Github messages for voidlinux
 help / color / mirror / Atom feed
* [PR PATCH] ffmpeg6 split
@ 2023-05-05 13:20 zlice
  2023-05-05 13:27 ` [PR PATCH] [Updated] " zlice
                   ` (97 more replies)
  0 siblings, 98 replies; 99+ messages in thread
From: zlice @ 2023-05-05 13:20 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 2794 bytes --]

There is a new pull request by zlice against master on the void-packages repository

https://github.com/zlice/void-packages ffmpeg6-split
https://github.com/void-linux/void-packages/pull/43761

ffmpeg6 split
[ci skip]


#### Testing the changes

- I tested the changes in this PR: **YES**

main testing has been vaapi in Firefox Nightly and enc/dec in Shotcut on Intel A770

#### New package

- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**

#### Local build testing

- I built this PR locally for my native architecture, **x86_64**

#### Discussion

Continuation of https://github.com/void-linux/void-packages/pull/36315

`libavresample` is deprecated, but marked as a dependency when trying to build other packages and install `ffmpeg`(5). I think the right way to handle this is make a meta package and the add to removals?


##### Commit naming / misc

Commits are 'dirty' right now, running with [gstreamer 1.22.1 updates](https://github.com/void-linux/void-packages/pull/42861) and [Intel OpenCL](https://github.com/void-linux/void-packages/pull/43084). This will also make [intel packages pr](https://github.com/void-linux/void-packages/pull/41132) obsolete.

Maintainer for previous ffmpeg(4) was orphaned, I can put my name in there if that matters, though I don't exactly see myself keeping up on ffmpeg.

This updates QT5 which looks like it is usually hosted by Johnny. Not sure if there's any reason to stay there or these sources are fine.

##### STILL FFMPEG4

These are a mix of emulators, games and/or older packages.

- attract (multiple patches in master)
- audacity  (3.2.x should work but void is missing some libs? vst3sdk?)
- ccextractor (master patches? no release)
- vice
- kodi
- mlt
- synfig (mlt)
- tvheadend
- ssr
- spek-alternative
- ppsspp
- olive
- moc
- mediastreamer
- libextractor
- idjc
- hedgewars
- ffmpegthumbnailer
- ffmpegthumbs
- deadbeef
- omxplayer
- qtav (fork has ffmpeg 5 patch - https://github.com/cmguo/QtAV)
- `vlc` (vlc4 will support ffmpeg5, there's a patch to build 3.x with ffmpeg5 but it will lack vaapi)
- `osg` (OpenSceneGraph plus `xine-lib`)
- `ytmdl` ? not sure but it uses `python3-ffmpeg-python` which being 6-8yr old I imagine is ffmpeg4


##### HAVE NOT BUILT YET

- omxplayer (rpi only?)
- kodi (big, but ffmpeg4)


##### UPDATED (for ffmpeg5)

- unpaper: update to 7.0.0.
- guvcview: update to 2.0.8.
- qt5: update to 5.15.8
- qt5-webengine: update to 5.18.13
- shiboken2: revbump for qt5.15.8 (patch)
- python3-pyside2: update to 5.15.8 (patch)


A patch file from https://github.com/void-linux/void-packages/pull/43761.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ffmpeg6-split-43761.patch --]
[-- Type: text/x-diff, Size: 822512 bytes --]

From 6d537689f78de1b6595fed56dcb67c7a180b5fbf Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:55:46 -0400
Subject: [PATCH 001/140] ffmpeg: update to 6.0.

---
 common/shlibs                                 | 26 +++++---
 srcpkgs/ffmpeg/files/altivec.patch            | 60 -------------------
 .../patches/armv5tel-floating-point.patch     | 18 ------
 .../workaround-mesa-readeon-vaapi-bug.patch   | 28 ---------
 srcpkgs/ffmpeg/template                       | 31 +++++-----
 5 files changed, 33 insertions(+), 130 deletions(-)
 delete mode 100644 srcpkgs/ffmpeg/files/altivec.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch

diff --git a/common/shlibs b/common/shlibs
index 8c47e79b8c43..d650f2a3045d 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -390,15 +390,23 @@ libid3tag.so.0 libid3tag-0.15.1b_1
 libgif.so.7 giflib-5.1.0_1
 libImlib2.so.1 imlib2-1.4.2_1
 libmp3lame.so.0 lame-3.98.2_1
-libavdevice.so.58 libavdevice-4.0_1
-libavformat.so.58 libavformat-4.0_1
-libswscale.so.5 libswscale-4.0_1
-libswresample.so.3 libswresample-4.0_1
-libavresample.so.4 libavresample-4.0_1
-libpostproc.so.55 libpostproc-4.0_1
-libavcodec.so.58 libavcodec-4.0_1
-libavutil.so.56 libavutil-4.0_1
-libavfilter.so.7 libavfilter-4.0_1
+libavdevice.so.60 libavdevice-6.0_1
+libavformat.so.60 libavformat-6.0_1
+libswscale.so.7 libswscale-6.0_1
+libswresample.so.4 libswresample-6.0_1
+libpostproc.so.57 libpostproc-6.0_1
+libavcodec.so.60 libavcodec-6.0_1
+libavutil.so.58 libavutil-6.0_1
+libavfilter.so.9 libavfilter-6.0_1
+libavdevice.so.58 libavdevice4-4.0_1
+libavformat.so.58 libavformat4-4.0_1
+libswscale.so.5 libswscale4-4.0_1
+libswresample.so.3 libswresample4-4.0_1
+libavresample.so.4 libavresample4-4.0_1
+libpostproc.so.55 libpostproc4-4.0_1
+libavcodec.so.58 libavcodec4-4.0_1
+libavutil.so.56 libavutil4-4.0_1
+libavfilter.so.7 libavfilter4-4.0_1
 libSDL-1.2.so.0 SDL-1.2.14_1
 libSDL_image-1.2.so.0 SDL_image-1.2.10_1
 libx264.so.157 x264-20190507.2245_1
diff --git a/srcpkgs/ffmpeg/files/altivec.patch b/srcpkgs/ffmpeg/files/altivec.patch
deleted file mode 100644
index 9c5720046332..000000000000
--- a/srcpkgs/ffmpeg/files/altivec.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-revert some altivec specific change on all ppc* except ppc64le*
-
-q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
-conditionally, for ppc* but not ppc64le* (the new code is valid for
-POWER8 VSX which LE targets as a baseline but not BE)"
-
-
-This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
----
- libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
- 1 file changed, 20 insertions(+), 4 deletions(-)
-
-diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
-index 536545293d..c1e2852adb 100644
---- a/libswscale/ppc/yuv2rgb_altivec.c
-+++ b/libswscale/ppc/yuv2rgb_altivec.c
-@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-     vector signed short R1, G1, B1;                                           \
-     vector unsigned char R, G, B;                                             \
-                                                                               \
-+    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
-+    vector unsigned char align_perm;                                          \
-+                                                                              \
-     vector signed short lCY       = c->CY;                                    \
-     vector signed short lOY       = c->OY;                                    \
-     vector signed short lCRV      = c->CRV;                                   \
-@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
-                                                                               \
-         for (j = 0; j < w / 16; j++) {                                        \
--            y0 = vec_xl(0, y1i);                                              \
-+            y1ivP = (const vector unsigned char *) y1i;                       \
-+            y2ivP = (const vector unsigned char *) y2i;                       \
-+            uivP  = (const vector unsigned char *) ui;                        \
-+            vivP  = (const vector unsigned char *) vi;                        \
-+                                                                              \
-+            align_perm = vec_lvsl(0, y1i);                                    \
-+            y0 = (vector unsigned char)                                       \
-+                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
-                                                                               \
--            y1 = vec_xl(0, y2i);                                              \
-+            align_perm = vec_lvsl(0, y2i);                                    \
-+            y1 = (vector unsigned char)                                       \
-+                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
-                                                                               \
--            u = (vector signed char) vec_xl(0, ui);                           \
-+            align_perm = vec_lvsl(0, ui);                                     \
-+            u = (vector signed char)                                          \
-+                    vec_perm(uivP[0], uivP[1], align_perm);                   \
-                                                                               \
--            v = (vector signed char) vec_xl(0, vi);                           \
-+            align_perm = vec_lvsl(0, vi);                                     \
-+            v = (vector signed char)                                          \
-+                    vec_perm(vivP[0], vivP[1], align_perm);                   \
-                                                                               \
-             u = (vector signed char)                                          \
-                     vec_sub(u,                                                \
--- 
-2.27.0
-
diff --git a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
deleted file mode 100644
index 9a55178c74f0..000000000000
--- a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
-+++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
-@@ -39,6 +39,15 @@
- #endif
- #include <fenv.h>
- 
-+#if (FE_ALL_EXCEPT == 0)
-+/* E.g. ARM soft float does not define these */
-+#define FE_INVALID    0
-+#define FE_DIVBYZERO  0
-+#define FE_OVERFLOW   0
-+#define FE_UNDERFLOW  0
-+#define FE_INEXACT    0
-+#endif
-+
- #if CONFIG_LIBFONTCONFIG
- #include <fontconfig/fontconfig.h>
- #endif
diff --git a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
deleted file mode 100644
index 00e3f68a415b..000000000000
--- a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
-From: Rainer Hochecker <fernetmenta@online.de>
-Date: Sat, 26 Jan 2019 19:48:35 +0100
-Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
-
-This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
-It was hit frequently when watching h264 channels received via DVB-X.
-Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
----
- libavcodec/vaapi_h264.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
-index 5854587a255..f12fdc457a4 100644
---- a/libavcodec/vaapi_h264.c
-+++ b/libavcodec/vaapi_h264.c
-@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
-     H264SliceContext *sl = &h->slice_ctx[0];
-     int ret;
- 
-+    if (pic->nb_slices == 0) {
-+        ret = AVERROR_INVALIDDATA;
-+        goto finish;
-+    }
-+
-     ret = ff_vaapi_decode_issue(avctx, pic);
-     if (ret < 0)
-         goto finish;
diff --git a/srcpkgs/ffmpeg/template b/srcpkgs/ffmpeg/template
index 23a3d5c9967b..3d99e5173697 100644
--- a/srcpkgs/ffmpeg/template
+++ b/srcpkgs/ffmpeg/template
@@ -1,15 +1,15 @@
 # Template file for 'ffmpeg'
 # audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
 pkgname=ffmpeg
-version=4.4.3
-revision=2
+version=6.0
+revision=1
 short_desc="Decoding, encoding and streaming software"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="https://www.ffmpeg.org"
 changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
 distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
-checksum=6c5b6c195e61534766a0b5fe16acc919170c883362612816d0a1c7f4f947006e
+checksum=57be87c22d9b49c112b6d24bc67d42508660e6b718b3db89c44e47e289137082
 
 hostmakedepends="pkg-config perl yasm"
 makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
@@ -26,12 +26,13 @@ makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-deve
  $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
  $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
  $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
- $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers Vulkan-Tools Vulkan-ValidationLayers')
+ $(vopt_if onevpl 'onevpl onevpl-devel')
  $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
 depends="ffplay>=${version}_${revision}"
 
 build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
- dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec onevpl"
 build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
 desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
 desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
@@ -39,7 +40,8 @@ desc_option_sofa="Enable support for AES SOFA"
 desc_option_webp="Enable support for WebP"
 
 case "$XBPS_TARGET_MACHINE" in
-	i686*|x86_64*) build_options_default+=" vaapi vdpau nvenc nvdec";;
+	i686*) build_options_default+=" vaapi vdpau nvenc nvdec";;
+	x86_64*) build_options_default+=" vaapi vdpau nvenc nvdec onevpl";;
 	ppc64*) build_options_default+=" vaapi vdpau";;
 	mips*) CFLAGS="-mnan=legacy";;
 esac
@@ -114,18 +116,19 @@ do_configure() {
 		$(vopt_enable x265 libx265) \
 		$(vopt_enable v4l2 libv4l2) \
 		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
-		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		--enable-libbs2b --enable-libvidstab \
 		$(vopt_enable dav1d libdav1d) \
 		$(vopt_enable zimg libzimg) \
 		$(vopt_enable webp libwebp) \
 		$(vopt_enable sofa libmysofa) \
 		$(vopt_enable vulkan) \
+		$(vopt_enable onevpl libvpl) \
 		$(vopt_enable drm libdrm) \
 		$(vopt_enable svtav1 libsvtav1) \
 		$(vopt_enable srt libsrt) \
 		$(vopt_enable rist librist) \
-		$(vopt_if nvenc '--enable-nvenc') \
-		$(vopt_if nvdec '--enable-nvdec')
+		$(vopt_enable nvenc nvenc) \
+		$(vopt_enable nvdec nvdec)
 }
 do_build() {
 	make ${makejobs}
@@ -148,10 +151,8 @@ libavdevice_package() {
 	}
 }
 libavresample_package() {
-	short_desc="FFmpeg audio resampling library"
-	pkg_install() {
-		vmove "usr/lib/libavresample.so.*"
-	}
+	short_desc="Package deprecated, removal needed"
+	build_style=meta
 }
 libavformat_package() {
 	short_desc="FFmpeg file format library"
@@ -198,9 +199,9 @@ ffmpeg-devel_package() {
 		libavfilter>=${version}_${revision}
 		libpostproc>=${version}_${revision}
 		libswscale>=${version}_${revision}
-		libswresample>=${version}_${revision}
-		libavresample>=${version}_${revision}"
+		libswresample>=${version}_${revision}"
 	short_desc+=" - development files"
+	conflicts="ffmpeg4-devel"
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig

From 6f50791cd4cb463c5967e0c1431b987e1146b800 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:56:22 -0400
Subject: [PATCH 002/140] New package: ffmpeg4-4.4.3.

---
 srcpkgs/ffmpeg4-devel                         |   1 +
 srcpkgs/ffmpeg4/files/altivec.patch           |  60 +++++
 .../patches/armv5tel-floating-point.patch     |  18 ++
 .../workaround-mesa-readeon-vaapi-bug.patch   |  28 +++
 srcpkgs/ffmpeg4/template                      | 214 ++++++++++++++++++
 srcpkgs/libavcodec4                           |   1 +
 srcpkgs/libavdevice4                          |   1 +
 srcpkgs/libavfilter4                          |   1 +
 srcpkgs/libavformat4                          |   1 +
 srcpkgs/libavresample4                        |   1 +
 srcpkgs/libavutil4                            |   1 +
 srcpkgs/libpostproc4                          |   1 +
 srcpkgs/libswresample4                        |   1 +
 srcpkgs/libswscale4                           |   1 +
 14 files changed, 330 insertions(+)
 create mode 120000 srcpkgs/ffmpeg4-devel
 create mode 100644 srcpkgs/ffmpeg4/files/altivec.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
 create mode 100644 srcpkgs/ffmpeg4/template
 create mode 120000 srcpkgs/libavcodec4
 create mode 120000 srcpkgs/libavdevice4
 create mode 120000 srcpkgs/libavfilter4
 create mode 120000 srcpkgs/libavformat4
 create mode 120000 srcpkgs/libavresample4
 create mode 120000 srcpkgs/libavutil4
 create mode 120000 srcpkgs/libpostproc4
 create mode 120000 srcpkgs/libswresample4
 create mode 120000 srcpkgs/libswscale4

diff --git a/srcpkgs/ffmpeg4-devel b/srcpkgs/ffmpeg4-devel
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/ffmpeg4-devel
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/ffmpeg4/files/altivec.patch b/srcpkgs/ffmpeg4/files/altivec.patch
new file mode 100644
index 000000000000..9c5720046332
--- /dev/null
+++ b/srcpkgs/ffmpeg4/files/altivec.patch
@@ -0,0 +1,60 @@
+revert some altivec specific change on all ppc* except ppc64le*
+
+q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
+conditionally, for ppc* but not ppc64le* (the new code is valid for
+POWER8 VSX which LE targets as a baseline but not BE)"
+
+
+This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
+---
+ libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
+ 1 file changed, 20 insertions(+), 4 deletions(-)
+
+diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
+index 536545293d..c1e2852adb 100644
+--- a/libswscale/ppc/yuv2rgb_altivec.c
++++ b/libswscale/ppc/yuv2rgb_altivec.c
+@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+     vector signed short R1, G1, B1;                                           \
+     vector unsigned char R, G, B;                                             \
+                                                                               \
++    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
++    vector unsigned char align_perm;                                          \
++                                                                              \
+     vector signed short lCY       = c->CY;                                    \
+     vector signed short lOY       = c->OY;                                    \
+     vector signed short lCRV      = c->CRV;                                   \
+@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
+                                                                               \
+         for (j = 0; j < w / 16; j++) {                                        \
+-            y0 = vec_xl(0, y1i);                                              \
++            y1ivP = (const vector unsigned char *) y1i;                       \
++            y2ivP = (const vector unsigned char *) y2i;                       \
++            uivP  = (const vector unsigned char *) ui;                        \
++            vivP  = (const vector unsigned char *) vi;                        \
++                                                                              \
++            align_perm = vec_lvsl(0, y1i);                                    \
++            y0 = (vector unsigned char)                                       \
++                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
+                                                                               \
+-            y1 = vec_xl(0, y2i);                                              \
++            align_perm = vec_lvsl(0, y2i);                                    \
++            y1 = (vector unsigned char)                                       \
++                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
+                                                                               \
+-            u = (vector signed char) vec_xl(0, ui);                           \
++            align_perm = vec_lvsl(0, ui);                                     \
++            u = (vector signed char)                                          \
++                    vec_perm(uivP[0], uivP[1], align_perm);                   \
+                                                                               \
+-            v = (vector signed char) vec_xl(0, vi);                           \
++            align_perm = vec_lvsl(0, vi);                                     \
++            v = (vector signed char)                                          \
++                    vec_perm(vivP[0], vivP[1], align_perm);                   \
+                                                                               \
+             u = (vector signed char)                                          \
+                     vec_sub(u,                                                \
+-- 
+2.27.0
+
diff --git a/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
new file mode 100644
index 000000000000..9a55178c74f0
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
@@ -0,0 +1,18 @@
+--- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
++++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
+@@ -39,6 +39,15 @@
+ #endif
+ #include <fenv.h>
+ 
++#if (FE_ALL_EXCEPT == 0)
++/* E.g. ARM soft float does not define these */
++#define FE_INVALID    0
++#define FE_DIVBYZERO  0
++#define FE_OVERFLOW   0
++#define FE_UNDERFLOW  0
++#define FE_INEXACT    0
++#endif
++
+ #if CONFIG_LIBFONTCONFIG
+ #include <fontconfig/fontconfig.h>
+ #endif
diff --git a/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
new file mode 100644
index 000000000000..00e3f68a415b
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
@@ -0,0 +1,28 @@
+From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
+From: Rainer Hochecker <fernetmenta@online.de>
+Date: Sat, 26 Jan 2019 19:48:35 +0100
+Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
+
+This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
+It was hit frequently when watching h264 channels received via DVB-X.
+Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
+---
+ libavcodec/vaapi_h264.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
+index 5854587a255..f12fdc457a4 100644
+--- a/libavcodec/vaapi_h264.c
++++ b/libavcodec/vaapi_h264.c
+@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
+     H264SliceContext *sl = &h->slice_ctx[0];
+     int ret;
+ 
++    if (pic->nb_slices == 0) {
++        ret = AVERROR_INVALIDDATA;
++        goto finish;
++    }
++
+     ret = ff_vaapi_decode_issue(avctx, pic);
+     if (ret < 0)
+         goto finish;
diff --git a/srcpkgs/ffmpeg4/template b/srcpkgs/ffmpeg4/template
new file mode 100644
index 000000000000..7bc64bb39f41
--- /dev/null
+++ b/srcpkgs/ffmpeg4/template
@@ -0,0 +1,214 @@
+# Template file for 'ffmpeg4'
+# audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
+pkgname=ffmpeg4
+version=4.4.3
+revision=1
+short_desc="Decoding, encoding and streaming software - ffmpeg4 libraries only"
+maintainer="Orphaned <orphan@voidlinux.org>"
+license="GPL-3.0-or-later"
+homepage="https://www.ffmpeg.org"
+changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
+distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
+checksum=6c5b6c195e61534766a0b5fe16acc919170c883362612816d0a1c7f4f947006e
+
+hostmakedepends="pkg-config perl yasm"
+makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
+ libXext-devel libXvMC-devel libxcb-devel lame-devel libtheora-devel
+ libvorbis-devel x264-devel xvidcore-devel jack-devel SDL2-devel
+ libcdio-paranoia-devel librtmp-devel libmodplug-devel gnutls-devel
+ speex-devel celt-devel harfbuzz-devel libass-devel opus-devel ocl-icd-devel
+ libbs2b-devel libvidstab-devel $(vopt_if pulseaudio pulseaudio-devel)
+ $(vopt_if vaapi libva-devel) $(vopt_if vdpau libvdpau-devel)
+ $(vopt_if x265 x265-devel) $(vopt_if v4l2 v4l-utils-devel)
+ $(vopt_if fdk_aac fdk-aac-devel) $(vopt_if vpx libvpx-devel)
+ $(vopt_if aom libaom-devel) $(vopt_if sndio sndio-devel)
+ $(vopt_if dav1d libdav1d-devel) $(vopt_if zimg zimg-devel)
+ $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
+ $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
+ $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
+
+build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
+
+desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
+desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
+desc_option_sofa="Enable support for AES SOFA"
+desc_option_webp="Enable support for WebP"
+
+case "$XBPS_TARGET_MACHINE" in
+	i686*|x86_64*) build_options_default+=" vaapi vdpau nvenc nvdec";;
+	ppc64*) build_options_default+=" vaapi vdpau";;
+	mips*) CFLAGS="-mnan=legacy";;
+esac
+
+if [ "$XBPS_TARGET_WORDSIZE" != "32" ]; then
+	build_options_default+=" svtav1"
+fi
+
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+fi
+
+_apply_patch() {
+	local args="$1" pname="$(basename $2)"
+
+	if [ ! -f ".${pname}_done" ]; then
+		patch -N $args -i $2
+		touch .${pname}_done
+	fi
+}
+
+post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64le*) ;;
+		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
+	esac
+}
+
+do_configure() {
+	# Fix gcc on x86_64-musl only
+	if [ "$XBPS_TARGET_MACHINE" = "x86_64-musl" ]; then
+		sed -i configure -e "s;_cflags_speed='-O3';_cflags_speed='-O2';"
+	fi
+
+	if [ "$CROSS_BUILD" ]; then
+		case "$XBPS_TARGET_MACHINE" in
+			arm*) _arch="arm";;
+			aarch64*) _arch="aarch64";;
+			mips*) _arch="mips";;
+			ppc64*) _arch="ppc64";;
+			ppc*) _arch="ppc";;
+			*) _arch="${XBPS_TARGET_MACHINE%%-musl}";;
+		esac
+
+		_args+=" --enable-cross-compile
+			--sysroot=$XBPS_CROSS_BASE
+			--cross-prefix=${XBPS_CROSS_TRIPLET}-
+			--target-os=linux --arch=${_arch}"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc|ppc-musl) _args+=" --disable-altivec";;
+	esac
+
+	if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+		_args+=" --extra-libs=-latomic"
+	fi
+
+	./configure --prefix=/usr --disable-debug --enable-gpl --enable-gnutls \
+		--disable-stripping \
+		--enable-libcdio --enable-version3 --enable-runtime-cpudetect \
+		--enable-libmp3lame --enable-libvorbis --enable-libxvid \
+		--enable-libx264 $(vopt_enable vpx libvpx) --enable-libtheora \
+		--enable-shared --enable-static --enable-libxcb \
+		$(vopt_enable pulseaudio libpulse) --enable-libfreetype --enable-libmodplug \
+		--enable-libspeex --enable-libcelt --enable-libass \
+		--enable-libopus --enable-librtmp --enable-libjack \
+		$(vopt_if fdk_aac '--enable-nonfree --enable-libfdk-aac') \
+		--disable-libopencore_amrnb --disable-libopencore_amrwb \
+		--disable-libopenjpeg \
+		--enable-postproc --enable-opencl ${_args} \
+		$(vopt_enable x265 libx265) \
+		$(vopt_enable v4l2 libv4l2) \
+		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
+		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		$(vopt_enable dav1d libdav1d) \
+		$(vopt_enable zimg libzimg) \
+		$(vopt_enable webp libwebp) \
+		$(vopt_enable sofa libmysofa) \
+		$(vopt_enable vulkan) \
+		$(vopt_enable drm libdrm) \
+		$(vopt_enable svtav1 libsvtav1) \
+		$(vopt_enable srt libsrt) \
+		$(vopt_enable rist librist) \
+		$(vopt_if nvenc '--enable-nvenc') \
+		$(vopt_if nvdec '--enable-nvdec')
+}
+do_build() {
+	make ${makejobs}
+	make doc/ff{mpeg,play}.1
+}
+do_install() {
+	make DESTDIR=${DESTDIR} install install-man
+	rm -rf ${DESTDIR}/usr/bin
+}
+
+libavcodec4_package() {
+	short_desc="FFmpeg codec library"
+	pkg_install() {
+		vmove "usr/lib/libavcodec.so.*"
+	}
+}
+libavdevice4_package() {
+	short_desc="FFmpeg device handling library"
+	pkg_install() {
+		vmove "usr/lib/libavdevice.so.*"
+	}
+}
+libavresample4_package() {
+	short_desc="FFmpeg audio resampling library"
+	pkg_install() {
+		vmove "usr/lib/libavresample.so.*"
+	}
+}
+libavformat4_package() {
+	short_desc="FFmpeg file format library"
+	pkg_install() {
+		vmove "usr/lib/libavformat.so.*"
+	}
+}
+libavutil4_package() {
+	short_desc="FFmpeg utility library"
+	pkg_install() {
+		vmove "usr/lib/libavutil.so.*"
+	}
+}
+libavfilter4_package() {
+	short_desc="FFmpeg audio/video filter library"
+	pkg_install() {
+		vmove "usr/lib/libavfilter.so.*"
+	}
+}
+libpostproc4_package() {
+	short_desc="FFmpeg video postprocessing library"
+	pkg_install() {
+		vmove "usr/lib/libpostproc.so.*"
+	}
+}
+libswscale4_package() {
+	short_desc="FFmpeg video scaling library"
+	pkg_install() {
+		vmove "usr/lib/libswscale.so.*"
+	}
+}
+libswresample4_package() {
+	short_desc="FFmpeg video resampling library"
+	pkg_install() {
+		vmove "usr/lib/libswresample.so.*"
+	}
+}
+ffmpeg4-devel_package() {
+	depends="
+		libavcodec4>=${version}_${revision}
+		libavdevice4>=${version}_${revision}
+		libavformat4>=${version}_${revision}
+		libavutil4>=${version}_${revision}
+		libavfilter4>=${version}_${revision}
+		libpostproc4>=${version}_${revision}
+		libswscale4>=${version}_${revision}
+		libswresample4>=${version}_${revision}
+		libavresample4>=${version}_${revision}"
+	short_desc+=" - development files"
+	conflicts="ffmpeg-devel"
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove usr/lib/*.a
+		vmove usr/lib/*.so
+		vmove usr/share/ffmpeg/examples
+		vmove usr/share/man/man3
+	}
+}
diff --git a/srcpkgs/libavcodec4 b/srcpkgs/libavcodec4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavcodec4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavdevice4 b/srcpkgs/libavdevice4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavdevice4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavfilter4 b/srcpkgs/libavfilter4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavfilter4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavformat4 b/srcpkgs/libavformat4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavformat4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavresample4 b/srcpkgs/libavresample4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavutil4 b/srcpkgs/libavutil4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavutil4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libpostproc4 b/srcpkgs/libpostproc4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libpostproc4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswresample4 b/srcpkgs/libswresample4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libswresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswscale4 b/srcpkgs/libswscale4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libswscale4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file

From b456cf2f2dcb036c8810093de5929d40df8c7c7d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:04 -0400
Subject: [PATCH 003/140] opencv: update to 4.7.0.

---
 common/shlibs           | 104 ++++++++++++++++++++--------------------
 srcpkgs/opencv/template |   8 ++--
 2 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index d650f2a3045d..4626cfda810b 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2137,58 +2137,58 @@ libcapstone.so.4 capstone-4.0_1
 libhavege.so.2 libhaveged-1.9.11_1
 libnih.so.1 libnih-1.0.3_1
 libnih-dbus.so.1 libnih-1.0.3_1
-libopencv_quality.so.406 libopencv-4.6.0_1
-libopencv_reg.so.406 libopencv-4.6.0_1
-libopencv_surface_matching.so.406 libopencv-4.6.0_1
-libopencv_xphoto.so.406 libopencv-4.6.0_1
-libopencv_freetype.so.406 libopencv-4.6.0_1
-libopencv_fuzzy.so.406 libopencv-4.6.0_1
-libopencv_hfs.so.406 libopencv-4.6.0_1
-libopencv_img_hash.so.406 libopencv-4.6.0_1
-libopencv_line_descriptor.so.406 libopencv-4.6.0_1
-libopencv_saliency.so.406 libopencv-4.6.0_1
-libopencv_structured_light.so.406 libopencv-4.6.0_1
-libopencv_aruco.so.406 libopencv-4.6.0_1
-libopencv_bgsegm.so.406 libopencv-4.6.0_1
-libopencv_bioinspired.so.406 libopencv-4.6.0_1
-libopencv_ccalib.so.406 libopencv-4.6.0_1
-libopencv_face.so.406 libopencv-4.6.0_1
-libopencv_tracking.so.406 libopencv-4.6.0_1
-libopencv_xfeatures2d.so.406 libopencv-4.6.0_1
-libopencv_optflow.so.406 libopencv-4.6.0_1
-libopencv_ximgproc.so.406 libopencv-4.6.0_1
-libopencv_plot.so.406 libopencv-4.6.0_1
-libopencv_text.so.406 libopencv-4.6.0_1
-libopencv_ml.so.406 libopencv-4.6.0_1
-libopencv_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn.so.406 libopencv-4.6.0_1
-libopencv_shape.so.406 libopencv-4.6.0_1
-libopencv_stitching.so.406 libopencv-4.6.0_1
-libopencv_photo.so.406 libopencv-4.6.0_1
-libopencv_video.so.406 libopencv-4.6.0_1
-libopencv_calib3d.so.406 libopencv-4.6.0_1
-libopencv_features2d.so.406 libopencv-4.6.0_1
-libopencv_flann.so.406 libopencv-4.6.0_1
-libopencv_highgui.so.406 libopencv-4.6.0_1
-libopencv_videoio.so.406 libopencv-4.6.0_1
-libopencv_imgcodecs.so.406 libopencv-4.6.0_1
-libopencv_imgproc.so.406 libopencv-4.6.0_1
-libopencv_core.so.406 libopencv-4.6.0_1
-libopencv_superres.so.406 libopencv-4.6.0_1
-libopencv_videostab.so.406 libopencv-4.6.0_1
-libopencv_gapi.so.406 libopencv-4.6.0_1
-libopencv_xobjdetect.so.406 libopencv-4.6.0_1
-libopencv_datasets.so.406 libopencv-4.6.0_1
-libopencv_dnn_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn_superres.so.406 libopencv-4.6.0_1
-libopencv_dpm.so.406 libopencv-4.6.0_1
-libopencv_phase_unwrapping.so.406 libopencv-4.6.0_1
-libopencv_stereo.so.406 libopencv-4.6.0_1
-libopencv_rapid.so.406 libopencv-4.6.0_1
-libopencv_intensity_transform.so.406 libopencv-4.6.0_1
-libopencv_alphamat.so.406 libopencv-4.6.0_1
-libopencv_barcode.so.406 libopencv-4.6.0_1
-libopencv_mcc.so.406 libopencv-4.6.0_1
+libopencv_quality.so.407 libopencv-4.7.0_1
+libopencv_reg.so.407 libopencv-4.7.0_1
+libopencv_surface_matching.so.407 libopencv-4.7.0_1
+libopencv_xphoto.so.407 libopencv-4.7.0_1
+libopencv_freetype.so.407 libopencv-4.7.0_1
+libopencv_fuzzy.so.407 libopencv-4.7.0_1
+libopencv_hfs.so.407 libopencv-4.7.0_1
+libopencv_img_hash.so.407 libopencv-4.7.0_1
+libopencv_line_descriptor.so.407 libopencv-4.7.0_1
+libopencv_saliency.so.407 libopencv-4.7.0_1
+libopencv_structured_light.so.407 libopencv-4.7.0_1
+libopencv_aruco.so.407 libopencv-4.7.0_1
+libopencv_bgsegm.so.407 libopencv-4.7.0_1
+libopencv_bioinspired.so.407 libopencv-4.7.0_1
+libopencv_ccalib.so.407 libopencv-4.7.0_1
+libopencv_face.so.407 libopencv-4.7.0_1
+libopencv_tracking.so.407 libopencv-4.7.0_1
+libopencv_xfeatures2d.so.407 libopencv-4.7.0_1
+libopencv_optflow.so.407 libopencv-4.7.0_1
+libopencv_ximgproc.so.407 libopencv-4.7.0_1
+libopencv_plot.so.407 libopencv-4.7.0_1
+libopencv_text.so.407 libopencv-4.7.0_1
+libopencv_ml.so.407 libopencv-4.7.0_1
+libopencv_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn.so.407 libopencv-4.7.0_1
+libopencv_shape.so.407 libopencv-4.7.0_1
+libopencv_stitching.so.407 libopencv-4.7.0_1
+libopencv_photo.so.407 libopencv-4.7.0_1
+libopencv_video.so.407 libopencv-4.7.0_1
+libopencv_calib3d.so.407 libopencv-4.7.0_1
+libopencv_features2d.so.407 libopencv-4.7.0_1
+libopencv_flann.so.407 libopencv-4.7.0_1
+libopencv_highgui.so.407 libopencv-4.7.0_1
+libopencv_videoio.so.407 libopencv-4.7.0_1
+libopencv_imgcodecs.so.407 libopencv-4.7.0_1
+libopencv_imgproc.so.407 libopencv-4.7.0_1
+libopencv_core.so.407 libopencv-4.7.0_1
+libopencv_superres.so.407 libopencv-4.7.0_1
+libopencv_videostab.so.407 libopencv-4.7.0_1
+libopencv_gapi.so.407 libopencv-4.7.0_1
+libopencv_xobjdetect.so.407 libopencv-4.7.0_1
+libopencv_datasets.so.407 libopencv-4.7.0_1
+libopencv_dnn_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn_superres.so.407 libopencv-4.7.0_1
+libopencv_dpm.so.407 libopencv-4.7.0_1
+libopencv_phase_unwrapping.so.407 libopencv-4.7.0_1
+libopencv_stereo.so.407 libopencv-4.7.0_1
+libopencv_rapid.so.407 libopencv-4.7.0_1
+libopencv_intensity_transform.so.407 libopencv-4.7.0_1
+libopencv_alphamat.so.407 libopencv-4.7.0_1
+libopencv_barcode.so.407 libopencv-4.7.0_1
+libopencv_mcc.so.407 libopencv-4.7.0_1
 libuniconf.so.4.6 wvstreams-4.6.1_20
 libwvbase.so.4.6 wvstreams-4.6.1_20
 libwvutils.so.4.6 wvstreams-4.6.1_20
diff --git a/srcpkgs/opencv/template b/srcpkgs/opencv/template
index 69c635b1ad2b..41f3183f1582 100644
--- a/srcpkgs/opencv/template
+++ b/srcpkgs/opencv/template
@@ -1,7 +1,7 @@
 # Template file for 'opencv'
 pkgname=opencv
-version=4.6.0
-revision=4
+version=4.7.0
+revision=1
 create_wrksrc=yes
 build_wrksrc=${pkgname}-${version}
 build_style=cmake
@@ -24,8 +24,8 @@ homepage="https://opencv.org"
 changelog="https://github.com/opencv/opencv/wiki/ChangeLog"
 distfiles="https://github.com/opencv/opencv/archive/${version}.tar.gz
  https://github.com/opencv/opencv_contrib/archive/${version}.tar.gz>contrib.tar.gz"
-checksum="1ec1cba65f9f20fe5a41fda1586e01c70ea0c9a6d7b67c9e13edf0cfe2239277
- 1777d5fd2b59029cf537e5fd6f8aa68d707075822f90bde683fcde086f85f7a7"
+checksum="8df0079cdbe179748a18d44731af62a245a45ebf5085223dc03133954c662973
+ 42df840cf9055e59d0e22c249cfb19f04743e1bdad113d31b1573d3934d62584"
 patch_args="-Np1 -d ${build_wrksrc}"
 # tests hang indenfinitely, even with test data included
 make_check=no

From 98ba394049b5ff00dbacf97220c2c2692eafc4b1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 004/140] actiona: revbump for opencv-4.7.0

---
 srcpkgs/actiona/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/actiona/template b/srcpkgs/actiona/template
index cf5f0b7a2ae6..0d899311e6df 100644
--- a/srcpkgs/actiona/template
+++ b/srcpkgs/actiona/template
@@ -1,7 +1,7 @@
 # Template file for 'actiona'
 pkgname=actiona
 version=3.10.1
-revision=2
+revision=3
 build_style=qmake
 configure_args="PKGCONFIG_OPENCV=opencv4"
 hostmakedepends="pkg-config qt5-plugin-mysql qt5-qmake qt5-host-tools"

From 032bfac6e8d4086b7fa313de4952eaee56405e9f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 005/140] gmic: revbump for opencv-4.7.0

---
 srcpkgs/gmic/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gmic/template b/srcpkgs/gmic/template
index 24a9c7218fdf..0bb4034d5cc8 100644
--- a/srcpkgs/gmic/template
+++ b/srcpkgs/gmic/template
@@ -1,7 +1,7 @@
 # Template file for 'gmic'
 pkgname=gmic
 version=3.1.6
-revision=3
+revision=4
 _zart_hash=34ebf6cce0bafb98abe57cec83c4a02cd1abeca0
 create_wrksrc=yes
 build_wrksrc="src"

From 325d5177879a203290498024126089d270eb12f0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 006/140] qimgv: revbump for opencv-4.7.0

---
 srcpkgs/qimgv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qimgv/template b/srcpkgs/qimgv/template
index 7eb30db33992..dd341dfe1bfc 100644
--- a/srcpkgs/qimgv/template
+++ b/srcpkgs/qimgv/template
@@ -1,7 +1,7 @@
 # Template file for 'qimgv'
 pkgname=qimgv
 version=1.0.2
-revision=2
+revision=3
 build_style=cmake
 configure_args="$(vopt_if video -DVIDEO_SUPPORT=ON -DVIDEO_SUPPORT=OFF)
  $(vopt_if scale -DOPENCV_SUPPORT=ON -DOPENCV_SUPPORT=OFF)

From 816c3f26e0a7f0a6e6a9e6d2d862d93d389c87d6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 007/140] retroshare: revbump for opencv-4.7.0

---
 srcpkgs/retroshare/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroshare/template b/srcpkgs/retroshare/template
index 8a0786c21a08..72023fa98b75 100644
--- a/srcpkgs/retroshare/template
+++ b/srcpkgs/retroshare/template
@@ -1,7 +1,7 @@
 # Template file for 'retroshare'
 pkgname=retroshare
 version=0.6.6
-revision=2
+revision=4
 build_style=qmake
 #XXX broadcast feature requires an ancient udp-discovery-cpp which either needs
 # to be fetched+patched (FTBFS) here or packaged :/

From 199f93854a9ac7bd07d23bbd07cf04a19c4f7272 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 008/140] siril: revbump for opencv-4.7.0

---
 srcpkgs/siril/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/siril/template b/srcpkgs/siril/template
index e88f30fb6178..84332f79d060 100644
--- a/srcpkgs/siril/template
+++ b/srcpkgs/siril/template
@@ -1,7 +1,7 @@
 # Template file for 'siril'
 pkgname=siril
 version=0.9.12
-revision=9
+revision=10
 build_style=gnu-configure
 hostmakedepends="pkg-config intltool autoconf automake gettext-devel"
 makedepends="fftw-devel libconfig-devel libopencv-devel libffms2-devel

From 674f578a40f767aac1cb8add733a22679a88ab68 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 009/140] waifu2x-converter-cpp: revbump for opencv-4.7.0

---
 srcpkgs/waifu2x-converter-cpp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waifu2x-converter-cpp/template b/srcpkgs/waifu2x-converter-cpp/template
index 8c095d0d7bab..aa52d8c981a8 100644
--- a/srcpkgs/waifu2x-converter-cpp/template
+++ b/srcpkgs/waifu2x-converter-cpp/template
@@ -1,7 +1,7 @@
 # Template file for 'waifu2x-converter-cpp'
 pkgname=waifu2x-converter-cpp
 version=5.2.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DINSTALL_MODELS=ON"
 hostmakedepends="pkg-config"

From b50a3d189eef2ddf2fe36600d8b3b20082d90b06 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:38 -0400
Subject: [PATCH 010/140] vlc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/vlc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/vlc/template b/srcpkgs/vlc/template
index 210762b0a7e2..855ca5238662 100644
--- a/srcpkgs/vlc/template
+++ b/srcpkgs/vlc/template
@@ -1,7 +1,7 @@
 # Template file for 'vlc'
 pkgname=vlc
 version=3.0.18
-revision=3
+revision=4
 build_style=gnu-configure
 configure_args="--disable-gme --disable-libtar --enable-jack
  --enable-live555 --disable-fluidsynth --enable-dvdread
@@ -25,7 +25,7 @@ lib32disabled=yes
 hostmakedepends="automake libtool pkg-config flex gettext libgcrypt-devel
  live555-devel gettext-devel $(vopt_if lua lua52) $(vopt_if chromecast protobuf)"
 makedepends="
- avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg-devel freefont-ttf
+ avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg4-devel freefont-ttf
  gnutls-devel jack-devel liba52-devel libass-devel libbluray-devel
  libcdio-devel libdca-devel libdvbpsi-devel libdvdnav-devel libmad-devel
  libmatroska-devel libmodplug-devel libmpcdec-devel libmpeg2-devel

From 67e074dd1a4376ca7ecad28c6c810ec19b58a17d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:55 -0400
Subject: [PATCH 011/140] osg: revbump for ffmpeg4-4.4.3

---
 srcpkgs/osg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/osg/template b/srcpkgs/osg/template
index a9ebbd287933..755793f7e11b 100644
--- a/srcpkgs/osg/template
+++ b/srcpkgs/osg/template
@@ -8,7 +8,7 @@ build_helper="qemu"
 configure_args="-DLIB_POSTFIX="
 hostmakedepends="pkg-config xrandr"
 makedepends="MesaLib-devel gtkglext-devel libcurl-devel giflib-devel librsvg-devel
- jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg-devel xine-lib-devel
+ jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg4-devel xine-lib-devel
  SDL2-devel gst-plugins-base1-devel
  $(vopt_if openexr libopenexr-devel)
  $(vopt_if poppler poppler-glib-devel)

From a02d106ff6726a0ba03d6adac66e5e38e569a99c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:13 -0400
Subject: [PATCH 012/140] xine-lib: revbump for ffmpeg4-4.4.3

---
 srcpkgs/xine-lib/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/xine-lib/template b/srcpkgs/xine-lib/template
index f713eff49b07..ed6194c17d11 100644
--- a/srcpkgs/xine-lib/template
+++ b/srcpkgs/xine-lib/template
@@ -1,6 +1,6 @@
 # Template file for 'xine-lib'
 pkgname=xine-lib
-version=1.2.12
+version=1.2.13
 revision=1
 build_style=gnu-configure
 configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
@@ -8,7 +8,7 @@ configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
 hostmakedepends="automake gettext-devel libtool pkg-config perl"
 makedepends="
  zlib-devel alsa-lib-devel libxcb-devel libSM-devel libXext-devel libXv-devel
- libXvMC-devel liba52-devel libmad-devel ffmpeg-devel pulseaudio-devel
+ libXvMC-devel liba52-devel libmad-devel ffmpeg4-devel pulseaudio-devel
  jack-devel samba-devel libflac-devel libmodplug-devel libmpcdec-devel
  speex-devel libtheora-devel libvorbis-devel libdca-devel faad2-devel
  libcdio-devel libbluray-devel aalib-devel libcaca-devel libXinerama-devel
@@ -19,7 +19,7 @@ license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="http://www.xine-project.org"
 changelog="https://sourceforge.net/projects/xine/files/xine-lib/${version}/README.txt/view"
 distfiles="${SOURCEFORGE_SITE}/xine/${pkgname}-${version}.tar.xz"
-checksum=d606270468e1540c2a89c0d7f5fdf11e17ecc0c2698cc0bcb1065ff26abee098
+checksum=5f10d6d718a4a51c17ed1b32b031d4f9b80b061e8276535b2be31e5ac4b75e6f
 
 case "$XBPS_TARGET_MACHINE" in
 	i686-musl)

From 04e6e3455350981602b6bf9cac81e024bda83e72 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 013/140] QMPlay2: revbump for ffmpeg-6.0

---
 srcpkgs/QMPlay2/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/QMPlay2/template b/srcpkgs/QMPlay2/template
index ad73cbb01bae..55284c051161 100644
--- a/srcpkgs/QMPlay2/template
+++ b/srcpkgs/QMPlay2/template
@@ -1,7 +1,7 @@
 # Template file for 'QMPlay2'
 pkgname=QMPlay2
 version=23.02.05
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools"
 makedepends="alsa-lib-devel ffmpeg-devel libass-devel libcdio-devel libgme-devel

From 5fb396a304576e623150439ed6ffe40c1feaceeb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 014/140] alsa-plugins: revbump for ffmpeg-6.0

---
 srcpkgs/alsa-plugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/alsa-plugins/template b/srcpkgs/alsa-plugins/template
index 0bfa6d9fd264..a5708a7d82a8 100644
--- a/srcpkgs/alsa-plugins/template
+++ b/srcpkgs/alsa-plugins/template
@@ -1,7 +1,7 @@
 # Template file for 'alsa-plugins'
 pkgname=alsa-plugins
 version=1.2.7.1
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--disable-maemo-plugin"
 hostmakedepends="pkg-config"

From 45b6117de5bc18b8c4ccacc0ba51bf73a79facb9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 015/140] arcan: revbump for ffmpeg-6.0

---
 srcpkgs/arcan/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/arcan/template b/srcpkgs/arcan/template
index 7be9652eccf3..ccc7df11ceac 100644
--- a/srcpkgs/arcan/template
+++ b/srcpkgs/arcan/template
@@ -2,7 +2,7 @@
 # !! keep synced with: acfgfs aclip aloadimage
 pkgname=arcan
 version=0.6.2.1
-revision=1
+revision=2
 create_wrksrc=yes
 build_wrksrc=arcan/src
 build_style=cmake

From 7d7f17e2bd9358810d2f5323f078acac16b0dbef Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 016/140] attract: revbump for ffmpeg4-4.4.3

---
 srcpkgs/attract/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/attract/template b/srcpkgs/attract/template
index 26144e931a3c..e760bf0d18ae 100644
--- a/srcpkgs/attract/template
+++ b/srcpkgs/attract/template
@@ -1,12 +1,12 @@
 # Template file for 'attract'
 pkgname=attract
 version=2.6.2
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="VERBOSE=1"
 make_use_env=yes
 hostmakedepends="pkg-config"
-makedepends="SFML-devel ffmpeg-devel fontconfig-devel glu-devel libarchive-devel
+makedepends="SFML-devel ffmpeg4-devel fontconfig-devel glu-devel libarchive-devel
  libcurl-devel libjpeg-turbo-devel xine-lib rapidjson libXrandr-devel"
 depends="git"
 short_desc="Attract-Mode is a graphical frontend for emulators"

From 2e80b0c920f6311d77a8c4a05982d9476bfb0ba5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 017/140] aubio: revbump for ffmpeg-6.0

---
 srcpkgs/aubio/patches/ffmpeg5.patch | 25 +++++++++++++++++++++++++
 srcpkgs/aubio/template              |  2 +-
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/aubio/patches/ffmpeg5.patch

diff --git a/srcpkgs/aubio/patches/ffmpeg5.patch b/srcpkgs/aubio/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..aace41a6e6d9
--- /dev/null
+++ b/srcpkgs/aubio/patches/ffmpeg5.patch
@@ -0,0 +1,25 @@
+From 8a05420e5dd8c7b8b2447f82dc919765876511b3 Mon Sep 17 00:00:00 2001
+From: Paul Brossier <piem@piem.org>
+Date: Tue, 25 Jan 2022 18:30:27 +0100
+Subject: [PATCH] [source_avcodec] define FF_API_LAVF_AVCTX for libavcodec >
+ 59, thx @berolinux (closes gh-353)
+
+---
+ src/io/source_avcodec.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/io/source_avcodec.c b/src/io/source_avcodec.c
+index e0ae93b5..1421bd9a 100644
+--- a/src/io/source_avcodec.c
++++ b/src/io/source_avcodec.c
+@@ -68,6 +68,10 @@
+ #define AUBIO_AVCODEC_MAX_BUFFER_SIZE AV_INPUT_BUFFER_MIN_SIZE
+ #endif
+ 
++#if LIBAVCODEC_VERSION_MAJOR >= 59
++#define FF_API_LAVF_AVCTX 1
++#endif
++
+ struct _aubio_source_avcodec_t {
+   uint_t hop_size;
+   uint_t samplerate;
diff --git a/srcpkgs/aubio/template b/srcpkgs/aubio/template
index ad1c4b256991..7d875cc02541 100644
--- a/srcpkgs/aubio/template
+++ b/srcpkgs/aubio/template
@@ -1,7 +1,7 @@
 # Template file for 'aubio'
 pkgname=aubio
 version=0.4.9
-revision=1
+revision=2
 build_style=waf3
 # XXX lash, pure and swig support.
 hostmakedepends="pkg-config txt2man"

From 7fb01cc5e73a215422bd72f9fa8b5fc26c7400a1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 018/140] audacious-plugins: revbump for ffmpeg-6.0

---
 .../audacious-plugins/patches/ffmpeg5.patch   | 43 +++++++++++++++++++
 srcpkgs/audacious-plugins/template            |  2 +-
 2 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/audacious-plugins/patches/ffmpeg5.patch

diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg5.patch b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..4e5e34099d71
--- /dev/null
+++ b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
@@ -0,0 +1,43 @@
+commit 298aa371c56c2f52c25a33d9bdec4918b11cebdc
+Author: tibequadorian <tibequadorian@posteo.de>
+Date:   Sat Mar 19 18:40:12 2022 +0100
+
+    audacious-plugins: rebuild against ffmpeg-5.0
+
+diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+new file mode 100644
+index 0000000000..617c11215b
+--- /dev/null
++++ b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+@@ -0,0 +1,31 @@
++From f60beb400eeb1e4778bbfd738bc4a4ccef3de539 Mon Sep 17 00:00:00 2001
++From: John Lindgren <john@jlindgren.net>
++Date: Sat, 5 Mar 2022 12:05:34 -0500
++Subject: [PATCH] Fix build with FFmpeg 5.0
++
++---
++ src/ffaudio/ffaudio-core.cc | 4 ++--
++ 1 file changed, 2 insertions(+), 2 deletions(-)
++
++diff --git a/src/ffaudio/ffaudio-core.cc b/src/ffaudio/ffaudio-core.cc
++index 16dc63e3a..a2b95fd6c 100644
++--- a/src/ffaudio/ffaudio-core.cc
+++++ b/src/ffaudio/ffaudio-core.cc
++@@ -274,7 +274,7 @@ static AVInputFormat * get_format_by_content (const char * name, VFSFile & file)
++         AVProbeData d = {name, buf, filled};
++         score = target;
++ 
++-        f = av_probe_input_format2 (& d, true, & score);
+++        f = (AVInputFormat *) av_probe_input_format2 (& d, true, & score);
++         if (f)
++             break;
++ 
++@@ -347,7 +347,7 @@ static bool find_codec (AVFormatContext * c, CodecInfo * cinfo)
++ #endif
++         if (stream && stream->codecpar && stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
++         {
++-            AVCodec * codec = avcodec_find_decoder (stream->codecpar->codec_id);
+++            AVCodec * codec = (AVCodec *) avcodec_find_decoder (stream->codecpar->codec_id);
++ 
++             if (codec)
++             {
diff --git a/srcpkgs/audacious-plugins/template b/srcpkgs/audacious-plugins/template
index 88cbc1671fc6..beebfae59ed4 100644
--- a/srcpkgs/audacious-plugins/template
+++ b/srcpkgs/audacious-plugins/template
@@ -2,7 +2,7 @@
 #Keep in sync with audacious!
 pkgname=audacious-plugins
 version=4.3.1
-revision=1
+revision=2
 build_style=meson
 configure_args="$(vopt_bool gtk3 gtk) $(vopt_bool gtk3)
  $(vopt_bool qt) $(vopt_bool qt qt6)"

From c8955a13670baa12da2f68c6802e23bf5bdda641 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 019/140] audacity: revbump for ffmpeg4-4.4.3

---
 srcpkgs/audacity/template | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/audacity/template b/srcpkgs/audacity/template
index d509c0a89407..11e20255685b 100644
--- a/srcpkgs/audacity/template
+++ b/srcpkgs/audacity/template
@@ -1,7 +1,7 @@
 # Template file for 'audacity'
 pkgname=audacity
 version=2.4.1
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--with-ffmpeg=system --with-libsndfile=system --with-expat=system
  --with-libsoxr=system --with-lame=system --with-lv2=system ac_cv_path_WX_CONFIG=wx-config-gtk3"
@@ -9,7 +9,7 @@ hostmakedepends="pkg-config cmake gettext libtool m4 which"
 makedepends="jack-devel wxWidgets-gtk3-devel gtk+3-devel
  libmad-devel soundtouch-devel libsoxr-devel
  vamp-plugin-sdk-devel lame-devel libid3tag-devel libflac-devel
- ffmpeg-devel twolame-devel serd-devel lv2 lilv-devel suil-devel"
+ ffmpeg4-devel twolame-devel serd-devel lv2 lilv-devel suil-devel"
 depends="desktop-file-utils hicolor-icon-theme"
 short_desc="Graphical cross-platform audio editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
@@ -33,5 +33,4 @@ post_install() {
 	vcopy plug-ins /usr/share/audacity
 
 	rm ${DESTDIR}/usr/share/doc/audacity/LICENSE.txt
-	vlicense LICENSE.txt LICENSE
 }

From 145985c0b62ee4b1888332a5be8256d6adcb5dca Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 020/140] avidemux: revbump for ffmpeg-6.0

---
 srcpkgs/avidemux/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/avidemux/template b/srcpkgs/avidemux/template
index 253a0243e225..557285982d2b 100644
--- a/srcpkgs/avidemux/template
+++ b/srcpkgs/avidemux/template
@@ -1,7 +1,7 @@
 # Template file for 'avidemux'
 pkgname=avidemux
 version=2.8.0
-revision=2
+revision=3
 # Can't be compiled for aarch64, arm* or mips*
 archs="x86_64* i686*"
 hostmakedepends="cmake pkg-config qt5-host-tools qt5-devel tar yasm"

From 1b314054810e8de661612ee40015dc043141ae3f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 021/140] baresip: revbump for ffmpeg-6.0

---
 srcpkgs/baresip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/baresip/template b/srcpkgs/baresip/template
index f1bd1817048b..b21e22334316 100644
--- a/srcpkgs/baresip/template
+++ b/srcpkgs/baresip/template
@@ -1,7 +1,7 @@
 # Template file for 'baresip'
 pkgname=baresip
 version=2.10.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config glib-devel"
 makedepends="libgsm-devel libpng-devel openssl-devel libsndfile-devel

From fd55de773224302a44fb079fe9cf5f0913e9ce94 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 022/140] blender: revbump for ffmpeg-6.0

---
 .../patches/ffmpeg6-compat-blender.patch      | 42 +++++++++++++++++++
 srcpkgs/blender/template                      |  2 +-
 2 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/blender/patches/ffmpeg6-compat-blender.patch

diff --git a/srcpkgs/blender/patches/ffmpeg6-compat-blender.patch b/srcpkgs/blender/patches/ffmpeg6-compat-blender.patch
new file mode 100644
index 000000000000..d51a9c7710cc
--- /dev/null
+++ b/srcpkgs/blender/patches/ffmpeg6-compat-blender.patch
@@ -0,0 +1,42 @@
+--- a/source/blender/blenkernel/intern/writeffmpeg.c	2022-11-08 13:50:16 UTC
++++ b/source/blender/blenkernel/intern/writeffmpeg.c
+@@ -855,7 +855,7 @@ static AVStream *alloc_video_stream(FFMpegContext *con
+                                                             255);
+   st->avg_frame_rate = av_inv_q(c->time_base);
+ 
+-  if (codec->capabilities & AV_CODEC_CAP_AUTO_THREADS) {
++  if (codec->capabilities & AV_CODEC_CAP_OTHER_THREADS) {
+     c->thread_count = 0;
+   }
+   else {
+--- a/source/blender/imbuf/intern/anim_movie.c	2022-11-04 00:33:07 UTC
++++ b/source/blender/imbuf/intern/anim_movie.c
+@@ -554,7 +554,7 @@ static int startffmpeg(struct anim *anim)
+   avcodec_parameters_to_context(pCodecCtx, video_stream->codecpar);
+   pCodecCtx->workaround_bugs = FF_BUG_AUTODETECT;
+ 
+-  if (pCodec->capabilities & AV_CODEC_CAP_AUTO_THREADS) {
++  if (pCodec->capabilities & AV_CODEC_CAP_OTHER_THREADS) {
+     pCodecCtx->thread_count = 0;
+   }
+   else {
+--- a/source/blender/imbuf/intern/indexer.c	2022-11-04 00:33:07 UTC
++++ b/source/blender/imbuf/intern/indexer.c
+@@ -559,7 +559,7 @@ static struct proxy_output_ctx *alloc_proxy_output_ffm
+   av_dict_set(&codec_opts, "preset", "veryfast", 0);
+   av_dict_set(&codec_opts, "tune", "fastdecode", 0);
+ 
+-  if (rv->codec->capabilities & AV_CODEC_CAP_AUTO_THREADS) {
++  if (rv->codec->capabilities & AV_CODEC_CAP_OTHER_THREADS) {
+     rv->c->thread_count = 0;
+   }
+   else {
+@@ -872,7 +872,7 @@ static IndexBuildContext *index_ffmpeg_create_context(
+   avcodec_parameters_to_context(context->iCodecCtx, context->iStream->codecpar);
+   context->iCodecCtx->workaround_bugs = FF_BUG_AUTODETECT;
+ 
+-  if (context->iCodec->capabilities & AV_CODEC_CAP_AUTO_THREADS) {
++  if (context->iCodec->capabilities & AV_CODEC_CAP_OTHER_THREADS) {
+     context->iCodecCtx->thread_count = 0;
+   }
+   else {
diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index 61b42eb2e51e..d18bc88838ff 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -1,7 +1,7 @@
 # Template file for 'blender'
 pkgname=blender
 version=3.4.1
-revision=3
+revision=4
 archs="x86_64* ppc64*"
 build_style="cmake"
 pycompile_dirs="/usr/share/blender/${version%.*}/scripts"

From b5178e4e573e5b75627b166200152ee31412c182 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 023/140] cantata: revbump for ffmpeg-6.0

---
 srcpkgs/cantata/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cantata/template b/srcpkgs/cantata/template
index 4b417d80d5c2..8a90aaa4c07a 100644
--- a/srcpkgs/cantata/template
+++ b/srcpkgs/cantata/template
@@ -1,7 +1,7 @@
 # Template file for 'cantata'
 pkgname=cantata
 version=2.5.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools qt5-tools"
 makedepends="qt5-devel qt5-tools-devel qt5-svg-devel qt5-xmlpatterns-devel

From 59259d40817fa204e536d43c7e944132f9beba14 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 024/140] ccextractor: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ccextractor/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/ccextractor/template b/srcpkgs/ccextractor/template
index 9abcd82852b2..6eccad5885af 100644
--- a/srcpkgs/ccextractor/template
+++ b/srcpkgs/ccextractor/template
@@ -1,12 +1,12 @@
 # Template file for 'ccextractor'
 pkgname=ccextractor
 version=0.93
-revision=1
+revision=2
 build_wrksrc="linux"
 build_style=gnu-configure
 configure_args="--enable-ocr --enable-hardsubx"
 hostmakedepends="automake pkg-config"
-makedepends="leptonica-devel tesseract-ocr-devel ffmpeg-devel"
+makedepends="leptonica-devel tesseract-ocr-devel ffmpeg4-devel"
 short_desc="Extract subtitles from video streams"
 maintainer="newbluemoon <blaumolch@mailbox.org>"
 license="GPL-2.0-or-later"

From 4300dd323d02bba6a36b8b4a0a1be5ed85f25fdb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 025/140] chromaprint: revbump for ffmpeg-6.0

---
 srcpkgs/chromaprint/patches/ffmpeg5.patch | 569 ++++++++++++++++++++++
 srcpkgs/chromaprint/template              |   2 +-
 2 files changed, 570 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromaprint/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromaprint/patches/ffmpeg5.patch b/srcpkgs/chromaprint/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..a9fd307a23c8
--- /dev/null
+++ b/srcpkgs/chromaprint/patches/ffmpeg5.patch
@@ -0,0 +1,569 @@
+From 8ccad6937177b1b92e40ab8f4447ea27bac009a7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= <lalinsky@gmail.com>
+Date: Fri, 4 Nov 2022 21:47:38 +0100
+Subject: [PATCH] Use FFmpeg 5.x (#120)
+
+* Use FFmpeg 5.1.2 for CI builds
+
+* Build on Ubuntu 20.04
+
+* Upgrade code to FFmpeg 5.x APIs
+
+* Only set FFmpeg include dirs if building tools
+
+* No longer needed
+
+* Use ubuntu 20.04
+---
+ .github/workflows/build.yml                   |   6 +-
+ CMakeLists.txt                                |  16 --
+ package/build.sh                              |   4 +-
+ src/audio/ffmpeg_audio_processor.h            |   2 -
+ src/audio/ffmpeg_audio_processor_avresample.h |  72 -------
+ src/audio/ffmpeg_audio_processor_swresample.h |  18 +-
+ src/audio/ffmpeg_audio_reader.h               | 197 +++++++++---------
+ tests/CMakeLists.txt                          |   6 +
+ 8 files changed, 122 insertions(+), 199 deletions(-)
+ delete mode 100644 src/audio/ffmpeg_audio_processor_avresample.h
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index f8d6a32..4da2405 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -84,9 +84,6 @@ find_package(FFmpeg)
+ if(FFMPEG_LIBRARIES)
+ 	cmake_push_check_state(RESET)
+ 	set(CMAKE_REQUIRED_LIBRARIES ${FFMPEG_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -lm)
+-	check_function_exists(av_packet_unref HAVE_AV_PACKET_UNREF)
+-	check_function_exists(av_frame_alloc HAVE_AV_FRAME_ALLOC)
+-	check_function_exists(av_frame_free HAVE_AV_FRAME_FREE)
+ 	cmake_pop_check_state()
+ endif()
+
+@@ -163,14 +160,11 @@ message(STATUS "Using ${FFT_LIB} for FFT calculations")
+ if(NOT AUDIO_PROCESSOR_LIB)
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+ 		set(AUDIO_PROCESSOR_LIB "swresample")
+-	elseif(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(AUDIO_PROCESSOR_LIB "avresample")
+ 	endif()
+ endif()
+
+ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE OFF)
+ 		set(USE_SWRESAMPLE ON)
+ 		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBSWRESAMPLE_LIBRARIES})
+ 		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBSWRESAMPLE_INCLUDE_DIRS})
+@@ -178,16 +172,6 @@ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+ 	endif()
+ 	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+-elseif(AUDIO_PROCESSOR_LIB STREQUAL "avresample")
+-	if(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE ON)
+-		set(USE_SWRESAMPLE OFF)
+-		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBAVRESAMPLE_LIBRARIES})
+-		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBAVRESAMPLE_INCLUDE_DIRS})
+-	else()
+-		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+-	endif()
+-	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+ else()
+ 	message(STATUS "Building without audio conversion support, please install FFmpeg with libswresample")
+ endif()
+diff --git a/package/build.sh b/package/build.sh
+index da631ae..b41d36e 100755
+--- a/package/build.sh
++++ b/package/build.sh
+@@ -7,8 +7,8 @@ set -eux
+
+ BASE_DIR=$(cd $(dirname $0)/.. && pwd)
+
+-FFMPEG_VERSION=4.4.1
+-FFMPEG_BUILD_TAG=v4.4.1-1
++FFMPEG_VERSION=5.1.2
++FFMPEG_BUILD_TAG=v${FFMPEG_VERSION}-1
+
+ TMP_BUILD_DIR=$BASE_DIR/$(mktemp -d build.XXXXXXXX)
+ trap 'rm -rf $TMP_BUILD_DIR' EXIT
+diff --git a/src/audio/ffmpeg_audio_processor.h b/src/audio/ffmpeg_audio_processor.h
+index 7628fc7..39f4f6d 100644
+--- a/src/audio/ffmpeg_audio_processor.h
++++ b/src/audio/ffmpeg_audio_processor.h
+@@ -10,8 +10,6 @@
+
+ #if defined(USE_SWRESAMPLE)
+ #include "audio/ffmpeg_audio_processor_swresample.h"
+-#elif defined(USE_AVRESAMPLE)
+-#include "audio/ffmpeg_audio_processor_avresample.h"
+ #else
+ #error "no audio processing library"
+ #endif
+diff --git a/src/audio/ffmpeg_audio_processor_avresample.h b/src/audio/ffmpeg_audio_processor_avresample.h
+deleted file mode 100644
+index bd85f92..0000000
+--- a/src/audio/ffmpeg_audio_processor_avresample.h
++++ /dev/null
+@@ -1,72 +0,0 @@
+-// Copyright (C) 2016  Lukas Lalinsky
+-// Distributed under the MIT license, see the LICENSE file for details.
+-
+-#ifndef CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-#define CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-
+-extern "C" {
+-#include <libavresample/avresample.h>
+-}
+-
+-namespace chromaprint {
+-
+-class FFmpegAudioProcessor {
+-public:
+-	FFmpegAudioProcessor() {
+-		m_resample_ctx = avresample_alloc_context();
+-	}
+-
+-	~FFmpegAudioProcessor() {
+-		avresample_free(&m_resample_ctx);
+-	}
+-
+-	void SetCompatibleMode() {
+-		av_opt_set_int(m_resample_ctx, "filter_size", 16, 0);
+-		av_opt_set_int(m_resample_ctx, "phase_shift", 8, 0);
+-		av_opt_set_int(m_resample_ctx, "linear_interp", 1, 0);
+-		av_opt_set_double(m_resample_ctx, "cutoff", 0.8, 0);
+-	}
+-
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "in_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_rate", sample_rate, 0);
+-	}
+-
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "out_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_rate, 0);
+-	}
+-
+-	int Init() {
+-		return avresample_open(m_resample_ctx);
+-	}
+-
+-	int Convert(uint8_t **out, int out_count, const uint8_t **in, int in_count) {
+-		return avresample_convert(m_resample_ctx, out, 0, out_count, (uint8_t **) in, 0, in_count);
+-	}
+-
+-	int Flush(uint8_t **out, int out_count) {
+-		return avresample_read(m_resample_ctx, out, out_count);
+-	}
+-
+-private:
+-	AVAudioResampleContext *m_resample_ctx = nullptr;
+-};
+-
+-}; // namespace chromaprint
+-
+-#endif
+diff --git a/src/audio/ffmpeg_audio_processor_swresample.h b/src/audio/ffmpeg_audio_processor_swresample.h
+index b86266b..b1d4bea 100644
+--- a/src/audio/ffmpeg_audio_processor_swresample.h
++++ b/src/audio/ffmpeg_audio_processor_swresample.h
+@@ -28,30 +28,28 @@ public:
+ 		av_opt_set_double(m_swr_ctx, "cutoff", 0.8, 0);
+ 	}
+
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "icl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "ich", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetInputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "in_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "isf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "in_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "isr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "in_sample_rate", sample_rate, 0);
+ 	}
+
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "ocl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "och", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetOutputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "out_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "osf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "out_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "osr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "out_sample_rate", sample_rate, 0);
+ 	}
+
+ 	int Init() {
+diff --git a/src/audio/ffmpeg_audio_reader.h b/src/audio/ffmpeg_audio_reader.h
+index 5550164..1c6b346 100644
+--- a/src/audio/ffmpeg_audio_reader.h
++++ b/src/audio/ffmpeg_audio_reader.h
+@@ -62,7 +62,7 @@ public:
+ 	bool Read(const int16_t **data, size_t *size);
+
+ 	bool IsOpen() const { return m_opened; }
+-	bool IsFinished() const { return m_finished && !m_got_frame; }
++	bool IsFinished() const { return !m_has_more_packets && !m_has_more_frames; }
+
+ 	std::string GetError() const { return m_error; }
+ 	int GetErrorCode() const { return m_error_code; }
+@@ -74,20 +74,19 @@ private:
+ 	uint8_t *m_convert_buffer[1] = { nullptr };
+ 	int m_convert_buffer_nb_samples = 0;
+
+-	AVInputFormat *m_input_fmt = nullptr;
++	const AVInputFormat *m_input_fmt = nullptr;
+ 	AVDictionary *m_input_opts = nullptr;
+
+ 	AVFormatContext *m_format_ctx = nullptr;
+ 	AVCodecContext *m_codec_ctx = nullptr;
+-	AVFrame *m_frame = nullptr;
+ 	int m_stream_index = -1;
+ 	std::string m_error;
+ 	int m_error_code = 0;
+-	bool m_finished = false;
+ 	bool m_opened = false;
+-	int m_got_frame = 0;
+-	AVPacket m_packet;
+-	AVPacket m_packet0;
++	bool m_has_more_packets = true;
++	bool m_has_more_frames = true;
++	AVPacket *m_packet = nullptr;
++	AVFrame *m_frame = nullptr;
+
+ 	int m_output_sample_rate = 0;
+ 	int m_output_channels = 0;
+@@ -98,19 +97,12 @@ private:
+
+ inline FFmpegAudioReader::FFmpegAudioReader() {
+ 	av_log_set_level(AV_LOG_QUIET);
+-
+-	av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
+ }
+
+ inline FFmpegAudioReader::~FFmpegAudioReader() {
+ 	Close();
+ 	av_dict_free(&m_input_opts);
+ 	av_freep(&m_convert_buffer[0]);
+-	av_packet_unref(&m_packet0);
+ }
+
+ inline bool FFmpegAudioReader::SetInputFormat(const char *name) {
+@@ -135,11 +127,10 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ 	Close();
+
+-    av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
++	m_packet = av_packet_alloc();
++	if (!m_packet) {
++		return false;
++	}
+
+ 	ret = avformat_open_input(&m_format_ctx, file_name.c_str(), m_input_fmt, &m_input_opts);
+ 	if (ret < 0) {
+@@ -153,26 +144,31 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		return false;
+ 	}
+
+-	AVCodec *codec;
++	const AVCodec *codec;
+ 	ret = av_find_best_stream(m_format_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &codec, 0);
+ 	if (ret < 0) {
+ 		SetError("Could not find any audio stream in the file", ret);
+ 		return false;
+ 	}
+ 	m_stream_index = ret;
++	auto stream = m_format_ctx->streams[m_stream_index];
+
+-	m_codec_ctx = m_format_ctx->streams[m_stream_index]->codec;
++	m_codec_ctx = avcodec_alloc_context3(codec);
+ 	m_codec_ctx->request_sample_fmt = AV_SAMPLE_FMT_S16;
+
++	ret = avcodec_parameters_to_context(m_codec_ctx, stream->codecpar);
++	if (ret < 0) {
++		SetError("Could not copy the stream parameters", ret);
++		return false;
++	}
++
+ 	ret = avcodec_open2(m_codec_ctx, codec, nullptr);
+ 	if (ret < 0) {
+ 		SetError("Could not open the codec", ret);
+ 		return false;
+ 	}
+
+-	if (!m_codec_ctx->channel_layout) {
+-		m_codec_ctx->channel_layout = av_get_default_channel_layout(m_codec_ctx->channels);
+-	}
++	av_dump_format(m_format_ctx, 0, "foo", 0);
+
+ 	m_frame = av_frame_alloc();
+ 	if (!m_frame) {
+@@ -183,19 +179,23 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		m_output_sample_rate = m_codec_ctx->sample_rate;
+ 	}
+
+-	if (!m_output_channels) {
+-		m_output_channels = m_codec_ctx->channels;
++	AVChannelLayout output_channel_layout;
++	if (m_output_channels) {
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
++	} else {
++		m_output_channels = m_codec_ctx->ch_layout.nb_channels;
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
+ 	}
+
+-	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
++	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->ch_layout.nb_channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
+ 		m_converter.reset(new FFmpegAudioProcessor());
+ 		m_converter->SetCompatibleMode();
+ 		m_converter->SetInputSampleFormat(m_codec_ctx->sample_fmt);
+ 		m_converter->SetInputSampleRate(m_codec_ctx->sample_rate);
+-		m_converter->SetInputChannelLayout(m_codec_ctx->channel_layout);
++		m_converter->SetInputChannelLayout(&(m_codec_ctx->ch_layout));
+ 		m_converter->SetOutputSampleFormat(AV_SAMPLE_FMT_S16);
+ 		m_converter->SetOutputSampleRate(m_output_sample_rate);
+-		m_converter->SetOutputChannelLayout(av_get_default_channel_layout(m_output_channels));
++		m_converter->SetOutputChannelLayout(&output_channel_layout);
+ 		auto ret = m_converter->Init();
+ 		if (ret != 0) {
+ 			SetError("Could not create an audio converter instance", ret);
+@@ -203,10 +203,11 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		}
+ 	}
+
++	av_channel_layout_uninit(&output_channel_layout);
++
+ 	m_opened = true;
+-	m_finished = false;
+-	m_got_frame = 0;
+-	m_nb_packets = 0;
++	m_has_more_packets = true;
++	m_has_more_frames = true;
+ 	m_decode_error = 0;
+
+ 	return true;
+@@ -214,6 +215,7 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ inline void FFmpegAudioReader::Close() {
+ 	av_frame_free(&m_frame);
++	av_packet_free(&m_packet);
+
+ 	m_stream_index = -1;
+
+@@ -252,91 +254,98 @@ inline bool FFmpegAudioReader::Read(const int16_t **data, size_t *size) {
+ 		return false;
+ 	}
+
++	*data = nullptr;
++	*size = 0;
++
+ 	int ret;
++	bool needs_packet = false;
+ 	while (true) {
+-		while (m_packet.size <= 0) {
+-			av_packet_unref(&m_packet0);
+-			av_init_packet(&m_packet);
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			ret = av_read_frame(m_format_ctx, &m_packet);
++		while (needs_packet && m_packet->size == 0) {
++			ret = av_read_frame(m_format_ctx, m_packet);
+ 			if (ret < 0) {
+ 				if (ret == AVERROR_EOF) {
+-					m_finished = true;
++					needs_packet = false;
++					m_has_more_packets = false;
+ 					break;
+-				} else {
++				}
++				SetError("Error reading from the audio source", ret);
++				return false;
++			}
++			if (m_packet->stream_index == m_stream_index) {
++				needs_packet = false;
++			} else {
++				av_packet_unref(m_packet);
++			}
++		}
++
++		if (m_packet->size != 0) {
++			ret = avcodec_send_packet(m_codec_ctx, m_packet);
++			if (ret < 0) {
++				if (ret != AVERROR(EAGAIN)) {
+ 					SetError("Error reading from the audio source", ret);
+ 					return false;
+ 				}
+-			}
+-			m_packet0 = m_packet;
+-			if (m_packet.stream_index != m_stream_index) {
+-				m_packet.data = nullptr;
+-				m_packet.size = 0;
+ 			} else {
+-				m_nb_packets++;
++				av_packet_unref(m_packet);
+ 			}
+ 		}
+
+-		ret = avcodec_decode_audio4(m_codec_ctx, m_frame, &m_got_frame, &m_packet);
++		ret = avcodec_receive_frame(m_codec_ctx, m_frame);
+ 		if (ret < 0) {
+-			if (m_decode_error) {
+-				SetError("Error decoding audio frame", m_decode_error);
+-				return false;
++			if (ret == AVERROR_EOF) {
++				m_has_more_frames = false;
++			} else if (ret == AVERROR(EAGAIN)) {
++				if (m_has_more_packets) {
++					needs_packet = true;
++					continue;
++				} else {
++					m_has_more_frames = false;
++				}
+ 			}
+-			m_decode_error = ret;
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			continue;
++			SetError("Error decoding the audio source", ret);
++			return false;
+ 		}
+
+-		break;
+-	}
+-
+-	m_decode_error = 0;
+-
+-	const int decoded = std::min(ret, m_packet.size);
+-	m_packet.data += decoded;
+-	m_packet.size -= decoded;
+-
+-	if (m_got_frame) {
+-		if (m_converter) {
+-			if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
+-				int linsize;
+-				av_freep(&m_convert_buffer[0]);
+-				m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
+-				ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
+-				if (ret < 0) {
+-					SetError("Couldn't allocate audio converter buffer", ret);
++		if (m_frame->nb_samples > 0) {
++			if (m_converter) {
++				if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
++					int linsize;
++					av_freep(&m_convert_buffer[0]);
++					m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
++					ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->ch_layout.nb_channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
++					if (ret < 0) {
++						SetError("Couldn't allocate audio converter buffer", ret);
++						return false;
++					}
++				}
++				auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
++				if (nb_samples < 0) {
++					SetError("Couldn't convert audio", ret);
+ 					return false;
+ 				}
+-			}
+-			auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			}
+-			*data = (const int16_t *) m_convert_buffer[0];
+-			*size = nb_samples;
+-		} else {
+-			*data = (const int16_t *) m_frame->data[0];
+-			*size = m_frame->nb_samples;
+-		}
+-	} else {
+-		if (m_finished && m_converter) {
+-			auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			} else if (nb_samples > 0) {
+-				m_got_frame = 1;
+ 				*data = (const int16_t *) m_convert_buffer[0];
+ 				*size = nb_samples;
++			} else {
++				*data = (const int16_t *) m_frame->data[0];
++				*size = m_frame->nb_samples;
++			}
++		} else {
++			if (m_converter) {
++				if (IsFinished()) {
++					auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
++					if (nb_samples < 0) {
++						SetError("Couldn't convert audio", ret);
++						return false;
++					} else if (nb_samples > 0) {
++						*data = (const int16_t *) m_convert_buffer[0];
++						*size = nb_samples;
++					}
++				}
+ 			}
+ 		}
+-	}
+
+-	return true;
++		return true;
++	}
+ }
+
+ inline void FFmpegAudioReader::SetError(const char *message, int errnum) {
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index a2b517b..123e643 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -38,6 +38,12 @@ set(SRCS
+
+ if(BUILD_TOOLS)
+ 	set(SRCS ${SRCS} ../src/audio/ffmpeg_audio_reader_test.cpp)
++    include_directories(
++        ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}
++        ${AUDIO_PROCESSOR_INCLUDE_DIRS}
++    )
+ 	link_libraries(fpcalc_libs)
+ endif()
+
+-- 
+2.38.1
+
+
diff --git a/srcpkgs/chromaprint/template b/srcpkgs/chromaprint/template
index 7ef7838949f3..1f7bbc70a22c 100644
--- a/srcpkgs/chromaprint/template
+++ b/srcpkgs/chromaprint/template
@@ -1,7 +1,7 @@
 # Template file for 'chromaprint'
 pkgname=chromaprint
 version=1.5.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DBUILD_TOOLS=ON"
 make_check_target="check"

From a25f84beadcc55197ebe6f2993098618baa74728 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 026/140] chromium: revbump for ffmpeg-6.0

---
 .../patches/chromium-93-ffmpeg-4.4.patch      | 36 --------------
 srcpkgs/chromium/patches/ffmpeg5.patch        | 47 +++++++++++++++++++
 srcpkgs/chromium/template                     |  2 +-
 3 files changed, 48 insertions(+), 37 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch
 create mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch b/srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch
deleted file mode 100644
index f0ec736f98bc..000000000000
--- a/srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch
+++ /dev/null
@@ -1,36 +0,0 @@
-diff --git a/media/filters/ffmpeg_demuxer.cc b/media/filters/ffmpeg_demuxer.cc
-index ac4713b07268..492a9a37d096 100644
---- a/media/filters/ffmpeg_demuxer.cc
-+++ b/media/filters/ffmpeg_demuxer.cc
-@@ -427,11 +427,11 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
-   scoped_refptr<DecoderBuffer> buffer;
- 
-   if (type() == DemuxerStream::TEXT) {
--    size_t id_size = 0;
-+    int id_size = 0;
-     uint8_t* id_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
- 
--    size_t settings_size = 0;
-+    int settings_size = 0;
-     uint8_t* settings_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
- 
-@@ -443,7 +443,7 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
-     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
-                                      side_data.data(), side_data.size());
-   } else {
--    size_t side_data_size = 0;
-+    int side_data_size = 0;
-     uint8_t* side_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
- 
-@@ -504,7 +504,7 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
-                                        packet->size - data_offset);
-     }
- 
--    size_t skip_samples_size = 0;
-+    int skip_samples_size = 0;
-     const uint32_t* skip_samples_ptr =
-         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
-             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..24e2da38e34c
--- /dev/null
+++ b/srcpkgs/chromium/patches/ffmpeg5.patch
@@ -0,0 +1,47 @@
+--- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
++++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
+@@ -92,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+-  if (stream->start_time != kNoFFmpegTimestamp)
++  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -1597,7 +1585,7 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+@@ -1618,7 +1606,7 @@
+     if (stream->type() != DemuxerStream::VIDEO)
+       continue;
+ 
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+ 
+     if (!stream->IsEnabled())
diff --git a/srcpkgs/chromium/template b/srcpkgs/chromium/template
index e50c739d3ee7..8705f2ef973f 100644
--- a/srcpkgs/chromium/template
+++ b/srcpkgs/chromium/template
@@ -2,7 +2,7 @@
 pkgname=chromium
 # See https://chromiumdash.appspot.com/releases?platform=Linux for the latest version
 version=112.0.5615.49
-revision=1
+revision=2
 archs="i686* x86_64* aarch64* armv7l*"
 hostmakedepends="
  $(vopt_if clang "clang lld llvm15")

From 896ee3463a55901c7c6c1aac5258f8fa49e13295 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 027/140] cmus: revbump for ffmpeg-6.0

---
 srcpkgs/cmus/patches/ffmpeg6.patch | 12 ++++++++++++
 srcpkgs/cmus/template              |  2 +-
 2 files changed, 13 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/cmus/patches/ffmpeg6.patch

diff --git a/srcpkgs/cmus/patches/ffmpeg6.patch b/srcpkgs/cmus/patches/ffmpeg6.patch
new file mode 100644
index 000000000000..ffa95ab81110
--- /dev/null
+++ b/srcpkgs/cmus/patches/ffmpeg6.patch
@@ -0,0 +1,12 @@
+--- a/ip/ffmpeg.c
++++ b/ip/ffmpeg.c
+@@ -202,9 +202,6 @@ static int ffmpeg_open(struct input_plugin_data *ip_data)
+ 			break;
+ 		}
+ 
+-		if (codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+-			cc->flags |= AV_CODEC_FLAG_TRUNCATED;
+-
+ 		if (avcodec_open2(cc, codec, NULL) < 0) {
+ 			d_print("could not open codec: %d, %s\n", cc->codec_id, avcodec_get_name(cc->codec_id));
+ 			err = -IP_ERROR_UNSUPPORTED_FILE_TYPE;
diff --git a/srcpkgs/cmus/template b/srcpkgs/cmus/template
index 0fcb424ce336..05b77d0fecae 100644
--- a/srcpkgs/cmus/template
+++ b/srcpkgs/cmus/template
@@ -1,7 +1,7 @@
 # Template file for 'cmus'
 pkgname=cmus
 version=2.10.0
-revision=1
+revision=2
 build_style=configure
 configure_args="prefix=/usr LD=$CC"
 hostmakedepends="pkg-config"

From 49941a66bd74a643b03290a573a7b181a61157f5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 028/140] cyanrip: revbump for ffmpeg-6.0

---
 srcpkgs/cyanrip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cyanrip/template b/srcpkgs/cyanrip/template
index 9796e3461601..5db30e020d17 100644
--- a/srcpkgs/cyanrip/template
+++ b/srcpkgs/cyanrip/template
@@ -1,7 +1,7 @@
 # Template file for 'cyanrip'
 pkgname=cyanrip
 version=0.9.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config"
 makedepends="ffmpeg-devel libcdio-devel libcdio-paranoia-devel libcurl-devel libmusicbrainz5-devel"

From cfe9a27590ddc6a5bb1b9e294d76f074ebb0cca0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 029/140] deadbeef: revbump for ffmpeg4-4.4.3

---
 srcpkgs/deadbeef/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/deadbeef/template b/srcpkgs/deadbeef/template
index b664bb1b9bd9..165b3c7b9cad 100644
--- a/srcpkgs/deadbeef/template
+++ b/srcpkgs/deadbeef/template
@@ -1,14 +1,14 @@
 # Template file for 'deadbeef'
 pkgname=deadbeef
 version=1.8.8
-revision=1
+revision=2
 create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-oss --disable-lfm --disable-notify --disable-gtk2"
 hostmakedepends="automake libtool gettext gettext-devel intltool pkg-config
  yasm clang glib-devel"
 makedepends="
- alsa-lib-devel dbus-devel faad2-devel ffmpeg-devel gtk+3-devel imlib2-devel
+ alsa-lib-devel dbus-devel faad2-devel ffmpeg4-devel gtk+3-devel imlib2-devel
  jansson-devel libcddb-devel libcdio-devel libcurl-devel libflac-devel
  libmad-devel libpng-devel libsamplerate-devel libsndfile-devel libvorbis-devel
  libzip-devel mpg123-devel opusfile-devel pulseaudio-devel wavpack-devel"

From e0d905a5fac0324504370f59e9be401db7d5b3bb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 030/140] dolphin-emu: revbump for ffmpeg-6.0

---
 srcpkgs/dolphin-emu/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/dolphin-emu/template b/srcpkgs/dolphin-emu/template
index 7ea197ceb2a8..7aeb0a5b645e 100644
--- a/srcpkgs/dolphin-emu/template
+++ b/srcpkgs/dolphin-emu/template
@@ -1,7 +1,7 @@
 # Template file for 'dolphin-emu'
 pkgname=dolphin-emu
 version=5.0.16101
-revision=1
+revision=2
 _dolphin_commit=8ecfa537a242de74d2e372e30d9d79b14584b2fb
 _mgba_commit=40d4c430fc36caeb7ea32fd39624947ed487d2f2
 #Version/hash pair can be found at https://dolphin-emu.org/download/

From 7f368372b0a37992f33586451b27e680017caf64 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 031/140] droidcam-obs-plugin: revbump for ffmpeg-6.0

---
 srcpkgs/droidcam-obs-plugin/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam-obs-plugin/template b/srcpkgs/droidcam-obs-plugin/template
index fc9c9bf6b9d5..fb0480754df4 100644
--- a/srcpkgs/droidcam-obs-plugin/template
+++ b/srcpkgs/droidcam-obs-plugin/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam-obs-plugin'
 pkgname=droidcam-obs-plugin
 version=2.0.1
-revision=1
+revision=2
 build_style=gnu-makefile
 make_use_env=yes
 make_build_args="ALLOW_STATIC=no"

From c1f67c71ba9baa4e302567e35821387bdf282fcb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 032/140] droidcam: revbump for ffmpeg-6.0

---
 srcpkgs/droidcam/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam/template b/srcpkgs/droidcam/template
index 1c3f1b8b1fc6..32a9220b79a4 100644
--- a/srcpkgs/droidcam/template
+++ b/srcpkgs/droidcam/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam'
 pkgname=droidcam
 version=1.8.2
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="USBMUXD=-lusbmuxd-2.0 JPEG=-lturbojpeg"
 hostmakedepends="pkg-config"

From c86d7439a778ef3ac904490276eb79f0771f53a4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 033/140] electron19: revbump for ffmpeg-6.0

---
 srcpkgs/electron19/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron19/template b/srcpkgs/electron19/template
index 068136be7623..32ce301e730c 100644
--- a/srcpkgs/electron19/template
+++ b/srcpkgs/electron19/template
@@ -1,7 +1,7 @@
 # Template file for 'electron19'
 pkgname=electron19
 version=19.0.8
-revision=2
+revision=3
 _nodever=16.14.2
 _chromiumver=102.0.5005.125
 archs="x86_64* aarch64* ppc64le*"

From 0e91a31d5e892b8d03857bbc0769be09314be4c2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 034/140] ffmpegthumbnailer: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ffmpegthumbnailer/template | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/srcpkgs/ffmpegthumbnailer/template b/srcpkgs/ffmpegthumbnailer/template
index 039eea7622b3..8546bef3e868 100644
--- a/srcpkgs/ffmpegthumbnailer/template
+++ b/srcpkgs/ffmpegthumbnailer/template
@@ -1,16 +1,16 @@
 # Template file for 'ffmpegthumbnailer'
 pkgname=ffmpegthumbnailer
 version=2.2.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
-makedepends="libpng-devel libjpeg-turbo-devel ffmpeg-devel"
-depends="ffmpeg"
+makedepends="libpng-devel libjpeg-turbo-devel ffmpeg4-devel"
+depends="ffmpeg4"
 short_desc="Lightweight video thumbnailer"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
-homepage="https://github.com/dirkvdb/${pkgname}"
-distfiles="${homepage}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
+homepage="https://github.com/dirkvdb"
+distfiles="${homepage}/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
 checksum=1cb24059c38223f657b300c84dd80491b7040d4b69471c4fea69be862bc99b5b
 
 post_install() {

From b398f64c5d68da8602a69df88ff41f0d1fbaeeec Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 035/140] ffmpegthumbs: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ffmpegthumbs/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/ffmpegthumbs/template b/srcpkgs/ffmpegthumbs/template
index 5f0b9414dada..944a78fbc96c 100644
--- a/srcpkgs/ffmpegthumbs/template
+++ b/srcpkgs/ffmpegthumbs/template
@@ -1,11 +1,11 @@
 # Template file for 'ffmpegthumbs'
 pkgname=ffmpegthumbs
 version=22.12.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules kcoreaddons kconfig-devel
  pkg-config qt5-host-tools qt5-qmake gettext"
-makedepends="qt5-devel kio-devel ffmpeg-devel taglib-devel"
+makedepends="qt5-devel kio-devel ffmpeg4-devel taglib-devel"
 short_desc="FFmpeg-based thumbnail creator for video files"
 maintainer="Michael Straube <straubem@gmx.de>"
 license="GPL-2.0-or-later"

From b15f02b9b062bacc8822f960111d558f1db98500 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 036/140] ffms2: revbump for ffmpeg-6.0

---
 srcpkgs/ffms2/patches/ffmpeg5.patch | 424 ++++++++++++++++++++++++++++
 srcpkgs/ffms2/template              |   2 +-
 2 files changed, 425 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ffms2/patches/ffmpeg5.patch

diff --git a/srcpkgs/ffms2/patches/ffmpeg5.patch b/srcpkgs/ffms2/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..1479fabcafcb
--- /dev/null
+++ b/srcpkgs/ffms2/patches/ffmpeg5.patch
@@ -0,0 +1,424 @@
+From 45673149e9a2f5586855ad472e3059084eaa36b1 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:41:21 +0100
+Subject: [PATCH] Use auto for AVCodec
+
+The geniuses over at FFmpeg decided to constify this API, so old
+versions of the library will return AVCodec *, while new versions
+of the libary will return const AVCodec *, which, in C++, are not
+OK to convert between.
+
+Rather than use some macro hell in ffmscompat.h, we can work around
+this by using auto.
+
+Gross.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 2 +-
+ src/core/indexing.cpp    | 6 +++---
+ src/core/videosource.cpp | 2 +-
+ 3 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index e4ce97c..ac09666 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -469,7 +469,7 @@ void FFMS_AudioSource::OpenFile() {
+ 
+     LAVFOpenFile(SourceFile.c_str(), FormatContext, TrackNumber);
+ 
+-    AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
++    auto *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
+     if (Codec == nullptr)
+         throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+             "Audio codec not found");
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index e547c5a..59fb4e8 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -384,7 +384,7 @@ FFMS_TrackType FFMS_Indexer::GetTrackType(int Track) {
+ }
+ 
+ const char *FFMS_Indexer::GetTrackCodec(int Track) {
+-    AVCodec *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
++    auto *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
+     return codec ? codec->name : nullptr;
+ }
+ 
+@@ -402,7 +402,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             UseDTS);
+ 
+         if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            AVCodec *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (!VideoCodec) {
+                 FormatContext->streams[i]->discard = AVDISCARD_ALL;
+                 IndexMask.erase(i);
+@@ -433,7 +433,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 IndexMask.insert(i);
+             }
+         } else if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+-            AVCodec *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (AudioCodec == nullptr)
+                 throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_UNSUPPORTED,
+                     "Audio codec not found");
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index b889970..8956c22 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -171,7 +171,7 @@ FFMS_VideoSource::FFMS_VideoSource(const char *SourceFile, FFMS_Index &Index, in
+ 
+         LAVFOpenFile(SourceFile, FormatContext, VideoTrack);
+ 
+-        AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
++        auto *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
+         if (Codec == nullptr)
+             throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+                 "Video codec not found");
+-- 
+2.40.0
+
+From 96cbf38ea9381829a1314f432a2c60495dcefaad Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:12:41 +0100
+Subject: [PATCH] all: Update AVPacket API usage
+
+AVPackets must all be on the heap now, since it is no longer
+part of the libav* ABI.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 16 ++++++----
+ src/core/indexing.cpp    | 63 ++++++++++++++++++++++------------------
+ src/core/indexing.h      |  4 +--
+ src/core/utils.cpp       |  6 ----
+ src/core/utils.h         |  1 -
+ src/core/videosource.cpp | 30 ++++++++++---------
+ 6 files changed, 64 insertions(+), 56 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index 37cf9ae..e4ce97c 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -285,10 +285,15 @@ FFMS_AudioSource::AudioBlock *FFMS_AudioSource::CacheBlock(CacheIterator &pos) {
+ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     CurrentFrame = &Frames[PacketNumber];
+ 
+-    AVPacket Packet;
+-    if (!ReadPacket(&Packet))
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++    if (!ReadPacket(Packet)) {
++        av_packet_free(&Packet);
+         throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_UNKNOWN,
+             "ReadPacket unexpectedly failed to read a packet");
++    }
+ 
+     // ReadPacket may have changed the packet number
+     CurrentFrame = &Frames[PacketNumber];
+@@ -297,8 +302,9 @@ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     int NumberOfSamples = 0;
+     AudioBlock *CachedBlock = nullptr;
+     
+-    int Ret = avcodec_send_packet(CodecContext, &Packet);
+-    av_packet_unref(&Packet);
++    int Ret = avcodec_send_packet(CodecContext, Packet);
++    av_packet_unref(Packet);
++    av_packet_free(&Packet);
+ 
+     av_frame_unref(DecodeFrame);
+     Ret = avcodec_receive_frame(CodecContext, DecodeFrame);
+@@ -513,8 +519,6 @@ void FFMS_AudioSource::Seek() {
+ }
+ 
+ bool FFMS_AudioSource::ReadPacket(AVPacket *Packet) {
+-    InitNullPacket(*Packet);
+-
+     while (av_read_frame(FormatContext, Packet) >= 0) {
+         if (Packet->stream_index == TrackNumber) {
+             // Required because not all audio packets, especially in ogg, have a pts. Use the previous valid packet's pts instead.
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index 23fb95b..e547c5a 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -320,7 +320,7 @@ void FFMS_Indexer::CheckAudioProperties(int Track, AVCodecContext *Context) {
+     }
+ }
+ 
+-void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict,
++void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict,
+                                     int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct) {
+     if (VideoContext.Parser) {
+         uint8_t *OB;
+@@ -330,8 +330,8 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+         av_parser_parse2(VideoContext.Parser,
+             VideoContext.CodecContext,
+             &OB, &OBSize,
+-            pkt.data, pkt.size,
+-            pkt.pts, pkt.dts, pkt.pos);
++            pkt->data, pkt->size,
++            pkt->pts, pkt->dts, pkt->pos);
+ 
+         // H.264 (PAFF) and HEVC may have one field per packet, so we need to track
+         // when we have a full or half frame available, and mark one of them as
+@@ -351,15 +351,15 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+ 
+         *RepeatPict = VideoContext.Parser->repeat_pict;
+         *FrameType = VideoContext.Parser->pict_type;
+-        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt.flags & AV_PKT_FLAG_DISCARD));
++        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt->flags & AV_PKT_FLAG_DISCARD));
+     } else {
+-        *Invisible = !!(pkt.flags & AV_PKT_FLAG_DISCARD);
++        *Invisible = !!(pkt->flags & AV_PKT_FLAG_DISCARD);
+     }
+ 
+     if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP8)
+-        ParseVP8(pkt.data[0], Invisible, FrameType);
++        ParseVP8(pkt->data[0], Invisible, FrameType);
+     else if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP9)
+-        ParseVP9(pkt.data[0], Invisible, FrameType);
++        ParseVP9(pkt->data[0], Invisible, FrameType);
+ }
+ 
+ void FFMS_Indexer::Free() {
+@@ -458,32 +458,36 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+         }
+     }
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
+     std::vector<int64_t> LastValidTS(FormatContext->nb_streams, AV_NOPTS_VALUE);
+ 
+     int64_t filesize = avio_size(FormatContext->pb);
+     enum AVPictureStructure LastPicStruct = AV_PICTURE_STRUCTURE_UNKNOWN;
+-    while (av_read_frame(FormatContext, &Packet) >= 0) {
++    while (av_read_frame(FormatContext, Packet) >= 0) {
+         // Update progress
+         // FormatContext->pb can apparently be NULL when opening images.
+         if (IC && FormatContext->pb) {
+-            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate))
++            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate)) {
++                av_packet_free(&Packet);
+                 throw FFMS_Exception(FFMS_ERROR_CANCELLED, FFMS_ERROR_USER,
+                     "Cancelled by user");
++            }
+         }
+-        if (!IndexMask.count(Packet.stream_index)) {
+-            av_packet_unref(&Packet);
++        if (!IndexMask.count(Packet->stream_index)) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+-        int Track = Packet.stream_index;
++        int Track = Packet->stream_index;
+         FFMS_Track &TrackInfo = (*TrackIndices)[Track];
+-        bool KeyFrame = !!(Packet.flags & AV_PKT_FLAG_KEY);
++        bool KeyFrame = !!(Packet->flags & AV_PKT_FLAG_KEY);
+         ReadTS(Packet, LastValidTS[Track], (*TrackIndices)[Track].UseDTS);
+ 
+         if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            int64_t PTS = TrackInfo.UseDTS ? Packet.dts : Packet.pts;
++            int64_t PTS = TrackInfo.UseDTS ? Packet->dts : Packet->pts;
+             if (PTS == AV_NOPTS_VALUE) {
+                 // VPx alt-refs are output as packets which lack timestmps or durations, since
+                 // they are invisible. Currently, the timestamp mangling code in libavformat
+@@ -495,9 +499,11 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 // FFMS2 currently sorts packets by PTS, which will break decoding, otherwise.
+                 bool HasAltRefs = (FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP8 ||
+                                    FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP9);
+-                if (Packet.duration == 0 && !HasAltRefs)
++                if (Packet->duration == 0 && !HasAltRefs) {
++                    av_packet_free(&Packet);
+                     throw FFMS_Exception(FFMS_ERROR_INDEXING, FFMS_ERROR_PARSER,
+                         "Invalid packet pts, dts, and duration");
++                }
+ 
+                 if (TrackInfo.empty())
+                     PTS = 0;
+@@ -513,7 +519,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             ParseVideoPacket(AVContexts[Track], Packet, &RepeatPict, &FrameType, &Invisible, &LastPicStruct);
+ 
+             TrackInfo.AddVideoFrame(PTS, RepeatPict, KeyFrame,
+-                FrameType, Packet.pos, Invisible);
++                FrameType, Packet->pos, Invisible);
+         } else if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+             // For video seeking timestamps are used only if all packets have
+             // timestamps, while for audio they're used if any have timestamps,
+@@ -522,28 +528,29 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 TrackInfo.HasTS = true;
+ 
+             int64_t StartSample = AVContexts[Track].CurrentSample;
+-            uint32_t SampleCount = IndexAudioPacket(Track, &Packet, AVContexts[Track], *TrackIndices);
++            uint32_t SampleCount = IndexAudioPacket(Track, Packet, AVContexts[Track], *TrackIndices);
+             TrackInfo.SampleRate = AVContexts[Track].CodecContext->sample_rate;
+ 
+             TrackInfo.AddAudioFrame(LastValidTS[Track],
+-                StartSample, SampleCount, KeyFrame, Packet.pos, Packet.flags & AV_PKT_FLAG_DISCARD);
++                StartSample, SampleCount, KeyFrame, Packet->pos, Packet->flags & AV_PKT_FLAG_DISCARD);
+         }
+ 
+-        if (!(Packet.flags & AV_PKT_FLAG_DISCARD))
+-            TrackInfo.LastDuration = Packet.duration;
++        if (!(Packet->flags & AV_PKT_FLAG_DISCARD))
++            TrackInfo.LastDuration = Packet->duration;
+ 
+-        av_packet_unref(&Packet);
++        av_packet_unref(Packet);
+     }
++    av_packet_free(&Packet);
+ 
+     TrackIndices->Finalize(AVContexts, FormatContext->iformat->name);
+     return TrackIndices.release();
+ }
+ 
+-void FFMS_Indexer::ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS) {
+-    if (!UseDTS && Packet.pts != AV_NOPTS_VALUE)
+-        TS = Packet.pts;
++void FFMS_Indexer::ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS) {
++    if (!UseDTS && Packet->pts != AV_NOPTS_VALUE)
++        TS = Packet->pts;
+     if (TS == AV_NOPTS_VALUE)
+         UseDTS = true;
+-    if (UseDTS && Packet.dts != AV_NOPTS_VALUE)
+-        TS = Packet.dts;
++    if (UseDTS && Packet->dts != AV_NOPTS_VALUE)
++        TS = Packet->dts;
+ }
+diff --git a/src/core/indexing.h b/src/core/indexing.h
+index 3cfc3c3..5c06868 100644
+--- a/src/core/indexing.h
++++ b/src/core/indexing.h
+@@ -80,10 +80,10 @@ private:
+     int64_t Filesize;
+     uint8_t Digest[20];
+ 
+-    void ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS);
++    void ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS);
+     void CheckAudioProperties(int Track, AVCodecContext *Context);
+     uint32_t IndexAudioPacket(int Track, AVPacket *Packet, SharedAVContext &Context, FFMS_Index &TrackIndices);
+-    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
++    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
+     void Free();
+ public:
+     FFMS_Indexer(const char *Filename);
+diff --git a/src/core/utils.cpp b/src/core/utils.cpp
+index ce67533..8a2e997 100644
+--- a/src/core/utils.cpp
++++ b/src/core/utils.cpp
+@@ -62,12 +62,6 @@ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo) {
+     }
+ }
+ 
+-void InitNullPacket(AVPacket &pkt) {
+-    av_init_packet(&pkt);
+-    pkt.data = nullptr;
+-    pkt.size = 0;
+-}
+-
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames) {
+     AP.SampleFormat = static_cast<FFMS_SampleFormat>(av_get_packed_sample_fmt(CTX->sample_fmt));
+     AP.BitsPerSample = av_get_bytes_per_sample(CTX->sample_fmt) * 8;
+diff --git a/src/core/utils.h b/src/core/utils.h
+index 9819dc7..003ab79 100644
+--- a/src/core/utils.h
++++ b/src/core/utils.h
+@@ -58,7 +58,6 @@ std::unique_ptr<T> make_unique(Args&&... args) {
+ }
+ 
+ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo);
+-void InitNullPacket(AVPacket &pkt);
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames);
+ 
+ void LAVFOpenFile(const char *SourceFile, AVFormatContext *&FormatContext, int Track);
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index 06bd161..b889970 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -673,30 +673,34 @@ void FFMS_VideoSource::DecodeNextFrame(int64_t &AStartTime, int64_t &Pos) {
+     if (HasPendingDelayedFrames())
+         return;
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
+-
+-    while (ReadFrame(&Packet) >= 0) {
+-        if (Packet.stream_index != VideoTrack) {
+-            av_packet_unref(&Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++
++    while (ReadFrame(Packet) >= 0) {
++        if (Packet->stream_index != VideoTrack) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+         if (AStartTime < 0)
+-            AStartTime = Frames.UseDTS ? Packet.dts : Packet.pts;
++            AStartTime = Frames.UseDTS ? Packet->dts : Packet->pts;
+ 
+         if (Pos < 0)
+-            Pos = Packet.pos;
++            Pos = Packet->pos;
+ 
+-        bool FrameFinished = DecodePacket(&Packet);
+-        av_packet_unref(&Packet);
+-        if (FrameFinished)
++        bool FrameFinished = DecodePacket(Packet);
++        av_packet_unref(Packet);
++        if (FrameFinished) {
++            av_packet_free(&Packet);
+             return;
++        }
+     }
+ 
+     // Flush final frames
+-    InitNullPacket(Packet);
+-    DecodePacket(&Packet);
++    DecodePacket(Packet);
++    av_packet_free(&Packet);
+ }
+ 
+ bool FFMS_VideoSource::SeekTo(int n, int SeekOffset) {
+-- 
+2.40.0
+
+From bf9e03e9e08534c024e5a744a6437c4aac160201 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:20:47 +0100
+Subject: [PATCH 2/3] configure: Remove deprecated API use
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ configure.ac | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index b35ef80bc..d19714d0f 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -102,10 +102,10 @@ CFLAGS="$_CFLAGS $FFMPEG_CFLAGS"
+
+ AC_DEFUN([TEST_FFMPEG],
+          [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+-            #include <libavcodec/avcodec.h>
++            #include <libavformat/avformat.h>
+             #include <libswscale/swscale.h>
+             ]],[[
+-                avcodec_register_all();
++                avformat_network_init();
+                 swscale_version();
+             ]])], [eval $1=yes], [eval $1=no])
+         ])
+
diff --git a/srcpkgs/ffms2/template b/srcpkgs/ffms2/template
index 68e8a0c14bce..2acfadac44b3 100644
--- a/srcpkgs/ffms2/template
+++ b/srcpkgs/ffms2/template
@@ -1,7 +1,7 @@
 # Template file for 'ffms2'
 pkgname=ffms2
 version=2.40
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-shared --disable-static"
 hostmakedepends="pkg-config autoconf automake libtool"

From f8ba7182faafc779e42cdee475f3cdd8e0f97373 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 037/140] freerdp: revbump for ffmpeg-6.0

---
 .../freerdp/patches/ffmpeg6_aa2cb9aa.patch    | 42 +++++++++++++++++++
 srcpkgs/freerdp/template                      |  2 +-
 2 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch

diff --git a/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
new file mode 100644
index 000000000000..a4324da3a882
--- /dev/null
+++ b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
@@ -0,0 +1,42 @@
+From aa2cb9aa5ff5562433598ba168a466e0752bca0e Mon Sep 17 00:00:00 2001
+From: akallabeth <akallabeth@posteo.net>
+Date: Tue, 14 Feb 2023 07:48:54 +0100
+Subject: [PATCH] Fixed #8686: Update h264 to use new FFMPEG API
+
+---
+ channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c | 2 ++
+ libfreerdp/codec/h264_ffmpeg.c            | 2 ++
+ 2 files changed, 4 insertions(+)
+
+diff --git a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+index 339462d865f..beea80b7a1e 100644
+--- a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
++++ b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+@@ -239,8 +239,10 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYP
+ 		}
+ 	}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 	if (mdecoder->codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		mdecoder->codec_context->flags |= AV_CODEC_FLAG_TRUNCATED;
++#endif
+ 
+ 	return TRUE;
+ }
+diff --git a/libfreerdp/codec/h264_ffmpeg.c b/libfreerdp/codec/h264_ffmpeg.c
+index 8a23db2473c..896a333019b 100644
+--- a/libfreerdp/codec/h264_ffmpeg.c
++++ b/libfreerdp/codec/h264_ffmpeg.c
+@@ -615,10 +615,12 @@ static BOOL libavcodec_init(H264_CONTEXT* h264)
+ 			goto EXCEPTION;
+ 		}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 		if (sys->codecDecoder->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		{
+ 			sys->codecDecoderContext->flags |= AV_CODEC_FLAG_TRUNCATED;
+ 		}
++#endif
+ 
+ #ifdef WITH_VAAPI
+ 
diff --git a/srcpkgs/freerdp/template b/srcpkgs/freerdp/template
index 25e8aa9677f0..4d51c8189902 100644
--- a/srcpkgs/freerdp/template
+++ b/srcpkgs/freerdp/template
@@ -1,7 +1,7 @@
 # Template file for 'freerdp'
 pkgname=freerdp
 version=2.10.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_ALSA=ON -DWITH_CUPS=OFF -DWITH_FFMPEG=ON
  -DWITH_GSTREAMER_0_10=OFF -DWITH_GSTREAMER_1_0=OFF -DWITH_JPEG=ON

From 8a1cda0bcf5c5b610e68541ae240384bb4a1136f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 038/140] gerbera: revbump for ffmpeg-6.0

---
 srcpkgs/gerbera/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gerbera/template b/srcpkgs/gerbera/template
index ae14f35c767c..2dc0ac0ce03b 100644
--- a/srcpkgs/gerbera/template
+++ b/srcpkgs/gerbera/template
@@ -1,7 +1,7 @@
 # Template file for 'gerbera'
 pkgname=gerbera
 version=1.12.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_SYSTEMD=0 -DWITH_AVCODEC=1"
 hostmakedepends="pkg-config"

From 8d5de4c9cf5b975fe58c6f191c6aeadb07ff9597 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 039/140] goldendict: revbump for ffmpeg-6.0

---
 srcpkgs/goldendict/patches/ffmpeg4.patch |  21 --
 srcpkgs/goldendict/patches/ffmpeg5.patch | 232 +++++++++++++++++++++++
 srcpkgs/goldendict/template              |   2 +-
 3 files changed, 233 insertions(+), 22 deletions(-)
 delete mode 100644 srcpkgs/goldendict/patches/ffmpeg4.patch
 create mode 100644 srcpkgs/goldendict/patches/ffmpeg5.patch

diff --git a/srcpkgs/goldendict/patches/ffmpeg4.patch b/srcpkgs/goldendict/patches/ffmpeg4.patch
deleted file mode 100644
index f045fa27f54b..000000000000
--- a/srcpkgs/goldendict/patches/ffmpeg4.patch
+++ /dev/null
@@ -1,21 +0,0 @@
---- a/ffmpegaudio.cc.orig 2018-05-09 22:16:13.480659958 +0200
-+++ b/ffmpegaudio.cc      2018-05-09 22:16:50.748322790 +0200
-@@ -143,7 +143,7 @@
-     return false;
-   }
-
--  unsigned char * avioBuffer = ( unsigned char * )av_malloc( kBufferSize + FF_INPUT_BUFFER_PADDING_SIZE );
-+  unsigned char * avioBuffer = ( unsigned char * )av_malloc( kBufferSize + AV_INPUT_BUFFER_PADDING_SIZE );
-   if ( !avioBuffer )
-   {
-     errorString = QObject::tr( "av_malloc() failed." );
-@@ -380,7 +380,7 @@
-   }
-
-   if ( !Qt4x5::AtomicInt::loadAcquire( isCancelled_ ) &&
--       codecContext_->codec->capabilities & CODEC_CAP_DELAY )
-+       codecContext_->codec->capabilities & AV_CODEC_CAP_DELAY )
-   {
-     av_init_packet( &packet );
-     int gotFrame = 0;
-
diff --git a/srcpkgs/goldendict/patches/ffmpeg5.patch b/srcpkgs/goldendict/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..7cfc98ada368
--- /dev/null
+++ b/srcpkgs/goldendict/patches/ffmpeg5.patch
@@ -0,0 +1,232 @@
+From 03bbe01b79a1f07a6780cb60f23a087104c5d77b Mon Sep 17 00:00:00 2001
+From: Abs62 <ottomann@yandex.ru>
+Date: Fri, 30 Mar 2018 22:53:24 +0300
+Subject: [PATCH] Fix warnings while compile with FFMpeg 3.4.2 (issue #978)
+
+---
+ ffmpegaudio.cc | 68 +++++++++++++++++++++++++++++++++++++++++++++-----
+ 1 file changed, 62 insertions(+), 6 deletions(-)
+
+diff --git a/ffmpegaudio.cc b/ffmpegaudio.cc
+index ed1172bdd..56e8f788e 100644
+--- a/ffmpegaudio.cc
++++ b/ffmpegaudio.cc
+@@ -91,6 +91,7 @@ struct DecoderContext
+   QByteArray audioData_;
+   QDataStream audioDataStream_;
+   AVFormatContext * formatContext_;
++  AVCodec * codec_;
+   AVCodecContext * codecContext_;
+   AVIOContext * avioContext_;
+   AVStream * audioStream_;
+@@ -114,6 +115,7 @@ DecoderContext::DecoderContext( QByteArray const & audioData, QAtomicInt & isCan
+   audioData_( audioData ),
+   audioDataStream_( audioData_ ),
+   formatContext_( NULL ),
++  codec_( NULL ),
+   codecContext_( NULL ),
+   avioContext_( NULL ),
+   audioStream_( NULL ),
+@@ -143,7 +145,11 @@ bool DecoderContext::openCodec( QString & errorString )
+     return false;
+   }
+
++#if LIBAVCODEC_VERSION_MAJOR < 56 || ( LIBAVCODEC_VERSION_MAJOR == 56 && LIBAVCODEC_VERSION_MINOR < 56 )
+   unsigned char * avioBuffer = ( unsigned char * )av_malloc( kBufferSize + FF_INPUT_BUFFER_PADDING_SIZE );
++#else
++  unsigned char * avioBuffer = ( unsigned char * )av_malloc( kBufferSize + AV_INPUT_BUFFER_PADDING_SIZE );
++#endif
+   if ( !avioBuffer )
+   {
+     errorString = QObject::tr( "av_malloc() failed." );
+@@ -186,7 +192,11 @@ bool DecoderContext::openCodec( QString & errorString )
+   // Find audio stream, use the first audio stream if available
+   for ( unsigned i = 0; i < formatContext_->nb_streams; i++ )
+   {
++#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 33 )
+     if ( formatContext_->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO )
++#else
++      if ( formatContext_->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO )
++#endif
+     {
+       audioStream_ = formatContext_->streams[i];
+       break;
+@@ -198,22 +208,38 @@ bool DecoderContext::openCodec( QString & errorString )
+     return false;
+   }
+
++#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 33 )
+   codecContext_ = audioStream_->codec;
+-  AVCodec * codec = avcodec_find_decoder( codecContext_->codec_id );
+-  if ( !codec )
++  codec_ = avcodec_find_decoder( codecContext_->codec_id );
++  if ( !codec_ )
+   {
+     errorString = QObject::tr( "Codec [id: %1] not found." ).arg( codecContext_->codec_id );
+     return false;
+   }
++#else
++  codec_ = avcodec_find_decoder( audioStream_->codecpar->codec_id );
++  if ( !codec_ )
++  {
++    errorString = QObject::tr( "Codec [id: %1] not found." ).arg( audioStream_->codecpar->codec_id );
++    return false;
++  }
++  codecContext_ = avcodec_alloc_context3( codec_ );
++  if ( !codecContext_ )
++  {
++    errorString = QObject::tr( "avcodec_alloc_context3() failed." );
++    return false;
++  }
++  avcodec_parameters_to_context( codecContext_, audioStream_->codecpar );
++#endif
+
+-  ret = avcodec_open2( codecContext_, codec, NULL );
++  ret = avcodec_open2( codecContext_, codec_, NULL );
+   if ( ret < 0 )
+   {
+     errorString = QObject::tr( "avcodec_open2() failed: %1." ).arg( avErrorString( ret ) );
+     return false;
+   }
+
+-  av_log( NULL, AV_LOG_INFO, "Codec open: %s: channels: %d, rate: %d, format: %s\n", codec->long_name,
++  av_log( NULL, AV_LOG_INFO, "Codec open: %s: channels: %d, rate: %d, format: %s\n", codec_->long_name,
+           codecContext_->channels, codecContext_->sample_rate, av_get_sample_fmt_name( codecContext_->sample_fmt ) );
+   return true;
+ }
+@@ -252,10 +278,13 @@ void DecoderContext::closeCodec()
+
+   // Closing a codec context without prior avcodec_open2() will result in
+   // a crash in ffmpeg
+-  if ( audioStream_ && audioStream_->codec && audioStream_->codec->codec )
++  if ( audioStream_ && codecContext_ && codec_ )
+   {
+     audioStream_->discard = AVDISCARD_ALL;
+-    avcodec_close( audioStream_->codec );
++    avcodec_close( codecContext_ );
++#if LIBAVCODEC_VERSION_MAJOR > 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR >= 33 )
++    avcodec_free_context( &codecContext_ );
++#endif
+   }
+
+   avformat_close_input( &formatContext_ );
+@@ -356,6 +385,7 @@ bool DecoderContext::play( QString & errorString )
+     if ( packet.stream_index == audioStream_->index )
+     {
+       AVPacket pack = packet;
++#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 37 )
+       int gotFrame = 0;
+       do
+       {
+@@ -370,6 +400,19 @@ bool DecoderContext::play( QString & errorString )
+         pack.data += len;
+       }
+       while( pack.size > 0 );
++#else
++      int ret = avcodec_send_packet( codecContext_, &pack );
++      /* read all the output frames (in general there may be any number of them) */
++      while( ret >= 0 )
++      {
++        ret = avcodec_receive_frame( codecContext_, frame);
++
++        if ( Qt4x5::AtomicInt::loadAcquire( isCancelled_ ) || ret < 0 )
++          break;
++
++        playFrame( frame );
++      }
++#endif
+     }
+     // av_free_packet() must be called after each call to av_read_frame()
+ #if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 7 )
+@@ -379,6 +422,7 @@ bool DecoderContext::play( QString & errorString )
+ #endif
+   }
+
++#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 37 )
+   if ( !Qt4x5::AtomicInt::loadAcquire( isCancelled_ ) &&
+        codecContext_->codec->capabilities & CODEC_CAP_DELAY )
+   {
+@@ -391,6 +435,18 @@ bool DecoderContext::play( QString & errorString )
+       playFrame( frame );
+     }
+   }
++#else
++  /* flush the decoder */
++  av_init_packet( &packet );
++  int ret = avcodec_send_packet(codecContext_, &packet );
++  while( ret >= 0 )
++  {
++    ret = avcodec_receive_frame(codecContext_, frame);
++    if ( Qt4x5::AtomicInt::loadAcquire( isCancelled_ ) || ret < 0 )
++      break;
++    playFrame( frame );
++  }
++#endif
+
+ #if LIBAVCODEC_VERSION_MAJOR < 54
+   av_free( frame );
+32
+srcpkgs/goldendict/patches/ffmpeg5-2.patch
+Comment on this file
+@@ -0,0 +1,32 @@
+From 966f4a8b78e6324b930e5a50f2bb930bd87e565e Mon Sep 17 00:00:00 2001
+From: Abs62 <ottomann@yandex.ru>
+Date: Fri, 27 Sep 2019 17:00:52 +0300
+Subject: [PATCH] FFmpeg player: Fix some crashes on broken files
+
+---
+ ffmpegaudio.cc | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/ffmpegaudio.cc b/ffmpegaudio.cc
+index 56e8f788e..415fc79cb 100644
+--- a/ffmpegaudio.cc
++++ b/ffmpegaudio.cc
+@@ -51,7 +51,9 @@ AudioService & AudioService::instance()
+
+ AudioService::AudioService()
+ {
++#if LIBAVFORMAT_VERSION_MAJOR < 58 || ( LIBAVFORMAT_VERSION_MAJOR == 58 && LIBAVFORMAT_VERSION_MINOR < 9 )
+   av_register_all();
++#endif
+   ao_initialize();
+ }
+
+@@ -438,6 +440,8 @@ bool DecoderContext::play( QString & errorString )
+ #else
+   /* flush the decoder */
+   av_init_packet( &packet );
++  packet.data = NULL;
++  packet.size = 0;
+   int ret = avcodec_send_packet(codecContext_, &packet );
+   while( ret >= 0 )
+   {
+25
+srcpkgs/goldendict/patches/ffmpeg5-3.patch
+Comment on this file
+@@ -0,0 +1,25 @@
+From 8acb288c9e9bdb3c6bf2e803954dd3b6ac273c05 Mon Sep 17 00:00:00 2001
+From: Liao Junxuan <mikeljx@126.com>
+Date: Sun, 20 Feb 2022 12:28:05 +0800
+Subject: [PATCH] add support for ffmpeg 5.0
+
+---
+ ffmpegaudio.cc | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/ffmpegaudio.cc b/ffmpegaudio.cc
+index d550f4a77..7948d2187 100644
+--- a/ffmpegaudio.cc
++++ b/ffmpegaudio.cc
+@@ -94,7 +94,11 @@ struct DecoderContext
+   QByteArray audioData_;
+   QDataStream audioDataStream_;
+   AVFormatContext * formatContext_;
++#if LIBAVCODEC_VERSION_MAJOR < 59
+   AVCodec * codec_;
++#else
++  const AVCodec * codec_;
++#endif
+   AVCodecContext * codecContext_;
+   AVIOContext * avioContext_;
+   AVStream * audioStream_;
diff --git a/srcpkgs/goldendict/template b/srcpkgs/goldendict/template
index 4544ae710ee6..2ca4185e538a 100644
--- a/srcpkgs/goldendict/template
+++ b/srcpkgs/goldendict/template
@@ -9,7 +9,7 @@ makedepends="tiff-devel qt5-devel libvorbis-devel zlib-devel
  libXtst-devel hunspell-devel qt5-tools-devel qt5-declarative-devel
  qt5-webkit-devel lzo-devel bzip2-devel libao-devel qt5-svg-devel
  libeb-devel qt5-x11extras-devel ffmpeg-devel liblzma-devel"
-short_desc="A feature-rich dictionary lookup program"
+short_desc="Feature-rich dictionary lookup program"
 maintainer="John <me@johnnynator.dev>"
 license="GPL-3.0-or-later"
 homepage="http://goldendict.org/"

From 96aba07c75f8f26cc885e53581ae3c66dd189c9d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 040/140] gst-libav: revbump for ffmpeg-6.0

---
 srcpkgs/gst-libav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index e9a79dc650a5..f082bd211c65 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.20.3
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"

From edd46d846c94db43f01bf94f3a339e504cced676 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 041/140] gst-plugins-bad1: revbump for ffmpeg-6.0

---
 srcpkgs/gst-plugins-bad1/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index f55f82fd4c77..5a9d5387e0d4 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-plugins-bad1'
 pkgname=gst-plugins-bad1
-version=1.20.3
-revision=3
+version=1.22.1
+revision=2
 build_helper="gir"
 build_style=meson
 configure_args="-Dpackage-origin=https://voidlinux.org -Ddoc=disabled

From 968f4008f3565a806b881a07649b3ca474bff6ca Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 042/140] gst-rtsp-server: revbump for ffmpeg-6.0

---
 srcpkgs/gst-rtsp-server/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index 33cd64ceb95e..8ceea8d34b4b 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
 version=1.20.3
-revision=2
+revision=3
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="glib-devel gst-plugins-bad1-devel gobject-introspection

From 1f3930648b11bdcb3e2538ea2bacc0235364aacb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 043/140] guvcview: update to 2.0.8.

---
 srcpkgs/guvcview/patches/fix-include.patch | 10 ++++++++++
 srcpkgs/guvcview/template                  |  5 ++---
 2 files changed, 12 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/guvcview/patches/fix-include.patch

diff --git a/srcpkgs/guvcview/patches/fix-include.patch b/srcpkgs/guvcview/patches/fix-include.patch
new file mode 100644
index 000000000000..503c2af3b78c
--- /dev/null
+++ b/srcpkgs/guvcview/patches/fix-include.patch
@@ -0,0 +1,10 @@
+--- a/guvcview/guvcview.c
++++ b/guvcview/guvcview.c
+@@ -28,6 +28,7 @@
+ #include <sys/stat.h>
+ #include <sys/resource.h>
+ #include <errno.h>
++#include <locale.h>
+ 
+ #include "gview.h"
+ #include "gviewv4l2core.h"
diff --git a/srcpkgs/guvcview/template b/srcpkgs/guvcview/template
index 345cf6006f24..86a7fd619612 100644
--- a/srcpkgs/guvcview/template
+++ b/srcpkgs/guvcview/template
@@ -1,8 +1,7 @@
 # Template file for 'guvcview'
 pkgname=guvcview
-version=2.0.7
+version=2.0.8
 revision=1
-create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-static --disable-debian-menu"
 hostmakedepends="pkg-config intltool autoconf automake libtool glib-devel"
@@ -14,7 +13,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="http://guvcview.sourceforge.net/"
 distfiles="${SOURCEFORGE_SITE}/${pkgname}/${pkgname}-src-${version}.tar.bz2"
-checksum=f47d51fbd06e44eeaa1a82f4a153c927527c90d94514197a70b2956028cc8ad4
+checksum=a21f4e448286666cf27bafef5290cc953a0a1796b752e5bbe521266dc1230c81
 
 post_patch() {
 	sed '31a#include <locale.h>' -i  guvcview/guvcview.c

From 28aceac5ac8bd39db425db1484974f357fd8e2b7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 044/140] handbrake: update to 1.6.1

---
 .../patches/fix-missing-x265-link-flag.patch   | 11 ++++++-----
 .../handbrake/patches/libhb-vpl-include.patch  | 15 +++++++++++++++
 srcpkgs/handbrake/template                     | 18 +++++++++++-------
 3 files changed, 32 insertions(+), 12 deletions(-)
 create mode 100644 srcpkgs/handbrake/patches/libhb-vpl-include.patch

diff --git a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
index 26db03867a0c..d6bb2eda627a 100644
--- a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
+++ b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
@@ -1,14 +1,15 @@
 --- a/gtk/configure.ac
 +++ b/gtk/configure.ac
 @@ -203,7 +203,7 @@
- 
+
  AM_CONDITIONAL([MINGW], [test "x$mingw_flag" = "xyes"])
- 
--HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg"
-+HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -ldl"
+
+-HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc"
++HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc -ldl"
  HB_CPPFLAGS="$HB_CPPFLAGS $HBINC"
- 
+
  PKG_CHECK_MODULES([x264], [x264], sys_x264=yes, sys_x264=no)
+
 --- a/test/module.defs
 +++ b/test/module.defs
 @@ -69,6 +69,9 @@
diff --git a/srcpkgs/handbrake/patches/libhb-vpl-include.patch b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
new file mode 100644
index 000000000000..298f9f4ab28f
--- /dev/null
+++ b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
@@ -0,0 +1,15 @@
+--- a/libhb/module.defs	2023-01-22 11:36:49.000000000 -0500
++++ b/libhb/module.defs	2023-04-03 22:37:52.395467010 -0400
+@@ -46,11 +46,7 @@
+ LIBHB.GCC.I += $(LIBHB.build/) $(CONTRIB.build/)include
+ 
+ ifeq (1,$(FEATURE.qsv))
+-    ifeq ($(HOST.system),freebsd))
+-        LIBHB.GCC.I += $(LOCALBASE)/include/vpl
+-    else
+-        LIBHB.GCC.I += $(CONTRIB.build/)include/vpl
+-    endif
++    LIBHB.GCC.I += /usr/include/vpl
+ endif
+ 
+ ifneq (,$(filter $(HOST.system),freebsd netbsd openbsd))
diff --git a/srcpkgs/handbrake/template b/srcpkgs/handbrake/template
index ca5e4571e49c..3c2ab8659615 100644
--- a/srcpkgs/handbrake/template
+++ b/srcpkgs/handbrake/template
@@ -1,10 +1,11 @@
 # Template file for 'handbrake'
 pkgname=handbrake
-version=1.5.1
+version=1.6.1
 revision=1
+wrksrc=HandBrake-${version}
 build_style=gnu-configure
 configure_args="--force --disable-gtk-update-checks --disable-df-fetch --harden
- $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc)"
+ $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc) $(vopt_enable qsv)"
 make_build_args="-C ${XBPS_TRIPLET}"
 make_install_args="-C ${XBPS_TRIPLET}"
 hostmakedepends="automake cmake gettext-devel glib-devel intltool libtool m4 meson nasm pkg-config python3"
@@ -12,8 +13,11 @@ makedepends="bzip2-devel ffmpeg-devel gst-plugins-base1-devel gtk+3-devel
  jansson-devel lame-devel libass-devel libbluray-devel libdav1d-devel
  libdvdnav-devel libdvdread-devel libgudev-devel libnuma-devel
  libsamplerate-devel libtheora-devel libvorbis-devel libvpx-devel libxml2-devel
- opus-devel speex-devel x264-devel x265-devel zimg-devel
+ opus-devel speex-devel x264-devel x265-devel zimg-devel libsvt-av1-devel
  $(vopt_if fdk_aac fdk-aac-devel)
+ $(vopt_if qsv libva-devel)
+ $(vopt_if qsv libdrm-devel)
+ $(vopt_if qsv onevpl-devel)
  $(vopt_if nvenc nv-codec-headers)"
 depends="desktop-file-utils gst-plugins-good1 hicolor-icon-theme"
 short_desc="Multithreaded video transcoder"
@@ -21,15 +25,15 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-2.0-only"
 homepage="https://handbrake.fr/"
 distfiles="https://github.com/HandBrake/HandBrake/releases/download/${version}/HandBrake-${version}-source.tar.bz2"
-checksum=3999fe06d5309c819799a73a968a8ec3840e7840c2b64af8f5cdb7fd8c9430f0
+checksum=94ccfe03db917a91650000c510f7fd53f844da19f19ad4b4be1b8f6bc31a8d4c
 nocross=yes
 
-build_options="fdk_aac nvenc"
+build_options="fdk_aac nvenc qsv"
 
 case "$XBPS_TARGET_MACHINE" in
 	x86_64*|i686*)
 		CFLAGS="-msse"
-		build_options_default="nvenc"
+		build_options_default="nvenc qsv"
 		;;
 esac
 
@@ -37,7 +41,7 @@ pre_configure() {
 	# use system libraries, don't download them
 	rm -rf contrib/
 	for module in fdk-aac ffmpeg libbluray libdav1d libdvdnav libdvdread nvenc \
-		x265 zimg; do
+		x265 zimg svt-av1 libvpl; do
 	    vsed -i "/MODULES += contrib\/${module}/d" make/include/main.defs
 	done
 }

From de923bdfbde5b1a4c000cd948d5b2a8772c84490 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 045/140] hedgewars: revbump for ffmpeg4-4.4.3

---
 srcpkgs/hedgewars/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/hedgewars/template b/srcpkgs/hedgewars/template
index 419f29b98b44..926fe4fe3e68 100644
--- a/srcpkgs/hedgewars/template
+++ b/srcpkgs/hedgewars/template
@@ -1,13 +1,13 @@
 # Template file for 'hedgewars'
 pkgname=hedgewars
 version=1.0.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DNOSERVER=1 -DDATA_INSTALL_DIR=/usr/share/${pkgname}
  -DPHYSFS_SYSTEM=1 -DMINIMAL_FLAGS=1"
 make_cmd=make
 hostmakedepends="lua51 pkg-config qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
+makedepends="ffmpeg4-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
  SDL2_mixer-devel SDL2_net-devel SDL2_ttf-devel"
 depends="libfreeglut"
 short_desc="Funny turn-based artillery game, featuring fighting Hedgehogs!"

From 563a3d51126d0e0ec3e65ca1471f2dc40a402ef6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 046/140] idjc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/idjc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/idjc/template b/srcpkgs/idjc/template
index df60318b3db9..36a75baf597c 100644
--- a/srcpkgs/idjc/template
+++ b/srcpkgs/idjc/template
@@ -1,11 +1,11 @@
 # Template file for 'idjc'
 pkgname=idjc
 version=0.9.1
-revision=3
+revision=4
 build_style=gnu-configure
 hostmakedepends="pkg-config git python3 automake gettext-devel libtool"
 makedepends="libvorbis-devel libogg-devel jack-devel libsamplerate-devel
- libflac-devel libsndfile-devel mpg123-devel ffmpeg-devel speex-devel
+ libflac-devel libsndfile-devel mpg123-devel ffmpeg4-devel speex-devel
  glib-devel pixman-devel lame-devel python3-gobject-devel libshout-idjc-devel
  opus-devel twolame-devel python3-mutagen python3-devel"
 depends="python3-gobject python3-mutagen desktop-file-utils shared-mime-info python3-dbus jack"

From ae47a462256653492a0847b49eb47cd5e1f3a678 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 047/140] kfilemetadata5: revbump for ffmpeg-6.0

---
 srcpkgs/kfilemetadata5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kfilemetadata5/template b/srcpkgs/kfilemetadata5/template
index 8980121fbc69..f662a2043f93 100644
--- a/srcpkgs/kfilemetadata5/template
+++ b/srcpkgs/kfilemetadata5/template
@@ -1,7 +1,7 @@
 # Template file for 'kfilemetadata5'
 pkgname=kfilemetadata5
 version=5.105.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="kcoreaddons extra-cmake-modules pkg-config qt5-host-tools qt5-qmake
  gettext kcoreaddons python3"

From cdbb9f85e235fce9725fe5c9dc07a2e86a4b133c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 048/140] kid3: revbump for ffmpeg-6.0

---
 srcpkgs/kid3/patches/ffmpeg5.patch | 17 +++++++++++++++++
 srcpkgs/kid3/template              |  2 +-
 2 files changed, 18 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/kid3/patches/ffmpeg5.patch

diff --git a/srcpkgs/kid3/patches/ffmpeg5.patch b/srcpkgs/kid3/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..135fc50e07c9
--- /dev/null
+++ b/srcpkgs/kid3/patches/ffmpeg5.patch
@@ -0,0 +1,17 @@
+# https://aur.archlinux.org/cgit/aur.git/diff/ffmpeg5.patch?h=kid3-cli&id=12410a74906612e7efc0ec8fbce739b4a0fef7e7
+diff --git a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+index e156d424..e12b9abd 100644
+--- a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
++++ b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+@@ -232,7 +232,11 @@ private:
+   friend class Format;
+   friend class Converter;
+   AVCodecContext* m_ptr;
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 0, 0)
+   AVCodec* m_impl;
++#else
++  const AVCodec* m_impl;
++#endif
+   AVFrame* m_frame;
+   bool m_opened;
+ };
diff --git a/srcpkgs/kid3/template b/srcpkgs/kid3/template
index 456206d90e16..f32f9decb0e7 100644
--- a/srcpkgs/kid3/template
+++ b/srcpkgs/kid3/template
@@ -1,7 +1,7 @@
 # Template file for 'kid3'
 pkgname=kid3
 version=3.9.1
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DWITH_APPS='CLI;$(vopt_if KDE KDE Qt)'
  -DWITH_DOCBOOKDIR=/usr/share/xsl/docbook -DWITH_FLAC=$(vopt_if flac ON OFF)

From fcc89c7cdb4043b467ab41050af8dfd0e68dacf1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 049/140] kodi: revbump for ffmpeg4-4.4.3

---
 srcpkgs/kodi/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/kodi/template b/srcpkgs/kodi/template
index 8057964d78a3..6cc1874be7ba 100644
--- a/srcpkgs/kodi/template
+++ b/srcpkgs/kodi/template
@@ -1,7 +1,7 @@
 # Template file for 'kodi'
 pkgname=kodi
 version=19.4
-revision=6
+revision=7
 _codename="Matrix"
 build_style=cmake
 configure_args="-DWITH_FFMPEG=/usr -DENABLE_LDGOLD=OFF
@@ -54,7 +54,7 @@ makedepends="
  libmad-devel fontconfig-devel libXinerama-devel libsamplerate-devel libmms-devel
  enca-devel boost-devel libcurl-devel libva-devel libvdpau-devel libass-devel
  libbluetooth-devel yajl-devel libplist-devel librtmp-devel tinyxml-devel
- taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg-devel
+ taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg4-devel
  giflib-devel libxslt-devel gnutls-devel libssh-devel libmicrohttpd-devel
  libcec-devel dcadec-devel flatbuffers-devel fmt-devel lcms2-devel
  libfstrcmp-devel rapidjson libcdio-paranoia spdlog libwaylandpp-devel

From 345e9511ce2c59a3609c3cfe767722687453bdb1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 050/140] kpipewire: revbump for ffmpeg-6.0

---
 srcpkgs/kpipewire/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kpipewire/template b/srcpkgs/kpipewire/template
index 467ab823a5e1..51827f24db9e 100644
--- a/srcpkgs/kpipewire/template
+++ b/srcpkgs/kpipewire/template
@@ -1,7 +1,7 @@
 # Template file for 'kpipewire'
 pkgname=kpipewire
 version=5.27.4
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules plasma-wayland-protocols gettext
  qt5-qmake qt5-host-tools pkg-config wayland-devel kcoreaddons

From 24053eaa9fc09bc454ee9eb01511621c5c48a44d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 051/140] libextractor: revbump for ffmpeg4-4.4.3

---
 srcpkgs/libextractor/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libextractor/template b/srcpkgs/libextractor/template
index ddd4790f93e8..1fb9ca56a96a 100644
--- a/srcpkgs/libextractor/template
+++ b/srcpkgs/libextractor/template
@@ -7,7 +7,7 @@ configure_args="--disable-static"
 hostmakedepends="pkg-config"
 makedepends="zlib-devel bzip2-devel exiv2-devel tiff-devel libpng-devel
  libjpeg-turbo-devel libvorbis-devel libflac-devel giflib-devel libmpeg2-devel
- ffmpeg-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
+ ffmpeg4-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
 short_desc="Library used to extract meta data from files"
 maintainer="Martin Riese <grauehaare@gmx.de>"
 license="GPL-3.0-or-later"

From 86cb35a9f5c68b3598d5fdf806e541d0d818ea79 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 052/140] libopenal: revbump for ffmpeg-6.0

---
 srcpkgs/libopenal/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenal/template b/srcpkgs/libopenal/template
index 77218f9e539d..3f49ed75a1fd 100644
--- a/srcpkgs/libopenal/template
+++ b/srcpkgs/libopenal/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenal'
 pkgname=libopenal
 version=1.22.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DALSOFT_EXAMPLES=OFF"
 hostmakedepends="pkg-config"

From 0320728c9770a94718824c7064e8014dc581b2dd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 053/140] libopenshot: revbump for ffmpeg-6.0

---
 srcpkgs/libopenshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenshot/template b/srcpkgs/libopenshot/template
index db831f69b474..81aa0d7136d9 100644
--- a/srcpkgs/libopenshot/template
+++ b/srcpkgs/libopenshot/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenshot'
 pkgname=libopenshot
 version=0.3.0
-revision=1
+revision=2
 build_style=cmake
 # Builds fail with Ruby-2.4.1
 configure_args="-DENABLE_RUBY=OFF -DUSE_SYSTEM_JSONCPP=ON"

From a8850c66c56b254f339c01730cf536a36e20c851 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 054/140] loudgain: revbump for ffmpeg-6.0

---
 srcpkgs/loudgain/patches/ffmpeg5.patch | 11 +++++++++++
 srcpkgs/loudgain/template              |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/loudgain/patches/ffmpeg5.patch

diff --git a/srcpkgs/loudgain/patches/ffmpeg5.patch b/srcpkgs/loudgain/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..16d4510ee98f
--- /dev/null
+++ b/srcpkgs/loudgain/patches/ffmpeg5.patch
@@ -0,0 +1,11 @@
+--- a/src/scan.c	2019-09-06 11:31:19.000000000 -0400
++++ b/src/scan.c	2023-03-23 11:15:40.867968521 -0400
+@@ -69,8 +69,6 @@
+ 	 * It is now useless
+ 	 * https://github.com/FFmpeg/FFmpeg/blob/70d25268c21cbee5f08304da95be1f647c630c15/doc/APIchanges#L86
+ 	 */
+-  if (avformat_version() < AV_VERSION_INT(58,9,100))
+-    av_register_all();
+ 
+ 	av_log_set_callback(scan_av_log);
+ 
diff --git a/srcpkgs/loudgain/template b/srcpkgs/loudgain/template
index da4f2d56e94c..4d6bf29efb4f 100644
--- a/srcpkgs/loudgain/template
+++ b/srcpkgs/loudgain/template
@@ -1,7 +1,7 @@
 # Template file for 'loudgain'
 pkgname=loudgain
 version=0.6.8
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libebur128-devel taglib-devel ffmpeg-devel"

From 78c33ebcb4b9c30d700461716cffd0a59e480b5c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 055/140] mediastreamer: revbump for ffmpeg4-4.4.3

---
 srcpkgs/mediastreamer/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mediastreamer/template b/srcpkgs/mediastreamer/template
index d0e97e858e29..1bde031443a5 100644
--- a/srcpkgs/mediastreamer/template
+++ b/srcpkgs/mediastreamer/template
@@ -1,11 +1,11 @@
 # Template file for 'mediastreamer'
 pkgname=mediastreamer
 version=5.2.6
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_STRICT=0 -DENABLE_UNIT_TESTS=0"
 hostmakedepends="python3"
-makedepends="bzrtp-devel ffmpeg-devel glew-devel libXv-devel libsrtp-devel
+makedepends="bzrtp-devel ffmpeg4-devel glew-devel libXv-devel libsrtp-devel
  libupnp-devel libvpx-devel mbedtls-devel opus-devel ortp-devel pulseaudio-devel
  libtheora-devel speex-devel v4l-utils-devel bcg729-devel bcmatroska2-devel libgsm-devel"
 # zxing-cpp-devel (1.2.0 probably not compatible, check again after updaing xzing)

From 74a40808546a46252594896a3a939199ead27675 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 056/140] mgba: revbump for ffmpeg-6.0

---
 srcpkgs/mgba/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mgba/template b/srcpkgs/mgba/template
index ae0504311eee..d31295a0cd3d 100644
--- a/srcpkgs/mgba/template
+++ b/srcpkgs/mgba/template
@@ -1,7 +1,7 @@
 # Template file for 'mgba'
 pkgname=mgba
 version=0.10.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake desktop-file-utils"
 makedepends="SDL2-devel ffmpeg-devel libedit-devel libepoxy-devel libmagick-devel

From b8e1f5567fb37dce052377785069a5e37ac88b0a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 057/140] minidlna: revbump for ffmpeg-6.0

---
 srcpkgs/minidlna/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/minidlna/template b/srcpkgs/minidlna/template
index e8081b1cbc67..9ee9714861fd 100644
--- a/srcpkgs/minidlna/template
+++ b/srcpkgs/minidlna/template
@@ -1,7 +1,7 @@
 # Template file for 'minidlna'
 pkgname=minidlna
 version=1.3.2
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="
  --sbindir=/usr/bin

From 4a1c6b28e96b9b4b3a7343688ffb58f6a611050e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 058/140] mixxx: revbump for ffmpeg-6.0

---
 srcpkgs/mixxx/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mixxx/template b/srcpkgs/mixxx/template
index 619ddca0d332..4b9ea00d3fb3 100644
--- a/srcpkgs/mixxx/template
+++ b/srcpkgs/mixxx/template
@@ -1,7 +1,7 @@
 # Template file for 'mixxx'
 pkgname=mixxx
 version=2.3.3
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="extra-cmake-modules pkg-config protobuf qt5-host-tools qt5-devel"

From 7f23c0e62bcadba7e24ce2e1a3198ee4bfea78fe Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 059/140] mlt: revbump for ffmpeg4-4.4.3

---
 srcpkgs/mlt/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mlt/template b/srcpkgs/mlt/template
index 8933eb4e7bb9..73353fedafb5 100644
--- a/srcpkgs/mlt/template
+++ b/srcpkgs/mlt/template
@@ -1,14 +1,14 @@
 # Template file for 'mlt'
 pkgname=mlt
 version=6.26.1
-revision=1
+revision=2
 build_style=configure
 configure_args="--prefix=/usr --libdir=/usr/lib$XBPS_TARGET_WORDSIZE
  --enable-gpl --enable-gpl3 --disable-swfdec --without-kde
  --swig-languages=python"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which"
 # XXX: movit vid.stab
-makedepends="alsa-lib-devel ffmpeg-devel gtk+-devel jack-devel ladspa-sdk
+makedepends="alsa-lib-devel ffmpeg4-devel gtk+-devel jack-devel ladspa-sdk
  libexif-devel libsamplerate-devel libxml2-devel sox-devel SDL_image-devel
  fftw-devel frei0r-plugins python3-devel pulseaudio-devel movit-devel
  libvidstab-devel libatomic-devel"

From 7426dae5d7ab434ea223f0e79fe4b7c6a830ceb9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 060/140] moc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/moc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/moc/template b/srcpkgs/moc/template
index c42be650a1d2..d4f0eefbad52 100644
--- a/srcpkgs/moc/template
+++ b/srcpkgs/moc/template
@@ -1,10 +1,10 @@
 # Template file for 'moc'
 pkgname=moc
 version=2.5.2
-revision=6
+revision=7
 build_style=gnu-configure
 hostmakedepends="pkg-config"
-makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg-devel
+makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg4-devel
  jack-devel alsa-lib-devel libltdl-devel libflac-devel libvorbis-devel
  libmad-devel libmpcdec-devel libmodplug-devel libid3tag-devel faad2-devel
  taglib-devel libsndfile-devel wavpack-devel speex-devel libsamplerate-devel

From 8b3ce3fef5898d875463b31509c8794d36fae97f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 061/140] motion: revbump for ffmpeg-6.0

---
 srcpkgs/motion/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/motion/template b/srcpkgs/motion/template
index 3cf3c3035c5b..7dca12d851e3 100644
--- a/srcpkgs/motion/template
+++ b/srcpkgs/motion/template
@@ -1,7 +1,7 @@
 # Template file for 'motion'
 pkgname=motion
 version=4.5.1
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake pkg-config gettext-devel tar"
 makedepends="ffmpeg-devel libmicrohttpd-devel v4l-utils-devel gettext-devel"

From f46cbaf4c6f4dee663f07532151cf4f778b728eb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 062/140] mpv: revbump for ffmpeg-6.0

---
 srcpkgs/mpv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpv/template b/srcpkgs/mpv/template
index e163c496c6eb..d4fefbf5e3c7 100644
--- a/srcpkgs/mpv/template
+++ b/srcpkgs/mpv/template
@@ -1,7 +1,7 @@
 # Template file for 'mpv'
 pkgname=mpv
 version=0.35.1
-revision=2
+revision=3
 build_style=meson
 configure_args="-Dcdda=enabled -Ddvbin=enabled -Ddvdnav=enabled
  -Dlibmpv=true -Dcplugins=enabled

From e3b0a90b4158a37fdb4020f4aff351ad675e1979 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 063/140] musikcube: revbump for ffmpeg-6.0

---
 srcpkgs/musikcube/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/musikcube/template b/srcpkgs/musikcube/template
index 4b7930041126..7cd65cf76b77 100644
--- a/srcpkgs/musikcube/template
+++ b/srcpkgs/musikcube/template
@@ -1,7 +1,7 @@
 # Template file for 'musikcube'
 pkgname=musikcube
 version=0.99.4
-revision=1
+revision=2
 build_style=cmake
 make_cmd=make
 configure_args="-DNO_NCURSESW=1"

From d4b795f42b057ed90a2ff99719a8bb8b00bf3cd5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 064/140] notcurses: revbump for ffmpeg-6.0

---
 srcpkgs/notcurses/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/notcurses/template b/srcpkgs/notcurses/template
index 6dd8a091319f..3110c30c9aff 100644
--- a/srcpkgs/notcurses/template
+++ b/srcpkgs/notcurses/template
@@ -1,7 +1,7 @@
 # Template file for 'notcurses'
 pkgname=notcurses
 version=3.0.9
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DUSE_STATIC=ON $(vopt_bool man USE_PANDOC)"
 hostmakedepends="pkg-config $(vopt_if man pandoc)"

From cba457bf8a12bb55c5c145d9bcc50bc685eadab1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 065/140] obs: revbump for ffmpeg-6.0

---
 srcpkgs/obs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/obs/template b/srcpkgs/obs/template
index 89fd11297c3f..3cf49e414bf3 100644
--- a/srcpkgs/obs/template
+++ b/srcpkgs/obs/template
@@ -1,7 +1,7 @@
 # Template file for 'obs'
 pkgname=obs
 version=29.1.0
-revision=1
+revision=2
 archs="i686* x86_64* ppc64le* aarch64*"
 build_style=cmake
 configure_args="-DOBS_VERSION_OVERRIDE=${version} -DENABLE_JACK=ON

From dc07ee177bf1f11a77e38d6d9af319e2b3cc3a79 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 066/140] olive: revbump for ffmpeg4-4.4.3

---
 srcpkgs/olive/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/olive/template b/srcpkgs/olive/template
index 12a46936c990..5c2917b9c512 100644
--- a/srcpkgs/olive/template
+++ b/srcpkgs/olive/template
@@ -1,10 +1,10 @@
 # Template file for 'olive'
 pkgname=olive
 version=0.1.2
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools pkg-config"
-makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg-devel frei0r-plugins"
+makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg4-devel frei0r-plugins"
 short_desc="Non-linear video editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"

From b43691adbdd8f7326caa228f2e246ddc0e80c550 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 067/140] omxplayer: revbump for ffmpeg4-4.4.3

---
 srcpkgs/omxplayer/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/omxplayer/template b/srcpkgs/omxplayer/template
index e70bf7873d4d..c835103d8789 100644
--- a/srcpkgs/omxplayer/template
+++ b/srcpkgs/omxplayer/template
@@ -1,10 +1,10 @@
 # Template file for 'omxplayer'
 pkgname=omxplayer
 version=20190102
-revision=1
+revision=2
 short_desc="Commandline OMX player for the Raspberry Pi"
 maintainer="Orphaned <orphan@voidlinux.org>"
-license="GPL-2"
+license="GPL-2-or-later"
 homepage="https://github.com/popcornmix/omxplayer"
 
 _commit="f06235cc9690a6d58187514452df8cf8fcdaacec"
@@ -15,7 +15,7 @@ checksum=af2d9450f8947842ea8c401fe9f71eec444013ebbdee29f2ac828c9c493c1329
 archs="armv6l* armv7l*"
 build_style=gnu-makefile
 hostmakedepends="curl pkg-config"
-makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg-devel dbus-devel"
+makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg4-devel dbus-devel"
 depends="freefont-ttf"
 
 do_build() {

From c181523e510ad21c7ca28b2647415853ae05f127 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 068/140] openimageio: revbump for ffmpeg-6.0

---
 common/shlibs                | 2 ++
 srcpkgs/openimageio/template | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/shlibs b/common/shlibs
index 4626cfda810b..d0d328b09ef9 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2262,6 +2262,8 @@ libxmp.so.4 libxmp-4.3.7_1
 libKF5ThreadWeaver.so.5 threadweaver-5.26.0_1
 libOpenImageIO_Util.so.2.4 openimageio-2.4.9.0_1
 libOpenImageIO.so.2.4 openimageio-2.4.9.0_1
+libOpenImageIO_Util.so.2.4 openimageio-2.4.8.1_1
+libOpenImageIO.so.2.4 openimageio-2.4.8.1_1
 libOpenColorIO.so.2.1 opencolorio-2.1.2_1
 libpystring.so.1 pystring-1.1.3_1
 libyaml-cpp.so.0.7 yaml-cpp-0.7.0_1
diff --git a/srcpkgs/openimageio/template b/srcpkgs/openimageio/template
index b661bbf7ba57..9b38ace50f7e 100644
--- a/srcpkgs/openimageio/template
+++ b/srcpkgs/openimageio/template
@@ -1,7 +1,7 @@
 # Template file for 'openimageio'
 pkgname=openimageio
 version=2.4.9.0
-revision=2
+revision=3
 build_style=cmake
 build_helper=qemu
 configure_args="-DUSE_QT=0 -DUSE_PYTHON=0 -DOIIO_BUILD_TESTS=0

From 0d93cf026a7b56a3bd6f942c63c71bc4b48b43dd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 069/140] openmw: revbump for ffmpeg-6.0

---
 srcpkgs/openmw/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openmw/template b/srcpkgs/openmw/template
index 5251a0283dc1..e3771c7aaf1a 100644
--- a/srcpkgs/openmw/template
+++ b/srcpkgs/openmw/template
@@ -1,7 +1,7 @@
 # Template file for 'openmw'
 pkgname=openmw
 version=0.47.0
-revision=4
+revision=5
 build_style=cmake
 _recast_commit=e75adf86f91eb3082220085e42dda62679f9a3ea
 _bullet_tag=3.17

From 96a94e42a7719eca112174c79402331d7a079615 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 070/140] openshot: revbump for ffmpeg-6.0

---
 srcpkgs/openshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openshot/template b/srcpkgs/openshot/template
index 322717d40abc..c074e0338773 100644
--- a/srcpkgs/openshot/template
+++ b/srcpkgs/openshot/template
@@ -1,7 +1,7 @@
 # Template file for 'openshot'
 pkgname=openshot
 version=3.0.0
-revision=1
+revision=2
 build_style=python3-module
 hostmakedepends="python3 python3-setuptools"
 makedepends="ffmpeg-devel python3-PyQt5"

From 16853b969fd4289d545dc8e8539de5970c4b431e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 071/140] opentoonz: revbump for ffmpeg-6.0

---
 srcpkgs/opentoonz/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/opentoonz/template b/srcpkgs/opentoonz/template
index ee9f7603f55f..3e81834ca0ed 100644
--- a/srcpkgs/opentoonz/template
+++ b/srcpkgs/opentoonz/template
@@ -1,7 +1,7 @@
 # Template file for 'opentoonz'
 pkgname=opentoonz
 version=1.6.0
-revision=2
+revision=3
 build_wrksrc="toonz/sources"
 build_style=cmake
 make_cmd=make

From bddb16cb1c74d93f687afbdb8306c6f0c35084ba Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 072/140] pianobar: revbump for ffmpeg-6.0

---
 srcpkgs/pianobar/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pianobar/template b/srcpkgs/pianobar/template
index a9b29e91993f..81efcd122c4d 100644
--- a/srcpkgs/pianobar/template
+++ b/srcpkgs/pianobar/template
@@ -1,7 +1,7 @@
 # Template file for 'pianobar'
 pkgname=pianobar
 version=2022.04.01
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="V=1"
 hostmakedepends="pkg-config"

From 90cae6cbf0b385f4536714f5f2acba544de56f46 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 073/140] ppsspp: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ppsspp/template | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/ppsspp/template b/srcpkgs/ppsspp/template
index 7984a733d4be..15a42fd2c993 100644
--- a/srcpkgs/ppsspp/template
+++ b/srcpkgs/ppsspp/template
@@ -1,7 +1,7 @@
 # Template file for 'ppsspp'
 pkgname=ppsspp
 version=1.14.4
-revision=1
+revision=2
 _glslang_commit=dc11adde23c455a24e13dd54de9b4ede8bdd7db8
 _SPIRV_Cross_commit=9acb9ec31f5a8ef80ea6b994bb77be787b08d3d1
 _armips_commit=6719edebaae03330ee5441d9b28280672edf00d5
@@ -13,7 +13,7 @@ configure_args="-DHEADLESS=1 -DUSE_SYSTEM_FFMPEG=1 -DUNITTEST=ON
  -DUSING_QT_UI=$(vopt_if qt ON OFF) -DUSE_SYSTEM_ZSTD=ON
  -DARMIPS_USE_STD_FILESYSTEM=ON"
 hostmakedepends="pkg-config python3 $(vopt_if qt qt5-host-tools)"
-makedepends="zlib-devel glew-devel ffmpeg-devel libzip-devel
+makedepends="zlib-devel glew-devel ffmpeg4-devel libzip-devel
  snappy-devel rapidjson libpng-devel libzstd-devel
  $(vopt_if sdl2 SDL2-devel) $(vopt_if wayland wayland-devel)
  $(vopt_if qt 'qt5-devel qt5-multimedia-devel')"
@@ -62,13 +62,12 @@ post_extract() {
 	mv ${wrksrc}/miniupnp-${_miniupnp_commit} ${wrksrc}/ext/miniupnp
 }
 
-post_patch(){
+post_patch() {
 	# disable git versioning
 	vsed -e 's|find_package(Git)|# &|' -i git-version.cmake
 }
 
 do_install() {
-	vlicense LICENSE.TXT
 	vinstall icons/icon.svg 644 usr/share/pixmaps ppsspp.svg
 	vinstall Qt/PPSSPP.desktop 644 usr/share/applications
 	vbin build/PPSSPPHeadless ppsspp-headless

From cb6988a511ed1a99d34dcc0121889f28cdfcbbe7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 074/140] pqiv: revbump for ffmpeg-6.0

---
 srcpkgs/pqiv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pqiv/template b/srcpkgs/pqiv/template
index 542fc27a2d32..9308d949b6a1 100644
--- a/srcpkgs/pqiv/template
+++ b/srcpkgs/pqiv/template
@@ -1,7 +1,7 @@
 # Template file for 'pqiv'
 pkgname=pqiv
 version=2.12
-revision=1
+revision=2
 build_style=gnu-makefile
 hostmakedepends="pkg-config"
 makedepends="glib-devel gtk+3-devel $(vopt_if ffmpeg ffmpeg-devel)

From c2a2a18c8a5809c68bb764ec475b4131042e7192 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 075/140] qmmp: revbump for ffmpeg-6.0

---
 srcpkgs/qmmp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qmmp/template b/srcpkgs/qmmp/template
index 26c661ed16be..a150d7441c7a 100644
--- a/srcpkgs/qmmp/template
+++ b/srcpkgs/qmmp/template
@@ -1,7 +1,7 @@
 # Template file for 'qmmp'
 pkgname=qmmp
 version=1.6.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DUSE_HAL:BOOL=FALSE -DQMMP_DEFAULT_UI:STRING=simple"
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From 9057694e1c778a3107703dd582126ca58902dc18 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 076/140] qt5-webengine: update to 5.15.13

---
 .../chromium-media-filters-cpp14.patch        |  11 ++
 srcpkgs/qt5-webengine/patches/ffmpeg5.patch   | 179 ++++++++++++++++++
 srcpkgs/qt5-webengine/template                |  10 +-
 3 files changed, 195 insertions(+), 5 deletions(-)
 create mode 100644 srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/ffmpeg5.patch

diff --git a/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
new file mode 100644
index 000000000000..04adc540f2cb
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
@@ -0,0 +1,11 @@
+--- a/src/3rdparty/chromium/media/filters/BUILD.gn	2023-02-27 13:32:59.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/BUILD.gn	2023-04-02 17:21:39.204066384 -0400
+@@ -96,6 +96,8 @@
+     "//ui/gfx/geometry:geometry",
+   ]
+ 
++  cflags_cc = [ "-std=c++14" ]
++
+   libs = []
+ 
+   if (proprietary_codecs) {
diff --git a/srcpkgs/qt5-webengine/patches/ffmpeg5.patch b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..ac55e1634423
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
@@ -0,0 +1,179 @@
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:57.732547446 -0400
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:09.486478995 -0400
+@@ -57,6 +57,8 @@
+ 
+ namespace {
+ 
++constexpr int64_t kRelativeTsBase = static_cast<int64_t>(0x7ffeffffffffffff);
++
+ void SetAVStreamDiscard(AVStream* stream, AVDiscard discard) {
+   DCHECK(stream);
+   stream->discard = discard;
+@@ -90,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+   if (stream->start_time != kNoFFmpegTimestamp)
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (stream->first_dts != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, stream->first_dts);
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -408,11 +398,11 @@
+   scoped_refptr<DecoderBuffer> buffer;
+ 
+   if (type() == DemuxerStream::TEXT) {
+-    int id_size = 0;
++    size_t id_size = 0;
+     uint8_t* id_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
+ 
+-    int settings_size = 0;
++    size_t settings_size = 0;
+     uint8_t* settings_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
+ 
+@@ -424,7 +414,7 @@
+     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
+                                      side_data.data(), side_data.size());
+   } else {
+-    int side_data_size = 0;
++    size_t side_data_size = 0;
+     uint8_t* side_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
+ 
+@@ -485,7 +475,7 @@
+                                        packet->size - data_offset);
+     }
+ 
+-    int skip_samples_size = 0;
++    size_t skip_samples_size = 0;
+     const uint32_t* skip_samples_ptr =
+         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
+             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
+@@ -1587,6 +1577,8 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++      continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+       lowest_start_time_stream = stream.get();
+@@ -1604,6 +1596,8 @@
+     if (stream && stream->type() == DemuxerStream::VIDEO &&
+         stream->IsEnabled()) {
+       video_stream = stream.get();
++      if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++        continue;
+       if (video_stream->start_time() <= seek_time) {
+         return video_stream;
+       }
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h qtwebengine-5.15.10/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h
+--- a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-07-11 22:12:47.917192788 -0500
+@@ -29,6 +29,7 @@ extern "C" {
+ #include <libavformat/avformat.h>
+ #include <libavformat/avio.h>
+ #include <libavutil/avutil.h>
++#include <libavutil/channel_layout.h>
+ #include <libavutil/imgutils.h>
+ #include <libavutil/log.h>
+ #include <libavutil/mastering_display_metadata.h>
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/audio_file_reader.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/audio_file_reader.cc
+--- a/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -85,7 +85,7 @@ bool AudioFileReader::OpenDemuxer() {
+ }
+ 
+ bool AudioFileReader::OpenDecoder() {
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (codec) {
+     // MP3 decodes to S16P which we don't support, tell it to use S16 instead.
+     if (codec_context_->sample_fmt == AV_SAMPLE_FMT_S16P)
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -329,7 +329,7 @@ bool FFmpegAudioDecoder::ConfigureDecode
+     }
+   }
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec ||
+       avcodec_open2(codec_context_.get(), codec, &codec_options) < 0) {
+     DLOG(ERROR) << "Could not initialize audio decoder: "
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -59,7 +59,6 @@ static int64_t AVIOSeekOperation(void* o
+ }
+ 
+ void FFmpegGlue::InitializeFFmpeg() {
+-  av_register_all();
+ }
+ 
+ static void LogContainer(bool is_local_file,
+@@ -95,9 +94,6 @@ FFmpegGlue::FFmpegGlue(FFmpegURLProtocol
+   // Enable fast, but inaccurate seeks for MP3.
+   format_context_->flags |= AVFMT_FLAG_FAST_SEEK;
+ 
+-  // Ensures we can read out various metadata bits like vp8 alpha.
+-  format_context_->flags |= AVFMT_FLAG_KEEP_SIDE_DATA;
+-
+   // Ensures format parsing errors will bail out. From an audit on 11/2017, all
+   // instances were real failures. Solves bugs like http://crbug.com/710791.
+   format_context_->error_recognition |= AV_EF_EXPLODE;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -391,7 +391,7 @@ bool FFmpegVideoDecoder::ConfigureDecode
+   if (decode_nalus_)
+     codec_context_->flags2 |= AV_CODEC_FLAG2_CHUNKS;
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
+     ReleaseFFmpegResources();
+     return false;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/media_file_checker.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/media_file_checker.cc
+--- a/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -68,7 +68,7 @@ bool MediaFileChecker::Start(base::TimeD
+       auto context = AVStreamToAVCodecContext(format_context->streams[i]);
+       if (!context)
+         continue;
+-      AVCodec* codec = avcodec_find_decoder(cp->codec_id);
++      const AVCodec* codec = avcodec_find_decoder(cp->codec_id);
+       if (codec && avcodec_open2(context.get(), codec, nullptr) >= 0) {
+         auto loop = std::make_unique<FFmpegDecodingLoop>(context.get());
+         stream_contexts[i] = {std::move(context), std::move(loop)};
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc qtwebengine-5.15.10/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc
+--- a/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -203,7 +203,7 @@ int32_t H264DecoderImpl::InitDecode(cons
+   // a pointer |this|.
+   av_context_->opaque = this;
+ 
+-  AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
+   if (!codec) {
+     // This is an indication that FFmpeg has not been initialized or it has not
+     // been compiled/initialized with the correct set of codecs.
diff --git a/srcpkgs/qt5-webengine/template b/srcpkgs/qt5-webengine/template
index 0a71484208bc..095ab67701e4 100644
--- a/srcpkgs/qt5-webengine/template
+++ b/srcpkgs/qt5-webengine/template
@@ -1,9 +1,9 @@
 # Template file for 'qt5-webengine'
 pkgname=qt5-webengine
-version=5.15.11
-revision=2
+version=5.15.13
+revision=1
 _version="${version}-lts"
-_chromium_commit=be349eaf62e77955791d7bf29f893f1e8a37daf4
+_chromium_commit=e48df7803c7c98b0b2471c94057d32e44a301ad5
 archs="x86_64* i686* armv[67]* ppc64* aarch64*"
 create_wrksrc=yes
 build_style=qmake
@@ -32,8 +32,8 @@ license="GPL-3.0-or-later, LGPL-3.0-or-later"
 homepage="https://qt.io/"
 distfiles="https://github.com/qt/qtwebengine/archive/v${_version}.tar.gz
  https://github.com/qt/qtwebengine-chromium/archive/${_chromium_commit}.tar.gz"
-checksum="aa7466356c450c5f5870f979b93cd7e7e62da1165c328ffcab1a9928db18ad67
- 6f47ed8ab8cc062411f6f206da6353bc8263d6ed6d6290c689a05c01d91f646b"
+checksum="4b59838ed75ef788b59e1e412535a0e42dd9d311661fdeadb191b581ba815c63
+ a91686562b1d4e8b220e0bbcbab5feb64630e2de974b35ac034bf388af771a6c"
 
 no_generic_pkgconfig_link=yes
 build_options="sndio pipewire"

From 8dd8e94477a4f061395dfe7e1e8c5a2ef8a2ab46 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 077/140] qt5: update to 5.15.8

---
 ...erywhere-opensource-src-5.15.8-kf5-1.patch | 12913 ++++++++++++++++
 srcpkgs/qt5/template                          |    10 +-
 2 files changed, 12919 insertions(+), 4 deletions(-)
 create mode 100644 srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch

diff --git a/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch b/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch
new file mode 100644
index 000000000000..966c98bcd3bb
--- /dev/null
+++ b/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch
@@ -0,0 +1,12913 @@
+Submitted By:            Pierre Labastie <pierre_dot_labastie_at_neuf_dot_fr>
+Date:                    2023-01-05
+Initial Package Version: 5.15.8
+Upstream Status:         Applied (according to KDE)
+Origin:                  KDE patch set
+Description:             Patch set maintained by the KDE folks
+see https://dot.kde.org/2021/04/06/announcing-kdes-qt-5-patch-collection
+Patch generated using the procedure in
+https://wiki.linuxfromscratch.org/blfs/ticket/17476#comment:3
+
+Submodule qtbase 4ee4fc18..9cf586d6:
+diff --git a/qtbase/mkspecs/common/android/qplatformdefs.h b/qtbase/mkspecs/common/android/qplatformdefs.h
+index f75bc4093b..2bd59410d4 100644
+--- a/qtbase/mkspecs/common/android/qplatformdefs.h
++++ b/qtbase/mkspecs/common/android/qplatformdefs.h
+@@ -144,11 +144,7 @@
+ #define QT_SIGNAL_ARGS          int
+ #define QT_SIGNAL_IGNORE        SIG_IGN
+ 
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+ #define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+ 
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+diff --git a/qtbase/mkspecs/features/mac/sdk.mk b/qtbase/mkspecs/features/mac/sdk.mk
+index f30b5830b4..a32ceacb6c 100644
+--- a/qtbase/mkspecs/features/mac/sdk.mk
++++ b/qtbase/mkspecs/features/mac/sdk.mk
+@@ -1,6 +1,6 @@
+ 
+ ifeq ($(QT_MAC_SDK_NO_VERSION_CHECK),)
+-    CHECK_SDK_COMMAND = /usr/bin/xcrun --sdk $(EXPORT_QMAKE_MAC_SDK) -show-sdk-version 2>&1
++    CHECK_SDK_COMMAND = /usr/bin/xcrun --sdk $(EXPORT_QMAKE_MAC_SDK) -show-sdk-version 2>/dev/null
+     CURRENT_MAC_SDK_VERSION := $(shell DEVELOPER_DIR=$(EXPORT_QMAKE_XCODE_DEVELOPER_PATH) $(CHECK_SDK_COMMAND))
+     ifneq ($(CURRENT_MAC_SDK_VERSION),$(EXPORT_QMAKE_MAC_SDK_VERSION))
+         # We don't want to complain about out of date SDK unless the target needs to be remade.
+diff --git a/qtbase/mkspecs/linux-clang/qplatformdefs.h b/qtbase/mkspecs/linux-clang/qplatformdefs.h
+index a818d973f0..c1ab72fbc6 100644
+--- a/qtbase/mkspecs/linux-clang/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-clang/qplatformdefs.h
+@@ -79,14 +79,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-g++/qplatformdefs.h b/qtbase/mkspecs/linux-g++/qplatformdefs.h
+index 13523f0702..4d2750d9ec 100644
+--- a/qtbase/mkspecs/linux-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-g++/qplatformdefs.h
+@@ -79,14 +79,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ < 2)
+-#define QT_SOCKLEN_T            int
+-#else
+-#define QT_SOCKLEN_T            socklen_t
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-llvm/qplatformdefs.h b/qtbase/mkspecs/linux-llvm/qplatformdefs.h
+index dc750ab1ef..d3cc39b47f 100644
+--- a/qtbase/mkspecs/linux-llvm/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-llvm/qplatformdefs.h
+@@ -80,14 +80,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h b/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
+index 4c4e53da2a..83baffb3e3 100644
+--- a/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
+@@ -85,16 +85,9 @@
+ #include "../common/posix/qplatformdefs.h"
+ 
+ #undef QT_OPEN_LARGEFILE
+-#undef QT_SOCKLEN_T
+ 
+ #define QT_OPEN_LARGEFILE       0
+ 
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #ifndef SIOCGIFBRDADDR
+ #  define SIOCGIFBRDADDR 0x8919
+ #endif
+diff --git a/qtbase/mkspecs/lynxos-g++/qplatformdefs.h b/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
+index 4339ea2b23..6007af0055 100644
+--- a/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
+@@ -72,14 +72,6 @@
+ 
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp b/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
+index c3c184258f..32af3f8f29 100644
+--- a/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
++++ b/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
+@@ -10,6 +10,7 @@
+ #include "libANGLE/HandleAllocator.h"
+ 
+ #include <algorithm>
++#include <limits>
+ 
+ #include "common/debug.h"
+ 
+diff --git a/qtbase/src/3rdparty/forkfd/forkfd_linux.c b/qtbase/src/3rdparty/forkfd/forkfd_linux.c
+index ffe0e9a5e2..b1f5408d11 100644
+--- a/qtbase/src/3rdparty/forkfd/forkfd_linux.c
++++ b/qtbase/src/3rdparty/forkfd/forkfd_linux.c
+@@ -82,7 +82,8 @@ static int sys_clone(unsigned long cloneflags, int *ptid)
+     return syscall(__NR_clone, cloneflags, child_stack, stack_size, ptid, newtls, ctid);
+ #elif defined(__arc__) || defined(__arm__) || defined(__aarch64__) || defined(__mips__) || \
+     defined(__nds32__) || defined(__hppa__) || defined(__powerpc__) || defined(__i386__) || \
+-    defined(__x86_64__) || defined(__xtensa__) || defined(__alpha__) || defined(__riscv)
++    defined(__x86_64__) || defined(__xtensa__) || defined(__alpha__) || defined(__riscv) || \
++    defined(__loongarch__)
+     /* ctid and newtls are inverted on CONFIG_CLONE_BACKWARDS architectures,
+      * but since both values are 0, there's no harm. */
+     return syscall(__NR_clone, cloneflags, child_stack, ptid, ctid, newtls);
+diff --git a/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java b/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
+index 5792b5b2f5..2f74750fcf 100644
+--- a/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
++++ b/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
+@@ -116,6 +116,7 @@ public class QtNative
+     public static QtThread m_qtThread = new QtThread();
+     private static HashMap<String, Uri> m_cachedUris = new HashMap<String, Uri>();
+     private static ArrayList<String> m_knownDirs = new ArrayList<String>();
++    private static final String NoPermissionErrorMessage = "No permissions to open Uri";
+ 
+     private static final Runnable runPendingCppRunnablesRunnable = new Runnable() {
+         @Override
+@@ -193,11 +194,10 @@ public class QtNative
+                     return iterUri;
+             }
+ 
+-            // Android 6 and earlier could still manage to open the file so we can return the
+-            // parsed uri here
+-            if (Build.VERSION.SDK_INT < 24)
+-                return parsedUri;
+-            return null;
++            // if we only have transient permissions on uri all the above will fail,
++            // but we will be able to read the file anyway, so continue with uri here anyway
++            // and check for SecurityExceptions later
++            return parsedUri;
+         } catch (SecurityException e) {
+             e.printStackTrace();
+             return null;
+@@ -244,7 +244,7 @@ public class QtNative
+         int error = -1;
+ 
+         if (uri == null) {
+-            Log.e(QtTAG, "openFdForContentUrl(): No permissions to open Uri");
++            Log.e(QtTAG, "openFdForContentUrl(): " + NoPermissionErrorMessage);
+             return error;
+         }
+ 
+@@ -254,12 +254,13 @@ public class QtNative
+             return fdDesc.detachFd();
+         } catch (FileNotFoundException e) {
+             e.printStackTrace();
+-            return error;
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "openFdForContentUrl(): Invalid Uri");
+             e.printStackTrace();
+-            return error;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return error;
+     }
+ 
+     public static long getSize(Context context, String contentUrl)
+@@ -270,7 +271,7 @@ public class QtNative
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+ 
+         if (uri == null) {
+-            Log.e(QtTAG, "getSize(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return size;
+         } else if (!m_cachedUris.containsKey(contentUrl)) {
+             m_cachedUris.put(contentUrl, uri);
+@@ -288,12 +289,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "getSize(): Invalid Uri");
+             e.printStackTrace();
+-            return size;
+         }  catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "getSize(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return size;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return size;
+     }
+ 
+     public static boolean checkFileExists(Context context, String contentUrl)
+@@ -303,7 +305,7 @@ public class QtNative
+         if (uri == null)
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+         if (uri == null) {
+-            Log.e(QtTAG, "checkFileExists(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return exists;
+         } else {
+             if (!m_cachedUris.containsKey(contentUrl))
+@@ -321,12 +323,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "checkFileExists(): Invalid Uri");
+             e.printStackTrace();
+-            return exists;
+         } catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "checkFileExists(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return false;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return exists;
+     }
+ 
+     public static boolean checkIfWritable(Context context, String contentUrl)
+@@ -344,7 +347,7 @@ public class QtNative
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+         }
+         if (uri == null) {
+-            Log.e(QtTAG, "isDir(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return isDir;
+         } else {
+             if (!m_cachedUris.containsKey(contentUrl))
+@@ -374,12 +377,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "checkIfDir(): Invalid Uri");
+             e.printStackTrace();
+-            return false;
+         } catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "checkIfDir(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return false;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return false;
+     }
+     public static String[] listContentsFromTreeUri(Context context, String contentUrl)
+     {
+diff --git a/qtbase/src/concurrent/qtconcurrentreducekernel.h b/qtbase/src/concurrent/qtconcurrentreducekernel.h
+index 8f9a938952..a98dedef2e 100644
+--- a/qtbase/src/concurrent/qtconcurrentreducekernel.h
++++ b/qtbase/src/concurrent/qtconcurrentreducekernel.h
+@@ -212,11 +212,13 @@ public:
+ 
+     inline bool shouldThrottle()
+     {
++        std::lock_guard<QMutex> locker(mutex);
+         return (resultsMapSize > (ReduceQueueThrottleLimit * threadCount));
+     }
+ 
+     inline bool shouldStartThread()
+     {
++        std::lock_guard<QMutex> locker(mutex);
+         return (resultsMapSize <= (ReduceQueueStartLimit * threadCount));
+     }
+ };
+diff --git a/qtbase/src/concurrent/qtconcurrentthreadengine.cpp b/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
+index ea6ce3ac42..7f91a2ba68 100644
+--- a/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
++++ b/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
+@@ -176,6 +176,39 @@ void ThreadEngineBase::startSingleThreaded()
+     finish();
+ }
+ 
++void ThreadEngineBase::startBlocking()
++{
++    start();
++    barrier.acquire();
++    startThreads();
++
++    bool throttled = false;
++#ifndef QT_NO_EXCEPTIONS
++    try {
++#endif
++        while (threadFunction() == ThrottleThread) {
++            if (threadThrottleExit()) {
++                throttled = true;
++                break;
++            }
++        }
++#ifndef QT_NO_EXCEPTIONS
++    } catch (QException &e) {
++        handleException(e);
++    } catch (...) {
++        handleException(QUnhandledException());
++    }
++#endif
++
++    if (throttled == false) {
++        barrier.release();
++    }
++
++    barrier.wait();
++    finish();
++    exceptionStore.throwPossibleException();
++}
++
+ void ThreadEngineBase::startThread()
+ {
+     startThreadInternal();
+diff --git a/qtbase/src/concurrent/qtconcurrentthreadengine.h b/qtbase/src/concurrent/qtconcurrentthreadengine.h
+index 7c30cebdbc..a4c8548cc4 100644
+--- a/qtbase/src/concurrent/qtconcurrentthreadengine.h
++++ b/qtbase/src/concurrent/qtconcurrentthreadengine.h
+@@ -91,6 +91,7 @@ public:
+     ThreadEngineBase();
+     virtual ~ThreadEngineBase();
+     void startSingleThreaded();
++    void startBlocking();
+     void startThread();
+     bool isCanceled();
+     void waitForResume();
+@@ -143,6 +144,15 @@ public:
+         return result();
+     }
+ 
++    // Runs the user algorithm using multiple threads.
++    // This function blocks until the algorithm is finished,
++    // and then returns the result.
++    T *startBlocking()
++    {
++        ThreadEngineBase::startBlocking();
++        return result();
++    }
++
+     // Runs the user algorithm using multiple threads.
+     // Does not block, returns a future.
+     QFuture<T> startAsynchronously()
+@@ -223,6 +233,13 @@ class ThreadEngineStarter : public ThreadEngineStarterBase<T>
+ public:
+     ThreadEngineStarter(TypedThreadEngine *eng)
+         : Base(eng) { }
++
++    T startBlocking()
++    {
++        T t = *this->threadEngine->startBlocking();
++        delete this->threadEngine;
++        return t;
++    }
+ };
+ 
+ // Full template specialization where T is void.
+@@ -232,6 +249,12 @@ class ThreadEngineStarter<void> : public ThreadEngineStarterBase<void>
+ public:
+     ThreadEngineStarter(ThreadEngine<void> *_threadEngine)
+         : ThreadEngineStarterBase<void>(_threadEngine) {}
++
++    void startBlocking()
++    {
++        this->threadEngine->startBlocking();
++        delete this->threadEngine;
++    }
+ };
+ 
+ //! [qtconcurrentthreadengine-1]
+diff --git a/qtbase/src/corelib/animation/qvariantanimation.cpp b/qtbase/src/corelib/animation/qvariantanimation.cpp
+index 98b02f0202..eac1524107 100644
+--- a/qtbase/src/corelib/animation/qvariantanimation.cpp
++++ b/qtbase/src/corelib/animation/qvariantanimation.cpp
+@@ -276,7 +276,9 @@ void QVariantAnimationPrivate::setCurrentValueForProgress(const qreal progress)
+ 
+     const qreal startProgress = currentInterval.start.first;
+     const qreal endProgress = currentInterval.end.first;
+-    const qreal localProgress = (progress - startProgress) / (endProgress - startProgress);
++    const qreal localProgress =
++            qIsNull(progress - startProgress) ? 0.0 // avoid 0/0 below
++            /* else */                        : (progress - startProgress) / (endProgress - startProgress);
+ 
+     QVariant ret = q->interpolated(currentInterval.start.second,
+                                    currentInterval.end.second,
+diff --git a/qtbase/src/corelib/global/qnamespace.h b/qtbase/src/corelib/global/qnamespace.h
+index ad4150b317..bf19b1627b 100644
+--- a/qtbase/src/corelib/global/qnamespace.h
++++ b/qtbase/src/corelib/global/qnamespace.h
+@@ -1864,7 +1864,7 @@ public:
+     QT_Q_ENUM(TimerType)
+     QT_Q_ENUM(ScrollPhase)
+     QT_Q_ENUM(MouseEventSource)
+-    QT_Q_FLAG(MouseEventFlag)
++    QT_Q_FLAG(MouseEventFlags)
+     QT_Q_ENUM(ChecksumType)
+     QT_Q_ENUM(HighDpiScaleFactorRoundingPolicy)
+     QT_Q_ENUM(TabFocusBehavior)
+diff --git a/qtbase/src/corelib/global/qrandom.cpp b/qtbase/src/corelib/global/qrandom.cpp
+index 10672c1f92..25f87c7e6a 100644
+--- a/qtbase/src/corelib/global/qrandom.cpp
++++ b/qtbase/src/corelib/global/qrandom.cpp
+@@ -383,7 +383,6 @@ struct QRandomGenerator::SystemAndGlobalGenerators
+ 
+         constexpr SystemAndGlobalGenerators g = {};
+         Q_UNUSED(g);
+-        Q_STATIC_ASSERT(std::is_literal_type<SystemAndGlobalGenerators>::value);
+ #endif
+     }
+ 
+diff --git a/qtbase/src/corelib/io/qbuffer.cpp b/qtbase/src/corelib/io/qbuffer.cpp
+index 595fcd2724..032c0ddd4b 100644
+--- a/qtbase/src/corelib/io/qbuffer.cpp
++++ b/qtbase/src/corelib/io/qbuffer.cpp
+@@ -41,6 +41,8 @@
+ #include <QtCore/qmetaobject.h>
+ #include "private/qiodevice_p.h"
+ 
++#include <limits>
++
+ QT_BEGIN_NAMESPACE
+ 
+ /** QBufferPrivate **/
+@@ -366,7 +368,9 @@ qint64 QBuffer::size() const
+ bool QBuffer::seek(qint64 pos)
+ {
+     Q_D(QBuffer);
+-    if (pos > d->buf->size() && isWritable()) {
++    const auto oldBufSize = d->buf->size();
++    constexpr qint64 MaxSeekPos = (std::numeric_limits<decltype(oldBufSize)>::max)();
++    if (pos <= MaxSeekPos && pos > oldBufSize && isWritable()) {
+         if (seek(d->buf->size())) {
+             const qint64 gapSize = pos - d->buf->size();
+             if (write(QByteArray(gapSize, 0)) != gapSize) {
+@@ -377,7 +381,7 @@ bool QBuffer::seek(qint64 pos)
+             return false;
+         }
+     } else if (pos > d->buf->size() || pos < 0) {
+-        qWarning("QBuffer::seek: Invalid pos: %d", int(pos));
++        qWarning("QBuffer::seek: Invalid pos: %lld", pos);
+         return false;
+     }
+     return QIODevice::seek(pos);
+diff --git a/qtbase/src/corelib/io/qfilesystemengine_win.cpp b/qtbase/src/corelib/io/qfilesystemengine_win.cpp
+index 81d3a71986..c86ed1f9b0 100644
+--- a/qtbase/src/corelib/io/qfilesystemengine_win.cpp
++++ b/qtbase/src/corelib/io/qfilesystemengine_win.cpp
+@@ -664,14 +664,14 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry)
+     return QFileSystemEntry(ret, QFileSystemEntry::FromInternalPath());
+ }
+ 
+-#if defined(Q_CC_MINGW) && WINVER < 0x0602 //  Windows 8 onwards
++#if defined(Q_CC_MINGW) && WINVER < 0x0602 && _WIN32_WINNT < _WIN32_WINNT_WIN8 //  Windows 8 onwards
+ 
+ typedef struct _FILE_ID_INFO {
+     ULONGLONG VolumeSerialNumber;
+     FILE_ID_128 FileId;
+ } FILE_ID_INFO, *PFILE_ID_INFO;
+ 
+-#endif // if defined (Q_CC_MINGW) && WINVER < 0x0602
++#endif // if defined(Q_CC_MINGW) && WINVER < 0x0602 && _WIN32_WINNT < _WIN32_WINNT_WIN8
+ 
+ // File ID for Windows up to version 7 and FAT32 drives
+ static inline QByteArray fileId(HANDLE handle)
+diff --git a/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp b/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
+index 94d9d06bcb..27e0b13b0b 100644
+--- a/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
++++ b/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
+@@ -366,7 +366,9 @@ void QInotifyFileSystemWatcherEngine::readFromInotify()
+     // qDebug("QInotifyFileSystemWatcherEngine::readFromInotify");
+ 
+     int buffSize = 0;
+-    ioctl(inotifyFd, FIONREAD, (char *) &buffSize);
++    if (ioctl(inotifyFd, FIONREAD, (char *) &buffSize) == -1 || buffSize == 0)
++        return;
++
+     QVarLengthArray<char, 4096> buffer(buffSize);
+     buffSize = read(inotifyFd, buffer.data(), buffSize);
+     char *at = buffer.data();
+diff --git a/qtbase/src/corelib/io/qlockfile_win.cpp b/qtbase/src/corelib/io/qlockfile_win.cpp
+index 277f8d4230..38ecef5550 100644
+--- a/qtbase/src/corelib/io/qlockfile_win.cpp
++++ b/qtbase/src/corelib/io/qlockfile_win.cpp
+@@ -48,6 +48,8 @@
+ #include "QtCore/qdebug.h"
+ #include "QtCore/qthread.h"
+ 
++#include "private/qsystemlibrary_p.h"
++
+ QT_BEGIN_NAMESPACE
+ 
+ static inline bool fileExists(const wchar_t *fileName)
+@@ -150,7 +152,7 @@ QString QLockFilePrivate::processNameByPid(qint64 pid)
+ #if !defined(Q_OS_WINRT)
+     typedef DWORD (WINAPI *GetModuleFileNameExFunc)(HANDLE, HMODULE, LPTSTR, DWORD);
+ 
+-    HMODULE hPsapi = LoadLibraryA("psapi");
++    HMODULE hPsapi = QSystemLibrary::load(L"psapi");
+     if (!hPsapi)
+         return QString();
+     GetModuleFileNameExFunc qGetModuleFileNameEx = reinterpret_cast<GetModuleFileNameExFunc>(
+diff --git a/qtbase/src/corelib/io/qprocess_unix.cpp b/qtbase/src/corelib/io/qprocess_unix.cpp
+index 50390e57f5..15c8f30745 100644
+--- a/qtbase/src/corelib/io/qprocess_unix.cpp
++++ b/qtbase/src/corelib/io/qprocess_unix.cpp
+@@ -1,7 +1,7 @@
+ /****************************************************************************
+ **
+ ** Copyright (C) 2016 The Qt Company Ltd.
+-** Copyright (C) 2016 Intel Corporation.
++** Copyright (C) 2022 Intel Corporation.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtCore module of the Qt Toolkit.
+@@ -422,14 +422,15 @@ void QProcessPrivate::startProcess()
+     // Add the program name to the argument list.
+     argv[0] = nullptr;
+     if (!program.contains(QLatin1Char('/'))) {
++        // findExecutable() returns its argument if it's an absolute path,
++        // otherwise it searches $PATH; returns empty if not found (we handle
++        // that case much later)
+         const QString &exeFilePath = QStandardPaths::findExecutable(program);
+-        if (!exeFilePath.isEmpty()) {
+-            const QByteArray &tmp = QFile::encodeName(exeFilePath);
+-            argv[0] = ::strdup(tmp.constData());
+-        }
+-    }
+-    if (!argv[0])
++        const QByteArray &tmp = QFile::encodeName(exeFilePath);
++        argv[0] = ::strdup(tmp.constData());
++    } else {
+         argv[0] = ::strdup(encodedProgramName.constData());
++    }
+ 
+     // Add every argument to the list
+     for (int i = 0; i < arguments.count(); ++i)
+@@ -983,15 +984,16 @@ bool QProcessPrivate::startDetached(qint64 *pid)
+                 envp = _q_dupEnvironment(environment.d.constData()->vars, &envc);
+             }
+ 
+-            QByteArray tmp;
+             if (!program.contains(QLatin1Char('/'))) {
++                // findExecutable() returns its argument if it's an absolute path,
++                // otherwise it searches $PATH; returns empty if not found (we handle
++                // that case much later)
+                 const QString &exeFilePath = QStandardPaths::findExecutable(program);
+-                if (!exeFilePath.isEmpty())
+-                    tmp = QFile::encodeName(exeFilePath);
++                const QByteArray &tmp = QFile::encodeName(exeFilePath);
++                argv[0] = ::strdup(tmp.constData());
++            } else {
++                argv[0] = ::strdup(QFile::encodeName(program));
+             }
+-            if (tmp.isEmpty())
+-                tmp = QFile::encodeName(program);
+-            argv[0] = tmp.data();
+ 
+             if (envp)
+                 qt_safe_execve(argv[0], argv, envp);
+diff --git a/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp b/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
+index 3a79c502af..997a634e76 100644
+--- a/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
++++ b/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
+@@ -3196,9 +3196,8 @@ bool QAbstractItemModel::beginMoveColumns(const QModelIndex &sourceParent, int s
+     destinationChange.needsAdjust = destinationParent.isValid() && destinationParent.row() >= sourceLast && destinationParent.parent() == sourceParent;
+     d->changes.push(destinationChange);
+ 
+-    d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Horizontal);
+-
+     emit columnsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, QPrivateSignal());
++    d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Horizontal);
+     return true;
+ }
+ 
+@@ -3231,7 +3230,6 @@ void QAbstractItemModel::endMoveColumns()
+       adjustedSource = createIndex(adjustedSource.row(), adjustedSource.column() + numMoved, adjustedSource.internalPointer());
+ 
+     d->itemsMoved(adjustedSource, removeChange.first, removeChange.last, adjustedDestination, insertChange.first, Qt::Horizontal);
+-
+     emit columnsMoved(adjustedSource, removeChange.first, removeChange.last, adjustedDestination, insertChange.first, QPrivateSignal());
+ }
+ 
+diff --git a/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+index dc6379d9fb..c5e287ee84 100644
+--- a/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
++++ b/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+@@ -939,8 +939,9 @@ void QSortFilterProxyModelPrivate::insert_source_items(
+                 q->beginInsertColumns(proxy_parent, proxy_start, proxy_end);
+         }
+ 
+-        for (int i = 0; i < source_items.size(); ++i)
+-            proxy_to_source.insert(proxy_start + i, source_items.at(i));
++        // TODO: use the range QList::insert() overload once it is implemented (QTBUG-58633).
++        proxy_to_source.insert(proxy_start, source_items.size(), 0);
++        std::copy(source_items.cbegin(), source_items.cend(), proxy_to_source.begin() + proxy_start);
+ 
+         build_source_to_proxy_mapping(proxy_to_source, source_to_proxy);
+ 
+@@ -3123,8 +3124,9 @@ bool QSortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex &
+ 
+     if (d->filter_data.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();
+@@ -3133,9 +3135,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.hasMatch(key);
+ }
+diff --git a/qtbase/src/corelib/kernel/qcoreapplication.cpp b/qtbase/src/corelib/kernel/qcoreapplication.cpp
+index ca2864df83..132b2eae52 100644
+--- a/qtbase/src/corelib/kernel/qcoreapplication.cpp
++++ b/qtbase/src/corelib/kernel/qcoreapplication.cpp
+@@ -1157,7 +1157,7 @@ static bool doNotify(QObject *receiver, QEvent *event)
+ bool QCoreApplicationPrivate::sendThroughApplicationEventFilters(QObject *receiver, QEvent *event)
+ {
+     // We can't access the application event filters outside of the main thread (race conditions)
+-    Q_ASSERT(receiver->d_func()->threadData.loadRelaxed()->thread.loadAcquire() == mainThread());
++    Q_ASSERT(receiver->d_func()->threadData.loadAcquire()->thread.loadRelaxed() == mainThread());
+ 
+     if (extraData) {
+         // application event filters are only called for objects in the GUI thread
+diff --git a/qtbase/src/corelib/kernel/qobject.cpp b/qtbase/src/corelib/kernel/qobject.cpp
+index 1eb79138d9..36cd780ee1 100644
+--- a/qtbase/src/corelib/kernel/qobject.cpp
++++ b/qtbase/src/corelib/kernel/qobject.cpp
+@@ -1010,7 +1010,7 @@ QObject::~QObject()
+         emit destroyed(this);
+     }
+ 
+-    if (d->declarativeData) {
++    if (!d->isDeletingChildren && d->declarativeData) {
+         if (static_cast<QAbstractDeclarativeDataImpl*>(d->declarativeData)->ownedByQml1) {
+             if (QAbstractDeclarativeData::destroyed_qml1)
+                 QAbstractDeclarativeData::destroyed_qml1(d->declarativeData, this);
+@@ -1580,7 +1580,7 @@ void QObject::moveToThread(QThread *targetThread)
+ 
+     QThreadData *currentData = QThreadData::current();
+     QThreadData *targetData = targetThread ? QThreadData::get2(targetThread) : nullptr;
+-    QThreadData *thisThreadData = d->threadData.loadRelaxed();
++    QThreadData *thisThreadData = d->threadData.loadAcquire();
+     if (!thisThreadData->thread.loadAcquire() && currentData == targetData) {
+         // one exception to the rule: we allow moving objects with no thread affinity to the current thread
+         currentData = d->threadData;
+@@ -2620,7 +2620,7 @@ int QObject::receivers(const char *signal) const
+         if (!d->isSignalConnected(signal_index))
+             return receivers;
+ 
+-        if (d->declarativeData && QAbstractDeclarativeData::receivers) {
++        if (!d->isDeletingChildren && d->declarativeData && QAbstractDeclarativeData::receivers) {
+             receivers += QAbstractDeclarativeData::receivers(d->declarativeData, this,
+                                                              signal_index);
+         }
+diff --git a/qtbase/src/corelib/kernel/qobject_p.h b/qtbase/src/corelib/kernel/qobject_p.h
+index 0b827a52ca..13ffb88999 100644
+--- a/qtbase/src/corelib/kernel/qobject_p.h
++++ b/qtbase/src/corelib/kernel/qobject_p.h
+@@ -444,7 +444,7 @@ inline void QObjectPrivate::checkForIncompatibleLibraryVersion(int version) cons
+ 
+ inline bool QObjectPrivate::isDeclarativeSignalConnected(uint signal_index) const
+ {
+-    return declarativeData && QAbstractDeclarativeData::isSignalConnected
++    return !isDeletingChildren && declarativeData && QAbstractDeclarativeData::isSignalConnected
+             && QAbstractDeclarativeData::isSignalConnected(declarativeData, q_func(), signal_index);
+ }
+ 
+diff --git a/qtbase/src/corelib/kernel/qtranslator.cpp b/qtbase/src/corelib/kernel/qtranslator.cpp
+index 2812ffb7ea..bc0177c5ec 100644
+--- a/qtbase/src/corelib/kernel/qtranslator.cpp
++++ b/qtbase/src/corelib/kernel/qtranslator.cpp
+@@ -902,7 +902,7 @@ static QString getMessage(const uchar *m, const uchar *end, const char *context,
+             goto end;
+         case Tag_Translation: {
+             int len = read32(m);
+-            if (len % 1)
++            if (len & 1)
+                 return QString();
+             m += 4;
+             if (!numerus--) {
+diff --git a/qtbase/src/corelib/mimetypes/qmimedatabase.cpp b/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
+index 9de22cef33..ff868a3268 100644
+--- a/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
+@@ -389,20 +389,23 @@ QMimeType QMimeDatabasePrivate::mimeTypeForFileNameAndData(const QString &fileNa
+         // Disambiguate conflicting extensions (if magic matching found something)
+         if (candidateByData.isValid() && magicAccuracy > 0) {
+             const QString sniffedMime = candidateByData.name();
+-            // If the sniffedMime matches a glob match, use it
++            // If the sniffedMime matches a highest-weight glob match, use it
+             if (candidatesByName.m_matchingMimeTypes.contains(sniffedMime)) {
+                 *accuracyPtr = 100;
+                 return candidateByData;
+             }
+-            for (const QString &m : qAsConst(candidatesByName.m_matchingMimeTypes)) {
++            for (const QString &m : qAsConst(candidatesByName.m_allMatchingMimeTypes)) {
+                 if (inherits(m, sniffedMime)) {
+                     // We have magic + pattern pointing to this, so it's a pretty good match
+                     *accuracyPtr = 100;
+                     return mimeTypeForName(m);
+                 }
+             }
+-            *accuracyPtr = magicAccuracy;
+-            return candidateByData;
++            if (candidatesByName.m_allMatchingMimeTypes.isEmpty()) {
++                // No glob, use magic
++                *accuracyPtr = magicAccuracy;
++                return candidateByData;
++            }
+         }
+     }
+ 
+diff --git a/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp b/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
+index a81112d227..fa8f4c545d 100644
+--- a/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
+@@ -83,7 +83,10 @@ void QMimeGlobMatchResult::addMatch(const QString &mimeType, int weight, const Q
+     }
+     if (!m_matchingMimeTypes.contains(mimeType)) {
+         m_matchingMimeTypes.append(mimeType);
+-        m_allMatchingMimeTypes.append(mimeType);
++        if (replace)
++            m_allMatchingMimeTypes.prepend(mimeType); // highest-weight first
++        else
++            m_allMatchingMimeTypes.append(mimeType);
+         m_knownSuffixLength = knownSuffixLength;
+     }
+ }
+@@ -94,7 +97,7 @@ QMimeGlobPattern::PatternType QMimeGlobPattern::detectPatternType(const QString
+     if (!patternLength)
+         return OtherPattern;
+ 
+-    const bool starCount = pattern.count(QLatin1Char('*')) == 1;
++    const int starCount = pattern.count(QLatin1Char('*'));
+     const bool hasSquareBracket = pattern.indexOf(QLatin1Char('[')) != -1;
+     const bool hasQuestionMark = pattern.indexOf(QLatin1Char('?')) != -1;
+ 
+@@ -106,10 +109,10 @@ QMimeGlobPattern::PatternType QMimeGlobPattern::detectPatternType(const QString
+             // Patterns like "README*" (well this is currently the only one like that...)
+             if (pattern.at(patternLength - 1) == QLatin1Char('*'))
+                 return PrefixPattern;
+-        }
+-        // Names without any wildcards like "README"
+-        if (starCount == 0)
++        } else if (starCount == 0) {
++            // Names without any wildcards like "README"
+             return LiteralPattern;
++        }
+     }
+ 
+     if (pattern == QLatin1String("[0-9][0-9][0-9].vdr"))
+diff --git a/qtbase/src/corelib/mimetypes/qmimeprovider.cpp b/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
+index 258dddf8cb..4642d0f2d0 100644
+--- a/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
+@@ -244,15 +244,18 @@ void QMimeBinaryProvider::addFileNameMatches(const QString &fileName, QMimeGlobM
+     const QString lowerFileName = fileName.toLower();
+     // Check literals (e.g. "Makefile")
+     matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosLiteralListOffset), fileName);
+-    // Check complex globs (e.g. "callgrind.out[0-9]*")
+-    matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosGlobListOffset), fileName);
+     // Check the very common *.txt cases with the suffix tree
+-    const int reverseSuffixTreeOffset = m_cacheFile->getUint32(PosReverseSuffixTreeOffset);
+-    const int numRoots = m_cacheFile->getUint32(reverseSuffixTreeOffset);
+-    const int firstRootOffset = m_cacheFile->getUint32(reverseSuffixTreeOffset + 4);
+-    matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, lowerFileName, lowerFileName.length() - 1, false);
++    if (result.m_matchingMimeTypes.isEmpty()) {
++        const int reverseSuffixTreeOffset = m_cacheFile->getUint32(PosReverseSuffixTreeOffset);
++        const int numRoots = m_cacheFile->getUint32(reverseSuffixTreeOffset);
++        const int firstRootOffset = m_cacheFile->getUint32(reverseSuffixTreeOffset + 4);
++        matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, lowerFileName, lowerFileName.length() - 1, false);
++        if (result.m_matchingMimeTypes.isEmpty())
++            matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, fileName, fileName.length() - 1, true);
++    }
++    // Check complex globs (e.g. "callgrind.out[0-9]*" or "README*")
+     if (result.m_matchingMimeTypes.isEmpty())
+-        matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, fileName, fileName.length() - 1, true);
++        matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosGlobListOffset), fileName);
+ }
+ 
+ void QMimeBinaryProvider::matchGlobList(QMimeGlobMatchResult &result, CacheFile *cacheFile, int off, const QString &fileName)
+diff --git a/qtbase/src/corelib/serialization/qjsonparser.cpp b/qtbase/src/corelib/serialization/qjsonparser.cpp
+index 17e6f111ab..2e40b6c8fb 100644
+--- a/qtbase/src/corelib/serialization/qjsonparser.cpp
++++ b/qtbase/src/corelib/serialization/qjsonparser.cpp
+@@ -379,10 +379,30 @@ error:
+     return QCborValue();
+ }
+ 
++// We need to retain the _last_ value for any duplicate keys and we need to deref containers.
++// Therefore the manual implementation of std::unique().
++template<typename Iterator, typename Compare, typename Assign>
++static Iterator customAssigningUniqueLast(Iterator first, Iterator last,
++                                          Compare compare, Assign assign)
++{
++    first = std::adjacent_find(first, last, compare);
++    if (first == last)
++        return last;
++
++    Iterator result = first;
++    while (++first != last) {
++        if (!compare(*result, *first))
++            ++result;
++        if (result != first)
++            assign(*result, *first);
++    }
++
++    return ++result;
++}
++
+ static void sortContainer(QCborContainerPrivate *container)
+ {
+     using Forward = QJsonPrivate::KeyIterator;
+-    using Reverse = std::reverse_iterator<Forward>;
+     using Value = Forward::value_type;
+ 
+     auto compare = [container](const Value &a, const Value &b)
+@@ -420,17 +440,31 @@ static void sortContainer(QCborContainerPrivate *container)
+         }
+     };
+ 
+-    std::sort(Forward(container->elements.begin()), Forward(container->elements.end()),
+-              [&compare](const Value &a, const Value &b) { return compare(a, b) < 0; });
++    // The elements' containers are owned by the outer container, not by the elements themselves.
++    auto move = [](Forward::reference target, Forward::reference source)
++    {
++        QtCbor::Element &targetValue = target.value();
++
++        // If the target has a container, deref it before overwriting, so that we don't leak.
++        if (targetValue.flags & QtCbor::Element::IsContainer)
++            targetValue.container->deref();
++
++        // Do not move, so that we can clear the value afterwards.
++        target = source;
++
++        // Clear the source value, so that we don't store the same container twice.
++        source.value() = QtCbor::Element();
++    };
++
++    std::stable_sort(
++                Forward(container->elements.begin()), Forward(container->elements.end()),
++                [&compare](const Value &a, const Value &b) { return compare(a, b) < 0; });
+ 
+-    // We need to retain the _last_ value for any duplicate keys. Therefore the reverse dance here.
+-    auto it = std::unique(Reverse(container->elements.end()), Reverse(container->elements.begin()),
+-                          [&compare](const Value &a, const Value &b) {
+-        return compare(a, b) == 0;
+-    }).base().elementsIterator();
++    Forward result = customAssigningUniqueLast(
++                Forward(container->elements.begin()),  Forward(container->elements.end()),
++                [&compare](const Value &a, const Value &b) { return compare(a, b) == 0; }, move);
+ 
+-    // The erase from beginning is expensive but hopefully rare.
+-    container->elements.erase(container->elements.begin(), it);
++    container->elements.erase(result.elementsIterator(), container->elements.end());
+ }
+ 
+ 
+diff --git a/qtbase/src/corelib/serialization/qxmlstream.cpp b/qtbase/src/corelib/serialization/qxmlstream.cpp
+index b2f846544d..7cd457ba3a 100644
+--- a/qtbase/src/corelib/serialization/qxmlstream.cpp
++++ b/qtbase/src/corelib/serialization/qxmlstream.cpp
+@@ -980,7 +980,7 @@ inline uint QXmlStreamReaderPrivate::peekChar()
+ bool QXmlStreamReaderPrivate::scanUntil(const char *str, short tokenToInject)
+ {
+     int pos = textBuffer.size();
+-    int oldLineNumber = lineNumber;
++    const auto oldLineNumber = lineNumber;
+ 
+     uint c;
+     while ((c = getChar()) != StreamEOF) {
+diff --git a/qtbase/src/corelib/text/qstring.cpp b/qtbase/src/corelib/text/qstring.cpp
+index 3e88ab4859..8deeae47bb 100644
+--- a/qtbase/src/corelib/text/qstring.cpp
++++ b/qtbase/src/corelib/text/qstring.cpp
+@@ -12312,7 +12312,7 @@ static qsizetype qLastIndexOf(Haystack haystack0, qsizetype from,
+     const auto needle = needle0.data();
+     const auto *end = haystack;
+     haystack += from;
+-    const std::size_t sl_minus_1 = sl - 1;
++    const std::size_t sl_minus_1 = sl ? sl - 1 : 0;
+     const auto *n = needle + sl_minus_1;
+     const auto *h = haystack + sl_minus_1;
+     std::size_t hashNeedle = 0, hashHaystack = 0;
+diff --git a/qtbase/src/corelib/text/qstringiterator_p.h b/qtbase/src/corelib/text/qstringiterator_p.h
+index 219589b6e4..1d0c66cc78 100644
+--- a/qtbase/src/corelib/text/qstringiterator_p.h
++++ b/qtbase/src/corelib/text/qstringiterator_p.h
+@@ -61,6 +61,8 @@ class QStringIterator
+ {
+     QString::const_iterator i, pos, e;
+     Q_STATIC_ASSERT((std::is_same<QString::const_iterator, const QChar *>::value));
++    static bool less(const QChar *lhs, const QChar *rhs) noexcept
++    { return std::less<QString::const_iterator>{}(lhs, rhs); }
+ public:
+     explicit QStringIterator(QStringView string, qsizetype idx = 0)
+         : i(string.begin()),
+@@ -95,7 +97,8 @@ public:
+ 
+     inline void setPosition(QString::const_iterator position)
+     {
+-        Q_ASSERT_X(i <= position && position <= e, Q_FUNC_INFO, "position out of bounds");
++        Q_ASSERT_X(!less(position, i) && !less(e, position),
++                   Q_FUNC_INFO, "position out of bounds");
+         pos = position;
+     }
+ 
+@@ -103,7 +106,7 @@ public:
+ 
+     inline bool hasNext() const
+     {
+-        return pos < e;
++        return less(pos, e);
+     }
+ 
+     inline void advance()
+@@ -120,16 +123,20 @@ public:
+     {
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+-        if (Q_UNLIKELY((pos++)->isHighSurrogate()))
++        if (Q_UNLIKELY((pos++)->isHighSurrogate())) {
++            Q_ASSERT(hasNext() && pos->isLowSurrogate());
+             ++pos;
++        }
+     }
+ 
+     inline uint peekNextUnchecked() const
+     {
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+-        if (Q_UNLIKELY(pos->isHighSurrogate()))
++        if (Q_UNLIKELY(pos->isHighSurrogate())) {
++            Q_ASSERT(less(pos + 1, e) && pos[1].isLowSurrogate());
+             return QChar::surrogateToUcs4(pos[0], pos[1]);
++        }
+ 
+         return pos->unicode();
+     }
+@@ -155,8 +162,10 @@ public:
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+         const QChar cur = *pos++;
+-        if (Q_UNLIKELY(cur.isHighSurrogate()))
++        if (Q_UNLIKELY(cur.isHighSurrogate())) {
++            Q_ASSERT(hasNext() && pos->isLowSurrogate());
+             return QChar::surrogateToUcs4(cur, *pos++);
++        }
+         return cur.unicode();
+     }
+ 
+@@ -166,7 +175,7 @@ public:
+ 
+         const QChar uc = *pos++;
+         if (Q_UNLIKELY(uc.isSurrogate())) {
+-            if (Q_LIKELY(uc.isHighSurrogate() && pos < e && pos->isLowSurrogate()))
++            if (Q_LIKELY(uc.isHighSurrogate() && hasNext() && pos->isLowSurrogate()))
+                 return QChar::surrogateToUcs4(uc, *pos++);
+             return invalidAs;
+         }
+@@ -178,7 +187,7 @@ public:
+ 
+     inline bool hasPrevious() const
+     {
+-        return pos > i;
++        return less(i, pos);
+     }
+ 
+     inline void recede()
+@@ -196,16 +205,20 @@ public:
+     {
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+-        if (Q_UNLIKELY((--pos)->isLowSurrogate()))
++        if (Q_UNLIKELY((--pos)->isLowSurrogate())) {
++            Q_ASSERT(hasPrevious() && pos[-1].isHighSurrogate());
+             --pos;
++        }
+     }
+ 
+     inline uint peekPreviousUnchecked() const
+     {
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+-        if (Q_UNLIKELY(pos[-1].isLowSurrogate()))
++        if (Q_UNLIKELY(pos[-1].isLowSurrogate())) {
++            Q_ASSERT(less(i + 1, pos) && pos[-2].isHighSurrogate());
+             return QChar::surrogateToUcs4(pos[-2], pos[-1]);
++        }
+         return pos[-1].unicode();
+     }
+ 
+@@ -230,8 +243,10 @@ public:
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+         const QChar cur = *--pos;
+-        if (Q_UNLIKELY(cur.isLowSurrogate()))
++        if (Q_UNLIKELY(cur.isLowSurrogate())) {
++            Q_ASSERT(hasPrevious() && pos[-1].isHighSurrogate());
+             return QChar::surrogateToUcs4(*--pos, cur);
++        }
+         return cur.unicode();
+     }
+ 
+@@ -241,7 +256,7 @@ public:
+ 
+         const QChar uc = *--pos;
+         if (Q_UNLIKELY(uc.isSurrogate())) {
+-            if (Q_LIKELY(uc.isLowSurrogate() && pos > i && pos[-1].isHighSurrogate()))
++            if (Q_LIKELY(uc.isLowSurrogate() && hasPrevious() && pos[-1].isHighSurrogate()))
+                 return QChar::surrogateToUcs4(*--pos, uc);
+             return invalidAs;
+         }
+diff --git a/qtbase/src/corelib/thread/qfutex_p.h b/qtbase/src/corelib/thread/qfutex_p.h
+index f287b752d7..e294537787 100644
+--- a/qtbase/src/corelib/thread/qfutex_p.h
++++ b/qtbase/src/corelib/thread/qfutex_p.h
+@@ -52,6 +52,7 @@
+ //
+ 
+ #include <qglobal.h>
++#include <QtCore/qtsan_impl.h>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -106,16 +107,13 @@ namespace QtLinuxFutex {
+     inline int _q_futex(int *addr, int op, int val, quintptr val2 = 0,
+                         int *addr2 = nullptr, int val3 = 0) noexcept
+     {
+-        // A futex call ensures total ordering on the futex words
+-        // (in either success or failure of the call). Instruct TSAN accordingly,
+-        // as TSAN does not understand the futex(2) syscall.
+-        _q_tsan_release(addr, addr2);
++        QtTsan::futexRelease(addr, addr2);
+ 
+         // we use __NR_futex because some libcs (like Android's bionic) don't
+         // provide SYS_futex etc.
+         int result = syscall(__NR_futex, addr, op | FUTEX_PRIVATE_FLAG, val, val2, addr2, val3);
+ 
+-        _q_tsan_acquire(addr, addr2);
++        QtTsan::futexAcquire(addr, addr2);
+ 
+         return result;
+     }
+diff --git a/qtbase/src/corelib/thread/qmutex.cpp b/qtbase/src/corelib/thread/qmutex.cpp
+index 310d1cb14f..7097122d8e 100644
+--- a/qtbase/src/corelib/thread/qmutex.cpp
++++ b/qtbase/src/corelib/thread/qmutex.cpp
+@@ -152,6 +152,7 @@ public:
+ 
+ /*!
+     \enum QMutex::RecursionMode
++    \obsolete Use QRecursiveMutex to create a recursive mutex.
+ 
+     \value Recursive  In this mode, a thread can lock the same mutex
+                       multiple times and the mutex won't be unlocked
+@@ -173,6 +174,7 @@ public:
+ 
+ /*!
+     Constructs a new mutex. The mutex is created in an unlocked state.
++    \obsolete Use QRecursiveMutex to create a recursive mutex.
+ 
+     If \a mode is QMutex::Recursive, a thread can lock the same mutex
+     multiple times and the mutex won't be unlocked until a
+@@ -197,7 +199,7 @@ QMutex::QMutex(RecursionMode mode)
+ QMutex::~QMutex()
+ {
+     QMutexData *d = d_ptr.loadRelaxed();
+-    if (isRecursive()) {
++    if (QBasicMutex::isRecursive()) {
+         delete static_cast<QRecursiveMutexPrivate *>(d);
+     } else if (d) {
+ #ifndef QT_LINUX_FUTEX
+diff --git a/qtbase/src/corelib/thread/qmutex.h b/qtbase/src/corelib/thread/qmutex.h
+index 73c9e00663..1bae573a03 100644
+--- a/qtbase/src/corelib/thread/qmutex.h
++++ b/qtbase/src/corelib/thread/qmutex.h
+@@ -42,6 +42,7 @@
+ 
+ #include <QtCore/qglobal.h>
+ #include <QtCore/qatomic.h>
++#include <QtCore/qtsan_impl.h>
+ #include <new>
+ 
+ #if __has_include(<chrono>)
+@@ -77,19 +78,37 @@ public:
+ 
+     // BasicLockable concept
+     inline void lock() QT_MUTEX_LOCK_NOEXCEPT {
++        QtTsan::mutexPreLock(this, 0u);
++
+         if (!fastTryLock())
+             lockInternal();
++
++        QtTsan::mutexPostLock(this, 0u, 0);
+     }
+ 
+     // BasicLockable concept
+     inline void unlock() noexcept {
+         Q_ASSERT(d_ptr.loadRelaxed()); //mutex must be locked
++
++        QtTsan::mutexPreUnlock(this, 0u);
++
+         if (!fastTryUnlock())
+             unlockInternal();
++
++        QtTsan::mutexPostUnlock(this, 0u);
+     }
+ 
+     bool tryLock() noexcept {
+-        return fastTryLock();
++        unsigned tsanFlags = QtTsan::TryLock;
++        QtTsan::mutexPreLock(this, tsanFlags);
++
++        const bool success = fastTryLock();
++
++        if (!success)
++            tsanFlags |= QtTsan::TryLockFailed;
++        QtTsan::mutexPostLock(this, tsanFlags, 0);
++
++        return success;
+     }
+ 
+     // Lockable concept
+@@ -134,8 +153,16 @@ public:
+ #else
+     QMutex() { d_ptr.storeRelaxed(nullptr); }
+ #endif
++#if QT_DEPRECATED_SINCE(5,15)
+     enum RecursionMode { NonRecursive, Recursive };
++    QT_DEPRECATED_VERSION_X(5, 15, "Use QRecursiveMutex instead of a recursive QMutex")
+     explicit QMutex(RecursionMode mode);
++
++    QT_DEPRECATED_VERSION_X(5, 15, "Use QRecursiveMutex instead of a recursive QMutex")
++    bool isRecursive() const noexcept
++    { return QBasicMutex::isRecursive(); }
++#endif
++
+     ~QMutex();
+ 
+     // BasicLockable concept
+@@ -166,9 +193,6 @@ public:
+     }
+ #endif
+ 
+-    bool isRecursive() const noexcept
+-    { return QBasicMutex::isRecursive(); }
+-
+ private:
+     Q_DISABLE_COPY(QMutex)
+     friend class QMutexLocker;
+diff --git a/qtbase/src/corelib/thread/qreadwritelock.cpp b/qtbase/src/corelib/thread/qreadwritelock.cpp
+index 8c28507d5a..9dd8503116 100644
+--- a/qtbase/src/corelib/thread/qreadwritelock.cpp
++++ b/qtbase/src/corelib/thread/qreadwritelock.cpp
+@@ -155,7 +155,7 @@ QReadWriteLock::QReadWriteLock(RecursionMode recursionMode)
+ */
+ QReadWriteLock::~QReadWriteLock()
+ {
+-    auto d = d_ptr.loadRelaxed();
++    auto d = d_ptr.loadAcquire();
+     if (isUncontendedLocked(d)) {
+         qWarning("QReadWriteLock: destroying locked QReadWriteLock");
+         return;
+@@ -445,7 +445,7 @@ void QReadWriteLock::unlock()
+ /*! \internal  Helper for QWaitCondition::wait */
+ QReadWriteLock::StateForWaitCondition QReadWriteLock::stateForWaitCondition() const
+ {
+-    QReadWriteLockPrivate *d = d_ptr.loadRelaxed();
++    QReadWriteLockPrivate *d = d_ptr.loadAcquire();
+     switch (quintptr(d) & StateMask) {
+     case StateLockedForRead: return LockedForRead;
+     case StateLockedForWrite: return LockedForWrite;
+@@ -453,6 +453,7 @@ QReadWriteLock::StateForWaitCondition QReadWriteLock::stateForWaitCondition() co
+ 
+     if (!d)
+         return Unlocked;
++    const auto lock = qt_scoped_lock(d->mutex);
+     if (d->writerCount > 1)
+         return RecursivelyLocked;
+     else if (d->writerCount == 1)
+diff --git a/qtbase/src/corelib/thread/qsemaphore.cpp b/qtbase/src/corelib/thread/qsemaphore.cpp
+index 1d01fc1b28..3ecdee3747 100644
+--- a/qtbase/src/corelib/thread/qsemaphore.cpp
++++ b/qtbase/src/corelib/thread/qsemaphore.cpp
+@@ -354,7 +354,12 @@ void QSemaphore::release(int n)
+         quintptr nn = unsigned(n);
+         if (futexHasWaiterCount)
+             nn |= quint64(nn) << 32;    // token count replicated in high word
+-        quintptr prevValue = u.fetchAndAddRelease(nn);
++        quintptr prevValue = u.loadRelaxed();
++        quintptr newValue;
++        do { // loop just to ensure the operations are done atomically
++            newValue = prevValue + nn;
++            newValue &= (futexNeedsWakeAllBit - 1);
++        } while (!u.testAndSetRelease(prevValue, newValue, prevValue));
+         if (futexNeedsWake(prevValue)) {
+ #ifdef FUTEX_OP
+             if (futexHasWaiterCount) {
+@@ -376,7 +381,6 @@ void QSemaphore::release(int n)
+                 quint32 oparg = 0;
+                 quint32 cmp = FUTEX_OP_CMP_NE;
+                 quint32 cmparg = 0;
+-                u.fetchAndAndRelease(futexNeedsWakeAllBit - 1);
+                 futexWakeOp(*futexLow32(&u), n, INT_MAX, *futexHigh32(&u), FUTEX_OP(op, oparg, cmp, cmparg));
+                 return;
+             }
+@@ -388,7 +392,6 @@ 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(futexNeedsWakeAllBit - 1);
+             if (futexHasWaiterCount) {
+                 futexWakeAll(*futexLow32(&u));
+                 futexWakeAll(*futexHigh32(&u));
+diff --git a/qtbase/src/corelib/thread/qthread_p.h b/qtbase/src/corelib/thread/qthread_p.h
+index b2d1628e6e..f32f6f0460 100644
+--- a/qtbase/src/corelib/thread/qthread_p.h
++++ b/qtbase/src/corelib/thread/qthread_p.h
+@@ -174,7 +174,7 @@ public:
+     int returnCode;
+ 
+     uint stackSize;
+-    QThread::Priority priority;
++    std::underlying_type<QThread::Priority>::type priority;
+ 
+     static QThread *threadForId(int id);
+ 
+@@ -213,6 +213,13 @@ public:
+             QCoreApplication::instance()->postEvent(q_ptr, new QEvent(QEvent::Quit));
+         }
+     }
++
++#ifndef Q_OS_INTEGRITY
++private:
++    // Used in QThread(Private)::start to avoid racy access to QObject::objectName,
++    // unset afterwards. On INTEGRITY we set the thread name before starting it.
++    QString objectName;
++#endif
+ };
+ 
+ #else // QT_CONFIG(thread)
+diff --git a/qtbase/src/corelib/thread/qthread_unix.cpp b/qtbase/src/corelib/thread/qthread_unix.cpp
+index 56a8e0a038..610117a640 100644
+--- a/qtbase/src/corelib/thread/qthread_unix.cpp
++++ b/qtbase/src/corelib/thread/qthread_unix.cpp
+@@ -169,8 +169,7 @@ static void set_thread_data(QThreadData *data)
+ 
+ static void clear_thread_data()
+ {
+-    currentThreadData = nullptr;
+-    pthread_setspecific(current_thread_data_key, nullptr);
++    set_thread_data(nullptr);
+ }
+ 
+ template <typename T>
+@@ -296,7 +295,7 @@ void *QThreadPrivate::start(void *arg)
+             QMutexLocker locker(&thr->d_func()->mutex);
+ 
+             // do we need to reset the thread priority?
+-            if (int(thr->d_func()->priority) & ThreadPriorityResetFlag) {
++            if (thr->d_func()->priority & ThreadPriorityResetFlag) {
+                 thr->d_func()->setPriority(QThread::Priority(thr->d_func()->priority & ~ThreadPriorityResetFlag));
+             }
+ 
+@@ -316,10 +315,10 @@ void *QThreadPrivate::start(void *arg)
+             // Sets the name of the current thread. We can only do this
+             // when the thread is starting, as we don't have a cross
+             // platform way of setting the name of an arbitrary thread.
+-            if (Q_LIKELY(thr->objectName().isEmpty()))
++            if (Q_LIKELY(thr->d_func()->objectName.isEmpty()))
+                 setCurrentThreadName(thr->metaObject()->className());
+             else
+-                setCurrentThreadName(thr->objectName().toLocal8Bit());
++                setCurrentThreadName(std::exchange(thr->d_func()->objectName, {}).toLocal8Bit());
+         }
+ #endif
+ 
+@@ -671,7 +670,7 @@ void QThread::start(Priority priority)
+                 // could not set scheduling hints, fallback to inheriting them
+                 // we'll try again from inside the thread
+                 pthread_attr_setinheritsched(&attr, PTHREAD_INHERIT_SCHED);
+-                d->priority = Priority(priority | ThreadPriorityResetFlag);
++                d->priority = static_cast<std::underlying_type<QThread::Priority>::type>(priority) | ThreadPriorityResetFlag;
+             }
+             break;
+         }
+@@ -702,7 +701,10 @@ void QThread::start(Priority priority)
+         pthread_attr_setthreadname(&attr, metaObject()->className());
+     else
+         pthread_attr_setthreadname(&attr, objectName().toLocal8Bit());
++#else
++    d->objectName = objectName();
+ #endif
++
+     pthread_t threadId;
+     int code = pthread_create(&threadId, &attr, QThreadPrivate::start, this);
+     if (code == EPERM) {
+diff --git a/qtbase/src/corelib/thread/qthread_win.cpp b/qtbase/src/corelib/thread/qthread_win.cpp
+index bc70e3178a..4e76972498 100644
+--- a/qtbase/src/corelib/thread/qthread_win.cpp
++++ b/qtbase/src/corelib/thread/qthread_win.cpp
+@@ -394,10 +394,9 @@ unsigned int __stdcall QT_ENSURE_STACK_ALIGNED_FOR_SSE QThreadPrivate::start(voi
+ 
+ #if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) && !defined(Q_OS_WINRT)
+     // sets the name of the current thread.
+-    QByteArray objectName = thr->objectName().toLocal8Bit();
+-    qt_set_thread_name(HANDLE(-1),
+-                       objectName.isEmpty() ?
+-                       thr->metaObject()->className() : objectName.constData());
++    qt_set_thread_name(HANDLE(-1), thr->d_func()->objectName.isEmpty()
++                        ? thr->metaObject()->className()
++                        : std::exchange(thr->d_func()->objectName, {}).toLocal8Bit().constData());
+ #endif
+ 
+     emit thr->started(QThread::QPrivateSignal());
+@@ -503,6 +502,7 @@ void QThread::start(Priority priority)
+     if (d->running)
+         return;
+ 
++    d->objectName = objectName();
+     d->running = true;
+     d->finished = false;
+     d->exited = false;
+@@ -548,7 +548,7 @@ void QThread::start(Priority priority)
+ 
+     int prio;
+     d->priority = priority;
+-    switch (d->priority) {
++    switch (priority) {
+     case IdlePriority:
+         prio = THREAD_PRIORITY_IDLE;
+         break;
+@@ -686,7 +686,7 @@ void QThreadPrivate::setPriority(QThread::Priority threadPriority)
+ 
+     int prio;
+     priority = threadPriority;
+-    switch (priority) {
++    switch (threadPriority) {
+     case QThread::IdlePriority:
+         prio = THREAD_PRIORITY_IDLE;
+         break;
+diff --git a/qtbase/src/corelib/thread/qtsan_impl.h b/qtbase/src/corelib/thread/qtsan_impl.h
+new file mode 100644
+index 0000000000..580a738b91
+--- /dev/null
++++ b/qtbase/src/corelib/thread/qtsan_impl.h
+@@ -0,0 +1,115 @@
++/****************************************************************************
++**
++** Copyright (C) 2017 Intel Corporation.
++** Copyright (C) 2022 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
++** 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 QTSAN_IMPL_H
++#define QTSAN_IMPL_H
++
++#include <QtCore/qglobal.h>
++
++#if (__has_feature(thread_sanitizer) || defined(__SANITIZE_THREAD__)) && __has_include(<sanitizer/tsan_interface.h>)
++#  define QT_BUILDING_UNDER_TSAN
++#  include <sanitizer/tsan_interface.h>
++#endif
++
++QT_BEGIN_NAMESPACE
++
++namespace QtTsan {
++#ifdef QT_BUILDING_UNDER_TSAN
++inline void futexAcquire(void *addr, void *addr2 = nullptr)
++{
++    // A futex call ensures total ordering on the futex words
++    // (in either success or failure of the call). Instruct TSAN accordingly,
++    // as TSAN does not understand the futex(2) syscall (or equivalent).
++    ::__tsan_acquire(addr);
++    if (addr2)
++        ::__tsan_acquire(addr2);
++}
++
++inline void futexRelease(void *addr, void *addr2 = nullptr)
++{
++    if (addr2)
++        ::__tsan_release(addr2);
++    ::__tsan_release(addr);
++}
++
++inline void mutexPreLock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_pre_lock(addr, flags);
++}
++
++inline void mutexPostLock(void *addr, unsigned flags, int recursion)
++{
++    ::__tsan_mutex_post_lock(addr, flags, recursion);
++}
++
++inline void mutexPreUnlock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_pre_unlock(addr, flags);
++}
++
++inline void mutexPostUnlock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_post_unlock(addr, flags);
++}
++
++enum : unsigned {
++    MutexWriteReentrant = ::__tsan_mutex_write_reentrant,
++    TryLock = ::__tsan_mutex_try_lock,
++    TryLockFailed = ::__tsan_mutex_try_lock_failed,
++};
++#else
++inline void futexAcquire(void *, void * = nullptr) {}
++inline void futexRelease(void *, void * = nullptr) {}
++
++enum : unsigned {
++    MutexWriteReentrant,
++    TryLock,
++    TryLockFailed,
++};
++inline void mutexPreLock(void *, unsigned) {}
++inline void mutexPostLock(void *, unsigned, int) {}
++inline void mutexPreUnlock(void *, unsigned) {}
++inline void mutexPostUnlock(void *, unsigned) {}
++#endif // QT_BUILDING_UNDER_TSAN
++} // namespace QtTsan
++
++QT_END_NAMESPACE
++
++#endif // QTSAN_IMPL_H
+diff --git a/qtbase/src/corelib/thread/qwaitcondition_unix.cpp b/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
+index 88b058f410..0f1da4dc9b 100644
+--- a/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
++++ b/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
+@@ -213,7 +213,7 @@ bool QWaitCondition::wait(QMutex *mutex, QDeadlineTimer deadline)
+ {
+     if (! mutex)
+         return false;
+-    if (mutex->isRecursive()) {
++    if (static_cast<QBasicMutex *>(mutex)->isRecursive()) {
+         qWarning("QWaitCondition: cannot wait on recursive mutexes");
+         return false;
+     }
+diff --git a/qtbase/src/corelib/time/qdatetime.cpp b/qtbase/src/corelib/time/qdatetime.cpp
+index ec12569e3f..2c0b098079 100644
+--- a/qtbase/src/corelib/time/qdatetime.cpp
++++ b/qtbase/src/corelib/time/qdatetime.cpp
+@@ -43,6 +43,7 @@
+ #if QT_CONFIG(datetimeparser)
+ #include "private/qdatetimeparser_p.h"
+ #endif
++#include <private/qnumeric_p.h>
+ 
+ #include "qdatastream.h"
+ #include "qset.h"
+@@ -1429,9 +1430,11 @@ QDate QDate::addDays(qint64 ndays) const
+     if (isNull())
+         return QDate();
+ 
+-    // Due to limits on minJd() and maxJd() we know that any overflow
+-    // will be invalid and caught by fromJulianDay().
+-    return fromJulianDay(jd + ndays);
++    qint64 r;
++    if (Q_UNLIKELY(add_overflow(jd, ndays, &r)))
++        return QDate();
++    else
++        return fromJulianDay(r);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/corelib/time/qtimezone.cpp b/qtbase/src/corelib/time/qtimezone.cpp
+index 0309e43e52..3d451696a1 100644
+--- a/qtbase/src/corelib/time/qtimezone.cpp
++++ b/qtbase/src/corelib/time/qtimezone.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2013 John Layt <jlayt@kde.org>
++** Copyright (C) 2020 John Layt <jlayt@kde.org>
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtCore module of the Qt Toolkit.
+@@ -975,9 +975,15 @@ QList<QByteArray> QTimeZone::windowsIdToIanaIds(const QByteArray &windowsId,
+ }
+ 
+ #ifndef QT_NO_DATASTREAM
++// Invalid, as an IANA ID: too long, starts with - and has other invalid characters in it
++static inline QString invalidId() { return QStringLiteral("-No Time Zone Specified!"); }
++
+ QDataStream &operator<<(QDataStream &ds, const QTimeZone &tz)
+ {
+-    tz.d->serialize(ds);
++    if (tz.isValid())
++        tz.d->serialize(ds);
++    else
++        ds << invalidId();
+     return ds;
+ }
+ 
+@@ -985,7 +991,9 @@ QDataStream &operator>>(QDataStream &ds, QTimeZone &tz)
+ {
+     QString ianaId;
+     ds >> ianaId;
+-    if (ianaId == QLatin1String("OffsetFromUtc")) {
++    if (ianaId == invalidId()) {
++        tz = QTimeZone();
++    } else if (ianaId == QLatin1String("OffsetFromUtc")) {
+         int utcOffset;
+         QString name;
+         QString abbreviation;
+diff --git a/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp b/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
+index b1611d7ddb..a7a6a72ccf 100644
+--- a/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
++++ b/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
+@@ -42,6 +42,7 @@
+ #include "qtimezone.h"
+ #include "qtimezoneprivate_p.h"
+ #include "private/qlocale_tools_p.h"
++#include "private/qlocking_p.h"
+ 
+ #include <QtCore/QDataStream>
+ #include <QtCore/QDateTime>
+@@ -62,6 +63,10 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++#if QT_CONFIG(icu)
++static QBasicMutex s_icu_mutex;
++#endif
++
+ /*
+     Private
+ 
+@@ -670,6 +675,9 @@ QTzTimeZonePrivate::~QTzTimeZonePrivate()
+ 
+ QTzTimeZonePrivate *QTzTimeZonePrivate::clone() const
+ {
++#if QT_CONFIG(icu)
++    const auto lock = qt_scoped_lock(s_icu_mutex);
++#endif
+     return new QTzTimeZonePrivate(*this);
+ }
+ 
+@@ -913,12 +921,14 @@ QString QTzTimeZonePrivate::displayName(qint64 atMSecsSinceEpoch,
+                                         const QLocale &locale) const
+ {
+ #if QT_CONFIG(icu)
++    auto lock = qt_unique_lock(s_icu_mutex);
+     if (!m_icu)
+         m_icu = new QIcuTimeZonePrivate(m_id);
+     // TODO small risk may not match if tran times differ due to outdated files
+     // TODO Some valid TZ names are not valid ICU names, use translation table?
+     if (m_icu->isValid())
+         return m_icu->displayName(atMSecsSinceEpoch, nameType, locale);
++    lock.unlock();
+ #else
+     Q_UNUSED(nameType)
+     Q_UNUSED(locale)
+@@ -932,12 +942,14 @@ QString QTzTimeZonePrivate::displayName(QTimeZone::TimeType timeType,
+                                         const QLocale &locale) const
+ {
+ #if QT_CONFIG(icu)
++    auto lock = qt_unique_lock(s_icu_mutex);
+     if (!m_icu)
+         m_icu = new QIcuTimeZonePrivate(m_id);
+     // TODO small risk may not match if tran times differ due to outdated files
+     // TODO Some valid TZ names are not valid ICU names, use translation table?
+     if (m_icu->isValid())
+         return m_icu->displayName(timeType, nameType, locale);
++    lock.unlock();
+ #else
+     Q_UNUSED(timeType)
+     Q_UNUSED(nameType)
+diff --git a/qtbase/src/corelib/tools/qarraydata.h b/qtbase/src/corelib/tools/qarraydata.h
+index dcd95924c1..d01739e7e6 100644
+--- a/qtbase/src/corelib/tools/qarraydata.h
++++ b/qtbase/src/corelib/tools/qarraydata.h
+@@ -42,6 +42,7 @@
+ 
+ #include <QtCore/qrefcount.h>
+ #include <string.h>
++#include <cstdint>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -58,14 +59,14 @@ struct Q_CORE_EXPORT QArrayData
+     {
+         Q_ASSERT(size == 0
+                 || offset < 0 || size_t(offset) >= sizeof(QArrayData));
+-        return reinterpret_cast<char *>(this) + offset;
++        return reinterpret_cast<void *> (reinterpret_cast<uintptr_t>(this) + offset);
+     }
+ 
+     const void *data() const
+     {
+         Q_ASSERT(size == 0
+                 || offset < 0 || size_t(offset) >= sizeof(QArrayData));
+-        return reinterpret_cast<const char *>(this) + offset;
++        return reinterpret_cast<void *> (reinterpret_cast<uintptr_t>(this) + offset);
+     }
+ 
+     // This refers to array data mutability, not "header data" represented by
+diff --git a/qtbase/src/corelib/tools/qfreelist_p.h b/qtbase/src/corelib/tools/qfreelist_p.h
+index 5ba23b344b..9974102136 100644
+--- a/qtbase/src/corelib/tools/qfreelist_p.h
++++ b/qtbase/src/corelib/tools/qfreelist_p.h
+@@ -161,7 +161,7 @@ class QFreeList
+                 return i;
+             x -= size;
+         }
+-        Q_ASSERT(false);
++        Q_UNREACHABLE();
+         return -1;
+     }
+ 
+diff --git a/qtbase/src/corelib/tools/qversionnumber.h b/qtbase/src/corelib/tools/qversionnumber.h
+index d43b86ba51..2843f2b043 100644
+--- a/qtbase/src/corelib/tools/qversionnumber.h
++++ b/qtbase/src/corelib/tools/qversionnumber.h
+@@ -273,10 +273,10 @@ public:
+ 
+     Q_REQUIRED_RESULT Q_CORE_EXPORT QString toString() const;
+ #if QT_STRINGVIEW_LEVEL < 2
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(const QString &string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(const QString &string, int *suffixIndex = nullptr);
+ #endif
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QLatin1String string, int *suffixIndex = nullptr);
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QStringView string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(QLatin1String string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(QStringView string, int *suffixIndex = nullptr);
+ 
+ private:
+ #ifndef QT_NO_DATASTREAM
+diff --git a/qtbase/src/dbus/qdbusintegrator.cpp b/qtbase/src/dbus/qdbusintegrator.cpp
+index 5b66ce971b..28a3b0ffea 100644
+--- a/qtbase/src/dbus/qdbusintegrator.cpp
++++ b/qtbase/src/dbus/qdbusintegrator.cpp
+@@ -1135,7 +1135,13 @@ void QDBusConnectionPrivate::closeConnection()
+         }
+     }
+ 
+-    qDeleteAll(pendingCalls);
++    for (auto it = pendingCalls.begin(); it != pendingCalls.end(); ++it) {
++        auto call = *it;
++        if (!call->ref.deref()) {
++            delete call;
++        }
++    }
++    pendingCalls.clear();
+ 
+     // Disconnect all signals from signal hooks and from the object tree to
+     // avoid QObject::destroyed being sent to dbus daemon thread which has
+@@ -2584,6 +2590,11 @@ QDBusConnectionPrivate::findMetaObject(const QString &service, const QString &pa
+         if (mo)
+             return mo;
+     }
++    if (path.isEmpty()) {
++        error = QDBusError(QDBusError::InvalidObjectPath, QLatin1String("Object path cannot be empty"));
++        lastError = error;
++        return nullptr;
++    }
+ 
+     // introspect the target object
+     QDBusMessage msg = QDBusMessage::createMethodCall(service, path,
+diff --git a/qtbase/src/dbus/qdbusmetaobject.cpp b/qtbase/src/dbus/qdbusmetaobject.cpp
+index 5265568f42..7e9f0f1acc 100644
+--- a/qtbase/src/dbus/qdbusmetaobject.cpp
++++ b/qtbase/src/dbus/qdbusmetaobject.cpp
+@@ -210,6 +210,9 @@ QDBusMetaObjectGenerator::findType(const QByteArray &signature,
+         } else if (signature == "a{ss}") {
+             result.name = "QMap<QString,QString>";
+             type = qMetaTypeId<QMap<QString, QString> >();
++        } else if (signature == "aay") {
++            result.name = "QByteArrayList";
++            type = qMetaTypeId<QByteArrayList>();
+         } else {
+             result.name = "{D-Bus type \"" + signature + "\"}";
+             type = registerComplexDBusType(result.name);
+diff --git a/qtbase/src/gui/accessible/qaccessible.cpp b/qtbase/src/gui/accessible/qaccessible.cpp
+index d705bfccb5..0caf3c808c 100644
+--- a/qtbase/src/gui/accessible/qaccessible.cpp
++++ b/qtbase/src/gui/accessible/qaccessible.cpp
+@@ -54,6 +54,7 @@
+ #include <QtCore/qdebug.h>
+ #include <QtCore/qloggingcategory.h>
+ #include <QtCore/qmetaobject.h>
++#include <QtCore/private/qmetaobject_p.h>
+ #include <QtCore/qhash.h>
+ #include <private/qfactoryloader_p.h>
+ 
+@@ -681,6 +682,25 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
+     // Create a QAccessibleInterface for the object class. Start by the most
+     // derived class and walk up the class hierarchy.
+     const QMetaObject *mo = object->metaObject();
++    const auto *objectPriv = QObjectPrivate::get(object);
++    /*
++     We do not want to cache each and every QML metaobject (Button_QMLTYPE_124,
++     Button_QMLTYPE_125, etc.). Those dynamic metaobjects shouldn't have an
++     accessible interface in any case. Instead, we start the whole checking
++     with the first non-dynamic meta-object. To avoid potential regressions
++     in other areas of Qt that also use dynamic metaobjects, we only do this
++     for objects that are QML-related (approximated by checking whether they
++     have ddata set).
++    */
++    const bool qmlRelated = !objectPriv->isDeletingChildren &&
++                            objectPriv->declarativeData;
++    while (qmlRelated && mo) {
++        auto mop = QMetaObjectPrivate::get(mo);
++        if (!mop || !(mop->flags & DynamicMetaObject))
++            break;
++
++        mo = mo->superClass();
++    };
+     while (mo) {
+         const QString cn = QLatin1String(mo->className());
+ 
+@@ -696,14 +716,15 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
+         // Find a QAccessiblePlugin (factory) for the class name. If there's
+         // no entry in the cache try to create it using the plugin loader.
+         if (!qAccessiblePlugins()->contains(cn)) {
++            QAccessiblePlugin *factory = nullptr; // 0 means "no plugin found". This is cached as well.
+             const int index = loader()->indexOf(cn);
+-            if (index != -1) {
+-                QAccessiblePlugin *factory = qobject_cast<QAccessiblePlugin *>(loader()->instance(index));
+-                qAccessiblePlugins()->insert(cn, factory);
+-            }
++            if (index != -1)
++                factory = qobject_cast<QAccessiblePlugin *>(loader()->instance(index));
++            qAccessiblePlugins()->insert(cn, factory);
+         }
+ 
+         // At this point the cache should contain a valid factory pointer or 0:
++        Q_ASSERT(qAccessiblePlugins()->contains(cn));
+         QAccessiblePlugin *factory = qAccessiblePlugins()->value(cn);
+         if (factory) {
+             QAccessibleInterface *result = factory->create(cn, object);
+diff --git a/qtbase/src/gui/configure.json b/qtbase/src/gui/configure.json
+index 1f08795c57..12c95742d2 100644
+--- a/qtbase/src/gui/configure.json
++++ b/qtbase/src/gui/configure.json
+@@ -834,7 +834,8 @@
+                     "// embedded devices, are not intended to be used together with X. EGL support",
+                     "// has to be disabled in plugins like xcb in this case since the native display,",
+                     "// window and pixmap types will be different than what an X-based platform",
+-                    "// plugin would expect."
++                    "// plugin would expect.",
++                    "#define USE_X11"
+                 ],
+                 "include": [ "EGL/egl.h", "X11/Xlib.h" ],
+                 "main": [
+diff --git a/qtbase/src/gui/image/qbmphandler.cpp b/qtbase/src/gui/image/qbmphandler.cpp
+index 96f1e8cb1d..0e73bbbdb0 100644
+--- a/qtbase/src/gui/image/qbmphandler.cpp
++++ b/qtbase/src/gui/image/qbmphandler.cpp
+@@ -150,16 +150,42 @@ static QDataStream &operator<<(QDataStream &s, const BMP_INFOHDR &bi)
+     return s;
+ }
+ 
+-static int calc_shift(uint mask)
++static uint calc_shift(uint mask)
+ {
+-    int result = 0;
+-    while (mask && !(mask & 1)) {
++    uint result = 0;
++    while ((mask >= 0x100) || (!(mask & 1) && mask)) {
+         result++;
+         mask >>= 1;
+     }
+     return result;
+ }
+ 
++static uint calc_scale(uint low_mask)
++{
++    uint result = 8;
++    while (low_mask && result) {
++        result--;
++        low_mask >>= 1;
++    }
++    return result;
++}
++
++static inline uint apply_scale(uint value, uint scale)
++{
++    if (!(scale & 0x07)) // return immediately if scale == 8 or 0
++        return value;
++
++    uint filled = 8 - scale;
++    uint result = value << scale;
++
++    do {
++        result |= result >> filled;
++        filled <<= 1;
++    } while (filled < 8);
++
++    return result;
++}
++
+ static bool read_dib_fileheader(QDataStream &s, BMP_FILEHDR &bf)
+ {
+     // read BMP file header
+@@ -222,14 +248,14 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+     uint green_mask = 0;
+     uint blue_mask = 0;
+     uint alpha_mask = 0;
+-    int red_shift = 0;
+-    int green_shift = 0;
+-    int blue_shift = 0;
+-    int alpha_shift = 0;
+-    int red_scale = 0;
+-    int green_scale = 0;
+-    int blue_scale = 0;
+-    int alpha_scale = 0;
++    uint red_shift = 0;
++    uint green_shift = 0;
++    uint blue_shift = 0;
++    uint alpha_shift = 0;
++    uint red_scale = 0;
++    uint green_scale = 0;
++    uint blue_scale = 0;
++    uint alpha_scale = 0;
+ 
+     if (!d->isSequential())
+         d->seek(startpos + BMP_FILEHDR_SIZE + bi.biSize); // goto start of colormap or masks
+@@ -308,19 +334,19 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+         red_shift = calc_shift(red_mask);
+         if (((red_mask >> red_shift) + 1) == 0)
+             return false;
+-        red_scale = 256 / ((red_mask >> red_shift) + 1);
++        red_scale = calc_scale(red_mask >> red_shift);
+         green_shift = calc_shift(green_mask);
+         if (((green_mask >> green_shift) + 1) == 0)
+             return false;
+-        green_scale = 256 / ((green_mask >> green_shift) + 1);
++        green_scale = calc_scale(green_mask >> green_shift);
+         blue_shift = calc_shift(blue_mask);
+         if (((blue_mask >> blue_shift) + 1) == 0)
+             return false;
+-        blue_scale = 256 / ((blue_mask >> blue_shift) + 1);
++        blue_scale = calc_scale(blue_mask >> blue_shift);
+         alpha_shift = calc_shift(alpha_mask);
+         if (((alpha_mask >> alpha_shift) + 1) == 0)
+             return false;
+-        alpha_scale = 256 / ((alpha_mask >> alpha_shift) + 1);
++        alpha_scale = calc_scale(alpha_mask >> alpha_shift);
+     } else if (comp == BMP_RGB && (nbits == 24 || nbits == 32)) {
+         blue_mask = 0x000000ff;
+         green_mask = 0x0000ff00;
+@@ -328,17 +354,15 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+         blue_shift = 0;
+         green_shift = 8;
+         red_shift = 16;
+-        blue_scale = green_scale = red_scale = 1;
++        blue_scale = green_scale = red_scale = 0;
+     } else if (comp == BMP_RGB && nbits == 16) {
+         blue_mask = 0x001f;
+         green_mask = 0x03e0;
+         red_mask = 0x7c00;
+         blue_shift = 0;
+-        green_shift = 2;
+-        red_shift = 7;
+-        red_scale = 1;
+-        green_scale = 1;
+-        blue_scale = 8;
++        green_shift = 5;
++        red_shift = 10;
++        blue_scale = green_scale = red_scale = 3;
+     }
+ 
+ #if 0
+@@ -544,10 +568,10 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+                     c |= *(uchar*)(b+2)<<16;
+                 if (nbits > 24)
+                     c |= *(uchar*)(b+3)<<24;
+-                *p++ = qRgba(((c & red_mask) >> red_shift) * red_scale,
+-                                        ((c & green_mask) >> green_shift) * green_scale,
+-                                        ((c & blue_mask) >> blue_shift) * blue_scale,
+-                                        transp ? ((c & alpha_mask) >> alpha_shift) * alpha_scale : 0xff);
++                *p++ = qRgba(apply_scale((c & red_mask) >> red_shift, red_scale),
++                             apply_scale((c & green_mask) >> green_shift, green_scale),
++                             apply_scale((c & blue_mask) >> blue_shift, blue_scale),
++                             transp ? apply_scale((c & alpha_mask) >> alpha_shift, alpha_scale) : 0xff);
+                 b += nbits/8;
+             }
+         }
+diff --git a/qtbase/src/gui/image/qimage.cpp b/qtbase/src/gui/image/qimage.cpp
+index 7152ac1607..0df772564c 100644
+--- a/qtbase/src/gui/image/qimage.cpp
++++ b/qtbase/src/gui/image/qimage.cpp
+@@ -4694,6 +4694,8 @@ QImage QImage::smoothScaled(int w, int h) const {
+ static QImage rotated90(const QImage &image)
+ {
+     QImage out(image.height(), image.width(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+@@ -4722,6 +4724,8 @@ static QImage rotated180(const QImage &image)
+         return image.mirrored(true, true);
+ 
+     QImage out(image.width(), image.height(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+@@ -4734,6 +4738,8 @@ static QImage rotated180(const QImage &image)
+ static QImage rotated270(const QImage &image)
+ {
+     QImage out(image.height(), image.width(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+diff --git a/qtbase/src/gui/kernel/qcursor.cpp b/qtbase/src/gui/kernel/qcursor.cpp
+index d6ccaff8ed..455088241c 100644
+--- a/qtbase/src/gui/kernel/qcursor.cpp
++++ b/qtbase/src/gui/kernel/qcursor.cpp
+@@ -251,7 +251,8 @@ void QCursor::setPos(QScreen *screen, int x, int y)
+ {
+     if (screen) {
+         if (QPlatformCursor *cursor = screen->handle()->cursor()) {
+-            const QPoint devicePos = QHighDpi::toNativePixels(QPoint(x, y), screen);
++            const QPoint pos(x, y);
++            const QPoint devicePos = QHighDpi::toNativePixels(pos, screen->virtualSiblingAt(pos));
+             // Need to check, since some X servers generate null mouse move
+             // events, causing looping in applications which call setPos() on
+             // every mouse move event.
+diff --git a/qtbase/src/gui/kernel/qhighdpiscaling.cpp b/qtbase/src/gui/kernel/qhighdpiscaling.cpp
+index 9bbf2773a9..3ac4a4d8b6 100644
+--- a/qtbase/src/gui/kernel/qhighdpiscaling.cpp
++++ b/qtbase/src/gui/kernel/qhighdpiscaling.cpp
+@@ -580,9 +580,8 @@ void QHighDpiScaling::setScreenFactor(QScreen *screen, qreal factor)
+     else
+         qNamedScreenScaleFactors()->insert(name, factor);
+ 
+-    // hack to force re-evaluation of screen geometry
+     if (screen->handle())
+-        screen->d_func()->setPlatformScreen(screen->handle()); // updates geometries based on scale factor
++        screen->d_func()->updateLogicalDpi();
+ }
+ 
+ QPoint QHighDpiScaling::mapPositionToNative(const QPoint &pos, const QPlatformScreen *platformScreen)
+diff --git a/qtbase/src/gui/kernel/qkeysequence.cpp b/qtbase/src/gui/kernel/qkeysequence.cpp
+index a75b8ef920..4f2d294739 100644
+--- a/qtbase/src/gui/kernel/qkeysequence.cpp
++++ b/qtbase/src/gui/kernel/qkeysequence.cpp
+@@ -701,6 +701,10 @@ static const struct {
+     { Qt::Key_TouchpadToggle,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad Toggle") },
+     { Qt::Key_TouchpadOn,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad On") },
+     { Qt::Key_TouchpadOff,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad Off") },
++    { Qt::Key_Shift,  QT_TRANSLATE_NOOP("QShortcut", "Shift") },
++    { Qt::Key_Control,  QT_TRANSLATE_NOOP("QShortcut", "Control") },
++    { Qt::Key_Alt,  QT_TRANSLATE_NOOP("QShortcut", "Alt") },
++    { Qt::Key_Meta,  QT_TRANSLATE_NOOP("QShortcut", "Meta") },
+ 
+ };
+ static Q_CONSTEXPR int numKeyNames = sizeof keyname / sizeof *keyname;
+diff --git a/qtbase/src/gui/kernel/qplatformservices.cpp b/qtbase/src/gui/kernel/qplatformservices.cpp
+index fdc6a6c4aa..ac47f98c5d 100644
+--- a/qtbase/src/gui/kernel/qplatformservices.cpp
++++ b/qtbase/src/gui/kernel/qplatformservices.cpp
+@@ -55,6 +55,19 @@ QT_BEGIN_NAMESPACE
+     \brief The QPlatformServices provides the backend for desktop-related functionality.
+ */
+ 
++/*!
++    \enum QPlatformServices::Capability
++
++    Capabilities are used to determine a specific platform service's availability.
++
++    \value ColorPickingFromScreen The platform natively supports color picking from screen.
++    This capability indicates that the platform supports "opaque" color picking, where the
++    platform implements a complete user experience for color picking and outputs a color.
++    This is in contrast to the application implementing the color picking user experience
++    (taking care of showing a cross hair, instructing the platform integration to obtain
++    the color at a given pixel, etc.). The related service function is pickColor().
++ */
++
+ QPlatformServices::QPlatformServices()
+ { }
+ 
+@@ -85,5 +98,16 @@ QByteArray QPlatformServices::desktopEnvironment() const
+     return QByteArray("UNKNOWN");
+ }
+ 
++QPlatformServiceColorPicker *QPlatformServices::colorPicker(QWindow *parent)
++{
++    Q_UNUSED(parent);
++    return nullptr;
++}
++
++bool QPlatformServices::hasCapability(Capability capability) const
++{
++    Q_UNUSED(capability)
++    return false;
++}
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/gui/kernel/qplatformservices.h b/qtbase/src/gui/kernel/qplatformservices.h
+index 5de96cfa7d..a8b2a4ce71 100644
+--- a/qtbase/src/gui/kernel/qplatformservices.h
++++ b/qtbase/src/gui/kernel/qplatformservices.h
+@@ -50,16 +50,32 @@
+ //
+ 
+ #include <QtGui/qtguiglobal.h>
++#include <QtCore/qobject.h>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+ class QUrl;
++class QWindow;
++
++class Q_GUI_EXPORT QPlatformServiceColorPicker : public QObject
++{
++    Q_OBJECT
++public:
++    using QObject::QObject;
++    virtual void pickColor() = 0;
++Q_SIGNALS:
++    void colorPicked(const QColor &color);
++};
+ 
+ class Q_GUI_EXPORT QPlatformServices
+ {
+ public:
+     Q_DISABLE_COPY_MOVE(QPlatformServices)
+ 
++    enum Capability {
++        ColorPicking,
++    };
++
+     QPlatformServices();
+     virtual ~QPlatformServices() { }
+ 
+@@ -67,6 +83,10 @@ public:
+     virtual bool openDocument(const QUrl &url);
+ 
+     virtual QByteArray desktopEnvironment() const;
++
++    virtual bool hasCapability(Capability capability) const;
++
++    virtual QPlatformServiceColorPicker *colorPicker(QWindow *parent = nullptr);
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/gui/kernel/qplatformtheme.cpp b/qtbase/src/gui/kernel/qplatformtheme.cpp
+index 71521c0339..2325873245 100644
+--- a/qtbase/src/gui/kernel/qplatformtheme.cpp
++++ b/qtbase/src/gui/kernel/qplatformtheme.cpp
+@@ -163,6 +163,8 @@ QT_BEGIN_NAMESPACE
+ 
+     \value ShowShortcutsInContextMenus (bool) Whether to display shortcut key sequences in context menus.
+ 
++    \value ButtonPressKeys (QList<Qt::Key>) A list of keys that can be used to press buttons via keyboard input.
++
+     \sa themeHint(), QStyle::pixelMetric()
+ */
+ 
+@@ -563,6 +565,8 @@ QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint)
+         }
+     case MouseQuickSelectionThreshold:
+         return QVariant(10);
++    case ButtonPressKeys:
++        return QVariant::fromValue(QList<Qt::Key>({ Qt::Key_Space, Qt::Key_Select }));
+     }
+     return QVariant();
+ }
+diff --git a/qtbase/src/gui/kernel/qplatformtheme.h b/qtbase/src/gui/kernel/qplatformtheme.h
+index 3185fc4541..7e6c9d5740 100644
+--- a/qtbase/src/gui/kernel/qplatformtheme.h
++++ b/qtbase/src/gui/kernel/qplatformtheme.h
+@@ -120,7 +120,8 @@ public:
+         TouchDoubleTapDistance,
+         ShowShortcutsInContextMenus,
+         IconFallbackSearchPaths,
+-        MouseQuickSelectionThreshold
++        MouseQuickSelectionThreshold,
++        ButtonPressKeys
+     };
+ 
+     enum DialogType {
+diff --git a/qtbase/src/gui/kernel/qscreen.cpp b/qtbase/src/gui/kernel/qscreen.cpp
+index 8e0eb35116..5d172a58dd 100644
+--- a/qtbase/src/gui/kernel/qscreen.cpp
++++ b/qtbase/src/gui/kernel/qscreen.cpp
+@@ -77,6 +77,12 @@ QScreen::QScreen(QPlatformScreen *screen)
+     d->setPlatformScreen(screen);
+ }
+ 
++void QScreenPrivate::updateLogicalDpi()
++{
++    logicalDpi = QPlatformScreen::overrideDpi(platformScreen->logicalDpi());
++    updateGeometriesWithSignals(); // updates geometries based on scale factor
++}
++
+ void QScreenPrivate::updateGeometriesWithSignals()
+ {
+     const QRect oldGeometry = geometry;
+diff --git a/qtbase/src/gui/kernel/qscreen_p.h b/qtbase/src/gui/kernel/qscreen_p.h
+index 7da542c25e..e50fc3190b 100644
+--- a/qtbase/src/gui/kernel/qscreen_p.h
++++ b/qtbase/src/gui/kernel/qscreen_p.h
+@@ -70,6 +70,7 @@ public:
+         geometry = platformScreen->deviceIndependentGeometry();
+         availableGeometry = QHighDpi::fromNative(platformScreen->availableGeometry(), QHighDpiScaling::factor(platformScreen), geometry.topLeft());
+     }
++    void updateLogicalDpi();
+ 
+     void updatePrimaryOrientation();
+     void updateGeometriesWithSignals();
+diff --git a/qtbase/src/gui/painting/qblendfunctions_p.h b/qtbase/src/gui/painting/qblendfunctions_p.h
+index 080da98ec4..6997d62b3c 100644
+--- a/qtbase/src/gui/painting/qblendfunctions_p.h
++++ b/qtbase/src/gui/painting/qblendfunctions_p.h
+@@ -246,25 +246,32 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+                                   int dudx, int dvdx, int dudy, int dvdy, int u0, int v0,
+                                   Blender blender)
+ {
+-    int fromY = qMax(qRound(topY), clip.top());
+-    int toY = qMin(qRound(bottomY), clip.top() + clip.height());
++    qint64 fromY = qMax(qRound(topY), clip.top());
++    qint64 toY = qMin(qRound(bottomY), clip.top() + clip.height());
+     if (fromY >= toY)
+         return;
+ 
+     qreal leftSlope = (bottomLeft.x - topLeft.x) / (bottomLeft.y - topLeft.y);
+     qreal rightSlope = (bottomRight.x - topRight.x) / (bottomRight.y - topRight.y);
+-    int dx_l = int(leftSlope * 0x10000);
+-    int dx_r = int(rightSlope * 0x10000);
+-    int x_l = int((topLeft.x + (qreal(0.5) + fromY - topLeft.y) * leftSlope + qreal(0.5)) * 0x10000);
+-    int x_r = int((topRight.x + (qreal(0.5) + fromY - topRight.y) * rightSlope + qreal(0.5)) * 0x10000);
+-
+-    int fromX, toX, x1, x2, u, v, i, ii;
++    qint64 dx_l = qint64(leftSlope * 0x10000);
++    qint64 dx_r = qint64(rightSlope * 0x10000);
++    qint64 x_l = qint64((topLeft.x + (qreal(0.5) + fromY - topLeft.y) * leftSlope + qreal(0.5)) * 0x10000);
++    qint64 x_r = qint64((topRight.x + (qreal(0.5) + fromY - topRight.y) * rightSlope + qreal(0.5)) * 0x10000);
++
++    qint64 sourceRectTop = qint64(sourceRect.top());
++    qint64 sourceRectLeft = qint64(sourceRect.left());
++    qint64 sourceRectWidth = qint64(sourceRect.width());
++    qint64 sourceRectHeight = qint64(sourceRect.height());
++    qint64 clipLeft = qint64(clip.left());
++    qint64 clipWidth = qint64(clip.width());
++
++    qint64 fromX, toX, x1, x2, u, v, i, ii;
+     DestT *line;
+-    for (int y = fromY; y < toY; ++y) {
++    for (qint64 y = fromY; y < toY; ++y) {
+         line = reinterpret_cast<DestT *>(reinterpret_cast<uchar *>(destPixels) + y * dbpl);
+ 
+-        fromX = qMax(x_l >> 16, clip.left());
+-        toX = qMin(x_r >> 16, clip.left() + clip.width());
++        fromX = qMax(x_l >> 16, clipLeft);
++        toX = qMin(x_r >> 16, clipLeft + clipWidth);
+         if (fromX < toX) {
+             // Because of rounding, we can get source coordinates outside the source image.
+             // Clamp these coordinates to the source rect to avoid segmentation fault and
+@@ -275,10 +282,10 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             u = x1 * dudx + y * dudy + u0;
+             v = x1 * dvdx + y * dvdy + v0;
+             for (; x1 < toX; ++x1) {
+-                int uu = u >> 16;
+-                int vv = v >> 16;
+-                if (uu >= sourceRect.left() && uu < sourceRect.left() + sourceRect.width()
+-                    && vv >= sourceRect.top() && vv < sourceRect.top() + sourceRect.height()) {
++                qint64 uu = u >> 16;
++                qint64 vv = v >> 16;
++                if (uu >= sourceRectLeft && uu < sourceRectLeft + sourceRectWidth
++                    && vv >= sourceRectTop && vv < sourceRectTop + sourceRectHeight) {
+                     break;
+                 }
+                 u += dudx;
+@@ -290,10 +297,10 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             u = (x2 - 1) * dudx + y * dudy + u0;
+             v = (x2 - 1) * dvdx + y * dvdy + v0;
+             for (; x2 > x1; --x2) {
+-                int uu = u >> 16;
+-                int vv = v >> 16;
+-                if (uu >= sourceRect.left() && uu < sourceRect.left() + sourceRect.width()
+-                    && vv >= sourceRect.top() && vv < sourceRect.top() + sourceRect.height()) {
++                qint64 uu = u >> 16;
++                qint64 vv = v >> 16;
++                if (uu >= sourceRectLeft && uu < sourceRectLeft + sourceRectWidth
++                    && vv >= sourceRectTop && vv < sourceRectTop + sourceRectHeight) {
+                     break;
+                 }
+                 u -= dudx;
+@@ -308,8 +315,8 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             // Beginning of the scan line, with per-pixel checks.
+             i = x1 - fromX;
+             while (i) {
+-                int uu = qBound(sourceRect.left(), u >> 16, sourceRect.left() + sourceRect.width() - 1);
+-                int vv = qBound(sourceRect.top(), v >> 16, sourceRect.top() + sourceRect.height() - 1);
++                qint64 uu = qBound(sourceRectLeft, u >> 16, sourceRectLeft + sourceRectWidth - 1);
++                qint64 vv = qBound(sourceRectTop, v >> 16, sourceRectTop + sourceRectHeight - 1);
+                 blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + vv * sbpl)[uu]);
+                 u += dudx;
+                 v += dvdx;
+@@ -348,8 +355,8 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             // End of the scan line, with per-pixel checks.
+             i = toX - x2;
+             while (i) {
+-                int uu = qBound(sourceRect.left(), u >> 16, sourceRect.left() + sourceRect.width() - 1);
+-                int vv = qBound(sourceRect.top(), v >> 16, sourceRect.top() + sourceRect.height() - 1);
++                qint64 uu = qBound(sourceRectLeft, u >> 16, sourceRectLeft + sourceRectWidth - 1);
++                qint64 vv = qBound(sourceRectTop, v >> 16, sourceRectTop + sourceRectHeight - 1);
+                 blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + vv * sbpl)[uu]);
+                 u += dudx;
+                 v += dvdx;
+diff --git a/qtbase/src/gui/painting/qcolortrclut_p.h b/qtbase/src/gui/painting/qcolortrclut_p.h
+index 76a6a60803..24fd522e6c 100644
+--- a/qtbase/src/gui/painting/qcolortrclut_p.h
++++ b/qtbase/src/gui/painting/qcolortrclut_p.h
+@@ -118,6 +118,7 @@ public:
+         return QRgba64::fromRgba64(r, g, b, qAlpha(rgb32) * 257);
+ #endif
+     }
++    QRgba64 toLinear64(QRgba64) const = delete;
+ 
+     QRgb toLinear(QRgb rgb32) const
+     {
+diff --git a/qtbase/src/gui/painting/qdrawhelper.cpp b/qtbase/src/gui/painting/qdrawhelper.cpp
+index a61793508a..5ba2d277b7 100644
+--- a/qtbase/src/gui/painting/qdrawhelper.cpp
++++ b/qtbase/src/gui/painting/qdrawhelper.cpp
+@@ -6091,7 +6091,7 @@ static inline void alphargbblend_argb32(quint32 *dst, uint coverage, const QRgba
+ static inline void rgbBlendPixel(QRgba64 &dst, int coverage, QRgba64 slinear, const QColorTrcLut *colorProfile)
+ {
+     // Do a gammacorrected RGB alphablend...
+-    const QRgba64 dlinear = colorProfile ? colorProfile->toLinear64(dst) : dst;
++    const QRgba64 dlinear = colorProfile ? colorProfile->toLinear(dst) : dst;
+ 
+     QRgba64 blend = rgbBlend(dlinear, slinear, coverage);
+ 
+diff --git a/qtbase/src/gui/painting/qpaintengine_raster.cpp b/qtbase/src/gui/painting/qpaintengine_raster.cpp
+index 283923de52..f08eb9cbee 100644
+--- a/qtbase/src/gui/painting/qpaintengine_raster.cpp
++++ b/qtbase/src/gui/painting/qpaintengine_raster.cpp
+@@ -560,31 +560,6 @@ void QRasterPaintEngine::updateMatrix(const QTransform &matrix)
+     QRasterPaintEngineState *s = state();
+     // FALCON: get rid of this line, see drawImage call below.
+     s->matrix = matrix;
+-    QTransform::TransformationType txop = s->matrix.type();
+-
+-    switch (txop) {
+-
+-    case QTransform::TxNone:
+-        s->flags.int_xform = true;
+-        break;
+-
+-    case QTransform::TxTranslate:
+-        s->flags.int_xform = qreal(int(s->matrix.dx())) == s->matrix.dx()
+-                            && qreal(int(s->matrix.dy())) == s->matrix.dy();
+-        break;
+-
+-    case QTransform::TxScale:
+-        s->flags.int_xform = qreal(int(s->matrix.dx())) == s->matrix.dx()
+-                            && qreal(int(s->matrix.dy())) == s->matrix.dy()
+-                            && qreal(int(s->matrix.m11())) == s->matrix.m11()
+-                            && qreal(int(s->matrix.m22())) == s->matrix.m22();
+-        break;
+-
+-    default: // shear / perspective...
+-        s->flags.int_xform = false;
+-        break;
+-    }
+-
+     s->flags.tx_noshear = qt_scaleForTransform(s->matrix, &s->txscale);
+ 
+     ensureOutlineMapper();
+@@ -617,7 +592,6 @@ QRasterPaintEngineState::QRasterPaintEngineState()
+     flags.bilinear = false;
+     flags.legacy_rounding = false;
+     flags.fast_text = true;
+-    flags.int_xform = true;
+     flags.tx_noshear = true;
+     flags.fast_images = true;
+ 
+@@ -1793,7 +1767,7 @@ void QRasterPaintEngine::fill(const QVectorPath &path, const QBrush &brush)
+     QRectF cpRect = path.controlPointRect();
+     const QRectF pathDeviceRect = s->matrix.mapRect(cpRect);
+     // Skip paths that by conservative estimates are completely outside the paint device.
+-    if (!pathDeviceRect.intersects(QRectF(d->deviceRect)))
++    if (!pathDeviceRect.intersects(QRectF(d->deviceRect)) || !pathDeviceRect.isValid())
+         return;
+ 
+     ProcessSpans blend = d->getBrushFunc(pathDeviceRect, &s->brushData);
+diff --git a/qtbase/src/gui/painting/qpaintengine_raster_p.h b/qtbase/src/gui/painting/qpaintengine_raster_p.h
+index 089aadc3f7..bf7363d5aa 100644
+--- a/qtbase/src/gui/painting/qpaintengine_raster_p.h
++++ b/qtbase/src/gui/painting/qpaintengine_raster_p.h
+@@ -111,7 +111,6 @@ public:
+         uint bilinear : 1;
+         uint legacy_rounding : 1;
+         uint fast_text : 1;
+-        uint int_xform : 1;
+         uint tx_noshear : 1;
+         uint fast_images : 1;
+     };
+diff --git a/qtbase/src/gui/painting/qpainterpath.cpp b/qtbase/src/gui/painting/qpainterpath.cpp
+index f9544a3241..d80fafeaf1 100644
+--- a/qtbase/src/gui/painting/qpainterpath.cpp
++++ b/qtbase/src/gui/painting/qpainterpath.cpp
+@@ -1253,7 +1253,7 @@ void QPainterPath::addText(const QPointF &point, const QFont &f, const QString &
+ 
+         if (si.analysis.flags < QScriptAnalysis::TabOrObject) {
+             QGlyphLayout glyphs = eng->shapedGlyphs(&si);
+-            QFontEngine *fe = f.d->engineForScript(si.analysis.script);
++            QFontEngine *fe = eng->fontEngine(si);
+             Q_ASSERT(fe);
+             fe->addOutlineToPath(x, y, glyphs, this,
+                                  si.analysis.bidiLevel % 2
+diff --git a/qtbase/src/gui/painting/qpathclipper_p.h b/qtbase/src/gui/painting/qpathclipper_p.h
+index 9444a87b71..18f64c5e8c 100644
+--- a/qtbase/src/gui/painting/qpathclipper_p.h
++++ b/qtbase/src/gui/painting/qpathclipper_p.h
+@@ -156,7 +156,7 @@ public:
+     int vertex(Direction direction) const;
+ 
+ private:
+-    int m_next[2][2];
++    int m_next[2][2] = { { -1, -1 }, { -1, -1 } };
+ };
+ 
+ class QPathSegments
+@@ -296,10 +296,6 @@ inline QPathEdge::QPathEdge(int a, int b)
+     , angle(0)
+     , invAngle(0)
+ {
+-    m_next[0][0] = -1;
+-    m_next[1][0] = -1;
+-    m_next[0][0] = -1;
+-    m_next[1][0] = -1;
+ }
+ 
+ inline int QPathEdge::next(Traversal traversal, Direction direction) const
+diff --git a/qtbase/src/gui/painting/qpdf.cpp b/qtbase/src/gui/painting/qpdf.cpp
+index 3066744f1b..2c8d3c3b53 100644
+--- a/qtbase/src/gui/painting/qpdf.cpp
++++ b/qtbase/src/gui/painting/qpdf.cpp
+@@ -2760,6 +2760,8 @@ int QPdfEnginePrivate::addBrushPattern(const QTransform &m, bool *specifyColor,
+         return gradientBrush(brush, matrix, gStateObject);
+     }
+ 
++    matrix = brush.transform() * matrix;
++
+     if ((!brush.isOpaque() && brush.style() < Qt::LinearGradientPattern) || opacity != 1.0)
+         *gStateObject = addConstantAlphaObject(qRound(brush.color().alpha() * opacity),
+                                                qRound(pen.color().alpha() * opacity));
+diff --git a/qtbase/src/gui/painting/qstroker.cpp b/qtbase/src/gui/painting/qstroker.cpp
+index cb5d395e80..3b6357a893 100644
+--- a/qtbase/src/gui/painting/qstroker.cpp
++++ b/qtbase/src/gui/painting/qstroker.cpp
+@@ -1182,6 +1182,7 @@ void QDashStroker::processCurrentSubpath()
+         // Check if the entire line should be clipped away or simplified
+         bool clipIt = clipping && !lineIntersectsRect(prev, e, clip_tl, clip_br);
+         bool skipDashing = elen * invSumLength > repetitionLimit();
++        int maxDashes = dashCount;
+         if (skipDashing || clipIt) {
+             // Cut away full dash sequences.
+             elen -= std::floor(elen * invSumLength) * sumLength;
+@@ -1196,7 +1197,7 @@ void QDashStroker::processCurrentSubpath()
+                     pos = estop; // move pos to next path element
+                     done = true;
+                 } else { // Dash is on this line
+-                    pos = dpos + estart;
++                    pos = --maxDashes > 0 ? dpos + estart : estop;
+                     done = pos >= estop;
+                     if (++idash >= dashCount)
+                         idash = 0;
+diff --git a/qtbase/src/gui/painting/qt_attribution.json b/qtbase/src/gui/painting/qt_attribution.json
+index 7b16e8c211..0e87d30aa2 100644
+--- a/qtbase/src/gui/painting/qt_attribution.json
++++ b/qtbase/src/gui/painting/qt_attribution.json
+@@ -10,7 +10,7 @@
+         "Homepage": "http://www.freetype.org",
+         "License": "Freetype Project License or GNU General Public License v2.0 only",
+         "LicenseId": "FTL or GPL-2.0",
+-        "LicenseFile": "../../3rdparty/freetype/docs/LICENSE.TXT",
++        "LicenseFile": "../../3rdparty/freetype/LICENSE.TXT",
+         "Copyright": "Copyright 2000-2016 by David Turner, Robert Wilhelm, and Werner Lemberg."
+     },
+     {
+diff --git a/qtbase/src/gui/rhi/qshader_p_p.h b/qtbase/src/gui/rhi/qshader_p_p.h
+index ec9d25971f..4a5a7a6d51 100644
+--- a/qtbase/src/gui/rhi/qshader_p_p.h
++++ b/qtbase/src/gui/rhi/qshader_p_p.h
+@@ -68,13 +68,13 @@ struct Q_GUI_EXPORT QShaderPrivate
+     {
+     }
+ 
+-    QShaderPrivate(const QShaderPrivate *other)
++    QShaderPrivate(const QShaderPrivate &other)
+         : ref(1),
+-          qsbVersion(other->qsbVersion),
+-          stage(other->stage),
+-          desc(other->desc),
+-          shaders(other->shaders),
+-          bindings(other->bindings)
++          qsbVersion(other.qsbVersion),
++          stage(other.stage),
++          desc(other.desc),
++          shaders(other.shaders),
++          bindings(other.bindings)
+     {
+     }
+ 
+diff --git a/qtbase/src/gui/rhi/qshaderdescription_p_p.h b/qtbase/src/gui/rhi/qshaderdescription_p_p.h
+index ec2b0b6b4c..3da33a8a2b 100644
+--- a/qtbase/src/gui/rhi/qshaderdescription_p_p.h
++++ b/qtbase/src/gui/rhi/qshaderdescription_p_p.h
+@@ -63,16 +63,16 @@ struct Q_GUI_EXPORT QShaderDescriptionPrivate
+         localSize[0] = localSize[1] = localSize[2] = 0;
+     }
+ 
+-    QShaderDescriptionPrivate(const QShaderDescriptionPrivate *other)
++    QShaderDescriptionPrivate(const QShaderDescriptionPrivate &other)
+         : ref(1),
+-          inVars(other->inVars),
+-          outVars(other->outVars),
+-          uniformBlocks(other->uniformBlocks),
+-          pushConstantBlocks(other->pushConstantBlocks),
+-          storageBlocks(other->storageBlocks),
+-          combinedImageSamplers(other->combinedImageSamplers),
+-          storageImages(other->storageImages),
+-          localSize(other->localSize)
++          inVars(other.inVars),
++          outVars(other.outVars),
++          uniformBlocks(other.uniformBlocks),
++          pushConstantBlocks(other.pushConstantBlocks),
++          storageBlocks(other.storageBlocks),
++          combinedImageSamplers(other.combinedImageSamplers),
++          storageImages(other.storageImages),
++          localSize(other.localSize)
+     {
+     }
+ 
+diff --git a/qtbase/src/gui/text/qfontdatabase.cpp b/qtbase/src/gui/text/qfontdatabase.cpp
+index a657a8c516..4fc0100958 100644
+--- a/qtbase/src/gui/text/qfontdatabase.cpp
++++ b/qtbase/src/gui/text/qfontdatabase.cpp
+@@ -983,7 +983,7 @@ QFontEngine *loadSingleEngine(int script,
+         if (style->key.stretch != 0 && request.stretch != 0
+             && (request.styleName.isEmpty() || request.styleName != style->styleName)) {
+             def.stretch = (request.stretch * 100 + style->key.stretch / 2) / style->key.stretch;
+-        } else {
++        } else if (request.stretch == QFont::AnyStretch) {
+             def.stretch = 100;
+         }
+ 
+diff --git a/qtbase/src/gui/text/qtextdocumentlayout.cpp b/qtbase/src/gui/text/qtextdocumentlayout.cpp
+index f3e6ea2100..72267e9380 100644
+--- a/qtbase/src/gui/text/qtextdocumentlayout.cpp
++++ b/qtbase/src/gui/text/qtextdocumentlayout.cpp
+@@ -2123,7 +2123,7 @@ void QTextDocumentLayoutPrivate::drawListItem(const QPointF &offset, QPainter *p
+ {
+     Q_Q(const QTextDocumentLayout);
+     const QTextBlockFormat blockFormat = bl.blockFormat();
+-    const QTextCharFormat charFormat = QTextCursor(bl).charFormat();
++    const QTextCharFormat charFormat = bl.charFormat();
+     QFont font(charFormat.font());
+     if (q->paintDevice())
+         font = QFont(font, q->paintDevice());
+diff --git a/qtbase/src/gui/text/qtextengine.cpp b/qtbase/src/gui/text/qtextengine.cpp
+index ce4abac472..a6c66e5d2d 100644
+--- a/qtbase/src/gui/text/qtextengine.cpp
++++ b/qtbase/src/gui/text/qtextengine.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2021 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtGui module of the Qt Toolkit.
+@@ -1565,6 +1565,12 @@ void QTextEngine::shapeText(int item) const
+         // Overwrite with 0 token to indicate failure
+         QGlyphLayout g = availableGlyphs(&si);
+         g.glyphs[0] = 0;
++        g.attributes[0].clusterStart = true;
++
++        ushort *log_clusters = logClusters(&si);
++        for (int i = 0; i < itemLength; ++i)
++            log_clusters[i] = 0;
++
+         return;
+     }
+ 
+diff --git a/qtbase/src/gui/util/qdesktopservices.cpp b/qtbase/src/gui/util/qdesktopservices.cpp
+index fbb63a9408..4d5fafaaa7 100644
+--- a/qtbase/src/gui/util/qdesktopservices.cpp
++++ b/qtbase/src/gui/util/qdesktopservices.cpp
+@@ -54,6 +54,8 @@
+ #include <qpa/qplatformintegration.h>
+ #include <qdir.h>
+ 
++#include <QtCore/private/qlocking_p.h>
++
+ QT_BEGIN_NAMESPACE
+ 
+ class QOpenUrlHandlerRegistry : public QObject
+@@ -81,6 +83,7 @@ Q_GLOBAL_STATIC(QOpenUrlHandlerRegistry, handlerRegistry)
+ 
+ void QOpenUrlHandlerRegistry::handlerDestroyed(QObject *handler)
+ {
++    const auto lock = qt_scoped_lock(mutex);
+     HandlerHash::Iterator it = handlers.begin();
+     while (it != handlers.end()) {
+         if (it->receiver == handler) {
+@@ -294,7 +297,8 @@ void QDesktopServices::setUrlHandler(const QString &scheme, QObject *receiver, c
+     h.name = method;
+     registry->handlers.insert(scheme.toLower(), h);
+     QObject::connect(receiver, SIGNAL(destroyed(QObject*)),
+-                     registry, SLOT(handlerDestroyed(QObject*)));
++                     registry, SLOT(handlerDestroyed(QObject*)),
++                     Qt::DirectConnection);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/gui/util/qpkmhandler.cpp b/qtbase/src/gui/util/qpkmhandler.cpp
+index e0c3b75efe..3414f9d8ba 100644
+--- a/qtbase/src/gui/util/qpkmhandler.cpp
++++ b/qtbase/src/gui/util/qpkmhandler.cpp
+@@ -57,7 +57,7 @@ struct PkmType
+     quint32 bytesPerBlock;
+ };
+ 
+-static PkmType typeMap[5] = {
++static constexpr PkmType typeMap[5] = {
+     { 0x8D64,  8 },   // GL_ETC1_RGB8_OES
+     { 0x9274,  8 },   // GL_COMPRESSED_RGB8_ETC2
+     { 0, 0 },         // unused (obsolete)
+diff --git a/qtbase/src/network/access/qnetworkreplyfileimpl.cpp b/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
+index b6be93147a..6e69b4c4d3 100644
+--- a/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
++++ b/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
+@@ -89,9 +89,10 @@ QNetworkReplyFileImpl::QNetworkReplyFileImpl(QNetworkAccessManager *manager, con
+         // we handle only local files
+         QString msg = QCoreApplication::translate("QNetworkAccessFileBackend", "Request for opening non-local file %1").arg(url.toString());
+         setError(QNetworkReply::ProtocolInvalidOperationError, msg);
++        setFinished(true); // We're finished, will emit finished() after ctor is done.
+         QMetaObject::invokeMethod(this, "errorOccurred", Qt::QueuedConnection,
+             Q_ARG(QNetworkReply::NetworkError, QNetworkReply::ProtocolInvalidOperationError));
+-        fileOpenFinished(false);
++        QMetaObject::invokeMethod(this, [this](){ fileOpenFinished(false); }, Qt::QueuedConnection);
+         return;
+     }
+ #endif
+diff --git a/qtbase/src/network/access/qnetworkreplyimpl.cpp b/qtbase/src/network/access/qnetworkreplyimpl.cpp
+index bcdf6ee2f1..3b6deb82bd 100644
+--- a/qtbase/src/network/access/qnetworkreplyimpl.cpp
++++ b/qtbase/src/network/access/qnetworkreplyimpl.cpp
+@@ -680,7 +680,7 @@ void QNetworkReplyImplPrivate::appendDownstreamData(QIODevice *data)
+     // read until EOF from data
+     if (Q_UNLIKELY(copyDevice)) {
+         qCritical("QNetworkReplyImpl: copy from QIODevice already in progress -- "
+-                  "backend probly needs to be fixed");
++                  "backend probably needs to be fixed");
+         return;
+     }
+ 
+diff --git a/qtbase/src/network/kernel/qauthenticator.cpp b/qtbase/src/network/kernel/qauthenticator.cpp
+index d9fe7bc47b..ccd04b294a 100644
+--- a/qtbase/src/network/kernel/qauthenticator.cpp
++++ b/qtbase/src/network/kernel/qauthenticator.cpp
+@@ -50,6 +50,7 @@
+ #include <qstring.h>
+ #include <qdatetime.h>
+ #include <qrandom.h>
++#include "private/qsystemlibrary_p.h"
+ 
+ #ifdef Q_OS_WIN
+ #include <qmutex.h>
+@@ -1563,7 +1564,7 @@ static bool q_SSPI_library_load()
+ 
+     // Initialize security interface
+     if (pSecurityFunctionTable == nullptr) {
+-        securityDLLHandle = LoadLibrary(L"secur32.dll");
++        securityDLLHandle = QSystemLibrary::load(L"secur32");
+         if (securityDLLHandle != nullptr) {
+             INIT_SECURITY_INTERFACE pInitSecurityInterface =
+                 reinterpret_cast<INIT_SECURITY_INTERFACE>(
+diff --git a/qtbase/src/network/kernel/qhostinfo_unix.cpp b/qtbase/src/network/kernel/qhostinfo_unix.cpp
+index 9b0a2ee669..73679c9ef1 100644
+--- a/qtbase/src/network/kernel/qhostinfo_unix.cpp
++++ b/qtbase/src/network/kernel/qhostinfo_unix.cpp
+@@ -122,7 +122,6 @@ static QFunctionPointer resolveSymbol(QLibrary &lib, const char *sym)
+ 
+ LibResolv::LibResolv()
+ {
+-    QLibrary lib;
+ #ifdef LIBRESOLV_SO
+     lib.setFileName(QStringLiteral(LIBRESOLV_SO));
+     if (!lib.load())
+diff --git a/qtbase/src/network/socket/qsocks5socketengine.cpp b/qtbase/src/network/socket/qsocks5socketengine.cpp
+index 3a046fd116..97fadca0b3 100644
+--- a/qtbase/src/network/socket/qsocks5socketengine.cpp
++++ b/qtbase/src/network/socket/qsocks5socketengine.cpp
+@@ -1296,7 +1296,7 @@ void QSocks5SocketEnginePrivate::_q_udpSocketReadNotification()
+         int pos = 0;
+         const char *buf = inBuf.constData();
+         if (inBuf.size() < 4) {
+-            QSOCKS5_D_DEBUG << "bugus udp data, discarding";
++            QSOCKS5_D_DEBUG << "bogus udp data, discarding";
+             return;
+         }
+         QSocks5RevivedDatagram datagram;
+diff --git a/qtbase/src/network/ssl/qsslcontext_openssl.cpp b/qtbase/src/network/ssl/qsslcontext_openssl.cpp
+index c9f202f573..c992da9d8e 100644
+--- a/qtbase/src/network/ssl/qsslcontext_openssl.cpp
++++ b/qtbase/src/network/ssl/qsslcontext_openssl.cpp
+@@ -409,7 +409,7 @@ init_context:
+         break;
+     case QSsl::DtlsV1_0OrLater:
+         minVersion = DTLS1_VERSION;
+-        maxVersion = DTLS_MAX_VERSION;
++        maxVersion = 0;
+         break;
+     case QSsl::DtlsV1_2:
+         minVersion = DTLS1_2_VERSION;
+@@ -417,7 +417,7 @@ init_context:
+         break;
+     case QSsl::DtlsV1_2OrLater:
+         minVersion = DTLS1_2_VERSION;
+-        maxVersion = DTLS_MAX_VERSION;
++        maxVersion = 0;
+         break;
+     case QSsl::TlsV1_3OrLater:
+ #ifdef TLS1_3_VERSION
+@@ -455,7 +455,7 @@ init_context:
+     }
+ 
+     // Enable bug workarounds.
+-    long options = QSslSocketBackendPrivate::setupOpenSslOptions(configuration.protocol(), configuration.d->sslOptions);
++    qssloptions options = QSslSocketBackendPrivate::setupOpenSslOptions(configuration.protocol(), configuration.d->sslOptions);
+     q_SSL_CTX_set_options(sslContext->ctx, options);
+ 
+     // Tell OpenSSL to release memory early
+diff --git a/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp b/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
+index aaf8741130..b58935372c 100644
+--- a/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
++++ b/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
+@@ -59,57 +59,6 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-#ifdef OPENSSL_NO_DEPRECATED_3_0
+-
+-static int q_DH_check(DH *dh, int *status)
+-{
+-    // DH_check was first deprecated in OpenSSL 3.0.0, as low-level
+-    // API; the EVP_PKEY family of functions was advised as an alternative.
+-    // As of now EVP_PKEY_params_check ends up calling ... DH_check,
+-    // which is good enough.
+-
+-    Q_ASSERT(dh);
+-    Q_ASSERT(status);
+-
+-    EVP_PKEY *key = q_EVP_PKEY_new();
+-    if (!key) {
+-        qCWarning(lcSsl, "EVP_PKEY_new failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-    const auto keyDeleter = qScopeGuard([key](){
+-        q_EVP_PKEY_free(key);
+-    });
+-    if (!q_EVP_PKEY_set1_DH(key, dh)) {
+-        qCWarning(lcSsl, "EVP_PKEY_set1_DH failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-
+-    EVP_PKEY_CTX *keyCtx = q_EVP_PKEY_CTX_new(key, nullptr);
+-    if (!keyCtx) {
+-        qCWarning(lcSsl, "EVP_PKEY_CTX_new failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-    const auto ctxDeleter = qScopeGuard([keyCtx]{
+-        q_EVP_PKEY_CTX_free(keyCtx);
+-    });
+-
+-    const int result = q_EVP_PKEY_param_check(keyCtx);
+-    QSslSocketBackendPrivate::logAndClearErrorQueue();
+-    // Note: unlike DH_check, we cannot obtain the 'status',
+-    // if the 'result' is 0 (actually the result is 1 only
+-    // if this 'status' was 0). We could probably check the
+-    // errors from the error queue, but it's not needed anyway
+-    // - see the 'isSafeDH' below, how it returns immediately
+-    // on 0.
+-    Q_UNUSED(status)
+-
+-    return result;
+-}
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+-
+ static bool isSafeDH(DH *dh)
+ {
+     int status = 0;
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl.cpp b/qtbase/src/network/ssl/qsslsocket_openssl.cpp
+index 37fad2a68f..8f6858c867 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl.cpp
++++ b/qtbase/src/network/ssl/qsslsocket_openssl.cpp
+@@ -550,9 +550,9 @@ static void q_loadCiphersForConnection(SSL *connection, QList<QSslCipher> &ciphe
+ // Defined in qsslsocket.cpp
+ void q_setDefaultDtlsCiphers(const QList<QSslCipher> &ciphers);
+ 
+-long QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions)
++qssloptions QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions)
+ {
+-    long options;
++    qssloptions options;
+     if (protocol == QSsl::TlsV1SslV3)
+         options = SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3;
+     else if (protocol == QSsl::SecureProtocols)
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_p.h b/qtbase/src/network/ssl/qsslsocket_openssl_p.h
+index 4103de23e8..5547589256 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_p.h
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_p.h
+@@ -107,6 +107,12 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++typedef uint64_t qssloptions;
++#else
++typedef unsigned long qssloptions;
++#endif
++
+ struct QSslErrorEntry {
+     int code;
+     int depth;
+@@ -171,7 +177,7 @@ public:
+     QVector<QSslError> ocspErrors;
+     QByteArray ocspResponseDer;
+ 
+-    Q_AUTOTEST_EXPORT static long setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions);
++    Q_AUTOTEST_EXPORT static qssloptions setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions);
+     static QSslCipher QSslCipher_from_SSL_CIPHER(const SSL_CIPHER *cipher);
+     static QList<QSslCertificate> STACKOFX509_to_QSslCertificates(STACK_OF(X509) *x509);
+     static QList<QSslError> verify(const QList<QSslCertificate> &certificateChain, const QString &hostName);
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp b/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
+index e53fb279f0..459ccd0b19 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
+@@ -148,7 +148,6 @@ DEFINEFUNC(int, EVP_PKEY_up_ref, EVP_PKEY *a, a, return 0, return)
+ DEFINEFUNC2(EVP_PKEY_CTX *, EVP_PKEY_CTX_new, EVP_PKEY *pkey, pkey, ENGINE *e, e, return nullptr, return)
+ DEFINEFUNC(int, EVP_PKEY_param_check, EVP_PKEY_CTX *ctx, ctx, return 0, return)
+ DEFINEFUNC(void, EVP_PKEY_CTX_free, EVP_PKEY_CTX *ctx, ctx, return, return)
+-DEFINEFUNC(int, EVP_PKEY_base_id, EVP_PKEY *a, a, return NID_undef, return)
+ DEFINEFUNC(int, RSA_bits, RSA *a, a, return 0, return)
+ DEFINEFUNC(int, DSA_bits, DSA *a, a, return 0, return)
+ DEFINEFUNC(int, OPENSSL_sk_num, OPENSSL_STACK *a, a, return -1, return)
+@@ -158,7 +157,7 @@ DEFINEFUNC2(void, OPENSSL_sk_push, OPENSSL_STACK *a, a, void *b, b, return, DUMM
+ DEFINEFUNC(void, OPENSSL_sk_free, OPENSSL_STACK *a, a, return, DUMMYARG)
+ DEFINEFUNC2(void *, OPENSSL_sk_value, OPENSSL_STACK *a, a, int b, b, return nullptr, return)
+ DEFINEFUNC(int, SSL_session_reused, SSL *a, a, return 0, return)
+-DEFINEFUNC2(unsigned long, SSL_CTX_set_options, SSL_CTX *ctx, ctx, unsigned long op, op, return 0, return)
++DEFINEFUNC2(qssloptions, SSL_CTX_set_options, SSL_CTX *ctx, ctx, qssloptions op, op, return 0, return)
+ DEFINEFUNC(int, SSL_CTX_get_security_level, const SSL_CTX *ctx, ctx, return -1, return)
+ DEFINEFUNC2(void, SSL_CTX_set_security_level, SSL_CTX *ctx, ctx, int level, level, return, return)
+ #ifdef TLS1_3_VERSION
+@@ -371,7 +370,15 @@ DEFINEFUNC(const SSL_CIPHER *, SSL_get_current_cipher, SSL *a, a, return nullptr
+ DEFINEFUNC(int, SSL_version, const SSL *a, a, return 0, return)
+ DEFINEFUNC2(int, SSL_get_error, SSL *a, a, int b, b, return -1, return)
+ DEFINEFUNC(STACK_OF(X509) *, SSL_get_peer_cert_chain, SSL *a, a, return nullptr, return)
++
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++DEFINEFUNC(X509 *, SSL_get1_peer_certificate, SSL *a, a, return nullptr, return)
++DEFINEFUNC(int, EVP_PKEY_get_base_id, const EVP_PKEY *pkey, pkey, return -1, return)
++#else
+ DEFINEFUNC(X509 *, SSL_get_peer_certificate, SSL *a, a, return nullptr, return)
++DEFINEFUNC(int, EVP_PKEY_base_id, EVP_PKEY *a, a, return NID_undef, return)
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+ DEFINEFUNC(long, SSL_get_verify_result, const SSL *a, a, return -1, return)
+ DEFINEFUNC(SSL *, SSL_new, SSL_CTX *a, a, return nullptr, return)
+ DEFINEFUNC(SSL_CTX *, SSL_get_SSL_CTX, SSL *a, a, return nullptr, return)
+@@ -492,9 +499,7 @@ DEFINEFUNC(DH *, DH_new, DUMMYARG, DUMMYARG, return nullptr, return)
+ DEFINEFUNC(void, DH_free, DH *dh, dh, return, DUMMYARG)
+ DEFINEFUNC3(DH *, d2i_DHparams, DH**a, a, const unsigned char **pp, pp, long length, length, return nullptr, return)
+ DEFINEFUNC2(int, i2d_DHparams, DH *a, a, unsigned char **p, p, return -1, return)
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+ DEFINEFUNC2(int, DH_check, DH *dh, dh, int *codes, codes, return 0, return)
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+ DEFINEFUNC3(BIGNUM *, BN_bin2bn, const unsigned char *s, s, int len, len, BIGNUM *ret, ret, return nullptr, return)
+ 
+ #ifndef OPENSSL_NO_EC
+@@ -868,7 +873,6 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(EVP_PKEY_CTX_new)
+     RESOLVEFUNC(EVP_PKEY_param_check)
+     RESOLVEFUNC(EVP_PKEY_CTX_free)
+-    RESOLVEFUNC(EVP_PKEY_base_id)
+     RESOLVEFUNC(RSA_bits)
+     RESOLVEFUNC(OPENSSL_sk_new_null)
+     RESOLVEFUNC(OPENSSL_sk_push)
+@@ -1107,7 +1111,15 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(SSL_version)
+     RESOLVEFUNC(SSL_get_error)
+     RESOLVEFUNC(SSL_get_peer_cert_chain)
++
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++    RESOLVEFUNC(SSL_get1_peer_certificate)
++    RESOLVEFUNC(EVP_PKEY_get_base_id)
++#else
+     RESOLVEFUNC(SSL_get_peer_certificate)
++    RESOLVEFUNC(EVP_PKEY_base_id)
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+     RESOLVEFUNC(SSL_get_verify_result)
+     RESOLVEFUNC(SSL_new)
+     RESOLVEFUNC(SSL_get_SSL_CTX)
+@@ -1206,9 +1218,7 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(DH_free)
+     RESOLVEFUNC(d2i_DHparams)
+     RESOLVEFUNC(i2d_DHparams)
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+     RESOLVEFUNC(DH_check)
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+     RESOLVEFUNC(BN_bin2bn)
+ 
+ #ifndef OPENSSL_NO_EC
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h b/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
+index 95e8897a3b..27aeffa18a 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
+@@ -237,7 +237,6 @@ Q_AUTOTEST_EXPORT int q_EVP_PKEY_up_ref(EVP_PKEY *a);
+ EVP_PKEY_CTX *q_EVP_PKEY_CTX_new(EVP_PKEY *pkey, ENGINE *e);
+ void q_EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx);
+ int q_EVP_PKEY_param_check(EVP_PKEY_CTX *ctx);
+-int q_EVP_PKEY_base_id(EVP_PKEY *a);
+ int q_RSA_bits(RSA *a);
+ Q_AUTOTEST_EXPORT int q_OPENSSL_sk_num(OPENSSL_STACK *a);
+ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_pop_free(OPENSSL_STACK *a, void (*b)(void *));
+@@ -246,7 +245,7 @@ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_push(OPENSSL_STACK *st, void *data);
+ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_free(OPENSSL_STACK *a);
+ Q_AUTOTEST_EXPORT void * q_OPENSSL_sk_value(OPENSSL_STACK *a, int b);
+ int q_SSL_session_reused(SSL *a);
+-unsigned long q_SSL_CTX_set_options(SSL_CTX *ctx, unsigned long op);
++qssloptions q_SSL_CTX_set_options(SSL_CTX *ctx, qssloptions op);
+ int q_OPENSSL_init_ssl(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings);
+ size_t q_SSL_get_client_random(SSL *a, unsigned char *out, size_t outlen);
+ size_t q_SSL_SESSION_get_master_key(const SSL_SESSION *session, unsigned char *out, size_t outlen);
+@@ -510,7 +509,6 @@ const SSL_CIPHER *q_SSL_get_current_cipher(SSL *a);
+ int q_SSL_version(const SSL *a);
+ int q_SSL_get_error(SSL *a, int b);
+ STACK_OF(X509) *q_SSL_get_peer_cert_chain(SSL *a);
+-X509 *q_SSL_get_peer_certificate(SSL *a);
+ long q_SSL_get_verify_result(const SSL *a);
+ SSL *q_SSL_new(SSL_CTX *a);
+ SSL_CTX *q_SSL_get_SSL_CTX(SSL *a);
+@@ -582,10 +580,7 @@ DH *q_DH_new();
+ void q_DH_free(DH *dh);
+ DH *q_d2i_DHparams(DH **a, const unsigned char **pp, long length);
+ int q_i2d_DHparams(DH *a, unsigned char **p);
+-
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+ int q_DH_check(DH *dh, int *codes);
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+ 
+ BIGNUM *q_BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret);
+ #define q_SSL_CTX_set_tmp_dh(ctx, dh) q_SSL_CTX_ctrl((ctx), SSL_CTRL_SET_TMP_DH, 0, (char *)dh)
+@@ -754,6 +749,17 @@ void q_CRYPTO_free(void *str, const char *file, int line);
+ int q_SSL_CTX_get_security_level(const SSL_CTX *ctx);
+ void q_SSL_CTX_set_security_level(SSL_CTX *ctx, int level);
+ 
++// Here we have the ones that make difference between OpenSSL pre/post v3:
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++X509 *q_SSL_get1_peer_certificate(SSL *a);
++#define q_SSL_get_peer_certificate q_SSL_get1_peer_certificate
++int q_EVP_PKEY_get_base_id(const EVP_PKEY *pkey);
++#define q_EVP_PKEY_base_id q_EVP_PKEY_get_base_id
++#else
++X509 *q_SSL_get_peer_certificate(SSL *a);
++int q_EVP_PKEY_base_id(EVP_PKEY *a);
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+ QT_END_NAMESPACE
+ 
+ #endif
+diff --git a/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h b/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
+index bf37d07fd8..dbd42fb799 100644
+--- a/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
++++ b/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
+@@ -61,7 +61,11 @@
+ # if !defined(Q_OS_INTEGRITY)
+ #  define WIN_INTERFACE_CUSTOM   // NV
+ # endif // Q_OS_INTEGRITY
+-#endif  // QT_EGL_NO_X11
++#else // QT_EGL_NO_X11
++// If one has an eglplatform.h with https://github.com/KhronosGroup/EGL-Registry/pull/130
++// that needs USE_X11 to be defined.
++# define USE_X11
++#endif
+ 
+ #ifdef QT_EGL_WAYLAND
+ # define WAYLAND // NV
+diff --git a/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+index 159b490ce0..00aa80cd58 100644
+--- a/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
++++ b/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+@@ -567,6 +567,8 @@ void QFontconfigDatabase::populateFontDatabase()
+         fonts = FcFontList(nullptr, pattern, os);
+         FcObjectSetDestroy(os);
+         FcPatternDestroy(pattern);
++        if (!fonts)
++            return;
+     }
+ 
+     for (int i = 0; i < fonts->nfont; i++)
+diff --git a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
+index b713c19447..7cb9a8c79a 100644
+--- a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
++++ b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
+@@ -95,6 +95,7 @@ static constexpr const auto KeyTbl = qMakeArray(
+         Xkb2Qt<XKB_KEY_Clear,                   Qt::Key_Delete>,
+         Xkb2Qt<XKB_KEY_Pause,                   Qt::Key_Pause>,
+         Xkb2Qt<XKB_KEY_Print,                   Qt::Key_Print>,
++        Xkb2Qt<XKB_KEY_Sys_Req,                 Qt::Key_SysReq>,
+         Xkb2Qt<0x1005FF60,                      Qt::Key_SysReq>,         // hardcoded Sun SysReq
+         Xkb2Qt<0x1007ff00,                      Qt::Key_SysReq>,         // hardcoded X386 SysReq
+ 
+@@ -471,7 +472,7 @@ QVector<xkb_keysym_t> QXkbCommon::toKeysym(QKeyEvent *event)
+     } else if (event->modifiers() & Qt::KeypadModifier) {
+         if (qtKey >= Qt::Key_0 && qtKey <= Qt::Key_9)
+             keysyms.append(XKB_KEY_KP_0 + (qtKey - Qt::Key_0));
+-    } else if (isLatin(qtKey) && event->text().isUpper()) {
++    } else if (isLatin1(qtKey) && event->text().isUpper()) {
+         keysyms.append(qtKey);
+     }
+ 
+@@ -523,7 +524,7 @@ int QXkbCommon::keysymToQtKey(xkb_keysym_t keysym, Qt::KeyboardModifiers modifie
+         // With standard shortcuts we should prefer a latin character, this is
+         // for checks like "some qkeyevent == QKeySequence::Copy" to work even
+         // when using for example 'russian' keyboard layout.
+-        if (!QXkbCommon::isLatin(keysym)) {
++        if (!QXkbCommon::isLatin1(keysym)) {
+             xkb_keysym_t latinKeysym = QXkbCommon::lookupLatinKeysym(state, code);
+             if (latinKeysym != XKB_KEY_NoSymbol)
+                 keysym = latinKeysym;
+@@ -546,7 +547,7 @@ static int keysymToQtKey_internal(xkb_keysym_t keysym, Qt::KeyboardModifiers mod
+     } else if (keysym >= XKB_KEY_KP_0 && keysym <= XKB_KEY_KP_9) {
+         // numeric keypad keys
+         qtKey = Qt::Key_0 + (keysym - XKB_KEY_KP_0);
+-    } else if (QXkbCommon::isLatin(keysym)) {
++    } else if (QXkbCommon::isLatin1(keysym)) {
+         qtKey = QXkbCommon::qxkbcommon_xkb_keysym_to_upper(keysym);
+     } else {
+         // check if we have a direct mapping
+@@ -678,7 +679,7 @@ QList<int> QXkbCommon::possibleKeys(xkb_state *state, const QKeyEvent *event,
+         Qt::KeyboardModifiers neededMods = ModsTbl[i];
+         if ((modifiers & neededMods) == neededMods) {
+             if (i == 8) {
+-                if (isLatin(baseQtKey))
++                if (isLatin1(baseQtKey))
+                     continue;
+                 // add a latin key as a fall back key
+                 sym = lookupLatinKeysym(state, keycode);
+@@ -733,7 +734,7 @@ void QXkbCommon::verifyHasLatinLayout(xkb_keymap *keymap)
+     for (xkb_layout_index_t layout = 0; layout < layoutCount; ++layout) {
+         for (xkb_keycode_t code = minKeycode; code < maxKeycode; ++code) {
+             xkb_keymap_key_get_syms_by_level(keymap, code, layout, 0, &keysyms);
+-            if (keysyms && isLatin(keysyms[0]))
++            if (keysyms && isLatin1(keysyms[0]))
+                 nrLatinKeys++;
+             if (nrLatinKeys > 10) // arbitrarily chosen threshold
+                 return;
+@@ -766,7 +767,7 @@ xkb_keysym_t QXkbCommon::lookupLatinKeysym(xkb_state *state, xkb_keycode_t keyco
+         xkb_level_index_t level = xkb_state_key_get_level(state, keycode, layout);
+         if (xkb_keymap_key_get_syms_by_level(keymap, keycode, layout, level, &syms) != 1)
+             continue;
+-        if (isLatin(syms[0])) {
++        if (isLatin1(syms[0])) {
+             sym = syms[0];
+             break;
+         }
+diff --git a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
+index 561eae03db..8389bd8f5a 100644
+--- a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
++++ b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
+@@ -94,8 +94,8 @@ public:
+     static void verifyHasLatinLayout(xkb_keymap *keymap);
+     static xkb_keysym_t lookupLatinKeysym(xkb_state *state, xkb_keycode_t keycode);
+ 
+-    static bool isLatin(xkb_keysym_t sym) {
+-        return ((sym >= 'a' && sym <= 'z') || (sym >= 'A' && sym <= 'Z'));
++    static bool isLatin1(xkb_keysym_t sym) {
++        return sym <= 0xff;
+     }
+     static bool isKeypad(xkb_keysym_t sym) {
+         return sym >= XKB_KEY_KP_Space && sym <= XKB_KEY_KP_9;
+diff --git a/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp b/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
+index 8cd7f9b368..406f84663f 100644
+--- a/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
++++ b/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
+@@ -318,7 +318,7 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources,
+ 
+     if (current < 0 && crtc_mode.clock != 0) {
+         modes << crtc_mode;
+-        current = mode.size() - 1;
++        current = modes.size() - 1;
+     }
+ 
+     if (configuration == OutputConfigCurrent)
+diff --git a/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp b/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
+index 9153fd20bb..255ea5e33e 100644
+--- a/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
++++ b/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
+@@ -194,6 +194,9 @@ QString AtSpiAdaptor::introspect(const QString &path) const
+                 "      <arg direction=\"out\" type=\"(so)\"/>\n"
+                 "      <annotation value=\"QSpiObjectReference\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n"
+                 "    </method>\n"
++                "    <method name=\"GetAccessibleId\">\n"
++                "      <arg direction=\"out\" type=\"s\"/>\n"
++                "    </method>\n"
+                 "  </interface>\n"
+                 );
+ 
+@@ -913,8 +916,17 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+     }
+     case QAccessible::NameChanged: {
+         if (sendObject || sendObject_property_change || sendObject_property_change_accessible_name) {
+-            QString path = pathForInterface(event->accessibleInterface());
+-            QVariantList args = packDBusSignalArguments(QLatin1String("accessible-name"), 0, 0, variantForPath(path));
++            QAccessibleInterface *iface = event->accessibleInterface();
++            if (!iface) {
++                qCDebug(lcAccessibilityAtspi,
++                        "NameChanged event from invalid accessible.");
++                return;
++            }
++
++            QString path = pathForInterface(iface);
++            QVariantList args = packDBusSignalArguments(
++                QLatin1String("accessible-name"), 0, 0,
++                QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Name))));
+             sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                            QLatin1String("PropertyChange"), args);
+         }
+@@ -922,8 +934,17 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+     }
+     case QAccessible::DescriptionChanged: {
+         if (sendObject || sendObject_property_change || sendObject_property_change_accessible_description) {
+-            QString path = pathForInterface(event->accessibleInterface());
+-            QVariantList args = packDBusSignalArguments(QLatin1String("accessible-description"), 0, 0, variantForPath(path));
++            QAccessibleInterface *iface = event->accessibleInterface();
++            if (!iface) {
++                qCDebug(lcAccessibilityAtspi,
++                        "DescriptionChanged event from invalid accessible.");
++                return;
++            }
++
++            QString path = pathForInterface(iface);
++            QVariantList args = packDBusSignalArguments(
++                QLatin1String("accessible-description"), 0, 0,
++                QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Description))));
+             sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                            QLatin1String("PropertyChange"), args);
+         }
+@@ -1038,7 +1059,9 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+                 // Combo Box with AT-SPI likes to be special
+                 // It requires a name-change to update caches and then selection-changed
+                 QString path = pathForInterface(iface);
+-                QVariantList args1 = packDBusSignalArguments(QLatin1String("accessible-name"), 0, 0, variantForPath(path));
++                QVariantList args1 = packDBusSignalArguments(
++                    QLatin1String("accessible-name"), 0, 0,
++                    QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Name))));
+                 sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                                QLatin1String("PropertyChange"), args1);
+                 QVariantList args2 = packDBusSignalArguments(QString(), 0, 0, QVariant::fromValue(QDBusVariant(QVariant(0))));
+@@ -1358,6 +1381,26 @@ void AtSpiAdaptor::registerApplication()
+     delete registry;
+ }
+ 
++namespace {
++QString accessibleIdForAccessible(QAccessibleInterface *accessible)
++{
++    QString result;
++    while (accessible) {
++        if (!result.isEmpty())
++            result.prepend(QLatin1Char('.'));
++        if (auto obj = accessible->object()) {
++            const QString name = obj->objectName();
++            if (!name.isEmpty())
++                result.prepend(name);
++            else
++                result.prepend(QString::fromUtf8(obj->metaObject()->className()));
++        }
++        accessible = accessible->parent();
++    }
++    return result;
++}
++} // namespace
++
+ // Accessible
+ bool AtSpiAdaptor::accessibleInterface(QAccessibleInterface *interface, const QString &function, const QDBusMessage &message, const QDBusConnection &connection)
+ {
+@@ -1441,6 +1484,9 @@ bool AtSpiAdaptor::accessibleInterface(QAccessibleInterface *interface, const QS
+             children << ref;
+         }
+         connection.send(message.createReply(QVariant::fromValue(children)));
++    } else if (function == QLatin1String("GetAccessibleId")) {
++        sendReply(connection, message,
++                  QVariant::fromValue(QDBusVariant(accessibleIdForAccessible(interface))));
+     } else {
+         qCDebug(lcAccessibilityAtspi) << "WARNING: AtSpiAdaptor::accessibleInterface does not implement " << function << message.path();
+         return false;
+diff --git a/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp b/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
+index 45ddc8e496..cc734abc63 100644
+--- a/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
++++ b/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
+@@ -69,6 +69,21 @@ QT_BEGIN_NAMESPACE
+ DBusConnection::DBusConnection(QObject *parent)
+     : QObject(parent), m_a11yConnection(QString()), m_enabled(false)
+ {
++    // If the bus is explicitly set via env var it overrides everything else.
++    QByteArray addressEnv = qgetenv("AT_SPI_BUS_ADDRESS");
++    if (!addressEnv.isEmpty()) {
++        // Only connect on next loop run, connections to our enabled signal are
++        // only established after the ctor returns.
++        QMetaObject::invokeMethod(
++                this,
++                [this, addressEnv] {
++                    m_enabled = true;
++                    connectA11yBus(QString::fromLocal8Bit(addressEnv));
++                },
++                Qt::QueuedConnection);
++        return;
++    }
++
+     // Start monitoring if "org.a11y.Bus" is registered as DBus service.
+     QDBusConnection c = QDBusConnection::sessionBus();
+     if (!c.isConnected()) {
+diff --git a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
+index 1a3cab275d..2abe039126 100644
+--- a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
++++ b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
+@@ -51,6 +51,9 @@
+ #include <QtCore/QStandardPaths>
+ #include <QtCore/QUrl>
+ 
++#include <QtGui/QGuiApplication>
++#include <QtGui/QWindow>
++
+ #if QT_CONFIG(dbus)
+ // These QtCore includes are needed for xdg-desktop-portal support
+ #include <QtCore/private/qcore_unix_p.h>
+@@ -58,6 +61,8 @@
+ #include <QtCore/QFileInfo>
+ #include <QtCore/QUrlQuery>
+ 
++#include <QtGui/QColor>
++
+ #include <QtDBus/QDBusConnection>
+ #include <QtDBus/QDBusMessage>
+ #include <QtDBus/QDBusPendingCall>
+@@ -142,6 +147,8 @@ static inline bool detectWebBrowser(const QByteArray &desktop,
+     }
+ 
+     if (desktop == QByteArray("KDE")) {
++        if (checkExecutable(QStringLiteral("kde-open5"), browser))
++            return true;
+         // Konqueror launcher
+         if (checkExecutable(QStringLiteral("kfmclient"), browser)) {
+             browser->append(QLatin1String(" exec"));
+@@ -296,8 +303,135 @@ static inline QDBusMessage xdgDesktopPortalSendEmail(const QUrl &url)
+ 
+     return QDBusConnection::sessionBus().call(message);
+ }
++
++namespace {
++struct XDGDesktopColor
++{
++    double r = 0;
++    double g = 0;
++    double b = 0;
++
++    QColor toQColor() const
++    {
++        constexpr auto rgbMax = 255;
++        return { static_cast<int>(r * rgbMax), static_cast<int>(g * rgbMax),
++                 static_cast<int>(b * rgbMax) };
++    }
++};
++
++const QDBusArgument &operator>>(const QDBusArgument &argument, XDGDesktopColor &myStruct)
++{
++    argument.beginStructure();
++    argument >> myStruct.r >> myStruct.g >> myStruct.b;
++    argument.endStructure();
++    return argument;
++}
++
++class XdgDesktopPortalColorPicker : public QPlatformServiceColorPicker
++{
++    Q_OBJECT
++public:
++    XdgDesktopPortalColorPicker(const QString &parentWindowId, QWindow *parent)
++        : QPlatformServiceColorPicker(parent), m_parentWindowId(parentWindowId)
++    {
++    }
++
++    void pickColor() override
++    {
++        // DBus signature:
++        // PickColor (IN   s      parent_window,
++        //            IN   a{sv}  options
++        //            OUT  o      handle)
++        // Options:
++        // handle_token (s) -  A string that will be used as the last element of the @handle.
++
++        QDBusMessage message = QDBusMessage::createMethodCall(
++                QStringLiteral("org.freedesktop.portal.Desktop"), QStringLiteral("/org/freedesktop/portal/desktop"),
++                QStringLiteral("org.freedesktop.portal.Screenshot"), QStringLiteral("PickColor"));
++        message << m_parentWindowId << QVariantMap();
++
++        QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
++        auto watcher = new QDBusPendingCallWatcher(pendingCall, this);
++        connect(watcher, &QDBusPendingCallWatcher::finished, this,
++                [this](QDBusPendingCallWatcher *watcher) {
++                    watcher->deleteLater();
++                    QDBusPendingReply<QDBusObjectPath> reply = *watcher;
++                    if (reply.isError()) {
++                        qWarning("DBus call to pick color failed: %s",
++                                 qPrintable(reply.error().message()));
++                        Q_EMIT colorPicked({});
++                    } else {
++                        QDBusConnection::sessionBus().connect(
++                                QStringLiteral("org.freedesktop.portal.Desktop"), reply.value().path(),
++                                QStringLiteral("org.freedesktop.portal.Request"), QStringLiteral("Response"), this,
++                                // clang-format off
++                                SLOT(gotColorResponse(uint,QVariantMap))
++                                // clang-format on
++                        );
++                    }
++                });
++    }
++
++private Q_SLOTS:
++    void gotColorResponse(uint result, const QVariantMap &map)
++    {
++        if (result != 0)
++            return;
++        XDGDesktopColor color{};
++        map.value(QStringLiteral("color")).value<QDBusArgument>() >> color;
++        Q_EMIT colorPicked(color.toQColor());
++        deleteLater();
++    }
++
++private:
++    const QString m_parentWindowId;
++};
++} // namespace
++
+ #endif // QT_CONFIG(dbus)
+ 
++QGenericUnixServices::QGenericUnixServices()
++{
++#if QT_CONFIG(dbus)
++    if (qEnvironmentVariableIntValue("QT_NO_XDG_DESKTOP_PORTAL") > 0) {
++        return;
++    }
++    QDBusMessage message = QDBusMessage::createMethodCall(
++            QStringLiteral("org.freedesktop.portal.Desktop"), QStringLiteral("/org/freedesktop/portal/desktop"),
++            QStringLiteral("org.freedesktop.DBus.Properties"), QStringLiteral("Get"));
++    message << QStringLiteral("org.freedesktop.portal.Screenshot")
++            << QStringLiteral("version");
++
++    QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
++    auto watcher = new QDBusPendingCallWatcher(pendingCall);
++    QObject::connect(watcher, &QDBusPendingCallWatcher::finished, watcher,
++                     [this](QDBusPendingCallWatcher *watcher) {
++                         watcher->deleteLater();
++                         QDBusPendingReply<QVariant> reply = *watcher;
++                         if (!reply.isError() && reply.value().toUInt() >= 2)
++                             m_hasScreenshotPortalWithColorPicking = true;
++                     });
++
++#endif
++}
++
++QPlatformServiceColorPicker *QGenericUnixServices::colorPicker(QWindow *parent)
++{
++#if QT_CONFIG(dbus)
++    // Make double sure that we are in a wayland environment. In particular check
++    // WAYLAND_DISPLAY so also XWayland apps benefit from portal-based color picking.
++    // Outside wayland we'll rather rely on other means than the XDG desktop portal.
++    if (!qEnvironmentVariableIsEmpty("WAYLAND_DISPLAY")
++        || QGuiApplication::platformName().startsWith(QLatin1String("wayland"))) {
++        return new XdgDesktopPortalColorPicker(portalWindowIdentifier(parent), parent);
++    }
++    return nullptr;
++#else
++    Q_UNUSED(parent);
++    return nullptr;
++#endif
++}
++
+ QByteArray QGenericUnixServices::desktopEnvironment() const
+ {
+     static const QByteArray result = detectDesktopEnvironment();
+@@ -352,6 +486,8 @@ bool QGenericUnixServices::openDocument(const QUrl &url)
+ }
+ 
+ #else
++QGenericUnixServices::QGenericUnixServices() = default;
++
+ QByteArray QGenericUnixServices::desktopEnvironment() const
+ {
+     return QByteArrayLiteral("UNKNOWN");
+@@ -371,6 +507,30 @@ bool QGenericUnixServices::openDocument(const QUrl &url)
+     return false;
+ }
+ 
++QPlatformServiceColorPicker *QGenericUnixServices::colorPicker(QWindow *parent)
++{
++    Q_UNUSED(parent);
++    return nullptr;
++}
++
+ #endif // QT_NO_MULTIPROCESS
+ 
++QString QGenericUnixServices::portalWindowIdentifier(QWindow *window)
++{
++    if (QGuiApplication::platformName() == QLatin1String("xcb"))
++        return QStringLiteral("x11:") + QString::number(window->winId(), 16);
++    return QString();
++}
++
++bool QGenericUnixServices::hasCapability(Capability capability) const
++{
++    switch (capability) {
++    case Capability::ColorPicking:
++        return m_hasScreenshotPortalWithColorPicking;
++    }
++    return false;
++}
++
+ QT_END_NAMESPACE
++
++#include "qgenericunixservices.moc"
+diff --git a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
+index 8ac3de6f03..30924e64bd 100644
+--- a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
++++ b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
+@@ -59,16 +59,21 @@ QT_BEGIN_NAMESPACE
+ class QGenericUnixServices : public QPlatformServices
+ {
+ public:
+-    QGenericUnixServices() {}
++    QGenericUnixServices();
+ 
+     QByteArray desktopEnvironment() const override;
+ 
++    bool hasCapability(Capability capability) const override;
+     bool openUrl(const QUrl &url) override;
+     bool openDocument(const QUrl &url) override;
++    QPlatformServiceColorPicker *colorPicker(QWindow *parent = nullptr) override;
++
++    virtual QString portalWindowIdentifier(QWindow *window);
+ 
+ private:
+     QString m_webBrowser;
+     QString m_documentLauncher;
++    bool m_hasScreenshotPortalWithColorPicking = false;
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
+index 09470bccc6..cc7c7d4d8a 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
+@@ -69,6 +69,7 @@ const QString MenuBarPath = QLatin1String("/MenuBar");
+ */
+ QDBusMenuConnection::QDBusMenuConnection(QObject *parent, const QString &serviceName)
+     : QObject(parent)
++    , m_serviceName(serviceName)
+     , m_connection(serviceName.isNull() ? QDBusConnection::sessionBus()
+                                         : QDBusConnection::connectToBus(QDBusConnection::SessionBus, serviceName))
+     , m_dbusWatcher(new QDBusServiceWatcher(StatusNotifierWatcherService, m_connection, QDBusServiceWatcher::WatchForRegistration, this))
+@@ -83,6 +84,12 @@ QDBusMenuConnection::QDBusMenuConnection(QObject *parent, const QString &service
+ #endif
+ }
+ 
++QDBusMenuConnection::~QDBusMenuConnection()
++{
++  if (!m_serviceName.isEmpty() && m_connection.isConnected())
++      QDBusConnection::disconnectFromBus(m_serviceName);
++}
++
+ void QDBusMenuConnection::dbusError(const QDBusError &error)
+ {
+     qWarning() << "QDBusTrayIcon encountered a D-Bus error:" << error;
+@@ -105,13 +112,7 @@ void QDBusMenuConnection::unregisterTrayIconMenu(QDBusTrayIcon *item)
+ 
+ bool QDBusMenuConnection::registerTrayIcon(QDBusTrayIcon *item)
+ {
+-    bool success = connection().registerService(item->instanceId());
+-    if (!success) {
+-        qWarning() << "failed to register service" << item->instanceId();
+-        return false;
+-    }
+-
+-    success = connection().registerObject(StatusNotifierItemPath, item);
++    bool success = connection().registerObject(StatusNotifierItemPath, item);
+     if (!success) {
+         unregisterTrayIcon(item);
+         qWarning() << "failed to register" << item->instanceId() << StatusNotifierItemPath;
+@@ -126,21 +127,18 @@ bool QDBusMenuConnection::registerTrayIcon(QDBusTrayIcon *item)
+ 
+ bool QDBusMenuConnection::registerTrayIconWithWatcher(QDBusTrayIcon *item)
+ {
++    Q_UNUSED(item);
+     QDBusMessage registerMethod = QDBusMessage::createMethodCall(
+                 StatusNotifierWatcherService, StatusNotifierWatcherPath, StatusNotifierWatcherService,
+                 QLatin1String("RegisterStatusNotifierItem"));
+-    registerMethod.setArguments(QVariantList() << item->instanceId());
++    registerMethod.setArguments(QVariantList() << m_connection.baseService());
+     return m_connection.callWithCallback(registerMethod, this, SIGNAL(trayIconRegistered()), SLOT(dbusError(QDBusError)));
+ }
+ 
+-bool QDBusMenuConnection::unregisterTrayIcon(QDBusTrayIcon *item)
++void QDBusMenuConnection::unregisterTrayIcon(QDBusTrayIcon *item)
+ {
+     unregisterTrayIconMenu(item);
+     connection().unregisterObject(StatusNotifierItemPath);
+-    bool success = connection().unregisterService(item->instanceId());
+-    if (!success)
+-        qWarning() << "failed to unregister service" << item->instanceId();
+-    return success;
+ }
+ #endif // QT_NO_SYSTEMTRAYICON
+ 
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
+index f484795fbb..97bdfabb85 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
++++ b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
+@@ -70,6 +70,7 @@ class QDBusMenuConnection : public QObject
+ 
+ public:
+     QDBusMenuConnection(QObject *parent = nullptr, const QString &serviceName = QString());
++    ~QDBusMenuConnection();
+     QDBusConnection connection() const { return m_connection; }
+     QDBusServiceWatcher *dbusWatcher() const { return m_dbusWatcher; }
+     bool isStatusNotifierHostRegistered() const { return m_statusNotifierHostRegistered; }
+@@ -78,7 +79,7 @@ public:
+     void unregisterTrayIconMenu(QDBusTrayIcon *item);
+     bool registerTrayIcon(QDBusTrayIcon *item);
+     bool registerTrayIconWithWatcher(QDBusTrayIcon *item);
+-    bool unregisterTrayIcon(QDBusTrayIcon *item);
++    void unregisterTrayIcon(QDBusTrayIcon *item);
+ #endif // QT_NO_SYSTEMTRAYICON
+ 
+ Q_SIGNALS:
+@@ -90,6 +91,7 @@ private Q_SLOTS:
+     void dbusError(const QDBusError &error);
+ 
+ private:
++    QString m_serviceName;
+     QDBusConnection m_connection;
+     QDBusServiceWatcher *m_dbusWatcher;
+     bool m_statusNotifierHostRegistered;
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp b/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
+index bede70975a..76bfec5e5a 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
+@@ -71,8 +71,12 @@ Q_LOGGING_CATEGORY(qLcTray, "qt.qpa.tray")
+ static QString iconTempPath()
+ {
+     QString tempPath = QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation);
+-    if (!tempPath.isEmpty())
++    if (!tempPath.isEmpty()) {
++        QString flatpakId = qEnvironmentVariable("FLATPAK_ID");
++        if (!flatpakId.isEmpty() && QFileInfo::exists(QLatin1String("/.flatpak-info")))
++            tempPath += QLatin1String("/app/") + flatpakId;
+         return tempPath;
++    }
+ 
+     tempPath = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation);
+ 
+diff --git a/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+index cb1b39db64..6e01af052c 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+@@ -755,6 +755,9 @@ QVariant QGnomeTheme::themeHint(QPlatformTheme::ThemeHint hint) const
+         return QVariant(QChar(0x2022));
+     case QPlatformTheme::UiEffects:
+         return QVariant(int(HoverEffect));
++    case QPlatformTheme::ButtonPressKeys:
++        return QVariant::fromValue(
++                QList<Qt::Key>({ Qt::Key_Space, Qt::Key_Return, Qt::Key_Enter, Qt::Key_Select }));
+     default:
+         break;
+     }
+diff --git a/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp b/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
+index 98e05195ee..1e92f43dec 100644
+--- a/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
++++ b/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
+@@ -343,8 +343,7 @@ void QEglFSCursor::paintOnScreen()
+     // screens are siblings of each other. When not enabled, the sibling list
+     // only contains m_screen itself.
+     for (QPlatformScreen *screen : m_screen->virtualSiblings()) {
+-        if (screen->geometry().contains(cr.topLeft().toPoint() + m_cursor.hotSpot)
+-            && QOpenGLContext::currentContext()->screen() == screen->screen())
++        if (screen->geometry().contains(cr.topLeft().toPoint() + m_cursor.hotSpot))
+         {
+             cr.translate(-screen->geometry().topLeft());
+             const QSize screenSize = screen->geometry().size();
+@@ -468,11 +467,12 @@ void QEglFSCursor::draw(const QRectF &r)
+ {
+     StateSaver stateSaver;
+ 
+-    QEglFSCursorData &gfx = static_cast<QEglFSContext*>(QOpenGLContext::currentContext()->handle())->cursorData;
+-    if (!gfx.program) {
+-        // one time initialization
++    // one time initialization
++    if (!QOpenGLFunctions::d_ptr)
+         initializeOpenGLFunctions();
+ 
++    QEglFSCursorData &gfx = static_cast<QEglFSContext*>(QOpenGLContext::currentContext()->handle())->cursorData;
++    if (!gfx.program) {
+         createShaderPrograms();
+ 
+         if (!gfx.atlasTexture) {
+diff --git a/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp b/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
+index 645a0ae2e9..3e0e406f1a 100644
+--- a/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
++++ b/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
+@@ -179,7 +179,7 @@ void QEglFSKmsEventReader::create(QEglFSKmsDevice *device)
+ 
+     m_device = device;
+ 
+-    qCDebug(qLcEglfsKmsDebug, "Initalizing event reader for device %p fd %d",
++    qCDebug(qLcEglfsKmsDebug, "Initializing event reader for device %p fd %d",
+             m_device, m_device->fd());
+ 
+     m_thread = new QEglFSKmsEventReaderThread(m_device->fd());
+diff --git a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
+index 141fb68a23..d4294d425a 100644
+--- a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
++++ b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
+@@ -122,11 +122,13 @@ QOffscreenIntegration::QOffscreenIntegration()
+ #endif
+     m_services.reset(new QPlatformServices);
+ 
+-    QWindowSystemInterface::handleScreenAdded(new QOffscreenScreen);
++    m_screen = new QOffscreenScreen;
++    QWindowSystemInterface::handleScreenAdded(m_screen);
+ }
+ 
+ QOffscreenIntegration::~QOffscreenIntegration()
+ {
++    QWindowSystemInterface::handleScreenRemoved(m_screen);
+ }
+ 
+ void QOffscreenIntegration::initialize()
+diff --git a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
+index 0ea90f6c2f..fe00fde07c 100644
+--- a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
++++ b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
+@@ -84,6 +84,7 @@ protected:
+ #endif
+     QScopedPointer<QPlatformInputContext> m_inputContext;
+     QScopedPointer<QPlatformServices> m_services;
++    QPlatformScreen *m_screen;
+     mutable QScopedPointer<QPlatformNativeInterface> m_nativeInterface;
+ };
+ 
+diff --git a/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp b/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
+index 6fa5a8a2b3..1f49f0aefd 100644
+--- a/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
++++ b/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
+@@ -48,6 +48,7 @@
+ #include <qpa/qplatformnativeinterface.h>
+ #include <QtPlatformHeaders/qwglnativecontext.h>
+ 
++#include <private/qsystemlibrary_p.h>
+ #include <algorithm>
+ 
+ #include <wingdi.h>
+@@ -162,19 +163,25 @@ QFunctionPointer QWindowsOpengl32DLL::resolve(const char *name)
+ 
+ bool QWindowsOpengl32DLL::init(bool softwareRendering)
+ {
+-    const QByteArray opengl32 = QByteArrayLiteral("opengl32.dll");
+-    const QByteArray swopengl = QByteArrayLiteral("opengl32sw.dll");
++    const QByteArray opengl32 = QByteArrayLiteral("opengl32");
++    const QByteArray swopengl = QByteArrayLiteral("opengl32sw");
++    bool useSystemLib = false;
+ 
+     QByteArray openglDll = qgetenv("QT_OPENGL_DLL");
+-    if (openglDll.isEmpty())
++    if (openglDll.isEmpty()) {
+         openglDll = softwareRendering ? swopengl : opengl32;
++        useSystemLib = !softwareRendering;
++    }
+ 
+     openglDll = openglDll.toLower();
+     m_nonOpengl32 = openglDll != opengl32;
+ 
+     qCDebug(lcQpaGl) << "Qt: Using WGL and OpenGL from" << openglDll;
+ 
+-    m_lib = ::LoadLibraryA(openglDll.constData());
++    if (useSystemLib)
++        m_lib = QSystemLibrary::load((wchar_t*)(QString::fromLatin1(openglDll).utf16()));
++    else
++        m_lib = LoadLibraryA(openglDll.constData());
+     if (!m_lib) {
+         qErrnoWarning(::GetLastError(), "Failed to load %s", openglDll.constData());
+         return false;
+@@ -184,7 +191,7 @@ bool QWindowsOpengl32DLL::init(bool softwareRendering)
+         // Load opengl32.dll always. GDI functions like ChoosePixelFormat do
+         // GetModuleHandle for opengl32.dll and behave differently (and call back into
+         // opengl32) when the module is present. This is fine for dummy contexts and windows.
+-        ::LoadLibraryA("opengl32.dll");
++        QSystemLibrary::load(L"opengl32");
+     }
+ 
+     wglCreateContext = reinterpret_cast<HGLRC (WINAPI *)(HDC)>(resolve("wglCreateContext"));
+diff --git a/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp b/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
+index d7d186e804..9eb4011bf2 100644
+--- a/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
++++ b/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
+@@ -49,6 +49,7 @@
+ #include <QtCore/qstandardpaths.h>
+ #include <QtCore/qlibraryinfo.h>
+ #include <QtCore/qhash.h>
++#include <private/qsystemlibrary_p.h>
+ 
+ #ifndef QT_NO_OPENGL
+ #include <private/qopengl_p.h>
+@@ -396,7 +397,7 @@ bool QWindowsOpenGLTester::testDesktopGL()
+ 
+     // Test #1: Load opengl32.dll and try to resolve an OpenGL 2 function.
+     // This will typically fail on systems that do not have a real OpenGL driver.
+-    lib = LoadLibraryA("opengl32.dll");
++    lib = QSystemLibrary::load(L"opengl32");
+     if (lib) {
+         CreateContext = reinterpret_cast<CreateContextType>(
+             reinterpret_cast<QFunctionPointer>(::GetProcAddress(lib, "wglCreateContext")));
+diff --git a/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp b/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
+index 1afa00cfc9..118af6ce73 100644
+--- a/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
++++ b/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
+@@ -41,6 +41,7 @@
+ 
+ #include <QRect>
+ #include <QList>
++#include <QMap>
+ #include <QDebug>
+ 
+ #include <qmath.h>
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp b/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
+index 9e2a37a6a1..e6e175a118 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
+@@ -488,12 +488,12 @@ void QXcbConnection::printXcbError(const char *message, xcb_generic_error_t *err
+     uint clamped_error_code = qMin<uint>(error->error_code, (sizeof(xcb_errors) / sizeof(xcb_errors[0])) - 1);
+     uint clamped_major_code = qMin<uint>(error->major_code, (sizeof(xcb_protocol_request_codes) / sizeof(xcb_protocol_request_codes[0])) - 1);
+ 
+-    qCWarning(lcQpaXcb, "%s: %d (%s), sequence: %d, resource id: %d, major code: %d (%s), minor code: %d",
+-             message,
+-             int(error->error_code), xcb_errors[clamped_error_code],
+-             int(error->sequence), int(error->resource_id),
+-             int(error->major_code), xcb_protocol_request_codes[clamped_major_code],
+-             int(error->minor_code));
++    qCDebug(lcQpaXcb, "%s: %d (%s), sequence: %d, resource id: %d, major code: %d (%s), minor code: %d",
++            message,
++            int(error->error_code), xcb_errors[clamped_error_code],
++            int(error->sequence), int(error->resource_id),
++            int(error->major_code), xcb_protocol_request_codes[clamped_major_code],
++            int(error->minor_code));
+ }
+ 
+ static Qt::MouseButtons translateMouseButtons(int s)
+@@ -702,6 +702,8 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
+             QXcbVirtualDesktop *virtualDesktop = virtualDesktopForRootWindow(propertyNotify->window);
+             if (virtualDesktop)
+                 virtualDesktop->updateWorkArea();
++        } else if (propertyNotify->atom == atom(QXcbAtom::_NET_SUPPORTED)) {
++            m_wmSupport->updateNetWMAtoms();
+         } else {
+             HANDLE_PLATFORM_WINDOW_EVENT(xcb_property_notify_event_t, window, handlePropertyNotifyEvent);
+         }
+@@ -750,7 +752,7 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
+                 case XCB_XKB_NEW_KEYBOARD_NOTIFY: {
+                     xcb_xkb_new_keyboard_notify_event_t *ev = &xkb_event->new_keyboard_notify;
+                     if (ev->changed & XCB_XKB_NKN_DETAIL_KEYCODES)
+-                        m_keyboard->updateKeymap(ev);
++                        m_keyboard->updateKeymap();
+                     break;
+                 }
+                 default:
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp b/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
+index 76869ced60..02d2eebb56 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
+@@ -274,8 +274,7 @@ QPlatformWindow *QXcbIntegration::createForeignWindow(QWindow *window, WId nativ
+ #ifndef QT_NO_OPENGL
+ QPlatformOpenGLContext *QXcbIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
+ {
+-    QXcbScreen *screen = static_cast<QXcbScreen *>(context->screen()->handle());
+-    QXcbGlIntegration *glIntegration = screen->connection()->glIntegration();
++    QXcbGlIntegration *glIntegration = defaultConnection()->glIntegration();
+     if (!glIntegration) {
+         qWarning("QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled");
+         return nullptr;
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+index efecd7e2d1..e8286381a2 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+@@ -365,17 +365,6 @@ void QXcbKeyboard::updateKeymap(xcb_mapping_notify_event_t *event)
+     updateKeymap();
+ }
+ 
+-void QXcbKeyboard::updateKeymap(xcb_xkb_new_keyboard_notify_event_t *event)
+-{
+-    if (!event)
+-        return;
+-
+-    if (event->deviceID != event->oldDeviceID)
+-        m_config = false;
+-
+-    updateKeymap();
+-}
+-
+ void QXcbKeyboard::updateKeymap()
+ {
+     KeysymModifierMap keysymMods;
+@@ -383,6 +372,8 @@ void QXcbKeyboard::updateKeymap()
+         keysymMods = keysymsToModifiers();
+     updateModifiers(keysymMods);
+ 
++    m_config = true;
++
+     if (!m_xkbContext) {
+         m_xkbContext.reset(xkb_context_new(XKB_CONTEXT_NO_DEFAULT_INCLUDES));
+         if (!m_xkbContext) {
+@@ -398,13 +389,8 @@ void QXcbKeyboard::updateKeymap()
+     if (connection()->hasXKB()) {
+         m_xkbKeymap.reset(xkb_x11_keymap_new_from_device(m_xkbContext.get(), xcb_connection(),
+                                                          core_device_id, XKB_KEYMAP_COMPILE_NO_FLAGS));
+-        if (m_xkbKeymap) {
+-            if (m_config)
+-                m_xkbState.reset(xkb_state_new(m_xkbKeymap.get()));
+-            else
+-                m_xkbState.reset(xkb_x11_state_new_from_device(m_xkbKeymap.get(), xcb_connection(), core_device_id));
+-
+-        }
++        if (m_xkbKeymap)
++            m_xkbState.reset(xkb_x11_state_new_from_device(m_xkbKeymap.get(), xcb_connection(), core_device_id));
+     } else {
+         m_xkbKeymap.reset(keymapFromCore(keysymMods));
+         if (m_xkbKeymap)
+@@ -425,8 +411,6 @@ void QXcbKeyboard::updateKeymap()
+     updateXKBMods();
+ 
+     QXkbCommon::verifyHasLatinLayout(m_xkbKeymap.get());
+-
+-    m_config = true;
+ }
+ 
+ QList<int> QXcbKeyboard::possibleKeys(const QKeyEvent *event) const
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
+index b652c85fe3..0ee08aeff2 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
++++ b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
+@@ -69,7 +69,6 @@ public:
+ 
+     Qt::KeyboardModifiers translateModifiers(int s) const;
+     void updateKeymap(xcb_mapping_notify_event_t *event);
+-    void updateKeymap(xcb_xkb_new_keyboard_notify_event_t *event);
+     void updateKeymap();
+     QList<int> possibleKeys(const QKeyEvent *event) const;
+ 
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp b/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
+index ffda7b6a57..863e961f4c 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
+@@ -564,11 +564,6 @@ void QXcbWindow::setGeometry(const QRect &rect)
+ {
+     QPlatformWindow::setGeometry(rect);
+ 
+-    if (shouldDeferTask(Task::SetGeometry)) {
+-        m_deferredGeometry = rect;
+-        return;
+-    }
+-
+     propagateSizeHints();
+ 
+     QXcbScreen *currentScreen = xcbScreen();
+@@ -693,9 +688,6 @@ void QXcbWindow::setVisible(bool visible)
+ 
+ void QXcbWindow::show()
+ {
+-    if (shouldDeferTask(Task::Map))
+-        return;
+-
+     if (window()->isTopLevel()) {
+ 
+         // update WM_NORMAL_HINTS
+@@ -706,7 +698,7 @@ void QXcbWindow::show()
+         if (isTransient(window())) {
+             const QWindow *tp = window()->transientParent();
+             if (tp && tp->handle())
+-                transientXcbParent = static_cast<const QXcbWindow *>(tp->handle())->winId();
++                transientXcbParent = tp->handle()->winId();
+             // Default to client leader if there is no transient parent, else modal dialogs can
+             // be hidden by their parents.
+             if (!transientXcbParent)
+@@ -746,10 +738,6 @@ void QXcbWindow::show()
+ 
+ void QXcbWindow::hide()
+ {
+-    if (shouldDeferTask(Task::Unmap))
+-        return;
+-
+-    m_wmStateValid = false;
+     xcb_unmap_window(xcb_connection(), m_window);
+ 
+     // send synthetic UnmapNotify event according to icccm 4.1.4
+@@ -909,9 +897,6 @@ QXcbWindow::NetWmStates QXcbWindow::netWmStates()
+ 
+ void QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
+ {
+-    if (shouldDeferTask(Task::SetWindowFlags))
+-        return;
+-
+     Qt::WindowType type = static_cast<Qt::WindowType>(int(flags & Qt::WindowType_Mask));
+ 
+     if (type == Qt::ToolTip)
+@@ -941,8 +926,6 @@ void QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
+ 
+     setTransparentForMouseEvents(flags & Qt::WindowTransparentForInput);
+     updateDoesNotAcceptFocus(flags & Qt::WindowDoesNotAcceptFocus);
+-
+-    m_isWmManagedWindow = !(flags & Qt::X11BypassWindowManagerHint);
+ }
+ 
+ void QXcbWindow::setMotifWmHints(Qt::WindowFlags flags)
+@@ -1142,9 +1125,6 @@ void QXcbWindow::setWindowState(Qt::WindowStates state)
+     if (state == m_windowState)
+         return;
+ 
+-    if (shouldDeferTask(Task::SetWindowState))
+-        return;
+-
+     // unset old state
+     if (m_windowState & Qt::WindowMinimized)
+         xcb_map_window(xcb_connection(), m_window);
+@@ -1350,6 +1330,12 @@ void QXcbWindow::setWindowIcon(const QIcon &icon)
+     }
+ 
+     if (!icon_data.isEmpty()) {
++        // Ignore icon exceeding maximum xcb request length
++        if (icon_data.size() > xcb_get_maximum_request_length(xcb_connection())) {
++            qWarning("Ignoring window icon: Size %llu exceeds maximum xcb request length %u.",
++                     icon_data.size(), xcb_get_maximum_request_length(xcb_connection()));
++            return;
++        }
+         xcb_change_property(xcb_connection(),
+                             XCB_PROP_MODE_REPLACE,
+                             m_window,
+@@ -1639,7 +1625,7 @@ void QXcbWindow::setWmWindowType(QXcbWindowFunctions::WmWindowTypes types, Qt::W
+         break;
+     }
+ 
+-    if ((flags & Qt::FramelessWindowHint) && !(type & QXcbWindowFunctions::KdeOverride)) {
++    if ((flags & Qt::FramelessWindowHint) && !(types & QXcbWindowFunctions::KdeOverride)) {
+         // override netwm type - quick and easy for KDE noborder
+         atoms.append(atom(QXcbAtom::_KDE_NET_WM_WINDOW_TYPE_OVERRIDE));
+     }
+@@ -1894,10 +1880,6 @@ void QXcbWindow::handleUnmapNotifyEvent(const xcb_unmap_notify_event_t *event)
+     if (event->window == m_window) {
+         m_mapped = false;
+         QWindowSystemInterface::handleExposeEvent(window(), QRegion());
+-        if (!m_isWmManagedWindow || parent()) {
+-            m_wmStateValid = true;
+-            handleDeferredTasks();
+-        }
+     }
+ }
+ 
+@@ -2212,98 +2194,30 @@ void QXcbWindow::handleLeaveNotifyEvent(const xcb_leave_notify_event_t *event)
+     handleLeaveNotifyEvent(event->root_x, event->root_y, event->mode, event->detail, event->time);
+ }
+ 
+-bool QXcbWindow::shouldDeferTask(Task task)
+-{
+-    if (m_wmStateValid)
+-        return false;
+-
+-    m_deferredTasks.append(task);
+-    return true;
+-}
+-
+-void QXcbWindow::handleDeferredTasks()
+-{
+-    Q_ASSERT(m_wmStateValid == true);
+-    if (m_deferredTasks.isEmpty())
+-        return;
+-
+-    bool map = false;
+-    bool unmap = false;
+-
+-    QVector<Task> tasks;
+-    for (auto taskIt = m_deferredTasks.rbegin(); taskIt != m_deferredTasks.rend(); ++taskIt) {
+-        if (!tasks.contains(*taskIt))
+-            tasks.prepend(*taskIt);
+-    }
+-
+-    for (Task task : tasks) {
+-        switch (task) {
+-        case Task::Map:
+-            map = true;
+-            unmap = false;
+-            break;
+-        case Task::Unmap:
+-            unmap = true;
+-            map = false;
+-            break;
+-        case Task::SetGeometry:
+-            setGeometry(m_deferredGeometry);
+-            break;
+-        case Task::SetWindowFlags:
+-            setWindowFlags(window()->flags());
+-            break;
+-        case Task::SetWindowState:
+-            setWindowState(window()->windowState());
+-            break;
+-        }
+-    }
+-    m_deferredTasks.clear();
+-
+-    if (map) {
+-        Q_ASSERT(unmap == false);
+-        show();
+-    }
+-    if (unmap) {
+-        Q_ASSERT(map == false);
+-        hide();
+-    }
+-}
+-
+ void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *event)
+ {
+     connection()->setTime(event->time);
+ 
+-    const bool wmStateChanged = event->atom == atom(QXcbAtom::WM_STATE);
+-    const bool netWmStateChanged = event->atom == atom(QXcbAtom::_NET_WM_STATE);
+-    if (netWmStateChanged || wmStateChanged) {
+-        if (wmStateChanged && !m_wmStateValid && m_isWmManagedWindow) {
+-            // ICCCM 4.1.4
+-            // Clients that want to re-use a client window (e.g. by mapping it again)
+-            // after withdrawing it must wait for the withdrawal to be complete before
+-            // proceeding. The preferred method for doing this is for clients to wait for
+-            // a window manager to update or remove the WM_STATE property.
+-            m_wmStateValid = true;
+-            handleDeferredTasks();
+-        }
+-        if (event->state == XCB_PROPERTY_DELETE)
++    const bool propertyDeleted = event->state == XCB_PROPERTY_DELETE;
++
++    if (event->atom == atom(QXcbAtom::_NET_WM_STATE) || event->atom == atom(QXcbAtom::WM_STATE)) {
++        if (propertyDeleted)
+             return;
+ 
+-        if (wmStateChanged) {
++        Qt::WindowStates newState = Qt::WindowNoState;
++
++        if (event->atom == atom(QXcbAtom::WM_STATE)) { // WM_STATE: Quick check for 'Minimize'.
+             auto reply = Q_XCB_REPLY(xcb_get_property, xcb_connection(),
+                                      0, m_window, atom(QXcbAtom::WM_STATE),
+                                      XCB_ATOM_ANY, 0, 1024);
+             if (reply && reply->format == 32 && reply->type == atom(QXcbAtom::WM_STATE)) {
+-                auto data = static_cast<const quint32 *>(xcb_get_property_value(reply.get()));
+-                if (reply->length != 0) {
+-                    const bool changedToWithdrawn = data[0] == XCB_ICCCM_WM_STATE_WITHDRAWN;
+-                    const bool changedToIconic = data[0] == XCB_ICCCM_WM_STATE_ICONIC;
+-                    m_minimized = changedToIconic || (changedToWithdrawn && m_minimized);
+-                }
++                const quint32 *data = (const quint32 *)xcb_get_property_value(reply.get());
++                if (reply->length != 0)
++                    m_minimized = (data[0] == XCB_ICCCM_WM_STATE_ICONIC
++                                   || (data[0] == XCB_ICCCM_WM_STATE_WITHDRAWN && m_minimized));
+             }
+         }
+ 
+-        // _NET_WM_STATE handling
+-        Qt::WindowStates newState = Qt::WindowNoState;
+         const NetWmStates states = netWmStates();
+         // _NET_WM_STATE_HIDDEN should be set by the Window Manager to indicate that a window would
+         // not be visible on the screen if its desktop/viewport were active and its coordinates were
+@@ -2325,6 +2239,7 @@ void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *ev
+             if ((m_windowState & Qt::WindowMinimized) && connection()->mouseGrabber() == this)
+                 connection()->setMouseGrabber(nullptr);
+         }
++        return;
+     } else if (event->atom == atom(QXcbAtom::_NET_FRAME_EXTENTS)) {
+         m_dirtyFrameMargins = true;
+     }
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbwindow.h b/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
+index 55af9279b1..6f5c1f5ed9 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
++++ b/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
+@@ -74,14 +74,6 @@ public:
+ 
+     Q_DECLARE_FLAGS(NetWmStates, NetWmState)
+ 
+-    enum Task {
+-        Map,
+-        Unmap,
+-        SetGeometry,
+-        SetWindowFlags,
+-        SetWindowState
+-    };
+-
+     QXcbWindow(QWindow *window);
+     ~QXcbWindow();
+ 
+@@ -151,9 +143,6 @@ public:
+ 
+     QXcbWindow *toWindow() override;
+ 
+-    bool shouldDeferTask(Task task);
+-    void handleDeferredTasks();
+-
+     void handleMouseEvent(xcb_timestamp_t time, const QPoint &local, const QPoint &global,
+                           Qt::KeyboardModifiers modifiers, QEvent::Type type, Qt::MouseEventSource source);
+ 
+@@ -292,11 +281,6 @@ protected:
+     int m_swapInterval = -1;
+ 
+     qreal m_sizeHintsScaleFactor = 1.0;
+-
+-    bool m_wmStateValid = true;
+-    QVector<Task> m_deferredTasks;
+-    bool m_isWmManagedWindow = true;
+-    QRect m_deferredGeometry;
+ };
+ 
+ class QXcbForeignWindow : public QXcbWindow
+diff --git a/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp b/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
+index d9d117faeb..640b49daa0 100644
+--- a/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
++++ b/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
+@@ -85,6 +85,7 @@ QGtk3MenuItem::QGtk3MenuItem()
+       m_checkable(false),
+       m_checked(false),
+       m_enabled(true),
++      m_exclusive(false),
+       m_underline(false),
+       m_invalid(true),
+       m_menu(nullptr),
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
+index 0048bbc1e6..396e7f6d1c 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
+@@ -102,15 +102,12 @@ const QDBusArgument &operator >>(const QDBusArgument &arg, QXdgDesktopPortalFile
+ class QXdgDesktopPortalFileDialogPrivate
+ {
+ public:
+-    QXdgDesktopPortalFileDialogPrivate(QPlatformFileDialogHelper *nativeFileDialog)
++    QXdgDesktopPortalFileDialogPrivate(QPlatformFileDialogHelper *nativeFileDialog, uint fileChooserPortalVersion)
+         : nativeFileDialog(nativeFileDialog)
++        , fileChooserPortalVersion(fileChooserPortalVersion)
+     { }
+ 
+-    WId winId = 0;
+-    bool directoryMode = false;
+-    bool modal = false;
+-    bool multipleFiles = false;
+-    bool saveFile = false;
++    QEventLoop loop;
+     QString acceptLabel;
+     QString directory;
+     QString title;
+@@ -121,19 +118,27 @@ public:
+     QString selectedMimeTypeFilter;
+     QString selectedNameFilter;
+     QStringList selectedFiles;
+-    QPlatformFileDialogHelper *nativeFileDialog = nullptr;
++    std::unique_ptr<QPlatformFileDialogHelper> nativeFileDialog;
++    uint fileChooserPortalVersion = 0;
++    bool failedToOpen = false;
++    bool directoryMode = false;
++    bool multipleFiles = false;
++    bool saveFile = false;
+ };
+ 
+-QXdgDesktopPortalFileDialog::QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog)
++QXdgDesktopPortalFileDialog::QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog, uint fileChooserPortalVersion)
+     : QPlatformFileDialogHelper()
+-    , d_ptr(new QXdgDesktopPortalFileDialogPrivate(nativeFileDialog))
++    , d_ptr(new QXdgDesktopPortalFileDialogPrivate(nativeFileDialog, fileChooserPortalVersion))
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+     if (d->nativeFileDialog) {
+-        connect(d->nativeFileDialog, SIGNAL(accept()), this, SIGNAL(accept()));
+-        connect(d->nativeFileDialog, SIGNAL(reject()), this, SIGNAL(reject()));
++        connect(d->nativeFileDialog.get(), SIGNAL(accept()), this, SIGNAL(accept()));
++        connect(d->nativeFileDialog.get(), SIGNAL(reject()), this, SIGNAL(reject()));
+     }
++
++    d->loop.connect(this, SIGNAL(accept()), SLOT(quit()));
++    d->loop.connect(this, SIGNAL(reject()), SLOT(quit()));
+ }
+ 
+ QXdgDesktopPortalFileDialog::~QXdgDesktopPortalFileDialog()
+@@ -177,7 +182,7 @@ void QXdgDesktopPortalFileDialog::initializeDialog()
+     setDirectory(options()->initialDirectory());
+ }
+ 
+-void QXdgDesktopPortalFileDialog::openPortal()
++void QXdgDesktopPortalFileDialog::openPortal(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent)
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+@@ -185,13 +190,13 @@ void QXdgDesktopPortalFileDialog::openPortal()
+                                                           QLatin1String("/org/freedesktop/portal/desktop"),
+                                                           QLatin1String("org.freedesktop.portal.FileChooser"),
+                                                           d->saveFile ? QLatin1String("SaveFile") : QLatin1String("OpenFile"));
+-    QString parentWindowId = QLatin1String("x11:") + QString::number(d->winId, 16);
++    QString parentWindowId = QLatin1String("x11:") + QString::number(parent ? parent->winId() : 0, 16);
+ 
+     QVariantMap options;
+     if (!d->acceptLabel.isEmpty())
+         options.insert(QLatin1String("accept_label"), d->acceptLabel);
+ 
+-    options.insert(QLatin1String("modal"), d->modal);
++    options.insert(QLatin1String("modal"), windowModality != Qt::NonModal);
+     options.insert(QLatin1String("multiple"), d->multipleFiles);
+     options.insert(QLatin1String("directory"), d->directoryMode);
+ 
+@@ -290,10 +295,18 @@ void QXdgDesktopPortalFileDialog::openPortal()
+ 
+     QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
+     QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingCall);
+-    connect(watcher, &QDBusPendingCallWatcher::finished, this, [this] (QDBusPendingCallWatcher *watcher) {
++    connect(watcher, &QDBusPendingCallWatcher::finished, this, [=] (QDBusPendingCallWatcher *watcher) {
+         QDBusPendingReply<QDBusObjectPath> reply = *watcher;
+-        if (reply.isError()) {
+-            Q_EMIT reject();
++        // Any error means the dialog is not shown and we need to fallback
++        d->failedToOpen = reply.isError();
++        if (d->failedToOpen) {
++            if (d->nativeFileDialog) {
++                d->nativeFileDialog->show(windowFlags, windowModality, parent);
++                if (d->loop.isRunning())
++                    d->nativeFileDialog->exec();
++            } else {
++                Q_EMIT reject();
++            }
+         } else {
+             QDBusConnection::sessionBus().connect(nullptr,
+                                                   reply.value().path(),
+@@ -302,6 +315,7 @@ void QXdgDesktopPortalFileDialog::openPortal()
+                                                   this,
+                                                   SLOT(gotResponse(uint,QVariantMap)));
+         }
++        watcher->deleteLater();
+     });
+ }
+ 
+@@ -326,7 +340,7 @@ QUrl QXdgDesktopPortalFileDialog::directory() const
+ {
+     Q_D(const QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog())
+         return d->nativeFileDialog->directory();
+ 
+     return d->directory;
+@@ -348,7 +362,7 @@ QList<QUrl> QXdgDesktopPortalFileDialog::selectedFiles() const
+ {
+     Q_D(const QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog())
+         return d->nativeFileDialog->selectedFiles();
+ 
+     QList<QUrl> files;
+@@ -403,16 +417,13 @@ void QXdgDesktopPortalFileDialog::exec()
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly)) {
++    if (d->nativeFileDialog && useNativeFileDialog()) {
+         d->nativeFileDialog->exec();
+         return;
+     }
+ 
+     // HACK we have to avoid returning until we emit that the dialog was accepted or rejected
+-    QEventLoop loop;
+-    loop.connect(this, SIGNAL(accept()), SLOT(quit()));
+-    loop.connect(this, SIGNAL(reject()), SLOT(quit()));
+-    loop.exec();
++    d->loop.exec();
+ }
+ 
+ void QXdgDesktopPortalFileDialog::hide()
+@@ -429,13 +440,10 @@ bool QXdgDesktopPortalFileDialog::show(Qt::WindowFlags windowFlags, Qt::WindowMo
+ 
+     initializeDialog();
+ 
+-    d->modal = windowModality != Qt::NonModal;
+-    d->winId = parent ? parent->winId() : 0;
+-
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog(OpenFallback))
+         return d->nativeFileDialog->show(windowFlags, windowModality, parent);
+ 
+-    openPortal();
++    openPortal(windowFlags, windowModality, parent);
+ 
+     return true;
+ }
+@@ -465,4 +473,21 @@ void QXdgDesktopPortalFileDialog::gotResponse(uint response, const QVariantMap &
+     }
+ }
+ 
++bool QXdgDesktopPortalFileDialog::useNativeFileDialog(QXdgDesktopPortalFileDialog::FallbackType fallbackType) const
++{
++    Q_D(const QXdgDesktopPortalFileDialog);
++
++    if (d->failedToOpen && fallbackType != OpenFallback)
++        return true;
++
++    if (d->fileChooserPortalVersion < 3) {
++        if (options()->fileMode() == QFileDialogOptions::Directory)
++            return true;
++        else if (options()->fileMode() == QFileDialogOptions::DirectoryOnly)
++            return true;
++    }
++
++    return false;
++}
++
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
+index 4f4de96ecf..65e22a5cf2 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
+@@ -51,6 +51,11 @@ class QXdgDesktopPortalFileDialog : public QPlatformFileDialogHelper
+     Q_OBJECT
+     Q_DECLARE_PRIVATE(QXdgDesktopPortalFileDialog)
+ public:
++    enum FallbackType {
++        GenericFallback,
++        OpenFallback
++    };
++
+     enum ConditionType : uint {
+         GlobalPattern = 0,
+         MimeType = 1
+@@ -69,7 +74,7 @@ public:
+     };
+     typedef QVector<Filter> FilterList;
+ 
+-    QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog = nullptr);
++    QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog = nullptr, uint fileChooserPortalVersion = 0);
+     ~QXdgDesktopPortalFileDialog();
+ 
+     bool defaultNameFilterDisables() const override;
+@@ -92,7 +97,8 @@ private Q_SLOTS:
+ 
+ private:
+     void initializeDialog();
+-    void openPortal();
++    void openPortal(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent);
++    bool useNativeFileDialog(FallbackType fallbackType = GenericFallback) const;
+ 
+     QScopedPointer<QXdgDesktopPortalFileDialogPrivate> d_ptr;
+ };
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
+index fb324afbd8..b809503122 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
+@@ -111,6 +111,7 @@ QXdgDesktopPortalTheme::QXdgDesktopPortalTheme()
+         if (reply.isValid()) {
+             d->fileChooserPortalVersion = reply.value().toUInt();
+         }
++        watcher->deleteLater();
+     });
+ }
+ 
+@@ -152,11 +153,12 @@ QPlatformDialogHelper* QXdgDesktopPortalTheme::createPlatformDialogHelper(Dialog
+ {
+     Q_D(const QXdgDesktopPortalTheme);
+ 
+-    if (type == FileDialog) {
++    if (type == FileDialog && d->fileChooserPortalVersion) {
+         // Older versions of FileChooser portal don't support opening directories, therefore we fallback
+         // to native file dialog opened inside the sandbox to open a directory.
+-        if (d->fileChooserPortalVersion < 3 && d->baseTheme->usePlatformNativeDialog(type))
+-            return new QXdgDesktopPortalFileDialog(static_cast<QPlatformFileDialogHelper*>(d->baseTheme->createPlatformDialogHelper(type)));
++        if (d->baseTheme->usePlatformNativeDialog(type))
++            return new QXdgDesktopPortalFileDialog(static_cast<QPlatformFileDialogHelper*>(d->baseTheme->createPlatformDialogHelper(type)),
++                                                   d->fileChooserPortalVersion);
+ 
+         return new QXdgDesktopPortalFileDialog;
+     }
+diff --git a/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp b/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
+index 43d5e119ad..1f9cbc4565 100644
+--- a/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
++++ b/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
+@@ -89,8 +89,10 @@ void QCupsPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &v
+         break;
+     case PPK_Duplex: {
+         QPrint::DuplexMode mode = QPrint::DuplexMode(value.toInt());
+-        if (mode != d->duplex && d->m_printDevice.supportedDuplexModes().contains(mode))
++        if (d->m_printDevice.supportedDuplexModes().contains(mode)) {
+             d->duplex = mode;
++            d->duplexRequestedExplicitly = true;
++        }
+         break;
+     }
+     case PPK_PrinterName:
+@@ -277,9 +279,12 @@ void QCupsPrintEnginePrivate::changePrinter(const QString &newPrinter)
+     m_printDevice.swap(printDevice);
+     printerName = m_printDevice.id();
+ 
+-    // Check if new printer supports current settings, otherwise us defaults
+-    if (duplex != QPrint::DuplexAuto && !m_printDevice.supportedDuplexModes().contains(duplex))
++    // in case a duplex value was explicitly set, check if new printer supports current value,
++    // otherwise use device default
++    if (!duplexRequestedExplicitly || !m_printDevice.supportedDuplexModes().contains(duplex)) {
+         duplex = m_printDevice.defaultDuplexMode();
++        duplexRequestedExplicitly = false;
++    }
+     QPrint::ColorMode colorMode = grayscale ? QPrint::GrayScale : QPrint::Color;
+     if (!m_printDevice.supportedColorModes().contains(colorMode))
+         grayscale = m_printDevice.defaultColorMode() == QPrint::GrayScale;
+diff --git a/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h b/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
+index c021b0c643..8f81fe478d 100644
+--- a/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
++++ b/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
+@@ -100,6 +100,7 @@ private:
+     QStringList cupsOptions;
+     QString cupsTempFile;
+     QPrint::DuplexMode duplex;
++    bool duplexRequestedExplicitly = false;
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp b/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
+index 67e7154fa6..40876152e5 100644
+--- a/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
++++ b/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
+@@ -817,7 +817,7 @@ bool QIBaseResultPrivate::writeArray(int column, const QList<QVariant> &list)
+     ba.resize(int(bufLen));
+ 
+     if (list.size() > arraySize) {
+-        error = QLatin1String("Array size missmatch: size of %1 is %2, size of provided list is %3");
++        error = QLatin1String("Array size mismatch: size of %1 is %2, size of provided list is %3");
+         error = error.arg(QLatin1String(sqlname)).arg(arraySize).arg(list.size());
+         q->setLastError(QSqlError(error, QLatin1String(""), QSqlError::StatementError));
+         return false;
+diff --git a/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp b/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
+index 7ca055eea2..6bc9d46755 100644
+--- a/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
++++ b/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
+@@ -223,7 +223,7 @@ public:
+     struct QMyField
+     {
+         char *outField = nullptr;
+-        MYSQL_FIELD *myField = nullptr;
++        const MYSQL_FIELD *myField = nullptr;
+         QMetaType::Type type = QMetaType::UnknownType;
+         my_bool nullIndicator = false;
+         ulong bufLength = 0ul;
+@@ -361,7 +361,7 @@ static bool qIsInteger(int t)
+ void QMYSQLResultPrivate::bindBlobs()
+ {
+     int i;
+-    MYSQL_FIELD *fieldInfo;
++    const MYSQL_FIELD *fieldInfo;
+     MYSQL_BIND *bind;
+ 
+     for(i = 0; i < fields.count(); ++i) {
+@@ -379,7 +379,6 @@ void QMYSQLResultPrivate::bindBlobs()
+ bool QMYSQLResultPrivate::bindInValues()
+ {
+     MYSQL_BIND *bind;
+-    char *field;
+     int i = 0;
+ 
+     if (!meta)
+@@ -392,35 +391,34 @@ bool QMYSQLResultPrivate::bindInValues()
+     inBinds = new MYSQL_BIND[fields.size()];
+     memset(inBinds, 0, fields.size() * sizeof(MYSQL_BIND));
+ 
+-    MYSQL_FIELD *fieldInfo;
++    const MYSQL_FIELD *fieldInfo;
+ 
+     while((fieldInfo = mysql_fetch_field(meta))) {
++        bind = &inBinds[i];
++
+         QMyField &f = fields[i];
+         f.myField = fieldInfo;
+-
++        bind->buffer_length = f.bufLength = fieldInfo->length + 1;
++        bind->buffer_type = fieldInfo->type;
+         f.type = qDecodeMYSQLType(fieldInfo->type, fieldInfo->flags);
+         if (qIsBlob(fieldInfo->type)) {
+             // the size of a blob-field is available as soon as we call
+             // mysql_stmt_store_result()
+             // after mysql_stmt_exec() in QMYSQLResult::exec()
+-            fieldInfo->length = 0;
++            bind->buffer_length = f.bufLength = 0;
+             hasBlobs = true;
+         } else if (qIsInteger(f.type)) {
+-            fieldInfo->length = 8;
++            bind->buffer_length = f.bufLength = 8;
+         } else {
+-            fieldInfo->type = MYSQL_TYPE_STRING;
++            bind->buffer_type = MYSQL_TYPE_STRING;
+         }
+-        bind = &inBinds[i];
+-        field = new char[fieldInfo->length + 1];
+-        memset(field, 0, fieldInfo->length + 1);
+ 
+-        bind->buffer_type = fieldInfo->type;
+-        bind->buffer = field;
+-        bind->buffer_length = f.bufLength = fieldInfo->length + 1;
+         bind->is_null = &f.nullIndicator;
+         bind->length = &f.bufLength;
+         bind->is_unsigned = fieldInfo->flags & UNSIGNED_FLAG ? 1 : 0;
+-        f.outField=field;
++
++        char *field = new char[bind->buffer_length + 1]{};
++        bind->buffer = f.outField = field;
+ 
+         ++i;
+     }
+@@ -1369,20 +1367,20 @@ bool QMYSQLDriver::open(const QString& db,
+     }
+ 
+ #if MYSQL_VERSION_ID >= 50007
+-    if (mysql_get_client_version() >= 50503 && mysql_get_server_version(d->mysql) >= 50503) {
+-        // force the communication to be utf8mb4 (only utf8mb4 supports 4-byte characters)
+-        mysql_set_character_set(d->mysql, "utf8mb4");
++    // force the communication to be utf8mb4 (only utf8mb4 supports 4-byte characters)
++    if (mysql_set_character_set(d->mysql, "utf8mb4")) {
++        // this failed, try forcing it to utf (BMP only)
++        if (mysql_set_character_set(d->mysql, "utf8"))
++            qWarning() << "MySQL: Unable to set the client character set to utf8.";
+ #if QT_CONFIG(textcodec)
+-        d->tc = QTextCodec::codecForName("UTF-8");
++        else
++            d->tc = codec(d->mysql);
+ #endif
+-    } else
+-    {
+-        // force the communication to be utf8
+-        mysql_set_character_set(d->mysql, "utf8");
++    }
+ #if QT_CONFIG(textcodec)
+-        d->tc = codec(d->mysql);
++    else
++        d->tc = QTextCodec::codecForName("UTF-8");
+ #endif
+-    }
+ #endif  // MYSQL_VERSION_ID >= 50007
+ 
+     d->preparedQuerysEnabled = checkPreparedQueries(d->mysql);
+diff --git a/qtbase/src/printsupport/dialogs/images/print-24.png b/qtbase/src/printsupport/dialogs/images/printer-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/print-24.png
+rename to src/printsupport/dialogs/images/printer-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/print-32.png b/qtbase/src/printsupport/dialogs/images/printer-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/print-32.png
+rename to src/printsupport/dialogs/images/printer-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-sided-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-facing-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-sided-24.png
+rename to src/printsupport/dialogs/images/view-pages-facing-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-sided-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-facing-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-sided-32.png
+rename to src/printsupport/dialogs/images/view-pages-facing-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-multi-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-overview-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-multi-24.png
+rename to src/printsupport/dialogs/images/view-pages-overview-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-multi-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-overview-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-multi-32.png
+rename to src/printsupport/dialogs/images/view-pages-overview-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-one-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-single-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-one-24.png
+rename to src/printsupport/dialogs/images/view-pages-single-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-one-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-single-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-one-32.png
+rename to src/printsupport/dialogs/images/view-pages-single-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-page-24.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-page-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-page-24.png
+rename to src/printsupport/dialogs/images/zoom-fit-page-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-page-32.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-page-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-page-32.png
+rename to src/printsupport/dialogs/images/zoom-fit-page-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-width-24.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-width-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-width-24.png
+rename to src/printsupport/dialogs/images/zoom-fit-width-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-width-32.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-width-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-width-32.png
+rename to src/printsupport/dialogs/images/zoom-fit-width-32.png
+diff --git a/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp b/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
+index 78e5b8d1ef..2a28516719 100644
+--- a/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
++++ b/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
+@@ -532,6 +532,7 @@ void QPageSetupWidget::updateWidget()
+ void QPageSetupWidget::setupPrinter() const
+ {
+     m_printer->setPageLayout(m_pageLayout);
++    m_printer->setPageOrientation(m_pageLayout.orientation());
+ #if QT_CONFIG(cups)
+     QCUPSSupport::PagesPerSheet pagesPerSheet = qvariant_cast<QCUPSSupport::PagesPerSheet>(m_ui.pagesPerSheetCombo->currentData()
+ );
+diff --git a/qtbase/src/printsupport/dialogs/qprintdialog.qrc b/qtbase/src/printsupport/dialogs/qprintdialog.qrc
+index 5a579baa55..10b8e1d341 100644
+--- a/qtbase/src/printsupport/dialogs/qprintdialog.qrc
++++ b/qtbase/src/printsupport/dialogs/qprintdialog.qrc
+@@ -1,9 +1,9 @@
+ <!DOCTYPE RCC><RCC version="1.0">
+ <qresource prefix="/qt-project.org/dialogs/qprintpreviewdialog">
+-<file>images/fit-page-24.png</file>
+-<file>images/fit-page-32.png</file>
+-<file>images/fit-width-24.png</file>
+-<file>images/fit-width-32.png</file>
++<file>images/zoom-fit-page-24.png</file>
++<file>images/zoom-fit-page-32.png</file>
++<file>images/zoom-fit-width-24.png</file>
++<file>images/zoom-fit-width-32.png</file>
+ <file>images/go-first-24.png</file>
+ <file>images/go-first-32.png</file>
+ <file>images/go-last-24.png</file>
+@@ -18,14 +18,14 @@
+ <file>images/layout-portrait-32.png</file>
+ <file>images/page-setup-24.png</file>
+ <file>images/page-setup-32.png</file>
+-<file>images/print-24.png</file>
+-<file>images/print-32.png</file>
+-<file>images/view-page-multi-24.png</file>
+-<file>images/view-page-multi-32.png</file>
+-<file>images/view-page-one-24.png</file>
+-<file>images/view-page-one-32.png</file>
+-<file>images/view-page-sided-24.png</file>
+-<file>images/view-page-sided-32.png</file>
++<file>images/printer-24.png</file>
++<file>images/printer-32.png</file>
++<file>images/view-pages-overview-24.png</file>
++<file>images/view-pages-overview-32.png</file>
++<file>images/view-pages-single-24.png</file>
++<file>images/view-pages-single-32.png</file>
++<file>images/view-pages-facing-24.png</file>
++<file>images/view-pages-facing-32.png</file>
+ <file>images/zoom-in-24.png</file>
+ <file>images/zoom-in-32.png</file>
+ <file>images/zoom-out-24.png</file>
+diff --git a/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp b/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
+index c5b845f4ec..5a5ba1d0a8 100644
+--- a/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
++++ b/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
+@@ -702,13 +702,14 @@ void QPrintDialogPrivate::selectPrinter(const QPrinter::OutputFormat outputForma
+         else
+             options.grayscale->setChecked(true);
+ 
+-        // keep duplex value explicitly set by user, if any, and selected printer supports it;
+-        // use device default otherwise
++        // duplex priorities to be as follows:
++        // 1) a user-selected duplex value in the dialog has highest prority
++        // 2) duplex value set in the QPrinter
+         QPrint::DuplexMode duplex;
+         if (explicitDuplexMode != QPrint::DuplexAuto && supportedDuplexMode.contains(explicitDuplexMode))
+             duplex = explicitDuplexMode;
+         else
+-            duplex = top->d->m_currentPrintDevice.defaultDuplexMode();
++            duplex = static_cast<QPrint::DuplexMode>(p->duplex());
+         switch (duplex) {
+         case QPrint::DuplexNone:
+             options.noDuplex->setChecked(true); break;
+@@ -1242,10 +1243,10 @@ void QUnixPrintWidgetPrivate::_q_printerChanged(int index)
+             QString filename = widget.filename->text();
+             widget.filename->setText(filename);
+             widget.lOutput->setEnabled(true);
+-            if (optionsPane)
+-                optionsPane->selectPrinter(QPrinter::PdfFormat);
+             printer->setOutputFormat(QPrinter::PdfFormat);
+             m_currentPrintDevice = QPrintDevice();
++            if (optionsPane)
++                optionsPane->selectPrinter(QPrinter::PdfFormat);
+             return;
+         }
+     }
+diff --git a/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp b/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
+index 39575d5f57..23b7e89538 100644
+--- a/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
++++ b/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
+@@ -352,7 +352,7 @@ void QPrintPreviewDialogPrivate::init(QPrinter *_printer)
+ static inline void qt_setupActionIcon(QAction *action, QLatin1String name)
+ {
+     QLatin1String imagePrefix(":/qt-project.org/dialogs/qprintpreviewdialog/images/");
+-    QIcon icon;
++    QIcon icon = QIcon::fromTheme(name);
+     icon.addFile(imagePrefix + name + QLatin1String("-24.png"), QSize(24, 24));
+     icon.addFile(imagePrefix + name + QLatin1String("-32.png"), QSize(32, 32));
+     action->setIcon(icon);
+@@ -383,8 +383,8 @@ void QPrintPreviewDialogPrivate::setupActions()
+     fitPageAction->setObjectName(QLatin1String("fitPageAction"));
+     fitWidthAction->setCheckable(true);
+     fitPageAction->setCheckable(true);
+-    qt_setupActionIcon(fitWidthAction, QLatin1String("fit-width"));
+-    qt_setupActionIcon(fitPageAction, QLatin1String("fit-page"));
++    qt_setupActionIcon(fitWidthAction, QLatin1String("zoom-fit-width"));
++    qt_setupActionIcon(fitPageAction, QLatin1String("zoom-fit-page"));
+     QObject::connect(fitGroup, SIGNAL(triggered(QAction*)), q, SLOT(_q_fit(QAction*)));
+ 
+     // Zoom
+@@ -410,9 +410,9 @@ void QPrintPreviewDialogPrivate::setupActions()
+     singleModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show single page"));
+     facingModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show facing pages"));
+     overviewModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show overview of all pages"));
+-    qt_setupActionIcon(singleModeAction, QLatin1String("view-page-one"));
+-    qt_setupActionIcon(facingModeAction, QLatin1String("view-page-sided"));
+-    qt_setupActionIcon(overviewModeAction, QLatin1String("view-page-multi"));
++    qt_setupActionIcon(singleModeAction, QLatin1String("view-pages-single"));
++    qt_setupActionIcon(facingModeAction, QLatin1String("view-pages-facing"));
++    qt_setupActionIcon(overviewModeAction, QLatin1String("view-pages-overview"));
+     singleModeAction->setObjectName(QLatin1String("singleModeAction"));
+     facingModeAction->setObjectName(QLatin1String("facingModeAction"));
+     overviewModeAction->setObjectName(QLatin1String("overviewModeAction"));
+@@ -426,7 +426,7 @@ void QPrintPreviewDialogPrivate::setupActions()
+     printerGroup = new QActionGroup(q);
+     printAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Print"));
+     pageSetupAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Page setup"));
+-    qt_setupActionIcon(printAction, QLatin1String("print"));
++    qt_setupActionIcon(printAction, QLatin1String("printer"));
+     qt_setupActionIcon(pageSetupAction, QLatin1String("page-setup"));
+     QObject::connect(printAction, SIGNAL(triggered(bool)), q, SLOT(_q_print()));
+     QObject::connect(pageSetupAction, SIGNAL(triggered(bool)), q, SLOT(_q_pageSetup()));
+diff --git a/qtbase/src/sql/kernel/qsqlquery.cpp b/qtbase/src/sql/kernel/qsqlquery.cpp
+index 32c6166c79..60afef10c3 100644
+--- a/qtbase/src/sql/kernel/qsqlquery.cpp
++++ b/qtbase/src/sql/kernel/qsqlquery.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2022 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtSql module of the Qt Toolkit.
+@@ -377,6 +377,10 @@ bool QSqlQuery::exec(const QString& query)
+     QElapsedTimer t;
+     t.start();
+ #endif
++    if (!driver()) {
++        qWarning("QSqlQuery::exec: called before driver has been set up");
++        return false;
++    }
+     if (d->ref.loadRelaxed() != 1) {
+         bool fo = isForwardOnly();
+         *this = QSqlQuery(driver()->createResult());
+diff --git a/qtbase/src/testlib/qabstractitemmodeltester.cpp b/qtbase/src/testlib/qabstractitemmodeltester.cpp
+index 8efb9c53d4..ce062f66d7 100644
+--- a/qtbase/src/testlib/qabstractitemmodeltester.cpp
++++ b/qtbase/src/testlib/qabstractitemmodeltester.cpp
+@@ -454,7 +454,7 @@ void QAbstractItemModelTesterPrivate::parent()
+ 
+     // Common error test #2, make sure that a second level index has a parent
+     // that is the first level index.
+-    if (model->rowCount(topIndex) > 0) {
++    if (model->rowCount(topIndex) > 0 && model->columnCount(topIndex) > 0) {
+         QModelIndex childIndex = model->index(0, 0, topIndex);
+         MODELTESTER_VERIFY(childIndex.isValid());
+         MODELTESTER_COMPARE(model->parent(childIndex), topIndex);
+diff --git a/qtbase/src/testlib/qasciikey.cpp b/qtbase/src/testlib/qasciikey.cpp
+index 9a308da2bc..93498b256f 100644
+--- a/qtbase/src/testlib/qasciikey.cpp
++++ b/qtbase/src/testlib/qasciikey.cpp
+@@ -498,6 +498,11 @@ char QTest::keyToAscii(Qt::Key key)
+     case Qt::Key_LaunchE : return 0; // = 0x10b0,
+     case Qt::Key_LaunchF : return 0; // = 0x10b1,
+ 
++    // Keypad navigation keys
++    case Qt::Key_Select : return 0; // = 0x01010000
++    case Qt::Key_Yes : return 0; // = 0x01010001
++    case Qt::Key_No : return 0; // = 0x01010002
++
+     default: QTEST_ASSERT(false); return 0;
+     }
+ }
+diff --git a/qtbase/src/testlib/qtestresult.cpp b/qtbase/src/testlib/qtestresult.cpp
+index 88028aac6e..2e89930776 100644
+--- a/qtbase/src/testlib/qtestresult.cpp
++++ b/qtbase/src/testlib/qtestresult.cpp
+@@ -251,7 +251,8 @@ bool QTestResult::verify(bool statement, const char *statementStr,
+ {
+     QTEST_ASSERT(statementStr);
+ 
+-    char msg[1024] = {'\0'};
++    char msg[1024];
++    msg[0] = '\0';
+ 
+     if (QTestLog::verboseLevel() >= 2) {
+         qsnprintf(msg, 1024, "QVERIFY(%s)", statementStr);
+@@ -309,7 +310,8 @@ static bool compareHelper(bool success, const char *failureMsg,
+                           bool hasValues = true)
+ {
+     const size_t maxMsgLen = 1024;
+-    char msg[maxMsgLen] = {'\0'};
++    char msg[maxMsgLen];
++    msg[0] = '\0';
+ 
+     QTEST_ASSERT(expected);
+     QTEST_ASSERT(actual);
+diff --git a/qtbase/src/widgets/dialogs/qcolordialog.cpp b/qtbase/src/widgets/dialogs/qcolordialog.cpp
+index 4247731275..cb325be85c 100644
+--- a/qtbase/src/widgets/dialogs/qcolordialog.cpp
++++ b/qtbase/src/widgets/dialogs/qcolordialog.cpp
+@@ -78,7 +78,10 @@
+ #include "qwindow.h"
+ 
+ #include "private/qdialog_p.h"
++#include "private/qguiapplication_p.h"
+ 
++#include <qpa/qplatformservices.h>
++#include <qpa/qplatformintegration.h>
+ #include <algorithm>
+ 
+ QT_BEGIN_NAMESPACE
+@@ -1611,6 +1614,20 @@ void QColorDialogPrivate::_q_newStandard(int r, int c)
+ void QColorDialogPrivate::_q_pickScreenColor()
+ {
+     Q_Q(QColorDialog);
++
++    auto *platformServices = QGuiApplicationPrivate::platformIntegration()->services();
++    if (platformServices->hasCapability(QPlatformServices::Capability::ColorPicking)) {
++        if (auto *colorPicker = platformServices->colorPicker(q->windowHandle())) {
++            q->connect(colorPicker, &QPlatformServiceColorPicker::colorPicked, q,
++                       [q, colorPicker](const QColor &color) {
++                           colorPicker->deleteLater();
++                           q->setCurrentColor(color);
++                       });
++            colorPicker->pickColor();
++            return;
++        }
++    }
++
+     if (!colorPickingEventFilter)
+         colorPickingEventFilter = new QColorPickingEventFilter(this, q);
+     q->installEventFilter(colorPickingEventFilter);
+diff --git a/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp b/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
+index e120817edc..8ea36b5427 100644
+--- a/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
++++ b/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
+@@ -400,12 +400,7 @@ bool QAbstractItemDelegate::helpEvent(QHelpEvent *event,
+         const QString tooltip = index.isValid() ?
+               d->textForRole(Qt::ToolTipRole, index.data(Qt::ToolTipRole), option.locale, precision) :
+               QString();
+-        QRect rect;
+-        if (index.isValid()) {
+-            const QRect r = view->visualRect(index);
+-            rect = QRect(view->mapToGlobal(r.topLeft()), r.size());
+-        }
+-        QToolTip::showText(he->globalPos(), tooltip, view, rect);
++        QToolTip::showText(he->globalPos(), tooltip, view->viewport(), option.rect);
+         event->setAccepted(!tooltip.isEmpty());
+         break;
+         }
+diff --git a/qtbase/src/widgets/itemviews/qlistview.cpp b/qtbase/src/widgets/itemviews/qlistview.cpp
+index 2b34476642..eebfaa030e 100644
+--- a/qtbase/src/widgets/itemviews/qlistview.cpp
++++ b/qtbase/src/widgets/itemviews/qlistview.cpp
+@@ -3386,6 +3386,7 @@ void QIconModeViewBase::updateContentsSize()
+ */
+ void QListView::currentChanged(const QModelIndex &current, const QModelIndex &previous)
+ {
++    QAbstractItemView::currentChanged(current, previous);
+ #ifndef QT_NO_ACCESSIBILITY
+     if (QAccessible::isActive()) {
+         if (current.isValid()) {
+@@ -3396,7 +3397,6 @@ void QListView::currentChanged(const QModelIndex &current, const QModelIndex &pr
+         }
+     }
+ #endif
+-    QAbstractItemView::currentChanged(current, previous);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/widgets/itemviews/qtableview.cpp b/qtbase/src/widgets/itemviews/qtableview.cpp
+index 934ac581b2..f79bb24249 100644
+--- a/qtbase/src/widgets/itemviews/qtableview.cpp
++++ b/qtbase/src/widgets/itemviews/qtableview.cpp
+@@ -1013,6 +1013,7 @@ void QTableViewPrivate::drawCell(QPainter *painter, const QStyleOptionViewItem &
+ int QTableViewPrivate::widthHintForIndex(const QModelIndex &index, int hint, const QStyleOptionViewItem &option) const
+ {
+     Q_Q(const QTableView);
++    const int oldHint = hint;
+     QWidget *editor = editorForIndex(index).widget.data();
+     if (editor && persistent.contains(editor)) {
+         hint = qMax(hint, editor->sizeHint().width());
+@@ -1021,6 +1022,17 @@ int QTableViewPrivate::widthHintForIndex(const QModelIndex &index, int hint, con
+         hint = qBound(min, hint, max);
+     }
+     hint = qMax(hint, q->itemDelegate(index)->sizeHint(option, index).width());
++
++    if (hasSpans()) {
++        auto span = spans.spanAt(index.column(), index.row());
++        if (span && span->m_left == index.column() && span->m_top == index.row()) {
++            // spans are screwed up when sections are moved
++            const auto left = logicalColumn(span->m_left);
++            for (int i = 1; i <= span->width(); ++i)
++               hint -= q->columnWidth(visualColumn(left + i));
++        }
++        hint = std::max(hint, oldHint);
++    }
+     return hint;
+ }
+ 
+@@ -1053,6 +1065,11 @@ int QTableViewPrivate::heightHintForIndex(const QModelIndex &index, int hint, QS
+         option.rect.setHeight(height);
+         option.rect.setX(q->columnViewportPosition(index.column()));
+         option.rect.setWidth(q->columnWidth(index.column()));
++        if (hasSpans()) {
++            auto span = spans.spanAt(index.column(), index.row());
++            if (span && span->m_left == index.column() && span->m_top == index.row())
++                option.rect.setWidth(std::max(option.rect.width(), visualSpanRect(*span).width()));
++        }
+         // 1px less space when grid is shown (see drawCell)
+         if (showGrid)
+             option.rect.setWidth(option.rect.width() - 1);
+diff --git a/qtbase/src/widgets/kernel/qaction.h b/qtbase/src/widgets/kernel/qaction.h
+index 258a1ea0a0..737c1e8285 100644
+--- a/qtbase/src/widgets/kernel/qaction.h
++++ b/qtbase/src/widgets/kernel/qaction.h
+@@ -81,7 +81,7 @@ class Q_WIDGETS_EXPORT QAction : public QObject
+     Q_PROPERTY(MenuRole menuRole READ menuRole WRITE setMenuRole NOTIFY changed)
+     Q_PROPERTY(bool iconVisibleInMenu READ isIconVisibleInMenu WRITE setIconVisibleInMenu NOTIFY changed)
+     Q_PROPERTY(bool shortcutVisibleInContextMenu READ isShortcutVisibleInContextMenu WRITE setShortcutVisibleInContextMenu NOTIFY changed)
+-    Q_PROPERTY(Priority priority READ priority WRITE setPriority)
++    Q_PROPERTY(Priority priority READ priority WRITE setPriority NOTIFY changed)
+ 
+ public:
+     // note this is copied into qplatformmenu.h, which must stay in sync
+diff --git a/qtbase/src/widgets/kernel/qwidget.cpp b/qtbase/src/widgets/kernel/qwidget.cpp
+index 9eba1e001e..26f6d27e18 100644
+--- a/qtbase/src/widgets/kernel/qwidget.cpp
++++ b/qtbase/src/widgets/kernel/qwidget.cpp
+@@ -5296,7 +5296,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
+         QWidgetEffectSourcePrivate *sourced = static_cast<QWidgetEffectSourcePrivate *>
+                                                          (source->d_func());
+         if (!sourced->context) {
+-            const QRegion effectRgn(rgn.boundingRect());
++            const QRegion effectRgn((flags & UseEffectRegionBounds) ? rgn.boundingRect() : rgn);
+             QWidgetPaintContext context(pdev, effectRgn, offset, flags, sharedPainter, repaintManager);
+             sourced->context = &context;
+             if (!sharedPainter) {
+@@ -5328,6 +5328,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
+         }
+     }
+ #endif // QT_CONFIG(graphicseffect)
++    flags = flags & ~UseEffectRegionBounds;
+ 
+     const bool alsoOnScreen = flags & DrawPaintOnScreen;
+     const bool recursive = flags & DrawRecursive;
+diff --git a/qtbase/src/widgets/kernel/qwidget_p.h b/qtbase/src/widgets/kernel/qwidget_p.h
+index eef6b8fa2c..c432f4b5d5 100644
+--- a/qtbase/src/widgets/kernel/qwidget_p.h
++++ b/qtbase/src/widgets/kernel/qwidget_p.h
+@@ -229,7 +229,8 @@ public:
+         DontSubtractOpaqueChildren = 0x10,
+         DontDrawOpaqueChildren = 0x20,
+         DontDrawNativeChildren = 0x40,
+-        DontSetCompositionMode = 0x80
++        DontSetCompositionMode = 0x80,
++        UseEffectRegionBounds = 0x100
+     };
+     Q_DECLARE_FLAGS(DrawWidgetFlags, DrawWidgetFlag)
+     Q_FLAG(DrawWidgetFlags)
+diff --git a/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp b/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
+index 02880b34da..0d44e1326d 100644
+--- a/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
++++ b/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
+@@ -1018,7 +1018,8 @@ void QWidgetRepaintManager::paintAndFlush()
+ 
+     // Paint the rest with composition.
+     if (repaintAllWidgets || !dirtyCopy.isEmpty()) {
+-        QWidgetPrivate::DrawWidgetFlags flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive;
++        QWidgetPrivate::DrawWidgetFlags flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive
++                | QWidgetPrivate::UseEffectRegionBounds;
+         tlw->d_func()->drawWidget(store->paintDevice(), dirtyCopy, QPoint(), flags, nullptr, this);
+     }
+ 
+diff --git a/qtbase/src/widgets/styles/qfusionstyle.cpp b/qtbase/src/widgets/styles/qfusionstyle.cpp
+index f4345d97c4..962912c838 100644
+--- a/qtbase/src/widgets/styles/qfusionstyle.cpp
++++ b/qtbase/src/widgets/styles/qfusionstyle.cpp
+@@ -1772,14 +1772,6 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio
+             proxy()->drawControl(CE_PushButtonLabel, &subopt, painter, widget);
+         }
+         break;
+-    case CE_PushButtonLabel:
+-        if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
+-            QStyleOptionButton b(*button);
+-            // no PM_ButtonShiftHorizontal and PM_ButtonShiftVertical for fusion style
+-            b.state &= ~(State_On | State_Sunken);
+-            QCommonStyle::drawControl(element, &b, painter, widget);
+-        }
+-        break;
+     case CE_MenuBarEmptyArea:
+         painter->save();
+     {
+diff --git a/qtbase/src/widgets/util/qcompleter.cpp b/qtbase/src/widgets/util/qcompleter.cpp
+index 18b24063d8..ef7207a8a3 100644
+--- a/qtbase/src/widgets/util/qcompleter.cpp
++++ b/qtbase/src/widgets/util/qcompleter.cpp
+@@ -1120,6 +1120,8 @@ void QCompleter::setModel(QAbstractItemModel *model)
+ {
+     Q_D(QCompleter);
+     QAbstractItemModel *oldModel = d->proxy->sourceModel();
++    if (oldModel == model)
++        return;
+ #if QT_CONFIG(filesystemmodel)
+     if (qobject_cast<const QFileSystemModel *>(oldModel))
+         setCompletionRole(Qt::EditRole); // QTBUG-54642, clear FileNameRole set by QFileSystemModel
+diff --git a/qtbase/src/widgets/widgets/qabstractbutton.cpp b/qtbase/src/widgets/widgets/qabstractbutton.cpp
+index a128b23950..dc40bf62fb 100644
+--- a/qtbase/src/widgets/widgets/qabstractbutton.cpp
++++ b/qtbase/src/widgets/widgets/qabstractbutton.cpp
+@@ -56,6 +56,7 @@
+ #ifndef QT_NO_ACCESSIBILITY
+ #include "qaccessible.h"
+ #endif
++#include <qpa/qplatformtheme.h>
+ 
+ #include <algorithm>
+ 
+@@ -1076,19 +1077,19 @@ void QAbstractButton::keyPressEvent(QKeyEvent *e)
+ {
+     Q_D(QAbstractButton);
+     bool next = true;
+-    switch (e->key()) {
+-    case Qt::Key_Enter:
+-    case Qt::Key_Return:
+-        e->ignore();
+-        break;
+-    case Qt::Key_Select:
+-    case Qt::Key_Space:
+-        if (!e->isAutoRepeat()) {
+-            setDown(true);
+-            repaint();
+-            d->emitPressed();
+-        }
+-        break;
++
++    const auto key = static_cast<Qt::Key>(e->key());
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(key) && !e->isAutoRepeat()) {
++        setDown(true);
++        repaint();
++        d->emitPressed();
++        return;
++    }
++
++    switch (key) {
+     case Qt::Key_Up:
+         next = false;
+         Q_FALLTHROUGH();
+@@ -1153,15 +1154,15 @@ void QAbstractButton::keyReleaseEvent(QKeyEvent *e)
+     if (!e->isAutoRepeat())
+         d->repeatTimer.stop();
+ 
+-    switch (e->key()) {
+-    case Qt::Key_Select:
+-    case Qt::Key_Space:
+-        if (!e->isAutoRepeat() && d->down)
+-            d->click();
+-        break;
+-    default:
+-        e->ignore();
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(static_cast<Qt::Key>(e->key())) && !e->isAutoRepeat() && d->down) {
++        d->click();
++        return;
+     }
++
++    e->ignore();
+ }
+ 
+ /*!\reimp
+diff --git a/qtbase/src/widgets/widgets/qcombobox.cpp b/qtbase/src/widgets/widgets/qcombobox.cpp
+index 7a496c27e0..0a3d96647b 100644
+--- a/qtbase/src/widgets/widgets/qcombobox.cpp
++++ b/qtbase/src/widgets/widgets/qcombobox.cpp
+@@ -3352,7 +3352,23 @@ void QComboBox::keyPressEvent(QKeyEvent *e)
+ 
+     Move move = NoMove;
+     int newIndex = currentIndex();
+-    switch (e->key()) {
++
++    bool pressLikeButton = !d->lineEdit;
++#ifdef QT_KEYPAD_NAVIGATION
++    pressLikeButton |= QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus();
++#endif
++    auto key = static_cast<Qt::Key>(e->key());
++    if (pressLikeButton) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(key)) {
++            showPopup();
++            return;
++        }
++    }
++
++    switch (key) {
+     case Qt::Key_Up:
+         if (e->modifiers() & Qt::ControlModifier)
+             break; // pass to line edit for auto completion
+@@ -3394,26 +3410,11 @@ void QComboBox::keyPressEvent(QKeyEvent *e)
+             return;
+         }
+         break;
+-    case Qt::Key_Space:
+-        if (!d->lineEdit) {
+-            showPopup();
+-            return;
+-        }
+-        break;
+-    case Qt::Key_Enter:
+-    case Qt::Key_Return:
+     case Qt::Key_Escape:
+         if (!d->lineEdit)
+             e->ignore();
+         break;
+ #ifdef QT_KEYPAD_NAVIGATION
+-    case Qt::Key_Select:
+-        if (QApplicationPrivate::keypadNavigationEnabled()
+-                && (!hasEditFocus() || !d->lineEdit)) {
+-            showPopup();
+-            return;
+-        }
+-        break;
+     case Qt::Key_Left:
+     case Qt::Key_Right:
+         if (QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus())
+diff --git a/qtbase/src/widgets/widgets/qdatetimeedit_p.h b/qtbase/src/widgets/widgets/qdatetimeedit_p.h
+index d36b6f8f9a..e0df5b5158 100644
+--- a/qtbase/src/widgets/widgets/qdatetimeedit_p.h
++++ b/qtbase/src/widgets/widgets/qdatetimeedit_p.h
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2018 The Qt Company Ltd.
++** Copyright (C) 2021 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtWidgets module of the Qt Toolkit.
+diff --git a/qtbase/src/widgets/widgets/qgroupbox.cpp b/qtbase/src/widgets/widgets/qgroupbox.cpp
+index 02a0bed325..3f3eccc370 100644
+--- a/qtbase/src/widgets/widgets/qgroupbox.cpp
++++ b/qtbase/src/widgets/widgets/qgroupbox.cpp
+@@ -54,6 +54,8 @@
+ #include "qaccessible.h"
+ #endif
+ #include <private/qwidget_p.h>
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
+ 
+ #include "qdebug.h"
+ 
+@@ -360,7 +362,10 @@ bool QGroupBox::event(QEvent *e)
+         return true;
+     case QEvent::KeyPress: {
+         QKeyEvent *k = static_cast<QKeyEvent*>(e);
+-        if (!k->isAutoRepeat() && (k->key() == Qt::Key_Select || k->key() == Qt::Key_Space)) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (!k->isAutoRepeat() && buttonPressKeys.contains(static_cast<Qt::Key>(k->key()))) {
+             d->pressedControl = QStyle::SC_GroupBoxCheckBox;
+             update(style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxCheckBox, this));
+             return true;
+@@ -369,7 +374,10 @@ bool QGroupBox::event(QEvent *e)
+     }
+     case QEvent::KeyRelease: {
+         QKeyEvent *k = static_cast<QKeyEvent*>(e);
+-        if (!k->isAutoRepeat() && (k->key() == Qt::Key_Select || k->key() == Qt::Key_Space)) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (!k->isAutoRepeat() && buttonPressKeys.contains(static_cast<Qt::Key>(k->key()))) {
+             bool toggle = (d->pressedControl == QStyle::SC_GroupBoxLabel
+                            || d->pressedControl == QStyle::SC_GroupBoxCheckBox);
+             d->pressedControl = QStyle::SC_None;
+diff --git a/qtbase/src/widgets/widgets/qlabel.cpp b/qtbase/src/widgets/widgets/qlabel.cpp
+index 30ff80cbb0..cf2605c17c 100644
+--- a/qtbase/src/widgets/widgets/qlabel.cpp
++++ b/qtbase/src/widgets/widgets/qlabel.cpp
+@@ -421,9 +421,6 @@ void QLabel::setPixmap(const QPixmap &pixmap)
+         d->pixmap = new QPixmap(pixmap);
+     }
+ 
+-    if (d->pixmap->depth() == 1 && !d->pixmap->mask())
+-        d->pixmap->setMask(*((QBitmap *)d->pixmap));
+-
+     d->updateLabel();
+ }
+ 
+diff --git a/qtbase/src/widgets/widgets/qtoolbararealayout.cpp b/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
+index 493c094cc1..d5f4b59017 100644
+--- a/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
++++ b/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
+@@ -1367,7 +1367,7 @@ bool QToolBarAreaLayout::restoreState(QDataStream &stream, const QList<QToolBar*
+                 item.widgetItem = new QWidgetItemV2(toolBar);
+                 toolBar->setOrientation(floating ? ((shown & 2) ? Qt::Vertical : Qt::Horizontal) : dock.o);
+                 toolBar->setVisible(shown & 1);
+-                toolBar->d_func()->setWindowState(floating, true, rect);
++                toolBar->d_func()->setWindowState(floating, false, rect);
+ 
+                 item.preferredSize = item.size;
+                 line.toolBarItems.append(item);
+diff --git a/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp b/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
+index 212c0a2e13..3c77b1ba0b 100644
+--- a/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
++++ b/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
+@@ -126,8 +126,7 @@ public:
+ 
+ void tst_QtConcurrentIterateKernel::instantiate()
+ {
+-    auto future = startThreadEngine(new PrintFor(0, 40)).startAsynchronously();
+-    future.waitForFinished();
++    startThreadEngine(new PrintFor(0, 40)).startBlocking();
+     QCOMPARE(iterations.loadRelaxed(), 40);
+ }
+ 
+@@ -166,10 +165,8 @@ void tst_QtConcurrentIterateKernel::stresstest()
+     const int times = 50;
+     for (int i = 0; i < times; ++i) {
+         counter.storeRelaxed(0);
+-        // ThreadEngine will delete f when it finishes
+-        auto f = new CountFor(0, iterations);
+-        auto future = f->startAsynchronously();
+-        future.waitForFinished();
++        CountFor f(0, iterations);
++        f.startBlocking();
+         QCOMPARE(counter.loadRelaxed(), iterations);
+     }
+ }
+@@ -177,11 +174,8 @@ void tst_QtConcurrentIterateKernel::stresstest()
+ void tst_QtConcurrentIterateKernel::noIterations()
+ {
+     const int times = 20000;
+-    for (int i = 0; i < times; ++i) {
+-        auto future = startThreadEngine(new IterateKernel<TestIterator, void>(0, 0))
+-                              .startAsynchronously();
+-        future.waitForFinished();
+-    }
++    for (int i = 0; i < times; ++i)
++        startThreadEngine(new IterateKernel<TestIterator, void>(0, 0)).startBlocking();
+ }
+ 
+ QMutex threadsMutex;
+@@ -236,10 +230,8 @@ void tst_QtConcurrentIterateKernel::throttling()
+ 
+     threads.clear();
+ 
+-    // ThreadEngine will delete f when it finishes
+-    auto f = new ThrottleFor(0, totalIterations);
+-    auto future = f->startAsynchronously();
+-    future.waitForFinished();
++    ThrottleFor f(0, totalIterations);
++    f.startBlocking();
+ 
+     QCOMPARE(iterations.loadRelaxed(), totalIterations);
+ 
+diff --git a/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp b/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
+index ac7be7acdd..81bc64c8d9 100644
+--- a/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
++++ b/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
+@@ -65,9 +65,16 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::runDirectly()
+ {
+-    PrintUser *engine = new PrintUser();
+-    QFuture<void> f = engine->startAsynchronously();
+-    f.waitForFinished();
++    {
++        PrintUser engine;
++        engine.startSingleThreaded();
++        engine.startBlocking();
++    }
++    {
++        PrintUser *engine = new PrintUser();
++        QFuture<void> f = engine->startAsynchronously();
++        f.waitForFinished();
++    }
+ }
+ 
+ class StringResultUser : public ThreadEngine<QString>
+@@ -99,10 +106,8 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::result()
+ {
+-    // ThreadEngine will delete 'engine' when it finishes
+-    auto engine = new StringResultUser();
+-    auto future = engine->startAsynchronously();
+-    QCOMPARE(future.result(), QString("Foo"));
++    StringResultUser engine;
++    QCOMPARE(*engine.startBlocking(), QString("Foo"));
+ }
+ 
+ class VoidResultUser : public ThreadEngine<void>
+@@ -128,9 +133,17 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::runThroughStarter()
+ {
+-    ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
+-    QFuture<QString> f = starter.startAsynchronously();
+-    QCOMPARE(f.result(), QString("Foo"));
++    {
++        ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
++        QFuture<QString>  f = starter.startAsynchronously();
++        QCOMPARE(f.result(), QString("Foo"));
++    }
++
++    {
++        ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
++        QString str = starter.startBlocking();
++        QCOMPARE(str, QString("Foo"));
++    }
+ }
+ 
+ class CancelUser : public ThreadEngine<void>
+@@ -213,6 +226,12 @@ void tst_QtConcurrentThreadEngine::throttle()
+         f.waitForFinished();
+         QCOMPARE(count.loadRelaxed(), 0);
+     }
++
++    for (int i = 0; i < repeats; ++i) {
++        ThrottleAlwaysUser t;
++        t.startBlocking();
++        QCOMPARE(count.loadRelaxed(), 0);
++    }
+ }
+ 
+ QSet<QThread *> threads;
+@@ -249,17 +268,35 @@ void tst_QtConcurrentThreadEngine::threadCount()
+ {
+     const int repeats = 10;
+     for (int i = 0; i < repeats; ++i) {
++        ThreadCountUser t;
++        t.startBlocking();
++        int count = threads.count();
++        int count_expected = QThreadPool::globalInstance()->maxThreadCount() + 1; // +1 for the main thread.
++        if (count != count_expected)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, count_expected);
++
+         (new ThreadCountUser())->startAsynchronously().waitForFinished();
+-        const auto count = threads.count();
+-        const auto maxThreadCount = QThreadPool::globalInstance()->maxThreadCount();
+-        QVERIFY(count <= maxThreadCount);
+-        QVERIFY(!threads.contains(QThread::currentThread()));
++        count = threads.count();
++        count_expected = QThreadPool::globalInstance()->maxThreadCount();
++        if (count != count_expected)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, count_expected);
+     }
+ 
+     // Set the finish flag immediately, this should give us one thread only.
+     for (int i = 0; i < repeats; ++i) {
++        ThreadCountUser t(true /*finishImmediately*/);
++        t.startBlocking();
++        int count = threads.count();
++        if (count != 1)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, 1);
++
+         (new ThreadCountUser(true /*finishImmediately*/))->startAsynchronously().waitForFinished();
+-        const auto count = threads.count();
++        count = threads.count();
++        if (count != 1)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
+         QCOMPARE(count, 1);
+         QVERIFY(!threads.contains(QThread::currentThread()));
+     }
+@@ -400,6 +437,7 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::exceptions()
+ {
++    // Asynchronous mode:
+     {
+         bool caught = false;
+         try  {
+@@ -412,6 +450,32 @@ void tst_QtConcurrentThreadEngine::exceptions()
+         QVERIFY2(caught, "did not get exception");
+     }
+ 
++    // Blocking mode:
++    // test throwing the exception from a worker thread.
++    {
++        bool caught = false;
++        try  {
++            QtConcurrentExceptionThrower e(QThread::currentThread());
++            e.startBlocking();
++        } catch (const QException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // test throwing the exception from the main thread (different code path)
++    {
++        bool caught = false;
++        try  {
++            QtConcurrentExceptionThrower e(0);
++            e.startBlocking();
++        } catch (const QException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // Asynchronous mode:
+     {
+         bool caught = false;
+         try  {
+@@ -423,6 +487,31 @@ void tst_QtConcurrentThreadEngine::exceptions()
+         }
+         QVERIFY2(caught, "did not get exception");
+     }
++
++    // Blocking mode:
++    // test throwing the exception from a worker thread.
++    {
++        bool caught = false;
++        try  {
++            UnrelatedExceptionThrower e(QThread::currentThread());
++            e.startBlocking();
++        } catch (const QUnhandledException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // test throwing the exception from the main thread (different code path)
++    {
++        bool caught = false;
++        try  {
++            UnrelatedExceptionThrower e(0);
++            e.startBlocking();
++        } catch (const QUnhandledException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
+ }
+ 
+ #endif
+diff --git a/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp b/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
+index 4968742110..f4c3fb711d 100644
+--- a/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
++++ b/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
+@@ -42,6 +42,7 @@ private slots:
+     void writeBlock_data();
+     void writeBlock();
+     void seek();
++    void invalidSeeks();
+     void seekTest_data();
+     void seekTest();
+     void read_rawdata();
+@@ -286,6 +287,29 @@ void tst_QBuffer::seek()
+     QCOMPARE(buffer.size(), pos);
+ }
+ 
++void tst_QBuffer::invalidSeeks()
++{
++    if constexpr (sizeof(qsizetype) == sizeof(qint64)) {
++        // sizeof(qsizetype) == sizeof(qint64), so +1 would overflow
++        QSKIP("This is a 32-bit-only test.");
++    } else {
++        QBuffer buffer;
++        buffer.open(QIODevice::WriteOnly);
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++        constexpr qint64 MaxQByteArrayCapacity = (std::numeric_limits<qsizetype>::max)();
++        // this should fail fast, not after trying to allocate nearly 2 GiB of data,
++        // potentially crashing in the process:
++        QVERIFY(!buffer.seek(2 * MaxQByteArrayCapacity - 1));
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++        // ditto:
++        QVERIFY(!buffer.seek(MaxQByteArrayCapacity + 1));
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++    }
++}
++
+ void tst_QBuffer::seekTest_data()
+ {
+     writeBlock_data();
+diff --git a/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp b/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
+index da5327594c..4a04e0f7c6 100644
+--- a/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
++++ b/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
+@@ -561,7 +561,8 @@ protected:
+     qint64 readData(char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf->size() - offset));
+-        memcpy(data, buf->constData() + offset, maxSize);
++        if (maxSize > 0)
++            memcpy(data, buf->constData() + offset, maxSize);
+         offset += maxSize;
+         return maxSize;
+     }
+@@ -604,13 +605,15 @@ protected:
+     qint64 readData(char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf.size() - pos()));
+-        memcpy(data, buf.constData() + pos(), maxSize);
++        if (maxSize > 0)
++            memcpy(data, buf.constData() + pos(), maxSize);
+         return maxSize;
+     }
+     qint64 writeData(const char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf.size() - pos()));
+-        memcpy(buf.data() + pos(), data, maxSize);
++        if (maxSize > 0)
++            memcpy(buf.data() + pos(), data, maxSize);
+         return maxSize;
+     }
+ 
+diff --git a/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+index db60bead64..f345a44414 100644
+--- a/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
++++ b/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+@@ -1,7 +1,8 @@
+ /****************************************************************************
+ **
+ ** Copyright (C) 2021 The Qt Company Ltd.
+-** Copyright (C) 2020 Intel Corporation.
++** Copyright (C) 2020 The Qt Company Ltd.
++** Copyright (C) 2022 Intel Corporation.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the test suite of the Qt Toolkit.
+@@ -150,6 +151,8 @@ private slots:
+     void startStopStartStopBuffers();
+     void processEventsInAReadyReadSlot_data();
+     void processEventsInAReadyReadSlot();
++    void startFromCurrentWorkingDir_data();
++    void startFromCurrentWorkingDir();
+ 
+     // keep these at the end, since they use lots of processes and sometimes
+     // caused obscure failures to occur in tests that followed them (esp. on the Mac)
+@@ -2731,5 +2734,94 @@ void tst_QProcess::finishProcessBeforeReadingDone_deprecated()
+ 
+ #endif
+ 
++enum class ChdirMode {
++    None = 0,
++    InParent,
++    InChild
++};
++Q_DECLARE_METATYPE(ChdirMode)
++
++void tst_QProcess::startFromCurrentWorkingDir_data()
++{
++    qRegisterMetaType<ChdirMode>();
++    QTest::addColumn<QString>("programPrefix");
++    QTest::addColumn<ChdirMode>("chdirMode");
++    QTest::addColumn<bool>("success");
++
++    constexpr bool IsWindows = true
++#ifdef Q_OS_UNIX
++            && false
++#endif
++            ;
++
++    // baseline: trying to execute the directory, this can't possibly succeed!
++    QTest::newRow("plain-same-cwd") << QString() << ChdirMode::None << false;
++
++    // cross-platform behavior: neither OS searches the setWorkingDirectory()
++    // dir without "./"
++    QTest::newRow("plain-child-chdir") << QString() << ChdirMode::InChild << false;
++
++    // cross-platform behavior: both OSes search the parent's CWD with "./"
++    QTest::newRow("prefixed-parent-chdir") << "./" << ChdirMode::InParent << true;
++
++    // opposite behaviors: Windows searches the parent's CWD and Unix searches
++    // the child's with "./"
++    QTest::newRow("prefixed-child-chdir") << "./" << ChdirMode::InChild << !IsWindows;
++
++    // Windows searches the parent's CWD without "./"
++    QTest::newRow("plain-parent-chdir") << QString() << ChdirMode::InParent << IsWindows;
++}
++
++void tst_QProcess::startFromCurrentWorkingDir()
++{
++    QFETCH(QString, programPrefix);
++    QFETCH(ChdirMode, chdirMode);
++    QFETCH(bool, success);
++
++    QProcess process;
++    qRegisterMetaType<QProcess::ProcessError>();
++    QSignalSpy errorSpy(&process, &QProcess::errorOccurred);
++    QVERIFY(errorSpy.isValid());
++
++    // both the dir name and the executable name
++    const QString target = QStringLiteral("testProcessNormal");
++    process.setProgram(programPrefix + target);
++
++#ifdef Q_OS_UNIX
++    // Reset PATH, to be sure it doesn't contain . or the empty path.
++    // We can't do this on Windows because DLLs are searched in PATH
++    // and Windows always searches "." anyway.
++    auto restoreEnv = qScopeGuard([old = qgetenv("PATH")] {
++        qputenv("PATH", old);
++    });
++    qputenv("PATH", "/");
++#endif
++
++    switch (chdirMode) {
++    case ChdirMode::InParent: {
++        auto restoreCwd = qScopeGuard([old = QDir::currentPath()] {
++            QDir::setCurrent(old);
++        });
++        QVERIFY(QDir::setCurrent(target));
++        process.start();
++        break;
++    }
++    case ChdirMode::InChild:
++        process.setWorkingDirectory(target);
++        Q_FALLTHROUGH();
++    case ChdirMode::None:
++        process.start();
++        break;
++    }
++
++    QCOMPARE(process.waitForStarted(), success);
++    QCOMPARE(errorSpy.count(), int(!success));
++    if (success) {
++        QVERIFY(process.waitForFinished());
++    } else {
++        QCOMPARE(process.error(), QProcess::FailedToStart);
++    }
++}
++
+ QTEST_MAIN(tst_QProcess)
+ #include "tst_qprocess.moc"
+diff --git a/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp b/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp
+index e1ea7a4552..90972caa57 100644
+--- a/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp
++++ b/qtbase/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"
+diff --git a/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+index 9bd66c0835..ed4a0bae5d 100644
+--- a/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
++++ b/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+@@ -158,6 +158,7 @@ private slots:
+     void nullReceiver();
+     void functorReferencesConnection();
+     void disconnectDisconnects();
++    void declarativeData();
+ };
+ 
+ struct QObjectCreatedOnShutdown
+@@ -7679,5 +7680,81 @@ void tst_QObject::disconnectDisconnects()
+ Q_STATIC_ASSERT(QtPrivate::HasQ_OBJECT_Macro<tst_QObject>::Value);
+ Q_STATIC_ASSERT(!QtPrivate::HasQ_OBJECT_Macro<SiblingDeleter>::Value);
+ 
++#ifdef QT_BUILD_INTERNAL
++/*
++    Since QObjectPrivate stores the declarativeData pointer in a union with the pointer
++    to the currently destroyed child, calls to the QtDeclarative handlers need to be
++    correctly guarded. QTBUG-105286
++*/
++namespace QtDeclarative {
++static QAbstractDeclarativeData *theData;
++
++static void destroyed(QAbstractDeclarativeData *data, QObject *)
++{
++    QCOMPARE(data, theData);
++}
++static void signalEmitted(QAbstractDeclarativeData *data, QObject *, int, void **)
++{
++    QCOMPARE(data, theData);
++}
++// we can't use QCOMPARE in the next two functions, as they don't return void
++static int receivers(QAbstractDeclarativeData *data, const QObject *, int)
++{
++    QTest::qCompare(data, theData, "data", "theData", __FILE__, __LINE__);
++    return 0;
++}
++static bool isSignalConnected(QAbstractDeclarativeData *data, const QObject *, int)
++{
++    QTest::qCompare(data, theData, "data", "theData", __FILE__, __LINE__);
++    return true;
++}
++
++class Object : public QObject
++{
++    Q_OBJECT
++public:
++    using QObject::QObject;
++    ~Object()
++    {
++        if (Object *p = static_cast<Object *>(parent()))
++            p->emitSignal();
++    }
++
++    void emitSignal()
++    {
++        emit theSignal();
++    }
++
++signals:
++    void theSignal();
++};
++
++}
++#endif
++
++void tst_QObject::declarativeData()
++{
++#ifdef QT_BUILD_INTERNAL
++    QScopedValueRollback destroyed(QAbstractDeclarativeData::destroyed,
++                                   QtDeclarative::destroyed);
++    QScopedValueRollback signalEmitted(QAbstractDeclarativeData::signalEmitted,
++                                       QtDeclarative::signalEmitted);
++    QScopedValueRollback receivers(QAbstractDeclarativeData::receivers,
++                                   QtDeclarative::receivers);
++    QScopedValueRollback isSignalConnected(QAbstractDeclarativeData::isSignalConnected,
++                                           QtDeclarative::isSignalConnected);
++
++    QtDeclarative::Object p;
++    QObjectPrivate *priv = QObjectPrivate::get(&p);
++    priv->declarativeData = QtDeclarative::theData = new QAbstractDeclarativeData;
++
++    connect(&p, &QtDeclarative::Object::theSignal, &p, []{
++    });
++
++    QtDeclarative::Object *child = new QtDeclarative::Object;
++    child->setParent(&p);
++#endif
++}
++
+ QTEST_MAIN(tst_QObject)
+ #include "tst_qobject.moc"
+diff --git a/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp b/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
+index 0ea422ecbc..1a3256534b 100644
+--- a/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
++++ b/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
+@@ -70,15 +70,15 @@ static inline QString testSuiteWarning()
+ 
+     QString result;
+     QTextStream str(&result);
+-    str << "\nCannot find the shared-mime-info test suite\nstarting from: "
++    str << "\nCannot find the shared-mime-info test suite\nin the parent of: "
+         << QDir::toNativeSeparators(QDir::currentPath()) << "\n"
+            "cd " << QDir::toNativeSeparators(QStringLiteral("tests/auto/corelib/mimetypes/qmimedatabase")) << "\n"
+-           "wget http://cgit.freedesktop.org/xdg/shared-mime-info/snapshot/Release-1-10.zip\n"
+-           "unzip Release-1-10.zip\n";
++           "wget https://gitlab.freedesktop.org/xdg/shared-mime-info/-/archive/2.1/shared-mime-info-2.1.zip\n"
++           "unzip shared-mime-info-2.1.zip\n";
+ #ifdef Q_OS_WIN
+-    str << "mkdir testfiles\nxcopy /s Release-1-10 s-m-i\n";
++    str << "mkdir testfiles\nxcopy /s shared-mime-info-2.1 s-m-i\n";
+ #else
+-    str << "ln -s Release-1-10 s-m-i\n";
++    str << "ln -s shared-mime-info-2.1 s-m-i\n";
+ #endif
+     return result;
+ }
+@@ -154,7 +154,7 @@ void tst_QMimeDatabase::initTestCase()
+     QVERIFY2(copyResourceFile(xmlFileName, xmlTargetFileName, &errorMessage), qPrintable(errorMessage));
+ #endif
+ 
+-    m_testSuite = QFINDTESTDATA("s-m-i/tests");
++    m_testSuite = QFINDTESTDATA("s-m-i/tests/mime-detection");
+     if (m_testSuite.isEmpty())
+         qWarning("%s", qPrintable(testSuiteWarning()));
+ 
+@@ -611,7 +611,7 @@ void tst_QMimeDatabase::allMimeTypes()
+     QVERIFY(!lst.isEmpty());
+ 
+     // Hardcoding this is the only way to check both providers find the same number of mimetypes.
+-    QCOMPARE(lst.count(), 779);
++    QCOMPARE(lst.count(), 811);
+ 
+     foreach (const QMimeType &mime, lst) {
+         const QString name = mime.name();
+@@ -631,10 +631,9 @@ void tst_QMimeDatabase::suffixes_data()
+ 
+     QTest::newRow("mimetype with a single pattern") << "application/pdf" << "*.pdf" << "pdf";
+     QTest::newRow("mimetype with multiple patterns") << "application/x-kpresenter" << "*.kpr;*.kpt" << "kpr";
+-    QTest::newRow("jpeg") << "image/jpeg" << "*.jpe;*.jpg;*.jpeg" << "jpeg";
+-    //if (KMimeType::sharedMimeInfoVersion() > KDE_MAKE_VERSION(0, 60, 0)) {
+-        QTest::newRow("mimetype with many patterns") << "application/vnd.wordperfect" << "*.wp;*.wp4;*.wp5;*.wp6;*.wpd;*.wpp" << "wp";
+-    //}
++    // The preferred suffix for image/jpeg is *.jpg, as per https://bugs.kde.org/show_bug.cgi?id=176737
++    QTest::newRow("jpeg") << "image/jpeg" << "*.jpe;*.jpg;*.jpeg" << "jpg";
++    QTest::newRow("mimetype with many patterns") << "application/vnd.wordperfect" << "*.wp;*.wp4;*.wp5;*.wp6;*.wpd;*.wpp" << "wp";
+     QTest::newRow("oasis text mimetype") << "application/vnd.oasis.opendocument.text" << "*.odt" << "odt";
+     QTest::newRow("oasis presentation mimetype") << "application/vnd.oasis.opendocument.presentation" << "*.odp" << "odp";
+     QTest::newRow("mimetype with multiple patterns") << "text/plain" << "*.asc;*.txt;*,v" << "txt";
+diff --git a/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp b/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
+index 3e58dd03cc..c8f82ef5d5 100644
+--- a/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
++++ b/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
+@@ -176,6 +176,8 @@ private Q_SLOTS:
+     void fromToVariantConversions_data();
+     void fromToVariantConversions();
+ 
++    void noLeakOnNameClash();
++
+ private:
+     QString testDataDir;
+ };
+@@ -3685,5 +3687,23 @@ void tst_QtJson::fromToVariantConversions()
+     }
+ }
+ 
++void tst_QtJson::noLeakOnNameClash()
++{
++    QJsonDocument doc = QJsonDocument::fromJson("{\"\":{\"\":0},\"\":0}");
++    QVERIFY(!doc.isNull());
++    const QJsonObject obj = doc.object();
++
++    // Removed the duplicate key.
++    QCOMPARE(obj.length(), 1);
++
++    // Retained the last of the duplicates.
++    const QJsonValue val = obj.begin().value();
++    QVERIFY(val.isDouble());
++    QCOMPARE(val.toDouble(), 0.0);
++
++    // It should not leak.
++    // In particular it should not forget to deref the container for the inner object.
++}
++
+ QTEST_MAIN(tst_QtJson)
+ #include "tst_qtjson.moc"
+diff --git a/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp b/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
+index a59b58d57f..241c3e84ac 100644
+--- a/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
++++ b/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
+@@ -63,6 +63,7 @@ private slots:
+     void isValidId_data();
+     void isValidId();
+     void malformed();
++    void serialize();
+     // Backend tests
+     void utcTest();
+     void icuTest();
+@@ -947,6 +948,33 @@ void tst_QTimeZone::malformed()
+         barf.offsetFromUtc(now);
+ }
+ 
++void tst_QTimeZone::serialize()
++{
++    int parts = 0;
++#ifndef QT_NO_DEBUG_STREAM
++    qDebug() << QTimeZone(); // to verify no crash
++    parts++;
++#endif
++#ifndef QT_NO_DATASTREAM
++    QByteArray blob;
++    {
++        QDataStream stream(&blob, QIODevice::WriteOnly);
++        stream << QTimeZone("Europe/Oslo") << QTimeZone(420) << QTimeZone() << qint64(-1);
++    }
++    QDataStream stream(&blob, QIODevice::ReadOnly);
++    QTimeZone invalid, offset, oslo;
++    qint64 minusone;
++    stream >> oslo >> offset >> invalid >> minusone;
++    QCOMPARE(oslo, QTimeZone("Europe/Oslo"));
++    QCOMPARE(offset, QTimeZone(420));
++    QVERIFY(!invalid.isValid());
++    QCOMPARE(minusone, qint64(-1));
++    parts++;
++#endif
++    if (!parts)
++        QSKIP("No serialization enabled");
++}
++
+ void tst_QTimeZone::utcTest()
+ {
+ #ifdef QT_BUILD_INTERNAL
+diff --git a/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp b/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
+index 05480c6dd2..70f4c75756 100644
+--- a/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
++++ b/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
+@@ -324,6 +324,13 @@ void tst_QDBusInterface::notValid()
+ 
+     QVERIFY(!interface.isValid());
+     QVERIFY(!QMetaObject::invokeMethod(&interface, "ListNames", Qt::DirectConnection));
++
++    // With a connection, but empty/null service and path specified
++    QDBusConnection con = QDBusConnection::sessionBus();
++    QVERIFY(con.isConnected());
++    QDBusInterface iface({}, {}, {}, con);
++    QVERIFY(!iface.isValid());
++    QVERIFY(!QMetaObject::invokeMethod(&interface, "ListNames", Qt::DirectConnection));
+ }
+ 
+ void tst_QDBusInterface::notValidDerived()
+diff --git a/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp b/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
+index 874468c954..04ceb4ab65 100644
+--- a/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
++++ b/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
+@@ -507,6 +507,10 @@ void tst_QKeySequence::toStringFromKeycode_data()
+     QTest::newRow("Ctrl+Alt+Num+Del") << QKeySequence(Qt::ControlModifier | Qt::AltModifier | Qt::KeypadModifier | Qt::Key_Delete) << "Ctrl+Alt+Num+Del";
+     QTest::newRow("Ctrl+Ins") << QKeySequence(Qt::ControlModifier | Qt::Key_Insert) << "Ctrl+Ins";
+     QTest::newRow("Ctrl+Num+Ins(1)") << QKeySequence(Qt::Key_Insert | Qt::KeypadModifier | Qt::ControlModifier) << "Ctrl+Num+Ins";
++    QTest::newRow("Ctrl") << QKeySequence(Qt::Key_Control) << "Control";
++    QTest::newRow("Alt") << QKeySequence(Qt::Key_Alt) << "Alt";
++    QTest::newRow("Shift") << QKeySequence(Qt::Key_Shift) << "Shift";
++    QTest::newRow("Meta") << QKeySequence(Qt::Key_Meta) << "Meta";
+ }
+ 
+ void tst_QKeySequence::toStringFromKeycode()
+diff --git a/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp b/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+index 15e0ecadaa..b4eca74283 100644
+--- a/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
++++ b/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+@@ -81,6 +81,8 @@ private slots:
+     void registerOpenTypePreferredNamesSystem();
+     void registerOpenTypePreferredNamesApplication();
+ 
++    void stretchRespected();
++
+ private:
+     QString m_ledFont;
+     QString m_testFont;
+@@ -355,6 +357,28 @@ static QString testString()
+     return QStringLiteral("foo bar");
+ }
+ 
++void tst_QFontDatabase::stretchRespected()
++{
++    int italicId = QFontDatabase::addApplicationFont(m_testFontItalic);
++    QVERIFY(italicId != -1);
++
++    QVERIFY(!QFontDatabase::applicationFontFamilies(italicId).isEmpty());
++
++    QString italicFontName = QFontDatabase::applicationFontFamilies(italicId).first();
++
++    QFont italicFont = QFontDatabase().font(italicFontName,
++                                            QString::fromLatin1("Italic"), 14);
++    QVERIFY(italicFont.italic());
++
++    QFont italicStretchedFont = italicFont;
++    italicStretchedFont.setStretch( 400 );
++
++    QVERIFY(QFontMetricsF(italicFont).horizontalAdvance(QStringLiteral("foobar")) <
++            QFontMetricsF(italicStretchedFont).horizontalAdvance(QStringLiteral("foobar")));
++
++    QFontDatabase::removeApplicationFont(italicId);
++}
++
+ void tst_QFontDatabase::condensedFontWidthNoFontMerging()
+ {
+     int regularFontId = QFontDatabase::addApplicationFont(m_testFont);
+diff --git a/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+index 3d4a094c43..b423e11a99 100644
+--- a/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
++++ b/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+@@ -281,6 +281,7 @@ private Q_SLOTS:
+     void ioGetFromFileSpecial();
+     void ioGetFromFile_data();
+     void ioGetFromFile();
++    void ioGetFromFileUrl();
+     void ioGetFromFtp_data();
+     void ioGetFromFtp();
+     void ioGetFromFtpWithReuse();
+@@ -3300,6 +3301,18 @@ void tst_QNetworkReply::ioGetFromFile()
+     QCOMPARE(reader.data, data);
+ }
+ 
++void tst_QNetworkReply::ioGetFromFileUrl()
++{
++    // This immediately fails on non-windows platforms:
++    QNetworkRequest request(QUrl("file://unc-server/some/path"));
++    QNetworkReplyPtr reply(manager.get(request));
++    QSignalSpy finishedSpy(reply.get(), &QNetworkReply::finished);
++    // QTBUG-105618: This would, on non-Windows platforms, never happen because the signal
++    // was emitted before the constructor finished, leaving no chance at all to connect to the
++    // signal
++    QVERIFY(finishedSpy.wait());
++}
++
+ void tst_QNetworkReply::ioGetFromFtp_data()
+ {
+     QTest::addColumn<QString>("fileName");
+diff --git a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
+index 069fa6b341..4cc4d9a5ea 100644
+--- a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
++++ b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
+@@ -1,75 +1,34 @@
+-Certificate:
+-    Data:
+-        Version: 3 (0x2)
+-        Serial Number: 0 (0x0)
+-        Signature Algorithm: sha1WithRSAEncryption
+-        Issuer: C=NO, ST=Oslo, L=Nydalen, O=Nokia Corporation and/or its subsidiary(-ies), OU=Development, CN=fluke.troll.no/emailAddress=ahanssen@trolltech.com
+-        Validity
+-            Not Before: Dec  4 01:10:32 2007 GMT
+-            Not After : Apr 21 01:10:32 2035 GMT
+-        Subject: C=NO, ST=Oslo, O=Nokia Corporation and/or its subsidiary(-ies), OU=Development, CN=fluke.troll.no
+-        Subject Public Key Info:
+-            Public Key Algorithm: rsaEncryption
+-            RSA Public Key: (1024 bit)
+-                Modulus (1024 bit):
+-                    00:a7:c8:a0:4a:c4:19:05:1b:66:ba:32:e2:d2:f1:
+-                    1c:6f:17:82:e4:39:2e:01:51:90:db:04:34:32:11:
+-                    21:c2:0d:6f:59:d8:53:90:54:3f:83:8f:a9:d3:b3:
+-                    d5:ee:1a:9b:80:ae:c3:25:c9:5e:a5:af:4b:60:05:
+-                    aa:a0:d1:91:01:1f:ca:04:83:e3:58:1c:99:32:45:
+-                    84:70:72:58:03:98:4a:63:8b:41:f5:08:49:d2:91:
+-                    02:60:6b:e4:64:fe:dd:a0:aa:74:08:e9:34:4c:91:
+-                    5f:12:3d:37:4d:54:2c:ad:7f:5b:98:60:36:02:8c:
+-                    3b:f6:45:f3:27:6a:9b:94:9d
+-                Exponent: 65537 (0x10001)
+-        X509v3 extensions:
+-            X509v3 Basic Constraints: 
+-                CA:FALSE
+-            Netscape Comment: 
+-                OpenSSL Generated Certificate
+-            X509v3 Subject Key Identifier: 
+-                21:85:04:3D:23:01:66:E5:F7:9F:1A:84:24:8A:AF:0A:79:F4:E5:AC
+-            X509v3 Authority Key Identifier: 
+-                DirName:/C=NO/ST=Oslo/L=Nydalen/O=Nokia Corporation and/or its subsidiary(-ies)/OU=Development/CN=fluke.troll.no/emailAddress=ahanssen@trolltech.com
+-                serial:8E:A8:B4:E8:91:B7:54:2E
+-
+-    Signature Algorithm: sha1WithRSAEncryption
+-        6d:57:5f:d1:05:43:f0:62:05:ec:2a:71:a5:dc:19:08:f2:c4:
+-        a6:bd:bb:25:d9:ca:89:01:0e:e4:cf:1f:c1:8c:c8:24:18:35:
+-        53:59:7b:c0:43:b4:32:e6:98:b2:a6:ef:15:05:0b:48:5f:e1:
+-        a0:0c:97:a9:a1:77:d8:35:18:30:bc:a9:8f:d3:b7:54:c7:f1:
+-        a9:9e:5d:e6:19:bf:f6:3c:5b:2b:d8:e4:3e:62:18:88:8b:d3:
+-        24:e1:40:9b:0c:e6:29:16:62:ab:ea:05:24:70:36:aa:55:93:
+-        ef:02:81:1b:23:10:a2:04:eb:56:95:75:fc:f8:94:b1:5d:42:
+-        c5:3f:36:44:85:5d:3a:2e:90:46:8a:a2:b9:6f:87:ae:0c:15:
+-        40:19:31:90:fc:3b:25:bb:ae:f1:66:13:0d:85:90:d9:49:34:
+-        8f:f2:5d:f9:7a:db:4d:5d:27:f6:76:9d:35:8c:06:a6:4c:a3:
+-        b1:b2:b6:6f:1d:d7:a3:00:fd:72:eb:9e:ea:44:a1:af:21:34:
+-        7d:c7:42:e2:49:91:19:8b:c0:ad:ba:82:80:a8:71:70:f4:35:
+-        31:91:63:84:20:95:e9:60:af:64:8b:cc:ff:3d:8a:76:74:3d:
+-        c8:55:6d:e4:8e:c3:2b:1c:e8:42:18:ae:9f:e6:6b:9c:34:06:
+-        ec:6a:f2:c3
+ -----BEGIN CERTIFICATE-----
+-MIIEEzCCAvugAwIBAgIBADANBgkqhkiG9w0BAQUFADCBnDELMAkGA1UEBhMCTk8x
+-DTALBgNVBAgTBE9zbG8xEDAOBgNVBAcTB055ZGFsZW4xFjAUBgNVBAoTDVRyb2xs
+-dGVjaCBBU0ExFDASBgNVBAsTC0RldmVsb3BtZW50MRcwFQYDVQQDEw5mbHVrZS50
+-cm9sbC5ubzElMCMGCSqGSIb3DQEJARYWYWhhbnNzZW5AdHJvbGx0ZWNoLmNvbTAe
+-Fw0wNzEyMDQwMTEwMzJaFw0zNTA0MjEwMTEwMzJaMGMxCzAJBgNVBAYTAk5PMQ0w
+-CwYDVQQIEwRPc2xvMRYwFAYDVQQKEw1Ucm9sbHRlY2ggQVNBMRQwEgYDVQQLEwtE
+-ZXZlbG9wbWVudDEXMBUGA1UEAxMOZmx1a2UudHJvbGwubm8wgZ8wDQYJKoZIhvcN
+-AQEBBQADgY0AMIGJAoGBAKfIoErEGQUbZroy4tLxHG8XguQ5LgFRkNsENDIRIcIN
+-b1nYU5BUP4OPqdOz1e4am4CuwyXJXqWvS2AFqqDRkQEfygSD41gcmTJFhHByWAOY
+-SmOLQfUISdKRAmBr5GT+3aCqdAjpNEyRXxI9N01ULK1/W5hgNgKMO/ZF8ydqm5Sd
+-AgMBAAGjggEaMIIBFjAJBgNVHRMEAjAAMCwGCWCGSAGG+EIBDQQfFh1PcGVuU1NM
+-IEdlbmVyYXRlZCBDZXJ0aWZpY2F0ZTAdBgNVHQ4EFgQUIYUEPSMBZuX3nxqEJIqv
+-Cnn05awwgbsGA1UdIwSBszCBsKGBoqSBnzCBnDELMAkGA1UEBhMCTk8xDTALBgNV
+-BAgTBE9zbG8xEDAOBgNVBAcTB055ZGFsZW4xFjAUBgNVBAoTDVRyb2xsdGVjaCBB
+-U0ExFDASBgNVBAsTC0RldmVsb3BtZW50MRcwFQYDVQQDEw5mbHVrZS50cm9sbC5u
+-bzElMCMGCSqGSIb3DQEJARYWYWhhbnNzZW5AdHJvbGx0ZWNoLmNvbYIJAI6otOiR
+-t1QuMA0GCSqGSIb3DQEBBQUAA4IBAQBtV1/RBUPwYgXsKnGl3BkI8sSmvbsl2cqJ
+-AQ7kzx/BjMgkGDVTWXvAQ7Qy5piypu8VBQtIX+GgDJepoXfYNRgwvKmP07dUx/Gp
+-nl3mGb/2PFsr2OQ+YhiIi9Mk4UCbDOYpFmKr6gUkcDaqVZPvAoEbIxCiBOtWlXX8
+-+JSxXULFPzZEhV06LpBGiqK5b4euDBVAGTGQ/Dslu67xZhMNhZDZSTSP8l35ettN
+-XSf2dp01jAamTKOxsrZvHdejAP1y657qRKGvITR9x0LiSZEZi8CtuoKAqHFw9DUx
+-kWOEIJXpYK9ki8z/PYp2dD3IVW3kjsMrHOhCGK6f5mucNAbsavLD
++MIIF6zCCA9OgAwIBAgIUfo9amJtJGWqWE6f+SkAO85zkGr4wDQYJKoZIhvcNAQEL
++BQAwgYMxCzAJBgNVBAYTAk5PMQ0wCwYDVQQIDARPc2xvMQ0wCwYDVQQHDARPc2xv
++MRcwFQYDVQQKDA5UaGUgUXQgQ29tcGFueTEMMAoGA1UECwwDUiZEMRIwEAYDVQQD
++DAlIMiBUZXN0ZXIxGzAZBgkqhkiG9w0BCQEWDG1pbmltaUBxdC5pbzAgFw0yMDEw
++MjYxMjAxMzFaGA8yMTIwMTAwMjEyMDEzMVowgYMxCzAJBgNVBAYTAk5PMQ0wCwYD
++VQQIDARPc2xvMQ0wCwYDVQQHDARPc2xvMRcwFQYDVQQKDA5UaGUgUXQgQ29tcGFu
++eTEMMAoGA1UECwwDUiZEMRIwEAYDVQQDDAlIMiBUZXN0ZXIxGzAZBgkqhkiG9w0B
++CQEWDG1pbmltaUBxdC5pbzCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIB
++AOiUp5+E4blouKH7q+rVNR8NoYX2XkBW+q+rpy1zu5ssRSzbqxAjDx9dkht7Qlnf
++VlDT00JvpOWdeuPon5915edQRsY4Unl6mKH29ra3OtUa1/yCJXsGVJTKCj7k4Bxb
++5mZzb/fTlZntMLdTIBMfUbw62FKir1WjKIcJ9fCoG8JaGeKVO4Rh5p0ezd4UUUId
++r1BXl5Nqdqy2vTMsEDnjOsD3egkv8I2SKN4O6n/C3wWYpMOWYZkGoZiKz7rJs/i/
++ez7bsV7JlwdzTlhpJzkcOSVFBP6JlEOxTNNxZ1wtKy7PtZGmsSSATq2e6+bw38Ae
++Op0XnzzqcGjtDDofBmT7OFzZWjS9VZS6+DOOe2QHWle1nCHcHyH4ku6IRlsr9xkR
++NAIlOfnvHHxqJUenoeaZ4oQDjCBKS1KXygJO/tL7BLTQVn/xK1EmPvKNnjzWk4tR
++PnibUhhs5635qpOU/YPqFBh1JjVruZbsWcDAhRcew0uxONXOa9E+4lttQ9ySYa1A
++LvWqJuAX7gu2BsBMLyqfm811YnA7CIFMyO+HlqmkLFfv5L/xIRAXR7l26YGO0VwX
++CGjMfz4NVPMMke4nB7qa9NkpXQBQKMms3Qzd5JW0Hy9Ruj5O8GPcFZmV0twjd1uJ
++PD/cAjkWLaXjdNsJ16QWc2nghQRS6HYqKRX6j+CXOxupAgMBAAGjUzBRMB0GA1Ud
++DgQWBBRSCOU58j9NJZkMamt623qyCrhN3TAfBgNVHSMEGDAWgBRSCOU58j9NJZkM
++amt623qyCrhN3TAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4ICAQCq
++q4jxsWeNDv5Nq14hJtF9HB+ZL64zcZtRjJP1YgNs0QppKICmjPOL2nIMGmI/jKrs
++0eGAL/9XXNVHPxm1OPOncvimMMmU6emZfpMdEtTfKP43+Pg9HgKRjLoQp406vGeQ
++8ki/mbBhrItVPgEm3tu2AFA02XTYi+YxCI9kRZLGkM3FbgtOuTLPl0Z9y+kiPc9F
++uCSC03anBEqv+vDSI8+wODymQ/IJ3Jyz1lxIRDfp4qAekmy0jU2c91VOHHEmOmqq
++kqygGFRdwbe99m9yP63r6q0b5K3X2UnJ6bns0hmTwThYwpVPXLU8jdaTddbMukN2
++/Ef96Tsw8nWOEOPMySHOTIPgwyZRp26b0kA9EmhLwOP401SxXVQCmSRmtwNagmtg
++jJKmZoYBN+//D45ibK8z6Q0oOm9P+Whf/uUXehcRxBxyV3xz7k0wKGQbHj/ddwcy
++IUoIN4lrAlib+lK170kTKN352PDmrpo2gmIzPEsfurKAIMSelDl6H+kih16BtZ8y
++Nz6fh9Soqrg3OSAware8pxV7k51crBMoPLN78KoRV8MFCK4K7Fddq4rRISq6hiXq
++r1nsjoEPuKM9huprmZVZe9t5YcDa2I+wb3IiE3uwpZbAdaLDyQ5n6F/qpsiIkZXn
++gtcF7oqpG5oYrwCcZ53y/ezUgUg7PlSz2XwAGvQtgg==
+ -----END CERTIFICATE-----
+diff --git a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
+index 9d1664d609..337ce541a6 100644
+--- a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
++++ b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
+@@ -1,15 +1,52 @@
+------BEGIN RSA PRIVATE KEY-----
+-MIICXAIBAAKBgQCnyKBKxBkFG2a6MuLS8RxvF4LkOS4BUZDbBDQyESHCDW9Z2FOQ
+-VD+Dj6nTs9XuGpuArsMlyV6lr0tgBaqg0ZEBH8oEg+NYHJkyRYRwclgDmEpji0H1
+-CEnSkQJga+Rk/t2gqnQI6TRMkV8SPTdNVCytf1uYYDYCjDv2RfMnapuUnQIDAQAB
+-AoGANFzLkanTeSGNFM0uttBipFT9F4a00dqHz6JnO7zXAT26I5r8sU1pqQBb6uLz
+-/+Qz5Zwk8RUAQcsMRgJetuPQUb0JZjF6Duv24hNazqXBCu7AZzUenjafwmKC/8ri
+-KpX3fTwqzfzi//FKGgbXQ80yykSSliDL3kn/drATxsLCgQECQQDXhEFWLJ0vVZ1s
+-1Ekf+3NITE+DR16X+LQ4W6vyEHAjTbaNWtcTKdAWLA2l6N4WAAPYSi6awm+zMxx4
+-VomVTsjdAkEAx0z+e7natLeFcrrq8pbU+wa6SAP1VfhQWKitxL1e7u/QO90NCpxE
+-oQYKzMkmmpOOFjQwEMAy1dvFMbm4LHlewQJAC/ksDBaUcQHHqjktCtrUb8rVjAyW
+-A8lscckeB2fEYyG5J6dJVaY4ClNOOs5yMDS2Afk1F6H/xKvtQ/5CzInA/QJATDub
+-K+BPU8jO9q+gpuIi3VIZdupssVGmCgObVCHLakG4uO04y9IyPhV9lA9tALtoIf4c
+-VIvv5fWGXBrZ48kZAQJBAJmVCdzQxd9LZI5vxijUCj5EI4e+x5DRqVUvyP8KCZrC
+-AiNyoDP85T+hBZaSXK3aYGpVwelyj3bvo1GrTNwNWLw=
+------END RSA PRIVATE KEY-----
++-----BEGIN PRIVATE KEY-----
++MIIJQgIBADANBgkqhkiG9w0BAQEFAASCCSwwggkoAgEAAoICAQDolKefhOG5aLih
+++6vq1TUfDaGF9l5AVvqvq6ctc7ubLEUs26sQIw8fXZIbe0JZ31ZQ09NCb6TlnXrj
++6J+fdeXnUEbGOFJ5epih9va2tzrVGtf8giV7BlSUygo+5OAcW+Zmc2/305WZ7TC3
++UyATH1G8OthSoq9VoyiHCfXwqBvCWhnilTuEYeadHs3eFFFCHa9QV5eTanastr0z
++LBA54zrA93oJL/CNkijeDup/wt8FmKTDlmGZBqGYis+6ybP4v3s+27FeyZcHc05Y
++aSc5HDklRQT+iZRDsUzTcWdcLSsuz7WRprEkgE6tnuvm8N/AHjqdF5886nBo7Qw6
++HwZk+zhc2Vo0vVWUuvgzjntkB1pXtZwh3B8h+JLuiEZbK/cZETQCJTn57xx8aiVH
++p6HmmeKEA4wgSktSl8oCTv7S+wS00FZ/8StRJj7yjZ481pOLUT54m1IYbOet+aqT
++lP2D6hQYdSY1a7mW7FnAwIUXHsNLsTjVzmvRPuJbbUPckmGtQC71qibgF+4LtgbA
++TC8qn5vNdWJwOwiBTMjvh5appCxX7+S/8SEQF0e5dumBjtFcFwhozH8+DVTzDJHu
++Jwe6mvTZKV0AUCjJrN0M3eSVtB8vUbo+TvBj3BWZldLcI3dbiTw/3AI5Fi2l43Tb
++CdekFnNp4IUEUuh2KikV+o/glzsbqQIDAQABAoICAFw1q6tr5I48vY7DF+rXsuLn
++5ZUWE1IQ6fzB4lr72nJv/9EEGnMgYzt9PpMUsD6vdCpBgS2C0+6RHArFzJtNA+RM
++iHLIG7K7702veyr/xBx/MwiSlMeMv/XpkFxVI6E6skMGG2s3AMXxKvJTy5CpRx+I
++eQFyLG+Ya1X2lgJes/q+/CpAHkOjCOpcLySQC5NZ74q734V7nSdmn+Zs3tYEh+O/
++eiuwTP/j5b38Te5vVTqDxTciJPmljmXLCwa0N100lWlbcpvw8qbqiTI2Jm3XCbUE
++AzHjW9vmrF3cRS1fXxKFGShw3SRqlkbxjfeWoi8qDPUBS4m8LOr8qG9Wo5Nfon0z
++zLP4bci3zHDvVcaaZrrsUBs/yZbg+Dgka1DmX7ekmeccr2yTdKDFgPupYUyxVbTl
++a9ZLJysjFD7rgBv1ZclHonLp6Vbm+ZoTqvteo4ikAy6L9RtBWJ23XEK34PkP/+c5
++2vWZaOrnjSeBHbFce8cdJSxqWpP+eSCI5I9XbDrYFIsQ/gqKgtzDKy2ihJ2Y8STL
++yO4hyFPFjxc+Gg4/P2PpmT5CY2ty44M0BWs+JGW96CJPrrplf2lmQUQJj5LZY66X
++Z/4C9L7ZYtKZ+bs5SvU46yWugAvQZX22Xm9xLXWyVXRdx3bj+3M3fDnF9di/zdbh
++CgLx7oWPNrXc7FCajnn9AoIBAQD5FMYwRpw9NWT9WDxQwx+cSI4Icbd88ByTW63S
++LzeRwZA0J9/SfwO+aBRupzc9GkGXCiZcGMw3AGsCtig8yFlw8E5KnzN7KlftDMnM
++9NUxxzlR8VwKyLnZfG7sDTl057ZlUujnqhmt/F8F7dIy7FVO1dE/8nngA+FYTCOG
++UZdGjwyBDlDM0JJdUWGY3xslutcpCDN5mzSTKjy9drMvImAshRawxRF6WBpn7vr2
++nC6vciqfx1Mzx1vyk0Jm0ilaydDdLMADjt/iL4Nkr0BEs4k+UzQiKDwp8gu7abQ1
++eBfxd9Iar4htQa2I1Ewl6P01G/q+ZYwgHhJ9RVn4AxQXefILAoIBAQDvCouORdQX
++C8wsyp7MwXlF/3NQeNN5/+B2mhbxrBOf7PmMCXLnkRWcjwJtzypWFqJ0sqai/2+0
++bqbMcjX5maT8stT2shl3zXe/Ejt2e3TBYpc1tyuses8Kb5BMU8hu6tTd3G2CMXpD
++dT6DVemJZCTtwj9aBNIxSizvlgMolJnCpzhPnlfHSI6E+g3m/LTTo3HwbjMSw/Uq
++irgjOpI2wSBB6LZPSgjvfcYPRyWUk16L4A5uSX0cADnovDFLa5/h0wJvN/OoCSQg
++rLCXG5E18EyL5Wc58BCY1ZvxmjG3lQtgPxYu2Jwc36R/y/JKlxW5suER5ZNpbbD4
++uOyTt2VxMQ2bAoIBAQC5+MzRFqdo/AjfL5Y5JrbfVTzXCTDa09xCGd16ZU60QTWN
+++4ed/r+o1sUKqUcRFB2MzEM/2DQBjQpZB/CbEWvWa1XJWXxypXbowveZU+QqOnmN
++uQvj8WLyA3o+PNF9e9QvauwCrHpn8VpxbtPWuaYoKnUFreFZZQxHhPGxRBIS2JOZ
++eDrT8ZaWnkCkh1AZp5smQ71LOprSlmKrg4jd1GjCVMxQR5N5KXbtyv0OTCZ/UFqK
++2aRBsMPyJgkaBChkZPLRcKwc+/wlQRx1fHQb14DNTApMxoXFO7eOwqmOkpAt9iyl
++SBIwoS0UUI5ab88+bBmXNvKcuFdNuQ4nowTJUn9pAoIBADMNkILBXSvS5DeIyuO2
++Sp1tkoZUV+5NfPY3sMDK3KIibaW/+t+EOBZo4L7tKQCb8vRzl21mmsfxfgRaPDbj
++3r3tv9g0b4YLxxBy52pFscj/soXRai17SS7UZwA2QK+XzgDYbDcLNC6mIsTQG4Gx
++dsWk3/zs3KuUSQaehmwrWK+fIUK38c1pLK8v7LoxrLkqxlHwZ04RthHw8KTthH7X
++Pnl1J0LF8CSeOyfWLSuPUfkT0GEzptnNHpEbaHfQM6R6eaGhVJPF6AZme4y6YYgg
++m2ihhSt1n0XVEWpHYWjxFy3mK2mz75unFC4LM+NEY2p2zuUQoCw7NjnY3QYrfCnx
++rRMCggEAXeXsMSLFjjyuoL7iKbAxo52HD/P0fBoy58LyRcwfNVr0lvYan4pYEx+o
++KijIh9K16PqXZXKMA9v003B+ulmF8bJ7SddCZ5NGvnFhUTDe4DdTKgp2RuwQ3Bsc
++3skPIDbhVETyOLCtys34USHrq8U/0DlGY3eLRfxw9GnbKxSBGa/KEu/qQLPNUo50
++7xHZDg7GKeC3kqNJeqKM9rkp0VzIGkEnaD9127LeNDmERDfftxJzFoC/THvUBLfU
++6Sus2ZYwRE8VFvKC30Q45t/c54X3IuhYvAuiCuTmyfE4ruyzyOwKzhUkeeLq1APX
++g0veFbyfzlJ0q8qzD/iffqqIa2ZSmQ==
++-----END PRIVATE KEY-----
+diff --git a/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp b/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
+index 7ba3715e13..752aa122f6 100644
+--- a/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
++++ b/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
+@@ -179,6 +179,7 @@ void tst_QAccessibilityLinux::initTestCase()
+     QVERIFY(!address.isEmpty());
+ 
+     m_window = new AccessibleTestWindow();
++    m_window->setObjectName("mainWindow"_L1);
+     m_window->show();
+ 
+     QVERIFY(QTest::qWaitForWindowExposed(m_window));
+@@ -236,8 +237,11 @@ bool hasState(QDBusInterface *interface, AtspiStateType state)
+ void tst_QAccessibilityLinux::testLabel()
+ {
+     QLabel *l = new QLabel(m_window);
++    l->setObjectName("theObjectName"_L1);
+     l->setText("Hello A11y");
+     m_window->addWidget(l);
++    auto a11yEmpty = new QLabel(m_window);
++    m_window->addWidget(l);
+ 
+     // Application
+     QCOMPARE(getParent(mainWindow), QLatin1String(ATSPI_DBUS_PATH_ROOT));
+@@ -249,6 +253,8 @@ void tst_QAccessibilityLinux::testLabel()
+     QCOMPARE(getChildren(labelInterface).count(), 0);
+     QCOMPARE(labelInterface->call(QDBus::Block, "GetRoleName").arguments().first().toString(), QLatin1String("label"));
+     QCOMPARE(labelInterface->call(QDBus::Block, "GetRole").arguments().first().toUInt(), 29u);
++    QCOMPARE(labelInterface->call(QDBus::Block, "GetAccessibleId").arguments().first().toString(),
++             QLatin1String("mainWindow.theObjectName"));
+     QCOMPARE(getParent(labelInterface), mainWindow->path());
+     QVERIFY(!hasState(labelInterface, ATSPI_STATE_EDITABLE));
+     QVERIFY(hasState(labelInterface, ATSPI_STATE_READ_ONLY));
+@@ -256,7 +262,12 @@ void tst_QAccessibilityLinux::testLabel()
+     l->setText("New text");
+     QCOMPARE(labelInterface->property("Name").toString(), l->text());
+ 
++    auto *a11yEmptyInterface = getInterface(children.at(1), "org.a11y.atspi.Accessible");
++    QCOMPARE(a11yEmptyInterface->call(QDBus::Block, "GetAccessibleId").arguments().first().toString(),
++             QLatin1String("mainWindow.QLabel"));
++
+     m_window->clearChildren();
++    delete a11yEmptyInterface;
+     delete labelInterface;
+ }
+ 
+diff --git a/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+index 76df61c892..6d6d65b791 100644
+--- a/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
++++ b/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2022 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the test suite of the Qt Toolkit.
+@@ -68,6 +68,8 @@ private slots:
+     void query_exec();
+     void execErrorRecovery_data() { generic_data(); }
+     void execErrorRecovery();
++    void prematureExec_data() { generic_data(); }
++    void prematureExec();
+     void first_data() { generic_data(); }
+     void first();
+     void next_data() { generic_data(); }
+@@ -2770,6 +2772,35 @@ void tst_QSqlQuery::execErrorRecovery()
+     QVERIFY_SQL( q, exec() );
+ }
+ 
++void tst_QSqlQuery::prematureExec()
++{
++    QFETCH(QString, dbName);
++    // We only want the engine name, for addDatabase():
++    int cut = dbName.indexOf(QChar('@'));
++    if (cut < 0)
++        QSKIP("Failed to parse database type out of name");
++    dbName.truncate(cut);
++    cut = dbName.indexOf(QChar('_'));
++    if (cut >= 0)
++        dbName = dbName.mid(cut + 1);
++
++    auto db = QSqlDatabase::addDatabase(dbName);
++    QSqlQuery q(db);
++
++    QTest::ignoreMessage(QtWarningMsg,
++                         "QSqlDatabasePrivate::removeDatabase: connection "
++                         "'qt_sql_default_connection' is still in use, all "
++                         "queries will cease to work.");
++    QTest::ignoreMessage(QtWarningMsg,
++                         "QSqlDatabasePrivate::addDatabase: duplicate connection name "
++                         "'qt_sql_default_connection', old connection removed.");
++    auto otherDb = QSqlDatabase::addDatabase(dbName);
++
++    QTest::ignoreMessage(QtWarningMsg, "QSqlQuery::exec: called before driver has been set up");
++    // QTBUG-100037: shouldn't crash !
++    QVERIFY(!q.exec("select stuff from TheVoid"));
++}
++
+ void tst_QSqlQuery::lastInsertId()
+ {
+     QFETCH( QString, dbName );
+diff --git a/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp b/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
+index 4aa3f8d60b..d2050a61aa 100644
+--- a/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
++++ b/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
+@@ -115,6 +115,10 @@ void tst_QAbstractItemModelTester::standardItemModelZeroColumns()
+     // QTBUG-92886
+     model.insertRows(0, 5);
+     model.removeRows(1, 2);
++
++    const QModelIndex parentIndex = model.index(0, 0);
++    model.insertRows(0, 5, parentIndex);
++    model.removeRows(1, 2, parentIndex);
+ }
+ 
+ void tst_QAbstractItemModelTester::testInsertThroughProxy()
+diff --git a/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json b/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
+index 12a4a22a19..ce518e78fb 100644
+--- a/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
++++ b/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
+@@ -668,50 +668,6 @@
+         "inputFile": "task192552.h",
+         "outputRevision": 67
+     },
+-    {
+-        "classes": [
+-            {
+-                "className": "InlineSlotsWithThrowDeclaration",
+-                "object": true,
+-                "qualifiedClassName": "InlineSlotsWithThrowDeclaration",
+-                "slots": [
+-                    {
+-                        "access": "public",
+-                        "name": "a",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "b",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "c",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "d",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "e",
+-                        "returnType": "void"
+-                    }
+-                ],
+-                "superClasses": [
+-                    {
+-                        "access": "public",
+-                        "name": "QObject"
+-                    }
+-                ]
+-            }
+-        ],
+-        "inputFile": "task189996.h",
+-        "outputRevision": 67
+-    },
+     {
+         "classes": [
+             {
+diff --git a/qtbase/tests/auto/tools/moc/moc.pro b/qtbase/tests/auto/tools/moc/moc.pro
+index c324b3a8cd..4aceb78dc0 100644
+--- a/qtbase/tests/auto/tools/moc/moc.pro
++++ b/qtbase/tests/auto/tools/moc/moc.pro
+@@ -15,7 +15,7 @@ cross_compile: DEFINES += MOC_CROSS_COMPILED
+ HEADERS += using-namespaces.h no-keywords.h task87883.h c-comments.h backslash-newlines.h oldstyle-casts.h \
+            slots-with-void-template.h qinvokable.h namespaced-flags.h trigraphs.h \
+            escapes-in-string-literals.h cstyle-enums.h qprivateslots.h gadgetwithnoenums.h \
+-           dir-in-include-path.h single_function_keyword.h task192552.h task189996.h \
++           dir-in-include-path.h single_function_keyword.h task192552.h \
+            task234909.h task240368.h pure-virtual-signals.h cxx11-enums.h \
+            cxx11-final-classes.h \
+            cxx11-explicit-override-control.h \
+diff --git a/qtbase/tests/auto/tools/moc/task189996.h b/qtbase/tests/auto/tools/moc/task189996.h
+deleted file mode 100644
+index f94a051b3a..0000000000
+--- a/qtbase/tests/auto/tools/moc/task189996.h
++++ /dev/null
+@@ -1,47 +0,0 @@
+-/****************************************************************************
+-**
+-** Copyright (C) 2016 The Qt Company Ltd.
+-** Contact: https://www.qt.io/licensing/
+-**
+-** This file is part of the test suite of the Qt Toolkit.
+-**
+-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+-** 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 General Public License Usage
+-** Alternatively, this file may be used under the terms of the GNU
+-** General Public License version 3 as published by the Free Software
+-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+-** 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-3.0.html.
+-**
+-** $QT_END_LICENSE$
+-**
+-****************************************************************************/
+-// inline functions can have throw declarations
+-
+-#ifndef TASK189996_H
+-#define TASK189996_H
+-
+-#include <QObject>
+-
+-class InlineSlotsWithThrowDeclaration : public QObject
+-{
+-    Q_OBJECT
+-
+-public slots:
+-    void a() throw() { }
+-    void b() const throw() { }
+-    void c() throw();
+-    void d() throw(int) { }
+-    void e() const throw(int,double) { }
+-};
+-
+-#endif
+diff --git a/qtbase/tests/auto/tools/moc/tst_moc.cpp b/qtbase/tests/auto/tools/moc/tst_moc.cpp
+index c716aead21..15dd9e41e5 100644
+--- a/qtbase/tests/auto/tools/moc/tst_moc.cpp
++++ b/qtbase/tests/auto/tools/moc/tst_moc.cpp
+@@ -631,7 +631,6 @@ public:
+ private slots:
+     void initTestCase();
+ 
+-    void slotWithException() throw(MyStruct);
+     void dontStripNamespaces();
+     void oldStyleCasts();
+     void warnOnExtraSignalSlotQualifiaction();
+@@ -673,7 +672,6 @@ private slots:
+     void templateGtGt();
+     void qprivateslots();
+     void qprivateproperties();
+-    void inlineSlotsWithThrowDeclaration();
+     void warnOnPropertyWithoutREAD();
+     void constructors();
+     void typenameWithUnsigned();
+@@ -784,12 +782,6 @@ void tst_Moc::initTestCase()
+ #endif
+ }
+ 
+-void tst_Moc::slotWithException() throw(MyStruct)
+-{
+-    // be happy
+-    QVERIFY(true);
+-}
+-
+ void tst_Moc::dontStripNamespaces()
+ {
+     Sender sender;
+@@ -824,7 +816,7 @@ void tst_Moc::oldStyleCasts()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-Wold-style-cast" << "-I" << "."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -894,7 +886,7 @@ void tst_Moc::inputFileNameWithDotsButNoExtension()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-I" << ".."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -1174,7 +1166,7 @@ void tst_Moc::ignoreOptionClashes()
+     QStringList gccArgs;
+     gccArgs << "-c" << "-x" << "c++" << "-I" << ".."
+          << "-I" << qtIncludePath << "-I" << includeDir << "-o" << "/dev/null"
+-         << "-fPIC" << "-std=c++11" <<  "-";
++         << "-fPIC" << "-std=c++1z" <<  "-";
+     proc.start("gcc", gccArgs);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -1593,21 +1585,6 @@ void tst_Moc::qprivateproperties()
+ 
+ }
+ 
+-#include "task189996.h"
+-
+-void InlineSlotsWithThrowDeclaration::c() throw() {}
+-
+-void tst_Moc::inlineSlotsWithThrowDeclaration()
+-{
+-    InlineSlotsWithThrowDeclaration tst;
+-    const QMetaObject *mobj = tst.metaObject();
+-    QVERIFY(mobj->indexOfSlot("a()") != -1);
+-    QVERIFY(mobj->indexOfSlot("b()") != -1);
+-    QVERIFY(mobj->indexOfSlot("c()") != -1);
+-    QVERIFY(mobj->indexOfSlot("d()") != -1);
+-    QVERIFY(mobj->indexOfSlot("e()") != -1);
+-}
+-
+ void tst_Moc::warnOnPropertyWithoutREAD()
+ {
+ #ifdef MOC_CROSS_COMPILED
+@@ -1869,7 +1846,7 @@ void tst_Moc::notifyError()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-I" << "."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+diff --git a/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+index c355ee9665..88c09de8e0 100644
+--- a/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
++++ b/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+@@ -251,6 +251,7 @@ private slots:
+     void testResetCachedSizeHint();
+     void statusTips();
+     void testRemovingColumnsViaLayoutChanged();
++    void testModelMovingColumns();
+ 
+ protected:
+     void setupTestData(bool use_reset_model = false);
+@@ -360,6 +361,12 @@ public:
+         endRemoveColumns();
+     }
+ 
++    void moveColumn(int from, int to)
++    {
++        beginMoveColumns(QModelIndex(), from, from, QModelIndex(), to);
++        endMoveColumns();
++    }
++
+     void cleanup()
+     {
+         emit layoutAboutToBeChanged();
+@@ -3627,5 +3634,18 @@ void tst_QHeaderView::testRemovingColumnsViaLayoutChanged()
+     // The main point of this test is that the section-size restoring code didn't go out of bounds.
+ }
+ 
++void tst_QHeaderView::testModelMovingColumns()
++{
++    QtTestModel model(10, 10);
++    QHeaderView hv(Qt::Horizontal);
++    hv.setModel(&model);
++    hv.resizeSections(QHeaderView::ResizeToContents);
++    hv.show();
++
++    QPersistentModelIndex index3 = model.index(0, 3);
++    model.moveColumn(3, 1);
++    QCOMPARE(index3.column(), 1);
++}
++
+ QTEST_MAIN(tst_QHeaderView)
+ #include "tst_qheaderview.moc"
+diff --git a/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+index 761357b252..06bb706074 100644
+--- a/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
++++ b/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+@@ -397,6 +397,7 @@ private slots:
+     void checkHeaderMinSize();
+ 
+     void resizeToContents();
++    void resizeToContentsSpans();
+ 
+     void tabFocus();
+     void bigModel();
+@@ -3721,6 +3722,70 @@ void tst_QTableView::resizeToContents()
+ 
+ }
+ 
++
++class SpanModel : public QAbstractTableModel
++{
++public:
++    SpanModel(bool sectionsMoved)
++        : _sectionsMoved(sectionsMoved)
++    {}
++    int columnCount(const QModelIndex & = {}) const override { return 2; }
++    int rowCount(const QModelIndex & = {}) const override { return 1; }
++    QVariant data(const QModelIndex &idx, int role = Qt::DisplayRole) const override
++    {
++        if (role != Qt::DisplayRole)
++            return QVariant();
++        const int col = _sectionsMoved ? 1 - idx.column() : idx.column();
++        if (col == 0)
++            return "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.";
++        return QVariant();
++    }
++private:
++    bool _sectionsMoved;
++};
++
++
++void tst_QTableView::resizeToContentsSpans()
++{
++    SpanModel model1(false);
++    SpanModel model2(true);
++    QTableView view1, view2, view3;
++    view1.setModel(&model1);
++    view2.setModel(&model2);
++    view2.horizontalHeader()->moveSection(0, 1);
++    view3.setModel(&model1);
++
++    view1.setSpan(0, 0, 1, 2);
++    view2.setSpan(0, 1, 1, 2);
++    view1.show();
++    view2.show();
++    view3.show();
++    QVERIFY(QTest::qWaitForWindowExposed(&view1));
++    QVERIFY(QTest::qWaitForWindowExposed(&view2));
++    QVERIFY(QTest::qWaitForWindowExposed(&view3));
++    view1.setColumnWidth(0, 100);
++    view1.setColumnWidth(1, 100);
++    view2.setColumnWidth(0, 100);
++    view2.setColumnWidth(1, 100);
++    view3.setColumnWidth(0, 200);
++
++    view1.resizeRowToContents(0);
++    view2.resizeRowToContents(0);
++    view3.resizeRowToContents(0);
++    QCOMPARE(view1.rowHeight(0), view3.rowHeight(0));
++    QCOMPARE(view2.rowHeight(0), view3.rowHeight(0));
++
++    view3.resizeColumnToContents(0);
++    view3.resizeRowToContents(0);
++    // height should be only 1 text line for easy testing
++    view1.setRowHeight(0, view3.verticalHeader()->sectionSize(0));
++    view2.setRowHeight(0, view3.verticalHeader()->sectionSize(0));
++    view1.resizeColumnToContents(0);
++    view2.resizeColumnToContents(1);
++    QCOMPARE(view1.columnWidth(0), view3.columnWidth(0) - view1.columnWidth(1));
++    QCOMPARE(view2.columnWidth(0), view3.columnWidth(0) - view2.columnWidth(1));
++}
++
+ QT_BEGIN_NAMESPACE
+ extern bool Q_WIDGETS_EXPORT qt_tab_all_widgets(); // qapplication.cpp
+ QT_END_NAMESPACE
+diff --git a/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+index a3b8ef78d8..4955cebd5d 100644
+--- a/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
++++ b/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+@@ -1498,7 +1498,7 @@ void tst_QApplication::desktopSettingsAware()
+     environment += QLatin1String("QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM=1");
+     testProcess.setEnvironment(environment);
+ #endif
+-    testProcess.start("desktopsettingsaware_helper");
++    testProcess.start("./desktopsettingsaware_helper");
+     QVERIFY2(testProcess.waitForStarted(),
+              qPrintable(QString::fromLatin1("Cannot start 'desktopsettingsaware_helper': %1").arg(testProcess.errorString())));
+     QVERIFY(testProcess.waitForFinished(10000));
+@@ -2452,7 +2452,7 @@ void tst_QApplication::qtbug_12673()
+ #if QT_CONFIG(process)
+     QProcess testProcess;
+     QStringList arguments;
+-    testProcess.start("modal_helper", arguments);
++    testProcess.start("./modal_helper", arguments);
+     QVERIFY2(testProcess.waitForStarted(),
+              qPrintable(QString::fromLatin1("Cannot start 'modal_helper': %1").arg(testProcess.errorString())));
+     QVERIFY(testProcess.waitForFinished(20000));
+diff --git a/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp b/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
+index eb108a40de..dca5528c1b 100644
+--- a/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
+@@ -41,6 +41,7 @@
+ 
+ #include <private/qguiapplication_p.h>
+ #include <qpa/qplatformintegration.h>
++#include <qpa/qplatformtheme.h>
+ 
+ class tst_QAbstractButton : public QObject
+ {
+@@ -76,6 +77,8 @@ private slots:
+     void keyNavigation();
+ #endif
+ 
++    void buttonPressKeys();
++
+ protected slots:
+     void onClicked();
+     void onToggled( bool on );
+@@ -269,7 +272,13 @@ void tst_QAbstractButton::setAutoRepeat()
+         QCOMPARE(press_count, click_count);
+         QVERIFY(click_count > 1);
+         break;
+-    case 4:
++    case 4: {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(Qt::Key_Enter)) {
++            QSKIP("platform theme has Key_Enter in ButtonPressKeys");
++        }
+         // check that pressing ENTER has no effect when autorepeat is false
+         testWidget->setDown( false );
+         testWidget->setAutoRepeat( false );
+@@ -286,7 +295,14 @@ void tst_QAbstractButton::setAutoRepeat()
+ 
+         QVERIFY( click_count == 0 );
+         break;
+-    case 5:
++    }
++    case 5: {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(Qt::Key_Enter)) {
++            QSKIP("platform theme has Key_Enter in ButtonPressKeys");
++        }
+         // check that pressing ENTER has no effect when autorepeat is true
+         testWidget->setDown( false );
+         testWidget->setAutoRepeat( true );
+@@ -304,6 +320,7 @@ void tst_QAbstractButton::setAutoRepeat()
+ 
+         QVERIFY( click_count == 0 );
+         break;
++    }
+     case 6:
+         // verify autorepeat is off by default.
+         MyButton tmp( 0);
+@@ -651,5 +668,16 @@ void tst_QAbstractButton::keyNavigation()
+ }
+ #endif
+ 
++void tst_QAbstractButton::buttonPressKeys()
++{
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(testWidget, buttonPressKeys[i]);
++        QCOMPARE(click_count, i + 1);
++    }
++}
++
+ QTEST_MAIN(tst_QAbstractButton)
+ #include "tst_qabstractbutton.moc"
+diff --git a/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+index 32437050f5..46b5af6d63 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+@@ -168,6 +168,7 @@ private slots:
+     void checkMenuItemPosWhenStyleSheetIsSet();
+     void checkEmbeddedLineEditWhenStyleSheetIsSet();
+     void propagateStyleChanges();
++    void buttonPressKeys();
+ 
+ private:
+     PlatformInputContext m_platformInputContext;
+@@ -1682,6 +1683,16 @@ void tst_QComboBox::setModel()
+     QCOMPARE(box.rootModelIndex(), rootModelIndex);
+     box.setModel(box.model());
+     QCOMPARE(box.rootModelIndex(), rootModelIndex);
++
++    // check that setting the same model as the completer's doesn't crash
++    QCompleter *completer = new QCompleter(&box);
++    box.setEditable(true);
++    box.setCompleter(completer);
++    auto *listModel = new QStringListModel({ "one", "two" }, completer);
++    completer->setModel(listModel);
++    QCOMPARE(listModel->rowCount(), 2); // make sure it wasn't deleted
++    box.setModel(listModel);
++    QCOMPARE(listModel->rowCount(), 2); // make sure it wasn't deleted
+ }
+ 
+ void tst_QComboBox::setCustomModelAndView()
+@@ -3632,5 +3643,24 @@ void tst_QComboBox::propagateStyleChanges()
+     QVERIFY(frameStyle.inquired);
+ }
+ 
++void tst_QComboBox::buttonPressKeys()
++{
++    QComboBox comboBox;
++    comboBox.setEditable(false);
++    comboBox.addItem(QString::number(1));
++    comboBox.addItem(QString::number(2));
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(&comboBox, buttonPressKeys[i]);
++        // On some platforms, a window will not be immediately visible,
++        // but take some event-loop iterations to complete.
++        // Using QTRY_VERIFY to deal with that.
++        QTRY_VERIFY(comboBox.view()->isVisible());
++        comboBox.hidePopup();
++    }
++}
++
+ QTEST_MAIN(tst_QComboBox)
+ #include "tst_qcombobox.moc"
+diff --git a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
+index be3cfcd104..c228fdfcca 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
++++ b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qcommandlinkbutton
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qcommandlinkbutton.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
+index 0044d33c66..4cf06296e4 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
+@@ -40,6 +40,9 @@
+ #include <QGridLayout>
+ #include <QPainter>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ class tst_QCommandLinkButton : public QObject
+ {
+     Q_OBJECT
+@@ -223,6 +226,13 @@ void tst_QCommandLinkButton::setAutoRepeat()
+     // check that pressing ENTER has no effect
+     resetCounters();
+     testWidget->setDown( false );
++    // Skip after reset if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
+     testWidget->setAutoRepeat( false );
+     QTest::keyPress( testWidget, Qt::Key_Enter );
+ 
+@@ -255,6 +265,14 @@ void tst_QCommandLinkButton::pressed()
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+ 
++    // Skip if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
++
+     QTest::keyPress( testWidget,Qt::Key_Enter );
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+diff --git a/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro b/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
+index 4a5e76ff65..a235fa1fac 100644
+--- a/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
++++ b/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qgroupbox
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qgroupbox.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp b/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
+index 4fb5d262ca..d8d7562b73 100644
+--- a/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
+@@ -35,6 +35,9 @@
+ #include <QRadioButton>
+ #include <QDialog>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ #include "qgroupbox.h"
+ 
+ class tst_QGroupBox : public QObject
+@@ -69,6 +72,7 @@ private slots:
+     void propagateFocus();
+     void task_QTBUG_19170_ignoreMouseReleaseEvent();
+     void task_QTBUG_15519_propagateMouseEvents();
++    void buttonPressKeys();
+ 
+ private:
+     bool checked;
+@@ -610,6 +614,20 @@ void tst_QGroupBox::task_QTBUG_15519_propagateMouseEvents()
+     QCOMPARE(parent.mouseMoved, true);
+ }
+ 
++void tst_QGroupBox::buttonPressKeys()
++{
++    QGroupBox groupBox;
++    groupBox.setCheckable(true);
++    QSignalSpy clickedSpy(&groupBox, &QGroupBox::clicked);
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(&groupBox, buttonPressKeys[i]);
++        QCOMPARE(clickedSpy.length(), i + 1);
++    }
++}
++
+ void tst_QGroupBox::sendMouseMoveEvent(QWidget *widget, const QPoint &localPos)
+ {
+     // Send a MouseMove event without actually moving the pointer
+diff --git a/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro b/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
+index 353ad06ca2..e55f6148f2 100644
+--- a/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
++++ b/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qpushbutton
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qpushbutton.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp b/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
+index e818514a79..4043e9326a 100644
+--- a/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
+@@ -41,6 +41,9 @@
+ #include <QStyleFactory>
+ #include <QTabWidget>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ class tst_QPushButton : public QObject
+ {
+ Q_OBJECT
+@@ -212,6 +215,13 @@ void tst_QPushButton::autoRepeat()
+     // check that pressing ENTER has no effect
+     resetCounters();
+     testWidget->setDown( false );
++    // Skip after reset if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
+     testWidget->setAutoRepeat( false );
+     QTest::keyPress( testWidget, Qt::Key_Enter );
+ 
+@@ -247,6 +257,14 @@ void tst_QPushButton::pressed()
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+ 
++    // Skip if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
++
+     QTest::keyPress( testWidget,Qt::Key_Enter );
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+diff --git a/qtbase/tests/manual/rhi/cubemap_render/buildshader.bat b/qtbase/tests/manual/rhi/cubemap_render/buildshader.bat
+old mode 100755
+new mode 100644
+Submodule qtconnectivity e957d481..056294c0:
+diff --git a/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp b/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
+index e2635fae..a8b8e3b9 100644
+--- a/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
++++ b/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
+@@ -563,9 +563,11 @@ void HciManager::handleHciAclPacket(const quint8 *data, int size)
+ 
+ void HciManager::handleLeMetaEvent(const quint8 *data)
+ {
+-    // Spec v4.2, Vol 2, part E, 7.7.65ff
++    // Spec v5.3, Vol 4, part E, 7.7.65.*
+     switch (*data) {
+-    case 0x1: {
++    case 0x1: // HCI_LE_Connection_Complete
++    case 0xA: // HCI_LE_Enhanced_Connection_Complete
++    {
+         const quint16 handle = bt_get_le16(data + 2);
+         emit connectionComplete(handle);
+         break;
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp b/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
+index 6a93143b..4a18cfc7 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
+@@ -320,7 +320,10 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_finishSdpScan(QBluetoothServiceD
+             for (const QBluetoothUuid &id : serviceClassUuids) {
+                 if (id.minimumSize() == 16) {
+                     serviceInfo.setServiceUuid(id);
+-                    serviceInfo.setServiceName(QBluetoothServiceDiscoveryAgent::tr("Custom Service"));
++                    if (serviceInfo.serviceName().isEmpty()) {
++                        serviceInfo.setServiceName(
++                                    QBluetoothServiceDiscoveryAgent::tr("Custom Service"));
++                    }
+                     QBluetoothServiceInfo::Sequence modSeq =
+                             serviceInfo.attribute(QBluetoothServiceInfo::ServiceClassIds).value<QBluetoothServiceInfo::Sequence>();
+                     modSeq.removeOne(QVariant::fromValue(id));
+@@ -334,8 +337,10 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_finishSdpScan(QBluetoothServiceD
+                 qCDebug(QT_BT_BLUEZ) << "Discovered services" << discoveredDevices.at(0).address().toString()
+                                      << serviceInfo.serviceName() << serviceInfo.serviceUuid()
+                                      << ">>>" << serviceInfo.serviceClassUuids();
+-
+-                emit q->serviceDiscovered(serviceInfo);
++                // Use queued connection to allow us finish the service looping; the application
++                // might call stop() when it has detected the service-of-interest.
++                QMetaObject::invokeMethod(q, "serviceDiscovered", Qt::QueuedConnection,
++                                          Q_ARG(QBluetoothServiceInfo, serviceInfo));
+             }
+         }
+     }
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp b/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
+index e4d85447..aadd4755 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
+@@ -593,7 +593,7 @@ void QBluetoothSocket::setSocketState(QBluetoothSocket::SocketState state)
+ bool QBluetoothSocket::canReadLine() const
+ {
+     Q_D(const QBluetoothSocketBase);
+-    return d->canReadLine();
++    return d->canReadLine() || QIODevice::canReadLine();
+ }
+ 
+ /*!
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp b/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
+index 084aa958..d6aa17a7 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
+@@ -284,6 +284,10 @@ void QBluetoothSocketPrivateBluezDBus::connectToService(
+         return;
+     }
+ 
++    if (service.socketProtocol() != QBluetoothServiceInfo::Protocol::UnknownProtocol)
++        socketType = service.socketProtocol();
++    qCDebug(QT_BT_BLUEZ) << "Socket protocol used:" << socketType;
++
+     connectToService(service.device().address(), targetService, openMode);
+ }
+ 
+diff --git a/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp b/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
+index 05bc1a0f..a7b5ef1f 100644
+--- a/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
++++ b/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
+@@ -142,7 +142,7 @@ void tst_QBluetoothSocket::initTestCase()
+     qDebug() << "Starting discovery";
+ 
+     sda->setUuidFilter(QBluetoothUuid(QString(TEST_SERVICE_UUID)));
+-    sda->start(QBluetoothServiceDiscoveryAgent::MinimalDiscovery);
++    sda->start(QBluetoothServiceDiscoveryAgent::FullDiscovery);
+ 
+     for (int connectTime = MaxConnectTime; !done_discovery && connectTime > 0; connectTime -= 1000)
+         QTest::qWait(1000);
+Submodule qtdeclarative f5701f0d..8defe7bf:
+diff --git a/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h b/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
+index b65b994d6c..15a8cd6878 100644
+--- a/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
++++ b/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
+@@ -86,7 +86,7 @@ public:
+         if (QTypeInfo<T>::isComplex) {
+             for (int i = 0; i < count; ++i)
+                 new (data + i) T(vector.at(i));
+-        } else {
++        } else if (count) {
+             memcpy(data, static_cast<const void*>(vector.constData()), count * sizeof(T));
+         }
+     }
+diff --git a/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp b/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
+index e57cdd8278..94613598af 100644
+--- a/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
++++ b/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
+@@ -1145,8 +1145,7 @@ void Heap::QObjectWrapper::markObjects(Heap::Base *that, QV4::MarkStack *markSta
+ void QObjectWrapper::destroyObject(bool lastCall)
+ {
+     Heap::QObjectWrapper *h = d();
+-    if (!h->internalClass)
+-        return; // destroyObject already got called
++    Q_ASSERT(h->internalClass);
+ 
+     if (h->object()) {
+         QQmlData *ddata = QQmlData::get(h->object(), false);
+@@ -1176,7 +1175,7 @@ void QObjectWrapper::destroyObject(bool lastCall)
+         }
+     }
+ 
+-    h->~Data();
++    h->destroy();
+ }
+ 
+ 
+diff --git a/qtdeclarative/src/qml/memory/qv4mm.cpp b/qtdeclarative/src/qml/memory/qv4mm.cpp
+index 06caf04e5a..da149a67c4 100644
+--- a/qtdeclarative/src/qml/memory/qv4mm.cpp
++++ b/qtdeclarative/src/qml/memory/qv4mm.cpp
+@@ -981,7 +981,7 @@ void MemoryManager::sweep(bool lastSweep, ClassDestroyStatsCallback classCountPt
+ 
+     if (MultiplyWrappedQObjectMap *multiplyWrappedQObjects = engine->m_multiplyWrappedQObjects) {
+         for (MultiplyWrappedQObjectMap::Iterator it = multiplyWrappedQObjects->begin(); it != multiplyWrappedQObjects->end();) {
+-            if (!it.value().isNullOrUndefined())
++            if (it.value().isNullOrUndefined())
+                 it = multiplyWrappedQObjects->erase(it);
+             else
+                 ++it;
+diff --git a/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp b/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
+index 2079a8ed04..a577cb2351 100644
+--- a/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
++++ b/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
+@@ -389,6 +389,12 @@ void QQmlDelegateModelPrivate::connectToAbstractItemModel()
+                       q,  QQmlDelegateModel, SLOT(_q_rowsRemoved(QModelIndex,int,int)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
+                       q,  QQmlDelegateModel, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsInserted(QModelIndex,int,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsInserted(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsRemoved(QModelIndex,int,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsRemoved(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsMoved(QModelIndex,int,int,QModelIndex,int)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
+                       q, QQmlDelegateModel, SLOT(_q_dataChanged(QModelIndex,QModelIndex,QVector<int>)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
+@@ -413,6 +419,12 @@ void QQmlDelegateModelPrivate::disconnectFromAbstractItemModel()
+                         q, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int)));
+     QObject::disconnect(aim, SIGNAL(rowsRemoved(QModelIndex,int,int)),
+                         q, SLOT(_q_rowsRemoved(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsInserted(QModelIndex,int,int)), q,
++                        SLOT(_q_columnsInserted(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsRemoved(QModelIndex,int,int)), q,
++                        SLOT(_q_columnsRemoved(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)), q,
++                        SLOT(_q_columnsMoved(QModelIndex,int,int,QModelIndex,int)));
+     QObject::disconnect(aim, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
+                         q, SLOT(_q_dataChanged(QModelIndex,QModelIndex,QVector<int>)));
+     QObject::disconnect(aim, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
+@@ -1973,6 +1985,38 @@ void QQmlDelegateModel::_q_rowsMoved(
+     }
+ }
+ 
++void QQmlDelegateModel::_q_columnsInserted(const QModelIndex &parent, int begin, int end)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if (parent == d->m_adaptorModel.rootIndex && begin == 0) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
++void QQmlDelegateModel::_q_columnsRemoved(const QModelIndex &parent, int begin, int end)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if (parent == d->m_adaptorModel.rootIndex && begin == 0) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
++void QQmlDelegateModel::_q_columnsMoved(const QModelIndex &parent, int start, int end,
++                                        const QModelIndex &destination, int column)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if ((parent == d->m_adaptorModel.rootIndex && start == 0)
++        || (destination == d->m_adaptorModel.rootIndex && column == 0)) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
+ void QQmlDelegateModel::_q_dataChanged(const QModelIndex &begin, const QModelIndex &end, const QVector<int> &roles)
+ {
+     Q_D(QQmlDelegateModel);
+diff --git a/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h b/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
+index 8aab4badca..d140bfbaaf 100644
+--- a/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
++++ b/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
+@@ -152,6 +152,9 @@ private Q_SLOTS:
+     void _q_itemsMoved(int from, int to, int count);
+     void _q_modelReset();
+     void _q_rowsInserted(const QModelIndex &,int,int);
++    void _q_columnsInserted(const QModelIndex &, int, int);
++    void _q_columnsRemoved(const QModelIndex &, int, int);
++    void _q_columnsMoved(const QModelIndex &, int, int, const QModelIndex &, int);
+     void _q_rowsAboutToBeRemoved(const QModelIndex &parent, int begin, int end);
+     void _q_rowsRemoved(const QModelIndex &,int,int);
+     void _q_rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int);
+diff --git a/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp b/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
+index 85719fdc80..78e2ab302c 100644
+--- a/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
++++ b/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
+@@ -46,6 +46,7 @@
+ #include "QtQuick/private/qquicktextinput_p.h"
+ #include "QtQuick/private/qquickaccessibleattached_p.h"
+ #include "QtQuick/qquicktextdocument.h"
++#include "QtQuick/qquickrendercontrol.h"
+ QT_BEGIN_NAMESPACE
+ 
+ #if QT_CONFIG(accessibility)
+@@ -57,7 +58,19 @@ QAccessibleQuickItem::QAccessibleQuickItem(QQuickItem *item)
+ 
+ QWindow *QAccessibleQuickItem::window() const
+ {
+-    return item()->window();
++    QQuickWindow *window = item()->window();
++
++    // For QQuickWidget the above window will be the offscreen QQuickWindow,
++    // which is not a part of the accessibility tree. Detect this case and
++    // return the window for the QQuickWidget instead.
++    if (window && !window->handle()) {
++        if (QQuickRenderControl *renderControl = QQuickWindowPrivate::get(window)->renderControl) {
++            if (QWindow *renderWindow = renderControl->renderWindow(nullptr))
++                return renderWindow;
++        }
++    }
++
++    return window;
+ }
+ 
+ int QAccessibleQuickItem::childCount() const
+@@ -113,19 +126,15 @@ QAccessibleInterface *QAccessibleQuickItem::childAt(int x, int y) const
+ QAccessibleInterface *QAccessibleQuickItem::parent() const
+ {
+     QQuickItem *parent = item()->parentItem();
+-    QQuickWindow *window = item()->window();
+-    QQuickItem *ci = window ? window->contentItem() : nullptr;
++    QQuickWindow *itemWindow = item()->window();
++    QQuickItem *ci = itemWindow ? itemWindow->contentItem() : nullptr;
+     while (parent && !QQuickItemPrivate::get(parent)->isAccessible && parent != ci)
+         parent = parent->parentItem();
+ 
+     if (parent) {
+         if (parent == ci) {
+-            // Jump out to the scene widget if the parent is the root item.
+-            // There are two root items, QQuickWindow::rootItem and
+-            // QQuickView::declarativeRoot. The former is the true root item,
+-            // but is not a part of the accessibility tree. Check if we hit
+-            // it here and return an interface for the scene instead.
+-            return QAccessible::queryAccessibleInterface(window);
++            // Jump out to the window if the parent is the root item
++            return QAccessible::queryAccessibleInterface(window());
+         } else {
+             while (parent && !parent->d_func()->isAccessible)
+                 parent = parent->parentItem();
+@@ -188,7 +197,7 @@ QAccessible::State QAccessibleQuickItem::state() const
+     QRect viewRect_ = viewRect();
+     QRect itemRect = rect();
+ 
+-    if (viewRect_.isNull() || itemRect.isNull() || !item()->window() || !item()->window()->isVisible() ||!item()->isVisible() || qFuzzyIsNull(item()->opacity()))
++    if (viewRect_.isNull() || itemRect.isNull() || !window() || !window()->isVisible() ||!item()->isVisible() || qFuzzyIsNull(item()->opacity()))
+         state.invisible = true;
+     if (!viewRect_.intersects(itemRect))
+         state.offscreen = true;
+@@ -201,6 +210,10 @@ QAccessible::State QAccessibleQuickItem::state() const
+     if (role() == QAccessible::EditableText)
+         if (auto ti = qobject_cast<QQuickTextInput *>(item()))
+             state.passwordEdit = ti->echoMode() != QQuickTextInput::Normal;
++    if (!item()->isEnabled()) {
++        state.focusable = false;
++        state.disabled = true;
++    }
+     return state;
+ }
+ 
+diff --git a/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h b/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
+index 39ffcaf39c..8baa01330c 100644
+--- a/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
++++ b/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
+@@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE
+ 
+ #if QT_CONFIG(accessibility)
+ 
+-class QAccessibleQuickWindow : public QAccessibleObject
++class Q_QUICK_EXPORT QAccessibleQuickWindow : public QAccessibleObject
+ {
+ public:
+     QAccessibleQuickWindow(QQuickWindow *object);
+diff --git a/qtdeclarative/src/quick/items/qquickdrag.cpp b/qtdeclarative/src/quick/items/qquickdrag.cpp
+index 8321fcfeed..383078b3b9 100644
+--- a/qtdeclarative/src/quick/items/qquickdrag.cpp
++++ b/qtdeclarative/src/quick/items/qquickdrag.cpp
+@@ -481,7 +481,9 @@ void QQuickDragAttached::setKeys(const QStringList &keys)
+     \qmlattachedproperty stringlist QtQuick::Drag::mimeData
+     \since 5.2
+ 
+-    This property holds a map of mimeData that is used during startDrag.
++    This property holds a map from mime type to data that is used during startDrag.
++    The mime data needs to be a \c string, or an \c ArrayBuffer with the data encoded
++    according to the mime type.
+ */
+ 
+ QVariantMap QQuickDragAttached::mimeData() const
+@@ -766,8 +768,12 @@ Qt::DropAction QQuickDragAttachedPrivate::startDrag(Qt::DropActions supportedAct
+     QDrag *drag = new QDrag(source ? source : q);
+     QMimeData *mimeData = new QMimeData();
+ 
+-    for (auto it = externalMimeData.cbegin(), end = externalMimeData.cend(); it != end; ++it)
+-        mimeData->setData(it.key(), it.value().toString().toUtf8());
++    for (auto it = externalMimeData.cbegin(), end = externalMimeData.cend(); it != end; ++it) {
++        if (static_cast<QMetaType::Type>(it.value().type()) == QMetaType::QByteArray)
++            mimeData->setData(it.key(), it.value().toByteArray());
++        else
++            mimeData->setData(it.key(), it.value().toString().toUtf8());
++    }
+ 
+     drag->setMimeData(mimeData);
+     if (pixmapLoader.isReady()) {
+diff --git a/qtdeclarative/src/quick/items/qquickitem.cpp b/qtdeclarative/src/quick/items/qquickitem.cpp
+index 75f1457816..dec0ae19ae 100644
+--- a/qtdeclarative/src/quick/items/qquickitem.cpp
++++ b/qtdeclarative/src/quick/items/qquickitem.cpp
+@@ -59,6 +59,7 @@
+ #include <QtCore/private/qnumeric_p.h>
+ #include <QtGui/qpa/qplatformtheme.h>
+ #include <QtCore/qloggingcategory.h>
++#include <QtCore/private/qduplicatetracker_p.h>
+ 
+ #include <private/qqmlglobal_p.h>
+ #include <private/qqmlengine_p.h>
+@@ -2326,6 +2327,7 @@ QQuickItem::QQuickItem(QQuickItemPrivate &dd, QQuickItem *parent)
+ QQuickItem::~QQuickItem()
+ {
+     Q_D(QQuickItem);
++    d->inDestructor = true;
+ 
+     if (d->windowRefCount > 1)
+         d->windowRefCount = 1; // Make sure window is set to null in next call to derefWindow().
+@@ -2526,6 +2528,7 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo
+     QQuickItem *current = item;
+     qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: startItem:" << startItem;
+     qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: firstFromItem:" << firstFromItem;
++    QDuplicateTracker<QQuickItem *> cycleDetector;
+     do {
+         qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: current:" << current;
+         qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: from:" << from;
+@@ -2592,7 +2595,10 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo
+         // traversed all of the chain (by compare the [current] item with [startItem])
+         // Since the [startItem] might be promoted to its parent if it is invisible,
+         // we still have to check [current] item with original start item
+-        if ((current == startItem || current == originalStartItem) && from == firstFromItem) {
++        // We might also run into a cycle before we reach firstFromItem again
++        // but note that we have to ignore current if we are meant to skip it
++        if (((current == startItem || current == originalStartItem) && from == firstFromItem) ||
++                (!skip && cycleDetector.hasSeen(current))) {
+             // wrapped around, avoid endless loops
+             if (item == contentItem) {
+                 qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: looped, return contentItem";
+@@ -2689,9 +2695,8 @@ void QQuickItem::setParentItem(QQuickItem *parentItem)
+ 
+         const bool wasVisible = isVisible();
+         op->removeChild(this);
+-        if (wasVisible) {
++        if (wasVisible && !op->inDestructor)
+             emit oldParentItem->visibleChildrenChanged();
+-        }
+     } else if (d->window) {
+         QQuickWindowPrivate::get(d->window)->parentlessItems.remove(this);
+     }
+@@ -2768,8 +2773,9 @@ void QQuickItem::setParentItem(QQuickItem *parentItem)
+ 
+     d->itemChange(ItemParentHasChanged, d->parentItem);
+ 
+-    emit parentChanged(d->parentItem);
+-    if (isVisible() && d->parentItem)
++    if (!d->inDestructor)
++        emit parentChanged(d->parentItem);
++    if (isVisible() && d->parentItem && !QQuickItemPrivate::get(d->parentItem)->inDestructor)
+         emit d->parentItem->visibleChildrenChanged();
+ }
+ 
+@@ -2965,7 +2971,8 @@ void QQuickItemPrivate::removeChild(QQuickItem *child)
+ 
+     itemChange(QQuickItem::ItemChildRemovedChange, child);
+ 
+-    emit q->childrenChanged();
++    if (!inDestructor)
++        emit q->childrenChanged();
+ }
+ 
+ void QQuickItemPrivate::refWindow(QQuickWindow *c)
+@@ -3194,6 +3201,7 @@ QQuickItemPrivate::QQuickItemPrivate()
+     , touchEnabled(false)
+ #endif
+     , hasCursorHandler(false)
++    , inDestructor(false)
+     , dirtyAttributes(0)
+     , nextDirtyItem(nullptr)
+     , prevDirtyItem(nullptr)
+@@ -5120,6 +5128,13 @@ void QQuickItem::componentComplete()
+         d->addToDirtyList();
+         QQuickWindowPrivate::get(d->window)->dirtyItem(this);
+     }
++
++#if QT_CONFIG(accessibility)
++    if (d->isAccessible && d->effectiveVisible) {
++        QAccessibleEvent ev(this, QAccessible::ObjectShow);
++        QAccessible::updateAccessibility(&ev);
++    }
++#endif
+ }
+ 
+ QQuickStateGroup *QQuickItemPrivate::_states()
+@@ -6106,9 +6121,11 @@ bool QQuickItemPrivate::setEffectiveVisibleRecur(bool newEffectiveVisible)
+         QAccessible::updateAccessibility(&ev);
+     }
+ #endif
+-    emit q->visibleChanged();
+-    if (childVisibilityChanged)
+-        emit q->visibleChildrenChanged();
++    if (!inDestructor) {
++        emit q->visibleChanged();
++        if (childVisibilityChanged)
++            emit q->visibleChildrenChanged();
++    }
+ 
+     return true;    // effective visibility DID change
+ }
+@@ -6157,6 +6174,15 @@ void QQuickItemPrivate::setEffectiveEnableRecur(QQuickItem *scope, bool newEffec
+     }
+ 
+     itemChange(QQuickItem::ItemEnabledHasChanged, effectiveEnable);
++#if QT_CONFIG(accessibility)
++    if (isAccessible) {
++        QAccessible::State changedState;
++        changedState.disabled = true;
++        changedState.focusable = true;
++        QAccessibleStateChangeEvent ev(q, changedState);
++        QAccessible::updateAccessibility(&ev);
++    }
++#endif
+     emit q->enabledChanged();
+ }
+ 
+diff --git a/qtdeclarative/src/quick/items/qquickitem_p.h b/qtdeclarative/src/quick/items/qquickitem_p.h
+index 841d91bb40..ade8fb61f2 100644
+--- a/qtdeclarative/src/quick/items/qquickitem_p.h
++++ b/qtdeclarative/src/quick/items/qquickitem_p.h
+@@ -472,6 +472,7 @@ public:
+     bool replayingPressEvent:1;
+     bool touchEnabled:1;
+     bool hasCursorHandler:1;
++    quint32 inDestructor:1; // has entered ~QQuickItem
+ 
+     enum DirtyType {
+         TransformOrigin         = 0x00000001,
+diff --git a/qtdeclarative/src/quick/items/qquickitemview.cpp b/qtdeclarative/src/quick/items/qquickitemview.cpp
+index 010a0152e1..f8ad168a17 100644
+--- a/qtdeclarative/src/quick/items/qquickitemview.cpp
++++ b/qtdeclarative/src/quick/items/qquickitemview.cpp
+@@ -1785,7 +1785,7 @@ void QQuickItemViewPrivate::refill(qreal from, qreal to)
+ 
+     do {
+         bufferPause.stop();
+-        if (currentChanges.hasPendingChanges() || bufferedChanges.hasPendingChanges()) {
++        if (currentChanges.hasPendingChanges() || bufferedChanges.hasPendingChanges() || currentChanges.active) {
+             currentChanges.reset();
+             bufferedChanges.reset();
+             releaseVisibleItems(reusableFlag);
+diff --git a/qtdeclarative/src/quick/items/qquickmousearea_p_p.h b/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
+index fba383e268..0d63618622 100644
+--- a/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
++++ b/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
+@@ -61,7 +61,6 @@ QT_BEGIN_NAMESPACE
+ 
+ class QQuickMouseEvent;
+ class QQuickMouseArea;
+-class QQuickPointerMask;
+ class QQuickMouseAreaPrivate : public QQuickItemPrivate
+ {
+     Q_DECLARE_PUBLIC(QQuickMouseArea)
+@@ -100,7 +99,6 @@ public:
+ #if QT_CONFIG(quick_draganddrop)
+     QQuickDrag *drag;
+ #endif
+-    QPointer<QQuickPointerMask> mask;
+     QPointF startScene;
+     QPointF targetStartPos;
+     QPointF lastPos;
+diff --git a/qtdeclarative/src/quick/items/qquicktext.cpp b/qtdeclarative/src/quick/items/qquicktext.cpp
+index 6230186933..e823ca1095 100644
+--- a/qtdeclarative/src/quick/items/qquicktext.cpp
++++ b/qtdeclarative/src/quick/items/qquicktext.cpp
+@@ -2168,7 +2168,7 @@ void QQuickText::resetMaximumLineCount()
+     <img src="" align="top,middle,bottom" width="" height=""> - inline images
+     <ol type="">, <ul type=""> and <li> - ordered and unordered lists
+     <pre></pre> - preformatted
+-    &gt; &lt; &amp;
++    &gt; &lt; &amp; &quot; &nbsp; &apos;
+     \endcode
+ 
+     \c Text.StyledText parser is strict, requiring tags to be correctly nested.
+diff --git a/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp b/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
+index eb4db0f85e..2325a2665b 100644
+--- a/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
++++ b/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
+@@ -446,7 +446,7 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+         const char *textureRecord = allocatorData;
+         for (int i = 0; i < textureCount; ++i, textureRecord += Qtdf::TextureRecordSize) {
+-            if (textureRecord + Qtdf::TextureRecordSize > qtdfTableEnd) {
++            if (qtdfTableEnd - textureRecord < Qtdf::TextureRecordSize) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+@@ -462,7 +462,7 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+         const char *glyphRecord = textureRecord;
+         for (quint32 i = 0; i < glyphCount; ++i, glyphRecord += Qtdf::GlyphRecordSize) {
+-            if (glyphRecord + Qtdf::GlyphRecordSize > qtdfTableEnd) {
++            if (qtdfTableEnd - glyphRecord < Qtdf:: GlyphRecordSize) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+@@ -512,8 +512,8 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+             int width = texInfo->allocatedArea.width();
+             int height = texInfo->allocatedArea.height();
+-            qint64 size = width * height;
+-            if (reinterpret_cast<const char *>(textureData + size) > qtdfTableEnd) {
++            qint64 size = qint64(width) * height;
++            if (qtdfTableEnd - reinterpret_cast<const char *>(textureData) < size) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+diff --git a/qtdeclarative/src/quick/util/qquickstyledtext.cpp b/qtdeclarative/src/quick/util/qquickstyledtext.cpp
+index d531fc9205..a25af90414 100644
+--- a/qtdeclarative/src/quick/util/qquickstyledtext.cpp
++++ b/qtdeclarative/src/quick/util/qquickstyledtext.cpp
+@@ -564,6 +564,8 @@ void QQuickStyledTextPrivate::parseEntity(const QChar *&ch, const QString &textI
+                 textOut += QChar(60);
+             else if (entity == QLatin1String("amp"))
+                 textOut += QChar(38);
++            else if (entity == QLatin1String("apos"))
++                textOut += QChar(39);
+             else if (entity == QLatin1String("quot"))
+                 textOut += QChar(34);
+             else if (entity == QLatin1String("nbsp"))
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp
+new file mode 100644
+index 0000000000..8a1c901880
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp
+@@ -0,0 +1,110 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include "qaccessiblequickwidget_p.h"
++
++#include "qquickwidget_p.h"
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleQuickWidget::QAccessibleQuickWidget(QQuickWidget* widget)
++: QAccessibleWidget(widget)
++, m_accessibleWindow(QQuickWidgetPrivate::get(widget)->offscreenWindow)
++{
++    // NOTE: m_accessibleWindow is a QAccessibleQuickWindow, and not a
++    // QAccessibleQuickWidgetOffscreenWindow (defined below). This means
++    // it will return the Quick item child interfaces, which is what's needed here
++    // (unlike QAccessibleQuickWidgetOffscreenWindow, which will report 0 children).
++}
++
++QAccessibleInterface *QAccessibleQuickWidget::child(int index) const
++{
++    return m_accessibleWindow.child(index);
++}
++
++int QAccessibleQuickWidget::childCount() const
++{
++    return m_accessibleWindow.childCount();
++}
++
++int QAccessibleQuickWidget::indexOfChild(const QAccessibleInterface *iface) const
++{
++    return m_accessibleWindow.indexOfChild(iface);
++}
++
++QAccessibleInterface *QAccessibleQuickWidget::childAt(int x, int y) const
++{
++    return m_accessibleWindow.childAt(x, y);
++}
++
++QAccessibleQuickWidgetOffscreenWindow::QAccessibleQuickWidgetOffscreenWindow(QQuickWindow *window)
++:QAccessibleQuickWindow(window)
++{
++
++}
++
++QAccessibleInterface *QAccessibleQuickWidgetOffscreenWindow::child(int index) const
++{
++    Q_UNUSED(index);
++    return nullptr;
++}
++
++int QAccessibleQuickWidgetOffscreenWindow::childCount() const
++{
++    return 0;
++}
++
++int QAccessibleQuickWidgetOffscreenWindow::indexOfChild(const QAccessibleInterface *iface) const
++{
++    Q_UNUSED(iface);
++    return -1;
++}
++
++QAccessibleInterface *QAccessibleQuickWidgetOffscreenWindow::QAccessibleQuickWidgetOffscreenWindow::childAt(int x, int y) const
++{
++    Q_UNUSED(x);
++    Q_UNUSED(y);
++    return nullptr;
++}
++
++#endif // accessibility
++
++QT_END_NAMESPACE
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h
+new file mode 100644
+index 0000000000..7c2ab930e0
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h
+@@ -0,0 +1,95 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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 QACCESSIBLEQUICKWIDGET_H
++#define QACCESSIBLEQUICKWIDGET_H
++
++//
++//  W A R N I N G
++//  -------------
++//
++// This file is not part of the Qt API.  It exists purely as an
++// implementation detail.  This header file may change from version to
++// version without notice, or even be removed.
++//
++// We mean it.
++//
++
++#include "qquickwidget.h"
++#include <QtWidgets/qaccessiblewidget.h>
++
++#include <private/qaccessiblequickview_p.h>
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++// These classes implement the QQuickWiget accessibility switcharoo,
++// where the child items of the QQuickWidgetOffscreenWindow are reported
++// as child accessible interfaces of the QAccessibleQuickWidget.
++class QAccessibleQuickWidget: public QAccessibleWidget
++{
++public:
++    QAccessibleQuickWidget(QQuickWidget* widget);
++
++    QAccessibleInterface *child(int index) const override;
++    int childCount() const override;
++    int indexOfChild(const QAccessibleInterface *iface) const override;
++    QAccessibleInterface *childAt(int x, int y) const override;
++
++private:
++    QAccessibleQuickWindow m_accessibleWindow;
++    Q_DISABLE_COPY(QAccessibleQuickWidget)
++};
++
++class QAccessibleQuickWidgetOffscreenWindow: public QAccessibleQuickWindow
++{
++public:
++    QAccessibleQuickWidgetOffscreenWindow(QQuickWindow *window);
++    QAccessibleInterface *child(int index) const override;
++    int childCount() const override;
++    int indexOfChild(const QAccessibleInterface *iface) const override;
++    QAccessibleInterface *childAt(int x, int y) const override;
++};
++
++#endif // accessibility
++
++QT_END_NAMESPACE
++
++#endif
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp
+new file mode 100644
+index 0000000000..7ba88a1769
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp
+@@ -0,0 +1,60 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include "qaccessiblequickwidgetfactory_p.h"
++#include "qaccessiblequickwidget_p.h"
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleInterface *qAccessibleQuickWidgetFactory(const QString &classname, QObject *object)
++{
++    if (classname == QLatin1String("QQuickWidget")) {
++        return new QAccessibleQuickWidget(qobject_cast<QQuickWidget *>(object));
++    } else if (classname == QLatin1String("QQuickWidgetOffscreenWindow")) {
++        return new QAccessibleQuickWidgetOffscreenWindow(qobject_cast<QQuickWindow *>(object));
++    }
++    return 0;
++}
++
++#endif // accessibility
++
++QT_END_NAMESPACE
++
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h
+new file mode 100644
+index 0000000000..8c63b09f81
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h
+@@ -0,0 +1,66 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include <QtGui/qaccessible.h>
++
++#ifndef QACCESSIBLEQUICKWIDGETFACTORY_H
++#define QACCESSIBLEQUICKWIDGETFACTORY_H
++
++//
++//  W A R N I N G
++//  -------------
++//
++// This file is not part of the Qt API.  It exists purely as an
++// implementation detail.  This header file may change from version to
++// version without notice, or even be removed.
++//
++// We mean it.
++//
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleInterface *qAccessibleQuickWidgetFactory(const QString &classname, QObject *object);
++
++#endif
++
++QT_END_NAMESPACE
++
++#endif
+diff --git a/qtdeclarative/src/quickwidgets/qquickwidget.cpp b/qtdeclarative/src/quickwidgets/qquickwidget.cpp
+index 39780f8de3..9c97b43518 100644
+--- a/qtdeclarative/src/quickwidgets/qquickwidget.cpp
++++ b/qtdeclarative/src/quickwidgets/qquickwidget.cpp
+@@ -39,6 +39,7 @@
+ 
+ #include "qquickwidget.h"
+ #include "qquickwidget_p.h"
++#include "qaccessiblequickwidgetfactory_p.h"
+ 
+ #include "private/qquickwindow_p.h"
+ #include "private/qquickitem_p.h"
+@@ -75,9 +76,16 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++QQuickWidgetOffscreenWindow::QQuickWidgetOffscreenWindow(QQuickWindowPrivate &dd, QQuickRenderControl *control)
++:QQuickWindow(dd, control)
++{
++    setTitle(QString::fromLatin1("Offscreen"));
++    setObjectName(QString::fromLatin1("QQuickOffScreenWindow"));
++}
++
+ // override setVisble to prevent accidental offscreen window being created
+ // by base class.
+-class QQuickOffcreenWindowPrivate: public QQuickWindowPrivate {
++class QQuickWidgetOffscreenWindowPrivate: public QQuickWindowPrivate {
+ public:
+     void setVisible(bool visible) override {
+         Q_Q(QWindow);
+@@ -105,9 +113,8 @@ void QQuickWidgetPrivate::init(QQmlEngine* e)
+     Q_Q(QQuickWidget);
+ 
+     renderControl = new QQuickWidgetRenderControl(q);
+-    offscreenWindow = new QQuickWindow(*new QQuickOffcreenWindowPrivate(),renderControl);
+-    offscreenWindow->setTitle(QString::fromLatin1("Offscreen"));
+-    offscreenWindow->setObjectName(QString::fromLatin1("QQuickOffScreenWindow"));
++    offscreenWindow = new QQuickWidgetOffscreenWindow(*new QQuickWidgetOffscreenWindowPrivate(), renderControl);
++    offscreenWindow->setScreen(q->screen());
+     // Do not call create() on offscreenWindow.
+ 
+     // Check if the Software Adaptation is being used
+@@ -138,6 +145,10 @@ void QQuickWidgetPrivate::init(QQmlEngine* e)
+     QWidget::connect(offscreenWindow, &QQuickWindow::focusObjectChanged, q, &QQuickWidget::propagateFocusObjectChanged);
+     QObject::connect(renderControl, SIGNAL(renderRequested()), q, SLOT(triggerUpdate()));
+     QObject::connect(renderControl, SIGNAL(sceneChanged()), q, SLOT(triggerUpdate()));
++
++#if QT_CONFIG(accessibility)
++    QAccessible::installFactory(&qAccessibleQuickWidgetFactory);
++#endif
+ }
+ 
+ void QQuickWidgetPrivate::ensureEngine() const
+@@ -901,9 +912,7 @@ void QQuickWidgetPrivate::createContext()
+ 
+         context = new QOpenGLContext;
+         context->setFormat(offscreenWindow->requestedFormat());
+-        const QWindow *win = q->window()->windowHandle();
+-        if (win && win->screen())
+-            context->setScreen(win->screen());
++        context->setScreen(q->screen());
+         QOpenGLContext *shareContext = qt_gl_global_share_context();
+         if (!shareContext)
+             shareContext = QWidgetPrivate::get(q->window())->shareContext();
+@@ -1520,19 +1529,16 @@ bool QQuickWidget::event(QEvent *e)
+         d->handleWindowChange();
+         break;
+ 
+-    case QEvent::ScreenChangeInternal:
+-        if (QWindow *window = this->window()->windowHandle()) {
+-            QScreen *newScreen = window->screen();
+-
+-            if (d->offscreenWindow)
+-                d->offscreenWindow->setScreen(newScreen);
+-            if (d->offscreenSurface)
+-                d->offscreenSurface->setScreen(newScreen);
++    case QEvent::ScreenChangeInternal: {
++        QScreen *newScreen = screen();
++        if (d->offscreenWindow)
++            d->offscreenWindow->setScreen(newScreen);
++        if (d->offscreenSurface)
++            d->offscreenSurface->setScreen(newScreen);
+ #if QT_CONFIG(opengl)
+-            if (d->context)
+-                d->context->setScreen(newScreen);
++        if (d->context)
++            d->context->setScreen(newScreen);
+ #endif
+-        }
+ 
+         if (d->useSoftwareRenderer
+ #if QT_CONFIG(opengl)
+@@ -1545,7 +1551,7 @@ bool QQuickWidget::event(QEvent *e)
+             d->render(true);
+         }
+         break;
+-
++    }
+     case QEvent::Show:
+     case QEvent::Move:
+         d->updatePosition();
+diff --git a/qtdeclarative/src/quickwidgets/qquickwidget_p.h b/qtdeclarative/src/quickwidgets/qquickwidget_p.h
+index 881f7f9220..1a946bcc71 100644
+--- a/qtdeclarative/src/quickwidgets/qquickwidget_p.h
++++ b/qtdeclarative/src/quickwidgets/qquickwidget_p.h
+@@ -148,6 +148,14 @@ public:
+     bool forceFullUpdate;
+ };
+ 
++class QQuickWidgetOffscreenWindow: public QQuickWindow
++{
++    Q_OBJECT
++
++public:
++    QQuickWidgetOffscreenWindow(QQuickWindowPrivate &dd, QQuickRenderControl *control);
++};
++
+ QT_END_NAMESPACE
+ 
+ #endif // QQuickWidget_P_H
+diff --git a/qtdeclarative/src/quickwidgets/quickwidgets.pro b/qtdeclarative/src/quickwidgets/quickwidgets.pro
+index 2438e577ae..85d156b8a3 100644
+--- a/qtdeclarative/src/quickwidgets/quickwidgets.pro
++++ b/qtdeclarative/src/quickwidgets/quickwidgets.pro
+@@ -7,9 +7,13 @@ DEFINES   += QT_NO_URL_CAST_FROM_STRING QT_NO_INTEGER_EVENT_COORDINATES QT_NO_FO
+ HEADERS += \
+     qquickwidget.h \
+     qquickwidget_p.h \
+-    qtquickwidgetsglobal.h
++    qtquickwidgetsglobal.h \
++    qaccessiblequickwidget_p.h \
++    qaccessiblequickwidgetfactory_p.h
+ 
+ SOURCES += \
+-    qquickwidget.cpp
++    qquickwidget.cpp \
++    qaccessiblequickwidget.cpp \
++    qaccessiblequickwidgetfactory.cpp
+ 
+ load(qt_module)
+diff --git a/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+index 3b7d74df63..b75bf820d5 100644
+--- a/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
++++ b/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+@@ -102,6 +102,7 @@ private slots:
+     void valueConversion_RegularExpression();
+     void castWithMultipleInheritance();
+     void collectGarbage();
++    void collectGarbageNestedWrappersTwoEngines();
+     void gcWithNestedDataStructure();
+     void stacktrace();
+     void numberParsing_data();
+@@ -1809,6 +1810,44 @@ void tst_QJSEngine::collectGarbage()
+     QVERIFY(ptr.isNull());
+ }
+ 
++class TestObjectContainer : public QObject
++{
++    Q_OBJECT
++    Q_PROPERTY(QObject *dummy MEMBER m_dummy CONSTANT)
++
++public:
++    TestObjectContainer() : m_dummy(new QObject(this)) {}
++
++private:
++    QObject *m_dummy;
++};
++
++void tst_QJSEngine::collectGarbageNestedWrappersTwoEngines()
++{
++    QJSEngine engine1;
++    QJSEngine engine2;
++
++    TestObjectContainer container;
++    QQmlEngine::setObjectOwnership(&container, QQmlEngine::CppOwnership);
++
++    engine1.globalObject().setProperty("foobar", engine1.newQObject(&container));
++    engine2.globalObject().setProperty("foobar", engine2.newQObject(&container));
++
++    engine1.evaluate("foobar.dummy.baz = 42");
++    engine2.evaluate("foobar.dummy.baz = 43");
++
++    QCOMPARE(engine1.evaluate("foobar.dummy.baz").toInt(), 42);
++    QCOMPARE(engine2.evaluate("foobar.dummy.baz").toInt(), 43);
++
++    engine1.collectGarbage();
++    engine2.collectGarbage();
++
++    // The GC should not collect dummy object wrappers neither in engine1 nor engine2, we
++    // verify that by checking whether the baz property still has its previous value.
++    QCOMPARE(engine1.evaluate("foobar.dummy.baz").toInt(), 42);
++    QCOMPARE(engine2.evaluate("foobar.dummy.baz").toInt(), 43);
++}
++
+ void tst_QJSEngine::gcWithNestedDataStructure()
+ {
+     // The GC must be able to traverse deeply nested objects, otherwise this
+diff --git a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml
+new file mode 100644
+index 0000000000..206133bb39
+--- /dev/null
++++ b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml
+@@ -0,0 +1,11 @@
++import QtQuick 2.8
++
++ListView {
++    id: root
++    width: 200
++    height: 200
++
++    delegate: Text {
++        text: display
++    }
++}
+diff --git a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
+index 35f1e2c94d..1722447830 100644
+--- a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
++++ b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
+@@ -27,6 +27,8 @@
+ ****************************************************************************/
+ 
+ #include <QtTest/qtest.h>
++#include <QtCore/QConcatenateTablesProxyModel>
++#include <QtGui/QStandardItemModel>
+ #include <QtQml/qqmlcomponent.h>
+ #include <QtQmlModels/private/qqmldelegatemodel_p.h>
+ #include <QtQuick/qquickview.h>
+@@ -47,6 +49,7 @@ private slots:
+     void filterOnGroup_removeWhenCompleted();
+     void qtbug_86017();
+     void contextAccessedByHandler();
++    void redrawUponColumnChange();
+ };
+ 
+ class AbstractItemModel : public QAbstractItemModel
+@@ -186,6 +189,30 @@ void tst_QQmlDelegateModel::contextAccessedByHandler()
+     QVERIFY(root->property("works").toBool());
+ }
+ 
++void tst_QQmlDelegateModel::redrawUponColumnChange()
++{
++    QStandardItemModel m1;
++    m1.appendRow({
++            new QStandardItem("Banana"),
++            new QStandardItem("Coconut"),
++    });
++
++    QQuickView view(testFileUrl("redrawUponColumnChange.qml"));
++    QCOMPARE(view.status(), QQuickView::Ready);
++    view.show();
++    QQuickItem *root = view.rootObject();
++    root->setProperty("model", QVariant::fromValue<QObject *>(&m1));
++
++    QObject *item = root->property("currentItem").value<QObject *>();
++    QVERIFY(item);
++    QCOMPARE(item->property("text").toString(), "Banana");
++
++    QVERIFY(root);
++    m1.removeColumn(0);
++
++    QCOMPARE(item->property("text").toString(), "Coconut");
++}
++
+ QTEST_MAIN(tst_QQmlDelegateModel)
+ 
+ #include "tst_qqmldelegatemodel.moc"
+diff --git a/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp b/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
+index 5d635aa63b..824fd89e5b 100644
+--- a/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
++++ b/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
+@@ -76,10 +76,10 @@ void tst_qv4mm::multiWrappedQObjects()
+         QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 1);
+         QCOMPARE(engine2.memoryManager->m_pendingFreedObjectWrapperValue.size(), 0);
+ 
+-        // Moves the additional WeakValue from m_multiplyWrappedQObjects to
+-        // m_pendingFreedObjectWrapperValue. It's still alive after all.
++        // The additional WeakValue from m_multiplyWrappedQObjects hasn't been moved
++        // to m_pendingFreedObjectWrapperValue yet. It's still alive after all.
+         engine1.memoryManager->runGC();
+-        QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 2);
++        QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 1);
+ 
+         // engine2 doesn't own the object as engine1 was the first to wrap it above.
+         // Therefore, no effect here.
+diff --git a/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml b/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml
+new file mode 100644
+index 0000000000..889e480f3b
+--- /dev/null
++++ b/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml
+@@ -0,0 +1,13 @@
++import QtQuick 2.6
++
++Item {
++    visible: true
++    Item {
++        visible: false
++        Item {
++            objectName: "hiddenChild"
++            activeFocusOnTab: true
++            focus: true
++        }
++    }
++}
+diff --git a/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp b/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+index c8f251dbe1..c8ef36ee68 100644
+--- a/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
++++ b/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+@@ -67,6 +67,7 @@ private slots:
+     void activeFocusOnTab10();
+     void activeFocusOnTab_infiniteLoop_data();
+     void activeFocusOnTab_infiniteLoop();
++    void activeFocusOnTab_infiniteLoopControls();
+ 
+     void nextItemInFocusChain();
+     void nextItemInFocusChain2();
+@@ -1057,6 +1058,17 @@ void tst_QQuickItem::activeFocusOnTab_infiniteLoop()
+     QCOMPARE(item, window->rootObject());
+ }
+ 
++
++void tst_QQuickItem::activeFocusOnTab_infiniteLoopControls()
++{
++    auto source = testFileUrl("activeFocusOnTab_infiniteLoop3.qml");
++    QScopedPointer<QQuickView>window(new QQuickView());
++    window->setSource(source);
++    window->show();
++    QVERIFY(window->errors().isEmpty());
++    QTest::keyClick(window.get(), Qt::Key_Tab); // should not hang
++}
++
+ void tst_QQuickItem::nextItemInFocusChain()
+ {
+     if (!qt_tab_all_widgets())
+Submodule qtdoc c0c7bf07...79d6ef69:
+Submodule qtimageformats 2dcf2899..abe44c0f:
+diff --git a/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp b/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
+index dde783c..1bf9074 100644
+--- a/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
+@@ -462,8 +462,12 @@ static bool parseIconEntryInfo(ICNSEntry &icon)
+     if (isIconCompressed(icon))
+         return true;
+     // Icon depth:
+-    if (!depth.isEmpty())
+-        icon.depth = ICNSEntry::Depth(depth.toUInt());
++    if (!depth.isEmpty()) {
++        const uint depthUInt = depth.toUInt();
++        if (depthUInt > 32)
++            return false;
++        icon.depth = ICNSEntry::Depth(depthUInt);
++    }
+     // Try mono if depth not found
+     if (icon.depth == ICNSEntry::DepthUnknown)
+         icon.depth = ICNSEntry::DepthMono;
+@@ -515,6 +519,9 @@ static bool parseIconEntryInfo(ICNSEntry &icon)
+         }
+         icon.height = icon.width;
+     }
++    // Sanity check
++    if (icon.width == 0 || icon.width > 4096)
++        return false;
+     return true;
+ }
+ 
+@@ -685,7 +692,7 @@ bool QICNSHandler::canRead() const
+ bool QICNSHandler::read(QImage *outImage)
+ {
+     QImage img;
+-    if (!ensureScanned()) {
++    if (!ensureScanned() || m_currentIconIndex >= m_icons.size()) {
+         qWarning("QICNSHandler::read(): The device wasn't parsed properly!");
+         return false;
+     }
+@@ -892,7 +899,7 @@ bool QICNSHandler::scanDevice()
+             return false;
+ 
+         const qint64 blockDataOffset = device()->pos();
+-        if (!isBlockHeaderValid(blockHeader)) {
++        if (!isBlockHeaderValid(blockHeader, ICNSBlockHeaderSize + filelength - blockDataOffset)) {
+             qWarning("QICNSHandler::scanDevice(): Failed, bad header at pos %s. OSType \"%s\", length %u",
+                      QByteArray::number(blockDataOffset).constData(),
+                      nameFromOSType(blockHeader.ostype).constData(), blockHeader.length);
+@@ -927,11 +934,14 @@ bool QICNSHandler::scanDevice()
+         case ICNSBlockHeader::TypeOdrp:
+             // Icns container seems to have an embedded icon variant container
+             // Let's start a scan for entries
+-            while (device()->pos() < nextBlockOffset) {
++            while (!stream.atEnd() && device()->pos() < nextBlockOffset) {
+                 ICNSBlockHeader icon;
+                 stream >> icon;
++                if (stream.status() != QDataStream::Ok)
++                    return false;
+                 // Check for incorrect variant entry header and stop scan
+-                if (!isBlockHeaderValid(icon, blockDataLength))
++                quint64 remaining = blockDataLength - (device()->pos() - blockDataOffset);
++                if (!isBlockHeaderValid(icon, ICNSBlockHeaderSize + remaining))
+                     break;
+                 if (!addEntry(icon, device()->pos(), blockHeader.ostype))
+                     return false;
+@@ -1003,7 +1013,7 @@ bool QICNSHandler::scanDevice()
+             break;
+         }
+     }
+-    return true;
++    return (m_icons.size() > 0);
+ }
+ 
+ const ICNSEntry &QICNSHandler::getIconMask(const ICNSEntry &icon) const
+diff --git a/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp b/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
+index 5082023..cb34374 100644
+--- a/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
++++ b/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
+@@ -43,6 +43,7 @@
+ #include "qimage.h"
+ #include "qvariant.h"
+ #include "qcolor.h"
++#include "qimagereader.h"
+ 
+ #include <jasper/jasper.h>
+ #include <math.h> // for pow
+@@ -333,16 +334,46 @@ private:
+ Jpeg2000JasperReader::Jpeg2000JasperReader(QIODevice *iod, SubFormat format)
+     : jasperOk(true), ioDevice(iod), format(format), hasAlpha(false)
+ {
++#if JAS_VERSION_MAJOR < 3
+     if (jas_init()) {
+         jasperOk = false;
+         qDebug("Jasper Library initialization failed");
+     }
++#else
++    jas_conf_clear();
++#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
++    jas_conf_set_max_mem_usage(QImageReader::allocationLimit() * 1024 * 1024);
++#else
++    // 128MB seems to be enough.
++    jas_conf_set_max_mem_usage(128 * 1024 * 1024);
++#endif
++    if (jas_init_library()) {
++        jasperOk = false;
++        qDebug("Jasper library initialization failed");
++    }
++    if (jas_init_thread()) {
++        jas_cleanup_library();
++        jasperOk = false;
++        qDebug("Jasper thread initialization failed");
++    }
++#endif
+ }
+ 
+ Jpeg2000JasperReader::~Jpeg2000JasperReader()
+ {
++#if JAS_VERSION_MAJOR < 3
+     if (jasperOk)
+         jas_cleanup();
++#else
++    if (jasperOk) {
++        if (jas_cleanup_thread()) {
++            qDebug("Jasper thread cleanup failed");
++        }
++        if (jas_cleanup_library()) {
++            qDebug("Jasper library cleanup failed");
++        }
++    }
++#endif
+ }
+ 
+ /*! \internal
+@@ -857,7 +888,7 @@ bool Jpeg2000JasperReader::write(const QImage &image, int quality)
+     }
+ 
+     // Open an empty jasper stream that grows automatically
+-    jas_stream_t * memory_stream = jas_stream_memopen(0, -1);
++    jas_stream_t * memory_stream = jas_stream_memopen(0, 0);
+ 
+     // Jasper wants a non-const string.
+     char *str = qstrdup(jasperFormatString.toLatin1().constData());
+diff --git a/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp b/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
+index 1386750..ac8956c 100644
+--- a/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
+@@ -361,6 +361,8 @@ bool QTiffHandler::read(QImage *image)
+     }
+ 
+     TIFF *const tiff = d->tiff;
++    if (TIFFIsTiled(tiff) && TIFFTileSize64(tiff) > uint64_t(image->sizeInBytes())) // Corrupt image
++        return false;
+     const quint32 width = d->size.width();
+     const quint32 height = d->size.height();
+ 
+diff --git a/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp b/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
+index 82d38cb..d02eb05 100644
+--- a/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
+@@ -45,6 +45,7 @@
+ #include <qdebug.h>
+ #include <qpainter.h>
+ #include <qvariant.h>
++#include <QtEndian>
+ 
+ static const int riffHeaderSize = 12; // RIFF_HEADER_SIZE from webp/format_constants.h
+ 
+@@ -102,21 +103,23 @@ bool QWebpHandler::ensureScanned() const
+ 
+     m_scanState = ScanError;
+ 
+-    if (device()->isSequential()) {
+-        qWarning() << "Sequential devices are not supported";
++    QWebpHandler *that = const_cast<QWebpHandler *>(this);
++    const int headerBytesNeeded = sizeof(WebPBitstreamFeatures);
++    QByteArray header = device()->peek(headerBytesNeeded);
++    if (header.size() < headerBytesNeeded)
+         return false;
+-    }
+ 
+-    qint64 oldPos = device()->pos();
+-    device()->seek(0);
+-
+-    QWebpHandler *that = const_cast<QWebpHandler *>(this);
+-    QByteArray header = device()->peek(sizeof(WebPBitstreamFeatures));
++    // We do no random access during decoding, just a readAll() of the whole image file. So if
++    // if it is all available already, we can accept a sequential device. The riff header contains
++    // the file size minus 8 bytes header
++    qint64 byteSize = qFromLittleEndian<quint32>(header.constData() + 4);
++    if (device()->isSequential() && device()->bytesAvailable() < byteSize + 8) {
++        qWarning() << "QWebpHandler: Insufficient data available in sequential device";
++        return false;
++    }
+     if (WebPGetFeatures((const uint8_t*)header.constData(), header.size(), &(that->m_features)) == VP8_STATUS_OK) {
+         if (m_features.has_animation) {
+             // For animation, we have to read and scan whole file to determine loop count and images count
+-            device()->seek(oldPos);
+-
+             if (that->ensureDemuxer()) {
+                 that->m_loop = WebPDemuxGetI(m_demuxer, WEBP_FF_LOOP_COUNT);
+                 that->m_frameCount = WebPDemuxGetI(m_demuxer, WEBP_FF_FRAME_COUNT);
+@@ -126,17 +129,13 @@ bool QWebpHandler::ensureScanned() const
+                 if (that->m_features.has_alpha)
+                     that->m_composited->fill(Qt::transparent);
+ 
+-                // We do not reset device position since we have read in all data
+                 m_scanState = ScanSuccess;
+-                return true;
+             }
+         } else {
+             m_scanState = ScanSuccess;
+         }
+     }
+ 
+-    device()->seek(oldPos);
+-
+     return m_scanState == ScanSuccess;
+ }
+ 
+@@ -159,7 +158,7 @@ bool QWebpHandler::ensureDemuxer()
+ 
+ bool QWebpHandler::read(QImage *image)
+ {
+-    if (!ensureScanned() || device()->isSequential() || !ensureDemuxer())
++    if (!ensureScanned() || !ensureDemuxer())
+         return false;
+ 
+     QRect prevFrameRect;
+Submodule qtlocation 98a5c511..f991e28c:
+diff --git a/qtlocation/src/location/configure.json b/qtlocation/src/location/configure.json
+index 6d01a9a3..d1e623a1 100644
+--- a/qtlocation/src/location/configure.json
++++ b/qtlocation/src/location/configure.json
+@@ -9,7 +9,7 @@
+             "label": "Qt.labs.location experimental QML plugin",
+             "purpose": "Provides experimental QtLocation QML types",
+             "section": "Location",
+-            "condition": "config.opengl",
++            "condition": "features.opengl",
+             "output": [ "privateFeature" ]
+         },
+         "geoservices_osm": {
+diff --git a/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp b/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
+index a978573d..11e1466f 100644
+--- a/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
++++ b/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
+@@ -158,7 +158,7 @@ void QGeoMapObjectQSGSupport::updateMapObjects(QSGNode *root, QQuickWindow *wind
+     if (!root)
+         return;
+ 
+-    if (m_mapObjectsRootNode && m_mapObjectsRootNode->parent())
++    if (m_mapObjectsRootNode && !m_mapObjectsRootNode->parent())
+         root->appendChildNode(m_mapObjectsRootNode.get());
+ 
+     if (!m_mapObjectsRootNode) {
+diff --git a/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
+index 5a40467e..d123c6a8 100644
+--- a/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
+@@ -59,8 +59,10 @@ QT_BEGIN_NAMESPACE
+ static const QString kPrefixEsri(QStringLiteral("esri."));
+ static const QString kParamUserAgent(kPrefixEsri + QStringLiteral("useragent"));
+ 
+-static const QString kUrlGeocode(QStringLiteral("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates"));
+-static const QString kUrlReverseGeocode(QStringLiteral("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode"));
++static const QString kUrlGeocode(QStringLiteral("https://geocode.arcgis.com/arcgis/rest/services/"
++                                                "World/GeocodeServer/findAddressCandidates"));
++static const QString kUrlReverseGeocode(QStringLiteral(
++        "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode"));
+ 
+ static QString addressToQuery(const QGeoAddress &address)
+ {
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
+index 17492d94..96c12b1b 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
+@@ -46,7 +46,8 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-// JSON reference: http://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
++// JSON reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
+ 
+ static const QString kErrorMessage(QStringLiteral("Error %1: %2."));
+ static const QString kErrorJson(QStringLiteral("Error: invalide JSON document."));
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
+index 8cadfb29..92b6bb13 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
+@@ -44,7 +44,8 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-// JSON reference: http://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
++// JSON reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
+ 
+ GeoRouteReplyEsri::GeoRouteReplyEsri(QNetworkReply *reply, const QGeoRouteRequest &request,
+                                      QObject *parent) :
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
+index 0e6bc2c7..ed613f4b 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
+@@ -48,7 +48,8 @@ static const QString kPrefixEsri(QStringLiteral("esri."));
+ static const QString kParamUserAgent(kPrefixEsri + QStringLiteral("useragent"));
+ static const QString kParamToken(kPrefixEsri + QStringLiteral("token"));
+ 
+-static const QString kUrlRouting(QStringLiteral("http://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve"));
++static const QString kUrlRouting(QStringLiteral(
++        "https://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve"));
+ 
+ GeoRoutingManagerEngineEsri::GeoRoutingManagerEngineEsri(const QVariantMap &parameters,
+                                                          QGeoServiceProvider::Error *error,
+@@ -70,7 +71,8 @@ GeoRoutingManagerEngineEsri::~GeoRoutingManagerEngineEsri()
+ {
+ }
+ 
+-// REST reference: http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
++// REST reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
+ 
+ QGeoRouteReply *GeoRoutingManagerEngineEsri::calculateRoute(const QGeoRouteRequest &request)
+ {
+@@ -125,7 +127,7 @@ void GeoRoutingManagerEngineEsri::replyError(QGeoRouteReply::Error errorCode, co
+ QString GeoRoutingManagerEngineEsri::preferedDirectionLangage()
+ {
+     // list of supported langages is defined in:
+-    // http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
++    // https://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
+     const QStringList supportedLanguages = {
+         "ar", // Generate directions in Arabic
+         "cs", // Generate directions in Czech
+diff --git a/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
+index 5d15835d..24148f95 100644
+--- a/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
+@@ -230,7 +230,8 @@ QGeoMap *GeoTiledMappingManagerEngineEsri::createMap()
+ // ${y} = Y
+ // ${token} = Token
+ 
+-// template = 'http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{{z}}/{{y}}/{{x}}.png'
++// template =
++// 'https://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{{z}}/{{y}}/{{x}}.png'
+ 
+ bool GeoTiledMappingManagerEngineEsri::initializeMapSources(QGeoServiceProvider::Error *error,
+                                                             QString *errorString,
+diff --git a/qtlocation/src/plugins/geoservices/esri/maps.json b/qtlocation/src/plugins/geoservices/esri/maps.json
+index 8167ae7d..862e087d 100644
+--- a/qtlocation/src/plugins/geoservices/esri/maps.json
++++ b/qtlocation/src/plugins/geoservices/esri/maps.json
+@@ -6,8 +6,8 @@
+             "description": "ArcGIS Online World Street Map",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=3b93337983e9436f8db950e38a8629af'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=3b93337983e9436f8db950e38a8629af'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -16,8 +16,8 @@
+             "": "ArcGIS Online World Imagery",
+             "mobile": true,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -26,8 +26,8 @@
+             "description": "ArcGIS Online World Terrain Base",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=c61ad8ab017d49e1a82f580ee1298931'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=c61ad8ab017d49e1a82f580ee1298931'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -36,8 +36,8 @@
+             "description": "ArcGIS Online World Topography",
+             "mobile": true,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=30e5fe3149c34df1ba922e6f5bbf808f'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=30e5fe3149c34df1ba922e6f5bbf808f'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -46,8 +46,8 @@
+             "description": "This map presents land cover and detailed topographic maps for the United States.",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=99cd5fbd98934028802b4f797c4b1732'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=99cd5fbd98934028802b4f797c4b1732'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -56,8 +56,8 @@
+             "description": "National Geographic World Map",
+             "mobile": false,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=b9b1b422198944fbbd5250b3241691b6'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=b9b1b422198944fbbd5250b3241691b6'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -66,8 +66,8 @@
+             "description": "Thematic content providing a neutral background with minimal colors",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=ed712cb1db3e4bae9e85329040fb9a49'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=ed712cb1db3e4bae9e85329040fb9a49'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -76,8 +76,8 @@
+             "description": "Natural Earth physical map for the world",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=c4ec722a1cd34cf0a23904aadf8923a0'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=c4ec722a1cd34cf0a23904aadf8923a0'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -86,8 +86,8 @@
+             "description": "Portrays surface elevation as shaded relief",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=9c5370d0b54f4de1b48a3792d7377ff2'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=9c5370d0b54f4de1b48a3792d7377ff2'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -96,8 +96,8 @@
+             "description": "This map is designed to be used as a basemap by marine GIS professionals and as a reference map by anyone interested in ocean data",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=1e126e7520f9466c9ca28b8f28b5e500'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=1e126e7520f9466c9ca28b8f28b5e500'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -106,8 +106,8 @@
+             "description": "Thematic content providing a neutral background with minimal colors",
+             "mobile": false,
+             "night": true,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=a284a9b99b3446a3910d4144a50990f6'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=a284a9b99b3446a3910d4144a50990f6'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -116,8 +116,8 @@
+             "description": "DeLorme’s topographic basemap is a seamless global data set that portrays transportation, hydrography, jurisdiction boundaries, and major geographic features",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/Specialty/DeLorme_World_Base_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=b165c3df453e4be6b5ac4fdb241effbe'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/Specialty/DeLorme_World_Base_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=b165c3df453e4be6b5ac4fdb241effbe'>Esri</a> contributors"
+         }
+     ]
+ }
+diff --git a/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
+index 3858ddf5..af66f28e 100644
+--- a/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
+@@ -63,8 +63,10 @@ static const QString kCountriesKey(QStringLiteral("detailedCountries"));
+ static const QString kLocalizedNamesKey(QStringLiteral("localizedNames"));
+ static const QString kMaxLocationsKey(QStringLiteral("maxLocations"));
+ 
+-static const QUrl kUrlGeocodeServer("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer?f=pjson");
+-static const QUrl kUrlFindAddressCandidates("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates");
++static const QUrl kUrlGeocodeServer(
++        "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer?f=pjson");
++static const QUrl kUrlFindAddressCandidates("https://geocode.arcgis.com/arcgis/rest/services/World/"
++                                            "GeocodeServer/findAddressCandidates");
+ 
+ PlaceManagerEngineEsri::PlaceManagerEngineEsri(const QVariantMap &parameters, QGeoServiceProvider::Error *error,
+                                                QString *errorString) :
+Submodule qtmultimedia f0344079..0d7cc33a:
+diff --git a/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp b/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
+index 2b5325132..b68b4af1b 100644
+--- a/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
++++ b/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
+@@ -402,6 +402,8 @@ int QPulseAudioInput::bytesReady() const
+ 
+ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ {
++    Q_ASSERT(data != nullptr || len == 0);
++
+     m_bytesAvailable = checkBytesReady();
+ 
+     setError(QAudio::NoError);
+@@ -411,7 +413,8 @@ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ 
+     if (!m_pullMode && !m_tempBuffer.isEmpty()) {
+         readBytes = qMin(static_cast<int>(len), m_tempBuffer.size());
+-        memcpy(data, m_tempBuffer.constData(), readBytes);
++        if (readBytes)
++            memcpy(data, m_tempBuffer.constData(), readBytes);
+         m_totalTimeValue += readBytes;
+ 
+         if (readBytes < m_tempBuffer.size()) {
+@@ -502,9 +505,10 @@ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ 
+ void QPulseAudioInput::applyVolume(const void *src, void *dest, int len)
+ {
++    Q_ASSERT((src && dest) || len == 0);
+     if (m_volume < 1.f)
+         QAudioHelperInternal::qMultiplySamples(m_volume, m_format, src, dest, len);
+-    else
++    else if (len)
+         memcpy(dest, src, len);
+ }
+ 
+Submodule qtpim 02efef5e...f9a8f0fc (commits not present)
+Submodule qtquick3d b85cf622..47defc8b:
+diff --git a/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro b/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
+index ca5c499e..174a075b 100644
+--- a/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
++++ b/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
+@@ -10,7 +10,7 @@ QT_FOR_CONFIG += assetimporters-private
+ include($$OUT_PWD/../qtassetimporters-config.pri)
+ 
+ qtConfig(system-assimp):!if(cross_compile:host_build) {
+-    QMAKE_USE_PRIVATE += assimp
++    QMAKE_USE_PRIVATE += quick3d-assimp
+ } else {
+     include(../../../3rdparty/assimp/assimp.pri)
+ }
+Submodule qtquickcontrols2 3a657dc0..56ce8233:
+diff --git a/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp b/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
+index e5fe734f7..e36922775 100644
+--- a/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
++++ b/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
+@@ -38,6 +38,7 @@
+ #include "qwidgetplatformmenuitem_p.h"
+ 
+ #include <QtGui/qwindow.h>
++#include <QtGui/private/qhighdpiscaling_p.h>
+ #include <QtWidgets/qmenu.h>
+ #include <QtWidgets/qaction.h>
+ 
+@@ -145,7 +146,7 @@ void QWidgetPlatformMenu::showPopup(const QWindow *window, const QRect &targetRe
+ 
+     QPoint targetPos = targetRect.bottomLeft();
+     if (window)
+-        targetPos = window->mapToGlobal(targetPos);
++        targetPos = window->mapToGlobal(QHighDpi::fromNativeLocalPosition(targetPos, window));
+ 
+     const QWidgetPlatformMenuItem *widgetItem = qobject_cast<const QWidgetPlatformMenuItem *>(item);
+     m_menu->popup(targetPos, widgetItem ? widgetItem->action() : nullptr);
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
+index 950e4e099..b81fbea0b 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
+@@ -387,6 +387,17 @@ void QQuickAbstractButtonPrivate::itemImplicitHeightChanged(QQuickItem *item)
+         emit q->implicitIndicatorHeightChanged();
+ }
+ 
++void QQuickAbstractButtonPrivate::itemDestroyed(QQuickItem *item)
++{
++    Q_Q(QQuickAbstractButton);
++    QQuickControlPrivate::itemDestroyed(item);
++    if (item == indicator) {
++        indicator = nullptr;
++        emit q->implicitIndicatorWidthChanged();
++        emit q->implicitIndicatorHeightChanged();
++    }
++}
++
+ QQuickAbstractButton *QQuickAbstractButtonPrivate::findCheckedButton() const
+ {
+     Q_Q(const QQuickAbstractButton);
+@@ -1176,6 +1187,12 @@ QAccessible::Role QQuickAbstractButton::accessibleRole() const
+     }
+     return QAccessible::Button;
+ }
++
++void QQuickAbstractButton::accessiblePressAction()
++{
++    Q_D(QQuickAbstractButton);
++    d->trigger();
++}
+ #endif
+ 
+ QT_END_NAMESPACE
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
+index 0fa48980e..ab66220d0 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
+@@ -209,6 +209,7 @@ protected:
+ #if QT_CONFIG(accessibility)
+     void accessibilityActiveChanged(bool active) override;
+     QAccessible::Role accessibleRole() const override;
++    Q_INVOKABLE void accessiblePressAction();
+ #endif
+ 
+ private:
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
+index 9291c1a87..b729720f2 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
+@@ -109,6 +109,7 @@ public:
+ 
+     void itemImplicitWidthChanged(QQuickItem *item) override;
+     void itemImplicitHeightChanged(QQuickItem *item) override;
++    void itemDestroyed(QQuickItem *item) override;
+ 
+     // copied from qabstractbutton.cpp
+     static const int AUTO_REPEAT_DELAY = 300;
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp b/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
+index 2041e7741..8610cdfae 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
+@@ -145,7 +145,7 @@ int QQuickActionPrivate::ShortcutEntry::shortcutId() const
+ 
+ void QQuickActionPrivate::ShortcutEntry::grab(const QKeySequence &shortcut, bool enabled)
+ {
+-    if (shortcut.isEmpty())
++    if (shortcut.isEmpty() || m_shortcutId)
+         return;
+ 
+     Qt::ShortcutContext context = Qt::WindowShortcut; // TODO
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp b/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
+index f38c2b09c..6eed2a024 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
+@@ -225,6 +225,7 @@ void QQuickContainerPrivate::cleanup()
+     QObject::disconnect(contentModel, &QQmlObjectModel::countChanged, q, &QQuickContainer::countChanged);
+     QObject::disconnect(contentModel, &QQmlObjectModel::childrenChanged, q, &QQuickContainer::contentChildrenChanged);
+     delete contentModel;
++    contentModel = nullptr;
+ }
+ 
+ QQuickItem *QQuickContainerPrivate::itemAt(int index) const
+@@ -436,7 +437,7 @@ void QQuickContainerPrivate::contentChildren_clear(QQmlListProperty<QQuickItem>
+ void QQuickContainerPrivate::updateContentWidth()
+ {
+     Q_Q(QQuickContainer);
+-    if (hasContentWidth || qFuzzyCompare(contentWidth, implicitContentWidth))
++    if (hasContentWidth || qFuzzyCompare(contentWidth, implicitContentWidth) || !contentModel)
+         return;
+ 
+     contentWidth = implicitContentWidth;
+@@ -446,7 +447,7 @@ void QQuickContainerPrivate::updateContentWidth()
+ void QQuickContainerPrivate::updateContentHeight()
+ {
+     Q_Q(QQuickContainer);
+-    if (hasContentHeight || qFuzzyCompare(contentHeight, implicitContentHeight))
++    if (hasContentHeight || qFuzzyCompare(contentHeight, implicitContentHeight) || !contentModel)
+         return;
+ 
+     contentHeight = implicitContentHeight;
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp b/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
+index bbbd0e622..1f4b47343 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
+@@ -845,6 +845,13 @@ void QQuickControlPrivate::executeBackground(bool complete)
+         quickCompleteDeferred(q, backgroundName(), background);
+ }
+ 
++/*
++    \internal
++
++    Hides an item that was replaced by a newer one, rather than
++    deleting it, as the item is typically created in QML and hence
++    we don't own it.
++*/
+ void QQuickControlPrivate::hideOldItem(QQuickItem *item)
+ {
+     if (!item)
+@@ -863,6 +870,29 @@ void QQuickControlPrivate::hideOldItem(QQuickItem *item)
+ #endif
+ }
+ 
++/*
++    \internal
++
++    Named "unhide" because it's used for cases where an item
++    that was previously hidden by \l hideOldItem() wants to be
++    shown by a control again, such as a ScrollBar in ScrollView.
++*/
++void QQuickControlPrivate::unhideOldItem(QQuickControl *control, QQuickItem *item)
++{
++    Q_ASSERT(item);
++    qCDebug(lcItemManagement) << "unhiding old item" << item;
++
++    item->setVisible(true);
++    item->setParentItem(control);
++
++#if QT_CONFIG(accessibility)
++    // Add the item back in to the accessibility tree.
++    QQuickAccessibleAttached *accessible = accessibleAttached(item);
++    if (accessible)
++        accessible->setIgnored(false);
++#endif
++}
++
+ void QQuickControlPrivate::updateBaselineOffset()
+ {
+     Q_Q(QQuickControl);
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h b/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
+index 8e979079e..a6e624c91 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
+@@ -173,6 +173,7 @@ public:
+     virtual void executeBackground(bool complete = false);
+ 
+     static void hideOldItem(QQuickItem *item);
++    static void unhideOldItem(QQuickControl *control, QQuickItem *item);
+ 
+     void updateBaselineOffset();
+ 
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp b/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
+index e6db14eb5..6197d1547 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
+@@ -237,7 +237,7 @@ static QRectF alignedRect(Qt::LayoutDirection direction, Qt::Alignment alignment
+ void QQuickDialogButtonBoxPrivate::resizeContent()
+ {
+     Q_Q(QQuickDialogButtonBox);
+-    if (!contentItem)
++    if (!contentItem || !contentModel)
+         return;
+ 
+     QRectF geometry = q->boundingRect().adjusted(q->leftPadding(), q->topPadding(), -q->rightPadding(), -q->bottomPadding());
+@@ -322,6 +322,9 @@ void QQuickDialogButtonBoxPrivate::updateLayout()
+ qreal QQuickDialogButtonBoxPrivate::getContentWidth() const
+ {
+     Q_Q(const QQuickDialogButtonBox);
++    if (!contentModel)
++        return 0;
++
+     const int count = contentModel->count();
+     const qreal totalSpacing = qMax(0, count - 1) * spacing;
+     qreal totalWidth = totalSpacing;
+@@ -341,6 +344,9 @@ qreal QQuickDialogButtonBoxPrivate::getContentWidth() const
+ qreal QQuickDialogButtonBoxPrivate::getContentHeight() const
+ {
+     Q_Q(const QQuickDialogButtonBox);
++    if (!contentModel)
++        return 0;
++
+     const int count = contentModel->count();
+     qreal maxHeight = 0;
+     for (int i = 0; i < count; ++i) {
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp b/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
+index 91bd59184..0ce518f84 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
+@@ -399,8 +399,11 @@ void QQuickOverlay::itemChange(ItemChange change, const ItemChangeData &data)
+     Q_D(QQuickOverlay);
+     QQuickItem::itemChange(change, data);
+ 
+-    if (change == ItemChildAddedChange || change == ItemChildRemovedChange)
++    if (change == ItemChildAddedChange || change == ItemChildRemovedChange) {
+         setVisible(!d->allDrawers.isEmpty() || !childItems().isEmpty());
++        if (data.item->parent() == d->mouseGrabberPopup)
++            d->setMouseGrabberPopup(nullptr);
++    }
+ }
+ 
+ void QQuickOverlay::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp b/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
+index 4e2f509db..1c4b308cd 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
+@@ -797,6 +797,14 @@ void QQuickScrollBarAttachedPrivate::initHorizontal()
+     if (parent && parent == flickable->parentItem())
+         horizontal->stackAfter(flickable);
+ 
++    // If a scroll bar was previously hidden (due to e.g. setting a new contentItem
++    // on a ScrollView), we need to make sure that we un-hide it.
++    // We don't bother checking if the item is actually the old one, because
++    // if it's not, all of the things the function does (setting parent, visibility, etc.)
++    // should be no-ops anyway.
++    if (auto control = qobject_cast<QQuickControl*>(q_ptr->parent()))
++        QQuickControlPrivate::unhideOldItem(control, horizontal);
++
+     layoutHorizontal();
+     horizontal->setSize(area->property("widthRatio").toReal());
+     horizontal->setPosition(area->property("xPosition").toReal());
+@@ -818,6 +826,9 @@ void QQuickScrollBarAttachedPrivate::initVertical()
+     if (parent && parent == flickable->parentItem())
+         vertical->stackAfter(flickable);
+ 
++    if (auto control = qobject_cast<QQuickControl*>(q_ptr->parent()))
++        QQuickControlPrivate::unhideOldItem(control, vertical);
++
+     layoutVertical();
+     vertical->setSize(area->property("heightRatio").toReal());
+     vertical->setPosition(area->property("yPosition").toReal());
+diff --git a/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml b/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
+index 0e8b08352..cd4931184 100644
+--- a/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
++++ b/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
+@@ -576,4 +576,51 @@ TestCase {
+         verify(newHorizontalScrollBar.visible)
+         verify(!oldHorizontalScrollBar.visible)
+     }
++
++    Component {
++        id: bindingToContentItemAndStandaloneFlickable
++
++        Item {
++            width: 200
++            height: 200
++
++            property alias scrollView: scrollView
++
++            ScrollView {
++                id: scrollView
++                anchors.fill: parent
++                contentItem: listView
++
++                property Item someBinding: contentItem
++            }
++            ListView {
++                id: listView
++                model: 10
++                delegate: ItemDelegate {
++                    text: modelData
++                    width: listView.width
++                }
++            }
++        }
++    }
++
++    // Tests that scroll bars show up for a ScrollView where
++    // - its contentItem is declared as a standalone, separate item
++    // - there is a binding to contentItem (which causes a default Flickable to be created)
++    function test_bindingToContentItemAndStandaloneFlickable() {
++        let root = createTemporaryObject(bindingToContentItemAndStandaloneFlickable, testCase)
++        verify(root)
++
++        let control = root.scrollView
++        let verticalScrollBar = control.ScrollBar.vertical
++        let horizontalScrollBar = control.ScrollBar.horizontal
++        compare(verticalScrollBar.parent, control)
++        compare(horizontalScrollBar.parent, control)
++        verify(verticalScrollBar.visible)
++        verify(horizontalScrollBar.visible)
++
++        mouseDrag(verticalScrollBar, verticalScrollBar.width / 2, verticalScrollBar.height / 2, 0, 50)
++        verify(verticalScrollBar.active)
++        verify(horizontalScrollBar.active)
++    }
+ }
+diff --git a/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml b/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
+index b3fab41ca..10b6baa02 100644
+--- a/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
++++ b/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
+@@ -608,4 +608,27 @@ TestCase {
+         mouseClick(control.indicator)
+         verify(control.activeFocus)
+     }
++
++    Component {
++        id: deletionOrder1
++        Item {
++            Image { id: innerImage }
++            Switch { indicator: innerImage }
++        }
++    }
++
++    Component {
++        id: deletionOrder2
++        Item {
++            Switch { indicator: innerImage }
++            Image { id: innerImage }
++        }
++    }
++
++    function test_deletionOrder() {
++        var control1 = createTemporaryObject(deletionOrder1, testCase)
++        verify(control1)
++        var control2 = createTemporaryObject(deletionOrder2, testCase)
++        verify(control2)
++    }
+ }
+diff --git a/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml b/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml
+new file mode 100644
+index 000000000..9e4598b9f
+--- /dev/null
++++ b/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml
+@@ -0,0 +1,78 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the test suite of the Qt Toolkit.
++**
++** $QT_BEGIN_LICENSE:BSD$
++** Commercial License Usage
++** Licensees holding valid commercial Qt licenses may use this file in
++** accordance with the commercial license agreement provided with the
++** Software or, alternatively, in accordance with the terms contained in
++** a written agreement between you and The Qt Company. For licensing terms
++** and conditions see https://www.qt.io/terms-conditions. For further
++** information use the contact form at https://www.qt.io/contact-us.
++**
++** BSD License Usage
++** Alternatively, you may use this file under the terms of the BSD license
++** as follows:
++**
++** "Redistribution and use in source and binary forms, with or without
++** modification, are permitted provided that the following conditions are
++** met:
++**   * Redistributions of source code must retain the above copyright
++**     notice, this list of conditions and the following disclaimer.
++**   * Redistributions in binary form must reproduce the above copyright
++**     notice, this list of conditions and the following disclaimer in
++**     the documentation and/or other materials provided with the
++**     distribution.
++**   * Neither the name of The Qt Company Ltd nor the names of its
++**     contributors may be used to endorse or promote products derived
++**     from this software without specific prior written permission.
++**
++**
++** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
++** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
++** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
++** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
++** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
++** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
++** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
++** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
++** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
++** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
++** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
++**
++** $QT_END_LICENSE$
++**
++****************************************************************************/
++
++import QtQuick 2.15
++import QtQuick.Controls 2.15
++
++ApplicationWindow {
++    id: window
++    width: 400
++    height: 400
++    title: "releaseAfterExitTransition"
++
++    property alias popup: popup
++    property alias modalPopup: modalPopup
++
++    Popup {
++        id: popup
++        y: parent.height - height
++        width: 50
++        height: 50
++    }
++
++    Popup {
++        id: modalPopup
++        modal: true
++        y: parent.height - height
++        width: 50
++        height: 50
++        exit:  Transition { PauseAnimation { duration: 100 } }
++    }
++}
+diff --git a/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp b/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
+index 54952d128..3d50e2dd4 100644
+--- a/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
++++ b/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
+@@ -100,6 +100,7 @@ private slots:
+     void invisibleToolTipOpen();
+     void centerInOverlayWithinStackViewItem();
+     void destroyDuringExitTransition();
++    void releaseAfterExitTransition();
+ };
+ 
+ void tst_QQuickPopup::initTestCase()
+@@ -1575,6 +1576,34 @@ void tst_QQuickPopup::destroyDuringExitTransition()
+     QVERIFY(!button->isDown());
+ }
+ 
++void tst_QQuickPopup::releaseAfterExitTransition()
++{
++    QQuickApplicationHelper helper(this, "releaseAfterExitTransition.qml");
++    QVERIFY2(helper.ready, helper.failureMessage());
++
++    QQuickWindow *window = helper.window;
++    window->show();
++    QVERIFY(QTest::qWaitForWindowActive(window));
++
++    QQuickOverlay *overlay = QQuickOverlay::overlay(window);
++    QQuickPopup *modalPopup = window->property("modalPopup").value<QQuickPopup *>();
++    QQuickPopup *popup = window->property("popup").value<QQuickPopup *>();
++
++    modalPopup->open();
++    QTRY_VERIFY(modalPopup->isOpened());
++
++    QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++    // wait until the transition is finished and the overlay hides itself
++    QTRY_VERIFY(!overlay->isVisible());
++    QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++
++    popup->open();
++    QTRY_VERIFY(popup->isOpened());
++    QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++    QTRY_VERIFY(!popup->isOpened());
++}
++
++
+ QTEST_QUICKCONTROLS_MAIN(tst_QQuickPopup)
+ 
+ #include "tst_qquickpopup.moc"
+Submodule qtscript 5be95f96...4d8e4bd2 (commits not present)
+Submodule qtspeech 17fc9fde..255845e2:
+diff --git a/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp b/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
+index 6eb74b8..bcc7dd1 100644
+--- a/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
++++ b/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
+@@ -357,7 +357,9 @@ QVector<QLocale> QTextToSpeechEngineSpeechd::availableLocales() const
+ 
+ QVector<QVoice> QTextToSpeechEngineSpeechd::availableVoices() const
+ {
+-    return m_voices.values(m_currentLocale.name()).toVector();
++    QList<QVoice> resultList = m_voices.values(m_currentLocale.name());
++    std::reverse(resultList.begin(), resultList.end());
++    return resultList.toVector();
+ }
+ 
+ // We have no way of knowing our own client_id since speech-dispatcher seems to be incomplete
+Submodule qtsvg 0c05780e..a7a0f249:
+diff --git a/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp b/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
+index 561e77e..12e0574 100644
+--- a/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
++++ b/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
+@@ -191,6 +191,8 @@ bool QSvgIOHandler::read(QImage *image)
+             }
+         }
+         if (!finalSize.isEmpty()) {
++            if (qMax(finalSize.width(), finalSize.height()) > 0xffff)
++                return false; // Assume corrupted file
+             image->fill(d->backColor.rgba());
+             QPainter p(image);
+             d->r.render(&p, bounds);
+diff --git a/qtsvg/src/svg/qsvghandler.cpp b/qtsvg/src/svg/qsvghandler.cpp
+index a5f877f..8dda563 100644
+--- a/qtsvg/src/svg/qsvghandler.cpp
++++ b/qtsvg/src/svg/qsvghandler.cpp
+@@ -1393,9 +1393,10 @@ static void parseFont(QSvgNode *node,
+         case FontSizeNone:
+             break;
+         case FontSizeValue: {
+-            QSvgHandler::LengthType dummy; // should always be pixel size
+-            fontStyle->setSize(qMin(parseLength(attributes.fontSize, dummy, handler),
+-                                    qreal(0xffff)));
++            QSvgHandler::LengthType type;
++            qreal fs = parseLength(attributes.fontSize, type, handler);
++            fs = convertToPixels(fs, true, type);
++            fontStyle->setSize(qMin(fs, qreal(0xffff)));
+         }
+             break;
+         default:
+@@ -2513,6 +2514,8 @@ static bool parseAnimateTransformNode(QSvgNode *parent,
+             ++s;
+         }
+     }
++    if (vals.count() % 3 != 0)
++        return false;
+ 
+     bool ok = true;
+     int begin = parseClockValue(beginStr, &ok);
+@@ -2576,6 +2579,8 @@ static QSvgNode *createCircleNode(QSvgNode *parent,
+     qreal ncx = toDouble(cx);
+     qreal ncy = toDouble(cy);
+     qreal nr  = toDouble(r);
++    if (nr < 0.0)
++        return nullptr;
+ 
+     QRectF rect(ncx-nr, ncy-nr, nr*2, nr*2);
+     QSvgNode *circle = new QSvgCircle(parent, rect);
+@@ -3046,15 +3051,16 @@ static QSvgStyleProperty *createRadialGradientNode(QSvgNode *node,
+ 
+     qreal ncx = 0.5;
+     qreal ncy = 0.5;
+-    qreal nr  = 0.5;
+     if (!cx.isEmpty())
+         ncx = toDouble(cx);
+     if (!cy.isEmpty())
+         ncy = toDouble(cy);
++
++    qreal nr = 0.0;
+     if (!r.isEmpty())
+         nr = toDouble(r);
+-    if (nr < 0.5)
+-        nr = 0.5;
++    if (nr <= 0.0)
++        return nullptr;
+ 
+     qreal nfx = ncx;
+     if (!fx.isEmpty())
+@@ -3350,7 +3356,9 @@ static QSvgNode *createTextNode(QSvgNode *parent,
+     //### editable and rotate not handled
+     QSvgHandler::LengthType type;
+     qreal nx = parseLength(x, type, handler);
++    nx = convertToPixels(nx, true, type);
+     qreal ny = parseLength(y, type, handler);
++    ny = convertToPixels(ny, true, type);
+ 
+     QSvgNode *text = new QSvgText(parent, QPointF(nx, ny));
+     return text;
+@@ -3691,9 +3699,7 @@ void QSvgHandler::parse()
+         case QXmlStreamReader::EndElement:
+             endElement(xml->name());
+             ++remainingUnfinishedElements;
+-            // if we are using somebody else's qxmlstreamreader
+-            // we should not read until the end of the stream
+-            done = !m_ownsReader && (xml->name() == QLatin1String("svg"));
++            done = (xml->name() == QLatin1String("svg"));
+             break;
+         case QXmlStreamReader::Characters:
+             characters(xml->text());
+diff --git a/qtsvg/src/svg/qsvgstructure.cpp b/qtsvg/src/svg/qsvgstructure.cpp
+index b89608b..89c9e4e 100644
+--- a/qtsvg/src/svg/qsvgstructure.cpp
++++ b/qtsvg/src/svg/qsvgstructure.cpp
+@@ -255,9 +255,13 @@ inline static bool isSupportedSvgFeature(const QString &str)
+     };
+ 
+     if (str.length() <= MAX_WORD_LENGTH && str.length() >= MIN_WORD_LENGTH) {
++        const char16_t unicode44 = str.at(44).unicode();
++        const char16_t unicode45 = str.at(45).unicode();
++        if (unicode44 >= sizeof(asso_values) || unicode45 >= sizeof(asso_values))
++            return false;
+         const int key = str.length()
+-                        + asso_values[str.at(45).unicode()]
+-                        + asso_values[str.at(44).unicode()];
++                        + asso_values[unicode45]
++                        + asso_values[unicode44];
+         if (key <= MAX_HASH_VALUE && key >= 0)
+             return str == QLatin1String(wordlist[key]);
+     }
+diff --git a/qtsvg/src/svg/qsvgtinydocument.cpp b/qtsvg/src/svg/qsvgtinydocument.cpp
+index 63d0797..19e7154 100644
+--- a/qtsvg/src/svg/qsvgtinydocument.cpp
++++ b/qtsvg/src/svg/qsvgtinydocument.cpp
+@@ -433,8 +433,16 @@ void QSvgTinyDocument::draw(QPainter *p, QSvgExtraStates &)
+     draw(p);
+ }
+ 
++static bool isValidMatrix(const QTransform &transform)
++{
++    qreal determinant = transform.determinant();
++    return qIsFinite(determinant);
++}
++
+ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect, const QRectF &sourceRect)
+ {
++    QTransform oldTransform = p->worldTransform();
++
+     QRectF target = targetRect;
+     if (target.isEmpty()) {
+         QPaintDevice *dev = p->device();
+@@ -487,6 +495,9 @@ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect,
+         }
+ #endif
+     }
++
++    if (!isValidMatrix(p->worldTransform()))
++        p->setWorldTransform(oldTransform);
+ }
+ 
+ QRectF QSvgTinyDocument::boundsOnElement(const QString &id) const
+diff --git a/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp b/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
+index 36c76ec..db71e02 100644
+--- a/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
++++ b/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
+@@ -86,6 +86,8 @@ private slots:
+     void oss_fuzz_23731();
+     void oss_fuzz_24131();
+     void oss_fuzz_24738();
++    void illegalAnimateTransform_data();
++    void illegalAnimateTransform();
+ 
+ #ifndef QT_NO_COMPRESS
+     void testGzLoading();
+@@ -1646,5 +1648,22 @@ void tst_QSvgRenderer::oss_fuzz_24738()
+     QSvgRenderer().load(QByteArray("<svg><path d=\"a 2 1e-212.....\">"));
+ }
+ 
++void tst_QSvgRenderer::illegalAnimateTransform_data()
++{
++    QTest::addColumn<QByteArray>("svg");
++
++    QTest::newRow("case1") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" values=\"8,0,5,0\">");
++    QTest::newRow("case2") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" values=\"1,2\">");
++    QTest::newRow("case3") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" from=\".. 5 2\" to=\"f\">");
++    QTest::newRow("case4") << QByteArray("<svg><animateTransform type=\"scale\" begin=\"1\" dur=\"2\" by=\"--,..\">");
++}
++
++void tst_QSvgRenderer::illegalAnimateTransform()
++{
++    QFETCH(QByteArray, svg);
++    QSvgRenderer renderer;
++    QVERIFY(!renderer.load(svg)); // also shouldn't assert
++}
++
+ QTEST_MAIN(tst_QSvgRenderer)
+ #include "tst_qsvgrenderer.moc"
+Submodule qttools 6914f7c8..090e526e:
+diff --git a/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp b/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
+index feab1e2d5..cbfb82507 100644
+--- a/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
++++ b/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
+@@ -445,7 +445,9 @@ bool HelpGeneratorPrivate::insertFiles(const QStringList &files, const QString &
+     if (filterSetId < 0)
+         return false;
+     ++filterSetId;
+-    for (int attId : qAsConst(filterAtts)) {
++    QList<int> attValues = filterAtts.values();
++    std::sort(attValues.begin(), attValues.end());
++    for (int attId : qAsConst(attValues)) {
+         m_query->prepare(QLatin1String("INSERT INTO FileAttributeSetTable "
+             "VALUES(?, ?)"));
+         m_query->bindValue(0, filterSetId);
+Submodule qtwayland dfb0129c..2904e1b3:
+diff --git a/qtwayland/src/client/configure.json b/qtwayland/src/client/configure.json
+index 2f424580..29222357 100644
+--- a/qtwayland/src/client/configure.json
++++ b/qtwayland/src/client/configure.json
+@@ -149,8 +149,7 @@
+                     "#endif"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "vulkan-server-buffer": {
+             "label": "Vulkan Buffer Sharing",
+@@ -168,7 +167,8 @@
+                     "exportAllocInfo.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR;",
+                     "return 0;"
+                 ]
+-            }
++            },
++            "use": "wayland-client"
+         },
+         "egl_1_5-wayland": {
+             "label": "EGL 1.5 with Wayland Platform",
+@@ -183,7 +183,7 @@
+                     "eglGetPlatformDisplay(EGL_PLATFORM_WAYLAND_EXT, (struct wl_display *)(nullptr), nullptr);"
+                 ]
+             },
+-            "use": "egl"
++            "use": "egl wayland-client"
+         }
+     },
+ 
+diff --git a/qtwayland/src/client/global/qwaylandclientextension.cpp b/qtwayland/src/client/global/qwaylandclientextension.cpp
+index 125b1e19..edccfe63 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension.cpp
++++ b/qtwayland/src/client/global/qwaylandclientextension.cpp
+@@ -74,7 +74,10 @@ void QWaylandClientExtensionPrivate::handleRegistryGlobal(void *data, ::wl_regis
+ void QWaylandClientExtension::addRegistryListener()
+ {
+     Q_D(QWaylandClientExtension);
+-    d->waylandIntegration->display()->addRegistryListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++    if (!d->registered) {
++        d->waylandIntegration->display()->addRegistryListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++        d->registered = true;
++    }
+ }
+ 
+ QWaylandClientExtension::QWaylandClientExtension(const int ver)
+@@ -88,6 +91,13 @@ QWaylandClientExtension::QWaylandClientExtension(const int ver)
+     QMetaObject::invokeMethod(this, "addRegistryListener", Qt::QueuedConnection);
+ }
+ 
++QWaylandClientExtension::~QWaylandClientExtension()
++{
++    Q_D(QWaylandClientExtension);
++    if (d->registered && !QCoreApplication::closingDown())
++        d->waylandIntegration->display()->removeListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++}
++
+ QtWaylandClient::QWaylandIntegration *QWaylandClientExtension::integration() const
+ {
+     Q_D(const QWaylandClientExtension);
+diff --git a/qtwayland/src/client/global/qwaylandclientextension.h b/qtwayland/src/client/global/qwaylandclientextension.h
+index 98272e57..5bd28398 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension.h
++++ b/qtwayland/src/client/global/qwaylandclientextension.h
+@@ -63,6 +63,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandClientExtension : public QObject
+     Q_PROPERTY(bool active READ isActive NOTIFY activeChanged)
+ public:
+     QWaylandClientExtension(const int version);
++    ~QWaylandClientExtension();
+ 
+     QtWaylandClient::QWaylandIntegration *integration() const;
+     int version() const;
+diff --git a/qtwayland/src/client/global/qwaylandclientextension_p.h b/qtwayland/src/client/global/qwaylandclientextension_p.h
+index 69cc46a0..9091efbe 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension_p.h
++++ b/qtwayland/src/client/global/qwaylandclientextension_p.h
+@@ -68,6 +68,7 @@ public:
+     QtWaylandClient::QWaylandIntegration *waylandIntegration = nullptr;
+     int version = -1;
+     bool active = false;
++    bool registered = false;
+ };
+ 
+ class Q_WAYLAND_CLIENT_EXPORT QWaylandClientExtensionTemplatePrivate : public QWaylandClientExtensionPrivate
+diff --git a/qtwayland/src/client/qwaylanddatadevice.cpp b/qtwayland/src/client/qwaylanddatadevice.cpp
+index 7e2e3308..e3e60ed5 100644
+--- a/qtwayland/src/client/qwaylanddatadevice.cpp
++++ b/qtwayland/src/client/qwaylanddatadevice.cpp
+@@ -72,6 +72,8 @@ QWaylandDataDevice::QWaylandDataDevice(QWaylandDataDeviceManager *manager, QWayl
+ 
+ QWaylandDataDevice::~QWaylandDataDevice()
+ {
++    if (wl_data_device_get_version(object()) >= WL_DATA_DEVICE_RELEASE_SINCE_VERSION)
++        release();
+ }
+ 
+ QWaylandDataOffer *QWaylandDataDevice::selectionOffer() const
+@@ -110,7 +112,7 @@ QWaylandDataOffer *QWaylandDataDevice::dragOffer() const
+     return m_dragOffer.data();
+ }
+ 
+-bool QWaylandDataDevice::startDrag(QMimeData *mimeData, QWaylandWindow *icon)
++bool QWaylandDataDevice::startDrag(QMimeData *mimeData, Qt::DropActions supportedActions, QWaylandWindow *icon)
+ {
+     auto *seat = m_display->currentInputDevice();
+     auto *origin = seat->pointerFocus();
+@@ -123,7 +125,28 @@ bool QWaylandDataDevice::startDrag(QMimeData *mimeData, QWaylandWindow *icon)
+     }
+ 
+     m_dragSource.reset(new QWaylandDataSource(m_display->dndSelectionHandler(), mimeData));
++
++    if (wl_data_device_get_version(object()) >= 3)
++        m_dragSource->set_actions(dropActionsToWl(supportedActions));
++
+     connect(m_dragSource.data(), &QWaylandDataSource::cancelled, this, &QWaylandDataDevice::dragSourceCancelled);
++    connect(m_dragSource.data(), &QWaylandDataSource::dndResponseUpdated, this, [this](bool accepted, Qt::DropAction action) {
++            auto drag = static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag());
++            // in old versions drop action is not set, so we guess
++            if (wl_data_source_get_version(m_dragSource->object()) < 3) {
++                drag->setResponse(accepted);
++            } else {
++                QPlatformDropQtResponse response(accepted, action);
++                drag->setResponse(response);
++            }
++    });
++    connect(m_dragSource.data(), &QWaylandDataSource::dndDropped, this, [](bool accepted, Qt::DropAction action) {
++        QPlatformDropQtResponse response(accepted, action);
++        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setDropResponse(response);
++    });
++    connect(m_dragSource.data(), &QWaylandDataSource::finished, this, []() {
++        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag();
++    });
+ 
+     start_drag(m_dragSource->object(), origin->wlSurface(), icon->wlSurface(), m_display->currentInputDevice()->serial());
+     return true;
+@@ -152,7 +175,7 @@ void QWaylandDataDevice::data_device_drop()
+         supportedActions = drag->supportedActions();
+     } else if (m_dragOffer) {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     } else {
+         return;
+     }
+@@ -162,7 +185,11 @@ void QWaylandDataDevice::data_device_drop()
+                                                                           QGuiApplication::keyboardModifiers());
+ 
+     if (drag) {
+-        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag(response);
++        auto drag =  static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag());
++        drag->setDropResponse(response);
++        drag->finishDrag();
++    } else if (m_dragOffer) {
++        m_dragOffer->finish();
+     }
+ }
+ 
+@@ -186,7 +213,7 @@ void QWaylandDataDevice::data_device_enter(uint32_t serial, wl_surface *surface,
+         supportedActions = drag->supportedActions();
+     } else if (m_dragOffer) {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     }
+ 
+     const QPlatformDragQtResponse &response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
+@@ -197,11 +224,7 @@ void QWaylandDataDevice::data_device_enter(uint32_t serial, wl_surface *surface,
+         static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setResponse(response);
+     }
+ 
+-    if (response.isAccepted()) {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, m_dragOffer->firstFormat().toUtf8().constData());
+-    } else {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, nullptr);
+-    }
++    sendResponse(supportedActions, response);
+ }
+ 
+ void QWaylandDataDevice::data_device_leave()
+@@ -235,10 +258,10 @@ void QWaylandDataDevice::data_device_motion(uint32_t time, wl_fixed_t x, wl_fixe
+         supportedActions = drag->supportedActions();
+     } else {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     }
+ 
+-    QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
++    const QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
+                                                                           QGuiApplication::mouseButtons(),
+                                                                           QGuiApplication::keyboardModifiers());
+ 
+@@ -246,11 +269,7 @@ void QWaylandDataDevice::data_device_motion(uint32_t time, wl_fixed_t x, wl_fixe
+         static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setResponse(response);
+     }
+ 
+-    if (response.isAccepted()) {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, m_dragOffer->firstFormat().toUtf8().constData());
+-    } else {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, nullptr);
+-    }
++    sendResponse(supportedActions, response);
+ }
+ #endif // QT_CONFIG(draganddrop)
+ 
+@@ -277,14 +296,10 @@ void QWaylandDataDevice::selectionSourceCancelled()
+ #if QT_CONFIG(draganddrop)
+ void QWaylandDataDevice::dragSourceCancelled()
+ {
++    static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag();
+     m_dragSource.reset();
+ }
+ 
+-void QWaylandDataDevice::dragSourceTargetChanged(const QString &mimeType)
+-{
+-    static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->updateTarget(mimeType);
+-}
+-
+ QPoint QWaylandDataDevice::calculateDragPosition(int x, int y, QWindow *wnd) const
+ {
+     QPoint pnt(wl_fixed_to_int(x), wl_fixed_to_int(y));
+@@ -297,6 +312,33 @@ QPoint QWaylandDataDevice::calculateDragPosition(int x, int y, QWindow *wnd) con
+     }
+     return pnt;
+ }
++
++void QWaylandDataDevice::sendResponse(Qt::DropActions supportedActions, const QPlatformDragQtResponse &response)
++{
++    if (response.isAccepted()) {
++        if (wl_data_device_get_version(object()) >= 3)
++            m_dragOffer->set_actions(dropActionsToWl(supportedActions), dropActionsToWl(response.acceptedAction()));
++
++        m_dragOffer->accept(m_enterSerial, m_dragOffer->firstFormat());
++    } else {
++        m_dragOffer->accept(m_enterSerial, QString());
++    }
++}
++
++int QWaylandDataDevice::dropActionsToWl(Qt::DropActions actions)
++{
++
++    int wlActions = WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE;
++    if (actions & Qt::CopyAction)
++        wlActions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY;
++    if (actions & (Qt::MoveAction | Qt::TargetMoveAction))
++        wlActions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE;
++
++    // wayland does not support LinkAction at the time of writing
++    return wlActions;
++}
++
++
+ #endif // QT_CONFIG(draganddrop)
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddatadevice_p.h b/qtwayland/src/client/qwaylanddatadevice_p.h
+index 16c3ad28..801dcc2c 100644
+--- a/qtwayland/src/client/qwaylanddatadevice_p.h
++++ b/qtwayland/src/client/qwaylanddatadevice_p.h
+@@ -64,6 +64,7 @@ QT_REQUIRE_CONFIG(wayland_datadevice);
+ QT_BEGIN_NAMESPACE
+ 
+ class QMimeData;
++class QPlatformDragQtResponse;
+ class QWindow;
+ 
+ namespace QtWaylandClient {
+@@ -89,7 +90,7 @@ public:
+ 
+ #if QT_CONFIG(draganddrop)
+     QWaylandDataOffer *dragOffer() const;
+-    bool startDrag(QMimeData *mimeData, QWaylandWindow *icon);
++    bool startDrag(QMimeData *mimeData, Qt::DropActions supportedActions, QWaylandWindow *icon);
+     void cancelDrag();
+ #endif
+ 
+@@ -109,13 +110,16 @@ private Q_SLOTS:
+ 
+ #if QT_CONFIG(draganddrop)
+     void dragSourceCancelled();
+-    void dragSourceTargetChanged(const QString &mimeType);
+ #endif
+ 
+ private:
+ #if QT_CONFIG(draganddrop)
+     QPoint calculateDragPosition(int x, int y, QWindow *wnd) const;
+ #endif
++    void sendResponse(Qt::DropActions supportedActions, const QPlatformDragQtResponse &response);
++
++    static int dropActionsToWl(Qt::DropActions dropActions);
++
+ 
+     QWaylandDisplay *m_display = nullptr;
+     QWaylandInputDevice *m_inputDevice = nullptr;
+diff --git a/qtwayland/src/client/qwaylanddatadevicemanager.cpp b/qtwayland/src/client/qwaylanddatadevicemanager.cpp
+index 35d67307..6dc4f77f 100644
+--- a/qtwayland/src/client/qwaylanddatadevicemanager.cpp
++++ b/qtwayland/src/client/qwaylanddatadevicemanager.cpp
+@@ -50,8 +50,8 @@ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
+-QWaylandDataDeviceManager::QWaylandDataDeviceManager(QWaylandDisplay *display, uint32_t id)
+-    : wl_data_device_manager(display->wl_registry(), id, 1)
++QWaylandDataDeviceManager::QWaylandDataDeviceManager(QWaylandDisplay *display, int version, uint32_t id)
++    : wl_data_device_manager(display->wl_registry(), id, qMin(version, 3))
+     , m_display(display)
+ {
+     // Create transfer devices for all input devices.
+diff --git a/qtwayland/src/client/qwaylanddatadevicemanager_p.h b/qtwayland/src/client/qwaylanddatadevicemanager_p.h
+index bd05c0fb..510d9be4 100644
+--- a/qtwayland/src/client/qwaylanddatadevicemanager_p.h
++++ b/qtwayland/src/client/qwaylanddatadevicemanager_p.h
+@@ -68,7 +68,7 @@ class QWaylandInputDevice;
+ class Q_WAYLAND_CLIENT_EXPORT QWaylandDataDeviceManager : public QtWayland::wl_data_device_manager
+ {
+ public:
+-    QWaylandDataDeviceManager(QWaylandDisplay *display, uint32_t id);
++    QWaylandDataDeviceManager(QWaylandDisplay *display, int version, uint32_t id);
+     ~QWaylandDataDeviceManager() override;
+ 
+     QWaylandDataDevice *getDataDevice(QWaylandInputDevice *inputDevice);
+diff --git a/qtwayland/src/client/qwaylanddataoffer.cpp b/qtwayland/src/client/qwaylanddataoffer.cpp
+index 2297e8a1..fe0ea8c9 100644
+--- a/qtwayland/src/client/qwaylanddataoffer.cpp
++++ b/qtwayland/src/client/qwaylanddataoffer.cpp
+@@ -82,6 +82,15 @@ QMimeData *QWaylandDataOffer::mimeData()
+     return m_mimeData.data();
+ }
+ 
++Qt::DropActions QWaylandDataOffer::supportedActions() const
++{
++    if (wl_data_offer_get_version(const_cast<::wl_data_offer*>(object())) < 3) {
++        return Qt::MoveAction | Qt::CopyAction;
++    }
++
++    return m_supportedActions;
++}
++
+ void QWaylandDataOffer::startReceiving(const QString &mimeType, int fd)
+ {
+     receive(mimeType, fd);
+@@ -93,6 +102,22 @@ void QWaylandDataOffer::data_offer_offer(const QString &mime_type)
+     m_mimeData->appendFormat(mime_type);
+ }
+ 
++void QWaylandDataOffer::data_offer_action(uint32_t dnd_action)
++{
++    Q_UNUSED(dnd_action);
++    // This is the compositor telling the drag target what action it should perform
++    // It does not map nicely into Qt final drop semantics, other than pretending there is only one supported action?
++}
++
++void QWaylandDataOffer::data_offer_source_actions(uint32_t source_actions)
++{
++    m_supportedActions = Qt::DropActions();
++    if (source_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
++        m_supportedActions |= Qt::MoveAction;
++    if (source_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
++        m_supportedActions |= Qt::CopyAction;
++}
++
+ QWaylandMimeData::QWaylandMimeData(QWaylandAbstractDataOffer *dataOffer)
+     : m_dataOffer(dataOffer)
+ {
+@@ -163,17 +188,18 @@ QVariant QWaylandMimeData::retrieveData_sys(const QString &mimeType, QVariant::T
+ 
+ int QWaylandMimeData::readData(int fd, QByteArray &data) const
+ {
+-    fd_set readset;
+-    FD_ZERO(&readset);
+-    FD_SET(fd, &readset);
+-    struct timeval timeout;
++    struct pollfd readset;
++    readset.fd = fd;
++    readset.events = POLLIN;
++    struct timespec timeout;
+     timeout.tv_sec = 1;
+-    timeout.tv_usec = 0;
++    timeout.tv_nsec = 0;
++
+ 
+     Q_FOREVER {
+-        int ready = select(FD_SETSIZE, &readset, nullptr, nullptr, &timeout);
++        int ready = qt_safe_poll(&readset, 1, &timeout);
+         if (ready < 0) {
+-            qWarning() << "QWaylandDataOffer: select() failed";
++            qWarning() << "QWaylandDataOffer: qt_safe_poll() failed";
+             return -1;
+         } else if (ready == 0) {
+             qWarning("QWaylandDataOffer: timeout reading from pipe");
+diff --git a/qtwayland/src/client/qwaylanddataoffer_p.h b/qtwayland/src/client/qwaylanddataoffer_p.h
+index 9cf1483c..6f667398 100644
+--- a/qtwayland/src/client/qwaylanddataoffer_p.h
++++ b/qtwayland/src/client/qwaylanddataoffer_p.h
+@@ -82,6 +82,7 @@ public:
+     explicit QWaylandDataOffer(QWaylandDisplay *display, struct ::wl_data_offer *offer);
+     ~QWaylandDataOffer() override;
+     QMimeData *mimeData() override;
++    Qt::DropActions supportedActions() const;
+ 
+     QString firstFormat() const;
+ 
+@@ -89,10 +90,13 @@ public:
+ 
+ protected:
+     void data_offer_offer(const QString &mime_type) override;
++    void data_offer_source_actions(uint32_t source_actions) override;
++    void data_offer_action(uint32_t dnd_action) override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+     QScopedPointer<QWaylandMimeData> m_mimeData;
++    Qt::DropActions m_supportedActions;
+ };
+ 
+ 
+diff --git a/qtwayland/src/client/qwaylanddatasource.cpp b/qtwayland/src/client/qwaylanddatasource.cpp
+index f45122fb..5599cbd4 100644
+--- a/qtwayland/src/client/qwaylanddatasource.cpp
++++ b/qtwayland/src/client/qwaylanddatasource.cpp
+@@ -101,7 +101,32 @@ void QWaylandDataSource::data_source_send(const QString &mime_type, int32_t fd)
+ 
+ void QWaylandDataSource::data_source_target(const QString &mime_type)
+ {
+-    Q_EMIT targetChanged(mime_type);
++    m_accepted = !mime_type.isEmpty();
++    Q_EMIT dndResponseUpdated(m_accepted, m_dropAction);
++}
++
++void QWaylandDataSource::data_source_action(uint32_t action)
++{
++    Qt::DropAction qtAction = Qt::IgnoreAction;
++
++    if (action == WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
++        qtAction = Qt::MoveAction;
++    else if (action == WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
++        qtAction = Qt::CopyAction;
++
++    m_dropAction = qtAction;
++    Q_EMIT dndResponseUpdated(m_accepted, m_dropAction);
++}
++
++void QWaylandDataSource::data_source_dnd_finished()
++{
++    Q_EMIT finished();
++}
++
++void QWaylandDataSource::data_source_dnd_drop_performed()
++{
++
++    Q_EMIT dndDropped(m_accepted, m_dropAction);
+ }
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddatasource_p.h b/qtwayland/src/client/qwaylanddatasource_p.h
+index 25afff79..96f07bc3 100644
+--- a/qtwayland/src/client/qwaylanddatasource_p.h
++++ b/qtwayland/src/client/qwaylanddatasource_p.h
+@@ -77,17 +77,25 @@ public:
+     QMimeData *mimeData() const;
+ 
+ Q_SIGNALS:
+-    void targetChanged(const QString &mime_type);
+     void cancelled();
++    void finished();
++
++    void dndResponseUpdated(bool accepted, Qt::DropAction action);
++    void dndDropped(bool accepted, Qt::DropAction action);
+ 
+ protected:
+     void data_source_cancelled() override;
+     void data_source_send(const QString &mime_type, int32_t fd) override;
+     void data_source_target(const QString &mime_type) override;
++    void data_source_dnd_drop_performed() override;
++    void data_source_dnd_finished() override;
++    void data_source_action(uint32_t action) override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+     QMimeData *m_mime_data = nullptr;
++    bool m_accepted = false;
++    Qt::DropAction m_dropAction = Qt::IgnoreAction;
+ };
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddisplay.cpp b/qtwayland/src/client/qwaylanddisplay.cpp
+index f10c1f79..c01e238b 100644
+--- a/qtwayland/src/client/qwaylanddisplay.cpp
++++ b/qtwayland/src/client/qwaylanddisplay.cpp
+@@ -85,10 +85,203 @@
+ 
+ #include <errno.h>
+ 
++#include <tuple> // for std::tie
++
++static void checkWaylandError(struct wl_display *display)
++{
++    int ecode = wl_display_get_error(display);
++    if ((ecode == EPIPE || ecode == ECONNRESET)) {
++        // special case this to provide a nicer error
++        qWarning("The Wayland connection broke. Did the Wayland compositor die?");
++    } else {
++        qWarning("The Wayland connection experienced a fatal error: %s", strerror(ecode));
++    }
++    _exit(1);
++}
++
+ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
++class EventThread : public QThread
++{
++    Q_OBJECT
++public:
++    enum OperatingMode {
++        EmitToDispatch, // Emit the signal, allow dispatching in a differnt thread.
++        SelfDispatch, // Dispatch the events inside this thread.
++    };
++
++    EventThread(struct wl_display * wl, struct wl_event_queue * ev_queue,
++                OperatingMode mode)
++        : m_fd(wl_display_get_fd(wl))
++        , m_pipefd{ -1, -1 }
++        , m_wldisplay(wl)
++        , m_wlevqueue(ev_queue)
++        , m_mode(mode)
++        , m_reading(true)
++        , m_quitting(false)
++    {
++        setObjectName(QStringLiteral("WaylandEventThread"));
++    }
++
++    void readAndDispatchEvents()
++    {
++        /*
++         * Dispatch pending events and flush the requests at least once. If the event thread
++         * is not reading, try to call _prepare_read() to allow the event thread to poll().
++         * If that fails, re-try dispatch & flush again until _prepare_read() is successful.
++         *
++         * This allow any call to readAndDispatchEvents() to start event thread's polling,
++         * not only the one issued from event thread's waitForReading(), which means functions
++         * called from dispatch_pending() can safely spin an event loop.
++         */
++        for (;;) {
++            if (dispatchQueuePending() < 0) {
++                checkWaylandError(m_wldisplay);
++                return;
++            }
++
++            wl_display_flush(m_wldisplay);
++
++            // We have to check if event thread is reading every time we dispatch
++            // something, as that may recursively call this function.
++            if (m_reading.loadAcquire())
++                break;
++
++            if (prepareReadQueue() == 0) {
++                QMutexLocker l(&m_mutex);
++                m_reading.storeRelease(true);
++                m_cond.wakeOne();
++                break;
++            }
++        }
++    }
++
++    void stop()
++    {
++        // We have to both write to the pipe and set the flag, as the thread may be
++        // either in the poll() or waiting for _prepare_read().
++        if (m_pipefd[1] != -1 && write(m_pipefd[1], "\0", 1) == -1)
++            qWarning("Failed to write to the pipe: %s.", strerror(errno));
++
++        {
++            QMutexLocker l(&m_mutex);
++            m_quitting = true;
++            m_cond.wakeOne();
++        }
++
++        wait();
++    }
++
++Q_SIGNALS:
++    void needReadAndDispatch();
++
++protected:
++    void run() override
++    {
++        // we use this pipe to make the loop exit otherwise if we simply used a flag on the loop condition, if stop() gets
++        // called while poll() is blocking the thread will never quit since there are no wayland messages coming anymore.
++        struct Pipe
++        {
++            Pipe(int *fds)
++                : fds(fds)
++            {
++                if (qt_safe_pipe(fds) != 0)
++                    qWarning("Pipe creation failed. Quitting may hang.");
++            }
++            ~Pipe()
++            {
++                if (fds[0] != -1) {
++                    close(fds[0]);
++                    close(fds[1]);
++                }
++            }
++
++            int *fds;
++        } pipe(m_pipefd);
++
++        // Make the main thread call wl_prepare_read(), dispatch the pending messages and flush the
++        // outbound ones. Wait until it's done before proceeding, unless we're told to quit.
++        while (waitForReading()) {
++            pollfd fds[2] = { { m_fd, POLLIN, 0 }, { m_pipefd[0], POLLIN, 0 } };
++            poll(fds, 2, -1);
++
++            if (fds[1].revents & POLLIN) {
++                // we don't really care to read the byte that was written here since we're closing down
++                wl_display_cancel_read(m_wldisplay);
++                break;
++            }
++
++            if (fds[0].revents & POLLIN)
++                wl_display_read_events(m_wldisplay);
++                // The polll was succesfull and the event thread did the wl_display_read_events(). On the next iteration of the loop
++                // the event sent to the main thread will cause it to dispatch the messages just read, unless the loop exits in which
++                // case we don't care anymore about them.
++            else
++                wl_display_cancel_read(m_wldisplay);
++        }
++    }
++
++private:
++    bool waitForReading()
++    {
++        Q_ASSERT(QThread::currentThread() == this);
++
++        m_reading.storeRelease(false);
++
++        if (m_mode == SelfDispatch) {
++            readAndDispatchEvents();
++        } else {
++            Q_EMIT needReadAndDispatch();
++
++            QMutexLocker lock(&m_mutex);
++            // m_reading might be set from our emit or some other invocation of
++            // readAndDispatchEvents().
++            while (!m_reading.loadRelaxed() && !m_quitting)
++                m_cond.wait(&m_mutex);
++        }
++
++        return !m_quitting;
++    }
++
++    int dispatchQueuePending()
++    {
++        if (m_wlevqueue)
++            return wl_display_dispatch_queue_pending(m_wldisplay, m_wlevqueue);
++        else
++            return wl_display_dispatch_pending(m_wldisplay);
++    }
++
++    int prepareReadQueue()
++    {
++        if (m_wlevqueue)
++            return wl_display_prepare_read_queue(m_wldisplay, m_wlevqueue);
++        else
++            return wl_display_prepare_read(m_wldisplay);
++    }
++
++    int m_fd;
++    int m_pipefd[2];
++    wl_display *m_wldisplay;
++    wl_event_queue *m_wlevqueue;
++    OperatingMode m_mode;
++
++    /* Concurrency note when operating in EmitToDispatch mode:
++     * m_reading is set to false inside event thread's waitForReading(), and is
++     * set to true inside main thread's readAndDispatchEvents().
++     * The lock is not taken when setting m_reading to false, as the main thread
++     * is not actively waiting for it to turn false. However, the lock is taken
++     * inside readAndDispatchEvents() before setting m_reading to true,
++     * as the event thread is actively waiting for it under the wait condition.
++     */
++
++    QAtomicInteger<bool> m_reading;
++    bool m_quitting;
++    QMutex m_mutex;
++    QWaitCondition m_cond;
++};
++
+ Q_LOGGING_CATEGORY(lcQpaWayland, "qt.qpa.wayland"); // for general (uncategorized) Wayland platform logging
+ 
+ struct wl_surface *QWaylandDisplay::createSurface(void *handle)
+@@ -158,17 +351,16 @@ QWaylandDisplay::QWaylandDisplay(QWaylandIntegration *waylandIntegration)
+     if (!mXkbContext)
+         qCWarning(lcQpaWayland, "failed to create xkb context");
+ #endif
+-
+-    forceRoundTrip();
+-
+-    if (!mWaitingScreens.isEmpty()) {
+-        // Give wl_output.done and zxdg_output_v1.done events a chance to arrive
+-        forceRoundTrip();
+-    }
+ }
+ 
+ QWaylandDisplay::~QWaylandDisplay(void)
+ {
++    if (m_eventThread)
++        m_eventThread->stop();
++
++    if (m_frameEventQueueThread)
++        m_frameEventQueueThread->stop();
++
+     if (mSyncCallback)
+         wl_callback_destroy(mSyncCallback);
+ 
+@@ -187,6 +379,21 @@ QWaylandDisplay::~QWaylandDisplay(void)
+ #endif
+     if (mDisplay)
+         wl_display_disconnect(mDisplay);
++
++    if (m_frameEventQueue)
++        wl_event_queue_destroy(m_frameEventQueue);
++}
++
++// Steps which is called just after constructor. This separates registry_global() out of the constructor
++// so that factory functions in integration can be overridden.
++void QWaylandDisplay::initialize()
++{
++    forceRoundTrip();
++
++    if (!mWaitingScreens.isEmpty()) {
++        // Give wl_output.done and zxdg_output_v1.done events a chance to arrive
++        forceRoundTrip();
++    }
+ }
+ 
+ void QWaylandDisplay::ensureScreen()
+@@ -203,98 +410,37 @@ void QWaylandDisplay::ensureScreen()
+ 
+ void QWaylandDisplay::checkError() const
+ {
+-    int ecode = wl_display_get_error(mDisplay);
+-    if ((ecode == EPIPE || ecode == ECONNRESET)) {
+-        // special case this to provide a nicer error
+-        qWarning("The Wayland connection broke. Did the Wayland compositor die?");
+-    } else {
+-        qWarning("The Wayland connection experienced a fatal error: %s", strerror(ecode));
+-    }
+-    _exit(1);
++    checkWaylandError(mDisplay);
+ }
+ 
++// Called in main thread, either from queued signal or directly.
+ void QWaylandDisplay::flushRequests()
+ {
+-    if (wl_display_prepare_read(mDisplay) == 0) {
+-        wl_display_read_events(mDisplay);
+-    }
+-
+-    if (wl_display_dispatch_pending(mDisplay) < 0)
+-        checkError();
+-
+-    {
+-        QReadLocker locker(&m_frameQueueLock);
+-        for (const FrameQueue &q : mExternalQueues) {
+-            QMutexLocker locker(q.mutex);
+-            while (wl_display_prepare_read_queue(mDisplay, q.queue) != 0)
+-                wl_display_dispatch_queue_pending(mDisplay, q.queue);
+-            wl_display_read_events(mDisplay);
+-            wl_display_dispatch_queue_pending(mDisplay, q.queue);
+-        }
+-    }
+-
+-    wl_display_flush(mDisplay);
+-}
+-
+-void QWaylandDisplay::blockingReadEvents()
+-{
+-    if (wl_display_dispatch(mDisplay) < 0)
+-        checkError();
+-}
+-
+-void QWaylandDisplay::destroyFrameQueue(const QWaylandDisplay::FrameQueue &q)
+-{
+-    QWriteLocker locker(&m_frameQueueLock);
+-    auto it = std::find_if(mExternalQueues.begin(),
+-                           mExternalQueues.end(),
+-                           [&q] (const QWaylandDisplay::FrameQueue &other){ return other.queue == q.queue; });
+-    Q_ASSERT(it != mExternalQueues.end());
+-    mExternalQueues.erase(it);
+-    if (q.queue != nullptr)
+-        wl_event_queue_destroy(q.queue);
+-    delete q.mutex;
++    m_eventThread->readAndDispatchEvents();
+ }
+ 
+-QWaylandDisplay::FrameQueue QWaylandDisplay::createFrameQueue()
++// We have to wait until we have an eventDispatcher before creating the eventThread,
++// otherwise forceRoundTrip() may block inside _events_read() because eventThread is
++// polling.
++void QWaylandDisplay::initEventThread()
+ {
+-    QWriteLocker locker(&m_frameQueueLock);
+-    FrameQueue q{createEventQueue()};
+-    mExternalQueues.append(q);
+-    return q;
+-}
++    m_eventThread.reset(
++            new EventThread(mDisplay, /* default queue */ nullptr, EventThread::EmitToDispatch));
++    connect(m_eventThread.get(), &EventThread::needReadAndDispatch, this,
++            &QWaylandDisplay::flushRequests, Qt::QueuedConnection);
++    m_eventThread->start();
+ 
+-wl_event_queue *QWaylandDisplay::createEventQueue()
+-{
+-    return wl_display_create_queue(mDisplay);
++    // wl_display_disconnect() free this.
++    m_frameEventQueue = wl_display_create_queue(mDisplay);
++    m_frameEventQueueThread.reset(
++            new EventThread(mDisplay, m_frameEventQueue, EventThread::SelfDispatch));
++    m_frameEventQueueThread->start();
+ }
+ 
+-void QWaylandDisplay::dispatchQueueWhile(wl_event_queue *queue, std::function<bool ()> condition, int timeout)
++void QWaylandDisplay::blockingReadEvents()
+ {
+-    if (!condition())
+-        return;
+-
+-    QElapsedTimer timer;
+-    timer.start();
+-    struct pollfd pFd = qt_make_pollfd(wl_display_get_fd(mDisplay), POLLIN);
+-    while (timeout == -1 || timer.elapsed() < timeout) {
+-        while (wl_display_prepare_read_queue(mDisplay, queue) != 0)
+-            wl_display_dispatch_queue_pending(mDisplay, queue);
+-
+-        wl_display_flush(mDisplay);
+-
+-        const int remaining = qMax(timeout - timer.elapsed(), 0ll);
+-        const int pollTimeout = timeout == -1 ? -1 : remaining;
+-        if (qt_poll_msecs(&pFd, 1, pollTimeout) > 0)
+-            wl_display_read_events(mDisplay);
+-        else
+-            wl_display_cancel_read(mDisplay);
+-
+-        if (wl_display_dispatch_queue_pending(mDisplay, queue) < 0)
+-            checkError();
+-
+-        if (!condition())
+-            break;
+-    }
++    if (wl_display_dispatch(mDisplay) < 0)
++        checkWaylandError(mDisplay);
+ }
+ 
+ QWaylandScreen *QWaylandDisplay::screenForOutput(struct wl_output *output) const
+@@ -345,7 +491,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+     if (interface == QStringLiteral("wl_output")) {
+         mWaitingScreens << new QWaylandScreen(this, version, id);
+     } else if (interface == QStringLiteral("wl_compositor")) {
+-        mCompositorVersion = qMin((int)version, 3);
++        mCompositorVersion = qMin((int)version, 4);
+         mCompositor.init(registry, id, mCompositorVersion);
+     } else if (interface == QStringLiteral("wl_shm")) {
+         mShm.reset(new QWaylandShm(this, version, id));
+@@ -354,7 +500,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+         mInputDevices.append(inputDevice);
+ #if QT_CONFIG(wayland_datadevice)
+     } else if (interface == QStringLiteral("wl_data_device_manager")) {
+-        mDndSelectionHandler.reset(new QWaylandDataDeviceManager(this, id));
++        mDndSelectionHandler.reset(new QWaylandDataDeviceManager(this, version, id));
+ #endif
+     } else if (interface == QStringLiteral("qt_surface_extension")) {
+         mWindowExtension.reset(new QtWayland::qt_surface_extension(registry, id, 1));
+@@ -369,6 +515,8 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+ #if QT_CONFIG(wayland_client_primary_selection)
+     } else if (interface == QStringLiteral("zwp_primary_selection_device_manager_v1")) {
+         mPrimarySelectionManager.reset(new QWaylandPrimarySelectionDeviceManagerV1(this, id, 1));
++        for (QWaylandInputDevice *inputDevice : qAsConst(mInputDevices))
++            inputDevice->setPrimarySelectionDevice(mPrimarySelectionManager->createDevice(inputDevice));
+ #endif
+     } else if (interface == QStringLiteral("zwp_text_input_manager_v2") && !mClientSideInputContextRequested) {
+         mTextInputManager.reset(new QtWayland::zwp_text_input_manager_v2(registry, id, 1));
+@@ -427,6 +575,13 @@ void QWaylandDisplay::registry_global_remove(uint32_t id)
+                     inputDevice->setTextInput(nullptr);
+                 mWaylandIntegration->reconfigureInputContext();
+             }
++#if QT_CONFIG(wayland_client_primary_selection)
++            if (global.interface == QStringLiteral("zwp_primary_selection_device_manager_v1")) {
++                mPrimarySelectionManager.reset();
++                for (QWaylandInputDevice *inputDevice : qAsConst(mInputDevices))
++                    inputDevice->setPrimarySelectionDevice(nullptr);
++            }
++#endif
+             mGlobals.removeAt(i);
+             break;
+         }
+@@ -452,9 +607,10 @@ void QWaylandDisplay::addRegistryListener(RegistryListener listener, void *data)
+ 
+ void QWaylandDisplay::removeListener(RegistryListener listener, void *data)
+ {
+-    std::remove_if(mRegistryListeners.begin(), mRegistryListeners.end(), [=](Listener l){
++    auto iter = std::remove_if(mRegistryListeners.begin(), mRegistryListeners.end(), [=](Listener l){
+         return (l.listener == listener && l.data == data);
+     });
++    mRegistryListeners.erase(iter, mRegistryListeners.end());
+ }
+ 
+ uint32_t QWaylandDisplay::currentTimeMillisec()
+@@ -467,50 +623,9 @@ uint32_t QWaylandDisplay::currentTimeMillisec()
+     return 0;
+ }
+ 
+-static void
+-sync_callback(void *data, struct wl_callback *callback, uint32_t serial)
+-{
+-    Q_UNUSED(serial)
+-    bool *done = static_cast<bool *>(data);
+-
+-    *done = true;
+-
+-    // If the wl_callback done event is received after the condition check in the while loop in
+-    // forceRoundTrip(), but before the call to processEvents, the call to processEvents may block
+-    // forever if no more events are posted (eventhough the callback is handled in response to the
+-    // aboutToBlock signal). Hence, we wake up the event dispatcher so forceRoundTrip may return.
+-    // (QTBUG-64696)
+-    if (auto *dispatcher = QThread::currentThread()->eventDispatcher())
+-        dispatcher->wakeUp();
+-
+-    wl_callback_destroy(callback);
+-}
+-
+-static const struct wl_callback_listener sync_listener = {
+-    sync_callback
+-};
+-
+ void QWaylandDisplay::forceRoundTrip()
+ {
+-    // wl_display_roundtrip() works on the main queue only,
+-    // but we use a separate one, so basically reimplement it here
+-    int ret = 0;
+-    bool done = false;
+-    wl_callback *callback = wl_display_sync(mDisplay);
+-    wl_callback_add_listener(callback, &sync_listener, &done);
+-    flushRequests();
+-    if (QThread::currentThread()->eventDispatcher()) {
+-        while (!done && ret >= 0) {
+-            QThread::currentThread()->eventDispatcher()->processEvents(QEventLoop::WaitForMoreEvents);
+-            ret = wl_display_dispatch_pending(mDisplay);
+-        }
+-    } else {
+-        while (!done && ret >= 0)
+-            ret = wl_display_dispatch(mDisplay);
+-    }
+-
+-    if (ret == -1 && !done)
+-        wl_callback_destroy(callback);
++     wl_display_roundtrip(mDisplay);
+ }
+ 
+ bool QWaylandDisplay::supportsWindowDecoration() const
+@@ -574,14 +689,10 @@ void QWaylandDisplay::handleKeyboardFocusChanged(QWaylandInputDevice *inputDevic
+     if (mLastKeyboardFocus == keyboardFocus)
+         return;
+ 
+-    if (mWaylandIntegration->mShellIntegration) {
+-        mWaylandIntegration->mShellIntegration->handleKeyboardFocusChanged(keyboardFocus, mLastKeyboardFocus);
+-    } else {
+-        if (keyboardFocus)
+-            handleWindowActivated(keyboardFocus);
+-        if (mLastKeyboardFocus)
+-            handleWindowDeactivated(mLastKeyboardFocus);
+-    }
++    if (keyboardFocus)
++        handleWindowActivated(keyboardFocus);
++    if (mLastKeyboardFocus)
++        handleWindowDeactivated(mLastKeyboardFocus);
+ 
+     mLastKeyboardFocus = keyboardFocus;
+ }
+@@ -600,6 +711,19 @@ void QWaylandDisplay::handleWaylandSync()
+     QWindow *activeWindow = mActiveWindows.empty() ? nullptr : mActiveWindows.last()->window();
+     if (activeWindow != QGuiApplication::focusWindow())
+         QWindowSystemInterface::handleWindowActivated(activeWindow);
++
++    if (!activeWindow) {
++        if (lastInputDevice()) {
++#if QT_CONFIG(clipboard)
++            if (auto *dataDevice = lastInputDevice()->dataDevice())
++                dataDevice->invalidateSelectionOffer();
++#endif
++#if QT_CONFIG(wayland_client_primary_selection)
++            if (auto *device = lastInputDevice()->primarySelectionDevice())
++                device->invalidateSelectionOffer();
++#endif
++        }
++    }
+ }
+ 
+ const wl_callback_listener QWaylandDisplay::syncCallbackListener = {
+@@ -626,6 +750,13 @@ QWaylandInputDevice *QWaylandDisplay::defaultInputDevice() const
+     return mInputDevices.isEmpty() ? 0 : mInputDevices.first();
+ }
+ 
++bool QWaylandDisplay::isKeyboardAvailable() const
++{
++    return std::any_of(
++            mInputDevices.constBegin(), mInputDevices.constEnd(),
++            [this](const QWaylandInputDevice *device) { return device->keyboard() != nullptr; });
++}
++
+ #if QT_CONFIG(cursor)
+ 
+ QWaylandCursor *QWaylandDisplay::waylandCursor()
+@@ -652,4 +783,6 @@ QWaylandCursorTheme *QWaylandDisplay::loadCursorTheme(const QString &name, int p
+ 
+ } // namespace QtWaylandClient
+ 
++#include "qwaylanddisplay.moc"
++
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/client/qwaylanddisplay_p.h b/qtwayland/src/client/qwaylanddisplay_p.h
+index 3b092bc8..42bc661d 100644
+--- a/qtwayland/src/client/qwaylanddisplay_p.h
++++ b/qtwayland/src/client/qwaylanddisplay_p.h
+@@ -109,6 +109,7 @@ class QWaylandSurface;
+ class QWaylandShellIntegration;
+ class QWaylandCursor;
+ class QWaylandCursorTheme;
++class EventThread;
+ 
+ typedef void (*RegistryListener)(void *data,
+                                  struct wl_registry *registry,
+@@ -120,15 +121,11 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandDisplay : public QObject, public QtWayland
+     Q_OBJECT
+ 
+ public:
+-    struct FrameQueue {
+-        FrameQueue(wl_event_queue *q = nullptr) : queue(q), mutex(new QMutex) {}
+-        wl_event_queue *queue;
+-        QMutex *mutex;
+-    };
+-
+     QWaylandDisplay(QWaylandIntegration *waylandIntegration);
+     ~QWaylandDisplay(void) override;
+ 
++    void initialize();
++
+ #if QT_CONFIG(xkbcommon)
+     struct xkb_context *xkbContext() const { return mXkbContext.get(); }
+ #endif
+@@ -210,11 +207,11 @@ public:
+     void handleKeyboardFocusChanged(QWaylandInputDevice *inputDevice);
+     void handleWindowDestroyed(QWaylandWindow *window);
+ 
+-    wl_event_queue *createEventQueue();
+-    FrameQueue createFrameQueue();
+-    void destroyFrameQueue(const FrameQueue &q);
+-    void dispatchQueueWhile(wl_event_queue *queue, std::function<bool()> condition, int timeout = -1);
++    wl_event_queue *frameEventQueue() { return m_frameEventQueue; };
++
++    bool isKeyboardAvailable() const;
+ 
++    void initEventThread();
+ public slots:
+     void blockingReadEvents();
+     void flushRequests();
+@@ -237,6 +234,9 @@ private:
+     };
+ 
+     struct wl_display *mDisplay = nullptr;
++    QScopedPointer<EventThread> m_eventThread;
++    wl_event_queue *m_frameEventQueue = nullptr;
++    QScopedPointer<EventThread> m_frameEventQueueThread;
+     QtWayland::wl_compositor mCompositor;
+     QScopedPointer<QWaylandShm> mShm;
+     QList<QWaylandScreen *> mWaitingScreens;
+@@ -273,11 +273,9 @@ private:
+     QWaylandInputDevice *mLastInputDevice = nullptr;
+     QPointer<QWaylandWindow> mLastInputWindow;
+     QPointer<QWaylandWindow> mLastKeyboardFocus;
+-    QVector<QWaylandWindow *> mActiveWindows;
+-    QVector<FrameQueue> mExternalQueues;
++    QList<QWaylandWindow *> mActiveWindows;
+     struct wl_callback *mSyncCallback = nullptr;
+     static const wl_callback_listener syncCallbackListener;
+-    QReadWriteLock m_frameQueueLock;
+ 
+     bool mClientSideInputContextRequested = !QPlatformInputContextFactory::requested().isNull();
+ 
+diff --git a/qtwayland/src/client/qwaylanddnd.cpp b/qtwayland/src/client/qwaylanddnd.cpp
+index 6535aa16..7c53f5fa 100644
+--- a/qtwayland/src/client/qwaylanddnd.cpp
++++ b/qtwayland/src/client/qwaylanddnd.cpp
+@@ -66,7 +66,7 @@ void QWaylandDrag::startDrag()
+ {
+     QBasicDrag::startDrag();
+     QWaylandWindow *icon = static_cast<QWaylandWindow *>(shapedPixmapWindow()->handle());
+-    if (m_display->currentInputDevice()->dataDevice()->startDrag(drag()->mimeData(), icon)) {
++    if (m_display->currentInputDevice()->dataDevice()->startDrag(drag()->mimeData(), drag()->supportedActions(), icon)) {
+         icon->addAttachOffset(-drag()->hotSpot());
+     } else {
+         // Cancelling immediately does not work, since the event loop for QDrag::exec is started
+@@ -80,6 +80,9 @@ void QWaylandDrag::cancel()
+     QBasicDrag::cancel();
+ 
+     m_display->currentInputDevice()->dataDevice()->cancelDrag();
++
++    if (drag())
++        drag()->deleteLater();
+ }
+ 
+ void QWaylandDrag::move(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods)
+@@ -103,33 +106,41 @@ void QWaylandDrag::endDrag()
+     m_display->currentInputDevice()->handleEndDrag();
+ }
+ 
+-void QWaylandDrag::updateTarget(const QString &mimeType)
++void QWaylandDrag::setResponse(bool accepted)
+ {
+-    setCanDrop(!mimeType.isEmpty());
+-
+-    if (canDrop()) {
+-        updateCursor(defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers()));
+-    } else {
+-        updateCursor(Qt::IgnoreAction);
+-    }
++    // This method is used for old DataDevices where the drag action is not communicated
++    Qt::DropAction action = defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers());
++    setResponse(QPlatformDropQtResponse(accepted, action));
+ }
+ 
+-void QWaylandDrag::setResponse(const QPlatformDragQtResponse &response)
++void QWaylandDrag::setResponse(const QPlatformDropQtResponse &response)
+ {
+     setCanDrop(response.isAccepted());
+ 
+     if (canDrop()) {
+-        updateCursor(defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers()));
++        updateCursor(response.acceptedAction());
+     } else {
+         updateCursor(Qt::IgnoreAction);
+     }
+ }
+ 
+-void QWaylandDrag::finishDrag(const QPlatformDropQtResponse &response)
++void QWaylandDrag::setDropResponse(const QPlatformDropQtResponse &response)
+ {
+     setExecutedDropAction(response.acceptedAction());
++}
++
++void QWaylandDrag::finishDrag()
++{
+     QKeyEvent event(QEvent::KeyPress, Qt::Key_Escape, Qt::NoModifier);
+     eventFilter(shapedPixmapWindow(), &event);
++
++    if (drag())
++        drag()->deleteLater();
++}
++
++bool QWaylandDrag::ownsDragObject() const
++{
++    return true;
+ }
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddnd_p.h b/qtwayland/src/client/qwaylanddnd_p.h
+index 474fe2ab..46f629ac 100644
+--- a/qtwayland/src/client/qwaylanddnd_p.h
++++ b/qtwayland/src/client/qwaylanddnd_p.h
+@@ -71,9 +71,10 @@ public:
+     QWaylandDrag(QWaylandDisplay *display);
+     ~QWaylandDrag() override;
+ 
+-    void updateTarget(const QString &mimeType);
+-    void setResponse(const QPlatformDragQtResponse &response);
+-    void finishDrag(const QPlatformDropQtResponse &response);
++    void setResponse(bool accepted);
++    void setResponse(const QPlatformDropQtResponse &response);
++    void setDropResponse(const QPlatformDropQtResponse &response);
++    void finishDrag();
+ 
+ protected:
+     void startDrag() override;
+@@ -82,6 +83,7 @@ protected:
+     void drop(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods) override;
+     void endDrag() override;
+ 
++    bool ownsDragObject() const override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+diff --git a/qtwayland/src/client/qwaylandinputdevice.cpp b/qtwayland/src/client/qwaylandinputdevice.cpp
+index 613fe862..4b90de84 100644
+--- a/qtwayland/src/client/qwaylandinputdevice.cpp
++++ b/qtwayland/src/client/qwaylandinputdevice.cpp
+@@ -685,6 +685,11 @@ public:
+ 
+ void QWaylandInputDevice::Pointer::pointer_leave(uint32_t time, struct wl_surface *surface)
+ {
++    invalidateFocus();
++    mButtons = Qt::NoButton;
++
++    mParent->mTime = time;
++
+     // The event may arrive after destroying the window, indicated by
+     // a null surface.
+     if (!surface)
+@@ -696,11 +701,6 @@ void QWaylandInputDevice::Pointer::pointer_leave(uint32_t time, struct wl_surfac
+ 
+     if (!QWaylandWindow::mouseGrab())
+         setFrameEvent(new LeaveEvent(window, mSurfacePos, mGlobalPos));
+-
+-    invalidateFocus();
+-    mButtons = Qt::NoButton;
+-
+-    mParent->mTime = time;
+ }
+ 
+ class MotionEvent : public QWaylandPointerEvent
+@@ -1300,14 +1300,6 @@ void QWaylandInputDevice::Keyboard::handleFocusDestroyed()
+ void QWaylandInputDevice::Keyboard::handleFocusLost()
+ {
+     mFocus = nullptr;
+-#if QT_CONFIG(clipboard)
+-    if (auto *dataDevice = mParent->dataDevice())
+-        dataDevice->invalidateSelectionOffer();
+-#endif
+-#if QT_CONFIG(wayland_client_primary_selection)
+-    if (auto *device = mParent->primarySelectionDevice())
+-        device->invalidateSelectionOffer();
+-#endif
+     mParent->mQDisplay->handleKeyboardFocusChanged(mParent);
+     mRepeatTimer.stop();
+ }
+@@ -1396,6 +1388,7 @@ void QWaylandInputDevice::Touch::touch_cancel()
+     if (touchExt)
+         touchExt->touchCanceled();
+ 
++    mFocus = nullptr;
+     QWindowSystemInterface::handleTouchCancelEvent(nullptr, mParent->mTouchDevice);
+ }
+ 
+diff --git a/qtwayland/src/client/qwaylandintegration.cpp b/qtwayland/src/client/qwaylandintegration.cpp
+index c53ccb78..54861600 100644
+--- a/qtwayland/src/client/qwaylandintegration.cpp
++++ b/qtwayland/src/client/qwaylandintegration.cpp
+@@ -125,6 +125,9 @@ QWaylandIntegration::QWaylandIntegration()
+ #endif
+ 
+     reconfigureInputContext();
++
++    QWaylandWindow::fixedToplevelPositions =
++            !qEnvironmentVariableIsSet("QT_WAYLAND_DISABLE_FIXED_POSITIONS");
+ }
+ 
+ QWaylandIntegration::~QWaylandIntegration()
+@@ -192,14 +195,18 @@ QAbstractEventDispatcher *QWaylandIntegration::createEventDispatcher() const
+ 
+ void QWaylandIntegration::initialize()
+ {
++    mDisplay->initEventThread();
++
++    // Call after eventDispatcher is fully connected, for QWaylandDisplay::forceRoundTrip()
++    mDisplay->initialize();
++
++    // But the aboutToBlock() and awake() should be connected after initializePlatform().
++    // Otherwise the connected flushRequests() may consumes up all events before processEvents starts to wait,
++    // so that processEvents(QEventLoop::WaitForMoreEvents) may be blocked in the forceRoundTrip().
+     QAbstractEventDispatcher *dispatcher = QGuiApplicationPrivate::eventDispatcher;
+     QObject::connect(dispatcher, SIGNAL(aboutToBlock()), mDisplay.data(), SLOT(flushRequests()));
+     QObject::connect(dispatcher, SIGNAL(awake()), mDisplay.data(), SLOT(flushRequests()));
+ 
+-    int fd = wl_display_get_fd(mDisplay->wl_display());
+-    QSocketNotifier *sn = new QSocketNotifier(fd, QSocketNotifier::Read, mDisplay.data());
+-    QObject::connect(sn, SIGNAL(activated(QSocketDescriptor)), mDisplay.data(), SLOT(flushRequests()));
+-
+     // Qt does not support running with no screens
+     mDisplay->ensureScreen();
+ }
+@@ -262,6 +269,14 @@ QWaylandDisplay *QWaylandIntegration::display() const
+     return mDisplay.data();
+ }
+ 
++Qt::KeyboardModifiers QWaylandIntegration::queryKeyboardModifiers() const
++{
++    if (auto *seat = mDisplay->currentInputDevice()) {
++        return seat->modifiers();
++    }
++    return Qt::NoModifier;
++}
++
+ QList<int> QWaylandIntegration::possibleKeys(const QKeyEvent *event) const
+ {
+     if (auto *seat = mDisplay->currentInputDevice())
+@@ -479,7 +494,7 @@ void QWaylandIntegration::reconfigureInputContext()
+     }
+ #endif
+ 
+-    qCDebug(lcQpaWayland) << "using input method:" << inputContext()->metaObject()->className();
++    qCDebug(lcQpaWayland) << "using input method:" << (inputContext() ? inputContext()->metaObject()->className() : "<none>");
+ }
+ 
+ QWaylandShellIntegration *QWaylandIntegration::createShellIntegration(const QString &integrationName)
+diff --git a/qtwayland/src/client/qwaylandintegration_p.h b/qtwayland/src/client/qwaylandintegration_p.h
+index ff70ae25..73b80658 100644
+--- a/qtwayland/src/client/qwaylandintegration_p.h
++++ b/qtwayland/src/client/qwaylandintegration_p.h
+@@ -107,6 +107,8 @@ public:
+ 
+     QWaylandDisplay *display() const;
+ 
++    Qt::KeyboardModifiers queryKeyboardModifiers() const override;
++
+     QList<int> possibleKeys(const QKeyEvent *event) const override;
+ 
+     QStringList themeNames() const override;
+diff --git a/qtwayland/src/client/qwaylandprimaryselectionv1.cpp b/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
+index 832f9678..ea508771 100644
+--- a/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
++++ b/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
+@@ -54,11 +54,6 @@ QWaylandPrimarySelectionDeviceManagerV1::QWaylandPrimarySelectionDeviceManagerV1
+     : zwp_primary_selection_device_manager_v1(display->wl_registry(), id, qMin(version, uint(1)))
+     , m_display(display)
+ {
+-    // Create devices for all seats.
+-    // This only works if we get the global before all devices
+-    const auto seats = m_display->inputDevices();
+-    for (auto *seat : seats)
+-        seat->setPrimarySelectionDevice(createDevice(seat));
+ }
+ 
+ QWaylandPrimarySelectionDeviceV1 *QWaylandPrimarySelectionDeviceManagerV1::createDevice(QWaylandInputDevice *seat)
+diff --git a/qtwayland/src/client/qwaylandscreen.cpp b/qtwayland/src/client/qwaylandscreen.cpp
+index 6cb337de..5537dafd 100644
+--- a/qtwayland/src/client/qwaylandscreen.cpp
++++ b/qtwayland/src/client/qwaylandscreen.cpp
+@@ -60,7 +60,7 @@ QWaylandXdgOutputManagerV1::QWaylandXdgOutputManagerV1(QWaylandDisplay* display,
+ }
+ 
+ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uint32_t id)
+-    : QtWayland::wl_output(waylandDisplay->wl_registry(), id, qMin(version, 2))
++    : QtWayland::wl_output(waylandDisplay->wl_registry(), id, qMin(version, 3))
+     , m_outputId(id)
+     , mWaylandDisplay(waylandDisplay)
+     , mOutputName(QStringLiteral("Screen%1").arg(id))
+@@ -72,7 +72,7 @@ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uin
+         qCWarning(lcQpaWayland) << "wl_output done event not supported by compositor,"
+                                 << "QScreen may not work correctly";
+         mWaylandDisplay->forceRoundTrip(); // Give the compositor a chance to send geometry etc.
+-        mOutputDone = true; // Fake the done event
++        mProcessedEvents |= OutputDoneEvent; // Fake the done event
+         maybeInitialize();
+     }
+ }
+@@ -81,16 +81,29 @@ QWaylandScreen::~QWaylandScreen()
+ {
+     if (zxdg_output_v1::isInitialized())
+         zxdg_output_v1::destroy();
++    if (wl_output::isInitialized() && wl_output_get_version(wl_output::object()) >= WL_OUTPUT_RELEASE_SINCE_VERSION)
++        wl_output::release();
++}
++
++uint QWaylandScreen::requiredEvents() const
++{
++    uint ret = OutputDoneEvent;
++
++    if (mWaylandDisplay->xdgOutputManager()) {
++        ret |= XdgOutputNameEvent;
++
++        if (mWaylandDisplay->xdgOutputManager()->version() < 3)
++            ret |= XdgOutputDoneEvent;
++    }
++    return ret;
+ }
+ 
+ void QWaylandScreen::maybeInitialize()
+ {
+     Q_ASSERT(!mInitialized);
+ 
+-    if (!mOutputDone)
+-        return;
+-
+-    if (mWaylandDisplay->xdgOutputManager() && !mXdgOutputDone)
++    const uint requiredEvents = this->requiredEvents();
++    if ((mProcessedEvents & requiredEvents) != requiredEvents)
+         return;
+ 
+     mInitialized = true;
+@@ -276,9 +289,8 @@ void QWaylandScreen::output_scale(int32_t factor)
+ 
+ void QWaylandScreen::output_done()
+ {
+-    mOutputDone = true;
+-    if (zxdg_output_v1::isInitialized() && mWaylandDisplay->xdgOutputManager()->version() >= 3)
+-        mXdgOutputDone = true;
++    mProcessedEvents |= OutputDoneEvent;
++
+     if (mInitialized) {
+         updateOutputProperties();
+         if (zxdg_output_v1::isInitialized())
+@@ -339,7 +351,7 @@ void QWaylandScreen::zxdg_output_v1_done()
+     if (Q_UNLIKELY(mWaylandDisplay->xdgOutputManager()->version() >= 3))
+         qWarning(lcQpaWayland) << "zxdg_output_v1.done received on version 3 or newer, this is most likely a bug in the compositor";
+ 
+-    mXdgOutputDone = true;
++    mProcessedEvents |= XdgOutputDoneEvent;
+     if (mInitialized)
+         updateXdgOutputProperties();
+     else
+@@ -348,7 +360,11 @@ void QWaylandScreen::zxdg_output_v1_done()
+ 
+ void QWaylandScreen::zxdg_output_v1_name(const QString &name)
+ {
++    if (Q_UNLIKELY(mInitialized))
++        qWarning(lcQpaWayland) << "zxdg_output_v1.name received after output has been initialized, this is most likely a bug in the compositor";
++
+     mOutputName = name;
++    mProcessedEvents |= XdgOutputNameEvent;
+ }
+ 
+ void QWaylandScreen::updateXdgOutputProperties()
+diff --git a/qtwayland/src/client/qwaylandscreen_p.h b/qtwayland/src/client/qwaylandscreen_p.h
+index df1c94f2..050cfdc0 100644
+--- a/qtwayland/src/client/qwaylandscreen_p.h
++++ b/qtwayland/src/client/qwaylandscreen_p.h
+@@ -116,6 +116,13 @@ public:
+     static QWaylandScreen *fromWlOutput(::wl_output *output);
+ 
+ private:
++    enum Event : uint {
++        XdgOutputDoneEvent = 0x1,
++        OutputDoneEvent = 0x2,
++        XdgOutputNameEvent = 0x4,
++    };
++    uint requiredEvents() const;
++
+     void output_mode(uint32_t flags, int width, int height, int refresh) override;
+     void output_geometry(int32_t x, int32_t y,
+                          int32_t width, int32_t height,
+@@ -148,8 +155,7 @@ private:
+     QSize mPhysicalSize;
+     QString mOutputName;
+     Qt::ScreenOrientation m_orientation = Qt::PrimaryOrientation;
+-    bool mOutputDone = false;
+-    bool mXdgOutputDone = false;
++    uint mProcessedEvents = 0;
+     bool mInitialized = false;
+ 
+ #if QT_CONFIG(cursor)
+diff --git a/qtwayland/src/client/qwaylandshmbackingstore.cpp b/qtwayland/src/client/qwaylandshmbackingstore.cpp
+index dc7ff670..41cffdf7 100644
+--- a/qtwayland/src/client/qwaylandshmbackingstore.cpp
++++ b/qtwayland/src/client/qwaylandshmbackingstore.cpp
+@@ -52,6 +52,7 @@
+ 
+ #include <QtWaylandClient/private/wayland-wayland-client-protocol.h>
+ 
++#include <fcntl.h>
+ #include <unistd.h>
+ #include <sys/mman.h>
+ 
+@@ -61,6 +62,9 @@
+ #  ifndef MFD_CLOEXEC
+ #    define MFD_CLOEXEC     0x0001U
+ #  endif
++#  ifndef MFD_ALLOW_SEALING
++#    define MFD_ALLOW_SEALING 0x0002U
++#  endif
+ #endif
+ 
+ QT_BEGIN_NAMESPACE
+@@ -74,8 +78,10 @@ QWaylandShmBuffer::QWaylandShmBuffer(QWaylandDisplay *display,
+     int alloc = stride * size.height();
+     int fd = -1;
+ 
+-#ifdef SYS_memfd_create
+-    fd = syscall(SYS_memfd_create, "wayland-shm", MFD_CLOEXEC);
++#if defined(SYS_memfd_create) && defined(F_SEAL_SEAL)
++    fd = syscall(SYS_memfd_create, "wayland-shm", MFD_CLOEXEC | MFD_ALLOW_SEALING);
++    if (fd >= 0)
++        fcntl(fd, F_ADD_SEALS, F_SEAL_SHRINK | F_SEAL_SEAL);
+ #endif
+ 
+     QScopedPointer<QFile> filePointer;
+diff --git a/qtwayland/src/client/qwaylandwindow.cpp b/qtwayland/src/client/qwaylandwindow.cpp
+index cb82857a..fb2c59dc 100644
+--- a/qtwayland/src/client/qwaylandwindow.cpp
++++ b/qtwayland/src/client/qwaylandwindow.cpp
+@@ -76,7 +76,6 @@ QWaylandWindow *QWaylandWindow::mMouseGrab = nullptr;
+ QWaylandWindow::QWaylandWindow(QWindow *window, QWaylandDisplay *display)
+     : QPlatformWindow(window)
+     , mDisplay(display)
+-    , mFrameQueue(mDisplay->createFrameQueue())
+     , mResizeAfterSwap(qEnvironmentVariableIsSet("QT_WAYLAND_RESIZE_AFTER_SWAP"))
+ {
+     {
+@@ -95,9 +94,6 @@ QWaylandWindow::QWaylandWindow(QWindow *window, QWaylandDisplay *display)
+ 
+ QWaylandWindow::~QWaylandWindow()
+ {
+-    mDisplay->destroyFrameQueue(mFrameQueue);
+-    mDisplay->handleWindowDestroyed(this);
+-
+     delete mWindowDecoration;
+ 
+     if (mSurface)
+@@ -243,6 +239,7 @@ bool QWaylandWindow::shouldCreateSubSurface() const
+ 
+ void QWaylandWindow::reset()
+ {
++    closeChildPopups();
+     delete mShellSurface;
+     mShellSurface = nullptr;
+     delete mSubSurfaceWindow;
+@@ -255,17 +252,22 @@ void QWaylandWindow::reset()
+         mSurface.reset();
+     }
+ 
+-    if (mFrameCallback) {
+-        wl_callback_destroy(mFrameCallback);
+-        mFrameCallback = nullptr;
+-    }
++    {
++        QMutexLocker lock(&mFrameSyncMutex);
++        if (mFrameCallback) {
++            wl_callback_destroy(mFrameCallback);
++            mFrameCallback = nullptr;
++        }
+ 
+-    mFrameCallbackElapsedTimer.invalidate();
+-    mWaitingForFrameCallback = false;
++        mFrameCallbackElapsedTimer.invalidate();
++        mWaitingForFrameCallback = false;
++    }
+     mFrameCallbackTimedOut = false;
+ 
+     mMask = QRegion();
+     mQueuedBuffer = nullptr;
++
++    mDisplay->handleWindowDestroyed(this);
+ }
+ 
+ QWaylandWindow *QWaylandWindow::fromWlSurface(::wl_surface *surface)
+@@ -351,19 +353,25 @@ void QWaylandWindow::setGeometry_helper(const QRect &rect)
+     }
+ }
+ 
+-void QWaylandWindow::setGeometry(const QRect &rect)
++void QWaylandWindow::setGeometry(const QRect &r)
+ {
++    auto rect = r;
++    if (fixedToplevelPositions && !QPlatformWindow::parent() && window()->type() != Qt::Popup
++        && window()->type() != Qt::ToolTip) {
++        rect.moveTo(screen()->geometry().topLeft());
++    }
+     setGeometry_helper(rect);
+ 
+     if (window()->isVisible() && rect.isValid()) {
+         if (mWindowDecoration)
+             mWindowDecoration->update();
+ 
+-        if (mResizeAfterSwap && windowType() == Egl && mSentInitialResize)
++        if (mResizeAfterSwap && windowType() == Egl && mSentInitialResize) {
++            QMutexLocker lock(&mResizeLock);
+             mResizeDirty = true;
+-        else
++        } else {
+             QWindowSystemInterface::handleGeometryChange(window(), geometry());
+-
++        }
+         mSentInitialResize = true;
+     }
+     QRect exposeGeometry(QPoint(), geometry().size());
+@@ -374,7 +382,7 @@ void QWaylandWindow::setGeometry(const QRect &rect)
+         mShellSurface->setWindowGeometry(windowContentGeometry());
+ 
+     if (isOpaque() && mMask.isEmpty())
+-        setOpaqueArea(rect);
++        setOpaqueArea(QRect(QPoint(0, 0), rect.size()));
+ }
+ 
+ void QWaylandWindow::resizeFromApplyConfigure(const QSize &sizeWithMargins, const QPoint &offset)
+@@ -399,21 +407,6 @@ void QWaylandWindow::sendExposeEvent(const QRect &rect)
+     mLastExposeGeometry = rect;
+ }
+ 
+-
+-static QVector<QPointer<QWaylandWindow>> activePopups;
+-
+-void QWaylandWindow::closePopups(QWaylandWindow *parent)
+-{
+-    while (!activePopups.isEmpty()) {
+-        auto popup = activePopups.takeLast();
+-        if (popup.isNull())
+-            continue;
+-        if (popup.data() == parent)
+-            return;
+-        popup->reset();
+-    }
+-}
+-
+ QPlatformScreen *QWaylandWindow::calculateScreenFromSurfaceEvents() const
+ {
+     QReadLocker lock(&mSurfaceLock);
+@@ -433,10 +426,7 @@ void QWaylandWindow::setVisible(bool visible)
+     lastVisible = visible;
+ 
+     if (visible) {
+-        if (window()->type() == Qt::Popup || window()->type() == Qt::ToolTip)
+-            activePopups << this;
+         initWindow();
+-        mDisplay->flushRequests();
+ 
+         setGeometry(windowGeometry());
+         // Don't flush the events here, or else the newly visible window may start drawing, but since
+@@ -444,7 +434,6 @@ void QWaylandWindow::setVisible(bool visible)
+         // QWaylandShmBackingStore::beginPaint().
+     } else {
+         sendExposeEvent(QRect());
+-        closePopups(this);
+         reset();
+     }
+ }
+@@ -556,12 +545,12 @@ void QWaylandWindow::sendRecursiveExposeEvent()
+ 
+ void QWaylandWindow::attach(QWaylandBuffer *buffer, int x, int y)
+ {
+-    Q_ASSERT(!buffer->committed());
+     QReadLocker locker(&mSurfaceLock);
+     if (mSurface == nullptr)
+         return;
+ 
+     if (buffer) {
++        Q_ASSERT(!buffer->committed());
+         handleUpdate();
+         buffer->setBusy();
+ 
+@@ -583,7 +572,11 @@ void QWaylandWindow::damage(const QRect &rect)
+     if (mSurface == nullptr)
+         return;
+ 
+-    mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    const int s = scale();
++    if (mDisplay->compositorVersion() >= 4)
++        mSurface->damage_buffer(s * rect.x(), s * rect.y(), s * rect.width(), s * rect.height());
++    else
++        mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
+ }
+ 
+ void QWaylandWindow::safeCommit(QWaylandBuffer *buffer, const QRegion &damage)
+@@ -619,8 +612,14 @@ void QWaylandWindow::commit(QWaylandBuffer *buffer, const QRegion &damage)
+         return;
+ 
+     attachOffset(buffer);
+-    for (const QRect &rect: damage)
+-        mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    if (mDisplay->compositorVersion() >= 4) {
++        const int s = scale();
++        for (const QRect &rect: damage)
++            mSurface->damage_buffer(s * rect.x(), s * rect.y(), s * rect.width(), s * rect.height());
++    } else {
++        for (const QRect &rect: damage)
++            mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    }
+     Q_ASSERT(!buffer->committed());
+     buffer->setCommitted();
+     mSurface->commit();
+@@ -635,42 +634,53 @@ void QWaylandWindow::commit()
+ 
+ const wl_callback_listener QWaylandWindow::callbackListener = {
+     [](void *data, wl_callback *callback, uint32_t time) {
+-        Q_UNUSED(callback);
+         Q_UNUSED(time);
+         auto *window = static_cast<QWaylandWindow*>(data);
+-        window->handleFrameCallback();
++        window->handleFrameCallback(callback);
+     }
+ };
+ 
+-void QWaylandWindow::handleFrameCallback()
++void QWaylandWindow::handleFrameCallback(wl_callback* callback)
+ {
++    QMutexLocker locker(&mFrameSyncMutex);
++    if (!mFrameCallback) {
++        // This means the callback is already unset by QWaylandWindow::reset.
++        // The wl_callback object will be destroyed there too.
++        return;
++    }
++    Q_ASSERT(callback == mFrameCallback);
++    wl_callback_destroy(callback);
++    mFrameCallback = nullptr;
++
+     mWaitingForFrameCallback = false;
+     mFrameCallbackElapsedTimer.invalidate();
+ 
+     // The rest can wait until we can run it on the correct thread
+-    if (!mWaitingForUpdateDelivery) {
+-        auto doHandleExpose = [this]() {
+-            bool wasExposed = isExposed();
+-            mFrameCallbackTimedOut = false;
+-            if (!wasExposed && isExposed()) // Did setting mFrameCallbackTimedOut make the window exposed?
+-                sendExposeEvent(QRect(QPoint(), geometry().size()));
+-            if (wasExposed && hasPendingUpdateRequest())
+-                deliverUpdateRequest();
+-
+-            mWaitingForUpdateDelivery = false;
+-        };
++    auto doHandleExpose = [this]() {
++        mWaitingForUpdateDelivery.storeRelease(false);
++        bool wasExposed = isExposed();
++        mFrameCallbackTimedOut = false;
++        if (!wasExposed && isExposed()) // Did setting mFrameCallbackTimedOut make the window exposed?
++            sendExposeEvent(QRect(QPoint(), geometry().size()));
++        if (wasExposed && hasPendingUpdateRequest())
++            deliverUpdateRequest();
++    };
+ 
++    if (mWaitingForUpdateDelivery.testAndSetAcquire(false, true)) {
+         // Queued connection, to make sure we don't call handleUpdate() from inside waitForFrameSync()
+         // in the single-threaded case.
+-        mWaitingForUpdateDelivery = true;
+         QMetaObject::invokeMethod(this, doHandleExpose, Qt::QueuedConnection);
+     }
++
++    mFrameSyncWait.notify_all();
+ }
+ 
+ bool QWaylandWindow::waitForFrameSync(int timeout)
+ {
+-    QMutexLocker locker(mFrameQueue.mutex);
+-    mDisplay->dispatchQueueWhile(mFrameQueue.queue, [&]() { return mWaitingForFrameCallback; }, timeout);
++    QMutexLocker locker(&mFrameSyncMutex);
++
++    QDeadlineTimer deadline(timeout);
++    while (mWaitingForFrameCallback && mFrameSyncWait.wait(&mFrameSyncMutex, deadline)) { }
+ 
+     if (mWaitingForFrameCallback) {
+         qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
+@@ -868,6 +878,17 @@ bool QWaylandWindow::createDecoration()
+             subsurf->set_position(pos.x() + m.left(), pos.y() + m.top());
+         }
+         sendExposeEvent(QRect(QPoint(), geometry().size()));
++
++        // This is a special case where the buffer is recreated, but since
++        // the content rect remains the same, the widgets remain the same
++        // size and are not redrawn, leaving the new buffer empty. As a simple
++        // work-around, we trigger a full extra update whenever the client-side
++        // window decorations are toggled while the window is showing.
++        // Note: createDecoration() is sometimes called from the render thread
++        // of Qt Quick. This is essentially wrong and could potentially cause problems,
++        // but until the underlying issue has been fixed, we have to use invokeMethod()
++        // here to avoid asserts.
++        QMetaObject::invokeMethod(window(), &QWindow::requestUpdate);
+     }
+ 
+     return mWindowDecoration;
+@@ -1023,6 +1044,13 @@ void QWaylandWindow::handleScreensChanged()
+ 
+     QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->QPlatformScreen::screen());
+     mLastReportedScreen = newScreen;
++    if (fixedToplevelPositions && !QPlatformWindow::parent() && window()->type() != Qt::Popup
++        && window()->type() != Qt::ToolTip
++        && geometry().topLeft() != newScreen->geometry().topLeft()) {
++        auto geometry = this->geometry();
++        geometry.moveTo(newScreen->geometry().topLeft());
++        setGeometry(geometry);
++    }
+ 
+     int scale = newScreen->isPlaceholder() ? 1 : static_cast<QWaylandScreen *>(newScreen)->scale();
+     if (scale != mScale) {
+@@ -1094,10 +1122,18 @@ bool QWaylandWindow::setMouseGrabEnabled(bool grab)
+     return true;
+ }
+ 
++Qt::WindowStates QWaylandWindow::windowStates() const
++{
++    return mLastReportedWindowStates;
++}
++
+ void QWaylandWindow::handleWindowStatesChanged(Qt::WindowStates states)
+ {
+     createDecoration();
+-    QWindowSystemInterface::handleWindowStateChanged(window(), states, mLastReportedWindowStates);
++    Qt::WindowStates statesWithoutActive = states & ~Qt::WindowActive;
++    Qt::WindowStates lastStatesWithoutActive = mLastReportedWindowStates & ~Qt::WindowActive;
++    QWindowSystemInterface::handleWindowStateChanged(window(), statesWithoutActive,
++                                                     lastStatesWithoutActive);
+     mLastReportedWindowStates = states;
+ }
+ 
+@@ -1139,19 +1175,24 @@ void QWaylandWindow::timerEvent(QTimerEvent *event)
+     if (event->timerId() != mFrameCallbackCheckIntervalTimerId)
+         return;
+ 
+-    bool callbackTimerExpired = mFrameCallbackElapsedTimer.hasExpired(mFrameCallbackTimeout);
+-    if (!mFrameCallbackElapsedTimer.isValid() || callbackTimerExpired ) {
+-        killTimer(mFrameCallbackCheckIntervalTimerId);
+-        mFrameCallbackCheckIntervalTimerId = -1;
+-    }
+-    if (mFrameCallbackElapsedTimer.isValid() && callbackTimerExpired) {
+-        mFrameCallbackElapsedTimer.invalidate();
++    {
++        QMutexLocker lock(&mFrameSyncMutex);
+ 
+-        qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
+-        mFrameCallbackTimedOut = true;
+-        mWaitingForUpdate = false;
+-        sendExposeEvent(QRect());
++        bool callbackTimerExpired = mFrameCallbackElapsedTimer.hasExpired(mFrameCallbackTimeout);
++        if (!mFrameCallbackElapsedTimer.isValid() || callbackTimerExpired ) {
++            killTimer(mFrameCallbackCheckIntervalTimerId);
++            mFrameCallbackCheckIntervalTimerId = -1;
++        }
++        if (!mFrameCallbackElapsedTimer.isValid() || !callbackTimerExpired) {
++            return;
++        }
++        mFrameCallbackElapsedTimer.invalidate();
+     }
++
++    qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
++    mFrameCallbackTimedOut = true;
++    mWaitingForUpdate = false;
++    sendExposeEvent(QRect());
+ }
+ 
+ void QWaylandWindow::requestUpdate()
+@@ -1160,8 +1201,11 @@ void QWaylandWindow::requestUpdate()
+     Q_ASSERT(hasPendingUpdateRequest()); // should be set by QPA
+ 
+     // If we have a frame callback all is good and will be taken care of there
+-    if (mWaitingForFrameCallback)
+-        return;
++    {
++        QMutexLocker locker(&mFrameSyncMutex);
++        if (mWaitingForFrameCallback)
++            return;
++    }
+ 
+     // If we've already called deliverUpdateRequest(), but haven't seen any attach+commit/swap yet
+     // This is a somewhat redundant behavior and might indicate a bug in the calling code, so log
+@@ -1174,7 +1218,12 @@ void QWaylandWindow::requestUpdate()
+     // so use invokeMethod to delay the delivery a bit.
+     QMetaObject::invokeMethod(this, [this] {
+         // Things might have changed in the meantime
+-        if (hasPendingUpdateRequest() && !mWaitingForFrameCallback)
++        {
++            QMutexLocker locker(&mFrameSyncMutex);
++            if (mWaitingForFrameCallback)
++                return;
++        }
++        if (hasPendingUpdateRequest())
+             deliverUpdateRequest();
+     }, Qt::QueuedConnection);
+ }
+@@ -1185,19 +1234,18 @@ void QWaylandWindow::requestUpdate()
+ void QWaylandWindow::handleUpdate()
+ {
+     qCDebug(lcWaylandBackingstore) << "handleUpdate" << QThread::currentThread();
++
+     // TODO: Should sync subsurfaces avoid requesting frame callbacks?
+     QReadLocker lock(&mSurfaceLock);
+     if (!mSurface)
+         return;
+ 
+-    if (mFrameCallback) {
+-        wl_callback_destroy(mFrameCallback);
+-        mFrameCallback = nullptr;
+-    }
++    QMutexLocker locker(&mFrameSyncMutex);
++    if (mWaitingForFrameCallback)
++        return;
+ 
+-    QMutexLocker locker(mFrameQueue.mutex);
+     struct ::wl_surface *wrappedSurface = reinterpret_cast<struct ::wl_surface *>(wl_proxy_create_wrapper(mSurface->object()));
+-    wl_proxy_set_queue(reinterpret_cast<wl_proxy *>(wrappedSurface), mFrameQueue.queue);
++    wl_proxy_set_queue(reinterpret_cast<wl_proxy *>(wrappedSurface), mDisplay->frameEventQueue());
+     mFrameCallback = wl_surface_frame(wrappedSurface);
+     wl_proxy_wrapper_destroy(wrappedSurface);
+     wl_callback_add_listener(mFrameCallback, &QWaylandWindow::callbackListener, this);
+@@ -1207,6 +1255,8 @@ void QWaylandWindow::handleUpdate()
+     // Start a timer for handling the case when the compositor stops sending frame callbacks.
+     if (mFrameCallbackTimeout > 0) {
+         QMetaObject::invokeMethod(this, [this] {
++            QMutexLocker locker(&mFrameSyncMutex);
++
+             if (mWaitingForFrameCallback) {
+                 if (mFrameCallbackCheckIntervalTimerId < 0)
+                     mFrameCallbackCheckIntervalTimerId = startTimer(mFrameCallbackTimeout);
+@@ -1267,6 +1317,20 @@ void QWaylandWindow::setOpaqueArea(const QRegion &opaqueArea)
+     wl_region_destroy(region);
+ }
+ 
++void QWaylandWindow::addChildPopup(QWaylandWindow *surface) {
++    mChildPopups.append(surface);
++}
++
++void QWaylandWindow::removeChildPopup(QWaylandWindow *surface) {
++    mChildPopups.removeAll(surface);
++}
++
++void QWaylandWindow::closeChildPopups() {
++    while (!mChildPopups.isEmpty()) {
++        auto popup = mChildPopups.takeLast();
++        popup->reset();
++    }
++}
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/client/qwaylandwindow_p.h b/qtwayland/src/client/qwaylandwindow_p.h
+index 01337cff..2f219d8c 100644
+--- a/qtwayland/src/client/qwaylandwindow_p.h
++++ b/qtwayland/src/client/qwaylandwindow_p.h
+@@ -98,6 +98,9 @@ public:
+     QWaylandWindow(QWindow *window, QWaylandDisplay *display);
+     ~QWaylandWindow() override;
+ 
++    // Keep Toplevels position on the top left corner of their screen
++    static inline bool fixedToplevelPositions = true;
++
+     virtual WindowType windowType() const = 0;
+     virtual void ensureSize();
+     WId winId() const override;
+@@ -148,6 +151,7 @@ public:
+     void setWindowState(Qt::WindowStates states) override;
+     void setWindowFlags(Qt::WindowFlags flags) override;
+     void handleWindowStatesChanged(Qt::WindowStates states);
++    Qt::WindowStates windowStates() const;
+ 
+     void raise() override;
+     void lower() override;
+@@ -206,6 +210,10 @@ public:
+     void handleUpdate();
+     void deliverUpdateRequest() override;
+ 
++    void addChildPopup(QWaylandWindow* child);
++    void removeChildPopup(QWaylandWindow* child);
++    void closeChildPopups();
++
+ public slots:
+     void applyConfigure();
+ 
+@@ -215,7 +223,11 @@ signals:
+ 
+ protected:
+     QWaylandDisplay *mDisplay = nullptr;
++
++    // mSurface can be written by the main thread. Other threads should claim a read lock for access
++    mutable QReadWriteLock mSurfaceLock;
+     QScopedPointer<QWaylandSurface> mSurface;
++
+     QWaylandShellSurface *mShellSurface = nullptr;
+     QWaylandSubSurface *mSubSurfaceWindow = nullptr;
+     QVector<QWaylandSubSurface *> mChildren;
+@@ -225,13 +237,14 @@ protected:
+     Qt::MouseButtons mMousePressedInContentArea = Qt::NoButton;
+ 
+     WId mWindowId;
+-    bool mWaitingForFrameCallback = false;
+     bool mFrameCallbackTimedOut = false; // Whether the frame callback has timed out
+-    bool mWaitingForUpdateDelivery = false;
+     int mFrameCallbackCheckIntervalTimerId = -1;
+-    QElapsedTimer mFrameCallbackElapsedTimer;
+-    struct ::wl_callback *mFrameCallback = nullptr;
+-    QWaylandDisplay::FrameQueue mFrameQueue;
++    QAtomicInt mWaitingForUpdateDelivery = false;
++
++    bool mWaitingForFrameCallback = false; // Protected by mFrameSyncMutex
++    QElapsedTimer mFrameCallbackElapsedTimer; // Protected by mFrameSyncMutex
++    struct ::wl_callback *mFrameCallback = nullptr; // Protected by mFrameSyncMutex
++    QMutex mFrameSyncMutex;
+     QWaitCondition mFrameSyncWait;
+ 
+     // True when we have called deliverRequestUpdate, but the client has not yet attached a new buffer
+@@ -261,6 +274,8 @@ protected:
+     QWaylandBuffer *mQueuedBuffer = nullptr;
+     QRegion mQueuedBufferDamage;
+ 
++    QList<QPointer<QWaylandWindow>> mChildPopups;
++
+ private:
+     void setGeometry_helper(const QRect &rect);
+     void initWindow();
+@@ -283,12 +298,10 @@ private:
+     QRect mLastExposeGeometry;
+ 
+     static const wl_callback_listener callbackListener;
+-    void handleFrameCallback();
++    void handleFrameCallback(struct ::wl_callback* callback);
+ 
+     static QWaylandWindow *mMouseGrab;
+ 
+-    mutable QReadWriteLock mSurfaceLock;
+-
+     friend class QWaylandSubSurface;
+ };
+ 
+diff --git a/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h b/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
+index ccad0048..4cc9b3b8 100644
+--- a/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
++++ b/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
+@@ -73,11 +73,10 @@ public:
+         return true;
+     }
+     virtual QWaylandShellSurface *createShellSurface(QWaylandWindow *window) = 0;
++    // kept for binary compat with layer-shell-qt
+     virtual void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) {
+-        if (newFocus)
+-            m_display->handleWindowActivated(newFocus);
+-        if (oldFocus)
+-            m_display->handleWindowDeactivated(oldFocus);
++        Q_UNUSED(newFocus);
++        Q_UNUSED(oldFocus);
+     }
+     virtual void *nativeResourceForWindow(const QByteArray &resource, QWindow *window) {
+         Q_UNUSED(resource);
+diff --git a/qtwayland/src/compositor/configure.json b/qtwayland/src/compositor/configure.json
+index bcfd5215..da95d07b 100644
+--- a/qtwayland/src/compositor/configure.json
++++ b/qtwayland/src/compositor/configure.json
+@@ -7,6 +7,31 @@
+     "testDir": "../../config.tests",
+ 
+     "libraries": {
++        "wayland-client": {
++            "label": "Wayland client library",
++            "headers": "wayland-version.h",
++            "test": {
++                "main": [
++                    "#if WAYLAND_VERSION_MAJOR < 1",
++                    "# error Wayland 1.8.0 or higher required",
++                    "#endif",
++                    "#if WAYLAND_VERSION_MAJOR == 1",
++                    "# if WAYLAND_VERSION_MINOR < 8",
++                    "#  error Wayland 1.8.0 or higher required",
++                    "# endif",
++                    "# if WAYLAND_VERSION_MINOR == 8",
++                    "#  if WAYLAND_VERSION_MICRO < 0",
++                    "#   error Wayland 1.8.0 or higher required",
++                    "#  endif",
++                    "# endif",
++                    "#endif"
++                 ]
++            },
++            "sources": [
++                { "type": "pkgConfig", "args": "wayland-client" },
++                "-lwayland-client"
++            ]
++        },
+         "wayland-server": {
+             "label": "wayland-server",
+             "headers": "wayland-version.h",
+@@ -151,8 +176,7 @@
+                     "#endif"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "dmabuf-client-buffer": {
+             "label": "Linux Client dma-buf Buffer Sharing",
+@@ -176,8 +200,7 @@
+                     "return 0;"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "vulkan-server-buffer": {
+             "label": "Vulkan Buffer Sharing",
+@@ -195,7 +218,8 @@
+                     "exportAllocInfo.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR;",
+                     "return 0;"
+                 ]
+-            }
++            },
++            "use": "wayland-client"
+         }
+     },
+ 
+diff --git a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
+index 7889f575..64140672 100644
+--- a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
++++ b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
+@@ -40,6 +40,7 @@
+ #include "qwaylandeglwindow.h"
+ 
+ #include <QtWaylandClient/private/qwaylandscreen_p.h>
++#include <QtWaylandClient/private/qwaylandsurface_p.h>
+ #include "qwaylandglcontext.h"
+ 
+ #include <QtEglSupport/private/qeglconvenience_p.h>
+@@ -124,6 +125,7 @@ void QWaylandEglWindow::updateSurface(bool create)
+         }
+         mOffset = QPoint();
+     } else {
++        QReadLocker locker(&mSurfaceLock);
+         if (m_waylandEglWindow) {
+             int current_width, current_height;
+             static bool disableResizeCheck = qgetenv("QT_WAYLAND_DISABLE_RESIZECHECK").toInt();
+@@ -131,14 +133,16 @@ void QWaylandEglWindow::updateSurface(bool create)
+             if (!disableResizeCheck) {
+                 wl_egl_window_get_attached_size(m_waylandEglWindow, &current_width, &current_height);
+             }
+-            if (disableResizeCheck || (current_width != sizeWithMargins.width() || current_height != sizeWithMargins.height())) {
++            if (disableResizeCheck || (current_width != sizeWithMargins.width() || current_height != sizeWithMargins.height()) || m_requestedSize != sizeWithMargins) {
+                 wl_egl_window_resize(m_waylandEglWindow, sizeWithMargins.width(), sizeWithMargins.height(), mOffset.x(), mOffset.y());
++                m_requestedSize = sizeWithMargins;
+                 mOffset = QPoint();
+ 
+                 m_resize = true;
+             }
+-        } else if (create && wlSurface()) {
+-            m_waylandEglWindow = wl_egl_window_create(wlSurface(), sizeWithMargins.width(), sizeWithMargins.height());
++        } else if (create && mSurface) {
++            m_waylandEglWindow = wl_egl_window_create(mSurface->object(), sizeWithMargins.width(), sizeWithMargins.height());
++            m_requestedSize = sizeWithMargins;
+         }
+ 
+         if (!m_eglSurface && m_waylandEglWindow && create) {
+diff --git a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
+index 5b1f4d56..0079dfef 100644
+--- a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
++++ b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
+@@ -88,6 +88,7 @@ private:
+     mutable QOpenGLFramebufferObject *m_contentFBO = nullptr;
+ 
+     QSurfaceFormat m_format;
++    QSize m_requestedSize;
+ };
+ 
+ }
+diff --git a/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h b/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
+index 56a710c3..c6a8b6c6 100644
+--- a/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
++++ b/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
+@@ -41,6 +41,8 @@
+ #include <QtCore/QTextStream>
+ #include <QtGui/QOpenGLTexture>
+ 
++#include <array>
++
+ #include <EGL/egl.h>
+ #include <EGL/eglext.h>
+ 
+diff --git a/qtwayland/src/plugins/decorations/bradient/main.cpp b/qtwayland/src/plugins/decorations/bradient/main.cpp
+index e75fda3c..fa885143 100644
+--- a/qtwayland/src/plugins/decorations/bradient/main.cpp
++++ b/qtwayland/src/plugins/decorations/bradient/main.cpp
+@@ -164,13 +164,10 @@ void QWaylandBradientDecoration::paint(QPaintDevice *device)
+     // Window icon
+     QIcon icon = waylandWindow()->windowIcon();
+     if (!icon.isNull()) {
+-        QPixmap pixmap = icon.pixmap(QSize(128, 128));
+-        QPixmap scaled = pixmap.scaled(22, 22, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+-
+         QRectF iconRect(0, 0, 22, 22);
+-        p.drawPixmap(iconRect.adjusted(margins().left() + BUTTON_SPACING, 4,
+-                                       margins().left() + BUTTON_SPACING, 4),
+-                     scaled, iconRect);
++        iconRect.adjust(margins().left() + BUTTON_SPACING, 4,
++                        margins().left() + BUTTON_SPACING, 4),
++        icon.paint(&p, iconRect.toRect());
+     }
+ 
+     // Window title
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
+index 85d25e3c..60bdd491 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
+@@ -47,18 +47,21 @@ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
+-QWaylandXdgPopupV5::QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow *window)
++QWaylandXdgPopupV5::QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow* parent, QWaylandWindow *window)
+     : QWaylandShellSurface(window)
+     , QtWayland::xdg_popup_v5(popup)
++    , m_parent(parent)
+     , m_window(window)
+ {
+     if (window->display()->windowExtension())
+         m_extendedWindow = new QWaylandExtendedSurface(window);
++    m_parent->addChildPopup(m_window);
+ }
+ 
+ QWaylandXdgPopupV5::~QWaylandXdgPopupV5()
+ {
+     xdg_popup_destroy(object());
++    m_parent->removeChildPopup(m_window);
+     delete m_extendedWindow;
+ }
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
+index 7494f6a6..d85f130b 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
+@@ -70,7 +70,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgPopupV5 : public QWaylandShellSurface
+ {
+     Q_OBJECT
+ public:
+-    QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow *window);
++    QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow* parent, QWaylandWindow *window);
+     ~QWaylandXdgPopupV5() override;
+ 
+ protected:
+@@ -78,6 +78,7 @@ protected:
+ 
+ private:
+     QWaylandExtendedSurface *m_extendedWindow = nullptr;
++    QWaylandWindow *m_parent = nullptr;
+     QWaylandWindow *m_window = nullptr;
+ };
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
+index 7e242c4a..def8452a 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
+@@ -84,7 +84,7 @@ QWaylandXdgPopupV5 *QWaylandXdgShellV5::createXdgPopup(QWaylandWindow *window, Q
+     int x = position.x() + parentWindow->frameMargins().left();
+     int y = position.y() + parentWindow->frameMargins().top();
+ 
+-    auto popup = new QWaylandXdgPopupV5(get_xdg_popup(window->wlSurface(), parentSurface, seat, m_popupSerial, x, y), window);
++    auto popup = new QWaylandXdgPopupV5(get_xdg_popup(window->wlSurface(), parentSurface, seat, m_popupSerial, x, y), parentWindow, window);
+     m_popups.append(window);
+     QObject::connect(popup, &QWaylandXdgPopupV5::destroyed, [this, window](){
+         m_popups.removeOne(window);
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
+index 4e25949f..cfc60939 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
+@@ -85,13 +85,6 @@ QWaylandShellSurface *QWaylandXdgShellV5Integration::createShellSurface(QWayland
+     return m_xdgShell->createXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellV5Integration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) {
+-    if (newFocus && qobject_cast<QWaylandXdgPopupV5 *>(newFocus->shellSurface()))
+-        m_display->handleWindowActivated(newFocus);
+-    if (oldFocus && qobject_cast<QWaylandXdgPopupV5 *>(oldFocus->shellSurface()))
+-        m_display->handleWindowDeactivated(oldFocus);
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
+index ce6bdb9e..aed88670 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
+@@ -67,7 +67,6 @@ public:
+     QWaylandXdgShellV5Integration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShellV5> m_xdgShell;
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
+index 8c371661..151c78e3 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
+@@ -174,6 +174,7 @@ QWaylandXdgSurfaceV6::Popup::Popup(QWaylandXdgSurfaceV6 *xdgSurface, QWaylandXdg
+     , m_xdgSurface(xdgSurface)
+     , m_parent(parent)
+ {
++    m_parent->window()->addChildPopup(m_xdgSurface->window());
+ }
+ 
+ QWaylandXdgSurfaceV6::Popup::~Popup()
+@@ -181,6 +182,8 @@ QWaylandXdgSurfaceV6::Popup::~Popup()
+     if (isInitialized())
+         destroy();
+ 
++    m_parent->window()->removeChildPopup(m_xdgSurface->window());
++
+     if (m_grabbing) {
+         auto *shell = m_xdgSurface->m_shell;
+         Q_ASSERT(shell->m_topmostGrabbingPopup == this);
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
+index 03164316..e8da8ba1 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
+@@ -68,20 +68,6 @@ QWaylandShellSurface *QWaylandXdgShellV6Integration::createShellSurface(QWayland
+     return m_xdgShell->getXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellV6Integration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus)
+-{
+-    if (newFocus) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurfaceV6 *>(newFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowActivated(newFocus);
+-    }
+-    if (oldFocus && qobject_cast<QWaylandXdgSurfaceV6 *>(oldFocus->shellSurface())) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurfaceV6 *>(oldFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowDeactivated(oldFocus);
+-    }
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
+index 261f8cbb..c1bcd5c6 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
+@@ -65,7 +65,6 @@ public:
+     QWaylandXdgShellV6Integration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShellV6> m_xdgShell;
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
+index f3e3c330..fa6d5808 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
+@@ -67,11 +67,6 @@ QWaylandXdgSurface::Toplevel::Toplevel(QWaylandXdgSurface *xdgSurface)
+ 
+ QWaylandXdgSurface::Toplevel::~Toplevel()
+ {
+-    if (m_applied.states & Qt::WindowActive) {
+-        QWaylandWindow *window = m_xdgSurface->window();
+-        window->display()->handleWindowDeactivated(window);
+-    }
+-
+     // The protocol spec requires that the decoration object is deleted before xdg_toplevel.
+     delete m_decoration;
+     m_decoration = nullptr;
+@@ -85,16 +80,15 @@ void QWaylandXdgSurface::Toplevel::applyConfigure()
+     if (!(m_applied.states & (Qt::WindowMaximized|Qt::WindowFullScreen)))
+         m_normalSize = m_xdgSurface->m_window->windowFrameGeometry().size();
+ 
+-    if ((m_pending.states & Qt::WindowActive) && !(m_applied.states & Qt::WindowActive))
++    if ((m_pending.states & Qt::WindowActive) && !(m_applied.states & Qt::WindowActive)
++        && !m_xdgSurface->m_window->display()->isKeyboardAvailable())
+         m_xdgSurface->m_window->display()->handleWindowActivated(m_xdgSurface->m_window);
+ 
+-    if (!(m_pending.states & Qt::WindowActive) && (m_applied.states & Qt::WindowActive))
++    if (!(m_pending.states & Qt::WindowActive) && (m_applied.states & Qt::WindowActive)
++        && !m_xdgSurface->m_window->display()->isKeyboardAvailable())
+         m_xdgSurface->m_window->display()->handleWindowDeactivated(m_xdgSurface->m_window);
+ 
+-    // TODO: none of the other plugins send WindowActive either, but is it on purpose?
+-    Qt::WindowStates statesWithoutActive = m_pending.states & ~Qt::WindowActive;
+-
+-    m_xdgSurface->m_window->handleWindowStatesChanged(statesWithoutActive);
++    m_xdgSurface->m_window->handleWindowStatesChanged(m_pending.states);
+ 
+     if (m_pending.size.isEmpty()) {
+         // An empty size in the configure means it's up to the client to choose the size
+@@ -105,8 +99,6 @@ void QWaylandXdgSurface::Toplevel::applyConfigure()
+         m_xdgSurface->m_window->resizeFromApplyConfigure(m_pending.size);
+     }
+ 
+-    m_xdgSurface->setSizeHints();
+-
+     m_applied = m_pending;
+     qCDebug(lcQpaWayland) << "Applied pending xdg_toplevel configure event:" << m_applied.size << m_applied.states;
+ }
+@@ -203,12 +195,17 @@ QtWayland::xdg_toplevel::resize_edge QWaylandXdgSurface::Toplevel::convertToResi
+                 | ((edges & Qt::RightEdge) ? resize_edge_right : 0));
+ }
+ 
+-QWaylandXdgSurface::Popup::Popup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parent,
++QWaylandXdgSurface::Popup::Popup(QWaylandXdgSurface *xdgSurface, QWaylandWindow *parent,
+                                  QtWayland::xdg_positioner *positioner)
+-    : xdg_popup(xdgSurface->get_popup(parent->object(), positioner->object()))
+-    , m_xdgSurface(xdgSurface)
++    : m_xdgSurface(xdgSurface)
++    , m_parentXdgSurface(qobject_cast<QWaylandXdgSurface *>(parent->shellSurface()))
+     , m_parent(parent)
+ {
++
++    init(xdgSurface->get_popup(m_parentXdgSurface ? m_parentXdgSurface->object() : nullptr, positioner->object()));
++    if (m_parent) {
++        m_parent->addChildPopup(m_xdgSurface->window());
++    }
+ }
+ 
+ QWaylandXdgSurface::Popup::~Popup()
+@@ -216,10 +213,24 @@ QWaylandXdgSurface::Popup::~Popup()
+     if (isInitialized())
+         destroy();
+ 
++    if (m_parent) {
++        m_parent->removeChildPopup(m_xdgSurface->window());
++    }
++
+     if (m_grabbing) {
+         auto *shell = m_xdgSurface->m_shell;
+         Q_ASSERT(shell->m_topmostGrabbingPopup == this);
+-        shell->m_topmostGrabbingPopup = m_parent->m_popup;
++        shell->m_topmostGrabbingPopup = m_parentXdgSurface ? m_parentXdgSurface->m_popup : nullptr;
++        m_grabbing = false;
++
++        // Synthesize Qt enter/leave events for popup
++        QWindow *leave = nullptr;
++        if (m_xdgSurface && m_xdgSurface->window())
++            leave = m_xdgSurface->window()->window();
++        QWindowSystemInterface::handleLeaveEvent(leave);
++
++        if (QWindow *enter = QGuiApplication::topLevelAt(QCursor::pos()))
++            QWindowSystemInterface::handleEnterEvent(enter, enter->mapFromGlobal(QCursor::pos()), QCursor::pos());
+     }
+ }
+ 
+@@ -257,6 +268,7 @@ QWaylandXdgSurface::QWaylandXdgSurface(QWaylandXdgShell *shell, ::xdg_surface *s
+                 m_toplevel->set_parent(parentXdgSurface->m_toplevel->object());
+         }
+     }
++    setSizeHints();
+ }
+ 
+ QWaylandXdgSurface::~QWaylandXdgSurface()
+@@ -400,8 +412,6 @@ void QWaylandXdgSurface::setPopup(QWaylandWindow *parent)
+ {
+     Q_ASSERT(!m_toplevel && !m_popup);
+ 
+-    auto parentXdgSurface = static_cast<QWaylandXdgSurface *>(parent->shellSurface());
+-
+     auto positioner = new QtWayland::xdg_positioner(m_shell->create_positioner());
+     // set_popup expects a position relative to the parent
+     QPoint transientPos = m_window->geometry().topLeft(); // this is absolute
+@@ -414,8 +424,9 @@ void QWaylandXdgSurface::setPopup(QWaylandWindow *parent)
+     positioner->set_anchor(QtWayland::xdg_positioner::anchor_top_left);
+     positioner->set_gravity(QtWayland::xdg_positioner::gravity_bottom_right);
+     positioner->set_size(m_window->geometry().width(), m_window->geometry().height());
+-    m_popup = new Popup(this, parentXdgSurface, positioner);
++    m_popup = new Popup(this, parent, positioner);
+     positioner->destroy();
++
+     delete positioner;
+ }
+ 
+@@ -437,6 +448,23 @@ void QWaylandXdgSurface::setGrabPopup(QWaylandWindow *parent, QWaylandInputDevic
+     }
+     setPopup(parent);
+     m_popup->grab(device, serial);
++
++    // Synthesize Qt enter/leave events for popup
++    if (!parent)
++        return;
++    QWindow *current = QGuiApplication::topLevelAt(QCursor::pos());
++    QWindow *leave = parent->window();
++    if (current != leave)
++        return;
++
++    QWindowSystemInterface::handleLeaveEvent(leave);
++
++    QWindow *enter = nullptr;
++    if (m_popup && m_popup->m_xdgSurface && m_popup->m_xdgSurface->window())
++        enter = m_popup->m_xdgSurface->window()->window();
++
++    if (enter)
++        QWindowSystemInterface::handleEnterEvent(enter, enter->mapFromGlobal(QCursor::pos()), QCursor::pos());
+ }
+ 
+ void QWaylandXdgSurface::xdg_surface_configure(uint32_t serial)
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
+index 96785205..4b518f0a 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
+@@ -131,14 +131,15 @@ private:
+ 
+     class Popup : public QtWayland::xdg_popup {
+     public:
+-        Popup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parent, QtWayland::xdg_positioner *positioner);
++        Popup(QWaylandXdgSurface *xdgSurface, QWaylandWindow *parent, QtWayland::xdg_positioner *positioner);
+         ~Popup() override;
+ 
+         void grab(QWaylandInputDevice *seat, uint serial);
+         void xdg_popup_popup_done() override;
+ 
+         QWaylandXdgSurface *m_xdgSurface = nullptr;
+-        QWaylandXdgSurface *m_parent = nullptr;
++        QWaylandXdgSurface *m_parentXdgSurface = nullptr;
++        QWaylandWindow *m_parent = nullptr;
+         bool m_grabbing = false;
+     };
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
+index 8769d971..da0dd6a7 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
+@@ -69,20 +69,6 @@ QWaylandShellSurface *QWaylandXdgShellIntegration::createShellSurface(QWaylandWi
+     return m_xdgShell->getXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellIntegration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus)
+-{
+-    if (newFocus) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurface *>(newFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowActivated(newFocus);
+-    }
+-    if (oldFocus && qobject_cast<QWaylandXdgSurface *>(oldFocus->shellSurface())) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurface *>(oldFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowDeactivated(oldFocus);
+-    }
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
+index b6caa6c9..2f929f98 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
+@@ -65,7 +65,6 @@ public:
+     QWaylandXdgShellIntegration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShell> m_xdgShell;
+diff --git a/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp b/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
+index 526d0ef4..f50ccf30 100644
+--- a/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
++++ b/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
+@@ -39,7 +39,10 @@
+ 
+ #include "qwaylandinputmethodeventbuilder_p.h"
+ 
++#include <QBrush>
++#include <QGuiApplication>
+ #include <QInputMethod>
++#include <QPalette>
+ #include <QTextCharFormat>
+ 
+ #ifdef QT_BUILD_WAYLANDCOMPOSITOR_LIB
+@@ -81,32 +84,38 @@ void QWaylandInputMethodEventBuilder::addPreeditStyling(uint32_t index, uint32_t
+     QTextCharFormat format;
+ 
+     switch (style) {
+-    case 0:
+-    case 1:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_NONE:
++        break;
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_DEFAULT:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_UNDERLINE:
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-    case 2:
+-    case 3:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_ACTIVE:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_INACTIVE:
+         format.setFontWeight(QFont::Bold);
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-    case 4:
+-        format.setFontUnderline(true);
+-        format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+-        m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_HIGHLIGHT:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_SELECTION:
++        {
++            format.setFontUnderline(true);
++            format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
++            QPalette palette = qApp->palette();
++            format.setBackground(QBrush(palette.color(QPalette::Active, QPalette::Highlight)));
++            format.setForeground(QBrush(palette.color(QPalette::Active, QPalette::HighlightedText)));
++            m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
++        }
+         break;
+-    case 5:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_INCORRECT:
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::WaveUnderline);
+         format.setUnderlineColor(QColor(Qt::red));
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-//    case QtWayland::wl_text_input::preedit_style_selection:
+-//    case QtWayland::wl_text_input::preedit_style_none:
+     default:
+         break;
+     }
+@@ -153,7 +162,7 @@ QInputMethodEvent QWaylandInputMethodEventBuilder::buildPreedit(const QString &t
+ 
+     if (m_preeditCursor < 0) {
+         attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, 0, QVariant()));
+-    } else if (m_preeditCursor > 0) {
++    } else {
+         attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, indexFromWayland(text, m_preeditCursor), 1, QVariant()));
+     }
+ 
+diff --git a/qtwayland/src/shared/qwaylandmimehelper.cpp b/qtwayland/src/shared/qwaylandmimehelper.cpp
+index a5fdd34d..e2fe1928 100644
+--- a/qtwayland/src/shared/qwaylandmimehelper.cpp
++++ b/qtwayland/src/shared/qwaylandmimehelper.cpp
+@@ -60,7 +60,7 @@ QByteArray QWaylandMimeHelper::getByteArray(QMimeData *mimeData, const QString &
+             buf.open(QIODevice::ReadWrite);
+             QByteArray fmt = "BMP";
+             if (mimeType.startsWith(QLatin1String("image/"))) {
+-                QByteArray imgFmt = mimeType.mid(6).toUpper().toLatin1();
++                QByteArray imgFmt = mimeType.mid(6).toLower().toLatin1();
+                 if (QImageWriter::supportedImageFormats().contains(imgFmt))
+                     fmt = imgFmt;
+             }
+@@ -74,7 +74,7 @@ QByteArray QWaylandMimeHelper::getByteArray(QMimeData *mimeData, const QString &
+         QList<QUrl> urls = mimeData->urls();
+         for (int i = 0; i < urls.count(); ++i) {
+             content.append(urls.at(i).toEncoded());
+-            content.append('\n');
++            content.append("\r\n");
+         }
+     } else {
+         content = mimeData->data(mimeType);
+diff --git a/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp b/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
+index 1568b3b9..067410d0 100644
+--- a/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
++++ b/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
+@@ -35,7 +35,7 @@
+ 
+ using namespace MockCompositor;
+ 
+-constexpr int dataDeviceVersion = 1;
++constexpr int dataDeviceVersion = 3;
+ 
+ class DataDeviceCompositor : public DefaultCompositor {
+ public:
+diff --git a/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp b/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
+index 9312c2e5..2ea382f1 100644
+--- a/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
++++ b/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
+@@ -73,6 +73,7 @@ private slots:
+     void multiTouch();
+     void multiTouchUpAndMotionFrame();
+     void tapAndMoveInSameFrame();
++    void cancelTouch();
+ };
+ 
+ void tst_seatv5::bindsToSeat()
+@@ -646,5 +647,34 @@ void tst_seatv5::tapAndMoveInSameFrame()
+     QTRY_COMPARE(window.m_events.last().touchPoints.first().state(), Qt::TouchPointState::TouchPointReleased);
+ }
+ 
++void tst_seatv5::cancelTouch()
++{
++    TouchWindow window;
++    QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
++
++    exec([=] {
++        auto *t = touch();
++        auto *c = client();
++        t->sendDown(xdgToplevel()->surface(), {32, 32}, 1);
++        t->sendFrame(c);
++        t->sendCancel(c);
++        t->sendFrame(c);
++    });
++
++    QTRY_VERIFY(!window.m_events.empty());
++    {
++        auto e = window.m_events.takeFirst();
++        QCOMPARE(e.type, QEvent::TouchBegin);
++        QCOMPARE(e.touchPointStates, Qt::TouchPointPressed);
++        QCOMPARE(e.touchPoints.length(), 1);
++        QCOMPARE(e.touchPoints.first().pos(), QPointF(32-window.frameMargins().left(), 32-window.frameMargins().top()));
++    }
++    {
++        auto e = window.m_events.takeFirst();
++        QCOMPARE(e.type, QEvent::TouchCancel);
++        QCOMPARE(e.touchPoints.length(), 0);
++    }
++}
++
+ QCOMPOSITOR_TEST_MAIN(tst_seatv5)
+ #include "tst_seatv5.moc"
+diff --git a/qtwayland/tests/auto/client/shared/corecompositor.cpp b/qtwayland/tests/auto/client/shared/corecompositor.cpp
+index 5c6c83ba..fa9b7662 100644
+--- a/qtwayland/tests/auto/client/shared/corecompositor.cpp
++++ b/qtwayland/tests/auto/client/shared/corecompositor.cpp
+@@ -27,6 +27,7 @@
+ ****************************************************************************/
+ 
+ #include "corecompositor.h"
++#include <thread>
+ 
+ namespace MockCompositor {
+ 
+diff --git a/qtwayland/tests/auto/client/shared/coreprotocol.cpp b/qtwayland/tests/auto/client/shared/coreprotocol.cpp
+index 0d988521..d1a2e7cb 100644
+--- a/qtwayland/tests/auto/client/shared/coreprotocol.cpp
++++ b/qtwayland/tests/auto/client/shared/coreprotocol.cpp
+@@ -451,6 +451,13 @@ void Touch::sendFrame(wl_client *client)
+         send_frame(r->handle);
+ }
+ 
++void Touch::sendCancel(wl_client *client)
++{
++    const auto touchResources = resourceMap().values(client);
++    for (auto *r : touchResources)
++        send_cancel(r->handle);
++}
++
+ uint Keyboard::sendEnter(Surface *surface)
+ {
+     auto serial = m_seat->m_compositor->nextSerial();
+diff --git a/qtwayland/tests/auto/client/shared/coreprotocol.h b/qtwayland/tests/auto/client/shared/coreprotocol.h
+index a1af137a..210d8ddb 100644
+--- a/qtwayland/tests/auto/client/shared/coreprotocol.h
++++ b/qtwayland/tests/auto/client/shared/coreprotocol.h
+@@ -158,7 +158,7 @@ class WlCompositor : public Global, public QtWaylandServer::wl_compositor
+ {
+     Q_OBJECT
+ public:
+-    explicit WlCompositor(CoreCompositor *compositor, int version = 3)
++    explicit WlCompositor(CoreCompositor *compositor, int version = 4)
+         : QtWaylandServer::wl_compositor(compositor->m_display, version)
+         , m_compositor(compositor)
+     {}
+@@ -364,6 +364,7 @@ public:
+     uint sendUp(wl_client *client, int id);
+     void sendMotion(wl_client *client, const QPointF &position, int id);
+     void sendFrame(wl_client *client);
++    void sendCancel(wl_client *client);
+ 
+     Seat *m_seat = nullptr;
+ };
+diff --git a/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp b/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
+index a415cbf5..b1d3d07d 100644
+--- a/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
++++ b/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
+@@ -342,7 +342,7 @@ Compositor::Compositor(MockCompositor *mockCompositor)
+         exit(EXIT_FAILURE);
+     }
+ 
+-    wl_global_create(m_display, &wl_compositor_interface, 1, this, bindCompositor);
++    wl_global_create(m_display, &wl_compositor_interface, 4, this, bindCompositor);
+ 
+     m_data_device_manager.reset(new DataDeviceManager(this, m_display));
+ 
+diff --git a/qtwayland/tests/auto/client/shared_old/mocksurface.cpp b/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
+index e9df5f90..c3246e4a 100644
+--- a/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
++++ b/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
+@@ -125,6 +125,16 @@ void Surface::surface_damage(Resource *resource,
+     Q_UNUSED(height);
+ }
+ 
++void Surface::surface_damage_buffer(Resource *resource,
++                                    int32_t x, int32_t y, int32_t width, int32_t height)
++{
++    Q_UNUSED(resource);
++    Q_UNUSED(x);
++    Q_UNUSED(y);
++    Q_UNUSED(width);
++    Q_UNUSED(height);
++}
++
+ void Surface::surface_frame(Resource *resource,
+                             uint32_t callback)
+ {
+diff --git a/qtwayland/tests/auto/client/shared_old/mocksurface.h b/qtwayland/tests/auto/client/shared_old/mocksurface.h
+index 949dc23d..d176837e 100644
+--- a/qtwayland/tests/auto/client/shared_old/mocksurface.h
++++ b/qtwayland/tests/auto/client/shared_old/mocksurface.h
+@@ -65,6 +65,8 @@ protected:
+                         struct wl_resource *buffer, int x, int y) override;
+     void surface_damage(Resource *resource,
+                         int32_t x, int32_t y, int32_t width, int32_t height) override;
++    void surface_damage_buffer(Resource *resource,
++                               int32_t x, int32_t y, int32_t width, int32_t height) override;
+     void surface_frame(Resource *resource,
+                        uint32_t callback) override;
+     void surface_commit(Resource *resource) override;
+diff --git a/qtwayland/tests/auto/client/surface/tst_surface.cpp b/qtwayland/tests/auto/client/surface/tst_surface.cpp
+index 95e4e609..60c672ce 100644
+--- a/qtwayland/tests/auto/client/surface/tst_surface.cpp
++++ b/qtwayland/tests/auto/client/surface/tst_surface.cpp
+@@ -129,6 +129,10 @@ void tst_surface::waitForFrameCallbackGl()
+     // Make sure we follow frame callbacks for some frames
+     for (int i = 0; i < 5; ++i) {
+         xdgPingAndWaitForPong(); // Make sure things have happened on the client
++        if (!qEnvironmentVariableIntValue("QT_WAYLAND_DISABLE_WINDOWDECORATION") && i == 0) {
++            QCOMPARE(bufferSpy.count(), 1);
++            bufferSpy.removeFirst();
++        }
+         exec([&] {
+             QVERIFY(bufferSpy.empty()); // Make sure no extra buffers have arrived
+             QVERIFY(!xdgToplevel()->surface()->m_waitingFrameCallbacks.empty());
+diff --git a/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp b/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
+index 2277bbb8..747875b4 100644
+--- a/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
++++ b/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
+@@ -31,6 +31,7 @@
+ #include <QtGui/QOpenGLWindow>
+ #include <QtGui/qpa/qplatformnativeinterface.h>
+ #include <QtWaylandClient/private/wayland-wayland-client-protocol.h>
++#include <QtWaylandClient/private/qwaylandwindow_p.h>
+ 
+ using namespace MockCompositor;
+ 
+@@ -45,6 +46,7 @@ private slots:
+     void configureStates();
+     void popup();
+     void tooltipOnPopup();
++    void tooltipAndSiblingPopup();
+     void switchPopups();
+     void hidePopupParent();
+     void pongs();
+@@ -138,6 +140,7 @@ void tst_xdgshell::configureSize()
+ 
+ void tst_xdgshell::configureStates()
+ {
++    QVERIFY(qputenv("QT_WAYLAND_FRAME_CALLBACK_TIMEOUT", "0"));
+     QRasterWindow window;
+     window.resize(64, 48);
+     window.show();
+@@ -154,9 +157,12 @@ void tst_xdgshell::configureStates()
+     // Toplevel windows don't know their position on xdg-shell
+ //    QCOMPARE(window.frameGeometry().topLeft(), QPoint()); // TODO: this doesn't currently work when window decorations are enabled
+ 
+-//    QEXPECT_FAIL("", "configure has already been acked, we shouldn't have to wait for isActive", Continue);
+-//    QVERIFY(window.isActive());
+-    QTRY_VERIFY(window.isActive()); // Just make sure it eventually get's set correctly
++    // window.windowstate() is driven by keyboard focus, however for decorations we want to follow
++    // XDGShell this is internal to QtWayland so it is queried directly
++    auto waylandWindow = static_cast<QtWaylandClient::QWaylandWindow *>(window.handle());
++    Q_ASSERT(waylandWindow);
++    QTRY_VERIFY(waylandWindow->windowStates().testFlag(
++            Qt::WindowActive)); // Just make sure it eventually get's set correctly
+ 
+     const QSize screenSize(640, 480);
+     const uint maximizedSerial = exec([=] {
+@@ -186,6 +192,7 @@ void tst_xdgshell::configureStates()
+     QCOMPARE(window.windowStates(), Qt::WindowNoState);
+     QCOMPARE(window.frameGeometry().size(), windowedSize);
+ //    QCOMPARE(window.frameGeometry().topLeft(), QPoint()); // TODO: this doesn't currently work when window decorations are enabled
++    QVERIFY(qunsetenv("QT_WAYLAND_FRAME_CALLBACK_TIMEOUT"));
+ }
+ 
+ void tst_xdgshell::popup()
+@@ -340,6 +347,92 @@ void tst_xdgshell::tooltipOnPopup()
+     QCOMPOSITOR_TRY_COMPARE(xdgPopup(0), nullptr);
+ }
+ 
++void tst_xdgshell::tooltipAndSiblingPopup()
++{
++    class ToolTip : public QRasterWindow {
++    public:
++        explicit ToolTip(QWindow *parent) {
++            setTransientParent(parent);
++            setFlags(Qt::ToolTip);
++            resize(100, 100);
++            show();
++        }
++        void mousePressEvent(QMouseEvent *event) override {
++            QRasterWindow::mousePressEvent(event);
++            m_popup = new QRasterWindow;
++            m_popup->setTransientParent(transientParent());
++            m_popup->setFlags(Qt::Popup);
++            m_popup->resize(100, 100);
++            m_popup->show();
++        }
++
++        QRasterWindow *m_popup = nullptr;
++    };
++
++    class Window : public QRasterWindow {
++    public:
++        void mousePressEvent(QMouseEvent *event) override {
++            QRasterWindow::mousePressEvent(event);
++            m_tooltip = new ToolTip(this);
++        }
++        ToolTip *m_tooltip = nullptr;
++    };
++
++    Window window;
++    window.resize(200, 200);
++    window.show();
++
++    QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
++    exec([=] { xdgToplevel()->sendCompleteConfigure(); });
++    QCOMPOSITOR_TRY_VERIFY(xdgToplevel()->m_xdgSurface->m_committedConfigureSerial);
++
++    exec([=] {
++        auto *surface = xdgToplevel()->surface();
++        auto *p = pointer();
++        auto *c = client();
++        p->sendEnter(surface, {100, 100});
++        p->sendFrame(c);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_pressed);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_released);
++        p->sendFrame(c);
++        p->sendLeave(surface);
++        p->sendFrame(c);
++    });
++
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup());
++    exec([=] { xdgPopup()->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup()->m_xdgSurface->m_committedConfigureSerial);
++    QCOMPOSITOR_TRY_VERIFY(!xdgPopup()->m_grabbed);
++
++    exec([=] {
++        auto *surface = xdgPopup()->surface();
++        auto *p = pointer();
++        auto *c = client();
++        p->sendEnter(surface, {100, 100});
++        p->sendFrame(c);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_pressed);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_released);
++        p->sendFrame(c);
++    });
++
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1));
++    exec([=] { xdgPopup(1)->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1)->m_xdgSurface->m_committedConfigureSerial);
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1)->m_grabbed);
++
++    // Close the middle tooltip (it should not close the sibling popup)
++    window.m_tooltip->close();
++
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(1), nullptr);
++    // Verify the remaining xdg surface is a grab popup..
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(0));
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(0)->m_grabbed);
++
++    window.m_tooltip->m_popup->close();
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(1), nullptr);
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(0), nullptr);
++}
++
+ // QTBUG-65680
+ void tst_xdgshell::switchPopups()
+ {
+@@ -505,7 +598,7 @@ void tst_xdgshell::minMaxSize()
+     window.show();
+     QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
+ 
+-    exec([=] { xdgToplevel()->sendCompleteConfigure(); });
++    // we don't roundtrip with our configuration the initial commit should be correct
+ 
+     QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.minSize, QSize(100, 100));
+     QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.maxSize, QSize(1000, 1000));
+Submodule qtwebchannel 618422ee..f8949655:
+diff --git a/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp b/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
+index 536eb5c..898d769 100644
+--- a/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
++++ b/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
+@@ -186,8 +186,6 @@ Q_DECLARE_TYPEINFO(OverloadResolutionCandidate, Q_MOVABLE_TYPE);
+ QMetaObjectPublisher::QMetaObjectPublisher(QWebChannel *webChannel)
+     : QObject(webChannel)
+     , webChannel(webChannel)
+-    , signalHandler(this)
+-    , clientIsIdle(false)
+     , blockUpdates(false)
+     , propertyUpdatesInitialized(false)
+ {
+@@ -301,17 +299,17 @@ QJsonObject QMetaObjectPublisher::classInfoForObject(const QObject *object, QWeb
+     return data;
+ }
+ 
+-void QMetaObjectPublisher::setClientIsIdle(bool isIdle)
++void QMetaObjectPublisher::setClientIsIdle(bool isIdle, QWebChannelAbstractTransport *transport)
+ {
+-    if (clientIsIdle == isIdle) {
+-        return;
+-    }
+-    clientIsIdle = isIdle;
+-    if (!isIdle && timer.isActive()) {
+-        timer.stop();
+-    } else if (isIdle && !timer.isActive()) {
+-        timer.start(PROPERTY_UPDATE_INTERVAL, this);
+-    }
++    transportState[transport].clientIsIdle = isIdle;
++    if (isIdle)
++        sendEnqueuedPropertyUpdates(transport);
++}
++
++bool QMetaObjectPublisher::isClientIdle(QWebChannelAbstractTransport *transport)
++{
++    auto found = transportState.find(transport);
++    return found != transportState.end() && found.value().clientIsIdle;
+ }
+ 
+ QJsonObject QMetaObjectPublisher::initializeClient(QWebChannelAbstractTransport *transport)
+@@ -333,6 +331,7 @@ QJsonObject QMetaObjectPublisher::initializeClient(QWebChannelAbstractTransport
+ 
+ void QMetaObjectPublisher::initializePropertyUpdates(const QObject *const object, const QJsonObject &objectInfo)
+ {
++    auto *signalHandler = signalHandlerFor(object);
+     foreach (const QJsonValue &propertyInfoVar, objectInfo[KEY_PROPERTIES].toArray()) {
+         const QJsonArray &propertyInfo = propertyInfoVar.toArray();
+         if (propertyInfo.size() < 2) {
+@@ -353,19 +352,19 @@ void QMetaObjectPublisher::initializePropertyUpdates(const QObject *const object
+ 
+         // Only connect for a property update once
+         if (connectedProperties.isEmpty()) {
+-            signalHandler.connectTo(object, signalIndex);
++            signalHandler->connectTo(object, signalIndex);
+         }
+ 
+         connectedProperties.insert(propertyIndex);
+     }
+ 
+     // also always connect to destroyed signal
+-    signalHandler.connectTo(object, s_destroyedSignalIndex);
++    signalHandler->connectTo(object, s_destroyedSignalIndex);
+ }
+ 
+ void QMetaObjectPublisher::sendPendingPropertyUpdates()
+ {
+-    if (blockUpdates || !clientIsIdle || pendingPropertyUpdates.isEmpty()) {
++    if (blockUpdates) {
+         return;
+     }
+ 
+@@ -415,18 +414,19 @@ void QMetaObjectPublisher::sendPendingPropertyUpdates()
+ 
+     // data does not contain specific updates
+     if (!data.isEmpty()) {
+-        setClientIsIdle(false);
+-
+         message[KEY_DATA] = data;
+-        broadcastMessage(message);
++        enqueueBroadcastMessage(message);
+     }
+ 
+     // send every property update which is not supposed to be broadcasted
+     const QHash<QWebChannelAbstractTransport*, QJsonArray>::const_iterator suend = specificUpdates.constEnd();
+     for (QHash<QWebChannelAbstractTransport*, QJsonArray>::const_iterator it = specificUpdates.constBegin(); it != suend; ++it) {
+         message[KEY_DATA] = it.value();
+-        it.key()->sendMessage(message);
++        enqueueMessage(message, it.key());
+     }
++
++    for (auto state = transportState.begin(); state != transportState.end(); ++state)
++        sendEnqueuedPropertyUpdates(state.key());
+ }
+ 
+ QVariant QMetaObjectPublisher::invokeMethod(QObject *const object, const QMetaMethod &method,
+@@ -572,7 +572,7 @@ void QMetaObjectPublisher::signalEmitted(const QObject *object, const int signal
+         }
+     } else {
+         pendingPropertyUpdates[object][signalIndex] = arguments;
+-        if (clientIsIdle && !blockUpdates && !timer.isActive()) {
++        if (!blockUpdates && !timer.isActive()) {
+             timer.start(PROPERTY_UPDATE_INTERVAL, this);
+         }
+     }
+@@ -590,7 +590,7 @@ void QMetaObjectPublisher::objectDestroyed(const QObject *object)
+     // only remove from handler when we initialized the property updates
+     // cf: https://bugreports.qt.io/browse/QTBUG-60250
+     if (propertyUpdatesInitialized) {
+-        signalHandler.remove(object);
++        signalHandlerFor(object)->remove(object);
+         signalToPropertyMap.remove(object);
+     }
+     pendingPropertyUpdates.remove(object);
+@@ -852,6 +852,52 @@ void QMetaObjectPublisher::broadcastMessage(const QJsonObject &message) const
+     }
+ }
+ 
++void QMetaObjectPublisher::enqueueBroadcastMessage(const QJsonObject &message)
++{
++    if (webChannel->d_func()->transports.isEmpty()) {
++        qWarning("QWebChannel is not connected to any transports, cannot send message: %s",
++                 QJsonDocument(message).toJson().constData());
++        return;
++    }
++
++    for (auto *transport : webChannel->d_func()->transports) {
++        auto &state = transportState[transport];
++        state.queuedMessages.append(message);
++    }
++}
++
++void QMetaObjectPublisher::enqueueMessage(const QJsonObject &message,
++                                          QWebChannelAbstractTransport *transport)
++{
++    auto &state = transportState[transport];
++    state.queuedMessages.append(message);
++}
++
++void QMetaObjectPublisher::sendEnqueuedPropertyUpdates(QWebChannelAbstractTransport *transport)
++{
++    auto found = transportState.find(transport);
++    if (found != transportState.end() && found.value().clientIsIdle
++        && !found.value().queuedMessages.isEmpty()) {
++
++        // If the client is connected with an in-process transport, it can
++        // happen that a message triggers a subsequent property change. In
++        // that case, we need to ensure that the queued messages have already
++        // been cleared; otherwise the recursive call will send everythig again.
++        // Case in point: The qmlwebchannel tests fail if we don't clear the
++        // queued messages before sending them out.
++        // For that same reason set the client to "busy" (aka non-idle) just
++        // right before sending out the messages; otherwise a potential
++        // "Idle" type message will not correctly restore the Idle state.
++        const auto messages = std::move(found.value().queuedMessages);
++        Q_ASSERT(found.value().queuedMessages.isEmpty());
++        found.value().clientIsIdle = false;
++
++        for (const auto &message : messages) {
++            transport->sendMessage(message);
++        }
++    }
++}
++
+ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannelAbstractTransport *transport)
+ {
+     if (!webChannel->d_func()->transports.contains(transport)) {
+@@ -866,7 +912,7 @@ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannel
+ 
+     const MessageType type = toType(message.value(KEY_TYPE));
+     if (type == TypeIdle) {
+-        setClientIsIdle(true);
++        setClientIsIdle(true, transport);
+     } else if (type == TypeInit) {
+         if (!message.contains(KEY_ID)) {
+             qWarning("JSON message object is missing the id property: %s",
+@@ -913,9 +959,9 @@ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannel
+                 return;
+             transport->sendMessage(createResponse(message.value(KEY_ID), wrapResult(result, transport)));
+         } else if (type == TypeConnectToSignal) {
+-            signalHandler.connectTo(object, message.value(KEY_SIGNAL).toInt(-1));
++            signalHandlerFor(object)->connectTo(object, message.value(KEY_SIGNAL).toInt(-1));
+         } else if (type == TypeDisconnectFromSignal) {
+-            signalHandler.disconnectFrom(object, message.value(KEY_SIGNAL).toInt(-1));
++            signalHandlerFor(object)->disconnectFrom(object, message.value(KEY_SIGNAL).toInt(-1));
+         } else if (type == TypeSetProperty) {
+             setProperty(object, message.value(KEY_PROPERTY).toInt(-1),
+                         message.value(KEY_VALUE));
+@@ -931,6 +977,7 @@ void QMetaObjectPublisher::setBlockUpdates(bool block)
+     blockUpdates = block;
+ 
+     if (!blockUpdates) {
++        timer.start(PROPERTY_UPDATE_INTERVAL, this);
+         sendPendingPropertyUpdates();
+     } else if (timer.isActive()) {
+         timer.stop();
+@@ -948,4 +995,15 @@ void QMetaObjectPublisher::timerEvent(QTimerEvent *event)
+     }
+ }
+ 
++SignalHandler<QMetaObjectPublisher> *QMetaObjectPublisher::signalHandlerFor(const QObject *object)
++{
++    auto thread = object->thread();
++    auto it = signalHandlers.find(thread);
++    if (it == signalHandlers.end()) {
++        it = signalHandlers.emplace(thread, this).first;
++        it->second.moveToThread(thread);
++    }
++    return &it->second;
++}
++
+ QT_END_NAMESPACE
+diff --git a/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h b/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
+index bbd9875..4713ef1 100644
+--- a/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
++++ b/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
+@@ -59,6 +59,9 @@
+ #include <QBasicTimer>
+ #include <QPointer>
+ #include <QJsonObject>
++#include <QQueue>
++
++#include <unordered_map>
+ 
+ #include "qwebchannelglobal.h"
+ 
+@@ -109,17 +112,36 @@ public:
+      */
+     void broadcastMessage(const QJsonObject &message) const;
+ 
++    /**
++     * Enqueue the given @p message to all known transports.
++     */
++    void enqueueBroadcastMessage(const QJsonObject &message);
++
++    /**
++     * Enqueue the given @p message to @p transport.
++     */
++    void enqueueMessage(const QJsonObject &message, QWebChannelAbstractTransport *transport);
++
++    /**
++     * If client for given @p transport is idle, send queued messaged to @p transport and then mark
++     * the client as not idle.
++     */
++    void sendEnqueuedPropertyUpdates(QWebChannelAbstractTransport *transport);
++
+     /**
+      * Serialize the QMetaObject of @p object and return it in JSON form.
+      */
+     QJsonObject classInfoForObject(const QObject *object, QWebChannelAbstractTransport *transport);
+ 
+     /**
+-     * Set the client to idle or busy, based on the value of @p isIdle.
+-     *
+-     * When the value changed, start/stop the property update timer accordingly.
++     * Set the client to idle or busy for a single @p transport, based on the value of @p isIdle.
++     */
++    void setClientIsIdle(bool isIdle, QWebChannelAbstractTransport *transport);
++
++    /**
++     * Check that client is idle for @p transport.
+      */
+-    void setClientIsIdle(bool isIdle);
++    bool isClientIdle(QWebChannelAbstractTransport *transport);
+ 
+     /**
+      * Initialize clients by sending them the class information of the registered objects.
+@@ -272,10 +294,18 @@ private:
+     friend class TestWebChannel;
+ 
+     QWebChannel *webChannel;
+-    SignalHandler<QMetaObjectPublisher> signalHandler;
++    std::unordered_map<const QThread*, SignalHandler<QMetaObjectPublisher>> signalHandlers;
++    SignalHandler<QMetaObjectPublisher> *signalHandlerFor(const QObject *object);
+ 
+-    // true when the client is idle, false otherwise
+-    bool clientIsIdle;
++    struct TransportState
++    {
++        TransportState() : clientIsIdle(false) { }
++        // true when the client is idle, false otherwise
++        bool clientIsIdle;
++        // messages to send
++        QQueue<QJsonObject> queuedMessages;
++    };
++    QHash<QWebChannelAbstractTransport *, TransportState> transportState;
+ 
+     // true when no property updates should be sent, false otherwise
+     bool blockUpdates;
+diff --git a/qtwebchannel/src/webchannel/signalhandler_p.h b/qtwebchannel/src/webchannel/signalhandler_p.h
+index 27afadb..d77373c 100644
+--- a/qtwebchannel/src/webchannel/signalhandler_p.h
++++ b/qtwebchannel/src/webchannel/signalhandler_p.h
+@@ -56,6 +56,7 @@
+ #include <QVector>
+ #include <QMetaMethod>
+ #include <QDebug>
++#include <QThread>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -71,6 +72,7 @@ static const int s_destroyedSignalIndex = QObject::staticMetaObject.indexOfMetho
+ template<class Receiver>
+ class SignalHandler : public QObject
+ {
++    Q_DISABLE_COPY(SignalHandler)
+ public:
+     SignalHandler(Receiver *receiver, QObject *parent = 0);
+ 
+@@ -268,6 +270,7 @@ int SignalHandler<Receiver>::qt_metacall(QMetaObject::Call call, int methodId, v
+     if (call == QMetaObject::InvokeMetaMethod) {
+         const QObject *object = sender();
+         Q_ASSERT(object);
++        Q_ASSERT(QThread::currentThread() == object->thread());
+         Q_ASSERT(senderSignalIndex() == methodId);
+         Q_ASSERT(m_connectionsCounter.contains(object));
+         Q_ASSERT(m_connectionsCounter.value(object).contains(methodId));
+diff --git a/qtwebchannel/tests/auto/qml/testwebchannel.cpp b/qtwebchannel/tests/auto/qml/testwebchannel.cpp
+index 9891687..3ca81c2 100644
+--- a/qtwebchannel/tests/auto/qml/testwebchannel.cpp
++++ b/qtwebchannel/tests/auto/qml/testwebchannel.cpp
+@@ -46,7 +46,11 @@ TestWebChannel::~TestWebChannel()
+ 
+ bool TestWebChannel::clientIsIdle() const
+ {
+-    return QWebChannel::d_func()->publisher->clientIsIdle;
++    for (auto *transport : QWebChannel::d_func()->transports) {
++        if (QWebChannel::d_func()->publisher->isClientIdle(transport))
++            return true;
++    }
++    return false;
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp b/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
+index 181da9e..37f989a 100644
+--- a/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
++++ b/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
+@@ -785,7 +785,7 @@ void TestWebChannel::testTransportWrapObjectProperties()
+     DummyTransport *dummyTransport = new DummyTransport(this);
+     channel.connectTo(dummyTransport);
+     channel.d_func()->publisher->initializeClient(dummyTransport);
+-    channel.d_func()->publisher->setClientIsIdle(true);
++    channel.d_func()->publisher->setClientIsIdle(true, dummyTransport);
+ 
+     QCOMPARE(channel.d_func()->publisher->transportedWrappedObjects.size(), 0);
+ 
+@@ -943,8 +943,6 @@ void TestWebChannel::testInfiniteRecursion()
+ 
+ void TestWebChannel::testAsyncObject()
+ {
+-    QSKIP("This test is broken. See QTBUG-80729");
+-
+     QWebChannel channel;
+     channel.connectTo(m_dummyTransport);
+ 
+@@ -990,6 +988,50 @@ void TestWebChannel::testAsyncObject()
+     thread.wait();
+ }
+ 
++void TestWebChannel::testPropertyMultipleTransports()
++{
++    DummyTransport transport1;
++    DummyTransport transport2;
++
++    QWebChannel channel;
++    QMetaObjectPublisher *publisher = channel.d_func()->publisher;
++
++    TestObject testObj;
++    testObj.setObjectName("testObject");
++    channel.registerObject(testObj.objectName(), &testObj);
++    channel.connectTo(&transport1);
++    channel.connectTo(&transport2);
++
++    testObj.setProp("Hello");
++
++    publisher->initializeClient(&transport1);
++    publisher->initializeClient(&transport2);
++    publisher->setClientIsIdle(true, &transport1);
++    QCOMPARE(publisher->isClientIdle(&transport1), true);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++    QVERIFY(transport1.messagesSent().isEmpty());
++    QVERIFY(transport2.messagesSent().isEmpty());
++
++    testObj.setProp("World");
++    QTRY_COMPARE_WITH_TIMEOUT(transport1.messagesSent().size(), 1u, 2000);
++    QCOMPARE(transport2.messagesSent().size(), 0u);
++    publisher->setClientIsIdle(true, &transport2);
++    QTRY_COMPARE_WITH_TIMEOUT(transport2.messagesSent().size(), 1u, 2000);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++
++    testObj.setProp("!!!");
++    publisher->setClientIsIdle(true, &transport2);
++    QCOMPARE(publisher->isClientIdle(&transport2), true);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QTRY_COMPARE_WITH_TIMEOUT(transport2.messagesSent().size(), 2u, 2000);
++    QCOMPARE(transport1.messagesSent().size(), 1u);
++    publisher->setClientIsIdle(true, &transport1);
++    QTRY_COMPARE_WITH_TIMEOUT(transport1.messagesSent().size(), 2u, 2000);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++}
++
+ class FunctionWrapper : public QObject
+ {
+     Q_OBJECT
+@@ -1082,7 +1124,7 @@ void TestWebChannel::benchInitializeClients()
+ 
+         publisher->propertyUpdatesInitialized = false;
+         publisher->signalToPropertyMap.clear();
+-        publisher->signalHandler.clear();
++        publisher->signalHandlers.clear();
+     }
+ }
+ 
+@@ -1107,7 +1149,7 @@ void TestWebChannel::benchPropertyUpdates()
+             obj->change();
+         }
+ 
+-        channel.d_func()->publisher->clientIsIdle = true;
++        channel.d_func()->publisher->setClientIsIdle(true, m_dummyTransport);
+         channel.d_func()->publisher->sendPendingPropertyUpdates();
+     }
+ }
+diff --git a/qtwebchannel/tests/auto/webchannel/tst_webchannel.h b/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
+index eae21f4..dd4e690 100644
+--- a/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
++++ b/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
+@@ -348,6 +348,7 @@ private slots:
+     void testJsonToVariant();
+     void testInfiniteRecursion();
+     void testAsyncObject();
++    void testPropertyMultipleTransports();
+     void testDeletionDuringMethodInvocation_data();
+     void testDeletionDuringMethodInvocation();
+ 
+Submodule qtwebengine f328054d...38e0df6c (commits not present)
+Submodule qtwebsockets 65850954..63fb8da1:
+diff --git a/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp b/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
+index 2affdd5..95f1194 100644
+--- a/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
++++ b/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
+@@ -273,6 +273,7 @@ void QWebSocketDataProcessor::clear()
+     if (!m_pConverterState)
+         m_pConverterState = new QTextCodec::ConverterState(QTextCodec::ConvertInvalidToNull |
+                                                            QTextCodec::IgnoreHeader);
++    frame.clear();
+ }
+ 
+ /*!
+diff --git a/qtwebsockets/src/websockets/qwebsocketprotocol.cpp b/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
+index df87a93..d0465f1 100644
+--- a/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
++++ b/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
+@@ -210,7 +210,7 @@ void QWebSocketProtocol::mask(char *payload, quint64 size, quint32 maskingKey)
+                             quint8((maskingKey & 0x0000FF00u) >> 8),
+                             quint8((maskingKey & 0x000000FFu))
+                           };
+-    int i = 0;
++    quint64 i = 0;
+     while (size-- > 0)
+         *payload++ ^= mask[i++ % 4];
+ }
diff --git a/srcpkgs/qt5/template b/srcpkgs/qt5/template
index e0463e1c9198..8e091091b878 100644
--- a/srcpkgs/qt5/template
+++ b/srcpkgs/qt5/template
@@ -2,7 +2,9 @@
 #
 # revbump libqtxdg after bumping patch version
 pkgname=qt5
-version=5.15.7+20221119
+version=5.15.8
+revision=1
+build_style=meta
 # commit f8c9fb304bc3e53b3aa07f962cd74e9160decccc
 # base repo: https://invent.kde.org/qt/qt/qt5
 revision=4
@@ -29,8 +31,9 @@ homepage="https://qt.io/"
 # tarball is generated with `git archive-all qt5-$version.tar.gz`
 # to keep the size smaller qtwebengine, qtwebview, qtdocgallery, qtactiveqt and qtpim
 # can be marked with the export-ignore attribute
-distfiles="https://void.johnnynator.dev/distfiles/qt5-${version}.tar.gz"
-checksum=9d57af471c78029a362276b7c99108ea009f511bb9ba6ff6cb884f6ddd255e9f
+#distfiles="https://void.johnnynator.dev/distfiles/qt5-${version}.tar.gz"
+distfiles="https://download.qt.io/archive/qt/5.15/${version}/single/qt-everywhere-opensource-src-${version}.tar.xz"
+checksum=776a9302c336671f9406a53bd30b8e36f825742b2ec44a57c08217bff0fa86b9
 python_version=2 #unverified
 replaces="qt5-doc<5.6.0 qt5-quick1<5.6.0 qt5-quick1-devel<5.6.0 qt5-webkit<5.6.0 qt5-webkit-devel<5.6.0
  qt5-enginio<5.7.1 qt5-enginio-devel<5.7.1 qt5-plugin-gtk<5.7.1 qt5-canvas3d<5.13.0"
@@ -248,7 +251,6 @@ do_configure() {
 	# opts+=" -v"
 	opts+=" -skip qtwebengine"
 	opts+=" -skip qtwebview"
-	opts+=" -skip qtdocgallery"
 	opts+=" -skip qtpim"
 	opts+=" -skip qtsystems"
 	opts+=" -skip qtspeech"

From ce617910577c6b66fca989241788c506eca03516 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 078/140] qt6-multimedia: revbump for ffmpeg-6.0

---
 srcpkgs/qt6-multimedia/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-multimedia/template b/srcpkgs/qt6-multimedia/template
index d89e7d54eb5a..aae15e57ca7b 100644
--- a/srcpkgs/qt6-multimedia/template
+++ b/srcpkgs/qt6-multimedia/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-multimedia'
 pkgname=qt6-multimedia
 version=6.4.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DQT_FEATURE_gstreamer=ON"
 hostmakedepends="perl qt6-declarative-host-tools pkg-config qt6-shadertools"

From c0f9eb39be84b536962e3424d343c161d6419e09 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 079/140] qtav: revbump for ffmpeg4-4.4.3

---
 srcpkgs/qtav/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtav/template b/srcpkgs/qtav/template
index 34c30b2c0c78..2d00ad104355 100644
--- a/srcpkgs/qtav/template
+++ b/srcpkgs/qtav/template
@@ -1,10 +1,10 @@
 # Template file for 'qtav'
 pkgname=qtav
 version=1.13.0
-revision=1
+revision=2
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel libass-devel libopenal-devel
+makedepends="ffmpeg4-devel libass-devel libopenal-devel
  libva-glx-devel libXv-devel pulseaudio-devel
  qt5-declarative-devel qt5-svg-devel
  qt5-quickcontrols"

From 3819de5bdbde44ec66fc7f5b2ff8540c5a18f5c3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 080/140] qtox: revbump for ffmpeg-6.0

---
 srcpkgs/qtox/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qtox/template b/srcpkgs/qtox/template
index 16019d7eaec9..5cea0b11b697 100644
--- a/srcpkgs/qtox/template
+++ b/srcpkgs/qtox/template
@@ -1,7 +1,7 @@
 # Template file for 'qtox'
 pkgname=qtox
 version=1.17.6
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DUPDATE_CHECK=OFF
  -DGIT_DESCRIBE=${version}

From 6aafd39859ee95435e81acb0e26a5b319680ad2c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 081/140] retroarch: revbump for ffmpeg-6.0

---
 srcpkgs/retroarch/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroarch/template b/srcpkgs/retroarch/template
index 240d3df9db00..6d0b16ae2598 100644
--- a/srcpkgs/retroarch/template
+++ b/srcpkgs/retroarch/template
@@ -1,7 +1,7 @@
 # Template file for 'retroarch'
 pkgname=retroarch
 version=1.14.0
-revision=1
+revision=2
 build_style=configure
 configure_args="--prefix=/usr --sysconfdir=/etc --enable-networking
  --enable-udev --disable-builtinflac --disable-builtinglslang

From 455aca9838d8cbe116f0fcfb92b4a77e8039b2b7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 082/140] scrcpy: revbump for ffmpeg-6.0

---
 srcpkgs/scrcpy/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/scrcpy/template b/srcpkgs/scrcpy/template
index ee6e698e387f..8ada5ca4323f 100644
--- a/srcpkgs/scrcpy/template
+++ b/srcpkgs/scrcpy/template
@@ -1,7 +1,7 @@
 # Template file for 'scrcpy'
 pkgname=scrcpy
 version=2.0
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcompile_server=false
  -Dprebuilt_server=/usr/share/scrcpy/scrcpy-server-v${version}"

From a1656359e90b966ef4b0ad4ea1c33a06f06f9fb0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 083/140] spek-alternative: revbump for ffmpeg4-4.4.3

---
 srcpkgs/spek-alternative/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/spek-alternative/template b/srcpkgs/spek-alternative/template
index d65086b8f008..05246f1b8d0c 100644
--- a/srcpkgs/spek-alternative/template
+++ b/srcpkgs/spek-alternative/template
@@ -1,11 +1,11 @@
 # Template file for 'spek-alternative'
 pkgname=spek-alternative
 version=0.8.2.3
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake gettext-devel intltool libtool pkg-config wxWidgets-common"
-makedepends="ffmpeg-devel wxWidgets-gtk3-devel"
-depends="ffmpeg"
+makedepends="ffmpeg4-devel wxWidgets-gtk3-devel"
+depends="ffmpeg4"
 short_desc="Acoustic spectrum analyser"
 maintainer="Kartik Singh <kartik.ynwa@gmail.com>"
 license="GPL-3.0-or-later"

From 20686d9f0451bdb1d3c611a4b5ff6d9c97c1824f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 084/140] ssr: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ssr/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/ssr/template b/srcpkgs/ssr/template
index b055b9ec0774..3448ca110eb0 100644
--- a/srcpkgs/ssr/template
+++ b/srcpkgs/ssr/template
@@ -1,11 +1,11 @@
 # Template file for 'ssr'
 pkgname=ssr
 version=0.4.4
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_QT5=ON"
 hostmakedepends="pkg-config"
-makedepends="alsa-lib-devel ffmpeg-devel glu-devel jack-devel pulseaudio-devel
+makedepends="alsa-lib-devel ffmpeg4-devel glu-devel jack-devel pulseaudio-devel
  qt5-tools-devel qt5-x11extras-devel libXinerama-devel v4l-utils-devel"
 depends="desktop-file-utils hicolor-icon-theme"
 short_desc="Simple Screen Recorder for programs and games"

From 0e7b81053e7bff355b75d50fe25b705a9228f138 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 085/140] sumo: revbump for ffmpeg-6.0

---
 srcpkgs/sumo/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/sumo/template b/srcpkgs/sumo/template
index 0f9b9ec815f5..a3fe134aa5ac 100644
--- a/srcpkgs/sumo/template
+++ b/srcpkgs/sumo/template
@@ -1,7 +1,7 @@
 # Template file for 'sumo'
 pkgname=sumo
 version=1.12.0
-revision=5
+revision=6
 build_style=cmake
 hostmakedepends="libgdal-tools pkg-config swig python3-setuptools"
 makedepends="python3-devel ffmpeg-devel fox-devel gl2ps-devel libgdal-devel

From b889d24a0564806429d75552d66daadc49712054 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 086/140] synfig: revbump for ffmpeg4-4.4.3

---
 srcpkgs/synfig/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/synfig/template b/srcpkgs/synfig/template
index 5f5f5bb3f4b2..9b4d9adf09c6 100644
--- a/srcpkgs/synfig/template
+++ b/srcpkgs/synfig/template
@@ -7,7 +7,7 @@ build_style=gnu-configure
 configure_args="--with-boost-libdir=${XBPS_CROSS_BASE}/usr/lib"
 hostmakedepends="boost-build ImageMagick pkg-config intltool"
 makedepends="ETL gettext-devel libxml++-devel mlt-devel libmagick-devel
- libmng-devel boost-build boost-devel libopenexr-devel ffmpeg-devel"
+ libmng-devel boost-build boost-devel libopenexr-devel ffmpeg4-devel"
 depends="ImageMagick"
 short_desc="CLI 2D vector and timeline-based animation software"
 maintainer="Orphaned <orphan@voidlinux.org>"

From 8de3f9a8db7b4a03d003bb0db520fa4f07c96b8b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 087/140] telegram-desktop: revbump for ffmpeg-6.0

---
 srcpkgs/telegram-desktop/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/telegram-desktop/template b/srcpkgs/telegram-desktop/template
index aae9f3135100..7943b36f0b8a 100644
--- a/srcpkgs/telegram-desktop/template
+++ b/srcpkgs/telegram-desktop/template
@@ -1,7 +1,7 @@
 # Template file for 'telegram-desktop'
 pkgname=telegram-desktop
 version=4.6.5
-revision=1
+revision=2
 build_style=cmake
 build_helper="qemu"
 configure_args="-DTDESKTOP_API_ID=209235

From b0b5d3041e592bd2f8cf84496a40dcf672e1a25b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 088/140] tg_owt: revbump for ffmpeg-6.0

---
 srcpkgs/tg_owt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tg_owt/template b/srcpkgs/tg_owt/template
index 97d195ddb34a..551614b24956 100644
--- a/srcpkgs/tg_owt/template
+++ b/srcpkgs/tg_owt/template
@@ -1,7 +1,7 @@
 # Template file for 'tg_owt'
 pkgname=tg_owt
 version=0.0.0.20230107
-revision=1
+revision=2
 _commit=5098730b9eb6173f0b52068fe2555b7c1015123a
 _libyuv_commit=00950840d1c9bcbb3eb6ebc5aac5793e71166c8b
 _abseil_commit=8c0b94e793a66495e0b1f34a5eb26bd7dc672db0

From 8093adaf1fd9075f760fbf840188a2afcbab41e1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 089/140] timg: revbump for ffmpeg-6.0

---
 srcpkgs/timg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/timg/template b/srcpkgs/timg/template
index 91f1516b2597..334443d3f9bb 100644
--- a/srcpkgs/timg/template
+++ b/srcpkgs/timg/template
@@ -1,7 +1,7 @@
 # Template file for 'timg'
 pkgname=timg
 version=1.4.4
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_OPENSLIDE_SUPPORT=off -Wno-dev"
 hostmakedepends="pkg-config git"

From cfe7604cd0adc6983408c963dd4a377a2b72238a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 090/140] tvheadend: revbump for ffmpeg4-4.4.3

---
 srcpkgs/tvheadend/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/tvheadend/template b/srcpkgs/tvheadend/template
index e6b16d7ccf3b..46b52b6fb7f9 100644
--- a/srcpkgs/tvheadend/template
+++ b/srcpkgs/tvheadend/template
@@ -1,14 +1,14 @@
 # Template file for 'tvheadend'
 pkgname=tvheadend
 version=4.2.8
-revision=6
+revision=7
 build_style=gnu-configure
 configure_args="--enable-dvbscan --disable-ffmpeg_static
 --disable-hdhomerun_static --disable-bintray_cache --disable-libx264_static
 --disable-libx265_static --disable-libvpx_static --disable-libtheora_static
 --disable-libvorbis_static --disable-libfdkaac_static"
 hostmakedepends="gettext pkg-config python git which"
-makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg-devel"
+makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg4-devel"
 short_desc="TV streaming server"
 maintainer="lemmi <lemmi@nerd2nerd.org>"
 license="GPL-3.0-only"

From 98f93f855182352cf8660e23f0b6100403534bda Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 091/140] unpaper: update to 7.0.0.

---
 srcpkgs/unpaper/template | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/srcpkgs/unpaper/template b/srcpkgs/unpaper/template
index 38ed47a58401..1ff910e722af 100644
--- a/srcpkgs/unpaper/template
+++ b/srcpkgs/unpaper/template
@@ -1,13 +1,13 @@
 # Template file for 'unpaper'
 pkgname=unpaper
-version=6.1
-revision=3
-build_style=gnu-configure
+version=7.0.0
+revision=1
+build_style=meson
+hostmakedepends="pkg-config meson libxslt"
+makedepends="ffmpeg-devel python3-Sphinx"
+short_desc="Post-processing tool for scanned sheets of paper"
 maintainer="Orphaned <orphan@voidlinux.org>"
-hostmakedepends="pkg-config libxslt"
-makedepends="ffmpeg-devel"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://www.flameeyes.eu/projects/unpaper"
-short_desc="A post-processing tool for scanned sheets of paper"
 distfiles="https://www.flameeyes.eu/files/${pkgname}-${version}.tar.xz"
-checksum=237c84f5da544b3f7709827f9f12c37c346cdf029b1128fb4633f9bafa5cb930
+checksum=2575fbbf26c22719d1cb882b59602c9900c7f747118ac130883f63419be46a80

From a234462b323497066076bb43b6dbaaf1f0f6b590 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 092/140] vba-m: revbump for ffmpeg-6.0

---
 srcpkgs/vba-m/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vba-m/template b/srcpkgs/vba-m/template
index ba153e0b58ca..aa6093645e97 100644
--- a/srcpkgs/vba-m/template
+++ b/srcpkgs/vba-m/template
@@ -2,7 +2,7 @@
 pkgname=vba-m
 reverts=1292_2
 version=2.1.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_GTK=TRUE -DENABLE_FFMPEG=TRUE -DENABLE_LINK=TRUE -DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="gettext pkg-config unzip zip yasm wxWidgets-gtk3-devel"

From 6ff9bfcd0dd43d5aaa1cfe74ffd5d998a264a09c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 093/140] vice: revbump for ffmpeg4-4.4.3

---
 srcpkgs/vice/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/vice/template b/srcpkgs/vice/template
index 0924767cfcfb..5981e45149d0 100644
--- a/srcpkgs/vice/template
+++ b/srcpkgs/vice/template
@@ -1,7 +1,7 @@
 # Template file for 'vice'
 pkgname=vice
 version=3.5
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="
 	$(vopt_enable sdl2 sdlui2)
@@ -28,7 +28,7 @@ makedepends="
 	$(vopt_if gtk3 gtk+3-devel)
 	$(vopt_if gtk3 pulseaudio-devel)
 	$(vopt_if gtk3 pango-devel)
-	$(vopt_if ffmpeg ffmpeg-devel)"
+	$(vopt_if ffmpeg ffmpeg4-devel)"
 short_desc="Emulator for C64, C128, CBM-II, PET, VIC20, Plus4 and C16"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"

From 308e19f02d1e1857112ab17e20990396f9b5c477 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 094/140] waypipe: revbump for ffmpeg-6.0

---
 srcpkgs/waypipe/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waypipe/template b/srcpkgs/waypipe/template
index 5c4161900060..1a46fe27f7d8 100644
--- a/srcpkgs/waypipe/template
+++ b/srcpkgs/waypipe/template
@@ -1,7 +1,7 @@
 # Template file for 'waypipe'
 pkgname=waypipe
 version=0.8.4
-revision=1
+revision=2
 build_style=meson
 # lto is off because it causes linking errors in armv6l and armv7l (due to NEON)
 configure_args="-Dwerror=false -Dwith_dmabuf=enabled -Dwith_lz4=enabled

From 3916eaa1fb7a6443a01f2203538833bf93ffce78 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 095/140] wf-recorder: revbump for ffmpeg-6.0

---
 srcpkgs/wf-recorder/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/wf-recorder/template b/srcpkgs/wf-recorder/template
index e278eb001600..5d014a5f28af 100644
--- a/srcpkgs/wf-recorder/template
+++ b/srcpkgs/wf-recorder/template
@@ -1,7 +1,7 @@
 # Template file for 'wf-recorder'
 pkgname=wf-recorder
 version=0.3.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config scdoc wayland-devel"
 makedepends="wayland-protocols wayland-devel ffmpeg-devel x264-devel

From 0f774085616f9dc60ad8cd32d27c52773ba3a251 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 096/140] xpra: revbump for ffmpeg-6.0

---
 srcpkgs/xpra/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xpra/template b/srcpkgs/xpra/template
index 38f83283b1e5..b6e01ff0a813 100644
--- a/srcpkgs/xpra/template
+++ b/srcpkgs/xpra/template
@@ -1,7 +1,7 @@
 # Template file for 'xpra'
 pkgname=xpra
 version=4.4.4
-revision=1
+revision=2
 build_style=python3-module
 make_build_args="--without-cuda_kernels --without-cuda_rebuild"
 make_install_args="$(vopt_with docs) ${make_build_args}"

From 9637df2fd231b7e7a270e2eff6dd5f07aa5b0364 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:07:40 -0400
Subject: [PATCH 097/140] nv-codec-headers: update to 12.0.16.0

---
 srcpkgs/nv-codec-headers/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/nv-codec-headers/template b/srcpkgs/nv-codec-headers/template
index 3d422a61e489..251e057f826f 100644
--- a/srcpkgs/nv-codec-headers/template
+++ b/srcpkgs/nv-codec-headers/template
@@ -1,6 +1,6 @@
 # Template file for 'nv-codec-headers'
 pkgname=nv-codec-headers
-version=11.1.5.1
+version=12.0.16.0
 revision=1
 build_style=gnu-makefile
 short_desc="FFmpeg version of headers required to interface with Nvidias codec APIs"
@@ -8,7 +8,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="MIT"
 homepage="http://git.videolan.org/?p=ffmpeg/nv-codec-headers.git"
 distfiles="https://github.com/FFmpeg/nv-codec-headers/archive/n${version}.tar.gz"
-checksum=d095fbd56aa93772471a323be0ebe65504a0f43f06c76a30b6d25da77b06ae9c
+checksum=2a1533b65f55f9da52956faf0627ed3b74868ac0c7f269990edd21369113b48f
 
 post_install() {
 	sed -n '4,25p' include/ffnvcodec/nvEncodeAPI.h > LICENSE

From 66259eae9d0e29471066f2158c45eacabb70dbef Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:08:40 -0400
Subject: [PATCH 098/140] openimagedenoise: revbump for ffmpeg-6.0

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index db5ccdb055cc..cb90045afb63 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,7 +1,7 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
 version=1.4.3
-revision=1
+revision=2
 archs="x86_64*"
 build_style=cmake
 hostmakedepends="ispc python3"

From a88b42ee425030fde19e4e6bda4c0f210cf3de7c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 19 Mar 2023 10:58:01 -0400
Subject: [PATCH 099/140] gst-libav: update to 1.22.1

---
 srcpkgs/gst-libav/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index f082bd211c65..a2c97bfbcdb9 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
-version=1.20.3
-revision=2
+version=1.22.1
+revision=1
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"
@@ -11,7 +11,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.0-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname}/${pkgname}-${version}.tar.xz"
-checksum=3fedd10560fcdfaa1b6462cbf79a38c4e7b57d7f390359393fc0cef6dbf27dfe
+checksum=c958e825dc3ac3b7a481f8db5268131a1cd701312385c2d803dc63c8e460b5fb
 
 case "$XBPS_TARGET_MACHINE" in
 	*-musl) # Required by musl for M_SQRT1_2

From 0258179c027328efa4c1ce16d9b168153c71398a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 19 Mar 2023 10:58:18 -0400
Subject: [PATCH 100/140] gst-omx: update to 1.22.1

---
 srcpkgs/gst-omx/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-omx/template b/srcpkgs/gst-omx/template
index 893535c463da..76692c2a13f6 100644
--- a/srcpkgs/gst-omx/template
+++ b/srcpkgs/gst-omx/template
@@ -1,6 +1,6 @@
 # Template file for 'gst-omx'
 pkgname=gst-omx
-version=1.20.3
+version=1.22.1
 revision=1
 build_style=meson
 configure_args="-Dexamples=disabled -Dtarget=generic"
@@ -11,4 +11,4 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.1-only"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname}/${pkgname}-${version}.tar.xz"
-checksum=8db48040bb41f09edf8d17ff6d16c54888d7777ba4501c2c69f0083350ea9a15
+checksum=2d37f60cd33e68dcef0bcd09b2dd8a0b2eb3ab6d6ac172dca46f70eb02756687

From 8b8c544e00e9695348cf2ebe5acdbee177f79703 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 19 Mar 2023 10:59:04 -0400
Subject: [PATCH 101/140] gst-plugins-bad1: update to 1.22.1

---
 common/shlibs                     | 1 +
 srcpkgs/gst-plugins-bad1/template | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/common/shlibs b/common/shlibs
index d0d328b09ef9..42744a55b1fc 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -1147,6 +1147,7 @@ libgstpbutils-1.0.so.0 gst-plugins-base1-1.0.0_1
 libgstriff-1.0.so.0 gst-plugins-base1-1.0.0_1
 libgstapp-1.0.so.0 gst-plugins-base1-1.0.0_1
 libgstallocators-1.0.so.0 gst-plugins-base1-1.1.1_1
+libgsttranscoder-1.0.so.0 gst-plugins-bad1-1.22.1_1
 libgstphotography-1.0.so.0 gst-plugins-bad1-1.18.3_2
 libgstsignalprocessor-1.0.so.0 gst-plugins-bad1-1.18.3_2
 libgstbasevideo-1.0.so.0 gst-plugins-bad1-1.18.3_2
diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index 5a9d5387e0d4..7f272f915ac4 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -36,7 +36,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later, LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname/1/}/${pkgname/1/}-${version}.tar.xz"
-checksum=7a11c13b55dd1d2386dd902219e41cbfcdda8e1e0aa3e738186c95074b35da4f
+checksum=2f39b6f222d98666f9ff420a00233e336949953a846237c2bfafc8805f509f0e
 
 build_options="gir gme wayland"
 build_options_default="gir wayland"

From ba55d5d71946d02f8e921c021b56474f4bc7a64e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 19 Mar 2023 10:59:04 -0400
Subject: [PATCH 102/140] gst-plugins-ugly1: update to 1.22.1

---
 srcpkgs/gst-plugins-ugly1/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-plugins-ugly1/template b/srcpkgs/gst-plugins-ugly1/template
index e254fd40f869..5647c012c9fe 100644
--- a/srcpkgs/gst-plugins-ugly1/template
+++ b/srcpkgs/gst-plugins-ugly1/template
@@ -1,6 +1,6 @@
 # Template file for 'gst-plugins-ugly1'
 pkgname=gst-plugins-ugly1
-version=1.20.3
+version=1.22.1
 revision=1
 build_style=meson
 configure_args="-Damrnb=disabled -Damrwbdec=disabled -Dsidplay=disabled"
@@ -15,4 +15,4 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname/1/}/${pkgname/1/}-${version}.tar.xz"
-checksum=8caa20789a09c304b49cf563d33cca9421b1875b84fcc187e4a385fa01d6aefd
+checksum=4ab3d9e13481bce1ca3c7c4bb1f65dce4f0bb40fb1cac4416e8c06dd648815c2

From 9d0baaabf3a3848ca1afd6d7defeba99d19cb85e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 19 Mar 2023 10:59:31 -0400
Subject: [PATCH 103/140] gst-editing-services: update to 1.22.1

---
 srcpkgs/gst1-editing-services/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst1-editing-services/template b/srcpkgs/gst1-editing-services/template
index 673b46970f24..f2045ad6043c 100644
--- a/srcpkgs/gst1-editing-services/template
+++ b/srcpkgs/gst1-editing-services/template
@@ -1,6 +1,6 @@
 # Template file for 'gst1-editing-services'
 pkgname=gst1-editing-services
-version=1.20.3
+version=1.22.1
 revision=1
 build_style=meson
 build_helper="gir"
@@ -12,7 +12,7 @@ maintainer="Toyam Cox <Vaelatern@gmail.com>"
 license="LGPL-2.0-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname/gst1/gst}/${pkgname/gst1/gst}-${version}.tar.xz"
-checksum=5fd896de69fbe24421eb6b0ff8d2f8b4c3cba3f3025ceacd302172f39a8abaa2
+checksum=0f9e5e08ef80a4b9a0e971c5f032b13c71aa6fef236265c2d615456e15161438
 
 do_check() {
 	: # Tests fail in older versions as well

From f0b50207650d199e57babe5491fb3ff7810cb57c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 19 Mar 2023 11:00:00 -0400
Subject: [PATCH 104/140] gst-rtsp-server: update to 1.22.1

---
 srcpkgs/gst-rtsp-server/template | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index 8ceea8d34b4b..ded9a69a2e9d 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
-version=1.20.3
-revision=3
+version=1.22.1
+revision=1
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="glib-devel gst-plugins-bad1-devel gobject-introspection
@@ -10,5 +10,5 @@ short_desc="GStreamer multimedia graph framework - rtsp server"
 maintainer="1is7ac3 <isaac.qa13@gmail.com>"
 license="LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
-distfiles="https://gstreamer.freedesktop.org/src/gst-rtsp-server/gst-rtsp-server-${version}.tar.xz"
-checksum=ee402718be9b127f0e5e66ca4c1b4f42e4926ec93ba307b7ccca5dc6cc9794ca
+distfiles="${homepage}/src/${pkgname}/${pkgname}-${version}.tar.xz"
+checksum=4e0b972608f67d5d8f5363c827cfcf132b0e00877be6f1905358d514249b05a3

From 6bcea1d88313aeed3c0587847f1221c40e6efbf8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 19 Mar 2023 11:00:39 -0400
Subject: [PATCH 105/140] gst1-python3: update to 1.22.1

---
 srcpkgs/gst1-python3/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/gst1-python3/template b/srcpkgs/gst1-python3/template
index 3f564ac64b93..7a8d094ef61f 100644
--- a/srcpkgs/gst1-python3/template
+++ b/srcpkgs/gst1-python3/template
@@ -1,7 +1,7 @@
 # Template file for 'gst1-python3'
 pkgname=gst1-python3
-version=1.20.3
-revision=2
+version=1.22.1
+revision=1
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="libglib-devel python3-devel python3-gobject-devel gst-plugins-base1-devel"
@@ -11,4 +11,4 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/gst-python/gst-python-${version}.tar.xz"
-checksum=db348120eae955b8cc4de3560a7ea06e36d6e1ddbaa99a7ad96b59846601cfdc
+checksum=96008a441d685a64275a515b893ccad0fea1d560c43acd0763533e17f3a13ebb

From 6fcf8665f50766b471cb548e9e8b558e2477aec2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 19 Mar 2023 11:00:46 -0400
Subject: [PATCH 106/140] gstreamer-vaapi: update to 1.22.1

---
 srcpkgs/gstreamer-vaapi/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gstreamer-vaapi/template b/srcpkgs/gstreamer-vaapi/template
index 3cc4e057559a..c100d99e9af1 100644
--- a/srcpkgs/gstreamer-vaapi/template
+++ b/srcpkgs/gstreamer-vaapi/template
@@ -1,6 +1,6 @@
 # Template file for 'gstreamer-vaapi'
 pkgname=gstreamer-vaapi
-version=1.20.3
+version=1.22.1
 revision=1
 build_style=meson
 hostmakedepends="pkg-config"
@@ -11,7 +11,7 @@ license="LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
 changelog="https://raw.githubusercontent.com/GStreamer/gstreamer-vaapi/master/ChangeLog"
 distfiles="${homepage}/src/gstreamer-vaapi/gstreamer-vaapi-${version}.tar.xz"
-checksum=6ee99eb316abdde9ad37002915bd8c3867918f6fdc74b7cf2ac4c1ae0d690b45
+checksum=423b57db7fc5f9137dadf17cb3853a47438d63cd4ba6889a882e63fb5be997bc
 
 pre_check() {
 	# Seems to need certain hardware to pass

From 8630148cd020d36f5d0c876b6e1a565a2827edde Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 19 Mar 2023 11:00:51 -0400
Subject: [PATCH 107/140] gstreamer1: update to 1.22.1

---
 srcpkgs/gstreamer1/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gstreamer1/template b/srcpkgs/gstreamer1/template
index ae8a49cb20e8..362fe82faec3 100644
--- a/srcpkgs/gstreamer1/template
+++ b/srcpkgs/gstreamer1/template
@@ -1,6 +1,6 @@
 # Template file for 'gstreamer1'
 pkgname=gstreamer1
-version=1.20.3
+version=1.22.1
 revision=1
 build_style=meson
 build_helper="gir"
@@ -16,7 +16,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.0-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/gstreamer/gstreamer-${version}.tar.xz"
-checksum=607daf64bbbd5fb18af9d17e21c0d22c4d702fffe83b23cb22d1b1af2ca23a2a
+checksum=cd3ca759f926763615fdfcea63c9761198c42889bc0615ceec73e22b24fde771
 
 pre_check() {
 	# gst_gstdatetime is known to fail according to LFS

From 20d2f1f5a758b82922175d2892a50fe03ce847a3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 19 Mar 2023 10:59:04 -0400
Subject: [PATCH 108/140] gst-plugins-good1: update to 1.22.1

---
 srcpkgs/gst-plugins-good1/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-plugins-good1/template b/srcpkgs/gst-plugins-good1/template
index 1f5e620ce1fd..00baa6732c75 100644
--- a/srcpkgs/gst-plugins-good1/template
+++ b/srcpkgs/gst-plugins-good1/template
@@ -1,6 +1,6 @@
 # Template file for 'gst-plugins-good1'
 pkgname=gst-plugins-good1
-version=1.20.3
+version=1.22.1
 revision=1
 build_style=meson
 configure_args="-Ddv=disabled -Ddv1394=disabled -Dshout2=disabled -Dqt5=enabled
@@ -22,7 +22,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname/1/}/${pkgname/1/}-${version}.tar.xz"
-checksum=f8f3c206bf5cdabc00953920b47b3575af0ef15e9f871c0b6966f6d0aa5868b7
+checksum=44f9104654b4fd042aebe90932ab92e7ff7d8460fbc05b23dad87dffe70974cc
 
 build_options="gtk3 wayland"
 build_options_default="gtk3 wayland"

From e09d3340288d9c31c67a2928d1bd59e1bb1281da Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 19 Mar 2023 10:59:04 -0400
Subject: [PATCH 109/140] gst-plugins-base1: update to 1.22.1

---
 srcpkgs/gst-plugins-base1/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-plugins-base1/template b/srcpkgs/gst-plugins-base1/template
index 29e8f76bd1fe..6d2cad16f985 100644
--- a/srcpkgs/gst-plugins-base1/template
+++ b/srcpkgs/gst-plugins-base1/template
@@ -1,6 +1,6 @@
 # Template file for 'gst-plugins-base1'
 pkgname=gst-plugins-base1
-version=1.20.3
+version=1.22.1
 revision=1
 build_style=meson
 build_helper="gir"
@@ -22,7 +22,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname/1/}/${pkgname/1/}-${version}.tar.xz"
-checksum=7e30b3dd81a70380ff7554f998471d6996ff76bbe6fc5447096f851e24473c9f
+checksum=59bcaeacc5646b8dbdcfa4ef20ca6e818dd234910efb4cee1bbea441a3801c69
 
 build_options="cdparanoia gir sndio wayland"
 build_options_default="cdparanoia gir wayland"

From dc50f33765103a8eda9bae95bef268f969a36d22 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 16 Dec 2022 09:25:22 -0500
Subject: [PATCH 110/140] intel-gmmlib: update to 22.3.3

---
 srcpkgs/intel-gmmlib/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/intel-gmmlib/template b/srcpkgs/intel-gmmlib/template
index 8ed6ed3cf56c..2605226152e5 100644
--- a/srcpkgs/intel-gmmlib/template
+++ b/srcpkgs/intel-gmmlib/template
@@ -1,6 +1,6 @@
 # Template file for 'intel-gmmlib'
 pkgname=intel-gmmlib
-version=22.2.0
+version=22.3.3
 revision=1
 archs="i686* x86_64*"
 build_style=cmake
@@ -18,7 +18,7 @@ maintainer="Stefano Ragni <st3r4g@protonmail.com>"
 license="MIT"
 homepage="https://github.com/intel/gmmlib"
 distfiles="https://github.com/intel/gmmlib/archive/intel-gmmlib-${version}.tar.gz"
-checksum=0b2253894c6fc8455b6d7c5e87e6504a76d6f60ea192e1445c2f93164bf529c0
+checksum=86651bd2803c9f0afd82471bec784e65d2b418dee315a053d22215eb2a679be7
 
 lib32disabled=yes
 

From 19115bde2696fddbb737e5cf8ec897aac163c54c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 16 Dec 2022 09:25:47 -0500
Subject: [PATCH 111/140] intel-media-driver: update to 22.6.4

---
 ...mmon-Enable-MMC-in-free-kernel-build.patch | 125 ++++++++++++++++++
 .../intel-media-driver/patches/execinfo.patch |  58 --------
 srcpkgs/intel-media-driver/template           |   4 +-
 3 files changed, 127 insertions(+), 60 deletions(-)
 create mode 100644 srcpkgs/intel-media-driver/patches/0001-Media-Common-Enable-MMC-in-free-kernel-build.patch
 delete mode 100644 srcpkgs/intel-media-driver/patches/execinfo.patch

diff --git a/srcpkgs/intel-media-driver/patches/0001-Media-Common-Enable-MMC-in-free-kernel-build.patch b/srcpkgs/intel-media-driver/patches/0001-Media-Common-Enable-MMC-in-free-kernel-build.patch
new file mode 100644
index 000000000000..525fb688722c
--- /dev/null
+++ b/srcpkgs/intel-media-driver/patches/0001-Media-Common-Enable-MMC-in-free-kernel-build.patch
@@ -0,0 +1,125 @@
+From e68feab7db036838d9521ba3b9f00717c37c024c Mon Sep 17 00:00:00 2001
+From: JayYang <jay.yang@intel.com>
+Date: Tue, 21 Mar 2023 17:17:55 +0800
+Subject: [PATCH] [Media Common] Enable MMC in free kernel build
+
+Add mmc build definition in free kernel build
+---
+ media_driver/agnostic/gen9/codec/hal/media_srcs.cmake          | 2 +-
+ media_driver/cmake/linux/media_feature_flags_linux.cmake       | 3 +--
+ .../media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp        | 2 +-
+ .../media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp        | 2 +-
+ .../media_interfaces_m9_glk/media_interfaces_g9_glk.cpp        | 2 +-
+ .../media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp        | 2 +-
+ .../media_interfaces_m9_skl/media_interfaces_g9_skl.cpp        | 2 +-
+ 7 files changed, 7 insertions(+), 8 deletions(-)
+
+diff --git a/media_driver/agnostic/gen9/codec/hal/media_srcs.cmake b/media_driver/agnostic/gen9/codec/hal/media_srcs.cmake
+index 8bb36bafe..78902a22d 100644
+--- a/media_driver/agnostic/gen9/codec/hal/media_srcs.cmake
++++ b/media_driver/agnostic/gen9/codec/hal/media_srcs.cmake
+@@ -27,7 +27,7 @@ set(TMP_1_HEADERS_
+     ${CMAKE_CURRENT_LIST_DIR}/codechal_hw_g9_X.h
+ )
+ 
+-if(${MMC_Supported} STREQUAL "yes")
++if(${MMC_Supported} STREQUAL "yes" AND ENABLE_NONFREE_KERNELS AND ENABLE_KERNELS)
+     set(TMP_1_SOURCES_
+         ${TMP_1_SOURCES_}
+         ${CMAKE_CURRENT_LIST_DIR}/codechal_memdecomp_g9.cpp
+diff --git a/media_driver/cmake/linux/media_feature_flags_linux.cmake b/media_driver/cmake/linux/media_feature_flags_linux.cmake
+index de0ca853f..8121ea60c 100644
+--- a/media_driver/cmake/linux/media_feature_flags_linux.cmake
++++ b/media_driver/cmake/linux/media_feature_flags_linux.cmake
+@@ -35,7 +35,6 @@ if(NOT ENABLE_KERNELS OR NOT ENABLE_NONFREE_KERNELS)
+     bs_set_if_undefined(HEVC_Encode_VME_Supported "no")
+     bs_set_if_undefined(MPEG2_Encode_VME_Supported "no")
+     bs_set_if_undefined(CMRT_HEVC_ENC_FEI_Supported "no")
+-    bs_set_if_undefined(MMC_Supported "no")
+     bs_set_if_undefined(VC1_Decode_Supported "no")
+     bs_set_if_undefined(Decode_Processing_Supported "no")
+     bs_set_if_undefined(Kernel_Auto_Denoise_Supported "no")
+@@ -46,7 +45,6 @@ else()
+     bs_set_if_undefined(HEVC_Encode_VME_Supported "${Encode_VME_Supported}")
+     bs_set_if_undefined(MPEG2_Encode_VME_Supported "${Encode_VME_Supported}")
+     bs_set_if_undefined(CMRT_HEVC_ENC_FEI_Supported "yes")
+-    bs_set_if_undefined(MMC_Supported "yes")
+     bs_set_if_undefined(VC1_Decode_Supported "yes")
+     bs_set_if_undefined(Decode_Processing_Supported "yes")
+     bs_set_if_undefined(Kernel_Auto_Denoise_Supported "yes")
+@@ -64,6 +62,7 @@ bs_set_if_undefined(VP9_Decode_Supported "yes")
+ bs_set_if_undefined(VP_SFC_Supported "yes")
+ bs_set_if_undefined(Common_Encode_Supported "yes")
+ bs_set_if_undefined(Media_Scalability_Supported "yes")
++bs_set_if_undefined(MMC_Supported "yes")
+ 
+ # features controlled by global flag Encode_VDEnc_Supported
+ bs_set_if_undefined(AVC_Encode_VDEnc_Supported "${Encode_VDEnc_Supported}")
+diff --git a/media_driver/media_interface/media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp b/media_driver/media_interface/media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp
+index 3f306ee2a..8e4c0f532 100644
+--- a/media_driver/media_interface/media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp
+@@ -135,7 +135,7 @@ MOS_STATUS MhwInterfacesG9Bxt::Initialize(
+ 
+     return MOS_STATUS_SUCCESS;
+ }
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool bxtRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Bxt>((uint32_t)IGFX_BROXTON);
+diff --git a/media_driver/media_interface/media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp b/media_driver/media_interface/media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp
+index b8fa1eec0..84e0fad1d 100644
+--- a/media_driver/media_interface/media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp
+@@ -44,7 +44,7 @@ static bool cflRegisteredMhw =
+     MediaFactory<uint32_t, MhwInterfaces>::
+     Register<MhwInterfacesG9Kbl>((uint32_t)IGFX_COFFEELAKE);
+ 
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool cflRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Kbl>((uint32_t)IGFX_COFFEELAKE);
+diff --git a/media_driver/media_interface/media_interfaces_m9_glk/media_interfaces_g9_glk.cpp b/media_driver/media_interface/media_interfaces_m9_glk/media_interfaces_g9_glk.cpp
+index de81e6091..2638cb3a6 100644
+--- a/media_driver/media_interface/media_interfaces_m9_glk/media_interfaces_g9_glk.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_glk/media_interfaces_g9_glk.cpp
+@@ -65,7 +65,7 @@ static bool glkRegisteredMhw =
+     MediaFactory<uint32_t, MhwInterfaces>::
+     Register<MhwInterfacesG9Kbl>((uint32_t)IGFX_GEMINILAKE);
+ 
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool glkRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Kbl>((uint32_t)IGFX_GEMINILAKE);
+diff --git a/media_driver/media_interface/media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp b/media_driver/media_interface/media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp
+index 99d786185..4e9c6e7f1 100644
+--- a/media_driver/media_interface/media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp
+@@ -131,7 +131,7 @@ MOS_STATUS MhwInterfacesG9Kbl::Initialize(
+ 
+     return MOS_STATUS_SUCCESS;
+ }
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool kblRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Kbl>((uint32_t)IGFX_KABYLAKE);
+diff --git a/media_driver/media_interface/media_interfaces_m9_skl/media_interfaces_g9_skl.cpp b/media_driver/media_interface/media_interfaces_m9_skl/media_interfaces_g9_skl.cpp
+index e2520edf7..4b0012c64 100644
+--- a/media_driver/media_interface/media_interfaces_m9_skl/media_interfaces_g9_skl.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_skl/media_interfaces_g9_skl.cpp
+@@ -139,7 +139,7 @@ MOS_STATUS MhwInterfacesG9Skl::Initialize(
+ 
+     return MOS_STATUS_SUCCESS;
+ }
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool sklRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Skl>((uint32_t)IGFX_SKYLAKE);
+-- 
+2.40.0
+
diff --git a/srcpkgs/intel-media-driver/patches/execinfo.patch b/srcpkgs/intel-media-driver/patches/execinfo.patch
deleted file mode 100644
index 25d21192d5a1..000000000000
--- a/srcpkgs/intel-media-driver/patches/execinfo.patch
+++ /dev/null
@@ -1,58 +0,0 @@
-From b17354142563b45e0ebf427485591426481368fd Mon Sep 17 00:00:00 2001
-From: Bernd Kuhls <bernd.kuhls@t-online.de>
-Date: Fri, 29 Jul 2022 19:51:39 +0200
-Subject: [PATCH] Fix uClibc build
-
-uClibc does not provide execinfo.h
----
- CMakeLists.txt                                              | 6 ++++++
- .../linux/common/os/osservice/mos_utilities_specific.cpp    | 4 ++++
- 2 files changed, 10 insertions(+)
-
-diff --git a/CMakeLists.txt b/CMakeLists.txt
-index 053904748..4a3f0869e 100755
---- a/CMakeLists.txt
-+++ b/CMakeLists.txt
-@@ -53,6 +53,12 @@ option (BUILD_CMRTLIB "Build and Install cmrtlib together with media driver" ON)
- 
- option (ENABLE_PRODUCTION_KMD "Enable Production KMD header files" OFF)
- 
-+include(CheckIncludeFileCXX)
-+check_include_file_cxx("execinfo.h" HAVE_EXECINFO)
-+if (HAVE_EXECINFO)
-+    add_definitions(-DHAVE_EXECINFO)
-+endif()
-+
- include(GNUInstallDirs)
- 
- if (BUILD_CMRTLIB AND NOT CMAKE_WDDM_LINUX)
-diff --git a/media_softlet/linux/common/os/osservice/mos_utilities_specific.cpp b/media_softlet/linux/common/os/osservice/mos_utilities_specific.cpp
-index bde216b83..120b02d55 100644
---- a/media_softlet/linux/common/os/osservice/mos_utilities_specific.cpp
-+++ b/media_softlet/linux/common/os/osservice/mos_utilities_specific.cpp
-@@ -34,7 +34,9 @@
- #include <signal.h>
- #include <unistd.h>  // fork
- #include <algorithm>
-+#ifdef HAVE_EXECINFO
- #include <execinfo.h> // backtrace
-+#endif
- #include <sys/types.h>
- #include <sys/stat.h>  // fstat
- #include <sys/ipc.h>  // System V IPC
-@@ -2473,6 +2475,7 @@ void MosUtilities::MosTraceEvent(
-                 MOS_FreeMemory(pTraceBuf);
-             }
-         }
-+#ifdef HAVE_EXECINFO
-         if (m_mosTraceFilter & (1ULL << TR_KEY_CALL_STACK))
-         {
-             // reserve space for header and stack size field.
-@@ -2492,6 +2495,7 @@ void MosUtilities::MosTraceEvent(
-                 size_t ret = write(MosUtilitiesSpecificNext::m_mosTraceFd, traceBuf, nLen);
-             }
-         }
-+#endif
-     }
-     return;
- }
diff --git a/srcpkgs/intel-media-driver/template b/srcpkgs/intel-media-driver/template
index 1ca94569e117..1735b90c65ce 100644
--- a/srcpkgs/intel-media-driver/template
+++ b/srcpkgs/intel-media-driver/template
@@ -1,6 +1,6 @@
 # Template file for 'intel-media-driver'
 pkgname=intel-media-driver
-version=22.5.3
+version=22.6.4
 revision=1
 archs="x86_64*"
 build_style=cmake
@@ -12,7 +12,7 @@ maintainer="Stefano Ragni <st3r4g@protonmail.com>"
 license="MIT, BSD-3-Clause"
 homepage="https://github.com/intel/media-driver"
 distfiles="https://github.com/intel/media-driver/archive/intel-media-${version}.tar.gz"
-checksum=65652b365d48be3c9f0b3c561502952b92ee5fcc587520b88d0d752cf2a6a3b5
+checksum=0c04b9d74b92de41fd409b62913ce4afd799236c0b6bc1983a496990764e5d90
 
 build_options="nonfree"
 desc_option_nonfree="Enable nonfree kernels"

From 2df76e50af221cce09ced6a38203600ad954d59e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 16 Dec 2022 09:31:43 -0500
Subject: [PATCH 112/140] New package: onevpl-2023.1.2

---
 common/shlibs           |  1 +
 srcpkgs/onevpl-devel    |  1 +
 srcpkgs/onevpl/template | 34 ++++++++++++++++++++++++++++++++++
 3 files changed, 36 insertions(+)
 create mode 120000 srcpkgs/onevpl-devel
 create mode 100644 srcpkgs/onevpl/template

diff --git a/common/shlibs b/common/shlibs
index 42744a55b1fc..f1675bacfe8b 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -879,6 +879,7 @@ libwebp.so.7 libwebp-0.6.0_1
 libwebpmux.so.3 libwebp-0.6.0_1
 libwebpdemux.so.2 libwebp-0.5.0_1
 libwebpdecoder.so.3 libwebp-0.6.0_1
+libvpl.so.2 onevpl-2023.1.2_1
 libva-x11.so.2 libva-2.13.0_1
 libva.so.2 libva-2.13.0_1
 libva-glx.so.2 libva-glx-2.13.0_1
diff --git a/srcpkgs/onevpl-devel b/srcpkgs/onevpl-devel
new file mode 120000
index 000000000000..e2306500b487
--- /dev/null
+++ b/srcpkgs/onevpl-devel
@@ -0,0 +1 @@
+onevpl
\ No newline at end of file
diff --git a/srcpkgs/onevpl/template b/srcpkgs/onevpl/template
new file mode 100644
index 000000000000..85c7c2da85ce
--- /dev/null
+++ b/srcpkgs/onevpl/template
@@ -0,0 +1,34 @@
+# Template file for 'onevpl'
+pkgname=onevpl
+version=2023.1.2
+revision=1
+archs="x86_64*"
+build_style=cmake
+configure_args="
+	-DCMAKE_BUILD_TYPE=Release -Wno-dev
+	-DBUILD_PYTHON_BINDING:BOOL='OFF'
+	-DBUILD_EXAMPLES:BOOL='OFF'
+	-DBUILD_TESTS:BOOL='ON'
+	-DINSTALL_EXAMPLE_CODE:BOOL='OFF'"
+hostmakedepends="cmake libX11 python wayland-protocols pkg-config"
+makedepends="libva-devel libX11-devel wayland-devel"
+short_desc="Intel oneAPI Video Processing library"
+maintainer="zlice <zlice555@gmail.com>"
+license="MIT"
+homepage="https://www.intel.com/content/www/us/en/developer/tools/oneapi/onevpl.html"
+distfiles="https://github.com/oneapi-src/oneVPL/archive/v${version}/${pkgname}-${version}.tar.gz"
+checksum=b2261cca174ce1815f3d47c647921ab17f68267c69c1e2444ff27aab7d199cbb
+
+post_install() {
+	vlicense LICENSE
+}
+
+onevpl-devel_package() {
+	depends="${makedepends} ${sourcepkg}-${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.so"
+	}
+}

From 4274baf41e02d579c4194fc3315d67b0d581318d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 16 Dec 2022 15:27:04 -0500
Subject: [PATCH 113/140] New package: onevpl-intel-gpu-22.6.4

---
 srcpkgs/onevpl-intel-gpu-devel    |  1 +
 srcpkgs/onevpl-intel-gpu/template | 27 +++++++++++++++++++++++++++
 2 files changed, 28 insertions(+)
 create mode 120000 srcpkgs/onevpl-intel-gpu-devel
 create mode 100644 srcpkgs/onevpl-intel-gpu/template

diff --git a/srcpkgs/onevpl-intel-gpu-devel b/srcpkgs/onevpl-intel-gpu-devel
new file mode 120000
index 000000000000..47920ceecf91
--- /dev/null
+++ b/srcpkgs/onevpl-intel-gpu-devel
@@ -0,0 +1 @@
+onevpl-intel-gpu
\ No newline at end of file
diff --git a/srcpkgs/onevpl-intel-gpu/template b/srcpkgs/onevpl-intel-gpu/template
new file mode 100644
index 000000000000..f14acb728a54
--- /dev/null
+++ b/srcpkgs/onevpl-intel-gpu/template
@@ -0,0 +1,27 @@
+# Template file for 'onevpl-intel-gpu'
+pkgname=onevpl-intel-gpu
+version=22.6.4
+revision=1
+archs="x86_64*"
+build_style=cmake
+configure_args="-Wno-dev -DCMAKE_BUILD_TYPE=Release"
+hostmakedepends="cmake pkg-config"
+makedepends="libdrm-devel libva-devel onevpl-devel"
+short_desc="Runtime implementation of oneVPL API for Intel Gen GPUs"
+maintainer="zlice <zlice555@gmail.com>"
+license="MIT"
+homepage="https://github.com/oneapi-src/oneVPL-intel-gpu"
+changelog="https://github.com/oneapi-src/oneVPL-intel-gpu/blob/main/CHANGELOG.md"
+distfiles="https://github.com/oneapi-src/oneVPL-intel-gpu/archive/refs/tags/intel-onevpl-${version}.tar.gz"
+checksum=74b0979dcb2af1b7c68edb8cbcb02d539de511090b12fac50652cbacd707c4e6
+
+post_install() {
+	vlicense LICENSE
+}
+
+onevpl-intel-gpu-devel_package() {
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/lib/pkgconfig
+	}
+}

From c0baf9571ee2f59abfb13995bbc0b026130285ff Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 18 Dec 2022 01:40:15 -0500
Subject: [PATCH 114/140] igt-gpu-tools: update to version 1.27 revbump idk
 remove

---
 ...-loading-failure-in-resolve-function.patch | 63 -------------------
 srcpkgs/igt-gpu-tools/patches/musl.patch      | 20 ++++++
 srcpkgs/igt-gpu-tools/template                |  4 +-
 3 files changed, 22 insertions(+), 65 deletions(-)
 delete mode 100644 srcpkgs/igt-gpu-tools/patches/i-g-t-Fix-global-symbol-loading-failure-in-resolve-function.patch

diff --git a/srcpkgs/igt-gpu-tools/patches/i-g-t-Fix-global-symbol-loading-failure-in-resolve-function.patch b/srcpkgs/igt-gpu-tools/patches/i-g-t-Fix-global-symbol-loading-failure-in-resolve-function.patch
deleted file mode 100644
index 0c3b554d9949..000000000000
--- a/srcpkgs/igt-gpu-tools/patches/i-g-t-Fix-global-symbol-loading-failure-in-resolve-function.patch
+++ /dev/null
@@ -1,63 +0,0 @@
-diff --git lib/igt_halffloat.c lib/igt_halffloat.c
-index 08ab05fc..e5e8a5bd 100644
---- a/lib/igt_halffloat.c
-+++ b/lib/igt_halffloat.c
-@@ -24,6 +24,19 @@
- 
- #include <assert.h>
- #include <math.h>
-+#include <stdbool.h>
-+
-+#ifdef HAVE_CPUID_H
-+#include <cpuid.h>
-+#else
-+#define __get_cpuid_max(x, y) 0
-+#define __cpuid(level, a, b, c, d) a = b = c = d = 0
-+#define __cpuid_count(level, count, a, b, c, d) a = b = c = d = 0
-+#endif
-+
-+#ifndef bit_F16C
-+#define bit_F16C	(1 << 29)
-+#endif
- 
- #include "igt_halffloat.h"
- #include "igt_x86.h"
-@@ -182,6 +195,20 @@ static void half_to_float_f16c(const uint16_t *h, float *f, unsigned int num)
- 
- #pragma GCC pop_options
- 
-+static bool f16c_is_supported(void)
-+{
-+	unsigned max = __get_cpuid_max(0, NULL);
-+	unsigned eax, ebx, ecx, edx;
-+
-+	if (max >= 1) {
-+		__cpuid(1, eax, ebx, ecx, edx);
-+
-+		if (ecx & bit_F16C)
-+			return true;
-+	}
-+	return false;
-+}
-+
- static void float_to_half(const float *f, uint16_t *h, unsigned int num)
- {
- 	for (int i = 0; i < num; i++)
-@@ -196,7 +223,7 @@ static void half_to_float(const uint16_t *h, float *f, unsigned int num)
- 
- static void (*resolve_float_to_half(void))(const float *f, uint16_t *h, unsigned int num)
- {
--	if (igt_x86_features() & F16C)
-+	if (f16c_is_supported())
- 		return float_to_half_f16c;
- 
- 	return float_to_half;
-@@ -207,7 +234,7 @@ void igt_float_to_half(const float *f, uint16_t *h, unsigned int num)
- 
- static void (*resolve_half_to_float(void))(const uint16_t *h, float *f, unsigned int num)
- {
--	if (igt_x86_features() & F16C)
-+	if (f16c_is_supported())
- 		return half_to_float_f16c;
- 
- 	return half_to_float;
diff --git a/srcpkgs/igt-gpu-tools/patches/musl.patch b/srcpkgs/igt-gpu-tools/patches/musl.patch
index 615afdb8f8ea..4de6e0cfd898 100644
--- a/srcpkgs/igt-gpu-tools/patches/musl.patch
+++ b/srcpkgs/igt-gpu-tools/patches/musl.patch
@@ -191,6 +191,7 @@ index 74935430..0dc87d8c 100644
 +++ b/tests/i915/i915_pm_rpm.c
 @@ -27,6 +27,7 @@
  
+<<<<<<< HEAD
  #include "config.h"
  
 +#include <limits.h> // PATH_MAX
@@ -293,3 +294,22 @@ index 0faf3fc8..f6bd970e 100644
  #include <stdio.h>
  #include <string.h>
  #include <stdlib.h>
+=======
+         fbo = bo->map;
+lib/ioctl_wrappers.c.new
+--- a/benchmarks/gem_exec_tracer.c	2022-12-18 10:32:15.742341964 -0500
++++ b/benchmarks/gem_exec_tracer.c	2022-12-18 10:32:09.862211372 -0500
+@@ -275,7 +275,11 @@
+     DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_EXECBUFFER2, struct drm_i915_gem_execbuffer2)
+ 
+ int
++#if defined(__GLIBC__) || defined(__FreeBSD__)
+ ioctl(int fd, unsigned long request, ...)
++#else
++ioctl(int fd, int request, ...)
++#endif
+ {
+ 	struct trace *t, **p;
+ 	va_list args;
+
+>>>>>>> 60301ae02f (igt-gpu-tools: update to version 1.26)
diff --git a/srcpkgs/igt-gpu-tools/template b/srcpkgs/igt-gpu-tools/template
index 225e2c79118a..1376c39d5d5b 100644
--- a/srcpkgs/igt-gpu-tools/template
+++ b/srcpkgs/igt-gpu-tools/template
@@ -1,7 +1,7 @@
 # Template file for 'igt-gpu-tools'
 pkgname=igt-gpu-tools
 version=1.27.1
-revision=1
+revision=2
 build_style=meson
 configure_args="-Db_ndebug=false -Ddocs=disabled"
 hostmakedepends="pkg-config flex peg python3-docutils"
@@ -13,7 +13,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="MIT"
 homepage="https://gitlab.freedesktop.org/drm/igt-gpu-tools"
 changelog="https://gitlab.freedesktop.org/drm/igt-gpu-tools/-/raw/master/NEWS"
-distfiles="${XORG_SITE}/app/igt-gpu-tools-${version}.tar.xz"
+distfiles="${XORG_SITE}/app/${pkgname}-${version}.tar.xz"
 checksum=93b9a4816ed22b5145bb61024314c8a65caeea991ce93027643f1d40723bf417
 # tests don't behave in containers
 make_check=ci-skip

From b0c46a793bdabef1bd17f8f7983df5a74edd4195 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:30:28 -0400
Subject: [PATCH 115/140] freecad: revbump for qt5-webengine-5.15.13

---
 srcpkgs/freecad/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/freecad/template b/srcpkgs/freecad/template
index f62023ee8ce4..e301f32d3540 100644
--- a/srcpkgs/freecad/template
+++ b/srcpkgs/freecad/template
@@ -1,7 +1,7 @@
 # Template file for 'freecad'
 pkgname=freecad
 version=0.20.2
-revision=3
+revision=4
 build_style=cmake
 
 _inst_prefix=/usr/lib/${pkgname}

From 02b79ac0c495f8f2c2237c43287378aa475ca39f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:31:45 -0400
Subject: [PATCH 116/140] shotcut: revbump for mlt7-7.14.0

---
 srcpkgs/shotcut/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/shotcut/template b/srcpkgs/shotcut/template
index 32583277dab2..8d8a7a0ebdeb 100644
--- a/srcpkgs/shotcut/template
+++ b/srcpkgs/shotcut/template
@@ -1,7 +1,7 @@
 # Template file for 'shotcut'
 pkgname=shotcut
 version=22.12.21
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSHOTCUT_VERSION=${version}"
 hostmakedepends="pkg-config qt5-tools-devel"

From 9955f00a5b449e62684efac640df0c24664ce08e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:30 -0400
Subject: [PATCH 117/140] shiboken2: revbump for qt5-5.15.8

---
 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch | 1 +
 srcpkgs/shiboken2/template                                 | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
 create mode 120000 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
new file mode 120000
index 000000000000..efcf3249bd88
--- /dev/null
+++ b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1 @@
+../../python3-pyside2/patches/importlib-machinery-bypass.patch
\ No newline at end of file
diff --git a/srcpkgs/shiboken2/template b/srcpkgs/shiboken2/template
index 084ecc3ba1e1..2a21998997eb 100644
--- a/srcpkgs/shiboken2/template
+++ b/srcpkgs/shiboken2/template
@@ -1,7 +1,7 @@
 # Template file for 'shiboken2'
 pkgname=shiboken2
 version=5.15.7
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/shiboken2"
 build_style=cmake

From 55a31610af49b4d666674fba71aade6ae6dd3b7a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:53 -0400
Subject: [PATCH 118/140] python3-pyside2: update to 5.15.8

---
 .../patches/importlib-machinery-bypass.patch      | 15 +++++++++++++++
 srcpkgs/python3-pyside2/template                  |  9 +++++----
 2 files changed, 20 insertions(+), 4 deletions(-)
 create mode 100644 srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
new file mode 100644
index 000000000000..64c429584776
--- /dev/null
+++ b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1,15 @@
+Using this prevents an error around line 220 below it.
+"AttributeError: module 'importlib' has no attribute 'machinery'"
+The old backup logic is in place and compiles without issues.
+--- a/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:09:34.688912402 -0400
++++ b/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:10:03.395529582 -0400
+@@ -170,9 +170,6 @@
+
+     # 'zipstring_sequence' comes from signature.cpp
+     zipbytes = base64.b64decode(''.join(zipstring_sequence))
+-    if sys.version_info[0] >= 3:
+-        vzip = zipfile.ZipFile(io.BytesIO(zipbytes))
+-        return sys.meta_path, EmbeddableZipImporter(vzip)
+
+     # Old version for Python 2.7, only.
+     import os
diff --git a/srcpkgs/python3-pyside2/template b/srcpkgs/python3-pyside2/template
index 50e6ff260d3b..b50e62bd215d 100644
--- a/srcpkgs/python3-pyside2/template
+++ b/srcpkgs/python3-pyside2/template
@@ -1,11 +1,12 @@
 # Template file for 'python3-pyside2'
 pkgname=python3-pyside2
-version=5.15.5
-revision=2
+version=5.15.8
+revision=1
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/pyside2"
 build_style=cmake
-configure_args="-DPYTHON_EXECUTABLE=/usr/bin/python"
+configure_args="-DPYTHON_EXECUTABLE=/usr/bin/python -DCMAKE_BUILD_TYPE=None
+ -DBUILD_TESTS=OFF"
 hostmakedepends="cmake python3 shiboken2"
 makedepends="python3-devel libshiboken2-devel qt5-devel
  qt5-multimedia-devel qt5-tools-devel qt5-plugin-mysql qt5-plugin-odbc
@@ -23,7 +24,7 @@ maintainer="yopito <pierre.bourgin@free.fr>"
 license="LGPL-3.0-or-later"
 homepage="https://wiki.qt.io/Qt_for_Python"
 distfiles="https://download.qt.io/official_releases/QtForPython/pyside2/PySide2-${version}-src/${_pkgname}.tar.xz"
-checksum=3920a4fb353300260c9bc46ff70f1fb975c5e7efa22e9d51222588928ce19b33
+checksum=23436302c8deb5b4cbc769b205d09604e38ba83b40708efccb7bd8c9af6f6b5d
 
 build_options="webengine"
 desc_option_webengine="Build Qt5 WebEngine bindings"

From 52d0ff624e2add8150a2ee66e246a64eb19f1bda Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:35 -0400
Subject: [PATCH 119/140] konqueror: revbump for ffmpeg-6.0

---
 srcpkgs/konqueror/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/konqueror/template b/srcpkgs/konqueror/template
index d8d0e73a78ab..c5bdba601d3c 100644
--- a/srcpkgs/konqueror/template
+++ b/srcpkgs/konqueror/template
@@ -1,11 +1,11 @@
 # Template file for 'konqueror'
 pkgname=konqueror
 version=23.04.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DDESKTOPTOJSON_EXECUTABLE=/usr/bin/desktoptojson"
 hostmakedepends="extra-cmake-modules python3 qt5-host-tools qt5-qmake kdoctools
-kcoreaddons kconfig gettext"
+ kcoreaddons kconfig gettext"
 makedepends="qt5-devel qt5-webengine-devel qt5-declarative-devel
  qt5-webchannel-devel qt5-location-devel kcmutils-devel kdelibs4support-devel
  karchive-devel khtml-devel kdesu-devel kactivities5-devel"

From 61c65c67d718432529f6294b28e90626b2afc039 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:58 -0400
Subject: [PATCH 120/140] qt5-speech: revbump for qt5-5.15.8

---
 srcpkgs/qt5-speech/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-speech/template b/srcpkgs/qt5-speech/template
index 3ecd10d50650..2d7d4d4d2453 100644
--- a/srcpkgs/qt5-speech/template
+++ b/srcpkgs/qt5-speech/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-speech'
 pkgname=qt5-speech
 version=5.15.7
-revision=2
+revision=3
 _commit=d32f4a479d38a11f547598004b975f4356424a16
 build_style=qmake
 configure_args="-- -flite -flite-alsa -speechd"

From 2a0907b8c3f09ded664a41bb90b84f9087769c59 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 18:38:50 -0400
Subject: [PATCH 121/140] qt5_styleplugins: revbump for qt5-5.15.8

---
 srcpkgs/qt5-styleplugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-styleplugins/template b/srcpkgs/qt5-styleplugins/template
index 96ed97d12cd2..30d93660a2a4 100644
--- a/srcpkgs/qt5-styleplugins/template
+++ b/srcpkgs/qt5-styleplugins/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-styleplugins'
 pkgname=qt5-styleplugins
 version=5.0.0
-revision=20
+revision=21
 _gitrev=335dbece103e2cbf6c7cf819ab6672c2956b17b3
 build_style=qmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From 45ed5d3da5fd8fa2e2b3e08fc8bf20f885feaca8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 27 Apr 2023 21:58:35 -0400
Subject: [PATCH 122/140] blender: update to 3.5.1

---
 srcpkgs/blender/patches/numpy-2.24.patch | 22 ----------------------
 srcpkgs/blender/template                 | 13 +++++++------
 2 files changed, 7 insertions(+), 28 deletions(-)
 delete mode 100644 srcpkgs/blender/patches/numpy-2.24.patch

diff --git a/srcpkgs/blender/patches/numpy-2.24.patch b/srcpkgs/blender/patches/numpy-2.24.patch
deleted file mode 100644
index 716315b74be7..000000000000
--- a/srcpkgs/blender/patches/numpy-2.24.patch
+++ /dev/null
@@ -1,22 +0,0 @@
-From 74e6e07cf7c67b55d384db72f5aa3892db8a3da6 Mon Sep 17 00:00:00 2001
-From: oreo639 <oreo6391@gmail.com>
-Date: Tue, 17 Jan 2023 14:36:54 -0800
-Subject: [PATCH] Remove usage of deprecated np.bool alias
-
----
- addons/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/addons/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py b/addons/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py
-index 6366434a6..8160c9e99 100644
---- a/release/scripts/addons/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py
-+++ b/release/scripts/addons/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py
-@@ -620,7 +620,7 @@ def set_poly_smoothing(gltf, pymesh, mesh, vert_normals, loop_vidxs):
-     # Try to guess which polys should be flat based on the fact that all the
-     # loop normals for a flat poly are = the poly's normal.
- 
--    poly_smooths = np.empty(num_polys, dtype=np.bool)
-+    poly_smooths = np.empty(num_polys, dtype=bool)
- 
-     poly_normals = np.empty(num_polys * 3, dtype=np.float32)
-     mesh.polygons.foreach_get('normal', poly_normals)
diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index d18bc88838ff..900bc17937c3 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -1,7 +1,7 @@
 # Template file for 'blender'
 pkgname=blender
-version=3.4.1
-revision=4
+version=3.5.1
+revision=1
 archs="x86_64* ppc64*"
 build_style="cmake"
 pycompile_dirs="/usr/share/blender/${version%.*}/scripts"
@@ -9,8 +9,8 @@ configure_args="-DWITH_INSTALL_PORTABLE=OFF -DWITH_PYTHON_INSTALL=OFF
  -DWITH_JACK=ON -DWITH_CODEC_FFMPEG=ON -DWITH_CODEC_SNDFILE=ON -DWITH_OPENMP=ON
  -DWITH_FFTW3=ON -DWITH_MOD_OCEANSIM=ON -DWITH_CYCLES_EMBREE=OFF -DWITH_OPENCOLORIO=ON
  -DWITH_IMAGE_OPENEXR=ON -DWITH_IMAGE_OPENJPEG=ON -DWITH_OPENSUBDIV=ON
- -DWITH_OPENCOLLADA=ON -DWITH_SYSTEM_GLEW=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
- -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_LIBDECOR=ON
+ -DWITH_OPENCOLLADA=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
+ -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_WAYLAND_LIBDECOR=ON
  -DWITH_BUILDINFO=OFF -DPYTHON_VERSION=${py3_ver} -DPYTHON_LIBPATH=/usr/lib
  -DPYTHON_LIBRARY='python${py3_ver}${py3_abiver}'
  -DPYTHON_INCLUDE_DIRS=/${py3_inc}"
@@ -22,14 +22,15 @@ makedepends="libgomp-devel libpng-devel tiff-devel python3-devel glu-devel
  opencolorio-devel opencollada-devel python3-numpy libXrender-devel
  OpenSubdiv-devel tbb-devel libxml2-devel openvdb-devel alembic-devel
  pugixml-devel libXxf86vm-devel libepoxy-devel gmp-devel gmpxx-devel
- wayland-protocols wayland-devel libxkbcommon-devel libdecor-devel"
+ wayland-protocols wayland-devel libxkbcommon-devel libdecor-devel
+ level-zero-devel"
 depends="desktop-file-utils hicolor-icon-theme"
 short_desc="3D graphics creation suite"
 maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="https://www.blender.org"
 distfiles="https://download.blender.org/source/blender-${version}.tar.xz"
-checksum=247c4c1228270c9010f4721c985cb5b628ab50abcf9f2678630737142eeb91c3
+checksum=bd7428c7e6cba5a900216269c32111dffaabaf1bdb5472f231965e615174a809
 python_version=3
 LDFLAGS="-Wl,-z,stack-size=2097152"
 # Blender tests are executed against a system installation of blender. This

From 40df1558fa8840c81b656bfb5b2214d91b3a11f8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 27 Apr 2023 20:41:10 -0400
Subject: [PATCH 123/140] New package: level-zero-1.10.0

---
 srcpkgs/level-zero-devel    |  1 +
 srcpkgs/level-zero/template | 28 ++++++++++++++++++++++++++++
 2 files changed, 29 insertions(+)
 create mode 120000 srcpkgs/level-zero-devel
 create mode 100644 srcpkgs/level-zero/template

diff --git a/srcpkgs/level-zero-devel b/srcpkgs/level-zero-devel
new file mode 120000
index 000000000000..96ee8adf7303
--- /dev/null
+++ b/srcpkgs/level-zero-devel
@@ -0,0 +1 @@
+level-zero
\ No newline at end of file
diff --git a/srcpkgs/level-zero/template b/srcpkgs/level-zero/template
new file mode 100644
index 000000000000..4631c8c67505
--- /dev/null
+++ b/srcpkgs/level-zero/template
@@ -0,0 +1,28 @@
+# Template file for 'level-zero'
+pkgname=level-zero
+version=1.10.0
+revision=1
+archs="x86_64*"
+build_style=cmake
+hostmakedepends="cmake"
+makedepends="llvm clang clang-tools-extra SPIRV-LLVM-Translator-devel"
+short_desc="oneAPI Level Zero Specification"
+maintainer="Zlice <zlice555@gmail.com>"
+license="NCSA"
+homepage="https://github.com/oneapi-src/level-zero"
+distfiles="${homepage}/archive/refs/tags/v${version}.tar.gz"
+checksum=2811e4128ff6114020d0a147c2769b9b2e782e68ad49827685c33b9e716bf6ab
+
+post_install() {
+	vlicense LICENSE
+}
+
+level-zero-devel_package() {
+	depends="${makedepends} ${sourcepkg}-${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.so"
+	}
+}

From 90f819a322fb212ca0df88678638ed6d1371348d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 28 Mar 2023 19:54:49 -0400
Subject: [PATCH 124/140] New package: intel-metrics-library 1.0.133

---
 srcpkgs/intel-metrics-library/template | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
 create mode 100644 srcpkgs/intel-metrics-library/template

diff --git a/srcpkgs/intel-metrics-library/template b/srcpkgs/intel-metrics-library/template
new file mode 100644
index 000000000000..50f1a6079d7b
--- /dev/null
+++ b/srcpkgs/intel-metrics-library/template
@@ -0,0 +1,19 @@
+# Template file for 'intel-metrics-library'
+pkgname=intel-metrics-library
+version=1.0.133
+revision=1
+archs="x86_64*"
+build_style=cmake
+configure_args="-Wdev-no -DCMAKE_BUILD_TYPE=Release"
+hostmakedepends="cmake"
+makedepends="libdrm-devel"
+short_desc="Helper library that provides access to GPU performance counters"
+maintainer="Zlice <zlice555@gmail.com>"
+license="MIT"
+homepage="https://github.com/intel/metrics-library"
+distfiles="${homepage}/archive/refs/tags/metrics-library-${version}.tar.gz"
+checksum=83f7b2de3af5ffd2f1b487df8836e6d212e11668bd958bebae622a483fb1231f
+
+post_install() {
+	vlicense LICENSE.md
+}

From 71269b488067d3bf9cb73f2e07f26046c0193166 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 28 Mar 2023 19:54:18 -0400
Subject: [PATCH 125/140] New package: intel-metrics-discovery 1.12.163

---
 srcpkgs/intel-metrics-discovery/template | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
 create mode 100644 srcpkgs/intel-metrics-discovery/template

diff --git a/srcpkgs/intel-metrics-discovery/template b/srcpkgs/intel-metrics-discovery/template
new file mode 100644
index 000000000000..6083595e273c
--- /dev/null
+++ b/srcpkgs/intel-metrics-discovery/template
@@ -0,0 +1,19 @@
+# Template file for 'intel-metrics-discovery'
+pkgname=intel-metrics-discovery
+version=1.12.163
+revision=1
+archs="x86_64*"
+build_style=cmake
+configure_args="-Wdev-no -DCMAKE_BUILD_TYPE=Release"
+hostmakedepends="cmake"
+makedepends="libdrm-devel"
+short_desc="Helper library that provides access to GPU performance data"
+maintainer="Zlice <zlice555@gmail.com>"
+license="MIT"
+homepage="https://github.com/intel/metrics-discovery"
+distfiles="${homepage}/archive/refs/tags/metrics-discovery-${version}.tar.gz"
+checksum=6dfe8d11c58625bf3ebf656ec2a95dc96bbb05705ec71c6c3c3dd0ef5cd2319c
+
+post_install() {
+	vlicense LICENSE.md
+}

From b1030763a537fc9434ff74d5f6918980ae34f426 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 26 Mar 2023 10:48:34 -0400
Subject: [PATCH 126/140] New package: intel-graphics-compiler-1.0.13463.18

---
 srcpkgs/intel-graphics-compiler/template | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 srcpkgs/intel-graphics-compiler/template

diff --git a/srcpkgs/intel-graphics-compiler/template b/srcpkgs/intel-graphics-compiler/template
new file mode 100644
index 000000000000..44d38214f929
--- /dev/null
+++ b/srcpkgs/intel-graphics-compiler/template
@@ -0,0 +1,22 @@
+# Template file for 'intel-graphics-compiler'
+pkgname=intel-graphics-compiler
+version=1.0.13463.18
+revision=1
+archs="x86_64*"
+build_style=cmake
+configure_args="-Wno-dev -DIGC_OPTION__LLVM_PREFERRED_VERSION=15.0.7 -DCCLANG_FROM_SYSTEM=ON
+ -DIGC_OPTION__SPIRV_TOOLS_MODE=Prebuilds -DIGC_OPTION__USE_PREINSTALLED_SPRIV_HEADERS=ON
+ -DIGC_OPTION__VC_INTRINSICS_MODE=Prebuilds"
+hostmakedepends="flex bison zlib-devel libzstd-devel cmake"
+makedepends="llvm clang clang-tools-extra intel-opencl-clang intel-vc-intrinsics
+ lld lld-devel SPIRV-Headers  SPIRV-LLVM-Translator-devel SPIRV-Tools-devel"
+short_desc="LLVM based compiler for OpenCL targeting Intel"
+maintainer="Zlice <zlice555@gmail.com>"
+license="MIT"
+homepage="https://github.com/intel/intel-graphics-compiler"
+distfiles="${homepage}/archive/refs/tags/igc-${version}.tar.gz"
+checksum=0b960878a5feffd6aa10197c48bf73a0a3a19d0105428d48163e91db0444070a
+
+post_install() {
+	vlicense LICENSE.md
+}

From 2bb11d6c0bac0e04e6ff0a5d47982b7d74f8afec Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 26 Mar 2023 10:48:05 -0400
Subject: [PATCH 127/140] New package: intel-compute-runtime-23.09.25812.14

---
 srcpkgs/intel-compute-runtime/template | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 srcpkgs/intel-compute-runtime/template

diff --git a/srcpkgs/intel-compute-runtime/template b/srcpkgs/intel-compute-runtime/template
new file mode 100644
index 000000000000..1132b830d348
--- /dev/null
+++ b/srcpkgs/intel-compute-runtime/template
@@ -0,0 +1,22 @@
+# Template file for 'intel-compute-runtime'
+pkgname=intel-compute-runtime
+version=23.09.25812.14
+revision=1
+archs="x86_64"
+build_style=cmake
+configure_args="-Wno-dev -DNEO_SKIP_UNIT_TESTS=1 -DSUPPORT_DG1=ON -DSUPPORT_DG2=ON"
+hostmakedepends="cmake pkg-config"
+makedepends="gcc intel-gmmlib-devel libva-devel ocl-icd-devel
+ intel-opencl-clang intel-graphics-compiler level-zero-devel
+ intel-metrics-library intel-metrics-discovery"
+depends="intel-graphics-compiler"
+short_desc="Intel Graphics Compute Runtime for oneAPI Level Zero and OpenCL"
+maintainer="Zlice <zlice555@gmail.com>"
+license="MIT"
+homepage="https://github.com/intel/compute-runtime"
+distfiles="${homepage}/archive/refs/tags/${version}.tar.gz"
+checksum=abe2e6d9d2ac771d5f42ee2357ce897ca3b00dc6185c06f3f62772f729c7f8e1
+
+post_install() {
+	vlicense LICENSE.md
+}

From e5a080b117dea40421ac0297c1012ec5f3016c23 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 26 Mar 2023 10:46:58 -0400
Subject: [PATCH 128/140] New package: intel-vc-intrinsics-0.12.3

---
 srcpkgs/intel-vc-intrinsics/template | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
 create mode 100644 srcpkgs/intel-vc-intrinsics/template

diff --git a/srcpkgs/intel-vc-intrinsics/template b/srcpkgs/intel-vc-intrinsics/template
new file mode 100644
index 000000000000..129482bdf985
--- /dev/null
+++ b/srcpkgs/intel-vc-intrinsics/template
@@ -0,0 +1,21 @@
+# Template file for 'intel-vc-intrinsics'
+pkgname=intel-vc-intrinsics
+version=0.12.3
+revision=1
+archs="x86_64*"
+build_style=cmake
+configure_args="-Wno-dev -DLLVM_DIR=/usr/lib/cmake/llvm -DCMAKE_BUILD_TYPE=Release"
+hostmakedepends="cmake python"
+makedepends="llvm clang clang-tools-extra"
+short_desc="Set of intrinsics on top of core LLVM IR"
+maintainer="Zlice <zlice555@gmail.com>"
+license="MIT"
+homepage="https://github.com/intel/vc-intrinsics"
+distfiles="${homepage}/archive/refs/tags/v${version}.tar.gz"
+checksum=ed1c0d968cb2f8ee7b2840a14c3261639f1700e844fb7d2a89856babffd5e1d1
+
+# TODO: license isn't bundled in tar?
+#       just added 2 days ago... mar 24th 2023
+#post_install() {
+#	vlicense LICENSE.md
+#}

From b4bcfbf802d9db130ac1196625ba761b2a1b32ec Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 26 Mar 2023 10:46:11 -0400
Subject: [PATCH 129/140] New package: intel-opencl-clang-15.0.0

---
 common/shlibs                       |  1 +
 srcpkgs/intel-opencl-clang/template | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+)
 create mode 100644 srcpkgs/intel-opencl-clang/template

diff --git a/common/shlibs b/common/shlibs
index f1675bacfe8b..f2d1be3d8514 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -1008,6 +1008,7 @@ libLLVM-15.so libllvm15-15.0.7_1
 libLLVMSPIRVLib.so.15 SPIRV-LLVM-Translator-15.0.0_1
 libomp.so.5 libomp-15.0.7_1
 libomptarget.so.15 libomp-15.0.7_1
+libopencl-clang.so.15 intel-opencl-clang-15.0.0_1
 libisofs.so.6 libisofs-0.6.24_1
 libmpack.so.0 libmpack-1.0.5_1
 libGeoIP.so.1 libgeoip-1.4.8_1
diff --git a/srcpkgs/intel-opencl-clang/template b/srcpkgs/intel-opencl-clang/template
new file mode 100644
index 000000000000..e6f09f6ad724
--- /dev/null
+++ b/srcpkgs/intel-opencl-clang/template
@@ -0,0 +1,18 @@
+# Template file for 'intel-opencl-clang'
+pkgname=intel-opencl-clang
+version=15.0.0
+revision=1
+archs="x86_64*"
+build_style=cmake
+hostmakedepends="cmake"
+makedepends="llvm clang clang-tools-extra SPIRV-LLVM-Translator-devel"
+short_desc="LLVM linked opencl-clang"
+maintainer="Zlice <zlice555@gmail.com>"
+license="NCSA"
+homepage="https://github.com/intel/opencl-clang"
+distfiles="${homepage}/archive/refs/tags/v${version}.tar.gz"
+checksum=ea179674e52bc8c658e2655f76be467f7052f7d2c37ebcfdb102dce645ad1411
+
+post_install() {
+	vlicense LICENSE
+}

From 6f9616cea0a03dc387f332b20ceff1d710d0d37b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 30 Apr 2023 20:22:25 -0400
Subject: [PATCH 130/140] gstreamer1: update to 1.22.2

---
 srcpkgs/gstreamer1/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gstreamer1/template b/srcpkgs/gstreamer1/template
index 362fe82faec3..571148f2ff33 100644
--- a/srcpkgs/gstreamer1/template
+++ b/srcpkgs/gstreamer1/template
@@ -1,6 +1,6 @@
 # Template file for 'gstreamer1'
 pkgname=gstreamer1
-version=1.22.1
+version=1.22.2
 revision=1
 build_style=meson
 build_helper="gir"
@@ -16,7 +16,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.0-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/gstreamer/gstreamer-${version}.tar.xz"
-checksum=cd3ca759f926763615fdfcea63c9761198c42889bc0615ceec73e22b24fde771
+checksum=b2afe73603921c608ba48969dbb7d743776744bfe5d8059ece241137b7f88e21
 
 pre_check() {
 	# gst_gstdatetime is known to fail according to LFS

From 3c68132e9334771a540b8534f3bf8fd453f67ff7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 30 Apr 2023 20:22:26 -0400
Subject: [PATCH 131/140] gst-plugins-base1: update to 1.22.2

---
 srcpkgs/gst-plugins-base1/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-plugins-base1/template b/srcpkgs/gst-plugins-base1/template
index 6d2cad16f985..2f20ea819849 100644
--- a/srcpkgs/gst-plugins-base1/template
+++ b/srcpkgs/gst-plugins-base1/template
@@ -1,6 +1,6 @@
 # Template file for 'gst-plugins-base1'
 pkgname=gst-plugins-base1
-version=1.22.1
+version=1.22.2
 revision=1
 build_style=meson
 build_helper="gir"
@@ -22,7 +22,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname/1/}/${pkgname/1/}-${version}.tar.xz"
-checksum=59bcaeacc5646b8dbdcfa4ef20ca6e818dd234910efb4cee1bbea441a3801c69
+checksum=eb65120c4ee79b7a153c3c1972d5c0158c2151877cc51ec7725bba5749679d49
 
 build_options="cdparanoia gir sndio wayland"
 build_options_default="cdparanoia gir wayland"

From 0447b402127d10a7baa60c971a06b18553cda909 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 30 Apr 2023 20:22:26 -0400
Subject: [PATCH 132/140] gst-plugins-good1: update to 1.22.2

---
 srcpkgs/gst-plugins-good1/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-plugins-good1/template b/srcpkgs/gst-plugins-good1/template
index 00baa6732c75..5d0fe1bfe284 100644
--- a/srcpkgs/gst-plugins-good1/template
+++ b/srcpkgs/gst-plugins-good1/template
@@ -1,6 +1,6 @@
 # Template file for 'gst-plugins-good1'
 pkgname=gst-plugins-good1
-version=1.22.1
+version=1.22.2
 revision=1
 build_style=meson
 configure_args="-Ddv=disabled -Ddv1394=disabled -Dshout2=disabled -Dqt5=enabled
@@ -22,7 +22,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname/1/}/${pkgname/1/}-${version}.tar.xz"
-checksum=44f9104654b4fd042aebe90932ab92e7ff7d8460fbc05b23dad87dffe70974cc
+checksum=7c8cc59425f2b232f60ca7d13e56edd615da4f711e73dd01a7cffa46e6bc0cdd
 
 build_options="gtk3 wayland"
 build_options_default="gtk3 wayland"

From 02af2e3e649d84a7e11490b4ce2371bacb8f308d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 30 Apr 2023 20:22:26 -0400
Subject: [PATCH 133/140] gst-plugins-bad1: update to 1.22.2

---
 srcpkgs/gst-plugins-bad1/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index 7f272f915ac4..77bf79981c20 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-plugins-bad1'
 pkgname=gst-plugins-bad1
-version=1.22.1
-revision=2
+version=1.22.2
+revision=1
 build_helper="gir"
 build_style=meson
 configure_args="-Dpackage-origin=https://voidlinux.org -Ddoc=disabled
@@ -36,7 +36,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later, LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname/1/}/${pkgname/1/}-${version}.tar.xz"
-checksum=2f39b6f222d98666f9ff420a00233e336949953a846237c2bfafc8805f509f0e
+checksum=3d8faf1ce3402c8535ce3a8c4e1a6c960e4b5655dbda6b55943db9ac79022d0f
 
 build_options="gir gme wayland"
 build_options_default="gir wayland"

From 1067e101a40008f3dcc2958e12826a7bb7ef4782 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 30 Apr 2023 20:22:26 -0400
Subject: [PATCH 134/140] gst-plugins-ugly1: update to 1.22.2

---
 srcpkgs/gst-plugins-ugly1/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-plugins-ugly1/template b/srcpkgs/gst-plugins-ugly1/template
index 5647c012c9fe..85ae64bc7a0a 100644
--- a/srcpkgs/gst-plugins-ugly1/template
+++ b/srcpkgs/gst-plugins-ugly1/template
@@ -1,6 +1,6 @@
 # Template file for 'gst-plugins-ugly1'
 pkgname=gst-plugins-ugly1
-version=1.22.1
+version=1.22.2
 revision=1
 build_style=meson
 configure_args="-Damrnb=disabled -Damrwbdec=disabled -Dsidplay=disabled"
@@ -15,4 +15,4 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname/1/}/${pkgname/1/}-${version}.tar.xz"
-checksum=4ab3d9e13481bce1ca3c7c4bb1f65dce4f0bb40fb1cac4416e8c06dd648815c2
+checksum=8f30f44db0bd063709bf6fbe55138e3a98af0abcb61c360f35582bbe10e80691

From 4bea475dc6a93f55a479f17fb32ba564083c6a33 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 30 Apr 2023 20:22:26 -0400
Subject: [PATCH 135/140] gst-omx: update to 1.22.2

---
 srcpkgs/gst-omx/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-omx/template b/srcpkgs/gst-omx/template
index 76692c2a13f6..5ad54cc7b9d8 100644
--- a/srcpkgs/gst-omx/template
+++ b/srcpkgs/gst-omx/template
@@ -1,6 +1,6 @@
 # Template file for 'gst-omx'
 pkgname=gst-omx
-version=1.22.1
+version=1.22.2
 revision=1
 build_style=meson
 configure_args="-Dexamples=disabled -Dtarget=generic"
@@ -11,4 +11,4 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.1-only"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname}/${pkgname}-${version}.tar.xz"
-checksum=2d37f60cd33e68dcef0bcd09b2dd8a0b2eb3ab6d6ac172dca46f70eb02756687
+checksum=1b0c57f2cc4ddeec5e7f0c436e502f06665c4e93c73261855b94e04fc94337b2

From bc1ad2483f42e78ecd04d7ec5719a00484e769f4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 30 Apr 2023 20:22:26 -0400
Subject: [PATCH 136/140] gst-rtsp-server: update to 1.22.2

---
 srcpkgs/gst-rtsp-server/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index ded9a69a2e9d..2f0c0c45ff82 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,6 +1,6 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
-version=1.22.1
+version=1.22.2
 revision=1
 build_style=meson
 hostmakedepends="pkg-config python3"
@@ -11,4 +11,4 @@ maintainer="1is7ac3 <isaac.qa13@gmail.com>"
 license="LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname}/${pkgname}-${version}.tar.xz"
-checksum=4e0b972608f67d5d8f5363c827cfcf132b0e00877be6f1905358d514249b05a3
+checksum=2be4aecfb88710100ea7115ed0216403e8094344ebf146094271b8d4d73828bf

From 81805936cd502dfdcaefad8fa2440cedb5afb593 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 30 Apr 2023 20:22:26 -0400
Subject: [PATCH 137/140] gst1-editing-services: update to 1.22.2

---
 srcpkgs/gst1-editing-services/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst1-editing-services/template b/srcpkgs/gst1-editing-services/template
index f2045ad6043c..102440f7f253 100644
--- a/srcpkgs/gst1-editing-services/template
+++ b/srcpkgs/gst1-editing-services/template
@@ -1,6 +1,6 @@
 # Template file for 'gst1-editing-services'
 pkgname=gst1-editing-services
-version=1.22.1
+version=1.22.2
 revision=1
 build_style=meson
 build_helper="gir"
@@ -12,7 +12,7 @@ maintainer="Toyam Cox <Vaelatern@gmail.com>"
 license="LGPL-2.0-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname/gst1/gst}/${pkgname/gst1/gst}-${version}.tar.xz"
-checksum=0f9e5e08ef80a4b9a0e971c5f032b13c71aa6fef236265c2d615456e15161438
+checksum=453b1464fc3857de269a7cb0ebd966afe02171d97bef672a0b8a0a6d43e0cebf
 
 do_check() {
 	: # Tests fail in older versions as well

From ffcb63dfd50b81c480c7db576d97968898bc60ac Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 30 Apr 2023 20:22:26 -0400
Subject: [PATCH 138/140] gst1-python3: update to 1.22.2

---
 srcpkgs/gst1-python3/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst1-python3/template b/srcpkgs/gst1-python3/template
index 7a8d094ef61f..789e40f036ea 100644
--- a/srcpkgs/gst1-python3/template
+++ b/srcpkgs/gst1-python3/template
@@ -1,6 +1,6 @@
 # Template file for 'gst1-python3'
 pkgname=gst1-python3
-version=1.22.1
+version=1.22.2
 revision=1
 build_style=meson
 hostmakedepends="pkg-config python3"
@@ -11,4 +11,4 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/gst-python/gst-python-${version}.tar.xz"
-checksum=96008a441d685a64275a515b893ccad0fea1d560c43acd0763533e17f3a13ebb
+checksum=bef2b3d82ce4be46b775b1bb56305c1003ee01b535a53a82f9fe8924972153ad

From 81fd5645d7ad253c01bc8704beb7bc502ff19bab Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 30 Apr 2023 20:22:26 -0400
Subject: [PATCH 139/140] gstreamer-vaapi: update to 1.22.2

---
 srcpkgs/gstreamer-vaapi/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gstreamer-vaapi/template b/srcpkgs/gstreamer-vaapi/template
index c100d99e9af1..0a5ee8b1ca3f 100644
--- a/srcpkgs/gstreamer-vaapi/template
+++ b/srcpkgs/gstreamer-vaapi/template
@@ -1,6 +1,6 @@
 # Template file for 'gstreamer-vaapi'
 pkgname=gstreamer-vaapi
-version=1.22.1
+version=1.22.2
 revision=1
 build_style=meson
 hostmakedepends="pkg-config"
@@ -11,7 +11,7 @@ license="LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
 changelog="https://raw.githubusercontent.com/GStreamer/gstreamer-vaapi/master/ChangeLog"
 distfiles="${homepage}/src/gstreamer-vaapi/gstreamer-vaapi-${version}.tar.xz"
-checksum=423b57db7fc5f9137dadf17cb3853a47438d63cd4ba6889a882e63fb5be997bc
+checksum=d2e642f9745f97d9f73a7f5085e7659a9a31fe209b774e6e45dae041b435df06
 
 pre_check() {
 	# Seems to need certain hardware to pass

From 1a380ed32a8c3fe5d508cc6a4af5f72f9e965b8c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 30 Apr 2023 20:22:26 -0400
Subject: [PATCH 140/140] gst-libav: update to 1.22.2

---
 srcpkgs/gst-libav/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index a2c97bfbcdb9..8c72fc3e97ee 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,6 +1,6 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
-version=1.22.1
+version=1.22.2
 revision=1
 build_style=meson
 hostmakedepends="pkg-config yasm"
@@ -11,7 +11,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.0-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname}/${pkgname}-${version}.tar.xz"
-checksum=c958e825dc3ac3b7a481f8db5268131a1cd701312385c2d803dc63c8e460b5fb
+checksum=fcaaf9878fe8f3bc82317ef13a1558824cb68df1f8968c6797f556c5e33bcffd
 
 case "$XBPS_TARGET_MACHINE" in
 	*-musl) # Required by musl for M_SQRT1_2

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
@ 2023-05-05 13:27 ` zlice
  2023-05-05 13:53 ` zlice
                   ` (96 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2023-05-05 13:27 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 2799 bytes --]

There is an updated pull request by zlice against master on the void-packages repository

https://github.com/zlice/void-packages ffmpeg6-split
https://github.com/void-linux/void-packages/pull/43761

ffmpeg6 split
[ci skip]


#### Testing the changes

- I tested the changes in this PR: **YES**

main testing has been vaapi in Firefox Nightly and enc/dec in Shotcut on Intel A770

#### New package

- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**

#### Local build testing

- I built this PR locally for my native architecture, **x86_64**

#### Discussion

Continuation of https://github.com/void-linux/void-packages/pull/36315

`libavresample` is deprecated, but marked as a dependency when trying to build other packages and install `ffmpeg`(5). I think the right way to handle this is make a meta package and the add to removals?


##### Commit naming / misc

Commits are 'dirty' right now, running with [gstreamer 1.22.1 updates](https://github.com/void-linux/void-packages/pull/42861) and [Intel OpenCL](https://github.com/void-linux/void-packages/pull/43084). This will also make [intel packages pr](https://github.com/void-linux/void-packages/pull/41132) obsolete.

Maintainer for previous ffmpeg(4) was orphaned, I can put my name in there if that matters, though I don't exactly see myself keeping up on ffmpeg.

This updates QT5 which looks like it is usually hosted by Johnny. Not sure if there's any reason to stay there or these sources are fine.

##### STILL FFMPEG4

These are a mix of emulators, games and/or older packages.

- attract (multiple patches in master)
- audacity  (3.2.x should work but void is missing some libs? vst3sdk?)
- ccextractor (master patches? no release)
- vice
- kodi
- mlt
- synfig (mlt)
- tvheadend
- ssr
- spek-alternative
- ppsspp
- olive
- moc
- mediastreamer
- libextractor
- idjc
- hedgewars
- ffmpegthumbnailer
- ffmpegthumbs
- deadbeef
- omxplayer
- qtav (fork has ffmpeg 5 patch - https://github.com/cmguo/QtAV)
- `vlc` (vlc4 will support ffmpeg5, there's a patch to build 3.x with ffmpeg5 but it will lack vaapi)
- `osg` (OpenSceneGraph plus `xine-lib`)
- `ytmdl` ? not sure but it uses `python3-ffmpeg-python` which being 6-8yr old I imagine is ffmpeg4


##### HAVE NOT BUILT YET

- omxplayer (rpi only?)
- kodi (big, but ffmpeg4)


##### UPDATED (for ffmpeg5)

- unpaper: update to 7.0.0.
- guvcview: update to 2.0.8.
- qt5: update to 5.15.8
- qt5-webengine: update to 5.18.13
- shiboken2: revbump for qt5.15.8 (patch)
- python3-pyside2: update to 5.15.8 (patch)


A patch file from https://github.com/void-linux/void-packages/pull/43761.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ffmpeg6-split-43761.patch --]
[-- Type: text/x-diff, Size: 822699 bytes --]

From 6d537689f78de1b6595fed56dcb67c7a180b5fbf Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:55:46 -0400
Subject: [PATCH 001/140] ffmpeg: update to 6.0.

---
 common/shlibs                                 | 26 +++++---
 srcpkgs/ffmpeg/files/altivec.patch            | 60 -------------------
 .../patches/armv5tel-floating-point.patch     | 18 ------
 .../workaround-mesa-readeon-vaapi-bug.patch   | 28 ---------
 srcpkgs/ffmpeg/template                       | 31 +++++-----
 5 files changed, 33 insertions(+), 130 deletions(-)
 delete mode 100644 srcpkgs/ffmpeg/files/altivec.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch

diff --git a/common/shlibs b/common/shlibs
index 8c47e79b8c43..d650f2a3045d 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -390,15 +390,23 @@ libid3tag.so.0 libid3tag-0.15.1b_1
 libgif.so.7 giflib-5.1.0_1
 libImlib2.so.1 imlib2-1.4.2_1
 libmp3lame.so.0 lame-3.98.2_1
-libavdevice.so.58 libavdevice-4.0_1
-libavformat.so.58 libavformat-4.0_1
-libswscale.so.5 libswscale-4.0_1
-libswresample.so.3 libswresample-4.0_1
-libavresample.so.4 libavresample-4.0_1
-libpostproc.so.55 libpostproc-4.0_1
-libavcodec.so.58 libavcodec-4.0_1
-libavutil.so.56 libavutil-4.0_1
-libavfilter.so.7 libavfilter-4.0_1
+libavdevice.so.60 libavdevice-6.0_1
+libavformat.so.60 libavformat-6.0_1
+libswscale.so.7 libswscale-6.0_1
+libswresample.so.4 libswresample-6.0_1
+libpostproc.so.57 libpostproc-6.0_1
+libavcodec.so.60 libavcodec-6.0_1
+libavutil.so.58 libavutil-6.0_1
+libavfilter.so.9 libavfilter-6.0_1
+libavdevice.so.58 libavdevice4-4.0_1
+libavformat.so.58 libavformat4-4.0_1
+libswscale.so.5 libswscale4-4.0_1
+libswresample.so.3 libswresample4-4.0_1
+libavresample.so.4 libavresample4-4.0_1
+libpostproc.so.55 libpostproc4-4.0_1
+libavcodec.so.58 libavcodec4-4.0_1
+libavutil.so.56 libavutil4-4.0_1
+libavfilter.so.7 libavfilter4-4.0_1
 libSDL-1.2.so.0 SDL-1.2.14_1
 libSDL_image-1.2.so.0 SDL_image-1.2.10_1
 libx264.so.157 x264-20190507.2245_1
diff --git a/srcpkgs/ffmpeg/files/altivec.patch b/srcpkgs/ffmpeg/files/altivec.patch
deleted file mode 100644
index 9c5720046332..000000000000
--- a/srcpkgs/ffmpeg/files/altivec.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-revert some altivec specific change on all ppc* except ppc64le*
-
-q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
-conditionally, for ppc* but not ppc64le* (the new code is valid for
-POWER8 VSX which LE targets as a baseline but not BE)"
-
-
-This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
----
- libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
- 1 file changed, 20 insertions(+), 4 deletions(-)
-
-diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
-index 536545293d..c1e2852adb 100644
---- a/libswscale/ppc/yuv2rgb_altivec.c
-+++ b/libswscale/ppc/yuv2rgb_altivec.c
-@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-     vector signed short R1, G1, B1;                                           \
-     vector unsigned char R, G, B;                                             \
-                                                                               \
-+    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
-+    vector unsigned char align_perm;                                          \
-+                                                                              \
-     vector signed short lCY       = c->CY;                                    \
-     vector signed short lOY       = c->OY;                                    \
-     vector signed short lCRV      = c->CRV;                                   \
-@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
-                                                                               \
-         for (j = 0; j < w / 16; j++) {                                        \
--            y0 = vec_xl(0, y1i);                                              \
-+            y1ivP = (const vector unsigned char *) y1i;                       \
-+            y2ivP = (const vector unsigned char *) y2i;                       \
-+            uivP  = (const vector unsigned char *) ui;                        \
-+            vivP  = (const vector unsigned char *) vi;                        \
-+                                                                              \
-+            align_perm = vec_lvsl(0, y1i);                                    \
-+            y0 = (vector unsigned char)                                       \
-+                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
-                                                                               \
--            y1 = vec_xl(0, y2i);                                              \
-+            align_perm = vec_lvsl(0, y2i);                                    \
-+            y1 = (vector unsigned char)                                       \
-+                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
-                                                                               \
--            u = (vector signed char) vec_xl(0, ui);                           \
-+            align_perm = vec_lvsl(0, ui);                                     \
-+            u = (vector signed char)                                          \
-+                    vec_perm(uivP[0], uivP[1], align_perm);                   \
-                                                                               \
--            v = (vector signed char) vec_xl(0, vi);                           \
-+            align_perm = vec_lvsl(0, vi);                                     \
-+            v = (vector signed char)                                          \
-+                    vec_perm(vivP[0], vivP[1], align_perm);                   \
-                                                                               \
-             u = (vector signed char)                                          \
-                     vec_sub(u,                                                \
--- 
-2.27.0
-
diff --git a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
deleted file mode 100644
index 9a55178c74f0..000000000000
--- a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
-+++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
-@@ -39,6 +39,15 @@
- #endif
- #include <fenv.h>
- 
-+#if (FE_ALL_EXCEPT == 0)
-+/* E.g. ARM soft float does not define these */
-+#define FE_INVALID    0
-+#define FE_DIVBYZERO  0
-+#define FE_OVERFLOW   0
-+#define FE_UNDERFLOW  0
-+#define FE_INEXACT    0
-+#endif
-+
- #if CONFIG_LIBFONTCONFIG
- #include <fontconfig/fontconfig.h>
- #endif
diff --git a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
deleted file mode 100644
index 00e3f68a415b..000000000000
--- a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
-From: Rainer Hochecker <fernetmenta@online.de>
-Date: Sat, 26 Jan 2019 19:48:35 +0100
-Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
-
-This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
-It was hit frequently when watching h264 channels received via DVB-X.
-Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
----
- libavcodec/vaapi_h264.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
-index 5854587a255..f12fdc457a4 100644
---- a/libavcodec/vaapi_h264.c
-+++ b/libavcodec/vaapi_h264.c
-@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
-     H264SliceContext *sl = &h->slice_ctx[0];
-     int ret;
- 
-+    if (pic->nb_slices == 0) {
-+        ret = AVERROR_INVALIDDATA;
-+        goto finish;
-+    }
-+
-     ret = ff_vaapi_decode_issue(avctx, pic);
-     if (ret < 0)
-         goto finish;
diff --git a/srcpkgs/ffmpeg/template b/srcpkgs/ffmpeg/template
index 23a3d5c9967b..3d99e5173697 100644
--- a/srcpkgs/ffmpeg/template
+++ b/srcpkgs/ffmpeg/template
@@ -1,15 +1,15 @@
 # Template file for 'ffmpeg'
 # audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
 pkgname=ffmpeg
-version=4.4.3
-revision=2
+version=6.0
+revision=1
 short_desc="Decoding, encoding and streaming software"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="https://www.ffmpeg.org"
 changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
 distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
-checksum=6c5b6c195e61534766a0b5fe16acc919170c883362612816d0a1c7f4f947006e
+checksum=57be87c22d9b49c112b6d24bc67d42508660e6b718b3db89c44e47e289137082
 
 hostmakedepends="pkg-config perl yasm"
 makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
@@ -26,12 +26,13 @@ makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-deve
  $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
  $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
  $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
- $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers Vulkan-Tools Vulkan-ValidationLayers')
+ $(vopt_if onevpl 'onevpl onevpl-devel')
  $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
 depends="ffplay>=${version}_${revision}"
 
 build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
- dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec onevpl"
 build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
 desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
 desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
@@ -39,7 +40,8 @@ desc_option_sofa="Enable support for AES SOFA"
 desc_option_webp="Enable support for WebP"
 
 case "$XBPS_TARGET_MACHINE" in
-	i686*|x86_64*) build_options_default+=" vaapi vdpau nvenc nvdec";;
+	i686*) build_options_default+=" vaapi vdpau nvenc nvdec";;
+	x86_64*) build_options_default+=" vaapi vdpau nvenc nvdec onevpl";;
 	ppc64*) build_options_default+=" vaapi vdpau";;
 	mips*) CFLAGS="-mnan=legacy";;
 esac
@@ -114,18 +116,19 @@ do_configure() {
 		$(vopt_enable x265 libx265) \
 		$(vopt_enable v4l2 libv4l2) \
 		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
-		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		--enable-libbs2b --enable-libvidstab \
 		$(vopt_enable dav1d libdav1d) \
 		$(vopt_enable zimg libzimg) \
 		$(vopt_enable webp libwebp) \
 		$(vopt_enable sofa libmysofa) \
 		$(vopt_enable vulkan) \
+		$(vopt_enable onevpl libvpl) \
 		$(vopt_enable drm libdrm) \
 		$(vopt_enable svtav1 libsvtav1) \
 		$(vopt_enable srt libsrt) \
 		$(vopt_enable rist librist) \
-		$(vopt_if nvenc '--enable-nvenc') \
-		$(vopt_if nvdec '--enable-nvdec')
+		$(vopt_enable nvenc nvenc) \
+		$(vopt_enable nvdec nvdec)
 }
 do_build() {
 	make ${makejobs}
@@ -148,10 +151,8 @@ libavdevice_package() {
 	}
 }
 libavresample_package() {
-	short_desc="FFmpeg audio resampling library"
-	pkg_install() {
-		vmove "usr/lib/libavresample.so.*"
-	}
+	short_desc="Package deprecated, removal needed"
+	build_style=meta
 }
 libavformat_package() {
 	short_desc="FFmpeg file format library"
@@ -198,9 +199,9 @@ ffmpeg-devel_package() {
 		libavfilter>=${version}_${revision}
 		libpostproc>=${version}_${revision}
 		libswscale>=${version}_${revision}
-		libswresample>=${version}_${revision}
-		libavresample>=${version}_${revision}"
+		libswresample>=${version}_${revision}"
 	short_desc+=" - development files"
+	conflicts="ffmpeg4-devel"
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig

From 6f50791cd4cb463c5967e0c1431b987e1146b800 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:56:22 -0400
Subject: [PATCH 002/140] New package: ffmpeg4-4.4.3.

---
 srcpkgs/ffmpeg4-devel                         |   1 +
 srcpkgs/ffmpeg4/files/altivec.patch           |  60 +++++
 .../patches/armv5tel-floating-point.patch     |  18 ++
 .../workaround-mesa-readeon-vaapi-bug.patch   |  28 +++
 srcpkgs/ffmpeg4/template                      | 214 ++++++++++++++++++
 srcpkgs/libavcodec4                           |   1 +
 srcpkgs/libavdevice4                          |   1 +
 srcpkgs/libavfilter4                          |   1 +
 srcpkgs/libavformat4                          |   1 +
 srcpkgs/libavresample4                        |   1 +
 srcpkgs/libavutil4                            |   1 +
 srcpkgs/libpostproc4                          |   1 +
 srcpkgs/libswresample4                        |   1 +
 srcpkgs/libswscale4                           |   1 +
 14 files changed, 330 insertions(+)
 create mode 120000 srcpkgs/ffmpeg4-devel
 create mode 100644 srcpkgs/ffmpeg4/files/altivec.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
 create mode 100644 srcpkgs/ffmpeg4/template
 create mode 120000 srcpkgs/libavcodec4
 create mode 120000 srcpkgs/libavdevice4
 create mode 120000 srcpkgs/libavfilter4
 create mode 120000 srcpkgs/libavformat4
 create mode 120000 srcpkgs/libavresample4
 create mode 120000 srcpkgs/libavutil4
 create mode 120000 srcpkgs/libpostproc4
 create mode 120000 srcpkgs/libswresample4
 create mode 120000 srcpkgs/libswscale4

diff --git a/srcpkgs/ffmpeg4-devel b/srcpkgs/ffmpeg4-devel
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/ffmpeg4-devel
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/ffmpeg4/files/altivec.patch b/srcpkgs/ffmpeg4/files/altivec.patch
new file mode 100644
index 000000000000..9c5720046332
--- /dev/null
+++ b/srcpkgs/ffmpeg4/files/altivec.patch
@@ -0,0 +1,60 @@
+revert some altivec specific change on all ppc* except ppc64le*
+
+q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
+conditionally, for ppc* but not ppc64le* (the new code is valid for
+POWER8 VSX which LE targets as a baseline but not BE)"
+
+
+This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
+---
+ libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
+ 1 file changed, 20 insertions(+), 4 deletions(-)
+
+diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
+index 536545293d..c1e2852adb 100644
+--- a/libswscale/ppc/yuv2rgb_altivec.c
++++ b/libswscale/ppc/yuv2rgb_altivec.c
+@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+     vector signed short R1, G1, B1;                                           \
+     vector unsigned char R, G, B;                                             \
+                                                                               \
++    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
++    vector unsigned char align_perm;                                          \
++                                                                              \
+     vector signed short lCY       = c->CY;                                    \
+     vector signed short lOY       = c->OY;                                    \
+     vector signed short lCRV      = c->CRV;                                   \
+@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
+                                                                               \
+         for (j = 0; j < w / 16; j++) {                                        \
+-            y0 = vec_xl(0, y1i);                                              \
++            y1ivP = (const vector unsigned char *) y1i;                       \
++            y2ivP = (const vector unsigned char *) y2i;                       \
++            uivP  = (const vector unsigned char *) ui;                        \
++            vivP  = (const vector unsigned char *) vi;                        \
++                                                                              \
++            align_perm = vec_lvsl(0, y1i);                                    \
++            y0 = (vector unsigned char)                                       \
++                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
+                                                                               \
+-            y1 = vec_xl(0, y2i);                                              \
++            align_perm = vec_lvsl(0, y2i);                                    \
++            y1 = (vector unsigned char)                                       \
++                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
+                                                                               \
+-            u = (vector signed char) vec_xl(0, ui);                           \
++            align_perm = vec_lvsl(0, ui);                                     \
++            u = (vector signed char)                                          \
++                    vec_perm(uivP[0], uivP[1], align_perm);                   \
+                                                                               \
+-            v = (vector signed char) vec_xl(0, vi);                           \
++            align_perm = vec_lvsl(0, vi);                                     \
++            v = (vector signed char)                                          \
++                    vec_perm(vivP[0], vivP[1], align_perm);                   \
+                                                                               \
+             u = (vector signed char)                                          \
+                     vec_sub(u,                                                \
+-- 
+2.27.0
+
diff --git a/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
new file mode 100644
index 000000000000..9a55178c74f0
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
@@ -0,0 +1,18 @@
+--- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
++++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
+@@ -39,6 +39,15 @@
+ #endif
+ #include <fenv.h>
+ 
++#if (FE_ALL_EXCEPT == 0)
++/* E.g. ARM soft float does not define these */
++#define FE_INVALID    0
++#define FE_DIVBYZERO  0
++#define FE_OVERFLOW   0
++#define FE_UNDERFLOW  0
++#define FE_INEXACT    0
++#endif
++
+ #if CONFIG_LIBFONTCONFIG
+ #include <fontconfig/fontconfig.h>
+ #endif
diff --git a/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
new file mode 100644
index 000000000000..00e3f68a415b
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
@@ -0,0 +1,28 @@
+From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
+From: Rainer Hochecker <fernetmenta@online.de>
+Date: Sat, 26 Jan 2019 19:48:35 +0100
+Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
+
+This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
+It was hit frequently when watching h264 channels received via DVB-X.
+Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
+---
+ libavcodec/vaapi_h264.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
+index 5854587a255..f12fdc457a4 100644
+--- a/libavcodec/vaapi_h264.c
++++ b/libavcodec/vaapi_h264.c
+@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
+     H264SliceContext *sl = &h->slice_ctx[0];
+     int ret;
+ 
++    if (pic->nb_slices == 0) {
++        ret = AVERROR_INVALIDDATA;
++        goto finish;
++    }
++
+     ret = ff_vaapi_decode_issue(avctx, pic);
+     if (ret < 0)
+         goto finish;
diff --git a/srcpkgs/ffmpeg4/template b/srcpkgs/ffmpeg4/template
new file mode 100644
index 000000000000..7bc64bb39f41
--- /dev/null
+++ b/srcpkgs/ffmpeg4/template
@@ -0,0 +1,214 @@
+# Template file for 'ffmpeg4'
+# audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
+pkgname=ffmpeg4
+version=4.4.3
+revision=1
+short_desc="Decoding, encoding and streaming software - ffmpeg4 libraries only"
+maintainer="Orphaned <orphan@voidlinux.org>"
+license="GPL-3.0-or-later"
+homepage="https://www.ffmpeg.org"
+changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
+distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
+checksum=6c5b6c195e61534766a0b5fe16acc919170c883362612816d0a1c7f4f947006e
+
+hostmakedepends="pkg-config perl yasm"
+makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
+ libXext-devel libXvMC-devel libxcb-devel lame-devel libtheora-devel
+ libvorbis-devel x264-devel xvidcore-devel jack-devel SDL2-devel
+ libcdio-paranoia-devel librtmp-devel libmodplug-devel gnutls-devel
+ speex-devel celt-devel harfbuzz-devel libass-devel opus-devel ocl-icd-devel
+ libbs2b-devel libvidstab-devel $(vopt_if pulseaudio pulseaudio-devel)
+ $(vopt_if vaapi libva-devel) $(vopt_if vdpau libvdpau-devel)
+ $(vopt_if x265 x265-devel) $(vopt_if v4l2 v4l-utils-devel)
+ $(vopt_if fdk_aac fdk-aac-devel) $(vopt_if vpx libvpx-devel)
+ $(vopt_if aom libaom-devel) $(vopt_if sndio sndio-devel)
+ $(vopt_if dav1d libdav1d-devel) $(vopt_if zimg zimg-devel)
+ $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
+ $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
+ $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
+
+build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
+
+desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
+desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
+desc_option_sofa="Enable support for AES SOFA"
+desc_option_webp="Enable support for WebP"
+
+case "$XBPS_TARGET_MACHINE" in
+	i686*|x86_64*) build_options_default+=" vaapi vdpau nvenc nvdec";;
+	ppc64*) build_options_default+=" vaapi vdpau";;
+	mips*) CFLAGS="-mnan=legacy";;
+esac
+
+if [ "$XBPS_TARGET_WORDSIZE" != "32" ]; then
+	build_options_default+=" svtav1"
+fi
+
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+fi
+
+_apply_patch() {
+	local args="$1" pname="$(basename $2)"
+
+	if [ ! -f ".${pname}_done" ]; then
+		patch -N $args -i $2
+		touch .${pname}_done
+	fi
+}
+
+post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64le*) ;;
+		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
+	esac
+}
+
+do_configure() {
+	# Fix gcc on x86_64-musl only
+	if [ "$XBPS_TARGET_MACHINE" = "x86_64-musl" ]; then
+		sed -i configure -e "s;_cflags_speed='-O3';_cflags_speed='-O2';"
+	fi
+
+	if [ "$CROSS_BUILD" ]; then
+		case "$XBPS_TARGET_MACHINE" in
+			arm*) _arch="arm";;
+			aarch64*) _arch="aarch64";;
+			mips*) _arch="mips";;
+			ppc64*) _arch="ppc64";;
+			ppc*) _arch="ppc";;
+			*) _arch="${XBPS_TARGET_MACHINE%%-musl}";;
+		esac
+
+		_args+=" --enable-cross-compile
+			--sysroot=$XBPS_CROSS_BASE
+			--cross-prefix=${XBPS_CROSS_TRIPLET}-
+			--target-os=linux --arch=${_arch}"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc|ppc-musl) _args+=" --disable-altivec";;
+	esac
+
+	if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+		_args+=" --extra-libs=-latomic"
+	fi
+
+	./configure --prefix=/usr --disable-debug --enable-gpl --enable-gnutls \
+		--disable-stripping \
+		--enable-libcdio --enable-version3 --enable-runtime-cpudetect \
+		--enable-libmp3lame --enable-libvorbis --enable-libxvid \
+		--enable-libx264 $(vopt_enable vpx libvpx) --enable-libtheora \
+		--enable-shared --enable-static --enable-libxcb \
+		$(vopt_enable pulseaudio libpulse) --enable-libfreetype --enable-libmodplug \
+		--enable-libspeex --enable-libcelt --enable-libass \
+		--enable-libopus --enable-librtmp --enable-libjack \
+		$(vopt_if fdk_aac '--enable-nonfree --enable-libfdk-aac') \
+		--disable-libopencore_amrnb --disable-libopencore_amrwb \
+		--disable-libopenjpeg \
+		--enable-postproc --enable-opencl ${_args} \
+		$(vopt_enable x265 libx265) \
+		$(vopt_enable v4l2 libv4l2) \
+		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
+		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		$(vopt_enable dav1d libdav1d) \
+		$(vopt_enable zimg libzimg) \
+		$(vopt_enable webp libwebp) \
+		$(vopt_enable sofa libmysofa) \
+		$(vopt_enable vulkan) \
+		$(vopt_enable drm libdrm) \
+		$(vopt_enable svtav1 libsvtav1) \
+		$(vopt_enable srt libsrt) \
+		$(vopt_enable rist librist) \
+		$(vopt_if nvenc '--enable-nvenc') \
+		$(vopt_if nvdec '--enable-nvdec')
+}
+do_build() {
+	make ${makejobs}
+	make doc/ff{mpeg,play}.1
+}
+do_install() {
+	make DESTDIR=${DESTDIR} install install-man
+	rm -rf ${DESTDIR}/usr/bin
+}
+
+libavcodec4_package() {
+	short_desc="FFmpeg codec library"
+	pkg_install() {
+		vmove "usr/lib/libavcodec.so.*"
+	}
+}
+libavdevice4_package() {
+	short_desc="FFmpeg device handling library"
+	pkg_install() {
+		vmove "usr/lib/libavdevice.so.*"
+	}
+}
+libavresample4_package() {
+	short_desc="FFmpeg audio resampling library"
+	pkg_install() {
+		vmove "usr/lib/libavresample.so.*"
+	}
+}
+libavformat4_package() {
+	short_desc="FFmpeg file format library"
+	pkg_install() {
+		vmove "usr/lib/libavformat.so.*"
+	}
+}
+libavutil4_package() {
+	short_desc="FFmpeg utility library"
+	pkg_install() {
+		vmove "usr/lib/libavutil.so.*"
+	}
+}
+libavfilter4_package() {
+	short_desc="FFmpeg audio/video filter library"
+	pkg_install() {
+		vmove "usr/lib/libavfilter.so.*"
+	}
+}
+libpostproc4_package() {
+	short_desc="FFmpeg video postprocessing library"
+	pkg_install() {
+		vmove "usr/lib/libpostproc.so.*"
+	}
+}
+libswscale4_package() {
+	short_desc="FFmpeg video scaling library"
+	pkg_install() {
+		vmove "usr/lib/libswscale.so.*"
+	}
+}
+libswresample4_package() {
+	short_desc="FFmpeg video resampling library"
+	pkg_install() {
+		vmove "usr/lib/libswresample.so.*"
+	}
+}
+ffmpeg4-devel_package() {
+	depends="
+		libavcodec4>=${version}_${revision}
+		libavdevice4>=${version}_${revision}
+		libavformat4>=${version}_${revision}
+		libavutil4>=${version}_${revision}
+		libavfilter4>=${version}_${revision}
+		libpostproc4>=${version}_${revision}
+		libswscale4>=${version}_${revision}
+		libswresample4>=${version}_${revision}
+		libavresample4>=${version}_${revision}"
+	short_desc+=" - development files"
+	conflicts="ffmpeg-devel"
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove usr/lib/*.a
+		vmove usr/lib/*.so
+		vmove usr/share/ffmpeg/examples
+		vmove usr/share/man/man3
+	}
+}
diff --git a/srcpkgs/libavcodec4 b/srcpkgs/libavcodec4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavcodec4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavdevice4 b/srcpkgs/libavdevice4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavdevice4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavfilter4 b/srcpkgs/libavfilter4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavfilter4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavformat4 b/srcpkgs/libavformat4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavformat4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavresample4 b/srcpkgs/libavresample4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavutil4 b/srcpkgs/libavutil4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavutil4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libpostproc4 b/srcpkgs/libpostproc4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libpostproc4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswresample4 b/srcpkgs/libswresample4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libswresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswscale4 b/srcpkgs/libswscale4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libswscale4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file

From b456cf2f2dcb036c8810093de5929d40df8c7c7d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:04 -0400
Subject: [PATCH 003/140] opencv: update to 4.7.0.

---
 common/shlibs           | 104 ++++++++++++++++++++--------------------
 srcpkgs/opencv/template |   8 ++--
 2 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index d650f2a3045d..4626cfda810b 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2137,58 +2137,58 @@ libcapstone.so.4 capstone-4.0_1
 libhavege.so.2 libhaveged-1.9.11_1
 libnih.so.1 libnih-1.0.3_1
 libnih-dbus.so.1 libnih-1.0.3_1
-libopencv_quality.so.406 libopencv-4.6.0_1
-libopencv_reg.so.406 libopencv-4.6.0_1
-libopencv_surface_matching.so.406 libopencv-4.6.0_1
-libopencv_xphoto.so.406 libopencv-4.6.0_1
-libopencv_freetype.so.406 libopencv-4.6.0_1
-libopencv_fuzzy.so.406 libopencv-4.6.0_1
-libopencv_hfs.so.406 libopencv-4.6.0_1
-libopencv_img_hash.so.406 libopencv-4.6.0_1
-libopencv_line_descriptor.so.406 libopencv-4.6.0_1
-libopencv_saliency.so.406 libopencv-4.6.0_1
-libopencv_structured_light.so.406 libopencv-4.6.0_1
-libopencv_aruco.so.406 libopencv-4.6.0_1
-libopencv_bgsegm.so.406 libopencv-4.6.0_1
-libopencv_bioinspired.so.406 libopencv-4.6.0_1
-libopencv_ccalib.so.406 libopencv-4.6.0_1
-libopencv_face.so.406 libopencv-4.6.0_1
-libopencv_tracking.so.406 libopencv-4.6.0_1
-libopencv_xfeatures2d.so.406 libopencv-4.6.0_1
-libopencv_optflow.so.406 libopencv-4.6.0_1
-libopencv_ximgproc.so.406 libopencv-4.6.0_1
-libopencv_plot.so.406 libopencv-4.6.0_1
-libopencv_text.so.406 libopencv-4.6.0_1
-libopencv_ml.so.406 libopencv-4.6.0_1
-libopencv_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn.so.406 libopencv-4.6.0_1
-libopencv_shape.so.406 libopencv-4.6.0_1
-libopencv_stitching.so.406 libopencv-4.6.0_1
-libopencv_photo.so.406 libopencv-4.6.0_1
-libopencv_video.so.406 libopencv-4.6.0_1
-libopencv_calib3d.so.406 libopencv-4.6.0_1
-libopencv_features2d.so.406 libopencv-4.6.0_1
-libopencv_flann.so.406 libopencv-4.6.0_1
-libopencv_highgui.so.406 libopencv-4.6.0_1
-libopencv_videoio.so.406 libopencv-4.6.0_1
-libopencv_imgcodecs.so.406 libopencv-4.6.0_1
-libopencv_imgproc.so.406 libopencv-4.6.0_1
-libopencv_core.so.406 libopencv-4.6.0_1
-libopencv_superres.so.406 libopencv-4.6.0_1
-libopencv_videostab.so.406 libopencv-4.6.0_1
-libopencv_gapi.so.406 libopencv-4.6.0_1
-libopencv_xobjdetect.so.406 libopencv-4.6.0_1
-libopencv_datasets.so.406 libopencv-4.6.0_1
-libopencv_dnn_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn_superres.so.406 libopencv-4.6.0_1
-libopencv_dpm.so.406 libopencv-4.6.0_1
-libopencv_phase_unwrapping.so.406 libopencv-4.6.0_1
-libopencv_stereo.so.406 libopencv-4.6.0_1
-libopencv_rapid.so.406 libopencv-4.6.0_1
-libopencv_intensity_transform.so.406 libopencv-4.6.0_1
-libopencv_alphamat.so.406 libopencv-4.6.0_1
-libopencv_barcode.so.406 libopencv-4.6.0_1
-libopencv_mcc.so.406 libopencv-4.6.0_1
+libopencv_quality.so.407 libopencv-4.7.0_1
+libopencv_reg.so.407 libopencv-4.7.0_1
+libopencv_surface_matching.so.407 libopencv-4.7.0_1
+libopencv_xphoto.so.407 libopencv-4.7.0_1
+libopencv_freetype.so.407 libopencv-4.7.0_1
+libopencv_fuzzy.so.407 libopencv-4.7.0_1
+libopencv_hfs.so.407 libopencv-4.7.0_1
+libopencv_img_hash.so.407 libopencv-4.7.0_1
+libopencv_line_descriptor.so.407 libopencv-4.7.0_1
+libopencv_saliency.so.407 libopencv-4.7.0_1
+libopencv_structured_light.so.407 libopencv-4.7.0_1
+libopencv_aruco.so.407 libopencv-4.7.0_1
+libopencv_bgsegm.so.407 libopencv-4.7.0_1
+libopencv_bioinspired.so.407 libopencv-4.7.0_1
+libopencv_ccalib.so.407 libopencv-4.7.0_1
+libopencv_face.so.407 libopencv-4.7.0_1
+libopencv_tracking.so.407 libopencv-4.7.0_1
+libopencv_xfeatures2d.so.407 libopencv-4.7.0_1
+libopencv_optflow.so.407 libopencv-4.7.0_1
+libopencv_ximgproc.so.407 libopencv-4.7.0_1
+libopencv_plot.so.407 libopencv-4.7.0_1
+libopencv_text.so.407 libopencv-4.7.0_1
+libopencv_ml.so.407 libopencv-4.7.0_1
+libopencv_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn.so.407 libopencv-4.7.0_1
+libopencv_shape.so.407 libopencv-4.7.0_1
+libopencv_stitching.so.407 libopencv-4.7.0_1
+libopencv_photo.so.407 libopencv-4.7.0_1
+libopencv_video.so.407 libopencv-4.7.0_1
+libopencv_calib3d.so.407 libopencv-4.7.0_1
+libopencv_features2d.so.407 libopencv-4.7.0_1
+libopencv_flann.so.407 libopencv-4.7.0_1
+libopencv_highgui.so.407 libopencv-4.7.0_1
+libopencv_videoio.so.407 libopencv-4.7.0_1
+libopencv_imgcodecs.so.407 libopencv-4.7.0_1
+libopencv_imgproc.so.407 libopencv-4.7.0_1
+libopencv_core.so.407 libopencv-4.7.0_1
+libopencv_superres.so.407 libopencv-4.7.0_1
+libopencv_videostab.so.407 libopencv-4.7.0_1
+libopencv_gapi.so.407 libopencv-4.7.0_1
+libopencv_xobjdetect.so.407 libopencv-4.7.0_1
+libopencv_datasets.so.407 libopencv-4.7.0_1
+libopencv_dnn_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn_superres.so.407 libopencv-4.7.0_1
+libopencv_dpm.so.407 libopencv-4.7.0_1
+libopencv_phase_unwrapping.so.407 libopencv-4.7.0_1
+libopencv_stereo.so.407 libopencv-4.7.0_1
+libopencv_rapid.so.407 libopencv-4.7.0_1
+libopencv_intensity_transform.so.407 libopencv-4.7.0_1
+libopencv_alphamat.so.407 libopencv-4.7.0_1
+libopencv_barcode.so.407 libopencv-4.7.0_1
+libopencv_mcc.so.407 libopencv-4.7.0_1
 libuniconf.so.4.6 wvstreams-4.6.1_20
 libwvbase.so.4.6 wvstreams-4.6.1_20
 libwvutils.so.4.6 wvstreams-4.6.1_20
diff --git a/srcpkgs/opencv/template b/srcpkgs/opencv/template
index 69c635b1ad2b..41f3183f1582 100644
--- a/srcpkgs/opencv/template
+++ b/srcpkgs/opencv/template
@@ -1,7 +1,7 @@
 # Template file for 'opencv'
 pkgname=opencv
-version=4.6.0
-revision=4
+version=4.7.0
+revision=1
 create_wrksrc=yes
 build_wrksrc=${pkgname}-${version}
 build_style=cmake
@@ -24,8 +24,8 @@ homepage="https://opencv.org"
 changelog="https://github.com/opencv/opencv/wiki/ChangeLog"
 distfiles="https://github.com/opencv/opencv/archive/${version}.tar.gz
  https://github.com/opencv/opencv_contrib/archive/${version}.tar.gz>contrib.tar.gz"
-checksum="1ec1cba65f9f20fe5a41fda1586e01c70ea0c9a6d7b67c9e13edf0cfe2239277
- 1777d5fd2b59029cf537e5fd6f8aa68d707075822f90bde683fcde086f85f7a7"
+checksum="8df0079cdbe179748a18d44731af62a245a45ebf5085223dc03133954c662973
+ 42df840cf9055e59d0e22c249cfb19f04743e1bdad113d31b1573d3934d62584"
 patch_args="-Np1 -d ${build_wrksrc}"
 # tests hang indenfinitely, even with test data included
 make_check=no

From 98ba394049b5ff00dbacf97220c2c2692eafc4b1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 004/140] actiona: revbump for opencv-4.7.0

---
 srcpkgs/actiona/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/actiona/template b/srcpkgs/actiona/template
index cf5f0b7a2ae6..0d899311e6df 100644
--- a/srcpkgs/actiona/template
+++ b/srcpkgs/actiona/template
@@ -1,7 +1,7 @@
 # Template file for 'actiona'
 pkgname=actiona
 version=3.10.1
-revision=2
+revision=3
 build_style=qmake
 configure_args="PKGCONFIG_OPENCV=opencv4"
 hostmakedepends="pkg-config qt5-plugin-mysql qt5-qmake qt5-host-tools"

From 032bfac6e8d4086b7fa313de4952eaee56405e9f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 005/140] gmic: revbump for opencv-4.7.0

---
 srcpkgs/gmic/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gmic/template b/srcpkgs/gmic/template
index 24a9c7218fdf..0bb4034d5cc8 100644
--- a/srcpkgs/gmic/template
+++ b/srcpkgs/gmic/template
@@ -1,7 +1,7 @@
 # Template file for 'gmic'
 pkgname=gmic
 version=3.1.6
-revision=3
+revision=4
 _zart_hash=34ebf6cce0bafb98abe57cec83c4a02cd1abeca0
 create_wrksrc=yes
 build_wrksrc="src"

From 325d5177879a203290498024126089d270eb12f0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 006/140] qimgv: revbump for opencv-4.7.0

---
 srcpkgs/qimgv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qimgv/template b/srcpkgs/qimgv/template
index 7eb30db33992..dd341dfe1bfc 100644
--- a/srcpkgs/qimgv/template
+++ b/srcpkgs/qimgv/template
@@ -1,7 +1,7 @@
 # Template file for 'qimgv'
 pkgname=qimgv
 version=1.0.2
-revision=2
+revision=3
 build_style=cmake
 configure_args="$(vopt_if video -DVIDEO_SUPPORT=ON -DVIDEO_SUPPORT=OFF)
  $(vopt_if scale -DOPENCV_SUPPORT=ON -DOPENCV_SUPPORT=OFF)

From 816c3f26e0a7f0a6e6a9e6d2d862d93d389c87d6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 007/140] retroshare: revbump for opencv-4.7.0

---
 srcpkgs/retroshare/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroshare/template b/srcpkgs/retroshare/template
index 8a0786c21a08..72023fa98b75 100644
--- a/srcpkgs/retroshare/template
+++ b/srcpkgs/retroshare/template
@@ -1,7 +1,7 @@
 # Template file for 'retroshare'
 pkgname=retroshare
 version=0.6.6
-revision=2
+revision=4
 build_style=qmake
 #XXX broadcast feature requires an ancient udp-discovery-cpp which either needs
 # to be fetched+patched (FTBFS) here or packaged :/

From 199f93854a9ac7bd07d23bbd07cf04a19c4f7272 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 008/140] siril: revbump for opencv-4.7.0

---
 srcpkgs/siril/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/siril/template b/srcpkgs/siril/template
index e88f30fb6178..84332f79d060 100644
--- a/srcpkgs/siril/template
+++ b/srcpkgs/siril/template
@@ -1,7 +1,7 @@
 # Template file for 'siril'
 pkgname=siril
 version=0.9.12
-revision=9
+revision=10
 build_style=gnu-configure
 hostmakedepends="pkg-config intltool autoconf automake gettext-devel"
 makedepends="fftw-devel libconfig-devel libopencv-devel libffms2-devel

From 674f578a40f767aac1cb8add733a22679a88ab68 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 009/140] waifu2x-converter-cpp: revbump for opencv-4.7.0

---
 srcpkgs/waifu2x-converter-cpp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waifu2x-converter-cpp/template b/srcpkgs/waifu2x-converter-cpp/template
index 8c095d0d7bab..aa52d8c981a8 100644
--- a/srcpkgs/waifu2x-converter-cpp/template
+++ b/srcpkgs/waifu2x-converter-cpp/template
@@ -1,7 +1,7 @@
 # Template file for 'waifu2x-converter-cpp'
 pkgname=waifu2x-converter-cpp
 version=5.2.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DINSTALL_MODELS=ON"
 hostmakedepends="pkg-config"

From b50a3d189eef2ddf2fe36600d8b3b20082d90b06 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:38 -0400
Subject: [PATCH 010/140] vlc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/vlc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/vlc/template b/srcpkgs/vlc/template
index 210762b0a7e2..855ca5238662 100644
--- a/srcpkgs/vlc/template
+++ b/srcpkgs/vlc/template
@@ -1,7 +1,7 @@
 # Template file for 'vlc'
 pkgname=vlc
 version=3.0.18
-revision=3
+revision=4
 build_style=gnu-configure
 configure_args="--disable-gme --disable-libtar --enable-jack
  --enable-live555 --disable-fluidsynth --enable-dvdread
@@ -25,7 +25,7 @@ lib32disabled=yes
 hostmakedepends="automake libtool pkg-config flex gettext libgcrypt-devel
  live555-devel gettext-devel $(vopt_if lua lua52) $(vopt_if chromecast protobuf)"
 makedepends="
- avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg-devel freefont-ttf
+ avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg4-devel freefont-ttf
  gnutls-devel jack-devel liba52-devel libass-devel libbluray-devel
  libcdio-devel libdca-devel libdvbpsi-devel libdvdnav-devel libmad-devel
  libmatroska-devel libmodplug-devel libmpcdec-devel libmpeg2-devel

From 67e074dd1a4376ca7ecad28c6c810ec19b58a17d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:55 -0400
Subject: [PATCH 011/140] osg: revbump for ffmpeg4-4.4.3

---
 srcpkgs/osg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/osg/template b/srcpkgs/osg/template
index a9ebbd287933..755793f7e11b 100644
--- a/srcpkgs/osg/template
+++ b/srcpkgs/osg/template
@@ -8,7 +8,7 @@ build_helper="qemu"
 configure_args="-DLIB_POSTFIX="
 hostmakedepends="pkg-config xrandr"
 makedepends="MesaLib-devel gtkglext-devel libcurl-devel giflib-devel librsvg-devel
- jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg-devel xine-lib-devel
+ jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg4-devel xine-lib-devel
  SDL2-devel gst-plugins-base1-devel
  $(vopt_if openexr libopenexr-devel)
  $(vopt_if poppler poppler-glib-devel)

From a02d106ff6726a0ba03d6adac66e5e38e569a99c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:13 -0400
Subject: [PATCH 012/140] xine-lib: revbump for ffmpeg4-4.4.3

---
 srcpkgs/xine-lib/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/xine-lib/template b/srcpkgs/xine-lib/template
index f713eff49b07..ed6194c17d11 100644
--- a/srcpkgs/xine-lib/template
+++ b/srcpkgs/xine-lib/template
@@ -1,6 +1,6 @@
 # Template file for 'xine-lib'
 pkgname=xine-lib
-version=1.2.12
+version=1.2.13
 revision=1
 build_style=gnu-configure
 configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
@@ -8,7 +8,7 @@ configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
 hostmakedepends="automake gettext-devel libtool pkg-config perl"
 makedepends="
  zlib-devel alsa-lib-devel libxcb-devel libSM-devel libXext-devel libXv-devel
- libXvMC-devel liba52-devel libmad-devel ffmpeg-devel pulseaudio-devel
+ libXvMC-devel liba52-devel libmad-devel ffmpeg4-devel pulseaudio-devel
  jack-devel samba-devel libflac-devel libmodplug-devel libmpcdec-devel
  speex-devel libtheora-devel libvorbis-devel libdca-devel faad2-devel
  libcdio-devel libbluray-devel aalib-devel libcaca-devel libXinerama-devel
@@ -19,7 +19,7 @@ license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="http://www.xine-project.org"
 changelog="https://sourceforge.net/projects/xine/files/xine-lib/${version}/README.txt/view"
 distfiles="${SOURCEFORGE_SITE}/xine/${pkgname}-${version}.tar.xz"
-checksum=d606270468e1540c2a89c0d7f5fdf11e17ecc0c2698cc0bcb1065ff26abee098
+checksum=5f10d6d718a4a51c17ed1b32b031d4f9b80b061e8276535b2be31e5ac4b75e6f
 
 case "$XBPS_TARGET_MACHINE" in
 	i686-musl)

From 04e6e3455350981602b6bf9cac81e024bda83e72 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 013/140] QMPlay2: revbump for ffmpeg-6.0

---
 srcpkgs/QMPlay2/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/QMPlay2/template b/srcpkgs/QMPlay2/template
index ad73cbb01bae..55284c051161 100644
--- a/srcpkgs/QMPlay2/template
+++ b/srcpkgs/QMPlay2/template
@@ -1,7 +1,7 @@
 # Template file for 'QMPlay2'
 pkgname=QMPlay2
 version=23.02.05
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools"
 makedepends="alsa-lib-devel ffmpeg-devel libass-devel libcdio-devel libgme-devel

From 5fb396a304576e623150439ed6ffe40c1feaceeb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 014/140] alsa-plugins: revbump for ffmpeg-6.0

---
 srcpkgs/alsa-plugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/alsa-plugins/template b/srcpkgs/alsa-plugins/template
index 0bfa6d9fd264..a5708a7d82a8 100644
--- a/srcpkgs/alsa-plugins/template
+++ b/srcpkgs/alsa-plugins/template
@@ -1,7 +1,7 @@
 # Template file for 'alsa-plugins'
 pkgname=alsa-plugins
 version=1.2.7.1
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--disable-maemo-plugin"
 hostmakedepends="pkg-config"

From 45b6117de5bc18b8c4ccacc0ba51bf73a79facb9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 015/140] arcan: revbump for ffmpeg-6.0

---
 srcpkgs/arcan/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/arcan/template b/srcpkgs/arcan/template
index 7be9652eccf3..ccc7df11ceac 100644
--- a/srcpkgs/arcan/template
+++ b/srcpkgs/arcan/template
@@ -2,7 +2,7 @@
 # !! keep synced with: acfgfs aclip aloadimage
 pkgname=arcan
 version=0.6.2.1
-revision=1
+revision=2
 create_wrksrc=yes
 build_wrksrc=arcan/src
 build_style=cmake

From 7d7f17e2bd9358810d2f5323f078acac16b0dbef Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 016/140] attract: revbump for ffmpeg4-4.4.3

---
 srcpkgs/attract/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/attract/template b/srcpkgs/attract/template
index 26144e931a3c..e760bf0d18ae 100644
--- a/srcpkgs/attract/template
+++ b/srcpkgs/attract/template
@@ -1,12 +1,12 @@
 # Template file for 'attract'
 pkgname=attract
 version=2.6.2
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="VERBOSE=1"
 make_use_env=yes
 hostmakedepends="pkg-config"
-makedepends="SFML-devel ffmpeg-devel fontconfig-devel glu-devel libarchive-devel
+makedepends="SFML-devel ffmpeg4-devel fontconfig-devel glu-devel libarchive-devel
  libcurl-devel libjpeg-turbo-devel xine-lib rapidjson libXrandr-devel"
 depends="git"
 short_desc="Attract-Mode is a graphical frontend for emulators"

From 2e80b0c920f6311d77a8c4a05982d9476bfb0ba5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 017/140] aubio: revbump for ffmpeg-6.0

---
 srcpkgs/aubio/patches/ffmpeg5.patch | 25 +++++++++++++++++++++++++
 srcpkgs/aubio/template              |  2 +-
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/aubio/patches/ffmpeg5.patch

diff --git a/srcpkgs/aubio/patches/ffmpeg5.patch b/srcpkgs/aubio/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..aace41a6e6d9
--- /dev/null
+++ b/srcpkgs/aubio/patches/ffmpeg5.patch
@@ -0,0 +1,25 @@
+From 8a05420e5dd8c7b8b2447f82dc919765876511b3 Mon Sep 17 00:00:00 2001
+From: Paul Brossier <piem@piem.org>
+Date: Tue, 25 Jan 2022 18:30:27 +0100
+Subject: [PATCH] [source_avcodec] define FF_API_LAVF_AVCTX for libavcodec >
+ 59, thx @berolinux (closes gh-353)
+
+---
+ src/io/source_avcodec.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/io/source_avcodec.c b/src/io/source_avcodec.c
+index e0ae93b5..1421bd9a 100644
+--- a/src/io/source_avcodec.c
++++ b/src/io/source_avcodec.c
+@@ -68,6 +68,10 @@
+ #define AUBIO_AVCODEC_MAX_BUFFER_SIZE AV_INPUT_BUFFER_MIN_SIZE
+ #endif
+ 
++#if LIBAVCODEC_VERSION_MAJOR >= 59
++#define FF_API_LAVF_AVCTX 1
++#endif
++
+ struct _aubio_source_avcodec_t {
+   uint_t hop_size;
+   uint_t samplerate;
diff --git a/srcpkgs/aubio/template b/srcpkgs/aubio/template
index ad1c4b256991..7d875cc02541 100644
--- a/srcpkgs/aubio/template
+++ b/srcpkgs/aubio/template
@@ -1,7 +1,7 @@
 # Template file for 'aubio'
 pkgname=aubio
 version=0.4.9
-revision=1
+revision=2
 build_style=waf3
 # XXX lash, pure and swig support.
 hostmakedepends="pkg-config txt2man"

From 7fb01cc5e73a215422bd72f9fa8b5fc26c7400a1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 018/140] audacious-plugins: revbump for ffmpeg-6.0

---
 .../audacious-plugins/patches/ffmpeg5.patch   | 43 +++++++++++++++++++
 srcpkgs/audacious-plugins/template            |  2 +-
 2 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/audacious-plugins/patches/ffmpeg5.patch

diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg5.patch b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..4e5e34099d71
--- /dev/null
+++ b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
@@ -0,0 +1,43 @@
+commit 298aa371c56c2f52c25a33d9bdec4918b11cebdc
+Author: tibequadorian <tibequadorian@posteo.de>
+Date:   Sat Mar 19 18:40:12 2022 +0100
+
+    audacious-plugins: rebuild against ffmpeg-5.0
+
+diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+new file mode 100644
+index 0000000000..617c11215b
+--- /dev/null
++++ b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+@@ -0,0 +1,31 @@
++From f60beb400eeb1e4778bbfd738bc4a4ccef3de539 Mon Sep 17 00:00:00 2001
++From: John Lindgren <john@jlindgren.net>
++Date: Sat, 5 Mar 2022 12:05:34 -0500
++Subject: [PATCH] Fix build with FFmpeg 5.0
++
++---
++ src/ffaudio/ffaudio-core.cc | 4 ++--
++ 1 file changed, 2 insertions(+), 2 deletions(-)
++
++diff --git a/src/ffaudio/ffaudio-core.cc b/src/ffaudio/ffaudio-core.cc
++index 16dc63e3a..a2b95fd6c 100644
++--- a/src/ffaudio/ffaudio-core.cc
+++++ b/src/ffaudio/ffaudio-core.cc
++@@ -274,7 +274,7 @@ static AVInputFormat * get_format_by_content (const char * name, VFSFile & file)
++         AVProbeData d = {name, buf, filled};
++         score = target;
++ 
++-        f = av_probe_input_format2 (& d, true, & score);
+++        f = (AVInputFormat *) av_probe_input_format2 (& d, true, & score);
++         if (f)
++             break;
++ 
++@@ -347,7 +347,7 @@ static bool find_codec (AVFormatContext * c, CodecInfo * cinfo)
++ #endif
++         if (stream && stream->codecpar && stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
++         {
++-            AVCodec * codec = avcodec_find_decoder (stream->codecpar->codec_id);
+++            AVCodec * codec = (AVCodec *) avcodec_find_decoder (stream->codecpar->codec_id);
++ 
++             if (codec)
++             {
diff --git a/srcpkgs/audacious-plugins/template b/srcpkgs/audacious-plugins/template
index 88cbc1671fc6..beebfae59ed4 100644
--- a/srcpkgs/audacious-plugins/template
+++ b/srcpkgs/audacious-plugins/template
@@ -2,7 +2,7 @@
 #Keep in sync with audacious!
 pkgname=audacious-plugins
 version=4.3.1
-revision=1
+revision=2
 build_style=meson
 configure_args="$(vopt_bool gtk3 gtk) $(vopt_bool gtk3)
  $(vopt_bool qt) $(vopt_bool qt qt6)"

From c8955a13670baa12da2f68c6802e23bf5bdda641 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 019/140] audacity: revbump for ffmpeg4-4.4.3

---
 srcpkgs/audacity/template | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/audacity/template b/srcpkgs/audacity/template
index d509c0a89407..11e20255685b 100644
--- a/srcpkgs/audacity/template
+++ b/srcpkgs/audacity/template
@@ -1,7 +1,7 @@
 # Template file for 'audacity'
 pkgname=audacity
 version=2.4.1
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--with-ffmpeg=system --with-libsndfile=system --with-expat=system
  --with-libsoxr=system --with-lame=system --with-lv2=system ac_cv_path_WX_CONFIG=wx-config-gtk3"
@@ -9,7 +9,7 @@ hostmakedepends="pkg-config cmake gettext libtool m4 which"
 makedepends="jack-devel wxWidgets-gtk3-devel gtk+3-devel
  libmad-devel soundtouch-devel libsoxr-devel
  vamp-plugin-sdk-devel lame-devel libid3tag-devel libflac-devel
- ffmpeg-devel twolame-devel serd-devel lv2 lilv-devel suil-devel"
+ ffmpeg4-devel twolame-devel serd-devel lv2 lilv-devel suil-devel"
 depends="desktop-file-utils hicolor-icon-theme"
 short_desc="Graphical cross-platform audio editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
@@ -33,5 +33,4 @@ post_install() {
 	vcopy plug-ins /usr/share/audacity
 
 	rm ${DESTDIR}/usr/share/doc/audacity/LICENSE.txt
-	vlicense LICENSE.txt LICENSE
 }

From 145985c0b62ee4b1888332a5be8256d6adcb5dca Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 020/140] avidemux: revbump for ffmpeg-6.0

---
 srcpkgs/avidemux/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/avidemux/template b/srcpkgs/avidemux/template
index 253a0243e225..557285982d2b 100644
--- a/srcpkgs/avidemux/template
+++ b/srcpkgs/avidemux/template
@@ -1,7 +1,7 @@
 # Template file for 'avidemux'
 pkgname=avidemux
 version=2.8.0
-revision=2
+revision=3
 # Can't be compiled for aarch64, arm* or mips*
 archs="x86_64* i686*"
 hostmakedepends="cmake pkg-config qt5-host-tools qt5-devel tar yasm"

From 1b314054810e8de661612ee40015dc043141ae3f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 021/140] baresip: revbump for ffmpeg-6.0

---
 srcpkgs/baresip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/baresip/template b/srcpkgs/baresip/template
index f1bd1817048b..b21e22334316 100644
--- a/srcpkgs/baresip/template
+++ b/srcpkgs/baresip/template
@@ -1,7 +1,7 @@
 # Template file for 'baresip'
 pkgname=baresip
 version=2.10.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config glib-devel"
 makedepends="libgsm-devel libpng-devel openssl-devel libsndfile-devel

From fd55de773224302a44fb079fe9cf5f0913e9ce94 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 022/140] blender: revbump for ffmpeg-6.0

---
 .../patches/ffmpeg6-compat-blender.patch      | 42 +++++++++++++++++++
 srcpkgs/blender/template                      |  2 +-
 2 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/blender/patches/ffmpeg6-compat-blender.patch

diff --git a/srcpkgs/blender/patches/ffmpeg6-compat-blender.patch b/srcpkgs/blender/patches/ffmpeg6-compat-blender.patch
new file mode 100644
index 000000000000..d51a9c7710cc
--- /dev/null
+++ b/srcpkgs/blender/patches/ffmpeg6-compat-blender.patch
@@ -0,0 +1,42 @@
+--- a/source/blender/blenkernel/intern/writeffmpeg.c	2022-11-08 13:50:16 UTC
++++ b/source/blender/blenkernel/intern/writeffmpeg.c
+@@ -855,7 +855,7 @@ static AVStream *alloc_video_stream(FFMpegContext *con
+                                                             255);
+   st->avg_frame_rate = av_inv_q(c->time_base);
+ 
+-  if (codec->capabilities & AV_CODEC_CAP_AUTO_THREADS) {
++  if (codec->capabilities & AV_CODEC_CAP_OTHER_THREADS) {
+     c->thread_count = 0;
+   }
+   else {
+--- a/source/blender/imbuf/intern/anim_movie.c	2022-11-04 00:33:07 UTC
++++ b/source/blender/imbuf/intern/anim_movie.c
+@@ -554,7 +554,7 @@ static int startffmpeg(struct anim *anim)
+   avcodec_parameters_to_context(pCodecCtx, video_stream->codecpar);
+   pCodecCtx->workaround_bugs = FF_BUG_AUTODETECT;
+ 
+-  if (pCodec->capabilities & AV_CODEC_CAP_AUTO_THREADS) {
++  if (pCodec->capabilities & AV_CODEC_CAP_OTHER_THREADS) {
+     pCodecCtx->thread_count = 0;
+   }
+   else {
+--- a/source/blender/imbuf/intern/indexer.c	2022-11-04 00:33:07 UTC
++++ b/source/blender/imbuf/intern/indexer.c
+@@ -559,7 +559,7 @@ static struct proxy_output_ctx *alloc_proxy_output_ffm
+   av_dict_set(&codec_opts, "preset", "veryfast", 0);
+   av_dict_set(&codec_opts, "tune", "fastdecode", 0);
+ 
+-  if (rv->codec->capabilities & AV_CODEC_CAP_AUTO_THREADS) {
++  if (rv->codec->capabilities & AV_CODEC_CAP_OTHER_THREADS) {
+     rv->c->thread_count = 0;
+   }
+   else {
+@@ -872,7 +872,7 @@ static IndexBuildContext *index_ffmpeg_create_context(
+   avcodec_parameters_to_context(context->iCodecCtx, context->iStream->codecpar);
+   context->iCodecCtx->workaround_bugs = FF_BUG_AUTODETECT;
+ 
+-  if (context->iCodec->capabilities & AV_CODEC_CAP_AUTO_THREADS) {
++  if (context->iCodec->capabilities & AV_CODEC_CAP_OTHER_THREADS) {
+     context->iCodecCtx->thread_count = 0;
+   }
+   else {
diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index 61b42eb2e51e..d18bc88838ff 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -1,7 +1,7 @@
 # Template file for 'blender'
 pkgname=blender
 version=3.4.1
-revision=3
+revision=4
 archs="x86_64* ppc64*"
 build_style="cmake"
 pycompile_dirs="/usr/share/blender/${version%.*}/scripts"

From b5178e4e573e5b75627b166200152ee31412c182 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 023/140] cantata: revbump for ffmpeg-6.0

---
 srcpkgs/cantata/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cantata/template b/srcpkgs/cantata/template
index 4b417d80d5c2..8a90aaa4c07a 100644
--- a/srcpkgs/cantata/template
+++ b/srcpkgs/cantata/template
@@ -1,7 +1,7 @@
 # Template file for 'cantata'
 pkgname=cantata
 version=2.5.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools qt5-tools"
 makedepends="qt5-devel qt5-tools-devel qt5-svg-devel qt5-xmlpatterns-devel

From 59259d40817fa204e536d43c7e944132f9beba14 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 024/140] ccextractor: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ccextractor/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/ccextractor/template b/srcpkgs/ccextractor/template
index 9abcd82852b2..6eccad5885af 100644
--- a/srcpkgs/ccextractor/template
+++ b/srcpkgs/ccextractor/template
@@ -1,12 +1,12 @@
 # Template file for 'ccextractor'
 pkgname=ccextractor
 version=0.93
-revision=1
+revision=2
 build_wrksrc="linux"
 build_style=gnu-configure
 configure_args="--enable-ocr --enable-hardsubx"
 hostmakedepends="automake pkg-config"
-makedepends="leptonica-devel tesseract-ocr-devel ffmpeg-devel"
+makedepends="leptonica-devel tesseract-ocr-devel ffmpeg4-devel"
 short_desc="Extract subtitles from video streams"
 maintainer="newbluemoon <blaumolch@mailbox.org>"
 license="GPL-2.0-or-later"

From 4300dd323d02bba6a36b8b4a0a1be5ed85f25fdb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 025/140] chromaprint: revbump for ffmpeg-6.0

---
 srcpkgs/chromaprint/patches/ffmpeg5.patch | 569 ++++++++++++++++++++++
 srcpkgs/chromaprint/template              |   2 +-
 2 files changed, 570 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromaprint/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromaprint/patches/ffmpeg5.patch b/srcpkgs/chromaprint/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..a9fd307a23c8
--- /dev/null
+++ b/srcpkgs/chromaprint/patches/ffmpeg5.patch
@@ -0,0 +1,569 @@
+From 8ccad6937177b1b92e40ab8f4447ea27bac009a7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= <lalinsky@gmail.com>
+Date: Fri, 4 Nov 2022 21:47:38 +0100
+Subject: [PATCH] Use FFmpeg 5.x (#120)
+
+* Use FFmpeg 5.1.2 for CI builds
+
+* Build on Ubuntu 20.04
+
+* Upgrade code to FFmpeg 5.x APIs
+
+* Only set FFmpeg include dirs if building tools
+
+* No longer needed
+
+* Use ubuntu 20.04
+---
+ .github/workflows/build.yml                   |   6 +-
+ CMakeLists.txt                                |  16 --
+ package/build.sh                              |   4 +-
+ src/audio/ffmpeg_audio_processor.h            |   2 -
+ src/audio/ffmpeg_audio_processor_avresample.h |  72 -------
+ src/audio/ffmpeg_audio_processor_swresample.h |  18 +-
+ src/audio/ffmpeg_audio_reader.h               | 197 +++++++++---------
+ tests/CMakeLists.txt                          |   6 +
+ 8 files changed, 122 insertions(+), 199 deletions(-)
+ delete mode 100644 src/audio/ffmpeg_audio_processor_avresample.h
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index f8d6a32..4da2405 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -84,9 +84,6 @@ find_package(FFmpeg)
+ if(FFMPEG_LIBRARIES)
+ 	cmake_push_check_state(RESET)
+ 	set(CMAKE_REQUIRED_LIBRARIES ${FFMPEG_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -lm)
+-	check_function_exists(av_packet_unref HAVE_AV_PACKET_UNREF)
+-	check_function_exists(av_frame_alloc HAVE_AV_FRAME_ALLOC)
+-	check_function_exists(av_frame_free HAVE_AV_FRAME_FREE)
+ 	cmake_pop_check_state()
+ endif()
+
+@@ -163,14 +160,11 @@ message(STATUS "Using ${FFT_LIB} for FFT calculations")
+ if(NOT AUDIO_PROCESSOR_LIB)
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+ 		set(AUDIO_PROCESSOR_LIB "swresample")
+-	elseif(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(AUDIO_PROCESSOR_LIB "avresample")
+ 	endif()
+ endif()
+
+ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE OFF)
+ 		set(USE_SWRESAMPLE ON)
+ 		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBSWRESAMPLE_LIBRARIES})
+ 		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBSWRESAMPLE_INCLUDE_DIRS})
+@@ -178,16 +172,6 @@ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+ 	endif()
+ 	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+-elseif(AUDIO_PROCESSOR_LIB STREQUAL "avresample")
+-	if(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE ON)
+-		set(USE_SWRESAMPLE OFF)
+-		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBAVRESAMPLE_LIBRARIES})
+-		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBAVRESAMPLE_INCLUDE_DIRS})
+-	else()
+-		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+-	endif()
+-	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+ else()
+ 	message(STATUS "Building without audio conversion support, please install FFmpeg with libswresample")
+ endif()
+diff --git a/package/build.sh b/package/build.sh
+index da631ae..b41d36e 100755
+--- a/package/build.sh
++++ b/package/build.sh
+@@ -7,8 +7,8 @@ set -eux
+
+ BASE_DIR=$(cd $(dirname $0)/.. && pwd)
+
+-FFMPEG_VERSION=4.4.1
+-FFMPEG_BUILD_TAG=v4.4.1-1
++FFMPEG_VERSION=5.1.2
++FFMPEG_BUILD_TAG=v${FFMPEG_VERSION}-1
+
+ TMP_BUILD_DIR=$BASE_DIR/$(mktemp -d build.XXXXXXXX)
+ trap 'rm -rf $TMP_BUILD_DIR' EXIT
+diff --git a/src/audio/ffmpeg_audio_processor.h b/src/audio/ffmpeg_audio_processor.h
+index 7628fc7..39f4f6d 100644
+--- a/src/audio/ffmpeg_audio_processor.h
++++ b/src/audio/ffmpeg_audio_processor.h
+@@ -10,8 +10,6 @@
+
+ #if defined(USE_SWRESAMPLE)
+ #include "audio/ffmpeg_audio_processor_swresample.h"
+-#elif defined(USE_AVRESAMPLE)
+-#include "audio/ffmpeg_audio_processor_avresample.h"
+ #else
+ #error "no audio processing library"
+ #endif
+diff --git a/src/audio/ffmpeg_audio_processor_avresample.h b/src/audio/ffmpeg_audio_processor_avresample.h
+deleted file mode 100644
+index bd85f92..0000000
+--- a/src/audio/ffmpeg_audio_processor_avresample.h
++++ /dev/null
+@@ -1,72 +0,0 @@
+-// Copyright (C) 2016  Lukas Lalinsky
+-// Distributed under the MIT license, see the LICENSE file for details.
+-
+-#ifndef CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-#define CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-
+-extern "C" {
+-#include <libavresample/avresample.h>
+-}
+-
+-namespace chromaprint {
+-
+-class FFmpegAudioProcessor {
+-public:
+-	FFmpegAudioProcessor() {
+-		m_resample_ctx = avresample_alloc_context();
+-	}
+-
+-	~FFmpegAudioProcessor() {
+-		avresample_free(&m_resample_ctx);
+-	}
+-
+-	void SetCompatibleMode() {
+-		av_opt_set_int(m_resample_ctx, "filter_size", 16, 0);
+-		av_opt_set_int(m_resample_ctx, "phase_shift", 8, 0);
+-		av_opt_set_int(m_resample_ctx, "linear_interp", 1, 0);
+-		av_opt_set_double(m_resample_ctx, "cutoff", 0.8, 0);
+-	}
+-
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "in_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_rate", sample_rate, 0);
+-	}
+-
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "out_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_rate, 0);
+-	}
+-
+-	int Init() {
+-		return avresample_open(m_resample_ctx);
+-	}
+-
+-	int Convert(uint8_t **out, int out_count, const uint8_t **in, int in_count) {
+-		return avresample_convert(m_resample_ctx, out, 0, out_count, (uint8_t **) in, 0, in_count);
+-	}
+-
+-	int Flush(uint8_t **out, int out_count) {
+-		return avresample_read(m_resample_ctx, out, out_count);
+-	}
+-
+-private:
+-	AVAudioResampleContext *m_resample_ctx = nullptr;
+-};
+-
+-}; // namespace chromaprint
+-
+-#endif
+diff --git a/src/audio/ffmpeg_audio_processor_swresample.h b/src/audio/ffmpeg_audio_processor_swresample.h
+index b86266b..b1d4bea 100644
+--- a/src/audio/ffmpeg_audio_processor_swresample.h
++++ b/src/audio/ffmpeg_audio_processor_swresample.h
+@@ -28,30 +28,28 @@ public:
+ 		av_opt_set_double(m_swr_ctx, "cutoff", 0.8, 0);
+ 	}
+
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "icl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "ich", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetInputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "in_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "isf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "in_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "isr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "in_sample_rate", sample_rate, 0);
+ 	}
+
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "ocl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "och", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetOutputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "out_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "osf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "out_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "osr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "out_sample_rate", sample_rate, 0);
+ 	}
+
+ 	int Init() {
+diff --git a/src/audio/ffmpeg_audio_reader.h b/src/audio/ffmpeg_audio_reader.h
+index 5550164..1c6b346 100644
+--- a/src/audio/ffmpeg_audio_reader.h
++++ b/src/audio/ffmpeg_audio_reader.h
+@@ -62,7 +62,7 @@ public:
+ 	bool Read(const int16_t **data, size_t *size);
+
+ 	bool IsOpen() const { return m_opened; }
+-	bool IsFinished() const { return m_finished && !m_got_frame; }
++	bool IsFinished() const { return !m_has_more_packets && !m_has_more_frames; }
+
+ 	std::string GetError() const { return m_error; }
+ 	int GetErrorCode() const { return m_error_code; }
+@@ -74,20 +74,19 @@ private:
+ 	uint8_t *m_convert_buffer[1] = { nullptr };
+ 	int m_convert_buffer_nb_samples = 0;
+
+-	AVInputFormat *m_input_fmt = nullptr;
++	const AVInputFormat *m_input_fmt = nullptr;
+ 	AVDictionary *m_input_opts = nullptr;
+
+ 	AVFormatContext *m_format_ctx = nullptr;
+ 	AVCodecContext *m_codec_ctx = nullptr;
+-	AVFrame *m_frame = nullptr;
+ 	int m_stream_index = -1;
+ 	std::string m_error;
+ 	int m_error_code = 0;
+-	bool m_finished = false;
+ 	bool m_opened = false;
+-	int m_got_frame = 0;
+-	AVPacket m_packet;
+-	AVPacket m_packet0;
++	bool m_has_more_packets = true;
++	bool m_has_more_frames = true;
++	AVPacket *m_packet = nullptr;
++	AVFrame *m_frame = nullptr;
+
+ 	int m_output_sample_rate = 0;
+ 	int m_output_channels = 0;
+@@ -98,19 +97,12 @@ private:
+
+ inline FFmpegAudioReader::FFmpegAudioReader() {
+ 	av_log_set_level(AV_LOG_QUIET);
+-
+-	av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
+ }
+
+ inline FFmpegAudioReader::~FFmpegAudioReader() {
+ 	Close();
+ 	av_dict_free(&m_input_opts);
+ 	av_freep(&m_convert_buffer[0]);
+-	av_packet_unref(&m_packet0);
+ }
+
+ inline bool FFmpegAudioReader::SetInputFormat(const char *name) {
+@@ -135,11 +127,10 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ 	Close();
+
+-    av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
++	m_packet = av_packet_alloc();
++	if (!m_packet) {
++		return false;
++	}
+
+ 	ret = avformat_open_input(&m_format_ctx, file_name.c_str(), m_input_fmt, &m_input_opts);
+ 	if (ret < 0) {
+@@ -153,26 +144,31 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		return false;
+ 	}
+
+-	AVCodec *codec;
++	const AVCodec *codec;
+ 	ret = av_find_best_stream(m_format_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &codec, 0);
+ 	if (ret < 0) {
+ 		SetError("Could not find any audio stream in the file", ret);
+ 		return false;
+ 	}
+ 	m_stream_index = ret;
++	auto stream = m_format_ctx->streams[m_stream_index];
+
+-	m_codec_ctx = m_format_ctx->streams[m_stream_index]->codec;
++	m_codec_ctx = avcodec_alloc_context3(codec);
+ 	m_codec_ctx->request_sample_fmt = AV_SAMPLE_FMT_S16;
+
++	ret = avcodec_parameters_to_context(m_codec_ctx, stream->codecpar);
++	if (ret < 0) {
++		SetError("Could not copy the stream parameters", ret);
++		return false;
++	}
++
+ 	ret = avcodec_open2(m_codec_ctx, codec, nullptr);
+ 	if (ret < 0) {
+ 		SetError("Could not open the codec", ret);
+ 		return false;
+ 	}
+
+-	if (!m_codec_ctx->channel_layout) {
+-		m_codec_ctx->channel_layout = av_get_default_channel_layout(m_codec_ctx->channels);
+-	}
++	av_dump_format(m_format_ctx, 0, "foo", 0);
+
+ 	m_frame = av_frame_alloc();
+ 	if (!m_frame) {
+@@ -183,19 +179,23 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		m_output_sample_rate = m_codec_ctx->sample_rate;
+ 	}
+
+-	if (!m_output_channels) {
+-		m_output_channels = m_codec_ctx->channels;
++	AVChannelLayout output_channel_layout;
++	if (m_output_channels) {
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
++	} else {
++		m_output_channels = m_codec_ctx->ch_layout.nb_channels;
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
+ 	}
+
+-	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
++	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->ch_layout.nb_channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
+ 		m_converter.reset(new FFmpegAudioProcessor());
+ 		m_converter->SetCompatibleMode();
+ 		m_converter->SetInputSampleFormat(m_codec_ctx->sample_fmt);
+ 		m_converter->SetInputSampleRate(m_codec_ctx->sample_rate);
+-		m_converter->SetInputChannelLayout(m_codec_ctx->channel_layout);
++		m_converter->SetInputChannelLayout(&(m_codec_ctx->ch_layout));
+ 		m_converter->SetOutputSampleFormat(AV_SAMPLE_FMT_S16);
+ 		m_converter->SetOutputSampleRate(m_output_sample_rate);
+-		m_converter->SetOutputChannelLayout(av_get_default_channel_layout(m_output_channels));
++		m_converter->SetOutputChannelLayout(&output_channel_layout);
+ 		auto ret = m_converter->Init();
+ 		if (ret != 0) {
+ 			SetError("Could not create an audio converter instance", ret);
+@@ -203,10 +203,11 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		}
+ 	}
+
++	av_channel_layout_uninit(&output_channel_layout);
++
+ 	m_opened = true;
+-	m_finished = false;
+-	m_got_frame = 0;
+-	m_nb_packets = 0;
++	m_has_more_packets = true;
++	m_has_more_frames = true;
+ 	m_decode_error = 0;
+
+ 	return true;
+@@ -214,6 +215,7 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ inline void FFmpegAudioReader::Close() {
+ 	av_frame_free(&m_frame);
++	av_packet_free(&m_packet);
+
+ 	m_stream_index = -1;
+
+@@ -252,91 +254,98 @@ inline bool FFmpegAudioReader::Read(const int16_t **data, size_t *size) {
+ 		return false;
+ 	}
+
++	*data = nullptr;
++	*size = 0;
++
+ 	int ret;
++	bool needs_packet = false;
+ 	while (true) {
+-		while (m_packet.size <= 0) {
+-			av_packet_unref(&m_packet0);
+-			av_init_packet(&m_packet);
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			ret = av_read_frame(m_format_ctx, &m_packet);
++		while (needs_packet && m_packet->size == 0) {
++			ret = av_read_frame(m_format_ctx, m_packet);
+ 			if (ret < 0) {
+ 				if (ret == AVERROR_EOF) {
+-					m_finished = true;
++					needs_packet = false;
++					m_has_more_packets = false;
+ 					break;
+-				} else {
++				}
++				SetError("Error reading from the audio source", ret);
++				return false;
++			}
++			if (m_packet->stream_index == m_stream_index) {
++				needs_packet = false;
++			} else {
++				av_packet_unref(m_packet);
++			}
++		}
++
++		if (m_packet->size != 0) {
++			ret = avcodec_send_packet(m_codec_ctx, m_packet);
++			if (ret < 0) {
++				if (ret != AVERROR(EAGAIN)) {
+ 					SetError("Error reading from the audio source", ret);
+ 					return false;
+ 				}
+-			}
+-			m_packet0 = m_packet;
+-			if (m_packet.stream_index != m_stream_index) {
+-				m_packet.data = nullptr;
+-				m_packet.size = 0;
+ 			} else {
+-				m_nb_packets++;
++				av_packet_unref(m_packet);
+ 			}
+ 		}
+
+-		ret = avcodec_decode_audio4(m_codec_ctx, m_frame, &m_got_frame, &m_packet);
++		ret = avcodec_receive_frame(m_codec_ctx, m_frame);
+ 		if (ret < 0) {
+-			if (m_decode_error) {
+-				SetError("Error decoding audio frame", m_decode_error);
+-				return false;
++			if (ret == AVERROR_EOF) {
++				m_has_more_frames = false;
++			} else if (ret == AVERROR(EAGAIN)) {
++				if (m_has_more_packets) {
++					needs_packet = true;
++					continue;
++				} else {
++					m_has_more_frames = false;
++				}
+ 			}
+-			m_decode_error = ret;
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			continue;
++			SetError("Error decoding the audio source", ret);
++			return false;
+ 		}
+
+-		break;
+-	}
+-
+-	m_decode_error = 0;
+-
+-	const int decoded = std::min(ret, m_packet.size);
+-	m_packet.data += decoded;
+-	m_packet.size -= decoded;
+-
+-	if (m_got_frame) {
+-		if (m_converter) {
+-			if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
+-				int linsize;
+-				av_freep(&m_convert_buffer[0]);
+-				m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
+-				ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
+-				if (ret < 0) {
+-					SetError("Couldn't allocate audio converter buffer", ret);
++		if (m_frame->nb_samples > 0) {
++			if (m_converter) {
++				if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
++					int linsize;
++					av_freep(&m_convert_buffer[0]);
++					m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
++					ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->ch_layout.nb_channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
++					if (ret < 0) {
++						SetError("Couldn't allocate audio converter buffer", ret);
++						return false;
++					}
++				}
++				auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
++				if (nb_samples < 0) {
++					SetError("Couldn't convert audio", ret);
+ 					return false;
+ 				}
+-			}
+-			auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			}
+-			*data = (const int16_t *) m_convert_buffer[0];
+-			*size = nb_samples;
+-		} else {
+-			*data = (const int16_t *) m_frame->data[0];
+-			*size = m_frame->nb_samples;
+-		}
+-	} else {
+-		if (m_finished && m_converter) {
+-			auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			} else if (nb_samples > 0) {
+-				m_got_frame = 1;
+ 				*data = (const int16_t *) m_convert_buffer[0];
+ 				*size = nb_samples;
++			} else {
++				*data = (const int16_t *) m_frame->data[0];
++				*size = m_frame->nb_samples;
++			}
++		} else {
++			if (m_converter) {
++				if (IsFinished()) {
++					auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
++					if (nb_samples < 0) {
++						SetError("Couldn't convert audio", ret);
++						return false;
++					} else if (nb_samples > 0) {
++						*data = (const int16_t *) m_convert_buffer[0];
++						*size = nb_samples;
++					}
++				}
+ 			}
+ 		}
+-	}
+
+-	return true;
++		return true;
++	}
+ }
+
+ inline void FFmpegAudioReader::SetError(const char *message, int errnum) {
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index a2b517b..123e643 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -38,6 +38,12 @@ set(SRCS
+
+ if(BUILD_TOOLS)
+ 	set(SRCS ${SRCS} ../src/audio/ffmpeg_audio_reader_test.cpp)
++    include_directories(
++        ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}
++        ${AUDIO_PROCESSOR_INCLUDE_DIRS}
++    )
+ 	link_libraries(fpcalc_libs)
+ endif()
+
+-- 
+2.38.1
+
+
diff --git a/srcpkgs/chromaprint/template b/srcpkgs/chromaprint/template
index 7ef7838949f3..1f7bbc70a22c 100644
--- a/srcpkgs/chromaprint/template
+++ b/srcpkgs/chromaprint/template
@@ -1,7 +1,7 @@
 # Template file for 'chromaprint'
 pkgname=chromaprint
 version=1.5.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DBUILD_TOOLS=ON"
 make_check_target="check"

From a25f84beadcc55197ebe6f2993098618baa74728 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 026/140] chromium: revbump for ffmpeg-6.0

---
 .../patches/chromium-93-ffmpeg-4.4.patch      | 36 --------------
 srcpkgs/chromium/patches/ffmpeg5.patch        | 47 +++++++++++++++++++
 srcpkgs/chromium/template                     |  2 +-
 3 files changed, 48 insertions(+), 37 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch
 create mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch b/srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch
deleted file mode 100644
index f0ec736f98bc..000000000000
--- a/srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch
+++ /dev/null
@@ -1,36 +0,0 @@
-diff --git a/media/filters/ffmpeg_demuxer.cc b/media/filters/ffmpeg_demuxer.cc
-index ac4713b07268..492a9a37d096 100644
---- a/media/filters/ffmpeg_demuxer.cc
-+++ b/media/filters/ffmpeg_demuxer.cc
-@@ -427,11 +427,11 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
-   scoped_refptr<DecoderBuffer> buffer;
- 
-   if (type() == DemuxerStream::TEXT) {
--    size_t id_size = 0;
-+    int id_size = 0;
-     uint8_t* id_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
- 
--    size_t settings_size = 0;
-+    int settings_size = 0;
-     uint8_t* settings_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
- 
-@@ -443,7 +443,7 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
-     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
-                                      side_data.data(), side_data.size());
-   } else {
--    size_t side_data_size = 0;
-+    int side_data_size = 0;
-     uint8_t* side_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
- 
-@@ -504,7 +504,7 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
-                                        packet->size - data_offset);
-     }
- 
--    size_t skip_samples_size = 0;
-+    int skip_samples_size = 0;
-     const uint32_t* skip_samples_ptr =
-         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
-             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..24e2da38e34c
--- /dev/null
+++ b/srcpkgs/chromium/patches/ffmpeg5.patch
@@ -0,0 +1,47 @@
+--- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
++++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
+@@ -92,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+-  if (stream->start_time != kNoFFmpegTimestamp)
++  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -1597,7 +1585,7 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+@@ -1618,7 +1606,7 @@
+     if (stream->type() != DemuxerStream::VIDEO)
+       continue;
+ 
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+ 
+     if (!stream->IsEnabled())
diff --git a/srcpkgs/chromium/template b/srcpkgs/chromium/template
index e50c739d3ee7..8705f2ef973f 100644
--- a/srcpkgs/chromium/template
+++ b/srcpkgs/chromium/template
@@ -2,7 +2,7 @@
 pkgname=chromium
 # See https://chromiumdash.appspot.com/releases?platform=Linux for the latest version
 version=112.0.5615.49
-revision=1
+revision=2
 archs="i686* x86_64* aarch64* armv7l*"
 hostmakedepends="
  $(vopt_if clang "clang lld llvm15")

From 896ee3463a55901c7c6c1aac5258f8fa49e13295 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 027/140] cmus: revbump for ffmpeg-6.0

---
 srcpkgs/cmus/patches/ffmpeg6.patch | 12 ++++++++++++
 srcpkgs/cmus/template              |  2 +-
 2 files changed, 13 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/cmus/patches/ffmpeg6.patch

diff --git a/srcpkgs/cmus/patches/ffmpeg6.patch b/srcpkgs/cmus/patches/ffmpeg6.patch
new file mode 100644
index 000000000000..ffa95ab81110
--- /dev/null
+++ b/srcpkgs/cmus/patches/ffmpeg6.patch
@@ -0,0 +1,12 @@
+--- a/ip/ffmpeg.c
++++ b/ip/ffmpeg.c
+@@ -202,9 +202,6 @@ static int ffmpeg_open(struct input_plugin_data *ip_data)
+ 			break;
+ 		}
+ 
+-		if (codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+-			cc->flags |= AV_CODEC_FLAG_TRUNCATED;
+-
+ 		if (avcodec_open2(cc, codec, NULL) < 0) {
+ 			d_print("could not open codec: %d, %s\n", cc->codec_id, avcodec_get_name(cc->codec_id));
+ 			err = -IP_ERROR_UNSUPPORTED_FILE_TYPE;
diff --git a/srcpkgs/cmus/template b/srcpkgs/cmus/template
index 0fcb424ce336..05b77d0fecae 100644
--- a/srcpkgs/cmus/template
+++ b/srcpkgs/cmus/template
@@ -1,7 +1,7 @@
 # Template file for 'cmus'
 pkgname=cmus
 version=2.10.0
-revision=1
+revision=2
 build_style=configure
 configure_args="prefix=/usr LD=$CC"
 hostmakedepends="pkg-config"

From 49941a66bd74a643b03290a573a7b181a61157f5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 028/140] cyanrip: revbump for ffmpeg-6.0

---
 srcpkgs/cyanrip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cyanrip/template b/srcpkgs/cyanrip/template
index 9796e3461601..5db30e020d17 100644
--- a/srcpkgs/cyanrip/template
+++ b/srcpkgs/cyanrip/template
@@ -1,7 +1,7 @@
 # Template file for 'cyanrip'
 pkgname=cyanrip
 version=0.9.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config"
 makedepends="ffmpeg-devel libcdio-devel libcdio-paranoia-devel libcurl-devel libmusicbrainz5-devel"

From cfe9a27590ddc6a5bb1b9e294d76f074ebb0cca0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 029/140] deadbeef: revbump for ffmpeg4-4.4.3

---
 srcpkgs/deadbeef/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/deadbeef/template b/srcpkgs/deadbeef/template
index b664bb1b9bd9..165b3c7b9cad 100644
--- a/srcpkgs/deadbeef/template
+++ b/srcpkgs/deadbeef/template
@@ -1,14 +1,14 @@
 # Template file for 'deadbeef'
 pkgname=deadbeef
 version=1.8.8
-revision=1
+revision=2
 create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-oss --disable-lfm --disable-notify --disable-gtk2"
 hostmakedepends="automake libtool gettext gettext-devel intltool pkg-config
  yasm clang glib-devel"
 makedepends="
- alsa-lib-devel dbus-devel faad2-devel ffmpeg-devel gtk+3-devel imlib2-devel
+ alsa-lib-devel dbus-devel faad2-devel ffmpeg4-devel gtk+3-devel imlib2-devel
  jansson-devel libcddb-devel libcdio-devel libcurl-devel libflac-devel
  libmad-devel libpng-devel libsamplerate-devel libsndfile-devel libvorbis-devel
  libzip-devel mpg123-devel opusfile-devel pulseaudio-devel wavpack-devel"

From e0d905a5fac0324504370f59e9be401db7d5b3bb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 030/140] dolphin-emu: revbump for ffmpeg-6.0

---
 srcpkgs/dolphin-emu/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/dolphin-emu/template b/srcpkgs/dolphin-emu/template
index 7ea197ceb2a8..7aeb0a5b645e 100644
--- a/srcpkgs/dolphin-emu/template
+++ b/srcpkgs/dolphin-emu/template
@@ -1,7 +1,7 @@
 # Template file for 'dolphin-emu'
 pkgname=dolphin-emu
 version=5.0.16101
-revision=1
+revision=2
 _dolphin_commit=8ecfa537a242de74d2e372e30d9d79b14584b2fb
 _mgba_commit=40d4c430fc36caeb7ea32fd39624947ed487d2f2
 #Version/hash pair can be found at https://dolphin-emu.org/download/

From 7f368372b0a37992f33586451b27e680017caf64 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 031/140] droidcam-obs-plugin: revbump for ffmpeg-6.0

---
 srcpkgs/droidcam-obs-plugin/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam-obs-plugin/template b/srcpkgs/droidcam-obs-plugin/template
index fc9c9bf6b9d5..fb0480754df4 100644
--- a/srcpkgs/droidcam-obs-plugin/template
+++ b/srcpkgs/droidcam-obs-plugin/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam-obs-plugin'
 pkgname=droidcam-obs-plugin
 version=2.0.1
-revision=1
+revision=2
 build_style=gnu-makefile
 make_use_env=yes
 make_build_args="ALLOW_STATIC=no"

From c1f67c71ba9baa4e302567e35821387bdf282fcb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 032/140] droidcam: revbump for ffmpeg-6.0

---
 srcpkgs/droidcam/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam/template b/srcpkgs/droidcam/template
index 1c3f1b8b1fc6..32a9220b79a4 100644
--- a/srcpkgs/droidcam/template
+++ b/srcpkgs/droidcam/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam'
 pkgname=droidcam
 version=1.8.2
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="USBMUXD=-lusbmuxd-2.0 JPEG=-lturbojpeg"
 hostmakedepends="pkg-config"

From c86d7439a778ef3ac904490276eb79f0771f53a4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 033/140] electron19: revbump for ffmpeg-6.0

---
 srcpkgs/electron19/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron19/template b/srcpkgs/electron19/template
index 068136be7623..32ce301e730c 100644
--- a/srcpkgs/electron19/template
+++ b/srcpkgs/electron19/template
@@ -1,7 +1,7 @@
 # Template file for 'electron19'
 pkgname=electron19
 version=19.0.8
-revision=2
+revision=3
 _nodever=16.14.2
 _chromiumver=102.0.5005.125
 archs="x86_64* aarch64* ppc64le*"

From 0e91a31d5e892b8d03857bbc0769be09314be4c2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 034/140] ffmpegthumbnailer: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ffmpegthumbnailer/template | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/srcpkgs/ffmpegthumbnailer/template b/srcpkgs/ffmpegthumbnailer/template
index 039eea7622b3..8546bef3e868 100644
--- a/srcpkgs/ffmpegthumbnailer/template
+++ b/srcpkgs/ffmpegthumbnailer/template
@@ -1,16 +1,16 @@
 # Template file for 'ffmpegthumbnailer'
 pkgname=ffmpegthumbnailer
 version=2.2.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
-makedepends="libpng-devel libjpeg-turbo-devel ffmpeg-devel"
-depends="ffmpeg"
+makedepends="libpng-devel libjpeg-turbo-devel ffmpeg4-devel"
+depends="ffmpeg4"
 short_desc="Lightweight video thumbnailer"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
-homepage="https://github.com/dirkvdb/${pkgname}"
-distfiles="${homepage}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
+homepage="https://github.com/dirkvdb"
+distfiles="${homepage}/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
 checksum=1cb24059c38223f657b300c84dd80491b7040d4b69471c4fea69be862bc99b5b
 
 post_install() {

From b398f64c5d68da8602a69df88ff41f0d1fbaeeec Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 035/140] ffmpegthumbs: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ffmpegthumbs/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/ffmpegthumbs/template b/srcpkgs/ffmpegthumbs/template
index 5f0b9414dada..944a78fbc96c 100644
--- a/srcpkgs/ffmpegthumbs/template
+++ b/srcpkgs/ffmpegthumbs/template
@@ -1,11 +1,11 @@
 # Template file for 'ffmpegthumbs'
 pkgname=ffmpegthumbs
 version=22.12.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules kcoreaddons kconfig-devel
  pkg-config qt5-host-tools qt5-qmake gettext"
-makedepends="qt5-devel kio-devel ffmpeg-devel taglib-devel"
+makedepends="qt5-devel kio-devel ffmpeg4-devel taglib-devel"
 short_desc="FFmpeg-based thumbnail creator for video files"
 maintainer="Michael Straube <straubem@gmx.de>"
 license="GPL-2.0-or-later"

From b15f02b9b062bacc8822f960111d558f1db98500 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 036/140] ffms2: revbump for ffmpeg-6.0

---
 srcpkgs/ffms2/patches/ffmpeg5.patch | 424 ++++++++++++++++++++++++++++
 srcpkgs/ffms2/template              |   2 +-
 2 files changed, 425 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ffms2/patches/ffmpeg5.patch

diff --git a/srcpkgs/ffms2/patches/ffmpeg5.patch b/srcpkgs/ffms2/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..1479fabcafcb
--- /dev/null
+++ b/srcpkgs/ffms2/patches/ffmpeg5.patch
@@ -0,0 +1,424 @@
+From 45673149e9a2f5586855ad472e3059084eaa36b1 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:41:21 +0100
+Subject: [PATCH] Use auto for AVCodec
+
+The geniuses over at FFmpeg decided to constify this API, so old
+versions of the library will return AVCodec *, while new versions
+of the libary will return const AVCodec *, which, in C++, are not
+OK to convert between.
+
+Rather than use some macro hell in ffmscompat.h, we can work around
+this by using auto.
+
+Gross.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 2 +-
+ src/core/indexing.cpp    | 6 +++---
+ src/core/videosource.cpp | 2 +-
+ 3 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index e4ce97c..ac09666 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -469,7 +469,7 @@ void FFMS_AudioSource::OpenFile() {
+ 
+     LAVFOpenFile(SourceFile.c_str(), FormatContext, TrackNumber);
+ 
+-    AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
++    auto *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
+     if (Codec == nullptr)
+         throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+             "Audio codec not found");
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index e547c5a..59fb4e8 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -384,7 +384,7 @@ FFMS_TrackType FFMS_Indexer::GetTrackType(int Track) {
+ }
+ 
+ const char *FFMS_Indexer::GetTrackCodec(int Track) {
+-    AVCodec *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
++    auto *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
+     return codec ? codec->name : nullptr;
+ }
+ 
+@@ -402,7 +402,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             UseDTS);
+ 
+         if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            AVCodec *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (!VideoCodec) {
+                 FormatContext->streams[i]->discard = AVDISCARD_ALL;
+                 IndexMask.erase(i);
+@@ -433,7 +433,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 IndexMask.insert(i);
+             }
+         } else if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+-            AVCodec *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (AudioCodec == nullptr)
+                 throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_UNSUPPORTED,
+                     "Audio codec not found");
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index b889970..8956c22 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -171,7 +171,7 @@ FFMS_VideoSource::FFMS_VideoSource(const char *SourceFile, FFMS_Index &Index, in
+ 
+         LAVFOpenFile(SourceFile, FormatContext, VideoTrack);
+ 
+-        AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
++        auto *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
+         if (Codec == nullptr)
+             throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+                 "Video codec not found");
+-- 
+2.40.0
+
+From 96cbf38ea9381829a1314f432a2c60495dcefaad Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:12:41 +0100
+Subject: [PATCH] all: Update AVPacket API usage
+
+AVPackets must all be on the heap now, since it is no longer
+part of the libav* ABI.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 16 ++++++----
+ src/core/indexing.cpp    | 63 ++++++++++++++++++++++------------------
+ src/core/indexing.h      |  4 +--
+ src/core/utils.cpp       |  6 ----
+ src/core/utils.h         |  1 -
+ src/core/videosource.cpp | 30 ++++++++++---------
+ 6 files changed, 64 insertions(+), 56 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index 37cf9ae..e4ce97c 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -285,10 +285,15 @@ FFMS_AudioSource::AudioBlock *FFMS_AudioSource::CacheBlock(CacheIterator &pos) {
+ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     CurrentFrame = &Frames[PacketNumber];
+ 
+-    AVPacket Packet;
+-    if (!ReadPacket(&Packet))
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++    if (!ReadPacket(Packet)) {
++        av_packet_free(&Packet);
+         throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_UNKNOWN,
+             "ReadPacket unexpectedly failed to read a packet");
++    }
+ 
+     // ReadPacket may have changed the packet number
+     CurrentFrame = &Frames[PacketNumber];
+@@ -297,8 +302,9 @@ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     int NumberOfSamples = 0;
+     AudioBlock *CachedBlock = nullptr;
+     
+-    int Ret = avcodec_send_packet(CodecContext, &Packet);
+-    av_packet_unref(&Packet);
++    int Ret = avcodec_send_packet(CodecContext, Packet);
++    av_packet_unref(Packet);
++    av_packet_free(&Packet);
+ 
+     av_frame_unref(DecodeFrame);
+     Ret = avcodec_receive_frame(CodecContext, DecodeFrame);
+@@ -513,8 +519,6 @@ void FFMS_AudioSource::Seek() {
+ }
+ 
+ bool FFMS_AudioSource::ReadPacket(AVPacket *Packet) {
+-    InitNullPacket(*Packet);
+-
+     while (av_read_frame(FormatContext, Packet) >= 0) {
+         if (Packet->stream_index == TrackNumber) {
+             // Required because not all audio packets, especially in ogg, have a pts. Use the previous valid packet's pts instead.
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index 23fb95b..e547c5a 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -320,7 +320,7 @@ void FFMS_Indexer::CheckAudioProperties(int Track, AVCodecContext *Context) {
+     }
+ }
+ 
+-void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict,
++void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict,
+                                     int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct) {
+     if (VideoContext.Parser) {
+         uint8_t *OB;
+@@ -330,8 +330,8 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+         av_parser_parse2(VideoContext.Parser,
+             VideoContext.CodecContext,
+             &OB, &OBSize,
+-            pkt.data, pkt.size,
+-            pkt.pts, pkt.dts, pkt.pos);
++            pkt->data, pkt->size,
++            pkt->pts, pkt->dts, pkt->pos);
+ 
+         // H.264 (PAFF) and HEVC may have one field per packet, so we need to track
+         // when we have a full or half frame available, and mark one of them as
+@@ -351,15 +351,15 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+ 
+         *RepeatPict = VideoContext.Parser->repeat_pict;
+         *FrameType = VideoContext.Parser->pict_type;
+-        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt.flags & AV_PKT_FLAG_DISCARD));
++        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt->flags & AV_PKT_FLAG_DISCARD));
+     } else {
+-        *Invisible = !!(pkt.flags & AV_PKT_FLAG_DISCARD);
++        *Invisible = !!(pkt->flags & AV_PKT_FLAG_DISCARD);
+     }
+ 
+     if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP8)
+-        ParseVP8(pkt.data[0], Invisible, FrameType);
++        ParseVP8(pkt->data[0], Invisible, FrameType);
+     else if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP9)
+-        ParseVP9(pkt.data[0], Invisible, FrameType);
++        ParseVP9(pkt->data[0], Invisible, FrameType);
+ }
+ 
+ void FFMS_Indexer::Free() {
+@@ -458,32 +458,36 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+         }
+     }
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
+     std::vector<int64_t> LastValidTS(FormatContext->nb_streams, AV_NOPTS_VALUE);
+ 
+     int64_t filesize = avio_size(FormatContext->pb);
+     enum AVPictureStructure LastPicStruct = AV_PICTURE_STRUCTURE_UNKNOWN;
+-    while (av_read_frame(FormatContext, &Packet) >= 0) {
++    while (av_read_frame(FormatContext, Packet) >= 0) {
+         // Update progress
+         // FormatContext->pb can apparently be NULL when opening images.
+         if (IC && FormatContext->pb) {
+-            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate))
++            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate)) {
++                av_packet_free(&Packet);
+                 throw FFMS_Exception(FFMS_ERROR_CANCELLED, FFMS_ERROR_USER,
+                     "Cancelled by user");
++            }
+         }
+-        if (!IndexMask.count(Packet.stream_index)) {
+-            av_packet_unref(&Packet);
++        if (!IndexMask.count(Packet->stream_index)) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+-        int Track = Packet.stream_index;
++        int Track = Packet->stream_index;
+         FFMS_Track &TrackInfo = (*TrackIndices)[Track];
+-        bool KeyFrame = !!(Packet.flags & AV_PKT_FLAG_KEY);
++        bool KeyFrame = !!(Packet->flags & AV_PKT_FLAG_KEY);
+         ReadTS(Packet, LastValidTS[Track], (*TrackIndices)[Track].UseDTS);
+ 
+         if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            int64_t PTS = TrackInfo.UseDTS ? Packet.dts : Packet.pts;
++            int64_t PTS = TrackInfo.UseDTS ? Packet->dts : Packet->pts;
+             if (PTS == AV_NOPTS_VALUE) {
+                 // VPx alt-refs are output as packets which lack timestmps or durations, since
+                 // they are invisible. Currently, the timestamp mangling code in libavformat
+@@ -495,9 +499,11 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 // FFMS2 currently sorts packets by PTS, which will break decoding, otherwise.
+                 bool HasAltRefs = (FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP8 ||
+                                    FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP9);
+-                if (Packet.duration == 0 && !HasAltRefs)
++                if (Packet->duration == 0 && !HasAltRefs) {
++                    av_packet_free(&Packet);
+                     throw FFMS_Exception(FFMS_ERROR_INDEXING, FFMS_ERROR_PARSER,
+                         "Invalid packet pts, dts, and duration");
++                }
+ 
+                 if (TrackInfo.empty())
+                     PTS = 0;
+@@ -513,7 +519,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             ParseVideoPacket(AVContexts[Track], Packet, &RepeatPict, &FrameType, &Invisible, &LastPicStruct);
+ 
+             TrackInfo.AddVideoFrame(PTS, RepeatPict, KeyFrame,
+-                FrameType, Packet.pos, Invisible);
++                FrameType, Packet->pos, Invisible);
+         } else if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+             // For video seeking timestamps are used only if all packets have
+             // timestamps, while for audio they're used if any have timestamps,
+@@ -522,28 +528,29 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 TrackInfo.HasTS = true;
+ 
+             int64_t StartSample = AVContexts[Track].CurrentSample;
+-            uint32_t SampleCount = IndexAudioPacket(Track, &Packet, AVContexts[Track], *TrackIndices);
++            uint32_t SampleCount = IndexAudioPacket(Track, Packet, AVContexts[Track], *TrackIndices);
+             TrackInfo.SampleRate = AVContexts[Track].CodecContext->sample_rate;
+ 
+             TrackInfo.AddAudioFrame(LastValidTS[Track],
+-                StartSample, SampleCount, KeyFrame, Packet.pos, Packet.flags & AV_PKT_FLAG_DISCARD);
++                StartSample, SampleCount, KeyFrame, Packet->pos, Packet->flags & AV_PKT_FLAG_DISCARD);
+         }
+ 
+-        if (!(Packet.flags & AV_PKT_FLAG_DISCARD))
+-            TrackInfo.LastDuration = Packet.duration;
++        if (!(Packet->flags & AV_PKT_FLAG_DISCARD))
++            TrackInfo.LastDuration = Packet->duration;
+ 
+-        av_packet_unref(&Packet);
++        av_packet_unref(Packet);
+     }
++    av_packet_free(&Packet);
+ 
+     TrackIndices->Finalize(AVContexts, FormatContext->iformat->name);
+     return TrackIndices.release();
+ }
+ 
+-void FFMS_Indexer::ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS) {
+-    if (!UseDTS && Packet.pts != AV_NOPTS_VALUE)
+-        TS = Packet.pts;
++void FFMS_Indexer::ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS) {
++    if (!UseDTS && Packet->pts != AV_NOPTS_VALUE)
++        TS = Packet->pts;
+     if (TS == AV_NOPTS_VALUE)
+         UseDTS = true;
+-    if (UseDTS && Packet.dts != AV_NOPTS_VALUE)
+-        TS = Packet.dts;
++    if (UseDTS && Packet->dts != AV_NOPTS_VALUE)
++        TS = Packet->dts;
+ }
+diff --git a/src/core/indexing.h b/src/core/indexing.h
+index 3cfc3c3..5c06868 100644
+--- a/src/core/indexing.h
++++ b/src/core/indexing.h
+@@ -80,10 +80,10 @@ private:
+     int64_t Filesize;
+     uint8_t Digest[20];
+ 
+-    void ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS);
++    void ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS);
+     void CheckAudioProperties(int Track, AVCodecContext *Context);
+     uint32_t IndexAudioPacket(int Track, AVPacket *Packet, SharedAVContext &Context, FFMS_Index &TrackIndices);
+-    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
++    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
+     void Free();
+ public:
+     FFMS_Indexer(const char *Filename);
+diff --git a/src/core/utils.cpp b/src/core/utils.cpp
+index ce67533..8a2e997 100644
+--- a/src/core/utils.cpp
++++ b/src/core/utils.cpp
+@@ -62,12 +62,6 @@ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo) {
+     }
+ }
+ 
+-void InitNullPacket(AVPacket &pkt) {
+-    av_init_packet(&pkt);
+-    pkt.data = nullptr;
+-    pkt.size = 0;
+-}
+-
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames) {
+     AP.SampleFormat = static_cast<FFMS_SampleFormat>(av_get_packed_sample_fmt(CTX->sample_fmt));
+     AP.BitsPerSample = av_get_bytes_per_sample(CTX->sample_fmt) * 8;
+diff --git a/src/core/utils.h b/src/core/utils.h
+index 9819dc7..003ab79 100644
+--- a/src/core/utils.h
++++ b/src/core/utils.h
+@@ -58,7 +58,6 @@ std::unique_ptr<T> make_unique(Args&&... args) {
+ }
+ 
+ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo);
+-void InitNullPacket(AVPacket &pkt);
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames);
+ 
+ void LAVFOpenFile(const char *SourceFile, AVFormatContext *&FormatContext, int Track);
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index 06bd161..b889970 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -673,30 +673,34 @@ void FFMS_VideoSource::DecodeNextFrame(int64_t &AStartTime, int64_t &Pos) {
+     if (HasPendingDelayedFrames())
+         return;
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
+-
+-    while (ReadFrame(&Packet) >= 0) {
+-        if (Packet.stream_index != VideoTrack) {
+-            av_packet_unref(&Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++
++    while (ReadFrame(Packet) >= 0) {
++        if (Packet->stream_index != VideoTrack) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+         if (AStartTime < 0)
+-            AStartTime = Frames.UseDTS ? Packet.dts : Packet.pts;
++            AStartTime = Frames.UseDTS ? Packet->dts : Packet->pts;
+ 
+         if (Pos < 0)
+-            Pos = Packet.pos;
++            Pos = Packet->pos;
+ 
+-        bool FrameFinished = DecodePacket(&Packet);
+-        av_packet_unref(&Packet);
+-        if (FrameFinished)
++        bool FrameFinished = DecodePacket(Packet);
++        av_packet_unref(Packet);
++        if (FrameFinished) {
++            av_packet_free(&Packet);
+             return;
++        }
+     }
+ 
+     // Flush final frames
+-    InitNullPacket(Packet);
+-    DecodePacket(&Packet);
++    DecodePacket(Packet);
++    av_packet_free(&Packet);
+ }
+ 
+ bool FFMS_VideoSource::SeekTo(int n, int SeekOffset) {
+-- 
+2.40.0
+
+From bf9e03e9e08534c024e5a744a6437c4aac160201 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:20:47 +0100
+Subject: [PATCH 2/3] configure: Remove deprecated API use
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ configure.ac | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index b35ef80bc..d19714d0f 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -102,10 +102,10 @@ CFLAGS="$_CFLAGS $FFMPEG_CFLAGS"
+
+ AC_DEFUN([TEST_FFMPEG],
+          [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+-            #include <libavcodec/avcodec.h>
++            #include <libavformat/avformat.h>
+             #include <libswscale/swscale.h>
+             ]],[[
+-                avcodec_register_all();
++                avformat_network_init();
+                 swscale_version();
+             ]])], [eval $1=yes], [eval $1=no])
+         ])
+
diff --git a/srcpkgs/ffms2/template b/srcpkgs/ffms2/template
index 68e8a0c14bce..2acfadac44b3 100644
--- a/srcpkgs/ffms2/template
+++ b/srcpkgs/ffms2/template
@@ -1,7 +1,7 @@
 # Template file for 'ffms2'
 pkgname=ffms2
 version=2.40
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-shared --disable-static"
 hostmakedepends="pkg-config autoconf automake libtool"

From f8ba7182faafc779e42cdee475f3cdd8e0f97373 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 037/140] freerdp: revbump for ffmpeg-6.0

---
 .../freerdp/patches/ffmpeg6_aa2cb9aa.patch    | 42 +++++++++++++++++++
 srcpkgs/freerdp/template                      |  2 +-
 2 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch

diff --git a/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
new file mode 100644
index 000000000000..a4324da3a882
--- /dev/null
+++ b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
@@ -0,0 +1,42 @@
+From aa2cb9aa5ff5562433598ba168a466e0752bca0e Mon Sep 17 00:00:00 2001
+From: akallabeth <akallabeth@posteo.net>
+Date: Tue, 14 Feb 2023 07:48:54 +0100
+Subject: [PATCH] Fixed #8686: Update h264 to use new FFMPEG API
+
+---
+ channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c | 2 ++
+ libfreerdp/codec/h264_ffmpeg.c            | 2 ++
+ 2 files changed, 4 insertions(+)
+
+diff --git a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+index 339462d865f..beea80b7a1e 100644
+--- a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
++++ b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+@@ -239,8 +239,10 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYP
+ 		}
+ 	}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 	if (mdecoder->codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		mdecoder->codec_context->flags |= AV_CODEC_FLAG_TRUNCATED;
++#endif
+ 
+ 	return TRUE;
+ }
+diff --git a/libfreerdp/codec/h264_ffmpeg.c b/libfreerdp/codec/h264_ffmpeg.c
+index 8a23db2473c..896a333019b 100644
+--- a/libfreerdp/codec/h264_ffmpeg.c
++++ b/libfreerdp/codec/h264_ffmpeg.c
+@@ -615,10 +615,12 @@ static BOOL libavcodec_init(H264_CONTEXT* h264)
+ 			goto EXCEPTION;
+ 		}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 		if (sys->codecDecoder->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		{
+ 			sys->codecDecoderContext->flags |= AV_CODEC_FLAG_TRUNCATED;
+ 		}
++#endif
+ 
+ #ifdef WITH_VAAPI
+ 
diff --git a/srcpkgs/freerdp/template b/srcpkgs/freerdp/template
index 25e8aa9677f0..4d51c8189902 100644
--- a/srcpkgs/freerdp/template
+++ b/srcpkgs/freerdp/template
@@ -1,7 +1,7 @@
 # Template file for 'freerdp'
 pkgname=freerdp
 version=2.10.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_ALSA=ON -DWITH_CUPS=OFF -DWITH_FFMPEG=ON
  -DWITH_GSTREAMER_0_10=OFF -DWITH_GSTREAMER_1_0=OFF -DWITH_JPEG=ON

From 8a1cda0bcf5c5b610e68541ae240384bb4a1136f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 038/140] gerbera: revbump for ffmpeg-6.0

---
 srcpkgs/gerbera/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gerbera/template b/srcpkgs/gerbera/template
index ae14f35c767c..2dc0ac0ce03b 100644
--- a/srcpkgs/gerbera/template
+++ b/srcpkgs/gerbera/template
@@ -1,7 +1,7 @@
 # Template file for 'gerbera'
 pkgname=gerbera
 version=1.12.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_SYSTEMD=0 -DWITH_AVCODEC=1"
 hostmakedepends="pkg-config"

From 8d5de4c9cf5b975fe58c6f191c6aeadb07ff9597 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 039/140] goldendict: revbump for ffmpeg-6.0

---
 srcpkgs/goldendict/patches/ffmpeg4.patch |  21 --
 srcpkgs/goldendict/patches/ffmpeg5.patch | 232 +++++++++++++++++++++++
 srcpkgs/goldendict/template              |   2 +-
 3 files changed, 233 insertions(+), 22 deletions(-)
 delete mode 100644 srcpkgs/goldendict/patches/ffmpeg4.patch
 create mode 100644 srcpkgs/goldendict/patches/ffmpeg5.patch

diff --git a/srcpkgs/goldendict/patches/ffmpeg4.patch b/srcpkgs/goldendict/patches/ffmpeg4.patch
deleted file mode 100644
index f045fa27f54b..000000000000
--- a/srcpkgs/goldendict/patches/ffmpeg4.patch
+++ /dev/null
@@ -1,21 +0,0 @@
---- a/ffmpegaudio.cc.orig 2018-05-09 22:16:13.480659958 +0200
-+++ b/ffmpegaudio.cc      2018-05-09 22:16:50.748322790 +0200
-@@ -143,7 +143,7 @@
-     return false;
-   }
-
--  unsigned char * avioBuffer = ( unsigned char * )av_malloc( kBufferSize + FF_INPUT_BUFFER_PADDING_SIZE );
-+  unsigned char * avioBuffer = ( unsigned char * )av_malloc( kBufferSize + AV_INPUT_BUFFER_PADDING_SIZE );
-   if ( !avioBuffer )
-   {
-     errorString = QObject::tr( "av_malloc() failed." );
-@@ -380,7 +380,7 @@
-   }
-
-   if ( !Qt4x5::AtomicInt::loadAcquire( isCancelled_ ) &&
--       codecContext_->codec->capabilities & CODEC_CAP_DELAY )
-+       codecContext_->codec->capabilities & AV_CODEC_CAP_DELAY )
-   {
-     av_init_packet( &packet );
-     int gotFrame = 0;
-
diff --git a/srcpkgs/goldendict/patches/ffmpeg5.patch b/srcpkgs/goldendict/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..7cfc98ada368
--- /dev/null
+++ b/srcpkgs/goldendict/patches/ffmpeg5.patch
@@ -0,0 +1,232 @@
+From 03bbe01b79a1f07a6780cb60f23a087104c5d77b Mon Sep 17 00:00:00 2001
+From: Abs62 <ottomann@yandex.ru>
+Date: Fri, 30 Mar 2018 22:53:24 +0300
+Subject: [PATCH] Fix warnings while compile with FFMpeg 3.4.2 (issue #978)
+
+---
+ ffmpegaudio.cc | 68 +++++++++++++++++++++++++++++++++++++++++++++-----
+ 1 file changed, 62 insertions(+), 6 deletions(-)
+
+diff --git a/ffmpegaudio.cc b/ffmpegaudio.cc
+index ed1172bdd..56e8f788e 100644
+--- a/ffmpegaudio.cc
++++ b/ffmpegaudio.cc
+@@ -91,6 +91,7 @@ struct DecoderContext
+   QByteArray audioData_;
+   QDataStream audioDataStream_;
+   AVFormatContext * formatContext_;
++  AVCodec * codec_;
+   AVCodecContext * codecContext_;
+   AVIOContext * avioContext_;
+   AVStream * audioStream_;
+@@ -114,6 +115,7 @@ DecoderContext::DecoderContext( QByteArray const & audioData, QAtomicInt & isCan
+   audioData_( audioData ),
+   audioDataStream_( audioData_ ),
+   formatContext_( NULL ),
++  codec_( NULL ),
+   codecContext_( NULL ),
+   avioContext_( NULL ),
+   audioStream_( NULL ),
+@@ -143,7 +145,11 @@ bool DecoderContext::openCodec( QString & errorString )
+     return false;
+   }
+
++#if LIBAVCODEC_VERSION_MAJOR < 56 || ( LIBAVCODEC_VERSION_MAJOR == 56 && LIBAVCODEC_VERSION_MINOR < 56 )
+   unsigned char * avioBuffer = ( unsigned char * )av_malloc( kBufferSize + FF_INPUT_BUFFER_PADDING_SIZE );
++#else
++  unsigned char * avioBuffer = ( unsigned char * )av_malloc( kBufferSize + AV_INPUT_BUFFER_PADDING_SIZE );
++#endif
+   if ( !avioBuffer )
+   {
+     errorString = QObject::tr( "av_malloc() failed." );
+@@ -186,7 +192,11 @@ bool DecoderContext::openCodec( QString & errorString )
+   // Find audio stream, use the first audio stream if available
+   for ( unsigned i = 0; i < formatContext_->nb_streams; i++ )
+   {
++#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 33 )
+     if ( formatContext_->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO )
++#else
++      if ( formatContext_->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO )
++#endif
+     {
+       audioStream_ = formatContext_->streams[i];
+       break;
+@@ -198,22 +208,38 @@ bool DecoderContext::openCodec( QString & errorString )
+     return false;
+   }
+
++#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 33 )
+   codecContext_ = audioStream_->codec;
+-  AVCodec * codec = avcodec_find_decoder( codecContext_->codec_id );
+-  if ( !codec )
++  codec_ = avcodec_find_decoder( codecContext_->codec_id );
++  if ( !codec_ )
+   {
+     errorString = QObject::tr( "Codec [id: %1] not found." ).arg( codecContext_->codec_id );
+     return false;
+   }
++#else
++  codec_ = avcodec_find_decoder( audioStream_->codecpar->codec_id );
++  if ( !codec_ )
++  {
++    errorString = QObject::tr( "Codec [id: %1] not found." ).arg( audioStream_->codecpar->codec_id );
++    return false;
++  }
++  codecContext_ = avcodec_alloc_context3( codec_ );
++  if ( !codecContext_ )
++  {
++    errorString = QObject::tr( "avcodec_alloc_context3() failed." );
++    return false;
++  }
++  avcodec_parameters_to_context( codecContext_, audioStream_->codecpar );
++#endif
+
+-  ret = avcodec_open2( codecContext_, codec, NULL );
++  ret = avcodec_open2( codecContext_, codec_, NULL );
+   if ( ret < 0 )
+   {
+     errorString = QObject::tr( "avcodec_open2() failed: %1." ).arg( avErrorString( ret ) );
+     return false;
+   }
+
+-  av_log( NULL, AV_LOG_INFO, "Codec open: %s: channels: %d, rate: %d, format: %s\n", codec->long_name,
++  av_log( NULL, AV_LOG_INFO, "Codec open: %s: channels: %d, rate: %d, format: %s\n", codec_->long_name,
+           codecContext_->channels, codecContext_->sample_rate, av_get_sample_fmt_name( codecContext_->sample_fmt ) );
+   return true;
+ }
+@@ -252,10 +278,13 @@ void DecoderContext::closeCodec()
+
+   // Closing a codec context without prior avcodec_open2() will result in
+   // a crash in ffmpeg
+-  if ( audioStream_ && audioStream_->codec && audioStream_->codec->codec )
++  if ( audioStream_ && codecContext_ && codec_ )
+   {
+     audioStream_->discard = AVDISCARD_ALL;
+-    avcodec_close( audioStream_->codec );
++    avcodec_close( codecContext_ );
++#if LIBAVCODEC_VERSION_MAJOR > 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR >= 33 )
++    avcodec_free_context( &codecContext_ );
++#endif
+   }
+
+   avformat_close_input( &formatContext_ );
+@@ -356,6 +385,7 @@ bool DecoderContext::play( QString & errorString )
+     if ( packet.stream_index == audioStream_->index )
+     {
+       AVPacket pack = packet;
++#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 37 )
+       int gotFrame = 0;
+       do
+       {
+@@ -370,6 +400,19 @@ bool DecoderContext::play( QString & errorString )
+         pack.data += len;
+       }
+       while( pack.size > 0 );
++#else
++      int ret = avcodec_send_packet( codecContext_, &pack );
++      /* read all the output frames (in general there may be any number of them) */
++      while( ret >= 0 )
++      {
++        ret = avcodec_receive_frame( codecContext_, frame);
++
++        if ( Qt4x5::AtomicInt::loadAcquire( isCancelled_ ) || ret < 0 )
++          break;
++
++        playFrame( frame );
++      }
++#endif
+     }
+     // av_free_packet() must be called after each call to av_read_frame()
+ #if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 7 )
+@@ -379,6 +422,7 @@ bool DecoderContext::play( QString & errorString )
+ #endif
+   }
+
++#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 37 )
+   if ( !Qt4x5::AtomicInt::loadAcquire( isCancelled_ ) &&
+        codecContext_->codec->capabilities & CODEC_CAP_DELAY )
+   {
+@@ -391,6 +435,18 @@ bool DecoderContext::play( QString & errorString )
+       playFrame( frame );
+     }
+   }
++#else
++  /* flush the decoder */
++  av_init_packet( &packet );
++  int ret = avcodec_send_packet(codecContext_, &packet );
++  while( ret >= 0 )
++  {
++    ret = avcodec_receive_frame(codecContext_, frame);
++    if ( Qt4x5::AtomicInt::loadAcquire( isCancelled_ ) || ret < 0 )
++      break;
++    playFrame( frame );
++  }
++#endif
+
+ #if LIBAVCODEC_VERSION_MAJOR < 54
+   av_free( frame );
+32
+srcpkgs/goldendict/patches/ffmpeg5-2.patch
+Comment on this file
+@@ -0,0 +1,32 @@
+From 966f4a8b78e6324b930e5a50f2bb930bd87e565e Mon Sep 17 00:00:00 2001
+From: Abs62 <ottomann@yandex.ru>
+Date: Fri, 27 Sep 2019 17:00:52 +0300
+Subject: [PATCH] FFmpeg player: Fix some crashes on broken files
+
+---
+ ffmpegaudio.cc | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/ffmpegaudio.cc b/ffmpegaudio.cc
+index 56e8f788e..415fc79cb 100644
+--- a/ffmpegaudio.cc
++++ b/ffmpegaudio.cc
+@@ -51,7 +51,9 @@ AudioService & AudioService::instance()
+
+ AudioService::AudioService()
+ {
++#if LIBAVFORMAT_VERSION_MAJOR < 58 || ( LIBAVFORMAT_VERSION_MAJOR == 58 && LIBAVFORMAT_VERSION_MINOR < 9 )
+   av_register_all();
++#endif
+   ao_initialize();
+ }
+
+@@ -438,6 +440,8 @@ bool DecoderContext::play( QString & errorString )
+ #else
+   /* flush the decoder */
+   av_init_packet( &packet );
++  packet.data = NULL;
++  packet.size = 0;
+   int ret = avcodec_send_packet(codecContext_, &packet );
+   while( ret >= 0 )
+   {
+25
+srcpkgs/goldendict/patches/ffmpeg5-3.patch
+Comment on this file
+@@ -0,0 +1,25 @@
+From 8acb288c9e9bdb3c6bf2e803954dd3b6ac273c05 Mon Sep 17 00:00:00 2001
+From: Liao Junxuan <mikeljx@126.com>
+Date: Sun, 20 Feb 2022 12:28:05 +0800
+Subject: [PATCH] add support for ffmpeg 5.0
+
+---
+ ffmpegaudio.cc | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/ffmpegaudio.cc b/ffmpegaudio.cc
+index d550f4a77..7948d2187 100644
+--- a/ffmpegaudio.cc
++++ b/ffmpegaudio.cc
+@@ -94,7 +94,11 @@ struct DecoderContext
+   QByteArray audioData_;
+   QDataStream audioDataStream_;
+   AVFormatContext * formatContext_;
++#if LIBAVCODEC_VERSION_MAJOR < 59
+   AVCodec * codec_;
++#else
++  const AVCodec * codec_;
++#endif
+   AVCodecContext * codecContext_;
+   AVIOContext * avioContext_;
+   AVStream * audioStream_;
diff --git a/srcpkgs/goldendict/template b/srcpkgs/goldendict/template
index 4544ae710ee6..2ca4185e538a 100644
--- a/srcpkgs/goldendict/template
+++ b/srcpkgs/goldendict/template
@@ -9,7 +9,7 @@ makedepends="tiff-devel qt5-devel libvorbis-devel zlib-devel
  libXtst-devel hunspell-devel qt5-tools-devel qt5-declarative-devel
  qt5-webkit-devel lzo-devel bzip2-devel libao-devel qt5-svg-devel
  libeb-devel qt5-x11extras-devel ffmpeg-devel liblzma-devel"
-short_desc="A feature-rich dictionary lookup program"
+short_desc="Feature-rich dictionary lookup program"
 maintainer="John <me@johnnynator.dev>"
 license="GPL-3.0-or-later"
 homepage="http://goldendict.org/"

From 96aba07c75f8f26cc885e53581ae3c66dd189c9d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 040/140] gst-libav: revbump for ffmpeg-6.0

---
 srcpkgs/gst-libav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index e9a79dc650a5..f082bd211c65 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.20.3
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"

From edd46d846c94db43f01bf94f3a339e504cced676 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 041/140] gst-plugins-bad1: revbump for ffmpeg-6.0

---
 srcpkgs/gst-plugins-bad1/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index f55f82fd4c77..5a9d5387e0d4 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-plugins-bad1'
 pkgname=gst-plugins-bad1
-version=1.20.3
-revision=3
+version=1.22.1
+revision=2
 build_helper="gir"
 build_style=meson
 configure_args="-Dpackage-origin=https://voidlinux.org -Ddoc=disabled

From 968f4008f3565a806b881a07649b3ca474bff6ca Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 042/140] gst-rtsp-server: revbump for ffmpeg-6.0

---
 srcpkgs/gst-rtsp-server/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index 33cd64ceb95e..8ceea8d34b4b 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
 version=1.20.3
-revision=2
+revision=3
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="glib-devel gst-plugins-bad1-devel gobject-introspection

From 1f3930648b11bdcb3e2538ea2bacc0235364aacb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 043/140] guvcview: update to 2.0.8.

---
 srcpkgs/guvcview/patches/fix-include.patch | 10 ++++++++++
 srcpkgs/guvcview/template                  |  5 ++---
 2 files changed, 12 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/guvcview/patches/fix-include.patch

diff --git a/srcpkgs/guvcview/patches/fix-include.patch b/srcpkgs/guvcview/patches/fix-include.patch
new file mode 100644
index 000000000000..503c2af3b78c
--- /dev/null
+++ b/srcpkgs/guvcview/patches/fix-include.patch
@@ -0,0 +1,10 @@
+--- a/guvcview/guvcview.c
++++ b/guvcview/guvcview.c
+@@ -28,6 +28,7 @@
+ #include <sys/stat.h>
+ #include <sys/resource.h>
+ #include <errno.h>
++#include <locale.h>
+ 
+ #include "gview.h"
+ #include "gviewv4l2core.h"
diff --git a/srcpkgs/guvcview/template b/srcpkgs/guvcview/template
index 345cf6006f24..86a7fd619612 100644
--- a/srcpkgs/guvcview/template
+++ b/srcpkgs/guvcview/template
@@ -1,8 +1,7 @@
 # Template file for 'guvcview'
 pkgname=guvcview
-version=2.0.7
+version=2.0.8
 revision=1
-create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-static --disable-debian-menu"
 hostmakedepends="pkg-config intltool autoconf automake libtool glib-devel"
@@ -14,7 +13,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="http://guvcview.sourceforge.net/"
 distfiles="${SOURCEFORGE_SITE}/${pkgname}/${pkgname}-src-${version}.tar.bz2"
-checksum=f47d51fbd06e44eeaa1a82f4a153c927527c90d94514197a70b2956028cc8ad4
+checksum=a21f4e448286666cf27bafef5290cc953a0a1796b752e5bbe521266dc1230c81
 
 post_patch() {
 	sed '31a#include <locale.h>' -i  guvcview/guvcview.c

From 28aceac5ac8bd39db425db1484974f357fd8e2b7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 044/140] handbrake: update to 1.6.1

---
 .../patches/fix-missing-x265-link-flag.patch   | 11 ++++++-----
 .../handbrake/patches/libhb-vpl-include.patch  | 15 +++++++++++++++
 srcpkgs/handbrake/template                     | 18 +++++++++++-------
 3 files changed, 32 insertions(+), 12 deletions(-)
 create mode 100644 srcpkgs/handbrake/patches/libhb-vpl-include.patch

diff --git a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
index 26db03867a0c..d6bb2eda627a 100644
--- a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
+++ b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
@@ -1,14 +1,15 @@
 --- a/gtk/configure.ac
 +++ b/gtk/configure.ac
 @@ -203,7 +203,7 @@
- 
+
  AM_CONDITIONAL([MINGW], [test "x$mingw_flag" = "xyes"])
- 
--HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg"
-+HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -ldl"
+
+-HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc"
++HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc -ldl"
  HB_CPPFLAGS="$HB_CPPFLAGS $HBINC"
- 
+
  PKG_CHECK_MODULES([x264], [x264], sys_x264=yes, sys_x264=no)
+
 --- a/test/module.defs
 +++ b/test/module.defs
 @@ -69,6 +69,9 @@
diff --git a/srcpkgs/handbrake/patches/libhb-vpl-include.patch b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
new file mode 100644
index 000000000000..298f9f4ab28f
--- /dev/null
+++ b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
@@ -0,0 +1,15 @@
+--- a/libhb/module.defs	2023-01-22 11:36:49.000000000 -0500
++++ b/libhb/module.defs	2023-04-03 22:37:52.395467010 -0400
+@@ -46,11 +46,7 @@
+ LIBHB.GCC.I += $(LIBHB.build/) $(CONTRIB.build/)include
+ 
+ ifeq (1,$(FEATURE.qsv))
+-    ifeq ($(HOST.system),freebsd))
+-        LIBHB.GCC.I += $(LOCALBASE)/include/vpl
+-    else
+-        LIBHB.GCC.I += $(CONTRIB.build/)include/vpl
+-    endif
++    LIBHB.GCC.I += /usr/include/vpl
+ endif
+ 
+ ifneq (,$(filter $(HOST.system),freebsd netbsd openbsd))
diff --git a/srcpkgs/handbrake/template b/srcpkgs/handbrake/template
index ca5e4571e49c..3c2ab8659615 100644
--- a/srcpkgs/handbrake/template
+++ b/srcpkgs/handbrake/template
@@ -1,10 +1,11 @@
 # Template file for 'handbrake'
 pkgname=handbrake
-version=1.5.1
+version=1.6.1
 revision=1
+wrksrc=HandBrake-${version}
 build_style=gnu-configure
 configure_args="--force --disable-gtk-update-checks --disable-df-fetch --harden
- $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc)"
+ $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc) $(vopt_enable qsv)"
 make_build_args="-C ${XBPS_TRIPLET}"
 make_install_args="-C ${XBPS_TRIPLET}"
 hostmakedepends="automake cmake gettext-devel glib-devel intltool libtool m4 meson nasm pkg-config python3"
@@ -12,8 +13,11 @@ makedepends="bzip2-devel ffmpeg-devel gst-plugins-base1-devel gtk+3-devel
  jansson-devel lame-devel libass-devel libbluray-devel libdav1d-devel
  libdvdnav-devel libdvdread-devel libgudev-devel libnuma-devel
  libsamplerate-devel libtheora-devel libvorbis-devel libvpx-devel libxml2-devel
- opus-devel speex-devel x264-devel x265-devel zimg-devel
+ opus-devel speex-devel x264-devel x265-devel zimg-devel libsvt-av1-devel
  $(vopt_if fdk_aac fdk-aac-devel)
+ $(vopt_if qsv libva-devel)
+ $(vopt_if qsv libdrm-devel)
+ $(vopt_if qsv onevpl-devel)
  $(vopt_if nvenc nv-codec-headers)"
 depends="desktop-file-utils gst-plugins-good1 hicolor-icon-theme"
 short_desc="Multithreaded video transcoder"
@@ -21,15 +25,15 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-2.0-only"
 homepage="https://handbrake.fr/"
 distfiles="https://github.com/HandBrake/HandBrake/releases/download/${version}/HandBrake-${version}-source.tar.bz2"
-checksum=3999fe06d5309c819799a73a968a8ec3840e7840c2b64af8f5cdb7fd8c9430f0
+checksum=94ccfe03db917a91650000c510f7fd53f844da19f19ad4b4be1b8f6bc31a8d4c
 nocross=yes
 
-build_options="fdk_aac nvenc"
+build_options="fdk_aac nvenc qsv"
 
 case "$XBPS_TARGET_MACHINE" in
 	x86_64*|i686*)
 		CFLAGS="-msse"
-		build_options_default="nvenc"
+		build_options_default="nvenc qsv"
 		;;
 esac
 
@@ -37,7 +41,7 @@ pre_configure() {
 	# use system libraries, don't download them
 	rm -rf contrib/
 	for module in fdk-aac ffmpeg libbluray libdav1d libdvdnav libdvdread nvenc \
-		x265 zimg; do
+		x265 zimg svt-av1 libvpl; do
 	    vsed -i "/MODULES += contrib\/${module}/d" make/include/main.defs
 	done
 }

From de923bdfbde5b1a4c000cd948d5b2a8772c84490 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 045/140] hedgewars: revbump for ffmpeg4-4.4.3

---
 srcpkgs/hedgewars/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/hedgewars/template b/srcpkgs/hedgewars/template
index 419f29b98b44..926fe4fe3e68 100644
--- a/srcpkgs/hedgewars/template
+++ b/srcpkgs/hedgewars/template
@@ -1,13 +1,13 @@
 # Template file for 'hedgewars'
 pkgname=hedgewars
 version=1.0.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DNOSERVER=1 -DDATA_INSTALL_DIR=/usr/share/${pkgname}
  -DPHYSFS_SYSTEM=1 -DMINIMAL_FLAGS=1"
 make_cmd=make
 hostmakedepends="lua51 pkg-config qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
+makedepends="ffmpeg4-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
  SDL2_mixer-devel SDL2_net-devel SDL2_ttf-devel"
 depends="libfreeglut"
 short_desc="Funny turn-based artillery game, featuring fighting Hedgehogs!"

From 563a3d51126d0e0ec3e65ca1471f2dc40a402ef6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 046/140] idjc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/idjc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/idjc/template b/srcpkgs/idjc/template
index df60318b3db9..36a75baf597c 100644
--- a/srcpkgs/idjc/template
+++ b/srcpkgs/idjc/template
@@ -1,11 +1,11 @@
 # Template file for 'idjc'
 pkgname=idjc
 version=0.9.1
-revision=3
+revision=4
 build_style=gnu-configure
 hostmakedepends="pkg-config git python3 automake gettext-devel libtool"
 makedepends="libvorbis-devel libogg-devel jack-devel libsamplerate-devel
- libflac-devel libsndfile-devel mpg123-devel ffmpeg-devel speex-devel
+ libflac-devel libsndfile-devel mpg123-devel ffmpeg4-devel speex-devel
  glib-devel pixman-devel lame-devel python3-gobject-devel libshout-idjc-devel
  opus-devel twolame-devel python3-mutagen python3-devel"
 depends="python3-gobject python3-mutagen desktop-file-utils shared-mime-info python3-dbus jack"

From ae47a462256653492a0847b49eb47cd5e1f3a678 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 047/140] kfilemetadata5: revbump for ffmpeg-6.0

---
 srcpkgs/kfilemetadata5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kfilemetadata5/template b/srcpkgs/kfilemetadata5/template
index 8980121fbc69..f662a2043f93 100644
--- a/srcpkgs/kfilemetadata5/template
+++ b/srcpkgs/kfilemetadata5/template
@@ -1,7 +1,7 @@
 # Template file for 'kfilemetadata5'
 pkgname=kfilemetadata5
 version=5.105.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="kcoreaddons extra-cmake-modules pkg-config qt5-host-tools qt5-qmake
  gettext kcoreaddons python3"

From cdbb9f85e235fce9725fe5c9dc07a2e86a4b133c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 048/140] kid3: revbump for ffmpeg-6.0

---
 srcpkgs/kid3/patches/ffmpeg5.patch | 17 +++++++++++++++++
 srcpkgs/kid3/template              |  2 +-
 2 files changed, 18 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/kid3/patches/ffmpeg5.patch

diff --git a/srcpkgs/kid3/patches/ffmpeg5.patch b/srcpkgs/kid3/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..135fc50e07c9
--- /dev/null
+++ b/srcpkgs/kid3/patches/ffmpeg5.patch
@@ -0,0 +1,17 @@
+# https://aur.archlinux.org/cgit/aur.git/diff/ffmpeg5.patch?h=kid3-cli&id=12410a74906612e7efc0ec8fbce739b4a0fef7e7
+diff --git a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+index e156d424..e12b9abd 100644
+--- a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
++++ b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+@@ -232,7 +232,11 @@ private:
+   friend class Format;
+   friend class Converter;
+   AVCodecContext* m_ptr;
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 0, 0)
+   AVCodec* m_impl;
++#else
++  const AVCodec* m_impl;
++#endif
+   AVFrame* m_frame;
+   bool m_opened;
+ };
diff --git a/srcpkgs/kid3/template b/srcpkgs/kid3/template
index 456206d90e16..f32f9decb0e7 100644
--- a/srcpkgs/kid3/template
+++ b/srcpkgs/kid3/template
@@ -1,7 +1,7 @@
 # Template file for 'kid3'
 pkgname=kid3
 version=3.9.1
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DWITH_APPS='CLI;$(vopt_if KDE KDE Qt)'
  -DWITH_DOCBOOKDIR=/usr/share/xsl/docbook -DWITH_FLAC=$(vopt_if flac ON OFF)

From fcc89c7cdb4043b467ab41050af8dfd0e68dacf1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 049/140] kodi: revbump for ffmpeg4-4.4.3

---
 srcpkgs/kodi/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/kodi/template b/srcpkgs/kodi/template
index 8057964d78a3..6cc1874be7ba 100644
--- a/srcpkgs/kodi/template
+++ b/srcpkgs/kodi/template
@@ -1,7 +1,7 @@
 # Template file for 'kodi'
 pkgname=kodi
 version=19.4
-revision=6
+revision=7
 _codename="Matrix"
 build_style=cmake
 configure_args="-DWITH_FFMPEG=/usr -DENABLE_LDGOLD=OFF
@@ -54,7 +54,7 @@ makedepends="
  libmad-devel fontconfig-devel libXinerama-devel libsamplerate-devel libmms-devel
  enca-devel boost-devel libcurl-devel libva-devel libvdpau-devel libass-devel
  libbluetooth-devel yajl-devel libplist-devel librtmp-devel tinyxml-devel
- taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg-devel
+ taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg4-devel
  giflib-devel libxslt-devel gnutls-devel libssh-devel libmicrohttpd-devel
  libcec-devel dcadec-devel flatbuffers-devel fmt-devel lcms2-devel
  libfstrcmp-devel rapidjson libcdio-paranoia spdlog libwaylandpp-devel

From 345e9511ce2c59a3609c3cfe767722687453bdb1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 050/140] kpipewire: revbump for ffmpeg-6.0

---
 srcpkgs/kpipewire/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kpipewire/template b/srcpkgs/kpipewire/template
index 467ab823a5e1..51827f24db9e 100644
--- a/srcpkgs/kpipewire/template
+++ b/srcpkgs/kpipewire/template
@@ -1,7 +1,7 @@
 # Template file for 'kpipewire'
 pkgname=kpipewire
 version=5.27.4
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules plasma-wayland-protocols gettext
  qt5-qmake qt5-host-tools pkg-config wayland-devel kcoreaddons

From 24053eaa9fc09bc454ee9eb01511621c5c48a44d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 051/140] libextractor: revbump for ffmpeg4-4.4.3

---
 srcpkgs/libextractor/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libextractor/template b/srcpkgs/libextractor/template
index ddd4790f93e8..1fb9ca56a96a 100644
--- a/srcpkgs/libextractor/template
+++ b/srcpkgs/libextractor/template
@@ -7,7 +7,7 @@ configure_args="--disable-static"
 hostmakedepends="pkg-config"
 makedepends="zlib-devel bzip2-devel exiv2-devel tiff-devel libpng-devel
  libjpeg-turbo-devel libvorbis-devel libflac-devel giflib-devel libmpeg2-devel
- ffmpeg-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
+ ffmpeg4-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
 short_desc="Library used to extract meta data from files"
 maintainer="Martin Riese <grauehaare@gmx.de>"
 license="GPL-3.0-or-later"

From 86cb35a9f5c68b3598d5fdf806e541d0d818ea79 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 052/140] libopenal: revbump for ffmpeg-6.0

---
 srcpkgs/libopenal/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenal/template b/srcpkgs/libopenal/template
index 77218f9e539d..3f49ed75a1fd 100644
--- a/srcpkgs/libopenal/template
+++ b/srcpkgs/libopenal/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenal'
 pkgname=libopenal
 version=1.22.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DALSOFT_EXAMPLES=OFF"
 hostmakedepends="pkg-config"

From 0320728c9770a94718824c7064e8014dc581b2dd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 053/140] libopenshot: revbump for ffmpeg-6.0

---
 srcpkgs/libopenshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenshot/template b/srcpkgs/libopenshot/template
index db831f69b474..81aa0d7136d9 100644
--- a/srcpkgs/libopenshot/template
+++ b/srcpkgs/libopenshot/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenshot'
 pkgname=libopenshot
 version=0.3.0
-revision=1
+revision=2
 build_style=cmake
 # Builds fail with Ruby-2.4.1
 configure_args="-DENABLE_RUBY=OFF -DUSE_SYSTEM_JSONCPP=ON"

From a8850c66c56b254f339c01730cf536a36e20c851 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 054/140] loudgain: revbump for ffmpeg-6.0

---
 srcpkgs/loudgain/patches/ffmpeg5.patch | 11 +++++++++++
 srcpkgs/loudgain/template              |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/loudgain/patches/ffmpeg5.patch

diff --git a/srcpkgs/loudgain/patches/ffmpeg5.patch b/srcpkgs/loudgain/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..16d4510ee98f
--- /dev/null
+++ b/srcpkgs/loudgain/patches/ffmpeg5.patch
@@ -0,0 +1,11 @@
+--- a/src/scan.c	2019-09-06 11:31:19.000000000 -0400
++++ b/src/scan.c	2023-03-23 11:15:40.867968521 -0400
+@@ -69,8 +69,6 @@
+ 	 * It is now useless
+ 	 * https://github.com/FFmpeg/FFmpeg/blob/70d25268c21cbee5f08304da95be1f647c630c15/doc/APIchanges#L86
+ 	 */
+-  if (avformat_version() < AV_VERSION_INT(58,9,100))
+-    av_register_all();
+ 
+ 	av_log_set_callback(scan_av_log);
+ 
diff --git a/srcpkgs/loudgain/template b/srcpkgs/loudgain/template
index da4f2d56e94c..4d6bf29efb4f 100644
--- a/srcpkgs/loudgain/template
+++ b/srcpkgs/loudgain/template
@@ -1,7 +1,7 @@
 # Template file for 'loudgain'
 pkgname=loudgain
 version=0.6.8
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libebur128-devel taglib-devel ffmpeg-devel"

From 78c33ebcb4b9c30d700461716cffd0a59e480b5c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 055/140] mediastreamer: revbump for ffmpeg4-4.4.3

---
 srcpkgs/mediastreamer/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mediastreamer/template b/srcpkgs/mediastreamer/template
index d0e97e858e29..1bde031443a5 100644
--- a/srcpkgs/mediastreamer/template
+++ b/srcpkgs/mediastreamer/template
@@ -1,11 +1,11 @@
 # Template file for 'mediastreamer'
 pkgname=mediastreamer
 version=5.2.6
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_STRICT=0 -DENABLE_UNIT_TESTS=0"
 hostmakedepends="python3"
-makedepends="bzrtp-devel ffmpeg-devel glew-devel libXv-devel libsrtp-devel
+makedepends="bzrtp-devel ffmpeg4-devel glew-devel libXv-devel libsrtp-devel
  libupnp-devel libvpx-devel mbedtls-devel opus-devel ortp-devel pulseaudio-devel
  libtheora-devel speex-devel v4l-utils-devel bcg729-devel bcmatroska2-devel libgsm-devel"
 # zxing-cpp-devel (1.2.0 probably not compatible, check again after updaing xzing)

From 74a40808546a46252594896a3a939199ead27675 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 056/140] mgba: revbump for ffmpeg-6.0

---
 srcpkgs/mgba/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mgba/template b/srcpkgs/mgba/template
index ae0504311eee..d31295a0cd3d 100644
--- a/srcpkgs/mgba/template
+++ b/srcpkgs/mgba/template
@@ -1,7 +1,7 @@
 # Template file for 'mgba'
 pkgname=mgba
 version=0.10.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake desktop-file-utils"
 makedepends="SDL2-devel ffmpeg-devel libedit-devel libepoxy-devel libmagick-devel

From b8e1f5567fb37dce052377785069a5e37ac88b0a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 057/140] minidlna: revbump for ffmpeg-6.0

---
 srcpkgs/minidlna/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/minidlna/template b/srcpkgs/minidlna/template
index e8081b1cbc67..9ee9714861fd 100644
--- a/srcpkgs/minidlna/template
+++ b/srcpkgs/minidlna/template
@@ -1,7 +1,7 @@
 # Template file for 'minidlna'
 pkgname=minidlna
 version=1.3.2
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="
  --sbindir=/usr/bin

From 4a1c6b28e96b9b4b3a7343688ffb58f6a611050e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 058/140] mixxx: revbump for ffmpeg-6.0

---
 srcpkgs/mixxx/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mixxx/template b/srcpkgs/mixxx/template
index 619ddca0d332..4b9ea00d3fb3 100644
--- a/srcpkgs/mixxx/template
+++ b/srcpkgs/mixxx/template
@@ -1,7 +1,7 @@
 # Template file for 'mixxx'
 pkgname=mixxx
 version=2.3.3
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="extra-cmake-modules pkg-config protobuf qt5-host-tools qt5-devel"

From 7f23c0e62bcadba7e24ce2e1a3198ee4bfea78fe Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 059/140] mlt: revbump for ffmpeg4-4.4.3

---
 srcpkgs/mlt/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mlt/template b/srcpkgs/mlt/template
index 8933eb4e7bb9..73353fedafb5 100644
--- a/srcpkgs/mlt/template
+++ b/srcpkgs/mlt/template
@@ -1,14 +1,14 @@
 # Template file for 'mlt'
 pkgname=mlt
 version=6.26.1
-revision=1
+revision=2
 build_style=configure
 configure_args="--prefix=/usr --libdir=/usr/lib$XBPS_TARGET_WORDSIZE
  --enable-gpl --enable-gpl3 --disable-swfdec --without-kde
  --swig-languages=python"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which"
 # XXX: movit vid.stab
-makedepends="alsa-lib-devel ffmpeg-devel gtk+-devel jack-devel ladspa-sdk
+makedepends="alsa-lib-devel ffmpeg4-devel gtk+-devel jack-devel ladspa-sdk
  libexif-devel libsamplerate-devel libxml2-devel sox-devel SDL_image-devel
  fftw-devel frei0r-plugins python3-devel pulseaudio-devel movit-devel
  libvidstab-devel libatomic-devel"

From 7426dae5d7ab434ea223f0e79fe4b7c6a830ceb9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 060/140] moc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/moc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/moc/template b/srcpkgs/moc/template
index c42be650a1d2..d4f0eefbad52 100644
--- a/srcpkgs/moc/template
+++ b/srcpkgs/moc/template
@@ -1,10 +1,10 @@
 # Template file for 'moc'
 pkgname=moc
 version=2.5.2
-revision=6
+revision=7
 build_style=gnu-configure
 hostmakedepends="pkg-config"
-makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg-devel
+makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg4-devel
  jack-devel alsa-lib-devel libltdl-devel libflac-devel libvorbis-devel
  libmad-devel libmpcdec-devel libmodplug-devel libid3tag-devel faad2-devel
  taglib-devel libsndfile-devel wavpack-devel speex-devel libsamplerate-devel

From 8b3ce3fef5898d875463b31509c8794d36fae97f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 061/140] motion: revbump for ffmpeg-6.0

---
 srcpkgs/motion/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/motion/template b/srcpkgs/motion/template
index 3cf3c3035c5b..7dca12d851e3 100644
--- a/srcpkgs/motion/template
+++ b/srcpkgs/motion/template
@@ -1,7 +1,7 @@
 # Template file for 'motion'
 pkgname=motion
 version=4.5.1
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake pkg-config gettext-devel tar"
 makedepends="ffmpeg-devel libmicrohttpd-devel v4l-utils-devel gettext-devel"

From f46cbaf4c6f4dee663f07532151cf4f778b728eb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 062/140] mpv: revbump for ffmpeg-6.0

---
 srcpkgs/mpv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpv/template b/srcpkgs/mpv/template
index e163c496c6eb..d4fefbf5e3c7 100644
--- a/srcpkgs/mpv/template
+++ b/srcpkgs/mpv/template
@@ -1,7 +1,7 @@
 # Template file for 'mpv'
 pkgname=mpv
 version=0.35.1
-revision=2
+revision=3
 build_style=meson
 configure_args="-Dcdda=enabled -Ddvbin=enabled -Ddvdnav=enabled
  -Dlibmpv=true -Dcplugins=enabled

From e3b0a90b4158a37fdb4020f4aff351ad675e1979 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 063/140] musikcube: revbump for ffmpeg-6.0

---
 srcpkgs/musikcube/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/musikcube/template b/srcpkgs/musikcube/template
index 4b7930041126..7cd65cf76b77 100644
--- a/srcpkgs/musikcube/template
+++ b/srcpkgs/musikcube/template
@@ -1,7 +1,7 @@
 # Template file for 'musikcube'
 pkgname=musikcube
 version=0.99.4
-revision=1
+revision=2
 build_style=cmake
 make_cmd=make
 configure_args="-DNO_NCURSESW=1"

From d4b795f42b057ed90a2ff99719a8bb8b00bf3cd5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 064/140] notcurses: revbump for ffmpeg-6.0

---
 srcpkgs/notcurses/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/notcurses/template b/srcpkgs/notcurses/template
index 6dd8a091319f..3110c30c9aff 100644
--- a/srcpkgs/notcurses/template
+++ b/srcpkgs/notcurses/template
@@ -1,7 +1,7 @@
 # Template file for 'notcurses'
 pkgname=notcurses
 version=3.0.9
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DUSE_STATIC=ON $(vopt_bool man USE_PANDOC)"
 hostmakedepends="pkg-config $(vopt_if man pandoc)"

From cba457bf8a12bb55c5c145d9bcc50bc685eadab1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 065/140] obs: revbump for ffmpeg-6.0

---
 srcpkgs/obs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/obs/template b/srcpkgs/obs/template
index 89fd11297c3f..3cf49e414bf3 100644
--- a/srcpkgs/obs/template
+++ b/srcpkgs/obs/template
@@ -1,7 +1,7 @@
 # Template file for 'obs'
 pkgname=obs
 version=29.1.0
-revision=1
+revision=2
 archs="i686* x86_64* ppc64le* aarch64*"
 build_style=cmake
 configure_args="-DOBS_VERSION_OVERRIDE=${version} -DENABLE_JACK=ON

From dc07ee177bf1f11a77e38d6d9af319e2b3cc3a79 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 066/140] olive: revbump for ffmpeg4-4.4.3

---
 srcpkgs/olive/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/olive/template b/srcpkgs/olive/template
index 12a46936c990..5c2917b9c512 100644
--- a/srcpkgs/olive/template
+++ b/srcpkgs/olive/template
@@ -1,10 +1,10 @@
 # Template file for 'olive'
 pkgname=olive
 version=0.1.2
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools pkg-config"
-makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg-devel frei0r-plugins"
+makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg4-devel frei0r-plugins"
 short_desc="Non-linear video editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"

From b43691adbdd8f7326caa228f2e246ddc0e80c550 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 067/140] omxplayer: revbump for ffmpeg4-4.4.3

---
 srcpkgs/omxplayer/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/omxplayer/template b/srcpkgs/omxplayer/template
index e70bf7873d4d..c835103d8789 100644
--- a/srcpkgs/omxplayer/template
+++ b/srcpkgs/omxplayer/template
@@ -1,10 +1,10 @@
 # Template file for 'omxplayer'
 pkgname=omxplayer
 version=20190102
-revision=1
+revision=2
 short_desc="Commandline OMX player for the Raspberry Pi"
 maintainer="Orphaned <orphan@voidlinux.org>"
-license="GPL-2"
+license="GPL-2-or-later"
 homepage="https://github.com/popcornmix/omxplayer"
 
 _commit="f06235cc9690a6d58187514452df8cf8fcdaacec"
@@ -15,7 +15,7 @@ checksum=af2d9450f8947842ea8c401fe9f71eec444013ebbdee29f2ac828c9c493c1329
 archs="armv6l* armv7l*"
 build_style=gnu-makefile
 hostmakedepends="curl pkg-config"
-makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg-devel dbus-devel"
+makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg4-devel dbus-devel"
 depends="freefont-ttf"
 
 do_build() {

From c181523e510ad21c7ca28b2647415853ae05f127 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 068/140] openimageio: revbump for ffmpeg-6.0

---
 common/shlibs                | 2 ++
 srcpkgs/openimageio/template | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/shlibs b/common/shlibs
index 4626cfda810b..d0d328b09ef9 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2262,6 +2262,8 @@ libxmp.so.4 libxmp-4.3.7_1
 libKF5ThreadWeaver.so.5 threadweaver-5.26.0_1
 libOpenImageIO_Util.so.2.4 openimageio-2.4.9.0_1
 libOpenImageIO.so.2.4 openimageio-2.4.9.0_1
+libOpenImageIO_Util.so.2.4 openimageio-2.4.8.1_1
+libOpenImageIO.so.2.4 openimageio-2.4.8.1_1
 libOpenColorIO.so.2.1 opencolorio-2.1.2_1
 libpystring.so.1 pystring-1.1.3_1
 libyaml-cpp.so.0.7 yaml-cpp-0.7.0_1
diff --git a/srcpkgs/openimageio/template b/srcpkgs/openimageio/template
index b661bbf7ba57..9b38ace50f7e 100644
--- a/srcpkgs/openimageio/template
+++ b/srcpkgs/openimageio/template
@@ -1,7 +1,7 @@
 # Template file for 'openimageio'
 pkgname=openimageio
 version=2.4.9.0
-revision=2
+revision=3
 build_style=cmake
 build_helper=qemu
 configure_args="-DUSE_QT=0 -DUSE_PYTHON=0 -DOIIO_BUILD_TESTS=0

From 0d93cf026a7b56a3bd6f942c63c71bc4b48b43dd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 069/140] openmw: revbump for ffmpeg-6.0

---
 srcpkgs/openmw/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openmw/template b/srcpkgs/openmw/template
index 5251a0283dc1..e3771c7aaf1a 100644
--- a/srcpkgs/openmw/template
+++ b/srcpkgs/openmw/template
@@ -1,7 +1,7 @@
 # Template file for 'openmw'
 pkgname=openmw
 version=0.47.0
-revision=4
+revision=5
 build_style=cmake
 _recast_commit=e75adf86f91eb3082220085e42dda62679f9a3ea
 _bullet_tag=3.17

From 96a94e42a7719eca112174c79402331d7a079615 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 070/140] openshot: revbump for ffmpeg-6.0

---
 srcpkgs/openshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openshot/template b/srcpkgs/openshot/template
index 322717d40abc..c074e0338773 100644
--- a/srcpkgs/openshot/template
+++ b/srcpkgs/openshot/template
@@ -1,7 +1,7 @@
 # Template file for 'openshot'
 pkgname=openshot
 version=3.0.0
-revision=1
+revision=2
 build_style=python3-module
 hostmakedepends="python3 python3-setuptools"
 makedepends="ffmpeg-devel python3-PyQt5"

From 16853b969fd4289d545dc8e8539de5970c4b431e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 071/140] opentoonz: revbump for ffmpeg-6.0

---
 srcpkgs/opentoonz/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/opentoonz/template b/srcpkgs/opentoonz/template
index ee9f7603f55f..3e81834ca0ed 100644
--- a/srcpkgs/opentoonz/template
+++ b/srcpkgs/opentoonz/template
@@ -1,7 +1,7 @@
 # Template file for 'opentoonz'
 pkgname=opentoonz
 version=1.6.0
-revision=2
+revision=3
 build_wrksrc="toonz/sources"
 build_style=cmake
 make_cmd=make

From bddb16cb1c74d93f687afbdb8306c6f0c35084ba Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 072/140] pianobar: revbump for ffmpeg-6.0

---
 srcpkgs/pianobar/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pianobar/template b/srcpkgs/pianobar/template
index a9b29e91993f..81efcd122c4d 100644
--- a/srcpkgs/pianobar/template
+++ b/srcpkgs/pianobar/template
@@ -1,7 +1,7 @@
 # Template file for 'pianobar'
 pkgname=pianobar
 version=2022.04.01
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="V=1"
 hostmakedepends="pkg-config"

From 90cae6cbf0b385f4536714f5f2acba544de56f46 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 073/140] ppsspp: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ppsspp/template | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/ppsspp/template b/srcpkgs/ppsspp/template
index 7984a733d4be..15a42fd2c993 100644
--- a/srcpkgs/ppsspp/template
+++ b/srcpkgs/ppsspp/template
@@ -1,7 +1,7 @@
 # Template file for 'ppsspp'
 pkgname=ppsspp
 version=1.14.4
-revision=1
+revision=2
 _glslang_commit=dc11adde23c455a24e13dd54de9b4ede8bdd7db8
 _SPIRV_Cross_commit=9acb9ec31f5a8ef80ea6b994bb77be787b08d3d1
 _armips_commit=6719edebaae03330ee5441d9b28280672edf00d5
@@ -13,7 +13,7 @@ configure_args="-DHEADLESS=1 -DUSE_SYSTEM_FFMPEG=1 -DUNITTEST=ON
  -DUSING_QT_UI=$(vopt_if qt ON OFF) -DUSE_SYSTEM_ZSTD=ON
  -DARMIPS_USE_STD_FILESYSTEM=ON"
 hostmakedepends="pkg-config python3 $(vopt_if qt qt5-host-tools)"
-makedepends="zlib-devel glew-devel ffmpeg-devel libzip-devel
+makedepends="zlib-devel glew-devel ffmpeg4-devel libzip-devel
  snappy-devel rapidjson libpng-devel libzstd-devel
  $(vopt_if sdl2 SDL2-devel) $(vopt_if wayland wayland-devel)
  $(vopt_if qt 'qt5-devel qt5-multimedia-devel')"
@@ -62,13 +62,12 @@ post_extract() {
 	mv ${wrksrc}/miniupnp-${_miniupnp_commit} ${wrksrc}/ext/miniupnp
 }
 
-post_patch(){
+post_patch() {
 	# disable git versioning
 	vsed -e 's|find_package(Git)|# &|' -i git-version.cmake
 }
 
 do_install() {
-	vlicense LICENSE.TXT
 	vinstall icons/icon.svg 644 usr/share/pixmaps ppsspp.svg
 	vinstall Qt/PPSSPP.desktop 644 usr/share/applications
 	vbin build/PPSSPPHeadless ppsspp-headless

From cb6988a511ed1a99d34dcc0121889f28cdfcbbe7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 074/140] pqiv: revbump for ffmpeg-6.0

---
 srcpkgs/pqiv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pqiv/template b/srcpkgs/pqiv/template
index 542fc27a2d32..9308d949b6a1 100644
--- a/srcpkgs/pqiv/template
+++ b/srcpkgs/pqiv/template
@@ -1,7 +1,7 @@
 # Template file for 'pqiv'
 pkgname=pqiv
 version=2.12
-revision=1
+revision=2
 build_style=gnu-makefile
 hostmakedepends="pkg-config"
 makedepends="glib-devel gtk+3-devel $(vopt_if ffmpeg ffmpeg-devel)

From c2a2a18c8a5809c68bb764ec475b4131042e7192 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 075/140] qmmp: revbump for ffmpeg-6.0

---
 srcpkgs/qmmp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qmmp/template b/srcpkgs/qmmp/template
index 26c661ed16be..a150d7441c7a 100644
--- a/srcpkgs/qmmp/template
+++ b/srcpkgs/qmmp/template
@@ -1,7 +1,7 @@
 # Template file for 'qmmp'
 pkgname=qmmp
 version=1.6.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DUSE_HAL:BOOL=FALSE -DQMMP_DEFAULT_UI:STRING=simple"
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From 9057694e1c778a3107703dd582126ca58902dc18 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 076/140] qt5-webengine: update to 5.15.13

---
 .../chromium-media-filters-cpp14.patch        |  11 ++
 srcpkgs/qt5-webengine/patches/ffmpeg5.patch   | 179 ++++++++++++++++++
 srcpkgs/qt5-webengine/template                |  10 +-
 3 files changed, 195 insertions(+), 5 deletions(-)
 create mode 100644 srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/ffmpeg5.patch

diff --git a/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
new file mode 100644
index 000000000000..04adc540f2cb
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
@@ -0,0 +1,11 @@
+--- a/src/3rdparty/chromium/media/filters/BUILD.gn	2023-02-27 13:32:59.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/BUILD.gn	2023-04-02 17:21:39.204066384 -0400
+@@ -96,6 +96,8 @@
+     "//ui/gfx/geometry:geometry",
+   ]
+ 
++  cflags_cc = [ "-std=c++14" ]
++
+   libs = []
+ 
+   if (proprietary_codecs) {
diff --git a/srcpkgs/qt5-webengine/patches/ffmpeg5.patch b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..ac55e1634423
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
@@ -0,0 +1,179 @@
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:57.732547446 -0400
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:09.486478995 -0400
+@@ -57,6 +57,8 @@
+ 
+ namespace {
+ 
++constexpr int64_t kRelativeTsBase = static_cast<int64_t>(0x7ffeffffffffffff);
++
+ void SetAVStreamDiscard(AVStream* stream, AVDiscard discard) {
+   DCHECK(stream);
+   stream->discard = discard;
+@@ -90,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+   if (stream->start_time != kNoFFmpegTimestamp)
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (stream->first_dts != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, stream->first_dts);
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -408,11 +398,11 @@
+   scoped_refptr<DecoderBuffer> buffer;
+ 
+   if (type() == DemuxerStream::TEXT) {
+-    int id_size = 0;
++    size_t id_size = 0;
+     uint8_t* id_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
+ 
+-    int settings_size = 0;
++    size_t settings_size = 0;
+     uint8_t* settings_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
+ 
+@@ -424,7 +414,7 @@
+     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
+                                      side_data.data(), side_data.size());
+   } else {
+-    int side_data_size = 0;
++    size_t side_data_size = 0;
+     uint8_t* side_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
+ 
+@@ -485,7 +475,7 @@
+                                        packet->size - data_offset);
+     }
+ 
+-    int skip_samples_size = 0;
++    size_t skip_samples_size = 0;
+     const uint32_t* skip_samples_ptr =
+         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
+             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
+@@ -1587,6 +1577,8 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++      continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+       lowest_start_time_stream = stream.get();
+@@ -1604,6 +1596,8 @@
+     if (stream && stream->type() == DemuxerStream::VIDEO &&
+         stream->IsEnabled()) {
+       video_stream = stream.get();
++      if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++        continue;
+       if (video_stream->start_time() <= seek_time) {
+         return video_stream;
+       }
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h qtwebengine-5.15.10/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h
+--- a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-07-11 22:12:47.917192788 -0500
+@@ -29,6 +29,7 @@ extern "C" {
+ #include <libavformat/avformat.h>
+ #include <libavformat/avio.h>
+ #include <libavutil/avutil.h>
++#include <libavutil/channel_layout.h>
+ #include <libavutil/imgutils.h>
+ #include <libavutil/log.h>
+ #include <libavutil/mastering_display_metadata.h>
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/audio_file_reader.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/audio_file_reader.cc
+--- a/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -85,7 +85,7 @@ bool AudioFileReader::OpenDemuxer() {
+ }
+ 
+ bool AudioFileReader::OpenDecoder() {
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (codec) {
+     // MP3 decodes to S16P which we don't support, tell it to use S16 instead.
+     if (codec_context_->sample_fmt == AV_SAMPLE_FMT_S16P)
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -329,7 +329,7 @@ bool FFmpegAudioDecoder::ConfigureDecode
+     }
+   }
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec ||
+       avcodec_open2(codec_context_.get(), codec, &codec_options) < 0) {
+     DLOG(ERROR) << "Could not initialize audio decoder: "
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -59,7 +59,6 @@ static int64_t AVIOSeekOperation(void* o
+ }
+ 
+ void FFmpegGlue::InitializeFFmpeg() {
+-  av_register_all();
+ }
+ 
+ static void LogContainer(bool is_local_file,
+@@ -95,9 +94,6 @@ FFmpegGlue::FFmpegGlue(FFmpegURLProtocol
+   // Enable fast, but inaccurate seeks for MP3.
+   format_context_->flags |= AVFMT_FLAG_FAST_SEEK;
+ 
+-  // Ensures we can read out various metadata bits like vp8 alpha.
+-  format_context_->flags |= AVFMT_FLAG_KEEP_SIDE_DATA;
+-
+   // Ensures format parsing errors will bail out. From an audit on 11/2017, all
+   // instances were real failures. Solves bugs like http://crbug.com/710791.
+   format_context_->error_recognition |= AV_EF_EXPLODE;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -391,7 +391,7 @@ bool FFmpegVideoDecoder::ConfigureDecode
+   if (decode_nalus_)
+     codec_context_->flags2 |= AV_CODEC_FLAG2_CHUNKS;
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
+     ReleaseFFmpegResources();
+     return false;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/media_file_checker.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/media_file_checker.cc
+--- a/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -68,7 +68,7 @@ bool MediaFileChecker::Start(base::TimeD
+       auto context = AVStreamToAVCodecContext(format_context->streams[i]);
+       if (!context)
+         continue;
+-      AVCodec* codec = avcodec_find_decoder(cp->codec_id);
++      const AVCodec* codec = avcodec_find_decoder(cp->codec_id);
+       if (codec && avcodec_open2(context.get(), codec, nullptr) >= 0) {
+         auto loop = std::make_unique<FFmpegDecodingLoop>(context.get());
+         stream_contexts[i] = {std::move(context), std::move(loop)};
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc qtwebengine-5.15.10/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc
+--- a/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -203,7 +203,7 @@ int32_t H264DecoderImpl::InitDecode(cons
+   // a pointer |this|.
+   av_context_->opaque = this;
+ 
+-  AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
+   if (!codec) {
+     // This is an indication that FFmpeg has not been initialized or it has not
+     // been compiled/initialized with the correct set of codecs.
diff --git a/srcpkgs/qt5-webengine/template b/srcpkgs/qt5-webengine/template
index 0a71484208bc..095ab67701e4 100644
--- a/srcpkgs/qt5-webengine/template
+++ b/srcpkgs/qt5-webengine/template
@@ -1,9 +1,9 @@
 # Template file for 'qt5-webengine'
 pkgname=qt5-webengine
-version=5.15.11
-revision=2
+version=5.15.13
+revision=1
 _version="${version}-lts"
-_chromium_commit=be349eaf62e77955791d7bf29f893f1e8a37daf4
+_chromium_commit=e48df7803c7c98b0b2471c94057d32e44a301ad5
 archs="x86_64* i686* armv[67]* ppc64* aarch64*"
 create_wrksrc=yes
 build_style=qmake
@@ -32,8 +32,8 @@ license="GPL-3.0-or-later, LGPL-3.0-or-later"
 homepage="https://qt.io/"
 distfiles="https://github.com/qt/qtwebengine/archive/v${_version}.tar.gz
  https://github.com/qt/qtwebengine-chromium/archive/${_chromium_commit}.tar.gz"
-checksum="aa7466356c450c5f5870f979b93cd7e7e62da1165c328ffcab1a9928db18ad67
- 6f47ed8ab8cc062411f6f206da6353bc8263d6ed6d6290c689a05c01d91f646b"
+checksum="4b59838ed75ef788b59e1e412535a0e42dd9d311661fdeadb191b581ba815c63
+ a91686562b1d4e8b220e0bbcbab5feb64630e2de974b35ac034bf388af771a6c"
 
 no_generic_pkgconfig_link=yes
 build_options="sndio pipewire"

From 9e6975288419beaa47ec110318f59cdd112cc36f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 077/140] qt5: update to 5.15.8

---
 ...erywhere-opensource-src-5.15.8-kf5-1.patch | 12913 ++++++++++++++++
 srcpkgs/qt5/template                          |    12 +-
 2 files changed, 12919 insertions(+), 6 deletions(-)
 create mode 100644 srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch

diff --git a/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch b/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch
new file mode 100644
index 000000000000..966c98bcd3bb
--- /dev/null
+++ b/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch
@@ -0,0 +1,12913 @@
+Submitted By:            Pierre Labastie <pierre_dot_labastie_at_neuf_dot_fr>
+Date:                    2023-01-05
+Initial Package Version: 5.15.8
+Upstream Status:         Applied (according to KDE)
+Origin:                  KDE patch set
+Description:             Patch set maintained by the KDE folks
+see https://dot.kde.org/2021/04/06/announcing-kdes-qt-5-patch-collection
+Patch generated using the procedure in
+https://wiki.linuxfromscratch.org/blfs/ticket/17476#comment:3
+
+Submodule qtbase 4ee4fc18..9cf586d6:
+diff --git a/qtbase/mkspecs/common/android/qplatformdefs.h b/qtbase/mkspecs/common/android/qplatformdefs.h
+index f75bc4093b..2bd59410d4 100644
+--- a/qtbase/mkspecs/common/android/qplatformdefs.h
++++ b/qtbase/mkspecs/common/android/qplatformdefs.h
+@@ -144,11 +144,7 @@
+ #define QT_SIGNAL_ARGS          int
+ #define QT_SIGNAL_IGNORE        SIG_IGN
+ 
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+ #define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+ 
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+diff --git a/qtbase/mkspecs/features/mac/sdk.mk b/qtbase/mkspecs/features/mac/sdk.mk
+index f30b5830b4..a32ceacb6c 100644
+--- a/qtbase/mkspecs/features/mac/sdk.mk
++++ b/qtbase/mkspecs/features/mac/sdk.mk
+@@ -1,6 +1,6 @@
+ 
+ ifeq ($(QT_MAC_SDK_NO_VERSION_CHECK),)
+-    CHECK_SDK_COMMAND = /usr/bin/xcrun --sdk $(EXPORT_QMAKE_MAC_SDK) -show-sdk-version 2>&1
++    CHECK_SDK_COMMAND = /usr/bin/xcrun --sdk $(EXPORT_QMAKE_MAC_SDK) -show-sdk-version 2>/dev/null
+     CURRENT_MAC_SDK_VERSION := $(shell DEVELOPER_DIR=$(EXPORT_QMAKE_XCODE_DEVELOPER_PATH) $(CHECK_SDK_COMMAND))
+     ifneq ($(CURRENT_MAC_SDK_VERSION),$(EXPORT_QMAKE_MAC_SDK_VERSION))
+         # We don't want to complain about out of date SDK unless the target needs to be remade.
+diff --git a/qtbase/mkspecs/linux-clang/qplatformdefs.h b/qtbase/mkspecs/linux-clang/qplatformdefs.h
+index a818d973f0..c1ab72fbc6 100644
+--- a/qtbase/mkspecs/linux-clang/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-clang/qplatformdefs.h
+@@ -79,14 +79,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-g++/qplatformdefs.h b/qtbase/mkspecs/linux-g++/qplatformdefs.h
+index 13523f0702..4d2750d9ec 100644
+--- a/qtbase/mkspecs/linux-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-g++/qplatformdefs.h
+@@ -79,14 +79,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ < 2)
+-#define QT_SOCKLEN_T            int
+-#else
+-#define QT_SOCKLEN_T            socklen_t
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-llvm/qplatformdefs.h b/qtbase/mkspecs/linux-llvm/qplatformdefs.h
+index dc750ab1ef..d3cc39b47f 100644
+--- a/qtbase/mkspecs/linux-llvm/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-llvm/qplatformdefs.h
+@@ -80,14 +80,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h b/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
+index 4c4e53da2a..83baffb3e3 100644
+--- a/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
+@@ -85,16 +85,9 @@
+ #include "../common/posix/qplatformdefs.h"
+ 
+ #undef QT_OPEN_LARGEFILE
+-#undef QT_SOCKLEN_T
+ 
+ #define QT_OPEN_LARGEFILE       0
+ 
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #ifndef SIOCGIFBRDADDR
+ #  define SIOCGIFBRDADDR 0x8919
+ #endif
+diff --git a/qtbase/mkspecs/lynxos-g++/qplatformdefs.h b/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
+index 4339ea2b23..6007af0055 100644
+--- a/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
+@@ -72,14 +72,6 @@
+ 
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp b/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
+index c3c184258f..32af3f8f29 100644
+--- a/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
++++ b/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
+@@ -10,6 +10,7 @@
+ #include "libANGLE/HandleAllocator.h"
+ 
+ #include <algorithm>
++#include <limits>
+ 
+ #include "common/debug.h"
+ 
+diff --git a/qtbase/src/3rdparty/forkfd/forkfd_linux.c b/qtbase/src/3rdparty/forkfd/forkfd_linux.c
+index ffe0e9a5e2..b1f5408d11 100644
+--- a/qtbase/src/3rdparty/forkfd/forkfd_linux.c
++++ b/qtbase/src/3rdparty/forkfd/forkfd_linux.c
+@@ -82,7 +82,8 @@ static int sys_clone(unsigned long cloneflags, int *ptid)
+     return syscall(__NR_clone, cloneflags, child_stack, stack_size, ptid, newtls, ctid);
+ #elif defined(__arc__) || defined(__arm__) || defined(__aarch64__) || defined(__mips__) || \
+     defined(__nds32__) || defined(__hppa__) || defined(__powerpc__) || defined(__i386__) || \
+-    defined(__x86_64__) || defined(__xtensa__) || defined(__alpha__) || defined(__riscv)
++    defined(__x86_64__) || defined(__xtensa__) || defined(__alpha__) || defined(__riscv) || \
++    defined(__loongarch__)
+     /* ctid and newtls are inverted on CONFIG_CLONE_BACKWARDS architectures,
+      * but since both values are 0, there's no harm. */
+     return syscall(__NR_clone, cloneflags, child_stack, ptid, ctid, newtls);
+diff --git a/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java b/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
+index 5792b5b2f5..2f74750fcf 100644
+--- a/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
++++ b/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
+@@ -116,6 +116,7 @@ public class QtNative
+     public static QtThread m_qtThread = new QtThread();
+     private static HashMap<String, Uri> m_cachedUris = new HashMap<String, Uri>();
+     private static ArrayList<String> m_knownDirs = new ArrayList<String>();
++    private static final String NoPermissionErrorMessage = "No permissions to open Uri";
+ 
+     private static final Runnable runPendingCppRunnablesRunnable = new Runnable() {
+         @Override
+@@ -193,11 +194,10 @@ public class QtNative
+                     return iterUri;
+             }
+ 
+-            // Android 6 and earlier could still manage to open the file so we can return the
+-            // parsed uri here
+-            if (Build.VERSION.SDK_INT < 24)
+-                return parsedUri;
+-            return null;
++            // if we only have transient permissions on uri all the above will fail,
++            // but we will be able to read the file anyway, so continue with uri here anyway
++            // and check for SecurityExceptions later
++            return parsedUri;
+         } catch (SecurityException e) {
+             e.printStackTrace();
+             return null;
+@@ -244,7 +244,7 @@ public class QtNative
+         int error = -1;
+ 
+         if (uri == null) {
+-            Log.e(QtTAG, "openFdForContentUrl(): No permissions to open Uri");
++            Log.e(QtTAG, "openFdForContentUrl(): " + NoPermissionErrorMessage);
+             return error;
+         }
+ 
+@@ -254,12 +254,13 @@ public class QtNative
+             return fdDesc.detachFd();
+         } catch (FileNotFoundException e) {
+             e.printStackTrace();
+-            return error;
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "openFdForContentUrl(): Invalid Uri");
+             e.printStackTrace();
+-            return error;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return error;
+     }
+ 
+     public static long getSize(Context context, String contentUrl)
+@@ -270,7 +271,7 @@ public class QtNative
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+ 
+         if (uri == null) {
+-            Log.e(QtTAG, "getSize(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return size;
+         } else if (!m_cachedUris.containsKey(contentUrl)) {
+             m_cachedUris.put(contentUrl, uri);
+@@ -288,12 +289,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "getSize(): Invalid Uri");
+             e.printStackTrace();
+-            return size;
+         }  catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "getSize(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return size;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return size;
+     }
+ 
+     public static boolean checkFileExists(Context context, String contentUrl)
+@@ -303,7 +305,7 @@ public class QtNative
+         if (uri == null)
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+         if (uri == null) {
+-            Log.e(QtTAG, "checkFileExists(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return exists;
+         } else {
+             if (!m_cachedUris.containsKey(contentUrl))
+@@ -321,12 +323,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "checkFileExists(): Invalid Uri");
+             e.printStackTrace();
+-            return exists;
+         } catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "checkFileExists(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return false;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return exists;
+     }
+ 
+     public static boolean checkIfWritable(Context context, String contentUrl)
+@@ -344,7 +347,7 @@ public class QtNative
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+         }
+         if (uri == null) {
+-            Log.e(QtTAG, "isDir(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return isDir;
+         } else {
+             if (!m_cachedUris.containsKey(contentUrl))
+@@ -374,12 +377,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "checkIfDir(): Invalid Uri");
+             e.printStackTrace();
+-            return false;
+         } catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "checkIfDir(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return false;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return false;
+     }
+     public static String[] listContentsFromTreeUri(Context context, String contentUrl)
+     {
+diff --git a/qtbase/src/concurrent/qtconcurrentreducekernel.h b/qtbase/src/concurrent/qtconcurrentreducekernel.h
+index 8f9a938952..a98dedef2e 100644
+--- a/qtbase/src/concurrent/qtconcurrentreducekernel.h
++++ b/qtbase/src/concurrent/qtconcurrentreducekernel.h
+@@ -212,11 +212,13 @@ public:
+ 
+     inline bool shouldThrottle()
+     {
++        std::lock_guard<QMutex> locker(mutex);
+         return (resultsMapSize > (ReduceQueueThrottleLimit * threadCount));
+     }
+ 
+     inline bool shouldStartThread()
+     {
++        std::lock_guard<QMutex> locker(mutex);
+         return (resultsMapSize <= (ReduceQueueStartLimit * threadCount));
+     }
+ };
+diff --git a/qtbase/src/concurrent/qtconcurrentthreadengine.cpp b/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
+index ea6ce3ac42..7f91a2ba68 100644
+--- a/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
++++ b/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
+@@ -176,6 +176,39 @@ void ThreadEngineBase::startSingleThreaded()
+     finish();
+ }
+ 
++void ThreadEngineBase::startBlocking()
++{
++    start();
++    barrier.acquire();
++    startThreads();
++
++    bool throttled = false;
++#ifndef QT_NO_EXCEPTIONS
++    try {
++#endif
++        while (threadFunction() == ThrottleThread) {
++            if (threadThrottleExit()) {
++                throttled = true;
++                break;
++            }
++        }
++#ifndef QT_NO_EXCEPTIONS
++    } catch (QException &e) {
++        handleException(e);
++    } catch (...) {
++        handleException(QUnhandledException());
++    }
++#endif
++
++    if (throttled == false) {
++        barrier.release();
++    }
++
++    barrier.wait();
++    finish();
++    exceptionStore.throwPossibleException();
++}
++
+ void ThreadEngineBase::startThread()
+ {
+     startThreadInternal();
+diff --git a/qtbase/src/concurrent/qtconcurrentthreadengine.h b/qtbase/src/concurrent/qtconcurrentthreadengine.h
+index 7c30cebdbc..a4c8548cc4 100644
+--- a/qtbase/src/concurrent/qtconcurrentthreadengine.h
++++ b/qtbase/src/concurrent/qtconcurrentthreadengine.h
+@@ -91,6 +91,7 @@ public:
+     ThreadEngineBase();
+     virtual ~ThreadEngineBase();
+     void startSingleThreaded();
++    void startBlocking();
+     void startThread();
+     bool isCanceled();
+     void waitForResume();
+@@ -143,6 +144,15 @@ public:
+         return result();
+     }
+ 
++    // Runs the user algorithm using multiple threads.
++    // This function blocks until the algorithm is finished,
++    // and then returns the result.
++    T *startBlocking()
++    {
++        ThreadEngineBase::startBlocking();
++        return result();
++    }
++
+     // Runs the user algorithm using multiple threads.
+     // Does not block, returns a future.
+     QFuture<T> startAsynchronously()
+@@ -223,6 +233,13 @@ class ThreadEngineStarter : public ThreadEngineStarterBase<T>
+ public:
+     ThreadEngineStarter(TypedThreadEngine *eng)
+         : Base(eng) { }
++
++    T startBlocking()
++    {
++        T t = *this->threadEngine->startBlocking();
++        delete this->threadEngine;
++        return t;
++    }
+ };
+ 
+ // Full template specialization where T is void.
+@@ -232,6 +249,12 @@ class ThreadEngineStarter<void> : public ThreadEngineStarterBase<void>
+ public:
+     ThreadEngineStarter(ThreadEngine<void> *_threadEngine)
+         : ThreadEngineStarterBase<void>(_threadEngine) {}
++
++    void startBlocking()
++    {
++        this->threadEngine->startBlocking();
++        delete this->threadEngine;
++    }
+ };
+ 
+ //! [qtconcurrentthreadengine-1]
+diff --git a/qtbase/src/corelib/animation/qvariantanimation.cpp b/qtbase/src/corelib/animation/qvariantanimation.cpp
+index 98b02f0202..eac1524107 100644
+--- a/qtbase/src/corelib/animation/qvariantanimation.cpp
++++ b/qtbase/src/corelib/animation/qvariantanimation.cpp
+@@ -276,7 +276,9 @@ void QVariantAnimationPrivate::setCurrentValueForProgress(const qreal progress)
+ 
+     const qreal startProgress = currentInterval.start.first;
+     const qreal endProgress = currentInterval.end.first;
+-    const qreal localProgress = (progress - startProgress) / (endProgress - startProgress);
++    const qreal localProgress =
++            qIsNull(progress - startProgress) ? 0.0 // avoid 0/0 below
++            /* else */                        : (progress - startProgress) / (endProgress - startProgress);
+ 
+     QVariant ret = q->interpolated(currentInterval.start.second,
+                                    currentInterval.end.second,
+diff --git a/qtbase/src/corelib/global/qnamespace.h b/qtbase/src/corelib/global/qnamespace.h
+index ad4150b317..bf19b1627b 100644
+--- a/qtbase/src/corelib/global/qnamespace.h
++++ b/qtbase/src/corelib/global/qnamespace.h
+@@ -1864,7 +1864,7 @@ public:
+     QT_Q_ENUM(TimerType)
+     QT_Q_ENUM(ScrollPhase)
+     QT_Q_ENUM(MouseEventSource)
+-    QT_Q_FLAG(MouseEventFlag)
++    QT_Q_FLAG(MouseEventFlags)
+     QT_Q_ENUM(ChecksumType)
+     QT_Q_ENUM(HighDpiScaleFactorRoundingPolicy)
+     QT_Q_ENUM(TabFocusBehavior)
+diff --git a/qtbase/src/corelib/global/qrandom.cpp b/qtbase/src/corelib/global/qrandom.cpp
+index 10672c1f92..25f87c7e6a 100644
+--- a/qtbase/src/corelib/global/qrandom.cpp
++++ b/qtbase/src/corelib/global/qrandom.cpp
+@@ -383,7 +383,6 @@ struct QRandomGenerator::SystemAndGlobalGenerators
+ 
+         constexpr SystemAndGlobalGenerators g = {};
+         Q_UNUSED(g);
+-        Q_STATIC_ASSERT(std::is_literal_type<SystemAndGlobalGenerators>::value);
+ #endif
+     }
+ 
+diff --git a/qtbase/src/corelib/io/qbuffer.cpp b/qtbase/src/corelib/io/qbuffer.cpp
+index 595fcd2724..032c0ddd4b 100644
+--- a/qtbase/src/corelib/io/qbuffer.cpp
++++ b/qtbase/src/corelib/io/qbuffer.cpp
+@@ -41,6 +41,8 @@
+ #include <QtCore/qmetaobject.h>
+ #include "private/qiodevice_p.h"
+ 
++#include <limits>
++
+ QT_BEGIN_NAMESPACE
+ 
+ /** QBufferPrivate **/
+@@ -366,7 +368,9 @@ qint64 QBuffer::size() const
+ bool QBuffer::seek(qint64 pos)
+ {
+     Q_D(QBuffer);
+-    if (pos > d->buf->size() && isWritable()) {
++    const auto oldBufSize = d->buf->size();
++    constexpr qint64 MaxSeekPos = (std::numeric_limits<decltype(oldBufSize)>::max)();
++    if (pos <= MaxSeekPos && pos > oldBufSize && isWritable()) {
+         if (seek(d->buf->size())) {
+             const qint64 gapSize = pos - d->buf->size();
+             if (write(QByteArray(gapSize, 0)) != gapSize) {
+@@ -377,7 +381,7 @@ bool QBuffer::seek(qint64 pos)
+             return false;
+         }
+     } else if (pos > d->buf->size() || pos < 0) {
+-        qWarning("QBuffer::seek: Invalid pos: %d", int(pos));
++        qWarning("QBuffer::seek: Invalid pos: %lld", pos);
+         return false;
+     }
+     return QIODevice::seek(pos);
+diff --git a/qtbase/src/corelib/io/qfilesystemengine_win.cpp b/qtbase/src/corelib/io/qfilesystemengine_win.cpp
+index 81d3a71986..c86ed1f9b0 100644
+--- a/qtbase/src/corelib/io/qfilesystemengine_win.cpp
++++ b/qtbase/src/corelib/io/qfilesystemengine_win.cpp
+@@ -664,14 +664,14 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry)
+     return QFileSystemEntry(ret, QFileSystemEntry::FromInternalPath());
+ }
+ 
+-#if defined(Q_CC_MINGW) && WINVER < 0x0602 //  Windows 8 onwards
++#if defined(Q_CC_MINGW) && WINVER < 0x0602 && _WIN32_WINNT < _WIN32_WINNT_WIN8 //  Windows 8 onwards
+ 
+ typedef struct _FILE_ID_INFO {
+     ULONGLONG VolumeSerialNumber;
+     FILE_ID_128 FileId;
+ } FILE_ID_INFO, *PFILE_ID_INFO;
+ 
+-#endif // if defined (Q_CC_MINGW) && WINVER < 0x0602
++#endif // if defined(Q_CC_MINGW) && WINVER < 0x0602 && _WIN32_WINNT < _WIN32_WINNT_WIN8
+ 
+ // File ID for Windows up to version 7 and FAT32 drives
+ static inline QByteArray fileId(HANDLE handle)
+diff --git a/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp b/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
+index 94d9d06bcb..27e0b13b0b 100644
+--- a/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
++++ b/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
+@@ -366,7 +366,9 @@ void QInotifyFileSystemWatcherEngine::readFromInotify()
+     // qDebug("QInotifyFileSystemWatcherEngine::readFromInotify");
+ 
+     int buffSize = 0;
+-    ioctl(inotifyFd, FIONREAD, (char *) &buffSize);
++    if (ioctl(inotifyFd, FIONREAD, (char *) &buffSize) == -1 || buffSize == 0)
++        return;
++
+     QVarLengthArray<char, 4096> buffer(buffSize);
+     buffSize = read(inotifyFd, buffer.data(), buffSize);
+     char *at = buffer.data();
+diff --git a/qtbase/src/corelib/io/qlockfile_win.cpp b/qtbase/src/corelib/io/qlockfile_win.cpp
+index 277f8d4230..38ecef5550 100644
+--- a/qtbase/src/corelib/io/qlockfile_win.cpp
++++ b/qtbase/src/corelib/io/qlockfile_win.cpp
+@@ -48,6 +48,8 @@
+ #include "QtCore/qdebug.h"
+ #include "QtCore/qthread.h"
+ 
++#include "private/qsystemlibrary_p.h"
++
+ QT_BEGIN_NAMESPACE
+ 
+ static inline bool fileExists(const wchar_t *fileName)
+@@ -150,7 +152,7 @@ QString QLockFilePrivate::processNameByPid(qint64 pid)
+ #if !defined(Q_OS_WINRT)
+     typedef DWORD (WINAPI *GetModuleFileNameExFunc)(HANDLE, HMODULE, LPTSTR, DWORD);
+ 
+-    HMODULE hPsapi = LoadLibraryA("psapi");
++    HMODULE hPsapi = QSystemLibrary::load(L"psapi");
+     if (!hPsapi)
+         return QString();
+     GetModuleFileNameExFunc qGetModuleFileNameEx = reinterpret_cast<GetModuleFileNameExFunc>(
+diff --git a/qtbase/src/corelib/io/qprocess_unix.cpp b/qtbase/src/corelib/io/qprocess_unix.cpp
+index 50390e57f5..15c8f30745 100644
+--- a/qtbase/src/corelib/io/qprocess_unix.cpp
++++ b/qtbase/src/corelib/io/qprocess_unix.cpp
+@@ -1,7 +1,7 @@
+ /****************************************************************************
+ **
+ ** Copyright (C) 2016 The Qt Company Ltd.
+-** Copyright (C) 2016 Intel Corporation.
++** Copyright (C) 2022 Intel Corporation.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtCore module of the Qt Toolkit.
+@@ -422,14 +422,15 @@ void QProcessPrivate::startProcess()
+     // Add the program name to the argument list.
+     argv[0] = nullptr;
+     if (!program.contains(QLatin1Char('/'))) {
++        // findExecutable() returns its argument if it's an absolute path,
++        // otherwise it searches $PATH; returns empty if not found (we handle
++        // that case much later)
+         const QString &exeFilePath = QStandardPaths::findExecutable(program);
+-        if (!exeFilePath.isEmpty()) {
+-            const QByteArray &tmp = QFile::encodeName(exeFilePath);
+-            argv[0] = ::strdup(tmp.constData());
+-        }
+-    }
+-    if (!argv[0])
++        const QByteArray &tmp = QFile::encodeName(exeFilePath);
++        argv[0] = ::strdup(tmp.constData());
++    } else {
+         argv[0] = ::strdup(encodedProgramName.constData());
++    }
+ 
+     // Add every argument to the list
+     for (int i = 0; i < arguments.count(); ++i)
+@@ -983,15 +984,16 @@ bool QProcessPrivate::startDetached(qint64 *pid)
+                 envp = _q_dupEnvironment(environment.d.constData()->vars, &envc);
+             }
+ 
+-            QByteArray tmp;
+             if (!program.contains(QLatin1Char('/'))) {
++                // findExecutable() returns its argument if it's an absolute path,
++                // otherwise it searches $PATH; returns empty if not found (we handle
++                // that case much later)
+                 const QString &exeFilePath = QStandardPaths::findExecutable(program);
+-                if (!exeFilePath.isEmpty())
+-                    tmp = QFile::encodeName(exeFilePath);
++                const QByteArray &tmp = QFile::encodeName(exeFilePath);
++                argv[0] = ::strdup(tmp.constData());
++            } else {
++                argv[0] = ::strdup(QFile::encodeName(program));
+             }
+-            if (tmp.isEmpty())
+-                tmp = QFile::encodeName(program);
+-            argv[0] = tmp.data();
+ 
+             if (envp)
+                 qt_safe_execve(argv[0], argv, envp);
+diff --git a/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp b/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
+index 3a79c502af..997a634e76 100644
+--- a/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
++++ b/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
+@@ -3196,9 +3196,8 @@ bool QAbstractItemModel::beginMoveColumns(const QModelIndex &sourceParent, int s
+     destinationChange.needsAdjust = destinationParent.isValid() && destinationParent.row() >= sourceLast && destinationParent.parent() == sourceParent;
+     d->changes.push(destinationChange);
+ 
+-    d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Horizontal);
+-
+     emit columnsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, QPrivateSignal());
++    d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Horizontal);
+     return true;
+ }
+ 
+@@ -3231,7 +3230,6 @@ void QAbstractItemModel::endMoveColumns()
+       adjustedSource = createIndex(adjustedSource.row(), adjustedSource.column() + numMoved, adjustedSource.internalPointer());
+ 
+     d->itemsMoved(adjustedSource, removeChange.first, removeChange.last, adjustedDestination, insertChange.first, Qt::Horizontal);
+-
+     emit columnsMoved(adjustedSource, removeChange.first, removeChange.last, adjustedDestination, insertChange.first, QPrivateSignal());
+ }
+ 
+diff --git a/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+index dc6379d9fb..c5e287ee84 100644
+--- a/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
++++ b/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+@@ -939,8 +939,9 @@ void QSortFilterProxyModelPrivate::insert_source_items(
+                 q->beginInsertColumns(proxy_parent, proxy_start, proxy_end);
+         }
+ 
+-        for (int i = 0; i < source_items.size(); ++i)
+-            proxy_to_source.insert(proxy_start + i, source_items.at(i));
++        // TODO: use the range QList::insert() overload once it is implemented (QTBUG-58633).
++        proxy_to_source.insert(proxy_start, source_items.size(), 0);
++        std::copy(source_items.cbegin(), source_items.cend(), proxy_to_source.begin() + proxy_start);
+ 
+         build_source_to_proxy_mapping(proxy_to_source, source_to_proxy);
+ 
+@@ -3123,8 +3124,9 @@ bool QSortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex &
+ 
+     if (d->filter_data.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();
+@@ -3133,9 +3135,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.hasMatch(key);
+ }
+diff --git a/qtbase/src/corelib/kernel/qcoreapplication.cpp b/qtbase/src/corelib/kernel/qcoreapplication.cpp
+index ca2864df83..132b2eae52 100644
+--- a/qtbase/src/corelib/kernel/qcoreapplication.cpp
++++ b/qtbase/src/corelib/kernel/qcoreapplication.cpp
+@@ -1157,7 +1157,7 @@ static bool doNotify(QObject *receiver, QEvent *event)
+ bool QCoreApplicationPrivate::sendThroughApplicationEventFilters(QObject *receiver, QEvent *event)
+ {
+     // We can't access the application event filters outside of the main thread (race conditions)
+-    Q_ASSERT(receiver->d_func()->threadData.loadRelaxed()->thread.loadAcquire() == mainThread());
++    Q_ASSERT(receiver->d_func()->threadData.loadAcquire()->thread.loadRelaxed() == mainThread());
+ 
+     if (extraData) {
+         // application event filters are only called for objects in the GUI thread
+diff --git a/qtbase/src/corelib/kernel/qobject.cpp b/qtbase/src/corelib/kernel/qobject.cpp
+index 1eb79138d9..36cd780ee1 100644
+--- a/qtbase/src/corelib/kernel/qobject.cpp
++++ b/qtbase/src/corelib/kernel/qobject.cpp
+@@ -1010,7 +1010,7 @@ QObject::~QObject()
+         emit destroyed(this);
+     }
+ 
+-    if (d->declarativeData) {
++    if (!d->isDeletingChildren && d->declarativeData) {
+         if (static_cast<QAbstractDeclarativeDataImpl*>(d->declarativeData)->ownedByQml1) {
+             if (QAbstractDeclarativeData::destroyed_qml1)
+                 QAbstractDeclarativeData::destroyed_qml1(d->declarativeData, this);
+@@ -1580,7 +1580,7 @@ void QObject::moveToThread(QThread *targetThread)
+ 
+     QThreadData *currentData = QThreadData::current();
+     QThreadData *targetData = targetThread ? QThreadData::get2(targetThread) : nullptr;
+-    QThreadData *thisThreadData = d->threadData.loadRelaxed();
++    QThreadData *thisThreadData = d->threadData.loadAcquire();
+     if (!thisThreadData->thread.loadAcquire() && currentData == targetData) {
+         // one exception to the rule: we allow moving objects with no thread affinity to the current thread
+         currentData = d->threadData;
+@@ -2620,7 +2620,7 @@ int QObject::receivers(const char *signal) const
+         if (!d->isSignalConnected(signal_index))
+             return receivers;
+ 
+-        if (d->declarativeData && QAbstractDeclarativeData::receivers) {
++        if (!d->isDeletingChildren && d->declarativeData && QAbstractDeclarativeData::receivers) {
+             receivers += QAbstractDeclarativeData::receivers(d->declarativeData, this,
+                                                              signal_index);
+         }
+diff --git a/qtbase/src/corelib/kernel/qobject_p.h b/qtbase/src/corelib/kernel/qobject_p.h
+index 0b827a52ca..13ffb88999 100644
+--- a/qtbase/src/corelib/kernel/qobject_p.h
++++ b/qtbase/src/corelib/kernel/qobject_p.h
+@@ -444,7 +444,7 @@ inline void QObjectPrivate::checkForIncompatibleLibraryVersion(int version) cons
+ 
+ inline bool QObjectPrivate::isDeclarativeSignalConnected(uint signal_index) const
+ {
+-    return declarativeData && QAbstractDeclarativeData::isSignalConnected
++    return !isDeletingChildren && declarativeData && QAbstractDeclarativeData::isSignalConnected
+             && QAbstractDeclarativeData::isSignalConnected(declarativeData, q_func(), signal_index);
+ }
+ 
+diff --git a/qtbase/src/corelib/kernel/qtranslator.cpp b/qtbase/src/corelib/kernel/qtranslator.cpp
+index 2812ffb7ea..bc0177c5ec 100644
+--- a/qtbase/src/corelib/kernel/qtranslator.cpp
++++ b/qtbase/src/corelib/kernel/qtranslator.cpp
+@@ -902,7 +902,7 @@ static QString getMessage(const uchar *m, const uchar *end, const char *context,
+             goto end;
+         case Tag_Translation: {
+             int len = read32(m);
+-            if (len % 1)
++            if (len & 1)
+                 return QString();
+             m += 4;
+             if (!numerus--) {
+diff --git a/qtbase/src/corelib/mimetypes/qmimedatabase.cpp b/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
+index 9de22cef33..ff868a3268 100644
+--- a/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
+@@ -389,20 +389,23 @@ QMimeType QMimeDatabasePrivate::mimeTypeForFileNameAndData(const QString &fileNa
+         // Disambiguate conflicting extensions (if magic matching found something)
+         if (candidateByData.isValid() && magicAccuracy > 0) {
+             const QString sniffedMime = candidateByData.name();
+-            // If the sniffedMime matches a glob match, use it
++            // If the sniffedMime matches a highest-weight glob match, use it
+             if (candidatesByName.m_matchingMimeTypes.contains(sniffedMime)) {
+                 *accuracyPtr = 100;
+                 return candidateByData;
+             }
+-            for (const QString &m : qAsConst(candidatesByName.m_matchingMimeTypes)) {
++            for (const QString &m : qAsConst(candidatesByName.m_allMatchingMimeTypes)) {
+                 if (inherits(m, sniffedMime)) {
+                     // We have magic + pattern pointing to this, so it's a pretty good match
+                     *accuracyPtr = 100;
+                     return mimeTypeForName(m);
+                 }
+             }
+-            *accuracyPtr = magicAccuracy;
+-            return candidateByData;
++            if (candidatesByName.m_allMatchingMimeTypes.isEmpty()) {
++                // No glob, use magic
++                *accuracyPtr = magicAccuracy;
++                return candidateByData;
++            }
+         }
+     }
+ 
+diff --git a/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp b/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
+index a81112d227..fa8f4c545d 100644
+--- a/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
+@@ -83,7 +83,10 @@ void QMimeGlobMatchResult::addMatch(const QString &mimeType, int weight, const Q
+     }
+     if (!m_matchingMimeTypes.contains(mimeType)) {
+         m_matchingMimeTypes.append(mimeType);
+-        m_allMatchingMimeTypes.append(mimeType);
++        if (replace)
++            m_allMatchingMimeTypes.prepend(mimeType); // highest-weight first
++        else
++            m_allMatchingMimeTypes.append(mimeType);
+         m_knownSuffixLength = knownSuffixLength;
+     }
+ }
+@@ -94,7 +97,7 @@ QMimeGlobPattern::PatternType QMimeGlobPattern::detectPatternType(const QString
+     if (!patternLength)
+         return OtherPattern;
+ 
+-    const bool starCount = pattern.count(QLatin1Char('*')) == 1;
++    const int starCount = pattern.count(QLatin1Char('*'));
+     const bool hasSquareBracket = pattern.indexOf(QLatin1Char('[')) != -1;
+     const bool hasQuestionMark = pattern.indexOf(QLatin1Char('?')) != -1;
+ 
+@@ -106,10 +109,10 @@ QMimeGlobPattern::PatternType QMimeGlobPattern::detectPatternType(const QString
+             // Patterns like "README*" (well this is currently the only one like that...)
+             if (pattern.at(patternLength - 1) == QLatin1Char('*'))
+                 return PrefixPattern;
+-        }
+-        // Names without any wildcards like "README"
+-        if (starCount == 0)
++        } else if (starCount == 0) {
++            // Names without any wildcards like "README"
+             return LiteralPattern;
++        }
+     }
+ 
+     if (pattern == QLatin1String("[0-9][0-9][0-9].vdr"))
+diff --git a/qtbase/src/corelib/mimetypes/qmimeprovider.cpp b/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
+index 258dddf8cb..4642d0f2d0 100644
+--- a/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
+@@ -244,15 +244,18 @@ void QMimeBinaryProvider::addFileNameMatches(const QString &fileName, QMimeGlobM
+     const QString lowerFileName = fileName.toLower();
+     // Check literals (e.g. "Makefile")
+     matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosLiteralListOffset), fileName);
+-    // Check complex globs (e.g. "callgrind.out[0-9]*")
+-    matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosGlobListOffset), fileName);
+     // Check the very common *.txt cases with the suffix tree
+-    const int reverseSuffixTreeOffset = m_cacheFile->getUint32(PosReverseSuffixTreeOffset);
+-    const int numRoots = m_cacheFile->getUint32(reverseSuffixTreeOffset);
+-    const int firstRootOffset = m_cacheFile->getUint32(reverseSuffixTreeOffset + 4);
+-    matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, lowerFileName, lowerFileName.length() - 1, false);
++    if (result.m_matchingMimeTypes.isEmpty()) {
++        const int reverseSuffixTreeOffset = m_cacheFile->getUint32(PosReverseSuffixTreeOffset);
++        const int numRoots = m_cacheFile->getUint32(reverseSuffixTreeOffset);
++        const int firstRootOffset = m_cacheFile->getUint32(reverseSuffixTreeOffset + 4);
++        matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, lowerFileName, lowerFileName.length() - 1, false);
++        if (result.m_matchingMimeTypes.isEmpty())
++            matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, fileName, fileName.length() - 1, true);
++    }
++    // Check complex globs (e.g. "callgrind.out[0-9]*" or "README*")
+     if (result.m_matchingMimeTypes.isEmpty())
+-        matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, fileName, fileName.length() - 1, true);
++        matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosGlobListOffset), fileName);
+ }
+ 
+ void QMimeBinaryProvider::matchGlobList(QMimeGlobMatchResult &result, CacheFile *cacheFile, int off, const QString &fileName)
+diff --git a/qtbase/src/corelib/serialization/qjsonparser.cpp b/qtbase/src/corelib/serialization/qjsonparser.cpp
+index 17e6f111ab..2e40b6c8fb 100644
+--- a/qtbase/src/corelib/serialization/qjsonparser.cpp
++++ b/qtbase/src/corelib/serialization/qjsonparser.cpp
+@@ -379,10 +379,30 @@ error:
+     return QCborValue();
+ }
+ 
++// We need to retain the _last_ value for any duplicate keys and we need to deref containers.
++// Therefore the manual implementation of std::unique().
++template<typename Iterator, typename Compare, typename Assign>
++static Iterator customAssigningUniqueLast(Iterator first, Iterator last,
++                                          Compare compare, Assign assign)
++{
++    first = std::adjacent_find(first, last, compare);
++    if (first == last)
++        return last;
++
++    Iterator result = first;
++    while (++first != last) {
++        if (!compare(*result, *first))
++            ++result;
++        if (result != first)
++            assign(*result, *first);
++    }
++
++    return ++result;
++}
++
+ static void sortContainer(QCborContainerPrivate *container)
+ {
+     using Forward = QJsonPrivate::KeyIterator;
+-    using Reverse = std::reverse_iterator<Forward>;
+     using Value = Forward::value_type;
+ 
+     auto compare = [container](const Value &a, const Value &b)
+@@ -420,17 +440,31 @@ static void sortContainer(QCborContainerPrivate *container)
+         }
+     };
+ 
+-    std::sort(Forward(container->elements.begin()), Forward(container->elements.end()),
+-              [&compare](const Value &a, const Value &b) { return compare(a, b) < 0; });
++    // The elements' containers are owned by the outer container, not by the elements themselves.
++    auto move = [](Forward::reference target, Forward::reference source)
++    {
++        QtCbor::Element &targetValue = target.value();
++
++        // If the target has a container, deref it before overwriting, so that we don't leak.
++        if (targetValue.flags & QtCbor::Element::IsContainer)
++            targetValue.container->deref();
++
++        // Do not move, so that we can clear the value afterwards.
++        target = source;
++
++        // Clear the source value, so that we don't store the same container twice.
++        source.value() = QtCbor::Element();
++    };
++
++    std::stable_sort(
++                Forward(container->elements.begin()), Forward(container->elements.end()),
++                [&compare](const Value &a, const Value &b) { return compare(a, b) < 0; });
+ 
+-    // We need to retain the _last_ value for any duplicate keys. Therefore the reverse dance here.
+-    auto it = std::unique(Reverse(container->elements.end()), Reverse(container->elements.begin()),
+-                          [&compare](const Value &a, const Value &b) {
+-        return compare(a, b) == 0;
+-    }).base().elementsIterator();
++    Forward result = customAssigningUniqueLast(
++                Forward(container->elements.begin()),  Forward(container->elements.end()),
++                [&compare](const Value &a, const Value &b) { return compare(a, b) == 0; }, move);
+ 
+-    // The erase from beginning is expensive but hopefully rare.
+-    container->elements.erase(container->elements.begin(), it);
++    container->elements.erase(result.elementsIterator(), container->elements.end());
+ }
+ 
+ 
+diff --git a/qtbase/src/corelib/serialization/qxmlstream.cpp b/qtbase/src/corelib/serialization/qxmlstream.cpp
+index b2f846544d..7cd457ba3a 100644
+--- a/qtbase/src/corelib/serialization/qxmlstream.cpp
++++ b/qtbase/src/corelib/serialization/qxmlstream.cpp
+@@ -980,7 +980,7 @@ inline uint QXmlStreamReaderPrivate::peekChar()
+ bool QXmlStreamReaderPrivate::scanUntil(const char *str, short tokenToInject)
+ {
+     int pos = textBuffer.size();
+-    int oldLineNumber = lineNumber;
++    const auto oldLineNumber = lineNumber;
+ 
+     uint c;
+     while ((c = getChar()) != StreamEOF) {
+diff --git a/qtbase/src/corelib/text/qstring.cpp b/qtbase/src/corelib/text/qstring.cpp
+index 3e88ab4859..8deeae47bb 100644
+--- a/qtbase/src/corelib/text/qstring.cpp
++++ b/qtbase/src/corelib/text/qstring.cpp
+@@ -12312,7 +12312,7 @@ static qsizetype qLastIndexOf(Haystack haystack0, qsizetype from,
+     const auto needle = needle0.data();
+     const auto *end = haystack;
+     haystack += from;
+-    const std::size_t sl_minus_1 = sl - 1;
++    const std::size_t sl_minus_1 = sl ? sl - 1 : 0;
+     const auto *n = needle + sl_minus_1;
+     const auto *h = haystack + sl_minus_1;
+     std::size_t hashNeedle = 0, hashHaystack = 0;
+diff --git a/qtbase/src/corelib/text/qstringiterator_p.h b/qtbase/src/corelib/text/qstringiterator_p.h
+index 219589b6e4..1d0c66cc78 100644
+--- a/qtbase/src/corelib/text/qstringiterator_p.h
++++ b/qtbase/src/corelib/text/qstringiterator_p.h
+@@ -61,6 +61,8 @@ class QStringIterator
+ {
+     QString::const_iterator i, pos, e;
+     Q_STATIC_ASSERT((std::is_same<QString::const_iterator, const QChar *>::value));
++    static bool less(const QChar *lhs, const QChar *rhs) noexcept
++    { return std::less<QString::const_iterator>{}(lhs, rhs); }
+ public:
+     explicit QStringIterator(QStringView string, qsizetype idx = 0)
+         : i(string.begin()),
+@@ -95,7 +97,8 @@ public:
+ 
+     inline void setPosition(QString::const_iterator position)
+     {
+-        Q_ASSERT_X(i <= position && position <= e, Q_FUNC_INFO, "position out of bounds");
++        Q_ASSERT_X(!less(position, i) && !less(e, position),
++                   Q_FUNC_INFO, "position out of bounds");
+         pos = position;
+     }
+ 
+@@ -103,7 +106,7 @@ public:
+ 
+     inline bool hasNext() const
+     {
+-        return pos < e;
++        return less(pos, e);
+     }
+ 
+     inline void advance()
+@@ -120,16 +123,20 @@ public:
+     {
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+-        if (Q_UNLIKELY((pos++)->isHighSurrogate()))
++        if (Q_UNLIKELY((pos++)->isHighSurrogate())) {
++            Q_ASSERT(hasNext() && pos->isLowSurrogate());
+             ++pos;
++        }
+     }
+ 
+     inline uint peekNextUnchecked() const
+     {
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+-        if (Q_UNLIKELY(pos->isHighSurrogate()))
++        if (Q_UNLIKELY(pos->isHighSurrogate())) {
++            Q_ASSERT(less(pos + 1, e) && pos[1].isLowSurrogate());
+             return QChar::surrogateToUcs4(pos[0], pos[1]);
++        }
+ 
+         return pos->unicode();
+     }
+@@ -155,8 +162,10 @@ public:
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+         const QChar cur = *pos++;
+-        if (Q_UNLIKELY(cur.isHighSurrogate()))
++        if (Q_UNLIKELY(cur.isHighSurrogate())) {
++            Q_ASSERT(hasNext() && pos->isLowSurrogate());
+             return QChar::surrogateToUcs4(cur, *pos++);
++        }
+         return cur.unicode();
+     }
+ 
+@@ -166,7 +175,7 @@ public:
+ 
+         const QChar uc = *pos++;
+         if (Q_UNLIKELY(uc.isSurrogate())) {
+-            if (Q_LIKELY(uc.isHighSurrogate() && pos < e && pos->isLowSurrogate()))
++            if (Q_LIKELY(uc.isHighSurrogate() && hasNext() && pos->isLowSurrogate()))
+                 return QChar::surrogateToUcs4(uc, *pos++);
+             return invalidAs;
+         }
+@@ -178,7 +187,7 @@ public:
+ 
+     inline bool hasPrevious() const
+     {
+-        return pos > i;
++        return less(i, pos);
+     }
+ 
+     inline void recede()
+@@ -196,16 +205,20 @@ public:
+     {
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+-        if (Q_UNLIKELY((--pos)->isLowSurrogate()))
++        if (Q_UNLIKELY((--pos)->isLowSurrogate())) {
++            Q_ASSERT(hasPrevious() && pos[-1].isHighSurrogate());
+             --pos;
++        }
+     }
+ 
+     inline uint peekPreviousUnchecked() const
+     {
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+-        if (Q_UNLIKELY(pos[-1].isLowSurrogate()))
++        if (Q_UNLIKELY(pos[-1].isLowSurrogate())) {
++            Q_ASSERT(less(i + 1, pos) && pos[-2].isHighSurrogate());
+             return QChar::surrogateToUcs4(pos[-2], pos[-1]);
++        }
+         return pos[-1].unicode();
+     }
+ 
+@@ -230,8 +243,10 @@ public:
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+         const QChar cur = *--pos;
+-        if (Q_UNLIKELY(cur.isLowSurrogate()))
++        if (Q_UNLIKELY(cur.isLowSurrogate())) {
++            Q_ASSERT(hasPrevious() && pos[-1].isHighSurrogate());
+             return QChar::surrogateToUcs4(*--pos, cur);
++        }
+         return cur.unicode();
+     }
+ 
+@@ -241,7 +256,7 @@ public:
+ 
+         const QChar uc = *--pos;
+         if (Q_UNLIKELY(uc.isSurrogate())) {
+-            if (Q_LIKELY(uc.isLowSurrogate() && pos > i && pos[-1].isHighSurrogate()))
++            if (Q_LIKELY(uc.isLowSurrogate() && hasPrevious() && pos[-1].isHighSurrogate()))
+                 return QChar::surrogateToUcs4(*--pos, uc);
+             return invalidAs;
+         }
+diff --git a/qtbase/src/corelib/thread/qfutex_p.h b/qtbase/src/corelib/thread/qfutex_p.h
+index f287b752d7..e294537787 100644
+--- a/qtbase/src/corelib/thread/qfutex_p.h
++++ b/qtbase/src/corelib/thread/qfutex_p.h
+@@ -52,6 +52,7 @@
+ //
+ 
+ #include <qglobal.h>
++#include <QtCore/qtsan_impl.h>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -106,16 +107,13 @@ namespace QtLinuxFutex {
+     inline int _q_futex(int *addr, int op, int val, quintptr val2 = 0,
+                         int *addr2 = nullptr, int val3 = 0) noexcept
+     {
+-        // A futex call ensures total ordering on the futex words
+-        // (in either success or failure of the call). Instruct TSAN accordingly,
+-        // as TSAN does not understand the futex(2) syscall.
+-        _q_tsan_release(addr, addr2);
++        QtTsan::futexRelease(addr, addr2);
+ 
+         // we use __NR_futex because some libcs (like Android's bionic) don't
+         // provide SYS_futex etc.
+         int result = syscall(__NR_futex, addr, op | FUTEX_PRIVATE_FLAG, val, val2, addr2, val3);
+ 
+-        _q_tsan_acquire(addr, addr2);
++        QtTsan::futexAcquire(addr, addr2);
+ 
+         return result;
+     }
+diff --git a/qtbase/src/corelib/thread/qmutex.cpp b/qtbase/src/corelib/thread/qmutex.cpp
+index 310d1cb14f..7097122d8e 100644
+--- a/qtbase/src/corelib/thread/qmutex.cpp
++++ b/qtbase/src/corelib/thread/qmutex.cpp
+@@ -152,6 +152,7 @@ public:
+ 
+ /*!
+     \enum QMutex::RecursionMode
++    \obsolete Use QRecursiveMutex to create a recursive mutex.
+ 
+     \value Recursive  In this mode, a thread can lock the same mutex
+                       multiple times and the mutex won't be unlocked
+@@ -173,6 +174,7 @@ public:
+ 
+ /*!
+     Constructs a new mutex. The mutex is created in an unlocked state.
++    \obsolete Use QRecursiveMutex to create a recursive mutex.
+ 
+     If \a mode is QMutex::Recursive, a thread can lock the same mutex
+     multiple times and the mutex won't be unlocked until a
+@@ -197,7 +199,7 @@ QMutex::QMutex(RecursionMode mode)
+ QMutex::~QMutex()
+ {
+     QMutexData *d = d_ptr.loadRelaxed();
+-    if (isRecursive()) {
++    if (QBasicMutex::isRecursive()) {
+         delete static_cast<QRecursiveMutexPrivate *>(d);
+     } else if (d) {
+ #ifndef QT_LINUX_FUTEX
+diff --git a/qtbase/src/corelib/thread/qmutex.h b/qtbase/src/corelib/thread/qmutex.h
+index 73c9e00663..1bae573a03 100644
+--- a/qtbase/src/corelib/thread/qmutex.h
++++ b/qtbase/src/corelib/thread/qmutex.h
+@@ -42,6 +42,7 @@
+ 
+ #include <QtCore/qglobal.h>
+ #include <QtCore/qatomic.h>
++#include <QtCore/qtsan_impl.h>
+ #include <new>
+ 
+ #if __has_include(<chrono>)
+@@ -77,19 +78,37 @@ public:
+ 
+     // BasicLockable concept
+     inline void lock() QT_MUTEX_LOCK_NOEXCEPT {
++        QtTsan::mutexPreLock(this, 0u);
++
+         if (!fastTryLock())
+             lockInternal();
++
++        QtTsan::mutexPostLock(this, 0u, 0);
+     }
+ 
+     // BasicLockable concept
+     inline void unlock() noexcept {
+         Q_ASSERT(d_ptr.loadRelaxed()); //mutex must be locked
++
++        QtTsan::mutexPreUnlock(this, 0u);
++
+         if (!fastTryUnlock())
+             unlockInternal();
++
++        QtTsan::mutexPostUnlock(this, 0u);
+     }
+ 
+     bool tryLock() noexcept {
+-        return fastTryLock();
++        unsigned tsanFlags = QtTsan::TryLock;
++        QtTsan::mutexPreLock(this, tsanFlags);
++
++        const bool success = fastTryLock();
++
++        if (!success)
++            tsanFlags |= QtTsan::TryLockFailed;
++        QtTsan::mutexPostLock(this, tsanFlags, 0);
++
++        return success;
+     }
+ 
+     // Lockable concept
+@@ -134,8 +153,16 @@ public:
+ #else
+     QMutex() { d_ptr.storeRelaxed(nullptr); }
+ #endif
++#if QT_DEPRECATED_SINCE(5,15)
+     enum RecursionMode { NonRecursive, Recursive };
++    QT_DEPRECATED_VERSION_X(5, 15, "Use QRecursiveMutex instead of a recursive QMutex")
+     explicit QMutex(RecursionMode mode);
++
++    QT_DEPRECATED_VERSION_X(5, 15, "Use QRecursiveMutex instead of a recursive QMutex")
++    bool isRecursive() const noexcept
++    { return QBasicMutex::isRecursive(); }
++#endif
++
+     ~QMutex();
+ 
+     // BasicLockable concept
+@@ -166,9 +193,6 @@ public:
+     }
+ #endif
+ 
+-    bool isRecursive() const noexcept
+-    { return QBasicMutex::isRecursive(); }
+-
+ private:
+     Q_DISABLE_COPY(QMutex)
+     friend class QMutexLocker;
+diff --git a/qtbase/src/corelib/thread/qreadwritelock.cpp b/qtbase/src/corelib/thread/qreadwritelock.cpp
+index 8c28507d5a..9dd8503116 100644
+--- a/qtbase/src/corelib/thread/qreadwritelock.cpp
++++ b/qtbase/src/corelib/thread/qreadwritelock.cpp
+@@ -155,7 +155,7 @@ QReadWriteLock::QReadWriteLock(RecursionMode recursionMode)
+ */
+ QReadWriteLock::~QReadWriteLock()
+ {
+-    auto d = d_ptr.loadRelaxed();
++    auto d = d_ptr.loadAcquire();
+     if (isUncontendedLocked(d)) {
+         qWarning("QReadWriteLock: destroying locked QReadWriteLock");
+         return;
+@@ -445,7 +445,7 @@ void QReadWriteLock::unlock()
+ /*! \internal  Helper for QWaitCondition::wait */
+ QReadWriteLock::StateForWaitCondition QReadWriteLock::stateForWaitCondition() const
+ {
+-    QReadWriteLockPrivate *d = d_ptr.loadRelaxed();
++    QReadWriteLockPrivate *d = d_ptr.loadAcquire();
+     switch (quintptr(d) & StateMask) {
+     case StateLockedForRead: return LockedForRead;
+     case StateLockedForWrite: return LockedForWrite;
+@@ -453,6 +453,7 @@ QReadWriteLock::StateForWaitCondition QReadWriteLock::stateForWaitCondition() co
+ 
+     if (!d)
+         return Unlocked;
++    const auto lock = qt_scoped_lock(d->mutex);
+     if (d->writerCount > 1)
+         return RecursivelyLocked;
+     else if (d->writerCount == 1)
+diff --git a/qtbase/src/corelib/thread/qsemaphore.cpp b/qtbase/src/corelib/thread/qsemaphore.cpp
+index 1d01fc1b28..3ecdee3747 100644
+--- a/qtbase/src/corelib/thread/qsemaphore.cpp
++++ b/qtbase/src/corelib/thread/qsemaphore.cpp
+@@ -354,7 +354,12 @@ void QSemaphore::release(int n)
+         quintptr nn = unsigned(n);
+         if (futexHasWaiterCount)
+             nn |= quint64(nn) << 32;    // token count replicated in high word
+-        quintptr prevValue = u.fetchAndAddRelease(nn);
++        quintptr prevValue = u.loadRelaxed();
++        quintptr newValue;
++        do { // loop just to ensure the operations are done atomically
++            newValue = prevValue + nn;
++            newValue &= (futexNeedsWakeAllBit - 1);
++        } while (!u.testAndSetRelease(prevValue, newValue, prevValue));
+         if (futexNeedsWake(prevValue)) {
+ #ifdef FUTEX_OP
+             if (futexHasWaiterCount) {
+@@ -376,7 +381,6 @@ void QSemaphore::release(int n)
+                 quint32 oparg = 0;
+                 quint32 cmp = FUTEX_OP_CMP_NE;
+                 quint32 cmparg = 0;
+-                u.fetchAndAndRelease(futexNeedsWakeAllBit - 1);
+                 futexWakeOp(*futexLow32(&u), n, INT_MAX, *futexHigh32(&u), FUTEX_OP(op, oparg, cmp, cmparg));
+                 return;
+             }
+@@ -388,7 +392,6 @@ 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(futexNeedsWakeAllBit - 1);
+             if (futexHasWaiterCount) {
+                 futexWakeAll(*futexLow32(&u));
+                 futexWakeAll(*futexHigh32(&u));
+diff --git a/qtbase/src/corelib/thread/qthread_p.h b/qtbase/src/corelib/thread/qthread_p.h
+index b2d1628e6e..f32f6f0460 100644
+--- a/qtbase/src/corelib/thread/qthread_p.h
++++ b/qtbase/src/corelib/thread/qthread_p.h
+@@ -174,7 +174,7 @@ public:
+     int returnCode;
+ 
+     uint stackSize;
+-    QThread::Priority priority;
++    std::underlying_type<QThread::Priority>::type priority;
+ 
+     static QThread *threadForId(int id);
+ 
+@@ -213,6 +213,13 @@ public:
+             QCoreApplication::instance()->postEvent(q_ptr, new QEvent(QEvent::Quit));
+         }
+     }
++
++#ifndef Q_OS_INTEGRITY
++private:
++    // Used in QThread(Private)::start to avoid racy access to QObject::objectName,
++    // unset afterwards. On INTEGRITY we set the thread name before starting it.
++    QString objectName;
++#endif
+ };
+ 
+ #else // QT_CONFIG(thread)
+diff --git a/qtbase/src/corelib/thread/qthread_unix.cpp b/qtbase/src/corelib/thread/qthread_unix.cpp
+index 56a8e0a038..610117a640 100644
+--- a/qtbase/src/corelib/thread/qthread_unix.cpp
++++ b/qtbase/src/corelib/thread/qthread_unix.cpp
+@@ -169,8 +169,7 @@ static void set_thread_data(QThreadData *data)
+ 
+ static void clear_thread_data()
+ {
+-    currentThreadData = nullptr;
+-    pthread_setspecific(current_thread_data_key, nullptr);
++    set_thread_data(nullptr);
+ }
+ 
+ template <typename T>
+@@ -296,7 +295,7 @@ void *QThreadPrivate::start(void *arg)
+             QMutexLocker locker(&thr->d_func()->mutex);
+ 
+             // do we need to reset the thread priority?
+-            if (int(thr->d_func()->priority) & ThreadPriorityResetFlag) {
++            if (thr->d_func()->priority & ThreadPriorityResetFlag) {
+                 thr->d_func()->setPriority(QThread::Priority(thr->d_func()->priority & ~ThreadPriorityResetFlag));
+             }
+ 
+@@ -316,10 +315,10 @@ void *QThreadPrivate::start(void *arg)
+             // Sets the name of the current thread. We can only do this
+             // when the thread is starting, as we don't have a cross
+             // platform way of setting the name of an arbitrary thread.
+-            if (Q_LIKELY(thr->objectName().isEmpty()))
++            if (Q_LIKELY(thr->d_func()->objectName.isEmpty()))
+                 setCurrentThreadName(thr->metaObject()->className());
+             else
+-                setCurrentThreadName(thr->objectName().toLocal8Bit());
++                setCurrentThreadName(std::exchange(thr->d_func()->objectName, {}).toLocal8Bit());
+         }
+ #endif
+ 
+@@ -671,7 +670,7 @@ void QThread::start(Priority priority)
+                 // could not set scheduling hints, fallback to inheriting them
+                 // we'll try again from inside the thread
+                 pthread_attr_setinheritsched(&attr, PTHREAD_INHERIT_SCHED);
+-                d->priority = Priority(priority | ThreadPriorityResetFlag);
++                d->priority = static_cast<std::underlying_type<QThread::Priority>::type>(priority) | ThreadPriorityResetFlag;
+             }
+             break;
+         }
+@@ -702,7 +701,10 @@ void QThread::start(Priority priority)
+         pthread_attr_setthreadname(&attr, metaObject()->className());
+     else
+         pthread_attr_setthreadname(&attr, objectName().toLocal8Bit());
++#else
++    d->objectName = objectName();
+ #endif
++
+     pthread_t threadId;
+     int code = pthread_create(&threadId, &attr, QThreadPrivate::start, this);
+     if (code == EPERM) {
+diff --git a/qtbase/src/corelib/thread/qthread_win.cpp b/qtbase/src/corelib/thread/qthread_win.cpp
+index bc70e3178a..4e76972498 100644
+--- a/qtbase/src/corelib/thread/qthread_win.cpp
++++ b/qtbase/src/corelib/thread/qthread_win.cpp
+@@ -394,10 +394,9 @@ unsigned int __stdcall QT_ENSURE_STACK_ALIGNED_FOR_SSE QThreadPrivate::start(voi
+ 
+ #if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) && !defined(Q_OS_WINRT)
+     // sets the name of the current thread.
+-    QByteArray objectName = thr->objectName().toLocal8Bit();
+-    qt_set_thread_name(HANDLE(-1),
+-                       objectName.isEmpty() ?
+-                       thr->metaObject()->className() : objectName.constData());
++    qt_set_thread_name(HANDLE(-1), thr->d_func()->objectName.isEmpty()
++                        ? thr->metaObject()->className()
++                        : std::exchange(thr->d_func()->objectName, {}).toLocal8Bit().constData());
+ #endif
+ 
+     emit thr->started(QThread::QPrivateSignal());
+@@ -503,6 +502,7 @@ void QThread::start(Priority priority)
+     if (d->running)
+         return;
+ 
++    d->objectName = objectName();
+     d->running = true;
+     d->finished = false;
+     d->exited = false;
+@@ -548,7 +548,7 @@ void QThread::start(Priority priority)
+ 
+     int prio;
+     d->priority = priority;
+-    switch (d->priority) {
++    switch (priority) {
+     case IdlePriority:
+         prio = THREAD_PRIORITY_IDLE;
+         break;
+@@ -686,7 +686,7 @@ void QThreadPrivate::setPriority(QThread::Priority threadPriority)
+ 
+     int prio;
+     priority = threadPriority;
+-    switch (priority) {
++    switch (threadPriority) {
+     case QThread::IdlePriority:
+         prio = THREAD_PRIORITY_IDLE;
+         break;
+diff --git a/qtbase/src/corelib/thread/qtsan_impl.h b/qtbase/src/corelib/thread/qtsan_impl.h
+new file mode 100644
+index 0000000000..580a738b91
+--- /dev/null
++++ b/qtbase/src/corelib/thread/qtsan_impl.h
+@@ -0,0 +1,115 @@
++/****************************************************************************
++**
++** Copyright (C) 2017 Intel Corporation.
++** Copyright (C) 2022 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
++** 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 QTSAN_IMPL_H
++#define QTSAN_IMPL_H
++
++#include <QtCore/qglobal.h>
++
++#if (__has_feature(thread_sanitizer) || defined(__SANITIZE_THREAD__)) && __has_include(<sanitizer/tsan_interface.h>)
++#  define QT_BUILDING_UNDER_TSAN
++#  include <sanitizer/tsan_interface.h>
++#endif
++
++QT_BEGIN_NAMESPACE
++
++namespace QtTsan {
++#ifdef QT_BUILDING_UNDER_TSAN
++inline void futexAcquire(void *addr, void *addr2 = nullptr)
++{
++    // A futex call ensures total ordering on the futex words
++    // (in either success or failure of the call). Instruct TSAN accordingly,
++    // as TSAN does not understand the futex(2) syscall (or equivalent).
++    ::__tsan_acquire(addr);
++    if (addr2)
++        ::__tsan_acquire(addr2);
++}
++
++inline void futexRelease(void *addr, void *addr2 = nullptr)
++{
++    if (addr2)
++        ::__tsan_release(addr2);
++    ::__tsan_release(addr);
++}
++
++inline void mutexPreLock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_pre_lock(addr, flags);
++}
++
++inline void mutexPostLock(void *addr, unsigned flags, int recursion)
++{
++    ::__tsan_mutex_post_lock(addr, flags, recursion);
++}
++
++inline void mutexPreUnlock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_pre_unlock(addr, flags);
++}
++
++inline void mutexPostUnlock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_post_unlock(addr, flags);
++}
++
++enum : unsigned {
++    MutexWriteReentrant = ::__tsan_mutex_write_reentrant,
++    TryLock = ::__tsan_mutex_try_lock,
++    TryLockFailed = ::__tsan_mutex_try_lock_failed,
++};
++#else
++inline void futexAcquire(void *, void * = nullptr) {}
++inline void futexRelease(void *, void * = nullptr) {}
++
++enum : unsigned {
++    MutexWriteReentrant,
++    TryLock,
++    TryLockFailed,
++};
++inline void mutexPreLock(void *, unsigned) {}
++inline void mutexPostLock(void *, unsigned, int) {}
++inline void mutexPreUnlock(void *, unsigned) {}
++inline void mutexPostUnlock(void *, unsigned) {}
++#endif // QT_BUILDING_UNDER_TSAN
++} // namespace QtTsan
++
++QT_END_NAMESPACE
++
++#endif // QTSAN_IMPL_H
+diff --git a/qtbase/src/corelib/thread/qwaitcondition_unix.cpp b/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
+index 88b058f410..0f1da4dc9b 100644
+--- a/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
++++ b/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
+@@ -213,7 +213,7 @@ bool QWaitCondition::wait(QMutex *mutex, QDeadlineTimer deadline)
+ {
+     if (! mutex)
+         return false;
+-    if (mutex->isRecursive()) {
++    if (static_cast<QBasicMutex *>(mutex)->isRecursive()) {
+         qWarning("QWaitCondition: cannot wait on recursive mutexes");
+         return false;
+     }
+diff --git a/qtbase/src/corelib/time/qdatetime.cpp b/qtbase/src/corelib/time/qdatetime.cpp
+index ec12569e3f..2c0b098079 100644
+--- a/qtbase/src/corelib/time/qdatetime.cpp
++++ b/qtbase/src/corelib/time/qdatetime.cpp
+@@ -43,6 +43,7 @@
+ #if QT_CONFIG(datetimeparser)
+ #include "private/qdatetimeparser_p.h"
+ #endif
++#include <private/qnumeric_p.h>
+ 
+ #include "qdatastream.h"
+ #include "qset.h"
+@@ -1429,9 +1430,11 @@ QDate QDate::addDays(qint64 ndays) const
+     if (isNull())
+         return QDate();
+ 
+-    // Due to limits on minJd() and maxJd() we know that any overflow
+-    // will be invalid and caught by fromJulianDay().
+-    return fromJulianDay(jd + ndays);
++    qint64 r;
++    if (Q_UNLIKELY(add_overflow(jd, ndays, &r)))
++        return QDate();
++    else
++        return fromJulianDay(r);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/corelib/time/qtimezone.cpp b/qtbase/src/corelib/time/qtimezone.cpp
+index 0309e43e52..3d451696a1 100644
+--- a/qtbase/src/corelib/time/qtimezone.cpp
++++ b/qtbase/src/corelib/time/qtimezone.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2013 John Layt <jlayt@kde.org>
++** Copyright (C) 2020 John Layt <jlayt@kde.org>
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtCore module of the Qt Toolkit.
+@@ -975,9 +975,15 @@ QList<QByteArray> QTimeZone::windowsIdToIanaIds(const QByteArray &windowsId,
+ }
+ 
+ #ifndef QT_NO_DATASTREAM
++// Invalid, as an IANA ID: too long, starts with - and has other invalid characters in it
++static inline QString invalidId() { return QStringLiteral("-No Time Zone Specified!"); }
++
+ QDataStream &operator<<(QDataStream &ds, const QTimeZone &tz)
+ {
+-    tz.d->serialize(ds);
++    if (tz.isValid())
++        tz.d->serialize(ds);
++    else
++        ds << invalidId();
+     return ds;
+ }
+ 
+@@ -985,7 +991,9 @@ QDataStream &operator>>(QDataStream &ds, QTimeZone &tz)
+ {
+     QString ianaId;
+     ds >> ianaId;
+-    if (ianaId == QLatin1String("OffsetFromUtc")) {
++    if (ianaId == invalidId()) {
++        tz = QTimeZone();
++    } else if (ianaId == QLatin1String("OffsetFromUtc")) {
+         int utcOffset;
+         QString name;
+         QString abbreviation;
+diff --git a/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp b/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
+index b1611d7ddb..a7a6a72ccf 100644
+--- a/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
++++ b/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
+@@ -42,6 +42,7 @@
+ #include "qtimezone.h"
+ #include "qtimezoneprivate_p.h"
+ #include "private/qlocale_tools_p.h"
++#include "private/qlocking_p.h"
+ 
+ #include <QtCore/QDataStream>
+ #include <QtCore/QDateTime>
+@@ -62,6 +63,10 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++#if QT_CONFIG(icu)
++static QBasicMutex s_icu_mutex;
++#endif
++
+ /*
+     Private
+ 
+@@ -670,6 +675,9 @@ QTzTimeZonePrivate::~QTzTimeZonePrivate()
+ 
+ QTzTimeZonePrivate *QTzTimeZonePrivate::clone() const
+ {
++#if QT_CONFIG(icu)
++    const auto lock = qt_scoped_lock(s_icu_mutex);
++#endif
+     return new QTzTimeZonePrivate(*this);
+ }
+ 
+@@ -913,12 +921,14 @@ QString QTzTimeZonePrivate::displayName(qint64 atMSecsSinceEpoch,
+                                         const QLocale &locale) const
+ {
+ #if QT_CONFIG(icu)
++    auto lock = qt_unique_lock(s_icu_mutex);
+     if (!m_icu)
+         m_icu = new QIcuTimeZonePrivate(m_id);
+     // TODO small risk may not match if tran times differ due to outdated files
+     // TODO Some valid TZ names are not valid ICU names, use translation table?
+     if (m_icu->isValid())
+         return m_icu->displayName(atMSecsSinceEpoch, nameType, locale);
++    lock.unlock();
+ #else
+     Q_UNUSED(nameType)
+     Q_UNUSED(locale)
+@@ -932,12 +942,14 @@ QString QTzTimeZonePrivate::displayName(QTimeZone::TimeType timeType,
+                                         const QLocale &locale) const
+ {
+ #if QT_CONFIG(icu)
++    auto lock = qt_unique_lock(s_icu_mutex);
+     if (!m_icu)
+         m_icu = new QIcuTimeZonePrivate(m_id);
+     // TODO small risk may not match if tran times differ due to outdated files
+     // TODO Some valid TZ names are not valid ICU names, use translation table?
+     if (m_icu->isValid())
+         return m_icu->displayName(timeType, nameType, locale);
++    lock.unlock();
+ #else
+     Q_UNUSED(timeType)
+     Q_UNUSED(nameType)
+diff --git a/qtbase/src/corelib/tools/qarraydata.h b/qtbase/src/corelib/tools/qarraydata.h
+index dcd95924c1..d01739e7e6 100644
+--- a/qtbase/src/corelib/tools/qarraydata.h
++++ b/qtbase/src/corelib/tools/qarraydata.h
+@@ -42,6 +42,7 @@
+ 
+ #include <QtCore/qrefcount.h>
+ #include <string.h>
++#include <cstdint>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -58,14 +59,14 @@ struct Q_CORE_EXPORT QArrayData
+     {
+         Q_ASSERT(size == 0
+                 || offset < 0 || size_t(offset) >= sizeof(QArrayData));
+-        return reinterpret_cast<char *>(this) + offset;
++        return reinterpret_cast<void *> (reinterpret_cast<uintptr_t>(this) + offset);
+     }
+ 
+     const void *data() const
+     {
+         Q_ASSERT(size == 0
+                 || offset < 0 || size_t(offset) >= sizeof(QArrayData));
+-        return reinterpret_cast<const char *>(this) + offset;
++        return reinterpret_cast<void *> (reinterpret_cast<uintptr_t>(this) + offset);
+     }
+ 
+     // This refers to array data mutability, not "header data" represented by
+diff --git a/qtbase/src/corelib/tools/qfreelist_p.h b/qtbase/src/corelib/tools/qfreelist_p.h
+index 5ba23b344b..9974102136 100644
+--- a/qtbase/src/corelib/tools/qfreelist_p.h
++++ b/qtbase/src/corelib/tools/qfreelist_p.h
+@@ -161,7 +161,7 @@ class QFreeList
+                 return i;
+             x -= size;
+         }
+-        Q_ASSERT(false);
++        Q_UNREACHABLE();
+         return -1;
+     }
+ 
+diff --git a/qtbase/src/corelib/tools/qversionnumber.h b/qtbase/src/corelib/tools/qversionnumber.h
+index d43b86ba51..2843f2b043 100644
+--- a/qtbase/src/corelib/tools/qversionnumber.h
++++ b/qtbase/src/corelib/tools/qversionnumber.h
+@@ -273,10 +273,10 @@ public:
+ 
+     Q_REQUIRED_RESULT Q_CORE_EXPORT QString toString() const;
+ #if QT_STRINGVIEW_LEVEL < 2
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(const QString &string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(const QString &string, int *suffixIndex = nullptr);
+ #endif
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QLatin1String string, int *suffixIndex = nullptr);
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QStringView string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(QLatin1String string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(QStringView string, int *suffixIndex = nullptr);
+ 
+ private:
+ #ifndef QT_NO_DATASTREAM
+diff --git a/qtbase/src/dbus/qdbusintegrator.cpp b/qtbase/src/dbus/qdbusintegrator.cpp
+index 5b66ce971b..28a3b0ffea 100644
+--- a/qtbase/src/dbus/qdbusintegrator.cpp
++++ b/qtbase/src/dbus/qdbusintegrator.cpp
+@@ -1135,7 +1135,13 @@ void QDBusConnectionPrivate::closeConnection()
+         }
+     }
+ 
+-    qDeleteAll(pendingCalls);
++    for (auto it = pendingCalls.begin(); it != pendingCalls.end(); ++it) {
++        auto call = *it;
++        if (!call->ref.deref()) {
++            delete call;
++        }
++    }
++    pendingCalls.clear();
+ 
+     // Disconnect all signals from signal hooks and from the object tree to
+     // avoid QObject::destroyed being sent to dbus daemon thread which has
+@@ -2584,6 +2590,11 @@ QDBusConnectionPrivate::findMetaObject(const QString &service, const QString &pa
+         if (mo)
+             return mo;
+     }
++    if (path.isEmpty()) {
++        error = QDBusError(QDBusError::InvalidObjectPath, QLatin1String("Object path cannot be empty"));
++        lastError = error;
++        return nullptr;
++    }
+ 
+     // introspect the target object
+     QDBusMessage msg = QDBusMessage::createMethodCall(service, path,
+diff --git a/qtbase/src/dbus/qdbusmetaobject.cpp b/qtbase/src/dbus/qdbusmetaobject.cpp
+index 5265568f42..7e9f0f1acc 100644
+--- a/qtbase/src/dbus/qdbusmetaobject.cpp
++++ b/qtbase/src/dbus/qdbusmetaobject.cpp
+@@ -210,6 +210,9 @@ QDBusMetaObjectGenerator::findType(const QByteArray &signature,
+         } else if (signature == "a{ss}") {
+             result.name = "QMap<QString,QString>";
+             type = qMetaTypeId<QMap<QString, QString> >();
++        } else if (signature == "aay") {
++            result.name = "QByteArrayList";
++            type = qMetaTypeId<QByteArrayList>();
+         } else {
+             result.name = "{D-Bus type \"" + signature + "\"}";
+             type = registerComplexDBusType(result.name);
+diff --git a/qtbase/src/gui/accessible/qaccessible.cpp b/qtbase/src/gui/accessible/qaccessible.cpp
+index d705bfccb5..0caf3c808c 100644
+--- a/qtbase/src/gui/accessible/qaccessible.cpp
++++ b/qtbase/src/gui/accessible/qaccessible.cpp
+@@ -54,6 +54,7 @@
+ #include <QtCore/qdebug.h>
+ #include <QtCore/qloggingcategory.h>
+ #include <QtCore/qmetaobject.h>
++#include <QtCore/private/qmetaobject_p.h>
+ #include <QtCore/qhash.h>
+ #include <private/qfactoryloader_p.h>
+ 
+@@ -681,6 +682,25 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
+     // Create a QAccessibleInterface for the object class. Start by the most
+     // derived class and walk up the class hierarchy.
+     const QMetaObject *mo = object->metaObject();
++    const auto *objectPriv = QObjectPrivate::get(object);
++    /*
++     We do not want to cache each and every QML metaobject (Button_QMLTYPE_124,
++     Button_QMLTYPE_125, etc.). Those dynamic metaobjects shouldn't have an
++     accessible interface in any case. Instead, we start the whole checking
++     with the first non-dynamic meta-object. To avoid potential regressions
++     in other areas of Qt that also use dynamic metaobjects, we only do this
++     for objects that are QML-related (approximated by checking whether they
++     have ddata set).
++    */
++    const bool qmlRelated = !objectPriv->isDeletingChildren &&
++                            objectPriv->declarativeData;
++    while (qmlRelated && mo) {
++        auto mop = QMetaObjectPrivate::get(mo);
++        if (!mop || !(mop->flags & DynamicMetaObject))
++            break;
++
++        mo = mo->superClass();
++    };
+     while (mo) {
+         const QString cn = QLatin1String(mo->className());
+ 
+@@ -696,14 +716,15 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
+         // Find a QAccessiblePlugin (factory) for the class name. If there's
+         // no entry in the cache try to create it using the plugin loader.
+         if (!qAccessiblePlugins()->contains(cn)) {
++            QAccessiblePlugin *factory = nullptr; // 0 means "no plugin found". This is cached as well.
+             const int index = loader()->indexOf(cn);
+-            if (index != -1) {
+-                QAccessiblePlugin *factory = qobject_cast<QAccessiblePlugin *>(loader()->instance(index));
+-                qAccessiblePlugins()->insert(cn, factory);
+-            }
++            if (index != -1)
++                factory = qobject_cast<QAccessiblePlugin *>(loader()->instance(index));
++            qAccessiblePlugins()->insert(cn, factory);
+         }
+ 
+         // At this point the cache should contain a valid factory pointer or 0:
++        Q_ASSERT(qAccessiblePlugins()->contains(cn));
+         QAccessiblePlugin *factory = qAccessiblePlugins()->value(cn);
+         if (factory) {
+             QAccessibleInterface *result = factory->create(cn, object);
+diff --git a/qtbase/src/gui/configure.json b/qtbase/src/gui/configure.json
+index 1f08795c57..12c95742d2 100644
+--- a/qtbase/src/gui/configure.json
++++ b/qtbase/src/gui/configure.json
+@@ -834,7 +834,8 @@
+                     "// embedded devices, are not intended to be used together with X. EGL support",
+                     "// has to be disabled in plugins like xcb in this case since the native display,",
+                     "// window and pixmap types will be different than what an X-based platform",
+-                    "// plugin would expect."
++                    "// plugin would expect.",
++                    "#define USE_X11"
+                 ],
+                 "include": [ "EGL/egl.h", "X11/Xlib.h" ],
+                 "main": [
+diff --git a/qtbase/src/gui/image/qbmphandler.cpp b/qtbase/src/gui/image/qbmphandler.cpp
+index 96f1e8cb1d..0e73bbbdb0 100644
+--- a/qtbase/src/gui/image/qbmphandler.cpp
++++ b/qtbase/src/gui/image/qbmphandler.cpp
+@@ -150,16 +150,42 @@ static QDataStream &operator<<(QDataStream &s, const BMP_INFOHDR &bi)
+     return s;
+ }
+ 
+-static int calc_shift(uint mask)
++static uint calc_shift(uint mask)
+ {
+-    int result = 0;
+-    while (mask && !(mask & 1)) {
++    uint result = 0;
++    while ((mask >= 0x100) || (!(mask & 1) && mask)) {
+         result++;
+         mask >>= 1;
+     }
+     return result;
+ }
+ 
++static uint calc_scale(uint low_mask)
++{
++    uint result = 8;
++    while (low_mask && result) {
++        result--;
++        low_mask >>= 1;
++    }
++    return result;
++}
++
++static inline uint apply_scale(uint value, uint scale)
++{
++    if (!(scale & 0x07)) // return immediately if scale == 8 or 0
++        return value;
++
++    uint filled = 8 - scale;
++    uint result = value << scale;
++
++    do {
++        result |= result >> filled;
++        filled <<= 1;
++    } while (filled < 8);
++
++    return result;
++}
++
+ static bool read_dib_fileheader(QDataStream &s, BMP_FILEHDR &bf)
+ {
+     // read BMP file header
+@@ -222,14 +248,14 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+     uint green_mask = 0;
+     uint blue_mask = 0;
+     uint alpha_mask = 0;
+-    int red_shift = 0;
+-    int green_shift = 0;
+-    int blue_shift = 0;
+-    int alpha_shift = 0;
+-    int red_scale = 0;
+-    int green_scale = 0;
+-    int blue_scale = 0;
+-    int alpha_scale = 0;
++    uint red_shift = 0;
++    uint green_shift = 0;
++    uint blue_shift = 0;
++    uint alpha_shift = 0;
++    uint red_scale = 0;
++    uint green_scale = 0;
++    uint blue_scale = 0;
++    uint alpha_scale = 0;
+ 
+     if (!d->isSequential())
+         d->seek(startpos + BMP_FILEHDR_SIZE + bi.biSize); // goto start of colormap or masks
+@@ -308,19 +334,19 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+         red_shift = calc_shift(red_mask);
+         if (((red_mask >> red_shift) + 1) == 0)
+             return false;
+-        red_scale = 256 / ((red_mask >> red_shift) + 1);
++        red_scale = calc_scale(red_mask >> red_shift);
+         green_shift = calc_shift(green_mask);
+         if (((green_mask >> green_shift) + 1) == 0)
+             return false;
+-        green_scale = 256 / ((green_mask >> green_shift) + 1);
++        green_scale = calc_scale(green_mask >> green_shift);
+         blue_shift = calc_shift(blue_mask);
+         if (((blue_mask >> blue_shift) + 1) == 0)
+             return false;
+-        blue_scale = 256 / ((blue_mask >> blue_shift) + 1);
++        blue_scale = calc_scale(blue_mask >> blue_shift);
+         alpha_shift = calc_shift(alpha_mask);
+         if (((alpha_mask >> alpha_shift) + 1) == 0)
+             return false;
+-        alpha_scale = 256 / ((alpha_mask >> alpha_shift) + 1);
++        alpha_scale = calc_scale(alpha_mask >> alpha_shift);
+     } else if (comp == BMP_RGB && (nbits == 24 || nbits == 32)) {
+         blue_mask = 0x000000ff;
+         green_mask = 0x0000ff00;
+@@ -328,17 +354,15 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+         blue_shift = 0;
+         green_shift = 8;
+         red_shift = 16;
+-        blue_scale = green_scale = red_scale = 1;
++        blue_scale = green_scale = red_scale = 0;
+     } else if (comp == BMP_RGB && nbits == 16) {
+         blue_mask = 0x001f;
+         green_mask = 0x03e0;
+         red_mask = 0x7c00;
+         blue_shift = 0;
+-        green_shift = 2;
+-        red_shift = 7;
+-        red_scale = 1;
+-        green_scale = 1;
+-        blue_scale = 8;
++        green_shift = 5;
++        red_shift = 10;
++        blue_scale = green_scale = red_scale = 3;
+     }
+ 
+ #if 0
+@@ -544,10 +568,10 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+                     c |= *(uchar*)(b+2)<<16;
+                 if (nbits > 24)
+                     c |= *(uchar*)(b+3)<<24;
+-                *p++ = qRgba(((c & red_mask) >> red_shift) * red_scale,
+-                                        ((c & green_mask) >> green_shift) * green_scale,
+-                                        ((c & blue_mask) >> blue_shift) * blue_scale,
+-                                        transp ? ((c & alpha_mask) >> alpha_shift) * alpha_scale : 0xff);
++                *p++ = qRgba(apply_scale((c & red_mask) >> red_shift, red_scale),
++                             apply_scale((c & green_mask) >> green_shift, green_scale),
++                             apply_scale((c & blue_mask) >> blue_shift, blue_scale),
++                             transp ? apply_scale((c & alpha_mask) >> alpha_shift, alpha_scale) : 0xff);
+                 b += nbits/8;
+             }
+         }
+diff --git a/qtbase/src/gui/image/qimage.cpp b/qtbase/src/gui/image/qimage.cpp
+index 7152ac1607..0df772564c 100644
+--- a/qtbase/src/gui/image/qimage.cpp
++++ b/qtbase/src/gui/image/qimage.cpp
+@@ -4694,6 +4694,8 @@ QImage QImage::smoothScaled(int w, int h) const {
+ static QImage rotated90(const QImage &image)
+ {
+     QImage out(image.height(), image.width(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+@@ -4722,6 +4724,8 @@ static QImage rotated180(const QImage &image)
+         return image.mirrored(true, true);
+ 
+     QImage out(image.width(), image.height(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+@@ -4734,6 +4738,8 @@ static QImage rotated180(const QImage &image)
+ static QImage rotated270(const QImage &image)
+ {
+     QImage out(image.height(), image.width(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+diff --git a/qtbase/src/gui/kernel/qcursor.cpp b/qtbase/src/gui/kernel/qcursor.cpp
+index d6ccaff8ed..455088241c 100644
+--- a/qtbase/src/gui/kernel/qcursor.cpp
++++ b/qtbase/src/gui/kernel/qcursor.cpp
+@@ -251,7 +251,8 @@ void QCursor::setPos(QScreen *screen, int x, int y)
+ {
+     if (screen) {
+         if (QPlatformCursor *cursor = screen->handle()->cursor()) {
+-            const QPoint devicePos = QHighDpi::toNativePixels(QPoint(x, y), screen);
++            const QPoint pos(x, y);
++            const QPoint devicePos = QHighDpi::toNativePixels(pos, screen->virtualSiblingAt(pos));
+             // Need to check, since some X servers generate null mouse move
+             // events, causing looping in applications which call setPos() on
+             // every mouse move event.
+diff --git a/qtbase/src/gui/kernel/qhighdpiscaling.cpp b/qtbase/src/gui/kernel/qhighdpiscaling.cpp
+index 9bbf2773a9..3ac4a4d8b6 100644
+--- a/qtbase/src/gui/kernel/qhighdpiscaling.cpp
++++ b/qtbase/src/gui/kernel/qhighdpiscaling.cpp
+@@ -580,9 +580,8 @@ void QHighDpiScaling::setScreenFactor(QScreen *screen, qreal factor)
+     else
+         qNamedScreenScaleFactors()->insert(name, factor);
+ 
+-    // hack to force re-evaluation of screen geometry
+     if (screen->handle())
+-        screen->d_func()->setPlatformScreen(screen->handle()); // updates geometries based on scale factor
++        screen->d_func()->updateLogicalDpi();
+ }
+ 
+ QPoint QHighDpiScaling::mapPositionToNative(const QPoint &pos, const QPlatformScreen *platformScreen)
+diff --git a/qtbase/src/gui/kernel/qkeysequence.cpp b/qtbase/src/gui/kernel/qkeysequence.cpp
+index a75b8ef920..4f2d294739 100644
+--- a/qtbase/src/gui/kernel/qkeysequence.cpp
++++ b/qtbase/src/gui/kernel/qkeysequence.cpp
+@@ -701,6 +701,10 @@ static const struct {
+     { Qt::Key_TouchpadToggle,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad Toggle") },
+     { Qt::Key_TouchpadOn,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad On") },
+     { Qt::Key_TouchpadOff,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad Off") },
++    { Qt::Key_Shift,  QT_TRANSLATE_NOOP("QShortcut", "Shift") },
++    { Qt::Key_Control,  QT_TRANSLATE_NOOP("QShortcut", "Control") },
++    { Qt::Key_Alt,  QT_TRANSLATE_NOOP("QShortcut", "Alt") },
++    { Qt::Key_Meta,  QT_TRANSLATE_NOOP("QShortcut", "Meta") },
+ 
+ };
+ static Q_CONSTEXPR int numKeyNames = sizeof keyname / sizeof *keyname;
+diff --git a/qtbase/src/gui/kernel/qplatformservices.cpp b/qtbase/src/gui/kernel/qplatformservices.cpp
+index fdc6a6c4aa..ac47f98c5d 100644
+--- a/qtbase/src/gui/kernel/qplatformservices.cpp
++++ b/qtbase/src/gui/kernel/qplatformservices.cpp
+@@ -55,6 +55,19 @@ QT_BEGIN_NAMESPACE
+     \brief The QPlatformServices provides the backend for desktop-related functionality.
+ */
+ 
++/*!
++    \enum QPlatformServices::Capability
++
++    Capabilities are used to determine a specific platform service's availability.
++
++    \value ColorPickingFromScreen The platform natively supports color picking from screen.
++    This capability indicates that the platform supports "opaque" color picking, where the
++    platform implements a complete user experience for color picking and outputs a color.
++    This is in contrast to the application implementing the color picking user experience
++    (taking care of showing a cross hair, instructing the platform integration to obtain
++    the color at a given pixel, etc.). The related service function is pickColor().
++ */
++
+ QPlatformServices::QPlatformServices()
+ { }
+ 
+@@ -85,5 +98,16 @@ QByteArray QPlatformServices::desktopEnvironment() const
+     return QByteArray("UNKNOWN");
+ }
+ 
++QPlatformServiceColorPicker *QPlatformServices::colorPicker(QWindow *parent)
++{
++    Q_UNUSED(parent);
++    return nullptr;
++}
++
++bool QPlatformServices::hasCapability(Capability capability) const
++{
++    Q_UNUSED(capability)
++    return false;
++}
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/gui/kernel/qplatformservices.h b/qtbase/src/gui/kernel/qplatformservices.h
+index 5de96cfa7d..a8b2a4ce71 100644
+--- a/qtbase/src/gui/kernel/qplatformservices.h
++++ b/qtbase/src/gui/kernel/qplatformservices.h
+@@ -50,16 +50,32 @@
+ //
+ 
+ #include <QtGui/qtguiglobal.h>
++#include <QtCore/qobject.h>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+ class QUrl;
++class QWindow;
++
++class Q_GUI_EXPORT QPlatformServiceColorPicker : public QObject
++{
++    Q_OBJECT
++public:
++    using QObject::QObject;
++    virtual void pickColor() = 0;
++Q_SIGNALS:
++    void colorPicked(const QColor &color);
++};
+ 
+ class Q_GUI_EXPORT QPlatformServices
+ {
+ public:
+     Q_DISABLE_COPY_MOVE(QPlatformServices)
+ 
++    enum Capability {
++        ColorPicking,
++    };
++
+     QPlatformServices();
+     virtual ~QPlatformServices() { }
+ 
+@@ -67,6 +83,10 @@ public:
+     virtual bool openDocument(const QUrl &url);
+ 
+     virtual QByteArray desktopEnvironment() const;
++
++    virtual bool hasCapability(Capability capability) const;
++
++    virtual QPlatformServiceColorPicker *colorPicker(QWindow *parent = nullptr);
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/gui/kernel/qplatformtheme.cpp b/qtbase/src/gui/kernel/qplatformtheme.cpp
+index 71521c0339..2325873245 100644
+--- a/qtbase/src/gui/kernel/qplatformtheme.cpp
++++ b/qtbase/src/gui/kernel/qplatformtheme.cpp
+@@ -163,6 +163,8 @@ QT_BEGIN_NAMESPACE
+ 
+     \value ShowShortcutsInContextMenus (bool) Whether to display shortcut key sequences in context menus.
+ 
++    \value ButtonPressKeys (QList<Qt::Key>) A list of keys that can be used to press buttons via keyboard input.
++
+     \sa themeHint(), QStyle::pixelMetric()
+ */
+ 
+@@ -563,6 +565,8 @@ QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint)
+         }
+     case MouseQuickSelectionThreshold:
+         return QVariant(10);
++    case ButtonPressKeys:
++        return QVariant::fromValue(QList<Qt::Key>({ Qt::Key_Space, Qt::Key_Select }));
+     }
+     return QVariant();
+ }
+diff --git a/qtbase/src/gui/kernel/qplatformtheme.h b/qtbase/src/gui/kernel/qplatformtheme.h
+index 3185fc4541..7e6c9d5740 100644
+--- a/qtbase/src/gui/kernel/qplatformtheme.h
++++ b/qtbase/src/gui/kernel/qplatformtheme.h
+@@ -120,7 +120,8 @@ public:
+         TouchDoubleTapDistance,
+         ShowShortcutsInContextMenus,
+         IconFallbackSearchPaths,
+-        MouseQuickSelectionThreshold
++        MouseQuickSelectionThreshold,
++        ButtonPressKeys
+     };
+ 
+     enum DialogType {
+diff --git a/qtbase/src/gui/kernel/qscreen.cpp b/qtbase/src/gui/kernel/qscreen.cpp
+index 8e0eb35116..5d172a58dd 100644
+--- a/qtbase/src/gui/kernel/qscreen.cpp
++++ b/qtbase/src/gui/kernel/qscreen.cpp
+@@ -77,6 +77,12 @@ QScreen::QScreen(QPlatformScreen *screen)
+     d->setPlatformScreen(screen);
+ }
+ 
++void QScreenPrivate::updateLogicalDpi()
++{
++    logicalDpi = QPlatformScreen::overrideDpi(platformScreen->logicalDpi());
++    updateGeometriesWithSignals(); // updates geometries based on scale factor
++}
++
+ void QScreenPrivate::updateGeometriesWithSignals()
+ {
+     const QRect oldGeometry = geometry;
+diff --git a/qtbase/src/gui/kernel/qscreen_p.h b/qtbase/src/gui/kernel/qscreen_p.h
+index 7da542c25e..e50fc3190b 100644
+--- a/qtbase/src/gui/kernel/qscreen_p.h
++++ b/qtbase/src/gui/kernel/qscreen_p.h
+@@ -70,6 +70,7 @@ public:
+         geometry = platformScreen->deviceIndependentGeometry();
+         availableGeometry = QHighDpi::fromNative(platformScreen->availableGeometry(), QHighDpiScaling::factor(platformScreen), geometry.topLeft());
+     }
++    void updateLogicalDpi();
+ 
+     void updatePrimaryOrientation();
+     void updateGeometriesWithSignals();
+diff --git a/qtbase/src/gui/painting/qblendfunctions_p.h b/qtbase/src/gui/painting/qblendfunctions_p.h
+index 080da98ec4..6997d62b3c 100644
+--- a/qtbase/src/gui/painting/qblendfunctions_p.h
++++ b/qtbase/src/gui/painting/qblendfunctions_p.h
+@@ -246,25 +246,32 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+                                   int dudx, int dvdx, int dudy, int dvdy, int u0, int v0,
+                                   Blender blender)
+ {
+-    int fromY = qMax(qRound(topY), clip.top());
+-    int toY = qMin(qRound(bottomY), clip.top() + clip.height());
++    qint64 fromY = qMax(qRound(topY), clip.top());
++    qint64 toY = qMin(qRound(bottomY), clip.top() + clip.height());
+     if (fromY >= toY)
+         return;
+ 
+     qreal leftSlope = (bottomLeft.x - topLeft.x) / (bottomLeft.y - topLeft.y);
+     qreal rightSlope = (bottomRight.x - topRight.x) / (bottomRight.y - topRight.y);
+-    int dx_l = int(leftSlope * 0x10000);
+-    int dx_r = int(rightSlope * 0x10000);
+-    int x_l = int((topLeft.x + (qreal(0.5) + fromY - topLeft.y) * leftSlope + qreal(0.5)) * 0x10000);
+-    int x_r = int((topRight.x + (qreal(0.5) + fromY - topRight.y) * rightSlope + qreal(0.5)) * 0x10000);
+-
+-    int fromX, toX, x1, x2, u, v, i, ii;
++    qint64 dx_l = qint64(leftSlope * 0x10000);
++    qint64 dx_r = qint64(rightSlope * 0x10000);
++    qint64 x_l = qint64((topLeft.x + (qreal(0.5) + fromY - topLeft.y) * leftSlope + qreal(0.5)) * 0x10000);
++    qint64 x_r = qint64((topRight.x + (qreal(0.5) + fromY - topRight.y) * rightSlope + qreal(0.5)) * 0x10000);
++
++    qint64 sourceRectTop = qint64(sourceRect.top());
++    qint64 sourceRectLeft = qint64(sourceRect.left());
++    qint64 sourceRectWidth = qint64(sourceRect.width());
++    qint64 sourceRectHeight = qint64(sourceRect.height());
++    qint64 clipLeft = qint64(clip.left());
++    qint64 clipWidth = qint64(clip.width());
++
++    qint64 fromX, toX, x1, x2, u, v, i, ii;
+     DestT *line;
+-    for (int y = fromY; y < toY; ++y) {
++    for (qint64 y = fromY; y < toY; ++y) {
+         line = reinterpret_cast<DestT *>(reinterpret_cast<uchar *>(destPixels) + y * dbpl);
+ 
+-        fromX = qMax(x_l >> 16, clip.left());
+-        toX = qMin(x_r >> 16, clip.left() + clip.width());
++        fromX = qMax(x_l >> 16, clipLeft);
++        toX = qMin(x_r >> 16, clipLeft + clipWidth);
+         if (fromX < toX) {
+             // Because of rounding, we can get source coordinates outside the source image.
+             // Clamp these coordinates to the source rect to avoid segmentation fault and
+@@ -275,10 +282,10 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             u = x1 * dudx + y * dudy + u0;
+             v = x1 * dvdx + y * dvdy + v0;
+             for (; x1 < toX; ++x1) {
+-                int uu = u >> 16;
+-                int vv = v >> 16;
+-                if (uu >= sourceRect.left() && uu < sourceRect.left() + sourceRect.width()
+-                    && vv >= sourceRect.top() && vv < sourceRect.top() + sourceRect.height()) {
++                qint64 uu = u >> 16;
++                qint64 vv = v >> 16;
++                if (uu >= sourceRectLeft && uu < sourceRectLeft + sourceRectWidth
++                    && vv >= sourceRectTop && vv < sourceRectTop + sourceRectHeight) {
+                     break;
+                 }
+                 u += dudx;
+@@ -290,10 +297,10 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             u = (x2 - 1) * dudx + y * dudy + u0;
+             v = (x2 - 1) * dvdx + y * dvdy + v0;
+             for (; x2 > x1; --x2) {
+-                int uu = u >> 16;
+-                int vv = v >> 16;
+-                if (uu >= sourceRect.left() && uu < sourceRect.left() + sourceRect.width()
+-                    && vv >= sourceRect.top() && vv < sourceRect.top() + sourceRect.height()) {
++                qint64 uu = u >> 16;
++                qint64 vv = v >> 16;
++                if (uu >= sourceRectLeft && uu < sourceRectLeft + sourceRectWidth
++                    && vv >= sourceRectTop && vv < sourceRectTop + sourceRectHeight) {
+                     break;
+                 }
+                 u -= dudx;
+@@ -308,8 +315,8 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             // Beginning of the scan line, with per-pixel checks.
+             i = x1 - fromX;
+             while (i) {
+-                int uu = qBound(sourceRect.left(), u >> 16, sourceRect.left() + sourceRect.width() - 1);
+-                int vv = qBound(sourceRect.top(), v >> 16, sourceRect.top() + sourceRect.height() - 1);
++                qint64 uu = qBound(sourceRectLeft, u >> 16, sourceRectLeft + sourceRectWidth - 1);
++                qint64 vv = qBound(sourceRectTop, v >> 16, sourceRectTop + sourceRectHeight - 1);
+                 blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + vv * sbpl)[uu]);
+                 u += dudx;
+                 v += dvdx;
+@@ -348,8 +355,8 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             // End of the scan line, with per-pixel checks.
+             i = toX - x2;
+             while (i) {
+-                int uu = qBound(sourceRect.left(), u >> 16, sourceRect.left() + sourceRect.width() - 1);
+-                int vv = qBound(sourceRect.top(), v >> 16, sourceRect.top() + sourceRect.height() - 1);
++                qint64 uu = qBound(sourceRectLeft, u >> 16, sourceRectLeft + sourceRectWidth - 1);
++                qint64 vv = qBound(sourceRectTop, v >> 16, sourceRectTop + sourceRectHeight - 1);
+                 blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + vv * sbpl)[uu]);
+                 u += dudx;
+                 v += dvdx;
+diff --git a/qtbase/src/gui/painting/qcolortrclut_p.h b/qtbase/src/gui/painting/qcolortrclut_p.h
+index 76a6a60803..24fd522e6c 100644
+--- a/qtbase/src/gui/painting/qcolortrclut_p.h
++++ b/qtbase/src/gui/painting/qcolortrclut_p.h
+@@ -118,6 +118,7 @@ public:
+         return QRgba64::fromRgba64(r, g, b, qAlpha(rgb32) * 257);
+ #endif
+     }
++    QRgba64 toLinear64(QRgba64) const = delete;
+ 
+     QRgb toLinear(QRgb rgb32) const
+     {
+diff --git a/qtbase/src/gui/painting/qdrawhelper.cpp b/qtbase/src/gui/painting/qdrawhelper.cpp
+index a61793508a..5ba2d277b7 100644
+--- a/qtbase/src/gui/painting/qdrawhelper.cpp
++++ b/qtbase/src/gui/painting/qdrawhelper.cpp
+@@ -6091,7 +6091,7 @@ static inline void alphargbblend_argb32(quint32 *dst, uint coverage, const QRgba
+ static inline void rgbBlendPixel(QRgba64 &dst, int coverage, QRgba64 slinear, const QColorTrcLut *colorProfile)
+ {
+     // Do a gammacorrected RGB alphablend...
+-    const QRgba64 dlinear = colorProfile ? colorProfile->toLinear64(dst) : dst;
++    const QRgba64 dlinear = colorProfile ? colorProfile->toLinear(dst) : dst;
+ 
+     QRgba64 blend = rgbBlend(dlinear, slinear, coverage);
+ 
+diff --git a/qtbase/src/gui/painting/qpaintengine_raster.cpp b/qtbase/src/gui/painting/qpaintengine_raster.cpp
+index 283923de52..f08eb9cbee 100644
+--- a/qtbase/src/gui/painting/qpaintengine_raster.cpp
++++ b/qtbase/src/gui/painting/qpaintengine_raster.cpp
+@@ -560,31 +560,6 @@ void QRasterPaintEngine::updateMatrix(const QTransform &matrix)
+     QRasterPaintEngineState *s = state();
+     // FALCON: get rid of this line, see drawImage call below.
+     s->matrix = matrix;
+-    QTransform::TransformationType txop = s->matrix.type();
+-
+-    switch (txop) {
+-
+-    case QTransform::TxNone:
+-        s->flags.int_xform = true;
+-        break;
+-
+-    case QTransform::TxTranslate:
+-        s->flags.int_xform = qreal(int(s->matrix.dx())) == s->matrix.dx()
+-                            && qreal(int(s->matrix.dy())) == s->matrix.dy();
+-        break;
+-
+-    case QTransform::TxScale:
+-        s->flags.int_xform = qreal(int(s->matrix.dx())) == s->matrix.dx()
+-                            && qreal(int(s->matrix.dy())) == s->matrix.dy()
+-                            && qreal(int(s->matrix.m11())) == s->matrix.m11()
+-                            && qreal(int(s->matrix.m22())) == s->matrix.m22();
+-        break;
+-
+-    default: // shear / perspective...
+-        s->flags.int_xform = false;
+-        break;
+-    }
+-
+     s->flags.tx_noshear = qt_scaleForTransform(s->matrix, &s->txscale);
+ 
+     ensureOutlineMapper();
+@@ -617,7 +592,6 @@ QRasterPaintEngineState::QRasterPaintEngineState()
+     flags.bilinear = false;
+     flags.legacy_rounding = false;
+     flags.fast_text = true;
+-    flags.int_xform = true;
+     flags.tx_noshear = true;
+     flags.fast_images = true;
+ 
+@@ -1793,7 +1767,7 @@ void QRasterPaintEngine::fill(const QVectorPath &path, const QBrush &brush)
+     QRectF cpRect = path.controlPointRect();
+     const QRectF pathDeviceRect = s->matrix.mapRect(cpRect);
+     // Skip paths that by conservative estimates are completely outside the paint device.
+-    if (!pathDeviceRect.intersects(QRectF(d->deviceRect)))
++    if (!pathDeviceRect.intersects(QRectF(d->deviceRect)) || !pathDeviceRect.isValid())
+         return;
+ 
+     ProcessSpans blend = d->getBrushFunc(pathDeviceRect, &s->brushData);
+diff --git a/qtbase/src/gui/painting/qpaintengine_raster_p.h b/qtbase/src/gui/painting/qpaintengine_raster_p.h
+index 089aadc3f7..bf7363d5aa 100644
+--- a/qtbase/src/gui/painting/qpaintengine_raster_p.h
++++ b/qtbase/src/gui/painting/qpaintengine_raster_p.h
+@@ -111,7 +111,6 @@ public:
+         uint bilinear : 1;
+         uint legacy_rounding : 1;
+         uint fast_text : 1;
+-        uint int_xform : 1;
+         uint tx_noshear : 1;
+         uint fast_images : 1;
+     };
+diff --git a/qtbase/src/gui/painting/qpainterpath.cpp b/qtbase/src/gui/painting/qpainterpath.cpp
+index f9544a3241..d80fafeaf1 100644
+--- a/qtbase/src/gui/painting/qpainterpath.cpp
++++ b/qtbase/src/gui/painting/qpainterpath.cpp
+@@ -1253,7 +1253,7 @@ void QPainterPath::addText(const QPointF &point, const QFont &f, const QString &
+ 
+         if (si.analysis.flags < QScriptAnalysis::TabOrObject) {
+             QGlyphLayout glyphs = eng->shapedGlyphs(&si);
+-            QFontEngine *fe = f.d->engineForScript(si.analysis.script);
++            QFontEngine *fe = eng->fontEngine(si);
+             Q_ASSERT(fe);
+             fe->addOutlineToPath(x, y, glyphs, this,
+                                  si.analysis.bidiLevel % 2
+diff --git a/qtbase/src/gui/painting/qpathclipper_p.h b/qtbase/src/gui/painting/qpathclipper_p.h
+index 9444a87b71..18f64c5e8c 100644
+--- a/qtbase/src/gui/painting/qpathclipper_p.h
++++ b/qtbase/src/gui/painting/qpathclipper_p.h
+@@ -156,7 +156,7 @@ public:
+     int vertex(Direction direction) const;
+ 
+ private:
+-    int m_next[2][2];
++    int m_next[2][2] = { { -1, -1 }, { -1, -1 } };
+ };
+ 
+ class QPathSegments
+@@ -296,10 +296,6 @@ inline QPathEdge::QPathEdge(int a, int b)
+     , angle(0)
+     , invAngle(0)
+ {
+-    m_next[0][0] = -1;
+-    m_next[1][0] = -1;
+-    m_next[0][0] = -1;
+-    m_next[1][0] = -1;
+ }
+ 
+ inline int QPathEdge::next(Traversal traversal, Direction direction) const
+diff --git a/qtbase/src/gui/painting/qpdf.cpp b/qtbase/src/gui/painting/qpdf.cpp
+index 3066744f1b..2c8d3c3b53 100644
+--- a/qtbase/src/gui/painting/qpdf.cpp
++++ b/qtbase/src/gui/painting/qpdf.cpp
+@@ -2760,6 +2760,8 @@ int QPdfEnginePrivate::addBrushPattern(const QTransform &m, bool *specifyColor,
+         return gradientBrush(brush, matrix, gStateObject);
+     }
+ 
++    matrix = brush.transform() * matrix;
++
+     if ((!brush.isOpaque() && brush.style() < Qt::LinearGradientPattern) || opacity != 1.0)
+         *gStateObject = addConstantAlphaObject(qRound(brush.color().alpha() * opacity),
+                                                qRound(pen.color().alpha() * opacity));
+diff --git a/qtbase/src/gui/painting/qstroker.cpp b/qtbase/src/gui/painting/qstroker.cpp
+index cb5d395e80..3b6357a893 100644
+--- a/qtbase/src/gui/painting/qstroker.cpp
++++ b/qtbase/src/gui/painting/qstroker.cpp
+@@ -1182,6 +1182,7 @@ void QDashStroker::processCurrentSubpath()
+         // Check if the entire line should be clipped away or simplified
+         bool clipIt = clipping && !lineIntersectsRect(prev, e, clip_tl, clip_br);
+         bool skipDashing = elen * invSumLength > repetitionLimit();
++        int maxDashes = dashCount;
+         if (skipDashing || clipIt) {
+             // Cut away full dash sequences.
+             elen -= std::floor(elen * invSumLength) * sumLength;
+@@ -1196,7 +1197,7 @@ void QDashStroker::processCurrentSubpath()
+                     pos = estop; // move pos to next path element
+                     done = true;
+                 } else { // Dash is on this line
+-                    pos = dpos + estart;
++                    pos = --maxDashes > 0 ? dpos + estart : estop;
+                     done = pos >= estop;
+                     if (++idash >= dashCount)
+                         idash = 0;
+diff --git a/qtbase/src/gui/painting/qt_attribution.json b/qtbase/src/gui/painting/qt_attribution.json
+index 7b16e8c211..0e87d30aa2 100644
+--- a/qtbase/src/gui/painting/qt_attribution.json
++++ b/qtbase/src/gui/painting/qt_attribution.json
+@@ -10,7 +10,7 @@
+         "Homepage": "http://www.freetype.org",
+         "License": "Freetype Project License or GNU General Public License v2.0 only",
+         "LicenseId": "FTL or GPL-2.0",
+-        "LicenseFile": "../../3rdparty/freetype/docs/LICENSE.TXT",
++        "LicenseFile": "../../3rdparty/freetype/LICENSE.TXT",
+         "Copyright": "Copyright 2000-2016 by David Turner, Robert Wilhelm, and Werner Lemberg."
+     },
+     {
+diff --git a/qtbase/src/gui/rhi/qshader_p_p.h b/qtbase/src/gui/rhi/qshader_p_p.h
+index ec9d25971f..4a5a7a6d51 100644
+--- a/qtbase/src/gui/rhi/qshader_p_p.h
++++ b/qtbase/src/gui/rhi/qshader_p_p.h
+@@ -68,13 +68,13 @@ struct Q_GUI_EXPORT QShaderPrivate
+     {
+     }
+ 
+-    QShaderPrivate(const QShaderPrivate *other)
++    QShaderPrivate(const QShaderPrivate &other)
+         : ref(1),
+-          qsbVersion(other->qsbVersion),
+-          stage(other->stage),
+-          desc(other->desc),
+-          shaders(other->shaders),
+-          bindings(other->bindings)
++          qsbVersion(other.qsbVersion),
++          stage(other.stage),
++          desc(other.desc),
++          shaders(other.shaders),
++          bindings(other.bindings)
+     {
+     }
+ 
+diff --git a/qtbase/src/gui/rhi/qshaderdescription_p_p.h b/qtbase/src/gui/rhi/qshaderdescription_p_p.h
+index ec2b0b6b4c..3da33a8a2b 100644
+--- a/qtbase/src/gui/rhi/qshaderdescription_p_p.h
++++ b/qtbase/src/gui/rhi/qshaderdescription_p_p.h
+@@ -63,16 +63,16 @@ struct Q_GUI_EXPORT QShaderDescriptionPrivate
+         localSize[0] = localSize[1] = localSize[2] = 0;
+     }
+ 
+-    QShaderDescriptionPrivate(const QShaderDescriptionPrivate *other)
++    QShaderDescriptionPrivate(const QShaderDescriptionPrivate &other)
+         : ref(1),
+-          inVars(other->inVars),
+-          outVars(other->outVars),
+-          uniformBlocks(other->uniformBlocks),
+-          pushConstantBlocks(other->pushConstantBlocks),
+-          storageBlocks(other->storageBlocks),
+-          combinedImageSamplers(other->combinedImageSamplers),
+-          storageImages(other->storageImages),
+-          localSize(other->localSize)
++          inVars(other.inVars),
++          outVars(other.outVars),
++          uniformBlocks(other.uniformBlocks),
++          pushConstantBlocks(other.pushConstantBlocks),
++          storageBlocks(other.storageBlocks),
++          combinedImageSamplers(other.combinedImageSamplers),
++          storageImages(other.storageImages),
++          localSize(other.localSize)
+     {
+     }
+ 
+diff --git a/qtbase/src/gui/text/qfontdatabase.cpp b/qtbase/src/gui/text/qfontdatabase.cpp
+index a657a8c516..4fc0100958 100644
+--- a/qtbase/src/gui/text/qfontdatabase.cpp
++++ b/qtbase/src/gui/text/qfontdatabase.cpp
+@@ -983,7 +983,7 @@ QFontEngine *loadSingleEngine(int script,
+         if (style->key.stretch != 0 && request.stretch != 0
+             && (request.styleName.isEmpty() || request.styleName != style->styleName)) {
+             def.stretch = (request.stretch * 100 + style->key.stretch / 2) / style->key.stretch;
+-        } else {
++        } else if (request.stretch == QFont::AnyStretch) {
+             def.stretch = 100;
+         }
+ 
+diff --git a/qtbase/src/gui/text/qtextdocumentlayout.cpp b/qtbase/src/gui/text/qtextdocumentlayout.cpp
+index f3e6ea2100..72267e9380 100644
+--- a/qtbase/src/gui/text/qtextdocumentlayout.cpp
++++ b/qtbase/src/gui/text/qtextdocumentlayout.cpp
+@@ -2123,7 +2123,7 @@ void QTextDocumentLayoutPrivate::drawListItem(const QPointF &offset, QPainter *p
+ {
+     Q_Q(const QTextDocumentLayout);
+     const QTextBlockFormat blockFormat = bl.blockFormat();
+-    const QTextCharFormat charFormat = QTextCursor(bl).charFormat();
++    const QTextCharFormat charFormat = bl.charFormat();
+     QFont font(charFormat.font());
+     if (q->paintDevice())
+         font = QFont(font, q->paintDevice());
+diff --git a/qtbase/src/gui/text/qtextengine.cpp b/qtbase/src/gui/text/qtextengine.cpp
+index ce4abac472..a6c66e5d2d 100644
+--- a/qtbase/src/gui/text/qtextengine.cpp
++++ b/qtbase/src/gui/text/qtextengine.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2021 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtGui module of the Qt Toolkit.
+@@ -1565,6 +1565,12 @@ void QTextEngine::shapeText(int item) const
+         // Overwrite with 0 token to indicate failure
+         QGlyphLayout g = availableGlyphs(&si);
+         g.glyphs[0] = 0;
++        g.attributes[0].clusterStart = true;
++
++        ushort *log_clusters = logClusters(&si);
++        for (int i = 0; i < itemLength; ++i)
++            log_clusters[i] = 0;
++
+         return;
+     }
+ 
+diff --git a/qtbase/src/gui/util/qdesktopservices.cpp b/qtbase/src/gui/util/qdesktopservices.cpp
+index fbb63a9408..4d5fafaaa7 100644
+--- a/qtbase/src/gui/util/qdesktopservices.cpp
++++ b/qtbase/src/gui/util/qdesktopservices.cpp
+@@ -54,6 +54,8 @@
+ #include <qpa/qplatformintegration.h>
+ #include <qdir.h>
+ 
++#include <QtCore/private/qlocking_p.h>
++
+ QT_BEGIN_NAMESPACE
+ 
+ class QOpenUrlHandlerRegistry : public QObject
+@@ -81,6 +83,7 @@ Q_GLOBAL_STATIC(QOpenUrlHandlerRegistry, handlerRegistry)
+ 
+ void QOpenUrlHandlerRegistry::handlerDestroyed(QObject *handler)
+ {
++    const auto lock = qt_scoped_lock(mutex);
+     HandlerHash::Iterator it = handlers.begin();
+     while (it != handlers.end()) {
+         if (it->receiver == handler) {
+@@ -294,7 +297,8 @@ void QDesktopServices::setUrlHandler(const QString &scheme, QObject *receiver, c
+     h.name = method;
+     registry->handlers.insert(scheme.toLower(), h);
+     QObject::connect(receiver, SIGNAL(destroyed(QObject*)),
+-                     registry, SLOT(handlerDestroyed(QObject*)));
++                     registry, SLOT(handlerDestroyed(QObject*)),
++                     Qt::DirectConnection);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/gui/util/qpkmhandler.cpp b/qtbase/src/gui/util/qpkmhandler.cpp
+index e0c3b75efe..3414f9d8ba 100644
+--- a/qtbase/src/gui/util/qpkmhandler.cpp
++++ b/qtbase/src/gui/util/qpkmhandler.cpp
+@@ -57,7 +57,7 @@ struct PkmType
+     quint32 bytesPerBlock;
+ };
+ 
+-static PkmType typeMap[5] = {
++static constexpr PkmType typeMap[5] = {
+     { 0x8D64,  8 },   // GL_ETC1_RGB8_OES
+     { 0x9274,  8 },   // GL_COMPRESSED_RGB8_ETC2
+     { 0, 0 },         // unused (obsolete)
+diff --git a/qtbase/src/network/access/qnetworkreplyfileimpl.cpp b/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
+index b6be93147a..6e69b4c4d3 100644
+--- a/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
++++ b/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
+@@ -89,9 +89,10 @@ QNetworkReplyFileImpl::QNetworkReplyFileImpl(QNetworkAccessManager *manager, con
+         // we handle only local files
+         QString msg = QCoreApplication::translate("QNetworkAccessFileBackend", "Request for opening non-local file %1").arg(url.toString());
+         setError(QNetworkReply::ProtocolInvalidOperationError, msg);
++        setFinished(true); // We're finished, will emit finished() after ctor is done.
+         QMetaObject::invokeMethod(this, "errorOccurred", Qt::QueuedConnection,
+             Q_ARG(QNetworkReply::NetworkError, QNetworkReply::ProtocolInvalidOperationError));
+-        fileOpenFinished(false);
++        QMetaObject::invokeMethod(this, [this](){ fileOpenFinished(false); }, Qt::QueuedConnection);
+         return;
+     }
+ #endif
+diff --git a/qtbase/src/network/access/qnetworkreplyimpl.cpp b/qtbase/src/network/access/qnetworkreplyimpl.cpp
+index bcdf6ee2f1..3b6deb82bd 100644
+--- a/qtbase/src/network/access/qnetworkreplyimpl.cpp
++++ b/qtbase/src/network/access/qnetworkreplyimpl.cpp
+@@ -680,7 +680,7 @@ void QNetworkReplyImplPrivate::appendDownstreamData(QIODevice *data)
+     // read until EOF from data
+     if (Q_UNLIKELY(copyDevice)) {
+         qCritical("QNetworkReplyImpl: copy from QIODevice already in progress -- "
+-                  "backend probly needs to be fixed");
++                  "backend probably needs to be fixed");
+         return;
+     }
+ 
+diff --git a/qtbase/src/network/kernel/qauthenticator.cpp b/qtbase/src/network/kernel/qauthenticator.cpp
+index d9fe7bc47b..ccd04b294a 100644
+--- a/qtbase/src/network/kernel/qauthenticator.cpp
++++ b/qtbase/src/network/kernel/qauthenticator.cpp
+@@ -50,6 +50,7 @@
+ #include <qstring.h>
+ #include <qdatetime.h>
+ #include <qrandom.h>
++#include "private/qsystemlibrary_p.h"
+ 
+ #ifdef Q_OS_WIN
+ #include <qmutex.h>
+@@ -1563,7 +1564,7 @@ static bool q_SSPI_library_load()
+ 
+     // Initialize security interface
+     if (pSecurityFunctionTable == nullptr) {
+-        securityDLLHandle = LoadLibrary(L"secur32.dll");
++        securityDLLHandle = QSystemLibrary::load(L"secur32");
+         if (securityDLLHandle != nullptr) {
+             INIT_SECURITY_INTERFACE pInitSecurityInterface =
+                 reinterpret_cast<INIT_SECURITY_INTERFACE>(
+diff --git a/qtbase/src/network/kernel/qhostinfo_unix.cpp b/qtbase/src/network/kernel/qhostinfo_unix.cpp
+index 9b0a2ee669..73679c9ef1 100644
+--- a/qtbase/src/network/kernel/qhostinfo_unix.cpp
++++ b/qtbase/src/network/kernel/qhostinfo_unix.cpp
+@@ -122,7 +122,6 @@ static QFunctionPointer resolveSymbol(QLibrary &lib, const char *sym)
+ 
+ LibResolv::LibResolv()
+ {
+-    QLibrary lib;
+ #ifdef LIBRESOLV_SO
+     lib.setFileName(QStringLiteral(LIBRESOLV_SO));
+     if (!lib.load())
+diff --git a/qtbase/src/network/socket/qsocks5socketengine.cpp b/qtbase/src/network/socket/qsocks5socketengine.cpp
+index 3a046fd116..97fadca0b3 100644
+--- a/qtbase/src/network/socket/qsocks5socketengine.cpp
++++ b/qtbase/src/network/socket/qsocks5socketengine.cpp
+@@ -1296,7 +1296,7 @@ void QSocks5SocketEnginePrivate::_q_udpSocketReadNotification()
+         int pos = 0;
+         const char *buf = inBuf.constData();
+         if (inBuf.size() < 4) {
+-            QSOCKS5_D_DEBUG << "bugus udp data, discarding";
++            QSOCKS5_D_DEBUG << "bogus udp data, discarding";
+             return;
+         }
+         QSocks5RevivedDatagram datagram;
+diff --git a/qtbase/src/network/ssl/qsslcontext_openssl.cpp b/qtbase/src/network/ssl/qsslcontext_openssl.cpp
+index c9f202f573..c992da9d8e 100644
+--- a/qtbase/src/network/ssl/qsslcontext_openssl.cpp
++++ b/qtbase/src/network/ssl/qsslcontext_openssl.cpp
+@@ -409,7 +409,7 @@ init_context:
+         break;
+     case QSsl::DtlsV1_0OrLater:
+         minVersion = DTLS1_VERSION;
+-        maxVersion = DTLS_MAX_VERSION;
++        maxVersion = 0;
+         break;
+     case QSsl::DtlsV1_2:
+         minVersion = DTLS1_2_VERSION;
+@@ -417,7 +417,7 @@ init_context:
+         break;
+     case QSsl::DtlsV1_2OrLater:
+         minVersion = DTLS1_2_VERSION;
+-        maxVersion = DTLS_MAX_VERSION;
++        maxVersion = 0;
+         break;
+     case QSsl::TlsV1_3OrLater:
+ #ifdef TLS1_3_VERSION
+@@ -455,7 +455,7 @@ init_context:
+     }
+ 
+     // Enable bug workarounds.
+-    long options = QSslSocketBackendPrivate::setupOpenSslOptions(configuration.protocol(), configuration.d->sslOptions);
++    qssloptions options = QSslSocketBackendPrivate::setupOpenSslOptions(configuration.protocol(), configuration.d->sslOptions);
+     q_SSL_CTX_set_options(sslContext->ctx, options);
+ 
+     // Tell OpenSSL to release memory early
+diff --git a/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp b/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
+index aaf8741130..b58935372c 100644
+--- a/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
++++ b/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
+@@ -59,57 +59,6 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-#ifdef OPENSSL_NO_DEPRECATED_3_0
+-
+-static int q_DH_check(DH *dh, int *status)
+-{
+-    // DH_check was first deprecated in OpenSSL 3.0.0, as low-level
+-    // API; the EVP_PKEY family of functions was advised as an alternative.
+-    // As of now EVP_PKEY_params_check ends up calling ... DH_check,
+-    // which is good enough.
+-
+-    Q_ASSERT(dh);
+-    Q_ASSERT(status);
+-
+-    EVP_PKEY *key = q_EVP_PKEY_new();
+-    if (!key) {
+-        qCWarning(lcSsl, "EVP_PKEY_new failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-    const auto keyDeleter = qScopeGuard([key](){
+-        q_EVP_PKEY_free(key);
+-    });
+-    if (!q_EVP_PKEY_set1_DH(key, dh)) {
+-        qCWarning(lcSsl, "EVP_PKEY_set1_DH failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-
+-    EVP_PKEY_CTX *keyCtx = q_EVP_PKEY_CTX_new(key, nullptr);
+-    if (!keyCtx) {
+-        qCWarning(lcSsl, "EVP_PKEY_CTX_new failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-    const auto ctxDeleter = qScopeGuard([keyCtx]{
+-        q_EVP_PKEY_CTX_free(keyCtx);
+-    });
+-
+-    const int result = q_EVP_PKEY_param_check(keyCtx);
+-    QSslSocketBackendPrivate::logAndClearErrorQueue();
+-    // Note: unlike DH_check, we cannot obtain the 'status',
+-    // if the 'result' is 0 (actually the result is 1 only
+-    // if this 'status' was 0). We could probably check the
+-    // errors from the error queue, but it's not needed anyway
+-    // - see the 'isSafeDH' below, how it returns immediately
+-    // on 0.
+-    Q_UNUSED(status)
+-
+-    return result;
+-}
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+-
+ static bool isSafeDH(DH *dh)
+ {
+     int status = 0;
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl.cpp b/qtbase/src/network/ssl/qsslsocket_openssl.cpp
+index 37fad2a68f..8f6858c867 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl.cpp
++++ b/qtbase/src/network/ssl/qsslsocket_openssl.cpp
+@@ -550,9 +550,9 @@ static void q_loadCiphersForConnection(SSL *connection, QList<QSslCipher> &ciphe
+ // Defined in qsslsocket.cpp
+ void q_setDefaultDtlsCiphers(const QList<QSslCipher> &ciphers);
+ 
+-long QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions)
++qssloptions QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions)
+ {
+-    long options;
++    qssloptions options;
+     if (protocol == QSsl::TlsV1SslV3)
+         options = SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3;
+     else if (protocol == QSsl::SecureProtocols)
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_p.h b/qtbase/src/network/ssl/qsslsocket_openssl_p.h
+index 4103de23e8..5547589256 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_p.h
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_p.h
+@@ -107,6 +107,12 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++typedef uint64_t qssloptions;
++#else
++typedef unsigned long qssloptions;
++#endif
++
+ struct QSslErrorEntry {
+     int code;
+     int depth;
+@@ -171,7 +177,7 @@ public:
+     QVector<QSslError> ocspErrors;
+     QByteArray ocspResponseDer;
+ 
+-    Q_AUTOTEST_EXPORT static long setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions);
++    Q_AUTOTEST_EXPORT static qssloptions setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions);
+     static QSslCipher QSslCipher_from_SSL_CIPHER(const SSL_CIPHER *cipher);
+     static QList<QSslCertificate> STACKOFX509_to_QSslCertificates(STACK_OF(X509) *x509);
+     static QList<QSslError> verify(const QList<QSslCertificate> &certificateChain, const QString &hostName);
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp b/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
+index e53fb279f0..459ccd0b19 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
+@@ -148,7 +148,6 @@ DEFINEFUNC(int, EVP_PKEY_up_ref, EVP_PKEY *a, a, return 0, return)
+ DEFINEFUNC2(EVP_PKEY_CTX *, EVP_PKEY_CTX_new, EVP_PKEY *pkey, pkey, ENGINE *e, e, return nullptr, return)
+ DEFINEFUNC(int, EVP_PKEY_param_check, EVP_PKEY_CTX *ctx, ctx, return 0, return)
+ DEFINEFUNC(void, EVP_PKEY_CTX_free, EVP_PKEY_CTX *ctx, ctx, return, return)
+-DEFINEFUNC(int, EVP_PKEY_base_id, EVP_PKEY *a, a, return NID_undef, return)
+ DEFINEFUNC(int, RSA_bits, RSA *a, a, return 0, return)
+ DEFINEFUNC(int, DSA_bits, DSA *a, a, return 0, return)
+ DEFINEFUNC(int, OPENSSL_sk_num, OPENSSL_STACK *a, a, return -1, return)
+@@ -158,7 +157,7 @@ DEFINEFUNC2(void, OPENSSL_sk_push, OPENSSL_STACK *a, a, void *b, b, return, DUMM
+ DEFINEFUNC(void, OPENSSL_sk_free, OPENSSL_STACK *a, a, return, DUMMYARG)
+ DEFINEFUNC2(void *, OPENSSL_sk_value, OPENSSL_STACK *a, a, int b, b, return nullptr, return)
+ DEFINEFUNC(int, SSL_session_reused, SSL *a, a, return 0, return)
+-DEFINEFUNC2(unsigned long, SSL_CTX_set_options, SSL_CTX *ctx, ctx, unsigned long op, op, return 0, return)
++DEFINEFUNC2(qssloptions, SSL_CTX_set_options, SSL_CTX *ctx, ctx, qssloptions op, op, return 0, return)
+ DEFINEFUNC(int, SSL_CTX_get_security_level, const SSL_CTX *ctx, ctx, return -1, return)
+ DEFINEFUNC2(void, SSL_CTX_set_security_level, SSL_CTX *ctx, ctx, int level, level, return, return)
+ #ifdef TLS1_3_VERSION
+@@ -371,7 +370,15 @@ DEFINEFUNC(const SSL_CIPHER *, SSL_get_current_cipher, SSL *a, a, return nullptr
+ DEFINEFUNC(int, SSL_version, const SSL *a, a, return 0, return)
+ DEFINEFUNC2(int, SSL_get_error, SSL *a, a, int b, b, return -1, return)
+ DEFINEFUNC(STACK_OF(X509) *, SSL_get_peer_cert_chain, SSL *a, a, return nullptr, return)
++
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++DEFINEFUNC(X509 *, SSL_get1_peer_certificate, SSL *a, a, return nullptr, return)
++DEFINEFUNC(int, EVP_PKEY_get_base_id, const EVP_PKEY *pkey, pkey, return -1, return)
++#else
+ DEFINEFUNC(X509 *, SSL_get_peer_certificate, SSL *a, a, return nullptr, return)
++DEFINEFUNC(int, EVP_PKEY_base_id, EVP_PKEY *a, a, return NID_undef, return)
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+ DEFINEFUNC(long, SSL_get_verify_result, const SSL *a, a, return -1, return)
+ DEFINEFUNC(SSL *, SSL_new, SSL_CTX *a, a, return nullptr, return)
+ DEFINEFUNC(SSL_CTX *, SSL_get_SSL_CTX, SSL *a, a, return nullptr, return)
+@@ -492,9 +499,7 @@ DEFINEFUNC(DH *, DH_new, DUMMYARG, DUMMYARG, return nullptr, return)
+ DEFINEFUNC(void, DH_free, DH *dh, dh, return, DUMMYARG)
+ DEFINEFUNC3(DH *, d2i_DHparams, DH**a, a, const unsigned char **pp, pp, long length, length, return nullptr, return)
+ DEFINEFUNC2(int, i2d_DHparams, DH *a, a, unsigned char **p, p, return -1, return)
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+ DEFINEFUNC2(int, DH_check, DH *dh, dh, int *codes, codes, return 0, return)
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+ DEFINEFUNC3(BIGNUM *, BN_bin2bn, const unsigned char *s, s, int len, len, BIGNUM *ret, ret, return nullptr, return)
+ 
+ #ifndef OPENSSL_NO_EC
+@@ -868,7 +873,6 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(EVP_PKEY_CTX_new)
+     RESOLVEFUNC(EVP_PKEY_param_check)
+     RESOLVEFUNC(EVP_PKEY_CTX_free)
+-    RESOLVEFUNC(EVP_PKEY_base_id)
+     RESOLVEFUNC(RSA_bits)
+     RESOLVEFUNC(OPENSSL_sk_new_null)
+     RESOLVEFUNC(OPENSSL_sk_push)
+@@ -1107,7 +1111,15 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(SSL_version)
+     RESOLVEFUNC(SSL_get_error)
+     RESOLVEFUNC(SSL_get_peer_cert_chain)
++
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++    RESOLVEFUNC(SSL_get1_peer_certificate)
++    RESOLVEFUNC(EVP_PKEY_get_base_id)
++#else
+     RESOLVEFUNC(SSL_get_peer_certificate)
++    RESOLVEFUNC(EVP_PKEY_base_id)
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+     RESOLVEFUNC(SSL_get_verify_result)
+     RESOLVEFUNC(SSL_new)
+     RESOLVEFUNC(SSL_get_SSL_CTX)
+@@ -1206,9 +1218,7 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(DH_free)
+     RESOLVEFUNC(d2i_DHparams)
+     RESOLVEFUNC(i2d_DHparams)
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+     RESOLVEFUNC(DH_check)
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+     RESOLVEFUNC(BN_bin2bn)
+ 
+ #ifndef OPENSSL_NO_EC
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h b/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
+index 95e8897a3b..27aeffa18a 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
+@@ -237,7 +237,6 @@ Q_AUTOTEST_EXPORT int q_EVP_PKEY_up_ref(EVP_PKEY *a);
+ EVP_PKEY_CTX *q_EVP_PKEY_CTX_new(EVP_PKEY *pkey, ENGINE *e);
+ void q_EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx);
+ int q_EVP_PKEY_param_check(EVP_PKEY_CTX *ctx);
+-int q_EVP_PKEY_base_id(EVP_PKEY *a);
+ int q_RSA_bits(RSA *a);
+ Q_AUTOTEST_EXPORT int q_OPENSSL_sk_num(OPENSSL_STACK *a);
+ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_pop_free(OPENSSL_STACK *a, void (*b)(void *));
+@@ -246,7 +245,7 @@ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_push(OPENSSL_STACK *st, void *data);
+ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_free(OPENSSL_STACK *a);
+ Q_AUTOTEST_EXPORT void * q_OPENSSL_sk_value(OPENSSL_STACK *a, int b);
+ int q_SSL_session_reused(SSL *a);
+-unsigned long q_SSL_CTX_set_options(SSL_CTX *ctx, unsigned long op);
++qssloptions q_SSL_CTX_set_options(SSL_CTX *ctx, qssloptions op);
+ int q_OPENSSL_init_ssl(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings);
+ size_t q_SSL_get_client_random(SSL *a, unsigned char *out, size_t outlen);
+ size_t q_SSL_SESSION_get_master_key(const SSL_SESSION *session, unsigned char *out, size_t outlen);
+@@ -510,7 +509,6 @@ const SSL_CIPHER *q_SSL_get_current_cipher(SSL *a);
+ int q_SSL_version(const SSL *a);
+ int q_SSL_get_error(SSL *a, int b);
+ STACK_OF(X509) *q_SSL_get_peer_cert_chain(SSL *a);
+-X509 *q_SSL_get_peer_certificate(SSL *a);
+ long q_SSL_get_verify_result(const SSL *a);
+ SSL *q_SSL_new(SSL_CTX *a);
+ SSL_CTX *q_SSL_get_SSL_CTX(SSL *a);
+@@ -582,10 +580,7 @@ DH *q_DH_new();
+ void q_DH_free(DH *dh);
+ DH *q_d2i_DHparams(DH **a, const unsigned char **pp, long length);
+ int q_i2d_DHparams(DH *a, unsigned char **p);
+-
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+ int q_DH_check(DH *dh, int *codes);
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+ 
+ BIGNUM *q_BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret);
+ #define q_SSL_CTX_set_tmp_dh(ctx, dh) q_SSL_CTX_ctrl((ctx), SSL_CTRL_SET_TMP_DH, 0, (char *)dh)
+@@ -754,6 +749,17 @@ void q_CRYPTO_free(void *str, const char *file, int line);
+ int q_SSL_CTX_get_security_level(const SSL_CTX *ctx);
+ void q_SSL_CTX_set_security_level(SSL_CTX *ctx, int level);
+ 
++// Here we have the ones that make difference between OpenSSL pre/post v3:
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++X509 *q_SSL_get1_peer_certificate(SSL *a);
++#define q_SSL_get_peer_certificate q_SSL_get1_peer_certificate
++int q_EVP_PKEY_get_base_id(const EVP_PKEY *pkey);
++#define q_EVP_PKEY_base_id q_EVP_PKEY_get_base_id
++#else
++X509 *q_SSL_get_peer_certificate(SSL *a);
++int q_EVP_PKEY_base_id(EVP_PKEY *a);
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+ QT_END_NAMESPACE
+ 
+ #endif
+diff --git a/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h b/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
+index bf37d07fd8..dbd42fb799 100644
+--- a/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
++++ b/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
+@@ -61,7 +61,11 @@
+ # if !defined(Q_OS_INTEGRITY)
+ #  define WIN_INTERFACE_CUSTOM   // NV
+ # endif // Q_OS_INTEGRITY
+-#endif  // QT_EGL_NO_X11
++#else // QT_EGL_NO_X11
++// If one has an eglplatform.h with https://github.com/KhronosGroup/EGL-Registry/pull/130
++// that needs USE_X11 to be defined.
++# define USE_X11
++#endif
+ 
+ #ifdef QT_EGL_WAYLAND
+ # define WAYLAND // NV
+diff --git a/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+index 159b490ce0..00aa80cd58 100644
+--- a/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
++++ b/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+@@ -567,6 +567,8 @@ void QFontconfigDatabase::populateFontDatabase()
+         fonts = FcFontList(nullptr, pattern, os);
+         FcObjectSetDestroy(os);
+         FcPatternDestroy(pattern);
++        if (!fonts)
++            return;
+     }
+ 
+     for (int i = 0; i < fonts->nfont; i++)
+diff --git a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
+index b713c19447..7cb9a8c79a 100644
+--- a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
++++ b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
+@@ -95,6 +95,7 @@ static constexpr const auto KeyTbl = qMakeArray(
+         Xkb2Qt<XKB_KEY_Clear,                   Qt::Key_Delete>,
+         Xkb2Qt<XKB_KEY_Pause,                   Qt::Key_Pause>,
+         Xkb2Qt<XKB_KEY_Print,                   Qt::Key_Print>,
++        Xkb2Qt<XKB_KEY_Sys_Req,                 Qt::Key_SysReq>,
+         Xkb2Qt<0x1005FF60,                      Qt::Key_SysReq>,         // hardcoded Sun SysReq
+         Xkb2Qt<0x1007ff00,                      Qt::Key_SysReq>,         // hardcoded X386 SysReq
+ 
+@@ -471,7 +472,7 @@ QVector<xkb_keysym_t> QXkbCommon::toKeysym(QKeyEvent *event)
+     } else if (event->modifiers() & Qt::KeypadModifier) {
+         if (qtKey >= Qt::Key_0 && qtKey <= Qt::Key_9)
+             keysyms.append(XKB_KEY_KP_0 + (qtKey - Qt::Key_0));
+-    } else if (isLatin(qtKey) && event->text().isUpper()) {
++    } else if (isLatin1(qtKey) && event->text().isUpper()) {
+         keysyms.append(qtKey);
+     }
+ 
+@@ -523,7 +524,7 @@ int QXkbCommon::keysymToQtKey(xkb_keysym_t keysym, Qt::KeyboardModifiers modifie
+         // With standard shortcuts we should prefer a latin character, this is
+         // for checks like "some qkeyevent == QKeySequence::Copy" to work even
+         // when using for example 'russian' keyboard layout.
+-        if (!QXkbCommon::isLatin(keysym)) {
++        if (!QXkbCommon::isLatin1(keysym)) {
+             xkb_keysym_t latinKeysym = QXkbCommon::lookupLatinKeysym(state, code);
+             if (latinKeysym != XKB_KEY_NoSymbol)
+                 keysym = latinKeysym;
+@@ -546,7 +547,7 @@ static int keysymToQtKey_internal(xkb_keysym_t keysym, Qt::KeyboardModifiers mod
+     } else if (keysym >= XKB_KEY_KP_0 && keysym <= XKB_KEY_KP_9) {
+         // numeric keypad keys
+         qtKey = Qt::Key_0 + (keysym - XKB_KEY_KP_0);
+-    } else if (QXkbCommon::isLatin(keysym)) {
++    } else if (QXkbCommon::isLatin1(keysym)) {
+         qtKey = QXkbCommon::qxkbcommon_xkb_keysym_to_upper(keysym);
+     } else {
+         // check if we have a direct mapping
+@@ -678,7 +679,7 @@ QList<int> QXkbCommon::possibleKeys(xkb_state *state, const QKeyEvent *event,
+         Qt::KeyboardModifiers neededMods = ModsTbl[i];
+         if ((modifiers & neededMods) == neededMods) {
+             if (i == 8) {
+-                if (isLatin(baseQtKey))
++                if (isLatin1(baseQtKey))
+                     continue;
+                 // add a latin key as a fall back key
+                 sym = lookupLatinKeysym(state, keycode);
+@@ -733,7 +734,7 @@ void QXkbCommon::verifyHasLatinLayout(xkb_keymap *keymap)
+     for (xkb_layout_index_t layout = 0; layout < layoutCount; ++layout) {
+         for (xkb_keycode_t code = minKeycode; code < maxKeycode; ++code) {
+             xkb_keymap_key_get_syms_by_level(keymap, code, layout, 0, &keysyms);
+-            if (keysyms && isLatin(keysyms[0]))
++            if (keysyms && isLatin1(keysyms[0]))
+                 nrLatinKeys++;
+             if (nrLatinKeys > 10) // arbitrarily chosen threshold
+                 return;
+@@ -766,7 +767,7 @@ xkb_keysym_t QXkbCommon::lookupLatinKeysym(xkb_state *state, xkb_keycode_t keyco
+         xkb_level_index_t level = xkb_state_key_get_level(state, keycode, layout);
+         if (xkb_keymap_key_get_syms_by_level(keymap, keycode, layout, level, &syms) != 1)
+             continue;
+-        if (isLatin(syms[0])) {
++        if (isLatin1(syms[0])) {
+             sym = syms[0];
+             break;
+         }
+diff --git a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
+index 561eae03db..8389bd8f5a 100644
+--- a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
++++ b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
+@@ -94,8 +94,8 @@ public:
+     static void verifyHasLatinLayout(xkb_keymap *keymap);
+     static xkb_keysym_t lookupLatinKeysym(xkb_state *state, xkb_keycode_t keycode);
+ 
+-    static bool isLatin(xkb_keysym_t sym) {
+-        return ((sym >= 'a' && sym <= 'z') || (sym >= 'A' && sym <= 'Z'));
++    static bool isLatin1(xkb_keysym_t sym) {
++        return sym <= 0xff;
+     }
+     static bool isKeypad(xkb_keysym_t sym) {
+         return sym >= XKB_KEY_KP_Space && sym <= XKB_KEY_KP_9;
+diff --git a/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp b/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
+index 8cd7f9b368..406f84663f 100644
+--- a/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
++++ b/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
+@@ -318,7 +318,7 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources,
+ 
+     if (current < 0 && crtc_mode.clock != 0) {
+         modes << crtc_mode;
+-        current = mode.size() - 1;
++        current = modes.size() - 1;
+     }
+ 
+     if (configuration == OutputConfigCurrent)
+diff --git a/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp b/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
+index 9153fd20bb..255ea5e33e 100644
+--- a/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
++++ b/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
+@@ -194,6 +194,9 @@ QString AtSpiAdaptor::introspect(const QString &path) const
+                 "      <arg direction=\"out\" type=\"(so)\"/>\n"
+                 "      <annotation value=\"QSpiObjectReference\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n"
+                 "    </method>\n"
++                "    <method name=\"GetAccessibleId\">\n"
++                "      <arg direction=\"out\" type=\"s\"/>\n"
++                "    </method>\n"
+                 "  </interface>\n"
+                 );
+ 
+@@ -913,8 +916,17 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+     }
+     case QAccessible::NameChanged: {
+         if (sendObject || sendObject_property_change || sendObject_property_change_accessible_name) {
+-            QString path = pathForInterface(event->accessibleInterface());
+-            QVariantList args = packDBusSignalArguments(QLatin1String("accessible-name"), 0, 0, variantForPath(path));
++            QAccessibleInterface *iface = event->accessibleInterface();
++            if (!iface) {
++                qCDebug(lcAccessibilityAtspi,
++                        "NameChanged event from invalid accessible.");
++                return;
++            }
++
++            QString path = pathForInterface(iface);
++            QVariantList args = packDBusSignalArguments(
++                QLatin1String("accessible-name"), 0, 0,
++                QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Name))));
+             sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                            QLatin1String("PropertyChange"), args);
+         }
+@@ -922,8 +934,17 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+     }
+     case QAccessible::DescriptionChanged: {
+         if (sendObject || sendObject_property_change || sendObject_property_change_accessible_description) {
+-            QString path = pathForInterface(event->accessibleInterface());
+-            QVariantList args = packDBusSignalArguments(QLatin1String("accessible-description"), 0, 0, variantForPath(path));
++            QAccessibleInterface *iface = event->accessibleInterface();
++            if (!iface) {
++                qCDebug(lcAccessibilityAtspi,
++                        "DescriptionChanged event from invalid accessible.");
++                return;
++            }
++
++            QString path = pathForInterface(iface);
++            QVariantList args = packDBusSignalArguments(
++                QLatin1String("accessible-description"), 0, 0,
++                QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Description))));
+             sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                            QLatin1String("PropertyChange"), args);
+         }
+@@ -1038,7 +1059,9 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+                 // Combo Box with AT-SPI likes to be special
+                 // It requires a name-change to update caches and then selection-changed
+                 QString path = pathForInterface(iface);
+-                QVariantList args1 = packDBusSignalArguments(QLatin1String("accessible-name"), 0, 0, variantForPath(path));
++                QVariantList args1 = packDBusSignalArguments(
++                    QLatin1String("accessible-name"), 0, 0,
++                    QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Name))));
+                 sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                                QLatin1String("PropertyChange"), args1);
+                 QVariantList args2 = packDBusSignalArguments(QString(), 0, 0, QVariant::fromValue(QDBusVariant(QVariant(0))));
+@@ -1358,6 +1381,26 @@ void AtSpiAdaptor::registerApplication()
+     delete registry;
+ }
+ 
++namespace {
++QString accessibleIdForAccessible(QAccessibleInterface *accessible)
++{
++    QString result;
++    while (accessible) {
++        if (!result.isEmpty())
++            result.prepend(QLatin1Char('.'));
++        if (auto obj = accessible->object()) {
++            const QString name = obj->objectName();
++            if (!name.isEmpty())
++                result.prepend(name);
++            else
++                result.prepend(QString::fromUtf8(obj->metaObject()->className()));
++        }
++        accessible = accessible->parent();
++    }
++    return result;
++}
++} // namespace
++
+ // Accessible
+ bool AtSpiAdaptor::accessibleInterface(QAccessibleInterface *interface, const QString &function, const QDBusMessage &message, const QDBusConnection &connection)
+ {
+@@ -1441,6 +1484,9 @@ bool AtSpiAdaptor::accessibleInterface(QAccessibleInterface *interface, const QS
+             children << ref;
+         }
+         connection.send(message.createReply(QVariant::fromValue(children)));
++    } else if (function == QLatin1String("GetAccessibleId")) {
++        sendReply(connection, message,
++                  QVariant::fromValue(QDBusVariant(accessibleIdForAccessible(interface))));
+     } else {
+         qCDebug(lcAccessibilityAtspi) << "WARNING: AtSpiAdaptor::accessibleInterface does not implement " << function << message.path();
+         return false;
+diff --git a/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp b/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
+index 45ddc8e496..cc734abc63 100644
+--- a/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
++++ b/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
+@@ -69,6 +69,21 @@ QT_BEGIN_NAMESPACE
+ DBusConnection::DBusConnection(QObject *parent)
+     : QObject(parent), m_a11yConnection(QString()), m_enabled(false)
+ {
++    // If the bus is explicitly set via env var it overrides everything else.
++    QByteArray addressEnv = qgetenv("AT_SPI_BUS_ADDRESS");
++    if (!addressEnv.isEmpty()) {
++        // Only connect on next loop run, connections to our enabled signal are
++        // only established after the ctor returns.
++        QMetaObject::invokeMethod(
++                this,
++                [this, addressEnv] {
++                    m_enabled = true;
++                    connectA11yBus(QString::fromLocal8Bit(addressEnv));
++                },
++                Qt::QueuedConnection);
++        return;
++    }
++
+     // Start monitoring if "org.a11y.Bus" is registered as DBus service.
+     QDBusConnection c = QDBusConnection::sessionBus();
+     if (!c.isConnected()) {
+diff --git a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
+index 1a3cab275d..2abe039126 100644
+--- a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
++++ b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
+@@ -51,6 +51,9 @@
+ #include <QtCore/QStandardPaths>
+ #include <QtCore/QUrl>
+ 
++#include <QtGui/QGuiApplication>
++#include <QtGui/QWindow>
++
+ #if QT_CONFIG(dbus)
+ // These QtCore includes are needed for xdg-desktop-portal support
+ #include <QtCore/private/qcore_unix_p.h>
+@@ -58,6 +61,8 @@
+ #include <QtCore/QFileInfo>
+ #include <QtCore/QUrlQuery>
+ 
++#include <QtGui/QColor>
++
+ #include <QtDBus/QDBusConnection>
+ #include <QtDBus/QDBusMessage>
+ #include <QtDBus/QDBusPendingCall>
+@@ -142,6 +147,8 @@ static inline bool detectWebBrowser(const QByteArray &desktop,
+     }
+ 
+     if (desktop == QByteArray("KDE")) {
++        if (checkExecutable(QStringLiteral("kde-open5"), browser))
++            return true;
+         // Konqueror launcher
+         if (checkExecutable(QStringLiteral("kfmclient"), browser)) {
+             browser->append(QLatin1String(" exec"));
+@@ -296,8 +303,135 @@ static inline QDBusMessage xdgDesktopPortalSendEmail(const QUrl &url)
+ 
+     return QDBusConnection::sessionBus().call(message);
+ }
++
++namespace {
++struct XDGDesktopColor
++{
++    double r = 0;
++    double g = 0;
++    double b = 0;
++
++    QColor toQColor() const
++    {
++        constexpr auto rgbMax = 255;
++        return { static_cast<int>(r * rgbMax), static_cast<int>(g * rgbMax),
++                 static_cast<int>(b * rgbMax) };
++    }
++};
++
++const QDBusArgument &operator>>(const QDBusArgument &argument, XDGDesktopColor &myStruct)
++{
++    argument.beginStructure();
++    argument >> myStruct.r >> myStruct.g >> myStruct.b;
++    argument.endStructure();
++    return argument;
++}
++
++class XdgDesktopPortalColorPicker : public QPlatformServiceColorPicker
++{
++    Q_OBJECT
++public:
++    XdgDesktopPortalColorPicker(const QString &parentWindowId, QWindow *parent)
++        : QPlatformServiceColorPicker(parent), m_parentWindowId(parentWindowId)
++    {
++    }
++
++    void pickColor() override
++    {
++        // DBus signature:
++        // PickColor (IN   s      parent_window,
++        //            IN   a{sv}  options
++        //            OUT  o      handle)
++        // Options:
++        // handle_token (s) -  A string that will be used as the last element of the @handle.
++
++        QDBusMessage message = QDBusMessage::createMethodCall(
++                QStringLiteral("org.freedesktop.portal.Desktop"), QStringLiteral("/org/freedesktop/portal/desktop"),
++                QStringLiteral("org.freedesktop.portal.Screenshot"), QStringLiteral("PickColor"));
++        message << m_parentWindowId << QVariantMap();
++
++        QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
++        auto watcher = new QDBusPendingCallWatcher(pendingCall, this);
++        connect(watcher, &QDBusPendingCallWatcher::finished, this,
++                [this](QDBusPendingCallWatcher *watcher) {
++                    watcher->deleteLater();
++                    QDBusPendingReply<QDBusObjectPath> reply = *watcher;
++                    if (reply.isError()) {
++                        qWarning("DBus call to pick color failed: %s",
++                                 qPrintable(reply.error().message()));
++                        Q_EMIT colorPicked({});
++                    } else {
++                        QDBusConnection::sessionBus().connect(
++                                QStringLiteral("org.freedesktop.portal.Desktop"), reply.value().path(),
++                                QStringLiteral("org.freedesktop.portal.Request"), QStringLiteral("Response"), this,
++                                // clang-format off
++                                SLOT(gotColorResponse(uint,QVariantMap))
++                                // clang-format on
++                        );
++                    }
++                });
++    }
++
++private Q_SLOTS:
++    void gotColorResponse(uint result, const QVariantMap &map)
++    {
++        if (result != 0)
++            return;
++        XDGDesktopColor color{};
++        map.value(QStringLiteral("color")).value<QDBusArgument>() >> color;
++        Q_EMIT colorPicked(color.toQColor());
++        deleteLater();
++    }
++
++private:
++    const QString m_parentWindowId;
++};
++} // namespace
++
+ #endif // QT_CONFIG(dbus)
+ 
++QGenericUnixServices::QGenericUnixServices()
++{
++#if QT_CONFIG(dbus)
++    if (qEnvironmentVariableIntValue("QT_NO_XDG_DESKTOP_PORTAL") > 0) {
++        return;
++    }
++    QDBusMessage message = QDBusMessage::createMethodCall(
++            QStringLiteral("org.freedesktop.portal.Desktop"), QStringLiteral("/org/freedesktop/portal/desktop"),
++            QStringLiteral("org.freedesktop.DBus.Properties"), QStringLiteral("Get"));
++    message << QStringLiteral("org.freedesktop.portal.Screenshot")
++            << QStringLiteral("version");
++
++    QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
++    auto watcher = new QDBusPendingCallWatcher(pendingCall);
++    QObject::connect(watcher, &QDBusPendingCallWatcher::finished, watcher,
++                     [this](QDBusPendingCallWatcher *watcher) {
++                         watcher->deleteLater();
++                         QDBusPendingReply<QVariant> reply = *watcher;
++                         if (!reply.isError() && reply.value().toUInt() >= 2)
++                             m_hasScreenshotPortalWithColorPicking = true;
++                     });
++
++#endif
++}
++
++QPlatformServiceColorPicker *QGenericUnixServices::colorPicker(QWindow *parent)
++{
++#if QT_CONFIG(dbus)
++    // Make double sure that we are in a wayland environment. In particular check
++    // WAYLAND_DISPLAY so also XWayland apps benefit from portal-based color picking.
++    // Outside wayland we'll rather rely on other means than the XDG desktop portal.
++    if (!qEnvironmentVariableIsEmpty("WAYLAND_DISPLAY")
++        || QGuiApplication::platformName().startsWith(QLatin1String("wayland"))) {
++        return new XdgDesktopPortalColorPicker(portalWindowIdentifier(parent), parent);
++    }
++    return nullptr;
++#else
++    Q_UNUSED(parent);
++    return nullptr;
++#endif
++}
++
+ QByteArray QGenericUnixServices::desktopEnvironment() const
+ {
+     static const QByteArray result = detectDesktopEnvironment();
+@@ -352,6 +486,8 @@ bool QGenericUnixServices::openDocument(const QUrl &url)
+ }
+ 
+ #else
++QGenericUnixServices::QGenericUnixServices() = default;
++
+ QByteArray QGenericUnixServices::desktopEnvironment() const
+ {
+     return QByteArrayLiteral("UNKNOWN");
+@@ -371,6 +507,30 @@ bool QGenericUnixServices::openDocument(const QUrl &url)
+     return false;
+ }
+ 
++QPlatformServiceColorPicker *QGenericUnixServices::colorPicker(QWindow *parent)
++{
++    Q_UNUSED(parent);
++    return nullptr;
++}
++
+ #endif // QT_NO_MULTIPROCESS
+ 
++QString QGenericUnixServices::portalWindowIdentifier(QWindow *window)
++{
++    if (QGuiApplication::platformName() == QLatin1String("xcb"))
++        return QStringLiteral("x11:") + QString::number(window->winId(), 16);
++    return QString();
++}
++
++bool QGenericUnixServices::hasCapability(Capability capability) const
++{
++    switch (capability) {
++    case Capability::ColorPicking:
++        return m_hasScreenshotPortalWithColorPicking;
++    }
++    return false;
++}
++
+ QT_END_NAMESPACE
++
++#include "qgenericunixservices.moc"
+diff --git a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
+index 8ac3de6f03..30924e64bd 100644
+--- a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
++++ b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
+@@ -59,16 +59,21 @@ QT_BEGIN_NAMESPACE
+ class QGenericUnixServices : public QPlatformServices
+ {
+ public:
+-    QGenericUnixServices() {}
++    QGenericUnixServices();
+ 
+     QByteArray desktopEnvironment() const override;
+ 
++    bool hasCapability(Capability capability) const override;
+     bool openUrl(const QUrl &url) override;
+     bool openDocument(const QUrl &url) override;
++    QPlatformServiceColorPicker *colorPicker(QWindow *parent = nullptr) override;
++
++    virtual QString portalWindowIdentifier(QWindow *window);
+ 
+ private:
+     QString m_webBrowser;
+     QString m_documentLauncher;
++    bool m_hasScreenshotPortalWithColorPicking = false;
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
+index 09470bccc6..cc7c7d4d8a 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
+@@ -69,6 +69,7 @@ const QString MenuBarPath = QLatin1String("/MenuBar");
+ */
+ QDBusMenuConnection::QDBusMenuConnection(QObject *parent, const QString &serviceName)
+     : QObject(parent)
++    , m_serviceName(serviceName)
+     , m_connection(serviceName.isNull() ? QDBusConnection::sessionBus()
+                                         : QDBusConnection::connectToBus(QDBusConnection::SessionBus, serviceName))
+     , m_dbusWatcher(new QDBusServiceWatcher(StatusNotifierWatcherService, m_connection, QDBusServiceWatcher::WatchForRegistration, this))
+@@ -83,6 +84,12 @@ QDBusMenuConnection::QDBusMenuConnection(QObject *parent, const QString &service
+ #endif
+ }
+ 
++QDBusMenuConnection::~QDBusMenuConnection()
++{
++  if (!m_serviceName.isEmpty() && m_connection.isConnected())
++      QDBusConnection::disconnectFromBus(m_serviceName);
++}
++
+ void QDBusMenuConnection::dbusError(const QDBusError &error)
+ {
+     qWarning() << "QDBusTrayIcon encountered a D-Bus error:" << error;
+@@ -105,13 +112,7 @@ void QDBusMenuConnection::unregisterTrayIconMenu(QDBusTrayIcon *item)
+ 
+ bool QDBusMenuConnection::registerTrayIcon(QDBusTrayIcon *item)
+ {
+-    bool success = connection().registerService(item->instanceId());
+-    if (!success) {
+-        qWarning() << "failed to register service" << item->instanceId();
+-        return false;
+-    }
+-
+-    success = connection().registerObject(StatusNotifierItemPath, item);
++    bool success = connection().registerObject(StatusNotifierItemPath, item);
+     if (!success) {
+         unregisterTrayIcon(item);
+         qWarning() << "failed to register" << item->instanceId() << StatusNotifierItemPath;
+@@ -126,21 +127,18 @@ bool QDBusMenuConnection::registerTrayIcon(QDBusTrayIcon *item)
+ 
+ bool QDBusMenuConnection::registerTrayIconWithWatcher(QDBusTrayIcon *item)
+ {
++    Q_UNUSED(item);
+     QDBusMessage registerMethod = QDBusMessage::createMethodCall(
+                 StatusNotifierWatcherService, StatusNotifierWatcherPath, StatusNotifierWatcherService,
+                 QLatin1String("RegisterStatusNotifierItem"));
+-    registerMethod.setArguments(QVariantList() << item->instanceId());
++    registerMethod.setArguments(QVariantList() << m_connection.baseService());
+     return m_connection.callWithCallback(registerMethod, this, SIGNAL(trayIconRegistered()), SLOT(dbusError(QDBusError)));
+ }
+ 
+-bool QDBusMenuConnection::unregisterTrayIcon(QDBusTrayIcon *item)
++void QDBusMenuConnection::unregisterTrayIcon(QDBusTrayIcon *item)
+ {
+     unregisterTrayIconMenu(item);
+     connection().unregisterObject(StatusNotifierItemPath);
+-    bool success = connection().unregisterService(item->instanceId());
+-    if (!success)
+-        qWarning() << "failed to unregister service" << item->instanceId();
+-    return success;
+ }
+ #endif // QT_NO_SYSTEMTRAYICON
+ 
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
+index f484795fbb..97bdfabb85 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
++++ b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
+@@ -70,6 +70,7 @@ class QDBusMenuConnection : public QObject
+ 
+ public:
+     QDBusMenuConnection(QObject *parent = nullptr, const QString &serviceName = QString());
++    ~QDBusMenuConnection();
+     QDBusConnection connection() const { return m_connection; }
+     QDBusServiceWatcher *dbusWatcher() const { return m_dbusWatcher; }
+     bool isStatusNotifierHostRegistered() const { return m_statusNotifierHostRegistered; }
+@@ -78,7 +79,7 @@ public:
+     void unregisterTrayIconMenu(QDBusTrayIcon *item);
+     bool registerTrayIcon(QDBusTrayIcon *item);
+     bool registerTrayIconWithWatcher(QDBusTrayIcon *item);
+-    bool unregisterTrayIcon(QDBusTrayIcon *item);
++    void unregisterTrayIcon(QDBusTrayIcon *item);
+ #endif // QT_NO_SYSTEMTRAYICON
+ 
+ Q_SIGNALS:
+@@ -90,6 +91,7 @@ private Q_SLOTS:
+     void dbusError(const QDBusError &error);
+ 
+ private:
++    QString m_serviceName;
+     QDBusConnection m_connection;
+     QDBusServiceWatcher *m_dbusWatcher;
+     bool m_statusNotifierHostRegistered;
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp b/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
+index bede70975a..76bfec5e5a 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
+@@ -71,8 +71,12 @@ Q_LOGGING_CATEGORY(qLcTray, "qt.qpa.tray")
+ static QString iconTempPath()
+ {
+     QString tempPath = QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation);
+-    if (!tempPath.isEmpty())
++    if (!tempPath.isEmpty()) {
++        QString flatpakId = qEnvironmentVariable("FLATPAK_ID");
++        if (!flatpakId.isEmpty() && QFileInfo::exists(QLatin1String("/.flatpak-info")))
++            tempPath += QLatin1String("/app/") + flatpakId;
+         return tempPath;
++    }
+ 
+     tempPath = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation);
+ 
+diff --git a/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+index cb1b39db64..6e01af052c 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+@@ -755,6 +755,9 @@ QVariant QGnomeTheme::themeHint(QPlatformTheme::ThemeHint hint) const
+         return QVariant(QChar(0x2022));
+     case QPlatformTheme::UiEffects:
+         return QVariant(int(HoverEffect));
++    case QPlatformTheme::ButtonPressKeys:
++        return QVariant::fromValue(
++                QList<Qt::Key>({ Qt::Key_Space, Qt::Key_Return, Qt::Key_Enter, Qt::Key_Select }));
+     default:
+         break;
+     }
+diff --git a/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp b/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
+index 98e05195ee..1e92f43dec 100644
+--- a/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
++++ b/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
+@@ -343,8 +343,7 @@ void QEglFSCursor::paintOnScreen()
+     // screens are siblings of each other. When not enabled, the sibling list
+     // only contains m_screen itself.
+     for (QPlatformScreen *screen : m_screen->virtualSiblings()) {
+-        if (screen->geometry().contains(cr.topLeft().toPoint() + m_cursor.hotSpot)
+-            && QOpenGLContext::currentContext()->screen() == screen->screen())
++        if (screen->geometry().contains(cr.topLeft().toPoint() + m_cursor.hotSpot))
+         {
+             cr.translate(-screen->geometry().topLeft());
+             const QSize screenSize = screen->geometry().size();
+@@ -468,11 +467,12 @@ void QEglFSCursor::draw(const QRectF &r)
+ {
+     StateSaver stateSaver;
+ 
+-    QEglFSCursorData &gfx = static_cast<QEglFSContext*>(QOpenGLContext::currentContext()->handle())->cursorData;
+-    if (!gfx.program) {
+-        // one time initialization
++    // one time initialization
++    if (!QOpenGLFunctions::d_ptr)
+         initializeOpenGLFunctions();
+ 
++    QEglFSCursorData &gfx = static_cast<QEglFSContext*>(QOpenGLContext::currentContext()->handle())->cursorData;
++    if (!gfx.program) {
+         createShaderPrograms();
+ 
+         if (!gfx.atlasTexture) {
+diff --git a/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp b/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
+index 645a0ae2e9..3e0e406f1a 100644
+--- a/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
++++ b/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
+@@ -179,7 +179,7 @@ void QEglFSKmsEventReader::create(QEglFSKmsDevice *device)
+ 
+     m_device = device;
+ 
+-    qCDebug(qLcEglfsKmsDebug, "Initalizing event reader for device %p fd %d",
++    qCDebug(qLcEglfsKmsDebug, "Initializing event reader for device %p fd %d",
+             m_device, m_device->fd());
+ 
+     m_thread = new QEglFSKmsEventReaderThread(m_device->fd());
+diff --git a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
+index 141fb68a23..d4294d425a 100644
+--- a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
++++ b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
+@@ -122,11 +122,13 @@ QOffscreenIntegration::QOffscreenIntegration()
+ #endif
+     m_services.reset(new QPlatformServices);
+ 
+-    QWindowSystemInterface::handleScreenAdded(new QOffscreenScreen);
++    m_screen = new QOffscreenScreen;
++    QWindowSystemInterface::handleScreenAdded(m_screen);
+ }
+ 
+ QOffscreenIntegration::~QOffscreenIntegration()
+ {
++    QWindowSystemInterface::handleScreenRemoved(m_screen);
+ }
+ 
+ void QOffscreenIntegration::initialize()
+diff --git a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
+index 0ea90f6c2f..fe00fde07c 100644
+--- a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
++++ b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
+@@ -84,6 +84,7 @@ protected:
+ #endif
+     QScopedPointer<QPlatformInputContext> m_inputContext;
+     QScopedPointer<QPlatformServices> m_services;
++    QPlatformScreen *m_screen;
+     mutable QScopedPointer<QPlatformNativeInterface> m_nativeInterface;
+ };
+ 
+diff --git a/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp b/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
+index 6fa5a8a2b3..1f49f0aefd 100644
+--- a/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
++++ b/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
+@@ -48,6 +48,7 @@
+ #include <qpa/qplatformnativeinterface.h>
+ #include <QtPlatformHeaders/qwglnativecontext.h>
+ 
++#include <private/qsystemlibrary_p.h>
+ #include <algorithm>
+ 
+ #include <wingdi.h>
+@@ -162,19 +163,25 @@ QFunctionPointer QWindowsOpengl32DLL::resolve(const char *name)
+ 
+ bool QWindowsOpengl32DLL::init(bool softwareRendering)
+ {
+-    const QByteArray opengl32 = QByteArrayLiteral("opengl32.dll");
+-    const QByteArray swopengl = QByteArrayLiteral("opengl32sw.dll");
++    const QByteArray opengl32 = QByteArrayLiteral("opengl32");
++    const QByteArray swopengl = QByteArrayLiteral("opengl32sw");
++    bool useSystemLib = false;
+ 
+     QByteArray openglDll = qgetenv("QT_OPENGL_DLL");
+-    if (openglDll.isEmpty())
++    if (openglDll.isEmpty()) {
+         openglDll = softwareRendering ? swopengl : opengl32;
++        useSystemLib = !softwareRendering;
++    }
+ 
+     openglDll = openglDll.toLower();
+     m_nonOpengl32 = openglDll != opengl32;
+ 
+     qCDebug(lcQpaGl) << "Qt: Using WGL and OpenGL from" << openglDll;
+ 
+-    m_lib = ::LoadLibraryA(openglDll.constData());
++    if (useSystemLib)
++        m_lib = QSystemLibrary::load((wchar_t*)(QString::fromLatin1(openglDll).utf16()));
++    else
++        m_lib = LoadLibraryA(openglDll.constData());
+     if (!m_lib) {
+         qErrnoWarning(::GetLastError(), "Failed to load %s", openglDll.constData());
+         return false;
+@@ -184,7 +191,7 @@ bool QWindowsOpengl32DLL::init(bool softwareRendering)
+         // Load opengl32.dll always. GDI functions like ChoosePixelFormat do
+         // GetModuleHandle for opengl32.dll and behave differently (and call back into
+         // opengl32) when the module is present. This is fine for dummy contexts and windows.
+-        ::LoadLibraryA("opengl32.dll");
++        QSystemLibrary::load(L"opengl32");
+     }
+ 
+     wglCreateContext = reinterpret_cast<HGLRC (WINAPI *)(HDC)>(resolve("wglCreateContext"));
+diff --git a/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp b/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
+index d7d186e804..9eb4011bf2 100644
+--- a/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
++++ b/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
+@@ -49,6 +49,7 @@
+ #include <QtCore/qstandardpaths.h>
+ #include <QtCore/qlibraryinfo.h>
+ #include <QtCore/qhash.h>
++#include <private/qsystemlibrary_p.h>
+ 
+ #ifndef QT_NO_OPENGL
+ #include <private/qopengl_p.h>
+@@ -396,7 +397,7 @@ bool QWindowsOpenGLTester::testDesktopGL()
+ 
+     // Test #1: Load opengl32.dll and try to resolve an OpenGL 2 function.
+     // This will typically fail on systems that do not have a real OpenGL driver.
+-    lib = LoadLibraryA("opengl32.dll");
++    lib = QSystemLibrary::load(L"opengl32");
+     if (lib) {
+         CreateContext = reinterpret_cast<CreateContextType>(
+             reinterpret_cast<QFunctionPointer>(::GetProcAddress(lib, "wglCreateContext")));
+diff --git a/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp b/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
+index 1afa00cfc9..118af6ce73 100644
+--- a/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
++++ b/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
+@@ -41,6 +41,7 @@
+ 
+ #include <QRect>
+ #include <QList>
++#include <QMap>
+ #include <QDebug>
+ 
+ #include <qmath.h>
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp b/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
+index 9e2a37a6a1..e6e175a118 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
+@@ -488,12 +488,12 @@ void QXcbConnection::printXcbError(const char *message, xcb_generic_error_t *err
+     uint clamped_error_code = qMin<uint>(error->error_code, (sizeof(xcb_errors) / sizeof(xcb_errors[0])) - 1);
+     uint clamped_major_code = qMin<uint>(error->major_code, (sizeof(xcb_protocol_request_codes) / sizeof(xcb_protocol_request_codes[0])) - 1);
+ 
+-    qCWarning(lcQpaXcb, "%s: %d (%s), sequence: %d, resource id: %d, major code: %d (%s), minor code: %d",
+-             message,
+-             int(error->error_code), xcb_errors[clamped_error_code],
+-             int(error->sequence), int(error->resource_id),
+-             int(error->major_code), xcb_protocol_request_codes[clamped_major_code],
+-             int(error->minor_code));
++    qCDebug(lcQpaXcb, "%s: %d (%s), sequence: %d, resource id: %d, major code: %d (%s), minor code: %d",
++            message,
++            int(error->error_code), xcb_errors[clamped_error_code],
++            int(error->sequence), int(error->resource_id),
++            int(error->major_code), xcb_protocol_request_codes[clamped_major_code],
++            int(error->minor_code));
+ }
+ 
+ static Qt::MouseButtons translateMouseButtons(int s)
+@@ -702,6 +702,8 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
+             QXcbVirtualDesktop *virtualDesktop = virtualDesktopForRootWindow(propertyNotify->window);
+             if (virtualDesktop)
+                 virtualDesktop->updateWorkArea();
++        } else if (propertyNotify->atom == atom(QXcbAtom::_NET_SUPPORTED)) {
++            m_wmSupport->updateNetWMAtoms();
+         } else {
+             HANDLE_PLATFORM_WINDOW_EVENT(xcb_property_notify_event_t, window, handlePropertyNotifyEvent);
+         }
+@@ -750,7 +752,7 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
+                 case XCB_XKB_NEW_KEYBOARD_NOTIFY: {
+                     xcb_xkb_new_keyboard_notify_event_t *ev = &xkb_event->new_keyboard_notify;
+                     if (ev->changed & XCB_XKB_NKN_DETAIL_KEYCODES)
+-                        m_keyboard->updateKeymap(ev);
++                        m_keyboard->updateKeymap();
+                     break;
+                 }
+                 default:
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp b/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
+index 76869ced60..02d2eebb56 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
+@@ -274,8 +274,7 @@ QPlatformWindow *QXcbIntegration::createForeignWindow(QWindow *window, WId nativ
+ #ifndef QT_NO_OPENGL
+ QPlatformOpenGLContext *QXcbIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
+ {
+-    QXcbScreen *screen = static_cast<QXcbScreen *>(context->screen()->handle());
+-    QXcbGlIntegration *glIntegration = screen->connection()->glIntegration();
++    QXcbGlIntegration *glIntegration = defaultConnection()->glIntegration();
+     if (!glIntegration) {
+         qWarning("QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled");
+         return nullptr;
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+index efecd7e2d1..e8286381a2 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+@@ -365,17 +365,6 @@ void QXcbKeyboard::updateKeymap(xcb_mapping_notify_event_t *event)
+     updateKeymap();
+ }
+ 
+-void QXcbKeyboard::updateKeymap(xcb_xkb_new_keyboard_notify_event_t *event)
+-{
+-    if (!event)
+-        return;
+-
+-    if (event->deviceID != event->oldDeviceID)
+-        m_config = false;
+-
+-    updateKeymap();
+-}
+-
+ void QXcbKeyboard::updateKeymap()
+ {
+     KeysymModifierMap keysymMods;
+@@ -383,6 +372,8 @@ void QXcbKeyboard::updateKeymap()
+         keysymMods = keysymsToModifiers();
+     updateModifiers(keysymMods);
+ 
++    m_config = true;
++
+     if (!m_xkbContext) {
+         m_xkbContext.reset(xkb_context_new(XKB_CONTEXT_NO_DEFAULT_INCLUDES));
+         if (!m_xkbContext) {
+@@ -398,13 +389,8 @@ void QXcbKeyboard::updateKeymap()
+     if (connection()->hasXKB()) {
+         m_xkbKeymap.reset(xkb_x11_keymap_new_from_device(m_xkbContext.get(), xcb_connection(),
+                                                          core_device_id, XKB_KEYMAP_COMPILE_NO_FLAGS));
+-        if (m_xkbKeymap) {
+-            if (m_config)
+-                m_xkbState.reset(xkb_state_new(m_xkbKeymap.get()));
+-            else
+-                m_xkbState.reset(xkb_x11_state_new_from_device(m_xkbKeymap.get(), xcb_connection(), core_device_id));
+-
+-        }
++        if (m_xkbKeymap)
++            m_xkbState.reset(xkb_x11_state_new_from_device(m_xkbKeymap.get(), xcb_connection(), core_device_id));
+     } else {
+         m_xkbKeymap.reset(keymapFromCore(keysymMods));
+         if (m_xkbKeymap)
+@@ -425,8 +411,6 @@ void QXcbKeyboard::updateKeymap()
+     updateXKBMods();
+ 
+     QXkbCommon::verifyHasLatinLayout(m_xkbKeymap.get());
+-
+-    m_config = true;
+ }
+ 
+ QList<int> QXcbKeyboard::possibleKeys(const QKeyEvent *event) const
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
+index b652c85fe3..0ee08aeff2 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
++++ b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
+@@ -69,7 +69,6 @@ public:
+ 
+     Qt::KeyboardModifiers translateModifiers(int s) const;
+     void updateKeymap(xcb_mapping_notify_event_t *event);
+-    void updateKeymap(xcb_xkb_new_keyboard_notify_event_t *event);
+     void updateKeymap();
+     QList<int> possibleKeys(const QKeyEvent *event) const;
+ 
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp b/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
+index ffda7b6a57..863e961f4c 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
+@@ -564,11 +564,6 @@ void QXcbWindow::setGeometry(const QRect &rect)
+ {
+     QPlatformWindow::setGeometry(rect);
+ 
+-    if (shouldDeferTask(Task::SetGeometry)) {
+-        m_deferredGeometry = rect;
+-        return;
+-    }
+-
+     propagateSizeHints();
+ 
+     QXcbScreen *currentScreen = xcbScreen();
+@@ -693,9 +688,6 @@ void QXcbWindow::setVisible(bool visible)
+ 
+ void QXcbWindow::show()
+ {
+-    if (shouldDeferTask(Task::Map))
+-        return;
+-
+     if (window()->isTopLevel()) {
+ 
+         // update WM_NORMAL_HINTS
+@@ -706,7 +698,7 @@ void QXcbWindow::show()
+         if (isTransient(window())) {
+             const QWindow *tp = window()->transientParent();
+             if (tp && tp->handle())
+-                transientXcbParent = static_cast<const QXcbWindow *>(tp->handle())->winId();
++                transientXcbParent = tp->handle()->winId();
+             // Default to client leader if there is no transient parent, else modal dialogs can
+             // be hidden by their parents.
+             if (!transientXcbParent)
+@@ -746,10 +738,6 @@ void QXcbWindow::show()
+ 
+ void QXcbWindow::hide()
+ {
+-    if (shouldDeferTask(Task::Unmap))
+-        return;
+-
+-    m_wmStateValid = false;
+     xcb_unmap_window(xcb_connection(), m_window);
+ 
+     // send synthetic UnmapNotify event according to icccm 4.1.4
+@@ -909,9 +897,6 @@ QXcbWindow::NetWmStates QXcbWindow::netWmStates()
+ 
+ void QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
+ {
+-    if (shouldDeferTask(Task::SetWindowFlags))
+-        return;
+-
+     Qt::WindowType type = static_cast<Qt::WindowType>(int(flags & Qt::WindowType_Mask));
+ 
+     if (type == Qt::ToolTip)
+@@ -941,8 +926,6 @@ void QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
+ 
+     setTransparentForMouseEvents(flags & Qt::WindowTransparentForInput);
+     updateDoesNotAcceptFocus(flags & Qt::WindowDoesNotAcceptFocus);
+-
+-    m_isWmManagedWindow = !(flags & Qt::X11BypassWindowManagerHint);
+ }
+ 
+ void QXcbWindow::setMotifWmHints(Qt::WindowFlags flags)
+@@ -1142,9 +1125,6 @@ void QXcbWindow::setWindowState(Qt::WindowStates state)
+     if (state == m_windowState)
+         return;
+ 
+-    if (shouldDeferTask(Task::SetWindowState))
+-        return;
+-
+     // unset old state
+     if (m_windowState & Qt::WindowMinimized)
+         xcb_map_window(xcb_connection(), m_window);
+@@ -1350,6 +1330,12 @@ void QXcbWindow::setWindowIcon(const QIcon &icon)
+     }
+ 
+     if (!icon_data.isEmpty()) {
++        // Ignore icon exceeding maximum xcb request length
++        if (icon_data.size() > xcb_get_maximum_request_length(xcb_connection())) {
++            qWarning("Ignoring window icon: Size %llu exceeds maximum xcb request length %u.",
++                     icon_data.size(), xcb_get_maximum_request_length(xcb_connection()));
++            return;
++        }
+         xcb_change_property(xcb_connection(),
+                             XCB_PROP_MODE_REPLACE,
+                             m_window,
+@@ -1639,7 +1625,7 @@ void QXcbWindow::setWmWindowType(QXcbWindowFunctions::WmWindowTypes types, Qt::W
+         break;
+     }
+ 
+-    if ((flags & Qt::FramelessWindowHint) && !(type & QXcbWindowFunctions::KdeOverride)) {
++    if ((flags & Qt::FramelessWindowHint) && !(types & QXcbWindowFunctions::KdeOverride)) {
+         // override netwm type - quick and easy for KDE noborder
+         atoms.append(atom(QXcbAtom::_KDE_NET_WM_WINDOW_TYPE_OVERRIDE));
+     }
+@@ -1894,10 +1880,6 @@ void QXcbWindow::handleUnmapNotifyEvent(const xcb_unmap_notify_event_t *event)
+     if (event->window == m_window) {
+         m_mapped = false;
+         QWindowSystemInterface::handleExposeEvent(window(), QRegion());
+-        if (!m_isWmManagedWindow || parent()) {
+-            m_wmStateValid = true;
+-            handleDeferredTasks();
+-        }
+     }
+ }
+ 
+@@ -2212,98 +2194,30 @@ void QXcbWindow::handleLeaveNotifyEvent(const xcb_leave_notify_event_t *event)
+     handleLeaveNotifyEvent(event->root_x, event->root_y, event->mode, event->detail, event->time);
+ }
+ 
+-bool QXcbWindow::shouldDeferTask(Task task)
+-{
+-    if (m_wmStateValid)
+-        return false;
+-
+-    m_deferredTasks.append(task);
+-    return true;
+-}
+-
+-void QXcbWindow::handleDeferredTasks()
+-{
+-    Q_ASSERT(m_wmStateValid == true);
+-    if (m_deferredTasks.isEmpty())
+-        return;
+-
+-    bool map = false;
+-    bool unmap = false;
+-
+-    QVector<Task> tasks;
+-    for (auto taskIt = m_deferredTasks.rbegin(); taskIt != m_deferredTasks.rend(); ++taskIt) {
+-        if (!tasks.contains(*taskIt))
+-            tasks.prepend(*taskIt);
+-    }
+-
+-    for (Task task : tasks) {
+-        switch (task) {
+-        case Task::Map:
+-            map = true;
+-            unmap = false;
+-            break;
+-        case Task::Unmap:
+-            unmap = true;
+-            map = false;
+-            break;
+-        case Task::SetGeometry:
+-            setGeometry(m_deferredGeometry);
+-            break;
+-        case Task::SetWindowFlags:
+-            setWindowFlags(window()->flags());
+-            break;
+-        case Task::SetWindowState:
+-            setWindowState(window()->windowState());
+-            break;
+-        }
+-    }
+-    m_deferredTasks.clear();
+-
+-    if (map) {
+-        Q_ASSERT(unmap == false);
+-        show();
+-    }
+-    if (unmap) {
+-        Q_ASSERT(map == false);
+-        hide();
+-    }
+-}
+-
+ void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *event)
+ {
+     connection()->setTime(event->time);
+ 
+-    const bool wmStateChanged = event->atom == atom(QXcbAtom::WM_STATE);
+-    const bool netWmStateChanged = event->atom == atom(QXcbAtom::_NET_WM_STATE);
+-    if (netWmStateChanged || wmStateChanged) {
+-        if (wmStateChanged && !m_wmStateValid && m_isWmManagedWindow) {
+-            // ICCCM 4.1.4
+-            // Clients that want to re-use a client window (e.g. by mapping it again)
+-            // after withdrawing it must wait for the withdrawal to be complete before
+-            // proceeding. The preferred method for doing this is for clients to wait for
+-            // a window manager to update or remove the WM_STATE property.
+-            m_wmStateValid = true;
+-            handleDeferredTasks();
+-        }
+-        if (event->state == XCB_PROPERTY_DELETE)
++    const bool propertyDeleted = event->state == XCB_PROPERTY_DELETE;
++
++    if (event->atom == atom(QXcbAtom::_NET_WM_STATE) || event->atom == atom(QXcbAtom::WM_STATE)) {
++        if (propertyDeleted)
+             return;
+ 
+-        if (wmStateChanged) {
++        Qt::WindowStates newState = Qt::WindowNoState;
++
++        if (event->atom == atom(QXcbAtom::WM_STATE)) { // WM_STATE: Quick check for 'Minimize'.
+             auto reply = Q_XCB_REPLY(xcb_get_property, xcb_connection(),
+                                      0, m_window, atom(QXcbAtom::WM_STATE),
+                                      XCB_ATOM_ANY, 0, 1024);
+             if (reply && reply->format == 32 && reply->type == atom(QXcbAtom::WM_STATE)) {
+-                auto data = static_cast<const quint32 *>(xcb_get_property_value(reply.get()));
+-                if (reply->length != 0) {
+-                    const bool changedToWithdrawn = data[0] == XCB_ICCCM_WM_STATE_WITHDRAWN;
+-                    const bool changedToIconic = data[0] == XCB_ICCCM_WM_STATE_ICONIC;
+-                    m_minimized = changedToIconic || (changedToWithdrawn && m_minimized);
+-                }
++                const quint32 *data = (const quint32 *)xcb_get_property_value(reply.get());
++                if (reply->length != 0)
++                    m_minimized = (data[0] == XCB_ICCCM_WM_STATE_ICONIC
++                                   || (data[0] == XCB_ICCCM_WM_STATE_WITHDRAWN && m_minimized));
+             }
+         }
+ 
+-        // _NET_WM_STATE handling
+-        Qt::WindowStates newState = Qt::WindowNoState;
+         const NetWmStates states = netWmStates();
+         // _NET_WM_STATE_HIDDEN should be set by the Window Manager to indicate that a window would
+         // not be visible on the screen if its desktop/viewport were active and its coordinates were
+@@ -2325,6 +2239,7 @@ void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *ev
+             if ((m_windowState & Qt::WindowMinimized) && connection()->mouseGrabber() == this)
+                 connection()->setMouseGrabber(nullptr);
+         }
++        return;
+     } else if (event->atom == atom(QXcbAtom::_NET_FRAME_EXTENTS)) {
+         m_dirtyFrameMargins = true;
+     }
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbwindow.h b/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
+index 55af9279b1..6f5c1f5ed9 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
++++ b/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
+@@ -74,14 +74,6 @@ public:
+ 
+     Q_DECLARE_FLAGS(NetWmStates, NetWmState)
+ 
+-    enum Task {
+-        Map,
+-        Unmap,
+-        SetGeometry,
+-        SetWindowFlags,
+-        SetWindowState
+-    };
+-
+     QXcbWindow(QWindow *window);
+     ~QXcbWindow();
+ 
+@@ -151,9 +143,6 @@ public:
+ 
+     QXcbWindow *toWindow() override;
+ 
+-    bool shouldDeferTask(Task task);
+-    void handleDeferredTasks();
+-
+     void handleMouseEvent(xcb_timestamp_t time, const QPoint &local, const QPoint &global,
+                           Qt::KeyboardModifiers modifiers, QEvent::Type type, Qt::MouseEventSource source);
+ 
+@@ -292,11 +281,6 @@ protected:
+     int m_swapInterval = -1;
+ 
+     qreal m_sizeHintsScaleFactor = 1.0;
+-
+-    bool m_wmStateValid = true;
+-    QVector<Task> m_deferredTasks;
+-    bool m_isWmManagedWindow = true;
+-    QRect m_deferredGeometry;
+ };
+ 
+ class QXcbForeignWindow : public QXcbWindow
+diff --git a/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp b/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
+index d9d117faeb..640b49daa0 100644
+--- a/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
++++ b/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
+@@ -85,6 +85,7 @@ QGtk3MenuItem::QGtk3MenuItem()
+       m_checkable(false),
+       m_checked(false),
+       m_enabled(true),
++      m_exclusive(false),
+       m_underline(false),
+       m_invalid(true),
+       m_menu(nullptr),
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
+index 0048bbc1e6..396e7f6d1c 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
+@@ -102,15 +102,12 @@ const QDBusArgument &operator >>(const QDBusArgument &arg, QXdgDesktopPortalFile
+ class QXdgDesktopPortalFileDialogPrivate
+ {
+ public:
+-    QXdgDesktopPortalFileDialogPrivate(QPlatformFileDialogHelper *nativeFileDialog)
++    QXdgDesktopPortalFileDialogPrivate(QPlatformFileDialogHelper *nativeFileDialog, uint fileChooserPortalVersion)
+         : nativeFileDialog(nativeFileDialog)
++        , fileChooserPortalVersion(fileChooserPortalVersion)
+     { }
+ 
+-    WId winId = 0;
+-    bool directoryMode = false;
+-    bool modal = false;
+-    bool multipleFiles = false;
+-    bool saveFile = false;
++    QEventLoop loop;
+     QString acceptLabel;
+     QString directory;
+     QString title;
+@@ -121,19 +118,27 @@ public:
+     QString selectedMimeTypeFilter;
+     QString selectedNameFilter;
+     QStringList selectedFiles;
+-    QPlatformFileDialogHelper *nativeFileDialog = nullptr;
++    std::unique_ptr<QPlatformFileDialogHelper> nativeFileDialog;
++    uint fileChooserPortalVersion = 0;
++    bool failedToOpen = false;
++    bool directoryMode = false;
++    bool multipleFiles = false;
++    bool saveFile = false;
+ };
+ 
+-QXdgDesktopPortalFileDialog::QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog)
++QXdgDesktopPortalFileDialog::QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog, uint fileChooserPortalVersion)
+     : QPlatformFileDialogHelper()
+-    , d_ptr(new QXdgDesktopPortalFileDialogPrivate(nativeFileDialog))
++    , d_ptr(new QXdgDesktopPortalFileDialogPrivate(nativeFileDialog, fileChooserPortalVersion))
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+     if (d->nativeFileDialog) {
+-        connect(d->nativeFileDialog, SIGNAL(accept()), this, SIGNAL(accept()));
+-        connect(d->nativeFileDialog, SIGNAL(reject()), this, SIGNAL(reject()));
++        connect(d->nativeFileDialog.get(), SIGNAL(accept()), this, SIGNAL(accept()));
++        connect(d->nativeFileDialog.get(), SIGNAL(reject()), this, SIGNAL(reject()));
+     }
++
++    d->loop.connect(this, SIGNAL(accept()), SLOT(quit()));
++    d->loop.connect(this, SIGNAL(reject()), SLOT(quit()));
+ }
+ 
+ QXdgDesktopPortalFileDialog::~QXdgDesktopPortalFileDialog()
+@@ -177,7 +182,7 @@ void QXdgDesktopPortalFileDialog::initializeDialog()
+     setDirectory(options()->initialDirectory());
+ }
+ 
+-void QXdgDesktopPortalFileDialog::openPortal()
++void QXdgDesktopPortalFileDialog::openPortal(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent)
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+@@ -185,13 +190,13 @@ void QXdgDesktopPortalFileDialog::openPortal()
+                                                           QLatin1String("/org/freedesktop/portal/desktop"),
+                                                           QLatin1String("org.freedesktop.portal.FileChooser"),
+                                                           d->saveFile ? QLatin1String("SaveFile") : QLatin1String("OpenFile"));
+-    QString parentWindowId = QLatin1String("x11:") + QString::number(d->winId, 16);
++    QString parentWindowId = QLatin1String("x11:") + QString::number(parent ? parent->winId() : 0, 16);
+ 
+     QVariantMap options;
+     if (!d->acceptLabel.isEmpty())
+         options.insert(QLatin1String("accept_label"), d->acceptLabel);
+ 
+-    options.insert(QLatin1String("modal"), d->modal);
++    options.insert(QLatin1String("modal"), windowModality != Qt::NonModal);
+     options.insert(QLatin1String("multiple"), d->multipleFiles);
+     options.insert(QLatin1String("directory"), d->directoryMode);
+ 
+@@ -290,10 +295,18 @@ void QXdgDesktopPortalFileDialog::openPortal()
+ 
+     QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
+     QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingCall);
+-    connect(watcher, &QDBusPendingCallWatcher::finished, this, [this] (QDBusPendingCallWatcher *watcher) {
++    connect(watcher, &QDBusPendingCallWatcher::finished, this, [=] (QDBusPendingCallWatcher *watcher) {
+         QDBusPendingReply<QDBusObjectPath> reply = *watcher;
+-        if (reply.isError()) {
+-            Q_EMIT reject();
++        // Any error means the dialog is not shown and we need to fallback
++        d->failedToOpen = reply.isError();
++        if (d->failedToOpen) {
++            if (d->nativeFileDialog) {
++                d->nativeFileDialog->show(windowFlags, windowModality, parent);
++                if (d->loop.isRunning())
++                    d->nativeFileDialog->exec();
++            } else {
++                Q_EMIT reject();
++            }
+         } else {
+             QDBusConnection::sessionBus().connect(nullptr,
+                                                   reply.value().path(),
+@@ -302,6 +315,7 @@ void QXdgDesktopPortalFileDialog::openPortal()
+                                                   this,
+                                                   SLOT(gotResponse(uint,QVariantMap)));
+         }
++        watcher->deleteLater();
+     });
+ }
+ 
+@@ -326,7 +340,7 @@ QUrl QXdgDesktopPortalFileDialog::directory() const
+ {
+     Q_D(const QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog())
+         return d->nativeFileDialog->directory();
+ 
+     return d->directory;
+@@ -348,7 +362,7 @@ QList<QUrl> QXdgDesktopPortalFileDialog::selectedFiles() const
+ {
+     Q_D(const QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog())
+         return d->nativeFileDialog->selectedFiles();
+ 
+     QList<QUrl> files;
+@@ -403,16 +417,13 @@ void QXdgDesktopPortalFileDialog::exec()
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly)) {
++    if (d->nativeFileDialog && useNativeFileDialog()) {
+         d->nativeFileDialog->exec();
+         return;
+     }
+ 
+     // HACK we have to avoid returning until we emit that the dialog was accepted or rejected
+-    QEventLoop loop;
+-    loop.connect(this, SIGNAL(accept()), SLOT(quit()));
+-    loop.connect(this, SIGNAL(reject()), SLOT(quit()));
+-    loop.exec();
++    d->loop.exec();
+ }
+ 
+ void QXdgDesktopPortalFileDialog::hide()
+@@ -429,13 +440,10 @@ bool QXdgDesktopPortalFileDialog::show(Qt::WindowFlags windowFlags, Qt::WindowMo
+ 
+     initializeDialog();
+ 
+-    d->modal = windowModality != Qt::NonModal;
+-    d->winId = parent ? parent->winId() : 0;
+-
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog(OpenFallback))
+         return d->nativeFileDialog->show(windowFlags, windowModality, parent);
+ 
+-    openPortal();
++    openPortal(windowFlags, windowModality, parent);
+ 
+     return true;
+ }
+@@ -465,4 +473,21 @@ void QXdgDesktopPortalFileDialog::gotResponse(uint response, const QVariantMap &
+     }
+ }
+ 
++bool QXdgDesktopPortalFileDialog::useNativeFileDialog(QXdgDesktopPortalFileDialog::FallbackType fallbackType) const
++{
++    Q_D(const QXdgDesktopPortalFileDialog);
++
++    if (d->failedToOpen && fallbackType != OpenFallback)
++        return true;
++
++    if (d->fileChooserPortalVersion < 3) {
++        if (options()->fileMode() == QFileDialogOptions::Directory)
++            return true;
++        else if (options()->fileMode() == QFileDialogOptions::DirectoryOnly)
++            return true;
++    }
++
++    return false;
++}
++
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
+index 4f4de96ecf..65e22a5cf2 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
+@@ -51,6 +51,11 @@ class QXdgDesktopPortalFileDialog : public QPlatformFileDialogHelper
+     Q_OBJECT
+     Q_DECLARE_PRIVATE(QXdgDesktopPortalFileDialog)
+ public:
++    enum FallbackType {
++        GenericFallback,
++        OpenFallback
++    };
++
+     enum ConditionType : uint {
+         GlobalPattern = 0,
+         MimeType = 1
+@@ -69,7 +74,7 @@ public:
+     };
+     typedef QVector<Filter> FilterList;
+ 
+-    QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog = nullptr);
++    QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog = nullptr, uint fileChooserPortalVersion = 0);
+     ~QXdgDesktopPortalFileDialog();
+ 
+     bool defaultNameFilterDisables() const override;
+@@ -92,7 +97,8 @@ private Q_SLOTS:
+ 
+ private:
+     void initializeDialog();
+-    void openPortal();
++    void openPortal(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent);
++    bool useNativeFileDialog(FallbackType fallbackType = GenericFallback) const;
+ 
+     QScopedPointer<QXdgDesktopPortalFileDialogPrivate> d_ptr;
+ };
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
+index fb324afbd8..b809503122 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
+@@ -111,6 +111,7 @@ QXdgDesktopPortalTheme::QXdgDesktopPortalTheme()
+         if (reply.isValid()) {
+             d->fileChooserPortalVersion = reply.value().toUInt();
+         }
++        watcher->deleteLater();
+     });
+ }
+ 
+@@ -152,11 +153,12 @@ QPlatformDialogHelper* QXdgDesktopPortalTheme::createPlatformDialogHelper(Dialog
+ {
+     Q_D(const QXdgDesktopPortalTheme);
+ 
+-    if (type == FileDialog) {
++    if (type == FileDialog && d->fileChooserPortalVersion) {
+         // Older versions of FileChooser portal don't support opening directories, therefore we fallback
+         // to native file dialog opened inside the sandbox to open a directory.
+-        if (d->fileChooserPortalVersion < 3 && d->baseTheme->usePlatformNativeDialog(type))
+-            return new QXdgDesktopPortalFileDialog(static_cast<QPlatformFileDialogHelper*>(d->baseTheme->createPlatformDialogHelper(type)));
++        if (d->baseTheme->usePlatformNativeDialog(type))
++            return new QXdgDesktopPortalFileDialog(static_cast<QPlatformFileDialogHelper*>(d->baseTheme->createPlatformDialogHelper(type)),
++                                                   d->fileChooserPortalVersion);
+ 
+         return new QXdgDesktopPortalFileDialog;
+     }
+diff --git a/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp b/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
+index 43d5e119ad..1f9cbc4565 100644
+--- a/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
++++ b/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
+@@ -89,8 +89,10 @@ void QCupsPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &v
+         break;
+     case PPK_Duplex: {
+         QPrint::DuplexMode mode = QPrint::DuplexMode(value.toInt());
+-        if (mode != d->duplex && d->m_printDevice.supportedDuplexModes().contains(mode))
++        if (d->m_printDevice.supportedDuplexModes().contains(mode)) {
+             d->duplex = mode;
++            d->duplexRequestedExplicitly = true;
++        }
+         break;
+     }
+     case PPK_PrinterName:
+@@ -277,9 +279,12 @@ void QCupsPrintEnginePrivate::changePrinter(const QString &newPrinter)
+     m_printDevice.swap(printDevice);
+     printerName = m_printDevice.id();
+ 
+-    // Check if new printer supports current settings, otherwise us defaults
+-    if (duplex != QPrint::DuplexAuto && !m_printDevice.supportedDuplexModes().contains(duplex))
++    // in case a duplex value was explicitly set, check if new printer supports current value,
++    // otherwise use device default
++    if (!duplexRequestedExplicitly || !m_printDevice.supportedDuplexModes().contains(duplex)) {
+         duplex = m_printDevice.defaultDuplexMode();
++        duplexRequestedExplicitly = false;
++    }
+     QPrint::ColorMode colorMode = grayscale ? QPrint::GrayScale : QPrint::Color;
+     if (!m_printDevice.supportedColorModes().contains(colorMode))
+         grayscale = m_printDevice.defaultColorMode() == QPrint::GrayScale;
+diff --git a/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h b/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
+index c021b0c643..8f81fe478d 100644
+--- a/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
++++ b/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
+@@ -100,6 +100,7 @@ private:
+     QStringList cupsOptions;
+     QString cupsTempFile;
+     QPrint::DuplexMode duplex;
++    bool duplexRequestedExplicitly = false;
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp b/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
+index 67e7154fa6..40876152e5 100644
+--- a/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
++++ b/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
+@@ -817,7 +817,7 @@ bool QIBaseResultPrivate::writeArray(int column, const QList<QVariant> &list)
+     ba.resize(int(bufLen));
+ 
+     if (list.size() > arraySize) {
+-        error = QLatin1String("Array size missmatch: size of %1 is %2, size of provided list is %3");
++        error = QLatin1String("Array size mismatch: size of %1 is %2, size of provided list is %3");
+         error = error.arg(QLatin1String(sqlname)).arg(arraySize).arg(list.size());
+         q->setLastError(QSqlError(error, QLatin1String(""), QSqlError::StatementError));
+         return false;
+diff --git a/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp b/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
+index 7ca055eea2..6bc9d46755 100644
+--- a/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
++++ b/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
+@@ -223,7 +223,7 @@ public:
+     struct QMyField
+     {
+         char *outField = nullptr;
+-        MYSQL_FIELD *myField = nullptr;
++        const MYSQL_FIELD *myField = nullptr;
+         QMetaType::Type type = QMetaType::UnknownType;
+         my_bool nullIndicator = false;
+         ulong bufLength = 0ul;
+@@ -361,7 +361,7 @@ static bool qIsInteger(int t)
+ void QMYSQLResultPrivate::bindBlobs()
+ {
+     int i;
+-    MYSQL_FIELD *fieldInfo;
++    const MYSQL_FIELD *fieldInfo;
+     MYSQL_BIND *bind;
+ 
+     for(i = 0; i < fields.count(); ++i) {
+@@ -379,7 +379,6 @@ void QMYSQLResultPrivate::bindBlobs()
+ bool QMYSQLResultPrivate::bindInValues()
+ {
+     MYSQL_BIND *bind;
+-    char *field;
+     int i = 0;
+ 
+     if (!meta)
+@@ -392,35 +391,34 @@ bool QMYSQLResultPrivate::bindInValues()
+     inBinds = new MYSQL_BIND[fields.size()];
+     memset(inBinds, 0, fields.size() * sizeof(MYSQL_BIND));
+ 
+-    MYSQL_FIELD *fieldInfo;
++    const MYSQL_FIELD *fieldInfo;
+ 
+     while((fieldInfo = mysql_fetch_field(meta))) {
++        bind = &inBinds[i];
++
+         QMyField &f = fields[i];
+         f.myField = fieldInfo;
+-
++        bind->buffer_length = f.bufLength = fieldInfo->length + 1;
++        bind->buffer_type = fieldInfo->type;
+         f.type = qDecodeMYSQLType(fieldInfo->type, fieldInfo->flags);
+         if (qIsBlob(fieldInfo->type)) {
+             // the size of a blob-field is available as soon as we call
+             // mysql_stmt_store_result()
+             // after mysql_stmt_exec() in QMYSQLResult::exec()
+-            fieldInfo->length = 0;
++            bind->buffer_length = f.bufLength = 0;
+             hasBlobs = true;
+         } else if (qIsInteger(f.type)) {
+-            fieldInfo->length = 8;
++            bind->buffer_length = f.bufLength = 8;
+         } else {
+-            fieldInfo->type = MYSQL_TYPE_STRING;
++            bind->buffer_type = MYSQL_TYPE_STRING;
+         }
+-        bind = &inBinds[i];
+-        field = new char[fieldInfo->length + 1];
+-        memset(field, 0, fieldInfo->length + 1);
+ 
+-        bind->buffer_type = fieldInfo->type;
+-        bind->buffer = field;
+-        bind->buffer_length = f.bufLength = fieldInfo->length + 1;
+         bind->is_null = &f.nullIndicator;
+         bind->length = &f.bufLength;
+         bind->is_unsigned = fieldInfo->flags & UNSIGNED_FLAG ? 1 : 0;
+-        f.outField=field;
++
++        char *field = new char[bind->buffer_length + 1]{};
++        bind->buffer = f.outField = field;
+ 
+         ++i;
+     }
+@@ -1369,20 +1367,20 @@ bool QMYSQLDriver::open(const QString& db,
+     }
+ 
+ #if MYSQL_VERSION_ID >= 50007
+-    if (mysql_get_client_version() >= 50503 && mysql_get_server_version(d->mysql) >= 50503) {
+-        // force the communication to be utf8mb4 (only utf8mb4 supports 4-byte characters)
+-        mysql_set_character_set(d->mysql, "utf8mb4");
++    // force the communication to be utf8mb4 (only utf8mb4 supports 4-byte characters)
++    if (mysql_set_character_set(d->mysql, "utf8mb4")) {
++        // this failed, try forcing it to utf (BMP only)
++        if (mysql_set_character_set(d->mysql, "utf8"))
++            qWarning() << "MySQL: Unable to set the client character set to utf8.";
+ #if QT_CONFIG(textcodec)
+-        d->tc = QTextCodec::codecForName("UTF-8");
++        else
++            d->tc = codec(d->mysql);
+ #endif
+-    } else
+-    {
+-        // force the communication to be utf8
+-        mysql_set_character_set(d->mysql, "utf8");
++    }
+ #if QT_CONFIG(textcodec)
+-        d->tc = codec(d->mysql);
++    else
++        d->tc = QTextCodec::codecForName("UTF-8");
+ #endif
+-    }
+ #endif  // MYSQL_VERSION_ID >= 50007
+ 
+     d->preparedQuerysEnabled = checkPreparedQueries(d->mysql);
+diff --git a/qtbase/src/printsupport/dialogs/images/print-24.png b/qtbase/src/printsupport/dialogs/images/printer-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/print-24.png
+rename to src/printsupport/dialogs/images/printer-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/print-32.png b/qtbase/src/printsupport/dialogs/images/printer-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/print-32.png
+rename to src/printsupport/dialogs/images/printer-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-sided-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-facing-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-sided-24.png
+rename to src/printsupport/dialogs/images/view-pages-facing-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-sided-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-facing-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-sided-32.png
+rename to src/printsupport/dialogs/images/view-pages-facing-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-multi-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-overview-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-multi-24.png
+rename to src/printsupport/dialogs/images/view-pages-overview-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-multi-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-overview-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-multi-32.png
+rename to src/printsupport/dialogs/images/view-pages-overview-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-one-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-single-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-one-24.png
+rename to src/printsupport/dialogs/images/view-pages-single-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-one-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-single-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-one-32.png
+rename to src/printsupport/dialogs/images/view-pages-single-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-page-24.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-page-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-page-24.png
+rename to src/printsupport/dialogs/images/zoom-fit-page-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-page-32.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-page-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-page-32.png
+rename to src/printsupport/dialogs/images/zoom-fit-page-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-width-24.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-width-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-width-24.png
+rename to src/printsupport/dialogs/images/zoom-fit-width-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-width-32.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-width-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-width-32.png
+rename to src/printsupport/dialogs/images/zoom-fit-width-32.png
+diff --git a/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp b/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
+index 78e5b8d1ef..2a28516719 100644
+--- a/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
++++ b/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
+@@ -532,6 +532,7 @@ void QPageSetupWidget::updateWidget()
+ void QPageSetupWidget::setupPrinter() const
+ {
+     m_printer->setPageLayout(m_pageLayout);
++    m_printer->setPageOrientation(m_pageLayout.orientation());
+ #if QT_CONFIG(cups)
+     QCUPSSupport::PagesPerSheet pagesPerSheet = qvariant_cast<QCUPSSupport::PagesPerSheet>(m_ui.pagesPerSheetCombo->currentData()
+ );
+diff --git a/qtbase/src/printsupport/dialogs/qprintdialog.qrc b/qtbase/src/printsupport/dialogs/qprintdialog.qrc
+index 5a579baa55..10b8e1d341 100644
+--- a/qtbase/src/printsupport/dialogs/qprintdialog.qrc
++++ b/qtbase/src/printsupport/dialogs/qprintdialog.qrc
+@@ -1,9 +1,9 @@
+ <!DOCTYPE RCC><RCC version="1.0">
+ <qresource prefix="/qt-project.org/dialogs/qprintpreviewdialog">
+-<file>images/fit-page-24.png</file>
+-<file>images/fit-page-32.png</file>
+-<file>images/fit-width-24.png</file>
+-<file>images/fit-width-32.png</file>
++<file>images/zoom-fit-page-24.png</file>
++<file>images/zoom-fit-page-32.png</file>
++<file>images/zoom-fit-width-24.png</file>
++<file>images/zoom-fit-width-32.png</file>
+ <file>images/go-first-24.png</file>
+ <file>images/go-first-32.png</file>
+ <file>images/go-last-24.png</file>
+@@ -18,14 +18,14 @@
+ <file>images/layout-portrait-32.png</file>
+ <file>images/page-setup-24.png</file>
+ <file>images/page-setup-32.png</file>
+-<file>images/print-24.png</file>
+-<file>images/print-32.png</file>
+-<file>images/view-page-multi-24.png</file>
+-<file>images/view-page-multi-32.png</file>
+-<file>images/view-page-one-24.png</file>
+-<file>images/view-page-one-32.png</file>
+-<file>images/view-page-sided-24.png</file>
+-<file>images/view-page-sided-32.png</file>
++<file>images/printer-24.png</file>
++<file>images/printer-32.png</file>
++<file>images/view-pages-overview-24.png</file>
++<file>images/view-pages-overview-32.png</file>
++<file>images/view-pages-single-24.png</file>
++<file>images/view-pages-single-32.png</file>
++<file>images/view-pages-facing-24.png</file>
++<file>images/view-pages-facing-32.png</file>
+ <file>images/zoom-in-24.png</file>
+ <file>images/zoom-in-32.png</file>
+ <file>images/zoom-out-24.png</file>
+diff --git a/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp b/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
+index c5b845f4ec..5a5ba1d0a8 100644
+--- a/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
++++ b/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
+@@ -702,13 +702,14 @@ void QPrintDialogPrivate::selectPrinter(const QPrinter::OutputFormat outputForma
+         else
+             options.grayscale->setChecked(true);
+ 
+-        // keep duplex value explicitly set by user, if any, and selected printer supports it;
+-        // use device default otherwise
++        // duplex priorities to be as follows:
++        // 1) a user-selected duplex value in the dialog has highest prority
++        // 2) duplex value set in the QPrinter
+         QPrint::DuplexMode duplex;
+         if (explicitDuplexMode != QPrint::DuplexAuto && supportedDuplexMode.contains(explicitDuplexMode))
+             duplex = explicitDuplexMode;
+         else
+-            duplex = top->d->m_currentPrintDevice.defaultDuplexMode();
++            duplex = static_cast<QPrint::DuplexMode>(p->duplex());
+         switch (duplex) {
+         case QPrint::DuplexNone:
+             options.noDuplex->setChecked(true); break;
+@@ -1242,10 +1243,10 @@ void QUnixPrintWidgetPrivate::_q_printerChanged(int index)
+             QString filename = widget.filename->text();
+             widget.filename->setText(filename);
+             widget.lOutput->setEnabled(true);
+-            if (optionsPane)
+-                optionsPane->selectPrinter(QPrinter::PdfFormat);
+             printer->setOutputFormat(QPrinter::PdfFormat);
+             m_currentPrintDevice = QPrintDevice();
++            if (optionsPane)
++                optionsPane->selectPrinter(QPrinter::PdfFormat);
+             return;
+         }
+     }
+diff --git a/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp b/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
+index 39575d5f57..23b7e89538 100644
+--- a/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
++++ b/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
+@@ -352,7 +352,7 @@ void QPrintPreviewDialogPrivate::init(QPrinter *_printer)
+ static inline void qt_setupActionIcon(QAction *action, QLatin1String name)
+ {
+     QLatin1String imagePrefix(":/qt-project.org/dialogs/qprintpreviewdialog/images/");
+-    QIcon icon;
++    QIcon icon = QIcon::fromTheme(name);
+     icon.addFile(imagePrefix + name + QLatin1String("-24.png"), QSize(24, 24));
+     icon.addFile(imagePrefix + name + QLatin1String("-32.png"), QSize(32, 32));
+     action->setIcon(icon);
+@@ -383,8 +383,8 @@ void QPrintPreviewDialogPrivate::setupActions()
+     fitPageAction->setObjectName(QLatin1String("fitPageAction"));
+     fitWidthAction->setCheckable(true);
+     fitPageAction->setCheckable(true);
+-    qt_setupActionIcon(fitWidthAction, QLatin1String("fit-width"));
+-    qt_setupActionIcon(fitPageAction, QLatin1String("fit-page"));
++    qt_setupActionIcon(fitWidthAction, QLatin1String("zoom-fit-width"));
++    qt_setupActionIcon(fitPageAction, QLatin1String("zoom-fit-page"));
+     QObject::connect(fitGroup, SIGNAL(triggered(QAction*)), q, SLOT(_q_fit(QAction*)));
+ 
+     // Zoom
+@@ -410,9 +410,9 @@ void QPrintPreviewDialogPrivate::setupActions()
+     singleModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show single page"));
+     facingModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show facing pages"));
+     overviewModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show overview of all pages"));
+-    qt_setupActionIcon(singleModeAction, QLatin1String("view-page-one"));
+-    qt_setupActionIcon(facingModeAction, QLatin1String("view-page-sided"));
+-    qt_setupActionIcon(overviewModeAction, QLatin1String("view-page-multi"));
++    qt_setupActionIcon(singleModeAction, QLatin1String("view-pages-single"));
++    qt_setupActionIcon(facingModeAction, QLatin1String("view-pages-facing"));
++    qt_setupActionIcon(overviewModeAction, QLatin1String("view-pages-overview"));
+     singleModeAction->setObjectName(QLatin1String("singleModeAction"));
+     facingModeAction->setObjectName(QLatin1String("facingModeAction"));
+     overviewModeAction->setObjectName(QLatin1String("overviewModeAction"));
+@@ -426,7 +426,7 @@ void QPrintPreviewDialogPrivate::setupActions()
+     printerGroup = new QActionGroup(q);
+     printAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Print"));
+     pageSetupAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Page setup"));
+-    qt_setupActionIcon(printAction, QLatin1String("print"));
++    qt_setupActionIcon(printAction, QLatin1String("printer"));
+     qt_setupActionIcon(pageSetupAction, QLatin1String("page-setup"));
+     QObject::connect(printAction, SIGNAL(triggered(bool)), q, SLOT(_q_print()));
+     QObject::connect(pageSetupAction, SIGNAL(triggered(bool)), q, SLOT(_q_pageSetup()));
+diff --git a/qtbase/src/sql/kernel/qsqlquery.cpp b/qtbase/src/sql/kernel/qsqlquery.cpp
+index 32c6166c79..60afef10c3 100644
+--- a/qtbase/src/sql/kernel/qsqlquery.cpp
++++ b/qtbase/src/sql/kernel/qsqlquery.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2022 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtSql module of the Qt Toolkit.
+@@ -377,6 +377,10 @@ bool QSqlQuery::exec(const QString& query)
+     QElapsedTimer t;
+     t.start();
+ #endif
++    if (!driver()) {
++        qWarning("QSqlQuery::exec: called before driver has been set up");
++        return false;
++    }
+     if (d->ref.loadRelaxed() != 1) {
+         bool fo = isForwardOnly();
+         *this = QSqlQuery(driver()->createResult());
+diff --git a/qtbase/src/testlib/qabstractitemmodeltester.cpp b/qtbase/src/testlib/qabstractitemmodeltester.cpp
+index 8efb9c53d4..ce062f66d7 100644
+--- a/qtbase/src/testlib/qabstractitemmodeltester.cpp
++++ b/qtbase/src/testlib/qabstractitemmodeltester.cpp
+@@ -454,7 +454,7 @@ void QAbstractItemModelTesterPrivate::parent()
+ 
+     // Common error test #2, make sure that a second level index has a parent
+     // that is the first level index.
+-    if (model->rowCount(topIndex) > 0) {
++    if (model->rowCount(topIndex) > 0 && model->columnCount(topIndex) > 0) {
+         QModelIndex childIndex = model->index(0, 0, topIndex);
+         MODELTESTER_VERIFY(childIndex.isValid());
+         MODELTESTER_COMPARE(model->parent(childIndex), topIndex);
+diff --git a/qtbase/src/testlib/qasciikey.cpp b/qtbase/src/testlib/qasciikey.cpp
+index 9a308da2bc..93498b256f 100644
+--- a/qtbase/src/testlib/qasciikey.cpp
++++ b/qtbase/src/testlib/qasciikey.cpp
+@@ -498,6 +498,11 @@ char QTest::keyToAscii(Qt::Key key)
+     case Qt::Key_LaunchE : return 0; // = 0x10b0,
+     case Qt::Key_LaunchF : return 0; // = 0x10b1,
+ 
++    // Keypad navigation keys
++    case Qt::Key_Select : return 0; // = 0x01010000
++    case Qt::Key_Yes : return 0; // = 0x01010001
++    case Qt::Key_No : return 0; // = 0x01010002
++
+     default: QTEST_ASSERT(false); return 0;
+     }
+ }
+diff --git a/qtbase/src/testlib/qtestresult.cpp b/qtbase/src/testlib/qtestresult.cpp
+index 88028aac6e..2e89930776 100644
+--- a/qtbase/src/testlib/qtestresult.cpp
++++ b/qtbase/src/testlib/qtestresult.cpp
+@@ -251,7 +251,8 @@ bool QTestResult::verify(bool statement, const char *statementStr,
+ {
+     QTEST_ASSERT(statementStr);
+ 
+-    char msg[1024] = {'\0'};
++    char msg[1024];
++    msg[0] = '\0';
+ 
+     if (QTestLog::verboseLevel() >= 2) {
+         qsnprintf(msg, 1024, "QVERIFY(%s)", statementStr);
+@@ -309,7 +310,8 @@ static bool compareHelper(bool success, const char *failureMsg,
+                           bool hasValues = true)
+ {
+     const size_t maxMsgLen = 1024;
+-    char msg[maxMsgLen] = {'\0'};
++    char msg[maxMsgLen];
++    msg[0] = '\0';
+ 
+     QTEST_ASSERT(expected);
+     QTEST_ASSERT(actual);
+diff --git a/qtbase/src/widgets/dialogs/qcolordialog.cpp b/qtbase/src/widgets/dialogs/qcolordialog.cpp
+index 4247731275..cb325be85c 100644
+--- a/qtbase/src/widgets/dialogs/qcolordialog.cpp
++++ b/qtbase/src/widgets/dialogs/qcolordialog.cpp
+@@ -78,7 +78,10 @@
+ #include "qwindow.h"
+ 
+ #include "private/qdialog_p.h"
++#include "private/qguiapplication_p.h"
+ 
++#include <qpa/qplatformservices.h>
++#include <qpa/qplatformintegration.h>
+ #include <algorithm>
+ 
+ QT_BEGIN_NAMESPACE
+@@ -1611,6 +1614,20 @@ void QColorDialogPrivate::_q_newStandard(int r, int c)
+ void QColorDialogPrivate::_q_pickScreenColor()
+ {
+     Q_Q(QColorDialog);
++
++    auto *platformServices = QGuiApplicationPrivate::platformIntegration()->services();
++    if (platformServices->hasCapability(QPlatformServices::Capability::ColorPicking)) {
++        if (auto *colorPicker = platformServices->colorPicker(q->windowHandle())) {
++            q->connect(colorPicker, &QPlatformServiceColorPicker::colorPicked, q,
++                       [q, colorPicker](const QColor &color) {
++                           colorPicker->deleteLater();
++                           q->setCurrentColor(color);
++                       });
++            colorPicker->pickColor();
++            return;
++        }
++    }
++
+     if (!colorPickingEventFilter)
+         colorPickingEventFilter = new QColorPickingEventFilter(this, q);
+     q->installEventFilter(colorPickingEventFilter);
+diff --git a/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp b/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
+index e120817edc..8ea36b5427 100644
+--- a/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
++++ b/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
+@@ -400,12 +400,7 @@ bool QAbstractItemDelegate::helpEvent(QHelpEvent *event,
+         const QString tooltip = index.isValid() ?
+               d->textForRole(Qt::ToolTipRole, index.data(Qt::ToolTipRole), option.locale, precision) :
+               QString();
+-        QRect rect;
+-        if (index.isValid()) {
+-            const QRect r = view->visualRect(index);
+-            rect = QRect(view->mapToGlobal(r.topLeft()), r.size());
+-        }
+-        QToolTip::showText(he->globalPos(), tooltip, view, rect);
++        QToolTip::showText(he->globalPos(), tooltip, view->viewport(), option.rect);
+         event->setAccepted(!tooltip.isEmpty());
+         break;
+         }
+diff --git a/qtbase/src/widgets/itemviews/qlistview.cpp b/qtbase/src/widgets/itemviews/qlistview.cpp
+index 2b34476642..eebfaa030e 100644
+--- a/qtbase/src/widgets/itemviews/qlistview.cpp
++++ b/qtbase/src/widgets/itemviews/qlistview.cpp
+@@ -3386,6 +3386,7 @@ void QIconModeViewBase::updateContentsSize()
+ */
+ void QListView::currentChanged(const QModelIndex &current, const QModelIndex &previous)
+ {
++    QAbstractItemView::currentChanged(current, previous);
+ #ifndef QT_NO_ACCESSIBILITY
+     if (QAccessible::isActive()) {
+         if (current.isValid()) {
+@@ -3396,7 +3397,6 @@ void QListView::currentChanged(const QModelIndex &current, const QModelIndex &pr
+         }
+     }
+ #endif
+-    QAbstractItemView::currentChanged(current, previous);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/widgets/itemviews/qtableview.cpp b/qtbase/src/widgets/itemviews/qtableview.cpp
+index 934ac581b2..f79bb24249 100644
+--- a/qtbase/src/widgets/itemviews/qtableview.cpp
++++ b/qtbase/src/widgets/itemviews/qtableview.cpp
+@@ -1013,6 +1013,7 @@ void QTableViewPrivate::drawCell(QPainter *painter, const QStyleOptionViewItem &
+ int QTableViewPrivate::widthHintForIndex(const QModelIndex &index, int hint, const QStyleOptionViewItem &option) const
+ {
+     Q_Q(const QTableView);
++    const int oldHint = hint;
+     QWidget *editor = editorForIndex(index).widget.data();
+     if (editor && persistent.contains(editor)) {
+         hint = qMax(hint, editor->sizeHint().width());
+@@ -1021,6 +1022,17 @@ int QTableViewPrivate::widthHintForIndex(const QModelIndex &index, int hint, con
+         hint = qBound(min, hint, max);
+     }
+     hint = qMax(hint, q->itemDelegate(index)->sizeHint(option, index).width());
++
++    if (hasSpans()) {
++        auto span = spans.spanAt(index.column(), index.row());
++        if (span && span->m_left == index.column() && span->m_top == index.row()) {
++            // spans are screwed up when sections are moved
++            const auto left = logicalColumn(span->m_left);
++            for (int i = 1; i <= span->width(); ++i)
++               hint -= q->columnWidth(visualColumn(left + i));
++        }
++        hint = std::max(hint, oldHint);
++    }
+     return hint;
+ }
+ 
+@@ -1053,6 +1065,11 @@ int QTableViewPrivate::heightHintForIndex(const QModelIndex &index, int hint, QS
+         option.rect.setHeight(height);
+         option.rect.setX(q->columnViewportPosition(index.column()));
+         option.rect.setWidth(q->columnWidth(index.column()));
++        if (hasSpans()) {
++            auto span = spans.spanAt(index.column(), index.row());
++            if (span && span->m_left == index.column() && span->m_top == index.row())
++                option.rect.setWidth(std::max(option.rect.width(), visualSpanRect(*span).width()));
++        }
+         // 1px less space when grid is shown (see drawCell)
+         if (showGrid)
+             option.rect.setWidth(option.rect.width() - 1);
+diff --git a/qtbase/src/widgets/kernel/qaction.h b/qtbase/src/widgets/kernel/qaction.h
+index 258a1ea0a0..737c1e8285 100644
+--- a/qtbase/src/widgets/kernel/qaction.h
++++ b/qtbase/src/widgets/kernel/qaction.h
+@@ -81,7 +81,7 @@ class Q_WIDGETS_EXPORT QAction : public QObject
+     Q_PROPERTY(MenuRole menuRole READ menuRole WRITE setMenuRole NOTIFY changed)
+     Q_PROPERTY(bool iconVisibleInMenu READ isIconVisibleInMenu WRITE setIconVisibleInMenu NOTIFY changed)
+     Q_PROPERTY(bool shortcutVisibleInContextMenu READ isShortcutVisibleInContextMenu WRITE setShortcutVisibleInContextMenu NOTIFY changed)
+-    Q_PROPERTY(Priority priority READ priority WRITE setPriority)
++    Q_PROPERTY(Priority priority READ priority WRITE setPriority NOTIFY changed)
+ 
+ public:
+     // note this is copied into qplatformmenu.h, which must stay in sync
+diff --git a/qtbase/src/widgets/kernel/qwidget.cpp b/qtbase/src/widgets/kernel/qwidget.cpp
+index 9eba1e001e..26f6d27e18 100644
+--- a/qtbase/src/widgets/kernel/qwidget.cpp
++++ b/qtbase/src/widgets/kernel/qwidget.cpp
+@@ -5296,7 +5296,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
+         QWidgetEffectSourcePrivate *sourced = static_cast<QWidgetEffectSourcePrivate *>
+                                                          (source->d_func());
+         if (!sourced->context) {
+-            const QRegion effectRgn(rgn.boundingRect());
++            const QRegion effectRgn((flags & UseEffectRegionBounds) ? rgn.boundingRect() : rgn);
+             QWidgetPaintContext context(pdev, effectRgn, offset, flags, sharedPainter, repaintManager);
+             sourced->context = &context;
+             if (!sharedPainter) {
+@@ -5328,6 +5328,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
+         }
+     }
+ #endif // QT_CONFIG(graphicseffect)
++    flags = flags & ~UseEffectRegionBounds;
+ 
+     const bool alsoOnScreen = flags & DrawPaintOnScreen;
+     const bool recursive = flags & DrawRecursive;
+diff --git a/qtbase/src/widgets/kernel/qwidget_p.h b/qtbase/src/widgets/kernel/qwidget_p.h
+index eef6b8fa2c..c432f4b5d5 100644
+--- a/qtbase/src/widgets/kernel/qwidget_p.h
++++ b/qtbase/src/widgets/kernel/qwidget_p.h
+@@ -229,7 +229,8 @@ public:
+         DontSubtractOpaqueChildren = 0x10,
+         DontDrawOpaqueChildren = 0x20,
+         DontDrawNativeChildren = 0x40,
+-        DontSetCompositionMode = 0x80
++        DontSetCompositionMode = 0x80,
++        UseEffectRegionBounds = 0x100
+     };
+     Q_DECLARE_FLAGS(DrawWidgetFlags, DrawWidgetFlag)
+     Q_FLAG(DrawWidgetFlags)
+diff --git a/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp b/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
+index 02880b34da..0d44e1326d 100644
+--- a/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
++++ b/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
+@@ -1018,7 +1018,8 @@ void QWidgetRepaintManager::paintAndFlush()
+ 
+     // Paint the rest with composition.
+     if (repaintAllWidgets || !dirtyCopy.isEmpty()) {
+-        QWidgetPrivate::DrawWidgetFlags flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive;
++        QWidgetPrivate::DrawWidgetFlags flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive
++                | QWidgetPrivate::UseEffectRegionBounds;
+         tlw->d_func()->drawWidget(store->paintDevice(), dirtyCopy, QPoint(), flags, nullptr, this);
+     }
+ 
+diff --git a/qtbase/src/widgets/styles/qfusionstyle.cpp b/qtbase/src/widgets/styles/qfusionstyle.cpp
+index f4345d97c4..962912c838 100644
+--- a/qtbase/src/widgets/styles/qfusionstyle.cpp
++++ b/qtbase/src/widgets/styles/qfusionstyle.cpp
+@@ -1772,14 +1772,6 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio
+             proxy()->drawControl(CE_PushButtonLabel, &subopt, painter, widget);
+         }
+         break;
+-    case CE_PushButtonLabel:
+-        if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
+-            QStyleOptionButton b(*button);
+-            // no PM_ButtonShiftHorizontal and PM_ButtonShiftVertical for fusion style
+-            b.state &= ~(State_On | State_Sunken);
+-            QCommonStyle::drawControl(element, &b, painter, widget);
+-        }
+-        break;
+     case CE_MenuBarEmptyArea:
+         painter->save();
+     {
+diff --git a/qtbase/src/widgets/util/qcompleter.cpp b/qtbase/src/widgets/util/qcompleter.cpp
+index 18b24063d8..ef7207a8a3 100644
+--- a/qtbase/src/widgets/util/qcompleter.cpp
++++ b/qtbase/src/widgets/util/qcompleter.cpp
+@@ -1120,6 +1120,8 @@ void QCompleter::setModel(QAbstractItemModel *model)
+ {
+     Q_D(QCompleter);
+     QAbstractItemModel *oldModel = d->proxy->sourceModel();
++    if (oldModel == model)
++        return;
+ #if QT_CONFIG(filesystemmodel)
+     if (qobject_cast<const QFileSystemModel *>(oldModel))
+         setCompletionRole(Qt::EditRole); // QTBUG-54642, clear FileNameRole set by QFileSystemModel
+diff --git a/qtbase/src/widgets/widgets/qabstractbutton.cpp b/qtbase/src/widgets/widgets/qabstractbutton.cpp
+index a128b23950..dc40bf62fb 100644
+--- a/qtbase/src/widgets/widgets/qabstractbutton.cpp
++++ b/qtbase/src/widgets/widgets/qabstractbutton.cpp
+@@ -56,6 +56,7 @@
+ #ifndef QT_NO_ACCESSIBILITY
+ #include "qaccessible.h"
+ #endif
++#include <qpa/qplatformtheme.h>
+ 
+ #include <algorithm>
+ 
+@@ -1076,19 +1077,19 @@ void QAbstractButton::keyPressEvent(QKeyEvent *e)
+ {
+     Q_D(QAbstractButton);
+     bool next = true;
+-    switch (e->key()) {
+-    case Qt::Key_Enter:
+-    case Qt::Key_Return:
+-        e->ignore();
+-        break;
+-    case Qt::Key_Select:
+-    case Qt::Key_Space:
+-        if (!e->isAutoRepeat()) {
+-            setDown(true);
+-            repaint();
+-            d->emitPressed();
+-        }
+-        break;
++
++    const auto key = static_cast<Qt::Key>(e->key());
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(key) && !e->isAutoRepeat()) {
++        setDown(true);
++        repaint();
++        d->emitPressed();
++        return;
++    }
++
++    switch (key) {
+     case Qt::Key_Up:
+         next = false;
+         Q_FALLTHROUGH();
+@@ -1153,15 +1154,15 @@ void QAbstractButton::keyReleaseEvent(QKeyEvent *e)
+     if (!e->isAutoRepeat())
+         d->repeatTimer.stop();
+ 
+-    switch (e->key()) {
+-    case Qt::Key_Select:
+-    case Qt::Key_Space:
+-        if (!e->isAutoRepeat() && d->down)
+-            d->click();
+-        break;
+-    default:
+-        e->ignore();
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(static_cast<Qt::Key>(e->key())) && !e->isAutoRepeat() && d->down) {
++        d->click();
++        return;
+     }
++
++    e->ignore();
+ }
+ 
+ /*!\reimp
+diff --git a/qtbase/src/widgets/widgets/qcombobox.cpp b/qtbase/src/widgets/widgets/qcombobox.cpp
+index 7a496c27e0..0a3d96647b 100644
+--- a/qtbase/src/widgets/widgets/qcombobox.cpp
++++ b/qtbase/src/widgets/widgets/qcombobox.cpp
+@@ -3352,7 +3352,23 @@ void QComboBox::keyPressEvent(QKeyEvent *e)
+ 
+     Move move = NoMove;
+     int newIndex = currentIndex();
+-    switch (e->key()) {
++
++    bool pressLikeButton = !d->lineEdit;
++#ifdef QT_KEYPAD_NAVIGATION
++    pressLikeButton |= QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus();
++#endif
++    auto key = static_cast<Qt::Key>(e->key());
++    if (pressLikeButton) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(key)) {
++            showPopup();
++            return;
++        }
++    }
++
++    switch (key) {
+     case Qt::Key_Up:
+         if (e->modifiers() & Qt::ControlModifier)
+             break; // pass to line edit for auto completion
+@@ -3394,26 +3410,11 @@ void QComboBox::keyPressEvent(QKeyEvent *e)
+             return;
+         }
+         break;
+-    case Qt::Key_Space:
+-        if (!d->lineEdit) {
+-            showPopup();
+-            return;
+-        }
+-        break;
+-    case Qt::Key_Enter:
+-    case Qt::Key_Return:
+     case Qt::Key_Escape:
+         if (!d->lineEdit)
+             e->ignore();
+         break;
+ #ifdef QT_KEYPAD_NAVIGATION
+-    case Qt::Key_Select:
+-        if (QApplicationPrivate::keypadNavigationEnabled()
+-                && (!hasEditFocus() || !d->lineEdit)) {
+-            showPopup();
+-            return;
+-        }
+-        break;
+     case Qt::Key_Left:
+     case Qt::Key_Right:
+         if (QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus())
+diff --git a/qtbase/src/widgets/widgets/qdatetimeedit_p.h b/qtbase/src/widgets/widgets/qdatetimeedit_p.h
+index d36b6f8f9a..e0df5b5158 100644
+--- a/qtbase/src/widgets/widgets/qdatetimeedit_p.h
++++ b/qtbase/src/widgets/widgets/qdatetimeedit_p.h
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2018 The Qt Company Ltd.
++** Copyright (C) 2021 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtWidgets module of the Qt Toolkit.
+diff --git a/qtbase/src/widgets/widgets/qgroupbox.cpp b/qtbase/src/widgets/widgets/qgroupbox.cpp
+index 02a0bed325..3f3eccc370 100644
+--- a/qtbase/src/widgets/widgets/qgroupbox.cpp
++++ b/qtbase/src/widgets/widgets/qgroupbox.cpp
+@@ -54,6 +54,8 @@
+ #include "qaccessible.h"
+ #endif
+ #include <private/qwidget_p.h>
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
+ 
+ #include "qdebug.h"
+ 
+@@ -360,7 +362,10 @@ bool QGroupBox::event(QEvent *e)
+         return true;
+     case QEvent::KeyPress: {
+         QKeyEvent *k = static_cast<QKeyEvent*>(e);
+-        if (!k->isAutoRepeat() && (k->key() == Qt::Key_Select || k->key() == Qt::Key_Space)) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (!k->isAutoRepeat() && buttonPressKeys.contains(static_cast<Qt::Key>(k->key()))) {
+             d->pressedControl = QStyle::SC_GroupBoxCheckBox;
+             update(style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxCheckBox, this));
+             return true;
+@@ -369,7 +374,10 @@ bool QGroupBox::event(QEvent *e)
+     }
+     case QEvent::KeyRelease: {
+         QKeyEvent *k = static_cast<QKeyEvent*>(e);
+-        if (!k->isAutoRepeat() && (k->key() == Qt::Key_Select || k->key() == Qt::Key_Space)) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (!k->isAutoRepeat() && buttonPressKeys.contains(static_cast<Qt::Key>(k->key()))) {
+             bool toggle = (d->pressedControl == QStyle::SC_GroupBoxLabel
+                            || d->pressedControl == QStyle::SC_GroupBoxCheckBox);
+             d->pressedControl = QStyle::SC_None;
+diff --git a/qtbase/src/widgets/widgets/qlabel.cpp b/qtbase/src/widgets/widgets/qlabel.cpp
+index 30ff80cbb0..cf2605c17c 100644
+--- a/qtbase/src/widgets/widgets/qlabel.cpp
++++ b/qtbase/src/widgets/widgets/qlabel.cpp
+@@ -421,9 +421,6 @@ void QLabel::setPixmap(const QPixmap &pixmap)
+         d->pixmap = new QPixmap(pixmap);
+     }
+ 
+-    if (d->pixmap->depth() == 1 && !d->pixmap->mask())
+-        d->pixmap->setMask(*((QBitmap *)d->pixmap));
+-
+     d->updateLabel();
+ }
+ 
+diff --git a/qtbase/src/widgets/widgets/qtoolbararealayout.cpp b/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
+index 493c094cc1..d5f4b59017 100644
+--- a/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
++++ b/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
+@@ -1367,7 +1367,7 @@ bool QToolBarAreaLayout::restoreState(QDataStream &stream, const QList<QToolBar*
+                 item.widgetItem = new QWidgetItemV2(toolBar);
+                 toolBar->setOrientation(floating ? ((shown & 2) ? Qt::Vertical : Qt::Horizontal) : dock.o);
+                 toolBar->setVisible(shown & 1);
+-                toolBar->d_func()->setWindowState(floating, true, rect);
++                toolBar->d_func()->setWindowState(floating, false, rect);
+ 
+                 item.preferredSize = item.size;
+                 line.toolBarItems.append(item);
+diff --git a/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp b/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
+index 212c0a2e13..3c77b1ba0b 100644
+--- a/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
++++ b/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
+@@ -126,8 +126,7 @@ public:
+ 
+ void tst_QtConcurrentIterateKernel::instantiate()
+ {
+-    auto future = startThreadEngine(new PrintFor(0, 40)).startAsynchronously();
+-    future.waitForFinished();
++    startThreadEngine(new PrintFor(0, 40)).startBlocking();
+     QCOMPARE(iterations.loadRelaxed(), 40);
+ }
+ 
+@@ -166,10 +165,8 @@ void tst_QtConcurrentIterateKernel::stresstest()
+     const int times = 50;
+     for (int i = 0; i < times; ++i) {
+         counter.storeRelaxed(0);
+-        // ThreadEngine will delete f when it finishes
+-        auto f = new CountFor(0, iterations);
+-        auto future = f->startAsynchronously();
+-        future.waitForFinished();
++        CountFor f(0, iterations);
++        f.startBlocking();
+         QCOMPARE(counter.loadRelaxed(), iterations);
+     }
+ }
+@@ -177,11 +174,8 @@ void tst_QtConcurrentIterateKernel::stresstest()
+ void tst_QtConcurrentIterateKernel::noIterations()
+ {
+     const int times = 20000;
+-    for (int i = 0; i < times; ++i) {
+-        auto future = startThreadEngine(new IterateKernel<TestIterator, void>(0, 0))
+-                              .startAsynchronously();
+-        future.waitForFinished();
+-    }
++    for (int i = 0; i < times; ++i)
++        startThreadEngine(new IterateKernel<TestIterator, void>(0, 0)).startBlocking();
+ }
+ 
+ QMutex threadsMutex;
+@@ -236,10 +230,8 @@ void tst_QtConcurrentIterateKernel::throttling()
+ 
+     threads.clear();
+ 
+-    // ThreadEngine will delete f when it finishes
+-    auto f = new ThrottleFor(0, totalIterations);
+-    auto future = f->startAsynchronously();
+-    future.waitForFinished();
++    ThrottleFor f(0, totalIterations);
++    f.startBlocking();
+ 
+     QCOMPARE(iterations.loadRelaxed(), totalIterations);
+ 
+diff --git a/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp b/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
+index ac7be7acdd..81bc64c8d9 100644
+--- a/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
++++ b/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
+@@ -65,9 +65,16 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::runDirectly()
+ {
+-    PrintUser *engine = new PrintUser();
+-    QFuture<void> f = engine->startAsynchronously();
+-    f.waitForFinished();
++    {
++        PrintUser engine;
++        engine.startSingleThreaded();
++        engine.startBlocking();
++    }
++    {
++        PrintUser *engine = new PrintUser();
++        QFuture<void> f = engine->startAsynchronously();
++        f.waitForFinished();
++    }
+ }
+ 
+ class StringResultUser : public ThreadEngine<QString>
+@@ -99,10 +106,8 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::result()
+ {
+-    // ThreadEngine will delete 'engine' when it finishes
+-    auto engine = new StringResultUser();
+-    auto future = engine->startAsynchronously();
+-    QCOMPARE(future.result(), QString("Foo"));
++    StringResultUser engine;
++    QCOMPARE(*engine.startBlocking(), QString("Foo"));
+ }
+ 
+ class VoidResultUser : public ThreadEngine<void>
+@@ -128,9 +133,17 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::runThroughStarter()
+ {
+-    ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
+-    QFuture<QString> f = starter.startAsynchronously();
+-    QCOMPARE(f.result(), QString("Foo"));
++    {
++        ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
++        QFuture<QString>  f = starter.startAsynchronously();
++        QCOMPARE(f.result(), QString("Foo"));
++    }
++
++    {
++        ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
++        QString str = starter.startBlocking();
++        QCOMPARE(str, QString("Foo"));
++    }
+ }
+ 
+ class CancelUser : public ThreadEngine<void>
+@@ -213,6 +226,12 @@ void tst_QtConcurrentThreadEngine::throttle()
+         f.waitForFinished();
+         QCOMPARE(count.loadRelaxed(), 0);
+     }
++
++    for (int i = 0; i < repeats; ++i) {
++        ThrottleAlwaysUser t;
++        t.startBlocking();
++        QCOMPARE(count.loadRelaxed(), 0);
++    }
+ }
+ 
+ QSet<QThread *> threads;
+@@ -249,17 +268,35 @@ void tst_QtConcurrentThreadEngine::threadCount()
+ {
+     const int repeats = 10;
+     for (int i = 0; i < repeats; ++i) {
++        ThreadCountUser t;
++        t.startBlocking();
++        int count = threads.count();
++        int count_expected = QThreadPool::globalInstance()->maxThreadCount() + 1; // +1 for the main thread.
++        if (count != count_expected)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, count_expected);
++
+         (new ThreadCountUser())->startAsynchronously().waitForFinished();
+-        const auto count = threads.count();
+-        const auto maxThreadCount = QThreadPool::globalInstance()->maxThreadCount();
+-        QVERIFY(count <= maxThreadCount);
+-        QVERIFY(!threads.contains(QThread::currentThread()));
++        count = threads.count();
++        count_expected = QThreadPool::globalInstance()->maxThreadCount();
++        if (count != count_expected)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, count_expected);
+     }
+ 
+     // Set the finish flag immediately, this should give us one thread only.
+     for (int i = 0; i < repeats; ++i) {
++        ThreadCountUser t(true /*finishImmediately*/);
++        t.startBlocking();
++        int count = threads.count();
++        if (count != 1)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, 1);
++
+         (new ThreadCountUser(true /*finishImmediately*/))->startAsynchronously().waitForFinished();
+-        const auto count = threads.count();
++        count = threads.count();
++        if (count != 1)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
+         QCOMPARE(count, 1);
+         QVERIFY(!threads.contains(QThread::currentThread()));
+     }
+@@ -400,6 +437,7 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::exceptions()
+ {
++    // Asynchronous mode:
+     {
+         bool caught = false;
+         try  {
+@@ -412,6 +450,32 @@ void tst_QtConcurrentThreadEngine::exceptions()
+         QVERIFY2(caught, "did not get exception");
+     }
+ 
++    // Blocking mode:
++    // test throwing the exception from a worker thread.
++    {
++        bool caught = false;
++        try  {
++            QtConcurrentExceptionThrower e(QThread::currentThread());
++            e.startBlocking();
++        } catch (const QException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // test throwing the exception from the main thread (different code path)
++    {
++        bool caught = false;
++        try  {
++            QtConcurrentExceptionThrower e(0);
++            e.startBlocking();
++        } catch (const QException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // Asynchronous mode:
+     {
+         bool caught = false;
+         try  {
+@@ -423,6 +487,31 @@ void tst_QtConcurrentThreadEngine::exceptions()
+         }
+         QVERIFY2(caught, "did not get exception");
+     }
++
++    // Blocking mode:
++    // test throwing the exception from a worker thread.
++    {
++        bool caught = false;
++        try  {
++            UnrelatedExceptionThrower e(QThread::currentThread());
++            e.startBlocking();
++        } catch (const QUnhandledException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // test throwing the exception from the main thread (different code path)
++    {
++        bool caught = false;
++        try  {
++            UnrelatedExceptionThrower e(0);
++            e.startBlocking();
++        } catch (const QUnhandledException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
+ }
+ 
+ #endif
+diff --git a/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp b/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
+index 4968742110..f4c3fb711d 100644
+--- a/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
++++ b/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
+@@ -42,6 +42,7 @@ private slots:
+     void writeBlock_data();
+     void writeBlock();
+     void seek();
++    void invalidSeeks();
+     void seekTest_data();
+     void seekTest();
+     void read_rawdata();
+@@ -286,6 +287,29 @@ void tst_QBuffer::seek()
+     QCOMPARE(buffer.size(), pos);
+ }
+ 
++void tst_QBuffer::invalidSeeks()
++{
++    if constexpr (sizeof(qsizetype) == sizeof(qint64)) {
++        // sizeof(qsizetype) == sizeof(qint64), so +1 would overflow
++        QSKIP("This is a 32-bit-only test.");
++    } else {
++        QBuffer buffer;
++        buffer.open(QIODevice::WriteOnly);
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++        constexpr qint64 MaxQByteArrayCapacity = (std::numeric_limits<qsizetype>::max)();
++        // this should fail fast, not after trying to allocate nearly 2 GiB of data,
++        // potentially crashing in the process:
++        QVERIFY(!buffer.seek(2 * MaxQByteArrayCapacity - 1));
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++        // ditto:
++        QVERIFY(!buffer.seek(MaxQByteArrayCapacity + 1));
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++    }
++}
++
+ void tst_QBuffer::seekTest_data()
+ {
+     writeBlock_data();
+diff --git a/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp b/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
+index da5327594c..4a04e0f7c6 100644
+--- a/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
++++ b/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
+@@ -561,7 +561,8 @@ protected:
+     qint64 readData(char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf->size() - offset));
+-        memcpy(data, buf->constData() + offset, maxSize);
++        if (maxSize > 0)
++            memcpy(data, buf->constData() + offset, maxSize);
+         offset += maxSize;
+         return maxSize;
+     }
+@@ -604,13 +605,15 @@ protected:
+     qint64 readData(char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf.size() - pos()));
+-        memcpy(data, buf.constData() + pos(), maxSize);
++        if (maxSize > 0)
++            memcpy(data, buf.constData() + pos(), maxSize);
+         return maxSize;
+     }
+     qint64 writeData(const char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf.size() - pos()));
+-        memcpy(buf.data() + pos(), data, maxSize);
++        if (maxSize > 0)
++            memcpy(buf.data() + pos(), data, maxSize);
+         return maxSize;
+     }
+ 
+diff --git a/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+index db60bead64..f345a44414 100644
+--- a/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
++++ b/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+@@ -1,7 +1,8 @@
+ /****************************************************************************
+ **
+ ** Copyright (C) 2021 The Qt Company Ltd.
+-** Copyright (C) 2020 Intel Corporation.
++** Copyright (C) 2020 The Qt Company Ltd.
++** Copyright (C) 2022 Intel Corporation.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the test suite of the Qt Toolkit.
+@@ -150,6 +151,8 @@ private slots:
+     void startStopStartStopBuffers();
+     void processEventsInAReadyReadSlot_data();
+     void processEventsInAReadyReadSlot();
++    void startFromCurrentWorkingDir_data();
++    void startFromCurrentWorkingDir();
+ 
+     // keep these at the end, since they use lots of processes and sometimes
+     // caused obscure failures to occur in tests that followed them (esp. on the Mac)
+@@ -2731,5 +2734,94 @@ void tst_QProcess::finishProcessBeforeReadingDone_deprecated()
+ 
+ #endif
+ 
++enum class ChdirMode {
++    None = 0,
++    InParent,
++    InChild
++};
++Q_DECLARE_METATYPE(ChdirMode)
++
++void tst_QProcess::startFromCurrentWorkingDir_data()
++{
++    qRegisterMetaType<ChdirMode>();
++    QTest::addColumn<QString>("programPrefix");
++    QTest::addColumn<ChdirMode>("chdirMode");
++    QTest::addColumn<bool>("success");
++
++    constexpr bool IsWindows = true
++#ifdef Q_OS_UNIX
++            && false
++#endif
++            ;
++
++    // baseline: trying to execute the directory, this can't possibly succeed!
++    QTest::newRow("plain-same-cwd") << QString() << ChdirMode::None << false;
++
++    // cross-platform behavior: neither OS searches the setWorkingDirectory()
++    // dir without "./"
++    QTest::newRow("plain-child-chdir") << QString() << ChdirMode::InChild << false;
++
++    // cross-platform behavior: both OSes search the parent's CWD with "./"
++    QTest::newRow("prefixed-parent-chdir") << "./" << ChdirMode::InParent << true;
++
++    // opposite behaviors: Windows searches the parent's CWD and Unix searches
++    // the child's with "./"
++    QTest::newRow("prefixed-child-chdir") << "./" << ChdirMode::InChild << !IsWindows;
++
++    // Windows searches the parent's CWD without "./"
++    QTest::newRow("plain-parent-chdir") << QString() << ChdirMode::InParent << IsWindows;
++}
++
++void tst_QProcess::startFromCurrentWorkingDir()
++{
++    QFETCH(QString, programPrefix);
++    QFETCH(ChdirMode, chdirMode);
++    QFETCH(bool, success);
++
++    QProcess process;
++    qRegisterMetaType<QProcess::ProcessError>();
++    QSignalSpy errorSpy(&process, &QProcess::errorOccurred);
++    QVERIFY(errorSpy.isValid());
++
++    // both the dir name and the executable name
++    const QString target = QStringLiteral("testProcessNormal");
++    process.setProgram(programPrefix + target);
++
++#ifdef Q_OS_UNIX
++    // Reset PATH, to be sure it doesn't contain . or the empty path.
++    // We can't do this on Windows because DLLs are searched in PATH
++    // and Windows always searches "." anyway.
++    auto restoreEnv = qScopeGuard([old = qgetenv("PATH")] {
++        qputenv("PATH", old);
++    });
++    qputenv("PATH", "/");
++#endif
++
++    switch (chdirMode) {
++    case ChdirMode::InParent: {
++        auto restoreCwd = qScopeGuard([old = QDir::currentPath()] {
++            QDir::setCurrent(old);
++        });
++        QVERIFY(QDir::setCurrent(target));
++        process.start();
++        break;
++    }
++    case ChdirMode::InChild:
++        process.setWorkingDirectory(target);
++        Q_FALLTHROUGH();
++    case ChdirMode::None:
++        process.start();
++        break;
++    }
++
++    QCOMPARE(process.waitForStarted(), success);
++    QCOMPARE(errorSpy.count(), int(!success));
++    if (success) {
++        QVERIFY(process.waitForFinished());
++    } else {
++        QCOMPARE(process.error(), QProcess::FailedToStart);
++    }
++}
++
+ QTEST_MAIN(tst_QProcess)
+ #include "tst_qprocess.moc"
+diff --git a/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp b/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp
+index e1ea7a4552..90972caa57 100644
+--- a/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp
++++ b/qtbase/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"
+diff --git a/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+index 9bd66c0835..ed4a0bae5d 100644
+--- a/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
++++ b/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+@@ -158,6 +158,7 @@ private slots:
+     void nullReceiver();
+     void functorReferencesConnection();
+     void disconnectDisconnects();
++    void declarativeData();
+ };
+ 
+ struct QObjectCreatedOnShutdown
+@@ -7679,5 +7680,81 @@ void tst_QObject::disconnectDisconnects()
+ Q_STATIC_ASSERT(QtPrivate::HasQ_OBJECT_Macro<tst_QObject>::Value);
+ Q_STATIC_ASSERT(!QtPrivate::HasQ_OBJECT_Macro<SiblingDeleter>::Value);
+ 
++#ifdef QT_BUILD_INTERNAL
++/*
++    Since QObjectPrivate stores the declarativeData pointer in a union with the pointer
++    to the currently destroyed child, calls to the QtDeclarative handlers need to be
++    correctly guarded. QTBUG-105286
++*/
++namespace QtDeclarative {
++static QAbstractDeclarativeData *theData;
++
++static void destroyed(QAbstractDeclarativeData *data, QObject *)
++{
++    QCOMPARE(data, theData);
++}
++static void signalEmitted(QAbstractDeclarativeData *data, QObject *, int, void **)
++{
++    QCOMPARE(data, theData);
++}
++// we can't use QCOMPARE in the next two functions, as they don't return void
++static int receivers(QAbstractDeclarativeData *data, const QObject *, int)
++{
++    QTest::qCompare(data, theData, "data", "theData", __FILE__, __LINE__);
++    return 0;
++}
++static bool isSignalConnected(QAbstractDeclarativeData *data, const QObject *, int)
++{
++    QTest::qCompare(data, theData, "data", "theData", __FILE__, __LINE__);
++    return true;
++}
++
++class Object : public QObject
++{
++    Q_OBJECT
++public:
++    using QObject::QObject;
++    ~Object()
++    {
++        if (Object *p = static_cast<Object *>(parent()))
++            p->emitSignal();
++    }
++
++    void emitSignal()
++    {
++        emit theSignal();
++    }
++
++signals:
++    void theSignal();
++};
++
++}
++#endif
++
++void tst_QObject::declarativeData()
++{
++#ifdef QT_BUILD_INTERNAL
++    QScopedValueRollback destroyed(QAbstractDeclarativeData::destroyed,
++                                   QtDeclarative::destroyed);
++    QScopedValueRollback signalEmitted(QAbstractDeclarativeData::signalEmitted,
++                                       QtDeclarative::signalEmitted);
++    QScopedValueRollback receivers(QAbstractDeclarativeData::receivers,
++                                   QtDeclarative::receivers);
++    QScopedValueRollback isSignalConnected(QAbstractDeclarativeData::isSignalConnected,
++                                           QtDeclarative::isSignalConnected);
++
++    QtDeclarative::Object p;
++    QObjectPrivate *priv = QObjectPrivate::get(&p);
++    priv->declarativeData = QtDeclarative::theData = new QAbstractDeclarativeData;
++
++    connect(&p, &QtDeclarative::Object::theSignal, &p, []{
++    });
++
++    QtDeclarative::Object *child = new QtDeclarative::Object;
++    child->setParent(&p);
++#endif
++}
++
+ QTEST_MAIN(tst_QObject)
+ #include "tst_qobject.moc"
+diff --git a/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp b/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
+index 0ea422ecbc..1a3256534b 100644
+--- a/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
++++ b/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
+@@ -70,15 +70,15 @@ static inline QString testSuiteWarning()
+ 
+     QString result;
+     QTextStream str(&result);
+-    str << "\nCannot find the shared-mime-info test suite\nstarting from: "
++    str << "\nCannot find the shared-mime-info test suite\nin the parent of: "
+         << QDir::toNativeSeparators(QDir::currentPath()) << "\n"
+            "cd " << QDir::toNativeSeparators(QStringLiteral("tests/auto/corelib/mimetypes/qmimedatabase")) << "\n"
+-           "wget http://cgit.freedesktop.org/xdg/shared-mime-info/snapshot/Release-1-10.zip\n"
+-           "unzip Release-1-10.zip\n";
++           "wget https://gitlab.freedesktop.org/xdg/shared-mime-info/-/archive/2.1/shared-mime-info-2.1.zip\n"
++           "unzip shared-mime-info-2.1.zip\n";
+ #ifdef Q_OS_WIN
+-    str << "mkdir testfiles\nxcopy /s Release-1-10 s-m-i\n";
++    str << "mkdir testfiles\nxcopy /s shared-mime-info-2.1 s-m-i\n";
+ #else
+-    str << "ln -s Release-1-10 s-m-i\n";
++    str << "ln -s shared-mime-info-2.1 s-m-i\n";
+ #endif
+     return result;
+ }
+@@ -154,7 +154,7 @@ void tst_QMimeDatabase::initTestCase()
+     QVERIFY2(copyResourceFile(xmlFileName, xmlTargetFileName, &errorMessage), qPrintable(errorMessage));
+ #endif
+ 
+-    m_testSuite = QFINDTESTDATA("s-m-i/tests");
++    m_testSuite = QFINDTESTDATA("s-m-i/tests/mime-detection");
+     if (m_testSuite.isEmpty())
+         qWarning("%s", qPrintable(testSuiteWarning()));
+ 
+@@ -611,7 +611,7 @@ void tst_QMimeDatabase::allMimeTypes()
+     QVERIFY(!lst.isEmpty());
+ 
+     // Hardcoding this is the only way to check both providers find the same number of mimetypes.
+-    QCOMPARE(lst.count(), 779);
++    QCOMPARE(lst.count(), 811);
+ 
+     foreach (const QMimeType &mime, lst) {
+         const QString name = mime.name();
+@@ -631,10 +631,9 @@ void tst_QMimeDatabase::suffixes_data()
+ 
+     QTest::newRow("mimetype with a single pattern") << "application/pdf" << "*.pdf" << "pdf";
+     QTest::newRow("mimetype with multiple patterns") << "application/x-kpresenter" << "*.kpr;*.kpt" << "kpr";
+-    QTest::newRow("jpeg") << "image/jpeg" << "*.jpe;*.jpg;*.jpeg" << "jpeg";
+-    //if (KMimeType::sharedMimeInfoVersion() > KDE_MAKE_VERSION(0, 60, 0)) {
+-        QTest::newRow("mimetype with many patterns") << "application/vnd.wordperfect" << "*.wp;*.wp4;*.wp5;*.wp6;*.wpd;*.wpp" << "wp";
+-    //}
++    // The preferred suffix for image/jpeg is *.jpg, as per https://bugs.kde.org/show_bug.cgi?id=176737
++    QTest::newRow("jpeg") << "image/jpeg" << "*.jpe;*.jpg;*.jpeg" << "jpg";
++    QTest::newRow("mimetype with many patterns") << "application/vnd.wordperfect" << "*.wp;*.wp4;*.wp5;*.wp6;*.wpd;*.wpp" << "wp";
+     QTest::newRow("oasis text mimetype") << "application/vnd.oasis.opendocument.text" << "*.odt" << "odt";
+     QTest::newRow("oasis presentation mimetype") << "application/vnd.oasis.opendocument.presentation" << "*.odp" << "odp";
+     QTest::newRow("mimetype with multiple patterns") << "text/plain" << "*.asc;*.txt;*,v" << "txt";
+diff --git a/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp b/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
+index 3e58dd03cc..c8f82ef5d5 100644
+--- a/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
++++ b/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
+@@ -176,6 +176,8 @@ private Q_SLOTS:
+     void fromToVariantConversions_data();
+     void fromToVariantConversions();
+ 
++    void noLeakOnNameClash();
++
+ private:
+     QString testDataDir;
+ };
+@@ -3685,5 +3687,23 @@ void tst_QtJson::fromToVariantConversions()
+     }
+ }
+ 
++void tst_QtJson::noLeakOnNameClash()
++{
++    QJsonDocument doc = QJsonDocument::fromJson("{\"\":{\"\":0},\"\":0}");
++    QVERIFY(!doc.isNull());
++    const QJsonObject obj = doc.object();
++
++    // Removed the duplicate key.
++    QCOMPARE(obj.length(), 1);
++
++    // Retained the last of the duplicates.
++    const QJsonValue val = obj.begin().value();
++    QVERIFY(val.isDouble());
++    QCOMPARE(val.toDouble(), 0.0);
++
++    // It should not leak.
++    // In particular it should not forget to deref the container for the inner object.
++}
++
+ QTEST_MAIN(tst_QtJson)
+ #include "tst_qtjson.moc"
+diff --git a/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp b/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
+index a59b58d57f..241c3e84ac 100644
+--- a/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
++++ b/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
+@@ -63,6 +63,7 @@ private slots:
+     void isValidId_data();
+     void isValidId();
+     void malformed();
++    void serialize();
+     // Backend tests
+     void utcTest();
+     void icuTest();
+@@ -947,6 +948,33 @@ void tst_QTimeZone::malformed()
+         barf.offsetFromUtc(now);
+ }
+ 
++void tst_QTimeZone::serialize()
++{
++    int parts = 0;
++#ifndef QT_NO_DEBUG_STREAM
++    qDebug() << QTimeZone(); // to verify no crash
++    parts++;
++#endif
++#ifndef QT_NO_DATASTREAM
++    QByteArray blob;
++    {
++        QDataStream stream(&blob, QIODevice::WriteOnly);
++        stream << QTimeZone("Europe/Oslo") << QTimeZone(420) << QTimeZone() << qint64(-1);
++    }
++    QDataStream stream(&blob, QIODevice::ReadOnly);
++    QTimeZone invalid, offset, oslo;
++    qint64 minusone;
++    stream >> oslo >> offset >> invalid >> minusone;
++    QCOMPARE(oslo, QTimeZone("Europe/Oslo"));
++    QCOMPARE(offset, QTimeZone(420));
++    QVERIFY(!invalid.isValid());
++    QCOMPARE(minusone, qint64(-1));
++    parts++;
++#endif
++    if (!parts)
++        QSKIP("No serialization enabled");
++}
++
+ void tst_QTimeZone::utcTest()
+ {
+ #ifdef QT_BUILD_INTERNAL
+diff --git a/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp b/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
+index 05480c6dd2..70f4c75756 100644
+--- a/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
++++ b/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
+@@ -324,6 +324,13 @@ void tst_QDBusInterface::notValid()
+ 
+     QVERIFY(!interface.isValid());
+     QVERIFY(!QMetaObject::invokeMethod(&interface, "ListNames", Qt::DirectConnection));
++
++    // With a connection, but empty/null service and path specified
++    QDBusConnection con = QDBusConnection::sessionBus();
++    QVERIFY(con.isConnected());
++    QDBusInterface iface({}, {}, {}, con);
++    QVERIFY(!iface.isValid());
++    QVERIFY(!QMetaObject::invokeMethod(&interface, "ListNames", Qt::DirectConnection));
+ }
+ 
+ void tst_QDBusInterface::notValidDerived()
+diff --git a/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp b/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
+index 874468c954..04ceb4ab65 100644
+--- a/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
++++ b/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
+@@ -507,6 +507,10 @@ void tst_QKeySequence::toStringFromKeycode_data()
+     QTest::newRow("Ctrl+Alt+Num+Del") << QKeySequence(Qt::ControlModifier | Qt::AltModifier | Qt::KeypadModifier | Qt::Key_Delete) << "Ctrl+Alt+Num+Del";
+     QTest::newRow("Ctrl+Ins") << QKeySequence(Qt::ControlModifier | Qt::Key_Insert) << "Ctrl+Ins";
+     QTest::newRow("Ctrl+Num+Ins(1)") << QKeySequence(Qt::Key_Insert | Qt::KeypadModifier | Qt::ControlModifier) << "Ctrl+Num+Ins";
++    QTest::newRow("Ctrl") << QKeySequence(Qt::Key_Control) << "Control";
++    QTest::newRow("Alt") << QKeySequence(Qt::Key_Alt) << "Alt";
++    QTest::newRow("Shift") << QKeySequence(Qt::Key_Shift) << "Shift";
++    QTest::newRow("Meta") << QKeySequence(Qt::Key_Meta) << "Meta";
+ }
+ 
+ void tst_QKeySequence::toStringFromKeycode()
+diff --git a/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp b/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+index 15e0ecadaa..b4eca74283 100644
+--- a/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
++++ b/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+@@ -81,6 +81,8 @@ private slots:
+     void registerOpenTypePreferredNamesSystem();
+     void registerOpenTypePreferredNamesApplication();
+ 
++    void stretchRespected();
++
+ private:
+     QString m_ledFont;
+     QString m_testFont;
+@@ -355,6 +357,28 @@ static QString testString()
+     return QStringLiteral("foo bar");
+ }
+ 
++void tst_QFontDatabase::stretchRespected()
++{
++    int italicId = QFontDatabase::addApplicationFont(m_testFontItalic);
++    QVERIFY(italicId != -1);
++
++    QVERIFY(!QFontDatabase::applicationFontFamilies(italicId).isEmpty());
++
++    QString italicFontName = QFontDatabase::applicationFontFamilies(italicId).first();
++
++    QFont italicFont = QFontDatabase().font(italicFontName,
++                                            QString::fromLatin1("Italic"), 14);
++    QVERIFY(italicFont.italic());
++
++    QFont italicStretchedFont = italicFont;
++    italicStretchedFont.setStretch( 400 );
++
++    QVERIFY(QFontMetricsF(italicFont).horizontalAdvance(QStringLiteral("foobar")) <
++            QFontMetricsF(italicStretchedFont).horizontalAdvance(QStringLiteral("foobar")));
++
++    QFontDatabase::removeApplicationFont(italicId);
++}
++
+ void tst_QFontDatabase::condensedFontWidthNoFontMerging()
+ {
+     int regularFontId = QFontDatabase::addApplicationFont(m_testFont);
+diff --git a/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+index 3d4a094c43..b423e11a99 100644
+--- a/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
++++ b/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+@@ -281,6 +281,7 @@ private Q_SLOTS:
+     void ioGetFromFileSpecial();
+     void ioGetFromFile_data();
+     void ioGetFromFile();
++    void ioGetFromFileUrl();
+     void ioGetFromFtp_data();
+     void ioGetFromFtp();
+     void ioGetFromFtpWithReuse();
+@@ -3300,6 +3301,18 @@ void tst_QNetworkReply::ioGetFromFile()
+     QCOMPARE(reader.data, data);
+ }
+ 
++void tst_QNetworkReply::ioGetFromFileUrl()
++{
++    // This immediately fails on non-windows platforms:
++    QNetworkRequest request(QUrl("file://unc-server/some/path"));
++    QNetworkReplyPtr reply(manager.get(request));
++    QSignalSpy finishedSpy(reply.get(), &QNetworkReply::finished);
++    // QTBUG-105618: This would, on non-Windows platforms, never happen because the signal
++    // was emitted before the constructor finished, leaving no chance at all to connect to the
++    // signal
++    QVERIFY(finishedSpy.wait());
++}
++
+ void tst_QNetworkReply::ioGetFromFtp_data()
+ {
+     QTest::addColumn<QString>("fileName");
+diff --git a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
+index 069fa6b341..4cc4d9a5ea 100644
+--- a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
++++ b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
+@@ -1,75 +1,34 @@
+-Certificate:
+-    Data:
+-        Version: 3 (0x2)
+-        Serial Number: 0 (0x0)
+-        Signature Algorithm: sha1WithRSAEncryption
+-        Issuer: C=NO, ST=Oslo, L=Nydalen, O=Nokia Corporation and/or its subsidiary(-ies), OU=Development, CN=fluke.troll.no/emailAddress=ahanssen@trolltech.com
+-        Validity
+-            Not Before: Dec  4 01:10:32 2007 GMT
+-            Not After : Apr 21 01:10:32 2035 GMT
+-        Subject: C=NO, ST=Oslo, O=Nokia Corporation and/or its subsidiary(-ies), OU=Development, CN=fluke.troll.no
+-        Subject Public Key Info:
+-            Public Key Algorithm: rsaEncryption
+-            RSA Public Key: (1024 bit)
+-                Modulus (1024 bit):
+-                    00:a7:c8:a0:4a:c4:19:05:1b:66:ba:32:e2:d2:f1:
+-                    1c:6f:17:82:e4:39:2e:01:51:90:db:04:34:32:11:
+-                    21:c2:0d:6f:59:d8:53:90:54:3f:83:8f:a9:d3:b3:
+-                    d5:ee:1a:9b:80:ae:c3:25:c9:5e:a5:af:4b:60:05:
+-                    aa:a0:d1:91:01:1f:ca:04:83:e3:58:1c:99:32:45:
+-                    84:70:72:58:03:98:4a:63:8b:41:f5:08:49:d2:91:
+-                    02:60:6b:e4:64:fe:dd:a0:aa:74:08:e9:34:4c:91:
+-                    5f:12:3d:37:4d:54:2c:ad:7f:5b:98:60:36:02:8c:
+-                    3b:f6:45:f3:27:6a:9b:94:9d
+-                Exponent: 65537 (0x10001)
+-        X509v3 extensions:
+-            X509v3 Basic Constraints: 
+-                CA:FALSE
+-            Netscape Comment: 
+-                OpenSSL Generated Certificate
+-            X509v3 Subject Key Identifier: 
+-                21:85:04:3D:23:01:66:E5:F7:9F:1A:84:24:8A:AF:0A:79:F4:E5:AC
+-            X509v3 Authority Key Identifier: 
+-                DirName:/C=NO/ST=Oslo/L=Nydalen/O=Nokia Corporation and/or its subsidiary(-ies)/OU=Development/CN=fluke.troll.no/emailAddress=ahanssen@trolltech.com
+-                serial:8E:A8:B4:E8:91:B7:54:2E
+-
+-    Signature Algorithm: sha1WithRSAEncryption
+-        6d:57:5f:d1:05:43:f0:62:05:ec:2a:71:a5:dc:19:08:f2:c4:
+-        a6:bd:bb:25:d9:ca:89:01:0e:e4:cf:1f:c1:8c:c8:24:18:35:
+-        53:59:7b:c0:43:b4:32:e6:98:b2:a6:ef:15:05:0b:48:5f:e1:
+-        a0:0c:97:a9:a1:77:d8:35:18:30:bc:a9:8f:d3:b7:54:c7:f1:
+-        a9:9e:5d:e6:19:bf:f6:3c:5b:2b:d8:e4:3e:62:18:88:8b:d3:
+-        24:e1:40:9b:0c:e6:29:16:62:ab:ea:05:24:70:36:aa:55:93:
+-        ef:02:81:1b:23:10:a2:04:eb:56:95:75:fc:f8:94:b1:5d:42:
+-        c5:3f:36:44:85:5d:3a:2e:90:46:8a:a2:b9:6f:87:ae:0c:15:
+-        40:19:31:90:fc:3b:25:bb:ae:f1:66:13:0d:85:90:d9:49:34:
+-        8f:f2:5d:f9:7a:db:4d:5d:27:f6:76:9d:35:8c:06:a6:4c:a3:
+-        b1:b2:b6:6f:1d:d7:a3:00:fd:72:eb:9e:ea:44:a1:af:21:34:
+-        7d:c7:42:e2:49:91:19:8b:c0:ad:ba:82:80:a8:71:70:f4:35:
+-        31:91:63:84:20:95:e9:60:af:64:8b:cc:ff:3d:8a:76:74:3d:
+-        c8:55:6d:e4:8e:c3:2b:1c:e8:42:18:ae:9f:e6:6b:9c:34:06:
+-        ec:6a:f2:c3
+ -----BEGIN CERTIFICATE-----
+-MIIEEzCCAvugAwIBAgIBADANBgkqhkiG9w0BAQUFADCBnDELMAkGA1UEBhMCTk8x
+-DTALBgNVBAgTBE9zbG8xEDAOBgNVBAcTB055ZGFsZW4xFjAUBgNVBAoTDVRyb2xs
+-dGVjaCBBU0ExFDASBgNVBAsTC0RldmVsb3BtZW50MRcwFQYDVQQDEw5mbHVrZS50
+-cm9sbC5ubzElMCMGCSqGSIb3DQEJARYWYWhhbnNzZW5AdHJvbGx0ZWNoLmNvbTAe
+-Fw0wNzEyMDQwMTEwMzJaFw0zNTA0MjEwMTEwMzJaMGMxCzAJBgNVBAYTAk5PMQ0w
+-CwYDVQQIEwRPc2xvMRYwFAYDVQQKEw1Ucm9sbHRlY2ggQVNBMRQwEgYDVQQLEwtE
+-ZXZlbG9wbWVudDEXMBUGA1UEAxMOZmx1a2UudHJvbGwubm8wgZ8wDQYJKoZIhvcN
+-AQEBBQADgY0AMIGJAoGBAKfIoErEGQUbZroy4tLxHG8XguQ5LgFRkNsENDIRIcIN
+-b1nYU5BUP4OPqdOz1e4am4CuwyXJXqWvS2AFqqDRkQEfygSD41gcmTJFhHByWAOY
+-SmOLQfUISdKRAmBr5GT+3aCqdAjpNEyRXxI9N01ULK1/W5hgNgKMO/ZF8ydqm5Sd
+-AgMBAAGjggEaMIIBFjAJBgNVHRMEAjAAMCwGCWCGSAGG+EIBDQQfFh1PcGVuU1NM
+-IEdlbmVyYXRlZCBDZXJ0aWZpY2F0ZTAdBgNVHQ4EFgQUIYUEPSMBZuX3nxqEJIqv
+-Cnn05awwgbsGA1UdIwSBszCBsKGBoqSBnzCBnDELMAkGA1UEBhMCTk8xDTALBgNV
+-BAgTBE9zbG8xEDAOBgNVBAcTB055ZGFsZW4xFjAUBgNVBAoTDVRyb2xsdGVjaCBB
+-U0ExFDASBgNVBAsTC0RldmVsb3BtZW50MRcwFQYDVQQDEw5mbHVrZS50cm9sbC5u
+-bzElMCMGCSqGSIb3DQEJARYWYWhhbnNzZW5AdHJvbGx0ZWNoLmNvbYIJAI6otOiR
+-t1QuMA0GCSqGSIb3DQEBBQUAA4IBAQBtV1/RBUPwYgXsKnGl3BkI8sSmvbsl2cqJ
+-AQ7kzx/BjMgkGDVTWXvAQ7Qy5piypu8VBQtIX+GgDJepoXfYNRgwvKmP07dUx/Gp
+-nl3mGb/2PFsr2OQ+YhiIi9Mk4UCbDOYpFmKr6gUkcDaqVZPvAoEbIxCiBOtWlXX8
+-+JSxXULFPzZEhV06LpBGiqK5b4euDBVAGTGQ/Dslu67xZhMNhZDZSTSP8l35ettN
+-XSf2dp01jAamTKOxsrZvHdejAP1y657qRKGvITR9x0LiSZEZi8CtuoKAqHFw9DUx
+-kWOEIJXpYK9ki8z/PYp2dD3IVW3kjsMrHOhCGK6f5mucNAbsavLD
++MIIF6zCCA9OgAwIBAgIUfo9amJtJGWqWE6f+SkAO85zkGr4wDQYJKoZIhvcNAQEL
++BQAwgYMxCzAJBgNVBAYTAk5PMQ0wCwYDVQQIDARPc2xvMQ0wCwYDVQQHDARPc2xv
++MRcwFQYDVQQKDA5UaGUgUXQgQ29tcGFueTEMMAoGA1UECwwDUiZEMRIwEAYDVQQD
++DAlIMiBUZXN0ZXIxGzAZBgkqhkiG9w0BCQEWDG1pbmltaUBxdC5pbzAgFw0yMDEw
++MjYxMjAxMzFaGA8yMTIwMTAwMjEyMDEzMVowgYMxCzAJBgNVBAYTAk5PMQ0wCwYD
++VQQIDARPc2xvMQ0wCwYDVQQHDARPc2xvMRcwFQYDVQQKDA5UaGUgUXQgQ29tcGFu
++eTEMMAoGA1UECwwDUiZEMRIwEAYDVQQDDAlIMiBUZXN0ZXIxGzAZBgkqhkiG9w0B
++CQEWDG1pbmltaUBxdC5pbzCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIB
++AOiUp5+E4blouKH7q+rVNR8NoYX2XkBW+q+rpy1zu5ssRSzbqxAjDx9dkht7Qlnf
++VlDT00JvpOWdeuPon5915edQRsY4Unl6mKH29ra3OtUa1/yCJXsGVJTKCj7k4Bxb
++5mZzb/fTlZntMLdTIBMfUbw62FKir1WjKIcJ9fCoG8JaGeKVO4Rh5p0ezd4UUUId
++r1BXl5Nqdqy2vTMsEDnjOsD3egkv8I2SKN4O6n/C3wWYpMOWYZkGoZiKz7rJs/i/
++ez7bsV7JlwdzTlhpJzkcOSVFBP6JlEOxTNNxZ1wtKy7PtZGmsSSATq2e6+bw38Ae
++Op0XnzzqcGjtDDofBmT7OFzZWjS9VZS6+DOOe2QHWle1nCHcHyH4ku6IRlsr9xkR
++NAIlOfnvHHxqJUenoeaZ4oQDjCBKS1KXygJO/tL7BLTQVn/xK1EmPvKNnjzWk4tR
++PnibUhhs5635qpOU/YPqFBh1JjVruZbsWcDAhRcew0uxONXOa9E+4lttQ9ySYa1A
++LvWqJuAX7gu2BsBMLyqfm811YnA7CIFMyO+HlqmkLFfv5L/xIRAXR7l26YGO0VwX
++CGjMfz4NVPMMke4nB7qa9NkpXQBQKMms3Qzd5JW0Hy9Ruj5O8GPcFZmV0twjd1uJ
++PD/cAjkWLaXjdNsJ16QWc2nghQRS6HYqKRX6j+CXOxupAgMBAAGjUzBRMB0GA1Ud
++DgQWBBRSCOU58j9NJZkMamt623qyCrhN3TAfBgNVHSMEGDAWgBRSCOU58j9NJZkM
++amt623qyCrhN3TAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4ICAQCq
++q4jxsWeNDv5Nq14hJtF9HB+ZL64zcZtRjJP1YgNs0QppKICmjPOL2nIMGmI/jKrs
++0eGAL/9XXNVHPxm1OPOncvimMMmU6emZfpMdEtTfKP43+Pg9HgKRjLoQp406vGeQ
++8ki/mbBhrItVPgEm3tu2AFA02XTYi+YxCI9kRZLGkM3FbgtOuTLPl0Z9y+kiPc9F
++uCSC03anBEqv+vDSI8+wODymQ/IJ3Jyz1lxIRDfp4qAekmy0jU2c91VOHHEmOmqq
++kqygGFRdwbe99m9yP63r6q0b5K3X2UnJ6bns0hmTwThYwpVPXLU8jdaTddbMukN2
++/Ef96Tsw8nWOEOPMySHOTIPgwyZRp26b0kA9EmhLwOP401SxXVQCmSRmtwNagmtg
++jJKmZoYBN+//D45ibK8z6Q0oOm9P+Whf/uUXehcRxBxyV3xz7k0wKGQbHj/ddwcy
++IUoIN4lrAlib+lK170kTKN352PDmrpo2gmIzPEsfurKAIMSelDl6H+kih16BtZ8y
++Nz6fh9Soqrg3OSAware8pxV7k51crBMoPLN78KoRV8MFCK4K7Fddq4rRISq6hiXq
++r1nsjoEPuKM9huprmZVZe9t5YcDa2I+wb3IiE3uwpZbAdaLDyQ5n6F/qpsiIkZXn
++gtcF7oqpG5oYrwCcZ53y/ezUgUg7PlSz2XwAGvQtgg==
+ -----END CERTIFICATE-----
+diff --git a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
+index 9d1664d609..337ce541a6 100644
+--- a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
++++ b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
+@@ -1,15 +1,52 @@
+------BEGIN RSA PRIVATE KEY-----
+-MIICXAIBAAKBgQCnyKBKxBkFG2a6MuLS8RxvF4LkOS4BUZDbBDQyESHCDW9Z2FOQ
+-VD+Dj6nTs9XuGpuArsMlyV6lr0tgBaqg0ZEBH8oEg+NYHJkyRYRwclgDmEpji0H1
+-CEnSkQJga+Rk/t2gqnQI6TRMkV8SPTdNVCytf1uYYDYCjDv2RfMnapuUnQIDAQAB
+-AoGANFzLkanTeSGNFM0uttBipFT9F4a00dqHz6JnO7zXAT26I5r8sU1pqQBb6uLz
+-/+Qz5Zwk8RUAQcsMRgJetuPQUb0JZjF6Duv24hNazqXBCu7AZzUenjafwmKC/8ri
+-KpX3fTwqzfzi//FKGgbXQ80yykSSliDL3kn/drATxsLCgQECQQDXhEFWLJ0vVZ1s
+-1Ekf+3NITE+DR16X+LQ4W6vyEHAjTbaNWtcTKdAWLA2l6N4WAAPYSi6awm+zMxx4
+-VomVTsjdAkEAx0z+e7natLeFcrrq8pbU+wa6SAP1VfhQWKitxL1e7u/QO90NCpxE
+-oQYKzMkmmpOOFjQwEMAy1dvFMbm4LHlewQJAC/ksDBaUcQHHqjktCtrUb8rVjAyW
+-A8lscckeB2fEYyG5J6dJVaY4ClNOOs5yMDS2Afk1F6H/xKvtQ/5CzInA/QJATDub
+-K+BPU8jO9q+gpuIi3VIZdupssVGmCgObVCHLakG4uO04y9IyPhV9lA9tALtoIf4c
+-VIvv5fWGXBrZ48kZAQJBAJmVCdzQxd9LZI5vxijUCj5EI4e+x5DRqVUvyP8KCZrC
+-AiNyoDP85T+hBZaSXK3aYGpVwelyj3bvo1GrTNwNWLw=
+------END RSA PRIVATE KEY-----
++-----BEGIN PRIVATE KEY-----
++MIIJQgIBADANBgkqhkiG9w0BAQEFAASCCSwwggkoAgEAAoICAQDolKefhOG5aLih
+++6vq1TUfDaGF9l5AVvqvq6ctc7ubLEUs26sQIw8fXZIbe0JZ31ZQ09NCb6TlnXrj
++6J+fdeXnUEbGOFJ5epih9va2tzrVGtf8giV7BlSUygo+5OAcW+Zmc2/305WZ7TC3
++UyATH1G8OthSoq9VoyiHCfXwqBvCWhnilTuEYeadHs3eFFFCHa9QV5eTanastr0z
++LBA54zrA93oJL/CNkijeDup/wt8FmKTDlmGZBqGYis+6ybP4v3s+27FeyZcHc05Y
++aSc5HDklRQT+iZRDsUzTcWdcLSsuz7WRprEkgE6tnuvm8N/AHjqdF5886nBo7Qw6
++HwZk+zhc2Vo0vVWUuvgzjntkB1pXtZwh3B8h+JLuiEZbK/cZETQCJTn57xx8aiVH
++p6HmmeKEA4wgSktSl8oCTv7S+wS00FZ/8StRJj7yjZ481pOLUT54m1IYbOet+aqT
++lP2D6hQYdSY1a7mW7FnAwIUXHsNLsTjVzmvRPuJbbUPckmGtQC71qibgF+4LtgbA
++TC8qn5vNdWJwOwiBTMjvh5appCxX7+S/8SEQF0e5dumBjtFcFwhozH8+DVTzDJHu
++Jwe6mvTZKV0AUCjJrN0M3eSVtB8vUbo+TvBj3BWZldLcI3dbiTw/3AI5Fi2l43Tb
++CdekFnNp4IUEUuh2KikV+o/glzsbqQIDAQABAoICAFw1q6tr5I48vY7DF+rXsuLn
++5ZUWE1IQ6fzB4lr72nJv/9EEGnMgYzt9PpMUsD6vdCpBgS2C0+6RHArFzJtNA+RM
++iHLIG7K7702veyr/xBx/MwiSlMeMv/XpkFxVI6E6skMGG2s3AMXxKvJTy5CpRx+I
++eQFyLG+Ya1X2lgJes/q+/CpAHkOjCOpcLySQC5NZ74q734V7nSdmn+Zs3tYEh+O/
++eiuwTP/j5b38Te5vVTqDxTciJPmljmXLCwa0N100lWlbcpvw8qbqiTI2Jm3XCbUE
++AzHjW9vmrF3cRS1fXxKFGShw3SRqlkbxjfeWoi8qDPUBS4m8LOr8qG9Wo5Nfon0z
++zLP4bci3zHDvVcaaZrrsUBs/yZbg+Dgka1DmX7ekmeccr2yTdKDFgPupYUyxVbTl
++a9ZLJysjFD7rgBv1ZclHonLp6Vbm+ZoTqvteo4ikAy6L9RtBWJ23XEK34PkP/+c5
++2vWZaOrnjSeBHbFce8cdJSxqWpP+eSCI5I9XbDrYFIsQ/gqKgtzDKy2ihJ2Y8STL
++yO4hyFPFjxc+Gg4/P2PpmT5CY2ty44M0BWs+JGW96CJPrrplf2lmQUQJj5LZY66X
++Z/4C9L7ZYtKZ+bs5SvU46yWugAvQZX22Xm9xLXWyVXRdx3bj+3M3fDnF9di/zdbh
++CgLx7oWPNrXc7FCajnn9AoIBAQD5FMYwRpw9NWT9WDxQwx+cSI4Icbd88ByTW63S
++LzeRwZA0J9/SfwO+aBRupzc9GkGXCiZcGMw3AGsCtig8yFlw8E5KnzN7KlftDMnM
++9NUxxzlR8VwKyLnZfG7sDTl057ZlUujnqhmt/F8F7dIy7FVO1dE/8nngA+FYTCOG
++UZdGjwyBDlDM0JJdUWGY3xslutcpCDN5mzSTKjy9drMvImAshRawxRF6WBpn7vr2
++nC6vciqfx1Mzx1vyk0Jm0ilaydDdLMADjt/iL4Nkr0BEs4k+UzQiKDwp8gu7abQ1
++eBfxd9Iar4htQa2I1Ewl6P01G/q+ZYwgHhJ9RVn4AxQXefILAoIBAQDvCouORdQX
++C8wsyp7MwXlF/3NQeNN5/+B2mhbxrBOf7PmMCXLnkRWcjwJtzypWFqJ0sqai/2+0
++bqbMcjX5maT8stT2shl3zXe/Ejt2e3TBYpc1tyuses8Kb5BMU8hu6tTd3G2CMXpD
++dT6DVemJZCTtwj9aBNIxSizvlgMolJnCpzhPnlfHSI6E+g3m/LTTo3HwbjMSw/Uq
++irgjOpI2wSBB6LZPSgjvfcYPRyWUk16L4A5uSX0cADnovDFLa5/h0wJvN/OoCSQg
++rLCXG5E18EyL5Wc58BCY1ZvxmjG3lQtgPxYu2Jwc36R/y/JKlxW5suER5ZNpbbD4
++uOyTt2VxMQ2bAoIBAQC5+MzRFqdo/AjfL5Y5JrbfVTzXCTDa09xCGd16ZU60QTWN
+++4ed/r+o1sUKqUcRFB2MzEM/2DQBjQpZB/CbEWvWa1XJWXxypXbowveZU+QqOnmN
++uQvj8WLyA3o+PNF9e9QvauwCrHpn8VpxbtPWuaYoKnUFreFZZQxHhPGxRBIS2JOZ
++eDrT8ZaWnkCkh1AZp5smQ71LOprSlmKrg4jd1GjCVMxQR5N5KXbtyv0OTCZ/UFqK
++2aRBsMPyJgkaBChkZPLRcKwc+/wlQRx1fHQb14DNTApMxoXFO7eOwqmOkpAt9iyl
++SBIwoS0UUI5ab88+bBmXNvKcuFdNuQ4nowTJUn9pAoIBADMNkILBXSvS5DeIyuO2
++Sp1tkoZUV+5NfPY3sMDK3KIibaW/+t+EOBZo4L7tKQCb8vRzl21mmsfxfgRaPDbj
++3r3tv9g0b4YLxxBy52pFscj/soXRai17SS7UZwA2QK+XzgDYbDcLNC6mIsTQG4Gx
++dsWk3/zs3KuUSQaehmwrWK+fIUK38c1pLK8v7LoxrLkqxlHwZ04RthHw8KTthH7X
++Pnl1J0LF8CSeOyfWLSuPUfkT0GEzptnNHpEbaHfQM6R6eaGhVJPF6AZme4y6YYgg
++m2ihhSt1n0XVEWpHYWjxFy3mK2mz75unFC4LM+NEY2p2zuUQoCw7NjnY3QYrfCnx
++rRMCggEAXeXsMSLFjjyuoL7iKbAxo52HD/P0fBoy58LyRcwfNVr0lvYan4pYEx+o
++KijIh9K16PqXZXKMA9v003B+ulmF8bJ7SddCZ5NGvnFhUTDe4DdTKgp2RuwQ3Bsc
++3skPIDbhVETyOLCtys34USHrq8U/0DlGY3eLRfxw9GnbKxSBGa/KEu/qQLPNUo50
++7xHZDg7GKeC3kqNJeqKM9rkp0VzIGkEnaD9127LeNDmERDfftxJzFoC/THvUBLfU
++6Sus2ZYwRE8VFvKC30Q45t/c54X3IuhYvAuiCuTmyfE4ruyzyOwKzhUkeeLq1APX
++g0veFbyfzlJ0q8qzD/iffqqIa2ZSmQ==
++-----END PRIVATE KEY-----
+diff --git a/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp b/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
+index 7ba3715e13..752aa122f6 100644
+--- a/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
++++ b/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
+@@ -179,6 +179,7 @@ void tst_QAccessibilityLinux::initTestCase()
+     QVERIFY(!address.isEmpty());
+ 
+     m_window = new AccessibleTestWindow();
++    m_window->setObjectName("mainWindow"_L1);
+     m_window->show();
+ 
+     QVERIFY(QTest::qWaitForWindowExposed(m_window));
+@@ -236,8 +237,11 @@ bool hasState(QDBusInterface *interface, AtspiStateType state)
+ void tst_QAccessibilityLinux::testLabel()
+ {
+     QLabel *l = new QLabel(m_window);
++    l->setObjectName("theObjectName"_L1);
+     l->setText("Hello A11y");
+     m_window->addWidget(l);
++    auto a11yEmpty = new QLabel(m_window);
++    m_window->addWidget(l);
+ 
+     // Application
+     QCOMPARE(getParent(mainWindow), QLatin1String(ATSPI_DBUS_PATH_ROOT));
+@@ -249,6 +253,8 @@ void tst_QAccessibilityLinux::testLabel()
+     QCOMPARE(getChildren(labelInterface).count(), 0);
+     QCOMPARE(labelInterface->call(QDBus::Block, "GetRoleName").arguments().first().toString(), QLatin1String("label"));
+     QCOMPARE(labelInterface->call(QDBus::Block, "GetRole").arguments().first().toUInt(), 29u);
++    QCOMPARE(labelInterface->call(QDBus::Block, "GetAccessibleId").arguments().first().toString(),
++             QLatin1String("mainWindow.theObjectName"));
+     QCOMPARE(getParent(labelInterface), mainWindow->path());
+     QVERIFY(!hasState(labelInterface, ATSPI_STATE_EDITABLE));
+     QVERIFY(hasState(labelInterface, ATSPI_STATE_READ_ONLY));
+@@ -256,7 +262,12 @@ void tst_QAccessibilityLinux::testLabel()
+     l->setText("New text");
+     QCOMPARE(labelInterface->property("Name").toString(), l->text());
+ 
++    auto *a11yEmptyInterface = getInterface(children.at(1), "org.a11y.atspi.Accessible");
++    QCOMPARE(a11yEmptyInterface->call(QDBus::Block, "GetAccessibleId").arguments().first().toString(),
++             QLatin1String("mainWindow.QLabel"));
++
+     m_window->clearChildren();
++    delete a11yEmptyInterface;
+     delete labelInterface;
+ }
+ 
+diff --git a/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+index 76df61c892..6d6d65b791 100644
+--- a/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
++++ b/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2022 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the test suite of the Qt Toolkit.
+@@ -68,6 +68,8 @@ private slots:
+     void query_exec();
+     void execErrorRecovery_data() { generic_data(); }
+     void execErrorRecovery();
++    void prematureExec_data() { generic_data(); }
++    void prematureExec();
+     void first_data() { generic_data(); }
+     void first();
+     void next_data() { generic_data(); }
+@@ -2770,6 +2772,35 @@ void tst_QSqlQuery::execErrorRecovery()
+     QVERIFY_SQL( q, exec() );
+ }
+ 
++void tst_QSqlQuery::prematureExec()
++{
++    QFETCH(QString, dbName);
++    // We only want the engine name, for addDatabase():
++    int cut = dbName.indexOf(QChar('@'));
++    if (cut < 0)
++        QSKIP("Failed to parse database type out of name");
++    dbName.truncate(cut);
++    cut = dbName.indexOf(QChar('_'));
++    if (cut >= 0)
++        dbName = dbName.mid(cut + 1);
++
++    auto db = QSqlDatabase::addDatabase(dbName);
++    QSqlQuery q(db);
++
++    QTest::ignoreMessage(QtWarningMsg,
++                         "QSqlDatabasePrivate::removeDatabase: connection "
++                         "'qt_sql_default_connection' is still in use, all "
++                         "queries will cease to work.");
++    QTest::ignoreMessage(QtWarningMsg,
++                         "QSqlDatabasePrivate::addDatabase: duplicate connection name "
++                         "'qt_sql_default_connection', old connection removed.");
++    auto otherDb = QSqlDatabase::addDatabase(dbName);
++
++    QTest::ignoreMessage(QtWarningMsg, "QSqlQuery::exec: called before driver has been set up");
++    // QTBUG-100037: shouldn't crash !
++    QVERIFY(!q.exec("select stuff from TheVoid"));
++}
++
+ void tst_QSqlQuery::lastInsertId()
+ {
+     QFETCH( QString, dbName );
+diff --git a/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp b/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
+index 4aa3f8d60b..d2050a61aa 100644
+--- a/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
++++ b/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
+@@ -115,6 +115,10 @@ void tst_QAbstractItemModelTester::standardItemModelZeroColumns()
+     // QTBUG-92886
+     model.insertRows(0, 5);
+     model.removeRows(1, 2);
++
++    const QModelIndex parentIndex = model.index(0, 0);
++    model.insertRows(0, 5, parentIndex);
++    model.removeRows(1, 2, parentIndex);
+ }
+ 
+ void tst_QAbstractItemModelTester::testInsertThroughProxy()
+diff --git a/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json b/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
+index 12a4a22a19..ce518e78fb 100644
+--- a/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
++++ b/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
+@@ -668,50 +668,6 @@
+         "inputFile": "task192552.h",
+         "outputRevision": 67
+     },
+-    {
+-        "classes": [
+-            {
+-                "className": "InlineSlotsWithThrowDeclaration",
+-                "object": true,
+-                "qualifiedClassName": "InlineSlotsWithThrowDeclaration",
+-                "slots": [
+-                    {
+-                        "access": "public",
+-                        "name": "a",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "b",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "c",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "d",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "e",
+-                        "returnType": "void"
+-                    }
+-                ],
+-                "superClasses": [
+-                    {
+-                        "access": "public",
+-                        "name": "QObject"
+-                    }
+-                ]
+-            }
+-        ],
+-        "inputFile": "task189996.h",
+-        "outputRevision": 67
+-    },
+     {
+         "classes": [
+             {
+diff --git a/qtbase/tests/auto/tools/moc/moc.pro b/qtbase/tests/auto/tools/moc/moc.pro
+index c324b3a8cd..4aceb78dc0 100644
+--- a/qtbase/tests/auto/tools/moc/moc.pro
++++ b/qtbase/tests/auto/tools/moc/moc.pro
+@@ -15,7 +15,7 @@ cross_compile: DEFINES += MOC_CROSS_COMPILED
+ HEADERS += using-namespaces.h no-keywords.h task87883.h c-comments.h backslash-newlines.h oldstyle-casts.h \
+            slots-with-void-template.h qinvokable.h namespaced-flags.h trigraphs.h \
+            escapes-in-string-literals.h cstyle-enums.h qprivateslots.h gadgetwithnoenums.h \
+-           dir-in-include-path.h single_function_keyword.h task192552.h task189996.h \
++           dir-in-include-path.h single_function_keyword.h task192552.h \
+            task234909.h task240368.h pure-virtual-signals.h cxx11-enums.h \
+            cxx11-final-classes.h \
+            cxx11-explicit-override-control.h \
+diff --git a/qtbase/tests/auto/tools/moc/task189996.h b/qtbase/tests/auto/tools/moc/task189996.h
+deleted file mode 100644
+index f94a051b3a..0000000000
+--- a/qtbase/tests/auto/tools/moc/task189996.h
++++ /dev/null
+@@ -1,47 +0,0 @@
+-/****************************************************************************
+-**
+-** Copyright (C) 2016 The Qt Company Ltd.
+-** Contact: https://www.qt.io/licensing/
+-**
+-** This file is part of the test suite of the Qt Toolkit.
+-**
+-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+-** 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 General Public License Usage
+-** Alternatively, this file may be used under the terms of the GNU
+-** General Public License version 3 as published by the Free Software
+-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+-** 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-3.0.html.
+-**
+-** $QT_END_LICENSE$
+-**
+-****************************************************************************/
+-// inline functions can have throw declarations
+-
+-#ifndef TASK189996_H
+-#define TASK189996_H
+-
+-#include <QObject>
+-
+-class InlineSlotsWithThrowDeclaration : public QObject
+-{
+-    Q_OBJECT
+-
+-public slots:
+-    void a() throw() { }
+-    void b() const throw() { }
+-    void c() throw();
+-    void d() throw(int) { }
+-    void e() const throw(int,double) { }
+-};
+-
+-#endif
+diff --git a/qtbase/tests/auto/tools/moc/tst_moc.cpp b/qtbase/tests/auto/tools/moc/tst_moc.cpp
+index c716aead21..15dd9e41e5 100644
+--- a/qtbase/tests/auto/tools/moc/tst_moc.cpp
++++ b/qtbase/tests/auto/tools/moc/tst_moc.cpp
+@@ -631,7 +631,6 @@ public:
+ private slots:
+     void initTestCase();
+ 
+-    void slotWithException() throw(MyStruct);
+     void dontStripNamespaces();
+     void oldStyleCasts();
+     void warnOnExtraSignalSlotQualifiaction();
+@@ -673,7 +672,6 @@ private slots:
+     void templateGtGt();
+     void qprivateslots();
+     void qprivateproperties();
+-    void inlineSlotsWithThrowDeclaration();
+     void warnOnPropertyWithoutREAD();
+     void constructors();
+     void typenameWithUnsigned();
+@@ -784,12 +782,6 @@ void tst_Moc::initTestCase()
+ #endif
+ }
+ 
+-void tst_Moc::slotWithException() throw(MyStruct)
+-{
+-    // be happy
+-    QVERIFY(true);
+-}
+-
+ void tst_Moc::dontStripNamespaces()
+ {
+     Sender sender;
+@@ -824,7 +816,7 @@ void tst_Moc::oldStyleCasts()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-Wold-style-cast" << "-I" << "."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -894,7 +886,7 @@ void tst_Moc::inputFileNameWithDotsButNoExtension()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-I" << ".."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -1174,7 +1166,7 @@ void tst_Moc::ignoreOptionClashes()
+     QStringList gccArgs;
+     gccArgs << "-c" << "-x" << "c++" << "-I" << ".."
+          << "-I" << qtIncludePath << "-I" << includeDir << "-o" << "/dev/null"
+-         << "-fPIC" << "-std=c++11" <<  "-";
++         << "-fPIC" << "-std=c++1z" <<  "-";
+     proc.start("gcc", gccArgs);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -1593,21 +1585,6 @@ void tst_Moc::qprivateproperties()
+ 
+ }
+ 
+-#include "task189996.h"
+-
+-void InlineSlotsWithThrowDeclaration::c() throw() {}
+-
+-void tst_Moc::inlineSlotsWithThrowDeclaration()
+-{
+-    InlineSlotsWithThrowDeclaration tst;
+-    const QMetaObject *mobj = tst.metaObject();
+-    QVERIFY(mobj->indexOfSlot("a()") != -1);
+-    QVERIFY(mobj->indexOfSlot("b()") != -1);
+-    QVERIFY(mobj->indexOfSlot("c()") != -1);
+-    QVERIFY(mobj->indexOfSlot("d()") != -1);
+-    QVERIFY(mobj->indexOfSlot("e()") != -1);
+-}
+-
+ void tst_Moc::warnOnPropertyWithoutREAD()
+ {
+ #ifdef MOC_CROSS_COMPILED
+@@ -1869,7 +1846,7 @@ void tst_Moc::notifyError()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-I" << "."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+diff --git a/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+index c355ee9665..88c09de8e0 100644
+--- a/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
++++ b/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+@@ -251,6 +251,7 @@ private slots:
+     void testResetCachedSizeHint();
+     void statusTips();
+     void testRemovingColumnsViaLayoutChanged();
++    void testModelMovingColumns();
+ 
+ protected:
+     void setupTestData(bool use_reset_model = false);
+@@ -360,6 +361,12 @@ public:
+         endRemoveColumns();
+     }
+ 
++    void moveColumn(int from, int to)
++    {
++        beginMoveColumns(QModelIndex(), from, from, QModelIndex(), to);
++        endMoveColumns();
++    }
++
+     void cleanup()
+     {
+         emit layoutAboutToBeChanged();
+@@ -3627,5 +3634,18 @@ void tst_QHeaderView::testRemovingColumnsViaLayoutChanged()
+     // The main point of this test is that the section-size restoring code didn't go out of bounds.
+ }
+ 
++void tst_QHeaderView::testModelMovingColumns()
++{
++    QtTestModel model(10, 10);
++    QHeaderView hv(Qt::Horizontal);
++    hv.setModel(&model);
++    hv.resizeSections(QHeaderView::ResizeToContents);
++    hv.show();
++
++    QPersistentModelIndex index3 = model.index(0, 3);
++    model.moveColumn(3, 1);
++    QCOMPARE(index3.column(), 1);
++}
++
+ QTEST_MAIN(tst_QHeaderView)
+ #include "tst_qheaderview.moc"
+diff --git a/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+index 761357b252..06bb706074 100644
+--- a/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
++++ b/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+@@ -397,6 +397,7 @@ private slots:
+     void checkHeaderMinSize();
+ 
+     void resizeToContents();
++    void resizeToContentsSpans();
+ 
+     void tabFocus();
+     void bigModel();
+@@ -3721,6 +3722,70 @@ void tst_QTableView::resizeToContents()
+ 
+ }
+ 
++
++class SpanModel : public QAbstractTableModel
++{
++public:
++    SpanModel(bool sectionsMoved)
++        : _sectionsMoved(sectionsMoved)
++    {}
++    int columnCount(const QModelIndex & = {}) const override { return 2; }
++    int rowCount(const QModelIndex & = {}) const override { return 1; }
++    QVariant data(const QModelIndex &idx, int role = Qt::DisplayRole) const override
++    {
++        if (role != Qt::DisplayRole)
++            return QVariant();
++        const int col = _sectionsMoved ? 1 - idx.column() : idx.column();
++        if (col == 0)
++            return "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.";
++        return QVariant();
++    }
++private:
++    bool _sectionsMoved;
++};
++
++
++void tst_QTableView::resizeToContentsSpans()
++{
++    SpanModel model1(false);
++    SpanModel model2(true);
++    QTableView view1, view2, view3;
++    view1.setModel(&model1);
++    view2.setModel(&model2);
++    view2.horizontalHeader()->moveSection(0, 1);
++    view3.setModel(&model1);
++
++    view1.setSpan(0, 0, 1, 2);
++    view2.setSpan(0, 1, 1, 2);
++    view1.show();
++    view2.show();
++    view3.show();
++    QVERIFY(QTest::qWaitForWindowExposed(&view1));
++    QVERIFY(QTest::qWaitForWindowExposed(&view2));
++    QVERIFY(QTest::qWaitForWindowExposed(&view3));
++    view1.setColumnWidth(0, 100);
++    view1.setColumnWidth(1, 100);
++    view2.setColumnWidth(0, 100);
++    view2.setColumnWidth(1, 100);
++    view3.setColumnWidth(0, 200);
++
++    view1.resizeRowToContents(0);
++    view2.resizeRowToContents(0);
++    view3.resizeRowToContents(0);
++    QCOMPARE(view1.rowHeight(0), view3.rowHeight(0));
++    QCOMPARE(view2.rowHeight(0), view3.rowHeight(0));
++
++    view3.resizeColumnToContents(0);
++    view3.resizeRowToContents(0);
++    // height should be only 1 text line for easy testing
++    view1.setRowHeight(0, view3.verticalHeader()->sectionSize(0));
++    view2.setRowHeight(0, view3.verticalHeader()->sectionSize(0));
++    view1.resizeColumnToContents(0);
++    view2.resizeColumnToContents(1);
++    QCOMPARE(view1.columnWidth(0), view3.columnWidth(0) - view1.columnWidth(1));
++    QCOMPARE(view2.columnWidth(0), view3.columnWidth(0) - view2.columnWidth(1));
++}
++
+ QT_BEGIN_NAMESPACE
+ extern bool Q_WIDGETS_EXPORT qt_tab_all_widgets(); // qapplication.cpp
+ QT_END_NAMESPACE
+diff --git a/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+index a3b8ef78d8..4955cebd5d 100644
+--- a/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
++++ b/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+@@ -1498,7 +1498,7 @@ void tst_QApplication::desktopSettingsAware()
+     environment += QLatin1String("QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM=1");
+     testProcess.setEnvironment(environment);
+ #endif
+-    testProcess.start("desktopsettingsaware_helper");
++    testProcess.start("./desktopsettingsaware_helper");
+     QVERIFY2(testProcess.waitForStarted(),
+              qPrintable(QString::fromLatin1("Cannot start 'desktopsettingsaware_helper': %1").arg(testProcess.errorString())));
+     QVERIFY(testProcess.waitForFinished(10000));
+@@ -2452,7 +2452,7 @@ void tst_QApplication::qtbug_12673()
+ #if QT_CONFIG(process)
+     QProcess testProcess;
+     QStringList arguments;
+-    testProcess.start("modal_helper", arguments);
++    testProcess.start("./modal_helper", arguments);
+     QVERIFY2(testProcess.waitForStarted(),
+              qPrintable(QString::fromLatin1("Cannot start 'modal_helper': %1").arg(testProcess.errorString())));
+     QVERIFY(testProcess.waitForFinished(20000));
+diff --git a/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp b/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
+index eb108a40de..dca5528c1b 100644
+--- a/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
+@@ -41,6 +41,7 @@
+ 
+ #include <private/qguiapplication_p.h>
+ #include <qpa/qplatformintegration.h>
++#include <qpa/qplatformtheme.h>
+ 
+ class tst_QAbstractButton : public QObject
+ {
+@@ -76,6 +77,8 @@ private slots:
+     void keyNavigation();
+ #endif
+ 
++    void buttonPressKeys();
++
+ protected slots:
+     void onClicked();
+     void onToggled( bool on );
+@@ -269,7 +272,13 @@ void tst_QAbstractButton::setAutoRepeat()
+         QCOMPARE(press_count, click_count);
+         QVERIFY(click_count > 1);
+         break;
+-    case 4:
++    case 4: {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(Qt::Key_Enter)) {
++            QSKIP("platform theme has Key_Enter in ButtonPressKeys");
++        }
+         // check that pressing ENTER has no effect when autorepeat is false
+         testWidget->setDown( false );
+         testWidget->setAutoRepeat( false );
+@@ -286,7 +295,14 @@ void tst_QAbstractButton::setAutoRepeat()
+ 
+         QVERIFY( click_count == 0 );
+         break;
+-    case 5:
++    }
++    case 5: {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(Qt::Key_Enter)) {
++            QSKIP("platform theme has Key_Enter in ButtonPressKeys");
++        }
+         // check that pressing ENTER has no effect when autorepeat is true
+         testWidget->setDown( false );
+         testWidget->setAutoRepeat( true );
+@@ -304,6 +320,7 @@ void tst_QAbstractButton::setAutoRepeat()
+ 
+         QVERIFY( click_count == 0 );
+         break;
++    }
+     case 6:
+         // verify autorepeat is off by default.
+         MyButton tmp( 0);
+@@ -651,5 +668,16 @@ void tst_QAbstractButton::keyNavigation()
+ }
+ #endif
+ 
++void tst_QAbstractButton::buttonPressKeys()
++{
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(testWidget, buttonPressKeys[i]);
++        QCOMPARE(click_count, i + 1);
++    }
++}
++
+ QTEST_MAIN(tst_QAbstractButton)
+ #include "tst_qabstractbutton.moc"
+diff --git a/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+index 32437050f5..46b5af6d63 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+@@ -168,6 +168,7 @@ private slots:
+     void checkMenuItemPosWhenStyleSheetIsSet();
+     void checkEmbeddedLineEditWhenStyleSheetIsSet();
+     void propagateStyleChanges();
++    void buttonPressKeys();
+ 
+ private:
+     PlatformInputContext m_platformInputContext;
+@@ -1682,6 +1683,16 @@ void tst_QComboBox::setModel()
+     QCOMPARE(box.rootModelIndex(), rootModelIndex);
+     box.setModel(box.model());
+     QCOMPARE(box.rootModelIndex(), rootModelIndex);
++
++    // check that setting the same model as the completer's doesn't crash
++    QCompleter *completer = new QCompleter(&box);
++    box.setEditable(true);
++    box.setCompleter(completer);
++    auto *listModel = new QStringListModel({ "one", "two" }, completer);
++    completer->setModel(listModel);
++    QCOMPARE(listModel->rowCount(), 2); // make sure it wasn't deleted
++    box.setModel(listModel);
++    QCOMPARE(listModel->rowCount(), 2); // make sure it wasn't deleted
+ }
+ 
+ void tst_QComboBox::setCustomModelAndView()
+@@ -3632,5 +3643,24 @@ void tst_QComboBox::propagateStyleChanges()
+     QVERIFY(frameStyle.inquired);
+ }
+ 
++void tst_QComboBox::buttonPressKeys()
++{
++    QComboBox comboBox;
++    comboBox.setEditable(false);
++    comboBox.addItem(QString::number(1));
++    comboBox.addItem(QString::number(2));
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(&comboBox, buttonPressKeys[i]);
++        // On some platforms, a window will not be immediately visible,
++        // but take some event-loop iterations to complete.
++        // Using QTRY_VERIFY to deal with that.
++        QTRY_VERIFY(comboBox.view()->isVisible());
++        comboBox.hidePopup();
++    }
++}
++
+ QTEST_MAIN(tst_QComboBox)
+ #include "tst_qcombobox.moc"
+diff --git a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
+index be3cfcd104..c228fdfcca 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
++++ b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qcommandlinkbutton
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qcommandlinkbutton.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
+index 0044d33c66..4cf06296e4 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
+@@ -40,6 +40,9 @@
+ #include <QGridLayout>
+ #include <QPainter>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ class tst_QCommandLinkButton : public QObject
+ {
+     Q_OBJECT
+@@ -223,6 +226,13 @@ void tst_QCommandLinkButton::setAutoRepeat()
+     // check that pressing ENTER has no effect
+     resetCounters();
+     testWidget->setDown( false );
++    // Skip after reset if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
+     testWidget->setAutoRepeat( false );
+     QTest::keyPress( testWidget, Qt::Key_Enter );
+ 
+@@ -255,6 +265,14 @@ void tst_QCommandLinkButton::pressed()
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+ 
++    // Skip if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
++
+     QTest::keyPress( testWidget,Qt::Key_Enter );
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+diff --git a/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro b/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
+index 4a5e76ff65..a235fa1fac 100644
+--- a/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
++++ b/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qgroupbox
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qgroupbox.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp b/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
+index 4fb5d262ca..d8d7562b73 100644
+--- a/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
+@@ -35,6 +35,9 @@
+ #include <QRadioButton>
+ #include <QDialog>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ #include "qgroupbox.h"
+ 
+ class tst_QGroupBox : public QObject
+@@ -69,6 +72,7 @@ private slots:
+     void propagateFocus();
+     void task_QTBUG_19170_ignoreMouseReleaseEvent();
+     void task_QTBUG_15519_propagateMouseEvents();
++    void buttonPressKeys();
+ 
+ private:
+     bool checked;
+@@ -610,6 +614,20 @@ void tst_QGroupBox::task_QTBUG_15519_propagateMouseEvents()
+     QCOMPARE(parent.mouseMoved, true);
+ }
+ 
++void tst_QGroupBox::buttonPressKeys()
++{
++    QGroupBox groupBox;
++    groupBox.setCheckable(true);
++    QSignalSpy clickedSpy(&groupBox, &QGroupBox::clicked);
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(&groupBox, buttonPressKeys[i]);
++        QCOMPARE(clickedSpy.length(), i + 1);
++    }
++}
++
+ void tst_QGroupBox::sendMouseMoveEvent(QWidget *widget, const QPoint &localPos)
+ {
+     // Send a MouseMove event without actually moving the pointer
+diff --git a/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro b/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
+index 353ad06ca2..e55f6148f2 100644
+--- a/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
++++ b/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qpushbutton
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qpushbutton.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp b/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
+index e818514a79..4043e9326a 100644
+--- a/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
+@@ -41,6 +41,9 @@
+ #include <QStyleFactory>
+ #include <QTabWidget>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ class tst_QPushButton : public QObject
+ {
+ Q_OBJECT
+@@ -212,6 +215,13 @@ void tst_QPushButton::autoRepeat()
+     // check that pressing ENTER has no effect
+     resetCounters();
+     testWidget->setDown( false );
++    // Skip after reset if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
+     testWidget->setAutoRepeat( false );
+     QTest::keyPress( testWidget, Qt::Key_Enter );
+ 
+@@ -247,6 +257,14 @@ void tst_QPushButton::pressed()
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+ 
++    // Skip if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
++
+     QTest::keyPress( testWidget,Qt::Key_Enter );
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+diff --git a/qtbase/tests/manual/rhi/cubemap_render/buildshader.bat b/qtbase/tests/manual/rhi/cubemap_render/buildshader.bat
+old mode 100755
+new mode 100644
+Submodule qtconnectivity e957d481..056294c0:
+diff --git a/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp b/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
+index e2635fae..a8b8e3b9 100644
+--- a/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
++++ b/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
+@@ -563,9 +563,11 @@ void HciManager::handleHciAclPacket(const quint8 *data, int size)
+ 
+ void HciManager::handleLeMetaEvent(const quint8 *data)
+ {
+-    // Spec v4.2, Vol 2, part E, 7.7.65ff
++    // Spec v5.3, Vol 4, part E, 7.7.65.*
+     switch (*data) {
+-    case 0x1: {
++    case 0x1: // HCI_LE_Connection_Complete
++    case 0xA: // HCI_LE_Enhanced_Connection_Complete
++    {
+         const quint16 handle = bt_get_le16(data + 2);
+         emit connectionComplete(handle);
+         break;
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp b/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
+index 6a93143b..4a18cfc7 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
+@@ -320,7 +320,10 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_finishSdpScan(QBluetoothServiceD
+             for (const QBluetoothUuid &id : serviceClassUuids) {
+                 if (id.minimumSize() == 16) {
+                     serviceInfo.setServiceUuid(id);
+-                    serviceInfo.setServiceName(QBluetoothServiceDiscoveryAgent::tr("Custom Service"));
++                    if (serviceInfo.serviceName().isEmpty()) {
++                        serviceInfo.setServiceName(
++                                    QBluetoothServiceDiscoveryAgent::tr("Custom Service"));
++                    }
+                     QBluetoothServiceInfo::Sequence modSeq =
+                             serviceInfo.attribute(QBluetoothServiceInfo::ServiceClassIds).value<QBluetoothServiceInfo::Sequence>();
+                     modSeq.removeOne(QVariant::fromValue(id));
+@@ -334,8 +337,10 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_finishSdpScan(QBluetoothServiceD
+                 qCDebug(QT_BT_BLUEZ) << "Discovered services" << discoveredDevices.at(0).address().toString()
+                                      << serviceInfo.serviceName() << serviceInfo.serviceUuid()
+                                      << ">>>" << serviceInfo.serviceClassUuids();
+-
+-                emit q->serviceDiscovered(serviceInfo);
++                // Use queued connection to allow us finish the service looping; the application
++                // might call stop() when it has detected the service-of-interest.
++                QMetaObject::invokeMethod(q, "serviceDiscovered", Qt::QueuedConnection,
++                                          Q_ARG(QBluetoothServiceInfo, serviceInfo));
+             }
+         }
+     }
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp b/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
+index e4d85447..aadd4755 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
+@@ -593,7 +593,7 @@ void QBluetoothSocket::setSocketState(QBluetoothSocket::SocketState state)
+ bool QBluetoothSocket::canReadLine() const
+ {
+     Q_D(const QBluetoothSocketBase);
+-    return d->canReadLine();
++    return d->canReadLine() || QIODevice::canReadLine();
+ }
+ 
+ /*!
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp b/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
+index 084aa958..d6aa17a7 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
+@@ -284,6 +284,10 @@ void QBluetoothSocketPrivateBluezDBus::connectToService(
+         return;
+     }
+ 
++    if (service.socketProtocol() != QBluetoothServiceInfo::Protocol::UnknownProtocol)
++        socketType = service.socketProtocol();
++    qCDebug(QT_BT_BLUEZ) << "Socket protocol used:" << socketType;
++
+     connectToService(service.device().address(), targetService, openMode);
+ }
+ 
+diff --git a/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp b/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
+index 05bc1a0f..a7b5ef1f 100644
+--- a/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
++++ b/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
+@@ -142,7 +142,7 @@ void tst_QBluetoothSocket::initTestCase()
+     qDebug() << "Starting discovery";
+ 
+     sda->setUuidFilter(QBluetoothUuid(QString(TEST_SERVICE_UUID)));
+-    sda->start(QBluetoothServiceDiscoveryAgent::MinimalDiscovery);
++    sda->start(QBluetoothServiceDiscoveryAgent::FullDiscovery);
+ 
+     for (int connectTime = MaxConnectTime; !done_discovery && connectTime > 0; connectTime -= 1000)
+         QTest::qWait(1000);
+Submodule qtdeclarative f5701f0d..8defe7bf:
+diff --git a/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h b/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
+index b65b994d6c..15a8cd6878 100644
+--- a/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
++++ b/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
+@@ -86,7 +86,7 @@ public:
+         if (QTypeInfo<T>::isComplex) {
+             for (int i = 0; i < count; ++i)
+                 new (data + i) T(vector.at(i));
+-        } else {
++        } else if (count) {
+             memcpy(data, static_cast<const void*>(vector.constData()), count * sizeof(T));
+         }
+     }
+diff --git a/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp b/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
+index e57cdd8278..94613598af 100644
+--- a/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
++++ b/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
+@@ -1145,8 +1145,7 @@ void Heap::QObjectWrapper::markObjects(Heap::Base *that, QV4::MarkStack *markSta
+ void QObjectWrapper::destroyObject(bool lastCall)
+ {
+     Heap::QObjectWrapper *h = d();
+-    if (!h->internalClass)
+-        return; // destroyObject already got called
++    Q_ASSERT(h->internalClass);
+ 
+     if (h->object()) {
+         QQmlData *ddata = QQmlData::get(h->object(), false);
+@@ -1176,7 +1175,7 @@ void QObjectWrapper::destroyObject(bool lastCall)
+         }
+     }
+ 
+-    h->~Data();
++    h->destroy();
+ }
+ 
+ 
+diff --git a/qtdeclarative/src/qml/memory/qv4mm.cpp b/qtdeclarative/src/qml/memory/qv4mm.cpp
+index 06caf04e5a..da149a67c4 100644
+--- a/qtdeclarative/src/qml/memory/qv4mm.cpp
++++ b/qtdeclarative/src/qml/memory/qv4mm.cpp
+@@ -981,7 +981,7 @@ void MemoryManager::sweep(bool lastSweep, ClassDestroyStatsCallback classCountPt
+ 
+     if (MultiplyWrappedQObjectMap *multiplyWrappedQObjects = engine->m_multiplyWrappedQObjects) {
+         for (MultiplyWrappedQObjectMap::Iterator it = multiplyWrappedQObjects->begin(); it != multiplyWrappedQObjects->end();) {
+-            if (!it.value().isNullOrUndefined())
++            if (it.value().isNullOrUndefined())
+                 it = multiplyWrappedQObjects->erase(it);
+             else
+                 ++it;
+diff --git a/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp b/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
+index 2079a8ed04..a577cb2351 100644
+--- a/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
++++ b/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
+@@ -389,6 +389,12 @@ void QQmlDelegateModelPrivate::connectToAbstractItemModel()
+                       q,  QQmlDelegateModel, SLOT(_q_rowsRemoved(QModelIndex,int,int)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
+                       q,  QQmlDelegateModel, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsInserted(QModelIndex,int,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsInserted(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsRemoved(QModelIndex,int,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsRemoved(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsMoved(QModelIndex,int,int,QModelIndex,int)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
+                       q, QQmlDelegateModel, SLOT(_q_dataChanged(QModelIndex,QModelIndex,QVector<int>)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
+@@ -413,6 +419,12 @@ void QQmlDelegateModelPrivate::disconnectFromAbstractItemModel()
+                         q, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int)));
+     QObject::disconnect(aim, SIGNAL(rowsRemoved(QModelIndex,int,int)),
+                         q, SLOT(_q_rowsRemoved(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsInserted(QModelIndex,int,int)), q,
++                        SLOT(_q_columnsInserted(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsRemoved(QModelIndex,int,int)), q,
++                        SLOT(_q_columnsRemoved(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)), q,
++                        SLOT(_q_columnsMoved(QModelIndex,int,int,QModelIndex,int)));
+     QObject::disconnect(aim, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
+                         q, SLOT(_q_dataChanged(QModelIndex,QModelIndex,QVector<int>)));
+     QObject::disconnect(aim, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
+@@ -1973,6 +1985,38 @@ void QQmlDelegateModel::_q_rowsMoved(
+     }
+ }
+ 
++void QQmlDelegateModel::_q_columnsInserted(const QModelIndex &parent, int begin, int end)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if (parent == d->m_adaptorModel.rootIndex && begin == 0) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
++void QQmlDelegateModel::_q_columnsRemoved(const QModelIndex &parent, int begin, int end)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if (parent == d->m_adaptorModel.rootIndex && begin == 0) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
++void QQmlDelegateModel::_q_columnsMoved(const QModelIndex &parent, int start, int end,
++                                        const QModelIndex &destination, int column)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if ((parent == d->m_adaptorModel.rootIndex && start == 0)
++        || (destination == d->m_adaptorModel.rootIndex && column == 0)) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
+ void QQmlDelegateModel::_q_dataChanged(const QModelIndex &begin, const QModelIndex &end, const QVector<int> &roles)
+ {
+     Q_D(QQmlDelegateModel);
+diff --git a/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h b/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
+index 8aab4badca..d140bfbaaf 100644
+--- a/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
++++ b/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
+@@ -152,6 +152,9 @@ private Q_SLOTS:
+     void _q_itemsMoved(int from, int to, int count);
+     void _q_modelReset();
+     void _q_rowsInserted(const QModelIndex &,int,int);
++    void _q_columnsInserted(const QModelIndex &, int, int);
++    void _q_columnsRemoved(const QModelIndex &, int, int);
++    void _q_columnsMoved(const QModelIndex &, int, int, const QModelIndex &, int);
+     void _q_rowsAboutToBeRemoved(const QModelIndex &parent, int begin, int end);
+     void _q_rowsRemoved(const QModelIndex &,int,int);
+     void _q_rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int);
+diff --git a/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp b/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
+index 85719fdc80..78e2ab302c 100644
+--- a/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
++++ b/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
+@@ -46,6 +46,7 @@
+ #include "QtQuick/private/qquicktextinput_p.h"
+ #include "QtQuick/private/qquickaccessibleattached_p.h"
+ #include "QtQuick/qquicktextdocument.h"
++#include "QtQuick/qquickrendercontrol.h"
+ QT_BEGIN_NAMESPACE
+ 
+ #if QT_CONFIG(accessibility)
+@@ -57,7 +58,19 @@ QAccessibleQuickItem::QAccessibleQuickItem(QQuickItem *item)
+ 
+ QWindow *QAccessibleQuickItem::window() const
+ {
+-    return item()->window();
++    QQuickWindow *window = item()->window();
++
++    // For QQuickWidget the above window will be the offscreen QQuickWindow,
++    // which is not a part of the accessibility tree. Detect this case and
++    // return the window for the QQuickWidget instead.
++    if (window && !window->handle()) {
++        if (QQuickRenderControl *renderControl = QQuickWindowPrivate::get(window)->renderControl) {
++            if (QWindow *renderWindow = renderControl->renderWindow(nullptr))
++                return renderWindow;
++        }
++    }
++
++    return window;
+ }
+ 
+ int QAccessibleQuickItem::childCount() const
+@@ -113,19 +126,15 @@ QAccessibleInterface *QAccessibleQuickItem::childAt(int x, int y) const
+ QAccessibleInterface *QAccessibleQuickItem::parent() const
+ {
+     QQuickItem *parent = item()->parentItem();
+-    QQuickWindow *window = item()->window();
+-    QQuickItem *ci = window ? window->contentItem() : nullptr;
++    QQuickWindow *itemWindow = item()->window();
++    QQuickItem *ci = itemWindow ? itemWindow->contentItem() : nullptr;
+     while (parent && !QQuickItemPrivate::get(parent)->isAccessible && parent != ci)
+         parent = parent->parentItem();
+ 
+     if (parent) {
+         if (parent == ci) {
+-            // Jump out to the scene widget if the parent is the root item.
+-            // There are two root items, QQuickWindow::rootItem and
+-            // QQuickView::declarativeRoot. The former is the true root item,
+-            // but is not a part of the accessibility tree. Check if we hit
+-            // it here and return an interface for the scene instead.
+-            return QAccessible::queryAccessibleInterface(window);
++            // Jump out to the window if the parent is the root item
++            return QAccessible::queryAccessibleInterface(window());
+         } else {
+             while (parent && !parent->d_func()->isAccessible)
+                 parent = parent->parentItem();
+@@ -188,7 +197,7 @@ QAccessible::State QAccessibleQuickItem::state() const
+     QRect viewRect_ = viewRect();
+     QRect itemRect = rect();
+ 
+-    if (viewRect_.isNull() || itemRect.isNull() || !item()->window() || !item()->window()->isVisible() ||!item()->isVisible() || qFuzzyIsNull(item()->opacity()))
++    if (viewRect_.isNull() || itemRect.isNull() || !window() || !window()->isVisible() ||!item()->isVisible() || qFuzzyIsNull(item()->opacity()))
+         state.invisible = true;
+     if (!viewRect_.intersects(itemRect))
+         state.offscreen = true;
+@@ -201,6 +210,10 @@ QAccessible::State QAccessibleQuickItem::state() const
+     if (role() == QAccessible::EditableText)
+         if (auto ti = qobject_cast<QQuickTextInput *>(item()))
+             state.passwordEdit = ti->echoMode() != QQuickTextInput::Normal;
++    if (!item()->isEnabled()) {
++        state.focusable = false;
++        state.disabled = true;
++    }
+     return state;
+ }
+ 
+diff --git a/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h b/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
+index 39ffcaf39c..8baa01330c 100644
+--- a/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
++++ b/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
+@@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE
+ 
+ #if QT_CONFIG(accessibility)
+ 
+-class QAccessibleQuickWindow : public QAccessibleObject
++class Q_QUICK_EXPORT QAccessibleQuickWindow : public QAccessibleObject
+ {
+ public:
+     QAccessibleQuickWindow(QQuickWindow *object);
+diff --git a/qtdeclarative/src/quick/items/qquickdrag.cpp b/qtdeclarative/src/quick/items/qquickdrag.cpp
+index 8321fcfeed..383078b3b9 100644
+--- a/qtdeclarative/src/quick/items/qquickdrag.cpp
++++ b/qtdeclarative/src/quick/items/qquickdrag.cpp
+@@ -481,7 +481,9 @@ void QQuickDragAttached::setKeys(const QStringList &keys)
+     \qmlattachedproperty stringlist QtQuick::Drag::mimeData
+     \since 5.2
+ 
+-    This property holds a map of mimeData that is used during startDrag.
++    This property holds a map from mime type to data that is used during startDrag.
++    The mime data needs to be a \c string, or an \c ArrayBuffer with the data encoded
++    according to the mime type.
+ */
+ 
+ QVariantMap QQuickDragAttached::mimeData() const
+@@ -766,8 +768,12 @@ Qt::DropAction QQuickDragAttachedPrivate::startDrag(Qt::DropActions supportedAct
+     QDrag *drag = new QDrag(source ? source : q);
+     QMimeData *mimeData = new QMimeData();
+ 
+-    for (auto it = externalMimeData.cbegin(), end = externalMimeData.cend(); it != end; ++it)
+-        mimeData->setData(it.key(), it.value().toString().toUtf8());
++    for (auto it = externalMimeData.cbegin(), end = externalMimeData.cend(); it != end; ++it) {
++        if (static_cast<QMetaType::Type>(it.value().type()) == QMetaType::QByteArray)
++            mimeData->setData(it.key(), it.value().toByteArray());
++        else
++            mimeData->setData(it.key(), it.value().toString().toUtf8());
++    }
+ 
+     drag->setMimeData(mimeData);
+     if (pixmapLoader.isReady()) {
+diff --git a/qtdeclarative/src/quick/items/qquickitem.cpp b/qtdeclarative/src/quick/items/qquickitem.cpp
+index 75f1457816..dec0ae19ae 100644
+--- a/qtdeclarative/src/quick/items/qquickitem.cpp
++++ b/qtdeclarative/src/quick/items/qquickitem.cpp
+@@ -59,6 +59,7 @@
+ #include <QtCore/private/qnumeric_p.h>
+ #include <QtGui/qpa/qplatformtheme.h>
+ #include <QtCore/qloggingcategory.h>
++#include <QtCore/private/qduplicatetracker_p.h>
+ 
+ #include <private/qqmlglobal_p.h>
+ #include <private/qqmlengine_p.h>
+@@ -2326,6 +2327,7 @@ QQuickItem::QQuickItem(QQuickItemPrivate &dd, QQuickItem *parent)
+ QQuickItem::~QQuickItem()
+ {
+     Q_D(QQuickItem);
++    d->inDestructor = true;
+ 
+     if (d->windowRefCount > 1)
+         d->windowRefCount = 1; // Make sure window is set to null in next call to derefWindow().
+@@ -2526,6 +2528,7 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo
+     QQuickItem *current = item;
+     qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: startItem:" << startItem;
+     qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: firstFromItem:" << firstFromItem;
++    QDuplicateTracker<QQuickItem *> cycleDetector;
+     do {
+         qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: current:" << current;
+         qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: from:" << from;
+@@ -2592,7 +2595,10 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo
+         // traversed all of the chain (by compare the [current] item with [startItem])
+         // Since the [startItem] might be promoted to its parent if it is invisible,
+         // we still have to check [current] item with original start item
+-        if ((current == startItem || current == originalStartItem) && from == firstFromItem) {
++        // We might also run into a cycle before we reach firstFromItem again
++        // but note that we have to ignore current if we are meant to skip it
++        if (((current == startItem || current == originalStartItem) && from == firstFromItem) ||
++                (!skip && cycleDetector.hasSeen(current))) {
+             // wrapped around, avoid endless loops
+             if (item == contentItem) {
+                 qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: looped, return contentItem";
+@@ -2689,9 +2695,8 @@ void QQuickItem::setParentItem(QQuickItem *parentItem)
+ 
+         const bool wasVisible = isVisible();
+         op->removeChild(this);
+-        if (wasVisible) {
++        if (wasVisible && !op->inDestructor)
+             emit oldParentItem->visibleChildrenChanged();
+-        }
+     } else if (d->window) {
+         QQuickWindowPrivate::get(d->window)->parentlessItems.remove(this);
+     }
+@@ -2768,8 +2773,9 @@ void QQuickItem::setParentItem(QQuickItem *parentItem)
+ 
+     d->itemChange(ItemParentHasChanged, d->parentItem);
+ 
+-    emit parentChanged(d->parentItem);
+-    if (isVisible() && d->parentItem)
++    if (!d->inDestructor)
++        emit parentChanged(d->parentItem);
++    if (isVisible() && d->parentItem && !QQuickItemPrivate::get(d->parentItem)->inDestructor)
+         emit d->parentItem->visibleChildrenChanged();
+ }
+ 
+@@ -2965,7 +2971,8 @@ void QQuickItemPrivate::removeChild(QQuickItem *child)
+ 
+     itemChange(QQuickItem::ItemChildRemovedChange, child);
+ 
+-    emit q->childrenChanged();
++    if (!inDestructor)
++        emit q->childrenChanged();
+ }
+ 
+ void QQuickItemPrivate::refWindow(QQuickWindow *c)
+@@ -3194,6 +3201,7 @@ QQuickItemPrivate::QQuickItemPrivate()
+     , touchEnabled(false)
+ #endif
+     , hasCursorHandler(false)
++    , inDestructor(false)
+     , dirtyAttributes(0)
+     , nextDirtyItem(nullptr)
+     , prevDirtyItem(nullptr)
+@@ -5120,6 +5128,13 @@ void QQuickItem::componentComplete()
+         d->addToDirtyList();
+         QQuickWindowPrivate::get(d->window)->dirtyItem(this);
+     }
++
++#if QT_CONFIG(accessibility)
++    if (d->isAccessible && d->effectiveVisible) {
++        QAccessibleEvent ev(this, QAccessible::ObjectShow);
++        QAccessible::updateAccessibility(&ev);
++    }
++#endif
+ }
+ 
+ QQuickStateGroup *QQuickItemPrivate::_states()
+@@ -6106,9 +6121,11 @@ bool QQuickItemPrivate::setEffectiveVisibleRecur(bool newEffectiveVisible)
+         QAccessible::updateAccessibility(&ev);
+     }
+ #endif
+-    emit q->visibleChanged();
+-    if (childVisibilityChanged)
+-        emit q->visibleChildrenChanged();
++    if (!inDestructor) {
++        emit q->visibleChanged();
++        if (childVisibilityChanged)
++            emit q->visibleChildrenChanged();
++    }
+ 
+     return true;    // effective visibility DID change
+ }
+@@ -6157,6 +6174,15 @@ void QQuickItemPrivate::setEffectiveEnableRecur(QQuickItem *scope, bool newEffec
+     }
+ 
+     itemChange(QQuickItem::ItemEnabledHasChanged, effectiveEnable);
++#if QT_CONFIG(accessibility)
++    if (isAccessible) {
++        QAccessible::State changedState;
++        changedState.disabled = true;
++        changedState.focusable = true;
++        QAccessibleStateChangeEvent ev(q, changedState);
++        QAccessible::updateAccessibility(&ev);
++    }
++#endif
+     emit q->enabledChanged();
+ }
+ 
+diff --git a/qtdeclarative/src/quick/items/qquickitem_p.h b/qtdeclarative/src/quick/items/qquickitem_p.h
+index 841d91bb40..ade8fb61f2 100644
+--- a/qtdeclarative/src/quick/items/qquickitem_p.h
++++ b/qtdeclarative/src/quick/items/qquickitem_p.h
+@@ -472,6 +472,7 @@ public:
+     bool replayingPressEvent:1;
+     bool touchEnabled:1;
+     bool hasCursorHandler:1;
++    quint32 inDestructor:1; // has entered ~QQuickItem
+ 
+     enum DirtyType {
+         TransformOrigin         = 0x00000001,
+diff --git a/qtdeclarative/src/quick/items/qquickitemview.cpp b/qtdeclarative/src/quick/items/qquickitemview.cpp
+index 010a0152e1..f8ad168a17 100644
+--- a/qtdeclarative/src/quick/items/qquickitemview.cpp
++++ b/qtdeclarative/src/quick/items/qquickitemview.cpp
+@@ -1785,7 +1785,7 @@ void QQuickItemViewPrivate::refill(qreal from, qreal to)
+ 
+     do {
+         bufferPause.stop();
+-        if (currentChanges.hasPendingChanges() || bufferedChanges.hasPendingChanges()) {
++        if (currentChanges.hasPendingChanges() || bufferedChanges.hasPendingChanges() || currentChanges.active) {
+             currentChanges.reset();
+             bufferedChanges.reset();
+             releaseVisibleItems(reusableFlag);
+diff --git a/qtdeclarative/src/quick/items/qquickmousearea_p_p.h b/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
+index fba383e268..0d63618622 100644
+--- a/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
++++ b/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
+@@ -61,7 +61,6 @@ QT_BEGIN_NAMESPACE
+ 
+ class QQuickMouseEvent;
+ class QQuickMouseArea;
+-class QQuickPointerMask;
+ class QQuickMouseAreaPrivate : public QQuickItemPrivate
+ {
+     Q_DECLARE_PUBLIC(QQuickMouseArea)
+@@ -100,7 +99,6 @@ public:
+ #if QT_CONFIG(quick_draganddrop)
+     QQuickDrag *drag;
+ #endif
+-    QPointer<QQuickPointerMask> mask;
+     QPointF startScene;
+     QPointF targetStartPos;
+     QPointF lastPos;
+diff --git a/qtdeclarative/src/quick/items/qquicktext.cpp b/qtdeclarative/src/quick/items/qquicktext.cpp
+index 6230186933..e823ca1095 100644
+--- a/qtdeclarative/src/quick/items/qquicktext.cpp
++++ b/qtdeclarative/src/quick/items/qquicktext.cpp
+@@ -2168,7 +2168,7 @@ void QQuickText::resetMaximumLineCount()
+     <img src="" align="top,middle,bottom" width="" height=""> - inline images
+     <ol type="">, <ul type=""> and <li> - ordered and unordered lists
+     <pre></pre> - preformatted
+-    &gt; &lt; &amp;
++    &gt; &lt; &amp; &quot; &nbsp; &apos;
+     \endcode
+ 
+     \c Text.StyledText parser is strict, requiring tags to be correctly nested.
+diff --git a/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp b/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
+index eb4db0f85e..2325a2665b 100644
+--- a/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
++++ b/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
+@@ -446,7 +446,7 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+         const char *textureRecord = allocatorData;
+         for (int i = 0; i < textureCount; ++i, textureRecord += Qtdf::TextureRecordSize) {
+-            if (textureRecord + Qtdf::TextureRecordSize > qtdfTableEnd) {
++            if (qtdfTableEnd - textureRecord < Qtdf::TextureRecordSize) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+@@ -462,7 +462,7 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+         const char *glyphRecord = textureRecord;
+         for (quint32 i = 0; i < glyphCount; ++i, glyphRecord += Qtdf::GlyphRecordSize) {
+-            if (glyphRecord + Qtdf::GlyphRecordSize > qtdfTableEnd) {
++            if (qtdfTableEnd - glyphRecord < Qtdf:: GlyphRecordSize) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+@@ -512,8 +512,8 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+             int width = texInfo->allocatedArea.width();
+             int height = texInfo->allocatedArea.height();
+-            qint64 size = width * height;
+-            if (reinterpret_cast<const char *>(textureData + size) > qtdfTableEnd) {
++            qint64 size = qint64(width) * height;
++            if (qtdfTableEnd - reinterpret_cast<const char *>(textureData) < size) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+diff --git a/qtdeclarative/src/quick/util/qquickstyledtext.cpp b/qtdeclarative/src/quick/util/qquickstyledtext.cpp
+index d531fc9205..a25af90414 100644
+--- a/qtdeclarative/src/quick/util/qquickstyledtext.cpp
++++ b/qtdeclarative/src/quick/util/qquickstyledtext.cpp
+@@ -564,6 +564,8 @@ void QQuickStyledTextPrivate::parseEntity(const QChar *&ch, const QString &textI
+                 textOut += QChar(60);
+             else if (entity == QLatin1String("amp"))
+                 textOut += QChar(38);
++            else if (entity == QLatin1String("apos"))
++                textOut += QChar(39);
+             else if (entity == QLatin1String("quot"))
+                 textOut += QChar(34);
+             else if (entity == QLatin1String("nbsp"))
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp
+new file mode 100644
+index 0000000000..8a1c901880
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp
+@@ -0,0 +1,110 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include "qaccessiblequickwidget_p.h"
++
++#include "qquickwidget_p.h"
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleQuickWidget::QAccessibleQuickWidget(QQuickWidget* widget)
++: QAccessibleWidget(widget)
++, m_accessibleWindow(QQuickWidgetPrivate::get(widget)->offscreenWindow)
++{
++    // NOTE: m_accessibleWindow is a QAccessibleQuickWindow, and not a
++    // QAccessibleQuickWidgetOffscreenWindow (defined below). This means
++    // it will return the Quick item child interfaces, which is what's needed here
++    // (unlike QAccessibleQuickWidgetOffscreenWindow, which will report 0 children).
++}
++
++QAccessibleInterface *QAccessibleQuickWidget::child(int index) const
++{
++    return m_accessibleWindow.child(index);
++}
++
++int QAccessibleQuickWidget::childCount() const
++{
++    return m_accessibleWindow.childCount();
++}
++
++int QAccessibleQuickWidget::indexOfChild(const QAccessibleInterface *iface) const
++{
++    return m_accessibleWindow.indexOfChild(iface);
++}
++
++QAccessibleInterface *QAccessibleQuickWidget::childAt(int x, int y) const
++{
++    return m_accessibleWindow.childAt(x, y);
++}
++
++QAccessibleQuickWidgetOffscreenWindow::QAccessibleQuickWidgetOffscreenWindow(QQuickWindow *window)
++:QAccessibleQuickWindow(window)
++{
++
++}
++
++QAccessibleInterface *QAccessibleQuickWidgetOffscreenWindow::child(int index) const
++{
++    Q_UNUSED(index);
++    return nullptr;
++}
++
++int QAccessibleQuickWidgetOffscreenWindow::childCount() const
++{
++    return 0;
++}
++
++int QAccessibleQuickWidgetOffscreenWindow::indexOfChild(const QAccessibleInterface *iface) const
++{
++    Q_UNUSED(iface);
++    return -1;
++}
++
++QAccessibleInterface *QAccessibleQuickWidgetOffscreenWindow::QAccessibleQuickWidgetOffscreenWindow::childAt(int x, int y) const
++{
++    Q_UNUSED(x);
++    Q_UNUSED(y);
++    return nullptr;
++}
++
++#endif // accessibility
++
++QT_END_NAMESPACE
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h
+new file mode 100644
+index 0000000000..7c2ab930e0
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h
+@@ -0,0 +1,95 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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 QACCESSIBLEQUICKWIDGET_H
++#define QACCESSIBLEQUICKWIDGET_H
++
++//
++//  W A R N I N G
++//  -------------
++//
++// This file is not part of the Qt API.  It exists purely as an
++// implementation detail.  This header file may change from version to
++// version without notice, or even be removed.
++//
++// We mean it.
++//
++
++#include "qquickwidget.h"
++#include <QtWidgets/qaccessiblewidget.h>
++
++#include <private/qaccessiblequickview_p.h>
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++// These classes implement the QQuickWiget accessibility switcharoo,
++// where the child items of the QQuickWidgetOffscreenWindow are reported
++// as child accessible interfaces of the QAccessibleQuickWidget.
++class QAccessibleQuickWidget: public QAccessibleWidget
++{
++public:
++    QAccessibleQuickWidget(QQuickWidget* widget);
++
++    QAccessibleInterface *child(int index) const override;
++    int childCount() const override;
++    int indexOfChild(const QAccessibleInterface *iface) const override;
++    QAccessibleInterface *childAt(int x, int y) const override;
++
++private:
++    QAccessibleQuickWindow m_accessibleWindow;
++    Q_DISABLE_COPY(QAccessibleQuickWidget)
++};
++
++class QAccessibleQuickWidgetOffscreenWindow: public QAccessibleQuickWindow
++{
++public:
++    QAccessibleQuickWidgetOffscreenWindow(QQuickWindow *window);
++    QAccessibleInterface *child(int index) const override;
++    int childCount() const override;
++    int indexOfChild(const QAccessibleInterface *iface) const override;
++    QAccessibleInterface *childAt(int x, int y) const override;
++};
++
++#endif // accessibility
++
++QT_END_NAMESPACE
++
++#endif
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp
+new file mode 100644
+index 0000000000..7ba88a1769
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp
+@@ -0,0 +1,60 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include "qaccessiblequickwidgetfactory_p.h"
++#include "qaccessiblequickwidget_p.h"
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleInterface *qAccessibleQuickWidgetFactory(const QString &classname, QObject *object)
++{
++    if (classname == QLatin1String("QQuickWidget")) {
++        return new QAccessibleQuickWidget(qobject_cast<QQuickWidget *>(object));
++    } else if (classname == QLatin1String("QQuickWidgetOffscreenWindow")) {
++        return new QAccessibleQuickWidgetOffscreenWindow(qobject_cast<QQuickWindow *>(object));
++    }
++    return 0;
++}
++
++#endif // accessibility
++
++QT_END_NAMESPACE
++
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h
+new file mode 100644
+index 0000000000..8c63b09f81
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h
+@@ -0,0 +1,66 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include <QtGui/qaccessible.h>
++
++#ifndef QACCESSIBLEQUICKWIDGETFACTORY_H
++#define QACCESSIBLEQUICKWIDGETFACTORY_H
++
++//
++//  W A R N I N G
++//  -------------
++//
++// This file is not part of the Qt API.  It exists purely as an
++// implementation detail.  This header file may change from version to
++// version without notice, or even be removed.
++//
++// We mean it.
++//
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleInterface *qAccessibleQuickWidgetFactory(const QString &classname, QObject *object);
++
++#endif
++
++QT_END_NAMESPACE
++
++#endif
+diff --git a/qtdeclarative/src/quickwidgets/qquickwidget.cpp b/qtdeclarative/src/quickwidgets/qquickwidget.cpp
+index 39780f8de3..9c97b43518 100644
+--- a/qtdeclarative/src/quickwidgets/qquickwidget.cpp
++++ b/qtdeclarative/src/quickwidgets/qquickwidget.cpp
+@@ -39,6 +39,7 @@
+ 
+ #include "qquickwidget.h"
+ #include "qquickwidget_p.h"
++#include "qaccessiblequickwidgetfactory_p.h"
+ 
+ #include "private/qquickwindow_p.h"
+ #include "private/qquickitem_p.h"
+@@ -75,9 +76,16 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++QQuickWidgetOffscreenWindow::QQuickWidgetOffscreenWindow(QQuickWindowPrivate &dd, QQuickRenderControl *control)
++:QQuickWindow(dd, control)
++{
++    setTitle(QString::fromLatin1("Offscreen"));
++    setObjectName(QString::fromLatin1("QQuickOffScreenWindow"));
++}
++
+ // override setVisble to prevent accidental offscreen window being created
+ // by base class.
+-class QQuickOffcreenWindowPrivate: public QQuickWindowPrivate {
++class QQuickWidgetOffscreenWindowPrivate: public QQuickWindowPrivate {
+ public:
+     void setVisible(bool visible) override {
+         Q_Q(QWindow);
+@@ -105,9 +113,8 @@ void QQuickWidgetPrivate::init(QQmlEngine* e)
+     Q_Q(QQuickWidget);
+ 
+     renderControl = new QQuickWidgetRenderControl(q);
+-    offscreenWindow = new QQuickWindow(*new QQuickOffcreenWindowPrivate(),renderControl);
+-    offscreenWindow->setTitle(QString::fromLatin1("Offscreen"));
+-    offscreenWindow->setObjectName(QString::fromLatin1("QQuickOffScreenWindow"));
++    offscreenWindow = new QQuickWidgetOffscreenWindow(*new QQuickWidgetOffscreenWindowPrivate(), renderControl);
++    offscreenWindow->setScreen(q->screen());
+     // Do not call create() on offscreenWindow.
+ 
+     // Check if the Software Adaptation is being used
+@@ -138,6 +145,10 @@ void QQuickWidgetPrivate::init(QQmlEngine* e)
+     QWidget::connect(offscreenWindow, &QQuickWindow::focusObjectChanged, q, &QQuickWidget::propagateFocusObjectChanged);
+     QObject::connect(renderControl, SIGNAL(renderRequested()), q, SLOT(triggerUpdate()));
+     QObject::connect(renderControl, SIGNAL(sceneChanged()), q, SLOT(triggerUpdate()));
++
++#if QT_CONFIG(accessibility)
++    QAccessible::installFactory(&qAccessibleQuickWidgetFactory);
++#endif
+ }
+ 
+ void QQuickWidgetPrivate::ensureEngine() const
+@@ -901,9 +912,7 @@ void QQuickWidgetPrivate::createContext()
+ 
+         context = new QOpenGLContext;
+         context->setFormat(offscreenWindow->requestedFormat());
+-        const QWindow *win = q->window()->windowHandle();
+-        if (win && win->screen())
+-            context->setScreen(win->screen());
++        context->setScreen(q->screen());
+         QOpenGLContext *shareContext = qt_gl_global_share_context();
+         if (!shareContext)
+             shareContext = QWidgetPrivate::get(q->window())->shareContext();
+@@ -1520,19 +1529,16 @@ bool QQuickWidget::event(QEvent *e)
+         d->handleWindowChange();
+         break;
+ 
+-    case QEvent::ScreenChangeInternal:
+-        if (QWindow *window = this->window()->windowHandle()) {
+-            QScreen *newScreen = window->screen();
+-
+-            if (d->offscreenWindow)
+-                d->offscreenWindow->setScreen(newScreen);
+-            if (d->offscreenSurface)
+-                d->offscreenSurface->setScreen(newScreen);
++    case QEvent::ScreenChangeInternal: {
++        QScreen *newScreen = screen();
++        if (d->offscreenWindow)
++            d->offscreenWindow->setScreen(newScreen);
++        if (d->offscreenSurface)
++            d->offscreenSurface->setScreen(newScreen);
+ #if QT_CONFIG(opengl)
+-            if (d->context)
+-                d->context->setScreen(newScreen);
++        if (d->context)
++            d->context->setScreen(newScreen);
+ #endif
+-        }
+ 
+         if (d->useSoftwareRenderer
+ #if QT_CONFIG(opengl)
+@@ -1545,7 +1551,7 @@ bool QQuickWidget::event(QEvent *e)
+             d->render(true);
+         }
+         break;
+-
++    }
+     case QEvent::Show:
+     case QEvent::Move:
+         d->updatePosition();
+diff --git a/qtdeclarative/src/quickwidgets/qquickwidget_p.h b/qtdeclarative/src/quickwidgets/qquickwidget_p.h
+index 881f7f9220..1a946bcc71 100644
+--- a/qtdeclarative/src/quickwidgets/qquickwidget_p.h
++++ b/qtdeclarative/src/quickwidgets/qquickwidget_p.h
+@@ -148,6 +148,14 @@ public:
+     bool forceFullUpdate;
+ };
+ 
++class QQuickWidgetOffscreenWindow: public QQuickWindow
++{
++    Q_OBJECT
++
++public:
++    QQuickWidgetOffscreenWindow(QQuickWindowPrivate &dd, QQuickRenderControl *control);
++};
++
+ QT_END_NAMESPACE
+ 
+ #endif // QQuickWidget_P_H
+diff --git a/qtdeclarative/src/quickwidgets/quickwidgets.pro b/qtdeclarative/src/quickwidgets/quickwidgets.pro
+index 2438e577ae..85d156b8a3 100644
+--- a/qtdeclarative/src/quickwidgets/quickwidgets.pro
++++ b/qtdeclarative/src/quickwidgets/quickwidgets.pro
+@@ -7,9 +7,13 @@ DEFINES   += QT_NO_URL_CAST_FROM_STRING QT_NO_INTEGER_EVENT_COORDINATES QT_NO_FO
+ HEADERS += \
+     qquickwidget.h \
+     qquickwidget_p.h \
+-    qtquickwidgetsglobal.h
++    qtquickwidgetsglobal.h \
++    qaccessiblequickwidget_p.h \
++    qaccessiblequickwidgetfactory_p.h
+ 
+ SOURCES += \
+-    qquickwidget.cpp
++    qquickwidget.cpp \
++    qaccessiblequickwidget.cpp \
++    qaccessiblequickwidgetfactory.cpp
+ 
+ load(qt_module)
+diff --git a/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+index 3b7d74df63..b75bf820d5 100644
+--- a/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
++++ b/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+@@ -102,6 +102,7 @@ private slots:
+     void valueConversion_RegularExpression();
+     void castWithMultipleInheritance();
+     void collectGarbage();
++    void collectGarbageNestedWrappersTwoEngines();
+     void gcWithNestedDataStructure();
+     void stacktrace();
+     void numberParsing_data();
+@@ -1809,6 +1810,44 @@ void tst_QJSEngine::collectGarbage()
+     QVERIFY(ptr.isNull());
+ }
+ 
++class TestObjectContainer : public QObject
++{
++    Q_OBJECT
++    Q_PROPERTY(QObject *dummy MEMBER m_dummy CONSTANT)
++
++public:
++    TestObjectContainer() : m_dummy(new QObject(this)) {}
++
++private:
++    QObject *m_dummy;
++};
++
++void tst_QJSEngine::collectGarbageNestedWrappersTwoEngines()
++{
++    QJSEngine engine1;
++    QJSEngine engine2;
++
++    TestObjectContainer container;
++    QQmlEngine::setObjectOwnership(&container, QQmlEngine::CppOwnership);
++
++    engine1.globalObject().setProperty("foobar", engine1.newQObject(&container));
++    engine2.globalObject().setProperty("foobar", engine2.newQObject(&container));
++
++    engine1.evaluate("foobar.dummy.baz = 42");
++    engine2.evaluate("foobar.dummy.baz = 43");
++
++    QCOMPARE(engine1.evaluate("foobar.dummy.baz").toInt(), 42);
++    QCOMPARE(engine2.evaluate("foobar.dummy.baz").toInt(), 43);
++
++    engine1.collectGarbage();
++    engine2.collectGarbage();
++
++    // The GC should not collect dummy object wrappers neither in engine1 nor engine2, we
++    // verify that by checking whether the baz property still has its previous value.
++    QCOMPARE(engine1.evaluate("foobar.dummy.baz").toInt(), 42);
++    QCOMPARE(engine2.evaluate("foobar.dummy.baz").toInt(), 43);
++}
++
+ void tst_QJSEngine::gcWithNestedDataStructure()
+ {
+     // The GC must be able to traverse deeply nested objects, otherwise this
+diff --git a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml
+new file mode 100644
+index 0000000000..206133bb39
+--- /dev/null
++++ b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml
+@@ -0,0 +1,11 @@
++import QtQuick 2.8
++
++ListView {
++    id: root
++    width: 200
++    height: 200
++
++    delegate: Text {
++        text: display
++    }
++}
+diff --git a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
+index 35f1e2c94d..1722447830 100644
+--- a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
++++ b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
+@@ -27,6 +27,8 @@
+ ****************************************************************************/
+ 
+ #include <QtTest/qtest.h>
++#include <QtCore/QConcatenateTablesProxyModel>
++#include <QtGui/QStandardItemModel>
+ #include <QtQml/qqmlcomponent.h>
+ #include <QtQmlModels/private/qqmldelegatemodel_p.h>
+ #include <QtQuick/qquickview.h>
+@@ -47,6 +49,7 @@ private slots:
+     void filterOnGroup_removeWhenCompleted();
+     void qtbug_86017();
+     void contextAccessedByHandler();
++    void redrawUponColumnChange();
+ };
+ 
+ class AbstractItemModel : public QAbstractItemModel
+@@ -186,6 +189,30 @@ void tst_QQmlDelegateModel::contextAccessedByHandler()
+     QVERIFY(root->property("works").toBool());
+ }
+ 
++void tst_QQmlDelegateModel::redrawUponColumnChange()
++{
++    QStandardItemModel m1;
++    m1.appendRow({
++            new QStandardItem("Banana"),
++            new QStandardItem("Coconut"),
++    });
++
++    QQuickView view(testFileUrl("redrawUponColumnChange.qml"));
++    QCOMPARE(view.status(), QQuickView::Ready);
++    view.show();
++    QQuickItem *root = view.rootObject();
++    root->setProperty("model", QVariant::fromValue<QObject *>(&m1));
++
++    QObject *item = root->property("currentItem").value<QObject *>();
++    QVERIFY(item);
++    QCOMPARE(item->property("text").toString(), "Banana");
++
++    QVERIFY(root);
++    m1.removeColumn(0);
++
++    QCOMPARE(item->property("text").toString(), "Coconut");
++}
++
+ QTEST_MAIN(tst_QQmlDelegateModel)
+ 
+ #include "tst_qqmldelegatemodel.moc"
+diff --git a/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp b/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
+index 5d635aa63b..824fd89e5b 100644
+--- a/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
++++ b/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
+@@ -76,10 +76,10 @@ void tst_qv4mm::multiWrappedQObjects()
+         QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 1);
+         QCOMPARE(engine2.memoryManager->m_pendingFreedObjectWrapperValue.size(), 0);
+ 
+-        // Moves the additional WeakValue from m_multiplyWrappedQObjects to
+-        // m_pendingFreedObjectWrapperValue. It's still alive after all.
++        // The additional WeakValue from m_multiplyWrappedQObjects hasn't been moved
++        // to m_pendingFreedObjectWrapperValue yet. It's still alive after all.
+         engine1.memoryManager->runGC();
+-        QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 2);
++        QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 1);
+ 
+         // engine2 doesn't own the object as engine1 was the first to wrap it above.
+         // Therefore, no effect here.
+diff --git a/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml b/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml
+new file mode 100644
+index 0000000000..889e480f3b
+--- /dev/null
++++ b/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml
+@@ -0,0 +1,13 @@
++import QtQuick 2.6
++
++Item {
++    visible: true
++    Item {
++        visible: false
++        Item {
++            objectName: "hiddenChild"
++            activeFocusOnTab: true
++            focus: true
++        }
++    }
++}
+diff --git a/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp b/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+index c8f251dbe1..c8ef36ee68 100644
+--- a/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
++++ b/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+@@ -67,6 +67,7 @@ private slots:
+     void activeFocusOnTab10();
+     void activeFocusOnTab_infiniteLoop_data();
+     void activeFocusOnTab_infiniteLoop();
++    void activeFocusOnTab_infiniteLoopControls();
+ 
+     void nextItemInFocusChain();
+     void nextItemInFocusChain2();
+@@ -1057,6 +1058,17 @@ void tst_QQuickItem::activeFocusOnTab_infiniteLoop()
+     QCOMPARE(item, window->rootObject());
+ }
+ 
++
++void tst_QQuickItem::activeFocusOnTab_infiniteLoopControls()
++{
++    auto source = testFileUrl("activeFocusOnTab_infiniteLoop3.qml");
++    QScopedPointer<QQuickView>window(new QQuickView());
++    window->setSource(source);
++    window->show();
++    QVERIFY(window->errors().isEmpty());
++    QTest::keyClick(window.get(), Qt::Key_Tab); // should not hang
++}
++
+ void tst_QQuickItem::nextItemInFocusChain()
+ {
+     if (!qt_tab_all_widgets())
+Submodule qtdoc c0c7bf07...79d6ef69:
+Submodule qtimageformats 2dcf2899..abe44c0f:
+diff --git a/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp b/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
+index dde783c..1bf9074 100644
+--- a/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
+@@ -462,8 +462,12 @@ static bool parseIconEntryInfo(ICNSEntry &icon)
+     if (isIconCompressed(icon))
+         return true;
+     // Icon depth:
+-    if (!depth.isEmpty())
+-        icon.depth = ICNSEntry::Depth(depth.toUInt());
++    if (!depth.isEmpty()) {
++        const uint depthUInt = depth.toUInt();
++        if (depthUInt > 32)
++            return false;
++        icon.depth = ICNSEntry::Depth(depthUInt);
++    }
+     // Try mono if depth not found
+     if (icon.depth == ICNSEntry::DepthUnknown)
+         icon.depth = ICNSEntry::DepthMono;
+@@ -515,6 +519,9 @@ static bool parseIconEntryInfo(ICNSEntry &icon)
+         }
+         icon.height = icon.width;
+     }
++    // Sanity check
++    if (icon.width == 0 || icon.width > 4096)
++        return false;
+     return true;
+ }
+ 
+@@ -685,7 +692,7 @@ bool QICNSHandler::canRead() const
+ bool QICNSHandler::read(QImage *outImage)
+ {
+     QImage img;
+-    if (!ensureScanned()) {
++    if (!ensureScanned() || m_currentIconIndex >= m_icons.size()) {
+         qWarning("QICNSHandler::read(): The device wasn't parsed properly!");
+         return false;
+     }
+@@ -892,7 +899,7 @@ bool QICNSHandler::scanDevice()
+             return false;
+ 
+         const qint64 blockDataOffset = device()->pos();
+-        if (!isBlockHeaderValid(blockHeader)) {
++        if (!isBlockHeaderValid(blockHeader, ICNSBlockHeaderSize + filelength - blockDataOffset)) {
+             qWarning("QICNSHandler::scanDevice(): Failed, bad header at pos %s. OSType \"%s\", length %u",
+                      QByteArray::number(blockDataOffset).constData(),
+                      nameFromOSType(blockHeader.ostype).constData(), blockHeader.length);
+@@ -927,11 +934,14 @@ bool QICNSHandler::scanDevice()
+         case ICNSBlockHeader::TypeOdrp:
+             // Icns container seems to have an embedded icon variant container
+             // Let's start a scan for entries
+-            while (device()->pos() < nextBlockOffset) {
++            while (!stream.atEnd() && device()->pos() < nextBlockOffset) {
+                 ICNSBlockHeader icon;
+                 stream >> icon;
++                if (stream.status() != QDataStream::Ok)
++                    return false;
+                 // Check for incorrect variant entry header and stop scan
+-                if (!isBlockHeaderValid(icon, blockDataLength))
++                quint64 remaining = blockDataLength - (device()->pos() - blockDataOffset);
++                if (!isBlockHeaderValid(icon, ICNSBlockHeaderSize + remaining))
+                     break;
+                 if (!addEntry(icon, device()->pos(), blockHeader.ostype))
+                     return false;
+@@ -1003,7 +1013,7 @@ bool QICNSHandler::scanDevice()
+             break;
+         }
+     }
+-    return true;
++    return (m_icons.size() > 0);
+ }
+ 
+ const ICNSEntry &QICNSHandler::getIconMask(const ICNSEntry &icon) const
+diff --git a/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp b/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
+index 5082023..cb34374 100644
+--- a/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
++++ b/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
+@@ -43,6 +43,7 @@
+ #include "qimage.h"
+ #include "qvariant.h"
+ #include "qcolor.h"
++#include "qimagereader.h"
+ 
+ #include <jasper/jasper.h>
+ #include <math.h> // for pow
+@@ -333,16 +334,46 @@ private:
+ Jpeg2000JasperReader::Jpeg2000JasperReader(QIODevice *iod, SubFormat format)
+     : jasperOk(true), ioDevice(iod), format(format), hasAlpha(false)
+ {
++#if JAS_VERSION_MAJOR < 3
+     if (jas_init()) {
+         jasperOk = false;
+         qDebug("Jasper Library initialization failed");
+     }
++#else
++    jas_conf_clear();
++#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
++    jas_conf_set_max_mem_usage(QImageReader::allocationLimit() * 1024 * 1024);
++#else
++    // 128MB seems to be enough.
++    jas_conf_set_max_mem_usage(128 * 1024 * 1024);
++#endif
++    if (jas_init_library()) {
++        jasperOk = false;
++        qDebug("Jasper library initialization failed");
++    }
++    if (jas_init_thread()) {
++        jas_cleanup_library();
++        jasperOk = false;
++        qDebug("Jasper thread initialization failed");
++    }
++#endif
+ }
+ 
+ Jpeg2000JasperReader::~Jpeg2000JasperReader()
+ {
++#if JAS_VERSION_MAJOR < 3
+     if (jasperOk)
+         jas_cleanup();
++#else
++    if (jasperOk) {
++        if (jas_cleanup_thread()) {
++            qDebug("Jasper thread cleanup failed");
++        }
++        if (jas_cleanup_library()) {
++            qDebug("Jasper library cleanup failed");
++        }
++    }
++#endif
+ }
+ 
+ /*! \internal
+@@ -857,7 +888,7 @@ bool Jpeg2000JasperReader::write(const QImage &image, int quality)
+     }
+ 
+     // Open an empty jasper stream that grows automatically
+-    jas_stream_t * memory_stream = jas_stream_memopen(0, -1);
++    jas_stream_t * memory_stream = jas_stream_memopen(0, 0);
+ 
+     // Jasper wants a non-const string.
+     char *str = qstrdup(jasperFormatString.toLatin1().constData());
+diff --git a/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp b/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
+index 1386750..ac8956c 100644
+--- a/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
+@@ -361,6 +361,8 @@ bool QTiffHandler::read(QImage *image)
+     }
+ 
+     TIFF *const tiff = d->tiff;
++    if (TIFFIsTiled(tiff) && TIFFTileSize64(tiff) > uint64_t(image->sizeInBytes())) // Corrupt image
++        return false;
+     const quint32 width = d->size.width();
+     const quint32 height = d->size.height();
+ 
+diff --git a/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp b/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
+index 82d38cb..d02eb05 100644
+--- a/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
+@@ -45,6 +45,7 @@
+ #include <qdebug.h>
+ #include <qpainter.h>
+ #include <qvariant.h>
++#include <QtEndian>
+ 
+ static const int riffHeaderSize = 12; // RIFF_HEADER_SIZE from webp/format_constants.h
+ 
+@@ -102,21 +103,23 @@ bool QWebpHandler::ensureScanned() const
+ 
+     m_scanState = ScanError;
+ 
+-    if (device()->isSequential()) {
+-        qWarning() << "Sequential devices are not supported";
++    QWebpHandler *that = const_cast<QWebpHandler *>(this);
++    const int headerBytesNeeded = sizeof(WebPBitstreamFeatures);
++    QByteArray header = device()->peek(headerBytesNeeded);
++    if (header.size() < headerBytesNeeded)
+         return false;
+-    }
+ 
+-    qint64 oldPos = device()->pos();
+-    device()->seek(0);
+-
+-    QWebpHandler *that = const_cast<QWebpHandler *>(this);
+-    QByteArray header = device()->peek(sizeof(WebPBitstreamFeatures));
++    // We do no random access during decoding, just a readAll() of the whole image file. So if
++    // if it is all available already, we can accept a sequential device. The riff header contains
++    // the file size minus 8 bytes header
++    qint64 byteSize = qFromLittleEndian<quint32>(header.constData() + 4);
++    if (device()->isSequential() && device()->bytesAvailable() < byteSize + 8) {
++        qWarning() << "QWebpHandler: Insufficient data available in sequential device";
++        return false;
++    }
+     if (WebPGetFeatures((const uint8_t*)header.constData(), header.size(), &(that->m_features)) == VP8_STATUS_OK) {
+         if (m_features.has_animation) {
+             // For animation, we have to read and scan whole file to determine loop count and images count
+-            device()->seek(oldPos);
+-
+             if (that->ensureDemuxer()) {
+                 that->m_loop = WebPDemuxGetI(m_demuxer, WEBP_FF_LOOP_COUNT);
+                 that->m_frameCount = WebPDemuxGetI(m_demuxer, WEBP_FF_FRAME_COUNT);
+@@ -126,17 +129,13 @@ bool QWebpHandler::ensureScanned() const
+                 if (that->m_features.has_alpha)
+                     that->m_composited->fill(Qt::transparent);
+ 
+-                // We do not reset device position since we have read in all data
+                 m_scanState = ScanSuccess;
+-                return true;
+             }
+         } else {
+             m_scanState = ScanSuccess;
+         }
+     }
+ 
+-    device()->seek(oldPos);
+-
+     return m_scanState == ScanSuccess;
+ }
+ 
+@@ -159,7 +158,7 @@ bool QWebpHandler::ensureDemuxer()
+ 
+ bool QWebpHandler::read(QImage *image)
+ {
+-    if (!ensureScanned() || device()->isSequential() || !ensureDemuxer())
++    if (!ensureScanned() || !ensureDemuxer())
+         return false;
+ 
+     QRect prevFrameRect;
+Submodule qtlocation 98a5c511..f991e28c:
+diff --git a/qtlocation/src/location/configure.json b/qtlocation/src/location/configure.json
+index 6d01a9a3..d1e623a1 100644
+--- a/qtlocation/src/location/configure.json
++++ b/qtlocation/src/location/configure.json
+@@ -9,7 +9,7 @@
+             "label": "Qt.labs.location experimental QML plugin",
+             "purpose": "Provides experimental QtLocation QML types",
+             "section": "Location",
+-            "condition": "config.opengl",
++            "condition": "features.opengl",
+             "output": [ "privateFeature" ]
+         },
+         "geoservices_osm": {
+diff --git a/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp b/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
+index a978573d..11e1466f 100644
+--- a/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
++++ b/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
+@@ -158,7 +158,7 @@ void QGeoMapObjectQSGSupport::updateMapObjects(QSGNode *root, QQuickWindow *wind
+     if (!root)
+         return;
+ 
+-    if (m_mapObjectsRootNode && m_mapObjectsRootNode->parent())
++    if (m_mapObjectsRootNode && !m_mapObjectsRootNode->parent())
+         root->appendChildNode(m_mapObjectsRootNode.get());
+ 
+     if (!m_mapObjectsRootNode) {
+diff --git a/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
+index 5a40467e..d123c6a8 100644
+--- a/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
+@@ -59,8 +59,10 @@ QT_BEGIN_NAMESPACE
+ static const QString kPrefixEsri(QStringLiteral("esri."));
+ static const QString kParamUserAgent(kPrefixEsri + QStringLiteral("useragent"));
+ 
+-static const QString kUrlGeocode(QStringLiteral("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates"));
+-static const QString kUrlReverseGeocode(QStringLiteral("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode"));
++static const QString kUrlGeocode(QStringLiteral("https://geocode.arcgis.com/arcgis/rest/services/"
++                                                "World/GeocodeServer/findAddressCandidates"));
++static const QString kUrlReverseGeocode(QStringLiteral(
++        "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode"));
+ 
+ static QString addressToQuery(const QGeoAddress &address)
+ {
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
+index 17492d94..96c12b1b 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
+@@ -46,7 +46,8 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-// JSON reference: http://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
++// JSON reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
+ 
+ static const QString kErrorMessage(QStringLiteral("Error %1: %2."));
+ static const QString kErrorJson(QStringLiteral("Error: invalide JSON document."));
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
+index 8cadfb29..92b6bb13 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
+@@ -44,7 +44,8 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-// JSON reference: http://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
++// JSON reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
+ 
+ GeoRouteReplyEsri::GeoRouteReplyEsri(QNetworkReply *reply, const QGeoRouteRequest &request,
+                                      QObject *parent) :
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
+index 0e6bc2c7..ed613f4b 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
+@@ -48,7 +48,8 @@ static const QString kPrefixEsri(QStringLiteral("esri."));
+ static const QString kParamUserAgent(kPrefixEsri + QStringLiteral("useragent"));
+ static const QString kParamToken(kPrefixEsri + QStringLiteral("token"));
+ 
+-static const QString kUrlRouting(QStringLiteral("http://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve"));
++static const QString kUrlRouting(QStringLiteral(
++        "https://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve"));
+ 
+ GeoRoutingManagerEngineEsri::GeoRoutingManagerEngineEsri(const QVariantMap &parameters,
+                                                          QGeoServiceProvider::Error *error,
+@@ -70,7 +71,8 @@ GeoRoutingManagerEngineEsri::~GeoRoutingManagerEngineEsri()
+ {
+ }
+ 
+-// REST reference: http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
++// REST reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
+ 
+ QGeoRouteReply *GeoRoutingManagerEngineEsri::calculateRoute(const QGeoRouteRequest &request)
+ {
+@@ -125,7 +127,7 @@ void GeoRoutingManagerEngineEsri::replyError(QGeoRouteReply::Error errorCode, co
+ QString GeoRoutingManagerEngineEsri::preferedDirectionLangage()
+ {
+     // list of supported langages is defined in:
+-    // http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
++    // https://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
+     const QStringList supportedLanguages = {
+         "ar", // Generate directions in Arabic
+         "cs", // Generate directions in Czech
+diff --git a/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
+index 5d15835d..24148f95 100644
+--- a/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
+@@ -230,7 +230,8 @@ QGeoMap *GeoTiledMappingManagerEngineEsri::createMap()
+ // ${y} = Y
+ // ${token} = Token
+ 
+-// template = 'http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{{z}}/{{y}}/{{x}}.png'
++// template =
++// 'https://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{{z}}/{{y}}/{{x}}.png'
+ 
+ bool GeoTiledMappingManagerEngineEsri::initializeMapSources(QGeoServiceProvider::Error *error,
+                                                             QString *errorString,
+diff --git a/qtlocation/src/plugins/geoservices/esri/maps.json b/qtlocation/src/plugins/geoservices/esri/maps.json
+index 8167ae7d..862e087d 100644
+--- a/qtlocation/src/plugins/geoservices/esri/maps.json
++++ b/qtlocation/src/plugins/geoservices/esri/maps.json
+@@ -6,8 +6,8 @@
+             "description": "ArcGIS Online World Street Map",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=3b93337983e9436f8db950e38a8629af'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=3b93337983e9436f8db950e38a8629af'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -16,8 +16,8 @@
+             "": "ArcGIS Online World Imagery",
+             "mobile": true,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -26,8 +26,8 @@
+             "description": "ArcGIS Online World Terrain Base",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=c61ad8ab017d49e1a82f580ee1298931'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=c61ad8ab017d49e1a82f580ee1298931'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -36,8 +36,8 @@
+             "description": "ArcGIS Online World Topography",
+             "mobile": true,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=30e5fe3149c34df1ba922e6f5bbf808f'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=30e5fe3149c34df1ba922e6f5bbf808f'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -46,8 +46,8 @@
+             "description": "This map presents land cover and detailed topographic maps for the United States.",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=99cd5fbd98934028802b4f797c4b1732'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=99cd5fbd98934028802b4f797c4b1732'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -56,8 +56,8 @@
+             "description": "National Geographic World Map",
+             "mobile": false,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=b9b1b422198944fbbd5250b3241691b6'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=b9b1b422198944fbbd5250b3241691b6'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -66,8 +66,8 @@
+             "description": "Thematic content providing a neutral background with minimal colors",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=ed712cb1db3e4bae9e85329040fb9a49'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=ed712cb1db3e4bae9e85329040fb9a49'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -76,8 +76,8 @@
+             "description": "Natural Earth physical map for the world",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=c4ec722a1cd34cf0a23904aadf8923a0'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=c4ec722a1cd34cf0a23904aadf8923a0'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -86,8 +86,8 @@
+             "description": "Portrays surface elevation as shaded relief",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=9c5370d0b54f4de1b48a3792d7377ff2'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=9c5370d0b54f4de1b48a3792d7377ff2'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -96,8 +96,8 @@
+             "description": "This map is designed to be used as a basemap by marine GIS professionals and as a reference map by anyone interested in ocean data",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=1e126e7520f9466c9ca28b8f28b5e500'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=1e126e7520f9466c9ca28b8f28b5e500'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -106,8 +106,8 @@
+             "description": "Thematic content providing a neutral background with minimal colors",
+             "mobile": false,
+             "night": true,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=a284a9b99b3446a3910d4144a50990f6'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=a284a9b99b3446a3910d4144a50990f6'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -116,8 +116,8 @@
+             "description": "DeLorme’s topographic basemap is a seamless global data set that portrays transportation, hydrography, jurisdiction boundaries, and major geographic features",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/Specialty/DeLorme_World_Base_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=b165c3df453e4be6b5ac4fdb241effbe'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/Specialty/DeLorme_World_Base_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=b165c3df453e4be6b5ac4fdb241effbe'>Esri</a> contributors"
+         }
+     ]
+ }
+diff --git a/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
+index 3858ddf5..af66f28e 100644
+--- a/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
+@@ -63,8 +63,10 @@ static const QString kCountriesKey(QStringLiteral("detailedCountries"));
+ static const QString kLocalizedNamesKey(QStringLiteral("localizedNames"));
+ static const QString kMaxLocationsKey(QStringLiteral("maxLocations"));
+ 
+-static const QUrl kUrlGeocodeServer("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer?f=pjson");
+-static const QUrl kUrlFindAddressCandidates("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates");
++static const QUrl kUrlGeocodeServer(
++        "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer?f=pjson");
++static const QUrl kUrlFindAddressCandidates("https://geocode.arcgis.com/arcgis/rest/services/World/"
++                                            "GeocodeServer/findAddressCandidates");
+ 
+ PlaceManagerEngineEsri::PlaceManagerEngineEsri(const QVariantMap &parameters, QGeoServiceProvider::Error *error,
+                                                QString *errorString) :
+Submodule qtmultimedia f0344079..0d7cc33a:
+diff --git a/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp b/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
+index 2b5325132..b68b4af1b 100644
+--- a/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
++++ b/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
+@@ -402,6 +402,8 @@ int QPulseAudioInput::bytesReady() const
+ 
+ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ {
++    Q_ASSERT(data != nullptr || len == 0);
++
+     m_bytesAvailable = checkBytesReady();
+ 
+     setError(QAudio::NoError);
+@@ -411,7 +413,8 @@ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ 
+     if (!m_pullMode && !m_tempBuffer.isEmpty()) {
+         readBytes = qMin(static_cast<int>(len), m_tempBuffer.size());
+-        memcpy(data, m_tempBuffer.constData(), readBytes);
++        if (readBytes)
++            memcpy(data, m_tempBuffer.constData(), readBytes);
+         m_totalTimeValue += readBytes;
+ 
+         if (readBytes < m_tempBuffer.size()) {
+@@ -502,9 +505,10 @@ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ 
+ void QPulseAudioInput::applyVolume(const void *src, void *dest, int len)
+ {
++    Q_ASSERT((src && dest) || len == 0);
+     if (m_volume < 1.f)
+         QAudioHelperInternal::qMultiplySamples(m_volume, m_format, src, dest, len);
+-    else
++    else if (len)
+         memcpy(dest, src, len);
+ }
+ 
+Submodule qtpim 02efef5e...f9a8f0fc (commits not present)
+Submodule qtquick3d b85cf622..47defc8b:
+diff --git a/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro b/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
+index ca5c499e..174a075b 100644
+--- a/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
++++ b/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
+@@ -10,7 +10,7 @@ QT_FOR_CONFIG += assetimporters-private
+ include($$OUT_PWD/../qtassetimporters-config.pri)
+ 
+ qtConfig(system-assimp):!if(cross_compile:host_build) {
+-    QMAKE_USE_PRIVATE += assimp
++    QMAKE_USE_PRIVATE += quick3d-assimp
+ } else {
+     include(../../../3rdparty/assimp/assimp.pri)
+ }
+Submodule qtquickcontrols2 3a657dc0..56ce8233:
+diff --git a/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp b/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
+index e5fe734f7..e36922775 100644
+--- a/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
++++ b/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
+@@ -38,6 +38,7 @@
+ #include "qwidgetplatformmenuitem_p.h"
+ 
+ #include <QtGui/qwindow.h>
++#include <QtGui/private/qhighdpiscaling_p.h>
+ #include <QtWidgets/qmenu.h>
+ #include <QtWidgets/qaction.h>
+ 
+@@ -145,7 +146,7 @@ void QWidgetPlatformMenu::showPopup(const QWindow *window, const QRect &targetRe
+ 
+     QPoint targetPos = targetRect.bottomLeft();
+     if (window)
+-        targetPos = window->mapToGlobal(targetPos);
++        targetPos = window->mapToGlobal(QHighDpi::fromNativeLocalPosition(targetPos, window));
+ 
+     const QWidgetPlatformMenuItem *widgetItem = qobject_cast<const QWidgetPlatformMenuItem *>(item);
+     m_menu->popup(targetPos, widgetItem ? widgetItem->action() : nullptr);
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
+index 950e4e099..b81fbea0b 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
+@@ -387,6 +387,17 @@ void QQuickAbstractButtonPrivate::itemImplicitHeightChanged(QQuickItem *item)
+         emit q->implicitIndicatorHeightChanged();
+ }
+ 
++void QQuickAbstractButtonPrivate::itemDestroyed(QQuickItem *item)
++{
++    Q_Q(QQuickAbstractButton);
++    QQuickControlPrivate::itemDestroyed(item);
++    if (item == indicator) {
++        indicator = nullptr;
++        emit q->implicitIndicatorWidthChanged();
++        emit q->implicitIndicatorHeightChanged();
++    }
++}
++
+ QQuickAbstractButton *QQuickAbstractButtonPrivate::findCheckedButton() const
+ {
+     Q_Q(const QQuickAbstractButton);
+@@ -1176,6 +1187,12 @@ QAccessible::Role QQuickAbstractButton::accessibleRole() const
+     }
+     return QAccessible::Button;
+ }
++
++void QQuickAbstractButton::accessiblePressAction()
++{
++    Q_D(QQuickAbstractButton);
++    d->trigger();
++}
+ #endif
+ 
+ QT_END_NAMESPACE
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
+index 0fa48980e..ab66220d0 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
+@@ -209,6 +209,7 @@ protected:
+ #if QT_CONFIG(accessibility)
+     void accessibilityActiveChanged(bool active) override;
+     QAccessible::Role accessibleRole() const override;
++    Q_INVOKABLE void accessiblePressAction();
+ #endif
+ 
+ private:
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
+index 9291c1a87..b729720f2 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
+@@ -109,6 +109,7 @@ public:
+ 
+     void itemImplicitWidthChanged(QQuickItem *item) override;
+     void itemImplicitHeightChanged(QQuickItem *item) override;
++    void itemDestroyed(QQuickItem *item) override;
+ 
+     // copied from qabstractbutton.cpp
+     static const int AUTO_REPEAT_DELAY = 300;
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp b/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
+index 2041e7741..8610cdfae 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
+@@ -145,7 +145,7 @@ int QQuickActionPrivate::ShortcutEntry::shortcutId() const
+ 
+ void QQuickActionPrivate::ShortcutEntry::grab(const QKeySequence &shortcut, bool enabled)
+ {
+-    if (shortcut.isEmpty())
++    if (shortcut.isEmpty() || m_shortcutId)
+         return;
+ 
+     Qt::ShortcutContext context = Qt::WindowShortcut; // TODO
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp b/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
+index f38c2b09c..6eed2a024 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
+@@ -225,6 +225,7 @@ void QQuickContainerPrivate::cleanup()
+     QObject::disconnect(contentModel, &QQmlObjectModel::countChanged, q, &QQuickContainer::countChanged);
+     QObject::disconnect(contentModel, &QQmlObjectModel::childrenChanged, q, &QQuickContainer::contentChildrenChanged);
+     delete contentModel;
++    contentModel = nullptr;
+ }
+ 
+ QQuickItem *QQuickContainerPrivate::itemAt(int index) const
+@@ -436,7 +437,7 @@ void QQuickContainerPrivate::contentChildren_clear(QQmlListProperty<QQuickItem>
+ void QQuickContainerPrivate::updateContentWidth()
+ {
+     Q_Q(QQuickContainer);
+-    if (hasContentWidth || qFuzzyCompare(contentWidth, implicitContentWidth))
++    if (hasContentWidth || qFuzzyCompare(contentWidth, implicitContentWidth) || !contentModel)
+         return;
+ 
+     contentWidth = implicitContentWidth;
+@@ -446,7 +447,7 @@ void QQuickContainerPrivate::updateContentWidth()
+ void QQuickContainerPrivate::updateContentHeight()
+ {
+     Q_Q(QQuickContainer);
+-    if (hasContentHeight || qFuzzyCompare(contentHeight, implicitContentHeight))
++    if (hasContentHeight || qFuzzyCompare(contentHeight, implicitContentHeight) || !contentModel)
+         return;
+ 
+     contentHeight = implicitContentHeight;
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp b/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
+index bbbd0e622..1f4b47343 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
+@@ -845,6 +845,13 @@ void QQuickControlPrivate::executeBackground(bool complete)
+         quickCompleteDeferred(q, backgroundName(), background);
+ }
+ 
++/*
++    \internal
++
++    Hides an item that was replaced by a newer one, rather than
++    deleting it, as the item is typically created in QML and hence
++    we don't own it.
++*/
+ void QQuickControlPrivate::hideOldItem(QQuickItem *item)
+ {
+     if (!item)
+@@ -863,6 +870,29 @@ void QQuickControlPrivate::hideOldItem(QQuickItem *item)
+ #endif
+ }
+ 
++/*
++    \internal
++
++    Named "unhide" because it's used for cases where an item
++    that was previously hidden by \l hideOldItem() wants to be
++    shown by a control again, such as a ScrollBar in ScrollView.
++*/
++void QQuickControlPrivate::unhideOldItem(QQuickControl *control, QQuickItem *item)
++{
++    Q_ASSERT(item);
++    qCDebug(lcItemManagement) << "unhiding old item" << item;
++
++    item->setVisible(true);
++    item->setParentItem(control);
++
++#if QT_CONFIG(accessibility)
++    // Add the item back in to the accessibility tree.
++    QQuickAccessibleAttached *accessible = accessibleAttached(item);
++    if (accessible)
++        accessible->setIgnored(false);
++#endif
++}
++
+ void QQuickControlPrivate::updateBaselineOffset()
+ {
+     Q_Q(QQuickControl);
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h b/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
+index 8e979079e..a6e624c91 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
+@@ -173,6 +173,7 @@ public:
+     virtual void executeBackground(bool complete = false);
+ 
+     static void hideOldItem(QQuickItem *item);
++    static void unhideOldItem(QQuickControl *control, QQuickItem *item);
+ 
+     void updateBaselineOffset();
+ 
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp b/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
+index e6db14eb5..6197d1547 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
+@@ -237,7 +237,7 @@ static QRectF alignedRect(Qt::LayoutDirection direction, Qt::Alignment alignment
+ void QQuickDialogButtonBoxPrivate::resizeContent()
+ {
+     Q_Q(QQuickDialogButtonBox);
+-    if (!contentItem)
++    if (!contentItem || !contentModel)
+         return;
+ 
+     QRectF geometry = q->boundingRect().adjusted(q->leftPadding(), q->topPadding(), -q->rightPadding(), -q->bottomPadding());
+@@ -322,6 +322,9 @@ void QQuickDialogButtonBoxPrivate::updateLayout()
+ qreal QQuickDialogButtonBoxPrivate::getContentWidth() const
+ {
+     Q_Q(const QQuickDialogButtonBox);
++    if (!contentModel)
++        return 0;
++
+     const int count = contentModel->count();
+     const qreal totalSpacing = qMax(0, count - 1) * spacing;
+     qreal totalWidth = totalSpacing;
+@@ -341,6 +344,9 @@ qreal QQuickDialogButtonBoxPrivate::getContentWidth() const
+ qreal QQuickDialogButtonBoxPrivate::getContentHeight() const
+ {
+     Q_Q(const QQuickDialogButtonBox);
++    if (!contentModel)
++        return 0;
++
+     const int count = contentModel->count();
+     qreal maxHeight = 0;
+     for (int i = 0; i < count; ++i) {
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp b/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
+index 91bd59184..0ce518f84 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
+@@ -399,8 +399,11 @@ void QQuickOverlay::itemChange(ItemChange change, const ItemChangeData &data)
+     Q_D(QQuickOverlay);
+     QQuickItem::itemChange(change, data);
+ 
+-    if (change == ItemChildAddedChange || change == ItemChildRemovedChange)
++    if (change == ItemChildAddedChange || change == ItemChildRemovedChange) {
+         setVisible(!d->allDrawers.isEmpty() || !childItems().isEmpty());
++        if (data.item->parent() == d->mouseGrabberPopup)
++            d->setMouseGrabberPopup(nullptr);
++    }
+ }
+ 
+ void QQuickOverlay::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp b/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
+index 4e2f509db..1c4b308cd 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
+@@ -797,6 +797,14 @@ void QQuickScrollBarAttachedPrivate::initHorizontal()
+     if (parent && parent == flickable->parentItem())
+         horizontal->stackAfter(flickable);
+ 
++    // If a scroll bar was previously hidden (due to e.g. setting a new contentItem
++    // on a ScrollView), we need to make sure that we un-hide it.
++    // We don't bother checking if the item is actually the old one, because
++    // if it's not, all of the things the function does (setting parent, visibility, etc.)
++    // should be no-ops anyway.
++    if (auto control = qobject_cast<QQuickControl*>(q_ptr->parent()))
++        QQuickControlPrivate::unhideOldItem(control, horizontal);
++
+     layoutHorizontal();
+     horizontal->setSize(area->property("widthRatio").toReal());
+     horizontal->setPosition(area->property("xPosition").toReal());
+@@ -818,6 +826,9 @@ void QQuickScrollBarAttachedPrivate::initVertical()
+     if (parent && parent == flickable->parentItem())
+         vertical->stackAfter(flickable);
+ 
++    if (auto control = qobject_cast<QQuickControl*>(q_ptr->parent()))
++        QQuickControlPrivate::unhideOldItem(control, vertical);
++
+     layoutVertical();
+     vertical->setSize(area->property("heightRatio").toReal());
+     vertical->setPosition(area->property("yPosition").toReal());
+diff --git a/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml b/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
+index 0e8b08352..cd4931184 100644
+--- a/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
++++ b/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
+@@ -576,4 +576,51 @@ TestCase {
+         verify(newHorizontalScrollBar.visible)
+         verify(!oldHorizontalScrollBar.visible)
+     }
++
++    Component {
++        id: bindingToContentItemAndStandaloneFlickable
++
++        Item {
++            width: 200
++            height: 200
++
++            property alias scrollView: scrollView
++
++            ScrollView {
++                id: scrollView
++                anchors.fill: parent
++                contentItem: listView
++
++                property Item someBinding: contentItem
++            }
++            ListView {
++                id: listView
++                model: 10
++                delegate: ItemDelegate {
++                    text: modelData
++                    width: listView.width
++                }
++            }
++        }
++    }
++
++    // Tests that scroll bars show up for a ScrollView where
++    // - its contentItem is declared as a standalone, separate item
++    // - there is a binding to contentItem (which causes a default Flickable to be created)
++    function test_bindingToContentItemAndStandaloneFlickable() {
++        let root = createTemporaryObject(bindingToContentItemAndStandaloneFlickable, testCase)
++        verify(root)
++
++        let control = root.scrollView
++        let verticalScrollBar = control.ScrollBar.vertical
++        let horizontalScrollBar = control.ScrollBar.horizontal
++        compare(verticalScrollBar.parent, control)
++        compare(horizontalScrollBar.parent, control)
++        verify(verticalScrollBar.visible)
++        verify(horizontalScrollBar.visible)
++
++        mouseDrag(verticalScrollBar, verticalScrollBar.width / 2, verticalScrollBar.height / 2, 0, 50)
++        verify(verticalScrollBar.active)
++        verify(horizontalScrollBar.active)
++    }
+ }
+diff --git a/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml b/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
+index b3fab41ca..10b6baa02 100644
+--- a/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
++++ b/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
+@@ -608,4 +608,27 @@ TestCase {
+         mouseClick(control.indicator)
+         verify(control.activeFocus)
+     }
++
++    Component {
++        id: deletionOrder1
++        Item {
++            Image { id: innerImage }
++            Switch { indicator: innerImage }
++        }
++    }
++
++    Component {
++        id: deletionOrder2
++        Item {
++            Switch { indicator: innerImage }
++            Image { id: innerImage }
++        }
++    }
++
++    function test_deletionOrder() {
++        var control1 = createTemporaryObject(deletionOrder1, testCase)
++        verify(control1)
++        var control2 = createTemporaryObject(deletionOrder2, testCase)
++        verify(control2)
++    }
+ }
+diff --git a/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml b/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml
+new file mode 100644
+index 000000000..9e4598b9f
+--- /dev/null
++++ b/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml
+@@ -0,0 +1,78 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the test suite of the Qt Toolkit.
++**
++** $QT_BEGIN_LICENSE:BSD$
++** Commercial License Usage
++** Licensees holding valid commercial Qt licenses may use this file in
++** accordance with the commercial license agreement provided with the
++** Software or, alternatively, in accordance with the terms contained in
++** a written agreement between you and The Qt Company. For licensing terms
++** and conditions see https://www.qt.io/terms-conditions. For further
++** information use the contact form at https://www.qt.io/contact-us.
++**
++** BSD License Usage
++** Alternatively, you may use this file under the terms of the BSD license
++** as follows:
++**
++** "Redistribution and use in source and binary forms, with or without
++** modification, are permitted provided that the following conditions are
++** met:
++**   * Redistributions of source code must retain the above copyright
++**     notice, this list of conditions and the following disclaimer.
++**   * Redistributions in binary form must reproduce the above copyright
++**     notice, this list of conditions and the following disclaimer in
++**     the documentation and/or other materials provided with the
++**     distribution.
++**   * Neither the name of The Qt Company Ltd nor the names of its
++**     contributors may be used to endorse or promote products derived
++**     from this software without specific prior written permission.
++**
++**
++** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
++** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
++** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
++** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
++** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
++** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
++** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
++** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
++** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
++** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
++** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
++**
++** $QT_END_LICENSE$
++**
++****************************************************************************/
++
++import QtQuick 2.15
++import QtQuick.Controls 2.15
++
++ApplicationWindow {
++    id: window
++    width: 400
++    height: 400
++    title: "releaseAfterExitTransition"
++
++    property alias popup: popup
++    property alias modalPopup: modalPopup
++
++    Popup {
++        id: popup
++        y: parent.height - height
++        width: 50
++        height: 50
++    }
++
++    Popup {
++        id: modalPopup
++        modal: true
++        y: parent.height - height
++        width: 50
++        height: 50
++        exit:  Transition { PauseAnimation { duration: 100 } }
++    }
++}
+diff --git a/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp b/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
+index 54952d128..3d50e2dd4 100644
+--- a/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
++++ b/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
+@@ -100,6 +100,7 @@ private slots:
+     void invisibleToolTipOpen();
+     void centerInOverlayWithinStackViewItem();
+     void destroyDuringExitTransition();
++    void releaseAfterExitTransition();
+ };
+ 
+ void tst_QQuickPopup::initTestCase()
+@@ -1575,6 +1576,34 @@ void tst_QQuickPopup::destroyDuringExitTransition()
+     QVERIFY(!button->isDown());
+ }
+ 
++void tst_QQuickPopup::releaseAfterExitTransition()
++{
++    QQuickApplicationHelper helper(this, "releaseAfterExitTransition.qml");
++    QVERIFY2(helper.ready, helper.failureMessage());
++
++    QQuickWindow *window = helper.window;
++    window->show();
++    QVERIFY(QTest::qWaitForWindowActive(window));
++
++    QQuickOverlay *overlay = QQuickOverlay::overlay(window);
++    QQuickPopup *modalPopup = window->property("modalPopup").value<QQuickPopup *>();
++    QQuickPopup *popup = window->property("popup").value<QQuickPopup *>();
++
++    modalPopup->open();
++    QTRY_VERIFY(modalPopup->isOpened());
++
++    QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++    // wait until the transition is finished and the overlay hides itself
++    QTRY_VERIFY(!overlay->isVisible());
++    QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++
++    popup->open();
++    QTRY_VERIFY(popup->isOpened());
++    QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++    QTRY_VERIFY(!popup->isOpened());
++}
++
++
+ QTEST_QUICKCONTROLS_MAIN(tst_QQuickPopup)
+ 
+ #include "tst_qquickpopup.moc"
+Submodule qtscript 5be95f96...4d8e4bd2 (commits not present)
+Submodule qtspeech 17fc9fde..255845e2:
+diff --git a/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp b/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
+index 6eb74b8..bcc7dd1 100644
+--- a/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
++++ b/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
+@@ -357,7 +357,9 @@ QVector<QLocale> QTextToSpeechEngineSpeechd::availableLocales() const
+ 
+ QVector<QVoice> QTextToSpeechEngineSpeechd::availableVoices() const
+ {
+-    return m_voices.values(m_currentLocale.name()).toVector();
++    QList<QVoice> resultList = m_voices.values(m_currentLocale.name());
++    std::reverse(resultList.begin(), resultList.end());
++    return resultList.toVector();
+ }
+ 
+ // We have no way of knowing our own client_id since speech-dispatcher seems to be incomplete
+Submodule qtsvg 0c05780e..a7a0f249:
+diff --git a/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp b/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
+index 561e77e..12e0574 100644
+--- a/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
++++ b/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
+@@ -191,6 +191,8 @@ bool QSvgIOHandler::read(QImage *image)
+             }
+         }
+         if (!finalSize.isEmpty()) {
++            if (qMax(finalSize.width(), finalSize.height()) > 0xffff)
++                return false; // Assume corrupted file
+             image->fill(d->backColor.rgba());
+             QPainter p(image);
+             d->r.render(&p, bounds);
+diff --git a/qtsvg/src/svg/qsvghandler.cpp b/qtsvg/src/svg/qsvghandler.cpp
+index a5f877f..8dda563 100644
+--- a/qtsvg/src/svg/qsvghandler.cpp
++++ b/qtsvg/src/svg/qsvghandler.cpp
+@@ -1393,9 +1393,10 @@ static void parseFont(QSvgNode *node,
+         case FontSizeNone:
+             break;
+         case FontSizeValue: {
+-            QSvgHandler::LengthType dummy; // should always be pixel size
+-            fontStyle->setSize(qMin(parseLength(attributes.fontSize, dummy, handler),
+-                                    qreal(0xffff)));
++            QSvgHandler::LengthType type;
++            qreal fs = parseLength(attributes.fontSize, type, handler);
++            fs = convertToPixels(fs, true, type);
++            fontStyle->setSize(qMin(fs, qreal(0xffff)));
+         }
+             break;
+         default:
+@@ -2513,6 +2514,8 @@ static bool parseAnimateTransformNode(QSvgNode *parent,
+             ++s;
+         }
+     }
++    if (vals.count() % 3 != 0)
++        return false;
+ 
+     bool ok = true;
+     int begin = parseClockValue(beginStr, &ok);
+@@ -2576,6 +2579,8 @@ static QSvgNode *createCircleNode(QSvgNode *parent,
+     qreal ncx = toDouble(cx);
+     qreal ncy = toDouble(cy);
+     qreal nr  = toDouble(r);
++    if (nr < 0.0)
++        return nullptr;
+ 
+     QRectF rect(ncx-nr, ncy-nr, nr*2, nr*2);
+     QSvgNode *circle = new QSvgCircle(parent, rect);
+@@ -3046,15 +3051,16 @@ static QSvgStyleProperty *createRadialGradientNode(QSvgNode *node,
+ 
+     qreal ncx = 0.5;
+     qreal ncy = 0.5;
+-    qreal nr  = 0.5;
+     if (!cx.isEmpty())
+         ncx = toDouble(cx);
+     if (!cy.isEmpty())
+         ncy = toDouble(cy);
++
++    qreal nr = 0.0;
+     if (!r.isEmpty())
+         nr = toDouble(r);
+-    if (nr < 0.5)
+-        nr = 0.5;
++    if (nr <= 0.0)
++        return nullptr;
+ 
+     qreal nfx = ncx;
+     if (!fx.isEmpty())
+@@ -3350,7 +3356,9 @@ static QSvgNode *createTextNode(QSvgNode *parent,
+     //### editable and rotate not handled
+     QSvgHandler::LengthType type;
+     qreal nx = parseLength(x, type, handler);
++    nx = convertToPixels(nx, true, type);
+     qreal ny = parseLength(y, type, handler);
++    ny = convertToPixels(ny, true, type);
+ 
+     QSvgNode *text = new QSvgText(parent, QPointF(nx, ny));
+     return text;
+@@ -3691,9 +3699,7 @@ void QSvgHandler::parse()
+         case QXmlStreamReader::EndElement:
+             endElement(xml->name());
+             ++remainingUnfinishedElements;
+-            // if we are using somebody else's qxmlstreamreader
+-            // we should not read until the end of the stream
+-            done = !m_ownsReader && (xml->name() == QLatin1String("svg"));
++            done = (xml->name() == QLatin1String("svg"));
+             break;
+         case QXmlStreamReader::Characters:
+             characters(xml->text());
+diff --git a/qtsvg/src/svg/qsvgstructure.cpp b/qtsvg/src/svg/qsvgstructure.cpp
+index b89608b..89c9e4e 100644
+--- a/qtsvg/src/svg/qsvgstructure.cpp
++++ b/qtsvg/src/svg/qsvgstructure.cpp
+@@ -255,9 +255,13 @@ inline static bool isSupportedSvgFeature(const QString &str)
+     };
+ 
+     if (str.length() <= MAX_WORD_LENGTH && str.length() >= MIN_WORD_LENGTH) {
++        const char16_t unicode44 = str.at(44).unicode();
++        const char16_t unicode45 = str.at(45).unicode();
++        if (unicode44 >= sizeof(asso_values) || unicode45 >= sizeof(asso_values))
++            return false;
+         const int key = str.length()
+-                        + asso_values[str.at(45).unicode()]
+-                        + asso_values[str.at(44).unicode()];
++                        + asso_values[unicode45]
++                        + asso_values[unicode44];
+         if (key <= MAX_HASH_VALUE && key >= 0)
+             return str == QLatin1String(wordlist[key]);
+     }
+diff --git a/qtsvg/src/svg/qsvgtinydocument.cpp b/qtsvg/src/svg/qsvgtinydocument.cpp
+index 63d0797..19e7154 100644
+--- a/qtsvg/src/svg/qsvgtinydocument.cpp
++++ b/qtsvg/src/svg/qsvgtinydocument.cpp
+@@ -433,8 +433,16 @@ void QSvgTinyDocument::draw(QPainter *p, QSvgExtraStates &)
+     draw(p);
+ }
+ 
++static bool isValidMatrix(const QTransform &transform)
++{
++    qreal determinant = transform.determinant();
++    return qIsFinite(determinant);
++}
++
+ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect, const QRectF &sourceRect)
+ {
++    QTransform oldTransform = p->worldTransform();
++
+     QRectF target = targetRect;
+     if (target.isEmpty()) {
+         QPaintDevice *dev = p->device();
+@@ -487,6 +495,9 @@ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect,
+         }
+ #endif
+     }
++
++    if (!isValidMatrix(p->worldTransform()))
++        p->setWorldTransform(oldTransform);
+ }
+ 
+ QRectF QSvgTinyDocument::boundsOnElement(const QString &id) const
+diff --git a/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp b/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
+index 36c76ec..db71e02 100644
+--- a/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
++++ b/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
+@@ -86,6 +86,8 @@ private slots:
+     void oss_fuzz_23731();
+     void oss_fuzz_24131();
+     void oss_fuzz_24738();
++    void illegalAnimateTransform_data();
++    void illegalAnimateTransform();
+ 
+ #ifndef QT_NO_COMPRESS
+     void testGzLoading();
+@@ -1646,5 +1648,22 @@ void tst_QSvgRenderer::oss_fuzz_24738()
+     QSvgRenderer().load(QByteArray("<svg><path d=\"a 2 1e-212.....\">"));
+ }
+ 
++void tst_QSvgRenderer::illegalAnimateTransform_data()
++{
++    QTest::addColumn<QByteArray>("svg");
++
++    QTest::newRow("case1") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" values=\"8,0,5,0\">");
++    QTest::newRow("case2") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" values=\"1,2\">");
++    QTest::newRow("case3") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" from=\".. 5 2\" to=\"f\">");
++    QTest::newRow("case4") << QByteArray("<svg><animateTransform type=\"scale\" begin=\"1\" dur=\"2\" by=\"--,..\">");
++}
++
++void tst_QSvgRenderer::illegalAnimateTransform()
++{
++    QFETCH(QByteArray, svg);
++    QSvgRenderer renderer;
++    QVERIFY(!renderer.load(svg)); // also shouldn't assert
++}
++
+ QTEST_MAIN(tst_QSvgRenderer)
+ #include "tst_qsvgrenderer.moc"
+Submodule qttools 6914f7c8..090e526e:
+diff --git a/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp b/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
+index feab1e2d5..cbfb82507 100644
+--- a/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
++++ b/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
+@@ -445,7 +445,9 @@ bool HelpGeneratorPrivate::insertFiles(const QStringList &files, const QString &
+     if (filterSetId < 0)
+         return false;
+     ++filterSetId;
+-    for (int attId : qAsConst(filterAtts)) {
++    QList<int> attValues = filterAtts.values();
++    std::sort(attValues.begin(), attValues.end());
++    for (int attId : qAsConst(attValues)) {
+         m_query->prepare(QLatin1String("INSERT INTO FileAttributeSetTable "
+             "VALUES(?, ?)"));
+         m_query->bindValue(0, filterSetId);
+Submodule qtwayland dfb0129c..2904e1b3:
+diff --git a/qtwayland/src/client/configure.json b/qtwayland/src/client/configure.json
+index 2f424580..29222357 100644
+--- a/qtwayland/src/client/configure.json
++++ b/qtwayland/src/client/configure.json
+@@ -149,8 +149,7 @@
+                     "#endif"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "vulkan-server-buffer": {
+             "label": "Vulkan Buffer Sharing",
+@@ -168,7 +167,8 @@
+                     "exportAllocInfo.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR;",
+                     "return 0;"
+                 ]
+-            }
++            },
++            "use": "wayland-client"
+         },
+         "egl_1_5-wayland": {
+             "label": "EGL 1.5 with Wayland Platform",
+@@ -183,7 +183,7 @@
+                     "eglGetPlatformDisplay(EGL_PLATFORM_WAYLAND_EXT, (struct wl_display *)(nullptr), nullptr);"
+                 ]
+             },
+-            "use": "egl"
++            "use": "egl wayland-client"
+         }
+     },
+ 
+diff --git a/qtwayland/src/client/global/qwaylandclientextension.cpp b/qtwayland/src/client/global/qwaylandclientextension.cpp
+index 125b1e19..edccfe63 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension.cpp
++++ b/qtwayland/src/client/global/qwaylandclientextension.cpp
+@@ -74,7 +74,10 @@ void QWaylandClientExtensionPrivate::handleRegistryGlobal(void *data, ::wl_regis
+ void QWaylandClientExtension::addRegistryListener()
+ {
+     Q_D(QWaylandClientExtension);
+-    d->waylandIntegration->display()->addRegistryListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++    if (!d->registered) {
++        d->waylandIntegration->display()->addRegistryListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++        d->registered = true;
++    }
+ }
+ 
+ QWaylandClientExtension::QWaylandClientExtension(const int ver)
+@@ -88,6 +91,13 @@ QWaylandClientExtension::QWaylandClientExtension(const int ver)
+     QMetaObject::invokeMethod(this, "addRegistryListener", Qt::QueuedConnection);
+ }
+ 
++QWaylandClientExtension::~QWaylandClientExtension()
++{
++    Q_D(QWaylandClientExtension);
++    if (d->registered && !QCoreApplication::closingDown())
++        d->waylandIntegration->display()->removeListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++}
++
+ QtWaylandClient::QWaylandIntegration *QWaylandClientExtension::integration() const
+ {
+     Q_D(const QWaylandClientExtension);
+diff --git a/qtwayland/src/client/global/qwaylandclientextension.h b/qtwayland/src/client/global/qwaylandclientextension.h
+index 98272e57..5bd28398 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension.h
++++ b/qtwayland/src/client/global/qwaylandclientextension.h
+@@ -63,6 +63,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandClientExtension : public QObject
+     Q_PROPERTY(bool active READ isActive NOTIFY activeChanged)
+ public:
+     QWaylandClientExtension(const int version);
++    ~QWaylandClientExtension();
+ 
+     QtWaylandClient::QWaylandIntegration *integration() const;
+     int version() const;
+diff --git a/qtwayland/src/client/global/qwaylandclientextension_p.h b/qtwayland/src/client/global/qwaylandclientextension_p.h
+index 69cc46a0..9091efbe 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension_p.h
++++ b/qtwayland/src/client/global/qwaylandclientextension_p.h
+@@ -68,6 +68,7 @@ public:
+     QtWaylandClient::QWaylandIntegration *waylandIntegration = nullptr;
+     int version = -1;
+     bool active = false;
++    bool registered = false;
+ };
+ 
+ class Q_WAYLAND_CLIENT_EXPORT QWaylandClientExtensionTemplatePrivate : public QWaylandClientExtensionPrivate
+diff --git a/qtwayland/src/client/qwaylanddatadevice.cpp b/qtwayland/src/client/qwaylanddatadevice.cpp
+index 7e2e3308..e3e60ed5 100644
+--- a/qtwayland/src/client/qwaylanddatadevice.cpp
++++ b/qtwayland/src/client/qwaylanddatadevice.cpp
+@@ -72,6 +72,8 @@ QWaylandDataDevice::QWaylandDataDevice(QWaylandDataDeviceManager *manager, QWayl
+ 
+ QWaylandDataDevice::~QWaylandDataDevice()
+ {
++    if (wl_data_device_get_version(object()) >= WL_DATA_DEVICE_RELEASE_SINCE_VERSION)
++        release();
+ }
+ 
+ QWaylandDataOffer *QWaylandDataDevice::selectionOffer() const
+@@ -110,7 +112,7 @@ QWaylandDataOffer *QWaylandDataDevice::dragOffer() const
+     return m_dragOffer.data();
+ }
+ 
+-bool QWaylandDataDevice::startDrag(QMimeData *mimeData, QWaylandWindow *icon)
++bool QWaylandDataDevice::startDrag(QMimeData *mimeData, Qt::DropActions supportedActions, QWaylandWindow *icon)
+ {
+     auto *seat = m_display->currentInputDevice();
+     auto *origin = seat->pointerFocus();
+@@ -123,7 +125,28 @@ bool QWaylandDataDevice::startDrag(QMimeData *mimeData, QWaylandWindow *icon)
+     }
+ 
+     m_dragSource.reset(new QWaylandDataSource(m_display->dndSelectionHandler(), mimeData));
++
++    if (wl_data_device_get_version(object()) >= 3)
++        m_dragSource->set_actions(dropActionsToWl(supportedActions));
++
+     connect(m_dragSource.data(), &QWaylandDataSource::cancelled, this, &QWaylandDataDevice::dragSourceCancelled);
++    connect(m_dragSource.data(), &QWaylandDataSource::dndResponseUpdated, this, [this](bool accepted, Qt::DropAction action) {
++            auto drag = static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag());
++            // in old versions drop action is not set, so we guess
++            if (wl_data_source_get_version(m_dragSource->object()) < 3) {
++                drag->setResponse(accepted);
++            } else {
++                QPlatformDropQtResponse response(accepted, action);
++                drag->setResponse(response);
++            }
++    });
++    connect(m_dragSource.data(), &QWaylandDataSource::dndDropped, this, [](bool accepted, Qt::DropAction action) {
++        QPlatformDropQtResponse response(accepted, action);
++        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setDropResponse(response);
++    });
++    connect(m_dragSource.data(), &QWaylandDataSource::finished, this, []() {
++        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag();
++    });
+ 
+     start_drag(m_dragSource->object(), origin->wlSurface(), icon->wlSurface(), m_display->currentInputDevice()->serial());
+     return true;
+@@ -152,7 +175,7 @@ void QWaylandDataDevice::data_device_drop()
+         supportedActions = drag->supportedActions();
+     } else if (m_dragOffer) {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     } else {
+         return;
+     }
+@@ -162,7 +185,11 @@ void QWaylandDataDevice::data_device_drop()
+                                                                           QGuiApplication::keyboardModifiers());
+ 
+     if (drag) {
+-        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag(response);
++        auto drag =  static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag());
++        drag->setDropResponse(response);
++        drag->finishDrag();
++    } else if (m_dragOffer) {
++        m_dragOffer->finish();
+     }
+ }
+ 
+@@ -186,7 +213,7 @@ void QWaylandDataDevice::data_device_enter(uint32_t serial, wl_surface *surface,
+         supportedActions = drag->supportedActions();
+     } else if (m_dragOffer) {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     }
+ 
+     const QPlatformDragQtResponse &response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
+@@ -197,11 +224,7 @@ void QWaylandDataDevice::data_device_enter(uint32_t serial, wl_surface *surface,
+         static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setResponse(response);
+     }
+ 
+-    if (response.isAccepted()) {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, m_dragOffer->firstFormat().toUtf8().constData());
+-    } else {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, nullptr);
+-    }
++    sendResponse(supportedActions, response);
+ }
+ 
+ void QWaylandDataDevice::data_device_leave()
+@@ -235,10 +258,10 @@ void QWaylandDataDevice::data_device_motion(uint32_t time, wl_fixed_t x, wl_fixe
+         supportedActions = drag->supportedActions();
+     } else {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     }
+ 
+-    QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
++    const QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
+                                                                           QGuiApplication::mouseButtons(),
+                                                                           QGuiApplication::keyboardModifiers());
+ 
+@@ -246,11 +269,7 @@ void QWaylandDataDevice::data_device_motion(uint32_t time, wl_fixed_t x, wl_fixe
+         static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setResponse(response);
+     }
+ 
+-    if (response.isAccepted()) {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, m_dragOffer->firstFormat().toUtf8().constData());
+-    } else {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, nullptr);
+-    }
++    sendResponse(supportedActions, response);
+ }
+ #endif // QT_CONFIG(draganddrop)
+ 
+@@ -277,14 +296,10 @@ void QWaylandDataDevice::selectionSourceCancelled()
+ #if QT_CONFIG(draganddrop)
+ void QWaylandDataDevice::dragSourceCancelled()
+ {
++    static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag();
+     m_dragSource.reset();
+ }
+ 
+-void QWaylandDataDevice::dragSourceTargetChanged(const QString &mimeType)
+-{
+-    static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->updateTarget(mimeType);
+-}
+-
+ QPoint QWaylandDataDevice::calculateDragPosition(int x, int y, QWindow *wnd) const
+ {
+     QPoint pnt(wl_fixed_to_int(x), wl_fixed_to_int(y));
+@@ -297,6 +312,33 @@ QPoint QWaylandDataDevice::calculateDragPosition(int x, int y, QWindow *wnd) con
+     }
+     return pnt;
+ }
++
++void QWaylandDataDevice::sendResponse(Qt::DropActions supportedActions, const QPlatformDragQtResponse &response)
++{
++    if (response.isAccepted()) {
++        if (wl_data_device_get_version(object()) >= 3)
++            m_dragOffer->set_actions(dropActionsToWl(supportedActions), dropActionsToWl(response.acceptedAction()));
++
++        m_dragOffer->accept(m_enterSerial, m_dragOffer->firstFormat());
++    } else {
++        m_dragOffer->accept(m_enterSerial, QString());
++    }
++}
++
++int QWaylandDataDevice::dropActionsToWl(Qt::DropActions actions)
++{
++
++    int wlActions = WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE;
++    if (actions & Qt::CopyAction)
++        wlActions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY;
++    if (actions & (Qt::MoveAction | Qt::TargetMoveAction))
++        wlActions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE;
++
++    // wayland does not support LinkAction at the time of writing
++    return wlActions;
++}
++
++
+ #endif // QT_CONFIG(draganddrop)
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddatadevice_p.h b/qtwayland/src/client/qwaylanddatadevice_p.h
+index 16c3ad28..801dcc2c 100644
+--- a/qtwayland/src/client/qwaylanddatadevice_p.h
++++ b/qtwayland/src/client/qwaylanddatadevice_p.h
+@@ -64,6 +64,7 @@ QT_REQUIRE_CONFIG(wayland_datadevice);
+ QT_BEGIN_NAMESPACE
+ 
+ class QMimeData;
++class QPlatformDragQtResponse;
+ class QWindow;
+ 
+ namespace QtWaylandClient {
+@@ -89,7 +90,7 @@ public:
+ 
+ #if QT_CONFIG(draganddrop)
+     QWaylandDataOffer *dragOffer() const;
+-    bool startDrag(QMimeData *mimeData, QWaylandWindow *icon);
++    bool startDrag(QMimeData *mimeData, Qt::DropActions supportedActions, QWaylandWindow *icon);
+     void cancelDrag();
+ #endif
+ 
+@@ -109,13 +110,16 @@ private Q_SLOTS:
+ 
+ #if QT_CONFIG(draganddrop)
+     void dragSourceCancelled();
+-    void dragSourceTargetChanged(const QString &mimeType);
+ #endif
+ 
+ private:
+ #if QT_CONFIG(draganddrop)
+     QPoint calculateDragPosition(int x, int y, QWindow *wnd) const;
+ #endif
++    void sendResponse(Qt::DropActions supportedActions, const QPlatformDragQtResponse &response);
++
++    static int dropActionsToWl(Qt::DropActions dropActions);
++
+ 
+     QWaylandDisplay *m_display = nullptr;
+     QWaylandInputDevice *m_inputDevice = nullptr;
+diff --git a/qtwayland/src/client/qwaylanddatadevicemanager.cpp b/qtwayland/src/client/qwaylanddatadevicemanager.cpp
+index 35d67307..6dc4f77f 100644
+--- a/qtwayland/src/client/qwaylanddatadevicemanager.cpp
++++ b/qtwayland/src/client/qwaylanddatadevicemanager.cpp
+@@ -50,8 +50,8 @@ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
+-QWaylandDataDeviceManager::QWaylandDataDeviceManager(QWaylandDisplay *display, uint32_t id)
+-    : wl_data_device_manager(display->wl_registry(), id, 1)
++QWaylandDataDeviceManager::QWaylandDataDeviceManager(QWaylandDisplay *display, int version, uint32_t id)
++    : wl_data_device_manager(display->wl_registry(), id, qMin(version, 3))
+     , m_display(display)
+ {
+     // Create transfer devices for all input devices.
+diff --git a/qtwayland/src/client/qwaylanddatadevicemanager_p.h b/qtwayland/src/client/qwaylanddatadevicemanager_p.h
+index bd05c0fb..510d9be4 100644
+--- a/qtwayland/src/client/qwaylanddatadevicemanager_p.h
++++ b/qtwayland/src/client/qwaylanddatadevicemanager_p.h
+@@ -68,7 +68,7 @@ class QWaylandInputDevice;
+ class Q_WAYLAND_CLIENT_EXPORT QWaylandDataDeviceManager : public QtWayland::wl_data_device_manager
+ {
+ public:
+-    QWaylandDataDeviceManager(QWaylandDisplay *display, uint32_t id);
++    QWaylandDataDeviceManager(QWaylandDisplay *display, int version, uint32_t id);
+     ~QWaylandDataDeviceManager() override;
+ 
+     QWaylandDataDevice *getDataDevice(QWaylandInputDevice *inputDevice);
+diff --git a/qtwayland/src/client/qwaylanddataoffer.cpp b/qtwayland/src/client/qwaylanddataoffer.cpp
+index 2297e8a1..fe0ea8c9 100644
+--- a/qtwayland/src/client/qwaylanddataoffer.cpp
++++ b/qtwayland/src/client/qwaylanddataoffer.cpp
+@@ -82,6 +82,15 @@ QMimeData *QWaylandDataOffer::mimeData()
+     return m_mimeData.data();
+ }
+ 
++Qt::DropActions QWaylandDataOffer::supportedActions() const
++{
++    if (wl_data_offer_get_version(const_cast<::wl_data_offer*>(object())) < 3) {
++        return Qt::MoveAction | Qt::CopyAction;
++    }
++
++    return m_supportedActions;
++}
++
+ void QWaylandDataOffer::startReceiving(const QString &mimeType, int fd)
+ {
+     receive(mimeType, fd);
+@@ -93,6 +102,22 @@ void QWaylandDataOffer::data_offer_offer(const QString &mime_type)
+     m_mimeData->appendFormat(mime_type);
+ }
+ 
++void QWaylandDataOffer::data_offer_action(uint32_t dnd_action)
++{
++    Q_UNUSED(dnd_action);
++    // This is the compositor telling the drag target what action it should perform
++    // It does not map nicely into Qt final drop semantics, other than pretending there is only one supported action?
++}
++
++void QWaylandDataOffer::data_offer_source_actions(uint32_t source_actions)
++{
++    m_supportedActions = Qt::DropActions();
++    if (source_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
++        m_supportedActions |= Qt::MoveAction;
++    if (source_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
++        m_supportedActions |= Qt::CopyAction;
++}
++
+ QWaylandMimeData::QWaylandMimeData(QWaylandAbstractDataOffer *dataOffer)
+     : m_dataOffer(dataOffer)
+ {
+@@ -163,17 +188,18 @@ QVariant QWaylandMimeData::retrieveData_sys(const QString &mimeType, QVariant::T
+ 
+ int QWaylandMimeData::readData(int fd, QByteArray &data) const
+ {
+-    fd_set readset;
+-    FD_ZERO(&readset);
+-    FD_SET(fd, &readset);
+-    struct timeval timeout;
++    struct pollfd readset;
++    readset.fd = fd;
++    readset.events = POLLIN;
++    struct timespec timeout;
+     timeout.tv_sec = 1;
+-    timeout.tv_usec = 0;
++    timeout.tv_nsec = 0;
++
+ 
+     Q_FOREVER {
+-        int ready = select(FD_SETSIZE, &readset, nullptr, nullptr, &timeout);
++        int ready = qt_safe_poll(&readset, 1, &timeout);
+         if (ready < 0) {
+-            qWarning() << "QWaylandDataOffer: select() failed";
++            qWarning() << "QWaylandDataOffer: qt_safe_poll() failed";
+             return -1;
+         } else if (ready == 0) {
+             qWarning("QWaylandDataOffer: timeout reading from pipe");
+diff --git a/qtwayland/src/client/qwaylanddataoffer_p.h b/qtwayland/src/client/qwaylanddataoffer_p.h
+index 9cf1483c..6f667398 100644
+--- a/qtwayland/src/client/qwaylanddataoffer_p.h
++++ b/qtwayland/src/client/qwaylanddataoffer_p.h
+@@ -82,6 +82,7 @@ public:
+     explicit QWaylandDataOffer(QWaylandDisplay *display, struct ::wl_data_offer *offer);
+     ~QWaylandDataOffer() override;
+     QMimeData *mimeData() override;
++    Qt::DropActions supportedActions() const;
+ 
+     QString firstFormat() const;
+ 
+@@ -89,10 +90,13 @@ public:
+ 
+ protected:
+     void data_offer_offer(const QString &mime_type) override;
++    void data_offer_source_actions(uint32_t source_actions) override;
++    void data_offer_action(uint32_t dnd_action) override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+     QScopedPointer<QWaylandMimeData> m_mimeData;
++    Qt::DropActions m_supportedActions;
+ };
+ 
+ 
+diff --git a/qtwayland/src/client/qwaylanddatasource.cpp b/qtwayland/src/client/qwaylanddatasource.cpp
+index f45122fb..5599cbd4 100644
+--- a/qtwayland/src/client/qwaylanddatasource.cpp
++++ b/qtwayland/src/client/qwaylanddatasource.cpp
+@@ -101,7 +101,32 @@ void QWaylandDataSource::data_source_send(const QString &mime_type, int32_t fd)
+ 
+ void QWaylandDataSource::data_source_target(const QString &mime_type)
+ {
+-    Q_EMIT targetChanged(mime_type);
++    m_accepted = !mime_type.isEmpty();
++    Q_EMIT dndResponseUpdated(m_accepted, m_dropAction);
++}
++
++void QWaylandDataSource::data_source_action(uint32_t action)
++{
++    Qt::DropAction qtAction = Qt::IgnoreAction;
++
++    if (action == WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
++        qtAction = Qt::MoveAction;
++    else if (action == WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
++        qtAction = Qt::CopyAction;
++
++    m_dropAction = qtAction;
++    Q_EMIT dndResponseUpdated(m_accepted, m_dropAction);
++}
++
++void QWaylandDataSource::data_source_dnd_finished()
++{
++    Q_EMIT finished();
++}
++
++void QWaylandDataSource::data_source_dnd_drop_performed()
++{
++
++    Q_EMIT dndDropped(m_accepted, m_dropAction);
+ }
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddatasource_p.h b/qtwayland/src/client/qwaylanddatasource_p.h
+index 25afff79..96f07bc3 100644
+--- a/qtwayland/src/client/qwaylanddatasource_p.h
++++ b/qtwayland/src/client/qwaylanddatasource_p.h
+@@ -77,17 +77,25 @@ public:
+     QMimeData *mimeData() const;
+ 
+ Q_SIGNALS:
+-    void targetChanged(const QString &mime_type);
+     void cancelled();
++    void finished();
++
++    void dndResponseUpdated(bool accepted, Qt::DropAction action);
++    void dndDropped(bool accepted, Qt::DropAction action);
+ 
+ protected:
+     void data_source_cancelled() override;
+     void data_source_send(const QString &mime_type, int32_t fd) override;
+     void data_source_target(const QString &mime_type) override;
++    void data_source_dnd_drop_performed() override;
++    void data_source_dnd_finished() override;
++    void data_source_action(uint32_t action) override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+     QMimeData *m_mime_data = nullptr;
++    bool m_accepted = false;
++    Qt::DropAction m_dropAction = Qt::IgnoreAction;
+ };
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddisplay.cpp b/qtwayland/src/client/qwaylanddisplay.cpp
+index f10c1f79..c01e238b 100644
+--- a/qtwayland/src/client/qwaylanddisplay.cpp
++++ b/qtwayland/src/client/qwaylanddisplay.cpp
+@@ -85,10 +85,203 @@
+ 
+ #include <errno.h>
+ 
++#include <tuple> // for std::tie
++
++static void checkWaylandError(struct wl_display *display)
++{
++    int ecode = wl_display_get_error(display);
++    if ((ecode == EPIPE || ecode == ECONNRESET)) {
++        // special case this to provide a nicer error
++        qWarning("The Wayland connection broke. Did the Wayland compositor die?");
++    } else {
++        qWarning("The Wayland connection experienced a fatal error: %s", strerror(ecode));
++    }
++    _exit(1);
++}
++
+ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
++class EventThread : public QThread
++{
++    Q_OBJECT
++public:
++    enum OperatingMode {
++        EmitToDispatch, // Emit the signal, allow dispatching in a differnt thread.
++        SelfDispatch, // Dispatch the events inside this thread.
++    };
++
++    EventThread(struct wl_display * wl, struct wl_event_queue * ev_queue,
++                OperatingMode mode)
++        : m_fd(wl_display_get_fd(wl))
++        , m_pipefd{ -1, -1 }
++        , m_wldisplay(wl)
++        , m_wlevqueue(ev_queue)
++        , m_mode(mode)
++        , m_reading(true)
++        , m_quitting(false)
++    {
++        setObjectName(QStringLiteral("WaylandEventThread"));
++    }
++
++    void readAndDispatchEvents()
++    {
++        /*
++         * Dispatch pending events and flush the requests at least once. If the event thread
++         * is not reading, try to call _prepare_read() to allow the event thread to poll().
++         * If that fails, re-try dispatch & flush again until _prepare_read() is successful.
++         *
++         * This allow any call to readAndDispatchEvents() to start event thread's polling,
++         * not only the one issued from event thread's waitForReading(), which means functions
++         * called from dispatch_pending() can safely spin an event loop.
++         */
++        for (;;) {
++            if (dispatchQueuePending() < 0) {
++                checkWaylandError(m_wldisplay);
++                return;
++            }
++
++            wl_display_flush(m_wldisplay);
++
++            // We have to check if event thread is reading every time we dispatch
++            // something, as that may recursively call this function.
++            if (m_reading.loadAcquire())
++                break;
++
++            if (prepareReadQueue() == 0) {
++                QMutexLocker l(&m_mutex);
++                m_reading.storeRelease(true);
++                m_cond.wakeOne();
++                break;
++            }
++        }
++    }
++
++    void stop()
++    {
++        // We have to both write to the pipe and set the flag, as the thread may be
++        // either in the poll() or waiting for _prepare_read().
++        if (m_pipefd[1] != -1 && write(m_pipefd[1], "\0", 1) == -1)
++            qWarning("Failed to write to the pipe: %s.", strerror(errno));
++
++        {
++            QMutexLocker l(&m_mutex);
++            m_quitting = true;
++            m_cond.wakeOne();
++        }
++
++        wait();
++    }
++
++Q_SIGNALS:
++    void needReadAndDispatch();
++
++protected:
++    void run() override
++    {
++        // we use this pipe to make the loop exit otherwise if we simply used a flag on the loop condition, if stop() gets
++        // called while poll() is blocking the thread will never quit since there are no wayland messages coming anymore.
++        struct Pipe
++        {
++            Pipe(int *fds)
++                : fds(fds)
++            {
++                if (qt_safe_pipe(fds) != 0)
++                    qWarning("Pipe creation failed. Quitting may hang.");
++            }
++            ~Pipe()
++            {
++                if (fds[0] != -1) {
++                    close(fds[0]);
++                    close(fds[1]);
++                }
++            }
++
++            int *fds;
++        } pipe(m_pipefd);
++
++        // Make the main thread call wl_prepare_read(), dispatch the pending messages and flush the
++        // outbound ones. Wait until it's done before proceeding, unless we're told to quit.
++        while (waitForReading()) {
++            pollfd fds[2] = { { m_fd, POLLIN, 0 }, { m_pipefd[0], POLLIN, 0 } };
++            poll(fds, 2, -1);
++
++            if (fds[1].revents & POLLIN) {
++                // we don't really care to read the byte that was written here since we're closing down
++                wl_display_cancel_read(m_wldisplay);
++                break;
++            }
++
++            if (fds[0].revents & POLLIN)
++                wl_display_read_events(m_wldisplay);
++                // The polll was succesfull and the event thread did the wl_display_read_events(). On the next iteration of the loop
++                // the event sent to the main thread will cause it to dispatch the messages just read, unless the loop exits in which
++                // case we don't care anymore about them.
++            else
++                wl_display_cancel_read(m_wldisplay);
++        }
++    }
++
++private:
++    bool waitForReading()
++    {
++        Q_ASSERT(QThread::currentThread() == this);
++
++        m_reading.storeRelease(false);
++
++        if (m_mode == SelfDispatch) {
++            readAndDispatchEvents();
++        } else {
++            Q_EMIT needReadAndDispatch();
++
++            QMutexLocker lock(&m_mutex);
++            // m_reading might be set from our emit or some other invocation of
++            // readAndDispatchEvents().
++            while (!m_reading.loadRelaxed() && !m_quitting)
++                m_cond.wait(&m_mutex);
++        }
++
++        return !m_quitting;
++    }
++
++    int dispatchQueuePending()
++    {
++        if (m_wlevqueue)
++            return wl_display_dispatch_queue_pending(m_wldisplay, m_wlevqueue);
++        else
++            return wl_display_dispatch_pending(m_wldisplay);
++    }
++
++    int prepareReadQueue()
++    {
++        if (m_wlevqueue)
++            return wl_display_prepare_read_queue(m_wldisplay, m_wlevqueue);
++        else
++            return wl_display_prepare_read(m_wldisplay);
++    }
++
++    int m_fd;
++    int m_pipefd[2];
++    wl_display *m_wldisplay;
++    wl_event_queue *m_wlevqueue;
++    OperatingMode m_mode;
++
++    /* Concurrency note when operating in EmitToDispatch mode:
++     * m_reading is set to false inside event thread's waitForReading(), and is
++     * set to true inside main thread's readAndDispatchEvents().
++     * The lock is not taken when setting m_reading to false, as the main thread
++     * is not actively waiting for it to turn false. However, the lock is taken
++     * inside readAndDispatchEvents() before setting m_reading to true,
++     * as the event thread is actively waiting for it under the wait condition.
++     */
++
++    QAtomicInteger<bool> m_reading;
++    bool m_quitting;
++    QMutex m_mutex;
++    QWaitCondition m_cond;
++};
++
+ Q_LOGGING_CATEGORY(lcQpaWayland, "qt.qpa.wayland"); // for general (uncategorized) Wayland platform logging
+ 
+ struct wl_surface *QWaylandDisplay::createSurface(void *handle)
+@@ -158,17 +351,16 @@ QWaylandDisplay::QWaylandDisplay(QWaylandIntegration *waylandIntegration)
+     if (!mXkbContext)
+         qCWarning(lcQpaWayland, "failed to create xkb context");
+ #endif
+-
+-    forceRoundTrip();
+-
+-    if (!mWaitingScreens.isEmpty()) {
+-        // Give wl_output.done and zxdg_output_v1.done events a chance to arrive
+-        forceRoundTrip();
+-    }
+ }
+ 
+ QWaylandDisplay::~QWaylandDisplay(void)
+ {
++    if (m_eventThread)
++        m_eventThread->stop();
++
++    if (m_frameEventQueueThread)
++        m_frameEventQueueThread->stop();
++
+     if (mSyncCallback)
+         wl_callback_destroy(mSyncCallback);
+ 
+@@ -187,6 +379,21 @@ QWaylandDisplay::~QWaylandDisplay(void)
+ #endif
+     if (mDisplay)
+         wl_display_disconnect(mDisplay);
++
++    if (m_frameEventQueue)
++        wl_event_queue_destroy(m_frameEventQueue);
++}
++
++// Steps which is called just after constructor. This separates registry_global() out of the constructor
++// so that factory functions in integration can be overridden.
++void QWaylandDisplay::initialize()
++{
++    forceRoundTrip();
++
++    if (!mWaitingScreens.isEmpty()) {
++        // Give wl_output.done and zxdg_output_v1.done events a chance to arrive
++        forceRoundTrip();
++    }
+ }
+ 
+ void QWaylandDisplay::ensureScreen()
+@@ -203,98 +410,37 @@ void QWaylandDisplay::ensureScreen()
+ 
+ void QWaylandDisplay::checkError() const
+ {
+-    int ecode = wl_display_get_error(mDisplay);
+-    if ((ecode == EPIPE || ecode == ECONNRESET)) {
+-        // special case this to provide a nicer error
+-        qWarning("The Wayland connection broke. Did the Wayland compositor die?");
+-    } else {
+-        qWarning("The Wayland connection experienced a fatal error: %s", strerror(ecode));
+-    }
+-    _exit(1);
++    checkWaylandError(mDisplay);
+ }
+ 
++// Called in main thread, either from queued signal or directly.
+ void QWaylandDisplay::flushRequests()
+ {
+-    if (wl_display_prepare_read(mDisplay) == 0) {
+-        wl_display_read_events(mDisplay);
+-    }
+-
+-    if (wl_display_dispatch_pending(mDisplay) < 0)
+-        checkError();
+-
+-    {
+-        QReadLocker locker(&m_frameQueueLock);
+-        for (const FrameQueue &q : mExternalQueues) {
+-            QMutexLocker locker(q.mutex);
+-            while (wl_display_prepare_read_queue(mDisplay, q.queue) != 0)
+-                wl_display_dispatch_queue_pending(mDisplay, q.queue);
+-            wl_display_read_events(mDisplay);
+-            wl_display_dispatch_queue_pending(mDisplay, q.queue);
+-        }
+-    }
+-
+-    wl_display_flush(mDisplay);
+-}
+-
+-void QWaylandDisplay::blockingReadEvents()
+-{
+-    if (wl_display_dispatch(mDisplay) < 0)
+-        checkError();
+-}
+-
+-void QWaylandDisplay::destroyFrameQueue(const QWaylandDisplay::FrameQueue &q)
+-{
+-    QWriteLocker locker(&m_frameQueueLock);
+-    auto it = std::find_if(mExternalQueues.begin(),
+-                           mExternalQueues.end(),
+-                           [&q] (const QWaylandDisplay::FrameQueue &other){ return other.queue == q.queue; });
+-    Q_ASSERT(it != mExternalQueues.end());
+-    mExternalQueues.erase(it);
+-    if (q.queue != nullptr)
+-        wl_event_queue_destroy(q.queue);
+-    delete q.mutex;
++    m_eventThread->readAndDispatchEvents();
+ }
+ 
+-QWaylandDisplay::FrameQueue QWaylandDisplay::createFrameQueue()
++// We have to wait until we have an eventDispatcher before creating the eventThread,
++// otherwise forceRoundTrip() may block inside _events_read() because eventThread is
++// polling.
++void QWaylandDisplay::initEventThread()
+ {
+-    QWriteLocker locker(&m_frameQueueLock);
+-    FrameQueue q{createEventQueue()};
+-    mExternalQueues.append(q);
+-    return q;
+-}
++    m_eventThread.reset(
++            new EventThread(mDisplay, /* default queue */ nullptr, EventThread::EmitToDispatch));
++    connect(m_eventThread.get(), &EventThread::needReadAndDispatch, this,
++            &QWaylandDisplay::flushRequests, Qt::QueuedConnection);
++    m_eventThread->start();
+ 
+-wl_event_queue *QWaylandDisplay::createEventQueue()
+-{
+-    return wl_display_create_queue(mDisplay);
++    // wl_display_disconnect() free this.
++    m_frameEventQueue = wl_display_create_queue(mDisplay);
++    m_frameEventQueueThread.reset(
++            new EventThread(mDisplay, m_frameEventQueue, EventThread::SelfDispatch));
++    m_frameEventQueueThread->start();
+ }
+ 
+-void QWaylandDisplay::dispatchQueueWhile(wl_event_queue *queue, std::function<bool ()> condition, int timeout)
++void QWaylandDisplay::blockingReadEvents()
+ {
+-    if (!condition())
+-        return;
+-
+-    QElapsedTimer timer;
+-    timer.start();
+-    struct pollfd pFd = qt_make_pollfd(wl_display_get_fd(mDisplay), POLLIN);
+-    while (timeout == -1 || timer.elapsed() < timeout) {
+-        while (wl_display_prepare_read_queue(mDisplay, queue) != 0)
+-            wl_display_dispatch_queue_pending(mDisplay, queue);
+-
+-        wl_display_flush(mDisplay);
+-
+-        const int remaining = qMax(timeout - timer.elapsed(), 0ll);
+-        const int pollTimeout = timeout == -1 ? -1 : remaining;
+-        if (qt_poll_msecs(&pFd, 1, pollTimeout) > 0)
+-            wl_display_read_events(mDisplay);
+-        else
+-            wl_display_cancel_read(mDisplay);
+-
+-        if (wl_display_dispatch_queue_pending(mDisplay, queue) < 0)
+-            checkError();
+-
+-        if (!condition())
+-            break;
+-    }
++    if (wl_display_dispatch(mDisplay) < 0)
++        checkWaylandError(mDisplay);
+ }
+ 
+ QWaylandScreen *QWaylandDisplay::screenForOutput(struct wl_output *output) const
+@@ -345,7 +491,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+     if (interface == QStringLiteral("wl_output")) {
+         mWaitingScreens << new QWaylandScreen(this, version, id);
+     } else if (interface == QStringLiteral("wl_compositor")) {
+-        mCompositorVersion = qMin((int)version, 3);
++        mCompositorVersion = qMin((int)version, 4);
+         mCompositor.init(registry, id, mCompositorVersion);
+     } else if (interface == QStringLiteral("wl_shm")) {
+         mShm.reset(new QWaylandShm(this, version, id));
+@@ -354,7 +500,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+         mInputDevices.append(inputDevice);
+ #if QT_CONFIG(wayland_datadevice)
+     } else if (interface == QStringLiteral("wl_data_device_manager")) {
+-        mDndSelectionHandler.reset(new QWaylandDataDeviceManager(this, id));
++        mDndSelectionHandler.reset(new QWaylandDataDeviceManager(this, version, id));
+ #endif
+     } else if (interface == QStringLiteral("qt_surface_extension")) {
+         mWindowExtension.reset(new QtWayland::qt_surface_extension(registry, id, 1));
+@@ -369,6 +515,8 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+ #if QT_CONFIG(wayland_client_primary_selection)
+     } else if (interface == QStringLiteral("zwp_primary_selection_device_manager_v1")) {
+         mPrimarySelectionManager.reset(new QWaylandPrimarySelectionDeviceManagerV1(this, id, 1));
++        for (QWaylandInputDevice *inputDevice : qAsConst(mInputDevices))
++            inputDevice->setPrimarySelectionDevice(mPrimarySelectionManager->createDevice(inputDevice));
+ #endif
+     } else if (interface == QStringLiteral("zwp_text_input_manager_v2") && !mClientSideInputContextRequested) {
+         mTextInputManager.reset(new QtWayland::zwp_text_input_manager_v2(registry, id, 1));
+@@ -427,6 +575,13 @@ void QWaylandDisplay::registry_global_remove(uint32_t id)
+                     inputDevice->setTextInput(nullptr);
+                 mWaylandIntegration->reconfigureInputContext();
+             }
++#if QT_CONFIG(wayland_client_primary_selection)
++            if (global.interface == QStringLiteral("zwp_primary_selection_device_manager_v1")) {
++                mPrimarySelectionManager.reset();
++                for (QWaylandInputDevice *inputDevice : qAsConst(mInputDevices))
++                    inputDevice->setPrimarySelectionDevice(nullptr);
++            }
++#endif
+             mGlobals.removeAt(i);
+             break;
+         }
+@@ -452,9 +607,10 @@ void QWaylandDisplay::addRegistryListener(RegistryListener listener, void *data)
+ 
+ void QWaylandDisplay::removeListener(RegistryListener listener, void *data)
+ {
+-    std::remove_if(mRegistryListeners.begin(), mRegistryListeners.end(), [=](Listener l){
++    auto iter = std::remove_if(mRegistryListeners.begin(), mRegistryListeners.end(), [=](Listener l){
+         return (l.listener == listener && l.data == data);
+     });
++    mRegistryListeners.erase(iter, mRegistryListeners.end());
+ }
+ 
+ uint32_t QWaylandDisplay::currentTimeMillisec()
+@@ -467,50 +623,9 @@ uint32_t QWaylandDisplay::currentTimeMillisec()
+     return 0;
+ }
+ 
+-static void
+-sync_callback(void *data, struct wl_callback *callback, uint32_t serial)
+-{
+-    Q_UNUSED(serial)
+-    bool *done = static_cast<bool *>(data);
+-
+-    *done = true;
+-
+-    // If the wl_callback done event is received after the condition check in the while loop in
+-    // forceRoundTrip(), but before the call to processEvents, the call to processEvents may block
+-    // forever if no more events are posted (eventhough the callback is handled in response to the
+-    // aboutToBlock signal). Hence, we wake up the event dispatcher so forceRoundTrip may return.
+-    // (QTBUG-64696)
+-    if (auto *dispatcher = QThread::currentThread()->eventDispatcher())
+-        dispatcher->wakeUp();
+-
+-    wl_callback_destroy(callback);
+-}
+-
+-static const struct wl_callback_listener sync_listener = {
+-    sync_callback
+-};
+-
+ void QWaylandDisplay::forceRoundTrip()
+ {
+-    // wl_display_roundtrip() works on the main queue only,
+-    // but we use a separate one, so basically reimplement it here
+-    int ret = 0;
+-    bool done = false;
+-    wl_callback *callback = wl_display_sync(mDisplay);
+-    wl_callback_add_listener(callback, &sync_listener, &done);
+-    flushRequests();
+-    if (QThread::currentThread()->eventDispatcher()) {
+-        while (!done && ret >= 0) {
+-            QThread::currentThread()->eventDispatcher()->processEvents(QEventLoop::WaitForMoreEvents);
+-            ret = wl_display_dispatch_pending(mDisplay);
+-        }
+-    } else {
+-        while (!done && ret >= 0)
+-            ret = wl_display_dispatch(mDisplay);
+-    }
+-
+-    if (ret == -1 && !done)
+-        wl_callback_destroy(callback);
++     wl_display_roundtrip(mDisplay);
+ }
+ 
+ bool QWaylandDisplay::supportsWindowDecoration() const
+@@ -574,14 +689,10 @@ void QWaylandDisplay::handleKeyboardFocusChanged(QWaylandInputDevice *inputDevic
+     if (mLastKeyboardFocus == keyboardFocus)
+         return;
+ 
+-    if (mWaylandIntegration->mShellIntegration) {
+-        mWaylandIntegration->mShellIntegration->handleKeyboardFocusChanged(keyboardFocus, mLastKeyboardFocus);
+-    } else {
+-        if (keyboardFocus)
+-            handleWindowActivated(keyboardFocus);
+-        if (mLastKeyboardFocus)
+-            handleWindowDeactivated(mLastKeyboardFocus);
+-    }
++    if (keyboardFocus)
++        handleWindowActivated(keyboardFocus);
++    if (mLastKeyboardFocus)
++        handleWindowDeactivated(mLastKeyboardFocus);
+ 
+     mLastKeyboardFocus = keyboardFocus;
+ }
+@@ -600,6 +711,19 @@ void QWaylandDisplay::handleWaylandSync()
+     QWindow *activeWindow = mActiveWindows.empty() ? nullptr : mActiveWindows.last()->window();
+     if (activeWindow != QGuiApplication::focusWindow())
+         QWindowSystemInterface::handleWindowActivated(activeWindow);
++
++    if (!activeWindow) {
++        if (lastInputDevice()) {
++#if QT_CONFIG(clipboard)
++            if (auto *dataDevice = lastInputDevice()->dataDevice())
++                dataDevice->invalidateSelectionOffer();
++#endif
++#if QT_CONFIG(wayland_client_primary_selection)
++            if (auto *device = lastInputDevice()->primarySelectionDevice())
++                device->invalidateSelectionOffer();
++#endif
++        }
++    }
+ }
+ 
+ const wl_callback_listener QWaylandDisplay::syncCallbackListener = {
+@@ -626,6 +750,13 @@ QWaylandInputDevice *QWaylandDisplay::defaultInputDevice() const
+     return mInputDevices.isEmpty() ? 0 : mInputDevices.first();
+ }
+ 
++bool QWaylandDisplay::isKeyboardAvailable() const
++{
++    return std::any_of(
++            mInputDevices.constBegin(), mInputDevices.constEnd(),
++            [this](const QWaylandInputDevice *device) { return device->keyboard() != nullptr; });
++}
++
+ #if QT_CONFIG(cursor)
+ 
+ QWaylandCursor *QWaylandDisplay::waylandCursor()
+@@ -652,4 +783,6 @@ QWaylandCursorTheme *QWaylandDisplay::loadCursorTheme(const QString &name, int p
+ 
+ } // namespace QtWaylandClient
+ 
++#include "qwaylanddisplay.moc"
++
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/client/qwaylanddisplay_p.h b/qtwayland/src/client/qwaylanddisplay_p.h
+index 3b092bc8..42bc661d 100644
+--- a/qtwayland/src/client/qwaylanddisplay_p.h
++++ b/qtwayland/src/client/qwaylanddisplay_p.h
+@@ -109,6 +109,7 @@ class QWaylandSurface;
+ class QWaylandShellIntegration;
+ class QWaylandCursor;
+ class QWaylandCursorTheme;
++class EventThread;
+ 
+ typedef void (*RegistryListener)(void *data,
+                                  struct wl_registry *registry,
+@@ -120,15 +121,11 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandDisplay : public QObject, public QtWayland
+     Q_OBJECT
+ 
+ public:
+-    struct FrameQueue {
+-        FrameQueue(wl_event_queue *q = nullptr) : queue(q), mutex(new QMutex) {}
+-        wl_event_queue *queue;
+-        QMutex *mutex;
+-    };
+-
+     QWaylandDisplay(QWaylandIntegration *waylandIntegration);
+     ~QWaylandDisplay(void) override;
+ 
++    void initialize();
++
+ #if QT_CONFIG(xkbcommon)
+     struct xkb_context *xkbContext() const { return mXkbContext.get(); }
+ #endif
+@@ -210,11 +207,11 @@ public:
+     void handleKeyboardFocusChanged(QWaylandInputDevice *inputDevice);
+     void handleWindowDestroyed(QWaylandWindow *window);
+ 
+-    wl_event_queue *createEventQueue();
+-    FrameQueue createFrameQueue();
+-    void destroyFrameQueue(const FrameQueue &q);
+-    void dispatchQueueWhile(wl_event_queue *queue, std::function<bool()> condition, int timeout = -1);
++    wl_event_queue *frameEventQueue() { return m_frameEventQueue; };
++
++    bool isKeyboardAvailable() const;
+ 
++    void initEventThread();
+ public slots:
+     void blockingReadEvents();
+     void flushRequests();
+@@ -237,6 +234,9 @@ private:
+     };
+ 
+     struct wl_display *mDisplay = nullptr;
++    QScopedPointer<EventThread> m_eventThread;
++    wl_event_queue *m_frameEventQueue = nullptr;
++    QScopedPointer<EventThread> m_frameEventQueueThread;
+     QtWayland::wl_compositor mCompositor;
+     QScopedPointer<QWaylandShm> mShm;
+     QList<QWaylandScreen *> mWaitingScreens;
+@@ -273,11 +273,9 @@ private:
+     QWaylandInputDevice *mLastInputDevice = nullptr;
+     QPointer<QWaylandWindow> mLastInputWindow;
+     QPointer<QWaylandWindow> mLastKeyboardFocus;
+-    QVector<QWaylandWindow *> mActiveWindows;
+-    QVector<FrameQueue> mExternalQueues;
++    QList<QWaylandWindow *> mActiveWindows;
+     struct wl_callback *mSyncCallback = nullptr;
+     static const wl_callback_listener syncCallbackListener;
+-    QReadWriteLock m_frameQueueLock;
+ 
+     bool mClientSideInputContextRequested = !QPlatformInputContextFactory::requested().isNull();
+ 
+diff --git a/qtwayland/src/client/qwaylanddnd.cpp b/qtwayland/src/client/qwaylanddnd.cpp
+index 6535aa16..7c53f5fa 100644
+--- a/qtwayland/src/client/qwaylanddnd.cpp
++++ b/qtwayland/src/client/qwaylanddnd.cpp
+@@ -66,7 +66,7 @@ void QWaylandDrag::startDrag()
+ {
+     QBasicDrag::startDrag();
+     QWaylandWindow *icon = static_cast<QWaylandWindow *>(shapedPixmapWindow()->handle());
+-    if (m_display->currentInputDevice()->dataDevice()->startDrag(drag()->mimeData(), icon)) {
++    if (m_display->currentInputDevice()->dataDevice()->startDrag(drag()->mimeData(), drag()->supportedActions(), icon)) {
+         icon->addAttachOffset(-drag()->hotSpot());
+     } else {
+         // Cancelling immediately does not work, since the event loop for QDrag::exec is started
+@@ -80,6 +80,9 @@ void QWaylandDrag::cancel()
+     QBasicDrag::cancel();
+ 
+     m_display->currentInputDevice()->dataDevice()->cancelDrag();
++
++    if (drag())
++        drag()->deleteLater();
+ }
+ 
+ void QWaylandDrag::move(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods)
+@@ -103,33 +106,41 @@ void QWaylandDrag::endDrag()
+     m_display->currentInputDevice()->handleEndDrag();
+ }
+ 
+-void QWaylandDrag::updateTarget(const QString &mimeType)
++void QWaylandDrag::setResponse(bool accepted)
+ {
+-    setCanDrop(!mimeType.isEmpty());
+-
+-    if (canDrop()) {
+-        updateCursor(defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers()));
+-    } else {
+-        updateCursor(Qt::IgnoreAction);
+-    }
++    // This method is used for old DataDevices where the drag action is not communicated
++    Qt::DropAction action = defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers());
++    setResponse(QPlatformDropQtResponse(accepted, action));
+ }
+ 
+-void QWaylandDrag::setResponse(const QPlatformDragQtResponse &response)
++void QWaylandDrag::setResponse(const QPlatformDropQtResponse &response)
+ {
+     setCanDrop(response.isAccepted());
+ 
+     if (canDrop()) {
+-        updateCursor(defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers()));
++        updateCursor(response.acceptedAction());
+     } else {
+         updateCursor(Qt::IgnoreAction);
+     }
+ }
+ 
+-void QWaylandDrag::finishDrag(const QPlatformDropQtResponse &response)
++void QWaylandDrag::setDropResponse(const QPlatformDropQtResponse &response)
+ {
+     setExecutedDropAction(response.acceptedAction());
++}
++
++void QWaylandDrag::finishDrag()
++{
+     QKeyEvent event(QEvent::KeyPress, Qt::Key_Escape, Qt::NoModifier);
+     eventFilter(shapedPixmapWindow(), &event);
++
++    if (drag())
++        drag()->deleteLater();
++}
++
++bool QWaylandDrag::ownsDragObject() const
++{
++    return true;
+ }
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddnd_p.h b/qtwayland/src/client/qwaylanddnd_p.h
+index 474fe2ab..46f629ac 100644
+--- a/qtwayland/src/client/qwaylanddnd_p.h
++++ b/qtwayland/src/client/qwaylanddnd_p.h
+@@ -71,9 +71,10 @@ public:
+     QWaylandDrag(QWaylandDisplay *display);
+     ~QWaylandDrag() override;
+ 
+-    void updateTarget(const QString &mimeType);
+-    void setResponse(const QPlatformDragQtResponse &response);
+-    void finishDrag(const QPlatformDropQtResponse &response);
++    void setResponse(bool accepted);
++    void setResponse(const QPlatformDropQtResponse &response);
++    void setDropResponse(const QPlatformDropQtResponse &response);
++    void finishDrag();
+ 
+ protected:
+     void startDrag() override;
+@@ -82,6 +83,7 @@ protected:
+     void drop(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods) override;
+     void endDrag() override;
+ 
++    bool ownsDragObject() const override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+diff --git a/qtwayland/src/client/qwaylandinputdevice.cpp b/qtwayland/src/client/qwaylandinputdevice.cpp
+index 613fe862..4b90de84 100644
+--- a/qtwayland/src/client/qwaylandinputdevice.cpp
++++ b/qtwayland/src/client/qwaylandinputdevice.cpp
+@@ -685,6 +685,11 @@ public:
+ 
+ void QWaylandInputDevice::Pointer::pointer_leave(uint32_t time, struct wl_surface *surface)
+ {
++    invalidateFocus();
++    mButtons = Qt::NoButton;
++
++    mParent->mTime = time;
++
+     // The event may arrive after destroying the window, indicated by
+     // a null surface.
+     if (!surface)
+@@ -696,11 +701,6 @@ void QWaylandInputDevice::Pointer::pointer_leave(uint32_t time, struct wl_surfac
+ 
+     if (!QWaylandWindow::mouseGrab())
+         setFrameEvent(new LeaveEvent(window, mSurfacePos, mGlobalPos));
+-
+-    invalidateFocus();
+-    mButtons = Qt::NoButton;
+-
+-    mParent->mTime = time;
+ }
+ 
+ class MotionEvent : public QWaylandPointerEvent
+@@ -1300,14 +1300,6 @@ void QWaylandInputDevice::Keyboard::handleFocusDestroyed()
+ void QWaylandInputDevice::Keyboard::handleFocusLost()
+ {
+     mFocus = nullptr;
+-#if QT_CONFIG(clipboard)
+-    if (auto *dataDevice = mParent->dataDevice())
+-        dataDevice->invalidateSelectionOffer();
+-#endif
+-#if QT_CONFIG(wayland_client_primary_selection)
+-    if (auto *device = mParent->primarySelectionDevice())
+-        device->invalidateSelectionOffer();
+-#endif
+     mParent->mQDisplay->handleKeyboardFocusChanged(mParent);
+     mRepeatTimer.stop();
+ }
+@@ -1396,6 +1388,7 @@ void QWaylandInputDevice::Touch::touch_cancel()
+     if (touchExt)
+         touchExt->touchCanceled();
+ 
++    mFocus = nullptr;
+     QWindowSystemInterface::handleTouchCancelEvent(nullptr, mParent->mTouchDevice);
+ }
+ 
+diff --git a/qtwayland/src/client/qwaylandintegration.cpp b/qtwayland/src/client/qwaylandintegration.cpp
+index c53ccb78..54861600 100644
+--- a/qtwayland/src/client/qwaylandintegration.cpp
++++ b/qtwayland/src/client/qwaylandintegration.cpp
+@@ -125,6 +125,9 @@ QWaylandIntegration::QWaylandIntegration()
+ #endif
+ 
+     reconfigureInputContext();
++
++    QWaylandWindow::fixedToplevelPositions =
++            !qEnvironmentVariableIsSet("QT_WAYLAND_DISABLE_FIXED_POSITIONS");
+ }
+ 
+ QWaylandIntegration::~QWaylandIntegration()
+@@ -192,14 +195,18 @@ QAbstractEventDispatcher *QWaylandIntegration::createEventDispatcher() const
+ 
+ void QWaylandIntegration::initialize()
+ {
++    mDisplay->initEventThread();
++
++    // Call after eventDispatcher is fully connected, for QWaylandDisplay::forceRoundTrip()
++    mDisplay->initialize();
++
++    // But the aboutToBlock() and awake() should be connected after initializePlatform().
++    // Otherwise the connected flushRequests() may consumes up all events before processEvents starts to wait,
++    // so that processEvents(QEventLoop::WaitForMoreEvents) may be blocked in the forceRoundTrip().
+     QAbstractEventDispatcher *dispatcher = QGuiApplicationPrivate::eventDispatcher;
+     QObject::connect(dispatcher, SIGNAL(aboutToBlock()), mDisplay.data(), SLOT(flushRequests()));
+     QObject::connect(dispatcher, SIGNAL(awake()), mDisplay.data(), SLOT(flushRequests()));
+ 
+-    int fd = wl_display_get_fd(mDisplay->wl_display());
+-    QSocketNotifier *sn = new QSocketNotifier(fd, QSocketNotifier::Read, mDisplay.data());
+-    QObject::connect(sn, SIGNAL(activated(QSocketDescriptor)), mDisplay.data(), SLOT(flushRequests()));
+-
+     // Qt does not support running with no screens
+     mDisplay->ensureScreen();
+ }
+@@ -262,6 +269,14 @@ QWaylandDisplay *QWaylandIntegration::display() const
+     return mDisplay.data();
+ }
+ 
++Qt::KeyboardModifiers QWaylandIntegration::queryKeyboardModifiers() const
++{
++    if (auto *seat = mDisplay->currentInputDevice()) {
++        return seat->modifiers();
++    }
++    return Qt::NoModifier;
++}
++
+ QList<int> QWaylandIntegration::possibleKeys(const QKeyEvent *event) const
+ {
+     if (auto *seat = mDisplay->currentInputDevice())
+@@ -479,7 +494,7 @@ void QWaylandIntegration::reconfigureInputContext()
+     }
+ #endif
+ 
+-    qCDebug(lcQpaWayland) << "using input method:" << inputContext()->metaObject()->className();
++    qCDebug(lcQpaWayland) << "using input method:" << (inputContext() ? inputContext()->metaObject()->className() : "<none>");
+ }
+ 
+ QWaylandShellIntegration *QWaylandIntegration::createShellIntegration(const QString &integrationName)
+diff --git a/qtwayland/src/client/qwaylandintegration_p.h b/qtwayland/src/client/qwaylandintegration_p.h
+index ff70ae25..73b80658 100644
+--- a/qtwayland/src/client/qwaylandintegration_p.h
++++ b/qtwayland/src/client/qwaylandintegration_p.h
+@@ -107,6 +107,8 @@ public:
+ 
+     QWaylandDisplay *display() const;
+ 
++    Qt::KeyboardModifiers queryKeyboardModifiers() const override;
++
+     QList<int> possibleKeys(const QKeyEvent *event) const override;
+ 
+     QStringList themeNames() const override;
+diff --git a/qtwayland/src/client/qwaylandprimaryselectionv1.cpp b/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
+index 832f9678..ea508771 100644
+--- a/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
++++ b/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
+@@ -54,11 +54,6 @@ QWaylandPrimarySelectionDeviceManagerV1::QWaylandPrimarySelectionDeviceManagerV1
+     : zwp_primary_selection_device_manager_v1(display->wl_registry(), id, qMin(version, uint(1)))
+     , m_display(display)
+ {
+-    // Create devices for all seats.
+-    // This only works if we get the global before all devices
+-    const auto seats = m_display->inputDevices();
+-    for (auto *seat : seats)
+-        seat->setPrimarySelectionDevice(createDevice(seat));
+ }
+ 
+ QWaylandPrimarySelectionDeviceV1 *QWaylandPrimarySelectionDeviceManagerV1::createDevice(QWaylandInputDevice *seat)
+diff --git a/qtwayland/src/client/qwaylandscreen.cpp b/qtwayland/src/client/qwaylandscreen.cpp
+index 6cb337de..5537dafd 100644
+--- a/qtwayland/src/client/qwaylandscreen.cpp
++++ b/qtwayland/src/client/qwaylandscreen.cpp
+@@ -60,7 +60,7 @@ QWaylandXdgOutputManagerV1::QWaylandXdgOutputManagerV1(QWaylandDisplay* display,
+ }
+ 
+ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uint32_t id)
+-    : QtWayland::wl_output(waylandDisplay->wl_registry(), id, qMin(version, 2))
++    : QtWayland::wl_output(waylandDisplay->wl_registry(), id, qMin(version, 3))
+     , m_outputId(id)
+     , mWaylandDisplay(waylandDisplay)
+     , mOutputName(QStringLiteral("Screen%1").arg(id))
+@@ -72,7 +72,7 @@ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uin
+         qCWarning(lcQpaWayland) << "wl_output done event not supported by compositor,"
+                                 << "QScreen may not work correctly";
+         mWaylandDisplay->forceRoundTrip(); // Give the compositor a chance to send geometry etc.
+-        mOutputDone = true; // Fake the done event
++        mProcessedEvents |= OutputDoneEvent; // Fake the done event
+         maybeInitialize();
+     }
+ }
+@@ -81,16 +81,29 @@ QWaylandScreen::~QWaylandScreen()
+ {
+     if (zxdg_output_v1::isInitialized())
+         zxdg_output_v1::destroy();
++    if (wl_output::isInitialized() && wl_output_get_version(wl_output::object()) >= WL_OUTPUT_RELEASE_SINCE_VERSION)
++        wl_output::release();
++}
++
++uint QWaylandScreen::requiredEvents() const
++{
++    uint ret = OutputDoneEvent;
++
++    if (mWaylandDisplay->xdgOutputManager()) {
++        ret |= XdgOutputNameEvent;
++
++        if (mWaylandDisplay->xdgOutputManager()->version() < 3)
++            ret |= XdgOutputDoneEvent;
++    }
++    return ret;
+ }
+ 
+ void QWaylandScreen::maybeInitialize()
+ {
+     Q_ASSERT(!mInitialized);
+ 
+-    if (!mOutputDone)
+-        return;
+-
+-    if (mWaylandDisplay->xdgOutputManager() && !mXdgOutputDone)
++    const uint requiredEvents = this->requiredEvents();
++    if ((mProcessedEvents & requiredEvents) != requiredEvents)
+         return;
+ 
+     mInitialized = true;
+@@ -276,9 +289,8 @@ void QWaylandScreen::output_scale(int32_t factor)
+ 
+ void QWaylandScreen::output_done()
+ {
+-    mOutputDone = true;
+-    if (zxdg_output_v1::isInitialized() && mWaylandDisplay->xdgOutputManager()->version() >= 3)
+-        mXdgOutputDone = true;
++    mProcessedEvents |= OutputDoneEvent;
++
+     if (mInitialized) {
+         updateOutputProperties();
+         if (zxdg_output_v1::isInitialized())
+@@ -339,7 +351,7 @@ void QWaylandScreen::zxdg_output_v1_done()
+     if (Q_UNLIKELY(mWaylandDisplay->xdgOutputManager()->version() >= 3))
+         qWarning(lcQpaWayland) << "zxdg_output_v1.done received on version 3 or newer, this is most likely a bug in the compositor";
+ 
+-    mXdgOutputDone = true;
++    mProcessedEvents |= XdgOutputDoneEvent;
+     if (mInitialized)
+         updateXdgOutputProperties();
+     else
+@@ -348,7 +360,11 @@ void QWaylandScreen::zxdg_output_v1_done()
+ 
+ void QWaylandScreen::zxdg_output_v1_name(const QString &name)
+ {
++    if (Q_UNLIKELY(mInitialized))
++        qWarning(lcQpaWayland) << "zxdg_output_v1.name received after output has been initialized, this is most likely a bug in the compositor";
++
+     mOutputName = name;
++    mProcessedEvents |= XdgOutputNameEvent;
+ }
+ 
+ void QWaylandScreen::updateXdgOutputProperties()
+diff --git a/qtwayland/src/client/qwaylandscreen_p.h b/qtwayland/src/client/qwaylandscreen_p.h
+index df1c94f2..050cfdc0 100644
+--- a/qtwayland/src/client/qwaylandscreen_p.h
++++ b/qtwayland/src/client/qwaylandscreen_p.h
+@@ -116,6 +116,13 @@ public:
+     static QWaylandScreen *fromWlOutput(::wl_output *output);
+ 
+ private:
++    enum Event : uint {
++        XdgOutputDoneEvent = 0x1,
++        OutputDoneEvent = 0x2,
++        XdgOutputNameEvent = 0x4,
++    };
++    uint requiredEvents() const;
++
+     void output_mode(uint32_t flags, int width, int height, int refresh) override;
+     void output_geometry(int32_t x, int32_t y,
+                          int32_t width, int32_t height,
+@@ -148,8 +155,7 @@ private:
+     QSize mPhysicalSize;
+     QString mOutputName;
+     Qt::ScreenOrientation m_orientation = Qt::PrimaryOrientation;
+-    bool mOutputDone = false;
+-    bool mXdgOutputDone = false;
++    uint mProcessedEvents = 0;
+     bool mInitialized = false;
+ 
+ #if QT_CONFIG(cursor)
+diff --git a/qtwayland/src/client/qwaylandshmbackingstore.cpp b/qtwayland/src/client/qwaylandshmbackingstore.cpp
+index dc7ff670..41cffdf7 100644
+--- a/qtwayland/src/client/qwaylandshmbackingstore.cpp
++++ b/qtwayland/src/client/qwaylandshmbackingstore.cpp
+@@ -52,6 +52,7 @@
+ 
+ #include <QtWaylandClient/private/wayland-wayland-client-protocol.h>
+ 
++#include <fcntl.h>
+ #include <unistd.h>
+ #include <sys/mman.h>
+ 
+@@ -61,6 +62,9 @@
+ #  ifndef MFD_CLOEXEC
+ #    define MFD_CLOEXEC     0x0001U
+ #  endif
++#  ifndef MFD_ALLOW_SEALING
++#    define MFD_ALLOW_SEALING 0x0002U
++#  endif
+ #endif
+ 
+ QT_BEGIN_NAMESPACE
+@@ -74,8 +78,10 @@ QWaylandShmBuffer::QWaylandShmBuffer(QWaylandDisplay *display,
+     int alloc = stride * size.height();
+     int fd = -1;
+ 
+-#ifdef SYS_memfd_create
+-    fd = syscall(SYS_memfd_create, "wayland-shm", MFD_CLOEXEC);
++#if defined(SYS_memfd_create) && defined(F_SEAL_SEAL)
++    fd = syscall(SYS_memfd_create, "wayland-shm", MFD_CLOEXEC | MFD_ALLOW_SEALING);
++    if (fd >= 0)
++        fcntl(fd, F_ADD_SEALS, F_SEAL_SHRINK | F_SEAL_SEAL);
+ #endif
+ 
+     QScopedPointer<QFile> filePointer;
+diff --git a/qtwayland/src/client/qwaylandwindow.cpp b/qtwayland/src/client/qwaylandwindow.cpp
+index cb82857a..fb2c59dc 100644
+--- a/qtwayland/src/client/qwaylandwindow.cpp
++++ b/qtwayland/src/client/qwaylandwindow.cpp
+@@ -76,7 +76,6 @@ QWaylandWindow *QWaylandWindow::mMouseGrab = nullptr;
+ QWaylandWindow::QWaylandWindow(QWindow *window, QWaylandDisplay *display)
+     : QPlatformWindow(window)
+     , mDisplay(display)
+-    , mFrameQueue(mDisplay->createFrameQueue())
+     , mResizeAfterSwap(qEnvironmentVariableIsSet("QT_WAYLAND_RESIZE_AFTER_SWAP"))
+ {
+     {
+@@ -95,9 +94,6 @@ QWaylandWindow::QWaylandWindow(QWindow *window, QWaylandDisplay *display)
+ 
+ QWaylandWindow::~QWaylandWindow()
+ {
+-    mDisplay->destroyFrameQueue(mFrameQueue);
+-    mDisplay->handleWindowDestroyed(this);
+-
+     delete mWindowDecoration;
+ 
+     if (mSurface)
+@@ -243,6 +239,7 @@ bool QWaylandWindow::shouldCreateSubSurface() const
+ 
+ void QWaylandWindow::reset()
+ {
++    closeChildPopups();
+     delete mShellSurface;
+     mShellSurface = nullptr;
+     delete mSubSurfaceWindow;
+@@ -255,17 +252,22 @@ void QWaylandWindow::reset()
+         mSurface.reset();
+     }
+ 
+-    if (mFrameCallback) {
+-        wl_callback_destroy(mFrameCallback);
+-        mFrameCallback = nullptr;
+-    }
++    {
++        QMutexLocker lock(&mFrameSyncMutex);
++        if (mFrameCallback) {
++            wl_callback_destroy(mFrameCallback);
++            mFrameCallback = nullptr;
++        }
+ 
+-    mFrameCallbackElapsedTimer.invalidate();
+-    mWaitingForFrameCallback = false;
++        mFrameCallbackElapsedTimer.invalidate();
++        mWaitingForFrameCallback = false;
++    }
+     mFrameCallbackTimedOut = false;
+ 
+     mMask = QRegion();
+     mQueuedBuffer = nullptr;
++
++    mDisplay->handleWindowDestroyed(this);
+ }
+ 
+ QWaylandWindow *QWaylandWindow::fromWlSurface(::wl_surface *surface)
+@@ -351,19 +353,25 @@ void QWaylandWindow::setGeometry_helper(const QRect &rect)
+     }
+ }
+ 
+-void QWaylandWindow::setGeometry(const QRect &rect)
++void QWaylandWindow::setGeometry(const QRect &r)
+ {
++    auto rect = r;
++    if (fixedToplevelPositions && !QPlatformWindow::parent() && window()->type() != Qt::Popup
++        && window()->type() != Qt::ToolTip) {
++        rect.moveTo(screen()->geometry().topLeft());
++    }
+     setGeometry_helper(rect);
+ 
+     if (window()->isVisible() && rect.isValid()) {
+         if (mWindowDecoration)
+             mWindowDecoration->update();
+ 
+-        if (mResizeAfterSwap && windowType() == Egl && mSentInitialResize)
++        if (mResizeAfterSwap && windowType() == Egl && mSentInitialResize) {
++            QMutexLocker lock(&mResizeLock);
+             mResizeDirty = true;
+-        else
++        } else {
+             QWindowSystemInterface::handleGeometryChange(window(), geometry());
+-
++        }
+         mSentInitialResize = true;
+     }
+     QRect exposeGeometry(QPoint(), geometry().size());
+@@ -374,7 +382,7 @@ void QWaylandWindow::setGeometry(const QRect &rect)
+         mShellSurface->setWindowGeometry(windowContentGeometry());
+ 
+     if (isOpaque() && mMask.isEmpty())
+-        setOpaqueArea(rect);
++        setOpaqueArea(QRect(QPoint(0, 0), rect.size()));
+ }
+ 
+ void QWaylandWindow::resizeFromApplyConfigure(const QSize &sizeWithMargins, const QPoint &offset)
+@@ -399,21 +407,6 @@ void QWaylandWindow::sendExposeEvent(const QRect &rect)
+     mLastExposeGeometry = rect;
+ }
+ 
+-
+-static QVector<QPointer<QWaylandWindow>> activePopups;
+-
+-void QWaylandWindow::closePopups(QWaylandWindow *parent)
+-{
+-    while (!activePopups.isEmpty()) {
+-        auto popup = activePopups.takeLast();
+-        if (popup.isNull())
+-            continue;
+-        if (popup.data() == parent)
+-            return;
+-        popup->reset();
+-    }
+-}
+-
+ QPlatformScreen *QWaylandWindow::calculateScreenFromSurfaceEvents() const
+ {
+     QReadLocker lock(&mSurfaceLock);
+@@ -433,10 +426,7 @@ void QWaylandWindow::setVisible(bool visible)
+     lastVisible = visible;
+ 
+     if (visible) {
+-        if (window()->type() == Qt::Popup || window()->type() == Qt::ToolTip)
+-            activePopups << this;
+         initWindow();
+-        mDisplay->flushRequests();
+ 
+         setGeometry(windowGeometry());
+         // Don't flush the events here, or else the newly visible window may start drawing, but since
+@@ -444,7 +434,6 @@ void QWaylandWindow::setVisible(bool visible)
+         // QWaylandShmBackingStore::beginPaint().
+     } else {
+         sendExposeEvent(QRect());
+-        closePopups(this);
+         reset();
+     }
+ }
+@@ -556,12 +545,12 @@ void QWaylandWindow::sendRecursiveExposeEvent()
+ 
+ void QWaylandWindow::attach(QWaylandBuffer *buffer, int x, int y)
+ {
+-    Q_ASSERT(!buffer->committed());
+     QReadLocker locker(&mSurfaceLock);
+     if (mSurface == nullptr)
+         return;
+ 
+     if (buffer) {
++        Q_ASSERT(!buffer->committed());
+         handleUpdate();
+         buffer->setBusy();
+ 
+@@ -583,7 +572,11 @@ void QWaylandWindow::damage(const QRect &rect)
+     if (mSurface == nullptr)
+         return;
+ 
+-    mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    const int s = scale();
++    if (mDisplay->compositorVersion() >= 4)
++        mSurface->damage_buffer(s * rect.x(), s * rect.y(), s * rect.width(), s * rect.height());
++    else
++        mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
+ }
+ 
+ void QWaylandWindow::safeCommit(QWaylandBuffer *buffer, const QRegion &damage)
+@@ -619,8 +612,14 @@ void QWaylandWindow::commit(QWaylandBuffer *buffer, const QRegion &damage)
+         return;
+ 
+     attachOffset(buffer);
+-    for (const QRect &rect: damage)
+-        mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    if (mDisplay->compositorVersion() >= 4) {
++        const int s = scale();
++        for (const QRect &rect: damage)
++            mSurface->damage_buffer(s * rect.x(), s * rect.y(), s * rect.width(), s * rect.height());
++    } else {
++        for (const QRect &rect: damage)
++            mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    }
+     Q_ASSERT(!buffer->committed());
+     buffer->setCommitted();
+     mSurface->commit();
+@@ -635,42 +634,53 @@ void QWaylandWindow::commit()
+ 
+ const wl_callback_listener QWaylandWindow::callbackListener = {
+     [](void *data, wl_callback *callback, uint32_t time) {
+-        Q_UNUSED(callback);
+         Q_UNUSED(time);
+         auto *window = static_cast<QWaylandWindow*>(data);
+-        window->handleFrameCallback();
++        window->handleFrameCallback(callback);
+     }
+ };
+ 
+-void QWaylandWindow::handleFrameCallback()
++void QWaylandWindow::handleFrameCallback(wl_callback* callback)
+ {
++    QMutexLocker locker(&mFrameSyncMutex);
++    if (!mFrameCallback) {
++        // This means the callback is already unset by QWaylandWindow::reset.
++        // The wl_callback object will be destroyed there too.
++        return;
++    }
++    Q_ASSERT(callback == mFrameCallback);
++    wl_callback_destroy(callback);
++    mFrameCallback = nullptr;
++
+     mWaitingForFrameCallback = false;
+     mFrameCallbackElapsedTimer.invalidate();
+ 
+     // The rest can wait until we can run it on the correct thread
+-    if (!mWaitingForUpdateDelivery) {
+-        auto doHandleExpose = [this]() {
+-            bool wasExposed = isExposed();
+-            mFrameCallbackTimedOut = false;
+-            if (!wasExposed && isExposed()) // Did setting mFrameCallbackTimedOut make the window exposed?
+-                sendExposeEvent(QRect(QPoint(), geometry().size()));
+-            if (wasExposed && hasPendingUpdateRequest())
+-                deliverUpdateRequest();
+-
+-            mWaitingForUpdateDelivery = false;
+-        };
++    auto doHandleExpose = [this]() {
++        mWaitingForUpdateDelivery.storeRelease(false);
++        bool wasExposed = isExposed();
++        mFrameCallbackTimedOut = false;
++        if (!wasExposed && isExposed()) // Did setting mFrameCallbackTimedOut make the window exposed?
++            sendExposeEvent(QRect(QPoint(), geometry().size()));
++        if (wasExposed && hasPendingUpdateRequest())
++            deliverUpdateRequest();
++    };
+ 
++    if (mWaitingForUpdateDelivery.testAndSetAcquire(false, true)) {
+         // Queued connection, to make sure we don't call handleUpdate() from inside waitForFrameSync()
+         // in the single-threaded case.
+-        mWaitingForUpdateDelivery = true;
+         QMetaObject::invokeMethod(this, doHandleExpose, Qt::QueuedConnection);
+     }
++
++    mFrameSyncWait.notify_all();
+ }
+ 
+ bool QWaylandWindow::waitForFrameSync(int timeout)
+ {
+-    QMutexLocker locker(mFrameQueue.mutex);
+-    mDisplay->dispatchQueueWhile(mFrameQueue.queue, [&]() { return mWaitingForFrameCallback; }, timeout);
++    QMutexLocker locker(&mFrameSyncMutex);
++
++    QDeadlineTimer deadline(timeout);
++    while (mWaitingForFrameCallback && mFrameSyncWait.wait(&mFrameSyncMutex, deadline)) { }
+ 
+     if (mWaitingForFrameCallback) {
+         qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
+@@ -868,6 +878,17 @@ bool QWaylandWindow::createDecoration()
+             subsurf->set_position(pos.x() + m.left(), pos.y() + m.top());
+         }
+         sendExposeEvent(QRect(QPoint(), geometry().size()));
++
++        // This is a special case where the buffer is recreated, but since
++        // the content rect remains the same, the widgets remain the same
++        // size and are not redrawn, leaving the new buffer empty. As a simple
++        // work-around, we trigger a full extra update whenever the client-side
++        // window decorations are toggled while the window is showing.
++        // Note: createDecoration() is sometimes called from the render thread
++        // of Qt Quick. This is essentially wrong and could potentially cause problems,
++        // but until the underlying issue has been fixed, we have to use invokeMethod()
++        // here to avoid asserts.
++        QMetaObject::invokeMethod(window(), &QWindow::requestUpdate);
+     }
+ 
+     return mWindowDecoration;
+@@ -1023,6 +1044,13 @@ void QWaylandWindow::handleScreensChanged()
+ 
+     QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->QPlatformScreen::screen());
+     mLastReportedScreen = newScreen;
++    if (fixedToplevelPositions && !QPlatformWindow::parent() && window()->type() != Qt::Popup
++        && window()->type() != Qt::ToolTip
++        && geometry().topLeft() != newScreen->geometry().topLeft()) {
++        auto geometry = this->geometry();
++        geometry.moveTo(newScreen->geometry().topLeft());
++        setGeometry(geometry);
++    }
+ 
+     int scale = newScreen->isPlaceholder() ? 1 : static_cast<QWaylandScreen *>(newScreen)->scale();
+     if (scale != mScale) {
+@@ -1094,10 +1122,18 @@ bool QWaylandWindow::setMouseGrabEnabled(bool grab)
+     return true;
+ }
+ 
++Qt::WindowStates QWaylandWindow::windowStates() const
++{
++    return mLastReportedWindowStates;
++}
++
+ void QWaylandWindow::handleWindowStatesChanged(Qt::WindowStates states)
+ {
+     createDecoration();
+-    QWindowSystemInterface::handleWindowStateChanged(window(), states, mLastReportedWindowStates);
++    Qt::WindowStates statesWithoutActive = states & ~Qt::WindowActive;
++    Qt::WindowStates lastStatesWithoutActive = mLastReportedWindowStates & ~Qt::WindowActive;
++    QWindowSystemInterface::handleWindowStateChanged(window(), statesWithoutActive,
++                                                     lastStatesWithoutActive);
+     mLastReportedWindowStates = states;
+ }
+ 
+@@ -1139,19 +1175,24 @@ void QWaylandWindow::timerEvent(QTimerEvent *event)
+     if (event->timerId() != mFrameCallbackCheckIntervalTimerId)
+         return;
+ 
+-    bool callbackTimerExpired = mFrameCallbackElapsedTimer.hasExpired(mFrameCallbackTimeout);
+-    if (!mFrameCallbackElapsedTimer.isValid() || callbackTimerExpired ) {
+-        killTimer(mFrameCallbackCheckIntervalTimerId);
+-        mFrameCallbackCheckIntervalTimerId = -1;
+-    }
+-    if (mFrameCallbackElapsedTimer.isValid() && callbackTimerExpired) {
+-        mFrameCallbackElapsedTimer.invalidate();
++    {
++        QMutexLocker lock(&mFrameSyncMutex);
+ 
+-        qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
+-        mFrameCallbackTimedOut = true;
+-        mWaitingForUpdate = false;
+-        sendExposeEvent(QRect());
++        bool callbackTimerExpired = mFrameCallbackElapsedTimer.hasExpired(mFrameCallbackTimeout);
++        if (!mFrameCallbackElapsedTimer.isValid() || callbackTimerExpired ) {
++            killTimer(mFrameCallbackCheckIntervalTimerId);
++            mFrameCallbackCheckIntervalTimerId = -1;
++        }
++        if (!mFrameCallbackElapsedTimer.isValid() || !callbackTimerExpired) {
++            return;
++        }
++        mFrameCallbackElapsedTimer.invalidate();
+     }
++
++    qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
++    mFrameCallbackTimedOut = true;
++    mWaitingForUpdate = false;
++    sendExposeEvent(QRect());
+ }
+ 
+ void QWaylandWindow::requestUpdate()
+@@ -1160,8 +1201,11 @@ void QWaylandWindow::requestUpdate()
+     Q_ASSERT(hasPendingUpdateRequest()); // should be set by QPA
+ 
+     // If we have a frame callback all is good and will be taken care of there
+-    if (mWaitingForFrameCallback)
+-        return;
++    {
++        QMutexLocker locker(&mFrameSyncMutex);
++        if (mWaitingForFrameCallback)
++            return;
++    }
+ 
+     // If we've already called deliverUpdateRequest(), but haven't seen any attach+commit/swap yet
+     // This is a somewhat redundant behavior and might indicate a bug in the calling code, so log
+@@ -1174,7 +1218,12 @@ void QWaylandWindow::requestUpdate()
+     // so use invokeMethod to delay the delivery a bit.
+     QMetaObject::invokeMethod(this, [this] {
+         // Things might have changed in the meantime
+-        if (hasPendingUpdateRequest() && !mWaitingForFrameCallback)
++        {
++            QMutexLocker locker(&mFrameSyncMutex);
++            if (mWaitingForFrameCallback)
++                return;
++        }
++        if (hasPendingUpdateRequest())
+             deliverUpdateRequest();
+     }, Qt::QueuedConnection);
+ }
+@@ -1185,19 +1234,18 @@ void QWaylandWindow::requestUpdate()
+ void QWaylandWindow::handleUpdate()
+ {
+     qCDebug(lcWaylandBackingstore) << "handleUpdate" << QThread::currentThread();
++
+     // TODO: Should sync subsurfaces avoid requesting frame callbacks?
+     QReadLocker lock(&mSurfaceLock);
+     if (!mSurface)
+         return;
+ 
+-    if (mFrameCallback) {
+-        wl_callback_destroy(mFrameCallback);
+-        mFrameCallback = nullptr;
+-    }
++    QMutexLocker locker(&mFrameSyncMutex);
++    if (mWaitingForFrameCallback)
++        return;
+ 
+-    QMutexLocker locker(mFrameQueue.mutex);
+     struct ::wl_surface *wrappedSurface = reinterpret_cast<struct ::wl_surface *>(wl_proxy_create_wrapper(mSurface->object()));
+-    wl_proxy_set_queue(reinterpret_cast<wl_proxy *>(wrappedSurface), mFrameQueue.queue);
++    wl_proxy_set_queue(reinterpret_cast<wl_proxy *>(wrappedSurface), mDisplay->frameEventQueue());
+     mFrameCallback = wl_surface_frame(wrappedSurface);
+     wl_proxy_wrapper_destroy(wrappedSurface);
+     wl_callback_add_listener(mFrameCallback, &QWaylandWindow::callbackListener, this);
+@@ -1207,6 +1255,8 @@ void QWaylandWindow::handleUpdate()
+     // Start a timer for handling the case when the compositor stops sending frame callbacks.
+     if (mFrameCallbackTimeout > 0) {
+         QMetaObject::invokeMethod(this, [this] {
++            QMutexLocker locker(&mFrameSyncMutex);
++
+             if (mWaitingForFrameCallback) {
+                 if (mFrameCallbackCheckIntervalTimerId < 0)
+                     mFrameCallbackCheckIntervalTimerId = startTimer(mFrameCallbackTimeout);
+@@ -1267,6 +1317,20 @@ void QWaylandWindow::setOpaqueArea(const QRegion &opaqueArea)
+     wl_region_destroy(region);
+ }
+ 
++void QWaylandWindow::addChildPopup(QWaylandWindow *surface) {
++    mChildPopups.append(surface);
++}
++
++void QWaylandWindow::removeChildPopup(QWaylandWindow *surface) {
++    mChildPopups.removeAll(surface);
++}
++
++void QWaylandWindow::closeChildPopups() {
++    while (!mChildPopups.isEmpty()) {
++        auto popup = mChildPopups.takeLast();
++        popup->reset();
++    }
++}
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/client/qwaylandwindow_p.h b/qtwayland/src/client/qwaylandwindow_p.h
+index 01337cff..2f219d8c 100644
+--- a/qtwayland/src/client/qwaylandwindow_p.h
++++ b/qtwayland/src/client/qwaylandwindow_p.h
+@@ -98,6 +98,9 @@ public:
+     QWaylandWindow(QWindow *window, QWaylandDisplay *display);
+     ~QWaylandWindow() override;
+ 
++    // Keep Toplevels position on the top left corner of their screen
++    static inline bool fixedToplevelPositions = true;
++
+     virtual WindowType windowType() const = 0;
+     virtual void ensureSize();
+     WId winId() const override;
+@@ -148,6 +151,7 @@ public:
+     void setWindowState(Qt::WindowStates states) override;
+     void setWindowFlags(Qt::WindowFlags flags) override;
+     void handleWindowStatesChanged(Qt::WindowStates states);
++    Qt::WindowStates windowStates() const;
+ 
+     void raise() override;
+     void lower() override;
+@@ -206,6 +210,10 @@ public:
+     void handleUpdate();
+     void deliverUpdateRequest() override;
+ 
++    void addChildPopup(QWaylandWindow* child);
++    void removeChildPopup(QWaylandWindow* child);
++    void closeChildPopups();
++
+ public slots:
+     void applyConfigure();
+ 
+@@ -215,7 +223,11 @@ signals:
+ 
+ protected:
+     QWaylandDisplay *mDisplay = nullptr;
++
++    // mSurface can be written by the main thread. Other threads should claim a read lock for access
++    mutable QReadWriteLock mSurfaceLock;
+     QScopedPointer<QWaylandSurface> mSurface;
++
+     QWaylandShellSurface *mShellSurface = nullptr;
+     QWaylandSubSurface *mSubSurfaceWindow = nullptr;
+     QVector<QWaylandSubSurface *> mChildren;
+@@ -225,13 +237,14 @@ protected:
+     Qt::MouseButtons mMousePressedInContentArea = Qt::NoButton;
+ 
+     WId mWindowId;
+-    bool mWaitingForFrameCallback = false;
+     bool mFrameCallbackTimedOut = false; // Whether the frame callback has timed out
+-    bool mWaitingForUpdateDelivery = false;
+     int mFrameCallbackCheckIntervalTimerId = -1;
+-    QElapsedTimer mFrameCallbackElapsedTimer;
+-    struct ::wl_callback *mFrameCallback = nullptr;
+-    QWaylandDisplay::FrameQueue mFrameQueue;
++    QAtomicInt mWaitingForUpdateDelivery = false;
++
++    bool mWaitingForFrameCallback = false; // Protected by mFrameSyncMutex
++    QElapsedTimer mFrameCallbackElapsedTimer; // Protected by mFrameSyncMutex
++    struct ::wl_callback *mFrameCallback = nullptr; // Protected by mFrameSyncMutex
++    QMutex mFrameSyncMutex;
+     QWaitCondition mFrameSyncWait;
+ 
+     // True when we have called deliverRequestUpdate, but the client has not yet attached a new buffer
+@@ -261,6 +274,8 @@ protected:
+     QWaylandBuffer *mQueuedBuffer = nullptr;
+     QRegion mQueuedBufferDamage;
+ 
++    QList<QPointer<QWaylandWindow>> mChildPopups;
++
+ private:
+     void setGeometry_helper(const QRect &rect);
+     void initWindow();
+@@ -283,12 +298,10 @@ private:
+     QRect mLastExposeGeometry;
+ 
+     static const wl_callback_listener callbackListener;
+-    void handleFrameCallback();
++    void handleFrameCallback(struct ::wl_callback* callback);
+ 
+     static QWaylandWindow *mMouseGrab;
+ 
+-    mutable QReadWriteLock mSurfaceLock;
+-
+     friend class QWaylandSubSurface;
+ };
+ 
+diff --git a/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h b/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
+index ccad0048..4cc9b3b8 100644
+--- a/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
++++ b/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
+@@ -73,11 +73,10 @@ public:
+         return true;
+     }
+     virtual QWaylandShellSurface *createShellSurface(QWaylandWindow *window) = 0;
++    // kept for binary compat with layer-shell-qt
+     virtual void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) {
+-        if (newFocus)
+-            m_display->handleWindowActivated(newFocus);
+-        if (oldFocus)
+-            m_display->handleWindowDeactivated(oldFocus);
++        Q_UNUSED(newFocus);
++        Q_UNUSED(oldFocus);
+     }
+     virtual void *nativeResourceForWindow(const QByteArray &resource, QWindow *window) {
+         Q_UNUSED(resource);
+diff --git a/qtwayland/src/compositor/configure.json b/qtwayland/src/compositor/configure.json
+index bcfd5215..da95d07b 100644
+--- a/qtwayland/src/compositor/configure.json
++++ b/qtwayland/src/compositor/configure.json
+@@ -7,6 +7,31 @@
+     "testDir": "../../config.tests",
+ 
+     "libraries": {
++        "wayland-client": {
++            "label": "Wayland client library",
++            "headers": "wayland-version.h",
++            "test": {
++                "main": [
++                    "#if WAYLAND_VERSION_MAJOR < 1",
++                    "# error Wayland 1.8.0 or higher required",
++                    "#endif",
++                    "#if WAYLAND_VERSION_MAJOR == 1",
++                    "# if WAYLAND_VERSION_MINOR < 8",
++                    "#  error Wayland 1.8.0 or higher required",
++                    "# endif",
++                    "# if WAYLAND_VERSION_MINOR == 8",
++                    "#  if WAYLAND_VERSION_MICRO < 0",
++                    "#   error Wayland 1.8.0 or higher required",
++                    "#  endif",
++                    "# endif",
++                    "#endif"
++                 ]
++            },
++            "sources": [
++                { "type": "pkgConfig", "args": "wayland-client" },
++                "-lwayland-client"
++            ]
++        },
+         "wayland-server": {
+             "label": "wayland-server",
+             "headers": "wayland-version.h",
+@@ -151,8 +176,7 @@
+                     "#endif"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "dmabuf-client-buffer": {
+             "label": "Linux Client dma-buf Buffer Sharing",
+@@ -176,8 +200,7 @@
+                     "return 0;"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "vulkan-server-buffer": {
+             "label": "Vulkan Buffer Sharing",
+@@ -195,7 +218,8 @@
+                     "exportAllocInfo.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR;",
+                     "return 0;"
+                 ]
+-            }
++            },
++            "use": "wayland-client"
+         }
+     },
+ 
+diff --git a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
+index 7889f575..64140672 100644
+--- a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
++++ b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
+@@ -40,6 +40,7 @@
+ #include "qwaylandeglwindow.h"
+ 
+ #include <QtWaylandClient/private/qwaylandscreen_p.h>
++#include <QtWaylandClient/private/qwaylandsurface_p.h>
+ #include "qwaylandglcontext.h"
+ 
+ #include <QtEglSupport/private/qeglconvenience_p.h>
+@@ -124,6 +125,7 @@ void QWaylandEglWindow::updateSurface(bool create)
+         }
+         mOffset = QPoint();
+     } else {
++        QReadLocker locker(&mSurfaceLock);
+         if (m_waylandEglWindow) {
+             int current_width, current_height;
+             static bool disableResizeCheck = qgetenv("QT_WAYLAND_DISABLE_RESIZECHECK").toInt();
+@@ -131,14 +133,16 @@ void QWaylandEglWindow::updateSurface(bool create)
+             if (!disableResizeCheck) {
+                 wl_egl_window_get_attached_size(m_waylandEglWindow, &current_width, &current_height);
+             }
+-            if (disableResizeCheck || (current_width != sizeWithMargins.width() || current_height != sizeWithMargins.height())) {
++            if (disableResizeCheck || (current_width != sizeWithMargins.width() || current_height != sizeWithMargins.height()) || m_requestedSize != sizeWithMargins) {
+                 wl_egl_window_resize(m_waylandEglWindow, sizeWithMargins.width(), sizeWithMargins.height(), mOffset.x(), mOffset.y());
++                m_requestedSize = sizeWithMargins;
+                 mOffset = QPoint();
+ 
+                 m_resize = true;
+             }
+-        } else if (create && wlSurface()) {
+-            m_waylandEglWindow = wl_egl_window_create(wlSurface(), sizeWithMargins.width(), sizeWithMargins.height());
++        } else if (create && mSurface) {
++            m_waylandEglWindow = wl_egl_window_create(mSurface->object(), sizeWithMargins.width(), sizeWithMargins.height());
++            m_requestedSize = sizeWithMargins;
+         }
+ 
+         if (!m_eglSurface && m_waylandEglWindow && create) {
+diff --git a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
+index 5b1f4d56..0079dfef 100644
+--- a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
++++ b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
+@@ -88,6 +88,7 @@ private:
+     mutable QOpenGLFramebufferObject *m_contentFBO = nullptr;
+ 
+     QSurfaceFormat m_format;
++    QSize m_requestedSize;
+ };
+ 
+ }
+diff --git a/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h b/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
+index 56a710c3..c6a8b6c6 100644
+--- a/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
++++ b/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
+@@ -41,6 +41,8 @@
+ #include <QtCore/QTextStream>
+ #include <QtGui/QOpenGLTexture>
+ 
++#include <array>
++
+ #include <EGL/egl.h>
+ #include <EGL/eglext.h>
+ 
+diff --git a/qtwayland/src/plugins/decorations/bradient/main.cpp b/qtwayland/src/plugins/decorations/bradient/main.cpp
+index e75fda3c..fa885143 100644
+--- a/qtwayland/src/plugins/decorations/bradient/main.cpp
++++ b/qtwayland/src/plugins/decorations/bradient/main.cpp
+@@ -164,13 +164,10 @@ void QWaylandBradientDecoration::paint(QPaintDevice *device)
+     // Window icon
+     QIcon icon = waylandWindow()->windowIcon();
+     if (!icon.isNull()) {
+-        QPixmap pixmap = icon.pixmap(QSize(128, 128));
+-        QPixmap scaled = pixmap.scaled(22, 22, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+-
+         QRectF iconRect(0, 0, 22, 22);
+-        p.drawPixmap(iconRect.adjusted(margins().left() + BUTTON_SPACING, 4,
+-                                       margins().left() + BUTTON_SPACING, 4),
+-                     scaled, iconRect);
++        iconRect.adjust(margins().left() + BUTTON_SPACING, 4,
++                        margins().left() + BUTTON_SPACING, 4),
++        icon.paint(&p, iconRect.toRect());
+     }
+ 
+     // Window title
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
+index 85d25e3c..60bdd491 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
+@@ -47,18 +47,21 @@ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
+-QWaylandXdgPopupV5::QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow *window)
++QWaylandXdgPopupV5::QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow* parent, QWaylandWindow *window)
+     : QWaylandShellSurface(window)
+     , QtWayland::xdg_popup_v5(popup)
++    , m_parent(parent)
+     , m_window(window)
+ {
+     if (window->display()->windowExtension())
+         m_extendedWindow = new QWaylandExtendedSurface(window);
++    m_parent->addChildPopup(m_window);
+ }
+ 
+ QWaylandXdgPopupV5::~QWaylandXdgPopupV5()
+ {
+     xdg_popup_destroy(object());
++    m_parent->removeChildPopup(m_window);
+     delete m_extendedWindow;
+ }
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
+index 7494f6a6..d85f130b 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
+@@ -70,7 +70,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgPopupV5 : public QWaylandShellSurface
+ {
+     Q_OBJECT
+ public:
+-    QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow *window);
++    QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow* parent, QWaylandWindow *window);
+     ~QWaylandXdgPopupV5() override;
+ 
+ protected:
+@@ -78,6 +78,7 @@ protected:
+ 
+ private:
+     QWaylandExtendedSurface *m_extendedWindow = nullptr;
++    QWaylandWindow *m_parent = nullptr;
+     QWaylandWindow *m_window = nullptr;
+ };
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
+index 7e242c4a..def8452a 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
+@@ -84,7 +84,7 @@ QWaylandXdgPopupV5 *QWaylandXdgShellV5::createXdgPopup(QWaylandWindow *window, Q
+     int x = position.x() + parentWindow->frameMargins().left();
+     int y = position.y() + parentWindow->frameMargins().top();
+ 
+-    auto popup = new QWaylandXdgPopupV5(get_xdg_popup(window->wlSurface(), parentSurface, seat, m_popupSerial, x, y), window);
++    auto popup = new QWaylandXdgPopupV5(get_xdg_popup(window->wlSurface(), parentSurface, seat, m_popupSerial, x, y), parentWindow, window);
+     m_popups.append(window);
+     QObject::connect(popup, &QWaylandXdgPopupV5::destroyed, [this, window](){
+         m_popups.removeOne(window);
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
+index 4e25949f..cfc60939 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
+@@ -85,13 +85,6 @@ QWaylandShellSurface *QWaylandXdgShellV5Integration::createShellSurface(QWayland
+     return m_xdgShell->createXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellV5Integration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) {
+-    if (newFocus && qobject_cast<QWaylandXdgPopupV5 *>(newFocus->shellSurface()))
+-        m_display->handleWindowActivated(newFocus);
+-    if (oldFocus && qobject_cast<QWaylandXdgPopupV5 *>(oldFocus->shellSurface()))
+-        m_display->handleWindowDeactivated(oldFocus);
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
+index ce6bdb9e..aed88670 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
+@@ -67,7 +67,6 @@ public:
+     QWaylandXdgShellV5Integration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShellV5> m_xdgShell;
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
+index 8c371661..151c78e3 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
+@@ -174,6 +174,7 @@ QWaylandXdgSurfaceV6::Popup::Popup(QWaylandXdgSurfaceV6 *xdgSurface, QWaylandXdg
+     , m_xdgSurface(xdgSurface)
+     , m_parent(parent)
+ {
++    m_parent->window()->addChildPopup(m_xdgSurface->window());
+ }
+ 
+ QWaylandXdgSurfaceV6::Popup::~Popup()
+@@ -181,6 +182,8 @@ QWaylandXdgSurfaceV6::Popup::~Popup()
+     if (isInitialized())
+         destroy();
+ 
++    m_parent->window()->removeChildPopup(m_xdgSurface->window());
++
+     if (m_grabbing) {
+         auto *shell = m_xdgSurface->m_shell;
+         Q_ASSERT(shell->m_topmostGrabbingPopup == this);
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
+index 03164316..e8da8ba1 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
+@@ -68,20 +68,6 @@ QWaylandShellSurface *QWaylandXdgShellV6Integration::createShellSurface(QWayland
+     return m_xdgShell->getXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellV6Integration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus)
+-{
+-    if (newFocus) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurfaceV6 *>(newFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowActivated(newFocus);
+-    }
+-    if (oldFocus && qobject_cast<QWaylandXdgSurfaceV6 *>(oldFocus->shellSurface())) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurfaceV6 *>(oldFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowDeactivated(oldFocus);
+-    }
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
+index 261f8cbb..c1bcd5c6 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
+@@ -65,7 +65,6 @@ public:
+     QWaylandXdgShellV6Integration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShellV6> m_xdgShell;
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
+index f3e3c330..fa6d5808 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
+@@ -67,11 +67,6 @@ QWaylandXdgSurface::Toplevel::Toplevel(QWaylandXdgSurface *xdgSurface)
+ 
+ QWaylandXdgSurface::Toplevel::~Toplevel()
+ {
+-    if (m_applied.states & Qt::WindowActive) {
+-        QWaylandWindow *window = m_xdgSurface->window();
+-        window->display()->handleWindowDeactivated(window);
+-    }
+-
+     // The protocol spec requires that the decoration object is deleted before xdg_toplevel.
+     delete m_decoration;
+     m_decoration = nullptr;
+@@ -85,16 +80,15 @@ void QWaylandXdgSurface::Toplevel::applyConfigure()
+     if (!(m_applied.states & (Qt::WindowMaximized|Qt::WindowFullScreen)))
+         m_normalSize = m_xdgSurface->m_window->windowFrameGeometry().size();
+ 
+-    if ((m_pending.states & Qt::WindowActive) && !(m_applied.states & Qt::WindowActive))
++    if ((m_pending.states & Qt::WindowActive) && !(m_applied.states & Qt::WindowActive)
++        && !m_xdgSurface->m_window->display()->isKeyboardAvailable())
+         m_xdgSurface->m_window->display()->handleWindowActivated(m_xdgSurface->m_window);
+ 
+-    if (!(m_pending.states & Qt::WindowActive) && (m_applied.states & Qt::WindowActive))
++    if (!(m_pending.states & Qt::WindowActive) && (m_applied.states & Qt::WindowActive)
++        && !m_xdgSurface->m_window->display()->isKeyboardAvailable())
+         m_xdgSurface->m_window->display()->handleWindowDeactivated(m_xdgSurface->m_window);
+ 
+-    // TODO: none of the other plugins send WindowActive either, but is it on purpose?
+-    Qt::WindowStates statesWithoutActive = m_pending.states & ~Qt::WindowActive;
+-
+-    m_xdgSurface->m_window->handleWindowStatesChanged(statesWithoutActive);
++    m_xdgSurface->m_window->handleWindowStatesChanged(m_pending.states);
+ 
+     if (m_pending.size.isEmpty()) {
+         // An empty size in the configure means it's up to the client to choose the size
+@@ -105,8 +99,6 @@ void QWaylandXdgSurface::Toplevel::applyConfigure()
+         m_xdgSurface->m_window->resizeFromApplyConfigure(m_pending.size);
+     }
+ 
+-    m_xdgSurface->setSizeHints();
+-
+     m_applied = m_pending;
+     qCDebug(lcQpaWayland) << "Applied pending xdg_toplevel configure event:" << m_applied.size << m_applied.states;
+ }
+@@ -203,12 +195,17 @@ QtWayland::xdg_toplevel::resize_edge QWaylandXdgSurface::Toplevel::convertToResi
+                 | ((edges & Qt::RightEdge) ? resize_edge_right : 0));
+ }
+ 
+-QWaylandXdgSurface::Popup::Popup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parent,
++QWaylandXdgSurface::Popup::Popup(QWaylandXdgSurface *xdgSurface, QWaylandWindow *parent,
+                                  QtWayland::xdg_positioner *positioner)
+-    : xdg_popup(xdgSurface->get_popup(parent->object(), positioner->object()))
+-    , m_xdgSurface(xdgSurface)
++    : m_xdgSurface(xdgSurface)
++    , m_parentXdgSurface(qobject_cast<QWaylandXdgSurface *>(parent->shellSurface()))
+     , m_parent(parent)
+ {
++
++    init(xdgSurface->get_popup(m_parentXdgSurface ? m_parentXdgSurface->object() : nullptr, positioner->object()));
++    if (m_parent) {
++        m_parent->addChildPopup(m_xdgSurface->window());
++    }
+ }
+ 
+ QWaylandXdgSurface::Popup::~Popup()
+@@ -216,10 +213,24 @@ QWaylandXdgSurface::Popup::~Popup()
+     if (isInitialized())
+         destroy();
+ 
++    if (m_parent) {
++        m_parent->removeChildPopup(m_xdgSurface->window());
++    }
++
+     if (m_grabbing) {
+         auto *shell = m_xdgSurface->m_shell;
+         Q_ASSERT(shell->m_topmostGrabbingPopup == this);
+-        shell->m_topmostGrabbingPopup = m_parent->m_popup;
++        shell->m_topmostGrabbingPopup = m_parentXdgSurface ? m_parentXdgSurface->m_popup : nullptr;
++        m_grabbing = false;
++
++        // Synthesize Qt enter/leave events for popup
++        QWindow *leave = nullptr;
++        if (m_xdgSurface && m_xdgSurface->window())
++            leave = m_xdgSurface->window()->window();
++        QWindowSystemInterface::handleLeaveEvent(leave);
++
++        if (QWindow *enter = QGuiApplication::topLevelAt(QCursor::pos()))
++            QWindowSystemInterface::handleEnterEvent(enter, enter->mapFromGlobal(QCursor::pos()), QCursor::pos());
+     }
+ }
+ 
+@@ -257,6 +268,7 @@ QWaylandXdgSurface::QWaylandXdgSurface(QWaylandXdgShell *shell, ::xdg_surface *s
+                 m_toplevel->set_parent(parentXdgSurface->m_toplevel->object());
+         }
+     }
++    setSizeHints();
+ }
+ 
+ QWaylandXdgSurface::~QWaylandXdgSurface()
+@@ -400,8 +412,6 @@ void QWaylandXdgSurface::setPopup(QWaylandWindow *parent)
+ {
+     Q_ASSERT(!m_toplevel && !m_popup);
+ 
+-    auto parentXdgSurface = static_cast<QWaylandXdgSurface *>(parent->shellSurface());
+-
+     auto positioner = new QtWayland::xdg_positioner(m_shell->create_positioner());
+     // set_popup expects a position relative to the parent
+     QPoint transientPos = m_window->geometry().topLeft(); // this is absolute
+@@ -414,8 +424,9 @@ void QWaylandXdgSurface::setPopup(QWaylandWindow *parent)
+     positioner->set_anchor(QtWayland::xdg_positioner::anchor_top_left);
+     positioner->set_gravity(QtWayland::xdg_positioner::gravity_bottom_right);
+     positioner->set_size(m_window->geometry().width(), m_window->geometry().height());
+-    m_popup = new Popup(this, parentXdgSurface, positioner);
++    m_popup = new Popup(this, parent, positioner);
+     positioner->destroy();
++
+     delete positioner;
+ }
+ 
+@@ -437,6 +448,23 @@ void QWaylandXdgSurface::setGrabPopup(QWaylandWindow *parent, QWaylandInputDevic
+     }
+     setPopup(parent);
+     m_popup->grab(device, serial);
++
++    // Synthesize Qt enter/leave events for popup
++    if (!parent)
++        return;
++    QWindow *current = QGuiApplication::topLevelAt(QCursor::pos());
++    QWindow *leave = parent->window();
++    if (current != leave)
++        return;
++
++    QWindowSystemInterface::handleLeaveEvent(leave);
++
++    QWindow *enter = nullptr;
++    if (m_popup && m_popup->m_xdgSurface && m_popup->m_xdgSurface->window())
++        enter = m_popup->m_xdgSurface->window()->window();
++
++    if (enter)
++        QWindowSystemInterface::handleEnterEvent(enter, enter->mapFromGlobal(QCursor::pos()), QCursor::pos());
+ }
+ 
+ void QWaylandXdgSurface::xdg_surface_configure(uint32_t serial)
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
+index 96785205..4b518f0a 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
+@@ -131,14 +131,15 @@ private:
+ 
+     class Popup : public QtWayland::xdg_popup {
+     public:
+-        Popup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parent, QtWayland::xdg_positioner *positioner);
++        Popup(QWaylandXdgSurface *xdgSurface, QWaylandWindow *parent, QtWayland::xdg_positioner *positioner);
+         ~Popup() override;
+ 
+         void grab(QWaylandInputDevice *seat, uint serial);
+         void xdg_popup_popup_done() override;
+ 
+         QWaylandXdgSurface *m_xdgSurface = nullptr;
+-        QWaylandXdgSurface *m_parent = nullptr;
++        QWaylandXdgSurface *m_parentXdgSurface = nullptr;
++        QWaylandWindow *m_parent = nullptr;
+         bool m_grabbing = false;
+     };
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
+index 8769d971..da0dd6a7 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
+@@ -69,20 +69,6 @@ QWaylandShellSurface *QWaylandXdgShellIntegration::createShellSurface(QWaylandWi
+     return m_xdgShell->getXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellIntegration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus)
+-{
+-    if (newFocus) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurface *>(newFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowActivated(newFocus);
+-    }
+-    if (oldFocus && qobject_cast<QWaylandXdgSurface *>(oldFocus->shellSurface())) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurface *>(oldFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowDeactivated(oldFocus);
+-    }
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
+index b6caa6c9..2f929f98 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
+@@ -65,7 +65,6 @@ public:
+     QWaylandXdgShellIntegration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShell> m_xdgShell;
+diff --git a/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp b/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
+index 526d0ef4..f50ccf30 100644
+--- a/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
++++ b/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
+@@ -39,7 +39,10 @@
+ 
+ #include "qwaylandinputmethodeventbuilder_p.h"
+ 
++#include <QBrush>
++#include <QGuiApplication>
+ #include <QInputMethod>
++#include <QPalette>
+ #include <QTextCharFormat>
+ 
+ #ifdef QT_BUILD_WAYLANDCOMPOSITOR_LIB
+@@ -81,32 +84,38 @@ void QWaylandInputMethodEventBuilder::addPreeditStyling(uint32_t index, uint32_t
+     QTextCharFormat format;
+ 
+     switch (style) {
+-    case 0:
+-    case 1:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_NONE:
++        break;
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_DEFAULT:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_UNDERLINE:
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-    case 2:
+-    case 3:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_ACTIVE:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_INACTIVE:
+         format.setFontWeight(QFont::Bold);
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-    case 4:
+-        format.setFontUnderline(true);
+-        format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+-        m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_HIGHLIGHT:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_SELECTION:
++        {
++            format.setFontUnderline(true);
++            format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
++            QPalette palette = qApp->palette();
++            format.setBackground(QBrush(palette.color(QPalette::Active, QPalette::Highlight)));
++            format.setForeground(QBrush(palette.color(QPalette::Active, QPalette::HighlightedText)));
++            m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
++        }
+         break;
+-    case 5:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_INCORRECT:
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::WaveUnderline);
+         format.setUnderlineColor(QColor(Qt::red));
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-//    case QtWayland::wl_text_input::preedit_style_selection:
+-//    case QtWayland::wl_text_input::preedit_style_none:
+     default:
+         break;
+     }
+@@ -153,7 +162,7 @@ QInputMethodEvent QWaylandInputMethodEventBuilder::buildPreedit(const QString &t
+ 
+     if (m_preeditCursor < 0) {
+         attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, 0, QVariant()));
+-    } else if (m_preeditCursor > 0) {
++    } else {
+         attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, indexFromWayland(text, m_preeditCursor), 1, QVariant()));
+     }
+ 
+diff --git a/qtwayland/src/shared/qwaylandmimehelper.cpp b/qtwayland/src/shared/qwaylandmimehelper.cpp
+index a5fdd34d..e2fe1928 100644
+--- a/qtwayland/src/shared/qwaylandmimehelper.cpp
++++ b/qtwayland/src/shared/qwaylandmimehelper.cpp
+@@ -60,7 +60,7 @@ QByteArray QWaylandMimeHelper::getByteArray(QMimeData *mimeData, const QString &
+             buf.open(QIODevice::ReadWrite);
+             QByteArray fmt = "BMP";
+             if (mimeType.startsWith(QLatin1String("image/"))) {
+-                QByteArray imgFmt = mimeType.mid(6).toUpper().toLatin1();
++                QByteArray imgFmt = mimeType.mid(6).toLower().toLatin1();
+                 if (QImageWriter::supportedImageFormats().contains(imgFmt))
+                     fmt = imgFmt;
+             }
+@@ -74,7 +74,7 @@ QByteArray QWaylandMimeHelper::getByteArray(QMimeData *mimeData, const QString &
+         QList<QUrl> urls = mimeData->urls();
+         for (int i = 0; i < urls.count(); ++i) {
+             content.append(urls.at(i).toEncoded());
+-            content.append('\n');
++            content.append("\r\n");
+         }
+     } else {
+         content = mimeData->data(mimeType);
+diff --git a/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp b/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
+index 1568b3b9..067410d0 100644
+--- a/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
++++ b/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
+@@ -35,7 +35,7 @@
+ 
+ using namespace MockCompositor;
+ 
+-constexpr int dataDeviceVersion = 1;
++constexpr int dataDeviceVersion = 3;
+ 
+ class DataDeviceCompositor : public DefaultCompositor {
+ public:
+diff --git a/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp b/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
+index 9312c2e5..2ea382f1 100644
+--- a/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
++++ b/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
+@@ -73,6 +73,7 @@ private slots:
+     void multiTouch();
+     void multiTouchUpAndMotionFrame();
+     void tapAndMoveInSameFrame();
++    void cancelTouch();
+ };
+ 
+ void tst_seatv5::bindsToSeat()
+@@ -646,5 +647,34 @@ void tst_seatv5::tapAndMoveInSameFrame()
+     QTRY_COMPARE(window.m_events.last().touchPoints.first().state(), Qt::TouchPointState::TouchPointReleased);
+ }
+ 
++void tst_seatv5::cancelTouch()
++{
++    TouchWindow window;
++    QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
++
++    exec([=] {
++        auto *t = touch();
++        auto *c = client();
++        t->sendDown(xdgToplevel()->surface(), {32, 32}, 1);
++        t->sendFrame(c);
++        t->sendCancel(c);
++        t->sendFrame(c);
++    });
++
++    QTRY_VERIFY(!window.m_events.empty());
++    {
++        auto e = window.m_events.takeFirst();
++        QCOMPARE(e.type, QEvent::TouchBegin);
++        QCOMPARE(e.touchPointStates, Qt::TouchPointPressed);
++        QCOMPARE(e.touchPoints.length(), 1);
++        QCOMPARE(e.touchPoints.first().pos(), QPointF(32-window.frameMargins().left(), 32-window.frameMargins().top()));
++    }
++    {
++        auto e = window.m_events.takeFirst();
++        QCOMPARE(e.type, QEvent::TouchCancel);
++        QCOMPARE(e.touchPoints.length(), 0);
++    }
++}
++
+ QCOMPOSITOR_TEST_MAIN(tst_seatv5)
+ #include "tst_seatv5.moc"
+diff --git a/qtwayland/tests/auto/client/shared/corecompositor.cpp b/qtwayland/tests/auto/client/shared/corecompositor.cpp
+index 5c6c83ba..fa9b7662 100644
+--- a/qtwayland/tests/auto/client/shared/corecompositor.cpp
++++ b/qtwayland/tests/auto/client/shared/corecompositor.cpp
+@@ -27,6 +27,7 @@
+ ****************************************************************************/
+ 
+ #include "corecompositor.h"
++#include <thread>
+ 
+ namespace MockCompositor {
+ 
+diff --git a/qtwayland/tests/auto/client/shared/coreprotocol.cpp b/qtwayland/tests/auto/client/shared/coreprotocol.cpp
+index 0d988521..d1a2e7cb 100644
+--- a/qtwayland/tests/auto/client/shared/coreprotocol.cpp
++++ b/qtwayland/tests/auto/client/shared/coreprotocol.cpp
+@@ -451,6 +451,13 @@ void Touch::sendFrame(wl_client *client)
+         send_frame(r->handle);
+ }
+ 
++void Touch::sendCancel(wl_client *client)
++{
++    const auto touchResources = resourceMap().values(client);
++    for (auto *r : touchResources)
++        send_cancel(r->handle);
++}
++
+ uint Keyboard::sendEnter(Surface *surface)
+ {
+     auto serial = m_seat->m_compositor->nextSerial();
+diff --git a/qtwayland/tests/auto/client/shared/coreprotocol.h b/qtwayland/tests/auto/client/shared/coreprotocol.h
+index a1af137a..210d8ddb 100644
+--- a/qtwayland/tests/auto/client/shared/coreprotocol.h
++++ b/qtwayland/tests/auto/client/shared/coreprotocol.h
+@@ -158,7 +158,7 @@ class WlCompositor : public Global, public QtWaylandServer::wl_compositor
+ {
+     Q_OBJECT
+ public:
+-    explicit WlCompositor(CoreCompositor *compositor, int version = 3)
++    explicit WlCompositor(CoreCompositor *compositor, int version = 4)
+         : QtWaylandServer::wl_compositor(compositor->m_display, version)
+         , m_compositor(compositor)
+     {}
+@@ -364,6 +364,7 @@ public:
+     uint sendUp(wl_client *client, int id);
+     void sendMotion(wl_client *client, const QPointF &position, int id);
+     void sendFrame(wl_client *client);
++    void sendCancel(wl_client *client);
+ 
+     Seat *m_seat = nullptr;
+ };
+diff --git a/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp b/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
+index a415cbf5..b1d3d07d 100644
+--- a/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
++++ b/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
+@@ -342,7 +342,7 @@ Compositor::Compositor(MockCompositor *mockCompositor)
+         exit(EXIT_FAILURE);
+     }
+ 
+-    wl_global_create(m_display, &wl_compositor_interface, 1, this, bindCompositor);
++    wl_global_create(m_display, &wl_compositor_interface, 4, this, bindCompositor);
+ 
+     m_data_device_manager.reset(new DataDeviceManager(this, m_display));
+ 
+diff --git a/qtwayland/tests/auto/client/shared_old/mocksurface.cpp b/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
+index e9df5f90..c3246e4a 100644
+--- a/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
++++ b/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
+@@ -125,6 +125,16 @@ void Surface::surface_damage(Resource *resource,
+     Q_UNUSED(height);
+ }
+ 
++void Surface::surface_damage_buffer(Resource *resource,
++                                    int32_t x, int32_t y, int32_t width, int32_t height)
++{
++    Q_UNUSED(resource);
++    Q_UNUSED(x);
++    Q_UNUSED(y);
++    Q_UNUSED(width);
++    Q_UNUSED(height);
++}
++
+ void Surface::surface_frame(Resource *resource,
+                             uint32_t callback)
+ {
+diff --git a/qtwayland/tests/auto/client/shared_old/mocksurface.h b/qtwayland/tests/auto/client/shared_old/mocksurface.h
+index 949dc23d..d176837e 100644
+--- a/qtwayland/tests/auto/client/shared_old/mocksurface.h
++++ b/qtwayland/tests/auto/client/shared_old/mocksurface.h
+@@ -65,6 +65,8 @@ protected:
+                         struct wl_resource *buffer, int x, int y) override;
+     void surface_damage(Resource *resource,
+                         int32_t x, int32_t y, int32_t width, int32_t height) override;
++    void surface_damage_buffer(Resource *resource,
++                               int32_t x, int32_t y, int32_t width, int32_t height) override;
+     void surface_frame(Resource *resource,
+                        uint32_t callback) override;
+     void surface_commit(Resource *resource) override;
+diff --git a/qtwayland/tests/auto/client/surface/tst_surface.cpp b/qtwayland/tests/auto/client/surface/tst_surface.cpp
+index 95e4e609..60c672ce 100644
+--- a/qtwayland/tests/auto/client/surface/tst_surface.cpp
++++ b/qtwayland/tests/auto/client/surface/tst_surface.cpp
+@@ -129,6 +129,10 @@ void tst_surface::waitForFrameCallbackGl()
+     // Make sure we follow frame callbacks for some frames
+     for (int i = 0; i < 5; ++i) {
+         xdgPingAndWaitForPong(); // Make sure things have happened on the client
++        if (!qEnvironmentVariableIntValue("QT_WAYLAND_DISABLE_WINDOWDECORATION") && i == 0) {
++            QCOMPARE(bufferSpy.count(), 1);
++            bufferSpy.removeFirst();
++        }
+         exec([&] {
+             QVERIFY(bufferSpy.empty()); // Make sure no extra buffers have arrived
+             QVERIFY(!xdgToplevel()->surface()->m_waitingFrameCallbacks.empty());
+diff --git a/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp b/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
+index 2277bbb8..747875b4 100644
+--- a/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
++++ b/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
+@@ -31,6 +31,7 @@
+ #include <QtGui/QOpenGLWindow>
+ #include <QtGui/qpa/qplatformnativeinterface.h>
+ #include <QtWaylandClient/private/wayland-wayland-client-protocol.h>
++#include <QtWaylandClient/private/qwaylandwindow_p.h>
+ 
+ using namespace MockCompositor;
+ 
+@@ -45,6 +46,7 @@ private slots:
+     void configureStates();
+     void popup();
+     void tooltipOnPopup();
++    void tooltipAndSiblingPopup();
+     void switchPopups();
+     void hidePopupParent();
+     void pongs();
+@@ -138,6 +140,7 @@ void tst_xdgshell::configureSize()
+ 
+ void tst_xdgshell::configureStates()
+ {
++    QVERIFY(qputenv("QT_WAYLAND_FRAME_CALLBACK_TIMEOUT", "0"));
+     QRasterWindow window;
+     window.resize(64, 48);
+     window.show();
+@@ -154,9 +157,12 @@ void tst_xdgshell::configureStates()
+     // Toplevel windows don't know their position on xdg-shell
+ //    QCOMPARE(window.frameGeometry().topLeft(), QPoint()); // TODO: this doesn't currently work when window decorations are enabled
+ 
+-//    QEXPECT_FAIL("", "configure has already been acked, we shouldn't have to wait for isActive", Continue);
+-//    QVERIFY(window.isActive());
+-    QTRY_VERIFY(window.isActive()); // Just make sure it eventually get's set correctly
++    // window.windowstate() is driven by keyboard focus, however for decorations we want to follow
++    // XDGShell this is internal to QtWayland so it is queried directly
++    auto waylandWindow = static_cast<QtWaylandClient::QWaylandWindow *>(window.handle());
++    Q_ASSERT(waylandWindow);
++    QTRY_VERIFY(waylandWindow->windowStates().testFlag(
++            Qt::WindowActive)); // Just make sure it eventually get's set correctly
+ 
+     const QSize screenSize(640, 480);
+     const uint maximizedSerial = exec([=] {
+@@ -186,6 +192,7 @@ void tst_xdgshell::configureStates()
+     QCOMPARE(window.windowStates(), Qt::WindowNoState);
+     QCOMPARE(window.frameGeometry().size(), windowedSize);
+ //    QCOMPARE(window.frameGeometry().topLeft(), QPoint()); // TODO: this doesn't currently work when window decorations are enabled
++    QVERIFY(qunsetenv("QT_WAYLAND_FRAME_CALLBACK_TIMEOUT"));
+ }
+ 
+ void tst_xdgshell::popup()
+@@ -340,6 +347,92 @@ void tst_xdgshell::tooltipOnPopup()
+     QCOMPOSITOR_TRY_COMPARE(xdgPopup(0), nullptr);
+ }
+ 
++void tst_xdgshell::tooltipAndSiblingPopup()
++{
++    class ToolTip : public QRasterWindow {
++    public:
++        explicit ToolTip(QWindow *parent) {
++            setTransientParent(parent);
++            setFlags(Qt::ToolTip);
++            resize(100, 100);
++            show();
++        }
++        void mousePressEvent(QMouseEvent *event) override {
++            QRasterWindow::mousePressEvent(event);
++            m_popup = new QRasterWindow;
++            m_popup->setTransientParent(transientParent());
++            m_popup->setFlags(Qt::Popup);
++            m_popup->resize(100, 100);
++            m_popup->show();
++        }
++
++        QRasterWindow *m_popup = nullptr;
++    };
++
++    class Window : public QRasterWindow {
++    public:
++        void mousePressEvent(QMouseEvent *event) override {
++            QRasterWindow::mousePressEvent(event);
++            m_tooltip = new ToolTip(this);
++        }
++        ToolTip *m_tooltip = nullptr;
++    };
++
++    Window window;
++    window.resize(200, 200);
++    window.show();
++
++    QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
++    exec([=] { xdgToplevel()->sendCompleteConfigure(); });
++    QCOMPOSITOR_TRY_VERIFY(xdgToplevel()->m_xdgSurface->m_committedConfigureSerial);
++
++    exec([=] {
++        auto *surface = xdgToplevel()->surface();
++        auto *p = pointer();
++        auto *c = client();
++        p->sendEnter(surface, {100, 100});
++        p->sendFrame(c);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_pressed);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_released);
++        p->sendFrame(c);
++        p->sendLeave(surface);
++        p->sendFrame(c);
++    });
++
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup());
++    exec([=] { xdgPopup()->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup()->m_xdgSurface->m_committedConfigureSerial);
++    QCOMPOSITOR_TRY_VERIFY(!xdgPopup()->m_grabbed);
++
++    exec([=] {
++        auto *surface = xdgPopup()->surface();
++        auto *p = pointer();
++        auto *c = client();
++        p->sendEnter(surface, {100, 100});
++        p->sendFrame(c);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_pressed);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_released);
++        p->sendFrame(c);
++    });
++
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1));
++    exec([=] { xdgPopup(1)->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1)->m_xdgSurface->m_committedConfigureSerial);
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1)->m_grabbed);
++
++    // Close the middle tooltip (it should not close the sibling popup)
++    window.m_tooltip->close();
++
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(1), nullptr);
++    // Verify the remaining xdg surface is a grab popup..
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(0));
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(0)->m_grabbed);
++
++    window.m_tooltip->m_popup->close();
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(1), nullptr);
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(0), nullptr);
++}
++
+ // QTBUG-65680
+ void tst_xdgshell::switchPopups()
+ {
+@@ -505,7 +598,7 @@ void tst_xdgshell::minMaxSize()
+     window.show();
+     QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
+ 
+-    exec([=] { xdgToplevel()->sendCompleteConfigure(); });
++    // we don't roundtrip with our configuration the initial commit should be correct
+ 
+     QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.minSize, QSize(100, 100));
+     QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.maxSize, QSize(1000, 1000));
+Submodule qtwebchannel 618422ee..f8949655:
+diff --git a/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp b/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
+index 536eb5c..898d769 100644
+--- a/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
++++ b/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
+@@ -186,8 +186,6 @@ Q_DECLARE_TYPEINFO(OverloadResolutionCandidate, Q_MOVABLE_TYPE);
+ QMetaObjectPublisher::QMetaObjectPublisher(QWebChannel *webChannel)
+     : QObject(webChannel)
+     , webChannel(webChannel)
+-    , signalHandler(this)
+-    , clientIsIdle(false)
+     , blockUpdates(false)
+     , propertyUpdatesInitialized(false)
+ {
+@@ -301,17 +299,17 @@ QJsonObject QMetaObjectPublisher::classInfoForObject(const QObject *object, QWeb
+     return data;
+ }
+ 
+-void QMetaObjectPublisher::setClientIsIdle(bool isIdle)
++void QMetaObjectPublisher::setClientIsIdle(bool isIdle, QWebChannelAbstractTransport *transport)
+ {
+-    if (clientIsIdle == isIdle) {
+-        return;
+-    }
+-    clientIsIdle = isIdle;
+-    if (!isIdle && timer.isActive()) {
+-        timer.stop();
+-    } else if (isIdle && !timer.isActive()) {
+-        timer.start(PROPERTY_UPDATE_INTERVAL, this);
+-    }
++    transportState[transport].clientIsIdle = isIdle;
++    if (isIdle)
++        sendEnqueuedPropertyUpdates(transport);
++}
++
++bool QMetaObjectPublisher::isClientIdle(QWebChannelAbstractTransport *transport)
++{
++    auto found = transportState.find(transport);
++    return found != transportState.end() && found.value().clientIsIdle;
+ }
+ 
+ QJsonObject QMetaObjectPublisher::initializeClient(QWebChannelAbstractTransport *transport)
+@@ -333,6 +331,7 @@ QJsonObject QMetaObjectPublisher::initializeClient(QWebChannelAbstractTransport
+ 
+ void QMetaObjectPublisher::initializePropertyUpdates(const QObject *const object, const QJsonObject &objectInfo)
+ {
++    auto *signalHandler = signalHandlerFor(object);
+     foreach (const QJsonValue &propertyInfoVar, objectInfo[KEY_PROPERTIES].toArray()) {
+         const QJsonArray &propertyInfo = propertyInfoVar.toArray();
+         if (propertyInfo.size() < 2) {
+@@ -353,19 +352,19 @@ void QMetaObjectPublisher::initializePropertyUpdates(const QObject *const object
+ 
+         // Only connect for a property update once
+         if (connectedProperties.isEmpty()) {
+-            signalHandler.connectTo(object, signalIndex);
++            signalHandler->connectTo(object, signalIndex);
+         }
+ 
+         connectedProperties.insert(propertyIndex);
+     }
+ 
+     // also always connect to destroyed signal
+-    signalHandler.connectTo(object, s_destroyedSignalIndex);
++    signalHandler->connectTo(object, s_destroyedSignalIndex);
+ }
+ 
+ void QMetaObjectPublisher::sendPendingPropertyUpdates()
+ {
+-    if (blockUpdates || !clientIsIdle || pendingPropertyUpdates.isEmpty()) {
++    if (blockUpdates) {
+         return;
+     }
+ 
+@@ -415,18 +414,19 @@ void QMetaObjectPublisher::sendPendingPropertyUpdates()
+ 
+     // data does not contain specific updates
+     if (!data.isEmpty()) {
+-        setClientIsIdle(false);
+-
+         message[KEY_DATA] = data;
+-        broadcastMessage(message);
++        enqueueBroadcastMessage(message);
+     }
+ 
+     // send every property update which is not supposed to be broadcasted
+     const QHash<QWebChannelAbstractTransport*, QJsonArray>::const_iterator suend = specificUpdates.constEnd();
+     for (QHash<QWebChannelAbstractTransport*, QJsonArray>::const_iterator it = specificUpdates.constBegin(); it != suend; ++it) {
+         message[KEY_DATA] = it.value();
+-        it.key()->sendMessage(message);
++        enqueueMessage(message, it.key());
+     }
++
++    for (auto state = transportState.begin(); state != transportState.end(); ++state)
++        sendEnqueuedPropertyUpdates(state.key());
+ }
+ 
+ QVariant QMetaObjectPublisher::invokeMethod(QObject *const object, const QMetaMethod &method,
+@@ -572,7 +572,7 @@ void QMetaObjectPublisher::signalEmitted(const QObject *object, const int signal
+         }
+     } else {
+         pendingPropertyUpdates[object][signalIndex] = arguments;
+-        if (clientIsIdle && !blockUpdates && !timer.isActive()) {
++        if (!blockUpdates && !timer.isActive()) {
+             timer.start(PROPERTY_UPDATE_INTERVAL, this);
+         }
+     }
+@@ -590,7 +590,7 @@ void QMetaObjectPublisher::objectDestroyed(const QObject *object)
+     // only remove from handler when we initialized the property updates
+     // cf: https://bugreports.qt.io/browse/QTBUG-60250
+     if (propertyUpdatesInitialized) {
+-        signalHandler.remove(object);
++        signalHandlerFor(object)->remove(object);
+         signalToPropertyMap.remove(object);
+     }
+     pendingPropertyUpdates.remove(object);
+@@ -852,6 +852,52 @@ void QMetaObjectPublisher::broadcastMessage(const QJsonObject &message) const
+     }
+ }
+ 
++void QMetaObjectPublisher::enqueueBroadcastMessage(const QJsonObject &message)
++{
++    if (webChannel->d_func()->transports.isEmpty()) {
++        qWarning("QWebChannel is not connected to any transports, cannot send message: %s",
++                 QJsonDocument(message).toJson().constData());
++        return;
++    }
++
++    for (auto *transport : webChannel->d_func()->transports) {
++        auto &state = transportState[transport];
++        state.queuedMessages.append(message);
++    }
++}
++
++void QMetaObjectPublisher::enqueueMessage(const QJsonObject &message,
++                                          QWebChannelAbstractTransport *transport)
++{
++    auto &state = transportState[transport];
++    state.queuedMessages.append(message);
++}
++
++void QMetaObjectPublisher::sendEnqueuedPropertyUpdates(QWebChannelAbstractTransport *transport)
++{
++    auto found = transportState.find(transport);
++    if (found != transportState.end() && found.value().clientIsIdle
++        && !found.value().queuedMessages.isEmpty()) {
++
++        // If the client is connected with an in-process transport, it can
++        // happen that a message triggers a subsequent property change. In
++        // that case, we need to ensure that the queued messages have already
++        // been cleared; otherwise the recursive call will send everythig again.
++        // Case in point: The qmlwebchannel tests fail if we don't clear the
++        // queued messages before sending them out.
++        // For that same reason set the client to "busy" (aka non-idle) just
++        // right before sending out the messages; otherwise a potential
++        // "Idle" type message will not correctly restore the Idle state.
++        const auto messages = std::move(found.value().queuedMessages);
++        Q_ASSERT(found.value().queuedMessages.isEmpty());
++        found.value().clientIsIdle = false;
++
++        for (const auto &message : messages) {
++            transport->sendMessage(message);
++        }
++    }
++}
++
+ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannelAbstractTransport *transport)
+ {
+     if (!webChannel->d_func()->transports.contains(transport)) {
+@@ -866,7 +912,7 @@ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannel
+ 
+     const MessageType type = toType(message.value(KEY_TYPE));
+     if (type == TypeIdle) {
+-        setClientIsIdle(true);
++        setClientIsIdle(true, transport);
+     } else if (type == TypeInit) {
+         if (!message.contains(KEY_ID)) {
+             qWarning("JSON message object is missing the id property: %s",
+@@ -913,9 +959,9 @@ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannel
+                 return;
+             transport->sendMessage(createResponse(message.value(KEY_ID), wrapResult(result, transport)));
+         } else if (type == TypeConnectToSignal) {
+-            signalHandler.connectTo(object, message.value(KEY_SIGNAL).toInt(-1));
++            signalHandlerFor(object)->connectTo(object, message.value(KEY_SIGNAL).toInt(-1));
+         } else if (type == TypeDisconnectFromSignal) {
+-            signalHandler.disconnectFrom(object, message.value(KEY_SIGNAL).toInt(-1));
++            signalHandlerFor(object)->disconnectFrom(object, message.value(KEY_SIGNAL).toInt(-1));
+         } else if (type == TypeSetProperty) {
+             setProperty(object, message.value(KEY_PROPERTY).toInt(-1),
+                         message.value(KEY_VALUE));
+@@ -931,6 +977,7 @@ void QMetaObjectPublisher::setBlockUpdates(bool block)
+     blockUpdates = block;
+ 
+     if (!blockUpdates) {
++        timer.start(PROPERTY_UPDATE_INTERVAL, this);
+         sendPendingPropertyUpdates();
+     } else if (timer.isActive()) {
+         timer.stop();
+@@ -948,4 +995,15 @@ void QMetaObjectPublisher::timerEvent(QTimerEvent *event)
+     }
+ }
+ 
++SignalHandler<QMetaObjectPublisher> *QMetaObjectPublisher::signalHandlerFor(const QObject *object)
++{
++    auto thread = object->thread();
++    auto it = signalHandlers.find(thread);
++    if (it == signalHandlers.end()) {
++        it = signalHandlers.emplace(thread, this).first;
++        it->second.moveToThread(thread);
++    }
++    return &it->second;
++}
++
+ QT_END_NAMESPACE
+diff --git a/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h b/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
+index bbd9875..4713ef1 100644
+--- a/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
++++ b/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
+@@ -59,6 +59,9 @@
+ #include <QBasicTimer>
+ #include <QPointer>
+ #include <QJsonObject>
++#include <QQueue>
++
++#include <unordered_map>
+ 
+ #include "qwebchannelglobal.h"
+ 
+@@ -109,17 +112,36 @@ public:
+      */
+     void broadcastMessage(const QJsonObject &message) const;
+ 
++    /**
++     * Enqueue the given @p message to all known transports.
++     */
++    void enqueueBroadcastMessage(const QJsonObject &message);
++
++    /**
++     * Enqueue the given @p message to @p transport.
++     */
++    void enqueueMessage(const QJsonObject &message, QWebChannelAbstractTransport *transport);
++
++    /**
++     * If client for given @p transport is idle, send queued messaged to @p transport and then mark
++     * the client as not idle.
++     */
++    void sendEnqueuedPropertyUpdates(QWebChannelAbstractTransport *transport);
++
+     /**
+      * Serialize the QMetaObject of @p object and return it in JSON form.
+      */
+     QJsonObject classInfoForObject(const QObject *object, QWebChannelAbstractTransport *transport);
+ 
+     /**
+-     * Set the client to idle or busy, based on the value of @p isIdle.
+-     *
+-     * When the value changed, start/stop the property update timer accordingly.
++     * Set the client to idle or busy for a single @p transport, based on the value of @p isIdle.
++     */
++    void setClientIsIdle(bool isIdle, QWebChannelAbstractTransport *transport);
++
++    /**
++     * Check that client is idle for @p transport.
+      */
+-    void setClientIsIdle(bool isIdle);
++    bool isClientIdle(QWebChannelAbstractTransport *transport);
+ 
+     /**
+      * Initialize clients by sending them the class information of the registered objects.
+@@ -272,10 +294,18 @@ private:
+     friend class TestWebChannel;
+ 
+     QWebChannel *webChannel;
+-    SignalHandler<QMetaObjectPublisher> signalHandler;
++    std::unordered_map<const QThread*, SignalHandler<QMetaObjectPublisher>> signalHandlers;
++    SignalHandler<QMetaObjectPublisher> *signalHandlerFor(const QObject *object);
+ 
+-    // true when the client is idle, false otherwise
+-    bool clientIsIdle;
++    struct TransportState
++    {
++        TransportState() : clientIsIdle(false) { }
++        // true when the client is idle, false otherwise
++        bool clientIsIdle;
++        // messages to send
++        QQueue<QJsonObject> queuedMessages;
++    };
++    QHash<QWebChannelAbstractTransport *, TransportState> transportState;
+ 
+     // true when no property updates should be sent, false otherwise
+     bool blockUpdates;
+diff --git a/qtwebchannel/src/webchannel/signalhandler_p.h b/qtwebchannel/src/webchannel/signalhandler_p.h
+index 27afadb..d77373c 100644
+--- a/qtwebchannel/src/webchannel/signalhandler_p.h
++++ b/qtwebchannel/src/webchannel/signalhandler_p.h
+@@ -56,6 +56,7 @@
+ #include <QVector>
+ #include <QMetaMethod>
+ #include <QDebug>
++#include <QThread>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -71,6 +72,7 @@ static const int s_destroyedSignalIndex = QObject::staticMetaObject.indexOfMetho
+ template<class Receiver>
+ class SignalHandler : public QObject
+ {
++    Q_DISABLE_COPY(SignalHandler)
+ public:
+     SignalHandler(Receiver *receiver, QObject *parent = 0);
+ 
+@@ -268,6 +270,7 @@ int SignalHandler<Receiver>::qt_metacall(QMetaObject::Call call, int methodId, v
+     if (call == QMetaObject::InvokeMetaMethod) {
+         const QObject *object = sender();
+         Q_ASSERT(object);
++        Q_ASSERT(QThread::currentThread() == object->thread());
+         Q_ASSERT(senderSignalIndex() == methodId);
+         Q_ASSERT(m_connectionsCounter.contains(object));
+         Q_ASSERT(m_connectionsCounter.value(object).contains(methodId));
+diff --git a/qtwebchannel/tests/auto/qml/testwebchannel.cpp b/qtwebchannel/tests/auto/qml/testwebchannel.cpp
+index 9891687..3ca81c2 100644
+--- a/qtwebchannel/tests/auto/qml/testwebchannel.cpp
++++ b/qtwebchannel/tests/auto/qml/testwebchannel.cpp
+@@ -46,7 +46,11 @@ TestWebChannel::~TestWebChannel()
+ 
+ bool TestWebChannel::clientIsIdle() const
+ {
+-    return QWebChannel::d_func()->publisher->clientIsIdle;
++    for (auto *transport : QWebChannel::d_func()->transports) {
++        if (QWebChannel::d_func()->publisher->isClientIdle(transport))
++            return true;
++    }
++    return false;
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp b/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
+index 181da9e..37f989a 100644
+--- a/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
++++ b/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
+@@ -785,7 +785,7 @@ void TestWebChannel::testTransportWrapObjectProperties()
+     DummyTransport *dummyTransport = new DummyTransport(this);
+     channel.connectTo(dummyTransport);
+     channel.d_func()->publisher->initializeClient(dummyTransport);
+-    channel.d_func()->publisher->setClientIsIdle(true);
++    channel.d_func()->publisher->setClientIsIdle(true, dummyTransport);
+ 
+     QCOMPARE(channel.d_func()->publisher->transportedWrappedObjects.size(), 0);
+ 
+@@ -943,8 +943,6 @@ void TestWebChannel::testInfiniteRecursion()
+ 
+ void TestWebChannel::testAsyncObject()
+ {
+-    QSKIP("This test is broken. See QTBUG-80729");
+-
+     QWebChannel channel;
+     channel.connectTo(m_dummyTransport);
+ 
+@@ -990,6 +988,50 @@ void TestWebChannel::testAsyncObject()
+     thread.wait();
+ }
+ 
++void TestWebChannel::testPropertyMultipleTransports()
++{
++    DummyTransport transport1;
++    DummyTransport transport2;
++
++    QWebChannel channel;
++    QMetaObjectPublisher *publisher = channel.d_func()->publisher;
++
++    TestObject testObj;
++    testObj.setObjectName("testObject");
++    channel.registerObject(testObj.objectName(), &testObj);
++    channel.connectTo(&transport1);
++    channel.connectTo(&transport2);
++
++    testObj.setProp("Hello");
++
++    publisher->initializeClient(&transport1);
++    publisher->initializeClient(&transport2);
++    publisher->setClientIsIdle(true, &transport1);
++    QCOMPARE(publisher->isClientIdle(&transport1), true);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++    QVERIFY(transport1.messagesSent().isEmpty());
++    QVERIFY(transport2.messagesSent().isEmpty());
++
++    testObj.setProp("World");
++    QTRY_COMPARE_WITH_TIMEOUT(transport1.messagesSent().size(), 1u, 2000);
++    QCOMPARE(transport2.messagesSent().size(), 0u);
++    publisher->setClientIsIdle(true, &transport2);
++    QTRY_COMPARE_WITH_TIMEOUT(transport2.messagesSent().size(), 1u, 2000);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++
++    testObj.setProp("!!!");
++    publisher->setClientIsIdle(true, &transport2);
++    QCOMPARE(publisher->isClientIdle(&transport2), true);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QTRY_COMPARE_WITH_TIMEOUT(transport2.messagesSent().size(), 2u, 2000);
++    QCOMPARE(transport1.messagesSent().size(), 1u);
++    publisher->setClientIsIdle(true, &transport1);
++    QTRY_COMPARE_WITH_TIMEOUT(transport1.messagesSent().size(), 2u, 2000);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++}
++
+ class FunctionWrapper : public QObject
+ {
+     Q_OBJECT
+@@ -1082,7 +1124,7 @@ void TestWebChannel::benchInitializeClients()
+ 
+         publisher->propertyUpdatesInitialized = false;
+         publisher->signalToPropertyMap.clear();
+-        publisher->signalHandler.clear();
++        publisher->signalHandlers.clear();
+     }
+ }
+ 
+@@ -1107,7 +1149,7 @@ void TestWebChannel::benchPropertyUpdates()
+             obj->change();
+         }
+ 
+-        channel.d_func()->publisher->clientIsIdle = true;
++        channel.d_func()->publisher->setClientIsIdle(true, m_dummyTransport);
+         channel.d_func()->publisher->sendPendingPropertyUpdates();
+     }
+ }
+diff --git a/qtwebchannel/tests/auto/webchannel/tst_webchannel.h b/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
+index eae21f4..dd4e690 100644
+--- a/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
++++ b/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
+@@ -348,6 +348,7 @@ private slots:
+     void testJsonToVariant();
+     void testInfiniteRecursion();
+     void testAsyncObject();
++    void testPropertyMultipleTransports();
+     void testDeletionDuringMethodInvocation_data();
+     void testDeletionDuringMethodInvocation();
+ 
+Submodule qtwebengine f328054d...38e0df6c (commits not present)
+Submodule qtwebsockets 65850954..63fb8da1:
+diff --git a/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp b/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
+index 2affdd5..95f1194 100644
+--- a/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
++++ b/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
+@@ -273,6 +273,7 @@ void QWebSocketDataProcessor::clear()
+     if (!m_pConverterState)
+         m_pConverterState = new QTextCodec::ConverterState(QTextCodec::ConvertInvalidToNull |
+                                                            QTextCodec::IgnoreHeader);
++    frame.clear();
+ }
+ 
+ /*!
+diff --git a/qtwebsockets/src/websockets/qwebsocketprotocol.cpp b/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
+index df87a93..d0465f1 100644
+--- a/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
++++ b/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
+@@ -210,7 +210,7 @@ void QWebSocketProtocol::mask(char *payload, quint64 size, quint32 maskingKey)
+                             quint8((maskingKey & 0x0000FF00u) >> 8),
+                             quint8((maskingKey & 0x000000FFu))
+                           };
+-    int i = 0;
++    quint64 i = 0;
+     while (size-- > 0)
+         *payload++ ^= mask[i++ % 4];
+ }
diff --git a/srcpkgs/qt5/template b/srcpkgs/qt5/template
index e0463e1c9198..ca1800ce9dc2 100644
--- a/srcpkgs/qt5/template
+++ b/srcpkgs/qt5/template
@@ -2,11 +2,11 @@
 #
 # revbump libqtxdg after bumping patch version
 pkgname=qt5
-version=5.15.7+20221119
+version=5.15.8
+revision=1
+build_style=meta
 # commit f8c9fb304bc3e53b3aa07f962cd74e9160decccc
 # base repo: https://invent.kde.org/qt/qt/qt5
-revision=4
-build_style=meta
 hostmakedepends="cmake clang flex perl glib-devel pkg-config
  python re2c ruby which"
 makedepends="SDL2-devel Vulkan-Headers alsa-lib-devel double-conversion-devel
@@ -29,8 +29,9 @@ homepage="https://qt.io/"
 # tarball is generated with `git archive-all qt5-$version.tar.gz`
 # to keep the size smaller qtwebengine, qtwebview, qtdocgallery, qtactiveqt and qtpim
 # can be marked with the export-ignore attribute
-distfiles="https://void.johnnynator.dev/distfiles/qt5-${version}.tar.gz"
-checksum=9d57af471c78029a362276b7c99108ea009f511bb9ba6ff6cb884f6ddd255e9f
+#distfiles="https://void.johnnynator.dev/distfiles/qt5-${version}.tar.gz"
+distfiles="https://download.qt.io/archive/qt/5.15/${version}/single/qt-everywhere-opensource-src-${version}.tar.xz"
+checksum=776a9302c336671f9406a53bd30b8e36f825742b2ec44a57c08217bff0fa86b9
 python_version=2 #unverified
 replaces="qt5-doc<5.6.0 qt5-quick1<5.6.0 qt5-quick1-devel<5.6.0 qt5-webkit<5.6.0 qt5-webkit-devel<5.6.0
  qt5-enginio<5.7.1 qt5-enginio-devel<5.7.1 qt5-plugin-gtk<5.7.1 qt5-canvas3d<5.13.0"
@@ -248,7 +249,6 @@ do_configure() {
 	# opts+=" -v"
 	opts+=" -skip qtwebengine"
 	opts+=" -skip qtwebview"
-	opts+=" -skip qtdocgallery"
 	opts+=" -skip qtpim"
 	opts+=" -skip qtsystems"
 	opts+=" -skip qtspeech"

From 243808bd9edf9d2e9aa1c2c47b10788c9fb5e3bc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 078/140] qt6-multimedia: revbump for ffmpeg-6.0

---
 srcpkgs/qt6-multimedia/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-multimedia/template b/srcpkgs/qt6-multimedia/template
index d89e7d54eb5a..aae15e57ca7b 100644
--- a/srcpkgs/qt6-multimedia/template
+++ b/srcpkgs/qt6-multimedia/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-multimedia'
 pkgname=qt6-multimedia
 version=6.4.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DQT_FEATURE_gstreamer=ON"
 hostmakedepends="perl qt6-declarative-host-tools pkg-config qt6-shadertools"

From b449adc5aa076cf311de40280e84695934936eae Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 079/140] qtav: revbump for ffmpeg4-4.4.3

---
 srcpkgs/qtav/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtav/template b/srcpkgs/qtav/template
index 34c30b2c0c78..2d00ad104355 100644
--- a/srcpkgs/qtav/template
+++ b/srcpkgs/qtav/template
@@ -1,10 +1,10 @@
 # Template file for 'qtav'
 pkgname=qtav
 version=1.13.0
-revision=1
+revision=2
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel libass-devel libopenal-devel
+makedepends="ffmpeg4-devel libass-devel libopenal-devel
  libva-glx-devel libXv-devel pulseaudio-devel
  qt5-declarative-devel qt5-svg-devel
  qt5-quickcontrols"

From 8c0bee263f98a53f6db0763061f97426ea35b626 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 080/140] qtox: revbump for ffmpeg-6.0

---
 srcpkgs/qtox/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qtox/template b/srcpkgs/qtox/template
index 16019d7eaec9..5cea0b11b697 100644
--- a/srcpkgs/qtox/template
+++ b/srcpkgs/qtox/template
@@ -1,7 +1,7 @@
 # Template file for 'qtox'
 pkgname=qtox
 version=1.17.6
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DUPDATE_CHECK=OFF
  -DGIT_DESCRIBE=${version}

From f7fdc24e1c895554fa026ee749d0f91e46dddc4c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 081/140] retroarch: revbump for ffmpeg-6.0

---
 srcpkgs/retroarch/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroarch/template b/srcpkgs/retroarch/template
index 240d3df9db00..6d0b16ae2598 100644
--- a/srcpkgs/retroarch/template
+++ b/srcpkgs/retroarch/template
@@ -1,7 +1,7 @@
 # Template file for 'retroarch'
 pkgname=retroarch
 version=1.14.0
-revision=1
+revision=2
 build_style=configure
 configure_args="--prefix=/usr --sysconfdir=/etc --enable-networking
  --enable-udev --disable-builtinflac --disable-builtinglslang

From e363ee33255297653e813ab0f446ac68a55f4697 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 082/140] scrcpy: revbump for ffmpeg-6.0

---
 srcpkgs/scrcpy/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/scrcpy/template b/srcpkgs/scrcpy/template
index ee6e698e387f..8ada5ca4323f 100644
--- a/srcpkgs/scrcpy/template
+++ b/srcpkgs/scrcpy/template
@@ -1,7 +1,7 @@
 # Template file for 'scrcpy'
 pkgname=scrcpy
 version=2.0
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcompile_server=false
  -Dprebuilt_server=/usr/share/scrcpy/scrcpy-server-v${version}"

From 0d6211e15b869331b1a5191c9306b3d696bc7e16 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 083/140] spek-alternative: revbump for ffmpeg4-4.4.3

---
 srcpkgs/spek-alternative/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/spek-alternative/template b/srcpkgs/spek-alternative/template
index d65086b8f008..05246f1b8d0c 100644
--- a/srcpkgs/spek-alternative/template
+++ b/srcpkgs/spek-alternative/template
@@ -1,11 +1,11 @@
 # Template file for 'spek-alternative'
 pkgname=spek-alternative
 version=0.8.2.3
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake gettext-devel intltool libtool pkg-config wxWidgets-common"
-makedepends="ffmpeg-devel wxWidgets-gtk3-devel"
-depends="ffmpeg"
+makedepends="ffmpeg4-devel wxWidgets-gtk3-devel"
+depends="ffmpeg4"
 short_desc="Acoustic spectrum analyser"
 maintainer="Kartik Singh <kartik.ynwa@gmail.com>"
 license="GPL-3.0-or-later"

From c526e1d75ba5268c9afaacbbd3fb32a0f399f11e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 084/140] ssr: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ssr/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/ssr/template b/srcpkgs/ssr/template
index b055b9ec0774..3448ca110eb0 100644
--- a/srcpkgs/ssr/template
+++ b/srcpkgs/ssr/template
@@ -1,11 +1,11 @@
 # Template file for 'ssr'
 pkgname=ssr
 version=0.4.4
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_QT5=ON"
 hostmakedepends="pkg-config"
-makedepends="alsa-lib-devel ffmpeg-devel glu-devel jack-devel pulseaudio-devel
+makedepends="alsa-lib-devel ffmpeg4-devel glu-devel jack-devel pulseaudio-devel
  qt5-tools-devel qt5-x11extras-devel libXinerama-devel v4l-utils-devel"
 depends="desktop-file-utils hicolor-icon-theme"
 short_desc="Simple Screen Recorder for programs and games"

From ad869ddfe565baf6bd473877e418b46d3ca0e9d0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 085/140] sumo: revbump for ffmpeg-6.0

---
 srcpkgs/sumo/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/sumo/template b/srcpkgs/sumo/template
index 0f9b9ec815f5..a3fe134aa5ac 100644
--- a/srcpkgs/sumo/template
+++ b/srcpkgs/sumo/template
@@ -1,7 +1,7 @@
 # Template file for 'sumo'
 pkgname=sumo
 version=1.12.0
-revision=5
+revision=6
 build_style=cmake
 hostmakedepends="libgdal-tools pkg-config swig python3-setuptools"
 makedepends="python3-devel ffmpeg-devel fox-devel gl2ps-devel libgdal-devel

From 5dcacf56e71d86ee8cf59cbb48b6732bbefd8c7c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 086/140] synfig: revbump for ffmpeg4-4.4.3

---
 srcpkgs/synfig/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/synfig/template b/srcpkgs/synfig/template
index 5f5f5bb3f4b2..9b4d9adf09c6 100644
--- a/srcpkgs/synfig/template
+++ b/srcpkgs/synfig/template
@@ -7,7 +7,7 @@ build_style=gnu-configure
 configure_args="--with-boost-libdir=${XBPS_CROSS_BASE}/usr/lib"
 hostmakedepends="boost-build ImageMagick pkg-config intltool"
 makedepends="ETL gettext-devel libxml++-devel mlt-devel libmagick-devel
- libmng-devel boost-build boost-devel libopenexr-devel ffmpeg-devel"
+ libmng-devel boost-build boost-devel libopenexr-devel ffmpeg4-devel"
 depends="ImageMagick"
 short_desc="CLI 2D vector and timeline-based animation software"
 maintainer="Orphaned <orphan@voidlinux.org>"

From a78827d2407e80c64db4e8438e857f7d27a308e5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 087/140] telegram-desktop: revbump for ffmpeg-6.0

---
 srcpkgs/telegram-desktop/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/telegram-desktop/template b/srcpkgs/telegram-desktop/template
index aae9f3135100..7943b36f0b8a 100644
--- a/srcpkgs/telegram-desktop/template
+++ b/srcpkgs/telegram-desktop/template
@@ -1,7 +1,7 @@
 # Template file for 'telegram-desktop'
 pkgname=telegram-desktop
 version=4.6.5
-revision=1
+revision=2
 build_style=cmake
 build_helper="qemu"
 configure_args="-DTDESKTOP_API_ID=209235

From d934199f8a52091dab168b5432da8aad7fa73bfb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 088/140] tg_owt: revbump for ffmpeg-6.0

---
 srcpkgs/tg_owt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tg_owt/template b/srcpkgs/tg_owt/template
index 97d195ddb34a..551614b24956 100644
--- a/srcpkgs/tg_owt/template
+++ b/srcpkgs/tg_owt/template
@@ -1,7 +1,7 @@
 # Template file for 'tg_owt'
 pkgname=tg_owt
 version=0.0.0.20230107
-revision=1
+revision=2
 _commit=5098730b9eb6173f0b52068fe2555b7c1015123a
 _libyuv_commit=00950840d1c9bcbb3eb6ebc5aac5793e71166c8b
 _abseil_commit=8c0b94e793a66495e0b1f34a5eb26bd7dc672db0

From 8c60e54421041010ed4005f495221f7526a17bd5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 089/140] timg: revbump for ffmpeg-6.0

---
 srcpkgs/timg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/timg/template b/srcpkgs/timg/template
index 91f1516b2597..334443d3f9bb 100644
--- a/srcpkgs/timg/template
+++ b/srcpkgs/timg/template
@@ -1,7 +1,7 @@
 # Template file for 'timg'
 pkgname=timg
 version=1.4.4
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_OPENSLIDE_SUPPORT=off -Wno-dev"
 hostmakedepends="pkg-config git"

From 4c9545e835a32247661a1e7dd5f1404e6afd747d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 090/140] tvheadend: revbump for ffmpeg4-4.4.3

---
 srcpkgs/tvheadend/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/tvheadend/template b/srcpkgs/tvheadend/template
index e6b16d7ccf3b..46b52b6fb7f9 100644
--- a/srcpkgs/tvheadend/template
+++ b/srcpkgs/tvheadend/template
@@ -1,14 +1,14 @@
 # Template file for 'tvheadend'
 pkgname=tvheadend
 version=4.2.8
-revision=6
+revision=7
 build_style=gnu-configure
 configure_args="--enable-dvbscan --disable-ffmpeg_static
 --disable-hdhomerun_static --disable-bintray_cache --disable-libx264_static
 --disable-libx265_static --disable-libvpx_static --disable-libtheora_static
 --disable-libvorbis_static --disable-libfdkaac_static"
 hostmakedepends="gettext pkg-config python git which"
-makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg-devel"
+makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg4-devel"
 short_desc="TV streaming server"
 maintainer="lemmi <lemmi@nerd2nerd.org>"
 license="GPL-3.0-only"

From 69bb06023efd670a285e47f599dc51584ac8f966 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 091/140] unpaper: update to 7.0.0.

---
 srcpkgs/unpaper/template | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/srcpkgs/unpaper/template b/srcpkgs/unpaper/template
index 38ed47a58401..1ff910e722af 100644
--- a/srcpkgs/unpaper/template
+++ b/srcpkgs/unpaper/template
@@ -1,13 +1,13 @@
 # Template file for 'unpaper'
 pkgname=unpaper
-version=6.1
-revision=3
-build_style=gnu-configure
+version=7.0.0
+revision=1
+build_style=meson
+hostmakedepends="pkg-config meson libxslt"
+makedepends="ffmpeg-devel python3-Sphinx"
+short_desc="Post-processing tool for scanned sheets of paper"
 maintainer="Orphaned <orphan@voidlinux.org>"
-hostmakedepends="pkg-config libxslt"
-makedepends="ffmpeg-devel"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://www.flameeyes.eu/projects/unpaper"
-short_desc="A post-processing tool for scanned sheets of paper"
 distfiles="https://www.flameeyes.eu/files/${pkgname}-${version}.tar.xz"
-checksum=237c84f5da544b3f7709827f9f12c37c346cdf029b1128fb4633f9bafa5cb930
+checksum=2575fbbf26c22719d1cb882b59602c9900c7f747118ac130883f63419be46a80

From 4e67bf542e96aac453bf8ec2d59148e5d3aa592d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 092/140] vba-m: revbump for ffmpeg-6.0

---
 srcpkgs/vba-m/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vba-m/template b/srcpkgs/vba-m/template
index ba153e0b58ca..aa6093645e97 100644
--- a/srcpkgs/vba-m/template
+++ b/srcpkgs/vba-m/template
@@ -2,7 +2,7 @@
 pkgname=vba-m
 reverts=1292_2
 version=2.1.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_GTK=TRUE -DENABLE_FFMPEG=TRUE -DENABLE_LINK=TRUE -DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="gettext pkg-config unzip zip yasm wxWidgets-gtk3-devel"

From 5b8eb943b36d218a4465a6b615435c312c9038f3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 093/140] vice: revbump for ffmpeg4-4.4.3

---
 srcpkgs/vice/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/vice/template b/srcpkgs/vice/template
index 0924767cfcfb..5981e45149d0 100644
--- a/srcpkgs/vice/template
+++ b/srcpkgs/vice/template
@@ -1,7 +1,7 @@
 # Template file for 'vice'
 pkgname=vice
 version=3.5
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="
 	$(vopt_enable sdl2 sdlui2)
@@ -28,7 +28,7 @@ makedepends="
 	$(vopt_if gtk3 gtk+3-devel)
 	$(vopt_if gtk3 pulseaudio-devel)
 	$(vopt_if gtk3 pango-devel)
-	$(vopt_if ffmpeg ffmpeg-devel)"
+	$(vopt_if ffmpeg ffmpeg4-devel)"
 short_desc="Emulator for C64, C128, CBM-II, PET, VIC20, Plus4 and C16"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"

From 8a6bd700919fe4060bf0d5e81125ea6ad2ee0e5b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 094/140] waypipe: revbump for ffmpeg-6.0

---
 srcpkgs/waypipe/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waypipe/template b/srcpkgs/waypipe/template
index 5c4161900060..1a46fe27f7d8 100644
--- a/srcpkgs/waypipe/template
+++ b/srcpkgs/waypipe/template
@@ -1,7 +1,7 @@
 # Template file for 'waypipe'
 pkgname=waypipe
 version=0.8.4
-revision=1
+revision=2
 build_style=meson
 # lto is off because it causes linking errors in armv6l and armv7l (due to NEON)
 configure_args="-Dwerror=false -Dwith_dmabuf=enabled -Dwith_lz4=enabled

From 5fbbe4c7bb60be4d10a49d7c3e4c106f6b875a8a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 095/140] wf-recorder: revbump for ffmpeg-6.0

---
 srcpkgs/wf-recorder/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/wf-recorder/template b/srcpkgs/wf-recorder/template
index e278eb001600..5d014a5f28af 100644
--- a/srcpkgs/wf-recorder/template
+++ b/srcpkgs/wf-recorder/template
@@ -1,7 +1,7 @@
 # Template file for 'wf-recorder'
 pkgname=wf-recorder
 version=0.3.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config scdoc wayland-devel"
 makedepends="wayland-protocols wayland-devel ffmpeg-devel x264-devel

From 28739e7d39594854accdd2efd50bbb3bde779496 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 096/140] xpra: revbump for ffmpeg-6.0

---
 srcpkgs/xpra/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xpra/template b/srcpkgs/xpra/template
index 38f83283b1e5..b6e01ff0a813 100644
--- a/srcpkgs/xpra/template
+++ b/srcpkgs/xpra/template
@@ -1,7 +1,7 @@
 # Template file for 'xpra'
 pkgname=xpra
 version=4.4.4
-revision=1
+revision=2
 build_style=python3-module
 make_build_args="--without-cuda_kernels --without-cuda_rebuild"
 make_install_args="$(vopt_with docs) ${make_build_args}"

From b9af0da7e2afed91c8f8ba4271ceaed945fb599b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:07:40 -0400
Subject: [PATCH 097/140] nv-codec-headers: update to 12.0.16.0

---
 srcpkgs/nv-codec-headers/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/nv-codec-headers/template b/srcpkgs/nv-codec-headers/template
index 3d422a61e489..251e057f826f 100644
--- a/srcpkgs/nv-codec-headers/template
+++ b/srcpkgs/nv-codec-headers/template
@@ -1,6 +1,6 @@
 # Template file for 'nv-codec-headers'
 pkgname=nv-codec-headers
-version=11.1.5.1
+version=12.0.16.0
 revision=1
 build_style=gnu-makefile
 short_desc="FFmpeg version of headers required to interface with Nvidias codec APIs"
@@ -8,7 +8,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="MIT"
 homepage="http://git.videolan.org/?p=ffmpeg/nv-codec-headers.git"
 distfiles="https://github.com/FFmpeg/nv-codec-headers/archive/n${version}.tar.gz"
-checksum=d095fbd56aa93772471a323be0ebe65504a0f43f06c76a30b6d25da77b06ae9c
+checksum=2a1533b65f55f9da52956faf0627ed3b74868ac0c7f269990edd21369113b48f
 
 post_install() {
 	sed -n '4,25p' include/ffnvcodec/nvEncodeAPI.h > LICENSE

From 5f816524af23f848c4a899b0a7d51f011d7abeef Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:08:40 -0400
Subject: [PATCH 098/140] openimagedenoise: revbump for ffmpeg-6.0

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index db5ccdb055cc..cb90045afb63 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,7 +1,7 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
 version=1.4.3
-revision=1
+revision=2
 archs="x86_64*"
 build_style=cmake
 hostmakedepends="ispc python3"

From e89f4bff512b9aa7c683b42e4a01474fea5924ac Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 19 Mar 2023 10:58:01 -0400
Subject: [PATCH 099/140] gst-libav: update to 1.22.1

---
 srcpkgs/gst-libav/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index f082bd211c65..a2c97bfbcdb9 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
-version=1.20.3
-revision=2
+version=1.22.1
+revision=1
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"
@@ -11,7 +11,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.0-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname}/${pkgname}-${version}.tar.xz"
-checksum=3fedd10560fcdfaa1b6462cbf79a38c4e7b57d7f390359393fc0cef6dbf27dfe
+checksum=c958e825dc3ac3b7a481f8db5268131a1cd701312385c2d803dc63c8e460b5fb
 
 case "$XBPS_TARGET_MACHINE" in
 	*-musl) # Required by musl for M_SQRT1_2

From 84aeee6cebac0ee164261d5bdbe4535a8198f992 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 19 Mar 2023 10:58:18 -0400
Subject: [PATCH 100/140] gst-omx: update to 1.22.1

---
 srcpkgs/gst-omx/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-omx/template b/srcpkgs/gst-omx/template
index 893535c463da..76692c2a13f6 100644
--- a/srcpkgs/gst-omx/template
+++ b/srcpkgs/gst-omx/template
@@ -1,6 +1,6 @@
 # Template file for 'gst-omx'
 pkgname=gst-omx
-version=1.20.3
+version=1.22.1
 revision=1
 build_style=meson
 configure_args="-Dexamples=disabled -Dtarget=generic"
@@ -11,4 +11,4 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.1-only"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname}/${pkgname}-${version}.tar.xz"
-checksum=8db48040bb41f09edf8d17ff6d16c54888d7777ba4501c2c69f0083350ea9a15
+checksum=2d37f60cd33e68dcef0bcd09b2dd8a0b2eb3ab6d6ac172dca46f70eb02756687

From 579e709bae9f9292a1e3e0e93077f4f73eb62fb6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 19 Mar 2023 10:59:04 -0400
Subject: [PATCH 101/140] gst-plugins-bad1: update to 1.22.1

---
 common/shlibs                     | 1 +
 srcpkgs/gst-plugins-bad1/template | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/common/shlibs b/common/shlibs
index d0d328b09ef9..42744a55b1fc 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -1147,6 +1147,7 @@ libgstpbutils-1.0.so.0 gst-plugins-base1-1.0.0_1
 libgstriff-1.0.so.0 gst-plugins-base1-1.0.0_1
 libgstapp-1.0.so.0 gst-plugins-base1-1.0.0_1
 libgstallocators-1.0.so.0 gst-plugins-base1-1.1.1_1
+libgsttranscoder-1.0.so.0 gst-plugins-bad1-1.22.1_1
 libgstphotography-1.0.so.0 gst-plugins-bad1-1.18.3_2
 libgstsignalprocessor-1.0.so.0 gst-plugins-bad1-1.18.3_2
 libgstbasevideo-1.0.so.0 gst-plugins-bad1-1.18.3_2
diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index 5a9d5387e0d4..7f272f915ac4 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -36,7 +36,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later, LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname/1/}/${pkgname/1/}-${version}.tar.xz"
-checksum=7a11c13b55dd1d2386dd902219e41cbfcdda8e1e0aa3e738186c95074b35da4f
+checksum=2f39b6f222d98666f9ff420a00233e336949953a846237c2bfafc8805f509f0e
 
 build_options="gir gme wayland"
 build_options_default="gir wayland"

From 561e0442961149466adfb7a3839bf97a97bd2cf4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 19 Mar 2023 10:59:04 -0400
Subject: [PATCH 102/140] gst-plugins-ugly1: update to 1.22.1

---
 srcpkgs/gst-plugins-ugly1/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-plugins-ugly1/template b/srcpkgs/gst-plugins-ugly1/template
index e254fd40f869..5647c012c9fe 100644
--- a/srcpkgs/gst-plugins-ugly1/template
+++ b/srcpkgs/gst-plugins-ugly1/template
@@ -1,6 +1,6 @@
 # Template file for 'gst-plugins-ugly1'
 pkgname=gst-plugins-ugly1
-version=1.20.3
+version=1.22.1
 revision=1
 build_style=meson
 configure_args="-Damrnb=disabled -Damrwbdec=disabled -Dsidplay=disabled"
@@ -15,4 +15,4 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname/1/}/${pkgname/1/}-${version}.tar.xz"
-checksum=8caa20789a09c304b49cf563d33cca9421b1875b84fcc187e4a385fa01d6aefd
+checksum=4ab3d9e13481bce1ca3c7c4bb1f65dce4f0bb40fb1cac4416e8c06dd648815c2

From 0f97b05ddc9eb9235451b25a34ac604ab725925a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 19 Mar 2023 10:59:31 -0400
Subject: [PATCH 103/140] gst-editing-services: update to 1.22.1

---
 srcpkgs/gst1-editing-services/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst1-editing-services/template b/srcpkgs/gst1-editing-services/template
index 673b46970f24..f2045ad6043c 100644
--- a/srcpkgs/gst1-editing-services/template
+++ b/srcpkgs/gst1-editing-services/template
@@ -1,6 +1,6 @@
 # Template file for 'gst1-editing-services'
 pkgname=gst1-editing-services
-version=1.20.3
+version=1.22.1
 revision=1
 build_style=meson
 build_helper="gir"
@@ -12,7 +12,7 @@ maintainer="Toyam Cox <Vaelatern@gmail.com>"
 license="LGPL-2.0-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname/gst1/gst}/${pkgname/gst1/gst}-${version}.tar.xz"
-checksum=5fd896de69fbe24421eb6b0ff8d2f8b4c3cba3f3025ceacd302172f39a8abaa2
+checksum=0f9e5e08ef80a4b9a0e971c5f032b13c71aa6fef236265c2d615456e15161438
 
 do_check() {
 	: # Tests fail in older versions as well

From cd8a349305d0ccff5b3384def8b79a450420e092 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 19 Mar 2023 11:00:00 -0400
Subject: [PATCH 104/140] gst-rtsp-server: update to 1.22.1

---
 srcpkgs/gst-rtsp-server/template | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index 8ceea8d34b4b..ded9a69a2e9d 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
-version=1.20.3
-revision=3
+version=1.22.1
+revision=1
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="glib-devel gst-plugins-bad1-devel gobject-introspection
@@ -10,5 +10,5 @@ short_desc="GStreamer multimedia graph framework - rtsp server"
 maintainer="1is7ac3 <isaac.qa13@gmail.com>"
 license="LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
-distfiles="https://gstreamer.freedesktop.org/src/gst-rtsp-server/gst-rtsp-server-${version}.tar.xz"
-checksum=ee402718be9b127f0e5e66ca4c1b4f42e4926ec93ba307b7ccca5dc6cc9794ca
+distfiles="${homepage}/src/${pkgname}/${pkgname}-${version}.tar.xz"
+checksum=4e0b972608f67d5d8f5363c827cfcf132b0e00877be6f1905358d514249b05a3

From 2fdc537fd1bf61ae4f40ee702d328a95b8a57e33 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 19 Mar 2023 11:00:39 -0400
Subject: [PATCH 105/140] gst1-python3: update to 1.22.1

---
 srcpkgs/gst1-python3/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/gst1-python3/template b/srcpkgs/gst1-python3/template
index 3f564ac64b93..7a8d094ef61f 100644
--- a/srcpkgs/gst1-python3/template
+++ b/srcpkgs/gst1-python3/template
@@ -1,7 +1,7 @@
 # Template file for 'gst1-python3'
 pkgname=gst1-python3
-version=1.20.3
-revision=2
+version=1.22.1
+revision=1
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="libglib-devel python3-devel python3-gobject-devel gst-plugins-base1-devel"
@@ -11,4 +11,4 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/gst-python/gst-python-${version}.tar.xz"
-checksum=db348120eae955b8cc4de3560a7ea06e36d6e1ddbaa99a7ad96b59846601cfdc
+checksum=96008a441d685a64275a515b893ccad0fea1d560c43acd0763533e17f3a13ebb

From 833e3fd54f170d0b369cfcf286d582a44bb514c5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 19 Mar 2023 11:00:46 -0400
Subject: [PATCH 106/140] gstreamer-vaapi: update to 1.22.1

---
 srcpkgs/gstreamer-vaapi/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gstreamer-vaapi/template b/srcpkgs/gstreamer-vaapi/template
index 3cc4e057559a..c100d99e9af1 100644
--- a/srcpkgs/gstreamer-vaapi/template
+++ b/srcpkgs/gstreamer-vaapi/template
@@ -1,6 +1,6 @@
 # Template file for 'gstreamer-vaapi'
 pkgname=gstreamer-vaapi
-version=1.20.3
+version=1.22.1
 revision=1
 build_style=meson
 hostmakedepends="pkg-config"
@@ -11,7 +11,7 @@ license="LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
 changelog="https://raw.githubusercontent.com/GStreamer/gstreamer-vaapi/master/ChangeLog"
 distfiles="${homepage}/src/gstreamer-vaapi/gstreamer-vaapi-${version}.tar.xz"
-checksum=6ee99eb316abdde9ad37002915bd8c3867918f6fdc74b7cf2ac4c1ae0d690b45
+checksum=423b57db7fc5f9137dadf17cb3853a47438d63cd4ba6889a882e63fb5be997bc
 
 pre_check() {
 	# Seems to need certain hardware to pass

From 334be539b615310766f23dc5b2006e96522fd01a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 19 Mar 2023 11:00:51 -0400
Subject: [PATCH 107/140] gstreamer1: update to 1.22.1

---
 srcpkgs/gstreamer1/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gstreamer1/template b/srcpkgs/gstreamer1/template
index ae8a49cb20e8..362fe82faec3 100644
--- a/srcpkgs/gstreamer1/template
+++ b/srcpkgs/gstreamer1/template
@@ -1,6 +1,6 @@
 # Template file for 'gstreamer1'
 pkgname=gstreamer1
-version=1.20.3
+version=1.22.1
 revision=1
 build_style=meson
 build_helper="gir"
@@ -16,7 +16,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.0-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/gstreamer/gstreamer-${version}.tar.xz"
-checksum=607daf64bbbd5fb18af9d17e21c0d22c4d702fffe83b23cb22d1b1af2ca23a2a
+checksum=cd3ca759f926763615fdfcea63c9761198c42889bc0615ceec73e22b24fde771
 
 pre_check() {
 	# gst_gstdatetime is known to fail according to LFS

From 73bb4eaf21c8d50e16a04a767919c59550b86938 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 19 Mar 2023 10:59:04 -0400
Subject: [PATCH 108/140] gst-plugins-good1: update to 1.22.1

---
 srcpkgs/gst-plugins-good1/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-plugins-good1/template b/srcpkgs/gst-plugins-good1/template
index 1f5e620ce1fd..00baa6732c75 100644
--- a/srcpkgs/gst-plugins-good1/template
+++ b/srcpkgs/gst-plugins-good1/template
@@ -1,6 +1,6 @@
 # Template file for 'gst-plugins-good1'
 pkgname=gst-plugins-good1
-version=1.20.3
+version=1.22.1
 revision=1
 build_style=meson
 configure_args="-Ddv=disabled -Ddv1394=disabled -Dshout2=disabled -Dqt5=enabled
@@ -22,7 +22,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname/1/}/${pkgname/1/}-${version}.tar.xz"
-checksum=f8f3c206bf5cdabc00953920b47b3575af0ef15e9f871c0b6966f6d0aa5868b7
+checksum=44f9104654b4fd042aebe90932ab92e7ff7d8460fbc05b23dad87dffe70974cc
 
 build_options="gtk3 wayland"
 build_options_default="gtk3 wayland"

From dd7301d1f6ed28c8a63ccf6cc43a94810d19c2aa Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 19 Mar 2023 10:59:04 -0400
Subject: [PATCH 109/140] gst-plugins-base1: update to 1.22.1

---
 srcpkgs/gst-plugins-base1/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-plugins-base1/template b/srcpkgs/gst-plugins-base1/template
index 29e8f76bd1fe..6d2cad16f985 100644
--- a/srcpkgs/gst-plugins-base1/template
+++ b/srcpkgs/gst-plugins-base1/template
@@ -1,6 +1,6 @@
 # Template file for 'gst-plugins-base1'
 pkgname=gst-plugins-base1
-version=1.20.3
+version=1.22.1
 revision=1
 build_style=meson
 build_helper="gir"
@@ -22,7 +22,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname/1/}/${pkgname/1/}-${version}.tar.xz"
-checksum=7e30b3dd81a70380ff7554f998471d6996ff76bbe6fc5447096f851e24473c9f
+checksum=59bcaeacc5646b8dbdcfa4ef20ca6e818dd234910efb4cee1bbea441a3801c69
 
 build_options="cdparanoia gir sndio wayland"
 build_options_default="cdparanoia gir wayland"

From d94174d2b6dbc98f15b0c6fb60ea57b5fd755bcc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 16 Dec 2022 09:25:22 -0500
Subject: [PATCH 110/140] intel-gmmlib: update to 22.3.3

---
 srcpkgs/intel-gmmlib/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/intel-gmmlib/template b/srcpkgs/intel-gmmlib/template
index 8ed6ed3cf56c..2605226152e5 100644
--- a/srcpkgs/intel-gmmlib/template
+++ b/srcpkgs/intel-gmmlib/template
@@ -1,6 +1,6 @@
 # Template file for 'intel-gmmlib'
 pkgname=intel-gmmlib
-version=22.2.0
+version=22.3.3
 revision=1
 archs="i686* x86_64*"
 build_style=cmake
@@ -18,7 +18,7 @@ maintainer="Stefano Ragni <st3r4g@protonmail.com>"
 license="MIT"
 homepage="https://github.com/intel/gmmlib"
 distfiles="https://github.com/intel/gmmlib/archive/intel-gmmlib-${version}.tar.gz"
-checksum=0b2253894c6fc8455b6d7c5e87e6504a76d6f60ea192e1445c2f93164bf529c0
+checksum=86651bd2803c9f0afd82471bec784e65d2b418dee315a053d22215eb2a679be7
 
 lib32disabled=yes
 

From 581d0d241961c40d8050a3b4105060998c836a67 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 16 Dec 2022 09:25:47 -0500
Subject: [PATCH 111/140] intel-media-driver: update to 22.6.4

---
 ...mmon-Enable-MMC-in-free-kernel-build.patch | 125 ++++++++++++++++++
 .../intel-media-driver/patches/execinfo.patch |  58 --------
 srcpkgs/intel-media-driver/template           |   4 +-
 3 files changed, 127 insertions(+), 60 deletions(-)
 create mode 100644 srcpkgs/intel-media-driver/patches/0001-Media-Common-Enable-MMC-in-free-kernel-build.patch
 delete mode 100644 srcpkgs/intel-media-driver/patches/execinfo.patch

diff --git a/srcpkgs/intel-media-driver/patches/0001-Media-Common-Enable-MMC-in-free-kernel-build.patch b/srcpkgs/intel-media-driver/patches/0001-Media-Common-Enable-MMC-in-free-kernel-build.patch
new file mode 100644
index 000000000000..525fb688722c
--- /dev/null
+++ b/srcpkgs/intel-media-driver/patches/0001-Media-Common-Enable-MMC-in-free-kernel-build.patch
@@ -0,0 +1,125 @@
+From e68feab7db036838d9521ba3b9f00717c37c024c Mon Sep 17 00:00:00 2001
+From: JayYang <jay.yang@intel.com>
+Date: Tue, 21 Mar 2023 17:17:55 +0800
+Subject: [PATCH] [Media Common] Enable MMC in free kernel build
+
+Add mmc build definition in free kernel build
+---
+ media_driver/agnostic/gen9/codec/hal/media_srcs.cmake          | 2 +-
+ media_driver/cmake/linux/media_feature_flags_linux.cmake       | 3 +--
+ .../media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp        | 2 +-
+ .../media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp        | 2 +-
+ .../media_interfaces_m9_glk/media_interfaces_g9_glk.cpp        | 2 +-
+ .../media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp        | 2 +-
+ .../media_interfaces_m9_skl/media_interfaces_g9_skl.cpp        | 2 +-
+ 7 files changed, 7 insertions(+), 8 deletions(-)
+
+diff --git a/media_driver/agnostic/gen9/codec/hal/media_srcs.cmake b/media_driver/agnostic/gen9/codec/hal/media_srcs.cmake
+index 8bb36bafe..78902a22d 100644
+--- a/media_driver/agnostic/gen9/codec/hal/media_srcs.cmake
++++ b/media_driver/agnostic/gen9/codec/hal/media_srcs.cmake
+@@ -27,7 +27,7 @@ set(TMP_1_HEADERS_
+     ${CMAKE_CURRENT_LIST_DIR}/codechal_hw_g9_X.h
+ )
+ 
+-if(${MMC_Supported} STREQUAL "yes")
++if(${MMC_Supported} STREQUAL "yes" AND ENABLE_NONFREE_KERNELS AND ENABLE_KERNELS)
+     set(TMP_1_SOURCES_
+         ${TMP_1_SOURCES_}
+         ${CMAKE_CURRENT_LIST_DIR}/codechal_memdecomp_g9.cpp
+diff --git a/media_driver/cmake/linux/media_feature_flags_linux.cmake b/media_driver/cmake/linux/media_feature_flags_linux.cmake
+index de0ca853f..8121ea60c 100644
+--- a/media_driver/cmake/linux/media_feature_flags_linux.cmake
++++ b/media_driver/cmake/linux/media_feature_flags_linux.cmake
+@@ -35,7 +35,6 @@ if(NOT ENABLE_KERNELS OR NOT ENABLE_NONFREE_KERNELS)
+     bs_set_if_undefined(HEVC_Encode_VME_Supported "no")
+     bs_set_if_undefined(MPEG2_Encode_VME_Supported "no")
+     bs_set_if_undefined(CMRT_HEVC_ENC_FEI_Supported "no")
+-    bs_set_if_undefined(MMC_Supported "no")
+     bs_set_if_undefined(VC1_Decode_Supported "no")
+     bs_set_if_undefined(Decode_Processing_Supported "no")
+     bs_set_if_undefined(Kernel_Auto_Denoise_Supported "no")
+@@ -46,7 +45,6 @@ else()
+     bs_set_if_undefined(HEVC_Encode_VME_Supported "${Encode_VME_Supported}")
+     bs_set_if_undefined(MPEG2_Encode_VME_Supported "${Encode_VME_Supported}")
+     bs_set_if_undefined(CMRT_HEVC_ENC_FEI_Supported "yes")
+-    bs_set_if_undefined(MMC_Supported "yes")
+     bs_set_if_undefined(VC1_Decode_Supported "yes")
+     bs_set_if_undefined(Decode_Processing_Supported "yes")
+     bs_set_if_undefined(Kernel_Auto_Denoise_Supported "yes")
+@@ -64,6 +62,7 @@ bs_set_if_undefined(VP9_Decode_Supported "yes")
+ bs_set_if_undefined(VP_SFC_Supported "yes")
+ bs_set_if_undefined(Common_Encode_Supported "yes")
+ bs_set_if_undefined(Media_Scalability_Supported "yes")
++bs_set_if_undefined(MMC_Supported "yes")
+ 
+ # features controlled by global flag Encode_VDEnc_Supported
+ bs_set_if_undefined(AVC_Encode_VDEnc_Supported "${Encode_VDEnc_Supported}")
+diff --git a/media_driver/media_interface/media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp b/media_driver/media_interface/media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp
+index 3f306ee2a..8e4c0f532 100644
+--- a/media_driver/media_interface/media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp
+@@ -135,7 +135,7 @@ MOS_STATUS MhwInterfacesG9Bxt::Initialize(
+ 
+     return MOS_STATUS_SUCCESS;
+ }
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool bxtRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Bxt>((uint32_t)IGFX_BROXTON);
+diff --git a/media_driver/media_interface/media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp b/media_driver/media_interface/media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp
+index b8fa1eec0..84e0fad1d 100644
+--- a/media_driver/media_interface/media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp
+@@ -44,7 +44,7 @@ static bool cflRegisteredMhw =
+     MediaFactory<uint32_t, MhwInterfaces>::
+     Register<MhwInterfacesG9Kbl>((uint32_t)IGFX_COFFEELAKE);
+ 
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool cflRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Kbl>((uint32_t)IGFX_COFFEELAKE);
+diff --git a/media_driver/media_interface/media_interfaces_m9_glk/media_interfaces_g9_glk.cpp b/media_driver/media_interface/media_interfaces_m9_glk/media_interfaces_g9_glk.cpp
+index de81e6091..2638cb3a6 100644
+--- a/media_driver/media_interface/media_interfaces_m9_glk/media_interfaces_g9_glk.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_glk/media_interfaces_g9_glk.cpp
+@@ -65,7 +65,7 @@ static bool glkRegisteredMhw =
+     MediaFactory<uint32_t, MhwInterfaces>::
+     Register<MhwInterfacesG9Kbl>((uint32_t)IGFX_GEMINILAKE);
+ 
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool glkRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Kbl>((uint32_t)IGFX_GEMINILAKE);
+diff --git a/media_driver/media_interface/media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp b/media_driver/media_interface/media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp
+index 99d786185..4e9c6e7f1 100644
+--- a/media_driver/media_interface/media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp
+@@ -131,7 +131,7 @@ MOS_STATUS MhwInterfacesG9Kbl::Initialize(
+ 
+     return MOS_STATUS_SUCCESS;
+ }
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool kblRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Kbl>((uint32_t)IGFX_KABYLAKE);
+diff --git a/media_driver/media_interface/media_interfaces_m9_skl/media_interfaces_g9_skl.cpp b/media_driver/media_interface/media_interfaces_m9_skl/media_interfaces_g9_skl.cpp
+index e2520edf7..4b0012c64 100644
+--- a/media_driver/media_interface/media_interfaces_m9_skl/media_interfaces_g9_skl.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_skl/media_interfaces_g9_skl.cpp
+@@ -139,7 +139,7 @@ MOS_STATUS MhwInterfacesG9Skl::Initialize(
+ 
+     return MOS_STATUS_SUCCESS;
+ }
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool sklRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Skl>((uint32_t)IGFX_SKYLAKE);
+-- 
+2.40.0
+
diff --git a/srcpkgs/intel-media-driver/patches/execinfo.patch b/srcpkgs/intel-media-driver/patches/execinfo.patch
deleted file mode 100644
index 25d21192d5a1..000000000000
--- a/srcpkgs/intel-media-driver/patches/execinfo.patch
+++ /dev/null
@@ -1,58 +0,0 @@
-From b17354142563b45e0ebf427485591426481368fd Mon Sep 17 00:00:00 2001
-From: Bernd Kuhls <bernd.kuhls@t-online.de>
-Date: Fri, 29 Jul 2022 19:51:39 +0200
-Subject: [PATCH] Fix uClibc build
-
-uClibc does not provide execinfo.h
----
- CMakeLists.txt                                              | 6 ++++++
- .../linux/common/os/osservice/mos_utilities_specific.cpp    | 4 ++++
- 2 files changed, 10 insertions(+)
-
-diff --git a/CMakeLists.txt b/CMakeLists.txt
-index 053904748..4a3f0869e 100755
---- a/CMakeLists.txt
-+++ b/CMakeLists.txt
-@@ -53,6 +53,12 @@ option (BUILD_CMRTLIB "Build and Install cmrtlib together with media driver" ON)
- 
- option (ENABLE_PRODUCTION_KMD "Enable Production KMD header files" OFF)
- 
-+include(CheckIncludeFileCXX)
-+check_include_file_cxx("execinfo.h" HAVE_EXECINFO)
-+if (HAVE_EXECINFO)
-+    add_definitions(-DHAVE_EXECINFO)
-+endif()
-+
- include(GNUInstallDirs)
- 
- if (BUILD_CMRTLIB AND NOT CMAKE_WDDM_LINUX)
-diff --git a/media_softlet/linux/common/os/osservice/mos_utilities_specific.cpp b/media_softlet/linux/common/os/osservice/mos_utilities_specific.cpp
-index bde216b83..120b02d55 100644
---- a/media_softlet/linux/common/os/osservice/mos_utilities_specific.cpp
-+++ b/media_softlet/linux/common/os/osservice/mos_utilities_specific.cpp
-@@ -34,7 +34,9 @@
- #include <signal.h>
- #include <unistd.h>  // fork
- #include <algorithm>
-+#ifdef HAVE_EXECINFO
- #include <execinfo.h> // backtrace
-+#endif
- #include <sys/types.h>
- #include <sys/stat.h>  // fstat
- #include <sys/ipc.h>  // System V IPC
-@@ -2473,6 +2475,7 @@ void MosUtilities::MosTraceEvent(
-                 MOS_FreeMemory(pTraceBuf);
-             }
-         }
-+#ifdef HAVE_EXECINFO
-         if (m_mosTraceFilter & (1ULL << TR_KEY_CALL_STACK))
-         {
-             // reserve space for header and stack size field.
-@@ -2492,6 +2495,7 @@ void MosUtilities::MosTraceEvent(
-                 size_t ret = write(MosUtilitiesSpecificNext::m_mosTraceFd, traceBuf, nLen);
-             }
-         }
-+#endif
-     }
-     return;
- }
diff --git a/srcpkgs/intel-media-driver/template b/srcpkgs/intel-media-driver/template
index 1ca94569e117..1735b90c65ce 100644
--- a/srcpkgs/intel-media-driver/template
+++ b/srcpkgs/intel-media-driver/template
@@ -1,6 +1,6 @@
 # Template file for 'intel-media-driver'
 pkgname=intel-media-driver
-version=22.5.3
+version=22.6.4
 revision=1
 archs="x86_64*"
 build_style=cmake
@@ -12,7 +12,7 @@ maintainer="Stefano Ragni <st3r4g@protonmail.com>"
 license="MIT, BSD-3-Clause"
 homepage="https://github.com/intel/media-driver"
 distfiles="https://github.com/intel/media-driver/archive/intel-media-${version}.tar.gz"
-checksum=65652b365d48be3c9f0b3c561502952b92ee5fcc587520b88d0d752cf2a6a3b5
+checksum=0c04b9d74b92de41fd409b62913ce4afd799236c0b6bc1983a496990764e5d90
 
 build_options="nonfree"
 desc_option_nonfree="Enable nonfree kernels"

From a926b907c751c2f377a8e5ab0d2a326b5599bb97 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 16 Dec 2022 09:31:43 -0500
Subject: [PATCH 112/140] New package: onevpl-2023.1.2

---
 common/shlibs           |  1 +
 srcpkgs/onevpl-devel    |  1 +
 srcpkgs/onevpl/template | 34 ++++++++++++++++++++++++++++++++++
 3 files changed, 36 insertions(+)
 create mode 120000 srcpkgs/onevpl-devel
 create mode 100644 srcpkgs/onevpl/template

diff --git a/common/shlibs b/common/shlibs
index 42744a55b1fc..f1675bacfe8b 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -879,6 +879,7 @@ libwebp.so.7 libwebp-0.6.0_1
 libwebpmux.so.3 libwebp-0.6.0_1
 libwebpdemux.so.2 libwebp-0.5.0_1
 libwebpdecoder.so.3 libwebp-0.6.0_1
+libvpl.so.2 onevpl-2023.1.2_1
 libva-x11.so.2 libva-2.13.0_1
 libva.so.2 libva-2.13.0_1
 libva-glx.so.2 libva-glx-2.13.0_1
diff --git a/srcpkgs/onevpl-devel b/srcpkgs/onevpl-devel
new file mode 120000
index 000000000000..e2306500b487
--- /dev/null
+++ b/srcpkgs/onevpl-devel
@@ -0,0 +1 @@
+onevpl
\ No newline at end of file
diff --git a/srcpkgs/onevpl/template b/srcpkgs/onevpl/template
new file mode 100644
index 000000000000..85c7c2da85ce
--- /dev/null
+++ b/srcpkgs/onevpl/template
@@ -0,0 +1,34 @@
+# Template file for 'onevpl'
+pkgname=onevpl
+version=2023.1.2
+revision=1
+archs="x86_64*"
+build_style=cmake
+configure_args="
+	-DCMAKE_BUILD_TYPE=Release -Wno-dev
+	-DBUILD_PYTHON_BINDING:BOOL='OFF'
+	-DBUILD_EXAMPLES:BOOL='OFF'
+	-DBUILD_TESTS:BOOL='ON'
+	-DINSTALL_EXAMPLE_CODE:BOOL='OFF'"
+hostmakedepends="cmake libX11 python wayland-protocols pkg-config"
+makedepends="libva-devel libX11-devel wayland-devel"
+short_desc="Intel oneAPI Video Processing library"
+maintainer="zlice <zlice555@gmail.com>"
+license="MIT"
+homepage="https://www.intel.com/content/www/us/en/developer/tools/oneapi/onevpl.html"
+distfiles="https://github.com/oneapi-src/oneVPL/archive/v${version}/${pkgname}-${version}.tar.gz"
+checksum=b2261cca174ce1815f3d47c647921ab17f68267c69c1e2444ff27aab7d199cbb
+
+post_install() {
+	vlicense LICENSE
+}
+
+onevpl-devel_package() {
+	depends="${makedepends} ${sourcepkg}-${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.so"
+	}
+}

From 4f4223a028a8bf07168ed56e336d44ca1c76974d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 16 Dec 2022 15:27:04 -0500
Subject: [PATCH 113/140] New package: onevpl-intel-gpu-22.6.4

---
 srcpkgs/onevpl-intel-gpu-devel    |  1 +
 srcpkgs/onevpl-intel-gpu/template | 27 +++++++++++++++++++++++++++
 2 files changed, 28 insertions(+)
 create mode 120000 srcpkgs/onevpl-intel-gpu-devel
 create mode 100644 srcpkgs/onevpl-intel-gpu/template

diff --git a/srcpkgs/onevpl-intel-gpu-devel b/srcpkgs/onevpl-intel-gpu-devel
new file mode 120000
index 000000000000..47920ceecf91
--- /dev/null
+++ b/srcpkgs/onevpl-intel-gpu-devel
@@ -0,0 +1 @@
+onevpl-intel-gpu
\ No newline at end of file
diff --git a/srcpkgs/onevpl-intel-gpu/template b/srcpkgs/onevpl-intel-gpu/template
new file mode 100644
index 000000000000..f14acb728a54
--- /dev/null
+++ b/srcpkgs/onevpl-intel-gpu/template
@@ -0,0 +1,27 @@
+# Template file for 'onevpl-intel-gpu'
+pkgname=onevpl-intel-gpu
+version=22.6.4
+revision=1
+archs="x86_64*"
+build_style=cmake
+configure_args="-Wno-dev -DCMAKE_BUILD_TYPE=Release"
+hostmakedepends="cmake pkg-config"
+makedepends="libdrm-devel libva-devel onevpl-devel"
+short_desc="Runtime implementation of oneVPL API for Intel Gen GPUs"
+maintainer="zlice <zlice555@gmail.com>"
+license="MIT"
+homepage="https://github.com/oneapi-src/oneVPL-intel-gpu"
+changelog="https://github.com/oneapi-src/oneVPL-intel-gpu/blob/main/CHANGELOG.md"
+distfiles="https://github.com/oneapi-src/oneVPL-intel-gpu/archive/refs/tags/intel-onevpl-${version}.tar.gz"
+checksum=74b0979dcb2af1b7c68edb8cbcb02d539de511090b12fac50652cbacd707c4e6
+
+post_install() {
+	vlicense LICENSE
+}
+
+onevpl-intel-gpu-devel_package() {
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/lib/pkgconfig
+	}
+}

From dff0b2e32e0009d234c97ec23c1746bfa0d7c893 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 18 Dec 2022 01:40:15 -0500
Subject: [PATCH 114/140] igt-gpu-tools: update to version 1.27 revbump idk
 remove

---
 ...-loading-failure-in-resolve-function.patch | 63 -------------------
 srcpkgs/igt-gpu-tools/patches/musl.patch      | 20 ++++++
 srcpkgs/igt-gpu-tools/template                |  4 +-
 3 files changed, 22 insertions(+), 65 deletions(-)
 delete mode 100644 srcpkgs/igt-gpu-tools/patches/i-g-t-Fix-global-symbol-loading-failure-in-resolve-function.patch

diff --git a/srcpkgs/igt-gpu-tools/patches/i-g-t-Fix-global-symbol-loading-failure-in-resolve-function.patch b/srcpkgs/igt-gpu-tools/patches/i-g-t-Fix-global-symbol-loading-failure-in-resolve-function.patch
deleted file mode 100644
index 0c3b554d9949..000000000000
--- a/srcpkgs/igt-gpu-tools/patches/i-g-t-Fix-global-symbol-loading-failure-in-resolve-function.patch
+++ /dev/null
@@ -1,63 +0,0 @@
-diff --git lib/igt_halffloat.c lib/igt_halffloat.c
-index 08ab05fc..e5e8a5bd 100644
---- a/lib/igt_halffloat.c
-+++ b/lib/igt_halffloat.c
-@@ -24,6 +24,19 @@
- 
- #include <assert.h>
- #include <math.h>
-+#include <stdbool.h>
-+
-+#ifdef HAVE_CPUID_H
-+#include <cpuid.h>
-+#else
-+#define __get_cpuid_max(x, y) 0
-+#define __cpuid(level, a, b, c, d) a = b = c = d = 0
-+#define __cpuid_count(level, count, a, b, c, d) a = b = c = d = 0
-+#endif
-+
-+#ifndef bit_F16C
-+#define bit_F16C	(1 << 29)
-+#endif
- 
- #include "igt_halffloat.h"
- #include "igt_x86.h"
-@@ -182,6 +195,20 @@ static void half_to_float_f16c(const uint16_t *h, float *f, unsigned int num)
- 
- #pragma GCC pop_options
- 
-+static bool f16c_is_supported(void)
-+{
-+	unsigned max = __get_cpuid_max(0, NULL);
-+	unsigned eax, ebx, ecx, edx;
-+
-+	if (max >= 1) {
-+		__cpuid(1, eax, ebx, ecx, edx);
-+
-+		if (ecx & bit_F16C)
-+			return true;
-+	}
-+	return false;
-+}
-+
- static void float_to_half(const float *f, uint16_t *h, unsigned int num)
- {
- 	for (int i = 0; i < num; i++)
-@@ -196,7 +223,7 @@ static void half_to_float(const uint16_t *h, float *f, unsigned int num)
- 
- static void (*resolve_float_to_half(void))(const float *f, uint16_t *h, unsigned int num)
- {
--	if (igt_x86_features() & F16C)
-+	if (f16c_is_supported())
- 		return float_to_half_f16c;
- 
- 	return float_to_half;
-@@ -207,7 +234,7 @@ void igt_float_to_half(const float *f, uint16_t *h, unsigned int num)
- 
- static void (*resolve_half_to_float(void))(const uint16_t *h, float *f, unsigned int num)
- {
--	if (igt_x86_features() & F16C)
-+	if (f16c_is_supported())
- 		return half_to_float_f16c;
- 
- 	return half_to_float;
diff --git a/srcpkgs/igt-gpu-tools/patches/musl.patch b/srcpkgs/igt-gpu-tools/patches/musl.patch
index 615afdb8f8ea..4de6e0cfd898 100644
--- a/srcpkgs/igt-gpu-tools/patches/musl.patch
+++ b/srcpkgs/igt-gpu-tools/patches/musl.patch
@@ -191,6 +191,7 @@ index 74935430..0dc87d8c 100644
 +++ b/tests/i915/i915_pm_rpm.c
 @@ -27,6 +27,7 @@
  
+<<<<<<< HEAD
  #include "config.h"
  
 +#include <limits.h> // PATH_MAX
@@ -293,3 +294,22 @@ index 0faf3fc8..f6bd970e 100644
  #include <stdio.h>
  #include <string.h>
  #include <stdlib.h>
+=======
+         fbo = bo->map;
+lib/ioctl_wrappers.c.new
+--- a/benchmarks/gem_exec_tracer.c	2022-12-18 10:32:15.742341964 -0500
++++ b/benchmarks/gem_exec_tracer.c	2022-12-18 10:32:09.862211372 -0500
+@@ -275,7 +275,11 @@
+     DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_EXECBUFFER2, struct drm_i915_gem_execbuffer2)
+ 
+ int
++#if defined(__GLIBC__) || defined(__FreeBSD__)
+ ioctl(int fd, unsigned long request, ...)
++#else
++ioctl(int fd, int request, ...)
++#endif
+ {
+ 	struct trace *t, **p;
+ 	va_list args;
+
+>>>>>>> 60301ae02f (igt-gpu-tools: update to version 1.26)
diff --git a/srcpkgs/igt-gpu-tools/template b/srcpkgs/igt-gpu-tools/template
index 225e2c79118a..1376c39d5d5b 100644
--- a/srcpkgs/igt-gpu-tools/template
+++ b/srcpkgs/igt-gpu-tools/template
@@ -1,7 +1,7 @@
 # Template file for 'igt-gpu-tools'
 pkgname=igt-gpu-tools
 version=1.27.1
-revision=1
+revision=2
 build_style=meson
 configure_args="-Db_ndebug=false -Ddocs=disabled"
 hostmakedepends="pkg-config flex peg python3-docutils"
@@ -13,7 +13,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="MIT"
 homepage="https://gitlab.freedesktop.org/drm/igt-gpu-tools"
 changelog="https://gitlab.freedesktop.org/drm/igt-gpu-tools/-/raw/master/NEWS"
-distfiles="${XORG_SITE}/app/igt-gpu-tools-${version}.tar.xz"
+distfiles="${XORG_SITE}/app/${pkgname}-${version}.tar.xz"
 checksum=93b9a4816ed22b5145bb61024314c8a65caeea991ce93027643f1d40723bf417
 # tests don't behave in containers
 make_check=ci-skip

From 2c2bbb3c048d7bb1e2ca260cda3c5157ca280e39 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:30:28 -0400
Subject: [PATCH 115/140] freecad: revbump for qt5-webengine-5.15.13

---
 srcpkgs/freecad/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/freecad/template b/srcpkgs/freecad/template
index f62023ee8ce4..e301f32d3540 100644
--- a/srcpkgs/freecad/template
+++ b/srcpkgs/freecad/template
@@ -1,7 +1,7 @@
 # Template file for 'freecad'
 pkgname=freecad
 version=0.20.2
-revision=3
+revision=4
 build_style=cmake
 
 _inst_prefix=/usr/lib/${pkgname}

From 2bd9f40dec77c0ba7b9444e116a063fb91985f89 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:31:45 -0400
Subject: [PATCH 116/140] shotcut: revbump for mlt7-7.14.0

---
 srcpkgs/shotcut/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/shotcut/template b/srcpkgs/shotcut/template
index 32583277dab2..8d8a7a0ebdeb 100644
--- a/srcpkgs/shotcut/template
+++ b/srcpkgs/shotcut/template
@@ -1,7 +1,7 @@
 # Template file for 'shotcut'
 pkgname=shotcut
 version=22.12.21
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSHOTCUT_VERSION=${version}"
 hostmakedepends="pkg-config qt5-tools-devel"

From 3eed630d5259d8b3a12ad23f11835b4d9a93c9c9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:30 -0400
Subject: [PATCH 117/140] shiboken2: revbump for qt5-5.15.8

---
 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch | 1 +
 srcpkgs/shiboken2/template                                 | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
 create mode 120000 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
new file mode 120000
index 000000000000..efcf3249bd88
--- /dev/null
+++ b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1 @@
+../../python3-pyside2/patches/importlib-machinery-bypass.patch
\ No newline at end of file
diff --git a/srcpkgs/shiboken2/template b/srcpkgs/shiboken2/template
index 084ecc3ba1e1..2a21998997eb 100644
--- a/srcpkgs/shiboken2/template
+++ b/srcpkgs/shiboken2/template
@@ -1,7 +1,7 @@
 # Template file for 'shiboken2'
 pkgname=shiboken2
 version=5.15.7
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/shiboken2"
 build_style=cmake

From 2f77e3b7f56f7a56b451c4adda302eb53776308f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:53 -0400
Subject: [PATCH 118/140] python3-pyside2: update to 5.15.8

---
 .../patches/importlib-machinery-bypass.patch      | 15 +++++++++++++++
 srcpkgs/python3-pyside2/template                  |  9 +++++----
 2 files changed, 20 insertions(+), 4 deletions(-)
 create mode 100644 srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
new file mode 100644
index 000000000000..64c429584776
--- /dev/null
+++ b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1,15 @@
+Using this prevents an error around line 220 below it.
+"AttributeError: module 'importlib' has no attribute 'machinery'"
+The old backup logic is in place and compiles without issues.
+--- a/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:09:34.688912402 -0400
++++ b/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:10:03.395529582 -0400
+@@ -170,9 +170,6 @@
+
+     # 'zipstring_sequence' comes from signature.cpp
+     zipbytes = base64.b64decode(''.join(zipstring_sequence))
+-    if sys.version_info[0] >= 3:
+-        vzip = zipfile.ZipFile(io.BytesIO(zipbytes))
+-        return sys.meta_path, EmbeddableZipImporter(vzip)
+
+     # Old version for Python 2.7, only.
+     import os
diff --git a/srcpkgs/python3-pyside2/template b/srcpkgs/python3-pyside2/template
index 50e6ff260d3b..b50e62bd215d 100644
--- a/srcpkgs/python3-pyside2/template
+++ b/srcpkgs/python3-pyside2/template
@@ -1,11 +1,12 @@
 # Template file for 'python3-pyside2'
 pkgname=python3-pyside2
-version=5.15.5
-revision=2
+version=5.15.8
+revision=1
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/pyside2"
 build_style=cmake
-configure_args="-DPYTHON_EXECUTABLE=/usr/bin/python"
+configure_args="-DPYTHON_EXECUTABLE=/usr/bin/python -DCMAKE_BUILD_TYPE=None
+ -DBUILD_TESTS=OFF"
 hostmakedepends="cmake python3 shiboken2"
 makedepends="python3-devel libshiboken2-devel qt5-devel
  qt5-multimedia-devel qt5-tools-devel qt5-plugin-mysql qt5-plugin-odbc
@@ -23,7 +24,7 @@ maintainer="yopito <pierre.bourgin@free.fr>"
 license="LGPL-3.0-or-later"
 homepage="https://wiki.qt.io/Qt_for_Python"
 distfiles="https://download.qt.io/official_releases/QtForPython/pyside2/PySide2-${version}-src/${_pkgname}.tar.xz"
-checksum=3920a4fb353300260c9bc46ff70f1fb975c5e7efa22e9d51222588928ce19b33
+checksum=23436302c8deb5b4cbc769b205d09604e38ba83b40708efccb7bd8c9af6f6b5d
 
 build_options="webengine"
 desc_option_webengine="Build Qt5 WebEngine bindings"

From 5db97d4908ebb421d36aeaacf8363326ea4aff84 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:35 -0400
Subject: [PATCH 119/140] konqueror: revbump for ffmpeg-6.0

---
 srcpkgs/konqueror/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/konqueror/template b/srcpkgs/konqueror/template
index d8d0e73a78ab..c5bdba601d3c 100644
--- a/srcpkgs/konqueror/template
+++ b/srcpkgs/konqueror/template
@@ -1,11 +1,11 @@
 # Template file for 'konqueror'
 pkgname=konqueror
 version=23.04.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DDESKTOPTOJSON_EXECUTABLE=/usr/bin/desktoptojson"
 hostmakedepends="extra-cmake-modules python3 qt5-host-tools qt5-qmake kdoctools
-kcoreaddons kconfig gettext"
+ kcoreaddons kconfig gettext"
 makedepends="qt5-devel qt5-webengine-devel qt5-declarative-devel
  qt5-webchannel-devel qt5-location-devel kcmutils-devel kdelibs4support-devel
  karchive-devel khtml-devel kdesu-devel kactivities5-devel"

From 4bc29eab751cd1209cab63f8c9621d5f16ca0a25 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:58 -0400
Subject: [PATCH 120/140] qt5-speech: revbump for qt5-5.15.8

---
 srcpkgs/qt5-speech/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-speech/template b/srcpkgs/qt5-speech/template
index 3ecd10d50650..2d7d4d4d2453 100644
--- a/srcpkgs/qt5-speech/template
+++ b/srcpkgs/qt5-speech/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-speech'
 pkgname=qt5-speech
 version=5.15.7
-revision=2
+revision=3
 _commit=d32f4a479d38a11f547598004b975f4356424a16
 build_style=qmake
 configure_args="-- -flite -flite-alsa -speechd"

From ad7e46e354c4f6db0dca5fd8104c4138bf5dbb3a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 18:38:50 -0400
Subject: [PATCH 121/140] qt5_styleplugins: revbump for qt5-5.15.8

---
 srcpkgs/qt5-styleplugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-styleplugins/template b/srcpkgs/qt5-styleplugins/template
index 96ed97d12cd2..30d93660a2a4 100644
--- a/srcpkgs/qt5-styleplugins/template
+++ b/srcpkgs/qt5-styleplugins/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-styleplugins'
 pkgname=qt5-styleplugins
 version=5.0.0
-revision=20
+revision=21
 _gitrev=335dbece103e2cbf6c7cf819ab6672c2956b17b3
 build_style=qmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From 5f2a93b834e886c0abb6b9b903c9b2cf988770b7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 27 Apr 2023 21:58:35 -0400
Subject: [PATCH 122/140] blender: update to 3.5.1

---
 srcpkgs/blender/patches/numpy-2.24.patch | 22 ----------------------
 srcpkgs/blender/template                 | 13 +++++++------
 2 files changed, 7 insertions(+), 28 deletions(-)
 delete mode 100644 srcpkgs/blender/patches/numpy-2.24.patch

diff --git a/srcpkgs/blender/patches/numpy-2.24.patch b/srcpkgs/blender/patches/numpy-2.24.patch
deleted file mode 100644
index 716315b74be7..000000000000
--- a/srcpkgs/blender/patches/numpy-2.24.patch
+++ /dev/null
@@ -1,22 +0,0 @@
-From 74e6e07cf7c67b55d384db72f5aa3892db8a3da6 Mon Sep 17 00:00:00 2001
-From: oreo639 <oreo6391@gmail.com>
-Date: Tue, 17 Jan 2023 14:36:54 -0800
-Subject: [PATCH] Remove usage of deprecated np.bool alias
-
----
- addons/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/addons/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py b/addons/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py
-index 6366434a6..8160c9e99 100644
---- a/release/scripts/addons/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py
-+++ b/release/scripts/addons/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py
-@@ -620,7 +620,7 @@ def set_poly_smoothing(gltf, pymesh, mesh, vert_normals, loop_vidxs):
-     # Try to guess which polys should be flat based on the fact that all the
-     # loop normals for a flat poly are = the poly's normal.
- 
--    poly_smooths = np.empty(num_polys, dtype=np.bool)
-+    poly_smooths = np.empty(num_polys, dtype=bool)
- 
-     poly_normals = np.empty(num_polys * 3, dtype=np.float32)
-     mesh.polygons.foreach_get('normal', poly_normals)
diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index d18bc88838ff..900bc17937c3 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -1,7 +1,7 @@
 # Template file for 'blender'
 pkgname=blender
-version=3.4.1
-revision=4
+version=3.5.1
+revision=1
 archs="x86_64* ppc64*"
 build_style="cmake"
 pycompile_dirs="/usr/share/blender/${version%.*}/scripts"
@@ -9,8 +9,8 @@ configure_args="-DWITH_INSTALL_PORTABLE=OFF -DWITH_PYTHON_INSTALL=OFF
  -DWITH_JACK=ON -DWITH_CODEC_FFMPEG=ON -DWITH_CODEC_SNDFILE=ON -DWITH_OPENMP=ON
  -DWITH_FFTW3=ON -DWITH_MOD_OCEANSIM=ON -DWITH_CYCLES_EMBREE=OFF -DWITH_OPENCOLORIO=ON
  -DWITH_IMAGE_OPENEXR=ON -DWITH_IMAGE_OPENJPEG=ON -DWITH_OPENSUBDIV=ON
- -DWITH_OPENCOLLADA=ON -DWITH_SYSTEM_GLEW=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
- -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_LIBDECOR=ON
+ -DWITH_OPENCOLLADA=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
+ -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_WAYLAND_LIBDECOR=ON
  -DWITH_BUILDINFO=OFF -DPYTHON_VERSION=${py3_ver} -DPYTHON_LIBPATH=/usr/lib
  -DPYTHON_LIBRARY='python${py3_ver}${py3_abiver}'
  -DPYTHON_INCLUDE_DIRS=/${py3_inc}"
@@ -22,14 +22,15 @@ makedepends="libgomp-devel libpng-devel tiff-devel python3-devel glu-devel
  opencolorio-devel opencollada-devel python3-numpy libXrender-devel
  OpenSubdiv-devel tbb-devel libxml2-devel openvdb-devel alembic-devel
  pugixml-devel libXxf86vm-devel libepoxy-devel gmp-devel gmpxx-devel
- wayland-protocols wayland-devel libxkbcommon-devel libdecor-devel"
+ wayland-protocols wayland-devel libxkbcommon-devel libdecor-devel
+ level-zero-devel"
 depends="desktop-file-utils hicolor-icon-theme"
 short_desc="3D graphics creation suite"
 maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="https://www.blender.org"
 distfiles="https://download.blender.org/source/blender-${version}.tar.xz"
-checksum=247c4c1228270c9010f4721c985cb5b628ab50abcf9f2678630737142eeb91c3
+checksum=bd7428c7e6cba5a900216269c32111dffaabaf1bdb5472f231965e615174a809
 python_version=3
 LDFLAGS="-Wl,-z,stack-size=2097152"
 # Blender tests are executed against a system installation of blender. This

From 3e3c48aee8f35f41a582362881c9eea1be7355f3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 27 Apr 2023 20:41:10 -0400
Subject: [PATCH 123/140] New package: level-zero-1.10.0

---
 srcpkgs/level-zero-devel    |  1 +
 srcpkgs/level-zero/template | 28 ++++++++++++++++++++++++++++
 2 files changed, 29 insertions(+)
 create mode 120000 srcpkgs/level-zero-devel
 create mode 100644 srcpkgs/level-zero/template

diff --git a/srcpkgs/level-zero-devel b/srcpkgs/level-zero-devel
new file mode 120000
index 000000000000..96ee8adf7303
--- /dev/null
+++ b/srcpkgs/level-zero-devel
@@ -0,0 +1 @@
+level-zero
\ No newline at end of file
diff --git a/srcpkgs/level-zero/template b/srcpkgs/level-zero/template
new file mode 100644
index 000000000000..4631c8c67505
--- /dev/null
+++ b/srcpkgs/level-zero/template
@@ -0,0 +1,28 @@
+# Template file for 'level-zero'
+pkgname=level-zero
+version=1.10.0
+revision=1
+archs="x86_64*"
+build_style=cmake
+hostmakedepends="cmake"
+makedepends="llvm clang clang-tools-extra SPIRV-LLVM-Translator-devel"
+short_desc="oneAPI Level Zero Specification"
+maintainer="Zlice <zlice555@gmail.com>"
+license="NCSA"
+homepage="https://github.com/oneapi-src/level-zero"
+distfiles="${homepage}/archive/refs/tags/v${version}.tar.gz"
+checksum=2811e4128ff6114020d0a147c2769b9b2e782e68ad49827685c33b9e716bf6ab
+
+post_install() {
+	vlicense LICENSE
+}
+
+level-zero-devel_package() {
+	depends="${makedepends} ${sourcepkg}-${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.so"
+	}
+}

From cd065f6f42d3251e2e56b3b84ad601d6f20de263 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 28 Mar 2023 19:54:49 -0400
Subject: [PATCH 124/140] New package: intel-metrics-library 1.0.133

---
 srcpkgs/intel-metrics-library/template | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
 create mode 100644 srcpkgs/intel-metrics-library/template

diff --git a/srcpkgs/intel-metrics-library/template b/srcpkgs/intel-metrics-library/template
new file mode 100644
index 000000000000..50f1a6079d7b
--- /dev/null
+++ b/srcpkgs/intel-metrics-library/template
@@ -0,0 +1,19 @@
+# Template file for 'intel-metrics-library'
+pkgname=intel-metrics-library
+version=1.0.133
+revision=1
+archs="x86_64*"
+build_style=cmake
+configure_args="-Wdev-no -DCMAKE_BUILD_TYPE=Release"
+hostmakedepends="cmake"
+makedepends="libdrm-devel"
+short_desc="Helper library that provides access to GPU performance counters"
+maintainer="Zlice <zlice555@gmail.com>"
+license="MIT"
+homepage="https://github.com/intel/metrics-library"
+distfiles="${homepage}/archive/refs/tags/metrics-library-${version}.tar.gz"
+checksum=83f7b2de3af5ffd2f1b487df8836e6d212e11668bd958bebae622a483fb1231f
+
+post_install() {
+	vlicense LICENSE.md
+}

From 0f23b9cb3a79a851b40412710dcc01a9525c41c0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 28 Mar 2023 19:54:18 -0400
Subject: [PATCH 125/140] New package: intel-metrics-discovery 1.12.163

---
 srcpkgs/intel-metrics-discovery/template | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
 create mode 100644 srcpkgs/intel-metrics-discovery/template

diff --git a/srcpkgs/intel-metrics-discovery/template b/srcpkgs/intel-metrics-discovery/template
new file mode 100644
index 000000000000..6083595e273c
--- /dev/null
+++ b/srcpkgs/intel-metrics-discovery/template
@@ -0,0 +1,19 @@
+# Template file for 'intel-metrics-discovery'
+pkgname=intel-metrics-discovery
+version=1.12.163
+revision=1
+archs="x86_64*"
+build_style=cmake
+configure_args="-Wdev-no -DCMAKE_BUILD_TYPE=Release"
+hostmakedepends="cmake"
+makedepends="libdrm-devel"
+short_desc="Helper library that provides access to GPU performance data"
+maintainer="Zlice <zlice555@gmail.com>"
+license="MIT"
+homepage="https://github.com/intel/metrics-discovery"
+distfiles="${homepage}/archive/refs/tags/metrics-discovery-${version}.tar.gz"
+checksum=6dfe8d11c58625bf3ebf656ec2a95dc96bbb05705ec71c6c3c3dd0ef5cd2319c
+
+post_install() {
+	vlicense LICENSE.md
+}

From 3727c79cb0e858a389626ca599bea657f8cfbcd1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 26 Mar 2023 10:48:34 -0400
Subject: [PATCH 126/140] New package: intel-graphics-compiler-1.0.13463.18

---
 srcpkgs/intel-graphics-compiler/template | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 srcpkgs/intel-graphics-compiler/template

diff --git a/srcpkgs/intel-graphics-compiler/template b/srcpkgs/intel-graphics-compiler/template
new file mode 100644
index 000000000000..44d38214f929
--- /dev/null
+++ b/srcpkgs/intel-graphics-compiler/template
@@ -0,0 +1,22 @@
+# Template file for 'intel-graphics-compiler'
+pkgname=intel-graphics-compiler
+version=1.0.13463.18
+revision=1
+archs="x86_64*"
+build_style=cmake
+configure_args="-Wno-dev -DIGC_OPTION__LLVM_PREFERRED_VERSION=15.0.7 -DCCLANG_FROM_SYSTEM=ON
+ -DIGC_OPTION__SPIRV_TOOLS_MODE=Prebuilds -DIGC_OPTION__USE_PREINSTALLED_SPRIV_HEADERS=ON
+ -DIGC_OPTION__VC_INTRINSICS_MODE=Prebuilds"
+hostmakedepends="flex bison zlib-devel libzstd-devel cmake"
+makedepends="llvm clang clang-tools-extra intel-opencl-clang intel-vc-intrinsics
+ lld lld-devel SPIRV-Headers  SPIRV-LLVM-Translator-devel SPIRV-Tools-devel"
+short_desc="LLVM based compiler for OpenCL targeting Intel"
+maintainer="Zlice <zlice555@gmail.com>"
+license="MIT"
+homepage="https://github.com/intel/intel-graphics-compiler"
+distfiles="${homepage}/archive/refs/tags/igc-${version}.tar.gz"
+checksum=0b960878a5feffd6aa10197c48bf73a0a3a19d0105428d48163e91db0444070a
+
+post_install() {
+	vlicense LICENSE.md
+}

From c697b135df60a4bba1d41f5ad63d28d0cbc078a2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 26 Mar 2023 10:48:05 -0400
Subject: [PATCH 127/140] New package: intel-compute-runtime-23.09.25812.14

---
 srcpkgs/intel-compute-runtime/template | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 srcpkgs/intel-compute-runtime/template

diff --git a/srcpkgs/intel-compute-runtime/template b/srcpkgs/intel-compute-runtime/template
new file mode 100644
index 000000000000..1132b830d348
--- /dev/null
+++ b/srcpkgs/intel-compute-runtime/template
@@ -0,0 +1,22 @@
+# Template file for 'intel-compute-runtime'
+pkgname=intel-compute-runtime
+version=23.09.25812.14
+revision=1
+archs="x86_64"
+build_style=cmake
+configure_args="-Wno-dev -DNEO_SKIP_UNIT_TESTS=1 -DSUPPORT_DG1=ON -DSUPPORT_DG2=ON"
+hostmakedepends="cmake pkg-config"
+makedepends="gcc intel-gmmlib-devel libva-devel ocl-icd-devel
+ intel-opencl-clang intel-graphics-compiler level-zero-devel
+ intel-metrics-library intel-metrics-discovery"
+depends="intel-graphics-compiler"
+short_desc="Intel Graphics Compute Runtime for oneAPI Level Zero and OpenCL"
+maintainer="Zlice <zlice555@gmail.com>"
+license="MIT"
+homepage="https://github.com/intel/compute-runtime"
+distfiles="${homepage}/archive/refs/tags/${version}.tar.gz"
+checksum=abe2e6d9d2ac771d5f42ee2357ce897ca3b00dc6185c06f3f62772f729c7f8e1
+
+post_install() {
+	vlicense LICENSE.md
+}

From dd9aaf4b83d14b721956071b8134f9dd1fca7b68 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 26 Mar 2023 10:46:58 -0400
Subject: [PATCH 128/140] New package: intel-vc-intrinsics-0.12.3

---
 srcpkgs/intel-vc-intrinsics/template | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
 create mode 100644 srcpkgs/intel-vc-intrinsics/template

diff --git a/srcpkgs/intel-vc-intrinsics/template b/srcpkgs/intel-vc-intrinsics/template
new file mode 100644
index 000000000000..129482bdf985
--- /dev/null
+++ b/srcpkgs/intel-vc-intrinsics/template
@@ -0,0 +1,21 @@
+# Template file for 'intel-vc-intrinsics'
+pkgname=intel-vc-intrinsics
+version=0.12.3
+revision=1
+archs="x86_64*"
+build_style=cmake
+configure_args="-Wno-dev -DLLVM_DIR=/usr/lib/cmake/llvm -DCMAKE_BUILD_TYPE=Release"
+hostmakedepends="cmake python"
+makedepends="llvm clang clang-tools-extra"
+short_desc="Set of intrinsics on top of core LLVM IR"
+maintainer="Zlice <zlice555@gmail.com>"
+license="MIT"
+homepage="https://github.com/intel/vc-intrinsics"
+distfiles="${homepage}/archive/refs/tags/v${version}.tar.gz"
+checksum=ed1c0d968cb2f8ee7b2840a14c3261639f1700e844fb7d2a89856babffd5e1d1
+
+# TODO: license isn't bundled in tar?
+#       just added 2 days ago... mar 24th 2023
+#post_install() {
+#	vlicense LICENSE.md
+#}

From b7df15baf1bcf650ccd41e3d069995f6d53939c2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 26 Mar 2023 10:46:11 -0400
Subject: [PATCH 129/140] New package: intel-opencl-clang-15.0.0

---
 common/shlibs                       |  1 +
 srcpkgs/intel-opencl-clang/template | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+)
 create mode 100644 srcpkgs/intel-opencl-clang/template

diff --git a/common/shlibs b/common/shlibs
index f1675bacfe8b..f2d1be3d8514 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -1008,6 +1008,7 @@ libLLVM-15.so libllvm15-15.0.7_1
 libLLVMSPIRVLib.so.15 SPIRV-LLVM-Translator-15.0.0_1
 libomp.so.5 libomp-15.0.7_1
 libomptarget.so.15 libomp-15.0.7_1
+libopencl-clang.so.15 intel-opencl-clang-15.0.0_1
 libisofs.so.6 libisofs-0.6.24_1
 libmpack.so.0 libmpack-1.0.5_1
 libGeoIP.so.1 libgeoip-1.4.8_1
diff --git a/srcpkgs/intel-opencl-clang/template b/srcpkgs/intel-opencl-clang/template
new file mode 100644
index 000000000000..e6f09f6ad724
--- /dev/null
+++ b/srcpkgs/intel-opencl-clang/template
@@ -0,0 +1,18 @@
+# Template file for 'intel-opencl-clang'
+pkgname=intel-opencl-clang
+version=15.0.0
+revision=1
+archs="x86_64*"
+build_style=cmake
+hostmakedepends="cmake"
+makedepends="llvm clang clang-tools-extra SPIRV-LLVM-Translator-devel"
+short_desc="LLVM linked opencl-clang"
+maintainer="Zlice <zlice555@gmail.com>"
+license="NCSA"
+homepage="https://github.com/intel/opencl-clang"
+distfiles="${homepage}/archive/refs/tags/v${version}.tar.gz"
+checksum=ea179674e52bc8c658e2655f76be467f7052f7d2c37ebcfdb102dce645ad1411
+
+post_install() {
+	vlicense LICENSE
+}

From 5612d4e634f39abf6cc187e27c5db5a3b27efefb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 30 Apr 2023 20:22:25 -0400
Subject: [PATCH 130/140] gstreamer1: update to 1.22.2

---
 srcpkgs/gstreamer1/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gstreamer1/template b/srcpkgs/gstreamer1/template
index 362fe82faec3..571148f2ff33 100644
--- a/srcpkgs/gstreamer1/template
+++ b/srcpkgs/gstreamer1/template
@@ -1,6 +1,6 @@
 # Template file for 'gstreamer1'
 pkgname=gstreamer1
-version=1.22.1
+version=1.22.2
 revision=1
 build_style=meson
 build_helper="gir"
@@ -16,7 +16,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.0-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/gstreamer/gstreamer-${version}.tar.xz"
-checksum=cd3ca759f926763615fdfcea63c9761198c42889bc0615ceec73e22b24fde771
+checksum=b2afe73603921c608ba48969dbb7d743776744bfe5d8059ece241137b7f88e21
 
 pre_check() {
 	# gst_gstdatetime is known to fail according to LFS

From 41c3c5a97b5d0506744cf961858e8829fb7cb13b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 30 Apr 2023 20:22:26 -0400
Subject: [PATCH 131/140] gst-plugins-base1: update to 1.22.2

---
 srcpkgs/gst-plugins-base1/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-plugins-base1/template b/srcpkgs/gst-plugins-base1/template
index 6d2cad16f985..2f20ea819849 100644
--- a/srcpkgs/gst-plugins-base1/template
+++ b/srcpkgs/gst-plugins-base1/template
@@ -1,6 +1,6 @@
 # Template file for 'gst-plugins-base1'
 pkgname=gst-plugins-base1
-version=1.22.1
+version=1.22.2
 revision=1
 build_style=meson
 build_helper="gir"
@@ -22,7 +22,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname/1/}/${pkgname/1/}-${version}.tar.xz"
-checksum=59bcaeacc5646b8dbdcfa4ef20ca6e818dd234910efb4cee1bbea441a3801c69
+checksum=eb65120c4ee79b7a153c3c1972d5c0158c2151877cc51ec7725bba5749679d49
 
 build_options="cdparanoia gir sndio wayland"
 build_options_default="cdparanoia gir wayland"

From 365ad737dd9435d192b5345f04258ca929a40923 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 30 Apr 2023 20:22:26 -0400
Subject: [PATCH 132/140] gst-plugins-good1: update to 1.22.2

---
 srcpkgs/gst-plugins-good1/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-plugins-good1/template b/srcpkgs/gst-plugins-good1/template
index 00baa6732c75..5d0fe1bfe284 100644
--- a/srcpkgs/gst-plugins-good1/template
+++ b/srcpkgs/gst-plugins-good1/template
@@ -1,6 +1,6 @@
 # Template file for 'gst-plugins-good1'
 pkgname=gst-plugins-good1
-version=1.22.1
+version=1.22.2
 revision=1
 build_style=meson
 configure_args="-Ddv=disabled -Ddv1394=disabled -Dshout2=disabled -Dqt5=enabled
@@ -22,7 +22,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname/1/}/${pkgname/1/}-${version}.tar.xz"
-checksum=44f9104654b4fd042aebe90932ab92e7ff7d8460fbc05b23dad87dffe70974cc
+checksum=7c8cc59425f2b232f60ca7d13e56edd615da4f711e73dd01a7cffa46e6bc0cdd
 
 build_options="gtk3 wayland"
 build_options_default="gtk3 wayland"

From 93dbba9600b15a8fb2767c8395503a1422357232 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 30 Apr 2023 20:22:26 -0400
Subject: [PATCH 133/140] gst-plugins-bad1: update to 1.22.2

---
 srcpkgs/gst-plugins-bad1/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index 7f272f915ac4..77bf79981c20 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-plugins-bad1'
 pkgname=gst-plugins-bad1
-version=1.22.1
-revision=2
+version=1.22.2
+revision=1
 build_helper="gir"
 build_style=meson
 configure_args="-Dpackage-origin=https://voidlinux.org -Ddoc=disabled
@@ -36,7 +36,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later, LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname/1/}/${pkgname/1/}-${version}.tar.xz"
-checksum=2f39b6f222d98666f9ff420a00233e336949953a846237c2bfafc8805f509f0e
+checksum=3d8faf1ce3402c8535ce3a8c4e1a6c960e4b5655dbda6b55943db9ac79022d0f
 
 build_options="gir gme wayland"
 build_options_default="gir wayland"

From b2cac7368f15838526ca2eccdf02b4b5e6261ce9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 30 Apr 2023 20:22:26 -0400
Subject: [PATCH 134/140] gst-plugins-ugly1: update to 1.22.2

---
 srcpkgs/gst-plugins-ugly1/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-plugins-ugly1/template b/srcpkgs/gst-plugins-ugly1/template
index 5647c012c9fe..85ae64bc7a0a 100644
--- a/srcpkgs/gst-plugins-ugly1/template
+++ b/srcpkgs/gst-plugins-ugly1/template
@@ -1,6 +1,6 @@
 # Template file for 'gst-plugins-ugly1'
 pkgname=gst-plugins-ugly1
-version=1.22.1
+version=1.22.2
 revision=1
 build_style=meson
 configure_args="-Damrnb=disabled -Damrwbdec=disabled -Dsidplay=disabled"
@@ -15,4 +15,4 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname/1/}/${pkgname/1/}-${version}.tar.xz"
-checksum=4ab3d9e13481bce1ca3c7c4bb1f65dce4f0bb40fb1cac4416e8c06dd648815c2
+checksum=8f30f44db0bd063709bf6fbe55138e3a98af0abcb61c360f35582bbe10e80691

From 1f9274630e726512c53e6e8110e1d25bdcbb8edc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 30 Apr 2023 20:22:26 -0400
Subject: [PATCH 135/140] gst-omx: update to 1.22.2

---
 srcpkgs/gst-omx/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-omx/template b/srcpkgs/gst-omx/template
index 76692c2a13f6..5ad54cc7b9d8 100644
--- a/srcpkgs/gst-omx/template
+++ b/srcpkgs/gst-omx/template
@@ -1,6 +1,6 @@
 # Template file for 'gst-omx'
 pkgname=gst-omx
-version=1.22.1
+version=1.22.2
 revision=1
 build_style=meson
 configure_args="-Dexamples=disabled -Dtarget=generic"
@@ -11,4 +11,4 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.1-only"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname}/${pkgname}-${version}.tar.xz"
-checksum=2d37f60cd33e68dcef0bcd09b2dd8a0b2eb3ab6d6ac172dca46f70eb02756687
+checksum=1b0c57f2cc4ddeec5e7f0c436e502f06665c4e93c73261855b94e04fc94337b2

From 740c292b2c608703a0f4d746699c618ae5dfb632 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 30 Apr 2023 20:22:26 -0400
Subject: [PATCH 136/140] gst-rtsp-server: update to 1.22.2

---
 srcpkgs/gst-rtsp-server/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index ded9a69a2e9d..2f0c0c45ff82 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,6 +1,6 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
-version=1.22.1
+version=1.22.2
 revision=1
 build_style=meson
 hostmakedepends="pkg-config python3"
@@ -11,4 +11,4 @@ maintainer="1is7ac3 <isaac.qa13@gmail.com>"
 license="LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname}/${pkgname}-${version}.tar.xz"
-checksum=4e0b972608f67d5d8f5363c827cfcf132b0e00877be6f1905358d514249b05a3
+checksum=2be4aecfb88710100ea7115ed0216403e8094344ebf146094271b8d4d73828bf

From 02f59c15c30a6bca2e3da44d555661823ef6c0d0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 30 Apr 2023 20:22:26 -0400
Subject: [PATCH 137/140] gst1-editing-services: update to 1.22.2

---
 srcpkgs/gst1-editing-services/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst1-editing-services/template b/srcpkgs/gst1-editing-services/template
index f2045ad6043c..102440f7f253 100644
--- a/srcpkgs/gst1-editing-services/template
+++ b/srcpkgs/gst1-editing-services/template
@@ -1,6 +1,6 @@
 # Template file for 'gst1-editing-services'
 pkgname=gst1-editing-services
-version=1.22.1
+version=1.22.2
 revision=1
 build_style=meson
 build_helper="gir"
@@ -12,7 +12,7 @@ maintainer="Toyam Cox <Vaelatern@gmail.com>"
 license="LGPL-2.0-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname/gst1/gst}/${pkgname/gst1/gst}-${version}.tar.xz"
-checksum=0f9e5e08ef80a4b9a0e971c5f032b13c71aa6fef236265c2d615456e15161438
+checksum=453b1464fc3857de269a7cb0ebd966afe02171d97bef672a0b8a0a6d43e0cebf
 
 do_check() {
 	: # Tests fail in older versions as well

From fece21e2cedb4e5a130571d7f77ef54c94d24e38 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 30 Apr 2023 20:22:26 -0400
Subject: [PATCH 138/140] gst1-python3: update to 1.22.2

---
 srcpkgs/gst1-python3/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst1-python3/template b/srcpkgs/gst1-python3/template
index 7a8d094ef61f..789e40f036ea 100644
--- a/srcpkgs/gst1-python3/template
+++ b/srcpkgs/gst1-python3/template
@@ -1,6 +1,6 @@
 # Template file for 'gst1-python3'
 pkgname=gst1-python3
-version=1.22.1
+version=1.22.2
 revision=1
 build_style=meson
 hostmakedepends="pkg-config python3"
@@ -11,4 +11,4 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/gst-python/gst-python-${version}.tar.xz"
-checksum=96008a441d685a64275a515b893ccad0fea1d560c43acd0763533e17f3a13ebb
+checksum=bef2b3d82ce4be46b775b1bb56305c1003ee01b535a53a82f9fe8924972153ad

From 559168bb24897305a7ed05002fe3dde79af6c88c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 30 Apr 2023 20:22:26 -0400
Subject: [PATCH 139/140] gstreamer-vaapi: update to 1.22.2

---
 srcpkgs/gstreamer-vaapi/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gstreamer-vaapi/template b/srcpkgs/gstreamer-vaapi/template
index c100d99e9af1..0a5ee8b1ca3f 100644
--- a/srcpkgs/gstreamer-vaapi/template
+++ b/srcpkgs/gstreamer-vaapi/template
@@ -1,6 +1,6 @@
 # Template file for 'gstreamer-vaapi'
 pkgname=gstreamer-vaapi
-version=1.22.1
+version=1.22.2
 revision=1
 build_style=meson
 hostmakedepends="pkg-config"
@@ -11,7 +11,7 @@ license="LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
 changelog="https://raw.githubusercontent.com/GStreamer/gstreamer-vaapi/master/ChangeLog"
 distfiles="${homepage}/src/gstreamer-vaapi/gstreamer-vaapi-${version}.tar.xz"
-checksum=423b57db7fc5f9137dadf17cb3853a47438d63cd4ba6889a882e63fb5be997bc
+checksum=d2e642f9745f97d9f73a7f5085e7659a9a31fe209b774e6e45dae041b435df06
 
 pre_check() {
 	# Seems to need certain hardware to pass

From 7cead1792cd0cf5d055e429b3f7222bf996b9985 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 30 Apr 2023 20:22:26 -0400
Subject: [PATCH 140/140] gst-libav: update to 1.22.2

---
 srcpkgs/gst-libav/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index a2c97bfbcdb9..8c72fc3e97ee 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,6 +1,6 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
-version=1.22.1
+version=1.22.2
 revision=1
 build_style=meson
 hostmakedepends="pkg-config yasm"
@@ -11,7 +11,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.0-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname}/${pkgname}-${version}.tar.xz"
-checksum=c958e825dc3ac3b7a481f8db5268131a1cd701312385c2d803dc63c8e460b5fb
+checksum=fcaaf9878fe8f3bc82317ef13a1558824cb68df1f8968c6797f556c5e33bcffd
 
 case "$XBPS_TARGET_MACHINE" in
 	*-musl) # Required by musl for M_SQRT1_2

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
  2023-05-05 13:27 ` [PR PATCH] [Updated] " zlice
@ 2023-05-05 13:53 ` zlice
  2023-05-05 18:04 ` [PR PATCH] [Updated] " zlice
                   ` (95 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2023-05-05 13:53 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 479 bytes --]

New comment by zlice on void-packages repository

https://github.com/void-linux/void-packages/pull/43761#issuecomment-1536296485

Comment:
xlint questions

```
============ qt5 ===============
qt5:35: verify python_version and remove "#unverified"
qt5:529: use <pkgname>-doc subpackage for documentation
```

what counts as 'verified' for python?

does doc pkg need changed? looks like a separate package (still on 5.15.2 and out of sync with current qt5 5.15.7)




^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
  2023-05-05 13:27 ` [PR PATCH] [Updated] " zlice
  2023-05-05 13:53 ` zlice
@ 2023-05-05 18:04 ` zlice
  2023-05-07 19:26 ` paper42
                   ` (94 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2023-05-05 18:04 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 2793 bytes --]

There is an updated pull request by zlice against master on the void-packages repository

https://github.com/zlice/void-packages ffmpeg6-split
https://github.com/void-linux/void-packages/pull/43761

ffmpeg6 split
[ci skip]


#### Testing the changes

- I tested the changes in this PR: **YES**

main testing has been vaapi in Firefox Nightly and enc/dec in Shotcut on Intel A770

#### New package

- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**

#### Local build testing

- I built this PR locally for my native architecture, **x86_64**

#### Discussion

Continuation of https://github.com/void-linux/void-packages/pull/36315

`libavresample` is deprecated, but marked as a dependency when trying to build other packages and install `ffmpeg`(5). I think the right way to handle this is make a meta package and the add to removals?


##### Commit naming / misc

Commits are 'dirty' right now, running with [gstreamer 1.22.1 updates](https://github.com/void-linux/void-packages/pull/42861) and [Intel OpenCL](https://github.com/void-linux/void-packages/pull/43084). This will also make [intel packages pr](https://github.com/void-linux/void-packages/pull/41132) obsolete.

Maintainer for previous ffmpeg(4) was orphaned, I can put my name in there if that matters, though I don't exactly see myself keeping up on ffmpeg.

This updates QT5 which looks like it is usually hosted by Johnny. Not sure if there's any reason to stay there or these sources are fine.

##### STILL FFMPEG4

These are a mix of emulators, games and/or older packages.

- attract (multiple patches in master)
- audacity  (3.2.x+ should work but requires wxWidgets dev 3.1.x)
- ccextractor (master patches? no release)
- vice
- kodi
- mlt
- synfig (mlt)
- tvheadend
- ssr
- spek-alternative
- ppsspp
- olive
- moc
- mediastreamer
- libextractor
- idjc
- hedgewars
- ffmpegthumbnailer
- ffmpegthumbs
- deadbeef
- omxplayer
- qtav (fork has ffmpeg 5 patch - https://github.com/cmguo/QtAV)
- `vlc` (vlc4 will support ffmpeg5, there's a patch to build 3.x with ffmpeg5 but it will lack vaapi)
- `osg` (OpenSceneGraph plus `xine-lib`)
- `ytmdl` ? not sure but it uses `python3-ffmpeg-python` which being 6-8yr old I imagine is ffmpeg4


##### HAVE NOT BUILT YET

- omxplayer (rpi only?)
- kodi (big, but ffmpeg4)


##### UPDATED (for ffmpeg5)

- unpaper: update to 7.0.0.
- guvcview: update to 2.0.8.
- qt5: update to 5.15.8
- qt5-webengine: update to 5.18.13
- shiboken2: revbump for qt5.15.8 (patch)
- python3-pyside2: update to 5.15.8 (patch)


A patch file from https://github.com/void-linux/void-packages/pull/43761.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ffmpeg6-split-43761.patch --]
[-- Type: text/x-diff, Size: 820169 bytes --]

From ffbaac24c1cbec506af20e9f5e044cc19d9a7e29 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:55:46 -0400
Subject: [PATCH 001/130] ffmpeg: update to 6.0.

---
 common/shlibs                                 | 26 +++++---
 srcpkgs/ffmpeg/files/altivec.patch            | 60 -------------------
 .../patches/armv5tel-floating-point.patch     | 18 ------
 .../workaround-mesa-readeon-vaapi-bug.patch   | 28 ---------
 srcpkgs/ffmpeg/template                       | 31 +++++-----
 5 files changed, 33 insertions(+), 130 deletions(-)
 delete mode 100644 srcpkgs/ffmpeg/files/altivec.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch

diff --git a/common/shlibs b/common/shlibs
index 8c47e79b8c43..d650f2a3045d 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -390,15 +390,23 @@ libid3tag.so.0 libid3tag-0.15.1b_1
 libgif.so.7 giflib-5.1.0_1
 libImlib2.so.1 imlib2-1.4.2_1
 libmp3lame.so.0 lame-3.98.2_1
-libavdevice.so.58 libavdevice-4.0_1
-libavformat.so.58 libavformat-4.0_1
-libswscale.so.5 libswscale-4.0_1
-libswresample.so.3 libswresample-4.0_1
-libavresample.so.4 libavresample-4.0_1
-libpostproc.so.55 libpostproc-4.0_1
-libavcodec.so.58 libavcodec-4.0_1
-libavutil.so.56 libavutil-4.0_1
-libavfilter.so.7 libavfilter-4.0_1
+libavdevice.so.60 libavdevice-6.0_1
+libavformat.so.60 libavformat-6.0_1
+libswscale.so.7 libswscale-6.0_1
+libswresample.so.4 libswresample-6.0_1
+libpostproc.so.57 libpostproc-6.0_1
+libavcodec.so.60 libavcodec-6.0_1
+libavutil.so.58 libavutil-6.0_1
+libavfilter.so.9 libavfilter-6.0_1
+libavdevice.so.58 libavdevice4-4.0_1
+libavformat.so.58 libavformat4-4.0_1
+libswscale.so.5 libswscale4-4.0_1
+libswresample.so.3 libswresample4-4.0_1
+libavresample.so.4 libavresample4-4.0_1
+libpostproc.so.55 libpostproc4-4.0_1
+libavcodec.so.58 libavcodec4-4.0_1
+libavutil.so.56 libavutil4-4.0_1
+libavfilter.so.7 libavfilter4-4.0_1
 libSDL-1.2.so.0 SDL-1.2.14_1
 libSDL_image-1.2.so.0 SDL_image-1.2.10_1
 libx264.so.157 x264-20190507.2245_1
diff --git a/srcpkgs/ffmpeg/files/altivec.patch b/srcpkgs/ffmpeg/files/altivec.patch
deleted file mode 100644
index 9c5720046332..000000000000
--- a/srcpkgs/ffmpeg/files/altivec.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-revert some altivec specific change on all ppc* except ppc64le*
-
-q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
-conditionally, for ppc* but not ppc64le* (the new code is valid for
-POWER8 VSX which LE targets as a baseline but not BE)"
-
-
-This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
----
- libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
- 1 file changed, 20 insertions(+), 4 deletions(-)
-
-diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
-index 536545293d..c1e2852adb 100644
---- a/libswscale/ppc/yuv2rgb_altivec.c
-+++ b/libswscale/ppc/yuv2rgb_altivec.c
-@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-     vector signed short R1, G1, B1;                                           \
-     vector unsigned char R, G, B;                                             \
-                                                                               \
-+    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
-+    vector unsigned char align_perm;                                          \
-+                                                                              \
-     vector signed short lCY       = c->CY;                                    \
-     vector signed short lOY       = c->OY;                                    \
-     vector signed short lCRV      = c->CRV;                                   \
-@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
-                                                                               \
-         for (j = 0; j < w / 16; j++) {                                        \
--            y0 = vec_xl(0, y1i);                                              \
-+            y1ivP = (const vector unsigned char *) y1i;                       \
-+            y2ivP = (const vector unsigned char *) y2i;                       \
-+            uivP  = (const vector unsigned char *) ui;                        \
-+            vivP  = (const vector unsigned char *) vi;                        \
-+                                                                              \
-+            align_perm = vec_lvsl(0, y1i);                                    \
-+            y0 = (vector unsigned char)                                       \
-+                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
-                                                                               \
--            y1 = vec_xl(0, y2i);                                              \
-+            align_perm = vec_lvsl(0, y2i);                                    \
-+            y1 = (vector unsigned char)                                       \
-+                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
-                                                                               \
--            u = (vector signed char) vec_xl(0, ui);                           \
-+            align_perm = vec_lvsl(0, ui);                                     \
-+            u = (vector signed char)                                          \
-+                    vec_perm(uivP[0], uivP[1], align_perm);                   \
-                                                                               \
--            v = (vector signed char) vec_xl(0, vi);                           \
-+            align_perm = vec_lvsl(0, vi);                                     \
-+            v = (vector signed char)                                          \
-+                    vec_perm(vivP[0], vivP[1], align_perm);                   \
-                                                                               \
-             u = (vector signed char)                                          \
-                     vec_sub(u,                                                \
--- 
-2.27.0
-
diff --git a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
deleted file mode 100644
index 9a55178c74f0..000000000000
--- a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
-+++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
-@@ -39,6 +39,15 @@
- #endif
- #include <fenv.h>
- 
-+#if (FE_ALL_EXCEPT == 0)
-+/* E.g. ARM soft float does not define these */
-+#define FE_INVALID    0
-+#define FE_DIVBYZERO  0
-+#define FE_OVERFLOW   0
-+#define FE_UNDERFLOW  0
-+#define FE_INEXACT    0
-+#endif
-+
- #if CONFIG_LIBFONTCONFIG
- #include <fontconfig/fontconfig.h>
- #endif
diff --git a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
deleted file mode 100644
index 00e3f68a415b..000000000000
--- a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
-From: Rainer Hochecker <fernetmenta@online.de>
-Date: Sat, 26 Jan 2019 19:48:35 +0100
-Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
-
-This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
-It was hit frequently when watching h264 channels received via DVB-X.
-Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
----
- libavcodec/vaapi_h264.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
-index 5854587a255..f12fdc457a4 100644
---- a/libavcodec/vaapi_h264.c
-+++ b/libavcodec/vaapi_h264.c
-@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
-     H264SliceContext *sl = &h->slice_ctx[0];
-     int ret;
- 
-+    if (pic->nb_slices == 0) {
-+        ret = AVERROR_INVALIDDATA;
-+        goto finish;
-+    }
-+
-     ret = ff_vaapi_decode_issue(avctx, pic);
-     if (ret < 0)
-         goto finish;
diff --git a/srcpkgs/ffmpeg/template b/srcpkgs/ffmpeg/template
index 23a3d5c9967b..3d99e5173697 100644
--- a/srcpkgs/ffmpeg/template
+++ b/srcpkgs/ffmpeg/template
@@ -1,15 +1,15 @@
 # Template file for 'ffmpeg'
 # audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
 pkgname=ffmpeg
-version=4.4.3
-revision=2
+version=6.0
+revision=1
 short_desc="Decoding, encoding and streaming software"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="https://www.ffmpeg.org"
 changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
 distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
-checksum=6c5b6c195e61534766a0b5fe16acc919170c883362612816d0a1c7f4f947006e
+checksum=57be87c22d9b49c112b6d24bc67d42508660e6b718b3db89c44e47e289137082
 
 hostmakedepends="pkg-config perl yasm"
 makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
@@ -26,12 +26,13 @@ makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-deve
  $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
  $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
  $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
- $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers Vulkan-Tools Vulkan-ValidationLayers')
+ $(vopt_if onevpl 'onevpl onevpl-devel')
  $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
 depends="ffplay>=${version}_${revision}"
 
 build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
- dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec onevpl"
 build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
 desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
 desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
@@ -39,7 +40,8 @@ desc_option_sofa="Enable support for AES SOFA"
 desc_option_webp="Enable support for WebP"
 
 case "$XBPS_TARGET_MACHINE" in
-	i686*|x86_64*) build_options_default+=" vaapi vdpau nvenc nvdec";;
+	i686*) build_options_default+=" vaapi vdpau nvenc nvdec";;
+	x86_64*) build_options_default+=" vaapi vdpau nvenc nvdec onevpl";;
 	ppc64*) build_options_default+=" vaapi vdpau";;
 	mips*) CFLAGS="-mnan=legacy";;
 esac
@@ -114,18 +116,19 @@ do_configure() {
 		$(vopt_enable x265 libx265) \
 		$(vopt_enable v4l2 libv4l2) \
 		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
-		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		--enable-libbs2b --enable-libvidstab \
 		$(vopt_enable dav1d libdav1d) \
 		$(vopt_enable zimg libzimg) \
 		$(vopt_enable webp libwebp) \
 		$(vopt_enable sofa libmysofa) \
 		$(vopt_enable vulkan) \
+		$(vopt_enable onevpl libvpl) \
 		$(vopt_enable drm libdrm) \
 		$(vopt_enable svtav1 libsvtav1) \
 		$(vopt_enable srt libsrt) \
 		$(vopt_enable rist librist) \
-		$(vopt_if nvenc '--enable-nvenc') \
-		$(vopt_if nvdec '--enable-nvdec')
+		$(vopt_enable nvenc nvenc) \
+		$(vopt_enable nvdec nvdec)
 }
 do_build() {
 	make ${makejobs}
@@ -148,10 +151,8 @@ libavdevice_package() {
 	}
 }
 libavresample_package() {
-	short_desc="FFmpeg audio resampling library"
-	pkg_install() {
-		vmove "usr/lib/libavresample.so.*"
-	}
+	short_desc="Package deprecated, removal needed"
+	build_style=meta
 }
 libavformat_package() {
 	short_desc="FFmpeg file format library"
@@ -198,9 +199,9 @@ ffmpeg-devel_package() {
 		libavfilter>=${version}_${revision}
 		libpostproc>=${version}_${revision}
 		libswscale>=${version}_${revision}
-		libswresample>=${version}_${revision}
-		libavresample>=${version}_${revision}"
+		libswresample>=${version}_${revision}"
 	short_desc+=" - development files"
+	conflicts="ffmpeg4-devel"
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig

From caec8fdc7829c01b67fc37fa84b9d7a84fc14761 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:56:22 -0400
Subject: [PATCH 002/130] New package: ffmpeg4-4.4.3.

---
 srcpkgs/ffmpeg4-devel                         |   1 +
 srcpkgs/ffmpeg4/files/altivec.patch           |  60 +++++
 .../patches/armv5tel-floating-point.patch     |  18 ++
 .../workaround-mesa-readeon-vaapi-bug.patch   |  28 +++
 srcpkgs/ffmpeg4/template                      | 214 ++++++++++++++++++
 srcpkgs/libavcodec4                           |   1 +
 srcpkgs/libavdevice4                          |   1 +
 srcpkgs/libavfilter4                          |   1 +
 srcpkgs/libavformat4                          |   1 +
 srcpkgs/libavresample4                        |   1 +
 srcpkgs/libavutil4                            |   1 +
 srcpkgs/libpostproc4                          |   1 +
 srcpkgs/libswresample4                        |   1 +
 srcpkgs/libswscale4                           |   1 +
 14 files changed, 330 insertions(+)
 create mode 120000 srcpkgs/ffmpeg4-devel
 create mode 100644 srcpkgs/ffmpeg4/files/altivec.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
 create mode 100644 srcpkgs/ffmpeg4/template
 create mode 120000 srcpkgs/libavcodec4
 create mode 120000 srcpkgs/libavdevice4
 create mode 120000 srcpkgs/libavfilter4
 create mode 120000 srcpkgs/libavformat4
 create mode 120000 srcpkgs/libavresample4
 create mode 120000 srcpkgs/libavutil4
 create mode 120000 srcpkgs/libpostproc4
 create mode 120000 srcpkgs/libswresample4
 create mode 120000 srcpkgs/libswscale4

diff --git a/srcpkgs/ffmpeg4-devel b/srcpkgs/ffmpeg4-devel
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/ffmpeg4-devel
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/ffmpeg4/files/altivec.patch b/srcpkgs/ffmpeg4/files/altivec.patch
new file mode 100644
index 000000000000..9c5720046332
--- /dev/null
+++ b/srcpkgs/ffmpeg4/files/altivec.patch
@@ -0,0 +1,60 @@
+revert some altivec specific change on all ppc* except ppc64le*
+
+q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
+conditionally, for ppc* but not ppc64le* (the new code is valid for
+POWER8 VSX which LE targets as a baseline but not BE)"
+
+
+This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
+---
+ libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
+ 1 file changed, 20 insertions(+), 4 deletions(-)
+
+diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
+index 536545293d..c1e2852adb 100644
+--- a/libswscale/ppc/yuv2rgb_altivec.c
++++ b/libswscale/ppc/yuv2rgb_altivec.c
+@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+     vector signed short R1, G1, B1;                                           \
+     vector unsigned char R, G, B;                                             \
+                                                                               \
++    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
++    vector unsigned char align_perm;                                          \
++                                                                              \
+     vector signed short lCY       = c->CY;                                    \
+     vector signed short lOY       = c->OY;                                    \
+     vector signed short lCRV      = c->CRV;                                   \
+@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
+                                                                               \
+         for (j = 0; j < w / 16; j++) {                                        \
+-            y0 = vec_xl(0, y1i);                                              \
++            y1ivP = (const vector unsigned char *) y1i;                       \
++            y2ivP = (const vector unsigned char *) y2i;                       \
++            uivP  = (const vector unsigned char *) ui;                        \
++            vivP  = (const vector unsigned char *) vi;                        \
++                                                                              \
++            align_perm = vec_lvsl(0, y1i);                                    \
++            y0 = (vector unsigned char)                                       \
++                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
+                                                                               \
+-            y1 = vec_xl(0, y2i);                                              \
++            align_perm = vec_lvsl(0, y2i);                                    \
++            y1 = (vector unsigned char)                                       \
++                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
+                                                                               \
+-            u = (vector signed char) vec_xl(0, ui);                           \
++            align_perm = vec_lvsl(0, ui);                                     \
++            u = (vector signed char)                                          \
++                    vec_perm(uivP[0], uivP[1], align_perm);                   \
+                                                                               \
+-            v = (vector signed char) vec_xl(0, vi);                           \
++            align_perm = vec_lvsl(0, vi);                                     \
++            v = (vector signed char)                                          \
++                    vec_perm(vivP[0], vivP[1], align_perm);                   \
+                                                                               \
+             u = (vector signed char)                                          \
+                     vec_sub(u,                                                \
+-- 
+2.27.0
+
diff --git a/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
new file mode 100644
index 000000000000..9a55178c74f0
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
@@ -0,0 +1,18 @@
+--- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
++++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
+@@ -39,6 +39,15 @@
+ #endif
+ #include <fenv.h>
+ 
++#if (FE_ALL_EXCEPT == 0)
++/* E.g. ARM soft float does not define these */
++#define FE_INVALID    0
++#define FE_DIVBYZERO  0
++#define FE_OVERFLOW   0
++#define FE_UNDERFLOW  0
++#define FE_INEXACT    0
++#endif
++
+ #if CONFIG_LIBFONTCONFIG
+ #include <fontconfig/fontconfig.h>
+ #endif
diff --git a/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
new file mode 100644
index 000000000000..00e3f68a415b
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
@@ -0,0 +1,28 @@
+From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
+From: Rainer Hochecker <fernetmenta@online.de>
+Date: Sat, 26 Jan 2019 19:48:35 +0100
+Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
+
+This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
+It was hit frequently when watching h264 channels received via DVB-X.
+Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
+---
+ libavcodec/vaapi_h264.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
+index 5854587a255..f12fdc457a4 100644
+--- a/libavcodec/vaapi_h264.c
++++ b/libavcodec/vaapi_h264.c
+@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
+     H264SliceContext *sl = &h->slice_ctx[0];
+     int ret;
+ 
++    if (pic->nb_slices == 0) {
++        ret = AVERROR_INVALIDDATA;
++        goto finish;
++    }
++
+     ret = ff_vaapi_decode_issue(avctx, pic);
+     if (ret < 0)
+         goto finish;
diff --git a/srcpkgs/ffmpeg4/template b/srcpkgs/ffmpeg4/template
new file mode 100644
index 000000000000..7bc64bb39f41
--- /dev/null
+++ b/srcpkgs/ffmpeg4/template
@@ -0,0 +1,214 @@
+# Template file for 'ffmpeg4'
+# audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
+pkgname=ffmpeg4
+version=4.4.3
+revision=1
+short_desc="Decoding, encoding and streaming software - ffmpeg4 libraries only"
+maintainer="Orphaned <orphan@voidlinux.org>"
+license="GPL-3.0-or-later"
+homepage="https://www.ffmpeg.org"
+changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
+distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
+checksum=6c5b6c195e61534766a0b5fe16acc919170c883362612816d0a1c7f4f947006e
+
+hostmakedepends="pkg-config perl yasm"
+makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
+ libXext-devel libXvMC-devel libxcb-devel lame-devel libtheora-devel
+ libvorbis-devel x264-devel xvidcore-devel jack-devel SDL2-devel
+ libcdio-paranoia-devel librtmp-devel libmodplug-devel gnutls-devel
+ speex-devel celt-devel harfbuzz-devel libass-devel opus-devel ocl-icd-devel
+ libbs2b-devel libvidstab-devel $(vopt_if pulseaudio pulseaudio-devel)
+ $(vopt_if vaapi libva-devel) $(vopt_if vdpau libvdpau-devel)
+ $(vopt_if x265 x265-devel) $(vopt_if v4l2 v4l-utils-devel)
+ $(vopt_if fdk_aac fdk-aac-devel) $(vopt_if vpx libvpx-devel)
+ $(vopt_if aom libaom-devel) $(vopt_if sndio sndio-devel)
+ $(vopt_if dav1d libdav1d-devel) $(vopt_if zimg zimg-devel)
+ $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
+ $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
+ $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
+
+build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
+
+desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
+desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
+desc_option_sofa="Enable support for AES SOFA"
+desc_option_webp="Enable support for WebP"
+
+case "$XBPS_TARGET_MACHINE" in
+	i686*|x86_64*) build_options_default+=" vaapi vdpau nvenc nvdec";;
+	ppc64*) build_options_default+=" vaapi vdpau";;
+	mips*) CFLAGS="-mnan=legacy";;
+esac
+
+if [ "$XBPS_TARGET_WORDSIZE" != "32" ]; then
+	build_options_default+=" svtav1"
+fi
+
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+fi
+
+_apply_patch() {
+	local args="$1" pname="$(basename $2)"
+
+	if [ ! -f ".${pname}_done" ]; then
+		patch -N $args -i $2
+		touch .${pname}_done
+	fi
+}
+
+post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64le*) ;;
+		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
+	esac
+}
+
+do_configure() {
+	# Fix gcc on x86_64-musl only
+	if [ "$XBPS_TARGET_MACHINE" = "x86_64-musl" ]; then
+		sed -i configure -e "s;_cflags_speed='-O3';_cflags_speed='-O2';"
+	fi
+
+	if [ "$CROSS_BUILD" ]; then
+		case "$XBPS_TARGET_MACHINE" in
+			arm*) _arch="arm";;
+			aarch64*) _arch="aarch64";;
+			mips*) _arch="mips";;
+			ppc64*) _arch="ppc64";;
+			ppc*) _arch="ppc";;
+			*) _arch="${XBPS_TARGET_MACHINE%%-musl}";;
+		esac
+
+		_args+=" --enable-cross-compile
+			--sysroot=$XBPS_CROSS_BASE
+			--cross-prefix=${XBPS_CROSS_TRIPLET}-
+			--target-os=linux --arch=${_arch}"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc|ppc-musl) _args+=" --disable-altivec";;
+	esac
+
+	if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+		_args+=" --extra-libs=-latomic"
+	fi
+
+	./configure --prefix=/usr --disable-debug --enable-gpl --enable-gnutls \
+		--disable-stripping \
+		--enable-libcdio --enable-version3 --enable-runtime-cpudetect \
+		--enable-libmp3lame --enable-libvorbis --enable-libxvid \
+		--enable-libx264 $(vopt_enable vpx libvpx) --enable-libtheora \
+		--enable-shared --enable-static --enable-libxcb \
+		$(vopt_enable pulseaudio libpulse) --enable-libfreetype --enable-libmodplug \
+		--enable-libspeex --enable-libcelt --enable-libass \
+		--enable-libopus --enable-librtmp --enable-libjack \
+		$(vopt_if fdk_aac '--enable-nonfree --enable-libfdk-aac') \
+		--disable-libopencore_amrnb --disable-libopencore_amrwb \
+		--disable-libopenjpeg \
+		--enable-postproc --enable-opencl ${_args} \
+		$(vopt_enable x265 libx265) \
+		$(vopt_enable v4l2 libv4l2) \
+		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
+		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		$(vopt_enable dav1d libdav1d) \
+		$(vopt_enable zimg libzimg) \
+		$(vopt_enable webp libwebp) \
+		$(vopt_enable sofa libmysofa) \
+		$(vopt_enable vulkan) \
+		$(vopt_enable drm libdrm) \
+		$(vopt_enable svtav1 libsvtav1) \
+		$(vopt_enable srt libsrt) \
+		$(vopt_enable rist librist) \
+		$(vopt_if nvenc '--enable-nvenc') \
+		$(vopt_if nvdec '--enable-nvdec')
+}
+do_build() {
+	make ${makejobs}
+	make doc/ff{mpeg,play}.1
+}
+do_install() {
+	make DESTDIR=${DESTDIR} install install-man
+	rm -rf ${DESTDIR}/usr/bin
+}
+
+libavcodec4_package() {
+	short_desc="FFmpeg codec library"
+	pkg_install() {
+		vmove "usr/lib/libavcodec.so.*"
+	}
+}
+libavdevice4_package() {
+	short_desc="FFmpeg device handling library"
+	pkg_install() {
+		vmove "usr/lib/libavdevice.so.*"
+	}
+}
+libavresample4_package() {
+	short_desc="FFmpeg audio resampling library"
+	pkg_install() {
+		vmove "usr/lib/libavresample.so.*"
+	}
+}
+libavformat4_package() {
+	short_desc="FFmpeg file format library"
+	pkg_install() {
+		vmove "usr/lib/libavformat.so.*"
+	}
+}
+libavutil4_package() {
+	short_desc="FFmpeg utility library"
+	pkg_install() {
+		vmove "usr/lib/libavutil.so.*"
+	}
+}
+libavfilter4_package() {
+	short_desc="FFmpeg audio/video filter library"
+	pkg_install() {
+		vmove "usr/lib/libavfilter.so.*"
+	}
+}
+libpostproc4_package() {
+	short_desc="FFmpeg video postprocessing library"
+	pkg_install() {
+		vmove "usr/lib/libpostproc.so.*"
+	}
+}
+libswscale4_package() {
+	short_desc="FFmpeg video scaling library"
+	pkg_install() {
+		vmove "usr/lib/libswscale.so.*"
+	}
+}
+libswresample4_package() {
+	short_desc="FFmpeg video resampling library"
+	pkg_install() {
+		vmove "usr/lib/libswresample.so.*"
+	}
+}
+ffmpeg4-devel_package() {
+	depends="
+		libavcodec4>=${version}_${revision}
+		libavdevice4>=${version}_${revision}
+		libavformat4>=${version}_${revision}
+		libavutil4>=${version}_${revision}
+		libavfilter4>=${version}_${revision}
+		libpostproc4>=${version}_${revision}
+		libswscale4>=${version}_${revision}
+		libswresample4>=${version}_${revision}
+		libavresample4>=${version}_${revision}"
+	short_desc+=" - development files"
+	conflicts="ffmpeg-devel"
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove usr/lib/*.a
+		vmove usr/lib/*.so
+		vmove usr/share/ffmpeg/examples
+		vmove usr/share/man/man3
+	}
+}
diff --git a/srcpkgs/libavcodec4 b/srcpkgs/libavcodec4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavcodec4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavdevice4 b/srcpkgs/libavdevice4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavdevice4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavfilter4 b/srcpkgs/libavfilter4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavfilter4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavformat4 b/srcpkgs/libavformat4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavformat4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavresample4 b/srcpkgs/libavresample4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavutil4 b/srcpkgs/libavutil4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavutil4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libpostproc4 b/srcpkgs/libpostproc4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libpostproc4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswresample4 b/srcpkgs/libswresample4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libswresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswscale4 b/srcpkgs/libswscale4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libswscale4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file

From a37b7dc3b9232c27eec1a6ea51f4eeb57d38793c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:04 -0400
Subject: [PATCH 003/130] opencv: update to 4.7.0.

---
 common/shlibs           | 104 ++++++++++++++++++++--------------------
 srcpkgs/opencv/template |   8 ++--
 2 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index d650f2a3045d..4626cfda810b 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2137,58 +2137,58 @@ libcapstone.so.4 capstone-4.0_1
 libhavege.so.2 libhaveged-1.9.11_1
 libnih.so.1 libnih-1.0.3_1
 libnih-dbus.so.1 libnih-1.0.3_1
-libopencv_quality.so.406 libopencv-4.6.0_1
-libopencv_reg.so.406 libopencv-4.6.0_1
-libopencv_surface_matching.so.406 libopencv-4.6.0_1
-libopencv_xphoto.so.406 libopencv-4.6.0_1
-libopencv_freetype.so.406 libopencv-4.6.0_1
-libopencv_fuzzy.so.406 libopencv-4.6.0_1
-libopencv_hfs.so.406 libopencv-4.6.0_1
-libopencv_img_hash.so.406 libopencv-4.6.0_1
-libopencv_line_descriptor.so.406 libopencv-4.6.0_1
-libopencv_saliency.so.406 libopencv-4.6.0_1
-libopencv_structured_light.so.406 libopencv-4.6.0_1
-libopencv_aruco.so.406 libopencv-4.6.0_1
-libopencv_bgsegm.so.406 libopencv-4.6.0_1
-libopencv_bioinspired.so.406 libopencv-4.6.0_1
-libopencv_ccalib.so.406 libopencv-4.6.0_1
-libopencv_face.so.406 libopencv-4.6.0_1
-libopencv_tracking.so.406 libopencv-4.6.0_1
-libopencv_xfeatures2d.so.406 libopencv-4.6.0_1
-libopencv_optflow.so.406 libopencv-4.6.0_1
-libopencv_ximgproc.so.406 libopencv-4.6.0_1
-libopencv_plot.so.406 libopencv-4.6.0_1
-libopencv_text.so.406 libopencv-4.6.0_1
-libopencv_ml.so.406 libopencv-4.6.0_1
-libopencv_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn.so.406 libopencv-4.6.0_1
-libopencv_shape.so.406 libopencv-4.6.0_1
-libopencv_stitching.so.406 libopencv-4.6.0_1
-libopencv_photo.so.406 libopencv-4.6.0_1
-libopencv_video.so.406 libopencv-4.6.0_1
-libopencv_calib3d.so.406 libopencv-4.6.0_1
-libopencv_features2d.so.406 libopencv-4.6.0_1
-libopencv_flann.so.406 libopencv-4.6.0_1
-libopencv_highgui.so.406 libopencv-4.6.0_1
-libopencv_videoio.so.406 libopencv-4.6.0_1
-libopencv_imgcodecs.so.406 libopencv-4.6.0_1
-libopencv_imgproc.so.406 libopencv-4.6.0_1
-libopencv_core.so.406 libopencv-4.6.0_1
-libopencv_superres.so.406 libopencv-4.6.0_1
-libopencv_videostab.so.406 libopencv-4.6.0_1
-libopencv_gapi.so.406 libopencv-4.6.0_1
-libopencv_xobjdetect.so.406 libopencv-4.6.0_1
-libopencv_datasets.so.406 libopencv-4.6.0_1
-libopencv_dnn_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn_superres.so.406 libopencv-4.6.0_1
-libopencv_dpm.so.406 libopencv-4.6.0_1
-libopencv_phase_unwrapping.so.406 libopencv-4.6.0_1
-libopencv_stereo.so.406 libopencv-4.6.0_1
-libopencv_rapid.so.406 libopencv-4.6.0_1
-libopencv_intensity_transform.so.406 libopencv-4.6.0_1
-libopencv_alphamat.so.406 libopencv-4.6.0_1
-libopencv_barcode.so.406 libopencv-4.6.0_1
-libopencv_mcc.so.406 libopencv-4.6.0_1
+libopencv_quality.so.407 libopencv-4.7.0_1
+libopencv_reg.so.407 libopencv-4.7.0_1
+libopencv_surface_matching.so.407 libopencv-4.7.0_1
+libopencv_xphoto.so.407 libopencv-4.7.0_1
+libopencv_freetype.so.407 libopencv-4.7.0_1
+libopencv_fuzzy.so.407 libopencv-4.7.0_1
+libopencv_hfs.so.407 libopencv-4.7.0_1
+libopencv_img_hash.so.407 libopencv-4.7.0_1
+libopencv_line_descriptor.so.407 libopencv-4.7.0_1
+libopencv_saliency.so.407 libopencv-4.7.0_1
+libopencv_structured_light.so.407 libopencv-4.7.0_1
+libopencv_aruco.so.407 libopencv-4.7.0_1
+libopencv_bgsegm.so.407 libopencv-4.7.0_1
+libopencv_bioinspired.so.407 libopencv-4.7.0_1
+libopencv_ccalib.so.407 libopencv-4.7.0_1
+libopencv_face.so.407 libopencv-4.7.0_1
+libopencv_tracking.so.407 libopencv-4.7.0_1
+libopencv_xfeatures2d.so.407 libopencv-4.7.0_1
+libopencv_optflow.so.407 libopencv-4.7.0_1
+libopencv_ximgproc.so.407 libopencv-4.7.0_1
+libopencv_plot.so.407 libopencv-4.7.0_1
+libopencv_text.so.407 libopencv-4.7.0_1
+libopencv_ml.so.407 libopencv-4.7.0_1
+libopencv_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn.so.407 libopencv-4.7.0_1
+libopencv_shape.so.407 libopencv-4.7.0_1
+libopencv_stitching.so.407 libopencv-4.7.0_1
+libopencv_photo.so.407 libopencv-4.7.0_1
+libopencv_video.so.407 libopencv-4.7.0_1
+libopencv_calib3d.so.407 libopencv-4.7.0_1
+libopencv_features2d.so.407 libopencv-4.7.0_1
+libopencv_flann.so.407 libopencv-4.7.0_1
+libopencv_highgui.so.407 libopencv-4.7.0_1
+libopencv_videoio.so.407 libopencv-4.7.0_1
+libopencv_imgcodecs.so.407 libopencv-4.7.0_1
+libopencv_imgproc.so.407 libopencv-4.7.0_1
+libopencv_core.so.407 libopencv-4.7.0_1
+libopencv_superres.so.407 libopencv-4.7.0_1
+libopencv_videostab.so.407 libopencv-4.7.0_1
+libopencv_gapi.so.407 libopencv-4.7.0_1
+libopencv_xobjdetect.so.407 libopencv-4.7.0_1
+libopencv_datasets.so.407 libopencv-4.7.0_1
+libopencv_dnn_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn_superres.so.407 libopencv-4.7.0_1
+libopencv_dpm.so.407 libopencv-4.7.0_1
+libopencv_phase_unwrapping.so.407 libopencv-4.7.0_1
+libopencv_stereo.so.407 libopencv-4.7.0_1
+libopencv_rapid.so.407 libopencv-4.7.0_1
+libopencv_intensity_transform.so.407 libopencv-4.7.0_1
+libopencv_alphamat.so.407 libopencv-4.7.0_1
+libopencv_barcode.so.407 libopencv-4.7.0_1
+libopencv_mcc.so.407 libopencv-4.7.0_1
 libuniconf.so.4.6 wvstreams-4.6.1_20
 libwvbase.so.4.6 wvstreams-4.6.1_20
 libwvutils.so.4.6 wvstreams-4.6.1_20
diff --git a/srcpkgs/opencv/template b/srcpkgs/opencv/template
index 69c635b1ad2b..41f3183f1582 100644
--- a/srcpkgs/opencv/template
+++ b/srcpkgs/opencv/template
@@ -1,7 +1,7 @@
 # Template file for 'opencv'
 pkgname=opencv
-version=4.6.0
-revision=4
+version=4.7.0
+revision=1
 create_wrksrc=yes
 build_wrksrc=${pkgname}-${version}
 build_style=cmake
@@ -24,8 +24,8 @@ homepage="https://opencv.org"
 changelog="https://github.com/opencv/opencv/wiki/ChangeLog"
 distfiles="https://github.com/opencv/opencv/archive/${version}.tar.gz
  https://github.com/opencv/opencv_contrib/archive/${version}.tar.gz>contrib.tar.gz"
-checksum="1ec1cba65f9f20fe5a41fda1586e01c70ea0c9a6d7b67c9e13edf0cfe2239277
- 1777d5fd2b59029cf537e5fd6f8aa68d707075822f90bde683fcde086f85f7a7"
+checksum="8df0079cdbe179748a18d44731af62a245a45ebf5085223dc03133954c662973
+ 42df840cf9055e59d0e22c249cfb19f04743e1bdad113d31b1573d3934d62584"
 patch_args="-Np1 -d ${build_wrksrc}"
 # tests hang indenfinitely, even with test data included
 make_check=no

From a5e4379112147403f438aa80abd927ef981d6622 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 004/130] actiona: revbump for opencv-4.7.0

---
 srcpkgs/actiona/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/actiona/template b/srcpkgs/actiona/template
index cf5f0b7a2ae6..0d899311e6df 100644
--- a/srcpkgs/actiona/template
+++ b/srcpkgs/actiona/template
@@ -1,7 +1,7 @@
 # Template file for 'actiona'
 pkgname=actiona
 version=3.10.1
-revision=2
+revision=3
 build_style=qmake
 configure_args="PKGCONFIG_OPENCV=opencv4"
 hostmakedepends="pkg-config qt5-plugin-mysql qt5-qmake qt5-host-tools"

From 05bfd896fff01a798a900405963c7b3d715aad3f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 005/130] gmic: revbump for opencv-4.7.0

---
 srcpkgs/gmic/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gmic/template b/srcpkgs/gmic/template
index 24a9c7218fdf..0bb4034d5cc8 100644
--- a/srcpkgs/gmic/template
+++ b/srcpkgs/gmic/template
@@ -1,7 +1,7 @@
 # Template file for 'gmic'
 pkgname=gmic
 version=3.1.6
-revision=3
+revision=4
 _zart_hash=34ebf6cce0bafb98abe57cec83c4a02cd1abeca0
 create_wrksrc=yes
 build_wrksrc="src"

From d62b8494305bd86f25fd3bb637aab62c58d7077d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 006/130] qimgv: revbump for opencv-4.7.0

---
 srcpkgs/qimgv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qimgv/template b/srcpkgs/qimgv/template
index 7eb30db33992..dd341dfe1bfc 100644
--- a/srcpkgs/qimgv/template
+++ b/srcpkgs/qimgv/template
@@ -1,7 +1,7 @@
 # Template file for 'qimgv'
 pkgname=qimgv
 version=1.0.2
-revision=2
+revision=3
 build_style=cmake
 configure_args="$(vopt_if video -DVIDEO_SUPPORT=ON -DVIDEO_SUPPORT=OFF)
  $(vopt_if scale -DOPENCV_SUPPORT=ON -DOPENCV_SUPPORT=OFF)

From 137e1c39f6e9311d5484ac6a2862e7a7d306ec5b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 007/130] retroshare: revbump for opencv-4.7.0

---
 srcpkgs/retroshare/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroshare/template b/srcpkgs/retroshare/template
index 8a0786c21a08..72023fa98b75 100644
--- a/srcpkgs/retroshare/template
+++ b/srcpkgs/retroshare/template
@@ -1,7 +1,7 @@
 # Template file for 'retroshare'
 pkgname=retroshare
 version=0.6.6
-revision=2
+revision=4
 build_style=qmake
 #XXX broadcast feature requires an ancient udp-discovery-cpp which either needs
 # to be fetched+patched (FTBFS) here or packaged :/

From c6c67ed88de0e31a68b4641d938e6e1b4622c14d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 008/130] siril: revbump for opencv-4.7.0

---
 srcpkgs/siril/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/siril/template b/srcpkgs/siril/template
index e88f30fb6178..84332f79d060 100644
--- a/srcpkgs/siril/template
+++ b/srcpkgs/siril/template
@@ -1,7 +1,7 @@
 # Template file for 'siril'
 pkgname=siril
 version=0.9.12
-revision=9
+revision=10
 build_style=gnu-configure
 hostmakedepends="pkg-config intltool autoconf automake gettext-devel"
 makedepends="fftw-devel libconfig-devel libopencv-devel libffms2-devel

From a466efdc189d9cf3c2808a23e4ea227fa0e2779c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 009/130] waifu2x-converter-cpp: revbump for opencv-4.7.0

---
 srcpkgs/waifu2x-converter-cpp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waifu2x-converter-cpp/template b/srcpkgs/waifu2x-converter-cpp/template
index 8c095d0d7bab..aa52d8c981a8 100644
--- a/srcpkgs/waifu2x-converter-cpp/template
+++ b/srcpkgs/waifu2x-converter-cpp/template
@@ -1,7 +1,7 @@
 # Template file for 'waifu2x-converter-cpp'
 pkgname=waifu2x-converter-cpp
 version=5.2.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DINSTALL_MODELS=ON"
 hostmakedepends="pkg-config"

From cce1f5df16330e2aa15321c5a09a318f9837f102 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:38 -0400
Subject: [PATCH 010/130] vlc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/vlc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/vlc/template b/srcpkgs/vlc/template
index 210762b0a7e2..855ca5238662 100644
--- a/srcpkgs/vlc/template
+++ b/srcpkgs/vlc/template
@@ -1,7 +1,7 @@
 # Template file for 'vlc'
 pkgname=vlc
 version=3.0.18
-revision=3
+revision=4
 build_style=gnu-configure
 configure_args="--disable-gme --disable-libtar --enable-jack
  --enable-live555 --disable-fluidsynth --enable-dvdread
@@ -25,7 +25,7 @@ lib32disabled=yes
 hostmakedepends="automake libtool pkg-config flex gettext libgcrypt-devel
  live555-devel gettext-devel $(vopt_if lua lua52) $(vopt_if chromecast protobuf)"
 makedepends="
- avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg-devel freefont-ttf
+ avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg4-devel freefont-ttf
  gnutls-devel jack-devel liba52-devel libass-devel libbluray-devel
  libcdio-devel libdca-devel libdvbpsi-devel libdvdnav-devel libmad-devel
  libmatroska-devel libmodplug-devel libmpcdec-devel libmpeg2-devel

From e2766771b4ed2de122cd5c9c1a0b60d0a76c14e4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:55 -0400
Subject: [PATCH 011/130] osg: revbump for ffmpeg4-4.4.3

---
 srcpkgs/osg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/osg/template b/srcpkgs/osg/template
index a9ebbd287933..755793f7e11b 100644
--- a/srcpkgs/osg/template
+++ b/srcpkgs/osg/template
@@ -8,7 +8,7 @@ build_helper="qemu"
 configure_args="-DLIB_POSTFIX="
 hostmakedepends="pkg-config xrandr"
 makedepends="MesaLib-devel gtkglext-devel libcurl-devel giflib-devel librsvg-devel
- jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg-devel xine-lib-devel
+ jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg4-devel xine-lib-devel
  SDL2-devel gst-plugins-base1-devel
  $(vopt_if openexr libopenexr-devel)
  $(vopt_if poppler poppler-glib-devel)

From 29df97a8351c4cdfab145c8bb6c69988666472ca Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:13 -0400
Subject: [PATCH 012/130] xine-lib: revbump for ffmpeg4-4.4.3

---
 srcpkgs/xine-lib/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/xine-lib/template b/srcpkgs/xine-lib/template
index f713eff49b07..ed6194c17d11 100644
--- a/srcpkgs/xine-lib/template
+++ b/srcpkgs/xine-lib/template
@@ -1,6 +1,6 @@
 # Template file for 'xine-lib'
 pkgname=xine-lib
-version=1.2.12
+version=1.2.13
 revision=1
 build_style=gnu-configure
 configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
@@ -8,7 +8,7 @@ configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
 hostmakedepends="automake gettext-devel libtool pkg-config perl"
 makedepends="
  zlib-devel alsa-lib-devel libxcb-devel libSM-devel libXext-devel libXv-devel
- libXvMC-devel liba52-devel libmad-devel ffmpeg-devel pulseaudio-devel
+ libXvMC-devel liba52-devel libmad-devel ffmpeg4-devel pulseaudio-devel
  jack-devel samba-devel libflac-devel libmodplug-devel libmpcdec-devel
  speex-devel libtheora-devel libvorbis-devel libdca-devel faad2-devel
  libcdio-devel libbluray-devel aalib-devel libcaca-devel libXinerama-devel
@@ -19,7 +19,7 @@ license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="http://www.xine-project.org"
 changelog="https://sourceforge.net/projects/xine/files/xine-lib/${version}/README.txt/view"
 distfiles="${SOURCEFORGE_SITE}/xine/${pkgname}-${version}.tar.xz"
-checksum=d606270468e1540c2a89c0d7f5fdf11e17ecc0c2698cc0bcb1065ff26abee098
+checksum=5f10d6d718a4a51c17ed1b32b031d4f9b80b061e8276535b2be31e5ac4b75e6f
 
 case "$XBPS_TARGET_MACHINE" in
 	i686-musl)

From 19ba661d425f89507e21f1f51a3457017a466dad Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 013/130] QMPlay2: revbump for ffmpeg-6.0

---
 srcpkgs/QMPlay2/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/QMPlay2/template b/srcpkgs/QMPlay2/template
index ad73cbb01bae..55284c051161 100644
--- a/srcpkgs/QMPlay2/template
+++ b/srcpkgs/QMPlay2/template
@@ -1,7 +1,7 @@
 # Template file for 'QMPlay2'
 pkgname=QMPlay2
 version=23.02.05
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools"
 makedepends="alsa-lib-devel ffmpeg-devel libass-devel libcdio-devel libgme-devel

From a036167ecaf89a5beee24f7c6497d0b266397a2e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 014/130] alsa-plugins: revbump for ffmpeg-6.0

---
 srcpkgs/alsa-plugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/alsa-plugins/template b/srcpkgs/alsa-plugins/template
index 0bfa6d9fd264..a5708a7d82a8 100644
--- a/srcpkgs/alsa-plugins/template
+++ b/srcpkgs/alsa-plugins/template
@@ -1,7 +1,7 @@
 # Template file for 'alsa-plugins'
 pkgname=alsa-plugins
 version=1.2.7.1
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--disable-maemo-plugin"
 hostmakedepends="pkg-config"

From 71313b3619befcb430917e14d4be820cb6219a4c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 015/130] arcan: revbump for ffmpeg-6.0

---
 srcpkgs/arcan/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/arcan/template b/srcpkgs/arcan/template
index 7be9652eccf3..ccc7df11ceac 100644
--- a/srcpkgs/arcan/template
+++ b/srcpkgs/arcan/template
@@ -2,7 +2,7 @@
 # !! keep synced with: acfgfs aclip aloadimage
 pkgname=arcan
 version=0.6.2.1
-revision=1
+revision=2
 create_wrksrc=yes
 build_wrksrc=arcan/src
 build_style=cmake

From edfdcc4efccb5f8152479ff34033e60d3f72fb88 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 016/130] attract: revbump for ffmpeg4-4.4.3

---
 srcpkgs/attract/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/attract/template b/srcpkgs/attract/template
index 26144e931a3c..e760bf0d18ae 100644
--- a/srcpkgs/attract/template
+++ b/srcpkgs/attract/template
@@ -1,12 +1,12 @@
 # Template file for 'attract'
 pkgname=attract
 version=2.6.2
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="VERBOSE=1"
 make_use_env=yes
 hostmakedepends="pkg-config"
-makedepends="SFML-devel ffmpeg-devel fontconfig-devel glu-devel libarchive-devel
+makedepends="SFML-devel ffmpeg4-devel fontconfig-devel glu-devel libarchive-devel
  libcurl-devel libjpeg-turbo-devel xine-lib rapidjson libXrandr-devel"
 depends="git"
 short_desc="Attract-Mode is a graphical frontend for emulators"

From 725d65813cb50a7906166422dbd529480e42b699 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 017/130] aubio: revbump for ffmpeg-6.0

---
 srcpkgs/aubio/patches/ffmpeg5.patch | 25 +++++++++++++++++++++++++
 srcpkgs/aubio/template              |  2 +-
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/aubio/patches/ffmpeg5.patch

diff --git a/srcpkgs/aubio/patches/ffmpeg5.patch b/srcpkgs/aubio/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..aace41a6e6d9
--- /dev/null
+++ b/srcpkgs/aubio/patches/ffmpeg5.patch
@@ -0,0 +1,25 @@
+From 8a05420e5dd8c7b8b2447f82dc919765876511b3 Mon Sep 17 00:00:00 2001
+From: Paul Brossier <piem@piem.org>
+Date: Tue, 25 Jan 2022 18:30:27 +0100
+Subject: [PATCH] [source_avcodec] define FF_API_LAVF_AVCTX for libavcodec >
+ 59, thx @berolinux (closes gh-353)
+
+---
+ src/io/source_avcodec.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/io/source_avcodec.c b/src/io/source_avcodec.c
+index e0ae93b5..1421bd9a 100644
+--- a/src/io/source_avcodec.c
++++ b/src/io/source_avcodec.c
+@@ -68,6 +68,10 @@
+ #define AUBIO_AVCODEC_MAX_BUFFER_SIZE AV_INPUT_BUFFER_MIN_SIZE
+ #endif
+ 
++#if LIBAVCODEC_VERSION_MAJOR >= 59
++#define FF_API_LAVF_AVCTX 1
++#endif
++
+ struct _aubio_source_avcodec_t {
+   uint_t hop_size;
+   uint_t samplerate;
diff --git a/srcpkgs/aubio/template b/srcpkgs/aubio/template
index ad1c4b256991..7d875cc02541 100644
--- a/srcpkgs/aubio/template
+++ b/srcpkgs/aubio/template
@@ -1,7 +1,7 @@
 # Template file for 'aubio'
 pkgname=aubio
 version=0.4.9
-revision=1
+revision=2
 build_style=waf3
 # XXX lash, pure and swig support.
 hostmakedepends="pkg-config txt2man"

From cbef04e99d5e823be93500c2d87d96dac3a64d83 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 018/130] audacious-plugins: revbump for ffmpeg-6.0

---
 .../audacious-plugins/patches/ffmpeg5.patch   | 43 +++++++++++++++++++
 srcpkgs/audacious-plugins/template            |  2 +-
 2 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/audacious-plugins/patches/ffmpeg5.patch

diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg5.patch b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..4e5e34099d71
--- /dev/null
+++ b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
@@ -0,0 +1,43 @@
+commit 298aa371c56c2f52c25a33d9bdec4918b11cebdc
+Author: tibequadorian <tibequadorian@posteo.de>
+Date:   Sat Mar 19 18:40:12 2022 +0100
+
+    audacious-plugins: rebuild against ffmpeg-5.0
+
+diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+new file mode 100644
+index 0000000000..617c11215b
+--- /dev/null
++++ b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+@@ -0,0 +1,31 @@
++From f60beb400eeb1e4778bbfd738bc4a4ccef3de539 Mon Sep 17 00:00:00 2001
++From: John Lindgren <john@jlindgren.net>
++Date: Sat, 5 Mar 2022 12:05:34 -0500
++Subject: [PATCH] Fix build with FFmpeg 5.0
++
++---
++ src/ffaudio/ffaudio-core.cc | 4 ++--
++ 1 file changed, 2 insertions(+), 2 deletions(-)
++
++diff --git a/src/ffaudio/ffaudio-core.cc b/src/ffaudio/ffaudio-core.cc
++index 16dc63e3a..a2b95fd6c 100644
++--- a/src/ffaudio/ffaudio-core.cc
+++++ b/src/ffaudio/ffaudio-core.cc
++@@ -274,7 +274,7 @@ static AVInputFormat * get_format_by_content (const char * name, VFSFile & file)
++         AVProbeData d = {name, buf, filled};
++         score = target;
++ 
++-        f = av_probe_input_format2 (& d, true, & score);
+++        f = (AVInputFormat *) av_probe_input_format2 (& d, true, & score);
++         if (f)
++             break;
++ 
++@@ -347,7 +347,7 @@ static bool find_codec (AVFormatContext * c, CodecInfo * cinfo)
++ #endif
++         if (stream && stream->codecpar && stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
++         {
++-            AVCodec * codec = avcodec_find_decoder (stream->codecpar->codec_id);
+++            AVCodec * codec = (AVCodec *) avcodec_find_decoder (stream->codecpar->codec_id);
++ 
++             if (codec)
++             {
diff --git a/srcpkgs/audacious-plugins/template b/srcpkgs/audacious-plugins/template
index 88cbc1671fc6..beebfae59ed4 100644
--- a/srcpkgs/audacious-plugins/template
+++ b/srcpkgs/audacious-plugins/template
@@ -2,7 +2,7 @@
 #Keep in sync with audacious!
 pkgname=audacious-plugins
 version=4.3.1
-revision=1
+revision=2
 build_style=meson
 configure_args="$(vopt_bool gtk3 gtk) $(vopt_bool gtk3)
  $(vopt_bool qt) $(vopt_bool qt qt6)"

From 61fc7ecac20a36de2c43bddee7f2a9f61c6f30c2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 019/130] audacity: revbump for ffmpeg4-4.4.3

---
 srcpkgs/audacity/template | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/audacity/template b/srcpkgs/audacity/template
index d509c0a89407..11e20255685b 100644
--- a/srcpkgs/audacity/template
+++ b/srcpkgs/audacity/template
@@ -1,7 +1,7 @@
 # Template file for 'audacity'
 pkgname=audacity
 version=2.4.1
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--with-ffmpeg=system --with-libsndfile=system --with-expat=system
  --with-libsoxr=system --with-lame=system --with-lv2=system ac_cv_path_WX_CONFIG=wx-config-gtk3"
@@ -9,7 +9,7 @@ hostmakedepends="pkg-config cmake gettext libtool m4 which"
 makedepends="jack-devel wxWidgets-gtk3-devel gtk+3-devel
  libmad-devel soundtouch-devel libsoxr-devel
  vamp-plugin-sdk-devel lame-devel libid3tag-devel libflac-devel
- ffmpeg-devel twolame-devel serd-devel lv2 lilv-devel suil-devel"
+ ffmpeg4-devel twolame-devel serd-devel lv2 lilv-devel suil-devel"
 depends="desktop-file-utils hicolor-icon-theme"
 short_desc="Graphical cross-platform audio editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
@@ -33,5 +33,4 @@ post_install() {
 	vcopy plug-ins /usr/share/audacity
 
 	rm ${DESTDIR}/usr/share/doc/audacity/LICENSE.txt
-	vlicense LICENSE.txt LICENSE
 }

From 296fd03bcbf8752a17ecf531c97a24c235274c9a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 020/130] avidemux: revbump for ffmpeg-6.0

---
 srcpkgs/avidemux/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/avidemux/template b/srcpkgs/avidemux/template
index 253a0243e225..557285982d2b 100644
--- a/srcpkgs/avidemux/template
+++ b/srcpkgs/avidemux/template
@@ -1,7 +1,7 @@
 # Template file for 'avidemux'
 pkgname=avidemux
 version=2.8.0
-revision=2
+revision=3
 # Can't be compiled for aarch64, arm* or mips*
 archs="x86_64* i686*"
 hostmakedepends="cmake pkg-config qt5-host-tools qt5-devel tar yasm"

From 73dcf788fb8b320e948fb3d71fd93cb0be5385ff Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 021/130] baresip: revbump for ffmpeg-6.0

---
 srcpkgs/baresip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/baresip/template b/srcpkgs/baresip/template
index f1bd1817048b..b21e22334316 100644
--- a/srcpkgs/baresip/template
+++ b/srcpkgs/baresip/template
@@ -1,7 +1,7 @@
 # Template file for 'baresip'
 pkgname=baresip
 version=2.10.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config glib-devel"
 makedepends="libgsm-devel libpng-devel openssl-devel libsndfile-devel

From 7905b028d86519937d46df8bd45ca577f56a7651 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 022/130] blender: revbump for ffmpeg-6.0

---
 .../patches/ffmpeg6-compat-blender.patch      | 42 +++++++++++++++++++
 srcpkgs/blender/template                      |  2 +-
 2 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/blender/patches/ffmpeg6-compat-blender.patch

diff --git a/srcpkgs/blender/patches/ffmpeg6-compat-blender.patch b/srcpkgs/blender/patches/ffmpeg6-compat-blender.patch
new file mode 100644
index 000000000000..d51a9c7710cc
--- /dev/null
+++ b/srcpkgs/blender/patches/ffmpeg6-compat-blender.patch
@@ -0,0 +1,42 @@
+--- a/source/blender/blenkernel/intern/writeffmpeg.c	2022-11-08 13:50:16 UTC
++++ b/source/blender/blenkernel/intern/writeffmpeg.c
+@@ -855,7 +855,7 @@ static AVStream *alloc_video_stream(FFMpegContext *con
+                                                             255);
+   st->avg_frame_rate = av_inv_q(c->time_base);
+ 
+-  if (codec->capabilities & AV_CODEC_CAP_AUTO_THREADS) {
++  if (codec->capabilities & AV_CODEC_CAP_OTHER_THREADS) {
+     c->thread_count = 0;
+   }
+   else {
+--- a/source/blender/imbuf/intern/anim_movie.c	2022-11-04 00:33:07 UTC
++++ b/source/blender/imbuf/intern/anim_movie.c
+@@ -554,7 +554,7 @@ static int startffmpeg(struct anim *anim)
+   avcodec_parameters_to_context(pCodecCtx, video_stream->codecpar);
+   pCodecCtx->workaround_bugs = FF_BUG_AUTODETECT;
+ 
+-  if (pCodec->capabilities & AV_CODEC_CAP_AUTO_THREADS) {
++  if (pCodec->capabilities & AV_CODEC_CAP_OTHER_THREADS) {
+     pCodecCtx->thread_count = 0;
+   }
+   else {
+--- a/source/blender/imbuf/intern/indexer.c	2022-11-04 00:33:07 UTC
++++ b/source/blender/imbuf/intern/indexer.c
+@@ -559,7 +559,7 @@ static struct proxy_output_ctx *alloc_proxy_output_ffm
+   av_dict_set(&codec_opts, "preset", "veryfast", 0);
+   av_dict_set(&codec_opts, "tune", "fastdecode", 0);
+ 
+-  if (rv->codec->capabilities & AV_CODEC_CAP_AUTO_THREADS) {
++  if (rv->codec->capabilities & AV_CODEC_CAP_OTHER_THREADS) {
+     rv->c->thread_count = 0;
+   }
+   else {
+@@ -872,7 +872,7 @@ static IndexBuildContext *index_ffmpeg_create_context(
+   avcodec_parameters_to_context(context->iCodecCtx, context->iStream->codecpar);
+   context->iCodecCtx->workaround_bugs = FF_BUG_AUTODETECT;
+ 
+-  if (context->iCodec->capabilities & AV_CODEC_CAP_AUTO_THREADS) {
++  if (context->iCodec->capabilities & AV_CODEC_CAP_OTHER_THREADS) {
+     context->iCodecCtx->thread_count = 0;
+   }
+   else {
diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index 61b42eb2e51e..d18bc88838ff 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -1,7 +1,7 @@
 # Template file for 'blender'
 pkgname=blender
 version=3.4.1
-revision=3
+revision=4
 archs="x86_64* ppc64*"
 build_style="cmake"
 pycompile_dirs="/usr/share/blender/${version%.*}/scripts"

From a14bbcbc848ff877c99294bfbd66f0b6bcdc3a88 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 023/130] cantata: revbump for ffmpeg-6.0

---
 srcpkgs/cantata/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cantata/template b/srcpkgs/cantata/template
index 4b417d80d5c2..8a90aaa4c07a 100644
--- a/srcpkgs/cantata/template
+++ b/srcpkgs/cantata/template
@@ -1,7 +1,7 @@
 # Template file for 'cantata'
 pkgname=cantata
 version=2.5.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools qt5-tools"
 makedepends="qt5-devel qt5-tools-devel qt5-svg-devel qt5-xmlpatterns-devel

From f8dc3f795958bb41f5c7ccdbefde6eb7c9758a89 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 024/130] ccextractor: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ccextractor/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/ccextractor/template b/srcpkgs/ccextractor/template
index 9abcd82852b2..6eccad5885af 100644
--- a/srcpkgs/ccextractor/template
+++ b/srcpkgs/ccextractor/template
@@ -1,12 +1,12 @@
 # Template file for 'ccextractor'
 pkgname=ccextractor
 version=0.93
-revision=1
+revision=2
 build_wrksrc="linux"
 build_style=gnu-configure
 configure_args="--enable-ocr --enable-hardsubx"
 hostmakedepends="automake pkg-config"
-makedepends="leptonica-devel tesseract-ocr-devel ffmpeg-devel"
+makedepends="leptonica-devel tesseract-ocr-devel ffmpeg4-devel"
 short_desc="Extract subtitles from video streams"
 maintainer="newbluemoon <blaumolch@mailbox.org>"
 license="GPL-2.0-or-later"

From 75fd1ea953931e5e7f50d6cb6a2caac1578d6c90 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 025/130] chromaprint: revbump for ffmpeg-6.0

---
 srcpkgs/chromaprint/patches/ffmpeg5.patch | 569 ++++++++++++++++++++++
 srcpkgs/chromaprint/template              |   2 +-
 2 files changed, 570 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromaprint/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromaprint/patches/ffmpeg5.patch b/srcpkgs/chromaprint/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..a9fd307a23c8
--- /dev/null
+++ b/srcpkgs/chromaprint/patches/ffmpeg5.patch
@@ -0,0 +1,569 @@
+From 8ccad6937177b1b92e40ab8f4447ea27bac009a7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= <lalinsky@gmail.com>
+Date: Fri, 4 Nov 2022 21:47:38 +0100
+Subject: [PATCH] Use FFmpeg 5.x (#120)
+
+* Use FFmpeg 5.1.2 for CI builds
+
+* Build on Ubuntu 20.04
+
+* Upgrade code to FFmpeg 5.x APIs
+
+* Only set FFmpeg include dirs if building tools
+
+* No longer needed
+
+* Use ubuntu 20.04
+---
+ .github/workflows/build.yml                   |   6 +-
+ CMakeLists.txt                                |  16 --
+ package/build.sh                              |   4 +-
+ src/audio/ffmpeg_audio_processor.h            |   2 -
+ src/audio/ffmpeg_audio_processor_avresample.h |  72 -------
+ src/audio/ffmpeg_audio_processor_swresample.h |  18 +-
+ src/audio/ffmpeg_audio_reader.h               | 197 +++++++++---------
+ tests/CMakeLists.txt                          |   6 +
+ 8 files changed, 122 insertions(+), 199 deletions(-)
+ delete mode 100644 src/audio/ffmpeg_audio_processor_avresample.h
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index f8d6a32..4da2405 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -84,9 +84,6 @@ find_package(FFmpeg)
+ if(FFMPEG_LIBRARIES)
+ 	cmake_push_check_state(RESET)
+ 	set(CMAKE_REQUIRED_LIBRARIES ${FFMPEG_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -lm)
+-	check_function_exists(av_packet_unref HAVE_AV_PACKET_UNREF)
+-	check_function_exists(av_frame_alloc HAVE_AV_FRAME_ALLOC)
+-	check_function_exists(av_frame_free HAVE_AV_FRAME_FREE)
+ 	cmake_pop_check_state()
+ endif()
+
+@@ -163,14 +160,11 @@ message(STATUS "Using ${FFT_LIB} for FFT calculations")
+ if(NOT AUDIO_PROCESSOR_LIB)
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+ 		set(AUDIO_PROCESSOR_LIB "swresample")
+-	elseif(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(AUDIO_PROCESSOR_LIB "avresample")
+ 	endif()
+ endif()
+
+ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE OFF)
+ 		set(USE_SWRESAMPLE ON)
+ 		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBSWRESAMPLE_LIBRARIES})
+ 		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBSWRESAMPLE_INCLUDE_DIRS})
+@@ -178,16 +172,6 @@ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+ 	endif()
+ 	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+-elseif(AUDIO_PROCESSOR_LIB STREQUAL "avresample")
+-	if(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE ON)
+-		set(USE_SWRESAMPLE OFF)
+-		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBAVRESAMPLE_LIBRARIES})
+-		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBAVRESAMPLE_INCLUDE_DIRS})
+-	else()
+-		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+-	endif()
+-	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+ else()
+ 	message(STATUS "Building without audio conversion support, please install FFmpeg with libswresample")
+ endif()
+diff --git a/package/build.sh b/package/build.sh
+index da631ae..b41d36e 100755
+--- a/package/build.sh
++++ b/package/build.sh
+@@ -7,8 +7,8 @@ set -eux
+
+ BASE_DIR=$(cd $(dirname $0)/.. && pwd)
+
+-FFMPEG_VERSION=4.4.1
+-FFMPEG_BUILD_TAG=v4.4.1-1
++FFMPEG_VERSION=5.1.2
++FFMPEG_BUILD_TAG=v${FFMPEG_VERSION}-1
+
+ TMP_BUILD_DIR=$BASE_DIR/$(mktemp -d build.XXXXXXXX)
+ trap 'rm -rf $TMP_BUILD_DIR' EXIT
+diff --git a/src/audio/ffmpeg_audio_processor.h b/src/audio/ffmpeg_audio_processor.h
+index 7628fc7..39f4f6d 100644
+--- a/src/audio/ffmpeg_audio_processor.h
++++ b/src/audio/ffmpeg_audio_processor.h
+@@ -10,8 +10,6 @@
+
+ #if defined(USE_SWRESAMPLE)
+ #include "audio/ffmpeg_audio_processor_swresample.h"
+-#elif defined(USE_AVRESAMPLE)
+-#include "audio/ffmpeg_audio_processor_avresample.h"
+ #else
+ #error "no audio processing library"
+ #endif
+diff --git a/src/audio/ffmpeg_audio_processor_avresample.h b/src/audio/ffmpeg_audio_processor_avresample.h
+deleted file mode 100644
+index bd85f92..0000000
+--- a/src/audio/ffmpeg_audio_processor_avresample.h
++++ /dev/null
+@@ -1,72 +0,0 @@
+-// Copyright (C) 2016  Lukas Lalinsky
+-// Distributed under the MIT license, see the LICENSE file for details.
+-
+-#ifndef CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-#define CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-
+-extern "C" {
+-#include <libavresample/avresample.h>
+-}
+-
+-namespace chromaprint {
+-
+-class FFmpegAudioProcessor {
+-public:
+-	FFmpegAudioProcessor() {
+-		m_resample_ctx = avresample_alloc_context();
+-	}
+-
+-	~FFmpegAudioProcessor() {
+-		avresample_free(&m_resample_ctx);
+-	}
+-
+-	void SetCompatibleMode() {
+-		av_opt_set_int(m_resample_ctx, "filter_size", 16, 0);
+-		av_opt_set_int(m_resample_ctx, "phase_shift", 8, 0);
+-		av_opt_set_int(m_resample_ctx, "linear_interp", 1, 0);
+-		av_opt_set_double(m_resample_ctx, "cutoff", 0.8, 0);
+-	}
+-
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "in_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_rate", sample_rate, 0);
+-	}
+-
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "out_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_rate, 0);
+-	}
+-
+-	int Init() {
+-		return avresample_open(m_resample_ctx);
+-	}
+-
+-	int Convert(uint8_t **out, int out_count, const uint8_t **in, int in_count) {
+-		return avresample_convert(m_resample_ctx, out, 0, out_count, (uint8_t **) in, 0, in_count);
+-	}
+-
+-	int Flush(uint8_t **out, int out_count) {
+-		return avresample_read(m_resample_ctx, out, out_count);
+-	}
+-
+-private:
+-	AVAudioResampleContext *m_resample_ctx = nullptr;
+-};
+-
+-}; // namespace chromaprint
+-
+-#endif
+diff --git a/src/audio/ffmpeg_audio_processor_swresample.h b/src/audio/ffmpeg_audio_processor_swresample.h
+index b86266b..b1d4bea 100644
+--- a/src/audio/ffmpeg_audio_processor_swresample.h
++++ b/src/audio/ffmpeg_audio_processor_swresample.h
+@@ -28,30 +28,28 @@ public:
+ 		av_opt_set_double(m_swr_ctx, "cutoff", 0.8, 0);
+ 	}
+
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "icl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "ich", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetInputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "in_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "isf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "in_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "isr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "in_sample_rate", sample_rate, 0);
+ 	}
+
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "ocl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "och", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetOutputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "out_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "osf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "out_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "osr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "out_sample_rate", sample_rate, 0);
+ 	}
+
+ 	int Init() {
+diff --git a/src/audio/ffmpeg_audio_reader.h b/src/audio/ffmpeg_audio_reader.h
+index 5550164..1c6b346 100644
+--- a/src/audio/ffmpeg_audio_reader.h
++++ b/src/audio/ffmpeg_audio_reader.h
+@@ -62,7 +62,7 @@ public:
+ 	bool Read(const int16_t **data, size_t *size);
+
+ 	bool IsOpen() const { return m_opened; }
+-	bool IsFinished() const { return m_finished && !m_got_frame; }
++	bool IsFinished() const { return !m_has_more_packets && !m_has_more_frames; }
+
+ 	std::string GetError() const { return m_error; }
+ 	int GetErrorCode() const { return m_error_code; }
+@@ -74,20 +74,19 @@ private:
+ 	uint8_t *m_convert_buffer[1] = { nullptr };
+ 	int m_convert_buffer_nb_samples = 0;
+
+-	AVInputFormat *m_input_fmt = nullptr;
++	const AVInputFormat *m_input_fmt = nullptr;
+ 	AVDictionary *m_input_opts = nullptr;
+
+ 	AVFormatContext *m_format_ctx = nullptr;
+ 	AVCodecContext *m_codec_ctx = nullptr;
+-	AVFrame *m_frame = nullptr;
+ 	int m_stream_index = -1;
+ 	std::string m_error;
+ 	int m_error_code = 0;
+-	bool m_finished = false;
+ 	bool m_opened = false;
+-	int m_got_frame = 0;
+-	AVPacket m_packet;
+-	AVPacket m_packet0;
++	bool m_has_more_packets = true;
++	bool m_has_more_frames = true;
++	AVPacket *m_packet = nullptr;
++	AVFrame *m_frame = nullptr;
+
+ 	int m_output_sample_rate = 0;
+ 	int m_output_channels = 0;
+@@ -98,19 +97,12 @@ private:
+
+ inline FFmpegAudioReader::FFmpegAudioReader() {
+ 	av_log_set_level(AV_LOG_QUIET);
+-
+-	av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
+ }
+
+ inline FFmpegAudioReader::~FFmpegAudioReader() {
+ 	Close();
+ 	av_dict_free(&m_input_opts);
+ 	av_freep(&m_convert_buffer[0]);
+-	av_packet_unref(&m_packet0);
+ }
+
+ inline bool FFmpegAudioReader::SetInputFormat(const char *name) {
+@@ -135,11 +127,10 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ 	Close();
+
+-    av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
++	m_packet = av_packet_alloc();
++	if (!m_packet) {
++		return false;
++	}
+
+ 	ret = avformat_open_input(&m_format_ctx, file_name.c_str(), m_input_fmt, &m_input_opts);
+ 	if (ret < 0) {
+@@ -153,26 +144,31 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		return false;
+ 	}
+
+-	AVCodec *codec;
++	const AVCodec *codec;
+ 	ret = av_find_best_stream(m_format_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &codec, 0);
+ 	if (ret < 0) {
+ 		SetError("Could not find any audio stream in the file", ret);
+ 		return false;
+ 	}
+ 	m_stream_index = ret;
++	auto stream = m_format_ctx->streams[m_stream_index];
+
+-	m_codec_ctx = m_format_ctx->streams[m_stream_index]->codec;
++	m_codec_ctx = avcodec_alloc_context3(codec);
+ 	m_codec_ctx->request_sample_fmt = AV_SAMPLE_FMT_S16;
+
++	ret = avcodec_parameters_to_context(m_codec_ctx, stream->codecpar);
++	if (ret < 0) {
++		SetError("Could not copy the stream parameters", ret);
++		return false;
++	}
++
+ 	ret = avcodec_open2(m_codec_ctx, codec, nullptr);
+ 	if (ret < 0) {
+ 		SetError("Could not open the codec", ret);
+ 		return false;
+ 	}
+
+-	if (!m_codec_ctx->channel_layout) {
+-		m_codec_ctx->channel_layout = av_get_default_channel_layout(m_codec_ctx->channels);
+-	}
++	av_dump_format(m_format_ctx, 0, "foo", 0);
+
+ 	m_frame = av_frame_alloc();
+ 	if (!m_frame) {
+@@ -183,19 +179,23 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		m_output_sample_rate = m_codec_ctx->sample_rate;
+ 	}
+
+-	if (!m_output_channels) {
+-		m_output_channels = m_codec_ctx->channels;
++	AVChannelLayout output_channel_layout;
++	if (m_output_channels) {
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
++	} else {
++		m_output_channels = m_codec_ctx->ch_layout.nb_channels;
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
+ 	}
+
+-	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
++	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->ch_layout.nb_channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
+ 		m_converter.reset(new FFmpegAudioProcessor());
+ 		m_converter->SetCompatibleMode();
+ 		m_converter->SetInputSampleFormat(m_codec_ctx->sample_fmt);
+ 		m_converter->SetInputSampleRate(m_codec_ctx->sample_rate);
+-		m_converter->SetInputChannelLayout(m_codec_ctx->channel_layout);
++		m_converter->SetInputChannelLayout(&(m_codec_ctx->ch_layout));
+ 		m_converter->SetOutputSampleFormat(AV_SAMPLE_FMT_S16);
+ 		m_converter->SetOutputSampleRate(m_output_sample_rate);
+-		m_converter->SetOutputChannelLayout(av_get_default_channel_layout(m_output_channels));
++		m_converter->SetOutputChannelLayout(&output_channel_layout);
+ 		auto ret = m_converter->Init();
+ 		if (ret != 0) {
+ 			SetError("Could not create an audio converter instance", ret);
+@@ -203,10 +203,11 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		}
+ 	}
+
++	av_channel_layout_uninit(&output_channel_layout);
++
+ 	m_opened = true;
+-	m_finished = false;
+-	m_got_frame = 0;
+-	m_nb_packets = 0;
++	m_has_more_packets = true;
++	m_has_more_frames = true;
+ 	m_decode_error = 0;
+
+ 	return true;
+@@ -214,6 +215,7 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ inline void FFmpegAudioReader::Close() {
+ 	av_frame_free(&m_frame);
++	av_packet_free(&m_packet);
+
+ 	m_stream_index = -1;
+
+@@ -252,91 +254,98 @@ inline bool FFmpegAudioReader::Read(const int16_t **data, size_t *size) {
+ 		return false;
+ 	}
+
++	*data = nullptr;
++	*size = 0;
++
+ 	int ret;
++	bool needs_packet = false;
+ 	while (true) {
+-		while (m_packet.size <= 0) {
+-			av_packet_unref(&m_packet0);
+-			av_init_packet(&m_packet);
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			ret = av_read_frame(m_format_ctx, &m_packet);
++		while (needs_packet && m_packet->size == 0) {
++			ret = av_read_frame(m_format_ctx, m_packet);
+ 			if (ret < 0) {
+ 				if (ret == AVERROR_EOF) {
+-					m_finished = true;
++					needs_packet = false;
++					m_has_more_packets = false;
+ 					break;
+-				} else {
++				}
++				SetError("Error reading from the audio source", ret);
++				return false;
++			}
++			if (m_packet->stream_index == m_stream_index) {
++				needs_packet = false;
++			} else {
++				av_packet_unref(m_packet);
++			}
++		}
++
++		if (m_packet->size != 0) {
++			ret = avcodec_send_packet(m_codec_ctx, m_packet);
++			if (ret < 0) {
++				if (ret != AVERROR(EAGAIN)) {
+ 					SetError("Error reading from the audio source", ret);
+ 					return false;
+ 				}
+-			}
+-			m_packet0 = m_packet;
+-			if (m_packet.stream_index != m_stream_index) {
+-				m_packet.data = nullptr;
+-				m_packet.size = 0;
+ 			} else {
+-				m_nb_packets++;
++				av_packet_unref(m_packet);
+ 			}
+ 		}
+
+-		ret = avcodec_decode_audio4(m_codec_ctx, m_frame, &m_got_frame, &m_packet);
++		ret = avcodec_receive_frame(m_codec_ctx, m_frame);
+ 		if (ret < 0) {
+-			if (m_decode_error) {
+-				SetError("Error decoding audio frame", m_decode_error);
+-				return false;
++			if (ret == AVERROR_EOF) {
++				m_has_more_frames = false;
++			} else if (ret == AVERROR(EAGAIN)) {
++				if (m_has_more_packets) {
++					needs_packet = true;
++					continue;
++				} else {
++					m_has_more_frames = false;
++				}
+ 			}
+-			m_decode_error = ret;
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			continue;
++			SetError("Error decoding the audio source", ret);
++			return false;
+ 		}
+
+-		break;
+-	}
+-
+-	m_decode_error = 0;
+-
+-	const int decoded = std::min(ret, m_packet.size);
+-	m_packet.data += decoded;
+-	m_packet.size -= decoded;
+-
+-	if (m_got_frame) {
+-		if (m_converter) {
+-			if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
+-				int linsize;
+-				av_freep(&m_convert_buffer[0]);
+-				m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
+-				ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
+-				if (ret < 0) {
+-					SetError("Couldn't allocate audio converter buffer", ret);
++		if (m_frame->nb_samples > 0) {
++			if (m_converter) {
++				if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
++					int linsize;
++					av_freep(&m_convert_buffer[0]);
++					m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
++					ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->ch_layout.nb_channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
++					if (ret < 0) {
++						SetError("Couldn't allocate audio converter buffer", ret);
++						return false;
++					}
++				}
++				auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
++				if (nb_samples < 0) {
++					SetError("Couldn't convert audio", ret);
+ 					return false;
+ 				}
+-			}
+-			auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			}
+-			*data = (const int16_t *) m_convert_buffer[0];
+-			*size = nb_samples;
+-		} else {
+-			*data = (const int16_t *) m_frame->data[0];
+-			*size = m_frame->nb_samples;
+-		}
+-	} else {
+-		if (m_finished && m_converter) {
+-			auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			} else if (nb_samples > 0) {
+-				m_got_frame = 1;
+ 				*data = (const int16_t *) m_convert_buffer[0];
+ 				*size = nb_samples;
++			} else {
++				*data = (const int16_t *) m_frame->data[0];
++				*size = m_frame->nb_samples;
++			}
++		} else {
++			if (m_converter) {
++				if (IsFinished()) {
++					auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
++					if (nb_samples < 0) {
++						SetError("Couldn't convert audio", ret);
++						return false;
++					} else if (nb_samples > 0) {
++						*data = (const int16_t *) m_convert_buffer[0];
++						*size = nb_samples;
++					}
++				}
+ 			}
+ 		}
+-	}
+
+-	return true;
++		return true;
++	}
+ }
+
+ inline void FFmpegAudioReader::SetError(const char *message, int errnum) {
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index a2b517b..123e643 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -38,6 +38,12 @@ set(SRCS
+
+ if(BUILD_TOOLS)
+ 	set(SRCS ${SRCS} ../src/audio/ffmpeg_audio_reader_test.cpp)
++    include_directories(
++        ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}
++        ${AUDIO_PROCESSOR_INCLUDE_DIRS}
++    )
+ 	link_libraries(fpcalc_libs)
+ endif()
+
+-- 
+2.38.1
+
+
diff --git a/srcpkgs/chromaprint/template b/srcpkgs/chromaprint/template
index 7ef7838949f3..1f7bbc70a22c 100644
--- a/srcpkgs/chromaprint/template
+++ b/srcpkgs/chromaprint/template
@@ -1,7 +1,7 @@
 # Template file for 'chromaprint'
 pkgname=chromaprint
 version=1.5.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DBUILD_TOOLS=ON"
 make_check_target="check"

From eb19570c7a6ab93c60217915c0365a599d4935a2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 026/130] chromium: revbump for ffmpeg-6.0

---
 .../patches/chromium-93-ffmpeg-4.4.patch      | 36 --------------
 srcpkgs/chromium/patches/ffmpeg5.patch        | 47 +++++++++++++++++++
 srcpkgs/chromium/template                     |  2 +-
 3 files changed, 48 insertions(+), 37 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch
 create mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch b/srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch
deleted file mode 100644
index f0ec736f98bc..000000000000
--- a/srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch
+++ /dev/null
@@ -1,36 +0,0 @@
-diff --git a/media/filters/ffmpeg_demuxer.cc b/media/filters/ffmpeg_demuxer.cc
-index ac4713b07268..492a9a37d096 100644
---- a/media/filters/ffmpeg_demuxer.cc
-+++ b/media/filters/ffmpeg_demuxer.cc
-@@ -427,11 +427,11 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
-   scoped_refptr<DecoderBuffer> buffer;
- 
-   if (type() == DemuxerStream::TEXT) {
--    size_t id_size = 0;
-+    int id_size = 0;
-     uint8_t* id_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
- 
--    size_t settings_size = 0;
-+    int settings_size = 0;
-     uint8_t* settings_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
- 
-@@ -443,7 +443,7 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
-     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
-                                      side_data.data(), side_data.size());
-   } else {
--    size_t side_data_size = 0;
-+    int side_data_size = 0;
-     uint8_t* side_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
- 
-@@ -504,7 +504,7 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
-                                        packet->size - data_offset);
-     }
- 
--    size_t skip_samples_size = 0;
-+    int skip_samples_size = 0;
-     const uint32_t* skip_samples_ptr =
-         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
-             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..24e2da38e34c
--- /dev/null
+++ b/srcpkgs/chromium/patches/ffmpeg5.patch
@@ -0,0 +1,47 @@
+--- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
++++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
+@@ -92,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+-  if (stream->start_time != kNoFFmpegTimestamp)
++  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -1597,7 +1585,7 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+@@ -1618,7 +1606,7 @@
+     if (stream->type() != DemuxerStream::VIDEO)
+       continue;
+ 
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+ 
+     if (!stream->IsEnabled())
diff --git a/srcpkgs/chromium/template b/srcpkgs/chromium/template
index e50c739d3ee7..8705f2ef973f 100644
--- a/srcpkgs/chromium/template
+++ b/srcpkgs/chromium/template
@@ -2,7 +2,7 @@
 pkgname=chromium
 # See https://chromiumdash.appspot.com/releases?platform=Linux for the latest version
 version=112.0.5615.49
-revision=1
+revision=2
 archs="i686* x86_64* aarch64* armv7l*"
 hostmakedepends="
  $(vopt_if clang "clang lld llvm15")

From e01500d5608ba5cb9213e41f7ee470d7a5dc8f06 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 027/130] cmus: revbump for ffmpeg-6.0

---
 srcpkgs/cmus/patches/ffmpeg6.patch | 12 ++++++++++++
 srcpkgs/cmus/template              |  2 +-
 2 files changed, 13 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/cmus/patches/ffmpeg6.patch

diff --git a/srcpkgs/cmus/patches/ffmpeg6.patch b/srcpkgs/cmus/patches/ffmpeg6.patch
new file mode 100644
index 000000000000..ffa95ab81110
--- /dev/null
+++ b/srcpkgs/cmus/patches/ffmpeg6.patch
@@ -0,0 +1,12 @@
+--- a/ip/ffmpeg.c
++++ b/ip/ffmpeg.c
+@@ -202,9 +202,6 @@ static int ffmpeg_open(struct input_plugin_data *ip_data)
+ 			break;
+ 		}
+ 
+-		if (codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+-			cc->flags |= AV_CODEC_FLAG_TRUNCATED;
+-
+ 		if (avcodec_open2(cc, codec, NULL) < 0) {
+ 			d_print("could not open codec: %d, %s\n", cc->codec_id, avcodec_get_name(cc->codec_id));
+ 			err = -IP_ERROR_UNSUPPORTED_FILE_TYPE;
diff --git a/srcpkgs/cmus/template b/srcpkgs/cmus/template
index 0fcb424ce336..05b77d0fecae 100644
--- a/srcpkgs/cmus/template
+++ b/srcpkgs/cmus/template
@@ -1,7 +1,7 @@
 # Template file for 'cmus'
 pkgname=cmus
 version=2.10.0
-revision=1
+revision=2
 build_style=configure
 configure_args="prefix=/usr LD=$CC"
 hostmakedepends="pkg-config"

From 7609997ec323c747e5543052e405ad2631b8047a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 028/130] cyanrip: revbump for ffmpeg-6.0

---
 srcpkgs/cyanrip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cyanrip/template b/srcpkgs/cyanrip/template
index 9796e3461601..5db30e020d17 100644
--- a/srcpkgs/cyanrip/template
+++ b/srcpkgs/cyanrip/template
@@ -1,7 +1,7 @@
 # Template file for 'cyanrip'
 pkgname=cyanrip
 version=0.9.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config"
 makedepends="ffmpeg-devel libcdio-devel libcdio-paranoia-devel libcurl-devel libmusicbrainz5-devel"

From f395f56ece2ed434cfb69583c6355f9f786529ab Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 029/130] deadbeef: revbump for ffmpeg4-4.4.3

---
 srcpkgs/deadbeef/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/deadbeef/template b/srcpkgs/deadbeef/template
index b664bb1b9bd9..165b3c7b9cad 100644
--- a/srcpkgs/deadbeef/template
+++ b/srcpkgs/deadbeef/template
@@ -1,14 +1,14 @@
 # Template file for 'deadbeef'
 pkgname=deadbeef
 version=1.8.8
-revision=1
+revision=2
 create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-oss --disable-lfm --disable-notify --disable-gtk2"
 hostmakedepends="automake libtool gettext gettext-devel intltool pkg-config
  yasm clang glib-devel"
 makedepends="
- alsa-lib-devel dbus-devel faad2-devel ffmpeg-devel gtk+3-devel imlib2-devel
+ alsa-lib-devel dbus-devel faad2-devel ffmpeg4-devel gtk+3-devel imlib2-devel
  jansson-devel libcddb-devel libcdio-devel libcurl-devel libflac-devel
  libmad-devel libpng-devel libsamplerate-devel libsndfile-devel libvorbis-devel
  libzip-devel mpg123-devel opusfile-devel pulseaudio-devel wavpack-devel"

From 043b5a8083a87b33537e057341daf2722a988009 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 030/130] dolphin-emu: revbump for ffmpeg-6.0

---
 srcpkgs/dolphin-emu/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/dolphin-emu/template b/srcpkgs/dolphin-emu/template
index 7ea197ceb2a8..7aeb0a5b645e 100644
--- a/srcpkgs/dolphin-emu/template
+++ b/srcpkgs/dolphin-emu/template
@@ -1,7 +1,7 @@
 # Template file for 'dolphin-emu'
 pkgname=dolphin-emu
 version=5.0.16101
-revision=1
+revision=2
 _dolphin_commit=8ecfa537a242de74d2e372e30d9d79b14584b2fb
 _mgba_commit=40d4c430fc36caeb7ea32fd39624947ed487d2f2
 #Version/hash pair can be found at https://dolphin-emu.org/download/

From 8f0d668dfb5f5ffe45bd9df9a9ae00179480af60 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 031/130] droidcam-obs-plugin: revbump for ffmpeg-6.0

---
 srcpkgs/droidcam-obs-plugin/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam-obs-plugin/template b/srcpkgs/droidcam-obs-plugin/template
index fc9c9bf6b9d5..fb0480754df4 100644
--- a/srcpkgs/droidcam-obs-plugin/template
+++ b/srcpkgs/droidcam-obs-plugin/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam-obs-plugin'
 pkgname=droidcam-obs-plugin
 version=2.0.1
-revision=1
+revision=2
 build_style=gnu-makefile
 make_use_env=yes
 make_build_args="ALLOW_STATIC=no"

From 988bd1b50dab15d8f05eb84d4f22bf71a1f91e89 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 032/130] droidcam: revbump for ffmpeg-6.0

---
 srcpkgs/droidcam/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam/template b/srcpkgs/droidcam/template
index 1c3f1b8b1fc6..32a9220b79a4 100644
--- a/srcpkgs/droidcam/template
+++ b/srcpkgs/droidcam/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam'
 pkgname=droidcam
 version=1.8.2
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="USBMUXD=-lusbmuxd-2.0 JPEG=-lturbojpeg"
 hostmakedepends="pkg-config"

From 293250be8e924466fa168f937d938cdbc99c8f2b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 033/130] electron19: revbump for ffmpeg-6.0

---
 srcpkgs/electron19/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron19/template b/srcpkgs/electron19/template
index 068136be7623..32ce301e730c 100644
--- a/srcpkgs/electron19/template
+++ b/srcpkgs/electron19/template
@@ -1,7 +1,7 @@
 # Template file for 'electron19'
 pkgname=electron19
 version=19.0.8
-revision=2
+revision=3
 _nodever=16.14.2
 _chromiumver=102.0.5005.125
 archs="x86_64* aarch64* ppc64le*"

From c4b356a9232110e835daad45e661dd51d0eb1507 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 034/130] ffmpegthumbnailer: revbump for ffmpeg-6.0

---
 .../ffmpegthumbnailer/patches/ffmpeg6.patch   | 202 ++++++++++++++++++
 srcpkgs/ffmpegthumbnailer/template            |   6 +-
 2 files changed, 205 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch

diff --git a/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
new file mode 100644
index 000000000000..363ff35a2841
--- /dev/null
+++ b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
@@ -0,0 +1,202 @@
+--- a/libffmpegthumbnailer/moviedecoder.cpp	2017-11-21 14:06:57.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.cpp	2023-05-05 13:14:47.946560668 -0400
+@@ -41,11 +41,6 @@
+ namespace ffmpegthumbnailer
+ {
+ 
+-struct SilenceLogLevel
+-{
+-    SilenceLogLevel() { av_log_set_level(AV_LOG_QUIET); }
+-};
+-
+ MovieDecoder::MovieDecoder(AVFormatContext* pavContext)
+ : m_VideoStream(-1)
+ , m_pFormatContext(pavContext)
+@@ -70,8 +65,6 @@
+ 
+ void MovieDecoder::initialize(const string& filename, bool preferEmbeddedMetadata)
+ {
+-    av_register_all();
+-    avcodec_register_all();
+     avformat_network_init();
+ 
+     string inputFile = filename == "-" ? "pipe:" : filename;
+@@ -97,8 +90,7 @@
+ {
+     if (m_pVideoCodecContext)
+     {
+-        avcodec_close(m_pVideoCodecContext);
+-        m_pVideoCodecContext = nullptr;
++        avcodec_free_context(&m_pVideoCodecContext);
+     }
+ 
+     if ((!m_FormatContextWasGiven) && m_pFormatContext)
+@@ -152,10 +144,10 @@
+     for (unsigned int i = 0; i < m_pFormatContext->nb_streams; ++i)
+     {
+         AVStream *stream = m_pFormatContext->streams[i];
+-        auto ctx = m_pFormatContext->streams[i]->codec;
+-        if (ctx->codec_type == AVMEDIA_TYPE_VIDEO)
++        auto par = m_pFormatContext->streams[i]->codecpar;
++        if (par->codec_type == AVMEDIA_TYPE_VIDEO)
+         {
+-            if (!preferEmbeddedMetadata || !isStillImageCodec(ctx->codec_id))
++            if (!preferEmbeddedMetadata || !isStillImageCodec(par->codec_id))
+             {
+                 videoStreams.push_back(i);
+                 continue;
+@@ -203,8 +195,7 @@
+     }
+ 
+     m_pVideoStream = m_pFormatContext->streams[m_VideoStream];
+-    m_pVideoCodecContext = m_pVideoStream->codec;
+-    m_pVideoCodec = avcodec_find_decoder(m_pVideoCodecContext->codec_id);
++    m_pVideoCodec = avcodec_find_decoder(m_pVideoStream->codecpar->codec_id);
+ 
+     if (m_pVideoCodec == nullptr)
+     {
+@@ -214,6 +205,20 @@
+         throw logic_error("Video Codec not found");
+     }
+ 
++    m_pVideoCodecContext = avcodec_alloc_context3(m_pVideoCodec);
++
++    if (m_pVideoCodecContext == nullptr)
++    {
++        destroy();
++        throw logic_error("Could not allocate video codec context");
++    }
++
++    if (avcodec_parameters_to_context(m_pVideoCodecContext, m_pVideoStream->codecpar) < 0)
++    {
++        destroy();
++        throw logic_error("Could not configure video codec context");
++    }
++
+     m_pVideoCodecContext->workaround_bugs = 1;
+ 
+     if (avcodec_open2(m_pVideoCodecContext, m_pVideoCodec, nullptr) < 0)
+@@ -386,13 +391,6 @@
+ 
+ void MovieDecoder::initializeFilterGraph(const AVRational& timeBase, const std::string& size, bool maintainAspectRatio)
+ {
+-    static const AVPixelFormat pixelFormats[] = { AV_PIX_FMT_RGB24, AV_PIX_FMT_NONE };
+-
+-    auto del = [] (AVBufferSinkParams* p) { av_freep(p); };
+-    std::unique_ptr<AVBufferSinkParams, decltype(del)> buffersinkParams(av_buffersink_params_alloc(), del);
+-
+-    avfilter_register_all();
+-
+     m_pFilterGraph = avfilter_graph_alloc();
+     assert(m_pFilterGraph);
+ 
+@@ -404,10 +402,8 @@
+ 
+     checkRc(avfilter_graph_create_filter(&m_pFilterSource, avfilter_get_by_name("buffer"), "thumb_buffer", ss.str().c_str(), nullptr, m_pFilterGraph),
+             "Failed to create filter source");
+-    buffersinkParams->pixel_fmts = pixelFormats;
+-    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, buffersinkParams.get(), m_pFilterGraph),
++    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, nullptr, m_pFilterGraph),
+             "Failed to create filter sink");
+-    buffersinkParams.release();
+ 
+     AVFilterContext* yadifFilter = nullptr;
+     if (m_pFrame->interlaced_frame != 0)
+@@ -500,15 +496,15 @@
+     }
+ 
+     checkRc(av_seek_frame(m_pFormatContext, -1, timestamp, 0), "Seeking in video failed");
+-    avcodec_flush_buffers(m_pFormatContext->streams[m_VideoStream]->codec);
++    avcodec_flush_buffers(m_pVideoCodecContext);
+ 
+     int keyFrameAttempts = 0;
+-    bool gotFrame = 0;
++    bool gotFrame;
+ 
+     do
+     {
+         int count = 0;
+-        gotFrame = 0;
++        gotFrame = false;
+ 
+         while (!gotFrame && count < 20)
+         {
+@@ -552,17 +548,33 @@
+         return false;
+     }
+ 
+-    av_frame_unref(m_pFrame);
+-
+-    int frameFinished;
++    int rc = avcodec_send_packet(m_pVideoCodecContext, m_pPacket);
++    if(rc == AVERROR(EAGAIN))
++    {
++        rc = 0;
++    }
+ 
+-    int bytesDecoded = avcodec_decode_video2(m_pVideoCodecContext, m_pFrame, &frameFinished, m_pPacket);
+-    if (bytesDecoded < 0)
++    if(rc == AVERROR_EOF)
++    {
++        return false;
++    }
++    else if(rc < 0)
+     {
+-        throw logic_error("Failed to decode video frame: bytesDecoded < 0");
++        throw logic_error("Failed to decode video frame: avcodec_send_packet() < 0");
+     }
+ 
+-    return frameFinished > 0;
++    rc = avcodec_receive_frame(m_pVideoCodecContext, m_pFrame);
++    switch(rc)
++    {
++        case 0:
++            return true;
++
++        case AVERROR(EAGAIN):
++            return false;
++
++        default:
++            throw logic_error("Failed to decode video frame: avcodec_receive_frame() < 0");
++    }
+ }
+ 
+ bool MovieDecoder::getVideoPacket()
+@@ -570,8 +582,6 @@
+     bool framesAvailable = true;
+     bool frameDecoded = false;
+ 
+-    int attempts = 0;
+-
+     if (m_pPacket)
+     {
+         av_packet_unref(m_pPacket);
+@@ -580,6 +590,7 @@
+ 
+     m_pPacket = new AVPacket();
+ 
++
+     while (framesAvailable && !frameDecoded)
+     {
+         framesAvailable = av_read_frame(m_pFormatContext, m_pPacket) >= 0;
+@@ -644,7 +655,7 @@
+ 
+ int32_t MovieDecoder::getStreamRotation()
+ {
+-    int32_t* matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
++    auto matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
+     if (matrix)
+     {
+         auto angle = lround(av_display_rotation_get(matrix));
+
+--- a/libffmpegthumbnailer/moviedecoder.h	2017-11-12 04:23:38.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.h	2023-05-05 13:26:07.095529911 -0400
+@@ -78,7 +78,7 @@
+     int                     m_VideoStream;
+     AVFormatContext*        m_pFormatContext;
+     AVCodecContext*         m_pVideoCodecContext;
+-    AVCodec*                m_pVideoCodec;
++    const AVCodec*          m_pVideoCodec;
+     AVFilterGraph*          m_pFilterGraph;
+     AVFilterContext*        m_pFilterSource;
+     AVFilterContext*        m_pFilterSink;
diff --git a/srcpkgs/ffmpegthumbnailer/template b/srcpkgs/ffmpegthumbnailer/template
index 039eea7622b3..35d546018d12 100644
--- a/srcpkgs/ffmpegthumbnailer/template
+++ b/srcpkgs/ffmpegthumbnailer/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbnailer'
 pkgname=ffmpegthumbnailer
 version=2.2.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libpng-devel libjpeg-turbo-devel ffmpeg-devel"
@@ -9,8 +9,8 @@ depends="ffmpeg"
 short_desc="Lightweight video thumbnailer"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
-homepage="https://github.com/dirkvdb/${pkgname}"
-distfiles="${homepage}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
+homepage="https://github.com/dirkvdb"
+distfiles="${homepage}/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
 checksum=1cb24059c38223f657b300c84dd80491b7040d4b69471c4fea69be862bc99b5b
 
 post_install() {

From 918e33d6659ef4a53ddecca8ed6b1c1dabd9f26c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 035/130] ffmpegthumbs: revbump for ffmpeg-6.0

---
 srcpkgs/ffmpegthumbs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ffmpegthumbs/template b/srcpkgs/ffmpegthumbs/template
index 5f0b9414dada..11b88193528f 100644
--- a/srcpkgs/ffmpegthumbs/template
+++ b/srcpkgs/ffmpegthumbs/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbs'
 pkgname=ffmpegthumbs
 version=22.12.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules kcoreaddons kconfig-devel
  pkg-config qt5-host-tools qt5-qmake gettext"

From f77ceace89411e604d42a87f18b48e6b08fbd38d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 036/130] ffms2: revbump for ffmpeg-6.0

---
 srcpkgs/ffms2/patches/ffmpeg5.patch | 424 ++++++++++++++++++++++++++++
 srcpkgs/ffms2/template              |   2 +-
 2 files changed, 425 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ffms2/patches/ffmpeg5.patch

diff --git a/srcpkgs/ffms2/patches/ffmpeg5.patch b/srcpkgs/ffms2/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..1479fabcafcb
--- /dev/null
+++ b/srcpkgs/ffms2/patches/ffmpeg5.patch
@@ -0,0 +1,424 @@
+From 45673149e9a2f5586855ad472e3059084eaa36b1 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:41:21 +0100
+Subject: [PATCH] Use auto for AVCodec
+
+The geniuses over at FFmpeg decided to constify this API, so old
+versions of the library will return AVCodec *, while new versions
+of the libary will return const AVCodec *, which, in C++, are not
+OK to convert between.
+
+Rather than use some macro hell in ffmscompat.h, we can work around
+this by using auto.
+
+Gross.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 2 +-
+ src/core/indexing.cpp    | 6 +++---
+ src/core/videosource.cpp | 2 +-
+ 3 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index e4ce97c..ac09666 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -469,7 +469,7 @@ void FFMS_AudioSource::OpenFile() {
+ 
+     LAVFOpenFile(SourceFile.c_str(), FormatContext, TrackNumber);
+ 
+-    AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
++    auto *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
+     if (Codec == nullptr)
+         throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+             "Audio codec not found");
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index e547c5a..59fb4e8 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -384,7 +384,7 @@ FFMS_TrackType FFMS_Indexer::GetTrackType(int Track) {
+ }
+ 
+ const char *FFMS_Indexer::GetTrackCodec(int Track) {
+-    AVCodec *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
++    auto *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
+     return codec ? codec->name : nullptr;
+ }
+ 
+@@ -402,7 +402,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             UseDTS);
+ 
+         if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            AVCodec *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (!VideoCodec) {
+                 FormatContext->streams[i]->discard = AVDISCARD_ALL;
+                 IndexMask.erase(i);
+@@ -433,7 +433,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 IndexMask.insert(i);
+             }
+         } else if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+-            AVCodec *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (AudioCodec == nullptr)
+                 throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_UNSUPPORTED,
+                     "Audio codec not found");
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index b889970..8956c22 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -171,7 +171,7 @@ FFMS_VideoSource::FFMS_VideoSource(const char *SourceFile, FFMS_Index &Index, in
+ 
+         LAVFOpenFile(SourceFile, FormatContext, VideoTrack);
+ 
+-        AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
++        auto *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
+         if (Codec == nullptr)
+             throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+                 "Video codec not found");
+-- 
+2.40.0
+
+From 96cbf38ea9381829a1314f432a2c60495dcefaad Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:12:41 +0100
+Subject: [PATCH] all: Update AVPacket API usage
+
+AVPackets must all be on the heap now, since it is no longer
+part of the libav* ABI.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 16 ++++++----
+ src/core/indexing.cpp    | 63 ++++++++++++++++++++++------------------
+ src/core/indexing.h      |  4 +--
+ src/core/utils.cpp       |  6 ----
+ src/core/utils.h         |  1 -
+ src/core/videosource.cpp | 30 ++++++++++---------
+ 6 files changed, 64 insertions(+), 56 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index 37cf9ae..e4ce97c 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -285,10 +285,15 @@ FFMS_AudioSource::AudioBlock *FFMS_AudioSource::CacheBlock(CacheIterator &pos) {
+ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     CurrentFrame = &Frames[PacketNumber];
+ 
+-    AVPacket Packet;
+-    if (!ReadPacket(&Packet))
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++    if (!ReadPacket(Packet)) {
++        av_packet_free(&Packet);
+         throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_UNKNOWN,
+             "ReadPacket unexpectedly failed to read a packet");
++    }
+ 
+     // ReadPacket may have changed the packet number
+     CurrentFrame = &Frames[PacketNumber];
+@@ -297,8 +302,9 @@ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     int NumberOfSamples = 0;
+     AudioBlock *CachedBlock = nullptr;
+     
+-    int Ret = avcodec_send_packet(CodecContext, &Packet);
+-    av_packet_unref(&Packet);
++    int Ret = avcodec_send_packet(CodecContext, Packet);
++    av_packet_unref(Packet);
++    av_packet_free(&Packet);
+ 
+     av_frame_unref(DecodeFrame);
+     Ret = avcodec_receive_frame(CodecContext, DecodeFrame);
+@@ -513,8 +519,6 @@ void FFMS_AudioSource::Seek() {
+ }
+ 
+ bool FFMS_AudioSource::ReadPacket(AVPacket *Packet) {
+-    InitNullPacket(*Packet);
+-
+     while (av_read_frame(FormatContext, Packet) >= 0) {
+         if (Packet->stream_index == TrackNumber) {
+             // Required because not all audio packets, especially in ogg, have a pts. Use the previous valid packet's pts instead.
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index 23fb95b..e547c5a 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -320,7 +320,7 @@ void FFMS_Indexer::CheckAudioProperties(int Track, AVCodecContext *Context) {
+     }
+ }
+ 
+-void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict,
++void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict,
+                                     int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct) {
+     if (VideoContext.Parser) {
+         uint8_t *OB;
+@@ -330,8 +330,8 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+         av_parser_parse2(VideoContext.Parser,
+             VideoContext.CodecContext,
+             &OB, &OBSize,
+-            pkt.data, pkt.size,
+-            pkt.pts, pkt.dts, pkt.pos);
++            pkt->data, pkt->size,
++            pkt->pts, pkt->dts, pkt->pos);
+ 
+         // H.264 (PAFF) and HEVC may have one field per packet, so we need to track
+         // when we have a full or half frame available, and mark one of them as
+@@ -351,15 +351,15 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+ 
+         *RepeatPict = VideoContext.Parser->repeat_pict;
+         *FrameType = VideoContext.Parser->pict_type;
+-        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt.flags & AV_PKT_FLAG_DISCARD));
++        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt->flags & AV_PKT_FLAG_DISCARD));
+     } else {
+-        *Invisible = !!(pkt.flags & AV_PKT_FLAG_DISCARD);
++        *Invisible = !!(pkt->flags & AV_PKT_FLAG_DISCARD);
+     }
+ 
+     if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP8)
+-        ParseVP8(pkt.data[0], Invisible, FrameType);
++        ParseVP8(pkt->data[0], Invisible, FrameType);
+     else if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP9)
+-        ParseVP9(pkt.data[0], Invisible, FrameType);
++        ParseVP9(pkt->data[0], Invisible, FrameType);
+ }
+ 
+ void FFMS_Indexer::Free() {
+@@ -458,32 +458,36 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+         }
+     }
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
+     std::vector<int64_t> LastValidTS(FormatContext->nb_streams, AV_NOPTS_VALUE);
+ 
+     int64_t filesize = avio_size(FormatContext->pb);
+     enum AVPictureStructure LastPicStruct = AV_PICTURE_STRUCTURE_UNKNOWN;
+-    while (av_read_frame(FormatContext, &Packet) >= 0) {
++    while (av_read_frame(FormatContext, Packet) >= 0) {
+         // Update progress
+         // FormatContext->pb can apparently be NULL when opening images.
+         if (IC && FormatContext->pb) {
+-            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate))
++            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate)) {
++                av_packet_free(&Packet);
+                 throw FFMS_Exception(FFMS_ERROR_CANCELLED, FFMS_ERROR_USER,
+                     "Cancelled by user");
++            }
+         }
+-        if (!IndexMask.count(Packet.stream_index)) {
+-            av_packet_unref(&Packet);
++        if (!IndexMask.count(Packet->stream_index)) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+-        int Track = Packet.stream_index;
++        int Track = Packet->stream_index;
+         FFMS_Track &TrackInfo = (*TrackIndices)[Track];
+-        bool KeyFrame = !!(Packet.flags & AV_PKT_FLAG_KEY);
++        bool KeyFrame = !!(Packet->flags & AV_PKT_FLAG_KEY);
+         ReadTS(Packet, LastValidTS[Track], (*TrackIndices)[Track].UseDTS);
+ 
+         if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            int64_t PTS = TrackInfo.UseDTS ? Packet.dts : Packet.pts;
++            int64_t PTS = TrackInfo.UseDTS ? Packet->dts : Packet->pts;
+             if (PTS == AV_NOPTS_VALUE) {
+                 // VPx alt-refs are output as packets which lack timestmps or durations, since
+                 // they are invisible. Currently, the timestamp mangling code in libavformat
+@@ -495,9 +499,11 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 // FFMS2 currently sorts packets by PTS, which will break decoding, otherwise.
+                 bool HasAltRefs = (FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP8 ||
+                                    FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP9);
+-                if (Packet.duration == 0 && !HasAltRefs)
++                if (Packet->duration == 0 && !HasAltRefs) {
++                    av_packet_free(&Packet);
+                     throw FFMS_Exception(FFMS_ERROR_INDEXING, FFMS_ERROR_PARSER,
+                         "Invalid packet pts, dts, and duration");
++                }
+ 
+                 if (TrackInfo.empty())
+                     PTS = 0;
+@@ -513,7 +519,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             ParseVideoPacket(AVContexts[Track], Packet, &RepeatPict, &FrameType, &Invisible, &LastPicStruct);
+ 
+             TrackInfo.AddVideoFrame(PTS, RepeatPict, KeyFrame,
+-                FrameType, Packet.pos, Invisible);
++                FrameType, Packet->pos, Invisible);
+         } else if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+             // For video seeking timestamps are used only if all packets have
+             // timestamps, while for audio they're used if any have timestamps,
+@@ -522,28 +528,29 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 TrackInfo.HasTS = true;
+ 
+             int64_t StartSample = AVContexts[Track].CurrentSample;
+-            uint32_t SampleCount = IndexAudioPacket(Track, &Packet, AVContexts[Track], *TrackIndices);
++            uint32_t SampleCount = IndexAudioPacket(Track, Packet, AVContexts[Track], *TrackIndices);
+             TrackInfo.SampleRate = AVContexts[Track].CodecContext->sample_rate;
+ 
+             TrackInfo.AddAudioFrame(LastValidTS[Track],
+-                StartSample, SampleCount, KeyFrame, Packet.pos, Packet.flags & AV_PKT_FLAG_DISCARD);
++                StartSample, SampleCount, KeyFrame, Packet->pos, Packet->flags & AV_PKT_FLAG_DISCARD);
+         }
+ 
+-        if (!(Packet.flags & AV_PKT_FLAG_DISCARD))
+-            TrackInfo.LastDuration = Packet.duration;
++        if (!(Packet->flags & AV_PKT_FLAG_DISCARD))
++            TrackInfo.LastDuration = Packet->duration;
+ 
+-        av_packet_unref(&Packet);
++        av_packet_unref(Packet);
+     }
++    av_packet_free(&Packet);
+ 
+     TrackIndices->Finalize(AVContexts, FormatContext->iformat->name);
+     return TrackIndices.release();
+ }
+ 
+-void FFMS_Indexer::ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS) {
+-    if (!UseDTS && Packet.pts != AV_NOPTS_VALUE)
+-        TS = Packet.pts;
++void FFMS_Indexer::ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS) {
++    if (!UseDTS && Packet->pts != AV_NOPTS_VALUE)
++        TS = Packet->pts;
+     if (TS == AV_NOPTS_VALUE)
+         UseDTS = true;
+-    if (UseDTS && Packet.dts != AV_NOPTS_VALUE)
+-        TS = Packet.dts;
++    if (UseDTS && Packet->dts != AV_NOPTS_VALUE)
++        TS = Packet->dts;
+ }
+diff --git a/src/core/indexing.h b/src/core/indexing.h
+index 3cfc3c3..5c06868 100644
+--- a/src/core/indexing.h
++++ b/src/core/indexing.h
+@@ -80,10 +80,10 @@ private:
+     int64_t Filesize;
+     uint8_t Digest[20];
+ 
+-    void ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS);
++    void ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS);
+     void CheckAudioProperties(int Track, AVCodecContext *Context);
+     uint32_t IndexAudioPacket(int Track, AVPacket *Packet, SharedAVContext &Context, FFMS_Index &TrackIndices);
+-    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
++    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
+     void Free();
+ public:
+     FFMS_Indexer(const char *Filename);
+diff --git a/src/core/utils.cpp b/src/core/utils.cpp
+index ce67533..8a2e997 100644
+--- a/src/core/utils.cpp
++++ b/src/core/utils.cpp
+@@ -62,12 +62,6 @@ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo) {
+     }
+ }
+ 
+-void InitNullPacket(AVPacket &pkt) {
+-    av_init_packet(&pkt);
+-    pkt.data = nullptr;
+-    pkt.size = 0;
+-}
+-
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames) {
+     AP.SampleFormat = static_cast<FFMS_SampleFormat>(av_get_packed_sample_fmt(CTX->sample_fmt));
+     AP.BitsPerSample = av_get_bytes_per_sample(CTX->sample_fmt) * 8;
+diff --git a/src/core/utils.h b/src/core/utils.h
+index 9819dc7..003ab79 100644
+--- a/src/core/utils.h
++++ b/src/core/utils.h
+@@ -58,7 +58,6 @@ std::unique_ptr<T> make_unique(Args&&... args) {
+ }
+ 
+ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo);
+-void InitNullPacket(AVPacket &pkt);
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames);
+ 
+ void LAVFOpenFile(const char *SourceFile, AVFormatContext *&FormatContext, int Track);
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index 06bd161..b889970 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -673,30 +673,34 @@ void FFMS_VideoSource::DecodeNextFrame(int64_t &AStartTime, int64_t &Pos) {
+     if (HasPendingDelayedFrames())
+         return;
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
+-
+-    while (ReadFrame(&Packet) >= 0) {
+-        if (Packet.stream_index != VideoTrack) {
+-            av_packet_unref(&Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++
++    while (ReadFrame(Packet) >= 0) {
++        if (Packet->stream_index != VideoTrack) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+         if (AStartTime < 0)
+-            AStartTime = Frames.UseDTS ? Packet.dts : Packet.pts;
++            AStartTime = Frames.UseDTS ? Packet->dts : Packet->pts;
+ 
+         if (Pos < 0)
+-            Pos = Packet.pos;
++            Pos = Packet->pos;
+ 
+-        bool FrameFinished = DecodePacket(&Packet);
+-        av_packet_unref(&Packet);
+-        if (FrameFinished)
++        bool FrameFinished = DecodePacket(Packet);
++        av_packet_unref(Packet);
++        if (FrameFinished) {
++            av_packet_free(&Packet);
+             return;
++        }
+     }
+ 
+     // Flush final frames
+-    InitNullPacket(Packet);
+-    DecodePacket(&Packet);
++    DecodePacket(Packet);
++    av_packet_free(&Packet);
+ }
+ 
+ bool FFMS_VideoSource::SeekTo(int n, int SeekOffset) {
+-- 
+2.40.0
+
+From bf9e03e9e08534c024e5a744a6437c4aac160201 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:20:47 +0100
+Subject: [PATCH 2/3] configure: Remove deprecated API use
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ configure.ac | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index b35ef80bc..d19714d0f 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -102,10 +102,10 @@ CFLAGS="$_CFLAGS $FFMPEG_CFLAGS"
+
+ AC_DEFUN([TEST_FFMPEG],
+          [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+-            #include <libavcodec/avcodec.h>
++            #include <libavformat/avformat.h>
+             #include <libswscale/swscale.h>
+             ]],[[
+-                avcodec_register_all();
++                avformat_network_init();
+                 swscale_version();
+             ]])], [eval $1=yes], [eval $1=no])
+         ])
+
diff --git a/srcpkgs/ffms2/template b/srcpkgs/ffms2/template
index 68e8a0c14bce..2acfadac44b3 100644
--- a/srcpkgs/ffms2/template
+++ b/srcpkgs/ffms2/template
@@ -1,7 +1,7 @@
 # Template file for 'ffms2'
 pkgname=ffms2
 version=2.40
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-shared --disable-static"
 hostmakedepends="pkg-config autoconf automake libtool"

From 721e2f6a8c1a2493894fe79100b676737cb08acb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 037/130] freerdp: revbump for ffmpeg-6.0

---
 .../freerdp/patches/ffmpeg6_aa2cb9aa.patch    | 42 +++++++++++++++++++
 srcpkgs/freerdp/template                      |  2 +-
 2 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch

diff --git a/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
new file mode 100644
index 000000000000..a4324da3a882
--- /dev/null
+++ b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
@@ -0,0 +1,42 @@
+From aa2cb9aa5ff5562433598ba168a466e0752bca0e Mon Sep 17 00:00:00 2001
+From: akallabeth <akallabeth@posteo.net>
+Date: Tue, 14 Feb 2023 07:48:54 +0100
+Subject: [PATCH] Fixed #8686: Update h264 to use new FFMPEG API
+
+---
+ channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c | 2 ++
+ libfreerdp/codec/h264_ffmpeg.c            | 2 ++
+ 2 files changed, 4 insertions(+)
+
+diff --git a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+index 339462d865f..beea80b7a1e 100644
+--- a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
++++ b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+@@ -239,8 +239,10 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYP
+ 		}
+ 	}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 	if (mdecoder->codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		mdecoder->codec_context->flags |= AV_CODEC_FLAG_TRUNCATED;
++#endif
+ 
+ 	return TRUE;
+ }
+diff --git a/libfreerdp/codec/h264_ffmpeg.c b/libfreerdp/codec/h264_ffmpeg.c
+index 8a23db2473c..896a333019b 100644
+--- a/libfreerdp/codec/h264_ffmpeg.c
++++ b/libfreerdp/codec/h264_ffmpeg.c
+@@ -615,10 +615,12 @@ static BOOL libavcodec_init(H264_CONTEXT* h264)
+ 			goto EXCEPTION;
+ 		}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 		if (sys->codecDecoder->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		{
+ 			sys->codecDecoderContext->flags |= AV_CODEC_FLAG_TRUNCATED;
+ 		}
++#endif
+ 
+ #ifdef WITH_VAAPI
+ 
diff --git a/srcpkgs/freerdp/template b/srcpkgs/freerdp/template
index 25e8aa9677f0..4d51c8189902 100644
--- a/srcpkgs/freerdp/template
+++ b/srcpkgs/freerdp/template
@@ -1,7 +1,7 @@
 # Template file for 'freerdp'
 pkgname=freerdp
 version=2.10.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_ALSA=ON -DWITH_CUPS=OFF -DWITH_FFMPEG=ON
  -DWITH_GSTREAMER_0_10=OFF -DWITH_GSTREAMER_1_0=OFF -DWITH_JPEG=ON

From 0dbcc9e5e081a28b0a97af8a0308f4a287757864 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 038/130] gerbera: revbump for ffmpeg-6.0

---
 srcpkgs/gerbera/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gerbera/template b/srcpkgs/gerbera/template
index ae14f35c767c..2dc0ac0ce03b 100644
--- a/srcpkgs/gerbera/template
+++ b/srcpkgs/gerbera/template
@@ -1,7 +1,7 @@
 # Template file for 'gerbera'
 pkgname=gerbera
 version=1.12.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_SYSTEMD=0 -DWITH_AVCODEC=1"
 hostmakedepends="pkg-config"

From 61d514fe75b9cd65401aa37806e4e39c4277fc50 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 039/130] goldendict: revbump for ffmpeg-6.0

---
 srcpkgs/goldendict/patches/ffmpeg4.patch |  21 --
 srcpkgs/goldendict/patches/ffmpeg5.patch | 232 +++++++++++++++++++++++
 srcpkgs/goldendict/template              |   2 +-
 3 files changed, 233 insertions(+), 22 deletions(-)
 delete mode 100644 srcpkgs/goldendict/patches/ffmpeg4.patch
 create mode 100644 srcpkgs/goldendict/patches/ffmpeg5.patch

diff --git a/srcpkgs/goldendict/patches/ffmpeg4.patch b/srcpkgs/goldendict/patches/ffmpeg4.patch
deleted file mode 100644
index f045fa27f54b..000000000000
--- a/srcpkgs/goldendict/patches/ffmpeg4.patch
+++ /dev/null
@@ -1,21 +0,0 @@
---- a/ffmpegaudio.cc.orig 2018-05-09 22:16:13.480659958 +0200
-+++ b/ffmpegaudio.cc      2018-05-09 22:16:50.748322790 +0200
-@@ -143,7 +143,7 @@
-     return false;
-   }
-
--  unsigned char * avioBuffer = ( unsigned char * )av_malloc( kBufferSize + FF_INPUT_BUFFER_PADDING_SIZE );
-+  unsigned char * avioBuffer = ( unsigned char * )av_malloc( kBufferSize + AV_INPUT_BUFFER_PADDING_SIZE );
-   if ( !avioBuffer )
-   {
-     errorString = QObject::tr( "av_malloc() failed." );
-@@ -380,7 +380,7 @@
-   }
-
-   if ( !Qt4x5::AtomicInt::loadAcquire( isCancelled_ ) &&
--       codecContext_->codec->capabilities & CODEC_CAP_DELAY )
-+       codecContext_->codec->capabilities & AV_CODEC_CAP_DELAY )
-   {
-     av_init_packet( &packet );
-     int gotFrame = 0;
-
diff --git a/srcpkgs/goldendict/patches/ffmpeg5.patch b/srcpkgs/goldendict/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..7cfc98ada368
--- /dev/null
+++ b/srcpkgs/goldendict/patches/ffmpeg5.patch
@@ -0,0 +1,232 @@
+From 03bbe01b79a1f07a6780cb60f23a087104c5d77b Mon Sep 17 00:00:00 2001
+From: Abs62 <ottomann@yandex.ru>
+Date: Fri, 30 Mar 2018 22:53:24 +0300
+Subject: [PATCH] Fix warnings while compile with FFMpeg 3.4.2 (issue #978)
+
+---
+ ffmpegaudio.cc | 68 +++++++++++++++++++++++++++++++++++++++++++++-----
+ 1 file changed, 62 insertions(+), 6 deletions(-)
+
+diff --git a/ffmpegaudio.cc b/ffmpegaudio.cc
+index ed1172bdd..56e8f788e 100644
+--- a/ffmpegaudio.cc
++++ b/ffmpegaudio.cc
+@@ -91,6 +91,7 @@ struct DecoderContext
+   QByteArray audioData_;
+   QDataStream audioDataStream_;
+   AVFormatContext * formatContext_;
++  AVCodec * codec_;
+   AVCodecContext * codecContext_;
+   AVIOContext * avioContext_;
+   AVStream * audioStream_;
+@@ -114,6 +115,7 @@ DecoderContext::DecoderContext( QByteArray const & audioData, QAtomicInt & isCan
+   audioData_( audioData ),
+   audioDataStream_( audioData_ ),
+   formatContext_( NULL ),
++  codec_( NULL ),
+   codecContext_( NULL ),
+   avioContext_( NULL ),
+   audioStream_( NULL ),
+@@ -143,7 +145,11 @@ bool DecoderContext::openCodec( QString & errorString )
+     return false;
+   }
+
++#if LIBAVCODEC_VERSION_MAJOR < 56 || ( LIBAVCODEC_VERSION_MAJOR == 56 && LIBAVCODEC_VERSION_MINOR < 56 )
+   unsigned char * avioBuffer = ( unsigned char * )av_malloc( kBufferSize + FF_INPUT_BUFFER_PADDING_SIZE );
++#else
++  unsigned char * avioBuffer = ( unsigned char * )av_malloc( kBufferSize + AV_INPUT_BUFFER_PADDING_SIZE );
++#endif
+   if ( !avioBuffer )
+   {
+     errorString = QObject::tr( "av_malloc() failed." );
+@@ -186,7 +192,11 @@ bool DecoderContext::openCodec( QString & errorString )
+   // Find audio stream, use the first audio stream if available
+   for ( unsigned i = 0; i < formatContext_->nb_streams; i++ )
+   {
++#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 33 )
+     if ( formatContext_->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO )
++#else
++      if ( formatContext_->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO )
++#endif
+     {
+       audioStream_ = formatContext_->streams[i];
+       break;
+@@ -198,22 +208,38 @@ bool DecoderContext::openCodec( QString & errorString )
+     return false;
+   }
+
++#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 33 )
+   codecContext_ = audioStream_->codec;
+-  AVCodec * codec = avcodec_find_decoder( codecContext_->codec_id );
+-  if ( !codec )
++  codec_ = avcodec_find_decoder( codecContext_->codec_id );
++  if ( !codec_ )
+   {
+     errorString = QObject::tr( "Codec [id: %1] not found." ).arg( codecContext_->codec_id );
+     return false;
+   }
++#else
++  codec_ = avcodec_find_decoder( audioStream_->codecpar->codec_id );
++  if ( !codec_ )
++  {
++    errorString = QObject::tr( "Codec [id: %1] not found." ).arg( audioStream_->codecpar->codec_id );
++    return false;
++  }
++  codecContext_ = avcodec_alloc_context3( codec_ );
++  if ( !codecContext_ )
++  {
++    errorString = QObject::tr( "avcodec_alloc_context3() failed." );
++    return false;
++  }
++  avcodec_parameters_to_context( codecContext_, audioStream_->codecpar );
++#endif
+
+-  ret = avcodec_open2( codecContext_, codec, NULL );
++  ret = avcodec_open2( codecContext_, codec_, NULL );
+   if ( ret < 0 )
+   {
+     errorString = QObject::tr( "avcodec_open2() failed: %1." ).arg( avErrorString( ret ) );
+     return false;
+   }
+
+-  av_log( NULL, AV_LOG_INFO, "Codec open: %s: channels: %d, rate: %d, format: %s\n", codec->long_name,
++  av_log( NULL, AV_LOG_INFO, "Codec open: %s: channels: %d, rate: %d, format: %s\n", codec_->long_name,
+           codecContext_->channels, codecContext_->sample_rate, av_get_sample_fmt_name( codecContext_->sample_fmt ) );
+   return true;
+ }
+@@ -252,10 +278,13 @@ void DecoderContext::closeCodec()
+
+   // Closing a codec context without prior avcodec_open2() will result in
+   // a crash in ffmpeg
+-  if ( audioStream_ && audioStream_->codec && audioStream_->codec->codec )
++  if ( audioStream_ && codecContext_ && codec_ )
+   {
+     audioStream_->discard = AVDISCARD_ALL;
+-    avcodec_close( audioStream_->codec );
++    avcodec_close( codecContext_ );
++#if LIBAVCODEC_VERSION_MAJOR > 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR >= 33 )
++    avcodec_free_context( &codecContext_ );
++#endif
+   }
+
+   avformat_close_input( &formatContext_ );
+@@ -356,6 +385,7 @@ bool DecoderContext::play( QString & errorString )
+     if ( packet.stream_index == audioStream_->index )
+     {
+       AVPacket pack = packet;
++#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 37 )
+       int gotFrame = 0;
+       do
+       {
+@@ -370,6 +400,19 @@ bool DecoderContext::play( QString & errorString )
+         pack.data += len;
+       }
+       while( pack.size > 0 );
++#else
++      int ret = avcodec_send_packet( codecContext_, &pack );
++      /* read all the output frames (in general there may be any number of them) */
++      while( ret >= 0 )
++      {
++        ret = avcodec_receive_frame( codecContext_, frame);
++
++        if ( Qt4x5::AtomicInt::loadAcquire( isCancelled_ ) || ret < 0 )
++          break;
++
++        playFrame( frame );
++      }
++#endif
+     }
+     // av_free_packet() must be called after each call to av_read_frame()
+ #if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 7 )
+@@ -379,6 +422,7 @@ bool DecoderContext::play( QString & errorString )
+ #endif
+   }
+
++#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 37 )
+   if ( !Qt4x5::AtomicInt::loadAcquire( isCancelled_ ) &&
+        codecContext_->codec->capabilities & CODEC_CAP_DELAY )
+   {
+@@ -391,6 +435,18 @@ bool DecoderContext::play( QString & errorString )
+       playFrame( frame );
+     }
+   }
++#else
++  /* flush the decoder */
++  av_init_packet( &packet );
++  int ret = avcodec_send_packet(codecContext_, &packet );
++  while( ret >= 0 )
++  {
++    ret = avcodec_receive_frame(codecContext_, frame);
++    if ( Qt4x5::AtomicInt::loadAcquire( isCancelled_ ) || ret < 0 )
++      break;
++    playFrame( frame );
++  }
++#endif
+
+ #if LIBAVCODEC_VERSION_MAJOR < 54
+   av_free( frame );
+32
+srcpkgs/goldendict/patches/ffmpeg5-2.patch
+Comment on this file
+@@ -0,0 +1,32 @@
+From 966f4a8b78e6324b930e5a50f2bb930bd87e565e Mon Sep 17 00:00:00 2001
+From: Abs62 <ottomann@yandex.ru>
+Date: Fri, 27 Sep 2019 17:00:52 +0300
+Subject: [PATCH] FFmpeg player: Fix some crashes on broken files
+
+---
+ ffmpegaudio.cc | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/ffmpegaudio.cc b/ffmpegaudio.cc
+index 56e8f788e..415fc79cb 100644
+--- a/ffmpegaudio.cc
++++ b/ffmpegaudio.cc
+@@ -51,7 +51,9 @@ AudioService & AudioService::instance()
+
+ AudioService::AudioService()
+ {
++#if LIBAVFORMAT_VERSION_MAJOR < 58 || ( LIBAVFORMAT_VERSION_MAJOR == 58 && LIBAVFORMAT_VERSION_MINOR < 9 )
+   av_register_all();
++#endif
+   ao_initialize();
+ }
+
+@@ -438,6 +440,8 @@ bool DecoderContext::play( QString & errorString )
+ #else
+   /* flush the decoder */
+   av_init_packet( &packet );
++  packet.data = NULL;
++  packet.size = 0;
+   int ret = avcodec_send_packet(codecContext_, &packet );
+   while( ret >= 0 )
+   {
+25
+srcpkgs/goldendict/patches/ffmpeg5-3.patch
+Comment on this file
+@@ -0,0 +1,25 @@
+From 8acb288c9e9bdb3c6bf2e803954dd3b6ac273c05 Mon Sep 17 00:00:00 2001
+From: Liao Junxuan <mikeljx@126.com>
+Date: Sun, 20 Feb 2022 12:28:05 +0800
+Subject: [PATCH] add support for ffmpeg 5.0
+
+---
+ ffmpegaudio.cc | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/ffmpegaudio.cc b/ffmpegaudio.cc
+index d550f4a77..7948d2187 100644
+--- a/ffmpegaudio.cc
++++ b/ffmpegaudio.cc
+@@ -94,7 +94,11 @@ struct DecoderContext
+   QByteArray audioData_;
+   QDataStream audioDataStream_;
+   AVFormatContext * formatContext_;
++#if LIBAVCODEC_VERSION_MAJOR < 59
+   AVCodec * codec_;
++#else
++  const AVCodec * codec_;
++#endif
+   AVCodecContext * codecContext_;
+   AVIOContext * avioContext_;
+   AVStream * audioStream_;
diff --git a/srcpkgs/goldendict/template b/srcpkgs/goldendict/template
index 4544ae710ee6..2ca4185e538a 100644
--- a/srcpkgs/goldendict/template
+++ b/srcpkgs/goldendict/template
@@ -9,7 +9,7 @@ makedepends="tiff-devel qt5-devel libvorbis-devel zlib-devel
  libXtst-devel hunspell-devel qt5-tools-devel qt5-declarative-devel
  qt5-webkit-devel lzo-devel bzip2-devel libao-devel qt5-svg-devel
  libeb-devel qt5-x11extras-devel ffmpeg-devel liblzma-devel"
-short_desc="A feature-rich dictionary lookup program"
+short_desc="Feature-rich dictionary lookup program"
 maintainer="John <me@johnnynator.dev>"
 license="GPL-3.0-or-later"
 homepage="http://goldendict.org/"

From 7d398cd286b6e22925247c6ec580b0484844fd28 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 040/130] gst-libav: revbump for ffmpeg-6.0

---
 srcpkgs/gst-libav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index e9a79dc650a5..f082bd211c65 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.20.3
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"

From 32630cb243147451a602f2d7d6f89a25821b7971 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 041/130] gst-plugins-bad1: revbump for ffmpeg-6.0

---
 srcpkgs/gst-plugins-bad1/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index f55f82fd4c77..5a9d5387e0d4 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-plugins-bad1'
 pkgname=gst-plugins-bad1
-version=1.20.3
-revision=3
+version=1.22.1
+revision=2
 build_helper="gir"
 build_style=meson
 configure_args="-Dpackage-origin=https://voidlinux.org -Ddoc=disabled

From 53fee738687fe8fd2896c8300dea3bd822873407 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 042/130] gst-rtsp-server: revbump for ffmpeg-6.0

---
 srcpkgs/gst-rtsp-server/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index 33cd64ceb95e..8ceea8d34b4b 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
 version=1.20.3
-revision=2
+revision=3
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="glib-devel gst-plugins-bad1-devel gobject-introspection

From a6400cfa1bc4aa203d8e14b04ebd9cd9429c2e42 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 043/130] guvcview: update to 2.0.8.

---
 srcpkgs/guvcview/patches/fix-include.patch | 10 ++++++++++
 srcpkgs/guvcview/template                  |  5 ++---
 2 files changed, 12 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/guvcview/patches/fix-include.patch

diff --git a/srcpkgs/guvcview/patches/fix-include.patch b/srcpkgs/guvcview/patches/fix-include.patch
new file mode 100644
index 000000000000..503c2af3b78c
--- /dev/null
+++ b/srcpkgs/guvcview/patches/fix-include.patch
@@ -0,0 +1,10 @@
+--- a/guvcview/guvcview.c
++++ b/guvcview/guvcview.c
+@@ -28,6 +28,7 @@
+ #include <sys/stat.h>
+ #include <sys/resource.h>
+ #include <errno.h>
++#include <locale.h>
+ 
+ #include "gview.h"
+ #include "gviewv4l2core.h"
diff --git a/srcpkgs/guvcview/template b/srcpkgs/guvcview/template
index 345cf6006f24..86a7fd619612 100644
--- a/srcpkgs/guvcview/template
+++ b/srcpkgs/guvcview/template
@@ -1,8 +1,7 @@
 # Template file for 'guvcview'
 pkgname=guvcview
-version=2.0.7
+version=2.0.8
 revision=1
-create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-static --disable-debian-menu"
 hostmakedepends="pkg-config intltool autoconf automake libtool glib-devel"
@@ -14,7 +13,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="http://guvcview.sourceforge.net/"
 distfiles="${SOURCEFORGE_SITE}/${pkgname}/${pkgname}-src-${version}.tar.bz2"
-checksum=f47d51fbd06e44eeaa1a82f4a153c927527c90d94514197a70b2956028cc8ad4
+checksum=a21f4e448286666cf27bafef5290cc953a0a1796b752e5bbe521266dc1230c81
 
 post_patch() {
 	sed '31a#include <locale.h>' -i  guvcview/guvcview.c

From fdf02069028eeacf58bdc7825a2e6d9c8c5fb5e6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 044/130] handbrake: update to 1.6.1

---
 .../patches/fix-missing-x265-link-flag.patch    | 11 ++++++-----
 .../handbrake/patches/libhb-vpl-include.patch   | 15 +++++++++++++++
 srcpkgs/handbrake/template                      | 17 ++++++++++-------
 3 files changed, 31 insertions(+), 12 deletions(-)
 create mode 100644 srcpkgs/handbrake/patches/libhb-vpl-include.patch

diff --git a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
index 26db03867a0c..d6bb2eda627a 100644
--- a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
+++ b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
@@ -1,14 +1,15 @@
 --- a/gtk/configure.ac
 +++ b/gtk/configure.ac
 @@ -203,7 +203,7 @@
- 
+
  AM_CONDITIONAL([MINGW], [test "x$mingw_flag" = "xyes"])
- 
--HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg"
-+HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -ldl"
+
+-HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc"
++HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc -ldl"
  HB_CPPFLAGS="$HB_CPPFLAGS $HBINC"
- 
+
  PKG_CHECK_MODULES([x264], [x264], sys_x264=yes, sys_x264=no)
+
 --- a/test/module.defs
 +++ b/test/module.defs
 @@ -69,6 +69,9 @@
diff --git a/srcpkgs/handbrake/patches/libhb-vpl-include.patch b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
new file mode 100644
index 000000000000..298f9f4ab28f
--- /dev/null
+++ b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
@@ -0,0 +1,15 @@
+--- a/libhb/module.defs	2023-01-22 11:36:49.000000000 -0500
++++ b/libhb/module.defs	2023-04-03 22:37:52.395467010 -0400
+@@ -46,11 +46,7 @@
+ LIBHB.GCC.I += $(LIBHB.build/) $(CONTRIB.build/)include
+ 
+ ifeq (1,$(FEATURE.qsv))
+-    ifeq ($(HOST.system),freebsd))
+-        LIBHB.GCC.I += $(LOCALBASE)/include/vpl
+-    else
+-        LIBHB.GCC.I += $(CONTRIB.build/)include/vpl
+-    endif
++    LIBHB.GCC.I += /usr/include/vpl
+ endif
+ 
+ ifneq (,$(filter $(HOST.system),freebsd netbsd openbsd))
diff --git a/srcpkgs/handbrake/template b/srcpkgs/handbrake/template
index ca5e4571e49c..c32cb1bfa31f 100644
--- a/srcpkgs/handbrake/template
+++ b/srcpkgs/handbrake/template
@@ -1,10 +1,10 @@
 # Template file for 'handbrake'
 pkgname=handbrake
-version=1.5.1
+version=1.6.1
 revision=1
 build_style=gnu-configure
 configure_args="--force --disable-gtk-update-checks --disable-df-fetch --harden
- $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc)"
+ $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc) $(vopt_enable qsv)"
 make_build_args="-C ${XBPS_TRIPLET}"
 make_install_args="-C ${XBPS_TRIPLET}"
 hostmakedepends="automake cmake gettext-devel glib-devel intltool libtool m4 meson nasm pkg-config python3"
@@ -12,8 +12,11 @@ makedepends="bzip2-devel ffmpeg-devel gst-plugins-base1-devel gtk+3-devel
  jansson-devel lame-devel libass-devel libbluray-devel libdav1d-devel
  libdvdnav-devel libdvdread-devel libgudev-devel libnuma-devel
  libsamplerate-devel libtheora-devel libvorbis-devel libvpx-devel libxml2-devel
- opus-devel speex-devel x264-devel x265-devel zimg-devel
+ opus-devel speex-devel x264-devel x265-devel zimg-devel libsvt-av1-devel
  $(vopt_if fdk_aac fdk-aac-devel)
+ $(vopt_if qsv libva-devel)
+ $(vopt_if qsv libdrm-devel)
+ $(vopt_if qsv onevpl-devel)
  $(vopt_if nvenc nv-codec-headers)"
 depends="desktop-file-utils gst-plugins-good1 hicolor-icon-theme"
 short_desc="Multithreaded video transcoder"
@@ -21,15 +24,15 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-2.0-only"
 homepage="https://handbrake.fr/"
 distfiles="https://github.com/HandBrake/HandBrake/releases/download/${version}/HandBrake-${version}-source.tar.bz2"
-checksum=3999fe06d5309c819799a73a968a8ec3840e7840c2b64af8f5cdb7fd8c9430f0
+checksum=94ccfe03db917a91650000c510f7fd53f844da19f19ad4b4be1b8f6bc31a8d4c
 nocross=yes
 
-build_options="fdk_aac nvenc"
+build_options="fdk_aac nvenc qsv"
 
 case "$XBPS_TARGET_MACHINE" in
 	x86_64*|i686*)
 		CFLAGS="-msse"
-		build_options_default="nvenc"
+		build_options_default="nvenc qsv"
 		;;
 esac
 
@@ -37,7 +40,7 @@ pre_configure() {
 	# use system libraries, don't download them
 	rm -rf contrib/
 	for module in fdk-aac ffmpeg libbluray libdav1d libdvdnav libdvdread nvenc \
-		x265 zimg; do
+		x265 zimg svt-av1 libvpl; do
 	    vsed -i "/MODULES += contrib\/${module}/d" make/include/main.defs
 	done
 }

From bc2255e2e79f55ecb68171082b9f76e2585ce737 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 045/130] hedgewars: revbump for ffmpeg4-4.4.3

---
 srcpkgs/hedgewars/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/hedgewars/template b/srcpkgs/hedgewars/template
index 419f29b98b44..926fe4fe3e68 100644
--- a/srcpkgs/hedgewars/template
+++ b/srcpkgs/hedgewars/template
@@ -1,13 +1,13 @@
 # Template file for 'hedgewars'
 pkgname=hedgewars
 version=1.0.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DNOSERVER=1 -DDATA_INSTALL_DIR=/usr/share/${pkgname}
  -DPHYSFS_SYSTEM=1 -DMINIMAL_FLAGS=1"
 make_cmd=make
 hostmakedepends="lua51 pkg-config qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
+makedepends="ffmpeg4-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
  SDL2_mixer-devel SDL2_net-devel SDL2_ttf-devel"
 depends="libfreeglut"
 short_desc="Funny turn-based artillery game, featuring fighting Hedgehogs!"

From 9d1d459dbc95409d29ad1bac85aebf2bb4c399b0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 046/130] idjc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/idjc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/idjc/template b/srcpkgs/idjc/template
index df60318b3db9..36a75baf597c 100644
--- a/srcpkgs/idjc/template
+++ b/srcpkgs/idjc/template
@@ -1,11 +1,11 @@
 # Template file for 'idjc'
 pkgname=idjc
 version=0.9.1
-revision=3
+revision=4
 build_style=gnu-configure
 hostmakedepends="pkg-config git python3 automake gettext-devel libtool"
 makedepends="libvorbis-devel libogg-devel jack-devel libsamplerate-devel
- libflac-devel libsndfile-devel mpg123-devel ffmpeg-devel speex-devel
+ libflac-devel libsndfile-devel mpg123-devel ffmpeg4-devel speex-devel
  glib-devel pixman-devel lame-devel python3-gobject-devel libshout-idjc-devel
  opus-devel twolame-devel python3-mutagen python3-devel"
 depends="python3-gobject python3-mutagen desktop-file-utils shared-mime-info python3-dbus jack"

From 3f928f7428ba5ea94fd367b9277b2e2cb685c2cc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 047/130] kfilemetadata5: revbump for ffmpeg-6.0

---
 srcpkgs/kfilemetadata5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kfilemetadata5/template b/srcpkgs/kfilemetadata5/template
index 8980121fbc69..f662a2043f93 100644
--- a/srcpkgs/kfilemetadata5/template
+++ b/srcpkgs/kfilemetadata5/template
@@ -1,7 +1,7 @@
 # Template file for 'kfilemetadata5'
 pkgname=kfilemetadata5
 version=5.105.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="kcoreaddons extra-cmake-modules pkg-config qt5-host-tools qt5-qmake
  gettext kcoreaddons python3"

From 371cd612b32c8686d46748955936e662f7801e03 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 048/130] kid3: revbump for ffmpeg-6.0

---
 srcpkgs/kid3/patches/ffmpeg5.patch | 17 +++++++++++++++++
 srcpkgs/kid3/template              |  2 +-
 2 files changed, 18 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/kid3/patches/ffmpeg5.patch

diff --git a/srcpkgs/kid3/patches/ffmpeg5.patch b/srcpkgs/kid3/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..135fc50e07c9
--- /dev/null
+++ b/srcpkgs/kid3/patches/ffmpeg5.patch
@@ -0,0 +1,17 @@
+# https://aur.archlinux.org/cgit/aur.git/diff/ffmpeg5.patch?h=kid3-cli&id=12410a74906612e7efc0ec8fbce739b4a0fef7e7
+diff --git a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+index e156d424..e12b9abd 100644
+--- a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
++++ b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+@@ -232,7 +232,11 @@ private:
+   friend class Format;
+   friend class Converter;
+   AVCodecContext* m_ptr;
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 0, 0)
+   AVCodec* m_impl;
++#else
++  const AVCodec* m_impl;
++#endif
+   AVFrame* m_frame;
+   bool m_opened;
+ };
diff --git a/srcpkgs/kid3/template b/srcpkgs/kid3/template
index 456206d90e16..f32f9decb0e7 100644
--- a/srcpkgs/kid3/template
+++ b/srcpkgs/kid3/template
@@ -1,7 +1,7 @@
 # Template file for 'kid3'
 pkgname=kid3
 version=3.9.1
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DWITH_APPS='CLI;$(vopt_if KDE KDE Qt)'
  -DWITH_DOCBOOKDIR=/usr/share/xsl/docbook -DWITH_FLAC=$(vopt_if flac ON OFF)

From 61afb904246d983debeed8c02da3e892c6a37328 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 049/130] kodi: revbump for ffmpeg4-4.4.3

---
 srcpkgs/kodi/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/kodi/template b/srcpkgs/kodi/template
index 8057964d78a3..6cc1874be7ba 100644
--- a/srcpkgs/kodi/template
+++ b/srcpkgs/kodi/template
@@ -1,7 +1,7 @@
 # Template file for 'kodi'
 pkgname=kodi
 version=19.4
-revision=6
+revision=7
 _codename="Matrix"
 build_style=cmake
 configure_args="-DWITH_FFMPEG=/usr -DENABLE_LDGOLD=OFF
@@ -54,7 +54,7 @@ makedepends="
  libmad-devel fontconfig-devel libXinerama-devel libsamplerate-devel libmms-devel
  enca-devel boost-devel libcurl-devel libva-devel libvdpau-devel libass-devel
  libbluetooth-devel yajl-devel libplist-devel librtmp-devel tinyxml-devel
- taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg-devel
+ taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg4-devel
  giflib-devel libxslt-devel gnutls-devel libssh-devel libmicrohttpd-devel
  libcec-devel dcadec-devel flatbuffers-devel fmt-devel lcms2-devel
  libfstrcmp-devel rapidjson libcdio-paranoia spdlog libwaylandpp-devel

From e1c52794a0b6e3ad8ee8b41919b0e16107087d06 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 050/130] kpipewire: revbump for ffmpeg-6.0

---
 srcpkgs/kpipewire/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kpipewire/template b/srcpkgs/kpipewire/template
index 467ab823a5e1..51827f24db9e 100644
--- a/srcpkgs/kpipewire/template
+++ b/srcpkgs/kpipewire/template
@@ -1,7 +1,7 @@
 # Template file for 'kpipewire'
 pkgname=kpipewire
 version=5.27.4
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules plasma-wayland-protocols gettext
  qt5-qmake qt5-host-tools pkg-config wayland-devel kcoreaddons

From b03af67a50d20cf146e22f133c658e3ec0dade18 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 051/130] libextractor: revbump for ffmpeg4-4.4.3

---
 srcpkgs/libextractor/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libextractor/template b/srcpkgs/libextractor/template
index ddd4790f93e8..1fb9ca56a96a 100644
--- a/srcpkgs/libextractor/template
+++ b/srcpkgs/libextractor/template
@@ -7,7 +7,7 @@ configure_args="--disable-static"
 hostmakedepends="pkg-config"
 makedepends="zlib-devel bzip2-devel exiv2-devel tiff-devel libpng-devel
  libjpeg-turbo-devel libvorbis-devel libflac-devel giflib-devel libmpeg2-devel
- ffmpeg-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
+ ffmpeg4-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
 short_desc="Library used to extract meta data from files"
 maintainer="Martin Riese <grauehaare@gmx.de>"
 license="GPL-3.0-or-later"

From df50383e265c2289cd46743fe699d4725d92e57e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 052/130] libopenal: revbump for ffmpeg-6.0

---
 srcpkgs/libopenal/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenal/template b/srcpkgs/libopenal/template
index 77218f9e539d..3f49ed75a1fd 100644
--- a/srcpkgs/libopenal/template
+++ b/srcpkgs/libopenal/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenal'
 pkgname=libopenal
 version=1.22.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DALSOFT_EXAMPLES=OFF"
 hostmakedepends="pkg-config"

From 0353b6f44b6099de27824920ba2150110b2a255d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 053/130] libopenshot: revbump for ffmpeg-6.0

---
 srcpkgs/libopenshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenshot/template b/srcpkgs/libopenshot/template
index db831f69b474..81aa0d7136d9 100644
--- a/srcpkgs/libopenshot/template
+++ b/srcpkgs/libopenshot/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenshot'
 pkgname=libopenshot
 version=0.3.0
-revision=1
+revision=2
 build_style=cmake
 # Builds fail with Ruby-2.4.1
 configure_args="-DENABLE_RUBY=OFF -DUSE_SYSTEM_JSONCPP=ON"

From 1fd7f1d30239c7d4255c763933b66fcd5a3d7ef4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 054/130] loudgain: revbump for ffmpeg-6.0

---
 srcpkgs/loudgain/patches/ffmpeg5.patch | 11 +++++++++++
 srcpkgs/loudgain/template              |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/loudgain/patches/ffmpeg5.patch

diff --git a/srcpkgs/loudgain/patches/ffmpeg5.patch b/srcpkgs/loudgain/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..16d4510ee98f
--- /dev/null
+++ b/srcpkgs/loudgain/patches/ffmpeg5.patch
@@ -0,0 +1,11 @@
+--- a/src/scan.c	2019-09-06 11:31:19.000000000 -0400
++++ b/src/scan.c	2023-03-23 11:15:40.867968521 -0400
+@@ -69,8 +69,6 @@
+ 	 * It is now useless
+ 	 * https://github.com/FFmpeg/FFmpeg/blob/70d25268c21cbee5f08304da95be1f647c630c15/doc/APIchanges#L86
+ 	 */
+-  if (avformat_version() < AV_VERSION_INT(58,9,100))
+-    av_register_all();
+ 
+ 	av_log_set_callback(scan_av_log);
+ 
diff --git a/srcpkgs/loudgain/template b/srcpkgs/loudgain/template
index da4f2d56e94c..4d6bf29efb4f 100644
--- a/srcpkgs/loudgain/template
+++ b/srcpkgs/loudgain/template
@@ -1,7 +1,7 @@
 # Template file for 'loudgain'
 pkgname=loudgain
 version=0.6.8
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libebur128-devel taglib-devel ffmpeg-devel"

From 0f4dc1b5d3b60b94b29bac5fbdfda3d6e13d560e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 055/130] mediastreamer: revbump for ffmpeg4-4.4.3

---
 srcpkgs/mediastreamer/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mediastreamer/template b/srcpkgs/mediastreamer/template
index d0e97e858e29..1bde031443a5 100644
--- a/srcpkgs/mediastreamer/template
+++ b/srcpkgs/mediastreamer/template
@@ -1,11 +1,11 @@
 # Template file for 'mediastreamer'
 pkgname=mediastreamer
 version=5.2.6
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_STRICT=0 -DENABLE_UNIT_TESTS=0"
 hostmakedepends="python3"
-makedepends="bzrtp-devel ffmpeg-devel glew-devel libXv-devel libsrtp-devel
+makedepends="bzrtp-devel ffmpeg4-devel glew-devel libXv-devel libsrtp-devel
  libupnp-devel libvpx-devel mbedtls-devel opus-devel ortp-devel pulseaudio-devel
  libtheora-devel speex-devel v4l-utils-devel bcg729-devel bcmatroska2-devel libgsm-devel"
 # zxing-cpp-devel (1.2.0 probably not compatible, check again after updaing xzing)

From 138bc14ebf333f30e1e2101ab30afaac832df141 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 056/130] mgba: revbump for ffmpeg-6.0

---
 srcpkgs/mgba/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mgba/template b/srcpkgs/mgba/template
index ae0504311eee..d31295a0cd3d 100644
--- a/srcpkgs/mgba/template
+++ b/srcpkgs/mgba/template
@@ -1,7 +1,7 @@
 # Template file for 'mgba'
 pkgname=mgba
 version=0.10.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake desktop-file-utils"
 makedepends="SDL2-devel ffmpeg-devel libedit-devel libepoxy-devel libmagick-devel

From f75acfadd38a353b6ecd7e9f3b69a5bd13e11e17 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 057/130] minidlna: revbump for ffmpeg-6.0

---
 srcpkgs/minidlna/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/minidlna/template b/srcpkgs/minidlna/template
index e8081b1cbc67..9ee9714861fd 100644
--- a/srcpkgs/minidlna/template
+++ b/srcpkgs/minidlna/template
@@ -1,7 +1,7 @@
 # Template file for 'minidlna'
 pkgname=minidlna
 version=1.3.2
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="
  --sbindir=/usr/bin

From 699fd1cee259b79098be209e1614706dce560d0c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 058/130] mixxx: revbump for ffmpeg-6.0

---
 srcpkgs/mixxx/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mixxx/template b/srcpkgs/mixxx/template
index 619ddca0d332..4b9ea00d3fb3 100644
--- a/srcpkgs/mixxx/template
+++ b/srcpkgs/mixxx/template
@@ -1,7 +1,7 @@
 # Template file for 'mixxx'
 pkgname=mixxx
 version=2.3.3
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="extra-cmake-modules pkg-config protobuf qt5-host-tools qt5-devel"

From c4f98926577c8592593634403ee0a9b151bedcaf Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 059/130] mlt: revbump for ffmpeg4-4.4.3

---
 srcpkgs/mlt/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mlt/template b/srcpkgs/mlt/template
index 8933eb4e7bb9..73353fedafb5 100644
--- a/srcpkgs/mlt/template
+++ b/srcpkgs/mlt/template
@@ -1,14 +1,14 @@
 # Template file for 'mlt'
 pkgname=mlt
 version=6.26.1
-revision=1
+revision=2
 build_style=configure
 configure_args="--prefix=/usr --libdir=/usr/lib$XBPS_TARGET_WORDSIZE
  --enable-gpl --enable-gpl3 --disable-swfdec --without-kde
  --swig-languages=python"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which"
 # XXX: movit vid.stab
-makedepends="alsa-lib-devel ffmpeg-devel gtk+-devel jack-devel ladspa-sdk
+makedepends="alsa-lib-devel ffmpeg4-devel gtk+-devel jack-devel ladspa-sdk
  libexif-devel libsamplerate-devel libxml2-devel sox-devel SDL_image-devel
  fftw-devel frei0r-plugins python3-devel pulseaudio-devel movit-devel
  libvidstab-devel libatomic-devel"

From dd538e534b5c67d5245cacc14727f059483b73dc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 060/130] moc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/moc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/moc/template b/srcpkgs/moc/template
index c42be650a1d2..d4f0eefbad52 100644
--- a/srcpkgs/moc/template
+++ b/srcpkgs/moc/template
@@ -1,10 +1,10 @@
 # Template file for 'moc'
 pkgname=moc
 version=2.5.2
-revision=6
+revision=7
 build_style=gnu-configure
 hostmakedepends="pkg-config"
-makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg-devel
+makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg4-devel
  jack-devel alsa-lib-devel libltdl-devel libflac-devel libvorbis-devel
  libmad-devel libmpcdec-devel libmodplug-devel libid3tag-devel faad2-devel
  taglib-devel libsndfile-devel wavpack-devel speex-devel libsamplerate-devel

From 57cf5902a476c912b7325800c3296de92f926abf Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 061/130] motion: revbump for ffmpeg-6.0

---
 srcpkgs/motion/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/motion/template b/srcpkgs/motion/template
index 3cf3c3035c5b..7dca12d851e3 100644
--- a/srcpkgs/motion/template
+++ b/srcpkgs/motion/template
@@ -1,7 +1,7 @@
 # Template file for 'motion'
 pkgname=motion
 version=4.5.1
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake pkg-config gettext-devel tar"
 makedepends="ffmpeg-devel libmicrohttpd-devel v4l-utils-devel gettext-devel"

From 31a6f2e7ec900f70d634fcf6a705e32cb22b211b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 062/130] mpv: revbump for ffmpeg-6.0

---
 srcpkgs/mpv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpv/template b/srcpkgs/mpv/template
index e163c496c6eb..d4fefbf5e3c7 100644
--- a/srcpkgs/mpv/template
+++ b/srcpkgs/mpv/template
@@ -1,7 +1,7 @@
 # Template file for 'mpv'
 pkgname=mpv
 version=0.35.1
-revision=2
+revision=3
 build_style=meson
 configure_args="-Dcdda=enabled -Ddvbin=enabled -Ddvdnav=enabled
  -Dlibmpv=true -Dcplugins=enabled

From 86fc1c173567bcae442c969a91ec348d61cc4c96 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 063/130] musikcube: revbump for ffmpeg-6.0

---
 srcpkgs/musikcube/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/musikcube/template b/srcpkgs/musikcube/template
index 4b7930041126..7cd65cf76b77 100644
--- a/srcpkgs/musikcube/template
+++ b/srcpkgs/musikcube/template
@@ -1,7 +1,7 @@
 # Template file for 'musikcube'
 pkgname=musikcube
 version=0.99.4
-revision=1
+revision=2
 build_style=cmake
 make_cmd=make
 configure_args="-DNO_NCURSESW=1"

From 408659e0c076564e0ceb705814fe4cf09f9d9a5d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 064/130] notcurses: revbump for ffmpeg-6.0

---
 srcpkgs/notcurses/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/notcurses/template b/srcpkgs/notcurses/template
index 6dd8a091319f..3110c30c9aff 100644
--- a/srcpkgs/notcurses/template
+++ b/srcpkgs/notcurses/template
@@ -1,7 +1,7 @@
 # Template file for 'notcurses'
 pkgname=notcurses
 version=3.0.9
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DUSE_STATIC=ON $(vopt_bool man USE_PANDOC)"
 hostmakedepends="pkg-config $(vopt_if man pandoc)"

From 8ae0ad0ba65f21a43c9d480ed6ba1f2e3e4c88d3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 065/130] obs: revbump for ffmpeg-6.0

---
 srcpkgs/obs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/obs/template b/srcpkgs/obs/template
index 89fd11297c3f..3cf49e414bf3 100644
--- a/srcpkgs/obs/template
+++ b/srcpkgs/obs/template
@@ -1,7 +1,7 @@
 # Template file for 'obs'
 pkgname=obs
 version=29.1.0
-revision=1
+revision=2
 archs="i686* x86_64* ppc64le* aarch64*"
 build_style=cmake
 configure_args="-DOBS_VERSION_OVERRIDE=${version} -DENABLE_JACK=ON

From 79ddcb5a840212dc4d5270609d0ab5e13c4db873 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 066/130] olive: revbump for ffmpeg4-4.4.3

---
 srcpkgs/olive/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/olive/template b/srcpkgs/olive/template
index 12a46936c990..5c2917b9c512 100644
--- a/srcpkgs/olive/template
+++ b/srcpkgs/olive/template
@@ -1,10 +1,10 @@
 # Template file for 'olive'
 pkgname=olive
 version=0.1.2
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools pkg-config"
-makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg-devel frei0r-plugins"
+makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg4-devel frei0r-plugins"
 short_desc="Non-linear video editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"

From 0b87b076c92d42447dd26377c985603d170050bf Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 067/130] omxplayer: revbump for ffmpeg4-4.4.3

---
 srcpkgs/omxplayer/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/omxplayer/template b/srcpkgs/omxplayer/template
index e70bf7873d4d..0e9bc70e7c8e 100644
--- a/srcpkgs/omxplayer/template
+++ b/srcpkgs/omxplayer/template
@@ -1,10 +1,10 @@
 # Template file for 'omxplayer'
 pkgname=omxplayer
 version=20190102
-revision=1
+revision=2
 short_desc="Commandline OMX player for the Raspberry Pi"
 maintainer="Orphaned <orphan@voidlinux.org>"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://github.com/popcornmix/omxplayer"
 
 _commit="f06235cc9690a6d58187514452df8cf8fcdaacec"
@@ -15,7 +15,7 @@ checksum=af2d9450f8947842ea8c401fe9f71eec444013ebbdee29f2ac828c9c493c1329
 archs="armv6l* armv7l*"
 build_style=gnu-makefile
 hostmakedepends="curl pkg-config"
-makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg-devel dbus-devel"
+makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg4-devel dbus-devel"
 depends="freefont-ttf"
 
 do_build() {

From 1a11d959c884c346c5e1064d23682bd21fd8686f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 068/130] openimageio: revbump for ffmpeg-6.0

---
 common/shlibs                | 2 ++
 srcpkgs/openimageio/template | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/shlibs b/common/shlibs
index 4626cfda810b..d0d328b09ef9 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2262,6 +2262,8 @@ libxmp.so.4 libxmp-4.3.7_1
 libKF5ThreadWeaver.so.5 threadweaver-5.26.0_1
 libOpenImageIO_Util.so.2.4 openimageio-2.4.9.0_1
 libOpenImageIO.so.2.4 openimageio-2.4.9.0_1
+libOpenImageIO_Util.so.2.4 openimageio-2.4.8.1_1
+libOpenImageIO.so.2.4 openimageio-2.4.8.1_1
 libOpenColorIO.so.2.1 opencolorio-2.1.2_1
 libpystring.so.1 pystring-1.1.3_1
 libyaml-cpp.so.0.7 yaml-cpp-0.7.0_1
diff --git a/srcpkgs/openimageio/template b/srcpkgs/openimageio/template
index b661bbf7ba57..9b38ace50f7e 100644
--- a/srcpkgs/openimageio/template
+++ b/srcpkgs/openimageio/template
@@ -1,7 +1,7 @@
 # Template file for 'openimageio'
 pkgname=openimageio
 version=2.4.9.0
-revision=2
+revision=3
 build_style=cmake
 build_helper=qemu
 configure_args="-DUSE_QT=0 -DUSE_PYTHON=0 -DOIIO_BUILD_TESTS=0

From 3026e678068d54d93aebf877ce36d8fee72269a9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 069/130] openmw: revbump for ffmpeg-6.0

---
 srcpkgs/openmw/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openmw/template b/srcpkgs/openmw/template
index 5251a0283dc1..e3771c7aaf1a 100644
--- a/srcpkgs/openmw/template
+++ b/srcpkgs/openmw/template
@@ -1,7 +1,7 @@
 # Template file for 'openmw'
 pkgname=openmw
 version=0.47.0
-revision=4
+revision=5
 build_style=cmake
 _recast_commit=e75adf86f91eb3082220085e42dda62679f9a3ea
 _bullet_tag=3.17

From 022169bb0f72ad568fa8f3e5c8cac4b7fa55be0e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 070/130] openshot: revbump for ffmpeg-6.0

---
 srcpkgs/openshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openshot/template b/srcpkgs/openshot/template
index 322717d40abc..c074e0338773 100644
--- a/srcpkgs/openshot/template
+++ b/srcpkgs/openshot/template
@@ -1,7 +1,7 @@
 # Template file for 'openshot'
 pkgname=openshot
 version=3.0.0
-revision=1
+revision=2
 build_style=python3-module
 hostmakedepends="python3 python3-setuptools"
 makedepends="ffmpeg-devel python3-PyQt5"

From 5610dc8aba6649bcd39c3ddfa1bfc5a190347145 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 071/130] opentoonz: revbump for ffmpeg-6.0

---
 srcpkgs/opentoonz/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/opentoonz/template b/srcpkgs/opentoonz/template
index ee9f7603f55f..3e81834ca0ed 100644
--- a/srcpkgs/opentoonz/template
+++ b/srcpkgs/opentoonz/template
@@ -1,7 +1,7 @@
 # Template file for 'opentoonz'
 pkgname=opentoonz
 version=1.6.0
-revision=2
+revision=3
 build_wrksrc="toonz/sources"
 build_style=cmake
 make_cmd=make

From 0c13172e51699fe67cfb8743be727f109708b0cd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 072/130] pianobar: revbump for ffmpeg-6.0

---
 srcpkgs/pianobar/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pianobar/template b/srcpkgs/pianobar/template
index a9b29e91993f..81efcd122c4d 100644
--- a/srcpkgs/pianobar/template
+++ b/srcpkgs/pianobar/template
@@ -1,7 +1,7 @@
 # Template file for 'pianobar'
 pkgname=pianobar
 version=2022.04.01
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="V=1"
 hostmakedepends="pkg-config"

From a9bf6c2d4099cc48888b533e15368fc721c6eb4c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 073/130] ppsspp: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ppsspp/template | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/ppsspp/template b/srcpkgs/ppsspp/template
index 7984a733d4be..15a42fd2c993 100644
--- a/srcpkgs/ppsspp/template
+++ b/srcpkgs/ppsspp/template
@@ -1,7 +1,7 @@
 # Template file for 'ppsspp'
 pkgname=ppsspp
 version=1.14.4
-revision=1
+revision=2
 _glslang_commit=dc11adde23c455a24e13dd54de9b4ede8bdd7db8
 _SPIRV_Cross_commit=9acb9ec31f5a8ef80ea6b994bb77be787b08d3d1
 _armips_commit=6719edebaae03330ee5441d9b28280672edf00d5
@@ -13,7 +13,7 @@ configure_args="-DHEADLESS=1 -DUSE_SYSTEM_FFMPEG=1 -DUNITTEST=ON
  -DUSING_QT_UI=$(vopt_if qt ON OFF) -DUSE_SYSTEM_ZSTD=ON
  -DARMIPS_USE_STD_FILESYSTEM=ON"
 hostmakedepends="pkg-config python3 $(vopt_if qt qt5-host-tools)"
-makedepends="zlib-devel glew-devel ffmpeg-devel libzip-devel
+makedepends="zlib-devel glew-devel ffmpeg4-devel libzip-devel
  snappy-devel rapidjson libpng-devel libzstd-devel
  $(vopt_if sdl2 SDL2-devel) $(vopt_if wayland wayland-devel)
  $(vopt_if qt 'qt5-devel qt5-multimedia-devel')"
@@ -62,13 +62,12 @@ post_extract() {
 	mv ${wrksrc}/miniupnp-${_miniupnp_commit} ${wrksrc}/ext/miniupnp
 }
 
-post_patch(){
+post_patch() {
 	# disable git versioning
 	vsed -e 's|find_package(Git)|# &|' -i git-version.cmake
 }
 
 do_install() {
-	vlicense LICENSE.TXT
 	vinstall icons/icon.svg 644 usr/share/pixmaps ppsspp.svg
 	vinstall Qt/PPSSPP.desktop 644 usr/share/applications
 	vbin build/PPSSPPHeadless ppsspp-headless

From 94edb0bf9d442ca44546dd97b5ccd2fe332de92d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 074/130] pqiv: revbump for ffmpeg-6.0

---
 srcpkgs/pqiv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pqiv/template b/srcpkgs/pqiv/template
index 542fc27a2d32..9308d949b6a1 100644
--- a/srcpkgs/pqiv/template
+++ b/srcpkgs/pqiv/template
@@ -1,7 +1,7 @@
 # Template file for 'pqiv'
 pkgname=pqiv
 version=2.12
-revision=1
+revision=2
 build_style=gnu-makefile
 hostmakedepends="pkg-config"
 makedepends="glib-devel gtk+3-devel $(vopt_if ffmpeg ffmpeg-devel)

From 85a642c07b68e57e8ee76cdc50bd4ac4c7278b24 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 075/130] qmmp: revbump for ffmpeg-6.0

---
 srcpkgs/qmmp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qmmp/template b/srcpkgs/qmmp/template
index 26c661ed16be..a150d7441c7a 100644
--- a/srcpkgs/qmmp/template
+++ b/srcpkgs/qmmp/template
@@ -1,7 +1,7 @@
 # Template file for 'qmmp'
 pkgname=qmmp
 version=1.6.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DUSE_HAL:BOOL=FALSE -DQMMP_DEFAULT_UI:STRING=simple"
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From 168c9e6bf95c3e1703c0850b7d3ea42ac142ad1a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 076/130] qt5-webengine: update to 5.15.13

---
 .../chromium-media-filters-cpp14.patch        |  11 ++
 srcpkgs/qt5-webengine/patches/ffmpeg5.patch   | 179 ++++++++++++++++++
 srcpkgs/qt5-webengine/template                |  10 +-
 3 files changed, 195 insertions(+), 5 deletions(-)
 create mode 100644 srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/ffmpeg5.patch

diff --git a/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
new file mode 100644
index 000000000000..04adc540f2cb
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
@@ -0,0 +1,11 @@
+--- a/src/3rdparty/chromium/media/filters/BUILD.gn	2023-02-27 13:32:59.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/BUILD.gn	2023-04-02 17:21:39.204066384 -0400
+@@ -96,6 +96,8 @@
+     "//ui/gfx/geometry:geometry",
+   ]
+ 
++  cflags_cc = [ "-std=c++14" ]
++
+   libs = []
+ 
+   if (proprietary_codecs) {
diff --git a/srcpkgs/qt5-webengine/patches/ffmpeg5.patch b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..ac55e1634423
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
@@ -0,0 +1,179 @@
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:57.732547446 -0400
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:09.486478995 -0400
+@@ -57,6 +57,8 @@
+ 
+ namespace {
+ 
++constexpr int64_t kRelativeTsBase = static_cast<int64_t>(0x7ffeffffffffffff);
++
+ void SetAVStreamDiscard(AVStream* stream, AVDiscard discard) {
+   DCHECK(stream);
+   stream->discard = discard;
+@@ -90,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+   if (stream->start_time != kNoFFmpegTimestamp)
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (stream->first_dts != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, stream->first_dts);
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -408,11 +398,11 @@
+   scoped_refptr<DecoderBuffer> buffer;
+ 
+   if (type() == DemuxerStream::TEXT) {
+-    int id_size = 0;
++    size_t id_size = 0;
+     uint8_t* id_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
+ 
+-    int settings_size = 0;
++    size_t settings_size = 0;
+     uint8_t* settings_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
+ 
+@@ -424,7 +414,7 @@
+     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
+                                      side_data.data(), side_data.size());
+   } else {
+-    int side_data_size = 0;
++    size_t side_data_size = 0;
+     uint8_t* side_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
+ 
+@@ -485,7 +475,7 @@
+                                        packet->size - data_offset);
+     }
+ 
+-    int skip_samples_size = 0;
++    size_t skip_samples_size = 0;
+     const uint32_t* skip_samples_ptr =
+         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
+             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
+@@ -1587,6 +1577,8 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++      continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+       lowest_start_time_stream = stream.get();
+@@ -1604,6 +1596,8 @@
+     if (stream && stream->type() == DemuxerStream::VIDEO &&
+         stream->IsEnabled()) {
+       video_stream = stream.get();
++      if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++        continue;
+       if (video_stream->start_time() <= seek_time) {
+         return video_stream;
+       }
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h qtwebengine-5.15.10/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h
+--- a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-07-11 22:12:47.917192788 -0500
+@@ -29,6 +29,7 @@ extern "C" {
+ #include <libavformat/avformat.h>
+ #include <libavformat/avio.h>
+ #include <libavutil/avutil.h>
++#include <libavutil/channel_layout.h>
+ #include <libavutil/imgutils.h>
+ #include <libavutil/log.h>
+ #include <libavutil/mastering_display_metadata.h>
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/audio_file_reader.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/audio_file_reader.cc
+--- a/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -85,7 +85,7 @@ bool AudioFileReader::OpenDemuxer() {
+ }
+ 
+ bool AudioFileReader::OpenDecoder() {
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (codec) {
+     // MP3 decodes to S16P which we don't support, tell it to use S16 instead.
+     if (codec_context_->sample_fmt == AV_SAMPLE_FMT_S16P)
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -329,7 +329,7 @@ bool FFmpegAudioDecoder::ConfigureDecode
+     }
+   }
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec ||
+       avcodec_open2(codec_context_.get(), codec, &codec_options) < 0) {
+     DLOG(ERROR) << "Could not initialize audio decoder: "
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -59,7 +59,6 @@ static int64_t AVIOSeekOperation(void* o
+ }
+ 
+ void FFmpegGlue::InitializeFFmpeg() {
+-  av_register_all();
+ }
+ 
+ static void LogContainer(bool is_local_file,
+@@ -95,9 +94,6 @@ FFmpegGlue::FFmpegGlue(FFmpegURLProtocol
+   // Enable fast, but inaccurate seeks for MP3.
+   format_context_->flags |= AVFMT_FLAG_FAST_SEEK;
+ 
+-  // Ensures we can read out various metadata bits like vp8 alpha.
+-  format_context_->flags |= AVFMT_FLAG_KEEP_SIDE_DATA;
+-
+   // Ensures format parsing errors will bail out. From an audit on 11/2017, all
+   // instances were real failures. Solves bugs like http://crbug.com/710791.
+   format_context_->error_recognition |= AV_EF_EXPLODE;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -391,7 +391,7 @@ bool FFmpegVideoDecoder::ConfigureDecode
+   if (decode_nalus_)
+     codec_context_->flags2 |= AV_CODEC_FLAG2_CHUNKS;
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
+     ReleaseFFmpegResources();
+     return false;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/media_file_checker.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/media_file_checker.cc
+--- a/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -68,7 +68,7 @@ bool MediaFileChecker::Start(base::TimeD
+       auto context = AVStreamToAVCodecContext(format_context->streams[i]);
+       if (!context)
+         continue;
+-      AVCodec* codec = avcodec_find_decoder(cp->codec_id);
++      const AVCodec* codec = avcodec_find_decoder(cp->codec_id);
+       if (codec && avcodec_open2(context.get(), codec, nullptr) >= 0) {
+         auto loop = std::make_unique<FFmpegDecodingLoop>(context.get());
+         stream_contexts[i] = {std::move(context), std::move(loop)};
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc qtwebengine-5.15.10/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc
+--- a/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -203,7 +203,7 @@ int32_t H264DecoderImpl::InitDecode(cons
+   // a pointer |this|.
+   av_context_->opaque = this;
+ 
+-  AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
+   if (!codec) {
+     // This is an indication that FFmpeg has not been initialized or it has not
+     // been compiled/initialized with the correct set of codecs.
diff --git a/srcpkgs/qt5-webengine/template b/srcpkgs/qt5-webengine/template
index 0a71484208bc..095ab67701e4 100644
--- a/srcpkgs/qt5-webengine/template
+++ b/srcpkgs/qt5-webengine/template
@@ -1,9 +1,9 @@
 # Template file for 'qt5-webengine'
 pkgname=qt5-webengine
-version=5.15.11
-revision=2
+version=5.15.13
+revision=1
 _version="${version}-lts"
-_chromium_commit=be349eaf62e77955791d7bf29f893f1e8a37daf4
+_chromium_commit=e48df7803c7c98b0b2471c94057d32e44a301ad5
 archs="x86_64* i686* armv[67]* ppc64* aarch64*"
 create_wrksrc=yes
 build_style=qmake
@@ -32,8 +32,8 @@ license="GPL-3.0-or-later, LGPL-3.0-or-later"
 homepage="https://qt.io/"
 distfiles="https://github.com/qt/qtwebengine/archive/v${_version}.tar.gz
  https://github.com/qt/qtwebengine-chromium/archive/${_chromium_commit}.tar.gz"
-checksum="aa7466356c450c5f5870f979b93cd7e7e62da1165c328ffcab1a9928db18ad67
- 6f47ed8ab8cc062411f6f206da6353bc8263d6ed6d6290c689a05c01d91f646b"
+checksum="4b59838ed75ef788b59e1e412535a0e42dd9d311661fdeadb191b581ba815c63
+ a91686562b1d4e8b220e0bbcbab5feb64630e2de974b35ac034bf388af771a6c"
 
 no_generic_pkgconfig_link=yes
 build_options="sndio pipewire"

From 28cb7c6dcffc726776dd6d2bdb0b9315cf86335d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 077/130] qt5: update to 5.15.8

---
 ...erywhere-opensource-src-5.15.8-kf5-1.patch | 12913 ++++++++++++++++
 srcpkgs/qt5/template                          |    12 +-
 2 files changed, 12919 insertions(+), 6 deletions(-)
 create mode 100644 srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch

diff --git a/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch b/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch
new file mode 100644
index 000000000000..966c98bcd3bb
--- /dev/null
+++ b/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch
@@ -0,0 +1,12913 @@
+Submitted By:            Pierre Labastie <pierre_dot_labastie_at_neuf_dot_fr>
+Date:                    2023-01-05
+Initial Package Version: 5.15.8
+Upstream Status:         Applied (according to KDE)
+Origin:                  KDE patch set
+Description:             Patch set maintained by the KDE folks
+see https://dot.kde.org/2021/04/06/announcing-kdes-qt-5-patch-collection
+Patch generated using the procedure in
+https://wiki.linuxfromscratch.org/blfs/ticket/17476#comment:3
+
+Submodule qtbase 4ee4fc18..9cf586d6:
+diff --git a/qtbase/mkspecs/common/android/qplatformdefs.h b/qtbase/mkspecs/common/android/qplatformdefs.h
+index f75bc4093b..2bd59410d4 100644
+--- a/qtbase/mkspecs/common/android/qplatformdefs.h
++++ b/qtbase/mkspecs/common/android/qplatformdefs.h
+@@ -144,11 +144,7 @@
+ #define QT_SIGNAL_ARGS          int
+ #define QT_SIGNAL_IGNORE        SIG_IGN
+ 
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+ #define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+ 
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+diff --git a/qtbase/mkspecs/features/mac/sdk.mk b/qtbase/mkspecs/features/mac/sdk.mk
+index f30b5830b4..a32ceacb6c 100644
+--- a/qtbase/mkspecs/features/mac/sdk.mk
++++ b/qtbase/mkspecs/features/mac/sdk.mk
+@@ -1,6 +1,6 @@
+ 
+ ifeq ($(QT_MAC_SDK_NO_VERSION_CHECK),)
+-    CHECK_SDK_COMMAND = /usr/bin/xcrun --sdk $(EXPORT_QMAKE_MAC_SDK) -show-sdk-version 2>&1
++    CHECK_SDK_COMMAND = /usr/bin/xcrun --sdk $(EXPORT_QMAKE_MAC_SDK) -show-sdk-version 2>/dev/null
+     CURRENT_MAC_SDK_VERSION := $(shell DEVELOPER_DIR=$(EXPORT_QMAKE_XCODE_DEVELOPER_PATH) $(CHECK_SDK_COMMAND))
+     ifneq ($(CURRENT_MAC_SDK_VERSION),$(EXPORT_QMAKE_MAC_SDK_VERSION))
+         # We don't want to complain about out of date SDK unless the target needs to be remade.
+diff --git a/qtbase/mkspecs/linux-clang/qplatformdefs.h b/qtbase/mkspecs/linux-clang/qplatformdefs.h
+index a818d973f0..c1ab72fbc6 100644
+--- a/qtbase/mkspecs/linux-clang/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-clang/qplatformdefs.h
+@@ -79,14 +79,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-g++/qplatformdefs.h b/qtbase/mkspecs/linux-g++/qplatformdefs.h
+index 13523f0702..4d2750d9ec 100644
+--- a/qtbase/mkspecs/linux-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-g++/qplatformdefs.h
+@@ -79,14 +79,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ < 2)
+-#define QT_SOCKLEN_T            int
+-#else
+-#define QT_SOCKLEN_T            socklen_t
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-llvm/qplatformdefs.h b/qtbase/mkspecs/linux-llvm/qplatformdefs.h
+index dc750ab1ef..d3cc39b47f 100644
+--- a/qtbase/mkspecs/linux-llvm/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-llvm/qplatformdefs.h
+@@ -80,14 +80,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h b/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
+index 4c4e53da2a..83baffb3e3 100644
+--- a/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
+@@ -85,16 +85,9 @@
+ #include "../common/posix/qplatformdefs.h"
+ 
+ #undef QT_OPEN_LARGEFILE
+-#undef QT_SOCKLEN_T
+ 
+ #define QT_OPEN_LARGEFILE       0
+ 
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #ifndef SIOCGIFBRDADDR
+ #  define SIOCGIFBRDADDR 0x8919
+ #endif
+diff --git a/qtbase/mkspecs/lynxos-g++/qplatformdefs.h b/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
+index 4339ea2b23..6007af0055 100644
+--- a/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
+@@ -72,14 +72,6 @@
+ 
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp b/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
+index c3c184258f..32af3f8f29 100644
+--- a/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
++++ b/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
+@@ -10,6 +10,7 @@
+ #include "libANGLE/HandleAllocator.h"
+ 
+ #include <algorithm>
++#include <limits>
+ 
+ #include "common/debug.h"
+ 
+diff --git a/qtbase/src/3rdparty/forkfd/forkfd_linux.c b/qtbase/src/3rdparty/forkfd/forkfd_linux.c
+index ffe0e9a5e2..b1f5408d11 100644
+--- a/qtbase/src/3rdparty/forkfd/forkfd_linux.c
++++ b/qtbase/src/3rdparty/forkfd/forkfd_linux.c
+@@ -82,7 +82,8 @@ static int sys_clone(unsigned long cloneflags, int *ptid)
+     return syscall(__NR_clone, cloneflags, child_stack, stack_size, ptid, newtls, ctid);
+ #elif defined(__arc__) || defined(__arm__) || defined(__aarch64__) || defined(__mips__) || \
+     defined(__nds32__) || defined(__hppa__) || defined(__powerpc__) || defined(__i386__) || \
+-    defined(__x86_64__) || defined(__xtensa__) || defined(__alpha__) || defined(__riscv)
++    defined(__x86_64__) || defined(__xtensa__) || defined(__alpha__) || defined(__riscv) || \
++    defined(__loongarch__)
+     /* ctid and newtls are inverted on CONFIG_CLONE_BACKWARDS architectures,
+      * but since both values are 0, there's no harm. */
+     return syscall(__NR_clone, cloneflags, child_stack, ptid, ctid, newtls);
+diff --git a/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java b/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
+index 5792b5b2f5..2f74750fcf 100644
+--- a/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
++++ b/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
+@@ -116,6 +116,7 @@ public class QtNative
+     public static QtThread m_qtThread = new QtThread();
+     private static HashMap<String, Uri> m_cachedUris = new HashMap<String, Uri>();
+     private static ArrayList<String> m_knownDirs = new ArrayList<String>();
++    private static final String NoPermissionErrorMessage = "No permissions to open Uri";
+ 
+     private static final Runnable runPendingCppRunnablesRunnable = new Runnable() {
+         @Override
+@@ -193,11 +194,10 @@ public class QtNative
+                     return iterUri;
+             }
+ 
+-            // Android 6 and earlier could still manage to open the file so we can return the
+-            // parsed uri here
+-            if (Build.VERSION.SDK_INT < 24)
+-                return parsedUri;
+-            return null;
++            // if we only have transient permissions on uri all the above will fail,
++            // but we will be able to read the file anyway, so continue with uri here anyway
++            // and check for SecurityExceptions later
++            return parsedUri;
+         } catch (SecurityException e) {
+             e.printStackTrace();
+             return null;
+@@ -244,7 +244,7 @@ public class QtNative
+         int error = -1;
+ 
+         if (uri == null) {
+-            Log.e(QtTAG, "openFdForContentUrl(): No permissions to open Uri");
++            Log.e(QtTAG, "openFdForContentUrl(): " + NoPermissionErrorMessage);
+             return error;
+         }
+ 
+@@ -254,12 +254,13 @@ public class QtNative
+             return fdDesc.detachFd();
+         } catch (FileNotFoundException e) {
+             e.printStackTrace();
+-            return error;
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "openFdForContentUrl(): Invalid Uri");
+             e.printStackTrace();
+-            return error;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return error;
+     }
+ 
+     public static long getSize(Context context, String contentUrl)
+@@ -270,7 +271,7 @@ public class QtNative
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+ 
+         if (uri == null) {
+-            Log.e(QtTAG, "getSize(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return size;
+         } else if (!m_cachedUris.containsKey(contentUrl)) {
+             m_cachedUris.put(contentUrl, uri);
+@@ -288,12 +289,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "getSize(): Invalid Uri");
+             e.printStackTrace();
+-            return size;
+         }  catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "getSize(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return size;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return size;
+     }
+ 
+     public static boolean checkFileExists(Context context, String contentUrl)
+@@ -303,7 +305,7 @@ public class QtNative
+         if (uri == null)
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+         if (uri == null) {
+-            Log.e(QtTAG, "checkFileExists(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return exists;
+         } else {
+             if (!m_cachedUris.containsKey(contentUrl))
+@@ -321,12 +323,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "checkFileExists(): Invalid Uri");
+             e.printStackTrace();
+-            return exists;
+         } catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "checkFileExists(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return false;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return exists;
+     }
+ 
+     public static boolean checkIfWritable(Context context, String contentUrl)
+@@ -344,7 +347,7 @@ public class QtNative
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+         }
+         if (uri == null) {
+-            Log.e(QtTAG, "isDir(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return isDir;
+         } else {
+             if (!m_cachedUris.containsKey(contentUrl))
+@@ -374,12 +377,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "checkIfDir(): Invalid Uri");
+             e.printStackTrace();
+-            return false;
+         } catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "checkIfDir(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return false;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return false;
+     }
+     public static String[] listContentsFromTreeUri(Context context, String contentUrl)
+     {
+diff --git a/qtbase/src/concurrent/qtconcurrentreducekernel.h b/qtbase/src/concurrent/qtconcurrentreducekernel.h
+index 8f9a938952..a98dedef2e 100644
+--- a/qtbase/src/concurrent/qtconcurrentreducekernel.h
++++ b/qtbase/src/concurrent/qtconcurrentreducekernel.h
+@@ -212,11 +212,13 @@ public:
+ 
+     inline bool shouldThrottle()
+     {
++        std::lock_guard<QMutex> locker(mutex);
+         return (resultsMapSize > (ReduceQueueThrottleLimit * threadCount));
+     }
+ 
+     inline bool shouldStartThread()
+     {
++        std::lock_guard<QMutex> locker(mutex);
+         return (resultsMapSize <= (ReduceQueueStartLimit * threadCount));
+     }
+ };
+diff --git a/qtbase/src/concurrent/qtconcurrentthreadengine.cpp b/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
+index ea6ce3ac42..7f91a2ba68 100644
+--- a/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
++++ b/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
+@@ -176,6 +176,39 @@ void ThreadEngineBase::startSingleThreaded()
+     finish();
+ }
+ 
++void ThreadEngineBase::startBlocking()
++{
++    start();
++    barrier.acquire();
++    startThreads();
++
++    bool throttled = false;
++#ifndef QT_NO_EXCEPTIONS
++    try {
++#endif
++        while (threadFunction() == ThrottleThread) {
++            if (threadThrottleExit()) {
++                throttled = true;
++                break;
++            }
++        }
++#ifndef QT_NO_EXCEPTIONS
++    } catch (QException &e) {
++        handleException(e);
++    } catch (...) {
++        handleException(QUnhandledException());
++    }
++#endif
++
++    if (throttled == false) {
++        barrier.release();
++    }
++
++    barrier.wait();
++    finish();
++    exceptionStore.throwPossibleException();
++}
++
+ void ThreadEngineBase::startThread()
+ {
+     startThreadInternal();
+diff --git a/qtbase/src/concurrent/qtconcurrentthreadengine.h b/qtbase/src/concurrent/qtconcurrentthreadengine.h
+index 7c30cebdbc..a4c8548cc4 100644
+--- a/qtbase/src/concurrent/qtconcurrentthreadengine.h
++++ b/qtbase/src/concurrent/qtconcurrentthreadengine.h
+@@ -91,6 +91,7 @@ public:
+     ThreadEngineBase();
+     virtual ~ThreadEngineBase();
+     void startSingleThreaded();
++    void startBlocking();
+     void startThread();
+     bool isCanceled();
+     void waitForResume();
+@@ -143,6 +144,15 @@ public:
+         return result();
+     }
+ 
++    // Runs the user algorithm using multiple threads.
++    // This function blocks until the algorithm is finished,
++    // and then returns the result.
++    T *startBlocking()
++    {
++        ThreadEngineBase::startBlocking();
++        return result();
++    }
++
+     // Runs the user algorithm using multiple threads.
+     // Does not block, returns a future.
+     QFuture<T> startAsynchronously()
+@@ -223,6 +233,13 @@ class ThreadEngineStarter : public ThreadEngineStarterBase<T>
+ public:
+     ThreadEngineStarter(TypedThreadEngine *eng)
+         : Base(eng) { }
++
++    T startBlocking()
++    {
++        T t = *this->threadEngine->startBlocking();
++        delete this->threadEngine;
++        return t;
++    }
+ };
+ 
+ // Full template specialization where T is void.
+@@ -232,6 +249,12 @@ class ThreadEngineStarter<void> : public ThreadEngineStarterBase<void>
+ public:
+     ThreadEngineStarter(ThreadEngine<void> *_threadEngine)
+         : ThreadEngineStarterBase<void>(_threadEngine) {}
++
++    void startBlocking()
++    {
++        this->threadEngine->startBlocking();
++        delete this->threadEngine;
++    }
+ };
+ 
+ //! [qtconcurrentthreadengine-1]
+diff --git a/qtbase/src/corelib/animation/qvariantanimation.cpp b/qtbase/src/corelib/animation/qvariantanimation.cpp
+index 98b02f0202..eac1524107 100644
+--- a/qtbase/src/corelib/animation/qvariantanimation.cpp
++++ b/qtbase/src/corelib/animation/qvariantanimation.cpp
+@@ -276,7 +276,9 @@ void QVariantAnimationPrivate::setCurrentValueForProgress(const qreal progress)
+ 
+     const qreal startProgress = currentInterval.start.first;
+     const qreal endProgress = currentInterval.end.first;
+-    const qreal localProgress = (progress - startProgress) / (endProgress - startProgress);
++    const qreal localProgress =
++            qIsNull(progress - startProgress) ? 0.0 // avoid 0/0 below
++            /* else */                        : (progress - startProgress) / (endProgress - startProgress);
+ 
+     QVariant ret = q->interpolated(currentInterval.start.second,
+                                    currentInterval.end.second,
+diff --git a/qtbase/src/corelib/global/qnamespace.h b/qtbase/src/corelib/global/qnamespace.h
+index ad4150b317..bf19b1627b 100644
+--- a/qtbase/src/corelib/global/qnamespace.h
++++ b/qtbase/src/corelib/global/qnamespace.h
+@@ -1864,7 +1864,7 @@ public:
+     QT_Q_ENUM(TimerType)
+     QT_Q_ENUM(ScrollPhase)
+     QT_Q_ENUM(MouseEventSource)
+-    QT_Q_FLAG(MouseEventFlag)
++    QT_Q_FLAG(MouseEventFlags)
+     QT_Q_ENUM(ChecksumType)
+     QT_Q_ENUM(HighDpiScaleFactorRoundingPolicy)
+     QT_Q_ENUM(TabFocusBehavior)
+diff --git a/qtbase/src/corelib/global/qrandom.cpp b/qtbase/src/corelib/global/qrandom.cpp
+index 10672c1f92..25f87c7e6a 100644
+--- a/qtbase/src/corelib/global/qrandom.cpp
++++ b/qtbase/src/corelib/global/qrandom.cpp
+@@ -383,7 +383,6 @@ struct QRandomGenerator::SystemAndGlobalGenerators
+ 
+         constexpr SystemAndGlobalGenerators g = {};
+         Q_UNUSED(g);
+-        Q_STATIC_ASSERT(std::is_literal_type<SystemAndGlobalGenerators>::value);
+ #endif
+     }
+ 
+diff --git a/qtbase/src/corelib/io/qbuffer.cpp b/qtbase/src/corelib/io/qbuffer.cpp
+index 595fcd2724..032c0ddd4b 100644
+--- a/qtbase/src/corelib/io/qbuffer.cpp
++++ b/qtbase/src/corelib/io/qbuffer.cpp
+@@ -41,6 +41,8 @@
+ #include <QtCore/qmetaobject.h>
+ #include "private/qiodevice_p.h"
+ 
++#include <limits>
++
+ QT_BEGIN_NAMESPACE
+ 
+ /** QBufferPrivate **/
+@@ -366,7 +368,9 @@ qint64 QBuffer::size() const
+ bool QBuffer::seek(qint64 pos)
+ {
+     Q_D(QBuffer);
+-    if (pos > d->buf->size() && isWritable()) {
++    const auto oldBufSize = d->buf->size();
++    constexpr qint64 MaxSeekPos = (std::numeric_limits<decltype(oldBufSize)>::max)();
++    if (pos <= MaxSeekPos && pos > oldBufSize && isWritable()) {
+         if (seek(d->buf->size())) {
+             const qint64 gapSize = pos - d->buf->size();
+             if (write(QByteArray(gapSize, 0)) != gapSize) {
+@@ -377,7 +381,7 @@ bool QBuffer::seek(qint64 pos)
+             return false;
+         }
+     } else if (pos > d->buf->size() || pos < 0) {
+-        qWarning("QBuffer::seek: Invalid pos: %d", int(pos));
++        qWarning("QBuffer::seek: Invalid pos: %lld", pos);
+         return false;
+     }
+     return QIODevice::seek(pos);
+diff --git a/qtbase/src/corelib/io/qfilesystemengine_win.cpp b/qtbase/src/corelib/io/qfilesystemengine_win.cpp
+index 81d3a71986..c86ed1f9b0 100644
+--- a/qtbase/src/corelib/io/qfilesystemengine_win.cpp
++++ b/qtbase/src/corelib/io/qfilesystemengine_win.cpp
+@@ -664,14 +664,14 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry)
+     return QFileSystemEntry(ret, QFileSystemEntry::FromInternalPath());
+ }
+ 
+-#if defined(Q_CC_MINGW) && WINVER < 0x0602 //  Windows 8 onwards
++#if defined(Q_CC_MINGW) && WINVER < 0x0602 && _WIN32_WINNT < _WIN32_WINNT_WIN8 //  Windows 8 onwards
+ 
+ typedef struct _FILE_ID_INFO {
+     ULONGLONG VolumeSerialNumber;
+     FILE_ID_128 FileId;
+ } FILE_ID_INFO, *PFILE_ID_INFO;
+ 
+-#endif // if defined (Q_CC_MINGW) && WINVER < 0x0602
++#endif // if defined(Q_CC_MINGW) && WINVER < 0x0602 && _WIN32_WINNT < _WIN32_WINNT_WIN8
+ 
+ // File ID for Windows up to version 7 and FAT32 drives
+ static inline QByteArray fileId(HANDLE handle)
+diff --git a/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp b/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
+index 94d9d06bcb..27e0b13b0b 100644
+--- a/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
++++ b/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
+@@ -366,7 +366,9 @@ void QInotifyFileSystemWatcherEngine::readFromInotify()
+     // qDebug("QInotifyFileSystemWatcherEngine::readFromInotify");
+ 
+     int buffSize = 0;
+-    ioctl(inotifyFd, FIONREAD, (char *) &buffSize);
++    if (ioctl(inotifyFd, FIONREAD, (char *) &buffSize) == -1 || buffSize == 0)
++        return;
++
+     QVarLengthArray<char, 4096> buffer(buffSize);
+     buffSize = read(inotifyFd, buffer.data(), buffSize);
+     char *at = buffer.data();
+diff --git a/qtbase/src/corelib/io/qlockfile_win.cpp b/qtbase/src/corelib/io/qlockfile_win.cpp
+index 277f8d4230..38ecef5550 100644
+--- a/qtbase/src/corelib/io/qlockfile_win.cpp
++++ b/qtbase/src/corelib/io/qlockfile_win.cpp
+@@ -48,6 +48,8 @@
+ #include "QtCore/qdebug.h"
+ #include "QtCore/qthread.h"
+ 
++#include "private/qsystemlibrary_p.h"
++
+ QT_BEGIN_NAMESPACE
+ 
+ static inline bool fileExists(const wchar_t *fileName)
+@@ -150,7 +152,7 @@ QString QLockFilePrivate::processNameByPid(qint64 pid)
+ #if !defined(Q_OS_WINRT)
+     typedef DWORD (WINAPI *GetModuleFileNameExFunc)(HANDLE, HMODULE, LPTSTR, DWORD);
+ 
+-    HMODULE hPsapi = LoadLibraryA("psapi");
++    HMODULE hPsapi = QSystemLibrary::load(L"psapi");
+     if (!hPsapi)
+         return QString();
+     GetModuleFileNameExFunc qGetModuleFileNameEx = reinterpret_cast<GetModuleFileNameExFunc>(
+diff --git a/qtbase/src/corelib/io/qprocess_unix.cpp b/qtbase/src/corelib/io/qprocess_unix.cpp
+index 50390e57f5..15c8f30745 100644
+--- a/qtbase/src/corelib/io/qprocess_unix.cpp
++++ b/qtbase/src/corelib/io/qprocess_unix.cpp
+@@ -1,7 +1,7 @@
+ /****************************************************************************
+ **
+ ** Copyright (C) 2016 The Qt Company Ltd.
+-** Copyright (C) 2016 Intel Corporation.
++** Copyright (C) 2022 Intel Corporation.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtCore module of the Qt Toolkit.
+@@ -422,14 +422,15 @@ void QProcessPrivate::startProcess()
+     // Add the program name to the argument list.
+     argv[0] = nullptr;
+     if (!program.contains(QLatin1Char('/'))) {
++        // findExecutable() returns its argument if it's an absolute path,
++        // otherwise it searches $PATH; returns empty if not found (we handle
++        // that case much later)
+         const QString &exeFilePath = QStandardPaths::findExecutable(program);
+-        if (!exeFilePath.isEmpty()) {
+-            const QByteArray &tmp = QFile::encodeName(exeFilePath);
+-            argv[0] = ::strdup(tmp.constData());
+-        }
+-    }
+-    if (!argv[0])
++        const QByteArray &tmp = QFile::encodeName(exeFilePath);
++        argv[0] = ::strdup(tmp.constData());
++    } else {
+         argv[0] = ::strdup(encodedProgramName.constData());
++    }
+ 
+     // Add every argument to the list
+     for (int i = 0; i < arguments.count(); ++i)
+@@ -983,15 +984,16 @@ bool QProcessPrivate::startDetached(qint64 *pid)
+                 envp = _q_dupEnvironment(environment.d.constData()->vars, &envc);
+             }
+ 
+-            QByteArray tmp;
+             if (!program.contains(QLatin1Char('/'))) {
++                // findExecutable() returns its argument if it's an absolute path,
++                // otherwise it searches $PATH; returns empty if not found (we handle
++                // that case much later)
+                 const QString &exeFilePath = QStandardPaths::findExecutable(program);
+-                if (!exeFilePath.isEmpty())
+-                    tmp = QFile::encodeName(exeFilePath);
++                const QByteArray &tmp = QFile::encodeName(exeFilePath);
++                argv[0] = ::strdup(tmp.constData());
++            } else {
++                argv[0] = ::strdup(QFile::encodeName(program));
+             }
+-            if (tmp.isEmpty())
+-                tmp = QFile::encodeName(program);
+-            argv[0] = tmp.data();
+ 
+             if (envp)
+                 qt_safe_execve(argv[0], argv, envp);
+diff --git a/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp b/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
+index 3a79c502af..997a634e76 100644
+--- a/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
++++ b/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
+@@ -3196,9 +3196,8 @@ bool QAbstractItemModel::beginMoveColumns(const QModelIndex &sourceParent, int s
+     destinationChange.needsAdjust = destinationParent.isValid() && destinationParent.row() >= sourceLast && destinationParent.parent() == sourceParent;
+     d->changes.push(destinationChange);
+ 
+-    d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Horizontal);
+-
+     emit columnsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, QPrivateSignal());
++    d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Horizontal);
+     return true;
+ }
+ 
+@@ -3231,7 +3230,6 @@ void QAbstractItemModel::endMoveColumns()
+       adjustedSource = createIndex(adjustedSource.row(), adjustedSource.column() + numMoved, adjustedSource.internalPointer());
+ 
+     d->itemsMoved(adjustedSource, removeChange.first, removeChange.last, adjustedDestination, insertChange.first, Qt::Horizontal);
+-
+     emit columnsMoved(adjustedSource, removeChange.first, removeChange.last, adjustedDestination, insertChange.first, QPrivateSignal());
+ }
+ 
+diff --git a/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+index dc6379d9fb..c5e287ee84 100644
+--- a/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
++++ b/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+@@ -939,8 +939,9 @@ void QSortFilterProxyModelPrivate::insert_source_items(
+                 q->beginInsertColumns(proxy_parent, proxy_start, proxy_end);
+         }
+ 
+-        for (int i = 0; i < source_items.size(); ++i)
+-            proxy_to_source.insert(proxy_start + i, source_items.at(i));
++        // TODO: use the range QList::insert() overload once it is implemented (QTBUG-58633).
++        proxy_to_source.insert(proxy_start, source_items.size(), 0);
++        std::copy(source_items.cbegin(), source_items.cend(), proxy_to_source.begin() + proxy_start);
+ 
+         build_source_to_proxy_mapping(proxy_to_source, source_to_proxy);
+ 
+@@ -3123,8 +3124,9 @@ bool QSortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex &
+ 
+     if (d->filter_data.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();
+@@ -3133,9 +3135,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.hasMatch(key);
+ }
+diff --git a/qtbase/src/corelib/kernel/qcoreapplication.cpp b/qtbase/src/corelib/kernel/qcoreapplication.cpp
+index ca2864df83..132b2eae52 100644
+--- a/qtbase/src/corelib/kernel/qcoreapplication.cpp
++++ b/qtbase/src/corelib/kernel/qcoreapplication.cpp
+@@ -1157,7 +1157,7 @@ static bool doNotify(QObject *receiver, QEvent *event)
+ bool QCoreApplicationPrivate::sendThroughApplicationEventFilters(QObject *receiver, QEvent *event)
+ {
+     // We can't access the application event filters outside of the main thread (race conditions)
+-    Q_ASSERT(receiver->d_func()->threadData.loadRelaxed()->thread.loadAcquire() == mainThread());
++    Q_ASSERT(receiver->d_func()->threadData.loadAcquire()->thread.loadRelaxed() == mainThread());
+ 
+     if (extraData) {
+         // application event filters are only called for objects in the GUI thread
+diff --git a/qtbase/src/corelib/kernel/qobject.cpp b/qtbase/src/corelib/kernel/qobject.cpp
+index 1eb79138d9..36cd780ee1 100644
+--- a/qtbase/src/corelib/kernel/qobject.cpp
++++ b/qtbase/src/corelib/kernel/qobject.cpp
+@@ -1010,7 +1010,7 @@ QObject::~QObject()
+         emit destroyed(this);
+     }
+ 
+-    if (d->declarativeData) {
++    if (!d->isDeletingChildren && d->declarativeData) {
+         if (static_cast<QAbstractDeclarativeDataImpl*>(d->declarativeData)->ownedByQml1) {
+             if (QAbstractDeclarativeData::destroyed_qml1)
+                 QAbstractDeclarativeData::destroyed_qml1(d->declarativeData, this);
+@@ -1580,7 +1580,7 @@ void QObject::moveToThread(QThread *targetThread)
+ 
+     QThreadData *currentData = QThreadData::current();
+     QThreadData *targetData = targetThread ? QThreadData::get2(targetThread) : nullptr;
+-    QThreadData *thisThreadData = d->threadData.loadRelaxed();
++    QThreadData *thisThreadData = d->threadData.loadAcquire();
+     if (!thisThreadData->thread.loadAcquire() && currentData == targetData) {
+         // one exception to the rule: we allow moving objects with no thread affinity to the current thread
+         currentData = d->threadData;
+@@ -2620,7 +2620,7 @@ int QObject::receivers(const char *signal) const
+         if (!d->isSignalConnected(signal_index))
+             return receivers;
+ 
+-        if (d->declarativeData && QAbstractDeclarativeData::receivers) {
++        if (!d->isDeletingChildren && d->declarativeData && QAbstractDeclarativeData::receivers) {
+             receivers += QAbstractDeclarativeData::receivers(d->declarativeData, this,
+                                                              signal_index);
+         }
+diff --git a/qtbase/src/corelib/kernel/qobject_p.h b/qtbase/src/corelib/kernel/qobject_p.h
+index 0b827a52ca..13ffb88999 100644
+--- a/qtbase/src/corelib/kernel/qobject_p.h
++++ b/qtbase/src/corelib/kernel/qobject_p.h
+@@ -444,7 +444,7 @@ inline void QObjectPrivate::checkForIncompatibleLibraryVersion(int version) cons
+ 
+ inline bool QObjectPrivate::isDeclarativeSignalConnected(uint signal_index) const
+ {
+-    return declarativeData && QAbstractDeclarativeData::isSignalConnected
++    return !isDeletingChildren && declarativeData && QAbstractDeclarativeData::isSignalConnected
+             && QAbstractDeclarativeData::isSignalConnected(declarativeData, q_func(), signal_index);
+ }
+ 
+diff --git a/qtbase/src/corelib/kernel/qtranslator.cpp b/qtbase/src/corelib/kernel/qtranslator.cpp
+index 2812ffb7ea..bc0177c5ec 100644
+--- a/qtbase/src/corelib/kernel/qtranslator.cpp
++++ b/qtbase/src/corelib/kernel/qtranslator.cpp
+@@ -902,7 +902,7 @@ static QString getMessage(const uchar *m, const uchar *end, const char *context,
+             goto end;
+         case Tag_Translation: {
+             int len = read32(m);
+-            if (len % 1)
++            if (len & 1)
+                 return QString();
+             m += 4;
+             if (!numerus--) {
+diff --git a/qtbase/src/corelib/mimetypes/qmimedatabase.cpp b/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
+index 9de22cef33..ff868a3268 100644
+--- a/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
+@@ -389,20 +389,23 @@ QMimeType QMimeDatabasePrivate::mimeTypeForFileNameAndData(const QString &fileNa
+         // Disambiguate conflicting extensions (if magic matching found something)
+         if (candidateByData.isValid() && magicAccuracy > 0) {
+             const QString sniffedMime = candidateByData.name();
+-            // If the sniffedMime matches a glob match, use it
++            // If the sniffedMime matches a highest-weight glob match, use it
+             if (candidatesByName.m_matchingMimeTypes.contains(sniffedMime)) {
+                 *accuracyPtr = 100;
+                 return candidateByData;
+             }
+-            for (const QString &m : qAsConst(candidatesByName.m_matchingMimeTypes)) {
++            for (const QString &m : qAsConst(candidatesByName.m_allMatchingMimeTypes)) {
+                 if (inherits(m, sniffedMime)) {
+                     // We have magic + pattern pointing to this, so it's a pretty good match
+                     *accuracyPtr = 100;
+                     return mimeTypeForName(m);
+                 }
+             }
+-            *accuracyPtr = magicAccuracy;
+-            return candidateByData;
++            if (candidatesByName.m_allMatchingMimeTypes.isEmpty()) {
++                // No glob, use magic
++                *accuracyPtr = magicAccuracy;
++                return candidateByData;
++            }
+         }
+     }
+ 
+diff --git a/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp b/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
+index a81112d227..fa8f4c545d 100644
+--- a/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
+@@ -83,7 +83,10 @@ void QMimeGlobMatchResult::addMatch(const QString &mimeType, int weight, const Q
+     }
+     if (!m_matchingMimeTypes.contains(mimeType)) {
+         m_matchingMimeTypes.append(mimeType);
+-        m_allMatchingMimeTypes.append(mimeType);
++        if (replace)
++            m_allMatchingMimeTypes.prepend(mimeType); // highest-weight first
++        else
++            m_allMatchingMimeTypes.append(mimeType);
+         m_knownSuffixLength = knownSuffixLength;
+     }
+ }
+@@ -94,7 +97,7 @@ QMimeGlobPattern::PatternType QMimeGlobPattern::detectPatternType(const QString
+     if (!patternLength)
+         return OtherPattern;
+ 
+-    const bool starCount = pattern.count(QLatin1Char('*')) == 1;
++    const int starCount = pattern.count(QLatin1Char('*'));
+     const bool hasSquareBracket = pattern.indexOf(QLatin1Char('[')) != -1;
+     const bool hasQuestionMark = pattern.indexOf(QLatin1Char('?')) != -1;
+ 
+@@ -106,10 +109,10 @@ QMimeGlobPattern::PatternType QMimeGlobPattern::detectPatternType(const QString
+             // Patterns like "README*" (well this is currently the only one like that...)
+             if (pattern.at(patternLength - 1) == QLatin1Char('*'))
+                 return PrefixPattern;
+-        }
+-        // Names without any wildcards like "README"
+-        if (starCount == 0)
++        } else if (starCount == 0) {
++            // Names without any wildcards like "README"
+             return LiteralPattern;
++        }
+     }
+ 
+     if (pattern == QLatin1String("[0-9][0-9][0-9].vdr"))
+diff --git a/qtbase/src/corelib/mimetypes/qmimeprovider.cpp b/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
+index 258dddf8cb..4642d0f2d0 100644
+--- a/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
+@@ -244,15 +244,18 @@ void QMimeBinaryProvider::addFileNameMatches(const QString &fileName, QMimeGlobM
+     const QString lowerFileName = fileName.toLower();
+     // Check literals (e.g. "Makefile")
+     matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosLiteralListOffset), fileName);
+-    // Check complex globs (e.g. "callgrind.out[0-9]*")
+-    matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosGlobListOffset), fileName);
+     // Check the very common *.txt cases with the suffix tree
+-    const int reverseSuffixTreeOffset = m_cacheFile->getUint32(PosReverseSuffixTreeOffset);
+-    const int numRoots = m_cacheFile->getUint32(reverseSuffixTreeOffset);
+-    const int firstRootOffset = m_cacheFile->getUint32(reverseSuffixTreeOffset + 4);
+-    matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, lowerFileName, lowerFileName.length() - 1, false);
++    if (result.m_matchingMimeTypes.isEmpty()) {
++        const int reverseSuffixTreeOffset = m_cacheFile->getUint32(PosReverseSuffixTreeOffset);
++        const int numRoots = m_cacheFile->getUint32(reverseSuffixTreeOffset);
++        const int firstRootOffset = m_cacheFile->getUint32(reverseSuffixTreeOffset + 4);
++        matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, lowerFileName, lowerFileName.length() - 1, false);
++        if (result.m_matchingMimeTypes.isEmpty())
++            matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, fileName, fileName.length() - 1, true);
++    }
++    // Check complex globs (e.g. "callgrind.out[0-9]*" or "README*")
+     if (result.m_matchingMimeTypes.isEmpty())
+-        matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, fileName, fileName.length() - 1, true);
++        matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosGlobListOffset), fileName);
+ }
+ 
+ void QMimeBinaryProvider::matchGlobList(QMimeGlobMatchResult &result, CacheFile *cacheFile, int off, const QString &fileName)
+diff --git a/qtbase/src/corelib/serialization/qjsonparser.cpp b/qtbase/src/corelib/serialization/qjsonparser.cpp
+index 17e6f111ab..2e40b6c8fb 100644
+--- a/qtbase/src/corelib/serialization/qjsonparser.cpp
++++ b/qtbase/src/corelib/serialization/qjsonparser.cpp
+@@ -379,10 +379,30 @@ error:
+     return QCborValue();
+ }
+ 
++// We need to retain the _last_ value for any duplicate keys and we need to deref containers.
++// Therefore the manual implementation of std::unique().
++template<typename Iterator, typename Compare, typename Assign>
++static Iterator customAssigningUniqueLast(Iterator first, Iterator last,
++                                          Compare compare, Assign assign)
++{
++    first = std::adjacent_find(first, last, compare);
++    if (first == last)
++        return last;
++
++    Iterator result = first;
++    while (++first != last) {
++        if (!compare(*result, *first))
++            ++result;
++        if (result != first)
++            assign(*result, *first);
++    }
++
++    return ++result;
++}
++
+ static void sortContainer(QCborContainerPrivate *container)
+ {
+     using Forward = QJsonPrivate::KeyIterator;
+-    using Reverse = std::reverse_iterator<Forward>;
+     using Value = Forward::value_type;
+ 
+     auto compare = [container](const Value &a, const Value &b)
+@@ -420,17 +440,31 @@ static void sortContainer(QCborContainerPrivate *container)
+         }
+     };
+ 
+-    std::sort(Forward(container->elements.begin()), Forward(container->elements.end()),
+-              [&compare](const Value &a, const Value &b) { return compare(a, b) < 0; });
++    // The elements' containers are owned by the outer container, not by the elements themselves.
++    auto move = [](Forward::reference target, Forward::reference source)
++    {
++        QtCbor::Element &targetValue = target.value();
++
++        // If the target has a container, deref it before overwriting, so that we don't leak.
++        if (targetValue.flags & QtCbor::Element::IsContainer)
++            targetValue.container->deref();
++
++        // Do not move, so that we can clear the value afterwards.
++        target = source;
++
++        // Clear the source value, so that we don't store the same container twice.
++        source.value() = QtCbor::Element();
++    };
++
++    std::stable_sort(
++                Forward(container->elements.begin()), Forward(container->elements.end()),
++                [&compare](const Value &a, const Value &b) { return compare(a, b) < 0; });
+ 
+-    // We need to retain the _last_ value for any duplicate keys. Therefore the reverse dance here.
+-    auto it = std::unique(Reverse(container->elements.end()), Reverse(container->elements.begin()),
+-                          [&compare](const Value &a, const Value &b) {
+-        return compare(a, b) == 0;
+-    }).base().elementsIterator();
++    Forward result = customAssigningUniqueLast(
++                Forward(container->elements.begin()),  Forward(container->elements.end()),
++                [&compare](const Value &a, const Value &b) { return compare(a, b) == 0; }, move);
+ 
+-    // The erase from beginning is expensive but hopefully rare.
+-    container->elements.erase(container->elements.begin(), it);
++    container->elements.erase(result.elementsIterator(), container->elements.end());
+ }
+ 
+ 
+diff --git a/qtbase/src/corelib/serialization/qxmlstream.cpp b/qtbase/src/corelib/serialization/qxmlstream.cpp
+index b2f846544d..7cd457ba3a 100644
+--- a/qtbase/src/corelib/serialization/qxmlstream.cpp
++++ b/qtbase/src/corelib/serialization/qxmlstream.cpp
+@@ -980,7 +980,7 @@ inline uint QXmlStreamReaderPrivate::peekChar()
+ bool QXmlStreamReaderPrivate::scanUntil(const char *str, short tokenToInject)
+ {
+     int pos = textBuffer.size();
+-    int oldLineNumber = lineNumber;
++    const auto oldLineNumber = lineNumber;
+ 
+     uint c;
+     while ((c = getChar()) != StreamEOF) {
+diff --git a/qtbase/src/corelib/text/qstring.cpp b/qtbase/src/corelib/text/qstring.cpp
+index 3e88ab4859..8deeae47bb 100644
+--- a/qtbase/src/corelib/text/qstring.cpp
++++ b/qtbase/src/corelib/text/qstring.cpp
+@@ -12312,7 +12312,7 @@ static qsizetype qLastIndexOf(Haystack haystack0, qsizetype from,
+     const auto needle = needle0.data();
+     const auto *end = haystack;
+     haystack += from;
+-    const std::size_t sl_minus_1 = sl - 1;
++    const std::size_t sl_minus_1 = sl ? sl - 1 : 0;
+     const auto *n = needle + sl_minus_1;
+     const auto *h = haystack + sl_minus_1;
+     std::size_t hashNeedle = 0, hashHaystack = 0;
+diff --git a/qtbase/src/corelib/text/qstringiterator_p.h b/qtbase/src/corelib/text/qstringiterator_p.h
+index 219589b6e4..1d0c66cc78 100644
+--- a/qtbase/src/corelib/text/qstringiterator_p.h
++++ b/qtbase/src/corelib/text/qstringiterator_p.h
+@@ -61,6 +61,8 @@ class QStringIterator
+ {
+     QString::const_iterator i, pos, e;
+     Q_STATIC_ASSERT((std::is_same<QString::const_iterator, const QChar *>::value));
++    static bool less(const QChar *lhs, const QChar *rhs) noexcept
++    { return std::less<QString::const_iterator>{}(lhs, rhs); }
+ public:
+     explicit QStringIterator(QStringView string, qsizetype idx = 0)
+         : i(string.begin()),
+@@ -95,7 +97,8 @@ public:
+ 
+     inline void setPosition(QString::const_iterator position)
+     {
+-        Q_ASSERT_X(i <= position && position <= e, Q_FUNC_INFO, "position out of bounds");
++        Q_ASSERT_X(!less(position, i) && !less(e, position),
++                   Q_FUNC_INFO, "position out of bounds");
+         pos = position;
+     }
+ 
+@@ -103,7 +106,7 @@ public:
+ 
+     inline bool hasNext() const
+     {
+-        return pos < e;
++        return less(pos, e);
+     }
+ 
+     inline void advance()
+@@ -120,16 +123,20 @@ public:
+     {
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+-        if (Q_UNLIKELY((pos++)->isHighSurrogate()))
++        if (Q_UNLIKELY((pos++)->isHighSurrogate())) {
++            Q_ASSERT(hasNext() && pos->isLowSurrogate());
+             ++pos;
++        }
+     }
+ 
+     inline uint peekNextUnchecked() const
+     {
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+-        if (Q_UNLIKELY(pos->isHighSurrogate()))
++        if (Q_UNLIKELY(pos->isHighSurrogate())) {
++            Q_ASSERT(less(pos + 1, e) && pos[1].isLowSurrogate());
+             return QChar::surrogateToUcs4(pos[0], pos[1]);
++        }
+ 
+         return pos->unicode();
+     }
+@@ -155,8 +162,10 @@ public:
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+         const QChar cur = *pos++;
+-        if (Q_UNLIKELY(cur.isHighSurrogate()))
++        if (Q_UNLIKELY(cur.isHighSurrogate())) {
++            Q_ASSERT(hasNext() && pos->isLowSurrogate());
+             return QChar::surrogateToUcs4(cur, *pos++);
++        }
+         return cur.unicode();
+     }
+ 
+@@ -166,7 +175,7 @@ public:
+ 
+         const QChar uc = *pos++;
+         if (Q_UNLIKELY(uc.isSurrogate())) {
+-            if (Q_LIKELY(uc.isHighSurrogate() && pos < e && pos->isLowSurrogate()))
++            if (Q_LIKELY(uc.isHighSurrogate() && hasNext() && pos->isLowSurrogate()))
+                 return QChar::surrogateToUcs4(uc, *pos++);
+             return invalidAs;
+         }
+@@ -178,7 +187,7 @@ public:
+ 
+     inline bool hasPrevious() const
+     {
+-        return pos > i;
++        return less(i, pos);
+     }
+ 
+     inline void recede()
+@@ -196,16 +205,20 @@ public:
+     {
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+-        if (Q_UNLIKELY((--pos)->isLowSurrogate()))
++        if (Q_UNLIKELY((--pos)->isLowSurrogate())) {
++            Q_ASSERT(hasPrevious() && pos[-1].isHighSurrogate());
+             --pos;
++        }
+     }
+ 
+     inline uint peekPreviousUnchecked() const
+     {
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+-        if (Q_UNLIKELY(pos[-1].isLowSurrogate()))
++        if (Q_UNLIKELY(pos[-1].isLowSurrogate())) {
++            Q_ASSERT(less(i + 1, pos) && pos[-2].isHighSurrogate());
+             return QChar::surrogateToUcs4(pos[-2], pos[-1]);
++        }
+         return pos[-1].unicode();
+     }
+ 
+@@ -230,8 +243,10 @@ public:
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+         const QChar cur = *--pos;
+-        if (Q_UNLIKELY(cur.isLowSurrogate()))
++        if (Q_UNLIKELY(cur.isLowSurrogate())) {
++            Q_ASSERT(hasPrevious() && pos[-1].isHighSurrogate());
+             return QChar::surrogateToUcs4(*--pos, cur);
++        }
+         return cur.unicode();
+     }
+ 
+@@ -241,7 +256,7 @@ public:
+ 
+         const QChar uc = *--pos;
+         if (Q_UNLIKELY(uc.isSurrogate())) {
+-            if (Q_LIKELY(uc.isLowSurrogate() && pos > i && pos[-1].isHighSurrogate()))
++            if (Q_LIKELY(uc.isLowSurrogate() && hasPrevious() && pos[-1].isHighSurrogate()))
+                 return QChar::surrogateToUcs4(*--pos, uc);
+             return invalidAs;
+         }
+diff --git a/qtbase/src/corelib/thread/qfutex_p.h b/qtbase/src/corelib/thread/qfutex_p.h
+index f287b752d7..e294537787 100644
+--- a/qtbase/src/corelib/thread/qfutex_p.h
++++ b/qtbase/src/corelib/thread/qfutex_p.h
+@@ -52,6 +52,7 @@
+ //
+ 
+ #include <qglobal.h>
++#include <QtCore/qtsan_impl.h>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -106,16 +107,13 @@ namespace QtLinuxFutex {
+     inline int _q_futex(int *addr, int op, int val, quintptr val2 = 0,
+                         int *addr2 = nullptr, int val3 = 0) noexcept
+     {
+-        // A futex call ensures total ordering on the futex words
+-        // (in either success or failure of the call). Instruct TSAN accordingly,
+-        // as TSAN does not understand the futex(2) syscall.
+-        _q_tsan_release(addr, addr2);
++        QtTsan::futexRelease(addr, addr2);
+ 
+         // we use __NR_futex because some libcs (like Android's bionic) don't
+         // provide SYS_futex etc.
+         int result = syscall(__NR_futex, addr, op | FUTEX_PRIVATE_FLAG, val, val2, addr2, val3);
+ 
+-        _q_tsan_acquire(addr, addr2);
++        QtTsan::futexAcquire(addr, addr2);
+ 
+         return result;
+     }
+diff --git a/qtbase/src/corelib/thread/qmutex.cpp b/qtbase/src/corelib/thread/qmutex.cpp
+index 310d1cb14f..7097122d8e 100644
+--- a/qtbase/src/corelib/thread/qmutex.cpp
++++ b/qtbase/src/corelib/thread/qmutex.cpp
+@@ -152,6 +152,7 @@ public:
+ 
+ /*!
+     \enum QMutex::RecursionMode
++    \obsolete Use QRecursiveMutex to create a recursive mutex.
+ 
+     \value Recursive  In this mode, a thread can lock the same mutex
+                       multiple times and the mutex won't be unlocked
+@@ -173,6 +174,7 @@ public:
+ 
+ /*!
+     Constructs a new mutex. The mutex is created in an unlocked state.
++    \obsolete Use QRecursiveMutex to create a recursive mutex.
+ 
+     If \a mode is QMutex::Recursive, a thread can lock the same mutex
+     multiple times and the mutex won't be unlocked until a
+@@ -197,7 +199,7 @@ QMutex::QMutex(RecursionMode mode)
+ QMutex::~QMutex()
+ {
+     QMutexData *d = d_ptr.loadRelaxed();
+-    if (isRecursive()) {
++    if (QBasicMutex::isRecursive()) {
+         delete static_cast<QRecursiveMutexPrivate *>(d);
+     } else if (d) {
+ #ifndef QT_LINUX_FUTEX
+diff --git a/qtbase/src/corelib/thread/qmutex.h b/qtbase/src/corelib/thread/qmutex.h
+index 73c9e00663..1bae573a03 100644
+--- a/qtbase/src/corelib/thread/qmutex.h
++++ b/qtbase/src/corelib/thread/qmutex.h
+@@ -42,6 +42,7 @@
+ 
+ #include <QtCore/qglobal.h>
+ #include <QtCore/qatomic.h>
++#include <QtCore/qtsan_impl.h>
+ #include <new>
+ 
+ #if __has_include(<chrono>)
+@@ -77,19 +78,37 @@ public:
+ 
+     // BasicLockable concept
+     inline void lock() QT_MUTEX_LOCK_NOEXCEPT {
++        QtTsan::mutexPreLock(this, 0u);
++
+         if (!fastTryLock())
+             lockInternal();
++
++        QtTsan::mutexPostLock(this, 0u, 0);
+     }
+ 
+     // BasicLockable concept
+     inline void unlock() noexcept {
+         Q_ASSERT(d_ptr.loadRelaxed()); //mutex must be locked
++
++        QtTsan::mutexPreUnlock(this, 0u);
++
+         if (!fastTryUnlock())
+             unlockInternal();
++
++        QtTsan::mutexPostUnlock(this, 0u);
+     }
+ 
+     bool tryLock() noexcept {
+-        return fastTryLock();
++        unsigned tsanFlags = QtTsan::TryLock;
++        QtTsan::mutexPreLock(this, tsanFlags);
++
++        const bool success = fastTryLock();
++
++        if (!success)
++            tsanFlags |= QtTsan::TryLockFailed;
++        QtTsan::mutexPostLock(this, tsanFlags, 0);
++
++        return success;
+     }
+ 
+     // Lockable concept
+@@ -134,8 +153,16 @@ public:
+ #else
+     QMutex() { d_ptr.storeRelaxed(nullptr); }
+ #endif
++#if QT_DEPRECATED_SINCE(5,15)
+     enum RecursionMode { NonRecursive, Recursive };
++    QT_DEPRECATED_VERSION_X(5, 15, "Use QRecursiveMutex instead of a recursive QMutex")
+     explicit QMutex(RecursionMode mode);
++
++    QT_DEPRECATED_VERSION_X(5, 15, "Use QRecursiveMutex instead of a recursive QMutex")
++    bool isRecursive() const noexcept
++    { return QBasicMutex::isRecursive(); }
++#endif
++
+     ~QMutex();
+ 
+     // BasicLockable concept
+@@ -166,9 +193,6 @@ public:
+     }
+ #endif
+ 
+-    bool isRecursive() const noexcept
+-    { return QBasicMutex::isRecursive(); }
+-
+ private:
+     Q_DISABLE_COPY(QMutex)
+     friend class QMutexLocker;
+diff --git a/qtbase/src/corelib/thread/qreadwritelock.cpp b/qtbase/src/corelib/thread/qreadwritelock.cpp
+index 8c28507d5a..9dd8503116 100644
+--- a/qtbase/src/corelib/thread/qreadwritelock.cpp
++++ b/qtbase/src/corelib/thread/qreadwritelock.cpp
+@@ -155,7 +155,7 @@ QReadWriteLock::QReadWriteLock(RecursionMode recursionMode)
+ */
+ QReadWriteLock::~QReadWriteLock()
+ {
+-    auto d = d_ptr.loadRelaxed();
++    auto d = d_ptr.loadAcquire();
+     if (isUncontendedLocked(d)) {
+         qWarning("QReadWriteLock: destroying locked QReadWriteLock");
+         return;
+@@ -445,7 +445,7 @@ void QReadWriteLock::unlock()
+ /*! \internal  Helper for QWaitCondition::wait */
+ QReadWriteLock::StateForWaitCondition QReadWriteLock::stateForWaitCondition() const
+ {
+-    QReadWriteLockPrivate *d = d_ptr.loadRelaxed();
++    QReadWriteLockPrivate *d = d_ptr.loadAcquire();
+     switch (quintptr(d) & StateMask) {
+     case StateLockedForRead: return LockedForRead;
+     case StateLockedForWrite: return LockedForWrite;
+@@ -453,6 +453,7 @@ QReadWriteLock::StateForWaitCondition QReadWriteLock::stateForWaitCondition() co
+ 
+     if (!d)
+         return Unlocked;
++    const auto lock = qt_scoped_lock(d->mutex);
+     if (d->writerCount > 1)
+         return RecursivelyLocked;
+     else if (d->writerCount == 1)
+diff --git a/qtbase/src/corelib/thread/qsemaphore.cpp b/qtbase/src/corelib/thread/qsemaphore.cpp
+index 1d01fc1b28..3ecdee3747 100644
+--- a/qtbase/src/corelib/thread/qsemaphore.cpp
++++ b/qtbase/src/corelib/thread/qsemaphore.cpp
+@@ -354,7 +354,12 @@ void QSemaphore::release(int n)
+         quintptr nn = unsigned(n);
+         if (futexHasWaiterCount)
+             nn |= quint64(nn) << 32;    // token count replicated in high word
+-        quintptr prevValue = u.fetchAndAddRelease(nn);
++        quintptr prevValue = u.loadRelaxed();
++        quintptr newValue;
++        do { // loop just to ensure the operations are done atomically
++            newValue = prevValue + nn;
++            newValue &= (futexNeedsWakeAllBit - 1);
++        } while (!u.testAndSetRelease(prevValue, newValue, prevValue));
+         if (futexNeedsWake(prevValue)) {
+ #ifdef FUTEX_OP
+             if (futexHasWaiterCount) {
+@@ -376,7 +381,6 @@ void QSemaphore::release(int n)
+                 quint32 oparg = 0;
+                 quint32 cmp = FUTEX_OP_CMP_NE;
+                 quint32 cmparg = 0;
+-                u.fetchAndAndRelease(futexNeedsWakeAllBit - 1);
+                 futexWakeOp(*futexLow32(&u), n, INT_MAX, *futexHigh32(&u), FUTEX_OP(op, oparg, cmp, cmparg));
+                 return;
+             }
+@@ -388,7 +392,6 @@ 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(futexNeedsWakeAllBit - 1);
+             if (futexHasWaiterCount) {
+                 futexWakeAll(*futexLow32(&u));
+                 futexWakeAll(*futexHigh32(&u));
+diff --git a/qtbase/src/corelib/thread/qthread_p.h b/qtbase/src/corelib/thread/qthread_p.h
+index b2d1628e6e..f32f6f0460 100644
+--- a/qtbase/src/corelib/thread/qthread_p.h
++++ b/qtbase/src/corelib/thread/qthread_p.h
+@@ -174,7 +174,7 @@ public:
+     int returnCode;
+ 
+     uint stackSize;
+-    QThread::Priority priority;
++    std::underlying_type<QThread::Priority>::type priority;
+ 
+     static QThread *threadForId(int id);
+ 
+@@ -213,6 +213,13 @@ public:
+             QCoreApplication::instance()->postEvent(q_ptr, new QEvent(QEvent::Quit));
+         }
+     }
++
++#ifndef Q_OS_INTEGRITY
++private:
++    // Used in QThread(Private)::start to avoid racy access to QObject::objectName,
++    // unset afterwards. On INTEGRITY we set the thread name before starting it.
++    QString objectName;
++#endif
+ };
+ 
+ #else // QT_CONFIG(thread)
+diff --git a/qtbase/src/corelib/thread/qthread_unix.cpp b/qtbase/src/corelib/thread/qthread_unix.cpp
+index 56a8e0a038..610117a640 100644
+--- a/qtbase/src/corelib/thread/qthread_unix.cpp
++++ b/qtbase/src/corelib/thread/qthread_unix.cpp
+@@ -169,8 +169,7 @@ static void set_thread_data(QThreadData *data)
+ 
+ static void clear_thread_data()
+ {
+-    currentThreadData = nullptr;
+-    pthread_setspecific(current_thread_data_key, nullptr);
++    set_thread_data(nullptr);
+ }
+ 
+ template <typename T>
+@@ -296,7 +295,7 @@ void *QThreadPrivate::start(void *arg)
+             QMutexLocker locker(&thr->d_func()->mutex);
+ 
+             // do we need to reset the thread priority?
+-            if (int(thr->d_func()->priority) & ThreadPriorityResetFlag) {
++            if (thr->d_func()->priority & ThreadPriorityResetFlag) {
+                 thr->d_func()->setPriority(QThread::Priority(thr->d_func()->priority & ~ThreadPriorityResetFlag));
+             }
+ 
+@@ -316,10 +315,10 @@ void *QThreadPrivate::start(void *arg)
+             // Sets the name of the current thread. We can only do this
+             // when the thread is starting, as we don't have a cross
+             // platform way of setting the name of an arbitrary thread.
+-            if (Q_LIKELY(thr->objectName().isEmpty()))
++            if (Q_LIKELY(thr->d_func()->objectName.isEmpty()))
+                 setCurrentThreadName(thr->metaObject()->className());
+             else
+-                setCurrentThreadName(thr->objectName().toLocal8Bit());
++                setCurrentThreadName(std::exchange(thr->d_func()->objectName, {}).toLocal8Bit());
+         }
+ #endif
+ 
+@@ -671,7 +670,7 @@ void QThread::start(Priority priority)
+                 // could not set scheduling hints, fallback to inheriting them
+                 // we'll try again from inside the thread
+                 pthread_attr_setinheritsched(&attr, PTHREAD_INHERIT_SCHED);
+-                d->priority = Priority(priority | ThreadPriorityResetFlag);
++                d->priority = static_cast<std::underlying_type<QThread::Priority>::type>(priority) | ThreadPriorityResetFlag;
+             }
+             break;
+         }
+@@ -702,7 +701,10 @@ void QThread::start(Priority priority)
+         pthread_attr_setthreadname(&attr, metaObject()->className());
+     else
+         pthread_attr_setthreadname(&attr, objectName().toLocal8Bit());
++#else
++    d->objectName = objectName();
+ #endif
++
+     pthread_t threadId;
+     int code = pthread_create(&threadId, &attr, QThreadPrivate::start, this);
+     if (code == EPERM) {
+diff --git a/qtbase/src/corelib/thread/qthread_win.cpp b/qtbase/src/corelib/thread/qthread_win.cpp
+index bc70e3178a..4e76972498 100644
+--- a/qtbase/src/corelib/thread/qthread_win.cpp
++++ b/qtbase/src/corelib/thread/qthread_win.cpp
+@@ -394,10 +394,9 @@ unsigned int __stdcall QT_ENSURE_STACK_ALIGNED_FOR_SSE QThreadPrivate::start(voi
+ 
+ #if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) && !defined(Q_OS_WINRT)
+     // sets the name of the current thread.
+-    QByteArray objectName = thr->objectName().toLocal8Bit();
+-    qt_set_thread_name(HANDLE(-1),
+-                       objectName.isEmpty() ?
+-                       thr->metaObject()->className() : objectName.constData());
++    qt_set_thread_name(HANDLE(-1), thr->d_func()->objectName.isEmpty()
++                        ? thr->metaObject()->className()
++                        : std::exchange(thr->d_func()->objectName, {}).toLocal8Bit().constData());
+ #endif
+ 
+     emit thr->started(QThread::QPrivateSignal());
+@@ -503,6 +502,7 @@ void QThread::start(Priority priority)
+     if (d->running)
+         return;
+ 
++    d->objectName = objectName();
+     d->running = true;
+     d->finished = false;
+     d->exited = false;
+@@ -548,7 +548,7 @@ void QThread::start(Priority priority)
+ 
+     int prio;
+     d->priority = priority;
+-    switch (d->priority) {
++    switch (priority) {
+     case IdlePriority:
+         prio = THREAD_PRIORITY_IDLE;
+         break;
+@@ -686,7 +686,7 @@ void QThreadPrivate::setPriority(QThread::Priority threadPriority)
+ 
+     int prio;
+     priority = threadPriority;
+-    switch (priority) {
++    switch (threadPriority) {
+     case QThread::IdlePriority:
+         prio = THREAD_PRIORITY_IDLE;
+         break;
+diff --git a/qtbase/src/corelib/thread/qtsan_impl.h b/qtbase/src/corelib/thread/qtsan_impl.h
+new file mode 100644
+index 0000000000..580a738b91
+--- /dev/null
++++ b/qtbase/src/corelib/thread/qtsan_impl.h
+@@ -0,0 +1,115 @@
++/****************************************************************************
++**
++** Copyright (C) 2017 Intel Corporation.
++** Copyright (C) 2022 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
++** 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 QTSAN_IMPL_H
++#define QTSAN_IMPL_H
++
++#include <QtCore/qglobal.h>
++
++#if (__has_feature(thread_sanitizer) || defined(__SANITIZE_THREAD__)) && __has_include(<sanitizer/tsan_interface.h>)
++#  define QT_BUILDING_UNDER_TSAN
++#  include <sanitizer/tsan_interface.h>
++#endif
++
++QT_BEGIN_NAMESPACE
++
++namespace QtTsan {
++#ifdef QT_BUILDING_UNDER_TSAN
++inline void futexAcquire(void *addr, void *addr2 = nullptr)
++{
++    // A futex call ensures total ordering on the futex words
++    // (in either success or failure of the call). Instruct TSAN accordingly,
++    // as TSAN does not understand the futex(2) syscall (or equivalent).
++    ::__tsan_acquire(addr);
++    if (addr2)
++        ::__tsan_acquire(addr2);
++}
++
++inline void futexRelease(void *addr, void *addr2 = nullptr)
++{
++    if (addr2)
++        ::__tsan_release(addr2);
++    ::__tsan_release(addr);
++}
++
++inline void mutexPreLock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_pre_lock(addr, flags);
++}
++
++inline void mutexPostLock(void *addr, unsigned flags, int recursion)
++{
++    ::__tsan_mutex_post_lock(addr, flags, recursion);
++}
++
++inline void mutexPreUnlock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_pre_unlock(addr, flags);
++}
++
++inline void mutexPostUnlock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_post_unlock(addr, flags);
++}
++
++enum : unsigned {
++    MutexWriteReentrant = ::__tsan_mutex_write_reentrant,
++    TryLock = ::__tsan_mutex_try_lock,
++    TryLockFailed = ::__tsan_mutex_try_lock_failed,
++};
++#else
++inline void futexAcquire(void *, void * = nullptr) {}
++inline void futexRelease(void *, void * = nullptr) {}
++
++enum : unsigned {
++    MutexWriteReentrant,
++    TryLock,
++    TryLockFailed,
++};
++inline void mutexPreLock(void *, unsigned) {}
++inline void mutexPostLock(void *, unsigned, int) {}
++inline void mutexPreUnlock(void *, unsigned) {}
++inline void mutexPostUnlock(void *, unsigned) {}
++#endif // QT_BUILDING_UNDER_TSAN
++} // namespace QtTsan
++
++QT_END_NAMESPACE
++
++#endif // QTSAN_IMPL_H
+diff --git a/qtbase/src/corelib/thread/qwaitcondition_unix.cpp b/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
+index 88b058f410..0f1da4dc9b 100644
+--- a/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
++++ b/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
+@@ -213,7 +213,7 @@ bool QWaitCondition::wait(QMutex *mutex, QDeadlineTimer deadline)
+ {
+     if (! mutex)
+         return false;
+-    if (mutex->isRecursive()) {
++    if (static_cast<QBasicMutex *>(mutex)->isRecursive()) {
+         qWarning("QWaitCondition: cannot wait on recursive mutexes");
+         return false;
+     }
+diff --git a/qtbase/src/corelib/time/qdatetime.cpp b/qtbase/src/corelib/time/qdatetime.cpp
+index ec12569e3f..2c0b098079 100644
+--- a/qtbase/src/corelib/time/qdatetime.cpp
++++ b/qtbase/src/corelib/time/qdatetime.cpp
+@@ -43,6 +43,7 @@
+ #if QT_CONFIG(datetimeparser)
+ #include "private/qdatetimeparser_p.h"
+ #endif
++#include <private/qnumeric_p.h>
+ 
+ #include "qdatastream.h"
+ #include "qset.h"
+@@ -1429,9 +1430,11 @@ QDate QDate::addDays(qint64 ndays) const
+     if (isNull())
+         return QDate();
+ 
+-    // Due to limits on minJd() and maxJd() we know that any overflow
+-    // will be invalid and caught by fromJulianDay().
+-    return fromJulianDay(jd + ndays);
++    qint64 r;
++    if (Q_UNLIKELY(add_overflow(jd, ndays, &r)))
++        return QDate();
++    else
++        return fromJulianDay(r);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/corelib/time/qtimezone.cpp b/qtbase/src/corelib/time/qtimezone.cpp
+index 0309e43e52..3d451696a1 100644
+--- a/qtbase/src/corelib/time/qtimezone.cpp
++++ b/qtbase/src/corelib/time/qtimezone.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2013 John Layt <jlayt@kde.org>
++** Copyright (C) 2020 John Layt <jlayt@kde.org>
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtCore module of the Qt Toolkit.
+@@ -975,9 +975,15 @@ QList<QByteArray> QTimeZone::windowsIdToIanaIds(const QByteArray &windowsId,
+ }
+ 
+ #ifndef QT_NO_DATASTREAM
++// Invalid, as an IANA ID: too long, starts with - and has other invalid characters in it
++static inline QString invalidId() { return QStringLiteral("-No Time Zone Specified!"); }
++
+ QDataStream &operator<<(QDataStream &ds, const QTimeZone &tz)
+ {
+-    tz.d->serialize(ds);
++    if (tz.isValid())
++        tz.d->serialize(ds);
++    else
++        ds << invalidId();
+     return ds;
+ }
+ 
+@@ -985,7 +991,9 @@ QDataStream &operator>>(QDataStream &ds, QTimeZone &tz)
+ {
+     QString ianaId;
+     ds >> ianaId;
+-    if (ianaId == QLatin1String("OffsetFromUtc")) {
++    if (ianaId == invalidId()) {
++        tz = QTimeZone();
++    } else if (ianaId == QLatin1String("OffsetFromUtc")) {
+         int utcOffset;
+         QString name;
+         QString abbreviation;
+diff --git a/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp b/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
+index b1611d7ddb..a7a6a72ccf 100644
+--- a/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
++++ b/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
+@@ -42,6 +42,7 @@
+ #include "qtimezone.h"
+ #include "qtimezoneprivate_p.h"
+ #include "private/qlocale_tools_p.h"
++#include "private/qlocking_p.h"
+ 
+ #include <QtCore/QDataStream>
+ #include <QtCore/QDateTime>
+@@ -62,6 +63,10 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++#if QT_CONFIG(icu)
++static QBasicMutex s_icu_mutex;
++#endif
++
+ /*
+     Private
+ 
+@@ -670,6 +675,9 @@ QTzTimeZonePrivate::~QTzTimeZonePrivate()
+ 
+ QTzTimeZonePrivate *QTzTimeZonePrivate::clone() const
+ {
++#if QT_CONFIG(icu)
++    const auto lock = qt_scoped_lock(s_icu_mutex);
++#endif
+     return new QTzTimeZonePrivate(*this);
+ }
+ 
+@@ -913,12 +921,14 @@ QString QTzTimeZonePrivate::displayName(qint64 atMSecsSinceEpoch,
+                                         const QLocale &locale) const
+ {
+ #if QT_CONFIG(icu)
++    auto lock = qt_unique_lock(s_icu_mutex);
+     if (!m_icu)
+         m_icu = new QIcuTimeZonePrivate(m_id);
+     // TODO small risk may not match if tran times differ due to outdated files
+     // TODO Some valid TZ names are not valid ICU names, use translation table?
+     if (m_icu->isValid())
+         return m_icu->displayName(atMSecsSinceEpoch, nameType, locale);
++    lock.unlock();
+ #else
+     Q_UNUSED(nameType)
+     Q_UNUSED(locale)
+@@ -932,12 +942,14 @@ QString QTzTimeZonePrivate::displayName(QTimeZone::TimeType timeType,
+                                         const QLocale &locale) const
+ {
+ #if QT_CONFIG(icu)
++    auto lock = qt_unique_lock(s_icu_mutex);
+     if (!m_icu)
+         m_icu = new QIcuTimeZonePrivate(m_id);
+     // TODO small risk may not match if tran times differ due to outdated files
+     // TODO Some valid TZ names are not valid ICU names, use translation table?
+     if (m_icu->isValid())
+         return m_icu->displayName(timeType, nameType, locale);
++    lock.unlock();
+ #else
+     Q_UNUSED(timeType)
+     Q_UNUSED(nameType)
+diff --git a/qtbase/src/corelib/tools/qarraydata.h b/qtbase/src/corelib/tools/qarraydata.h
+index dcd95924c1..d01739e7e6 100644
+--- a/qtbase/src/corelib/tools/qarraydata.h
++++ b/qtbase/src/corelib/tools/qarraydata.h
+@@ -42,6 +42,7 @@
+ 
+ #include <QtCore/qrefcount.h>
+ #include <string.h>
++#include <cstdint>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -58,14 +59,14 @@ struct Q_CORE_EXPORT QArrayData
+     {
+         Q_ASSERT(size == 0
+                 || offset < 0 || size_t(offset) >= sizeof(QArrayData));
+-        return reinterpret_cast<char *>(this) + offset;
++        return reinterpret_cast<void *> (reinterpret_cast<uintptr_t>(this) + offset);
+     }
+ 
+     const void *data() const
+     {
+         Q_ASSERT(size == 0
+                 || offset < 0 || size_t(offset) >= sizeof(QArrayData));
+-        return reinterpret_cast<const char *>(this) + offset;
++        return reinterpret_cast<void *> (reinterpret_cast<uintptr_t>(this) + offset);
+     }
+ 
+     // This refers to array data mutability, not "header data" represented by
+diff --git a/qtbase/src/corelib/tools/qfreelist_p.h b/qtbase/src/corelib/tools/qfreelist_p.h
+index 5ba23b344b..9974102136 100644
+--- a/qtbase/src/corelib/tools/qfreelist_p.h
++++ b/qtbase/src/corelib/tools/qfreelist_p.h
+@@ -161,7 +161,7 @@ class QFreeList
+                 return i;
+             x -= size;
+         }
+-        Q_ASSERT(false);
++        Q_UNREACHABLE();
+         return -1;
+     }
+ 
+diff --git a/qtbase/src/corelib/tools/qversionnumber.h b/qtbase/src/corelib/tools/qversionnumber.h
+index d43b86ba51..2843f2b043 100644
+--- a/qtbase/src/corelib/tools/qversionnumber.h
++++ b/qtbase/src/corelib/tools/qversionnumber.h
+@@ -273,10 +273,10 @@ public:
+ 
+     Q_REQUIRED_RESULT Q_CORE_EXPORT QString toString() const;
+ #if QT_STRINGVIEW_LEVEL < 2
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(const QString &string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(const QString &string, int *suffixIndex = nullptr);
+ #endif
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QLatin1String string, int *suffixIndex = nullptr);
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QStringView string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(QLatin1String string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(QStringView string, int *suffixIndex = nullptr);
+ 
+ private:
+ #ifndef QT_NO_DATASTREAM
+diff --git a/qtbase/src/dbus/qdbusintegrator.cpp b/qtbase/src/dbus/qdbusintegrator.cpp
+index 5b66ce971b..28a3b0ffea 100644
+--- a/qtbase/src/dbus/qdbusintegrator.cpp
++++ b/qtbase/src/dbus/qdbusintegrator.cpp
+@@ -1135,7 +1135,13 @@ void QDBusConnectionPrivate::closeConnection()
+         }
+     }
+ 
+-    qDeleteAll(pendingCalls);
++    for (auto it = pendingCalls.begin(); it != pendingCalls.end(); ++it) {
++        auto call = *it;
++        if (!call->ref.deref()) {
++            delete call;
++        }
++    }
++    pendingCalls.clear();
+ 
+     // Disconnect all signals from signal hooks and from the object tree to
+     // avoid QObject::destroyed being sent to dbus daemon thread which has
+@@ -2584,6 +2590,11 @@ QDBusConnectionPrivate::findMetaObject(const QString &service, const QString &pa
+         if (mo)
+             return mo;
+     }
++    if (path.isEmpty()) {
++        error = QDBusError(QDBusError::InvalidObjectPath, QLatin1String("Object path cannot be empty"));
++        lastError = error;
++        return nullptr;
++    }
+ 
+     // introspect the target object
+     QDBusMessage msg = QDBusMessage::createMethodCall(service, path,
+diff --git a/qtbase/src/dbus/qdbusmetaobject.cpp b/qtbase/src/dbus/qdbusmetaobject.cpp
+index 5265568f42..7e9f0f1acc 100644
+--- a/qtbase/src/dbus/qdbusmetaobject.cpp
++++ b/qtbase/src/dbus/qdbusmetaobject.cpp
+@@ -210,6 +210,9 @@ QDBusMetaObjectGenerator::findType(const QByteArray &signature,
+         } else if (signature == "a{ss}") {
+             result.name = "QMap<QString,QString>";
+             type = qMetaTypeId<QMap<QString, QString> >();
++        } else if (signature == "aay") {
++            result.name = "QByteArrayList";
++            type = qMetaTypeId<QByteArrayList>();
+         } else {
+             result.name = "{D-Bus type \"" + signature + "\"}";
+             type = registerComplexDBusType(result.name);
+diff --git a/qtbase/src/gui/accessible/qaccessible.cpp b/qtbase/src/gui/accessible/qaccessible.cpp
+index d705bfccb5..0caf3c808c 100644
+--- a/qtbase/src/gui/accessible/qaccessible.cpp
++++ b/qtbase/src/gui/accessible/qaccessible.cpp
+@@ -54,6 +54,7 @@
+ #include <QtCore/qdebug.h>
+ #include <QtCore/qloggingcategory.h>
+ #include <QtCore/qmetaobject.h>
++#include <QtCore/private/qmetaobject_p.h>
+ #include <QtCore/qhash.h>
+ #include <private/qfactoryloader_p.h>
+ 
+@@ -681,6 +682,25 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
+     // Create a QAccessibleInterface for the object class. Start by the most
+     // derived class and walk up the class hierarchy.
+     const QMetaObject *mo = object->metaObject();
++    const auto *objectPriv = QObjectPrivate::get(object);
++    /*
++     We do not want to cache each and every QML metaobject (Button_QMLTYPE_124,
++     Button_QMLTYPE_125, etc.). Those dynamic metaobjects shouldn't have an
++     accessible interface in any case. Instead, we start the whole checking
++     with the first non-dynamic meta-object. To avoid potential regressions
++     in other areas of Qt that also use dynamic metaobjects, we only do this
++     for objects that are QML-related (approximated by checking whether they
++     have ddata set).
++    */
++    const bool qmlRelated = !objectPriv->isDeletingChildren &&
++                            objectPriv->declarativeData;
++    while (qmlRelated && mo) {
++        auto mop = QMetaObjectPrivate::get(mo);
++        if (!mop || !(mop->flags & DynamicMetaObject))
++            break;
++
++        mo = mo->superClass();
++    };
+     while (mo) {
+         const QString cn = QLatin1String(mo->className());
+ 
+@@ -696,14 +716,15 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
+         // Find a QAccessiblePlugin (factory) for the class name. If there's
+         // no entry in the cache try to create it using the plugin loader.
+         if (!qAccessiblePlugins()->contains(cn)) {
++            QAccessiblePlugin *factory = nullptr; // 0 means "no plugin found". This is cached as well.
+             const int index = loader()->indexOf(cn);
+-            if (index != -1) {
+-                QAccessiblePlugin *factory = qobject_cast<QAccessiblePlugin *>(loader()->instance(index));
+-                qAccessiblePlugins()->insert(cn, factory);
+-            }
++            if (index != -1)
++                factory = qobject_cast<QAccessiblePlugin *>(loader()->instance(index));
++            qAccessiblePlugins()->insert(cn, factory);
+         }
+ 
+         // At this point the cache should contain a valid factory pointer or 0:
++        Q_ASSERT(qAccessiblePlugins()->contains(cn));
+         QAccessiblePlugin *factory = qAccessiblePlugins()->value(cn);
+         if (factory) {
+             QAccessibleInterface *result = factory->create(cn, object);
+diff --git a/qtbase/src/gui/configure.json b/qtbase/src/gui/configure.json
+index 1f08795c57..12c95742d2 100644
+--- a/qtbase/src/gui/configure.json
++++ b/qtbase/src/gui/configure.json
+@@ -834,7 +834,8 @@
+                     "// embedded devices, are not intended to be used together with X. EGL support",
+                     "// has to be disabled in plugins like xcb in this case since the native display,",
+                     "// window and pixmap types will be different than what an X-based platform",
+-                    "// plugin would expect."
++                    "// plugin would expect.",
++                    "#define USE_X11"
+                 ],
+                 "include": [ "EGL/egl.h", "X11/Xlib.h" ],
+                 "main": [
+diff --git a/qtbase/src/gui/image/qbmphandler.cpp b/qtbase/src/gui/image/qbmphandler.cpp
+index 96f1e8cb1d..0e73bbbdb0 100644
+--- a/qtbase/src/gui/image/qbmphandler.cpp
++++ b/qtbase/src/gui/image/qbmphandler.cpp
+@@ -150,16 +150,42 @@ static QDataStream &operator<<(QDataStream &s, const BMP_INFOHDR &bi)
+     return s;
+ }
+ 
+-static int calc_shift(uint mask)
++static uint calc_shift(uint mask)
+ {
+-    int result = 0;
+-    while (mask && !(mask & 1)) {
++    uint result = 0;
++    while ((mask >= 0x100) || (!(mask & 1) && mask)) {
+         result++;
+         mask >>= 1;
+     }
+     return result;
+ }
+ 
++static uint calc_scale(uint low_mask)
++{
++    uint result = 8;
++    while (low_mask && result) {
++        result--;
++        low_mask >>= 1;
++    }
++    return result;
++}
++
++static inline uint apply_scale(uint value, uint scale)
++{
++    if (!(scale & 0x07)) // return immediately if scale == 8 or 0
++        return value;
++
++    uint filled = 8 - scale;
++    uint result = value << scale;
++
++    do {
++        result |= result >> filled;
++        filled <<= 1;
++    } while (filled < 8);
++
++    return result;
++}
++
+ static bool read_dib_fileheader(QDataStream &s, BMP_FILEHDR &bf)
+ {
+     // read BMP file header
+@@ -222,14 +248,14 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+     uint green_mask = 0;
+     uint blue_mask = 0;
+     uint alpha_mask = 0;
+-    int red_shift = 0;
+-    int green_shift = 0;
+-    int blue_shift = 0;
+-    int alpha_shift = 0;
+-    int red_scale = 0;
+-    int green_scale = 0;
+-    int blue_scale = 0;
+-    int alpha_scale = 0;
++    uint red_shift = 0;
++    uint green_shift = 0;
++    uint blue_shift = 0;
++    uint alpha_shift = 0;
++    uint red_scale = 0;
++    uint green_scale = 0;
++    uint blue_scale = 0;
++    uint alpha_scale = 0;
+ 
+     if (!d->isSequential())
+         d->seek(startpos + BMP_FILEHDR_SIZE + bi.biSize); // goto start of colormap or masks
+@@ -308,19 +334,19 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+         red_shift = calc_shift(red_mask);
+         if (((red_mask >> red_shift) + 1) == 0)
+             return false;
+-        red_scale = 256 / ((red_mask >> red_shift) + 1);
++        red_scale = calc_scale(red_mask >> red_shift);
+         green_shift = calc_shift(green_mask);
+         if (((green_mask >> green_shift) + 1) == 0)
+             return false;
+-        green_scale = 256 / ((green_mask >> green_shift) + 1);
++        green_scale = calc_scale(green_mask >> green_shift);
+         blue_shift = calc_shift(blue_mask);
+         if (((blue_mask >> blue_shift) + 1) == 0)
+             return false;
+-        blue_scale = 256 / ((blue_mask >> blue_shift) + 1);
++        blue_scale = calc_scale(blue_mask >> blue_shift);
+         alpha_shift = calc_shift(alpha_mask);
+         if (((alpha_mask >> alpha_shift) + 1) == 0)
+             return false;
+-        alpha_scale = 256 / ((alpha_mask >> alpha_shift) + 1);
++        alpha_scale = calc_scale(alpha_mask >> alpha_shift);
+     } else if (comp == BMP_RGB && (nbits == 24 || nbits == 32)) {
+         blue_mask = 0x000000ff;
+         green_mask = 0x0000ff00;
+@@ -328,17 +354,15 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+         blue_shift = 0;
+         green_shift = 8;
+         red_shift = 16;
+-        blue_scale = green_scale = red_scale = 1;
++        blue_scale = green_scale = red_scale = 0;
+     } else if (comp == BMP_RGB && nbits == 16) {
+         blue_mask = 0x001f;
+         green_mask = 0x03e0;
+         red_mask = 0x7c00;
+         blue_shift = 0;
+-        green_shift = 2;
+-        red_shift = 7;
+-        red_scale = 1;
+-        green_scale = 1;
+-        blue_scale = 8;
++        green_shift = 5;
++        red_shift = 10;
++        blue_scale = green_scale = red_scale = 3;
+     }
+ 
+ #if 0
+@@ -544,10 +568,10 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+                     c |= *(uchar*)(b+2)<<16;
+                 if (nbits > 24)
+                     c |= *(uchar*)(b+3)<<24;
+-                *p++ = qRgba(((c & red_mask) >> red_shift) * red_scale,
+-                                        ((c & green_mask) >> green_shift) * green_scale,
+-                                        ((c & blue_mask) >> blue_shift) * blue_scale,
+-                                        transp ? ((c & alpha_mask) >> alpha_shift) * alpha_scale : 0xff);
++                *p++ = qRgba(apply_scale((c & red_mask) >> red_shift, red_scale),
++                             apply_scale((c & green_mask) >> green_shift, green_scale),
++                             apply_scale((c & blue_mask) >> blue_shift, blue_scale),
++                             transp ? apply_scale((c & alpha_mask) >> alpha_shift, alpha_scale) : 0xff);
+                 b += nbits/8;
+             }
+         }
+diff --git a/qtbase/src/gui/image/qimage.cpp b/qtbase/src/gui/image/qimage.cpp
+index 7152ac1607..0df772564c 100644
+--- a/qtbase/src/gui/image/qimage.cpp
++++ b/qtbase/src/gui/image/qimage.cpp
+@@ -4694,6 +4694,8 @@ QImage QImage::smoothScaled(int w, int h) const {
+ static QImage rotated90(const QImage &image)
+ {
+     QImage out(image.height(), image.width(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+@@ -4722,6 +4724,8 @@ static QImage rotated180(const QImage &image)
+         return image.mirrored(true, true);
+ 
+     QImage out(image.width(), image.height(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+@@ -4734,6 +4738,8 @@ static QImage rotated180(const QImage &image)
+ static QImage rotated270(const QImage &image)
+ {
+     QImage out(image.height(), image.width(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+diff --git a/qtbase/src/gui/kernel/qcursor.cpp b/qtbase/src/gui/kernel/qcursor.cpp
+index d6ccaff8ed..455088241c 100644
+--- a/qtbase/src/gui/kernel/qcursor.cpp
++++ b/qtbase/src/gui/kernel/qcursor.cpp
+@@ -251,7 +251,8 @@ void QCursor::setPos(QScreen *screen, int x, int y)
+ {
+     if (screen) {
+         if (QPlatformCursor *cursor = screen->handle()->cursor()) {
+-            const QPoint devicePos = QHighDpi::toNativePixels(QPoint(x, y), screen);
++            const QPoint pos(x, y);
++            const QPoint devicePos = QHighDpi::toNativePixels(pos, screen->virtualSiblingAt(pos));
+             // Need to check, since some X servers generate null mouse move
+             // events, causing looping in applications which call setPos() on
+             // every mouse move event.
+diff --git a/qtbase/src/gui/kernel/qhighdpiscaling.cpp b/qtbase/src/gui/kernel/qhighdpiscaling.cpp
+index 9bbf2773a9..3ac4a4d8b6 100644
+--- a/qtbase/src/gui/kernel/qhighdpiscaling.cpp
++++ b/qtbase/src/gui/kernel/qhighdpiscaling.cpp
+@@ -580,9 +580,8 @@ void QHighDpiScaling::setScreenFactor(QScreen *screen, qreal factor)
+     else
+         qNamedScreenScaleFactors()->insert(name, factor);
+ 
+-    // hack to force re-evaluation of screen geometry
+     if (screen->handle())
+-        screen->d_func()->setPlatformScreen(screen->handle()); // updates geometries based on scale factor
++        screen->d_func()->updateLogicalDpi();
+ }
+ 
+ QPoint QHighDpiScaling::mapPositionToNative(const QPoint &pos, const QPlatformScreen *platformScreen)
+diff --git a/qtbase/src/gui/kernel/qkeysequence.cpp b/qtbase/src/gui/kernel/qkeysequence.cpp
+index a75b8ef920..4f2d294739 100644
+--- a/qtbase/src/gui/kernel/qkeysequence.cpp
++++ b/qtbase/src/gui/kernel/qkeysequence.cpp
+@@ -701,6 +701,10 @@ static const struct {
+     { Qt::Key_TouchpadToggle,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad Toggle") },
+     { Qt::Key_TouchpadOn,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad On") },
+     { Qt::Key_TouchpadOff,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad Off") },
++    { Qt::Key_Shift,  QT_TRANSLATE_NOOP("QShortcut", "Shift") },
++    { Qt::Key_Control,  QT_TRANSLATE_NOOP("QShortcut", "Control") },
++    { Qt::Key_Alt,  QT_TRANSLATE_NOOP("QShortcut", "Alt") },
++    { Qt::Key_Meta,  QT_TRANSLATE_NOOP("QShortcut", "Meta") },
+ 
+ };
+ static Q_CONSTEXPR int numKeyNames = sizeof keyname / sizeof *keyname;
+diff --git a/qtbase/src/gui/kernel/qplatformservices.cpp b/qtbase/src/gui/kernel/qplatformservices.cpp
+index fdc6a6c4aa..ac47f98c5d 100644
+--- a/qtbase/src/gui/kernel/qplatformservices.cpp
++++ b/qtbase/src/gui/kernel/qplatformservices.cpp
+@@ -55,6 +55,19 @@ QT_BEGIN_NAMESPACE
+     \brief The QPlatformServices provides the backend for desktop-related functionality.
+ */
+ 
++/*!
++    \enum QPlatformServices::Capability
++
++    Capabilities are used to determine a specific platform service's availability.
++
++    \value ColorPickingFromScreen The platform natively supports color picking from screen.
++    This capability indicates that the platform supports "opaque" color picking, where the
++    platform implements a complete user experience for color picking and outputs a color.
++    This is in contrast to the application implementing the color picking user experience
++    (taking care of showing a cross hair, instructing the platform integration to obtain
++    the color at a given pixel, etc.). The related service function is pickColor().
++ */
++
+ QPlatformServices::QPlatformServices()
+ { }
+ 
+@@ -85,5 +98,16 @@ QByteArray QPlatformServices::desktopEnvironment() const
+     return QByteArray("UNKNOWN");
+ }
+ 
++QPlatformServiceColorPicker *QPlatformServices::colorPicker(QWindow *parent)
++{
++    Q_UNUSED(parent);
++    return nullptr;
++}
++
++bool QPlatformServices::hasCapability(Capability capability) const
++{
++    Q_UNUSED(capability)
++    return false;
++}
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/gui/kernel/qplatformservices.h b/qtbase/src/gui/kernel/qplatformservices.h
+index 5de96cfa7d..a8b2a4ce71 100644
+--- a/qtbase/src/gui/kernel/qplatformservices.h
++++ b/qtbase/src/gui/kernel/qplatformservices.h
+@@ -50,16 +50,32 @@
+ //
+ 
+ #include <QtGui/qtguiglobal.h>
++#include <QtCore/qobject.h>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+ class QUrl;
++class QWindow;
++
++class Q_GUI_EXPORT QPlatformServiceColorPicker : public QObject
++{
++    Q_OBJECT
++public:
++    using QObject::QObject;
++    virtual void pickColor() = 0;
++Q_SIGNALS:
++    void colorPicked(const QColor &color);
++};
+ 
+ class Q_GUI_EXPORT QPlatformServices
+ {
+ public:
+     Q_DISABLE_COPY_MOVE(QPlatformServices)
+ 
++    enum Capability {
++        ColorPicking,
++    };
++
+     QPlatformServices();
+     virtual ~QPlatformServices() { }
+ 
+@@ -67,6 +83,10 @@ public:
+     virtual bool openDocument(const QUrl &url);
+ 
+     virtual QByteArray desktopEnvironment() const;
++
++    virtual bool hasCapability(Capability capability) const;
++
++    virtual QPlatformServiceColorPicker *colorPicker(QWindow *parent = nullptr);
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/gui/kernel/qplatformtheme.cpp b/qtbase/src/gui/kernel/qplatformtheme.cpp
+index 71521c0339..2325873245 100644
+--- a/qtbase/src/gui/kernel/qplatformtheme.cpp
++++ b/qtbase/src/gui/kernel/qplatformtheme.cpp
+@@ -163,6 +163,8 @@ QT_BEGIN_NAMESPACE
+ 
+     \value ShowShortcutsInContextMenus (bool) Whether to display shortcut key sequences in context menus.
+ 
++    \value ButtonPressKeys (QList<Qt::Key>) A list of keys that can be used to press buttons via keyboard input.
++
+     \sa themeHint(), QStyle::pixelMetric()
+ */
+ 
+@@ -563,6 +565,8 @@ QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint)
+         }
+     case MouseQuickSelectionThreshold:
+         return QVariant(10);
++    case ButtonPressKeys:
++        return QVariant::fromValue(QList<Qt::Key>({ Qt::Key_Space, Qt::Key_Select }));
+     }
+     return QVariant();
+ }
+diff --git a/qtbase/src/gui/kernel/qplatformtheme.h b/qtbase/src/gui/kernel/qplatformtheme.h
+index 3185fc4541..7e6c9d5740 100644
+--- a/qtbase/src/gui/kernel/qplatformtheme.h
++++ b/qtbase/src/gui/kernel/qplatformtheme.h
+@@ -120,7 +120,8 @@ public:
+         TouchDoubleTapDistance,
+         ShowShortcutsInContextMenus,
+         IconFallbackSearchPaths,
+-        MouseQuickSelectionThreshold
++        MouseQuickSelectionThreshold,
++        ButtonPressKeys
+     };
+ 
+     enum DialogType {
+diff --git a/qtbase/src/gui/kernel/qscreen.cpp b/qtbase/src/gui/kernel/qscreen.cpp
+index 8e0eb35116..5d172a58dd 100644
+--- a/qtbase/src/gui/kernel/qscreen.cpp
++++ b/qtbase/src/gui/kernel/qscreen.cpp
+@@ -77,6 +77,12 @@ QScreen::QScreen(QPlatformScreen *screen)
+     d->setPlatformScreen(screen);
+ }
+ 
++void QScreenPrivate::updateLogicalDpi()
++{
++    logicalDpi = QPlatformScreen::overrideDpi(platformScreen->logicalDpi());
++    updateGeometriesWithSignals(); // updates geometries based on scale factor
++}
++
+ void QScreenPrivate::updateGeometriesWithSignals()
+ {
+     const QRect oldGeometry = geometry;
+diff --git a/qtbase/src/gui/kernel/qscreen_p.h b/qtbase/src/gui/kernel/qscreen_p.h
+index 7da542c25e..e50fc3190b 100644
+--- a/qtbase/src/gui/kernel/qscreen_p.h
++++ b/qtbase/src/gui/kernel/qscreen_p.h
+@@ -70,6 +70,7 @@ public:
+         geometry = platformScreen->deviceIndependentGeometry();
+         availableGeometry = QHighDpi::fromNative(platformScreen->availableGeometry(), QHighDpiScaling::factor(platformScreen), geometry.topLeft());
+     }
++    void updateLogicalDpi();
+ 
+     void updatePrimaryOrientation();
+     void updateGeometriesWithSignals();
+diff --git a/qtbase/src/gui/painting/qblendfunctions_p.h b/qtbase/src/gui/painting/qblendfunctions_p.h
+index 080da98ec4..6997d62b3c 100644
+--- a/qtbase/src/gui/painting/qblendfunctions_p.h
++++ b/qtbase/src/gui/painting/qblendfunctions_p.h
+@@ -246,25 +246,32 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+                                   int dudx, int dvdx, int dudy, int dvdy, int u0, int v0,
+                                   Blender blender)
+ {
+-    int fromY = qMax(qRound(topY), clip.top());
+-    int toY = qMin(qRound(bottomY), clip.top() + clip.height());
++    qint64 fromY = qMax(qRound(topY), clip.top());
++    qint64 toY = qMin(qRound(bottomY), clip.top() + clip.height());
+     if (fromY >= toY)
+         return;
+ 
+     qreal leftSlope = (bottomLeft.x - topLeft.x) / (bottomLeft.y - topLeft.y);
+     qreal rightSlope = (bottomRight.x - topRight.x) / (bottomRight.y - topRight.y);
+-    int dx_l = int(leftSlope * 0x10000);
+-    int dx_r = int(rightSlope * 0x10000);
+-    int x_l = int((topLeft.x + (qreal(0.5) + fromY - topLeft.y) * leftSlope + qreal(0.5)) * 0x10000);
+-    int x_r = int((topRight.x + (qreal(0.5) + fromY - topRight.y) * rightSlope + qreal(0.5)) * 0x10000);
+-
+-    int fromX, toX, x1, x2, u, v, i, ii;
++    qint64 dx_l = qint64(leftSlope * 0x10000);
++    qint64 dx_r = qint64(rightSlope * 0x10000);
++    qint64 x_l = qint64((topLeft.x + (qreal(0.5) + fromY - topLeft.y) * leftSlope + qreal(0.5)) * 0x10000);
++    qint64 x_r = qint64((topRight.x + (qreal(0.5) + fromY - topRight.y) * rightSlope + qreal(0.5)) * 0x10000);
++
++    qint64 sourceRectTop = qint64(sourceRect.top());
++    qint64 sourceRectLeft = qint64(sourceRect.left());
++    qint64 sourceRectWidth = qint64(sourceRect.width());
++    qint64 sourceRectHeight = qint64(sourceRect.height());
++    qint64 clipLeft = qint64(clip.left());
++    qint64 clipWidth = qint64(clip.width());
++
++    qint64 fromX, toX, x1, x2, u, v, i, ii;
+     DestT *line;
+-    for (int y = fromY; y < toY; ++y) {
++    for (qint64 y = fromY; y < toY; ++y) {
+         line = reinterpret_cast<DestT *>(reinterpret_cast<uchar *>(destPixels) + y * dbpl);
+ 
+-        fromX = qMax(x_l >> 16, clip.left());
+-        toX = qMin(x_r >> 16, clip.left() + clip.width());
++        fromX = qMax(x_l >> 16, clipLeft);
++        toX = qMin(x_r >> 16, clipLeft + clipWidth);
+         if (fromX < toX) {
+             // Because of rounding, we can get source coordinates outside the source image.
+             // Clamp these coordinates to the source rect to avoid segmentation fault and
+@@ -275,10 +282,10 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             u = x1 * dudx + y * dudy + u0;
+             v = x1 * dvdx + y * dvdy + v0;
+             for (; x1 < toX; ++x1) {
+-                int uu = u >> 16;
+-                int vv = v >> 16;
+-                if (uu >= sourceRect.left() && uu < sourceRect.left() + sourceRect.width()
+-                    && vv >= sourceRect.top() && vv < sourceRect.top() + sourceRect.height()) {
++                qint64 uu = u >> 16;
++                qint64 vv = v >> 16;
++                if (uu >= sourceRectLeft && uu < sourceRectLeft + sourceRectWidth
++                    && vv >= sourceRectTop && vv < sourceRectTop + sourceRectHeight) {
+                     break;
+                 }
+                 u += dudx;
+@@ -290,10 +297,10 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             u = (x2 - 1) * dudx + y * dudy + u0;
+             v = (x2 - 1) * dvdx + y * dvdy + v0;
+             for (; x2 > x1; --x2) {
+-                int uu = u >> 16;
+-                int vv = v >> 16;
+-                if (uu >= sourceRect.left() && uu < sourceRect.left() + sourceRect.width()
+-                    && vv >= sourceRect.top() && vv < sourceRect.top() + sourceRect.height()) {
++                qint64 uu = u >> 16;
++                qint64 vv = v >> 16;
++                if (uu >= sourceRectLeft && uu < sourceRectLeft + sourceRectWidth
++                    && vv >= sourceRectTop && vv < sourceRectTop + sourceRectHeight) {
+                     break;
+                 }
+                 u -= dudx;
+@@ -308,8 +315,8 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             // Beginning of the scan line, with per-pixel checks.
+             i = x1 - fromX;
+             while (i) {
+-                int uu = qBound(sourceRect.left(), u >> 16, sourceRect.left() + sourceRect.width() - 1);
+-                int vv = qBound(sourceRect.top(), v >> 16, sourceRect.top() + sourceRect.height() - 1);
++                qint64 uu = qBound(sourceRectLeft, u >> 16, sourceRectLeft + sourceRectWidth - 1);
++                qint64 vv = qBound(sourceRectTop, v >> 16, sourceRectTop + sourceRectHeight - 1);
+                 blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + vv * sbpl)[uu]);
+                 u += dudx;
+                 v += dvdx;
+@@ -348,8 +355,8 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             // End of the scan line, with per-pixel checks.
+             i = toX - x2;
+             while (i) {
+-                int uu = qBound(sourceRect.left(), u >> 16, sourceRect.left() + sourceRect.width() - 1);
+-                int vv = qBound(sourceRect.top(), v >> 16, sourceRect.top() + sourceRect.height() - 1);
++                qint64 uu = qBound(sourceRectLeft, u >> 16, sourceRectLeft + sourceRectWidth - 1);
++                qint64 vv = qBound(sourceRectTop, v >> 16, sourceRectTop + sourceRectHeight - 1);
+                 blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + vv * sbpl)[uu]);
+                 u += dudx;
+                 v += dvdx;
+diff --git a/qtbase/src/gui/painting/qcolortrclut_p.h b/qtbase/src/gui/painting/qcolortrclut_p.h
+index 76a6a60803..24fd522e6c 100644
+--- a/qtbase/src/gui/painting/qcolortrclut_p.h
++++ b/qtbase/src/gui/painting/qcolortrclut_p.h
+@@ -118,6 +118,7 @@ public:
+         return QRgba64::fromRgba64(r, g, b, qAlpha(rgb32) * 257);
+ #endif
+     }
++    QRgba64 toLinear64(QRgba64) const = delete;
+ 
+     QRgb toLinear(QRgb rgb32) const
+     {
+diff --git a/qtbase/src/gui/painting/qdrawhelper.cpp b/qtbase/src/gui/painting/qdrawhelper.cpp
+index a61793508a..5ba2d277b7 100644
+--- a/qtbase/src/gui/painting/qdrawhelper.cpp
++++ b/qtbase/src/gui/painting/qdrawhelper.cpp
+@@ -6091,7 +6091,7 @@ static inline void alphargbblend_argb32(quint32 *dst, uint coverage, const QRgba
+ static inline void rgbBlendPixel(QRgba64 &dst, int coverage, QRgba64 slinear, const QColorTrcLut *colorProfile)
+ {
+     // Do a gammacorrected RGB alphablend...
+-    const QRgba64 dlinear = colorProfile ? colorProfile->toLinear64(dst) : dst;
++    const QRgba64 dlinear = colorProfile ? colorProfile->toLinear(dst) : dst;
+ 
+     QRgba64 blend = rgbBlend(dlinear, slinear, coverage);
+ 
+diff --git a/qtbase/src/gui/painting/qpaintengine_raster.cpp b/qtbase/src/gui/painting/qpaintengine_raster.cpp
+index 283923de52..f08eb9cbee 100644
+--- a/qtbase/src/gui/painting/qpaintengine_raster.cpp
++++ b/qtbase/src/gui/painting/qpaintengine_raster.cpp
+@@ -560,31 +560,6 @@ void QRasterPaintEngine::updateMatrix(const QTransform &matrix)
+     QRasterPaintEngineState *s = state();
+     // FALCON: get rid of this line, see drawImage call below.
+     s->matrix = matrix;
+-    QTransform::TransformationType txop = s->matrix.type();
+-
+-    switch (txop) {
+-
+-    case QTransform::TxNone:
+-        s->flags.int_xform = true;
+-        break;
+-
+-    case QTransform::TxTranslate:
+-        s->flags.int_xform = qreal(int(s->matrix.dx())) == s->matrix.dx()
+-                            && qreal(int(s->matrix.dy())) == s->matrix.dy();
+-        break;
+-
+-    case QTransform::TxScale:
+-        s->flags.int_xform = qreal(int(s->matrix.dx())) == s->matrix.dx()
+-                            && qreal(int(s->matrix.dy())) == s->matrix.dy()
+-                            && qreal(int(s->matrix.m11())) == s->matrix.m11()
+-                            && qreal(int(s->matrix.m22())) == s->matrix.m22();
+-        break;
+-
+-    default: // shear / perspective...
+-        s->flags.int_xform = false;
+-        break;
+-    }
+-
+     s->flags.tx_noshear = qt_scaleForTransform(s->matrix, &s->txscale);
+ 
+     ensureOutlineMapper();
+@@ -617,7 +592,6 @@ QRasterPaintEngineState::QRasterPaintEngineState()
+     flags.bilinear = false;
+     flags.legacy_rounding = false;
+     flags.fast_text = true;
+-    flags.int_xform = true;
+     flags.tx_noshear = true;
+     flags.fast_images = true;
+ 
+@@ -1793,7 +1767,7 @@ void QRasterPaintEngine::fill(const QVectorPath &path, const QBrush &brush)
+     QRectF cpRect = path.controlPointRect();
+     const QRectF pathDeviceRect = s->matrix.mapRect(cpRect);
+     // Skip paths that by conservative estimates are completely outside the paint device.
+-    if (!pathDeviceRect.intersects(QRectF(d->deviceRect)))
++    if (!pathDeviceRect.intersects(QRectF(d->deviceRect)) || !pathDeviceRect.isValid())
+         return;
+ 
+     ProcessSpans blend = d->getBrushFunc(pathDeviceRect, &s->brushData);
+diff --git a/qtbase/src/gui/painting/qpaintengine_raster_p.h b/qtbase/src/gui/painting/qpaintengine_raster_p.h
+index 089aadc3f7..bf7363d5aa 100644
+--- a/qtbase/src/gui/painting/qpaintengine_raster_p.h
++++ b/qtbase/src/gui/painting/qpaintengine_raster_p.h
+@@ -111,7 +111,6 @@ public:
+         uint bilinear : 1;
+         uint legacy_rounding : 1;
+         uint fast_text : 1;
+-        uint int_xform : 1;
+         uint tx_noshear : 1;
+         uint fast_images : 1;
+     };
+diff --git a/qtbase/src/gui/painting/qpainterpath.cpp b/qtbase/src/gui/painting/qpainterpath.cpp
+index f9544a3241..d80fafeaf1 100644
+--- a/qtbase/src/gui/painting/qpainterpath.cpp
++++ b/qtbase/src/gui/painting/qpainterpath.cpp
+@@ -1253,7 +1253,7 @@ void QPainterPath::addText(const QPointF &point, const QFont &f, const QString &
+ 
+         if (si.analysis.flags < QScriptAnalysis::TabOrObject) {
+             QGlyphLayout glyphs = eng->shapedGlyphs(&si);
+-            QFontEngine *fe = f.d->engineForScript(si.analysis.script);
++            QFontEngine *fe = eng->fontEngine(si);
+             Q_ASSERT(fe);
+             fe->addOutlineToPath(x, y, glyphs, this,
+                                  si.analysis.bidiLevel % 2
+diff --git a/qtbase/src/gui/painting/qpathclipper_p.h b/qtbase/src/gui/painting/qpathclipper_p.h
+index 9444a87b71..18f64c5e8c 100644
+--- a/qtbase/src/gui/painting/qpathclipper_p.h
++++ b/qtbase/src/gui/painting/qpathclipper_p.h
+@@ -156,7 +156,7 @@ public:
+     int vertex(Direction direction) const;
+ 
+ private:
+-    int m_next[2][2];
++    int m_next[2][2] = { { -1, -1 }, { -1, -1 } };
+ };
+ 
+ class QPathSegments
+@@ -296,10 +296,6 @@ inline QPathEdge::QPathEdge(int a, int b)
+     , angle(0)
+     , invAngle(0)
+ {
+-    m_next[0][0] = -1;
+-    m_next[1][0] = -1;
+-    m_next[0][0] = -1;
+-    m_next[1][0] = -1;
+ }
+ 
+ inline int QPathEdge::next(Traversal traversal, Direction direction) const
+diff --git a/qtbase/src/gui/painting/qpdf.cpp b/qtbase/src/gui/painting/qpdf.cpp
+index 3066744f1b..2c8d3c3b53 100644
+--- a/qtbase/src/gui/painting/qpdf.cpp
++++ b/qtbase/src/gui/painting/qpdf.cpp
+@@ -2760,6 +2760,8 @@ int QPdfEnginePrivate::addBrushPattern(const QTransform &m, bool *specifyColor,
+         return gradientBrush(brush, matrix, gStateObject);
+     }
+ 
++    matrix = brush.transform() * matrix;
++
+     if ((!brush.isOpaque() && brush.style() < Qt::LinearGradientPattern) || opacity != 1.0)
+         *gStateObject = addConstantAlphaObject(qRound(brush.color().alpha() * opacity),
+                                                qRound(pen.color().alpha() * opacity));
+diff --git a/qtbase/src/gui/painting/qstroker.cpp b/qtbase/src/gui/painting/qstroker.cpp
+index cb5d395e80..3b6357a893 100644
+--- a/qtbase/src/gui/painting/qstroker.cpp
++++ b/qtbase/src/gui/painting/qstroker.cpp
+@@ -1182,6 +1182,7 @@ void QDashStroker::processCurrentSubpath()
+         // Check if the entire line should be clipped away or simplified
+         bool clipIt = clipping && !lineIntersectsRect(prev, e, clip_tl, clip_br);
+         bool skipDashing = elen * invSumLength > repetitionLimit();
++        int maxDashes = dashCount;
+         if (skipDashing || clipIt) {
+             // Cut away full dash sequences.
+             elen -= std::floor(elen * invSumLength) * sumLength;
+@@ -1196,7 +1197,7 @@ void QDashStroker::processCurrentSubpath()
+                     pos = estop; // move pos to next path element
+                     done = true;
+                 } else { // Dash is on this line
+-                    pos = dpos + estart;
++                    pos = --maxDashes > 0 ? dpos + estart : estop;
+                     done = pos >= estop;
+                     if (++idash >= dashCount)
+                         idash = 0;
+diff --git a/qtbase/src/gui/painting/qt_attribution.json b/qtbase/src/gui/painting/qt_attribution.json
+index 7b16e8c211..0e87d30aa2 100644
+--- a/qtbase/src/gui/painting/qt_attribution.json
++++ b/qtbase/src/gui/painting/qt_attribution.json
+@@ -10,7 +10,7 @@
+         "Homepage": "http://www.freetype.org",
+         "License": "Freetype Project License or GNU General Public License v2.0 only",
+         "LicenseId": "FTL or GPL-2.0",
+-        "LicenseFile": "../../3rdparty/freetype/docs/LICENSE.TXT",
++        "LicenseFile": "../../3rdparty/freetype/LICENSE.TXT",
+         "Copyright": "Copyright 2000-2016 by David Turner, Robert Wilhelm, and Werner Lemberg."
+     },
+     {
+diff --git a/qtbase/src/gui/rhi/qshader_p_p.h b/qtbase/src/gui/rhi/qshader_p_p.h
+index ec9d25971f..4a5a7a6d51 100644
+--- a/qtbase/src/gui/rhi/qshader_p_p.h
++++ b/qtbase/src/gui/rhi/qshader_p_p.h
+@@ -68,13 +68,13 @@ struct Q_GUI_EXPORT QShaderPrivate
+     {
+     }
+ 
+-    QShaderPrivate(const QShaderPrivate *other)
++    QShaderPrivate(const QShaderPrivate &other)
+         : ref(1),
+-          qsbVersion(other->qsbVersion),
+-          stage(other->stage),
+-          desc(other->desc),
+-          shaders(other->shaders),
+-          bindings(other->bindings)
++          qsbVersion(other.qsbVersion),
++          stage(other.stage),
++          desc(other.desc),
++          shaders(other.shaders),
++          bindings(other.bindings)
+     {
+     }
+ 
+diff --git a/qtbase/src/gui/rhi/qshaderdescription_p_p.h b/qtbase/src/gui/rhi/qshaderdescription_p_p.h
+index ec2b0b6b4c..3da33a8a2b 100644
+--- a/qtbase/src/gui/rhi/qshaderdescription_p_p.h
++++ b/qtbase/src/gui/rhi/qshaderdescription_p_p.h
+@@ -63,16 +63,16 @@ struct Q_GUI_EXPORT QShaderDescriptionPrivate
+         localSize[0] = localSize[1] = localSize[2] = 0;
+     }
+ 
+-    QShaderDescriptionPrivate(const QShaderDescriptionPrivate *other)
++    QShaderDescriptionPrivate(const QShaderDescriptionPrivate &other)
+         : ref(1),
+-          inVars(other->inVars),
+-          outVars(other->outVars),
+-          uniformBlocks(other->uniformBlocks),
+-          pushConstantBlocks(other->pushConstantBlocks),
+-          storageBlocks(other->storageBlocks),
+-          combinedImageSamplers(other->combinedImageSamplers),
+-          storageImages(other->storageImages),
+-          localSize(other->localSize)
++          inVars(other.inVars),
++          outVars(other.outVars),
++          uniformBlocks(other.uniformBlocks),
++          pushConstantBlocks(other.pushConstantBlocks),
++          storageBlocks(other.storageBlocks),
++          combinedImageSamplers(other.combinedImageSamplers),
++          storageImages(other.storageImages),
++          localSize(other.localSize)
+     {
+     }
+ 
+diff --git a/qtbase/src/gui/text/qfontdatabase.cpp b/qtbase/src/gui/text/qfontdatabase.cpp
+index a657a8c516..4fc0100958 100644
+--- a/qtbase/src/gui/text/qfontdatabase.cpp
++++ b/qtbase/src/gui/text/qfontdatabase.cpp
+@@ -983,7 +983,7 @@ QFontEngine *loadSingleEngine(int script,
+         if (style->key.stretch != 0 && request.stretch != 0
+             && (request.styleName.isEmpty() || request.styleName != style->styleName)) {
+             def.stretch = (request.stretch * 100 + style->key.stretch / 2) / style->key.stretch;
+-        } else {
++        } else if (request.stretch == QFont::AnyStretch) {
+             def.stretch = 100;
+         }
+ 
+diff --git a/qtbase/src/gui/text/qtextdocumentlayout.cpp b/qtbase/src/gui/text/qtextdocumentlayout.cpp
+index f3e6ea2100..72267e9380 100644
+--- a/qtbase/src/gui/text/qtextdocumentlayout.cpp
++++ b/qtbase/src/gui/text/qtextdocumentlayout.cpp
+@@ -2123,7 +2123,7 @@ void QTextDocumentLayoutPrivate::drawListItem(const QPointF &offset, QPainter *p
+ {
+     Q_Q(const QTextDocumentLayout);
+     const QTextBlockFormat blockFormat = bl.blockFormat();
+-    const QTextCharFormat charFormat = QTextCursor(bl).charFormat();
++    const QTextCharFormat charFormat = bl.charFormat();
+     QFont font(charFormat.font());
+     if (q->paintDevice())
+         font = QFont(font, q->paintDevice());
+diff --git a/qtbase/src/gui/text/qtextengine.cpp b/qtbase/src/gui/text/qtextengine.cpp
+index ce4abac472..a6c66e5d2d 100644
+--- a/qtbase/src/gui/text/qtextengine.cpp
++++ b/qtbase/src/gui/text/qtextengine.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2021 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtGui module of the Qt Toolkit.
+@@ -1565,6 +1565,12 @@ void QTextEngine::shapeText(int item) const
+         // Overwrite with 0 token to indicate failure
+         QGlyphLayout g = availableGlyphs(&si);
+         g.glyphs[0] = 0;
++        g.attributes[0].clusterStart = true;
++
++        ushort *log_clusters = logClusters(&si);
++        for (int i = 0; i < itemLength; ++i)
++            log_clusters[i] = 0;
++
+         return;
+     }
+ 
+diff --git a/qtbase/src/gui/util/qdesktopservices.cpp b/qtbase/src/gui/util/qdesktopservices.cpp
+index fbb63a9408..4d5fafaaa7 100644
+--- a/qtbase/src/gui/util/qdesktopservices.cpp
++++ b/qtbase/src/gui/util/qdesktopservices.cpp
+@@ -54,6 +54,8 @@
+ #include <qpa/qplatformintegration.h>
+ #include <qdir.h>
+ 
++#include <QtCore/private/qlocking_p.h>
++
+ QT_BEGIN_NAMESPACE
+ 
+ class QOpenUrlHandlerRegistry : public QObject
+@@ -81,6 +83,7 @@ Q_GLOBAL_STATIC(QOpenUrlHandlerRegistry, handlerRegistry)
+ 
+ void QOpenUrlHandlerRegistry::handlerDestroyed(QObject *handler)
+ {
++    const auto lock = qt_scoped_lock(mutex);
+     HandlerHash::Iterator it = handlers.begin();
+     while (it != handlers.end()) {
+         if (it->receiver == handler) {
+@@ -294,7 +297,8 @@ void QDesktopServices::setUrlHandler(const QString &scheme, QObject *receiver, c
+     h.name = method;
+     registry->handlers.insert(scheme.toLower(), h);
+     QObject::connect(receiver, SIGNAL(destroyed(QObject*)),
+-                     registry, SLOT(handlerDestroyed(QObject*)));
++                     registry, SLOT(handlerDestroyed(QObject*)),
++                     Qt::DirectConnection);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/gui/util/qpkmhandler.cpp b/qtbase/src/gui/util/qpkmhandler.cpp
+index e0c3b75efe..3414f9d8ba 100644
+--- a/qtbase/src/gui/util/qpkmhandler.cpp
++++ b/qtbase/src/gui/util/qpkmhandler.cpp
+@@ -57,7 +57,7 @@ struct PkmType
+     quint32 bytesPerBlock;
+ };
+ 
+-static PkmType typeMap[5] = {
++static constexpr PkmType typeMap[5] = {
+     { 0x8D64,  8 },   // GL_ETC1_RGB8_OES
+     { 0x9274,  8 },   // GL_COMPRESSED_RGB8_ETC2
+     { 0, 0 },         // unused (obsolete)
+diff --git a/qtbase/src/network/access/qnetworkreplyfileimpl.cpp b/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
+index b6be93147a..6e69b4c4d3 100644
+--- a/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
++++ b/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
+@@ -89,9 +89,10 @@ QNetworkReplyFileImpl::QNetworkReplyFileImpl(QNetworkAccessManager *manager, con
+         // we handle only local files
+         QString msg = QCoreApplication::translate("QNetworkAccessFileBackend", "Request for opening non-local file %1").arg(url.toString());
+         setError(QNetworkReply::ProtocolInvalidOperationError, msg);
++        setFinished(true); // We're finished, will emit finished() after ctor is done.
+         QMetaObject::invokeMethod(this, "errorOccurred", Qt::QueuedConnection,
+             Q_ARG(QNetworkReply::NetworkError, QNetworkReply::ProtocolInvalidOperationError));
+-        fileOpenFinished(false);
++        QMetaObject::invokeMethod(this, [this](){ fileOpenFinished(false); }, Qt::QueuedConnection);
+         return;
+     }
+ #endif
+diff --git a/qtbase/src/network/access/qnetworkreplyimpl.cpp b/qtbase/src/network/access/qnetworkreplyimpl.cpp
+index bcdf6ee2f1..3b6deb82bd 100644
+--- a/qtbase/src/network/access/qnetworkreplyimpl.cpp
++++ b/qtbase/src/network/access/qnetworkreplyimpl.cpp
+@@ -680,7 +680,7 @@ void QNetworkReplyImplPrivate::appendDownstreamData(QIODevice *data)
+     // read until EOF from data
+     if (Q_UNLIKELY(copyDevice)) {
+         qCritical("QNetworkReplyImpl: copy from QIODevice already in progress -- "
+-                  "backend probly needs to be fixed");
++                  "backend probably needs to be fixed");
+         return;
+     }
+ 
+diff --git a/qtbase/src/network/kernel/qauthenticator.cpp b/qtbase/src/network/kernel/qauthenticator.cpp
+index d9fe7bc47b..ccd04b294a 100644
+--- a/qtbase/src/network/kernel/qauthenticator.cpp
++++ b/qtbase/src/network/kernel/qauthenticator.cpp
+@@ -50,6 +50,7 @@
+ #include <qstring.h>
+ #include <qdatetime.h>
+ #include <qrandom.h>
++#include "private/qsystemlibrary_p.h"
+ 
+ #ifdef Q_OS_WIN
+ #include <qmutex.h>
+@@ -1563,7 +1564,7 @@ static bool q_SSPI_library_load()
+ 
+     // Initialize security interface
+     if (pSecurityFunctionTable == nullptr) {
+-        securityDLLHandle = LoadLibrary(L"secur32.dll");
++        securityDLLHandle = QSystemLibrary::load(L"secur32");
+         if (securityDLLHandle != nullptr) {
+             INIT_SECURITY_INTERFACE pInitSecurityInterface =
+                 reinterpret_cast<INIT_SECURITY_INTERFACE>(
+diff --git a/qtbase/src/network/kernel/qhostinfo_unix.cpp b/qtbase/src/network/kernel/qhostinfo_unix.cpp
+index 9b0a2ee669..73679c9ef1 100644
+--- a/qtbase/src/network/kernel/qhostinfo_unix.cpp
++++ b/qtbase/src/network/kernel/qhostinfo_unix.cpp
+@@ -122,7 +122,6 @@ static QFunctionPointer resolveSymbol(QLibrary &lib, const char *sym)
+ 
+ LibResolv::LibResolv()
+ {
+-    QLibrary lib;
+ #ifdef LIBRESOLV_SO
+     lib.setFileName(QStringLiteral(LIBRESOLV_SO));
+     if (!lib.load())
+diff --git a/qtbase/src/network/socket/qsocks5socketengine.cpp b/qtbase/src/network/socket/qsocks5socketengine.cpp
+index 3a046fd116..97fadca0b3 100644
+--- a/qtbase/src/network/socket/qsocks5socketengine.cpp
++++ b/qtbase/src/network/socket/qsocks5socketengine.cpp
+@@ -1296,7 +1296,7 @@ void QSocks5SocketEnginePrivate::_q_udpSocketReadNotification()
+         int pos = 0;
+         const char *buf = inBuf.constData();
+         if (inBuf.size() < 4) {
+-            QSOCKS5_D_DEBUG << "bugus udp data, discarding";
++            QSOCKS5_D_DEBUG << "bogus udp data, discarding";
+             return;
+         }
+         QSocks5RevivedDatagram datagram;
+diff --git a/qtbase/src/network/ssl/qsslcontext_openssl.cpp b/qtbase/src/network/ssl/qsslcontext_openssl.cpp
+index c9f202f573..c992da9d8e 100644
+--- a/qtbase/src/network/ssl/qsslcontext_openssl.cpp
++++ b/qtbase/src/network/ssl/qsslcontext_openssl.cpp
+@@ -409,7 +409,7 @@ init_context:
+         break;
+     case QSsl::DtlsV1_0OrLater:
+         minVersion = DTLS1_VERSION;
+-        maxVersion = DTLS_MAX_VERSION;
++        maxVersion = 0;
+         break;
+     case QSsl::DtlsV1_2:
+         minVersion = DTLS1_2_VERSION;
+@@ -417,7 +417,7 @@ init_context:
+         break;
+     case QSsl::DtlsV1_2OrLater:
+         minVersion = DTLS1_2_VERSION;
+-        maxVersion = DTLS_MAX_VERSION;
++        maxVersion = 0;
+         break;
+     case QSsl::TlsV1_3OrLater:
+ #ifdef TLS1_3_VERSION
+@@ -455,7 +455,7 @@ init_context:
+     }
+ 
+     // Enable bug workarounds.
+-    long options = QSslSocketBackendPrivate::setupOpenSslOptions(configuration.protocol(), configuration.d->sslOptions);
++    qssloptions options = QSslSocketBackendPrivate::setupOpenSslOptions(configuration.protocol(), configuration.d->sslOptions);
+     q_SSL_CTX_set_options(sslContext->ctx, options);
+ 
+     // Tell OpenSSL to release memory early
+diff --git a/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp b/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
+index aaf8741130..b58935372c 100644
+--- a/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
++++ b/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
+@@ -59,57 +59,6 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-#ifdef OPENSSL_NO_DEPRECATED_3_0
+-
+-static int q_DH_check(DH *dh, int *status)
+-{
+-    // DH_check was first deprecated in OpenSSL 3.0.0, as low-level
+-    // API; the EVP_PKEY family of functions was advised as an alternative.
+-    // As of now EVP_PKEY_params_check ends up calling ... DH_check,
+-    // which is good enough.
+-
+-    Q_ASSERT(dh);
+-    Q_ASSERT(status);
+-
+-    EVP_PKEY *key = q_EVP_PKEY_new();
+-    if (!key) {
+-        qCWarning(lcSsl, "EVP_PKEY_new failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-    const auto keyDeleter = qScopeGuard([key](){
+-        q_EVP_PKEY_free(key);
+-    });
+-    if (!q_EVP_PKEY_set1_DH(key, dh)) {
+-        qCWarning(lcSsl, "EVP_PKEY_set1_DH failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-
+-    EVP_PKEY_CTX *keyCtx = q_EVP_PKEY_CTX_new(key, nullptr);
+-    if (!keyCtx) {
+-        qCWarning(lcSsl, "EVP_PKEY_CTX_new failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-    const auto ctxDeleter = qScopeGuard([keyCtx]{
+-        q_EVP_PKEY_CTX_free(keyCtx);
+-    });
+-
+-    const int result = q_EVP_PKEY_param_check(keyCtx);
+-    QSslSocketBackendPrivate::logAndClearErrorQueue();
+-    // Note: unlike DH_check, we cannot obtain the 'status',
+-    // if the 'result' is 0 (actually the result is 1 only
+-    // if this 'status' was 0). We could probably check the
+-    // errors from the error queue, but it's not needed anyway
+-    // - see the 'isSafeDH' below, how it returns immediately
+-    // on 0.
+-    Q_UNUSED(status)
+-
+-    return result;
+-}
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+-
+ static bool isSafeDH(DH *dh)
+ {
+     int status = 0;
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl.cpp b/qtbase/src/network/ssl/qsslsocket_openssl.cpp
+index 37fad2a68f..8f6858c867 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl.cpp
++++ b/qtbase/src/network/ssl/qsslsocket_openssl.cpp
+@@ -550,9 +550,9 @@ static void q_loadCiphersForConnection(SSL *connection, QList<QSslCipher> &ciphe
+ // Defined in qsslsocket.cpp
+ void q_setDefaultDtlsCiphers(const QList<QSslCipher> &ciphers);
+ 
+-long QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions)
++qssloptions QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions)
+ {
+-    long options;
++    qssloptions options;
+     if (protocol == QSsl::TlsV1SslV3)
+         options = SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3;
+     else if (protocol == QSsl::SecureProtocols)
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_p.h b/qtbase/src/network/ssl/qsslsocket_openssl_p.h
+index 4103de23e8..5547589256 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_p.h
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_p.h
+@@ -107,6 +107,12 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++typedef uint64_t qssloptions;
++#else
++typedef unsigned long qssloptions;
++#endif
++
+ struct QSslErrorEntry {
+     int code;
+     int depth;
+@@ -171,7 +177,7 @@ public:
+     QVector<QSslError> ocspErrors;
+     QByteArray ocspResponseDer;
+ 
+-    Q_AUTOTEST_EXPORT static long setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions);
++    Q_AUTOTEST_EXPORT static qssloptions setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions);
+     static QSslCipher QSslCipher_from_SSL_CIPHER(const SSL_CIPHER *cipher);
+     static QList<QSslCertificate> STACKOFX509_to_QSslCertificates(STACK_OF(X509) *x509);
+     static QList<QSslError> verify(const QList<QSslCertificate> &certificateChain, const QString &hostName);
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp b/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
+index e53fb279f0..459ccd0b19 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
+@@ -148,7 +148,6 @@ DEFINEFUNC(int, EVP_PKEY_up_ref, EVP_PKEY *a, a, return 0, return)
+ DEFINEFUNC2(EVP_PKEY_CTX *, EVP_PKEY_CTX_new, EVP_PKEY *pkey, pkey, ENGINE *e, e, return nullptr, return)
+ DEFINEFUNC(int, EVP_PKEY_param_check, EVP_PKEY_CTX *ctx, ctx, return 0, return)
+ DEFINEFUNC(void, EVP_PKEY_CTX_free, EVP_PKEY_CTX *ctx, ctx, return, return)
+-DEFINEFUNC(int, EVP_PKEY_base_id, EVP_PKEY *a, a, return NID_undef, return)
+ DEFINEFUNC(int, RSA_bits, RSA *a, a, return 0, return)
+ DEFINEFUNC(int, DSA_bits, DSA *a, a, return 0, return)
+ DEFINEFUNC(int, OPENSSL_sk_num, OPENSSL_STACK *a, a, return -1, return)
+@@ -158,7 +157,7 @@ DEFINEFUNC2(void, OPENSSL_sk_push, OPENSSL_STACK *a, a, void *b, b, return, DUMM
+ DEFINEFUNC(void, OPENSSL_sk_free, OPENSSL_STACK *a, a, return, DUMMYARG)
+ DEFINEFUNC2(void *, OPENSSL_sk_value, OPENSSL_STACK *a, a, int b, b, return nullptr, return)
+ DEFINEFUNC(int, SSL_session_reused, SSL *a, a, return 0, return)
+-DEFINEFUNC2(unsigned long, SSL_CTX_set_options, SSL_CTX *ctx, ctx, unsigned long op, op, return 0, return)
++DEFINEFUNC2(qssloptions, SSL_CTX_set_options, SSL_CTX *ctx, ctx, qssloptions op, op, return 0, return)
+ DEFINEFUNC(int, SSL_CTX_get_security_level, const SSL_CTX *ctx, ctx, return -1, return)
+ DEFINEFUNC2(void, SSL_CTX_set_security_level, SSL_CTX *ctx, ctx, int level, level, return, return)
+ #ifdef TLS1_3_VERSION
+@@ -371,7 +370,15 @@ DEFINEFUNC(const SSL_CIPHER *, SSL_get_current_cipher, SSL *a, a, return nullptr
+ DEFINEFUNC(int, SSL_version, const SSL *a, a, return 0, return)
+ DEFINEFUNC2(int, SSL_get_error, SSL *a, a, int b, b, return -1, return)
+ DEFINEFUNC(STACK_OF(X509) *, SSL_get_peer_cert_chain, SSL *a, a, return nullptr, return)
++
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++DEFINEFUNC(X509 *, SSL_get1_peer_certificate, SSL *a, a, return nullptr, return)
++DEFINEFUNC(int, EVP_PKEY_get_base_id, const EVP_PKEY *pkey, pkey, return -1, return)
++#else
+ DEFINEFUNC(X509 *, SSL_get_peer_certificate, SSL *a, a, return nullptr, return)
++DEFINEFUNC(int, EVP_PKEY_base_id, EVP_PKEY *a, a, return NID_undef, return)
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+ DEFINEFUNC(long, SSL_get_verify_result, const SSL *a, a, return -1, return)
+ DEFINEFUNC(SSL *, SSL_new, SSL_CTX *a, a, return nullptr, return)
+ DEFINEFUNC(SSL_CTX *, SSL_get_SSL_CTX, SSL *a, a, return nullptr, return)
+@@ -492,9 +499,7 @@ DEFINEFUNC(DH *, DH_new, DUMMYARG, DUMMYARG, return nullptr, return)
+ DEFINEFUNC(void, DH_free, DH *dh, dh, return, DUMMYARG)
+ DEFINEFUNC3(DH *, d2i_DHparams, DH**a, a, const unsigned char **pp, pp, long length, length, return nullptr, return)
+ DEFINEFUNC2(int, i2d_DHparams, DH *a, a, unsigned char **p, p, return -1, return)
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+ DEFINEFUNC2(int, DH_check, DH *dh, dh, int *codes, codes, return 0, return)
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+ DEFINEFUNC3(BIGNUM *, BN_bin2bn, const unsigned char *s, s, int len, len, BIGNUM *ret, ret, return nullptr, return)
+ 
+ #ifndef OPENSSL_NO_EC
+@@ -868,7 +873,6 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(EVP_PKEY_CTX_new)
+     RESOLVEFUNC(EVP_PKEY_param_check)
+     RESOLVEFUNC(EVP_PKEY_CTX_free)
+-    RESOLVEFUNC(EVP_PKEY_base_id)
+     RESOLVEFUNC(RSA_bits)
+     RESOLVEFUNC(OPENSSL_sk_new_null)
+     RESOLVEFUNC(OPENSSL_sk_push)
+@@ -1107,7 +1111,15 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(SSL_version)
+     RESOLVEFUNC(SSL_get_error)
+     RESOLVEFUNC(SSL_get_peer_cert_chain)
++
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++    RESOLVEFUNC(SSL_get1_peer_certificate)
++    RESOLVEFUNC(EVP_PKEY_get_base_id)
++#else
+     RESOLVEFUNC(SSL_get_peer_certificate)
++    RESOLVEFUNC(EVP_PKEY_base_id)
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+     RESOLVEFUNC(SSL_get_verify_result)
+     RESOLVEFUNC(SSL_new)
+     RESOLVEFUNC(SSL_get_SSL_CTX)
+@@ -1206,9 +1218,7 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(DH_free)
+     RESOLVEFUNC(d2i_DHparams)
+     RESOLVEFUNC(i2d_DHparams)
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+     RESOLVEFUNC(DH_check)
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+     RESOLVEFUNC(BN_bin2bn)
+ 
+ #ifndef OPENSSL_NO_EC
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h b/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
+index 95e8897a3b..27aeffa18a 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
+@@ -237,7 +237,6 @@ Q_AUTOTEST_EXPORT int q_EVP_PKEY_up_ref(EVP_PKEY *a);
+ EVP_PKEY_CTX *q_EVP_PKEY_CTX_new(EVP_PKEY *pkey, ENGINE *e);
+ void q_EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx);
+ int q_EVP_PKEY_param_check(EVP_PKEY_CTX *ctx);
+-int q_EVP_PKEY_base_id(EVP_PKEY *a);
+ int q_RSA_bits(RSA *a);
+ Q_AUTOTEST_EXPORT int q_OPENSSL_sk_num(OPENSSL_STACK *a);
+ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_pop_free(OPENSSL_STACK *a, void (*b)(void *));
+@@ -246,7 +245,7 @@ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_push(OPENSSL_STACK *st, void *data);
+ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_free(OPENSSL_STACK *a);
+ Q_AUTOTEST_EXPORT void * q_OPENSSL_sk_value(OPENSSL_STACK *a, int b);
+ int q_SSL_session_reused(SSL *a);
+-unsigned long q_SSL_CTX_set_options(SSL_CTX *ctx, unsigned long op);
++qssloptions q_SSL_CTX_set_options(SSL_CTX *ctx, qssloptions op);
+ int q_OPENSSL_init_ssl(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings);
+ size_t q_SSL_get_client_random(SSL *a, unsigned char *out, size_t outlen);
+ size_t q_SSL_SESSION_get_master_key(const SSL_SESSION *session, unsigned char *out, size_t outlen);
+@@ -510,7 +509,6 @@ const SSL_CIPHER *q_SSL_get_current_cipher(SSL *a);
+ int q_SSL_version(const SSL *a);
+ int q_SSL_get_error(SSL *a, int b);
+ STACK_OF(X509) *q_SSL_get_peer_cert_chain(SSL *a);
+-X509 *q_SSL_get_peer_certificate(SSL *a);
+ long q_SSL_get_verify_result(const SSL *a);
+ SSL *q_SSL_new(SSL_CTX *a);
+ SSL_CTX *q_SSL_get_SSL_CTX(SSL *a);
+@@ -582,10 +580,7 @@ DH *q_DH_new();
+ void q_DH_free(DH *dh);
+ DH *q_d2i_DHparams(DH **a, const unsigned char **pp, long length);
+ int q_i2d_DHparams(DH *a, unsigned char **p);
+-
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+ int q_DH_check(DH *dh, int *codes);
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+ 
+ BIGNUM *q_BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret);
+ #define q_SSL_CTX_set_tmp_dh(ctx, dh) q_SSL_CTX_ctrl((ctx), SSL_CTRL_SET_TMP_DH, 0, (char *)dh)
+@@ -754,6 +749,17 @@ void q_CRYPTO_free(void *str, const char *file, int line);
+ int q_SSL_CTX_get_security_level(const SSL_CTX *ctx);
+ void q_SSL_CTX_set_security_level(SSL_CTX *ctx, int level);
+ 
++// Here we have the ones that make difference between OpenSSL pre/post v3:
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++X509 *q_SSL_get1_peer_certificate(SSL *a);
++#define q_SSL_get_peer_certificate q_SSL_get1_peer_certificate
++int q_EVP_PKEY_get_base_id(const EVP_PKEY *pkey);
++#define q_EVP_PKEY_base_id q_EVP_PKEY_get_base_id
++#else
++X509 *q_SSL_get_peer_certificate(SSL *a);
++int q_EVP_PKEY_base_id(EVP_PKEY *a);
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+ QT_END_NAMESPACE
+ 
+ #endif
+diff --git a/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h b/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
+index bf37d07fd8..dbd42fb799 100644
+--- a/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
++++ b/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
+@@ -61,7 +61,11 @@
+ # if !defined(Q_OS_INTEGRITY)
+ #  define WIN_INTERFACE_CUSTOM   // NV
+ # endif // Q_OS_INTEGRITY
+-#endif  // QT_EGL_NO_X11
++#else // QT_EGL_NO_X11
++// If one has an eglplatform.h with https://github.com/KhronosGroup/EGL-Registry/pull/130
++// that needs USE_X11 to be defined.
++# define USE_X11
++#endif
+ 
+ #ifdef QT_EGL_WAYLAND
+ # define WAYLAND // NV
+diff --git a/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+index 159b490ce0..00aa80cd58 100644
+--- a/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
++++ b/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+@@ -567,6 +567,8 @@ void QFontconfigDatabase::populateFontDatabase()
+         fonts = FcFontList(nullptr, pattern, os);
+         FcObjectSetDestroy(os);
+         FcPatternDestroy(pattern);
++        if (!fonts)
++            return;
+     }
+ 
+     for (int i = 0; i < fonts->nfont; i++)
+diff --git a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
+index b713c19447..7cb9a8c79a 100644
+--- a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
++++ b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
+@@ -95,6 +95,7 @@ static constexpr const auto KeyTbl = qMakeArray(
+         Xkb2Qt<XKB_KEY_Clear,                   Qt::Key_Delete>,
+         Xkb2Qt<XKB_KEY_Pause,                   Qt::Key_Pause>,
+         Xkb2Qt<XKB_KEY_Print,                   Qt::Key_Print>,
++        Xkb2Qt<XKB_KEY_Sys_Req,                 Qt::Key_SysReq>,
+         Xkb2Qt<0x1005FF60,                      Qt::Key_SysReq>,         // hardcoded Sun SysReq
+         Xkb2Qt<0x1007ff00,                      Qt::Key_SysReq>,         // hardcoded X386 SysReq
+ 
+@@ -471,7 +472,7 @@ QVector<xkb_keysym_t> QXkbCommon::toKeysym(QKeyEvent *event)
+     } else if (event->modifiers() & Qt::KeypadModifier) {
+         if (qtKey >= Qt::Key_0 && qtKey <= Qt::Key_9)
+             keysyms.append(XKB_KEY_KP_0 + (qtKey - Qt::Key_0));
+-    } else if (isLatin(qtKey) && event->text().isUpper()) {
++    } else if (isLatin1(qtKey) && event->text().isUpper()) {
+         keysyms.append(qtKey);
+     }
+ 
+@@ -523,7 +524,7 @@ int QXkbCommon::keysymToQtKey(xkb_keysym_t keysym, Qt::KeyboardModifiers modifie
+         // With standard shortcuts we should prefer a latin character, this is
+         // for checks like "some qkeyevent == QKeySequence::Copy" to work even
+         // when using for example 'russian' keyboard layout.
+-        if (!QXkbCommon::isLatin(keysym)) {
++        if (!QXkbCommon::isLatin1(keysym)) {
+             xkb_keysym_t latinKeysym = QXkbCommon::lookupLatinKeysym(state, code);
+             if (latinKeysym != XKB_KEY_NoSymbol)
+                 keysym = latinKeysym;
+@@ -546,7 +547,7 @@ static int keysymToQtKey_internal(xkb_keysym_t keysym, Qt::KeyboardModifiers mod
+     } else if (keysym >= XKB_KEY_KP_0 && keysym <= XKB_KEY_KP_9) {
+         // numeric keypad keys
+         qtKey = Qt::Key_0 + (keysym - XKB_KEY_KP_0);
+-    } else if (QXkbCommon::isLatin(keysym)) {
++    } else if (QXkbCommon::isLatin1(keysym)) {
+         qtKey = QXkbCommon::qxkbcommon_xkb_keysym_to_upper(keysym);
+     } else {
+         // check if we have a direct mapping
+@@ -678,7 +679,7 @@ QList<int> QXkbCommon::possibleKeys(xkb_state *state, const QKeyEvent *event,
+         Qt::KeyboardModifiers neededMods = ModsTbl[i];
+         if ((modifiers & neededMods) == neededMods) {
+             if (i == 8) {
+-                if (isLatin(baseQtKey))
++                if (isLatin1(baseQtKey))
+                     continue;
+                 // add a latin key as a fall back key
+                 sym = lookupLatinKeysym(state, keycode);
+@@ -733,7 +734,7 @@ void QXkbCommon::verifyHasLatinLayout(xkb_keymap *keymap)
+     for (xkb_layout_index_t layout = 0; layout < layoutCount; ++layout) {
+         for (xkb_keycode_t code = minKeycode; code < maxKeycode; ++code) {
+             xkb_keymap_key_get_syms_by_level(keymap, code, layout, 0, &keysyms);
+-            if (keysyms && isLatin(keysyms[0]))
++            if (keysyms && isLatin1(keysyms[0]))
+                 nrLatinKeys++;
+             if (nrLatinKeys > 10) // arbitrarily chosen threshold
+                 return;
+@@ -766,7 +767,7 @@ xkb_keysym_t QXkbCommon::lookupLatinKeysym(xkb_state *state, xkb_keycode_t keyco
+         xkb_level_index_t level = xkb_state_key_get_level(state, keycode, layout);
+         if (xkb_keymap_key_get_syms_by_level(keymap, keycode, layout, level, &syms) != 1)
+             continue;
+-        if (isLatin(syms[0])) {
++        if (isLatin1(syms[0])) {
+             sym = syms[0];
+             break;
+         }
+diff --git a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
+index 561eae03db..8389bd8f5a 100644
+--- a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
++++ b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
+@@ -94,8 +94,8 @@ public:
+     static void verifyHasLatinLayout(xkb_keymap *keymap);
+     static xkb_keysym_t lookupLatinKeysym(xkb_state *state, xkb_keycode_t keycode);
+ 
+-    static bool isLatin(xkb_keysym_t sym) {
+-        return ((sym >= 'a' && sym <= 'z') || (sym >= 'A' && sym <= 'Z'));
++    static bool isLatin1(xkb_keysym_t sym) {
++        return sym <= 0xff;
+     }
+     static bool isKeypad(xkb_keysym_t sym) {
+         return sym >= XKB_KEY_KP_Space && sym <= XKB_KEY_KP_9;
+diff --git a/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp b/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
+index 8cd7f9b368..406f84663f 100644
+--- a/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
++++ b/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
+@@ -318,7 +318,7 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources,
+ 
+     if (current < 0 && crtc_mode.clock != 0) {
+         modes << crtc_mode;
+-        current = mode.size() - 1;
++        current = modes.size() - 1;
+     }
+ 
+     if (configuration == OutputConfigCurrent)
+diff --git a/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp b/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
+index 9153fd20bb..255ea5e33e 100644
+--- a/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
++++ b/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
+@@ -194,6 +194,9 @@ QString AtSpiAdaptor::introspect(const QString &path) const
+                 "      <arg direction=\"out\" type=\"(so)\"/>\n"
+                 "      <annotation value=\"QSpiObjectReference\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n"
+                 "    </method>\n"
++                "    <method name=\"GetAccessibleId\">\n"
++                "      <arg direction=\"out\" type=\"s\"/>\n"
++                "    </method>\n"
+                 "  </interface>\n"
+                 );
+ 
+@@ -913,8 +916,17 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+     }
+     case QAccessible::NameChanged: {
+         if (sendObject || sendObject_property_change || sendObject_property_change_accessible_name) {
+-            QString path = pathForInterface(event->accessibleInterface());
+-            QVariantList args = packDBusSignalArguments(QLatin1String("accessible-name"), 0, 0, variantForPath(path));
++            QAccessibleInterface *iface = event->accessibleInterface();
++            if (!iface) {
++                qCDebug(lcAccessibilityAtspi,
++                        "NameChanged event from invalid accessible.");
++                return;
++            }
++
++            QString path = pathForInterface(iface);
++            QVariantList args = packDBusSignalArguments(
++                QLatin1String("accessible-name"), 0, 0,
++                QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Name))));
+             sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                            QLatin1String("PropertyChange"), args);
+         }
+@@ -922,8 +934,17 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+     }
+     case QAccessible::DescriptionChanged: {
+         if (sendObject || sendObject_property_change || sendObject_property_change_accessible_description) {
+-            QString path = pathForInterface(event->accessibleInterface());
+-            QVariantList args = packDBusSignalArguments(QLatin1String("accessible-description"), 0, 0, variantForPath(path));
++            QAccessibleInterface *iface = event->accessibleInterface();
++            if (!iface) {
++                qCDebug(lcAccessibilityAtspi,
++                        "DescriptionChanged event from invalid accessible.");
++                return;
++            }
++
++            QString path = pathForInterface(iface);
++            QVariantList args = packDBusSignalArguments(
++                QLatin1String("accessible-description"), 0, 0,
++                QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Description))));
+             sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                            QLatin1String("PropertyChange"), args);
+         }
+@@ -1038,7 +1059,9 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+                 // Combo Box with AT-SPI likes to be special
+                 // It requires a name-change to update caches and then selection-changed
+                 QString path = pathForInterface(iface);
+-                QVariantList args1 = packDBusSignalArguments(QLatin1String("accessible-name"), 0, 0, variantForPath(path));
++                QVariantList args1 = packDBusSignalArguments(
++                    QLatin1String("accessible-name"), 0, 0,
++                    QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Name))));
+                 sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                                QLatin1String("PropertyChange"), args1);
+                 QVariantList args2 = packDBusSignalArguments(QString(), 0, 0, QVariant::fromValue(QDBusVariant(QVariant(0))));
+@@ -1358,6 +1381,26 @@ void AtSpiAdaptor::registerApplication()
+     delete registry;
+ }
+ 
++namespace {
++QString accessibleIdForAccessible(QAccessibleInterface *accessible)
++{
++    QString result;
++    while (accessible) {
++        if (!result.isEmpty())
++            result.prepend(QLatin1Char('.'));
++        if (auto obj = accessible->object()) {
++            const QString name = obj->objectName();
++            if (!name.isEmpty())
++                result.prepend(name);
++            else
++                result.prepend(QString::fromUtf8(obj->metaObject()->className()));
++        }
++        accessible = accessible->parent();
++    }
++    return result;
++}
++} // namespace
++
+ // Accessible
+ bool AtSpiAdaptor::accessibleInterface(QAccessibleInterface *interface, const QString &function, const QDBusMessage &message, const QDBusConnection &connection)
+ {
+@@ -1441,6 +1484,9 @@ bool AtSpiAdaptor::accessibleInterface(QAccessibleInterface *interface, const QS
+             children << ref;
+         }
+         connection.send(message.createReply(QVariant::fromValue(children)));
++    } else if (function == QLatin1String("GetAccessibleId")) {
++        sendReply(connection, message,
++                  QVariant::fromValue(QDBusVariant(accessibleIdForAccessible(interface))));
+     } else {
+         qCDebug(lcAccessibilityAtspi) << "WARNING: AtSpiAdaptor::accessibleInterface does not implement " << function << message.path();
+         return false;
+diff --git a/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp b/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
+index 45ddc8e496..cc734abc63 100644
+--- a/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
++++ b/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
+@@ -69,6 +69,21 @@ QT_BEGIN_NAMESPACE
+ DBusConnection::DBusConnection(QObject *parent)
+     : QObject(parent), m_a11yConnection(QString()), m_enabled(false)
+ {
++    // If the bus is explicitly set via env var it overrides everything else.
++    QByteArray addressEnv = qgetenv("AT_SPI_BUS_ADDRESS");
++    if (!addressEnv.isEmpty()) {
++        // Only connect on next loop run, connections to our enabled signal are
++        // only established after the ctor returns.
++        QMetaObject::invokeMethod(
++                this,
++                [this, addressEnv] {
++                    m_enabled = true;
++                    connectA11yBus(QString::fromLocal8Bit(addressEnv));
++                },
++                Qt::QueuedConnection);
++        return;
++    }
++
+     // Start monitoring if "org.a11y.Bus" is registered as DBus service.
+     QDBusConnection c = QDBusConnection::sessionBus();
+     if (!c.isConnected()) {
+diff --git a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
+index 1a3cab275d..2abe039126 100644
+--- a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
++++ b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
+@@ -51,6 +51,9 @@
+ #include <QtCore/QStandardPaths>
+ #include <QtCore/QUrl>
+ 
++#include <QtGui/QGuiApplication>
++#include <QtGui/QWindow>
++
+ #if QT_CONFIG(dbus)
+ // These QtCore includes are needed for xdg-desktop-portal support
+ #include <QtCore/private/qcore_unix_p.h>
+@@ -58,6 +61,8 @@
+ #include <QtCore/QFileInfo>
+ #include <QtCore/QUrlQuery>
+ 
++#include <QtGui/QColor>
++
+ #include <QtDBus/QDBusConnection>
+ #include <QtDBus/QDBusMessage>
+ #include <QtDBus/QDBusPendingCall>
+@@ -142,6 +147,8 @@ static inline bool detectWebBrowser(const QByteArray &desktop,
+     }
+ 
+     if (desktop == QByteArray("KDE")) {
++        if (checkExecutable(QStringLiteral("kde-open5"), browser))
++            return true;
+         // Konqueror launcher
+         if (checkExecutable(QStringLiteral("kfmclient"), browser)) {
+             browser->append(QLatin1String(" exec"));
+@@ -296,8 +303,135 @@ static inline QDBusMessage xdgDesktopPortalSendEmail(const QUrl &url)
+ 
+     return QDBusConnection::sessionBus().call(message);
+ }
++
++namespace {
++struct XDGDesktopColor
++{
++    double r = 0;
++    double g = 0;
++    double b = 0;
++
++    QColor toQColor() const
++    {
++        constexpr auto rgbMax = 255;
++        return { static_cast<int>(r * rgbMax), static_cast<int>(g * rgbMax),
++                 static_cast<int>(b * rgbMax) };
++    }
++};
++
++const QDBusArgument &operator>>(const QDBusArgument &argument, XDGDesktopColor &myStruct)
++{
++    argument.beginStructure();
++    argument >> myStruct.r >> myStruct.g >> myStruct.b;
++    argument.endStructure();
++    return argument;
++}
++
++class XdgDesktopPortalColorPicker : public QPlatformServiceColorPicker
++{
++    Q_OBJECT
++public:
++    XdgDesktopPortalColorPicker(const QString &parentWindowId, QWindow *parent)
++        : QPlatformServiceColorPicker(parent), m_parentWindowId(parentWindowId)
++    {
++    }
++
++    void pickColor() override
++    {
++        // DBus signature:
++        // PickColor (IN   s      parent_window,
++        //            IN   a{sv}  options
++        //            OUT  o      handle)
++        // Options:
++        // handle_token (s) -  A string that will be used as the last element of the @handle.
++
++        QDBusMessage message = QDBusMessage::createMethodCall(
++                QStringLiteral("org.freedesktop.portal.Desktop"), QStringLiteral("/org/freedesktop/portal/desktop"),
++                QStringLiteral("org.freedesktop.portal.Screenshot"), QStringLiteral("PickColor"));
++        message << m_parentWindowId << QVariantMap();
++
++        QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
++        auto watcher = new QDBusPendingCallWatcher(pendingCall, this);
++        connect(watcher, &QDBusPendingCallWatcher::finished, this,
++                [this](QDBusPendingCallWatcher *watcher) {
++                    watcher->deleteLater();
++                    QDBusPendingReply<QDBusObjectPath> reply = *watcher;
++                    if (reply.isError()) {
++                        qWarning("DBus call to pick color failed: %s",
++                                 qPrintable(reply.error().message()));
++                        Q_EMIT colorPicked({});
++                    } else {
++                        QDBusConnection::sessionBus().connect(
++                                QStringLiteral("org.freedesktop.portal.Desktop"), reply.value().path(),
++                                QStringLiteral("org.freedesktop.portal.Request"), QStringLiteral("Response"), this,
++                                // clang-format off
++                                SLOT(gotColorResponse(uint,QVariantMap))
++                                // clang-format on
++                        );
++                    }
++                });
++    }
++
++private Q_SLOTS:
++    void gotColorResponse(uint result, const QVariantMap &map)
++    {
++        if (result != 0)
++            return;
++        XDGDesktopColor color{};
++        map.value(QStringLiteral("color")).value<QDBusArgument>() >> color;
++        Q_EMIT colorPicked(color.toQColor());
++        deleteLater();
++    }
++
++private:
++    const QString m_parentWindowId;
++};
++} // namespace
++
+ #endif // QT_CONFIG(dbus)
+ 
++QGenericUnixServices::QGenericUnixServices()
++{
++#if QT_CONFIG(dbus)
++    if (qEnvironmentVariableIntValue("QT_NO_XDG_DESKTOP_PORTAL") > 0) {
++        return;
++    }
++    QDBusMessage message = QDBusMessage::createMethodCall(
++            QStringLiteral("org.freedesktop.portal.Desktop"), QStringLiteral("/org/freedesktop/portal/desktop"),
++            QStringLiteral("org.freedesktop.DBus.Properties"), QStringLiteral("Get"));
++    message << QStringLiteral("org.freedesktop.portal.Screenshot")
++            << QStringLiteral("version");
++
++    QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
++    auto watcher = new QDBusPendingCallWatcher(pendingCall);
++    QObject::connect(watcher, &QDBusPendingCallWatcher::finished, watcher,
++                     [this](QDBusPendingCallWatcher *watcher) {
++                         watcher->deleteLater();
++                         QDBusPendingReply<QVariant> reply = *watcher;
++                         if (!reply.isError() && reply.value().toUInt() >= 2)
++                             m_hasScreenshotPortalWithColorPicking = true;
++                     });
++
++#endif
++}
++
++QPlatformServiceColorPicker *QGenericUnixServices::colorPicker(QWindow *parent)
++{
++#if QT_CONFIG(dbus)
++    // Make double sure that we are in a wayland environment. In particular check
++    // WAYLAND_DISPLAY so also XWayland apps benefit from portal-based color picking.
++    // Outside wayland we'll rather rely on other means than the XDG desktop portal.
++    if (!qEnvironmentVariableIsEmpty("WAYLAND_DISPLAY")
++        || QGuiApplication::platformName().startsWith(QLatin1String("wayland"))) {
++        return new XdgDesktopPortalColorPicker(portalWindowIdentifier(parent), parent);
++    }
++    return nullptr;
++#else
++    Q_UNUSED(parent);
++    return nullptr;
++#endif
++}
++
+ QByteArray QGenericUnixServices::desktopEnvironment() const
+ {
+     static const QByteArray result = detectDesktopEnvironment();
+@@ -352,6 +486,8 @@ bool QGenericUnixServices::openDocument(const QUrl &url)
+ }
+ 
+ #else
++QGenericUnixServices::QGenericUnixServices() = default;
++
+ QByteArray QGenericUnixServices::desktopEnvironment() const
+ {
+     return QByteArrayLiteral("UNKNOWN");
+@@ -371,6 +507,30 @@ bool QGenericUnixServices::openDocument(const QUrl &url)
+     return false;
+ }
+ 
++QPlatformServiceColorPicker *QGenericUnixServices::colorPicker(QWindow *parent)
++{
++    Q_UNUSED(parent);
++    return nullptr;
++}
++
+ #endif // QT_NO_MULTIPROCESS
+ 
++QString QGenericUnixServices::portalWindowIdentifier(QWindow *window)
++{
++    if (QGuiApplication::platformName() == QLatin1String("xcb"))
++        return QStringLiteral("x11:") + QString::number(window->winId(), 16);
++    return QString();
++}
++
++bool QGenericUnixServices::hasCapability(Capability capability) const
++{
++    switch (capability) {
++    case Capability::ColorPicking:
++        return m_hasScreenshotPortalWithColorPicking;
++    }
++    return false;
++}
++
+ QT_END_NAMESPACE
++
++#include "qgenericunixservices.moc"
+diff --git a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
+index 8ac3de6f03..30924e64bd 100644
+--- a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
++++ b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
+@@ -59,16 +59,21 @@ QT_BEGIN_NAMESPACE
+ class QGenericUnixServices : public QPlatformServices
+ {
+ public:
+-    QGenericUnixServices() {}
++    QGenericUnixServices();
+ 
+     QByteArray desktopEnvironment() const override;
+ 
++    bool hasCapability(Capability capability) const override;
+     bool openUrl(const QUrl &url) override;
+     bool openDocument(const QUrl &url) override;
++    QPlatformServiceColorPicker *colorPicker(QWindow *parent = nullptr) override;
++
++    virtual QString portalWindowIdentifier(QWindow *window);
+ 
+ private:
+     QString m_webBrowser;
+     QString m_documentLauncher;
++    bool m_hasScreenshotPortalWithColorPicking = false;
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
+index 09470bccc6..cc7c7d4d8a 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
+@@ -69,6 +69,7 @@ const QString MenuBarPath = QLatin1String("/MenuBar");
+ */
+ QDBusMenuConnection::QDBusMenuConnection(QObject *parent, const QString &serviceName)
+     : QObject(parent)
++    , m_serviceName(serviceName)
+     , m_connection(serviceName.isNull() ? QDBusConnection::sessionBus()
+                                         : QDBusConnection::connectToBus(QDBusConnection::SessionBus, serviceName))
+     , m_dbusWatcher(new QDBusServiceWatcher(StatusNotifierWatcherService, m_connection, QDBusServiceWatcher::WatchForRegistration, this))
+@@ -83,6 +84,12 @@ QDBusMenuConnection::QDBusMenuConnection(QObject *parent, const QString &service
+ #endif
+ }
+ 
++QDBusMenuConnection::~QDBusMenuConnection()
++{
++  if (!m_serviceName.isEmpty() && m_connection.isConnected())
++      QDBusConnection::disconnectFromBus(m_serviceName);
++}
++
+ void QDBusMenuConnection::dbusError(const QDBusError &error)
+ {
+     qWarning() << "QDBusTrayIcon encountered a D-Bus error:" << error;
+@@ -105,13 +112,7 @@ void QDBusMenuConnection::unregisterTrayIconMenu(QDBusTrayIcon *item)
+ 
+ bool QDBusMenuConnection::registerTrayIcon(QDBusTrayIcon *item)
+ {
+-    bool success = connection().registerService(item->instanceId());
+-    if (!success) {
+-        qWarning() << "failed to register service" << item->instanceId();
+-        return false;
+-    }
+-
+-    success = connection().registerObject(StatusNotifierItemPath, item);
++    bool success = connection().registerObject(StatusNotifierItemPath, item);
+     if (!success) {
+         unregisterTrayIcon(item);
+         qWarning() << "failed to register" << item->instanceId() << StatusNotifierItemPath;
+@@ -126,21 +127,18 @@ bool QDBusMenuConnection::registerTrayIcon(QDBusTrayIcon *item)
+ 
+ bool QDBusMenuConnection::registerTrayIconWithWatcher(QDBusTrayIcon *item)
+ {
++    Q_UNUSED(item);
+     QDBusMessage registerMethod = QDBusMessage::createMethodCall(
+                 StatusNotifierWatcherService, StatusNotifierWatcherPath, StatusNotifierWatcherService,
+                 QLatin1String("RegisterStatusNotifierItem"));
+-    registerMethod.setArguments(QVariantList() << item->instanceId());
++    registerMethod.setArguments(QVariantList() << m_connection.baseService());
+     return m_connection.callWithCallback(registerMethod, this, SIGNAL(trayIconRegistered()), SLOT(dbusError(QDBusError)));
+ }
+ 
+-bool QDBusMenuConnection::unregisterTrayIcon(QDBusTrayIcon *item)
++void QDBusMenuConnection::unregisterTrayIcon(QDBusTrayIcon *item)
+ {
+     unregisterTrayIconMenu(item);
+     connection().unregisterObject(StatusNotifierItemPath);
+-    bool success = connection().unregisterService(item->instanceId());
+-    if (!success)
+-        qWarning() << "failed to unregister service" << item->instanceId();
+-    return success;
+ }
+ #endif // QT_NO_SYSTEMTRAYICON
+ 
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
+index f484795fbb..97bdfabb85 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
++++ b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
+@@ -70,6 +70,7 @@ class QDBusMenuConnection : public QObject
+ 
+ public:
+     QDBusMenuConnection(QObject *parent = nullptr, const QString &serviceName = QString());
++    ~QDBusMenuConnection();
+     QDBusConnection connection() const { return m_connection; }
+     QDBusServiceWatcher *dbusWatcher() const { return m_dbusWatcher; }
+     bool isStatusNotifierHostRegistered() const { return m_statusNotifierHostRegistered; }
+@@ -78,7 +79,7 @@ public:
+     void unregisterTrayIconMenu(QDBusTrayIcon *item);
+     bool registerTrayIcon(QDBusTrayIcon *item);
+     bool registerTrayIconWithWatcher(QDBusTrayIcon *item);
+-    bool unregisterTrayIcon(QDBusTrayIcon *item);
++    void unregisterTrayIcon(QDBusTrayIcon *item);
+ #endif // QT_NO_SYSTEMTRAYICON
+ 
+ Q_SIGNALS:
+@@ -90,6 +91,7 @@ private Q_SLOTS:
+     void dbusError(const QDBusError &error);
+ 
+ private:
++    QString m_serviceName;
+     QDBusConnection m_connection;
+     QDBusServiceWatcher *m_dbusWatcher;
+     bool m_statusNotifierHostRegistered;
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp b/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
+index bede70975a..76bfec5e5a 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
+@@ -71,8 +71,12 @@ Q_LOGGING_CATEGORY(qLcTray, "qt.qpa.tray")
+ static QString iconTempPath()
+ {
+     QString tempPath = QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation);
+-    if (!tempPath.isEmpty())
++    if (!tempPath.isEmpty()) {
++        QString flatpakId = qEnvironmentVariable("FLATPAK_ID");
++        if (!flatpakId.isEmpty() && QFileInfo::exists(QLatin1String("/.flatpak-info")))
++            tempPath += QLatin1String("/app/") + flatpakId;
+         return tempPath;
++    }
+ 
+     tempPath = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation);
+ 
+diff --git a/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+index cb1b39db64..6e01af052c 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+@@ -755,6 +755,9 @@ QVariant QGnomeTheme::themeHint(QPlatformTheme::ThemeHint hint) const
+         return QVariant(QChar(0x2022));
+     case QPlatformTheme::UiEffects:
+         return QVariant(int(HoverEffect));
++    case QPlatformTheme::ButtonPressKeys:
++        return QVariant::fromValue(
++                QList<Qt::Key>({ Qt::Key_Space, Qt::Key_Return, Qt::Key_Enter, Qt::Key_Select }));
+     default:
+         break;
+     }
+diff --git a/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp b/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
+index 98e05195ee..1e92f43dec 100644
+--- a/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
++++ b/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
+@@ -343,8 +343,7 @@ void QEglFSCursor::paintOnScreen()
+     // screens are siblings of each other. When not enabled, the sibling list
+     // only contains m_screen itself.
+     for (QPlatformScreen *screen : m_screen->virtualSiblings()) {
+-        if (screen->geometry().contains(cr.topLeft().toPoint() + m_cursor.hotSpot)
+-            && QOpenGLContext::currentContext()->screen() == screen->screen())
++        if (screen->geometry().contains(cr.topLeft().toPoint() + m_cursor.hotSpot))
+         {
+             cr.translate(-screen->geometry().topLeft());
+             const QSize screenSize = screen->geometry().size();
+@@ -468,11 +467,12 @@ void QEglFSCursor::draw(const QRectF &r)
+ {
+     StateSaver stateSaver;
+ 
+-    QEglFSCursorData &gfx = static_cast<QEglFSContext*>(QOpenGLContext::currentContext()->handle())->cursorData;
+-    if (!gfx.program) {
+-        // one time initialization
++    // one time initialization
++    if (!QOpenGLFunctions::d_ptr)
+         initializeOpenGLFunctions();
+ 
++    QEglFSCursorData &gfx = static_cast<QEglFSContext*>(QOpenGLContext::currentContext()->handle())->cursorData;
++    if (!gfx.program) {
+         createShaderPrograms();
+ 
+         if (!gfx.atlasTexture) {
+diff --git a/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp b/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
+index 645a0ae2e9..3e0e406f1a 100644
+--- a/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
++++ b/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
+@@ -179,7 +179,7 @@ void QEglFSKmsEventReader::create(QEglFSKmsDevice *device)
+ 
+     m_device = device;
+ 
+-    qCDebug(qLcEglfsKmsDebug, "Initalizing event reader for device %p fd %d",
++    qCDebug(qLcEglfsKmsDebug, "Initializing event reader for device %p fd %d",
+             m_device, m_device->fd());
+ 
+     m_thread = new QEglFSKmsEventReaderThread(m_device->fd());
+diff --git a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
+index 141fb68a23..d4294d425a 100644
+--- a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
++++ b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
+@@ -122,11 +122,13 @@ QOffscreenIntegration::QOffscreenIntegration()
+ #endif
+     m_services.reset(new QPlatformServices);
+ 
+-    QWindowSystemInterface::handleScreenAdded(new QOffscreenScreen);
++    m_screen = new QOffscreenScreen;
++    QWindowSystemInterface::handleScreenAdded(m_screen);
+ }
+ 
+ QOffscreenIntegration::~QOffscreenIntegration()
+ {
++    QWindowSystemInterface::handleScreenRemoved(m_screen);
+ }
+ 
+ void QOffscreenIntegration::initialize()
+diff --git a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
+index 0ea90f6c2f..fe00fde07c 100644
+--- a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
++++ b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
+@@ -84,6 +84,7 @@ protected:
+ #endif
+     QScopedPointer<QPlatformInputContext> m_inputContext;
+     QScopedPointer<QPlatformServices> m_services;
++    QPlatformScreen *m_screen;
+     mutable QScopedPointer<QPlatformNativeInterface> m_nativeInterface;
+ };
+ 
+diff --git a/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp b/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
+index 6fa5a8a2b3..1f49f0aefd 100644
+--- a/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
++++ b/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
+@@ -48,6 +48,7 @@
+ #include <qpa/qplatformnativeinterface.h>
+ #include <QtPlatformHeaders/qwglnativecontext.h>
+ 
++#include <private/qsystemlibrary_p.h>
+ #include <algorithm>
+ 
+ #include <wingdi.h>
+@@ -162,19 +163,25 @@ QFunctionPointer QWindowsOpengl32DLL::resolve(const char *name)
+ 
+ bool QWindowsOpengl32DLL::init(bool softwareRendering)
+ {
+-    const QByteArray opengl32 = QByteArrayLiteral("opengl32.dll");
+-    const QByteArray swopengl = QByteArrayLiteral("opengl32sw.dll");
++    const QByteArray opengl32 = QByteArrayLiteral("opengl32");
++    const QByteArray swopengl = QByteArrayLiteral("opengl32sw");
++    bool useSystemLib = false;
+ 
+     QByteArray openglDll = qgetenv("QT_OPENGL_DLL");
+-    if (openglDll.isEmpty())
++    if (openglDll.isEmpty()) {
+         openglDll = softwareRendering ? swopengl : opengl32;
++        useSystemLib = !softwareRendering;
++    }
+ 
+     openglDll = openglDll.toLower();
+     m_nonOpengl32 = openglDll != opengl32;
+ 
+     qCDebug(lcQpaGl) << "Qt: Using WGL and OpenGL from" << openglDll;
+ 
+-    m_lib = ::LoadLibraryA(openglDll.constData());
++    if (useSystemLib)
++        m_lib = QSystemLibrary::load((wchar_t*)(QString::fromLatin1(openglDll).utf16()));
++    else
++        m_lib = LoadLibraryA(openglDll.constData());
+     if (!m_lib) {
+         qErrnoWarning(::GetLastError(), "Failed to load %s", openglDll.constData());
+         return false;
+@@ -184,7 +191,7 @@ bool QWindowsOpengl32DLL::init(bool softwareRendering)
+         // Load opengl32.dll always. GDI functions like ChoosePixelFormat do
+         // GetModuleHandle for opengl32.dll and behave differently (and call back into
+         // opengl32) when the module is present. This is fine for dummy contexts and windows.
+-        ::LoadLibraryA("opengl32.dll");
++        QSystemLibrary::load(L"opengl32");
+     }
+ 
+     wglCreateContext = reinterpret_cast<HGLRC (WINAPI *)(HDC)>(resolve("wglCreateContext"));
+diff --git a/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp b/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
+index d7d186e804..9eb4011bf2 100644
+--- a/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
++++ b/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
+@@ -49,6 +49,7 @@
+ #include <QtCore/qstandardpaths.h>
+ #include <QtCore/qlibraryinfo.h>
+ #include <QtCore/qhash.h>
++#include <private/qsystemlibrary_p.h>
+ 
+ #ifndef QT_NO_OPENGL
+ #include <private/qopengl_p.h>
+@@ -396,7 +397,7 @@ bool QWindowsOpenGLTester::testDesktopGL()
+ 
+     // Test #1: Load opengl32.dll and try to resolve an OpenGL 2 function.
+     // This will typically fail on systems that do not have a real OpenGL driver.
+-    lib = LoadLibraryA("opengl32.dll");
++    lib = QSystemLibrary::load(L"opengl32");
+     if (lib) {
+         CreateContext = reinterpret_cast<CreateContextType>(
+             reinterpret_cast<QFunctionPointer>(::GetProcAddress(lib, "wglCreateContext")));
+diff --git a/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp b/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
+index 1afa00cfc9..118af6ce73 100644
+--- a/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
++++ b/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
+@@ -41,6 +41,7 @@
+ 
+ #include <QRect>
+ #include <QList>
++#include <QMap>
+ #include <QDebug>
+ 
+ #include <qmath.h>
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp b/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
+index 9e2a37a6a1..e6e175a118 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
+@@ -488,12 +488,12 @@ void QXcbConnection::printXcbError(const char *message, xcb_generic_error_t *err
+     uint clamped_error_code = qMin<uint>(error->error_code, (sizeof(xcb_errors) / sizeof(xcb_errors[0])) - 1);
+     uint clamped_major_code = qMin<uint>(error->major_code, (sizeof(xcb_protocol_request_codes) / sizeof(xcb_protocol_request_codes[0])) - 1);
+ 
+-    qCWarning(lcQpaXcb, "%s: %d (%s), sequence: %d, resource id: %d, major code: %d (%s), minor code: %d",
+-             message,
+-             int(error->error_code), xcb_errors[clamped_error_code],
+-             int(error->sequence), int(error->resource_id),
+-             int(error->major_code), xcb_protocol_request_codes[clamped_major_code],
+-             int(error->minor_code));
++    qCDebug(lcQpaXcb, "%s: %d (%s), sequence: %d, resource id: %d, major code: %d (%s), minor code: %d",
++            message,
++            int(error->error_code), xcb_errors[clamped_error_code],
++            int(error->sequence), int(error->resource_id),
++            int(error->major_code), xcb_protocol_request_codes[clamped_major_code],
++            int(error->minor_code));
+ }
+ 
+ static Qt::MouseButtons translateMouseButtons(int s)
+@@ -702,6 +702,8 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
+             QXcbVirtualDesktop *virtualDesktop = virtualDesktopForRootWindow(propertyNotify->window);
+             if (virtualDesktop)
+                 virtualDesktop->updateWorkArea();
++        } else if (propertyNotify->atom == atom(QXcbAtom::_NET_SUPPORTED)) {
++            m_wmSupport->updateNetWMAtoms();
+         } else {
+             HANDLE_PLATFORM_WINDOW_EVENT(xcb_property_notify_event_t, window, handlePropertyNotifyEvent);
+         }
+@@ -750,7 +752,7 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
+                 case XCB_XKB_NEW_KEYBOARD_NOTIFY: {
+                     xcb_xkb_new_keyboard_notify_event_t *ev = &xkb_event->new_keyboard_notify;
+                     if (ev->changed & XCB_XKB_NKN_DETAIL_KEYCODES)
+-                        m_keyboard->updateKeymap(ev);
++                        m_keyboard->updateKeymap();
+                     break;
+                 }
+                 default:
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp b/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
+index 76869ced60..02d2eebb56 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
+@@ -274,8 +274,7 @@ QPlatformWindow *QXcbIntegration::createForeignWindow(QWindow *window, WId nativ
+ #ifndef QT_NO_OPENGL
+ QPlatformOpenGLContext *QXcbIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
+ {
+-    QXcbScreen *screen = static_cast<QXcbScreen *>(context->screen()->handle());
+-    QXcbGlIntegration *glIntegration = screen->connection()->glIntegration();
++    QXcbGlIntegration *glIntegration = defaultConnection()->glIntegration();
+     if (!glIntegration) {
+         qWarning("QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled");
+         return nullptr;
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+index efecd7e2d1..e8286381a2 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+@@ -365,17 +365,6 @@ void QXcbKeyboard::updateKeymap(xcb_mapping_notify_event_t *event)
+     updateKeymap();
+ }
+ 
+-void QXcbKeyboard::updateKeymap(xcb_xkb_new_keyboard_notify_event_t *event)
+-{
+-    if (!event)
+-        return;
+-
+-    if (event->deviceID != event->oldDeviceID)
+-        m_config = false;
+-
+-    updateKeymap();
+-}
+-
+ void QXcbKeyboard::updateKeymap()
+ {
+     KeysymModifierMap keysymMods;
+@@ -383,6 +372,8 @@ void QXcbKeyboard::updateKeymap()
+         keysymMods = keysymsToModifiers();
+     updateModifiers(keysymMods);
+ 
++    m_config = true;
++
+     if (!m_xkbContext) {
+         m_xkbContext.reset(xkb_context_new(XKB_CONTEXT_NO_DEFAULT_INCLUDES));
+         if (!m_xkbContext) {
+@@ -398,13 +389,8 @@ void QXcbKeyboard::updateKeymap()
+     if (connection()->hasXKB()) {
+         m_xkbKeymap.reset(xkb_x11_keymap_new_from_device(m_xkbContext.get(), xcb_connection(),
+                                                          core_device_id, XKB_KEYMAP_COMPILE_NO_FLAGS));
+-        if (m_xkbKeymap) {
+-            if (m_config)
+-                m_xkbState.reset(xkb_state_new(m_xkbKeymap.get()));
+-            else
+-                m_xkbState.reset(xkb_x11_state_new_from_device(m_xkbKeymap.get(), xcb_connection(), core_device_id));
+-
+-        }
++        if (m_xkbKeymap)
++            m_xkbState.reset(xkb_x11_state_new_from_device(m_xkbKeymap.get(), xcb_connection(), core_device_id));
+     } else {
+         m_xkbKeymap.reset(keymapFromCore(keysymMods));
+         if (m_xkbKeymap)
+@@ -425,8 +411,6 @@ void QXcbKeyboard::updateKeymap()
+     updateXKBMods();
+ 
+     QXkbCommon::verifyHasLatinLayout(m_xkbKeymap.get());
+-
+-    m_config = true;
+ }
+ 
+ QList<int> QXcbKeyboard::possibleKeys(const QKeyEvent *event) const
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
+index b652c85fe3..0ee08aeff2 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
++++ b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
+@@ -69,7 +69,6 @@ public:
+ 
+     Qt::KeyboardModifiers translateModifiers(int s) const;
+     void updateKeymap(xcb_mapping_notify_event_t *event);
+-    void updateKeymap(xcb_xkb_new_keyboard_notify_event_t *event);
+     void updateKeymap();
+     QList<int> possibleKeys(const QKeyEvent *event) const;
+ 
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp b/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
+index ffda7b6a57..863e961f4c 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
+@@ -564,11 +564,6 @@ void QXcbWindow::setGeometry(const QRect &rect)
+ {
+     QPlatformWindow::setGeometry(rect);
+ 
+-    if (shouldDeferTask(Task::SetGeometry)) {
+-        m_deferredGeometry = rect;
+-        return;
+-    }
+-
+     propagateSizeHints();
+ 
+     QXcbScreen *currentScreen = xcbScreen();
+@@ -693,9 +688,6 @@ void QXcbWindow::setVisible(bool visible)
+ 
+ void QXcbWindow::show()
+ {
+-    if (shouldDeferTask(Task::Map))
+-        return;
+-
+     if (window()->isTopLevel()) {
+ 
+         // update WM_NORMAL_HINTS
+@@ -706,7 +698,7 @@ void QXcbWindow::show()
+         if (isTransient(window())) {
+             const QWindow *tp = window()->transientParent();
+             if (tp && tp->handle())
+-                transientXcbParent = static_cast<const QXcbWindow *>(tp->handle())->winId();
++                transientXcbParent = tp->handle()->winId();
+             // Default to client leader if there is no transient parent, else modal dialogs can
+             // be hidden by their parents.
+             if (!transientXcbParent)
+@@ -746,10 +738,6 @@ void QXcbWindow::show()
+ 
+ void QXcbWindow::hide()
+ {
+-    if (shouldDeferTask(Task::Unmap))
+-        return;
+-
+-    m_wmStateValid = false;
+     xcb_unmap_window(xcb_connection(), m_window);
+ 
+     // send synthetic UnmapNotify event according to icccm 4.1.4
+@@ -909,9 +897,6 @@ QXcbWindow::NetWmStates QXcbWindow::netWmStates()
+ 
+ void QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
+ {
+-    if (shouldDeferTask(Task::SetWindowFlags))
+-        return;
+-
+     Qt::WindowType type = static_cast<Qt::WindowType>(int(flags & Qt::WindowType_Mask));
+ 
+     if (type == Qt::ToolTip)
+@@ -941,8 +926,6 @@ void QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
+ 
+     setTransparentForMouseEvents(flags & Qt::WindowTransparentForInput);
+     updateDoesNotAcceptFocus(flags & Qt::WindowDoesNotAcceptFocus);
+-
+-    m_isWmManagedWindow = !(flags & Qt::X11BypassWindowManagerHint);
+ }
+ 
+ void QXcbWindow::setMotifWmHints(Qt::WindowFlags flags)
+@@ -1142,9 +1125,6 @@ void QXcbWindow::setWindowState(Qt::WindowStates state)
+     if (state == m_windowState)
+         return;
+ 
+-    if (shouldDeferTask(Task::SetWindowState))
+-        return;
+-
+     // unset old state
+     if (m_windowState & Qt::WindowMinimized)
+         xcb_map_window(xcb_connection(), m_window);
+@@ -1350,6 +1330,12 @@ void QXcbWindow::setWindowIcon(const QIcon &icon)
+     }
+ 
+     if (!icon_data.isEmpty()) {
++        // Ignore icon exceeding maximum xcb request length
++        if (icon_data.size() > xcb_get_maximum_request_length(xcb_connection())) {
++            qWarning("Ignoring window icon: Size %llu exceeds maximum xcb request length %u.",
++                     icon_data.size(), xcb_get_maximum_request_length(xcb_connection()));
++            return;
++        }
+         xcb_change_property(xcb_connection(),
+                             XCB_PROP_MODE_REPLACE,
+                             m_window,
+@@ -1639,7 +1625,7 @@ void QXcbWindow::setWmWindowType(QXcbWindowFunctions::WmWindowTypes types, Qt::W
+         break;
+     }
+ 
+-    if ((flags & Qt::FramelessWindowHint) && !(type & QXcbWindowFunctions::KdeOverride)) {
++    if ((flags & Qt::FramelessWindowHint) && !(types & QXcbWindowFunctions::KdeOverride)) {
+         // override netwm type - quick and easy for KDE noborder
+         atoms.append(atom(QXcbAtom::_KDE_NET_WM_WINDOW_TYPE_OVERRIDE));
+     }
+@@ -1894,10 +1880,6 @@ void QXcbWindow::handleUnmapNotifyEvent(const xcb_unmap_notify_event_t *event)
+     if (event->window == m_window) {
+         m_mapped = false;
+         QWindowSystemInterface::handleExposeEvent(window(), QRegion());
+-        if (!m_isWmManagedWindow || parent()) {
+-            m_wmStateValid = true;
+-            handleDeferredTasks();
+-        }
+     }
+ }
+ 
+@@ -2212,98 +2194,30 @@ void QXcbWindow::handleLeaveNotifyEvent(const xcb_leave_notify_event_t *event)
+     handleLeaveNotifyEvent(event->root_x, event->root_y, event->mode, event->detail, event->time);
+ }
+ 
+-bool QXcbWindow::shouldDeferTask(Task task)
+-{
+-    if (m_wmStateValid)
+-        return false;
+-
+-    m_deferredTasks.append(task);
+-    return true;
+-}
+-
+-void QXcbWindow::handleDeferredTasks()
+-{
+-    Q_ASSERT(m_wmStateValid == true);
+-    if (m_deferredTasks.isEmpty())
+-        return;
+-
+-    bool map = false;
+-    bool unmap = false;
+-
+-    QVector<Task> tasks;
+-    for (auto taskIt = m_deferredTasks.rbegin(); taskIt != m_deferredTasks.rend(); ++taskIt) {
+-        if (!tasks.contains(*taskIt))
+-            tasks.prepend(*taskIt);
+-    }
+-
+-    for (Task task : tasks) {
+-        switch (task) {
+-        case Task::Map:
+-            map = true;
+-            unmap = false;
+-            break;
+-        case Task::Unmap:
+-            unmap = true;
+-            map = false;
+-            break;
+-        case Task::SetGeometry:
+-            setGeometry(m_deferredGeometry);
+-            break;
+-        case Task::SetWindowFlags:
+-            setWindowFlags(window()->flags());
+-            break;
+-        case Task::SetWindowState:
+-            setWindowState(window()->windowState());
+-            break;
+-        }
+-    }
+-    m_deferredTasks.clear();
+-
+-    if (map) {
+-        Q_ASSERT(unmap == false);
+-        show();
+-    }
+-    if (unmap) {
+-        Q_ASSERT(map == false);
+-        hide();
+-    }
+-}
+-
+ void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *event)
+ {
+     connection()->setTime(event->time);
+ 
+-    const bool wmStateChanged = event->atom == atom(QXcbAtom::WM_STATE);
+-    const bool netWmStateChanged = event->atom == atom(QXcbAtom::_NET_WM_STATE);
+-    if (netWmStateChanged || wmStateChanged) {
+-        if (wmStateChanged && !m_wmStateValid && m_isWmManagedWindow) {
+-            // ICCCM 4.1.4
+-            // Clients that want to re-use a client window (e.g. by mapping it again)
+-            // after withdrawing it must wait for the withdrawal to be complete before
+-            // proceeding. The preferred method for doing this is for clients to wait for
+-            // a window manager to update or remove the WM_STATE property.
+-            m_wmStateValid = true;
+-            handleDeferredTasks();
+-        }
+-        if (event->state == XCB_PROPERTY_DELETE)
++    const bool propertyDeleted = event->state == XCB_PROPERTY_DELETE;
++
++    if (event->atom == atom(QXcbAtom::_NET_WM_STATE) || event->atom == atom(QXcbAtom::WM_STATE)) {
++        if (propertyDeleted)
+             return;
+ 
+-        if (wmStateChanged) {
++        Qt::WindowStates newState = Qt::WindowNoState;
++
++        if (event->atom == atom(QXcbAtom::WM_STATE)) { // WM_STATE: Quick check for 'Minimize'.
+             auto reply = Q_XCB_REPLY(xcb_get_property, xcb_connection(),
+                                      0, m_window, atom(QXcbAtom::WM_STATE),
+                                      XCB_ATOM_ANY, 0, 1024);
+             if (reply && reply->format == 32 && reply->type == atom(QXcbAtom::WM_STATE)) {
+-                auto data = static_cast<const quint32 *>(xcb_get_property_value(reply.get()));
+-                if (reply->length != 0) {
+-                    const bool changedToWithdrawn = data[0] == XCB_ICCCM_WM_STATE_WITHDRAWN;
+-                    const bool changedToIconic = data[0] == XCB_ICCCM_WM_STATE_ICONIC;
+-                    m_minimized = changedToIconic || (changedToWithdrawn && m_minimized);
+-                }
++                const quint32 *data = (const quint32 *)xcb_get_property_value(reply.get());
++                if (reply->length != 0)
++                    m_minimized = (data[0] == XCB_ICCCM_WM_STATE_ICONIC
++                                   || (data[0] == XCB_ICCCM_WM_STATE_WITHDRAWN && m_minimized));
+             }
+         }
+ 
+-        // _NET_WM_STATE handling
+-        Qt::WindowStates newState = Qt::WindowNoState;
+         const NetWmStates states = netWmStates();
+         // _NET_WM_STATE_HIDDEN should be set by the Window Manager to indicate that a window would
+         // not be visible on the screen if its desktop/viewport were active and its coordinates were
+@@ -2325,6 +2239,7 @@ void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *ev
+             if ((m_windowState & Qt::WindowMinimized) && connection()->mouseGrabber() == this)
+                 connection()->setMouseGrabber(nullptr);
+         }
++        return;
+     } else if (event->atom == atom(QXcbAtom::_NET_FRAME_EXTENTS)) {
+         m_dirtyFrameMargins = true;
+     }
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbwindow.h b/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
+index 55af9279b1..6f5c1f5ed9 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
++++ b/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
+@@ -74,14 +74,6 @@ public:
+ 
+     Q_DECLARE_FLAGS(NetWmStates, NetWmState)
+ 
+-    enum Task {
+-        Map,
+-        Unmap,
+-        SetGeometry,
+-        SetWindowFlags,
+-        SetWindowState
+-    };
+-
+     QXcbWindow(QWindow *window);
+     ~QXcbWindow();
+ 
+@@ -151,9 +143,6 @@ public:
+ 
+     QXcbWindow *toWindow() override;
+ 
+-    bool shouldDeferTask(Task task);
+-    void handleDeferredTasks();
+-
+     void handleMouseEvent(xcb_timestamp_t time, const QPoint &local, const QPoint &global,
+                           Qt::KeyboardModifiers modifiers, QEvent::Type type, Qt::MouseEventSource source);
+ 
+@@ -292,11 +281,6 @@ protected:
+     int m_swapInterval = -1;
+ 
+     qreal m_sizeHintsScaleFactor = 1.0;
+-
+-    bool m_wmStateValid = true;
+-    QVector<Task> m_deferredTasks;
+-    bool m_isWmManagedWindow = true;
+-    QRect m_deferredGeometry;
+ };
+ 
+ class QXcbForeignWindow : public QXcbWindow
+diff --git a/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp b/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
+index d9d117faeb..640b49daa0 100644
+--- a/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
++++ b/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
+@@ -85,6 +85,7 @@ QGtk3MenuItem::QGtk3MenuItem()
+       m_checkable(false),
+       m_checked(false),
+       m_enabled(true),
++      m_exclusive(false),
+       m_underline(false),
+       m_invalid(true),
+       m_menu(nullptr),
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
+index 0048bbc1e6..396e7f6d1c 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
+@@ -102,15 +102,12 @@ const QDBusArgument &operator >>(const QDBusArgument &arg, QXdgDesktopPortalFile
+ class QXdgDesktopPortalFileDialogPrivate
+ {
+ public:
+-    QXdgDesktopPortalFileDialogPrivate(QPlatformFileDialogHelper *nativeFileDialog)
++    QXdgDesktopPortalFileDialogPrivate(QPlatformFileDialogHelper *nativeFileDialog, uint fileChooserPortalVersion)
+         : nativeFileDialog(nativeFileDialog)
++        , fileChooserPortalVersion(fileChooserPortalVersion)
+     { }
+ 
+-    WId winId = 0;
+-    bool directoryMode = false;
+-    bool modal = false;
+-    bool multipleFiles = false;
+-    bool saveFile = false;
++    QEventLoop loop;
+     QString acceptLabel;
+     QString directory;
+     QString title;
+@@ -121,19 +118,27 @@ public:
+     QString selectedMimeTypeFilter;
+     QString selectedNameFilter;
+     QStringList selectedFiles;
+-    QPlatformFileDialogHelper *nativeFileDialog = nullptr;
++    std::unique_ptr<QPlatformFileDialogHelper> nativeFileDialog;
++    uint fileChooserPortalVersion = 0;
++    bool failedToOpen = false;
++    bool directoryMode = false;
++    bool multipleFiles = false;
++    bool saveFile = false;
+ };
+ 
+-QXdgDesktopPortalFileDialog::QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog)
++QXdgDesktopPortalFileDialog::QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog, uint fileChooserPortalVersion)
+     : QPlatformFileDialogHelper()
+-    , d_ptr(new QXdgDesktopPortalFileDialogPrivate(nativeFileDialog))
++    , d_ptr(new QXdgDesktopPortalFileDialogPrivate(nativeFileDialog, fileChooserPortalVersion))
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+     if (d->nativeFileDialog) {
+-        connect(d->nativeFileDialog, SIGNAL(accept()), this, SIGNAL(accept()));
+-        connect(d->nativeFileDialog, SIGNAL(reject()), this, SIGNAL(reject()));
++        connect(d->nativeFileDialog.get(), SIGNAL(accept()), this, SIGNAL(accept()));
++        connect(d->nativeFileDialog.get(), SIGNAL(reject()), this, SIGNAL(reject()));
+     }
++
++    d->loop.connect(this, SIGNAL(accept()), SLOT(quit()));
++    d->loop.connect(this, SIGNAL(reject()), SLOT(quit()));
+ }
+ 
+ QXdgDesktopPortalFileDialog::~QXdgDesktopPortalFileDialog()
+@@ -177,7 +182,7 @@ void QXdgDesktopPortalFileDialog::initializeDialog()
+     setDirectory(options()->initialDirectory());
+ }
+ 
+-void QXdgDesktopPortalFileDialog::openPortal()
++void QXdgDesktopPortalFileDialog::openPortal(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent)
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+@@ -185,13 +190,13 @@ void QXdgDesktopPortalFileDialog::openPortal()
+                                                           QLatin1String("/org/freedesktop/portal/desktop"),
+                                                           QLatin1String("org.freedesktop.portal.FileChooser"),
+                                                           d->saveFile ? QLatin1String("SaveFile") : QLatin1String("OpenFile"));
+-    QString parentWindowId = QLatin1String("x11:") + QString::number(d->winId, 16);
++    QString parentWindowId = QLatin1String("x11:") + QString::number(parent ? parent->winId() : 0, 16);
+ 
+     QVariantMap options;
+     if (!d->acceptLabel.isEmpty())
+         options.insert(QLatin1String("accept_label"), d->acceptLabel);
+ 
+-    options.insert(QLatin1String("modal"), d->modal);
++    options.insert(QLatin1String("modal"), windowModality != Qt::NonModal);
+     options.insert(QLatin1String("multiple"), d->multipleFiles);
+     options.insert(QLatin1String("directory"), d->directoryMode);
+ 
+@@ -290,10 +295,18 @@ void QXdgDesktopPortalFileDialog::openPortal()
+ 
+     QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
+     QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingCall);
+-    connect(watcher, &QDBusPendingCallWatcher::finished, this, [this] (QDBusPendingCallWatcher *watcher) {
++    connect(watcher, &QDBusPendingCallWatcher::finished, this, [=] (QDBusPendingCallWatcher *watcher) {
+         QDBusPendingReply<QDBusObjectPath> reply = *watcher;
+-        if (reply.isError()) {
+-            Q_EMIT reject();
++        // Any error means the dialog is not shown and we need to fallback
++        d->failedToOpen = reply.isError();
++        if (d->failedToOpen) {
++            if (d->nativeFileDialog) {
++                d->nativeFileDialog->show(windowFlags, windowModality, parent);
++                if (d->loop.isRunning())
++                    d->nativeFileDialog->exec();
++            } else {
++                Q_EMIT reject();
++            }
+         } else {
+             QDBusConnection::sessionBus().connect(nullptr,
+                                                   reply.value().path(),
+@@ -302,6 +315,7 @@ void QXdgDesktopPortalFileDialog::openPortal()
+                                                   this,
+                                                   SLOT(gotResponse(uint,QVariantMap)));
+         }
++        watcher->deleteLater();
+     });
+ }
+ 
+@@ -326,7 +340,7 @@ QUrl QXdgDesktopPortalFileDialog::directory() const
+ {
+     Q_D(const QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog())
+         return d->nativeFileDialog->directory();
+ 
+     return d->directory;
+@@ -348,7 +362,7 @@ QList<QUrl> QXdgDesktopPortalFileDialog::selectedFiles() const
+ {
+     Q_D(const QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog())
+         return d->nativeFileDialog->selectedFiles();
+ 
+     QList<QUrl> files;
+@@ -403,16 +417,13 @@ void QXdgDesktopPortalFileDialog::exec()
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly)) {
++    if (d->nativeFileDialog && useNativeFileDialog()) {
+         d->nativeFileDialog->exec();
+         return;
+     }
+ 
+     // HACK we have to avoid returning until we emit that the dialog was accepted or rejected
+-    QEventLoop loop;
+-    loop.connect(this, SIGNAL(accept()), SLOT(quit()));
+-    loop.connect(this, SIGNAL(reject()), SLOT(quit()));
+-    loop.exec();
++    d->loop.exec();
+ }
+ 
+ void QXdgDesktopPortalFileDialog::hide()
+@@ -429,13 +440,10 @@ bool QXdgDesktopPortalFileDialog::show(Qt::WindowFlags windowFlags, Qt::WindowMo
+ 
+     initializeDialog();
+ 
+-    d->modal = windowModality != Qt::NonModal;
+-    d->winId = parent ? parent->winId() : 0;
+-
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog(OpenFallback))
+         return d->nativeFileDialog->show(windowFlags, windowModality, parent);
+ 
+-    openPortal();
++    openPortal(windowFlags, windowModality, parent);
+ 
+     return true;
+ }
+@@ -465,4 +473,21 @@ void QXdgDesktopPortalFileDialog::gotResponse(uint response, const QVariantMap &
+     }
+ }
+ 
++bool QXdgDesktopPortalFileDialog::useNativeFileDialog(QXdgDesktopPortalFileDialog::FallbackType fallbackType) const
++{
++    Q_D(const QXdgDesktopPortalFileDialog);
++
++    if (d->failedToOpen && fallbackType != OpenFallback)
++        return true;
++
++    if (d->fileChooserPortalVersion < 3) {
++        if (options()->fileMode() == QFileDialogOptions::Directory)
++            return true;
++        else if (options()->fileMode() == QFileDialogOptions::DirectoryOnly)
++            return true;
++    }
++
++    return false;
++}
++
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
+index 4f4de96ecf..65e22a5cf2 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
+@@ -51,6 +51,11 @@ class QXdgDesktopPortalFileDialog : public QPlatformFileDialogHelper
+     Q_OBJECT
+     Q_DECLARE_PRIVATE(QXdgDesktopPortalFileDialog)
+ public:
++    enum FallbackType {
++        GenericFallback,
++        OpenFallback
++    };
++
+     enum ConditionType : uint {
+         GlobalPattern = 0,
+         MimeType = 1
+@@ -69,7 +74,7 @@ public:
+     };
+     typedef QVector<Filter> FilterList;
+ 
+-    QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog = nullptr);
++    QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog = nullptr, uint fileChooserPortalVersion = 0);
+     ~QXdgDesktopPortalFileDialog();
+ 
+     bool defaultNameFilterDisables() const override;
+@@ -92,7 +97,8 @@ private Q_SLOTS:
+ 
+ private:
+     void initializeDialog();
+-    void openPortal();
++    void openPortal(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent);
++    bool useNativeFileDialog(FallbackType fallbackType = GenericFallback) const;
+ 
+     QScopedPointer<QXdgDesktopPortalFileDialogPrivate> d_ptr;
+ };
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
+index fb324afbd8..b809503122 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
+@@ -111,6 +111,7 @@ QXdgDesktopPortalTheme::QXdgDesktopPortalTheme()
+         if (reply.isValid()) {
+             d->fileChooserPortalVersion = reply.value().toUInt();
+         }
++        watcher->deleteLater();
+     });
+ }
+ 
+@@ -152,11 +153,12 @@ QPlatformDialogHelper* QXdgDesktopPortalTheme::createPlatformDialogHelper(Dialog
+ {
+     Q_D(const QXdgDesktopPortalTheme);
+ 
+-    if (type == FileDialog) {
++    if (type == FileDialog && d->fileChooserPortalVersion) {
+         // Older versions of FileChooser portal don't support opening directories, therefore we fallback
+         // to native file dialog opened inside the sandbox to open a directory.
+-        if (d->fileChooserPortalVersion < 3 && d->baseTheme->usePlatformNativeDialog(type))
+-            return new QXdgDesktopPortalFileDialog(static_cast<QPlatformFileDialogHelper*>(d->baseTheme->createPlatformDialogHelper(type)));
++        if (d->baseTheme->usePlatformNativeDialog(type))
++            return new QXdgDesktopPortalFileDialog(static_cast<QPlatformFileDialogHelper*>(d->baseTheme->createPlatformDialogHelper(type)),
++                                                   d->fileChooserPortalVersion);
+ 
+         return new QXdgDesktopPortalFileDialog;
+     }
+diff --git a/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp b/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
+index 43d5e119ad..1f9cbc4565 100644
+--- a/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
++++ b/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
+@@ -89,8 +89,10 @@ void QCupsPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &v
+         break;
+     case PPK_Duplex: {
+         QPrint::DuplexMode mode = QPrint::DuplexMode(value.toInt());
+-        if (mode != d->duplex && d->m_printDevice.supportedDuplexModes().contains(mode))
++        if (d->m_printDevice.supportedDuplexModes().contains(mode)) {
+             d->duplex = mode;
++            d->duplexRequestedExplicitly = true;
++        }
+         break;
+     }
+     case PPK_PrinterName:
+@@ -277,9 +279,12 @@ void QCupsPrintEnginePrivate::changePrinter(const QString &newPrinter)
+     m_printDevice.swap(printDevice);
+     printerName = m_printDevice.id();
+ 
+-    // Check if new printer supports current settings, otherwise us defaults
+-    if (duplex != QPrint::DuplexAuto && !m_printDevice.supportedDuplexModes().contains(duplex))
++    // in case a duplex value was explicitly set, check if new printer supports current value,
++    // otherwise use device default
++    if (!duplexRequestedExplicitly || !m_printDevice.supportedDuplexModes().contains(duplex)) {
+         duplex = m_printDevice.defaultDuplexMode();
++        duplexRequestedExplicitly = false;
++    }
+     QPrint::ColorMode colorMode = grayscale ? QPrint::GrayScale : QPrint::Color;
+     if (!m_printDevice.supportedColorModes().contains(colorMode))
+         grayscale = m_printDevice.defaultColorMode() == QPrint::GrayScale;
+diff --git a/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h b/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
+index c021b0c643..8f81fe478d 100644
+--- a/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
++++ b/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
+@@ -100,6 +100,7 @@ private:
+     QStringList cupsOptions;
+     QString cupsTempFile;
+     QPrint::DuplexMode duplex;
++    bool duplexRequestedExplicitly = false;
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp b/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
+index 67e7154fa6..40876152e5 100644
+--- a/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
++++ b/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
+@@ -817,7 +817,7 @@ bool QIBaseResultPrivate::writeArray(int column, const QList<QVariant> &list)
+     ba.resize(int(bufLen));
+ 
+     if (list.size() > arraySize) {
+-        error = QLatin1String("Array size missmatch: size of %1 is %2, size of provided list is %3");
++        error = QLatin1String("Array size mismatch: size of %1 is %2, size of provided list is %3");
+         error = error.arg(QLatin1String(sqlname)).arg(arraySize).arg(list.size());
+         q->setLastError(QSqlError(error, QLatin1String(""), QSqlError::StatementError));
+         return false;
+diff --git a/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp b/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
+index 7ca055eea2..6bc9d46755 100644
+--- a/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
++++ b/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
+@@ -223,7 +223,7 @@ public:
+     struct QMyField
+     {
+         char *outField = nullptr;
+-        MYSQL_FIELD *myField = nullptr;
++        const MYSQL_FIELD *myField = nullptr;
+         QMetaType::Type type = QMetaType::UnknownType;
+         my_bool nullIndicator = false;
+         ulong bufLength = 0ul;
+@@ -361,7 +361,7 @@ static bool qIsInteger(int t)
+ void QMYSQLResultPrivate::bindBlobs()
+ {
+     int i;
+-    MYSQL_FIELD *fieldInfo;
++    const MYSQL_FIELD *fieldInfo;
+     MYSQL_BIND *bind;
+ 
+     for(i = 0; i < fields.count(); ++i) {
+@@ -379,7 +379,6 @@ void QMYSQLResultPrivate::bindBlobs()
+ bool QMYSQLResultPrivate::bindInValues()
+ {
+     MYSQL_BIND *bind;
+-    char *field;
+     int i = 0;
+ 
+     if (!meta)
+@@ -392,35 +391,34 @@ bool QMYSQLResultPrivate::bindInValues()
+     inBinds = new MYSQL_BIND[fields.size()];
+     memset(inBinds, 0, fields.size() * sizeof(MYSQL_BIND));
+ 
+-    MYSQL_FIELD *fieldInfo;
++    const MYSQL_FIELD *fieldInfo;
+ 
+     while((fieldInfo = mysql_fetch_field(meta))) {
++        bind = &inBinds[i];
++
+         QMyField &f = fields[i];
+         f.myField = fieldInfo;
+-
++        bind->buffer_length = f.bufLength = fieldInfo->length + 1;
++        bind->buffer_type = fieldInfo->type;
+         f.type = qDecodeMYSQLType(fieldInfo->type, fieldInfo->flags);
+         if (qIsBlob(fieldInfo->type)) {
+             // the size of a blob-field is available as soon as we call
+             // mysql_stmt_store_result()
+             // after mysql_stmt_exec() in QMYSQLResult::exec()
+-            fieldInfo->length = 0;
++            bind->buffer_length = f.bufLength = 0;
+             hasBlobs = true;
+         } else if (qIsInteger(f.type)) {
+-            fieldInfo->length = 8;
++            bind->buffer_length = f.bufLength = 8;
+         } else {
+-            fieldInfo->type = MYSQL_TYPE_STRING;
++            bind->buffer_type = MYSQL_TYPE_STRING;
+         }
+-        bind = &inBinds[i];
+-        field = new char[fieldInfo->length + 1];
+-        memset(field, 0, fieldInfo->length + 1);
+ 
+-        bind->buffer_type = fieldInfo->type;
+-        bind->buffer = field;
+-        bind->buffer_length = f.bufLength = fieldInfo->length + 1;
+         bind->is_null = &f.nullIndicator;
+         bind->length = &f.bufLength;
+         bind->is_unsigned = fieldInfo->flags & UNSIGNED_FLAG ? 1 : 0;
+-        f.outField=field;
++
++        char *field = new char[bind->buffer_length + 1]{};
++        bind->buffer = f.outField = field;
+ 
+         ++i;
+     }
+@@ -1369,20 +1367,20 @@ bool QMYSQLDriver::open(const QString& db,
+     }
+ 
+ #if MYSQL_VERSION_ID >= 50007
+-    if (mysql_get_client_version() >= 50503 && mysql_get_server_version(d->mysql) >= 50503) {
+-        // force the communication to be utf8mb4 (only utf8mb4 supports 4-byte characters)
+-        mysql_set_character_set(d->mysql, "utf8mb4");
++    // force the communication to be utf8mb4 (only utf8mb4 supports 4-byte characters)
++    if (mysql_set_character_set(d->mysql, "utf8mb4")) {
++        // this failed, try forcing it to utf (BMP only)
++        if (mysql_set_character_set(d->mysql, "utf8"))
++            qWarning() << "MySQL: Unable to set the client character set to utf8.";
+ #if QT_CONFIG(textcodec)
+-        d->tc = QTextCodec::codecForName("UTF-8");
++        else
++            d->tc = codec(d->mysql);
+ #endif
+-    } else
+-    {
+-        // force the communication to be utf8
+-        mysql_set_character_set(d->mysql, "utf8");
++    }
+ #if QT_CONFIG(textcodec)
+-        d->tc = codec(d->mysql);
++    else
++        d->tc = QTextCodec::codecForName("UTF-8");
+ #endif
+-    }
+ #endif  // MYSQL_VERSION_ID >= 50007
+ 
+     d->preparedQuerysEnabled = checkPreparedQueries(d->mysql);
+diff --git a/qtbase/src/printsupport/dialogs/images/print-24.png b/qtbase/src/printsupport/dialogs/images/printer-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/print-24.png
+rename to src/printsupport/dialogs/images/printer-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/print-32.png b/qtbase/src/printsupport/dialogs/images/printer-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/print-32.png
+rename to src/printsupport/dialogs/images/printer-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-sided-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-facing-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-sided-24.png
+rename to src/printsupport/dialogs/images/view-pages-facing-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-sided-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-facing-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-sided-32.png
+rename to src/printsupport/dialogs/images/view-pages-facing-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-multi-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-overview-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-multi-24.png
+rename to src/printsupport/dialogs/images/view-pages-overview-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-multi-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-overview-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-multi-32.png
+rename to src/printsupport/dialogs/images/view-pages-overview-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-one-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-single-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-one-24.png
+rename to src/printsupport/dialogs/images/view-pages-single-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-one-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-single-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-one-32.png
+rename to src/printsupport/dialogs/images/view-pages-single-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-page-24.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-page-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-page-24.png
+rename to src/printsupport/dialogs/images/zoom-fit-page-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-page-32.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-page-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-page-32.png
+rename to src/printsupport/dialogs/images/zoom-fit-page-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-width-24.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-width-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-width-24.png
+rename to src/printsupport/dialogs/images/zoom-fit-width-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-width-32.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-width-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-width-32.png
+rename to src/printsupport/dialogs/images/zoom-fit-width-32.png
+diff --git a/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp b/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
+index 78e5b8d1ef..2a28516719 100644
+--- a/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
++++ b/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
+@@ -532,6 +532,7 @@ void QPageSetupWidget::updateWidget()
+ void QPageSetupWidget::setupPrinter() const
+ {
+     m_printer->setPageLayout(m_pageLayout);
++    m_printer->setPageOrientation(m_pageLayout.orientation());
+ #if QT_CONFIG(cups)
+     QCUPSSupport::PagesPerSheet pagesPerSheet = qvariant_cast<QCUPSSupport::PagesPerSheet>(m_ui.pagesPerSheetCombo->currentData()
+ );
+diff --git a/qtbase/src/printsupport/dialogs/qprintdialog.qrc b/qtbase/src/printsupport/dialogs/qprintdialog.qrc
+index 5a579baa55..10b8e1d341 100644
+--- a/qtbase/src/printsupport/dialogs/qprintdialog.qrc
++++ b/qtbase/src/printsupport/dialogs/qprintdialog.qrc
+@@ -1,9 +1,9 @@
+ <!DOCTYPE RCC><RCC version="1.0">
+ <qresource prefix="/qt-project.org/dialogs/qprintpreviewdialog">
+-<file>images/fit-page-24.png</file>
+-<file>images/fit-page-32.png</file>
+-<file>images/fit-width-24.png</file>
+-<file>images/fit-width-32.png</file>
++<file>images/zoom-fit-page-24.png</file>
++<file>images/zoom-fit-page-32.png</file>
++<file>images/zoom-fit-width-24.png</file>
++<file>images/zoom-fit-width-32.png</file>
+ <file>images/go-first-24.png</file>
+ <file>images/go-first-32.png</file>
+ <file>images/go-last-24.png</file>
+@@ -18,14 +18,14 @@
+ <file>images/layout-portrait-32.png</file>
+ <file>images/page-setup-24.png</file>
+ <file>images/page-setup-32.png</file>
+-<file>images/print-24.png</file>
+-<file>images/print-32.png</file>
+-<file>images/view-page-multi-24.png</file>
+-<file>images/view-page-multi-32.png</file>
+-<file>images/view-page-one-24.png</file>
+-<file>images/view-page-one-32.png</file>
+-<file>images/view-page-sided-24.png</file>
+-<file>images/view-page-sided-32.png</file>
++<file>images/printer-24.png</file>
++<file>images/printer-32.png</file>
++<file>images/view-pages-overview-24.png</file>
++<file>images/view-pages-overview-32.png</file>
++<file>images/view-pages-single-24.png</file>
++<file>images/view-pages-single-32.png</file>
++<file>images/view-pages-facing-24.png</file>
++<file>images/view-pages-facing-32.png</file>
+ <file>images/zoom-in-24.png</file>
+ <file>images/zoom-in-32.png</file>
+ <file>images/zoom-out-24.png</file>
+diff --git a/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp b/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
+index c5b845f4ec..5a5ba1d0a8 100644
+--- a/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
++++ b/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
+@@ -702,13 +702,14 @@ void QPrintDialogPrivate::selectPrinter(const QPrinter::OutputFormat outputForma
+         else
+             options.grayscale->setChecked(true);
+ 
+-        // keep duplex value explicitly set by user, if any, and selected printer supports it;
+-        // use device default otherwise
++        // duplex priorities to be as follows:
++        // 1) a user-selected duplex value in the dialog has highest prority
++        // 2) duplex value set in the QPrinter
+         QPrint::DuplexMode duplex;
+         if (explicitDuplexMode != QPrint::DuplexAuto && supportedDuplexMode.contains(explicitDuplexMode))
+             duplex = explicitDuplexMode;
+         else
+-            duplex = top->d->m_currentPrintDevice.defaultDuplexMode();
++            duplex = static_cast<QPrint::DuplexMode>(p->duplex());
+         switch (duplex) {
+         case QPrint::DuplexNone:
+             options.noDuplex->setChecked(true); break;
+@@ -1242,10 +1243,10 @@ void QUnixPrintWidgetPrivate::_q_printerChanged(int index)
+             QString filename = widget.filename->text();
+             widget.filename->setText(filename);
+             widget.lOutput->setEnabled(true);
+-            if (optionsPane)
+-                optionsPane->selectPrinter(QPrinter::PdfFormat);
+             printer->setOutputFormat(QPrinter::PdfFormat);
+             m_currentPrintDevice = QPrintDevice();
++            if (optionsPane)
++                optionsPane->selectPrinter(QPrinter::PdfFormat);
+             return;
+         }
+     }
+diff --git a/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp b/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
+index 39575d5f57..23b7e89538 100644
+--- a/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
++++ b/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
+@@ -352,7 +352,7 @@ void QPrintPreviewDialogPrivate::init(QPrinter *_printer)
+ static inline void qt_setupActionIcon(QAction *action, QLatin1String name)
+ {
+     QLatin1String imagePrefix(":/qt-project.org/dialogs/qprintpreviewdialog/images/");
+-    QIcon icon;
++    QIcon icon = QIcon::fromTheme(name);
+     icon.addFile(imagePrefix + name + QLatin1String("-24.png"), QSize(24, 24));
+     icon.addFile(imagePrefix + name + QLatin1String("-32.png"), QSize(32, 32));
+     action->setIcon(icon);
+@@ -383,8 +383,8 @@ void QPrintPreviewDialogPrivate::setupActions()
+     fitPageAction->setObjectName(QLatin1String("fitPageAction"));
+     fitWidthAction->setCheckable(true);
+     fitPageAction->setCheckable(true);
+-    qt_setupActionIcon(fitWidthAction, QLatin1String("fit-width"));
+-    qt_setupActionIcon(fitPageAction, QLatin1String("fit-page"));
++    qt_setupActionIcon(fitWidthAction, QLatin1String("zoom-fit-width"));
++    qt_setupActionIcon(fitPageAction, QLatin1String("zoom-fit-page"));
+     QObject::connect(fitGroup, SIGNAL(triggered(QAction*)), q, SLOT(_q_fit(QAction*)));
+ 
+     // Zoom
+@@ -410,9 +410,9 @@ void QPrintPreviewDialogPrivate::setupActions()
+     singleModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show single page"));
+     facingModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show facing pages"));
+     overviewModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show overview of all pages"));
+-    qt_setupActionIcon(singleModeAction, QLatin1String("view-page-one"));
+-    qt_setupActionIcon(facingModeAction, QLatin1String("view-page-sided"));
+-    qt_setupActionIcon(overviewModeAction, QLatin1String("view-page-multi"));
++    qt_setupActionIcon(singleModeAction, QLatin1String("view-pages-single"));
++    qt_setupActionIcon(facingModeAction, QLatin1String("view-pages-facing"));
++    qt_setupActionIcon(overviewModeAction, QLatin1String("view-pages-overview"));
+     singleModeAction->setObjectName(QLatin1String("singleModeAction"));
+     facingModeAction->setObjectName(QLatin1String("facingModeAction"));
+     overviewModeAction->setObjectName(QLatin1String("overviewModeAction"));
+@@ -426,7 +426,7 @@ void QPrintPreviewDialogPrivate::setupActions()
+     printerGroup = new QActionGroup(q);
+     printAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Print"));
+     pageSetupAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Page setup"));
+-    qt_setupActionIcon(printAction, QLatin1String("print"));
++    qt_setupActionIcon(printAction, QLatin1String("printer"));
+     qt_setupActionIcon(pageSetupAction, QLatin1String("page-setup"));
+     QObject::connect(printAction, SIGNAL(triggered(bool)), q, SLOT(_q_print()));
+     QObject::connect(pageSetupAction, SIGNAL(triggered(bool)), q, SLOT(_q_pageSetup()));
+diff --git a/qtbase/src/sql/kernel/qsqlquery.cpp b/qtbase/src/sql/kernel/qsqlquery.cpp
+index 32c6166c79..60afef10c3 100644
+--- a/qtbase/src/sql/kernel/qsqlquery.cpp
++++ b/qtbase/src/sql/kernel/qsqlquery.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2022 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtSql module of the Qt Toolkit.
+@@ -377,6 +377,10 @@ bool QSqlQuery::exec(const QString& query)
+     QElapsedTimer t;
+     t.start();
+ #endif
++    if (!driver()) {
++        qWarning("QSqlQuery::exec: called before driver has been set up");
++        return false;
++    }
+     if (d->ref.loadRelaxed() != 1) {
+         bool fo = isForwardOnly();
+         *this = QSqlQuery(driver()->createResult());
+diff --git a/qtbase/src/testlib/qabstractitemmodeltester.cpp b/qtbase/src/testlib/qabstractitemmodeltester.cpp
+index 8efb9c53d4..ce062f66d7 100644
+--- a/qtbase/src/testlib/qabstractitemmodeltester.cpp
++++ b/qtbase/src/testlib/qabstractitemmodeltester.cpp
+@@ -454,7 +454,7 @@ void QAbstractItemModelTesterPrivate::parent()
+ 
+     // Common error test #2, make sure that a second level index has a parent
+     // that is the first level index.
+-    if (model->rowCount(topIndex) > 0) {
++    if (model->rowCount(topIndex) > 0 && model->columnCount(topIndex) > 0) {
+         QModelIndex childIndex = model->index(0, 0, topIndex);
+         MODELTESTER_VERIFY(childIndex.isValid());
+         MODELTESTER_COMPARE(model->parent(childIndex), topIndex);
+diff --git a/qtbase/src/testlib/qasciikey.cpp b/qtbase/src/testlib/qasciikey.cpp
+index 9a308da2bc..93498b256f 100644
+--- a/qtbase/src/testlib/qasciikey.cpp
++++ b/qtbase/src/testlib/qasciikey.cpp
+@@ -498,6 +498,11 @@ char QTest::keyToAscii(Qt::Key key)
+     case Qt::Key_LaunchE : return 0; // = 0x10b0,
+     case Qt::Key_LaunchF : return 0; // = 0x10b1,
+ 
++    // Keypad navigation keys
++    case Qt::Key_Select : return 0; // = 0x01010000
++    case Qt::Key_Yes : return 0; // = 0x01010001
++    case Qt::Key_No : return 0; // = 0x01010002
++
+     default: QTEST_ASSERT(false); return 0;
+     }
+ }
+diff --git a/qtbase/src/testlib/qtestresult.cpp b/qtbase/src/testlib/qtestresult.cpp
+index 88028aac6e..2e89930776 100644
+--- a/qtbase/src/testlib/qtestresult.cpp
++++ b/qtbase/src/testlib/qtestresult.cpp
+@@ -251,7 +251,8 @@ bool QTestResult::verify(bool statement, const char *statementStr,
+ {
+     QTEST_ASSERT(statementStr);
+ 
+-    char msg[1024] = {'\0'};
++    char msg[1024];
++    msg[0] = '\0';
+ 
+     if (QTestLog::verboseLevel() >= 2) {
+         qsnprintf(msg, 1024, "QVERIFY(%s)", statementStr);
+@@ -309,7 +310,8 @@ static bool compareHelper(bool success, const char *failureMsg,
+                           bool hasValues = true)
+ {
+     const size_t maxMsgLen = 1024;
+-    char msg[maxMsgLen] = {'\0'};
++    char msg[maxMsgLen];
++    msg[0] = '\0';
+ 
+     QTEST_ASSERT(expected);
+     QTEST_ASSERT(actual);
+diff --git a/qtbase/src/widgets/dialogs/qcolordialog.cpp b/qtbase/src/widgets/dialogs/qcolordialog.cpp
+index 4247731275..cb325be85c 100644
+--- a/qtbase/src/widgets/dialogs/qcolordialog.cpp
++++ b/qtbase/src/widgets/dialogs/qcolordialog.cpp
+@@ -78,7 +78,10 @@
+ #include "qwindow.h"
+ 
+ #include "private/qdialog_p.h"
++#include "private/qguiapplication_p.h"
+ 
++#include <qpa/qplatformservices.h>
++#include <qpa/qplatformintegration.h>
+ #include <algorithm>
+ 
+ QT_BEGIN_NAMESPACE
+@@ -1611,6 +1614,20 @@ void QColorDialogPrivate::_q_newStandard(int r, int c)
+ void QColorDialogPrivate::_q_pickScreenColor()
+ {
+     Q_Q(QColorDialog);
++
++    auto *platformServices = QGuiApplicationPrivate::platformIntegration()->services();
++    if (platformServices->hasCapability(QPlatformServices::Capability::ColorPicking)) {
++        if (auto *colorPicker = platformServices->colorPicker(q->windowHandle())) {
++            q->connect(colorPicker, &QPlatformServiceColorPicker::colorPicked, q,
++                       [q, colorPicker](const QColor &color) {
++                           colorPicker->deleteLater();
++                           q->setCurrentColor(color);
++                       });
++            colorPicker->pickColor();
++            return;
++        }
++    }
++
+     if (!colorPickingEventFilter)
+         colorPickingEventFilter = new QColorPickingEventFilter(this, q);
+     q->installEventFilter(colorPickingEventFilter);
+diff --git a/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp b/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
+index e120817edc..8ea36b5427 100644
+--- a/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
++++ b/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
+@@ -400,12 +400,7 @@ bool QAbstractItemDelegate::helpEvent(QHelpEvent *event,
+         const QString tooltip = index.isValid() ?
+               d->textForRole(Qt::ToolTipRole, index.data(Qt::ToolTipRole), option.locale, precision) :
+               QString();
+-        QRect rect;
+-        if (index.isValid()) {
+-            const QRect r = view->visualRect(index);
+-            rect = QRect(view->mapToGlobal(r.topLeft()), r.size());
+-        }
+-        QToolTip::showText(he->globalPos(), tooltip, view, rect);
++        QToolTip::showText(he->globalPos(), tooltip, view->viewport(), option.rect);
+         event->setAccepted(!tooltip.isEmpty());
+         break;
+         }
+diff --git a/qtbase/src/widgets/itemviews/qlistview.cpp b/qtbase/src/widgets/itemviews/qlistview.cpp
+index 2b34476642..eebfaa030e 100644
+--- a/qtbase/src/widgets/itemviews/qlistview.cpp
++++ b/qtbase/src/widgets/itemviews/qlistview.cpp
+@@ -3386,6 +3386,7 @@ void QIconModeViewBase::updateContentsSize()
+ */
+ void QListView::currentChanged(const QModelIndex &current, const QModelIndex &previous)
+ {
++    QAbstractItemView::currentChanged(current, previous);
+ #ifndef QT_NO_ACCESSIBILITY
+     if (QAccessible::isActive()) {
+         if (current.isValid()) {
+@@ -3396,7 +3397,6 @@ void QListView::currentChanged(const QModelIndex &current, const QModelIndex &pr
+         }
+     }
+ #endif
+-    QAbstractItemView::currentChanged(current, previous);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/widgets/itemviews/qtableview.cpp b/qtbase/src/widgets/itemviews/qtableview.cpp
+index 934ac581b2..f79bb24249 100644
+--- a/qtbase/src/widgets/itemviews/qtableview.cpp
++++ b/qtbase/src/widgets/itemviews/qtableview.cpp
+@@ -1013,6 +1013,7 @@ void QTableViewPrivate::drawCell(QPainter *painter, const QStyleOptionViewItem &
+ int QTableViewPrivate::widthHintForIndex(const QModelIndex &index, int hint, const QStyleOptionViewItem &option) const
+ {
+     Q_Q(const QTableView);
++    const int oldHint = hint;
+     QWidget *editor = editorForIndex(index).widget.data();
+     if (editor && persistent.contains(editor)) {
+         hint = qMax(hint, editor->sizeHint().width());
+@@ -1021,6 +1022,17 @@ int QTableViewPrivate::widthHintForIndex(const QModelIndex &index, int hint, con
+         hint = qBound(min, hint, max);
+     }
+     hint = qMax(hint, q->itemDelegate(index)->sizeHint(option, index).width());
++
++    if (hasSpans()) {
++        auto span = spans.spanAt(index.column(), index.row());
++        if (span && span->m_left == index.column() && span->m_top == index.row()) {
++            // spans are screwed up when sections are moved
++            const auto left = logicalColumn(span->m_left);
++            for (int i = 1; i <= span->width(); ++i)
++               hint -= q->columnWidth(visualColumn(left + i));
++        }
++        hint = std::max(hint, oldHint);
++    }
+     return hint;
+ }
+ 
+@@ -1053,6 +1065,11 @@ int QTableViewPrivate::heightHintForIndex(const QModelIndex &index, int hint, QS
+         option.rect.setHeight(height);
+         option.rect.setX(q->columnViewportPosition(index.column()));
+         option.rect.setWidth(q->columnWidth(index.column()));
++        if (hasSpans()) {
++            auto span = spans.spanAt(index.column(), index.row());
++            if (span && span->m_left == index.column() && span->m_top == index.row())
++                option.rect.setWidth(std::max(option.rect.width(), visualSpanRect(*span).width()));
++        }
+         // 1px less space when grid is shown (see drawCell)
+         if (showGrid)
+             option.rect.setWidth(option.rect.width() - 1);
+diff --git a/qtbase/src/widgets/kernel/qaction.h b/qtbase/src/widgets/kernel/qaction.h
+index 258a1ea0a0..737c1e8285 100644
+--- a/qtbase/src/widgets/kernel/qaction.h
++++ b/qtbase/src/widgets/kernel/qaction.h
+@@ -81,7 +81,7 @@ class Q_WIDGETS_EXPORT QAction : public QObject
+     Q_PROPERTY(MenuRole menuRole READ menuRole WRITE setMenuRole NOTIFY changed)
+     Q_PROPERTY(bool iconVisibleInMenu READ isIconVisibleInMenu WRITE setIconVisibleInMenu NOTIFY changed)
+     Q_PROPERTY(bool shortcutVisibleInContextMenu READ isShortcutVisibleInContextMenu WRITE setShortcutVisibleInContextMenu NOTIFY changed)
+-    Q_PROPERTY(Priority priority READ priority WRITE setPriority)
++    Q_PROPERTY(Priority priority READ priority WRITE setPriority NOTIFY changed)
+ 
+ public:
+     // note this is copied into qplatformmenu.h, which must stay in sync
+diff --git a/qtbase/src/widgets/kernel/qwidget.cpp b/qtbase/src/widgets/kernel/qwidget.cpp
+index 9eba1e001e..26f6d27e18 100644
+--- a/qtbase/src/widgets/kernel/qwidget.cpp
++++ b/qtbase/src/widgets/kernel/qwidget.cpp
+@@ -5296,7 +5296,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
+         QWidgetEffectSourcePrivate *sourced = static_cast<QWidgetEffectSourcePrivate *>
+                                                          (source->d_func());
+         if (!sourced->context) {
+-            const QRegion effectRgn(rgn.boundingRect());
++            const QRegion effectRgn((flags & UseEffectRegionBounds) ? rgn.boundingRect() : rgn);
+             QWidgetPaintContext context(pdev, effectRgn, offset, flags, sharedPainter, repaintManager);
+             sourced->context = &context;
+             if (!sharedPainter) {
+@@ -5328,6 +5328,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
+         }
+     }
+ #endif // QT_CONFIG(graphicseffect)
++    flags = flags & ~UseEffectRegionBounds;
+ 
+     const bool alsoOnScreen = flags & DrawPaintOnScreen;
+     const bool recursive = flags & DrawRecursive;
+diff --git a/qtbase/src/widgets/kernel/qwidget_p.h b/qtbase/src/widgets/kernel/qwidget_p.h
+index eef6b8fa2c..c432f4b5d5 100644
+--- a/qtbase/src/widgets/kernel/qwidget_p.h
++++ b/qtbase/src/widgets/kernel/qwidget_p.h
+@@ -229,7 +229,8 @@ public:
+         DontSubtractOpaqueChildren = 0x10,
+         DontDrawOpaqueChildren = 0x20,
+         DontDrawNativeChildren = 0x40,
+-        DontSetCompositionMode = 0x80
++        DontSetCompositionMode = 0x80,
++        UseEffectRegionBounds = 0x100
+     };
+     Q_DECLARE_FLAGS(DrawWidgetFlags, DrawWidgetFlag)
+     Q_FLAG(DrawWidgetFlags)
+diff --git a/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp b/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
+index 02880b34da..0d44e1326d 100644
+--- a/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
++++ b/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
+@@ -1018,7 +1018,8 @@ void QWidgetRepaintManager::paintAndFlush()
+ 
+     // Paint the rest with composition.
+     if (repaintAllWidgets || !dirtyCopy.isEmpty()) {
+-        QWidgetPrivate::DrawWidgetFlags flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive;
++        QWidgetPrivate::DrawWidgetFlags flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive
++                | QWidgetPrivate::UseEffectRegionBounds;
+         tlw->d_func()->drawWidget(store->paintDevice(), dirtyCopy, QPoint(), flags, nullptr, this);
+     }
+ 
+diff --git a/qtbase/src/widgets/styles/qfusionstyle.cpp b/qtbase/src/widgets/styles/qfusionstyle.cpp
+index f4345d97c4..962912c838 100644
+--- a/qtbase/src/widgets/styles/qfusionstyle.cpp
++++ b/qtbase/src/widgets/styles/qfusionstyle.cpp
+@@ -1772,14 +1772,6 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio
+             proxy()->drawControl(CE_PushButtonLabel, &subopt, painter, widget);
+         }
+         break;
+-    case CE_PushButtonLabel:
+-        if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
+-            QStyleOptionButton b(*button);
+-            // no PM_ButtonShiftHorizontal and PM_ButtonShiftVertical for fusion style
+-            b.state &= ~(State_On | State_Sunken);
+-            QCommonStyle::drawControl(element, &b, painter, widget);
+-        }
+-        break;
+     case CE_MenuBarEmptyArea:
+         painter->save();
+     {
+diff --git a/qtbase/src/widgets/util/qcompleter.cpp b/qtbase/src/widgets/util/qcompleter.cpp
+index 18b24063d8..ef7207a8a3 100644
+--- a/qtbase/src/widgets/util/qcompleter.cpp
++++ b/qtbase/src/widgets/util/qcompleter.cpp
+@@ -1120,6 +1120,8 @@ void QCompleter::setModel(QAbstractItemModel *model)
+ {
+     Q_D(QCompleter);
+     QAbstractItemModel *oldModel = d->proxy->sourceModel();
++    if (oldModel == model)
++        return;
+ #if QT_CONFIG(filesystemmodel)
+     if (qobject_cast<const QFileSystemModel *>(oldModel))
+         setCompletionRole(Qt::EditRole); // QTBUG-54642, clear FileNameRole set by QFileSystemModel
+diff --git a/qtbase/src/widgets/widgets/qabstractbutton.cpp b/qtbase/src/widgets/widgets/qabstractbutton.cpp
+index a128b23950..dc40bf62fb 100644
+--- a/qtbase/src/widgets/widgets/qabstractbutton.cpp
++++ b/qtbase/src/widgets/widgets/qabstractbutton.cpp
+@@ -56,6 +56,7 @@
+ #ifndef QT_NO_ACCESSIBILITY
+ #include "qaccessible.h"
+ #endif
++#include <qpa/qplatformtheme.h>
+ 
+ #include <algorithm>
+ 
+@@ -1076,19 +1077,19 @@ void QAbstractButton::keyPressEvent(QKeyEvent *e)
+ {
+     Q_D(QAbstractButton);
+     bool next = true;
+-    switch (e->key()) {
+-    case Qt::Key_Enter:
+-    case Qt::Key_Return:
+-        e->ignore();
+-        break;
+-    case Qt::Key_Select:
+-    case Qt::Key_Space:
+-        if (!e->isAutoRepeat()) {
+-            setDown(true);
+-            repaint();
+-            d->emitPressed();
+-        }
+-        break;
++
++    const auto key = static_cast<Qt::Key>(e->key());
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(key) && !e->isAutoRepeat()) {
++        setDown(true);
++        repaint();
++        d->emitPressed();
++        return;
++    }
++
++    switch (key) {
+     case Qt::Key_Up:
+         next = false;
+         Q_FALLTHROUGH();
+@@ -1153,15 +1154,15 @@ void QAbstractButton::keyReleaseEvent(QKeyEvent *e)
+     if (!e->isAutoRepeat())
+         d->repeatTimer.stop();
+ 
+-    switch (e->key()) {
+-    case Qt::Key_Select:
+-    case Qt::Key_Space:
+-        if (!e->isAutoRepeat() && d->down)
+-            d->click();
+-        break;
+-    default:
+-        e->ignore();
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(static_cast<Qt::Key>(e->key())) && !e->isAutoRepeat() && d->down) {
++        d->click();
++        return;
+     }
++
++    e->ignore();
+ }
+ 
+ /*!\reimp
+diff --git a/qtbase/src/widgets/widgets/qcombobox.cpp b/qtbase/src/widgets/widgets/qcombobox.cpp
+index 7a496c27e0..0a3d96647b 100644
+--- a/qtbase/src/widgets/widgets/qcombobox.cpp
++++ b/qtbase/src/widgets/widgets/qcombobox.cpp
+@@ -3352,7 +3352,23 @@ void QComboBox::keyPressEvent(QKeyEvent *e)
+ 
+     Move move = NoMove;
+     int newIndex = currentIndex();
+-    switch (e->key()) {
++
++    bool pressLikeButton = !d->lineEdit;
++#ifdef QT_KEYPAD_NAVIGATION
++    pressLikeButton |= QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus();
++#endif
++    auto key = static_cast<Qt::Key>(e->key());
++    if (pressLikeButton) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(key)) {
++            showPopup();
++            return;
++        }
++    }
++
++    switch (key) {
+     case Qt::Key_Up:
+         if (e->modifiers() & Qt::ControlModifier)
+             break; // pass to line edit for auto completion
+@@ -3394,26 +3410,11 @@ void QComboBox::keyPressEvent(QKeyEvent *e)
+             return;
+         }
+         break;
+-    case Qt::Key_Space:
+-        if (!d->lineEdit) {
+-            showPopup();
+-            return;
+-        }
+-        break;
+-    case Qt::Key_Enter:
+-    case Qt::Key_Return:
+     case Qt::Key_Escape:
+         if (!d->lineEdit)
+             e->ignore();
+         break;
+ #ifdef QT_KEYPAD_NAVIGATION
+-    case Qt::Key_Select:
+-        if (QApplicationPrivate::keypadNavigationEnabled()
+-                && (!hasEditFocus() || !d->lineEdit)) {
+-            showPopup();
+-            return;
+-        }
+-        break;
+     case Qt::Key_Left:
+     case Qt::Key_Right:
+         if (QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus())
+diff --git a/qtbase/src/widgets/widgets/qdatetimeedit_p.h b/qtbase/src/widgets/widgets/qdatetimeedit_p.h
+index d36b6f8f9a..e0df5b5158 100644
+--- a/qtbase/src/widgets/widgets/qdatetimeedit_p.h
++++ b/qtbase/src/widgets/widgets/qdatetimeedit_p.h
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2018 The Qt Company Ltd.
++** Copyright (C) 2021 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtWidgets module of the Qt Toolkit.
+diff --git a/qtbase/src/widgets/widgets/qgroupbox.cpp b/qtbase/src/widgets/widgets/qgroupbox.cpp
+index 02a0bed325..3f3eccc370 100644
+--- a/qtbase/src/widgets/widgets/qgroupbox.cpp
++++ b/qtbase/src/widgets/widgets/qgroupbox.cpp
+@@ -54,6 +54,8 @@
+ #include "qaccessible.h"
+ #endif
+ #include <private/qwidget_p.h>
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
+ 
+ #include "qdebug.h"
+ 
+@@ -360,7 +362,10 @@ bool QGroupBox::event(QEvent *e)
+         return true;
+     case QEvent::KeyPress: {
+         QKeyEvent *k = static_cast<QKeyEvent*>(e);
+-        if (!k->isAutoRepeat() && (k->key() == Qt::Key_Select || k->key() == Qt::Key_Space)) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (!k->isAutoRepeat() && buttonPressKeys.contains(static_cast<Qt::Key>(k->key()))) {
+             d->pressedControl = QStyle::SC_GroupBoxCheckBox;
+             update(style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxCheckBox, this));
+             return true;
+@@ -369,7 +374,10 @@ bool QGroupBox::event(QEvent *e)
+     }
+     case QEvent::KeyRelease: {
+         QKeyEvent *k = static_cast<QKeyEvent*>(e);
+-        if (!k->isAutoRepeat() && (k->key() == Qt::Key_Select || k->key() == Qt::Key_Space)) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (!k->isAutoRepeat() && buttonPressKeys.contains(static_cast<Qt::Key>(k->key()))) {
+             bool toggle = (d->pressedControl == QStyle::SC_GroupBoxLabel
+                            || d->pressedControl == QStyle::SC_GroupBoxCheckBox);
+             d->pressedControl = QStyle::SC_None;
+diff --git a/qtbase/src/widgets/widgets/qlabel.cpp b/qtbase/src/widgets/widgets/qlabel.cpp
+index 30ff80cbb0..cf2605c17c 100644
+--- a/qtbase/src/widgets/widgets/qlabel.cpp
++++ b/qtbase/src/widgets/widgets/qlabel.cpp
+@@ -421,9 +421,6 @@ void QLabel::setPixmap(const QPixmap &pixmap)
+         d->pixmap = new QPixmap(pixmap);
+     }
+ 
+-    if (d->pixmap->depth() == 1 && !d->pixmap->mask())
+-        d->pixmap->setMask(*((QBitmap *)d->pixmap));
+-
+     d->updateLabel();
+ }
+ 
+diff --git a/qtbase/src/widgets/widgets/qtoolbararealayout.cpp b/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
+index 493c094cc1..d5f4b59017 100644
+--- a/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
++++ b/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
+@@ -1367,7 +1367,7 @@ bool QToolBarAreaLayout::restoreState(QDataStream &stream, const QList<QToolBar*
+                 item.widgetItem = new QWidgetItemV2(toolBar);
+                 toolBar->setOrientation(floating ? ((shown & 2) ? Qt::Vertical : Qt::Horizontal) : dock.o);
+                 toolBar->setVisible(shown & 1);
+-                toolBar->d_func()->setWindowState(floating, true, rect);
++                toolBar->d_func()->setWindowState(floating, false, rect);
+ 
+                 item.preferredSize = item.size;
+                 line.toolBarItems.append(item);
+diff --git a/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp b/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
+index 212c0a2e13..3c77b1ba0b 100644
+--- a/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
++++ b/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
+@@ -126,8 +126,7 @@ public:
+ 
+ void tst_QtConcurrentIterateKernel::instantiate()
+ {
+-    auto future = startThreadEngine(new PrintFor(0, 40)).startAsynchronously();
+-    future.waitForFinished();
++    startThreadEngine(new PrintFor(0, 40)).startBlocking();
+     QCOMPARE(iterations.loadRelaxed(), 40);
+ }
+ 
+@@ -166,10 +165,8 @@ void tst_QtConcurrentIterateKernel::stresstest()
+     const int times = 50;
+     for (int i = 0; i < times; ++i) {
+         counter.storeRelaxed(0);
+-        // ThreadEngine will delete f when it finishes
+-        auto f = new CountFor(0, iterations);
+-        auto future = f->startAsynchronously();
+-        future.waitForFinished();
++        CountFor f(0, iterations);
++        f.startBlocking();
+         QCOMPARE(counter.loadRelaxed(), iterations);
+     }
+ }
+@@ -177,11 +174,8 @@ void tst_QtConcurrentIterateKernel::stresstest()
+ void tst_QtConcurrentIterateKernel::noIterations()
+ {
+     const int times = 20000;
+-    for (int i = 0; i < times; ++i) {
+-        auto future = startThreadEngine(new IterateKernel<TestIterator, void>(0, 0))
+-                              .startAsynchronously();
+-        future.waitForFinished();
+-    }
++    for (int i = 0; i < times; ++i)
++        startThreadEngine(new IterateKernel<TestIterator, void>(0, 0)).startBlocking();
+ }
+ 
+ QMutex threadsMutex;
+@@ -236,10 +230,8 @@ void tst_QtConcurrentIterateKernel::throttling()
+ 
+     threads.clear();
+ 
+-    // ThreadEngine will delete f when it finishes
+-    auto f = new ThrottleFor(0, totalIterations);
+-    auto future = f->startAsynchronously();
+-    future.waitForFinished();
++    ThrottleFor f(0, totalIterations);
++    f.startBlocking();
+ 
+     QCOMPARE(iterations.loadRelaxed(), totalIterations);
+ 
+diff --git a/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp b/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
+index ac7be7acdd..81bc64c8d9 100644
+--- a/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
++++ b/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
+@@ -65,9 +65,16 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::runDirectly()
+ {
+-    PrintUser *engine = new PrintUser();
+-    QFuture<void> f = engine->startAsynchronously();
+-    f.waitForFinished();
++    {
++        PrintUser engine;
++        engine.startSingleThreaded();
++        engine.startBlocking();
++    }
++    {
++        PrintUser *engine = new PrintUser();
++        QFuture<void> f = engine->startAsynchronously();
++        f.waitForFinished();
++    }
+ }
+ 
+ class StringResultUser : public ThreadEngine<QString>
+@@ -99,10 +106,8 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::result()
+ {
+-    // ThreadEngine will delete 'engine' when it finishes
+-    auto engine = new StringResultUser();
+-    auto future = engine->startAsynchronously();
+-    QCOMPARE(future.result(), QString("Foo"));
++    StringResultUser engine;
++    QCOMPARE(*engine.startBlocking(), QString("Foo"));
+ }
+ 
+ class VoidResultUser : public ThreadEngine<void>
+@@ -128,9 +133,17 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::runThroughStarter()
+ {
+-    ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
+-    QFuture<QString> f = starter.startAsynchronously();
+-    QCOMPARE(f.result(), QString("Foo"));
++    {
++        ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
++        QFuture<QString>  f = starter.startAsynchronously();
++        QCOMPARE(f.result(), QString("Foo"));
++    }
++
++    {
++        ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
++        QString str = starter.startBlocking();
++        QCOMPARE(str, QString("Foo"));
++    }
+ }
+ 
+ class CancelUser : public ThreadEngine<void>
+@@ -213,6 +226,12 @@ void tst_QtConcurrentThreadEngine::throttle()
+         f.waitForFinished();
+         QCOMPARE(count.loadRelaxed(), 0);
+     }
++
++    for (int i = 0; i < repeats; ++i) {
++        ThrottleAlwaysUser t;
++        t.startBlocking();
++        QCOMPARE(count.loadRelaxed(), 0);
++    }
+ }
+ 
+ QSet<QThread *> threads;
+@@ -249,17 +268,35 @@ void tst_QtConcurrentThreadEngine::threadCount()
+ {
+     const int repeats = 10;
+     for (int i = 0; i < repeats; ++i) {
++        ThreadCountUser t;
++        t.startBlocking();
++        int count = threads.count();
++        int count_expected = QThreadPool::globalInstance()->maxThreadCount() + 1; // +1 for the main thread.
++        if (count != count_expected)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, count_expected);
++
+         (new ThreadCountUser())->startAsynchronously().waitForFinished();
+-        const auto count = threads.count();
+-        const auto maxThreadCount = QThreadPool::globalInstance()->maxThreadCount();
+-        QVERIFY(count <= maxThreadCount);
+-        QVERIFY(!threads.contains(QThread::currentThread()));
++        count = threads.count();
++        count_expected = QThreadPool::globalInstance()->maxThreadCount();
++        if (count != count_expected)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, count_expected);
+     }
+ 
+     // Set the finish flag immediately, this should give us one thread only.
+     for (int i = 0; i < repeats; ++i) {
++        ThreadCountUser t(true /*finishImmediately*/);
++        t.startBlocking();
++        int count = threads.count();
++        if (count != 1)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, 1);
++
+         (new ThreadCountUser(true /*finishImmediately*/))->startAsynchronously().waitForFinished();
+-        const auto count = threads.count();
++        count = threads.count();
++        if (count != 1)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
+         QCOMPARE(count, 1);
+         QVERIFY(!threads.contains(QThread::currentThread()));
+     }
+@@ -400,6 +437,7 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::exceptions()
+ {
++    // Asynchronous mode:
+     {
+         bool caught = false;
+         try  {
+@@ -412,6 +450,32 @@ void tst_QtConcurrentThreadEngine::exceptions()
+         QVERIFY2(caught, "did not get exception");
+     }
+ 
++    // Blocking mode:
++    // test throwing the exception from a worker thread.
++    {
++        bool caught = false;
++        try  {
++            QtConcurrentExceptionThrower e(QThread::currentThread());
++            e.startBlocking();
++        } catch (const QException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // test throwing the exception from the main thread (different code path)
++    {
++        bool caught = false;
++        try  {
++            QtConcurrentExceptionThrower e(0);
++            e.startBlocking();
++        } catch (const QException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // Asynchronous mode:
+     {
+         bool caught = false;
+         try  {
+@@ -423,6 +487,31 @@ void tst_QtConcurrentThreadEngine::exceptions()
+         }
+         QVERIFY2(caught, "did not get exception");
+     }
++
++    // Blocking mode:
++    // test throwing the exception from a worker thread.
++    {
++        bool caught = false;
++        try  {
++            UnrelatedExceptionThrower e(QThread::currentThread());
++            e.startBlocking();
++        } catch (const QUnhandledException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // test throwing the exception from the main thread (different code path)
++    {
++        bool caught = false;
++        try  {
++            UnrelatedExceptionThrower e(0);
++            e.startBlocking();
++        } catch (const QUnhandledException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
+ }
+ 
+ #endif
+diff --git a/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp b/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
+index 4968742110..f4c3fb711d 100644
+--- a/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
++++ b/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
+@@ -42,6 +42,7 @@ private slots:
+     void writeBlock_data();
+     void writeBlock();
+     void seek();
++    void invalidSeeks();
+     void seekTest_data();
+     void seekTest();
+     void read_rawdata();
+@@ -286,6 +287,29 @@ void tst_QBuffer::seek()
+     QCOMPARE(buffer.size(), pos);
+ }
+ 
++void tst_QBuffer::invalidSeeks()
++{
++    if constexpr (sizeof(qsizetype) == sizeof(qint64)) {
++        // sizeof(qsizetype) == sizeof(qint64), so +1 would overflow
++        QSKIP("This is a 32-bit-only test.");
++    } else {
++        QBuffer buffer;
++        buffer.open(QIODevice::WriteOnly);
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++        constexpr qint64 MaxQByteArrayCapacity = (std::numeric_limits<qsizetype>::max)();
++        // this should fail fast, not after trying to allocate nearly 2 GiB of data,
++        // potentially crashing in the process:
++        QVERIFY(!buffer.seek(2 * MaxQByteArrayCapacity - 1));
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++        // ditto:
++        QVERIFY(!buffer.seek(MaxQByteArrayCapacity + 1));
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++    }
++}
++
+ void tst_QBuffer::seekTest_data()
+ {
+     writeBlock_data();
+diff --git a/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp b/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
+index da5327594c..4a04e0f7c6 100644
+--- a/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
++++ b/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
+@@ -561,7 +561,8 @@ protected:
+     qint64 readData(char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf->size() - offset));
+-        memcpy(data, buf->constData() + offset, maxSize);
++        if (maxSize > 0)
++            memcpy(data, buf->constData() + offset, maxSize);
+         offset += maxSize;
+         return maxSize;
+     }
+@@ -604,13 +605,15 @@ protected:
+     qint64 readData(char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf.size() - pos()));
+-        memcpy(data, buf.constData() + pos(), maxSize);
++        if (maxSize > 0)
++            memcpy(data, buf.constData() + pos(), maxSize);
+         return maxSize;
+     }
+     qint64 writeData(const char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf.size() - pos()));
+-        memcpy(buf.data() + pos(), data, maxSize);
++        if (maxSize > 0)
++            memcpy(buf.data() + pos(), data, maxSize);
+         return maxSize;
+     }
+ 
+diff --git a/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+index db60bead64..f345a44414 100644
+--- a/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
++++ b/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+@@ -1,7 +1,8 @@
+ /****************************************************************************
+ **
+ ** Copyright (C) 2021 The Qt Company Ltd.
+-** Copyright (C) 2020 Intel Corporation.
++** Copyright (C) 2020 The Qt Company Ltd.
++** Copyright (C) 2022 Intel Corporation.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the test suite of the Qt Toolkit.
+@@ -150,6 +151,8 @@ private slots:
+     void startStopStartStopBuffers();
+     void processEventsInAReadyReadSlot_data();
+     void processEventsInAReadyReadSlot();
++    void startFromCurrentWorkingDir_data();
++    void startFromCurrentWorkingDir();
+ 
+     // keep these at the end, since they use lots of processes and sometimes
+     // caused obscure failures to occur in tests that followed them (esp. on the Mac)
+@@ -2731,5 +2734,94 @@ void tst_QProcess::finishProcessBeforeReadingDone_deprecated()
+ 
+ #endif
+ 
++enum class ChdirMode {
++    None = 0,
++    InParent,
++    InChild
++};
++Q_DECLARE_METATYPE(ChdirMode)
++
++void tst_QProcess::startFromCurrentWorkingDir_data()
++{
++    qRegisterMetaType<ChdirMode>();
++    QTest::addColumn<QString>("programPrefix");
++    QTest::addColumn<ChdirMode>("chdirMode");
++    QTest::addColumn<bool>("success");
++
++    constexpr bool IsWindows = true
++#ifdef Q_OS_UNIX
++            && false
++#endif
++            ;
++
++    // baseline: trying to execute the directory, this can't possibly succeed!
++    QTest::newRow("plain-same-cwd") << QString() << ChdirMode::None << false;
++
++    // cross-platform behavior: neither OS searches the setWorkingDirectory()
++    // dir without "./"
++    QTest::newRow("plain-child-chdir") << QString() << ChdirMode::InChild << false;
++
++    // cross-platform behavior: both OSes search the parent's CWD with "./"
++    QTest::newRow("prefixed-parent-chdir") << "./" << ChdirMode::InParent << true;
++
++    // opposite behaviors: Windows searches the parent's CWD and Unix searches
++    // the child's with "./"
++    QTest::newRow("prefixed-child-chdir") << "./" << ChdirMode::InChild << !IsWindows;
++
++    // Windows searches the parent's CWD without "./"
++    QTest::newRow("plain-parent-chdir") << QString() << ChdirMode::InParent << IsWindows;
++}
++
++void tst_QProcess::startFromCurrentWorkingDir()
++{
++    QFETCH(QString, programPrefix);
++    QFETCH(ChdirMode, chdirMode);
++    QFETCH(bool, success);
++
++    QProcess process;
++    qRegisterMetaType<QProcess::ProcessError>();
++    QSignalSpy errorSpy(&process, &QProcess::errorOccurred);
++    QVERIFY(errorSpy.isValid());
++
++    // both the dir name and the executable name
++    const QString target = QStringLiteral("testProcessNormal");
++    process.setProgram(programPrefix + target);
++
++#ifdef Q_OS_UNIX
++    // Reset PATH, to be sure it doesn't contain . or the empty path.
++    // We can't do this on Windows because DLLs are searched in PATH
++    // and Windows always searches "." anyway.
++    auto restoreEnv = qScopeGuard([old = qgetenv("PATH")] {
++        qputenv("PATH", old);
++    });
++    qputenv("PATH", "/");
++#endif
++
++    switch (chdirMode) {
++    case ChdirMode::InParent: {
++        auto restoreCwd = qScopeGuard([old = QDir::currentPath()] {
++            QDir::setCurrent(old);
++        });
++        QVERIFY(QDir::setCurrent(target));
++        process.start();
++        break;
++    }
++    case ChdirMode::InChild:
++        process.setWorkingDirectory(target);
++        Q_FALLTHROUGH();
++    case ChdirMode::None:
++        process.start();
++        break;
++    }
++
++    QCOMPARE(process.waitForStarted(), success);
++    QCOMPARE(errorSpy.count(), int(!success));
++    if (success) {
++        QVERIFY(process.waitForFinished());
++    } else {
++        QCOMPARE(process.error(), QProcess::FailedToStart);
++    }
++}
++
+ QTEST_MAIN(tst_QProcess)
+ #include "tst_qprocess.moc"
+diff --git a/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp b/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp
+index e1ea7a4552..90972caa57 100644
+--- a/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp
++++ b/qtbase/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"
+diff --git a/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+index 9bd66c0835..ed4a0bae5d 100644
+--- a/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
++++ b/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+@@ -158,6 +158,7 @@ private slots:
+     void nullReceiver();
+     void functorReferencesConnection();
+     void disconnectDisconnects();
++    void declarativeData();
+ };
+ 
+ struct QObjectCreatedOnShutdown
+@@ -7679,5 +7680,81 @@ void tst_QObject::disconnectDisconnects()
+ Q_STATIC_ASSERT(QtPrivate::HasQ_OBJECT_Macro<tst_QObject>::Value);
+ Q_STATIC_ASSERT(!QtPrivate::HasQ_OBJECT_Macro<SiblingDeleter>::Value);
+ 
++#ifdef QT_BUILD_INTERNAL
++/*
++    Since QObjectPrivate stores the declarativeData pointer in a union with the pointer
++    to the currently destroyed child, calls to the QtDeclarative handlers need to be
++    correctly guarded. QTBUG-105286
++*/
++namespace QtDeclarative {
++static QAbstractDeclarativeData *theData;
++
++static void destroyed(QAbstractDeclarativeData *data, QObject *)
++{
++    QCOMPARE(data, theData);
++}
++static void signalEmitted(QAbstractDeclarativeData *data, QObject *, int, void **)
++{
++    QCOMPARE(data, theData);
++}
++// we can't use QCOMPARE in the next two functions, as they don't return void
++static int receivers(QAbstractDeclarativeData *data, const QObject *, int)
++{
++    QTest::qCompare(data, theData, "data", "theData", __FILE__, __LINE__);
++    return 0;
++}
++static bool isSignalConnected(QAbstractDeclarativeData *data, const QObject *, int)
++{
++    QTest::qCompare(data, theData, "data", "theData", __FILE__, __LINE__);
++    return true;
++}
++
++class Object : public QObject
++{
++    Q_OBJECT
++public:
++    using QObject::QObject;
++    ~Object()
++    {
++        if (Object *p = static_cast<Object *>(parent()))
++            p->emitSignal();
++    }
++
++    void emitSignal()
++    {
++        emit theSignal();
++    }
++
++signals:
++    void theSignal();
++};
++
++}
++#endif
++
++void tst_QObject::declarativeData()
++{
++#ifdef QT_BUILD_INTERNAL
++    QScopedValueRollback destroyed(QAbstractDeclarativeData::destroyed,
++                                   QtDeclarative::destroyed);
++    QScopedValueRollback signalEmitted(QAbstractDeclarativeData::signalEmitted,
++                                       QtDeclarative::signalEmitted);
++    QScopedValueRollback receivers(QAbstractDeclarativeData::receivers,
++                                   QtDeclarative::receivers);
++    QScopedValueRollback isSignalConnected(QAbstractDeclarativeData::isSignalConnected,
++                                           QtDeclarative::isSignalConnected);
++
++    QtDeclarative::Object p;
++    QObjectPrivate *priv = QObjectPrivate::get(&p);
++    priv->declarativeData = QtDeclarative::theData = new QAbstractDeclarativeData;
++
++    connect(&p, &QtDeclarative::Object::theSignal, &p, []{
++    });
++
++    QtDeclarative::Object *child = new QtDeclarative::Object;
++    child->setParent(&p);
++#endif
++}
++
+ QTEST_MAIN(tst_QObject)
+ #include "tst_qobject.moc"
+diff --git a/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp b/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
+index 0ea422ecbc..1a3256534b 100644
+--- a/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
++++ b/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
+@@ -70,15 +70,15 @@ static inline QString testSuiteWarning()
+ 
+     QString result;
+     QTextStream str(&result);
+-    str << "\nCannot find the shared-mime-info test suite\nstarting from: "
++    str << "\nCannot find the shared-mime-info test suite\nin the parent of: "
+         << QDir::toNativeSeparators(QDir::currentPath()) << "\n"
+            "cd " << QDir::toNativeSeparators(QStringLiteral("tests/auto/corelib/mimetypes/qmimedatabase")) << "\n"
+-           "wget http://cgit.freedesktop.org/xdg/shared-mime-info/snapshot/Release-1-10.zip\n"
+-           "unzip Release-1-10.zip\n";
++           "wget https://gitlab.freedesktop.org/xdg/shared-mime-info/-/archive/2.1/shared-mime-info-2.1.zip\n"
++           "unzip shared-mime-info-2.1.zip\n";
+ #ifdef Q_OS_WIN
+-    str << "mkdir testfiles\nxcopy /s Release-1-10 s-m-i\n";
++    str << "mkdir testfiles\nxcopy /s shared-mime-info-2.1 s-m-i\n";
+ #else
+-    str << "ln -s Release-1-10 s-m-i\n";
++    str << "ln -s shared-mime-info-2.1 s-m-i\n";
+ #endif
+     return result;
+ }
+@@ -154,7 +154,7 @@ void tst_QMimeDatabase::initTestCase()
+     QVERIFY2(copyResourceFile(xmlFileName, xmlTargetFileName, &errorMessage), qPrintable(errorMessage));
+ #endif
+ 
+-    m_testSuite = QFINDTESTDATA("s-m-i/tests");
++    m_testSuite = QFINDTESTDATA("s-m-i/tests/mime-detection");
+     if (m_testSuite.isEmpty())
+         qWarning("%s", qPrintable(testSuiteWarning()));
+ 
+@@ -611,7 +611,7 @@ void tst_QMimeDatabase::allMimeTypes()
+     QVERIFY(!lst.isEmpty());
+ 
+     // Hardcoding this is the only way to check both providers find the same number of mimetypes.
+-    QCOMPARE(lst.count(), 779);
++    QCOMPARE(lst.count(), 811);
+ 
+     foreach (const QMimeType &mime, lst) {
+         const QString name = mime.name();
+@@ -631,10 +631,9 @@ void tst_QMimeDatabase::suffixes_data()
+ 
+     QTest::newRow("mimetype with a single pattern") << "application/pdf" << "*.pdf" << "pdf";
+     QTest::newRow("mimetype with multiple patterns") << "application/x-kpresenter" << "*.kpr;*.kpt" << "kpr";
+-    QTest::newRow("jpeg") << "image/jpeg" << "*.jpe;*.jpg;*.jpeg" << "jpeg";
+-    //if (KMimeType::sharedMimeInfoVersion() > KDE_MAKE_VERSION(0, 60, 0)) {
+-        QTest::newRow("mimetype with many patterns") << "application/vnd.wordperfect" << "*.wp;*.wp4;*.wp5;*.wp6;*.wpd;*.wpp" << "wp";
+-    //}
++    // The preferred suffix for image/jpeg is *.jpg, as per https://bugs.kde.org/show_bug.cgi?id=176737
++    QTest::newRow("jpeg") << "image/jpeg" << "*.jpe;*.jpg;*.jpeg" << "jpg";
++    QTest::newRow("mimetype with many patterns") << "application/vnd.wordperfect" << "*.wp;*.wp4;*.wp5;*.wp6;*.wpd;*.wpp" << "wp";
+     QTest::newRow("oasis text mimetype") << "application/vnd.oasis.opendocument.text" << "*.odt" << "odt";
+     QTest::newRow("oasis presentation mimetype") << "application/vnd.oasis.opendocument.presentation" << "*.odp" << "odp";
+     QTest::newRow("mimetype with multiple patterns") << "text/plain" << "*.asc;*.txt;*,v" << "txt";
+diff --git a/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp b/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
+index 3e58dd03cc..c8f82ef5d5 100644
+--- a/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
++++ b/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
+@@ -176,6 +176,8 @@ private Q_SLOTS:
+     void fromToVariantConversions_data();
+     void fromToVariantConversions();
+ 
++    void noLeakOnNameClash();
++
+ private:
+     QString testDataDir;
+ };
+@@ -3685,5 +3687,23 @@ void tst_QtJson::fromToVariantConversions()
+     }
+ }
+ 
++void tst_QtJson::noLeakOnNameClash()
++{
++    QJsonDocument doc = QJsonDocument::fromJson("{\"\":{\"\":0},\"\":0}");
++    QVERIFY(!doc.isNull());
++    const QJsonObject obj = doc.object();
++
++    // Removed the duplicate key.
++    QCOMPARE(obj.length(), 1);
++
++    // Retained the last of the duplicates.
++    const QJsonValue val = obj.begin().value();
++    QVERIFY(val.isDouble());
++    QCOMPARE(val.toDouble(), 0.0);
++
++    // It should not leak.
++    // In particular it should not forget to deref the container for the inner object.
++}
++
+ QTEST_MAIN(tst_QtJson)
+ #include "tst_qtjson.moc"
+diff --git a/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp b/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
+index a59b58d57f..241c3e84ac 100644
+--- a/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
++++ b/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
+@@ -63,6 +63,7 @@ private slots:
+     void isValidId_data();
+     void isValidId();
+     void malformed();
++    void serialize();
+     // Backend tests
+     void utcTest();
+     void icuTest();
+@@ -947,6 +948,33 @@ void tst_QTimeZone::malformed()
+         barf.offsetFromUtc(now);
+ }
+ 
++void tst_QTimeZone::serialize()
++{
++    int parts = 0;
++#ifndef QT_NO_DEBUG_STREAM
++    qDebug() << QTimeZone(); // to verify no crash
++    parts++;
++#endif
++#ifndef QT_NO_DATASTREAM
++    QByteArray blob;
++    {
++        QDataStream stream(&blob, QIODevice::WriteOnly);
++        stream << QTimeZone("Europe/Oslo") << QTimeZone(420) << QTimeZone() << qint64(-1);
++    }
++    QDataStream stream(&blob, QIODevice::ReadOnly);
++    QTimeZone invalid, offset, oslo;
++    qint64 minusone;
++    stream >> oslo >> offset >> invalid >> minusone;
++    QCOMPARE(oslo, QTimeZone("Europe/Oslo"));
++    QCOMPARE(offset, QTimeZone(420));
++    QVERIFY(!invalid.isValid());
++    QCOMPARE(minusone, qint64(-1));
++    parts++;
++#endif
++    if (!parts)
++        QSKIP("No serialization enabled");
++}
++
+ void tst_QTimeZone::utcTest()
+ {
+ #ifdef QT_BUILD_INTERNAL
+diff --git a/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp b/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
+index 05480c6dd2..70f4c75756 100644
+--- a/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
++++ b/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
+@@ -324,6 +324,13 @@ void tst_QDBusInterface::notValid()
+ 
+     QVERIFY(!interface.isValid());
+     QVERIFY(!QMetaObject::invokeMethod(&interface, "ListNames", Qt::DirectConnection));
++
++    // With a connection, but empty/null service and path specified
++    QDBusConnection con = QDBusConnection::sessionBus();
++    QVERIFY(con.isConnected());
++    QDBusInterface iface({}, {}, {}, con);
++    QVERIFY(!iface.isValid());
++    QVERIFY(!QMetaObject::invokeMethod(&interface, "ListNames", Qt::DirectConnection));
+ }
+ 
+ void tst_QDBusInterface::notValidDerived()
+diff --git a/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp b/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
+index 874468c954..04ceb4ab65 100644
+--- a/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
++++ b/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
+@@ -507,6 +507,10 @@ void tst_QKeySequence::toStringFromKeycode_data()
+     QTest::newRow("Ctrl+Alt+Num+Del") << QKeySequence(Qt::ControlModifier | Qt::AltModifier | Qt::KeypadModifier | Qt::Key_Delete) << "Ctrl+Alt+Num+Del";
+     QTest::newRow("Ctrl+Ins") << QKeySequence(Qt::ControlModifier | Qt::Key_Insert) << "Ctrl+Ins";
+     QTest::newRow("Ctrl+Num+Ins(1)") << QKeySequence(Qt::Key_Insert | Qt::KeypadModifier | Qt::ControlModifier) << "Ctrl+Num+Ins";
++    QTest::newRow("Ctrl") << QKeySequence(Qt::Key_Control) << "Control";
++    QTest::newRow("Alt") << QKeySequence(Qt::Key_Alt) << "Alt";
++    QTest::newRow("Shift") << QKeySequence(Qt::Key_Shift) << "Shift";
++    QTest::newRow("Meta") << QKeySequence(Qt::Key_Meta) << "Meta";
+ }
+ 
+ void tst_QKeySequence::toStringFromKeycode()
+diff --git a/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp b/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+index 15e0ecadaa..b4eca74283 100644
+--- a/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
++++ b/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+@@ -81,6 +81,8 @@ private slots:
+     void registerOpenTypePreferredNamesSystem();
+     void registerOpenTypePreferredNamesApplication();
+ 
++    void stretchRespected();
++
+ private:
+     QString m_ledFont;
+     QString m_testFont;
+@@ -355,6 +357,28 @@ static QString testString()
+     return QStringLiteral("foo bar");
+ }
+ 
++void tst_QFontDatabase::stretchRespected()
++{
++    int italicId = QFontDatabase::addApplicationFont(m_testFontItalic);
++    QVERIFY(italicId != -1);
++
++    QVERIFY(!QFontDatabase::applicationFontFamilies(italicId).isEmpty());
++
++    QString italicFontName = QFontDatabase::applicationFontFamilies(italicId).first();
++
++    QFont italicFont = QFontDatabase().font(italicFontName,
++                                            QString::fromLatin1("Italic"), 14);
++    QVERIFY(italicFont.italic());
++
++    QFont italicStretchedFont = italicFont;
++    italicStretchedFont.setStretch( 400 );
++
++    QVERIFY(QFontMetricsF(italicFont).horizontalAdvance(QStringLiteral("foobar")) <
++            QFontMetricsF(italicStretchedFont).horizontalAdvance(QStringLiteral("foobar")));
++
++    QFontDatabase::removeApplicationFont(italicId);
++}
++
+ void tst_QFontDatabase::condensedFontWidthNoFontMerging()
+ {
+     int regularFontId = QFontDatabase::addApplicationFont(m_testFont);
+diff --git a/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+index 3d4a094c43..b423e11a99 100644
+--- a/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
++++ b/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+@@ -281,6 +281,7 @@ private Q_SLOTS:
+     void ioGetFromFileSpecial();
+     void ioGetFromFile_data();
+     void ioGetFromFile();
++    void ioGetFromFileUrl();
+     void ioGetFromFtp_data();
+     void ioGetFromFtp();
+     void ioGetFromFtpWithReuse();
+@@ -3300,6 +3301,18 @@ void tst_QNetworkReply::ioGetFromFile()
+     QCOMPARE(reader.data, data);
+ }
+ 
++void tst_QNetworkReply::ioGetFromFileUrl()
++{
++    // This immediately fails on non-windows platforms:
++    QNetworkRequest request(QUrl("file://unc-server/some/path"));
++    QNetworkReplyPtr reply(manager.get(request));
++    QSignalSpy finishedSpy(reply.get(), &QNetworkReply::finished);
++    // QTBUG-105618: This would, on non-Windows platforms, never happen because the signal
++    // was emitted before the constructor finished, leaving no chance at all to connect to the
++    // signal
++    QVERIFY(finishedSpy.wait());
++}
++
+ void tst_QNetworkReply::ioGetFromFtp_data()
+ {
+     QTest::addColumn<QString>("fileName");
+diff --git a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
+index 069fa6b341..4cc4d9a5ea 100644
+--- a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
++++ b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
+@@ -1,75 +1,34 @@
+-Certificate:
+-    Data:
+-        Version: 3 (0x2)
+-        Serial Number: 0 (0x0)
+-        Signature Algorithm: sha1WithRSAEncryption
+-        Issuer: C=NO, ST=Oslo, L=Nydalen, O=Nokia Corporation and/or its subsidiary(-ies), OU=Development, CN=fluke.troll.no/emailAddress=ahanssen@trolltech.com
+-        Validity
+-            Not Before: Dec  4 01:10:32 2007 GMT
+-            Not After : Apr 21 01:10:32 2035 GMT
+-        Subject: C=NO, ST=Oslo, O=Nokia Corporation and/or its subsidiary(-ies), OU=Development, CN=fluke.troll.no
+-        Subject Public Key Info:
+-            Public Key Algorithm: rsaEncryption
+-            RSA Public Key: (1024 bit)
+-                Modulus (1024 bit):
+-                    00:a7:c8:a0:4a:c4:19:05:1b:66:ba:32:e2:d2:f1:
+-                    1c:6f:17:82:e4:39:2e:01:51:90:db:04:34:32:11:
+-                    21:c2:0d:6f:59:d8:53:90:54:3f:83:8f:a9:d3:b3:
+-                    d5:ee:1a:9b:80:ae:c3:25:c9:5e:a5:af:4b:60:05:
+-                    aa:a0:d1:91:01:1f:ca:04:83:e3:58:1c:99:32:45:
+-                    84:70:72:58:03:98:4a:63:8b:41:f5:08:49:d2:91:
+-                    02:60:6b:e4:64:fe:dd:a0:aa:74:08:e9:34:4c:91:
+-                    5f:12:3d:37:4d:54:2c:ad:7f:5b:98:60:36:02:8c:
+-                    3b:f6:45:f3:27:6a:9b:94:9d
+-                Exponent: 65537 (0x10001)
+-        X509v3 extensions:
+-            X509v3 Basic Constraints: 
+-                CA:FALSE
+-            Netscape Comment: 
+-                OpenSSL Generated Certificate
+-            X509v3 Subject Key Identifier: 
+-                21:85:04:3D:23:01:66:E5:F7:9F:1A:84:24:8A:AF:0A:79:F4:E5:AC
+-            X509v3 Authority Key Identifier: 
+-                DirName:/C=NO/ST=Oslo/L=Nydalen/O=Nokia Corporation and/or its subsidiary(-ies)/OU=Development/CN=fluke.troll.no/emailAddress=ahanssen@trolltech.com
+-                serial:8E:A8:B4:E8:91:B7:54:2E
+-
+-    Signature Algorithm: sha1WithRSAEncryption
+-        6d:57:5f:d1:05:43:f0:62:05:ec:2a:71:a5:dc:19:08:f2:c4:
+-        a6:bd:bb:25:d9:ca:89:01:0e:e4:cf:1f:c1:8c:c8:24:18:35:
+-        53:59:7b:c0:43:b4:32:e6:98:b2:a6:ef:15:05:0b:48:5f:e1:
+-        a0:0c:97:a9:a1:77:d8:35:18:30:bc:a9:8f:d3:b7:54:c7:f1:
+-        a9:9e:5d:e6:19:bf:f6:3c:5b:2b:d8:e4:3e:62:18:88:8b:d3:
+-        24:e1:40:9b:0c:e6:29:16:62:ab:ea:05:24:70:36:aa:55:93:
+-        ef:02:81:1b:23:10:a2:04:eb:56:95:75:fc:f8:94:b1:5d:42:
+-        c5:3f:36:44:85:5d:3a:2e:90:46:8a:a2:b9:6f:87:ae:0c:15:
+-        40:19:31:90:fc:3b:25:bb:ae:f1:66:13:0d:85:90:d9:49:34:
+-        8f:f2:5d:f9:7a:db:4d:5d:27:f6:76:9d:35:8c:06:a6:4c:a3:
+-        b1:b2:b6:6f:1d:d7:a3:00:fd:72:eb:9e:ea:44:a1:af:21:34:
+-        7d:c7:42:e2:49:91:19:8b:c0:ad:ba:82:80:a8:71:70:f4:35:
+-        31:91:63:84:20:95:e9:60:af:64:8b:cc:ff:3d:8a:76:74:3d:
+-        c8:55:6d:e4:8e:c3:2b:1c:e8:42:18:ae:9f:e6:6b:9c:34:06:
+-        ec:6a:f2:c3
+ -----BEGIN CERTIFICATE-----
+-MIIEEzCCAvugAwIBAgIBADANBgkqhkiG9w0BAQUFADCBnDELMAkGA1UEBhMCTk8x
+-DTALBgNVBAgTBE9zbG8xEDAOBgNVBAcTB055ZGFsZW4xFjAUBgNVBAoTDVRyb2xs
+-dGVjaCBBU0ExFDASBgNVBAsTC0RldmVsb3BtZW50MRcwFQYDVQQDEw5mbHVrZS50
+-cm9sbC5ubzElMCMGCSqGSIb3DQEJARYWYWhhbnNzZW5AdHJvbGx0ZWNoLmNvbTAe
+-Fw0wNzEyMDQwMTEwMzJaFw0zNTA0MjEwMTEwMzJaMGMxCzAJBgNVBAYTAk5PMQ0w
+-CwYDVQQIEwRPc2xvMRYwFAYDVQQKEw1Ucm9sbHRlY2ggQVNBMRQwEgYDVQQLEwtE
+-ZXZlbG9wbWVudDEXMBUGA1UEAxMOZmx1a2UudHJvbGwubm8wgZ8wDQYJKoZIhvcN
+-AQEBBQADgY0AMIGJAoGBAKfIoErEGQUbZroy4tLxHG8XguQ5LgFRkNsENDIRIcIN
+-b1nYU5BUP4OPqdOz1e4am4CuwyXJXqWvS2AFqqDRkQEfygSD41gcmTJFhHByWAOY
+-SmOLQfUISdKRAmBr5GT+3aCqdAjpNEyRXxI9N01ULK1/W5hgNgKMO/ZF8ydqm5Sd
+-AgMBAAGjggEaMIIBFjAJBgNVHRMEAjAAMCwGCWCGSAGG+EIBDQQfFh1PcGVuU1NM
+-IEdlbmVyYXRlZCBDZXJ0aWZpY2F0ZTAdBgNVHQ4EFgQUIYUEPSMBZuX3nxqEJIqv
+-Cnn05awwgbsGA1UdIwSBszCBsKGBoqSBnzCBnDELMAkGA1UEBhMCTk8xDTALBgNV
+-BAgTBE9zbG8xEDAOBgNVBAcTB055ZGFsZW4xFjAUBgNVBAoTDVRyb2xsdGVjaCBB
+-U0ExFDASBgNVBAsTC0RldmVsb3BtZW50MRcwFQYDVQQDEw5mbHVrZS50cm9sbC5u
+-bzElMCMGCSqGSIb3DQEJARYWYWhhbnNzZW5AdHJvbGx0ZWNoLmNvbYIJAI6otOiR
+-t1QuMA0GCSqGSIb3DQEBBQUAA4IBAQBtV1/RBUPwYgXsKnGl3BkI8sSmvbsl2cqJ
+-AQ7kzx/BjMgkGDVTWXvAQ7Qy5piypu8VBQtIX+GgDJepoXfYNRgwvKmP07dUx/Gp
+-nl3mGb/2PFsr2OQ+YhiIi9Mk4UCbDOYpFmKr6gUkcDaqVZPvAoEbIxCiBOtWlXX8
+-+JSxXULFPzZEhV06LpBGiqK5b4euDBVAGTGQ/Dslu67xZhMNhZDZSTSP8l35ettN
+-XSf2dp01jAamTKOxsrZvHdejAP1y657qRKGvITR9x0LiSZEZi8CtuoKAqHFw9DUx
+-kWOEIJXpYK9ki8z/PYp2dD3IVW3kjsMrHOhCGK6f5mucNAbsavLD
++MIIF6zCCA9OgAwIBAgIUfo9amJtJGWqWE6f+SkAO85zkGr4wDQYJKoZIhvcNAQEL
++BQAwgYMxCzAJBgNVBAYTAk5PMQ0wCwYDVQQIDARPc2xvMQ0wCwYDVQQHDARPc2xv
++MRcwFQYDVQQKDA5UaGUgUXQgQ29tcGFueTEMMAoGA1UECwwDUiZEMRIwEAYDVQQD
++DAlIMiBUZXN0ZXIxGzAZBgkqhkiG9w0BCQEWDG1pbmltaUBxdC5pbzAgFw0yMDEw
++MjYxMjAxMzFaGA8yMTIwMTAwMjEyMDEzMVowgYMxCzAJBgNVBAYTAk5PMQ0wCwYD
++VQQIDARPc2xvMQ0wCwYDVQQHDARPc2xvMRcwFQYDVQQKDA5UaGUgUXQgQ29tcGFu
++eTEMMAoGA1UECwwDUiZEMRIwEAYDVQQDDAlIMiBUZXN0ZXIxGzAZBgkqhkiG9w0B
++CQEWDG1pbmltaUBxdC5pbzCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIB
++AOiUp5+E4blouKH7q+rVNR8NoYX2XkBW+q+rpy1zu5ssRSzbqxAjDx9dkht7Qlnf
++VlDT00JvpOWdeuPon5915edQRsY4Unl6mKH29ra3OtUa1/yCJXsGVJTKCj7k4Bxb
++5mZzb/fTlZntMLdTIBMfUbw62FKir1WjKIcJ9fCoG8JaGeKVO4Rh5p0ezd4UUUId
++r1BXl5Nqdqy2vTMsEDnjOsD3egkv8I2SKN4O6n/C3wWYpMOWYZkGoZiKz7rJs/i/
++ez7bsV7JlwdzTlhpJzkcOSVFBP6JlEOxTNNxZ1wtKy7PtZGmsSSATq2e6+bw38Ae
++Op0XnzzqcGjtDDofBmT7OFzZWjS9VZS6+DOOe2QHWle1nCHcHyH4ku6IRlsr9xkR
++NAIlOfnvHHxqJUenoeaZ4oQDjCBKS1KXygJO/tL7BLTQVn/xK1EmPvKNnjzWk4tR
++PnibUhhs5635qpOU/YPqFBh1JjVruZbsWcDAhRcew0uxONXOa9E+4lttQ9ySYa1A
++LvWqJuAX7gu2BsBMLyqfm811YnA7CIFMyO+HlqmkLFfv5L/xIRAXR7l26YGO0VwX
++CGjMfz4NVPMMke4nB7qa9NkpXQBQKMms3Qzd5JW0Hy9Ruj5O8GPcFZmV0twjd1uJ
++PD/cAjkWLaXjdNsJ16QWc2nghQRS6HYqKRX6j+CXOxupAgMBAAGjUzBRMB0GA1Ud
++DgQWBBRSCOU58j9NJZkMamt623qyCrhN3TAfBgNVHSMEGDAWgBRSCOU58j9NJZkM
++amt623qyCrhN3TAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4ICAQCq
++q4jxsWeNDv5Nq14hJtF9HB+ZL64zcZtRjJP1YgNs0QppKICmjPOL2nIMGmI/jKrs
++0eGAL/9XXNVHPxm1OPOncvimMMmU6emZfpMdEtTfKP43+Pg9HgKRjLoQp406vGeQ
++8ki/mbBhrItVPgEm3tu2AFA02XTYi+YxCI9kRZLGkM3FbgtOuTLPl0Z9y+kiPc9F
++uCSC03anBEqv+vDSI8+wODymQ/IJ3Jyz1lxIRDfp4qAekmy0jU2c91VOHHEmOmqq
++kqygGFRdwbe99m9yP63r6q0b5K3X2UnJ6bns0hmTwThYwpVPXLU8jdaTddbMukN2
++/Ef96Tsw8nWOEOPMySHOTIPgwyZRp26b0kA9EmhLwOP401SxXVQCmSRmtwNagmtg
++jJKmZoYBN+//D45ibK8z6Q0oOm9P+Whf/uUXehcRxBxyV3xz7k0wKGQbHj/ddwcy
++IUoIN4lrAlib+lK170kTKN352PDmrpo2gmIzPEsfurKAIMSelDl6H+kih16BtZ8y
++Nz6fh9Soqrg3OSAware8pxV7k51crBMoPLN78KoRV8MFCK4K7Fddq4rRISq6hiXq
++r1nsjoEPuKM9huprmZVZe9t5YcDa2I+wb3IiE3uwpZbAdaLDyQ5n6F/qpsiIkZXn
++gtcF7oqpG5oYrwCcZ53y/ezUgUg7PlSz2XwAGvQtgg==
+ -----END CERTIFICATE-----
+diff --git a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
+index 9d1664d609..337ce541a6 100644
+--- a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
++++ b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
+@@ -1,15 +1,52 @@
+------BEGIN RSA PRIVATE KEY-----
+-MIICXAIBAAKBgQCnyKBKxBkFG2a6MuLS8RxvF4LkOS4BUZDbBDQyESHCDW9Z2FOQ
+-VD+Dj6nTs9XuGpuArsMlyV6lr0tgBaqg0ZEBH8oEg+NYHJkyRYRwclgDmEpji0H1
+-CEnSkQJga+Rk/t2gqnQI6TRMkV8SPTdNVCytf1uYYDYCjDv2RfMnapuUnQIDAQAB
+-AoGANFzLkanTeSGNFM0uttBipFT9F4a00dqHz6JnO7zXAT26I5r8sU1pqQBb6uLz
+-/+Qz5Zwk8RUAQcsMRgJetuPQUb0JZjF6Duv24hNazqXBCu7AZzUenjafwmKC/8ri
+-KpX3fTwqzfzi//FKGgbXQ80yykSSliDL3kn/drATxsLCgQECQQDXhEFWLJ0vVZ1s
+-1Ekf+3NITE+DR16X+LQ4W6vyEHAjTbaNWtcTKdAWLA2l6N4WAAPYSi6awm+zMxx4
+-VomVTsjdAkEAx0z+e7natLeFcrrq8pbU+wa6SAP1VfhQWKitxL1e7u/QO90NCpxE
+-oQYKzMkmmpOOFjQwEMAy1dvFMbm4LHlewQJAC/ksDBaUcQHHqjktCtrUb8rVjAyW
+-A8lscckeB2fEYyG5J6dJVaY4ClNOOs5yMDS2Afk1F6H/xKvtQ/5CzInA/QJATDub
+-K+BPU8jO9q+gpuIi3VIZdupssVGmCgObVCHLakG4uO04y9IyPhV9lA9tALtoIf4c
+-VIvv5fWGXBrZ48kZAQJBAJmVCdzQxd9LZI5vxijUCj5EI4e+x5DRqVUvyP8KCZrC
+-AiNyoDP85T+hBZaSXK3aYGpVwelyj3bvo1GrTNwNWLw=
+------END RSA PRIVATE KEY-----
++-----BEGIN PRIVATE KEY-----
++MIIJQgIBADANBgkqhkiG9w0BAQEFAASCCSwwggkoAgEAAoICAQDolKefhOG5aLih
+++6vq1TUfDaGF9l5AVvqvq6ctc7ubLEUs26sQIw8fXZIbe0JZ31ZQ09NCb6TlnXrj
++6J+fdeXnUEbGOFJ5epih9va2tzrVGtf8giV7BlSUygo+5OAcW+Zmc2/305WZ7TC3
++UyATH1G8OthSoq9VoyiHCfXwqBvCWhnilTuEYeadHs3eFFFCHa9QV5eTanastr0z
++LBA54zrA93oJL/CNkijeDup/wt8FmKTDlmGZBqGYis+6ybP4v3s+27FeyZcHc05Y
++aSc5HDklRQT+iZRDsUzTcWdcLSsuz7WRprEkgE6tnuvm8N/AHjqdF5886nBo7Qw6
++HwZk+zhc2Vo0vVWUuvgzjntkB1pXtZwh3B8h+JLuiEZbK/cZETQCJTn57xx8aiVH
++p6HmmeKEA4wgSktSl8oCTv7S+wS00FZ/8StRJj7yjZ481pOLUT54m1IYbOet+aqT
++lP2D6hQYdSY1a7mW7FnAwIUXHsNLsTjVzmvRPuJbbUPckmGtQC71qibgF+4LtgbA
++TC8qn5vNdWJwOwiBTMjvh5appCxX7+S/8SEQF0e5dumBjtFcFwhozH8+DVTzDJHu
++Jwe6mvTZKV0AUCjJrN0M3eSVtB8vUbo+TvBj3BWZldLcI3dbiTw/3AI5Fi2l43Tb
++CdekFnNp4IUEUuh2KikV+o/glzsbqQIDAQABAoICAFw1q6tr5I48vY7DF+rXsuLn
++5ZUWE1IQ6fzB4lr72nJv/9EEGnMgYzt9PpMUsD6vdCpBgS2C0+6RHArFzJtNA+RM
++iHLIG7K7702veyr/xBx/MwiSlMeMv/XpkFxVI6E6skMGG2s3AMXxKvJTy5CpRx+I
++eQFyLG+Ya1X2lgJes/q+/CpAHkOjCOpcLySQC5NZ74q734V7nSdmn+Zs3tYEh+O/
++eiuwTP/j5b38Te5vVTqDxTciJPmljmXLCwa0N100lWlbcpvw8qbqiTI2Jm3XCbUE
++AzHjW9vmrF3cRS1fXxKFGShw3SRqlkbxjfeWoi8qDPUBS4m8LOr8qG9Wo5Nfon0z
++zLP4bci3zHDvVcaaZrrsUBs/yZbg+Dgka1DmX7ekmeccr2yTdKDFgPupYUyxVbTl
++a9ZLJysjFD7rgBv1ZclHonLp6Vbm+ZoTqvteo4ikAy6L9RtBWJ23XEK34PkP/+c5
++2vWZaOrnjSeBHbFce8cdJSxqWpP+eSCI5I9XbDrYFIsQ/gqKgtzDKy2ihJ2Y8STL
++yO4hyFPFjxc+Gg4/P2PpmT5CY2ty44M0BWs+JGW96CJPrrplf2lmQUQJj5LZY66X
++Z/4C9L7ZYtKZ+bs5SvU46yWugAvQZX22Xm9xLXWyVXRdx3bj+3M3fDnF9di/zdbh
++CgLx7oWPNrXc7FCajnn9AoIBAQD5FMYwRpw9NWT9WDxQwx+cSI4Icbd88ByTW63S
++LzeRwZA0J9/SfwO+aBRupzc9GkGXCiZcGMw3AGsCtig8yFlw8E5KnzN7KlftDMnM
++9NUxxzlR8VwKyLnZfG7sDTl057ZlUujnqhmt/F8F7dIy7FVO1dE/8nngA+FYTCOG
++UZdGjwyBDlDM0JJdUWGY3xslutcpCDN5mzSTKjy9drMvImAshRawxRF6WBpn7vr2
++nC6vciqfx1Mzx1vyk0Jm0ilaydDdLMADjt/iL4Nkr0BEs4k+UzQiKDwp8gu7abQ1
++eBfxd9Iar4htQa2I1Ewl6P01G/q+ZYwgHhJ9RVn4AxQXefILAoIBAQDvCouORdQX
++C8wsyp7MwXlF/3NQeNN5/+B2mhbxrBOf7PmMCXLnkRWcjwJtzypWFqJ0sqai/2+0
++bqbMcjX5maT8stT2shl3zXe/Ejt2e3TBYpc1tyuses8Kb5BMU8hu6tTd3G2CMXpD
++dT6DVemJZCTtwj9aBNIxSizvlgMolJnCpzhPnlfHSI6E+g3m/LTTo3HwbjMSw/Uq
++irgjOpI2wSBB6LZPSgjvfcYPRyWUk16L4A5uSX0cADnovDFLa5/h0wJvN/OoCSQg
++rLCXG5E18EyL5Wc58BCY1ZvxmjG3lQtgPxYu2Jwc36R/y/JKlxW5suER5ZNpbbD4
++uOyTt2VxMQ2bAoIBAQC5+MzRFqdo/AjfL5Y5JrbfVTzXCTDa09xCGd16ZU60QTWN
+++4ed/r+o1sUKqUcRFB2MzEM/2DQBjQpZB/CbEWvWa1XJWXxypXbowveZU+QqOnmN
++uQvj8WLyA3o+PNF9e9QvauwCrHpn8VpxbtPWuaYoKnUFreFZZQxHhPGxRBIS2JOZ
++eDrT8ZaWnkCkh1AZp5smQ71LOprSlmKrg4jd1GjCVMxQR5N5KXbtyv0OTCZ/UFqK
++2aRBsMPyJgkaBChkZPLRcKwc+/wlQRx1fHQb14DNTApMxoXFO7eOwqmOkpAt9iyl
++SBIwoS0UUI5ab88+bBmXNvKcuFdNuQ4nowTJUn9pAoIBADMNkILBXSvS5DeIyuO2
++Sp1tkoZUV+5NfPY3sMDK3KIibaW/+t+EOBZo4L7tKQCb8vRzl21mmsfxfgRaPDbj
++3r3tv9g0b4YLxxBy52pFscj/soXRai17SS7UZwA2QK+XzgDYbDcLNC6mIsTQG4Gx
++dsWk3/zs3KuUSQaehmwrWK+fIUK38c1pLK8v7LoxrLkqxlHwZ04RthHw8KTthH7X
++Pnl1J0LF8CSeOyfWLSuPUfkT0GEzptnNHpEbaHfQM6R6eaGhVJPF6AZme4y6YYgg
++m2ihhSt1n0XVEWpHYWjxFy3mK2mz75unFC4LM+NEY2p2zuUQoCw7NjnY3QYrfCnx
++rRMCggEAXeXsMSLFjjyuoL7iKbAxo52HD/P0fBoy58LyRcwfNVr0lvYan4pYEx+o
++KijIh9K16PqXZXKMA9v003B+ulmF8bJ7SddCZ5NGvnFhUTDe4DdTKgp2RuwQ3Bsc
++3skPIDbhVETyOLCtys34USHrq8U/0DlGY3eLRfxw9GnbKxSBGa/KEu/qQLPNUo50
++7xHZDg7GKeC3kqNJeqKM9rkp0VzIGkEnaD9127LeNDmERDfftxJzFoC/THvUBLfU
++6Sus2ZYwRE8VFvKC30Q45t/c54X3IuhYvAuiCuTmyfE4ruyzyOwKzhUkeeLq1APX
++g0veFbyfzlJ0q8qzD/iffqqIa2ZSmQ==
++-----END PRIVATE KEY-----
+diff --git a/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp b/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
+index 7ba3715e13..752aa122f6 100644
+--- a/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
++++ b/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
+@@ -179,6 +179,7 @@ void tst_QAccessibilityLinux::initTestCase()
+     QVERIFY(!address.isEmpty());
+ 
+     m_window = new AccessibleTestWindow();
++    m_window->setObjectName("mainWindow"_L1);
+     m_window->show();
+ 
+     QVERIFY(QTest::qWaitForWindowExposed(m_window));
+@@ -236,8 +237,11 @@ bool hasState(QDBusInterface *interface, AtspiStateType state)
+ void tst_QAccessibilityLinux::testLabel()
+ {
+     QLabel *l = new QLabel(m_window);
++    l->setObjectName("theObjectName"_L1);
+     l->setText("Hello A11y");
+     m_window->addWidget(l);
++    auto a11yEmpty = new QLabel(m_window);
++    m_window->addWidget(l);
+ 
+     // Application
+     QCOMPARE(getParent(mainWindow), QLatin1String(ATSPI_DBUS_PATH_ROOT));
+@@ -249,6 +253,8 @@ void tst_QAccessibilityLinux::testLabel()
+     QCOMPARE(getChildren(labelInterface).count(), 0);
+     QCOMPARE(labelInterface->call(QDBus::Block, "GetRoleName").arguments().first().toString(), QLatin1String("label"));
+     QCOMPARE(labelInterface->call(QDBus::Block, "GetRole").arguments().first().toUInt(), 29u);
++    QCOMPARE(labelInterface->call(QDBus::Block, "GetAccessibleId").arguments().first().toString(),
++             QLatin1String("mainWindow.theObjectName"));
+     QCOMPARE(getParent(labelInterface), mainWindow->path());
+     QVERIFY(!hasState(labelInterface, ATSPI_STATE_EDITABLE));
+     QVERIFY(hasState(labelInterface, ATSPI_STATE_READ_ONLY));
+@@ -256,7 +262,12 @@ void tst_QAccessibilityLinux::testLabel()
+     l->setText("New text");
+     QCOMPARE(labelInterface->property("Name").toString(), l->text());
+ 
++    auto *a11yEmptyInterface = getInterface(children.at(1), "org.a11y.atspi.Accessible");
++    QCOMPARE(a11yEmptyInterface->call(QDBus::Block, "GetAccessibleId").arguments().first().toString(),
++             QLatin1String("mainWindow.QLabel"));
++
+     m_window->clearChildren();
++    delete a11yEmptyInterface;
+     delete labelInterface;
+ }
+ 
+diff --git a/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+index 76df61c892..6d6d65b791 100644
+--- a/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
++++ b/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2022 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the test suite of the Qt Toolkit.
+@@ -68,6 +68,8 @@ private slots:
+     void query_exec();
+     void execErrorRecovery_data() { generic_data(); }
+     void execErrorRecovery();
++    void prematureExec_data() { generic_data(); }
++    void prematureExec();
+     void first_data() { generic_data(); }
+     void first();
+     void next_data() { generic_data(); }
+@@ -2770,6 +2772,35 @@ void tst_QSqlQuery::execErrorRecovery()
+     QVERIFY_SQL( q, exec() );
+ }
+ 
++void tst_QSqlQuery::prematureExec()
++{
++    QFETCH(QString, dbName);
++    // We only want the engine name, for addDatabase():
++    int cut = dbName.indexOf(QChar('@'));
++    if (cut < 0)
++        QSKIP("Failed to parse database type out of name");
++    dbName.truncate(cut);
++    cut = dbName.indexOf(QChar('_'));
++    if (cut >= 0)
++        dbName = dbName.mid(cut + 1);
++
++    auto db = QSqlDatabase::addDatabase(dbName);
++    QSqlQuery q(db);
++
++    QTest::ignoreMessage(QtWarningMsg,
++                         "QSqlDatabasePrivate::removeDatabase: connection "
++                         "'qt_sql_default_connection' is still in use, all "
++                         "queries will cease to work.");
++    QTest::ignoreMessage(QtWarningMsg,
++                         "QSqlDatabasePrivate::addDatabase: duplicate connection name "
++                         "'qt_sql_default_connection', old connection removed.");
++    auto otherDb = QSqlDatabase::addDatabase(dbName);
++
++    QTest::ignoreMessage(QtWarningMsg, "QSqlQuery::exec: called before driver has been set up");
++    // QTBUG-100037: shouldn't crash !
++    QVERIFY(!q.exec("select stuff from TheVoid"));
++}
++
+ void tst_QSqlQuery::lastInsertId()
+ {
+     QFETCH( QString, dbName );
+diff --git a/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp b/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
+index 4aa3f8d60b..d2050a61aa 100644
+--- a/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
++++ b/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
+@@ -115,6 +115,10 @@ void tst_QAbstractItemModelTester::standardItemModelZeroColumns()
+     // QTBUG-92886
+     model.insertRows(0, 5);
+     model.removeRows(1, 2);
++
++    const QModelIndex parentIndex = model.index(0, 0);
++    model.insertRows(0, 5, parentIndex);
++    model.removeRows(1, 2, parentIndex);
+ }
+ 
+ void tst_QAbstractItemModelTester::testInsertThroughProxy()
+diff --git a/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json b/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
+index 12a4a22a19..ce518e78fb 100644
+--- a/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
++++ b/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
+@@ -668,50 +668,6 @@
+         "inputFile": "task192552.h",
+         "outputRevision": 67
+     },
+-    {
+-        "classes": [
+-            {
+-                "className": "InlineSlotsWithThrowDeclaration",
+-                "object": true,
+-                "qualifiedClassName": "InlineSlotsWithThrowDeclaration",
+-                "slots": [
+-                    {
+-                        "access": "public",
+-                        "name": "a",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "b",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "c",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "d",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "e",
+-                        "returnType": "void"
+-                    }
+-                ],
+-                "superClasses": [
+-                    {
+-                        "access": "public",
+-                        "name": "QObject"
+-                    }
+-                ]
+-            }
+-        ],
+-        "inputFile": "task189996.h",
+-        "outputRevision": 67
+-    },
+     {
+         "classes": [
+             {
+diff --git a/qtbase/tests/auto/tools/moc/moc.pro b/qtbase/tests/auto/tools/moc/moc.pro
+index c324b3a8cd..4aceb78dc0 100644
+--- a/qtbase/tests/auto/tools/moc/moc.pro
++++ b/qtbase/tests/auto/tools/moc/moc.pro
+@@ -15,7 +15,7 @@ cross_compile: DEFINES += MOC_CROSS_COMPILED
+ HEADERS += using-namespaces.h no-keywords.h task87883.h c-comments.h backslash-newlines.h oldstyle-casts.h \
+            slots-with-void-template.h qinvokable.h namespaced-flags.h trigraphs.h \
+            escapes-in-string-literals.h cstyle-enums.h qprivateslots.h gadgetwithnoenums.h \
+-           dir-in-include-path.h single_function_keyword.h task192552.h task189996.h \
++           dir-in-include-path.h single_function_keyword.h task192552.h \
+            task234909.h task240368.h pure-virtual-signals.h cxx11-enums.h \
+            cxx11-final-classes.h \
+            cxx11-explicit-override-control.h \
+diff --git a/qtbase/tests/auto/tools/moc/task189996.h b/qtbase/tests/auto/tools/moc/task189996.h
+deleted file mode 100644
+index f94a051b3a..0000000000
+--- a/qtbase/tests/auto/tools/moc/task189996.h
++++ /dev/null
+@@ -1,47 +0,0 @@
+-/****************************************************************************
+-**
+-** Copyright (C) 2016 The Qt Company Ltd.
+-** Contact: https://www.qt.io/licensing/
+-**
+-** This file is part of the test suite of the Qt Toolkit.
+-**
+-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+-** 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 General Public License Usage
+-** Alternatively, this file may be used under the terms of the GNU
+-** General Public License version 3 as published by the Free Software
+-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+-** 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-3.0.html.
+-**
+-** $QT_END_LICENSE$
+-**
+-****************************************************************************/
+-// inline functions can have throw declarations
+-
+-#ifndef TASK189996_H
+-#define TASK189996_H
+-
+-#include <QObject>
+-
+-class InlineSlotsWithThrowDeclaration : public QObject
+-{
+-    Q_OBJECT
+-
+-public slots:
+-    void a() throw() { }
+-    void b() const throw() { }
+-    void c() throw();
+-    void d() throw(int) { }
+-    void e() const throw(int,double) { }
+-};
+-
+-#endif
+diff --git a/qtbase/tests/auto/tools/moc/tst_moc.cpp b/qtbase/tests/auto/tools/moc/tst_moc.cpp
+index c716aead21..15dd9e41e5 100644
+--- a/qtbase/tests/auto/tools/moc/tst_moc.cpp
++++ b/qtbase/tests/auto/tools/moc/tst_moc.cpp
+@@ -631,7 +631,6 @@ public:
+ private slots:
+     void initTestCase();
+ 
+-    void slotWithException() throw(MyStruct);
+     void dontStripNamespaces();
+     void oldStyleCasts();
+     void warnOnExtraSignalSlotQualifiaction();
+@@ -673,7 +672,6 @@ private slots:
+     void templateGtGt();
+     void qprivateslots();
+     void qprivateproperties();
+-    void inlineSlotsWithThrowDeclaration();
+     void warnOnPropertyWithoutREAD();
+     void constructors();
+     void typenameWithUnsigned();
+@@ -784,12 +782,6 @@ void tst_Moc::initTestCase()
+ #endif
+ }
+ 
+-void tst_Moc::slotWithException() throw(MyStruct)
+-{
+-    // be happy
+-    QVERIFY(true);
+-}
+-
+ void tst_Moc::dontStripNamespaces()
+ {
+     Sender sender;
+@@ -824,7 +816,7 @@ void tst_Moc::oldStyleCasts()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-Wold-style-cast" << "-I" << "."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -894,7 +886,7 @@ void tst_Moc::inputFileNameWithDotsButNoExtension()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-I" << ".."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -1174,7 +1166,7 @@ void tst_Moc::ignoreOptionClashes()
+     QStringList gccArgs;
+     gccArgs << "-c" << "-x" << "c++" << "-I" << ".."
+          << "-I" << qtIncludePath << "-I" << includeDir << "-o" << "/dev/null"
+-         << "-fPIC" << "-std=c++11" <<  "-";
++         << "-fPIC" << "-std=c++1z" <<  "-";
+     proc.start("gcc", gccArgs);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -1593,21 +1585,6 @@ void tst_Moc::qprivateproperties()
+ 
+ }
+ 
+-#include "task189996.h"
+-
+-void InlineSlotsWithThrowDeclaration::c() throw() {}
+-
+-void tst_Moc::inlineSlotsWithThrowDeclaration()
+-{
+-    InlineSlotsWithThrowDeclaration tst;
+-    const QMetaObject *mobj = tst.metaObject();
+-    QVERIFY(mobj->indexOfSlot("a()") != -1);
+-    QVERIFY(mobj->indexOfSlot("b()") != -1);
+-    QVERIFY(mobj->indexOfSlot("c()") != -1);
+-    QVERIFY(mobj->indexOfSlot("d()") != -1);
+-    QVERIFY(mobj->indexOfSlot("e()") != -1);
+-}
+-
+ void tst_Moc::warnOnPropertyWithoutREAD()
+ {
+ #ifdef MOC_CROSS_COMPILED
+@@ -1869,7 +1846,7 @@ void tst_Moc::notifyError()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-I" << "."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+diff --git a/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+index c355ee9665..88c09de8e0 100644
+--- a/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
++++ b/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+@@ -251,6 +251,7 @@ private slots:
+     void testResetCachedSizeHint();
+     void statusTips();
+     void testRemovingColumnsViaLayoutChanged();
++    void testModelMovingColumns();
+ 
+ protected:
+     void setupTestData(bool use_reset_model = false);
+@@ -360,6 +361,12 @@ public:
+         endRemoveColumns();
+     }
+ 
++    void moveColumn(int from, int to)
++    {
++        beginMoveColumns(QModelIndex(), from, from, QModelIndex(), to);
++        endMoveColumns();
++    }
++
+     void cleanup()
+     {
+         emit layoutAboutToBeChanged();
+@@ -3627,5 +3634,18 @@ void tst_QHeaderView::testRemovingColumnsViaLayoutChanged()
+     // The main point of this test is that the section-size restoring code didn't go out of bounds.
+ }
+ 
++void tst_QHeaderView::testModelMovingColumns()
++{
++    QtTestModel model(10, 10);
++    QHeaderView hv(Qt::Horizontal);
++    hv.setModel(&model);
++    hv.resizeSections(QHeaderView::ResizeToContents);
++    hv.show();
++
++    QPersistentModelIndex index3 = model.index(0, 3);
++    model.moveColumn(3, 1);
++    QCOMPARE(index3.column(), 1);
++}
++
+ QTEST_MAIN(tst_QHeaderView)
+ #include "tst_qheaderview.moc"
+diff --git a/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+index 761357b252..06bb706074 100644
+--- a/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
++++ b/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+@@ -397,6 +397,7 @@ private slots:
+     void checkHeaderMinSize();
+ 
+     void resizeToContents();
++    void resizeToContentsSpans();
+ 
+     void tabFocus();
+     void bigModel();
+@@ -3721,6 +3722,70 @@ void tst_QTableView::resizeToContents()
+ 
+ }
+ 
++
++class SpanModel : public QAbstractTableModel
++{
++public:
++    SpanModel(bool sectionsMoved)
++        : _sectionsMoved(sectionsMoved)
++    {}
++    int columnCount(const QModelIndex & = {}) const override { return 2; }
++    int rowCount(const QModelIndex & = {}) const override { return 1; }
++    QVariant data(const QModelIndex &idx, int role = Qt::DisplayRole) const override
++    {
++        if (role != Qt::DisplayRole)
++            return QVariant();
++        const int col = _sectionsMoved ? 1 - idx.column() : idx.column();
++        if (col == 0)
++            return "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.";
++        return QVariant();
++    }
++private:
++    bool _sectionsMoved;
++};
++
++
++void tst_QTableView::resizeToContentsSpans()
++{
++    SpanModel model1(false);
++    SpanModel model2(true);
++    QTableView view1, view2, view3;
++    view1.setModel(&model1);
++    view2.setModel(&model2);
++    view2.horizontalHeader()->moveSection(0, 1);
++    view3.setModel(&model1);
++
++    view1.setSpan(0, 0, 1, 2);
++    view2.setSpan(0, 1, 1, 2);
++    view1.show();
++    view2.show();
++    view3.show();
++    QVERIFY(QTest::qWaitForWindowExposed(&view1));
++    QVERIFY(QTest::qWaitForWindowExposed(&view2));
++    QVERIFY(QTest::qWaitForWindowExposed(&view3));
++    view1.setColumnWidth(0, 100);
++    view1.setColumnWidth(1, 100);
++    view2.setColumnWidth(0, 100);
++    view2.setColumnWidth(1, 100);
++    view3.setColumnWidth(0, 200);
++
++    view1.resizeRowToContents(0);
++    view2.resizeRowToContents(0);
++    view3.resizeRowToContents(0);
++    QCOMPARE(view1.rowHeight(0), view3.rowHeight(0));
++    QCOMPARE(view2.rowHeight(0), view3.rowHeight(0));
++
++    view3.resizeColumnToContents(0);
++    view3.resizeRowToContents(0);
++    // height should be only 1 text line for easy testing
++    view1.setRowHeight(0, view3.verticalHeader()->sectionSize(0));
++    view2.setRowHeight(0, view3.verticalHeader()->sectionSize(0));
++    view1.resizeColumnToContents(0);
++    view2.resizeColumnToContents(1);
++    QCOMPARE(view1.columnWidth(0), view3.columnWidth(0) - view1.columnWidth(1));
++    QCOMPARE(view2.columnWidth(0), view3.columnWidth(0) - view2.columnWidth(1));
++}
++
+ QT_BEGIN_NAMESPACE
+ extern bool Q_WIDGETS_EXPORT qt_tab_all_widgets(); // qapplication.cpp
+ QT_END_NAMESPACE
+diff --git a/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+index a3b8ef78d8..4955cebd5d 100644
+--- a/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
++++ b/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+@@ -1498,7 +1498,7 @@ void tst_QApplication::desktopSettingsAware()
+     environment += QLatin1String("QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM=1");
+     testProcess.setEnvironment(environment);
+ #endif
+-    testProcess.start("desktopsettingsaware_helper");
++    testProcess.start("./desktopsettingsaware_helper");
+     QVERIFY2(testProcess.waitForStarted(),
+              qPrintable(QString::fromLatin1("Cannot start 'desktopsettingsaware_helper': %1").arg(testProcess.errorString())));
+     QVERIFY(testProcess.waitForFinished(10000));
+@@ -2452,7 +2452,7 @@ void tst_QApplication::qtbug_12673()
+ #if QT_CONFIG(process)
+     QProcess testProcess;
+     QStringList arguments;
+-    testProcess.start("modal_helper", arguments);
++    testProcess.start("./modal_helper", arguments);
+     QVERIFY2(testProcess.waitForStarted(),
+              qPrintable(QString::fromLatin1("Cannot start 'modal_helper': %1").arg(testProcess.errorString())));
+     QVERIFY(testProcess.waitForFinished(20000));
+diff --git a/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp b/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
+index eb108a40de..dca5528c1b 100644
+--- a/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
+@@ -41,6 +41,7 @@
+ 
+ #include <private/qguiapplication_p.h>
+ #include <qpa/qplatformintegration.h>
++#include <qpa/qplatformtheme.h>
+ 
+ class tst_QAbstractButton : public QObject
+ {
+@@ -76,6 +77,8 @@ private slots:
+     void keyNavigation();
+ #endif
+ 
++    void buttonPressKeys();
++
+ protected slots:
+     void onClicked();
+     void onToggled( bool on );
+@@ -269,7 +272,13 @@ void tst_QAbstractButton::setAutoRepeat()
+         QCOMPARE(press_count, click_count);
+         QVERIFY(click_count > 1);
+         break;
+-    case 4:
++    case 4: {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(Qt::Key_Enter)) {
++            QSKIP("platform theme has Key_Enter in ButtonPressKeys");
++        }
+         // check that pressing ENTER has no effect when autorepeat is false
+         testWidget->setDown( false );
+         testWidget->setAutoRepeat( false );
+@@ -286,7 +295,14 @@ void tst_QAbstractButton::setAutoRepeat()
+ 
+         QVERIFY( click_count == 0 );
+         break;
+-    case 5:
++    }
++    case 5: {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(Qt::Key_Enter)) {
++            QSKIP("platform theme has Key_Enter in ButtonPressKeys");
++        }
+         // check that pressing ENTER has no effect when autorepeat is true
+         testWidget->setDown( false );
+         testWidget->setAutoRepeat( true );
+@@ -304,6 +320,7 @@ void tst_QAbstractButton::setAutoRepeat()
+ 
+         QVERIFY( click_count == 0 );
+         break;
++    }
+     case 6:
+         // verify autorepeat is off by default.
+         MyButton tmp( 0);
+@@ -651,5 +668,16 @@ void tst_QAbstractButton::keyNavigation()
+ }
+ #endif
+ 
++void tst_QAbstractButton::buttonPressKeys()
++{
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(testWidget, buttonPressKeys[i]);
++        QCOMPARE(click_count, i + 1);
++    }
++}
++
+ QTEST_MAIN(tst_QAbstractButton)
+ #include "tst_qabstractbutton.moc"
+diff --git a/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+index 32437050f5..46b5af6d63 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+@@ -168,6 +168,7 @@ private slots:
+     void checkMenuItemPosWhenStyleSheetIsSet();
+     void checkEmbeddedLineEditWhenStyleSheetIsSet();
+     void propagateStyleChanges();
++    void buttonPressKeys();
+ 
+ private:
+     PlatformInputContext m_platformInputContext;
+@@ -1682,6 +1683,16 @@ void tst_QComboBox::setModel()
+     QCOMPARE(box.rootModelIndex(), rootModelIndex);
+     box.setModel(box.model());
+     QCOMPARE(box.rootModelIndex(), rootModelIndex);
++
++    // check that setting the same model as the completer's doesn't crash
++    QCompleter *completer = new QCompleter(&box);
++    box.setEditable(true);
++    box.setCompleter(completer);
++    auto *listModel = new QStringListModel({ "one", "two" }, completer);
++    completer->setModel(listModel);
++    QCOMPARE(listModel->rowCount(), 2); // make sure it wasn't deleted
++    box.setModel(listModel);
++    QCOMPARE(listModel->rowCount(), 2); // make sure it wasn't deleted
+ }
+ 
+ void tst_QComboBox::setCustomModelAndView()
+@@ -3632,5 +3643,24 @@ void tst_QComboBox::propagateStyleChanges()
+     QVERIFY(frameStyle.inquired);
+ }
+ 
++void tst_QComboBox::buttonPressKeys()
++{
++    QComboBox comboBox;
++    comboBox.setEditable(false);
++    comboBox.addItem(QString::number(1));
++    comboBox.addItem(QString::number(2));
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(&comboBox, buttonPressKeys[i]);
++        // On some platforms, a window will not be immediately visible,
++        // but take some event-loop iterations to complete.
++        // Using QTRY_VERIFY to deal with that.
++        QTRY_VERIFY(comboBox.view()->isVisible());
++        comboBox.hidePopup();
++    }
++}
++
+ QTEST_MAIN(tst_QComboBox)
+ #include "tst_qcombobox.moc"
+diff --git a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
+index be3cfcd104..c228fdfcca 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
++++ b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qcommandlinkbutton
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qcommandlinkbutton.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
+index 0044d33c66..4cf06296e4 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
+@@ -40,6 +40,9 @@
+ #include <QGridLayout>
+ #include <QPainter>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ class tst_QCommandLinkButton : public QObject
+ {
+     Q_OBJECT
+@@ -223,6 +226,13 @@ void tst_QCommandLinkButton::setAutoRepeat()
+     // check that pressing ENTER has no effect
+     resetCounters();
+     testWidget->setDown( false );
++    // Skip after reset if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
+     testWidget->setAutoRepeat( false );
+     QTest::keyPress( testWidget, Qt::Key_Enter );
+ 
+@@ -255,6 +265,14 @@ void tst_QCommandLinkButton::pressed()
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+ 
++    // Skip if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
++
+     QTest::keyPress( testWidget,Qt::Key_Enter );
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+diff --git a/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro b/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
+index 4a5e76ff65..a235fa1fac 100644
+--- a/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
++++ b/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qgroupbox
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qgroupbox.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp b/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
+index 4fb5d262ca..d8d7562b73 100644
+--- a/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
+@@ -35,6 +35,9 @@
+ #include <QRadioButton>
+ #include <QDialog>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ #include "qgroupbox.h"
+ 
+ class tst_QGroupBox : public QObject
+@@ -69,6 +72,7 @@ private slots:
+     void propagateFocus();
+     void task_QTBUG_19170_ignoreMouseReleaseEvent();
+     void task_QTBUG_15519_propagateMouseEvents();
++    void buttonPressKeys();
+ 
+ private:
+     bool checked;
+@@ -610,6 +614,20 @@ void tst_QGroupBox::task_QTBUG_15519_propagateMouseEvents()
+     QCOMPARE(parent.mouseMoved, true);
+ }
+ 
++void tst_QGroupBox::buttonPressKeys()
++{
++    QGroupBox groupBox;
++    groupBox.setCheckable(true);
++    QSignalSpy clickedSpy(&groupBox, &QGroupBox::clicked);
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(&groupBox, buttonPressKeys[i]);
++        QCOMPARE(clickedSpy.length(), i + 1);
++    }
++}
++
+ void tst_QGroupBox::sendMouseMoveEvent(QWidget *widget, const QPoint &localPos)
+ {
+     // Send a MouseMove event without actually moving the pointer
+diff --git a/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro b/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
+index 353ad06ca2..e55f6148f2 100644
+--- a/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
++++ b/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qpushbutton
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qpushbutton.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp b/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
+index e818514a79..4043e9326a 100644
+--- a/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
+@@ -41,6 +41,9 @@
+ #include <QStyleFactory>
+ #include <QTabWidget>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ class tst_QPushButton : public QObject
+ {
+ Q_OBJECT
+@@ -212,6 +215,13 @@ void tst_QPushButton::autoRepeat()
+     // check that pressing ENTER has no effect
+     resetCounters();
+     testWidget->setDown( false );
++    // Skip after reset if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
+     testWidget->setAutoRepeat( false );
+     QTest::keyPress( testWidget, Qt::Key_Enter );
+ 
+@@ -247,6 +257,14 @@ void tst_QPushButton::pressed()
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+ 
++    // Skip if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
++
+     QTest::keyPress( testWidget,Qt::Key_Enter );
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+diff --git a/qtbase/tests/manual/rhi/cubemap_render/buildshader.bat b/qtbase/tests/manual/rhi/cubemap_render/buildshader.bat
+old mode 100755
+new mode 100644
+Submodule qtconnectivity e957d481..056294c0:
+diff --git a/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp b/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
+index e2635fae..a8b8e3b9 100644
+--- a/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
++++ b/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
+@@ -563,9 +563,11 @@ void HciManager::handleHciAclPacket(const quint8 *data, int size)
+ 
+ void HciManager::handleLeMetaEvent(const quint8 *data)
+ {
+-    // Spec v4.2, Vol 2, part E, 7.7.65ff
++    // Spec v5.3, Vol 4, part E, 7.7.65.*
+     switch (*data) {
+-    case 0x1: {
++    case 0x1: // HCI_LE_Connection_Complete
++    case 0xA: // HCI_LE_Enhanced_Connection_Complete
++    {
+         const quint16 handle = bt_get_le16(data + 2);
+         emit connectionComplete(handle);
+         break;
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp b/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
+index 6a93143b..4a18cfc7 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
+@@ -320,7 +320,10 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_finishSdpScan(QBluetoothServiceD
+             for (const QBluetoothUuid &id : serviceClassUuids) {
+                 if (id.minimumSize() == 16) {
+                     serviceInfo.setServiceUuid(id);
+-                    serviceInfo.setServiceName(QBluetoothServiceDiscoveryAgent::tr("Custom Service"));
++                    if (serviceInfo.serviceName().isEmpty()) {
++                        serviceInfo.setServiceName(
++                                    QBluetoothServiceDiscoveryAgent::tr("Custom Service"));
++                    }
+                     QBluetoothServiceInfo::Sequence modSeq =
+                             serviceInfo.attribute(QBluetoothServiceInfo::ServiceClassIds).value<QBluetoothServiceInfo::Sequence>();
+                     modSeq.removeOne(QVariant::fromValue(id));
+@@ -334,8 +337,10 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_finishSdpScan(QBluetoothServiceD
+                 qCDebug(QT_BT_BLUEZ) << "Discovered services" << discoveredDevices.at(0).address().toString()
+                                      << serviceInfo.serviceName() << serviceInfo.serviceUuid()
+                                      << ">>>" << serviceInfo.serviceClassUuids();
+-
+-                emit q->serviceDiscovered(serviceInfo);
++                // Use queued connection to allow us finish the service looping; the application
++                // might call stop() when it has detected the service-of-interest.
++                QMetaObject::invokeMethod(q, "serviceDiscovered", Qt::QueuedConnection,
++                                          Q_ARG(QBluetoothServiceInfo, serviceInfo));
+             }
+         }
+     }
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp b/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
+index e4d85447..aadd4755 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
+@@ -593,7 +593,7 @@ void QBluetoothSocket::setSocketState(QBluetoothSocket::SocketState state)
+ bool QBluetoothSocket::canReadLine() const
+ {
+     Q_D(const QBluetoothSocketBase);
+-    return d->canReadLine();
++    return d->canReadLine() || QIODevice::canReadLine();
+ }
+ 
+ /*!
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp b/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
+index 084aa958..d6aa17a7 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
+@@ -284,6 +284,10 @@ void QBluetoothSocketPrivateBluezDBus::connectToService(
+         return;
+     }
+ 
++    if (service.socketProtocol() != QBluetoothServiceInfo::Protocol::UnknownProtocol)
++        socketType = service.socketProtocol();
++    qCDebug(QT_BT_BLUEZ) << "Socket protocol used:" << socketType;
++
+     connectToService(service.device().address(), targetService, openMode);
+ }
+ 
+diff --git a/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp b/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
+index 05bc1a0f..a7b5ef1f 100644
+--- a/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
++++ b/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
+@@ -142,7 +142,7 @@ void tst_QBluetoothSocket::initTestCase()
+     qDebug() << "Starting discovery";
+ 
+     sda->setUuidFilter(QBluetoothUuid(QString(TEST_SERVICE_UUID)));
+-    sda->start(QBluetoothServiceDiscoveryAgent::MinimalDiscovery);
++    sda->start(QBluetoothServiceDiscoveryAgent::FullDiscovery);
+ 
+     for (int connectTime = MaxConnectTime; !done_discovery && connectTime > 0; connectTime -= 1000)
+         QTest::qWait(1000);
+Submodule qtdeclarative f5701f0d..8defe7bf:
+diff --git a/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h b/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
+index b65b994d6c..15a8cd6878 100644
+--- a/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
++++ b/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
+@@ -86,7 +86,7 @@ public:
+         if (QTypeInfo<T>::isComplex) {
+             for (int i = 0; i < count; ++i)
+                 new (data + i) T(vector.at(i));
+-        } else {
++        } else if (count) {
+             memcpy(data, static_cast<const void*>(vector.constData()), count * sizeof(T));
+         }
+     }
+diff --git a/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp b/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
+index e57cdd8278..94613598af 100644
+--- a/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
++++ b/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
+@@ -1145,8 +1145,7 @@ void Heap::QObjectWrapper::markObjects(Heap::Base *that, QV4::MarkStack *markSta
+ void QObjectWrapper::destroyObject(bool lastCall)
+ {
+     Heap::QObjectWrapper *h = d();
+-    if (!h->internalClass)
+-        return; // destroyObject already got called
++    Q_ASSERT(h->internalClass);
+ 
+     if (h->object()) {
+         QQmlData *ddata = QQmlData::get(h->object(), false);
+@@ -1176,7 +1175,7 @@ void QObjectWrapper::destroyObject(bool lastCall)
+         }
+     }
+ 
+-    h->~Data();
++    h->destroy();
+ }
+ 
+ 
+diff --git a/qtdeclarative/src/qml/memory/qv4mm.cpp b/qtdeclarative/src/qml/memory/qv4mm.cpp
+index 06caf04e5a..da149a67c4 100644
+--- a/qtdeclarative/src/qml/memory/qv4mm.cpp
++++ b/qtdeclarative/src/qml/memory/qv4mm.cpp
+@@ -981,7 +981,7 @@ void MemoryManager::sweep(bool lastSweep, ClassDestroyStatsCallback classCountPt
+ 
+     if (MultiplyWrappedQObjectMap *multiplyWrappedQObjects = engine->m_multiplyWrappedQObjects) {
+         for (MultiplyWrappedQObjectMap::Iterator it = multiplyWrappedQObjects->begin(); it != multiplyWrappedQObjects->end();) {
+-            if (!it.value().isNullOrUndefined())
++            if (it.value().isNullOrUndefined())
+                 it = multiplyWrappedQObjects->erase(it);
+             else
+                 ++it;
+diff --git a/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp b/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
+index 2079a8ed04..a577cb2351 100644
+--- a/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
++++ b/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
+@@ -389,6 +389,12 @@ void QQmlDelegateModelPrivate::connectToAbstractItemModel()
+                       q,  QQmlDelegateModel, SLOT(_q_rowsRemoved(QModelIndex,int,int)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
+                       q,  QQmlDelegateModel, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsInserted(QModelIndex,int,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsInserted(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsRemoved(QModelIndex,int,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsRemoved(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsMoved(QModelIndex,int,int,QModelIndex,int)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
+                       q, QQmlDelegateModel, SLOT(_q_dataChanged(QModelIndex,QModelIndex,QVector<int>)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
+@@ -413,6 +419,12 @@ void QQmlDelegateModelPrivate::disconnectFromAbstractItemModel()
+                         q, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int)));
+     QObject::disconnect(aim, SIGNAL(rowsRemoved(QModelIndex,int,int)),
+                         q, SLOT(_q_rowsRemoved(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsInserted(QModelIndex,int,int)), q,
++                        SLOT(_q_columnsInserted(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsRemoved(QModelIndex,int,int)), q,
++                        SLOT(_q_columnsRemoved(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)), q,
++                        SLOT(_q_columnsMoved(QModelIndex,int,int,QModelIndex,int)));
+     QObject::disconnect(aim, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
+                         q, SLOT(_q_dataChanged(QModelIndex,QModelIndex,QVector<int>)));
+     QObject::disconnect(aim, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
+@@ -1973,6 +1985,38 @@ void QQmlDelegateModel::_q_rowsMoved(
+     }
+ }
+ 
++void QQmlDelegateModel::_q_columnsInserted(const QModelIndex &parent, int begin, int end)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if (parent == d->m_adaptorModel.rootIndex && begin == 0) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
++void QQmlDelegateModel::_q_columnsRemoved(const QModelIndex &parent, int begin, int end)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if (parent == d->m_adaptorModel.rootIndex && begin == 0) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
++void QQmlDelegateModel::_q_columnsMoved(const QModelIndex &parent, int start, int end,
++                                        const QModelIndex &destination, int column)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if ((parent == d->m_adaptorModel.rootIndex && start == 0)
++        || (destination == d->m_adaptorModel.rootIndex && column == 0)) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
+ void QQmlDelegateModel::_q_dataChanged(const QModelIndex &begin, const QModelIndex &end, const QVector<int> &roles)
+ {
+     Q_D(QQmlDelegateModel);
+diff --git a/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h b/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
+index 8aab4badca..d140bfbaaf 100644
+--- a/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
++++ b/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
+@@ -152,6 +152,9 @@ private Q_SLOTS:
+     void _q_itemsMoved(int from, int to, int count);
+     void _q_modelReset();
+     void _q_rowsInserted(const QModelIndex &,int,int);
++    void _q_columnsInserted(const QModelIndex &, int, int);
++    void _q_columnsRemoved(const QModelIndex &, int, int);
++    void _q_columnsMoved(const QModelIndex &, int, int, const QModelIndex &, int);
+     void _q_rowsAboutToBeRemoved(const QModelIndex &parent, int begin, int end);
+     void _q_rowsRemoved(const QModelIndex &,int,int);
+     void _q_rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int);
+diff --git a/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp b/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
+index 85719fdc80..78e2ab302c 100644
+--- a/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
++++ b/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
+@@ -46,6 +46,7 @@
+ #include "QtQuick/private/qquicktextinput_p.h"
+ #include "QtQuick/private/qquickaccessibleattached_p.h"
+ #include "QtQuick/qquicktextdocument.h"
++#include "QtQuick/qquickrendercontrol.h"
+ QT_BEGIN_NAMESPACE
+ 
+ #if QT_CONFIG(accessibility)
+@@ -57,7 +58,19 @@ QAccessibleQuickItem::QAccessibleQuickItem(QQuickItem *item)
+ 
+ QWindow *QAccessibleQuickItem::window() const
+ {
+-    return item()->window();
++    QQuickWindow *window = item()->window();
++
++    // For QQuickWidget the above window will be the offscreen QQuickWindow,
++    // which is not a part of the accessibility tree. Detect this case and
++    // return the window for the QQuickWidget instead.
++    if (window && !window->handle()) {
++        if (QQuickRenderControl *renderControl = QQuickWindowPrivate::get(window)->renderControl) {
++            if (QWindow *renderWindow = renderControl->renderWindow(nullptr))
++                return renderWindow;
++        }
++    }
++
++    return window;
+ }
+ 
+ int QAccessibleQuickItem::childCount() const
+@@ -113,19 +126,15 @@ QAccessibleInterface *QAccessibleQuickItem::childAt(int x, int y) const
+ QAccessibleInterface *QAccessibleQuickItem::parent() const
+ {
+     QQuickItem *parent = item()->parentItem();
+-    QQuickWindow *window = item()->window();
+-    QQuickItem *ci = window ? window->contentItem() : nullptr;
++    QQuickWindow *itemWindow = item()->window();
++    QQuickItem *ci = itemWindow ? itemWindow->contentItem() : nullptr;
+     while (parent && !QQuickItemPrivate::get(parent)->isAccessible && parent != ci)
+         parent = parent->parentItem();
+ 
+     if (parent) {
+         if (parent == ci) {
+-            // Jump out to the scene widget if the parent is the root item.
+-            // There are two root items, QQuickWindow::rootItem and
+-            // QQuickView::declarativeRoot. The former is the true root item,
+-            // but is not a part of the accessibility tree. Check if we hit
+-            // it here and return an interface for the scene instead.
+-            return QAccessible::queryAccessibleInterface(window);
++            // Jump out to the window if the parent is the root item
++            return QAccessible::queryAccessibleInterface(window());
+         } else {
+             while (parent && !parent->d_func()->isAccessible)
+                 parent = parent->parentItem();
+@@ -188,7 +197,7 @@ QAccessible::State QAccessibleQuickItem::state() const
+     QRect viewRect_ = viewRect();
+     QRect itemRect = rect();
+ 
+-    if (viewRect_.isNull() || itemRect.isNull() || !item()->window() || !item()->window()->isVisible() ||!item()->isVisible() || qFuzzyIsNull(item()->opacity()))
++    if (viewRect_.isNull() || itemRect.isNull() || !window() || !window()->isVisible() ||!item()->isVisible() || qFuzzyIsNull(item()->opacity()))
+         state.invisible = true;
+     if (!viewRect_.intersects(itemRect))
+         state.offscreen = true;
+@@ -201,6 +210,10 @@ QAccessible::State QAccessibleQuickItem::state() const
+     if (role() == QAccessible::EditableText)
+         if (auto ti = qobject_cast<QQuickTextInput *>(item()))
+             state.passwordEdit = ti->echoMode() != QQuickTextInput::Normal;
++    if (!item()->isEnabled()) {
++        state.focusable = false;
++        state.disabled = true;
++    }
+     return state;
+ }
+ 
+diff --git a/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h b/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
+index 39ffcaf39c..8baa01330c 100644
+--- a/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
++++ b/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
+@@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE
+ 
+ #if QT_CONFIG(accessibility)
+ 
+-class QAccessibleQuickWindow : public QAccessibleObject
++class Q_QUICK_EXPORT QAccessibleQuickWindow : public QAccessibleObject
+ {
+ public:
+     QAccessibleQuickWindow(QQuickWindow *object);
+diff --git a/qtdeclarative/src/quick/items/qquickdrag.cpp b/qtdeclarative/src/quick/items/qquickdrag.cpp
+index 8321fcfeed..383078b3b9 100644
+--- a/qtdeclarative/src/quick/items/qquickdrag.cpp
++++ b/qtdeclarative/src/quick/items/qquickdrag.cpp
+@@ -481,7 +481,9 @@ void QQuickDragAttached::setKeys(const QStringList &keys)
+     \qmlattachedproperty stringlist QtQuick::Drag::mimeData
+     \since 5.2
+ 
+-    This property holds a map of mimeData that is used during startDrag.
++    This property holds a map from mime type to data that is used during startDrag.
++    The mime data needs to be a \c string, or an \c ArrayBuffer with the data encoded
++    according to the mime type.
+ */
+ 
+ QVariantMap QQuickDragAttached::mimeData() const
+@@ -766,8 +768,12 @@ Qt::DropAction QQuickDragAttachedPrivate::startDrag(Qt::DropActions supportedAct
+     QDrag *drag = new QDrag(source ? source : q);
+     QMimeData *mimeData = new QMimeData();
+ 
+-    for (auto it = externalMimeData.cbegin(), end = externalMimeData.cend(); it != end; ++it)
+-        mimeData->setData(it.key(), it.value().toString().toUtf8());
++    for (auto it = externalMimeData.cbegin(), end = externalMimeData.cend(); it != end; ++it) {
++        if (static_cast<QMetaType::Type>(it.value().type()) == QMetaType::QByteArray)
++            mimeData->setData(it.key(), it.value().toByteArray());
++        else
++            mimeData->setData(it.key(), it.value().toString().toUtf8());
++    }
+ 
+     drag->setMimeData(mimeData);
+     if (pixmapLoader.isReady()) {
+diff --git a/qtdeclarative/src/quick/items/qquickitem.cpp b/qtdeclarative/src/quick/items/qquickitem.cpp
+index 75f1457816..dec0ae19ae 100644
+--- a/qtdeclarative/src/quick/items/qquickitem.cpp
++++ b/qtdeclarative/src/quick/items/qquickitem.cpp
+@@ -59,6 +59,7 @@
+ #include <QtCore/private/qnumeric_p.h>
+ #include <QtGui/qpa/qplatformtheme.h>
+ #include <QtCore/qloggingcategory.h>
++#include <QtCore/private/qduplicatetracker_p.h>
+ 
+ #include <private/qqmlglobal_p.h>
+ #include <private/qqmlengine_p.h>
+@@ -2326,6 +2327,7 @@ QQuickItem::QQuickItem(QQuickItemPrivate &dd, QQuickItem *parent)
+ QQuickItem::~QQuickItem()
+ {
+     Q_D(QQuickItem);
++    d->inDestructor = true;
+ 
+     if (d->windowRefCount > 1)
+         d->windowRefCount = 1; // Make sure window is set to null in next call to derefWindow().
+@@ -2526,6 +2528,7 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo
+     QQuickItem *current = item;
+     qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: startItem:" << startItem;
+     qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: firstFromItem:" << firstFromItem;
++    QDuplicateTracker<QQuickItem *> cycleDetector;
+     do {
+         qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: current:" << current;
+         qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: from:" << from;
+@@ -2592,7 +2595,10 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo
+         // traversed all of the chain (by compare the [current] item with [startItem])
+         // Since the [startItem] might be promoted to its parent if it is invisible,
+         // we still have to check [current] item with original start item
+-        if ((current == startItem || current == originalStartItem) && from == firstFromItem) {
++        // We might also run into a cycle before we reach firstFromItem again
++        // but note that we have to ignore current if we are meant to skip it
++        if (((current == startItem || current == originalStartItem) && from == firstFromItem) ||
++                (!skip && cycleDetector.hasSeen(current))) {
+             // wrapped around, avoid endless loops
+             if (item == contentItem) {
+                 qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: looped, return contentItem";
+@@ -2689,9 +2695,8 @@ void QQuickItem::setParentItem(QQuickItem *parentItem)
+ 
+         const bool wasVisible = isVisible();
+         op->removeChild(this);
+-        if (wasVisible) {
++        if (wasVisible && !op->inDestructor)
+             emit oldParentItem->visibleChildrenChanged();
+-        }
+     } else if (d->window) {
+         QQuickWindowPrivate::get(d->window)->parentlessItems.remove(this);
+     }
+@@ -2768,8 +2773,9 @@ void QQuickItem::setParentItem(QQuickItem *parentItem)
+ 
+     d->itemChange(ItemParentHasChanged, d->parentItem);
+ 
+-    emit parentChanged(d->parentItem);
+-    if (isVisible() && d->parentItem)
++    if (!d->inDestructor)
++        emit parentChanged(d->parentItem);
++    if (isVisible() && d->parentItem && !QQuickItemPrivate::get(d->parentItem)->inDestructor)
+         emit d->parentItem->visibleChildrenChanged();
+ }
+ 
+@@ -2965,7 +2971,8 @@ void QQuickItemPrivate::removeChild(QQuickItem *child)
+ 
+     itemChange(QQuickItem::ItemChildRemovedChange, child);
+ 
+-    emit q->childrenChanged();
++    if (!inDestructor)
++        emit q->childrenChanged();
+ }
+ 
+ void QQuickItemPrivate::refWindow(QQuickWindow *c)
+@@ -3194,6 +3201,7 @@ QQuickItemPrivate::QQuickItemPrivate()
+     , touchEnabled(false)
+ #endif
+     , hasCursorHandler(false)
++    , inDestructor(false)
+     , dirtyAttributes(0)
+     , nextDirtyItem(nullptr)
+     , prevDirtyItem(nullptr)
+@@ -5120,6 +5128,13 @@ void QQuickItem::componentComplete()
+         d->addToDirtyList();
+         QQuickWindowPrivate::get(d->window)->dirtyItem(this);
+     }
++
++#if QT_CONFIG(accessibility)
++    if (d->isAccessible && d->effectiveVisible) {
++        QAccessibleEvent ev(this, QAccessible::ObjectShow);
++        QAccessible::updateAccessibility(&ev);
++    }
++#endif
+ }
+ 
+ QQuickStateGroup *QQuickItemPrivate::_states()
+@@ -6106,9 +6121,11 @@ bool QQuickItemPrivate::setEffectiveVisibleRecur(bool newEffectiveVisible)
+         QAccessible::updateAccessibility(&ev);
+     }
+ #endif
+-    emit q->visibleChanged();
+-    if (childVisibilityChanged)
+-        emit q->visibleChildrenChanged();
++    if (!inDestructor) {
++        emit q->visibleChanged();
++        if (childVisibilityChanged)
++            emit q->visibleChildrenChanged();
++    }
+ 
+     return true;    // effective visibility DID change
+ }
+@@ -6157,6 +6174,15 @@ void QQuickItemPrivate::setEffectiveEnableRecur(QQuickItem *scope, bool newEffec
+     }
+ 
+     itemChange(QQuickItem::ItemEnabledHasChanged, effectiveEnable);
++#if QT_CONFIG(accessibility)
++    if (isAccessible) {
++        QAccessible::State changedState;
++        changedState.disabled = true;
++        changedState.focusable = true;
++        QAccessibleStateChangeEvent ev(q, changedState);
++        QAccessible::updateAccessibility(&ev);
++    }
++#endif
+     emit q->enabledChanged();
+ }
+ 
+diff --git a/qtdeclarative/src/quick/items/qquickitem_p.h b/qtdeclarative/src/quick/items/qquickitem_p.h
+index 841d91bb40..ade8fb61f2 100644
+--- a/qtdeclarative/src/quick/items/qquickitem_p.h
++++ b/qtdeclarative/src/quick/items/qquickitem_p.h
+@@ -472,6 +472,7 @@ public:
+     bool replayingPressEvent:1;
+     bool touchEnabled:1;
+     bool hasCursorHandler:1;
++    quint32 inDestructor:1; // has entered ~QQuickItem
+ 
+     enum DirtyType {
+         TransformOrigin         = 0x00000001,
+diff --git a/qtdeclarative/src/quick/items/qquickitemview.cpp b/qtdeclarative/src/quick/items/qquickitemview.cpp
+index 010a0152e1..f8ad168a17 100644
+--- a/qtdeclarative/src/quick/items/qquickitemview.cpp
++++ b/qtdeclarative/src/quick/items/qquickitemview.cpp
+@@ -1785,7 +1785,7 @@ void QQuickItemViewPrivate::refill(qreal from, qreal to)
+ 
+     do {
+         bufferPause.stop();
+-        if (currentChanges.hasPendingChanges() || bufferedChanges.hasPendingChanges()) {
++        if (currentChanges.hasPendingChanges() || bufferedChanges.hasPendingChanges() || currentChanges.active) {
+             currentChanges.reset();
+             bufferedChanges.reset();
+             releaseVisibleItems(reusableFlag);
+diff --git a/qtdeclarative/src/quick/items/qquickmousearea_p_p.h b/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
+index fba383e268..0d63618622 100644
+--- a/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
++++ b/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
+@@ -61,7 +61,6 @@ QT_BEGIN_NAMESPACE
+ 
+ class QQuickMouseEvent;
+ class QQuickMouseArea;
+-class QQuickPointerMask;
+ class QQuickMouseAreaPrivate : public QQuickItemPrivate
+ {
+     Q_DECLARE_PUBLIC(QQuickMouseArea)
+@@ -100,7 +99,6 @@ public:
+ #if QT_CONFIG(quick_draganddrop)
+     QQuickDrag *drag;
+ #endif
+-    QPointer<QQuickPointerMask> mask;
+     QPointF startScene;
+     QPointF targetStartPos;
+     QPointF lastPos;
+diff --git a/qtdeclarative/src/quick/items/qquicktext.cpp b/qtdeclarative/src/quick/items/qquicktext.cpp
+index 6230186933..e823ca1095 100644
+--- a/qtdeclarative/src/quick/items/qquicktext.cpp
++++ b/qtdeclarative/src/quick/items/qquicktext.cpp
+@@ -2168,7 +2168,7 @@ void QQuickText::resetMaximumLineCount()
+     <img src="" align="top,middle,bottom" width="" height=""> - inline images
+     <ol type="">, <ul type=""> and <li> - ordered and unordered lists
+     <pre></pre> - preformatted
+-    &gt; &lt; &amp;
++    &gt; &lt; &amp; &quot; &nbsp; &apos;
+     \endcode
+ 
+     \c Text.StyledText parser is strict, requiring tags to be correctly nested.
+diff --git a/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp b/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
+index eb4db0f85e..2325a2665b 100644
+--- a/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
++++ b/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
+@@ -446,7 +446,7 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+         const char *textureRecord = allocatorData;
+         for (int i = 0; i < textureCount; ++i, textureRecord += Qtdf::TextureRecordSize) {
+-            if (textureRecord + Qtdf::TextureRecordSize > qtdfTableEnd) {
++            if (qtdfTableEnd - textureRecord < Qtdf::TextureRecordSize) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+@@ -462,7 +462,7 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+         const char *glyphRecord = textureRecord;
+         for (quint32 i = 0; i < glyphCount; ++i, glyphRecord += Qtdf::GlyphRecordSize) {
+-            if (glyphRecord + Qtdf::GlyphRecordSize > qtdfTableEnd) {
++            if (qtdfTableEnd - glyphRecord < Qtdf:: GlyphRecordSize) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+@@ -512,8 +512,8 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+             int width = texInfo->allocatedArea.width();
+             int height = texInfo->allocatedArea.height();
+-            qint64 size = width * height;
+-            if (reinterpret_cast<const char *>(textureData + size) > qtdfTableEnd) {
++            qint64 size = qint64(width) * height;
++            if (qtdfTableEnd - reinterpret_cast<const char *>(textureData) < size) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+diff --git a/qtdeclarative/src/quick/util/qquickstyledtext.cpp b/qtdeclarative/src/quick/util/qquickstyledtext.cpp
+index d531fc9205..a25af90414 100644
+--- a/qtdeclarative/src/quick/util/qquickstyledtext.cpp
++++ b/qtdeclarative/src/quick/util/qquickstyledtext.cpp
+@@ -564,6 +564,8 @@ void QQuickStyledTextPrivate::parseEntity(const QChar *&ch, const QString &textI
+                 textOut += QChar(60);
+             else if (entity == QLatin1String("amp"))
+                 textOut += QChar(38);
++            else if (entity == QLatin1String("apos"))
++                textOut += QChar(39);
+             else if (entity == QLatin1String("quot"))
+                 textOut += QChar(34);
+             else if (entity == QLatin1String("nbsp"))
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp
+new file mode 100644
+index 0000000000..8a1c901880
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp
+@@ -0,0 +1,110 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include "qaccessiblequickwidget_p.h"
++
++#include "qquickwidget_p.h"
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleQuickWidget::QAccessibleQuickWidget(QQuickWidget* widget)
++: QAccessibleWidget(widget)
++, m_accessibleWindow(QQuickWidgetPrivate::get(widget)->offscreenWindow)
++{
++    // NOTE: m_accessibleWindow is a QAccessibleQuickWindow, and not a
++    // QAccessibleQuickWidgetOffscreenWindow (defined below). This means
++    // it will return the Quick item child interfaces, which is what's needed here
++    // (unlike QAccessibleQuickWidgetOffscreenWindow, which will report 0 children).
++}
++
++QAccessibleInterface *QAccessibleQuickWidget::child(int index) const
++{
++    return m_accessibleWindow.child(index);
++}
++
++int QAccessibleQuickWidget::childCount() const
++{
++    return m_accessibleWindow.childCount();
++}
++
++int QAccessibleQuickWidget::indexOfChild(const QAccessibleInterface *iface) const
++{
++    return m_accessibleWindow.indexOfChild(iface);
++}
++
++QAccessibleInterface *QAccessibleQuickWidget::childAt(int x, int y) const
++{
++    return m_accessibleWindow.childAt(x, y);
++}
++
++QAccessibleQuickWidgetOffscreenWindow::QAccessibleQuickWidgetOffscreenWindow(QQuickWindow *window)
++:QAccessibleQuickWindow(window)
++{
++
++}
++
++QAccessibleInterface *QAccessibleQuickWidgetOffscreenWindow::child(int index) const
++{
++    Q_UNUSED(index);
++    return nullptr;
++}
++
++int QAccessibleQuickWidgetOffscreenWindow::childCount() const
++{
++    return 0;
++}
++
++int QAccessibleQuickWidgetOffscreenWindow::indexOfChild(const QAccessibleInterface *iface) const
++{
++    Q_UNUSED(iface);
++    return -1;
++}
++
++QAccessibleInterface *QAccessibleQuickWidgetOffscreenWindow::QAccessibleQuickWidgetOffscreenWindow::childAt(int x, int y) const
++{
++    Q_UNUSED(x);
++    Q_UNUSED(y);
++    return nullptr;
++}
++
++#endif // accessibility
++
++QT_END_NAMESPACE
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h
+new file mode 100644
+index 0000000000..7c2ab930e0
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h
+@@ -0,0 +1,95 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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 QACCESSIBLEQUICKWIDGET_H
++#define QACCESSIBLEQUICKWIDGET_H
++
++//
++//  W A R N I N G
++//  -------------
++//
++// This file is not part of the Qt API.  It exists purely as an
++// implementation detail.  This header file may change from version to
++// version without notice, or even be removed.
++//
++// We mean it.
++//
++
++#include "qquickwidget.h"
++#include <QtWidgets/qaccessiblewidget.h>
++
++#include <private/qaccessiblequickview_p.h>
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++// These classes implement the QQuickWiget accessibility switcharoo,
++// where the child items of the QQuickWidgetOffscreenWindow are reported
++// as child accessible interfaces of the QAccessibleQuickWidget.
++class QAccessibleQuickWidget: public QAccessibleWidget
++{
++public:
++    QAccessibleQuickWidget(QQuickWidget* widget);
++
++    QAccessibleInterface *child(int index) const override;
++    int childCount() const override;
++    int indexOfChild(const QAccessibleInterface *iface) const override;
++    QAccessibleInterface *childAt(int x, int y) const override;
++
++private:
++    QAccessibleQuickWindow m_accessibleWindow;
++    Q_DISABLE_COPY(QAccessibleQuickWidget)
++};
++
++class QAccessibleQuickWidgetOffscreenWindow: public QAccessibleQuickWindow
++{
++public:
++    QAccessibleQuickWidgetOffscreenWindow(QQuickWindow *window);
++    QAccessibleInterface *child(int index) const override;
++    int childCount() const override;
++    int indexOfChild(const QAccessibleInterface *iface) const override;
++    QAccessibleInterface *childAt(int x, int y) const override;
++};
++
++#endif // accessibility
++
++QT_END_NAMESPACE
++
++#endif
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp
+new file mode 100644
+index 0000000000..7ba88a1769
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp
+@@ -0,0 +1,60 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include "qaccessiblequickwidgetfactory_p.h"
++#include "qaccessiblequickwidget_p.h"
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleInterface *qAccessibleQuickWidgetFactory(const QString &classname, QObject *object)
++{
++    if (classname == QLatin1String("QQuickWidget")) {
++        return new QAccessibleQuickWidget(qobject_cast<QQuickWidget *>(object));
++    } else if (classname == QLatin1String("QQuickWidgetOffscreenWindow")) {
++        return new QAccessibleQuickWidgetOffscreenWindow(qobject_cast<QQuickWindow *>(object));
++    }
++    return 0;
++}
++
++#endif // accessibility
++
++QT_END_NAMESPACE
++
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h
+new file mode 100644
+index 0000000000..8c63b09f81
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h
+@@ -0,0 +1,66 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include <QtGui/qaccessible.h>
++
++#ifndef QACCESSIBLEQUICKWIDGETFACTORY_H
++#define QACCESSIBLEQUICKWIDGETFACTORY_H
++
++//
++//  W A R N I N G
++//  -------------
++//
++// This file is not part of the Qt API.  It exists purely as an
++// implementation detail.  This header file may change from version to
++// version without notice, or even be removed.
++//
++// We mean it.
++//
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleInterface *qAccessibleQuickWidgetFactory(const QString &classname, QObject *object);
++
++#endif
++
++QT_END_NAMESPACE
++
++#endif
+diff --git a/qtdeclarative/src/quickwidgets/qquickwidget.cpp b/qtdeclarative/src/quickwidgets/qquickwidget.cpp
+index 39780f8de3..9c97b43518 100644
+--- a/qtdeclarative/src/quickwidgets/qquickwidget.cpp
++++ b/qtdeclarative/src/quickwidgets/qquickwidget.cpp
+@@ -39,6 +39,7 @@
+ 
+ #include "qquickwidget.h"
+ #include "qquickwidget_p.h"
++#include "qaccessiblequickwidgetfactory_p.h"
+ 
+ #include "private/qquickwindow_p.h"
+ #include "private/qquickitem_p.h"
+@@ -75,9 +76,16 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++QQuickWidgetOffscreenWindow::QQuickWidgetOffscreenWindow(QQuickWindowPrivate &dd, QQuickRenderControl *control)
++:QQuickWindow(dd, control)
++{
++    setTitle(QString::fromLatin1("Offscreen"));
++    setObjectName(QString::fromLatin1("QQuickOffScreenWindow"));
++}
++
+ // override setVisble to prevent accidental offscreen window being created
+ // by base class.
+-class QQuickOffcreenWindowPrivate: public QQuickWindowPrivate {
++class QQuickWidgetOffscreenWindowPrivate: public QQuickWindowPrivate {
+ public:
+     void setVisible(bool visible) override {
+         Q_Q(QWindow);
+@@ -105,9 +113,8 @@ void QQuickWidgetPrivate::init(QQmlEngine* e)
+     Q_Q(QQuickWidget);
+ 
+     renderControl = new QQuickWidgetRenderControl(q);
+-    offscreenWindow = new QQuickWindow(*new QQuickOffcreenWindowPrivate(),renderControl);
+-    offscreenWindow->setTitle(QString::fromLatin1("Offscreen"));
+-    offscreenWindow->setObjectName(QString::fromLatin1("QQuickOffScreenWindow"));
++    offscreenWindow = new QQuickWidgetOffscreenWindow(*new QQuickWidgetOffscreenWindowPrivate(), renderControl);
++    offscreenWindow->setScreen(q->screen());
+     // Do not call create() on offscreenWindow.
+ 
+     // Check if the Software Adaptation is being used
+@@ -138,6 +145,10 @@ void QQuickWidgetPrivate::init(QQmlEngine* e)
+     QWidget::connect(offscreenWindow, &QQuickWindow::focusObjectChanged, q, &QQuickWidget::propagateFocusObjectChanged);
+     QObject::connect(renderControl, SIGNAL(renderRequested()), q, SLOT(triggerUpdate()));
+     QObject::connect(renderControl, SIGNAL(sceneChanged()), q, SLOT(triggerUpdate()));
++
++#if QT_CONFIG(accessibility)
++    QAccessible::installFactory(&qAccessibleQuickWidgetFactory);
++#endif
+ }
+ 
+ void QQuickWidgetPrivate::ensureEngine() const
+@@ -901,9 +912,7 @@ void QQuickWidgetPrivate::createContext()
+ 
+         context = new QOpenGLContext;
+         context->setFormat(offscreenWindow->requestedFormat());
+-        const QWindow *win = q->window()->windowHandle();
+-        if (win && win->screen())
+-            context->setScreen(win->screen());
++        context->setScreen(q->screen());
+         QOpenGLContext *shareContext = qt_gl_global_share_context();
+         if (!shareContext)
+             shareContext = QWidgetPrivate::get(q->window())->shareContext();
+@@ -1520,19 +1529,16 @@ bool QQuickWidget::event(QEvent *e)
+         d->handleWindowChange();
+         break;
+ 
+-    case QEvent::ScreenChangeInternal:
+-        if (QWindow *window = this->window()->windowHandle()) {
+-            QScreen *newScreen = window->screen();
+-
+-            if (d->offscreenWindow)
+-                d->offscreenWindow->setScreen(newScreen);
+-            if (d->offscreenSurface)
+-                d->offscreenSurface->setScreen(newScreen);
++    case QEvent::ScreenChangeInternal: {
++        QScreen *newScreen = screen();
++        if (d->offscreenWindow)
++            d->offscreenWindow->setScreen(newScreen);
++        if (d->offscreenSurface)
++            d->offscreenSurface->setScreen(newScreen);
+ #if QT_CONFIG(opengl)
+-            if (d->context)
+-                d->context->setScreen(newScreen);
++        if (d->context)
++            d->context->setScreen(newScreen);
+ #endif
+-        }
+ 
+         if (d->useSoftwareRenderer
+ #if QT_CONFIG(opengl)
+@@ -1545,7 +1551,7 @@ bool QQuickWidget::event(QEvent *e)
+             d->render(true);
+         }
+         break;
+-
++    }
+     case QEvent::Show:
+     case QEvent::Move:
+         d->updatePosition();
+diff --git a/qtdeclarative/src/quickwidgets/qquickwidget_p.h b/qtdeclarative/src/quickwidgets/qquickwidget_p.h
+index 881f7f9220..1a946bcc71 100644
+--- a/qtdeclarative/src/quickwidgets/qquickwidget_p.h
++++ b/qtdeclarative/src/quickwidgets/qquickwidget_p.h
+@@ -148,6 +148,14 @@ public:
+     bool forceFullUpdate;
+ };
+ 
++class QQuickWidgetOffscreenWindow: public QQuickWindow
++{
++    Q_OBJECT
++
++public:
++    QQuickWidgetOffscreenWindow(QQuickWindowPrivate &dd, QQuickRenderControl *control);
++};
++
+ QT_END_NAMESPACE
+ 
+ #endif // QQuickWidget_P_H
+diff --git a/qtdeclarative/src/quickwidgets/quickwidgets.pro b/qtdeclarative/src/quickwidgets/quickwidgets.pro
+index 2438e577ae..85d156b8a3 100644
+--- a/qtdeclarative/src/quickwidgets/quickwidgets.pro
++++ b/qtdeclarative/src/quickwidgets/quickwidgets.pro
+@@ -7,9 +7,13 @@ DEFINES   += QT_NO_URL_CAST_FROM_STRING QT_NO_INTEGER_EVENT_COORDINATES QT_NO_FO
+ HEADERS += \
+     qquickwidget.h \
+     qquickwidget_p.h \
+-    qtquickwidgetsglobal.h
++    qtquickwidgetsglobal.h \
++    qaccessiblequickwidget_p.h \
++    qaccessiblequickwidgetfactory_p.h
+ 
+ SOURCES += \
+-    qquickwidget.cpp
++    qquickwidget.cpp \
++    qaccessiblequickwidget.cpp \
++    qaccessiblequickwidgetfactory.cpp
+ 
+ load(qt_module)
+diff --git a/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+index 3b7d74df63..b75bf820d5 100644
+--- a/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
++++ b/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+@@ -102,6 +102,7 @@ private slots:
+     void valueConversion_RegularExpression();
+     void castWithMultipleInheritance();
+     void collectGarbage();
++    void collectGarbageNestedWrappersTwoEngines();
+     void gcWithNestedDataStructure();
+     void stacktrace();
+     void numberParsing_data();
+@@ -1809,6 +1810,44 @@ void tst_QJSEngine::collectGarbage()
+     QVERIFY(ptr.isNull());
+ }
+ 
++class TestObjectContainer : public QObject
++{
++    Q_OBJECT
++    Q_PROPERTY(QObject *dummy MEMBER m_dummy CONSTANT)
++
++public:
++    TestObjectContainer() : m_dummy(new QObject(this)) {}
++
++private:
++    QObject *m_dummy;
++};
++
++void tst_QJSEngine::collectGarbageNestedWrappersTwoEngines()
++{
++    QJSEngine engine1;
++    QJSEngine engine2;
++
++    TestObjectContainer container;
++    QQmlEngine::setObjectOwnership(&container, QQmlEngine::CppOwnership);
++
++    engine1.globalObject().setProperty("foobar", engine1.newQObject(&container));
++    engine2.globalObject().setProperty("foobar", engine2.newQObject(&container));
++
++    engine1.evaluate("foobar.dummy.baz = 42");
++    engine2.evaluate("foobar.dummy.baz = 43");
++
++    QCOMPARE(engine1.evaluate("foobar.dummy.baz").toInt(), 42);
++    QCOMPARE(engine2.evaluate("foobar.dummy.baz").toInt(), 43);
++
++    engine1.collectGarbage();
++    engine2.collectGarbage();
++
++    // The GC should not collect dummy object wrappers neither in engine1 nor engine2, we
++    // verify that by checking whether the baz property still has its previous value.
++    QCOMPARE(engine1.evaluate("foobar.dummy.baz").toInt(), 42);
++    QCOMPARE(engine2.evaluate("foobar.dummy.baz").toInt(), 43);
++}
++
+ void tst_QJSEngine::gcWithNestedDataStructure()
+ {
+     // The GC must be able to traverse deeply nested objects, otherwise this
+diff --git a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml
+new file mode 100644
+index 0000000000..206133bb39
+--- /dev/null
++++ b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml
+@@ -0,0 +1,11 @@
++import QtQuick 2.8
++
++ListView {
++    id: root
++    width: 200
++    height: 200
++
++    delegate: Text {
++        text: display
++    }
++}
+diff --git a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
+index 35f1e2c94d..1722447830 100644
+--- a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
++++ b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
+@@ -27,6 +27,8 @@
+ ****************************************************************************/
+ 
+ #include <QtTest/qtest.h>
++#include <QtCore/QConcatenateTablesProxyModel>
++#include <QtGui/QStandardItemModel>
+ #include <QtQml/qqmlcomponent.h>
+ #include <QtQmlModels/private/qqmldelegatemodel_p.h>
+ #include <QtQuick/qquickview.h>
+@@ -47,6 +49,7 @@ private slots:
+     void filterOnGroup_removeWhenCompleted();
+     void qtbug_86017();
+     void contextAccessedByHandler();
++    void redrawUponColumnChange();
+ };
+ 
+ class AbstractItemModel : public QAbstractItemModel
+@@ -186,6 +189,30 @@ void tst_QQmlDelegateModel::contextAccessedByHandler()
+     QVERIFY(root->property("works").toBool());
+ }
+ 
++void tst_QQmlDelegateModel::redrawUponColumnChange()
++{
++    QStandardItemModel m1;
++    m1.appendRow({
++            new QStandardItem("Banana"),
++            new QStandardItem("Coconut"),
++    });
++
++    QQuickView view(testFileUrl("redrawUponColumnChange.qml"));
++    QCOMPARE(view.status(), QQuickView::Ready);
++    view.show();
++    QQuickItem *root = view.rootObject();
++    root->setProperty("model", QVariant::fromValue<QObject *>(&m1));
++
++    QObject *item = root->property("currentItem").value<QObject *>();
++    QVERIFY(item);
++    QCOMPARE(item->property("text").toString(), "Banana");
++
++    QVERIFY(root);
++    m1.removeColumn(0);
++
++    QCOMPARE(item->property("text").toString(), "Coconut");
++}
++
+ QTEST_MAIN(tst_QQmlDelegateModel)
+ 
+ #include "tst_qqmldelegatemodel.moc"
+diff --git a/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp b/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
+index 5d635aa63b..824fd89e5b 100644
+--- a/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
++++ b/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
+@@ -76,10 +76,10 @@ void tst_qv4mm::multiWrappedQObjects()
+         QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 1);
+         QCOMPARE(engine2.memoryManager->m_pendingFreedObjectWrapperValue.size(), 0);
+ 
+-        // Moves the additional WeakValue from m_multiplyWrappedQObjects to
+-        // m_pendingFreedObjectWrapperValue. It's still alive after all.
++        // The additional WeakValue from m_multiplyWrappedQObjects hasn't been moved
++        // to m_pendingFreedObjectWrapperValue yet. It's still alive after all.
+         engine1.memoryManager->runGC();
+-        QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 2);
++        QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 1);
+ 
+         // engine2 doesn't own the object as engine1 was the first to wrap it above.
+         // Therefore, no effect here.
+diff --git a/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml b/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml
+new file mode 100644
+index 0000000000..889e480f3b
+--- /dev/null
++++ b/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml
+@@ -0,0 +1,13 @@
++import QtQuick 2.6
++
++Item {
++    visible: true
++    Item {
++        visible: false
++        Item {
++            objectName: "hiddenChild"
++            activeFocusOnTab: true
++            focus: true
++        }
++    }
++}
+diff --git a/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp b/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+index c8f251dbe1..c8ef36ee68 100644
+--- a/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
++++ b/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+@@ -67,6 +67,7 @@ private slots:
+     void activeFocusOnTab10();
+     void activeFocusOnTab_infiniteLoop_data();
+     void activeFocusOnTab_infiniteLoop();
++    void activeFocusOnTab_infiniteLoopControls();
+ 
+     void nextItemInFocusChain();
+     void nextItemInFocusChain2();
+@@ -1057,6 +1058,17 @@ void tst_QQuickItem::activeFocusOnTab_infiniteLoop()
+     QCOMPARE(item, window->rootObject());
+ }
+ 
++
++void tst_QQuickItem::activeFocusOnTab_infiniteLoopControls()
++{
++    auto source = testFileUrl("activeFocusOnTab_infiniteLoop3.qml");
++    QScopedPointer<QQuickView>window(new QQuickView());
++    window->setSource(source);
++    window->show();
++    QVERIFY(window->errors().isEmpty());
++    QTest::keyClick(window.get(), Qt::Key_Tab); // should not hang
++}
++
+ void tst_QQuickItem::nextItemInFocusChain()
+ {
+     if (!qt_tab_all_widgets())
+Submodule qtdoc c0c7bf07...79d6ef69:
+Submodule qtimageformats 2dcf2899..abe44c0f:
+diff --git a/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp b/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
+index dde783c..1bf9074 100644
+--- a/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
+@@ -462,8 +462,12 @@ static bool parseIconEntryInfo(ICNSEntry &icon)
+     if (isIconCompressed(icon))
+         return true;
+     // Icon depth:
+-    if (!depth.isEmpty())
+-        icon.depth = ICNSEntry::Depth(depth.toUInt());
++    if (!depth.isEmpty()) {
++        const uint depthUInt = depth.toUInt();
++        if (depthUInt > 32)
++            return false;
++        icon.depth = ICNSEntry::Depth(depthUInt);
++    }
+     // Try mono if depth not found
+     if (icon.depth == ICNSEntry::DepthUnknown)
+         icon.depth = ICNSEntry::DepthMono;
+@@ -515,6 +519,9 @@ static bool parseIconEntryInfo(ICNSEntry &icon)
+         }
+         icon.height = icon.width;
+     }
++    // Sanity check
++    if (icon.width == 0 || icon.width > 4096)
++        return false;
+     return true;
+ }
+ 
+@@ -685,7 +692,7 @@ bool QICNSHandler::canRead() const
+ bool QICNSHandler::read(QImage *outImage)
+ {
+     QImage img;
+-    if (!ensureScanned()) {
++    if (!ensureScanned() || m_currentIconIndex >= m_icons.size()) {
+         qWarning("QICNSHandler::read(): The device wasn't parsed properly!");
+         return false;
+     }
+@@ -892,7 +899,7 @@ bool QICNSHandler::scanDevice()
+             return false;
+ 
+         const qint64 blockDataOffset = device()->pos();
+-        if (!isBlockHeaderValid(blockHeader)) {
++        if (!isBlockHeaderValid(blockHeader, ICNSBlockHeaderSize + filelength - blockDataOffset)) {
+             qWarning("QICNSHandler::scanDevice(): Failed, bad header at pos %s. OSType \"%s\", length %u",
+                      QByteArray::number(blockDataOffset).constData(),
+                      nameFromOSType(blockHeader.ostype).constData(), blockHeader.length);
+@@ -927,11 +934,14 @@ bool QICNSHandler::scanDevice()
+         case ICNSBlockHeader::TypeOdrp:
+             // Icns container seems to have an embedded icon variant container
+             // Let's start a scan for entries
+-            while (device()->pos() < nextBlockOffset) {
++            while (!stream.atEnd() && device()->pos() < nextBlockOffset) {
+                 ICNSBlockHeader icon;
+                 stream >> icon;
++                if (stream.status() != QDataStream::Ok)
++                    return false;
+                 // Check for incorrect variant entry header and stop scan
+-                if (!isBlockHeaderValid(icon, blockDataLength))
++                quint64 remaining = blockDataLength - (device()->pos() - blockDataOffset);
++                if (!isBlockHeaderValid(icon, ICNSBlockHeaderSize + remaining))
+                     break;
+                 if (!addEntry(icon, device()->pos(), blockHeader.ostype))
+                     return false;
+@@ -1003,7 +1013,7 @@ bool QICNSHandler::scanDevice()
+             break;
+         }
+     }
+-    return true;
++    return (m_icons.size() > 0);
+ }
+ 
+ const ICNSEntry &QICNSHandler::getIconMask(const ICNSEntry &icon) const
+diff --git a/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp b/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
+index 5082023..cb34374 100644
+--- a/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
++++ b/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
+@@ -43,6 +43,7 @@
+ #include "qimage.h"
+ #include "qvariant.h"
+ #include "qcolor.h"
++#include "qimagereader.h"
+ 
+ #include <jasper/jasper.h>
+ #include <math.h> // for pow
+@@ -333,16 +334,46 @@ private:
+ Jpeg2000JasperReader::Jpeg2000JasperReader(QIODevice *iod, SubFormat format)
+     : jasperOk(true), ioDevice(iod), format(format), hasAlpha(false)
+ {
++#if JAS_VERSION_MAJOR < 3
+     if (jas_init()) {
+         jasperOk = false;
+         qDebug("Jasper Library initialization failed");
+     }
++#else
++    jas_conf_clear();
++#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
++    jas_conf_set_max_mem_usage(QImageReader::allocationLimit() * 1024 * 1024);
++#else
++    // 128MB seems to be enough.
++    jas_conf_set_max_mem_usage(128 * 1024 * 1024);
++#endif
++    if (jas_init_library()) {
++        jasperOk = false;
++        qDebug("Jasper library initialization failed");
++    }
++    if (jas_init_thread()) {
++        jas_cleanup_library();
++        jasperOk = false;
++        qDebug("Jasper thread initialization failed");
++    }
++#endif
+ }
+ 
+ Jpeg2000JasperReader::~Jpeg2000JasperReader()
+ {
++#if JAS_VERSION_MAJOR < 3
+     if (jasperOk)
+         jas_cleanup();
++#else
++    if (jasperOk) {
++        if (jas_cleanup_thread()) {
++            qDebug("Jasper thread cleanup failed");
++        }
++        if (jas_cleanup_library()) {
++            qDebug("Jasper library cleanup failed");
++        }
++    }
++#endif
+ }
+ 
+ /*! \internal
+@@ -857,7 +888,7 @@ bool Jpeg2000JasperReader::write(const QImage &image, int quality)
+     }
+ 
+     // Open an empty jasper stream that grows automatically
+-    jas_stream_t * memory_stream = jas_stream_memopen(0, -1);
++    jas_stream_t * memory_stream = jas_stream_memopen(0, 0);
+ 
+     // Jasper wants a non-const string.
+     char *str = qstrdup(jasperFormatString.toLatin1().constData());
+diff --git a/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp b/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
+index 1386750..ac8956c 100644
+--- a/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
+@@ -361,6 +361,8 @@ bool QTiffHandler::read(QImage *image)
+     }
+ 
+     TIFF *const tiff = d->tiff;
++    if (TIFFIsTiled(tiff) && TIFFTileSize64(tiff) > uint64_t(image->sizeInBytes())) // Corrupt image
++        return false;
+     const quint32 width = d->size.width();
+     const quint32 height = d->size.height();
+ 
+diff --git a/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp b/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
+index 82d38cb..d02eb05 100644
+--- a/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
+@@ -45,6 +45,7 @@
+ #include <qdebug.h>
+ #include <qpainter.h>
+ #include <qvariant.h>
++#include <QtEndian>
+ 
+ static const int riffHeaderSize = 12; // RIFF_HEADER_SIZE from webp/format_constants.h
+ 
+@@ -102,21 +103,23 @@ bool QWebpHandler::ensureScanned() const
+ 
+     m_scanState = ScanError;
+ 
+-    if (device()->isSequential()) {
+-        qWarning() << "Sequential devices are not supported";
++    QWebpHandler *that = const_cast<QWebpHandler *>(this);
++    const int headerBytesNeeded = sizeof(WebPBitstreamFeatures);
++    QByteArray header = device()->peek(headerBytesNeeded);
++    if (header.size() < headerBytesNeeded)
+         return false;
+-    }
+ 
+-    qint64 oldPos = device()->pos();
+-    device()->seek(0);
+-
+-    QWebpHandler *that = const_cast<QWebpHandler *>(this);
+-    QByteArray header = device()->peek(sizeof(WebPBitstreamFeatures));
++    // We do no random access during decoding, just a readAll() of the whole image file. So if
++    // if it is all available already, we can accept a sequential device. The riff header contains
++    // the file size minus 8 bytes header
++    qint64 byteSize = qFromLittleEndian<quint32>(header.constData() + 4);
++    if (device()->isSequential() && device()->bytesAvailable() < byteSize + 8) {
++        qWarning() << "QWebpHandler: Insufficient data available in sequential device";
++        return false;
++    }
+     if (WebPGetFeatures((const uint8_t*)header.constData(), header.size(), &(that->m_features)) == VP8_STATUS_OK) {
+         if (m_features.has_animation) {
+             // For animation, we have to read and scan whole file to determine loop count and images count
+-            device()->seek(oldPos);
+-
+             if (that->ensureDemuxer()) {
+                 that->m_loop = WebPDemuxGetI(m_demuxer, WEBP_FF_LOOP_COUNT);
+                 that->m_frameCount = WebPDemuxGetI(m_demuxer, WEBP_FF_FRAME_COUNT);
+@@ -126,17 +129,13 @@ bool QWebpHandler::ensureScanned() const
+                 if (that->m_features.has_alpha)
+                     that->m_composited->fill(Qt::transparent);
+ 
+-                // We do not reset device position since we have read in all data
+                 m_scanState = ScanSuccess;
+-                return true;
+             }
+         } else {
+             m_scanState = ScanSuccess;
+         }
+     }
+ 
+-    device()->seek(oldPos);
+-
+     return m_scanState == ScanSuccess;
+ }
+ 
+@@ -159,7 +158,7 @@ bool QWebpHandler::ensureDemuxer()
+ 
+ bool QWebpHandler::read(QImage *image)
+ {
+-    if (!ensureScanned() || device()->isSequential() || !ensureDemuxer())
++    if (!ensureScanned() || !ensureDemuxer())
+         return false;
+ 
+     QRect prevFrameRect;
+Submodule qtlocation 98a5c511..f991e28c:
+diff --git a/qtlocation/src/location/configure.json b/qtlocation/src/location/configure.json
+index 6d01a9a3..d1e623a1 100644
+--- a/qtlocation/src/location/configure.json
++++ b/qtlocation/src/location/configure.json
+@@ -9,7 +9,7 @@
+             "label": "Qt.labs.location experimental QML plugin",
+             "purpose": "Provides experimental QtLocation QML types",
+             "section": "Location",
+-            "condition": "config.opengl",
++            "condition": "features.opengl",
+             "output": [ "privateFeature" ]
+         },
+         "geoservices_osm": {
+diff --git a/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp b/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
+index a978573d..11e1466f 100644
+--- a/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
++++ b/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
+@@ -158,7 +158,7 @@ void QGeoMapObjectQSGSupport::updateMapObjects(QSGNode *root, QQuickWindow *wind
+     if (!root)
+         return;
+ 
+-    if (m_mapObjectsRootNode && m_mapObjectsRootNode->parent())
++    if (m_mapObjectsRootNode && !m_mapObjectsRootNode->parent())
+         root->appendChildNode(m_mapObjectsRootNode.get());
+ 
+     if (!m_mapObjectsRootNode) {
+diff --git a/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
+index 5a40467e..d123c6a8 100644
+--- a/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
+@@ -59,8 +59,10 @@ QT_BEGIN_NAMESPACE
+ static const QString kPrefixEsri(QStringLiteral("esri."));
+ static const QString kParamUserAgent(kPrefixEsri + QStringLiteral("useragent"));
+ 
+-static const QString kUrlGeocode(QStringLiteral("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates"));
+-static const QString kUrlReverseGeocode(QStringLiteral("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode"));
++static const QString kUrlGeocode(QStringLiteral("https://geocode.arcgis.com/arcgis/rest/services/"
++                                                "World/GeocodeServer/findAddressCandidates"));
++static const QString kUrlReverseGeocode(QStringLiteral(
++        "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode"));
+ 
+ static QString addressToQuery(const QGeoAddress &address)
+ {
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
+index 17492d94..96c12b1b 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
+@@ -46,7 +46,8 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-// JSON reference: http://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
++// JSON reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
+ 
+ static const QString kErrorMessage(QStringLiteral("Error %1: %2."));
+ static const QString kErrorJson(QStringLiteral("Error: invalide JSON document."));
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
+index 8cadfb29..92b6bb13 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
+@@ -44,7 +44,8 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-// JSON reference: http://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
++// JSON reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
+ 
+ GeoRouteReplyEsri::GeoRouteReplyEsri(QNetworkReply *reply, const QGeoRouteRequest &request,
+                                      QObject *parent) :
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
+index 0e6bc2c7..ed613f4b 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
+@@ -48,7 +48,8 @@ static const QString kPrefixEsri(QStringLiteral("esri."));
+ static const QString kParamUserAgent(kPrefixEsri + QStringLiteral("useragent"));
+ static const QString kParamToken(kPrefixEsri + QStringLiteral("token"));
+ 
+-static const QString kUrlRouting(QStringLiteral("http://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve"));
++static const QString kUrlRouting(QStringLiteral(
++        "https://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve"));
+ 
+ GeoRoutingManagerEngineEsri::GeoRoutingManagerEngineEsri(const QVariantMap &parameters,
+                                                          QGeoServiceProvider::Error *error,
+@@ -70,7 +71,8 @@ GeoRoutingManagerEngineEsri::~GeoRoutingManagerEngineEsri()
+ {
+ }
+ 
+-// REST reference: http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
++// REST reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
+ 
+ QGeoRouteReply *GeoRoutingManagerEngineEsri::calculateRoute(const QGeoRouteRequest &request)
+ {
+@@ -125,7 +127,7 @@ void GeoRoutingManagerEngineEsri::replyError(QGeoRouteReply::Error errorCode, co
+ QString GeoRoutingManagerEngineEsri::preferedDirectionLangage()
+ {
+     // list of supported langages is defined in:
+-    // http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
++    // https://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
+     const QStringList supportedLanguages = {
+         "ar", // Generate directions in Arabic
+         "cs", // Generate directions in Czech
+diff --git a/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
+index 5d15835d..24148f95 100644
+--- a/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
+@@ -230,7 +230,8 @@ QGeoMap *GeoTiledMappingManagerEngineEsri::createMap()
+ // ${y} = Y
+ // ${token} = Token
+ 
+-// template = 'http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{{z}}/{{y}}/{{x}}.png'
++// template =
++// 'https://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{{z}}/{{y}}/{{x}}.png'
+ 
+ bool GeoTiledMappingManagerEngineEsri::initializeMapSources(QGeoServiceProvider::Error *error,
+                                                             QString *errorString,
+diff --git a/qtlocation/src/plugins/geoservices/esri/maps.json b/qtlocation/src/plugins/geoservices/esri/maps.json
+index 8167ae7d..862e087d 100644
+--- a/qtlocation/src/plugins/geoservices/esri/maps.json
++++ b/qtlocation/src/plugins/geoservices/esri/maps.json
+@@ -6,8 +6,8 @@
+             "description": "ArcGIS Online World Street Map",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=3b93337983e9436f8db950e38a8629af'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=3b93337983e9436f8db950e38a8629af'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -16,8 +16,8 @@
+             "": "ArcGIS Online World Imagery",
+             "mobile": true,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -26,8 +26,8 @@
+             "description": "ArcGIS Online World Terrain Base",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=c61ad8ab017d49e1a82f580ee1298931'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=c61ad8ab017d49e1a82f580ee1298931'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -36,8 +36,8 @@
+             "description": "ArcGIS Online World Topography",
+             "mobile": true,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=30e5fe3149c34df1ba922e6f5bbf808f'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=30e5fe3149c34df1ba922e6f5bbf808f'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -46,8 +46,8 @@
+             "description": "This map presents land cover and detailed topographic maps for the United States.",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=99cd5fbd98934028802b4f797c4b1732'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=99cd5fbd98934028802b4f797c4b1732'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -56,8 +56,8 @@
+             "description": "National Geographic World Map",
+             "mobile": false,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=b9b1b422198944fbbd5250b3241691b6'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=b9b1b422198944fbbd5250b3241691b6'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -66,8 +66,8 @@
+             "description": "Thematic content providing a neutral background with minimal colors",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=ed712cb1db3e4bae9e85329040fb9a49'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=ed712cb1db3e4bae9e85329040fb9a49'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -76,8 +76,8 @@
+             "description": "Natural Earth physical map for the world",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=c4ec722a1cd34cf0a23904aadf8923a0'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=c4ec722a1cd34cf0a23904aadf8923a0'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -86,8 +86,8 @@
+             "description": "Portrays surface elevation as shaded relief",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=9c5370d0b54f4de1b48a3792d7377ff2'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=9c5370d0b54f4de1b48a3792d7377ff2'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -96,8 +96,8 @@
+             "description": "This map is designed to be used as a basemap by marine GIS professionals and as a reference map by anyone interested in ocean data",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=1e126e7520f9466c9ca28b8f28b5e500'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=1e126e7520f9466c9ca28b8f28b5e500'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -106,8 +106,8 @@
+             "description": "Thematic content providing a neutral background with minimal colors",
+             "mobile": false,
+             "night": true,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=a284a9b99b3446a3910d4144a50990f6'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=a284a9b99b3446a3910d4144a50990f6'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -116,8 +116,8 @@
+             "description": "DeLorme’s topographic basemap is a seamless global data set that portrays transportation, hydrography, jurisdiction boundaries, and major geographic features",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/Specialty/DeLorme_World_Base_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=b165c3df453e4be6b5ac4fdb241effbe'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/Specialty/DeLorme_World_Base_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=b165c3df453e4be6b5ac4fdb241effbe'>Esri</a> contributors"
+         }
+     ]
+ }
+diff --git a/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
+index 3858ddf5..af66f28e 100644
+--- a/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
+@@ -63,8 +63,10 @@ static const QString kCountriesKey(QStringLiteral("detailedCountries"));
+ static const QString kLocalizedNamesKey(QStringLiteral("localizedNames"));
+ static const QString kMaxLocationsKey(QStringLiteral("maxLocations"));
+ 
+-static const QUrl kUrlGeocodeServer("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer?f=pjson");
+-static const QUrl kUrlFindAddressCandidates("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates");
++static const QUrl kUrlGeocodeServer(
++        "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer?f=pjson");
++static const QUrl kUrlFindAddressCandidates("https://geocode.arcgis.com/arcgis/rest/services/World/"
++                                            "GeocodeServer/findAddressCandidates");
+ 
+ PlaceManagerEngineEsri::PlaceManagerEngineEsri(const QVariantMap &parameters, QGeoServiceProvider::Error *error,
+                                                QString *errorString) :
+Submodule qtmultimedia f0344079..0d7cc33a:
+diff --git a/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp b/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
+index 2b5325132..b68b4af1b 100644
+--- a/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
++++ b/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
+@@ -402,6 +402,8 @@ int QPulseAudioInput::bytesReady() const
+ 
+ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ {
++    Q_ASSERT(data != nullptr || len == 0);
++
+     m_bytesAvailable = checkBytesReady();
+ 
+     setError(QAudio::NoError);
+@@ -411,7 +413,8 @@ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ 
+     if (!m_pullMode && !m_tempBuffer.isEmpty()) {
+         readBytes = qMin(static_cast<int>(len), m_tempBuffer.size());
+-        memcpy(data, m_tempBuffer.constData(), readBytes);
++        if (readBytes)
++            memcpy(data, m_tempBuffer.constData(), readBytes);
+         m_totalTimeValue += readBytes;
+ 
+         if (readBytes < m_tempBuffer.size()) {
+@@ -502,9 +505,10 @@ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ 
+ void QPulseAudioInput::applyVolume(const void *src, void *dest, int len)
+ {
++    Q_ASSERT((src && dest) || len == 0);
+     if (m_volume < 1.f)
+         QAudioHelperInternal::qMultiplySamples(m_volume, m_format, src, dest, len);
+-    else
++    else if (len)
+         memcpy(dest, src, len);
+ }
+ 
+Submodule qtpim 02efef5e...f9a8f0fc (commits not present)
+Submodule qtquick3d b85cf622..47defc8b:
+diff --git a/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro b/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
+index ca5c499e..174a075b 100644
+--- a/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
++++ b/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
+@@ -10,7 +10,7 @@ QT_FOR_CONFIG += assetimporters-private
+ include($$OUT_PWD/../qtassetimporters-config.pri)
+ 
+ qtConfig(system-assimp):!if(cross_compile:host_build) {
+-    QMAKE_USE_PRIVATE += assimp
++    QMAKE_USE_PRIVATE += quick3d-assimp
+ } else {
+     include(../../../3rdparty/assimp/assimp.pri)
+ }
+Submodule qtquickcontrols2 3a657dc0..56ce8233:
+diff --git a/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp b/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
+index e5fe734f7..e36922775 100644
+--- a/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
++++ b/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
+@@ -38,6 +38,7 @@
+ #include "qwidgetplatformmenuitem_p.h"
+ 
+ #include <QtGui/qwindow.h>
++#include <QtGui/private/qhighdpiscaling_p.h>
+ #include <QtWidgets/qmenu.h>
+ #include <QtWidgets/qaction.h>
+ 
+@@ -145,7 +146,7 @@ void QWidgetPlatformMenu::showPopup(const QWindow *window, const QRect &targetRe
+ 
+     QPoint targetPos = targetRect.bottomLeft();
+     if (window)
+-        targetPos = window->mapToGlobal(targetPos);
++        targetPos = window->mapToGlobal(QHighDpi::fromNativeLocalPosition(targetPos, window));
+ 
+     const QWidgetPlatformMenuItem *widgetItem = qobject_cast<const QWidgetPlatformMenuItem *>(item);
+     m_menu->popup(targetPos, widgetItem ? widgetItem->action() : nullptr);
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
+index 950e4e099..b81fbea0b 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
+@@ -387,6 +387,17 @@ void QQuickAbstractButtonPrivate::itemImplicitHeightChanged(QQuickItem *item)
+         emit q->implicitIndicatorHeightChanged();
+ }
+ 
++void QQuickAbstractButtonPrivate::itemDestroyed(QQuickItem *item)
++{
++    Q_Q(QQuickAbstractButton);
++    QQuickControlPrivate::itemDestroyed(item);
++    if (item == indicator) {
++        indicator = nullptr;
++        emit q->implicitIndicatorWidthChanged();
++        emit q->implicitIndicatorHeightChanged();
++    }
++}
++
+ QQuickAbstractButton *QQuickAbstractButtonPrivate::findCheckedButton() const
+ {
+     Q_Q(const QQuickAbstractButton);
+@@ -1176,6 +1187,12 @@ QAccessible::Role QQuickAbstractButton::accessibleRole() const
+     }
+     return QAccessible::Button;
+ }
++
++void QQuickAbstractButton::accessiblePressAction()
++{
++    Q_D(QQuickAbstractButton);
++    d->trigger();
++}
+ #endif
+ 
+ QT_END_NAMESPACE
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
+index 0fa48980e..ab66220d0 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
+@@ -209,6 +209,7 @@ protected:
+ #if QT_CONFIG(accessibility)
+     void accessibilityActiveChanged(bool active) override;
+     QAccessible::Role accessibleRole() const override;
++    Q_INVOKABLE void accessiblePressAction();
+ #endif
+ 
+ private:
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
+index 9291c1a87..b729720f2 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
+@@ -109,6 +109,7 @@ public:
+ 
+     void itemImplicitWidthChanged(QQuickItem *item) override;
+     void itemImplicitHeightChanged(QQuickItem *item) override;
++    void itemDestroyed(QQuickItem *item) override;
+ 
+     // copied from qabstractbutton.cpp
+     static const int AUTO_REPEAT_DELAY = 300;
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp b/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
+index 2041e7741..8610cdfae 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
+@@ -145,7 +145,7 @@ int QQuickActionPrivate::ShortcutEntry::shortcutId() const
+ 
+ void QQuickActionPrivate::ShortcutEntry::grab(const QKeySequence &shortcut, bool enabled)
+ {
+-    if (shortcut.isEmpty())
++    if (shortcut.isEmpty() || m_shortcutId)
+         return;
+ 
+     Qt::ShortcutContext context = Qt::WindowShortcut; // TODO
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp b/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
+index f38c2b09c..6eed2a024 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
+@@ -225,6 +225,7 @@ void QQuickContainerPrivate::cleanup()
+     QObject::disconnect(contentModel, &QQmlObjectModel::countChanged, q, &QQuickContainer::countChanged);
+     QObject::disconnect(contentModel, &QQmlObjectModel::childrenChanged, q, &QQuickContainer::contentChildrenChanged);
+     delete contentModel;
++    contentModel = nullptr;
+ }
+ 
+ QQuickItem *QQuickContainerPrivate::itemAt(int index) const
+@@ -436,7 +437,7 @@ void QQuickContainerPrivate::contentChildren_clear(QQmlListProperty<QQuickItem>
+ void QQuickContainerPrivate::updateContentWidth()
+ {
+     Q_Q(QQuickContainer);
+-    if (hasContentWidth || qFuzzyCompare(contentWidth, implicitContentWidth))
++    if (hasContentWidth || qFuzzyCompare(contentWidth, implicitContentWidth) || !contentModel)
+         return;
+ 
+     contentWidth = implicitContentWidth;
+@@ -446,7 +447,7 @@ void QQuickContainerPrivate::updateContentWidth()
+ void QQuickContainerPrivate::updateContentHeight()
+ {
+     Q_Q(QQuickContainer);
+-    if (hasContentHeight || qFuzzyCompare(contentHeight, implicitContentHeight))
++    if (hasContentHeight || qFuzzyCompare(contentHeight, implicitContentHeight) || !contentModel)
+         return;
+ 
+     contentHeight = implicitContentHeight;
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp b/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
+index bbbd0e622..1f4b47343 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
+@@ -845,6 +845,13 @@ void QQuickControlPrivate::executeBackground(bool complete)
+         quickCompleteDeferred(q, backgroundName(), background);
+ }
+ 
++/*
++    \internal
++
++    Hides an item that was replaced by a newer one, rather than
++    deleting it, as the item is typically created in QML and hence
++    we don't own it.
++*/
+ void QQuickControlPrivate::hideOldItem(QQuickItem *item)
+ {
+     if (!item)
+@@ -863,6 +870,29 @@ void QQuickControlPrivate::hideOldItem(QQuickItem *item)
+ #endif
+ }
+ 
++/*
++    \internal
++
++    Named "unhide" because it's used for cases where an item
++    that was previously hidden by \l hideOldItem() wants to be
++    shown by a control again, such as a ScrollBar in ScrollView.
++*/
++void QQuickControlPrivate::unhideOldItem(QQuickControl *control, QQuickItem *item)
++{
++    Q_ASSERT(item);
++    qCDebug(lcItemManagement) << "unhiding old item" << item;
++
++    item->setVisible(true);
++    item->setParentItem(control);
++
++#if QT_CONFIG(accessibility)
++    // Add the item back in to the accessibility tree.
++    QQuickAccessibleAttached *accessible = accessibleAttached(item);
++    if (accessible)
++        accessible->setIgnored(false);
++#endif
++}
++
+ void QQuickControlPrivate::updateBaselineOffset()
+ {
+     Q_Q(QQuickControl);
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h b/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
+index 8e979079e..a6e624c91 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
+@@ -173,6 +173,7 @@ public:
+     virtual void executeBackground(bool complete = false);
+ 
+     static void hideOldItem(QQuickItem *item);
++    static void unhideOldItem(QQuickControl *control, QQuickItem *item);
+ 
+     void updateBaselineOffset();
+ 
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp b/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
+index e6db14eb5..6197d1547 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
+@@ -237,7 +237,7 @@ static QRectF alignedRect(Qt::LayoutDirection direction, Qt::Alignment alignment
+ void QQuickDialogButtonBoxPrivate::resizeContent()
+ {
+     Q_Q(QQuickDialogButtonBox);
+-    if (!contentItem)
++    if (!contentItem || !contentModel)
+         return;
+ 
+     QRectF geometry = q->boundingRect().adjusted(q->leftPadding(), q->topPadding(), -q->rightPadding(), -q->bottomPadding());
+@@ -322,6 +322,9 @@ void QQuickDialogButtonBoxPrivate::updateLayout()
+ qreal QQuickDialogButtonBoxPrivate::getContentWidth() const
+ {
+     Q_Q(const QQuickDialogButtonBox);
++    if (!contentModel)
++        return 0;
++
+     const int count = contentModel->count();
+     const qreal totalSpacing = qMax(0, count - 1) * spacing;
+     qreal totalWidth = totalSpacing;
+@@ -341,6 +344,9 @@ qreal QQuickDialogButtonBoxPrivate::getContentWidth() const
+ qreal QQuickDialogButtonBoxPrivate::getContentHeight() const
+ {
+     Q_Q(const QQuickDialogButtonBox);
++    if (!contentModel)
++        return 0;
++
+     const int count = contentModel->count();
+     qreal maxHeight = 0;
+     for (int i = 0; i < count; ++i) {
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp b/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
+index 91bd59184..0ce518f84 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
+@@ -399,8 +399,11 @@ void QQuickOverlay::itemChange(ItemChange change, const ItemChangeData &data)
+     Q_D(QQuickOverlay);
+     QQuickItem::itemChange(change, data);
+ 
+-    if (change == ItemChildAddedChange || change == ItemChildRemovedChange)
++    if (change == ItemChildAddedChange || change == ItemChildRemovedChange) {
+         setVisible(!d->allDrawers.isEmpty() || !childItems().isEmpty());
++        if (data.item->parent() == d->mouseGrabberPopup)
++            d->setMouseGrabberPopup(nullptr);
++    }
+ }
+ 
+ void QQuickOverlay::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp b/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
+index 4e2f509db..1c4b308cd 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
+@@ -797,6 +797,14 @@ void QQuickScrollBarAttachedPrivate::initHorizontal()
+     if (parent && parent == flickable->parentItem())
+         horizontal->stackAfter(flickable);
+ 
++    // If a scroll bar was previously hidden (due to e.g. setting a new contentItem
++    // on a ScrollView), we need to make sure that we un-hide it.
++    // We don't bother checking if the item is actually the old one, because
++    // if it's not, all of the things the function does (setting parent, visibility, etc.)
++    // should be no-ops anyway.
++    if (auto control = qobject_cast<QQuickControl*>(q_ptr->parent()))
++        QQuickControlPrivate::unhideOldItem(control, horizontal);
++
+     layoutHorizontal();
+     horizontal->setSize(area->property("widthRatio").toReal());
+     horizontal->setPosition(area->property("xPosition").toReal());
+@@ -818,6 +826,9 @@ void QQuickScrollBarAttachedPrivate::initVertical()
+     if (parent && parent == flickable->parentItem())
+         vertical->stackAfter(flickable);
+ 
++    if (auto control = qobject_cast<QQuickControl*>(q_ptr->parent()))
++        QQuickControlPrivate::unhideOldItem(control, vertical);
++
+     layoutVertical();
+     vertical->setSize(area->property("heightRatio").toReal());
+     vertical->setPosition(area->property("yPosition").toReal());
+diff --git a/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml b/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
+index 0e8b08352..cd4931184 100644
+--- a/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
++++ b/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
+@@ -576,4 +576,51 @@ TestCase {
+         verify(newHorizontalScrollBar.visible)
+         verify(!oldHorizontalScrollBar.visible)
+     }
++
++    Component {
++        id: bindingToContentItemAndStandaloneFlickable
++
++        Item {
++            width: 200
++            height: 200
++
++            property alias scrollView: scrollView
++
++            ScrollView {
++                id: scrollView
++                anchors.fill: parent
++                contentItem: listView
++
++                property Item someBinding: contentItem
++            }
++            ListView {
++                id: listView
++                model: 10
++                delegate: ItemDelegate {
++                    text: modelData
++                    width: listView.width
++                }
++            }
++        }
++    }
++
++    // Tests that scroll bars show up for a ScrollView where
++    // - its contentItem is declared as a standalone, separate item
++    // - there is a binding to contentItem (which causes a default Flickable to be created)
++    function test_bindingToContentItemAndStandaloneFlickable() {
++        let root = createTemporaryObject(bindingToContentItemAndStandaloneFlickable, testCase)
++        verify(root)
++
++        let control = root.scrollView
++        let verticalScrollBar = control.ScrollBar.vertical
++        let horizontalScrollBar = control.ScrollBar.horizontal
++        compare(verticalScrollBar.parent, control)
++        compare(horizontalScrollBar.parent, control)
++        verify(verticalScrollBar.visible)
++        verify(horizontalScrollBar.visible)
++
++        mouseDrag(verticalScrollBar, verticalScrollBar.width / 2, verticalScrollBar.height / 2, 0, 50)
++        verify(verticalScrollBar.active)
++        verify(horizontalScrollBar.active)
++    }
+ }
+diff --git a/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml b/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
+index b3fab41ca..10b6baa02 100644
+--- a/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
++++ b/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
+@@ -608,4 +608,27 @@ TestCase {
+         mouseClick(control.indicator)
+         verify(control.activeFocus)
+     }
++
++    Component {
++        id: deletionOrder1
++        Item {
++            Image { id: innerImage }
++            Switch { indicator: innerImage }
++        }
++    }
++
++    Component {
++        id: deletionOrder2
++        Item {
++            Switch { indicator: innerImage }
++            Image { id: innerImage }
++        }
++    }
++
++    function test_deletionOrder() {
++        var control1 = createTemporaryObject(deletionOrder1, testCase)
++        verify(control1)
++        var control2 = createTemporaryObject(deletionOrder2, testCase)
++        verify(control2)
++    }
+ }
+diff --git a/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml b/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml
+new file mode 100644
+index 000000000..9e4598b9f
+--- /dev/null
++++ b/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml
+@@ -0,0 +1,78 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the test suite of the Qt Toolkit.
++**
++** $QT_BEGIN_LICENSE:BSD$
++** Commercial License Usage
++** Licensees holding valid commercial Qt licenses may use this file in
++** accordance with the commercial license agreement provided with the
++** Software or, alternatively, in accordance with the terms contained in
++** a written agreement between you and The Qt Company. For licensing terms
++** and conditions see https://www.qt.io/terms-conditions. For further
++** information use the contact form at https://www.qt.io/contact-us.
++**
++** BSD License Usage
++** Alternatively, you may use this file under the terms of the BSD license
++** as follows:
++**
++** "Redistribution and use in source and binary forms, with or without
++** modification, are permitted provided that the following conditions are
++** met:
++**   * Redistributions of source code must retain the above copyright
++**     notice, this list of conditions and the following disclaimer.
++**   * Redistributions in binary form must reproduce the above copyright
++**     notice, this list of conditions and the following disclaimer in
++**     the documentation and/or other materials provided with the
++**     distribution.
++**   * Neither the name of The Qt Company Ltd nor the names of its
++**     contributors may be used to endorse or promote products derived
++**     from this software without specific prior written permission.
++**
++**
++** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
++** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
++** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
++** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
++** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
++** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
++** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
++** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
++** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
++** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
++** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
++**
++** $QT_END_LICENSE$
++**
++****************************************************************************/
++
++import QtQuick 2.15
++import QtQuick.Controls 2.15
++
++ApplicationWindow {
++    id: window
++    width: 400
++    height: 400
++    title: "releaseAfterExitTransition"
++
++    property alias popup: popup
++    property alias modalPopup: modalPopup
++
++    Popup {
++        id: popup
++        y: parent.height - height
++        width: 50
++        height: 50
++    }
++
++    Popup {
++        id: modalPopup
++        modal: true
++        y: parent.height - height
++        width: 50
++        height: 50
++        exit:  Transition { PauseAnimation { duration: 100 } }
++    }
++}
+diff --git a/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp b/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
+index 54952d128..3d50e2dd4 100644
+--- a/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
++++ b/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
+@@ -100,6 +100,7 @@ private slots:
+     void invisibleToolTipOpen();
+     void centerInOverlayWithinStackViewItem();
+     void destroyDuringExitTransition();
++    void releaseAfterExitTransition();
+ };
+ 
+ void tst_QQuickPopup::initTestCase()
+@@ -1575,6 +1576,34 @@ void tst_QQuickPopup::destroyDuringExitTransition()
+     QVERIFY(!button->isDown());
+ }
+ 
++void tst_QQuickPopup::releaseAfterExitTransition()
++{
++    QQuickApplicationHelper helper(this, "releaseAfterExitTransition.qml");
++    QVERIFY2(helper.ready, helper.failureMessage());
++
++    QQuickWindow *window = helper.window;
++    window->show();
++    QVERIFY(QTest::qWaitForWindowActive(window));
++
++    QQuickOverlay *overlay = QQuickOverlay::overlay(window);
++    QQuickPopup *modalPopup = window->property("modalPopup").value<QQuickPopup *>();
++    QQuickPopup *popup = window->property("popup").value<QQuickPopup *>();
++
++    modalPopup->open();
++    QTRY_VERIFY(modalPopup->isOpened());
++
++    QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++    // wait until the transition is finished and the overlay hides itself
++    QTRY_VERIFY(!overlay->isVisible());
++    QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++
++    popup->open();
++    QTRY_VERIFY(popup->isOpened());
++    QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++    QTRY_VERIFY(!popup->isOpened());
++}
++
++
+ QTEST_QUICKCONTROLS_MAIN(tst_QQuickPopup)
+ 
+ #include "tst_qquickpopup.moc"
+Submodule qtscript 5be95f96...4d8e4bd2 (commits not present)
+Submodule qtspeech 17fc9fde..255845e2:
+diff --git a/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp b/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
+index 6eb74b8..bcc7dd1 100644
+--- a/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
++++ b/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
+@@ -357,7 +357,9 @@ QVector<QLocale> QTextToSpeechEngineSpeechd::availableLocales() const
+ 
+ QVector<QVoice> QTextToSpeechEngineSpeechd::availableVoices() const
+ {
+-    return m_voices.values(m_currentLocale.name()).toVector();
++    QList<QVoice> resultList = m_voices.values(m_currentLocale.name());
++    std::reverse(resultList.begin(), resultList.end());
++    return resultList.toVector();
+ }
+ 
+ // We have no way of knowing our own client_id since speech-dispatcher seems to be incomplete
+Submodule qtsvg 0c05780e..a7a0f249:
+diff --git a/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp b/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
+index 561e77e..12e0574 100644
+--- a/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
++++ b/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
+@@ -191,6 +191,8 @@ bool QSvgIOHandler::read(QImage *image)
+             }
+         }
+         if (!finalSize.isEmpty()) {
++            if (qMax(finalSize.width(), finalSize.height()) > 0xffff)
++                return false; // Assume corrupted file
+             image->fill(d->backColor.rgba());
+             QPainter p(image);
+             d->r.render(&p, bounds);
+diff --git a/qtsvg/src/svg/qsvghandler.cpp b/qtsvg/src/svg/qsvghandler.cpp
+index a5f877f..8dda563 100644
+--- a/qtsvg/src/svg/qsvghandler.cpp
++++ b/qtsvg/src/svg/qsvghandler.cpp
+@@ -1393,9 +1393,10 @@ static void parseFont(QSvgNode *node,
+         case FontSizeNone:
+             break;
+         case FontSizeValue: {
+-            QSvgHandler::LengthType dummy; // should always be pixel size
+-            fontStyle->setSize(qMin(parseLength(attributes.fontSize, dummy, handler),
+-                                    qreal(0xffff)));
++            QSvgHandler::LengthType type;
++            qreal fs = parseLength(attributes.fontSize, type, handler);
++            fs = convertToPixels(fs, true, type);
++            fontStyle->setSize(qMin(fs, qreal(0xffff)));
+         }
+             break;
+         default:
+@@ -2513,6 +2514,8 @@ static bool parseAnimateTransformNode(QSvgNode *parent,
+             ++s;
+         }
+     }
++    if (vals.count() % 3 != 0)
++        return false;
+ 
+     bool ok = true;
+     int begin = parseClockValue(beginStr, &ok);
+@@ -2576,6 +2579,8 @@ static QSvgNode *createCircleNode(QSvgNode *parent,
+     qreal ncx = toDouble(cx);
+     qreal ncy = toDouble(cy);
+     qreal nr  = toDouble(r);
++    if (nr < 0.0)
++        return nullptr;
+ 
+     QRectF rect(ncx-nr, ncy-nr, nr*2, nr*2);
+     QSvgNode *circle = new QSvgCircle(parent, rect);
+@@ -3046,15 +3051,16 @@ static QSvgStyleProperty *createRadialGradientNode(QSvgNode *node,
+ 
+     qreal ncx = 0.5;
+     qreal ncy = 0.5;
+-    qreal nr  = 0.5;
+     if (!cx.isEmpty())
+         ncx = toDouble(cx);
+     if (!cy.isEmpty())
+         ncy = toDouble(cy);
++
++    qreal nr = 0.0;
+     if (!r.isEmpty())
+         nr = toDouble(r);
+-    if (nr < 0.5)
+-        nr = 0.5;
++    if (nr <= 0.0)
++        return nullptr;
+ 
+     qreal nfx = ncx;
+     if (!fx.isEmpty())
+@@ -3350,7 +3356,9 @@ static QSvgNode *createTextNode(QSvgNode *parent,
+     //### editable and rotate not handled
+     QSvgHandler::LengthType type;
+     qreal nx = parseLength(x, type, handler);
++    nx = convertToPixels(nx, true, type);
+     qreal ny = parseLength(y, type, handler);
++    ny = convertToPixels(ny, true, type);
+ 
+     QSvgNode *text = new QSvgText(parent, QPointF(nx, ny));
+     return text;
+@@ -3691,9 +3699,7 @@ void QSvgHandler::parse()
+         case QXmlStreamReader::EndElement:
+             endElement(xml->name());
+             ++remainingUnfinishedElements;
+-            // if we are using somebody else's qxmlstreamreader
+-            // we should not read until the end of the stream
+-            done = !m_ownsReader && (xml->name() == QLatin1String("svg"));
++            done = (xml->name() == QLatin1String("svg"));
+             break;
+         case QXmlStreamReader::Characters:
+             characters(xml->text());
+diff --git a/qtsvg/src/svg/qsvgstructure.cpp b/qtsvg/src/svg/qsvgstructure.cpp
+index b89608b..89c9e4e 100644
+--- a/qtsvg/src/svg/qsvgstructure.cpp
++++ b/qtsvg/src/svg/qsvgstructure.cpp
+@@ -255,9 +255,13 @@ inline static bool isSupportedSvgFeature(const QString &str)
+     };
+ 
+     if (str.length() <= MAX_WORD_LENGTH && str.length() >= MIN_WORD_LENGTH) {
++        const char16_t unicode44 = str.at(44).unicode();
++        const char16_t unicode45 = str.at(45).unicode();
++        if (unicode44 >= sizeof(asso_values) || unicode45 >= sizeof(asso_values))
++            return false;
+         const int key = str.length()
+-                        + asso_values[str.at(45).unicode()]
+-                        + asso_values[str.at(44).unicode()];
++                        + asso_values[unicode45]
++                        + asso_values[unicode44];
+         if (key <= MAX_HASH_VALUE && key >= 0)
+             return str == QLatin1String(wordlist[key]);
+     }
+diff --git a/qtsvg/src/svg/qsvgtinydocument.cpp b/qtsvg/src/svg/qsvgtinydocument.cpp
+index 63d0797..19e7154 100644
+--- a/qtsvg/src/svg/qsvgtinydocument.cpp
++++ b/qtsvg/src/svg/qsvgtinydocument.cpp
+@@ -433,8 +433,16 @@ void QSvgTinyDocument::draw(QPainter *p, QSvgExtraStates &)
+     draw(p);
+ }
+ 
++static bool isValidMatrix(const QTransform &transform)
++{
++    qreal determinant = transform.determinant();
++    return qIsFinite(determinant);
++}
++
+ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect, const QRectF &sourceRect)
+ {
++    QTransform oldTransform = p->worldTransform();
++
+     QRectF target = targetRect;
+     if (target.isEmpty()) {
+         QPaintDevice *dev = p->device();
+@@ -487,6 +495,9 @@ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect,
+         }
+ #endif
+     }
++
++    if (!isValidMatrix(p->worldTransform()))
++        p->setWorldTransform(oldTransform);
+ }
+ 
+ QRectF QSvgTinyDocument::boundsOnElement(const QString &id) const
+diff --git a/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp b/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
+index 36c76ec..db71e02 100644
+--- a/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
++++ b/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
+@@ -86,6 +86,8 @@ private slots:
+     void oss_fuzz_23731();
+     void oss_fuzz_24131();
+     void oss_fuzz_24738();
++    void illegalAnimateTransform_data();
++    void illegalAnimateTransform();
+ 
+ #ifndef QT_NO_COMPRESS
+     void testGzLoading();
+@@ -1646,5 +1648,22 @@ void tst_QSvgRenderer::oss_fuzz_24738()
+     QSvgRenderer().load(QByteArray("<svg><path d=\"a 2 1e-212.....\">"));
+ }
+ 
++void tst_QSvgRenderer::illegalAnimateTransform_data()
++{
++    QTest::addColumn<QByteArray>("svg");
++
++    QTest::newRow("case1") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" values=\"8,0,5,0\">");
++    QTest::newRow("case2") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" values=\"1,2\">");
++    QTest::newRow("case3") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" from=\".. 5 2\" to=\"f\">");
++    QTest::newRow("case4") << QByteArray("<svg><animateTransform type=\"scale\" begin=\"1\" dur=\"2\" by=\"--,..\">");
++}
++
++void tst_QSvgRenderer::illegalAnimateTransform()
++{
++    QFETCH(QByteArray, svg);
++    QSvgRenderer renderer;
++    QVERIFY(!renderer.load(svg)); // also shouldn't assert
++}
++
+ QTEST_MAIN(tst_QSvgRenderer)
+ #include "tst_qsvgrenderer.moc"
+Submodule qttools 6914f7c8..090e526e:
+diff --git a/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp b/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
+index feab1e2d5..cbfb82507 100644
+--- a/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
++++ b/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
+@@ -445,7 +445,9 @@ bool HelpGeneratorPrivate::insertFiles(const QStringList &files, const QString &
+     if (filterSetId < 0)
+         return false;
+     ++filterSetId;
+-    for (int attId : qAsConst(filterAtts)) {
++    QList<int> attValues = filterAtts.values();
++    std::sort(attValues.begin(), attValues.end());
++    for (int attId : qAsConst(attValues)) {
+         m_query->prepare(QLatin1String("INSERT INTO FileAttributeSetTable "
+             "VALUES(?, ?)"));
+         m_query->bindValue(0, filterSetId);
+Submodule qtwayland dfb0129c..2904e1b3:
+diff --git a/qtwayland/src/client/configure.json b/qtwayland/src/client/configure.json
+index 2f424580..29222357 100644
+--- a/qtwayland/src/client/configure.json
++++ b/qtwayland/src/client/configure.json
+@@ -149,8 +149,7 @@
+                     "#endif"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "vulkan-server-buffer": {
+             "label": "Vulkan Buffer Sharing",
+@@ -168,7 +167,8 @@
+                     "exportAllocInfo.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR;",
+                     "return 0;"
+                 ]
+-            }
++            },
++            "use": "wayland-client"
+         },
+         "egl_1_5-wayland": {
+             "label": "EGL 1.5 with Wayland Platform",
+@@ -183,7 +183,7 @@
+                     "eglGetPlatformDisplay(EGL_PLATFORM_WAYLAND_EXT, (struct wl_display *)(nullptr), nullptr);"
+                 ]
+             },
+-            "use": "egl"
++            "use": "egl wayland-client"
+         }
+     },
+ 
+diff --git a/qtwayland/src/client/global/qwaylandclientextension.cpp b/qtwayland/src/client/global/qwaylandclientextension.cpp
+index 125b1e19..edccfe63 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension.cpp
++++ b/qtwayland/src/client/global/qwaylandclientextension.cpp
+@@ -74,7 +74,10 @@ void QWaylandClientExtensionPrivate::handleRegistryGlobal(void *data, ::wl_regis
+ void QWaylandClientExtension::addRegistryListener()
+ {
+     Q_D(QWaylandClientExtension);
+-    d->waylandIntegration->display()->addRegistryListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++    if (!d->registered) {
++        d->waylandIntegration->display()->addRegistryListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++        d->registered = true;
++    }
+ }
+ 
+ QWaylandClientExtension::QWaylandClientExtension(const int ver)
+@@ -88,6 +91,13 @@ QWaylandClientExtension::QWaylandClientExtension(const int ver)
+     QMetaObject::invokeMethod(this, "addRegistryListener", Qt::QueuedConnection);
+ }
+ 
++QWaylandClientExtension::~QWaylandClientExtension()
++{
++    Q_D(QWaylandClientExtension);
++    if (d->registered && !QCoreApplication::closingDown())
++        d->waylandIntegration->display()->removeListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++}
++
+ QtWaylandClient::QWaylandIntegration *QWaylandClientExtension::integration() const
+ {
+     Q_D(const QWaylandClientExtension);
+diff --git a/qtwayland/src/client/global/qwaylandclientextension.h b/qtwayland/src/client/global/qwaylandclientextension.h
+index 98272e57..5bd28398 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension.h
++++ b/qtwayland/src/client/global/qwaylandclientextension.h
+@@ -63,6 +63,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandClientExtension : public QObject
+     Q_PROPERTY(bool active READ isActive NOTIFY activeChanged)
+ public:
+     QWaylandClientExtension(const int version);
++    ~QWaylandClientExtension();
+ 
+     QtWaylandClient::QWaylandIntegration *integration() const;
+     int version() const;
+diff --git a/qtwayland/src/client/global/qwaylandclientextension_p.h b/qtwayland/src/client/global/qwaylandclientextension_p.h
+index 69cc46a0..9091efbe 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension_p.h
++++ b/qtwayland/src/client/global/qwaylandclientextension_p.h
+@@ -68,6 +68,7 @@ public:
+     QtWaylandClient::QWaylandIntegration *waylandIntegration = nullptr;
+     int version = -1;
+     bool active = false;
++    bool registered = false;
+ };
+ 
+ class Q_WAYLAND_CLIENT_EXPORT QWaylandClientExtensionTemplatePrivate : public QWaylandClientExtensionPrivate
+diff --git a/qtwayland/src/client/qwaylanddatadevice.cpp b/qtwayland/src/client/qwaylanddatadevice.cpp
+index 7e2e3308..e3e60ed5 100644
+--- a/qtwayland/src/client/qwaylanddatadevice.cpp
++++ b/qtwayland/src/client/qwaylanddatadevice.cpp
+@@ -72,6 +72,8 @@ QWaylandDataDevice::QWaylandDataDevice(QWaylandDataDeviceManager *manager, QWayl
+ 
+ QWaylandDataDevice::~QWaylandDataDevice()
+ {
++    if (wl_data_device_get_version(object()) >= WL_DATA_DEVICE_RELEASE_SINCE_VERSION)
++        release();
+ }
+ 
+ QWaylandDataOffer *QWaylandDataDevice::selectionOffer() const
+@@ -110,7 +112,7 @@ QWaylandDataOffer *QWaylandDataDevice::dragOffer() const
+     return m_dragOffer.data();
+ }
+ 
+-bool QWaylandDataDevice::startDrag(QMimeData *mimeData, QWaylandWindow *icon)
++bool QWaylandDataDevice::startDrag(QMimeData *mimeData, Qt::DropActions supportedActions, QWaylandWindow *icon)
+ {
+     auto *seat = m_display->currentInputDevice();
+     auto *origin = seat->pointerFocus();
+@@ -123,7 +125,28 @@ bool QWaylandDataDevice::startDrag(QMimeData *mimeData, QWaylandWindow *icon)
+     }
+ 
+     m_dragSource.reset(new QWaylandDataSource(m_display->dndSelectionHandler(), mimeData));
++
++    if (wl_data_device_get_version(object()) >= 3)
++        m_dragSource->set_actions(dropActionsToWl(supportedActions));
++
+     connect(m_dragSource.data(), &QWaylandDataSource::cancelled, this, &QWaylandDataDevice::dragSourceCancelled);
++    connect(m_dragSource.data(), &QWaylandDataSource::dndResponseUpdated, this, [this](bool accepted, Qt::DropAction action) {
++            auto drag = static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag());
++            // in old versions drop action is not set, so we guess
++            if (wl_data_source_get_version(m_dragSource->object()) < 3) {
++                drag->setResponse(accepted);
++            } else {
++                QPlatformDropQtResponse response(accepted, action);
++                drag->setResponse(response);
++            }
++    });
++    connect(m_dragSource.data(), &QWaylandDataSource::dndDropped, this, [](bool accepted, Qt::DropAction action) {
++        QPlatformDropQtResponse response(accepted, action);
++        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setDropResponse(response);
++    });
++    connect(m_dragSource.data(), &QWaylandDataSource::finished, this, []() {
++        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag();
++    });
+ 
+     start_drag(m_dragSource->object(), origin->wlSurface(), icon->wlSurface(), m_display->currentInputDevice()->serial());
+     return true;
+@@ -152,7 +175,7 @@ void QWaylandDataDevice::data_device_drop()
+         supportedActions = drag->supportedActions();
+     } else if (m_dragOffer) {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     } else {
+         return;
+     }
+@@ -162,7 +185,11 @@ void QWaylandDataDevice::data_device_drop()
+                                                                           QGuiApplication::keyboardModifiers());
+ 
+     if (drag) {
+-        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag(response);
++        auto drag =  static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag());
++        drag->setDropResponse(response);
++        drag->finishDrag();
++    } else if (m_dragOffer) {
++        m_dragOffer->finish();
+     }
+ }
+ 
+@@ -186,7 +213,7 @@ void QWaylandDataDevice::data_device_enter(uint32_t serial, wl_surface *surface,
+         supportedActions = drag->supportedActions();
+     } else if (m_dragOffer) {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     }
+ 
+     const QPlatformDragQtResponse &response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
+@@ -197,11 +224,7 @@ void QWaylandDataDevice::data_device_enter(uint32_t serial, wl_surface *surface,
+         static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setResponse(response);
+     }
+ 
+-    if (response.isAccepted()) {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, m_dragOffer->firstFormat().toUtf8().constData());
+-    } else {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, nullptr);
+-    }
++    sendResponse(supportedActions, response);
+ }
+ 
+ void QWaylandDataDevice::data_device_leave()
+@@ -235,10 +258,10 @@ void QWaylandDataDevice::data_device_motion(uint32_t time, wl_fixed_t x, wl_fixe
+         supportedActions = drag->supportedActions();
+     } else {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     }
+ 
+-    QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
++    const QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
+                                                                           QGuiApplication::mouseButtons(),
+                                                                           QGuiApplication::keyboardModifiers());
+ 
+@@ -246,11 +269,7 @@ void QWaylandDataDevice::data_device_motion(uint32_t time, wl_fixed_t x, wl_fixe
+         static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setResponse(response);
+     }
+ 
+-    if (response.isAccepted()) {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, m_dragOffer->firstFormat().toUtf8().constData());
+-    } else {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, nullptr);
+-    }
++    sendResponse(supportedActions, response);
+ }
+ #endif // QT_CONFIG(draganddrop)
+ 
+@@ -277,14 +296,10 @@ void QWaylandDataDevice::selectionSourceCancelled()
+ #if QT_CONFIG(draganddrop)
+ void QWaylandDataDevice::dragSourceCancelled()
+ {
++    static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag();
+     m_dragSource.reset();
+ }
+ 
+-void QWaylandDataDevice::dragSourceTargetChanged(const QString &mimeType)
+-{
+-    static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->updateTarget(mimeType);
+-}
+-
+ QPoint QWaylandDataDevice::calculateDragPosition(int x, int y, QWindow *wnd) const
+ {
+     QPoint pnt(wl_fixed_to_int(x), wl_fixed_to_int(y));
+@@ -297,6 +312,33 @@ QPoint QWaylandDataDevice::calculateDragPosition(int x, int y, QWindow *wnd) con
+     }
+     return pnt;
+ }
++
++void QWaylandDataDevice::sendResponse(Qt::DropActions supportedActions, const QPlatformDragQtResponse &response)
++{
++    if (response.isAccepted()) {
++        if (wl_data_device_get_version(object()) >= 3)
++            m_dragOffer->set_actions(dropActionsToWl(supportedActions), dropActionsToWl(response.acceptedAction()));
++
++        m_dragOffer->accept(m_enterSerial, m_dragOffer->firstFormat());
++    } else {
++        m_dragOffer->accept(m_enterSerial, QString());
++    }
++}
++
++int QWaylandDataDevice::dropActionsToWl(Qt::DropActions actions)
++{
++
++    int wlActions = WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE;
++    if (actions & Qt::CopyAction)
++        wlActions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY;
++    if (actions & (Qt::MoveAction | Qt::TargetMoveAction))
++        wlActions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE;
++
++    // wayland does not support LinkAction at the time of writing
++    return wlActions;
++}
++
++
+ #endif // QT_CONFIG(draganddrop)
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddatadevice_p.h b/qtwayland/src/client/qwaylanddatadevice_p.h
+index 16c3ad28..801dcc2c 100644
+--- a/qtwayland/src/client/qwaylanddatadevice_p.h
++++ b/qtwayland/src/client/qwaylanddatadevice_p.h
+@@ -64,6 +64,7 @@ QT_REQUIRE_CONFIG(wayland_datadevice);
+ QT_BEGIN_NAMESPACE
+ 
+ class QMimeData;
++class QPlatformDragQtResponse;
+ class QWindow;
+ 
+ namespace QtWaylandClient {
+@@ -89,7 +90,7 @@ public:
+ 
+ #if QT_CONFIG(draganddrop)
+     QWaylandDataOffer *dragOffer() const;
+-    bool startDrag(QMimeData *mimeData, QWaylandWindow *icon);
++    bool startDrag(QMimeData *mimeData, Qt::DropActions supportedActions, QWaylandWindow *icon);
+     void cancelDrag();
+ #endif
+ 
+@@ -109,13 +110,16 @@ private Q_SLOTS:
+ 
+ #if QT_CONFIG(draganddrop)
+     void dragSourceCancelled();
+-    void dragSourceTargetChanged(const QString &mimeType);
+ #endif
+ 
+ private:
+ #if QT_CONFIG(draganddrop)
+     QPoint calculateDragPosition(int x, int y, QWindow *wnd) const;
+ #endif
++    void sendResponse(Qt::DropActions supportedActions, const QPlatformDragQtResponse &response);
++
++    static int dropActionsToWl(Qt::DropActions dropActions);
++
+ 
+     QWaylandDisplay *m_display = nullptr;
+     QWaylandInputDevice *m_inputDevice = nullptr;
+diff --git a/qtwayland/src/client/qwaylanddatadevicemanager.cpp b/qtwayland/src/client/qwaylanddatadevicemanager.cpp
+index 35d67307..6dc4f77f 100644
+--- a/qtwayland/src/client/qwaylanddatadevicemanager.cpp
++++ b/qtwayland/src/client/qwaylanddatadevicemanager.cpp
+@@ -50,8 +50,8 @@ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
+-QWaylandDataDeviceManager::QWaylandDataDeviceManager(QWaylandDisplay *display, uint32_t id)
+-    : wl_data_device_manager(display->wl_registry(), id, 1)
++QWaylandDataDeviceManager::QWaylandDataDeviceManager(QWaylandDisplay *display, int version, uint32_t id)
++    : wl_data_device_manager(display->wl_registry(), id, qMin(version, 3))
+     , m_display(display)
+ {
+     // Create transfer devices for all input devices.
+diff --git a/qtwayland/src/client/qwaylanddatadevicemanager_p.h b/qtwayland/src/client/qwaylanddatadevicemanager_p.h
+index bd05c0fb..510d9be4 100644
+--- a/qtwayland/src/client/qwaylanddatadevicemanager_p.h
++++ b/qtwayland/src/client/qwaylanddatadevicemanager_p.h
+@@ -68,7 +68,7 @@ class QWaylandInputDevice;
+ class Q_WAYLAND_CLIENT_EXPORT QWaylandDataDeviceManager : public QtWayland::wl_data_device_manager
+ {
+ public:
+-    QWaylandDataDeviceManager(QWaylandDisplay *display, uint32_t id);
++    QWaylandDataDeviceManager(QWaylandDisplay *display, int version, uint32_t id);
+     ~QWaylandDataDeviceManager() override;
+ 
+     QWaylandDataDevice *getDataDevice(QWaylandInputDevice *inputDevice);
+diff --git a/qtwayland/src/client/qwaylanddataoffer.cpp b/qtwayland/src/client/qwaylanddataoffer.cpp
+index 2297e8a1..fe0ea8c9 100644
+--- a/qtwayland/src/client/qwaylanddataoffer.cpp
++++ b/qtwayland/src/client/qwaylanddataoffer.cpp
+@@ -82,6 +82,15 @@ QMimeData *QWaylandDataOffer::mimeData()
+     return m_mimeData.data();
+ }
+ 
++Qt::DropActions QWaylandDataOffer::supportedActions() const
++{
++    if (wl_data_offer_get_version(const_cast<::wl_data_offer*>(object())) < 3) {
++        return Qt::MoveAction | Qt::CopyAction;
++    }
++
++    return m_supportedActions;
++}
++
+ void QWaylandDataOffer::startReceiving(const QString &mimeType, int fd)
+ {
+     receive(mimeType, fd);
+@@ -93,6 +102,22 @@ void QWaylandDataOffer::data_offer_offer(const QString &mime_type)
+     m_mimeData->appendFormat(mime_type);
+ }
+ 
++void QWaylandDataOffer::data_offer_action(uint32_t dnd_action)
++{
++    Q_UNUSED(dnd_action);
++    // This is the compositor telling the drag target what action it should perform
++    // It does not map nicely into Qt final drop semantics, other than pretending there is only one supported action?
++}
++
++void QWaylandDataOffer::data_offer_source_actions(uint32_t source_actions)
++{
++    m_supportedActions = Qt::DropActions();
++    if (source_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
++        m_supportedActions |= Qt::MoveAction;
++    if (source_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
++        m_supportedActions |= Qt::CopyAction;
++}
++
+ QWaylandMimeData::QWaylandMimeData(QWaylandAbstractDataOffer *dataOffer)
+     : m_dataOffer(dataOffer)
+ {
+@@ -163,17 +188,18 @@ QVariant QWaylandMimeData::retrieveData_sys(const QString &mimeType, QVariant::T
+ 
+ int QWaylandMimeData::readData(int fd, QByteArray &data) const
+ {
+-    fd_set readset;
+-    FD_ZERO(&readset);
+-    FD_SET(fd, &readset);
+-    struct timeval timeout;
++    struct pollfd readset;
++    readset.fd = fd;
++    readset.events = POLLIN;
++    struct timespec timeout;
+     timeout.tv_sec = 1;
+-    timeout.tv_usec = 0;
++    timeout.tv_nsec = 0;
++
+ 
+     Q_FOREVER {
+-        int ready = select(FD_SETSIZE, &readset, nullptr, nullptr, &timeout);
++        int ready = qt_safe_poll(&readset, 1, &timeout);
+         if (ready < 0) {
+-            qWarning() << "QWaylandDataOffer: select() failed";
++            qWarning() << "QWaylandDataOffer: qt_safe_poll() failed";
+             return -1;
+         } else if (ready == 0) {
+             qWarning("QWaylandDataOffer: timeout reading from pipe");
+diff --git a/qtwayland/src/client/qwaylanddataoffer_p.h b/qtwayland/src/client/qwaylanddataoffer_p.h
+index 9cf1483c..6f667398 100644
+--- a/qtwayland/src/client/qwaylanddataoffer_p.h
++++ b/qtwayland/src/client/qwaylanddataoffer_p.h
+@@ -82,6 +82,7 @@ public:
+     explicit QWaylandDataOffer(QWaylandDisplay *display, struct ::wl_data_offer *offer);
+     ~QWaylandDataOffer() override;
+     QMimeData *mimeData() override;
++    Qt::DropActions supportedActions() const;
+ 
+     QString firstFormat() const;
+ 
+@@ -89,10 +90,13 @@ public:
+ 
+ protected:
+     void data_offer_offer(const QString &mime_type) override;
++    void data_offer_source_actions(uint32_t source_actions) override;
++    void data_offer_action(uint32_t dnd_action) override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+     QScopedPointer<QWaylandMimeData> m_mimeData;
++    Qt::DropActions m_supportedActions;
+ };
+ 
+ 
+diff --git a/qtwayland/src/client/qwaylanddatasource.cpp b/qtwayland/src/client/qwaylanddatasource.cpp
+index f45122fb..5599cbd4 100644
+--- a/qtwayland/src/client/qwaylanddatasource.cpp
++++ b/qtwayland/src/client/qwaylanddatasource.cpp
+@@ -101,7 +101,32 @@ void QWaylandDataSource::data_source_send(const QString &mime_type, int32_t fd)
+ 
+ void QWaylandDataSource::data_source_target(const QString &mime_type)
+ {
+-    Q_EMIT targetChanged(mime_type);
++    m_accepted = !mime_type.isEmpty();
++    Q_EMIT dndResponseUpdated(m_accepted, m_dropAction);
++}
++
++void QWaylandDataSource::data_source_action(uint32_t action)
++{
++    Qt::DropAction qtAction = Qt::IgnoreAction;
++
++    if (action == WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
++        qtAction = Qt::MoveAction;
++    else if (action == WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
++        qtAction = Qt::CopyAction;
++
++    m_dropAction = qtAction;
++    Q_EMIT dndResponseUpdated(m_accepted, m_dropAction);
++}
++
++void QWaylandDataSource::data_source_dnd_finished()
++{
++    Q_EMIT finished();
++}
++
++void QWaylandDataSource::data_source_dnd_drop_performed()
++{
++
++    Q_EMIT dndDropped(m_accepted, m_dropAction);
+ }
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddatasource_p.h b/qtwayland/src/client/qwaylanddatasource_p.h
+index 25afff79..96f07bc3 100644
+--- a/qtwayland/src/client/qwaylanddatasource_p.h
++++ b/qtwayland/src/client/qwaylanddatasource_p.h
+@@ -77,17 +77,25 @@ public:
+     QMimeData *mimeData() const;
+ 
+ Q_SIGNALS:
+-    void targetChanged(const QString &mime_type);
+     void cancelled();
++    void finished();
++
++    void dndResponseUpdated(bool accepted, Qt::DropAction action);
++    void dndDropped(bool accepted, Qt::DropAction action);
+ 
+ protected:
+     void data_source_cancelled() override;
+     void data_source_send(const QString &mime_type, int32_t fd) override;
+     void data_source_target(const QString &mime_type) override;
++    void data_source_dnd_drop_performed() override;
++    void data_source_dnd_finished() override;
++    void data_source_action(uint32_t action) override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+     QMimeData *m_mime_data = nullptr;
++    bool m_accepted = false;
++    Qt::DropAction m_dropAction = Qt::IgnoreAction;
+ };
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddisplay.cpp b/qtwayland/src/client/qwaylanddisplay.cpp
+index f10c1f79..c01e238b 100644
+--- a/qtwayland/src/client/qwaylanddisplay.cpp
++++ b/qtwayland/src/client/qwaylanddisplay.cpp
+@@ -85,10 +85,203 @@
+ 
+ #include <errno.h>
+ 
++#include <tuple> // for std::tie
++
++static void checkWaylandError(struct wl_display *display)
++{
++    int ecode = wl_display_get_error(display);
++    if ((ecode == EPIPE || ecode == ECONNRESET)) {
++        // special case this to provide a nicer error
++        qWarning("The Wayland connection broke. Did the Wayland compositor die?");
++    } else {
++        qWarning("The Wayland connection experienced a fatal error: %s", strerror(ecode));
++    }
++    _exit(1);
++}
++
+ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
++class EventThread : public QThread
++{
++    Q_OBJECT
++public:
++    enum OperatingMode {
++        EmitToDispatch, // Emit the signal, allow dispatching in a differnt thread.
++        SelfDispatch, // Dispatch the events inside this thread.
++    };
++
++    EventThread(struct wl_display * wl, struct wl_event_queue * ev_queue,
++                OperatingMode mode)
++        : m_fd(wl_display_get_fd(wl))
++        , m_pipefd{ -1, -1 }
++        , m_wldisplay(wl)
++        , m_wlevqueue(ev_queue)
++        , m_mode(mode)
++        , m_reading(true)
++        , m_quitting(false)
++    {
++        setObjectName(QStringLiteral("WaylandEventThread"));
++    }
++
++    void readAndDispatchEvents()
++    {
++        /*
++         * Dispatch pending events and flush the requests at least once. If the event thread
++         * is not reading, try to call _prepare_read() to allow the event thread to poll().
++         * If that fails, re-try dispatch & flush again until _prepare_read() is successful.
++         *
++         * This allow any call to readAndDispatchEvents() to start event thread's polling,
++         * not only the one issued from event thread's waitForReading(), which means functions
++         * called from dispatch_pending() can safely spin an event loop.
++         */
++        for (;;) {
++            if (dispatchQueuePending() < 0) {
++                checkWaylandError(m_wldisplay);
++                return;
++            }
++
++            wl_display_flush(m_wldisplay);
++
++            // We have to check if event thread is reading every time we dispatch
++            // something, as that may recursively call this function.
++            if (m_reading.loadAcquire())
++                break;
++
++            if (prepareReadQueue() == 0) {
++                QMutexLocker l(&m_mutex);
++                m_reading.storeRelease(true);
++                m_cond.wakeOne();
++                break;
++            }
++        }
++    }
++
++    void stop()
++    {
++        // We have to both write to the pipe and set the flag, as the thread may be
++        // either in the poll() or waiting for _prepare_read().
++        if (m_pipefd[1] != -1 && write(m_pipefd[1], "\0", 1) == -1)
++            qWarning("Failed to write to the pipe: %s.", strerror(errno));
++
++        {
++            QMutexLocker l(&m_mutex);
++            m_quitting = true;
++            m_cond.wakeOne();
++        }
++
++        wait();
++    }
++
++Q_SIGNALS:
++    void needReadAndDispatch();
++
++protected:
++    void run() override
++    {
++        // we use this pipe to make the loop exit otherwise if we simply used a flag on the loop condition, if stop() gets
++        // called while poll() is blocking the thread will never quit since there are no wayland messages coming anymore.
++        struct Pipe
++        {
++            Pipe(int *fds)
++                : fds(fds)
++            {
++                if (qt_safe_pipe(fds) != 0)
++                    qWarning("Pipe creation failed. Quitting may hang.");
++            }
++            ~Pipe()
++            {
++                if (fds[0] != -1) {
++                    close(fds[0]);
++                    close(fds[1]);
++                }
++            }
++
++            int *fds;
++        } pipe(m_pipefd);
++
++        // Make the main thread call wl_prepare_read(), dispatch the pending messages and flush the
++        // outbound ones. Wait until it's done before proceeding, unless we're told to quit.
++        while (waitForReading()) {
++            pollfd fds[2] = { { m_fd, POLLIN, 0 }, { m_pipefd[0], POLLIN, 0 } };
++            poll(fds, 2, -1);
++
++            if (fds[1].revents & POLLIN) {
++                // we don't really care to read the byte that was written here since we're closing down
++                wl_display_cancel_read(m_wldisplay);
++                break;
++            }
++
++            if (fds[0].revents & POLLIN)
++                wl_display_read_events(m_wldisplay);
++                // The polll was succesfull and the event thread did the wl_display_read_events(). On the next iteration of the loop
++                // the event sent to the main thread will cause it to dispatch the messages just read, unless the loop exits in which
++                // case we don't care anymore about them.
++            else
++                wl_display_cancel_read(m_wldisplay);
++        }
++    }
++
++private:
++    bool waitForReading()
++    {
++        Q_ASSERT(QThread::currentThread() == this);
++
++        m_reading.storeRelease(false);
++
++        if (m_mode == SelfDispatch) {
++            readAndDispatchEvents();
++        } else {
++            Q_EMIT needReadAndDispatch();
++
++            QMutexLocker lock(&m_mutex);
++            // m_reading might be set from our emit or some other invocation of
++            // readAndDispatchEvents().
++            while (!m_reading.loadRelaxed() && !m_quitting)
++                m_cond.wait(&m_mutex);
++        }
++
++        return !m_quitting;
++    }
++
++    int dispatchQueuePending()
++    {
++        if (m_wlevqueue)
++            return wl_display_dispatch_queue_pending(m_wldisplay, m_wlevqueue);
++        else
++            return wl_display_dispatch_pending(m_wldisplay);
++    }
++
++    int prepareReadQueue()
++    {
++        if (m_wlevqueue)
++            return wl_display_prepare_read_queue(m_wldisplay, m_wlevqueue);
++        else
++            return wl_display_prepare_read(m_wldisplay);
++    }
++
++    int m_fd;
++    int m_pipefd[2];
++    wl_display *m_wldisplay;
++    wl_event_queue *m_wlevqueue;
++    OperatingMode m_mode;
++
++    /* Concurrency note when operating in EmitToDispatch mode:
++     * m_reading is set to false inside event thread's waitForReading(), and is
++     * set to true inside main thread's readAndDispatchEvents().
++     * The lock is not taken when setting m_reading to false, as the main thread
++     * is not actively waiting for it to turn false. However, the lock is taken
++     * inside readAndDispatchEvents() before setting m_reading to true,
++     * as the event thread is actively waiting for it under the wait condition.
++     */
++
++    QAtomicInteger<bool> m_reading;
++    bool m_quitting;
++    QMutex m_mutex;
++    QWaitCondition m_cond;
++};
++
+ Q_LOGGING_CATEGORY(lcQpaWayland, "qt.qpa.wayland"); // for general (uncategorized) Wayland platform logging
+ 
+ struct wl_surface *QWaylandDisplay::createSurface(void *handle)
+@@ -158,17 +351,16 @@ QWaylandDisplay::QWaylandDisplay(QWaylandIntegration *waylandIntegration)
+     if (!mXkbContext)
+         qCWarning(lcQpaWayland, "failed to create xkb context");
+ #endif
+-
+-    forceRoundTrip();
+-
+-    if (!mWaitingScreens.isEmpty()) {
+-        // Give wl_output.done and zxdg_output_v1.done events a chance to arrive
+-        forceRoundTrip();
+-    }
+ }
+ 
+ QWaylandDisplay::~QWaylandDisplay(void)
+ {
++    if (m_eventThread)
++        m_eventThread->stop();
++
++    if (m_frameEventQueueThread)
++        m_frameEventQueueThread->stop();
++
+     if (mSyncCallback)
+         wl_callback_destroy(mSyncCallback);
+ 
+@@ -187,6 +379,21 @@ QWaylandDisplay::~QWaylandDisplay(void)
+ #endif
+     if (mDisplay)
+         wl_display_disconnect(mDisplay);
++
++    if (m_frameEventQueue)
++        wl_event_queue_destroy(m_frameEventQueue);
++}
++
++// Steps which is called just after constructor. This separates registry_global() out of the constructor
++// so that factory functions in integration can be overridden.
++void QWaylandDisplay::initialize()
++{
++    forceRoundTrip();
++
++    if (!mWaitingScreens.isEmpty()) {
++        // Give wl_output.done and zxdg_output_v1.done events a chance to arrive
++        forceRoundTrip();
++    }
+ }
+ 
+ void QWaylandDisplay::ensureScreen()
+@@ -203,98 +410,37 @@ void QWaylandDisplay::ensureScreen()
+ 
+ void QWaylandDisplay::checkError() const
+ {
+-    int ecode = wl_display_get_error(mDisplay);
+-    if ((ecode == EPIPE || ecode == ECONNRESET)) {
+-        // special case this to provide a nicer error
+-        qWarning("The Wayland connection broke. Did the Wayland compositor die?");
+-    } else {
+-        qWarning("The Wayland connection experienced a fatal error: %s", strerror(ecode));
+-    }
+-    _exit(1);
++    checkWaylandError(mDisplay);
+ }
+ 
++// Called in main thread, either from queued signal or directly.
+ void QWaylandDisplay::flushRequests()
+ {
+-    if (wl_display_prepare_read(mDisplay) == 0) {
+-        wl_display_read_events(mDisplay);
+-    }
+-
+-    if (wl_display_dispatch_pending(mDisplay) < 0)
+-        checkError();
+-
+-    {
+-        QReadLocker locker(&m_frameQueueLock);
+-        for (const FrameQueue &q : mExternalQueues) {
+-            QMutexLocker locker(q.mutex);
+-            while (wl_display_prepare_read_queue(mDisplay, q.queue) != 0)
+-                wl_display_dispatch_queue_pending(mDisplay, q.queue);
+-            wl_display_read_events(mDisplay);
+-            wl_display_dispatch_queue_pending(mDisplay, q.queue);
+-        }
+-    }
+-
+-    wl_display_flush(mDisplay);
+-}
+-
+-void QWaylandDisplay::blockingReadEvents()
+-{
+-    if (wl_display_dispatch(mDisplay) < 0)
+-        checkError();
+-}
+-
+-void QWaylandDisplay::destroyFrameQueue(const QWaylandDisplay::FrameQueue &q)
+-{
+-    QWriteLocker locker(&m_frameQueueLock);
+-    auto it = std::find_if(mExternalQueues.begin(),
+-                           mExternalQueues.end(),
+-                           [&q] (const QWaylandDisplay::FrameQueue &other){ return other.queue == q.queue; });
+-    Q_ASSERT(it != mExternalQueues.end());
+-    mExternalQueues.erase(it);
+-    if (q.queue != nullptr)
+-        wl_event_queue_destroy(q.queue);
+-    delete q.mutex;
++    m_eventThread->readAndDispatchEvents();
+ }
+ 
+-QWaylandDisplay::FrameQueue QWaylandDisplay::createFrameQueue()
++// We have to wait until we have an eventDispatcher before creating the eventThread,
++// otherwise forceRoundTrip() may block inside _events_read() because eventThread is
++// polling.
++void QWaylandDisplay::initEventThread()
+ {
+-    QWriteLocker locker(&m_frameQueueLock);
+-    FrameQueue q{createEventQueue()};
+-    mExternalQueues.append(q);
+-    return q;
+-}
++    m_eventThread.reset(
++            new EventThread(mDisplay, /* default queue */ nullptr, EventThread::EmitToDispatch));
++    connect(m_eventThread.get(), &EventThread::needReadAndDispatch, this,
++            &QWaylandDisplay::flushRequests, Qt::QueuedConnection);
++    m_eventThread->start();
+ 
+-wl_event_queue *QWaylandDisplay::createEventQueue()
+-{
+-    return wl_display_create_queue(mDisplay);
++    // wl_display_disconnect() free this.
++    m_frameEventQueue = wl_display_create_queue(mDisplay);
++    m_frameEventQueueThread.reset(
++            new EventThread(mDisplay, m_frameEventQueue, EventThread::SelfDispatch));
++    m_frameEventQueueThread->start();
+ }
+ 
+-void QWaylandDisplay::dispatchQueueWhile(wl_event_queue *queue, std::function<bool ()> condition, int timeout)
++void QWaylandDisplay::blockingReadEvents()
+ {
+-    if (!condition())
+-        return;
+-
+-    QElapsedTimer timer;
+-    timer.start();
+-    struct pollfd pFd = qt_make_pollfd(wl_display_get_fd(mDisplay), POLLIN);
+-    while (timeout == -1 || timer.elapsed() < timeout) {
+-        while (wl_display_prepare_read_queue(mDisplay, queue) != 0)
+-            wl_display_dispatch_queue_pending(mDisplay, queue);
+-
+-        wl_display_flush(mDisplay);
+-
+-        const int remaining = qMax(timeout - timer.elapsed(), 0ll);
+-        const int pollTimeout = timeout == -1 ? -1 : remaining;
+-        if (qt_poll_msecs(&pFd, 1, pollTimeout) > 0)
+-            wl_display_read_events(mDisplay);
+-        else
+-            wl_display_cancel_read(mDisplay);
+-
+-        if (wl_display_dispatch_queue_pending(mDisplay, queue) < 0)
+-            checkError();
+-
+-        if (!condition())
+-            break;
+-    }
++    if (wl_display_dispatch(mDisplay) < 0)
++        checkWaylandError(mDisplay);
+ }
+ 
+ QWaylandScreen *QWaylandDisplay::screenForOutput(struct wl_output *output) const
+@@ -345,7 +491,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+     if (interface == QStringLiteral("wl_output")) {
+         mWaitingScreens << new QWaylandScreen(this, version, id);
+     } else if (interface == QStringLiteral("wl_compositor")) {
+-        mCompositorVersion = qMin((int)version, 3);
++        mCompositorVersion = qMin((int)version, 4);
+         mCompositor.init(registry, id, mCompositorVersion);
+     } else if (interface == QStringLiteral("wl_shm")) {
+         mShm.reset(new QWaylandShm(this, version, id));
+@@ -354,7 +500,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+         mInputDevices.append(inputDevice);
+ #if QT_CONFIG(wayland_datadevice)
+     } else if (interface == QStringLiteral("wl_data_device_manager")) {
+-        mDndSelectionHandler.reset(new QWaylandDataDeviceManager(this, id));
++        mDndSelectionHandler.reset(new QWaylandDataDeviceManager(this, version, id));
+ #endif
+     } else if (interface == QStringLiteral("qt_surface_extension")) {
+         mWindowExtension.reset(new QtWayland::qt_surface_extension(registry, id, 1));
+@@ -369,6 +515,8 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+ #if QT_CONFIG(wayland_client_primary_selection)
+     } else if (interface == QStringLiteral("zwp_primary_selection_device_manager_v1")) {
+         mPrimarySelectionManager.reset(new QWaylandPrimarySelectionDeviceManagerV1(this, id, 1));
++        for (QWaylandInputDevice *inputDevice : qAsConst(mInputDevices))
++            inputDevice->setPrimarySelectionDevice(mPrimarySelectionManager->createDevice(inputDevice));
+ #endif
+     } else if (interface == QStringLiteral("zwp_text_input_manager_v2") && !mClientSideInputContextRequested) {
+         mTextInputManager.reset(new QtWayland::zwp_text_input_manager_v2(registry, id, 1));
+@@ -427,6 +575,13 @@ void QWaylandDisplay::registry_global_remove(uint32_t id)
+                     inputDevice->setTextInput(nullptr);
+                 mWaylandIntegration->reconfigureInputContext();
+             }
++#if QT_CONFIG(wayland_client_primary_selection)
++            if (global.interface == QStringLiteral("zwp_primary_selection_device_manager_v1")) {
++                mPrimarySelectionManager.reset();
++                for (QWaylandInputDevice *inputDevice : qAsConst(mInputDevices))
++                    inputDevice->setPrimarySelectionDevice(nullptr);
++            }
++#endif
+             mGlobals.removeAt(i);
+             break;
+         }
+@@ -452,9 +607,10 @@ void QWaylandDisplay::addRegistryListener(RegistryListener listener, void *data)
+ 
+ void QWaylandDisplay::removeListener(RegistryListener listener, void *data)
+ {
+-    std::remove_if(mRegistryListeners.begin(), mRegistryListeners.end(), [=](Listener l){
++    auto iter = std::remove_if(mRegistryListeners.begin(), mRegistryListeners.end(), [=](Listener l){
+         return (l.listener == listener && l.data == data);
+     });
++    mRegistryListeners.erase(iter, mRegistryListeners.end());
+ }
+ 
+ uint32_t QWaylandDisplay::currentTimeMillisec()
+@@ -467,50 +623,9 @@ uint32_t QWaylandDisplay::currentTimeMillisec()
+     return 0;
+ }
+ 
+-static void
+-sync_callback(void *data, struct wl_callback *callback, uint32_t serial)
+-{
+-    Q_UNUSED(serial)
+-    bool *done = static_cast<bool *>(data);
+-
+-    *done = true;
+-
+-    // If the wl_callback done event is received after the condition check in the while loop in
+-    // forceRoundTrip(), but before the call to processEvents, the call to processEvents may block
+-    // forever if no more events are posted (eventhough the callback is handled in response to the
+-    // aboutToBlock signal). Hence, we wake up the event dispatcher so forceRoundTrip may return.
+-    // (QTBUG-64696)
+-    if (auto *dispatcher = QThread::currentThread()->eventDispatcher())
+-        dispatcher->wakeUp();
+-
+-    wl_callback_destroy(callback);
+-}
+-
+-static const struct wl_callback_listener sync_listener = {
+-    sync_callback
+-};
+-
+ void QWaylandDisplay::forceRoundTrip()
+ {
+-    // wl_display_roundtrip() works on the main queue only,
+-    // but we use a separate one, so basically reimplement it here
+-    int ret = 0;
+-    bool done = false;
+-    wl_callback *callback = wl_display_sync(mDisplay);
+-    wl_callback_add_listener(callback, &sync_listener, &done);
+-    flushRequests();
+-    if (QThread::currentThread()->eventDispatcher()) {
+-        while (!done && ret >= 0) {
+-            QThread::currentThread()->eventDispatcher()->processEvents(QEventLoop::WaitForMoreEvents);
+-            ret = wl_display_dispatch_pending(mDisplay);
+-        }
+-    } else {
+-        while (!done && ret >= 0)
+-            ret = wl_display_dispatch(mDisplay);
+-    }
+-
+-    if (ret == -1 && !done)
+-        wl_callback_destroy(callback);
++     wl_display_roundtrip(mDisplay);
+ }
+ 
+ bool QWaylandDisplay::supportsWindowDecoration() const
+@@ -574,14 +689,10 @@ void QWaylandDisplay::handleKeyboardFocusChanged(QWaylandInputDevice *inputDevic
+     if (mLastKeyboardFocus == keyboardFocus)
+         return;
+ 
+-    if (mWaylandIntegration->mShellIntegration) {
+-        mWaylandIntegration->mShellIntegration->handleKeyboardFocusChanged(keyboardFocus, mLastKeyboardFocus);
+-    } else {
+-        if (keyboardFocus)
+-            handleWindowActivated(keyboardFocus);
+-        if (mLastKeyboardFocus)
+-            handleWindowDeactivated(mLastKeyboardFocus);
+-    }
++    if (keyboardFocus)
++        handleWindowActivated(keyboardFocus);
++    if (mLastKeyboardFocus)
++        handleWindowDeactivated(mLastKeyboardFocus);
+ 
+     mLastKeyboardFocus = keyboardFocus;
+ }
+@@ -600,6 +711,19 @@ void QWaylandDisplay::handleWaylandSync()
+     QWindow *activeWindow = mActiveWindows.empty() ? nullptr : mActiveWindows.last()->window();
+     if (activeWindow != QGuiApplication::focusWindow())
+         QWindowSystemInterface::handleWindowActivated(activeWindow);
++
++    if (!activeWindow) {
++        if (lastInputDevice()) {
++#if QT_CONFIG(clipboard)
++            if (auto *dataDevice = lastInputDevice()->dataDevice())
++                dataDevice->invalidateSelectionOffer();
++#endif
++#if QT_CONFIG(wayland_client_primary_selection)
++            if (auto *device = lastInputDevice()->primarySelectionDevice())
++                device->invalidateSelectionOffer();
++#endif
++        }
++    }
+ }
+ 
+ const wl_callback_listener QWaylandDisplay::syncCallbackListener = {
+@@ -626,6 +750,13 @@ QWaylandInputDevice *QWaylandDisplay::defaultInputDevice() const
+     return mInputDevices.isEmpty() ? 0 : mInputDevices.first();
+ }
+ 
++bool QWaylandDisplay::isKeyboardAvailable() const
++{
++    return std::any_of(
++            mInputDevices.constBegin(), mInputDevices.constEnd(),
++            [this](const QWaylandInputDevice *device) { return device->keyboard() != nullptr; });
++}
++
+ #if QT_CONFIG(cursor)
+ 
+ QWaylandCursor *QWaylandDisplay::waylandCursor()
+@@ -652,4 +783,6 @@ QWaylandCursorTheme *QWaylandDisplay::loadCursorTheme(const QString &name, int p
+ 
+ } // namespace QtWaylandClient
+ 
++#include "qwaylanddisplay.moc"
++
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/client/qwaylanddisplay_p.h b/qtwayland/src/client/qwaylanddisplay_p.h
+index 3b092bc8..42bc661d 100644
+--- a/qtwayland/src/client/qwaylanddisplay_p.h
++++ b/qtwayland/src/client/qwaylanddisplay_p.h
+@@ -109,6 +109,7 @@ class QWaylandSurface;
+ class QWaylandShellIntegration;
+ class QWaylandCursor;
+ class QWaylandCursorTheme;
++class EventThread;
+ 
+ typedef void (*RegistryListener)(void *data,
+                                  struct wl_registry *registry,
+@@ -120,15 +121,11 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandDisplay : public QObject, public QtWayland
+     Q_OBJECT
+ 
+ public:
+-    struct FrameQueue {
+-        FrameQueue(wl_event_queue *q = nullptr) : queue(q), mutex(new QMutex) {}
+-        wl_event_queue *queue;
+-        QMutex *mutex;
+-    };
+-
+     QWaylandDisplay(QWaylandIntegration *waylandIntegration);
+     ~QWaylandDisplay(void) override;
+ 
++    void initialize();
++
+ #if QT_CONFIG(xkbcommon)
+     struct xkb_context *xkbContext() const { return mXkbContext.get(); }
+ #endif
+@@ -210,11 +207,11 @@ public:
+     void handleKeyboardFocusChanged(QWaylandInputDevice *inputDevice);
+     void handleWindowDestroyed(QWaylandWindow *window);
+ 
+-    wl_event_queue *createEventQueue();
+-    FrameQueue createFrameQueue();
+-    void destroyFrameQueue(const FrameQueue &q);
+-    void dispatchQueueWhile(wl_event_queue *queue, std::function<bool()> condition, int timeout = -1);
++    wl_event_queue *frameEventQueue() { return m_frameEventQueue; };
++
++    bool isKeyboardAvailable() const;
+ 
++    void initEventThread();
+ public slots:
+     void blockingReadEvents();
+     void flushRequests();
+@@ -237,6 +234,9 @@ private:
+     };
+ 
+     struct wl_display *mDisplay = nullptr;
++    QScopedPointer<EventThread> m_eventThread;
++    wl_event_queue *m_frameEventQueue = nullptr;
++    QScopedPointer<EventThread> m_frameEventQueueThread;
+     QtWayland::wl_compositor mCompositor;
+     QScopedPointer<QWaylandShm> mShm;
+     QList<QWaylandScreen *> mWaitingScreens;
+@@ -273,11 +273,9 @@ private:
+     QWaylandInputDevice *mLastInputDevice = nullptr;
+     QPointer<QWaylandWindow> mLastInputWindow;
+     QPointer<QWaylandWindow> mLastKeyboardFocus;
+-    QVector<QWaylandWindow *> mActiveWindows;
+-    QVector<FrameQueue> mExternalQueues;
++    QList<QWaylandWindow *> mActiveWindows;
+     struct wl_callback *mSyncCallback = nullptr;
+     static const wl_callback_listener syncCallbackListener;
+-    QReadWriteLock m_frameQueueLock;
+ 
+     bool mClientSideInputContextRequested = !QPlatformInputContextFactory::requested().isNull();
+ 
+diff --git a/qtwayland/src/client/qwaylanddnd.cpp b/qtwayland/src/client/qwaylanddnd.cpp
+index 6535aa16..7c53f5fa 100644
+--- a/qtwayland/src/client/qwaylanddnd.cpp
++++ b/qtwayland/src/client/qwaylanddnd.cpp
+@@ -66,7 +66,7 @@ void QWaylandDrag::startDrag()
+ {
+     QBasicDrag::startDrag();
+     QWaylandWindow *icon = static_cast<QWaylandWindow *>(shapedPixmapWindow()->handle());
+-    if (m_display->currentInputDevice()->dataDevice()->startDrag(drag()->mimeData(), icon)) {
++    if (m_display->currentInputDevice()->dataDevice()->startDrag(drag()->mimeData(), drag()->supportedActions(), icon)) {
+         icon->addAttachOffset(-drag()->hotSpot());
+     } else {
+         // Cancelling immediately does not work, since the event loop for QDrag::exec is started
+@@ -80,6 +80,9 @@ void QWaylandDrag::cancel()
+     QBasicDrag::cancel();
+ 
+     m_display->currentInputDevice()->dataDevice()->cancelDrag();
++
++    if (drag())
++        drag()->deleteLater();
+ }
+ 
+ void QWaylandDrag::move(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods)
+@@ -103,33 +106,41 @@ void QWaylandDrag::endDrag()
+     m_display->currentInputDevice()->handleEndDrag();
+ }
+ 
+-void QWaylandDrag::updateTarget(const QString &mimeType)
++void QWaylandDrag::setResponse(bool accepted)
+ {
+-    setCanDrop(!mimeType.isEmpty());
+-
+-    if (canDrop()) {
+-        updateCursor(defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers()));
+-    } else {
+-        updateCursor(Qt::IgnoreAction);
+-    }
++    // This method is used for old DataDevices where the drag action is not communicated
++    Qt::DropAction action = defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers());
++    setResponse(QPlatformDropQtResponse(accepted, action));
+ }
+ 
+-void QWaylandDrag::setResponse(const QPlatformDragQtResponse &response)
++void QWaylandDrag::setResponse(const QPlatformDropQtResponse &response)
+ {
+     setCanDrop(response.isAccepted());
+ 
+     if (canDrop()) {
+-        updateCursor(defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers()));
++        updateCursor(response.acceptedAction());
+     } else {
+         updateCursor(Qt::IgnoreAction);
+     }
+ }
+ 
+-void QWaylandDrag::finishDrag(const QPlatformDropQtResponse &response)
++void QWaylandDrag::setDropResponse(const QPlatformDropQtResponse &response)
+ {
+     setExecutedDropAction(response.acceptedAction());
++}
++
++void QWaylandDrag::finishDrag()
++{
+     QKeyEvent event(QEvent::KeyPress, Qt::Key_Escape, Qt::NoModifier);
+     eventFilter(shapedPixmapWindow(), &event);
++
++    if (drag())
++        drag()->deleteLater();
++}
++
++bool QWaylandDrag::ownsDragObject() const
++{
++    return true;
+ }
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddnd_p.h b/qtwayland/src/client/qwaylanddnd_p.h
+index 474fe2ab..46f629ac 100644
+--- a/qtwayland/src/client/qwaylanddnd_p.h
++++ b/qtwayland/src/client/qwaylanddnd_p.h
+@@ -71,9 +71,10 @@ public:
+     QWaylandDrag(QWaylandDisplay *display);
+     ~QWaylandDrag() override;
+ 
+-    void updateTarget(const QString &mimeType);
+-    void setResponse(const QPlatformDragQtResponse &response);
+-    void finishDrag(const QPlatformDropQtResponse &response);
++    void setResponse(bool accepted);
++    void setResponse(const QPlatformDropQtResponse &response);
++    void setDropResponse(const QPlatformDropQtResponse &response);
++    void finishDrag();
+ 
+ protected:
+     void startDrag() override;
+@@ -82,6 +83,7 @@ protected:
+     void drop(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods) override;
+     void endDrag() override;
+ 
++    bool ownsDragObject() const override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+diff --git a/qtwayland/src/client/qwaylandinputdevice.cpp b/qtwayland/src/client/qwaylandinputdevice.cpp
+index 613fe862..4b90de84 100644
+--- a/qtwayland/src/client/qwaylandinputdevice.cpp
++++ b/qtwayland/src/client/qwaylandinputdevice.cpp
+@@ -685,6 +685,11 @@ public:
+ 
+ void QWaylandInputDevice::Pointer::pointer_leave(uint32_t time, struct wl_surface *surface)
+ {
++    invalidateFocus();
++    mButtons = Qt::NoButton;
++
++    mParent->mTime = time;
++
+     // The event may arrive after destroying the window, indicated by
+     // a null surface.
+     if (!surface)
+@@ -696,11 +701,6 @@ void QWaylandInputDevice::Pointer::pointer_leave(uint32_t time, struct wl_surfac
+ 
+     if (!QWaylandWindow::mouseGrab())
+         setFrameEvent(new LeaveEvent(window, mSurfacePos, mGlobalPos));
+-
+-    invalidateFocus();
+-    mButtons = Qt::NoButton;
+-
+-    mParent->mTime = time;
+ }
+ 
+ class MotionEvent : public QWaylandPointerEvent
+@@ -1300,14 +1300,6 @@ void QWaylandInputDevice::Keyboard::handleFocusDestroyed()
+ void QWaylandInputDevice::Keyboard::handleFocusLost()
+ {
+     mFocus = nullptr;
+-#if QT_CONFIG(clipboard)
+-    if (auto *dataDevice = mParent->dataDevice())
+-        dataDevice->invalidateSelectionOffer();
+-#endif
+-#if QT_CONFIG(wayland_client_primary_selection)
+-    if (auto *device = mParent->primarySelectionDevice())
+-        device->invalidateSelectionOffer();
+-#endif
+     mParent->mQDisplay->handleKeyboardFocusChanged(mParent);
+     mRepeatTimer.stop();
+ }
+@@ -1396,6 +1388,7 @@ void QWaylandInputDevice::Touch::touch_cancel()
+     if (touchExt)
+         touchExt->touchCanceled();
+ 
++    mFocus = nullptr;
+     QWindowSystemInterface::handleTouchCancelEvent(nullptr, mParent->mTouchDevice);
+ }
+ 
+diff --git a/qtwayland/src/client/qwaylandintegration.cpp b/qtwayland/src/client/qwaylandintegration.cpp
+index c53ccb78..54861600 100644
+--- a/qtwayland/src/client/qwaylandintegration.cpp
++++ b/qtwayland/src/client/qwaylandintegration.cpp
+@@ -125,6 +125,9 @@ QWaylandIntegration::QWaylandIntegration()
+ #endif
+ 
+     reconfigureInputContext();
++
++    QWaylandWindow::fixedToplevelPositions =
++            !qEnvironmentVariableIsSet("QT_WAYLAND_DISABLE_FIXED_POSITIONS");
+ }
+ 
+ QWaylandIntegration::~QWaylandIntegration()
+@@ -192,14 +195,18 @@ QAbstractEventDispatcher *QWaylandIntegration::createEventDispatcher() const
+ 
+ void QWaylandIntegration::initialize()
+ {
++    mDisplay->initEventThread();
++
++    // Call after eventDispatcher is fully connected, for QWaylandDisplay::forceRoundTrip()
++    mDisplay->initialize();
++
++    // But the aboutToBlock() and awake() should be connected after initializePlatform().
++    // Otherwise the connected flushRequests() may consumes up all events before processEvents starts to wait,
++    // so that processEvents(QEventLoop::WaitForMoreEvents) may be blocked in the forceRoundTrip().
+     QAbstractEventDispatcher *dispatcher = QGuiApplicationPrivate::eventDispatcher;
+     QObject::connect(dispatcher, SIGNAL(aboutToBlock()), mDisplay.data(), SLOT(flushRequests()));
+     QObject::connect(dispatcher, SIGNAL(awake()), mDisplay.data(), SLOT(flushRequests()));
+ 
+-    int fd = wl_display_get_fd(mDisplay->wl_display());
+-    QSocketNotifier *sn = new QSocketNotifier(fd, QSocketNotifier::Read, mDisplay.data());
+-    QObject::connect(sn, SIGNAL(activated(QSocketDescriptor)), mDisplay.data(), SLOT(flushRequests()));
+-
+     // Qt does not support running with no screens
+     mDisplay->ensureScreen();
+ }
+@@ -262,6 +269,14 @@ QWaylandDisplay *QWaylandIntegration::display() const
+     return mDisplay.data();
+ }
+ 
++Qt::KeyboardModifiers QWaylandIntegration::queryKeyboardModifiers() const
++{
++    if (auto *seat = mDisplay->currentInputDevice()) {
++        return seat->modifiers();
++    }
++    return Qt::NoModifier;
++}
++
+ QList<int> QWaylandIntegration::possibleKeys(const QKeyEvent *event) const
+ {
+     if (auto *seat = mDisplay->currentInputDevice())
+@@ -479,7 +494,7 @@ void QWaylandIntegration::reconfigureInputContext()
+     }
+ #endif
+ 
+-    qCDebug(lcQpaWayland) << "using input method:" << inputContext()->metaObject()->className();
++    qCDebug(lcQpaWayland) << "using input method:" << (inputContext() ? inputContext()->metaObject()->className() : "<none>");
+ }
+ 
+ QWaylandShellIntegration *QWaylandIntegration::createShellIntegration(const QString &integrationName)
+diff --git a/qtwayland/src/client/qwaylandintegration_p.h b/qtwayland/src/client/qwaylandintegration_p.h
+index ff70ae25..73b80658 100644
+--- a/qtwayland/src/client/qwaylandintegration_p.h
++++ b/qtwayland/src/client/qwaylandintegration_p.h
+@@ -107,6 +107,8 @@ public:
+ 
+     QWaylandDisplay *display() const;
+ 
++    Qt::KeyboardModifiers queryKeyboardModifiers() const override;
++
+     QList<int> possibleKeys(const QKeyEvent *event) const override;
+ 
+     QStringList themeNames() const override;
+diff --git a/qtwayland/src/client/qwaylandprimaryselectionv1.cpp b/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
+index 832f9678..ea508771 100644
+--- a/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
++++ b/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
+@@ -54,11 +54,6 @@ QWaylandPrimarySelectionDeviceManagerV1::QWaylandPrimarySelectionDeviceManagerV1
+     : zwp_primary_selection_device_manager_v1(display->wl_registry(), id, qMin(version, uint(1)))
+     , m_display(display)
+ {
+-    // Create devices for all seats.
+-    // This only works if we get the global before all devices
+-    const auto seats = m_display->inputDevices();
+-    for (auto *seat : seats)
+-        seat->setPrimarySelectionDevice(createDevice(seat));
+ }
+ 
+ QWaylandPrimarySelectionDeviceV1 *QWaylandPrimarySelectionDeviceManagerV1::createDevice(QWaylandInputDevice *seat)
+diff --git a/qtwayland/src/client/qwaylandscreen.cpp b/qtwayland/src/client/qwaylandscreen.cpp
+index 6cb337de..5537dafd 100644
+--- a/qtwayland/src/client/qwaylandscreen.cpp
++++ b/qtwayland/src/client/qwaylandscreen.cpp
+@@ -60,7 +60,7 @@ QWaylandXdgOutputManagerV1::QWaylandXdgOutputManagerV1(QWaylandDisplay* display,
+ }
+ 
+ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uint32_t id)
+-    : QtWayland::wl_output(waylandDisplay->wl_registry(), id, qMin(version, 2))
++    : QtWayland::wl_output(waylandDisplay->wl_registry(), id, qMin(version, 3))
+     , m_outputId(id)
+     , mWaylandDisplay(waylandDisplay)
+     , mOutputName(QStringLiteral("Screen%1").arg(id))
+@@ -72,7 +72,7 @@ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uin
+         qCWarning(lcQpaWayland) << "wl_output done event not supported by compositor,"
+                                 << "QScreen may not work correctly";
+         mWaylandDisplay->forceRoundTrip(); // Give the compositor a chance to send geometry etc.
+-        mOutputDone = true; // Fake the done event
++        mProcessedEvents |= OutputDoneEvent; // Fake the done event
+         maybeInitialize();
+     }
+ }
+@@ -81,16 +81,29 @@ QWaylandScreen::~QWaylandScreen()
+ {
+     if (zxdg_output_v1::isInitialized())
+         zxdg_output_v1::destroy();
++    if (wl_output::isInitialized() && wl_output_get_version(wl_output::object()) >= WL_OUTPUT_RELEASE_SINCE_VERSION)
++        wl_output::release();
++}
++
++uint QWaylandScreen::requiredEvents() const
++{
++    uint ret = OutputDoneEvent;
++
++    if (mWaylandDisplay->xdgOutputManager()) {
++        ret |= XdgOutputNameEvent;
++
++        if (mWaylandDisplay->xdgOutputManager()->version() < 3)
++            ret |= XdgOutputDoneEvent;
++    }
++    return ret;
+ }
+ 
+ void QWaylandScreen::maybeInitialize()
+ {
+     Q_ASSERT(!mInitialized);
+ 
+-    if (!mOutputDone)
+-        return;
+-
+-    if (mWaylandDisplay->xdgOutputManager() && !mXdgOutputDone)
++    const uint requiredEvents = this->requiredEvents();
++    if ((mProcessedEvents & requiredEvents) != requiredEvents)
+         return;
+ 
+     mInitialized = true;
+@@ -276,9 +289,8 @@ void QWaylandScreen::output_scale(int32_t factor)
+ 
+ void QWaylandScreen::output_done()
+ {
+-    mOutputDone = true;
+-    if (zxdg_output_v1::isInitialized() && mWaylandDisplay->xdgOutputManager()->version() >= 3)
+-        mXdgOutputDone = true;
++    mProcessedEvents |= OutputDoneEvent;
++
+     if (mInitialized) {
+         updateOutputProperties();
+         if (zxdg_output_v1::isInitialized())
+@@ -339,7 +351,7 @@ void QWaylandScreen::zxdg_output_v1_done()
+     if (Q_UNLIKELY(mWaylandDisplay->xdgOutputManager()->version() >= 3))
+         qWarning(lcQpaWayland) << "zxdg_output_v1.done received on version 3 or newer, this is most likely a bug in the compositor";
+ 
+-    mXdgOutputDone = true;
++    mProcessedEvents |= XdgOutputDoneEvent;
+     if (mInitialized)
+         updateXdgOutputProperties();
+     else
+@@ -348,7 +360,11 @@ void QWaylandScreen::zxdg_output_v1_done()
+ 
+ void QWaylandScreen::zxdg_output_v1_name(const QString &name)
+ {
++    if (Q_UNLIKELY(mInitialized))
++        qWarning(lcQpaWayland) << "zxdg_output_v1.name received after output has been initialized, this is most likely a bug in the compositor";
++
+     mOutputName = name;
++    mProcessedEvents |= XdgOutputNameEvent;
+ }
+ 
+ void QWaylandScreen::updateXdgOutputProperties()
+diff --git a/qtwayland/src/client/qwaylandscreen_p.h b/qtwayland/src/client/qwaylandscreen_p.h
+index df1c94f2..050cfdc0 100644
+--- a/qtwayland/src/client/qwaylandscreen_p.h
++++ b/qtwayland/src/client/qwaylandscreen_p.h
+@@ -116,6 +116,13 @@ public:
+     static QWaylandScreen *fromWlOutput(::wl_output *output);
+ 
+ private:
++    enum Event : uint {
++        XdgOutputDoneEvent = 0x1,
++        OutputDoneEvent = 0x2,
++        XdgOutputNameEvent = 0x4,
++    };
++    uint requiredEvents() const;
++
+     void output_mode(uint32_t flags, int width, int height, int refresh) override;
+     void output_geometry(int32_t x, int32_t y,
+                          int32_t width, int32_t height,
+@@ -148,8 +155,7 @@ private:
+     QSize mPhysicalSize;
+     QString mOutputName;
+     Qt::ScreenOrientation m_orientation = Qt::PrimaryOrientation;
+-    bool mOutputDone = false;
+-    bool mXdgOutputDone = false;
++    uint mProcessedEvents = 0;
+     bool mInitialized = false;
+ 
+ #if QT_CONFIG(cursor)
+diff --git a/qtwayland/src/client/qwaylandshmbackingstore.cpp b/qtwayland/src/client/qwaylandshmbackingstore.cpp
+index dc7ff670..41cffdf7 100644
+--- a/qtwayland/src/client/qwaylandshmbackingstore.cpp
++++ b/qtwayland/src/client/qwaylandshmbackingstore.cpp
+@@ -52,6 +52,7 @@
+ 
+ #include <QtWaylandClient/private/wayland-wayland-client-protocol.h>
+ 
++#include <fcntl.h>
+ #include <unistd.h>
+ #include <sys/mman.h>
+ 
+@@ -61,6 +62,9 @@
+ #  ifndef MFD_CLOEXEC
+ #    define MFD_CLOEXEC     0x0001U
+ #  endif
++#  ifndef MFD_ALLOW_SEALING
++#    define MFD_ALLOW_SEALING 0x0002U
++#  endif
+ #endif
+ 
+ QT_BEGIN_NAMESPACE
+@@ -74,8 +78,10 @@ QWaylandShmBuffer::QWaylandShmBuffer(QWaylandDisplay *display,
+     int alloc = stride * size.height();
+     int fd = -1;
+ 
+-#ifdef SYS_memfd_create
+-    fd = syscall(SYS_memfd_create, "wayland-shm", MFD_CLOEXEC);
++#if defined(SYS_memfd_create) && defined(F_SEAL_SEAL)
++    fd = syscall(SYS_memfd_create, "wayland-shm", MFD_CLOEXEC | MFD_ALLOW_SEALING);
++    if (fd >= 0)
++        fcntl(fd, F_ADD_SEALS, F_SEAL_SHRINK | F_SEAL_SEAL);
+ #endif
+ 
+     QScopedPointer<QFile> filePointer;
+diff --git a/qtwayland/src/client/qwaylandwindow.cpp b/qtwayland/src/client/qwaylandwindow.cpp
+index cb82857a..fb2c59dc 100644
+--- a/qtwayland/src/client/qwaylandwindow.cpp
++++ b/qtwayland/src/client/qwaylandwindow.cpp
+@@ -76,7 +76,6 @@ QWaylandWindow *QWaylandWindow::mMouseGrab = nullptr;
+ QWaylandWindow::QWaylandWindow(QWindow *window, QWaylandDisplay *display)
+     : QPlatformWindow(window)
+     , mDisplay(display)
+-    , mFrameQueue(mDisplay->createFrameQueue())
+     , mResizeAfterSwap(qEnvironmentVariableIsSet("QT_WAYLAND_RESIZE_AFTER_SWAP"))
+ {
+     {
+@@ -95,9 +94,6 @@ QWaylandWindow::QWaylandWindow(QWindow *window, QWaylandDisplay *display)
+ 
+ QWaylandWindow::~QWaylandWindow()
+ {
+-    mDisplay->destroyFrameQueue(mFrameQueue);
+-    mDisplay->handleWindowDestroyed(this);
+-
+     delete mWindowDecoration;
+ 
+     if (mSurface)
+@@ -243,6 +239,7 @@ bool QWaylandWindow::shouldCreateSubSurface() const
+ 
+ void QWaylandWindow::reset()
+ {
++    closeChildPopups();
+     delete mShellSurface;
+     mShellSurface = nullptr;
+     delete mSubSurfaceWindow;
+@@ -255,17 +252,22 @@ void QWaylandWindow::reset()
+         mSurface.reset();
+     }
+ 
+-    if (mFrameCallback) {
+-        wl_callback_destroy(mFrameCallback);
+-        mFrameCallback = nullptr;
+-    }
++    {
++        QMutexLocker lock(&mFrameSyncMutex);
++        if (mFrameCallback) {
++            wl_callback_destroy(mFrameCallback);
++            mFrameCallback = nullptr;
++        }
+ 
+-    mFrameCallbackElapsedTimer.invalidate();
+-    mWaitingForFrameCallback = false;
++        mFrameCallbackElapsedTimer.invalidate();
++        mWaitingForFrameCallback = false;
++    }
+     mFrameCallbackTimedOut = false;
+ 
+     mMask = QRegion();
+     mQueuedBuffer = nullptr;
++
++    mDisplay->handleWindowDestroyed(this);
+ }
+ 
+ QWaylandWindow *QWaylandWindow::fromWlSurface(::wl_surface *surface)
+@@ -351,19 +353,25 @@ void QWaylandWindow::setGeometry_helper(const QRect &rect)
+     }
+ }
+ 
+-void QWaylandWindow::setGeometry(const QRect &rect)
++void QWaylandWindow::setGeometry(const QRect &r)
+ {
++    auto rect = r;
++    if (fixedToplevelPositions && !QPlatformWindow::parent() && window()->type() != Qt::Popup
++        && window()->type() != Qt::ToolTip) {
++        rect.moveTo(screen()->geometry().topLeft());
++    }
+     setGeometry_helper(rect);
+ 
+     if (window()->isVisible() && rect.isValid()) {
+         if (mWindowDecoration)
+             mWindowDecoration->update();
+ 
+-        if (mResizeAfterSwap && windowType() == Egl && mSentInitialResize)
++        if (mResizeAfterSwap && windowType() == Egl && mSentInitialResize) {
++            QMutexLocker lock(&mResizeLock);
+             mResizeDirty = true;
+-        else
++        } else {
+             QWindowSystemInterface::handleGeometryChange(window(), geometry());
+-
++        }
+         mSentInitialResize = true;
+     }
+     QRect exposeGeometry(QPoint(), geometry().size());
+@@ -374,7 +382,7 @@ void QWaylandWindow::setGeometry(const QRect &rect)
+         mShellSurface->setWindowGeometry(windowContentGeometry());
+ 
+     if (isOpaque() && mMask.isEmpty())
+-        setOpaqueArea(rect);
++        setOpaqueArea(QRect(QPoint(0, 0), rect.size()));
+ }
+ 
+ void QWaylandWindow::resizeFromApplyConfigure(const QSize &sizeWithMargins, const QPoint &offset)
+@@ -399,21 +407,6 @@ void QWaylandWindow::sendExposeEvent(const QRect &rect)
+     mLastExposeGeometry = rect;
+ }
+ 
+-
+-static QVector<QPointer<QWaylandWindow>> activePopups;
+-
+-void QWaylandWindow::closePopups(QWaylandWindow *parent)
+-{
+-    while (!activePopups.isEmpty()) {
+-        auto popup = activePopups.takeLast();
+-        if (popup.isNull())
+-            continue;
+-        if (popup.data() == parent)
+-            return;
+-        popup->reset();
+-    }
+-}
+-
+ QPlatformScreen *QWaylandWindow::calculateScreenFromSurfaceEvents() const
+ {
+     QReadLocker lock(&mSurfaceLock);
+@@ -433,10 +426,7 @@ void QWaylandWindow::setVisible(bool visible)
+     lastVisible = visible;
+ 
+     if (visible) {
+-        if (window()->type() == Qt::Popup || window()->type() == Qt::ToolTip)
+-            activePopups << this;
+         initWindow();
+-        mDisplay->flushRequests();
+ 
+         setGeometry(windowGeometry());
+         // Don't flush the events here, or else the newly visible window may start drawing, but since
+@@ -444,7 +434,6 @@ void QWaylandWindow::setVisible(bool visible)
+         // QWaylandShmBackingStore::beginPaint().
+     } else {
+         sendExposeEvent(QRect());
+-        closePopups(this);
+         reset();
+     }
+ }
+@@ -556,12 +545,12 @@ void QWaylandWindow::sendRecursiveExposeEvent()
+ 
+ void QWaylandWindow::attach(QWaylandBuffer *buffer, int x, int y)
+ {
+-    Q_ASSERT(!buffer->committed());
+     QReadLocker locker(&mSurfaceLock);
+     if (mSurface == nullptr)
+         return;
+ 
+     if (buffer) {
++        Q_ASSERT(!buffer->committed());
+         handleUpdate();
+         buffer->setBusy();
+ 
+@@ -583,7 +572,11 @@ void QWaylandWindow::damage(const QRect &rect)
+     if (mSurface == nullptr)
+         return;
+ 
+-    mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    const int s = scale();
++    if (mDisplay->compositorVersion() >= 4)
++        mSurface->damage_buffer(s * rect.x(), s * rect.y(), s * rect.width(), s * rect.height());
++    else
++        mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
+ }
+ 
+ void QWaylandWindow::safeCommit(QWaylandBuffer *buffer, const QRegion &damage)
+@@ -619,8 +612,14 @@ void QWaylandWindow::commit(QWaylandBuffer *buffer, const QRegion &damage)
+         return;
+ 
+     attachOffset(buffer);
+-    for (const QRect &rect: damage)
+-        mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    if (mDisplay->compositorVersion() >= 4) {
++        const int s = scale();
++        for (const QRect &rect: damage)
++            mSurface->damage_buffer(s * rect.x(), s * rect.y(), s * rect.width(), s * rect.height());
++    } else {
++        for (const QRect &rect: damage)
++            mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    }
+     Q_ASSERT(!buffer->committed());
+     buffer->setCommitted();
+     mSurface->commit();
+@@ -635,42 +634,53 @@ void QWaylandWindow::commit()
+ 
+ const wl_callback_listener QWaylandWindow::callbackListener = {
+     [](void *data, wl_callback *callback, uint32_t time) {
+-        Q_UNUSED(callback);
+         Q_UNUSED(time);
+         auto *window = static_cast<QWaylandWindow*>(data);
+-        window->handleFrameCallback();
++        window->handleFrameCallback(callback);
+     }
+ };
+ 
+-void QWaylandWindow::handleFrameCallback()
++void QWaylandWindow::handleFrameCallback(wl_callback* callback)
+ {
++    QMutexLocker locker(&mFrameSyncMutex);
++    if (!mFrameCallback) {
++        // This means the callback is already unset by QWaylandWindow::reset.
++        // The wl_callback object will be destroyed there too.
++        return;
++    }
++    Q_ASSERT(callback == mFrameCallback);
++    wl_callback_destroy(callback);
++    mFrameCallback = nullptr;
++
+     mWaitingForFrameCallback = false;
+     mFrameCallbackElapsedTimer.invalidate();
+ 
+     // The rest can wait until we can run it on the correct thread
+-    if (!mWaitingForUpdateDelivery) {
+-        auto doHandleExpose = [this]() {
+-            bool wasExposed = isExposed();
+-            mFrameCallbackTimedOut = false;
+-            if (!wasExposed && isExposed()) // Did setting mFrameCallbackTimedOut make the window exposed?
+-                sendExposeEvent(QRect(QPoint(), geometry().size()));
+-            if (wasExposed && hasPendingUpdateRequest())
+-                deliverUpdateRequest();
+-
+-            mWaitingForUpdateDelivery = false;
+-        };
++    auto doHandleExpose = [this]() {
++        mWaitingForUpdateDelivery.storeRelease(false);
++        bool wasExposed = isExposed();
++        mFrameCallbackTimedOut = false;
++        if (!wasExposed && isExposed()) // Did setting mFrameCallbackTimedOut make the window exposed?
++            sendExposeEvent(QRect(QPoint(), geometry().size()));
++        if (wasExposed && hasPendingUpdateRequest())
++            deliverUpdateRequest();
++    };
+ 
++    if (mWaitingForUpdateDelivery.testAndSetAcquire(false, true)) {
+         // Queued connection, to make sure we don't call handleUpdate() from inside waitForFrameSync()
+         // in the single-threaded case.
+-        mWaitingForUpdateDelivery = true;
+         QMetaObject::invokeMethod(this, doHandleExpose, Qt::QueuedConnection);
+     }
++
++    mFrameSyncWait.notify_all();
+ }
+ 
+ bool QWaylandWindow::waitForFrameSync(int timeout)
+ {
+-    QMutexLocker locker(mFrameQueue.mutex);
+-    mDisplay->dispatchQueueWhile(mFrameQueue.queue, [&]() { return mWaitingForFrameCallback; }, timeout);
++    QMutexLocker locker(&mFrameSyncMutex);
++
++    QDeadlineTimer deadline(timeout);
++    while (mWaitingForFrameCallback && mFrameSyncWait.wait(&mFrameSyncMutex, deadline)) { }
+ 
+     if (mWaitingForFrameCallback) {
+         qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
+@@ -868,6 +878,17 @@ bool QWaylandWindow::createDecoration()
+             subsurf->set_position(pos.x() + m.left(), pos.y() + m.top());
+         }
+         sendExposeEvent(QRect(QPoint(), geometry().size()));
++
++        // This is a special case where the buffer is recreated, but since
++        // the content rect remains the same, the widgets remain the same
++        // size and are not redrawn, leaving the new buffer empty. As a simple
++        // work-around, we trigger a full extra update whenever the client-side
++        // window decorations are toggled while the window is showing.
++        // Note: createDecoration() is sometimes called from the render thread
++        // of Qt Quick. This is essentially wrong and could potentially cause problems,
++        // but until the underlying issue has been fixed, we have to use invokeMethod()
++        // here to avoid asserts.
++        QMetaObject::invokeMethod(window(), &QWindow::requestUpdate);
+     }
+ 
+     return mWindowDecoration;
+@@ -1023,6 +1044,13 @@ void QWaylandWindow::handleScreensChanged()
+ 
+     QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->QPlatformScreen::screen());
+     mLastReportedScreen = newScreen;
++    if (fixedToplevelPositions && !QPlatformWindow::parent() && window()->type() != Qt::Popup
++        && window()->type() != Qt::ToolTip
++        && geometry().topLeft() != newScreen->geometry().topLeft()) {
++        auto geometry = this->geometry();
++        geometry.moveTo(newScreen->geometry().topLeft());
++        setGeometry(geometry);
++    }
+ 
+     int scale = newScreen->isPlaceholder() ? 1 : static_cast<QWaylandScreen *>(newScreen)->scale();
+     if (scale != mScale) {
+@@ -1094,10 +1122,18 @@ bool QWaylandWindow::setMouseGrabEnabled(bool grab)
+     return true;
+ }
+ 
++Qt::WindowStates QWaylandWindow::windowStates() const
++{
++    return mLastReportedWindowStates;
++}
++
+ void QWaylandWindow::handleWindowStatesChanged(Qt::WindowStates states)
+ {
+     createDecoration();
+-    QWindowSystemInterface::handleWindowStateChanged(window(), states, mLastReportedWindowStates);
++    Qt::WindowStates statesWithoutActive = states & ~Qt::WindowActive;
++    Qt::WindowStates lastStatesWithoutActive = mLastReportedWindowStates & ~Qt::WindowActive;
++    QWindowSystemInterface::handleWindowStateChanged(window(), statesWithoutActive,
++                                                     lastStatesWithoutActive);
+     mLastReportedWindowStates = states;
+ }
+ 
+@@ -1139,19 +1175,24 @@ void QWaylandWindow::timerEvent(QTimerEvent *event)
+     if (event->timerId() != mFrameCallbackCheckIntervalTimerId)
+         return;
+ 
+-    bool callbackTimerExpired = mFrameCallbackElapsedTimer.hasExpired(mFrameCallbackTimeout);
+-    if (!mFrameCallbackElapsedTimer.isValid() || callbackTimerExpired ) {
+-        killTimer(mFrameCallbackCheckIntervalTimerId);
+-        mFrameCallbackCheckIntervalTimerId = -1;
+-    }
+-    if (mFrameCallbackElapsedTimer.isValid() && callbackTimerExpired) {
+-        mFrameCallbackElapsedTimer.invalidate();
++    {
++        QMutexLocker lock(&mFrameSyncMutex);
+ 
+-        qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
+-        mFrameCallbackTimedOut = true;
+-        mWaitingForUpdate = false;
+-        sendExposeEvent(QRect());
++        bool callbackTimerExpired = mFrameCallbackElapsedTimer.hasExpired(mFrameCallbackTimeout);
++        if (!mFrameCallbackElapsedTimer.isValid() || callbackTimerExpired ) {
++            killTimer(mFrameCallbackCheckIntervalTimerId);
++            mFrameCallbackCheckIntervalTimerId = -1;
++        }
++        if (!mFrameCallbackElapsedTimer.isValid() || !callbackTimerExpired) {
++            return;
++        }
++        mFrameCallbackElapsedTimer.invalidate();
+     }
++
++    qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
++    mFrameCallbackTimedOut = true;
++    mWaitingForUpdate = false;
++    sendExposeEvent(QRect());
+ }
+ 
+ void QWaylandWindow::requestUpdate()
+@@ -1160,8 +1201,11 @@ void QWaylandWindow::requestUpdate()
+     Q_ASSERT(hasPendingUpdateRequest()); // should be set by QPA
+ 
+     // If we have a frame callback all is good and will be taken care of there
+-    if (mWaitingForFrameCallback)
+-        return;
++    {
++        QMutexLocker locker(&mFrameSyncMutex);
++        if (mWaitingForFrameCallback)
++            return;
++    }
+ 
+     // If we've already called deliverUpdateRequest(), but haven't seen any attach+commit/swap yet
+     // This is a somewhat redundant behavior and might indicate a bug in the calling code, so log
+@@ -1174,7 +1218,12 @@ void QWaylandWindow::requestUpdate()
+     // so use invokeMethod to delay the delivery a bit.
+     QMetaObject::invokeMethod(this, [this] {
+         // Things might have changed in the meantime
+-        if (hasPendingUpdateRequest() && !mWaitingForFrameCallback)
++        {
++            QMutexLocker locker(&mFrameSyncMutex);
++            if (mWaitingForFrameCallback)
++                return;
++        }
++        if (hasPendingUpdateRequest())
+             deliverUpdateRequest();
+     }, Qt::QueuedConnection);
+ }
+@@ -1185,19 +1234,18 @@ void QWaylandWindow::requestUpdate()
+ void QWaylandWindow::handleUpdate()
+ {
+     qCDebug(lcWaylandBackingstore) << "handleUpdate" << QThread::currentThread();
++
+     // TODO: Should sync subsurfaces avoid requesting frame callbacks?
+     QReadLocker lock(&mSurfaceLock);
+     if (!mSurface)
+         return;
+ 
+-    if (mFrameCallback) {
+-        wl_callback_destroy(mFrameCallback);
+-        mFrameCallback = nullptr;
+-    }
++    QMutexLocker locker(&mFrameSyncMutex);
++    if (mWaitingForFrameCallback)
++        return;
+ 
+-    QMutexLocker locker(mFrameQueue.mutex);
+     struct ::wl_surface *wrappedSurface = reinterpret_cast<struct ::wl_surface *>(wl_proxy_create_wrapper(mSurface->object()));
+-    wl_proxy_set_queue(reinterpret_cast<wl_proxy *>(wrappedSurface), mFrameQueue.queue);
++    wl_proxy_set_queue(reinterpret_cast<wl_proxy *>(wrappedSurface), mDisplay->frameEventQueue());
+     mFrameCallback = wl_surface_frame(wrappedSurface);
+     wl_proxy_wrapper_destroy(wrappedSurface);
+     wl_callback_add_listener(mFrameCallback, &QWaylandWindow::callbackListener, this);
+@@ -1207,6 +1255,8 @@ void QWaylandWindow::handleUpdate()
+     // Start a timer for handling the case when the compositor stops sending frame callbacks.
+     if (mFrameCallbackTimeout > 0) {
+         QMetaObject::invokeMethod(this, [this] {
++            QMutexLocker locker(&mFrameSyncMutex);
++
+             if (mWaitingForFrameCallback) {
+                 if (mFrameCallbackCheckIntervalTimerId < 0)
+                     mFrameCallbackCheckIntervalTimerId = startTimer(mFrameCallbackTimeout);
+@@ -1267,6 +1317,20 @@ void QWaylandWindow::setOpaqueArea(const QRegion &opaqueArea)
+     wl_region_destroy(region);
+ }
+ 
++void QWaylandWindow::addChildPopup(QWaylandWindow *surface) {
++    mChildPopups.append(surface);
++}
++
++void QWaylandWindow::removeChildPopup(QWaylandWindow *surface) {
++    mChildPopups.removeAll(surface);
++}
++
++void QWaylandWindow::closeChildPopups() {
++    while (!mChildPopups.isEmpty()) {
++        auto popup = mChildPopups.takeLast();
++        popup->reset();
++    }
++}
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/client/qwaylandwindow_p.h b/qtwayland/src/client/qwaylandwindow_p.h
+index 01337cff..2f219d8c 100644
+--- a/qtwayland/src/client/qwaylandwindow_p.h
++++ b/qtwayland/src/client/qwaylandwindow_p.h
+@@ -98,6 +98,9 @@ public:
+     QWaylandWindow(QWindow *window, QWaylandDisplay *display);
+     ~QWaylandWindow() override;
+ 
++    // Keep Toplevels position on the top left corner of their screen
++    static inline bool fixedToplevelPositions = true;
++
+     virtual WindowType windowType() const = 0;
+     virtual void ensureSize();
+     WId winId() const override;
+@@ -148,6 +151,7 @@ public:
+     void setWindowState(Qt::WindowStates states) override;
+     void setWindowFlags(Qt::WindowFlags flags) override;
+     void handleWindowStatesChanged(Qt::WindowStates states);
++    Qt::WindowStates windowStates() const;
+ 
+     void raise() override;
+     void lower() override;
+@@ -206,6 +210,10 @@ public:
+     void handleUpdate();
+     void deliverUpdateRequest() override;
+ 
++    void addChildPopup(QWaylandWindow* child);
++    void removeChildPopup(QWaylandWindow* child);
++    void closeChildPopups();
++
+ public slots:
+     void applyConfigure();
+ 
+@@ -215,7 +223,11 @@ signals:
+ 
+ protected:
+     QWaylandDisplay *mDisplay = nullptr;
++
++    // mSurface can be written by the main thread. Other threads should claim a read lock for access
++    mutable QReadWriteLock mSurfaceLock;
+     QScopedPointer<QWaylandSurface> mSurface;
++
+     QWaylandShellSurface *mShellSurface = nullptr;
+     QWaylandSubSurface *mSubSurfaceWindow = nullptr;
+     QVector<QWaylandSubSurface *> mChildren;
+@@ -225,13 +237,14 @@ protected:
+     Qt::MouseButtons mMousePressedInContentArea = Qt::NoButton;
+ 
+     WId mWindowId;
+-    bool mWaitingForFrameCallback = false;
+     bool mFrameCallbackTimedOut = false; // Whether the frame callback has timed out
+-    bool mWaitingForUpdateDelivery = false;
+     int mFrameCallbackCheckIntervalTimerId = -1;
+-    QElapsedTimer mFrameCallbackElapsedTimer;
+-    struct ::wl_callback *mFrameCallback = nullptr;
+-    QWaylandDisplay::FrameQueue mFrameQueue;
++    QAtomicInt mWaitingForUpdateDelivery = false;
++
++    bool mWaitingForFrameCallback = false; // Protected by mFrameSyncMutex
++    QElapsedTimer mFrameCallbackElapsedTimer; // Protected by mFrameSyncMutex
++    struct ::wl_callback *mFrameCallback = nullptr; // Protected by mFrameSyncMutex
++    QMutex mFrameSyncMutex;
+     QWaitCondition mFrameSyncWait;
+ 
+     // True when we have called deliverRequestUpdate, but the client has not yet attached a new buffer
+@@ -261,6 +274,8 @@ protected:
+     QWaylandBuffer *mQueuedBuffer = nullptr;
+     QRegion mQueuedBufferDamage;
+ 
++    QList<QPointer<QWaylandWindow>> mChildPopups;
++
+ private:
+     void setGeometry_helper(const QRect &rect);
+     void initWindow();
+@@ -283,12 +298,10 @@ private:
+     QRect mLastExposeGeometry;
+ 
+     static const wl_callback_listener callbackListener;
+-    void handleFrameCallback();
++    void handleFrameCallback(struct ::wl_callback* callback);
+ 
+     static QWaylandWindow *mMouseGrab;
+ 
+-    mutable QReadWriteLock mSurfaceLock;
+-
+     friend class QWaylandSubSurface;
+ };
+ 
+diff --git a/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h b/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
+index ccad0048..4cc9b3b8 100644
+--- a/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
++++ b/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
+@@ -73,11 +73,10 @@ public:
+         return true;
+     }
+     virtual QWaylandShellSurface *createShellSurface(QWaylandWindow *window) = 0;
++    // kept for binary compat with layer-shell-qt
+     virtual void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) {
+-        if (newFocus)
+-            m_display->handleWindowActivated(newFocus);
+-        if (oldFocus)
+-            m_display->handleWindowDeactivated(oldFocus);
++        Q_UNUSED(newFocus);
++        Q_UNUSED(oldFocus);
+     }
+     virtual void *nativeResourceForWindow(const QByteArray &resource, QWindow *window) {
+         Q_UNUSED(resource);
+diff --git a/qtwayland/src/compositor/configure.json b/qtwayland/src/compositor/configure.json
+index bcfd5215..da95d07b 100644
+--- a/qtwayland/src/compositor/configure.json
++++ b/qtwayland/src/compositor/configure.json
+@@ -7,6 +7,31 @@
+     "testDir": "../../config.tests",
+ 
+     "libraries": {
++        "wayland-client": {
++            "label": "Wayland client library",
++            "headers": "wayland-version.h",
++            "test": {
++                "main": [
++                    "#if WAYLAND_VERSION_MAJOR < 1",
++                    "# error Wayland 1.8.0 or higher required",
++                    "#endif",
++                    "#if WAYLAND_VERSION_MAJOR == 1",
++                    "# if WAYLAND_VERSION_MINOR < 8",
++                    "#  error Wayland 1.8.0 or higher required",
++                    "# endif",
++                    "# if WAYLAND_VERSION_MINOR == 8",
++                    "#  if WAYLAND_VERSION_MICRO < 0",
++                    "#   error Wayland 1.8.0 or higher required",
++                    "#  endif",
++                    "# endif",
++                    "#endif"
++                 ]
++            },
++            "sources": [
++                { "type": "pkgConfig", "args": "wayland-client" },
++                "-lwayland-client"
++            ]
++        },
+         "wayland-server": {
+             "label": "wayland-server",
+             "headers": "wayland-version.h",
+@@ -151,8 +176,7 @@
+                     "#endif"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "dmabuf-client-buffer": {
+             "label": "Linux Client dma-buf Buffer Sharing",
+@@ -176,8 +200,7 @@
+                     "return 0;"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "vulkan-server-buffer": {
+             "label": "Vulkan Buffer Sharing",
+@@ -195,7 +218,8 @@
+                     "exportAllocInfo.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR;",
+                     "return 0;"
+                 ]
+-            }
++            },
++            "use": "wayland-client"
+         }
+     },
+ 
+diff --git a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
+index 7889f575..64140672 100644
+--- a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
++++ b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
+@@ -40,6 +40,7 @@
+ #include "qwaylandeglwindow.h"
+ 
+ #include <QtWaylandClient/private/qwaylandscreen_p.h>
++#include <QtWaylandClient/private/qwaylandsurface_p.h>
+ #include "qwaylandglcontext.h"
+ 
+ #include <QtEglSupport/private/qeglconvenience_p.h>
+@@ -124,6 +125,7 @@ void QWaylandEglWindow::updateSurface(bool create)
+         }
+         mOffset = QPoint();
+     } else {
++        QReadLocker locker(&mSurfaceLock);
+         if (m_waylandEglWindow) {
+             int current_width, current_height;
+             static bool disableResizeCheck = qgetenv("QT_WAYLAND_DISABLE_RESIZECHECK").toInt();
+@@ -131,14 +133,16 @@ void QWaylandEglWindow::updateSurface(bool create)
+             if (!disableResizeCheck) {
+                 wl_egl_window_get_attached_size(m_waylandEglWindow, &current_width, &current_height);
+             }
+-            if (disableResizeCheck || (current_width != sizeWithMargins.width() || current_height != sizeWithMargins.height())) {
++            if (disableResizeCheck || (current_width != sizeWithMargins.width() || current_height != sizeWithMargins.height()) || m_requestedSize != sizeWithMargins) {
+                 wl_egl_window_resize(m_waylandEglWindow, sizeWithMargins.width(), sizeWithMargins.height(), mOffset.x(), mOffset.y());
++                m_requestedSize = sizeWithMargins;
+                 mOffset = QPoint();
+ 
+                 m_resize = true;
+             }
+-        } else if (create && wlSurface()) {
+-            m_waylandEglWindow = wl_egl_window_create(wlSurface(), sizeWithMargins.width(), sizeWithMargins.height());
++        } else if (create && mSurface) {
++            m_waylandEglWindow = wl_egl_window_create(mSurface->object(), sizeWithMargins.width(), sizeWithMargins.height());
++            m_requestedSize = sizeWithMargins;
+         }
+ 
+         if (!m_eglSurface && m_waylandEglWindow && create) {
+diff --git a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
+index 5b1f4d56..0079dfef 100644
+--- a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
++++ b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
+@@ -88,6 +88,7 @@ private:
+     mutable QOpenGLFramebufferObject *m_contentFBO = nullptr;
+ 
+     QSurfaceFormat m_format;
++    QSize m_requestedSize;
+ };
+ 
+ }
+diff --git a/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h b/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
+index 56a710c3..c6a8b6c6 100644
+--- a/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
++++ b/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
+@@ -41,6 +41,8 @@
+ #include <QtCore/QTextStream>
+ #include <QtGui/QOpenGLTexture>
+ 
++#include <array>
++
+ #include <EGL/egl.h>
+ #include <EGL/eglext.h>
+ 
+diff --git a/qtwayland/src/plugins/decorations/bradient/main.cpp b/qtwayland/src/plugins/decorations/bradient/main.cpp
+index e75fda3c..fa885143 100644
+--- a/qtwayland/src/plugins/decorations/bradient/main.cpp
++++ b/qtwayland/src/plugins/decorations/bradient/main.cpp
+@@ -164,13 +164,10 @@ void QWaylandBradientDecoration::paint(QPaintDevice *device)
+     // Window icon
+     QIcon icon = waylandWindow()->windowIcon();
+     if (!icon.isNull()) {
+-        QPixmap pixmap = icon.pixmap(QSize(128, 128));
+-        QPixmap scaled = pixmap.scaled(22, 22, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+-
+         QRectF iconRect(0, 0, 22, 22);
+-        p.drawPixmap(iconRect.adjusted(margins().left() + BUTTON_SPACING, 4,
+-                                       margins().left() + BUTTON_SPACING, 4),
+-                     scaled, iconRect);
++        iconRect.adjust(margins().left() + BUTTON_SPACING, 4,
++                        margins().left() + BUTTON_SPACING, 4),
++        icon.paint(&p, iconRect.toRect());
+     }
+ 
+     // Window title
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
+index 85d25e3c..60bdd491 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
+@@ -47,18 +47,21 @@ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
+-QWaylandXdgPopupV5::QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow *window)
++QWaylandXdgPopupV5::QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow* parent, QWaylandWindow *window)
+     : QWaylandShellSurface(window)
+     , QtWayland::xdg_popup_v5(popup)
++    , m_parent(parent)
+     , m_window(window)
+ {
+     if (window->display()->windowExtension())
+         m_extendedWindow = new QWaylandExtendedSurface(window);
++    m_parent->addChildPopup(m_window);
+ }
+ 
+ QWaylandXdgPopupV5::~QWaylandXdgPopupV5()
+ {
+     xdg_popup_destroy(object());
++    m_parent->removeChildPopup(m_window);
+     delete m_extendedWindow;
+ }
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
+index 7494f6a6..d85f130b 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
+@@ -70,7 +70,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgPopupV5 : public QWaylandShellSurface
+ {
+     Q_OBJECT
+ public:
+-    QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow *window);
++    QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow* parent, QWaylandWindow *window);
+     ~QWaylandXdgPopupV5() override;
+ 
+ protected:
+@@ -78,6 +78,7 @@ protected:
+ 
+ private:
+     QWaylandExtendedSurface *m_extendedWindow = nullptr;
++    QWaylandWindow *m_parent = nullptr;
+     QWaylandWindow *m_window = nullptr;
+ };
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
+index 7e242c4a..def8452a 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
+@@ -84,7 +84,7 @@ QWaylandXdgPopupV5 *QWaylandXdgShellV5::createXdgPopup(QWaylandWindow *window, Q
+     int x = position.x() + parentWindow->frameMargins().left();
+     int y = position.y() + parentWindow->frameMargins().top();
+ 
+-    auto popup = new QWaylandXdgPopupV5(get_xdg_popup(window->wlSurface(), parentSurface, seat, m_popupSerial, x, y), window);
++    auto popup = new QWaylandXdgPopupV5(get_xdg_popup(window->wlSurface(), parentSurface, seat, m_popupSerial, x, y), parentWindow, window);
+     m_popups.append(window);
+     QObject::connect(popup, &QWaylandXdgPopupV5::destroyed, [this, window](){
+         m_popups.removeOne(window);
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
+index 4e25949f..cfc60939 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
+@@ -85,13 +85,6 @@ QWaylandShellSurface *QWaylandXdgShellV5Integration::createShellSurface(QWayland
+     return m_xdgShell->createXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellV5Integration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) {
+-    if (newFocus && qobject_cast<QWaylandXdgPopupV5 *>(newFocus->shellSurface()))
+-        m_display->handleWindowActivated(newFocus);
+-    if (oldFocus && qobject_cast<QWaylandXdgPopupV5 *>(oldFocus->shellSurface()))
+-        m_display->handleWindowDeactivated(oldFocus);
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
+index ce6bdb9e..aed88670 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
+@@ -67,7 +67,6 @@ public:
+     QWaylandXdgShellV5Integration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShellV5> m_xdgShell;
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
+index 8c371661..151c78e3 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
+@@ -174,6 +174,7 @@ QWaylandXdgSurfaceV6::Popup::Popup(QWaylandXdgSurfaceV6 *xdgSurface, QWaylandXdg
+     , m_xdgSurface(xdgSurface)
+     , m_parent(parent)
+ {
++    m_parent->window()->addChildPopup(m_xdgSurface->window());
+ }
+ 
+ QWaylandXdgSurfaceV6::Popup::~Popup()
+@@ -181,6 +182,8 @@ QWaylandXdgSurfaceV6::Popup::~Popup()
+     if (isInitialized())
+         destroy();
+ 
++    m_parent->window()->removeChildPopup(m_xdgSurface->window());
++
+     if (m_grabbing) {
+         auto *shell = m_xdgSurface->m_shell;
+         Q_ASSERT(shell->m_topmostGrabbingPopup == this);
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
+index 03164316..e8da8ba1 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
+@@ -68,20 +68,6 @@ QWaylandShellSurface *QWaylandXdgShellV6Integration::createShellSurface(QWayland
+     return m_xdgShell->getXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellV6Integration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus)
+-{
+-    if (newFocus) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurfaceV6 *>(newFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowActivated(newFocus);
+-    }
+-    if (oldFocus && qobject_cast<QWaylandXdgSurfaceV6 *>(oldFocus->shellSurface())) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurfaceV6 *>(oldFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowDeactivated(oldFocus);
+-    }
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
+index 261f8cbb..c1bcd5c6 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
+@@ -65,7 +65,6 @@ public:
+     QWaylandXdgShellV6Integration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShellV6> m_xdgShell;
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
+index f3e3c330..fa6d5808 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
+@@ -67,11 +67,6 @@ QWaylandXdgSurface::Toplevel::Toplevel(QWaylandXdgSurface *xdgSurface)
+ 
+ QWaylandXdgSurface::Toplevel::~Toplevel()
+ {
+-    if (m_applied.states & Qt::WindowActive) {
+-        QWaylandWindow *window = m_xdgSurface->window();
+-        window->display()->handleWindowDeactivated(window);
+-    }
+-
+     // The protocol spec requires that the decoration object is deleted before xdg_toplevel.
+     delete m_decoration;
+     m_decoration = nullptr;
+@@ -85,16 +80,15 @@ void QWaylandXdgSurface::Toplevel::applyConfigure()
+     if (!(m_applied.states & (Qt::WindowMaximized|Qt::WindowFullScreen)))
+         m_normalSize = m_xdgSurface->m_window->windowFrameGeometry().size();
+ 
+-    if ((m_pending.states & Qt::WindowActive) && !(m_applied.states & Qt::WindowActive))
++    if ((m_pending.states & Qt::WindowActive) && !(m_applied.states & Qt::WindowActive)
++        && !m_xdgSurface->m_window->display()->isKeyboardAvailable())
+         m_xdgSurface->m_window->display()->handleWindowActivated(m_xdgSurface->m_window);
+ 
+-    if (!(m_pending.states & Qt::WindowActive) && (m_applied.states & Qt::WindowActive))
++    if (!(m_pending.states & Qt::WindowActive) && (m_applied.states & Qt::WindowActive)
++        && !m_xdgSurface->m_window->display()->isKeyboardAvailable())
+         m_xdgSurface->m_window->display()->handleWindowDeactivated(m_xdgSurface->m_window);
+ 
+-    // TODO: none of the other plugins send WindowActive either, but is it on purpose?
+-    Qt::WindowStates statesWithoutActive = m_pending.states & ~Qt::WindowActive;
+-
+-    m_xdgSurface->m_window->handleWindowStatesChanged(statesWithoutActive);
++    m_xdgSurface->m_window->handleWindowStatesChanged(m_pending.states);
+ 
+     if (m_pending.size.isEmpty()) {
+         // An empty size in the configure means it's up to the client to choose the size
+@@ -105,8 +99,6 @@ void QWaylandXdgSurface::Toplevel::applyConfigure()
+         m_xdgSurface->m_window->resizeFromApplyConfigure(m_pending.size);
+     }
+ 
+-    m_xdgSurface->setSizeHints();
+-
+     m_applied = m_pending;
+     qCDebug(lcQpaWayland) << "Applied pending xdg_toplevel configure event:" << m_applied.size << m_applied.states;
+ }
+@@ -203,12 +195,17 @@ QtWayland::xdg_toplevel::resize_edge QWaylandXdgSurface::Toplevel::convertToResi
+                 | ((edges & Qt::RightEdge) ? resize_edge_right : 0));
+ }
+ 
+-QWaylandXdgSurface::Popup::Popup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parent,
++QWaylandXdgSurface::Popup::Popup(QWaylandXdgSurface *xdgSurface, QWaylandWindow *parent,
+                                  QtWayland::xdg_positioner *positioner)
+-    : xdg_popup(xdgSurface->get_popup(parent->object(), positioner->object()))
+-    , m_xdgSurface(xdgSurface)
++    : m_xdgSurface(xdgSurface)
++    , m_parentXdgSurface(qobject_cast<QWaylandXdgSurface *>(parent->shellSurface()))
+     , m_parent(parent)
+ {
++
++    init(xdgSurface->get_popup(m_parentXdgSurface ? m_parentXdgSurface->object() : nullptr, positioner->object()));
++    if (m_parent) {
++        m_parent->addChildPopup(m_xdgSurface->window());
++    }
+ }
+ 
+ QWaylandXdgSurface::Popup::~Popup()
+@@ -216,10 +213,24 @@ QWaylandXdgSurface::Popup::~Popup()
+     if (isInitialized())
+         destroy();
+ 
++    if (m_parent) {
++        m_parent->removeChildPopup(m_xdgSurface->window());
++    }
++
+     if (m_grabbing) {
+         auto *shell = m_xdgSurface->m_shell;
+         Q_ASSERT(shell->m_topmostGrabbingPopup == this);
+-        shell->m_topmostGrabbingPopup = m_parent->m_popup;
++        shell->m_topmostGrabbingPopup = m_parentXdgSurface ? m_parentXdgSurface->m_popup : nullptr;
++        m_grabbing = false;
++
++        // Synthesize Qt enter/leave events for popup
++        QWindow *leave = nullptr;
++        if (m_xdgSurface && m_xdgSurface->window())
++            leave = m_xdgSurface->window()->window();
++        QWindowSystemInterface::handleLeaveEvent(leave);
++
++        if (QWindow *enter = QGuiApplication::topLevelAt(QCursor::pos()))
++            QWindowSystemInterface::handleEnterEvent(enter, enter->mapFromGlobal(QCursor::pos()), QCursor::pos());
+     }
+ }
+ 
+@@ -257,6 +268,7 @@ QWaylandXdgSurface::QWaylandXdgSurface(QWaylandXdgShell *shell, ::xdg_surface *s
+                 m_toplevel->set_parent(parentXdgSurface->m_toplevel->object());
+         }
+     }
++    setSizeHints();
+ }
+ 
+ QWaylandXdgSurface::~QWaylandXdgSurface()
+@@ -400,8 +412,6 @@ void QWaylandXdgSurface::setPopup(QWaylandWindow *parent)
+ {
+     Q_ASSERT(!m_toplevel && !m_popup);
+ 
+-    auto parentXdgSurface = static_cast<QWaylandXdgSurface *>(parent->shellSurface());
+-
+     auto positioner = new QtWayland::xdg_positioner(m_shell->create_positioner());
+     // set_popup expects a position relative to the parent
+     QPoint transientPos = m_window->geometry().topLeft(); // this is absolute
+@@ -414,8 +424,9 @@ void QWaylandXdgSurface::setPopup(QWaylandWindow *parent)
+     positioner->set_anchor(QtWayland::xdg_positioner::anchor_top_left);
+     positioner->set_gravity(QtWayland::xdg_positioner::gravity_bottom_right);
+     positioner->set_size(m_window->geometry().width(), m_window->geometry().height());
+-    m_popup = new Popup(this, parentXdgSurface, positioner);
++    m_popup = new Popup(this, parent, positioner);
+     positioner->destroy();
++
+     delete positioner;
+ }
+ 
+@@ -437,6 +448,23 @@ void QWaylandXdgSurface::setGrabPopup(QWaylandWindow *parent, QWaylandInputDevic
+     }
+     setPopup(parent);
+     m_popup->grab(device, serial);
++
++    // Synthesize Qt enter/leave events for popup
++    if (!parent)
++        return;
++    QWindow *current = QGuiApplication::topLevelAt(QCursor::pos());
++    QWindow *leave = parent->window();
++    if (current != leave)
++        return;
++
++    QWindowSystemInterface::handleLeaveEvent(leave);
++
++    QWindow *enter = nullptr;
++    if (m_popup && m_popup->m_xdgSurface && m_popup->m_xdgSurface->window())
++        enter = m_popup->m_xdgSurface->window()->window();
++
++    if (enter)
++        QWindowSystemInterface::handleEnterEvent(enter, enter->mapFromGlobal(QCursor::pos()), QCursor::pos());
+ }
+ 
+ void QWaylandXdgSurface::xdg_surface_configure(uint32_t serial)
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
+index 96785205..4b518f0a 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
+@@ -131,14 +131,15 @@ private:
+ 
+     class Popup : public QtWayland::xdg_popup {
+     public:
+-        Popup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parent, QtWayland::xdg_positioner *positioner);
++        Popup(QWaylandXdgSurface *xdgSurface, QWaylandWindow *parent, QtWayland::xdg_positioner *positioner);
+         ~Popup() override;
+ 
+         void grab(QWaylandInputDevice *seat, uint serial);
+         void xdg_popup_popup_done() override;
+ 
+         QWaylandXdgSurface *m_xdgSurface = nullptr;
+-        QWaylandXdgSurface *m_parent = nullptr;
++        QWaylandXdgSurface *m_parentXdgSurface = nullptr;
++        QWaylandWindow *m_parent = nullptr;
+         bool m_grabbing = false;
+     };
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
+index 8769d971..da0dd6a7 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
+@@ -69,20 +69,6 @@ QWaylandShellSurface *QWaylandXdgShellIntegration::createShellSurface(QWaylandWi
+     return m_xdgShell->getXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellIntegration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus)
+-{
+-    if (newFocus) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurface *>(newFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowActivated(newFocus);
+-    }
+-    if (oldFocus && qobject_cast<QWaylandXdgSurface *>(oldFocus->shellSurface())) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurface *>(oldFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowDeactivated(oldFocus);
+-    }
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
+index b6caa6c9..2f929f98 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
+@@ -65,7 +65,6 @@ public:
+     QWaylandXdgShellIntegration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShell> m_xdgShell;
+diff --git a/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp b/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
+index 526d0ef4..f50ccf30 100644
+--- a/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
++++ b/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
+@@ -39,7 +39,10 @@
+ 
+ #include "qwaylandinputmethodeventbuilder_p.h"
+ 
++#include <QBrush>
++#include <QGuiApplication>
+ #include <QInputMethod>
++#include <QPalette>
+ #include <QTextCharFormat>
+ 
+ #ifdef QT_BUILD_WAYLANDCOMPOSITOR_LIB
+@@ -81,32 +84,38 @@ void QWaylandInputMethodEventBuilder::addPreeditStyling(uint32_t index, uint32_t
+     QTextCharFormat format;
+ 
+     switch (style) {
+-    case 0:
+-    case 1:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_NONE:
++        break;
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_DEFAULT:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_UNDERLINE:
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-    case 2:
+-    case 3:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_ACTIVE:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_INACTIVE:
+         format.setFontWeight(QFont::Bold);
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-    case 4:
+-        format.setFontUnderline(true);
+-        format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+-        m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_HIGHLIGHT:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_SELECTION:
++        {
++            format.setFontUnderline(true);
++            format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
++            QPalette palette = qApp->palette();
++            format.setBackground(QBrush(palette.color(QPalette::Active, QPalette::Highlight)));
++            format.setForeground(QBrush(palette.color(QPalette::Active, QPalette::HighlightedText)));
++            m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
++        }
+         break;
+-    case 5:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_INCORRECT:
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::WaveUnderline);
+         format.setUnderlineColor(QColor(Qt::red));
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-//    case QtWayland::wl_text_input::preedit_style_selection:
+-//    case QtWayland::wl_text_input::preedit_style_none:
+     default:
+         break;
+     }
+@@ -153,7 +162,7 @@ QInputMethodEvent QWaylandInputMethodEventBuilder::buildPreedit(const QString &t
+ 
+     if (m_preeditCursor < 0) {
+         attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, 0, QVariant()));
+-    } else if (m_preeditCursor > 0) {
++    } else {
+         attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, indexFromWayland(text, m_preeditCursor), 1, QVariant()));
+     }
+ 
+diff --git a/qtwayland/src/shared/qwaylandmimehelper.cpp b/qtwayland/src/shared/qwaylandmimehelper.cpp
+index a5fdd34d..e2fe1928 100644
+--- a/qtwayland/src/shared/qwaylandmimehelper.cpp
++++ b/qtwayland/src/shared/qwaylandmimehelper.cpp
+@@ -60,7 +60,7 @@ QByteArray QWaylandMimeHelper::getByteArray(QMimeData *mimeData, const QString &
+             buf.open(QIODevice::ReadWrite);
+             QByteArray fmt = "BMP";
+             if (mimeType.startsWith(QLatin1String("image/"))) {
+-                QByteArray imgFmt = mimeType.mid(6).toUpper().toLatin1();
++                QByteArray imgFmt = mimeType.mid(6).toLower().toLatin1();
+                 if (QImageWriter::supportedImageFormats().contains(imgFmt))
+                     fmt = imgFmt;
+             }
+@@ -74,7 +74,7 @@ QByteArray QWaylandMimeHelper::getByteArray(QMimeData *mimeData, const QString &
+         QList<QUrl> urls = mimeData->urls();
+         for (int i = 0; i < urls.count(); ++i) {
+             content.append(urls.at(i).toEncoded());
+-            content.append('\n');
++            content.append("\r\n");
+         }
+     } else {
+         content = mimeData->data(mimeType);
+diff --git a/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp b/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
+index 1568b3b9..067410d0 100644
+--- a/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
++++ b/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
+@@ -35,7 +35,7 @@
+ 
+ using namespace MockCompositor;
+ 
+-constexpr int dataDeviceVersion = 1;
++constexpr int dataDeviceVersion = 3;
+ 
+ class DataDeviceCompositor : public DefaultCompositor {
+ public:
+diff --git a/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp b/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
+index 9312c2e5..2ea382f1 100644
+--- a/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
++++ b/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
+@@ -73,6 +73,7 @@ private slots:
+     void multiTouch();
+     void multiTouchUpAndMotionFrame();
+     void tapAndMoveInSameFrame();
++    void cancelTouch();
+ };
+ 
+ void tst_seatv5::bindsToSeat()
+@@ -646,5 +647,34 @@ void tst_seatv5::tapAndMoveInSameFrame()
+     QTRY_COMPARE(window.m_events.last().touchPoints.first().state(), Qt::TouchPointState::TouchPointReleased);
+ }
+ 
++void tst_seatv5::cancelTouch()
++{
++    TouchWindow window;
++    QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
++
++    exec([=] {
++        auto *t = touch();
++        auto *c = client();
++        t->sendDown(xdgToplevel()->surface(), {32, 32}, 1);
++        t->sendFrame(c);
++        t->sendCancel(c);
++        t->sendFrame(c);
++    });
++
++    QTRY_VERIFY(!window.m_events.empty());
++    {
++        auto e = window.m_events.takeFirst();
++        QCOMPARE(e.type, QEvent::TouchBegin);
++        QCOMPARE(e.touchPointStates, Qt::TouchPointPressed);
++        QCOMPARE(e.touchPoints.length(), 1);
++        QCOMPARE(e.touchPoints.first().pos(), QPointF(32-window.frameMargins().left(), 32-window.frameMargins().top()));
++    }
++    {
++        auto e = window.m_events.takeFirst();
++        QCOMPARE(e.type, QEvent::TouchCancel);
++        QCOMPARE(e.touchPoints.length(), 0);
++    }
++}
++
+ QCOMPOSITOR_TEST_MAIN(tst_seatv5)
+ #include "tst_seatv5.moc"
+diff --git a/qtwayland/tests/auto/client/shared/corecompositor.cpp b/qtwayland/tests/auto/client/shared/corecompositor.cpp
+index 5c6c83ba..fa9b7662 100644
+--- a/qtwayland/tests/auto/client/shared/corecompositor.cpp
++++ b/qtwayland/tests/auto/client/shared/corecompositor.cpp
+@@ -27,6 +27,7 @@
+ ****************************************************************************/
+ 
+ #include "corecompositor.h"
++#include <thread>
+ 
+ namespace MockCompositor {
+ 
+diff --git a/qtwayland/tests/auto/client/shared/coreprotocol.cpp b/qtwayland/tests/auto/client/shared/coreprotocol.cpp
+index 0d988521..d1a2e7cb 100644
+--- a/qtwayland/tests/auto/client/shared/coreprotocol.cpp
++++ b/qtwayland/tests/auto/client/shared/coreprotocol.cpp
+@@ -451,6 +451,13 @@ void Touch::sendFrame(wl_client *client)
+         send_frame(r->handle);
+ }
+ 
++void Touch::sendCancel(wl_client *client)
++{
++    const auto touchResources = resourceMap().values(client);
++    for (auto *r : touchResources)
++        send_cancel(r->handle);
++}
++
+ uint Keyboard::sendEnter(Surface *surface)
+ {
+     auto serial = m_seat->m_compositor->nextSerial();
+diff --git a/qtwayland/tests/auto/client/shared/coreprotocol.h b/qtwayland/tests/auto/client/shared/coreprotocol.h
+index a1af137a..210d8ddb 100644
+--- a/qtwayland/tests/auto/client/shared/coreprotocol.h
++++ b/qtwayland/tests/auto/client/shared/coreprotocol.h
+@@ -158,7 +158,7 @@ class WlCompositor : public Global, public QtWaylandServer::wl_compositor
+ {
+     Q_OBJECT
+ public:
+-    explicit WlCompositor(CoreCompositor *compositor, int version = 3)
++    explicit WlCompositor(CoreCompositor *compositor, int version = 4)
+         : QtWaylandServer::wl_compositor(compositor->m_display, version)
+         , m_compositor(compositor)
+     {}
+@@ -364,6 +364,7 @@ public:
+     uint sendUp(wl_client *client, int id);
+     void sendMotion(wl_client *client, const QPointF &position, int id);
+     void sendFrame(wl_client *client);
++    void sendCancel(wl_client *client);
+ 
+     Seat *m_seat = nullptr;
+ };
+diff --git a/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp b/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
+index a415cbf5..b1d3d07d 100644
+--- a/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
++++ b/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
+@@ -342,7 +342,7 @@ Compositor::Compositor(MockCompositor *mockCompositor)
+         exit(EXIT_FAILURE);
+     }
+ 
+-    wl_global_create(m_display, &wl_compositor_interface, 1, this, bindCompositor);
++    wl_global_create(m_display, &wl_compositor_interface, 4, this, bindCompositor);
+ 
+     m_data_device_manager.reset(new DataDeviceManager(this, m_display));
+ 
+diff --git a/qtwayland/tests/auto/client/shared_old/mocksurface.cpp b/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
+index e9df5f90..c3246e4a 100644
+--- a/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
++++ b/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
+@@ -125,6 +125,16 @@ void Surface::surface_damage(Resource *resource,
+     Q_UNUSED(height);
+ }
+ 
++void Surface::surface_damage_buffer(Resource *resource,
++                                    int32_t x, int32_t y, int32_t width, int32_t height)
++{
++    Q_UNUSED(resource);
++    Q_UNUSED(x);
++    Q_UNUSED(y);
++    Q_UNUSED(width);
++    Q_UNUSED(height);
++}
++
+ void Surface::surface_frame(Resource *resource,
+                             uint32_t callback)
+ {
+diff --git a/qtwayland/tests/auto/client/shared_old/mocksurface.h b/qtwayland/tests/auto/client/shared_old/mocksurface.h
+index 949dc23d..d176837e 100644
+--- a/qtwayland/tests/auto/client/shared_old/mocksurface.h
++++ b/qtwayland/tests/auto/client/shared_old/mocksurface.h
+@@ -65,6 +65,8 @@ protected:
+                         struct wl_resource *buffer, int x, int y) override;
+     void surface_damage(Resource *resource,
+                         int32_t x, int32_t y, int32_t width, int32_t height) override;
++    void surface_damage_buffer(Resource *resource,
++                               int32_t x, int32_t y, int32_t width, int32_t height) override;
+     void surface_frame(Resource *resource,
+                        uint32_t callback) override;
+     void surface_commit(Resource *resource) override;
+diff --git a/qtwayland/tests/auto/client/surface/tst_surface.cpp b/qtwayland/tests/auto/client/surface/tst_surface.cpp
+index 95e4e609..60c672ce 100644
+--- a/qtwayland/tests/auto/client/surface/tst_surface.cpp
++++ b/qtwayland/tests/auto/client/surface/tst_surface.cpp
+@@ -129,6 +129,10 @@ void tst_surface::waitForFrameCallbackGl()
+     // Make sure we follow frame callbacks for some frames
+     for (int i = 0; i < 5; ++i) {
+         xdgPingAndWaitForPong(); // Make sure things have happened on the client
++        if (!qEnvironmentVariableIntValue("QT_WAYLAND_DISABLE_WINDOWDECORATION") && i == 0) {
++            QCOMPARE(bufferSpy.count(), 1);
++            bufferSpy.removeFirst();
++        }
+         exec([&] {
+             QVERIFY(bufferSpy.empty()); // Make sure no extra buffers have arrived
+             QVERIFY(!xdgToplevel()->surface()->m_waitingFrameCallbacks.empty());
+diff --git a/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp b/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
+index 2277bbb8..747875b4 100644
+--- a/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
++++ b/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
+@@ -31,6 +31,7 @@
+ #include <QtGui/QOpenGLWindow>
+ #include <QtGui/qpa/qplatformnativeinterface.h>
+ #include <QtWaylandClient/private/wayland-wayland-client-protocol.h>
++#include <QtWaylandClient/private/qwaylandwindow_p.h>
+ 
+ using namespace MockCompositor;
+ 
+@@ -45,6 +46,7 @@ private slots:
+     void configureStates();
+     void popup();
+     void tooltipOnPopup();
++    void tooltipAndSiblingPopup();
+     void switchPopups();
+     void hidePopupParent();
+     void pongs();
+@@ -138,6 +140,7 @@ void tst_xdgshell::configureSize()
+ 
+ void tst_xdgshell::configureStates()
+ {
++    QVERIFY(qputenv("QT_WAYLAND_FRAME_CALLBACK_TIMEOUT", "0"));
+     QRasterWindow window;
+     window.resize(64, 48);
+     window.show();
+@@ -154,9 +157,12 @@ void tst_xdgshell::configureStates()
+     // Toplevel windows don't know their position on xdg-shell
+ //    QCOMPARE(window.frameGeometry().topLeft(), QPoint()); // TODO: this doesn't currently work when window decorations are enabled
+ 
+-//    QEXPECT_FAIL("", "configure has already been acked, we shouldn't have to wait for isActive", Continue);
+-//    QVERIFY(window.isActive());
+-    QTRY_VERIFY(window.isActive()); // Just make sure it eventually get's set correctly
++    // window.windowstate() is driven by keyboard focus, however for decorations we want to follow
++    // XDGShell this is internal to QtWayland so it is queried directly
++    auto waylandWindow = static_cast<QtWaylandClient::QWaylandWindow *>(window.handle());
++    Q_ASSERT(waylandWindow);
++    QTRY_VERIFY(waylandWindow->windowStates().testFlag(
++            Qt::WindowActive)); // Just make sure it eventually get's set correctly
+ 
+     const QSize screenSize(640, 480);
+     const uint maximizedSerial = exec([=] {
+@@ -186,6 +192,7 @@ void tst_xdgshell::configureStates()
+     QCOMPARE(window.windowStates(), Qt::WindowNoState);
+     QCOMPARE(window.frameGeometry().size(), windowedSize);
+ //    QCOMPARE(window.frameGeometry().topLeft(), QPoint()); // TODO: this doesn't currently work when window decorations are enabled
++    QVERIFY(qunsetenv("QT_WAYLAND_FRAME_CALLBACK_TIMEOUT"));
+ }
+ 
+ void tst_xdgshell::popup()
+@@ -340,6 +347,92 @@ void tst_xdgshell::tooltipOnPopup()
+     QCOMPOSITOR_TRY_COMPARE(xdgPopup(0), nullptr);
+ }
+ 
++void tst_xdgshell::tooltipAndSiblingPopup()
++{
++    class ToolTip : public QRasterWindow {
++    public:
++        explicit ToolTip(QWindow *parent) {
++            setTransientParent(parent);
++            setFlags(Qt::ToolTip);
++            resize(100, 100);
++            show();
++        }
++        void mousePressEvent(QMouseEvent *event) override {
++            QRasterWindow::mousePressEvent(event);
++            m_popup = new QRasterWindow;
++            m_popup->setTransientParent(transientParent());
++            m_popup->setFlags(Qt::Popup);
++            m_popup->resize(100, 100);
++            m_popup->show();
++        }
++
++        QRasterWindow *m_popup = nullptr;
++    };
++
++    class Window : public QRasterWindow {
++    public:
++        void mousePressEvent(QMouseEvent *event) override {
++            QRasterWindow::mousePressEvent(event);
++            m_tooltip = new ToolTip(this);
++        }
++        ToolTip *m_tooltip = nullptr;
++    };
++
++    Window window;
++    window.resize(200, 200);
++    window.show();
++
++    QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
++    exec([=] { xdgToplevel()->sendCompleteConfigure(); });
++    QCOMPOSITOR_TRY_VERIFY(xdgToplevel()->m_xdgSurface->m_committedConfigureSerial);
++
++    exec([=] {
++        auto *surface = xdgToplevel()->surface();
++        auto *p = pointer();
++        auto *c = client();
++        p->sendEnter(surface, {100, 100});
++        p->sendFrame(c);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_pressed);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_released);
++        p->sendFrame(c);
++        p->sendLeave(surface);
++        p->sendFrame(c);
++    });
++
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup());
++    exec([=] { xdgPopup()->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup()->m_xdgSurface->m_committedConfigureSerial);
++    QCOMPOSITOR_TRY_VERIFY(!xdgPopup()->m_grabbed);
++
++    exec([=] {
++        auto *surface = xdgPopup()->surface();
++        auto *p = pointer();
++        auto *c = client();
++        p->sendEnter(surface, {100, 100});
++        p->sendFrame(c);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_pressed);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_released);
++        p->sendFrame(c);
++    });
++
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1));
++    exec([=] { xdgPopup(1)->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1)->m_xdgSurface->m_committedConfigureSerial);
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1)->m_grabbed);
++
++    // Close the middle tooltip (it should not close the sibling popup)
++    window.m_tooltip->close();
++
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(1), nullptr);
++    // Verify the remaining xdg surface is a grab popup..
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(0));
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(0)->m_grabbed);
++
++    window.m_tooltip->m_popup->close();
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(1), nullptr);
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(0), nullptr);
++}
++
+ // QTBUG-65680
+ void tst_xdgshell::switchPopups()
+ {
+@@ -505,7 +598,7 @@ void tst_xdgshell::minMaxSize()
+     window.show();
+     QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
+ 
+-    exec([=] { xdgToplevel()->sendCompleteConfigure(); });
++    // we don't roundtrip with our configuration the initial commit should be correct
+ 
+     QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.minSize, QSize(100, 100));
+     QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.maxSize, QSize(1000, 1000));
+Submodule qtwebchannel 618422ee..f8949655:
+diff --git a/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp b/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
+index 536eb5c..898d769 100644
+--- a/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
++++ b/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
+@@ -186,8 +186,6 @@ Q_DECLARE_TYPEINFO(OverloadResolutionCandidate, Q_MOVABLE_TYPE);
+ QMetaObjectPublisher::QMetaObjectPublisher(QWebChannel *webChannel)
+     : QObject(webChannel)
+     , webChannel(webChannel)
+-    , signalHandler(this)
+-    , clientIsIdle(false)
+     , blockUpdates(false)
+     , propertyUpdatesInitialized(false)
+ {
+@@ -301,17 +299,17 @@ QJsonObject QMetaObjectPublisher::classInfoForObject(const QObject *object, QWeb
+     return data;
+ }
+ 
+-void QMetaObjectPublisher::setClientIsIdle(bool isIdle)
++void QMetaObjectPublisher::setClientIsIdle(bool isIdle, QWebChannelAbstractTransport *transport)
+ {
+-    if (clientIsIdle == isIdle) {
+-        return;
+-    }
+-    clientIsIdle = isIdle;
+-    if (!isIdle && timer.isActive()) {
+-        timer.stop();
+-    } else if (isIdle && !timer.isActive()) {
+-        timer.start(PROPERTY_UPDATE_INTERVAL, this);
+-    }
++    transportState[transport].clientIsIdle = isIdle;
++    if (isIdle)
++        sendEnqueuedPropertyUpdates(transport);
++}
++
++bool QMetaObjectPublisher::isClientIdle(QWebChannelAbstractTransport *transport)
++{
++    auto found = transportState.find(transport);
++    return found != transportState.end() && found.value().clientIsIdle;
+ }
+ 
+ QJsonObject QMetaObjectPublisher::initializeClient(QWebChannelAbstractTransport *transport)
+@@ -333,6 +331,7 @@ QJsonObject QMetaObjectPublisher::initializeClient(QWebChannelAbstractTransport
+ 
+ void QMetaObjectPublisher::initializePropertyUpdates(const QObject *const object, const QJsonObject &objectInfo)
+ {
++    auto *signalHandler = signalHandlerFor(object);
+     foreach (const QJsonValue &propertyInfoVar, objectInfo[KEY_PROPERTIES].toArray()) {
+         const QJsonArray &propertyInfo = propertyInfoVar.toArray();
+         if (propertyInfo.size() < 2) {
+@@ -353,19 +352,19 @@ void QMetaObjectPublisher::initializePropertyUpdates(const QObject *const object
+ 
+         // Only connect for a property update once
+         if (connectedProperties.isEmpty()) {
+-            signalHandler.connectTo(object, signalIndex);
++            signalHandler->connectTo(object, signalIndex);
+         }
+ 
+         connectedProperties.insert(propertyIndex);
+     }
+ 
+     // also always connect to destroyed signal
+-    signalHandler.connectTo(object, s_destroyedSignalIndex);
++    signalHandler->connectTo(object, s_destroyedSignalIndex);
+ }
+ 
+ void QMetaObjectPublisher::sendPendingPropertyUpdates()
+ {
+-    if (blockUpdates || !clientIsIdle || pendingPropertyUpdates.isEmpty()) {
++    if (blockUpdates) {
+         return;
+     }
+ 
+@@ -415,18 +414,19 @@ void QMetaObjectPublisher::sendPendingPropertyUpdates()
+ 
+     // data does not contain specific updates
+     if (!data.isEmpty()) {
+-        setClientIsIdle(false);
+-
+         message[KEY_DATA] = data;
+-        broadcastMessage(message);
++        enqueueBroadcastMessage(message);
+     }
+ 
+     // send every property update which is not supposed to be broadcasted
+     const QHash<QWebChannelAbstractTransport*, QJsonArray>::const_iterator suend = specificUpdates.constEnd();
+     for (QHash<QWebChannelAbstractTransport*, QJsonArray>::const_iterator it = specificUpdates.constBegin(); it != suend; ++it) {
+         message[KEY_DATA] = it.value();
+-        it.key()->sendMessage(message);
++        enqueueMessage(message, it.key());
+     }
++
++    for (auto state = transportState.begin(); state != transportState.end(); ++state)
++        sendEnqueuedPropertyUpdates(state.key());
+ }
+ 
+ QVariant QMetaObjectPublisher::invokeMethod(QObject *const object, const QMetaMethod &method,
+@@ -572,7 +572,7 @@ void QMetaObjectPublisher::signalEmitted(const QObject *object, const int signal
+         }
+     } else {
+         pendingPropertyUpdates[object][signalIndex] = arguments;
+-        if (clientIsIdle && !blockUpdates && !timer.isActive()) {
++        if (!blockUpdates && !timer.isActive()) {
+             timer.start(PROPERTY_UPDATE_INTERVAL, this);
+         }
+     }
+@@ -590,7 +590,7 @@ void QMetaObjectPublisher::objectDestroyed(const QObject *object)
+     // only remove from handler when we initialized the property updates
+     // cf: https://bugreports.qt.io/browse/QTBUG-60250
+     if (propertyUpdatesInitialized) {
+-        signalHandler.remove(object);
++        signalHandlerFor(object)->remove(object);
+         signalToPropertyMap.remove(object);
+     }
+     pendingPropertyUpdates.remove(object);
+@@ -852,6 +852,52 @@ void QMetaObjectPublisher::broadcastMessage(const QJsonObject &message) const
+     }
+ }
+ 
++void QMetaObjectPublisher::enqueueBroadcastMessage(const QJsonObject &message)
++{
++    if (webChannel->d_func()->transports.isEmpty()) {
++        qWarning("QWebChannel is not connected to any transports, cannot send message: %s",
++                 QJsonDocument(message).toJson().constData());
++        return;
++    }
++
++    for (auto *transport : webChannel->d_func()->transports) {
++        auto &state = transportState[transport];
++        state.queuedMessages.append(message);
++    }
++}
++
++void QMetaObjectPublisher::enqueueMessage(const QJsonObject &message,
++                                          QWebChannelAbstractTransport *transport)
++{
++    auto &state = transportState[transport];
++    state.queuedMessages.append(message);
++}
++
++void QMetaObjectPublisher::sendEnqueuedPropertyUpdates(QWebChannelAbstractTransport *transport)
++{
++    auto found = transportState.find(transport);
++    if (found != transportState.end() && found.value().clientIsIdle
++        && !found.value().queuedMessages.isEmpty()) {
++
++        // If the client is connected with an in-process transport, it can
++        // happen that a message triggers a subsequent property change. In
++        // that case, we need to ensure that the queued messages have already
++        // been cleared; otherwise the recursive call will send everythig again.
++        // Case in point: The qmlwebchannel tests fail if we don't clear the
++        // queued messages before sending them out.
++        // For that same reason set the client to "busy" (aka non-idle) just
++        // right before sending out the messages; otherwise a potential
++        // "Idle" type message will not correctly restore the Idle state.
++        const auto messages = std::move(found.value().queuedMessages);
++        Q_ASSERT(found.value().queuedMessages.isEmpty());
++        found.value().clientIsIdle = false;
++
++        for (const auto &message : messages) {
++            transport->sendMessage(message);
++        }
++    }
++}
++
+ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannelAbstractTransport *transport)
+ {
+     if (!webChannel->d_func()->transports.contains(transport)) {
+@@ -866,7 +912,7 @@ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannel
+ 
+     const MessageType type = toType(message.value(KEY_TYPE));
+     if (type == TypeIdle) {
+-        setClientIsIdle(true);
++        setClientIsIdle(true, transport);
+     } else if (type == TypeInit) {
+         if (!message.contains(KEY_ID)) {
+             qWarning("JSON message object is missing the id property: %s",
+@@ -913,9 +959,9 @@ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannel
+                 return;
+             transport->sendMessage(createResponse(message.value(KEY_ID), wrapResult(result, transport)));
+         } else if (type == TypeConnectToSignal) {
+-            signalHandler.connectTo(object, message.value(KEY_SIGNAL).toInt(-1));
++            signalHandlerFor(object)->connectTo(object, message.value(KEY_SIGNAL).toInt(-1));
+         } else if (type == TypeDisconnectFromSignal) {
+-            signalHandler.disconnectFrom(object, message.value(KEY_SIGNAL).toInt(-1));
++            signalHandlerFor(object)->disconnectFrom(object, message.value(KEY_SIGNAL).toInt(-1));
+         } else if (type == TypeSetProperty) {
+             setProperty(object, message.value(KEY_PROPERTY).toInt(-1),
+                         message.value(KEY_VALUE));
+@@ -931,6 +977,7 @@ void QMetaObjectPublisher::setBlockUpdates(bool block)
+     blockUpdates = block;
+ 
+     if (!blockUpdates) {
++        timer.start(PROPERTY_UPDATE_INTERVAL, this);
+         sendPendingPropertyUpdates();
+     } else if (timer.isActive()) {
+         timer.stop();
+@@ -948,4 +995,15 @@ void QMetaObjectPublisher::timerEvent(QTimerEvent *event)
+     }
+ }
+ 
++SignalHandler<QMetaObjectPublisher> *QMetaObjectPublisher::signalHandlerFor(const QObject *object)
++{
++    auto thread = object->thread();
++    auto it = signalHandlers.find(thread);
++    if (it == signalHandlers.end()) {
++        it = signalHandlers.emplace(thread, this).first;
++        it->second.moveToThread(thread);
++    }
++    return &it->second;
++}
++
+ QT_END_NAMESPACE
+diff --git a/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h b/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
+index bbd9875..4713ef1 100644
+--- a/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
++++ b/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
+@@ -59,6 +59,9 @@
+ #include <QBasicTimer>
+ #include <QPointer>
+ #include <QJsonObject>
++#include <QQueue>
++
++#include <unordered_map>
+ 
+ #include "qwebchannelglobal.h"
+ 
+@@ -109,17 +112,36 @@ public:
+      */
+     void broadcastMessage(const QJsonObject &message) const;
+ 
++    /**
++     * Enqueue the given @p message to all known transports.
++     */
++    void enqueueBroadcastMessage(const QJsonObject &message);
++
++    /**
++     * Enqueue the given @p message to @p transport.
++     */
++    void enqueueMessage(const QJsonObject &message, QWebChannelAbstractTransport *transport);
++
++    /**
++     * If client for given @p transport is idle, send queued messaged to @p transport and then mark
++     * the client as not idle.
++     */
++    void sendEnqueuedPropertyUpdates(QWebChannelAbstractTransport *transport);
++
+     /**
+      * Serialize the QMetaObject of @p object and return it in JSON form.
+      */
+     QJsonObject classInfoForObject(const QObject *object, QWebChannelAbstractTransport *transport);
+ 
+     /**
+-     * Set the client to idle or busy, based on the value of @p isIdle.
+-     *
+-     * When the value changed, start/stop the property update timer accordingly.
++     * Set the client to idle or busy for a single @p transport, based on the value of @p isIdle.
++     */
++    void setClientIsIdle(bool isIdle, QWebChannelAbstractTransport *transport);
++
++    /**
++     * Check that client is idle for @p transport.
+      */
+-    void setClientIsIdle(bool isIdle);
++    bool isClientIdle(QWebChannelAbstractTransport *transport);
+ 
+     /**
+      * Initialize clients by sending them the class information of the registered objects.
+@@ -272,10 +294,18 @@ private:
+     friend class TestWebChannel;
+ 
+     QWebChannel *webChannel;
+-    SignalHandler<QMetaObjectPublisher> signalHandler;
++    std::unordered_map<const QThread*, SignalHandler<QMetaObjectPublisher>> signalHandlers;
++    SignalHandler<QMetaObjectPublisher> *signalHandlerFor(const QObject *object);
+ 
+-    // true when the client is idle, false otherwise
+-    bool clientIsIdle;
++    struct TransportState
++    {
++        TransportState() : clientIsIdle(false) { }
++        // true when the client is idle, false otherwise
++        bool clientIsIdle;
++        // messages to send
++        QQueue<QJsonObject> queuedMessages;
++    };
++    QHash<QWebChannelAbstractTransport *, TransportState> transportState;
+ 
+     // true when no property updates should be sent, false otherwise
+     bool blockUpdates;
+diff --git a/qtwebchannel/src/webchannel/signalhandler_p.h b/qtwebchannel/src/webchannel/signalhandler_p.h
+index 27afadb..d77373c 100644
+--- a/qtwebchannel/src/webchannel/signalhandler_p.h
++++ b/qtwebchannel/src/webchannel/signalhandler_p.h
+@@ -56,6 +56,7 @@
+ #include <QVector>
+ #include <QMetaMethod>
+ #include <QDebug>
++#include <QThread>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -71,6 +72,7 @@ static const int s_destroyedSignalIndex = QObject::staticMetaObject.indexOfMetho
+ template<class Receiver>
+ class SignalHandler : public QObject
+ {
++    Q_DISABLE_COPY(SignalHandler)
+ public:
+     SignalHandler(Receiver *receiver, QObject *parent = 0);
+ 
+@@ -268,6 +270,7 @@ int SignalHandler<Receiver>::qt_metacall(QMetaObject::Call call, int methodId, v
+     if (call == QMetaObject::InvokeMetaMethod) {
+         const QObject *object = sender();
+         Q_ASSERT(object);
++        Q_ASSERT(QThread::currentThread() == object->thread());
+         Q_ASSERT(senderSignalIndex() == methodId);
+         Q_ASSERT(m_connectionsCounter.contains(object));
+         Q_ASSERT(m_connectionsCounter.value(object).contains(methodId));
+diff --git a/qtwebchannel/tests/auto/qml/testwebchannel.cpp b/qtwebchannel/tests/auto/qml/testwebchannel.cpp
+index 9891687..3ca81c2 100644
+--- a/qtwebchannel/tests/auto/qml/testwebchannel.cpp
++++ b/qtwebchannel/tests/auto/qml/testwebchannel.cpp
+@@ -46,7 +46,11 @@ TestWebChannel::~TestWebChannel()
+ 
+ bool TestWebChannel::clientIsIdle() const
+ {
+-    return QWebChannel::d_func()->publisher->clientIsIdle;
++    for (auto *transport : QWebChannel::d_func()->transports) {
++        if (QWebChannel::d_func()->publisher->isClientIdle(transport))
++            return true;
++    }
++    return false;
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp b/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
+index 181da9e..37f989a 100644
+--- a/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
++++ b/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
+@@ -785,7 +785,7 @@ void TestWebChannel::testTransportWrapObjectProperties()
+     DummyTransport *dummyTransport = new DummyTransport(this);
+     channel.connectTo(dummyTransport);
+     channel.d_func()->publisher->initializeClient(dummyTransport);
+-    channel.d_func()->publisher->setClientIsIdle(true);
++    channel.d_func()->publisher->setClientIsIdle(true, dummyTransport);
+ 
+     QCOMPARE(channel.d_func()->publisher->transportedWrappedObjects.size(), 0);
+ 
+@@ -943,8 +943,6 @@ void TestWebChannel::testInfiniteRecursion()
+ 
+ void TestWebChannel::testAsyncObject()
+ {
+-    QSKIP("This test is broken. See QTBUG-80729");
+-
+     QWebChannel channel;
+     channel.connectTo(m_dummyTransport);
+ 
+@@ -990,6 +988,50 @@ void TestWebChannel::testAsyncObject()
+     thread.wait();
+ }
+ 
++void TestWebChannel::testPropertyMultipleTransports()
++{
++    DummyTransport transport1;
++    DummyTransport transport2;
++
++    QWebChannel channel;
++    QMetaObjectPublisher *publisher = channel.d_func()->publisher;
++
++    TestObject testObj;
++    testObj.setObjectName("testObject");
++    channel.registerObject(testObj.objectName(), &testObj);
++    channel.connectTo(&transport1);
++    channel.connectTo(&transport2);
++
++    testObj.setProp("Hello");
++
++    publisher->initializeClient(&transport1);
++    publisher->initializeClient(&transport2);
++    publisher->setClientIsIdle(true, &transport1);
++    QCOMPARE(publisher->isClientIdle(&transport1), true);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++    QVERIFY(transport1.messagesSent().isEmpty());
++    QVERIFY(transport2.messagesSent().isEmpty());
++
++    testObj.setProp("World");
++    QTRY_COMPARE_WITH_TIMEOUT(transport1.messagesSent().size(), 1u, 2000);
++    QCOMPARE(transport2.messagesSent().size(), 0u);
++    publisher->setClientIsIdle(true, &transport2);
++    QTRY_COMPARE_WITH_TIMEOUT(transport2.messagesSent().size(), 1u, 2000);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++
++    testObj.setProp("!!!");
++    publisher->setClientIsIdle(true, &transport2);
++    QCOMPARE(publisher->isClientIdle(&transport2), true);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QTRY_COMPARE_WITH_TIMEOUT(transport2.messagesSent().size(), 2u, 2000);
++    QCOMPARE(transport1.messagesSent().size(), 1u);
++    publisher->setClientIsIdle(true, &transport1);
++    QTRY_COMPARE_WITH_TIMEOUT(transport1.messagesSent().size(), 2u, 2000);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++}
++
+ class FunctionWrapper : public QObject
+ {
+     Q_OBJECT
+@@ -1082,7 +1124,7 @@ void TestWebChannel::benchInitializeClients()
+ 
+         publisher->propertyUpdatesInitialized = false;
+         publisher->signalToPropertyMap.clear();
+-        publisher->signalHandler.clear();
++        publisher->signalHandlers.clear();
+     }
+ }
+ 
+@@ -1107,7 +1149,7 @@ void TestWebChannel::benchPropertyUpdates()
+             obj->change();
+         }
+ 
+-        channel.d_func()->publisher->clientIsIdle = true;
++        channel.d_func()->publisher->setClientIsIdle(true, m_dummyTransport);
+         channel.d_func()->publisher->sendPendingPropertyUpdates();
+     }
+ }
+diff --git a/qtwebchannel/tests/auto/webchannel/tst_webchannel.h b/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
+index eae21f4..dd4e690 100644
+--- a/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
++++ b/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
+@@ -348,6 +348,7 @@ private slots:
+     void testJsonToVariant();
+     void testInfiniteRecursion();
+     void testAsyncObject();
++    void testPropertyMultipleTransports();
+     void testDeletionDuringMethodInvocation_data();
+     void testDeletionDuringMethodInvocation();
+ 
+Submodule qtwebengine f328054d...38e0df6c (commits not present)
+Submodule qtwebsockets 65850954..63fb8da1:
+diff --git a/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp b/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
+index 2affdd5..95f1194 100644
+--- a/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
++++ b/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
+@@ -273,6 +273,7 @@ void QWebSocketDataProcessor::clear()
+     if (!m_pConverterState)
+         m_pConverterState = new QTextCodec::ConverterState(QTextCodec::ConvertInvalidToNull |
+                                                            QTextCodec::IgnoreHeader);
++    frame.clear();
+ }
+ 
+ /*!
+diff --git a/qtwebsockets/src/websockets/qwebsocketprotocol.cpp b/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
+index df87a93..d0465f1 100644
+--- a/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
++++ b/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
+@@ -210,7 +210,7 @@ void QWebSocketProtocol::mask(char *payload, quint64 size, quint32 maskingKey)
+                             quint8((maskingKey & 0x0000FF00u) >> 8),
+                             quint8((maskingKey & 0x000000FFu))
+                           };
+-    int i = 0;
++    quint64 i = 0;
+     while (size-- > 0)
+         *payload++ ^= mask[i++ % 4];
+ }
diff --git a/srcpkgs/qt5/template b/srcpkgs/qt5/template
index e0463e1c9198..ca1800ce9dc2 100644
--- a/srcpkgs/qt5/template
+++ b/srcpkgs/qt5/template
@@ -2,11 +2,11 @@
 #
 # revbump libqtxdg after bumping patch version
 pkgname=qt5
-version=5.15.7+20221119
+version=5.15.8
+revision=1
+build_style=meta
 # commit f8c9fb304bc3e53b3aa07f962cd74e9160decccc
 # base repo: https://invent.kde.org/qt/qt/qt5
-revision=4
-build_style=meta
 hostmakedepends="cmake clang flex perl glib-devel pkg-config
  python re2c ruby which"
 makedepends="SDL2-devel Vulkan-Headers alsa-lib-devel double-conversion-devel
@@ -29,8 +29,9 @@ homepage="https://qt.io/"
 # tarball is generated with `git archive-all qt5-$version.tar.gz`
 # to keep the size smaller qtwebengine, qtwebview, qtdocgallery, qtactiveqt and qtpim
 # can be marked with the export-ignore attribute
-distfiles="https://void.johnnynator.dev/distfiles/qt5-${version}.tar.gz"
-checksum=9d57af471c78029a362276b7c99108ea009f511bb9ba6ff6cb884f6ddd255e9f
+#distfiles="https://void.johnnynator.dev/distfiles/qt5-${version}.tar.gz"
+distfiles="https://download.qt.io/archive/qt/5.15/${version}/single/qt-everywhere-opensource-src-${version}.tar.xz"
+checksum=776a9302c336671f9406a53bd30b8e36f825742b2ec44a57c08217bff0fa86b9
 python_version=2 #unverified
 replaces="qt5-doc<5.6.0 qt5-quick1<5.6.0 qt5-quick1-devel<5.6.0 qt5-webkit<5.6.0 qt5-webkit-devel<5.6.0
  qt5-enginio<5.7.1 qt5-enginio-devel<5.7.1 qt5-plugin-gtk<5.7.1 qt5-canvas3d<5.13.0"
@@ -248,7 +249,6 @@ do_configure() {
 	# opts+=" -v"
 	opts+=" -skip qtwebengine"
 	opts+=" -skip qtwebview"
-	opts+=" -skip qtdocgallery"
 	opts+=" -skip qtpim"
 	opts+=" -skip qtsystems"
 	opts+=" -skip qtspeech"

From f8d4814ab768e63224b06d2ac05dd5ff0d2356a9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 078/130] qt6-multimedia: revbump for ffmpeg-6.0

---
 srcpkgs/qt6-multimedia/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-multimedia/template b/srcpkgs/qt6-multimedia/template
index d89e7d54eb5a..aae15e57ca7b 100644
--- a/srcpkgs/qt6-multimedia/template
+++ b/srcpkgs/qt6-multimedia/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-multimedia'
 pkgname=qt6-multimedia
 version=6.4.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DQT_FEATURE_gstreamer=ON"
 hostmakedepends="perl qt6-declarative-host-tools pkg-config qt6-shadertools"

From a7475a8958e163f53fdcde791caf5d15958f149c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 079/130] qtav: revbump for ffmpeg4-4.4.3

---
 srcpkgs/qtav/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtav/template b/srcpkgs/qtav/template
index 34c30b2c0c78..2d00ad104355 100644
--- a/srcpkgs/qtav/template
+++ b/srcpkgs/qtav/template
@@ -1,10 +1,10 @@
 # Template file for 'qtav'
 pkgname=qtav
 version=1.13.0
-revision=1
+revision=2
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel libass-devel libopenal-devel
+makedepends="ffmpeg4-devel libass-devel libopenal-devel
  libva-glx-devel libXv-devel pulseaudio-devel
  qt5-declarative-devel qt5-svg-devel
  qt5-quickcontrols"

From 1b5bb912204ce6efb71ea01843717b1698a88705 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 080/130] qtox: revbump for ffmpeg-6.0

---
 srcpkgs/qtox/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qtox/template b/srcpkgs/qtox/template
index 16019d7eaec9..5cea0b11b697 100644
--- a/srcpkgs/qtox/template
+++ b/srcpkgs/qtox/template
@@ -1,7 +1,7 @@
 # Template file for 'qtox'
 pkgname=qtox
 version=1.17.6
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DUPDATE_CHECK=OFF
  -DGIT_DESCRIBE=${version}

From 89e5d436d14ed04676574302a6694b82393b5386 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 081/130] retroarch: revbump for ffmpeg-6.0

---
 srcpkgs/retroarch/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroarch/template b/srcpkgs/retroarch/template
index 240d3df9db00..6d0b16ae2598 100644
--- a/srcpkgs/retroarch/template
+++ b/srcpkgs/retroarch/template
@@ -1,7 +1,7 @@
 # Template file for 'retroarch'
 pkgname=retroarch
 version=1.14.0
-revision=1
+revision=2
 build_style=configure
 configure_args="--prefix=/usr --sysconfdir=/etc --enable-networking
  --enable-udev --disable-builtinflac --disable-builtinglslang

From 192d0aaa5e505e89f0c6c3c8b299dc610e767309 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 082/130] scrcpy: revbump for ffmpeg-6.0

---
 srcpkgs/scrcpy/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/scrcpy/template b/srcpkgs/scrcpy/template
index ee6e698e387f..8ada5ca4323f 100644
--- a/srcpkgs/scrcpy/template
+++ b/srcpkgs/scrcpy/template
@@ -1,7 +1,7 @@
 # Template file for 'scrcpy'
 pkgname=scrcpy
 version=2.0
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcompile_server=false
  -Dprebuilt_server=/usr/share/scrcpy/scrcpy-server-v${version}"

From e343ec6226ae1f5bfbcb09f6c3a4b14dee0b8c10 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 083/130] spek-alternative: revbump for ffmpeg4-4.4.3

---
 srcpkgs/spek-alternative/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/spek-alternative/template b/srcpkgs/spek-alternative/template
index d65086b8f008..05246f1b8d0c 100644
--- a/srcpkgs/spek-alternative/template
+++ b/srcpkgs/spek-alternative/template
@@ -1,11 +1,11 @@
 # Template file for 'spek-alternative'
 pkgname=spek-alternative
 version=0.8.2.3
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake gettext-devel intltool libtool pkg-config wxWidgets-common"
-makedepends="ffmpeg-devel wxWidgets-gtk3-devel"
-depends="ffmpeg"
+makedepends="ffmpeg4-devel wxWidgets-gtk3-devel"
+depends="ffmpeg4"
 short_desc="Acoustic spectrum analyser"
 maintainer="Kartik Singh <kartik.ynwa@gmail.com>"
 license="GPL-3.0-or-later"

From 3f97f97606cddc28f1af588bdefc2fd2426a98fd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 084/130] ssr: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ssr/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/ssr/template b/srcpkgs/ssr/template
index b055b9ec0774..3448ca110eb0 100644
--- a/srcpkgs/ssr/template
+++ b/srcpkgs/ssr/template
@@ -1,11 +1,11 @@
 # Template file for 'ssr'
 pkgname=ssr
 version=0.4.4
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_QT5=ON"
 hostmakedepends="pkg-config"
-makedepends="alsa-lib-devel ffmpeg-devel glu-devel jack-devel pulseaudio-devel
+makedepends="alsa-lib-devel ffmpeg4-devel glu-devel jack-devel pulseaudio-devel
  qt5-tools-devel qt5-x11extras-devel libXinerama-devel v4l-utils-devel"
 depends="desktop-file-utils hicolor-icon-theme"
 short_desc="Simple Screen Recorder for programs and games"

From f20fa071b18ed2cc44a2e7302e7662cd081ea4a7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 085/130] sumo: revbump for ffmpeg-6.0

---
 srcpkgs/sumo/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/sumo/template b/srcpkgs/sumo/template
index 0f9b9ec815f5..a3fe134aa5ac 100644
--- a/srcpkgs/sumo/template
+++ b/srcpkgs/sumo/template
@@ -1,7 +1,7 @@
 # Template file for 'sumo'
 pkgname=sumo
 version=1.12.0
-revision=5
+revision=6
 build_style=cmake
 hostmakedepends="libgdal-tools pkg-config swig python3-setuptools"
 makedepends="python3-devel ffmpeg-devel fox-devel gl2ps-devel libgdal-devel

From 141ddd9358317c3d4847ea07b78484010055e60e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 086/130] synfig: revbump for ffmpeg-6.0 and mlt7

---
 srcpkgs/synfig/patches/ffmpeg6.patch | 46 ++++++++++++++++++++++++++++
 srcpkgs/synfig/template              |  4 +--
 2 files changed, 48 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/synfig/patches/ffmpeg6.patch

diff --git a/srcpkgs/synfig/patches/ffmpeg6.patch b/srcpkgs/synfig/patches/ffmpeg6.patch
new file mode 100644
index 000000000000..a70204a9d23e
--- /dev/null
+++ b/srcpkgs/synfig/patches/ffmpeg6.patch
@@ -0,0 +1,46 @@
+--- a/src/modules/mod_libavcodec/trgt_av.cpp	2022-10-25 09:14:12.000000000 -0400
++++ b/src/modules/mod_libavcodec/trgt_av.cpp	2023-05-05 12:04:04.897219775 -0400
+@@ -49,6 +49,8 @@
+ #   endif
+ #endif
+ 
++#include <libavcodec/avcodec.h>
++
+ #ifdef HAVE_LIBSWSCALE_SWSCALE_H
+ #	include <libswscale/swscale.h>
+ #elif defined(HAVE_SWSCALE_H)
+--- a/src/modules/mod_libavcodec/trgt_av.cpp	2023-05-05 12:07:26.579860833 -0400
++++ b/src/modules/mod_libavcodec/trgt_av.cpp	2023-05-05 12:14:11.122033763 -0400
+@@ -236,12 +236,11 @@
+ 		close();
+ 
+ 		if (!av_registered) {
+-			av_register_all();
+ 			av_registered = true;
+ 		}
+ 
+ 		// guess format
+-		AVOutputFormat *format = av_guess_format(NULL, filename.c_str(), NULL);
++		const AVOutputFormat *format = av_guess_format(NULL, filename.c_str(), NULL);
+ 		if (!format) {
+ 			synfig::warning("Target_LibAVCodec: unable to guess the output format, defaulting to MPEG");
+ 			format = av_guess_format("mpeg", NULL, NULL);
+@@ -256,15 +255,15 @@
+ 		context = avformat_alloc_context();
+ 		assert(context);
+ 		context->oformat = format;
+-		if (filename.size() + 1 > sizeof(context->filename)) {
++		if (filename.size() + 1 > sizeof(context->url)) {
+ 			synfig::error(
+ 				"Target_LibAVCodec: filename too long, max length is %d, filename is '%s'",
+-				sizeof(context->filename) - 1,
++				sizeof(context->url) - 1,
+ 				filename.c_str() );
+ 			close();
+ 			return false;
+ 		}
+-		memcpy(context->filename, filename.c_str(), filename.size() + 1);
++		memcpy(context->url, filename.c_str(), filename.size() + 1);
+ 
+ 		packet = av_packet_alloc();
+ 		assert(packet);
diff --git a/srcpkgs/synfig/template b/srcpkgs/synfig/template
index 5f5f5bb3f4b2..6e0d713150ae 100644
--- a/srcpkgs/synfig/template
+++ b/srcpkgs/synfig/template
@@ -6,7 +6,7 @@ revision=2
 build_style=gnu-configure
 configure_args="--with-boost-libdir=${XBPS_CROSS_BASE}/usr/lib"
 hostmakedepends="boost-build ImageMagick pkg-config intltool"
-makedepends="ETL gettext-devel libxml++-devel mlt-devel libmagick-devel
+makedepends="ETL gettext-devel libxml++-devel mlt7-devel libmagick-devel
  libmng-devel boost-build boost-devel libopenexr-devel ffmpeg-devel"
 depends="ImageMagick"
 short_desc="CLI 2D vector and timeline-based animation software"
@@ -20,7 +20,7 @@ CXXFLAGS="-std=c++11 -DHAVE_LOCALE_H=1"
 
 synfig-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision}
-	 libopenexr-devel libxml++-devel mlt-devel"
+	 libopenexr-devel libxml++-devel mlt7-devel"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/bin/synfig-config

From 08c40ae13f36544c386999284a7e9cc9ccd37ab0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 5 May 2023 12:57:57 -0400
Subject: [PATCH 087/130] synfigstudio: revbump for synfig mlt7

---
 srcpkgs/synfigstudio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/synfigstudio/template b/srcpkgs/synfigstudio/template
index 91349169ed2b..af1c5a296ef0 100644
--- a/srcpkgs/synfigstudio/template
+++ b/srcpkgs/synfigstudio/template
@@ -2,7 +2,7 @@
 # Should be kept in sync with 'synfig' and 'ETL'
 pkgname=synfigstudio
 version=1.4.4
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--disable-update-mimedb"
 hostmakedepends="pkg-config intltool gettext synfig"

From f1c3cd289dee8bf9147e557c775113ce11035213 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 088/130] telegram-desktop: revbump for ffmpeg-6.0

---
 srcpkgs/telegram-desktop/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/telegram-desktop/template b/srcpkgs/telegram-desktop/template
index aae9f3135100..7943b36f0b8a 100644
--- a/srcpkgs/telegram-desktop/template
+++ b/srcpkgs/telegram-desktop/template
@@ -1,7 +1,7 @@
 # Template file for 'telegram-desktop'
 pkgname=telegram-desktop
 version=4.6.5
-revision=1
+revision=2
 build_style=cmake
 build_helper="qemu"
 configure_args="-DTDESKTOP_API_ID=209235

From 9f410af0f16cc1de7ee78849701aa810624f9cc1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 089/130] tg_owt: revbump for ffmpeg-6.0

---
 srcpkgs/tg_owt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tg_owt/template b/srcpkgs/tg_owt/template
index 97d195ddb34a..551614b24956 100644
--- a/srcpkgs/tg_owt/template
+++ b/srcpkgs/tg_owt/template
@@ -1,7 +1,7 @@
 # Template file for 'tg_owt'
 pkgname=tg_owt
 version=0.0.0.20230107
-revision=1
+revision=2
 _commit=5098730b9eb6173f0b52068fe2555b7c1015123a
 _libyuv_commit=00950840d1c9bcbb3eb6ebc5aac5793e71166c8b
 _abseil_commit=8c0b94e793a66495e0b1f34a5eb26bd7dc672db0

From 33554050489c681efc31187fd02b1648e11c8fd3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 090/130] timg: revbump for ffmpeg-6.0

---
 srcpkgs/timg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/timg/template b/srcpkgs/timg/template
index 91f1516b2597..334443d3f9bb 100644
--- a/srcpkgs/timg/template
+++ b/srcpkgs/timg/template
@@ -1,7 +1,7 @@
 # Template file for 'timg'
 pkgname=timg
 version=1.4.4
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_OPENSLIDE_SUPPORT=off -Wno-dev"
 hostmakedepends="pkg-config git"

From 9f6b096156cc99bbdd829b6a713f36c89ee67439 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 091/130] tvheadend: revbump for ffmpeg4-4.4.3

---
 srcpkgs/tvheadend/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/tvheadend/template b/srcpkgs/tvheadend/template
index e6b16d7ccf3b..46b52b6fb7f9 100644
--- a/srcpkgs/tvheadend/template
+++ b/srcpkgs/tvheadend/template
@@ -1,14 +1,14 @@
 # Template file for 'tvheadend'
 pkgname=tvheadend
 version=4.2.8
-revision=6
+revision=7
 build_style=gnu-configure
 configure_args="--enable-dvbscan --disable-ffmpeg_static
 --disable-hdhomerun_static --disable-bintray_cache --disable-libx264_static
 --disable-libx265_static --disable-libvpx_static --disable-libtheora_static
 --disable-libvorbis_static --disable-libfdkaac_static"
 hostmakedepends="gettext pkg-config python git which"
-makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg-devel"
+makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg4-devel"
 short_desc="TV streaming server"
 maintainer="lemmi <lemmi@nerd2nerd.org>"
 license="GPL-3.0-only"

From a0d740bdc08ec4461cbdf1a953b154c827de849c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 092/130] unpaper: update to 7.0.0.

---
 srcpkgs/unpaper/template | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/srcpkgs/unpaper/template b/srcpkgs/unpaper/template
index 38ed47a58401..1ff910e722af 100644
--- a/srcpkgs/unpaper/template
+++ b/srcpkgs/unpaper/template
@@ -1,13 +1,13 @@
 # Template file for 'unpaper'
 pkgname=unpaper
-version=6.1
-revision=3
-build_style=gnu-configure
+version=7.0.0
+revision=1
+build_style=meson
+hostmakedepends="pkg-config meson libxslt"
+makedepends="ffmpeg-devel python3-Sphinx"
+short_desc="Post-processing tool for scanned sheets of paper"
 maintainer="Orphaned <orphan@voidlinux.org>"
-hostmakedepends="pkg-config libxslt"
-makedepends="ffmpeg-devel"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://www.flameeyes.eu/projects/unpaper"
-short_desc="A post-processing tool for scanned sheets of paper"
 distfiles="https://www.flameeyes.eu/files/${pkgname}-${version}.tar.xz"
-checksum=237c84f5da544b3f7709827f9f12c37c346cdf029b1128fb4633f9bafa5cb930
+checksum=2575fbbf26c22719d1cb882b59602c9900c7f747118ac130883f63419be46a80

From 8e0375be46171fcd7dd9468bc28b4d7ced3fe295 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 093/130] vba-m: revbump for ffmpeg-6.0

---
 srcpkgs/vba-m/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vba-m/template b/srcpkgs/vba-m/template
index ba153e0b58ca..aa6093645e97 100644
--- a/srcpkgs/vba-m/template
+++ b/srcpkgs/vba-m/template
@@ -2,7 +2,7 @@
 pkgname=vba-m
 reverts=1292_2
 version=2.1.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_GTK=TRUE -DENABLE_FFMPEG=TRUE -DENABLE_LINK=TRUE -DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="gettext pkg-config unzip zip yasm wxWidgets-gtk3-devel"

From 197baa2fecfcdbdce2e721ccf69d153218b89283 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 094/130] vice: revbump for ffmpeg4-4.4.3

---
 srcpkgs/vice/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/vice/template b/srcpkgs/vice/template
index 0924767cfcfb..5981e45149d0 100644
--- a/srcpkgs/vice/template
+++ b/srcpkgs/vice/template
@@ -1,7 +1,7 @@
 # Template file for 'vice'
 pkgname=vice
 version=3.5
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="
 	$(vopt_enable sdl2 sdlui2)
@@ -28,7 +28,7 @@ makedepends="
 	$(vopt_if gtk3 gtk+3-devel)
 	$(vopt_if gtk3 pulseaudio-devel)
 	$(vopt_if gtk3 pango-devel)
-	$(vopt_if ffmpeg ffmpeg-devel)"
+	$(vopt_if ffmpeg ffmpeg4-devel)"
 short_desc="Emulator for C64, C128, CBM-II, PET, VIC20, Plus4 and C16"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"

From 555c583938b20ce29c6da8890e2ff435b5d577d8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 095/130] waypipe: revbump for ffmpeg-6.0

---
 srcpkgs/waypipe/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waypipe/template b/srcpkgs/waypipe/template
index 5c4161900060..1a46fe27f7d8 100644
--- a/srcpkgs/waypipe/template
+++ b/srcpkgs/waypipe/template
@@ -1,7 +1,7 @@
 # Template file for 'waypipe'
 pkgname=waypipe
 version=0.8.4
-revision=1
+revision=2
 build_style=meson
 # lto is off because it causes linking errors in armv6l and armv7l (due to NEON)
 configure_args="-Dwerror=false -Dwith_dmabuf=enabled -Dwith_lz4=enabled

From 9f7d61d3840076cb3a2402774f2a0dc7568806ac Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 096/130] wf-recorder: revbump for ffmpeg-6.0

---
 srcpkgs/wf-recorder/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/wf-recorder/template b/srcpkgs/wf-recorder/template
index e278eb001600..5d014a5f28af 100644
--- a/srcpkgs/wf-recorder/template
+++ b/srcpkgs/wf-recorder/template
@@ -1,7 +1,7 @@
 # Template file for 'wf-recorder'
 pkgname=wf-recorder
 version=0.3.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config scdoc wayland-devel"
 makedepends="wayland-protocols wayland-devel ffmpeg-devel x264-devel

From 63f9107c64d75b09b2d8bd7f243439e67dec7d15 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 097/130] xpra: revbump for ffmpeg-6.0

---
 srcpkgs/xpra/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xpra/template b/srcpkgs/xpra/template
index 38f83283b1e5..b6e01ff0a813 100644
--- a/srcpkgs/xpra/template
+++ b/srcpkgs/xpra/template
@@ -1,7 +1,7 @@
 # Template file for 'xpra'
 pkgname=xpra
 version=4.4.4
-revision=1
+revision=2
 build_style=python3-module
 make_build_args="--without-cuda_kernels --without-cuda_rebuild"
 make_install_args="$(vopt_with docs) ${make_build_args}"

From 662734cb1c7fc58526257d3e33acb1b4d92f024a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:07:40 -0400
Subject: [PATCH 098/130] nv-codec-headers: update to 12.0.16.0

---
 srcpkgs/nv-codec-headers/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/nv-codec-headers/template b/srcpkgs/nv-codec-headers/template
index 3d422a61e489..251e057f826f 100644
--- a/srcpkgs/nv-codec-headers/template
+++ b/srcpkgs/nv-codec-headers/template
@@ -1,6 +1,6 @@
 # Template file for 'nv-codec-headers'
 pkgname=nv-codec-headers
-version=11.1.5.1
+version=12.0.16.0
 revision=1
 build_style=gnu-makefile
 short_desc="FFmpeg version of headers required to interface with Nvidias codec APIs"
@@ -8,7 +8,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="MIT"
 homepage="http://git.videolan.org/?p=ffmpeg/nv-codec-headers.git"
 distfiles="https://github.com/FFmpeg/nv-codec-headers/archive/n${version}.tar.gz"
-checksum=d095fbd56aa93772471a323be0ebe65504a0f43f06c76a30b6d25da77b06ae9c
+checksum=2a1533b65f55f9da52956faf0627ed3b74868ac0c7f269990edd21369113b48f
 
 post_install() {
 	sed -n '4,25p' include/ffnvcodec/nvEncodeAPI.h > LICENSE

From b2acede94aa1b2de553fab049039500efad9f79f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:08:40 -0400
Subject: [PATCH 099/130] openimagedenoise: revbump for ffmpeg-6.0

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index db5ccdb055cc..cb90045afb63 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,7 +1,7 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
 version=1.4.3
-revision=1
+revision=2
 archs="x86_64*"
 build_style=cmake
 hostmakedepends="ispc python3"

From 039e9516e5ec8c20f0df654f49993751ae1e4fb9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 16 Dec 2022 09:25:22 -0500
Subject: [PATCH 100/130] intel-gmmlib: update to 22.3.3

---
 srcpkgs/intel-gmmlib/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/intel-gmmlib/template b/srcpkgs/intel-gmmlib/template
index 8ed6ed3cf56c..2605226152e5 100644
--- a/srcpkgs/intel-gmmlib/template
+++ b/srcpkgs/intel-gmmlib/template
@@ -1,6 +1,6 @@
 # Template file for 'intel-gmmlib'
 pkgname=intel-gmmlib
-version=22.2.0
+version=22.3.3
 revision=1
 archs="i686* x86_64*"
 build_style=cmake
@@ -18,7 +18,7 @@ maintainer="Stefano Ragni <st3r4g@protonmail.com>"
 license="MIT"
 homepage="https://github.com/intel/gmmlib"
 distfiles="https://github.com/intel/gmmlib/archive/intel-gmmlib-${version}.tar.gz"
-checksum=0b2253894c6fc8455b6d7c5e87e6504a76d6f60ea192e1445c2f93164bf529c0
+checksum=86651bd2803c9f0afd82471bec784e65d2b418dee315a053d22215eb2a679be7
 
 lib32disabled=yes
 

From 04f823cf014314ef50326aa5808b3c245e62b9ef Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 16 Dec 2022 09:25:47 -0500
Subject: [PATCH 101/130] intel-media-driver: update to 22.6.4

---
 ...mmon-Enable-MMC-in-free-kernel-build.patch | 125 ++++++++++++++++++
 .../intel-media-driver/patches/execinfo.patch |  58 --------
 srcpkgs/intel-media-driver/template           |   4 +-
 3 files changed, 127 insertions(+), 60 deletions(-)
 create mode 100644 srcpkgs/intel-media-driver/patches/0001-Media-Common-Enable-MMC-in-free-kernel-build.patch
 delete mode 100644 srcpkgs/intel-media-driver/patches/execinfo.patch

diff --git a/srcpkgs/intel-media-driver/patches/0001-Media-Common-Enable-MMC-in-free-kernel-build.patch b/srcpkgs/intel-media-driver/patches/0001-Media-Common-Enable-MMC-in-free-kernel-build.patch
new file mode 100644
index 000000000000..525fb688722c
--- /dev/null
+++ b/srcpkgs/intel-media-driver/patches/0001-Media-Common-Enable-MMC-in-free-kernel-build.patch
@@ -0,0 +1,125 @@
+From e68feab7db036838d9521ba3b9f00717c37c024c Mon Sep 17 00:00:00 2001
+From: JayYang <jay.yang@intel.com>
+Date: Tue, 21 Mar 2023 17:17:55 +0800
+Subject: [PATCH] [Media Common] Enable MMC in free kernel build
+
+Add mmc build definition in free kernel build
+---
+ media_driver/agnostic/gen9/codec/hal/media_srcs.cmake          | 2 +-
+ media_driver/cmake/linux/media_feature_flags_linux.cmake       | 3 +--
+ .../media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp        | 2 +-
+ .../media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp        | 2 +-
+ .../media_interfaces_m9_glk/media_interfaces_g9_glk.cpp        | 2 +-
+ .../media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp        | 2 +-
+ .../media_interfaces_m9_skl/media_interfaces_g9_skl.cpp        | 2 +-
+ 7 files changed, 7 insertions(+), 8 deletions(-)
+
+diff --git a/media_driver/agnostic/gen9/codec/hal/media_srcs.cmake b/media_driver/agnostic/gen9/codec/hal/media_srcs.cmake
+index 8bb36bafe..78902a22d 100644
+--- a/media_driver/agnostic/gen9/codec/hal/media_srcs.cmake
++++ b/media_driver/agnostic/gen9/codec/hal/media_srcs.cmake
+@@ -27,7 +27,7 @@ set(TMP_1_HEADERS_
+     ${CMAKE_CURRENT_LIST_DIR}/codechal_hw_g9_X.h
+ )
+ 
+-if(${MMC_Supported} STREQUAL "yes")
++if(${MMC_Supported} STREQUAL "yes" AND ENABLE_NONFREE_KERNELS AND ENABLE_KERNELS)
+     set(TMP_1_SOURCES_
+         ${TMP_1_SOURCES_}
+         ${CMAKE_CURRENT_LIST_DIR}/codechal_memdecomp_g9.cpp
+diff --git a/media_driver/cmake/linux/media_feature_flags_linux.cmake b/media_driver/cmake/linux/media_feature_flags_linux.cmake
+index de0ca853f..8121ea60c 100644
+--- a/media_driver/cmake/linux/media_feature_flags_linux.cmake
++++ b/media_driver/cmake/linux/media_feature_flags_linux.cmake
+@@ -35,7 +35,6 @@ if(NOT ENABLE_KERNELS OR NOT ENABLE_NONFREE_KERNELS)
+     bs_set_if_undefined(HEVC_Encode_VME_Supported "no")
+     bs_set_if_undefined(MPEG2_Encode_VME_Supported "no")
+     bs_set_if_undefined(CMRT_HEVC_ENC_FEI_Supported "no")
+-    bs_set_if_undefined(MMC_Supported "no")
+     bs_set_if_undefined(VC1_Decode_Supported "no")
+     bs_set_if_undefined(Decode_Processing_Supported "no")
+     bs_set_if_undefined(Kernel_Auto_Denoise_Supported "no")
+@@ -46,7 +45,6 @@ else()
+     bs_set_if_undefined(HEVC_Encode_VME_Supported "${Encode_VME_Supported}")
+     bs_set_if_undefined(MPEG2_Encode_VME_Supported "${Encode_VME_Supported}")
+     bs_set_if_undefined(CMRT_HEVC_ENC_FEI_Supported "yes")
+-    bs_set_if_undefined(MMC_Supported "yes")
+     bs_set_if_undefined(VC1_Decode_Supported "yes")
+     bs_set_if_undefined(Decode_Processing_Supported "yes")
+     bs_set_if_undefined(Kernel_Auto_Denoise_Supported "yes")
+@@ -64,6 +62,7 @@ bs_set_if_undefined(VP9_Decode_Supported "yes")
+ bs_set_if_undefined(VP_SFC_Supported "yes")
+ bs_set_if_undefined(Common_Encode_Supported "yes")
+ bs_set_if_undefined(Media_Scalability_Supported "yes")
++bs_set_if_undefined(MMC_Supported "yes")
+ 
+ # features controlled by global flag Encode_VDEnc_Supported
+ bs_set_if_undefined(AVC_Encode_VDEnc_Supported "${Encode_VDEnc_Supported}")
+diff --git a/media_driver/media_interface/media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp b/media_driver/media_interface/media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp
+index 3f306ee2a..8e4c0f532 100644
+--- a/media_driver/media_interface/media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp
+@@ -135,7 +135,7 @@ MOS_STATUS MhwInterfacesG9Bxt::Initialize(
+ 
+     return MOS_STATUS_SUCCESS;
+ }
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool bxtRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Bxt>((uint32_t)IGFX_BROXTON);
+diff --git a/media_driver/media_interface/media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp b/media_driver/media_interface/media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp
+index b8fa1eec0..84e0fad1d 100644
+--- a/media_driver/media_interface/media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp
+@@ -44,7 +44,7 @@ static bool cflRegisteredMhw =
+     MediaFactory<uint32_t, MhwInterfaces>::
+     Register<MhwInterfacesG9Kbl>((uint32_t)IGFX_COFFEELAKE);
+ 
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool cflRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Kbl>((uint32_t)IGFX_COFFEELAKE);
+diff --git a/media_driver/media_interface/media_interfaces_m9_glk/media_interfaces_g9_glk.cpp b/media_driver/media_interface/media_interfaces_m9_glk/media_interfaces_g9_glk.cpp
+index de81e6091..2638cb3a6 100644
+--- a/media_driver/media_interface/media_interfaces_m9_glk/media_interfaces_g9_glk.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_glk/media_interfaces_g9_glk.cpp
+@@ -65,7 +65,7 @@ static bool glkRegisteredMhw =
+     MediaFactory<uint32_t, MhwInterfaces>::
+     Register<MhwInterfacesG9Kbl>((uint32_t)IGFX_GEMINILAKE);
+ 
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool glkRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Kbl>((uint32_t)IGFX_GEMINILAKE);
+diff --git a/media_driver/media_interface/media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp b/media_driver/media_interface/media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp
+index 99d786185..4e9c6e7f1 100644
+--- a/media_driver/media_interface/media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp
+@@ -131,7 +131,7 @@ MOS_STATUS MhwInterfacesG9Kbl::Initialize(
+ 
+     return MOS_STATUS_SUCCESS;
+ }
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool kblRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Kbl>((uint32_t)IGFX_KABYLAKE);
+diff --git a/media_driver/media_interface/media_interfaces_m9_skl/media_interfaces_g9_skl.cpp b/media_driver/media_interface/media_interfaces_m9_skl/media_interfaces_g9_skl.cpp
+index e2520edf7..4b0012c64 100644
+--- a/media_driver/media_interface/media_interfaces_m9_skl/media_interfaces_g9_skl.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_skl/media_interfaces_g9_skl.cpp
+@@ -139,7 +139,7 @@ MOS_STATUS MhwInterfacesG9Skl::Initialize(
+ 
+     return MOS_STATUS_SUCCESS;
+ }
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool sklRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Skl>((uint32_t)IGFX_SKYLAKE);
+-- 
+2.40.0
+
diff --git a/srcpkgs/intel-media-driver/patches/execinfo.patch b/srcpkgs/intel-media-driver/patches/execinfo.patch
deleted file mode 100644
index 25d21192d5a1..000000000000
--- a/srcpkgs/intel-media-driver/patches/execinfo.patch
+++ /dev/null
@@ -1,58 +0,0 @@
-From b17354142563b45e0ebf427485591426481368fd Mon Sep 17 00:00:00 2001
-From: Bernd Kuhls <bernd.kuhls@t-online.de>
-Date: Fri, 29 Jul 2022 19:51:39 +0200
-Subject: [PATCH] Fix uClibc build
-
-uClibc does not provide execinfo.h
----
- CMakeLists.txt                                              | 6 ++++++
- .../linux/common/os/osservice/mos_utilities_specific.cpp    | 4 ++++
- 2 files changed, 10 insertions(+)
-
-diff --git a/CMakeLists.txt b/CMakeLists.txt
-index 053904748..4a3f0869e 100755
---- a/CMakeLists.txt
-+++ b/CMakeLists.txt
-@@ -53,6 +53,12 @@ option (BUILD_CMRTLIB "Build and Install cmrtlib together with media driver" ON)
- 
- option (ENABLE_PRODUCTION_KMD "Enable Production KMD header files" OFF)
- 
-+include(CheckIncludeFileCXX)
-+check_include_file_cxx("execinfo.h" HAVE_EXECINFO)
-+if (HAVE_EXECINFO)
-+    add_definitions(-DHAVE_EXECINFO)
-+endif()
-+
- include(GNUInstallDirs)
- 
- if (BUILD_CMRTLIB AND NOT CMAKE_WDDM_LINUX)
-diff --git a/media_softlet/linux/common/os/osservice/mos_utilities_specific.cpp b/media_softlet/linux/common/os/osservice/mos_utilities_specific.cpp
-index bde216b83..120b02d55 100644
---- a/media_softlet/linux/common/os/osservice/mos_utilities_specific.cpp
-+++ b/media_softlet/linux/common/os/osservice/mos_utilities_specific.cpp
-@@ -34,7 +34,9 @@
- #include <signal.h>
- #include <unistd.h>  // fork
- #include <algorithm>
-+#ifdef HAVE_EXECINFO
- #include <execinfo.h> // backtrace
-+#endif
- #include <sys/types.h>
- #include <sys/stat.h>  // fstat
- #include <sys/ipc.h>  // System V IPC
-@@ -2473,6 +2475,7 @@ void MosUtilities::MosTraceEvent(
-                 MOS_FreeMemory(pTraceBuf);
-             }
-         }
-+#ifdef HAVE_EXECINFO
-         if (m_mosTraceFilter & (1ULL << TR_KEY_CALL_STACK))
-         {
-             // reserve space for header and stack size field.
-@@ -2492,6 +2495,7 @@ void MosUtilities::MosTraceEvent(
-                 size_t ret = write(MosUtilitiesSpecificNext::m_mosTraceFd, traceBuf, nLen);
-             }
-         }
-+#endif
-     }
-     return;
- }
diff --git a/srcpkgs/intel-media-driver/template b/srcpkgs/intel-media-driver/template
index 1ca94569e117..1735b90c65ce 100644
--- a/srcpkgs/intel-media-driver/template
+++ b/srcpkgs/intel-media-driver/template
@@ -1,6 +1,6 @@
 # Template file for 'intel-media-driver'
 pkgname=intel-media-driver
-version=22.5.3
+version=22.6.4
 revision=1
 archs="x86_64*"
 build_style=cmake
@@ -12,7 +12,7 @@ maintainer="Stefano Ragni <st3r4g@protonmail.com>"
 license="MIT, BSD-3-Clause"
 homepage="https://github.com/intel/media-driver"
 distfiles="https://github.com/intel/media-driver/archive/intel-media-${version}.tar.gz"
-checksum=65652b365d48be3c9f0b3c561502952b92ee5fcc587520b88d0d752cf2a6a3b5
+checksum=0c04b9d74b92de41fd409b62913ce4afd799236c0b6bc1983a496990764e5d90
 
 build_options="nonfree"
 desc_option_nonfree="Enable nonfree kernels"

From e60eeb3d157ebea5c44bf585326c14705ff25fa3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 16 Dec 2022 09:31:43 -0500
Subject: [PATCH 102/130] New package: onevpl-2023.1.2

---
 common/shlibs           |  1 +
 srcpkgs/onevpl-devel    |  1 +
 srcpkgs/onevpl/template | 34 ++++++++++++++++++++++++++++++++++
 3 files changed, 36 insertions(+)
 create mode 120000 srcpkgs/onevpl-devel
 create mode 100644 srcpkgs/onevpl/template

diff --git a/common/shlibs b/common/shlibs
index d0d328b09ef9..dbc2dbf25d3d 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -879,6 +879,7 @@ libwebp.so.7 libwebp-0.6.0_1
 libwebpmux.so.3 libwebp-0.6.0_1
 libwebpdemux.so.2 libwebp-0.5.0_1
 libwebpdecoder.so.3 libwebp-0.6.0_1
+libvpl.so.2 onevpl-2023.1.2_1
 libva-x11.so.2 libva-2.13.0_1
 libva.so.2 libva-2.13.0_1
 libva-glx.so.2 libva-glx-2.13.0_1
diff --git a/srcpkgs/onevpl-devel b/srcpkgs/onevpl-devel
new file mode 120000
index 000000000000..e2306500b487
--- /dev/null
+++ b/srcpkgs/onevpl-devel
@@ -0,0 +1 @@
+onevpl
\ No newline at end of file
diff --git a/srcpkgs/onevpl/template b/srcpkgs/onevpl/template
new file mode 100644
index 000000000000..85c7c2da85ce
--- /dev/null
+++ b/srcpkgs/onevpl/template
@@ -0,0 +1,34 @@
+# Template file for 'onevpl'
+pkgname=onevpl
+version=2023.1.2
+revision=1
+archs="x86_64*"
+build_style=cmake
+configure_args="
+	-DCMAKE_BUILD_TYPE=Release -Wno-dev
+	-DBUILD_PYTHON_BINDING:BOOL='OFF'
+	-DBUILD_EXAMPLES:BOOL='OFF'
+	-DBUILD_TESTS:BOOL='ON'
+	-DINSTALL_EXAMPLE_CODE:BOOL='OFF'"
+hostmakedepends="cmake libX11 python wayland-protocols pkg-config"
+makedepends="libva-devel libX11-devel wayland-devel"
+short_desc="Intel oneAPI Video Processing library"
+maintainer="zlice <zlice555@gmail.com>"
+license="MIT"
+homepage="https://www.intel.com/content/www/us/en/developer/tools/oneapi/onevpl.html"
+distfiles="https://github.com/oneapi-src/oneVPL/archive/v${version}/${pkgname}-${version}.tar.gz"
+checksum=b2261cca174ce1815f3d47c647921ab17f68267c69c1e2444ff27aab7d199cbb
+
+post_install() {
+	vlicense LICENSE
+}
+
+onevpl-devel_package() {
+	depends="${makedepends} ${sourcepkg}-${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.so"
+	}
+}

From 38c14e84fc61a229d7f2bafd4bf58d8ed8fa0ecd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 16 Dec 2022 15:27:04 -0500
Subject: [PATCH 103/130] New package: onevpl-intel-gpu-22.6.4

---
 srcpkgs/onevpl-intel-gpu-devel    |  1 +
 srcpkgs/onevpl-intel-gpu/template | 27 +++++++++++++++++++++++++++
 2 files changed, 28 insertions(+)
 create mode 120000 srcpkgs/onevpl-intel-gpu-devel
 create mode 100644 srcpkgs/onevpl-intel-gpu/template

diff --git a/srcpkgs/onevpl-intel-gpu-devel b/srcpkgs/onevpl-intel-gpu-devel
new file mode 120000
index 000000000000..47920ceecf91
--- /dev/null
+++ b/srcpkgs/onevpl-intel-gpu-devel
@@ -0,0 +1 @@
+onevpl-intel-gpu
\ No newline at end of file
diff --git a/srcpkgs/onevpl-intel-gpu/template b/srcpkgs/onevpl-intel-gpu/template
new file mode 100644
index 000000000000..f14acb728a54
--- /dev/null
+++ b/srcpkgs/onevpl-intel-gpu/template
@@ -0,0 +1,27 @@
+# Template file for 'onevpl-intel-gpu'
+pkgname=onevpl-intel-gpu
+version=22.6.4
+revision=1
+archs="x86_64*"
+build_style=cmake
+configure_args="-Wno-dev -DCMAKE_BUILD_TYPE=Release"
+hostmakedepends="cmake pkg-config"
+makedepends="libdrm-devel libva-devel onevpl-devel"
+short_desc="Runtime implementation of oneVPL API for Intel Gen GPUs"
+maintainer="zlice <zlice555@gmail.com>"
+license="MIT"
+homepage="https://github.com/oneapi-src/oneVPL-intel-gpu"
+changelog="https://github.com/oneapi-src/oneVPL-intel-gpu/blob/main/CHANGELOG.md"
+distfiles="https://github.com/oneapi-src/oneVPL-intel-gpu/archive/refs/tags/intel-onevpl-${version}.tar.gz"
+checksum=74b0979dcb2af1b7c68edb8cbcb02d539de511090b12fac50652cbacd707c4e6
+
+post_install() {
+	vlicense LICENSE
+}
+
+onevpl-intel-gpu-devel_package() {
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/lib/pkgconfig
+	}
+}

From f218310407f98c5ec3d5e042d7da05c80e604456 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 18 Dec 2022 01:40:15 -0500
Subject: [PATCH 104/130] igt-gpu-tools: update to version 1.27 revbump idk
 remove

---
 ...-loading-failure-in-resolve-function.patch | 63 -------------------
 srcpkgs/igt-gpu-tools/patches/musl.patch      | 20 ++++++
 srcpkgs/igt-gpu-tools/template                |  4 +-
 3 files changed, 22 insertions(+), 65 deletions(-)
 delete mode 100644 srcpkgs/igt-gpu-tools/patches/i-g-t-Fix-global-symbol-loading-failure-in-resolve-function.patch

diff --git a/srcpkgs/igt-gpu-tools/patches/i-g-t-Fix-global-symbol-loading-failure-in-resolve-function.patch b/srcpkgs/igt-gpu-tools/patches/i-g-t-Fix-global-symbol-loading-failure-in-resolve-function.patch
deleted file mode 100644
index 0c3b554d9949..000000000000
--- a/srcpkgs/igt-gpu-tools/patches/i-g-t-Fix-global-symbol-loading-failure-in-resolve-function.patch
+++ /dev/null
@@ -1,63 +0,0 @@
-diff --git lib/igt_halffloat.c lib/igt_halffloat.c
-index 08ab05fc..e5e8a5bd 100644
---- a/lib/igt_halffloat.c
-+++ b/lib/igt_halffloat.c
-@@ -24,6 +24,19 @@
- 
- #include <assert.h>
- #include <math.h>
-+#include <stdbool.h>
-+
-+#ifdef HAVE_CPUID_H
-+#include <cpuid.h>
-+#else
-+#define __get_cpuid_max(x, y) 0
-+#define __cpuid(level, a, b, c, d) a = b = c = d = 0
-+#define __cpuid_count(level, count, a, b, c, d) a = b = c = d = 0
-+#endif
-+
-+#ifndef bit_F16C
-+#define bit_F16C	(1 << 29)
-+#endif
- 
- #include "igt_halffloat.h"
- #include "igt_x86.h"
-@@ -182,6 +195,20 @@ static void half_to_float_f16c(const uint16_t *h, float *f, unsigned int num)
- 
- #pragma GCC pop_options
- 
-+static bool f16c_is_supported(void)
-+{
-+	unsigned max = __get_cpuid_max(0, NULL);
-+	unsigned eax, ebx, ecx, edx;
-+
-+	if (max >= 1) {
-+		__cpuid(1, eax, ebx, ecx, edx);
-+
-+		if (ecx & bit_F16C)
-+			return true;
-+	}
-+	return false;
-+}
-+
- static void float_to_half(const float *f, uint16_t *h, unsigned int num)
- {
- 	for (int i = 0; i < num; i++)
-@@ -196,7 +223,7 @@ static void half_to_float(const uint16_t *h, float *f, unsigned int num)
- 
- static void (*resolve_float_to_half(void))(const float *f, uint16_t *h, unsigned int num)
- {
--	if (igt_x86_features() & F16C)
-+	if (f16c_is_supported())
- 		return float_to_half_f16c;
- 
- 	return float_to_half;
-@@ -207,7 +234,7 @@ void igt_float_to_half(const float *f, uint16_t *h, unsigned int num)
- 
- static void (*resolve_half_to_float(void))(const uint16_t *h, float *f, unsigned int num)
- {
--	if (igt_x86_features() & F16C)
-+	if (f16c_is_supported())
- 		return half_to_float_f16c;
- 
- 	return half_to_float;
diff --git a/srcpkgs/igt-gpu-tools/patches/musl.patch b/srcpkgs/igt-gpu-tools/patches/musl.patch
index 615afdb8f8ea..4de6e0cfd898 100644
--- a/srcpkgs/igt-gpu-tools/patches/musl.patch
+++ b/srcpkgs/igt-gpu-tools/patches/musl.patch
@@ -191,6 +191,7 @@ index 74935430..0dc87d8c 100644
 +++ b/tests/i915/i915_pm_rpm.c
 @@ -27,6 +27,7 @@
  
+<<<<<<< HEAD
  #include "config.h"
  
 +#include <limits.h> // PATH_MAX
@@ -293,3 +294,22 @@ index 0faf3fc8..f6bd970e 100644
  #include <stdio.h>
  #include <string.h>
  #include <stdlib.h>
+=======
+         fbo = bo->map;
+lib/ioctl_wrappers.c.new
+--- a/benchmarks/gem_exec_tracer.c	2022-12-18 10:32:15.742341964 -0500
++++ b/benchmarks/gem_exec_tracer.c	2022-12-18 10:32:09.862211372 -0500
+@@ -275,7 +275,11 @@
+     DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_EXECBUFFER2, struct drm_i915_gem_execbuffer2)
+ 
+ int
++#if defined(__GLIBC__) || defined(__FreeBSD__)
+ ioctl(int fd, unsigned long request, ...)
++#else
++ioctl(int fd, int request, ...)
++#endif
+ {
+ 	struct trace *t, **p;
+ 	va_list args;
+
+>>>>>>> 60301ae02f (igt-gpu-tools: update to version 1.26)
diff --git a/srcpkgs/igt-gpu-tools/template b/srcpkgs/igt-gpu-tools/template
index 225e2c79118a..1376c39d5d5b 100644
--- a/srcpkgs/igt-gpu-tools/template
+++ b/srcpkgs/igt-gpu-tools/template
@@ -1,7 +1,7 @@
 # Template file for 'igt-gpu-tools'
 pkgname=igt-gpu-tools
 version=1.27.1
-revision=1
+revision=2
 build_style=meson
 configure_args="-Db_ndebug=false -Ddocs=disabled"
 hostmakedepends="pkg-config flex peg python3-docutils"
@@ -13,7 +13,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="MIT"
 homepage="https://gitlab.freedesktop.org/drm/igt-gpu-tools"
 changelog="https://gitlab.freedesktop.org/drm/igt-gpu-tools/-/raw/master/NEWS"
-distfiles="${XORG_SITE}/app/igt-gpu-tools-${version}.tar.xz"
+distfiles="${XORG_SITE}/app/${pkgname}-${version}.tar.xz"
 checksum=93b9a4816ed22b5145bb61024314c8a65caeea991ce93027643f1d40723bf417
 # tests don't behave in containers
 make_check=ci-skip

From 64a751bebba7c8c754eef8f948ac206201824568 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:30:28 -0400
Subject: [PATCH 105/130] freecad: revbump for qt5-webengine-5.15.13

---
 srcpkgs/freecad/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/freecad/template b/srcpkgs/freecad/template
index f62023ee8ce4..e301f32d3540 100644
--- a/srcpkgs/freecad/template
+++ b/srcpkgs/freecad/template
@@ -1,7 +1,7 @@
 # Template file for 'freecad'
 pkgname=freecad
 version=0.20.2
-revision=3
+revision=4
 build_style=cmake
 
 _inst_prefix=/usr/lib/${pkgname}

From c7e2185c1e7d843ee603999520df932bf20fc40f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:31:45 -0400
Subject: [PATCH 106/130] shotcut: revbump for mlt7-7.14.0

---
 srcpkgs/shotcut/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/shotcut/template b/srcpkgs/shotcut/template
index 32583277dab2..8d8a7a0ebdeb 100644
--- a/srcpkgs/shotcut/template
+++ b/srcpkgs/shotcut/template
@@ -1,7 +1,7 @@
 # Template file for 'shotcut'
 pkgname=shotcut
 version=22.12.21
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSHOTCUT_VERSION=${version}"
 hostmakedepends="pkg-config qt5-tools-devel"

From 4c468ed479dc7e94954999e599aa2c34cdc09b4b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:30 -0400
Subject: [PATCH 107/130] shiboken2: revbump for qt5-5.15.8

---
 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch | 1 +
 srcpkgs/shiboken2/template                                 | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
 create mode 120000 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
new file mode 120000
index 000000000000..efcf3249bd88
--- /dev/null
+++ b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1 @@
+../../python3-pyside2/patches/importlib-machinery-bypass.patch
\ No newline at end of file
diff --git a/srcpkgs/shiboken2/template b/srcpkgs/shiboken2/template
index 084ecc3ba1e1..2a21998997eb 100644
--- a/srcpkgs/shiboken2/template
+++ b/srcpkgs/shiboken2/template
@@ -1,7 +1,7 @@
 # Template file for 'shiboken2'
 pkgname=shiboken2
 version=5.15.7
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/shiboken2"
 build_style=cmake

From 3585f2154e8e876e2db0c98ed2b5d95ea3951e5b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:53 -0400
Subject: [PATCH 108/130] python3-pyside2: update to 5.15.8

---
 .../patches/importlib-machinery-bypass.patch      | 15 +++++++++++++++
 srcpkgs/python3-pyside2/template                  |  9 +++++----
 2 files changed, 20 insertions(+), 4 deletions(-)
 create mode 100644 srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
new file mode 100644
index 000000000000..64c429584776
--- /dev/null
+++ b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1,15 @@
+Using this prevents an error around line 220 below it.
+"AttributeError: module 'importlib' has no attribute 'machinery'"
+The old backup logic is in place and compiles without issues.
+--- a/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:09:34.688912402 -0400
++++ b/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:10:03.395529582 -0400
+@@ -170,9 +170,6 @@
+
+     # 'zipstring_sequence' comes from signature.cpp
+     zipbytes = base64.b64decode(''.join(zipstring_sequence))
+-    if sys.version_info[0] >= 3:
+-        vzip = zipfile.ZipFile(io.BytesIO(zipbytes))
+-        return sys.meta_path, EmbeddableZipImporter(vzip)
+
+     # Old version for Python 2.7, only.
+     import os
diff --git a/srcpkgs/python3-pyside2/template b/srcpkgs/python3-pyside2/template
index 50e6ff260d3b..b50e62bd215d 100644
--- a/srcpkgs/python3-pyside2/template
+++ b/srcpkgs/python3-pyside2/template
@@ -1,11 +1,12 @@
 # Template file for 'python3-pyside2'
 pkgname=python3-pyside2
-version=5.15.5
-revision=2
+version=5.15.8
+revision=1
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/pyside2"
 build_style=cmake
-configure_args="-DPYTHON_EXECUTABLE=/usr/bin/python"
+configure_args="-DPYTHON_EXECUTABLE=/usr/bin/python -DCMAKE_BUILD_TYPE=None
+ -DBUILD_TESTS=OFF"
 hostmakedepends="cmake python3 shiboken2"
 makedepends="python3-devel libshiboken2-devel qt5-devel
  qt5-multimedia-devel qt5-tools-devel qt5-plugin-mysql qt5-plugin-odbc
@@ -23,7 +24,7 @@ maintainer="yopito <pierre.bourgin@free.fr>"
 license="LGPL-3.0-or-later"
 homepage="https://wiki.qt.io/Qt_for_Python"
 distfiles="https://download.qt.io/official_releases/QtForPython/pyside2/PySide2-${version}-src/${_pkgname}.tar.xz"
-checksum=3920a4fb353300260c9bc46ff70f1fb975c5e7efa22e9d51222588928ce19b33
+checksum=23436302c8deb5b4cbc769b205d09604e38ba83b40708efccb7bd8c9af6f6b5d
 
 build_options="webengine"
 desc_option_webengine="Build Qt5 WebEngine bindings"

From 3a79eb02c109a17527e193a8630944742f29edc0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:35 -0400
Subject: [PATCH 109/130] konqueror: revbump for ffmpeg-6.0

---
 srcpkgs/konqueror/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/konqueror/template b/srcpkgs/konqueror/template
index d8d0e73a78ab..c5bdba601d3c 100644
--- a/srcpkgs/konqueror/template
+++ b/srcpkgs/konqueror/template
@@ -1,11 +1,11 @@
 # Template file for 'konqueror'
 pkgname=konqueror
 version=23.04.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DDESKTOPTOJSON_EXECUTABLE=/usr/bin/desktoptojson"
 hostmakedepends="extra-cmake-modules python3 qt5-host-tools qt5-qmake kdoctools
-kcoreaddons kconfig gettext"
+ kcoreaddons kconfig gettext"
 makedepends="qt5-devel qt5-webengine-devel qt5-declarative-devel
  qt5-webchannel-devel qt5-location-devel kcmutils-devel kdelibs4support-devel
  karchive-devel khtml-devel kdesu-devel kactivities5-devel"

From 8b656d724bd174600d8e40a6a720c978141b768d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:58 -0400
Subject: [PATCH 110/130] qt5-speech: revbump for qt5-5.15.8

---
 srcpkgs/qt5-speech/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-speech/template b/srcpkgs/qt5-speech/template
index 3ecd10d50650..2d7d4d4d2453 100644
--- a/srcpkgs/qt5-speech/template
+++ b/srcpkgs/qt5-speech/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-speech'
 pkgname=qt5-speech
 version=5.15.7
-revision=2
+revision=3
 _commit=d32f4a479d38a11f547598004b975f4356424a16
 build_style=qmake
 configure_args="-- -flite -flite-alsa -speechd"

From 1841dd928690d5da2e23b16a51c013952317837a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 18:38:50 -0400
Subject: [PATCH 111/130] qt5-styleplugins: revbump for qt5-5.15.8

---
 srcpkgs/qt5-styleplugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-styleplugins/template b/srcpkgs/qt5-styleplugins/template
index 96ed97d12cd2..30d93660a2a4 100644
--- a/srcpkgs/qt5-styleplugins/template
+++ b/srcpkgs/qt5-styleplugins/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-styleplugins'
 pkgname=qt5-styleplugins
 version=5.0.0
-revision=20
+revision=21
 _gitrev=335dbece103e2cbf6c7cf819ab6672c2956b17b3
 build_style=qmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From 2c2f0f3b4ea2798279708acb71ad12fa865fcf2b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 27 Apr 2023 21:58:35 -0400
Subject: [PATCH 112/130] blender: update to 3.5.1

---
 srcpkgs/blender/patches/numpy-2.24.patch | 22 ----------------------
 srcpkgs/blender/template                 | 13 +++++++------
 2 files changed, 7 insertions(+), 28 deletions(-)
 delete mode 100644 srcpkgs/blender/patches/numpy-2.24.patch

diff --git a/srcpkgs/blender/patches/numpy-2.24.patch b/srcpkgs/blender/patches/numpy-2.24.patch
deleted file mode 100644
index 716315b74be7..000000000000
--- a/srcpkgs/blender/patches/numpy-2.24.patch
+++ /dev/null
@@ -1,22 +0,0 @@
-From 74e6e07cf7c67b55d384db72f5aa3892db8a3da6 Mon Sep 17 00:00:00 2001
-From: oreo639 <oreo6391@gmail.com>
-Date: Tue, 17 Jan 2023 14:36:54 -0800
-Subject: [PATCH] Remove usage of deprecated np.bool alias
-
----
- addons/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/addons/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py b/addons/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py
-index 6366434a6..8160c9e99 100644
---- a/release/scripts/addons/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py
-+++ b/release/scripts/addons/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py
-@@ -620,7 +620,7 @@ def set_poly_smoothing(gltf, pymesh, mesh, vert_normals, loop_vidxs):
-     # Try to guess which polys should be flat based on the fact that all the
-     # loop normals for a flat poly are = the poly's normal.
- 
--    poly_smooths = np.empty(num_polys, dtype=np.bool)
-+    poly_smooths = np.empty(num_polys, dtype=bool)
- 
-     poly_normals = np.empty(num_polys * 3, dtype=np.float32)
-     mesh.polygons.foreach_get('normal', poly_normals)
diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index d18bc88838ff..900bc17937c3 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -1,7 +1,7 @@
 # Template file for 'blender'
 pkgname=blender
-version=3.4.1
-revision=4
+version=3.5.1
+revision=1
 archs="x86_64* ppc64*"
 build_style="cmake"
 pycompile_dirs="/usr/share/blender/${version%.*}/scripts"
@@ -9,8 +9,8 @@ configure_args="-DWITH_INSTALL_PORTABLE=OFF -DWITH_PYTHON_INSTALL=OFF
  -DWITH_JACK=ON -DWITH_CODEC_FFMPEG=ON -DWITH_CODEC_SNDFILE=ON -DWITH_OPENMP=ON
  -DWITH_FFTW3=ON -DWITH_MOD_OCEANSIM=ON -DWITH_CYCLES_EMBREE=OFF -DWITH_OPENCOLORIO=ON
  -DWITH_IMAGE_OPENEXR=ON -DWITH_IMAGE_OPENJPEG=ON -DWITH_OPENSUBDIV=ON
- -DWITH_OPENCOLLADA=ON -DWITH_SYSTEM_GLEW=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
- -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_LIBDECOR=ON
+ -DWITH_OPENCOLLADA=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
+ -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_WAYLAND_LIBDECOR=ON
  -DWITH_BUILDINFO=OFF -DPYTHON_VERSION=${py3_ver} -DPYTHON_LIBPATH=/usr/lib
  -DPYTHON_LIBRARY='python${py3_ver}${py3_abiver}'
  -DPYTHON_INCLUDE_DIRS=/${py3_inc}"
@@ -22,14 +22,15 @@ makedepends="libgomp-devel libpng-devel tiff-devel python3-devel glu-devel
  opencolorio-devel opencollada-devel python3-numpy libXrender-devel
  OpenSubdiv-devel tbb-devel libxml2-devel openvdb-devel alembic-devel
  pugixml-devel libXxf86vm-devel libepoxy-devel gmp-devel gmpxx-devel
- wayland-protocols wayland-devel libxkbcommon-devel libdecor-devel"
+ wayland-protocols wayland-devel libxkbcommon-devel libdecor-devel
+ level-zero-devel"
 depends="desktop-file-utils hicolor-icon-theme"
 short_desc="3D graphics creation suite"
 maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="https://www.blender.org"
 distfiles="https://download.blender.org/source/blender-${version}.tar.xz"
-checksum=247c4c1228270c9010f4721c985cb5b628ab50abcf9f2678630737142eeb91c3
+checksum=bd7428c7e6cba5a900216269c32111dffaabaf1bdb5472f231965e615174a809
 python_version=3
 LDFLAGS="-Wl,-z,stack-size=2097152"
 # Blender tests are executed against a system installation of blender. This

From c1f1116388b47a4027b03bbd1946c5988e5140c9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 27 Apr 2023 20:41:10 -0400
Subject: [PATCH 113/130] New package: level-zero-1.10.0

---
 srcpkgs/level-zero-devel    |  1 +
 srcpkgs/level-zero/template | 28 ++++++++++++++++++++++++++++
 2 files changed, 29 insertions(+)
 create mode 120000 srcpkgs/level-zero-devel
 create mode 100644 srcpkgs/level-zero/template

diff --git a/srcpkgs/level-zero-devel b/srcpkgs/level-zero-devel
new file mode 120000
index 000000000000..96ee8adf7303
--- /dev/null
+++ b/srcpkgs/level-zero-devel
@@ -0,0 +1 @@
+level-zero
\ No newline at end of file
diff --git a/srcpkgs/level-zero/template b/srcpkgs/level-zero/template
new file mode 100644
index 000000000000..2338482a0fda
--- /dev/null
+++ b/srcpkgs/level-zero/template
@@ -0,0 +1,28 @@
+# Template file for 'level-zero'
+pkgname=level-zero
+version=1.10.0
+revision=1
+archs="x86_64*"
+build_style=cmake
+hostmakedepends="cmake"
+makedepends="llvm clang clang-tools-extra SPIRV-LLVM-Translator-devel"
+short_desc="OneAPI Level Zero Specification"
+maintainer="Zlice <zlice555@gmail.com>"
+license="NCSA"
+homepage="https://github.com/oneapi-src/level-zero"
+distfiles="${homepage}/archive/refs/tags/v${version}.tar.gz"
+checksum=2811e4128ff6114020d0a147c2769b9b2e782e68ad49827685c33b9e716bf6ab
+
+post_install() {
+	vlicense LICENSE
+}
+
+level-zero-devel_package() {
+	depends="${makedepends} ${sourcepkg}-${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.so"
+	}
+}

From 5a265894b90f7abdf1403f2d4729c92329711968 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 28 Mar 2023 19:54:49 -0400
Subject: [PATCH 114/130] New package: intel-metrics-library 1.0.133

---
 srcpkgs/intel-metrics-library/template | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
 create mode 100644 srcpkgs/intel-metrics-library/template

diff --git a/srcpkgs/intel-metrics-library/template b/srcpkgs/intel-metrics-library/template
new file mode 100644
index 000000000000..50f1a6079d7b
--- /dev/null
+++ b/srcpkgs/intel-metrics-library/template
@@ -0,0 +1,19 @@
+# Template file for 'intel-metrics-library'
+pkgname=intel-metrics-library
+version=1.0.133
+revision=1
+archs="x86_64*"
+build_style=cmake
+configure_args="-Wdev-no -DCMAKE_BUILD_TYPE=Release"
+hostmakedepends="cmake"
+makedepends="libdrm-devel"
+short_desc="Helper library that provides access to GPU performance counters"
+maintainer="Zlice <zlice555@gmail.com>"
+license="MIT"
+homepage="https://github.com/intel/metrics-library"
+distfiles="${homepage}/archive/refs/tags/metrics-library-${version}.tar.gz"
+checksum=83f7b2de3af5ffd2f1b487df8836e6d212e11668bd958bebae622a483fb1231f
+
+post_install() {
+	vlicense LICENSE.md
+}

From a75c70f5248f33133ce0519bcedbf74f5b6555ca Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 28 Mar 2023 19:54:18 -0400
Subject: [PATCH 115/130] New package: intel-metrics-discovery 1.12.163

---
 srcpkgs/intel-metrics-discovery/template | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
 create mode 100644 srcpkgs/intel-metrics-discovery/template

diff --git a/srcpkgs/intel-metrics-discovery/template b/srcpkgs/intel-metrics-discovery/template
new file mode 100644
index 000000000000..6083595e273c
--- /dev/null
+++ b/srcpkgs/intel-metrics-discovery/template
@@ -0,0 +1,19 @@
+# Template file for 'intel-metrics-discovery'
+pkgname=intel-metrics-discovery
+version=1.12.163
+revision=1
+archs="x86_64*"
+build_style=cmake
+configure_args="-Wdev-no -DCMAKE_BUILD_TYPE=Release"
+hostmakedepends="cmake"
+makedepends="libdrm-devel"
+short_desc="Helper library that provides access to GPU performance data"
+maintainer="Zlice <zlice555@gmail.com>"
+license="MIT"
+homepage="https://github.com/intel/metrics-discovery"
+distfiles="${homepage}/archive/refs/tags/metrics-discovery-${version}.tar.gz"
+checksum=6dfe8d11c58625bf3ebf656ec2a95dc96bbb05705ec71c6c3c3dd0ef5cd2319c
+
+post_install() {
+	vlicense LICENSE.md
+}

From cdac747ace175f7779c2d08aa375900dccabd100 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 26 Mar 2023 10:48:34 -0400
Subject: [PATCH 116/130] New package: intel-graphics-compiler-1.0.13463.18

---
 srcpkgs/intel-graphics-compiler/template | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 srcpkgs/intel-graphics-compiler/template

diff --git a/srcpkgs/intel-graphics-compiler/template b/srcpkgs/intel-graphics-compiler/template
new file mode 100644
index 000000000000..44d38214f929
--- /dev/null
+++ b/srcpkgs/intel-graphics-compiler/template
@@ -0,0 +1,22 @@
+# Template file for 'intel-graphics-compiler'
+pkgname=intel-graphics-compiler
+version=1.0.13463.18
+revision=1
+archs="x86_64*"
+build_style=cmake
+configure_args="-Wno-dev -DIGC_OPTION__LLVM_PREFERRED_VERSION=15.0.7 -DCCLANG_FROM_SYSTEM=ON
+ -DIGC_OPTION__SPIRV_TOOLS_MODE=Prebuilds -DIGC_OPTION__USE_PREINSTALLED_SPRIV_HEADERS=ON
+ -DIGC_OPTION__VC_INTRINSICS_MODE=Prebuilds"
+hostmakedepends="flex bison zlib-devel libzstd-devel cmake"
+makedepends="llvm clang clang-tools-extra intel-opencl-clang intel-vc-intrinsics
+ lld lld-devel SPIRV-Headers  SPIRV-LLVM-Translator-devel SPIRV-Tools-devel"
+short_desc="LLVM based compiler for OpenCL targeting Intel"
+maintainer="Zlice <zlice555@gmail.com>"
+license="MIT"
+homepage="https://github.com/intel/intel-graphics-compiler"
+distfiles="${homepage}/archive/refs/tags/igc-${version}.tar.gz"
+checksum=0b960878a5feffd6aa10197c48bf73a0a3a19d0105428d48163e91db0444070a
+
+post_install() {
+	vlicense LICENSE.md
+}

From a1bade807be1b6b27e431804062822ef3e3168ff Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 26 Mar 2023 10:48:05 -0400
Subject: [PATCH 117/130] New package: intel-compute-runtime-23.09.25812.14

---
 srcpkgs/intel-compute-runtime/template | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 srcpkgs/intel-compute-runtime/template

diff --git a/srcpkgs/intel-compute-runtime/template b/srcpkgs/intel-compute-runtime/template
new file mode 100644
index 000000000000..1132b830d348
--- /dev/null
+++ b/srcpkgs/intel-compute-runtime/template
@@ -0,0 +1,22 @@
+# Template file for 'intel-compute-runtime'
+pkgname=intel-compute-runtime
+version=23.09.25812.14
+revision=1
+archs="x86_64"
+build_style=cmake
+configure_args="-Wno-dev -DNEO_SKIP_UNIT_TESTS=1 -DSUPPORT_DG1=ON -DSUPPORT_DG2=ON"
+hostmakedepends="cmake pkg-config"
+makedepends="gcc intel-gmmlib-devel libva-devel ocl-icd-devel
+ intel-opencl-clang intel-graphics-compiler level-zero-devel
+ intel-metrics-library intel-metrics-discovery"
+depends="intel-graphics-compiler"
+short_desc="Intel Graphics Compute Runtime for oneAPI Level Zero and OpenCL"
+maintainer="Zlice <zlice555@gmail.com>"
+license="MIT"
+homepage="https://github.com/intel/compute-runtime"
+distfiles="${homepage}/archive/refs/tags/${version}.tar.gz"
+checksum=abe2e6d9d2ac771d5f42ee2357ce897ca3b00dc6185c06f3f62772f729c7f8e1
+
+post_install() {
+	vlicense LICENSE.md
+}

From a531615f5b0e1e3a5c8f44d000645aa667d34bd9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 26 Mar 2023 10:46:58 -0400
Subject: [PATCH 118/130] New package: intel-vc-intrinsics-0.12.3

---
 srcpkgs/intel-vc-intrinsics/template | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
 create mode 100644 srcpkgs/intel-vc-intrinsics/template

diff --git a/srcpkgs/intel-vc-intrinsics/template b/srcpkgs/intel-vc-intrinsics/template
new file mode 100644
index 000000000000..129482bdf985
--- /dev/null
+++ b/srcpkgs/intel-vc-intrinsics/template
@@ -0,0 +1,21 @@
+# Template file for 'intel-vc-intrinsics'
+pkgname=intel-vc-intrinsics
+version=0.12.3
+revision=1
+archs="x86_64*"
+build_style=cmake
+configure_args="-Wno-dev -DLLVM_DIR=/usr/lib/cmake/llvm -DCMAKE_BUILD_TYPE=Release"
+hostmakedepends="cmake python"
+makedepends="llvm clang clang-tools-extra"
+short_desc="Set of intrinsics on top of core LLVM IR"
+maintainer="Zlice <zlice555@gmail.com>"
+license="MIT"
+homepage="https://github.com/intel/vc-intrinsics"
+distfiles="${homepage}/archive/refs/tags/v${version}.tar.gz"
+checksum=ed1c0d968cb2f8ee7b2840a14c3261639f1700e844fb7d2a89856babffd5e1d1
+
+# TODO: license isn't bundled in tar?
+#       just added 2 days ago... mar 24th 2023
+#post_install() {
+#	vlicense LICENSE.md
+#}

From 39d5bc2fdb575fe21933f5c57c1da7de488f0a34 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 26 Mar 2023 10:46:11 -0400
Subject: [PATCH 119/130] New package: intel-opencl-clang-15.0.0

---
 common/shlibs                       |  1 +
 srcpkgs/intel-opencl-clang/template | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+)
 create mode 100644 srcpkgs/intel-opencl-clang/template

diff --git a/common/shlibs b/common/shlibs
index dbc2dbf25d3d..25178211b8ec 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -1008,6 +1008,7 @@ libLLVM-15.so libllvm15-15.0.7_1
 libLLVMSPIRVLib.so.15 SPIRV-LLVM-Translator-15.0.0_1
 libomp.so.5 libomp-15.0.7_1
 libomptarget.so.15 libomp-15.0.7_1
+libopencl-clang.so.15 intel-opencl-clang-15.0.0_1
 libisofs.so.6 libisofs-0.6.24_1
 libmpack.so.0 libmpack-1.0.5_1
 libGeoIP.so.1 libgeoip-1.4.8_1
diff --git a/srcpkgs/intel-opencl-clang/template b/srcpkgs/intel-opencl-clang/template
new file mode 100644
index 000000000000..e6f09f6ad724
--- /dev/null
+++ b/srcpkgs/intel-opencl-clang/template
@@ -0,0 +1,18 @@
+# Template file for 'intel-opencl-clang'
+pkgname=intel-opencl-clang
+version=15.0.0
+revision=1
+archs="x86_64*"
+build_style=cmake
+hostmakedepends="cmake"
+makedepends="llvm clang clang-tools-extra SPIRV-LLVM-Translator-devel"
+short_desc="LLVM linked opencl-clang"
+maintainer="Zlice <zlice555@gmail.com>"
+license="NCSA"
+homepage="https://github.com/intel/opencl-clang"
+distfiles="${homepage}/archive/refs/tags/v${version}.tar.gz"
+checksum=ea179674e52bc8c658e2655f76be467f7052f7d2c37ebcfdb102dce645ad1411
+
+post_install() {
+	vlicense LICENSE
+}

From 7968cad60609a8267424f51ee70bb0a6f1de3644 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 30 Apr 2023 20:22:25 -0400
Subject: [PATCH 120/130] gstreamer1: update to 1.22.2

---
 srcpkgs/gstreamer1/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gstreamer1/template b/srcpkgs/gstreamer1/template
index ae8a49cb20e8..571148f2ff33 100644
--- a/srcpkgs/gstreamer1/template
+++ b/srcpkgs/gstreamer1/template
@@ -1,6 +1,6 @@
 # Template file for 'gstreamer1'
 pkgname=gstreamer1
-version=1.20.3
+version=1.22.2
 revision=1
 build_style=meson
 build_helper="gir"
@@ -16,7 +16,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.0-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/gstreamer/gstreamer-${version}.tar.xz"
-checksum=607daf64bbbd5fb18af9d17e21c0d22c4d702fffe83b23cb22d1b1af2ca23a2a
+checksum=b2afe73603921c608ba48969dbb7d743776744bfe5d8059ece241137b7f88e21
 
 pre_check() {
 	# gst_gstdatetime is known to fail according to LFS

From 88382cc213c964a2528d396725e72365bf755119 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 30 Apr 2023 20:22:26 -0400
Subject: [PATCH 121/130] gst-plugins-base1: update to 1.22.2

---
 srcpkgs/gst-plugins-base1/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-plugins-base1/template b/srcpkgs/gst-plugins-base1/template
index 29e8f76bd1fe..2f20ea819849 100644
--- a/srcpkgs/gst-plugins-base1/template
+++ b/srcpkgs/gst-plugins-base1/template
@@ -1,6 +1,6 @@
 # Template file for 'gst-plugins-base1'
 pkgname=gst-plugins-base1
-version=1.20.3
+version=1.22.2
 revision=1
 build_style=meson
 build_helper="gir"
@@ -22,7 +22,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname/1/}/${pkgname/1/}-${version}.tar.xz"
-checksum=7e30b3dd81a70380ff7554f998471d6996ff76bbe6fc5447096f851e24473c9f
+checksum=eb65120c4ee79b7a153c3c1972d5c0158c2151877cc51ec7725bba5749679d49
 
 build_options="cdparanoia gir sndio wayland"
 build_options_default="cdparanoia gir wayland"

From edaff2bb50e19481b0e3f68bfcc664a4736e3cc7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 30 Apr 2023 20:22:26 -0400
Subject: [PATCH 122/130] gst-plugins-good1: update to 1.22.2

---
 srcpkgs/gst-plugins-good1/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-plugins-good1/template b/srcpkgs/gst-plugins-good1/template
index 1f5e620ce1fd..5d0fe1bfe284 100644
--- a/srcpkgs/gst-plugins-good1/template
+++ b/srcpkgs/gst-plugins-good1/template
@@ -1,6 +1,6 @@
 # Template file for 'gst-plugins-good1'
 pkgname=gst-plugins-good1
-version=1.20.3
+version=1.22.2
 revision=1
 build_style=meson
 configure_args="-Ddv=disabled -Ddv1394=disabled -Dshout2=disabled -Dqt5=enabled
@@ -22,7 +22,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname/1/}/${pkgname/1/}-${version}.tar.xz"
-checksum=f8f3c206bf5cdabc00953920b47b3575af0ef15e9f871c0b6966f6d0aa5868b7
+checksum=7c8cc59425f2b232f60ca7d13e56edd615da4f711e73dd01a7cffa46e6bc0cdd
 
 build_options="gtk3 wayland"
 build_options_default="gtk3 wayland"

From a7505e721ef76ffc7fb94f5cfb1ecfa86157e72d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 30 Apr 2023 20:22:26 -0400
Subject: [PATCH 123/130] gst-plugins-bad1: update to 1.22.2

---
 srcpkgs/gst-plugins-bad1/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index 5a9d5387e0d4..77bf79981c20 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-plugins-bad1'
 pkgname=gst-plugins-bad1
-version=1.22.1
-revision=2
+version=1.22.2
+revision=1
 build_helper="gir"
 build_style=meson
 configure_args="-Dpackage-origin=https://voidlinux.org -Ddoc=disabled
@@ -36,7 +36,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later, LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname/1/}/${pkgname/1/}-${version}.tar.xz"
-checksum=7a11c13b55dd1d2386dd902219e41cbfcdda8e1e0aa3e738186c95074b35da4f
+checksum=3d8faf1ce3402c8535ce3a8c4e1a6c960e4b5655dbda6b55943db9ac79022d0f
 
 build_options="gir gme wayland"
 build_options_default="gir wayland"

From 227f948225b2825167de946408680c5f06eec7e4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 30 Apr 2023 20:22:26 -0400
Subject: [PATCH 124/130] gst-plugins-ugly1: update to 1.22.2

---
 srcpkgs/gst-plugins-ugly1/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-plugins-ugly1/template b/srcpkgs/gst-plugins-ugly1/template
index e254fd40f869..85ae64bc7a0a 100644
--- a/srcpkgs/gst-plugins-ugly1/template
+++ b/srcpkgs/gst-plugins-ugly1/template
@@ -1,6 +1,6 @@
 # Template file for 'gst-plugins-ugly1'
 pkgname=gst-plugins-ugly1
-version=1.20.3
+version=1.22.2
 revision=1
 build_style=meson
 configure_args="-Damrnb=disabled -Damrwbdec=disabled -Dsidplay=disabled"
@@ -15,4 +15,4 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname/1/}/${pkgname/1/}-${version}.tar.xz"
-checksum=8caa20789a09c304b49cf563d33cca9421b1875b84fcc187e4a385fa01d6aefd
+checksum=8f30f44db0bd063709bf6fbe55138e3a98af0abcb61c360f35582bbe10e80691

From e44f19cfc4d127520d2455c3bde0d3222703a0f1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 30 Apr 2023 20:22:26 -0400
Subject: [PATCH 125/130] gst-omx: update to 1.22.2

---
 srcpkgs/gst-omx/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-omx/template b/srcpkgs/gst-omx/template
index 893535c463da..5ad54cc7b9d8 100644
--- a/srcpkgs/gst-omx/template
+++ b/srcpkgs/gst-omx/template
@@ -1,6 +1,6 @@
 # Template file for 'gst-omx'
 pkgname=gst-omx
-version=1.20.3
+version=1.22.2
 revision=1
 build_style=meson
 configure_args="-Dexamples=disabled -Dtarget=generic"
@@ -11,4 +11,4 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.1-only"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname}/${pkgname}-${version}.tar.xz"
-checksum=8db48040bb41f09edf8d17ff6d16c54888d7777ba4501c2c69f0083350ea9a15
+checksum=1b0c57f2cc4ddeec5e7f0c436e502f06665c4e93c73261855b94e04fc94337b2

From d031d9801a56a82faffbf0eddcf13f59801bfb59 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 30 Apr 2023 20:22:26 -0400
Subject: [PATCH 126/130] gst-rtsp-server: update to 1.22.2

---
 srcpkgs/gst-rtsp-server/template | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index 8ceea8d34b4b..2f0c0c45ff82 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
-version=1.20.3
-revision=3
+version=1.22.2
+revision=1
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="glib-devel gst-plugins-bad1-devel gobject-introspection
@@ -10,5 +10,5 @@ short_desc="GStreamer multimedia graph framework - rtsp server"
 maintainer="1is7ac3 <isaac.qa13@gmail.com>"
 license="LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
-distfiles="https://gstreamer.freedesktop.org/src/gst-rtsp-server/gst-rtsp-server-${version}.tar.xz"
-checksum=ee402718be9b127f0e5e66ca4c1b4f42e4926ec93ba307b7ccca5dc6cc9794ca
+distfiles="${homepage}/src/${pkgname}/${pkgname}-${version}.tar.xz"
+checksum=2be4aecfb88710100ea7115ed0216403e8094344ebf146094271b8d4d73828bf

From 0e8395724127b1012d4b0a24ba44c742bd8c4efc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 30 Apr 2023 20:22:26 -0400
Subject: [PATCH 127/130] gst1-editing-services: update to 1.22.2

---
 srcpkgs/gst1-editing-services/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst1-editing-services/template b/srcpkgs/gst1-editing-services/template
index 673b46970f24..102440f7f253 100644
--- a/srcpkgs/gst1-editing-services/template
+++ b/srcpkgs/gst1-editing-services/template
@@ -1,6 +1,6 @@
 # Template file for 'gst1-editing-services'
 pkgname=gst1-editing-services
-version=1.20.3
+version=1.22.2
 revision=1
 build_style=meson
 build_helper="gir"
@@ -12,7 +12,7 @@ maintainer="Toyam Cox <Vaelatern@gmail.com>"
 license="LGPL-2.0-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname/gst1/gst}/${pkgname/gst1/gst}-${version}.tar.xz"
-checksum=5fd896de69fbe24421eb6b0ff8d2f8b4c3cba3f3025ceacd302172f39a8abaa2
+checksum=453b1464fc3857de269a7cb0ebd966afe02171d97bef672a0b8a0a6d43e0cebf
 
 do_check() {
 	: # Tests fail in older versions as well

From 7ad7458371b0140d5c2071ff962d4f44c8e450bb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 30 Apr 2023 20:22:26 -0400
Subject: [PATCH 128/130] gst1-python3: update to 1.22.2

---
 srcpkgs/gst1-python3/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/gst1-python3/template b/srcpkgs/gst1-python3/template
index 3f564ac64b93..789e40f036ea 100644
--- a/srcpkgs/gst1-python3/template
+++ b/srcpkgs/gst1-python3/template
@@ -1,7 +1,7 @@
 # Template file for 'gst1-python3'
 pkgname=gst1-python3
-version=1.20.3
-revision=2
+version=1.22.2
+revision=1
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="libglib-devel python3-devel python3-gobject-devel gst-plugins-base1-devel"
@@ -11,4 +11,4 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/gst-python/gst-python-${version}.tar.xz"
-checksum=db348120eae955b8cc4de3560a7ea06e36d6e1ddbaa99a7ad96b59846601cfdc
+checksum=bef2b3d82ce4be46b775b1bb56305c1003ee01b535a53a82f9fe8924972153ad

From e0f2b814656bfbd166208bab9a1a3dc4711ec4fd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 30 Apr 2023 20:22:26 -0400
Subject: [PATCH 129/130] gstreamer-vaapi: update to 1.22.2

---
 srcpkgs/gstreamer-vaapi/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gstreamer-vaapi/template b/srcpkgs/gstreamer-vaapi/template
index 3cc4e057559a..0a5ee8b1ca3f 100644
--- a/srcpkgs/gstreamer-vaapi/template
+++ b/srcpkgs/gstreamer-vaapi/template
@@ -1,6 +1,6 @@
 # Template file for 'gstreamer-vaapi'
 pkgname=gstreamer-vaapi
-version=1.20.3
+version=1.22.2
 revision=1
 build_style=meson
 hostmakedepends="pkg-config"
@@ -11,7 +11,7 @@ license="LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
 changelog="https://raw.githubusercontent.com/GStreamer/gstreamer-vaapi/master/ChangeLog"
 distfiles="${homepage}/src/gstreamer-vaapi/gstreamer-vaapi-${version}.tar.xz"
-checksum=6ee99eb316abdde9ad37002915bd8c3867918f6fdc74b7cf2ac4c1ae0d690b45
+checksum=d2e642f9745f97d9f73a7f5085e7659a9a31fe209b774e6e45dae041b435df06
 
 pre_check() {
 	# Seems to need certain hardware to pass

From 93e0afe90dd5a2ae3fcdb143c62a3192681a6530 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 30 Apr 2023 20:22:26 -0400
Subject: [PATCH 130/130] gst-libav: update to 1.22.2

---
 srcpkgs/gst-libav/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index f082bd211c65..8c72fc3e97ee 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
-version=1.20.3
-revision=2
+version=1.22.2
+revision=1
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"
@@ -11,7 +11,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.0-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname}/${pkgname}-${version}.tar.xz"
-checksum=3fedd10560fcdfaa1b6462cbf79a38c4e7b57d7f390359393fc0cef6dbf27dfe
+checksum=fcaaf9878fe8f3bc82317ef13a1558824cb68df1f8968c6797f556c5e33bcffd
 
 case "$XBPS_TARGET_MACHINE" in
 	*-musl) # Required by musl for M_SQRT1_2

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (2 preceding siblings ...)
  2023-05-05 18:04 ` [PR PATCH] [Updated] " zlice
@ 2023-05-07 19:26 ` paper42
  2023-05-07 22:00 ` zlice
                   ` (93 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: paper42 @ 2023-05-07 19:26 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 437 bytes --]

New comment by paper42 on void-packages repository

https://github.com/void-linux/void-packages/pull/43761#issuecomment-1537522552

Comment:
are the commits for a blender update, gstreamer and new intel packages really necessary for this PR? If not, please drop them. If yes and they could be merged before merging this PR, please split them to a separate PR and mention that it should be merged before this PR in this PR's description.

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (3 preceding siblings ...)
  2023-05-07 19:26 ` paper42
@ 2023-05-07 22:00 ` zlice
  2023-05-07 22:00 ` [PR PATCH] [Updated] " zlice
                   ` (92 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2023-05-07 22:00 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 374 bytes --]

New comment by zlice on void-packages repository

https://github.com/void-linux/void-packages/pull/43761#issuecomment-1537549840

Comment:
**Intel OpenCL** commits removed

**blender** - uses ffmpeg-devel, added to update list

**gstreamer** - added to 'Requirements' section and only revbumped the appropriate packages

**Intel Packages** - added to 'Requirements'


^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (4 preceding siblings ...)
  2023-05-07 22:00 ` zlice
@ 2023-05-07 22:00 ` zlice
  2023-05-08  0:23 ` zlice
                   ` (91 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2023-05-07 22:00 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 3256 bytes --]

There is an updated pull request by zlice against master on the void-packages repository

https://github.com/zlice/void-packages ffmpeg6-split
https://github.com/void-linux/void-packages/pull/43761

ffmpeg6 split
[ci skip]


#### Testing the changes

- I tested the changes in this PR: **YES**

main testing has been vaapi in Firefox Nightly and enc/dec in Shotcut on Intel A770

#### New package

- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**

#### Local build testing

- I built this PR locally for my native architecture, **x86_64**

#### Discussion

Continuation of https://github.com/void-linux/void-packages/pull/36315

`libavresample` is deprecated, but marked as a dependency when trying to build other packages and install `ffmpeg`(6). I think the right way to handle this is make a meta package and the add to removals?


##### Commit naming / misc

~~Commits are 'dirty' right now, running with [gstreamer 1.22.1 updates](https://github.com/void-linux/void-packages/pull/42861) and [Intel OpenCL](https://github.com/void-linux/void-packages/pull/43084). This will also make [intel packages pr](https://github.com/void-linux/void-packages/pull/41132) obsolete.~~ (see Requirements below)

Maintainer for previous ffmpeg(4) was orphaned, I can put my name in there if that matters, though I don't exactly see myself keeping up on ffmpeg.

This updates QT5 which looks like it is usually hosted by Johnny. Not sure if there's any reason to stay there or these sources are fine.

##### STILL FFMPEG4

These are a mix of emulators, games and/or older packages.

- attract (multiple patches in master)
- audacity  (3.2.x+ should work but requires wxWidgets dev 3.1.x)
- ccextractor (master patches? no release)
- vice
- kodi
- mlt (only dep left is flowblade)
- ~~synfig (mlt)~~ (work with mlt7, bump synfigstudio)
- tvheadend
- ssr
- spek-alternative
- ppsspp
- olive
- moc
- mediastreamer
- libextractor
- idjc
- hedgewars
- ~~ffmpegthumbnailer~~ (patches for moviedecoder.xxx files)
- ~~ffmpegthumbs~~ (latest compiles)
- deadbeef
- omxplayer
- qtav (fork has ffmpeg 5 patch - https://github.com/cmguo/QtAV)
- `vlc` (vlc4 will support ffmpeg5, there's a patch to build 3.x with ffmpeg5 but it will lack vaapi)
- `osg` (OpenSceneGraph plus `xine-lib`)


##### HAVE NOT BUILT YET

- omxplayer (rpi only? ffmpeg4)
- kodi (big, but ffmpeg4)


##### UPDATED (for ffmpeg6)

- blender: update to 3.5.1
- unpaper: update to 7.0.0.
- guvcview: update to 2.0.8.
- qt5: update to 5.15.8
- qt5-webengine: update to 5.18.13
- shiboken2: revbump for qt5.15.8 (patch)
- python3-pyside2: update to 5.15.8 (patch)


##### Requirements

- [gstreamer 1.22.2](https://github.com/void-linux/void-packages/pull/42861) - a few packages use ffmpeg-devel and require a revbump

- [Intel Packages](https://github.com/void-linux/void-packages/pull/41132) - ffmpeg4 uses different libraries than 6 (libmfx / Intel-MediaSDK vs only oneVPL that Intel is moving to), both are included here

A patch file from https://github.com/void-linux/void-packages/pull/43761.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ffmpeg6-split-43761.patch --]
[-- Type: text/x-diff, Size: 781111 bytes --]

From f278ff8326ee28cf7c3a18299ef6f519bd747330 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:55:46 -0400
Subject: [PATCH 001/110] ffmpeg: update to 6.0.

---
 common/shlibs                                 | 26 +++++---
 srcpkgs/ffmpeg/files/altivec.patch            | 60 -------------------
 .../patches/armv5tel-floating-point.patch     | 18 ------
 .../workaround-mesa-readeon-vaapi-bug.patch   | 28 ---------
 srcpkgs/ffmpeg/template                       | 31 +++++-----
 5 files changed, 33 insertions(+), 130 deletions(-)
 delete mode 100644 srcpkgs/ffmpeg/files/altivec.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch

diff --git a/common/shlibs b/common/shlibs
index 89f7e53081f8..9497f6499aa2 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -390,15 +390,23 @@ libid3tag.so.0 libid3tag-0.15.1b_1
 libgif.so.7 giflib-5.1.0_1
 libImlib2.so.1 imlib2-1.4.2_1
 libmp3lame.so.0 lame-3.98.2_1
-libavdevice.so.58 libavdevice-4.0_1
-libavformat.so.58 libavformat-4.0_1
-libswscale.so.5 libswscale-4.0_1
-libswresample.so.3 libswresample-4.0_1
-libavresample.so.4 libavresample-4.0_1
-libpostproc.so.55 libpostproc-4.0_1
-libavcodec.so.58 libavcodec-4.0_1
-libavutil.so.56 libavutil-4.0_1
-libavfilter.so.7 libavfilter-4.0_1
+libavdevice.so.60 libavdevice-6.0_1
+libavformat.so.60 libavformat-6.0_1
+libswscale.so.7 libswscale-6.0_1
+libswresample.so.4 libswresample-6.0_1
+libpostproc.so.57 libpostproc-6.0_1
+libavcodec.so.60 libavcodec-6.0_1
+libavutil.so.58 libavutil-6.0_1
+libavfilter.so.9 libavfilter-6.0_1
+libavdevice.so.58 libavdevice4-4.0_1
+libavformat.so.58 libavformat4-4.0_1
+libswscale.so.5 libswscale4-4.0_1
+libswresample.so.3 libswresample4-4.0_1
+libavresample.so.4 libavresample4-4.0_1
+libpostproc.so.55 libpostproc4-4.0_1
+libavcodec.so.58 libavcodec4-4.0_1
+libavutil.so.56 libavutil4-4.0_1
+libavfilter.so.7 libavfilter4-4.0_1
 libSDL-1.2.so.0 SDL-1.2.14_1
 libSDL_image-1.2.so.0 SDL_image-1.2.10_1
 libx264.so.157 x264-20190507.2245_1
diff --git a/srcpkgs/ffmpeg/files/altivec.patch b/srcpkgs/ffmpeg/files/altivec.patch
deleted file mode 100644
index 9c5720046332..000000000000
--- a/srcpkgs/ffmpeg/files/altivec.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-revert some altivec specific change on all ppc* except ppc64le*
-
-q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
-conditionally, for ppc* but not ppc64le* (the new code is valid for
-POWER8 VSX which LE targets as a baseline but not BE)"
-
-
-This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
----
- libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
- 1 file changed, 20 insertions(+), 4 deletions(-)
-
-diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
-index 536545293d..c1e2852adb 100644
---- a/libswscale/ppc/yuv2rgb_altivec.c
-+++ b/libswscale/ppc/yuv2rgb_altivec.c
-@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-     vector signed short R1, G1, B1;                                           \
-     vector unsigned char R, G, B;                                             \
-                                                                               \
-+    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
-+    vector unsigned char align_perm;                                          \
-+                                                                              \
-     vector signed short lCY       = c->CY;                                    \
-     vector signed short lOY       = c->OY;                                    \
-     vector signed short lCRV      = c->CRV;                                   \
-@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
-                                                                               \
-         for (j = 0; j < w / 16; j++) {                                        \
--            y0 = vec_xl(0, y1i);                                              \
-+            y1ivP = (const vector unsigned char *) y1i;                       \
-+            y2ivP = (const vector unsigned char *) y2i;                       \
-+            uivP  = (const vector unsigned char *) ui;                        \
-+            vivP  = (const vector unsigned char *) vi;                        \
-+                                                                              \
-+            align_perm = vec_lvsl(0, y1i);                                    \
-+            y0 = (vector unsigned char)                                       \
-+                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
-                                                                               \
--            y1 = vec_xl(0, y2i);                                              \
-+            align_perm = vec_lvsl(0, y2i);                                    \
-+            y1 = (vector unsigned char)                                       \
-+                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
-                                                                               \
--            u = (vector signed char) vec_xl(0, ui);                           \
-+            align_perm = vec_lvsl(0, ui);                                     \
-+            u = (vector signed char)                                          \
-+                    vec_perm(uivP[0], uivP[1], align_perm);                   \
-                                                                               \
--            v = (vector signed char) vec_xl(0, vi);                           \
-+            align_perm = vec_lvsl(0, vi);                                     \
-+            v = (vector signed char)                                          \
-+                    vec_perm(vivP[0], vivP[1], align_perm);                   \
-                                                                               \
-             u = (vector signed char)                                          \
-                     vec_sub(u,                                                \
--- 
-2.27.0
-
diff --git a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
deleted file mode 100644
index 9a55178c74f0..000000000000
--- a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
-+++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
-@@ -39,6 +39,15 @@
- #endif
- #include <fenv.h>
- 
-+#if (FE_ALL_EXCEPT == 0)
-+/* E.g. ARM soft float does not define these */
-+#define FE_INVALID    0
-+#define FE_DIVBYZERO  0
-+#define FE_OVERFLOW   0
-+#define FE_UNDERFLOW  0
-+#define FE_INEXACT    0
-+#endif
-+
- #if CONFIG_LIBFONTCONFIG
- #include <fontconfig/fontconfig.h>
- #endif
diff --git a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
deleted file mode 100644
index 00e3f68a415b..000000000000
--- a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
-From: Rainer Hochecker <fernetmenta@online.de>
-Date: Sat, 26 Jan 2019 19:48:35 +0100
-Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
-
-This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
-It was hit frequently when watching h264 channels received via DVB-X.
-Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
----
- libavcodec/vaapi_h264.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
-index 5854587a255..f12fdc457a4 100644
---- a/libavcodec/vaapi_h264.c
-+++ b/libavcodec/vaapi_h264.c
-@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
-     H264SliceContext *sl = &h->slice_ctx[0];
-     int ret;
- 
-+    if (pic->nb_slices == 0) {
-+        ret = AVERROR_INVALIDDATA;
-+        goto finish;
-+    }
-+
-     ret = ff_vaapi_decode_issue(avctx, pic);
-     if (ret < 0)
-         goto finish;
diff --git a/srcpkgs/ffmpeg/template b/srcpkgs/ffmpeg/template
index 23a3d5c9967b..3d99e5173697 100644
--- a/srcpkgs/ffmpeg/template
+++ b/srcpkgs/ffmpeg/template
@@ -1,15 +1,15 @@
 # Template file for 'ffmpeg'
 # audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
 pkgname=ffmpeg
-version=4.4.3
-revision=2
+version=6.0
+revision=1
 short_desc="Decoding, encoding and streaming software"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="https://www.ffmpeg.org"
 changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
 distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
-checksum=6c5b6c195e61534766a0b5fe16acc919170c883362612816d0a1c7f4f947006e
+checksum=57be87c22d9b49c112b6d24bc67d42508660e6b718b3db89c44e47e289137082
 
 hostmakedepends="pkg-config perl yasm"
 makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
@@ -26,12 +26,13 @@ makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-deve
  $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
  $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
  $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
- $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers Vulkan-Tools Vulkan-ValidationLayers')
+ $(vopt_if onevpl 'onevpl onevpl-devel')
  $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
 depends="ffplay>=${version}_${revision}"
 
 build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
- dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec onevpl"
 build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
 desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
 desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
@@ -39,7 +40,8 @@ desc_option_sofa="Enable support for AES SOFA"
 desc_option_webp="Enable support for WebP"
 
 case "$XBPS_TARGET_MACHINE" in
-	i686*|x86_64*) build_options_default+=" vaapi vdpau nvenc nvdec";;
+	i686*) build_options_default+=" vaapi vdpau nvenc nvdec";;
+	x86_64*) build_options_default+=" vaapi vdpau nvenc nvdec onevpl";;
 	ppc64*) build_options_default+=" vaapi vdpau";;
 	mips*) CFLAGS="-mnan=legacy";;
 esac
@@ -114,18 +116,19 @@ do_configure() {
 		$(vopt_enable x265 libx265) \
 		$(vopt_enable v4l2 libv4l2) \
 		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
-		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		--enable-libbs2b --enable-libvidstab \
 		$(vopt_enable dav1d libdav1d) \
 		$(vopt_enable zimg libzimg) \
 		$(vopt_enable webp libwebp) \
 		$(vopt_enable sofa libmysofa) \
 		$(vopt_enable vulkan) \
+		$(vopt_enable onevpl libvpl) \
 		$(vopt_enable drm libdrm) \
 		$(vopt_enable svtav1 libsvtav1) \
 		$(vopt_enable srt libsrt) \
 		$(vopt_enable rist librist) \
-		$(vopt_if nvenc '--enable-nvenc') \
-		$(vopt_if nvdec '--enable-nvdec')
+		$(vopt_enable nvenc nvenc) \
+		$(vopt_enable nvdec nvdec)
 }
 do_build() {
 	make ${makejobs}
@@ -148,10 +151,8 @@ libavdevice_package() {
 	}
 }
 libavresample_package() {
-	short_desc="FFmpeg audio resampling library"
-	pkg_install() {
-		vmove "usr/lib/libavresample.so.*"
-	}
+	short_desc="Package deprecated, removal needed"
+	build_style=meta
 }
 libavformat_package() {
 	short_desc="FFmpeg file format library"
@@ -198,9 +199,9 @@ ffmpeg-devel_package() {
 		libavfilter>=${version}_${revision}
 		libpostproc>=${version}_${revision}
 		libswscale>=${version}_${revision}
-		libswresample>=${version}_${revision}
-		libavresample>=${version}_${revision}"
+		libswresample>=${version}_${revision}"
 	short_desc+=" - development files"
+	conflicts="ffmpeg4-devel"
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig

From ac6cf0bdb93725409f9bb2bb8043c0572efe1fde Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:56:22 -0400
Subject: [PATCH 002/110] New package: ffmpeg4-4.4.3.

---
 srcpkgs/ffmpeg4-devel                         |   1 +
 srcpkgs/ffmpeg4/files/altivec.patch           |  60 +++++
 .../patches/armv5tel-floating-point.patch     |  18 ++
 .../workaround-mesa-readeon-vaapi-bug.patch   |  28 +++
 srcpkgs/ffmpeg4/template                      | 217 ++++++++++++++++++
 srcpkgs/libavcodec4                           |   1 +
 srcpkgs/libavdevice4                          |   1 +
 srcpkgs/libavfilter4                          |   1 +
 srcpkgs/libavformat4                          |   1 +
 srcpkgs/libavresample4                        |   1 +
 srcpkgs/libavutil4                            |   1 +
 srcpkgs/libpostproc4                          |   1 +
 srcpkgs/libswresample4                        |   1 +
 srcpkgs/libswscale4                           |   1 +
 14 files changed, 333 insertions(+)
 create mode 120000 srcpkgs/ffmpeg4-devel
 create mode 100644 srcpkgs/ffmpeg4/files/altivec.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
 create mode 100644 srcpkgs/ffmpeg4/template
 create mode 120000 srcpkgs/libavcodec4
 create mode 120000 srcpkgs/libavdevice4
 create mode 120000 srcpkgs/libavfilter4
 create mode 120000 srcpkgs/libavformat4
 create mode 120000 srcpkgs/libavresample4
 create mode 120000 srcpkgs/libavutil4
 create mode 120000 srcpkgs/libpostproc4
 create mode 120000 srcpkgs/libswresample4
 create mode 120000 srcpkgs/libswscale4

diff --git a/srcpkgs/ffmpeg4-devel b/srcpkgs/ffmpeg4-devel
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/ffmpeg4-devel
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/ffmpeg4/files/altivec.patch b/srcpkgs/ffmpeg4/files/altivec.patch
new file mode 100644
index 000000000000..9c5720046332
--- /dev/null
+++ b/srcpkgs/ffmpeg4/files/altivec.patch
@@ -0,0 +1,60 @@
+revert some altivec specific change on all ppc* except ppc64le*
+
+q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
+conditionally, for ppc* but not ppc64le* (the new code is valid for
+POWER8 VSX which LE targets as a baseline but not BE)"
+
+
+This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
+---
+ libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
+ 1 file changed, 20 insertions(+), 4 deletions(-)
+
+diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
+index 536545293d..c1e2852adb 100644
+--- a/libswscale/ppc/yuv2rgb_altivec.c
++++ b/libswscale/ppc/yuv2rgb_altivec.c
+@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+     vector signed short R1, G1, B1;                                           \
+     vector unsigned char R, G, B;                                             \
+                                                                               \
++    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
++    vector unsigned char align_perm;                                          \
++                                                                              \
+     vector signed short lCY       = c->CY;                                    \
+     vector signed short lOY       = c->OY;                                    \
+     vector signed short lCRV      = c->CRV;                                   \
+@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
+                                                                               \
+         for (j = 0; j < w / 16; j++) {                                        \
+-            y0 = vec_xl(0, y1i);                                              \
++            y1ivP = (const vector unsigned char *) y1i;                       \
++            y2ivP = (const vector unsigned char *) y2i;                       \
++            uivP  = (const vector unsigned char *) ui;                        \
++            vivP  = (const vector unsigned char *) vi;                        \
++                                                                              \
++            align_perm = vec_lvsl(0, y1i);                                    \
++            y0 = (vector unsigned char)                                       \
++                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
+                                                                               \
+-            y1 = vec_xl(0, y2i);                                              \
++            align_perm = vec_lvsl(0, y2i);                                    \
++            y1 = (vector unsigned char)                                       \
++                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
+                                                                               \
+-            u = (vector signed char) vec_xl(0, ui);                           \
++            align_perm = vec_lvsl(0, ui);                                     \
++            u = (vector signed char)                                          \
++                    vec_perm(uivP[0], uivP[1], align_perm);                   \
+                                                                               \
+-            v = (vector signed char) vec_xl(0, vi);                           \
++            align_perm = vec_lvsl(0, vi);                                     \
++            v = (vector signed char)                                          \
++                    vec_perm(vivP[0], vivP[1], align_perm);                   \
+                                                                               \
+             u = (vector signed char)                                          \
+                     vec_sub(u,                                                \
+-- 
+2.27.0
+
diff --git a/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
new file mode 100644
index 000000000000..9a55178c74f0
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
@@ -0,0 +1,18 @@
+--- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
++++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
+@@ -39,6 +39,15 @@
+ #endif
+ #include <fenv.h>
+ 
++#if (FE_ALL_EXCEPT == 0)
++/* E.g. ARM soft float does not define these */
++#define FE_INVALID    0
++#define FE_DIVBYZERO  0
++#define FE_OVERFLOW   0
++#define FE_UNDERFLOW  0
++#define FE_INEXACT    0
++#endif
++
+ #if CONFIG_LIBFONTCONFIG
+ #include <fontconfig/fontconfig.h>
+ #endif
diff --git a/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
new file mode 100644
index 000000000000..00e3f68a415b
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
@@ -0,0 +1,28 @@
+From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
+From: Rainer Hochecker <fernetmenta@online.de>
+Date: Sat, 26 Jan 2019 19:48:35 +0100
+Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
+
+This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
+It was hit frequently when watching h264 channels received via DVB-X.
+Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
+---
+ libavcodec/vaapi_h264.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
+index 5854587a255..f12fdc457a4 100644
+--- a/libavcodec/vaapi_h264.c
++++ b/libavcodec/vaapi_h264.c
+@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
+     H264SliceContext *sl = &h->slice_ctx[0];
+     int ret;
+ 
++    if (pic->nb_slices == 0) {
++        ret = AVERROR_INVALIDDATA;
++        goto finish;
++    }
++
+     ret = ff_vaapi_decode_issue(avctx, pic);
+     if (ret < 0)
+         goto finish;
diff --git a/srcpkgs/ffmpeg4/template b/srcpkgs/ffmpeg4/template
new file mode 100644
index 000000000000..e736c205371d
--- /dev/null
+++ b/srcpkgs/ffmpeg4/template
@@ -0,0 +1,217 @@
+# Template file for 'ffmpeg4'
+# audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
+pkgname=ffmpeg4
+version=4.4.3
+revision=1
+short_desc="Decoding, encoding and streaming software - ffmpeg4 libraries only"
+maintainer="Orphaned <orphan@voidlinux.org>"
+license="GPL-3.0-or-later"
+homepage="https://www.ffmpeg.org"
+changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
+distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
+checksum=6c5b6c195e61534766a0b5fe16acc919170c883362612816d0a1c7f4f947006e
+
+hostmakedepends="pkg-config perl yasm"
+makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
+ libXext-devel libXvMC-devel libxcb-devel lame-devel libtheora-devel
+ libvorbis-devel x264-devel xvidcore-devel jack-devel SDL2-devel
+ libcdio-paranoia-devel librtmp-devel libmodplug-devel gnutls-devel
+ speex-devel celt-devel harfbuzz-devel libass-devel opus-devel ocl-icd-devel
+ libbs2b-devel libvidstab-devel $(vopt_if pulseaudio pulseaudio-devel)
+ $(vopt_if vaapi libva-devel) $(vopt_if vdpau libvdpau-devel)
+ $(vopt_if x265 x265-devel) $(vopt_if v4l2 v4l-utils-devel)
+ $(vopt_if fdk_aac fdk-aac-devel) $(vopt_if vpx libvpx-devel)
+ $(vopt_if aom libaom-devel) $(vopt_if sndio sndio-devel)
+ $(vopt_if dav1d libdav1d-devel) $(vopt_if zimg zimg-devel)
+ $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
+ $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
+ $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if mfx 'libmfx libmfx-devel')
+ $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
+
+build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec mfx"
+build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
+
+desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
+desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
+desc_option_sofa="Enable support for AES SOFA"
+desc_option_webp="Enable support for WebP"
+
+case "$XBPS_TARGET_MACHINE" in
+	i686*) build_options_default+=" vaapi vdpau nvenc nvdec";;
+	x86_64*) build_options_default+=" vaapi vdpau mfx nvenc nvdec";;
+	ppc64*) build_options_default+=" vaapi vdpau";;
+	mips*) CFLAGS="-mnan=legacy";;
+esac
+
+if [ "$XBPS_TARGET_WORDSIZE" != "32" ]; then
+	build_options_default+=" svtav1"
+fi
+
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+fi
+
+_apply_patch() {
+	local args="$1" pname="$(basename $2)"
+
+	if [ ! -f ".${pname}_done" ]; then
+		patch -N $args -i $2
+		touch .${pname}_done
+	fi
+}
+
+post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64le*) ;;
+		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
+	esac
+}
+
+do_configure() {
+	# Fix gcc on x86_64-musl only
+	if [ "$XBPS_TARGET_MACHINE" = "x86_64-musl" ]; then
+		sed -i configure -e "s;_cflags_speed='-O3';_cflags_speed='-O2';"
+	fi
+
+	if [ "$CROSS_BUILD" ]; then
+		case "$XBPS_TARGET_MACHINE" in
+			arm*) _arch="arm";;
+			aarch64*) _arch="aarch64";;
+			mips*) _arch="mips";;
+			ppc64*) _arch="ppc64";;
+			ppc*) _arch="ppc";;
+			*) _arch="${XBPS_TARGET_MACHINE%%-musl}";;
+		esac
+
+		_args+=" --enable-cross-compile
+			--sysroot=$XBPS_CROSS_BASE
+			--cross-prefix=${XBPS_CROSS_TRIPLET}-
+			--target-os=linux --arch=${_arch}"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc|ppc-musl) _args+=" --disable-altivec";;
+	esac
+
+	if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+		_args+=" --extra-libs=-latomic"
+	fi
+
+	./configure --prefix=/usr --disable-debug --enable-gpl --enable-gnutls \
+		--disable-stripping \
+		--enable-libcdio --enable-version3 --enable-runtime-cpudetect \
+		--enable-libmp3lame --enable-libvorbis --enable-libxvid \
+		--enable-libx264 $(vopt_enable vpx libvpx) --enable-libtheora \
+		--enable-shared --enable-static --enable-libxcb \
+		$(vopt_enable pulseaudio libpulse) --enable-libfreetype --enable-libmodplug \
+		--enable-libspeex --enable-libcelt --enable-libass \
+		--enable-libopus --enable-librtmp --enable-libjack \
+		$(vopt_if fdk_aac '--enable-nonfree --enable-libfdk-aac') \
+		--disable-libopencore_amrnb --disable-libopencore_amrwb \
+		--disable-libopenjpeg \
+		--enable-postproc --enable-opencl ${_args} \
+		$(vopt_enable x265 libx265) \
+		$(vopt_enable v4l2 libv4l2) \
+		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
+		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		$(vopt_enable dav1d libdav1d) \
+		$(vopt_enable zimg libzimg) \
+		$(vopt_enable webp libwebp) \
+		$(vopt_enable sofa libmysofa) \
+		$(vopt_enable vulkan) \
+		$(vopt_enable drm libdrm) \
+		$(vopt_enable svtav1 libsvtav1) \
+		$(vopt_enable srt libsrt) \
+		$(vopt_enable rist librist) \
+		$(vopt_enable mfx libmfx) \
+		$(vopt_if nvenc '--enable-nvenc') \
+		$(vopt_if nvdec '--enable-nvdec')
+}
+do_build() {
+	make ${makejobs}
+	make doc/ff{mpeg,play}.1
+}
+do_install() {
+	make DESTDIR=${DESTDIR} install install-man
+	rm -rf ${DESTDIR}/usr/bin
+}
+
+libavcodec4_package() {
+	short_desc="FFmpeg codec library"
+	pkg_install() {
+		vmove "usr/lib/libavcodec.so.*"
+	}
+}
+libavdevice4_package() {
+	short_desc="FFmpeg device handling library"
+	pkg_install() {
+		vmove "usr/lib/libavdevice.so.*"
+	}
+}
+libavresample4_package() {
+	short_desc="FFmpeg audio resampling library"
+	pkg_install() {
+		vmove "usr/lib/libavresample.so.*"
+	}
+}
+libavformat4_package() {
+	short_desc="FFmpeg file format library"
+	pkg_install() {
+		vmove "usr/lib/libavformat.so.*"
+	}
+}
+libavutil4_package() {
+	short_desc="FFmpeg utility library"
+	pkg_install() {
+		vmove "usr/lib/libavutil.so.*"
+	}
+}
+libavfilter4_package() {
+	short_desc="FFmpeg audio/video filter library"
+	pkg_install() {
+		vmove "usr/lib/libavfilter.so.*"
+	}
+}
+libpostproc4_package() {
+	short_desc="FFmpeg video postprocessing library"
+	pkg_install() {
+		vmove "usr/lib/libpostproc.so.*"
+	}
+}
+libswscale4_package() {
+	short_desc="FFmpeg video scaling library"
+	pkg_install() {
+		vmove "usr/lib/libswscale.so.*"
+	}
+}
+libswresample4_package() {
+	short_desc="FFmpeg video resampling library"
+	pkg_install() {
+		vmove "usr/lib/libswresample.so.*"
+	}
+}
+ffmpeg4-devel_package() {
+	depends="
+		libavcodec4>=${version}_${revision}
+		libavdevice4>=${version}_${revision}
+		libavformat4>=${version}_${revision}
+		libavutil4>=${version}_${revision}
+		libavfilter4>=${version}_${revision}
+		libpostproc4>=${version}_${revision}
+		libswscale4>=${version}_${revision}
+		libswresample4>=${version}_${revision}
+		libavresample4>=${version}_${revision}"
+	short_desc+=" - development files"
+	conflicts="ffmpeg-devel"
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove usr/lib/*.a
+		vmove usr/lib/*.so
+		vmove usr/share/ffmpeg/examples
+		vmove usr/share/man/man3
+	}
+}
diff --git a/srcpkgs/libavcodec4 b/srcpkgs/libavcodec4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavcodec4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavdevice4 b/srcpkgs/libavdevice4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavdevice4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavfilter4 b/srcpkgs/libavfilter4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavfilter4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavformat4 b/srcpkgs/libavformat4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavformat4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavresample4 b/srcpkgs/libavresample4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavutil4 b/srcpkgs/libavutil4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavutil4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libpostproc4 b/srcpkgs/libpostproc4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libpostproc4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswresample4 b/srcpkgs/libswresample4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libswresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswscale4 b/srcpkgs/libswscale4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libswscale4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file

From 76e6a1ba626611e69f2530f2f949b8b00d9e9ca2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:04 -0400
Subject: [PATCH 003/110] opencv: update to 4.7.0.

---
 common/shlibs           | 104 ++++++++++++++++++++--------------------
 srcpkgs/opencv/template |   8 ++--
 2 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index 9497f6499aa2..fcc7401be626 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2137,58 +2137,58 @@ libcapstone.so.4 capstone-4.0_1
 libhavege.so.2 libhaveged-1.9.11_1
 libnih.so.1 libnih-1.0.3_1
 libnih-dbus.so.1 libnih-1.0.3_1
-libopencv_quality.so.406 libopencv-4.6.0_1
-libopencv_reg.so.406 libopencv-4.6.0_1
-libopencv_surface_matching.so.406 libopencv-4.6.0_1
-libopencv_xphoto.so.406 libopencv-4.6.0_1
-libopencv_freetype.so.406 libopencv-4.6.0_1
-libopencv_fuzzy.so.406 libopencv-4.6.0_1
-libopencv_hfs.so.406 libopencv-4.6.0_1
-libopencv_img_hash.so.406 libopencv-4.6.0_1
-libopencv_line_descriptor.so.406 libopencv-4.6.0_1
-libopencv_saliency.so.406 libopencv-4.6.0_1
-libopencv_structured_light.so.406 libopencv-4.6.0_1
-libopencv_aruco.so.406 libopencv-4.6.0_1
-libopencv_bgsegm.so.406 libopencv-4.6.0_1
-libopencv_bioinspired.so.406 libopencv-4.6.0_1
-libopencv_ccalib.so.406 libopencv-4.6.0_1
-libopencv_face.so.406 libopencv-4.6.0_1
-libopencv_tracking.so.406 libopencv-4.6.0_1
-libopencv_xfeatures2d.so.406 libopencv-4.6.0_1
-libopencv_optflow.so.406 libopencv-4.6.0_1
-libopencv_ximgproc.so.406 libopencv-4.6.0_1
-libopencv_plot.so.406 libopencv-4.6.0_1
-libopencv_text.so.406 libopencv-4.6.0_1
-libopencv_ml.so.406 libopencv-4.6.0_1
-libopencv_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn.so.406 libopencv-4.6.0_1
-libopencv_shape.so.406 libopencv-4.6.0_1
-libopencv_stitching.so.406 libopencv-4.6.0_1
-libopencv_photo.so.406 libopencv-4.6.0_1
-libopencv_video.so.406 libopencv-4.6.0_1
-libopencv_calib3d.so.406 libopencv-4.6.0_1
-libopencv_features2d.so.406 libopencv-4.6.0_1
-libopencv_flann.so.406 libopencv-4.6.0_1
-libopencv_highgui.so.406 libopencv-4.6.0_1
-libopencv_videoio.so.406 libopencv-4.6.0_1
-libopencv_imgcodecs.so.406 libopencv-4.6.0_1
-libopencv_imgproc.so.406 libopencv-4.6.0_1
-libopencv_core.so.406 libopencv-4.6.0_1
-libopencv_superres.so.406 libopencv-4.6.0_1
-libopencv_videostab.so.406 libopencv-4.6.0_1
-libopencv_gapi.so.406 libopencv-4.6.0_1
-libopencv_xobjdetect.so.406 libopencv-4.6.0_1
-libopencv_datasets.so.406 libopencv-4.6.0_1
-libopencv_dnn_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn_superres.so.406 libopencv-4.6.0_1
-libopencv_dpm.so.406 libopencv-4.6.0_1
-libopencv_phase_unwrapping.so.406 libopencv-4.6.0_1
-libopencv_stereo.so.406 libopencv-4.6.0_1
-libopencv_rapid.so.406 libopencv-4.6.0_1
-libopencv_intensity_transform.so.406 libopencv-4.6.0_1
-libopencv_alphamat.so.406 libopencv-4.6.0_1
-libopencv_barcode.so.406 libopencv-4.6.0_1
-libopencv_mcc.so.406 libopencv-4.6.0_1
+libopencv_quality.so.407 libopencv-4.7.0_1
+libopencv_reg.so.407 libopencv-4.7.0_1
+libopencv_surface_matching.so.407 libopencv-4.7.0_1
+libopencv_xphoto.so.407 libopencv-4.7.0_1
+libopencv_freetype.so.407 libopencv-4.7.0_1
+libopencv_fuzzy.so.407 libopencv-4.7.0_1
+libopencv_hfs.so.407 libopencv-4.7.0_1
+libopencv_img_hash.so.407 libopencv-4.7.0_1
+libopencv_line_descriptor.so.407 libopencv-4.7.0_1
+libopencv_saliency.so.407 libopencv-4.7.0_1
+libopencv_structured_light.so.407 libopencv-4.7.0_1
+libopencv_aruco.so.407 libopencv-4.7.0_1
+libopencv_bgsegm.so.407 libopencv-4.7.0_1
+libopencv_bioinspired.so.407 libopencv-4.7.0_1
+libopencv_ccalib.so.407 libopencv-4.7.0_1
+libopencv_face.so.407 libopencv-4.7.0_1
+libopencv_tracking.so.407 libopencv-4.7.0_1
+libopencv_xfeatures2d.so.407 libopencv-4.7.0_1
+libopencv_optflow.so.407 libopencv-4.7.0_1
+libopencv_ximgproc.so.407 libopencv-4.7.0_1
+libopencv_plot.so.407 libopencv-4.7.0_1
+libopencv_text.so.407 libopencv-4.7.0_1
+libopencv_ml.so.407 libopencv-4.7.0_1
+libopencv_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn.so.407 libopencv-4.7.0_1
+libopencv_shape.so.407 libopencv-4.7.0_1
+libopencv_stitching.so.407 libopencv-4.7.0_1
+libopencv_photo.so.407 libopencv-4.7.0_1
+libopencv_video.so.407 libopencv-4.7.0_1
+libopencv_calib3d.so.407 libopencv-4.7.0_1
+libopencv_features2d.so.407 libopencv-4.7.0_1
+libopencv_flann.so.407 libopencv-4.7.0_1
+libopencv_highgui.so.407 libopencv-4.7.0_1
+libopencv_videoio.so.407 libopencv-4.7.0_1
+libopencv_imgcodecs.so.407 libopencv-4.7.0_1
+libopencv_imgproc.so.407 libopencv-4.7.0_1
+libopencv_core.so.407 libopencv-4.7.0_1
+libopencv_superres.so.407 libopencv-4.7.0_1
+libopencv_videostab.so.407 libopencv-4.7.0_1
+libopencv_gapi.so.407 libopencv-4.7.0_1
+libopencv_xobjdetect.so.407 libopencv-4.7.0_1
+libopencv_datasets.so.407 libopencv-4.7.0_1
+libopencv_dnn_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn_superres.so.407 libopencv-4.7.0_1
+libopencv_dpm.so.407 libopencv-4.7.0_1
+libopencv_phase_unwrapping.so.407 libopencv-4.7.0_1
+libopencv_stereo.so.407 libopencv-4.7.0_1
+libopencv_rapid.so.407 libopencv-4.7.0_1
+libopencv_intensity_transform.so.407 libopencv-4.7.0_1
+libopencv_alphamat.so.407 libopencv-4.7.0_1
+libopencv_barcode.so.407 libopencv-4.7.0_1
+libopencv_mcc.so.407 libopencv-4.7.0_1
 libuniconf.so.4.6 wvstreams-4.6.1_20
 libwvbase.so.4.6 wvstreams-4.6.1_20
 libwvutils.so.4.6 wvstreams-4.6.1_20
diff --git a/srcpkgs/opencv/template b/srcpkgs/opencv/template
index 69c635b1ad2b..41f3183f1582 100644
--- a/srcpkgs/opencv/template
+++ b/srcpkgs/opencv/template
@@ -1,7 +1,7 @@
 # Template file for 'opencv'
 pkgname=opencv
-version=4.6.0
-revision=4
+version=4.7.0
+revision=1
 create_wrksrc=yes
 build_wrksrc=${pkgname}-${version}
 build_style=cmake
@@ -24,8 +24,8 @@ homepage="https://opencv.org"
 changelog="https://github.com/opencv/opencv/wiki/ChangeLog"
 distfiles="https://github.com/opencv/opencv/archive/${version}.tar.gz
  https://github.com/opencv/opencv_contrib/archive/${version}.tar.gz>contrib.tar.gz"
-checksum="1ec1cba65f9f20fe5a41fda1586e01c70ea0c9a6d7b67c9e13edf0cfe2239277
- 1777d5fd2b59029cf537e5fd6f8aa68d707075822f90bde683fcde086f85f7a7"
+checksum="8df0079cdbe179748a18d44731af62a245a45ebf5085223dc03133954c662973
+ 42df840cf9055e59d0e22c249cfb19f04743e1bdad113d31b1573d3934d62584"
 patch_args="-Np1 -d ${build_wrksrc}"
 # tests hang indenfinitely, even with test data included
 make_check=no

From a509c1b5be006ed1b2f1ff94bc7be74ad8e92594 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 004/110] actiona: revbump for opencv-4.7.0

---
 srcpkgs/actiona/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/actiona/template b/srcpkgs/actiona/template
index cf5f0b7a2ae6..0d899311e6df 100644
--- a/srcpkgs/actiona/template
+++ b/srcpkgs/actiona/template
@@ -1,7 +1,7 @@
 # Template file for 'actiona'
 pkgname=actiona
 version=3.10.1
-revision=2
+revision=3
 build_style=qmake
 configure_args="PKGCONFIG_OPENCV=opencv4"
 hostmakedepends="pkg-config qt5-plugin-mysql qt5-qmake qt5-host-tools"

From 190023a92a4b726734883507c8721a38a9bf2642 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 005/110] gmic: revbump for opencv-4.7.0

---
 srcpkgs/gmic/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gmic/template b/srcpkgs/gmic/template
index 24a9c7218fdf..0bb4034d5cc8 100644
--- a/srcpkgs/gmic/template
+++ b/srcpkgs/gmic/template
@@ -1,7 +1,7 @@
 # Template file for 'gmic'
 pkgname=gmic
 version=3.1.6
-revision=3
+revision=4
 _zart_hash=34ebf6cce0bafb98abe57cec83c4a02cd1abeca0
 create_wrksrc=yes
 build_wrksrc="src"

From 9b1d36b0e1e4c7a9465960f003785edfc048fc6e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 006/110] qimgv: revbump for opencv-4.7.0

---
 srcpkgs/qimgv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qimgv/template b/srcpkgs/qimgv/template
index 7eb30db33992..dd341dfe1bfc 100644
--- a/srcpkgs/qimgv/template
+++ b/srcpkgs/qimgv/template
@@ -1,7 +1,7 @@
 # Template file for 'qimgv'
 pkgname=qimgv
 version=1.0.2
-revision=2
+revision=3
 build_style=cmake
 configure_args="$(vopt_if video -DVIDEO_SUPPORT=ON -DVIDEO_SUPPORT=OFF)
  $(vopt_if scale -DOPENCV_SUPPORT=ON -DOPENCV_SUPPORT=OFF)

From e346a9f402d63ffb70b7180928a879d641eee6ec Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 007/110] retroshare: revbump for opencv-4.7.0

---
 srcpkgs/retroshare/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroshare/template b/srcpkgs/retroshare/template
index 8a0786c21a08..72023fa98b75 100644
--- a/srcpkgs/retroshare/template
+++ b/srcpkgs/retroshare/template
@@ -1,7 +1,7 @@
 # Template file for 'retroshare'
 pkgname=retroshare
 version=0.6.6
-revision=2
+revision=4
 build_style=qmake
 #XXX broadcast feature requires an ancient udp-discovery-cpp which either needs
 # to be fetched+patched (FTBFS) here or packaged :/

From 9785459d7311f68d0339b13fac30db2fecfaa877 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 008/110] siril: revbump for opencv-4.7.0

---
 srcpkgs/siril/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/siril/template b/srcpkgs/siril/template
index e88f30fb6178..84332f79d060 100644
--- a/srcpkgs/siril/template
+++ b/srcpkgs/siril/template
@@ -1,7 +1,7 @@
 # Template file for 'siril'
 pkgname=siril
 version=0.9.12
-revision=9
+revision=10
 build_style=gnu-configure
 hostmakedepends="pkg-config intltool autoconf automake gettext-devel"
 makedepends="fftw-devel libconfig-devel libopencv-devel libffms2-devel

From b00da3a5eb14e386b5fe8aaf72950c12d60991b0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 009/110] waifu2x-converter-cpp: revbump for opencv-4.7.0

---
 srcpkgs/waifu2x-converter-cpp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waifu2x-converter-cpp/template b/srcpkgs/waifu2x-converter-cpp/template
index 8c095d0d7bab..aa52d8c981a8 100644
--- a/srcpkgs/waifu2x-converter-cpp/template
+++ b/srcpkgs/waifu2x-converter-cpp/template
@@ -1,7 +1,7 @@
 # Template file for 'waifu2x-converter-cpp'
 pkgname=waifu2x-converter-cpp
 version=5.2.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DINSTALL_MODELS=ON"
 hostmakedepends="pkg-config"

From 3455096e71cf50ea1a0920ba62c067cbbbdaa9ba Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:38 -0400
Subject: [PATCH 010/110] vlc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/vlc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/vlc/template b/srcpkgs/vlc/template
index 210762b0a7e2..855ca5238662 100644
--- a/srcpkgs/vlc/template
+++ b/srcpkgs/vlc/template
@@ -1,7 +1,7 @@
 # Template file for 'vlc'
 pkgname=vlc
 version=3.0.18
-revision=3
+revision=4
 build_style=gnu-configure
 configure_args="--disable-gme --disable-libtar --enable-jack
  --enable-live555 --disable-fluidsynth --enable-dvdread
@@ -25,7 +25,7 @@ lib32disabled=yes
 hostmakedepends="automake libtool pkg-config flex gettext libgcrypt-devel
  live555-devel gettext-devel $(vopt_if lua lua52) $(vopt_if chromecast protobuf)"
 makedepends="
- avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg-devel freefont-ttf
+ avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg4-devel freefont-ttf
  gnutls-devel jack-devel liba52-devel libass-devel libbluray-devel
  libcdio-devel libdca-devel libdvbpsi-devel libdvdnav-devel libmad-devel
  libmatroska-devel libmodplug-devel libmpcdec-devel libmpeg2-devel

From 406094108d480e8c65e8b6d9b2974243bd797347 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:55 -0400
Subject: [PATCH 011/110] osg: revbump for ffmpeg4-4.4.3

---
 srcpkgs/osg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/osg/template b/srcpkgs/osg/template
index a9ebbd287933..755793f7e11b 100644
--- a/srcpkgs/osg/template
+++ b/srcpkgs/osg/template
@@ -8,7 +8,7 @@ build_helper="qemu"
 configure_args="-DLIB_POSTFIX="
 hostmakedepends="pkg-config xrandr"
 makedepends="MesaLib-devel gtkglext-devel libcurl-devel giflib-devel librsvg-devel
- jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg-devel xine-lib-devel
+ jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg4-devel xine-lib-devel
  SDL2-devel gst-plugins-base1-devel
  $(vopt_if openexr libopenexr-devel)
  $(vopt_if poppler poppler-glib-devel)

From 119d0efa7794b3eac98f14cf2cca68dbe5bf84af Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:13 -0400
Subject: [PATCH 012/110] xine-lib: revbump for ffmpeg4-4.4.3

---
 srcpkgs/xine-lib/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/xine-lib/template b/srcpkgs/xine-lib/template
index f713eff49b07..ed6194c17d11 100644
--- a/srcpkgs/xine-lib/template
+++ b/srcpkgs/xine-lib/template
@@ -1,6 +1,6 @@
 # Template file for 'xine-lib'
 pkgname=xine-lib
-version=1.2.12
+version=1.2.13
 revision=1
 build_style=gnu-configure
 configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
@@ -8,7 +8,7 @@ configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
 hostmakedepends="automake gettext-devel libtool pkg-config perl"
 makedepends="
  zlib-devel alsa-lib-devel libxcb-devel libSM-devel libXext-devel libXv-devel
- libXvMC-devel liba52-devel libmad-devel ffmpeg-devel pulseaudio-devel
+ libXvMC-devel liba52-devel libmad-devel ffmpeg4-devel pulseaudio-devel
  jack-devel samba-devel libflac-devel libmodplug-devel libmpcdec-devel
  speex-devel libtheora-devel libvorbis-devel libdca-devel faad2-devel
  libcdio-devel libbluray-devel aalib-devel libcaca-devel libXinerama-devel
@@ -19,7 +19,7 @@ license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="http://www.xine-project.org"
 changelog="https://sourceforge.net/projects/xine/files/xine-lib/${version}/README.txt/view"
 distfiles="${SOURCEFORGE_SITE}/xine/${pkgname}-${version}.tar.xz"
-checksum=d606270468e1540c2a89c0d7f5fdf11e17ecc0c2698cc0bcb1065ff26abee098
+checksum=5f10d6d718a4a51c17ed1b32b031d4f9b80b061e8276535b2be31e5ac4b75e6f
 
 case "$XBPS_TARGET_MACHINE" in
 	i686-musl)

From 29b9b402f89b90493d5647b9d13714b19d3f3708 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 013/110] QMPlay2: revbump for ffmpeg-6.0

---
 srcpkgs/QMPlay2/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/QMPlay2/template b/srcpkgs/QMPlay2/template
index ad73cbb01bae..55284c051161 100644
--- a/srcpkgs/QMPlay2/template
+++ b/srcpkgs/QMPlay2/template
@@ -1,7 +1,7 @@
 # Template file for 'QMPlay2'
 pkgname=QMPlay2
 version=23.02.05
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools"
 makedepends="alsa-lib-devel ffmpeg-devel libass-devel libcdio-devel libgme-devel

From 18eefc5a66bc8cbff261cd6c775148ed3fd26d52 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 014/110] alsa-plugins: revbump for ffmpeg-6.0

---
 srcpkgs/alsa-plugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/alsa-plugins/template b/srcpkgs/alsa-plugins/template
index 0bfa6d9fd264..a5708a7d82a8 100644
--- a/srcpkgs/alsa-plugins/template
+++ b/srcpkgs/alsa-plugins/template
@@ -1,7 +1,7 @@
 # Template file for 'alsa-plugins'
 pkgname=alsa-plugins
 version=1.2.7.1
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--disable-maemo-plugin"
 hostmakedepends="pkg-config"

From 0a3360b77f9a48aecca6322db8909b875405ddef Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 015/110] arcan: revbump for ffmpeg-6.0

---
 srcpkgs/arcan/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/arcan/template b/srcpkgs/arcan/template
index 7be9652eccf3..ccc7df11ceac 100644
--- a/srcpkgs/arcan/template
+++ b/srcpkgs/arcan/template
@@ -2,7 +2,7 @@
 # !! keep synced with: acfgfs aclip aloadimage
 pkgname=arcan
 version=0.6.2.1
-revision=1
+revision=2
 create_wrksrc=yes
 build_wrksrc=arcan/src
 build_style=cmake

From 5ef415dbca0848cad76a128f45eb98cf4b5ea7e0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 016/110] attract: revbump for ffmpeg4-4.4.3

---
 srcpkgs/attract/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/attract/template b/srcpkgs/attract/template
index 26144e931a3c..e760bf0d18ae 100644
--- a/srcpkgs/attract/template
+++ b/srcpkgs/attract/template
@@ -1,12 +1,12 @@
 # Template file for 'attract'
 pkgname=attract
 version=2.6.2
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="VERBOSE=1"
 make_use_env=yes
 hostmakedepends="pkg-config"
-makedepends="SFML-devel ffmpeg-devel fontconfig-devel glu-devel libarchive-devel
+makedepends="SFML-devel ffmpeg4-devel fontconfig-devel glu-devel libarchive-devel
  libcurl-devel libjpeg-turbo-devel xine-lib rapidjson libXrandr-devel"
 depends="git"
 short_desc="Attract-Mode is a graphical frontend for emulators"

From d8e13c06eacf1e520e7ef537dbb449a3ffbe1412 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 017/110] aubio: revbump for ffmpeg-6.0

---
 srcpkgs/aubio/patches/ffmpeg5.patch | 25 +++++++++++++++++++++++++
 srcpkgs/aubio/template              |  2 +-
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/aubio/patches/ffmpeg5.patch

diff --git a/srcpkgs/aubio/patches/ffmpeg5.patch b/srcpkgs/aubio/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..aace41a6e6d9
--- /dev/null
+++ b/srcpkgs/aubio/patches/ffmpeg5.patch
@@ -0,0 +1,25 @@
+From 8a05420e5dd8c7b8b2447f82dc919765876511b3 Mon Sep 17 00:00:00 2001
+From: Paul Brossier <piem@piem.org>
+Date: Tue, 25 Jan 2022 18:30:27 +0100
+Subject: [PATCH] [source_avcodec] define FF_API_LAVF_AVCTX for libavcodec >
+ 59, thx @berolinux (closes gh-353)
+
+---
+ src/io/source_avcodec.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/io/source_avcodec.c b/src/io/source_avcodec.c
+index e0ae93b5..1421bd9a 100644
+--- a/src/io/source_avcodec.c
++++ b/src/io/source_avcodec.c
+@@ -68,6 +68,10 @@
+ #define AUBIO_AVCODEC_MAX_BUFFER_SIZE AV_INPUT_BUFFER_MIN_SIZE
+ #endif
+ 
++#if LIBAVCODEC_VERSION_MAJOR >= 59
++#define FF_API_LAVF_AVCTX 1
++#endif
++
+ struct _aubio_source_avcodec_t {
+   uint_t hop_size;
+   uint_t samplerate;
diff --git a/srcpkgs/aubio/template b/srcpkgs/aubio/template
index ad1c4b256991..7d875cc02541 100644
--- a/srcpkgs/aubio/template
+++ b/srcpkgs/aubio/template
@@ -1,7 +1,7 @@
 # Template file for 'aubio'
 pkgname=aubio
 version=0.4.9
-revision=1
+revision=2
 build_style=waf3
 # XXX lash, pure and swig support.
 hostmakedepends="pkg-config txt2man"

From 24e5231c5ed6e3a9c30548e6eb2a441c3f490d3b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 018/110] audacious-plugins: revbump for ffmpeg-6.0

---
 .../audacious-plugins/patches/ffmpeg5.patch   | 43 +++++++++++++++++++
 srcpkgs/audacious-plugins/template            |  2 +-
 2 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/audacious-plugins/patches/ffmpeg5.patch

diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg5.patch b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..4e5e34099d71
--- /dev/null
+++ b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
@@ -0,0 +1,43 @@
+commit 298aa371c56c2f52c25a33d9bdec4918b11cebdc
+Author: tibequadorian <tibequadorian@posteo.de>
+Date:   Sat Mar 19 18:40:12 2022 +0100
+
+    audacious-plugins: rebuild against ffmpeg-5.0
+
+diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+new file mode 100644
+index 0000000000..617c11215b
+--- /dev/null
++++ b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+@@ -0,0 +1,31 @@
++From f60beb400eeb1e4778bbfd738bc4a4ccef3de539 Mon Sep 17 00:00:00 2001
++From: John Lindgren <john@jlindgren.net>
++Date: Sat, 5 Mar 2022 12:05:34 -0500
++Subject: [PATCH] Fix build with FFmpeg 5.0
++
++---
++ src/ffaudio/ffaudio-core.cc | 4 ++--
++ 1 file changed, 2 insertions(+), 2 deletions(-)
++
++diff --git a/src/ffaudio/ffaudio-core.cc b/src/ffaudio/ffaudio-core.cc
++index 16dc63e3a..a2b95fd6c 100644
++--- a/src/ffaudio/ffaudio-core.cc
+++++ b/src/ffaudio/ffaudio-core.cc
++@@ -274,7 +274,7 @@ static AVInputFormat * get_format_by_content (const char * name, VFSFile & file)
++         AVProbeData d = {name, buf, filled};
++         score = target;
++ 
++-        f = av_probe_input_format2 (& d, true, & score);
+++        f = (AVInputFormat *) av_probe_input_format2 (& d, true, & score);
++         if (f)
++             break;
++ 
++@@ -347,7 +347,7 @@ static bool find_codec (AVFormatContext * c, CodecInfo * cinfo)
++ #endif
++         if (stream && stream->codecpar && stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
++         {
++-            AVCodec * codec = avcodec_find_decoder (stream->codecpar->codec_id);
+++            AVCodec * codec = (AVCodec *) avcodec_find_decoder (stream->codecpar->codec_id);
++ 
++             if (codec)
++             {
diff --git a/srcpkgs/audacious-plugins/template b/srcpkgs/audacious-plugins/template
index 88cbc1671fc6..beebfae59ed4 100644
--- a/srcpkgs/audacious-plugins/template
+++ b/srcpkgs/audacious-plugins/template
@@ -2,7 +2,7 @@
 #Keep in sync with audacious!
 pkgname=audacious-plugins
 version=4.3.1
-revision=1
+revision=2
 build_style=meson
 configure_args="$(vopt_bool gtk3 gtk) $(vopt_bool gtk3)
  $(vopt_bool qt) $(vopt_bool qt qt6)"

From 2de41f17ef3610d78b034c06ef41d5eb499f065b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 019/110] audacity: revbump for ffmpeg4-4.4.3

---
 srcpkgs/audacity/template | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/audacity/template b/srcpkgs/audacity/template
index d509c0a89407..11e20255685b 100644
--- a/srcpkgs/audacity/template
+++ b/srcpkgs/audacity/template
@@ -1,7 +1,7 @@
 # Template file for 'audacity'
 pkgname=audacity
 version=2.4.1
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--with-ffmpeg=system --with-libsndfile=system --with-expat=system
  --with-libsoxr=system --with-lame=system --with-lv2=system ac_cv_path_WX_CONFIG=wx-config-gtk3"
@@ -9,7 +9,7 @@ hostmakedepends="pkg-config cmake gettext libtool m4 which"
 makedepends="jack-devel wxWidgets-gtk3-devel gtk+3-devel
  libmad-devel soundtouch-devel libsoxr-devel
  vamp-plugin-sdk-devel lame-devel libid3tag-devel libflac-devel
- ffmpeg-devel twolame-devel serd-devel lv2 lilv-devel suil-devel"
+ ffmpeg4-devel twolame-devel serd-devel lv2 lilv-devel suil-devel"
 depends="desktop-file-utils hicolor-icon-theme"
 short_desc="Graphical cross-platform audio editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
@@ -33,5 +33,4 @@ post_install() {
 	vcopy plug-ins /usr/share/audacity
 
 	rm ${DESTDIR}/usr/share/doc/audacity/LICENSE.txt
-	vlicense LICENSE.txt LICENSE
 }

From 4c70d1505c1fab3721d7aef479112117de0bb98a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 020/110] avidemux: revbump for ffmpeg-6.0

---
 srcpkgs/avidemux/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/avidemux/template b/srcpkgs/avidemux/template
index 253a0243e225..557285982d2b 100644
--- a/srcpkgs/avidemux/template
+++ b/srcpkgs/avidemux/template
@@ -1,7 +1,7 @@
 # Template file for 'avidemux'
 pkgname=avidemux
 version=2.8.0
-revision=2
+revision=3
 # Can't be compiled for aarch64, arm* or mips*
 archs="x86_64* i686*"
 hostmakedepends="cmake pkg-config qt5-host-tools qt5-devel tar yasm"

From f722a1bc1a3b9d0dc76fa458d339903524bbfdd7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 021/110] baresip: revbump for ffmpeg-6.0

---
 srcpkgs/baresip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/baresip/template b/srcpkgs/baresip/template
index f1bd1817048b..b21e22334316 100644
--- a/srcpkgs/baresip/template
+++ b/srcpkgs/baresip/template
@@ -1,7 +1,7 @@
 # Template file for 'baresip'
 pkgname=baresip
 version=2.10.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config glib-devel"
 makedepends="libgsm-devel libpng-devel openssl-devel libsndfile-devel

From 4d4905c17768c254e1b6f47455f873b93e2c286d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 022/110] blender: revbump for ffmpeg-6.0

---
 .../patches/ffmpeg6-compat-blender.patch      | 42 +++++++++++++++++++
 srcpkgs/blender/template                      |  2 +-
 2 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/blender/patches/ffmpeg6-compat-blender.patch

diff --git a/srcpkgs/blender/patches/ffmpeg6-compat-blender.patch b/srcpkgs/blender/patches/ffmpeg6-compat-blender.patch
new file mode 100644
index 000000000000..d51a9c7710cc
--- /dev/null
+++ b/srcpkgs/blender/patches/ffmpeg6-compat-blender.patch
@@ -0,0 +1,42 @@
+--- a/source/blender/blenkernel/intern/writeffmpeg.c	2022-11-08 13:50:16 UTC
++++ b/source/blender/blenkernel/intern/writeffmpeg.c
+@@ -855,7 +855,7 @@ static AVStream *alloc_video_stream(FFMpegContext *con
+                                                             255);
+   st->avg_frame_rate = av_inv_q(c->time_base);
+ 
+-  if (codec->capabilities & AV_CODEC_CAP_AUTO_THREADS) {
++  if (codec->capabilities & AV_CODEC_CAP_OTHER_THREADS) {
+     c->thread_count = 0;
+   }
+   else {
+--- a/source/blender/imbuf/intern/anim_movie.c	2022-11-04 00:33:07 UTC
++++ b/source/blender/imbuf/intern/anim_movie.c
+@@ -554,7 +554,7 @@ static int startffmpeg(struct anim *anim)
+   avcodec_parameters_to_context(pCodecCtx, video_stream->codecpar);
+   pCodecCtx->workaround_bugs = FF_BUG_AUTODETECT;
+ 
+-  if (pCodec->capabilities & AV_CODEC_CAP_AUTO_THREADS) {
++  if (pCodec->capabilities & AV_CODEC_CAP_OTHER_THREADS) {
+     pCodecCtx->thread_count = 0;
+   }
+   else {
+--- a/source/blender/imbuf/intern/indexer.c	2022-11-04 00:33:07 UTC
++++ b/source/blender/imbuf/intern/indexer.c
+@@ -559,7 +559,7 @@ static struct proxy_output_ctx *alloc_proxy_output_ffm
+   av_dict_set(&codec_opts, "preset", "veryfast", 0);
+   av_dict_set(&codec_opts, "tune", "fastdecode", 0);
+ 
+-  if (rv->codec->capabilities & AV_CODEC_CAP_AUTO_THREADS) {
++  if (rv->codec->capabilities & AV_CODEC_CAP_OTHER_THREADS) {
+     rv->c->thread_count = 0;
+   }
+   else {
+@@ -872,7 +872,7 @@ static IndexBuildContext *index_ffmpeg_create_context(
+   avcodec_parameters_to_context(context->iCodecCtx, context->iStream->codecpar);
+   context->iCodecCtx->workaround_bugs = FF_BUG_AUTODETECT;
+ 
+-  if (context->iCodec->capabilities & AV_CODEC_CAP_AUTO_THREADS) {
++  if (context->iCodec->capabilities & AV_CODEC_CAP_OTHER_THREADS) {
+     context->iCodecCtx->thread_count = 0;
+   }
+   else {
diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index 61b42eb2e51e..d18bc88838ff 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -1,7 +1,7 @@
 # Template file for 'blender'
 pkgname=blender
 version=3.4.1
-revision=3
+revision=4
 archs="x86_64* ppc64*"
 build_style="cmake"
 pycompile_dirs="/usr/share/blender/${version%.*}/scripts"

From 80efbfaa9c09e0ab8ce50d09f60bec27539acf5f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 023/110] cantata: revbump for ffmpeg-6.0

---
 srcpkgs/cantata/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cantata/template b/srcpkgs/cantata/template
index 4b417d80d5c2..8a90aaa4c07a 100644
--- a/srcpkgs/cantata/template
+++ b/srcpkgs/cantata/template
@@ -1,7 +1,7 @@
 # Template file for 'cantata'
 pkgname=cantata
 version=2.5.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools qt5-tools"
 makedepends="qt5-devel qt5-tools-devel qt5-svg-devel qt5-xmlpatterns-devel

From d52d2a9e99aa813b4a8865c9aeb501ce769bde7f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 024/110] ccextractor: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ccextractor/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/ccextractor/template b/srcpkgs/ccextractor/template
index 9abcd82852b2..6eccad5885af 100644
--- a/srcpkgs/ccextractor/template
+++ b/srcpkgs/ccextractor/template
@@ -1,12 +1,12 @@
 # Template file for 'ccextractor'
 pkgname=ccextractor
 version=0.93
-revision=1
+revision=2
 build_wrksrc="linux"
 build_style=gnu-configure
 configure_args="--enable-ocr --enable-hardsubx"
 hostmakedepends="automake pkg-config"
-makedepends="leptonica-devel tesseract-ocr-devel ffmpeg-devel"
+makedepends="leptonica-devel tesseract-ocr-devel ffmpeg4-devel"
 short_desc="Extract subtitles from video streams"
 maintainer="newbluemoon <blaumolch@mailbox.org>"
 license="GPL-2.0-or-later"

From c854753841086ce7b6dbc25e59c9d25c88300800 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 025/110] chromaprint: revbump for ffmpeg-6.0

---
 srcpkgs/chromaprint/patches/ffmpeg5.patch | 569 ++++++++++++++++++++++
 srcpkgs/chromaprint/template              |   2 +-
 2 files changed, 570 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromaprint/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromaprint/patches/ffmpeg5.patch b/srcpkgs/chromaprint/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..a9fd307a23c8
--- /dev/null
+++ b/srcpkgs/chromaprint/patches/ffmpeg5.patch
@@ -0,0 +1,569 @@
+From 8ccad6937177b1b92e40ab8f4447ea27bac009a7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= <lalinsky@gmail.com>
+Date: Fri, 4 Nov 2022 21:47:38 +0100
+Subject: [PATCH] Use FFmpeg 5.x (#120)
+
+* Use FFmpeg 5.1.2 for CI builds
+
+* Build on Ubuntu 20.04
+
+* Upgrade code to FFmpeg 5.x APIs
+
+* Only set FFmpeg include dirs if building tools
+
+* No longer needed
+
+* Use ubuntu 20.04
+---
+ .github/workflows/build.yml                   |   6 +-
+ CMakeLists.txt                                |  16 --
+ package/build.sh                              |   4 +-
+ src/audio/ffmpeg_audio_processor.h            |   2 -
+ src/audio/ffmpeg_audio_processor_avresample.h |  72 -------
+ src/audio/ffmpeg_audio_processor_swresample.h |  18 +-
+ src/audio/ffmpeg_audio_reader.h               | 197 +++++++++---------
+ tests/CMakeLists.txt                          |   6 +
+ 8 files changed, 122 insertions(+), 199 deletions(-)
+ delete mode 100644 src/audio/ffmpeg_audio_processor_avresample.h
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index f8d6a32..4da2405 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -84,9 +84,6 @@ find_package(FFmpeg)
+ if(FFMPEG_LIBRARIES)
+ 	cmake_push_check_state(RESET)
+ 	set(CMAKE_REQUIRED_LIBRARIES ${FFMPEG_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -lm)
+-	check_function_exists(av_packet_unref HAVE_AV_PACKET_UNREF)
+-	check_function_exists(av_frame_alloc HAVE_AV_FRAME_ALLOC)
+-	check_function_exists(av_frame_free HAVE_AV_FRAME_FREE)
+ 	cmake_pop_check_state()
+ endif()
+
+@@ -163,14 +160,11 @@ message(STATUS "Using ${FFT_LIB} for FFT calculations")
+ if(NOT AUDIO_PROCESSOR_LIB)
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+ 		set(AUDIO_PROCESSOR_LIB "swresample")
+-	elseif(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(AUDIO_PROCESSOR_LIB "avresample")
+ 	endif()
+ endif()
+
+ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE OFF)
+ 		set(USE_SWRESAMPLE ON)
+ 		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBSWRESAMPLE_LIBRARIES})
+ 		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBSWRESAMPLE_INCLUDE_DIRS})
+@@ -178,16 +172,6 @@ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+ 	endif()
+ 	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+-elseif(AUDIO_PROCESSOR_LIB STREQUAL "avresample")
+-	if(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE ON)
+-		set(USE_SWRESAMPLE OFF)
+-		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBAVRESAMPLE_LIBRARIES})
+-		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBAVRESAMPLE_INCLUDE_DIRS})
+-	else()
+-		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+-	endif()
+-	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+ else()
+ 	message(STATUS "Building without audio conversion support, please install FFmpeg with libswresample")
+ endif()
+diff --git a/package/build.sh b/package/build.sh
+index da631ae..b41d36e 100755
+--- a/package/build.sh
++++ b/package/build.sh
+@@ -7,8 +7,8 @@ set -eux
+
+ BASE_DIR=$(cd $(dirname $0)/.. && pwd)
+
+-FFMPEG_VERSION=4.4.1
+-FFMPEG_BUILD_TAG=v4.4.1-1
++FFMPEG_VERSION=5.1.2
++FFMPEG_BUILD_TAG=v${FFMPEG_VERSION}-1
+
+ TMP_BUILD_DIR=$BASE_DIR/$(mktemp -d build.XXXXXXXX)
+ trap 'rm -rf $TMP_BUILD_DIR' EXIT
+diff --git a/src/audio/ffmpeg_audio_processor.h b/src/audio/ffmpeg_audio_processor.h
+index 7628fc7..39f4f6d 100644
+--- a/src/audio/ffmpeg_audio_processor.h
++++ b/src/audio/ffmpeg_audio_processor.h
+@@ -10,8 +10,6 @@
+
+ #if defined(USE_SWRESAMPLE)
+ #include "audio/ffmpeg_audio_processor_swresample.h"
+-#elif defined(USE_AVRESAMPLE)
+-#include "audio/ffmpeg_audio_processor_avresample.h"
+ #else
+ #error "no audio processing library"
+ #endif
+diff --git a/src/audio/ffmpeg_audio_processor_avresample.h b/src/audio/ffmpeg_audio_processor_avresample.h
+deleted file mode 100644
+index bd85f92..0000000
+--- a/src/audio/ffmpeg_audio_processor_avresample.h
++++ /dev/null
+@@ -1,72 +0,0 @@
+-// Copyright (C) 2016  Lukas Lalinsky
+-// Distributed under the MIT license, see the LICENSE file for details.
+-
+-#ifndef CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-#define CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-
+-extern "C" {
+-#include <libavresample/avresample.h>
+-}
+-
+-namespace chromaprint {
+-
+-class FFmpegAudioProcessor {
+-public:
+-	FFmpegAudioProcessor() {
+-		m_resample_ctx = avresample_alloc_context();
+-	}
+-
+-	~FFmpegAudioProcessor() {
+-		avresample_free(&m_resample_ctx);
+-	}
+-
+-	void SetCompatibleMode() {
+-		av_opt_set_int(m_resample_ctx, "filter_size", 16, 0);
+-		av_opt_set_int(m_resample_ctx, "phase_shift", 8, 0);
+-		av_opt_set_int(m_resample_ctx, "linear_interp", 1, 0);
+-		av_opt_set_double(m_resample_ctx, "cutoff", 0.8, 0);
+-	}
+-
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "in_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_rate", sample_rate, 0);
+-	}
+-
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "out_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_rate, 0);
+-	}
+-
+-	int Init() {
+-		return avresample_open(m_resample_ctx);
+-	}
+-
+-	int Convert(uint8_t **out, int out_count, const uint8_t **in, int in_count) {
+-		return avresample_convert(m_resample_ctx, out, 0, out_count, (uint8_t **) in, 0, in_count);
+-	}
+-
+-	int Flush(uint8_t **out, int out_count) {
+-		return avresample_read(m_resample_ctx, out, out_count);
+-	}
+-
+-private:
+-	AVAudioResampleContext *m_resample_ctx = nullptr;
+-};
+-
+-}; // namespace chromaprint
+-
+-#endif
+diff --git a/src/audio/ffmpeg_audio_processor_swresample.h b/src/audio/ffmpeg_audio_processor_swresample.h
+index b86266b..b1d4bea 100644
+--- a/src/audio/ffmpeg_audio_processor_swresample.h
++++ b/src/audio/ffmpeg_audio_processor_swresample.h
+@@ -28,30 +28,28 @@ public:
+ 		av_opt_set_double(m_swr_ctx, "cutoff", 0.8, 0);
+ 	}
+
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "icl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "ich", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetInputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "in_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "isf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "in_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "isr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "in_sample_rate", sample_rate, 0);
+ 	}
+
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "ocl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "och", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetOutputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "out_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "osf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "out_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "osr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "out_sample_rate", sample_rate, 0);
+ 	}
+
+ 	int Init() {
+diff --git a/src/audio/ffmpeg_audio_reader.h b/src/audio/ffmpeg_audio_reader.h
+index 5550164..1c6b346 100644
+--- a/src/audio/ffmpeg_audio_reader.h
++++ b/src/audio/ffmpeg_audio_reader.h
+@@ -62,7 +62,7 @@ public:
+ 	bool Read(const int16_t **data, size_t *size);
+
+ 	bool IsOpen() const { return m_opened; }
+-	bool IsFinished() const { return m_finished && !m_got_frame; }
++	bool IsFinished() const { return !m_has_more_packets && !m_has_more_frames; }
+
+ 	std::string GetError() const { return m_error; }
+ 	int GetErrorCode() const { return m_error_code; }
+@@ -74,20 +74,19 @@ private:
+ 	uint8_t *m_convert_buffer[1] = { nullptr };
+ 	int m_convert_buffer_nb_samples = 0;
+
+-	AVInputFormat *m_input_fmt = nullptr;
++	const AVInputFormat *m_input_fmt = nullptr;
+ 	AVDictionary *m_input_opts = nullptr;
+
+ 	AVFormatContext *m_format_ctx = nullptr;
+ 	AVCodecContext *m_codec_ctx = nullptr;
+-	AVFrame *m_frame = nullptr;
+ 	int m_stream_index = -1;
+ 	std::string m_error;
+ 	int m_error_code = 0;
+-	bool m_finished = false;
+ 	bool m_opened = false;
+-	int m_got_frame = 0;
+-	AVPacket m_packet;
+-	AVPacket m_packet0;
++	bool m_has_more_packets = true;
++	bool m_has_more_frames = true;
++	AVPacket *m_packet = nullptr;
++	AVFrame *m_frame = nullptr;
+
+ 	int m_output_sample_rate = 0;
+ 	int m_output_channels = 0;
+@@ -98,19 +97,12 @@ private:
+
+ inline FFmpegAudioReader::FFmpegAudioReader() {
+ 	av_log_set_level(AV_LOG_QUIET);
+-
+-	av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
+ }
+
+ inline FFmpegAudioReader::~FFmpegAudioReader() {
+ 	Close();
+ 	av_dict_free(&m_input_opts);
+ 	av_freep(&m_convert_buffer[0]);
+-	av_packet_unref(&m_packet0);
+ }
+
+ inline bool FFmpegAudioReader::SetInputFormat(const char *name) {
+@@ -135,11 +127,10 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ 	Close();
+
+-    av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
++	m_packet = av_packet_alloc();
++	if (!m_packet) {
++		return false;
++	}
+
+ 	ret = avformat_open_input(&m_format_ctx, file_name.c_str(), m_input_fmt, &m_input_opts);
+ 	if (ret < 0) {
+@@ -153,26 +144,31 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		return false;
+ 	}
+
+-	AVCodec *codec;
++	const AVCodec *codec;
+ 	ret = av_find_best_stream(m_format_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &codec, 0);
+ 	if (ret < 0) {
+ 		SetError("Could not find any audio stream in the file", ret);
+ 		return false;
+ 	}
+ 	m_stream_index = ret;
++	auto stream = m_format_ctx->streams[m_stream_index];
+
+-	m_codec_ctx = m_format_ctx->streams[m_stream_index]->codec;
++	m_codec_ctx = avcodec_alloc_context3(codec);
+ 	m_codec_ctx->request_sample_fmt = AV_SAMPLE_FMT_S16;
+
++	ret = avcodec_parameters_to_context(m_codec_ctx, stream->codecpar);
++	if (ret < 0) {
++		SetError("Could not copy the stream parameters", ret);
++		return false;
++	}
++
+ 	ret = avcodec_open2(m_codec_ctx, codec, nullptr);
+ 	if (ret < 0) {
+ 		SetError("Could not open the codec", ret);
+ 		return false;
+ 	}
+
+-	if (!m_codec_ctx->channel_layout) {
+-		m_codec_ctx->channel_layout = av_get_default_channel_layout(m_codec_ctx->channels);
+-	}
++	av_dump_format(m_format_ctx, 0, "foo", 0);
+
+ 	m_frame = av_frame_alloc();
+ 	if (!m_frame) {
+@@ -183,19 +179,23 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		m_output_sample_rate = m_codec_ctx->sample_rate;
+ 	}
+
+-	if (!m_output_channels) {
+-		m_output_channels = m_codec_ctx->channels;
++	AVChannelLayout output_channel_layout;
++	if (m_output_channels) {
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
++	} else {
++		m_output_channels = m_codec_ctx->ch_layout.nb_channels;
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
+ 	}
+
+-	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
++	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->ch_layout.nb_channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
+ 		m_converter.reset(new FFmpegAudioProcessor());
+ 		m_converter->SetCompatibleMode();
+ 		m_converter->SetInputSampleFormat(m_codec_ctx->sample_fmt);
+ 		m_converter->SetInputSampleRate(m_codec_ctx->sample_rate);
+-		m_converter->SetInputChannelLayout(m_codec_ctx->channel_layout);
++		m_converter->SetInputChannelLayout(&(m_codec_ctx->ch_layout));
+ 		m_converter->SetOutputSampleFormat(AV_SAMPLE_FMT_S16);
+ 		m_converter->SetOutputSampleRate(m_output_sample_rate);
+-		m_converter->SetOutputChannelLayout(av_get_default_channel_layout(m_output_channels));
++		m_converter->SetOutputChannelLayout(&output_channel_layout);
+ 		auto ret = m_converter->Init();
+ 		if (ret != 0) {
+ 			SetError("Could not create an audio converter instance", ret);
+@@ -203,10 +203,11 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		}
+ 	}
+
++	av_channel_layout_uninit(&output_channel_layout);
++
+ 	m_opened = true;
+-	m_finished = false;
+-	m_got_frame = 0;
+-	m_nb_packets = 0;
++	m_has_more_packets = true;
++	m_has_more_frames = true;
+ 	m_decode_error = 0;
+
+ 	return true;
+@@ -214,6 +215,7 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ inline void FFmpegAudioReader::Close() {
+ 	av_frame_free(&m_frame);
++	av_packet_free(&m_packet);
+
+ 	m_stream_index = -1;
+
+@@ -252,91 +254,98 @@ inline bool FFmpegAudioReader::Read(const int16_t **data, size_t *size) {
+ 		return false;
+ 	}
+
++	*data = nullptr;
++	*size = 0;
++
+ 	int ret;
++	bool needs_packet = false;
+ 	while (true) {
+-		while (m_packet.size <= 0) {
+-			av_packet_unref(&m_packet0);
+-			av_init_packet(&m_packet);
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			ret = av_read_frame(m_format_ctx, &m_packet);
++		while (needs_packet && m_packet->size == 0) {
++			ret = av_read_frame(m_format_ctx, m_packet);
+ 			if (ret < 0) {
+ 				if (ret == AVERROR_EOF) {
+-					m_finished = true;
++					needs_packet = false;
++					m_has_more_packets = false;
+ 					break;
+-				} else {
++				}
++				SetError("Error reading from the audio source", ret);
++				return false;
++			}
++			if (m_packet->stream_index == m_stream_index) {
++				needs_packet = false;
++			} else {
++				av_packet_unref(m_packet);
++			}
++		}
++
++		if (m_packet->size != 0) {
++			ret = avcodec_send_packet(m_codec_ctx, m_packet);
++			if (ret < 0) {
++				if (ret != AVERROR(EAGAIN)) {
+ 					SetError("Error reading from the audio source", ret);
+ 					return false;
+ 				}
+-			}
+-			m_packet0 = m_packet;
+-			if (m_packet.stream_index != m_stream_index) {
+-				m_packet.data = nullptr;
+-				m_packet.size = 0;
+ 			} else {
+-				m_nb_packets++;
++				av_packet_unref(m_packet);
+ 			}
+ 		}
+
+-		ret = avcodec_decode_audio4(m_codec_ctx, m_frame, &m_got_frame, &m_packet);
++		ret = avcodec_receive_frame(m_codec_ctx, m_frame);
+ 		if (ret < 0) {
+-			if (m_decode_error) {
+-				SetError("Error decoding audio frame", m_decode_error);
+-				return false;
++			if (ret == AVERROR_EOF) {
++				m_has_more_frames = false;
++			} else if (ret == AVERROR(EAGAIN)) {
++				if (m_has_more_packets) {
++					needs_packet = true;
++					continue;
++				} else {
++					m_has_more_frames = false;
++				}
+ 			}
+-			m_decode_error = ret;
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			continue;
++			SetError("Error decoding the audio source", ret);
++			return false;
+ 		}
+
+-		break;
+-	}
+-
+-	m_decode_error = 0;
+-
+-	const int decoded = std::min(ret, m_packet.size);
+-	m_packet.data += decoded;
+-	m_packet.size -= decoded;
+-
+-	if (m_got_frame) {
+-		if (m_converter) {
+-			if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
+-				int linsize;
+-				av_freep(&m_convert_buffer[0]);
+-				m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
+-				ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
+-				if (ret < 0) {
+-					SetError("Couldn't allocate audio converter buffer", ret);
++		if (m_frame->nb_samples > 0) {
++			if (m_converter) {
++				if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
++					int linsize;
++					av_freep(&m_convert_buffer[0]);
++					m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
++					ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->ch_layout.nb_channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
++					if (ret < 0) {
++						SetError("Couldn't allocate audio converter buffer", ret);
++						return false;
++					}
++				}
++				auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
++				if (nb_samples < 0) {
++					SetError("Couldn't convert audio", ret);
+ 					return false;
+ 				}
+-			}
+-			auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			}
+-			*data = (const int16_t *) m_convert_buffer[0];
+-			*size = nb_samples;
+-		} else {
+-			*data = (const int16_t *) m_frame->data[0];
+-			*size = m_frame->nb_samples;
+-		}
+-	} else {
+-		if (m_finished && m_converter) {
+-			auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			} else if (nb_samples > 0) {
+-				m_got_frame = 1;
+ 				*data = (const int16_t *) m_convert_buffer[0];
+ 				*size = nb_samples;
++			} else {
++				*data = (const int16_t *) m_frame->data[0];
++				*size = m_frame->nb_samples;
++			}
++		} else {
++			if (m_converter) {
++				if (IsFinished()) {
++					auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
++					if (nb_samples < 0) {
++						SetError("Couldn't convert audio", ret);
++						return false;
++					} else if (nb_samples > 0) {
++						*data = (const int16_t *) m_convert_buffer[0];
++						*size = nb_samples;
++					}
++				}
+ 			}
+ 		}
+-	}
+
+-	return true;
++		return true;
++	}
+ }
+
+ inline void FFmpegAudioReader::SetError(const char *message, int errnum) {
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index a2b517b..123e643 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -38,6 +38,12 @@ set(SRCS
+
+ if(BUILD_TOOLS)
+ 	set(SRCS ${SRCS} ../src/audio/ffmpeg_audio_reader_test.cpp)
++    include_directories(
++        ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}
++        ${AUDIO_PROCESSOR_INCLUDE_DIRS}
++    )
+ 	link_libraries(fpcalc_libs)
+ endif()
+
+-- 
+2.38.1
+
+
diff --git a/srcpkgs/chromaprint/template b/srcpkgs/chromaprint/template
index 7ef7838949f3..1f7bbc70a22c 100644
--- a/srcpkgs/chromaprint/template
+++ b/srcpkgs/chromaprint/template
@@ -1,7 +1,7 @@
 # Template file for 'chromaprint'
 pkgname=chromaprint
 version=1.5.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DBUILD_TOOLS=ON"
 make_check_target="check"

From 4eff70ebc68cdc5f320b0f69c6ab405e658fd543 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 026/110] chromium: revbump for ffmpeg-6.0

---
 .../patches/chromium-93-ffmpeg-4.4.patch      | 36 --------------
 srcpkgs/chromium/patches/ffmpeg5.patch        | 47 +++++++++++++++++++
 srcpkgs/chromium/template                     |  2 +-
 3 files changed, 48 insertions(+), 37 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch
 create mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch b/srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch
deleted file mode 100644
index f0ec736f98bc..000000000000
--- a/srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch
+++ /dev/null
@@ -1,36 +0,0 @@
-diff --git a/media/filters/ffmpeg_demuxer.cc b/media/filters/ffmpeg_demuxer.cc
-index ac4713b07268..492a9a37d096 100644
---- a/media/filters/ffmpeg_demuxer.cc
-+++ b/media/filters/ffmpeg_demuxer.cc
-@@ -427,11 +427,11 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
-   scoped_refptr<DecoderBuffer> buffer;
- 
-   if (type() == DemuxerStream::TEXT) {
--    size_t id_size = 0;
-+    int id_size = 0;
-     uint8_t* id_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
- 
--    size_t settings_size = 0;
-+    int settings_size = 0;
-     uint8_t* settings_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
- 
-@@ -443,7 +443,7 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
-     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
-                                      side_data.data(), side_data.size());
-   } else {
--    size_t side_data_size = 0;
-+    int side_data_size = 0;
-     uint8_t* side_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
- 
-@@ -504,7 +504,7 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
-                                        packet->size - data_offset);
-     }
- 
--    size_t skip_samples_size = 0;
-+    int skip_samples_size = 0;
-     const uint32_t* skip_samples_ptr =
-         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
-             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..24e2da38e34c
--- /dev/null
+++ b/srcpkgs/chromium/patches/ffmpeg5.patch
@@ -0,0 +1,47 @@
+--- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
++++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
+@@ -92,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+-  if (stream->start_time != kNoFFmpegTimestamp)
++  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -1597,7 +1585,7 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+@@ -1618,7 +1606,7 @@
+     if (stream->type() != DemuxerStream::VIDEO)
+       continue;
+ 
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+ 
+     if (!stream->IsEnabled())
diff --git a/srcpkgs/chromium/template b/srcpkgs/chromium/template
index e50c739d3ee7..8705f2ef973f 100644
--- a/srcpkgs/chromium/template
+++ b/srcpkgs/chromium/template
@@ -2,7 +2,7 @@
 pkgname=chromium
 # See https://chromiumdash.appspot.com/releases?platform=Linux for the latest version
 version=112.0.5615.49
-revision=1
+revision=2
 archs="i686* x86_64* aarch64* armv7l*"
 hostmakedepends="
  $(vopt_if clang "clang lld llvm15")

From b98c175524d808211385f5673fe92684bc829839 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 027/110] cmus: revbump for ffmpeg-6.0

---
 srcpkgs/cmus/patches/ffmpeg6.patch | 12 ++++++++++++
 srcpkgs/cmus/template              |  2 +-
 2 files changed, 13 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/cmus/patches/ffmpeg6.patch

diff --git a/srcpkgs/cmus/patches/ffmpeg6.patch b/srcpkgs/cmus/patches/ffmpeg6.patch
new file mode 100644
index 000000000000..ffa95ab81110
--- /dev/null
+++ b/srcpkgs/cmus/patches/ffmpeg6.patch
@@ -0,0 +1,12 @@
+--- a/ip/ffmpeg.c
++++ b/ip/ffmpeg.c
+@@ -202,9 +202,6 @@ static int ffmpeg_open(struct input_plugin_data *ip_data)
+ 			break;
+ 		}
+ 
+-		if (codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+-			cc->flags |= AV_CODEC_FLAG_TRUNCATED;
+-
+ 		if (avcodec_open2(cc, codec, NULL) < 0) {
+ 			d_print("could not open codec: %d, %s\n", cc->codec_id, avcodec_get_name(cc->codec_id));
+ 			err = -IP_ERROR_UNSUPPORTED_FILE_TYPE;
diff --git a/srcpkgs/cmus/template b/srcpkgs/cmus/template
index 0fcb424ce336..05b77d0fecae 100644
--- a/srcpkgs/cmus/template
+++ b/srcpkgs/cmus/template
@@ -1,7 +1,7 @@
 # Template file for 'cmus'
 pkgname=cmus
 version=2.10.0
-revision=1
+revision=2
 build_style=configure
 configure_args="prefix=/usr LD=$CC"
 hostmakedepends="pkg-config"

From 30b63fff37a439263e89febd8d653aa4246a4e7e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 028/110] cyanrip: revbump for ffmpeg-6.0

---
 srcpkgs/cyanrip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cyanrip/template b/srcpkgs/cyanrip/template
index 9796e3461601..5db30e020d17 100644
--- a/srcpkgs/cyanrip/template
+++ b/srcpkgs/cyanrip/template
@@ -1,7 +1,7 @@
 # Template file for 'cyanrip'
 pkgname=cyanrip
 version=0.9.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config"
 makedepends="ffmpeg-devel libcdio-devel libcdio-paranoia-devel libcurl-devel libmusicbrainz5-devel"

From 902fd691e1a36042aac84f60ff26c3d54d3e7f97 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 029/110] deadbeef: revbump for ffmpeg4-4.4.3

---
 srcpkgs/deadbeef/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/deadbeef/template b/srcpkgs/deadbeef/template
index b664bb1b9bd9..165b3c7b9cad 100644
--- a/srcpkgs/deadbeef/template
+++ b/srcpkgs/deadbeef/template
@@ -1,14 +1,14 @@
 # Template file for 'deadbeef'
 pkgname=deadbeef
 version=1.8.8
-revision=1
+revision=2
 create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-oss --disable-lfm --disable-notify --disable-gtk2"
 hostmakedepends="automake libtool gettext gettext-devel intltool pkg-config
  yasm clang glib-devel"
 makedepends="
- alsa-lib-devel dbus-devel faad2-devel ffmpeg-devel gtk+3-devel imlib2-devel
+ alsa-lib-devel dbus-devel faad2-devel ffmpeg4-devel gtk+3-devel imlib2-devel
  jansson-devel libcddb-devel libcdio-devel libcurl-devel libflac-devel
  libmad-devel libpng-devel libsamplerate-devel libsndfile-devel libvorbis-devel
  libzip-devel mpg123-devel opusfile-devel pulseaudio-devel wavpack-devel"

From 2456a8f4bbce810d6519144f291fd01db94b1d83 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 030/110] dolphin-emu: revbump for ffmpeg-6.0

---
 srcpkgs/dolphin-emu/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/dolphin-emu/template b/srcpkgs/dolphin-emu/template
index 7ea197ceb2a8..7aeb0a5b645e 100644
--- a/srcpkgs/dolphin-emu/template
+++ b/srcpkgs/dolphin-emu/template
@@ -1,7 +1,7 @@
 # Template file for 'dolphin-emu'
 pkgname=dolphin-emu
 version=5.0.16101
-revision=1
+revision=2
 _dolphin_commit=8ecfa537a242de74d2e372e30d9d79b14584b2fb
 _mgba_commit=40d4c430fc36caeb7ea32fd39624947ed487d2f2
 #Version/hash pair can be found at https://dolphin-emu.org/download/

From e68ee8f569ec5211863bcc95fe81d4b3ced82d4c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 031/110] droidcam-obs-plugin: revbump for ffmpeg-6.0

---
 srcpkgs/droidcam-obs-plugin/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam-obs-plugin/template b/srcpkgs/droidcam-obs-plugin/template
index fc9c9bf6b9d5..fb0480754df4 100644
--- a/srcpkgs/droidcam-obs-plugin/template
+++ b/srcpkgs/droidcam-obs-plugin/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam-obs-plugin'
 pkgname=droidcam-obs-plugin
 version=2.0.1
-revision=1
+revision=2
 build_style=gnu-makefile
 make_use_env=yes
 make_build_args="ALLOW_STATIC=no"

From d96079ddd992bdd31dc09731bdb6f17811a9fcf0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 032/110] droidcam: revbump for ffmpeg-6.0

---
 srcpkgs/droidcam/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam/template b/srcpkgs/droidcam/template
index 1c3f1b8b1fc6..32a9220b79a4 100644
--- a/srcpkgs/droidcam/template
+++ b/srcpkgs/droidcam/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam'
 pkgname=droidcam
 version=1.8.2
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="USBMUXD=-lusbmuxd-2.0 JPEG=-lturbojpeg"
 hostmakedepends="pkg-config"

From 6386b9085759bc7afafb8a8a1e68491ed05882eb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 033/110] electron19: revbump for ffmpeg-6.0

---
 srcpkgs/electron19/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron19/template b/srcpkgs/electron19/template
index 068136be7623..32ce301e730c 100644
--- a/srcpkgs/electron19/template
+++ b/srcpkgs/electron19/template
@@ -1,7 +1,7 @@
 # Template file for 'electron19'
 pkgname=electron19
 version=19.0.8
-revision=2
+revision=3
 _nodever=16.14.2
 _chromiumver=102.0.5005.125
 archs="x86_64* aarch64* ppc64le*"

From 45c6aee838ecd1878339d8b45ce441b7cb544ba5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 034/110] ffmpegthumbnailer: revbump for ffmpeg-6.0

---
 .../ffmpegthumbnailer/patches/ffmpeg6.patch   | 202 ++++++++++++++++++
 srcpkgs/ffmpegthumbnailer/template            |   6 +-
 2 files changed, 205 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch

diff --git a/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
new file mode 100644
index 000000000000..363ff35a2841
--- /dev/null
+++ b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
@@ -0,0 +1,202 @@
+--- a/libffmpegthumbnailer/moviedecoder.cpp	2017-11-21 14:06:57.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.cpp	2023-05-05 13:14:47.946560668 -0400
+@@ -41,11 +41,6 @@
+ namespace ffmpegthumbnailer
+ {
+ 
+-struct SilenceLogLevel
+-{
+-    SilenceLogLevel() { av_log_set_level(AV_LOG_QUIET); }
+-};
+-
+ MovieDecoder::MovieDecoder(AVFormatContext* pavContext)
+ : m_VideoStream(-1)
+ , m_pFormatContext(pavContext)
+@@ -70,8 +65,6 @@
+ 
+ void MovieDecoder::initialize(const string& filename, bool preferEmbeddedMetadata)
+ {
+-    av_register_all();
+-    avcodec_register_all();
+     avformat_network_init();
+ 
+     string inputFile = filename == "-" ? "pipe:" : filename;
+@@ -97,8 +90,7 @@
+ {
+     if (m_pVideoCodecContext)
+     {
+-        avcodec_close(m_pVideoCodecContext);
+-        m_pVideoCodecContext = nullptr;
++        avcodec_free_context(&m_pVideoCodecContext);
+     }
+ 
+     if ((!m_FormatContextWasGiven) && m_pFormatContext)
+@@ -152,10 +144,10 @@
+     for (unsigned int i = 0; i < m_pFormatContext->nb_streams; ++i)
+     {
+         AVStream *stream = m_pFormatContext->streams[i];
+-        auto ctx = m_pFormatContext->streams[i]->codec;
+-        if (ctx->codec_type == AVMEDIA_TYPE_VIDEO)
++        auto par = m_pFormatContext->streams[i]->codecpar;
++        if (par->codec_type == AVMEDIA_TYPE_VIDEO)
+         {
+-            if (!preferEmbeddedMetadata || !isStillImageCodec(ctx->codec_id))
++            if (!preferEmbeddedMetadata || !isStillImageCodec(par->codec_id))
+             {
+                 videoStreams.push_back(i);
+                 continue;
+@@ -203,8 +195,7 @@
+     }
+ 
+     m_pVideoStream = m_pFormatContext->streams[m_VideoStream];
+-    m_pVideoCodecContext = m_pVideoStream->codec;
+-    m_pVideoCodec = avcodec_find_decoder(m_pVideoCodecContext->codec_id);
++    m_pVideoCodec = avcodec_find_decoder(m_pVideoStream->codecpar->codec_id);
+ 
+     if (m_pVideoCodec == nullptr)
+     {
+@@ -214,6 +205,20 @@
+         throw logic_error("Video Codec not found");
+     }
+ 
++    m_pVideoCodecContext = avcodec_alloc_context3(m_pVideoCodec);
++
++    if (m_pVideoCodecContext == nullptr)
++    {
++        destroy();
++        throw logic_error("Could not allocate video codec context");
++    }
++
++    if (avcodec_parameters_to_context(m_pVideoCodecContext, m_pVideoStream->codecpar) < 0)
++    {
++        destroy();
++        throw logic_error("Could not configure video codec context");
++    }
++
+     m_pVideoCodecContext->workaround_bugs = 1;
+ 
+     if (avcodec_open2(m_pVideoCodecContext, m_pVideoCodec, nullptr) < 0)
+@@ -386,13 +391,6 @@
+ 
+ void MovieDecoder::initializeFilterGraph(const AVRational& timeBase, const std::string& size, bool maintainAspectRatio)
+ {
+-    static const AVPixelFormat pixelFormats[] = { AV_PIX_FMT_RGB24, AV_PIX_FMT_NONE };
+-
+-    auto del = [] (AVBufferSinkParams* p) { av_freep(p); };
+-    std::unique_ptr<AVBufferSinkParams, decltype(del)> buffersinkParams(av_buffersink_params_alloc(), del);
+-
+-    avfilter_register_all();
+-
+     m_pFilterGraph = avfilter_graph_alloc();
+     assert(m_pFilterGraph);
+ 
+@@ -404,10 +402,8 @@
+ 
+     checkRc(avfilter_graph_create_filter(&m_pFilterSource, avfilter_get_by_name("buffer"), "thumb_buffer", ss.str().c_str(), nullptr, m_pFilterGraph),
+             "Failed to create filter source");
+-    buffersinkParams->pixel_fmts = pixelFormats;
+-    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, buffersinkParams.get(), m_pFilterGraph),
++    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, nullptr, m_pFilterGraph),
+             "Failed to create filter sink");
+-    buffersinkParams.release();
+ 
+     AVFilterContext* yadifFilter = nullptr;
+     if (m_pFrame->interlaced_frame != 0)
+@@ -500,15 +496,15 @@
+     }
+ 
+     checkRc(av_seek_frame(m_pFormatContext, -1, timestamp, 0), "Seeking in video failed");
+-    avcodec_flush_buffers(m_pFormatContext->streams[m_VideoStream]->codec);
++    avcodec_flush_buffers(m_pVideoCodecContext);
+ 
+     int keyFrameAttempts = 0;
+-    bool gotFrame = 0;
++    bool gotFrame;
+ 
+     do
+     {
+         int count = 0;
+-        gotFrame = 0;
++        gotFrame = false;
+ 
+         while (!gotFrame && count < 20)
+         {
+@@ -552,17 +548,33 @@
+         return false;
+     }
+ 
+-    av_frame_unref(m_pFrame);
+-
+-    int frameFinished;
++    int rc = avcodec_send_packet(m_pVideoCodecContext, m_pPacket);
++    if(rc == AVERROR(EAGAIN))
++    {
++        rc = 0;
++    }
+ 
+-    int bytesDecoded = avcodec_decode_video2(m_pVideoCodecContext, m_pFrame, &frameFinished, m_pPacket);
+-    if (bytesDecoded < 0)
++    if(rc == AVERROR_EOF)
++    {
++        return false;
++    }
++    else if(rc < 0)
+     {
+-        throw logic_error("Failed to decode video frame: bytesDecoded < 0");
++        throw logic_error("Failed to decode video frame: avcodec_send_packet() < 0");
+     }
+ 
+-    return frameFinished > 0;
++    rc = avcodec_receive_frame(m_pVideoCodecContext, m_pFrame);
++    switch(rc)
++    {
++        case 0:
++            return true;
++
++        case AVERROR(EAGAIN):
++            return false;
++
++        default:
++            throw logic_error("Failed to decode video frame: avcodec_receive_frame() < 0");
++    }
+ }
+ 
+ bool MovieDecoder::getVideoPacket()
+@@ -570,8 +582,6 @@
+     bool framesAvailable = true;
+     bool frameDecoded = false;
+ 
+-    int attempts = 0;
+-
+     if (m_pPacket)
+     {
+         av_packet_unref(m_pPacket);
+@@ -580,6 +590,7 @@
+ 
+     m_pPacket = new AVPacket();
+ 
++
+     while (framesAvailable && !frameDecoded)
+     {
+         framesAvailable = av_read_frame(m_pFormatContext, m_pPacket) >= 0;
+@@ -644,7 +655,7 @@
+ 
+ int32_t MovieDecoder::getStreamRotation()
+ {
+-    int32_t* matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
++    auto matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
+     if (matrix)
+     {
+         auto angle = lround(av_display_rotation_get(matrix));
+
+--- a/libffmpegthumbnailer/moviedecoder.h	2017-11-12 04:23:38.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.h	2023-05-05 13:26:07.095529911 -0400
+@@ -78,7 +78,7 @@
+     int                     m_VideoStream;
+     AVFormatContext*        m_pFormatContext;
+     AVCodecContext*         m_pVideoCodecContext;
+-    AVCodec*                m_pVideoCodec;
++    const AVCodec*          m_pVideoCodec;
+     AVFilterGraph*          m_pFilterGraph;
+     AVFilterContext*        m_pFilterSource;
+     AVFilterContext*        m_pFilterSink;
diff --git a/srcpkgs/ffmpegthumbnailer/template b/srcpkgs/ffmpegthumbnailer/template
index 039eea7622b3..35d546018d12 100644
--- a/srcpkgs/ffmpegthumbnailer/template
+++ b/srcpkgs/ffmpegthumbnailer/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbnailer'
 pkgname=ffmpegthumbnailer
 version=2.2.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libpng-devel libjpeg-turbo-devel ffmpeg-devel"
@@ -9,8 +9,8 @@ depends="ffmpeg"
 short_desc="Lightweight video thumbnailer"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
-homepage="https://github.com/dirkvdb/${pkgname}"
-distfiles="${homepage}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
+homepage="https://github.com/dirkvdb"
+distfiles="${homepage}/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
 checksum=1cb24059c38223f657b300c84dd80491b7040d4b69471c4fea69be862bc99b5b
 
 post_install() {

From 40e5ac9edaceee097397791f9d15ac0b69689a30 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 035/110] ffmpegthumbs: revbump for ffmpeg-6.0

---
 srcpkgs/ffmpegthumbs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ffmpegthumbs/template b/srcpkgs/ffmpegthumbs/template
index 5f0b9414dada..11b88193528f 100644
--- a/srcpkgs/ffmpegthumbs/template
+++ b/srcpkgs/ffmpegthumbs/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbs'
 pkgname=ffmpegthumbs
 version=22.12.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules kcoreaddons kconfig-devel
  pkg-config qt5-host-tools qt5-qmake gettext"

From 259d49a7dc220758b5c7f2248766953104edd88b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 036/110] ffms2: revbump for ffmpeg-6.0

---
 srcpkgs/ffms2/patches/ffmpeg5.patch | 424 ++++++++++++++++++++++++++++
 srcpkgs/ffms2/template              |   2 +-
 2 files changed, 425 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ffms2/patches/ffmpeg5.patch

diff --git a/srcpkgs/ffms2/patches/ffmpeg5.patch b/srcpkgs/ffms2/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..1479fabcafcb
--- /dev/null
+++ b/srcpkgs/ffms2/patches/ffmpeg5.patch
@@ -0,0 +1,424 @@
+From 45673149e9a2f5586855ad472e3059084eaa36b1 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:41:21 +0100
+Subject: [PATCH] Use auto for AVCodec
+
+The geniuses over at FFmpeg decided to constify this API, so old
+versions of the library will return AVCodec *, while new versions
+of the libary will return const AVCodec *, which, in C++, are not
+OK to convert between.
+
+Rather than use some macro hell in ffmscompat.h, we can work around
+this by using auto.
+
+Gross.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 2 +-
+ src/core/indexing.cpp    | 6 +++---
+ src/core/videosource.cpp | 2 +-
+ 3 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index e4ce97c..ac09666 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -469,7 +469,7 @@ void FFMS_AudioSource::OpenFile() {
+ 
+     LAVFOpenFile(SourceFile.c_str(), FormatContext, TrackNumber);
+ 
+-    AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
++    auto *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
+     if (Codec == nullptr)
+         throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+             "Audio codec not found");
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index e547c5a..59fb4e8 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -384,7 +384,7 @@ FFMS_TrackType FFMS_Indexer::GetTrackType(int Track) {
+ }
+ 
+ const char *FFMS_Indexer::GetTrackCodec(int Track) {
+-    AVCodec *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
++    auto *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
+     return codec ? codec->name : nullptr;
+ }
+ 
+@@ -402,7 +402,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             UseDTS);
+ 
+         if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            AVCodec *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (!VideoCodec) {
+                 FormatContext->streams[i]->discard = AVDISCARD_ALL;
+                 IndexMask.erase(i);
+@@ -433,7 +433,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 IndexMask.insert(i);
+             }
+         } else if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+-            AVCodec *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (AudioCodec == nullptr)
+                 throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_UNSUPPORTED,
+                     "Audio codec not found");
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index b889970..8956c22 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -171,7 +171,7 @@ FFMS_VideoSource::FFMS_VideoSource(const char *SourceFile, FFMS_Index &Index, in
+ 
+         LAVFOpenFile(SourceFile, FormatContext, VideoTrack);
+ 
+-        AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
++        auto *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
+         if (Codec == nullptr)
+             throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+                 "Video codec not found");
+-- 
+2.40.0
+
+From 96cbf38ea9381829a1314f432a2c60495dcefaad Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:12:41 +0100
+Subject: [PATCH] all: Update AVPacket API usage
+
+AVPackets must all be on the heap now, since it is no longer
+part of the libav* ABI.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 16 ++++++----
+ src/core/indexing.cpp    | 63 ++++++++++++++++++++++------------------
+ src/core/indexing.h      |  4 +--
+ src/core/utils.cpp       |  6 ----
+ src/core/utils.h         |  1 -
+ src/core/videosource.cpp | 30 ++++++++++---------
+ 6 files changed, 64 insertions(+), 56 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index 37cf9ae..e4ce97c 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -285,10 +285,15 @@ FFMS_AudioSource::AudioBlock *FFMS_AudioSource::CacheBlock(CacheIterator &pos) {
+ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     CurrentFrame = &Frames[PacketNumber];
+ 
+-    AVPacket Packet;
+-    if (!ReadPacket(&Packet))
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++    if (!ReadPacket(Packet)) {
++        av_packet_free(&Packet);
+         throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_UNKNOWN,
+             "ReadPacket unexpectedly failed to read a packet");
++    }
+ 
+     // ReadPacket may have changed the packet number
+     CurrentFrame = &Frames[PacketNumber];
+@@ -297,8 +302,9 @@ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     int NumberOfSamples = 0;
+     AudioBlock *CachedBlock = nullptr;
+     
+-    int Ret = avcodec_send_packet(CodecContext, &Packet);
+-    av_packet_unref(&Packet);
++    int Ret = avcodec_send_packet(CodecContext, Packet);
++    av_packet_unref(Packet);
++    av_packet_free(&Packet);
+ 
+     av_frame_unref(DecodeFrame);
+     Ret = avcodec_receive_frame(CodecContext, DecodeFrame);
+@@ -513,8 +519,6 @@ void FFMS_AudioSource::Seek() {
+ }
+ 
+ bool FFMS_AudioSource::ReadPacket(AVPacket *Packet) {
+-    InitNullPacket(*Packet);
+-
+     while (av_read_frame(FormatContext, Packet) >= 0) {
+         if (Packet->stream_index == TrackNumber) {
+             // Required because not all audio packets, especially in ogg, have a pts. Use the previous valid packet's pts instead.
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index 23fb95b..e547c5a 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -320,7 +320,7 @@ void FFMS_Indexer::CheckAudioProperties(int Track, AVCodecContext *Context) {
+     }
+ }
+ 
+-void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict,
++void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict,
+                                     int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct) {
+     if (VideoContext.Parser) {
+         uint8_t *OB;
+@@ -330,8 +330,8 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+         av_parser_parse2(VideoContext.Parser,
+             VideoContext.CodecContext,
+             &OB, &OBSize,
+-            pkt.data, pkt.size,
+-            pkt.pts, pkt.dts, pkt.pos);
++            pkt->data, pkt->size,
++            pkt->pts, pkt->dts, pkt->pos);
+ 
+         // H.264 (PAFF) and HEVC may have one field per packet, so we need to track
+         // when we have a full or half frame available, and mark one of them as
+@@ -351,15 +351,15 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+ 
+         *RepeatPict = VideoContext.Parser->repeat_pict;
+         *FrameType = VideoContext.Parser->pict_type;
+-        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt.flags & AV_PKT_FLAG_DISCARD));
++        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt->flags & AV_PKT_FLAG_DISCARD));
+     } else {
+-        *Invisible = !!(pkt.flags & AV_PKT_FLAG_DISCARD);
++        *Invisible = !!(pkt->flags & AV_PKT_FLAG_DISCARD);
+     }
+ 
+     if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP8)
+-        ParseVP8(pkt.data[0], Invisible, FrameType);
++        ParseVP8(pkt->data[0], Invisible, FrameType);
+     else if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP9)
+-        ParseVP9(pkt.data[0], Invisible, FrameType);
++        ParseVP9(pkt->data[0], Invisible, FrameType);
+ }
+ 
+ void FFMS_Indexer::Free() {
+@@ -458,32 +458,36 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+         }
+     }
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
+     std::vector<int64_t> LastValidTS(FormatContext->nb_streams, AV_NOPTS_VALUE);
+ 
+     int64_t filesize = avio_size(FormatContext->pb);
+     enum AVPictureStructure LastPicStruct = AV_PICTURE_STRUCTURE_UNKNOWN;
+-    while (av_read_frame(FormatContext, &Packet) >= 0) {
++    while (av_read_frame(FormatContext, Packet) >= 0) {
+         // Update progress
+         // FormatContext->pb can apparently be NULL when opening images.
+         if (IC && FormatContext->pb) {
+-            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate))
++            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate)) {
++                av_packet_free(&Packet);
+                 throw FFMS_Exception(FFMS_ERROR_CANCELLED, FFMS_ERROR_USER,
+                     "Cancelled by user");
++            }
+         }
+-        if (!IndexMask.count(Packet.stream_index)) {
+-            av_packet_unref(&Packet);
++        if (!IndexMask.count(Packet->stream_index)) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+-        int Track = Packet.stream_index;
++        int Track = Packet->stream_index;
+         FFMS_Track &TrackInfo = (*TrackIndices)[Track];
+-        bool KeyFrame = !!(Packet.flags & AV_PKT_FLAG_KEY);
++        bool KeyFrame = !!(Packet->flags & AV_PKT_FLAG_KEY);
+         ReadTS(Packet, LastValidTS[Track], (*TrackIndices)[Track].UseDTS);
+ 
+         if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            int64_t PTS = TrackInfo.UseDTS ? Packet.dts : Packet.pts;
++            int64_t PTS = TrackInfo.UseDTS ? Packet->dts : Packet->pts;
+             if (PTS == AV_NOPTS_VALUE) {
+                 // VPx alt-refs are output as packets which lack timestmps or durations, since
+                 // they are invisible. Currently, the timestamp mangling code in libavformat
+@@ -495,9 +499,11 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 // FFMS2 currently sorts packets by PTS, which will break decoding, otherwise.
+                 bool HasAltRefs = (FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP8 ||
+                                    FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP9);
+-                if (Packet.duration == 0 && !HasAltRefs)
++                if (Packet->duration == 0 && !HasAltRefs) {
++                    av_packet_free(&Packet);
+                     throw FFMS_Exception(FFMS_ERROR_INDEXING, FFMS_ERROR_PARSER,
+                         "Invalid packet pts, dts, and duration");
++                }
+ 
+                 if (TrackInfo.empty())
+                     PTS = 0;
+@@ -513,7 +519,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             ParseVideoPacket(AVContexts[Track], Packet, &RepeatPict, &FrameType, &Invisible, &LastPicStruct);
+ 
+             TrackInfo.AddVideoFrame(PTS, RepeatPict, KeyFrame,
+-                FrameType, Packet.pos, Invisible);
++                FrameType, Packet->pos, Invisible);
+         } else if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+             // For video seeking timestamps are used only if all packets have
+             // timestamps, while for audio they're used if any have timestamps,
+@@ -522,28 +528,29 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 TrackInfo.HasTS = true;
+ 
+             int64_t StartSample = AVContexts[Track].CurrentSample;
+-            uint32_t SampleCount = IndexAudioPacket(Track, &Packet, AVContexts[Track], *TrackIndices);
++            uint32_t SampleCount = IndexAudioPacket(Track, Packet, AVContexts[Track], *TrackIndices);
+             TrackInfo.SampleRate = AVContexts[Track].CodecContext->sample_rate;
+ 
+             TrackInfo.AddAudioFrame(LastValidTS[Track],
+-                StartSample, SampleCount, KeyFrame, Packet.pos, Packet.flags & AV_PKT_FLAG_DISCARD);
++                StartSample, SampleCount, KeyFrame, Packet->pos, Packet->flags & AV_PKT_FLAG_DISCARD);
+         }
+ 
+-        if (!(Packet.flags & AV_PKT_FLAG_DISCARD))
+-            TrackInfo.LastDuration = Packet.duration;
++        if (!(Packet->flags & AV_PKT_FLAG_DISCARD))
++            TrackInfo.LastDuration = Packet->duration;
+ 
+-        av_packet_unref(&Packet);
++        av_packet_unref(Packet);
+     }
++    av_packet_free(&Packet);
+ 
+     TrackIndices->Finalize(AVContexts, FormatContext->iformat->name);
+     return TrackIndices.release();
+ }
+ 
+-void FFMS_Indexer::ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS) {
+-    if (!UseDTS && Packet.pts != AV_NOPTS_VALUE)
+-        TS = Packet.pts;
++void FFMS_Indexer::ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS) {
++    if (!UseDTS && Packet->pts != AV_NOPTS_VALUE)
++        TS = Packet->pts;
+     if (TS == AV_NOPTS_VALUE)
+         UseDTS = true;
+-    if (UseDTS && Packet.dts != AV_NOPTS_VALUE)
+-        TS = Packet.dts;
++    if (UseDTS && Packet->dts != AV_NOPTS_VALUE)
++        TS = Packet->dts;
+ }
+diff --git a/src/core/indexing.h b/src/core/indexing.h
+index 3cfc3c3..5c06868 100644
+--- a/src/core/indexing.h
++++ b/src/core/indexing.h
+@@ -80,10 +80,10 @@ private:
+     int64_t Filesize;
+     uint8_t Digest[20];
+ 
+-    void ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS);
++    void ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS);
+     void CheckAudioProperties(int Track, AVCodecContext *Context);
+     uint32_t IndexAudioPacket(int Track, AVPacket *Packet, SharedAVContext &Context, FFMS_Index &TrackIndices);
+-    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
++    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
+     void Free();
+ public:
+     FFMS_Indexer(const char *Filename);
+diff --git a/src/core/utils.cpp b/src/core/utils.cpp
+index ce67533..8a2e997 100644
+--- a/src/core/utils.cpp
++++ b/src/core/utils.cpp
+@@ -62,12 +62,6 @@ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo) {
+     }
+ }
+ 
+-void InitNullPacket(AVPacket &pkt) {
+-    av_init_packet(&pkt);
+-    pkt.data = nullptr;
+-    pkt.size = 0;
+-}
+-
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames) {
+     AP.SampleFormat = static_cast<FFMS_SampleFormat>(av_get_packed_sample_fmt(CTX->sample_fmt));
+     AP.BitsPerSample = av_get_bytes_per_sample(CTX->sample_fmt) * 8;
+diff --git a/src/core/utils.h b/src/core/utils.h
+index 9819dc7..003ab79 100644
+--- a/src/core/utils.h
++++ b/src/core/utils.h
+@@ -58,7 +58,6 @@ std::unique_ptr<T> make_unique(Args&&... args) {
+ }
+ 
+ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo);
+-void InitNullPacket(AVPacket &pkt);
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames);
+ 
+ void LAVFOpenFile(const char *SourceFile, AVFormatContext *&FormatContext, int Track);
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index 06bd161..b889970 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -673,30 +673,34 @@ void FFMS_VideoSource::DecodeNextFrame(int64_t &AStartTime, int64_t &Pos) {
+     if (HasPendingDelayedFrames())
+         return;
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
+-
+-    while (ReadFrame(&Packet) >= 0) {
+-        if (Packet.stream_index != VideoTrack) {
+-            av_packet_unref(&Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++
++    while (ReadFrame(Packet) >= 0) {
++        if (Packet->stream_index != VideoTrack) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+         if (AStartTime < 0)
+-            AStartTime = Frames.UseDTS ? Packet.dts : Packet.pts;
++            AStartTime = Frames.UseDTS ? Packet->dts : Packet->pts;
+ 
+         if (Pos < 0)
+-            Pos = Packet.pos;
++            Pos = Packet->pos;
+ 
+-        bool FrameFinished = DecodePacket(&Packet);
+-        av_packet_unref(&Packet);
+-        if (FrameFinished)
++        bool FrameFinished = DecodePacket(Packet);
++        av_packet_unref(Packet);
++        if (FrameFinished) {
++            av_packet_free(&Packet);
+             return;
++        }
+     }
+ 
+     // Flush final frames
+-    InitNullPacket(Packet);
+-    DecodePacket(&Packet);
++    DecodePacket(Packet);
++    av_packet_free(&Packet);
+ }
+ 
+ bool FFMS_VideoSource::SeekTo(int n, int SeekOffset) {
+-- 
+2.40.0
+
+From bf9e03e9e08534c024e5a744a6437c4aac160201 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:20:47 +0100
+Subject: [PATCH 2/3] configure: Remove deprecated API use
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ configure.ac | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index b35ef80bc..d19714d0f 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -102,10 +102,10 @@ CFLAGS="$_CFLAGS $FFMPEG_CFLAGS"
+
+ AC_DEFUN([TEST_FFMPEG],
+          [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+-            #include <libavcodec/avcodec.h>
++            #include <libavformat/avformat.h>
+             #include <libswscale/swscale.h>
+             ]],[[
+-                avcodec_register_all();
++                avformat_network_init();
+                 swscale_version();
+             ]])], [eval $1=yes], [eval $1=no])
+         ])
+
diff --git a/srcpkgs/ffms2/template b/srcpkgs/ffms2/template
index 68e8a0c14bce..2acfadac44b3 100644
--- a/srcpkgs/ffms2/template
+++ b/srcpkgs/ffms2/template
@@ -1,7 +1,7 @@
 # Template file for 'ffms2'
 pkgname=ffms2
 version=2.40
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-shared --disable-static"
 hostmakedepends="pkg-config autoconf automake libtool"

From d126aef90bfaff4562679bb8478dc903a390c1b0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 037/110] freerdp: revbump for ffmpeg-6.0

---
 .../freerdp/patches/ffmpeg6_aa2cb9aa.patch    | 42 +++++++++++++++++++
 srcpkgs/freerdp/template                      |  2 +-
 2 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch

diff --git a/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
new file mode 100644
index 000000000000..a4324da3a882
--- /dev/null
+++ b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
@@ -0,0 +1,42 @@
+From aa2cb9aa5ff5562433598ba168a466e0752bca0e Mon Sep 17 00:00:00 2001
+From: akallabeth <akallabeth@posteo.net>
+Date: Tue, 14 Feb 2023 07:48:54 +0100
+Subject: [PATCH] Fixed #8686: Update h264 to use new FFMPEG API
+
+---
+ channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c | 2 ++
+ libfreerdp/codec/h264_ffmpeg.c            | 2 ++
+ 2 files changed, 4 insertions(+)
+
+diff --git a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+index 339462d865f..beea80b7a1e 100644
+--- a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
++++ b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+@@ -239,8 +239,10 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYP
+ 		}
+ 	}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 	if (mdecoder->codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		mdecoder->codec_context->flags |= AV_CODEC_FLAG_TRUNCATED;
++#endif
+ 
+ 	return TRUE;
+ }
+diff --git a/libfreerdp/codec/h264_ffmpeg.c b/libfreerdp/codec/h264_ffmpeg.c
+index 8a23db2473c..896a333019b 100644
+--- a/libfreerdp/codec/h264_ffmpeg.c
++++ b/libfreerdp/codec/h264_ffmpeg.c
+@@ -615,10 +615,12 @@ static BOOL libavcodec_init(H264_CONTEXT* h264)
+ 			goto EXCEPTION;
+ 		}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 		if (sys->codecDecoder->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		{
+ 			sys->codecDecoderContext->flags |= AV_CODEC_FLAG_TRUNCATED;
+ 		}
++#endif
+ 
+ #ifdef WITH_VAAPI
+ 
diff --git a/srcpkgs/freerdp/template b/srcpkgs/freerdp/template
index 25e8aa9677f0..4d51c8189902 100644
--- a/srcpkgs/freerdp/template
+++ b/srcpkgs/freerdp/template
@@ -1,7 +1,7 @@
 # Template file for 'freerdp'
 pkgname=freerdp
 version=2.10.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_ALSA=ON -DWITH_CUPS=OFF -DWITH_FFMPEG=ON
  -DWITH_GSTREAMER_0_10=OFF -DWITH_GSTREAMER_1_0=OFF -DWITH_JPEG=ON

From 1f033aec29257dbf388e178cd4c00ee78591800d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 038/110] gerbera: revbump for ffmpeg-6.0

---
 srcpkgs/gerbera/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gerbera/template b/srcpkgs/gerbera/template
index ae14f35c767c..2dc0ac0ce03b 100644
--- a/srcpkgs/gerbera/template
+++ b/srcpkgs/gerbera/template
@@ -1,7 +1,7 @@
 # Template file for 'gerbera'
 pkgname=gerbera
 version=1.12.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_SYSTEMD=0 -DWITH_AVCODEC=1"
 hostmakedepends="pkg-config"

From 4ea188d64e5f4806ab1259a39d7a7aba46e59f6d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 039/110] goldendict: revbump for ffmpeg-6.0

---
 srcpkgs/goldendict/patches/ffmpeg4.patch |  21 --
 srcpkgs/goldendict/patches/ffmpeg5.patch | 232 +++++++++++++++++++++++
 srcpkgs/goldendict/template              |   2 +-
 3 files changed, 233 insertions(+), 22 deletions(-)
 delete mode 100644 srcpkgs/goldendict/patches/ffmpeg4.patch
 create mode 100644 srcpkgs/goldendict/patches/ffmpeg5.patch

diff --git a/srcpkgs/goldendict/patches/ffmpeg4.patch b/srcpkgs/goldendict/patches/ffmpeg4.patch
deleted file mode 100644
index f045fa27f54b..000000000000
--- a/srcpkgs/goldendict/patches/ffmpeg4.patch
+++ /dev/null
@@ -1,21 +0,0 @@
---- a/ffmpegaudio.cc.orig 2018-05-09 22:16:13.480659958 +0200
-+++ b/ffmpegaudio.cc      2018-05-09 22:16:50.748322790 +0200
-@@ -143,7 +143,7 @@
-     return false;
-   }
-
--  unsigned char * avioBuffer = ( unsigned char * )av_malloc( kBufferSize + FF_INPUT_BUFFER_PADDING_SIZE );
-+  unsigned char * avioBuffer = ( unsigned char * )av_malloc( kBufferSize + AV_INPUT_BUFFER_PADDING_SIZE );
-   if ( !avioBuffer )
-   {
-     errorString = QObject::tr( "av_malloc() failed." );
-@@ -380,7 +380,7 @@
-   }
-
-   if ( !Qt4x5::AtomicInt::loadAcquire( isCancelled_ ) &&
--       codecContext_->codec->capabilities & CODEC_CAP_DELAY )
-+       codecContext_->codec->capabilities & AV_CODEC_CAP_DELAY )
-   {
-     av_init_packet( &packet );
-     int gotFrame = 0;
-
diff --git a/srcpkgs/goldendict/patches/ffmpeg5.patch b/srcpkgs/goldendict/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..7cfc98ada368
--- /dev/null
+++ b/srcpkgs/goldendict/patches/ffmpeg5.patch
@@ -0,0 +1,232 @@
+From 03bbe01b79a1f07a6780cb60f23a087104c5d77b Mon Sep 17 00:00:00 2001
+From: Abs62 <ottomann@yandex.ru>
+Date: Fri, 30 Mar 2018 22:53:24 +0300
+Subject: [PATCH] Fix warnings while compile with FFMpeg 3.4.2 (issue #978)
+
+---
+ ffmpegaudio.cc | 68 +++++++++++++++++++++++++++++++++++++++++++++-----
+ 1 file changed, 62 insertions(+), 6 deletions(-)
+
+diff --git a/ffmpegaudio.cc b/ffmpegaudio.cc
+index ed1172bdd..56e8f788e 100644
+--- a/ffmpegaudio.cc
++++ b/ffmpegaudio.cc
+@@ -91,6 +91,7 @@ struct DecoderContext
+   QByteArray audioData_;
+   QDataStream audioDataStream_;
+   AVFormatContext * formatContext_;
++  AVCodec * codec_;
+   AVCodecContext * codecContext_;
+   AVIOContext * avioContext_;
+   AVStream * audioStream_;
+@@ -114,6 +115,7 @@ DecoderContext::DecoderContext( QByteArray const & audioData, QAtomicInt & isCan
+   audioData_( audioData ),
+   audioDataStream_( audioData_ ),
+   formatContext_( NULL ),
++  codec_( NULL ),
+   codecContext_( NULL ),
+   avioContext_( NULL ),
+   audioStream_( NULL ),
+@@ -143,7 +145,11 @@ bool DecoderContext::openCodec( QString & errorString )
+     return false;
+   }
+
++#if LIBAVCODEC_VERSION_MAJOR < 56 || ( LIBAVCODEC_VERSION_MAJOR == 56 && LIBAVCODEC_VERSION_MINOR < 56 )
+   unsigned char * avioBuffer = ( unsigned char * )av_malloc( kBufferSize + FF_INPUT_BUFFER_PADDING_SIZE );
++#else
++  unsigned char * avioBuffer = ( unsigned char * )av_malloc( kBufferSize + AV_INPUT_BUFFER_PADDING_SIZE );
++#endif
+   if ( !avioBuffer )
+   {
+     errorString = QObject::tr( "av_malloc() failed." );
+@@ -186,7 +192,11 @@ bool DecoderContext::openCodec( QString & errorString )
+   // Find audio stream, use the first audio stream if available
+   for ( unsigned i = 0; i < formatContext_->nb_streams; i++ )
+   {
++#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 33 )
+     if ( formatContext_->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO )
++#else
++      if ( formatContext_->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO )
++#endif
+     {
+       audioStream_ = formatContext_->streams[i];
+       break;
+@@ -198,22 +208,38 @@ bool DecoderContext::openCodec( QString & errorString )
+     return false;
+   }
+
++#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 33 )
+   codecContext_ = audioStream_->codec;
+-  AVCodec * codec = avcodec_find_decoder( codecContext_->codec_id );
+-  if ( !codec )
++  codec_ = avcodec_find_decoder( codecContext_->codec_id );
++  if ( !codec_ )
+   {
+     errorString = QObject::tr( "Codec [id: %1] not found." ).arg( codecContext_->codec_id );
+     return false;
+   }
++#else
++  codec_ = avcodec_find_decoder( audioStream_->codecpar->codec_id );
++  if ( !codec_ )
++  {
++    errorString = QObject::tr( "Codec [id: %1] not found." ).arg( audioStream_->codecpar->codec_id );
++    return false;
++  }
++  codecContext_ = avcodec_alloc_context3( codec_ );
++  if ( !codecContext_ )
++  {
++    errorString = QObject::tr( "avcodec_alloc_context3() failed." );
++    return false;
++  }
++  avcodec_parameters_to_context( codecContext_, audioStream_->codecpar );
++#endif
+
+-  ret = avcodec_open2( codecContext_, codec, NULL );
++  ret = avcodec_open2( codecContext_, codec_, NULL );
+   if ( ret < 0 )
+   {
+     errorString = QObject::tr( "avcodec_open2() failed: %1." ).arg( avErrorString( ret ) );
+     return false;
+   }
+
+-  av_log( NULL, AV_LOG_INFO, "Codec open: %s: channels: %d, rate: %d, format: %s\n", codec->long_name,
++  av_log( NULL, AV_LOG_INFO, "Codec open: %s: channels: %d, rate: %d, format: %s\n", codec_->long_name,
+           codecContext_->channels, codecContext_->sample_rate, av_get_sample_fmt_name( codecContext_->sample_fmt ) );
+   return true;
+ }
+@@ -252,10 +278,13 @@ void DecoderContext::closeCodec()
+
+   // Closing a codec context without prior avcodec_open2() will result in
+   // a crash in ffmpeg
+-  if ( audioStream_ && audioStream_->codec && audioStream_->codec->codec )
++  if ( audioStream_ && codecContext_ && codec_ )
+   {
+     audioStream_->discard = AVDISCARD_ALL;
+-    avcodec_close( audioStream_->codec );
++    avcodec_close( codecContext_ );
++#if LIBAVCODEC_VERSION_MAJOR > 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR >= 33 )
++    avcodec_free_context( &codecContext_ );
++#endif
+   }
+
+   avformat_close_input( &formatContext_ );
+@@ -356,6 +385,7 @@ bool DecoderContext::play( QString & errorString )
+     if ( packet.stream_index == audioStream_->index )
+     {
+       AVPacket pack = packet;
++#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 37 )
+       int gotFrame = 0;
+       do
+       {
+@@ -370,6 +400,19 @@ bool DecoderContext::play( QString & errorString )
+         pack.data += len;
+       }
+       while( pack.size > 0 );
++#else
++      int ret = avcodec_send_packet( codecContext_, &pack );
++      /* read all the output frames (in general there may be any number of them) */
++      while( ret >= 0 )
++      {
++        ret = avcodec_receive_frame( codecContext_, frame);
++
++        if ( Qt4x5::AtomicInt::loadAcquire( isCancelled_ ) || ret < 0 )
++          break;
++
++        playFrame( frame );
++      }
++#endif
+     }
+     // av_free_packet() must be called after each call to av_read_frame()
+ #if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 7 )
+@@ -379,6 +422,7 @@ bool DecoderContext::play( QString & errorString )
+ #endif
+   }
+
++#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 37 )
+   if ( !Qt4x5::AtomicInt::loadAcquire( isCancelled_ ) &&
+        codecContext_->codec->capabilities & CODEC_CAP_DELAY )
+   {
+@@ -391,6 +435,18 @@ bool DecoderContext::play( QString & errorString )
+       playFrame( frame );
+     }
+   }
++#else
++  /* flush the decoder */
++  av_init_packet( &packet );
++  int ret = avcodec_send_packet(codecContext_, &packet );
++  while( ret >= 0 )
++  {
++    ret = avcodec_receive_frame(codecContext_, frame);
++    if ( Qt4x5::AtomicInt::loadAcquire( isCancelled_ ) || ret < 0 )
++      break;
++    playFrame( frame );
++  }
++#endif
+
+ #if LIBAVCODEC_VERSION_MAJOR < 54
+   av_free( frame );
+32
+srcpkgs/goldendict/patches/ffmpeg5-2.patch
+Comment on this file
+@@ -0,0 +1,32 @@
+From 966f4a8b78e6324b930e5a50f2bb930bd87e565e Mon Sep 17 00:00:00 2001
+From: Abs62 <ottomann@yandex.ru>
+Date: Fri, 27 Sep 2019 17:00:52 +0300
+Subject: [PATCH] FFmpeg player: Fix some crashes on broken files
+
+---
+ ffmpegaudio.cc | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/ffmpegaudio.cc b/ffmpegaudio.cc
+index 56e8f788e..415fc79cb 100644
+--- a/ffmpegaudio.cc
++++ b/ffmpegaudio.cc
+@@ -51,7 +51,9 @@ AudioService & AudioService::instance()
+
+ AudioService::AudioService()
+ {
++#if LIBAVFORMAT_VERSION_MAJOR < 58 || ( LIBAVFORMAT_VERSION_MAJOR == 58 && LIBAVFORMAT_VERSION_MINOR < 9 )
+   av_register_all();
++#endif
+   ao_initialize();
+ }
+
+@@ -438,6 +440,8 @@ bool DecoderContext::play( QString & errorString )
+ #else
+   /* flush the decoder */
+   av_init_packet( &packet );
++  packet.data = NULL;
++  packet.size = 0;
+   int ret = avcodec_send_packet(codecContext_, &packet );
+   while( ret >= 0 )
+   {
+25
+srcpkgs/goldendict/patches/ffmpeg5-3.patch
+Comment on this file
+@@ -0,0 +1,25 @@
+From 8acb288c9e9bdb3c6bf2e803954dd3b6ac273c05 Mon Sep 17 00:00:00 2001
+From: Liao Junxuan <mikeljx@126.com>
+Date: Sun, 20 Feb 2022 12:28:05 +0800
+Subject: [PATCH] add support for ffmpeg 5.0
+
+---
+ ffmpegaudio.cc | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/ffmpegaudio.cc b/ffmpegaudio.cc
+index d550f4a77..7948d2187 100644
+--- a/ffmpegaudio.cc
++++ b/ffmpegaudio.cc
+@@ -94,7 +94,11 @@ struct DecoderContext
+   QByteArray audioData_;
+   QDataStream audioDataStream_;
+   AVFormatContext * formatContext_;
++#if LIBAVCODEC_VERSION_MAJOR < 59
+   AVCodec * codec_;
++#else
++  const AVCodec * codec_;
++#endif
+   AVCodecContext * codecContext_;
+   AVIOContext * avioContext_;
+   AVStream * audioStream_;
diff --git a/srcpkgs/goldendict/template b/srcpkgs/goldendict/template
index 4544ae710ee6..2ca4185e538a 100644
--- a/srcpkgs/goldendict/template
+++ b/srcpkgs/goldendict/template
@@ -9,7 +9,7 @@ makedepends="tiff-devel qt5-devel libvorbis-devel zlib-devel
  libXtst-devel hunspell-devel qt5-tools-devel qt5-declarative-devel
  qt5-webkit-devel lzo-devel bzip2-devel libao-devel qt5-svg-devel
  libeb-devel qt5-x11extras-devel ffmpeg-devel liblzma-devel"
-short_desc="A feature-rich dictionary lookup program"
+short_desc="Feature-rich dictionary lookup program"
 maintainer="John <me@johnnynator.dev>"
 license="GPL-3.0-or-later"
 homepage="http://goldendict.org/"

From e6ba92d79d1f211876e0373ce29adea4f1c6261c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 040/110] gst-libav: revbump for ffmpeg-6.0

---
 srcpkgs/gst-libav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index e9a79dc650a5..f082bd211c65 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.20.3
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"

From 0e27fb9528d61dd6b1f17ca00364da1ba4f9f342 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 041/110] gst-plugins-bad1: revbump for ffmpeg-6.0

---
 srcpkgs/gst-plugins-bad1/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index f55f82fd4c77..5a9d5387e0d4 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-plugins-bad1'
 pkgname=gst-plugins-bad1
-version=1.20.3
-revision=3
+version=1.22.1
+revision=2
 build_helper="gir"
 build_style=meson
 configure_args="-Dpackage-origin=https://voidlinux.org -Ddoc=disabled

From 8b323b01849cb45238d6c451949c1bd4f60e4b99 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 042/110] gst-rtsp-server: revbump for ffmpeg-6.0

---
 srcpkgs/gst-rtsp-server/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index 33cd64ceb95e..8ceea8d34b4b 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
 version=1.20.3
-revision=2
+revision=3
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="glib-devel gst-plugins-bad1-devel gobject-introspection

From 273c42c9bb65e2599b0569581487fa084c1c2a3e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 043/110] guvcview: update to 2.0.8.

---
 srcpkgs/guvcview/patches/fix-include.patch | 10 ++++++++++
 srcpkgs/guvcview/template                  |  5 ++---
 2 files changed, 12 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/guvcview/patches/fix-include.patch

diff --git a/srcpkgs/guvcview/patches/fix-include.patch b/srcpkgs/guvcview/patches/fix-include.patch
new file mode 100644
index 000000000000..503c2af3b78c
--- /dev/null
+++ b/srcpkgs/guvcview/patches/fix-include.patch
@@ -0,0 +1,10 @@
+--- a/guvcview/guvcview.c
++++ b/guvcview/guvcview.c
+@@ -28,6 +28,7 @@
+ #include <sys/stat.h>
+ #include <sys/resource.h>
+ #include <errno.h>
++#include <locale.h>
+ 
+ #include "gview.h"
+ #include "gviewv4l2core.h"
diff --git a/srcpkgs/guvcview/template b/srcpkgs/guvcview/template
index 345cf6006f24..86a7fd619612 100644
--- a/srcpkgs/guvcview/template
+++ b/srcpkgs/guvcview/template
@@ -1,8 +1,7 @@
 # Template file for 'guvcview'
 pkgname=guvcview
-version=2.0.7
+version=2.0.8
 revision=1
-create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-static --disable-debian-menu"
 hostmakedepends="pkg-config intltool autoconf automake libtool glib-devel"
@@ -14,7 +13,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="http://guvcview.sourceforge.net/"
 distfiles="${SOURCEFORGE_SITE}/${pkgname}/${pkgname}-src-${version}.tar.bz2"
-checksum=f47d51fbd06e44eeaa1a82f4a153c927527c90d94514197a70b2956028cc8ad4
+checksum=a21f4e448286666cf27bafef5290cc953a0a1796b752e5bbe521266dc1230c81
 
 post_patch() {
 	sed '31a#include <locale.h>' -i  guvcview/guvcview.c

From 76e4aa9c13a874d5409b7f5367bd6ede458316d8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 044/110] handbrake: update to 1.6.1

---
 .../patches/fix-missing-x265-link-flag.patch    | 11 ++++++-----
 .../handbrake/patches/libhb-vpl-include.patch   | 15 +++++++++++++++
 srcpkgs/handbrake/template                      | 17 ++++++++++-------
 3 files changed, 31 insertions(+), 12 deletions(-)
 create mode 100644 srcpkgs/handbrake/patches/libhb-vpl-include.patch

diff --git a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
index 26db03867a0c..d6bb2eda627a 100644
--- a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
+++ b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
@@ -1,14 +1,15 @@
 --- a/gtk/configure.ac
 +++ b/gtk/configure.ac
 @@ -203,7 +203,7 @@
- 
+
  AM_CONDITIONAL([MINGW], [test "x$mingw_flag" = "xyes"])
- 
--HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg"
-+HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -ldl"
+
+-HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc"
++HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc -ldl"
  HB_CPPFLAGS="$HB_CPPFLAGS $HBINC"
- 
+
  PKG_CHECK_MODULES([x264], [x264], sys_x264=yes, sys_x264=no)
+
 --- a/test/module.defs
 +++ b/test/module.defs
 @@ -69,6 +69,9 @@
diff --git a/srcpkgs/handbrake/patches/libhb-vpl-include.patch b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
new file mode 100644
index 000000000000..298f9f4ab28f
--- /dev/null
+++ b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
@@ -0,0 +1,15 @@
+--- a/libhb/module.defs	2023-01-22 11:36:49.000000000 -0500
++++ b/libhb/module.defs	2023-04-03 22:37:52.395467010 -0400
+@@ -46,11 +46,7 @@
+ LIBHB.GCC.I += $(LIBHB.build/) $(CONTRIB.build/)include
+ 
+ ifeq (1,$(FEATURE.qsv))
+-    ifeq ($(HOST.system),freebsd))
+-        LIBHB.GCC.I += $(LOCALBASE)/include/vpl
+-    else
+-        LIBHB.GCC.I += $(CONTRIB.build/)include/vpl
+-    endif
++    LIBHB.GCC.I += /usr/include/vpl
+ endif
+ 
+ ifneq (,$(filter $(HOST.system),freebsd netbsd openbsd))
diff --git a/srcpkgs/handbrake/template b/srcpkgs/handbrake/template
index ca5e4571e49c..c32cb1bfa31f 100644
--- a/srcpkgs/handbrake/template
+++ b/srcpkgs/handbrake/template
@@ -1,10 +1,10 @@
 # Template file for 'handbrake'
 pkgname=handbrake
-version=1.5.1
+version=1.6.1
 revision=1
 build_style=gnu-configure
 configure_args="--force --disable-gtk-update-checks --disable-df-fetch --harden
- $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc)"
+ $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc) $(vopt_enable qsv)"
 make_build_args="-C ${XBPS_TRIPLET}"
 make_install_args="-C ${XBPS_TRIPLET}"
 hostmakedepends="automake cmake gettext-devel glib-devel intltool libtool m4 meson nasm pkg-config python3"
@@ -12,8 +12,11 @@ makedepends="bzip2-devel ffmpeg-devel gst-plugins-base1-devel gtk+3-devel
  jansson-devel lame-devel libass-devel libbluray-devel libdav1d-devel
  libdvdnav-devel libdvdread-devel libgudev-devel libnuma-devel
  libsamplerate-devel libtheora-devel libvorbis-devel libvpx-devel libxml2-devel
- opus-devel speex-devel x264-devel x265-devel zimg-devel
+ opus-devel speex-devel x264-devel x265-devel zimg-devel libsvt-av1-devel
  $(vopt_if fdk_aac fdk-aac-devel)
+ $(vopt_if qsv libva-devel)
+ $(vopt_if qsv libdrm-devel)
+ $(vopt_if qsv onevpl-devel)
  $(vopt_if nvenc nv-codec-headers)"
 depends="desktop-file-utils gst-plugins-good1 hicolor-icon-theme"
 short_desc="Multithreaded video transcoder"
@@ -21,15 +24,15 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-2.0-only"
 homepage="https://handbrake.fr/"
 distfiles="https://github.com/HandBrake/HandBrake/releases/download/${version}/HandBrake-${version}-source.tar.bz2"
-checksum=3999fe06d5309c819799a73a968a8ec3840e7840c2b64af8f5cdb7fd8c9430f0
+checksum=94ccfe03db917a91650000c510f7fd53f844da19f19ad4b4be1b8f6bc31a8d4c
 nocross=yes
 
-build_options="fdk_aac nvenc"
+build_options="fdk_aac nvenc qsv"
 
 case "$XBPS_TARGET_MACHINE" in
 	x86_64*|i686*)
 		CFLAGS="-msse"
-		build_options_default="nvenc"
+		build_options_default="nvenc qsv"
 		;;
 esac
 
@@ -37,7 +40,7 @@ pre_configure() {
 	# use system libraries, don't download them
 	rm -rf contrib/
 	for module in fdk-aac ffmpeg libbluray libdav1d libdvdnav libdvdread nvenc \
-		x265 zimg; do
+		x265 zimg svt-av1 libvpl; do
 	    vsed -i "/MODULES += contrib\/${module}/d" make/include/main.defs
 	done
 }

From 0cd7f8afb3be8335009fa2049e823565a02f5c7a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 045/110] hedgewars: revbump for ffmpeg4-4.4.3

---
 srcpkgs/hedgewars/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/hedgewars/template b/srcpkgs/hedgewars/template
index 419f29b98b44..926fe4fe3e68 100644
--- a/srcpkgs/hedgewars/template
+++ b/srcpkgs/hedgewars/template
@@ -1,13 +1,13 @@
 # Template file for 'hedgewars'
 pkgname=hedgewars
 version=1.0.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DNOSERVER=1 -DDATA_INSTALL_DIR=/usr/share/${pkgname}
  -DPHYSFS_SYSTEM=1 -DMINIMAL_FLAGS=1"
 make_cmd=make
 hostmakedepends="lua51 pkg-config qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
+makedepends="ffmpeg4-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
  SDL2_mixer-devel SDL2_net-devel SDL2_ttf-devel"
 depends="libfreeglut"
 short_desc="Funny turn-based artillery game, featuring fighting Hedgehogs!"

From 1cb72aa09e22c605bea0313f3faab6d86e7420ba Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 046/110] idjc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/idjc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/idjc/template b/srcpkgs/idjc/template
index df60318b3db9..36a75baf597c 100644
--- a/srcpkgs/idjc/template
+++ b/srcpkgs/idjc/template
@@ -1,11 +1,11 @@
 # Template file for 'idjc'
 pkgname=idjc
 version=0.9.1
-revision=3
+revision=4
 build_style=gnu-configure
 hostmakedepends="pkg-config git python3 automake gettext-devel libtool"
 makedepends="libvorbis-devel libogg-devel jack-devel libsamplerate-devel
- libflac-devel libsndfile-devel mpg123-devel ffmpeg-devel speex-devel
+ libflac-devel libsndfile-devel mpg123-devel ffmpeg4-devel speex-devel
  glib-devel pixman-devel lame-devel python3-gobject-devel libshout-idjc-devel
  opus-devel twolame-devel python3-mutagen python3-devel"
 depends="python3-gobject python3-mutagen desktop-file-utils shared-mime-info python3-dbus jack"

From 05cb713f07c3a74543c2ec7418617cc7c331c0cc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 047/110] kfilemetadata5: revbump for ffmpeg-6.0

---
 srcpkgs/kfilemetadata5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kfilemetadata5/template b/srcpkgs/kfilemetadata5/template
index 8980121fbc69..f662a2043f93 100644
--- a/srcpkgs/kfilemetadata5/template
+++ b/srcpkgs/kfilemetadata5/template
@@ -1,7 +1,7 @@
 # Template file for 'kfilemetadata5'
 pkgname=kfilemetadata5
 version=5.105.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="kcoreaddons extra-cmake-modules pkg-config qt5-host-tools qt5-qmake
  gettext kcoreaddons python3"

From 09b41f29d8853380499d10349dbfc93e3af3e8a0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 048/110] kid3: revbump for ffmpeg-6.0

---
 srcpkgs/kid3/patches/ffmpeg5.patch | 17 +++++++++++++++++
 srcpkgs/kid3/template              |  2 +-
 2 files changed, 18 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/kid3/patches/ffmpeg5.patch

diff --git a/srcpkgs/kid3/patches/ffmpeg5.patch b/srcpkgs/kid3/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..135fc50e07c9
--- /dev/null
+++ b/srcpkgs/kid3/patches/ffmpeg5.patch
@@ -0,0 +1,17 @@
+# https://aur.archlinux.org/cgit/aur.git/diff/ffmpeg5.patch?h=kid3-cli&id=12410a74906612e7efc0ec8fbce739b4a0fef7e7
+diff --git a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+index e156d424..e12b9abd 100644
+--- a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
++++ b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+@@ -232,7 +232,11 @@ private:
+   friend class Format;
+   friend class Converter;
+   AVCodecContext* m_ptr;
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 0, 0)
+   AVCodec* m_impl;
++#else
++  const AVCodec* m_impl;
++#endif
+   AVFrame* m_frame;
+   bool m_opened;
+ };
diff --git a/srcpkgs/kid3/template b/srcpkgs/kid3/template
index 456206d90e16..f32f9decb0e7 100644
--- a/srcpkgs/kid3/template
+++ b/srcpkgs/kid3/template
@@ -1,7 +1,7 @@
 # Template file for 'kid3'
 pkgname=kid3
 version=3.9.1
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DWITH_APPS='CLI;$(vopt_if KDE KDE Qt)'
  -DWITH_DOCBOOKDIR=/usr/share/xsl/docbook -DWITH_FLAC=$(vopt_if flac ON OFF)

From 3cb6a98588f710b94fe04729f6e2b95852bd8f0a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 049/110] kodi: revbump for ffmpeg4-4.4.3

---
 srcpkgs/kodi/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/kodi/template b/srcpkgs/kodi/template
index 8057964d78a3..6cc1874be7ba 100644
--- a/srcpkgs/kodi/template
+++ b/srcpkgs/kodi/template
@@ -1,7 +1,7 @@
 # Template file for 'kodi'
 pkgname=kodi
 version=19.4
-revision=6
+revision=7
 _codename="Matrix"
 build_style=cmake
 configure_args="-DWITH_FFMPEG=/usr -DENABLE_LDGOLD=OFF
@@ -54,7 +54,7 @@ makedepends="
  libmad-devel fontconfig-devel libXinerama-devel libsamplerate-devel libmms-devel
  enca-devel boost-devel libcurl-devel libva-devel libvdpau-devel libass-devel
  libbluetooth-devel yajl-devel libplist-devel librtmp-devel tinyxml-devel
- taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg-devel
+ taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg4-devel
  giflib-devel libxslt-devel gnutls-devel libssh-devel libmicrohttpd-devel
  libcec-devel dcadec-devel flatbuffers-devel fmt-devel lcms2-devel
  libfstrcmp-devel rapidjson libcdio-paranoia spdlog libwaylandpp-devel

From 916a44b7203c62e94e6a1ee76249271b5085af56 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 050/110] kpipewire: revbump for ffmpeg-6.0

---
 srcpkgs/kpipewire/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kpipewire/template b/srcpkgs/kpipewire/template
index 467ab823a5e1..51827f24db9e 100644
--- a/srcpkgs/kpipewire/template
+++ b/srcpkgs/kpipewire/template
@@ -1,7 +1,7 @@
 # Template file for 'kpipewire'
 pkgname=kpipewire
 version=5.27.4
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules plasma-wayland-protocols gettext
  qt5-qmake qt5-host-tools pkg-config wayland-devel kcoreaddons

From 45e732702da0292eef1bea8c3d169361d10013f6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 051/110] libextractor: revbump for ffmpeg4-4.4.3

---
 srcpkgs/libextractor/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libextractor/template b/srcpkgs/libextractor/template
index ddd4790f93e8..1fb9ca56a96a 100644
--- a/srcpkgs/libextractor/template
+++ b/srcpkgs/libextractor/template
@@ -7,7 +7,7 @@ configure_args="--disable-static"
 hostmakedepends="pkg-config"
 makedepends="zlib-devel bzip2-devel exiv2-devel tiff-devel libpng-devel
  libjpeg-turbo-devel libvorbis-devel libflac-devel giflib-devel libmpeg2-devel
- ffmpeg-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
+ ffmpeg4-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
 short_desc="Library used to extract meta data from files"
 maintainer="Martin Riese <grauehaare@gmx.de>"
 license="GPL-3.0-or-later"

From 156a438afc5a01a65449435df2952c2853813c1f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 052/110] libopenal: revbump for ffmpeg-6.0

---
 srcpkgs/libopenal/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenal/template b/srcpkgs/libopenal/template
index 77218f9e539d..3f49ed75a1fd 100644
--- a/srcpkgs/libopenal/template
+++ b/srcpkgs/libopenal/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenal'
 pkgname=libopenal
 version=1.22.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DALSOFT_EXAMPLES=OFF"
 hostmakedepends="pkg-config"

From 179dd5a54b3f154f718bb51730b0ad81c5048776 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 053/110] libopenshot: revbump for ffmpeg-6.0

---
 srcpkgs/libopenshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenshot/template b/srcpkgs/libopenshot/template
index db831f69b474..81aa0d7136d9 100644
--- a/srcpkgs/libopenshot/template
+++ b/srcpkgs/libopenshot/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenshot'
 pkgname=libopenshot
 version=0.3.0
-revision=1
+revision=2
 build_style=cmake
 # Builds fail with Ruby-2.4.1
 configure_args="-DENABLE_RUBY=OFF -DUSE_SYSTEM_JSONCPP=ON"

From 5c6c1494d4261548b052f3b0bf6e22421280be3a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 054/110] loudgain: revbump for ffmpeg-6.0

---
 srcpkgs/loudgain/patches/ffmpeg5.patch | 11 +++++++++++
 srcpkgs/loudgain/template              |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/loudgain/patches/ffmpeg5.patch

diff --git a/srcpkgs/loudgain/patches/ffmpeg5.patch b/srcpkgs/loudgain/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..16d4510ee98f
--- /dev/null
+++ b/srcpkgs/loudgain/patches/ffmpeg5.patch
@@ -0,0 +1,11 @@
+--- a/src/scan.c	2019-09-06 11:31:19.000000000 -0400
++++ b/src/scan.c	2023-03-23 11:15:40.867968521 -0400
+@@ -69,8 +69,6 @@
+ 	 * It is now useless
+ 	 * https://github.com/FFmpeg/FFmpeg/blob/70d25268c21cbee5f08304da95be1f647c630c15/doc/APIchanges#L86
+ 	 */
+-  if (avformat_version() < AV_VERSION_INT(58,9,100))
+-    av_register_all();
+ 
+ 	av_log_set_callback(scan_av_log);
+ 
diff --git a/srcpkgs/loudgain/template b/srcpkgs/loudgain/template
index da4f2d56e94c..4d6bf29efb4f 100644
--- a/srcpkgs/loudgain/template
+++ b/srcpkgs/loudgain/template
@@ -1,7 +1,7 @@
 # Template file for 'loudgain'
 pkgname=loudgain
 version=0.6.8
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libebur128-devel taglib-devel ffmpeg-devel"

From a494d51205779fa8a5457ffc8a009f5c5b2c7261 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 055/110] mediastreamer: revbump for ffmpeg4-4.4.3

---
 srcpkgs/mediastreamer/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mediastreamer/template b/srcpkgs/mediastreamer/template
index d0e97e858e29..1bde031443a5 100644
--- a/srcpkgs/mediastreamer/template
+++ b/srcpkgs/mediastreamer/template
@@ -1,11 +1,11 @@
 # Template file for 'mediastreamer'
 pkgname=mediastreamer
 version=5.2.6
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_STRICT=0 -DENABLE_UNIT_TESTS=0"
 hostmakedepends="python3"
-makedepends="bzrtp-devel ffmpeg-devel glew-devel libXv-devel libsrtp-devel
+makedepends="bzrtp-devel ffmpeg4-devel glew-devel libXv-devel libsrtp-devel
  libupnp-devel libvpx-devel mbedtls-devel opus-devel ortp-devel pulseaudio-devel
  libtheora-devel speex-devel v4l-utils-devel bcg729-devel bcmatroska2-devel libgsm-devel"
 # zxing-cpp-devel (1.2.0 probably not compatible, check again after updaing xzing)

From ea1f818456bac1f377aa26cfa095927b65f46183 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 056/110] mgba: revbump for ffmpeg-6.0

---
 srcpkgs/mgba/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mgba/template b/srcpkgs/mgba/template
index ae0504311eee..d31295a0cd3d 100644
--- a/srcpkgs/mgba/template
+++ b/srcpkgs/mgba/template
@@ -1,7 +1,7 @@
 # Template file for 'mgba'
 pkgname=mgba
 version=0.10.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake desktop-file-utils"
 makedepends="SDL2-devel ffmpeg-devel libedit-devel libepoxy-devel libmagick-devel

From 79b0075e25daf0be86eb91a2d23431f81b99b707 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 057/110] minidlna: revbump for ffmpeg-6.0

---
 srcpkgs/minidlna/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/minidlna/template b/srcpkgs/minidlna/template
index e8081b1cbc67..9ee9714861fd 100644
--- a/srcpkgs/minidlna/template
+++ b/srcpkgs/minidlna/template
@@ -1,7 +1,7 @@
 # Template file for 'minidlna'
 pkgname=minidlna
 version=1.3.2
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="
  --sbindir=/usr/bin

From c01f7fd094f1da3369954331388193563742187e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 058/110] mixxx: revbump for ffmpeg-6.0

---
 srcpkgs/mixxx/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mixxx/template b/srcpkgs/mixxx/template
index 619ddca0d332..4b9ea00d3fb3 100644
--- a/srcpkgs/mixxx/template
+++ b/srcpkgs/mixxx/template
@@ -1,7 +1,7 @@
 # Template file for 'mixxx'
 pkgname=mixxx
 version=2.3.3
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="extra-cmake-modules pkg-config protobuf qt5-host-tools qt5-devel"

From 3233fa3991eafa6bdee7fa943bae7cb8e8432423 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 059/110] mlt: revbump for ffmpeg4-4.4.3

---
 srcpkgs/mlt/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mlt/template b/srcpkgs/mlt/template
index 8933eb4e7bb9..73353fedafb5 100644
--- a/srcpkgs/mlt/template
+++ b/srcpkgs/mlt/template
@@ -1,14 +1,14 @@
 # Template file for 'mlt'
 pkgname=mlt
 version=6.26.1
-revision=1
+revision=2
 build_style=configure
 configure_args="--prefix=/usr --libdir=/usr/lib$XBPS_TARGET_WORDSIZE
  --enable-gpl --enable-gpl3 --disable-swfdec --without-kde
  --swig-languages=python"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which"
 # XXX: movit vid.stab
-makedepends="alsa-lib-devel ffmpeg-devel gtk+-devel jack-devel ladspa-sdk
+makedepends="alsa-lib-devel ffmpeg4-devel gtk+-devel jack-devel ladspa-sdk
  libexif-devel libsamplerate-devel libxml2-devel sox-devel SDL_image-devel
  fftw-devel frei0r-plugins python3-devel pulseaudio-devel movit-devel
  libvidstab-devel libatomic-devel"

From 872195cb60f49c12f166b9be201205088d8015cd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 060/110] moc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/moc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/moc/template b/srcpkgs/moc/template
index c42be650a1d2..d4f0eefbad52 100644
--- a/srcpkgs/moc/template
+++ b/srcpkgs/moc/template
@@ -1,10 +1,10 @@
 # Template file for 'moc'
 pkgname=moc
 version=2.5.2
-revision=6
+revision=7
 build_style=gnu-configure
 hostmakedepends="pkg-config"
-makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg-devel
+makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg4-devel
  jack-devel alsa-lib-devel libltdl-devel libflac-devel libvorbis-devel
  libmad-devel libmpcdec-devel libmodplug-devel libid3tag-devel faad2-devel
  taglib-devel libsndfile-devel wavpack-devel speex-devel libsamplerate-devel

From 9befcbdbb9437163eac879e5a72780295d63b9e3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 061/110] motion: revbump for ffmpeg-6.0

---
 srcpkgs/motion/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/motion/template b/srcpkgs/motion/template
index 3cf3c3035c5b..7dca12d851e3 100644
--- a/srcpkgs/motion/template
+++ b/srcpkgs/motion/template
@@ -1,7 +1,7 @@
 # Template file for 'motion'
 pkgname=motion
 version=4.5.1
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake pkg-config gettext-devel tar"
 makedepends="ffmpeg-devel libmicrohttpd-devel v4l-utils-devel gettext-devel"

From a2f9fbadbbbb11cbb3c744ef296fb1181752b813 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 062/110] mpv: revbump for ffmpeg-6.0

---
 srcpkgs/mpv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpv/template b/srcpkgs/mpv/template
index e163c496c6eb..d4fefbf5e3c7 100644
--- a/srcpkgs/mpv/template
+++ b/srcpkgs/mpv/template
@@ -1,7 +1,7 @@
 # Template file for 'mpv'
 pkgname=mpv
 version=0.35.1
-revision=2
+revision=3
 build_style=meson
 configure_args="-Dcdda=enabled -Ddvbin=enabled -Ddvdnav=enabled
  -Dlibmpv=true -Dcplugins=enabled

From 8f1f20999f83532f0e26c0236f62173c1bfdb356 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 063/110] musikcube: revbump for ffmpeg-6.0

---
 srcpkgs/musikcube/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/musikcube/template b/srcpkgs/musikcube/template
index 4b7930041126..7cd65cf76b77 100644
--- a/srcpkgs/musikcube/template
+++ b/srcpkgs/musikcube/template
@@ -1,7 +1,7 @@
 # Template file for 'musikcube'
 pkgname=musikcube
 version=0.99.4
-revision=1
+revision=2
 build_style=cmake
 make_cmd=make
 configure_args="-DNO_NCURSESW=1"

From 62eb73128b9ad2415792972cb4ee7d963154b900 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 064/110] notcurses: revbump for ffmpeg-6.0

---
 srcpkgs/notcurses/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/notcurses/template b/srcpkgs/notcurses/template
index 6dd8a091319f..3110c30c9aff 100644
--- a/srcpkgs/notcurses/template
+++ b/srcpkgs/notcurses/template
@@ -1,7 +1,7 @@
 # Template file for 'notcurses'
 pkgname=notcurses
 version=3.0.9
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DUSE_STATIC=ON $(vopt_bool man USE_PANDOC)"
 hostmakedepends="pkg-config $(vopt_if man pandoc)"

From 7acde282bd77d6f56ecd04255eaa05ed64a392fa Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 065/110] obs: revbump for ffmpeg-6.0

---
 srcpkgs/obs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/obs/template b/srcpkgs/obs/template
index 89fd11297c3f..3cf49e414bf3 100644
--- a/srcpkgs/obs/template
+++ b/srcpkgs/obs/template
@@ -1,7 +1,7 @@
 # Template file for 'obs'
 pkgname=obs
 version=29.1.0
-revision=1
+revision=2
 archs="i686* x86_64* ppc64le* aarch64*"
 build_style=cmake
 configure_args="-DOBS_VERSION_OVERRIDE=${version} -DENABLE_JACK=ON

From c770da63d236cbc3d992f4910cb481f263a15fe3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 066/110] olive: revbump for ffmpeg4-4.4.3

---
 srcpkgs/olive/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/olive/template b/srcpkgs/olive/template
index 12a46936c990..5c2917b9c512 100644
--- a/srcpkgs/olive/template
+++ b/srcpkgs/olive/template
@@ -1,10 +1,10 @@
 # Template file for 'olive'
 pkgname=olive
 version=0.1.2
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools pkg-config"
-makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg-devel frei0r-plugins"
+makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg4-devel frei0r-plugins"
 short_desc="Non-linear video editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"

From b67130e6b1f97bdfdb04ebfb2112e3944f53ce72 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 067/110] omxplayer: revbump for ffmpeg4-4.4.3

---
 srcpkgs/omxplayer/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/omxplayer/template b/srcpkgs/omxplayer/template
index e70bf7873d4d..0e9bc70e7c8e 100644
--- a/srcpkgs/omxplayer/template
+++ b/srcpkgs/omxplayer/template
@@ -1,10 +1,10 @@
 # Template file for 'omxplayer'
 pkgname=omxplayer
 version=20190102
-revision=1
+revision=2
 short_desc="Commandline OMX player for the Raspberry Pi"
 maintainer="Orphaned <orphan@voidlinux.org>"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://github.com/popcornmix/omxplayer"
 
 _commit="f06235cc9690a6d58187514452df8cf8fcdaacec"
@@ -15,7 +15,7 @@ checksum=af2d9450f8947842ea8c401fe9f71eec444013ebbdee29f2ac828c9c493c1329
 archs="armv6l* armv7l*"
 build_style=gnu-makefile
 hostmakedepends="curl pkg-config"
-makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg-devel dbus-devel"
+makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg4-devel dbus-devel"
 depends="freefont-ttf"
 
 do_build() {

From ff414c79bff8df0b91f7a06b03279024bd3882b9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 068/110] openimageio: revbump for ffmpeg-6.0

---
 common/shlibs                | 2 ++
 srcpkgs/openimageio/template | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/shlibs b/common/shlibs
index fcc7401be626..5f05896ba1d1 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2262,6 +2262,8 @@ libxmp.so.4 libxmp-4.3.7_1
 libKF5ThreadWeaver.so.5 threadweaver-5.26.0_1
 libOpenImageIO_Util.so.2.4 openimageio-2.4.9.0_1
 libOpenImageIO.so.2.4 openimageio-2.4.9.0_1
+libOpenImageIO_Util.so.2.4 openimageio-2.4.8.1_1
+libOpenImageIO.so.2.4 openimageio-2.4.8.1_1
 libOpenColorIO.so.2.1 opencolorio-2.1.2_1
 libpystring.so.1 pystring-1.1.3_1
 libyaml-cpp.so.0.7 yaml-cpp-0.7.0_1
diff --git a/srcpkgs/openimageio/template b/srcpkgs/openimageio/template
index b661bbf7ba57..9b38ace50f7e 100644
--- a/srcpkgs/openimageio/template
+++ b/srcpkgs/openimageio/template
@@ -1,7 +1,7 @@
 # Template file for 'openimageio'
 pkgname=openimageio
 version=2.4.9.0
-revision=2
+revision=3
 build_style=cmake
 build_helper=qemu
 configure_args="-DUSE_QT=0 -DUSE_PYTHON=0 -DOIIO_BUILD_TESTS=0

From 3e9d7602aa4309b2ef35c23e1c6c25a6a973dac8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 069/110] openmw: revbump for ffmpeg-6.0

---
 srcpkgs/openmw/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openmw/template b/srcpkgs/openmw/template
index 5251a0283dc1..e3771c7aaf1a 100644
--- a/srcpkgs/openmw/template
+++ b/srcpkgs/openmw/template
@@ -1,7 +1,7 @@
 # Template file for 'openmw'
 pkgname=openmw
 version=0.47.0
-revision=4
+revision=5
 build_style=cmake
 _recast_commit=e75adf86f91eb3082220085e42dda62679f9a3ea
 _bullet_tag=3.17

From 7c056ef462a1540048fe17ff39a07ef81b1e03ad Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 070/110] openshot: revbump for ffmpeg-6.0

---
 srcpkgs/openshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openshot/template b/srcpkgs/openshot/template
index 322717d40abc..c074e0338773 100644
--- a/srcpkgs/openshot/template
+++ b/srcpkgs/openshot/template
@@ -1,7 +1,7 @@
 # Template file for 'openshot'
 pkgname=openshot
 version=3.0.0
-revision=1
+revision=2
 build_style=python3-module
 hostmakedepends="python3 python3-setuptools"
 makedepends="ffmpeg-devel python3-PyQt5"

From 87dd339ffef41c2976be1b88c47655bfdf587fd9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 071/110] opentoonz: revbump for ffmpeg-6.0

---
 srcpkgs/opentoonz/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/opentoonz/template b/srcpkgs/opentoonz/template
index ee9f7603f55f..3e81834ca0ed 100644
--- a/srcpkgs/opentoonz/template
+++ b/srcpkgs/opentoonz/template
@@ -1,7 +1,7 @@
 # Template file for 'opentoonz'
 pkgname=opentoonz
 version=1.6.0
-revision=2
+revision=3
 build_wrksrc="toonz/sources"
 build_style=cmake
 make_cmd=make

From 94f318e08d5dab7240b54b297ead562ba5f7321a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 072/110] pianobar: revbump for ffmpeg-6.0

---
 srcpkgs/pianobar/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pianobar/template b/srcpkgs/pianobar/template
index a9b29e91993f..81efcd122c4d 100644
--- a/srcpkgs/pianobar/template
+++ b/srcpkgs/pianobar/template
@@ -1,7 +1,7 @@
 # Template file for 'pianobar'
 pkgname=pianobar
 version=2022.04.01
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="V=1"
 hostmakedepends="pkg-config"

From ae8839ef9612cfa96ded9def765189499a051eb6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 073/110] ppsspp: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ppsspp/template | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/ppsspp/template b/srcpkgs/ppsspp/template
index 7984a733d4be..15a42fd2c993 100644
--- a/srcpkgs/ppsspp/template
+++ b/srcpkgs/ppsspp/template
@@ -1,7 +1,7 @@
 # Template file for 'ppsspp'
 pkgname=ppsspp
 version=1.14.4
-revision=1
+revision=2
 _glslang_commit=dc11adde23c455a24e13dd54de9b4ede8bdd7db8
 _SPIRV_Cross_commit=9acb9ec31f5a8ef80ea6b994bb77be787b08d3d1
 _armips_commit=6719edebaae03330ee5441d9b28280672edf00d5
@@ -13,7 +13,7 @@ configure_args="-DHEADLESS=1 -DUSE_SYSTEM_FFMPEG=1 -DUNITTEST=ON
  -DUSING_QT_UI=$(vopt_if qt ON OFF) -DUSE_SYSTEM_ZSTD=ON
  -DARMIPS_USE_STD_FILESYSTEM=ON"
 hostmakedepends="pkg-config python3 $(vopt_if qt qt5-host-tools)"
-makedepends="zlib-devel glew-devel ffmpeg-devel libzip-devel
+makedepends="zlib-devel glew-devel ffmpeg4-devel libzip-devel
  snappy-devel rapidjson libpng-devel libzstd-devel
  $(vopt_if sdl2 SDL2-devel) $(vopt_if wayland wayland-devel)
  $(vopt_if qt 'qt5-devel qt5-multimedia-devel')"
@@ -62,13 +62,12 @@ post_extract() {
 	mv ${wrksrc}/miniupnp-${_miniupnp_commit} ${wrksrc}/ext/miniupnp
 }
 
-post_patch(){
+post_patch() {
 	# disable git versioning
 	vsed -e 's|find_package(Git)|# &|' -i git-version.cmake
 }
 
 do_install() {
-	vlicense LICENSE.TXT
 	vinstall icons/icon.svg 644 usr/share/pixmaps ppsspp.svg
 	vinstall Qt/PPSSPP.desktop 644 usr/share/applications
 	vbin build/PPSSPPHeadless ppsspp-headless

From 7b8d07be011eadf5c96922ef118097fa99b038ce Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 074/110] pqiv: revbump for ffmpeg-6.0

---
 srcpkgs/pqiv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pqiv/template b/srcpkgs/pqiv/template
index 542fc27a2d32..9308d949b6a1 100644
--- a/srcpkgs/pqiv/template
+++ b/srcpkgs/pqiv/template
@@ -1,7 +1,7 @@
 # Template file for 'pqiv'
 pkgname=pqiv
 version=2.12
-revision=1
+revision=2
 build_style=gnu-makefile
 hostmakedepends="pkg-config"
 makedepends="glib-devel gtk+3-devel $(vopt_if ffmpeg ffmpeg-devel)

From 5593dda726829d77cc471b7e9c7ae7caf33ed373 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 075/110] qmmp: revbump for ffmpeg-6.0

---
 srcpkgs/qmmp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qmmp/template b/srcpkgs/qmmp/template
index 26c661ed16be..a150d7441c7a 100644
--- a/srcpkgs/qmmp/template
+++ b/srcpkgs/qmmp/template
@@ -1,7 +1,7 @@
 # Template file for 'qmmp'
 pkgname=qmmp
 version=1.6.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DUSE_HAL:BOOL=FALSE -DQMMP_DEFAULT_UI:STRING=simple"
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From 234609804864d53a21f61ca2ef3f43cff8d43184 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 076/110] qt5-webengine: update to 5.15.13

---
 .../chromium-media-filters-cpp14.patch        |  11 ++
 srcpkgs/qt5-webengine/patches/ffmpeg5.patch   | 179 ++++++++++++++++++
 srcpkgs/qt5-webengine/template                |  10 +-
 3 files changed, 195 insertions(+), 5 deletions(-)
 create mode 100644 srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/ffmpeg5.patch

diff --git a/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
new file mode 100644
index 000000000000..04adc540f2cb
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
@@ -0,0 +1,11 @@
+--- a/src/3rdparty/chromium/media/filters/BUILD.gn	2023-02-27 13:32:59.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/BUILD.gn	2023-04-02 17:21:39.204066384 -0400
+@@ -96,6 +96,8 @@
+     "//ui/gfx/geometry:geometry",
+   ]
+ 
++  cflags_cc = [ "-std=c++14" ]
++
+   libs = []
+ 
+   if (proprietary_codecs) {
diff --git a/srcpkgs/qt5-webengine/patches/ffmpeg5.patch b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..ac55e1634423
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
@@ -0,0 +1,179 @@
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:57.732547446 -0400
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:09.486478995 -0400
+@@ -57,6 +57,8 @@
+ 
+ namespace {
+ 
++constexpr int64_t kRelativeTsBase = static_cast<int64_t>(0x7ffeffffffffffff);
++
+ void SetAVStreamDiscard(AVStream* stream, AVDiscard discard) {
+   DCHECK(stream);
+   stream->discard = discard;
+@@ -90,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+   if (stream->start_time != kNoFFmpegTimestamp)
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (stream->first_dts != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, stream->first_dts);
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -408,11 +398,11 @@
+   scoped_refptr<DecoderBuffer> buffer;
+ 
+   if (type() == DemuxerStream::TEXT) {
+-    int id_size = 0;
++    size_t id_size = 0;
+     uint8_t* id_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
+ 
+-    int settings_size = 0;
++    size_t settings_size = 0;
+     uint8_t* settings_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
+ 
+@@ -424,7 +414,7 @@
+     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
+                                      side_data.data(), side_data.size());
+   } else {
+-    int side_data_size = 0;
++    size_t side_data_size = 0;
+     uint8_t* side_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
+ 
+@@ -485,7 +475,7 @@
+                                        packet->size - data_offset);
+     }
+ 
+-    int skip_samples_size = 0;
++    size_t skip_samples_size = 0;
+     const uint32_t* skip_samples_ptr =
+         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
+             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
+@@ -1587,6 +1577,8 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++      continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+       lowest_start_time_stream = stream.get();
+@@ -1604,6 +1596,8 @@
+     if (stream && stream->type() == DemuxerStream::VIDEO &&
+         stream->IsEnabled()) {
+       video_stream = stream.get();
++      if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++        continue;
+       if (video_stream->start_time() <= seek_time) {
+         return video_stream;
+       }
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h qtwebengine-5.15.10/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h
+--- a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-07-11 22:12:47.917192788 -0500
+@@ -29,6 +29,7 @@ extern "C" {
+ #include <libavformat/avformat.h>
+ #include <libavformat/avio.h>
+ #include <libavutil/avutil.h>
++#include <libavutil/channel_layout.h>
+ #include <libavutil/imgutils.h>
+ #include <libavutil/log.h>
+ #include <libavutil/mastering_display_metadata.h>
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/audio_file_reader.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/audio_file_reader.cc
+--- a/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -85,7 +85,7 @@ bool AudioFileReader::OpenDemuxer() {
+ }
+ 
+ bool AudioFileReader::OpenDecoder() {
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (codec) {
+     // MP3 decodes to S16P which we don't support, tell it to use S16 instead.
+     if (codec_context_->sample_fmt == AV_SAMPLE_FMT_S16P)
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -329,7 +329,7 @@ bool FFmpegAudioDecoder::ConfigureDecode
+     }
+   }
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec ||
+       avcodec_open2(codec_context_.get(), codec, &codec_options) < 0) {
+     DLOG(ERROR) << "Could not initialize audio decoder: "
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -59,7 +59,6 @@ static int64_t AVIOSeekOperation(void* o
+ }
+ 
+ void FFmpegGlue::InitializeFFmpeg() {
+-  av_register_all();
+ }
+ 
+ static void LogContainer(bool is_local_file,
+@@ -95,9 +94,6 @@ FFmpegGlue::FFmpegGlue(FFmpegURLProtocol
+   // Enable fast, but inaccurate seeks for MP3.
+   format_context_->flags |= AVFMT_FLAG_FAST_SEEK;
+ 
+-  // Ensures we can read out various metadata bits like vp8 alpha.
+-  format_context_->flags |= AVFMT_FLAG_KEEP_SIDE_DATA;
+-
+   // Ensures format parsing errors will bail out. From an audit on 11/2017, all
+   // instances were real failures. Solves bugs like http://crbug.com/710791.
+   format_context_->error_recognition |= AV_EF_EXPLODE;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -391,7 +391,7 @@ bool FFmpegVideoDecoder::ConfigureDecode
+   if (decode_nalus_)
+     codec_context_->flags2 |= AV_CODEC_FLAG2_CHUNKS;
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
+     ReleaseFFmpegResources();
+     return false;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/media_file_checker.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/media_file_checker.cc
+--- a/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -68,7 +68,7 @@ bool MediaFileChecker::Start(base::TimeD
+       auto context = AVStreamToAVCodecContext(format_context->streams[i]);
+       if (!context)
+         continue;
+-      AVCodec* codec = avcodec_find_decoder(cp->codec_id);
++      const AVCodec* codec = avcodec_find_decoder(cp->codec_id);
+       if (codec && avcodec_open2(context.get(), codec, nullptr) >= 0) {
+         auto loop = std::make_unique<FFmpegDecodingLoop>(context.get());
+         stream_contexts[i] = {std::move(context), std::move(loop)};
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc qtwebengine-5.15.10/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc
+--- a/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -203,7 +203,7 @@ int32_t H264DecoderImpl::InitDecode(cons
+   // a pointer |this|.
+   av_context_->opaque = this;
+ 
+-  AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
+   if (!codec) {
+     // This is an indication that FFmpeg has not been initialized or it has not
+     // been compiled/initialized with the correct set of codecs.
diff --git a/srcpkgs/qt5-webengine/template b/srcpkgs/qt5-webengine/template
index 0a71484208bc..095ab67701e4 100644
--- a/srcpkgs/qt5-webengine/template
+++ b/srcpkgs/qt5-webengine/template
@@ -1,9 +1,9 @@
 # Template file for 'qt5-webengine'
 pkgname=qt5-webengine
-version=5.15.11
-revision=2
+version=5.15.13
+revision=1
 _version="${version}-lts"
-_chromium_commit=be349eaf62e77955791d7bf29f893f1e8a37daf4
+_chromium_commit=e48df7803c7c98b0b2471c94057d32e44a301ad5
 archs="x86_64* i686* armv[67]* ppc64* aarch64*"
 create_wrksrc=yes
 build_style=qmake
@@ -32,8 +32,8 @@ license="GPL-3.0-or-later, LGPL-3.0-or-later"
 homepage="https://qt.io/"
 distfiles="https://github.com/qt/qtwebengine/archive/v${_version}.tar.gz
  https://github.com/qt/qtwebengine-chromium/archive/${_chromium_commit}.tar.gz"
-checksum="aa7466356c450c5f5870f979b93cd7e7e62da1165c328ffcab1a9928db18ad67
- 6f47ed8ab8cc062411f6f206da6353bc8263d6ed6d6290c689a05c01d91f646b"
+checksum="4b59838ed75ef788b59e1e412535a0e42dd9d311661fdeadb191b581ba815c63
+ a91686562b1d4e8b220e0bbcbab5feb64630e2de974b35ac034bf388af771a6c"
 
 no_generic_pkgconfig_link=yes
 build_options="sndio pipewire"

From 2dcc253c4a271a2b437c6a82fdbef7d98a8894f4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 077/110] qt5: update to 5.15.8

---
 ...erywhere-opensource-src-5.15.8-kf5-1.patch | 12913 ++++++++++++++++
 srcpkgs/qt5/template                          |    12 +-
 2 files changed, 12919 insertions(+), 6 deletions(-)
 create mode 100644 srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch

diff --git a/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch b/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch
new file mode 100644
index 000000000000..966c98bcd3bb
--- /dev/null
+++ b/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch
@@ -0,0 +1,12913 @@
+Submitted By:            Pierre Labastie <pierre_dot_labastie_at_neuf_dot_fr>
+Date:                    2023-01-05
+Initial Package Version: 5.15.8
+Upstream Status:         Applied (according to KDE)
+Origin:                  KDE patch set
+Description:             Patch set maintained by the KDE folks
+see https://dot.kde.org/2021/04/06/announcing-kdes-qt-5-patch-collection
+Patch generated using the procedure in
+https://wiki.linuxfromscratch.org/blfs/ticket/17476#comment:3
+
+Submodule qtbase 4ee4fc18..9cf586d6:
+diff --git a/qtbase/mkspecs/common/android/qplatformdefs.h b/qtbase/mkspecs/common/android/qplatformdefs.h
+index f75bc4093b..2bd59410d4 100644
+--- a/qtbase/mkspecs/common/android/qplatformdefs.h
++++ b/qtbase/mkspecs/common/android/qplatformdefs.h
+@@ -144,11 +144,7 @@
+ #define QT_SIGNAL_ARGS          int
+ #define QT_SIGNAL_IGNORE        SIG_IGN
+ 
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+ #define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+ 
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+diff --git a/qtbase/mkspecs/features/mac/sdk.mk b/qtbase/mkspecs/features/mac/sdk.mk
+index f30b5830b4..a32ceacb6c 100644
+--- a/qtbase/mkspecs/features/mac/sdk.mk
++++ b/qtbase/mkspecs/features/mac/sdk.mk
+@@ -1,6 +1,6 @@
+ 
+ ifeq ($(QT_MAC_SDK_NO_VERSION_CHECK),)
+-    CHECK_SDK_COMMAND = /usr/bin/xcrun --sdk $(EXPORT_QMAKE_MAC_SDK) -show-sdk-version 2>&1
++    CHECK_SDK_COMMAND = /usr/bin/xcrun --sdk $(EXPORT_QMAKE_MAC_SDK) -show-sdk-version 2>/dev/null
+     CURRENT_MAC_SDK_VERSION := $(shell DEVELOPER_DIR=$(EXPORT_QMAKE_XCODE_DEVELOPER_PATH) $(CHECK_SDK_COMMAND))
+     ifneq ($(CURRENT_MAC_SDK_VERSION),$(EXPORT_QMAKE_MAC_SDK_VERSION))
+         # We don't want to complain about out of date SDK unless the target needs to be remade.
+diff --git a/qtbase/mkspecs/linux-clang/qplatformdefs.h b/qtbase/mkspecs/linux-clang/qplatformdefs.h
+index a818d973f0..c1ab72fbc6 100644
+--- a/qtbase/mkspecs/linux-clang/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-clang/qplatformdefs.h
+@@ -79,14 +79,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-g++/qplatformdefs.h b/qtbase/mkspecs/linux-g++/qplatformdefs.h
+index 13523f0702..4d2750d9ec 100644
+--- a/qtbase/mkspecs/linux-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-g++/qplatformdefs.h
+@@ -79,14 +79,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ < 2)
+-#define QT_SOCKLEN_T            int
+-#else
+-#define QT_SOCKLEN_T            socklen_t
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-llvm/qplatformdefs.h b/qtbase/mkspecs/linux-llvm/qplatformdefs.h
+index dc750ab1ef..d3cc39b47f 100644
+--- a/qtbase/mkspecs/linux-llvm/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-llvm/qplatformdefs.h
+@@ -80,14 +80,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h b/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
+index 4c4e53da2a..83baffb3e3 100644
+--- a/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
+@@ -85,16 +85,9 @@
+ #include "../common/posix/qplatformdefs.h"
+ 
+ #undef QT_OPEN_LARGEFILE
+-#undef QT_SOCKLEN_T
+ 
+ #define QT_OPEN_LARGEFILE       0
+ 
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #ifndef SIOCGIFBRDADDR
+ #  define SIOCGIFBRDADDR 0x8919
+ #endif
+diff --git a/qtbase/mkspecs/lynxos-g++/qplatformdefs.h b/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
+index 4339ea2b23..6007af0055 100644
+--- a/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
+@@ -72,14 +72,6 @@
+ 
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp b/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
+index c3c184258f..32af3f8f29 100644
+--- a/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
++++ b/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
+@@ -10,6 +10,7 @@
+ #include "libANGLE/HandleAllocator.h"
+ 
+ #include <algorithm>
++#include <limits>
+ 
+ #include "common/debug.h"
+ 
+diff --git a/qtbase/src/3rdparty/forkfd/forkfd_linux.c b/qtbase/src/3rdparty/forkfd/forkfd_linux.c
+index ffe0e9a5e2..b1f5408d11 100644
+--- a/qtbase/src/3rdparty/forkfd/forkfd_linux.c
++++ b/qtbase/src/3rdparty/forkfd/forkfd_linux.c
+@@ -82,7 +82,8 @@ static int sys_clone(unsigned long cloneflags, int *ptid)
+     return syscall(__NR_clone, cloneflags, child_stack, stack_size, ptid, newtls, ctid);
+ #elif defined(__arc__) || defined(__arm__) || defined(__aarch64__) || defined(__mips__) || \
+     defined(__nds32__) || defined(__hppa__) || defined(__powerpc__) || defined(__i386__) || \
+-    defined(__x86_64__) || defined(__xtensa__) || defined(__alpha__) || defined(__riscv)
++    defined(__x86_64__) || defined(__xtensa__) || defined(__alpha__) || defined(__riscv) || \
++    defined(__loongarch__)
+     /* ctid and newtls are inverted on CONFIG_CLONE_BACKWARDS architectures,
+      * but since both values are 0, there's no harm. */
+     return syscall(__NR_clone, cloneflags, child_stack, ptid, ctid, newtls);
+diff --git a/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java b/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
+index 5792b5b2f5..2f74750fcf 100644
+--- a/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
++++ b/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
+@@ -116,6 +116,7 @@ public class QtNative
+     public static QtThread m_qtThread = new QtThread();
+     private static HashMap<String, Uri> m_cachedUris = new HashMap<String, Uri>();
+     private static ArrayList<String> m_knownDirs = new ArrayList<String>();
++    private static final String NoPermissionErrorMessage = "No permissions to open Uri";
+ 
+     private static final Runnable runPendingCppRunnablesRunnable = new Runnable() {
+         @Override
+@@ -193,11 +194,10 @@ public class QtNative
+                     return iterUri;
+             }
+ 
+-            // Android 6 and earlier could still manage to open the file so we can return the
+-            // parsed uri here
+-            if (Build.VERSION.SDK_INT < 24)
+-                return parsedUri;
+-            return null;
++            // if we only have transient permissions on uri all the above will fail,
++            // but we will be able to read the file anyway, so continue with uri here anyway
++            // and check for SecurityExceptions later
++            return parsedUri;
+         } catch (SecurityException e) {
+             e.printStackTrace();
+             return null;
+@@ -244,7 +244,7 @@ public class QtNative
+         int error = -1;
+ 
+         if (uri == null) {
+-            Log.e(QtTAG, "openFdForContentUrl(): No permissions to open Uri");
++            Log.e(QtTAG, "openFdForContentUrl(): " + NoPermissionErrorMessage);
+             return error;
+         }
+ 
+@@ -254,12 +254,13 @@ public class QtNative
+             return fdDesc.detachFd();
+         } catch (FileNotFoundException e) {
+             e.printStackTrace();
+-            return error;
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "openFdForContentUrl(): Invalid Uri");
+             e.printStackTrace();
+-            return error;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return error;
+     }
+ 
+     public static long getSize(Context context, String contentUrl)
+@@ -270,7 +271,7 @@ public class QtNative
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+ 
+         if (uri == null) {
+-            Log.e(QtTAG, "getSize(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return size;
+         } else if (!m_cachedUris.containsKey(contentUrl)) {
+             m_cachedUris.put(contentUrl, uri);
+@@ -288,12 +289,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "getSize(): Invalid Uri");
+             e.printStackTrace();
+-            return size;
+         }  catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "getSize(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return size;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return size;
+     }
+ 
+     public static boolean checkFileExists(Context context, String contentUrl)
+@@ -303,7 +305,7 @@ public class QtNative
+         if (uri == null)
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+         if (uri == null) {
+-            Log.e(QtTAG, "checkFileExists(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return exists;
+         } else {
+             if (!m_cachedUris.containsKey(contentUrl))
+@@ -321,12 +323,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "checkFileExists(): Invalid Uri");
+             e.printStackTrace();
+-            return exists;
+         } catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "checkFileExists(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return false;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return exists;
+     }
+ 
+     public static boolean checkIfWritable(Context context, String contentUrl)
+@@ -344,7 +347,7 @@ public class QtNative
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+         }
+         if (uri == null) {
+-            Log.e(QtTAG, "isDir(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return isDir;
+         } else {
+             if (!m_cachedUris.containsKey(contentUrl))
+@@ -374,12 +377,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "checkIfDir(): Invalid Uri");
+             e.printStackTrace();
+-            return false;
+         } catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "checkIfDir(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return false;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return false;
+     }
+     public static String[] listContentsFromTreeUri(Context context, String contentUrl)
+     {
+diff --git a/qtbase/src/concurrent/qtconcurrentreducekernel.h b/qtbase/src/concurrent/qtconcurrentreducekernel.h
+index 8f9a938952..a98dedef2e 100644
+--- a/qtbase/src/concurrent/qtconcurrentreducekernel.h
++++ b/qtbase/src/concurrent/qtconcurrentreducekernel.h
+@@ -212,11 +212,13 @@ public:
+ 
+     inline bool shouldThrottle()
+     {
++        std::lock_guard<QMutex> locker(mutex);
+         return (resultsMapSize > (ReduceQueueThrottleLimit * threadCount));
+     }
+ 
+     inline bool shouldStartThread()
+     {
++        std::lock_guard<QMutex> locker(mutex);
+         return (resultsMapSize <= (ReduceQueueStartLimit * threadCount));
+     }
+ };
+diff --git a/qtbase/src/concurrent/qtconcurrentthreadengine.cpp b/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
+index ea6ce3ac42..7f91a2ba68 100644
+--- a/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
++++ b/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
+@@ -176,6 +176,39 @@ void ThreadEngineBase::startSingleThreaded()
+     finish();
+ }
+ 
++void ThreadEngineBase::startBlocking()
++{
++    start();
++    barrier.acquire();
++    startThreads();
++
++    bool throttled = false;
++#ifndef QT_NO_EXCEPTIONS
++    try {
++#endif
++        while (threadFunction() == ThrottleThread) {
++            if (threadThrottleExit()) {
++                throttled = true;
++                break;
++            }
++        }
++#ifndef QT_NO_EXCEPTIONS
++    } catch (QException &e) {
++        handleException(e);
++    } catch (...) {
++        handleException(QUnhandledException());
++    }
++#endif
++
++    if (throttled == false) {
++        barrier.release();
++    }
++
++    barrier.wait();
++    finish();
++    exceptionStore.throwPossibleException();
++}
++
+ void ThreadEngineBase::startThread()
+ {
+     startThreadInternal();
+diff --git a/qtbase/src/concurrent/qtconcurrentthreadengine.h b/qtbase/src/concurrent/qtconcurrentthreadengine.h
+index 7c30cebdbc..a4c8548cc4 100644
+--- a/qtbase/src/concurrent/qtconcurrentthreadengine.h
++++ b/qtbase/src/concurrent/qtconcurrentthreadengine.h
+@@ -91,6 +91,7 @@ public:
+     ThreadEngineBase();
+     virtual ~ThreadEngineBase();
+     void startSingleThreaded();
++    void startBlocking();
+     void startThread();
+     bool isCanceled();
+     void waitForResume();
+@@ -143,6 +144,15 @@ public:
+         return result();
+     }
+ 
++    // Runs the user algorithm using multiple threads.
++    // This function blocks until the algorithm is finished,
++    // and then returns the result.
++    T *startBlocking()
++    {
++        ThreadEngineBase::startBlocking();
++        return result();
++    }
++
+     // Runs the user algorithm using multiple threads.
+     // Does not block, returns a future.
+     QFuture<T> startAsynchronously()
+@@ -223,6 +233,13 @@ class ThreadEngineStarter : public ThreadEngineStarterBase<T>
+ public:
+     ThreadEngineStarter(TypedThreadEngine *eng)
+         : Base(eng) { }
++
++    T startBlocking()
++    {
++        T t = *this->threadEngine->startBlocking();
++        delete this->threadEngine;
++        return t;
++    }
+ };
+ 
+ // Full template specialization where T is void.
+@@ -232,6 +249,12 @@ class ThreadEngineStarter<void> : public ThreadEngineStarterBase<void>
+ public:
+     ThreadEngineStarter(ThreadEngine<void> *_threadEngine)
+         : ThreadEngineStarterBase<void>(_threadEngine) {}
++
++    void startBlocking()
++    {
++        this->threadEngine->startBlocking();
++        delete this->threadEngine;
++    }
+ };
+ 
+ //! [qtconcurrentthreadengine-1]
+diff --git a/qtbase/src/corelib/animation/qvariantanimation.cpp b/qtbase/src/corelib/animation/qvariantanimation.cpp
+index 98b02f0202..eac1524107 100644
+--- a/qtbase/src/corelib/animation/qvariantanimation.cpp
++++ b/qtbase/src/corelib/animation/qvariantanimation.cpp
+@@ -276,7 +276,9 @@ void QVariantAnimationPrivate::setCurrentValueForProgress(const qreal progress)
+ 
+     const qreal startProgress = currentInterval.start.first;
+     const qreal endProgress = currentInterval.end.first;
+-    const qreal localProgress = (progress - startProgress) / (endProgress - startProgress);
++    const qreal localProgress =
++            qIsNull(progress - startProgress) ? 0.0 // avoid 0/0 below
++            /* else */                        : (progress - startProgress) / (endProgress - startProgress);
+ 
+     QVariant ret = q->interpolated(currentInterval.start.second,
+                                    currentInterval.end.second,
+diff --git a/qtbase/src/corelib/global/qnamespace.h b/qtbase/src/corelib/global/qnamespace.h
+index ad4150b317..bf19b1627b 100644
+--- a/qtbase/src/corelib/global/qnamespace.h
++++ b/qtbase/src/corelib/global/qnamespace.h
+@@ -1864,7 +1864,7 @@ public:
+     QT_Q_ENUM(TimerType)
+     QT_Q_ENUM(ScrollPhase)
+     QT_Q_ENUM(MouseEventSource)
+-    QT_Q_FLAG(MouseEventFlag)
++    QT_Q_FLAG(MouseEventFlags)
+     QT_Q_ENUM(ChecksumType)
+     QT_Q_ENUM(HighDpiScaleFactorRoundingPolicy)
+     QT_Q_ENUM(TabFocusBehavior)
+diff --git a/qtbase/src/corelib/global/qrandom.cpp b/qtbase/src/corelib/global/qrandom.cpp
+index 10672c1f92..25f87c7e6a 100644
+--- a/qtbase/src/corelib/global/qrandom.cpp
++++ b/qtbase/src/corelib/global/qrandom.cpp
+@@ -383,7 +383,6 @@ struct QRandomGenerator::SystemAndGlobalGenerators
+ 
+         constexpr SystemAndGlobalGenerators g = {};
+         Q_UNUSED(g);
+-        Q_STATIC_ASSERT(std::is_literal_type<SystemAndGlobalGenerators>::value);
+ #endif
+     }
+ 
+diff --git a/qtbase/src/corelib/io/qbuffer.cpp b/qtbase/src/corelib/io/qbuffer.cpp
+index 595fcd2724..032c0ddd4b 100644
+--- a/qtbase/src/corelib/io/qbuffer.cpp
++++ b/qtbase/src/corelib/io/qbuffer.cpp
+@@ -41,6 +41,8 @@
+ #include <QtCore/qmetaobject.h>
+ #include "private/qiodevice_p.h"
+ 
++#include <limits>
++
+ QT_BEGIN_NAMESPACE
+ 
+ /** QBufferPrivate **/
+@@ -366,7 +368,9 @@ qint64 QBuffer::size() const
+ bool QBuffer::seek(qint64 pos)
+ {
+     Q_D(QBuffer);
+-    if (pos > d->buf->size() && isWritable()) {
++    const auto oldBufSize = d->buf->size();
++    constexpr qint64 MaxSeekPos = (std::numeric_limits<decltype(oldBufSize)>::max)();
++    if (pos <= MaxSeekPos && pos > oldBufSize && isWritable()) {
+         if (seek(d->buf->size())) {
+             const qint64 gapSize = pos - d->buf->size();
+             if (write(QByteArray(gapSize, 0)) != gapSize) {
+@@ -377,7 +381,7 @@ bool QBuffer::seek(qint64 pos)
+             return false;
+         }
+     } else if (pos > d->buf->size() || pos < 0) {
+-        qWarning("QBuffer::seek: Invalid pos: %d", int(pos));
++        qWarning("QBuffer::seek: Invalid pos: %lld", pos);
+         return false;
+     }
+     return QIODevice::seek(pos);
+diff --git a/qtbase/src/corelib/io/qfilesystemengine_win.cpp b/qtbase/src/corelib/io/qfilesystemengine_win.cpp
+index 81d3a71986..c86ed1f9b0 100644
+--- a/qtbase/src/corelib/io/qfilesystemengine_win.cpp
++++ b/qtbase/src/corelib/io/qfilesystemengine_win.cpp
+@@ -664,14 +664,14 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry)
+     return QFileSystemEntry(ret, QFileSystemEntry::FromInternalPath());
+ }
+ 
+-#if defined(Q_CC_MINGW) && WINVER < 0x0602 //  Windows 8 onwards
++#if defined(Q_CC_MINGW) && WINVER < 0x0602 && _WIN32_WINNT < _WIN32_WINNT_WIN8 //  Windows 8 onwards
+ 
+ typedef struct _FILE_ID_INFO {
+     ULONGLONG VolumeSerialNumber;
+     FILE_ID_128 FileId;
+ } FILE_ID_INFO, *PFILE_ID_INFO;
+ 
+-#endif // if defined (Q_CC_MINGW) && WINVER < 0x0602
++#endif // if defined(Q_CC_MINGW) && WINVER < 0x0602 && _WIN32_WINNT < _WIN32_WINNT_WIN8
+ 
+ // File ID for Windows up to version 7 and FAT32 drives
+ static inline QByteArray fileId(HANDLE handle)
+diff --git a/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp b/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
+index 94d9d06bcb..27e0b13b0b 100644
+--- a/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
++++ b/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
+@@ -366,7 +366,9 @@ void QInotifyFileSystemWatcherEngine::readFromInotify()
+     // qDebug("QInotifyFileSystemWatcherEngine::readFromInotify");
+ 
+     int buffSize = 0;
+-    ioctl(inotifyFd, FIONREAD, (char *) &buffSize);
++    if (ioctl(inotifyFd, FIONREAD, (char *) &buffSize) == -1 || buffSize == 0)
++        return;
++
+     QVarLengthArray<char, 4096> buffer(buffSize);
+     buffSize = read(inotifyFd, buffer.data(), buffSize);
+     char *at = buffer.data();
+diff --git a/qtbase/src/corelib/io/qlockfile_win.cpp b/qtbase/src/corelib/io/qlockfile_win.cpp
+index 277f8d4230..38ecef5550 100644
+--- a/qtbase/src/corelib/io/qlockfile_win.cpp
++++ b/qtbase/src/corelib/io/qlockfile_win.cpp
+@@ -48,6 +48,8 @@
+ #include "QtCore/qdebug.h"
+ #include "QtCore/qthread.h"
+ 
++#include "private/qsystemlibrary_p.h"
++
+ QT_BEGIN_NAMESPACE
+ 
+ static inline bool fileExists(const wchar_t *fileName)
+@@ -150,7 +152,7 @@ QString QLockFilePrivate::processNameByPid(qint64 pid)
+ #if !defined(Q_OS_WINRT)
+     typedef DWORD (WINAPI *GetModuleFileNameExFunc)(HANDLE, HMODULE, LPTSTR, DWORD);
+ 
+-    HMODULE hPsapi = LoadLibraryA("psapi");
++    HMODULE hPsapi = QSystemLibrary::load(L"psapi");
+     if (!hPsapi)
+         return QString();
+     GetModuleFileNameExFunc qGetModuleFileNameEx = reinterpret_cast<GetModuleFileNameExFunc>(
+diff --git a/qtbase/src/corelib/io/qprocess_unix.cpp b/qtbase/src/corelib/io/qprocess_unix.cpp
+index 50390e57f5..15c8f30745 100644
+--- a/qtbase/src/corelib/io/qprocess_unix.cpp
++++ b/qtbase/src/corelib/io/qprocess_unix.cpp
+@@ -1,7 +1,7 @@
+ /****************************************************************************
+ **
+ ** Copyright (C) 2016 The Qt Company Ltd.
+-** Copyright (C) 2016 Intel Corporation.
++** Copyright (C) 2022 Intel Corporation.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtCore module of the Qt Toolkit.
+@@ -422,14 +422,15 @@ void QProcessPrivate::startProcess()
+     // Add the program name to the argument list.
+     argv[0] = nullptr;
+     if (!program.contains(QLatin1Char('/'))) {
++        // findExecutable() returns its argument if it's an absolute path,
++        // otherwise it searches $PATH; returns empty if not found (we handle
++        // that case much later)
+         const QString &exeFilePath = QStandardPaths::findExecutable(program);
+-        if (!exeFilePath.isEmpty()) {
+-            const QByteArray &tmp = QFile::encodeName(exeFilePath);
+-            argv[0] = ::strdup(tmp.constData());
+-        }
+-    }
+-    if (!argv[0])
++        const QByteArray &tmp = QFile::encodeName(exeFilePath);
++        argv[0] = ::strdup(tmp.constData());
++    } else {
+         argv[0] = ::strdup(encodedProgramName.constData());
++    }
+ 
+     // Add every argument to the list
+     for (int i = 0; i < arguments.count(); ++i)
+@@ -983,15 +984,16 @@ bool QProcessPrivate::startDetached(qint64 *pid)
+                 envp = _q_dupEnvironment(environment.d.constData()->vars, &envc);
+             }
+ 
+-            QByteArray tmp;
+             if (!program.contains(QLatin1Char('/'))) {
++                // findExecutable() returns its argument if it's an absolute path,
++                // otherwise it searches $PATH; returns empty if not found (we handle
++                // that case much later)
+                 const QString &exeFilePath = QStandardPaths::findExecutable(program);
+-                if (!exeFilePath.isEmpty())
+-                    tmp = QFile::encodeName(exeFilePath);
++                const QByteArray &tmp = QFile::encodeName(exeFilePath);
++                argv[0] = ::strdup(tmp.constData());
++            } else {
++                argv[0] = ::strdup(QFile::encodeName(program));
+             }
+-            if (tmp.isEmpty())
+-                tmp = QFile::encodeName(program);
+-            argv[0] = tmp.data();
+ 
+             if (envp)
+                 qt_safe_execve(argv[0], argv, envp);
+diff --git a/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp b/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
+index 3a79c502af..997a634e76 100644
+--- a/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
++++ b/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
+@@ -3196,9 +3196,8 @@ bool QAbstractItemModel::beginMoveColumns(const QModelIndex &sourceParent, int s
+     destinationChange.needsAdjust = destinationParent.isValid() && destinationParent.row() >= sourceLast && destinationParent.parent() == sourceParent;
+     d->changes.push(destinationChange);
+ 
+-    d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Horizontal);
+-
+     emit columnsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, QPrivateSignal());
++    d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Horizontal);
+     return true;
+ }
+ 
+@@ -3231,7 +3230,6 @@ void QAbstractItemModel::endMoveColumns()
+       adjustedSource = createIndex(adjustedSource.row(), adjustedSource.column() + numMoved, adjustedSource.internalPointer());
+ 
+     d->itemsMoved(adjustedSource, removeChange.first, removeChange.last, adjustedDestination, insertChange.first, Qt::Horizontal);
+-
+     emit columnsMoved(adjustedSource, removeChange.first, removeChange.last, adjustedDestination, insertChange.first, QPrivateSignal());
+ }
+ 
+diff --git a/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+index dc6379d9fb..c5e287ee84 100644
+--- a/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
++++ b/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+@@ -939,8 +939,9 @@ void QSortFilterProxyModelPrivate::insert_source_items(
+                 q->beginInsertColumns(proxy_parent, proxy_start, proxy_end);
+         }
+ 
+-        for (int i = 0; i < source_items.size(); ++i)
+-            proxy_to_source.insert(proxy_start + i, source_items.at(i));
++        // TODO: use the range QList::insert() overload once it is implemented (QTBUG-58633).
++        proxy_to_source.insert(proxy_start, source_items.size(), 0);
++        std::copy(source_items.cbegin(), source_items.cend(), proxy_to_source.begin() + proxy_start);
+ 
+         build_source_to_proxy_mapping(proxy_to_source, source_to_proxy);
+ 
+@@ -3123,8 +3124,9 @@ bool QSortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex &
+ 
+     if (d->filter_data.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();
+@@ -3133,9 +3135,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.hasMatch(key);
+ }
+diff --git a/qtbase/src/corelib/kernel/qcoreapplication.cpp b/qtbase/src/corelib/kernel/qcoreapplication.cpp
+index ca2864df83..132b2eae52 100644
+--- a/qtbase/src/corelib/kernel/qcoreapplication.cpp
++++ b/qtbase/src/corelib/kernel/qcoreapplication.cpp
+@@ -1157,7 +1157,7 @@ static bool doNotify(QObject *receiver, QEvent *event)
+ bool QCoreApplicationPrivate::sendThroughApplicationEventFilters(QObject *receiver, QEvent *event)
+ {
+     // We can't access the application event filters outside of the main thread (race conditions)
+-    Q_ASSERT(receiver->d_func()->threadData.loadRelaxed()->thread.loadAcquire() == mainThread());
++    Q_ASSERT(receiver->d_func()->threadData.loadAcquire()->thread.loadRelaxed() == mainThread());
+ 
+     if (extraData) {
+         // application event filters are only called for objects in the GUI thread
+diff --git a/qtbase/src/corelib/kernel/qobject.cpp b/qtbase/src/corelib/kernel/qobject.cpp
+index 1eb79138d9..36cd780ee1 100644
+--- a/qtbase/src/corelib/kernel/qobject.cpp
++++ b/qtbase/src/corelib/kernel/qobject.cpp
+@@ -1010,7 +1010,7 @@ QObject::~QObject()
+         emit destroyed(this);
+     }
+ 
+-    if (d->declarativeData) {
++    if (!d->isDeletingChildren && d->declarativeData) {
+         if (static_cast<QAbstractDeclarativeDataImpl*>(d->declarativeData)->ownedByQml1) {
+             if (QAbstractDeclarativeData::destroyed_qml1)
+                 QAbstractDeclarativeData::destroyed_qml1(d->declarativeData, this);
+@@ -1580,7 +1580,7 @@ void QObject::moveToThread(QThread *targetThread)
+ 
+     QThreadData *currentData = QThreadData::current();
+     QThreadData *targetData = targetThread ? QThreadData::get2(targetThread) : nullptr;
+-    QThreadData *thisThreadData = d->threadData.loadRelaxed();
++    QThreadData *thisThreadData = d->threadData.loadAcquire();
+     if (!thisThreadData->thread.loadAcquire() && currentData == targetData) {
+         // one exception to the rule: we allow moving objects with no thread affinity to the current thread
+         currentData = d->threadData;
+@@ -2620,7 +2620,7 @@ int QObject::receivers(const char *signal) const
+         if (!d->isSignalConnected(signal_index))
+             return receivers;
+ 
+-        if (d->declarativeData && QAbstractDeclarativeData::receivers) {
++        if (!d->isDeletingChildren && d->declarativeData && QAbstractDeclarativeData::receivers) {
+             receivers += QAbstractDeclarativeData::receivers(d->declarativeData, this,
+                                                              signal_index);
+         }
+diff --git a/qtbase/src/corelib/kernel/qobject_p.h b/qtbase/src/corelib/kernel/qobject_p.h
+index 0b827a52ca..13ffb88999 100644
+--- a/qtbase/src/corelib/kernel/qobject_p.h
++++ b/qtbase/src/corelib/kernel/qobject_p.h
+@@ -444,7 +444,7 @@ inline void QObjectPrivate::checkForIncompatibleLibraryVersion(int version) cons
+ 
+ inline bool QObjectPrivate::isDeclarativeSignalConnected(uint signal_index) const
+ {
+-    return declarativeData && QAbstractDeclarativeData::isSignalConnected
++    return !isDeletingChildren && declarativeData && QAbstractDeclarativeData::isSignalConnected
+             && QAbstractDeclarativeData::isSignalConnected(declarativeData, q_func(), signal_index);
+ }
+ 
+diff --git a/qtbase/src/corelib/kernel/qtranslator.cpp b/qtbase/src/corelib/kernel/qtranslator.cpp
+index 2812ffb7ea..bc0177c5ec 100644
+--- a/qtbase/src/corelib/kernel/qtranslator.cpp
++++ b/qtbase/src/corelib/kernel/qtranslator.cpp
+@@ -902,7 +902,7 @@ static QString getMessage(const uchar *m, const uchar *end, const char *context,
+             goto end;
+         case Tag_Translation: {
+             int len = read32(m);
+-            if (len % 1)
++            if (len & 1)
+                 return QString();
+             m += 4;
+             if (!numerus--) {
+diff --git a/qtbase/src/corelib/mimetypes/qmimedatabase.cpp b/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
+index 9de22cef33..ff868a3268 100644
+--- a/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
+@@ -389,20 +389,23 @@ QMimeType QMimeDatabasePrivate::mimeTypeForFileNameAndData(const QString &fileNa
+         // Disambiguate conflicting extensions (if magic matching found something)
+         if (candidateByData.isValid() && magicAccuracy > 0) {
+             const QString sniffedMime = candidateByData.name();
+-            // If the sniffedMime matches a glob match, use it
++            // If the sniffedMime matches a highest-weight glob match, use it
+             if (candidatesByName.m_matchingMimeTypes.contains(sniffedMime)) {
+                 *accuracyPtr = 100;
+                 return candidateByData;
+             }
+-            for (const QString &m : qAsConst(candidatesByName.m_matchingMimeTypes)) {
++            for (const QString &m : qAsConst(candidatesByName.m_allMatchingMimeTypes)) {
+                 if (inherits(m, sniffedMime)) {
+                     // We have magic + pattern pointing to this, so it's a pretty good match
+                     *accuracyPtr = 100;
+                     return mimeTypeForName(m);
+                 }
+             }
+-            *accuracyPtr = magicAccuracy;
+-            return candidateByData;
++            if (candidatesByName.m_allMatchingMimeTypes.isEmpty()) {
++                // No glob, use magic
++                *accuracyPtr = magicAccuracy;
++                return candidateByData;
++            }
+         }
+     }
+ 
+diff --git a/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp b/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
+index a81112d227..fa8f4c545d 100644
+--- a/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
+@@ -83,7 +83,10 @@ void QMimeGlobMatchResult::addMatch(const QString &mimeType, int weight, const Q
+     }
+     if (!m_matchingMimeTypes.contains(mimeType)) {
+         m_matchingMimeTypes.append(mimeType);
+-        m_allMatchingMimeTypes.append(mimeType);
++        if (replace)
++            m_allMatchingMimeTypes.prepend(mimeType); // highest-weight first
++        else
++            m_allMatchingMimeTypes.append(mimeType);
+         m_knownSuffixLength = knownSuffixLength;
+     }
+ }
+@@ -94,7 +97,7 @@ QMimeGlobPattern::PatternType QMimeGlobPattern::detectPatternType(const QString
+     if (!patternLength)
+         return OtherPattern;
+ 
+-    const bool starCount = pattern.count(QLatin1Char('*')) == 1;
++    const int starCount = pattern.count(QLatin1Char('*'));
+     const bool hasSquareBracket = pattern.indexOf(QLatin1Char('[')) != -1;
+     const bool hasQuestionMark = pattern.indexOf(QLatin1Char('?')) != -1;
+ 
+@@ -106,10 +109,10 @@ QMimeGlobPattern::PatternType QMimeGlobPattern::detectPatternType(const QString
+             // Patterns like "README*" (well this is currently the only one like that...)
+             if (pattern.at(patternLength - 1) == QLatin1Char('*'))
+                 return PrefixPattern;
+-        }
+-        // Names without any wildcards like "README"
+-        if (starCount == 0)
++        } else if (starCount == 0) {
++            // Names without any wildcards like "README"
+             return LiteralPattern;
++        }
+     }
+ 
+     if (pattern == QLatin1String("[0-9][0-9][0-9].vdr"))
+diff --git a/qtbase/src/corelib/mimetypes/qmimeprovider.cpp b/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
+index 258dddf8cb..4642d0f2d0 100644
+--- a/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
+@@ -244,15 +244,18 @@ void QMimeBinaryProvider::addFileNameMatches(const QString &fileName, QMimeGlobM
+     const QString lowerFileName = fileName.toLower();
+     // Check literals (e.g. "Makefile")
+     matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosLiteralListOffset), fileName);
+-    // Check complex globs (e.g. "callgrind.out[0-9]*")
+-    matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosGlobListOffset), fileName);
+     // Check the very common *.txt cases with the suffix tree
+-    const int reverseSuffixTreeOffset = m_cacheFile->getUint32(PosReverseSuffixTreeOffset);
+-    const int numRoots = m_cacheFile->getUint32(reverseSuffixTreeOffset);
+-    const int firstRootOffset = m_cacheFile->getUint32(reverseSuffixTreeOffset + 4);
+-    matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, lowerFileName, lowerFileName.length() - 1, false);
++    if (result.m_matchingMimeTypes.isEmpty()) {
++        const int reverseSuffixTreeOffset = m_cacheFile->getUint32(PosReverseSuffixTreeOffset);
++        const int numRoots = m_cacheFile->getUint32(reverseSuffixTreeOffset);
++        const int firstRootOffset = m_cacheFile->getUint32(reverseSuffixTreeOffset + 4);
++        matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, lowerFileName, lowerFileName.length() - 1, false);
++        if (result.m_matchingMimeTypes.isEmpty())
++            matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, fileName, fileName.length() - 1, true);
++    }
++    // Check complex globs (e.g. "callgrind.out[0-9]*" or "README*")
+     if (result.m_matchingMimeTypes.isEmpty())
+-        matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, fileName, fileName.length() - 1, true);
++        matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosGlobListOffset), fileName);
+ }
+ 
+ void QMimeBinaryProvider::matchGlobList(QMimeGlobMatchResult &result, CacheFile *cacheFile, int off, const QString &fileName)
+diff --git a/qtbase/src/corelib/serialization/qjsonparser.cpp b/qtbase/src/corelib/serialization/qjsonparser.cpp
+index 17e6f111ab..2e40b6c8fb 100644
+--- a/qtbase/src/corelib/serialization/qjsonparser.cpp
++++ b/qtbase/src/corelib/serialization/qjsonparser.cpp
+@@ -379,10 +379,30 @@ error:
+     return QCborValue();
+ }
+ 
++// We need to retain the _last_ value for any duplicate keys and we need to deref containers.
++// Therefore the manual implementation of std::unique().
++template<typename Iterator, typename Compare, typename Assign>
++static Iterator customAssigningUniqueLast(Iterator first, Iterator last,
++                                          Compare compare, Assign assign)
++{
++    first = std::adjacent_find(first, last, compare);
++    if (first == last)
++        return last;
++
++    Iterator result = first;
++    while (++first != last) {
++        if (!compare(*result, *first))
++            ++result;
++        if (result != first)
++            assign(*result, *first);
++    }
++
++    return ++result;
++}
++
+ static void sortContainer(QCborContainerPrivate *container)
+ {
+     using Forward = QJsonPrivate::KeyIterator;
+-    using Reverse = std::reverse_iterator<Forward>;
+     using Value = Forward::value_type;
+ 
+     auto compare = [container](const Value &a, const Value &b)
+@@ -420,17 +440,31 @@ static void sortContainer(QCborContainerPrivate *container)
+         }
+     };
+ 
+-    std::sort(Forward(container->elements.begin()), Forward(container->elements.end()),
+-              [&compare](const Value &a, const Value &b) { return compare(a, b) < 0; });
++    // The elements' containers are owned by the outer container, not by the elements themselves.
++    auto move = [](Forward::reference target, Forward::reference source)
++    {
++        QtCbor::Element &targetValue = target.value();
++
++        // If the target has a container, deref it before overwriting, so that we don't leak.
++        if (targetValue.flags & QtCbor::Element::IsContainer)
++            targetValue.container->deref();
++
++        // Do not move, so that we can clear the value afterwards.
++        target = source;
++
++        // Clear the source value, so that we don't store the same container twice.
++        source.value() = QtCbor::Element();
++    };
++
++    std::stable_sort(
++                Forward(container->elements.begin()), Forward(container->elements.end()),
++                [&compare](const Value &a, const Value &b) { return compare(a, b) < 0; });
+ 
+-    // We need to retain the _last_ value for any duplicate keys. Therefore the reverse dance here.
+-    auto it = std::unique(Reverse(container->elements.end()), Reverse(container->elements.begin()),
+-                          [&compare](const Value &a, const Value &b) {
+-        return compare(a, b) == 0;
+-    }).base().elementsIterator();
++    Forward result = customAssigningUniqueLast(
++                Forward(container->elements.begin()),  Forward(container->elements.end()),
++                [&compare](const Value &a, const Value &b) { return compare(a, b) == 0; }, move);
+ 
+-    // The erase from beginning is expensive but hopefully rare.
+-    container->elements.erase(container->elements.begin(), it);
++    container->elements.erase(result.elementsIterator(), container->elements.end());
+ }
+ 
+ 
+diff --git a/qtbase/src/corelib/serialization/qxmlstream.cpp b/qtbase/src/corelib/serialization/qxmlstream.cpp
+index b2f846544d..7cd457ba3a 100644
+--- a/qtbase/src/corelib/serialization/qxmlstream.cpp
++++ b/qtbase/src/corelib/serialization/qxmlstream.cpp
+@@ -980,7 +980,7 @@ inline uint QXmlStreamReaderPrivate::peekChar()
+ bool QXmlStreamReaderPrivate::scanUntil(const char *str, short tokenToInject)
+ {
+     int pos = textBuffer.size();
+-    int oldLineNumber = lineNumber;
++    const auto oldLineNumber = lineNumber;
+ 
+     uint c;
+     while ((c = getChar()) != StreamEOF) {
+diff --git a/qtbase/src/corelib/text/qstring.cpp b/qtbase/src/corelib/text/qstring.cpp
+index 3e88ab4859..8deeae47bb 100644
+--- a/qtbase/src/corelib/text/qstring.cpp
++++ b/qtbase/src/corelib/text/qstring.cpp
+@@ -12312,7 +12312,7 @@ static qsizetype qLastIndexOf(Haystack haystack0, qsizetype from,
+     const auto needle = needle0.data();
+     const auto *end = haystack;
+     haystack += from;
+-    const std::size_t sl_minus_1 = sl - 1;
++    const std::size_t sl_minus_1 = sl ? sl - 1 : 0;
+     const auto *n = needle + sl_minus_1;
+     const auto *h = haystack + sl_minus_1;
+     std::size_t hashNeedle = 0, hashHaystack = 0;
+diff --git a/qtbase/src/corelib/text/qstringiterator_p.h b/qtbase/src/corelib/text/qstringiterator_p.h
+index 219589b6e4..1d0c66cc78 100644
+--- a/qtbase/src/corelib/text/qstringiterator_p.h
++++ b/qtbase/src/corelib/text/qstringiterator_p.h
+@@ -61,6 +61,8 @@ class QStringIterator
+ {
+     QString::const_iterator i, pos, e;
+     Q_STATIC_ASSERT((std::is_same<QString::const_iterator, const QChar *>::value));
++    static bool less(const QChar *lhs, const QChar *rhs) noexcept
++    { return std::less<QString::const_iterator>{}(lhs, rhs); }
+ public:
+     explicit QStringIterator(QStringView string, qsizetype idx = 0)
+         : i(string.begin()),
+@@ -95,7 +97,8 @@ public:
+ 
+     inline void setPosition(QString::const_iterator position)
+     {
+-        Q_ASSERT_X(i <= position && position <= e, Q_FUNC_INFO, "position out of bounds");
++        Q_ASSERT_X(!less(position, i) && !less(e, position),
++                   Q_FUNC_INFO, "position out of bounds");
+         pos = position;
+     }
+ 
+@@ -103,7 +106,7 @@ public:
+ 
+     inline bool hasNext() const
+     {
+-        return pos < e;
++        return less(pos, e);
+     }
+ 
+     inline void advance()
+@@ -120,16 +123,20 @@ public:
+     {
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+-        if (Q_UNLIKELY((pos++)->isHighSurrogate()))
++        if (Q_UNLIKELY((pos++)->isHighSurrogate())) {
++            Q_ASSERT(hasNext() && pos->isLowSurrogate());
+             ++pos;
++        }
+     }
+ 
+     inline uint peekNextUnchecked() const
+     {
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+-        if (Q_UNLIKELY(pos->isHighSurrogate()))
++        if (Q_UNLIKELY(pos->isHighSurrogate())) {
++            Q_ASSERT(less(pos + 1, e) && pos[1].isLowSurrogate());
+             return QChar::surrogateToUcs4(pos[0], pos[1]);
++        }
+ 
+         return pos->unicode();
+     }
+@@ -155,8 +162,10 @@ public:
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+         const QChar cur = *pos++;
+-        if (Q_UNLIKELY(cur.isHighSurrogate()))
++        if (Q_UNLIKELY(cur.isHighSurrogate())) {
++            Q_ASSERT(hasNext() && pos->isLowSurrogate());
+             return QChar::surrogateToUcs4(cur, *pos++);
++        }
+         return cur.unicode();
+     }
+ 
+@@ -166,7 +175,7 @@ public:
+ 
+         const QChar uc = *pos++;
+         if (Q_UNLIKELY(uc.isSurrogate())) {
+-            if (Q_LIKELY(uc.isHighSurrogate() && pos < e && pos->isLowSurrogate()))
++            if (Q_LIKELY(uc.isHighSurrogate() && hasNext() && pos->isLowSurrogate()))
+                 return QChar::surrogateToUcs4(uc, *pos++);
+             return invalidAs;
+         }
+@@ -178,7 +187,7 @@ public:
+ 
+     inline bool hasPrevious() const
+     {
+-        return pos > i;
++        return less(i, pos);
+     }
+ 
+     inline void recede()
+@@ -196,16 +205,20 @@ public:
+     {
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+-        if (Q_UNLIKELY((--pos)->isLowSurrogate()))
++        if (Q_UNLIKELY((--pos)->isLowSurrogate())) {
++            Q_ASSERT(hasPrevious() && pos[-1].isHighSurrogate());
+             --pos;
++        }
+     }
+ 
+     inline uint peekPreviousUnchecked() const
+     {
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+-        if (Q_UNLIKELY(pos[-1].isLowSurrogate()))
++        if (Q_UNLIKELY(pos[-1].isLowSurrogate())) {
++            Q_ASSERT(less(i + 1, pos) && pos[-2].isHighSurrogate());
+             return QChar::surrogateToUcs4(pos[-2], pos[-1]);
++        }
+         return pos[-1].unicode();
+     }
+ 
+@@ -230,8 +243,10 @@ public:
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+         const QChar cur = *--pos;
+-        if (Q_UNLIKELY(cur.isLowSurrogate()))
++        if (Q_UNLIKELY(cur.isLowSurrogate())) {
++            Q_ASSERT(hasPrevious() && pos[-1].isHighSurrogate());
+             return QChar::surrogateToUcs4(*--pos, cur);
++        }
+         return cur.unicode();
+     }
+ 
+@@ -241,7 +256,7 @@ public:
+ 
+         const QChar uc = *--pos;
+         if (Q_UNLIKELY(uc.isSurrogate())) {
+-            if (Q_LIKELY(uc.isLowSurrogate() && pos > i && pos[-1].isHighSurrogate()))
++            if (Q_LIKELY(uc.isLowSurrogate() && hasPrevious() && pos[-1].isHighSurrogate()))
+                 return QChar::surrogateToUcs4(*--pos, uc);
+             return invalidAs;
+         }
+diff --git a/qtbase/src/corelib/thread/qfutex_p.h b/qtbase/src/corelib/thread/qfutex_p.h
+index f287b752d7..e294537787 100644
+--- a/qtbase/src/corelib/thread/qfutex_p.h
++++ b/qtbase/src/corelib/thread/qfutex_p.h
+@@ -52,6 +52,7 @@
+ //
+ 
+ #include <qglobal.h>
++#include <QtCore/qtsan_impl.h>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -106,16 +107,13 @@ namespace QtLinuxFutex {
+     inline int _q_futex(int *addr, int op, int val, quintptr val2 = 0,
+                         int *addr2 = nullptr, int val3 = 0) noexcept
+     {
+-        // A futex call ensures total ordering on the futex words
+-        // (in either success or failure of the call). Instruct TSAN accordingly,
+-        // as TSAN does not understand the futex(2) syscall.
+-        _q_tsan_release(addr, addr2);
++        QtTsan::futexRelease(addr, addr2);
+ 
+         // we use __NR_futex because some libcs (like Android's bionic) don't
+         // provide SYS_futex etc.
+         int result = syscall(__NR_futex, addr, op | FUTEX_PRIVATE_FLAG, val, val2, addr2, val3);
+ 
+-        _q_tsan_acquire(addr, addr2);
++        QtTsan::futexAcquire(addr, addr2);
+ 
+         return result;
+     }
+diff --git a/qtbase/src/corelib/thread/qmutex.cpp b/qtbase/src/corelib/thread/qmutex.cpp
+index 310d1cb14f..7097122d8e 100644
+--- a/qtbase/src/corelib/thread/qmutex.cpp
++++ b/qtbase/src/corelib/thread/qmutex.cpp
+@@ -152,6 +152,7 @@ public:
+ 
+ /*!
+     \enum QMutex::RecursionMode
++    \obsolete Use QRecursiveMutex to create a recursive mutex.
+ 
+     \value Recursive  In this mode, a thread can lock the same mutex
+                       multiple times and the mutex won't be unlocked
+@@ -173,6 +174,7 @@ public:
+ 
+ /*!
+     Constructs a new mutex. The mutex is created in an unlocked state.
++    \obsolete Use QRecursiveMutex to create a recursive mutex.
+ 
+     If \a mode is QMutex::Recursive, a thread can lock the same mutex
+     multiple times and the mutex won't be unlocked until a
+@@ -197,7 +199,7 @@ QMutex::QMutex(RecursionMode mode)
+ QMutex::~QMutex()
+ {
+     QMutexData *d = d_ptr.loadRelaxed();
+-    if (isRecursive()) {
++    if (QBasicMutex::isRecursive()) {
+         delete static_cast<QRecursiveMutexPrivate *>(d);
+     } else if (d) {
+ #ifndef QT_LINUX_FUTEX
+diff --git a/qtbase/src/corelib/thread/qmutex.h b/qtbase/src/corelib/thread/qmutex.h
+index 73c9e00663..1bae573a03 100644
+--- a/qtbase/src/corelib/thread/qmutex.h
++++ b/qtbase/src/corelib/thread/qmutex.h
+@@ -42,6 +42,7 @@
+ 
+ #include <QtCore/qglobal.h>
+ #include <QtCore/qatomic.h>
++#include <QtCore/qtsan_impl.h>
+ #include <new>
+ 
+ #if __has_include(<chrono>)
+@@ -77,19 +78,37 @@ public:
+ 
+     // BasicLockable concept
+     inline void lock() QT_MUTEX_LOCK_NOEXCEPT {
++        QtTsan::mutexPreLock(this, 0u);
++
+         if (!fastTryLock())
+             lockInternal();
++
++        QtTsan::mutexPostLock(this, 0u, 0);
+     }
+ 
+     // BasicLockable concept
+     inline void unlock() noexcept {
+         Q_ASSERT(d_ptr.loadRelaxed()); //mutex must be locked
++
++        QtTsan::mutexPreUnlock(this, 0u);
++
+         if (!fastTryUnlock())
+             unlockInternal();
++
++        QtTsan::mutexPostUnlock(this, 0u);
+     }
+ 
+     bool tryLock() noexcept {
+-        return fastTryLock();
++        unsigned tsanFlags = QtTsan::TryLock;
++        QtTsan::mutexPreLock(this, tsanFlags);
++
++        const bool success = fastTryLock();
++
++        if (!success)
++            tsanFlags |= QtTsan::TryLockFailed;
++        QtTsan::mutexPostLock(this, tsanFlags, 0);
++
++        return success;
+     }
+ 
+     // Lockable concept
+@@ -134,8 +153,16 @@ public:
+ #else
+     QMutex() { d_ptr.storeRelaxed(nullptr); }
+ #endif
++#if QT_DEPRECATED_SINCE(5,15)
+     enum RecursionMode { NonRecursive, Recursive };
++    QT_DEPRECATED_VERSION_X(5, 15, "Use QRecursiveMutex instead of a recursive QMutex")
+     explicit QMutex(RecursionMode mode);
++
++    QT_DEPRECATED_VERSION_X(5, 15, "Use QRecursiveMutex instead of a recursive QMutex")
++    bool isRecursive() const noexcept
++    { return QBasicMutex::isRecursive(); }
++#endif
++
+     ~QMutex();
+ 
+     // BasicLockable concept
+@@ -166,9 +193,6 @@ public:
+     }
+ #endif
+ 
+-    bool isRecursive() const noexcept
+-    { return QBasicMutex::isRecursive(); }
+-
+ private:
+     Q_DISABLE_COPY(QMutex)
+     friend class QMutexLocker;
+diff --git a/qtbase/src/corelib/thread/qreadwritelock.cpp b/qtbase/src/corelib/thread/qreadwritelock.cpp
+index 8c28507d5a..9dd8503116 100644
+--- a/qtbase/src/corelib/thread/qreadwritelock.cpp
++++ b/qtbase/src/corelib/thread/qreadwritelock.cpp
+@@ -155,7 +155,7 @@ QReadWriteLock::QReadWriteLock(RecursionMode recursionMode)
+ */
+ QReadWriteLock::~QReadWriteLock()
+ {
+-    auto d = d_ptr.loadRelaxed();
++    auto d = d_ptr.loadAcquire();
+     if (isUncontendedLocked(d)) {
+         qWarning("QReadWriteLock: destroying locked QReadWriteLock");
+         return;
+@@ -445,7 +445,7 @@ void QReadWriteLock::unlock()
+ /*! \internal  Helper for QWaitCondition::wait */
+ QReadWriteLock::StateForWaitCondition QReadWriteLock::stateForWaitCondition() const
+ {
+-    QReadWriteLockPrivate *d = d_ptr.loadRelaxed();
++    QReadWriteLockPrivate *d = d_ptr.loadAcquire();
+     switch (quintptr(d) & StateMask) {
+     case StateLockedForRead: return LockedForRead;
+     case StateLockedForWrite: return LockedForWrite;
+@@ -453,6 +453,7 @@ QReadWriteLock::StateForWaitCondition QReadWriteLock::stateForWaitCondition() co
+ 
+     if (!d)
+         return Unlocked;
++    const auto lock = qt_scoped_lock(d->mutex);
+     if (d->writerCount > 1)
+         return RecursivelyLocked;
+     else if (d->writerCount == 1)
+diff --git a/qtbase/src/corelib/thread/qsemaphore.cpp b/qtbase/src/corelib/thread/qsemaphore.cpp
+index 1d01fc1b28..3ecdee3747 100644
+--- a/qtbase/src/corelib/thread/qsemaphore.cpp
++++ b/qtbase/src/corelib/thread/qsemaphore.cpp
+@@ -354,7 +354,12 @@ void QSemaphore::release(int n)
+         quintptr nn = unsigned(n);
+         if (futexHasWaiterCount)
+             nn |= quint64(nn) << 32;    // token count replicated in high word
+-        quintptr prevValue = u.fetchAndAddRelease(nn);
++        quintptr prevValue = u.loadRelaxed();
++        quintptr newValue;
++        do { // loop just to ensure the operations are done atomically
++            newValue = prevValue + nn;
++            newValue &= (futexNeedsWakeAllBit - 1);
++        } while (!u.testAndSetRelease(prevValue, newValue, prevValue));
+         if (futexNeedsWake(prevValue)) {
+ #ifdef FUTEX_OP
+             if (futexHasWaiterCount) {
+@@ -376,7 +381,6 @@ void QSemaphore::release(int n)
+                 quint32 oparg = 0;
+                 quint32 cmp = FUTEX_OP_CMP_NE;
+                 quint32 cmparg = 0;
+-                u.fetchAndAndRelease(futexNeedsWakeAllBit - 1);
+                 futexWakeOp(*futexLow32(&u), n, INT_MAX, *futexHigh32(&u), FUTEX_OP(op, oparg, cmp, cmparg));
+                 return;
+             }
+@@ -388,7 +392,6 @@ 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(futexNeedsWakeAllBit - 1);
+             if (futexHasWaiterCount) {
+                 futexWakeAll(*futexLow32(&u));
+                 futexWakeAll(*futexHigh32(&u));
+diff --git a/qtbase/src/corelib/thread/qthread_p.h b/qtbase/src/corelib/thread/qthread_p.h
+index b2d1628e6e..f32f6f0460 100644
+--- a/qtbase/src/corelib/thread/qthread_p.h
++++ b/qtbase/src/corelib/thread/qthread_p.h
+@@ -174,7 +174,7 @@ public:
+     int returnCode;
+ 
+     uint stackSize;
+-    QThread::Priority priority;
++    std::underlying_type<QThread::Priority>::type priority;
+ 
+     static QThread *threadForId(int id);
+ 
+@@ -213,6 +213,13 @@ public:
+             QCoreApplication::instance()->postEvent(q_ptr, new QEvent(QEvent::Quit));
+         }
+     }
++
++#ifndef Q_OS_INTEGRITY
++private:
++    // Used in QThread(Private)::start to avoid racy access to QObject::objectName,
++    // unset afterwards. On INTEGRITY we set the thread name before starting it.
++    QString objectName;
++#endif
+ };
+ 
+ #else // QT_CONFIG(thread)
+diff --git a/qtbase/src/corelib/thread/qthread_unix.cpp b/qtbase/src/corelib/thread/qthread_unix.cpp
+index 56a8e0a038..610117a640 100644
+--- a/qtbase/src/corelib/thread/qthread_unix.cpp
++++ b/qtbase/src/corelib/thread/qthread_unix.cpp
+@@ -169,8 +169,7 @@ static void set_thread_data(QThreadData *data)
+ 
+ static void clear_thread_data()
+ {
+-    currentThreadData = nullptr;
+-    pthread_setspecific(current_thread_data_key, nullptr);
++    set_thread_data(nullptr);
+ }
+ 
+ template <typename T>
+@@ -296,7 +295,7 @@ void *QThreadPrivate::start(void *arg)
+             QMutexLocker locker(&thr->d_func()->mutex);
+ 
+             // do we need to reset the thread priority?
+-            if (int(thr->d_func()->priority) & ThreadPriorityResetFlag) {
++            if (thr->d_func()->priority & ThreadPriorityResetFlag) {
+                 thr->d_func()->setPriority(QThread::Priority(thr->d_func()->priority & ~ThreadPriorityResetFlag));
+             }
+ 
+@@ -316,10 +315,10 @@ void *QThreadPrivate::start(void *arg)
+             // Sets the name of the current thread. We can only do this
+             // when the thread is starting, as we don't have a cross
+             // platform way of setting the name of an arbitrary thread.
+-            if (Q_LIKELY(thr->objectName().isEmpty()))
++            if (Q_LIKELY(thr->d_func()->objectName.isEmpty()))
+                 setCurrentThreadName(thr->metaObject()->className());
+             else
+-                setCurrentThreadName(thr->objectName().toLocal8Bit());
++                setCurrentThreadName(std::exchange(thr->d_func()->objectName, {}).toLocal8Bit());
+         }
+ #endif
+ 
+@@ -671,7 +670,7 @@ void QThread::start(Priority priority)
+                 // could not set scheduling hints, fallback to inheriting them
+                 // we'll try again from inside the thread
+                 pthread_attr_setinheritsched(&attr, PTHREAD_INHERIT_SCHED);
+-                d->priority = Priority(priority | ThreadPriorityResetFlag);
++                d->priority = static_cast<std::underlying_type<QThread::Priority>::type>(priority) | ThreadPriorityResetFlag;
+             }
+             break;
+         }
+@@ -702,7 +701,10 @@ void QThread::start(Priority priority)
+         pthread_attr_setthreadname(&attr, metaObject()->className());
+     else
+         pthread_attr_setthreadname(&attr, objectName().toLocal8Bit());
++#else
++    d->objectName = objectName();
+ #endif
++
+     pthread_t threadId;
+     int code = pthread_create(&threadId, &attr, QThreadPrivate::start, this);
+     if (code == EPERM) {
+diff --git a/qtbase/src/corelib/thread/qthread_win.cpp b/qtbase/src/corelib/thread/qthread_win.cpp
+index bc70e3178a..4e76972498 100644
+--- a/qtbase/src/corelib/thread/qthread_win.cpp
++++ b/qtbase/src/corelib/thread/qthread_win.cpp
+@@ -394,10 +394,9 @@ unsigned int __stdcall QT_ENSURE_STACK_ALIGNED_FOR_SSE QThreadPrivate::start(voi
+ 
+ #if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) && !defined(Q_OS_WINRT)
+     // sets the name of the current thread.
+-    QByteArray objectName = thr->objectName().toLocal8Bit();
+-    qt_set_thread_name(HANDLE(-1),
+-                       objectName.isEmpty() ?
+-                       thr->metaObject()->className() : objectName.constData());
++    qt_set_thread_name(HANDLE(-1), thr->d_func()->objectName.isEmpty()
++                        ? thr->metaObject()->className()
++                        : std::exchange(thr->d_func()->objectName, {}).toLocal8Bit().constData());
+ #endif
+ 
+     emit thr->started(QThread::QPrivateSignal());
+@@ -503,6 +502,7 @@ void QThread::start(Priority priority)
+     if (d->running)
+         return;
+ 
++    d->objectName = objectName();
+     d->running = true;
+     d->finished = false;
+     d->exited = false;
+@@ -548,7 +548,7 @@ void QThread::start(Priority priority)
+ 
+     int prio;
+     d->priority = priority;
+-    switch (d->priority) {
++    switch (priority) {
+     case IdlePriority:
+         prio = THREAD_PRIORITY_IDLE;
+         break;
+@@ -686,7 +686,7 @@ void QThreadPrivate::setPriority(QThread::Priority threadPriority)
+ 
+     int prio;
+     priority = threadPriority;
+-    switch (priority) {
++    switch (threadPriority) {
+     case QThread::IdlePriority:
+         prio = THREAD_PRIORITY_IDLE;
+         break;
+diff --git a/qtbase/src/corelib/thread/qtsan_impl.h b/qtbase/src/corelib/thread/qtsan_impl.h
+new file mode 100644
+index 0000000000..580a738b91
+--- /dev/null
++++ b/qtbase/src/corelib/thread/qtsan_impl.h
+@@ -0,0 +1,115 @@
++/****************************************************************************
++**
++** Copyright (C) 2017 Intel Corporation.
++** Copyright (C) 2022 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
++** 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 QTSAN_IMPL_H
++#define QTSAN_IMPL_H
++
++#include <QtCore/qglobal.h>
++
++#if (__has_feature(thread_sanitizer) || defined(__SANITIZE_THREAD__)) && __has_include(<sanitizer/tsan_interface.h>)
++#  define QT_BUILDING_UNDER_TSAN
++#  include <sanitizer/tsan_interface.h>
++#endif
++
++QT_BEGIN_NAMESPACE
++
++namespace QtTsan {
++#ifdef QT_BUILDING_UNDER_TSAN
++inline void futexAcquire(void *addr, void *addr2 = nullptr)
++{
++    // A futex call ensures total ordering on the futex words
++    // (in either success or failure of the call). Instruct TSAN accordingly,
++    // as TSAN does not understand the futex(2) syscall (or equivalent).
++    ::__tsan_acquire(addr);
++    if (addr2)
++        ::__tsan_acquire(addr2);
++}
++
++inline void futexRelease(void *addr, void *addr2 = nullptr)
++{
++    if (addr2)
++        ::__tsan_release(addr2);
++    ::__tsan_release(addr);
++}
++
++inline void mutexPreLock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_pre_lock(addr, flags);
++}
++
++inline void mutexPostLock(void *addr, unsigned flags, int recursion)
++{
++    ::__tsan_mutex_post_lock(addr, flags, recursion);
++}
++
++inline void mutexPreUnlock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_pre_unlock(addr, flags);
++}
++
++inline void mutexPostUnlock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_post_unlock(addr, flags);
++}
++
++enum : unsigned {
++    MutexWriteReentrant = ::__tsan_mutex_write_reentrant,
++    TryLock = ::__tsan_mutex_try_lock,
++    TryLockFailed = ::__tsan_mutex_try_lock_failed,
++};
++#else
++inline void futexAcquire(void *, void * = nullptr) {}
++inline void futexRelease(void *, void * = nullptr) {}
++
++enum : unsigned {
++    MutexWriteReentrant,
++    TryLock,
++    TryLockFailed,
++};
++inline void mutexPreLock(void *, unsigned) {}
++inline void mutexPostLock(void *, unsigned, int) {}
++inline void mutexPreUnlock(void *, unsigned) {}
++inline void mutexPostUnlock(void *, unsigned) {}
++#endif // QT_BUILDING_UNDER_TSAN
++} // namespace QtTsan
++
++QT_END_NAMESPACE
++
++#endif // QTSAN_IMPL_H
+diff --git a/qtbase/src/corelib/thread/qwaitcondition_unix.cpp b/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
+index 88b058f410..0f1da4dc9b 100644
+--- a/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
++++ b/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
+@@ -213,7 +213,7 @@ bool QWaitCondition::wait(QMutex *mutex, QDeadlineTimer deadline)
+ {
+     if (! mutex)
+         return false;
+-    if (mutex->isRecursive()) {
++    if (static_cast<QBasicMutex *>(mutex)->isRecursive()) {
+         qWarning("QWaitCondition: cannot wait on recursive mutexes");
+         return false;
+     }
+diff --git a/qtbase/src/corelib/time/qdatetime.cpp b/qtbase/src/corelib/time/qdatetime.cpp
+index ec12569e3f..2c0b098079 100644
+--- a/qtbase/src/corelib/time/qdatetime.cpp
++++ b/qtbase/src/corelib/time/qdatetime.cpp
+@@ -43,6 +43,7 @@
+ #if QT_CONFIG(datetimeparser)
+ #include "private/qdatetimeparser_p.h"
+ #endif
++#include <private/qnumeric_p.h>
+ 
+ #include "qdatastream.h"
+ #include "qset.h"
+@@ -1429,9 +1430,11 @@ QDate QDate::addDays(qint64 ndays) const
+     if (isNull())
+         return QDate();
+ 
+-    // Due to limits on minJd() and maxJd() we know that any overflow
+-    // will be invalid and caught by fromJulianDay().
+-    return fromJulianDay(jd + ndays);
++    qint64 r;
++    if (Q_UNLIKELY(add_overflow(jd, ndays, &r)))
++        return QDate();
++    else
++        return fromJulianDay(r);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/corelib/time/qtimezone.cpp b/qtbase/src/corelib/time/qtimezone.cpp
+index 0309e43e52..3d451696a1 100644
+--- a/qtbase/src/corelib/time/qtimezone.cpp
++++ b/qtbase/src/corelib/time/qtimezone.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2013 John Layt <jlayt@kde.org>
++** Copyright (C) 2020 John Layt <jlayt@kde.org>
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtCore module of the Qt Toolkit.
+@@ -975,9 +975,15 @@ QList<QByteArray> QTimeZone::windowsIdToIanaIds(const QByteArray &windowsId,
+ }
+ 
+ #ifndef QT_NO_DATASTREAM
++// Invalid, as an IANA ID: too long, starts with - and has other invalid characters in it
++static inline QString invalidId() { return QStringLiteral("-No Time Zone Specified!"); }
++
+ QDataStream &operator<<(QDataStream &ds, const QTimeZone &tz)
+ {
+-    tz.d->serialize(ds);
++    if (tz.isValid())
++        tz.d->serialize(ds);
++    else
++        ds << invalidId();
+     return ds;
+ }
+ 
+@@ -985,7 +991,9 @@ QDataStream &operator>>(QDataStream &ds, QTimeZone &tz)
+ {
+     QString ianaId;
+     ds >> ianaId;
+-    if (ianaId == QLatin1String("OffsetFromUtc")) {
++    if (ianaId == invalidId()) {
++        tz = QTimeZone();
++    } else if (ianaId == QLatin1String("OffsetFromUtc")) {
+         int utcOffset;
+         QString name;
+         QString abbreviation;
+diff --git a/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp b/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
+index b1611d7ddb..a7a6a72ccf 100644
+--- a/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
++++ b/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
+@@ -42,6 +42,7 @@
+ #include "qtimezone.h"
+ #include "qtimezoneprivate_p.h"
+ #include "private/qlocale_tools_p.h"
++#include "private/qlocking_p.h"
+ 
+ #include <QtCore/QDataStream>
+ #include <QtCore/QDateTime>
+@@ -62,6 +63,10 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++#if QT_CONFIG(icu)
++static QBasicMutex s_icu_mutex;
++#endif
++
+ /*
+     Private
+ 
+@@ -670,6 +675,9 @@ QTzTimeZonePrivate::~QTzTimeZonePrivate()
+ 
+ QTzTimeZonePrivate *QTzTimeZonePrivate::clone() const
+ {
++#if QT_CONFIG(icu)
++    const auto lock = qt_scoped_lock(s_icu_mutex);
++#endif
+     return new QTzTimeZonePrivate(*this);
+ }
+ 
+@@ -913,12 +921,14 @@ QString QTzTimeZonePrivate::displayName(qint64 atMSecsSinceEpoch,
+                                         const QLocale &locale) const
+ {
+ #if QT_CONFIG(icu)
++    auto lock = qt_unique_lock(s_icu_mutex);
+     if (!m_icu)
+         m_icu = new QIcuTimeZonePrivate(m_id);
+     // TODO small risk may not match if tran times differ due to outdated files
+     // TODO Some valid TZ names are not valid ICU names, use translation table?
+     if (m_icu->isValid())
+         return m_icu->displayName(atMSecsSinceEpoch, nameType, locale);
++    lock.unlock();
+ #else
+     Q_UNUSED(nameType)
+     Q_UNUSED(locale)
+@@ -932,12 +942,14 @@ QString QTzTimeZonePrivate::displayName(QTimeZone::TimeType timeType,
+                                         const QLocale &locale) const
+ {
+ #if QT_CONFIG(icu)
++    auto lock = qt_unique_lock(s_icu_mutex);
+     if (!m_icu)
+         m_icu = new QIcuTimeZonePrivate(m_id);
+     // TODO small risk may not match if tran times differ due to outdated files
+     // TODO Some valid TZ names are not valid ICU names, use translation table?
+     if (m_icu->isValid())
+         return m_icu->displayName(timeType, nameType, locale);
++    lock.unlock();
+ #else
+     Q_UNUSED(timeType)
+     Q_UNUSED(nameType)
+diff --git a/qtbase/src/corelib/tools/qarraydata.h b/qtbase/src/corelib/tools/qarraydata.h
+index dcd95924c1..d01739e7e6 100644
+--- a/qtbase/src/corelib/tools/qarraydata.h
++++ b/qtbase/src/corelib/tools/qarraydata.h
+@@ -42,6 +42,7 @@
+ 
+ #include <QtCore/qrefcount.h>
+ #include <string.h>
++#include <cstdint>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -58,14 +59,14 @@ struct Q_CORE_EXPORT QArrayData
+     {
+         Q_ASSERT(size == 0
+                 || offset < 0 || size_t(offset) >= sizeof(QArrayData));
+-        return reinterpret_cast<char *>(this) + offset;
++        return reinterpret_cast<void *> (reinterpret_cast<uintptr_t>(this) + offset);
+     }
+ 
+     const void *data() const
+     {
+         Q_ASSERT(size == 0
+                 || offset < 0 || size_t(offset) >= sizeof(QArrayData));
+-        return reinterpret_cast<const char *>(this) + offset;
++        return reinterpret_cast<void *> (reinterpret_cast<uintptr_t>(this) + offset);
+     }
+ 
+     // This refers to array data mutability, not "header data" represented by
+diff --git a/qtbase/src/corelib/tools/qfreelist_p.h b/qtbase/src/corelib/tools/qfreelist_p.h
+index 5ba23b344b..9974102136 100644
+--- a/qtbase/src/corelib/tools/qfreelist_p.h
++++ b/qtbase/src/corelib/tools/qfreelist_p.h
+@@ -161,7 +161,7 @@ class QFreeList
+                 return i;
+             x -= size;
+         }
+-        Q_ASSERT(false);
++        Q_UNREACHABLE();
+         return -1;
+     }
+ 
+diff --git a/qtbase/src/corelib/tools/qversionnumber.h b/qtbase/src/corelib/tools/qversionnumber.h
+index d43b86ba51..2843f2b043 100644
+--- a/qtbase/src/corelib/tools/qversionnumber.h
++++ b/qtbase/src/corelib/tools/qversionnumber.h
+@@ -273,10 +273,10 @@ public:
+ 
+     Q_REQUIRED_RESULT Q_CORE_EXPORT QString toString() const;
+ #if QT_STRINGVIEW_LEVEL < 2
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(const QString &string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(const QString &string, int *suffixIndex = nullptr);
+ #endif
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QLatin1String string, int *suffixIndex = nullptr);
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QStringView string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(QLatin1String string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(QStringView string, int *suffixIndex = nullptr);
+ 
+ private:
+ #ifndef QT_NO_DATASTREAM
+diff --git a/qtbase/src/dbus/qdbusintegrator.cpp b/qtbase/src/dbus/qdbusintegrator.cpp
+index 5b66ce971b..28a3b0ffea 100644
+--- a/qtbase/src/dbus/qdbusintegrator.cpp
++++ b/qtbase/src/dbus/qdbusintegrator.cpp
+@@ -1135,7 +1135,13 @@ void QDBusConnectionPrivate::closeConnection()
+         }
+     }
+ 
+-    qDeleteAll(pendingCalls);
++    for (auto it = pendingCalls.begin(); it != pendingCalls.end(); ++it) {
++        auto call = *it;
++        if (!call->ref.deref()) {
++            delete call;
++        }
++    }
++    pendingCalls.clear();
+ 
+     // Disconnect all signals from signal hooks and from the object tree to
+     // avoid QObject::destroyed being sent to dbus daemon thread which has
+@@ -2584,6 +2590,11 @@ QDBusConnectionPrivate::findMetaObject(const QString &service, const QString &pa
+         if (mo)
+             return mo;
+     }
++    if (path.isEmpty()) {
++        error = QDBusError(QDBusError::InvalidObjectPath, QLatin1String("Object path cannot be empty"));
++        lastError = error;
++        return nullptr;
++    }
+ 
+     // introspect the target object
+     QDBusMessage msg = QDBusMessage::createMethodCall(service, path,
+diff --git a/qtbase/src/dbus/qdbusmetaobject.cpp b/qtbase/src/dbus/qdbusmetaobject.cpp
+index 5265568f42..7e9f0f1acc 100644
+--- a/qtbase/src/dbus/qdbusmetaobject.cpp
++++ b/qtbase/src/dbus/qdbusmetaobject.cpp
+@@ -210,6 +210,9 @@ QDBusMetaObjectGenerator::findType(const QByteArray &signature,
+         } else if (signature == "a{ss}") {
+             result.name = "QMap<QString,QString>";
+             type = qMetaTypeId<QMap<QString, QString> >();
++        } else if (signature == "aay") {
++            result.name = "QByteArrayList";
++            type = qMetaTypeId<QByteArrayList>();
+         } else {
+             result.name = "{D-Bus type \"" + signature + "\"}";
+             type = registerComplexDBusType(result.name);
+diff --git a/qtbase/src/gui/accessible/qaccessible.cpp b/qtbase/src/gui/accessible/qaccessible.cpp
+index d705bfccb5..0caf3c808c 100644
+--- a/qtbase/src/gui/accessible/qaccessible.cpp
++++ b/qtbase/src/gui/accessible/qaccessible.cpp
+@@ -54,6 +54,7 @@
+ #include <QtCore/qdebug.h>
+ #include <QtCore/qloggingcategory.h>
+ #include <QtCore/qmetaobject.h>
++#include <QtCore/private/qmetaobject_p.h>
+ #include <QtCore/qhash.h>
+ #include <private/qfactoryloader_p.h>
+ 
+@@ -681,6 +682,25 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
+     // Create a QAccessibleInterface for the object class. Start by the most
+     // derived class and walk up the class hierarchy.
+     const QMetaObject *mo = object->metaObject();
++    const auto *objectPriv = QObjectPrivate::get(object);
++    /*
++     We do not want to cache each and every QML metaobject (Button_QMLTYPE_124,
++     Button_QMLTYPE_125, etc.). Those dynamic metaobjects shouldn't have an
++     accessible interface in any case. Instead, we start the whole checking
++     with the first non-dynamic meta-object. To avoid potential regressions
++     in other areas of Qt that also use dynamic metaobjects, we only do this
++     for objects that are QML-related (approximated by checking whether they
++     have ddata set).
++    */
++    const bool qmlRelated = !objectPriv->isDeletingChildren &&
++                            objectPriv->declarativeData;
++    while (qmlRelated && mo) {
++        auto mop = QMetaObjectPrivate::get(mo);
++        if (!mop || !(mop->flags & DynamicMetaObject))
++            break;
++
++        mo = mo->superClass();
++    };
+     while (mo) {
+         const QString cn = QLatin1String(mo->className());
+ 
+@@ -696,14 +716,15 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
+         // Find a QAccessiblePlugin (factory) for the class name. If there's
+         // no entry in the cache try to create it using the plugin loader.
+         if (!qAccessiblePlugins()->contains(cn)) {
++            QAccessiblePlugin *factory = nullptr; // 0 means "no plugin found". This is cached as well.
+             const int index = loader()->indexOf(cn);
+-            if (index != -1) {
+-                QAccessiblePlugin *factory = qobject_cast<QAccessiblePlugin *>(loader()->instance(index));
+-                qAccessiblePlugins()->insert(cn, factory);
+-            }
++            if (index != -1)
++                factory = qobject_cast<QAccessiblePlugin *>(loader()->instance(index));
++            qAccessiblePlugins()->insert(cn, factory);
+         }
+ 
+         // At this point the cache should contain a valid factory pointer or 0:
++        Q_ASSERT(qAccessiblePlugins()->contains(cn));
+         QAccessiblePlugin *factory = qAccessiblePlugins()->value(cn);
+         if (factory) {
+             QAccessibleInterface *result = factory->create(cn, object);
+diff --git a/qtbase/src/gui/configure.json b/qtbase/src/gui/configure.json
+index 1f08795c57..12c95742d2 100644
+--- a/qtbase/src/gui/configure.json
++++ b/qtbase/src/gui/configure.json
+@@ -834,7 +834,8 @@
+                     "// embedded devices, are not intended to be used together with X. EGL support",
+                     "// has to be disabled in plugins like xcb in this case since the native display,",
+                     "// window and pixmap types will be different than what an X-based platform",
+-                    "// plugin would expect."
++                    "// plugin would expect.",
++                    "#define USE_X11"
+                 ],
+                 "include": [ "EGL/egl.h", "X11/Xlib.h" ],
+                 "main": [
+diff --git a/qtbase/src/gui/image/qbmphandler.cpp b/qtbase/src/gui/image/qbmphandler.cpp
+index 96f1e8cb1d..0e73bbbdb0 100644
+--- a/qtbase/src/gui/image/qbmphandler.cpp
++++ b/qtbase/src/gui/image/qbmphandler.cpp
+@@ -150,16 +150,42 @@ static QDataStream &operator<<(QDataStream &s, const BMP_INFOHDR &bi)
+     return s;
+ }
+ 
+-static int calc_shift(uint mask)
++static uint calc_shift(uint mask)
+ {
+-    int result = 0;
+-    while (mask && !(mask & 1)) {
++    uint result = 0;
++    while ((mask >= 0x100) || (!(mask & 1) && mask)) {
+         result++;
+         mask >>= 1;
+     }
+     return result;
+ }
+ 
++static uint calc_scale(uint low_mask)
++{
++    uint result = 8;
++    while (low_mask && result) {
++        result--;
++        low_mask >>= 1;
++    }
++    return result;
++}
++
++static inline uint apply_scale(uint value, uint scale)
++{
++    if (!(scale & 0x07)) // return immediately if scale == 8 or 0
++        return value;
++
++    uint filled = 8 - scale;
++    uint result = value << scale;
++
++    do {
++        result |= result >> filled;
++        filled <<= 1;
++    } while (filled < 8);
++
++    return result;
++}
++
+ static bool read_dib_fileheader(QDataStream &s, BMP_FILEHDR &bf)
+ {
+     // read BMP file header
+@@ -222,14 +248,14 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+     uint green_mask = 0;
+     uint blue_mask = 0;
+     uint alpha_mask = 0;
+-    int red_shift = 0;
+-    int green_shift = 0;
+-    int blue_shift = 0;
+-    int alpha_shift = 0;
+-    int red_scale = 0;
+-    int green_scale = 0;
+-    int blue_scale = 0;
+-    int alpha_scale = 0;
++    uint red_shift = 0;
++    uint green_shift = 0;
++    uint blue_shift = 0;
++    uint alpha_shift = 0;
++    uint red_scale = 0;
++    uint green_scale = 0;
++    uint blue_scale = 0;
++    uint alpha_scale = 0;
+ 
+     if (!d->isSequential())
+         d->seek(startpos + BMP_FILEHDR_SIZE + bi.biSize); // goto start of colormap or masks
+@@ -308,19 +334,19 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+         red_shift = calc_shift(red_mask);
+         if (((red_mask >> red_shift) + 1) == 0)
+             return false;
+-        red_scale = 256 / ((red_mask >> red_shift) + 1);
++        red_scale = calc_scale(red_mask >> red_shift);
+         green_shift = calc_shift(green_mask);
+         if (((green_mask >> green_shift) + 1) == 0)
+             return false;
+-        green_scale = 256 / ((green_mask >> green_shift) + 1);
++        green_scale = calc_scale(green_mask >> green_shift);
+         blue_shift = calc_shift(blue_mask);
+         if (((blue_mask >> blue_shift) + 1) == 0)
+             return false;
+-        blue_scale = 256 / ((blue_mask >> blue_shift) + 1);
++        blue_scale = calc_scale(blue_mask >> blue_shift);
+         alpha_shift = calc_shift(alpha_mask);
+         if (((alpha_mask >> alpha_shift) + 1) == 0)
+             return false;
+-        alpha_scale = 256 / ((alpha_mask >> alpha_shift) + 1);
++        alpha_scale = calc_scale(alpha_mask >> alpha_shift);
+     } else if (comp == BMP_RGB && (nbits == 24 || nbits == 32)) {
+         blue_mask = 0x000000ff;
+         green_mask = 0x0000ff00;
+@@ -328,17 +354,15 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+         blue_shift = 0;
+         green_shift = 8;
+         red_shift = 16;
+-        blue_scale = green_scale = red_scale = 1;
++        blue_scale = green_scale = red_scale = 0;
+     } else if (comp == BMP_RGB && nbits == 16) {
+         blue_mask = 0x001f;
+         green_mask = 0x03e0;
+         red_mask = 0x7c00;
+         blue_shift = 0;
+-        green_shift = 2;
+-        red_shift = 7;
+-        red_scale = 1;
+-        green_scale = 1;
+-        blue_scale = 8;
++        green_shift = 5;
++        red_shift = 10;
++        blue_scale = green_scale = red_scale = 3;
+     }
+ 
+ #if 0
+@@ -544,10 +568,10 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+                     c |= *(uchar*)(b+2)<<16;
+                 if (nbits > 24)
+                     c |= *(uchar*)(b+3)<<24;
+-                *p++ = qRgba(((c & red_mask) >> red_shift) * red_scale,
+-                                        ((c & green_mask) >> green_shift) * green_scale,
+-                                        ((c & blue_mask) >> blue_shift) * blue_scale,
+-                                        transp ? ((c & alpha_mask) >> alpha_shift) * alpha_scale : 0xff);
++                *p++ = qRgba(apply_scale((c & red_mask) >> red_shift, red_scale),
++                             apply_scale((c & green_mask) >> green_shift, green_scale),
++                             apply_scale((c & blue_mask) >> blue_shift, blue_scale),
++                             transp ? apply_scale((c & alpha_mask) >> alpha_shift, alpha_scale) : 0xff);
+                 b += nbits/8;
+             }
+         }
+diff --git a/qtbase/src/gui/image/qimage.cpp b/qtbase/src/gui/image/qimage.cpp
+index 7152ac1607..0df772564c 100644
+--- a/qtbase/src/gui/image/qimage.cpp
++++ b/qtbase/src/gui/image/qimage.cpp
+@@ -4694,6 +4694,8 @@ QImage QImage::smoothScaled(int w, int h) const {
+ static QImage rotated90(const QImage &image)
+ {
+     QImage out(image.height(), image.width(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+@@ -4722,6 +4724,8 @@ static QImage rotated180(const QImage &image)
+         return image.mirrored(true, true);
+ 
+     QImage out(image.width(), image.height(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+@@ -4734,6 +4738,8 @@ static QImage rotated180(const QImage &image)
+ static QImage rotated270(const QImage &image)
+ {
+     QImage out(image.height(), image.width(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+diff --git a/qtbase/src/gui/kernel/qcursor.cpp b/qtbase/src/gui/kernel/qcursor.cpp
+index d6ccaff8ed..455088241c 100644
+--- a/qtbase/src/gui/kernel/qcursor.cpp
++++ b/qtbase/src/gui/kernel/qcursor.cpp
+@@ -251,7 +251,8 @@ void QCursor::setPos(QScreen *screen, int x, int y)
+ {
+     if (screen) {
+         if (QPlatformCursor *cursor = screen->handle()->cursor()) {
+-            const QPoint devicePos = QHighDpi::toNativePixels(QPoint(x, y), screen);
++            const QPoint pos(x, y);
++            const QPoint devicePos = QHighDpi::toNativePixels(pos, screen->virtualSiblingAt(pos));
+             // Need to check, since some X servers generate null mouse move
+             // events, causing looping in applications which call setPos() on
+             // every mouse move event.
+diff --git a/qtbase/src/gui/kernel/qhighdpiscaling.cpp b/qtbase/src/gui/kernel/qhighdpiscaling.cpp
+index 9bbf2773a9..3ac4a4d8b6 100644
+--- a/qtbase/src/gui/kernel/qhighdpiscaling.cpp
++++ b/qtbase/src/gui/kernel/qhighdpiscaling.cpp
+@@ -580,9 +580,8 @@ void QHighDpiScaling::setScreenFactor(QScreen *screen, qreal factor)
+     else
+         qNamedScreenScaleFactors()->insert(name, factor);
+ 
+-    // hack to force re-evaluation of screen geometry
+     if (screen->handle())
+-        screen->d_func()->setPlatformScreen(screen->handle()); // updates geometries based on scale factor
++        screen->d_func()->updateLogicalDpi();
+ }
+ 
+ QPoint QHighDpiScaling::mapPositionToNative(const QPoint &pos, const QPlatformScreen *platformScreen)
+diff --git a/qtbase/src/gui/kernel/qkeysequence.cpp b/qtbase/src/gui/kernel/qkeysequence.cpp
+index a75b8ef920..4f2d294739 100644
+--- a/qtbase/src/gui/kernel/qkeysequence.cpp
++++ b/qtbase/src/gui/kernel/qkeysequence.cpp
+@@ -701,6 +701,10 @@ static const struct {
+     { Qt::Key_TouchpadToggle,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad Toggle") },
+     { Qt::Key_TouchpadOn,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad On") },
+     { Qt::Key_TouchpadOff,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad Off") },
++    { Qt::Key_Shift,  QT_TRANSLATE_NOOP("QShortcut", "Shift") },
++    { Qt::Key_Control,  QT_TRANSLATE_NOOP("QShortcut", "Control") },
++    { Qt::Key_Alt,  QT_TRANSLATE_NOOP("QShortcut", "Alt") },
++    { Qt::Key_Meta,  QT_TRANSLATE_NOOP("QShortcut", "Meta") },
+ 
+ };
+ static Q_CONSTEXPR int numKeyNames = sizeof keyname / sizeof *keyname;
+diff --git a/qtbase/src/gui/kernel/qplatformservices.cpp b/qtbase/src/gui/kernel/qplatformservices.cpp
+index fdc6a6c4aa..ac47f98c5d 100644
+--- a/qtbase/src/gui/kernel/qplatformservices.cpp
++++ b/qtbase/src/gui/kernel/qplatformservices.cpp
+@@ -55,6 +55,19 @@ QT_BEGIN_NAMESPACE
+     \brief The QPlatformServices provides the backend for desktop-related functionality.
+ */
+ 
++/*!
++    \enum QPlatformServices::Capability
++
++    Capabilities are used to determine a specific platform service's availability.
++
++    \value ColorPickingFromScreen The platform natively supports color picking from screen.
++    This capability indicates that the platform supports "opaque" color picking, where the
++    platform implements a complete user experience for color picking and outputs a color.
++    This is in contrast to the application implementing the color picking user experience
++    (taking care of showing a cross hair, instructing the platform integration to obtain
++    the color at a given pixel, etc.). The related service function is pickColor().
++ */
++
+ QPlatformServices::QPlatformServices()
+ { }
+ 
+@@ -85,5 +98,16 @@ QByteArray QPlatformServices::desktopEnvironment() const
+     return QByteArray("UNKNOWN");
+ }
+ 
++QPlatformServiceColorPicker *QPlatformServices::colorPicker(QWindow *parent)
++{
++    Q_UNUSED(parent);
++    return nullptr;
++}
++
++bool QPlatformServices::hasCapability(Capability capability) const
++{
++    Q_UNUSED(capability)
++    return false;
++}
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/gui/kernel/qplatformservices.h b/qtbase/src/gui/kernel/qplatformservices.h
+index 5de96cfa7d..a8b2a4ce71 100644
+--- a/qtbase/src/gui/kernel/qplatformservices.h
++++ b/qtbase/src/gui/kernel/qplatformservices.h
+@@ -50,16 +50,32 @@
+ //
+ 
+ #include <QtGui/qtguiglobal.h>
++#include <QtCore/qobject.h>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+ class QUrl;
++class QWindow;
++
++class Q_GUI_EXPORT QPlatformServiceColorPicker : public QObject
++{
++    Q_OBJECT
++public:
++    using QObject::QObject;
++    virtual void pickColor() = 0;
++Q_SIGNALS:
++    void colorPicked(const QColor &color);
++};
+ 
+ class Q_GUI_EXPORT QPlatformServices
+ {
+ public:
+     Q_DISABLE_COPY_MOVE(QPlatformServices)
+ 
++    enum Capability {
++        ColorPicking,
++    };
++
+     QPlatformServices();
+     virtual ~QPlatformServices() { }
+ 
+@@ -67,6 +83,10 @@ public:
+     virtual bool openDocument(const QUrl &url);
+ 
+     virtual QByteArray desktopEnvironment() const;
++
++    virtual bool hasCapability(Capability capability) const;
++
++    virtual QPlatformServiceColorPicker *colorPicker(QWindow *parent = nullptr);
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/gui/kernel/qplatformtheme.cpp b/qtbase/src/gui/kernel/qplatformtheme.cpp
+index 71521c0339..2325873245 100644
+--- a/qtbase/src/gui/kernel/qplatformtheme.cpp
++++ b/qtbase/src/gui/kernel/qplatformtheme.cpp
+@@ -163,6 +163,8 @@ QT_BEGIN_NAMESPACE
+ 
+     \value ShowShortcutsInContextMenus (bool) Whether to display shortcut key sequences in context menus.
+ 
++    \value ButtonPressKeys (QList<Qt::Key>) A list of keys that can be used to press buttons via keyboard input.
++
+     \sa themeHint(), QStyle::pixelMetric()
+ */
+ 
+@@ -563,6 +565,8 @@ QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint)
+         }
+     case MouseQuickSelectionThreshold:
+         return QVariant(10);
++    case ButtonPressKeys:
++        return QVariant::fromValue(QList<Qt::Key>({ Qt::Key_Space, Qt::Key_Select }));
+     }
+     return QVariant();
+ }
+diff --git a/qtbase/src/gui/kernel/qplatformtheme.h b/qtbase/src/gui/kernel/qplatformtheme.h
+index 3185fc4541..7e6c9d5740 100644
+--- a/qtbase/src/gui/kernel/qplatformtheme.h
++++ b/qtbase/src/gui/kernel/qplatformtheme.h
+@@ -120,7 +120,8 @@ public:
+         TouchDoubleTapDistance,
+         ShowShortcutsInContextMenus,
+         IconFallbackSearchPaths,
+-        MouseQuickSelectionThreshold
++        MouseQuickSelectionThreshold,
++        ButtonPressKeys
+     };
+ 
+     enum DialogType {
+diff --git a/qtbase/src/gui/kernel/qscreen.cpp b/qtbase/src/gui/kernel/qscreen.cpp
+index 8e0eb35116..5d172a58dd 100644
+--- a/qtbase/src/gui/kernel/qscreen.cpp
++++ b/qtbase/src/gui/kernel/qscreen.cpp
+@@ -77,6 +77,12 @@ QScreen::QScreen(QPlatformScreen *screen)
+     d->setPlatformScreen(screen);
+ }
+ 
++void QScreenPrivate::updateLogicalDpi()
++{
++    logicalDpi = QPlatformScreen::overrideDpi(platformScreen->logicalDpi());
++    updateGeometriesWithSignals(); // updates geometries based on scale factor
++}
++
+ void QScreenPrivate::updateGeometriesWithSignals()
+ {
+     const QRect oldGeometry = geometry;
+diff --git a/qtbase/src/gui/kernel/qscreen_p.h b/qtbase/src/gui/kernel/qscreen_p.h
+index 7da542c25e..e50fc3190b 100644
+--- a/qtbase/src/gui/kernel/qscreen_p.h
++++ b/qtbase/src/gui/kernel/qscreen_p.h
+@@ -70,6 +70,7 @@ public:
+         geometry = platformScreen->deviceIndependentGeometry();
+         availableGeometry = QHighDpi::fromNative(platformScreen->availableGeometry(), QHighDpiScaling::factor(platformScreen), geometry.topLeft());
+     }
++    void updateLogicalDpi();
+ 
+     void updatePrimaryOrientation();
+     void updateGeometriesWithSignals();
+diff --git a/qtbase/src/gui/painting/qblendfunctions_p.h b/qtbase/src/gui/painting/qblendfunctions_p.h
+index 080da98ec4..6997d62b3c 100644
+--- a/qtbase/src/gui/painting/qblendfunctions_p.h
++++ b/qtbase/src/gui/painting/qblendfunctions_p.h
+@@ -246,25 +246,32 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+                                   int dudx, int dvdx, int dudy, int dvdy, int u0, int v0,
+                                   Blender blender)
+ {
+-    int fromY = qMax(qRound(topY), clip.top());
+-    int toY = qMin(qRound(bottomY), clip.top() + clip.height());
++    qint64 fromY = qMax(qRound(topY), clip.top());
++    qint64 toY = qMin(qRound(bottomY), clip.top() + clip.height());
+     if (fromY >= toY)
+         return;
+ 
+     qreal leftSlope = (bottomLeft.x - topLeft.x) / (bottomLeft.y - topLeft.y);
+     qreal rightSlope = (bottomRight.x - topRight.x) / (bottomRight.y - topRight.y);
+-    int dx_l = int(leftSlope * 0x10000);
+-    int dx_r = int(rightSlope * 0x10000);
+-    int x_l = int((topLeft.x + (qreal(0.5) + fromY - topLeft.y) * leftSlope + qreal(0.5)) * 0x10000);
+-    int x_r = int((topRight.x + (qreal(0.5) + fromY - topRight.y) * rightSlope + qreal(0.5)) * 0x10000);
+-
+-    int fromX, toX, x1, x2, u, v, i, ii;
++    qint64 dx_l = qint64(leftSlope * 0x10000);
++    qint64 dx_r = qint64(rightSlope * 0x10000);
++    qint64 x_l = qint64((topLeft.x + (qreal(0.5) + fromY - topLeft.y) * leftSlope + qreal(0.5)) * 0x10000);
++    qint64 x_r = qint64((topRight.x + (qreal(0.5) + fromY - topRight.y) * rightSlope + qreal(0.5)) * 0x10000);
++
++    qint64 sourceRectTop = qint64(sourceRect.top());
++    qint64 sourceRectLeft = qint64(sourceRect.left());
++    qint64 sourceRectWidth = qint64(sourceRect.width());
++    qint64 sourceRectHeight = qint64(sourceRect.height());
++    qint64 clipLeft = qint64(clip.left());
++    qint64 clipWidth = qint64(clip.width());
++
++    qint64 fromX, toX, x1, x2, u, v, i, ii;
+     DestT *line;
+-    for (int y = fromY; y < toY; ++y) {
++    for (qint64 y = fromY; y < toY; ++y) {
+         line = reinterpret_cast<DestT *>(reinterpret_cast<uchar *>(destPixels) + y * dbpl);
+ 
+-        fromX = qMax(x_l >> 16, clip.left());
+-        toX = qMin(x_r >> 16, clip.left() + clip.width());
++        fromX = qMax(x_l >> 16, clipLeft);
++        toX = qMin(x_r >> 16, clipLeft + clipWidth);
+         if (fromX < toX) {
+             // Because of rounding, we can get source coordinates outside the source image.
+             // Clamp these coordinates to the source rect to avoid segmentation fault and
+@@ -275,10 +282,10 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             u = x1 * dudx + y * dudy + u0;
+             v = x1 * dvdx + y * dvdy + v0;
+             for (; x1 < toX; ++x1) {
+-                int uu = u >> 16;
+-                int vv = v >> 16;
+-                if (uu >= sourceRect.left() && uu < sourceRect.left() + sourceRect.width()
+-                    && vv >= sourceRect.top() && vv < sourceRect.top() + sourceRect.height()) {
++                qint64 uu = u >> 16;
++                qint64 vv = v >> 16;
++                if (uu >= sourceRectLeft && uu < sourceRectLeft + sourceRectWidth
++                    && vv >= sourceRectTop && vv < sourceRectTop + sourceRectHeight) {
+                     break;
+                 }
+                 u += dudx;
+@@ -290,10 +297,10 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             u = (x2 - 1) * dudx + y * dudy + u0;
+             v = (x2 - 1) * dvdx + y * dvdy + v0;
+             for (; x2 > x1; --x2) {
+-                int uu = u >> 16;
+-                int vv = v >> 16;
+-                if (uu >= sourceRect.left() && uu < sourceRect.left() + sourceRect.width()
+-                    && vv >= sourceRect.top() && vv < sourceRect.top() + sourceRect.height()) {
++                qint64 uu = u >> 16;
++                qint64 vv = v >> 16;
++                if (uu >= sourceRectLeft && uu < sourceRectLeft + sourceRectWidth
++                    && vv >= sourceRectTop && vv < sourceRectTop + sourceRectHeight) {
+                     break;
+                 }
+                 u -= dudx;
+@@ -308,8 +315,8 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             // Beginning of the scan line, with per-pixel checks.
+             i = x1 - fromX;
+             while (i) {
+-                int uu = qBound(sourceRect.left(), u >> 16, sourceRect.left() + sourceRect.width() - 1);
+-                int vv = qBound(sourceRect.top(), v >> 16, sourceRect.top() + sourceRect.height() - 1);
++                qint64 uu = qBound(sourceRectLeft, u >> 16, sourceRectLeft + sourceRectWidth - 1);
++                qint64 vv = qBound(sourceRectTop, v >> 16, sourceRectTop + sourceRectHeight - 1);
+                 blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + vv * sbpl)[uu]);
+                 u += dudx;
+                 v += dvdx;
+@@ -348,8 +355,8 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             // End of the scan line, with per-pixel checks.
+             i = toX - x2;
+             while (i) {
+-                int uu = qBound(sourceRect.left(), u >> 16, sourceRect.left() + sourceRect.width() - 1);
+-                int vv = qBound(sourceRect.top(), v >> 16, sourceRect.top() + sourceRect.height() - 1);
++                qint64 uu = qBound(sourceRectLeft, u >> 16, sourceRectLeft + sourceRectWidth - 1);
++                qint64 vv = qBound(sourceRectTop, v >> 16, sourceRectTop + sourceRectHeight - 1);
+                 blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + vv * sbpl)[uu]);
+                 u += dudx;
+                 v += dvdx;
+diff --git a/qtbase/src/gui/painting/qcolortrclut_p.h b/qtbase/src/gui/painting/qcolortrclut_p.h
+index 76a6a60803..24fd522e6c 100644
+--- a/qtbase/src/gui/painting/qcolortrclut_p.h
++++ b/qtbase/src/gui/painting/qcolortrclut_p.h
+@@ -118,6 +118,7 @@ public:
+         return QRgba64::fromRgba64(r, g, b, qAlpha(rgb32) * 257);
+ #endif
+     }
++    QRgba64 toLinear64(QRgba64) const = delete;
+ 
+     QRgb toLinear(QRgb rgb32) const
+     {
+diff --git a/qtbase/src/gui/painting/qdrawhelper.cpp b/qtbase/src/gui/painting/qdrawhelper.cpp
+index a61793508a..5ba2d277b7 100644
+--- a/qtbase/src/gui/painting/qdrawhelper.cpp
++++ b/qtbase/src/gui/painting/qdrawhelper.cpp
+@@ -6091,7 +6091,7 @@ static inline void alphargbblend_argb32(quint32 *dst, uint coverage, const QRgba
+ static inline void rgbBlendPixel(QRgba64 &dst, int coverage, QRgba64 slinear, const QColorTrcLut *colorProfile)
+ {
+     // Do a gammacorrected RGB alphablend...
+-    const QRgba64 dlinear = colorProfile ? colorProfile->toLinear64(dst) : dst;
++    const QRgba64 dlinear = colorProfile ? colorProfile->toLinear(dst) : dst;
+ 
+     QRgba64 blend = rgbBlend(dlinear, slinear, coverage);
+ 
+diff --git a/qtbase/src/gui/painting/qpaintengine_raster.cpp b/qtbase/src/gui/painting/qpaintengine_raster.cpp
+index 283923de52..f08eb9cbee 100644
+--- a/qtbase/src/gui/painting/qpaintengine_raster.cpp
++++ b/qtbase/src/gui/painting/qpaintengine_raster.cpp
+@@ -560,31 +560,6 @@ void QRasterPaintEngine::updateMatrix(const QTransform &matrix)
+     QRasterPaintEngineState *s = state();
+     // FALCON: get rid of this line, see drawImage call below.
+     s->matrix = matrix;
+-    QTransform::TransformationType txop = s->matrix.type();
+-
+-    switch (txop) {
+-
+-    case QTransform::TxNone:
+-        s->flags.int_xform = true;
+-        break;
+-
+-    case QTransform::TxTranslate:
+-        s->flags.int_xform = qreal(int(s->matrix.dx())) == s->matrix.dx()
+-                            && qreal(int(s->matrix.dy())) == s->matrix.dy();
+-        break;
+-
+-    case QTransform::TxScale:
+-        s->flags.int_xform = qreal(int(s->matrix.dx())) == s->matrix.dx()
+-                            && qreal(int(s->matrix.dy())) == s->matrix.dy()
+-                            && qreal(int(s->matrix.m11())) == s->matrix.m11()
+-                            && qreal(int(s->matrix.m22())) == s->matrix.m22();
+-        break;
+-
+-    default: // shear / perspective...
+-        s->flags.int_xform = false;
+-        break;
+-    }
+-
+     s->flags.tx_noshear = qt_scaleForTransform(s->matrix, &s->txscale);
+ 
+     ensureOutlineMapper();
+@@ -617,7 +592,6 @@ QRasterPaintEngineState::QRasterPaintEngineState()
+     flags.bilinear = false;
+     flags.legacy_rounding = false;
+     flags.fast_text = true;
+-    flags.int_xform = true;
+     flags.tx_noshear = true;
+     flags.fast_images = true;
+ 
+@@ -1793,7 +1767,7 @@ void QRasterPaintEngine::fill(const QVectorPath &path, const QBrush &brush)
+     QRectF cpRect = path.controlPointRect();
+     const QRectF pathDeviceRect = s->matrix.mapRect(cpRect);
+     // Skip paths that by conservative estimates are completely outside the paint device.
+-    if (!pathDeviceRect.intersects(QRectF(d->deviceRect)))
++    if (!pathDeviceRect.intersects(QRectF(d->deviceRect)) || !pathDeviceRect.isValid())
+         return;
+ 
+     ProcessSpans blend = d->getBrushFunc(pathDeviceRect, &s->brushData);
+diff --git a/qtbase/src/gui/painting/qpaintengine_raster_p.h b/qtbase/src/gui/painting/qpaintengine_raster_p.h
+index 089aadc3f7..bf7363d5aa 100644
+--- a/qtbase/src/gui/painting/qpaintengine_raster_p.h
++++ b/qtbase/src/gui/painting/qpaintengine_raster_p.h
+@@ -111,7 +111,6 @@ public:
+         uint bilinear : 1;
+         uint legacy_rounding : 1;
+         uint fast_text : 1;
+-        uint int_xform : 1;
+         uint tx_noshear : 1;
+         uint fast_images : 1;
+     };
+diff --git a/qtbase/src/gui/painting/qpainterpath.cpp b/qtbase/src/gui/painting/qpainterpath.cpp
+index f9544a3241..d80fafeaf1 100644
+--- a/qtbase/src/gui/painting/qpainterpath.cpp
++++ b/qtbase/src/gui/painting/qpainterpath.cpp
+@@ -1253,7 +1253,7 @@ void QPainterPath::addText(const QPointF &point, const QFont &f, const QString &
+ 
+         if (si.analysis.flags < QScriptAnalysis::TabOrObject) {
+             QGlyphLayout glyphs = eng->shapedGlyphs(&si);
+-            QFontEngine *fe = f.d->engineForScript(si.analysis.script);
++            QFontEngine *fe = eng->fontEngine(si);
+             Q_ASSERT(fe);
+             fe->addOutlineToPath(x, y, glyphs, this,
+                                  si.analysis.bidiLevel % 2
+diff --git a/qtbase/src/gui/painting/qpathclipper_p.h b/qtbase/src/gui/painting/qpathclipper_p.h
+index 9444a87b71..18f64c5e8c 100644
+--- a/qtbase/src/gui/painting/qpathclipper_p.h
++++ b/qtbase/src/gui/painting/qpathclipper_p.h
+@@ -156,7 +156,7 @@ public:
+     int vertex(Direction direction) const;
+ 
+ private:
+-    int m_next[2][2];
++    int m_next[2][2] = { { -1, -1 }, { -1, -1 } };
+ };
+ 
+ class QPathSegments
+@@ -296,10 +296,6 @@ inline QPathEdge::QPathEdge(int a, int b)
+     , angle(0)
+     , invAngle(0)
+ {
+-    m_next[0][0] = -1;
+-    m_next[1][0] = -1;
+-    m_next[0][0] = -1;
+-    m_next[1][0] = -1;
+ }
+ 
+ inline int QPathEdge::next(Traversal traversal, Direction direction) const
+diff --git a/qtbase/src/gui/painting/qpdf.cpp b/qtbase/src/gui/painting/qpdf.cpp
+index 3066744f1b..2c8d3c3b53 100644
+--- a/qtbase/src/gui/painting/qpdf.cpp
++++ b/qtbase/src/gui/painting/qpdf.cpp
+@@ -2760,6 +2760,8 @@ int QPdfEnginePrivate::addBrushPattern(const QTransform &m, bool *specifyColor,
+         return gradientBrush(brush, matrix, gStateObject);
+     }
+ 
++    matrix = brush.transform() * matrix;
++
+     if ((!brush.isOpaque() && brush.style() < Qt::LinearGradientPattern) || opacity != 1.0)
+         *gStateObject = addConstantAlphaObject(qRound(brush.color().alpha() * opacity),
+                                                qRound(pen.color().alpha() * opacity));
+diff --git a/qtbase/src/gui/painting/qstroker.cpp b/qtbase/src/gui/painting/qstroker.cpp
+index cb5d395e80..3b6357a893 100644
+--- a/qtbase/src/gui/painting/qstroker.cpp
++++ b/qtbase/src/gui/painting/qstroker.cpp
+@@ -1182,6 +1182,7 @@ void QDashStroker::processCurrentSubpath()
+         // Check if the entire line should be clipped away or simplified
+         bool clipIt = clipping && !lineIntersectsRect(prev, e, clip_tl, clip_br);
+         bool skipDashing = elen * invSumLength > repetitionLimit();
++        int maxDashes = dashCount;
+         if (skipDashing || clipIt) {
+             // Cut away full dash sequences.
+             elen -= std::floor(elen * invSumLength) * sumLength;
+@@ -1196,7 +1197,7 @@ void QDashStroker::processCurrentSubpath()
+                     pos = estop; // move pos to next path element
+                     done = true;
+                 } else { // Dash is on this line
+-                    pos = dpos + estart;
++                    pos = --maxDashes > 0 ? dpos + estart : estop;
+                     done = pos >= estop;
+                     if (++idash >= dashCount)
+                         idash = 0;
+diff --git a/qtbase/src/gui/painting/qt_attribution.json b/qtbase/src/gui/painting/qt_attribution.json
+index 7b16e8c211..0e87d30aa2 100644
+--- a/qtbase/src/gui/painting/qt_attribution.json
++++ b/qtbase/src/gui/painting/qt_attribution.json
+@@ -10,7 +10,7 @@
+         "Homepage": "http://www.freetype.org",
+         "License": "Freetype Project License or GNU General Public License v2.0 only",
+         "LicenseId": "FTL or GPL-2.0",
+-        "LicenseFile": "../../3rdparty/freetype/docs/LICENSE.TXT",
++        "LicenseFile": "../../3rdparty/freetype/LICENSE.TXT",
+         "Copyright": "Copyright 2000-2016 by David Turner, Robert Wilhelm, and Werner Lemberg."
+     },
+     {
+diff --git a/qtbase/src/gui/rhi/qshader_p_p.h b/qtbase/src/gui/rhi/qshader_p_p.h
+index ec9d25971f..4a5a7a6d51 100644
+--- a/qtbase/src/gui/rhi/qshader_p_p.h
++++ b/qtbase/src/gui/rhi/qshader_p_p.h
+@@ -68,13 +68,13 @@ struct Q_GUI_EXPORT QShaderPrivate
+     {
+     }
+ 
+-    QShaderPrivate(const QShaderPrivate *other)
++    QShaderPrivate(const QShaderPrivate &other)
+         : ref(1),
+-          qsbVersion(other->qsbVersion),
+-          stage(other->stage),
+-          desc(other->desc),
+-          shaders(other->shaders),
+-          bindings(other->bindings)
++          qsbVersion(other.qsbVersion),
++          stage(other.stage),
++          desc(other.desc),
++          shaders(other.shaders),
++          bindings(other.bindings)
+     {
+     }
+ 
+diff --git a/qtbase/src/gui/rhi/qshaderdescription_p_p.h b/qtbase/src/gui/rhi/qshaderdescription_p_p.h
+index ec2b0b6b4c..3da33a8a2b 100644
+--- a/qtbase/src/gui/rhi/qshaderdescription_p_p.h
++++ b/qtbase/src/gui/rhi/qshaderdescription_p_p.h
+@@ -63,16 +63,16 @@ struct Q_GUI_EXPORT QShaderDescriptionPrivate
+         localSize[0] = localSize[1] = localSize[2] = 0;
+     }
+ 
+-    QShaderDescriptionPrivate(const QShaderDescriptionPrivate *other)
++    QShaderDescriptionPrivate(const QShaderDescriptionPrivate &other)
+         : ref(1),
+-          inVars(other->inVars),
+-          outVars(other->outVars),
+-          uniformBlocks(other->uniformBlocks),
+-          pushConstantBlocks(other->pushConstantBlocks),
+-          storageBlocks(other->storageBlocks),
+-          combinedImageSamplers(other->combinedImageSamplers),
+-          storageImages(other->storageImages),
+-          localSize(other->localSize)
++          inVars(other.inVars),
++          outVars(other.outVars),
++          uniformBlocks(other.uniformBlocks),
++          pushConstantBlocks(other.pushConstantBlocks),
++          storageBlocks(other.storageBlocks),
++          combinedImageSamplers(other.combinedImageSamplers),
++          storageImages(other.storageImages),
++          localSize(other.localSize)
+     {
+     }
+ 
+diff --git a/qtbase/src/gui/text/qfontdatabase.cpp b/qtbase/src/gui/text/qfontdatabase.cpp
+index a657a8c516..4fc0100958 100644
+--- a/qtbase/src/gui/text/qfontdatabase.cpp
++++ b/qtbase/src/gui/text/qfontdatabase.cpp
+@@ -983,7 +983,7 @@ QFontEngine *loadSingleEngine(int script,
+         if (style->key.stretch != 0 && request.stretch != 0
+             && (request.styleName.isEmpty() || request.styleName != style->styleName)) {
+             def.stretch = (request.stretch * 100 + style->key.stretch / 2) / style->key.stretch;
+-        } else {
++        } else if (request.stretch == QFont::AnyStretch) {
+             def.stretch = 100;
+         }
+ 
+diff --git a/qtbase/src/gui/text/qtextdocumentlayout.cpp b/qtbase/src/gui/text/qtextdocumentlayout.cpp
+index f3e6ea2100..72267e9380 100644
+--- a/qtbase/src/gui/text/qtextdocumentlayout.cpp
++++ b/qtbase/src/gui/text/qtextdocumentlayout.cpp
+@@ -2123,7 +2123,7 @@ void QTextDocumentLayoutPrivate::drawListItem(const QPointF &offset, QPainter *p
+ {
+     Q_Q(const QTextDocumentLayout);
+     const QTextBlockFormat blockFormat = bl.blockFormat();
+-    const QTextCharFormat charFormat = QTextCursor(bl).charFormat();
++    const QTextCharFormat charFormat = bl.charFormat();
+     QFont font(charFormat.font());
+     if (q->paintDevice())
+         font = QFont(font, q->paintDevice());
+diff --git a/qtbase/src/gui/text/qtextengine.cpp b/qtbase/src/gui/text/qtextengine.cpp
+index ce4abac472..a6c66e5d2d 100644
+--- a/qtbase/src/gui/text/qtextengine.cpp
++++ b/qtbase/src/gui/text/qtextengine.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2021 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtGui module of the Qt Toolkit.
+@@ -1565,6 +1565,12 @@ void QTextEngine::shapeText(int item) const
+         // Overwrite with 0 token to indicate failure
+         QGlyphLayout g = availableGlyphs(&si);
+         g.glyphs[0] = 0;
++        g.attributes[0].clusterStart = true;
++
++        ushort *log_clusters = logClusters(&si);
++        for (int i = 0; i < itemLength; ++i)
++            log_clusters[i] = 0;
++
+         return;
+     }
+ 
+diff --git a/qtbase/src/gui/util/qdesktopservices.cpp b/qtbase/src/gui/util/qdesktopservices.cpp
+index fbb63a9408..4d5fafaaa7 100644
+--- a/qtbase/src/gui/util/qdesktopservices.cpp
++++ b/qtbase/src/gui/util/qdesktopservices.cpp
+@@ -54,6 +54,8 @@
+ #include <qpa/qplatformintegration.h>
+ #include <qdir.h>
+ 
++#include <QtCore/private/qlocking_p.h>
++
+ QT_BEGIN_NAMESPACE
+ 
+ class QOpenUrlHandlerRegistry : public QObject
+@@ -81,6 +83,7 @@ Q_GLOBAL_STATIC(QOpenUrlHandlerRegistry, handlerRegistry)
+ 
+ void QOpenUrlHandlerRegistry::handlerDestroyed(QObject *handler)
+ {
++    const auto lock = qt_scoped_lock(mutex);
+     HandlerHash::Iterator it = handlers.begin();
+     while (it != handlers.end()) {
+         if (it->receiver == handler) {
+@@ -294,7 +297,8 @@ void QDesktopServices::setUrlHandler(const QString &scheme, QObject *receiver, c
+     h.name = method;
+     registry->handlers.insert(scheme.toLower(), h);
+     QObject::connect(receiver, SIGNAL(destroyed(QObject*)),
+-                     registry, SLOT(handlerDestroyed(QObject*)));
++                     registry, SLOT(handlerDestroyed(QObject*)),
++                     Qt::DirectConnection);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/gui/util/qpkmhandler.cpp b/qtbase/src/gui/util/qpkmhandler.cpp
+index e0c3b75efe..3414f9d8ba 100644
+--- a/qtbase/src/gui/util/qpkmhandler.cpp
++++ b/qtbase/src/gui/util/qpkmhandler.cpp
+@@ -57,7 +57,7 @@ struct PkmType
+     quint32 bytesPerBlock;
+ };
+ 
+-static PkmType typeMap[5] = {
++static constexpr PkmType typeMap[5] = {
+     { 0x8D64,  8 },   // GL_ETC1_RGB8_OES
+     { 0x9274,  8 },   // GL_COMPRESSED_RGB8_ETC2
+     { 0, 0 },         // unused (obsolete)
+diff --git a/qtbase/src/network/access/qnetworkreplyfileimpl.cpp b/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
+index b6be93147a..6e69b4c4d3 100644
+--- a/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
++++ b/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
+@@ -89,9 +89,10 @@ QNetworkReplyFileImpl::QNetworkReplyFileImpl(QNetworkAccessManager *manager, con
+         // we handle only local files
+         QString msg = QCoreApplication::translate("QNetworkAccessFileBackend", "Request for opening non-local file %1").arg(url.toString());
+         setError(QNetworkReply::ProtocolInvalidOperationError, msg);
++        setFinished(true); // We're finished, will emit finished() after ctor is done.
+         QMetaObject::invokeMethod(this, "errorOccurred", Qt::QueuedConnection,
+             Q_ARG(QNetworkReply::NetworkError, QNetworkReply::ProtocolInvalidOperationError));
+-        fileOpenFinished(false);
++        QMetaObject::invokeMethod(this, [this](){ fileOpenFinished(false); }, Qt::QueuedConnection);
+         return;
+     }
+ #endif
+diff --git a/qtbase/src/network/access/qnetworkreplyimpl.cpp b/qtbase/src/network/access/qnetworkreplyimpl.cpp
+index bcdf6ee2f1..3b6deb82bd 100644
+--- a/qtbase/src/network/access/qnetworkreplyimpl.cpp
++++ b/qtbase/src/network/access/qnetworkreplyimpl.cpp
+@@ -680,7 +680,7 @@ void QNetworkReplyImplPrivate::appendDownstreamData(QIODevice *data)
+     // read until EOF from data
+     if (Q_UNLIKELY(copyDevice)) {
+         qCritical("QNetworkReplyImpl: copy from QIODevice already in progress -- "
+-                  "backend probly needs to be fixed");
++                  "backend probably needs to be fixed");
+         return;
+     }
+ 
+diff --git a/qtbase/src/network/kernel/qauthenticator.cpp b/qtbase/src/network/kernel/qauthenticator.cpp
+index d9fe7bc47b..ccd04b294a 100644
+--- a/qtbase/src/network/kernel/qauthenticator.cpp
++++ b/qtbase/src/network/kernel/qauthenticator.cpp
+@@ -50,6 +50,7 @@
+ #include <qstring.h>
+ #include <qdatetime.h>
+ #include <qrandom.h>
++#include "private/qsystemlibrary_p.h"
+ 
+ #ifdef Q_OS_WIN
+ #include <qmutex.h>
+@@ -1563,7 +1564,7 @@ static bool q_SSPI_library_load()
+ 
+     // Initialize security interface
+     if (pSecurityFunctionTable == nullptr) {
+-        securityDLLHandle = LoadLibrary(L"secur32.dll");
++        securityDLLHandle = QSystemLibrary::load(L"secur32");
+         if (securityDLLHandle != nullptr) {
+             INIT_SECURITY_INTERFACE pInitSecurityInterface =
+                 reinterpret_cast<INIT_SECURITY_INTERFACE>(
+diff --git a/qtbase/src/network/kernel/qhostinfo_unix.cpp b/qtbase/src/network/kernel/qhostinfo_unix.cpp
+index 9b0a2ee669..73679c9ef1 100644
+--- a/qtbase/src/network/kernel/qhostinfo_unix.cpp
++++ b/qtbase/src/network/kernel/qhostinfo_unix.cpp
+@@ -122,7 +122,6 @@ static QFunctionPointer resolveSymbol(QLibrary &lib, const char *sym)
+ 
+ LibResolv::LibResolv()
+ {
+-    QLibrary lib;
+ #ifdef LIBRESOLV_SO
+     lib.setFileName(QStringLiteral(LIBRESOLV_SO));
+     if (!lib.load())
+diff --git a/qtbase/src/network/socket/qsocks5socketengine.cpp b/qtbase/src/network/socket/qsocks5socketengine.cpp
+index 3a046fd116..97fadca0b3 100644
+--- a/qtbase/src/network/socket/qsocks5socketengine.cpp
++++ b/qtbase/src/network/socket/qsocks5socketengine.cpp
+@@ -1296,7 +1296,7 @@ void QSocks5SocketEnginePrivate::_q_udpSocketReadNotification()
+         int pos = 0;
+         const char *buf = inBuf.constData();
+         if (inBuf.size() < 4) {
+-            QSOCKS5_D_DEBUG << "bugus udp data, discarding";
++            QSOCKS5_D_DEBUG << "bogus udp data, discarding";
+             return;
+         }
+         QSocks5RevivedDatagram datagram;
+diff --git a/qtbase/src/network/ssl/qsslcontext_openssl.cpp b/qtbase/src/network/ssl/qsslcontext_openssl.cpp
+index c9f202f573..c992da9d8e 100644
+--- a/qtbase/src/network/ssl/qsslcontext_openssl.cpp
++++ b/qtbase/src/network/ssl/qsslcontext_openssl.cpp
+@@ -409,7 +409,7 @@ init_context:
+         break;
+     case QSsl::DtlsV1_0OrLater:
+         minVersion = DTLS1_VERSION;
+-        maxVersion = DTLS_MAX_VERSION;
++        maxVersion = 0;
+         break;
+     case QSsl::DtlsV1_2:
+         minVersion = DTLS1_2_VERSION;
+@@ -417,7 +417,7 @@ init_context:
+         break;
+     case QSsl::DtlsV1_2OrLater:
+         minVersion = DTLS1_2_VERSION;
+-        maxVersion = DTLS_MAX_VERSION;
++        maxVersion = 0;
+         break;
+     case QSsl::TlsV1_3OrLater:
+ #ifdef TLS1_3_VERSION
+@@ -455,7 +455,7 @@ init_context:
+     }
+ 
+     // Enable bug workarounds.
+-    long options = QSslSocketBackendPrivate::setupOpenSslOptions(configuration.protocol(), configuration.d->sslOptions);
++    qssloptions options = QSslSocketBackendPrivate::setupOpenSslOptions(configuration.protocol(), configuration.d->sslOptions);
+     q_SSL_CTX_set_options(sslContext->ctx, options);
+ 
+     // Tell OpenSSL to release memory early
+diff --git a/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp b/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
+index aaf8741130..b58935372c 100644
+--- a/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
++++ b/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
+@@ -59,57 +59,6 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-#ifdef OPENSSL_NO_DEPRECATED_3_0
+-
+-static int q_DH_check(DH *dh, int *status)
+-{
+-    // DH_check was first deprecated in OpenSSL 3.0.0, as low-level
+-    // API; the EVP_PKEY family of functions was advised as an alternative.
+-    // As of now EVP_PKEY_params_check ends up calling ... DH_check,
+-    // which is good enough.
+-
+-    Q_ASSERT(dh);
+-    Q_ASSERT(status);
+-
+-    EVP_PKEY *key = q_EVP_PKEY_new();
+-    if (!key) {
+-        qCWarning(lcSsl, "EVP_PKEY_new failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-    const auto keyDeleter = qScopeGuard([key](){
+-        q_EVP_PKEY_free(key);
+-    });
+-    if (!q_EVP_PKEY_set1_DH(key, dh)) {
+-        qCWarning(lcSsl, "EVP_PKEY_set1_DH failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-
+-    EVP_PKEY_CTX *keyCtx = q_EVP_PKEY_CTX_new(key, nullptr);
+-    if (!keyCtx) {
+-        qCWarning(lcSsl, "EVP_PKEY_CTX_new failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-    const auto ctxDeleter = qScopeGuard([keyCtx]{
+-        q_EVP_PKEY_CTX_free(keyCtx);
+-    });
+-
+-    const int result = q_EVP_PKEY_param_check(keyCtx);
+-    QSslSocketBackendPrivate::logAndClearErrorQueue();
+-    // Note: unlike DH_check, we cannot obtain the 'status',
+-    // if the 'result' is 0 (actually the result is 1 only
+-    // if this 'status' was 0). We could probably check the
+-    // errors from the error queue, but it's not needed anyway
+-    // - see the 'isSafeDH' below, how it returns immediately
+-    // on 0.
+-    Q_UNUSED(status)
+-
+-    return result;
+-}
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+-
+ static bool isSafeDH(DH *dh)
+ {
+     int status = 0;
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl.cpp b/qtbase/src/network/ssl/qsslsocket_openssl.cpp
+index 37fad2a68f..8f6858c867 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl.cpp
++++ b/qtbase/src/network/ssl/qsslsocket_openssl.cpp
+@@ -550,9 +550,9 @@ static void q_loadCiphersForConnection(SSL *connection, QList<QSslCipher> &ciphe
+ // Defined in qsslsocket.cpp
+ void q_setDefaultDtlsCiphers(const QList<QSslCipher> &ciphers);
+ 
+-long QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions)
++qssloptions QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions)
+ {
+-    long options;
++    qssloptions options;
+     if (protocol == QSsl::TlsV1SslV3)
+         options = SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3;
+     else if (protocol == QSsl::SecureProtocols)
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_p.h b/qtbase/src/network/ssl/qsslsocket_openssl_p.h
+index 4103de23e8..5547589256 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_p.h
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_p.h
+@@ -107,6 +107,12 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++typedef uint64_t qssloptions;
++#else
++typedef unsigned long qssloptions;
++#endif
++
+ struct QSslErrorEntry {
+     int code;
+     int depth;
+@@ -171,7 +177,7 @@ public:
+     QVector<QSslError> ocspErrors;
+     QByteArray ocspResponseDer;
+ 
+-    Q_AUTOTEST_EXPORT static long setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions);
++    Q_AUTOTEST_EXPORT static qssloptions setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions);
+     static QSslCipher QSslCipher_from_SSL_CIPHER(const SSL_CIPHER *cipher);
+     static QList<QSslCertificate> STACKOFX509_to_QSslCertificates(STACK_OF(X509) *x509);
+     static QList<QSslError> verify(const QList<QSslCertificate> &certificateChain, const QString &hostName);
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp b/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
+index e53fb279f0..459ccd0b19 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
+@@ -148,7 +148,6 @@ DEFINEFUNC(int, EVP_PKEY_up_ref, EVP_PKEY *a, a, return 0, return)
+ DEFINEFUNC2(EVP_PKEY_CTX *, EVP_PKEY_CTX_new, EVP_PKEY *pkey, pkey, ENGINE *e, e, return nullptr, return)
+ DEFINEFUNC(int, EVP_PKEY_param_check, EVP_PKEY_CTX *ctx, ctx, return 0, return)
+ DEFINEFUNC(void, EVP_PKEY_CTX_free, EVP_PKEY_CTX *ctx, ctx, return, return)
+-DEFINEFUNC(int, EVP_PKEY_base_id, EVP_PKEY *a, a, return NID_undef, return)
+ DEFINEFUNC(int, RSA_bits, RSA *a, a, return 0, return)
+ DEFINEFUNC(int, DSA_bits, DSA *a, a, return 0, return)
+ DEFINEFUNC(int, OPENSSL_sk_num, OPENSSL_STACK *a, a, return -1, return)
+@@ -158,7 +157,7 @@ DEFINEFUNC2(void, OPENSSL_sk_push, OPENSSL_STACK *a, a, void *b, b, return, DUMM
+ DEFINEFUNC(void, OPENSSL_sk_free, OPENSSL_STACK *a, a, return, DUMMYARG)
+ DEFINEFUNC2(void *, OPENSSL_sk_value, OPENSSL_STACK *a, a, int b, b, return nullptr, return)
+ DEFINEFUNC(int, SSL_session_reused, SSL *a, a, return 0, return)
+-DEFINEFUNC2(unsigned long, SSL_CTX_set_options, SSL_CTX *ctx, ctx, unsigned long op, op, return 0, return)
++DEFINEFUNC2(qssloptions, SSL_CTX_set_options, SSL_CTX *ctx, ctx, qssloptions op, op, return 0, return)
+ DEFINEFUNC(int, SSL_CTX_get_security_level, const SSL_CTX *ctx, ctx, return -1, return)
+ DEFINEFUNC2(void, SSL_CTX_set_security_level, SSL_CTX *ctx, ctx, int level, level, return, return)
+ #ifdef TLS1_3_VERSION
+@@ -371,7 +370,15 @@ DEFINEFUNC(const SSL_CIPHER *, SSL_get_current_cipher, SSL *a, a, return nullptr
+ DEFINEFUNC(int, SSL_version, const SSL *a, a, return 0, return)
+ DEFINEFUNC2(int, SSL_get_error, SSL *a, a, int b, b, return -1, return)
+ DEFINEFUNC(STACK_OF(X509) *, SSL_get_peer_cert_chain, SSL *a, a, return nullptr, return)
++
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++DEFINEFUNC(X509 *, SSL_get1_peer_certificate, SSL *a, a, return nullptr, return)
++DEFINEFUNC(int, EVP_PKEY_get_base_id, const EVP_PKEY *pkey, pkey, return -1, return)
++#else
+ DEFINEFUNC(X509 *, SSL_get_peer_certificate, SSL *a, a, return nullptr, return)
++DEFINEFUNC(int, EVP_PKEY_base_id, EVP_PKEY *a, a, return NID_undef, return)
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+ DEFINEFUNC(long, SSL_get_verify_result, const SSL *a, a, return -1, return)
+ DEFINEFUNC(SSL *, SSL_new, SSL_CTX *a, a, return nullptr, return)
+ DEFINEFUNC(SSL_CTX *, SSL_get_SSL_CTX, SSL *a, a, return nullptr, return)
+@@ -492,9 +499,7 @@ DEFINEFUNC(DH *, DH_new, DUMMYARG, DUMMYARG, return nullptr, return)
+ DEFINEFUNC(void, DH_free, DH *dh, dh, return, DUMMYARG)
+ DEFINEFUNC3(DH *, d2i_DHparams, DH**a, a, const unsigned char **pp, pp, long length, length, return nullptr, return)
+ DEFINEFUNC2(int, i2d_DHparams, DH *a, a, unsigned char **p, p, return -1, return)
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+ DEFINEFUNC2(int, DH_check, DH *dh, dh, int *codes, codes, return 0, return)
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+ DEFINEFUNC3(BIGNUM *, BN_bin2bn, const unsigned char *s, s, int len, len, BIGNUM *ret, ret, return nullptr, return)
+ 
+ #ifndef OPENSSL_NO_EC
+@@ -868,7 +873,6 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(EVP_PKEY_CTX_new)
+     RESOLVEFUNC(EVP_PKEY_param_check)
+     RESOLVEFUNC(EVP_PKEY_CTX_free)
+-    RESOLVEFUNC(EVP_PKEY_base_id)
+     RESOLVEFUNC(RSA_bits)
+     RESOLVEFUNC(OPENSSL_sk_new_null)
+     RESOLVEFUNC(OPENSSL_sk_push)
+@@ -1107,7 +1111,15 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(SSL_version)
+     RESOLVEFUNC(SSL_get_error)
+     RESOLVEFUNC(SSL_get_peer_cert_chain)
++
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++    RESOLVEFUNC(SSL_get1_peer_certificate)
++    RESOLVEFUNC(EVP_PKEY_get_base_id)
++#else
+     RESOLVEFUNC(SSL_get_peer_certificate)
++    RESOLVEFUNC(EVP_PKEY_base_id)
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+     RESOLVEFUNC(SSL_get_verify_result)
+     RESOLVEFUNC(SSL_new)
+     RESOLVEFUNC(SSL_get_SSL_CTX)
+@@ -1206,9 +1218,7 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(DH_free)
+     RESOLVEFUNC(d2i_DHparams)
+     RESOLVEFUNC(i2d_DHparams)
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+     RESOLVEFUNC(DH_check)
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+     RESOLVEFUNC(BN_bin2bn)
+ 
+ #ifndef OPENSSL_NO_EC
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h b/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
+index 95e8897a3b..27aeffa18a 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
+@@ -237,7 +237,6 @@ Q_AUTOTEST_EXPORT int q_EVP_PKEY_up_ref(EVP_PKEY *a);
+ EVP_PKEY_CTX *q_EVP_PKEY_CTX_new(EVP_PKEY *pkey, ENGINE *e);
+ void q_EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx);
+ int q_EVP_PKEY_param_check(EVP_PKEY_CTX *ctx);
+-int q_EVP_PKEY_base_id(EVP_PKEY *a);
+ int q_RSA_bits(RSA *a);
+ Q_AUTOTEST_EXPORT int q_OPENSSL_sk_num(OPENSSL_STACK *a);
+ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_pop_free(OPENSSL_STACK *a, void (*b)(void *));
+@@ -246,7 +245,7 @@ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_push(OPENSSL_STACK *st, void *data);
+ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_free(OPENSSL_STACK *a);
+ Q_AUTOTEST_EXPORT void * q_OPENSSL_sk_value(OPENSSL_STACK *a, int b);
+ int q_SSL_session_reused(SSL *a);
+-unsigned long q_SSL_CTX_set_options(SSL_CTX *ctx, unsigned long op);
++qssloptions q_SSL_CTX_set_options(SSL_CTX *ctx, qssloptions op);
+ int q_OPENSSL_init_ssl(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings);
+ size_t q_SSL_get_client_random(SSL *a, unsigned char *out, size_t outlen);
+ size_t q_SSL_SESSION_get_master_key(const SSL_SESSION *session, unsigned char *out, size_t outlen);
+@@ -510,7 +509,6 @@ const SSL_CIPHER *q_SSL_get_current_cipher(SSL *a);
+ int q_SSL_version(const SSL *a);
+ int q_SSL_get_error(SSL *a, int b);
+ STACK_OF(X509) *q_SSL_get_peer_cert_chain(SSL *a);
+-X509 *q_SSL_get_peer_certificate(SSL *a);
+ long q_SSL_get_verify_result(const SSL *a);
+ SSL *q_SSL_new(SSL_CTX *a);
+ SSL_CTX *q_SSL_get_SSL_CTX(SSL *a);
+@@ -582,10 +580,7 @@ DH *q_DH_new();
+ void q_DH_free(DH *dh);
+ DH *q_d2i_DHparams(DH **a, const unsigned char **pp, long length);
+ int q_i2d_DHparams(DH *a, unsigned char **p);
+-
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+ int q_DH_check(DH *dh, int *codes);
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+ 
+ BIGNUM *q_BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret);
+ #define q_SSL_CTX_set_tmp_dh(ctx, dh) q_SSL_CTX_ctrl((ctx), SSL_CTRL_SET_TMP_DH, 0, (char *)dh)
+@@ -754,6 +749,17 @@ void q_CRYPTO_free(void *str, const char *file, int line);
+ int q_SSL_CTX_get_security_level(const SSL_CTX *ctx);
+ void q_SSL_CTX_set_security_level(SSL_CTX *ctx, int level);
+ 
++// Here we have the ones that make difference between OpenSSL pre/post v3:
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++X509 *q_SSL_get1_peer_certificate(SSL *a);
++#define q_SSL_get_peer_certificate q_SSL_get1_peer_certificate
++int q_EVP_PKEY_get_base_id(const EVP_PKEY *pkey);
++#define q_EVP_PKEY_base_id q_EVP_PKEY_get_base_id
++#else
++X509 *q_SSL_get_peer_certificate(SSL *a);
++int q_EVP_PKEY_base_id(EVP_PKEY *a);
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+ QT_END_NAMESPACE
+ 
+ #endif
+diff --git a/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h b/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
+index bf37d07fd8..dbd42fb799 100644
+--- a/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
++++ b/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
+@@ -61,7 +61,11 @@
+ # if !defined(Q_OS_INTEGRITY)
+ #  define WIN_INTERFACE_CUSTOM   // NV
+ # endif // Q_OS_INTEGRITY
+-#endif  // QT_EGL_NO_X11
++#else // QT_EGL_NO_X11
++// If one has an eglplatform.h with https://github.com/KhronosGroup/EGL-Registry/pull/130
++// that needs USE_X11 to be defined.
++# define USE_X11
++#endif
+ 
+ #ifdef QT_EGL_WAYLAND
+ # define WAYLAND // NV
+diff --git a/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+index 159b490ce0..00aa80cd58 100644
+--- a/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
++++ b/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+@@ -567,6 +567,8 @@ void QFontconfigDatabase::populateFontDatabase()
+         fonts = FcFontList(nullptr, pattern, os);
+         FcObjectSetDestroy(os);
+         FcPatternDestroy(pattern);
++        if (!fonts)
++            return;
+     }
+ 
+     for (int i = 0; i < fonts->nfont; i++)
+diff --git a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
+index b713c19447..7cb9a8c79a 100644
+--- a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
++++ b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
+@@ -95,6 +95,7 @@ static constexpr const auto KeyTbl = qMakeArray(
+         Xkb2Qt<XKB_KEY_Clear,                   Qt::Key_Delete>,
+         Xkb2Qt<XKB_KEY_Pause,                   Qt::Key_Pause>,
+         Xkb2Qt<XKB_KEY_Print,                   Qt::Key_Print>,
++        Xkb2Qt<XKB_KEY_Sys_Req,                 Qt::Key_SysReq>,
+         Xkb2Qt<0x1005FF60,                      Qt::Key_SysReq>,         // hardcoded Sun SysReq
+         Xkb2Qt<0x1007ff00,                      Qt::Key_SysReq>,         // hardcoded X386 SysReq
+ 
+@@ -471,7 +472,7 @@ QVector<xkb_keysym_t> QXkbCommon::toKeysym(QKeyEvent *event)
+     } else if (event->modifiers() & Qt::KeypadModifier) {
+         if (qtKey >= Qt::Key_0 && qtKey <= Qt::Key_9)
+             keysyms.append(XKB_KEY_KP_0 + (qtKey - Qt::Key_0));
+-    } else if (isLatin(qtKey) && event->text().isUpper()) {
++    } else if (isLatin1(qtKey) && event->text().isUpper()) {
+         keysyms.append(qtKey);
+     }
+ 
+@@ -523,7 +524,7 @@ int QXkbCommon::keysymToQtKey(xkb_keysym_t keysym, Qt::KeyboardModifiers modifie
+         // With standard shortcuts we should prefer a latin character, this is
+         // for checks like "some qkeyevent == QKeySequence::Copy" to work even
+         // when using for example 'russian' keyboard layout.
+-        if (!QXkbCommon::isLatin(keysym)) {
++        if (!QXkbCommon::isLatin1(keysym)) {
+             xkb_keysym_t latinKeysym = QXkbCommon::lookupLatinKeysym(state, code);
+             if (latinKeysym != XKB_KEY_NoSymbol)
+                 keysym = latinKeysym;
+@@ -546,7 +547,7 @@ static int keysymToQtKey_internal(xkb_keysym_t keysym, Qt::KeyboardModifiers mod
+     } else if (keysym >= XKB_KEY_KP_0 && keysym <= XKB_KEY_KP_9) {
+         // numeric keypad keys
+         qtKey = Qt::Key_0 + (keysym - XKB_KEY_KP_0);
+-    } else if (QXkbCommon::isLatin(keysym)) {
++    } else if (QXkbCommon::isLatin1(keysym)) {
+         qtKey = QXkbCommon::qxkbcommon_xkb_keysym_to_upper(keysym);
+     } else {
+         // check if we have a direct mapping
+@@ -678,7 +679,7 @@ QList<int> QXkbCommon::possibleKeys(xkb_state *state, const QKeyEvent *event,
+         Qt::KeyboardModifiers neededMods = ModsTbl[i];
+         if ((modifiers & neededMods) == neededMods) {
+             if (i == 8) {
+-                if (isLatin(baseQtKey))
++                if (isLatin1(baseQtKey))
+                     continue;
+                 // add a latin key as a fall back key
+                 sym = lookupLatinKeysym(state, keycode);
+@@ -733,7 +734,7 @@ void QXkbCommon::verifyHasLatinLayout(xkb_keymap *keymap)
+     for (xkb_layout_index_t layout = 0; layout < layoutCount; ++layout) {
+         for (xkb_keycode_t code = minKeycode; code < maxKeycode; ++code) {
+             xkb_keymap_key_get_syms_by_level(keymap, code, layout, 0, &keysyms);
+-            if (keysyms && isLatin(keysyms[0]))
++            if (keysyms && isLatin1(keysyms[0]))
+                 nrLatinKeys++;
+             if (nrLatinKeys > 10) // arbitrarily chosen threshold
+                 return;
+@@ -766,7 +767,7 @@ xkb_keysym_t QXkbCommon::lookupLatinKeysym(xkb_state *state, xkb_keycode_t keyco
+         xkb_level_index_t level = xkb_state_key_get_level(state, keycode, layout);
+         if (xkb_keymap_key_get_syms_by_level(keymap, keycode, layout, level, &syms) != 1)
+             continue;
+-        if (isLatin(syms[0])) {
++        if (isLatin1(syms[0])) {
+             sym = syms[0];
+             break;
+         }
+diff --git a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
+index 561eae03db..8389bd8f5a 100644
+--- a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
++++ b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
+@@ -94,8 +94,8 @@ public:
+     static void verifyHasLatinLayout(xkb_keymap *keymap);
+     static xkb_keysym_t lookupLatinKeysym(xkb_state *state, xkb_keycode_t keycode);
+ 
+-    static bool isLatin(xkb_keysym_t sym) {
+-        return ((sym >= 'a' && sym <= 'z') || (sym >= 'A' && sym <= 'Z'));
++    static bool isLatin1(xkb_keysym_t sym) {
++        return sym <= 0xff;
+     }
+     static bool isKeypad(xkb_keysym_t sym) {
+         return sym >= XKB_KEY_KP_Space && sym <= XKB_KEY_KP_9;
+diff --git a/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp b/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
+index 8cd7f9b368..406f84663f 100644
+--- a/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
++++ b/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
+@@ -318,7 +318,7 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources,
+ 
+     if (current < 0 && crtc_mode.clock != 0) {
+         modes << crtc_mode;
+-        current = mode.size() - 1;
++        current = modes.size() - 1;
+     }
+ 
+     if (configuration == OutputConfigCurrent)
+diff --git a/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp b/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
+index 9153fd20bb..255ea5e33e 100644
+--- a/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
++++ b/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
+@@ -194,6 +194,9 @@ QString AtSpiAdaptor::introspect(const QString &path) const
+                 "      <arg direction=\"out\" type=\"(so)\"/>\n"
+                 "      <annotation value=\"QSpiObjectReference\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n"
+                 "    </method>\n"
++                "    <method name=\"GetAccessibleId\">\n"
++                "      <arg direction=\"out\" type=\"s\"/>\n"
++                "    </method>\n"
+                 "  </interface>\n"
+                 );
+ 
+@@ -913,8 +916,17 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+     }
+     case QAccessible::NameChanged: {
+         if (sendObject || sendObject_property_change || sendObject_property_change_accessible_name) {
+-            QString path = pathForInterface(event->accessibleInterface());
+-            QVariantList args = packDBusSignalArguments(QLatin1String("accessible-name"), 0, 0, variantForPath(path));
++            QAccessibleInterface *iface = event->accessibleInterface();
++            if (!iface) {
++                qCDebug(lcAccessibilityAtspi,
++                        "NameChanged event from invalid accessible.");
++                return;
++            }
++
++            QString path = pathForInterface(iface);
++            QVariantList args = packDBusSignalArguments(
++                QLatin1String("accessible-name"), 0, 0,
++                QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Name))));
+             sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                            QLatin1String("PropertyChange"), args);
+         }
+@@ -922,8 +934,17 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+     }
+     case QAccessible::DescriptionChanged: {
+         if (sendObject || sendObject_property_change || sendObject_property_change_accessible_description) {
+-            QString path = pathForInterface(event->accessibleInterface());
+-            QVariantList args = packDBusSignalArguments(QLatin1String("accessible-description"), 0, 0, variantForPath(path));
++            QAccessibleInterface *iface = event->accessibleInterface();
++            if (!iface) {
++                qCDebug(lcAccessibilityAtspi,
++                        "DescriptionChanged event from invalid accessible.");
++                return;
++            }
++
++            QString path = pathForInterface(iface);
++            QVariantList args = packDBusSignalArguments(
++                QLatin1String("accessible-description"), 0, 0,
++                QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Description))));
+             sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                            QLatin1String("PropertyChange"), args);
+         }
+@@ -1038,7 +1059,9 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+                 // Combo Box with AT-SPI likes to be special
+                 // It requires a name-change to update caches and then selection-changed
+                 QString path = pathForInterface(iface);
+-                QVariantList args1 = packDBusSignalArguments(QLatin1String("accessible-name"), 0, 0, variantForPath(path));
++                QVariantList args1 = packDBusSignalArguments(
++                    QLatin1String("accessible-name"), 0, 0,
++                    QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Name))));
+                 sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                                QLatin1String("PropertyChange"), args1);
+                 QVariantList args2 = packDBusSignalArguments(QString(), 0, 0, QVariant::fromValue(QDBusVariant(QVariant(0))));
+@@ -1358,6 +1381,26 @@ void AtSpiAdaptor::registerApplication()
+     delete registry;
+ }
+ 
++namespace {
++QString accessibleIdForAccessible(QAccessibleInterface *accessible)
++{
++    QString result;
++    while (accessible) {
++        if (!result.isEmpty())
++            result.prepend(QLatin1Char('.'));
++        if (auto obj = accessible->object()) {
++            const QString name = obj->objectName();
++            if (!name.isEmpty())
++                result.prepend(name);
++            else
++                result.prepend(QString::fromUtf8(obj->metaObject()->className()));
++        }
++        accessible = accessible->parent();
++    }
++    return result;
++}
++} // namespace
++
+ // Accessible
+ bool AtSpiAdaptor::accessibleInterface(QAccessibleInterface *interface, const QString &function, const QDBusMessage &message, const QDBusConnection &connection)
+ {
+@@ -1441,6 +1484,9 @@ bool AtSpiAdaptor::accessibleInterface(QAccessibleInterface *interface, const QS
+             children << ref;
+         }
+         connection.send(message.createReply(QVariant::fromValue(children)));
++    } else if (function == QLatin1String("GetAccessibleId")) {
++        sendReply(connection, message,
++                  QVariant::fromValue(QDBusVariant(accessibleIdForAccessible(interface))));
+     } else {
+         qCDebug(lcAccessibilityAtspi) << "WARNING: AtSpiAdaptor::accessibleInterface does not implement " << function << message.path();
+         return false;
+diff --git a/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp b/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
+index 45ddc8e496..cc734abc63 100644
+--- a/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
++++ b/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
+@@ -69,6 +69,21 @@ QT_BEGIN_NAMESPACE
+ DBusConnection::DBusConnection(QObject *parent)
+     : QObject(parent), m_a11yConnection(QString()), m_enabled(false)
+ {
++    // If the bus is explicitly set via env var it overrides everything else.
++    QByteArray addressEnv = qgetenv("AT_SPI_BUS_ADDRESS");
++    if (!addressEnv.isEmpty()) {
++        // Only connect on next loop run, connections to our enabled signal are
++        // only established after the ctor returns.
++        QMetaObject::invokeMethod(
++                this,
++                [this, addressEnv] {
++                    m_enabled = true;
++                    connectA11yBus(QString::fromLocal8Bit(addressEnv));
++                },
++                Qt::QueuedConnection);
++        return;
++    }
++
+     // Start monitoring if "org.a11y.Bus" is registered as DBus service.
+     QDBusConnection c = QDBusConnection::sessionBus();
+     if (!c.isConnected()) {
+diff --git a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
+index 1a3cab275d..2abe039126 100644
+--- a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
++++ b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
+@@ -51,6 +51,9 @@
+ #include <QtCore/QStandardPaths>
+ #include <QtCore/QUrl>
+ 
++#include <QtGui/QGuiApplication>
++#include <QtGui/QWindow>
++
+ #if QT_CONFIG(dbus)
+ // These QtCore includes are needed for xdg-desktop-portal support
+ #include <QtCore/private/qcore_unix_p.h>
+@@ -58,6 +61,8 @@
+ #include <QtCore/QFileInfo>
+ #include <QtCore/QUrlQuery>
+ 
++#include <QtGui/QColor>
++
+ #include <QtDBus/QDBusConnection>
+ #include <QtDBus/QDBusMessage>
+ #include <QtDBus/QDBusPendingCall>
+@@ -142,6 +147,8 @@ static inline bool detectWebBrowser(const QByteArray &desktop,
+     }
+ 
+     if (desktop == QByteArray("KDE")) {
++        if (checkExecutable(QStringLiteral("kde-open5"), browser))
++            return true;
+         // Konqueror launcher
+         if (checkExecutable(QStringLiteral("kfmclient"), browser)) {
+             browser->append(QLatin1String(" exec"));
+@@ -296,8 +303,135 @@ static inline QDBusMessage xdgDesktopPortalSendEmail(const QUrl &url)
+ 
+     return QDBusConnection::sessionBus().call(message);
+ }
++
++namespace {
++struct XDGDesktopColor
++{
++    double r = 0;
++    double g = 0;
++    double b = 0;
++
++    QColor toQColor() const
++    {
++        constexpr auto rgbMax = 255;
++        return { static_cast<int>(r * rgbMax), static_cast<int>(g * rgbMax),
++                 static_cast<int>(b * rgbMax) };
++    }
++};
++
++const QDBusArgument &operator>>(const QDBusArgument &argument, XDGDesktopColor &myStruct)
++{
++    argument.beginStructure();
++    argument >> myStruct.r >> myStruct.g >> myStruct.b;
++    argument.endStructure();
++    return argument;
++}
++
++class XdgDesktopPortalColorPicker : public QPlatformServiceColorPicker
++{
++    Q_OBJECT
++public:
++    XdgDesktopPortalColorPicker(const QString &parentWindowId, QWindow *parent)
++        : QPlatformServiceColorPicker(parent), m_parentWindowId(parentWindowId)
++    {
++    }
++
++    void pickColor() override
++    {
++        // DBus signature:
++        // PickColor (IN   s      parent_window,
++        //            IN   a{sv}  options
++        //            OUT  o      handle)
++        // Options:
++        // handle_token (s) -  A string that will be used as the last element of the @handle.
++
++        QDBusMessage message = QDBusMessage::createMethodCall(
++                QStringLiteral("org.freedesktop.portal.Desktop"), QStringLiteral("/org/freedesktop/portal/desktop"),
++                QStringLiteral("org.freedesktop.portal.Screenshot"), QStringLiteral("PickColor"));
++        message << m_parentWindowId << QVariantMap();
++
++        QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
++        auto watcher = new QDBusPendingCallWatcher(pendingCall, this);
++        connect(watcher, &QDBusPendingCallWatcher::finished, this,
++                [this](QDBusPendingCallWatcher *watcher) {
++                    watcher->deleteLater();
++                    QDBusPendingReply<QDBusObjectPath> reply = *watcher;
++                    if (reply.isError()) {
++                        qWarning("DBus call to pick color failed: %s",
++                                 qPrintable(reply.error().message()));
++                        Q_EMIT colorPicked({});
++                    } else {
++                        QDBusConnection::sessionBus().connect(
++                                QStringLiteral("org.freedesktop.portal.Desktop"), reply.value().path(),
++                                QStringLiteral("org.freedesktop.portal.Request"), QStringLiteral("Response"), this,
++                                // clang-format off
++                                SLOT(gotColorResponse(uint,QVariantMap))
++                                // clang-format on
++                        );
++                    }
++                });
++    }
++
++private Q_SLOTS:
++    void gotColorResponse(uint result, const QVariantMap &map)
++    {
++        if (result != 0)
++            return;
++        XDGDesktopColor color{};
++        map.value(QStringLiteral("color")).value<QDBusArgument>() >> color;
++        Q_EMIT colorPicked(color.toQColor());
++        deleteLater();
++    }
++
++private:
++    const QString m_parentWindowId;
++};
++} // namespace
++
+ #endif // QT_CONFIG(dbus)
+ 
++QGenericUnixServices::QGenericUnixServices()
++{
++#if QT_CONFIG(dbus)
++    if (qEnvironmentVariableIntValue("QT_NO_XDG_DESKTOP_PORTAL") > 0) {
++        return;
++    }
++    QDBusMessage message = QDBusMessage::createMethodCall(
++            QStringLiteral("org.freedesktop.portal.Desktop"), QStringLiteral("/org/freedesktop/portal/desktop"),
++            QStringLiteral("org.freedesktop.DBus.Properties"), QStringLiteral("Get"));
++    message << QStringLiteral("org.freedesktop.portal.Screenshot")
++            << QStringLiteral("version");
++
++    QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
++    auto watcher = new QDBusPendingCallWatcher(pendingCall);
++    QObject::connect(watcher, &QDBusPendingCallWatcher::finished, watcher,
++                     [this](QDBusPendingCallWatcher *watcher) {
++                         watcher->deleteLater();
++                         QDBusPendingReply<QVariant> reply = *watcher;
++                         if (!reply.isError() && reply.value().toUInt() >= 2)
++                             m_hasScreenshotPortalWithColorPicking = true;
++                     });
++
++#endif
++}
++
++QPlatformServiceColorPicker *QGenericUnixServices::colorPicker(QWindow *parent)
++{
++#if QT_CONFIG(dbus)
++    // Make double sure that we are in a wayland environment. In particular check
++    // WAYLAND_DISPLAY so also XWayland apps benefit from portal-based color picking.
++    // Outside wayland we'll rather rely on other means than the XDG desktop portal.
++    if (!qEnvironmentVariableIsEmpty("WAYLAND_DISPLAY")
++        || QGuiApplication::platformName().startsWith(QLatin1String("wayland"))) {
++        return new XdgDesktopPortalColorPicker(portalWindowIdentifier(parent), parent);
++    }
++    return nullptr;
++#else
++    Q_UNUSED(parent);
++    return nullptr;
++#endif
++}
++
+ QByteArray QGenericUnixServices::desktopEnvironment() const
+ {
+     static const QByteArray result = detectDesktopEnvironment();
+@@ -352,6 +486,8 @@ bool QGenericUnixServices::openDocument(const QUrl &url)
+ }
+ 
+ #else
++QGenericUnixServices::QGenericUnixServices() = default;
++
+ QByteArray QGenericUnixServices::desktopEnvironment() const
+ {
+     return QByteArrayLiteral("UNKNOWN");
+@@ -371,6 +507,30 @@ bool QGenericUnixServices::openDocument(const QUrl &url)
+     return false;
+ }
+ 
++QPlatformServiceColorPicker *QGenericUnixServices::colorPicker(QWindow *parent)
++{
++    Q_UNUSED(parent);
++    return nullptr;
++}
++
+ #endif // QT_NO_MULTIPROCESS
+ 
++QString QGenericUnixServices::portalWindowIdentifier(QWindow *window)
++{
++    if (QGuiApplication::platformName() == QLatin1String("xcb"))
++        return QStringLiteral("x11:") + QString::number(window->winId(), 16);
++    return QString();
++}
++
++bool QGenericUnixServices::hasCapability(Capability capability) const
++{
++    switch (capability) {
++    case Capability::ColorPicking:
++        return m_hasScreenshotPortalWithColorPicking;
++    }
++    return false;
++}
++
+ QT_END_NAMESPACE
++
++#include "qgenericunixservices.moc"
+diff --git a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
+index 8ac3de6f03..30924e64bd 100644
+--- a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
++++ b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
+@@ -59,16 +59,21 @@ QT_BEGIN_NAMESPACE
+ class QGenericUnixServices : public QPlatformServices
+ {
+ public:
+-    QGenericUnixServices() {}
++    QGenericUnixServices();
+ 
+     QByteArray desktopEnvironment() const override;
+ 
++    bool hasCapability(Capability capability) const override;
+     bool openUrl(const QUrl &url) override;
+     bool openDocument(const QUrl &url) override;
++    QPlatformServiceColorPicker *colorPicker(QWindow *parent = nullptr) override;
++
++    virtual QString portalWindowIdentifier(QWindow *window);
+ 
+ private:
+     QString m_webBrowser;
+     QString m_documentLauncher;
++    bool m_hasScreenshotPortalWithColorPicking = false;
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
+index 09470bccc6..cc7c7d4d8a 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
+@@ -69,6 +69,7 @@ const QString MenuBarPath = QLatin1String("/MenuBar");
+ */
+ QDBusMenuConnection::QDBusMenuConnection(QObject *parent, const QString &serviceName)
+     : QObject(parent)
++    , m_serviceName(serviceName)
+     , m_connection(serviceName.isNull() ? QDBusConnection::sessionBus()
+                                         : QDBusConnection::connectToBus(QDBusConnection::SessionBus, serviceName))
+     , m_dbusWatcher(new QDBusServiceWatcher(StatusNotifierWatcherService, m_connection, QDBusServiceWatcher::WatchForRegistration, this))
+@@ -83,6 +84,12 @@ QDBusMenuConnection::QDBusMenuConnection(QObject *parent, const QString &service
+ #endif
+ }
+ 
++QDBusMenuConnection::~QDBusMenuConnection()
++{
++  if (!m_serviceName.isEmpty() && m_connection.isConnected())
++      QDBusConnection::disconnectFromBus(m_serviceName);
++}
++
+ void QDBusMenuConnection::dbusError(const QDBusError &error)
+ {
+     qWarning() << "QDBusTrayIcon encountered a D-Bus error:" << error;
+@@ -105,13 +112,7 @@ void QDBusMenuConnection::unregisterTrayIconMenu(QDBusTrayIcon *item)
+ 
+ bool QDBusMenuConnection::registerTrayIcon(QDBusTrayIcon *item)
+ {
+-    bool success = connection().registerService(item->instanceId());
+-    if (!success) {
+-        qWarning() << "failed to register service" << item->instanceId();
+-        return false;
+-    }
+-
+-    success = connection().registerObject(StatusNotifierItemPath, item);
++    bool success = connection().registerObject(StatusNotifierItemPath, item);
+     if (!success) {
+         unregisterTrayIcon(item);
+         qWarning() << "failed to register" << item->instanceId() << StatusNotifierItemPath;
+@@ -126,21 +127,18 @@ bool QDBusMenuConnection::registerTrayIcon(QDBusTrayIcon *item)
+ 
+ bool QDBusMenuConnection::registerTrayIconWithWatcher(QDBusTrayIcon *item)
+ {
++    Q_UNUSED(item);
+     QDBusMessage registerMethod = QDBusMessage::createMethodCall(
+                 StatusNotifierWatcherService, StatusNotifierWatcherPath, StatusNotifierWatcherService,
+                 QLatin1String("RegisterStatusNotifierItem"));
+-    registerMethod.setArguments(QVariantList() << item->instanceId());
++    registerMethod.setArguments(QVariantList() << m_connection.baseService());
+     return m_connection.callWithCallback(registerMethod, this, SIGNAL(trayIconRegistered()), SLOT(dbusError(QDBusError)));
+ }
+ 
+-bool QDBusMenuConnection::unregisterTrayIcon(QDBusTrayIcon *item)
++void QDBusMenuConnection::unregisterTrayIcon(QDBusTrayIcon *item)
+ {
+     unregisterTrayIconMenu(item);
+     connection().unregisterObject(StatusNotifierItemPath);
+-    bool success = connection().unregisterService(item->instanceId());
+-    if (!success)
+-        qWarning() << "failed to unregister service" << item->instanceId();
+-    return success;
+ }
+ #endif // QT_NO_SYSTEMTRAYICON
+ 
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
+index f484795fbb..97bdfabb85 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
++++ b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
+@@ -70,6 +70,7 @@ class QDBusMenuConnection : public QObject
+ 
+ public:
+     QDBusMenuConnection(QObject *parent = nullptr, const QString &serviceName = QString());
++    ~QDBusMenuConnection();
+     QDBusConnection connection() const { return m_connection; }
+     QDBusServiceWatcher *dbusWatcher() const { return m_dbusWatcher; }
+     bool isStatusNotifierHostRegistered() const { return m_statusNotifierHostRegistered; }
+@@ -78,7 +79,7 @@ public:
+     void unregisterTrayIconMenu(QDBusTrayIcon *item);
+     bool registerTrayIcon(QDBusTrayIcon *item);
+     bool registerTrayIconWithWatcher(QDBusTrayIcon *item);
+-    bool unregisterTrayIcon(QDBusTrayIcon *item);
++    void unregisterTrayIcon(QDBusTrayIcon *item);
+ #endif // QT_NO_SYSTEMTRAYICON
+ 
+ Q_SIGNALS:
+@@ -90,6 +91,7 @@ private Q_SLOTS:
+     void dbusError(const QDBusError &error);
+ 
+ private:
++    QString m_serviceName;
+     QDBusConnection m_connection;
+     QDBusServiceWatcher *m_dbusWatcher;
+     bool m_statusNotifierHostRegistered;
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp b/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
+index bede70975a..76bfec5e5a 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
+@@ -71,8 +71,12 @@ Q_LOGGING_CATEGORY(qLcTray, "qt.qpa.tray")
+ static QString iconTempPath()
+ {
+     QString tempPath = QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation);
+-    if (!tempPath.isEmpty())
++    if (!tempPath.isEmpty()) {
++        QString flatpakId = qEnvironmentVariable("FLATPAK_ID");
++        if (!flatpakId.isEmpty() && QFileInfo::exists(QLatin1String("/.flatpak-info")))
++            tempPath += QLatin1String("/app/") + flatpakId;
+         return tempPath;
++    }
+ 
+     tempPath = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation);
+ 
+diff --git a/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+index cb1b39db64..6e01af052c 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+@@ -755,6 +755,9 @@ QVariant QGnomeTheme::themeHint(QPlatformTheme::ThemeHint hint) const
+         return QVariant(QChar(0x2022));
+     case QPlatformTheme::UiEffects:
+         return QVariant(int(HoverEffect));
++    case QPlatformTheme::ButtonPressKeys:
++        return QVariant::fromValue(
++                QList<Qt::Key>({ Qt::Key_Space, Qt::Key_Return, Qt::Key_Enter, Qt::Key_Select }));
+     default:
+         break;
+     }
+diff --git a/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp b/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
+index 98e05195ee..1e92f43dec 100644
+--- a/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
++++ b/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
+@@ -343,8 +343,7 @@ void QEglFSCursor::paintOnScreen()
+     // screens are siblings of each other. When not enabled, the sibling list
+     // only contains m_screen itself.
+     for (QPlatformScreen *screen : m_screen->virtualSiblings()) {
+-        if (screen->geometry().contains(cr.topLeft().toPoint() + m_cursor.hotSpot)
+-            && QOpenGLContext::currentContext()->screen() == screen->screen())
++        if (screen->geometry().contains(cr.topLeft().toPoint() + m_cursor.hotSpot))
+         {
+             cr.translate(-screen->geometry().topLeft());
+             const QSize screenSize = screen->geometry().size();
+@@ -468,11 +467,12 @@ void QEglFSCursor::draw(const QRectF &r)
+ {
+     StateSaver stateSaver;
+ 
+-    QEglFSCursorData &gfx = static_cast<QEglFSContext*>(QOpenGLContext::currentContext()->handle())->cursorData;
+-    if (!gfx.program) {
+-        // one time initialization
++    // one time initialization
++    if (!QOpenGLFunctions::d_ptr)
+         initializeOpenGLFunctions();
+ 
++    QEglFSCursorData &gfx = static_cast<QEglFSContext*>(QOpenGLContext::currentContext()->handle())->cursorData;
++    if (!gfx.program) {
+         createShaderPrograms();
+ 
+         if (!gfx.atlasTexture) {
+diff --git a/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp b/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
+index 645a0ae2e9..3e0e406f1a 100644
+--- a/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
++++ b/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
+@@ -179,7 +179,7 @@ void QEglFSKmsEventReader::create(QEglFSKmsDevice *device)
+ 
+     m_device = device;
+ 
+-    qCDebug(qLcEglfsKmsDebug, "Initalizing event reader for device %p fd %d",
++    qCDebug(qLcEglfsKmsDebug, "Initializing event reader for device %p fd %d",
+             m_device, m_device->fd());
+ 
+     m_thread = new QEglFSKmsEventReaderThread(m_device->fd());
+diff --git a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
+index 141fb68a23..d4294d425a 100644
+--- a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
++++ b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
+@@ -122,11 +122,13 @@ QOffscreenIntegration::QOffscreenIntegration()
+ #endif
+     m_services.reset(new QPlatformServices);
+ 
+-    QWindowSystemInterface::handleScreenAdded(new QOffscreenScreen);
++    m_screen = new QOffscreenScreen;
++    QWindowSystemInterface::handleScreenAdded(m_screen);
+ }
+ 
+ QOffscreenIntegration::~QOffscreenIntegration()
+ {
++    QWindowSystemInterface::handleScreenRemoved(m_screen);
+ }
+ 
+ void QOffscreenIntegration::initialize()
+diff --git a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
+index 0ea90f6c2f..fe00fde07c 100644
+--- a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
++++ b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
+@@ -84,6 +84,7 @@ protected:
+ #endif
+     QScopedPointer<QPlatformInputContext> m_inputContext;
+     QScopedPointer<QPlatformServices> m_services;
++    QPlatformScreen *m_screen;
+     mutable QScopedPointer<QPlatformNativeInterface> m_nativeInterface;
+ };
+ 
+diff --git a/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp b/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
+index 6fa5a8a2b3..1f49f0aefd 100644
+--- a/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
++++ b/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
+@@ -48,6 +48,7 @@
+ #include <qpa/qplatformnativeinterface.h>
+ #include <QtPlatformHeaders/qwglnativecontext.h>
+ 
++#include <private/qsystemlibrary_p.h>
+ #include <algorithm>
+ 
+ #include <wingdi.h>
+@@ -162,19 +163,25 @@ QFunctionPointer QWindowsOpengl32DLL::resolve(const char *name)
+ 
+ bool QWindowsOpengl32DLL::init(bool softwareRendering)
+ {
+-    const QByteArray opengl32 = QByteArrayLiteral("opengl32.dll");
+-    const QByteArray swopengl = QByteArrayLiteral("opengl32sw.dll");
++    const QByteArray opengl32 = QByteArrayLiteral("opengl32");
++    const QByteArray swopengl = QByteArrayLiteral("opengl32sw");
++    bool useSystemLib = false;
+ 
+     QByteArray openglDll = qgetenv("QT_OPENGL_DLL");
+-    if (openglDll.isEmpty())
++    if (openglDll.isEmpty()) {
+         openglDll = softwareRendering ? swopengl : opengl32;
++        useSystemLib = !softwareRendering;
++    }
+ 
+     openglDll = openglDll.toLower();
+     m_nonOpengl32 = openglDll != opengl32;
+ 
+     qCDebug(lcQpaGl) << "Qt: Using WGL and OpenGL from" << openglDll;
+ 
+-    m_lib = ::LoadLibraryA(openglDll.constData());
++    if (useSystemLib)
++        m_lib = QSystemLibrary::load((wchar_t*)(QString::fromLatin1(openglDll).utf16()));
++    else
++        m_lib = LoadLibraryA(openglDll.constData());
+     if (!m_lib) {
+         qErrnoWarning(::GetLastError(), "Failed to load %s", openglDll.constData());
+         return false;
+@@ -184,7 +191,7 @@ bool QWindowsOpengl32DLL::init(bool softwareRendering)
+         // Load opengl32.dll always. GDI functions like ChoosePixelFormat do
+         // GetModuleHandle for opengl32.dll and behave differently (and call back into
+         // opengl32) when the module is present. This is fine for dummy contexts and windows.
+-        ::LoadLibraryA("opengl32.dll");
++        QSystemLibrary::load(L"opengl32");
+     }
+ 
+     wglCreateContext = reinterpret_cast<HGLRC (WINAPI *)(HDC)>(resolve("wglCreateContext"));
+diff --git a/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp b/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
+index d7d186e804..9eb4011bf2 100644
+--- a/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
++++ b/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
+@@ -49,6 +49,7 @@
+ #include <QtCore/qstandardpaths.h>
+ #include <QtCore/qlibraryinfo.h>
+ #include <QtCore/qhash.h>
++#include <private/qsystemlibrary_p.h>
+ 
+ #ifndef QT_NO_OPENGL
+ #include <private/qopengl_p.h>
+@@ -396,7 +397,7 @@ bool QWindowsOpenGLTester::testDesktopGL()
+ 
+     // Test #1: Load opengl32.dll and try to resolve an OpenGL 2 function.
+     // This will typically fail on systems that do not have a real OpenGL driver.
+-    lib = LoadLibraryA("opengl32.dll");
++    lib = QSystemLibrary::load(L"opengl32");
+     if (lib) {
+         CreateContext = reinterpret_cast<CreateContextType>(
+             reinterpret_cast<QFunctionPointer>(::GetProcAddress(lib, "wglCreateContext")));
+diff --git a/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp b/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
+index 1afa00cfc9..118af6ce73 100644
+--- a/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
++++ b/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
+@@ -41,6 +41,7 @@
+ 
+ #include <QRect>
+ #include <QList>
++#include <QMap>
+ #include <QDebug>
+ 
+ #include <qmath.h>
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp b/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
+index 9e2a37a6a1..e6e175a118 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
+@@ -488,12 +488,12 @@ void QXcbConnection::printXcbError(const char *message, xcb_generic_error_t *err
+     uint clamped_error_code = qMin<uint>(error->error_code, (sizeof(xcb_errors) / sizeof(xcb_errors[0])) - 1);
+     uint clamped_major_code = qMin<uint>(error->major_code, (sizeof(xcb_protocol_request_codes) / sizeof(xcb_protocol_request_codes[0])) - 1);
+ 
+-    qCWarning(lcQpaXcb, "%s: %d (%s), sequence: %d, resource id: %d, major code: %d (%s), minor code: %d",
+-             message,
+-             int(error->error_code), xcb_errors[clamped_error_code],
+-             int(error->sequence), int(error->resource_id),
+-             int(error->major_code), xcb_protocol_request_codes[clamped_major_code],
+-             int(error->minor_code));
++    qCDebug(lcQpaXcb, "%s: %d (%s), sequence: %d, resource id: %d, major code: %d (%s), minor code: %d",
++            message,
++            int(error->error_code), xcb_errors[clamped_error_code],
++            int(error->sequence), int(error->resource_id),
++            int(error->major_code), xcb_protocol_request_codes[clamped_major_code],
++            int(error->minor_code));
+ }
+ 
+ static Qt::MouseButtons translateMouseButtons(int s)
+@@ -702,6 +702,8 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
+             QXcbVirtualDesktop *virtualDesktop = virtualDesktopForRootWindow(propertyNotify->window);
+             if (virtualDesktop)
+                 virtualDesktop->updateWorkArea();
++        } else if (propertyNotify->atom == atom(QXcbAtom::_NET_SUPPORTED)) {
++            m_wmSupport->updateNetWMAtoms();
+         } else {
+             HANDLE_PLATFORM_WINDOW_EVENT(xcb_property_notify_event_t, window, handlePropertyNotifyEvent);
+         }
+@@ -750,7 +752,7 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
+                 case XCB_XKB_NEW_KEYBOARD_NOTIFY: {
+                     xcb_xkb_new_keyboard_notify_event_t *ev = &xkb_event->new_keyboard_notify;
+                     if (ev->changed & XCB_XKB_NKN_DETAIL_KEYCODES)
+-                        m_keyboard->updateKeymap(ev);
++                        m_keyboard->updateKeymap();
+                     break;
+                 }
+                 default:
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp b/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
+index 76869ced60..02d2eebb56 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
+@@ -274,8 +274,7 @@ QPlatformWindow *QXcbIntegration::createForeignWindow(QWindow *window, WId nativ
+ #ifndef QT_NO_OPENGL
+ QPlatformOpenGLContext *QXcbIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
+ {
+-    QXcbScreen *screen = static_cast<QXcbScreen *>(context->screen()->handle());
+-    QXcbGlIntegration *glIntegration = screen->connection()->glIntegration();
++    QXcbGlIntegration *glIntegration = defaultConnection()->glIntegration();
+     if (!glIntegration) {
+         qWarning("QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled");
+         return nullptr;
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+index efecd7e2d1..e8286381a2 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+@@ -365,17 +365,6 @@ void QXcbKeyboard::updateKeymap(xcb_mapping_notify_event_t *event)
+     updateKeymap();
+ }
+ 
+-void QXcbKeyboard::updateKeymap(xcb_xkb_new_keyboard_notify_event_t *event)
+-{
+-    if (!event)
+-        return;
+-
+-    if (event->deviceID != event->oldDeviceID)
+-        m_config = false;
+-
+-    updateKeymap();
+-}
+-
+ void QXcbKeyboard::updateKeymap()
+ {
+     KeysymModifierMap keysymMods;
+@@ -383,6 +372,8 @@ void QXcbKeyboard::updateKeymap()
+         keysymMods = keysymsToModifiers();
+     updateModifiers(keysymMods);
+ 
++    m_config = true;
++
+     if (!m_xkbContext) {
+         m_xkbContext.reset(xkb_context_new(XKB_CONTEXT_NO_DEFAULT_INCLUDES));
+         if (!m_xkbContext) {
+@@ -398,13 +389,8 @@ void QXcbKeyboard::updateKeymap()
+     if (connection()->hasXKB()) {
+         m_xkbKeymap.reset(xkb_x11_keymap_new_from_device(m_xkbContext.get(), xcb_connection(),
+                                                          core_device_id, XKB_KEYMAP_COMPILE_NO_FLAGS));
+-        if (m_xkbKeymap) {
+-            if (m_config)
+-                m_xkbState.reset(xkb_state_new(m_xkbKeymap.get()));
+-            else
+-                m_xkbState.reset(xkb_x11_state_new_from_device(m_xkbKeymap.get(), xcb_connection(), core_device_id));
+-
+-        }
++        if (m_xkbKeymap)
++            m_xkbState.reset(xkb_x11_state_new_from_device(m_xkbKeymap.get(), xcb_connection(), core_device_id));
+     } else {
+         m_xkbKeymap.reset(keymapFromCore(keysymMods));
+         if (m_xkbKeymap)
+@@ -425,8 +411,6 @@ void QXcbKeyboard::updateKeymap()
+     updateXKBMods();
+ 
+     QXkbCommon::verifyHasLatinLayout(m_xkbKeymap.get());
+-
+-    m_config = true;
+ }
+ 
+ QList<int> QXcbKeyboard::possibleKeys(const QKeyEvent *event) const
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
+index b652c85fe3..0ee08aeff2 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
++++ b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
+@@ -69,7 +69,6 @@ public:
+ 
+     Qt::KeyboardModifiers translateModifiers(int s) const;
+     void updateKeymap(xcb_mapping_notify_event_t *event);
+-    void updateKeymap(xcb_xkb_new_keyboard_notify_event_t *event);
+     void updateKeymap();
+     QList<int> possibleKeys(const QKeyEvent *event) const;
+ 
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp b/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
+index ffda7b6a57..863e961f4c 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
+@@ -564,11 +564,6 @@ void QXcbWindow::setGeometry(const QRect &rect)
+ {
+     QPlatformWindow::setGeometry(rect);
+ 
+-    if (shouldDeferTask(Task::SetGeometry)) {
+-        m_deferredGeometry = rect;
+-        return;
+-    }
+-
+     propagateSizeHints();
+ 
+     QXcbScreen *currentScreen = xcbScreen();
+@@ -693,9 +688,6 @@ void QXcbWindow::setVisible(bool visible)
+ 
+ void QXcbWindow::show()
+ {
+-    if (shouldDeferTask(Task::Map))
+-        return;
+-
+     if (window()->isTopLevel()) {
+ 
+         // update WM_NORMAL_HINTS
+@@ -706,7 +698,7 @@ void QXcbWindow::show()
+         if (isTransient(window())) {
+             const QWindow *tp = window()->transientParent();
+             if (tp && tp->handle())
+-                transientXcbParent = static_cast<const QXcbWindow *>(tp->handle())->winId();
++                transientXcbParent = tp->handle()->winId();
+             // Default to client leader if there is no transient parent, else modal dialogs can
+             // be hidden by their parents.
+             if (!transientXcbParent)
+@@ -746,10 +738,6 @@ void QXcbWindow::show()
+ 
+ void QXcbWindow::hide()
+ {
+-    if (shouldDeferTask(Task::Unmap))
+-        return;
+-
+-    m_wmStateValid = false;
+     xcb_unmap_window(xcb_connection(), m_window);
+ 
+     // send synthetic UnmapNotify event according to icccm 4.1.4
+@@ -909,9 +897,6 @@ QXcbWindow::NetWmStates QXcbWindow::netWmStates()
+ 
+ void QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
+ {
+-    if (shouldDeferTask(Task::SetWindowFlags))
+-        return;
+-
+     Qt::WindowType type = static_cast<Qt::WindowType>(int(flags & Qt::WindowType_Mask));
+ 
+     if (type == Qt::ToolTip)
+@@ -941,8 +926,6 @@ void QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
+ 
+     setTransparentForMouseEvents(flags & Qt::WindowTransparentForInput);
+     updateDoesNotAcceptFocus(flags & Qt::WindowDoesNotAcceptFocus);
+-
+-    m_isWmManagedWindow = !(flags & Qt::X11BypassWindowManagerHint);
+ }
+ 
+ void QXcbWindow::setMotifWmHints(Qt::WindowFlags flags)
+@@ -1142,9 +1125,6 @@ void QXcbWindow::setWindowState(Qt::WindowStates state)
+     if (state == m_windowState)
+         return;
+ 
+-    if (shouldDeferTask(Task::SetWindowState))
+-        return;
+-
+     // unset old state
+     if (m_windowState & Qt::WindowMinimized)
+         xcb_map_window(xcb_connection(), m_window);
+@@ -1350,6 +1330,12 @@ void QXcbWindow::setWindowIcon(const QIcon &icon)
+     }
+ 
+     if (!icon_data.isEmpty()) {
++        // Ignore icon exceeding maximum xcb request length
++        if (icon_data.size() > xcb_get_maximum_request_length(xcb_connection())) {
++            qWarning("Ignoring window icon: Size %llu exceeds maximum xcb request length %u.",
++                     icon_data.size(), xcb_get_maximum_request_length(xcb_connection()));
++            return;
++        }
+         xcb_change_property(xcb_connection(),
+                             XCB_PROP_MODE_REPLACE,
+                             m_window,
+@@ -1639,7 +1625,7 @@ void QXcbWindow::setWmWindowType(QXcbWindowFunctions::WmWindowTypes types, Qt::W
+         break;
+     }
+ 
+-    if ((flags & Qt::FramelessWindowHint) && !(type & QXcbWindowFunctions::KdeOverride)) {
++    if ((flags & Qt::FramelessWindowHint) && !(types & QXcbWindowFunctions::KdeOverride)) {
+         // override netwm type - quick and easy for KDE noborder
+         atoms.append(atom(QXcbAtom::_KDE_NET_WM_WINDOW_TYPE_OVERRIDE));
+     }
+@@ -1894,10 +1880,6 @@ void QXcbWindow::handleUnmapNotifyEvent(const xcb_unmap_notify_event_t *event)
+     if (event->window == m_window) {
+         m_mapped = false;
+         QWindowSystemInterface::handleExposeEvent(window(), QRegion());
+-        if (!m_isWmManagedWindow || parent()) {
+-            m_wmStateValid = true;
+-            handleDeferredTasks();
+-        }
+     }
+ }
+ 
+@@ -2212,98 +2194,30 @@ void QXcbWindow::handleLeaveNotifyEvent(const xcb_leave_notify_event_t *event)
+     handleLeaveNotifyEvent(event->root_x, event->root_y, event->mode, event->detail, event->time);
+ }
+ 
+-bool QXcbWindow::shouldDeferTask(Task task)
+-{
+-    if (m_wmStateValid)
+-        return false;
+-
+-    m_deferredTasks.append(task);
+-    return true;
+-}
+-
+-void QXcbWindow::handleDeferredTasks()
+-{
+-    Q_ASSERT(m_wmStateValid == true);
+-    if (m_deferredTasks.isEmpty())
+-        return;
+-
+-    bool map = false;
+-    bool unmap = false;
+-
+-    QVector<Task> tasks;
+-    for (auto taskIt = m_deferredTasks.rbegin(); taskIt != m_deferredTasks.rend(); ++taskIt) {
+-        if (!tasks.contains(*taskIt))
+-            tasks.prepend(*taskIt);
+-    }
+-
+-    for (Task task : tasks) {
+-        switch (task) {
+-        case Task::Map:
+-            map = true;
+-            unmap = false;
+-            break;
+-        case Task::Unmap:
+-            unmap = true;
+-            map = false;
+-            break;
+-        case Task::SetGeometry:
+-            setGeometry(m_deferredGeometry);
+-            break;
+-        case Task::SetWindowFlags:
+-            setWindowFlags(window()->flags());
+-            break;
+-        case Task::SetWindowState:
+-            setWindowState(window()->windowState());
+-            break;
+-        }
+-    }
+-    m_deferredTasks.clear();
+-
+-    if (map) {
+-        Q_ASSERT(unmap == false);
+-        show();
+-    }
+-    if (unmap) {
+-        Q_ASSERT(map == false);
+-        hide();
+-    }
+-}
+-
+ void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *event)
+ {
+     connection()->setTime(event->time);
+ 
+-    const bool wmStateChanged = event->atom == atom(QXcbAtom::WM_STATE);
+-    const bool netWmStateChanged = event->atom == atom(QXcbAtom::_NET_WM_STATE);
+-    if (netWmStateChanged || wmStateChanged) {
+-        if (wmStateChanged && !m_wmStateValid && m_isWmManagedWindow) {
+-            // ICCCM 4.1.4
+-            // Clients that want to re-use a client window (e.g. by mapping it again)
+-            // after withdrawing it must wait for the withdrawal to be complete before
+-            // proceeding. The preferred method for doing this is for clients to wait for
+-            // a window manager to update or remove the WM_STATE property.
+-            m_wmStateValid = true;
+-            handleDeferredTasks();
+-        }
+-        if (event->state == XCB_PROPERTY_DELETE)
++    const bool propertyDeleted = event->state == XCB_PROPERTY_DELETE;
++
++    if (event->atom == atom(QXcbAtom::_NET_WM_STATE) || event->atom == atom(QXcbAtom::WM_STATE)) {
++        if (propertyDeleted)
+             return;
+ 
+-        if (wmStateChanged) {
++        Qt::WindowStates newState = Qt::WindowNoState;
++
++        if (event->atom == atom(QXcbAtom::WM_STATE)) { // WM_STATE: Quick check for 'Minimize'.
+             auto reply = Q_XCB_REPLY(xcb_get_property, xcb_connection(),
+                                      0, m_window, atom(QXcbAtom::WM_STATE),
+                                      XCB_ATOM_ANY, 0, 1024);
+             if (reply && reply->format == 32 && reply->type == atom(QXcbAtom::WM_STATE)) {
+-                auto data = static_cast<const quint32 *>(xcb_get_property_value(reply.get()));
+-                if (reply->length != 0) {
+-                    const bool changedToWithdrawn = data[0] == XCB_ICCCM_WM_STATE_WITHDRAWN;
+-                    const bool changedToIconic = data[0] == XCB_ICCCM_WM_STATE_ICONIC;
+-                    m_minimized = changedToIconic || (changedToWithdrawn && m_minimized);
+-                }
++                const quint32 *data = (const quint32 *)xcb_get_property_value(reply.get());
++                if (reply->length != 0)
++                    m_minimized = (data[0] == XCB_ICCCM_WM_STATE_ICONIC
++                                   || (data[0] == XCB_ICCCM_WM_STATE_WITHDRAWN && m_minimized));
+             }
+         }
+ 
+-        // _NET_WM_STATE handling
+-        Qt::WindowStates newState = Qt::WindowNoState;
+         const NetWmStates states = netWmStates();
+         // _NET_WM_STATE_HIDDEN should be set by the Window Manager to indicate that a window would
+         // not be visible on the screen if its desktop/viewport were active and its coordinates were
+@@ -2325,6 +2239,7 @@ void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *ev
+             if ((m_windowState & Qt::WindowMinimized) && connection()->mouseGrabber() == this)
+                 connection()->setMouseGrabber(nullptr);
+         }
++        return;
+     } else if (event->atom == atom(QXcbAtom::_NET_FRAME_EXTENTS)) {
+         m_dirtyFrameMargins = true;
+     }
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbwindow.h b/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
+index 55af9279b1..6f5c1f5ed9 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
++++ b/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
+@@ -74,14 +74,6 @@ public:
+ 
+     Q_DECLARE_FLAGS(NetWmStates, NetWmState)
+ 
+-    enum Task {
+-        Map,
+-        Unmap,
+-        SetGeometry,
+-        SetWindowFlags,
+-        SetWindowState
+-    };
+-
+     QXcbWindow(QWindow *window);
+     ~QXcbWindow();
+ 
+@@ -151,9 +143,6 @@ public:
+ 
+     QXcbWindow *toWindow() override;
+ 
+-    bool shouldDeferTask(Task task);
+-    void handleDeferredTasks();
+-
+     void handleMouseEvent(xcb_timestamp_t time, const QPoint &local, const QPoint &global,
+                           Qt::KeyboardModifiers modifiers, QEvent::Type type, Qt::MouseEventSource source);
+ 
+@@ -292,11 +281,6 @@ protected:
+     int m_swapInterval = -1;
+ 
+     qreal m_sizeHintsScaleFactor = 1.0;
+-
+-    bool m_wmStateValid = true;
+-    QVector<Task> m_deferredTasks;
+-    bool m_isWmManagedWindow = true;
+-    QRect m_deferredGeometry;
+ };
+ 
+ class QXcbForeignWindow : public QXcbWindow
+diff --git a/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp b/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
+index d9d117faeb..640b49daa0 100644
+--- a/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
++++ b/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
+@@ -85,6 +85,7 @@ QGtk3MenuItem::QGtk3MenuItem()
+       m_checkable(false),
+       m_checked(false),
+       m_enabled(true),
++      m_exclusive(false),
+       m_underline(false),
+       m_invalid(true),
+       m_menu(nullptr),
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
+index 0048bbc1e6..396e7f6d1c 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
+@@ -102,15 +102,12 @@ const QDBusArgument &operator >>(const QDBusArgument &arg, QXdgDesktopPortalFile
+ class QXdgDesktopPortalFileDialogPrivate
+ {
+ public:
+-    QXdgDesktopPortalFileDialogPrivate(QPlatformFileDialogHelper *nativeFileDialog)
++    QXdgDesktopPortalFileDialogPrivate(QPlatformFileDialogHelper *nativeFileDialog, uint fileChooserPortalVersion)
+         : nativeFileDialog(nativeFileDialog)
++        , fileChooserPortalVersion(fileChooserPortalVersion)
+     { }
+ 
+-    WId winId = 0;
+-    bool directoryMode = false;
+-    bool modal = false;
+-    bool multipleFiles = false;
+-    bool saveFile = false;
++    QEventLoop loop;
+     QString acceptLabel;
+     QString directory;
+     QString title;
+@@ -121,19 +118,27 @@ public:
+     QString selectedMimeTypeFilter;
+     QString selectedNameFilter;
+     QStringList selectedFiles;
+-    QPlatformFileDialogHelper *nativeFileDialog = nullptr;
++    std::unique_ptr<QPlatformFileDialogHelper> nativeFileDialog;
++    uint fileChooserPortalVersion = 0;
++    bool failedToOpen = false;
++    bool directoryMode = false;
++    bool multipleFiles = false;
++    bool saveFile = false;
+ };
+ 
+-QXdgDesktopPortalFileDialog::QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog)
++QXdgDesktopPortalFileDialog::QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog, uint fileChooserPortalVersion)
+     : QPlatformFileDialogHelper()
+-    , d_ptr(new QXdgDesktopPortalFileDialogPrivate(nativeFileDialog))
++    , d_ptr(new QXdgDesktopPortalFileDialogPrivate(nativeFileDialog, fileChooserPortalVersion))
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+     if (d->nativeFileDialog) {
+-        connect(d->nativeFileDialog, SIGNAL(accept()), this, SIGNAL(accept()));
+-        connect(d->nativeFileDialog, SIGNAL(reject()), this, SIGNAL(reject()));
++        connect(d->nativeFileDialog.get(), SIGNAL(accept()), this, SIGNAL(accept()));
++        connect(d->nativeFileDialog.get(), SIGNAL(reject()), this, SIGNAL(reject()));
+     }
++
++    d->loop.connect(this, SIGNAL(accept()), SLOT(quit()));
++    d->loop.connect(this, SIGNAL(reject()), SLOT(quit()));
+ }
+ 
+ QXdgDesktopPortalFileDialog::~QXdgDesktopPortalFileDialog()
+@@ -177,7 +182,7 @@ void QXdgDesktopPortalFileDialog::initializeDialog()
+     setDirectory(options()->initialDirectory());
+ }
+ 
+-void QXdgDesktopPortalFileDialog::openPortal()
++void QXdgDesktopPortalFileDialog::openPortal(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent)
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+@@ -185,13 +190,13 @@ void QXdgDesktopPortalFileDialog::openPortal()
+                                                           QLatin1String("/org/freedesktop/portal/desktop"),
+                                                           QLatin1String("org.freedesktop.portal.FileChooser"),
+                                                           d->saveFile ? QLatin1String("SaveFile") : QLatin1String("OpenFile"));
+-    QString parentWindowId = QLatin1String("x11:") + QString::number(d->winId, 16);
++    QString parentWindowId = QLatin1String("x11:") + QString::number(parent ? parent->winId() : 0, 16);
+ 
+     QVariantMap options;
+     if (!d->acceptLabel.isEmpty())
+         options.insert(QLatin1String("accept_label"), d->acceptLabel);
+ 
+-    options.insert(QLatin1String("modal"), d->modal);
++    options.insert(QLatin1String("modal"), windowModality != Qt::NonModal);
+     options.insert(QLatin1String("multiple"), d->multipleFiles);
+     options.insert(QLatin1String("directory"), d->directoryMode);
+ 
+@@ -290,10 +295,18 @@ void QXdgDesktopPortalFileDialog::openPortal()
+ 
+     QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
+     QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingCall);
+-    connect(watcher, &QDBusPendingCallWatcher::finished, this, [this] (QDBusPendingCallWatcher *watcher) {
++    connect(watcher, &QDBusPendingCallWatcher::finished, this, [=] (QDBusPendingCallWatcher *watcher) {
+         QDBusPendingReply<QDBusObjectPath> reply = *watcher;
+-        if (reply.isError()) {
+-            Q_EMIT reject();
++        // Any error means the dialog is not shown and we need to fallback
++        d->failedToOpen = reply.isError();
++        if (d->failedToOpen) {
++            if (d->nativeFileDialog) {
++                d->nativeFileDialog->show(windowFlags, windowModality, parent);
++                if (d->loop.isRunning())
++                    d->nativeFileDialog->exec();
++            } else {
++                Q_EMIT reject();
++            }
+         } else {
+             QDBusConnection::sessionBus().connect(nullptr,
+                                                   reply.value().path(),
+@@ -302,6 +315,7 @@ void QXdgDesktopPortalFileDialog::openPortal()
+                                                   this,
+                                                   SLOT(gotResponse(uint,QVariantMap)));
+         }
++        watcher->deleteLater();
+     });
+ }
+ 
+@@ -326,7 +340,7 @@ QUrl QXdgDesktopPortalFileDialog::directory() const
+ {
+     Q_D(const QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog())
+         return d->nativeFileDialog->directory();
+ 
+     return d->directory;
+@@ -348,7 +362,7 @@ QList<QUrl> QXdgDesktopPortalFileDialog::selectedFiles() const
+ {
+     Q_D(const QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog())
+         return d->nativeFileDialog->selectedFiles();
+ 
+     QList<QUrl> files;
+@@ -403,16 +417,13 @@ void QXdgDesktopPortalFileDialog::exec()
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly)) {
++    if (d->nativeFileDialog && useNativeFileDialog()) {
+         d->nativeFileDialog->exec();
+         return;
+     }
+ 
+     // HACK we have to avoid returning until we emit that the dialog was accepted or rejected
+-    QEventLoop loop;
+-    loop.connect(this, SIGNAL(accept()), SLOT(quit()));
+-    loop.connect(this, SIGNAL(reject()), SLOT(quit()));
+-    loop.exec();
++    d->loop.exec();
+ }
+ 
+ void QXdgDesktopPortalFileDialog::hide()
+@@ -429,13 +440,10 @@ bool QXdgDesktopPortalFileDialog::show(Qt::WindowFlags windowFlags, Qt::WindowMo
+ 
+     initializeDialog();
+ 
+-    d->modal = windowModality != Qt::NonModal;
+-    d->winId = parent ? parent->winId() : 0;
+-
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog(OpenFallback))
+         return d->nativeFileDialog->show(windowFlags, windowModality, parent);
+ 
+-    openPortal();
++    openPortal(windowFlags, windowModality, parent);
+ 
+     return true;
+ }
+@@ -465,4 +473,21 @@ void QXdgDesktopPortalFileDialog::gotResponse(uint response, const QVariantMap &
+     }
+ }
+ 
++bool QXdgDesktopPortalFileDialog::useNativeFileDialog(QXdgDesktopPortalFileDialog::FallbackType fallbackType) const
++{
++    Q_D(const QXdgDesktopPortalFileDialog);
++
++    if (d->failedToOpen && fallbackType != OpenFallback)
++        return true;
++
++    if (d->fileChooserPortalVersion < 3) {
++        if (options()->fileMode() == QFileDialogOptions::Directory)
++            return true;
++        else if (options()->fileMode() == QFileDialogOptions::DirectoryOnly)
++            return true;
++    }
++
++    return false;
++}
++
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
+index 4f4de96ecf..65e22a5cf2 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
+@@ -51,6 +51,11 @@ class QXdgDesktopPortalFileDialog : public QPlatformFileDialogHelper
+     Q_OBJECT
+     Q_DECLARE_PRIVATE(QXdgDesktopPortalFileDialog)
+ public:
++    enum FallbackType {
++        GenericFallback,
++        OpenFallback
++    };
++
+     enum ConditionType : uint {
+         GlobalPattern = 0,
+         MimeType = 1
+@@ -69,7 +74,7 @@ public:
+     };
+     typedef QVector<Filter> FilterList;
+ 
+-    QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog = nullptr);
++    QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog = nullptr, uint fileChooserPortalVersion = 0);
+     ~QXdgDesktopPortalFileDialog();
+ 
+     bool defaultNameFilterDisables() const override;
+@@ -92,7 +97,8 @@ private Q_SLOTS:
+ 
+ private:
+     void initializeDialog();
+-    void openPortal();
++    void openPortal(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent);
++    bool useNativeFileDialog(FallbackType fallbackType = GenericFallback) const;
+ 
+     QScopedPointer<QXdgDesktopPortalFileDialogPrivate> d_ptr;
+ };
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
+index fb324afbd8..b809503122 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
+@@ -111,6 +111,7 @@ QXdgDesktopPortalTheme::QXdgDesktopPortalTheme()
+         if (reply.isValid()) {
+             d->fileChooserPortalVersion = reply.value().toUInt();
+         }
++        watcher->deleteLater();
+     });
+ }
+ 
+@@ -152,11 +153,12 @@ QPlatformDialogHelper* QXdgDesktopPortalTheme::createPlatformDialogHelper(Dialog
+ {
+     Q_D(const QXdgDesktopPortalTheme);
+ 
+-    if (type == FileDialog) {
++    if (type == FileDialog && d->fileChooserPortalVersion) {
+         // Older versions of FileChooser portal don't support opening directories, therefore we fallback
+         // to native file dialog opened inside the sandbox to open a directory.
+-        if (d->fileChooserPortalVersion < 3 && d->baseTheme->usePlatformNativeDialog(type))
+-            return new QXdgDesktopPortalFileDialog(static_cast<QPlatformFileDialogHelper*>(d->baseTheme->createPlatformDialogHelper(type)));
++        if (d->baseTheme->usePlatformNativeDialog(type))
++            return new QXdgDesktopPortalFileDialog(static_cast<QPlatformFileDialogHelper*>(d->baseTheme->createPlatformDialogHelper(type)),
++                                                   d->fileChooserPortalVersion);
+ 
+         return new QXdgDesktopPortalFileDialog;
+     }
+diff --git a/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp b/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
+index 43d5e119ad..1f9cbc4565 100644
+--- a/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
++++ b/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
+@@ -89,8 +89,10 @@ void QCupsPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &v
+         break;
+     case PPK_Duplex: {
+         QPrint::DuplexMode mode = QPrint::DuplexMode(value.toInt());
+-        if (mode != d->duplex && d->m_printDevice.supportedDuplexModes().contains(mode))
++        if (d->m_printDevice.supportedDuplexModes().contains(mode)) {
+             d->duplex = mode;
++            d->duplexRequestedExplicitly = true;
++        }
+         break;
+     }
+     case PPK_PrinterName:
+@@ -277,9 +279,12 @@ void QCupsPrintEnginePrivate::changePrinter(const QString &newPrinter)
+     m_printDevice.swap(printDevice);
+     printerName = m_printDevice.id();
+ 
+-    // Check if new printer supports current settings, otherwise us defaults
+-    if (duplex != QPrint::DuplexAuto && !m_printDevice.supportedDuplexModes().contains(duplex))
++    // in case a duplex value was explicitly set, check if new printer supports current value,
++    // otherwise use device default
++    if (!duplexRequestedExplicitly || !m_printDevice.supportedDuplexModes().contains(duplex)) {
+         duplex = m_printDevice.defaultDuplexMode();
++        duplexRequestedExplicitly = false;
++    }
+     QPrint::ColorMode colorMode = grayscale ? QPrint::GrayScale : QPrint::Color;
+     if (!m_printDevice.supportedColorModes().contains(colorMode))
+         grayscale = m_printDevice.defaultColorMode() == QPrint::GrayScale;
+diff --git a/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h b/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
+index c021b0c643..8f81fe478d 100644
+--- a/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
++++ b/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
+@@ -100,6 +100,7 @@ private:
+     QStringList cupsOptions;
+     QString cupsTempFile;
+     QPrint::DuplexMode duplex;
++    bool duplexRequestedExplicitly = false;
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp b/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
+index 67e7154fa6..40876152e5 100644
+--- a/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
++++ b/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
+@@ -817,7 +817,7 @@ bool QIBaseResultPrivate::writeArray(int column, const QList<QVariant> &list)
+     ba.resize(int(bufLen));
+ 
+     if (list.size() > arraySize) {
+-        error = QLatin1String("Array size missmatch: size of %1 is %2, size of provided list is %3");
++        error = QLatin1String("Array size mismatch: size of %1 is %2, size of provided list is %3");
+         error = error.arg(QLatin1String(sqlname)).arg(arraySize).arg(list.size());
+         q->setLastError(QSqlError(error, QLatin1String(""), QSqlError::StatementError));
+         return false;
+diff --git a/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp b/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
+index 7ca055eea2..6bc9d46755 100644
+--- a/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
++++ b/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
+@@ -223,7 +223,7 @@ public:
+     struct QMyField
+     {
+         char *outField = nullptr;
+-        MYSQL_FIELD *myField = nullptr;
++        const MYSQL_FIELD *myField = nullptr;
+         QMetaType::Type type = QMetaType::UnknownType;
+         my_bool nullIndicator = false;
+         ulong bufLength = 0ul;
+@@ -361,7 +361,7 @@ static bool qIsInteger(int t)
+ void QMYSQLResultPrivate::bindBlobs()
+ {
+     int i;
+-    MYSQL_FIELD *fieldInfo;
++    const MYSQL_FIELD *fieldInfo;
+     MYSQL_BIND *bind;
+ 
+     for(i = 0; i < fields.count(); ++i) {
+@@ -379,7 +379,6 @@ void QMYSQLResultPrivate::bindBlobs()
+ bool QMYSQLResultPrivate::bindInValues()
+ {
+     MYSQL_BIND *bind;
+-    char *field;
+     int i = 0;
+ 
+     if (!meta)
+@@ -392,35 +391,34 @@ bool QMYSQLResultPrivate::bindInValues()
+     inBinds = new MYSQL_BIND[fields.size()];
+     memset(inBinds, 0, fields.size() * sizeof(MYSQL_BIND));
+ 
+-    MYSQL_FIELD *fieldInfo;
++    const MYSQL_FIELD *fieldInfo;
+ 
+     while((fieldInfo = mysql_fetch_field(meta))) {
++        bind = &inBinds[i];
++
+         QMyField &f = fields[i];
+         f.myField = fieldInfo;
+-
++        bind->buffer_length = f.bufLength = fieldInfo->length + 1;
++        bind->buffer_type = fieldInfo->type;
+         f.type = qDecodeMYSQLType(fieldInfo->type, fieldInfo->flags);
+         if (qIsBlob(fieldInfo->type)) {
+             // the size of a blob-field is available as soon as we call
+             // mysql_stmt_store_result()
+             // after mysql_stmt_exec() in QMYSQLResult::exec()
+-            fieldInfo->length = 0;
++            bind->buffer_length = f.bufLength = 0;
+             hasBlobs = true;
+         } else if (qIsInteger(f.type)) {
+-            fieldInfo->length = 8;
++            bind->buffer_length = f.bufLength = 8;
+         } else {
+-            fieldInfo->type = MYSQL_TYPE_STRING;
++            bind->buffer_type = MYSQL_TYPE_STRING;
+         }
+-        bind = &inBinds[i];
+-        field = new char[fieldInfo->length + 1];
+-        memset(field, 0, fieldInfo->length + 1);
+ 
+-        bind->buffer_type = fieldInfo->type;
+-        bind->buffer = field;
+-        bind->buffer_length = f.bufLength = fieldInfo->length + 1;
+         bind->is_null = &f.nullIndicator;
+         bind->length = &f.bufLength;
+         bind->is_unsigned = fieldInfo->flags & UNSIGNED_FLAG ? 1 : 0;
+-        f.outField=field;
++
++        char *field = new char[bind->buffer_length + 1]{};
++        bind->buffer = f.outField = field;
+ 
+         ++i;
+     }
+@@ -1369,20 +1367,20 @@ bool QMYSQLDriver::open(const QString& db,
+     }
+ 
+ #if MYSQL_VERSION_ID >= 50007
+-    if (mysql_get_client_version() >= 50503 && mysql_get_server_version(d->mysql) >= 50503) {
+-        // force the communication to be utf8mb4 (only utf8mb4 supports 4-byte characters)
+-        mysql_set_character_set(d->mysql, "utf8mb4");
++    // force the communication to be utf8mb4 (only utf8mb4 supports 4-byte characters)
++    if (mysql_set_character_set(d->mysql, "utf8mb4")) {
++        // this failed, try forcing it to utf (BMP only)
++        if (mysql_set_character_set(d->mysql, "utf8"))
++            qWarning() << "MySQL: Unable to set the client character set to utf8.";
+ #if QT_CONFIG(textcodec)
+-        d->tc = QTextCodec::codecForName("UTF-8");
++        else
++            d->tc = codec(d->mysql);
+ #endif
+-    } else
+-    {
+-        // force the communication to be utf8
+-        mysql_set_character_set(d->mysql, "utf8");
++    }
+ #if QT_CONFIG(textcodec)
+-        d->tc = codec(d->mysql);
++    else
++        d->tc = QTextCodec::codecForName("UTF-8");
+ #endif
+-    }
+ #endif  // MYSQL_VERSION_ID >= 50007
+ 
+     d->preparedQuerysEnabled = checkPreparedQueries(d->mysql);
+diff --git a/qtbase/src/printsupport/dialogs/images/print-24.png b/qtbase/src/printsupport/dialogs/images/printer-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/print-24.png
+rename to src/printsupport/dialogs/images/printer-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/print-32.png b/qtbase/src/printsupport/dialogs/images/printer-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/print-32.png
+rename to src/printsupport/dialogs/images/printer-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-sided-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-facing-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-sided-24.png
+rename to src/printsupport/dialogs/images/view-pages-facing-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-sided-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-facing-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-sided-32.png
+rename to src/printsupport/dialogs/images/view-pages-facing-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-multi-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-overview-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-multi-24.png
+rename to src/printsupport/dialogs/images/view-pages-overview-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-multi-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-overview-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-multi-32.png
+rename to src/printsupport/dialogs/images/view-pages-overview-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-one-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-single-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-one-24.png
+rename to src/printsupport/dialogs/images/view-pages-single-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-one-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-single-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-one-32.png
+rename to src/printsupport/dialogs/images/view-pages-single-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-page-24.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-page-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-page-24.png
+rename to src/printsupport/dialogs/images/zoom-fit-page-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-page-32.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-page-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-page-32.png
+rename to src/printsupport/dialogs/images/zoom-fit-page-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-width-24.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-width-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-width-24.png
+rename to src/printsupport/dialogs/images/zoom-fit-width-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-width-32.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-width-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-width-32.png
+rename to src/printsupport/dialogs/images/zoom-fit-width-32.png
+diff --git a/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp b/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
+index 78e5b8d1ef..2a28516719 100644
+--- a/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
++++ b/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
+@@ -532,6 +532,7 @@ void QPageSetupWidget::updateWidget()
+ void QPageSetupWidget::setupPrinter() const
+ {
+     m_printer->setPageLayout(m_pageLayout);
++    m_printer->setPageOrientation(m_pageLayout.orientation());
+ #if QT_CONFIG(cups)
+     QCUPSSupport::PagesPerSheet pagesPerSheet = qvariant_cast<QCUPSSupport::PagesPerSheet>(m_ui.pagesPerSheetCombo->currentData()
+ );
+diff --git a/qtbase/src/printsupport/dialogs/qprintdialog.qrc b/qtbase/src/printsupport/dialogs/qprintdialog.qrc
+index 5a579baa55..10b8e1d341 100644
+--- a/qtbase/src/printsupport/dialogs/qprintdialog.qrc
++++ b/qtbase/src/printsupport/dialogs/qprintdialog.qrc
+@@ -1,9 +1,9 @@
+ <!DOCTYPE RCC><RCC version="1.0">
+ <qresource prefix="/qt-project.org/dialogs/qprintpreviewdialog">
+-<file>images/fit-page-24.png</file>
+-<file>images/fit-page-32.png</file>
+-<file>images/fit-width-24.png</file>
+-<file>images/fit-width-32.png</file>
++<file>images/zoom-fit-page-24.png</file>
++<file>images/zoom-fit-page-32.png</file>
++<file>images/zoom-fit-width-24.png</file>
++<file>images/zoom-fit-width-32.png</file>
+ <file>images/go-first-24.png</file>
+ <file>images/go-first-32.png</file>
+ <file>images/go-last-24.png</file>
+@@ -18,14 +18,14 @@
+ <file>images/layout-portrait-32.png</file>
+ <file>images/page-setup-24.png</file>
+ <file>images/page-setup-32.png</file>
+-<file>images/print-24.png</file>
+-<file>images/print-32.png</file>
+-<file>images/view-page-multi-24.png</file>
+-<file>images/view-page-multi-32.png</file>
+-<file>images/view-page-one-24.png</file>
+-<file>images/view-page-one-32.png</file>
+-<file>images/view-page-sided-24.png</file>
+-<file>images/view-page-sided-32.png</file>
++<file>images/printer-24.png</file>
++<file>images/printer-32.png</file>
++<file>images/view-pages-overview-24.png</file>
++<file>images/view-pages-overview-32.png</file>
++<file>images/view-pages-single-24.png</file>
++<file>images/view-pages-single-32.png</file>
++<file>images/view-pages-facing-24.png</file>
++<file>images/view-pages-facing-32.png</file>
+ <file>images/zoom-in-24.png</file>
+ <file>images/zoom-in-32.png</file>
+ <file>images/zoom-out-24.png</file>
+diff --git a/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp b/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
+index c5b845f4ec..5a5ba1d0a8 100644
+--- a/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
++++ b/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
+@@ -702,13 +702,14 @@ void QPrintDialogPrivate::selectPrinter(const QPrinter::OutputFormat outputForma
+         else
+             options.grayscale->setChecked(true);
+ 
+-        // keep duplex value explicitly set by user, if any, and selected printer supports it;
+-        // use device default otherwise
++        // duplex priorities to be as follows:
++        // 1) a user-selected duplex value in the dialog has highest prority
++        // 2) duplex value set in the QPrinter
+         QPrint::DuplexMode duplex;
+         if (explicitDuplexMode != QPrint::DuplexAuto && supportedDuplexMode.contains(explicitDuplexMode))
+             duplex = explicitDuplexMode;
+         else
+-            duplex = top->d->m_currentPrintDevice.defaultDuplexMode();
++            duplex = static_cast<QPrint::DuplexMode>(p->duplex());
+         switch (duplex) {
+         case QPrint::DuplexNone:
+             options.noDuplex->setChecked(true); break;
+@@ -1242,10 +1243,10 @@ void QUnixPrintWidgetPrivate::_q_printerChanged(int index)
+             QString filename = widget.filename->text();
+             widget.filename->setText(filename);
+             widget.lOutput->setEnabled(true);
+-            if (optionsPane)
+-                optionsPane->selectPrinter(QPrinter::PdfFormat);
+             printer->setOutputFormat(QPrinter::PdfFormat);
+             m_currentPrintDevice = QPrintDevice();
++            if (optionsPane)
++                optionsPane->selectPrinter(QPrinter::PdfFormat);
+             return;
+         }
+     }
+diff --git a/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp b/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
+index 39575d5f57..23b7e89538 100644
+--- a/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
++++ b/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
+@@ -352,7 +352,7 @@ void QPrintPreviewDialogPrivate::init(QPrinter *_printer)
+ static inline void qt_setupActionIcon(QAction *action, QLatin1String name)
+ {
+     QLatin1String imagePrefix(":/qt-project.org/dialogs/qprintpreviewdialog/images/");
+-    QIcon icon;
++    QIcon icon = QIcon::fromTheme(name);
+     icon.addFile(imagePrefix + name + QLatin1String("-24.png"), QSize(24, 24));
+     icon.addFile(imagePrefix + name + QLatin1String("-32.png"), QSize(32, 32));
+     action->setIcon(icon);
+@@ -383,8 +383,8 @@ void QPrintPreviewDialogPrivate::setupActions()
+     fitPageAction->setObjectName(QLatin1String("fitPageAction"));
+     fitWidthAction->setCheckable(true);
+     fitPageAction->setCheckable(true);
+-    qt_setupActionIcon(fitWidthAction, QLatin1String("fit-width"));
+-    qt_setupActionIcon(fitPageAction, QLatin1String("fit-page"));
++    qt_setupActionIcon(fitWidthAction, QLatin1String("zoom-fit-width"));
++    qt_setupActionIcon(fitPageAction, QLatin1String("zoom-fit-page"));
+     QObject::connect(fitGroup, SIGNAL(triggered(QAction*)), q, SLOT(_q_fit(QAction*)));
+ 
+     // Zoom
+@@ -410,9 +410,9 @@ void QPrintPreviewDialogPrivate::setupActions()
+     singleModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show single page"));
+     facingModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show facing pages"));
+     overviewModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show overview of all pages"));
+-    qt_setupActionIcon(singleModeAction, QLatin1String("view-page-one"));
+-    qt_setupActionIcon(facingModeAction, QLatin1String("view-page-sided"));
+-    qt_setupActionIcon(overviewModeAction, QLatin1String("view-page-multi"));
++    qt_setupActionIcon(singleModeAction, QLatin1String("view-pages-single"));
++    qt_setupActionIcon(facingModeAction, QLatin1String("view-pages-facing"));
++    qt_setupActionIcon(overviewModeAction, QLatin1String("view-pages-overview"));
+     singleModeAction->setObjectName(QLatin1String("singleModeAction"));
+     facingModeAction->setObjectName(QLatin1String("facingModeAction"));
+     overviewModeAction->setObjectName(QLatin1String("overviewModeAction"));
+@@ -426,7 +426,7 @@ void QPrintPreviewDialogPrivate::setupActions()
+     printerGroup = new QActionGroup(q);
+     printAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Print"));
+     pageSetupAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Page setup"));
+-    qt_setupActionIcon(printAction, QLatin1String("print"));
++    qt_setupActionIcon(printAction, QLatin1String("printer"));
+     qt_setupActionIcon(pageSetupAction, QLatin1String("page-setup"));
+     QObject::connect(printAction, SIGNAL(triggered(bool)), q, SLOT(_q_print()));
+     QObject::connect(pageSetupAction, SIGNAL(triggered(bool)), q, SLOT(_q_pageSetup()));
+diff --git a/qtbase/src/sql/kernel/qsqlquery.cpp b/qtbase/src/sql/kernel/qsqlquery.cpp
+index 32c6166c79..60afef10c3 100644
+--- a/qtbase/src/sql/kernel/qsqlquery.cpp
++++ b/qtbase/src/sql/kernel/qsqlquery.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2022 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtSql module of the Qt Toolkit.
+@@ -377,6 +377,10 @@ bool QSqlQuery::exec(const QString& query)
+     QElapsedTimer t;
+     t.start();
+ #endif
++    if (!driver()) {
++        qWarning("QSqlQuery::exec: called before driver has been set up");
++        return false;
++    }
+     if (d->ref.loadRelaxed() != 1) {
+         bool fo = isForwardOnly();
+         *this = QSqlQuery(driver()->createResult());
+diff --git a/qtbase/src/testlib/qabstractitemmodeltester.cpp b/qtbase/src/testlib/qabstractitemmodeltester.cpp
+index 8efb9c53d4..ce062f66d7 100644
+--- a/qtbase/src/testlib/qabstractitemmodeltester.cpp
++++ b/qtbase/src/testlib/qabstractitemmodeltester.cpp
+@@ -454,7 +454,7 @@ void QAbstractItemModelTesterPrivate::parent()
+ 
+     // Common error test #2, make sure that a second level index has a parent
+     // that is the first level index.
+-    if (model->rowCount(topIndex) > 0) {
++    if (model->rowCount(topIndex) > 0 && model->columnCount(topIndex) > 0) {
+         QModelIndex childIndex = model->index(0, 0, topIndex);
+         MODELTESTER_VERIFY(childIndex.isValid());
+         MODELTESTER_COMPARE(model->parent(childIndex), topIndex);
+diff --git a/qtbase/src/testlib/qasciikey.cpp b/qtbase/src/testlib/qasciikey.cpp
+index 9a308da2bc..93498b256f 100644
+--- a/qtbase/src/testlib/qasciikey.cpp
++++ b/qtbase/src/testlib/qasciikey.cpp
+@@ -498,6 +498,11 @@ char QTest::keyToAscii(Qt::Key key)
+     case Qt::Key_LaunchE : return 0; // = 0x10b0,
+     case Qt::Key_LaunchF : return 0; // = 0x10b1,
+ 
++    // Keypad navigation keys
++    case Qt::Key_Select : return 0; // = 0x01010000
++    case Qt::Key_Yes : return 0; // = 0x01010001
++    case Qt::Key_No : return 0; // = 0x01010002
++
+     default: QTEST_ASSERT(false); return 0;
+     }
+ }
+diff --git a/qtbase/src/testlib/qtestresult.cpp b/qtbase/src/testlib/qtestresult.cpp
+index 88028aac6e..2e89930776 100644
+--- a/qtbase/src/testlib/qtestresult.cpp
++++ b/qtbase/src/testlib/qtestresult.cpp
+@@ -251,7 +251,8 @@ bool QTestResult::verify(bool statement, const char *statementStr,
+ {
+     QTEST_ASSERT(statementStr);
+ 
+-    char msg[1024] = {'\0'};
++    char msg[1024];
++    msg[0] = '\0';
+ 
+     if (QTestLog::verboseLevel() >= 2) {
+         qsnprintf(msg, 1024, "QVERIFY(%s)", statementStr);
+@@ -309,7 +310,8 @@ static bool compareHelper(bool success, const char *failureMsg,
+                           bool hasValues = true)
+ {
+     const size_t maxMsgLen = 1024;
+-    char msg[maxMsgLen] = {'\0'};
++    char msg[maxMsgLen];
++    msg[0] = '\0';
+ 
+     QTEST_ASSERT(expected);
+     QTEST_ASSERT(actual);
+diff --git a/qtbase/src/widgets/dialogs/qcolordialog.cpp b/qtbase/src/widgets/dialogs/qcolordialog.cpp
+index 4247731275..cb325be85c 100644
+--- a/qtbase/src/widgets/dialogs/qcolordialog.cpp
++++ b/qtbase/src/widgets/dialogs/qcolordialog.cpp
+@@ -78,7 +78,10 @@
+ #include "qwindow.h"
+ 
+ #include "private/qdialog_p.h"
++#include "private/qguiapplication_p.h"
+ 
++#include <qpa/qplatformservices.h>
++#include <qpa/qplatformintegration.h>
+ #include <algorithm>
+ 
+ QT_BEGIN_NAMESPACE
+@@ -1611,6 +1614,20 @@ void QColorDialogPrivate::_q_newStandard(int r, int c)
+ void QColorDialogPrivate::_q_pickScreenColor()
+ {
+     Q_Q(QColorDialog);
++
++    auto *platformServices = QGuiApplicationPrivate::platformIntegration()->services();
++    if (platformServices->hasCapability(QPlatformServices::Capability::ColorPicking)) {
++        if (auto *colorPicker = platformServices->colorPicker(q->windowHandle())) {
++            q->connect(colorPicker, &QPlatformServiceColorPicker::colorPicked, q,
++                       [q, colorPicker](const QColor &color) {
++                           colorPicker->deleteLater();
++                           q->setCurrentColor(color);
++                       });
++            colorPicker->pickColor();
++            return;
++        }
++    }
++
+     if (!colorPickingEventFilter)
+         colorPickingEventFilter = new QColorPickingEventFilter(this, q);
+     q->installEventFilter(colorPickingEventFilter);
+diff --git a/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp b/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
+index e120817edc..8ea36b5427 100644
+--- a/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
++++ b/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
+@@ -400,12 +400,7 @@ bool QAbstractItemDelegate::helpEvent(QHelpEvent *event,
+         const QString tooltip = index.isValid() ?
+               d->textForRole(Qt::ToolTipRole, index.data(Qt::ToolTipRole), option.locale, precision) :
+               QString();
+-        QRect rect;
+-        if (index.isValid()) {
+-            const QRect r = view->visualRect(index);
+-            rect = QRect(view->mapToGlobal(r.topLeft()), r.size());
+-        }
+-        QToolTip::showText(he->globalPos(), tooltip, view, rect);
++        QToolTip::showText(he->globalPos(), tooltip, view->viewport(), option.rect);
+         event->setAccepted(!tooltip.isEmpty());
+         break;
+         }
+diff --git a/qtbase/src/widgets/itemviews/qlistview.cpp b/qtbase/src/widgets/itemviews/qlistview.cpp
+index 2b34476642..eebfaa030e 100644
+--- a/qtbase/src/widgets/itemviews/qlistview.cpp
++++ b/qtbase/src/widgets/itemviews/qlistview.cpp
+@@ -3386,6 +3386,7 @@ void QIconModeViewBase::updateContentsSize()
+ */
+ void QListView::currentChanged(const QModelIndex &current, const QModelIndex &previous)
+ {
++    QAbstractItemView::currentChanged(current, previous);
+ #ifndef QT_NO_ACCESSIBILITY
+     if (QAccessible::isActive()) {
+         if (current.isValid()) {
+@@ -3396,7 +3397,6 @@ void QListView::currentChanged(const QModelIndex &current, const QModelIndex &pr
+         }
+     }
+ #endif
+-    QAbstractItemView::currentChanged(current, previous);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/widgets/itemviews/qtableview.cpp b/qtbase/src/widgets/itemviews/qtableview.cpp
+index 934ac581b2..f79bb24249 100644
+--- a/qtbase/src/widgets/itemviews/qtableview.cpp
++++ b/qtbase/src/widgets/itemviews/qtableview.cpp
+@@ -1013,6 +1013,7 @@ void QTableViewPrivate::drawCell(QPainter *painter, const QStyleOptionViewItem &
+ int QTableViewPrivate::widthHintForIndex(const QModelIndex &index, int hint, const QStyleOptionViewItem &option) const
+ {
+     Q_Q(const QTableView);
++    const int oldHint = hint;
+     QWidget *editor = editorForIndex(index).widget.data();
+     if (editor && persistent.contains(editor)) {
+         hint = qMax(hint, editor->sizeHint().width());
+@@ -1021,6 +1022,17 @@ int QTableViewPrivate::widthHintForIndex(const QModelIndex &index, int hint, con
+         hint = qBound(min, hint, max);
+     }
+     hint = qMax(hint, q->itemDelegate(index)->sizeHint(option, index).width());
++
++    if (hasSpans()) {
++        auto span = spans.spanAt(index.column(), index.row());
++        if (span && span->m_left == index.column() && span->m_top == index.row()) {
++            // spans are screwed up when sections are moved
++            const auto left = logicalColumn(span->m_left);
++            for (int i = 1; i <= span->width(); ++i)
++               hint -= q->columnWidth(visualColumn(left + i));
++        }
++        hint = std::max(hint, oldHint);
++    }
+     return hint;
+ }
+ 
+@@ -1053,6 +1065,11 @@ int QTableViewPrivate::heightHintForIndex(const QModelIndex &index, int hint, QS
+         option.rect.setHeight(height);
+         option.rect.setX(q->columnViewportPosition(index.column()));
+         option.rect.setWidth(q->columnWidth(index.column()));
++        if (hasSpans()) {
++            auto span = spans.spanAt(index.column(), index.row());
++            if (span && span->m_left == index.column() && span->m_top == index.row())
++                option.rect.setWidth(std::max(option.rect.width(), visualSpanRect(*span).width()));
++        }
+         // 1px less space when grid is shown (see drawCell)
+         if (showGrid)
+             option.rect.setWidth(option.rect.width() - 1);
+diff --git a/qtbase/src/widgets/kernel/qaction.h b/qtbase/src/widgets/kernel/qaction.h
+index 258a1ea0a0..737c1e8285 100644
+--- a/qtbase/src/widgets/kernel/qaction.h
++++ b/qtbase/src/widgets/kernel/qaction.h
+@@ -81,7 +81,7 @@ class Q_WIDGETS_EXPORT QAction : public QObject
+     Q_PROPERTY(MenuRole menuRole READ menuRole WRITE setMenuRole NOTIFY changed)
+     Q_PROPERTY(bool iconVisibleInMenu READ isIconVisibleInMenu WRITE setIconVisibleInMenu NOTIFY changed)
+     Q_PROPERTY(bool shortcutVisibleInContextMenu READ isShortcutVisibleInContextMenu WRITE setShortcutVisibleInContextMenu NOTIFY changed)
+-    Q_PROPERTY(Priority priority READ priority WRITE setPriority)
++    Q_PROPERTY(Priority priority READ priority WRITE setPriority NOTIFY changed)
+ 
+ public:
+     // note this is copied into qplatformmenu.h, which must stay in sync
+diff --git a/qtbase/src/widgets/kernel/qwidget.cpp b/qtbase/src/widgets/kernel/qwidget.cpp
+index 9eba1e001e..26f6d27e18 100644
+--- a/qtbase/src/widgets/kernel/qwidget.cpp
++++ b/qtbase/src/widgets/kernel/qwidget.cpp
+@@ -5296,7 +5296,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
+         QWidgetEffectSourcePrivate *sourced = static_cast<QWidgetEffectSourcePrivate *>
+                                                          (source->d_func());
+         if (!sourced->context) {
+-            const QRegion effectRgn(rgn.boundingRect());
++            const QRegion effectRgn((flags & UseEffectRegionBounds) ? rgn.boundingRect() : rgn);
+             QWidgetPaintContext context(pdev, effectRgn, offset, flags, sharedPainter, repaintManager);
+             sourced->context = &context;
+             if (!sharedPainter) {
+@@ -5328,6 +5328,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
+         }
+     }
+ #endif // QT_CONFIG(graphicseffect)
++    flags = flags & ~UseEffectRegionBounds;
+ 
+     const bool alsoOnScreen = flags & DrawPaintOnScreen;
+     const bool recursive = flags & DrawRecursive;
+diff --git a/qtbase/src/widgets/kernel/qwidget_p.h b/qtbase/src/widgets/kernel/qwidget_p.h
+index eef6b8fa2c..c432f4b5d5 100644
+--- a/qtbase/src/widgets/kernel/qwidget_p.h
++++ b/qtbase/src/widgets/kernel/qwidget_p.h
+@@ -229,7 +229,8 @@ public:
+         DontSubtractOpaqueChildren = 0x10,
+         DontDrawOpaqueChildren = 0x20,
+         DontDrawNativeChildren = 0x40,
+-        DontSetCompositionMode = 0x80
++        DontSetCompositionMode = 0x80,
++        UseEffectRegionBounds = 0x100
+     };
+     Q_DECLARE_FLAGS(DrawWidgetFlags, DrawWidgetFlag)
+     Q_FLAG(DrawWidgetFlags)
+diff --git a/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp b/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
+index 02880b34da..0d44e1326d 100644
+--- a/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
++++ b/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
+@@ -1018,7 +1018,8 @@ void QWidgetRepaintManager::paintAndFlush()
+ 
+     // Paint the rest with composition.
+     if (repaintAllWidgets || !dirtyCopy.isEmpty()) {
+-        QWidgetPrivate::DrawWidgetFlags flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive;
++        QWidgetPrivate::DrawWidgetFlags flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive
++                | QWidgetPrivate::UseEffectRegionBounds;
+         tlw->d_func()->drawWidget(store->paintDevice(), dirtyCopy, QPoint(), flags, nullptr, this);
+     }
+ 
+diff --git a/qtbase/src/widgets/styles/qfusionstyle.cpp b/qtbase/src/widgets/styles/qfusionstyle.cpp
+index f4345d97c4..962912c838 100644
+--- a/qtbase/src/widgets/styles/qfusionstyle.cpp
++++ b/qtbase/src/widgets/styles/qfusionstyle.cpp
+@@ -1772,14 +1772,6 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio
+             proxy()->drawControl(CE_PushButtonLabel, &subopt, painter, widget);
+         }
+         break;
+-    case CE_PushButtonLabel:
+-        if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
+-            QStyleOptionButton b(*button);
+-            // no PM_ButtonShiftHorizontal and PM_ButtonShiftVertical for fusion style
+-            b.state &= ~(State_On | State_Sunken);
+-            QCommonStyle::drawControl(element, &b, painter, widget);
+-        }
+-        break;
+     case CE_MenuBarEmptyArea:
+         painter->save();
+     {
+diff --git a/qtbase/src/widgets/util/qcompleter.cpp b/qtbase/src/widgets/util/qcompleter.cpp
+index 18b24063d8..ef7207a8a3 100644
+--- a/qtbase/src/widgets/util/qcompleter.cpp
++++ b/qtbase/src/widgets/util/qcompleter.cpp
+@@ -1120,6 +1120,8 @@ void QCompleter::setModel(QAbstractItemModel *model)
+ {
+     Q_D(QCompleter);
+     QAbstractItemModel *oldModel = d->proxy->sourceModel();
++    if (oldModel == model)
++        return;
+ #if QT_CONFIG(filesystemmodel)
+     if (qobject_cast<const QFileSystemModel *>(oldModel))
+         setCompletionRole(Qt::EditRole); // QTBUG-54642, clear FileNameRole set by QFileSystemModel
+diff --git a/qtbase/src/widgets/widgets/qabstractbutton.cpp b/qtbase/src/widgets/widgets/qabstractbutton.cpp
+index a128b23950..dc40bf62fb 100644
+--- a/qtbase/src/widgets/widgets/qabstractbutton.cpp
++++ b/qtbase/src/widgets/widgets/qabstractbutton.cpp
+@@ -56,6 +56,7 @@
+ #ifndef QT_NO_ACCESSIBILITY
+ #include "qaccessible.h"
+ #endif
++#include <qpa/qplatformtheme.h>
+ 
+ #include <algorithm>
+ 
+@@ -1076,19 +1077,19 @@ void QAbstractButton::keyPressEvent(QKeyEvent *e)
+ {
+     Q_D(QAbstractButton);
+     bool next = true;
+-    switch (e->key()) {
+-    case Qt::Key_Enter:
+-    case Qt::Key_Return:
+-        e->ignore();
+-        break;
+-    case Qt::Key_Select:
+-    case Qt::Key_Space:
+-        if (!e->isAutoRepeat()) {
+-            setDown(true);
+-            repaint();
+-            d->emitPressed();
+-        }
+-        break;
++
++    const auto key = static_cast<Qt::Key>(e->key());
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(key) && !e->isAutoRepeat()) {
++        setDown(true);
++        repaint();
++        d->emitPressed();
++        return;
++    }
++
++    switch (key) {
+     case Qt::Key_Up:
+         next = false;
+         Q_FALLTHROUGH();
+@@ -1153,15 +1154,15 @@ void QAbstractButton::keyReleaseEvent(QKeyEvent *e)
+     if (!e->isAutoRepeat())
+         d->repeatTimer.stop();
+ 
+-    switch (e->key()) {
+-    case Qt::Key_Select:
+-    case Qt::Key_Space:
+-        if (!e->isAutoRepeat() && d->down)
+-            d->click();
+-        break;
+-    default:
+-        e->ignore();
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(static_cast<Qt::Key>(e->key())) && !e->isAutoRepeat() && d->down) {
++        d->click();
++        return;
+     }
++
++    e->ignore();
+ }
+ 
+ /*!\reimp
+diff --git a/qtbase/src/widgets/widgets/qcombobox.cpp b/qtbase/src/widgets/widgets/qcombobox.cpp
+index 7a496c27e0..0a3d96647b 100644
+--- a/qtbase/src/widgets/widgets/qcombobox.cpp
++++ b/qtbase/src/widgets/widgets/qcombobox.cpp
+@@ -3352,7 +3352,23 @@ void QComboBox::keyPressEvent(QKeyEvent *e)
+ 
+     Move move = NoMove;
+     int newIndex = currentIndex();
+-    switch (e->key()) {
++
++    bool pressLikeButton = !d->lineEdit;
++#ifdef QT_KEYPAD_NAVIGATION
++    pressLikeButton |= QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus();
++#endif
++    auto key = static_cast<Qt::Key>(e->key());
++    if (pressLikeButton) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(key)) {
++            showPopup();
++            return;
++        }
++    }
++
++    switch (key) {
+     case Qt::Key_Up:
+         if (e->modifiers() & Qt::ControlModifier)
+             break; // pass to line edit for auto completion
+@@ -3394,26 +3410,11 @@ void QComboBox::keyPressEvent(QKeyEvent *e)
+             return;
+         }
+         break;
+-    case Qt::Key_Space:
+-        if (!d->lineEdit) {
+-            showPopup();
+-            return;
+-        }
+-        break;
+-    case Qt::Key_Enter:
+-    case Qt::Key_Return:
+     case Qt::Key_Escape:
+         if (!d->lineEdit)
+             e->ignore();
+         break;
+ #ifdef QT_KEYPAD_NAVIGATION
+-    case Qt::Key_Select:
+-        if (QApplicationPrivate::keypadNavigationEnabled()
+-                && (!hasEditFocus() || !d->lineEdit)) {
+-            showPopup();
+-            return;
+-        }
+-        break;
+     case Qt::Key_Left:
+     case Qt::Key_Right:
+         if (QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus())
+diff --git a/qtbase/src/widgets/widgets/qdatetimeedit_p.h b/qtbase/src/widgets/widgets/qdatetimeedit_p.h
+index d36b6f8f9a..e0df5b5158 100644
+--- a/qtbase/src/widgets/widgets/qdatetimeedit_p.h
++++ b/qtbase/src/widgets/widgets/qdatetimeedit_p.h
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2018 The Qt Company Ltd.
++** Copyright (C) 2021 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtWidgets module of the Qt Toolkit.
+diff --git a/qtbase/src/widgets/widgets/qgroupbox.cpp b/qtbase/src/widgets/widgets/qgroupbox.cpp
+index 02a0bed325..3f3eccc370 100644
+--- a/qtbase/src/widgets/widgets/qgroupbox.cpp
++++ b/qtbase/src/widgets/widgets/qgroupbox.cpp
+@@ -54,6 +54,8 @@
+ #include "qaccessible.h"
+ #endif
+ #include <private/qwidget_p.h>
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
+ 
+ #include "qdebug.h"
+ 
+@@ -360,7 +362,10 @@ bool QGroupBox::event(QEvent *e)
+         return true;
+     case QEvent::KeyPress: {
+         QKeyEvent *k = static_cast<QKeyEvent*>(e);
+-        if (!k->isAutoRepeat() && (k->key() == Qt::Key_Select || k->key() == Qt::Key_Space)) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (!k->isAutoRepeat() && buttonPressKeys.contains(static_cast<Qt::Key>(k->key()))) {
+             d->pressedControl = QStyle::SC_GroupBoxCheckBox;
+             update(style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxCheckBox, this));
+             return true;
+@@ -369,7 +374,10 @@ bool QGroupBox::event(QEvent *e)
+     }
+     case QEvent::KeyRelease: {
+         QKeyEvent *k = static_cast<QKeyEvent*>(e);
+-        if (!k->isAutoRepeat() && (k->key() == Qt::Key_Select || k->key() == Qt::Key_Space)) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (!k->isAutoRepeat() && buttonPressKeys.contains(static_cast<Qt::Key>(k->key()))) {
+             bool toggle = (d->pressedControl == QStyle::SC_GroupBoxLabel
+                            || d->pressedControl == QStyle::SC_GroupBoxCheckBox);
+             d->pressedControl = QStyle::SC_None;
+diff --git a/qtbase/src/widgets/widgets/qlabel.cpp b/qtbase/src/widgets/widgets/qlabel.cpp
+index 30ff80cbb0..cf2605c17c 100644
+--- a/qtbase/src/widgets/widgets/qlabel.cpp
++++ b/qtbase/src/widgets/widgets/qlabel.cpp
+@@ -421,9 +421,6 @@ void QLabel::setPixmap(const QPixmap &pixmap)
+         d->pixmap = new QPixmap(pixmap);
+     }
+ 
+-    if (d->pixmap->depth() == 1 && !d->pixmap->mask())
+-        d->pixmap->setMask(*((QBitmap *)d->pixmap));
+-
+     d->updateLabel();
+ }
+ 
+diff --git a/qtbase/src/widgets/widgets/qtoolbararealayout.cpp b/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
+index 493c094cc1..d5f4b59017 100644
+--- a/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
++++ b/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
+@@ -1367,7 +1367,7 @@ bool QToolBarAreaLayout::restoreState(QDataStream &stream, const QList<QToolBar*
+                 item.widgetItem = new QWidgetItemV2(toolBar);
+                 toolBar->setOrientation(floating ? ((shown & 2) ? Qt::Vertical : Qt::Horizontal) : dock.o);
+                 toolBar->setVisible(shown & 1);
+-                toolBar->d_func()->setWindowState(floating, true, rect);
++                toolBar->d_func()->setWindowState(floating, false, rect);
+ 
+                 item.preferredSize = item.size;
+                 line.toolBarItems.append(item);
+diff --git a/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp b/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
+index 212c0a2e13..3c77b1ba0b 100644
+--- a/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
++++ b/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
+@@ -126,8 +126,7 @@ public:
+ 
+ void tst_QtConcurrentIterateKernel::instantiate()
+ {
+-    auto future = startThreadEngine(new PrintFor(0, 40)).startAsynchronously();
+-    future.waitForFinished();
++    startThreadEngine(new PrintFor(0, 40)).startBlocking();
+     QCOMPARE(iterations.loadRelaxed(), 40);
+ }
+ 
+@@ -166,10 +165,8 @@ void tst_QtConcurrentIterateKernel::stresstest()
+     const int times = 50;
+     for (int i = 0; i < times; ++i) {
+         counter.storeRelaxed(0);
+-        // ThreadEngine will delete f when it finishes
+-        auto f = new CountFor(0, iterations);
+-        auto future = f->startAsynchronously();
+-        future.waitForFinished();
++        CountFor f(0, iterations);
++        f.startBlocking();
+         QCOMPARE(counter.loadRelaxed(), iterations);
+     }
+ }
+@@ -177,11 +174,8 @@ void tst_QtConcurrentIterateKernel::stresstest()
+ void tst_QtConcurrentIterateKernel::noIterations()
+ {
+     const int times = 20000;
+-    for (int i = 0; i < times; ++i) {
+-        auto future = startThreadEngine(new IterateKernel<TestIterator, void>(0, 0))
+-                              .startAsynchronously();
+-        future.waitForFinished();
+-    }
++    for (int i = 0; i < times; ++i)
++        startThreadEngine(new IterateKernel<TestIterator, void>(0, 0)).startBlocking();
+ }
+ 
+ QMutex threadsMutex;
+@@ -236,10 +230,8 @@ void tst_QtConcurrentIterateKernel::throttling()
+ 
+     threads.clear();
+ 
+-    // ThreadEngine will delete f when it finishes
+-    auto f = new ThrottleFor(0, totalIterations);
+-    auto future = f->startAsynchronously();
+-    future.waitForFinished();
++    ThrottleFor f(0, totalIterations);
++    f.startBlocking();
+ 
+     QCOMPARE(iterations.loadRelaxed(), totalIterations);
+ 
+diff --git a/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp b/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
+index ac7be7acdd..81bc64c8d9 100644
+--- a/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
++++ b/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
+@@ -65,9 +65,16 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::runDirectly()
+ {
+-    PrintUser *engine = new PrintUser();
+-    QFuture<void> f = engine->startAsynchronously();
+-    f.waitForFinished();
++    {
++        PrintUser engine;
++        engine.startSingleThreaded();
++        engine.startBlocking();
++    }
++    {
++        PrintUser *engine = new PrintUser();
++        QFuture<void> f = engine->startAsynchronously();
++        f.waitForFinished();
++    }
+ }
+ 
+ class StringResultUser : public ThreadEngine<QString>
+@@ -99,10 +106,8 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::result()
+ {
+-    // ThreadEngine will delete 'engine' when it finishes
+-    auto engine = new StringResultUser();
+-    auto future = engine->startAsynchronously();
+-    QCOMPARE(future.result(), QString("Foo"));
++    StringResultUser engine;
++    QCOMPARE(*engine.startBlocking(), QString("Foo"));
+ }
+ 
+ class VoidResultUser : public ThreadEngine<void>
+@@ -128,9 +133,17 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::runThroughStarter()
+ {
+-    ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
+-    QFuture<QString> f = starter.startAsynchronously();
+-    QCOMPARE(f.result(), QString("Foo"));
++    {
++        ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
++        QFuture<QString>  f = starter.startAsynchronously();
++        QCOMPARE(f.result(), QString("Foo"));
++    }
++
++    {
++        ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
++        QString str = starter.startBlocking();
++        QCOMPARE(str, QString("Foo"));
++    }
+ }
+ 
+ class CancelUser : public ThreadEngine<void>
+@@ -213,6 +226,12 @@ void tst_QtConcurrentThreadEngine::throttle()
+         f.waitForFinished();
+         QCOMPARE(count.loadRelaxed(), 0);
+     }
++
++    for (int i = 0; i < repeats; ++i) {
++        ThrottleAlwaysUser t;
++        t.startBlocking();
++        QCOMPARE(count.loadRelaxed(), 0);
++    }
+ }
+ 
+ QSet<QThread *> threads;
+@@ -249,17 +268,35 @@ void tst_QtConcurrentThreadEngine::threadCount()
+ {
+     const int repeats = 10;
+     for (int i = 0; i < repeats; ++i) {
++        ThreadCountUser t;
++        t.startBlocking();
++        int count = threads.count();
++        int count_expected = QThreadPool::globalInstance()->maxThreadCount() + 1; // +1 for the main thread.
++        if (count != count_expected)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, count_expected);
++
+         (new ThreadCountUser())->startAsynchronously().waitForFinished();
+-        const auto count = threads.count();
+-        const auto maxThreadCount = QThreadPool::globalInstance()->maxThreadCount();
+-        QVERIFY(count <= maxThreadCount);
+-        QVERIFY(!threads.contains(QThread::currentThread()));
++        count = threads.count();
++        count_expected = QThreadPool::globalInstance()->maxThreadCount();
++        if (count != count_expected)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, count_expected);
+     }
+ 
+     // Set the finish flag immediately, this should give us one thread only.
+     for (int i = 0; i < repeats; ++i) {
++        ThreadCountUser t(true /*finishImmediately*/);
++        t.startBlocking();
++        int count = threads.count();
++        if (count != 1)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, 1);
++
+         (new ThreadCountUser(true /*finishImmediately*/))->startAsynchronously().waitForFinished();
+-        const auto count = threads.count();
++        count = threads.count();
++        if (count != 1)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
+         QCOMPARE(count, 1);
+         QVERIFY(!threads.contains(QThread::currentThread()));
+     }
+@@ -400,6 +437,7 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::exceptions()
+ {
++    // Asynchronous mode:
+     {
+         bool caught = false;
+         try  {
+@@ -412,6 +450,32 @@ void tst_QtConcurrentThreadEngine::exceptions()
+         QVERIFY2(caught, "did not get exception");
+     }
+ 
++    // Blocking mode:
++    // test throwing the exception from a worker thread.
++    {
++        bool caught = false;
++        try  {
++            QtConcurrentExceptionThrower e(QThread::currentThread());
++            e.startBlocking();
++        } catch (const QException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // test throwing the exception from the main thread (different code path)
++    {
++        bool caught = false;
++        try  {
++            QtConcurrentExceptionThrower e(0);
++            e.startBlocking();
++        } catch (const QException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // Asynchronous mode:
+     {
+         bool caught = false;
+         try  {
+@@ -423,6 +487,31 @@ void tst_QtConcurrentThreadEngine::exceptions()
+         }
+         QVERIFY2(caught, "did not get exception");
+     }
++
++    // Blocking mode:
++    // test throwing the exception from a worker thread.
++    {
++        bool caught = false;
++        try  {
++            UnrelatedExceptionThrower e(QThread::currentThread());
++            e.startBlocking();
++        } catch (const QUnhandledException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // test throwing the exception from the main thread (different code path)
++    {
++        bool caught = false;
++        try  {
++            UnrelatedExceptionThrower e(0);
++            e.startBlocking();
++        } catch (const QUnhandledException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
+ }
+ 
+ #endif
+diff --git a/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp b/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
+index 4968742110..f4c3fb711d 100644
+--- a/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
++++ b/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
+@@ -42,6 +42,7 @@ private slots:
+     void writeBlock_data();
+     void writeBlock();
+     void seek();
++    void invalidSeeks();
+     void seekTest_data();
+     void seekTest();
+     void read_rawdata();
+@@ -286,6 +287,29 @@ void tst_QBuffer::seek()
+     QCOMPARE(buffer.size(), pos);
+ }
+ 
++void tst_QBuffer::invalidSeeks()
++{
++    if constexpr (sizeof(qsizetype) == sizeof(qint64)) {
++        // sizeof(qsizetype) == sizeof(qint64), so +1 would overflow
++        QSKIP("This is a 32-bit-only test.");
++    } else {
++        QBuffer buffer;
++        buffer.open(QIODevice::WriteOnly);
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++        constexpr qint64 MaxQByteArrayCapacity = (std::numeric_limits<qsizetype>::max)();
++        // this should fail fast, not after trying to allocate nearly 2 GiB of data,
++        // potentially crashing in the process:
++        QVERIFY(!buffer.seek(2 * MaxQByteArrayCapacity - 1));
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++        // ditto:
++        QVERIFY(!buffer.seek(MaxQByteArrayCapacity + 1));
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++    }
++}
++
+ void tst_QBuffer::seekTest_data()
+ {
+     writeBlock_data();
+diff --git a/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp b/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
+index da5327594c..4a04e0f7c6 100644
+--- a/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
++++ b/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
+@@ -561,7 +561,8 @@ protected:
+     qint64 readData(char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf->size() - offset));
+-        memcpy(data, buf->constData() + offset, maxSize);
++        if (maxSize > 0)
++            memcpy(data, buf->constData() + offset, maxSize);
+         offset += maxSize;
+         return maxSize;
+     }
+@@ -604,13 +605,15 @@ protected:
+     qint64 readData(char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf.size() - pos()));
+-        memcpy(data, buf.constData() + pos(), maxSize);
++        if (maxSize > 0)
++            memcpy(data, buf.constData() + pos(), maxSize);
+         return maxSize;
+     }
+     qint64 writeData(const char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf.size() - pos()));
+-        memcpy(buf.data() + pos(), data, maxSize);
++        if (maxSize > 0)
++            memcpy(buf.data() + pos(), data, maxSize);
+         return maxSize;
+     }
+ 
+diff --git a/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+index db60bead64..f345a44414 100644
+--- a/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
++++ b/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+@@ -1,7 +1,8 @@
+ /****************************************************************************
+ **
+ ** Copyright (C) 2021 The Qt Company Ltd.
+-** Copyright (C) 2020 Intel Corporation.
++** Copyright (C) 2020 The Qt Company Ltd.
++** Copyright (C) 2022 Intel Corporation.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the test suite of the Qt Toolkit.
+@@ -150,6 +151,8 @@ private slots:
+     void startStopStartStopBuffers();
+     void processEventsInAReadyReadSlot_data();
+     void processEventsInAReadyReadSlot();
++    void startFromCurrentWorkingDir_data();
++    void startFromCurrentWorkingDir();
+ 
+     // keep these at the end, since they use lots of processes and sometimes
+     // caused obscure failures to occur in tests that followed them (esp. on the Mac)
+@@ -2731,5 +2734,94 @@ void tst_QProcess::finishProcessBeforeReadingDone_deprecated()
+ 
+ #endif
+ 
++enum class ChdirMode {
++    None = 0,
++    InParent,
++    InChild
++};
++Q_DECLARE_METATYPE(ChdirMode)
++
++void tst_QProcess::startFromCurrentWorkingDir_data()
++{
++    qRegisterMetaType<ChdirMode>();
++    QTest::addColumn<QString>("programPrefix");
++    QTest::addColumn<ChdirMode>("chdirMode");
++    QTest::addColumn<bool>("success");
++
++    constexpr bool IsWindows = true
++#ifdef Q_OS_UNIX
++            && false
++#endif
++            ;
++
++    // baseline: trying to execute the directory, this can't possibly succeed!
++    QTest::newRow("plain-same-cwd") << QString() << ChdirMode::None << false;
++
++    // cross-platform behavior: neither OS searches the setWorkingDirectory()
++    // dir without "./"
++    QTest::newRow("plain-child-chdir") << QString() << ChdirMode::InChild << false;
++
++    // cross-platform behavior: both OSes search the parent's CWD with "./"
++    QTest::newRow("prefixed-parent-chdir") << "./" << ChdirMode::InParent << true;
++
++    // opposite behaviors: Windows searches the parent's CWD and Unix searches
++    // the child's with "./"
++    QTest::newRow("prefixed-child-chdir") << "./" << ChdirMode::InChild << !IsWindows;
++
++    // Windows searches the parent's CWD without "./"
++    QTest::newRow("plain-parent-chdir") << QString() << ChdirMode::InParent << IsWindows;
++}
++
++void tst_QProcess::startFromCurrentWorkingDir()
++{
++    QFETCH(QString, programPrefix);
++    QFETCH(ChdirMode, chdirMode);
++    QFETCH(bool, success);
++
++    QProcess process;
++    qRegisterMetaType<QProcess::ProcessError>();
++    QSignalSpy errorSpy(&process, &QProcess::errorOccurred);
++    QVERIFY(errorSpy.isValid());
++
++    // both the dir name and the executable name
++    const QString target = QStringLiteral("testProcessNormal");
++    process.setProgram(programPrefix + target);
++
++#ifdef Q_OS_UNIX
++    // Reset PATH, to be sure it doesn't contain . or the empty path.
++    // We can't do this on Windows because DLLs are searched in PATH
++    // and Windows always searches "." anyway.
++    auto restoreEnv = qScopeGuard([old = qgetenv("PATH")] {
++        qputenv("PATH", old);
++    });
++    qputenv("PATH", "/");
++#endif
++
++    switch (chdirMode) {
++    case ChdirMode::InParent: {
++        auto restoreCwd = qScopeGuard([old = QDir::currentPath()] {
++            QDir::setCurrent(old);
++        });
++        QVERIFY(QDir::setCurrent(target));
++        process.start();
++        break;
++    }
++    case ChdirMode::InChild:
++        process.setWorkingDirectory(target);
++        Q_FALLTHROUGH();
++    case ChdirMode::None:
++        process.start();
++        break;
++    }
++
++    QCOMPARE(process.waitForStarted(), success);
++    QCOMPARE(errorSpy.count(), int(!success));
++    if (success) {
++        QVERIFY(process.waitForFinished());
++    } else {
++        QCOMPARE(process.error(), QProcess::FailedToStart);
++    }
++}
++
+ QTEST_MAIN(tst_QProcess)
+ #include "tst_qprocess.moc"
+diff --git a/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp b/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp
+index e1ea7a4552..90972caa57 100644
+--- a/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp
++++ b/qtbase/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"
+diff --git a/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+index 9bd66c0835..ed4a0bae5d 100644
+--- a/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
++++ b/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+@@ -158,6 +158,7 @@ private slots:
+     void nullReceiver();
+     void functorReferencesConnection();
+     void disconnectDisconnects();
++    void declarativeData();
+ };
+ 
+ struct QObjectCreatedOnShutdown
+@@ -7679,5 +7680,81 @@ void tst_QObject::disconnectDisconnects()
+ Q_STATIC_ASSERT(QtPrivate::HasQ_OBJECT_Macro<tst_QObject>::Value);
+ Q_STATIC_ASSERT(!QtPrivate::HasQ_OBJECT_Macro<SiblingDeleter>::Value);
+ 
++#ifdef QT_BUILD_INTERNAL
++/*
++    Since QObjectPrivate stores the declarativeData pointer in a union with the pointer
++    to the currently destroyed child, calls to the QtDeclarative handlers need to be
++    correctly guarded. QTBUG-105286
++*/
++namespace QtDeclarative {
++static QAbstractDeclarativeData *theData;
++
++static void destroyed(QAbstractDeclarativeData *data, QObject *)
++{
++    QCOMPARE(data, theData);
++}
++static void signalEmitted(QAbstractDeclarativeData *data, QObject *, int, void **)
++{
++    QCOMPARE(data, theData);
++}
++// we can't use QCOMPARE in the next two functions, as they don't return void
++static int receivers(QAbstractDeclarativeData *data, const QObject *, int)
++{
++    QTest::qCompare(data, theData, "data", "theData", __FILE__, __LINE__);
++    return 0;
++}
++static bool isSignalConnected(QAbstractDeclarativeData *data, const QObject *, int)
++{
++    QTest::qCompare(data, theData, "data", "theData", __FILE__, __LINE__);
++    return true;
++}
++
++class Object : public QObject
++{
++    Q_OBJECT
++public:
++    using QObject::QObject;
++    ~Object()
++    {
++        if (Object *p = static_cast<Object *>(parent()))
++            p->emitSignal();
++    }
++
++    void emitSignal()
++    {
++        emit theSignal();
++    }
++
++signals:
++    void theSignal();
++};
++
++}
++#endif
++
++void tst_QObject::declarativeData()
++{
++#ifdef QT_BUILD_INTERNAL
++    QScopedValueRollback destroyed(QAbstractDeclarativeData::destroyed,
++                                   QtDeclarative::destroyed);
++    QScopedValueRollback signalEmitted(QAbstractDeclarativeData::signalEmitted,
++                                       QtDeclarative::signalEmitted);
++    QScopedValueRollback receivers(QAbstractDeclarativeData::receivers,
++                                   QtDeclarative::receivers);
++    QScopedValueRollback isSignalConnected(QAbstractDeclarativeData::isSignalConnected,
++                                           QtDeclarative::isSignalConnected);
++
++    QtDeclarative::Object p;
++    QObjectPrivate *priv = QObjectPrivate::get(&p);
++    priv->declarativeData = QtDeclarative::theData = new QAbstractDeclarativeData;
++
++    connect(&p, &QtDeclarative::Object::theSignal, &p, []{
++    });
++
++    QtDeclarative::Object *child = new QtDeclarative::Object;
++    child->setParent(&p);
++#endif
++}
++
+ QTEST_MAIN(tst_QObject)
+ #include "tst_qobject.moc"
+diff --git a/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp b/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
+index 0ea422ecbc..1a3256534b 100644
+--- a/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
++++ b/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
+@@ -70,15 +70,15 @@ static inline QString testSuiteWarning()
+ 
+     QString result;
+     QTextStream str(&result);
+-    str << "\nCannot find the shared-mime-info test suite\nstarting from: "
++    str << "\nCannot find the shared-mime-info test suite\nin the parent of: "
+         << QDir::toNativeSeparators(QDir::currentPath()) << "\n"
+            "cd " << QDir::toNativeSeparators(QStringLiteral("tests/auto/corelib/mimetypes/qmimedatabase")) << "\n"
+-           "wget http://cgit.freedesktop.org/xdg/shared-mime-info/snapshot/Release-1-10.zip\n"
+-           "unzip Release-1-10.zip\n";
++           "wget https://gitlab.freedesktop.org/xdg/shared-mime-info/-/archive/2.1/shared-mime-info-2.1.zip\n"
++           "unzip shared-mime-info-2.1.zip\n";
+ #ifdef Q_OS_WIN
+-    str << "mkdir testfiles\nxcopy /s Release-1-10 s-m-i\n";
++    str << "mkdir testfiles\nxcopy /s shared-mime-info-2.1 s-m-i\n";
+ #else
+-    str << "ln -s Release-1-10 s-m-i\n";
++    str << "ln -s shared-mime-info-2.1 s-m-i\n";
+ #endif
+     return result;
+ }
+@@ -154,7 +154,7 @@ void tst_QMimeDatabase::initTestCase()
+     QVERIFY2(copyResourceFile(xmlFileName, xmlTargetFileName, &errorMessage), qPrintable(errorMessage));
+ #endif
+ 
+-    m_testSuite = QFINDTESTDATA("s-m-i/tests");
++    m_testSuite = QFINDTESTDATA("s-m-i/tests/mime-detection");
+     if (m_testSuite.isEmpty())
+         qWarning("%s", qPrintable(testSuiteWarning()));
+ 
+@@ -611,7 +611,7 @@ void tst_QMimeDatabase::allMimeTypes()
+     QVERIFY(!lst.isEmpty());
+ 
+     // Hardcoding this is the only way to check both providers find the same number of mimetypes.
+-    QCOMPARE(lst.count(), 779);
++    QCOMPARE(lst.count(), 811);
+ 
+     foreach (const QMimeType &mime, lst) {
+         const QString name = mime.name();
+@@ -631,10 +631,9 @@ void tst_QMimeDatabase::suffixes_data()
+ 
+     QTest::newRow("mimetype with a single pattern") << "application/pdf" << "*.pdf" << "pdf";
+     QTest::newRow("mimetype with multiple patterns") << "application/x-kpresenter" << "*.kpr;*.kpt" << "kpr";
+-    QTest::newRow("jpeg") << "image/jpeg" << "*.jpe;*.jpg;*.jpeg" << "jpeg";
+-    //if (KMimeType::sharedMimeInfoVersion() > KDE_MAKE_VERSION(0, 60, 0)) {
+-        QTest::newRow("mimetype with many patterns") << "application/vnd.wordperfect" << "*.wp;*.wp4;*.wp5;*.wp6;*.wpd;*.wpp" << "wp";
+-    //}
++    // The preferred suffix for image/jpeg is *.jpg, as per https://bugs.kde.org/show_bug.cgi?id=176737
++    QTest::newRow("jpeg") << "image/jpeg" << "*.jpe;*.jpg;*.jpeg" << "jpg";
++    QTest::newRow("mimetype with many patterns") << "application/vnd.wordperfect" << "*.wp;*.wp4;*.wp5;*.wp6;*.wpd;*.wpp" << "wp";
+     QTest::newRow("oasis text mimetype") << "application/vnd.oasis.opendocument.text" << "*.odt" << "odt";
+     QTest::newRow("oasis presentation mimetype") << "application/vnd.oasis.opendocument.presentation" << "*.odp" << "odp";
+     QTest::newRow("mimetype with multiple patterns") << "text/plain" << "*.asc;*.txt;*,v" << "txt";
+diff --git a/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp b/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
+index 3e58dd03cc..c8f82ef5d5 100644
+--- a/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
++++ b/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
+@@ -176,6 +176,8 @@ private Q_SLOTS:
+     void fromToVariantConversions_data();
+     void fromToVariantConversions();
+ 
++    void noLeakOnNameClash();
++
+ private:
+     QString testDataDir;
+ };
+@@ -3685,5 +3687,23 @@ void tst_QtJson::fromToVariantConversions()
+     }
+ }
+ 
++void tst_QtJson::noLeakOnNameClash()
++{
++    QJsonDocument doc = QJsonDocument::fromJson("{\"\":{\"\":0},\"\":0}");
++    QVERIFY(!doc.isNull());
++    const QJsonObject obj = doc.object();
++
++    // Removed the duplicate key.
++    QCOMPARE(obj.length(), 1);
++
++    // Retained the last of the duplicates.
++    const QJsonValue val = obj.begin().value();
++    QVERIFY(val.isDouble());
++    QCOMPARE(val.toDouble(), 0.0);
++
++    // It should not leak.
++    // In particular it should not forget to deref the container for the inner object.
++}
++
+ QTEST_MAIN(tst_QtJson)
+ #include "tst_qtjson.moc"
+diff --git a/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp b/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
+index a59b58d57f..241c3e84ac 100644
+--- a/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
++++ b/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
+@@ -63,6 +63,7 @@ private slots:
+     void isValidId_data();
+     void isValidId();
+     void malformed();
++    void serialize();
+     // Backend tests
+     void utcTest();
+     void icuTest();
+@@ -947,6 +948,33 @@ void tst_QTimeZone::malformed()
+         barf.offsetFromUtc(now);
+ }
+ 
++void tst_QTimeZone::serialize()
++{
++    int parts = 0;
++#ifndef QT_NO_DEBUG_STREAM
++    qDebug() << QTimeZone(); // to verify no crash
++    parts++;
++#endif
++#ifndef QT_NO_DATASTREAM
++    QByteArray blob;
++    {
++        QDataStream stream(&blob, QIODevice::WriteOnly);
++        stream << QTimeZone("Europe/Oslo") << QTimeZone(420) << QTimeZone() << qint64(-1);
++    }
++    QDataStream stream(&blob, QIODevice::ReadOnly);
++    QTimeZone invalid, offset, oslo;
++    qint64 minusone;
++    stream >> oslo >> offset >> invalid >> minusone;
++    QCOMPARE(oslo, QTimeZone("Europe/Oslo"));
++    QCOMPARE(offset, QTimeZone(420));
++    QVERIFY(!invalid.isValid());
++    QCOMPARE(minusone, qint64(-1));
++    parts++;
++#endif
++    if (!parts)
++        QSKIP("No serialization enabled");
++}
++
+ void tst_QTimeZone::utcTest()
+ {
+ #ifdef QT_BUILD_INTERNAL
+diff --git a/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp b/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
+index 05480c6dd2..70f4c75756 100644
+--- a/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
++++ b/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
+@@ -324,6 +324,13 @@ void tst_QDBusInterface::notValid()
+ 
+     QVERIFY(!interface.isValid());
+     QVERIFY(!QMetaObject::invokeMethod(&interface, "ListNames", Qt::DirectConnection));
++
++    // With a connection, but empty/null service and path specified
++    QDBusConnection con = QDBusConnection::sessionBus();
++    QVERIFY(con.isConnected());
++    QDBusInterface iface({}, {}, {}, con);
++    QVERIFY(!iface.isValid());
++    QVERIFY(!QMetaObject::invokeMethod(&interface, "ListNames", Qt::DirectConnection));
+ }
+ 
+ void tst_QDBusInterface::notValidDerived()
+diff --git a/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp b/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
+index 874468c954..04ceb4ab65 100644
+--- a/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
++++ b/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
+@@ -507,6 +507,10 @@ void tst_QKeySequence::toStringFromKeycode_data()
+     QTest::newRow("Ctrl+Alt+Num+Del") << QKeySequence(Qt::ControlModifier | Qt::AltModifier | Qt::KeypadModifier | Qt::Key_Delete) << "Ctrl+Alt+Num+Del";
+     QTest::newRow("Ctrl+Ins") << QKeySequence(Qt::ControlModifier | Qt::Key_Insert) << "Ctrl+Ins";
+     QTest::newRow("Ctrl+Num+Ins(1)") << QKeySequence(Qt::Key_Insert | Qt::KeypadModifier | Qt::ControlModifier) << "Ctrl+Num+Ins";
++    QTest::newRow("Ctrl") << QKeySequence(Qt::Key_Control) << "Control";
++    QTest::newRow("Alt") << QKeySequence(Qt::Key_Alt) << "Alt";
++    QTest::newRow("Shift") << QKeySequence(Qt::Key_Shift) << "Shift";
++    QTest::newRow("Meta") << QKeySequence(Qt::Key_Meta) << "Meta";
+ }
+ 
+ void tst_QKeySequence::toStringFromKeycode()
+diff --git a/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp b/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+index 15e0ecadaa..b4eca74283 100644
+--- a/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
++++ b/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+@@ -81,6 +81,8 @@ private slots:
+     void registerOpenTypePreferredNamesSystem();
+     void registerOpenTypePreferredNamesApplication();
+ 
++    void stretchRespected();
++
+ private:
+     QString m_ledFont;
+     QString m_testFont;
+@@ -355,6 +357,28 @@ static QString testString()
+     return QStringLiteral("foo bar");
+ }
+ 
++void tst_QFontDatabase::stretchRespected()
++{
++    int italicId = QFontDatabase::addApplicationFont(m_testFontItalic);
++    QVERIFY(italicId != -1);
++
++    QVERIFY(!QFontDatabase::applicationFontFamilies(italicId).isEmpty());
++
++    QString italicFontName = QFontDatabase::applicationFontFamilies(italicId).first();
++
++    QFont italicFont = QFontDatabase().font(italicFontName,
++                                            QString::fromLatin1("Italic"), 14);
++    QVERIFY(italicFont.italic());
++
++    QFont italicStretchedFont = italicFont;
++    italicStretchedFont.setStretch( 400 );
++
++    QVERIFY(QFontMetricsF(italicFont).horizontalAdvance(QStringLiteral("foobar")) <
++            QFontMetricsF(italicStretchedFont).horizontalAdvance(QStringLiteral("foobar")));
++
++    QFontDatabase::removeApplicationFont(italicId);
++}
++
+ void tst_QFontDatabase::condensedFontWidthNoFontMerging()
+ {
+     int regularFontId = QFontDatabase::addApplicationFont(m_testFont);
+diff --git a/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+index 3d4a094c43..b423e11a99 100644
+--- a/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
++++ b/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+@@ -281,6 +281,7 @@ private Q_SLOTS:
+     void ioGetFromFileSpecial();
+     void ioGetFromFile_data();
+     void ioGetFromFile();
++    void ioGetFromFileUrl();
+     void ioGetFromFtp_data();
+     void ioGetFromFtp();
+     void ioGetFromFtpWithReuse();
+@@ -3300,6 +3301,18 @@ void tst_QNetworkReply::ioGetFromFile()
+     QCOMPARE(reader.data, data);
+ }
+ 
++void tst_QNetworkReply::ioGetFromFileUrl()
++{
++    // This immediately fails on non-windows platforms:
++    QNetworkRequest request(QUrl("file://unc-server/some/path"));
++    QNetworkReplyPtr reply(manager.get(request));
++    QSignalSpy finishedSpy(reply.get(), &QNetworkReply::finished);
++    // QTBUG-105618: This would, on non-Windows platforms, never happen because the signal
++    // was emitted before the constructor finished, leaving no chance at all to connect to the
++    // signal
++    QVERIFY(finishedSpy.wait());
++}
++
+ void tst_QNetworkReply::ioGetFromFtp_data()
+ {
+     QTest::addColumn<QString>("fileName");
+diff --git a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
+index 069fa6b341..4cc4d9a5ea 100644
+--- a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
++++ b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
+@@ -1,75 +1,34 @@
+-Certificate:
+-    Data:
+-        Version: 3 (0x2)
+-        Serial Number: 0 (0x0)
+-        Signature Algorithm: sha1WithRSAEncryption
+-        Issuer: C=NO, ST=Oslo, L=Nydalen, O=Nokia Corporation and/or its subsidiary(-ies), OU=Development, CN=fluke.troll.no/emailAddress=ahanssen@trolltech.com
+-        Validity
+-            Not Before: Dec  4 01:10:32 2007 GMT
+-            Not After : Apr 21 01:10:32 2035 GMT
+-        Subject: C=NO, ST=Oslo, O=Nokia Corporation and/or its subsidiary(-ies), OU=Development, CN=fluke.troll.no
+-        Subject Public Key Info:
+-            Public Key Algorithm: rsaEncryption
+-            RSA Public Key: (1024 bit)
+-                Modulus (1024 bit):
+-                    00:a7:c8:a0:4a:c4:19:05:1b:66:ba:32:e2:d2:f1:
+-                    1c:6f:17:82:e4:39:2e:01:51:90:db:04:34:32:11:
+-                    21:c2:0d:6f:59:d8:53:90:54:3f:83:8f:a9:d3:b3:
+-                    d5:ee:1a:9b:80:ae:c3:25:c9:5e:a5:af:4b:60:05:
+-                    aa:a0:d1:91:01:1f:ca:04:83:e3:58:1c:99:32:45:
+-                    84:70:72:58:03:98:4a:63:8b:41:f5:08:49:d2:91:
+-                    02:60:6b:e4:64:fe:dd:a0:aa:74:08:e9:34:4c:91:
+-                    5f:12:3d:37:4d:54:2c:ad:7f:5b:98:60:36:02:8c:
+-                    3b:f6:45:f3:27:6a:9b:94:9d
+-                Exponent: 65537 (0x10001)
+-        X509v3 extensions:
+-            X509v3 Basic Constraints: 
+-                CA:FALSE
+-            Netscape Comment: 
+-                OpenSSL Generated Certificate
+-            X509v3 Subject Key Identifier: 
+-                21:85:04:3D:23:01:66:E5:F7:9F:1A:84:24:8A:AF:0A:79:F4:E5:AC
+-            X509v3 Authority Key Identifier: 
+-                DirName:/C=NO/ST=Oslo/L=Nydalen/O=Nokia Corporation and/or its subsidiary(-ies)/OU=Development/CN=fluke.troll.no/emailAddress=ahanssen@trolltech.com
+-                serial:8E:A8:B4:E8:91:B7:54:2E
+-
+-    Signature Algorithm: sha1WithRSAEncryption
+-        6d:57:5f:d1:05:43:f0:62:05:ec:2a:71:a5:dc:19:08:f2:c4:
+-        a6:bd:bb:25:d9:ca:89:01:0e:e4:cf:1f:c1:8c:c8:24:18:35:
+-        53:59:7b:c0:43:b4:32:e6:98:b2:a6:ef:15:05:0b:48:5f:e1:
+-        a0:0c:97:a9:a1:77:d8:35:18:30:bc:a9:8f:d3:b7:54:c7:f1:
+-        a9:9e:5d:e6:19:bf:f6:3c:5b:2b:d8:e4:3e:62:18:88:8b:d3:
+-        24:e1:40:9b:0c:e6:29:16:62:ab:ea:05:24:70:36:aa:55:93:
+-        ef:02:81:1b:23:10:a2:04:eb:56:95:75:fc:f8:94:b1:5d:42:
+-        c5:3f:36:44:85:5d:3a:2e:90:46:8a:a2:b9:6f:87:ae:0c:15:
+-        40:19:31:90:fc:3b:25:bb:ae:f1:66:13:0d:85:90:d9:49:34:
+-        8f:f2:5d:f9:7a:db:4d:5d:27:f6:76:9d:35:8c:06:a6:4c:a3:
+-        b1:b2:b6:6f:1d:d7:a3:00:fd:72:eb:9e:ea:44:a1:af:21:34:
+-        7d:c7:42:e2:49:91:19:8b:c0:ad:ba:82:80:a8:71:70:f4:35:
+-        31:91:63:84:20:95:e9:60:af:64:8b:cc:ff:3d:8a:76:74:3d:
+-        c8:55:6d:e4:8e:c3:2b:1c:e8:42:18:ae:9f:e6:6b:9c:34:06:
+-        ec:6a:f2:c3
+ -----BEGIN CERTIFICATE-----
+-MIIEEzCCAvugAwIBAgIBADANBgkqhkiG9w0BAQUFADCBnDELMAkGA1UEBhMCTk8x
+-DTALBgNVBAgTBE9zbG8xEDAOBgNVBAcTB055ZGFsZW4xFjAUBgNVBAoTDVRyb2xs
+-dGVjaCBBU0ExFDASBgNVBAsTC0RldmVsb3BtZW50MRcwFQYDVQQDEw5mbHVrZS50
+-cm9sbC5ubzElMCMGCSqGSIb3DQEJARYWYWhhbnNzZW5AdHJvbGx0ZWNoLmNvbTAe
+-Fw0wNzEyMDQwMTEwMzJaFw0zNTA0MjEwMTEwMzJaMGMxCzAJBgNVBAYTAk5PMQ0w
+-CwYDVQQIEwRPc2xvMRYwFAYDVQQKEw1Ucm9sbHRlY2ggQVNBMRQwEgYDVQQLEwtE
+-ZXZlbG9wbWVudDEXMBUGA1UEAxMOZmx1a2UudHJvbGwubm8wgZ8wDQYJKoZIhvcN
+-AQEBBQADgY0AMIGJAoGBAKfIoErEGQUbZroy4tLxHG8XguQ5LgFRkNsENDIRIcIN
+-b1nYU5BUP4OPqdOz1e4am4CuwyXJXqWvS2AFqqDRkQEfygSD41gcmTJFhHByWAOY
+-SmOLQfUISdKRAmBr5GT+3aCqdAjpNEyRXxI9N01ULK1/W5hgNgKMO/ZF8ydqm5Sd
+-AgMBAAGjggEaMIIBFjAJBgNVHRMEAjAAMCwGCWCGSAGG+EIBDQQfFh1PcGVuU1NM
+-IEdlbmVyYXRlZCBDZXJ0aWZpY2F0ZTAdBgNVHQ4EFgQUIYUEPSMBZuX3nxqEJIqv
+-Cnn05awwgbsGA1UdIwSBszCBsKGBoqSBnzCBnDELMAkGA1UEBhMCTk8xDTALBgNV
+-BAgTBE9zbG8xEDAOBgNVBAcTB055ZGFsZW4xFjAUBgNVBAoTDVRyb2xsdGVjaCBB
+-U0ExFDASBgNVBAsTC0RldmVsb3BtZW50MRcwFQYDVQQDEw5mbHVrZS50cm9sbC5u
+-bzElMCMGCSqGSIb3DQEJARYWYWhhbnNzZW5AdHJvbGx0ZWNoLmNvbYIJAI6otOiR
+-t1QuMA0GCSqGSIb3DQEBBQUAA4IBAQBtV1/RBUPwYgXsKnGl3BkI8sSmvbsl2cqJ
+-AQ7kzx/BjMgkGDVTWXvAQ7Qy5piypu8VBQtIX+GgDJepoXfYNRgwvKmP07dUx/Gp
+-nl3mGb/2PFsr2OQ+YhiIi9Mk4UCbDOYpFmKr6gUkcDaqVZPvAoEbIxCiBOtWlXX8
+-+JSxXULFPzZEhV06LpBGiqK5b4euDBVAGTGQ/Dslu67xZhMNhZDZSTSP8l35ettN
+-XSf2dp01jAamTKOxsrZvHdejAP1y657qRKGvITR9x0LiSZEZi8CtuoKAqHFw9DUx
+-kWOEIJXpYK9ki8z/PYp2dD3IVW3kjsMrHOhCGK6f5mucNAbsavLD
++MIIF6zCCA9OgAwIBAgIUfo9amJtJGWqWE6f+SkAO85zkGr4wDQYJKoZIhvcNAQEL
++BQAwgYMxCzAJBgNVBAYTAk5PMQ0wCwYDVQQIDARPc2xvMQ0wCwYDVQQHDARPc2xv
++MRcwFQYDVQQKDA5UaGUgUXQgQ29tcGFueTEMMAoGA1UECwwDUiZEMRIwEAYDVQQD
++DAlIMiBUZXN0ZXIxGzAZBgkqhkiG9w0BCQEWDG1pbmltaUBxdC5pbzAgFw0yMDEw
++MjYxMjAxMzFaGA8yMTIwMTAwMjEyMDEzMVowgYMxCzAJBgNVBAYTAk5PMQ0wCwYD
++VQQIDARPc2xvMQ0wCwYDVQQHDARPc2xvMRcwFQYDVQQKDA5UaGUgUXQgQ29tcGFu
++eTEMMAoGA1UECwwDUiZEMRIwEAYDVQQDDAlIMiBUZXN0ZXIxGzAZBgkqhkiG9w0B
++CQEWDG1pbmltaUBxdC5pbzCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIB
++AOiUp5+E4blouKH7q+rVNR8NoYX2XkBW+q+rpy1zu5ssRSzbqxAjDx9dkht7Qlnf
++VlDT00JvpOWdeuPon5915edQRsY4Unl6mKH29ra3OtUa1/yCJXsGVJTKCj7k4Bxb
++5mZzb/fTlZntMLdTIBMfUbw62FKir1WjKIcJ9fCoG8JaGeKVO4Rh5p0ezd4UUUId
++r1BXl5Nqdqy2vTMsEDnjOsD3egkv8I2SKN4O6n/C3wWYpMOWYZkGoZiKz7rJs/i/
++ez7bsV7JlwdzTlhpJzkcOSVFBP6JlEOxTNNxZ1wtKy7PtZGmsSSATq2e6+bw38Ae
++Op0XnzzqcGjtDDofBmT7OFzZWjS9VZS6+DOOe2QHWle1nCHcHyH4ku6IRlsr9xkR
++NAIlOfnvHHxqJUenoeaZ4oQDjCBKS1KXygJO/tL7BLTQVn/xK1EmPvKNnjzWk4tR
++PnibUhhs5635qpOU/YPqFBh1JjVruZbsWcDAhRcew0uxONXOa9E+4lttQ9ySYa1A
++LvWqJuAX7gu2BsBMLyqfm811YnA7CIFMyO+HlqmkLFfv5L/xIRAXR7l26YGO0VwX
++CGjMfz4NVPMMke4nB7qa9NkpXQBQKMms3Qzd5JW0Hy9Ruj5O8GPcFZmV0twjd1uJ
++PD/cAjkWLaXjdNsJ16QWc2nghQRS6HYqKRX6j+CXOxupAgMBAAGjUzBRMB0GA1Ud
++DgQWBBRSCOU58j9NJZkMamt623qyCrhN3TAfBgNVHSMEGDAWgBRSCOU58j9NJZkM
++amt623qyCrhN3TAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4ICAQCq
++q4jxsWeNDv5Nq14hJtF9HB+ZL64zcZtRjJP1YgNs0QppKICmjPOL2nIMGmI/jKrs
++0eGAL/9XXNVHPxm1OPOncvimMMmU6emZfpMdEtTfKP43+Pg9HgKRjLoQp406vGeQ
++8ki/mbBhrItVPgEm3tu2AFA02XTYi+YxCI9kRZLGkM3FbgtOuTLPl0Z9y+kiPc9F
++uCSC03anBEqv+vDSI8+wODymQ/IJ3Jyz1lxIRDfp4qAekmy0jU2c91VOHHEmOmqq
++kqygGFRdwbe99m9yP63r6q0b5K3X2UnJ6bns0hmTwThYwpVPXLU8jdaTddbMukN2
++/Ef96Tsw8nWOEOPMySHOTIPgwyZRp26b0kA9EmhLwOP401SxXVQCmSRmtwNagmtg
++jJKmZoYBN+//D45ibK8z6Q0oOm9P+Whf/uUXehcRxBxyV3xz7k0wKGQbHj/ddwcy
++IUoIN4lrAlib+lK170kTKN352PDmrpo2gmIzPEsfurKAIMSelDl6H+kih16BtZ8y
++Nz6fh9Soqrg3OSAware8pxV7k51crBMoPLN78KoRV8MFCK4K7Fddq4rRISq6hiXq
++r1nsjoEPuKM9huprmZVZe9t5YcDa2I+wb3IiE3uwpZbAdaLDyQ5n6F/qpsiIkZXn
++gtcF7oqpG5oYrwCcZ53y/ezUgUg7PlSz2XwAGvQtgg==
+ -----END CERTIFICATE-----
+diff --git a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
+index 9d1664d609..337ce541a6 100644
+--- a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
++++ b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
+@@ -1,15 +1,52 @@
+------BEGIN RSA PRIVATE KEY-----
+-MIICXAIBAAKBgQCnyKBKxBkFG2a6MuLS8RxvF4LkOS4BUZDbBDQyESHCDW9Z2FOQ
+-VD+Dj6nTs9XuGpuArsMlyV6lr0tgBaqg0ZEBH8oEg+NYHJkyRYRwclgDmEpji0H1
+-CEnSkQJga+Rk/t2gqnQI6TRMkV8SPTdNVCytf1uYYDYCjDv2RfMnapuUnQIDAQAB
+-AoGANFzLkanTeSGNFM0uttBipFT9F4a00dqHz6JnO7zXAT26I5r8sU1pqQBb6uLz
+-/+Qz5Zwk8RUAQcsMRgJetuPQUb0JZjF6Duv24hNazqXBCu7AZzUenjafwmKC/8ri
+-KpX3fTwqzfzi//FKGgbXQ80yykSSliDL3kn/drATxsLCgQECQQDXhEFWLJ0vVZ1s
+-1Ekf+3NITE+DR16X+LQ4W6vyEHAjTbaNWtcTKdAWLA2l6N4WAAPYSi6awm+zMxx4
+-VomVTsjdAkEAx0z+e7natLeFcrrq8pbU+wa6SAP1VfhQWKitxL1e7u/QO90NCpxE
+-oQYKzMkmmpOOFjQwEMAy1dvFMbm4LHlewQJAC/ksDBaUcQHHqjktCtrUb8rVjAyW
+-A8lscckeB2fEYyG5J6dJVaY4ClNOOs5yMDS2Afk1F6H/xKvtQ/5CzInA/QJATDub
+-K+BPU8jO9q+gpuIi3VIZdupssVGmCgObVCHLakG4uO04y9IyPhV9lA9tALtoIf4c
+-VIvv5fWGXBrZ48kZAQJBAJmVCdzQxd9LZI5vxijUCj5EI4e+x5DRqVUvyP8KCZrC
+-AiNyoDP85T+hBZaSXK3aYGpVwelyj3bvo1GrTNwNWLw=
+------END RSA PRIVATE KEY-----
++-----BEGIN PRIVATE KEY-----
++MIIJQgIBADANBgkqhkiG9w0BAQEFAASCCSwwggkoAgEAAoICAQDolKefhOG5aLih
+++6vq1TUfDaGF9l5AVvqvq6ctc7ubLEUs26sQIw8fXZIbe0JZ31ZQ09NCb6TlnXrj
++6J+fdeXnUEbGOFJ5epih9va2tzrVGtf8giV7BlSUygo+5OAcW+Zmc2/305WZ7TC3
++UyATH1G8OthSoq9VoyiHCfXwqBvCWhnilTuEYeadHs3eFFFCHa9QV5eTanastr0z
++LBA54zrA93oJL/CNkijeDup/wt8FmKTDlmGZBqGYis+6ybP4v3s+27FeyZcHc05Y
++aSc5HDklRQT+iZRDsUzTcWdcLSsuz7WRprEkgE6tnuvm8N/AHjqdF5886nBo7Qw6
++HwZk+zhc2Vo0vVWUuvgzjntkB1pXtZwh3B8h+JLuiEZbK/cZETQCJTn57xx8aiVH
++p6HmmeKEA4wgSktSl8oCTv7S+wS00FZ/8StRJj7yjZ481pOLUT54m1IYbOet+aqT
++lP2D6hQYdSY1a7mW7FnAwIUXHsNLsTjVzmvRPuJbbUPckmGtQC71qibgF+4LtgbA
++TC8qn5vNdWJwOwiBTMjvh5appCxX7+S/8SEQF0e5dumBjtFcFwhozH8+DVTzDJHu
++Jwe6mvTZKV0AUCjJrN0M3eSVtB8vUbo+TvBj3BWZldLcI3dbiTw/3AI5Fi2l43Tb
++CdekFnNp4IUEUuh2KikV+o/glzsbqQIDAQABAoICAFw1q6tr5I48vY7DF+rXsuLn
++5ZUWE1IQ6fzB4lr72nJv/9EEGnMgYzt9PpMUsD6vdCpBgS2C0+6RHArFzJtNA+RM
++iHLIG7K7702veyr/xBx/MwiSlMeMv/XpkFxVI6E6skMGG2s3AMXxKvJTy5CpRx+I
++eQFyLG+Ya1X2lgJes/q+/CpAHkOjCOpcLySQC5NZ74q734V7nSdmn+Zs3tYEh+O/
++eiuwTP/j5b38Te5vVTqDxTciJPmljmXLCwa0N100lWlbcpvw8qbqiTI2Jm3XCbUE
++AzHjW9vmrF3cRS1fXxKFGShw3SRqlkbxjfeWoi8qDPUBS4m8LOr8qG9Wo5Nfon0z
++zLP4bci3zHDvVcaaZrrsUBs/yZbg+Dgka1DmX7ekmeccr2yTdKDFgPupYUyxVbTl
++a9ZLJysjFD7rgBv1ZclHonLp6Vbm+ZoTqvteo4ikAy6L9RtBWJ23XEK34PkP/+c5
++2vWZaOrnjSeBHbFce8cdJSxqWpP+eSCI5I9XbDrYFIsQ/gqKgtzDKy2ihJ2Y8STL
++yO4hyFPFjxc+Gg4/P2PpmT5CY2ty44M0BWs+JGW96CJPrrplf2lmQUQJj5LZY66X
++Z/4C9L7ZYtKZ+bs5SvU46yWugAvQZX22Xm9xLXWyVXRdx3bj+3M3fDnF9di/zdbh
++CgLx7oWPNrXc7FCajnn9AoIBAQD5FMYwRpw9NWT9WDxQwx+cSI4Icbd88ByTW63S
++LzeRwZA0J9/SfwO+aBRupzc9GkGXCiZcGMw3AGsCtig8yFlw8E5KnzN7KlftDMnM
++9NUxxzlR8VwKyLnZfG7sDTl057ZlUujnqhmt/F8F7dIy7FVO1dE/8nngA+FYTCOG
++UZdGjwyBDlDM0JJdUWGY3xslutcpCDN5mzSTKjy9drMvImAshRawxRF6WBpn7vr2
++nC6vciqfx1Mzx1vyk0Jm0ilaydDdLMADjt/iL4Nkr0BEs4k+UzQiKDwp8gu7abQ1
++eBfxd9Iar4htQa2I1Ewl6P01G/q+ZYwgHhJ9RVn4AxQXefILAoIBAQDvCouORdQX
++C8wsyp7MwXlF/3NQeNN5/+B2mhbxrBOf7PmMCXLnkRWcjwJtzypWFqJ0sqai/2+0
++bqbMcjX5maT8stT2shl3zXe/Ejt2e3TBYpc1tyuses8Kb5BMU8hu6tTd3G2CMXpD
++dT6DVemJZCTtwj9aBNIxSizvlgMolJnCpzhPnlfHSI6E+g3m/LTTo3HwbjMSw/Uq
++irgjOpI2wSBB6LZPSgjvfcYPRyWUk16L4A5uSX0cADnovDFLa5/h0wJvN/OoCSQg
++rLCXG5E18EyL5Wc58BCY1ZvxmjG3lQtgPxYu2Jwc36R/y/JKlxW5suER5ZNpbbD4
++uOyTt2VxMQ2bAoIBAQC5+MzRFqdo/AjfL5Y5JrbfVTzXCTDa09xCGd16ZU60QTWN
+++4ed/r+o1sUKqUcRFB2MzEM/2DQBjQpZB/CbEWvWa1XJWXxypXbowveZU+QqOnmN
++uQvj8WLyA3o+PNF9e9QvauwCrHpn8VpxbtPWuaYoKnUFreFZZQxHhPGxRBIS2JOZ
++eDrT8ZaWnkCkh1AZp5smQ71LOprSlmKrg4jd1GjCVMxQR5N5KXbtyv0OTCZ/UFqK
++2aRBsMPyJgkaBChkZPLRcKwc+/wlQRx1fHQb14DNTApMxoXFO7eOwqmOkpAt9iyl
++SBIwoS0UUI5ab88+bBmXNvKcuFdNuQ4nowTJUn9pAoIBADMNkILBXSvS5DeIyuO2
++Sp1tkoZUV+5NfPY3sMDK3KIibaW/+t+EOBZo4L7tKQCb8vRzl21mmsfxfgRaPDbj
++3r3tv9g0b4YLxxBy52pFscj/soXRai17SS7UZwA2QK+XzgDYbDcLNC6mIsTQG4Gx
++dsWk3/zs3KuUSQaehmwrWK+fIUK38c1pLK8v7LoxrLkqxlHwZ04RthHw8KTthH7X
++Pnl1J0LF8CSeOyfWLSuPUfkT0GEzptnNHpEbaHfQM6R6eaGhVJPF6AZme4y6YYgg
++m2ihhSt1n0XVEWpHYWjxFy3mK2mz75unFC4LM+NEY2p2zuUQoCw7NjnY3QYrfCnx
++rRMCggEAXeXsMSLFjjyuoL7iKbAxo52HD/P0fBoy58LyRcwfNVr0lvYan4pYEx+o
++KijIh9K16PqXZXKMA9v003B+ulmF8bJ7SddCZ5NGvnFhUTDe4DdTKgp2RuwQ3Bsc
++3skPIDbhVETyOLCtys34USHrq8U/0DlGY3eLRfxw9GnbKxSBGa/KEu/qQLPNUo50
++7xHZDg7GKeC3kqNJeqKM9rkp0VzIGkEnaD9127LeNDmERDfftxJzFoC/THvUBLfU
++6Sus2ZYwRE8VFvKC30Q45t/c54X3IuhYvAuiCuTmyfE4ruyzyOwKzhUkeeLq1APX
++g0veFbyfzlJ0q8qzD/iffqqIa2ZSmQ==
++-----END PRIVATE KEY-----
+diff --git a/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp b/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
+index 7ba3715e13..752aa122f6 100644
+--- a/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
++++ b/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
+@@ -179,6 +179,7 @@ void tst_QAccessibilityLinux::initTestCase()
+     QVERIFY(!address.isEmpty());
+ 
+     m_window = new AccessibleTestWindow();
++    m_window->setObjectName("mainWindow"_L1);
+     m_window->show();
+ 
+     QVERIFY(QTest::qWaitForWindowExposed(m_window));
+@@ -236,8 +237,11 @@ bool hasState(QDBusInterface *interface, AtspiStateType state)
+ void tst_QAccessibilityLinux::testLabel()
+ {
+     QLabel *l = new QLabel(m_window);
++    l->setObjectName("theObjectName"_L1);
+     l->setText("Hello A11y");
+     m_window->addWidget(l);
++    auto a11yEmpty = new QLabel(m_window);
++    m_window->addWidget(l);
+ 
+     // Application
+     QCOMPARE(getParent(mainWindow), QLatin1String(ATSPI_DBUS_PATH_ROOT));
+@@ -249,6 +253,8 @@ void tst_QAccessibilityLinux::testLabel()
+     QCOMPARE(getChildren(labelInterface).count(), 0);
+     QCOMPARE(labelInterface->call(QDBus::Block, "GetRoleName").arguments().first().toString(), QLatin1String("label"));
+     QCOMPARE(labelInterface->call(QDBus::Block, "GetRole").arguments().first().toUInt(), 29u);
++    QCOMPARE(labelInterface->call(QDBus::Block, "GetAccessibleId").arguments().first().toString(),
++             QLatin1String("mainWindow.theObjectName"));
+     QCOMPARE(getParent(labelInterface), mainWindow->path());
+     QVERIFY(!hasState(labelInterface, ATSPI_STATE_EDITABLE));
+     QVERIFY(hasState(labelInterface, ATSPI_STATE_READ_ONLY));
+@@ -256,7 +262,12 @@ void tst_QAccessibilityLinux::testLabel()
+     l->setText("New text");
+     QCOMPARE(labelInterface->property("Name").toString(), l->text());
+ 
++    auto *a11yEmptyInterface = getInterface(children.at(1), "org.a11y.atspi.Accessible");
++    QCOMPARE(a11yEmptyInterface->call(QDBus::Block, "GetAccessibleId").arguments().first().toString(),
++             QLatin1String("mainWindow.QLabel"));
++
+     m_window->clearChildren();
++    delete a11yEmptyInterface;
+     delete labelInterface;
+ }
+ 
+diff --git a/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+index 76df61c892..6d6d65b791 100644
+--- a/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
++++ b/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2022 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the test suite of the Qt Toolkit.
+@@ -68,6 +68,8 @@ private slots:
+     void query_exec();
+     void execErrorRecovery_data() { generic_data(); }
+     void execErrorRecovery();
++    void prematureExec_data() { generic_data(); }
++    void prematureExec();
+     void first_data() { generic_data(); }
+     void first();
+     void next_data() { generic_data(); }
+@@ -2770,6 +2772,35 @@ void tst_QSqlQuery::execErrorRecovery()
+     QVERIFY_SQL( q, exec() );
+ }
+ 
++void tst_QSqlQuery::prematureExec()
++{
++    QFETCH(QString, dbName);
++    // We only want the engine name, for addDatabase():
++    int cut = dbName.indexOf(QChar('@'));
++    if (cut < 0)
++        QSKIP("Failed to parse database type out of name");
++    dbName.truncate(cut);
++    cut = dbName.indexOf(QChar('_'));
++    if (cut >= 0)
++        dbName = dbName.mid(cut + 1);
++
++    auto db = QSqlDatabase::addDatabase(dbName);
++    QSqlQuery q(db);
++
++    QTest::ignoreMessage(QtWarningMsg,
++                         "QSqlDatabasePrivate::removeDatabase: connection "
++                         "'qt_sql_default_connection' is still in use, all "
++                         "queries will cease to work.");
++    QTest::ignoreMessage(QtWarningMsg,
++                         "QSqlDatabasePrivate::addDatabase: duplicate connection name "
++                         "'qt_sql_default_connection', old connection removed.");
++    auto otherDb = QSqlDatabase::addDatabase(dbName);
++
++    QTest::ignoreMessage(QtWarningMsg, "QSqlQuery::exec: called before driver has been set up");
++    // QTBUG-100037: shouldn't crash !
++    QVERIFY(!q.exec("select stuff from TheVoid"));
++}
++
+ void tst_QSqlQuery::lastInsertId()
+ {
+     QFETCH( QString, dbName );
+diff --git a/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp b/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
+index 4aa3f8d60b..d2050a61aa 100644
+--- a/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
++++ b/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
+@@ -115,6 +115,10 @@ void tst_QAbstractItemModelTester::standardItemModelZeroColumns()
+     // QTBUG-92886
+     model.insertRows(0, 5);
+     model.removeRows(1, 2);
++
++    const QModelIndex parentIndex = model.index(0, 0);
++    model.insertRows(0, 5, parentIndex);
++    model.removeRows(1, 2, parentIndex);
+ }
+ 
+ void tst_QAbstractItemModelTester::testInsertThroughProxy()
+diff --git a/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json b/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
+index 12a4a22a19..ce518e78fb 100644
+--- a/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
++++ b/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
+@@ -668,50 +668,6 @@
+         "inputFile": "task192552.h",
+         "outputRevision": 67
+     },
+-    {
+-        "classes": [
+-            {
+-                "className": "InlineSlotsWithThrowDeclaration",
+-                "object": true,
+-                "qualifiedClassName": "InlineSlotsWithThrowDeclaration",
+-                "slots": [
+-                    {
+-                        "access": "public",
+-                        "name": "a",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "b",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "c",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "d",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "e",
+-                        "returnType": "void"
+-                    }
+-                ],
+-                "superClasses": [
+-                    {
+-                        "access": "public",
+-                        "name": "QObject"
+-                    }
+-                ]
+-            }
+-        ],
+-        "inputFile": "task189996.h",
+-        "outputRevision": 67
+-    },
+     {
+         "classes": [
+             {
+diff --git a/qtbase/tests/auto/tools/moc/moc.pro b/qtbase/tests/auto/tools/moc/moc.pro
+index c324b3a8cd..4aceb78dc0 100644
+--- a/qtbase/tests/auto/tools/moc/moc.pro
++++ b/qtbase/tests/auto/tools/moc/moc.pro
+@@ -15,7 +15,7 @@ cross_compile: DEFINES += MOC_CROSS_COMPILED
+ HEADERS += using-namespaces.h no-keywords.h task87883.h c-comments.h backslash-newlines.h oldstyle-casts.h \
+            slots-with-void-template.h qinvokable.h namespaced-flags.h trigraphs.h \
+            escapes-in-string-literals.h cstyle-enums.h qprivateslots.h gadgetwithnoenums.h \
+-           dir-in-include-path.h single_function_keyword.h task192552.h task189996.h \
++           dir-in-include-path.h single_function_keyword.h task192552.h \
+            task234909.h task240368.h pure-virtual-signals.h cxx11-enums.h \
+            cxx11-final-classes.h \
+            cxx11-explicit-override-control.h \
+diff --git a/qtbase/tests/auto/tools/moc/task189996.h b/qtbase/tests/auto/tools/moc/task189996.h
+deleted file mode 100644
+index f94a051b3a..0000000000
+--- a/qtbase/tests/auto/tools/moc/task189996.h
++++ /dev/null
+@@ -1,47 +0,0 @@
+-/****************************************************************************
+-**
+-** Copyright (C) 2016 The Qt Company Ltd.
+-** Contact: https://www.qt.io/licensing/
+-**
+-** This file is part of the test suite of the Qt Toolkit.
+-**
+-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+-** 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 General Public License Usage
+-** Alternatively, this file may be used under the terms of the GNU
+-** General Public License version 3 as published by the Free Software
+-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+-** 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-3.0.html.
+-**
+-** $QT_END_LICENSE$
+-**
+-****************************************************************************/
+-// inline functions can have throw declarations
+-
+-#ifndef TASK189996_H
+-#define TASK189996_H
+-
+-#include <QObject>
+-
+-class InlineSlotsWithThrowDeclaration : public QObject
+-{
+-    Q_OBJECT
+-
+-public slots:
+-    void a() throw() { }
+-    void b() const throw() { }
+-    void c() throw();
+-    void d() throw(int) { }
+-    void e() const throw(int,double) { }
+-};
+-
+-#endif
+diff --git a/qtbase/tests/auto/tools/moc/tst_moc.cpp b/qtbase/tests/auto/tools/moc/tst_moc.cpp
+index c716aead21..15dd9e41e5 100644
+--- a/qtbase/tests/auto/tools/moc/tst_moc.cpp
++++ b/qtbase/tests/auto/tools/moc/tst_moc.cpp
+@@ -631,7 +631,6 @@ public:
+ private slots:
+     void initTestCase();
+ 
+-    void slotWithException() throw(MyStruct);
+     void dontStripNamespaces();
+     void oldStyleCasts();
+     void warnOnExtraSignalSlotQualifiaction();
+@@ -673,7 +672,6 @@ private slots:
+     void templateGtGt();
+     void qprivateslots();
+     void qprivateproperties();
+-    void inlineSlotsWithThrowDeclaration();
+     void warnOnPropertyWithoutREAD();
+     void constructors();
+     void typenameWithUnsigned();
+@@ -784,12 +782,6 @@ void tst_Moc::initTestCase()
+ #endif
+ }
+ 
+-void tst_Moc::slotWithException() throw(MyStruct)
+-{
+-    // be happy
+-    QVERIFY(true);
+-}
+-
+ void tst_Moc::dontStripNamespaces()
+ {
+     Sender sender;
+@@ -824,7 +816,7 @@ void tst_Moc::oldStyleCasts()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-Wold-style-cast" << "-I" << "."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -894,7 +886,7 @@ void tst_Moc::inputFileNameWithDotsButNoExtension()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-I" << ".."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -1174,7 +1166,7 @@ void tst_Moc::ignoreOptionClashes()
+     QStringList gccArgs;
+     gccArgs << "-c" << "-x" << "c++" << "-I" << ".."
+          << "-I" << qtIncludePath << "-I" << includeDir << "-o" << "/dev/null"
+-         << "-fPIC" << "-std=c++11" <<  "-";
++         << "-fPIC" << "-std=c++1z" <<  "-";
+     proc.start("gcc", gccArgs);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -1593,21 +1585,6 @@ void tst_Moc::qprivateproperties()
+ 
+ }
+ 
+-#include "task189996.h"
+-
+-void InlineSlotsWithThrowDeclaration::c() throw() {}
+-
+-void tst_Moc::inlineSlotsWithThrowDeclaration()
+-{
+-    InlineSlotsWithThrowDeclaration tst;
+-    const QMetaObject *mobj = tst.metaObject();
+-    QVERIFY(mobj->indexOfSlot("a()") != -1);
+-    QVERIFY(mobj->indexOfSlot("b()") != -1);
+-    QVERIFY(mobj->indexOfSlot("c()") != -1);
+-    QVERIFY(mobj->indexOfSlot("d()") != -1);
+-    QVERIFY(mobj->indexOfSlot("e()") != -1);
+-}
+-
+ void tst_Moc::warnOnPropertyWithoutREAD()
+ {
+ #ifdef MOC_CROSS_COMPILED
+@@ -1869,7 +1846,7 @@ void tst_Moc::notifyError()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-I" << "."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+diff --git a/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+index c355ee9665..88c09de8e0 100644
+--- a/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
++++ b/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+@@ -251,6 +251,7 @@ private slots:
+     void testResetCachedSizeHint();
+     void statusTips();
+     void testRemovingColumnsViaLayoutChanged();
++    void testModelMovingColumns();
+ 
+ protected:
+     void setupTestData(bool use_reset_model = false);
+@@ -360,6 +361,12 @@ public:
+         endRemoveColumns();
+     }
+ 
++    void moveColumn(int from, int to)
++    {
++        beginMoveColumns(QModelIndex(), from, from, QModelIndex(), to);
++        endMoveColumns();
++    }
++
+     void cleanup()
+     {
+         emit layoutAboutToBeChanged();
+@@ -3627,5 +3634,18 @@ void tst_QHeaderView::testRemovingColumnsViaLayoutChanged()
+     // The main point of this test is that the section-size restoring code didn't go out of bounds.
+ }
+ 
++void tst_QHeaderView::testModelMovingColumns()
++{
++    QtTestModel model(10, 10);
++    QHeaderView hv(Qt::Horizontal);
++    hv.setModel(&model);
++    hv.resizeSections(QHeaderView::ResizeToContents);
++    hv.show();
++
++    QPersistentModelIndex index3 = model.index(0, 3);
++    model.moveColumn(3, 1);
++    QCOMPARE(index3.column(), 1);
++}
++
+ QTEST_MAIN(tst_QHeaderView)
+ #include "tst_qheaderview.moc"
+diff --git a/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+index 761357b252..06bb706074 100644
+--- a/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
++++ b/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+@@ -397,6 +397,7 @@ private slots:
+     void checkHeaderMinSize();
+ 
+     void resizeToContents();
++    void resizeToContentsSpans();
+ 
+     void tabFocus();
+     void bigModel();
+@@ -3721,6 +3722,70 @@ void tst_QTableView::resizeToContents()
+ 
+ }
+ 
++
++class SpanModel : public QAbstractTableModel
++{
++public:
++    SpanModel(bool sectionsMoved)
++        : _sectionsMoved(sectionsMoved)
++    {}
++    int columnCount(const QModelIndex & = {}) const override { return 2; }
++    int rowCount(const QModelIndex & = {}) const override { return 1; }
++    QVariant data(const QModelIndex &idx, int role = Qt::DisplayRole) const override
++    {
++        if (role != Qt::DisplayRole)
++            return QVariant();
++        const int col = _sectionsMoved ? 1 - idx.column() : idx.column();
++        if (col == 0)
++            return "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.";
++        return QVariant();
++    }
++private:
++    bool _sectionsMoved;
++};
++
++
++void tst_QTableView::resizeToContentsSpans()
++{
++    SpanModel model1(false);
++    SpanModel model2(true);
++    QTableView view1, view2, view3;
++    view1.setModel(&model1);
++    view2.setModel(&model2);
++    view2.horizontalHeader()->moveSection(0, 1);
++    view3.setModel(&model1);
++
++    view1.setSpan(0, 0, 1, 2);
++    view2.setSpan(0, 1, 1, 2);
++    view1.show();
++    view2.show();
++    view3.show();
++    QVERIFY(QTest::qWaitForWindowExposed(&view1));
++    QVERIFY(QTest::qWaitForWindowExposed(&view2));
++    QVERIFY(QTest::qWaitForWindowExposed(&view3));
++    view1.setColumnWidth(0, 100);
++    view1.setColumnWidth(1, 100);
++    view2.setColumnWidth(0, 100);
++    view2.setColumnWidth(1, 100);
++    view3.setColumnWidth(0, 200);
++
++    view1.resizeRowToContents(0);
++    view2.resizeRowToContents(0);
++    view3.resizeRowToContents(0);
++    QCOMPARE(view1.rowHeight(0), view3.rowHeight(0));
++    QCOMPARE(view2.rowHeight(0), view3.rowHeight(0));
++
++    view3.resizeColumnToContents(0);
++    view3.resizeRowToContents(0);
++    // height should be only 1 text line for easy testing
++    view1.setRowHeight(0, view3.verticalHeader()->sectionSize(0));
++    view2.setRowHeight(0, view3.verticalHeader()->sectionSize(0));
++    view1.resizeColumnToContents(0);
++    view2.resizeColumnToContents(1);
++    QCOMPARE(view1.columnWidth(0), view3.columnWidth(0) - view1.columnWidth(1));
++    QCOMPARE(view2.columnWidth(0), view3.columnWidth(0) - view2.columnWidth(1));
++}
++
+ QT_BEGIN_NAMESPACE
+ extern bool Q_WIDGETS_EXPORT qt_tab_all_widgets(); // qapplication.cpp
+ QT_END_NAMESPACE
+diff --git a/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+index a3b8ef78d8..4955cebd5d 100644
+--- a/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
++++ b/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+@@ -1498,7 +1498,7 @@ void tst_QApplication::desktopSettingsAware()
+     environment += QLatin1String("QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM=1");
+     testProcess.setEnvironment(environment);
+ #endif
+-    testProcess.start("desktopsettingsaware_helper");
++    testProcess.start("./desktopsettingsaware_helper");
+     QVERIFY2(testProcess.waitForStarted(),
+              qPrintable(QString::fromLatin1("Cannot start 'desktopsettingsaware_helper': %1").arg(testProcess.errorString())));
+     QVERIFY(testProcess.waitForFinished(10000));
+@@ -2452,7 +2452,7 @@ void tst_QApplication::qtbug_12673()
+ #if QT_CONFIG(process)
+     QProcess testProcess;
+     QStringList arguments;
+-    testProcess.start("modal_helper", arguments);
++    testProcess.start("./modal_helper", arguments);
+     QVERIFY2(testProcess.waitForStarted(),
+              qPrintable(QString::fromLatin1("Cannot start 'modal_helper': %1").arg(testProcess.errorString())));
+     QVERIFY(testProcess.waitForFinished(20000));
+diff --git a/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp b/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
+index eb108a40de..dca5528c1b 100644
+--- a/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
+@@ -41,6 +41,7 @@
+ 
+ #include <private/qguiapplication_p.h>
+ #include <qpa/qplatformintegration.h>
++#include <qpa/qplatformtheme.h>
+ 
+ class tst_QAbstractButton : public QObject
+ {
+@@ -76,6 +77,8 @@ private slots:
+     void keyNavigation();
+ #endif
+ 
++    void buttonPressKeys();
++
+ protected slots:
+     void onClicked();
+     void onToggled( bool on );
+@@ -269,7 +272,13 @@ void tst_QAbstractButton::setAutoRepeat()
+         QCOMPARE(press_count, click_count);
+         QVERIFY(click_count > 1);
+         break;
+-    case 4:
++    case 4: {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(Qt::Key_Enter)) {
++            QSKIP("platform theme has Key_Enter in ButtonPressKeys");
++        }
+         // check that pressing ENTER has no effect when autorepeat is false
+         testWidget->setDown( false );
+         testWidget->setAutoRepeat( false );
+@@ -286,7 +295,14 @@ void tst_QAbstractButton::setAutoRepeat()
+ 
+         QVERIFY( click_count == 0 );
+         break;
+-    case 5:
++    }
++    case 5: {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(Qt::Key_Enter)) {
++            QSKIP("platform theme has Key_Enter in ButtonPressKeys");
++        }
+         // check that pressing ENTER has no effect when autorepeat is true
+         testWidget->setDown( false );
+         testWidget->setAutoRepeat( true );
+@@ -304,6 +320,7 @@ void tst_QAbstractButton::setAutoRepeat()
+ 
+         QVERIFY( click_count == 0 );
+         break;
++    }
+     case 6:
+         // verify autorepeat is off by default.
+         MyButton tmp( 0);
+@@ -651,5 +668,16 @@ void tst_QAbstractButton::keyNavigation()
+ }
+ #endif
+ 
++void tst_QAbstractButton::buttonPressKeys()
++{
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(testWidget, buttonPressKeys[i]);
++        QCOMPARE(click_count, i + 1);
++    }
++}
++
+ QTEST_MAIN(tst_QAbstractButton)
+ #include "tst_qabstractbutton.moc"
+diff --git a/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+index 32437050f5..46b5af6d63 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+@@ -168,6 +168,7 @@ private slots:
+     void checkMenuItemPosWhenStyleSheetIsSet();
+     void checkEmbeddedLineEditWhenStyleSheetIsSet();
+     void propagateStyleChanges();
++    void buttonPressKeys();
+ 
+ private:
+     PlatformInputContext m_platformInputContext;
+@@ -1682,6 +1683,16 @@ void tst_QComboBox::setModel()
+     QCOMPARE(box.rootModelIndex(), rootModelIndex);
+     box.setModel(box.model());
+     QCOMPARE(box.rootModelIndex(), rootModelIndex);
++
++    // check that setting the same model as the completer's doesn't crash
++    QCompleter *completer = new QCompleter(&box);
++    box.setEditable(true);
++    box.setCompleter(completer);
++    auto *listModel = new QStringListModel({ "one", "two" }, completer);
++    completer->setModel(listModel);
++    QCOMPARE(listModel->rowCount(), 2); // make sure it wasn't deleted
++    box.setModel(listModel);
++    QCOMPARE(listModel->rowCount(), 2); // make sure it wasn't deleted
+ }
+ 
+ void tst_QComboBox::setCustomModelAndView()
+@@ -3632,5 +3643,24 @@ void tst_QComboBox::propagateStyleChanges()
+     QVERIFY(frameStyle.inquired);
+ }
+ 
++void tst_QComboBox::buttonPressKeys()
++{
++    QComboBox comboBox;
++    comboBox.setEditable(false);
++    comboBox.addItem(QString::number(1));
++    comboBox.addItem(QString::number(2));
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(&comboBox, buttonPressKeys[i]);
++        // On some platforms, a window will not be immediately visible,
++        // but take some event-loop iterations to complete.
++        // Using QTRY_VERIFY to deal with that.
++        QTRY_VERIFY(comboBox.view()->isVisible());
++        comboBox.hidePopup();
++    }
++}
++
+ QTEST_MAIN(tst_QComboBox)
+ #include "tst_qcombobox.moc"
+diff --git a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
+index be3cfcd104..c228fdfcca 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
++++ b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qcommandlinkbutton
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qcommandlinkbutton.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
+index 0044d33c66..4cf06296e4 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
+@@ -40,6 +40,9 @@
+ #include <QGridLayout>
+ #include <QPainter>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ class tst_QCommandLinkButton : public QObject
+ {
+     Q_OBJECT
+@@ -223,6 +226,13 @@ void tst_QCommandLinkButton::setAutoRepeat()
+     // check that pressing ENTER has no effect
+     resetCounters();
+     testWidget->setDown( false );
++    // Skip after reset if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
+     testWidget->setAutoRepeat( false );
+     QTest::keyPress( testWidget, Qt::Key_Enter );
+ 
+@@ -255,6 +265,14 @@ void tst_QCommandLinkButton::pressed()
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+ 
++    // Skip if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
++
+     QTest::keyPress( testWidget,Qt::Key_Enter );
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+diff --git a/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro b/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
+index 4a5e76ff65..a235fa1fac 100644
+--- a/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
++++ b/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qgroupbox
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qgroupbox.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp b/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
+index 4fb5d262ca..d8d7562b73 100644
+--- a/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
+@@ -35,6 +35,9 @@
+ #include <QRadioButton>
+ #include <QDialog>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ #include "qgroupbox.h"
+ 
+ class tst_QGroupBox : public QObject
+@@ -69,6 +72,7 @@ private slots:
+     void propagateFocus();
+     void task_QTBUG_19170_ignoreMouseReleaseEvent();
+     void task_QTBUG_15519_propagateMouseEvents();
++    void buttonPressKeys();
+ 
+ private:
+     bool checked;
+@@ -610,6 +614,20 @@ void tst_QGroupBox::task_QTBUG_15519_propagateMouseEvents()
+     QCOMPARE(parent.mouseMoved, true);
+ }
+ 
++void tst_QGroupBox::buttonPressKeys()
++{
++    QGroupBox groupBox;
++    groupBox.setCheckable(true);
++    QSignalSpy clickedSpy(&groupBox, &QGroupBox::clicked);
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(&groupBox, buttonPressKeys[i]);
++        QCOMPARE(clickedSpy.length(), i + 1);
++    }
++}
++
+ void tst_QGroupBox::sendMouseMoveEvent(QWidget *widget, const QPoint &localPos)
+ {
+     // Send a MouseMove event without actually moving the pointer
+diff --git a/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro b/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
+index 353ad06ca2..e55f6148f2 100644
+--- a/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
++++ b/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qpushbutton
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qpushbutton.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp b/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
+index e818514a79..4043e9326a 100644
+--- a/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
+@@ -41,6 +41,9 @@
+ #include <QStyleFactory>
+ #include <QTabWidget>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ class tst_QPushButton : public QObject
+ {
+ Q_OBJECT
+@@ -212,6 +215,13 @@ void tst_QPushButton::autoRepeat()
+     // check that pressing ENTER has no effect
+     resetCounters();
+     testWidget->setDown( false );
++    // Skip after reset if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
+     testWidget->setAutoRepeat( false );
+     QTest::keyPress( testWidget, Qt::Key_Enter );
+ 
+@@ -247,6 +257,14 @@ void tst_QPushButton::pressed()
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+ 
++    // Skip if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
++
+     QTest::keyPress( testWidget,Qt::Key_Enter );
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+diff --git a/qtbase/tests/manual/rhi/cubemap_render/buildshader.bat b/qtbase/tests/manual/rhi/cubemap_render/buildshader.bat
+old mode 100755
+new mode 100644
+Submodule qtconnectivity e957d481..056294c0:
+diff --git a/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp b/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
+index e2635fae..a8b8e3b9 100644
+--- a/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
++++ b/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
+@@ -563,9 +563,11 @@ void HciManager::handleHciAclPacket(const quint8 *data, int size)
+ 
+ void HciManager::handleLeMetaEvent(const quint8 *data)
+ {
+-    // Spec v4.2, Vol 2, part E, 7.7.65ff
++    // Spec v5.3, Vol 4, part E, 7.7.65.*
+     switch (*data) {
+-    case 0x1: {
++    case 0x1: // HCI_LE_Connection_Complete
++    case 0xA: // HCI_LE_Enhanced_Connection_Complete
++    {
+         const quint16 handle = bt_get_le16(data + 2);
+         emit connectionComplete(handle);
+         break;
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp b/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
+index 6a93143b..4a18cfc7 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
+@@ -320,7 +320,10 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_finishSdpScan(QBluetoothServiceD
+             for (const QBluetoothUuid &id : serviceClassUuids) {
+                 if (id.minimumSize() == 16) {
+                     serviceInfo.setServiceUuid(id);
+-                    serviceInfo.setServiceName(QBluetoothServiceDiscoveryAgent::tr("Custom Service"));
++                    if (serviceInfo.serviceName().isEmpty()) {
++                        serviceInfo.setServiceName(
++                                    QBluetoothServiceDiscoveryAgent::tr("Custom Service"));
++                    }
+                     QBluetoothServiceInfo::Sequence modSeq =
+                             serviceInfo.attribute(QBluetoothServiceInfo::ServiceClassIds).value<QBluetoothServiceInfo::Sequence>();
+                     modSeq.removeOne(QVariant::fromValue(id));
+@@ -334,8 +337,10 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_finishSdpScan(QBluetoothServiceD
+                 qCDebug(QT_BT_BLUEZ) << "Discovered services" << discoveredDevices.at(0).address().toString()
+                                      << serviceInfo.serviceName() << serviceInfo.serviceUuid()
+                                      << ">>>" << serviceInfo.serviceClassUuids();
+-
+-                emit q->serviceDiscovered(serviceInfo);
++                // Use queued connection to allow us finish the service looping; the application
++                // might call stop() when it has detected the service-of-interest.
++                QMetaObject::invokeMethod(q, "serviceDiscovered", Qt::QueuedConnection,
++                                          Q_ARG(QBluetoothServiceInfo, serviceInfo));
+             }
+         }
+     }
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp b/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
+index e4d85447..aadd4755 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
+@@ -593,7 +593,7 @@ void QBluetoothSocket::setSocketState(QBluetoothSocket::SocketState state)
+ bool QBluetoothSocket::canReadLine() const
+ {
+     Q_D(const QBluetoothSocketBase);
+-    return d->canReadLine();
++    return d->canReadLine() || QIODevice::canReadLine();
+ }
+ 
+ /*!
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp b/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
+index 084aa958..d6aa17a7 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
+@@ -284,6 +284,10 @@ void QBluetoothSocketPrivateBluezDBus::connectToService(
+         return;
+     }
+ 
++    if (service.socketProtocol() != QBluetoothServiceInfo::Protocol::UnknownProtocol)
++        socketType = service.socketProtocol();
++    qCDebug(QT_BT_BLUEZ) << "Socket protocol used:" << socketType;
++
+     connectToService(service.device().address(), targetService, openMode);
+ }
+ 
+diff --git a/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp b/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
+index 05bc1a0f..a7b5ef1f 100644
+--- a/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
++++ b/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
+@@ -142,7 +142,7 @@ void tst_QBluetoothSocket::initTestCase()
+     qDebug() << "Starting discovery";
+ 
+     sda->setUuidFilter(QBluetoothUuid(QString(TEST_SERVICE_UUID)));
+-    sda->start(QBluetoothServiceDiscoveryAgent::MinimalDiscovery);
++    sda->start(QBluetoothServiceDiscoveryAgent::FullDiscovery);
+ 
+     for (int connectTime = MaxConnectTime; !done_discovery && connectTime > 0; connectTime -= 1000)
+         QTest::qWait(1000);
+Submodule qtdeclarative f5701f0d..8defe7bf:
+diff --git a/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h b/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
+index b65b994d6c..15a8cd6878 100644
+--- a/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
++++ b/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
+@@ -86,7 +86,7 @@ public:
+         if (QTypeInfo<T>::isComplex) {
+             for (int i = 0; i < count; ++i)
+                 new (data + i) T(vector.at(i));
+-        } else {
++        } else if (count) {
+             memcpy(data, static_cast<const void*>(vector.constData()), count * sizeof(T));
+         }
+     }
+diff --git a/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp b/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
+index e57cdd8278..94613598af 100644
+--- a/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
++++ b/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
+@@ -1145,8 +1145,7 @@ void Heap::QObjectWrapper::markObjects(Heap::Base *that, QV4::MarkStack *markSta
+ void QObjectWrapper::destroyObject(bool lastCall)
+ {
+     Heap::QObjectWrapper *h = d();
+-    if (!h->internalClass)
+-        return; // destroyObject already got called
++    Q_ASSERT(h->internalClass);
+ 
+     if (h->object()) {
+         QQmlData *ddata = QQmlData::get(h->object(), false);
+@@ -1176,7 +1175,7 @@ void QObjectWrapper::destroyObject(bool lastCall)
+         }
+     }
+ 
+-    h->~Data();
++    h->destroy();
+ }
+ 
+ 
+diff --git a/qtdeclarative/src/qml/memory/qv4mm.cpp b/qtdeclarative/src/qml/memory/qv4mm.cpp
+index 06caf04e5a..da149a67c4 100644
+--- a/qtdeclarative/src/qml/memory/qv4mm.cpp
++++ b/qtdeclarative/src/qml/memory/qv4mm.cpp
+@@ -981,7 +981,7 @@ void MemoryManager::sweep(bool lastSweep, ClassDestroyStatsCallback classCountPt
+ 
+     if (MultiplyWrappedQObjectMap *multiplyWrappedQObjects = engine->m_multiplyWrappedQObjects) {
+         for (MultiplyWrappedQObjectMap::Iterator it = multiplyWrappedQObjects->begin(); it != multiplyWrappedQObjects->end();) {
+-            if (!it.value().isNullOrUndefined())
++            if (it.value().isNullOrUndefined())
+                 it = multiplyWrappedQObjects->erase(it);
+             else
+                 ++it;
+diff --git a/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp b/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
+index 2079a8ed04..a577cb2351 100644
+--- a/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
++++ b/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
+@@ -389,6 +389,12 @@ void QQmlDelegateModelPrivate::connectToAbstractItemModel()
+                       q,  QQmlDelegateModel, SLOT(_q_rowsRemoved(QModelIndex,int,int)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
+                       q,  QQmlDelegateModel, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsInserted(QModelIndex,int,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsInserted(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsRemoved(QModelIndex,int,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsRemoved(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsMoved(QModelIndex,int,int,QModelIndex,int)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
+                       q, QQmlDelegateModel, SLOT(_q_dataChanged(QModelIndex,QModelIndex,QVector<int>)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
+@@ -413,6 +419,12 @@ void QQmlDelegateModelPrivate::disconnectFromAbstractItemModel()
+                         q, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int)));
+     QObject::disconnect(aim, SIGNAL(rowsRemoved(QModelIndex,int,int)),
+                         q, SLOT(_q_rowsRemoved(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsInserted(QModelIndex,int,int)), q,
++                        SLOT(_q_columnsInserted(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsRemoved(QModelIndex,int,int)), q,
++                        SLOT(_q_columnsRemoved(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)), q,
++                        SLOT(_q_columnsMoved(QModelIndex,int,int,QModelIndex,int)));
+     QObject::disconnect(aim, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
+                         q, SLOT(_q_dataChanged(QModelIndex,QModelIndex,QVector<int>)));
+     QObject::disconnect(aim, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
+@@ -1973,6 +1985,38 @@ void QQmlDelegateModel::_q_rowsMoved(
+     }
+ }
+ 
++void QQmlDelegateModel::_q_columnsInserted(const QModelIndex &parent, int begin, int end)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if (parent == d->m_adaptorModel.rootIndex && begin == 0) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
++void QQmlDelegateModel::_q_columnsRemoved(const QModelIndex &parent, int begin, int end)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if (parent == d->m_adaptorModel.rootIndex && begin == 0) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
++void QQmlDelegateModel::_q_columnsMoved(const QModelIndex &parent, int start, int end,
++                                        const QModelIndex &destination, int column)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if ((parent == d->m_adaptorModel.rootIndex && start == 0)
++        || (destination == d->m_adaptorModel.rootIndex && column == 0)) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
+ void QQmlDelegateModel::_q_dataChanged(const QModelIndex &begin, const QModelIndex &end, const QVector<int> &roles)
+ {
+     Q_D(QQmlDelegateModel);
+diff --git a/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h b/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
+index 8aab4badca..d140bfbaaf 100644
+--- a/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
++++ b/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
+@@ -152,6 +152,9 @@ private Q_SLOTS:
+     void _q_itemsMoved(int from, int to, int count);
+     void _q_modelReset();
+     void _q_rowsInserted(const QModelIndex &,int,int);
++    void _q_columnsInserted(const QModelIndex &, int, int);
++    void _q_columnsRemoved(const QModelIndex &, int, int);
++    void _q_columnsMoved(const QModelIndex &, int, int, const QModelIndex &, int);
+     void _q_rowsAboutToBeRemoved(const QModelIndex &parent, int begin, int end);
+     void _q_rowsRemoved(const QModelIndex &,int,int);
+     void _q_rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int);
+diff --git a/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp b/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
+index 85719fdc80..78e2ab302c 100644
+--- a/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
++++ b/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
+@@ -46,6 +46,7 @@
+ #include "QtQuick/private/qquicktextinput_p.h"
+ #include "QtQuick/private/qquickaccessibleattached_p.h"
+ #include "QtQuick/qquicktextdocument.h"
++#include "QtQuick/qquickrendercontrol.h"
+ QT_BEGIN_NAMESPACE
+ 
+ #if QT_CONFIG(accessibility)
+@@ -57,7 +58,19 @@ QAccessibleQuickItem::QAccessibleQuickItem(QQuickItem *item)
+ 
+ QWindow *QAccessibleQuickItem::window() const
+ {
+-    return item()->window();
++    QQuickWindow *window = item()->window();
++
++    // For QQuickWidget the above window will be the offscreen QQuickWindow,
++    // which is not a part of the accessibility tree. Detect this case and
++    // return the window for the QQuickWidget instead.
++    if (window && !window->handle()) {
++        if (QQuickRenderControl *renderControl = QQuickWindowPrivate::get(window)->renderControl) {
++            if (QWindow *renderWindow = renderControl->renderWindow(nullptr))
++                return renderWindow;
++        }
++    }
++
++    return window;
+ }
+ 
+ int QAccessibleQuickItem::childCount() const
+@@ -113,19 +126,15 @@ QAccessibleInterface *QAccessibleQuickItem::childAt(int x, int y) const
+ QAccessibleInterface *QAccessibleQuickItem::parent() const
+ {
+     QQuickItem *parent = item()->parentItem();
+-    QQuickWindow *window = item()->window();
+-    QQuickItem *ci = window ? window->contentItem() : nullptr;
++    QQuickWindow *itemWindow = item()->window();
++    QQuickItem *ci = itemWindow ? itemWindow->contentItem() : nullptr;
+     while (parent && !QQuickItemPrivate::get(parent)->isAccessible && parent != ci)
+         parent = parent->parentItem();
+ 
+     if (parent) {
+         if (parent == ci) {
+-            // Jump out to the scene widget if the parent is the root item.
+-            // There are two root items, QQuickWindow::rootItem and
+-            // QQuickView::declarativeRoot. The former is the true root item,
+-            // but is not a part of the accessibility tree. Check if we hit
+-            // it here and return an interface for the scene instead.
+-            return QAccessible::queryAccessibleInterface(window);
++            // Jump out to the window if the parent is the root item
++            return QAccessible::queryAccessibleInterface(window());
+         } else {
+             while (parent && !parent->d_func()->isAccessible)
+                 parent = parent->parentItem();
+@@ -188,7 +197,7 @@ QAccessible::State QAccessibleQuickItem::state() const
+     QRect viewRect_ = viewRect();
+     QRect itemRect = rect();
+ 
+-    if (viewRect_.isNull() || itemRect.isNull() || !item()->window() || !item()->window()->isVisible() ||!item()->isVisible() || qFuzzyIsNull(item()->opacity()))
++    if (viewRect_.isNull() || itemRect.isNull() || !window() || !window()->isVisible() ||!item()->isVisible() || qFuzzyIsNull(item()->opacity()))
+         state.invisible = true;
+     if (!viewRect_.intersects(itemRect))
+         state.offscreen = true;
+@@ -201,6 +210,10 @@ QAccessible::State QAccessibleQuickItem::state() const
+     if (role() == QAccessible::EditableText)
+         if (auto ti = qobject_cast<QQuickTextInput *>(item()))
+             state.passwordEdit = ti->echoMode() != QQuickTextInput::Normal;
++    if (!item()->isEnabled()) {
++        state.focusable = false;
++        state.disabled = true;
++    }
+     return state;
+ }
+ 
+diff --git a/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h b/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
+index 39ffcaf39c..8baa01330c 100644
+--- a/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
++++ b/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
+@@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE
+ 
+ #if QT_CONFIG(accessibility)
+ 
+-class QAccessibleQuickWindow : public QAccessibleObject
++class Q_QUICK_EXPORT QAccessibleQuickWindow : public QAccessibleObject
+ {
+ public:
+     QAccessibleQuickWindow(QQuickWindow *object);
+diff --git a/qtdeclarative/src/quick/items/qquickdrag.cpp b/qtdeclarative/src/quick/items/qquickdrag.cpp
+index 8321fcfeed..383078b3b9 100644
+--- a/qtdeclarative/src/quick/items/qquickdrag.cpp
++++ b/qtdeclarative/src/quick/items/qquickdrag.cpp
+@@ -481,7 +481,9 @@ void QQuickDragAttached::setKeys(const QStringList &keys)
+     \qmlattachedproperty stringlist QtQuick::Drag::mimeData
+     \since 5.2
+ 
+-    This property holds a map of mimeData that is used during startDrag.
++    This property holds a map from mime type to data that is used during startDrag.
++    The mime data needs to be a \c string, or an \c ArrayBuffer with the data encoded
++    according to the mime type.
+ */
+ 
+ QVariantMap QQuickDragAttached::mimeData() const
+@@ -766,8 +768,12 @@ Qt::DropAction QQuickDragAttachedPrivate::startDrag(Qt::DropActions supportedAct
+     QDrag *drag = new QDrag(source ? source : q);
+     QMimeData *mimeData = new QMimeData();
+ 
+-    for (auto it = externalMimeData.cbegin(), end = externalMimeData.cend(); it != end; ++it)
+-        mimeData->setData(it.key(), it.value().toString().toUtf8());
++    for (auto it = externalMimeData.cbegin(), end = externalMimeData.cend(); it != end; ++it) {
++        if (static_cast<QMetaType::Type>(it.value().type()) == QMetaType::QByteArray)
++            mimeData->setData(it.key(), it.value().toByteArray());
++        else
++            mimeData->setData(it.key(), it.value().toString().toUtf8());
++    }
+ 
+     drag->setMimeData(mimeData);
+     if (pixmapLoader.isReady()) {
+diff --git a/qtdeclarative/src/quick/items/qquickitem.cpp b/qtdeclarative/src/quick/items/qquickitem.cpp
+index 75f1457816..dec0ae19ae 100644
+--- a/qtdeclarative/src/quick/items/qquickitem.cpp
++++ b/qtdeclarative/src/quick/items/qquickitem.cpp
+@@ -59,6 +59,7 @@
+ #include <QtCore/private/qnumeric_p.h>
+ #include <QtGui/qpa/qplatformtheme.h>
+ #include <QtCore/qloggingcategory.h>
++#include <QtCore/private/qduplicatetracker_p.h>
+ 
+ #include <private/qqmlglobal_p.h>
+ #include <private/qqmlengine_p.h>
+@@ -2326,6 +2327,7 @@ QQuickItem::QQuickItem(QQuickItemPrivate &dd, QQuickItem *parent)
+ QQuickItem::~QQuickItem()
+ {
+     Q_D(QQuickItem);
++    d->inDestructor = true;
+ 
+     if (d->windowRefCount > 1)
+         d->windowRefCount = 1; // Make sure window is set to null in next call to derefWindow().
+@@ -2526,6 +2528,7 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo
+     QQuickItem *current = item;
+     qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: startItem:" << startItem;
+     qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: firstFromItem:" << firstFromItem;
++    QDuplicateTracker<QQuickItem *> cycleDetector;
+     do {
+         qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: current:" << current;
+         qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: from:" << from;
+@@ -2592,7 +2595,10 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo
+         // traversed all of the chain (by compare the [current] item with [startItem])
+         // Since the [startItem] might be promoted to its parent if it is invisible,
+         // we still have to check [current] item with original start item
+-        if ((current == startItem || current == originalStartItem) && from == firstFromItem) {
++        // We might also run into a cycle before we reach firstFromItem again
++        // but note that we have to ignore current if we are meant to skip it
++        if (((current == startItem || current == originalStartItem) && from == firstFromItem) ||
++                (!skip && cycleDetector.hasSeen(current))) {
+             // wrapped around, avoid endless loops
+             if (item == contentItem) {
+                 qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: looped, return contentItem";
+@@ -2689,9 +2695,8 @@ void QQuickItem::setParentItem(QQuickItem *parentItem)
+ 
+         const bool wasVisible = isVisible();
+         op->removeChild(this);
+-        if (wasVisible) {
++        if (wasVisible && !op->inDestructor)
+             emit oldParentItem->visibleChildrenChanged();
+-        }
+     } else if (d->window) {
+         QQuickWindowPrivate::get(d->window)->parentlessItems.remove(this);
+     }
+@@ -2768,8 +2773,9 @@ void QQuickItem::setParentItem(QQuickItem *parentItem)
+ 
+     d->itemChange(ItemParentHasChanged, d->parentItem);
+ 
+-    emit parentChanged(d->parentItem);
+-    if (isVisible() && d->parentItem)
++    if (!d->inDestructor)
++        emit parentChanged(d->parentItem);
++    if (isVisible() && d->parentItem && !QQuickItemPrivate::get(d->parentItem)->inDestructor)
+         emit d->parentItem->visibleChildrenChanged();
+ }
+ 
+@@ -2965,7 +2971,8 @@ void QQuickItemPrivate::removeChild(QQuickItem *child)
+ 
+     itemChange(QQuickItem::ItemChildRemovedChange, child);
+ 
+-    emit q->childrenChanged();
++    if (!inDestructor)
++        emit q->childrenChanged();
+ }
+ 
+ void QQuickItemPrivate::refWindow(QQuickWindow *c)
+@@ -3194,6 +3201,7 @@ QQuickItemPrivate::QQuickItemPrivate()
+     , touchEnabled(false)
+ #endif
+     , hasCursorHandler(false)
++    , inDestructor(false)
+     , dirtyAttributes(0)
+     , nextDirtyItem(nullptr)
+     , prevDirtyItem(nullptr)
+@@ -5120,6 +5128,13 @@ void QQuickItem::componentComplete()
+         d->addToDirtyList();
+         QQuickWindowPrivate::get(d->window)->dirtyItem(this);
+     }
++
++#if QT_CONFIG(accessibility)
++    if (d->isAccessible && d->effectiveVisible) {
++        QAccessibleEvent ev(this, QAccessible::ObjectShow);
++        QAccessible::updateAccessibility(&ev);
++    }
++#endif
+ }
+ 
+ QQuickStateGroup *QQuickItemPrivate::_states()
+@@ -6106,9 +6121,11 @@ bool QQuickItemPrivate::setEffectiveVisibleRecur(bool newEffectiveVisible)
+         QAccessible::updateAccessibility(&ev);
+     }
+ #endif
+-    emit q->visibleChanged();
+-    if (childVisibilityChanged)
+-        emit q->visibleChildrenChanged();
++    if (!inDestructor) {
++        emit q->visibleChanged();
++        if (childVisibilityChanged)
++            emit q->visibleChildrenChanged();
++    }
+ 
+     return true;    // effective visibility DID change
+ }
+@@ -6157,6 +6174,15 @@ void QQuickItemPrivate::setEffectiveEnableRecur(QQuickItem *scope, bool newEffec
+     }
+ 
+     itemChange(QQuickItem::ItemEnabledHasChanged, effectiveEnable);
++#if QT_CONFIG(accessibility)
++    if (isAccessible) {
++        QAccessible::State changedState;
++        changedState.disabled = true;
++        changedState.focusable = true;
++        QAccessibleStateChangeEvent ev(q, changedState);
++        QAccessible::updateAccessibility(&ev);
++    }
++#endif
+     emit q->enabledChanged();
+ }
+ 
+diff --git a/qtdeclarative/src/quick/items/qquickitem_p.h b/qtdeclarative/src/quick/items/qquickitem_p.h
+index 841d91bb40..ade8fb61f2 100644
+--- a/qtdeclarative/src/quick/items/qquickitem_p.h
++++ b/qtdeclarative/src/quick/items/qquickitem_p.h
+@@ -472,6 +472,7 @@ public:
+     bool replayingPressEvent:1;
+     bool touchEnabled:1;
+     bool hasCursorHandler:1;
++    quint32 inDestructor:1; // has entered ~QQuickItem
+ 
+     enum DirtyType {
+         TransformOrigin         = 0x00000001,
+diff --git a/qtdeclarative/src/quick/items/qquickitemview.cpp b/qtdeclarative/src/quick/items/qquickitemview.cpp
+index 010a0152e1..f8ad168a17 100644
+--- a/qtdeclarative/src/quick/items/qquickitemview.cpp
++++ b/qtdeclarative/src/quick/items/qquickitemview.cpp
+@@ -1785,7 +1785,7 @@ void QQuickItemViewPrivate::refill(qreal from, qreal to)
+ 
+     do {
+         bufferPause.stop();
+-        if (currentChanges.hasPendingChanges() || bufferedChanges.hasPendingChanges()) {
++        if (currentChanges.hasPendingChanges() || bufferedChanges.hasPendingChanges() || currentChanges.active) {
+             currentChanges.reset();
+             bufferedChanges.reset();
+             releaseVisibleItems(reusableFlag);
+diff --git a/qtdeclarative/src/quick/items/qquickmousearea_p_p.h b/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
+index fba383e268..0d63618622 100644
+--- a/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
++++ b/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
+@@ -61,7 +61,6 @@ QT_BEGIN_NAMESPACE
+ 
+ class QQuickMouseEvent;
+ class QQuickMouseArea;
+-class QQuickPointerMask;
+ class QQuickMouseAreaPrivate : public QQuickItemPrivate
+ {
+     Q_DECLARE_PUBLIC(QQuickMouseArea)
+@@ -100,7 +99,6 @@ public:
+ #if QT_CONFIG(quick_draganddrop)
+     QQuickDrag *drag;
+ #endif
+-    QPointer<QQuickPointerMask> mask;
+     QPointF startScene;
+     QPointF targetStartPos;
+     QPointF lastPos;
+diff --git a/qtdeclarative/src/quick/items/qquicktext.cpp b/qtdeclarative/src/quick/items/qquicktext.cpp
+index 6230186933..e823ca1095 100644
+--- a/qtdeclarative/src/quick/items/qquicktext.cpp
++++ b/qtdeclarative/src/quick/items/qquicktext.cpp
+@@ -2168,7 +2168,7 @@ void QQuickText::resetMaximumLineCount()
+     <img src="" align="top,middle,bottom" width="" height=""> - inline images
+     <ol type="">, <ul type=""> and <li> - ordered and unordered lists
+     <pre></pre> - preformatted
+-    &gt; &lt; &amp;
++    &gt; &lt; &amp; &quot; &nbsp; &apos;
+     \endcode
+ 
+     \c Text.StyledText parser is strict, requiring tags to be correctly nested.
+diff --git a/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp b/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
+index eb4db0f85e..2325a2665b 100644
+--- a/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
++++ b/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
+@@ -446,7 +446,7 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+         const char *textureRecord = allocatorData;
+         for (int i = 0; i < textureCount; ++i, textureRecord += Qtdf::TextureRecordSize) {
+-            if (textureRecord + Qtdf::TextureRecordSize > qtdfTableEnd) {
++            if (qtdfTableEnd - textureRecord < Qtdf::TextureRecordSize) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+@@ -462,7 +462,7 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+         const char *glyphRecord = textureRecord;
+         for (quint32 i = 0; i < glyphCount; ++i, glyphRecord += Qtdf::GlyphRecordSize) {
+-            if (glyphRecord + Qtdf::GlyphRecordSize > qtdfTableEnd) {
++            if (qtdfTableEnd - glyphRecord < Qtdf:: GlyphRecordSize) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+@@ -512,8 +512,8 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+             int width = texInfo->allocatedArea.width();
+             int height = texInfo->allocatedArea.height();
+-            qint64 size = width * height;
+-            if (reinterpret_cast<const char *>(textureData + size) > qtdfTableEnd) {
++            qint64 size = qint64(width) * height;
++            if (qtdfTableEnd - reinterpret_cast<const char *>(textureData) < size) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+diff --git a/qtdeclarative/src/quick/util/qquickstyledtext.cpp b/qtdeclarative/src/quick/util/qquickstyledtext.cpp
+index d531fc9205..a25af90414 100644
+--- a/qtdeclarative/src/quick/util/qquickstyledtext.cpp
++++ b/qtdeclarative/src/quick/util/qquickstyledtext.cpp
+@@ -564,6 +564,8 @@ void QQuickStyledTextPrivate::parseEntity(const QChar *&ch, const QString &textI
+                 textOut += QChar(60);
+             else if (entity == QLatin1String("amp"))
+                 textOut += QChar(38);
++            else if (entity == QLatin1String("apos"))
++                textOut += QChar(39);
+             else if (entity == QLatin1String("quot"))
+                 textOut += QChar(34);
+             else if (entity == QLatin1String("nbsp"))
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp
+new file mode 100644
+index 0000000000..8a1c901880
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp
+@@ -0,0 +1,110 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include "qaccessiblequickwidget_p.h"
++
++#include "qquickwidget_p.h"
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleQuickWidget::QAccessibleQuickWidget(QQuickWidget* widget)
++: QAccessibleWidget(widget)
++, m_accessibleWindow(QQuickWidgetPrivate::get(widget)->offscreenWindow)
++{
++    // NOTE: m_accessibleWindow is a QAccessibleQuickWindow, and not a
++    // QAccessibleQuickWidgetOffscreenWindow (defined below). This means
++    // it will return the Quick item child interfaces, which is what's needed here
++    // (unlike QAccessibleQuickWidgetOffscreenWindow, which will report 0 children).
++}
++
++QAccessibleInterface *QAccessibleQuickWidget::child(int index) const
++{
++    return m_accessibleWindow.child(index);
++}
++
++int QAccessibleQuickWidget::childCount() const
++{
++    return m_accessibleWindow.childCount();
++}
++
++int QAccessibleQuickWidget::indexOfChild(const QAccessibleInterface *iface) const
++{
++    return m_accessibleWindow.indexOfChild(iface);
++}
++
++QAccessibleInterface *QAccessibleQuickWidget::childAt(int x, int y) const
++{
++    return m_accessibleWindow.childAt(x, y);
++}
++
++QAccessibleQuickWidgetOffscreenWindow::QAccessibleQuickWidgetOffscreenWindow(QQuickWindow *window)
++:QAccessibleQuickWindow(window)
++{
++
++}
++
++QAccessibleInterface *QAccessibleQuickWidgetOffscreenWindow::child(int index) const
++{
++    Q_UNUSED(index);
++    return nullptr;
++}
++
++int QAccessibleQuickWidgetOffscreenWindow::childCount() const
++{
++    return 0;
++}
++
++int QAccessibleQuickWidgetOffscreenWindow::indexOfChild(const QAccessibleInterface *iface) const
++{
++    Q_UNUSED(iface);
++    return -1;
++}
++
++QAccessibleInterface *QAccessibleQuickWidgetOffscreenWindow::QAccessibleQuickWidgetOffscreenWindow::childAt(int x, int y) const
++{
++    Q_UNUSED(x);
++    Q_UNUSED(y);
++    return nullptr;
++}
++
++#endif // accessibility
++
++QT_END_NAMESPACE
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h
+new file mode 100644
+index 0000000000..7c2ab930e0
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h
+@@ -0,0 +1,95 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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 QACCESSIBLEQUICKWIDGET_H
++#define QACCESSIBLEQUICKWIDGET_H
++
++//
++//  W A R N I N G
++//  -------------
++//
++// This file is not part of the Qt API.  It exists purely as an
++// implementation detail.  This header file may change from version to
++// version without notice, or even be removed.
++//
++// We mean it.
++//
++
++#include "qquickwidget.h"
++#include <QtWidgets/qaccessiblewidget.h>
++
++#include <private/qaccessiblequickview_p.h>
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++// These classes implement the QQuickWiget accessibility switcharoo,
++// where the child items of the QQuickWidgetOffscreenWindow are reported
++// as child accessible interfaces of the QAccessibleQuickWidget.
++class QAccessibleQuickWidget: public QAccessibleWidget
++{
++public:
++    QAccessibleQuickWidget(QQuickWidget* widget);
++
++    QAccessibleInterface *child(int index) const override;
++    int childCount() const override;
++    int indexOfChild(const QAccessibleInterface *iface) const override;
++    QAccessibleInterface *childAt(int x, int y) const override;
++
++private:
++    QAccessibleQuickWindow m_accessibleWindow;
++    Q_DISABLE_COPY(QAccessibleQuickWidget)
++};
++
++class QAccessibleQuickWidgetOffscreenWindow: public QAccessibleQuickWindow
++{
++public:
++    QAccessibleQuickWidgetOffscreenWindow(QQuickWindow *window);
++    QAccessibleInterface *child(int index) const override;
++    int childCount() const override;
++    int indexOfChild(const QAccessibleInterface *iface) const override;
++    QAccessibleInterface *childAt(int x, int y) const override;
++};
++
++#endif // accessibility
++
++QT_END_NAMESPACE
++
++#endif
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp
+new file mode 100644
+index 0000000000..7ba88a1769
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp
+@@ -0,0 +1,60 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include "qaccessiblequickwidgetfactory_p.h"
++#include "qaccessiblequickwidget_p.h"
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleInterface *qAccessibleQuickWidgetFactory(const QString &classname, QObject *object)
++{
++    if (classname == QLatin1String("QQuickWidget")) {
++        return new QAccessibleQuickWidget(qobject_cast<QQuickWidget *>(object));
++    } else if (classname == QLatin1String("QQuickWidgetOffscreenWindow")) {
++        return new QAccessibleQuickWidgetOffscreenWindow(qobject_cast<QQuickWindow *>(object));
++    }
++    return 0;
++}
++
++#endif // accessibility
++
++QT_END_NAMESPACE
++
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h
+new file mode 100644
+index 0000000000..8c63b09f81
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h
+@@ -0,0 +1,66 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include <QtGui/qaccessible.h>
++
++#ifndef QACCESSIBLEQUICKWIDGETFACTORY_H
++#define QACCESSIBLEQUICKWIDGETFACTORY_H
++
++//
++//  W A R N I N G
++//  -------------
++//
++// This file is not part of the Qt API.  It exists purely as an
++// implementation detail.  This header file may change from version to
++// version without notice, or even be removed.
++//
++// We mean it.
++//
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleInterface *qAccessibleQuickWidgetFactory(const QString &classname, QObject *object);
++
++#endif
++
++QT_END_NAMESPACE
++
++#endif
+diff --git a/qtdeclarative/src/quickwidgets/qquickwidget.cpp b/qtdeclarative/src/quickwidgets/qquickwidget.cpp
+index 39780f8de3..9c97b43518 100644
+--- a/qtdeclarative/src/quickwidgets/qquickwidget.cpp
++++ b/qtdeclarative/src/quickwidgets/qquickwidget.cpp
+@@ -39,6 +39,7 @@
+ 
+ #include "qquickwidget.h"
+ #include "qquickwidget_p.h"
++#include "qaccessiblequickwidgetfactory_p.h"
+ 
+ #include "private/qquickwindow_p.h"
+ #include "private/qquickitem_p.h"
+@@ -75,9 +76,16 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++QQuickWidgetOffscreenWindow::QQuickWidgetOffscreenWindow(QQuickWindowPrivate &dd, QQuickRenderControl *control)
++:QQuickWindow(dd, control)
++{
++    setTitle(QString::fromLatin1("Offscreen"));
++    setObjectName(QString::fromLatin1("QQuickOffScreenWindow"));
++}
++
+ // override setVisble to prevent accidental offscreen window being created
+ // by base class.
+-class QQuickOffcreenWindowPrivate: public QQuickWindowPrivate {
++class QQuickWidgetOffscreenWindowPrivate: public QQuickWindowPrivate {
+ public:
+     void setVisible(bool visible) override {
+         Q_Q(QWindow);
+@@ -105,9 +113,8 @@ void QQuickWidgetPrivate::init(QQmlEngine* e)
+     Q_Q(QQuickWidget);
+ 
+     renderControl = new QQuickWidgetRenderControl(q);
+-    offscreenWindow = new QQuickWindow(*new QQuickOffcreenWindowPrivate(),renderControl);
+-    offscreenWindow->setTitle(QString::fromLatin1("Offscreen"));
+-    offscreenWindow->setObjectName(QString::fromLatin1("QQuickOffScreenWindow"));
++    offscreenWindow = new QQuickWidgetOffscreenWindow(*new QQuickWidgetOffscreenWindowPrivate(), renderControl);
++    offscreenWindow->setScreen(q->screen());
+     // Do not call create() on offscreenWindow.
+ 
+     // Check if the Software Adaptation is being used
+@@ -138,6 +145,10 @@ void QQuickWidgetPrivate::init(QQmlEngine* e)
+     QWidget::connect(offscreenWindow, &QQuickWindow::focusObjectChanged, q, &QQuickWidget::propagateFocusObjectChanged);
+     QObject::connect(renderControl, SIGNAL(renderRequested()), q, SLOT(triggerUpdate()));
+     QObject::connect(renderControl, SIGNAL(sceneChanged()), q, SLOT(triggerUpdate()));
++
++#if QT_CONFIG(accessibility)
++    QAccessible::installFactory(&qAccessibleQuickWidgetFactory);
++#endif
+ }
+ 
+ void QQuickWidgetPrivate::ensureEngine() const
+@@ -901,9 +912,7 @@ void QQuickWidgetPrivate::createContext()
+ 
+         context = new QOpenGLContext;
+         context->setFormat(offscreenWindow->requestedFormat());
+-        const QWindow *win = q->window()->windowHandle();
+-        if (win && win->screen())
+-            context->setScreen(win->screen());
++        context->setScreen(q->screen());
+         QOpenGLContext *shareContext = qt_gl_global_share_context();
+         if (!shareContext)
+             shareContext = QWidgetPrivate::get(q->window())->shareContext();
+@@ -1520,19 +1529,16 @@ bool QQuickWidget::event(QEvent *e)
+         d->handleWindowChange();
+         break;
+ 
+-    case QEvent::ScreenChangeInternal:
+-        if (QWindow *window = this->window()->windowHandle()) {
+-            QScreen *newScreen = window->screen();
+-
+-            if (d->offscreenWindow)
+-                d->offscreenWindow->setScreen(newScreen);
+-            if (d->offscreenSurface)
+-                d->offscreenSurface->setScreen(newScreen);
++    case QEvent::ScreenChangeInternal: {
++        QScreen *newScreen = screen();
++        if (d->offscreenWindow)
++            d->offscreenWindow->setScreen(newScreen);
++        if (d->offscreenSurface)
++            d->offscreenSurface->setScreen(newScreen);
+ #if QT_CONFIG(opengl)
+-            if (d->context)
+-                d->context->setScreen(newScreen);
++        if (d->context)
++            d->context->setScreen(newScreen);
+ #endif
+-        }
+ 
+         if (d->useSoftwareRenderer
+ #if QT_CONFIG(opengl)
+@@ -1545,7 +1551,7 @@ bool QQuickWidget::event(QEvent *e)
+             d->render(true);
+         }
+         break;
+-
++    }
+     case QEvent::Show:
+     case QEvent::Move:
+         d->updatePosition();
+diff --git a/qtdeclarative/src/quickwidgets/qquickwidget_p.h b/qtdeclarative/src/quickwidgets/qquickwidget_p.h
+index 881f7f9220..1a946bcc71 100644
+--- a/qtdeclarative/src/quickwidgets/qquickwidget_p.h
++++ b/qtdeclarative/src/quickwidgets/qquickwidget_p.h
+@@ -148,6 +148,14 @@ public:
+     bool forceFullUpdate;
+ };
+ 
++class QQuickWidgetOffscreenWindow: public QQuickWindow
++{
++    Q_OBJECT
++
++public:
++    QQuickWidgetOffscreenWindow(QQuickWindowPrivate &dd, QQuickRenderControl *control);
++};
++
+ QT_END_NAMESPACE
+ 
+ #endif // QQuickWidget_P_H
+diff --git a/qtdeclarative/src/quickwidgets/quickwidgets.pro b/qtdeclarative/src/quickwidgets/quickwidgets.pro
+index 2438e577ae..85d156b8a3 100644
+--- a/qtdeclarative/src/quickwidgets/quickwidgets.pro
++++ b/qtdeclarative/src/quickwidgets/quickwidgets.pro
+@@ -7,9 +7,13 @@ DEFINES   += QT_NO_URL_CAST_FROM_STRING QT_NO_INTEGER_EVENT_COORDINATES QT_NO_FO
+ HEADERS += \
+     qquickwidget.h \
+     qquickwidget_p.h \
+-    qtquickwidgetsglobal.h
++    qtquickwidgetsglobal.h \
++    qaccessiblequickwidget_p.h \
++    qaccessiblequickwidgetfactory_p.h
+ 
+ SOURCES += \
+-    qquickwidget.cpp
++    qquickwidget.cpp \
++    qaccessiblequickwidget.cpp \
++    qaccessiblequickwidgetfactory.cpp
+ 
+ load(qt_module)
+diff --git a/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+index 3b7d74df63..b75bf820d5 100644
+--- a/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
++++ b/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+@@ -102,6 +102,7 @@ private slots:
+     void valueConversion_RegularExpression();
+     void castWithMultipleInheritance();
+     void collectGarbage();
++    void collectGarbageNestedWrappersTwoEngines();
+     void gcWithNestedDataStructure();
+     void stacktrace();
+     void numberParsing_data();
+@@ -1809,6 +1810,44 @@ void tst_QJSEngine::collectGarbage()
+     QVERIFY(ptr.isNull());
+ }
+ 
++class TestObjectContainer : public QObject
++{
++    Q_OBJECT
++    Q_PROPERTY(QObject *dummy MEMBER m_dummy CONSTANT)
++
++public:
++    TestObjectContainer() : m_dummy(new QObject(this)) {}
++
++private:
++    QObject *m_dummy;
++};
++
++void tst_QJSEngine::collectGarbageNestedWrappersTwoEngines()
++{
++    QJSEngine engine1;
++    QJSEngine engine2;
++
++    TestObjectContainer container;
++    QQmlEngine::setObjectOwnership(&container, QQmlEngine::CppOwnership);
++
++    engine1.globalObject().setProperty("foobar", engine1.newQObject(&container));
++    engine2.globalObject().setProperty("foobar", engine2.newQObject(&container));
++
++    engine1.evaluate("foobar.dummy.baz = 42");
++    engine2.evaluate("foobar.dummy.baz = 43");
++
++    QCOMPARE(engine1.evaluate("foobar.dummy.baz").toInt(), 42);
++    QCOMPARE(engine2.evaluate("foobar.dummy.baz").toInt(), 43);
++
++    engine1.collectGarbage();
++    engine2.collectGarbage();
++
++    // The GC should not collect dummy object wrappers neither in engine1 nor engine2, we
++    // verify that by checking whether the baz property still has its previous value.
++    QCOMPARE(engine1.evaluate("foobar.dummy.baz").toInt(), 42);
++    QCOMPARE(engine2.evaluate("foobar.dummy.baz").toInt(), 43);
++}
++
+ void tst_QJSEngine::gcWithNestedDataStructure()
+ {
+     // The GC must be able to traverse deeply nested objects, otherwise this
+diff --git a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml
+new file mode 100644
+index 0000000000..206133bb39
+--- /dev/null
++++ b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml
+@@ -0,0 +1,11 @@
++import QtQuick 2.8
++
++ListView {
++    id: root
++    width: 200
++    height: 200
++
++    delegate: Text {
++        text: display
++    }
++}
+diff --git a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
+index 35f1e2c94d..1722447830 100644
+--- a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
++++ b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
+@@ -27,6 +27,8 @@
+ ****************************************************************************/
+ 
+ #include <QtTest/qtest.h>
++#include <QtCore/QConcatenateTablesProxyModel>
++#include <QtGui/QStandardItemModel>
+ #include <QtQml/qqmlcomponent.h>
+ #include <QtQmlModels/private/qqmldelegatemodel_p.h>
+ #include <QtQuick/qquickview.h>
+@@ -47,6 +49,7 @@ private slots:
+     void filterOnGroup_removeWhenCompleted();
+     void qtbug_86017();
+     void contextAccessedByHandler();
++    void redrawUponColumnChange();
+ };
+ 
+ class AbstractItemModel : public QAbstractItemModel
+@@ -186,6 +189,30 @@ void tst_QQmlDelegateModel::contextAccessedByHandler()
+     QVERIFY(root->property("works").toBool());
+ }
+ 
++void tst_QQmlDelegateModel::redrawUponColumnChange()
++{
++    QStandardItemModel m1;
++    m1.appendRow({
++            new QStandardItem("Banana"),
++            new QStandardItem("Coconut"),
++    });
++
++    QQuickView view(testFileUrl("redrawUponColumnChange.qml"));
++    QCOMPARE(view.status(), QQuickView::Ready);
++    view.show();
++    QQuickItem *root = view.rootObject();
++    root->setProperty("model", QVariant::fromValue<QObject *>(&m1));
++
++    QObject *item = root->property("currentItem").value<QObject *>();
++    QVERIFY(item);
++    QCOMPARE(item->property("text").toString(), "Banana");
++
++    QVERIFY(root);
++    m1.removeColumn(0);
++
++    QCOMPARE(item->property("text").toString(), "Coconut");
++}
++
+ QTEST_MAIN(tst_QQmlDelegateModel)
+ 
+ #include "tst_qqmldelegatemodel.moc"
+diff --git a/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp b/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
+index 5d635aa63b..824fd89e5b 100644
+--- a/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
++++ b/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
+@@ -76,10 +76,10 @@ void tst_qv4mm::multiWrappedQObjects()
+         QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 1);
+         QCOMPARE(engine2.memoryManager->m_pendingFreedObjectWrapperValue.size(), 0);
+ 
+-        // Moves the additional WeakValue from m_multiplyWrappedQObjects to
+-        // m_pendingFreedObjectWrapperValue. It's still alive after all.
++        // The additional WeakValue from m_multiplyWrappedQObjects hasn't been moved
++        // to m_pendingFreedObjectWrapperValue yet. It's still alive after all.
+         engine1.memoryManager->runGC();
+-        QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 2);
++        QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 1);
+ 
+         // engine2 doesn't own the object as engine1 was the first to wrap it above.
+         // Therefore, no effect here.
+diff --git a/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml b/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml
+new file mode 100644
+index 0000000000..889e480f3b
+--- /dev/null
++++ b/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml
+@@ -0,0 +1,13 @@
++import QtQuick 2.6
++
++Item {
++    visible: true
++    Item {
++        visible: false
++        Item {
++            objectName: "hiddenChild"
++            activeFocusOnTab: true
++            focus: true
++        }
++    }
++}
+diff --git a/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp b/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+index c8f251dbe1..c8ef36ee68 100644
+--- a/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
++++ b/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+@@ -67,6 +67,7 @@ private slots:
+     void activeFocusOnTab10();
+     void activeFocusOnTab_infiniteLoop_data();
+     void activeFocusOnTab_infiniteLoop();
++    void activeFocusOnTab_infiniteLoopControls();
+ 
+     void nextItemInFocusChain();
+     void nextItemInFocusChain2();
+@@ -1057,6 +1058,17 @@ void tst_QQuickItem::activeFocusOnTab_infiniteLoop()
+     QCOMPARE(item, window->rootObject());
+ }
+ 
++
++void tst_QQuickItem::activeFocusOnTab_infiniteLoopControls()
++{
++    auto source = testFileUrl("activeFocusOnTab_infiniteLoop3.qml");
++    QScopedPointer<QQuickView>window(new QQuickView());
++    window->setSource(source);
++    window->show();
++    QVERIFY(window->errors().isEmpty());
++    QTest::keyClick(window.get(), Qt::Key_Tab); // should not hang
++}
++
+ void tst_QQuickItem::nextItemInFocusChain()
+ {
+     if (!qt_tab_all_widgets())
+Submodule qtdoc c0c7bf07...79d6ef69:
+Submodule qtimageformats 2dcf2899..abe44c0f:
+diff --git a/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp b/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
+index dde783c..1bf9074 100644
+--- a/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
+@@ -462,8 +462,12 @@ static bool parseIconEntryInfo(ICNSEntry &icon)
+     if (isIconCompressed(icon))
+         return true;
+     // Icon depth:
+-    if (!depth.isEmpty())
+-        icon.depth = ICNSEntry::Depth(depth.toUInt());
++    if (!depth.isEmpty()) {
++        const uint depthUInt = depth.toUInt();
++        if (depthUInt > 32)
++            return false;
++        icon.depth = ICNSEntry::Depth(depthUInt);
++    }
+     // Try mono if depth not found
+     if (icon.depth == ICNSEntry::DepthUnknown)
+         icon.depth = ICNSEntry::DepthMono;
+@@ -515,6 +519,9 @@ static bool parseIconEntryInfo(ICNSEntry &icon)
+         }
+         icon.height = icon.width;
+     }
++    // Sanity check
++    if (icon.width == 0 || icon.width > 4096)
++        return false;
+     return true;
+ }
+ 
+@@ -685,7 +692,7 @@ bool QICNSHandler::canRead() const
+ bool QICNSHandler::read(QImage *outImage)
+ {
+     QImage img;
+-    if (!ensureScanned()) {
++    if (!ensureScanned() || m_currentIconIndex >= m_icons.size()) {
+         qWarning("QICNSHandler::read(): The device wasn't parsed properly!");
+         return false;
+     }
+@@ -892,7 +899,7 @@ bool QICNSHandler::scanDevice()
+             return false;
+ 
+         const qint64 blockDataOffset = device()->pos();
+-        if (!isBlockHeaderValid(blockHeader)) {
++        if (!isBlockHeaderValid(blockHeader, ICNSBlockHeaderSize + filelength - blockDataOffset)) {
+             qWarning("QICNSHandler::scanDevice(): Failed, bad header at pos %s. OSType \"%s\", length %u",
+                      QByteArray::number(blockDataOffset).constData(),
+                      nameFromOSType(blockHeader.ostype).constData(), blockHeader.length);
+@@ -927,11 +934,14 @@ bool QICNSHandler::scanDevice()
+         case ICNSBlockHeader::TypeOdrp:
+             // Icns container seems to have an embedded icon variant container
+             // Let's start a scan for entries
+-            while (device()->pos() < nextBlockOffset) {
++            while (!stream.atEnd() && device()->pos() < nextBlockOffset) {
+                 ICNSBlockHeader icon;
+                 stream >> icon;
++                if (stream.status() != QDataStream::Ok)
++                    return false;
+                 // Check for incorrect variant entry header and stop scan
+-                if (!isBlockHeaderValid(icon, blockDataLength))
++                quint64 remaining = blockDataLength - (device()->pos() - blockDataOffset);
++                if (!isBlockHeaderValid(icon, ICNSBlockHeaderSize + remaining))
+                     break;
+                 if (!addEntry(icon, device()->pos(), blockHeader.ostype))
+                     return false;
+@@ -1003,7 +1013,7 @@ bool QICNSHandler::scanDevice()
+             break;
+         }
+     }
+-    return true;
++    return (m_icons.size() > 0);
+ }
+ 
+ const ICNSEntry &QICNSHandler::getIconMask(const ICNSEntry &icon) const
+diff --git a/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp b/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
+index 5082023..cb34374 100644
+--- a/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
++++ b/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
+@@ -43,6 +43,7 @@
+ #include "qimage.h"
+ #include "qvariant.h"
+ #include "qcolor.h"
++#include "qimagereader.h"
+ 
+ #include <jasper/jasper.h>
+ #include <math.h> // for pow
+@@ -333,16 +334,46 @@ private:
+ Jpeg2000JasperReader::Jpeg2000JasperReader(QIODevice *iod, SubFormat format)
+     : jasperOk(true), ioDevice(iod), format(format), hasAlpha(false)
+ {
++#if JAS_VERSION_MAJOR < 3
+     if (jas_init()) {
+         jasperOk = false;
+         qDebug("Jasper Library initialization failed");
+     }
++#else
++    jas_conf_clear();
++#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
++    jas_conf_set_max_mem_usage(QImageReader::allocationLimit() * 1024 * 1024);
++#else
++    // 128MB seems to be enough.
++    jas_conf_set_max_mem_usage(128 * 1024 * 1024);
++#endif
++    if (jas_init_library()) {
++        jasperOk = false;
++        qDebug("Jasper library initialization failed");
++    }
++    if (jas_init_thread()) {
++        jas_cleanup_library();
++        jasperOk = false;
++        qDebug("Jasper thread initialization failed");
++    }
++#endif
+ }
+ 
+ Jpeg2000JasperReader::~Jpeg2000JasperReader()
+ {
++#if JAS_VERSION_MAJOR < 3
+     if (jasperOk)
+         jas_cleanup();
++#else
++    if (jasperOk) {
++        if (jas_cleanup_thread()) {
++            qDebug("Jasper thread cleanup failed");
++        }
++        if (jas_cleanup_library()) {
++            qDebug("Jasper library cleanup failed");
++        }
++    }
++#endif
+ }
+ 
+ /*! \internal
+@@ -857,7 +888,7 @@ bool Jpeg2000JasperReader::write(const QImage &image, int quality)
+     }
+ 
+     // Open an empty jasper stream that grows automatically
+-    jas_stream_t * memory_stream = jas_stream_memopen(0, -1);
++    jas_stream_t * memory_stream = jas_stream_memopen(0, 0);
+ 
+     // Jasper wants a non-const string.
+     char *str = qstrdup(jasperFormatString.toLatin1().constData());
+diff --git a/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp b/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
+index 1386750..ac8956c 100644
+--- a/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
+@@ -361,6 +361,8 @@ bool QTiffHandler::read(QImage *image)
+     }
+ 
+     TIFF *const tiff = d->tiff;
++    if (TIFFIsTiled(tiff) && TIFFTileSize64(tiff) > uint64_t(image->sizeInBytes())) // Corrupt image
++        return false;
+     const quint32 width = d->size.width();
+     const quint32 height = d->size.height();
+ 
+diff --git a/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp b/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
+index 82d38cb..d02eb05 100644
+--- a/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
+@@ -45,6 +45,7 @@
+ #include <qdebug.h>
+ #include <qpainter.h>
+ #include <qvariant.h>
++#include <QtEndian>
+ 
+ static const int riffHeaderSize = 12; // RIFF_HEADER_SIZE from webp/format_constants.h
+ 
+@@ -102,21 +103,23 @@ bool QWebpHandler::ensureScanned() const
+ 
+     m_scanState = ScanError;
+ 
+-    if (device()->isSequential()) {
+-        qWarning() << "Sequential devices are not supported";
++    QWebpHandler *that = const_cast<QWebpHandler *>(this);
++    const int headerBytesNeeded = sizeof(WebPBitstreamFeatures);
++    QByteArray header = device()->peek(headerBytesNeeded);
++    if (header.size() < headerBytesNeeded)
+         return false;
+-    }
+ 
+-    qint64 oldPos = device()->pos();
+-    device()->seek(0);
+-
+-    QWebpHandler *that = const_cast<QWebpHandler *>(this);
+-    QByteArray header = device()->peek(sizeof(WebPBitstreamFeatures));
++    // We do no random access during decoding, just a readAll() of the whole image file. So if
++    // if it is all available already, we can accept a sequential device. The riff header contains
++    // the file size minus 8 bytes header
++    qint64 byteSize = qFromLittleEndian<quint32>(header.constData() + 4);
++    if (device()->isSequential() && device()->bytesAvailable() < byteSize + 8) {
++        qWarning() << "QWebpHandler: Insufficient data available in sequential device";
++        return false;
++    }
+     if (WebPGetFeatures((const uint8_t*)header.constData(), header.size(), &(that->m_features)) == VP8_STATUS_OK) {
+         if (m_features.has_animation) {
+             // For animation, we have to read and scan whole file to determine loop count and images count
+-            device()->seek(oldPos);
+-
+             if (that->ensureDemuxer()) {
+                 that->m_loop = WebPDemuxGetI(m_demuxer, WEBP_FF_LOOP_COUNT);
+                 that->m_frameCount = WebPDemuxGetI(m_demuxer, WEBP_FF_FRAME_COUNT);
+@@ -126,17 +129,13 @@ bool QWebpHandler::ensureScanned() const
+                 if (that->m_features.has_alpha)
+                     that->m_composited->fill(Qt::transparent);
+ 
+-                // We do not reset device position since we have read in all data
+                 m_scanState = ScanSuccess;
+-                return true;
+             }
+         } else {
+             m_scanState = ScanSuccess;
+         }
+     }
+ 
+-    device()->seek(oldPos);
+-
+     return m_scanState == ScanSuccess;
+ }
+ 
+@@ -159,7 +158,7 @@ bool QWebpHandler::ensureDemuxer()
+ 
+ bool QWebpHandler::read(QImage *image)
+ {
+-    if (!ensureScanned() || device()->isSequential() || !ensureDemuxer())
++    if (!ensureScanned() || !ensureDemuxer())
+         return false;
+ 
+     QRect prevFrameRect;
+Submodule qtlocation 98a5c511..f991e28c:
+diff --git a/qtlocation/src/location/configure.json b/qtlocation/src/location/configure.json
+index 6d01a9a3..d1e623a1 100644
+--- a/qtlocation/src/location/configure.json
++++ b/qtlocation/src/location/configure.json
+@@ -9,7 +9,7 @@
+             "label": "Qt.labs.location experimental QML plugin",
+             "purpose": "Provides experimental QtLocation QML types",
+             "section": "Location",
+-            "condition": "config.opengl",
++            "condition": "features.opengl",
+             "output": [ "privateFeature" ]
+         },
+         "geoservices_osm": {
+diff --git a/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp b/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
+index a978573d..11e1466f 100644
+--- a/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
++++ b/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
+@@ -158,7 +158,7 @@ void QGeoMapObjectQSGSupport::updateMapObjects(QSGNode *root, QQuickWindow *wind
+     if (!root)
+         return;
+ 
+-    if (m_mapObjectsRootNode && m_mapObjectsRootNode->parent())
++    if (m_mapObjectsRootNode && !m_mapObjectsRootNode->parent())
+         root->appendChildNode(m_mapObjectsRootNode.get());
+ 
+     if (!m_mapObjectsRootNode) {
+diff --git a/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
+index 5a40467e..d123c6a8 100644
+--- a/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
+@@ -59,8 +59,10 @@ QT_BEGIN_NAMESPACE
+ static const QString kPrefixEsri(QStringLiteral("esri."));
+ static const QString kParamUserAgent(kPrefixEsri + QStringLiteral("useragent"));
+ 
+-static const QString kUrlGeocode(QStringLiteral("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates"));
+-static const QString kUrlReverseGeocode(QStringLiteral("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode"));
++static const QString kUrlGeocode(QStringLiteral("https://geocode.arcgis.com/arcgis/rest/services/"
++                                                "World/GeocodeServer/findAddressCandidates"));
++static const QString kUrlReverseGeocode(QStringLiteral(
++        "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode"));
+ 
+ static QString addressToQuery(const QGeoAddress &address)
+ {
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
+index 17492d94..96c12b1b 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
+@@ -46,7 +46,8 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-// JSON reference: http://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
++// JSON reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
+ 
+ static const QString kErrorMessage(QStringLiteral("Error %1: %2."));
+ static const QString kErrorJson(QStringLiteral("Error: invalide JSON document."));
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
+index 8cadfb29..92b6bb13 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
+@@ -44,7 +44,8 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-// JSON reference: http://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
++// JSON reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
+ 
+ GeoRouteReplyEsri::GeoRouteReplyEsri(QNetworkReply *reply, const QGeoRouteRequest &request,
+                                      QObject *parent) :
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
+index 0e6bc2c7..ed613f4b 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
+@@ -48,7 +48,8 @@ static const QString kPrefixEsri(QStringLiteral("esri."));
+ static const QString kParamUserAgent(kPrefixEsri + QStringLiteral("useragent"));
+ static const QString kParamToken(kPrefixEsri + QStringLiteral("token"));
+ 
+-static const QString kUrlRouting(QStringLiteral("http://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve"));
++static const QString kUrlRouting(QStringLiteral(
++        "https://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve"));
+ 
+ GeoRoutingManagerEngineEsri::GeoRoutingManagerEngineEsri(const QVariantMap &parameters,
+                                                          QGeoServiceProvider::Error *error,
+@@ -70,7 +71,8 @@ GeoRoutingManagerEngineEsri::~GeoRoutingManagerEngineEsri()
+ {
+ }
+ 
+-// REST reference: http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
++// REST reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
+ 
+ QGeoRouteReply *GeoRoutingManagerEngineEsri::calculateRoute(const QGeoRouteRequest &request)
+ {
+@@ -125,7 +127,7 @@ void GeoRoutingManagerEngineEsri::replyError(QGeoRouteReply::Error errorCode, co
+ QString GeoRoutingManagerEngineEsri::preferedDirectionLangage()
+ {
+     // list of supported langages is defined in:
+-    // http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
++    // https://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
+     const QStringList supportedLanguages = {
+         "ar", // Generate directions in Arabic
+         "cs", // Generate directions in Czech
+diff --git a/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
+index 5d15835d..24148f95 100644
+--- a/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
+@@ -230,7 +230,8 @@ QGeoMap *GeoTiledMappingManagerEngineEsri::createMap()
+ // ${y} = Y
+ // ${token} = Token
+ 
+-// template = 'http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{{z}}/{{y}}/{{x}}.png'
++// template =
++// 'https://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{{z}}/{{y}}/{{x}}.png'
+ 
+ bool GeoTiledMappingManagerEngineEsri::initializeMapSources(QGeoServiceProvider::Error *error,
+                                                             QString *errorString,
+diff --git a/qtlocation/src/plugins/geoservices/esri/maps.json b/qtlocation/src/plugins/geoservices/esri/maps.json
+index 8167ae7d..862e087d 100644
+--- a/qtlocation/src/plugins/geoservices/esri/maps.json
++++ b/qtlocation/src/plugins/geoservices/esri/maps.json
+@@ -6,8 +6,8 @@
+             "description": "ArcGIS Online World Street Map",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=3b93337983e9436f8db950e38a8629af'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=3b93337983e9436f8db950e38a8629af'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -16,8 +16,8 @@
+             "": "ArcGIS Online World Imagery",
+             "mobile": true,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -26,8 +26,8 @@
+             "description": "ArcGIS Online World Terrain Base",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=c61ad8ab017d49e1a82f580ee1298931'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=c61ad8ab017d49e1a82f580ee1298931'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -36,8 +36,8 @@
+             "description": "ArcGIS Online World Topography",
+             "mobile": true,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=30e5fe3149c34df1ba922e6f5bbf808f'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=30e5fe3149c34df1ba922e6f5bbf808f'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -46,8 +46,8 @@
+             "description": "This map presents land cover and detailed topographic maps for the United States.",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=99cd5fbd98934028802b4f797c4b1732'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=99cd5fbd98934028802b4f797c4b1732'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -56,8 +56,8 @@
+             "description": "National Geographic World Map",
+             "mobile": false,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=b9b1b422198944fbbd5250b3241691b6'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=b9b1b422198944fbbd5250b3241691b6'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -66,8 +66,8 @@
+             "description": "Thematic content providing a neutral background with minimal colors",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=ed712cb1db3e4bae9e85329040fb9a49'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=ed712cb1db3e4bae9e85329040fb9a49'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -76,8 +76,8 @@
+             "description": "Natural Earth physical map for the world",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=c4ec722a1cd34cf0a23904aadf8923a0'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=c4ec722a1cd34cf0a23904aadf8923a0'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -86,8 +86,8 @@
+             "description": "Portrays surface elevation as shaded relief",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=9c5370d0b54f4de1b48a3792d7377ff2'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=9c5370d0b54f4de1b48a3792d7377ff2'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -96,8 +96,8 @@
+             "description": "This map is designed to be used as a basemap by marine GIS professionals and as a reference map by anyone interested in ocean data",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=1e126e7520f9466c9ca28b8f28b5e500'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=1e126e7520f9466c9ca28b8f28b5e500'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -106,8 +106,8 @@
+             "description": "Thematic content providing a neutral background with minimal colors",
+             "mobile": false,
+             "night": true,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=a284a9b99b3446a3910d4144a50990f6'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=a284a9b99b3446a3910d4144a50990f6'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -116,8 +116,8 @@
+             "description": "DeLorme’s topographic basemap is a seamless global data set that portrays transportation, hydrography, jurisdiction boundaries, and major geographic features",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/Specialty/DeLorme_World_Base_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=b165c3df453e4be6b5ac4fdb241effbe'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/Specialty/DeLorme_World_Base_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=b165c3df453e4be6b5ac4fdb241effbe'>Esri</a> contributors"
+         }
+     ]
+ }
+diff --git a/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
+index 3858ddf5..af66f28e 100644
+--- a/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
+@@ -63,8 +63,10 @@ static const QString kCountriesKey(QStringLiteral("detailedCountries"));
+ static const QString kLocalizedNamesKey(QStringLiteral("localizedNames"));
+ static const QString kMaxLocationsKey(QStringLiteral("maxLocations"));
+ 
+-static const QUrl kUrlGeocodeServer("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer?f=pjson");
+-static const QUrl kUrlFindAddressCandidates("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates");
++static const QUrl kUrlGeocodeServer(
++        "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer?f=pjson");
++static const QUrl kUrlFindAddressCandidates("https://geocode.arcgis.com/arcgis/rest/services/World/"
++                                            "GeocodeServer/findAddressCandidates");
+ 
+ PlaceManagerEngineEsri::PlaceManagerEngineEsri(const QVariantMap &parameters, QGeoServiceProvider::Error *error,
+                                                QString *errorString) :
+Submodule qtmultimedia f0344079..0d7cc33a:
+diff --git a/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp b/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
+index 2b5325132..b68b4af1b 100644
+--- a/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
++++ b/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
+@@ -402,6 +402,8 @@ int QPulseAudioInput::bytesReady() const
+ 
+ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ {
++    Q_ASSERT(data != nullptr || len == 0);
++
+     m_bytesAvailable = checkBytesReady();
+ 
+     setError(QAudio::NoError);
+@@ -411,7 +413,8 @@ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ 
+     if (!m_pullMode && !m_tempBuffer.isEmpty()) {
+         readBytes = qMin(static_cast<int>(len), m_tempBuffer.size());
+-        memcpy(data, m_tempBuffer.constData(), readBytes);
++        if (readBytes)
++            memcpy(data, m_tempBuffer.constData(), readBytes);
+         m_totalTimeValue += readBytes;
+ 
+         if (readBytes < m_tempBuffer.size()) {
+@@ -502,9 +505,10 @@ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ 
+ void QPulseAudioInput::applyVolume(const void *src, void *dest, int len)
+ {
++    Q_ASSERT((src && dest) || len == 0);
+     if (m_volume < 1.f)
+         QAudioHelperInternal::qMultiplySamples(m_volume, m_format, src, dest, len);
+-    else
++    else if (len)
+         memcpy(dest, src, len);
+ }
+ 
+Submodule qtpim 02efef5e...f9a8f0fc (commits not present)
+Submodule qtquick3d b85cf622..47defc8b:
+diff --git a/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro b/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
+index ca5c499e..174a075b 100644
+--- a/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
++++ b/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
+@@ -10,7 +10,7 @@ QT_FOR_CONFIG += assetimporters-private
+ include($$OUT_PWD/../qtassetimporters-config.pri)
+ 
+ qtConfig(system-assimp):!if(cross_compile:host_build) {
+-    QMAKE_USE_PRIVATE += assimp
++    QMAKE_USE_PRIVATE += quick3d-assimp
+ } else {
+     include(../../../3rdparty/assimp/assimp.pri)
+ }
+Submodule qtquickcontrols2 3a657dc0..56ce8233:
+diff --git a/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp b/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
+index e5fe734f7..e36922775 100644
+--- a/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
++++ b/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
+@@ -38,6 +38,7 @@
+ #include "qwidgetplatformmenuitem_p.h"
+ 
+ #include <QtGui/qwindow.h>
++#include <QtGui/private/qhighdpiscaling_p.h>
+ #include <QtWidgets/qmenu.h>
+ #include <QtWidgets/qaction.h>
+ 
+@@ -145,7 +146,7 @@ void QWidgetPlatformMenu::showPopup(const QWindow *window, const QRect &targetRe
+ 
+     QPoint targetPos = targetRect.bottomLeft();
+     if (window)
+-        targetPos = window->mapToGlobal(targetPos);
++        targetPos = window->mapToGlobal(QHighDpi::fromNativeLocalPosition(targetPos, window));
+ 
+     const QWidgetPlatformMenuItem *widgetItem = qobject_cast<const QWidgetPlatformMenuItem *>(item);
+     m_menu->popup(targetPos, widgetItem ? widgetItem->action() : nullptr);
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
+index 950e4e099..b81fbea0b 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
+@@ -387,6 +387,17 @@ void QQuickAbstractButtonPrivate::itemImplicitHeightChanged(QQuickItem *item)
+         emit q->implicitIndicatorHeightChanged();
+ }
+ 
++void QQuickAbstractButtonPrivate::itemDestroyed(QQuickItem *item)
++{
++    Q_Q(QQuickAbstractButton);
++    QQuickControlPrivate::itemDestroyed(item);
++    if (item == indicator) {
++        indicator = nullptr;
++        emit q->implicitIndicatorWidthChanged();
++        emit q->implicitIndicatorHeightChanged();
++    }
++}
++
+ QQuickAbstractButton *QQuickAbstractButtonPrivate::findCheckedButton() const
+ {
+     Q_Q(const QQuickAbstractButton);
+@@ -1176,6 +1187,12 @@ QAccessible::Role QQuickAbstractButton::accessibleRole() const
+     }
+     return QAccessible::Button;
+ }
++
++void QQuickAbstractButton::accessiblePressAction()
++{
++    Q_D(QQuickAbstractButton);
++    d->trigger();
++}
+ #endif
+ 
+ QT_END_NAMESPACE
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
+index 0fa48980e..ab66220d0 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
+@@ -209,6 +209,7 @@ protected:
+ #if QT_CONFIG(accessibility)
+     void accessibilityActiveChanged(bool active) override;
+     QAccessible::Role accessibleRole() const override;
++    Q_INVOKABLE void accessiblePressAction();
+ #endif
+ 
+ private:
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
+index 9291c1a87..b729720f2 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
+@@ -109,6 +109,7 @@ public:
+ 
+     void itemImplicitWidthChanged(QQuickItem *item) override;
+     void itemImplicitHeightChanged(QQuickItem *item) override;
++    void itemDestroyed(QQuickItem *item) override;
+ 
+     // copied from qabstractbutton.cpp
+     static const int AUTO_REPEAT_DELAY = 300;
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp b/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
+index 2041e7741..8610cdfae 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
+@@ -145,7 +145,7 @@ int QQuickActionPrivate::ShortcutEntry::shortcutId() const
+ 
+ void QQuickActionPrivate::ShortcutEntry::grab(const QKeySequence &shortcut, bool enabled)
+ {
+-    if (shortcut.isEmpty())
++    if (shortcut.isEmpty() || m_shortcutId)
+         return;
+ 
+     Qt::ShortcutContext context = Qt::WindowShortcut; // TODO
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp b/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
+index f38c2b09c..6eed2a024 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
+@@ -225,6 +225,7 @@ void QQuickContainerPrivate::cleanup()
+     QObject::disconnect(contentModel, &QQmlObjectModel::countChanged, q, &QQuickContainer::countChanged);
+     QObject::disconnect(contentModel, &QQmlObjectModel::childrenChanged, q, &QQuickContainer::contentChildrenChanged);
+     delete contentModel;
++    contentModel = nullptr;
+ }
+ 
+ QQuickItem *QQuickContainerPrivate::itemAt(int index) const
+@@ -436,7 +437,7 @@ void QQuickContainerPrivate::contentChildren_clear(QQmlListProperty<QQuickItem>
+ void QQuickContainerPrivate::updateContentWidth()
+ {
+     Q_Q(QQuickContainer);
+-    if (hasContentWidth || qFuzzyCompare(contentWidth, implicitContentWidth))
++    if (hasContentWidth || qFuzzyCompare(contentWidth, implicitContentWidth) || !contentModel)
+         return;
+ 
+     contentWidth = implicitContentWidth;
+@@ -446,7 +447,7 @@ void QQuickContainerPrivate::updateContentWidth()
+ void QQuickContainerPrivate::updateContentHeight()
+ {
+     Q_Q(QQuickContainer);
+-    if (hasContentHeight || qFuzzyCompare(contentHeight, implicitContentHeight))
++    if (hasContentHeight || qFuzzyCompare(contentHeight, implicitContentHeight) || !contentModel)
+         return;
+ 
+     contentHeight = implicitContentHeight;
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp b/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
+index bbbd0e622..1f4b47343 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
+@@ -845,6 +845,13 @@ void QQuickControlPrivate::executeBackground(bool complete)
+         quickCompleteDeferred(q, backgroundName(), background);
+ }
+ 
++/*
++    \internal
++
++    Hides an item that was replaced by a newer one, rather than
++    deleting it, as the item is typically created in QML and hence
++    we don't own it.
++*/
+ void QQuickControlPrivate::hideOldItem(QQuickItem *item)
+ {
+     if (!item)
+@@ -863,6 +870,29 @@ void QQuickControlPrivate::hideOldItem(QQuickItem *item)
+ #endif
+ }
+ 
++/*
++    \internal
++
++    Named "unhide" because it's used for cases where an item
++    that was previously hidden by \l hideOldItem() wants to be
++    shown by a control again, such as a ScrollBar in ScrollView.
++*/
++void QQuickControlPrivate::unhideOldItem(QQuickControl *control, QQuickItem *item)
++{
++    Q_ASSERT(item);
++    qCDebug(lcItemManagement) << "unhiding old item" << item;
++
++    item->setVisible(true);
++    item->setParentItem(control);
++
++#if QT_CONFIG(accessibility)
++    // Add the item back in to the accessibility tree.
++    QQuickAccessibleAttached *accessible = accessibleAttached(item);
++    if (accessible)
++        accessible->setIgnored(false);
++#endif
++}
++
+ void QQuickControlPrivate::updateBaselineOffset()
+ {
+     Q_Q(QQuickControl);
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h b/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
+index 8e979079e..a6e624c91 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
+@@ -173,6 +173,7 @@ public:
+     virtual void executeBackground(bool complete = false);
+ 
+     static void hideOldItem(QQuickItem *item);
++    static void unhideOldItem(QQuickControl *control, QQuickItem *item);
+ 
+     void updateBaselineOffset();
+ 
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp b/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
+index e6db14eb5..6197d1547 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
+@@ -237,7 +237,7 @@ static QRectF alignedRect(Qt::LayoutDirection direction, Qt::Alignment alignment
+ void QQuickDialogButtonBoxPrivate::resizeContent()
+ {
+     Q_Q(QQuickDialogButtonBox);
+-    if (!contentItem)
++    if (!contentItem || !contentModel)
+         return;
+ 
+     QRectF geometry = q->boundingRect().adjusted(q->leftPadding(), q->topPadding(), -q->rightPadding(), -q->bottomPadding());
+@@ -322,6 +322,9 @@ void QQuickDialogButtonBoxPrivate::updateLayout()
+ qreal QQuickDialogButtonBoxPrivate::getContentWidth() const
+ {
+     Q_Q(const QQuickDialogButtonBox);
++    if (!contentModel)
++        return 0;
++
+     const int count = contentModel->count();
+     const qreal totalSpacing = qMax(0, count - 1) * spacing;
+     qreal totalWidth = totalSpacing;
+@@ -341,6 +344,9 @@ qreal QQuickDialogButtonBoxPrivate::getContentWidth() const
+ qreal QQuickDialogButtonBoxPrivate::getContentHeight() const
+ {
+     Q_Q(const QQuickDialogButtonBox);
++    if (!contentModel)
++        return 0;
++
+     const int count = contentModel->count();
+     qreal maxHeight = 0;
+     for (int i = 0; i < count; ++i) {
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp b/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
+index 91bd59184..0ce518f84 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
+@@ -399,8 +399,11 @@ void QQuickOverlay::itemChange(ItemChange change, const ItemChangeData &data)
+     Q_D(QQuickOverlay);
+     QQuickItem::itemChange(change, data);
+ 
+-    if (change == ItemChildAddedChange || change == ItemChildRemovedChange)
++    if (change == ItemChildAddedChange || change == ItemChildRemovedChange) {
+         setVisible(!d->allDrawers.isEmpty() || !childItems().isEmpty());
++        if (data.item->parent() == d->mouseGrabberPopup)
++            d->setMouseGrabberPopup(nullptr);
++    }
+ }
+ 
+ void QQuickOverlay::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp b/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
+index 4e2f509db..1c4b308cd 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
+@@ -797,6 +797,14 @@ void QQuickScrollBarAttachedPrivate::initHorizontal()
+     if (parent && parent == flickable->parentItem())
+         horizontal->stackAfter(flickable);
+ 
++    // If a scroll bar was previously hidden (due to e.g. setting a new contentItem
++    // on a ScrollView), we need to make sure that we un-hide it.
++    // We don't bother checking if the item is actually the old one, because
++    // if it's not, all of the things the function does (setting parent, visibility, etc.)
++    // should be no-ops anyway.
++    if (auto control = qobject_cast<QQuickControl*>(q_ptr->parent()))
++        QQuickControlPrivate::unhideOldItem(control, horizontal);
++
+     layoutHorizontal();
+     horizontal->setSize(area->property("widthRatio").toReal());
+     horizontal->setPosition(area->property("xPosition").toReal());
+@@ -818,6 +826,9 @@ void QQuickScrollBarAttachedPrivate::initVertical()
+     if (parent && parent == flickable->parentItem())
+         vertical->stackAfter(flickable);
+ 
++    if (auto control = qobject_cast<QQuickControl*>(q_ptr->parent()))
++        QQuickControlPrivate::unhideOldItem(control, vertical);
++
+     layoutVertical();
+     vertical->setSize(area->property("heightRatio").toReal());
+     vertical->setPosition(area->property("yPosition").toReal());
+diff --git a/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml b/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
+index 0e8b08352..cd4931184 100644
+--- a/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
++++ b/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
+@@ -576,4 +576,51 @@ TestCase {
+         verify(newHorizontalScrollBar.visible)
+         verify(!oldHorizontalScrollBar.visible)
+     }
++
++    Component {
++        id: bindingToContentItemAndStandaloneFlickable
++
++        Item {
++            width: 200
++            height: 200
++
++            property alias scrollView: scrollView
++
++            ScrollView {
++                id: scrollView
++                anchors.fill: parent
++                contentItem: listView
++
++                property Item someBinding: contentItem
++            }
++            ListView {
++                id: listView
++                model: 10
++                delegate: ItemDelegate {
++                    text: modelData
++                    width: listView.width
++                }
++            }
++        }
++    }
++
++    // Tests that scroll bars show up for a ScrollView where
++    // - its contentItem is declared as a standalone, separate item
++    // - there is a binding to contentItem (which causes a default Flickable to be created)
++    function test_bindingToContentItemAndStandaloneFlickable() {
++        let root = createTemporaryObject(bindingToContentItemAndStandaloneFlickable, testCase)
++        verify(root)
++
++        let control = root.scrollView
++        let verticalScrollBar = control.ScrollBar.vertical
++        let horizontalScrollBar = control.ScrollBar.horizontal
++        compare(verticalScrollBar.parent, control)
++        compare(horizontalScrollBar.parent, control)
++        verify(verticalScrollBar.visible)
++        verify(horizontalScrollBar.visible)
++
++        mouseDrag(verticalScrollBar, verticalScrollBar.width / 2, verticalScrollBar.height / 2, 0, 50)
++        verify(verticalScrollBar.active)
++        verify(horizontalScrollBar.active)
++    }
+ }
+diff --git a/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml b/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
+index b3fab41ca..10b6baa02 100644
+--- a/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
++++ b/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
+@@ -608,4 +608,27 @@ TestCase {
+         mouseClick(control.indicator)
+         verify(control.activeFocus)
+     }
++
++    Component {
++        id: deletionOrder1
++        Item {
++            Image { id: innerImage }
++            Switch { indicator: innerImage }
++        }
++    }
++
++    Component {
++        id: deletionOrder2
++        Item {
++            Switch { indicator: innerImage }
++            Image { id: innerImage }
++        }
++    }
++
++    function test_deletionOrder() {
++        var control1 = createTemporaryObject(deletionOrder1, testCase)
++        verify(control1)
++        var control2 = createTemporaryObject(deletionOrder2, testCase)
++        verify(control2)
++    }
+ }
+diff --git a/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml b/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml
+new file mode 100644
+index 000000000..9e4598b9f
+--- /dev/null
++++ b/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml
+@@ -0,0 +1,78 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the test suite of the Qt Toolkit.
++**
++** $QT_BEGIN_LICENSE:BSD$
++** Commercial License Usage
++** Licensees holding valid commercial Qt licenses may use this file in
++** accordance with the commercial license agreement provided with the
++** Software or, alternatively, in accordance with the terms contained in
++** a written agreement between you and The Qt Company. For licensing terms
++** and conditions see https://www.qt.io/terms-conditions. For further
++** information use the contact form at https://www.qt.io/contact-us.
++**
++** BSD License Usage
++** Alternatively, you may use this file under the terms of the BSD license
++** as follows:
++**
++** "Redistribution and use in source and binary forms, with or without
++** modification, are permitted provided that the following conditions are
++** met:
++**   * Redistributions of source code must retain the above copyright
++**     notice, this list of conditions and the following disclaimer.
++**   * Redistributions in binary form must reproduce the above copyright
++**     notice, this list of conditions and the following disclaimer in
++**     the documentation and/or other materials provided with the
++**     distribution.
++**   * Neither the name of The Qt Company Ltd nor the names of its
++**     contributors may be used to endorse or promote products derived
++**     from this software without specific prior written permission.
++**
++**
++** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
++** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
++** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
++** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
++** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
++** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
++** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
++** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
++** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
++** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
++** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
++**
++** $QT_END_LICENSE$
++**
++****************************************************************************/
++
++import QtQuick 2.15
++import QtQuick.Controls 2.15
++
++ApplicationWindow {
++    id: window
++    width: 400
++    height: 400
++    title: "releaseAfterExitTransition"
++
++    property alias popup: popup
++    property alias modalPopup: modalPopup
++
++    Popup {
++        id: popup
++        y: parent.height - height
++        width: 50
++        height: 50
++    }
++
++    Popup {
++        id: modalPopup
++        modal: true
++        y: parent.height - height
++        width: 50
++        height: 50
++        exit:  Transition { PauseAnimation { duration: 100 } }
++    }
++}
+diff --git a/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp b/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
+index 54952d128..3d50e2dd4 100644
+--- a/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
++++ b/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
+@@ -100,6 +100,7 @@ private slots:
+     void invisibleToolTipOpen();
+     void centerInOverlayWithinStackViewItem();
+     void destroyDuringExitTransition();
++    void releaseAfterExitTransition();
+ };
+ 
+ void tst_QQuickPopup::initTestCase()
+@@ -1575,6 +1576,34 @@ void tst_QQuickPopup::destroyDuringExitTransition()
+     QVERIFY(!button->isDown());
+ }
+ 
++void tst_QQuickPopup::releaseAfterExitTransition()
++{
++    QQuickApplicationHelper helper(this, "releaseAfterExitTransition.qml");
++    QVERIFY2(helper.ready, helper.failureMessage());
++
++    QQuickWindow *window = helper.window;
++    window->show();
++    QVERIFY(QTest::qWaitForWindowActive(window));
++
++    QQuickOverlay *overlay = QQuickOverlay::overlay(window);
++    QQuickPopup *modalPopup = window->property("modalPopup").value<QQuickPopup *>();
++    QQuickPopup *popup = window->property("popup").value<QQuickPopup *>();
++
++    modalPopup->open();
++    QTRY_VERIFY(modalPopup->isOpened());
++
++    QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++    // wait until the transition is finished and the overlay hides itself
++    QTRY_VERIFY(!overlay->isVisible());
++    QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++
++    popup->open();
++    QTRY_VERIFY(popup->isOpened());
++    QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++    QTRY_VERIFY(!popup->isOpened());
++}
++
++
+ QTEST_QUICKCONTROLS_MAIN(tst_QQuickPopup)
+ 
+ #include "tst_qquickpopup.moc"
+Submodule qtscript 5be95f96...4d8e4bd2 (commits not present)
+Submodule qtspeech 17fc9fde..255845e2:
+diff --git a/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp b/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
+index 6eb74b8..bcc7dd1 100644
+--- a/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
++++ b/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
+@@ -357,7 +357,9 @@ QVector<QLocale> QTextToSpeechEngineSpeechd::availableLocales() const
+ 
+ QVector<QVoice> QTextToSpeechEngineSpeechd::availableVoices() const
+ {
+-    return m_voices.values(m_currentLocale.name()).toVector();
++    QList<QVoice> resultList = m_voices.values(m_currentLocale.name());
++    std::reverse(resultList.begin(), resultList.end());
++    return resultList.toVector();
+ }
+ 
+ // We have no way of knowing our own client_id since speech-dispatcher seems to be incomplete
+Submodule qtsvg 0c05780e..a7a0f249:
+diff --git a/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp b/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
+index 561e77e..12e0574 100644
+--- a/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
++++ b/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
+@@ -191,6 +191,8 @@ bool QSvgIOHandler::read(QImage *image)
+             }
+         }
+         if (!finalSize.isEmpty()) {
++            if (qMax(finalSize.width(), finalSize.height()) > 0xffff)
++                return false; // Assume corrupted file
+             image->fill(d->backColor.rgba());
+             QPainter p(image);
+             d->r.render(&p, bounds);
+diff --git a/qtsvg/src/svg/qsvghandler.cpp b/qtsvg/src/svg/qsvghandler.cpp
+index a5f877f..8dda563 100644
+--- a/qtsvg/src/svg/qsvghandler.cpp
++++ b/qtsvg/src/svg/qsvghandler.cpp
+@@ -1393,9 +1393,10 @@ static void parseFont(QSvgNode *node,
+         case FontSizeNone:
+             break;
+         case FontSizeValue: {
+-            QSvgHandler::LengthType dummy; // should always be pixel size
+-            fontStyle->setSize(qMin(parseLength(attributes.fontSize, dummy, handler),
+-                                    qreal(0xffff)));
++            QSvgHandler::LengthType type;
++            qreal fs = parseLength(attributes.fontSize, type, handler);
++            fs = convertToPixels(fs, true, type);
++            fontStyle->setSize(qMin(fs, qreal(0xffff)));
+         }
+             break;
+         default:
+@@ -2513,6 +2514,8 @@ static bool parseAnimateTransformNode(QSvgNode *parent,
+             ++s;
+         }
+     }
++    if (vals.count() % 3 != 0)
++        return false;
+ 
+     bool ok = true;
+     int begin = parseClockValue(beginStr, &ok);
+@@ -2576,6 +2579,8 @@ static QSvgNode *createCircleNode(QSvgNode *parent,
+     qreal ncx = toDouble(cx);
+     qreal ncy = toDouble(cy);
+     qreal nr  = toDouble(r);
++    if (nr < 0.0)
++        return nullptr;
+ 
+     QRectF rect(ncx-nr, ncy-nr, nr*2, nr*2);
+     QSvgNode *circle = new QSvgCircle(parent, rect);
+@@ -3046,15 +3051,16 @@ static QSvgStyleProperty *createRadialGradientNode(QSvgNode *node,
+ 
+     qreal ncx = 0.5;
+     qreal ncy = 0.5;
+-    qreal nr  = 0.5;
+     if (!cx.isEmpty())
+         ncx = toDouble(cx);
+     if (!cy.isEmpty())
+         ncy = toDouble(cy);
++
++    qreal nr = 0.0;
+     if (!r.isEmpty())
+         nr = toDouble(r);
+-    if (nr < 0.5)
+-        nr = 0.5;
++    if (nr <= 0.0)
++        return nullptr;
+ 
+     qreal nfx = ncx;
+     if (!fx.isEmpty())
+@@ -3350,7 +3356,9 @@ static QSvgNode *createTextNode(QSvgNode *parent,
+     //### editable and rotate not handled
+     QSvgHandler::LengthType type;
+     qreal nx = parseLength(x, type, handler);
++    nx = convertToPixels(nx, true, type);
+     qreal ny = parseLength(y, type, handler);
++    ny = convertToPixels(ny, true, type);
+ 
+     QSvgNode *text = new QSvgText(parent, QPointF(nx, ny));
+     return text;
+@@ -3691,9 +3699,7 @@ void QSvgHandler::parse()
+         case QXmlStreamReader::EndElement:
+             endElement(xml->name());
+             ++remainingUnfinishedElements;
+-            // if we are using somebody else's qxmlstreamreader
+-            // we should not read until the end of the stream
+-            done = !m_ownsReader && (xml->name() == QLatin1String("svg"));
++            done = (xml->name() == QLatin1String("svg"));
+             break;
+         case QXmlStreamReader::Characters:
+             characters(xml->text());
+diff --git a/qtsvg/src/svg/qsvgstructure.cpp b/qtsvg/src/svg/qsvgstructure.cpp
+index b89608b..89c9e4e 100644
+--- a/qtsvg/src/svg/qsvgstructure.cpp
++++ b/qtsvg/src/svg/qsvgstructure.cpp
+@@ -255,9 +255,13 @@ inline static bool isSupportedSvgFeature(const QString &str)
+     };
+ 
+     if (str.length() <= MAX_WORD_LENGTH && str.length() >= MIN_WORD_LENGTH) {
++        const char16_t unicode44 = str.at(44).unicode();
++        const char16_t unicode45 = str.at(45).unicode();
++        if (unicode44 >= sizeof(asso_values) || unicode45 >= sizeof(asso_values))
++            return false;
+         const int key = str.length()
+-                        + asso_values[str.at(45).unicode()]
+-                        + asso_values[str.at(44).unicode()];
++                        + asso_values[unicode45]
++                        + asso_values[unicode44];
+         if (key <= MAX_HASH_VALUE && key >= 0)
+             return str == QLatin1String(wordlist[key]);
+     }
+diff --git a/qtsvg/src/svg/qsvgtinydocument.cpp b/qtsvg/src/svg/qsvgtinydocument.cpp
+index 63d0797..19e7154 100644
+--- a/qtsvg/src/svg/qsvgtinydocument.cpp
++++ b/qtsvg/src/svg/qsvgtinydocument.cpp
+@@ -433,8 +433,16 @@ void QSvgTinyDocument::draw(QPainter *p, QSvgExtraStates &)
+     draw(p);
+ }
+ 
++static bool isValidMatrix(const QTransform &transform)
++{
++    qreal determinant = transform.determinant();
++    return qIsFinite(determinant);
++}
++
+ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect, const QRectF &sourceRect)
+ {
++    QTransform oldTransform = p->worldTransform();
++
+     QRectF target = targetRect;
+     if (target.isEmpty()) {
+         QPaintDevice *dev = p->device();
+@@ -487,6 +495,9 @@ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect,
+         }
+ #endif
+     }
++
++    if (!isValidMatrix(p->worldTransform()))
++        p->setWorldTransform(oldTransform);
+ }
+ 
+ QRectF QSvgTinyDocument::boundsOnElement(const QString &id) const
+diff --git a/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp b/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
+index 36c76ec..db71e02 100644
+--- a/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
++++ b/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
+@@ -86,6 +86,8 @@ private slots:
+     void oss_fuzz_23731();
+     void oss_fuzz_24131();
+     void oss_fuzz_24738();
++    void illegalAnimateTransform_data();
++    void illegalAnimateTransform();
+ 
+ #ifndef QT_NO_COMPRESS
+     void testGzLoading();
+@@ -1646,5 +1648,22 @@ void tst_QSvgRenderer::oss_fuzz_24738()
+     QSvgRenderer().load(QByteArray("<svg><path d=\"a 2 1e-212.....\">"));
+ }
+ 
++void tst_QSvgRenderer::illegalAnimateTransform_data()
++{
++    QTest::addColumn<QByteArray>("svg");
++
++    QTest::newRow("case1") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" values=\"8,0,5,0\">");
++    QTest::newRow("case2") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" values=\"1,2\">");
++    QTest::newRow("case3") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" from=\".. 5 2\" to=\"f\">");
++    QTest::newRow("case4") << QByteArray("<svg><animateTransform type=\"scale\" begin=\"1\" dur=\"2\" by=\"--,..\">");
++}
++
++void tst_QSvgRenderer::illegalAnimateTransform()
++{
++    QFETCH(QByteArray, svg);
++    QSvgRenderer renderer;
++    QVERIFY(!renderer.load(svg)); // also shouldn't assert
++}
++
+ QTEST_MAIN(tst_QSvgRenderer)
+ #include "tst_qsvgrenderer.moc"
+Submodule qttools 6914f7c8..090e526e:
+diff --git a/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp b/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
+index feab1e2d5..cbfb82507 100644
+--- a/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
++++ b/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
+@@ -445,7 +445,9 @@ bool HelpGeneratorPrivate::insertFiles(const QStringList &files, const QString &
+     if (filterSetId < 0)
+         return false;
+     ++filterSetId;
+-    for (int attId : qAsConst(filterAtts)) {
++    QList<int> attValues = filterAtts.values();
++    std::sort(attValues.begin(), attValues.end());
++    for (int attId : qAsConst(attValues)) {
+         m_query->prepare(QLatin1String("INSERT INTO FileAttributeSetTable "
+             "VALUES(?, ?)"));
+         m_query->bindValue(0, filterSetId);
+Submodule qtwayland dfb0129c..2904e1b3:
+diff --git a/qtwayland/src/client/configure.json b/qtwayland/src/client/configure.json
+index 2f424580..29222357 100644
+--- a/qtwayland/src/client/configure.json
++++ b/qtwayland/src/client/configure.json
+@@ -149,8 +149,7 @@
+                     "#endif"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "vulkan-server-buffer": {
+             "label": "Vulkan Buffer Sharing",
+@@ -168,7 +167,8 @@
+                     "exportAllocInfo.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR;",
+                     "return 0;"
+                 ]
+-            }
++            },
++            "use": "wayland-client"
+         },
+         "egl_1_5-wayland": {
+             "label": "EGL 1.5 with Wayland Platform",
+@@ -183,7 +183,7 @@
+                     "eglGetPlatformDisplay(EGL_PLATFORM_WAYLAND_EXT, (struct wl_display *)(nullptr), nullptr);"
+                 ]
+             },
+-            "use": "egl"
++            "use": "egl wayland-client"
+         }
+     },
+ 
+diff --git a/qtwayland/src/client/global/qwaylandclientextension.cpp b/qtwayland/src/client/global/qwaylandclientextension.cpp
+index 125b1e19..edccfe63 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension.cpp
++++ b/qtwayland/src/client/global/qwaylandclientextension.cpp
+@@ -74,7 +74,10 @@ void QWaylandClientExtensionPrivate::handleRegistryGlobal(void *data, ::wl_regis
+ void QWaylandClientExtension::addRegistryListener()
+ {
+     Q_D(QWaylandClientExtension);
+-    d->waylandIntegration->display()->addRegistryListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++    if (!d->registered) {
++        d->waylandIntegration->display()->addRegistryListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++        d->registered = true;
++    }
+ }
+ 
+ QWaylandClientExtension::QWaylandClientExtension(const int ver)
+@@ -88,6 +91,13 @@ QWaylandClientExtension::QWaylandClientExtension(const int ver)
+     QMetaObject::invokeMethod(this, "addRegistryListener", Qt::QueuedConnection);
+ }
+ 
++QWaylandClientExtension::~QWaylandClientExtension()
++{
++    Q_D(QWaylandClientExtension);
++    if (d->registered && !QCoreApplication::closingDown())
++        d->waylandIntegration->display()->removeListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++}
++
+ QtWaylandClient::QWaylandIntegration *QWaylandClientExtension::integration() const
+ {
+     Q_D(const QWaylandClientExtension);
+diff --git a/qtwayland/src/client/global/qwaylandclientextension.h b/qtwayland/src/client/global/qwaylandclientextension.h
+index 98272e57..5bd28398 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension.h
++++ b/qtwayland/src/client/global/qwaylandclientextension.h
+@@ -63,6 +63,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandClientExtension : public QObject
+     Q_PROPERTY(bool active READ isActive NOTIFY activeChanged)
+ public:
+     QWaylandClientExtension(const int version);
++    ~QWaylandClientExtension();
+ 
+     QtWaylandClient::QWaylandIntegration *integration() const;
+     int version() const;
+diff --git a/qtwayland/src/client/global/qwaylandclientextension_p.h b/qtwayland/src/client/global/qwaylandclientextension_p.h
+index 69cc46a0..9091efbe 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension_p.h
++++ b/qtwayland/src/client/global/qwaylandclientextension_p.h
+@@ -68,6 +68,7 @@ public:
+     QtWaylandClient::QWaylandIntegration *waylandIntegration = nullptr;
+     int version = -1;
+     bool active = false;
++    bool registered = false;
+ };
+ 
+ class Q_WAYLAND_CLIENT_EXPORT QWaylandClientExtensionTemplatePrivate : public QWaylandClientExtensionPrivate
+diff --git a/qtwayland/src/client/qwaylanddatadevice.cpp b/qtwayland/src/client/qwaylanddatadevice.cpp
+index 7e2e3308..e3e60ed5 100644
+--- a/qtwayland/src/client/qwaylanddatadevice.cpp
++++ b/qtwayland/src/client/qwaylanddatadevice.cpp
+@@ -72,6 +72,8 @@ QWaylandDataDevice::QWaylandDataDevice(QWaylandDataDeviceManager *manager, QWayl
+ 
+ QWaylandDataDevice::~QWaylandDataDevice()
+ {
++    if (wl_data_device_get_version(object()) >= WL_DATA_DEVICE_RELEASE_SINCE_VERSION)
++        release();
+ }
+ 
+ QWaylandDataOffer *QWaylandDataDevice::selectionOffer() const
+@@ -110,7 +112,7 @@ QWaylandDataOffer *QWaylandDataDevice::dragOffer() const
+     return m_dragOffer.data();
+ }
+ 
+-bool QWaylandDataDevice::startDrag(QMimeData *mimeData, QWaylandWindow *icon)
++bool QWaylandDataDevice::startDrag(QMimeData *mimeData, Qt::DropActions supportedActions, QWaylandWindow *icon)
+ {
+     auto *seat = m_display->currentInputDevice();
+     auto *origin = seat->pointerFocus();
+@@ -123,7 +125,28 @@ bool QWaylandDataDevice::startDrag(QMimeData *mimeData, QWaylandWindow *icon)
+     }
+ 
+     m_dragSource.reset(new QWaylandDataSource(m_display->dndSelectionHandler(), mimeData));
++
++    if (wl_data_device_get_version(object()) >= 3)
++        m_dragSource->set_actions(dropActionsToWl(supportedActions));
++
+     connect(m_dragSource.data(), &QWaylandDataSource::cancelled, this, &QWaylandDataDevice::dragSourceCancelled);
++    connect(m_dragSource.data(), &QWaylandDataSource::dndResponseUpdated, this, [this](bool accepted, Qt::DropAction action) {
++            auto drag = static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag());
++            // in old versions drop action is not set, so we guess
++            if (wl_data_source_get_version(m_dragSource->object()) < 3) {
++                drag->setResponse(accepted);
++            } else {
++                QPlatformDropQtResponse response(accepted, action);
++                drag->setResponse(response);
++            }
++    });
++    connect(m_dragSource.data(), &QWaylandDataSource::dndDropped, this, [](bool accepted, Qt::DropAction action) {
++        QPlatformDropQtResponse response(accepted, action);
++        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setDropResponse(response);
++    });
++    connect(m_dragSource.data(), &QWaylandDataSource::finished, this, []() {
++        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag();
++    });
+ 
+     start_drag(m_dragSource->object(), origin->wlSurface(), icon->wlSurface(), m_display->currentInputDevice()->serial());
+     return true;
+@@ -152,7 +175,7 @@ void QWaylandDataDevice::data_device_drop()
+         supportedActions = drag->supportedActions();
+     } else if (m_dragOffer) {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     } else {
+         return;
+     }
+@@ -162,7 +185,11 @@ void QWaylandDataDevice::data_device_drop()
+                                                                           QGuiApplication::keyboardModifiers());
+ 
+     if (drag) {
+-        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag(response);
++        auto drag =  static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag());
++        drag->setDropResponse(response);
++        drag->finishDrag();
++    } else if (m_dragOffer) {
++        m_dragOffer->finish();
+     }
+ }
+ 
+@@ -186,7 +213,7 @@ void QWaylandDataDevice::data_device_enter(uint32_t serial, wl_surface *surface,
+         supportedActions = drag->supportedActions();
+     } else if (m_dragOffer) {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     }
+ 
+     const QPlatformDragQtResponse &response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
+@@ -197,11 +224,7 @@ void QWaylandDataDevice::data_device_enter(uint32_t serial, wl_surface *surface,
+         static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setResponse(response);
+     }
+ 
+-    if (response.isAccepted()) {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, m_dragOffer->firstFormat().toUtf8().constData());
+-    } else {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, nullptr);
+-    }
++    sendResponse(supportedActions, response);
+ }
+ 
+ void QWaylandDataDevice::data_device_leave()
+@@ -235,10 +258,10 @@ void QWaylandDataDevice::data_device_motion(uint32_t time, wl_fixed_t x, wl_fixe
+         supportedActions = drag->supportedActions();
+     } else {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     }
+ 
+-    QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
++    const QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
+                                                                           QGuiApplication::mouseButtons(),
+                                                                           QGuiApplication::keyboardModifiers());
+ 
+@@ -246,11 +269,7 @@ void QWaylandDataDevice::data_device_motion(uint32_t time, wl_fixed_t x, wl_fixe
+         static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setResponse(response);
+     }
+ 
+-    if (response.isAccepted()) {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, m_dragOffer->firstFormat().toUtf8().constData());
+-    } else {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, nullptr);
+-    }
++    sendResponse(supportedActions, response);
+ }
+ #endif // QT_CONFIG(draganddrop)
+ 
+@@ -277,14 +296,10 @@ void QWaylandDataDevice::selectionSourceCancelled()
+ #if QT_CONFIG(draganddrop)
+ void QWaylandDataDevice::dragSourceCancelled()
+ {
++    static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag();
+     m_dragSource.reset();
+ }
+ 
+-void QWaylandDataDevice::dragSourceTargetChanged(const QString &mimeType)
+-{
+-    static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->updateTarget(mimeType);
+-}
+-
+ QPoint QWaylandDataDevice::calculateDragPosition(int x, int y, QWindow *wnd) const
+ {
+     QPoint pnt(wl_fixed_to_int(x), wl_fixed_to_int(y));
+@@ -297,6 +312,33 @@ QPoint QWaylandDataDevice::calculateDragPosition(int x, int y, QWindow *wnd) con
+     }
+     return pnt;
+ }
++
++void QWaylandDataDevice::sendResponse(Qt::DropActions supportedActions, const QPlatformDragQtResponse &response)
++{
++    if (response.isAccepted()) {
++        if (wl_data_device_get_version(object()) >= 3)
++            m_dragOffer->set_actions(dropActionsToWl(supportedActions), dropActionsToWl(response.acceptedAction()));
++
++        m_dragOffer->accept(m_enterSerial, m_dragOffer->firstFormat());
++    } else {
++        m_dragOffer->accept(m_enterSerial, QString());
++    }
++}
++
++int QWaylandDataDevice::dropActionsToWl(Qt::DropActions actions)
++{
++
++    int wlActions = WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE;
++    if (actions & Qt::CopyAction)
++        wlActions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY;
++    if (actions & (Qt::MoveAction | Qt::TargetMoveAction))
++        wlActions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE;
++
++    // wayland does not support LinkAction at the time of writing
++    return wlActions;
++}
++
++
+ #endif // QT_CONFIG(draganddrop)
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddatadevice_p.h b/qtwayland/src/client/qwaylanddatadevice_p.h
+index 16c3ad28..801dcc2c 100644
+--- a/qtwayland/src/client/qwaylanddatadevice_p.h
++++ b/qtwayland/src/client/qwaylanddatadevice_p.h
+@@ -64,6 +64,7 @@ QT_REQUIRE_CONFIG(wayland_datadevice);
+ QT_BEGIN_NAMESPACE
+ 
+ class QMimeData;
++class QPlatformDragQtResponse;
+ class QWindow;
+ 
+ namespace QtWaylandClient {
+@@ -89,7 +90,7 @@ public:
+ 
+ #if QT_CONFIG(draganddrop)
+     QWaylandDataOffer *dragOffer() const;
+-    bool startDrag(QMimeData *mimeData, QWaylandWindow *icon);
++    bool startDrag(QMimeData *mimeData, Qt::DropActions supportedActions, QWaylandWindow *icon);
+     void cancelDrag();
+ #endif
+ 
+@@ -109,13 +110,16 @@ private Q_SLOTS:
+ 
+ #if QT_CONFIG(draganddrop)
+     void dragSourceCancelled();
+-    void dragSourceTargetChanged(const QString &mimeType);
+ #endif
+ 
+ private:
+ #if QT_CONFIG(draganddrop)
+     QPoint calculateDragPosition(int x, int y, QWindow *wnd) const;
+ #endif
++    void sendResponse(Qt::DropActions supportedActions, const QPlatformDragQtResponse &response);
++
++    static int dropActionsToWl(Qt::DropActions dropActions);
++
+ 
+     QWaylandDisplay *m_display = nullptr;
+     QWaylandInputDevice *m_inputDevice = nullptr;
+diff --git a/qtwayland/src/client/qwaylanddatadevicemanager.cpp b/qtwayland/src/client/qwaylanddatadevicemanager.cpp
+index 35d67307..6dc4f77f 100644
+--- a/qtwayland/src/client/qwaylanddatadevicemanager.cpp
++++ b/qtwayland/src/client/qwaylanddatadevicemanager.cpp
+@@ -50,8 +50,8 @@ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
+-QWaylandDataDeviceManager::QWaylandDataDeviceManager(QWaylandDisplay *display, uint32_t id)
+-    : wl_data_device_manager(display->wl_registry(), id, 1)
++QWaylandDataDeviceManager::QWaylandDataDeviceManager(QWaylandDisplay *display, int version, uint32_t id)
++    : wl_data_device_manager(display->wl_registry(), id, qMin(version, 3))
+     , m_display(display)
+ {
+     // Create transfer devices for all input devices.
+diff --git a/qtwayland/src/client/qwaylanddatadevicemanager_p.h b/qtwayland/src/client/qwaylanddatadevicemanager_p.h
+index bd05c0fb..510d9be4 100644
+--- a/qtwayland/src/client/qwaylanddatadevicemanager_p.h
++++ b/qtwayland/src/client/qwaylanddatadevicemanager_p.h
+@@ -68,7 +68,7 @@ class QWaylandInputDevice;
+ class Q_WAYLAND_CLIENT_EXPORT QWaylandDataDeviceManager : public QtWayland::wl_data_device_manager
+ {
+ public:
+-    QWaylandDataDeviceManager(QWaylandDisplay *display, uint32_t id);
++    QWaylandDataDeviceManager(QWaylandDisplay *display, int version, uint32_t id);
+     ~QWaylandDataDeviceManager() override;
+ 
+     QWaylandDataDevice *getDataDevice(QWaylandInputDevice *inputDevice);
+diff --git a/qtwayland/src/client/qwaylanddataoffer.cpp b/qtwayland/src/client/qwaylanddataoffer.cpp
+index 2297e8a1..fe0ea8c9 100644
+--- a/qtwayland/src/client/qwaylanddataoffer.cpp
++++ b/qtwayland/src/client/qwaylanddataoffer.cpp
+@@ -82,6 +82,15 @@ QMimeData *QWaylandDataOffer::mimeData()
+     return m_mimeData.data();
+ }
+ 
++Qt::DropActions QWaylandDataOffer::supportedActions() const
++{
++    if (wl_data_offer_get_version(const_cast<::wl_data_offer*>(object())) < 3) {
++        return Qt::MoveAction | Qt::CopyAction;
++    }
++
++    return m_supportedActions;
++}
++
+ void QWaylandDataOffer::startReceiving(const QString &mimeType, int fd)
+ {
+     receive(mimeType, fd);
+@@ -93,6 +102,22 @@ void QWaylandDataOffer::data_offer_offer(const QString &mime_type)
+     m_mimeData->appendFormat(mime_type);
+ }
+ 
++void QWaylandDataOffer::data_offer_action(uint32_t dnd_action)
++{
++    Q_UNUSED(dnd_action);
++    // This is the compositor telling the drag target what action it should perform
++    // It does not map nicely into Qt final drop semantics, other than pretending there is only one supported action?
++}
++
++void QWaylandDataOffer::data_offer_source_actions(uint32_t source_actions)
++{
++    m_supportedActions = Qt::DropActions();
++    if (source_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
++        m_supportedActions |= Qt::MoveAction;
++    if (source_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
++        m_supportedActions |= Qt::CopyAction;
++}
++
+ QWaylandMimeData::QWaylandMimeData(QWaylandAbstractDataOffer *dataOffer)
+     : m_dataOffer(dataOffer)
+ {
+@@ -163,17 +188,18 @@ QVariant QWaylandMimeData::retrieveData_sys(const QString &mimeType, QVariant::T
+ 
+ int QWaylandMimeData::readData(int fd, QByteArray &data) const
+ {
+-    fd_set readset;
+-    FD_ZERO(&readset);
+-    FD_SET(fd, &readset);
+-    struct timeval timeout;
++    struct pollfd readset;
++    readset.fd = fd;
++    readset.events = POLLIN;
++    struct timespec timeout;
+     timeout.tv_sec = 1;
+-    timeout.tv_usec = 0;
++    timeout.tv_nsec = 0;
++
+ 
+     Q_FOREVER {
+-        int ready = select(FD_SETSIZE, &readset, nullptr, nullptr, &timeout);
++        int ready = qt_safe_poll(&readset, 1, &timeout);
+         if (ready < 0) {
+-            qWarning() << "QWaylandDataOffer: select() failed";
++            qWarning() << "QWaylandDataOffer: qt_safe_poll() failed";
+             return -1;
+         } else if (ready == 0) {
+             qWarning("QWaylandDataOffer: timeout reading from pipe");
+diff --git a/qtwayland/src/client/qwaylanddataoffer_p.h b/qtwayland/src/client/qwaylanddataoffer_p.h
+index 9cf1483c..6f667398 100644
+--- a/qtwayland/src/client/qwaylanddataoffer_p.h
++++ b/qtwayland/src/client/qwaylanddataoffer_p.h
+@@ -82,6 +82,7 @@ public:
+     explicit QWaylandDataOffer(QWaylandDisplay *display, struct ::wl_data_offer *offer);
+     ~QWaylandDataOffer() override;
+     QMimeData *mimeData() override;
++    Qt::DropActions supportedActions() const;
+ 
+     QString firstFormat() const;
+ 
+@@ -89,10 +90,13 @@ public:
+ 
+ protected:
+     void data_offer_offer(const QString &mime_type) override;
++    void data_offer_source_actions(uint32_t source_actions) override;
++    void data_offer_action(uint32_t dnd_action) override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+     QScopedPointer<QWaylandMimeData> m_mimeData;
++    Qt::DropActions m_supportedActions;
+ };
+ 
+ 
+diff --git a/qtwayland/src/client/qwaylanddatasource.cpp b/qtwayland/src/client/qwaylanddatasource.cpp
+index f45122fb..5599cbd4 100644
+--- a/qtwayland/src/client/qwaylanddatasource.cpp
++++ b/qtwayland/src/client/qwaylanddatasource.cpp
+@@ -101,7 +101,32 @@ void QWaylandDataSource::data_source_send(const QString &mime_type, int32_t fd)
+ 
+ void QWaylandDataSource::data_source_target(const QString &mime_type)
+ {
+-    Q_EMIT targetChanged(mime_type);
++    m_accepted = !mime_type.isEmpty();
++    Q_EMIT dndResponseUpdated(m_accepted, m_dropAction);
++}
++
++void QWaylandDataSource::data_source_action(uint32_t action)
++{
++    Qt::DropAction qtAction = Qt::IgnoreAction;
++
++    if (action == WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
++        qtAction = Qt::MoveAction;
++    else if (action == WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
++        qtAction = Qt::CopyAction;
++
++    m_dropAction = qtAction;
++    Q_EMIT dndResponseUpdated(m_accepted, m_dropAction);
++}
++
++void QWaylandDataSource::data_source_dnd_finished()
++{
++    Q_EMIT finished();
++}
++
++void QWaylandDataSource::data_source_dnd_drop_performed()
++{
++
++    Q_EMIT dndDropped(m_accepted, m_dropAction);
+ }
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddatasource_p.h b/qtwayland/src/client/qwaylanddatasource_p.h
+index 25afff79..96f07bc3 100644
+--- a/qtwayland/src/client/qwaylanddatasource_p.h
++++ b/qtwayland/src/client/qwaylanddatasource_p.h
+@@ -77,17 +77,25 @@ public:
+     QMimeData *mimeData() const;
+ 
+ Q_SIGNALS:
+-    void targetChanged(const QString &mime_type);
+     void cancelled();
++    void finished();
++
++    void dndResponseUpdated(bool accepted, Qt::DropAction action);
++    void dndDropped(bool accepted, Qt::DropAction action);
+ 
+ protected:
+     void data_source_cancelled() override;
+     void data_source_send(const QString &mime_type, int32_t fd) override;
+     void data_source_target(const QString &mime_type) override;
++    void data_source_dnd_drop_performed() override;
++    void data_source_dnd_finished() override;
++    void data_source_action(uint32_t action) override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+     QMimeData *m_mime_data = nullptr;
++    bool m_accepted = false;
++    Qt::DropAction m_dropAction = Qt::IgnoreAction;
+ };
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddisplay.cpp b/qtwayland/src/client/qwaylanddisplay.cpp
+index f10c1f79..c01e238b 100644
+--- a/qtwayland/src/client/qwaylanddisplay.cpp
++++ b/qtwayland/src/client/qwaylanddisplay.cpp
+@@ -85,10 +85,203 @@
+ 
+ #include <errno.h>
+ 
++#include <tuple> // for std::tie
++
++static void checkWaylandError(struct wl_display *display)
++{
++    int ecode = wl_display_get_error(display);
++    if ((ecode == EPIPE || ecode == ECONNRESET)) {
++        // special case this to provide a nicer error
++        qWarning("The Wayland connection broke. Did the Wayland compositor die?");
++    } else {
++        qWarning("The Wayland connection experienced a fatal error: %s", strerror(ecode));
++    }
++    _exit(1);
++}
++
+ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
++class EventThread : public QThread
++{
++    Q_OBJECT
++public:
++    enum OperatingMode {
++        EmitToDispatch, // Emit the signal, allow dispatching in a differnt thread.
++        SelfDispatch, // Dispatch the events inside this thread.
++    };
++
++    EventThread(struct wl_display * wl, struct wl_event_queue * ev_queue,
++                OperatingMode mode)
++        : m_fd(wl_display_get_fd(wl))
++        , m_pipefd{ -1, -1 }
++        , m_wldisplay(wl)
++        , m_wlevqueue(ev_queue)
++        , m_mode(mode)
++        , m_reading(true)
++        , m_quitting(false)
++    {
++        setObjectName(QStringLiteral("WaylandEventThread"));
++    }
++
++    void readAndDispatchEvents()
++    {
++        /*
++         * Dispatch pending events and flush the requests at least once. If the event thread
++         * is not reading, try to call _prepare_read() to allow the event thread to poll().
++         * If that fails, re-try dispatch & flush again until _prepare_read() is successful.
++         *
++         * This allow any call to readAndDispatchEvents() to start event thread's polling,
++         * not only the one issued from event thread's waitForReading(), which means functions
++         * called from dispatch_pending() can safely spin an event loop.
++         */
++        for (;;) {
++            if (dispatchQueuePending() < 0) {
++                checkWaylandError(m_wldisplay);
++                return;
++            }
++
++            wl_display_flush(m_wldisplay);
++
++            // We have to check if event thread is reading every time we dispatch
++            // something, as that may recursively call this function.
++            if (m_reading.loadAcquire())
++                break;
++
++            if (prepareReadQueue() == 0) {
++                QMutexLocker l(&m_mutex);
++                m_reading.storeRelease(true);
++                m_cond.wakeOne();
++                break;
++            }
++        }
++    }
++
++    void stop()
++    {
++        // We have to both write to the pipe and set the flag, as the thread may be
++        // either in the poll() or waiting for _prepare_read().
++        if (m_pipefd[1] != -1 && write(m_pipefd[1], "\0", 1) == -1)
++            qWarning("Failed to write to the pipe: %s.", strerror(errno));
++
++        {
++            QMutexLocker l(&m_mutex);
++            m_quitting = true;
++            m_cond.wakeOne();
++        }
++
++        wait();
++    }
++
++Q_SIGNALS:
++    void needReadAndDispatch();
++
++protected:
++    void run() override
++    {
++        // we use this pipe to make the loop exit otherwise if we simply used a flag on the loop condition, if stop() gets
++        // called while poll() is blocking the thread will never quit since there are no wayland messages coming anymore.
++        struct Pipe
++        {
++            Pipe(int *fds)
++                : fds(fds)
++            {
++                if (qt_safe_pipe(fds) != 0)
++                    qWarning("Pipe creation failed. Quitting may hang.");
++            }
++            ~Pipe()
++            {
++                if (fds[0] != -1) {
++                    close(fds[0]);
++                    close(fds[1]);
++                }
++            }
++
++            int *fds;
++        } pipe(m_pipefd);
++
++        // Make the main thread call wl_prepare_read(), dispatch the pending messages and flush the
++        // outbound ones. Wait until it's done before proceeding, unless we're told to quit.
++        while (waitForReading()) {
++            pollfd fds[2] = { { m_fd, POLLIN, 0 }, { m_pipefd[0], POLLIN, 0 } };
++            poll(fds, 2, -1);
++
++            if (fds[1].revents & POLLIN) {
++                // we don't really care to read the byte that was written here since we're closing down
++                wl_display_cancel_read(m_wldisplay);
++                break;
++            }
++
++            if (fds[0].revents & POLLIN)
++                wl_display_read_events(m_wldisplay);
++                // The polll was succesfull and the event thread did the wl_display_read_events(). On the next iteration of the loop
++                // the event sent to the main thread will cause it to dispatch the messages just read, unless the loop exits in which
++                // case we don't care anymore about them.
++            else
++                wl_display_cancel_read(m_wldisplay);
++        }
++    }
++
++private:
++    bool waitForReading()
++    {
++        Q_ASSERT(QThread::currentThread() == this);
++
++        m_reading.storeRelease(false);
++
++        if (m_mode == SelfDispatch) {
++            readAndDispatchEvents();
++        } else {
++            Q_EMIT needReadAndDispatch();
++
++            QMutexLocker lock(&m_mutex);
++            // m_reading might be set from our emit or some other invocation of
++            // readAndDispatchEvents().
++            while (!m_reading.loadRelaxed() && !m_quitting)
++                m_cond.wait(&m_mutex);
++        }
++
++        return !m_quitting;
++    }
++
++    int dispatchQueuePending()
++    {
++        if (m_wlevqueue)
++            return wl_display_dispatch_queue_pending(m_wldisplay, m_wlevqueue);
++        else
++            return wl_display_dispatch_pending(m_wldisplay);
++    }
++
++    int prepareReadQueue()
++    {
++        if (m_wlevqueue)
++            return wl_display_prepare_read_queue(m_wldisplay, m_wlevqueue);
++        else
++            return wl_display_prepare_read(m_wldisplay);
++    }
++
++    int m_fd;
++    int m_pipefd[2];
++    wl_display *m_wldisplay;
++    wl_event_queue *m_wlevqueue;
++    OperatingMode m_mode;
++
++    /* Concurrency note when operating in EmitToDispatch mode:
++     * m_reading is set to false inside event thread's waitForReading(), and is
++     * set to true inside main thread's readAndDispatchEvents().
++     * The lock is not taken when setting m_reading to false, as the main thread
++     * is not actively waiting for it to turn false. However, the lock is taken
++     * inside readAndDispatchEvents() before setting m_reading to true,
++     * as the event thread is actively waiting for it under the wait condition.
++     */
++
++    QAtomicInteger<bool> m_reading;
++    bool m_quitting;
++    QMutex m_mutex;
++    QWaitCondition m_cond;
++};
++
+ Q_LOGGING_CATEGORY(lcQpaWayland, "qt.qpa.wayland"); // for general (uncategorized) Wayland platform logging
+ 
+ struct wl_surface *QWaylandDisplay::createSurface(void *handle)
+@@ -158,17 +351,16 @@ QWaylandDisplay::QWaylandDisplay(QWaylandIntegration *waylandIntegration)
+     if (!mXkbContext)
+         qCWarning(lcQpaWayland, "failed to create xkb context");
+ #endif
+-
+-    forceRoundTrip();
+-
+-    if (!mWaitingScreens.isEmpty()) {
+-        // Give wl_output.done and zxdg_output_v1.done events a chance to arrive
+-        forceRoundTrip();
+-    }
+ }
+ 
+ QWaylandDisplay::~QWaylandDisplay(void)
+ {
++    if (m_eventThread)
++        m_eventThread->stop();
++
++    if (m_frameEventQueueThread)
++        m_frameEventQueueThread->stop();
++
+     if (mSyncCallback)
+         wl_callback_destroy(mSyncCallback);
+ 
+@@ -187,6 +379,21 @@ QWaylandDisplay::~QWaylandDisplay(void)
+ #endif
+     if (mDisplay)
+         wl_display_disconnect(mDisplay);
++
++    if (m_frameEventQueue)
++        wl_event_queue_destroy(m_frameEventQueue);
++}
++
++// Steps which is called just after constructor. This separates registry_global() out of the constructor
++// so that factory functions in integration can be overridden.
++void QWaylandDisplay::initialize()
++{
++    forceRoundTrip();
++
++    if (!mWaitingScreens.isEmpty()) {
++        // Give wl_output.done and zxdg_output_v1.done events a chance to arrive
++        forceRoundTrip();
++    }
+ }
+ 
+ void QWaylandDisplay::ensureScreen()
+@@ -203,98 +410,37 @@ void QWaylandDisplay::ensureScreen()
+ 
+ void QWaylandDisplay::checkError() const
+ {
+-    int ecode = wl_display_get_error(mDisplay);
+-    if ((ecode == EPIPE || ecode == ECONNRESET)) {
+-        // special case this to provide a nicer error
+-        qWarning("The Wayland connection broke. Did the Wayland compositor die?");
+-    } else {
+-        qWarning("The Wayland connection experienced a fatal error: %s", strerror(ecode));
+-    }
+-    _exit(1);
++    checkWaylandError(mDisplay);
+ }
+ 
++// Called in main thread, either from queued signal or directly.
+ void QWaylandDisplay::flushRequests()
+ {
+-    if (wl_display_prepare_read(mDisplay) == 0) {
+-        wl_display_read_events(mDisplay);
+-    }
+-
+-    if (wl_display_dispatch_pending(mDisplay) < 0)
+-        checkError();
+-
+-    {
+-        QReadLocker locker(&m_frameQueueLock);
+-        for (const FrameQueue &q : mExternalQueues) {
+-            QMutexLocker locker(q.mutex);
+-            while (wl_display_prepare_read_queue(mDisplay, q.queue) != 0)
+-                wl_display_dispatch_queue_pending(mDisplay, q.queue);
+-            wl_display_read_events(mDisplay);
+-            wl_display_dispatch_queue_pending(mDisplay, q.queue);
+-        }
+-    }
+-
+-    wl_display_flush(mDisplay);
+-}
+-
+-void QWaylandDisplay::blockingReadEvents()
+-{
+-    if (wl_display_dispatch(mDisplay) < 0)
+-        checkError();
+-}
+-
+-void QWaylandDisplay::destroyFrameQueue(const QWaylandDisplay::FrameQueue &q)
+-{
+-    QWriteLocker locker(&m_frameQueueLock);
+-    auto it = std::find_if(mExternalQueues.begin(),
+-                           mExternalQueues.end(),
+-                           [&q] (const QWaylandDisplay::FrameQueue &other){ return other.queue == q.queue; });
+-    Q_ASSERT(it != mExternalQueues.end());
+-    mExternalQueues.erase(it);
+-    if (q.queue != nullptr)
+-        wl_event_queue_destroy(q.queue);
+-    delete q.mutex;
++    m_eventThread->readAndDispatchEvents();
+ }
+ 
+-QWaylandDisplay::FrameQueue QWaylandDisplay::createFrameQueue()
++// We have to wait until we have an eventDispatcher before creating the eventThread,
++// otherwise forceRoundTrip() may block inside _events_read() because eventThread is
++// polling.
++void QWaylandDisplay::initEventThread()
+ {
+-    QWriteLocker locker(&m_frameQueueLock);
+-    FrameQueue q{createEventQueue()};
+-    mExternalQueues.append(q);
+-    return q;
+-}
++    m_eventThread.reset(
++            new EventThread(mDisplay, /* default queue */ nullptr, EventThread::EmitToDispatch));
++    connect(m_eventThread.get(), &EventThread::needReadAndDispatch, this,
++            &QWaylandDisplay::flushRequests, Qt::QueuedConnection);
++    m_eventThread->start();
+ 
+-wl_event_queue *QWaylandDisplay::createEventQueue()
+-{
+-    return wl_display_create_queue(mDisplay);
++    // wl_display_disconnect() free this.
++    m_frameEventQueue = wl_display_create_queue(mDisplay);
++    m_frameEventQueueThread.reset(
++            new EventThread(mDisplay, m_frameEventQueue, EventThread::SelfDispatch));
++    m_frameEventQueueThread->start();
+ }
+ 
+-void QWaylandDisplay::dispatchQueueWhile(wl_event_queue *queue, std::function<bool ()> condition, int timeout)
++void QWaylandDisplay::blockingReadEvents()
+ {
+-    if (!condition())
+-        return;
+-
+-    QElapsedTimer timer;
+-    timer.start();
+-    struct pollfd pFd = qt_make_pollfd(wl_display_get_fd(mDisplay), POLLIN);
+-    while (timeout == -1 || timer.elapsed() < timeout) {
+-        while (wl_display_prepare_read_queue(mDisplay, queue) != 0)
+-            wl_display_dispatch_queue_pending(mDisplay, queue);
+-
+-        wl_display_flush(mDisplay);
+-
+-        const int remaining = qMax(timeout - timer.elapsed(), 0ll);
+-        const int pollTimeout = timeout == -1 ? -1 : remaining;
+-        if (qt_poll_msecs(&pFd, 1, pollTimeout) > 0)
+-            wl_display_read_events(mDisplay);
+-        else
+-            wl_display_cancel_read(mDisplay);
+-
+-        if (wl_display_dispatch_queue_pending(mDisplay, queue) < 0)
+-            checkError();
+-
+-        if (!condition())
+-            break;
+-    }
++    if (wl_display_dispatch(mDisplay) < 0)
++        checkWaylandError(mDisplay);
+ }
+ 
+ QWaylandScreen *QWaylandDisplay::screenForOutput(struct wl_output *output) const
+@@ -345,7 +491,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+     if (interface == QStringLiteral("wl_output")) {
+         mWaitingScreens << new QWaylandScreen(this, version, id);
+     } else if (interface == QStringLiteral("wl_compositor")) {
+-        mCompositorVersion = qMin((int)version, 3);
++        mCompositorVersion = qMin((int)version, 4);
+         mCompositor.init(registry, id, mCompositorVersion);
+     } else if (interface == QStringLiteral("wl_shm")) {
+         mShm.reset(new QWaylandShm(this, version, id));
+@@ -354,7 +500,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+         mInputDevices.append(inputDevice);
+ #if QT_CONFIG(wayland_datadevice)
+     } else if (interface == QStringLiteral("wl_data_device_manager")) {
+-        mDndSelectionHandler.reset(new QWaylandDataDeviceManager(this, id));
++        mDndSelectionHandler.reset(new QWaylandDataDeviceManager(this, version, id));
+ #endif
+     } else if (interface == QStringLiteral("qt_surface_extension")) {
+         mWindowExtension.reset(new QtWayland::qt_surface_extension(registry, id, 1));
+@@ -369,6 +515,8 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+ #if QT_CONFIG(wayland_client_primary_selection)
+     } else if (interface == QStringLiteral("zwp_primary_selection_device_manager_v1")) {
+         mPrimarySelectionManager.reset(new QWaylandPrimarySelectionDeviceManagerV1(this, id, 1));
++        for (QWaylandInputDevice *inputDevice : qAsConst(mInputDevices))
++            inputDevice->setPrimarySelectionDevice(mPrimarySelectionManager->createDevice(inputDevice));
+ #endif
+     } else if (interface == QStringLiteral("zwp_text_input_manager_v2") && !mClientSideInputContextRequested) {
+         mTextInputManager.reset(new QtWayland::zwp_text_input_manager_v2(registry, id, 1));
+@@ -427,6 +575,13 @@ void QWaylandDisplay::registry_global_remove(uint32_t id)
+                     inputDevice->setTextInput(nullptr);
+                 mWaylandIntegration->reconfigureInputContext();
+             }
++#if QT_CONFIG(wayland_client_primary_selection)
++            if (global.interface == QStringLiteral("zwp_primary_selection_device_manager_v1")) {
++                mPrimarySelectionManager.reset();
++                for (QWaylandInputDevice *inputDevice : qAsConst(mInputDevices))
++                    inputDevice->setPrimarySelectionDevice(nullptr);
++            }
++#endif
+             mGlobals.removeAt(i);
+             break;
+         }
+@@ -452,9 +607,10 @@ void QWaylandDisplay::addRegistryListener(RegistryListener listener, void *data)
+ 
+ void QWaylandDisplay::removeListener(RegistryListener listener, void *data)
+ {
+-    std::remove_if(mRegistryListeners.begin(), mRegistryListeners.end(), [=](Listener l){
++    auto iter = std::remove_if(mRegistryListeners.begin(), mRegistryListeners.end(), [=](Listener l){
+         return (l.listener == listener && l.data == data);
+     });
++    mRegistryListeners.erase(iter, mRegistryListeners.end());
+ }
+ 
+ uint32_t QWaylandDisplay::currentTimeMillisec()
+@@ -467,50 +623,9 @@ uint32_t QWaylandDisplay::currentTimeMillisec()
+     return 0;
+ }
+ 
+-static void
+-sync_callback(void *data, struct wl_callback *callback, uint32_t serial)
+-{
+-    Q_UNUSED(serial)
+-    bool *done = static_cast<bool *>(data);
+-
+-    *done = true;
+-
+-    // If the wl_callback done event is received after the condition check in the while loop in
+-    // forceRoundTrip(), but before the call to processEvents, the call to processEvents may block
+-    // forever if no more events are posted (eventhough the callback is handled in response to the
+-    // aboutToBlock signal). Hence, we wake up the event dispatcher so forceRoundTrip may return.
+-    // (QTBUG-64696)
+-    if (auto *dispatcher = QThread::currentThread()->eventDispatcher())
+-        dispatcher->wakeUp();
+-
+-    wl_callback_destroy(callback);
+-}
+-
+-static const struct wl_callback_listener sync_listener = {
+-    sync_callback
+-};
+-
+ void QWaylandDisplay::forceRoundTrip()
+ {
+-    // wl_display_roundtrip() works on the main queue only,
+-    // but we use a separate one, so basically reimplement it here
+-    int ret = 0;
+-    bool done = false;
+-    wl_callback *callback = wl_display_sync(mDisplay);
+-    wl_callback_add_listener(callback, &sync_listener, &done);
+-    flushRequests();
+-    if (QThread::currentThread()->eventDispatcher()) {
+-        while (!done && ret >= 0) {
+-            QThread::currentThread()->eventDispatcher()->processEvents(QEventLoop::WaitForMoreEvents);
+-            ret = wl_display_dispatch_pending(mDisplay);
+-        }
+-    } else {
+-        while (!done && ret >= 0)
+-            ret = wl_display_dispatch(mDisplay);
+-    }
+-
+-    if (ret == -1 && !done)
+-        wl_callback_destroy(callback);
++     wl_display_roundtrip(mDisplay);
+ }
+ 
+ bool QWaylandDisplay::supportsWindowDecoration() const
+@@ -574,14 +689,10 @@ void QWaylandDisplay::handleKeyboardFocusChanged(QWaylandInputDevice *inputDevic
+     if (mLastKeyboardFocus == keyboardFocus)
+         return;
+ 
+-    if (mWaylandIntegration->mShellIntegration) {
+-        mWaylandIntegration->mShellIntegration->handleKeyboardFocusChanged(keyboardFocus, mLastKeyboardFocus);
+-    } else {
+-        if (keyboardFocus)
+-            handleWindowActivated(keyboardFocus);
+-        if (mLastKeyboardFocus)
+-            handleWindowDeactivated(mLastKeyboardFocus);
+-    }
++    if (keyboardFocus)
++        handleWindowActivated(keyboardFocus);
++    if (mLastKeyboardFocus)
++        handleWindowDeactivated(mLastKeyboardFocus);
+ 
+     mLastKeyboardFocus = keyboardFocus;
+ }
+@@ -600,6 +711,19 @@ void QWaylandDisplay::handleWaylandSync()
+     QWindow *activeWindow = mActiveWindows.empty() ? nullptr : mActiveWindows.last()->window();
+     if (activeWindow != QGuiApplication::focusWindow())
+         QWindowSystemInterface::handleWindowActivated(activeWindow);
++
++    if (!activeWindow) {
++        if (lastInputDevice()) {
++#if QT_CONFIG(clipboard)
++            if (auto *dataDevice = lastInputDevice()->dataDevice())
++                dataDevice->invalidateSelectionOffer();
++#endif
++#if QT_CONFIG(wayland_client_primary_selection)
++            if (auto *device = lastInputDevice()->primarySelectionDevice())
++                device->invalidateSelectionOffer();
++#endif
++        }
++    }
+ }
+ 
+ const wl_callback_listener QWaylandDisplay::syncCallbackListener = {
+@@ -626,6 +750,13 @@ QWaylandInputDevice *QWaylandDisplay::defaultInputDevice() const
+     return mInputDevices.isEmpty() ? 0 : mInputDevices.first();
+ }
+ 
++bool QWaylandDisplay::isKeyboardAvailable() const
++{
++    return std::any_of(
++            mInputDevices.constBegin(), mInputDevices.constEnd(),
++            [this](const QWaylandInputDevice *device) { return device->keyboard() != nullptr; });
++}
++
+ #if QT_CONFIG(cursor)
+ 
+ QWaylandCursor *QWaylandDisplay::waylandCursor()
+@@ -652,4 +783,6 @@ QWaylandCursorTheme *QWaylandDisplay::loadCursorTheme(const QString &name, int p
+ 
+ } // namespace QtWaylandClient
+ 
++#include "qwaylanddisplay.moc"
++
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/client/qwaylanddisplay_p.h b/qtwayland/src/client/qwaylanddisplay_p.h
+index 3b092bc8..42bc661d 100644
+--- a/qtwayland/src/client/qwaylanddisplay_p.h
++++ b/qtwayland/src/client/qwaylanddisplay_p.h
+@@ -109,6 +109,7 @@ class QWaylandSurface;
+ class QWaylandShellIntegration;
+ class QWaylandCursor;
+ class QWaylandCursorTheme;
++class EventThread;
+ 
+ typedef void (*RegistryListener)(void *data,
+                                  struct wl_registry *registry,
+@@ -120,15 +121,11 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandDisplay : public QObject, public QtWayland
+     Q_OBJECT
+ 
+ public:
+-    struct FrameQueue {
+-        FrameQueue(wl_event_queue *q = nullptr) : queue(q), mutex(new QMutex) {}
+-        wl_event_queue *queue;
+-        QMutex *mutex;
+-    };
+-
+     QWaylandDisplay(QWaylandIntegration *waylandIntegration);
+     ~QWaylandDisplay(void) override;
+ 
++    void initialize();
++
+ #if QT_CONFIG(xkbcommon)
+     struct xkb_context *xkbContext() const { return mXkbContext.get(); }
+ #endif
+@@ -210,11 +207,11 @@ public:
+     void handleKeyboardFocusChanged(QWaylandInputDevice *inputDevice);
+     void handleWindowDestroyed(QWaylandWindow *window);
+ 
+-    wl_event_queue *createEventQueue();
+-    FrameQueue createFrameQueue();
+-    void destroyFrameQueue(const FrameQueue &q);
+-    void dispatchQueueWhile(wl_event_queue *queue, std::function<bool()> condition, int timeout = -1);
++    wl_event_queue *frameEventQueue() { return m_frameEventQueue; };
++
++    bool isKeyboardAvailable() const;
+ 
++    void initEventThread();
+ public slots:
+     void blockingReadEvents();
+     void flushRequests();
+@@ -237,6 +234,9 @@ private:
+     };
+ 
+     struct wl_display *mDisplay = nullptr;
++    QScopedPointer<EventThread> m_eventThread;
++    wl_event_queue *m_frameEventQueue = nullptr;
++    QScopedPointer<EventThread> m_frameEventQueueThread;
+     QtWayland::wl_compositor mCompositor;
+     QScopedPointer<QWaylandShm> mShm;
+     QList<QWaylandScreen *> mWaitingScreens;
+@@ -273,11 +273,9 @@ private:
+     QWaylandInputDevice *mLastInputDevice = nullptr;
+     QPointer<QWaylandWindow> mLastInputWindow;
+     QPointer<QWaylandWindow> mLastKeyboardFocus;
+-    QVector<QWaylandWindow *> mActiveWindows;
+-    QVector<FrameQueue> mExternalQueues;
++    QList<QWaylandWindow *> mActiveWindows;
+     struct wl_callback *mSyncCallback = nullptr;
+     static const wl_callback_listener syncCallbackListener;
+-    QReadWriteLock m_frameQueueLock;
+ 
+     bool mClientSideInputContextRequested = !QPlatformInputContextFactory::requested().isNull();
+ 
+diff --git a/qtwayland/src/client/qwaylanddnd.cpp b/qtwayland/src/client/qwaylanddnd.cpp
+index 6535aa16..7c53f5fa 100644
+--- a/qtwayland/src/client/qwaylanddnd.cpp
++++ b/qtwayland/src/client/qwaylanddnd.cpp
+@@ -66,7 +66,7 @@ void QWaylandDrag::startDrag()
+ {
+     QBasicDrag::startDrag();
+     QWaylandWindow *icon = static_cast<QWaylandWindow *>(shapedPixmapWindow()->handle());
+-    if (m_display->currentInputDevice()->dataDevice()->startDrag(drag()->mimeData(), icon)) {
++    if (m_display->currentInputDevice()->dataDevice()->startDrag(drag()->mimeData(), drag()->supportedActions(), icon)) {
+         icon->addAttachOffset(-drag()->hotSpot());
+     } else {
+         // Cancelling immediately does not work, since the event loop for QDrag::exec is started
+@@ -80,6 +80,9 @@ void QWaylandDrag::cancel()
+     QBasicDrag::cancel();
+ 
+     m_display->currentInputDevice()->dataDevice()->cancelDrag();
++
++    if (drag())
++        drag()->deleteLater();
+ }
+ 
+ void QWaylandDrag::move(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods)
+@@ -103,33 +106,41 @@ void QWaylandDrag::endDrag()
+     m_display->currentInputDevice()->handleEndDrag();
+ }
+ 
+-void QWaylandDrag::updateTarget(const QString &mimeType)
++void QWaylandDrag::setResponse(bool accepted)
+ {
+-    setCanDrop(!mimeType.isEmpty());
+-
+-    if (canDrop()) {
+-        updateCursor(defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers()));
+-    } else {
+-        updateCursor(Qt::IgnoreAction);
+-    }
++    // This method is used for old DataDevices where the drag action is not communicated
++    Qt::DropAction action = defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers());
++    setResponse(QPlatformDropQtResponse(accepted, action));
+ }
+ 
+-void QWaylandDrag::setResponse(const QPlatformDragQtResponse &response)
++void QWaylandDrag::setResponse(const QPlatformDropQtResponse &response)
+ {
+     setCanDrop(response.isAccepted());
+ 
+     if (canDrop()) {
+-        updateCursor(defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers()));
++        updateCursor(response.acceptedAction());
+     } else {
+         updateCursor(Qt::IgnoreAction);
+     }
+ }
+ 
+-void QWaylandDrag::finishDrag(const QPlatformDropQtResponse &response)
++void QWaylandDrag::setDropResponse(const QPlatformDropQtResponse &response)
+ {
+     setExecutedDropAction(response.acceptedAction());
++}
++
++void QWaylandDrag::finishDrag()
++{
+     QKeyEvent event(QEvent::KeyPress, Qt::Key_Escape, Qt::NoModifier);
+     eventFilter(shapedPixmapWindow(), &event);
++
++    if (drag())
++        drag()->deleteLater();
++}
++
++bool QWaylandDrag::ownsDragObject() const
++{
++    return true;
+ }
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddnd_p.h b/qtwayland/src/client/qwaylanddnd_p.h
+index 474fe2ab..46f629ac 100644
+--- a/qtwayland/src/client/qwaylanddnd_p.h
++++ b/qtwayland/src/client/qwaylanddnd_p.h
+@@ -71,9 +71,10 @@ public:
+     QWaylandDrag(QWaylandDisplay *display);
+     ~QWaylandDrag() override;
+ 
+-    void updateTarget(const QString &mimeType);
+-    void setResponse(const QPlatformDragQtResponse &response);
+-    void finishDrag(const QPlatformDropQtResponse &response);
++    void setResponse(bool accepted);
++    void setResponse(const QPlatformDropQtResponse &response);
++    void setDropResponse(const QPlatformDropQtResponse &response);
++    void finishDrag();
+ 
+ protected:
+     void startDrag() override;
+@@ -82,6 +83,7 @@ protected:
+     void drop(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods) override;
+     void endDrag() override;
+ 
++    bool ownsDragObject() const override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+diff --git a/qtwayland/src/client/qwaylandinputdevice.cpp b/qtwayland/src/client/qwaylandinputdevice.cpp
+index 613fe862..4b90de84 100644
+--- a/qtwayland/src/client/qwaylandinputdevice.cpp
++++ b/qtwayland/src/client/qwaylandinputdevice.cpp
+@@ -685,6 +685,11 @@ public:
+ 
+ void QWaylandInputDevice::Pointer::pointer_leave(uint32_t time, struct wl_surface *surface)
+ {
++    invalidateFocus();
++    mButtons = Qt::NoButton;
++
++    mParent->mTime = time;
++
+     // The event may arrive after destroying the window, indicated by
+     // a null surface.
+     if (!surface)
+@@ -696,11 +701,6 @@ void QWaylandInputDevice::Pointer::pointer_leave(uint32_t time, struct wl_surfac
+ 
+     if (!QWaylandWindow::mouseGrab())
+         setFrameEvent(new LeaveEvent(window, mSurfacePos, mGlobalPos));
+-
+-    invalidateFocus();
+-    mButtons = Qt::NoButton;
+-
+-    mParent->mTime = time;
+ }
+ 
+ class MotionEvent : public QWaylandPointerEvent
+@@ -1300,14 +1300,6 @@ void QWaylandInputDevice::Keyboard::handleFocusDestroyed()
+ void QWaylandInputDevice::Keyboard::handleFocusLost()
+ {
+     mFocus = nullptr;
+-#if QT_CONFIG(clipboard)
+-    if (auto *dataDevice = mParent->dataDevice())
+-        dataDevice->invalidateSelectionOffer();
+-#endif
+-#if QT_CONFIG(wayland_client_primary_selection)
+-    if (auto *device = mParent->primarySelectionDevice())
+-        device->invalidateSelectionOffer();
+-#endif
+     mParent->mQDisplay->handleKeyboardFocusChanged(mParent);
+     mRepeatTimer.stop();
+ }
+@@ -1396,6 +1388,7 @@ void QWaylandInputDevice::Touch::touch_cancel()
+     if (touchExt)
+         touchExt->touchCanceled();
+ 
++    mFocus = nullptr;
+     QWindowSystemInterface::handleTouchCancelEvent(nullptr, mParent->mTouchDevice);
+ }
+ 
+diff --git a/qtwayland/src/client/qwaylandintegration.cpp b/qtwayland/src/client/qwaylandintegration.cpp
+index c53ccb78..54861600 100644
+--- a/qtwayland/src/client/qwaylandintegration.cpp
++++ b/qtwayland/src/client/qwaylandintegration.cpp
+@@ -125,6 +125,9 @@ QWaylandIntegration::QWaylandIntegration()
+ #endif
+ 
+     reconfigureInputContext();
++
++    QWaylandWindow::fixedToplevelPositions =
++            !qEnvironmentVariableIsSet("QT_WAYLAND_DISABLE_FIXED_POSITIONS");
+ }
+ 
+ QWaylandIntegration::~QWaylandIntegration()
+@@ -192,14 +195,18 @@ QAbstractEventDispatcher *QWaylandIntegration::createEventDispatcher() const
+ 
+ void QWaylandIntegration::initialize()
+ {
++    mDisplay->initEventThread();
++
++    // Call after eventDispatcher is fully connected, for QWaylandDisplay::forceRoundTrip()
++    mDisplay->initialize();
++
++    // But the aboutToBlock() and awake() should be connected after initializePlatform().
++    // Otherwise the connected flushRequests() may consumes up all events before processEvents starts to wait,
++    // so that processEvents(QEventLoop::WaitForMoreEvents) may be blocked in the forceRoundTrip().
+     QAbstractEventDispatcher *dispatcher = QGuiApplicationPrivate::eventDispatcher;
+     QObject::connect(dispatcher, SIGNAL(aboutToBlock()), mDisplay.data(), SLOT(flushRequests()));
+     QObject::connect(dispatcher, SIGNAL(awake()), mDisplay.data(), SLOT(flushRequests()));
+ 
+-    int fd = wl_display_get_fd(mDisplay->wl_display());
+-    QSocketNotifier *sn = new QSocketNotifier(fd, QSocketNotifier::Read, mDisplay.data());
+-    QObject::connect(sn, SIGNAL(activated(QSocketDescriptor)), mDisplay.data(), SLOT(flushRequests()));
+-
+     // Qt does not support running with no screens
+     mDisplay->ensureScreen();
+ }
+@@ -262,6 +269,14 @@ QWaylandDisplay *QWaylandIntegration::display() const
+     return mDisplay.data();
+ }
+ 
++Qt::KeyboardModifiers QWaylandIntegration::queryKeyboardModifiers() const
++{
++    if (auto *seat = mDisplay->currentInputDevice()) {
++        return seat->modifiers();
++    }
++    return Qt::NoModifier;
++}
++
+ QList<int> QWaylandIntegration::possibleKeys(const QKeyEvent *event) const
+ {
+     if (auto *seat = mDisplay->currentInputDevice())
+@@ -479,7 +494,7 @@ void QWaylandIntegration::reconfigureInputContext()
+     }
+ #endif
+ 
+-    qCDebug(lcQpaWayland) << "using input method:" << inputContext()->metaObject()->className();
++    qCDebug(lcQpaWayland) << "using input method:" << (inputContext() ? inputContext()->metaObject()->className() : "<none>");
+ }
+ 
+ QWaylandShellIntegration *QWaylandIntegration::createShellIntegration(const QString &integrationName)
+diff --git a/qtwayland/src/client/qwaylandintegration_p.h b/qtwayland/src/client/qwaylandintegration_p.h
+index ff70ae25..73b80658 100644
+--- a/qtwayland/src/client/qwaylandintegration_p.h
++++ b/qtwayland/src/client/qwaylandintegration_p.h
+@@ -107,6 +107,8 @@ public:
+ 
+     QWaylandDisplay *display() const;
+ 
++    Qt::KeyboardModifiers queryKeyboardModifiers() const override;
++
+     QList<int> possibleKeys(const QKeyEvent *event) const override;
+ 
+     QStringList themeNames() const override;
+diff --git a/qtwayland/src/client/qwaylandprimaryselectionv1.cpp b/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
+index 832f9678..ea508771 100644
+--- a/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
++++ b/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
+@@ -54,11 +54,6 @@ QWaylandPrimarySelectionDeviceManagerV1::QWaylandPrimarySelectionDeviceManagerV1
+     : zwp_primary_selection_device_manager_v1(display->wl_registry(), id, qMin(version, uint(1)))
+     , m_display(display)
+ {
+-    // Create devices for all seats.
+-    // This only works if we get the global before all devices
+-    const auto seats = m_display->inputDevices();
+-    for (auto *seat : seats)
+-        seat->setPrimarySelectionDevice(createDevice(seat));
+ }
+ 
+ QWaylandPrimarySelectionDeviceV1 *QWaylandPrimarySelectionDeviceManagerV1::createDevice(QWaylandInputDevice *seat)
+diff --git a/qtwayland/src/client/qwaylandscreen.cpp b/qtwayland/src/client/qwaylandscreen.cpp
+index 6cb337de..5537dafd 100644
+--- a/qtwayland/src/client/qwaylandscreen.cpp
++++ b/qtwayland/src/client/qwaylandscreen.cpp
+@@ -60,7 +60,7 @@ QWaylandXdgOutputManagerV1::QWaylandXdgOutputManagerV1(QWaylandDisplay* display,
+ }
+ 
+ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uint32_t id)
+-    : QtWayland::wl_output(waylandDisplay->wl_registry(), id, qMin(version, 2))
++    : QtWayland::wl_output(waylandDisplay->wl_registry(), id, qMin(version, 3))
+     , m_outputId(id)
+     , mWaylandDisplay(waylandDisplay)
+     , mOutputName(QStringLiteral("Screen%1").arg(id))
+@@ -72,7 +72,7 @@ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uin
+         qCWarning(lcQpaWayland) << "wl_output done event not supported by compositor,"
+                                 << "QScreen may not work correctly";
+         mWaylandDisplay->forceRoundTrip(); // Give the compositor a chance to send geometry etc.
+-        mOutputDone = true; // Fake the done event
++        mProcessedEvents |= OutputDoneEvent; // Fake the done event
+         maybeInitialize();
+     }
+ }
+@@ -81,16 +81,29 @@ QWaylandScreen::~QWaylandScreen()
+ {
+     if (zxdg_output_v1::isInitialized())
+         zxdg_output_v1::destroy();
++    if (wl_output::isInitialized() && wl_output_get_version(wl_output::object()) >= WL_OUTPUT_RELEASE_SINCE_VERSION)
++        wl_output::release();
++}
++
++uint QWaylandScreen::requiredEvents() const
++{
++    uint ret = OutputDoneEvent;
++
++    if (mWaylandDisplay->xdgOutputManager()) {
++        ret |= XdgOutputNameEvent;
++
++        if (mWaylandDisplay->xdgOutputManager()->version() < 3)
++            ret |= XdgOutputDoneEvent;
++    }
++    return ret;
+ }
+ 
+ void QWaylandScreen::maybeInitialize()
+ {
+     Q_ASSERT(!mInitialized);
+ 
+-    if (!mOutputDone)
+-        return;
+-
+-    if (mWaylandDisplay->xdgOutputManager() && !mXdgOutputDone)
++    const uint requiredEvents = this->requiredEvents();
++    if ((mProcessedEvents & requiredEvents) != requiredEvents)
+         return;
+ 
+     mInitialized = true;
+@@ -276,9 +289,8 @@ void QWaylandScreen::output_scale(int32_t factor)
+ 
+ void QWaylandScreen::output_done()
+ {
+-    mOutputDone = true;
+-    if (zxdg_output_v1::isInitialized() && mWaylandDisplay->xdgOutputManager()->version() >= 3)
+-        mXdgOutputDone = true;
++    mProcessedEvents |= OutputDoneEvent;
++
+     if (mInitialized) {
+         updateOutputProperties();
+         if (zxdg_output_v1::isInitialized())
+@@ -339,7 +351,7 @@ void QWaylandScreen::zxdg_output_v1_done()
+     if (Q_UNLIKELY(mWaylandDisplay->xdgOutputManager()->version() >= 3))
+         qWarning(lcQpaWayland) << "zxdg_output_v1.done received on version 3 or newer, this is most likely a bug in the compositor";
+ 
+-    mXdgOutputDone = true;
++    mProcessedEvents |= XdgOutputDoneEvent;
+     if (mInitialized)
+         updateXdgOutputProperties();
+     else
+@@ -348,7 +360,11 @@ void QWaylandScreen::zxdg_output_v1_done()
+ 
+ void QWaylandScreen::zxdg_output_v1_name(const QString &name)
+ {
++    if (Q_UNLIKELY(mInitialized))
++        qWarning(lcQpaWayland) << "zxdg_output_v1.name received after output has been initialized, this is most likely a bug in the compositor";
++
+     mOutputName = name;
++    mProcessedEvents |= XdgOutputNameEvent;
+ }
+ 
+ void QWaylandScreen::updateXdgOutputProperties()
+diff --git a/qtwayland/src/client/qwaylandscreen_p.h b/qtwayland/src/client/qwaylandscreen_p.h
+index df1c94f2..050cfdc0 100644
+--- a/qtwayland/src/client/qwaylandscreen_p.h
++++ b/qtwayland/src/client/qwaylandscreen_p.h
+@@ -116,6 +116,13 @@ public:
+     static QWaylandScreen *fromWlOutput(::wl_output *output);
+ 
+ private:
++    enum Event : uint {
++        XdgOutputDoneEvent = 0x1,
++        OutputDoneEvent = 0x2,
++        XdgOutputNameEvent = 0x4,
++    };
++    uint requiredEvents() const;
++
+     void output_mode(uint32_t flags, int width, int height, int refresh) override;
+     void output_geometry(int32_t x, int32_t y,
+                          int32_t width, int32_t height,
+@@ -148,8 +155,7 @@ private:
+     QSize mPhysicalSize;
+     QString mOutputName;
+     Qt::ScreenOrientation m_orientation = Qt::PrimaryOrientation;
+-    bool mOutputDone = false;
+-    bool mXdgOutputDone = false;
++    uint mProcessedEvents = 0;
+     bool mInitialized = false;
+ 
+ #if QT_CONFIG(cursor)
+diff --git a/qtwayland/src/client/qwaylandshmbackingstore.cpp b/qtwayland/src/client/qwaylandshmbackingstore.cpp
+index dc7ff670..41cffdf7 100644
+--- a/qtwayland/src/client/qwaylandshmbackingstore.cpp
++++ b/qtwayland/src/client/qwaylandshmbackingstore.cpp
+@@ -52,6 +52,7 @@
+ 
+ #include <QtWaylandClient/private/wayland-wayland-client-protocol.h>
+ 
++#include <fcntl.h>
+ #include <unistd.h>
+ #include <sys/mman.h>
+ 
+@@ -61,6 +62,9 @@
+ #  ifndef MFD_CLOEXEC
+ #    define MFD_CLOEXEC     0x0001U
+ #  endif
++#  ifndef MFD_ALLOW_SEALING
++#    define MFD_ALLOW_SEALING 0x0002U
++#  endif
+ #endif
+ 
+ QT_BEGIN_NAMESPACE
+@@ -74,8 +78,10 @@ QWaylandShmBuffer::QWaylandShmBuffer(QWaylandDisplay *display,
+     int alloc = stride * size.height();
+     int fd = -1;
+ 
+-#ifdef SYS_memfd_create
+-    fd = syscall(SYS_memfd_create, "wayland-shm", MFD_CLOEXEC);
++#if defined(SYS_memfd_create) && defined(F_SEAL_SEAL)
++    fd = syscall(SYS_memfd_create, "wayland-shm", MFD_CLOEXEC | MFD_ALLOW_SEALING);
++    if (fd >= 0)
++        fcntl(fd, F_ADD_SEALS, F_SEAL_SHRINK | F_SEAL_SEAL);
+ #endif
+ 
+     QScopedPointer<QFile> filePointer;
+diff --git a/qtwayland/src/client/qwaylandwindow.cpp b/qtwayland/src/client/qwaylandwindow.cpp
+index cb82857a..fb2c59dc 100644
+--- a/qtwayland/src/client/qwaylandwindow.cpp
++++ b/qtwayland/src/client/qwaylandwindow.cpp
+@@ -76,7 +76,6 @@ QWaylandWindow *QWaylandWindow::mMouseGrab = nullptr;
+ QWaylandWindow::QWaylandWindow(QWindow *window, QWaylandDisplay *display)
+     : QPlatformWindow(window)
+     , mDisplay(display)
+-    , mFrameQueue(mDisplay->createFrameQueue())
+     , mResizeAfterSwap(qEnvironmentVariableIsSet("QT_WAYLAND_RESIZE_AFTER_SWAP"))
+ {
+     {
+@@ -95,9 +94,6 @@ QWaylandWindow::QWaylandWindow(QWindow *window, QWaylandDisplay *display)
+ 
+ QWaylandWindow::~QWaylandWindow()
+ {
+-    mDisplay->destroyFrameQueue(mFrameQueue);
+-    mDisplay->handleWindowDestroyed(this);
+-
+     delete mWindowDecoration;
+ 
+     if (mSurface)
+@@ -243,6 +239,7 @@ bool QWaylandWindow::shouldCreateSubSurface() const
+ 
+ void QWaylandWindow::reset()
+ {
++    closeChildPopups();
+     delete mShellSurface;
+     mShellSurface = nullptr;
+     delete mSubSurfaceWindow;
+@@ -255,17 +252,22 @@ void QWaylandWindow::reset()
+         mSurface.reset();
+     }
+ 
+-    if (mFrameCallback) {
+-        wl_callback_destroy(mFrameCallback);
+-        mFrameCallback = nullptr;
+-    }
++    {
++        QMutexLocker lock(&mFrameSyncMutex);
++        if (mFrameCallback) {
++            wl_callback_destroy(mFrameCallback);
++            mFrameCallback = nullptr;
++        }
+ 
+-    mFrameCallbackElapsedTimer.invalidate();
+-    mWaitingForFrameCallback = false;
++        mFrameCallbackElapsedTimer.invalidate();
++        mWaitingForFrameCallback = false;
++    }
+     mFrameCallbackTimedOut = false;
+ 
+     mMask = QRegion();
+     mQueuedBuffer = nullptr;
++
++    mDisplay->handleWindowDestroyed(this);
+ }
+ 
+ QWaylandWindow *QWaylandWindow::fromWlSurface(::wl_surface *surface)
+@@ -351,19 +353,25 @@ void QWaylandWindow::setGeometry_helper(const QRect &rect)
+     }
+ }
+ 
+-void QWaylandWindow::setGeometry(const QRect &rect)
++void QWaylandWindow::setGeometry(const QRect &r)
+ {
++    auto rect = r;
++    if (fixedToplevelPositions && !QPlatformWindow::parent() && window()->type() != Qt::Popup
++        && window()->type() != Qt::ToolTip) {
++        rect.moveTo(screen()->geometry().topLeft());
++    }
+     setGeometry_helper(rect);
+ 
+     if (window()->isVisible() && rect.isValid()) {
+         if (mWindowDecoration)
+             mWindowDecoration->update();
+ 
+-        if (mResizeAfterSwap && windowType() == Egl && mSentInitialResize)
++        if (mResizeAfterSwap && windowType() == Egl && mSentInitialResize) {
++            QMutexLocker lock(&mResizeLock);
+             mResizeDirty = true;
+-        else
++        } else {
+             QWindowSystemInterface::handleGeometryChange(window(), geometry());
+-
++        }
+         mSentInitialResize = true;
+     }
+     QRect exposeGeometry(QPoint(), geometry().size());
+@@ -374,7 +382,7 @@ void QWaylandWindow::setGeometry(const QRect &rect)
+         mShellSurface->setWindowGeometry(windowContentGeometry());
+ 
+     if (isOpaque() && mMask.isEmpty())
+-        setOpaqueArea(rect);
++        setOpaqueArea(QRect(QPoint(0, 0), rect.size()));
+ }
+ 
+ void QWaylandWindow::resizeFromApplyConfigure(const QSize &sizeWithMargins, const QPoint &offset)
+@@ -399,21 +407,6 @@ void QWaylandWindow::sendExposeEvent(const QRect &rect)
+     mLastExposeGeometry = rect;
+ }
+ 
+-
+-static QVector<QPointer<QWaylandWindow>> activePopups;
+-
+-void QWaylandWindow::closePopups(QWaylandWindow *parent)
+-{
+-    while (!activePopups.isEmpty()) {
+-        auto popup = activePopups.takeLast();
+-        if (popup.isNull())
+-            continue;
+-        if (popup.data() == parent)
+-            return;
+-        popup->reset();
+-    }
+-}
+-
+ QPlatformScreen *QWaylandWindow::calculateScreenFromSurfaceEvents() const
+ {
+     QReadLocker lock(&mSurfaceLock);
+@@ -433,10 +426,7 @@ void QWaylandWindow::setVisible(bool visible)
+     lastVisible = visible;
+ 
+     if (visible) {
+-        if (window()->type() == Qt::Popup || window()->type() == Qt::ToolTip)
+-            activePopups << this;
+         initWindow();
+-        mDisplay->flushRequests();
+ 
+         setGeometry(windowGeometry());
+         // Don't flush the events here, or else the newly visible window may start drawing, but since
+@@ -444,7 +434,6 @@ void QWaylandWindow::setVisible(bool visible)
+         // QWaylandShmBackingStore::beginPaint().
+     } else {
+         sendExposeEvent(QRect());
+-        closePopups(this);
+         reset();
+     }
+ }
+@@ -556,12 +545,12 @@ void QWaylandWindow::sendRecursiveExposeEvent()
+ 
+ void QWaylandWindow::attach(QWaylandBuffer *buffer, int x, int y)
+ {
+-    Q_ASSERT(!buffer->committed());
+     QReadLocker locker(&mSurfaceLock);
+     if (mSurface == nullptr)
+         return;
+ 
+     if (buffer) {
++        Q_ASSERT(!buffer->committed());
+         handleUpdate();
+         buffer->setBusy();
+ 
+@@ -583,7 +572,11 @@ void QWaylandWindow::damage(const QRect &rect)
+     if (mSurface == nullptr)
+         return;
+ 
+-    mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    const int s = scale();
++    if (mDisplay->compositorVersion() >= 4)
++        mSurface->damage_buffer(s * rect.x(), s * rect.y(), s * rect.width(), s * rect.height());
++    else
++        mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
+ }
+ 
+ void QWaylandWindow::safeCommit(QWaylandBuffer *buffer, const QRegion &damage)
+@@ -619,8 +612,14 @@ void QWaylandWindow::commit(QWaylandBuffer *buffer, const QRegion &damage)
+         return;
+ 
+     attachOffset(buffer);
+-    for (const QRect &rect: damage)
+-        mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    if (mDisplay->compositorVersion() >= 4) {
++        const int s = scale();
++        for (const QRect &rect: damage)
++            mSurface->damage_buffer(s * rect.x(), s * rect.y(), s * rect.width(), s * rect.height());
++    } else {
++        for (const QRect &rect: damage)
++            mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    }
+     Q_ASSERT(!buffer->committed());
+     buffer->setCommitted();
+     mSurface->commit();
+@@ -635,42 +634,53 @@ void QWaylandWindow::commit()
+ 
+ const wl_callback_listener QWaylandWindow::callbackListener = {
+     [](void *data, wl_callback *callback, uint32_t time) {
+-        Q_UNUSED(callback);
+         Q_UNUSED(time);
+         auto *window = static_cast<QWaylandWindow*>(data);
+-        window->handleFrameCallback();
++        window->handleFrameCallback(callback);
+     }
+ };
+ 
+-void QWaylandWindow::handleFrameCallback()
++void QWaylandWindow::handleFrameCallback(wl_callback* callback)
+ {
++    QMutexLocker locker(&mFrameSyncMutex);
++    if (!mFrameCallback) {
++        // This means the callback is already unset by QWaylandWindow::reset.
++        // The wl_callback object will be destroyed there too.
++        return;
++    }
++    Q_ASSERT(callback == mFrameCallback);
++    wl_callback_destroy(callback);
++    mFrameCallback = nullptr;
++
+     mWaitingForFrameCallback = false;
+     mFrameCallbackElapsedTimer.invalidate();
+ 
+     // The rest can wait until we can run it on the correct thread
+-    if (!mWaitingForUpdateDelivery) {
+-        auto doHandleExpose = [this]() {
+-            bool wasExposed = isExposed();
+-            mFrameCallbackTimedOut = false;
+-            if (!wasExposed && isExposed()) // Did setting mFrameCallbackTimedOut make the window exposed?
+-                sendExposeEvent(QRect(QPoint(), geometry().size()));
+-            if (wasExposed && hasPendingUpdateRequest())
+-                deliverUpdateRequest();
+-
+-            mWaitingForUpdateDelivery = false;
+-        };
++    auto doHandleExpose = [this]() {
++        mWaitingForUpdateDelivery.storeRelease(false);
++        bool wasExposed = isExposed();
++        mFrameCallbackTimedOut = false;
++        if (!wasExposed && isExposed()) // Did setting mFrameCallbackTimedOut make the window exposed?
++            sendExposeEvent(QRect(QPoint(), geometry().size()));
++        if (wasExposed && hasPendingUpdateRequest())
++            deliverUpdateRequest();
++    };
+ 
++    if (mWaitingForUpdateDelivery.testAndSetAcquire(false, true)) {
+         // Queued connection, to make sure we don't call handleUpdate() from inside waitForFrameSync()
+         // in the single-threaded case.
+-        mWaitingForUpdateDelivery = true;
+         QMetaObject::invokeMethod(this, doHandleExpose, Qt::QueuedConnection);
+     }
++
++    mFrameSyncWait.notify_all();
+ }
+ 
+ bool QWaylandWindow::waitForFrameSync(int timeout)
+ {
+-    QMutexLocker locker(mFrameQueue.mutex);
+-    mDisplay->dispatchQueueWhile(mFrameQueue.queue, [&]() { return mWaitingForFrameCallback; }, timeout);
++    QMutexLocker locker(&mFrameSyncMutex);
++
++    QDeadlineTimer deadline(timeout);
++    while (mWaitingForFrameCallback && mFrameSyncWait.wait(&mFrameSyncMutex, deadline)) { }
+ 
+     if (mWaitingForFrameCallback) {
+         qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
+@@ -868,6 +878,17 @@ bool QWaylandWindow::createDecoration()
+             subsurf->set_position(pos.x() + m.left(), pos.y() + m.top());
+         }
+         sendExposeEvent(QRect(QPoint(), geometry().size()));
++
++        // This is a special case where the buffer is recreated, but since
++        // the content rect remains the same, the widgets remain the same
++        // size and are not redrawn, leaving the new buffer empty. As a simple
++        // work-around, we trigger a full extra update whenever the client-side
++        // window decorations are toggled while the window is showing.
++        // Note: createDecoration() is sometimes called from the render thread
++        // of Qt Quick. This is essentially wrong and could potentially cause problems,
++        // but until the underlying issue has been fixed, we have to use invokeMethod()
++        // here to avoid asserts.
++        QMetaObject::invokeMethod(window(), &QWindow::requestUpdate);
+     }
+ 
+     return mWindowDecoration;
+@@ -1023,6 +1044,13 @@ void QWaylandWindow::handleScreensChanged()
+ 
+     QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->QPlatformScreen::screen());
+     mLastReportedScreen = newScreen;
++    if (fixedToplevelPositions && !QPlatformWindow::parent() && window()->type() != Qt::Popup
++        && window()->type() != Qt::ToolTip
++        && geometry().topLeft() != newScreen->geometry().topLeft()) {
++        auto geometry = this->geometry();
++        geometry.moveTo(newScreen->geometry().topLeft());
++        setGeometry(geometry);
++    }
+ 
+     int scale = newScreen->isPlaceholder() ? 1 : static_cast<QWaylandScreen *>(newScreen)->scale();
+     if (scale != mScale) {
+@@ -1094,10 +1122,18 @@ bool QWaylandWindow::setMouseGrabEnabled(bool grab)
+     return true;
+ }
+ 
++Qt::WindowStates QWaylandWindow::windowStates() const
++{
++    return mLastReportedWindowStates;
++}
++
+ void QWaylandWindow::handleWindowStatesChanged(Qt::WindowStates states)
+ {
+     createDecoration();
+-    QWindowSystemInterface::handleWindowStateChanged(window(), states, mLastReportedWindowStates);
++    Qt::WindowStates statesWithoutActive = states & ~Qt::WindowActive;
++    Qt::WindowStates lastStatesWithoutActive = mLastReportedWindowStates & ~Qt::WindowActive;
++    QWindowSystemInterface::handleWindowStateChanged(window(), statesWithoutActive,
++                                                     lastStatesWithoutActive);
+     mLastReportedWindowStates = states;
+ }
+ 
+@@ -1139,19 +1175,24 @@ void QWaylandWindow::timerEvent(QTimerEvent *event)
+     if (event->timerId() != mFrameCallbackCheckIntervalTimerId)
+         return;
+ 
+-    bool callbackTimerExpired = mFrameCallbackElapsedTimer.hasExpired(mFrameCallbackTimeout);
+-    if (!mFrameCallbackElapsedTimer.isValid() || callbackTimerExpired ) {
+-        killTimer(mFrameCallbackCheckIntervalTimerId);
+-        mFrameCallbackCheckIntervalTimerId = -1;
+-    }
+-    if (mFrameCallbackElapsedTimer.isValid() && callbackTimerExpired) {
+-        mFrameCallbackElapsedTimer.invalidate();
++    {
++        QMutexLocker lock(&mFrameSyncMutex);
+ 
+-        qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
+-        mFrameCallbackTimedOut = true;
+-        mWaitingForUpdate = false;
+-        sendExposeEvent(QRect());
++        bool callbackTimerExpired = mFrameCallbackElapsedTimer.hasExpired(mFrameCallbackTimeout);
++        if (!mFrameCallbackElapsedTimer.isValid() || callbackTimerExpired ) {
++            killTimer(mFrameCallbackCheckIntervalTimerId);
++            mFrameCallbackCheckIntervalTimerId = -1;
++        }
++        if (!mFrameCallbackElapsedTimer.isValid() || !callbackTimerExpired) {
++            return;
++        }
++        mFrameCallbackElapsedTimer.invalidate();
+     }
++
++    qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
++    mFrameCallbackTimedOut = true;
++    mWaitingForUpdate = false;
++    sendExposeEvent(QRect());
+ }
+ 
+ void QWaylandWindow::requestUpdate()
+@@ -1160,8 +1201,11 @@ void QWaylandWindow::requestUpdate()
+     Q_ASSERT(hasPendingUpdateRequest()); // should be set by QPA
+ 
+     // If we have a frame callback all is good and will be taken care of there
+-    if (mWaitingForFrameCallback)
+-        return;
++    {
++        QMutexLocker locker(&mFrameSyncMutex);
++        if (mWaitingForFrameCallback)
++            return;
++    }
+ 
+     // If we've already called deliverUpdateRequest(), but haven't seen any attach+commit/swap yet
+     // This is a somewhat redundant behavior and might indicate a bug in the calling code, so log
+@@ -1174,7 +1218,12 @@ void QWaylandWindow::requestUpdate()
+     // so use invokeMethod to delay the delivery a bit.
+     QMetaObject::invokeMethod(this, [this] {
+         // Things might have changed in the meantime
+-        if (hasPendingUpdateRequest() && !mWaitingForFrameCallback)
++        {
++            QMutexLocker locker(&mFrameSyncMutex);
++            if (mWaitingForFrameCallback)
++                return;
++        }
++        if (hasPendingUpdateRequest())
+             deliverUpdateRequest();
+     }, Qt::QueuedConnection);
+ }
+@@ -1185,19 +1234,18 @@ void QWaylandWindow::requestUpdate()
+ void QWaylandWindow::handleUpdate()
+ {
+     qCDebug(lcWaylandBackingstore) << "handleUpdate" << QThread::currentThread();
++
+     // TODO: Should sync subsurfaces avoid requesting frame callbacks?
+     QReadLocker lock(&mSurfaceLock);
+     if (!mSurface)
+         return;
+ 
+-    if (mFrameCallback) {
+-        wl_callback_destroy(mFrameCallback);
+-        mFrameCallback = nullptr;
+-    }
++    QMutexLocker locker(&mFrameSyncMutex);
++    if (mWaitingForFrameCallback)
++        return;
+ 
+-    QMutexLocker locker(mFrameQueue.mutex);
+     struct ::wl_surface *wrappedSurface = reinterpret_cast<struct ::wl_surface *>(wl_proxy_create_wrapper(mSurface->object()));
+-    wl_proxy_set_queue(reinterpret_cast<wl_proxy *>(wrappedSurface), mFrameQueue.queue);
++    wl_proxy_set_queue(reinterpret_cast<wl_proxy *>(wrappedSurface), mDisplay->frameEventQueue());
+     mFrameCallback = wl_surface_frame(wrappedSurface);
+     wl_proxy_wrapper_destroy(wrappedSurface);
+     wl_callback_add_listener(mFrameCallback, &QWaylandWindow::callbackListener, this);
+@@ -1207,6 +1255,8 @@ void QWaylandWindow::handleUpdate()
+     // Start a timer for handling the case when the compositor stops sending frame callbacks.
+     if (mFrameCallbackTimeout > 0) {
+         QMetaObject::invokeMethod(this, [this] {
++            QMutexLocker locker(&mFrameSyncMutex);
++
+             if (mWaitingForFrameCallback) {
+                 if (mFrameCallbackCheckIntervalTimerId < 0)
+                     mFrameCallbackCheckIntervalTimerId = startTimer(mFrameCallbackTimeout);
+@@ -1267,6 +1317,20 @@ void QWaylandWindow::setOpaqueArea(const QRegion &opaqueArea)
+     wl_region_destroy(region);
+ }
+ 
++void QWaylandWindow::addChildPopup(QWaylandWindow *surface) {
++    mChildPopups.append(surface);
++}
++
++void QWaylandWindow::removeChildPopup(QWaylandWindow *surface) {
++    mChildPopups.removeAll(surface);
++}
++
++void QWaylandWindow::closeChildPopups() {
++    while (!mChildPopups.isEmpty()) {
++        auto popup = mChildPopups.takeLast();
++        popup->reset();
++    }
++}
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/client/qwaylandwindow_p.h b/qtwayland/src/client/qwaylandwindow_p.h
+index 01337cff..2f219d8c 100644
+--- a/qtwayland/src/client/qwaylandwindow_p.h
++++ b/qtwayland/src/client/qwaylandwindow_p.h
+@@ -98,6 +98,9 @@ public:
+     QWaylandWindow(QWindow *window, QWaylandDisplay *display);
+     ~QWaylandWindow() override;
+ 
++    // Keep Toplevels position on the top left corner of their screen
++    static inline bool fixedToplevelPositions = true;
++
+     virtual WindowType windowType() const = 0;
+     virtual void ensureSize();
+     WId winId() const override;
+@@ -148,6 +151,7 @@ public:
+     void setWindowState(Qt::WindowStates states) override;
+     void setWindowFlags(Qt::WindowFlags flags) override;
+     void handleWindowStatesChanged(Qt::WindowStates states);
++    Qt::WindowStates windowStates() const;
+ 
+     void raise() override;
+     void lower() override;
+@@ -206,6 +210,10 @@ public:
+     void handleUpdate();
+     void deliverUpdateRequest() override;
+ 
++    void addChildPopup(QWaylandWindow* child);
++    void removeChildPopup(QWaylandWindow* child);
++    void closeChildPopups();
++
+ public slots:
+     void applyConfigure();
+ 
+@@ -215,7 +223,11 @@ signals:
+ 
+ protected:
+     QWaylandDisplay *mDisplay = nullptr;
++
++    // mSurface can be written by the main thread. Other threads should claim a read lock for access
++    mutable QReadWriteLock mSurfaceLock;
+     QScopedPointer<QWaylandSurface> mSurface;
++
+     QWaylandShellSurface *mShellSurface = nullptr;
+     QWaylandSubSurface *mSubSurfaceWindow = nullptr;
+     QVector<QWaylandSubSurface *> mChildren;
+@@ -225,13 +237,14 @@ protected:
+     Qt::MouseButtons mMousePressedInContentArea = Qt::NoButton;
+ 
+     WId mWindowId;
+-    bool mWaitingForFrameCallback = false;
+     bool mFrameCallbackTimedOut = false; // Whether the frame callback has timed out
+-    bool mWaitingForUpdateDelivery = false;
+     int mFrameCallbackCheckIntervalTimerId = -1;
+-    QElapsedTimer mFrameCallbackElapsedTimer;
+-    struct ::wl_callback *mFrameCallback = nullptr;
+-    QWaylandDisplay::FrameQueue mFrameQueue;
++    QAtomicInt mWaitingForUpdateDelivery = false;
++
++    bool mWaitingForFrameCallback = false; // Protected by mFrameSyncMutex
++    QElapsedTimer mFrameCallbackElapsedTimer; // Protected by mFrameSyncMutex
++    struct ::wl_callback *mFrameCallback = nullptr; // Protected by mFrameSyncMutex
++    QMutex mFrameSyncMutex;
+     QWaitCondition mFrameSyncWait;
+ 
+     // True when we have called deliverRequestUpdate, but the client has not yet attached a new buffer
+@@ -261,6 +274,8 @@ protected:
+     QWaylandBuffer *mQueuedBuffer = nullptr;
+     QRegion mQueuedBufferDamage;
+ 
++    QList<QPointer<QWaylandWindow>> mChildPopups;
++
+ private:
+     void setGeometry_helper(const QRect &rect);
+     void initWindow();
+@@ -283,12 +298,10 @@ private:
+     QRect mLastExposeGeometry;
+ 
+     static const wl_callback_listener callbackListener;
+-    void handleFrameCallback();
++    void handleFrameCallback(struct ::wl_callback* callback);
+ 
+     static QWaylandWindow *mMouseGrab;
+ 
+-    mutable QReadWriteLock mSurfaceLock;
+-
+     friend class QWaylandSubSurface;
+ };
+ 
+diff --git a/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h b/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
+index ccad0048..4cc9b3b8 100644
+--- a/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
++++ b/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
+@@ -73,11 +73,10 @@ public:
+         return true;
+     }
+     virtual QWaylandShellSurface *createShellSurface(QWaylandWindow *window) = 0;
++    // kept for binary compat with layer-shell-qt
+     virtual void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) {
+-        if (newFocus)
+-            m_display->handleWindowActivated(newFocus);
+-        if (oldFocus)
+-            m_display->handleWindowDeactivated(oldFocus);
++        Q_UNUSED(newFocus);
++        Q_UNUSED(oldFocus);
+     }
+     virtual void *nativeResourceForWindow(const QByteArray &resource, QWindow *window) {
+         Q_UNUSED(resource);
+diff --git a/qtwayland/src/compositor/configure.json b/qtwayland/src/compositor/configure.json
+index bcfd5215..da95d07b 100644
+--- a/qtwayland/src/compositor/configure.json
++++ b/qtwayland/src/compositor/configure.json
+@@ -7,6 +7,31 @@
+     "testDir": "../../config.tests",
+ 
+     "libraries": {
++        "wayland-client": {
++            "label": "Wayland client library",
++            "headers": "wayland-version.h",
++            "test": {
++                "main": [
++                    "#if WAYLAND_VERSION_MAJOR < 1",
++                    "# error Wayland 1.8.0 or higher required",
++                    "#endif",
++                    "#if WAYLAND_VERSION_MAJOR == 1",
++                    "# if WAYLAND_VERSION_MINOR < 8",
++                    "#  error Wayland 1.8.0 or higher required",
++                    "# endif",
++                    "# if WAYLAND_VERSION_MINOR == 8",
++                    "#  if WAYLAND_VERSION_MICRO < 0",
++                    "#   error Wayland 1.8.0 or higher required",
++                    "#  endif",
++                    "# endif",
++                    "#endif"
++                 ]
++            },
++            "sources": [
++                { "type": "pkgConfig", "args": "wayland-client" },
++                "-lwayland-client"
++            ]
++        },
+         "wayland-server": {
+             "label": "wayland-server",
+             "headers": "wayland-version.h",
+@@ -151,8 +176,7 @@
+                     "#endif"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "dmabuf-client-buffer": {
+             "label": "Linux Client dma-buf Buffer Sharing",
+@@ -176,8 +200,7 @@
+                     "return 0;"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "vulkan-server-buffer": {
+             "label": "Vulkan Buffer Sharing",
+@@ -195,7 +218,8 @@
+                     "exportAllocInfo.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR;",
+                     "return 0;"
+                 ]
+-            }
++            },
++            "use": "wayland-client"
+         }
+     },
+ 
+diff --git a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
+index 7889f575..64140672 100644
+--- a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
++++ b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
+@@ -40,6 +40,7 @@
+ #include "qwaylandeglwindow.h"
+ 
+ #include <QtWaylandClient/private/qwaylandscreen_p.h>
++#include <QtWaylandClient/private/qwaylandsurface_p.h>
+ #include "qwaylandglcontext.h"
+ 
+ #include <QtEglSupport/private/qeglconvenience_p.h>
+@@ -124,6 +125,7 @@ void QWaylandEglWindow::updateSurface(bool create)
+         }
+         mOffset = QPoint();
+     } else {
++        QReadLocker locker(&mSurfaceLock);
+         if (m_waylandEglWindow) {
+             int current_width, current_height;
+             static bool disableResizeCheck = qgetenv("QT_WAYLAND_DISABLE_RESIZECHECK").toInt();
+@@ -131,14 +133,16 @@ void QWaylandEglWindow::updateSurface(bool create)
+             if (!disableResizeCheck) {
+                 wl_egl_window_get_attached_size(m_waylandEglWindow, &current_width, &current_height);
+             }
+-            if (disableResizeCheck || (current_width != sizeWithMargins.width() || current_height != sizeWithMargins.height())) {
++            if (disableResizeCheck || (current_width != sizeWithMargins.width() || current_height != sizeWithMargins.height()) || m_requestedSize != sizeWithMargins) {
+                 wl_egl_window_resize(m_waylandEglWindow, sizeWithMargins.width(), sizeWithMargins.height(), mOffset.x(), mOffset.y());
++                m_requestedSize = sizeWithMargins;
+                 mOffset = QPoint();
+ 
+                 m_resize = true;
+             }
+-        } else if (create && wlSurface()) {
+-            m_waylandEglWindow = wl_egl_window_create(wlSurface(), sizeWithMargins.width(), sizeWithMargins.height());
++        } else if (create && mSurface) {
++            m_waylandEglWindow = wl_egl_window_create(mSurface->object(), sizeWithMargins.width(), sizeWithMargins.height());
++            m_requestedSize = sizeWithMargins;
+         }
+ 
+         if (!m_eglSurface && m_waylandEglWindow && create) {
+diff --git a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
+index 5b1f4d56..0079dfef 100644
+--- a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
++++ b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
+@@ -88,6 +88,7 @@ private:
+     mutable QOpenGLFramebufferObject *m_contentFBO = nullptr;
+ 
+     QSurfaceFormat m_format;
++    QSize m_requestedSize;
+ };
+ 
+ }
+diff --git a/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h b/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
+index 56a710c3..c6a8b6c6 100644
+--- a/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
++++ b/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
+@@ -41,6 +41,8 @@
+ #include <QtCore/QTextStream>
+ #include <QtGui/QOpenGLTexture>
+ 
++#include <array>
++
+ #include <EGL/egl.h>
+ #include <EGL/eglext.h>
+ 
+diff --git a/qtwayland/src/plugins/decorations/bradient/main.cpp b/qtwayland/src/plugins/decorations/bradient/main.cpp
+index e75fda3c..fa885143 100644
+--- a/qtwayland/src/plugins/decorations/bradient/main.cpp
++++ b/qtwayland/src/plugins/decorations/bradient/main.cpp
+@@ -164,13 +164,10 @@ void QWaylandBradientDecoration::paint(QPaintDevice *device)
+     // Window icon
+     QIcon icon = waylandWindow()->windowIcon();
+     if (!icon.isNull()) {
+-        QPixmap pixmap = icon.pixmap(QSize(128, 128));
+-        QPixmap scaled = pixmap.scaled(22, 22, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+-
+         QRectF iconRect(0, 0, 22, 22);
+-        p.drawPixmap(iconRect.adjusted(margins().left() + BUTTON_SPACING, 4,
+-                                       margins().left() + BUTTON_SPACING, 4),
+-                     scaled, iconRect);
++        iconRect.adjust(margins().left() + BUTTON_SPACING, 4,
++                        margins().left() + BUTTON_SPACING, 4),
++        icon.paint(&p, iconRect.toRect());
+     }
+ 
+     // Window title
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
+index 85d25e3c..60bdd491 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
+@@ -47,18 +47,21 @@ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
+-QWaylandXdgPopupV5::QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow *window)
++QWaylandXdgPopupV5::QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow* parent, QWaylandWindow *window)
+     : QWaylandShellSurface(window)
+     , QtWayland::xdg_popup_v5(popup)
++    , m_parent(parent)
+     , m_window(window)
+ {
+     if (window->display()->windowExtension())
+         m_extendedWindow = new QWaylandExtendedSurface(window);
++    m_parent->addChildPopup(m_window);
+ }
+ 
+ QWaylandXdgPopupV5::~QWaylandXdgPopupV5()
+ {
+     xdg_popup_destroy(object());
++    m_parent->removeChildPopup(m_window);
+     delete m_extendedWindow;
+ }
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
+index 7494f6a6..d85f130b 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
+@@ -70,7 +70,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgPopupV5 : public QWaylandShellSurface
+ {
+     Q_OBJECT
+ public:
+-    QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow *window);
++    QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow* parent, QWaylandWindow *window);
+     ~QWaylandXdgPopupV5() override;
+ 
+ protected:
+@@ -78,6 +78,7 @@ protected:
+ 
+ private:
+     QWaylandExtendedSurface *m_extendedWindow = nullptr;
++    QWaylandWindow *m_parent = nullptr;
+     QWaylandWindow *m_window = nullptr;
+ };
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
+index 7e242c4a..def8452a 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
+@@ -84,7 +84,7 @@ QWaylandXdgPopupV5 *QWaylandXdgShellV5::createXdgPopup(QWaylandWindow *window, Q
+     int x = position.x() + parentWindow->frameMargins().left();
+     int y = position.y() + parentWindow->frameMargins().top();
+ 
+-    auto popup = new QWaylandXdgPopupV5(get_xdg_popup(window->wlSurface(), parentSurface, seat, m_popupSerial, x, y), window);
++    auto popup = new QWaylandXdgPopupV5(get_xdg_popup(window->wlSurface(), parentSurface, seat, m_popupSerial, x, y), parentWindow, window);
+     m_popups.append(window);
+     QObject::connect(popup, &QWaylandXdgPopupV5::destroyed, [this, window](){
+         m_popups.removeOne(window);
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
+index 4e25949f..cfc60939 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
+@@ -85,13 +85,6 @@ QWaylandShellSurface *QWaylandXdgShellV5Integration::createShellSurface(QWayland
+     return m_xdgShell->createXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellV5Integration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) {
+-    if (newFocus && qobject_cast<QWaylandXdgPopupV5 *>(newFocus->shellSurface()))
+-        m_display->handleWindowActivated(newFocus);
+-    if (oldFocus && qobject_cast<QWaylandXdgPopupV5 *>(oldFocus->shellSurface()))
+-        m_display->handleWindowDeactivated(oldFocus);
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
+index ce6bdb9e..aed88670 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
+@@ -67,7 +67,6 @@ public:
+     QWaylandXdgShellV5Integration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShellV5> m_xdgShell;
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
+index 8c371661..151c78e3 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
+@@ -174,6 +174,7 @@ QWaylandXdgSurfaceV6::Popup::Popup(QWaylandXdgSurfaceV6 *xdgSurface, QWaylandXdg
+     , m_xdgSurface(xdgSurface)
+     , m_parent(parent)
+ {
++    m_parent->window()->addChildPopup(m_xdgSurface->window());
+ }
+ 
+ QWaylandXdgSurfaceV6::Popup::~Popup()
+@@ -181,6 +182,8 @@ QWaylandXdgSurfaceV6::Popup::~Popup()
+     if (isInitialized())
+         destroy();
+ 
++    m_parent->window()->removeChildPopup(m_xdgSurface->window());
++
+     if (m_grabbing) {
+         auto *shell = m_xdgSurface->m_shell;
+         Q_ASSERT(shell->m_topmostGrabbingPopup == this);
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
+index 03164316..e8da8ba1 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
+@@ -68,20 +68,6 @@ QWaylandShellSurface *QWaylandXdgShellV6Integration::createShellSurface(QWayland
+     return m_xdgShell->getXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellV6Integration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus)
+-{
+-    if (newFocus) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurfaceV6 *>(newFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowActivated(newFocus);
+-    }
+-    if (oldFocus && qobject_cast<QWaylandXdgSurfaceV6 *>(oldFocus->shellSurface())) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurfaceV6 *>(oldFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowDeactivated(oldFocus);
+-    }
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
+index 261f8cbb..c1bcd5c6 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
+@@ -65,7 +65,6 @@ public:
+     QWaylandXdgShellV6Integration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShellV6> m_xdgShell;
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
+index f3e3c330..fa6d5808 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
+@@ -67,11 +67,6 @@ QWaylandXdgSurface::Toplevel::Toplevel(QWaylandXdgSurface *xdgSurface)
+ 
+ QWaylandXdgSurface::Toplevel::~Toplevel()
+ {
+-    if (m_applied.states & Qt::WindowActive) {
+-        QWaylandWindow *window = m_xdgSurface->window();
+-        window->display()->handleWindowDeactivated(window);
+-    }
+-
+     // The protocol spec requires that the decoration object is deleted before xdg_toplevel.
+     delete m_decoration;
+     m_decoration = nullptr;
+@@ -85,16 +80,15 @@ void QWaylandXdgSurface::Toplevel::applyConfigure()
+     if (!(m_applied.states & (Qt::WindowMaximized|Qt::WindowFullScreen)))
+         m_normalSize = m_xdgSurface->m_window->windowFrameGeometry().size();
+ 
+-    if ((m_pending.states & Qt::WindowActive) && !(m_applied.states & Qt::WindowActive))
++    if ((m_pending.states & Qt::WindowActive) && !(m_applied.states & Qt::WindowActive)
++        && !m_xdgSurface->m_window->display()->isKeyboardAvailable())
+         m_xdgSurface->m_window->display()->handleWindowActivated(m_xdgSurface->m_window);
+ 
+-    if (!(m_pending.states & Qt::WindowActive) && (m_applied.states & Qt::WindowActive))
++    if (!(m_pending.states & Qt::WindowActive) && (m_applied.states & Qt::WindowActive)
++        && !m_xdgSurface->m_window->display()->isKeyboardAvailable())
+         m_xdgSurface->m_window->display()->handleWindowDeactivated(m_xdgSurface->m_window);
+ 
+-    // TODO: none of the other plugins send WindowActive either, but is it on purpose?
+-    Qt::WindowStates statesWithoutActive = m_pending.states & ~Qt::WindowActive;
+-
+-    m_xdgSurface->m_window->handleWindowStatesChanged(statesWithoutActive);
++    m_xdgSurface->m_window->handleWindowStatesChanged(m_pending.states);
+ 
+     if (m_pending.size.isEmpty()) {
+         // An empty size in the configure means it's up to the client to choose the size
+@@ -105,8 +99,6 @@ void QWaylandXdgSurface::Toplevel::applyConfigure()
+         m_xdgSurface->m_window->resizeFromApplyConfigure(m_pending.size);
+     }
+ 
+-    m_xdgSurface->setSizeHints();
+-
+     m_applied = m_pending;
+     qCDebug(lcQpaWayland) << "Applied pending xdg_toplevel configure event:" << m_applied.size << m_applied.states;
+ }
+@@ -203,12 +195,17 @@ QtWayland::xdg_toplevel::resize_edge QWaylandXdgSurface::Toplevel::convertToResi
+                 | ((edges & Qt::RightEdge) ? resize_edge_right : 0));
+ }
+ 
+-QWaylandXdgSurface::Popup::Popup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parent,
++QWaylandXdgSurface::Popup::Popup(QWaylandXdgSurface *xdgSurface, QWaylandWindow *parent,
+                                  QtWayland::xdg_positioner *positioner)
+-    : xdg_popup(xdgSurface->get_popup(parent->object(), positioner->object()))
+-    , m_xdgSurface(xdgSurface)
++    : m_xdgSurface(xdgSurface)
++    , m_parentXdgSurface(qobject_cast<QWaylandXdgSurface *>(parent->shellSurface()))
+     , m_parent(parent)
+ {
++
++    init(xdgSurface->get_popup(m_parentXdgSurface ? m_parentXdgSurface->object() : nullptr, positioner->object()));
++    if (m_parent) {
++        m_parent->addChildPopup(m_xdgSurface->window());
++    }
+ }
+ 
+ QWaylandXdgSurface::Popup::~Popup()
+@@ -216,10 +213,24 @@ QWaylandXdgSurface::Popup::~Popup()
+     if (isInitialized())
+         destroy();
+ 
++    if (m_parent) {
++        m_parent->removeChildPopup(m_xdgSurface->window());
++    }
++
+     if (m_grabbing) {
+         auto *shell = m_xdgSurface->m_shell;
+         Q_ASSERT(shell->m_topmostGrabbingPopup == this);
+-        shell->m_topmostGrabbingPopup = m_parent->m_popup;
++        shell->m_topmostGrabbingPopup = m_parentXdgSurface ? m_parentXdgSurface->m_popup : nullptr;
++        m_grabbing = false;
++
++        // Synthesize Qt enter/leave events for popup
++        QWindow *leave = nullptr;
++        if (m_xdgSurface && m_xdgSurface->window())
++            leave = m_xdgSurface->window()->window();
++        QWindowSystemInterface::handleLeaveEvent(leave);
++
++        if (QWindow *enter = QGuiApplication::topLevelAt(QCursor::pos()))
++            QWindowSystemInterface::handleEnterEvent(enter, enter->mapFromGlobal(QCursor::pos()), QCursor::pos());
+     }
+ }
+ 
+@@ -257,6 +268,7 @@ QWaylandXdgSurface::QWaylandXdgSurface(QWaylandXdgShell *shell, ::xdg_surface *s
+                 m_toplevel->set_parent(parentXdgSurface->m_toplevel->object());
+         }
+     }
++    setSizeHints();
+ }
+ 
+ QWaylandXdgSurface::~QWaylandXdgSurface()
+@@ -400,8 +412,6 @@ void QWaylandXdgSurface::setPopup(QWaylandWindow *parent)
+ {
+     Q_ASSERT(!m_toplevel && !m_popup);
+ 
+-    auto parentXdgSurface = static_cast<QWaylandXdgSurface *>(parent->shellSurface());
+-
+     auto positioner = new QtWayland::xdg_positioner(m_shell->create_positioner());
+     // set_popup expects a position relative to the parent
+     QPoint transientPos = m_window->geometry().topLeft(); // this is absolute
+@@ -414,8 +424,9 @@ void QWaylandXdgSurface::setPopup(QWaylandWindow *parent)
+     positioner->set_anchor(QtWayland::xdg_positioner::anchor_top_left);
+     positioner->set_gravity(QtWayland::xdg_positioner::gravity_bottom_right);
+     positioner->set_size(m_window->geometry().width(), m_window->geometry().height());
+-    m_popup = new Popup(this, parentXdgSurface, positioner);
++    m_popup = new Popup(this, parent, positioner);
+     positioner->destroy();
++
+     delete positioner;
+ }
+ 
+@@ -437,6 +448,23 @@ void QWaylandXdgSurface::setGrabPopup(QWaylandWindow *parent, QWaylandInputDevic
+     }
+     setPopup(parent);
+     m_popup->grab(device, serial);
++
++    // Synthesize Qt enter/leave events for popup
++    if (!parent)
++        return;
++    QWindow *current = QGuiApplication::topLevelAt(QCursor::pos());
++    QWindow *leave = parent->window();
++    if (current != leave)
++        return;
++
++    QWindowSystemInterface::handleLeaveEvent(leave);
++
++    QWindow *enter = nullptr;
++    if (m_popup && m_popup->m_xdgSurface && m_popup->m_xdgSurface->window())
++        enter = m_popup->m_xdgSurface->window()->window();
++
++    if (enter)
++        QWindowSystemInterface::handleEnterEvent(enter, enter->mapFromGlobal(QCursor::pos()), QCursor::pos());
+ }
+ 
+ void QWaylandXdgSurface::xdg_surface_configure(uint32_t serial)
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
+index 96785205..4b518f0a 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
+@@ -131,14 +131,15 @@ private:
+ 
+     class Popup : public QtWayland::xdg_popup {
+     public:
+-        Popup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parent, QtWayland::xdg_positioner *positioner);
++        Popup(QWaylandXdgSurface *xdgSurface, QWaylandWindow *parent, QtWayland::xdg_positioner *positioner);
+         ~Popup() override;
+ 
+         void grab(QWaylandInputDevice *seat, uint serial);
+         void xdg_popup_popup_done() override;
+ 
+         QWaylandXdgSurface *m_xdgSurface = nullptr;
+-        QWaylandXdgSurface *m_parent = nullptr;
++        QWaylandXdgSurface *m_parentXdgSurface = nullptr;
++        QWaylandWindow *m_parent = nullptr;
+         bool m_grabbing = false;
+     };
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
+index 8769d971..da0dd6a7 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
+@@ -69,20 +69,6 @@ QWaylandShellSurface *QWaylandXdgShellIntegration::createShellSurface(QWaylandWi
+     return m_xdgShell->getXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellIntegration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus)
+-{
+-    if (newFocus) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurface *>(newFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowActivated(newFocus);
+-    }
+-    if (oldFocus && qobject_cast<QWaylandXdgSurface *>(oldFocus->shellSurface())) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurface *>(oldFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowDeactivated(oldFocus);
+-    }
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
+index b6caa6c9..2f929f98 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
+@@ -65,7 +65,6 @@ public:
+     QWaylandXdgShellIntegration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShell> m_xdgShell;
+diff --git a/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp b/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
+index 526d0ef4..f50ccf30 100644
+--- a/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
++++ b/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
+@@ -39,7 +39,10 @@
+ 
+ #include "qwaylandinputmethodeventbuilder_p.h"
+ 
++#include <QBrush>
++#include <QGuiApplication>
+ #include <QInputMethod>
++#include <QPalette>
+ #include <QTextCharFormat>
+ 
+ #ifdef QT_BUILD_WAYLANDCOMPOSITOR_LIB
+@@ -81,32 +84,38 @@ void QWaylandInputMethodEventBuilder::addPreeditStyling(uint32_t index, uint32_t
+     QTextCharFormat format;
+ 
+     switch (style) {
+-    case 0:
+-    case 1:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_NONE:
++        break;
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_DEFAULT:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_UNDERLINE:
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-    case 2:
+-    case 3:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_ACTIVE:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_INACTIVE:
+         format.setFontWeight(QFont::Bold);
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-    case 4:
+-        format.setFontUnderline(true);
+-        format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+-        m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_HIGHLIGHT:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_SELECTION:
++        {
++            format.setFontUnderline(true);
++            format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
++            QPalette palette = qApp->palette();
++            format.setBackground(QBrush(palette.color(QPalette::Active, QPalette::Highlight)));
++            format.setForeground(QBrush(palette.color(QPalette::Active, QPalette::HighlightedText)));
++            m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
++        }
+         break;
+-    case 5:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_INCORRECT:
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::WaveUnderline);
+         format.setUnderlineColor(QColor(Qt::red));
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-//    case QtWayland::wl_text_input::preedit_style_selection:
+-//    case QtWayland::wl_text_input::preedit_style_none:
+     default:
+         break;
+     }
+@@ -153,7 +162,7 @@ QInputMethodEvent QWaylandInputMethodEventBuilder::buildPreedit(const QString &t
+ 
+     if (m_preeditCursor < 0) {
+         attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, 0, QVariant()));
+-    } else if (m_preeditCursor > 0) {
++    } else {
+         attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, indexFromWayland(text, m_preeditCursor), 1, QVariant()));
+     }
+ 
+diff --git a/qtwayland/src/shared/qwaylandmimehelper.cpp b/qtwayland/src/shared/qwaylandmimehelper.cpp
+index a5fdd34d..e2fe1928 100644
+--- a/qtwayland/src/shared/qwaylandmimehelper.cpp
++++ b/qtwayland/src/shared/qwaylandmimehelper.cpp
+@@ -60,7 +60,7 @@ QByteArray QWaylandMimeHelper::getByteArray(QMimeData *mimeData, const QString &
+             buf.open(QIODevice::ReadWrite);
+             QByteArray fmt = "BMP";
+             if (mimeType.startsWith(QLatin1String("image/"))) {
+-                QByteArray imgFmt = mimeType.mid(6).toUpper().toLatin1();
++                QByteArray imgFmt = mimeType.mid(6).toLower().toLatin1();
+                 if (QImageWriter::supportedImageFormats().contains(imgFmt))
+                     fmt = imgFmt;
+             }
+@@ -74,7 +74,7 @@ QByteArray QWaylandMimeHelper::getByteArray(QMimeData *mimeData, const QString &
+         QList<QUrl> urls = mimeData->urls();
+         for (int i = 0; i < urls.count(); ++i) {
+             content.append(urls.at(i).toEncoded());
+-            content.append('\n');
++            content.append("\r\n");
+         }
+     } else {
+         content = mimeData->data(mimeType);
+diff --git a/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp b/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
+index 1568b3b9..067410d0 100644
+--- a/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
++++ b/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
+@@ -35,7 +35,7 @@
+ 
+ using namespace MockCompositor;
+ 
+-constexpr int dataDeviceVersion = 1;
++constexpr int dataDeviceVersion = 3;
+ 
+ class DataDeviceCompositor : public DefaultCompositor {
+ public:
+diff --git a/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp b/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
+index 9312c2e5..2ea382f1 100644
+--- a/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
++++ b/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
+@@ -73,6 +73,7 @@ private slots:
+     void multiTouch();
+     void multiTouchUpAndMotionFrame();
+     void tapAndMoveInSameFrame();
++    void cancelTouch();
+ };
+ 
+ void tst_seatv5::bindsToSeat()
+@@ -646,5 +647,34 @@ void tst_seatv5::tapAndMoveInSameFrame()
+     QTRY_COMPARE(window.m_events.last().touchPoints.first().state(), Qt::TouchPointState::TouchPointReleased);
+ }
+ 
++void tst_seatv5::cancelTouch()
++{
++    TouchWindow window;
++    QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
++
++    exec([=] {
++        auto *t = touch();
++        auto *c = client();
++        t->sendDown(xdgToplevel()->surface(), {32, 32}, 1);
++        t->sendFrame(c);
++        t->sendCancel(c);
++        t->sendFrame(c);
++    });
++
++    QTRY_VERIFY(!window.m_events.empty());
++    {
++        auto e = window.m_events.takeFirst();
++        QCOMPARE(e.type, QEvent::TouchBegin);
++        QCOMPARE(e.touchPointStates, Qt::TouchPointPressed);
++        QCOMPARE(e.touchPoints.length(), 1);
++        QCOMPARE(e.touchPoints.first().pos(), QPointF(32-window.frameMargins().left(), 32-window.frameMargins().top()));
++    }
++    {
++        auto e = window.m_events.takeFirst();
++        QCOMPARE(e.type, QEvent::TouchCancel);
++        QCOMPARE(e.touchPoints.length(), 0);
++    }
++}
++
+ QCOMPOSITOR_TEST_MAIN(tst_seatv5)
+ #include "tst_seatv5.moc"
+diff --git a/qtwayland/tests/auto/client/shared/corecompositor.cpp b/qtwayland/tests/auto/client/shared/corecompositor.cpp
+index 5c6c83ba..fa9b7662 100644
+--- a/qtwayland/tests/auto/client/shared/corecompositor.cpp
++++ b/qtwayland/tests/auto/client/shared/corecompositor.cpp
+@@ -27,6 +27,7 @@
+ ****************************************************************************/
+ 
+ #include "corecompositor.h"
++#include <thread>
+ 
+ namespace MockCompositor {
+ 
+diff --git a/qtwayland/tests/auto/client/shared/coreprotocol.cpp b/qtwayland/tests/auto/client/shared/coreprotocol.cpp
+index 0d988521..d1a2e7cb 100644
+--- a/qtwayland/tests/auto/client/shared/coreprotocol.cpp
++++ b/qtwayland/tests/auto/client/shared/coreprotocol.cpp
+@@ -451,6 +451,13 @@ void Touch::sendFrame(wl_client *client)
+         send_frame(r->handle);
+ }
+ 
++void Touch::sendCancel(wl_client *client)
++{
++    const auto touchResources = resourceMap().values(client);
++    for (auto *r : touchResources)
++        send_cancel(r->handle);
++}
++
+ uint Keyboard::sendEnter(Surface *surface)
+ {
+     auto serial = m_seat->m_compositor->nextSerial();
+diff --git a/qtwayland/tests/auto/client/shared/coreprotocol.h b/qtwayland/tests/auto/client/shared/coreprotocol.h
+index a1af137a..210d8ddb 100644
+--- a/qtwayland/tests/auto/client/shared/coreprotocol.h
++++ b/qtwayland/tests/auto/client/shared/coreprotocol.h
+@@ -158,7 +158,7 @@ class WlCompositor : public Global, public QtWaylandServer::wl_compositor
+ {
+     Q_OBJECT
+ public:
+-    explicit WlCompositor(CoreCompositor *compositor, int version = 3)
++    explicit WlCompositor(CoreCompositor *compositor, int version = 4)
+         : QtWaylandServer::wl_compositor(compositor->m_display, version)
+         , m_compositor(compositor)
+     {}
+@@ -364,6 +364,7 @@ public:
+     uint sendUp(wl_client *client, int id);
+     void sendMotion(wl_client *client, const QPointF &position, int id);
+     void sendFrame(wl_client *client);
++    void sendCancel(wl_client *client);
+ 
+     Seat *m_seat = nullptr;
+ };
+diff --git a/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp b/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
+index a415cbf5..b1d3d07d 100644
+--- a/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
++++ b/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
+@@ -342,7 +342,7 @@ Compositor::Compositor(MockCompositor *mockCompositor)
+         exit(EXIT_FAILURE);
+     }
+ 
+-    wl_global_create(m_display, &wl_compositor_interface, 1, this, bindCompositor);
++    wl_global_create(m_display, &wl_compositor_interface, 4, this, bindCompositor);
+ 
+     m_data_device_manager.reset(new DataDeviceManager(this, m_display));
+ 
+diff --git a/qtwayland/tests/auto/client/shared_old/mocksurface.cpp b/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
+index e9df5f90..c3246e4a 100644
+--- a/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
++++ b/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
+@@ -125,6 +125,16 @@ void Surface::surface_damage(Resource *resource,
+     Q_UNUSED(height);
+ }
+ 
++void Surface::surface_damage_buffer(Resource *resource,
++                                    int32_t x, int32_t y, int32_t width, int32_t height)
++{
++    Q_UNUSED(resource);
++    Q_UNUSED(x);
++    Q_UNUSED(y);
++    Q_UNUSED(width);
++    Q_UNUSED(height);
++}
++
+ void Surface::surface_frame(Resource *resource,
+                             uint32_t callback)
+ {
+diff --git a/qtwayland/tests/auto/client/shared_old/mocksurface.h b/qtwayland/tests/auto/client/shared_old/mocksurface.h
+index 949dc23d..d176837e 100644
+--- a/qtwayland/tests/auto/client/shared_old/mocksurface.h
++++ b/qtwayland/tests/auto/client/shared_old/mocksurface.h
+@@ -65,6 +65,8 @@ protected:
+                         struct wl_resource *buffer, int x, int y) override;
+     void surface_damage(Resource *resource,
+                         int32_t x, int32_t y, int32_t width, int32_t height) override;
++    void surface_damage_buffer(Resource *resource,
++                               int32_t x, int32_t y, int32_t width, int32_t height) override;
+     void surface_frame(Resource *resource,
+                        uint32_t callback) override;
+     void surface_commit(Resource *resource) override;
+diff --git a/qtwayland/tests/auto/client/surface/tst_surface.cpp b/qtwayland/tests/auto/client/surface/tst_surface.cpp
+index 95e4e609..60c672ce 100644
+--- a/qtwayland/tests/auto/client/surface/tst_surface.cpp
++++ b/qtwayland/tests/auto/client/surface/tst_surface.cpp
+@@ -129,6 +129,10 @@ void tst_surface::waitForFrameCallbackGl()
+     // Make sure we follow frame callbacks for some frames
+     for (int i = 0; i < 5; ++i) {
+         xdgPingAndWaitForPong(); // Make sure things have happened on the client
++        if (!qEnvironmentVariableIntValue("QT_WAYLAND_DISABLE_WINDOWDECORATION") && i == 0) {
++            QCOMPARE(bufferSpy.count(), 1);
++            bufferSpy.removeFirst();
++        }
+         exec([&] {
+             QVERIFY(bufferSpy.empty()); // Make sure no extra buffers have arrived
+             QVERIFY(!xdgToplevel()->surface()->m_waitingFrameCallbacks.empty());
+diff --git a/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp b/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
+index 2277bbb8..747875b4 100644
+--- a/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
++++ b/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
+@@ -31,6 +31,7 @@
+ #include <QtGui/QOpenGLWindow>
+ #include <QtGui/qpa/qplatformnativeinterface.h>
+ #include <QtWaylandClient/private/wayland-wayland-client-protocol.h>
++#include <QtWaylandClient/private/qwaylandwindow_p.h>
+ 
+ using namespace MockCompositor;
+ 
+@@ -45,6 +46,7 @@ private slots:
+     void configureStates();
+     void popup();
+     void tooltipOnPopup();
++    void tooltipAndSiblingPopup();
+     void switchPopups();
+     void hidePopupParent();
+     void pongs();
+@@ -138,6 +140,7 @@ void tst_xdgshell::configureSize()
+ 
+ void tst_xdgshell::configureStates()
+ {
++    QVERIFY(qputenv("QT_WAYLAND_FRAME_CALLBACK_TIMEOUT", "0"));
+     QRasterWindow window;
+     window.resize(64, 48);
+     window.show();
+@@ -154,9 +157,12 @@ void tst_xdgshell::configureStates()
+     // Toplevel windows don't know their position on xdg-shell
+ //    QCOMPARE(window.frameGeometry().topLeft(), QPoint()); // TODO: this doesn't currently work when window decorations are enabled
+ 
+-//    QEXPECT_FAIL("", "configure has already been acked, we shouldn't have to wait for isActive", Continue);
+-//    QVERIFY(window.isActive());
+-    QTRY_VERIFY(window.isActive()); // Just make sure it eventually get's set correctly
++    // window.windowstate() is driven by keyboard focus, however for decorations we want to follow
++    // XDGShell this is internal to QtWayland so it is queried directly
++    auto waylandWindow = static_cast<QtWaylandClient::QWaylandWindow *>(window.handle());
++    Q_ASSERT(waylandWindow);
++    QTRY_VERIFY(waylandWindow->windowStates().testFlag(
++            Qt::WindowActive)); // Just make sure it eventually get's set correctly
+ 
+     const QSize screenSize(640, 480);
+     const uint maximizedSerial = exec([=] {
+@@ -186,6 +192,7 @@ void tst_xdgshell::configureStates()
+     QCOMPARE(window.windowStates(), Qt::WindowNoState);
+     QCOMPARE(window.frameGeometry().size(), windowedSize);
+ //    QCOMPARE(window.frameGeometry().topLeft(), QPoint()); // TODO: this doesn't currently work when window decorations are enabled
++    QVERIFY(qunsetenv("QT_WAYLAND_FRAME_CALLBACK_TIMEOUT"));
+ }
+ 
+ void tst_xdgshell::popup()
+@@ -340,6 +347,92 @@ void tst_xdgshell::tooltipOnPopup()
+     QCOMPOSITOR_TRY_COMPARE(xdgPopup(0), nullptr);
+ }
+ 
++void tst_xdgshell::tooltipAndSiblingPopup()
++{
++    class ToolTip : public QRasterWindow {
++    public:
++        explicit ToolTip(QWindow *parent) {
++            setTransientParent(parent);
++            setFlags(Qt::ToolTip);
++            resize(100, 100);
++            show();
++        }
++        void mousePressEvent(QMouseEvent *event) override {
++            QRasterWindow::mousePressEvent(event);
++            m_popup = new QRasterWindow;
++            m_popup->setTransientParent(transientParent());
++            m_popup->setFlags(Qt::Popup);
++            m_popup->resize(100, 100);
++            m_popup->show();
++        }
++
++        QRasterWindow *m_popup = nullptr;
++    };
++
++    class Window : public QRasterWindow {
++    public:
++        void mousePressEvent(QMouseEvent *event) override {
++            QRasterWindow::mousePressEvent(event);
++            m_tooltip = new ToolTip(this);
++        }
++        ToolTip *m_tooltip = nullptr;
++    };
++
++    Window window;
++    window.resize(200, 200);
++    window.show();
++
++    QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
++    exec([=] { xdgToplevel()->sendCompleteConfigure(); });
++    QCOMPOSITOR_TRY_VERIFY(xdgToplevel()->m_xdgSurface->m_committedConfigureSerial);
++
++    exec([=] {
++        auto *surface = xdgToplevel()->surface();
++        auto *p = pointer();
++        auto *c = client();
++        p->sendEnter(surface, {100, 100});
++        p->sendFrame(c);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_pressed);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_released);
++        p->sendFrame(c);
++        p->sendLeave(surface);
++        p->sendFrame(c);
++    });
++
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup());
++    exec([=] { xdgPopup()->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup()->m_xdgSurface->m_committedConfigureSerial);
++    QCOMPOSITOR_TRY_VERIFY(!xdgPopup()->m_grabbed);
++
++    exec([=] {
++        auto *surface = xdgPopup()->surface();
++        auto *p = pointer();
++        auto *c = client();
++        p->sendEnter(surface, {100, 100});
++        p->sendFrame(c);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_pressed);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_released);
++        p->sendFrame(c);
++    });
++
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1));
++    exec([=] { xdgPopup(1)->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1)->m_xdgSurface->m_committedConfigureSerial);
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1)->m_grabbed);
++
++    // Close the middle tooltip (it should not close the sibling popup)
++    window.m_tooltip->close();
++
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(1), nullptr);
++    // Verify the remaining xdg surface is a grab popup..
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(0));
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(0)->m_grabbed);
++
++    window.m_tooltip->m_popup->close();
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(1), nullptr);
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(0), nullptr);
++}
++
+ // QTBUG-65680
+ void tst_xdgshell::switchPopups()
+ {
+@@ -505,7 +598,7 @@ void tst_xdgshell::minMaxSize()
+     window.show();
+     QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
+ 
+-    exec([=] { xdgToplevel()->sendCompleteConfigure(); });
++    // we don't roundtrip with our configuration the initial commit should be correct
+ 
+     QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.minSize, QSize(100, 100));
+     QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.maxSize, QSize(1000, 1000));
+Submodule qtwebchannel 618422ee..f8949655:
+diff --git a/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp b/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
+index 536eb5c..898d769 100644
+--- a/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
++++ b/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
+@@ -186,8 +186,6 @@ Q_DECLARE_TYPEINFO(OverloadResolutionCandidate, Q_MOVABLE_TYPE);
+ QMetaObjectPublisher::QMetaObjectPublisher(QWebChannel *webChannel)
+     : QObject(webChannel)
+     , webChannel(webChannel)
+-    , signalHandler(this)
+-    , clientIsIdle(false)
+     , blockUpdates(false)
+     , propertyUpdatesInitialized(false)
+ {
+@@ -301,17 +299,17 @@ QJsonObject QMetaObjectPublisher::classInfoForObject(const QObject *object, QWeb
+     return data;
+ }
+ 
+-void QMetaObjectPublisher::setClientIsIdle(bool isIdle)
++void QMetaObjectPublisher::setClientIsIdle(bool isIdle, QWebChannelAbstractTransport *transport)
+ {
+-    if (clientIsIdle == isIdle) {
+-        return;
+-    }
+-    clientIsIdle = isIdle;
+-    if (!isIdle && timer.isActive()) {
+-        timer.stop();
+-    } else if (isIdle && !timer.isActive()) {
+-        timer.start(PROPERTY_UPDATE_INTERVAL, this);
+-    }
++    transportState[transport].clientIsIdle = isIdle;
++    if (isIdle)
++        sendEnqueuedPropertyUpdates(transport);
++}
++
++bool QMetaObjectPublisher::isClientIdle(QWebChannelAbstractTransport *transport)
++{
++    auto found = transportState.find(transport);
++    return found != transportState.end() && found.value().clientIsIdle;
+ }
+ 
+ QJsonObject QMetaObjectPublisher::initializeClient(QWebChannelAbstractTransport *transport)
+@@ -333,6 +331,7 @@ QJsonObject QMetaObjectPublisher::initializeClient(QWebChannelAbstractTransport
+ 
+ void QMetaObjectPublisher::initializePropertyUpdates(const QObject *const object, const QJsonObject &objectInfo)
+ {
++    auto *signalHandler = signalHandlerFor(object);
+     foreach (const QJsonValue &propertyInfoVar, objectInfo[KEY_PROPERTIES].toArray()) {
+         const QJsonArray &propertyInfo = propertyInfoVar.toArray();
+         if (propertyInfo.size() < 2) {
+@@ -353,19 +352,19 @@ void QMetaObjectPublisher::initializePropertyUpdates(const QObject *const object
+ 
+         // Only connect for a property update once
+         if (connectedProperties.isEmpty()) {
+-            signalHandler.connectTo(object, signalIndex);
++            signalHandler->connectTo(object, signalIndex);
+         }
+ 
+         connectedProperties.insert(propertyIndex);
+     }
+ 
+     // also always connect to destroyed signal
+-    signalHandler.connectTo(object, s_destroyedSignalIndex);
++    signalHandler->connectTo(object, s_destroyedSignalIndex);
+ }
+ 
+ void QMetaObjectPublisher::sendPendingPropertyUpdates()
+ {
+-    if (blockUpdates || !clientIsIdle || pendingPropertyUpdates.isEmpty()) {
++    if (blockUpdates) {
+         return;
+     }
+ 
+@@ -415,18 +414,19 @@ void QMetaObjectPublisher::sendPendingPropertyUpdates()
+ 
+     // data does not contain specific updates
+     if (!data.isEmpty()) {
+-        setClientIsIdle(false);
+-
+         message[KEY_DATA] = data;
+-        broadcastMessage(message);
++        enqueueBroadcastMessage(message);
+     }
+ 
+     // send every property update which is not supposed to be broadcasted
+     const QHash<QWebChannelAbstractTransport*, QJsonArray>::const_iterator suend = specificUpdates.constEnd();
+     for (QHash<QWebChannelAbstractTransport*, QJsonArray>::const_iterator it = specificUpdates.constBegin(); it != suend; ++it) {
+         message[KEY_DATA] = it.value();
+-        it.key()->sendMessage(message);
++        enqueueMessage(message, it.key());
+     }
++
++    for (auto state = transportState.begin(); state != transportState.end(); ++state)
++        sendEnqueuedPropertyUpdates(state.key());
+ }
+ 
+ QVariant QMetaObjectPublisher::invokeMethod(QObject *const object, const QMetaMethod &method,
+@@ -572,7 +572,7 @@ void QMetaObjectPublisher::signalEmitted(const QObject *object, const int signal
+         }
+     } else {
+         pendingPropertyUpdates[object][signalIndex] = arguments;
+-        if (clientIsIdle && !blockUpdates && !timer.isActive()) {
++        if (!blockUpdates && !timer.isActive()) {
+             timer.start(PROPERTY_UPDATE_INTERVAL, this);
+         }
+     }
+@@ -590,7 +590,7 @@ void QMetaObjectPublisher::objectDestroyed(const QObject *object)
+     // only remove from handler when we initialized the property updates
+     // cf: https://bugreports.qt.io/browse/QTBUG-60250
+     if (propertyUpdatesInitialized) {
+-        signalHandler.remove(object);
++        signalHandlerFor(object)->remove(object);
+         signalToPropertyMap.remove(object);
+     }
+     pendingPropertyUpdates.remove(object);
+@@ -852,6 +852,52 @@ void QMetaObjectPublisher::broadcastMessage(const QJsonObject &message) const
+     }
+ }
+ 
++void QMetaObjectPublisher::enqueueBroadcastMessage(const QJsonObject &message)
++{
++    if (webChannel->d_func()->transports.isEmpty()) {
++        qWarning("QWebChannel is not connected to any transports, cannot send message: %s",
++                 QJsonDocument(message).toJson().constData());
++        return;
++    }
++
++    for (auto *transport : webChannel->d_func()->transports) {
++        auto &state = transportState[transport];
++        state.queuedMessages.append(message);
++    }
++}
++
++void QMetaObjectPublisher::enqueueMessage(const QJsonObject &message,
++                                          QWebChannelAbstractTransport *transport)
++{
++    auto &state = transportState[transport];
++    state.queuedMessages.append(message);
++}
++
++void QMetaObjectPublisher::sendEnqueuedPropertyUpdates(QWebChannelAbstractTransport *transport)
++{
++    auto found = transportState.find(transport);
++    if (found != transportState.end() && found.value().clientIsIdle
++        && !found.value().queuedMessages.isEmpty()) {
++
++        // If the client is connected with an in-process transport, it can
++        // happen that a message triggers a subsequent property change. In
++        // that case, we need to ensure that the queued messages have already
++        // been cleared; otherwise the recursive call will send everythig again.
++        // Case in point: The qmlwebchannel tests fail if we don't clear the
++        // queued messages before sending them out.
++        // For that same reason set the client to "busy" (aka non-idle) just
++        // right before sending out the messages; otherwise a potential
++        // "Idle" type message will not correctly restore the Idle state.
++        const auto messages = std::move(found.value().queuedMessages);
++        Q_ASSERT(found.value().queuedMessages.isEmpty());
++        found.value().clientIsIdle = false;
++
++        for (const auto &message : messages) {
++            transport->sendMessage(message);
++        }
++    }
++}
++
+ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannelAbstractTransport *transport)
+ {
+     if (!webChannel->d_func()->transports.contains(transport)) {
+@@ -866,7 +912,7 @@ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannel
+ 
+     const MessageType type = toType(message.value(KEY_TYPE));
+     if (type == TypeIdle) {
+-        setClientIsIdle(true);
++        setClientIsIdle(true, transport);
+     } else if (type == TypeInit) {
+         if (!message.contains(KEY_ID)) {
+             qWarning("JSON message object is missing the id property: %s",
+@@ -913,9 +959,9 @@ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannel
+                 return;
+             transport->sendMessage(createResponse(message.value(KEY_ID), wrapResult(result, transport)));
+         } else if (type == TypeConnectToSignal) {
+-            signalHandler.connectTo(object, message.value(KEY_SIGNAL).toInt(-1));
++            signalHandlerFor(object)->connectTo(object, message.value(KEY_SIGNAL).toInt(-1));
+         } else if (type == TypeDisconnectFromSignal) {
+-            signalHandler.disconnectFrom(object, message.value(KEY_SIGNAL).toInt(-1));
++            signalHandlerFor(object)->disconnectFrom(object, message.value(KEY_SIGNAL).toInt(-1));
+         } else if (type == TypeSetProperty) {
+             setProperty(object, message.value(KEY_PROPERTY).toInt(-1),
+                         message.value(KEY_VALUE));
+@@ -931,6 +977,7 @@ void QMetaObjectPublisher::setBlockUpdates(bool block)
+     blockUpdates = block;
+ 
+     if (!blockUpdates) {
++        timer.start(PROPERTY_UPDATE_INTERVAL, this);
+         sendPendingPropertyUpdates();
+     } else if (timer.isActive()) {
+         timer.stop();
+@@ -948,4 +995,15 @@ void QMetaObjectPublisher::timerEvent(QTimerEvent *event)
+     }
+ }
+ 
++SignalHandler<QMetaObjectPublisher> *QMetaObjectPublisher::signalHandlerFor(const QObject *object)
++{
++    auto thread = object->thread();
++    auto it = signalHandlers.find(thread);
++    if (it == signalHandlers.end()) {
++        it = signalHandlers.emplace(thread, this).first;
++        it->second.moveToThread(thread);
++    }
++    return &it->second;
++}
++
+ QT_END_NAMESPACE
+diff --git a/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h b/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
+index bbd9875..4713ef1 100644
+--- a/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
++++ b/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
+@@ -59,6 +59,9 @@
+ #include <QBasicTimer>
+ #include <QPointer>
+ #include <QJsonObject>
++#include <QQueue>
++
++#include <unordered_map>
+ 
+ #include "qwebchannelglobal.h"
+ 
+@@ -109,17 +112,36 @@ public:
+      */
+     void broadcastMessage(const QJsonObject &message) const;
+ 
++    /**
++     * Enqueue the given @p message to all known transports.
++     */
++    void enqueueBroadcastMessage(const QJsonObject &message);
++
++    /**
++     * Enqueue the given @p message to @p transport.
++     */
++    void enqueueMessage(const QJsonObject &message, QWebChannelAbstractTransport *transport);
++
++    /**
++     * If client for given @p transport is idle, send queued messaged to @p transport and then mark
++     * the client as not idle.
++     */
++    void sendEnqueuedPropertyUpdates(QWebChannelAbstractTransport *transport);
++
+     /**
+      * Serialize the QMetaObject of @p object and return it in JSON form.
+      */
+     QJsonObject classInfoForObject(const QObject *object, QWebChannelAbstractTransport *transport);
+ 
+     /**
+-     * Set the client to idle or busy, based on the value of @p isIdle.
+-     *
+-     * When the value changed, start/stop the property update timer accordingly.
++     * Set the client to idle or busy for a single @p transport, based on the value of @p isIdle.
++     */
++    void setClientIsIdle(bool isIdle, QWebChannelAbstractTransport *transport);
++
++    /**
++     * Check that client is idle for @p transport.
+      */
+-    void setClientIsIdle(bool isIdle);
++    bool isClientIdle(QWebChannelAbstractTransport *transport);
+ 
+     /**
+      * Initialize clients by sending them the class information of the registered objects.
+@@ -272,10 +294,18 @@ private:
+     friend class TestWebChannel;
+ 
+     QWebChannel *webChannel;
+-    SignalHandler<QMetaObjectPublisher> signalHandler;
++    std::unordered_map<const QThread*, SignalHandler<QMetaObjectPublisher>> signalHandlers;
++    SignalHandler<QMetaObjectPublisher> *signalHandlerFor(const QObject *object);
+ 
+-    // true when the client is idle, false otherwise
+-    bool clientIsIdle;
++    struct TransportState
++    {
++        TransportState() : clientIsIdle(false) { }
++        // true when the client is idle, false otherwise
++        bool clientIsIdle;
++        // messages to send
++        QQueue<QJsonObject> queuedMessages;
++    };
++    QHash<QWebChannelAbstractTransport *, TransportState> transportState;
+ 
+     // true when no property updates should be sent, false otherwise
+     bool blockUpdates;
+diff --git a/qtwebchannel/src/webchannel/signalhandler_p.h b/qtwebchannel/src/webchannel/signalhandler_p.h
+index 27afadb..d77373c 100644
+--- a/qtwebchannel/src/webchannel/signalhandler_p.h
++++ b/qtwebchannel/src/webchannel/signalhandler_p.h
+@@ -56,6 +56,7 @@
+ #include <QVector>
+ #include <QMetaMethod>
+ #include <QDebug>
++#include <QThread>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -71,6 +72,7 @@ static const int s_destroyedSignalIndex = QObject::staticMetaObject.indexOfMetho
+ template<class Receiver>
+ class SignalHandler : public QObject
+ {
++    Q_DISABLE_COPY(SignalHandler)
+ public:
+     SignalHandler(Receiver *receiver, QObject *parent = 0);
+ 
+@@ -268,6 +270,7 @@ int SignalHandler<Receiver>::qt_metacall(QMetaObject::Call call, int methodId, v
+     if (call == QMetaObject::InvokeMetaMethod) {
+         const QObject *object = sender();
+         Q_ASSERT(object);
++        Q_ASSERT(QThread::currentThread() == object->thread());
+         Q_ASSERT(senderSignalIndex() == methodId);
+         Q_ASSERT(m_connectionsCounter.contains(object));
+         Q_ASSERT(m_connectionsCounter.value(object).contains(methodId));
+diff --git a/qtwebchannel/tests/auto/qml/testwebchannel.cpp b/qtwebchannel/tests/auto/qml/testwebchannel.cpp
+index 9891687..3ca81c2 100644
+--- a/qtwebchannel/tests/auto/qml/testwebchannel.cpp
++++ b/qtwebchannel/tests/auto/qml/testwebchannel.cpp
+@@ -46,7 +46,11 @@ TestWebChannel::~TestWebChannel()
+ 
+ bool TestWebChannel::clientIsIdle() const
+ {
+-    return QWebChannel::d_func()->publisher->clientIsIdle;
++    for (auto *transport : QWebChannel::d_func()->transports) {
++        if (QWebChannel::d_func()->publisher->isClientIdle(transport))
++            return true;
++    }
++    return false;
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp b/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
+index 181da9e..37f989a 100644
+--- a/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
++++ b/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
+@@ -785,7 +785,7 @@ void TestWebChannel::testTransportWrapObjectProperties()
+     DummyTransport *dummyTransport = new DummyTransport(this);
+     channel.connectTo(dummyTransport);
+     channel.d_func()->publisher->initializeClient(dummyTransport);
+-    channel.d_func()->publisher->setClientIsIdle(true);
++    channel.d_func()->publisher->setClientIsIdle(true, dummyTransport);
+ 
+     QCOMPARE(channel.d_func()->publisher->transportedWrappedObjects.size(), 0);
+ 
+@@ -943,8 +943,6 @@ void TestWebChannel::testInfiniteRecursion()
+ 
+ void TestWebChannel::testAsyncObject()
+ {
+-    QSKIP("This test is broken. See QTBUG-80729");
+-
+     QWebChannel channel;
+     channel.connectTo(m_dummyTransport);
+ 
+@@ -990,6 +988,50 @@ void TestWebChannel::testAsyncObject()
+     thread.wait();
+ }
+ 
++void TestWebChannel::testPropertyMultipleTransports()
++{
++    DummyTransport transport1;
++    DummyTransport transport2;
++
++    QWebChannel channel;
++    QMetaObjectPublisher *publisher = channel.d_func()->publisher;
++
++    TestObject testObj;
++    testObj.setObjectName("testObject");
++    channel.registerObject(testObj.objectName(), &testObj);
++    channel.connectTo(&transport1);
++    channel.connectTo(&transport2);
++
++    testObj.setProp("Hello");
++
++    publisher->initializeClient(&transport1);
++    publisher->initializeClient(&transport2);
++    publisher->setClientIsIdle(true, &transport1);
++    QCOMPARE(publisher->isClientIdle(&transport1), true);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++    QVERIFY(transport1.messagesSent().isEmpty());
++    QVERIFY(transport2.messagesSent().isEmpty());
++
++    testObj.setProp("World");
++    QTRY_COMPARE_WITH_TIMEOUT(transport1.messagesSent().size(), 1u, 2000);
++    QCOMPARE(transport2.messagesSent().size(), 0u);
++    publisher->setClientIsIdle(true, &transport2);
++    QTRY_COMPARE_WITH_TIMEOUT(transport2.messagesSent().size(), 1u, 2000);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++
++    testObj.setProp("!!!");
++    publisher->setClientIsIdle(true, &transport2);
++    QCOMPARE(publisher->isClientIdle(&transport2), true);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QTRY_COMPARE_WITH_TIMEOUT(transport2.messagesSent().size(), 2u, 2000);
++    QCOMPARE(transport1.messagesSent().size(), 1u);
++    publisher->setClientIsIdle(true, &transport1);
++    QTRY_COMPARE_WITH_TIMEOUT(transport1.messagesSent().size(), 2u, 2000);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++}
++
+ class FunctionWrapper : public QObject
+ {
+     Q_OBJECT
+@@ -1082,7 +1124,7 @@ void TestWebChannel::benchInitializeClients()
+ 
+         publisher->propertyUpdatesInitialized = false;
+         publisher->signalToPropertyMap.clear();
+-        publisher->signalHandler.clear();
++        publisher->signalHandlers.clear();
+     }
+ }
+ 
+@@ -1107,7 +1149,7 @@ void TestWebChannel::benchPropertyUpdates()
+             obj->change();
+         }
+ 
+-        channel.d_func()->publisher->clientIsIdle = true;
++        channel.d_func()->publisher->setClientIsIdle(true, m_dummyTransport);
+         channel.d_func()->publisher->sendPendingPropertyUpdates();
+     }
+ }
+diff --git a/qtwebchannel/tests/auto/webchannel/tst_webchannel.h b/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
+index eae21f4..dd4e690 100644
+--- a/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
++++ b/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
+@@ -348,6 +348,7 @@ private slots:
+     void testJsonToVariant();
+     void testInfiniteRecursion();
+     void testAsyncObject();
++    void testPropertyMultipleTransports();
+     void testDeletionDuringMethodInvocation_data();
+     void testDeletionDuringMethodInvocation();
+ 
+Submodule qtwebengine f328054d...38e0df6c (commits not present)
+Submodule qtwebsockets 65850954..63fb8da1:
+diff --git a/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp b/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
+index 2affdd5..95f1194 100644
+--- a/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
++++ b/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
+@@ -273,6 +273,7 @@ void QWebSocketDataProcessor::clear()
+     if (!m_pConverterState)
+         m_pConverterState = new QTextCodec::ConverterState(QTextCodec::ConvertInvalidToNull |
+                                                            QTextCodec::IgnoreHeader);
++    frame.clear();
+ }
+ 
+ /*!
+diff --git a/qtwebsockets/src/websockets/qwebsocketprotocol.cpp b/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
+index df87a93..d0465f1 100644
+--- a/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
++++ b/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
+@@ -210,7 +210,7 @@ void QWebSocketProtocol::mask(char *payload, quint64 size, quint32 maskingKey)
+                             quint8((maskingKey & 0x0000FF00u) >> 8),
+                             quint8((maskingKey & 0x000000FFu))
+                           };
+-    int i = 0;
++    quint64 i = 0;
+     while (size-- > 0)
+         *payload++ ^= mask[i++ % 4];
+ }
diff --git a/srcpkgs/qt5/template b/srcpkgs/qt5/template
index e0463e1c9198..ca1800ce9dc2 100644
--- a/srcpkgs/qt5/template
+++ b/srcpkgs/qt5/template
@@ -2,11 +2,11 @@
 #
 # revbump libqtxdg after bumping patch version
 pkgname=qt5
-version=5.15.7+20221119
+version=5.15.8
+revision=1
+build_style=meta
 # commit f8c9fb304bc3e53b3aa07f962cd74e9160decccc
 # base repo: https://invent.kde.org/qt/qt/qt5
-revision=4
-build_style=meta
 hostmakedepends="cmake clang flex perl glib-devel pkg-config
  python re2c ruby which"
 makedepends="SDL2-devel Vulkan-Headers alsa-lib-devel double-conversion-devel
@@ -29,8 +29,9 @@ homepage="https://qt.io/"
 # tarball is generated with `git archive-all qt5-$version.tar.gz`
 # to keep the size smaller qtwebengine, qtwebview, qtdocgallery, qtactiveqt and qtpim
 # can be marked with the export-ignore attribute
-distfiles="https://void.johnnynator.dev/distfiles/qt5-${version}.tar.gz"
-checksum=9d57af471c78029a362276b7c99108ea009f511bb9ba6ff6cb884f6ddd255e9f
+#distfiles="https://void.johnnynator.dev/distfiles/qt5-${version}.tar.gz"
+distfiles="https://download.qt.io/archive/qt/5.15/${version}/single/qt-everywhere-opensource-src-${version}.tar.xz"
+checksum=776a9302c336671f9406a53bd30b8e36f825742b2ec44a57c08217bff0fa86b9
 python_version=2 #unverified
 replaces="qt5-doc<5.6.0 qt5-quick1<5.6.0 qt5-quick1-devel<5.6.0 qt5-webkit<5.6.0 qt5-webkit-devel<5.6.0
  qt5-enginio<5.7.1 qt5-enginio-devel<5.7.1 qt5-plugin-gtk<5.7.1 qt5-canvas3d<5.13.0"
@@ -248,7 +249,6 @@ do_configure() {
 	# opts+=" -v"
 	opts+=" -skip qtwebengine"
 	opts+=" -skip qtwebview"
-	opts+=" -skip qtdocgallery"
 	opts+=" -skip qtpim"
 	opts+=" -skip qtsystems"
 	opts+=" -skip qtspeech"

From ceb43f2aee8105b7cbf0daa7fc44cc3ef2984437 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 078/110] qt6-multimedia: revbump for ffmpeg-6.0

---
 srcpkgs/qt6-multimedia/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-multimedia/template b/srcpkgs/qt6-multimedia/template
index d89e7d54eb5a..aae15e57ca7b 100644
--- a/srcpkgs/qt6-multimedia/template
+++ b/srcpkgs/qt6-multimedia/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-multimedia'
 pkgname=qt6-multimedia
 version=6.4.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DQT_FEATURE_gstreamer=ON"
 hostmakedepends="perl qt6-declarative-host-tools pkg-config qt6-shadertools"

From 497f4fc6016b0987051fd6b383583d5630ab5689 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 079/110] qtav: revbump for ffmpeg4-4.4.3

---
 srcpkgs/qtav/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtav/template b/srcpkgs/qtav/template
index 34c30b2c0c78..2d00ad104355 100644
--- a/srcpkgs/qtav/template
+++ b/srcpkgs/qtav/template
@@ -1,10 +1,10 @@
 # Template file for 'qtav'
 pkgname=qtav
 version=1.13.0
-revision=1
+revision=2
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel libass-devel libopenal-devel
+makedepends="ffmpeg4-devel libass-devel libopenal-devel
  libva-glx-devel libXv-devel pulseaudio-devel
  qt5-declarative-devel qt5-svg-devel
  qt5-quickcontrols"

From 780df5f0e8766c14b09e548edbba07cbb0f53085 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 080/110] qtox: revbump for ffmpeg-6.0

---
 srcpkgs/qtox/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qtox/template b/srcpkgs/qtox/template
index 16019d7eaec9..5cea0b11b697 100644
--- a/srcpkgs/qtox/template
+++ b/srcpkgs/qtox/template
@@ -1,7 +1,7 @@
 # Template file for 'qtox'
 pkgname=qtox
 version=1.17.6
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DUPDATE_CHECK=OFF
  -DGIT_DESCRIBE=${version}

From 95e70674c9f1128d3b2121d791e3e38bc49dd1f6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 081/110] retroarch: revbump for ffmpeg-6.0

---
 srcpkgs/retroarch/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroarch/template b/srcpkgs/retroarch/template
index 240d3df9db00..6d0b16ae2598 100644
--- a/srcpkgs/retroarch/template
+++ b/srcpkgs/retroarch/template
@@ -1,7 +1,7 @@
 # Template file for 'retroarch'
 pkgname=retroarch
 version=1.14.0
-revision=1
+revision=2
 build_style=configure
 configure_args="--prefix=/usr --sysconfdir=/etc --enable-networking
  --enable-udev --disable-builtinflac --disable-builtinglslang

From ef6b21095b8db3cbf4a58048903bd2ed0d7a37a4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 082/110] scrcpy: revbump for ffmpeg-6.0

---
 srcpkgs/scrcpy/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/scrcpy/template b/srcpkgs/scrcpy/template
index ee6e698e387f..8ada5ca4323f 100644
--- a/srcpkgs/scrcpy/template
+++ b/srcpkgs/scrcpy/template
@@ -1,7 +1,7 @@
 # Template file for 'scrcpy'
 pkgname=scrcpy
 version=2.0
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcompile_server=false
  -Dprebuilt_server=/usr/share/scrcpy/scrcpy-server-v${version}"

From f43c95897ec2557208adceaa2ea515548fb5aafc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 083/110] spek-alternative: revbump for ffmpeg4-4.4.3

---
 srcpkgs/spek-alternative/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/spek-alternative/template b/srcpkgs/spek-alternative/template
index d65086b8f008..05246f1b8d0c 100644
--- a/srcpkgs/spek-alternative/template
+++ b/srcpkgs/spek-alternative/template
@@ -1,11 +1,11 @@
 # Template file for 'spek-alternative'
 pkgname=spek-alternative
 version=0.8.2.3
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake gettext-devel intltool libtool pkg-config wxWidgets-common"
-makedepends="ffmpeg-devel wxWidgets-gtk3-devel"
-depends="ffmpeg"
+makedepends="ffmpeg4-devel wxWidgets-gtk3-devel"
+depends="ffmpeg4"
 short_desc="Acoustic spectrum analyser"
 maintainer="Kartik Singh <kartik.ynwa@gmail.com>"
 license="GPL-3.0-or-later"

From 7860618e990d9d8d68ec13049cd24ba38cbcf6c9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 084/110] ssr: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ssr/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/ssr/template b/srcpkgs/ssr/template
index b055b9ec0774..3448ca110eb0 100644
--- a/srcpkgs/ssr/template
+++ b/srcpkgs/ssr/template
@@ -1,11 +1,11 @@
 # Template file for 'ssr'
 pkgname=ssr
 version=0.4.4
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_QT5=ON"
 hostmakedepends="pkg-config"
-makedepends="alsa-lib-devel ffmpeg-devel glu-devel jack-devel pulseaudio-devel
+makedepends="alsa-lib-devel ffmpeg4-devel glu-devel jack-devel pulseaudio-devel
  qt5-tools-devel qt5-x11extras-devel libXinerama-devel v4l-utils-devel"
 depends="desktop-file-utils hicolor-icon-theme"
 short_desc="Simple Screen Recorder for programs and games"

From dfa84ffec0fc3ec7cfbb4666e2e7227f3db4d617 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 085/110] sumo: revbump for ffmpeg-6.0

---
 srcpkgs/sumo/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/sumo/template b/srcpkgs/sumo/template
index 0f9b9ec815f5..a3fe134aa5ac 100644
--- a/srcpkgs/sumo/template
+++ b/srcpkgs/sumo/template
@@ -1,7 +1,7 @@
 # Template file for 'sumo'
 pkgname=sumo
 version=1.12.0
-revision=5
+revision=6
 build_style=cmake
 hostmakedepends="libgdal-tools pkg-config swig python3-setuptools"
 makedepends="python3-devel ffmpeg-devel fox-devel gl2ps-devel libgdal-devel

From 73eab171c21ee2c32b9e8c70568245bb7eccb6b0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 086/110] synfig: revbump for ffmpeg-6.0 and mlt7

---
 srcpkgs/synfig/patches/ffmpeg6.patch | 71 ++++++++++++++++++++++++++++
 srcpkgs/synfig/template              |  4 +-
 2 files changed, 73 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/synfig/patches/ffmpeg6.patch

diff --git a/srcpkgs/synfig/patches/ffmpeg6.patch b/srcpkgs/synfig/patches/ffmpeg6.patch
new file mode 100644
index 000000000000..10780b42782f
--- /dev/null
+++ b/srcpkgs/synfig/patches/ffmpeg6.patch
@@ -0,0 +1,71 @@
+--- a/src/modules/mod_libavcodec/trgt_av.cpp	2022-10-25 09:14:12.000000000 -0400
++++ b/src/modules/mod_libavcodec/trgt_av.cpp	2023-05-05 21:34:17.899194559 -0400
+@@ -38,6 +41,7 @@
+ extern "C"
+ {
+ #ifdef HAVE_LIBAVFORMAT_AVFORMAT_H
++#	include <libavcodec/avcodec.h>
+ #	include <libavformat/avformat.h>
+ #elif defined(HAVE_AVFORMAT_H)
+ #	include <avformat.h>
+@@ -155,11 +156,11 @@
+     }
+ 
+ 	bool open_video_stream() {
+-		if (avcodec_open2(video_context, NULL, NULL) < 0) {
++		if (avcodec_open2(video_context, nullptr, nullptr) < 0) {
+ 			synfig::error("Target_LibAVCodec: could not open video codec");
+ 			// seems the calling of avcodec_free_context after error will cause crash
+ 			// so just forget about this context
+-			video_context = NULL;
++			video_context = nullptr;
+ 			close();
+ 			return false;
+         }
+@@ -234,15 +235,21 @@
+ 		close();
+ 
+ 		if (!av_registered) {
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 			av_register_all();
++#endif
+ 			av_registered = true;
+ 		}
+ 
+ 		// guess format
+-		AVOutputFormat *format = av_guess_format(NULL, filename.c_str(), NULL);
++#if LIBAVCODEC_VERSION_MAJOR < 59 // FFMPEG < 5.0
++		AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#else
++		const AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#endif
+ 		if (!format) {
+ 			synfig::warning("Target_LibAVCodec: unable to guess the output format, defaulting to MPEG");
+-			format = av_guess_format("mpeg", NULL, NULL);
++			format = av_guess_format("mpeg", nullptr, nullptr);
+ 		}
+ 		if (!format) {
+ 			synfig::error("Target_LibAVCodec: unable to find 'mpeg' output format");
+@@ -254,6 +261,7 @@
+ 		context = avformat_alloc_context();
+ 		assert(context);
+ 		context->oformat = format;
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 		if (filename.size() + 1 > sizeof(context->filename)) {
+ 			synfig::error(
+ 				"Target_LibAVCodec: filename too long, max length is %d, filename is '%s'",
+@@ -263,6 +271,14 @@
+ 			return false;
+ 		}
+ 		memcpy(context->filename, filename.c_str(), filename.size() + 1);
++#else
++		context->url = av_strndup(filename.c_str(), filename.size());
++		if (!context->url) {
++			synfig::error("Target_LibAVCodec: cannot allocate space for filename");
++			close();
++			return false;
++		}
++#endif
+ 
+ 		packet = av_packet_alloc();
+ 		assert(packet);
diff --git a/srcpkgs/synfig/template b/srcpkgs/synfig/template
index 5f5f5bb3f4b2..6e0d713150ae 100644
--- a/srcpkgs/synfig/template
+++ b/srcpkgs/synfig/template
@@ -6,7 +6,7 @@ revision=2
 build_style=gnu-configure
 configure_args="--with-boost-libdir=${XBPS_CROSS_BASE}/usr/lib"
 hostmakedepends="boost-build ImageMagick pkg-config intltool"
-makedepends="ETL gettext-devel libxml++-devel mlt-devel libmagick-devel
+makedepends="ETL gettext-devel libxml++-devel mlt7-devel libmagick-devel
  libmng-devel boost-build boost-devel libopenexr-devel ffmpeg-devel"
 depends="ImageMagick"
 short_desc="CLI 2D vector and timeline-based animation software"
@@ -20,7 +20,7 @@ CXXFLAGS="-std=c++11 -DHAVE_LOCALE_H=1"
 
 synfig-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision}
-	 libopenexr-devel libxml++-devel mlt-devel"
+	 libopenexr-devel libxml++-devel mlt7-devel"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/bin/synfig-config

From 730277ca9899d55da547f420c2ec8ee5b969ea1b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 5 May 2023 12:57:57 -0400
Subject: [PATCH 087/110] synfigstudio: revbump for synfig mlt7

---
 srcpkgs/synfigstudio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/synfigstudio/template b/srcpkgs/synfigstudio/template
index 91349169ed2b..af1c5a296ef0 100644
--- a/srcpkgs/synfigstudio/template
+++ b/srcpkgs/synfigstudio/template
@@ -2,7 +2,7 @@
 # Should be kept in sync with 'synfig' and 'ETL'
 pkgname=synfigstudio
 version=1.4.4
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--disable-update-mimedb"
 hostmakedepends="pkg-config intltool gettext synfig"

From 1985dec1b7c0e7febf5caba5c08a442d57c9c335 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 088/110] telegram-desktop: revbump for ffmpeg-6.0

---
 srcpkgs/telegram-desktop/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/telegram-desktop/template b/srcpkgs/telegram-desktop/template
index 60df3278b05e..83aa72a67448 100644
--- a/srcpkgs/telegram-desktop/template
+++ b/srcpkgs/telegram-desktop/template
@@ -1,7 +1,7 @@
 # Template file for 'telegram-desktop'
 pkgname=telegram-desktop
 version=4.8.1
-revision=1
+revision=2
 build_style=cmake
 build_helper="qemu"
 configure_args="-DTDESKTOP_API_ID=209235

From a2d86a1789d9ca0a2119aef9811526eb552eacee Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 089/110] tg_owt: revbump for ffmpeg-6.0

---
 srcpkgs/tg_owt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tg_owt/template b/srcpkgs/tg_owt/template
index 97d195ddb34a..551614b24956 100644
--- a/srcpkgs/tg_owt/template
+++ b/srcpkgs/tg_owt/template
@@ -1,7 +1,7 @@
 # Template file for 'tg_owt'
 pkgname=tg_owt
 version=0.0.0.20230107
-revision=1
+revision=2
 _commit=5098730b9eb6173f0b52068fe2555b7c1015123a
 _libyuv_commit=00950840d1c9bcbb3eb6ebc5aac5793e71166c8b
 _abseil_commit=8c0b94e793a66495e0b1f34a5eb26bd7dc672db0

From a0d568dc8019abb4595d2815c48f4ebce9f5071b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 090/110] timg: revbump for ffmpeg-6.0

---
 srcpkgs/timg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/timg/template b/srcpkgs/timg/template
index 91f1516b2597..334443d3f9bb 100644
--- a/srcpkgs/timg/template
+++ b/srcpkgs/timg/template
@@ -1,7 +1,7 @@
 # Template file for 'timg'
 pkgname=timg
 version=1.4.4
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_OPENSLIDE_SUPPORT=off -Wno-dev"
 hostmakedepends="pkg-config git"

From ee3cd73c90ca2038047d68dd1e0cc9c040abc78f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 091/110] tvheadend: revbump for ffmpeg4-4.4.3

---
 srcpkgs/tvheadend/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/tvheadend/template b/srcpkgs/tvheadend/template
index e6b16d7ccf3b..46b52b6fb7f9 100644
--- a/srcpkgs/tvheadend/template
+++ b/srcpkgs/tvheadend/template
@@ -1,14 +1,14 @@
 # Template file for 'tvheadend'
 pkgname=tvheadend
 version=4.2.8
-revision=6
+revision=7
 build_style=gnu-configure
 configure_args="--enable-dvbscan --disable-ffmpeg_static
 --disable-hdhomerun_static --disable-bintray_cache --disable-libx264_static
 --disable-libx265_static --disable-libvpx_static --disable-libtheora_static
 --disable-libvorbis_static --disable-libfdkaac_static"
 hostmakedepends="gettext pkg-config python git which"
-makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg-devel"
+makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg4-devel"
 short_desc="TV streaming server"
 maintainer="lemmi <lemmi@nerd2nerd.org>"
 license="GPL-3.0-only"

From 1cc46baceaa0ca0d6bbc9f441893eccd2a599161 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 092/110] unpaper: update to 7.0.0.

---
 srcpkgs/unpaper/template | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/srcpkgs/unpaper/template b/srcpkgs/unpaper/template
index 38ed47a58401..1ff910e722af 100644
--- a/srcpkgs/unpaper/template
+++ b/srcpkgs/unpaper/template
@@ -1,13 +1,13 @@
 # Template file for 'unpaper'
 pkgname=unpaper
-version=6.1
-revision=3
-build_style=gnu-configure
+version=7.0.0
+revision=1
+build_style=meson
+hostmakedepends="pkg-config meson libxslt"
+makedepends="ffmpeg-devel python3-Sphinx"
+short_desc="Post-processing tool for scanned sheets of paper"
 maintainer="Orphaned <orphan@voidlinux.org>"
-hostmakedepends="pkg-config libxslt"
-makedepends="ffmpeg-devel"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://www.flameeyes.eu/projects/unpaper"
-short_desc="A post-processing tool for scanned sheets of paper"
 distfiles="https://www.flameeyes.eu/files/${pkgname}-${version}.tar.xz"
-checksum=237c84f5da544b3f7709827f9f12c37c346cdf029b1128fb4633f9bafa5cb930
+checksum=2575fbbf26c22719d1cb882b59602c9900c7f747118ac130883f63419be46a80

From 3faa558ade3857867fab33a8042f68d9b135a12f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 093/110] vba-m: revbump for ffmpeg-6.0

---
 srcpkgs/vba-m/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vba-m/template b/srcpkgs/vba-m/template
index ba153e0b58ca..aa6093645e97 100644
--- a/srcpkgs/vba-m/template
+++ b/srcpkgs/vba-m/template
@@ -2,7 +2,7 @@
 pkgname=vba-m
 reverts=1292_2
 version=2.1.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_GTK=TRUE -DENABLE_FFMPEG=TRUE -DENABLE_LINK=TRUE -DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="gettext pkg-config unzip zip yasm wxWidgets-gtk3-devel"

From 61b604f3acdc80d3b903e9c9d466e9ad6b0c1c2c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 094/110] vice: revbump for ffmpeg4-4.4.3

---
 srcpkgs/vice/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/vice/template b/srcpkgs/vice/template
index 0924767cfcfb..5981e45149d0 100644
--- a/srcpkgs/vice/template
+++ b/srcpkgs/vice/template
@@ -1,7 +1,7 @@
 # Template file for 'vice'
 pkgname=vice
 version=3.5
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="
 	$(vopt_enable sdl2 sdlui2)
@@ -28,7 +28,7 @@ makedepends="
 	$(vopt_if gtk3 gtk+3-devel)
 	$(vopt_if gtk3 pulseaudio-devel)
 	$(vopt_if gtk3 pango-devel)
-	$(vopt_if ffmpeg ffmpeg-devel)"
+	$(vopt_if ffmpeg ffmpeg4-devel)"
 short_desc="Emulator for C64, C128, CBM-II, PET, VIC20, Plus4 and C16"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"

From a8cc6f977612d1516721b461a3f9a61ec7e03c4a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 095/110] waypipe: revbump for ffmpeg-6.0

---
 srcpkgs/waypipe/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waypipe/template b/srcpkgs/waypipe/template
index 5c4161900060..1a46fe27f7d8 100644
--- a/srcpkgs/waypipe/template
+++ b/srcpkgs/waypipe/template
@@ -1,7 +1,7 @@
 # Template file for 'waypipe'
 pkgname=waypipe
 version=0.8.4
-revision=1
+revision=2
 build_style=meson
 # lto is off because it causes linking errors in armv6l and armv7l (due to NEON)
 configure_args="-Dwerror=false -Dwith_dmabuf=enabled -Dwith_lz4=enabled

From 167d1701a73c957716fcea8283493c4601a2bd71 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 096/110] wf-recorder: revbump for ffmpeg-6.0

---
 srcpkgs/wf-recorder/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/wf-recorder/template b/srcpkgs/wf-recorder/template
index e278eb001600..5d014a5f28af 100644
--- a/srcpkgs/wf-recorder/template
+++ b/srcpkgs/wf-recorder/template
@@ -1,7 +1,7 @@
 # Template file for 'wf-recorder'
 pkgname=wf-recorder
 version=0.3.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config scdoc wayland-devel"
 makedepends="wayland-protocols wayland-devel ffmpeg-devel x264-devel

From fafbc03076ff966943c1bb00992598182a3348a3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 097/110] xpra: revbump for ffmpeg-6.0

---
 srcpkgs/xpra/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xpra/template b/srcpkgs/xpra/template
index 38f83283b1e5..b6e01ff0a813 100644
--- a/srcpkgs/xpra/template
+++ b/srcpkgs/xpra/template
@@ -1,7 +1,7 @@
 # Template file for 'xpra'
 pkgname=xpra
 version=4.4.4
-revision=1
+revision=2
 build_style=python3-module
 make_build_args="--without-cuda_kernels --without-cuda_rebuild"
 make_install_args="$(vopt_with docs) ${make_build_args}"

From b009466a3cd8b4be508a9c6f3f77c76a1c2e9387 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:07:40 -0400
Subject: [PATCH 098/110] nv-codec-headers: update to 12.0.16.0

---
 srcpkgs/nv-codec-headers/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/nv-codec-headers/template b/srcpkgs/nv-codec-headers/template
index 3d422a61e489..251e057f826f 100644
--- a/srcpkgs/nv-codec-headers/template
+++ b/srcpkgs/nv-codec-headers/template
@@ -1,6 +1,6 @@
 # Template file for 'nv-codec-headers'
 pkgname=nv-codec-headers
-version=11.1.5.1
+version=12.0.16.0
 revision=1
 build_style=gnu-makefile
 short_desc="FFmpeg version of headers required to interface with Nvidias codec APIs"
@@ -8,7 +8,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="MIT"
 homepage="http://git.videolan.org/?p=ffmpeg/nv-codec-headers.git"
 distfiles="https://github.com/FFmpeg/nv-codec-headers/archive/n${version}.tar.gz"
-checksum=d095fbd56aa93772471a323be0ebe65504a0f43f06c76a30b6d25da77b06ae9c
+checksum=2a1533b65f55f9da52956faf0627ed3b74868ac0c7f269990edd21369113b48f
 
 post_install() {
 	sed -n '4,25p' include/ffnvcodec/nvEncodeAPI.h > LICENSE

From 7f126a07dfab9cac6dab60bf4d3d442e3c418b69 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:08:40 -0400
Subject: [PATCH 099/110] openimagedenoise: revbump for ffmpeg-6.0

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index db5ccdb055cc..cb90045afb63 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,7 +1,7 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
 version=1.4.3
-revision=1
+revision=2
 archs="x86_64*"
 build_style=cmake
 hostmakedepends="ispc python3"

From a91fc81e4fc3614c3bac333865153435f14695f3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:30:28 -0400
Subject: [PATCH 100/110] freecad: revbump for qt5-webengine-5.15.13

---
 srcpkgs/freecad/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/freecad/template b/srcpkgs/freecad/template
index f62023ee8ce4..e301f32d3540 100644
--- a/srcpkgs/freecad/template
+++ b/srcpkgs/freecad/template
@@ -1,7 +1,7 @@
 # Template file for 'freecad'
 pkgname=freecad
 version=0.20.2
-revision=3
+revision=4
 build_style=cmake
 
 _inst_prefix=/usr/lib/${pkgname}

From fd3fa2af3ec120dbafa6346307d0078408573bfa Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:31:45 -0400
Subject: [PATCH 101/110] shotcut: revbump for mlt7-7.14.0

---
 srcpkgs/shotcut/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/shotcut/template b/srcpkgs/shotcut/template
index 32583277dab2..8d8a7a0ebdeb 100644
--- a/srcpkgs/shotcut/template
+++ b/srcpkgs/shotcut/template
@@ -1,7 +1,7 @@
 # Template file for 'shotcut'
 pkgname=shotcut
 version=22.12.21
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSHOTCUT_VERSION=${version}"
 hostmakedepends="pkg-config qt5-tools-devel"

From 0100fe9a7f32b8219d919812729af4a10f69b736 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:30 -0400
Subject: [PATCH 102/110] shiboken2: revbump for qt5-5.15.8

---
 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch | 1 +
 srcpkgs/shiboken2/template                                 | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
 create mode 120000 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
new file mode 120000
index 000000000000..efcf3249bd88
--- /dev/null
+++ b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1 @@
+../../python3-pyside2/patches/importlib-machinery-bypass.patch
\ No newline at end of file
diff --git a/srcpkgs/shiboken2/template b/srcpkgs/shiboken2/template
index 084ecc3ba1e1..2a21998997eb 100644
--- a/srcpkgs/shiboken2/template
+++ b/srcpkgs/shiboken2/template
@@ -1,7 +1,7 @@
 # Template file for 'shiboken2'
 pkgname=shiboken2
 version=5.15.7
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/shiboken2"
 build_style=cmake

From 61f5c014d608268edd5f5e4ff3fded78fe75d951 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:53 -0400
Subject: [PATCH 103/110] python3-pyside2: update to 5.15.8

---
 .../patches/importlib-machinery-bypass.patch      | 15 +++++++++++++++
 srcpkgs/python3-pyside2/template                  |  9 +++++----
 2 files changed, 20 insertions(+), 4 deletions(-)
 create mode 100644 srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
new file mode 100644
index 000000000000..64c429584776
--- /dev/null
+++ b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1,15 @@
+Using this prevents an error around line 220 below it.
+"AttributeError: module 'importlib' has no attribute 'machinery'"
+The old backup logic is in place and compiles without issues.
+--- a/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:09:34.688912402 -0400
++++ b/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:10:03.395529582 -0400
+@@ -170,9 +170,6 @@
+
+     # 'zipstring_sequence' comes from signature.cpp
+     zipbytes = base64.b64decode(''.join(zipstring_sequence))
+-    if sys.version_info[0] >= 3:
+-        vzip = zipfile.ZipFile(io.BytesIO(zipbytes))
+-        return sys.meta_path, EmbeddableZipImporter(vzip)
+
+     # Old version for Python 2.7, only.
+     import os
diff --git a/srcpkgs/python3-pyside2/template b/srcpkgs/python3-pyside2/template
index 50e6ff260d3b..b50e62bd215d 100644
--- a/srcpkgs/python3-pyside2/template
+++ b/srcpkgs/python3-pyside2/template
@@ -1,11 +1,12 @@
 # Template file for 'python3-pyside2'
 pkgname=python3-pyside2
-version=5.15.5
-revision=2
+version=5.15.8
+revision=1
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/pyside2"
 build_style=cmake
-configure_args="-DPYTHON_EXECUTABLE=/usr/bin/python"
+configure_args="-DPYTHON_EXECUTABLE=/usr/bin/python -DCMAKE_BUILD_TYPE=None
+ -DBUILD_TESTS=OFF"
 hostmakedepends="cmake python3 shiboken2"
 makedepends="python3-devel libshiboken2-devel qt5-devel
  qt5-multimedia-devel qt5-tools-devel qt5-plugin-mysql qt5-plugin-odbc
@@ -23,7 +24,7 @@ maintainer="yopito <pierre.bourgin@free.fr>"
 license="LGPL-3.0-or-later"
 homepage="https://wiki.qt.io/Qt_for_Python"
 distfiles="https://download.qt.io/official_releases/QtForPython/pyside2/PySide2-${version}-src/${_pkgname}.tar.xz"
-checksum=3920a4fb353300260c9bc46ff70f1fb975c5e7efa22e9d51222588928ce19b33
+checksum=23436302c8deb5b4cbc769b205d09604e38ba83b40708efccb7bd8c9af6f6b5d
 
 build_options="webengine"
 desc_option_webengine="Build Qt5 WebEngine bindings"

From 1dee8b5c6a512061489328b82f85562484e4226e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:35 -0400
Subject: [PATCH 104/110] konqueror: revbump for ffmpeg-6.0

---
 srcpkgs/konqueror/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/konqueror/template b/srcpkgs/konqueror/template
index d8d0e73a78ab..c5bdba601d3c 100644
--- a/srcpkgs/konqueror/template
+++ b/srcpkgs/konqueror/template
@@ -1,11 +1,11 @@
 # Template file for 'konqueror'
 pkgname=konqueror
 version=23.04.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DDESKTOPTOJSON_EXECUTABLE=/usr/bin/desktoptojson"
 hostmakedepends="extra-cmake-modules python3 qt5-host-tools qt5-qmake kdoctools
-kcoreaddons kconfig gettext"
+ kcoreaddons kconfig gettext"
 makedepends="qt5-devel qt5-webengine-devel qt5-declarative-devel
  qt5-webchannel-devel qt5-location-devel kcmutils-devel kdelibs4support-devel
  karchive-devel khtml-devel kdesu-devel kactivities5-devel"

From 3c1b795a0f956b3eafd40fb28c1c5c695151fc23 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:58 -0400
Subject: [PATCH 105/110] qt5-speech: revbump for qt5-5.15.8

---
 srcpkgs/qt5-speech/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-speech/template b/srcpkgs/qt5-speech/template
index 3ecd10d50650..2d7d4d4d2453 100644
--- a/srcpkgs/qt5-speech/template
+++ b/srcpkgs/qt5-speech/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-speech'
 pkgname=qt5-speech
 version=5.15.7
-revision=2
+revision=3
 _commit=d32f4a479d38a11f547598004b975f4356424a16
 build_style=qmake
 configure_args="-- -flite -flite-alsa -speechd"

From bad1654720dadba34414577b98cf2b23c56b91b3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 18:38:50 -0400
Subject: [PATCH 106/110] qt5-styleplugins: revbump for qt5-5.15.8

---
 srcpkgs/qt5-styleplugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-styleplugins/template b/srcpkgs/qt5-styleplugins/template
index 96ed97d12cd2..30d93660a2a4 100644
--- a/srcpkgs/qt5-styleplugins/template
+++ b/srcpkgs/qt5-styleplugins/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-styleplugins'
 pkgname=qt5-styleplugins
 version=5.0.0
-revision=20
+revision=21
 _gitrev=335dbece103e2cbf6c7cf819ab6672c2956b17b3
 build_style=qmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From 0f5a8b040f5cad4d3fd3ad6a27af36e372e1fd05 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 27 Apr 2023 21:58:35 -0400
Subject: [PATCH 107/110] blender: update to 3.5.1

---
 srcpkgs/blender/patches/numpy-2.24.patch | 22 ----------------------
 srcpkgs/blender/template                 | 13 +++++++------
 2 files changed, 7 insertions(+), 28 deletions(-)
 delete mode 100644 srcpkgs/blender/patches/numpy-2.24.patch

diff --git a/srcpkgs/blender/patches/numpy-2.24.patch b/srcpkgs/blender/patches/numpy-2.24.patch
deleted file mode 100644
index 716315b74be7..000000000000
--- a/srcpkgs/blender/patches/numpy-2.24.patch
+++ /dev/null
@@ -1,22 +0,0 @@
-From 74e6e07cf7c67b55d384db72f5aa3892db8a3da6 Mon Sep 17 00:00:00 2001
-From: oreo639 <oreo6391@gmail.com>
-Date: Tue, 17 Jan 2023 14:36:54 -0800
-Subject: [PATCH] Remove usage of deprecated np.bool alias
-
----
- addons/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/addons/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py b/addons/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py
-index 6366434a6..8160c9e99 100644
---- a/release/scripts/addons/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py
-+++ b/release/scripts/addons/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py
-@@ -620,7 +620,7 @@ def set_poly_smoothing(gltf, pymesh, mesh, vert_normals, loop_vidxs):
-     # Try to guess which polys should be flat based on the fact that all the
-     # loop normals for a flat poly are = the poly's normal.
- 
--    poly_smooths = np.empty(num_polys, dtype=np.bool)
-+    poly_smooths = np.empty(num_polys, dtype=bool)
- 
-     poly_normals = np.empty(num_polys * 3, dtype=np.float32)
-     mesh.polygons.foreach_get('normal', poly_normals)
diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index d18bc88838ff..900bc17937c3 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -1,7 +1,7 @@
 # Template file for 'blender'
 pkgname=blender
-version=3.4.1
-revision=4
+version=3.5.1
+revision=1
 archs="x86_64* ppc64*"
 build_style="cmake"
 pycompile_dirs="/usr/share/blender/${version%.*}/scripts"
@@ -9,8 +9,8 @@ configure_args="-DWITH_INSTALL_PORTABLE=OFF -DWITH_PYTHON_INSTALL=OFF
  -DWITH_JACK=ON -DWITH_CODEC_FFMPEG=ON -DWITH_CODEC_SNDFILE=ON -DWITH_OPENMP=ON
  -DWITH_FFTW3=ON -DWITH_MOD_OCEANSIM=ON -DWITH_CYCLES_EMBREE=OFF -DWITH_OPENCOLORIO=ON
  -DWITH_IMAGE_OPENEXR=ON -DWITH_IMAGE_OPENJPEG=ON -DWITH_OPENSUBDIV=ON
- -DWITH_OPENCOLLADA=ON -DWITH_SYSTEM_GLEW=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
- -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_LIBDECOR=ON
+ -DWITH_OPENCOLLADA=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
+ -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_WAYLAND_LIBDECOR=ON
  -DWITH_BUILDINFO=OFF -DPYTHON_VERSION=${py3_ver} -DPYTHON_LIBPATH=/usr/lib
  -DPYTHON_LIBRARY='python${py3_ver}${py3_abiver}'
  -DPYTHON_INCLUDE_DIRS=/${py3_inc}"
@@ -22,14 +22,15 @@ makedepends="libgomp-devel libpng-devel tiff-devel python3-devel glu-devel
  opencolorio-devel opencollada-devel python3-numpy libXrender-devel
  OpenSubdiv-devel tbb-devel libxml2-devel openvdb-devel alembic-devel
  pugixml-devel libXxf86vm-devel libepoxy-devel gmp-devel gmpxx-devel
- wayland-protocols wayland-devel libxkbcommon-devel libdecor-devel"
+ wayland-protocols wayland-devel libxkbcommon-devel libdecor-devel
+ level-zero-devel"
 depends="desktop-file-utils hicolor-icon-theme"
 short_desc="3D graphics creation suite"
 maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="https://www.blender.org"
 distfiles="https://download.blender.org/source/blender-${version}.tar.xz"
-checksum=247c4c1228270c9010f4721c985cb5b628ab50abcf9f2678630737142eeb91c3
+checksum=bd7428c7e6cba5a900216269c32111dffaabaf1bdb5472f231965e615174a809
 python_version=3
 LDFLAGS="-Wl,-z,stack-size=2097152"
 # Blender tests are executed against a system installation of blender. This

From 4522c49f8a94d0ca61dbc103c0a5f6ffc5b869e5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 30 Apr 2023 20:22:26 -0400
Subject: [PATCH 108/110] gst-plugins-ugly1: revbump for ffmpeg-6.0

---
 srcpkgs/gst-plugins-ugly1/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-plugins-ugly1/template b/srcpkgs/gst-plugins-ugly1/template
index e254fd40f869..85ae64bc7a0a 100644
--- a/srcpkgs/gst-plugins-ugly1/template
+++ b/srcpkgs/gst-plugins-ugly1/template
@@ -1,6 +1,6 @@
 # Template file for 'gst-plugins-ugly1'
 pkgname=gst-plugins-ugly1
-version=1.20.3
+version=1.22.2
 revision=1
 build_style=meson
 configure_args="-Damrnb=disabled -Damrwbdec=disabled -Dsidplay=disabled"
@@ -15,4 +15,4 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname/1/}/${pkgname/1/}-${version}.tar.xz"
-checksum=8caa20789a09c304b49cf563d33cca9421b1875b84fcc187e4a385fa01d6aefd
+checksum=8f30f44db0bd063709bf6fbe55138e3a98af0abcb61c360f35582bbe10e80691

From 4d8166b1c5d85aad94e66ef2df272b80acf16cf8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 30 Apr 2023 20:22:26 -0400
Subject: [PATCH 109/110] gst-rtsp-server: revbump for ffmpeg-6.0

---
 srcpkgs/gst-rtsp-server/template | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index 8ceea8d34b4b..980fd72cdd4c 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
-version=1.20.3
-revision=3
+version=1.22.2
+revision=2
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="glib-devel gst-plugins-bad1-devel gobject-introspection
@@ -10,5 +10,5 @@ short_desc="GStreamer multimedia graph framework - rtsp server"
 maintainer="1is7ac3 <isaac.qa13@gmail.com>"
 license="LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
-distfiles="https://gstreamer.freedesktop.org/src/gst-rtsp-server/gst-rtsp-server-${version}.tar.xz"
-checksum=ee402718be9b127f0e5e66ca4c1b4f42e4926ec93ba307b7ccca5dc6cc9794ca
+distfiles="${homepage}/src/${pkgname}/${pkgname}-${version}.tar.xz"
+checksum=2be4aecfb88710100ea7115ed0216403e8094344ebf146094271b8d4d73828bf

From 64527953c6d70d820f222412e211a03c32043493 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 30 Apr 2023 20:22:26 -0400
Subject: [PATCH 110/110] gst-libav: revbump for ffmpeg-6.0

---
 srcpkgs/gst-libav/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index f082bd211c65..04c39bff1489 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,6 +1,6 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
-version=1.20.3
+version=1.22.2
 revision=2
 build_style=meson
 hostmakedepends="pkg-config yasm"
@@ -11,7 +11,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.0-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname}/${pkgname}-${version}.tar.xz"
-checksum=3fedd10560fcdfaa1b6462cbf79a38c4e7b57d7f390359393fc0cef6dbf27dfe
+checksum=fcaaf9878fe8f3bc82317ef13a1558824cb68df1f8968c6797f556c5e33bcffd
 
 case "$XBPS_TARGET_MACHINE" in
 	*-musl) # Required by musl for M_SQRT1_2

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (5 preceding siblings ...)
  2023-05-07 22:00 ` [PR PATCH] [Updated] " zlice
@ 2023-05-08  0:23 ` zlice
  2023-05-29  1:43 ` zlice
                   ` (90 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2023-05-08  0:23 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 3256 bytes --]

There is an updated pull request by zlice against master on the void-packages repository

https://github.com/zlice/void-packages ffmpeg6-split
https://github.com/void-linux/void-packages/pull/43761

ffmpeg6 split
[ci skip]


#### Testing the changes

- I tested the changes in this PR: **YES**

main testing has been vaapi in Firefox Nightly and enc/dec in Shotcut on Intel A770

#### New package

- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**

#### Local build testing

- I built this PR locally for my native architecture, **x86_64**

#### Discussion

Continuation of https://github.com/void-linux/void-packages/pull/36315

`libavresample` is deprecated, but marked as a dependency when trying to build other packages and install `ffmpeg`(6). I think the right way to handle this is make a meta package and the add to removals?


##### Commit naming / misc

~~Commits are 'dirty' right now, running with [gstreamer 1.22.1 updates](https://github.com/void-linux/void-packages/pull/42861) and [Intel OpenCL](https://github.com/void-linux/void-packages/pull/43084). This will also make [intel packages pr](https://github.com/void-linux/void-packages/pull/41132) obsolete.~~ (see Requirements below)

Maintainer for previous ffmpeg(4) was orphaned, I can put my name in there if that matters, though I don't exactly see myself keeping up on ffmpeg.

This updates QT5 which looks like it is usually hosted by Johnny. Not sure if there's any reason to stay there or these sources are fine.

##### STILL FFMPEG4

These are a mix of emulators, games and/or older packages.

- attract (multiple patches in master)
- audacity  (3.2.x+ should work but requires wxWidgets dev 3.1.x)
- ccextractor (master patches? no release)
- vice
- kodi
- mlt (only dep left is flowblade)
- ~~synfig (mlt)~~ (work with mlt7, bump synfigstudio)
- tvheadend
- ssr
- spek-alternative
- ppsspp
- olive
- moc
- mediastreamer
- libextractor
- idjc
- hedgewars
- ~~ffmpegthumbnailer~~ (patches for moviedecoder.xxx files)
- ~~ffmpegthumbs~~ (latest compiles)
- deadbeef
- omxplayer
- qtav (fork has ffmpeg 5 patch - https://github.com/cmguo/QtAV)
- `vlc` (vlc4 will support ffmpeg5, there's a patch to build 3.x with ffmpeg5 but it will lack vaapi)
- `osg` (OpenSceneGraph plus `xine-lib`)


##### HAVE NOT BUILT YET

- omxplayer (rpi only? ffmpeg4)
- kodi (big, but ffmpeg4)


##### UPDATED (for ffmpeg6)

- blender: update to 3.5.1
- unpaper: update to 7.0.0.
- guvcview: update to 2.0.8.
- qt5: update to 5.15.8
- qt5-webengine: update to 5.18.13
- shiboken2: revbump for qt5.15.8 (patch)
- python3-pyside2: update to 5.15.8 (patch)


##### Requirements

- [gstreamer 1.22.2](https://github.com/void-linux/void-packages/pull/42861) - a few packages use ffmpeg-devel and require a revbump

- [Intel Packages](https://github.com/void-linux/void-packages/pull/41132) - ffmpeg4 uses different libraries than 6 (libmfx / Intel-MediaSDK vs only oneVPL that Intel is moving to), both are included here

A patch file from https://github.com/void-linux/void-packages/pull/43761.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ffmpeg6-split-43761.patch --]
[-- Type: text/x-diff, Size: 790913 bytes --]

From 25aec7f003c71ca658c00e37bc4707c391adc219 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:55:46 -0400
Subject: [PATCH 001/115] ffmpeg: update to 6.0.

---
 common/shlibs                                 | 26 +++++---
 srcpkgs/ffmpeg/files/altivec.patch            | 60 -------------------
 .../patches/armv5tel-floating-point.patch     | 18 ------
 .../workaround-mesa-readeon-vaapi-bug.patch   | 28 ---------
 srcpkgs/ffmpeg/template                       | 31 +++++-----
 5 files changed, 33 insertions(+), 130 deletions(-)
 delete mode 100644 srcpkgs/ffmpeg/files/altivec.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch

diff --git a/common/shlibs b/common/shlibs
index 89f7e53081f8..9497f6499aa2 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -390,15 +390,23 @@ libid3tag.so.0 libid3tag-0.15.1b_1
 libgif.so.7 giflib-5.1.0_1
 libImlib2.so.1 imlib2-1.4.2_1
 libmp3lame.so.0 lame-3.98.2_1
-libavdevice.so.58 libavdevice-4.0_1
-libavformat.so.58 libavformat-4.0_1
-libswscale.so.5 libswscale-4.0_1
-libswresample.so.3 libswresample-4.0_1
-libavresample.so.4 libavresample-4.0_1
-libpostproc.so.55 libpostproc-4.0_1
-libavcodec.so.58 libavcodec-4.0_1
-libavutil.so.56 libavutil-4.0_1
-libavfilter.so.7 libavfilter-4.0_1
+libavdevice.so.60 libavdevice-6.0_1
+libavformat.so.60 libavformat-6.0_1
+libswscale.so.7 libswscale-6.0_1
+libswresample.so.4 libswresample-6.0_1
+libpostproc.so.57 libpostproc-6.0_1
+libavcodec.so.60 libavcodec-6.0_1
+libavutil.so.58 libavutil-6.0_1
+libavfilter.so.9 libavfilter-6.0_1
+libavdevice.so.58 libavdevice4-4.0_1
+libavformat.so.58 libavformat4-4.0_1
+libswscale.so.5 libswscale4-4.0_1
+libswresample.so.3 libswresample4-4.0_1
+libavresample.so.4 libavresample4-4.0_1
+libpostproc.so.55 libpostproc4-4.0_1
+libavcodec.so.58 libavcodec4-4.0_1
+libavutil.so.56 libavutil4-4.0_1
+libavfilter.so.7 libavfilter4-4.0_1
 libSDL-1.2.so.0 SDL-1.2.14_1
 libSDL_image-1.2.so.0 SDL_image-1.2.10_1
 libx264.so.157 x264-20190507.2245_1
diff --git a/srcpkgs/ffmpeg/files/altivec.patch b/srcpkgs/ffmpeg/files/altivec.patch
deleted file mode 100644
index 9c5720046332..000000000000
--- a/srcpkgs/ffmpeg/files/altivec.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-revert some altivec specific change on all ppc* except ppc64le*
-
-q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
-conditionally, for ppc* but not ppc64le* (the new code is valid for
-POWER8 VSX which LE targets as a baseline but not BE)"
-
-
-This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
----
- libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
- 1 file changed, 20 insertions(+), 4 deletions(-)
-
-diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
-index 536545293d..c1e2852adb 100644
---- a/libswscale/ppc/yuv2rgb_altivec.c
-+++ b/libswscale/ppc/yuv2rgb_altivec.c
-@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-     vector signed short R1, G1, B1;                                           \
-     vector unsigned char R, G, B;                                             \
-                                                                               \
-+    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
-+    vector unsigned char align_perm;                                          \
-+                                                                              \
-     vector signed short lCY       = c->CY;                                    \
-     vector signed short lOY       = c->OY;                                    \
-     vector signed short lCRV      = c->CRV;                                   \
-@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
-                                                                               \
-         for (j = 0; j < w / 16; j++) {                                        \
--            y0 = vec_xl(0, y1i);                                              \
-+            y1ivP = (const vector unsigned char *) y1i;                       \
-+            y2ivP = (const vector unsigned char *) y2i;                       \
-+            uivP  = (const vector unsigned char *) ui;                        \
-+            vivP  = (const vector unsigned char *) vi;                        \
-+                                                                              \
-+            align_perm = vec_lvsl(0, y1i);                                    \
-+            y0 = (vector unsigned char)                                       \
-+                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
-                                                                               \
--            y1 = vec_xl(0, y2i);                                              \
-+            align_perm = vec_lvsl(0, y2i);                                    \
-+            y1 = (vector unsigned char)                                       \
-+                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
-                                                                               \
--            u = (vector signed char) vec_xl(0, ui);                           \
-+            align_perm = vec_lvsl(0, ui);                                     \
-+            u = (vector signed char)                                          \
-+                    vec_perm(uivP[0], uivP[1], align_perm);                   \
-                                                                               \
--            v = (vector signed char) vec_xl(0, vi);                           \
-+            align_perm = vec_lvsl(0, vi);                                     \
-+            v = (vector signed char)                                          \
-+                    vec_perm(vivP[0], vivP[1], align_perm);                   \
-                                                                               \
-             u = (vector signed char)                                          \
-                     vec_sub(u,                                                \
--- 
-2.27.0
-
diff --git a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
deleted file mode 100644
index 9a55178c74f0..000000000000
--- a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
-+++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
-@@ -39,6 +39,15 @@
- #endif
- #include <fenv.h>
- 
-+#if (FE_ALL_EXCEPT == 0)
-+/* E.g. ARM soft float does not define these */
-+#define FE_INVALID    0
-+#define FE_DIVBYZERO  0
-+#define FE_OVERFLOW   0
-+#define FE_UNDERFLOW  0
-+#define FE_INEXACT    0
-+#endif
-+
- #if CONFIG_LIBFONTCONFIG
- #include <fontconfig/fontconfig.h>
- #endif
diff --git a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
deleted file mode 100644
index 00e3f68a415b..000000000000
--- a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
-From: Rainer Hochecker <fernetmenta@online.de>
-Date: Sat, 26 Jan 2019 19:48:35 +0100
-Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
-
-This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
-It was hit frequently when watching h264 channels received via DVB-X.
-Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
----
- libavcodec/vaapi_h264.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
-index 5854587a255..f12fdc457a4 100644
---- a/libavcodec/vaapi_h264.c
-+++ b/libavcodec/vaapi_h264.c
-@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
-     H264SliceContext *sl = &h->slice_ctx[0];
-     int ret;
- 
-+    if (pic->nb_slices == 0) {
-+        ret = AVERROR_INVALIDDATA;
-+        goto finish;
-+    }
-+
-     ret = ff_vaapi_decode_issue(avctx, pic);
-     if (ret < 0)
-         goto finish;
diff --git a/srcpkgs/ffmpeg/template b/srcpkgs/ffmpeg/template
index 23a3d5c9967b..3d99e5173697 100644
--- a/srcpkgs/ffmpeg/template
+++ b/srcpkgs/ffmpeg/template
@@ -1,15 +1,15 @@
 # Template file for 'ffmpeg'
 # audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
 pkgname=ffmpeg
-version=4.4.3
-revision=2
+version=6.0
+revision=1
 short_desc="Decoding, encoding and streaming software"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="https://www.ffmpeg.org"
 changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
 distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
-checksum=6c5b6c195e61534766a0b5fe16acc919170c883362612816d0a1c7f4f947006e
+checksum=57be87c22d9b49c112b6d24bc67d42508660e6b718b3db89c44e47e289137082
 
 hostmakedepends="pkg-config perl yasm"
 makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
@@ -26,12 +26,13 @@ makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-deve
  $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
  $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
  $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
- $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers Vulkan-Tools Vulkan-ValidationLayers')
+ $(vopt_if onevpl 'onevpl onevpl-devel')
  $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
 depends="ffplay>=${version}_${revision}"
 
 build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
- dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec onevpl"
 build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
 desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
 desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
@@ -39,7 +40,8 @@ desc_option_sofa="Enable support for AES SOFA"
 desc_option_webp="Enable support for WebP"
 
 case "$XBPS_TARGET_MACHINE" in
-	i686*|x86_64*) build_options_default+=" vaapi vdpau nvenc nvdec";;
+	i686*) build_options_default+=" vaapi vdpau nvenc nvdec";;
+	x86_64*) build_options_default+=" vaapi vdpau nvenc nvdec onevpl";;
 	ppc64*) build_options_default+=" vaapi vdpau";;
 	mips*) CFLAGS="-mnan=legacy";;
 esac
@@ -114,18 +116,19 @@ do_configure() {
 		$(vopt_enable x265 libx265) \
 		$(vopt_enable v4l2 libv4l2) \
 		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
-		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		--enable-libbs2b --enable-libvidstab \
 		$(vopt_enable dav1d libdav1d) \
 		$(vopt_enable zimg libzimg) \
 		$(vopt_enable webp libwebp) \
 		$(vopt_enable sofa libmysofa) \
 		$(vopt_enable vulkan) \
+		$(vopt_enable onevpl libvpl) \
 		$(vopt_enable drm libdrm) \
 		$(vopt_enable svtav1 libsvtav1) \
 		$(vopt_enable srt libsrt) \
 		$(vopt_enable rist librist) \
-		$(vopt_if nvenc '--enable-nvenc') \
-		$(vopt_if nvdec '--enable-nvdec')
+		$(vopt_enable nvenc nvenc) \
+		$(vopt_enable nvdec nvdec)
 }
 do_build() {
 	make ${makejobs}
@@ -148,10 +151,8 @@ libavdevice_package() {
 	}
 }
 libavresample_package() {
-	short_desc="FFmpeg audio resampling library"
-	pkg_install() {
-		vmove "usr/lib/libavresample.so.*"
-	}
+	short_desc="Package deprecated, removal needed"
+	build_style=meta
 }
 libavformat_package() {
 	short_desc="FFmpeg file format library"
@@ -198,9 +199,9 @@ ffmpeg-devel_package() {
 		libavfilter>=${version}_${revision}
 		libpostproc>=${version}_${revision}
 		libswscale>=${version}_${revision}
-		libswresample>=${version}_${revision}
-		libavresample>=${version}_${revision}"
+		libswresample>=${version}_${revision}"
 	short_desc+=" - development files"
+	conflicts="ffmpeg4-devel"
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig

From 1ca2204fe9d5819d469ff21c06343018583837f8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:56:22 -0400
Subject: [PATCH 002/115] New package: ffmpeg4-4.4.3.

---
 srcpkgs/ffmpeg4-devel                         |   1 +
 srcpkgs/ffmpeg4/files/altivec.patch           |  60 +++++
 .../patches/armv5tel-floating-point.patch     |  18 ++
 .../workaround-mesa-readeon-vaapi-bug.patch   |  28 +++
 srcpkgs/ffmpeg4/template                      | 217 ++++++++++++++++++
 srcpkgs/libavcodec4                           |   1 +
 srcpkgs/libavdevice4                          |   1 +
 srcpkgs/libavfilter4                          |   1 +
 srcpkgs/libavformat4                          |   1 +
 srcpkgs/libavresample4                        |   1 +
 srcpkgs/libavutil4                            |   1 +
 srcpkgs/libpostproc4                          |   1 +
 srcpkgs/libswresample4                        |   1 +
 srcpkgs/libswscale4                           |   1 +
 14 files changed, 333 insertions(+)
 create mode 120000 srcpkgs/ffmpeg4-devel
 create mode 100644 srcpkgs/ffmpeg4/files/altivec.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
 create mode 100644 srcpkgs/ffmpeg4/template
 create mode 120000 srcpkgs/libavcodec4
 create mode 120000 srcpkgs/libavdevice4
 create mode 120000 srcpkgs/libavfilter4
 create mode 120000 srcpkgs/libavformat4
 create mode 120000 srcpkgs/libavresample4
 create mode 120000 srcpkgs/libavutil4
 create mode 120000 srcpkgs/libpostproc4
 create mode 120000 srcpkgs/libswresample4
 create mode 120000 srcpkgs/libswscale4

diff --git a/srcpkgs/ffmpeg4-devel b/srcpkgs/ffmpeg4-devel
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/ffmpeg4-devel
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/ffmpeg4/files/altivec.patch b/srcpkgs/ffmpeg4/files/altivec.patch
new file mode 100644
index 000000000000..9c5720046332
--- /dev/null
+++ b/srcpkgs/ffmpeg4/files/altivec.patch
@@ -0,0 +1,60 @@
+revert some altivec specific change on all ppc* except ppc64le*
+
+q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
+conditionally, for ppc* but not ppc64le* (the new code is valid for
+POWER8 VSX which LE targets as a baseline but not BE)"
+
+
+This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
+---
+ libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
+ 1 file changed, 20 insertions(+), 4 deletions(-)
+
+diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
+index 536545293d..c1e2852adb 100644
+--- a/libswscale/ppc/yuv2rgb_altivec.c
++++ b/libswscale/ppc/yuv2rgb_altivec.c
+@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+     vector signed short R1, G1, B1;                                           \
+     vector unsigned char R, G, B;                                             \
+                                                                               \
++    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
++    vector unsigned char align_perm;                                          \
++                                                                              \
+     vector signed short lCY       = c->CY;                                    \
+     vector signed short lOY       = c->OY;                                    \
+     vector signed short lCRV      = c->CRV;                                   \
+@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
+                                                                               \
+         for (j = 0; j < w / 16; j++) {                                        \
+-            y0 = vec_xl(0, y1i);                                              \
++            y1ivP = (const vector unsigned char *) y1i;                       \
++            y2ivP = (const vector unsigned char *) y2i;                       \
++            uivP  = (const vector unsigned char *) ui;                        \
++            vivP  = (const vector unsigned char *) vi;                        \
++                                                                              \
++            align_perm = vec_lvsl(0, y1i);                                    \
++            y0 = (vector unsigned char)                                       \
++                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
+                                                                               \
+-            y1 = vec_xl(0, y2i);                                              \
++            align_perm = vec_lvsl(0, y2i);                                    \
++            y1 = (vector unsigned char)                                       \
++                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
+                                                                               \
+-            u = (vector signed char) vec_xl(0, ui);                           \
++            align_perm = vec_lvsl(0, ui);                                     \
++            u = (vector signed char)                                          \
++                    vec_perm(uivP[0], uivP[1], align_perm);                   \
+                                                                               \
+-            v = (vector signed char) vec_xl(0, vi);                           \
++            align_perm = vec_lvsl(0, vi);                                     \
++            v = (vector signed char)                                          \
++                    vec_perm(vivP[0], vivP[1], align_perm);                   \
+                                                                               \
+             u = (vector signed char)                                          \
+                     vec_sub(u,                                                \
+-- 
+2.27.0
+
diff --git a/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
new file mode 100644
index 000000000000..9a55178c74f0
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
@@ -0,0 +1,18 @@
+--- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
++++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
+@@ -39,6 +39,15 @@
+ #endif
+ #include <fenv.h>
+ 
++#if (FE_ALL_EXCEPT == 0)
++/* E.g. ARM soft float does not define these */
++#define FE_INVALID    0
++#define FE_DIVBYZERO  0
++#define FE_OVERFLOW   0
++#define FE_UNDERFLOW  0
++#define FE_INEXACT    0
++#endif
++
+ #if CONFIG_LIBFONTCONFIG
+ #include <fontconfig/fontconfig.h>
+ #endif
diff --git a/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
new file mode 100644
index 000000000000..00e3f68a415b
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
@@ -0,0 +1,28 @@
+From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
+From: Rainer Hochecker <fernetmenta@online.de>
+Date: Sat, 26 Jan 2019 19:48:35 +0100
+Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
+
+This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
+It was hit frequently when watching h264 channels received via DVB-X.
+Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
+---
+ libavcodec/vaapi_h264.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
+index 5854587a255..f12fdc457a4 100644
+--- a/libavcodec/vaapi_h264.c
++++ b/libavcodec/vaapi_h264.c
+@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
+     H264SliceContext *sl = &h->slice_ctx[0];
+     int ret;
+ 
++    if (pic->nb_slices == 0) {
++        ret = AVERROR_INVALIDDATA;
++        goto finish;
++    }
++
+     ret = ff_vaapi_decode_issue(avctx, pic);
+     if (ret < 0)
+         goto finish;
diff --git a/srcpkgs/ffmpeg4/template b/srcpkgs/ffmpeg4/template
new file mode 100644
index 000000000000..e736c205371d
--- /dev/null
+++ b/srcpkgs/ffmpeg4/template
@@ -0,0 +1,217 @@
+# Template file for 'ffmpeg4'
+# audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
+pkgname=ffmpeg4
+version=4.4.3
+revision=1
+short_desc="Decoding, encoding and streaming software - ffmpeg4 libraries only"
+maintainer="Orphaned <orphan@voidlinux.org>"
+license="GPL-3.0-or-later"
+homepage="https://www.ffmpeg.org"
+changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
+distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
+checksum=6c5b6c195e61534766a0b5fe16acc919170c883362612816d0a1c7f4f947006e
+
+hostmakedepends="pkg-config perl yasm"
+makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
+ libXext-devel libXvMC-devel libxcb-devel lame-devel libtheora-devel
+ libvorbis-devel x264-devel xvidcore-devel jack-devel SDL2-devel
+ libcdio-paranoia-devel librtmp-devel libmodplug-devel gnutls-devel
+ speex-devel celt-devel harfbuzz-devel libass-devel opus-devel ocl-icd-devel
+ libbs2b-devel libvidstab-devel $(vopt_if pulseaudio pulseaudio-devel)
+ $(vopt_if vaapi libva-devel) $(vopt_if vdpau libvdpau-devel)
+ $(vopt_if x265 x265-devel) $(vopt_if v4l2 v4l-utils-devel)
+ $(vopt_if fdk_aac fdk-aac-devel) $(vopt_if vpx libvpx-devel)
+ $(vopt_if aom libaom-devel) $(vopt_if sndio sndio-devel)
+ $(vopt_if dav1d libdav1d-devel) $(vopt_if zimg zimg-devel)
+ $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
+ $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
+ $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if mfx 'libmfx libmfx-devel')
+ $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
+
+build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec mfx"
+build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
+
+desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
+desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
+desc_option_sofa="Enable support for AES SOFA"
+desc_option_webp="Enable support for WebP"
+
+case "$XBPS_TARGET_MACHINE" in
+	i686*) build_options_default+=" vaapi vdpau nvenc nvdec";;
+	x86_64*) build_options_default+=" vaapi vdpau mfx nvenc nvdec";;
+	ppc64*) build_options_default+=" vaapi vdpau";;
+	mips*) CFLAGS="-mnan=legacy";;
+esac
+
+if [ "$XBPS_TARGET_WORDSIZE" != "32" ]; then
+	build_options_default+=" svtav1"
+fi
+
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+fi
+
+_apply_patch() {
+	local args="$1" pname="$(basename $2)"
+
+	if [ ! -f ".${pname}_done" ]; then
+		patch -N $args -i $2
+		touch .${pname}_done
+	fi
+}
+
+post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64le*) ;;
+		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
+	esac
+}
+
+do_configure() {
+	# Fix gcc on x86_64-musl only
+	if [ "$XBPS_TARGET_MACHINE" = "x86_64-musl" ]; then
+		sed -i configure -e "s;_cflags_speed='-O3';_cflags_speed='-O2';"
+	fi
+
+	if [ "$CROSS_BUILD" ]; then
+		case "$XBPS_TARGET_MACHINE" in
+			arm*) _arch="arm";;
+			aarch64*) _arch="aarch64";;
+			mips*) _arch="mips";;
+			ppc64*) _arch="ppc64";;
+			ppc*) _arch="ppc";;
+			*) _arch="${XBPS_TARGET_MACHINE%%-musl}";;
+		esac
+
+		_args+=" --enable-cross-compile
+			--sysroot=$XBPS_CROSS_BASE
+			--cross-prefix=${XBPS_CROSS_TRIPLET}-
+			--target-os=linux --arch=${_arch}"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc|ppc-musl) _args+=" --disable-altivec";;
+	esac
+
+	if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+		_args+=" --extra-libs=-latomic"
+	fi
+
+	./configure --prefix=/usr --disable-debug --enable-gpl --enable-gnutls \
+		--disable-stripping \
+		--enable-libcdio --enable-version3 --enable-runtime-cpudetect \
+		--enable-libmp3lame --enable-libvorbis --enable-libxvid \
+		--enable-libx264 $(vopt_enable vpx libvpx) --enable-libtheora \
+		--enable-shared --enable-static --enable-libxcb \
+		$(vopt_enable pulseaudio libpulse) --enable-libfreetype --enable-libmodplug \
+		--enable-libspeex --enable-libcelt --enable-libass \
+		--enable-libopus --enable-librtmp --enable-libjack \
+		$(vopt_if fdk_aac '--enable-nonfree --enable-libfdk-aac') \
+		--disable-libopencore_amrnb --disable-libopencore_amrwb \
+		--disable-libopenjpeg \
+		--enable-postproc --enable-opencl ${_args} \
+		$(vopt_enable x265 libx265) \
+		$(vopt_enable v4l2 libv4l2) \
+		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
+		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		$(vopt_enable dav1d libdav1d) \
+		$(vopt_enable zimg libzimg) \
+		$(vopt_enable webp libwebp) \
+		$(vopt_enable sofa libmysofa) \
+		$(vopt_enable vulkan) \
+		$(vopt_enable drm libdrm) \
+		$(vopt_enable svtav1 libsvtav1) \
+		$(vopt_enable srt libsrt) \
+		$(vopt_enable rist librist) \
+		$(vopt_enable mfx libmfx) \
+		$(vopt_if nvenc '--enable-nvenc') \
+		$(vopt_if nvdec '--enable-nvdec')
+}
+do_build() {
+	make ${makejobs}
+	make doc/ff{mpeg,play}.1
+}
+do_install() {
+	make DESTDIR=${DESTDIR} install install-man
+	rm -rf ${DESTDIR}/usr/bin
+}
+
+libavcodec4_package() {
+	short_desc="FFmpeg codec library"
+	pkg_install() {
+		vmove "usr/lib/libavcodec.so.*"
+	}
+}
+libavdevice4_package() {
+	short_desc="FFmpeg device handling library"
+	pkg_install() {
+		vmove "usr/lib/libavdevice.so.*"
+	}
+}
+libavresample4_package() {
+	short_desc="FFmpeg audio resampling library"
+	pkg_install() {
+		vmove "usr/lib/libavresample.so.*"
+	}
+}
+libavformat4_package() {
+	short_desc="FFmpeg file format library"
+	pkg_install() {
+		vmove "usr/lib/libavformat.so.*"
+	}
+}
+libavutil4_package() {
+	short_desc="FFmpeg utility library"
+	pkg_install() {
+		vmove "usr/lib/libavutil.so.*"
+	}
+}
+libavfilter4_package() {
+	short_desc="FFmpeg audio/video filter library"
+	pkg_install() {
+		vmove "usr/lib/libavfilter.so.*"
+	}
+}
+libpostproc4_package() {
+	short_desc="FFmpeg video postprocessing library"
+	pkg_install() {
+		vmove "usr/lib/libpostproc.so.*"
+	}
+}
+libswscale4_package() {
+	short_desc="FFmpeg video scaling library"
+	pkg_install() {
+		vmove "usr/lib/libswscale.so.*"
+	}
+}
+libswresample4_package() {
+	short_desc="FFmpeg video resampling library"
+	pkg_install() {
+		vmove "usr/lib/libswresample.so.*"
+	}
+}
+ffmpeg4-devel_package() {
+	depends="
+		libavcodec4>=${version}_${revision}
+		libavdevice4>=${version}_${revision}
+		libavformat4>=${version}_${revision}
+		libavutil4>=${version}_${revision}
+		libavfilter4>=${version}_${revision}
+		libpostproc4>=${version}_${revision}
+		libswscale4>=${version}_${revision}
+		libswresample4>=${version}_${revision}
+		libavresample4>=${version}_${revision}"
+	short_desc+=" - development files"
+	conflicts="ffmpeg-devel"
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove usr/lib/*.a
+		vmove usr/lib/*.so
+		vmove usr/share/ffmpeg/examples
+		vmove usr/share/man/man3
+	}
+}
diff --git a/srcpkgs/libavcodec4 b/srcpkgs/libavcodec4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavcodec4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavdevice4 b/srcpkgs/libavdevice4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavdevice4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavfilter4 b/srcpkgs/libavfilter4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavfilter4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavformat4 b/srcpkgs/libavformat4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavformat4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavresample4 b/srcpkgs/libavresample4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavutil4 b/srcpkgs/libavutil4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavutil4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libpostproc4 b/srcpkgs/libpostproc4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libpostproc4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswresample4 b/srcpkgs/libswresample4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libswresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswscale4 b/srcpkgs/libswscale4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libswscale4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file

From 9114267121dc20e29a132a07a7a6b39de8b3f7f3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:04 -0400
Subject: [PATCH 003/115] opencv: update to 4.7.0.

---
 common/shlibs           | 104 ++++++++++++++++++++--------------------
 srcpkgs/opencv/template |   8 ++--
 2 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index 9497f6499aa2..fcc7401be626 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2137,58 +2137,58 @@ libcapstone.so.4 capstone-4.0_1
 libhavege.so.2 libhaveged-1.9.11_1
 libnih.so.1 libnih-1.0.3_1
 libnih-dbus.so.1 libnih-1.0.3_1
-libopencv_quality.so.406 libopencv-4.6.0_1
-libopencv_reg.so.406 libopencv-4.6.0_1
-libopencv_surface_matching.so.406 libopencv-4.6.0_1
-libopencv_xphoto.so.406 libopencv-4.6.0_1
-libopencv_freetype.so.406 libopencv-4.6.0_1
-libopencv_fuzzy.so.406 libopencv-4.6.0_1
-libopencv_hfs.so.406 libopencv-4.6.0_1
-libopencv_img_hash.so.406 libopencv-4.6.0_1
-libopencv_line_descriptor.so.406 libopencv-4.6.0_1
-libopencv_saliency.so.406 libopencv-4.6.0_1
-libopencv_structured_light.so.406 libopencv-4.6.0_1
-libopencv_aruco.so.406 libopencv-4.6.0_1
-libopencv_bgsegm.so.406 libopencv-4.6.0_1
-libopencv_bioinspired.so.406 libopencv-4.6.0_1
-libopencv_ccalib.so.406 libopencv-4.6.0_1
-libopencv_face.so.406 libopencv-4.6.0_1
-libopencv_tracking.so.406 libopencv-4.6.0_1
-libopencv_xfeatures2d.so.406 libopencv-4.6.0_1
-libopencv_optflow.so.406 libopencv-4.6.0_1
-libopencv_ximgproc.so.406 libopencv-4.6.0_1
-libopencv_plot.so.406 libopencv-4.6.0_1
-libopencv_text.so.406 libopencv-4.6.0_1
-libopencv_ml.so.406 libopencv-4.6.0_1
-libopencv_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn.so.406 libopencv-4.6.0_1
-libopencv_shape.so.406 libopencv-4.6.0_1
-libopencv_stitching.so.406 libopencv-4.6.0_1
-libopencv_photo.so.406 libopencv-4.6.0_1
-libopencv_video.so.406 libopencv-4.6.0_1
-libopencv_calib3d.so.406 libopencv-4.6.0_1
-libopencv_features2d.so.406 libopencv-4.6.0_1
-libopencv_flann.so.406 libopencv-4.6.0_1
-libopencv_highgui.so.406 libopencv-4.6.0_1
-libopencv_videoio.so.406 libopencv-4.6.0_1
-libopencv_imgcodecs.so.406 libopencv-4.6.0_1
-libopencv_imgproc.so.406 libopencv-4.6.0_1
-libopencv_core.so.406 libopencv-4.6.0_1
-libopencv_superres.so.406 libopencv-4.6.0_1
-libopencv_videostab.so.406 libopencv-4.6.0_1
-libopencv_gapi.so.406 libopencv-4.6.0_1
-libopencv_xobjdetect.so.406 libopencv-4.6.0_1
-libopencv_datasets.so.406 libopencv-4.6.0_1
-libopencv_dnn_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn_superres.so.406 libopencv-4.6.0_1
-libopencv_dpm.so.406 libopencv-4.6.0_1
-libopencv_phase_unwrapping.so.406 libopencv-4.6.0_1
-libopencv_stereo.so.406 libopencv-4.6.0_1
-libopencv_rapid.so.406 libopencv-4.6.0_1
-libopencv_intensity_transform.so.406 libopencv-4.6.0_1
-libopencv_alphamat.so.406 libopencv-4.6.0_1
-libopencv_barcode.so.406 libopencv-4.6.0_1
-libopencv_mcc.so.406 libopencv-4.6.0_1
+libopencv_quality.so.407 libopencv-4.7.0_1
+libopencv_reg.so.407 libopencv-4.7.0_1
+libopencv_surface_matching.so.407 libopencv-4.7.0_1
+libopencv_xphoto.so.407 libopencv-4.7.0_1
+libopencv_freetype.so.407 libopencv-4.7.0_1
+libopencv_fuzzy.so.407 libopencv-4.7.0_1
+libopencv_hfs.so.407 libopencv-4.7.0_1
+libopencv_img_hash.so.407 libopencv-4.7.0_1
+libopencv_line_descriptor.so.407 libopencv-4.7.0_1
+libopencv_saliency.so.407 libopencv-4.7.0_1
+libopencv_structured_light.so.407 libopencv-4.7.0_1
+libopencv_aruco.so.407 libopencv-4.7.0_1
+libopencv_bgsegm.so.407 libopencv-4.7.0_1
+libopencv_bioinspired.so.407 libopencv-4.7.0_1
+libopencv_ccalib.so.407 libopencv-4.7.0_1
+libopencv_face.so.407 libopencv-4.7.0_1
+libopencv_tracking.so.407 libopencv-4.7.0_1
+libopencv_xfeatures2d.so.407 libopencv-4.7.0_1
+libopencv_optflow.so.407 libopencv-4.7.0_1
+libopencv_ximgproc.so.407 libopencv-4.7.0_1
+libopencv_plot.so.407 libopencv-4.7.0_1
+libopencv_text.so.407 libopencv-4.7.0_1
+libopencv_ml.so.407 libopencv-4.7.0_1
+libopencv_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn.so.407 libopencv-4.7.0_1
+libopencv_shape.so.407 libopencv-4.7.0_1
+libopencv_stitching.so.407 libopencv-4.7.0_1
+libopencv_photo.so.407 libopencv-4.7.0_1
+libopencv_video.so.407 libopencv-4.7.0_1
+libopencv_calib3d.so.407 libopencv-4.7.0_1
+libopencv_features2d.so.407 libopencv-4.7.0_1
+libopencv_flann.so.407 libopencv-4.7.0_1
+libopencv_highgui.so.407 libopencv-4.7.0_1
+libopencv_videoio.so.407 libopencv-4.7.0_1
+libopencv_imgcodecs.so.407 libopencv-4.7.0_1
+libopencv_imgproc.so.407 libopencv-4.7.0_1
+libopencv_core.so.407 libopencv-4.7.0_1
+libopencv_superres.so.407 libopencv-4.7.0_1
+libopencv_videostab.so.407 libopencv-4.7.0_1
+libopencv_gapi.so.407 libopencv-4.7.0_1
+libopencv_xobjdetect.so.407 libopencv-4.7.0_1
+libopencv_datasets.so.407 libopencv-4.7.0_1
+libopencv_dnn_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn_superres.so.407 libopencv-4.7.0_1
+libopencv_dpm.so.407 libopencv-4.7.0_1
+libopencv_phase_unwrapping.so.407 libopencv-4.7.0_1
+libopencv_stereo.so.407 libopencv-4.7.0_1
+libopencv_rapid.so.407 libopencv-4.7.0_1
+libopencv_intensity_transform.so.407 libopencv-4.7.0_1
+libopencv_alphamat.so.407 libopencv-4.7.0_1
+libopencv_barcode.so.407 libopencv-4.7.0_1
+libopencv_mcc.so.407 libopencv-4.7.0_1
 libuniconf.so.4.6 wvstreams-4.6.1_20
 libwvbase.so.4.6 wvstreams-4.6.1_20
 libwvutils.so.4.6 wvstreams-4.6.1_20
diff --git a/srcpkgs/opencv/template b/srcpkgs/opencv/template
index 69c635b1ad2b..41f3183f1582 100644
--- a/srcpkgs/opencv/template
+++ b/srcpkgs/opencv/template
@@ -1,7 +1,7 @@
 # Template file for 'opencv'
 pkgname=opencv
-version=4.6.0
-revision=4
+version=4.7.0
+revision=1
 create_wrksrc=yes
 build_wrksrc=${pkgname}-${version}
 build_style=cmake
@@ -24,8 +24,8 @@ homepage="https://opencv.org"
 changelog="https://github.com/opencv/opencv/wiki/ChangeLog"
 distfiles="https://github.com/opencv/opencv/archive/${version}.tar.gz
  https://github.com/opencv/opencv_contrib/archive/${version}.tar.gz>contrib.tar.gz"
-checksum="1ec1cba65f9f20fe5a41fda1586e01c70ea0c9a6d7b67c9e13edf0cfe2239277
- 1777d5fd2b59029cf537e5fd6f8aa68d707075822f90bde683fcde086f85f7a7"
+checksum="8df0079cdbe179748a18d44731af62a245a45ebf5085223dc03133954c662973
+ 42df840cf9055e59d0e22c249cfb19f04743e1bdad113d31b1573d3934d62584"
 patch_args="-Np1 -d ${build_wrksrc}"
 # tests hang indenfinitely, even with test data included
 make_check=no

From 6135f7a9607b47c60f4340b5d2736a024dc1c3e5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 004/115] actiona: revbump for opencv-4.7.0

---
 srcpkgs/actiona/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/actiona/template b/srcpkgs/actiona/template
index cf5f0b7a2ae6..0d899311e6df 100644
--- a/srcpkgs/actiona/template
+++ b/srcpkgs/actiona/template
@@ -1,7 +1,7 @@
 # Template file for 'actiona'
 pkgname=actiona
 version=3.10.1
-revision=2
+revision=3
 build_style=qmake
 configure_args="PKGCONFIG_OPENCV=opencv4"
 hostmakedepends="pkg-config qt5-plugin-mysql qt5-qmake qt5-host-tools"

From bb4405ae6656d539e721fb3dca56b80924167799 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 005/115] gmic: revbump for opencv-4.7.0

---
 srcpkgs/gmic/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gmic/template b/srcpkgs/gmic/template
index 24a9c7218fdf..0bb4034d5cc8 100644
--- a/srcpkgs/gmic/template
+++ b/srcpkgs/gmic/template
@@ -1,7 +1,7 @@
 # Template file for 'gmic'
 pkgname=gmic
 version=3.1.6
-revision=3
+revision=4
 _zart_hash=34ebf6cce0bafb98abe57cec83c4a02cd1abeca0
 create_wrksrc=yes
 build_wrksrc="src"

From 0c8688ca1d27b3c0ba8ce57a02281575959a2455 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 006/115] qimgv: revbump for opencv-4.7.0

---
 srcpkgs/qimgv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qimgv/template b/srcpkgs/qimgv/template
index 7eb30db33992..dd341dfe1bfc 100644
--- a/srcpkgs/qimgv/template
+++ b/srcpkgs/qimgv/template
@@ -1,7 +1,7 @@
 # Template file for 'qimgv'
 pkgname=qimgv
 version=1.0.2
-revision=2
+revision=3
 build_style=cmake
 configure_args="$(vopt_if video -DVIDEO_SUPPORT=ON -DVIDEO_SUPPORT=OFF)
  $(vopt_if scale -DOPENCV_SUPPORT=ON -DOPENCV_SUPPORT=OFF)

From cc1cb7326876f5aeea947414fd7dbb62fc1f1593 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 007/115] retroshare: revbump for opencv-4.7.0

---
 srcpkgs/retroshare/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroshare/template b/srcpkgs/retroshare/template
index 8a0786c21a08..72023fa98b75 100644
--- a/srcpkgs/retroshare/template
+++ b/srcpkgs/retroshare/template
@@ -1,7 +1,7 @@
 # Template file for 'retroshare'
 pkgname=retroshare
 version=0.6.6
-revision=2
+revision=4
 build_style=qmake
 #XXX broadcast feature requires an ancient udp-discovery-cpp which either needs
 # to be fetched+patched (FTBFS) here or packaged :/

From bf2f235fbe2d0344eb5f43f92e44cad3f35e0544 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 008/115] siril: revbump for opencv-4.7.0

---
 srcpkgs/siril/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/siril/template b/srcpkgs/siril/template
index e88f30fb6178..84332f79d060 100644
--- a/srcpkgs/siril/template
+++ b/srcpkgs/siril/template
@@ -1,7 +1,7 @@
 # Template file for 'siril'
 pkgname=siril
 version=0.9.12
-revision=9
+revision=10
 build_style=gnu-configure
 hostmakedepends="pkg-config intltool autoconf automake gettext-devel"
 makedepends="fftw-devel libconfig-devel libopencv-devel libffms2-devel

From e80fe533b645ea6c5da57e894077e76f29c63c2f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 009/115] waifu2x-converter-cpp: revbump for opencv-4.7.0

---
 srcpkgs/waifu2x-converter-cpp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waifu2x-converter-cpp/template b/srcpkgs/waifu2x-converter-cpp/template
index 8c095d0d7bab..aa52d8c981a8 100644
--- a/srcpkgs/waifu2x-converter-cpp/template
+++ b/srcpkgs/waifu2x-converter-cpp/template
@@ -1,7 +1,7 @@
 # Template file for 'waifu2x-converter-cpp'
 pkgname=waifu2x-converter-cpp
 version=5.2.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DINSTALL_MODELS=ON"
 hostmakedepends="pkg-config"

From 76f75fc7f7348a1450c2ae89bb44c545e8069902 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:38 -0400
Subject: [PATCH 010/115] vlc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/vlc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/vlc/template b/srcpkgs/vlc/template
index 210762b0a7e2..855ca5238662 100644
--- a/srcpkgs/vlc/template
+++ b/srcpkgs/vlc/template
@@ -1,7 +1,7 @@
 # Template file for 'vlc'
 pkgname=vlc
 version=3.0.18
-revision=3
+revision=4
 build_style=gnu-configure
 configure_args="--disable-gme --disable-libtar --enable-jack
  --enable-live555 --disable-fluidsynth --enable-dvdread
@@ -25,7 +25,7 @@ lib32disabled=yes
 hostmakedepends="automake libtool pkg-config flex gettext libgcrypt-devel
  live555-devel gettext-devel $(vopt_if lua lua52) $(vopt_if chromecast protobuf)"
 makedepends="
- avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg-devel freefont-ttf
+ avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg4-devel freefont-ttf
  gnutls-devel jack-devel liba52-devel libass-devel libbluray-devel
  libcdio-devel libdca-devel libdvbpsi-devel libdvdnav-devel libmad-devel
  libmatroska-devel libmodplug-devel libmpcdec-devel libmpeg2-devel

From 10a7f7d081d20388e213f2aabac2e04249e678ac Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:55 -0400
Subject: [PATCH 011/115] osg: revbump for ffmpeg4-4.4.3

---
 srcpkgs/osg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/osg/template b/srcpkgs/osg/template
index a9ebbd287933..755793f7e11b 100644
--- a/srcpkgs/osg/template
+++ b/srcpkgs/osg/template
@@ -8,7 +8,7 @@ build_helper="qemu"
 configure_args="-DLIB_POSTFIX="
 hostmakedepends="pkg-config xrandr"
 makedepends="MesaLib-devel gtkglext-devel libcurl-devel giflib-devel librsvg-devel
- jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg-devel xine-lib-devel
+ jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg4-devel xine-lib-devel
  SDL2-devel gst-plugins-base1-devel
  $(vopt_if openexr libopenexr-devel)
  $(vopt_if poppler poppler-glib-devel)

From 2889d5fa7ebdf7626c90698e914a8f574077e2e3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:13 -0400
Subject: [PATCH 012/115] xine-lib: revbump for ffmpeg4-4.4.3

---
 srcpkgs/xine-lib/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/xine-lib/template b/srcpkgs/xine-lib/template
index f713eff49b07..ed6194c17d11 100644
--- a/srcpkgs/xine-lib/template
+++ b/srcpkgs/xine-lib/template
@@ -1,6 +1,6 @@
 # Template file for 'xine-lib'
 pkgname=xine-lib
-version=1.2.12
+version=1.2.13
 revision=1
 build_style=gnu-configure
 configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
@@ -8,7 +8,7 @@ configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
 hostmakedepends="automake gettext-devel libtool pkg-config perl"
 makedepends="
  zlib-devel alsa-lib-devel libxcb-devel libSM-devel libXext-devel libXv-devel
- libXvMC-devel liba52-devel libmad-devel ffmpeg-devel pulseaudio-devel
+ libXvMC-devel liba52-devel libmad-devel ffmpeg4-devel pulseaudio-devel
  jack-devel samba-devel libflac-devel libmodplug-devel libmpcdec-devel
  speex-devel libtheora-devel libvorbis-devel libdca-devel faad2-devel
  libcdio-devel libbluray-devel aalib-devel libcaca-devel libXinerama-devel
@@ -19,7 +19,7 @@ license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="http://www.xine-project.org"
 changelog="https://sourceforge.net/projects/xine/files/xine-lib/${version}/README.txt/view"
 distfiles="${SOURCEFORGE_SITE}/xine/${pkgname}-${version}.tar.xz"
-checksum=d606270468e1540c2a89c0d7f5fdf11e17ecc0c2698cc0bcb1065ff26abee098
+checksum=5f10d6d718a4a51c17ed1b32b031d4f9b80b061e8276535b2be31e5ac4b75e6f
 
 case "$XBPS_TARGET_MACHINE" in
 	i686-musl)

From f090af258afe17d08b255a4f00ae4f52137f966f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 013/115] QMPlay2: revbump for ffmpeg-6.0

---
 srcpkgs/QMPlay2/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/QMPlay2/template b/srcpkgs/QMPlay2/template
index ad73cbb01bae..55284c051161 100644
--- a/srcpkgs/QMPlay2/template
+++ b/srcpkgs/QMPlay2/template
@@ -1,7 +1,7 @@
 # Template file for 'QMPlay2'
 pkgname=QMPlay2
 version=23.02.05
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools"
 makedepends="alsa-lib-devel ffmpeg-devel libass-devel libcdio-devel libgme-devel

From a4c49254105e3b89910b04c7b22add59592f77e5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 014/115] alsa-plugins: revbump for ffmpeg-6.0

---
 srcpkgs/alsa-plugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/alsa-plugins/template b/srcpkgs/alsa-plugins/template
index 0bfa6d9fd264..a5708a7d82a8 100644
--- a/srcpkgs/alsa-plugins/template
+++ b/srcpkgs/alsa-plugins/template
@@ -1,7 +1,7 @@
 # Template file for 'alsa-plugins'
 pkgname=alsa-plugins
 version=1.2.7.1
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--disable-maemo-plugin"
 hostmakedepends="pkg-config"

From e55ecc75068286d87db2cbd96dece3dff612178f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 015/115] arcan: revbump for ffmpeg-6.0

---
 srcpkgs/arcan/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/arcan/template b/srcpkgs/arcan/template
index 7be9652eccf3..ccc7df11ceac 100644
--- a/srcpkgs/arcan/template
+++ b/srcpkgs/arcan/template
@@ -2,7 +2,7 @@
 # !! keep synced with: acfgfs aclip aloadimage
 pkgname=arcan
 version=0.6.2.1
-revision=1
+revision=2
 create_wrksrc=yes
 build_wrksrc=arcan/src
 build_style=cmake

From 1d3853b9d6c40618030e4d4aba6b07ccdd46d9a0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 016/115] attract: revbump for ffmpeg4-4.4.3

---
 srcpkgs/attract/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/attract/template b/srcpkgs/attract/template
index 26144e931a3c..e760bf0d18ae 100644
--- a/srcpkgs/attract/template
+++ b/srcpkgs/attract/template
@@ -1,12 +1,12 @@
 # Template file for 'attract'
 pkgname=attract
 version=2.6.2
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="VERBOSE=1"
 make_use_env=yes
 hostmakedepends="pkg-config"
-makedepends="SFML-devel ffmpeg-devel fontconfig-devel glu-devel libarchive-devel
+makedepends="SFML-devel ffmpeg4-devel fontconfig-devel glu-devel libarchive-devel
  libcurl-devel libjpeg-turbo-devel xine-lib rapidjson libXrandr-devel"
 depends="git"
 short_desc="Attract-Mode is a graphical frontend for emulators"

From 36847e27f7d820302eb4ce70aa9d050a0bb70d86 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 017/115] aubio: revbump for ffmpeg-6.0

---
 srcpkgs/aubio/patches/ffmpeg5.patch | 25 +++++++++++++++++++++++++
 srcpkgs/aubio/template              |  2 +-
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/aubio/patches/ffmpeg5.patch

diff --git a/srcpkgs/aubio/patches/ffmpeg5.patch b/srcpkgs/aubio/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..aace41a6e6d9
--- /dev/null
+++ b/srcpkgs/aubio/patches/ffmpeg5.patch
@@ -0,0 +1,25 @@
+From 8a05420e5dd8c7b8b2447f82dc919765876511b3 Mon Sep 17 00:00:00 2001
+From: Paul Brossier <piem@piem.org>
+Date: Tue, 25 Jan 2022 18:30:27 +0100
+Subject: [PATCH] [source_avcodec] define FF_API_LAVF_AVCTX for libavcodec >
+ 59, thx @berolinux (closes gh-353)
+
+---
+ src/io/source_avcodec.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/io/source_avcodec.c b/src/io/source_avcodec.c
+index e0ae93b5..1421bd9a 100644
+--- a/src/io/source_avcodec.c
++++ b/src/io/source_avcodec.c
+@@ -68,6 +68,10 @@
+ #define AUBIO_AVCODEC_MAX_BUFFER_SIZE AV_INPUT_BUFFER_MIN_SIZE
+ #endif
+ 
++#if LIBAVCODEC_VERSION_MAJOR >= 59
++#define FF_API_LAVF_AVCTX 1
++#endif
++
+ struct _aubio_source_avcodec_t {
+   uint_t hop_size;
+   uint_t samplerate;
diff --git a/srcpkgs/aubio/template b/srcpkgs/aubio/template
index ad1c4b256991..7d875cc02541 100644
--- a/srcpkgs/aubio/template
+++ b/srcpkgs/aubio/template
@@ -1,7 +1,7 @@
 # Template file for 'aubio'
 pkgname=aubio
 version=0.4.9
-revision=1
+revision=2
 build_style=waf3
 # XXX lash, pure and swig support.
 hostmakedepends="pkg-config txt2man"

From b698d4116032d9ba973025461f631a27282ae823 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 018/115] audacious-plugins: revbump for ffmpeg-6.0

---
 .../audacious-plugins/patches/ffmpeg5.patch   | 43 +++++++++++++++++++
 srcpkgs/audacious-plugins/template            |  2 +-
 2 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/audacious-plugins/patches/ffmpeg5.patch

diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg5.patch b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..4e5e34099d71
--- /dev/null
+++ b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
@@ -0,0 +1,43 @@
+commit 298aa371c56c2f52c25a33d9bdec4918b11cebdc
+Author: tibequadorian <tibequadorian@posteo.de>
+Date:   Sat Mar 19 18:40:12 2022 +0100
+
+    audacious-plugins: rebuild against ffmpeg-5.0
+
+diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+new file mode 100644
+index 0000000000..617c11215b
+--- /dev/null
++++ b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+@@ -0,0 +1,31 @@
++From f60beb400eeb1e4778bbfd738bc4a4ccef3de539 Mon Sep 17 00:00:00 2001
++From: John Lindgren <john@jlindgren.net>
++Date: Sat, 5 Mar 2022 12:05:34 -0500
++Subject: [PATCH] Fix build with FFmpeg 5.0
++
++---
++ src/ffaudio/ffaudio-core.cc | 4 ++--
++ 1 file changed, 2 insertions(+), 2 deletions(-)
++
++diff --git a/src/ffaudio/ffaudio-core.cc b/src/ffaudio/ffaudio-core.cc
++index 16dc63e3a..a2b95fd6c 100644
++--- a/src/ffaudio/ffaudio-core.cc
+++++ b/src/ffaudio/ffaudio-core.cc
++@@ -274,7 +274,7 @@ static AVInputFormat * get_format_by_content (const char * name, VFSFile & file)
++         AVProbeData d = {name, buf, filled};
++         score = target;
++ 
++-        f = av_probe_input_format2 (& d, true, & score);
+++        f = (AVInputFormat *) av_probe_input_format2 (& d, true, & score);
++         if (f)
++             break;
++ 
++@@ -347,7 +347,7 @@ static bool find_codec (AVFormatContext * c, CodecInfo * cinfo)
++ #endif
++         if (stream && stream->codecpar && stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
++         {
++-            AVCodec * codec = avcodec_find_decoder (stream->codecpar->codec_id);
+++            AVCodec * codec = (AVCodec *) avcodec_find_decoder (stream->codecpar->codec_id);
++ 
++             if (codec)
++             {
diff --git a/srcpkgs/audacious-plugins/template b/srcpkgs/audacious-plugins/template
index 88cbc1671fc6..beebfae59ed4 100644
--- a/srcpkgs/audacious-plugins/template
+++ b/srcpkgs/audacious-plugins/template
@@ -2,7 +2,7 @@
 #Keep in sync with audacious!
 pkgname=audacious-plugins
 version=4.3.1
-revision=1
+revision=2
 build_style=meson
 configure_args="$(vopt_bool gtk3 gtk) $(vopt_bool gtk3)
  $(vopt_bool qt) $(vopt_bool qt qt6)"

From 726d6008341e15e79027526fa134cff9ff60c03d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 019/115] audacity: revbump for ffmpeg4-4.4.3

---
 srcpkgs/audacity/template | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/audacity/template b/srcpkgs/audacity/template
index d509c0a89407..11e20255685b 100644
--- a/srcpkgs/audacity/template
+++ b/srcpkgs/audacity/template
@@ -1,7 +1,7 @@
 # Template file for 'audacity'
 pkgname=audacity
 version=2.4.1
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--with-ffmpeg=system --with-libsndfile=system --with-expat=system
  --with-libsoxr=system --with-lame=system --with-lv2=system ac_cv_path_WX_CONFIG=wx-config-gtk3"
@@ -9,7 +9,7 @@ hostmakedepends="pkg-config cmake gettext libtool m4 which"
 makedepends="jack-devel wxWidgets-gtk3-devel gtk+3-devel
  libmad-devel soundtouch-devel libsoxr-devel
  vamp-plugin-sdk-devel lame-devel libid3tag-devel libflac-devel
- ffmpeg-devel twolame-devel serd-devel lv2 lilv-devel suil-devel"
+ ffmpeg4-devel twolame-devel serd-devel lv2 lilv-devel suil-devel"
 depends="desktop-file-utils hicolor-icon-theme"
 short_desc="Graphical cross-platform audio editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
@@ -33,5 +33,4 @@ post_install() {
 	vcopy plug-ins /usr/share/audacity
 
 	rm ${DESTDIR}/usr/share/doc/audacity/LICENSE.txt
-	vlicense LICENSE.txt LICENSE
 }

From 34cb1b58b2516b5994a58dbb9df10455e97950d4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 020/115] avidemux: revbump for ffmpeg-6.0

---
 srcpkgs/avidemux/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/avidemux/template b/srcpkgs/avidemux/template
index 253a0243e225..557285982d2b 100644
--- a/srcpkgs/avidemux/template
+++ b/srcpkgs/avidemux/template
@@ -1,7 +1,7 @@
 # Template file for 'avidemux'
 pkgname=avidemux
 version=2.8.0
-revision=2
+revision=3
 # Can't be compiled for aarch64, arm* or mips*
 archs="x86_64* i686*"
 hostmakedepends="cmake pkg-config qt5-host-tools qt5-devel tar yasm"

From da7c79c4eba97dd2f235318fd422506a62925bb3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 021/115] baresip: revbump for ffmpeg-6.0

---
 srcpkgs/baresip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/baresip/template b/srcpkgs/baresip/template
index f1bd1817048b..b21e22334316 100644
--- a/srcpkgs/baresip/template
+++ b/srcpkgs/baresip/template
@@ -1,7 +1,7 @@
 # Template file for 'baresip'
 pkgname=baresip
 version=2.10.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config glib-devel"
 makedepends="libgsm-devel libpng-devel openssl-devel libsndfile-devel

From 201bee8767aff1e59a176e37a8f6985afecd2dcd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 022/115] blender: revbump for ffmpeg-6.0

---
 .../patches/ffmpeg6-compat-blender.patch      | 42 +++++++++++++++++++
 srcpkgs/blender/template                      |  2 +-
 2 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/blender/patches/ffmpeg6-compat-blender.patch

diff --git a/srcpkgs/blender/patches/ffmpeg6-compat-blender.patch b/srcpkgs/blender/patches/ffmpeg6-compat-blender.patch
new file mode 100644
index 000000000000..d51a9c7710cc
--- /dev/null
+++ b/srcpkgs/blender/patches/ffmpeg6-compat-blender.patch
@@ -0,0 +1,42 @@
+--- a/source/blender/blenkernel/intern/writeffmpeg.c	2022-11-08 13:50:16 UTC
++++ b/source/blender/blenkernel/intern/writeffmpeg.c
+@@ -855,7 +855,7 @@ static AVStream *alloc_video_stream(FFMpegContext *con
+                                                             255);
+   st->avg_frame_rate = av_inv_q(c->time_base);
+ 
+-  if (codec->capabilities & AV_CODEC_CAP_AUTO_THREADS) {
++  if (codec->capabilities & AV_CODEC_CAP_OTHER_THREADS) {
+     c->thread_count = 0;
+   }
+   else {
+--- a/source/blender/imbuf/intern/anim_movie.c	2022-11-04 00:33:07 UTC
++++ b/source/blender/imbuf/intern/anim_movie.c
+@@ -554,7 +554,7 @@ static int startffmpeg(struct anim *anim)
+   avcodec_parameters_to_context(pCodecCtx, video_stream->codecpar);
+   pCodecCtx->workaround_bugs = FF_BUG_AUTODETECT;
+ 
+-  if (pCodec->capabilities & AV_CODEC_CAP_AUTO_THREADS) {
++  if (pCodec->capabilities & AV_CODEC_CAP_OTHER_THREADS) {
+     pCodecCtx->thread_count = 0;
+   }
+   else {
+--- a/source/blender/imbuf/intern/indexer.c	2022-11-04 00:33:07 UTC
++++ b/source/blender/imbuf/intern/indexer.c
+@@ -559,7 +559,7 @@ static struct proxy_output_ctx *alloc_proxy_output_ffm
+   av_dict_set(&codec_opts, "preset", "veryfast", 0);
+   av_dict_set(&codec_opts, "tune", "fastdecode", 0);
+ 
+-  if (rv->codec->capabilities & AV_CODEC_CAP_AUTO_THREADS) {
++  if (rv->codec->capabilities & AV_CODEC_CAP_OTHER_THREADS) {
+     rv->c->thread_count = 0;
+   }
+   else {
+@@ -872,7 +872,7 @@ static IndexBuildContext *index_ffmpeg_create_context(
+   avcodec_parameters_to_context(context->iCodecCtx, context->iStream->codecpar);
+   context->iCodecCtx->workaround_bugs = FF_BUG_AUTODETECT;
+ 
+-  if (context->iCodec->capabilities & AV_CODEC_CAP_AUTO_THREADS) {
++  if (context->iCodec->capabilities & AV_CODEC_CAP_OTHER_THREADS) {
+     context->iCodecCtx->thread_count = 0;
+   }
+   else {
diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index 61b42eb2e51e..d18bc88838ff 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -1,7 +1,7 @@
 # Template file for 'blender'
 pkgname=blender
 version=3.4.1
-revision=3
+revision=4
 archs="x86_64* ppc64*"
 build_style="cmake"
 pycompile_dirs="/usr/share/blender/${version%.*}/scripts"

From d1beefb550f44520729886469d68e3055bb211c9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 023/115] cantata: revbump for ffmpeg-6.0

---
 srcpkgs/cantata/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cantata/template b/srcpkgs/cantata/template
index 4b417d80d5c2..8a90aaa4c07a 100644
--- a/srcpkgs/cantata/template
+++ b/srcpkgs/cantata/template
@@ -1,7 +1,7 @@
 # Template file for 'cantata'
 pkgname=cantata
 version=2.5.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools qt5-tools"
 makedepends="qt5-devel qt5-tools-devel qt5-svg-devel qt5-xmlpatterns-devel

From a30aef40400d89e2f7eee4d7abd19cc4033f9e38 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 024/115] ccextractor: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ccextractor/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/ccextractor/template b/srcpkgs/ccextractor/template
index 9abcd82852b2..6eccad5885af 100644
--- a/srcpkgs/ccextractor/template
+++ b/srcpkgs/ccextractor/template
@@ -1,12 +1,12 @@
 # Template file for 'ccextractor'
 pkgname=ccextractor
 version=0.93
-revision=1
+revision=2
 build_wrksrc="linux"
 build_style=gnu-configure
 configure_args="--enable-ocr --enable-hardsubx"
 hostmakedepends="automake pkg-config"
-makedepends="leptonica-devel tesseract-ocr-devel ffmpeg-devel"
+makedepends="leptonica-devel tesseract-ocr-devel ffmpeg4-devel"
 short_desc="Extract subtitles from video streams"
 maintainer="newbluemoon <blaumolch@mailbox.org>"
 license="GPL-2.0-or-later"

From f133fcd2c5ed3aba4d6d04665196de4c82d02718 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 025/115] chromaprint: revbump for ffmpeg-6.0

---
 srcpkgs/chromaprint/patches/ffmpeg5.patch | 569 ++++++++++++++++++++++
 srcpkgs/chromaprint/template              |   2 +-
 2 files changed, 570 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromaprint/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromaprint/patches/ffmpeg5.patch b/srcpkgs/chromaprint/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..a9fd307a23c8
--- /dev/null
+++ b/srcpkgs/chromaprint/patches/ffmpeg5.patch
@@ -0,0 +1,569 @@
+From 8ccad6937177b1b92e40ab8f4447ea27bac009a7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= <lalinsky@gmail.com>
+Date: Fri, 4 Nov 2022 21:47:38 +0100
+Subject: [PATCH] Use FFmpeg 5.x (#120)
+
+* Use FFmpeg 5.1.2 for CI builds
+
+* Build on Ubuntu 20.04
+
+* Upgrade code to FFmpeg 5.x APIs
+
+* Only set FFmpeg include dirs if building tools
+
+* No longer needed
+
+* Use ubuntu 20.04
+---
+ .github/workflows/build.yml                   |   6 +-
+ CMakeLists.txt                                |  16 --
+ package/build.sh                              |   4 +-
+ src/audio/ffmpeg_audio_processor.h            |   2 -
+ src/audio/ffmpeg_audio_processor_avresample.h |  72 -------
+ src/audio/ffmpeg_audio_processor_swresample.h |  18 +-
+ src/audio/ffmpeg_audio_reader.h               | 197 +++++++++---------
+ tests/CMakeLists.txt                          |   6 +
+ 8 files changed, 122 insertions(+), 199 deletions(-)
+ delete mode 100644 src/audio/ffmpeg_audio_processor_avresample.h
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index f8d6a32..4da2405 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -84,9 +84,6 @@ find_package(FFmpeg)
+ if(FFMPEG_LIBRARIES)
+ 	cmake_push_check_state(RESET)
+ 	set(CMAKE_REQUIRED_LIBRARIES ${FFMPEG_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -lm)
+-	check_function_exists(av_packet_unref HAVE_AV_PACKET_UNREF)
+-	check_function_exists(av_frame_alloc HAVE_AV_FRAME_ALLOC)
+-	check_function_exists(av_frame_free HAVE_AV_FRAME_FREE)
+ 	cmake_pop_check_state()
+ endif()
+
+@@ -163,14 +160,11 @@ message(STATUS "Using ${FFT_LIB} for FFT calculations")
+ if(NOT AUDIO_PROCESSOR_LIB)
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+ 		set(AUDIO_PROCESSOR_LIB "swresample")
+-	elseif(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(AUDIO_PROCESSOR_LIB "avresample")
+ 	endif()
+ endif()
+
+ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE OFF)
+ 		set(USE_SWRESAMPLE ON)
+ 		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBSWRESAMPLE_LIBRARIES})
+ 		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBSWRESAMPLE_INCLUDE_DIRS})
+@@ -178,16 +172,6 @@ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+ 	endif()
+ 	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+-elseif(AUDIO_PROCESSOR_LIB STREQUAL "avresample")
+-	if(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE ON)
+-		set(USE_SWRESAMPLE OFF)
+-		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBAVRESAMPLE_LIBRARIES})
+-		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBAVRESAMPLE_INCLUDE_DIRS})
+-	else()
+-		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+-	endif()
+-	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+ else()
+ 	message(STATUS "Building without audio conversion support, please install FFmpeg with libswresample")
+ endif()
+diff --git a/package/build.sh b/package/build.sh
+index da631ae..b41d36e 100755
+--- a/package/build.sh
++++ b/package/build.sh
+@@ -7,8 +7,8 @@ set -eux
+
+ BASE_DIR=$(cd $(dirname $0)/.. && pwd)
+
+-FFMPEG_VERSION=4.4.1
+-FFMPEG_BUILD_TAG=v4.4.1-1
++FFMPEG_VERSION=5.1.2
++FFMPEG_BUILD_TAG=v${FFMPEG_VERSION}-1
+
+ TMP_BUILD_DIR=$BASE_DIR/$(mktemp -d build.XXXXXXXX)
+ trap 'rm -rf $TMP_BUILD_DIR' EXIT
+diff --git a/src/audio/ffmpeg_audio_processor.h b/src/audio/ffmpeg_audio_processor.h
+index 7628fc7..39f4f6d 100644
+--- a/src/audio/ffmpeg_audio_processor.h
++++ b/src/audio/ffmpeg_audio_processor.h
+@@ -10,8 +10,6 @@
+
+ #if defined(USE_SWRESAMPLE)
+ #include "audio/ffmpeg_audio_processor_swresample.h"
+-#elif defined(USE_AVRESAMPLE)
+-#include "audio/ffmpeg_audio_processor_avresample.h"
+ #else
+ #error "no audio processing library"
+ #endif
+diff --git a/src/audio/ffmpeg_audio_processor_avresample.h b/src/audio/ffmpeg_audio_processor_avresample.h
+deleted file mode 100644
+index bd85f92..0000000
+--- a/src/audio/ffmpeg_audio_processor_avresample.h
++++ /dev/null
+@@ -1,72 +0,0 @@
+-// Copyright (C) 2016  Lukas Lalinsky
+-// Distributed under the MIT license, see the LICENSE file for details.
+-
+-#ifndef CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-#define CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-
+-extern "C" {
+-#include <libavresample/avresample.h>
+-}
+-
+-namespace chromaprint {
+-
+-class FFmpegAudioProcessor {
+-public:
+-	FFmpegAudioProcessor() {
+-		m_resample_ctx = avresample_alloc_context();
+-	}
+-
+-	~FFmpegAudioProcessor() {
+-		avresample_free(&m_resample_ctx);
+-	}
+-
+-	void SetCompatibleMode() {
+-		av_opt_set_int(m_resample_ctx, "filter_size", 16, 0);
+-		av_opt_set_int(m_resample_ctx, "phase_shift", 8, 0);
+-		av_opt_set_int(m_resample_ctx, "linear_interp", 1, 0);
+-		av_opt_set_double(m_resample_ctx, "cutoff", 0.8, 0);
+-	}
+-
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "in_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_rate", sample_rate, 0);
+-	}
+-
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "out_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_rate, 0);
+-	}
+-
+-	int Init() {
+-		return avresample_open(m_resample_ctx);
+-	}
+-
+-	int Convert(uint8_t **out, int out_count, const uint8_t **in, int in_count) {
+-		return avresample_convert(m_resample_ctx, out, 0, out_count, (uint8_t **) in, 0, in_count);
+-	}
+-
+-	int Flush(uint8_t **out, int out_count) {
+-		return avresample_read(m_resample_ctx, out, out_count);
+-	}
+-
+-private:
+-	AVAudioResampleContext *m_resample_ctx = nullptr;
+-};
+-
+-}; // namespace chromaprint
+-
+-#endif
+diff --git a/src/audio/ffmpeg_audio_processor_swresample.h b/src/audio/ffmpeg_audio_processor_swresample.h
+index b86266b..b1d4bea 100644
+--- a/src/audio/ffmpeg_audio_processor_swresample.h
++++ b/src/audio/ffmpeg_audio_processor_swresample.h
+@@ -28,30 +28,28 @@ public:
+ 		av_opt_set_double(m_swr_ctx, "cutoff", 0.8, 0);
+ 	}
+
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "icl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "ich", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetInputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "in_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "isf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "in_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "isr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "in_sample_rate", sample_rate, 0);
+ 	}
+
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "ocl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "och", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetOutputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "out_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "osf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "out_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "osr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "out_sample_rate", sample_rate, 0);
+ 	}
+
+ 	int Init() {
+diff --git a/src/audio/ffmpeg_audio_reader.h b/src/audio/ffmpeg_audio_reader.h
+index 5550164..1c6b346 100644
+--- a/src/audio/ffmpeg_audio_reader.h
++++ b/src/audio/ffmpeg_audio_reader.h
+@@ -62,7 +62,7 @@ public:
+ 	bool Read(const int16_t **data, size_t *size);
+
+ 	bool IsOpen() const { return m_opened; }
+-	bool IsFinished() const { return m_finished && !m_got_frame; }
++	bool IsFinished() const { return !m_has_more_packets && !m_has_more_frames; }
+
+ 	std::string GetError() const { return m_error; }
+ 	int GetErrorCode() const { return m_error_code; }
+@@ -74,20 +74,19 @@ private:
+ 	uint8_t *m_convert_buffer[1] = { nullptr };
+ 	int m_convert_buffer_nb_samples = 0;
+
+-	AVInputFormat *m_input_fmt = nullptr;
++	const AVInputFormat *m_input_fmt = nullptr;
+ 	AVDictionary *m_input_opts = nullptr;
+
+ 	AVFormatContext *m_format_ctx = nullptr;
+ 	AVCodecContext *m_codec_ctx = nullptr;
+-	AVFrame *m_frame = nullptr;
+ 	int m_stream_index = -1;
+ 	std::string m_error;
+ 	int m_error_code = 0;
+-	bool m_finished = false;
+ 	bool m_opened = false;
+-	int m_got_frame = 0;
+-	AVPacket m_packet;
+-	AVPacket m_packet0;
++	bool m_has_more_packets = true;
++	bool m_has_more_frames = true;
++	AVPacket *m_packet = nullptr;
++	AVFrame *m_frame = nullptr;
+
+ 	int m_output_sample_rate = 0;
+ 	int m_output_channels = 0;
+@@ -98,19 +97,12 @@ private:
+
+ inline FFmpegAudioReader::FFmpegAudioReader() {
+ 	av_log_set_level(AV_LOG_QUIET);
+-
+-	av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
+ }
+
+ inline FFmpegAudioReader::~FFmpegAudioReader() {
+ 	Close();
+ 	av_dict_free(&m_input_opts);
+ 	av_freep(&m_convert_buffer[0]);
+-	av_packet_unref(&m_packet0);
+ }
+
+ inline bool FFmpegAudioReader::SetInputFormat(const char *name) {
+@@ -135,11 +127,10 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ 	Close();
+
+-    av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
++	m_packet = av_packet_alloc();
++	if (!m_packet) {
++		return false;
++	}
+
+ 	ret = avformat_open_input(&m_format_ctx, file_name.c_str(), m_input_fmt, &m_input_opts);
+ 	if (ret < 0) {
+@@ -153,26 +144,31 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		return false;
+ 	}
+
+-	AVCodec *codec;
++	const AVCodec *codec;
+ 	ret = av_find_best_stream(m_format_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &codec, 0);
+ 	if (ret < 0) {
+ 		SetError("Could not find any audio stream in the file", ret);
+ 		return false;
+ 	}
+ 	m_stream_index = ret;
++	auto stream = m_format_ctx->streams[m_stream_index];
+
+-	m_codec_ctx = m_format_ctx->streams[m_stream_index]->codec;
++	m_codec_ctx = avcodec_alloc_context3(codec);
+ 	m_codec_ctx->request_sample_fmt = AV_SAMPLE_FMT_S16;
+
++	ret = avcodec_parameters_to_context(m_codec_ctx, stream->codecpar);
++	if (ret < 0) {
++		SetError("Could not copy the stream parameters", ret);
++		return false;
++	}
++
+ 	ret = avcodec_open2(m_codec_ctx, codec, nullptr);
+ 	if (ret < 0) {
+ 		SetError("Could not open the codec", ret);
+ 		return false;
+ 	}
+
+-	if (!m_codec_ctx->channel_layout) {
+-		m_codec_ctx->channel_layout = av_get_default_channel_layout(m_codec_ctx->channels);
+-	}
++	av_dump_format(m_format_ctx, 0, "foo", 0);
+
+ 	m_frame = av_frame_alloc();
+ 	if (!m_frame) {
+@@ -183,19 +179,23 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		m_output_sample_rate = m_codec_ctx->sample_rate;
+ 	}
+
+-	if (!m_output_channels) {
+-		m_output_channels = m_codec_ctx->channels;
++	AVChannelLayout output_channel_layout;
++	if (m_output_channels) {
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
++	} else {
++		m_output_channels = m_codec_ctx->ch_layout.nb_channels;
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
+ 	}
+
+-	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
++	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->ch_layout.nb_channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
+ 		m_converter.reset(new FFmpegAudioProcessor());
+ 		m_converter->SetCompatibleMode();
+ 		m_converter->SetInputSampleFormat(m_codec_ctx->sample_fmt);
+ 		m_converter->SetInputSampleRate(m_codec_ctx->sample_rate);
+-		m_converter->SetInputChannelLayout(m_codec_ctx->channel_layout);
++		m_converter->SetInputChannelLayout(&(m_codec_ctx->ch_layout));
+ 		m_converter->SetOutputSampleFormat(AV_SAMPLE_FMT_S16);
+ 		m_converter->SetOutputSampleRate(m_output_sample_rate);
+-		m_converter->SetOutputChannelLayout(av_get_default_channel_layout(m_output_channels));
++		m_converter->SetOutputChannelLayout(&output_channel_layout);
+ 		auto ret = m_converter->Init();
+ 		if (ret != 0) {
+ 			SetError("Could not create an audio converter instance", ret);
+@@ -203,10 +203,11 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		}
+ 	}
+
++	av_channel_layout_uninit(&output_channel_layout);
++
+ 	m_opened = true;
+-	m_finished = false;
+-	m_got_frame = 0;
+-	m_nb_packets = 0;
++	m_has_more_packets = true;
++	m_has_more_frames = true;
+ 	m_decode_error = 0;
+
+ 	return true;
+@@ -214,6 +215,7 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ inline void FFmpegAudioReader::Close() {
+ 	av_frame_free(&m_frame);
++	av_packet_free(&m_packet);
+
+ 	m_stream_index = -1;
+
+@@ -252,91 +254,98 @@ inline bool FFmpegAudioReader::Read(const int16_t **data, size_t *size) {
+ 		return false;
+ 	}
+
++	*data = nullptr;
++	*size = 0;
++
+ 	int ret;
++	bool needs_packet = false;
+ 	while (true) {
+-		while (m_packet.size <= 0) {
+-			av_packet_unref(&m_packet0);
+-			av_init_packet(&m_packet);
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			ret = av_read_frame(m_format_ctx, &m_packet);
++		while (needs_packet && m_packet->size == 0) {
++			ret = av_read_frame(m_format_ctx, m_packet);
+ 			if (ret < 0) {
+ 				if (ret == AVERROR_EOF) {
+-					m_finished = true;
++					needs_packet = false;
++					m_has_more_packets = false;
+ 					break;
+-				} else {
++				}
++				SetError("Error reading from the audio source", ret);
++				return false;
++			}
++			if (m_packet->stream_index == m_stream_index) {
++				needs_packet = false;
++			} else {
++				av_packet_unref(m_packet);
++			}
++		}
++
++		if (m_packet->size != 0) {
++			ret = avcodec_send_packet(m_codec_ctx, m_packet);
++			if (ret < 0) {
++				if (ret != AVERROR(EAGAIN)) {
+ 					SetError("Error reading from the audio source", ret);
+ 					return false;
+ 				}
+-			}
+-			m_packet0 = m_packet;
+-			if (m_packet.stream_index != m_stream_index) {
+-				m_packet.data = nullptr;
+-				m_packet.size = 0;
+ 			} else {
+-				m_nb_packets++;
++				av_packet_unref(m_packet);
+ 			}
+ 		}
+
+-		ret = avcodec_decode_audio4(m_codec_ctx, m_frame, &m_got_frame, &m_packet);
++		ret = avcodec_receive_frame(m_codec_ctx, m_frame);
+ 		if (ret < 0) {
+-			if (m_decode_error) {
+-				SetError("Error decoding audio frame", m_decode_error);
+-				return false;
++			if (ret == AVERROR_EOF) {
++				m_has_more_frames = false;
++			} else if (ret == AVERROR(EAGAIN)) {
++				if (m_has_more_packets) {
++					needs_packet = true;
++					continue;
++				} else {
++					m_has_more_frames = false;
++				}
+ 			}
+-			m_decode_error = ret;
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			continue;
++			SetError("Error decoding the audio source", ret);
++			return false;
+ 		}
+
+-		break;
+-	}
+-
+-	m_decode_error = 0;
+-
+-	const int decoded = std::min(ret, m_packet.size);
+-	m_packet.data += decoded;
+-	m_packet.size -= decoded;
+-
+-	if (m_got_frame) {
+-		if (m_converter) {
+-			if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
+-				int linsize;
+-				av_freep(&m_convert_buffer[0]);
+-				m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
+-				ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
+-				if (ret < 0) {
+-					SetError("Couldn't allocate audio converter buffer", ret);
++		if (m_frame->nb_samples > 0) {
++			if (m_converter) {
++				if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
++					int linsize;
++					av_freep(&m_convert_buffer[0]);
++					m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
++					ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->ch_layout.nb_channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
++					if (ret < 0) {
++						SetError("Couldn't allocate audio converter buffer", ret);
++						return false;
++					}
++				}
++				auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
++				if (nb_samples < 0) {
++					SetError("Couldn't convert audio", ret);
+ 					return false;
+ 				}
+-			}
+-			auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			}
+-			*data = (const int16_t *) m_convert_buffer[0];
+-			*size = nb_samples;
+-		} else {
+-			*data = (const int16_t *) m_frame->data[0];
+-			*size = m_frame->nb_samples;
+-		}
+-	} else {
+-		if (m_finished && m_converter) {
+-			auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			} else if (nb_samples > 0) {
+-				m_got_frame = 1;
+ 				*data = (const int16_t *) m_convert_buffer[0];
+ 				*size = nb_samples;
++			} else {
++				*data = (const int16_t *) m_frame->data[0];
++				*size = m_frame->nb_samples;
++			}
++		} else {
++			if (m_converter) {
++				if (IsFinished()) {
++					auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
++					if (nb_samples < 0) {
++						SetError("Couldn't convert audio", ret);
++						return false;
++					} else if (nb_samples > 0) {
++						*data = (const int16_t *) m_convert_buffer[0];
++						*size = nb_samples;
++					}
++				}
+ 			}
+ 		}
+-	}
+
+-	return true;
++		return true;
++	}
+ }
+
+ inline void FFmpegAudioReader::SetError(const char *message, int errnum) {
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index a2b517b..123e643 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -38,6 +38,12 @@ set(SRCS
+
+ if(BUILD_TOOLS)
+ 	set(SRCS ${SRCS} ../src/audio/ffmpeg_audio_reader_test.cpp)
++    include_directories(
++        ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}
++        ${AUDIO_PROCESSOR_INCLUDE_DIRS}
++    )
+ 	link_libraries(fpcalc_libs)
+ endif()
+
+-- 
+2.38.1
+
+
diff --git a/srcpkgs/chromaprint/template b/srcpkgs/chromaprint/template
index 7ef7838949f3..1f7bbc70a22c 100644
--- a/srcpkgs/chromaprint/template
+++ b/srcpkgs/chromaprint/template
@@ -1,7 +1,7 @@
 # Template file for 'chromaprint'
 pkgname=chromaprint
 version=1.5.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DBUILD_TOOLS=ON"
 make_check_target="check"

From aed921f701932ce232bdcb1e5d9751098e56cc2e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 026/115] chromium: revbump for ffmpeg-6.0

---
 .../patches/chromium-93-ffmpeg-4.4.patch      | 36 --------------
 srcpkgs/chromium/patches/ffmpeg5.patch        | 47 +++++++++++++++++++
 srcpkgs/chromium/template                     |  2 +-
 3 files changed, 48 insertions(+), 37 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch
 create mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch b/srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch
deleted file mode 100644
index f0ec736f98bc..000000000000
--- a/srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch
+++ /dev/null
@@ -1,36 +0,0 @@
-diff --git a/media/filters/ffmpeg_demuxer.cc b/media/filters/ffmpeg_demuxer.cc
-index ac4713b07268..492a9a37d096 100644
---- a/media/filters/ffmpeg_demuxer.cc
-+++ b/media/filters/ffmpeg_demuxer.cc
-@@ -427,11 +427,11 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
-   scoped_refptr<DecoderBuffer> buffer;
- 
-   if (type() == DemuxerStream::TEXT) {
--    size_t id_size = 0;
-+    int id_size = 0;
-     uint8_t* id_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
- 
--    size_t settings_size = 0;
-+    int settings_size = 0;
-     uint8_t* settings_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
- 
-@@ -443,7 +443,7 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
-     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
-                                      side_data.data(), side_data.size());
-   } else {
--    size_t side_data_size = 0;
-+    int side_data_size = 0;
-     uint8_t* side_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
- 
-@@ -504,7 +504,7 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
-                                        packet->size - data_offset);
-     }
- 
--    size_t skip_samples_size = 0;
-+    int skip_samples_size = 0;
-     const uint32_t* skip_samples_ptr =
-         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
-             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..24e2da38e34c
--- /dev/null
+++ b/srcpkgs/chromium/patches/ffmpeg5.patch
@@ -0,0 +1,47 @@
+--- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
++++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
+@@ -92,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+-  if (stream->start_time != kNoFFmpegTimestamp)
++  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -1597,7 +1585,7 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+@@ -1618,7 +1606,7 @@
+     if (stream->type() != DemuxerStream::VIDEO)
+       continue;
+ 
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+ 
+     if (!stream->IsEnabled())
diff --git a/srcpkgs/chromium/template b/srcpkgs/chromium/template
index c3a1cd59eafe..5f4f6bd24d46 100644
--- a/srcpkgs/chromium/template
+++ b/srcpkgs/chromium/template
@@ -2,7 +2,7 @@
 pkgname=chromium
 # See https://chromiumdash.appspot.com/releases?platform=Linux for the latest version
 version=113.0.5672.63
-revision=1
+revision=2
 archs="i686* x86_64* aarch64* armv7l*"
 hostmakedepends="
  $(vopt_if clang "clang lld llvm15")

From 754ea7f90b2fe9f4c4de594e1228d43518b4e748 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 027/115] cmus: revbump for ffmpeg-6.0

---
 srcpkgs/cmus/patches/ffmpeg6.patch | 12 ++++++++++++
 srcpkgs/cmus/template              |  2 +-
 2 files changed, 13 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/cmus/patches/ffmpeg6.patch

diff --git a/srcpkgs/cmus/patches/ffmpeg6.patch b/srcpkgs/cmus/patches/ffmpeg6.patch
new file mode 100644
index 000000000000..ffa95ab81110
--- /dev/null
+++ b/srcpkgs/cmus/patches/ffmpeg6.patch
@@ -0,0 +1,12 @@
+--- a/ip/ffmpeg.c
++++ b/ip/ffmpeg.c
+@@ -202,9 +202,6 @@ static int ffmpeg_open(struct input_plugin_data *ip_data)
+ 			break;
+ 		}
+ 
+-		if (codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+-			cc->flags |= AV_CODEC_FLAG_TRUNCATED;
+-
+ 		if (avcodec_open2(cc, codec, NULL) < 0) {
+ 			d_print("could not open codec: %d, %s\n", cc->codec_id, avcodec_get_name(cc->codec_id));
+ 			err = -IP_ERROR_UNSUPPORTED_FILE_TYPE;
diff --git a/srcpkgs/cmus/template b/srcpkgs/cmus/template
index 0fcb424ce336..05b77d0fecae 100644
--- a/srcpkgs/cmus/template
+++ b/srcpkgs/cmus/template
@@ -1,7 +1,7 @@
 # Template file for 'cmus'
 pkgname=cmus
 version=2.10.0
-revision=1
+revision=2
 build_style=configure
 configure_args="prefix=/usr LD=$CC"
 hostmakedepends="pkg-config"

From a25e3d74b7df189b9879bb153cdc8ca58d328d1b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 028/115] cyanrip: revbump for ffmpeg-6.0

---
 srcpkgs/cyanrip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cyanrip/template b/srcpkgs/cyanrip/template
index 9796e3461601..5db30e020d17 100644
--- a/srcpkgs/cyanrip/template
+++ b/srcpkgs/cyanrip/template
@@ -1,7 +1,7 @@
 # Template file for 'cyanrip'
 pkgname=cyanrip
 version=0.9.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config"
 makedepends="ffmpeg-devel libcdio-devel libcdio-paranoia-devel libcurl-devel libmusicbrainz5-devel"

From 0ab39cb0937e847d0df581b702e7b4319643b2b1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 029/115] deadbeef: revbump for ffmpeg4-4.4.3

---
 srcpkgs/deadbeef/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/deadbeef/template b/srcpkgs/deadbeef/template
index b664bb1b9bd9..165b3c7b9cad 100644
--- a/srcpkgs/deadbeef/template
+++ b/srcpkgs/deadbeef/template
@@ -1,14 +1,14 @@
 # Template file for 'deadbeef'
 pkgname=deadbeef
 version=1.8.8
-revision=1
+revision=2
 create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-oss --disable-lfm --disable-notify --disable-gtk2"
 hostmakedepends="automake libtool gettext gettext-devel intltool pkg-config
  yasm clang glib-devel"
 makedepends="
- alsa-lib-devel dbus-devel faad2-devel ffmpeg-devel gtk+3-devel imlib2-devel
+ alsa-lib-devel dbus-devel faad2-devel ffmpeg4-devel gtk+3-devel imlib2-devel
  jansson-devel libcddb-devel libcdio-devel libcurl-devel libflac-devel
  libmad-devel libpng-devel libsamplerate-devel libsndfile-devel libvorbis-devel
  libzip-devel mpg123-devel opusfile-devel pulseaudio-devel wavpack-devel"

From 42beea4adfdb83f5eeadc8e69982b13cae32490a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 030/115] dolphin-emu: revbump for ffmpeg-6.0

---
 srcpkgs/dolphin-emu/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/dolphin-emu/template b/srcpkgs/dolphin-emu/template
index 7ea197ceb2a8..7aeb0a5b645e 100644
--- a/srcpkgs/dolphin-emu/template
+++ b/srcpkgs/dolphin-emu/template
@@ -1,7 +1,7 @@
 # Template file for 'dolphin-emu'
 pkgname=dolphin-emu
 version=5.0.16101
-revision=1
+revision=2
 _dolphin_commit=8ecfa537a242de74d2e372e30d9d79b14584b2fb
 _mgba_commit=40d4c430fc36caeb7ea32fd39624947ed487d2f2
 #Version/hash pair can be found at https://dolphin-emu.org/download/

From 37fcbe189246490434e522624500c79eaa06e41a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 031/115] droidcam-obs-plugin: revbump for ffmpeg-6.0

---
 srcpkgs/droidcam-obs-plugin/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam-obs-plugin/template b/srcpkgs/droidcam-obs-plugin/template
index fc9c9bf6b9d5..fb0480754df4 100644
--- a/srcpkgs/droidcam-obs-plugin/template
+++ b/srcpkgs/droidcam-obs-plugin/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam-obs-plugin'
 pkgname=droidcam-obs-plugin
 version=2.0.1
-revision=1
+revision=2
 build_style=gnu-makefile
 make_use_env=yes
 make_build_args="ALLOW_STATIC=no"

From 2102e4d728a5a80e01328d3946a68501d6bb047a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 032/115] droidcam: revbump for ffmpeg-6.0

---
 srcpkgs/droidcam/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam/template b/srcpkgs/droidcam/template
index 1c3f1b8b1fc6..32a9220b79a4 100644
--- a/srcpkgs/droidcam/template
+++ b/srcpkgs/droidcam/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam'
 pkgname=droidcam
 version=1.8.2
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="USBMUXD=-lusbmuxd-2.0 JPEG=-lturbojpeg"
 hostmakedepends="pkg-config"

From d3361215bff0ab2667fe972fa96d9e32a7972d6c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 033/115] electron19: revbump for ffmpeg-6.0

---
 srcpkgs/electron19/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron19/template b/srcpkgs/electron19/template
index 068136be7623..32ce301e730c 100644
--- a/srcpkgs/electron19/template
+++ b/srcpkgs/electron19/template
@@ -1,7 +1,7 @@
 # Template file for 'electron19'
 pkgname=electron19
 version=19.0.8
-revision=2
+revision=3
 _nodever=16.14.2
 _chromiumver=102.0.5005.125
 archs="x86_64* aarch64* ppc64le*"

From ebb2470bcabe4bec6edaa2292b38cb0ad999c85b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 034/115] ffmpegthumbnailer: revbump for ffmpeg-6.0

---
 .../ffmpegthumbnailer/patches/ffmpeg6.patch   | 202 ++++++++++++++++++
 srcpkgs/ffmpegthumbnailer/template            |   6 +-
 2 files changed, 205 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch

diff --git a/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
new file mode 100644
index 000000000000..363ff35a2841
--- /dev/null
+++ b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
@@ -0,0 +1,202 @@
+--- a/libffmpegthumbnailer/moviedecoder.cpp	2017-11-21 14:06:57.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.cpp	2023-05-05 13:14:47.946560668 -0400
+@@ -41,11 +41,6 @@
+ namespace ffmpegthumbnailer
+ {
+ 
+-struct SilenceLogLevel
+-{
+-    SilenceLogLevel() { av_log_set_level(AV_LOG_QUIET); }
+-};
+-
+ MovieDecoder::MovieDecoder(AVFormatContext* pavContext)
+ : m_VideoStream(-1)
+ , m_pFormatContext(pavContext)
+@@ -70,8 +65,6 @@
+ 
+ void MovieDecoder::initialize(const string& filename, bool preferEmbeddedMetadata)
+ {
+-    av_register_all();
+-    avcodec_register_all();
+     avformat_network_init();
+ 
+     string inputFile = filename == "-" ? "pipe:" : filename;
+@@ -97,8 +90,7 @@
+ {
+     if (m_pVideoCodecContext)
+     {
+-        avcodec_close(m_pVideoCodecContext);
+-        m_pVideoCodecContext = nullptr;
++        avcodec_free_context(&m_pVideoCodecContext);
+     }
+ 
+     if ((!m_FormatContextWasGiven) && m_pFormatContext)
+@@ -152,10 +144,10 @@
+     for (unsigned int i = 0; i < m_pFormatContext->nb_streams; ++i)
+     {
+         AVStream *stream = m_pFormatContext->streams[i];
+-        auto ctx = m_pFormatContext->streams[i]->codec;
+-        if (ctx->codec_type == AVMEDIA_TYPE_VIDEO)
++        auto par = m_pFormatContext->streams[i]->codecpar;
++        if (par->codec_type == AVMEDIA_TYPE_VIDEO)
+         {
+-            if (!preferEmbeddedMetadata || !isStillImageCodec(ctx->codec_id))
++            if (!preferEmbeddedMetadata || !isStillImageCodec(par->codec_id))
+             {
+                 videoStreams.push_back(i);
+                 continue;
+@@ -203,8 +195,7 @@
+     }
+ 
+     m_pVideoStream = m_pFormatContext->streams[m_VideoStream];
+-    m_pVideoCodecContext = m_pVideoStream->codec;
+-    m_pVideoCodec = avcodec_find_decoder(m_pVideoCodecContext->codec_id);
++    m_pVideoCodec = avcodec_find_decoder(m_pVideoStream->codecpar->codec_id);
+ 
+     if (m_pVideoCodec == nullptr)
+     {
+@@ -214,6 +205,20 @@
+         throw logic_error("Video Codec not found");
+     }
+ 
++    m_pVideoCodecContext = avcodec_alloc_context3(m_pVideoCodec);
++
++    if (m_pVideoCodecContext == nullptr)
++    {
++        destroy();
++        throw logic_error("Could not allocate video codec context");
++    }
++
++    if (avcodec_parameters_to_context(m_pVideoCodecContext, m_pVideoStream->codecpar) < 0)
++    {
++        destroy();
++        throw logic_error("Could not configure video codec context");
++    }
++
+     m_pVideoCodecContext->workaround_bugs = 1;
+ 
+     if (avcodec_open2(m_pVideoCodecContext, m_pVideoCodec, nullptr) < 0)
+@@ -386,13 +391,6 @@
+ 
+ void MovieDecoder::initializeFilterGraph(const AVRational& timeBase, const std::string& size, bool maintainAspectRatio)
+ {
+-    static const AVPixelFormat pixelFormats[] = { AV_PIX_FMT_RGB24, AV_PIX_FMT_NONE };
+-
+-    auto del = [] (AVBufferSinkParams* p) { av_freep(p); };
+-    std::unique_ptr<AVBufferSinkParams, decltype(del)> buffersinkParams(av_buffersink_params_alloc(), del);
+-
+-    avfilter_register_all();
+-
+     m_pFilterGraph = avfilter_graph_alloc();
+     assert(m_pFilterGraph);
+ 
+@@ -404,10 +402,8 @@
+ 
+     checkRc(avfilter_graph_create_filter(&m_pFilterSource, avfilter_get_by_name("buffer"), "thumb_buffer", ss.str().c_str(), nullptr, m_pFilterGraph),
+             "Failed to create filter source");
+-    buffersinkParams->pixel_fmts = pixelFormats;
+-    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, buffersinkParams.get(), m_pFilterGraph),
++    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, nullptr, m_pFilterGraph),
+             "Failed to create filter sink");
+-    buffersinkParams.release();
+ 
+     AVFilterContext* yadifFilter = nullptr;
+     if (m_pFrame->interlaced_frame != 0)
+@@ -500,15 +496,15 @@
+     }
+ 
+     checkRc(av_seek_frame(m_pFormatContext, -1, timestamp, 0), "Seeking in video failed");
+-    avcodec_flush_buffers(m_pFormatContext->streams[m_VideoStream]->codec);
++    avcodec_flush_buffers(m_pVideoCodecContext);
+ 
+     int keyFrameAttempts = 0;
+-    bool gotFrame = 0;
++    bool gotFrame;
+ 
+     do
+     {
+         int count = 0;
+-        gotFrame = 0;
++        gotFrame = false;
+ 
+         while (!gotFrame && count < 20)
+         {
+@@ -552,17 +548,33 @@
+         return false;
+     }
+ 
+-    av_frame_unref(m_pFrame);
+-
+-    int frameFinished;
++    int rc = avcodec_send_packet(m_pVideoCodecContext, m_pPacket);
++    if(rc == AVERROR(EAGAIN))
++    {
++        rc = 0;
++    }
+ 
+-    int bytesDecoded = avcodec_decode_video2(m_pVideoCodecContext, m_pFrame, &frameFinished, m_pPacket);
+-    if (bytesDecoded < 0)
++    if(rc == AVERROR_EOF)
++    {
++        return false;
++    }
++    else if(rc < 0)
+     {
+-        throw logic_error("Failed to decode video frame: bytesDecoded < 0");
++        throw logic_error("Failed to decode video frame: avcodec_send_packet() < 0");
+     }
+ 
+-    return frameFinished > 0;
++    rc = avcodec_receive_frame(m_pVideoCodecContext, m_pFrame);
++    switch(rc)
++    {
++        case 0:
++            return true;
++
++        case AVERROR(EAGAIN):
++            return false;
++
++        default:
++            throw logic_error("Failed to decode video frame: avcodec_receive_frame() < 0");
++    }
+ }
+ 
+ bool MovieDecoder::getVideoPacket()
+@@ -570,8 +582,6 @@
+     bool framesAvailable = true;
+     bool frameDecoded = false;
+ 
+-    int attempts = 0;
+-
+     if (m_pPacket)
+     {
+         av_packet_unref(m_pPacket);
+@@ -580,6 +590,7 @@
+ 
+     m_pPacket = new AVPacket();
+ 
++
+     while (framesAvailable && !frameDecoded)
+     {
+         framesAvailable = av_read_frame(m_pFormatContext, m_pPacket) >= 0;
+@@ -644,7 +655,7 @@
+ 
+ int32_t MovieDecoder::getStreamRotation()
+ {
+-    int32_t* matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
++    auto matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
+     if (matrix)
+     {
+         auto angle = lround(av_display_rotation_get(matrix));
+
+--- a/libffmpegthumbnailer/moviedecoder.h	2017-11-12 04:23:38.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.h	2023-05-05 13:26:07.095529911 -0400
+@@ -78,7 +78,7 @@
+     int                     m_VideoStream;
+     AVFormatContext*        m_pFormatContext;
+     AVCodecContext*         m_pVideoCodecContext;
+-    AVCodec*                m_pVideoCodec;
++    const AVCodec*          m_pVideoCodec;
+     AVFilterGraph*          m_pFilterGraph;
+     AVFilterContext*        m_pFilterSource;
+     AVFilterContext*        m_pFilterSink;
diff --git a/srcpkgs/ffmpegthumbnailer/template b/srcpkgs/ffmpegthumbnailer/template
index 039eea7622b3..35d546018d12 100644
--- a/srcpkgs/ffmpegthumbnailer/template
+++ b/srcpkgs/ffmpegthumbnailer/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbnailer'
 pkgname=ffmpegthumbnailer
 version=2.2.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libpng-devel libjpeg-turbo-devel ffmpeg-devel"
@@ -9,8 +9,8 @@ depends="ffmpeg"
 short_desc="Lightweight video thumbnailer"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
-homepage="https://github.com/dirkvdb/${pkgname}"
-distfiles="${homepage}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
+homepage="https://github.com/dirkvdb"
+distfiles="${homepage}/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
 checksum=1cb24059c38223f657b300c84dd80491b7040d4b69471c4fea69be862bc99b5b
 
 post_install() {

From e63c25096d3deb32562b2a0baffb618240f49519 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 035/115] ffmpegthumbs: revbump for ffmpeg-6.0

---
 srcpkgs/ffmpegthumbs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ffmpegthumbs/template b/srcpkgs/ffmpegthumbs/template
index 5f0b9414dada..11b88193528f 100644
--- a/srcpkgs/ffmpegthumbs/template
+++ b/srcpkgs/ffmpegthumbs/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbs'
 pkgname=ffmpegthumbs
 version=22.12.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules kcoreaddons kconfig-devel
  pkg-config qt5-host-tools qt5-qmake gettext"

From 4e9adba7994bd9d3140e577377f7a8c28ac403ad Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 036/115] ffms2: revbump for ffmpeg-6.0

---
 srcpkgs/ffms2/patches/ffmpeg5.patch | 424 ++++++++++++++++++++++++++++
 srcpkgs/ffms2/template              |   2 +-
 2 files changed, 425 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ffms2/patches/ffmpeg5.patch

diff --git a/srcpkgs/ffms2/patches/ffmpeg5.patch b/srcpkgs/ffms2/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..1479fabcafcb
--- /dev/null
+++ b/srcpkgs/ffms2/patches/ffmpeg5.patch
@@ -0,0 +1,424 @@
+From 45673149e9a2f5586855ad472e3059084eaa36b1 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:41:21 +0100
+Subject: [PATCH] Use auto for AVCodec
+
+The geniuses over at FFmpeg decided to constify this API, so old
+versions of the library will return AVCodec *, while new versions
+of the libary will return const AVCodec *, which, in C++, are not
+OK to convert between.
+
+Rather than use some macro hell in ffmscompat.h, we can work around
+this by using auto.
+
+Gross.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 2 +-
+ src/core/indexing.cpp    | 6 +++---
+ src/core/videosource.cpp | 2 +-
+ 3 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index e4ce97c..ac09666 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -469,7 +469,7 @@ void FFMS_AudioSource::OpenFile() {
+ 
+     LAVFOpenFile(SourceFile.c_str(), FormatContext, TrackNumber);
+ 
+-    AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
++    auto *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
+     if (Codec == nullptr)
+         throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+             "Audio codec not found");
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index e547c5a..59fb4e8 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -384,7 +384,7 @@ FFMS_TrackType FFMS_Indexer::GetTrackType(int Track) {
+ }
+ 
+ const char *FFMS_Indexer::GetTrackCodec(int Track) {
+-    AVCodec *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
++    auto *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
+     return codec ? codec->name : nullptr;
+ }
+ 
+@@ -402,7 +402,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             UseDTS);
+ 
+         if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            AVCodec *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (!VideoCodec) {
+                 FormatContext->streams[i]->discard = AVDISCARD_ALL;
+                 IndexMask.erase(i);
+@@ -433,7 +433,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 IndexMask.insert(i);
+             }
+         } else if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+-            AVCodec *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (AudioCodec == nullptr)
+                 throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_UNSUPPORTED,
+                     "Audio codec not found");
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index b889970..8956c22 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -171,7 +171,7 @@ FFMS_VideoSource::FFMS_VideoSource(const char *SourceFile, FFMS_Index &Index, in
+ 
+         LAVFOpenFile(SourceFile, FormatContext, VideoTrack);
+ 
+-        AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
++        auto *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
+         if (Codec == nullptr)
+             throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+                 "Video codec not found");
+-- 
+2.40.0
+
+From 96cbf38ea9381829a1314f432a2c60495dcefaad Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:12:41 +0100
+Subject: [PATCH] all: Update AVPacket API usage
+
+AVPackets must all be on the heap now, since it is no longer
+part of the libav* ABI.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 16 ++++++----
+ src/core/indexing.cpp    | 63 ++++++++++++++++++++++------------------
+ src/core/indexing.h      |  4 +--
+ src/core/utils.cpp       |  6 ----
+ src/core/utils.h         |  1 -
+ src/core/videosource.cpp | 30 ++++++++++---------
+ 6 files changed, 64 insertions(+), 56 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index 37cf9ae..e4ce97c 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -285,10 +285,15 @@ FFMS_AudioSource::AudioBlock *FFMS_AudioSource::CacheBlock(CacheIterator &pos) {
+ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     CurrentFrame = &Frames[PacketNumber];
+ 
+-    AVPacket Packet;
+-    if (!ReadPacket(&Packet))
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++    if (!ReadPacket(Packet)) {
++        av_packet_free(&Packet);
+         throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_UNKNOWN,
+             "ReadPacket unexpectedly failed to read a packet");
++    }
+ 
+     // ReadPacket may have changed the packet number
+     CurrentFrame = &Frames[PacketNumber];
+@@ -297,8 +302,9 @@ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     int NumberOfSamples = 0;
+     AudioBlock *CachedBlock = nullptr;
+     
+-    int Ret = avcodec_send_packet(CodecContext, &Packet);
+-    av_packet_unref(&Packet);
++    int Ret = avcodec_send_packet(CodecContext, Packet);
++    av_packet_unref(Packet);
++    av_packet_free(&Packet);
+ 
+     av_frame_unref(DecodeFrame);
+     Ret = avcodec_receive_frame(CodecContext, DecodeFrame);
+@@ -513,8 +519,6 @@ void FFMS_AudioSource::Seek() {
+ }
+ 
+ bool FFMS_AudioSource::ReadPacket(AVPacket *Packet) {
+-    InitNullPacket(*Packet);
+-
+     while (av_read_frame(FormatContext, Packet) >= 0) {
+         if (Packet->stream_index == TrackNumber) {
+             // Required because not all audio packets, especially in ogg, have a pts. Use the previous valid packet's pts instead.
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index 23fb95b..e547c5a 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -320,7 +320,7 @@ void FFMS_Indexer::CheckAudioProperties(int Track, AVCodecContext *Context) {
+     }
+ }
+ 
+-void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict,
++void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict,
+                                     int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct) {
+     if (VideoContext.Parser) {
+         uint8_t *OB;
+@@ -330,8 +330,8 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+         av_parser_parse2(VideoContext.Parser,
+             VideoContext.CodecContext,
+             &OB, &OBSize,
+-            pkt.data, pkt.size,
+-            pkt.pts, pkt.dts, pkt.pos);
++            pkt->data, pkt->size,
++            pkt->pts, pkt->dts, pkt->pos);
+ 
+         // H.264 (PAFF) and HEVC may have one field per packet, so we need to track
+         // when we have a full or half frame available, and mark one of them as
+@@ -351,15 +351,15 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+ 
+         *RepeatPict = VideoContext.Parser->repeat_pict;
+         *FrameType = VideoContext.Parser->pict_type;
+-        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt.flags & AV_PKT_FLAG_DISCARD));
++        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt->flags & AV_PKT_FLAG_DISCARD));
+     } else {
+-        *Invisible = !!(pkt.flags & AV_PKT_FLAG_DISCARD);
++        *Invisible = !!(pkt->flags & AV_PKT_FLAG_DISCARD);
+     }
+ 
+     if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP8)
+-        ParseVP8(pkt.data[0], Invisible, FrameType);
++        ParseVP8(pkt->data[0], Invisible, FrameType);
+     else if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP9)
+-        ParseVP9(pkt.data[0], Invisible, FrameType);
++        ParseVP9(pkt->data[0], Invisible, FrameType);
+ }
+ 
+ void FFMS_Indexer::Free() {
+@@ -458,32 +458,36 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+         }
+     }
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
+     std::vector<int64_t> LastValidTS(FormatContext->nb_streams, AV_NOPTS_VALUE);
+ 
+     int64_t filesize = avio_size(FormatContext->pb);
+     enum AVPictureStructure LastPicStruct = AV_PICTURE_STRUCTURE_UNKNOWN;
+-    while (av_read_frame(FormatContext, &Packet) >= 0) {
++    while (av_read_frame(FormatContext, Packet) >= 0) {
+         // Update progress
+         // FormatContext->pb can apparently be NULL when opening images.
+         if (IC && FormatContext->pb) {
+-            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate))
++            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate)) {
++                av_packet_free(&Packet);
+                 throw FFMS_Exception(FFMS_ERROR_CANCELLED, FFMS_ERROR_USER,
+                     "Cancelled by user");
++            }
+         }
+-        if (!IndexMask.count(Packet.stream_index)) {
+-            av_packet_unref(&Packet);
++        if (!IndexMask.count(Packet->stream_index)) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+-        int Track = Packet.stream_index;
++        int Track = Packet->stream_index;
+         FFMS_Track &TrackInfo = (*TrackIndices)[Track];
+-        bool KeyFrame = !!(Packet.flags & AV_PKT_FLAG_KEY);
++        bool KeyFrame = !!(Packet->flags & AV_PKT_FLAG_KEY);
+         ReadTS(Packet, LastValidTS[Track], (*TrackIndices)[Track].UseDTS);
+ 
+         if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            int64_t PTS = TrackInfo.UseDTS ? Packet.dts : Packet.pts;
++            int64_t PTS = TrackInfo.UseDTS ? Packet->dts : Packet->pts;
+             if (PTS == AV_NOPTS_VALUE) {
+                 // VPx alt-refs are output as packets which lack timestmps or durations, since
+                 // they are invisible. Currently, the timestamp mangling code in libavformat
+@@ -495,9 +499,11 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 // FFMS2 currently sorts packets by PTS, which will break decoding, otherwise.
+                 bool HasAltRefs = (FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP8 ||
+                                    FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP9);
+-                if (Packet.duration == 0 && !HasAltRefs)
++                if (Packet->duration == 0 && !HasAltRefs) {
++                    av_packet_free(&Packet);
+                     throw FFMS_Exception(FFMS_ERROR_INDEXING, FFMS_ERROR_PARSER,
+                         "Invalid packet pts, dts, and duration");
++                }
+ 
+                 if (TrackInfo.empty())
+                     PTS = 0;
+@@ -513,7 +519,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             ParseVideoPacket(AVContexts[Track], Packet, &RepeatPict, &FrameType, &Invisible, &LastPicStruct);
+ 
+             TrackInfo.AddVideoFrame(PTS, RepeatPict, KeyFrame,
+-                FrameType, Packet.pos, Invisible);
++                FrameType, Packet->pos, Invisible);
+         } else if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+             // For video seeking timestamps are used only if all packets have
+             // timestamps, while for audio they're used if any have timestamps,
+@@ -522,28 +528,29 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 TrackInfo.HasTS = true;
+ 
+             int64_t StartSample = AVContexts[Track].CurrentSample;
+-            uint32_t SampleCount = IndexAudioPacket(Track, &Packet, AVContexts[Track], *TrackIndices);
++            uint32_t SampleCount = IndexAudioPacket(Track, Packet, AVContexts[Track], *TrackIndices);
+             TrackInfo.SampleRate = AVContexts[Track].CodecContext->sample_rate;
+ 
+             TrackInfo.AddAudioFrame(LastValidTS[Track],
+-                StartSample, SampleCount, KeyFrame, Packet.pos, Packet.flags & AV_PKT_FLAG_DISCARD);
++                StartSample, SampleCount, KeyFrame, Packet->pos, Packet->flags & AV_PKT_FLAG_DISCARD);
+         }
+ 
+-        if (!(Packet.flags & AV_PKT_FLAG_DISCARD))
+-            TrackInfo.LastDuration = Packet.duration;
++        if (!(Packet->flags & AV_PKT_FLAG_DISCARD))
++            TrackInfo.LastDuration = Packet->duration;
+ 
+-        av_packet_unref(&Packet);
++        av_packet_unref(Packet);
+     }
++    av_packet_free(&Packet);
+ 
+     TrackIndices->Finalize(AVContexts, FormatContext->iformat->name);
+     return TrackIndices.release();
+ }
+ 
+-void FFMS_Indexer::ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS) {
+-    if (!UseDTS && Packet.pts != AV_NOPTS_VALUE)
+-        TS = Packet.pts;
++void FFMS_Indexer::ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS) {
++    if (!UseDTS && Packet->pts != AV_NOPTS_VALUE)
++        TS = Packet->pts;
+     if (TS == AV_NOPTS_VALUE)
+         UseDTS = true;
+-    if (UseDTS && Packet.dts != AV_NOPTS_VALUE)
+-        TS = Packet.dts;
++    if (UseDTS && Packet->dts != AV_NOPTS_VALUE)
++        TS = Packet->dts;
+ }
+diff --git a/src/core/indexing.h b/src/core/indexing.h
+index 3cfc3c3..5c06868 100644
+--- a/src/core/indexing.h
++++ b/src/core/indexing.h
+@@ -80,10 +80,10 @@ private:
+     int64_t Filesize;
+     uint8_t Digest[20];
+ 
+-    void ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS);
++    void ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS);
+     void CheckAudioProperties(int Track, AVCodecContext *Context);
+     uint32_t IndexAudioPacket(int Track, AVPacket *Packet, SharedAVContext &Context, FFMS_Index &TrackIndices);
+-    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
++    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
+     void Free();
+ public:
+     FFMS_Indexer(const char *Filename);
+diff --git a/src/core/utils.cpp b/src/core/utils.cpp
+index ce67533..8a2e997 100644
+--- a/src/core/utils.cpp
++++ b/src/core/utils.cpp
+@@ -62,12 +62,6 @@ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo) {
+     }
+ }
+ 
+-void InitNullPacket(AVPacket &pkt) {
+-    av_init_packet(&pkt);
+-    pkt.data = nullptr;
+-    pkt.size = 0;
+-}
+-
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames) {
+     AP.SampleFormat = static_cast<FFMS_SampleFormat>(av_get_packed_sample_fmt(CTX->sample_fmt));
+     AP.BitsPerSample = av_get_bytes_per_sample(CTX->sample_fmt) * 8;
+diff --git a/src/core/utils.h b/src/core/utils.h
+index 9819dc7..003ab79 100644
+--- a/src/core/utils.h
++++ b/src/core/utils.h
+@@ -58,7 +58,6 @@ std::unique_ptr<T> make_unique(Args&&... args) {
+ }
+ 
+ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo);
+-void InitNullPacket(AVPacket &pkt);
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames);
+ 
+ void LAVFOpenFile(const char *SourceFile, AVFormatContext *&FormatContext, int Track);
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index 06bd161..b889970 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -673,30 +673,34 @@ void FFMS_VideoSource::DecodeNextFrame(int64_t &AStartTime, int64_t &Pos) {
+     if (HasPendingDelayedFrames())
+         return;
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
+-
+-    while (ReadFrame(&Packet) >= 0) {
+-        if (Packet.stream_index != VideoTrack) {
+-            av_packet_unref(&Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++
++    while (ReadFrame(Packet) >= 0) {
++        if (Packet->stream_index != VideoTrack) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+         if (AStartTime < 0)
+-            AStartTime = Frames.UseDTS ? Packet.dts : Packet.pts;
++            AStartTime = Frames.UseDTS ? Packet->dts : Packet->pts;
+ 
+         if (Pos < 0)
+-            Pos = Packet.pos;
++            Pos = Packet->pos;
+ 
+-        bool FrameFinished = DecodePacket(&Packet);
+-        av_packet_unref(&Packet);
+-        if (FrameFinished)
++        bool FrameFinished = DecodePacket(Packet);
++        av_packet_unref(Packet);
++        if (FrameFinished) {
++            av_packet_free(&Packet);
+             return;
++        }
+     }
+ 
+     // Flush final frames
+-    InitNullPacket(Packet);
+-    DecodePacket(&Packet);
++    DecodePacket(Packet);
++    av_packet_free(&Packet);
+ }
+ 
+ bool FFMS_VideoSource::SeekTo(int n, int SeekOffset) {
+-- 
+2.40.0
+
+From bf9e03e9e08534c024e5a744a6437c4aac160201 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:20:47 +0100
+Subject: [PATCH 2/3] configure: Remove deprecated API use
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ configure.ac | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index b35ef80bc..d19714d0f 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -102,10 +102,10 @@ CFLAGS="$_CFLAGS $FFMPEG_CFLAGS"
+
+ AC_DEFUN([TEST_FFMPEG],
+          [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+-            #include <libavcodec/avcodec.h>
++            #include <libavformat/avformat.h>
+             #include <libswscale/swscale.h>
+             ]],[[
+-                avcodec_register_all();
++                avformat_network_init();
+                 swscale_version();
+             ]])], [eval $1=yes], [eval $1=no])
+         ])
+
diff --git a/srcpkgs/ffms2/template b/srcpkgs/ffms2/template
index 68e8a0c14bce..2acfadac44b3 100644
--- a/srcpkgs/ffms2/template
+++ b/srcpkgs/ffms2/template
@@ -1,7 +1,7 @@
 # Template file for 'ffms2'
 pkgname=ffms2
 version=2.40
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-shared --disable-static"
 hostmakedepends="pkg-config autoconf automake libtool"

From 1222fe908d51f49828cf907c43269b774863a239 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 037/115] freerdp: revbump for ffmpeg-6.0

---
 .../freerdp/patches/ffmpeg6_aa2cb9aa.patch    | 42 +++++++++++++++++++
 srcpkgs/freerdp/template                      |  2 +-
 2 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch

diff --git a/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
new file mode 100644
index 000000000000..a4324da3a882
--- /dev/null
+++ b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
@@ -0,0 +1,42 @@
+From aa2cb9aa5ff5562433598ba168a466e0752bca0e Mon Sep 17 00:00:00 2001
+From: akallabeth <akallabeth@posteo.net>
+Date: Tue, 14 Feb 2023 07:48:54 +0100
+Subject: [PATCH] Fixed #8686: Update h264 to use new FFMPEG API
+
+---
+ channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c | 2 ++
+ libfreerdp/codec/h264_ffmpeg.c            | 2 ++
+ 2 files changed, 4 insertions(+)
+
+diff --git a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+index 339462d865f..beea80b7a1e 100644
+--- a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
++++ b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+@@ -239,8 +239,10 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYP
+ 		}
+ 	}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 	if (mdecoder->codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		mdecoder->codec_context->flags |= AV_CODEC_FLAG_TRUNCATED;
++#endif
+ 
+ 	return TRUE;
+ }
+diff --git a/libfreerdp/codec/h264_ffmpeg.c b/libfreerdp/codec/h264_ffmpeg.c
+index 8a23db2473c..896a333019b 100644
+--- a/libfreerdp/codec/h264_ffmpeg.c
++++ b/libfreerdp/codec/h264_ffmpeg.c
+@@ -615,10 +615,12 @@ static BOOL libavcodec_init(H264_CONTEXT* h264)
+ 			goto EXCEPTION;
+ 		}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 		if (sys->codecDecoder->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		{
+ 			sys->codecDecoderContext->flags |= AV_CODEC_FLAG_TRUNCATED;
+ 		}
++#endif
+ 
+ #ifdef WITH_VAAPI
+ 
diff --git a/srcpkgs/freerdp/template b/srcpkgs/freerdp/template
index 25e8aa9677f0..4d51c8189902 100644
--- a/srcpkgs/freerdp/template
+++ b/srcpkgs/freerdp/template
@@ -1,7 +1,7 @@
 # Template file for 'freerdp'
 pkgname=freerdp
 version=2.10.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_ALSA=ON -DWITH_CUPS=OFF -DWITH_FFMPEG=ON
  -DWITH_GSTREAMER_0_10=OFF -DWITH_GSTREAMER_1_0=OFF -DWITH_JPEG=ON

From f995b47cca685dd2b14dacc16ecc361acfac193d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 038/115] gerbera: revbump for ffmpeg-6.0

---
 srcpkgs/gerbera/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gerbera/template b/srcpkgs/gerbera/template
index ae14f35c767c..2dc0ac0ce03b 100644
--- a/srcpkgs/gerbera/template
+++ b/srcpkgs/gerbera/template
@@ -1,7 +1,7 @@
 # Template file for 'gerbera'
 pkgname=gerbera
 version=1.12.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_SYSTEMD=0 -DWITH_AVCODEC=1"
 hostmakedepends="pkg-config"

From 1ec1c2866aea383d4a6cb7ffa8eaae1fc81505d3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 039/115] goldendict: revbump for ffmpeg-6.0

---
 srcpkgs/goldendict/patches/ffmpeg4.patch |  21 --
 srcpkgs/goldendict/patches/ffmpeg5.patch | 232 +++++++++++++++++++++++
 srcpkgs/goldendict/template              |   2 +-
 3 files changed, 233 insertions(+), 22 deletions(-)
 delete mode 100644 srcpkgs/goldendict/patches/ffmpeg4.patch
 create mode 100644 srcpkgs/goldendict/patches/ffmpeg5.patch

diff --git a/srcpkgs/goldendict/patches/ffmpeg4.patch b/srcpkgs/goldendict/patches/ffmpeg4.patch
deleted file mode 100644
index f045fa27f54b..000000000000
--- a/srcpkgs/goldendict/patches/ffmpeg4.patch
+++ /dev/null
@@ -1,21 +0,0 @@
---- a/ffmpegaudio.cc.orig 2018-05-09 22:16:13.480659958 +0200
-+++ b/ffmpegaudio.cc      2018-05-09 22:16:50.748322790 +0200
-@@ -143,7 +143,7 @@
-     return false;
-   }
-
--  unsigned char * avioBuffer = ( unsigned char * )av_malloc( kBufferSize + FF_INPUT_BUFFER_PADDING_SIZE );
-+  unsigned char * avioBuffer = ( unsigned char * )av_malloc( kBufferSize + AV_INPUT_BUFFER_PADDING_SIZE );
-   if ( !avioBuffer )
-   {
-     errorString = QObject::tr( "av_malloc() failed." );
-@@ -380,7 +380,7 @@
-   }
-
-   if ( !Qt4x5::AtomicInt::loadAcquire( isCancelled_ ) &&
--       codecContext_->codec->capabilities & CODEC_CAP_DELAY )
-+       codecContext_->codec->capabilities & AV_CODEC_CAP_DELAY )
-   {
-     av_init_packet( &packet );
-     int gotFrame = 0;
-
diff --git a/srcpkgs/goldendict/patches/ffmpeg5.patch b/srcpkgs/goldendict/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..7cfc98ada368
--- /dev/null
+++ b/srcpkgs/goldendict/patches/ffmpeg5.patch
@@ -0,0 +1,232 @@
+From 03bbe01b79a1f07a6780cb60f23a087104c5d77b Mon Sep 17 00:00:00 2001
+From: Abs62 <ottomann@yandex.ru>
+Date: Fri, 30 Mar 2018 22:53:24 +0300
+Subject: [PATCH] Fix warnings while compile with FFMpeg 3.4.2 (issue #978)
+
+---
+ ffmpegaudio.cc | 68 +++++++++++++++++++++++++++++++++++++++++++++-----
+ 1 file changed, 62 insertions(+), 6 deletions(-)
+
+diff --git a/ffmpegaudio.cc b/ffmpegaudio.cc
+index ed1172bdd..56e8f788e 100644
+--- a/ffmpegaudio.cc
++++ b/ffmpegaudio.cc
+@@ -91,6 +91,7 @@ struct DecoderContext
+   QByteArray audioData_;
+   QDataStream audioDataStream_;
+   AVFormatContext * formatContext_;
++  AVCodec * codec_;
+   AVCodecContext * codecContext_;
+   AVIOContext * avioContext_;
+   AVStream * audioStream_;
+@@ -114,6 +115,7 @@ DecoderContext::DecoderContext( QByteArray const & audioData, QAtomicInt & isCan
+   audioData_( audioData ),
+   audioDataStream_( audioData_ ),
+   formatContext_( NULL ),
++  codec_( NULL ),
+   codecContext_( NULL ),
+   avioContext_( NULL ),
+   audioStream_( NULL ),
+@@ -143,7 +145,11 @@ bool DecoderContext::openCodec( QString & errorString )
+     return false;
+   }
+
++#if LIBAVCODEC_VERSION_MAJOR < 56 || ( LIBAVCODEC_VERSION_MAJOR == 56 && LIBAVCODEC_VERSION_MINOR < 56 )
+   unsigned char * avioBuffer = ( unsigned char * )av_malloc( kBufferSize + FF_INPUT_BUFFER_PADDING_SIZE );
++#else
++  unsigned char * avioBuffer = ( unsigned char * )av_malloc( kBufferSize + AV_INPUT_BUFFER_PADDING_SIZE );
++#endif
+   if ( !avioBuffer )
+   {
+     errorString = QObject::tr( "av_malloc() failed." );
+@@ -186,7 +192,11 @@ bool DecoderContext::openCodec( QString & errorString )
+   // Find audio stream, use the first audio stream if available
+   for ( unsigned i = 0; i < formatContext_->nb_streams; i++ )
+   {
++#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 33 )
+     if ( formatContext_->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO )
++#else
++      if ( formatContext_->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO )
++#endif
+     {
+       audioStream_ = formatContext_->streams[i];
+       break;
+@@ -198,22 +208,38 @@ bool DecoderContext::openCodec( QString & errorString )
+     return false;
+   }
+
++#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 33 )
+   codecContext_ = audioStream_->codec;
+-  AVCodec * codec = avcodec_find_decoder( codecContext_->codec_id );
+-  if ( !codec )
++  codec_ = avcodec_find_decoder( codecContext_->codec_id );
++  if ( !codec_ )
+   {
+     errorString = QObject::tr( "Codec [id: %1] not found." ).arg( codecContext_->codec_id );
+     return false;
+   }
++#else
++  codec_ = avcodec_find_decoder( audioStream_->codecpar->codec_id );
++  if ( !codec_ )
++  {
++    errorString = QObject::tr( "Codec [id: %1] not found." ).arg( audioStream_->codecpar->codec_id );
++    return false;
++  }
++  codecContext_ = avcodec_alloc_context3( codec_ );
++  if ( !codecContext_ )
++  {
++    errorString = QObject::tr( "avcodec_alloc_context3() failed." );
++    return false;
++  }
++  avcodec_parameters_to_context( codecContext_, audioStream_->codecpar );
++#endif
+
+-  ret = avcodec_open2( codecContext_, codec, NULL );
++  ret = avcodec_open2( codecContext_, codec_, NULL );
+   if ( ret < 0 )
+   {
+     errorString = QObject::tr( "avcodec_open2() failed: %1." ).arg( avErrorString( ret ) );
+     return false;
+   }
+
+-  av_log( NULL, AV_LOG_INFO, "Codec open: %s: channels: %d, rate: %d, format: %s\n", codec->long_name,
++  av_log( NULL, AV_LOG_INFO, "Codec open: %s: channels: %d, rate: %d, format: %s\n", codec_->long_name,
+           codecContext_->channels, codecContext_->sample_rate, av_get_sample_fmt_name( codecContext_->sample_fmt ) );
+   return true;
+ }
+@@ -252,10 +278,13 @@ void DecoderContext::closeCodec()
+
+   // Closing a codec context without prior avcodec_open2() will result in
+   // a crash in ffmpeg
+-  if ( audioStream_ && audioStream_->codec && audioStream_->codec->codec )
++  if ( audioStream_ && codecContext_ && codec_ )
+   {
+     audioStream_->discard = AVDISCARD_ALL;
+-    avcodec_close( audioStream_->codec );
++    avcodec_close( codecContext_ );
++#if LIBAVCODEC_VERSION_MAJOR > 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR >= 33 )
++    avcodec_free_context( &codecContext_ );
++#endif
+   }
+
+   avformat_close_input( &formatContext_ );
+@@ -356,6 +385,7 @@ bool DecoderContext::play( QString & errorString )
+     if ( packet.stream_index == audioStream_->index )
+     {
+       AVPacket pack = packet;
++#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 37 )
+       int gotFrame = 0;
+       do
+       {
+@@ -370,6 +400,19 @@ bool DecoderContext::play( QString & errorString )
+         pack.data += len;
+       }
+       while( pack.size > 0 );
++#else
++      int ret = avcodec_send_packet( codecContext_, &pack );
++      /* read all the output frames (in general there may be any number of them) */
++      while( ret >= 0 )
++      {
++        ret = avcodec_receive_frame( codecContext_, frame);
++
++        if ( Qt4x5::AtomicInt::loadAcquire( isCancelled_ ) || ret < 0 )
++          break;
++
++        playFrame( frame );
++      }
++#endif
+     }
+     // av_free_packet() must be called after each call to av_read_frame()
+ #if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 7 )
+@@ -379,6 +422,7 @@ bool DecoderContext::play( QString & errorString )
+ #endif
+   }
+
++#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 37 )
+   if ( !Qt4x5::AtomicInt::loadAcquire( isCancelled_ ) &&
+        codecContext_->codec->capabilities & CODEC_CAP_DELAY )
+   {
+@@ -391,6 +435,18 @@ bool DecoderContext::play( QString & errorString )
+       playFrame( frame );
+     }
+   }
++#else
++  /* flush the decoder */
++  av_init_packet( &packet );
++  int ret = avcodec_send_packet(codecContext_, &packet );
++  while( ret >= 0 )
++  {
++    ret = avcodec_receive_frame(codecContext_, frame);
++    if ( Qt4x5::AtomicInt::loadAcquire( isCancelled_ ) || ret < 0 )
++      break;
++    playFrame( frame );
++  }
++#endif
+
+ #if LIBAVCODEC_VERSION_MAJOR < 54
+   av_free( frame );
+32
+srcpkgs/goldendict/patches/ffmpeg5-2.patch
+Comment on this file
+@@ -0,0 +1,32 @@
+From 966f4a8b78e6324b930e5a50f2bb930bd87e565e Mon Sep 17 00:00:00 2001
+From: Abs62 <ottomann@yandex.ru>
+Date: Fri, 27 Sep 2019 17:00:52 +0300
+Subject: [PATCH] FFmpeg player: Fix some crashes on broken files
+
+---
+ ffmpegaudio.cc | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/ffmpegaudio.cc b/ffmpegaudio.cc
+index 56e8f788e..415fc79cb 100644
+--- a/ffmpegaudio.cc
++++ b/ffmpegaudio.cc
+@@ -51,7 +51,9 @@ AudioService & AudioService::instance()
+
+ AudioService::AudioService()
+ {
++#if LIBAVFORMAT_VERSION_MAJOR < 58 || ( LIBAVFORMAT_VERSION_MAJOR == 58 && LIBAVFORMAT_VERSION_MINOR < 9 )
+   av_register_all();
++#endif
+   ao_initialize();
+ }
+
+@@ -438,6 +440,8 @@ bool DecoderContext::play( QString & errorString )
+ #else
+   /* flush the decoder */
+   av_init_packet( &packet );
++  packet.data = NULL;
++  packet.size = 0;
+   int ret = avcodec_send_packet(codecContext_, &packet );
+   while( ret >= 0 )
+   {
+25
+srcpkgs/goldendict/patches/ffmpeg5-3.patch
+Comment on this file
+@@ -0,0 +1,25 @@
+From 8acb288c9e9bdb3c6bf2e803954dd3b6ac273c05 Mon Sep 17 00:00:00 2001
+From: Liao Junxuan <mikeljx@126.com>
+Date: Sun, 20 Feb 2022 12:28:05 +0800
+Subject: [PATCH] add support for ffmpeg 5.0
+
+---
+ ffmpegaudio.cc | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/ffmpegaudio.cc b/ffmpegaudio.cc
+index d550f4a77..7948d2187 100644
+--- a/ffmpegaudio.cc
++++ b/ffmpegaudio.cc
+@@ -94,7 +94,11 @@ struct DecoderContext
+   QByteArray audioData_;
+   QDataStream audioDataStream_;
+   AVFormatContext * formatContext_;
++#if LIBAVCODEC_VERSION_MAJOR < 59
+   AVCodec * codec_;
++#else
++  const AVCodec * codec_;
++#endif
+   AVCodecContext * codecContext_;
+   AVIOContext * avioContext_;
+   AVStream * audioStream_;
diff --git a/srcpkgs/goldendict/template b/srcpkgs/goldendict/template
index 4544ae710ee6..2ca4185e538a 100644
--- a/srcpkgs/goldendict/template
+++ b/srcpkgs/goldendict/template
@@ -9,7 +9,7 @@ makedepends="tiff-devel qt5-devel libvorbis-devel zlib-devel
  libXtst-devel hunspell-devel qt5-tools-devel qt5-declarative-devel
  qt5-webkit-devel lzo-devel bzip2-devel libao-devel qt5-svg-devel
  libeb-devel qt5-x11extras-devel ffmpeg-devel liblzma-devel"
-short_desc="A feature-rich dictionary lookup program"
+short_desc="Feature-rich dictionary lookup program"
 maintainer="John <me@johnnynator.dev>"
 license="GPL-3.0-or-later"
 homepage="http://goldendict.org/"

From 1aee6e8d96f9c4cfb76fb089b25f12cea5d37dde Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 040/115] gst-libav: revbump for ffmpeg-6.0

---
 srcpkgs/gst-libav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index e9a79dc650a5..f082bd211c65 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.20.3
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"

From 9116fbba9005538f87198d08359bc9db3f16505a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 041/115] gst-plugins-bad1: revbump for ffmpeg-6.0

---
 srcpkgs/gst-plugins-bad1/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index f55f82fd4c77..dc9d389734e1 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-plugins-bad1'
 pkgname=gst-plugins-bad1
-version=1.20.3
-revision=3
+version=1.22.2
+revision=2
 build_helper="gir"
 build_style=meson
 configure_args="-Dpackage-origin=https://voidlinux.org -Ddoc=disabled

From 79d20087f60b715b7cfcb50b2b5a1d94cd4239a0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 042/115] gst-rtsp-server: revbump for ffmpeg-6.0

---
 srcpkgs/gst-rtsp-server/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index 33cd64ceb95e..8ceea8d34b4b 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
 version=1.20.3
-revision=2
+revision=3
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="glib-devel gst-plugins-bad1-devel gobject-introspection

From e7b5f401b71a5b37aa5ecfaa94decc429d6f29bf Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 043/115] guvcview: update to 2.0.8.

---
 srcpkgs/guvcview/patches/fix-include.patch | 10 ++++++++++
 srcpkgs/guvcview/template                  |  5 ++---
 2 files changed, 12 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/guvcview/patches/fix-include.patch

diff --git a/srcpkgs/guvcview/patches/fix-include.patch b/srcpkgs/guvcview/patches/fix-include.patch
new file mode 100644
index 000000000000..503c2af3b78c
--- /dev/null
+++ b/srcpkgs/guvcview/patches/fix-include.patch
@@ -0,0 +1,10 @@
+--- a/guvcview/guvcview.c
++++ b/guvcview/guvcview.c
+@@ -28,6 +28,7 @@
+ #include <sys/stat.h>
+ #include <sys/resource.h>
+ #include <errno.h>
++#include <locale.h>
+ 
+ #include "gview.h"
+ #include "gviewv4l2core.h"
diff --git a/srcpkgs/guvcview/template b/srcpkgs/guvcview/template
index 345cf6006f24..86a7fd619612 100644
--- a/srcpkgs/guvcview/template
+++ b/srcpkgs/guvcview/template
@@ -1,8 +1,7 @@
 # Template file for 'guvcview'
 pkgname=guvcview
-version=2.0.7
+version=2.0.8
 revision=1
-create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-static --disable-debian-menu"
 hostmakedepends="pkg-config intltool autoconf automake libtool glib-devel"
@@ -14,7 +13,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="http://guvcview.sourceforge.net/"
 distfiles="${SOURCEFORGE_SITE}/${pkgname}/${pkgname}-src-${version}.tar.bz2"
-checksum=f47d51fbd06e44eeaa1a82f4a153c927527c90d94514197a70b2956028cc8ad4
+checksum=a21f4e448286666cf27bafef5290cc953a0a1796b752e5bbe521266dc1230c81
 
 post_patch() {
 	sed '31a#include <locale.h>' -i  guvcview/guvcview.c

From 1f613e34f36191ec5e5573f1ad54105426ca7b37 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 044/115] handbrake: update to 1.6.1

---
 .../patches/fix-missing-x265-link-flag.patch    | 11 ++++++-----
 .../handbrake/patches/libhb-vpl-include.patch   | 15 +++++++++++++++
 srcpkgs/handbrake/template                      | 17 ++++++++++-------
 3 files changed, 31 insertions(+), 12 deletions(-)
 create mode 100644 srcpkgs/handbrake/patches/libhb-vpl-include.patch

diff --git a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
index 26db03867a0c..d6bb2eda627a 100644
--- a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
+++ b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
@@ -1,14 +1,15 @@
 --- a/gtk/configure.ac
 +++ b/gtk/configure.ac
 @@ -203,7 +203,7 @@
- 
+
  AM_CONDITIONAL([MINGW], [test "x$mingw_flag" = "xyes"])
- 
--HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg"
-+HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -ldl"
+
+-HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc"
++HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc -ldl"
  HB_CPPFLAGS="$HB_CPPFLAGS $HBINC"
- 
+
  PKG_CHECK_MODULES([x264], [x264], sys_x264=yes, sys_x264=no)
+
 --- a/test/module.defs
 +++ b/test/module.defs
 @@ -69,6 +69,9 @@
diff --git a/srcpkgs/handbrake/patches/libhb-vpl-include.patch b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
new file mode 100644
index 000000000000..298f9f4ab28f
--- /dev/null
+++ b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
@@ -0,0 +1,15 @@
+--- a/libhb/module.defs	2023-01-22 11:36:49.000000000 -0500
++++ b/libhb/module.defs	2023-04-03 22:37:52.395467010 -0400
+@@ -46,11 +46,7 @@
+ LIBHB.GCC.I += $(LIBHB.build/) $(CONTRIB.build/)include
+ 
+ ifeq (1,$(FEATURE.qsv))
+-    ifeq ($(HOST.system),freebsd))
+-        LIBHB.GCC.I += $(LOCALBASE)/include/vpl
+-    else
+-        LIBHB.GCC.I += $(CONTRIB.build/)include/vpl
+-    endif
++    LIBHB.GCC.I += /usr/include/vpl
+ endif
+ 
+ ifneq (,$(filter $(HOST.system),freebsd netbsd openbsd))
diff --git a/srcpkgs/handbrake/template b/srcpkgs/handbrake/template
index ca5e4571e49c..c32cb1bfa31f 100644
--- a/srcpkgs/handbrake/template
+++ b/srcpkgs/handbrake/template
@@ -1,10 +1,10 @@
 # Template file for 'handbrake'
 pkgname=handbrake
-version=1.5.1
+version=1.6.1
 revision=1
 build_style=gnu-configure
 configure_args="--force --disable-gtk-update-checks --disable-df-fetch --harden
- $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc)"
+ $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc) $(vopt_enable qsv)"
 make_build_args="-C ${XBPS_TRIPLET}"
 make_install_args="-C ${XBPS_TRIPLET}"
 hostmakedepends="automake cmake gettext-devel glib-devel intltool libtool m4 meson nasm pkg-config python3"
@@ -12,8 +12,11 @@ makedepends="bzip2-devel ffmpeg-devel gst-plugins-base1-devel gtk+3-devel
  jansson-devel lame-devel libass-devel libbluray-devel libdav1d-devel
  libdvdnav-devel libdvdread-devel libgudev-devel libnuma-devel
  libsamplerate-devel libtheora-devel libvorbis-devel libvpx-devel libxml2-devel
- opus-devel speex-devel x264-devel x265-devel zimg-devel
+ opus-devel speex-devel x264-devel x265-devel zimg-devel libsvt-av1-devel
  $(vopt_if fdk_aac fdk-aac-devel)
+ $(vopt_if qsv libva-devel)
+ $(vopt_if qsv libdrm-devel)
+ $(vopt_if qsv onevpl-devel)
  $(vopt_if nvenc nv-codec-headers)"
 depends="desktop-file-utils gst-plugins-good1 hicolor-icon-theme"
 short_desc="Multithreaded video transcoder"
@@ -21,15 +24,15 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-2.0-only"
 homepage="https://handbrake.fr/"
 distfiles="https://github.com/HandBrake/HandBrake/releases/download/${version}/HandBrake-${version}-source.tar.bz2"
-checksum=3999fe06d5309c819799a73a968a8ec3840e7840c2b64af8f5cdb7fd8c9430f0
+checksum=94ccfe03db917a91650000c510f7fd53f844da19f19ad4b4be1b8f6bc31a8d4c
 nocross=yes
 
-build_options="fdk_aac nvenc"
+build_options="fdk_aac nvenc qsv"
 
 case "$XBPS_TARGET_MACHINE" in
 	x86_64*|i686*)
 		CFLAGS="-msse"
-		build_options_default="nvenc"
+		build_options_default="nvenc qsv"
 		;;
 esac
 
@@ -37,7 +40,7 @@ pre_configure() {
 	# use system libraries, don't download them
 	rm -rf contrib/
 	for module in fdk-aac ffmpeg libbluray libdav1d libdvdnav libdvdread nvenc \
-		x265 zimg; do
+		x265 zimg svt-av1 libvpl; do
 	    vsed -i "/MODULES += contrib\/${module}/d" make/include/main.defs
 	done
 }

From 23c775316676797c187faa386717ade8d480a4ab Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 045/115] hedgewars: revbump for ffmpeg4-4.4.3

---
 srcpkgs/hedgewars/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/hedgewars/template b/srcpkgs/hedgewars/template
index 419f29b98b44..926fe4fe3e68 100644
--- a/srcpkgs/hedgewars/template
+++ b/srcpkgs/hedgewars/template
@@ -1,13 +1,13 @@
 # Template file for 'hedgewars'
 pkgname=hedgewars
 version=1.0.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DNOSERVER=1 -DDATA_INSTALL_DIR=/usr/share/${pkgname}
  -DPHYSFS_SYSTEM=1 -DMINIMAL_FLAGS=1"
 make_cmd=make
 hostmakedepends="lua51 pkg-config qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
+makedepends="ffmpeg4-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
  SDL2_mixer-devel SDL2_net-devel SDL2_ttf-devel"
 depends="libfreeglut"
 short_desc="Funny turn-based artillery game, featuring fighting Hedgehogs!"

From d65f579cd3dab169a42ea3680615cdbf524e499f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 046/115] idjc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/idjc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/idjc/template b/srcpkgs/idjc/template
index df60318b3db9..36a75baf597c 100644
--- a/srcpkgs/idjc/template
+++ b/srcpkgs/idjc/template
@@ -1,11 +1,11 @@
 # Template file for 'idjc'
 pkgname=idjc
 version=0.9.1
-revision=3
+revision=4
 build_style=gnu-configure
 hostmakedepends="pkg-config git python3 automake gettext-devel libtool"
 makedepends="libvorbis-devel libogg-devel jack-devel libsamplerate-devel
- libflac-devel libsndfile-devel mpg123-devel ffmpeg-devel speex-devel
+ libflac-devel libsndfile-devel mpg123-devel ffmpeg4-devel speex-devel
  glib-devel pixman-devel lame-devel python3-gobject-devel libshout-idjc-devel
  opus-devel twolame-devel python3-mutagen python3-devel"
 depends="python3-gobject python3-mutagen desktop-file-utils shared-mime-info python3-dbus jack"

From 72d8d52d2bfe083dc04d76f1bb56c4c4bfeb2f54 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 047/115] kfilemetadata5: revbump for ffmpeg-6.0

---
 srcpkgs/kfilemetadata5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kfilemetadata5/template b/srcpkgs/kfilemetadata5/template
index 8980121fbc69..f662a2043f93 100644
--- a/srcpkgs/kfilemetadata5/template
+++ b/srcpkgs/kfilemetadata5/template
@@ -1,7 +1,7 @@
 # Template file for 'kfilemetadata5'
 pkgname=kfilemetadata5
 version=5.105.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="kcoreaddons extra-cmake-modules pkg-config qt5-host-tools qt5-qmake
  gettext kcoreaddons python3"

From 08a598b72e6c53b793aa155807a04785dea9abb3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 048/115] kid3: revbump for ffmpeg-6.0

---
 srcpkgs/kid3/patches/ffmpeg5.patch | 17 +++++++++++++++++
 srcpkgs/kid3/template              |  2 +-
 2 files changed, 18 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/kid3/patches/ffmpeg5.patch

diff --git a/srcpkgs/kid3/patches/ffmpeg5.patch b/srcpkgs/kid3/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..135fc50e07c9
--- /dev/null
+++ b/srcpkgs/kid3/patches/ffmpeg5.patch
@@ -0,0 +1,17 @@
+# https://aur.archlinux.org/cgit/aur.git/diff/ffmpeg5.patch?h=kid3-cli&id=12410a74906612e7efc0ec8fbce739b4a0fef7e7
+diff --git a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+index e156d424..e12b9abd 100644
+--- a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
++++ b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+@@ -232,7 +232,11 @@ private:
+   friend class Format;
+   friend class Converter;
+   AVCodecContext* m_ptr;
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 0, 0)
+   AVCodec* m_impl;
++#else
++  const AVCodec* m_impl;
++#endif
+   AVFrame* m_frame;
+   bool m_opened;
+ };
diff --git a/srcpkgs/kid3/template b/srcpkgs/kid3/template
index 456206d90e16..f32f9decb0e7 100644
--- a/srcpkgs/kid3/template
+++ b/srcpkgs/kid3/template
@@ -1,7 +1,7 @@
 # Template file for 'kid3'
 pkgname=kid3
 version=3.9.1
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DWITH_APPS='CLI;$(vopt_if KDE KDE Qt)'
  -DWITH_DOCBOOKDIR=/usr/share/xsl/docbook -DWITH_FLAC=$(vopt_if flac ON OFF)

From 4253cbff60908b72c1a21047b66d49b9c471a8c5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 049/115] kodi: revbump for ffmpeg4-4.4.3

---
 srcpkgs/kodi/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/kodi/template b/srcpkgs/kodi/template
index 8057964d78a3..6cc1874be7ba 100644
--- a/srcpkgs/kodi/template
+++ b/srcpkgs/kodi/template
@@ -1,7 +1,7 @@
 # Template file for 'kodi'
 pkgname=kodi
 version=19.4
-revision=6
+revision=7
 _codename="Matrix"
 build_style=cmake
 configure_args="-DWITH_FFMPEG=/usr -DENABLE_LDGOLD=OFF
@@ -54,7 +54,7 @@ makedepends="
  libmad-devel fontconfig-devel libXinerama-devel libsamplerate-devel libmms-devel
  enca-devel boost-devel libcurl-devel libva-devel libvdpau-devel libass-devel
  libbluetooth-devel yajl-devel libplist-devel librtmp-devel tinyxml-devel
- taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg-devel
+ taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg4-devel
  giflib-devel libxslt-devel gnutls-devel libssh-devel libmicrohttpd-devel
  libcec-devel dcadec-devel flatbuffers-devel fmt-devel lcms2-devel
  libfstrcmp-devel rapidjson libcdio-paranoia spdlog libwaylandpp-devel

From 0b4cd6b4017591086137a4c0239e4a46d30460fd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 050/115] kpipewire: revbump for ffmpeg-6.0

---
 srcpkgs/kpipewire/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kpipewire/template b/srcpkgs/kpipewire/template
index 467ab823a5e1..51827f24db9e 100644
--- a/srcpkgs/kpipewire/template
+++ b/srcpkgs/kpipewire/template
@@ -1,7 +1,7 @@
 # Template file for 'kpipewire'
 pkgname=kpipewire
 version=5.27.4
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules plasma-wayland-protocols gettext
  qt5-qmake qt5-host-tools pkg-config wayland-devel kcoreaddons

From 7fa28b2af916efea654a4f681b4de60e2a610382 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 051/115] libextractor: revbump for ffmpeg4-4.4.3

---
 srcpkgs/libextractor/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libextractor/template b/srcpkgs/libextractor/template
index ddd4790f93e8..1fb9ca56a96a 100644
--- a/srcpkgs/libextractor/template
+++ b/srcpkgs/libextractor/template
@@ -7,7 +7,7 @@ configure_args="--disable-static"
 hostmakedepends="pkg-config"
 makedepends="zlib-devel bzip2-devel exiv2-devel tiff-devel libpng-devel
  libjpeg-turbo-devel libvorbis-devel libflac-devel giflib-devel libmpeg2-devel
- ffmpeg-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
+ ffmpeg4-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
 short_desc="Library used to extract meta data from files"
 maintainer="Martin Riese <grauehaare@gmx.de>"
 license="GPL-3.0-or-later"

From 187931f718670dc74c879b408b32548f9656b205 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 052/115] libopenal: revbump for ffmpeg-6.0

---
 srcpkgs/libopenal/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenal/template b/srcpkgs/libopenal/template
index 77218f9e539d..3f49ed75a1fd 100644
--- a/srcpkgs/libopenal/template
+++ b/srcpkgs/libopenal/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenal'
 pkgname=libopenal
 version=1.22.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DALSOFT_EXAMPLES=OFF"
 hostmakedepends="pkg-config"

From 5815972357c594243a909666ace64a0dadcad050 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 053/115] libopenshot: revbump for ffmpeg-6.0

---
 srcpkgs/libopenshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenshot/template b/srcpkgs/libopenshot/template
index db831f69b474..81aa0d7136d9 100644
--- a/srcpkgs/libopenshot/template
+++ b/srcpkgs/libopenshot/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenshot'
 pkgname=libopenshot
 version=0.3.0
-revision=1
+revision=2
 build_style=cmake
 # Builds fail with Ruby-2.4.1
 configure_args="-DENABLE_RUBY=OFF -DUSE_SYSTEM_JSONCPP=ON"

From 50d776c0dabbdd5bdd2f03627ada27443bbb173b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 054/115] loudgain: revbump for ffmpeg-6.0

---
 srcpkgs/loudgain/patches/ffmpeg5.patch | 11 +++++++++++
 srcpkgs/loudgain/template              |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/loudgain/patches/ffmpeg5.patch

diff --git a/srcpkgs/loudgain/patches/ffmpeg5.patch b/srcpkgs/loudgain/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..16d4510ee98f
--- /dev/null
+++ b/srcpkgs/loudgain/patches/ffmpeg5.patch
@@ -0,0 +1,11 @@
+--- a/src/scan.c	2019-09-06 11:31:19.000000000 -0400
++++ b/src/scan.c	2023-03-23 11:15:40.867968521 -0400
+@@ -69,8 +69,6 @@
+ 	 * It is now useless
+ 	 * https://github.com/FFmpeg/FFmpeg/blob/70d25268c21cbee5f08304da95be1f647c630c15/doc/APIchanges#L86
+ 	 */
+-  if (avformat_version() < AV_VERSION_INT(58,9,100))
+-    av_register_all();
+ 
+ 	av_log_set_callback(scan_av_log);
+ 
diff --git a/srcpkgs/loudgain/template b/srcpkgs/loudgain/template
index da4f2d56e94c..4d6bf29efb4f 100644
--- a/srcpkgs/loudgain/template
+++ b/srcpkgs/loudgain/template
@@ -1,7 +1,7 @@
 # Template file for 'loudgain'
 pkgname=loudgain
 version=0.6.8
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libebur128-devel taglib-devel ffmpeg-devel"

From f8cda18c46eab51c4e005d53439627a8343a8c88 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 055/115] mediastreamer: revbump for ffmpeg4-4.4.3

---
 srcpkgs/mediastreamer/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mediastreamer/template b/srcpkgs/mediastreamer/template
index d0e97e858e29..1bde031443a5 100644
--- a/srcpkgs/mediastreamer/template
+++ b/srcpkgs/mediastreamer/template
@@ -1,11 +1,11 @@
 # Template file for 'mediastreamer'
 pkgname=mediastreamer
 version=5.2.6
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_STRICT=0 -DENABLE_UNIT_TESTS=0"
 hostmakedepends="python3"
-makedepends="bzrtp-devel ffmpeg-devel glew-devel libXv-devel libsrtp-devel
+makedepends="bzrtp-devel ffmpeg4-devel glew-devel libXv-devel libsrtp-devel
  libupnp-devel libvpx-devel mbedtls-devel opus-devel ortp-devel pulseaudio-devel
  libtheora-devel speex-devel v4l-utils-devel bcg729-devel bcmatroska2-devel libgsm-devel"
 # zxing-cpp-devel (1.2.0 probably not compatible, check again after updaing xzing)

From 8f233333909c232570b4073560075f96e7df04df Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 056/115] mgba: revbump for ffmpeg-6.0

---
 srcpkgs/mgba/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mgba/template b/srcpkgs/mgba/template
index ae0504311eee..d31295a0cd3d 100644
--- a/srcpkgs/mgba/template
+++ b/srcpkgs/mgba/template
@@ -1,7 +1,7 @@
 # Template file for 'mgba'
 pkgname=mgba
 version=0.10.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake desktop-file-utils"
 makedepends="SDL2-devel ffmpeg-devel libedit-devel libepoxy-devel libmagick-devel

From cdce2b526a5cb555ed95aeac0d898bafd0e1a1f4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 057/115] minidlna: revbump for ffmpeg-6.0

---
 srcpkgs/minidlna/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/minidlna/template b/srcpkgs/minidlna/template
index e8081b1cbc67..9ee9714861fd 100644
--- a/srcpkgs/minidlna/template
+++ b/srcpkgs/minidlna/template
@@ -1,7 +1,7 @@
 # Template file for 'minidlna'
 pkgname=minidlna
 version=1.3.2
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="
  --sbindir=/usr/bin

From 8be3ee09f8e0d0f48443aded7dd171480e80adb8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 058/115] mixxx: revbump for ffmpeg-6.0

---
 srcpkgs/mixxx/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mixxx/template b/srcpkgs/mixxx/template
index 619ddca0d332..4b9ea00d3fb3 100644
--- a/srcpkgs/mixxx/template
+++ b/srcpkgs/mixxx/template
@@ -1,7 +1,7 @@
 # Template file for 'mixxx'
 pkgname=mixxx
 version=2.3.3
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="extra-cmake-modules pkg-config protobuf qt5-host-tools qt5-devel"

From 367870c32065dc29ca1c061dd3184425f4806323 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 059/115] mlt: revbump for ffmpeg4-4.4.3

---
 srcpkgs/mlt/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mlt/template b/srcpkgs/mlt/template
index 8933eb4e7bb9..73353fedafb5 100644
--- a/srcpkgs/mlt/template
+++ b/srcpkgs/mlt/template
@@ -1,14 +1,14 @@
 # Template file for 'mlt'
 pkgname=mlt
 version=6.26.1
-revision=1
+revision=2
 build_style=configure
 configure_args="--prefix=/usr --libdir=/usr/lib$XBPS_TARGET_WORDSIZE
  --enable-gpl --enable-gpl3 --disable-swfdec --without-kde
  --swig-languages=python"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which"
 # XXX: movit vid.stab
-makedepends="alsa-lib-devel ffmpeg-devel gtk+-devel jack-devel ladspa-sdk
+makedepends="alsa-lib-devel ffmpeg4-devel gtk+-devel jack-devel ladspa-sdk
  libexif-devel libsamplerate-devel libxml2-devel sox-devel SDL_image-devel
  fftw-devel frei0r-plugins python3-devel pulseaudio-devel movit-devel
  libvidstab-devel libatomic-devel"

From b1c4aafcb4733b922233b3f1a7f7ce22ff90888c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 060/115] moc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/moc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/moc/template b/srcpkgs/moc/template
index c42be650a1d2..d4f0eefbad52 100644
--- a/srcpkgs/moc/template
+++ b/srcpkgs/moc/template
@@ -1,10 +1,10 @@
 # Template file for 'moc'
 pkgname=moc
 version=2.5.2
-revision=6
+revision=7
 build_style=gnu-configure
 hostmakedepends="pkg-config"
-makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg-devel
+makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg4-devel
  jack-devel alsa-lib-devel libltdl-devel libflac-devel libvorbis-devel
  libmad-devel libmpcdec-devel libmodplug-devel libid3tag-devel faad2-devel
  taglib-devel libsndfile-devel wavpack-devel speex-devel libsamplerate-devel

From 1eff1b52487efd649fcd394cc985bc518805e580 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 061/115] motion: revbump for ffmpeg-6.0

---
 srcpkgs/motion/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/motion/template b/srcpkgs/motion/template
index 3cf3c3035c5b..7dca12d851e3 100644
--- a/srcpkgs/motion/template
+++ b/srcpkgs/motion/template
@@ -1,7 +1,7 @@
 # Template file for 'motion'
 pkgname=motion
 version=4.5.1
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake pkg-config gettext-devel tar"
 makedepends="ffmpeg-devel libmicrohttpd-devel v4l-utils-devel gettext-devel"

From 32eb49a3aaa1d2865ccadda81db7a4c76cdae901 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 062/115] mpv: revbump for ffmpeg-6.0

---
 srcpkgs/mpv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpv/template b/srcpkgs/mpv/template
index e163c496c6eb..d4fefbf5e3c7 100644
--- a/srcpkgs/mpv/template
+++ b/srcpkgs/mpv/template
@@ -1,7 +1,7 @@
 # Template file for 'mpv'
 pkgname=mpv
 version=0.35.1
-revision=2
+revision=3
 build_style=meson
 configure_args="-Dcdda=enabled -Ddvbin=enabled -Ddvdnav=enabled
  -Dlibmpv=true -Dcplugins=enabled

From 8c9690d2905383ed28e649af2f10e8cd267f07e8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 063/115] musikcube: revbump for ffmpeg-6.0

---
 srcpkgs/musikcube/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/musikcube/template b/srcpkgs/musikcube/template
index 4b7930041126..7cd65cf76b77 100644
--- a/srcpkgs/musikcube/template
+++ b/srcpkgs/musikcube/template
@@ -1,7 +1,7 @@
 # Template file for 'musikcube'
 pkgname=musikcube
 version=0.99.4
-revision=1
+revision=2
 build_style=cmake
 make_cmd=make
 configure_args="-DNO_NCURSESW=1"

From 2625715963d686174a62465f0bce4257916f0d35 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 064/115] notcurses: revbump for ffmpeg-6.0

---
 srcpkgs/notcurses/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/notcurses/template b/srcpkgs/notcurses/template
index 6dd8a091319f..3110c30c9aff 100644
--- a/srcpkgs/notcurses/template
+++ b/srcpkgs/notcurses/template
@@ -1,7 +1,7 @@
 # Template file for 'notcurses'
 pkgname=notcurses
 version=3.0.9
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DUSE_STATIC=ON $(vopt_bool man USE_PANDOC)"
 hostmakedepends="pkg-config $(vopt_if man pandoc)"

From 664e7bde66882fb5f8c6b0017bde4c2cc2e8c41a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 065/115] obs: revbump for ffmpeg-6.0

---
 srcpkgs/obs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/obs/template b/srcpkgs/obs/template
index 89fd11297c3f..3cf49e414bf3 100644
--- a/srcpkgs/obs/template
+++ b/srcpkgs/obs/template
@@ -1,7 +1,7 @@
 # Template file for 'obs'
 pkgname=obs
 version=29.1.0
-revision=1
+revision=2
 archs="i686* x86_64* ppc64le* aarch64*"
 build_style=cmake
 configure_args="-DOBS_VERSION_OVERRIDE=${version} -DENABLE_JACK=ON

From 893fb73b0b047e5fa8e33a0de91bfdb1ef1296bd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 066/115] olive: revbump for ffmpeg4-4.4.3

---
 srcpkgs/olive/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/olive/template b/srcpkgs/olive/template
index 12a46936c990..5c2917b9c512 100644
--- a/srcpkgs/olive/template
+++ b/srcpkgs/olive/template
@@ -1,10 +1,10 @@
 # Template file for 'olive'
 pkgname=olive
 version=0.1.2
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools pkg-config"
-makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg-devel frei0r-plugins"
+makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg4-devel frei0r-plugins"
 short_desc="Non-linear video editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"

From de56fe4d55bddaa978c0fe094fc04d242085401c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 067/115] omxplayer: revbump for ffmpeg4-4.4.3

---
 srcpkgs/omxplayer/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/omxplayer/template b/srcpkgs/omxplayer/template
index e70bf7873d4d..0e9bc70e7c8e 100644
--- a/srcpkgs/omxplayer/template
+++ b/srcpkgs/omxplayer/template
@@ -1,10 +1,10 @@
 # Template file for 'omxplayer'
 pkgname=omxplayer
 version=20190102
-revision=1
+revision=2
 short_desc="Commandline OMX player for the Raspberry Pi"
 maintainer="Orphaned <orphan@voidlinux.org>"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://github.com/popcornmix/omxplayer"
 
 _commit="f06235cc9690a6d58187514452df8cf8fcdaacec"
@@ -15,7 +15,7 @@ checksum=af2d9450f8947842ea8c401fe9f71eec444013ebbdee29f2ac828c9c493c1329
 archs="armv6l* armv7l*"
 build_style=gnu-makefile
 hostmakedepends="curl pkg-config"
-makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg-devel dbus-devel"
+makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg4-devel dbus-devel"
 depends="freefont-ttf"
 
 do_build() {

From ef9f8927d630d02ae1e3c990ee2bbbe3bab6fc5a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 068/115] openimageio: revbump for ffmpeg-6.0

---
 common/shlibs                | 2 ++
 srcpkgs/openimageio/template | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/shlibs b/common/shlibs
index fcc7401be626..5f05896ba1d1 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2262,6 +2262,8 @@ libxmp.so.4 libxmp-4.3.7_1
 libKF5ThreadWeaver.so.5 threadweaver-5.26.0_1
 libOpenImageIO_Util.so.2.4 openimageio-2.4.9.0_1
 libOpenImageIO.so.2.4 openimageio-2.4.9.0_1
+libOpenImageIO_Util.so.2.4 openimageio-2.4.8.1_1
+libOpenImageIO.so.2.4 openimageio-2.4.8.1_1
 libOpenColorIO.so.2.1 opencolorio-2.1.2_1
 libpystring.so.1 pystring-1.1.3_1
 libyaml-cpp.so.0.7 yaml-cpp-0.7.0_1
diff --git a/srcpkgs/openimageio/template b/srcpkgs/openimageio/template
index b661bbf7ba57..9b38ace50f7e 100644
--- a/srcpkgs/openimageio/template
+++ b/srcpkgs/openimageio/template
@@ -1,7 +1,7 @@
 # Template file for 'openimageio'
 pkgname=openimageio
 version=2.4.9.0
-revision=2
+revision=3
 build_style=cmake
 build_helper=qemu
 configure_args="-DUSE_QT=0 -DUSE_PYTHON=0 -DOIIO_BUILD_TESTS=0

From 811c70c6496f6ee84ea727e00613131d573c0eb0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 069/115] openmw: revbump for ffmpeg-6.0

---
 srcpkgs/openmw/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openmw/template b/srcpkgs/openmw/template
index 5251a0283dc1..e3771c7aaf1a 100644
--- a/srcpkgs/openmw/template
+++ b/srcpkgs/openmw/template
@@ -1,7 +1,7 @@
 # Template file for 'openmw'
 pkgname=openmw
 version=0.47.0
-revision=4
+revision=5
 build_style=cmake
 _recast_commit=e75adf86f91eb3082220085e42dda62679f9a3ea
 _bullet_tag=3.17

From 2f2ba3fcd1c541342e4cc5d0c5d40bd7404ec9a5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 070/115] openshot: revbump for ffmpeg-6.0

---
 srcpkgs/openshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openshot/template b/srcpkgs/openshot/template
index 322717d40abc..c074e0338773 100644
--- a/srcpkgs/openshot/template
+++ b/srcpkgs/openshot/template
@@ -1,7 +1,7 @@
 # Template file for 'openshot'
 pkgname=openshot
 version=3.0.0
-revision=1
+revision=2
 build_style=python3-module
 hostmakedepends="python3 python3-setuptools"
 makedepends="ffmpeg-devel python3-PyQt5"

From 9488a765692629eddc8944341de8267bc4461b90 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 071/115] opentoonz: revbump for ffmpeg-6.0

---
 srcpkgs/opentoonz/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/opentoonz/template b/srcpkgs/opentoonz/template
index ee9f7603f55f..3e81834ca0ed 100644
--- a/srcpkgs/opentoonz/template
+++ b/srcpkgs/opentoonz/template
@@ -1,7 +1,7 @@
 # Template file for 'opentoonz'
 pkgname=opentoonz
 version=1.6.0
-revision=2
+revision=3
 build_wrksrc="toonz/sources"
 build_style=cmake
 make_cmd=make

From d803d9a848206b9d59967576ef4febbc0d537d58 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 072/115] pianobar: revbump for ffmpeg-6.0

---
 srcpkgs/pianobar/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pianobar/template b/srcpkgs/pianobar/template
index a9b29e91993f..81efcd122c4d 100644
--- a/srcpkgs/pianobar/template
+++ b/srcpkgs/pianobar/template
@@ -1,7 +1,7 @@
 # Template file for 'pianobar'
 pkgname=pianobar
 version=2022.04.01
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="V=1"
 hostmakedepends="pkg-config"

From ebf95e2d004bd3156ff436d6bea236fd18fdac5f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 073/115] ppsspp: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ppsspp/template | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/ppsspp/template b/srcpkgs/ppsspp/template
index 7984a733d4be..15a42fd2c993 100644
--- a/srcpkgs/ppsspp/template
+++ b/srcpkgs/ppsspp/template
@@ -1,7 +1,7 @@
 # Template file for 'ppsspp'
 pkgname=ppsspp
 version=1.14.4
-revision=1
+revision=2
 _glslang_commit=dc11adde23c455a24e13dd54de9b4ede8bdd7db8
 _SPIRV_Cross_commit=9acb9ec31f5a8ef80ea6b994bb77be787b08d3d1
 _armips_commit=6719edebaae03330ee5441d9b28280672edf00d5
@@ -13,7 +13,7 @@ configure_args="-DHEADLESS=1 -DUSE_SYSTEM_FFMPEG=1 -DUNITTEST=ON
  -DUSING_QT_UI=$(vopt_if qt ON OFF) -DUSE_SYSTEM_ZSTD=ON
  -DARMIPS_USE_STD_FILESYSTEM=ON"
 hostmakedepends="pkg-config python3 $(vopt_if qt qt5-host-tools)"
-makedepends="zlib-devel glew-devel ffmpeg-devel libzip-devel
+makedepends="zlib-devel glew-devel ffmpeg4-devel libzip-devel
  snappy-devel rapidjson libpng-devel libzstd-devel
  $(vopt_if sdl2 SDL2-devel) $(vopt_if wayland wayland-devel)
  $(vopt_if qt 'qt5-devel qt5-multimedia-devel')"
@@ -62,13 +62,12 @@ post_extract() {
 	mv ${wrksrc}/miniupnp-${_miniupnp_commit} ${wrksrc}/ext/miniupnp
 }
 
-post_patch(){
+post_patch() {
 	# disable git versioning
 	vsed -e 's|find_package(Git)|# &|' -i git-version.cmake
 }
 
 do_install() {
-	vlicense LICENSE.TXT
 	vinstall icons/icon.svg 644 usr/share/pixmaps ppsspp.svg
 	vinstall Qt/PPSSPP.desktop 644 usr/share/applications
 	vbin build/PPSSPPHeadless ppsspp-headless

From d9457ef5ad55b755ce49c6f10f5ed721871043cc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 074/115] pqiv: revbump for ffmpeg-6.0

---
 srcpkgs/pqiv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pqiv/template b/srcpkgs/pqiv/template
index 542fc27a2d32..9308d949b6a1 100644
--- a/srcpkgs/pqiv/template
+++ b/srcpkgs/pqiv/template
@@ -1,7 +1,7 @@
 # Template file for 'pqiv'
 pkgname=pqiv
 version=2.12
-revision=1
+revision=2
 build_style=gnu-makefile
 hostmakedepends="pkg-config"
 makedepends="glib-devel gtk+3-devel $(vopt_if ffmpeg ffmpeg-devel)

From 70a28738048f99eea3ea55c412300ad4a7f3baa5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 075/115] qmmp: revbump for ffmpeg-6.0

---
 srcpkgs/qmmp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qmmp/template b/srcpkgs/qmmp/template
index 26c661ed16be..a150d7441c7a 100644
--- a/srcpkgs/qmmp/template
+++ b/srcpkgs/qmmp/template
@@ -1,7 +1,7 @@
 # Template file for 'qmmp'
 pkgname=qmmp
 version=1.6.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DUSE_HAL:BOOL=FALSE -DQMMP_DEFAULT_UI:STRING=simple"
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From 7122ecfe1aac0dffb9796d19abb03b5db7b0f121 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 076/115] qt5-webengine: update to 5.15.13

---
 .../chromium-media-filters-cpp14.patch        |  11 ++
 srcpkgs/qt5-webengine/patches/ffmpeg5.patch   | 179 ++++++++++++++++++
 srcpkgs/qt5-webengine/template                |  10 +-
 3 files changed, 195 insertions(+), 5 deletions(-)
 create mode 100644 srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/ffmpeg5.patch

diff --git a/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
new file mode 100644
index 000000000000..04adc540f2cb
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
@@ -0,0 +1,11 @@
+--- a/src/3rdparty/chromium/media/filters/BUILD.gn	2023-02-27 13:32:59.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/BUILD.gn	2023-04-02 17:21:39.204066384 -0400
+@@ -96,6 +96,8 @@
+     "//ui/gfx/geometry:geometry",
+   ]
+ 
++  cflags_cc = [ "-std=c++14" ]
++
+   libs = []
+ 
+   if (proprietary_codecs) {
diff --git a/srcpkgs/qt5-webengine/patches/ffmpeg5.patch b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..ac55e1634423
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
@@ -0,0 +1,179 @@
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:57.732547446 -0400
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:09.486478995 -0400
+@@ -57,6 +57,8 @@
+ 
+ namespace {
+ 
++constexpr int64_t kRelativeTsBase = static_cast<int64_t>(0x7ffeffffffffffff);
++
+ void SetAVStreamDiscard(AVStream* stream, AVDiscard discard) {
+   DCHECK(stream);
+   stream->discard = discard;
+@@ -90,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+   if (stream->start_time != kNoFFmpegTimestamp)
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (stream->first_dts != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, stream->first_dts);
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -408,11 +398,11 @@
+   scoped_refptr<DecoderBuffer> buffer;
+ 
+   if (type() == DemuxerStream::TEXT) {
+-    int id_size = 0;
++    size_t id_size = 0;
+     uint8_t* id_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
+ 
+-    int settings_size = 0;
++    size_t settings_size = 0;
+     uint8_t* settings_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
+ 
+@@ -424,7 +414,7 @@
+     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
+                                      side_data.data(), side_data.size());
+   } else {
+-    int side_data_size = 0;
++    size_t side_data_size = 0;
+     uint8_t* side_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
+ 
+@@ -485,7 +475,7 @@
+                                        packet->size - data_offset);
+     }
+ 
+-    int skip_samples_size = 0;
++    size_t skip_samples_size = 0;
+     const uint32_t* skip_samples_ptr =
+         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
+             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
+@@ -1587,6 +1577,8 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++      continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+       lowest_start_time_stream = stream.get();
+@@ -1604,6 +1596,8 @@
+     if (stream && stream->type() == DemuxerStream::VIDEO &&
+         stream->IsEnabled()) {
+       video_stream = stream.get();
++      if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++        continue;
+       if (video_stream->start_time() <= seek_time) {
+         return video_stream;
+       }
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h qtwebengine-5.15.10/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h
+--- a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-07-11 22:12:47.917192788 -0500
+@@ -29,6 +29,7 @@ extern "C" {
+ #include <libavformat/avformat.h>
+ #include <libavformat/avio.h>
+ #include <libavutil/avutil.h>
++#include <libavutil/channel_layout.h>
+ #include <libavutil/imgutils.h>
+ #include <libavutil/log.h>
+ #include <libavutil/mastering_display_metadata.h>
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/audio_file_reader.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/audio_file_reader.cc
+--- a/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -85,7 +85,7 @@ bool AudioFileReader::OpenDemuxer() {
+ }
+ 
+ bool AudioFileReader::OpenDecoder() {
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (codec) {
+     // MP3 decodes to S16P which we don't support, tell it to use S16 instead.
+     if (codec_context_->sample_fmt == AV_SAMPLE_FMT_S16P)
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -329,7 +329,7 @@ bool FFmpegAudioDecoder::ConfigureDecode
+     }
+   }
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec ||
+       avcodec_open2(codec_context_.get(), codec, &codec_options) < 0) {
+     DLOG(ERROR) << "Could not initialize audio decoder: "
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -59,7 +59,6 @@ static int64_t AVIOSeekOperation(void* o
+ }
+ 
+ void FFmpegGlue::InitializeFFmpeg() {
+-  av_register_all();
+ }
+ 
+ static void LogContainer(bool is_local_file,
+@@ -95,9 +94,6 @@ FFmpegGlue::FFmpegGlue(FFmpegURLProtocol
+   // Enable fast, but inaccurate seeks for MP3.
+   format_context_->flags |= AVFMT_FLAG_FAST_SEEK;
+ 
+-  // Ensures we can read out various metadata bits like vp8 alpha.
+-  format_context_->flags |= AVFMT_FLAG_KEEP_SIDE_DATA;
+-
+   // Ensures format parsing errors will bail out. From an audit on 11/2017, all
+   // instances were real failures. Solves bugs like http://crbug.com/710791.
+   format_context_->error_recognition |= AV_EF_EXPLODE;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -391,7 +391,7 @@ bool FFmpegVideoDecoder::ConfigureDecode
+   if (decode_nalus_)
+     codec_context_->flags2 |= AV_CODEC_FLAG2_CHUNKS;
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
+     ReleaseFFmpegResources();
+     return false;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/media_file_checker.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/media_file_checker.cc
+--- a/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -68,7 +68,7 @@ bool MediaFileChecker::Start(base::TimeD
+       auto context = AVStreamToAVCodecContext(format_context->streams[i]);
+       if (!context)
+         continue;
+-      AVCodec* codec = avcodec_find_decoder(cp->codec_id);
++      const AVCodec* codec = avcodec_find_decoder(cp->codec_id);
+       if (codec && avcodec_open2(context.get(), codec, nullptr) >= 0) {
+         auto loop = std::make_unique<FFmpegDecodingLoop>(context.get());
+         stream_contexts[i] = {std::move(context), std::move(loop)};
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc qtwebengine-5.15.10/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc
+--- a/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -203,7 +203,7 @@ int32_t H264DecoderImpl::InitDecode(cons
+   // a pointer |this|.
+   av_context_->opaque = this;
+ 
+-  AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
+   if (!codec) {
+     // This is an indication that FFmpeg has not been initialized or it has not
+     // been compiled/initialized with the correct set of codecs.
diff --git a/srcpkgs/qt5-webengine/template b/srcpkgs/qt5-webengine/template
index 0a71484208bc..095ab67701e4 100644
--- a/srcpkgs/qt5-webengine/template
+++ b/srcpkgs/qt5-webengine/template
@@ -1,9 +1,9 @@
 # Template file for 'qt5-webengine'
 pkgname=qt5-webengine
-version=5.15.11
-revision=2
+version=5.15.13
+revision=1
 _version="${version}-lts"
-_chromium_commit=be349eaf62e77955791d7bf29f893f1e8a37daf4
+_chromium_commit=e48df7803c7c98b0b2471c94057d32e44a301ad5
 archs="x86_64* i686* armv[67]* ppc64* aarch64*"
 create_wrksrc=yes
 build_style=qmake
@@ -32,8 +32,8 @@ license="GPL-3.0-or-later, LGPL-3.0-or-later"
 homepage="https://qt.io/"
 distfiles="https://github.com/qt/qtwebengine/archive/v${_version}.tar.gz
  https://github.com/qt/qtwebengine-chromium/archive/${_chromium_commit}.tar.gz"
-checksum="aa7466356c450c5f5870f979b93cd7e7e62da1165c328ffcab1a9928db18ad67
- 6f47ed8ab8cc062411f6f206da6353bc8263d6ed6d6290c689a05c01d91f646b"
+checksum="4b59838ed75ef788b59e1e412535a0e42dd9d311661fdeadb191b581ba815c63
+ a91686562b1d4e8b220e0bbcbab5feb64630e2de974b35ac034bf388af771a6c"
 
 no_generic_pkgconfig_link=yes
 build_options="sndio pipewire"

From 9b9ff4e130db5e70ce55e050939c607a779408f5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 077/115] qt5: update to 5.15.8

---
 ...erywhere-opensource-src-5.15.8-kf5-1.patch | 12913 ++++++++++++++++
 srcpkgs/qt5/template                          |    12 +-
 2 files changed, 12919 insertions(+), 6 deletions(-)
 create mode 100644 srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch

diff --git a/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch b/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch
new file mode 100644
index 000000000000..966c98bcd3bb
--- /dev/null
+++ b/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch
@@ -0,0 +1,12913 @@
+Submitted By:            Pierre Labastie <pierre_dot_labastie_at_neuf_dot_fr>
+Date:                    2023-01-05
+Initial Package Version: 5.15.8
+Upstream Status:         Applied (according to KDE)
+Origin:                  KDE patch set
+Description:             Patch set maintained by the KDE folks
+see https://dot.kde.org/2021/04/06/announcing-kdes-qt-5-patch-collection
+Patch generated using the procedure in
+https://wiki.linuxfromscratch.org/blfs/ticket/17476#comment:3
+
+Submodule qtbase 4ee4fc18..9cf586d6:
+diff --git a/qtbase/mkspecs/common/android/qplatformdefs.h b/qtbase/mkspecs/common/android/qplatformdefs.h
+index f75bc4093b..2bd59410d4 100644
+--- a/qtbase/mkspecs/common/android/qplatformdefs.h
++++ b/qtbase/mkspecs/common/android/qplatformdefs.h
+@@ -144,11 +144,7 @@
+ #define QT_SIGNAL_ARGS          int
+ #define QT_SIGNAL_IGNORE        SIG_IGN
+ 
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+ #define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+ 
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+diff --git a/qtbase/mkspecs/features/mac/sdk.mk b/qtbase/mkspecs/features/mac/sdk.mk
+index f30b5830b4..a32ceacb6c 100644
+--- a/qtbase/mkspecs/features/mac/sdk.mk
++++ b/qtbase/mkspecs/features/mac/sdk.mk
+@@ -1,6 +1,6 @@
+ 
+ ifeq ($(QT_MAC_SDK_NO_VERSION_CHECK),)
+-    CHECK_SDK_COMMAND = /usr/bin/xcrun --sdk $(EXPORT_QMAKE_MAC_SDK) -show-sdk-version 2>&1
++    CHECK_SDK_COMMAND = /usr/bin/xcrun --sdk $(EXPORT_QMAKE_MAC_SDK) -show-sdk-version 2>/dev/null
+     CURRENT_MAC_SDK_VERSION := $(shell DEVELOPER_DIR=$(EXPORT_QMAKE_XCODE_DEVELOPER_PATH) $(CHECK_SDK_COMMAND))
+     ifneq ($(CURRENT_MAC_SDK_VERSION),$(EXPORT_QMAKE_MAC_SDK_VERSION))
+         # We don't want to complain about out of date SDK unless the target needs to be remade.
+diff --git a/qtbase/mkspecs/linux-clang/qplatformdefs.h b/qtbase/mkspecs/linux-clang/qplatformdefs.h
+index a818d973f0..c1ab72fbc6 100644
+--- a/qtbase/mkspecs/linux-clang/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-clang/qplatformdefs.h
+@@ -79,14 +79,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-g++/qplatformdefs.h b/qtbase/mkspecs/linux-g++/qplatformdefs.h
+index 13523f0702..4d2750d9ec 100644
+--- a/qtbase/mkspecs/linux-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-g++/qplatformdefs.h
+@@ -79,14 +79,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ < 2)
+-#define QT_SOCKLEN_T            int
+-#else
+-#define QT_SOCKLEN_T            socklen_t
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-llvm/qplatformdefs.h b/qtbase/mkspecs/linux-llvm/qplatformdefs.h
+index dc750ab1ef..d3cc39b47f 100644
+--- a/qtbase/mkspecs/linux-llvm/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-llvm/qplatformdefs.h
+@@ -80,14 +80,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h b/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
+index 4c4e53da2a..83baffb3e3 100644
+--- a/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
+@@ -85,16 +85,9 @@
+ #include "../common/posix/qplatformdefs.h"
+ 
+ #undef QT_OPEN_LARGEFILE
+-#undef QT_SOCKLEN_T
+ 
+ #define QT_OPEN_LARGEFILE       0
+ 
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #ifndef SIOCGIFBRDADDR
+ #  define SIOCGIFBRDADDR 0x8919
+ #endif
+diff --git a/qtbase/mkspecs/lynxos-g++/qplatformdefs.h b/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
+index 4339ea2b23..6007af0055 100644
+--- a/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
+@@ -72,14 +72,6 @@
+ 
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp b/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
+index c3c184258f..32af3f8f29 100644
+--- a/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
++++ b/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
+@@ -10,6 +10,7 @@
+ #include "libANGLE/HandleAllocator.h"
+ 
+ #include <algorithm>
++#include <limits>
+ 
+ #include "common/debug.h"
+ 
+diff --git a/qtbase/src/3rdparty/forkfd/forkfd_linux.c b/qtbase/src/3rdparty/forkfd/forkfd_linux.c
+index ffe0e9a5e2..b1f5408d11 100644
+--- a/qtbase/src/3rdparty/forkfd/forkfd_linux.c
++++ b/qtbase/src/3rdparty/forkfd/forkfd_linux.c
+@@ -82,7 +82,8 @@ static int sys_clone(unsigned long cloneflags, int *ptid)
+     return syscall(__NR_clone, cloneflags, child_stack, stack_size, ptid, newtls, ctid);
+ #elif defined(__arc__) || defined(__arm__) || defined(__aarch64__) || defined(__mips__) || \
+     defined(__nds32__) || defined(__hppa__) || defined(__powerpc__) || defined(__i386__) || \
+-    defined(__x86_64__) || defined(__xtensa__) || defined(__alpha__) || defined(__riscv)
++    defined(__x86_64__) || defined(__xtensa__) || defined(__alpha__) || defined(__riscv) || \
++    defined(__loongarch__)
+     /* ctid and newtls are inverted on CONFIG_CLONE_BACKWARDS architectures,
+      * but since both values are 0, there's no harm. */
+     return syscall(__NR_clone, cloneflags, child_stack, ptid, ctid, newtls);
+diff --git a/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java b/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
+index 5792b5b2f5..2f74750fcf 100644
+--- a/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
++++ b/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
+@@ -116,6 +116,7 @@ public class QtNative
+     public static QtThread m_qtThread = new QtThread();
+     private static HashMap<String, Uri> m_cachedUris = new HashMap<String, Uri>();
+     private static ArrayList<String> m_knownDirs = new ArrayList<String>();
++    private static final String NoPermissionErrorMessage = "No permissions to open Uri";
+ 
+     private static final Runnable runPendingCppRunnablesRunnable = new Runnable() {
+         @Override
+@@ -193,11 +194,10 @@ public class QtNative
+                     return iterUri;
+             }
+ 
+-            // Android 6 and earlier could still manage to open the file so we can return the
+-            // parsed uri here
+-            if (Build.VERSION.SDK_INT < 24)
+-                return parsedUri;
+-            return null;
++            // if we only have transient permissions on uri all the above will fail,
++            // but we will be able to read the file anyway, so continue with uri here anyway
++            // and check for SecurityExceptions later
++            return parsedUri;
+         } catch (SecurityException e) {
+             e.printStackTrace();
+             return null;
+@@ -244,7 +244,7 @@ public class QtNative
+         int error = -1;
+ 
+         if (uri == null) {
+-            Log.e(QtTAG, "openFdForContentUrl(): No permissions to open Uri");
++            Log.e(QtTAG, "openFdForContentUrl(): " + NoPermissionErrorMessage);
+             return error;
+         }
+ 
+@@ -254,12 +254,13 @@ public class QtNative
+             return fdDesc.detachFd();
+         } catch (FileNotFoundException e) {
+             e.printStackTrace();
+-            return error;
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "openFdForContentUrl(): Invalid Uri");
+             e.printStackTrace();
+-            return error;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return error;
+     }
+ 
+     public static long getSize(Context context, String contentUrl)
+@@ -270,7 +271,7 @@ public class QtNative
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+ 
+         if (uri == null) {
+-            Log.e(QtTAG, "getSize(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return size;
+         } else if (!m_cachedUris.containsKey(contentUrl)) {
+             m_cachedUris.put(contentUrl, uri);
+@@ -288,12 +289,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "getSize(): Invalid Uri");
+             e.printStackTrace();
+-            return size;
+         }  catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "getSize(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return size;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return size;
+     }
+ 
+     public static boolean checkFileExists(Context context, String contentUrl)
+@@ -303,7 +305,7 @@ public class QtNative
+         if (uri == null)
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+         if (uri == null) {
+-            Log.e(QtTAG, "checkFileExists(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return exists;
+         } else {
+             if (!m_cachedUris.containsKey(contentUrl))
+@@ -321,12 +323,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "checkFileExists(): Invalid Uri");
+             e.printStackTrace();
+-            return exists;
+         } catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "checkFileExists(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return false;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return exists;
+     }
+ 
+     public static boolean checkIfWritable(Context context, String contentUrl)
+@@ -344,7 +347,7 @@ public class QtNative
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+         }
+         if (uri == null) {
+-            Log.e(QtTAG, "isDir(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return isDir;
+         } else {
+             if (!m_cachedUris.containsKey(contentUrl))
+@@ -374,12 +377,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "checkIfDir(): Invalid Uri");
+             e.printStackTrace();
+-            return false;
+         } catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "checkIfDir(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return false;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return false;
+     }
+     public static String[] listContentsFromTreeUri(Context context, String contentUrl)
+     {
+diff --git a/qtbase/src/concurrent/qtconcurrentreducekernel.h b/qtbase/src/concurrent/qtconcurrentreducekernel.h
+index 8f9a938952..a98dedef2e 100644
+--- a/qtbase/src/concurrent/qtconcurrentreducekernel.h
++++ b/qtbase/src/concurrent/qtconcurrentreducekernel.h
+@@ -212,11 +212,13 @@ public:
+ 
+     inline bool shouldThrottle()
+     {
++        std::lock_guard<QMutex> locker(mutex);
+         return (resultsMapSize > (ReduceQueueThrottleLimit * threadCount));
+     }
+ 
+     inline bool shouldStartThread()
+     {
++        std::lock_guard<QMutex> locker(mutex);
+         return (resultsMapSize <= (ReduceQueueStartLimit * threadCount));
+     }
+ };
+diff --git a/qtbase/src/concurrent/qtconcurrentthreadengine.cpp b/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
+index ea6ce3ac42..7f91a2ba68 100644
+--- a/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
++++ b/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
+@@ -176,6 +176,39 @@ void ThreadEngineBase::startSingleThreaded()
+     finish();
+ }
+ 
++void ThreadEngineBase::startBlocking()
++{
++    start();
++    barrier.acquire();
++    startThreads();
++
++    bool throttled = false;
++#ifndef QT_NO_EXCEPTIONS
++    try {
++#endif
++        while (threadFunction() == ThrottleThread) {
++            if (threadThrottleExit()) {
++                throttled = true;
++                break;
++            }
++        }
++#ifndef QT_NO_EXCEPTIONS
++    } catch (QException &e) {
++        handleException(e);
++    } catch (...) {
++        handleException(QUnhandledException());
++    }
++#endif
++
++    if (throttled == false) {
++        barrier.release();
++    }
++
++    barrier.wait();
++    finish();
++    exceptionStore.throwPossibleException();
++}
++
+ void ThreadEngineBase::startThread()
+ {
+     startThreadInternal();
+diff --git a/qtbase/src/concurrent/qtconcurrentthreadengine.h b/qtbase/src/concurrent/qtconcurrentthreadengine.h
+index 7c30cebdbc..a4c8548cc4 100644
+--- a/qtbase/src/concurrent/qtconcurrentthreadengine.h
++++ b/qtbase/src/concurrent/qtconcurrentthreadengine.h
+@@ -91,6 +91,7 @@ public:
+     ThreadEngineBase();
+     virtual ~ThreadEngineBase();
+     void startSingleThreaded();
++    void startBlocking();
+     void startThread();
+     bool isCanceled();
+     void waitForResume();
+@@ -143,6 +144,15 @@ public:
+         return result();
+     }
+ 
++    // Runs the user algorithm using multiple threads.
++    // This function blocks until the algorithm is finished,
++    // and then returns the result.
++    T *startBlocking()
++    {
++        ThreadEngineBase::startBlocking();
++        return result();
++    }
++
+     // Runs the user algorithm using multiple threads.
+     // Does not block, returns a future.
+     QFuture<T> startAsynchronously()
+@@ -223,6 +233,13 @@ class ThreadEngineStarter : public ThreadEngineStarterBase<T>
+ public:
+     ThreadEngineStarter(TypedThreadEngine *eng)
+         : Base(eng) { }
++
++    T startBlocking()
++    {
++        T t = *this->threadEngine->startBlocking();
++        delete this->threadEngine;
++        return t;
++    }
+ };
+ 
+ // Full template specialization where T is void.
+@@ -232,6 +249,12 @@ class ThreadEngineStarter<void> : public ThreadEngineStarterBase<void>
+ public:
+     ThreadEngineStarter(ThreadEngine<void> *_threadEngine)
+         : ThreadEngineStarterBase<void>(_threadEngine) {}
++
++    void startBlocking()
++    {
++        this->threadEngine->startBlocking();
++        delete this->threadEngine;
++    }
+ };
+ 
+ //! [qtconcurrentthreadengine-1]
+diff --git a/qtbase/src/corelib/animation/qvariantanimation.cpp b/qtbase/src/corelib/animation/qvariantanimation.cpp
+index 98b02f0202..eac1524107 100644
+--- a/qtbase/src/corelib/animation/qvariantanimation.cpp
++++ b/qtbase/src/corelib/animation/qvariantanimation.cpp
+@@ -276,7 +276,9 @@ void QVariantAnimationPrivate::setCurrentValueForProgress(const qreal progress)
+ 
+     const qreal startProgress = currentInterval.start.first;
+     const qreal endProgress = currentInterval.end.first;
+-    const qreal localProgress = (progress - startProgress) / (endProgress - startProgress);
++    const qreal localProgress =
++            qIsNull(progress - startProgress) ? 0.0 // avoid 0/0 below
++            /* else */                        : (progress - startProgress) / (endProgress - startProgress);
+ 
+     QVariant ret = q->interpolated(currentInterval.start.second,
+                                    currentInterval.end.second,
+diff --git a/qtbase/src/corelib/global/qnamespace.h b/qtbase/src/corelib/global/qnamespace.h
+index ad4150b317..bf19b1627b 100644
+--- a/qtbase/src/corelib/global/qnamespace.h
++++ b/qtbase/src/corelib/global/qnamespace.h
+@@ -1864,7 +1864,7 @@ public:
+     QT_Q_ENUM(TimerType)
+     QT_Q_ENUM(ScrollPhase)
+     QT_Q_ENUM(MouseEventSource)
+-    QT_Q_FLAG(MouseEventFlag)
++    QT_Q_FLAG(MouseEventFlags)
+     QT_Q_ENUM(ChecksumType)
+     QT_Q_ENUM(HighDpiScaleFactorRoundingPolicy)
+     QT_Q_ENUM(TabFocusBehavior)
+diff --git a/qtbase/src/corelib/global/qrandom.cpp b/qtbase/src/corelib/global/qrandom.cpp
+index 10672c1f92..25f87c7e6a 100644
+--- a/qtbase/src/corelib/global/qrandom.cpp
++++ b/qtbase/src/corelib/global/qrandom.cpp
+@@ -383,7 +383,6 @@ struct QRandomGenerator::SystemAndGlobalGenerators
+ 
+         constexpr SystemAndGlobalGenerators g = {};
+         Q_UNUSED(g);
+-        Q_STATIC_ASSERT(std::is_literal_type<SystemAndGlobalGenerators>::value);
+ #endif
+     }
+ 
+diff --git a/qtbase/src/corelib/io/qbuffer.cpp b/qtbase/src/corelib/io/qbuffer.cpp
+index 595fcd2724..032c0ddd4b 100644
+--- a/qtbase/src/corelib/io/qbuffer.cpp
++++ b/qtbase/src/corelib/io/qbuffer.cpp
+@@ -41,6 +41,8 @@
+ #include <QtCore/qmetaobject.h>
+ #include "private/qiodevice_p.h"
+ 
++#include <limits>
++
+ QT_BEGIN_NAMESPACE
+ 
+ /** QBufferPrivate **/
+@@ -366,7 +368,9 @@ qint64 QBuffer::size() const
+ bool QBuffer::seek(qint64 pos)
+ {
+     Q_D(QBuffer);
+-    if (pos > d->buf->size() && isWritable()) {
++    const auto oldBufSize = d->buf->size();
++    constexpr qint64 MaxSeekPos = (std::numeric_limits<decltype(oldBufSize)>::max)();
++    if (pos <= MaxSeekPos && pos > oldBufSize && isWritable()) {
+         if (seek(d->buf->size())) {
+             const qint64 gapSize = pos - d->buf->size();
+             if (write(QByteArray(gapSize, 0)) != gapSize) {
+@@ -377,7 +381,7 @@ bool QBuffer::seek(qint64 pos)
+             return false;
+         }
+     } else if (pos > d->buf->size() || pos < 0) {
+-        qWarning("QBuffer::seek: Invalid pos: %d", int(pos));
++        qWarning("QBuffer::seek: Invalid pos: %lld", pos);
+         return false;
+     }
+     return QIODevice::seek(pos);
+diff --git a/qtbase/src/corelib/io/qfilesystemengine_win.cpp b/qtbase/src/corelib/io/qfilesystemengine_win.cpp
+index 81d3a71986..c86ed1f9b0 100644
+--- a/qtbase/src/corelib/io/qfilesystemengine_win.cpp
++++ b/qtbase/src/corelib/io/qfilesystemengine_win.cpp
+@@ -664,14 +664,14 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry)
+     return QFileSystemEntry(ret, QFileSystemEntry::FromInternalPath());
+ }
+ 
+-#if defined(Q_CC_MINGW) && WINVER < 0x0602 //  Windows 8 onwards
++#if defined(Q_CC_MINGW) && WINVER < 0x0602 && _WIN32_WINNT < _WIN32_WINNT_WIN8 //  Windows 8 onwards
+ 
+ typedef struct _FILE_ID_INFO {
+     ULONGLONG VolumeSerialNumber;
+     FILE_ID_128 FileId;
+ } FILE_ID_INFO, *PFILE_ID_INFO;
+ 
+-#endif // if defined (Q_CC_MINGW) && WINVER < 0x0602
++#endif // if defined(Q_CC_MINGW) && WINVER < 0x0602 && _WIN32_WINNT < _WIN32_WINNT_WIN8
+ 
+ // File ID for Windows up to version 7 and FAT32 drives
+ static inline QByteArray fileId(HANDLE handle)
+diff --git a/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp b/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
+index 94d9d06bcb..27e0b13b0b 100644
+--- a/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
++++ b/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
+@@ -366,7 +366,9 @@ void QInotifyFileSystemWatcherEngine::readFromInotify()
+     // qDebug("QInotifyFileSystemWatcherEngine::readFromInotify");
+ 
+     int buffSize = 0;
+-    ioctl(inotifyFd, FIONREAD, (char *) &buffSize);
++    if (ioctl(inotifyFd, FIONREAD, (char *) &buffSize) == -1 || buffSize == 0)
++        return;
++
+     QVarLengthArray<char, 4096> buffer(buffSize);
+     buffSize = read(inotifyFd, buffer.data(), buffSize);
+     char *at = buffer.data();
+diff --git a/qtbase/src/corelib/io/qlockfile_win.cpp b/qtbase/src/corelib/io/qlockfile_win.cpp
+index 277f8d4230..38ecef5550 100644
+--- a/qtbase/src/corelib/io/qlockfile_win.cpp
++++ b/qtbase/src/corelib/io/qlockfile_win.cpp
+@@ -48,6 +48,8 @@
+ #include "QtCore/qdebug.h"
+ #include "QtCore/qthread.h"
+ 
++#include "private/qsystemlibrary_p.h"
++
+ QT_BEGIN_NAMESPACE
+ 
+ static inline bool fileExists(const wchar_t *fileName)
+@@ -150,7 +152,7 @@ QString QLockFilePrivate::processNameByPid(qint64 pid)
+ #if !defined(Q_OS_WINRT)
+     typedef DWORD (WINAPI *GetModuleFileNameExFunc)(HANDLE, HMODULE, LPTSTR, DWORD);
+ 
+-    HMODULE hPsapi = LoadLibraryA("psapi");
++    HMODULE hPsapi = QSystemLibrary::load(L"psapi");
+     if (!hPsapi)
+         return QString();
+     GetModuleFileNameExFunc qGetModuleFileNameEx = reinterpret_cast<GetModuleFileNameExFunc>(
+diff --git a/qtbase/src/corelib/io/qprocess_unix.cpp b/qtbase/src/corelib/io/qprocess_unix.cpp
+index 50390e57f5..15c8f30745 100644
+--- a/qtbase/src/corelib/io/qprocess_unix.cpp
++++ b/qtbase/src/corelib/io/qprocess_unix.cpp
+@@ -1,7 +1,7 @@
+ /****************************************************************************
+ **
+ ** Copyright (C) 2016 The Qt Company Ltd.
+-** Copyright (C) 2016 Intel Corporation.
++** Copyright (C) 2022 Intel Corporation.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtCore module of the Qt Toolkit.
+@@ -422,14 +422,15 @@ void QProcessPrivate::startProcess()
+     // Add the program name to the argument list.
+     argv[0] = nullptr;
+     if (!program.contains(QLatin1Char('/'))) {
++        // findExecutable() returns its argument if it's an absolute path,
++        // otherwise it searches $PATH; returns empty if not found (we handle
++        // that case much later)
+         const QString &exeFilePath = QStandardPaths::findExecutable(program);
+-        if (!exeFilePath.isEmpty()) {
+-            const QByteArray &tmp = QFile::encodeName(exeFilePath);
+-            argv[0] = ::strdup(tmp.constData());
+-        }
+-    }
+-    if (!argv[0])
++        const QByteArray &tmp = QFile::encodeName(exeFilePath);
++        argv[0] = ::strdup(tmp.constData());
++    } else {
+         argv[0] = ::strdup(encodedProgramName.constData());
++    }
+ 
+     // Add every argument to the list
+     for (int i = 0; i < arguments.count(); ++i)
+@@ -983,15 +984,16 @@ bool QProcessPrivate::startDetached(qint64 *pid)
+                 envp = _q_dupEnvironment(environment.d.constData()->vars, &envc);
+             }
+ 
+-            QByteArray tmp;
+             if (!program.contains(QLatin1Char('/'))) {
++                // findExecutable() returns its argument if it's an absolute path,
++                // otherwise it searches $PATH; returns empty if not found (we handle
++                // that case much later)
+                 const QString &exeFilePath = QStandardPaths::findExecutable(program);
+-                if (!exeFilePath.isEmpty())
+-                    tmp = QFile::encodeName(exeFilePath);
++                const QByteArray &tmp = QFile::encodeName(exeFilePath);
++                argv[0] = ::strdup(tmp.constData());
++            } else {
++                argv[0] = ::strdup(QFile::encodeName(program));
+             }
+-            if (tmp.isEmpty())
+-                tmp = QFile::encodeName(program);
+-            argv[0] = tmp.data();
+ 
+             if (envp)
+                 qt_safe_execve(argv[0], argv, envp);
+diff --git a/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp b/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
+index 3a79c502af..997a634e76 100644
+--- a/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
++++ b/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
+@@ -3196,9 +3196,8 @@ bool QAbstractItemModel::beginMoveColumns(const QModelIndex &sourceParent, int s
+     destinationChange.needsAdjust = destinationParent.isValid() && destinationParent.row() >= sourceLast && destinationParent.parent() == sourceParent;
+     d->changes.push(destinationChange);
+ 
+-    d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Horizontal);
+-
+     emit columnsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, QPrivateSignal());
++    d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Horizontal);
+     return true;
+ }
+ 
+@@ -3231,7 +3230,6 @@ void QAbstractItemModel::endMoveColumns()
+       adjustedSource = createIndex(adjustedSource.row(), adjustedSource.column() + numMoved, adjustedSource.internalPointer());
+ 
+     d->itemsMoved(adjustedSource, removeChange.first, removeChange.last, adjustedDestination, insertChange.first, Qt::Horizontal);
+-
+     emit columnsMoved(adjustedSource, removeChange.first, removeChange.last, adjustedDestination, insertChange.first, QPrivateSignal());
+ }
+ 
+diff --git a/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+index dc6379d9fb..c5e287ee84 100644
+--- a/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
++++ b/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+@@ -939,8 +939,9 @@ void QSortFilterProxyModelPrivate::insert_source_items(
+                 q->beginInsertColumns(proxy_parent, proxy_start, proxy_end);
+         }
+ 
+-        for (int i = 0; i < source_items.size(); ++i)
+-            proxy_to_source.insert(proxy_start + i, source_items.at(i));
++        // TODO: use the range QList::insert() overload once it is implemented (QTBUG-58633).
++        proxy_to_source.insert(proxy_start, source_items.size(), 0);
++        std::copy(source_items.cbegin(), source_items.cend(), proxy_to_source.begin() + proxy_start);
+ 
+         build_source_to_proxy_mapping(proxy_to_source, source_to_proxy);
+ 
+@@ -3123,8 +3124,9 @@ bool QSortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex &
+ 
+     if (d->filter_data.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();
+@@ -3133,9 +3135,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.hasMatch(key);
+ }
+diff --git a/qtbase/src/corelib/kernel/qcoreapplication.cpp b/qtbase/src/corelib/kernel/qcoreapplication.cpp
+index ca2864df83..132b2eae52 100644
+--- a/qtbase/src/corelib/kernel/qcoreapplication.cpp
++++ b/qtbase/src/corelib/kernel/qcoreapplication.cpp
+@@ -1157,7 +1157,7 @@ static bool doNotify(QObject *receiver, QEvent *event)
+ bool QCoreApplicationPrivate::sendThroughApplicationEventFilters(QObject *receiver, QEvent *event)
+ {
+     // We can't access the application event filters outside of the main thread (race conditions)
+-    Q_ASSERT(receiver->d_func()->threadData.loadRelaxed()->thread.loadAcquire() == mainThread());
++    Q_ASSERT(receiver->d_func()->threadData.loadAcquire()->thread.loadRelaxed() == mainThread());
+ 
+     if (extraData) {
+         // application event filters are only called for objects in the GUI thread
+diff --git a/qtbase/src/corelib/kernel/qobject.cpp b/qtbase/src/corelib/kernel/qobject.cpp
+index 1eb79138d9..36cd780ee1 100644
+--- a/qtbase/src/corelib/kernel/qobject.cpp
++++ b/qtbase/src/corelib/kernel/qobject.cpp
+@@ -1010,7 +1010,7 @@ QObject::~QObject()
+         emit destroyed(this);
+     }
+ 
+-    if (d->declarativeData) {
++    if (!d->isDeletingChildren && d->declarativeData) {
+         if (static_cast<QAbstractDeclarativeDataImpl*>(d->declarativeData)->ownedByQml1) {
+             if (QAbstractDeclarativeData::destroyed_qml1)
+                 QAbstractDeclarativeData::destroyed_qml1(d->declarativeData, this);
+@@ -1580,7 +1580,7 @@ void QObject::moveToThread(QThread *targetThread)
+ 
+     QThreadData *currentData = QThreadData::current();
+     QThreadData *targetData = targetThread ? QThreadData::get2(targetThread) : nullptr;
+-    QThreadData *thisThreadData = d->threadData.loadRelaxed();
++    QThreadData *thisThreadData = d->threadData.loadAcquire();
+     if (!thisThreadData->thread.loadAcquire() && currentData == targetData) {
+         // one exception to the rule: we allow moving objects with no thread affinity to the current thread
+         currentData = d->threadData;
+@@ -2620,7 +2620,7 @@ int QObject::receivers(const char *signal) const
+         if (!d->isSignalConnected(signal_index))
+             return receivers;
+ 
+-        if (d->declarativeData && QAbstractDeclarativeData::receivers) {
++        if (!d->isDeletingChildren && d->declarativeData && QAbstractDeclarativeData::receivers) {
+             receivers += QAbstractDeclarativeData::receivers(d->declarativeData, this,
+                                                              signal_index);
+         }
+diff --git a/qtbase/src/corelib/kernel/qobject_p.h b/qtbase/src/corelib/kernel/qobject_p.h
+index 0b827a52ca..13ffb88999 100644
+--- a/qtbase/src/corelib/kernel/qobject_p.h
++++ b/qtbase/src/corelib/kernel/qobject_p.h
+@@ -444,7 +444,7 @@ inline void QObjectPrivate::checkForIncompatibleLibraryVersion(int version) cons
+ 
+ inline bool QObjectPrivate::isDeclarativeSignalConnected(uint signal_index) const
+ {
+-    return declarativeData && QAbstractDeclarativeData::isSignalConnected
++    return !isDeletingChildren && declarativeData && QAbstractDeclarativeData::isSignalConnected
+             && QAbstractDeclarativeData::isSignalConnected(declarativeData, q_func(), signal_index);
+ }
+ 
+diff --git a/qtbase/src/corelib/kernel/qtranslator.cpp b/qtbase/src/corelib/kernel/qtranslator.cpp
+index 2812ffb7ea..bc0177c5ec 100644
+--- a/qtbase/src/corelib/kernel/qtranslator.cpp
++++ b/qtbase/src/corelib/kernel/qtranslator.cpp
+@@ -902,7 +902,7 @@ static QString getMessage(const uchar *m, const uchar *end, const char *context,
+             goto end;
+         case Tag_Translation: {
+             int len = read32(m);
+-            if (len % 1)
++            if (len & 1)
+                 return QString();
+             m += 4;
+             if (!numerus--) {
+diff --git a/qtbase/src/corelib/mimetypes/qmimedatabase.cpp b/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
+index 9de22cef33..ff868a3268 100644
+--- a/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
+@@ -389,20 +389,23 @@ QMimeType QMimeDatabasePrivate::mimeTypeForFileNameAndData(const QString &fileNa
+         // Disambiguate conflicting extensions (if magic matching found something)
+         if (candidateByData.isValid() && magicAccuracy > 0) {
+             const QString sniffedMime = candidateByData.name();
+-            // If the sniffedMime matches a glob match, use it
++            // If the sniffedMime matches a highest-weight glob match, use it
+             if (candidatesByName.m_matchingMimeTypes.contains(sniffedMime)) {
+                 *accuracyPtr = 100;
+                 return candidateByData;
+             }
+-            for (const QString &m : qAsConst(candidatesByName.m_matchingMimeTypes)) {
++            for (const QString &m : qAsConst(candidatesByName.m_allMatchingMimeTypes)) {
+                 if (inherits(m, sniffedMime)) {
+                     // We have magic + pattern pointing to this, so it's a pretty good match
+                     *accuracyPtr = 100;
+                     return mimeTypeForName(m);
+                 }
+             }
+-            *accuracyPtr = magicAccuracy;
+-            return candidateByData;
++            if (candidatesByName.m_allMatchingMimeTypes.isEmpty()) {
++                // No glob, use magic
++                *accuracyPtr = magicAccuracy;
++                return candidateByData;
++            }
+         }
+     }
+ 
+diff --git a/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp b/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
+index a81112d227..fa8f4c545d 100644
+--- a/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
+@@ -83,7 +83,10 @@ void QMimeGlobMatchResult::addMatch(const QString &mimeType, int weight, const Q
+     }
+     if (!m_matchingMimeTypes.contains(mimeType)) {
+         m_matchingMimeTypes.append(mimeType);
+-        m_allMatchingMimeTypes.append(mimeType);
++        if (replace)
++            m_allMatchingMimeTypes.prepend(mimeType); // highest-weight first
++        else
++            m_allMatchingMimeTypes.append(mimeType);
+         m_knownSuffixLength = knownSuffixLength;
+     }
+ }
+@@ -94,7 +97,7 @@ QMimeGlobPattern::PatternType QMimeGlobPattern::detectPatternType(const QString
+     if (!patternLength)
+         return OtherPattern;
+ 
+-    const bool starCount = pattern.count(QLatin1Char('*')) == 1;
++    const int starCount = pattern.count(QLatin1Char('*'));
+     const bool hasSquareBracket = pattern.indexOf(QLatin1Char('[')) != -1;
+     const bool hasQuestionMark = pattern.indexOf(QLatin1Char('?')) != -1;
+ 
+@@ -106,10 +109,10 @@ QMimeGlobPattern::PatternType QMimeGlobPattern::detectPatternType(const QString
+             // Patterns like "README*" (well this is currently the only one like that...)
+             if (pattern.at(patternLength - 1) == QLatin1Char('*'))
+                 return PrefixPattern;
+-        }
+-        // Names without any wildcards like "README"
+-        if (starCount == 0)
++        } else if (starCount == 0) {
++            // Names without any wildcards like "README"
+             return LiteralPattern;
++        }
+     }
+ 
+     if (pattern == QLatin1String("[0-9][0-9][0-9].vdr"))
+diff --git a/qtbase/src/corelib/mimetypes/qmimeprovider.cpp b/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
+index 258dddf8cb..4642d0f2d0 100644
+--- a/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
+@@ -244,15 +244,18 @@ void QMimeBinaryProvider::addFileNameMatches(const QString &fileName, QMimeGlobM
+     const QString lowerFileName = fileName.toLower();
+     // Check literals (e.g. "Makefile")
+     matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosLiteralListOffset), fileName);
+-    // Check complex globs (e.g. "callgrind.out[0-9]*")
+-    matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosGlobListOffset), fileName);
+     // Check the very common *.txt cases with the suffix tree
+-    const int reverseSuffixTreeOffset = m_cacheFile->getUint32(PosReverseSuffixTreeOffset);
+-    const int numRoots = m_cacheFile->getUint32(reverseSuffixTreeOffset);
+-    const int firstRootOffset = m_cacheFile->getUint32(reverseSuffixTreeOffset + 4);
+-    matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, lowerFileName, lowerFileName.length() - 1, false);
++    if (result.m_matchingMimeTypes.isEmpty()) {
++        const int reverseSuffixTreeOffset = m_cacheFile->getUint32(PosReverseSuffixTreeOffset);
++        const int numRoots = m_cacheFile->getUint32(reverseSuffixTreeOffset);
++        const int firstRootOffset = m_cacheFile->getUint32(reverseSuffixTreeOffset + 4);
++        matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, lowerFileName, lowerFileName.length() - 1, false);
++        if (result.m_matchingMimeTypes.isEmpty())
++            matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, fileName, fileName.length() - 1, true);
++    }
++    // Check complex globs (e.g. "callgrind.out[0-9]*" or "README*")
+     if (result.m_matchingMimeTypes.isEmpty())
+-        matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, fileName, fileName.length() - 1, true);
++        matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosGlobListOffset), fileName);
+ }
+ 
+ void QMimeBinaryProvider::matchGlobList(QMimeGlobMatchResult &result, CacheFile *cacheFile, int off, const QString &fileName)
+diff --git a/qtbase/src/corelib/serialization/qjsonparser.cpp b/qtbase/src/corelib/serialization/qjsonparser.cpp
+index 17e6f111ab..2e40b6c8fb 100644
+--- a/qtbase/src/corelib/serialization/qjsonparser.cpp
++++ b/qtbase/src/corelib/serialization/qjsonparser.cpp
+@@ -379,10 +379,30 @@ error:
+     return QCborValue();
+ }
+ 
++// We need to retain the _last_ value for any duplicate keys and we need to deref containers.
++// Therefore the manual implementation of std::unique().
++template<typename Iterator, typename Compare, typename Assign>
++static Iterator customAssigningUniqueLast(Iterator first, Iterator last,
++                                          Compare compare, Assign assign)
++{
++    first = std::adjacent_find(first, last, compare);
++    if (first == last)
++        return last;
++
++    Iterator result = first;
++    while (++first != last) {
++        if (!compare(*result, *first))
++            ++result;
++        if (result != first)
++            assign(*result, *first);
++    }
++
++    return ++result;
++}
++
+ static void sortContainer(QCborContainerPrivate *container)
+ {
+     using Forward = QJsonPrivate::KeyIterator;
+-    using Reverse = std::reverse_iterator<Forward>;
+     using Value = Forward::value_type;
+ 
+     auto compare = [container](const Value &a, const Value &b)
+@@ -420,17 +440,31 @@ static void sortContainer(QCborContainerPrivate *container)
+         }
+     };
+ 
+-    std::sort(Forward(container->elements.begin()), Forward(container->elements.end()),
+-              [&compare](const Value &a, const Value &b) { return compare(a, b) < 0; });
++    // The elements' containers are owned by the outer container, not by the elements themselves.
++    auto move = [](Forward::reference target, Forward::reference source)
++    {
++        QtCbor::Element &targetValue = target.value();
++
++        // If the target has a container, deref it before overwriting, so that we don't leak.
++        if (targetValue.flags & QtCbor::Element::IsContainer)
++            targetValue.container->deref();
++
++        // Do not move, so that we can clear the value afterwards.
++        target = source;
++
++        // Clear the source value, so that we don't store the same container twice.
++        source.value() = QtCbor::Element();
++    };
++
++    std::stable_sort(
++                Forward(container->elements.begin()), Forward(container->elements.end()),
++                [&compare](const Value &a, const Value &b) { return compare(a, b) < 0; });
+ 
+-    // We need to retain the _last_ value for any duplicate keys. Therefore the reverse dance here.
+-    auto it = std::unique(Reverse(container->elements.end()), Reverse(container->elements.begin()),
+-                          [&compare](const Value &a, const Value &b) {
+-        return compare(a, b) == 0;
+-    }).base().elementsIterator();
++    Forward result = customAssigningUniqueLast(
++                Forward(container->elements.begin()),  Forward(container->elements.end()),
++                [&compare](const Value &a, const Value &b) { return compare(a, b) == 0; }, move);
+ 
+-    // The erase from beginning is expensive but hopefully rare.
+-    container->elements.erase(container->elements.begin(), it);
++    container->elements.erase(result.elementsIterator(), container->elements.end());
+ }
+ 
+ 
+diff --git a/qtbase/src/corelib/serialization/qxmlstream.cpp b/qtbase/src/corelib/serialization/qxmlstream.cpp
+index b2f846544d..7cd457ba3a 100644
+--- a/qtbase/src/corelib/serialization/qxmlstream.cpp
++++ b/qtbase/src/corelib/serialization/qxmlstream.cpp
+@@ -980,7 +980,7 @@ inline uint QXmlStreamReaderPrivate::peekChar()
+ bool QXmlStreamReaderPrivate::scanUntil(const char *str, short tokenToInject)
+ {
+     int pos = textBuffer.size();
+-    int oldLineNumber = lineNumber;
++    const auto oldLineNumber = lineNumber;
+ 
+     uint c;
+     while ((c = getChar()) != StreamEOF) {
+diff --git a/qtbase/src/corelib/text/qstring.cpp b/qtbase/src/corelib/text/qstring.cpp
+index 3e88ab4859..8deeae47bb 100644
+--- a/qtbase/src/corelib/text/qstring.cpp
++++ b/qtbase/src/corelib/text/qstring.cpp
+@@ -12312,7 +12312,7 @@ static qsizetype qLastIndexOf(Haystack haystack0, qsizetype from,
+     const auto needle = needle0.data();
+     const auto *end = haystack;
+     haystack += from;
+-    const std::size_t sl_minus_1 = sl - 1;
++    const std::size_t sl_minus_1 = sl ? sl - 1 : 0;
+     const auto *n = needle + sl_minus_1;
+     const auto *h = haystack + sl_minus_1;
+     std::size_t hashNeedle = 0, hashHaystack = 0;
+diff --git a/qtbase/src/corelib/text/qstringiterator_p.h b/qtbase/src/corelib/text/qstringiterator_p.h
+index 219589b6e4..1d0c66cc78 100644
+--- a/qtbase/src/corelib/text/qstringiterator_p.h
++++ b/qtbase/src/corelib/text/qstringiterator_p.h
+@@ -61,6 +61,8 @@ class QStringIterator
+ {
+     QString::const_iterator i, pos, e;
+     Q_STATIC_ASSERT((std::is_same<QString::const_iterator, const QChar *>::value));
++    static bool less(const QChar *lhs, const QChar *rhs) noexcept
++    { return std::less<QString::const_iterator>{}(lhs, rhs); }
+ public:
+     explicit QStringIterator(QStringView string, qsizetype idx = 0)
+         : i(string.begin()),
+@@ -95,7 +97,8 @@ public:
+ 
+     inline void setPosition(QString::const_iterator position)
+     {
+-        Q_ASSERT_X(i <= position && position <= e, Q_FUNC_INFO, "position out of bounds");
++        Q_ASSERT_X(!less(position, i) && !less(e, position),
++                   Q_FUNC_INFO, "position out of bounds");
+         pos = position;
+     }
+ 
+@@ -103,7 +106,7 @@ public:
+ 
+     inline bool hasNext() const
+     {
+-        return pos < e;
++        return less(pos, e);
+     }
+ 
+     inline void advance()
+@@ -120,16 +123,20 @@ public:
+     {
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+-        if (Q_UNLIKELY((pos++)->isHighSurrogate()))
++        if (Q_UNLIKELY((pos++)->isHighSurrogate())) {
++            Q_ASSERT(hasNext() && pos->isLowSurrogate());
+             ++pos;
++        }
+     }
+ 
+     inline uint peekNextUnchecked() const
+     {
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+-        if (Q_UNLIKELY(pos->isHighSurrogate()))
++        if (Q_UNLIKELY(pos->isHighSurrogate())) {
++            Q_ASSERT(less(pos + 1, e) && pos[1].isLowSurrogate());
+             return QChar::surrogateToUcs4(pos[0], pos[1]);
++        }
+ 
+         return pos->unicode();
+     }
+@@ -155,8 +162,10 @@ public:
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+         const QChar cur = *pos++;
+-        if (Q_UNLIKELY(cur.isHighSurrogate()))
++        if (Q_UNLIKELY(cur.isHighSurrogate())) {
++            Q_ASSERT(hasNext() && pos->isLowSurrogate());
+             return QChar::surrogateToUcs4(cur, *pos++);
++        }
+         return cur.unicode();
+     }
+ 
+@@ -166,7 +175,7 @@ public:
+ 
+         const QChar uc = *pos++;
+         if (Q_UNLIKELY(uc.isSurrogate())) {
+-            if (Q_LIKELY(uc.isHighSurrogate() && pos < e && pos->isLowSurrogate()))
++            if (Q_LIKELY(uc.isHighSurrogate() && hasNext() && pos->isLowSurrogate()))
+                 return QChar::surrogateToUcs4(uc, *pos++);
+             return invalidAs;
+         }
+@@ -178,7 +187,7 @@ public:
+ 
+     inline bool hasPrevious() const
+     {
+-        return pos > i;
++        return less(i, pos);
+     }
+ 
+     inline void recede()
+@@ -196,16 +205,20 @@ public:
+     {
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+-        if (Q_UNLIKELY((--pos)->isLowSurrogate()))
++        if (Q_UNLIKELY((--pos)->isLowSurrogate())) {
++            Q_ASSERT(hasPrevious() && pos[-1].isHighSurrogate());
+             --pos;
++        }
+     }
+ 
+     inline uint peekPreviousUnchecked() const
+     {
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+-        if (Q_UNLIKELY(pos[-1].isLowSurrogate()))
++        if (Q_UNLIKELY(pos[-1].isLowSurrogate())) {
++            Q_ASSERT(less(i + 1, pos) && pos[-2].isHighSurrogate());
+             return QChar::surrogateToUcs4(pos[-2], pos[-1]);
++        }
+         return pos[-1].unicode();
+     }
+ 
+@@ -230,8 +243,10 @@ public:
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+         const QChar cur = *--pos;
+-        if (Q_UNLIKELY(cur.isLowSurrogate()))
++        if (Q_UNLIKELY(cur.isLowSurrogate())) {
++            Q_ASSERT(hasPrevious() && pos[-1].isHighSurrogate());
+             return QChar::surrogateToUcs4(*--pos, cur);
++        }
+         return cur.unicode();
+     }
+ 
+@@ -241,7 +256,7 @@ public:
+ 
+         const QChar uc = *--pos;
+         if (Q_UNLIKELY(uc.isSurrogate())) {
+-            if (Q_LIKELY(uc.isLowSurrogate() && pos > i && pos[-1].isHighSurrogate()))
++            if (Q_LIKELY(uc.isLowSurrogate() && hasPrevious() && pos[-1].isHighSurrogate()))
+                 return QChar::surrogateToUcs4(*--pos, uc);
+             return invalidAs;
+         }
+diff --git a/qtbase/src/corelib/thread/qfutex_p.h b/qtbase/src/corelib/thread/qfutex_p.h
+index f287b752d7..e294537787 100644
+--- a/qtbase/src/corelib/thread/qfutex_p.h
++++ b/qtbase/src/corelib/thread/qfutex_p.h
+@@ -52,6 +52,7 @@
+ //
+ 
+ #include <qglobal.h>
++#include <QtCore/qtsan_impl.h>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -106,16 +107,13 @@ namespace QtLinuxFutex {
+     inline int _q_futex(int *addr, int op, int val, quintptr val2 = 0,
+                         int *addr2 = nullptr, int val3 = 0) noexcept
+     {
+-        // A futex call ensures total ordering on the futex words
+-        // (in either success or failure of the call). Instruct TSAN accordingly,
+-        // as TSAN does not understand the futex(2) syscall.
+-        _q_tsan_release(addr, addr2);
++        QtTsan::futexRelease(addr, addr2);
+ 
+         // we use __NR_futex because some libcs (like Android's bionic) don't
+         // provide SYS_futex etc.
+         int result = syscall(__NR_futex, addr, op | FUTEX_PRIVATE_FLAG, val, val2, addr2, val3);
+ 
+-        _q_tsan_acquire(addr, addr2);
++        QtTsan::futexAcquire(addr, addr2);
+ 
+         return result;
+     }
+diff --git a/qtbase/src/corelib/thread/qmutex.cpp b/qtbase/src/corelib/thread/qmutex.cpp
+index 310d1cb14f..7097122d8e 100644
+--- a/qtbase/src/corelib/thread/qmutex.cpp
++++ b/qtbase/src/corelib/thread/qmutex.cpp
+@@ -152,6 +152,7 @@ public:
+ 
+ /*!
+     \enum QMutex::RecursionMode
++    \obsolete Use QRecursiveMutex to create a recursive mutex.
+ 
+     \value Recursive  In this mode, a thread can lock the same mutex
+                       multiple times and the mutex won't be unlocked
+@@ -173,6 +174,7 @@ public:
+ 
+ /*!
+     Constructs a new mutex. The mutex is created in an unlocked state.
++    \obsolete Use QRecursiveMutex to create a recursive mutex.
+ 
+     If \a mode is QMutex::Recursive, a thread can lock the same mutex
+     multiple times and the mutex won't be unlocked until a
+@@ -197,7 +199,7 @@ QMutex::QMutex(RecursionMode mode)
+ QMutex::~QMutex()
+ {
+     QMutexData *d = d_ptr.loadRelaxed();
+-    if (isRecursive()) {
++    if (QBasicMutex::isRecursive()) {
+         delete static_cast<QRecursiveMutexPrivate *>(d);
+     } else if (d) {
+ #ifndef QT_LINUX_FUTEX
+diff --git a/qtbase/src/corelib/thread/qmutex.h b/qtbase/src/corelib/thread/qmutex.h
+index 73c9e00663..1bae573a03 100644
+--- a/qtbase/src/corelib/thread/qmutex.h
++++ b/qtbase/src/corelib/thread/qmutex.h
+@@ -42,6 +42,7 @@
+ 
+ #include <QtCore/qglobal.h>
+ #include <QtCore/qatomic.h>
++#include <QtCore/qtsan_impl.h>
+ #include <new>
+ 
+ #if __has_include(<chrono>)
+@@ -77,19 +78,37 @@ public:
+ 
+     // BasicLockable concept
+     inline void lock() QT_MUTEX_LOCK_NOEXCEPT {
++        QtTsan::mutexPreLock(this, 0u);
++
+         if (!fastTryLock())
+             lockInternal();
++
++        QtTsan::mutexPostLock(this, 0u, 0);
+     }
+ 
+     // BasicLockable concept
+     inline void unlock() noexcept {
+         Q_ASSERT(d_ptr.loadRelaxed()); //mutex must be locked
++
++        QtTsan::mutexPreUnlock(this, 0u);
++
+         if (!fastTryUnlock())
+             unlockInternal();
++
++        QtTsan::mutexPostUnlock(this, 0u);
+     }
+ 
+     bool tryLock() noexcept {
+-        return fastTryLock();
++        unsigned tsanFlags = QtTsan::TryLock;
++        QtTsan::mutexPreLock(this, tsanFlags);
++
++        const bool success = fastTryLock();
++
++        if (!success)
++            tsanFlags |= QtTsan::TryLockFailed;
++        QtTsan::mutexPostLock(this, tsanFlags, 0);
++
++        return success;
+     }
+ 
+     // Lockable concept
+@@ -134,8 +153,16 @@ public:
+ #else
+     QMutex() { d_ptr.storeRelaxed(nullptr); }
+ #endif
++#if QT_DEPRECATED_SINCE(5,15)
+     enum RecursionMode { NonRecursive, Recursive };
++    QT_DEPRECATED_VERSION_X(5, 15, "Use QRecursiveMutex instead of a recursive QMutex")
+     explicit QMutex(RecursionMode mode);
++
++    QT_DEPRECATED_VERSION_X(5, 15, "Use QRecursiveMutex instead of a recursive QMutex")
++    bool isRecursive() const noexcept
++    { return QBasicMutex::isRecursive(); }
++#endif
++
+     ~QMutex();
+ 
+     // BasicLockable concept
+@@ -166,9 +193,6 @@ public:
+     }
+ #endif
+ 
+-    bool isRecursive() const noexcept
+-    { return QBasicMutex::isRecursive(); }
+-
+ private:
+     Q_DISABLE_COPY(QMutex)
+     friend class QMutexLocker;
+diff --git a/qtbase/src/corelib/thread/qreadwritelock.cpp b/qtbase/src/corelib/thread/qreadwritelock.cpp
+index 8c28507d5a..9dd8503116 100644
+--- a/qtbase/src/corelib/thread/qreadwritelock.cpp
++++ b/qtbase/src/corelib/thread/qreadwritelock.cpp
+@@ -155,7 +155,7 @@ QReadWriteLock::QReadWriteLock(RecursionMode recursionMode)
+ */
+ QReadWriteLock::~QReadWriteLock()
+ {
+-    auto d = d_ptr.loadRelaxed();
++    auto d = d_ptr.loadAcquire();
+     if (isUncontendedLocked(d)) {
+         qWarning("QReadWriteLock: destroying locked QReadWriteLock");
+         return;
+@@ -445,7 +445,7 @@ void QReadWriteLock::unlock()
+ /*! \internal  Helper for QWaitCondition::wait */
+ QReadWriteLock::StateForWaitCondition QReadWriteLock::stateForWaitCondition() const
+ {
+-    QReadWriteLockPrivate *d = d_ptr.loadRelaxed();
++    QReadWriteLockPrivate *d = d_ptr.loadAcquire();
+     switch (quintptr(d) & StateMask) {
+     case StateLockedForRead: return LockedForRead;
+     case StateLockedForWrite: return LockedForWrite;
+@@ -453,6 +453,7 @@ QReadWriteLock::StateForWaitCondition QReadWriteLock::stateForWaitCondition() co
+ 
+     if (!d)
+         return Unlocked;
++    const auto lock = qt_scoped_lock(d->mutex);
+     if (d->writerCount > 1)
+         return RecursivelyLocked;
+     else if (d->writerCount == 1)
+diff --git a/qtbase/src/corelib/thread/qsemaphore.cpp b/qtbase/src/corelib/thread/qsemaphore.cpp
+index 1d01fc1b28..3ecdee3747 100644
+--- a/qtbase/src/corelib/thread/qsemaphore.cpp
++++ b/qtbase/src/corelib/thread/qsemaphore.cpp
+@@ -354,7 +354,12 @@ void QSemaphore::release(int n)
+         quintptr nn = unsigned(n);
+         if (futexHasWaiterCount)
+             nn |= quint64(nn) << 32;    // token count replicated in high word
+-        quintptr prevValue = u.fetchAndAddRelease(nn);
++        quintptr prevValue = u.loadRelaxed();
++        quintptr newValue;
++        do { // loop just to ensure the operations are done atomically
++            newValue = prevValue + nn;
++            newValue &= (futexNeedsWakeAllBit - 1);
++        } while (!u.testAndSetRelease(prevValue, newValue, prevValue));
+         if (futexNeedsWake(prevValue)) {
+ #ifdef FUTEX_OP
+             if (futexHasWaiterCount) {
+@@ -376,7 +381,6 @@ void QSemaphore::release(int n)
+                 quint32 oparg = 0;
+                 quint32 cmp = FUTEX_OP_CMP_NE;
+                 quint32 cmparg = 0;
+-                u.fetchAndAndRelease(futexNeedsWakeAllBit - 1);
+                 futexWakeOp(*futexLow32(&u), n, INT_MAX, *futexHigh32(&u), FUTEX_OP(op, oparg, cmp, cmparg));
+                 return;
+             }
+@@ -388,7 +392,6 @@ 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(futexNeedsWakeAllBit - 1);
+             if (futexHasWaiterCount) {
+                 futexWakeAll(*futexLow32(&u));
+                 futexWakeAll(*futexHigh32(&u));
+diff --git a/qtbase/src/corelib/thread/qthread_p.h b/qtbase/src/corelib/thread/qthread_p.h
+index b2d1628e6e..f32f6f0460 100644
+--- a/qtbase/src/corelib/thread/qthread_p.h
++++ b/qtbase/src/corelib/thread/qthread_p.h
+@@ -174,7 +174,7 @@ public:
+     int returnCode;
+ 
+     uint stackSize;
+-    QThread::Priority priority;
++    std::underlying_type<QThread::Priority>::type priority;
+ 
+     static QThread *threadForId(int id);
+ 
+@@ -213,6 +213,13 @@ public:
+             QCoreApplication::instance()->postEvent(q_ptr, new QEvent(QEvent::Quit));
+         }
+     }
++
++#ifndef Q_OS_INTEGRITY
++private:
++    // Used in QThread(Private)::start to avoid racy access to QObject::objectName,
++    // unset afterwards. On INTEGRITY we set the thread name before starting it.
++    QString objectName;
++#endif
+ };
+ 
+ #else // QT_CONFIG(thread)
+diff --git a/qtbase/src/corelib/thread/qthread_unix.cpp b/qtbase/src/corelib/thread/qthread_unix.cpp
+index 56a8e0a038..610117a640 100644
+--- a/qtbase/src/corelib/thread/qthread_unix.cpp
++++ b/qtbase/src/corelib/thread/qthread_unix.cpp
+@@ -169,8 +169,7 @@ static void set_thread_data(QThreadData *data)
+ 
+ static void clear_thread_data()
+ {
+-    currentThreadData = nullptr;
+-    pthread_setspecific(current_thread_data_key, nullptr);
++    set_thread_data(nullptr);
+ }
+ 
+ template <typename T>
+@@ -296,7 +295,7 @@ void *QThreadPrivate::start(void *arg)
+             QMutexLocker locker(&thr->d_func()->mutex);
+ 
+             // do we need to reset the thread priority?
+-            if (int(thr->d_func()->priority) & ThreadPriorityResetFlag) {
++            if (thr->d_func()->priority & ThreadPriorityResetFlag) {
+                 thr->d_func()->setPriority(QThread::Priority(thr->d_func()->priority & ~ThreadPriorityResetFlag));
+             }
+ 
+@@ -316,10 +315,10 @@ void *QThreadPrivate::start(void *arg)
+             // Sets the name of the current thread. We can only do this
+             // when the thread is starting, as we don't have a cross
+             // platform way of setting the name of an arbitrary thread.
+-            if (Q_LIKELY(thr->objectName().isEmpty()))
++            if (Q_LIKELY(thr->d_func()->objectName.isEmpty()))
+                 setCurrentThreadName(thr->metaObject()->className());
+             else
+-                setCurrentThreadName(thr->objectName().toLocal8Bit());
++                setCurrentThreadName(std::exchange(thr->d_func()->objectName, {}).toLocal8Bit());
+         }
+ #endif
+ 
+@@ -671,7 +670,7 @@ void QThread::start(Priority priority)
+                 // could not set scheduling hints, fallback to inheriting them
+                 // we'll try again from inside the thread
+                 pthread_attr_setinheritsched(&attr, PTHREAD_INHERIT_SCHED);
+-                d->priority = Priority(priority | ThreadPriorityResetFlag);
++                d->priority = static_cast<std::underlying_type<QThread::Priority>::type>(priority) | ThreadPriorityResetFlag;
+             }
+             break;
+         }
+@@ -702,7 +701,10 @@ void QThread::start(Priority priority)
+         pthread_attr_setthreadname(&attr, metaObject()->className());
+     else
+         pthread_attr_setthreadname(&attr, objectName().toLocal8Bit());
++#else
++    d->objectName = objectName();
+ #endif
++
+     pthread_t threadId;
+     int code = pthread_create(&threadId, &attr, QThreadPrivate::start, this);
+     if (code == EPERM) {
+diff --git a/qtbase/src/corelib/thread/qthread_win.cpp b/qtbase/src/corelib/thread/qthread_win.cpp
+index bc70e3178a..4e76972498 100644
+--- a/qtbase/src/corelib/thread/qthread_win.cpp
++++ b/qtbase/src/corelib/thread/qthread_win.cpp
+@@ -394,10 +394,9 @@ unsigned int __stdcall QT_ENSURE_STACK_ALIGNED_FOR_SSE QThreadPrivate::start(voi
+ 
+ #if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) && !defined(Q_OS_WINRT)
+     // sets the name of the current thread.
+-    QByteArray objectName = thr->objectName().toLocal8Bit();
+-    qt_set_thread_name(HANDLE(-1),
+-                       objectName.isEmpty() ?
+-                       thr->metaObject()->className() : objectName.constData());
++    qt_set_thread_name(HANDLE(-1), thr->d_func()->objectName.isEmpty()
++                        ? thr->metaObject()->className()
++                        : std::exchange(thr->d_func()->objectName, {}).toLocal8Bit().constData());
+ #endif
+ 
+     emit thr->started(QThread::QPrivateSignal());
+@@ -503,6 +502,7 @@ void QThread::start(Priority priority)
+     if (d->running)
+         return;
+ 
++    d->objectName = objectName();
+     d->running = true;
+     d->finished = false;
+     d->exited = false;
+@@ -548,7 +548,7 @@ void QThread::start(Priority priority)
+ 
+     int prio;
+     d->priority = priority;
+-    switch (d->priority) {
++    switch (priority) {
+     case IdlePriority:
+         prio = THREAD_PRIORITY_IDLE;
+         break;
+@@ -686,7 +686,7 @@ void QThreadPrivate::setPriority(QThread::Priority threadPriority)
+ 
+     int prio;
+     priority = threadPriority;
+-    switch (priority) {
++    switch (threadPriority) {
+     case QThread::IdlePriority:
+         prio = THREAD_PRIORITY_IDLE;
+         break;
+diff --git a/qtbase/src/corelib/thread/qtsan_impl.h b/qtbase/src/corelib/thread/qtsan_impl.h
+new file mode 100644
+index 0000000000..580a738b91
+--- /dev/null
++++ b/qtbase/src/corelib/thread/qtsan_impl.h
+@@ -0,0 +1,115 @@
++/****************************************************************************
++**
++** Copyright (C) 2017 Intel Corporation.
++** Copyright (C) 2022 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
++** 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 QTSAN_IMPL_H
++#define QTSAN_IMPL_H
++
++#include <QtCore/qglobal.h>
++
++#if (__has_feature(thread_sanitizer) || defined(__SANITIZE_THREAD__)) && __has_include(<sanitizer/tsan_interface.h>)
++#  define QT_BUILDING_UNDER_TSAN
++#  include <sanitizer/tsan_interface.h>
++#endif
++
++QT_BEGIN_NAMESPACE
++
++namespace QtTsan {
++#ifdef QT_BUILDING_UNDER_TSAN
++inline void futexAcquire(void *addr, void *addr2 = nullptr)
++{
++    // A futex call ensures total ordering on the futex words
++    // (in either success or failure of the call). Instruct TSAN accordingly,
++    // as TSAN does not understand the futex(2) syscall (or equivalent).
++    ::__tsan_acquire(addr);
++    if (addr2)
++        ::__tsan_acquire(addr2);
++}
++
++inline void futexRelease(void *addr, void *addr2 = nullptr)
++{
++    if (addr2)
++        ::__tsan_release(addr2);
++    ::__tsan_release(addr);
++}
++
++inline void mutexPreLock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_pre_lock(addr, flags);
++}
++
++inline void mutexPostLock(void *addr, unsigned flags, int recursion)
++{
++    ::__tsan_mutex_post_lock(addr, flags, recursion);
++}
++
++inline void mutexPreUnlock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_pre_unlock(addr, flags);
++}
++
++inline void mutexPostUnlock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_post_unlock(addr, flags);
++}
++
++enum : unsigned {
++    MutexWriteReentrant = ::__tsan_mutex_write_reentrant,
++    TryLock = ::__tsan_mutex_try_lock,
++    TryLockFailed = ::__tsan_mutex_try_lock_failed,
++};
++#else
++inline void futexAcquire(void *, void * = nullptr) {}
++inline void futexRelease(void *, void * = nullptr) {}
++
++enum : unsigned {
++    MutexWriteReentrant,
++    TryLock,
++    TryLockFailed,
++};
++inline void mutexPreLock(void *, unsigned) {}
++inline void mutexPostLock(void *, unsigned, int) {}
++inline void mutexPreUnlock(void *, unsigned) {}
++inline void mutexPostUnlock(void *, unsigned) {}
++#endif // QT_BUILDING_UNDER_TSAN
++} // namespace QtTsan
++
++QT_END_NAMESPACE
++
++#endif // QTSAN_IMPL_H
+diff --git a/qtbase/src/corelib/thread/qwaitcondition_unix.cpp b/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
+index 88b058f410..0f1da4dc9b 100644
+--- a/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
++++ b/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
+@@ -213,7 +213,7 @@ bool QWaitCondition::wait(QMutex *mutex, QDeadlineTimer deadline)
+ {
+     if (! mutex)
+         return false;
+-    if (mutex->isRecursive()) {
++    if (static_cast<QBasicMutex *>(mutex)->isRecursive()) {
+         qWarning("QWaitCondition: cannot wait on recursive mutexes");
+         return false;
+     }
+diff --git a/qtbase/src/corelib/time/qdatetime.cpp b/qtbase/src/corelib/time/qdatetime.cpp
+index ec12569e3f..2c0b098079 100644
+--- a/qtbase/src/corelib/time/qdatetime.cpp
++++ b/qtbase/src/corelib/time/qdatetime.cpp
+@@ -43,6 +43,7 @@
+ #if QT_CONFIG(datetimeparser)
+ #include "private/qdatetimeparser_p.h"
+ #endif
++#include <private/qnumeric_p.h>
+ 
+ #include "qdatastream.h"
+ #include "qset.h"
+@@ -1429,9 +1430,11 @@ QDate QDate::addDays(qint64 ndays) const
+     if (isNull())
+         return QDate();
+ 
+-    // Due to limits on minJd() and maxJd() we know that any overflow
+-    // will be invalid and caught by fromJulianDay().
+-    return fromJulianDay(jd + ndays);
++    qint64 r;
++    if (Q_UNLIKELY(add_overflow(jd, ndays, &r)))
++        return QDate();
++    else
++        return fromJulianDay(r);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/corelib/time/qtimezone.cpp b/qtbase/src/corelib/time/qtimezone.cpp
+index 0309e43e52..3d451696a1 100644
+--- a/qtbase/src/corelib/time/qtimezone.cpp
++++ b/qtbase/src/corelib/time/qtimezone.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2013 John Layt <jlayt@kde.org>
++** Copyright (C) 2020 John Layt <jlayt@kde.org>
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtCore module of the Qt Toolkit.
+@@ -975,9 +975,15 @@ QList<QByteArray> QTimeZone::windowsIdToIanaIds(const QByteArray &windowsId,
+ }
+ 
+ #ifndef QT_NO_DATASTREAM
++// Invalid, as an IANA ID: too long, starts with - and has other invalid characters in it
++static inline QString invalidId() { return QStringLiteral("-No Time Zone Specified!"); }
++
+ QDataStream &operator<<(QDataStream &ds, const QTimeZone &tz)
+ {
+-    tz.d->serialize(ds);
++    if (tz.isValid())
++        tz.d->serialize(ds);
++    else
++        ds << invalidId();
+     return ds;
+ }
+ 
+@@ -985,7 +991,9 @@ QDataStream &operator>>(QDataStream &ds, QTimeZone &tz)
+ {
+     QString ianaId;
+     ds >> ianaId;
+-    if (ianaId == QLatin1String("OffsetFromUtc")) {
++    if (ianaId == invalidId()) {
++        tz = QTimeZone();
++    } else if (ianaId == QLatin1String("OffsetFromUtc")) {
+         int utcOffset;
+         QString name;
+         QString abbreviation;
+diff --git a/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp b/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
+index b1611d7ddb..a7a6a72ccf 100644
+--- a/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
++++ b/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
+@@ -42,6 +42,7 @@
+ #include "qtimezone.h"
+ #include "qtimezoneprivate_p.h"
+ #include "private/qlocale_tools_p.h"
++#include "private/qlocking_p.h"
+ 
+ #include <QtCore/QDataStream>
+ #include <QtCore/QDateTime>
+@@ -62,6 +63,10 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++#if QT_CONFIG(icu)
++static QBasicMutex s_icu_mutex;
++#endif
++
+ /*
+     Private
+ 
+@@ -670,6 +675,9 @@ QTzTimeZonePrivate::~QTzTimeZonePrivate()
+ 
+ QTzTimeZonePrivate *QTzTimeZonePrivate::clone() const
+ {
++#if QT_CONFIG(icu)
++    const auto lock = qt_scoped_lock(s_icu_mutex);
++#endif
+     return new QTzTimeZonePrivate(*this);
+ }
+ 
+@@ -913,12 +921,14 @@ QString QTzTimeZonePrivate::displayName(qint64 atMSecsSinceEpoch,
+                                         const QLocale &locale) const
+ {
+ #if QT_CONFIG(icu)
++    auto lock = qt_unique_lock(s_icu_mutex);
+     if (!m_icu)
+         m_icu = new QIcuTimeZonePrivate(m_id);
+     // TODO small risk may not match if tran times differ due to outdated files
+     // TODO Some valid TZ names are not valid ICU names, use translation table?
+     if (m_icu->isValid())
+         return m_icu->displayName(atMSecsSinceEpoch, nameType, locale);
++    lock.unlock();
+ #else
+     Q_UNUSED(nameType)
+     Q_UNUSED(locale)
+@@ -932,12 +942,14 @@ QString QTzTimeZonePrivate::displayName(QTimeZone::TimeType timeType,
+                                         const QLocale &locale) const
+ {
+ #if QT_CONFIG(icu)
++    auto lock = qt_unique_lock(s_icu_mutex);
+     if (!m_icu)
+         m_icu = new QIcuTimeZonePrivate(m_id);
+     // TODO small risk may not match if tran times differ due to outdated files
+     // TODO Some valid TZ names are not valid ICU names, use translation table?
+     if (m_icu->isValid())
+         return m_icu->displayName(timeType, nameType, locale);
++    lock.unlock();
+ #else
+     Q_UNUSED(timeType)
+     Q_UNUSED(nameType)
+diff --git a/qtbase/src/corelib/tools/qarraydata.h b/qtbase/src/corelib/tools/qarraydata.h
+index dcd95924c1..d01739e7e6 100644
+--- a/qtbase/src/corelib/tools/qarraydata.h
++++ b/qtbase/src/corelib/tools/qarraydata.h
+@@ -42,6 +42,7 @@
+ 
+ #include <QtCore/qrefcount.h>
+ #include <string.h>
++#include <cstdint>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -58,14 +59,14 @@ struct Q_CORE_EXPORT QArrayData
+     {
+         Q_ASSERT(size == 0
+                 || offset < 0 || size_t(offset) >= sizeof(QArrayData));
+-        return reinterpret_cast<char *>(this) + offset;
++        return reinterpret_cast<void *> (reinterpret_cast<uintptr_t>(this) + offset);
+     }
+ 
+     const void *data() const
+     {
+         Q_ASSERT(size == 0
+                 || offset < 0 || size_t(offset) >= sizeof(QArrayData));
+-        return reinterpret_cast<const char *>(this) + offset;
++        return reinterpret_cast<void *> (reinterpret_cast<uintptr_t>(this) + offset);
+     }
+ 
+     // This refers to array data mutability, not "header data" represented by
+diff --git a/qtbase/src/corelib/tools/qfreelist_p.h b/qtbase/src/corelib/tools/qfreelist_p.h
+index 5ba23b344b..9974102136 100644
+--- a/qtbase/src/corelib/tools/qfreelist_p.h
++++ b/qtbase/src/corelib/tools/qfreelist_p.h
+@@ -161,7 +161,7 @@ class QFreeList
+                 return i;
+             x -= size;
+         }
+-        Q_ASSERT(false);
++        Q_UNREACHABLE();
+         return -1;
+     }
+ 
+diff --git a/qtbase/src/corelib/tools/qversionnumber.h b/qtbase/src/corelib/tools/qversionnumber.h
+index d43b86ba51..2843f2b043 100644
+--- a/qtbase/src/corelib/tools/qversionnumber.h
++++ b/qtbase/src/corelib/tools/qversionnumber.h
+@@ -273,10 +273,10 @@ public:
+ 
+     Q_REQUIRED_RESULT Q_CORE_EXPORT QString toString() const;
+ #if QT_STRINGVIEW_LEVEL < 2
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(const QString &string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(const QString &string, int *suffixIndex = nullptr);
+ #endif
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QLatin1String string, int *suffixIndex = nullptr);
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QStringView string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(QLatin1String string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(QStringView string, int *suffixIndex = nullptr);
+ 
+ private:
+ #ifndef QT_NO_DATASTREAM
+diff --git a/qtbase/src/dbus/qdbusintegrator.cpp b/qtbase/src/dbus/qdbusintegrator.cpp
+index 5b66ce971b..28a3b0ffea 100644
+--- a/qtbase/src/dbus/qdbusintegrator.cpp
++++ b/qtbase/src/dbus/qdbusintegrator.cpp
+@@ -1135,7 +1135,13 @@ void QDBusConnectionPrivate::closeConnection()
+         }
+     }
+ 
+-    qDeleteAll(pendingCalls);
++    for (auto it = pendingCalls.begin(); it != pendingCalls.end(); ++it) {
++        auto call = *it;
++        if (!call->ref.deref()) {
++            delete call;
++        }
++    }
++    pendingCalls.clear();
+ 
+     // Disconnect all signals from signal hooks and from the object tree to
+     // avoid QObject::destroyed being sent to dbus daemon thread which has
+@@ -2584,6 +2590,11 @@ QDBusConnectionPrivate::findMetaObject(const QString &service, const QString &pa
+         if (mo)
+             return mo;
+     }
++    if (path.isEmpty()) {
++        error = QDBusError(QDBusError::InvalidObjectPath, QLatin1String("Object path cannot be empty"));
++        lastError = error;
++        return nullptr;
++    }
+ 
+     // introspect the target object
+     QDBusMessage msg = QDBusMessage::createMethodCall(service, path,
+diff --git a/qtbase/src/dbus/qdbusmetaobject.cpp b/qtbase/src/dbus/qdbusmetaobject.cpp
+index 5265568f42..7e9f0f1acc 100644
+--- a/qtbase/src/dbus/qdbusmetaobject.cpp
++++ b/qtbase/src/dbus/qdbusmetaobject.cpp
+@@ -210,6 +210,9 @@ QDBusMetaObjectGenerator::findType(const QByteArray &signature,
+         } else if (signature == "a{ss}") {
+             result.name = "QMap<QString,QString>";
+             type = qMetaTypeId<QMap<QString, QString> >();
++        } else if (signature == "aay") {
++            result.name = "QByteArrayList";
++            type = qMetaTypeId<QByteArrayList>();
+         } else {
+             result.name = "{D-Bus type \"" + signature + "\"}";
+             type = registerComplexDBusType(result.name);
+diff --git a/qtbase/src/gui/accessible/qaccessible.cpp b/qtbase/src/gui/accessible/qaccessible.cpp
+index d705bfccb5..0caf3c808c 100644
+--- a/qtbase/src/gui/accessible/qaccessible.cpp
++++ b/qtbase/src/gui/accessible/qaccessible.cpp
+@@ -54,6 +54,7 @@
+ #include <QtCore/qdebug.h>
+ #include <QtCore/qloggingcategory.h>
+ #include <QtCore/qmetaobject.h>
++#include <QtCore/private/qmetaobject_p.h>
+ #include <QtCore/qhash.h>
+ #include <private/qfactoryloader_p.h>
+ 
+@@ -681,6 +682,25 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
+     // Create a QAccessibleInterface for the object class. Start by the most
+     // derived class and walk up the class hierarchy.
+     const QMetaObject *mo = object->metaObject();
++    const auto *objectPriv = QObjectPrivate::get(object);
++    /*
++     We do not want to cache each and every QML metaobject (Button_QMLTYPE_124,
++     Button_QMLTYPE_125, etc.). Those dynamic metaobjects shouldn't have an
++     accessible interface in any case. Instead, we start the whole checking
++     with the first non-dynamic meta-object. To avoid potential regressions
++     in other areas of Qt that also use dynamic metaobjects, we only do this
++     for objects that are QML-related (approximated by checking whether they
++     have ddata set).
++    */
++    const bool qmlRelated = !objectPriv->isDeletingChildren &&
++                            objectPriv->declarativeData;
++    while (qmlRelated && mo) {
++        auto mop = QMetaObjectPrivate::get(mo);
++        if (!mop || !(mop->flags & DynamicMetaObject))
++            break;
++
++        mo = mo->superClass();
++    };
+     while (mo) {
+         const QString cn = QLatin1String(mo->className());
+ 
+@@ -696,14 +716,15 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
+         // Find a QAccessiblePlugin (factory) for the class name. If there's
+         // no entry in the cache try to create it using the plugin loader.
+         if (!qAccessiblePlugins()->contains(cn)) {
++            QAccessiblePlugin *factory = nullptr; // 0 means "no plugin found". This is cached as well.
+             const int index = loader()->indexOf(cn);
+-            if (index != -1) {
+-                QAccessiblePlugin *factory = qobject_cast<QAccessiblePlugin *>(loader()->instance(index));
+-                qAccessiblePlugins()->insert(cn, factory);
+-            }
++            if (index != -1)
++                factory = qobject_cast<QAccessiblePlugin *>(loader()->instance(index));
++            qAccessiblePlugins()->insert(cn, factory);
+         }
+ 
+         // At this point the cache should contain a valid factory pointer or 0:
++        Q_ASSERT(qAccessiblePlugins()->contains(cn));
+         QAccessiblePlugin *factory = qAccessiblePlugins()->value(cn);
+         if (factory) {
+             QAccessibleInterface *result = factory->create(cn, object);
+diff --git a/qtbase/src/gui/configure.json b/qtbase/src/gui/configure.json
+index 1f08795c57..12c95742d2 100644
+--- a/qtbase/src/gui/configure.json
++++ b/qtbase/src/gui/configure.json
+@@ -834,7 +834,8 @@
+                     "// embedded devices, are not intended to be used together with X. EGL support",
+                     "// has to be disabled in plugins like xcb in this case since the native display,",
+                     "// window and pixmap types will be different than what an X-based platform",
+-                    "// plugin would expect."
++                    "// plugin would expect.",
++                    "#define USE_X11"
+                 ],
+                 "include": [ "EGL/egl.h", "X11/Xlib.h" ],
+                 "main": [
+diff --git a/qtbase/src/gui/image/qbmphandler.cpp b/qtbase/src/gui/image/qbmphandler.cpp
+index 96f1e8cb1d..0e73bbbdb0 100644
+--- a/qtbase/src/gui/image/qbmphandler.cpp
++++ b/qtbase/src/gui/image/qbmphandler.cpp
+@@ -150,16 +150,42 @@ static QDataStream &operator<<(QDataStream &s, const BMP_INFOHDR &bi)
+     return s;
+ }
+ 
+-static int calc_shift(uint mask)
++static uint calc_shift(uint mask)
+ {
+-    int result = 0;
+-    while (mask && !(mask & 1)) {
++    uint result = 0;
++    while ((mask >= 0x100) || (!(mask & 1) && mask)) {
+         result++;
+         mask >>= 1;
+     }
+     return result;
+ }
+ 
++static uint calc_scale(uint low_mask)
++{
++    uint result = 8;
++    while (low_mask && result) {
++        result--;
++        low_mask >>= 1;
++    }
++    return result;
++}
++
++static inline uint apply_scale(uint value, uint scale)
++{
++    if (!(scale & 0x07)) // return immediately if scale == 8 or 0
++        return value;
++
++    uint filled = 8 - scale;
++    uint result = value << scale;
++
++    do {
++        result |= result >> filled;
++        filled <<= 1;
++    } while (filled < 8);
++
++    return result;
++}
++
+ static bool read_dib_fileheader(QDataStream &s, BMP_FILEHDR &bf)
+ {
+     // read BMP file header
+@@ -222,14 +248,14 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+     uint green_mask = 0;
+     uint blue_mask = 0;
+     uint alpha_mask = 0;
+-    int red_shift = 0;
+-    int green_shift = 0;
+-    int blue_shift = 0;
+-    int alpha_shift = 0;
+-    int red_scale = 0;
+-    int green_scale = 0;
+-    int blue_scale = 0;
+-    int alpha_scale = 0;
++    uint red_shift = 0;
++    uint green_shift = 0;
++    uint blue_shift = 0;
++    uint alpha_shift = 0;
++    uint red_scale = 0;
++    uint green_scale = 0;
++    uint blue_scale = 0;
++    uint alpha_scale = 0;
+ 
+     if (!d->isSequential())
+         d->seek(startpos + BMP_FILEHDR_SIZE + bi.biSize); // goto start of colormap or masks
+@@ -308,19 +334,19 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+         red_shift = calc_shift(red_mask);
+         if (((red_mask >> red_shift) + 1) == 0)
+             return false;
+-        red_scale = 256 / ((red_mask >> red_shift) + 1);
++        red_scale = calc_scale(red_mask >> red_shift);
+         green_shift = calc_shift(green_mask);
+         if (((green_mask >> green_shift) + 1) == 0)
+             return false;
+-        green_scale = 256 / ((green_mask >> green_shift) + 1);
++        green_scale = calc_scale(green_mask >> green_shift);
+         blue_shift = calc_shift(blue_mask);
+         if (((blue_mask >> blue_shift) + 1) == 0)
+             return false;
+-        blue_scale = 256 / ((blue_mask >> blue_shift) + 1);
++        blue_scale = calc_scale(blue_mask >> blue_shift);
+         alpha_shift = calc_shift(alpha_mask);
+         if (((alpha_mask >> alpha_shift) + 1) == 0)
+             return false;
+-        alpha_scale = 256 / ((alpha_mask >> alpha_shift) + 1);
++        alpha_scale = calc_scale(alpha_mask >> alpha_shift);
+     } else if (comp == BMP_RGB && (nbits == 24 || nbits == 32)) {
+         blue_mask = 0x000000ff;
+         green_mask = 0x0000ff00;
+@@ -328,17 +354,15 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+         blue_shift = 0;
+         green_shift = 8;
+         red_shift = 16;
+-        blue_scale = green_scale = red_scale = 1;
++        blue_scale = green_scale = red_scale = 0;
+     } else if (comp == BMP_RGB && nbits == 16) {
+         blue_mask = 0x001f;
+         green_mask = 0x03e0;
+         red_mask = 0x7c00;
+         blue_shift = 0;
+-        green_shift = 2;
+-        red_shift = 7;
+-        red_scale = 1;
+-        green_scale = 1;
+-        blue_scale = 8;
++        green_shift = 5;
++        red_shift = 10;
++        blue_scale = green_scale = red_scale = 3;
+     }
+ 
+ #if 0
+@@ -544,10 +568,10 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+                     c |= *(uchar*)(b+2)<<16;
+                 if (nbits > 24)
+                     c |= *(uchar*)(b+3)<<24;
+-                *p++ = qRgba(((c & red_mask) >> red_shift) * red_scale,
+-                                        ((c & green_mask) >> green_shift) * green_scale,
+-                                        ((c & blue_mask) >> blue_shift) * blue_scale,
+-                                        transp ? ((c & alpha_mask) >> alpha_shift) * alpha_scale : 0xff);
++                *p++ = qRgba(apply_scale((c & red_mask) >> red_shift, red_scale),
++                             apply_scale((c & green_mask) >> green_shift, green_scale),
++                             apply_scale((c & blue_mask) >> blue_shift, blue_scale),
++                             transp ? apply_scale((c & alpha_mask) >> alpha_shift, alpha_scale) : 0xff);
+                 b += nbits/8;
+             }
+         }
+diff --git a/qtbase/src/gui/image/qimage.cpp b/qtbase/src/gui/image/qimage.cpp
+index 7152ac1607..0df772564c 100644
+--- a/qtbase/src/gui/image/qimage.cpp
++++ b/qtbase/src/gui/image/qimage.cpp
+@@ -4694,6 +4694,8 @@ QImage QImage::smoothScaled(int w, int h) const {
+ static QImage rotated90(const QImage &image)
+ {
+     QImage out(image.height(), image.width(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+@@ -4722,6 +4724,8 @@ static QImage rotated180(const QImage &image)
+         return image.mirrored(true, true);
+ 
+     QImage out(image.width(), image.height(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+@@ -4734,6 +4738,8 @@ static QImage rotated180(const QImage &image)
+ static QImage rotated270(const QImage &image)
+ {
+     QImage out(image.height(), image.width(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+diff --git a/qtbase/src/gui/kernel/qcursor.cpp b/qtbase/src/gui/kernel/qcursor.cpp
+index d6ccaff8ed..455088241c 100644
+--- a/qtbase/src/gui/kernel/qcursor.cpp
++++ b/qtbase/src/gui/kernel/qcursor.cpp
+@@ -251,7 +251,8 @@ void QCursor::setPos(QScreen *screen, int x, int y)
+ {
+     if (screen) {
+         if (QPlatformCursor *cursor = screen->handle()->cursor()) {
+-            const QPoint devicePos = QHighDpi::toNativePixels(QPoint(x, y), screen);
++            const QPoint pos(x, y);
++            const QPoint devicePos = QHighDpi::toNativePixels(pos, screen->virtualSiblingAt(pos));
+             // Need to check, since some X servers generate null mouse move
+             // events, causing looping in applications which call setPos() on
+             // every mouse move event.
+diff --git a/qtbase/src/gui/kernel/qhighdpiscaling.cpp b/qtbase/src/gui/kernel/qhighdpiscaling.cpp
+index 9bbf2773a9..3ac4a4d8b6 100644
+--- a/qtbase/src/gui/kernel/qhighdpiscaling.cpp
++++ b/qtbase/src/gui/kernel/qhighdpiscaling.cpp
+@@ -580,9 +580,8 @@ void QHighDpiScaling::setScreenFactor(QScreen *screen, qreal factor)
+     else
+         qNamedScreenScaleFactors()->insert(name, factor);
+ 
+-    // hack to force re-evaluation of screen geometry
+     if (screen->handle())
+-        screen->d_func()->setPlatformScreen(screen->handle()); // updates geometries based on scale factor
++        screen->d_func()->updateLogicalDpi();
+ }
+ 
+ QPoint QHighDpiScaling::mapPositionToNative(const QPoint &pos, const QPlatformScreen *platformScreen)
+diff --git a/qtbase/src/gui/kernel/qkeysequence.cpp b/qtbase/src/gui/kernel/qkeysequence.cpp
+index a75b8ef920..4f2d294739 100644
+--- a/qtbase/src/gui/kernel/qkeysequence.cpp
++++ b/qtbase/src/gui/kernel/qkeysequence.cpp
+@@ -701,6 +701,10 @@ static const struct {
+     { Qt::Key_TouchpadToggle,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad Toggle") },
+     { Qt::Key_TouchpadOn,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad On") },
+     { Qt::Key_TouchpadOff,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad Off") },
++    { Qt::Key_Shift,  QT_TRANSLATE_NOOP("QShortcut", "Shift") },
++    { Qt::Key_Control,  QT_TRANSLATE_NOOP("QShortcut", "Control") },
++    { Qt::Key_Alt,  QT_TRANSLATE_NOOP("QShortcut", "Alt") },
++    { Qt::Key_Meta,  QT_TRANSLATE_NOOP("QShortcut", "Meta") },
+ 
+ };
+ static Q_CONSTEXPR int numKeyNames = sizeof keyname / sizeof *keyname;
+diff --git a/qtbase/src/gui/kernel/qplatformservices.cpp b/qtbase/src/gui/kernel/qplatformservices.cpp
+index fdc6a6c4aa..ac47f98c5d 100644
+--- a/qtbase/src/gui/kernel/qplatformservices.cpp
++++ b/qtbase/src/gui/kernel/qplatformservices.cpp
+@@ -55,6 +55,19 @@ QT_BEGIN_NAMESPACE
+     \brief The QPlatformServices provides the backend for desktop-related functionality.
+ */
+ 
++/*!
++    \enum QPlatformServices::Capability
++
++    Capabilities are used to determine a specific platform service's availability.
++
++    \value ColorPickingFromScreen The platform natively supports color picking from screen.
++    This capability indicates that the platform supports "opaque" color picking, where the
++    platform implements a complete user experience for color picking and outputs a color.
++    This is in contrast to the application implementing the color picking user experience
++    (taking care of showing a cross hair, instructing the platform integration to obtain
++    the color at a given pixel, etc.). The related service function is pickColor().
++ */
++
+ QPlatformServices::QPlatformServices()
+ { }
+ 
+@@ -85,5 +98,16 @@ QByteArray QPlatformServices::desktopEnvironment() const
+     return QByteArray("UNKNOWN");
+ }
+ 
++QPlatformServiceColorPicker *QPlatformServices::colorPicker(QWindow *parent)
++{
++    Q_UNUSED(parent);
++    return nullptr;
++}
++
++bool QPlatformServices::hasCapability(Capability capability) const
++{
++    Q_UNUSED(capability)
++    return false;
++}
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/gui/kernel/qplatformservices.h b/qtbase/src/gui/kernel/qplatformservices.h
+index 5de96cfa7d..a8b2a4ce71 100644
+--- a/qtbase/src/gui/kernel/qplatformservices.h
++++ b/qtbase/src/gui/kernel/qplatformservices.h
+@@ -50,16 +50,32 @@
+ //
+ 
+ #include <QtGui/qtguiglobal.h>
++#include <QtCore/qobject.h>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+ class QUrl;
++class QWindow;
++
++class Q_GUI_EXPORT QPlatformServiceColorPicker : public QObject
++{
++    Q_OBJECT
++public:
++    using QObject::QObject;
++    virtual void pickColor() = 0;
++Q_SIGNALS:
++    void colorPicked(const QColor &color);
++};
+ 
+ class Q_GUI_EXPORT QPlatformServices
+ {
+ public:
+     Q_DISABLE_COPY_MOVE(QPlatformServices)
+ 
++    enum Capability {
++        ColorPicking,
++    };
++
+     QPlatformServices();
+     virtual ~QPlatformServices() { }
+ 
+@@ -67,6 +83,10 @@ public:
+     virtual bool openDocument(const QUrl &url);
+ 
+     virtual QByteArray desktopEnvironment() const;
++
++    virtual bool hasCapability(Capability capability) const;
++
++    virtual QPlatformServiceColorPicker *colorPicker(QWindow *parent = nullptr);
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/gui/kernel/qplatformtheme.cpp b/qtbase/src/gui/kernel/qplatformtheme.cpp
+index 71521c0339..2325873245 100644
+--- a/qtbase/src/gui/kernel/qplatformtheme.cpp
++++ b/qtbase/src/gui/kernel/qplatformtheme.cpp
+@@ -163,6 +163,8 @@ QT_BEGIN_NAMESPACE
+ 
+     \value ShowShortcutsInContextMenus (bool) Whether to display shortcut key sequences in context menus.
+ 
++    \value ButtonPressKeys (QList<Qt::Key>) A list of keys that can be used to press buttons via keyboard input.
++
+     \sa themeHint(), QStyle::pixelMetric()
+ */
+ 
+@@ -563,6 +565,8 @@ QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint)
+         }
+     case MouseQuickSelectionThreshold:
+         return QVariant(10);
++    case ButtonPressKeys:
++        return QVariant::fromValue(QList<Qt::Key>({ Qt::Key_Space, Qt::Key_Select }));
+     }
+     return QVariant();
+ }
+diff --git a/qtbase/src/gui/kernel/qplatformtheme.h b/qtbase/src/gui/kernel/qplatformtheme.h
+index 3185fc4541..7e6c9d5740 100644
+--- a/qtbase/src/gui/kernel/qplatformtheme.h
++++ b/qtbase/src/gui/kernel/qplatformtheme.h
+@@ -120,7 +120,8 @@ public:
+         TouchDoubleTapDistance,
+         ShowShortcutsInContextMenus,
+         IconFallbackSearchPaths,
+-        MouseQuickSelectionThreshold
++        MouseQuickSelectionThreshold,
++        ButtonPressKeys
+     };
+ 
+     enum DialogType {
+diff --git a/qtbase/src/gui/kernel/qscreen.cpp b/qtbase/src/gui/kernel/qscreen.cpp
+index 8e0eb35116..5d172a58dd 100644
+--- a/qtbase/src/gui/kernel/qscreen.cpp
++++ b/qtbase/src/gui/kernel/qscreen.cpp
+@@ -77,6 +77,12 @@ QScreen::QScreen(QPlatformScreen *screen)
+     d->setPlatformScreen(screen);
+ }
+ 
++void QScreenPrivate::updateLogicalDpi()
++{
++    logicalDpi = QPlatformScreen::overrideDpi(platformScreen->logicalDpi());
++    updateGeometriesWithSignals(); // updates geometries based on scale factor
++}
++
+ void QScreenPrivate::updateGeometriesWithSignals()
+ {
+     const QRect oldGeometry = geometry;
+diff --git a/qtbase/src/gui/kernel/qscreen_p.h b/qtbase/src/gui/kernel/qscreen_p.h
+index 7da542c25e..e50fc3190b 100644
+--- a/qtbase/src/gui/kernel/qscreen_p.h
++++ b/qtbase/src/gui/kernel/qscreen_p.h
+@@ -70,6 +70,7 @@ public:
+         geometry = platformScreen->deviceIndependentGeometry();
+         availableGeometry = QHighDpi::fromNative(platformScreen->availableGeometry(), QHighDpiScaling::factor(platformScreen), geometry.topLeft());
+     }
++    void updateLogicalDpi();
+ 
+     void updatePrimaryOrientation();
+     void updateGeometriesWithSignals();
+diff --git a/qtbase/src/gui/painting/qblendfunctions_p.h b/qtbase/src/gui/painting/qblendfunctions_p.h
+index 080da98ec4..6997d62b3c 100644
+--- a/qtbase/src/gui/painting/qblendfunctions_p.h
++++ b/qtbase/src/gui/painting/qblendfunctions_p.h
+@@ -246,25 +246,32 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+                                   int dudx, int dvdx, int dudy, int dvdy, int u0, int v0,
+                                   Blender blender)
+ {
+-    int fromY = qMax(qRound(topY), clip.top());
+-    int toY = qMin(qRound(bottomY), clip.top() + clip.height());
++    qint64 fromY = qMax(qRound(topY), clip.top());
++    qint64 toY = qMin(qRound(bottomY), clip.top() + clip.height());
+     if (fromY >= toY)
+         return;
+ 
+     qreal leftSlope = (bottomLeft.x - topLeft.x) / (bottomLeft.y - topLeft.y);
+     qreal rightSlope = (bottomRight.x - topRight.x) / (bottomRight.y - topRight.y);
+-    int dx_l = int(leftSlope * 0x10000);
+-    int dx_r = int(rightSlope * 0x10000);
+-    int x_l = int((topLeft.x + (qreal(0.5) + fromY - topLeft.y) * leftSlope + qreal(0.5)) * 0x10000);
+-    int x_r = int((topRight.x + (qreal(0.5) + fromY - topRight.y) * rightSlope + qreal(0.5)) * 0x10000);
+-
+-    int fromX, toX, x1, x2, u, v, i, ii;
++    qint64 dx_l = qint64(leftSlope * 0x10000);
++    qint64 dx_r = qint64(rightSlope * 0x10000);
++    qint64 x_l = qint64((topLeft.x + (qreal(0.5) + fromY - topLeft.y) * leftSlope + qreal(0.5)) * 0x10000);
++    qint64 x_r = qint64((topRight.x + (qreal(0.5) + fromY - topRight.y) * rightSlope + qreal(0.5)) * 0x10000);
++
++    qint64 sourceRectTop = qint64(sourceRect.top());
++    qint64 sourceRectLeft = qint64(sourceRect.left());
++    qint64 sourceRectWidth = qint64(sourceRect.width());
++    qint64 sourceRectHeight = qint64(sourceRect.height());
++    qint64 clipLeft = qint64(clip.left());
++    qint64 clipWidth = qint64(clip.width());
++
++    qint64 fromX, toX, x1, x2, u, v, i, ii;
+     DestT *line;
+-    for (int y = fromY; y < toY; ++y) {
++    for (qint64 y = fromY; y < toY; ++y) {
+         line = reinterpret_cast<DestT *>(reinterpret_cast<uchar *>(destPixels) + y * dbpl);
+ 
+-        fromX = qMax(x_l >> 16, clip.left());
+-        toX = qMin(x_r >> 16, clip.left() + clip.width());
++        fromX = qMax(x_l >> 16, clipLeft);
++        toX = qMin(x_r >> 16, clipLeft + clipWidth);
+         if (fromX < toX) {
+             // Because of rounding, we can get source coordinates outside the source image.
+             // Clamp these coordinates to the source rect to avoid segmentation fault and
+@@ -275,10 +282,10 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             u = x1 * dudx + y * dudy + u0;
+             v = x1 * dvdx + y * dvdy + v0;
+             for (; x1 < toX; ++x1) {
+-                int uu = u >> 16;
+-                int vv = v >> 16;
+-                if (uu >= sourceRect.left() && uu < sourceRect.left() + sourceRect.width()
+-                    && vv >= sourceRect.top() && vv < sourceRect.top() + sourceRect.height()) {
++                qint64 uu = u >> 16;
++                qint64 vv = v >> 16;
++                if (uu >= sourceRectLeft && uu < sourceRectLeft + sourceRectWidth
++                    && vv >= sourceRectTop && vv < sourceRectTop + sourceRectHeight) {
+                     break;
+                 }
+                 u += dudx;
+@@ -290,10 +297,10 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             u = (x2 - 1) * dudx + y * dudy + u0;
+             v = (x2 - 1) * dvdx + y * dvdy + v0;
+             for (; x2 > x1; --x2) {
+-                int uu = u >> 16;
+-                int vv = v >> 16;
+-                if (uu >= sourceRect.left() && uu < sourceRect.left() + sourceRect.width()
+-                    && vv >= sourceRect.top() && vv < sourceRect.top() + sourceRect.height()) {
++                qint64 uu = u >> 16;
++                qint64 vv = v >> 16;
++                if (uu >= sourceRectLeft && uu < sourceRectLeft + sourceRectWidth
++                    && vv >= sourceRectTop && vv < sourceRectTop + sourceRectHeight) {
+                     break;
+                 }
+                 u -= dudx;
+@@ -308,8 +315,8 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             // Beginning of the scan line, with per-pixel checks.
+             i = x1 - fromX;
+             while (i) {
+-                int uu = qBound(sourceRect.left(), u >> 16, sourceRect.left() + sourceRect.width() - 1);
+-                int vv = qBound(sourceRect.top(), v >> 16, sourceRect.top() + sourceRect.height() - 1);
++                qint64 uu = qBound(sourceRectLeft, u >> 16, sourceRectLeft + sourceRectWidth - 1);
++                qint64 vv = qBound(sourceRectTop, v >> 16, sourceRectTop + sourceRectHeight - 1);
+                 blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + vv * sbpl)[uu]);
+                 u += dudx;
+                 v += dvdx;
+@@ -348,8 +355,8 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             // End of the scan line, with per-pixel checks.
+             i = toX - x2;
+             while (i) {
+-                int uu = qBound(sourceRect.left(), u >> 16, sourceRect.left() + sourceRect.width() - 1);
+-                int vv = qBound(sourceRect.top(), v >> 16, sourceRect.top() + sourceRect.height() - 1);
++                qint64 uu = qBound(sourceRectLeft, u >> 16, sourceRectLeft + sourceRectWidth - 1);
++                qint64 vv = qBound(sourceRectTop, v >> 16, sourceRectTop + sourceRectHeight - 1);
+                 blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + vv * sbpl)[uu]);
+                 u += dudx;
+                 v += dvdx;
+diff --git a/qtbase/src/gui/painting/qcolortrclut_p.h b/qtbase/src/gui/painting/qcolortrclut_p.h
+index 76a6a60803..24fd522e6c 100644
+--- a/qtbase/src/gui/painting/qcolortrclut_p.h
++++ b/qtbase/src/gui/painting/qcolortrclut_p.h
+@@ -118,6 +118,7 @@ public:
+         return QRgba64::fromRgba64(r, g, b, qAlpha(rgb32) * 257);
+ #endif
+     }
++    QRgba64 toLinear64(QRgba64) const = delete;
+ 
+     QRgb toLinear(QRgb rgb32) const
+     {
+diff --git a/qtbase/src/gui/painting/qdrawhelper.cpp b/qtbase/src/gui/painting/qdrawhelper.cpp
+index a61793508a..5ba2d277b7 100644
+--- a/qtbase/src/gui/painting/qdrawhelper.cpp
++++ b/qtbase/src/gui/painting/qdrawhelper.cpp
+@@ -6091,7 +6091,7 @@ static inline void alphargbblend_argb32(quint32 *dst, uint coverage, const QRgba
+ static inline void rgbBlendPixel(QRgba64 &dst, int coverage, QRgba64 slinear, const QColorTrcLut *colorProfile)
+ {
+     // Do a gammacorrected RGB alphablend...
+-    const QRgba64 dlinear = colorProfile ? colorProfile->toLinear64(dst) : dst;
++    const QRgba64 dlinear = colorProfile ? colorProfile->toLinear(dst) : dst;
+ 
+     QRgba64 blend = rgbBlend(dlinear, slinear, coverage);
+ 
+diff --git a/qtbase/src/gui/painting/qpaintengine_raster.cpp b/qtbase/src/gui/painting/qpaintengine_raster.cpp
+index 283923de52..f08eb9cbee 100644
+--- a/qtbase/src/gui/painting/qpaintengine_raster.cpp
++++ b/qtbase/src/gui/painting/qpaintengine_raster.cpp
+@@ -560,31 +560,6 @@ void QRasterPaintEngine::updateMatrix(const QTransform &matrix)
+     QRasterPaintEngineState *s = state();
+     // FALCON: get rid of this line, see drawImage call below.
+     s->matrix = matrix;
+-    QTransform::TransformationType txop = s->matrix.type();
+-
+-    switch (txop) {
+-
+-    case QTransform::TxNone:
+-        s->flags.int_xform = true;
+-        break;
+-
+-    case QTransform::TxTranslate:
+-        s->flags.int_xform = qreal(int(s->matrix.dx())) == s->matrix.dx()
+-                            && qreal(int(s->matrix.dy())) == s->matrix.dy();
+-        break;
+-
+-    case QTransform::TxScale:
+-        s->flags.int_xform = qreal(int(s->matrix.dx())) == s->matrix.dx()
+-                            && qreal(int(s->matrix.dy())) == s->matrix.dy()
+-                            && qreal(int(s->matrix.m11())) == s->matrix.m11()
+-                            && qreal(int(s->matrix.m22())) == s->matrix.m22();
+-        break;
+-
+-    default: // shear / perspective...
+-        s->flags.int_xform = false;
+-        break;
+-    }
+-
+     s->flags.tx_noshear = qt_scaleForTransform(s->matrix, &s->txscale);
+ 
+     ensureOutlineMapper();
+@@ -617,7 +592,6 @@ QRasterPaintEngineState::QRasterPaintEngineState()
+     flags.bilinear = false;
+     flags.legacy_rounding = false;
+     flags.fast_text = true;
+-    flags.int_xform = true;
+     flags.tx_noshear = true;
+     flags.fast_images = true;
+ 
+@@ -1793,7 +1767,7 @@ void QRasterPaintEngine::fill(const QVectorPath &path, const QBrush &brush)
+     QRectF cpRect = path.controlPointRect();
+     const QRectF pathDeviceRect = s->matrix.mapRect(cpRect);
+     // Skip paths that by conservative estimates are completely outside the paint device.
+-    if (!pathDeviceRect.intersects(QRectF(d->deviceRect)))
++    if (!pathDeviceRect.intersects(QRectF(d->deviceRect)) || !pathDeviceRect.isValid())
+         return;
+ 
+     ProcessSpans blend = d->getBrushFunc(pathDeviceRect, &s->brushData);
+diff --git a/qtbase/src/gui/painting/qpaintengine_raster_p.h b/qtbase/src/gui/painting/qpaintengine_raster_p.h
+index 089aadc3f7..bf7363d5aa 100644
+--- a/qtbase/src/gui/painting/qpaintengine_raster_p.h
++++ b/qtbase/src/gui/painting/qpaintengine_raster_p.h
+@@ -111,7 +111,6 @@ public:
+         uint bilinear : 1;
+         uint legacy_rounding : 1;
+         uint fast_text : 1;
+-        uint int_xform : 1;
+         uint tx_noshear : 1;
+         uint fast_images : 1;
+     };
+diff --git a/qtbase/src/gui/painting/qpainterpath.cpp b/qtbase/src/gui/painting/qpainterpath.cpp
+index f9544a3241..d80fafeaf1 100644
+--- a/qtbase/src/gui/painting/qpainterpath.cpp
++++ b/qtbase/src/gui/painting/qpainterpath.cpp
+@@ -1253,7 +1253,7 @@ void QPainterPath::addText(const QPointF &point, const QFont &f, const QString &
+ 
+         if (si.analysis.flags < QScriptAnalysis::TabOrObject) {
+             QGlyphLayout glyphs = eng->shapedGlyphs(&si);
+-            QFontEngine *fe = f.d->engineForScript(si.analysis.script);
++            QFontEngine *fe = eng->fontEngine(si);
+             Q_ASSERT(fe);
+             fe->addOutlineToPath(x, y, glyphs, this,
+                                  si.analysis.bidiLevel % 2
+diff --git a/qtbase/src/gui/painting/qpathclipper_p.h b/qtbase/src/gui/painting/qpathclipper_p.h
+index 9444a87b71..18f64c5e8c 100644
+--- a/qtbase/src/gui/painting/qpathclipper_p.h
++++ b/qtbase/src/gui/painting/qpathclipper_p.h
+@@ -156,7 +156,7 @@ public:
+     int vertex(Direction direction) const;
+ 
+ private:
+-    int m_next[2][2];
++    int m_next[2][2] = { { -1, -1 }, { -1, -1 } };
+ };
+ 
+ class QPathSegments
+@@ -296,10 +296,6 @@ inline QPathEdge::QPathEdge(int a, int b)
+     , angle(0)
+     , invAngle(0)
+ {
+-    m_next[0][0] = -1;
+-    m_next[1][0] = -1;
+-    m_next[0][0] = -1;
+-    m_next[1][0] = -1;
+ }
+ 
+ inline int QPathEdge::next(Traversal traversal, Direction direction) const
+diff --git a/qtbase/src/gui/painting/qpdf.cpp b/qtbase/src/gui/painting/qpdf.cpp
+index 3066744f1b..2c8d3c3b53 100644
+--- a/qtbase/src/gui/painting/qpdf.cpp
++++ b/qtbase/src/gui/painting/qpdf.cpp
+@@ -2760,6 +2760,8 @@ int QPdfEnginePrivate::addBrushPattern(const QTransform &m, bool *specifyColor,
+         return gradientBrush(brush, matrix, gStateObject);
+     }
+ 
++    matrix = brush.transform() * matrix;
++
+     if ((!brush.isOpaque() && brush.style() < Qt::LinearGradientPattern) || opacity != 1.0)
+         *gStateObject = addConstantAlphaObject(qRound(brush.color().alpha() * opacity),
+                                                qRound(pen.color().alpha() * opacity));
+diff --git a/qtbase/src/gui/painting/qstroker.cpp b/qtbase/src/gui/painting/qstroker.cpp
+index cb5d395e80..3b6357a893 100644
+--- a/qtbase/src/gui/painting/qstroker.cpp
++++ b/qtbase/src/gui/painting/qstroker.cpp
+@@ -1182,6 +1182,7 @@ void QDashStroker::processCurrentSubpath()
+         // Check if the entire line should be clipped away or simplified
+         bool clipIt = clipping && !lineIntersectsRect(prev, e, clip_tl, clip_br);
+         bool skipDashing = elen * invSumLength > repetitionLimit();
++        int maxDashes = dashCount;
+         if (skipDashing || clipIt) {
+             // Cut away full dash sequences.
+             elen -= std::floor(elen * invSumLength) * sumLength;
+@@ -1196,7 +1197,7 @@ void QDashStroker::processCurrentSubpath()
+                     pos = estop; // move pos to next path element
+                     done = true;
+                 } else { // Dash is on this line
+-                    pos = dpos + estart;
++                    pos = --maxDashes > 0 ? dpos + estart : estop;
+                     done = pos >= estop;
+                     if (++idash >= dashCount)
+                         idash = 0;
+diff --git a/qtbase/src/gui/painting/qt_attribution.json b/qtbase/src/gui/painting/qt_attribution.json
+index 7b16e8c211..0e87d30aa2 100644
+--- a/qtbase/src/gui/painting/qt_attribution.json
++++ b/qtbase/src/gui/painting/qt_attribution.json
+@@ -10,7 +10,7 @@
+         "Homepage": "http://www.freetype.org",
+         "License": "Freetype Project License or GNU General Public License v2.0 only",
+         "LicenseId": "FTL or GPL-2.0",
+-        "LicenseFile": "../../3rdparty/freetype/docs/LICENSE.TXT",
++        "LicenseFile": "../../3rdparty/freetype/LICENSE.TXT",
+         "Copyright": "Copyright 2000-2016 by David Turner, Robert Wilhelm, and Werner Lemberg."
+     },
+     {
+diff --git a/qtbase/src/gui/rhi/qshader_p_p.h b/qtbase/src/gui/rhi/qshader_p_p.h
+index ec9d25971f..4a5a7a6d51 100644
+--- a/qtbase/src/gui/rhi/qshader_p_p.h
++++ b/qtbase/src/gui/rhi/qshader_p_p.h
+@@ -68,13 +68,13 @@ struct Q_GUI_EXPORT QShaderPrivate
+     {
+     }
+ 
+-    QShaderPrivate(const QShaderPrivate *other)
++    QShaderPrivate(const QShaderPrivate &other)
+         : ref(1),
+-          qsbVersion(other->qsbVersion),
+-          stage(other->stage),
+-          desc(other->desc),
+-          shaders(other->shaders),
+-          bindings(other->bindings)
++          qsbVersion(other.qsbVersion),
++          stage(other.stage),
++          desc(other.desc),
++          shaders(other.shaders),
++          bindings(other.bindings)
+     {
+     }
+ 
+diff --git a/qtbase/src/gui/rhi/qshaderdescription_p_p.h b/qtbase/src/gui/rhi/qshaderdescription_p_p.h
+index ec2b0b6b4c..3da33a8a2b 100644
+--- a/qtbase/src/gui/rhi/qshaderdescription_p_p.h
++++ b/qtbase/src/gui/rhi/qshaderdescription_p_p.h
+@@ -63,16 +63,16 @@ struct Q_GUI_EXPORT QShaderDescriptionPrivate
+         localSize[0] = localSize[1] = localSize[2] = 0;
+     }
+ 
+-    QShaderDescriptionPrivate(const QShaderDescriptionPrivate *other)
++    QShaderDescriptionPrivate(const QShaderDescriptionPrivate &other)
+         : ref(1),
+-          inVars(other->inVars),
+-          outVars(other->outVars),
+-          uniformBlocks(other->uniformBlocks),
+-          pushConstantBlocks(other->pushConstantBlocks),
+-          storageBlocks(other->storageBlocks),
+-          combinedImageSamplers(other->combinedImageSamplers),
+-          storageImages(other->storageImages),
+-          localSize(other->localSize)
++          inVars(other.inVars),
++          outVars(other.outVars),
++          uniformBlocks(other.uniformBlocks),
++          pushConstantBlocks(other.pushConstantBlocks),
++          storageBlocks(other.storageBlocks),
++          combinedImageSamplers(other.combinedImageSamplers),
++          storageImages(other.storageImages),
++          localSize(other.localSize)
+     {
+     }
+ 
+diff --git a/qtbase/src/gui/text/qfontdatabase.cpp b/qtbase/src/gui/text/qfontdatabase.cpp
+index a657a8c516..4fc0100958 100644
+--- a/qtbase/src/gui/text/qfontdatabase.cpp
++++ b/qtbase/src/gui/text/qfontdatabase.cpp
+@@ -983,7 +983,7 @@ QFontEngine *loadSingleEngine(int script,
+         if (style->key.stretch != 0 && request.stretch != 0
+             && (request.styleName.isEmpty() || request.styleName != style->styleName)) {
+             def.stretch = (request.stretch * 100 + style->key.stretch / 2) / style->key.stretch;
+-        } else {
++        } else if (request.stretch == QFont::AnyStretch) {
+             def.stretch = 100;
+         }
+ 
+diff --git a/qtbase/src/gui/text/qtextdocumentlayout.cpp b/qtbase/src/gui/text/qtextdocumentlayout.cpp
+index f3e6ea2100..72267e9380 100644
+--- a/qtbase/src/gui/text/qtextdocumentlayout.cpp
++++ b/qtbase/src/gui/text/qtextdocumentlayout.cpp
+@@ -2123,7 +2123,7 @@ void QTextDocumentLayoutPrivate::drawListItem(const QPointF &offset, QPainter *p
+ {
+     Q_Q(const QTextDocumentLayout);
+     const QTextBlockFormat blockFormat = bl.blockFormat();
+-    const QTextCharFormat charFormat = QTextCursor(bl).charFormat();
++    const QTextCharFormat charFormat = bl.charFormat();
+     QFont font(charFormat.font());
+     if (q->paintDevice())
+         font = QFont(font, q->paintDevice());
+diff --git a/qtbase/src/gui/text/qtextengine.cpp b/qtbase/src/gui/text/qtextengine.cpp
+index ce4abac472..a6c66e5d2d 100644
+--- a/qtbase/src/gui/text/qtextengine.cpp
++++ b/qtbase/src/gui/text/qtextengine.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2021 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtGui module of the Qt Toolkit.
+@@ -1565,6 +1565,12 @@ void QTextEngine::shapeText(int item) const
+         // Overwrite with 0 token to indicate failure
+         QGlyphLayout g = availableGlyphs(&si);
+         g.glyphs[0] = 0;
++        g.attributes[0].clusterStart = true;
++
++        ushort *log_clusters = logClusters(&si);
++        for (int i = 0; i < itemLength; ++i)
++            log_clusters[i] = 0;
++
+         return;
+     }
+ 
+diff --git a/qtbase/src/gui/util/qdesktopservices.cpp b/qtbase/src/gui/util/qdesktopservices.cpp
+index fbb63a9408..4d5fafaaa7 100644
+--- a/qtbase/src/gui/util/qdesktopservices.cpp
++++ b/qtbase/src/gui/util/qdesktopservices.cpp
+@@ -54,6 +54,8 @@
+ #include <qpa/qplatformintegration.h>
+ #include <qdir.h>
+ 
++#include <QtCore/private/qlocking_p.h>
++
+ QT_BEGIN_NAMESPACE
+ 
+ class QOpenUrlHandlerRegistry : public QObject
+@@ -81,6 +83,7 @@ Q_GLOBAL_STATIC(QOpenUrlHandlerRegistry, handlerRegistry)
+ 
+ void QOpenUrlHandlerRegistry::handlerDestroyed(QObject *handler)
+ {
++    const auto lock = qt_scoped_lock(mutex);
+     HandlerHash::Iterator it = handlers.begin();
+     while (it != handlers.end()) {
+         if (it->receiver == handler) {
+@@ -294,7 +297,8 @@ void QDesktopServices::setUrlHandler(const QString &scheme, QObject *receiver, c
+     h.name = method;
+     registry->handlers.insert(scheme.toLower(), h);
+     QObject::connect(receiver, SIGNAL(destroyed(QObject*)),
+-                     registry, SLOT(handlerDestroyed(QObject*)));
++                     registry, SLOT(handlerDestroyed(QObject*)),
++                     Qt::DirectConnection);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/gui/util/qpkmhandler.cpp b/qtbase/src/gui/util/qpkmhandler.cpp
+index e0c3b75efe..3414f9d8ba 100644
+--- a/qtbase/src/gui/util/qpkmhandler.cpp
++++ b/qtbase/src/gui/util/qpkmhandler.cpp
+@@ -57,7 +57,7 @@ struct PkmType
+     quint32 bytesPerBlock;
+ };
+ 
+-static PkmType typeMap[5] = {
++static constexpr PkmType typeMap[5] = {
+     { 0x8D64,  8 },   // GL_ETC1_RGB8_OES
+     { 0x9274,  8 },   // GL_COMPRESSED_RGB8_ETC2
+     { 0, 0 },         // unused (obsolete)
+diff --git a/qtbase/src/network/access/qnetworkreplyfileimpl.cpp b/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
+index b6be93147a..6e69b4c4d3 100644
+--- a/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
++++ b/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
+@@ -89,9 +89,10 @@ QNetworkReplyFileImpl::QNetworkReplyFileImpl(QNetworkAccessManager *manager, con
+         // we handle only local files
+         QString msg = QCoreApplication::translate("QNetworkAccessFileBackend", "Request for opening non-local file %1").arg(url.toString());
+         setError(QNetworkReply::ProtocolInvalidOperationError, msg);
++        setFinished(true); // We're finished, will emit finished() after ctor is done.
+         QMetaObject::invokeMethod(this, "errorOccurred", Qt::QueuedConnection,
+             Q_ARG(QNetworkReply::NetworkError, QNetworkReply::ProtocolInvalidOperationError));
+-        fileOpenFinished(false);
++        QMetaObject::invokeMethod(this, [this](){ fileOpenFinished(false); }, Qt::QueuedConnection);
+         return;
+     }
+ #endif
+diff --git a/qtbase/src/network/access/qnetworkreplyimpl.cpp b/qtbase/src/network/access/qnetworkreplyimpl.cpp
+index bcdf6ee2f1..3b6deb82bd 100644
+--- a/qtbase/src/network/access/qnetworkreplyimpl.cpp
++++ b/qtbase/src/network/access/qnetworkreplyimpl.cpp
+@@ -680,7 +680,7 @@ void QNetworkReplyImplPrivate::appendDownstreamData(QIODevice *data)
+     // read until EOF from data
+     if (Q_UNLIKELY(copyDevice)) {
+         qCritical("QNetworkReplyImpl: copy from QIODevice already in progress -- "
+-                  "backend probly needs to be fixed");
++                  "backend probably needs to be fixed");
+         return;
+     }
+ 
+diff --git a/qtbase/src/network/kernel/qauthenticator.cpp b/qtbase/src/network/kernel/qauthenticator.cpp
+index d9fe7bc47b..ccd04b294a 100644
+--- a/qtbase/src/network/kernel/qauthenticator.cpp
++++ b/qtbase/src/network/kernel/qauthenticator.cpp
+@@ -50,6 +50,7 @@
+ #include <qstring.h>
+ #include <qdatetime.h>
+ #include <qrandom.h>
++#include "private/qsystemlibrary_p.h"
+ 
+ #ifdef Q_OS_WIN
+ #include <qmutex.h>
+@@ -1563,7 +1564,7 @@ static bool q_SSPI_library_load()
+ 
+     // Initialize security interface
+     if (pSecurityFunctionTable == nullptr) {
+-        securityDLLHandle = LoadLibrary(L"secur32.dll");
++        securityDLLHandle = QSystemLibrary::load(L"secur32");
+         if (securityDLLHandle != nullptr) {
+             INIT_SECURITY_INTERFACE pInitSecurityInterface =
+                 reinterpret_cast<INIT_SECURITY_INTERFACE>(
+diff --git a/qtbase/src/network/kernel/qhostinfo_unix.cpp b/qtbase/src/network/kernel/qhostinfo_unix.cpp
+index 9b0a2ee669..73679c9ef1 100644
+--- a/qtbase/src/network/kernel/qhostinfo_unix.cpp
++++ b/qtbase/src/network/kernel/qhostinfo_unix.cpp
+@@ -122,7 +122,6 @@ static QFunctionPointer resolveSymbol(QLibrary &lib, const char *sym)
+ 
+ LibResolv::LibResolv()
+ {
+-    QLibrary lib;
+ #ifdef LIBRESOLV_SO
+     lib.setFileName(QStringLiteral(LIBRESOLV_SO));
+     if (!lib.load())
+diff --git a/qtbase/src/network/socket/qsocks5socketengine.cpp b/qtbase/src/network/socket/qsocks5socketengine.cpp
+index 3a046fd116..97fadca0b3 100644
+--- a/qtbase/src/network/socket/qsocks5socketengine.cpp
++++ b/qtbase/src/network/socket/qsocks5socketengine.cpp
+@@ -1296,7 +1296,7 @@ void QSocks5SocketEnginePrivate::_q_udpSocketReadNotification()
+         int pos = 0;
+         const char *buf = inBuf.constData();
+         if (inBuf.size() < 4) {
+-            QSOCKS5_D_DEBUG << "bugus udp data, discarding";
++            QSOCKS5_D_DEBUG << "bogus udp data, discarding";
+             return;
+         }
+         QSocks5RevivedDatagram datagram;
+diff --git a/qtbase/src/network/ssl/qsslcontext_openssl.cpp b/qtbase/src/network/ssl/qsslcontext_openssl.cpp
+index c9f202f573..c992da9d8e 100644
+--- a/qtbase/src/network/ssl/qsslcontext_openssl.cpp
++++ b/qtbase/src/network/ssl/qsslcontext_openssl.cpp
+@@ -409,7 +409,7 @@ init_context:
+         break;
+     case QSsl::DtlsV1_0OrLater:
+         minVersion = DTLS1_VERSION;
+-        maxVersion = DTLS_MAX_VERSION;
++        maxVersion = 0;
+         break;
+     case QSsl::DtlsV1_2:
+         minVersion = DTLS1_2_VERSION;
+@@ -417,7 +417,7 @@ init_context:
+         break;
+     case QSsl::DtlsV1_2OrLater:
+         minVersion = DTLS1_2_VERSION;
+-        maxVersion = DTLS_MAX_VERSION;
++        maxVersion = 0;
+         break;
+     case QSsl::TlsV1_3OrLater:
+ #ifdef TLS1_3_VERSION
+@@ -455,7 +455,7 @@ init_context:
+     }
+ 
+     // Enable bug workarounds.
+-    long options = QSslSocketBackendPrivate::setupOpenSslOptions(configuration.protocol(), configuration.d->sslOptions);
++    qssloptions options = QSslSocketBackendPrivate::setupOpenSslOptions(configuration.protocol(), configuration.d->sslOptions);
+     q_SSL_CTX_set_options(sslContext->ctx, options);
+ 
+     // Tell OpenSSL to release memory early
+diff --git a/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp b/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
+index aaf8741130..b58935372c 100644
+--- a/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
++++ b/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
+@@ -59,57 +59,6 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-#ifdef OPENSSL_NO_DEPRECATED_3_0
+-
+-static int q_DH_check(DH *dh, int *status)
+-{
+-    // DH_check was first deprecated in OpenSSL 3.0.0, as low-level
+-    // API; the EVP_PKEY family of functions was advised as an alternative.
+-    // As of now EVP_PKEY_params_check ends up calling ... DH_check,
+-    // which is good enough.
+-
+-    Q_ASSERT(dh);
+-    Q_ASSERT(status);
+-
+-    EVP_PKEY *key = q_EVP_PKEY_new();
+-    if (!key) {
+-        qCWarning(lcSsl, "EVP_PKEY_new failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-    const auto keyDeleter = qScopeGuard([key](){
+-        q_EVP_PKEY_free(key);
+-    });
+-    if (!q_EVP_PKEY_set1_DH(key, dh)) {
+-        qCWarning(lcSsl, "EVP_PKEY_set1_DH failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-
+-    EVP_PKEY_CTX *keyCtx = q_EVP_PKEY_CTX_new(key, nullptr);
+-    if (!keyCtx) {
+-        qCWarning(lcSsl, "EVP_PKEY_CTX_new failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-    const auto ctxDeleter = qScopeGuard([keyCtx]{
+-        q_EVP_PKEY_CTX_free(keyCtx);
+-    });
+-
+-    const int result = q_EVP_PKEY_param_check(keyCtx);
+-    QSslSocketBackendPrivate::logAndClearErrorQueue();
+-    // Note: unlike DH_check, we cannot obtain the 'status',
+-    // if the 'result' is 0 (actually the result is 1 only
+-    // if this 'status' was 0). We could probably check the
+-    // errors from the error queue, but it's not needed anyway
+-    // - see the 'isSafeDH' below, how it returns immediately
+-    // on 0.
+-    Q_UNUSED(status)
+-
+-    return result;
+-}
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+-
+ static bool isSafeDH(DH *dh)
+ {
+     int status = 0;
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl.cpp b/qtbase/src/network/ssl/qsslsocket_openssl.cpp
+index 37fad2a68f..8f6858c867 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl.cpp
++++ b/qtbase/src/network/ssl/qsslsocket_openssl.cpp
+@@ -550,9 +550,9 @@ static void q_loadCiphersForConnection(SSL *connection, QList<QSslCipher> &ciphe
+ // Defined in qsslsocket.cpp
+ void q_setDefaultDtlsCiphers(const QList<QSslCipher> &ciphers);
+ 
+-long QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions)
++qssloptions QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions)
+ {
+-    long options;
++    qssloptions options;
+     if (protocol == QSsl::TlsV1SslV3)
+         options = SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3;
+     else if (protocol == QSsl::SecureProtocols)
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_p.h b/qtbase/src/network/ssl/qsslsocket_openssl_p.h
+index 4103de23e8..5547589256 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_p.h
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_p.h
+@@ -107,6 +107,12 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++typedef uint64_t qssloptions;
++#else
++typedef unsigned long qssloptions;
++#endif
++
+ struct QSslErrorEntry {
+     int code;
+     int depth;
+@@ -171,7 +177,7 @@ public:
+     QVector<QSslError> ocspErrors;
+     QByteArray ocspResponseDer;
+ 
+-    Q_AUTOTEST_EXPORT static long setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions);
++    Q_AUTOTEST_EXPORT static qssloptions setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions);
+     static QSslCipher QSslCipher_from_SSL_CIPHER(const SSL_CIPHER *cipher);
+     static QList<QSslCertificate> STACKOFX509_to_QSslCertificates(STACK_OF(X509) *x509);
+     static QList<QSslError> verify(const QList<QSslCertificate> &certificateChain, const QString &hostName);
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp b/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
+index e53fb279f0..459ccd0b19 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
+@@ -148,7 +148,6 @@ DEFINEFUNC(int, EVP_PKEY_up_ref, EVP_PKEY *a, a, return 0, return)
+ DEFINEFUNC2(EVP_PKEY_CTX *, EVP_PKEY_CTX_new, EVP_PKEY *pkey, pkey, ENGINE *e, e, return nullptr, return)
+ DEFINEFUNC(int, EVP_PKEY_param_check, EVP_PKEY_CTX *ctx, ctx, return 0, return)
+ DEFINEFUNC(void, EVP_PKEY_CTX_free, EVP_PKEY_CTX *ctx, ctx, return, return)
+-DEFINEFUNC(int, EVP_PKEY_base_id, EVP_PKEY *a, a, return NID_undef, return)
+ DEFINEFUNC(int, RSA_bits, RSA *a, a, return 0, return)
+ DEFINEFUNC(int, DSA_bits, DSA *a, a, return 0, return)
+ DEFINEFUNC(int, OPENSSL_sk_num, OPENSSL_STACK *a, a, return -1, return)
+@@ -158,7 +157,7 @@ DEFINEFUNC2(void, OPENSSL_sk_push, OPENSSL_STACK *a, a, void *b, b, return, DUMM
+ DEFINEFUNC(void, OPENSSL_sk_free, OPENSSL_STACK *a, a, return, DUMMYARG)
+ DEFINEFUNC2(void *, OPENSSL_sk_value, OPENSSL_STACK *a, a, int b, b, return nullptr, return)
+ DEFINEFUNC(int, SSL_session_reused, SSL *a, a, return 0, return)
+-DEFINEFUNC2(unsigned long, SSL_CTX_set_options, SSL_CTX *ctx, ctx, unsigned long op, op, return 0, return)
++DEFINEFUNC2(qssloptions, SSL_CTX_set_options, SSL_CTX *ctx, ctx, qssloptions op, op, return 0, return)
+ DEFINEFUNC(int, SSL_CTX_get_security_level, const SSL_CTX *ctx, ctx, return -1, return)
+ DEFINEFUNC2(void, SSL_CTX_set_security_level, SSL_CTX *ctx, ctx, int level, level, return, return)
+ #ifdef TLS1_3_VERSION
+@@ -371,7 +370,15 @@ DEFINEFUNC(const SSL_CIPHER *, SSL_get_current_cipher, SSL *a, a, return nullptr
+ DEFINEFUNC(int, SSL_version, const SSL *a, a, return 0, return)
+ DEFINEFUNC2(int, SSL_get_error, SSL *a, a, int b, b, return -1, return)
+ DEFINEFUNC(STACK_OF(X509) *, SSL_get_peer_cert_chain, SSL *a, a, return nullptr, return)
++
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++DEFINEFUNC(X509 *, SSL_get1_peer_certificate, SSL *a, a, return nullptr, return)
++DEFINEFUNC(int, EVP_PKEY_get_base_id, const EVP_PKEY *pkey, pkey, return -1, return)
++#else
+ DEFINEFUNC(X509 *, SSL_get_peer_certificate, SSL *a, a, return nullptr, return)
++DEFINEFUNC(int, EVP_PKEY_base_id, EVP_PKEY *a, a, return NID_undef, return)
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+ DEFINEFUNC(long, SSL_get_verify_result, const SSL *a, a, return -1, return)
+ DEFINEFUNC(SSL *, SSL_new, SSL_CTX *a, a, return nullptr, return)
+ DEFINEFUNC(SSL_CTX *, SSL_get_SSL_CTX, SSL *a, a, return nullptr, return)
+@@ -492,9 +499,7 @@ DEFINEFUNC(DH *, DH_new, DUMMYARG, DUMMYARG, return nullptr, return)
+ DEFINEFUNC(void, DH_free, DH *dh, dh, return, DUMMYARG)
+ DEFINEFUNC3(DH *, d2i_DHparams, DH**a, a, const unsigned char **pp, pp, long length, length, return nullptr, return)
+ DEFINEFUNC2(int, i2d_DHparams, DH *a, a, unsigned char **p, p, return -1, return)
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+ DEFINEFUNC2(int, DH_check, DH *dh, dh, int *codes, codes, return 0, return)
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+ DEFINEFUNC3(BIGNUM *, BN_bin2bn, const unsigned char *s, s, int len, len, BIGNUM *ret, ret, return nullptr, return)
+ 
+ #ifndef OPENSSL_NO_EC
+@@ -868,7 +873,6 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(EVP_PKEY_CTX_new)
+     RESOLVEFUNC(EVP_PKEY_param_check)
+     RESOLVEFUNC(EVP_PKEY_CTX_free)
+-    RESOLVEFUNC(EVP_PKEY_base_id)
+     RESOLVEFUNC(RSA_bits)
+     RESOLVEFUNC(OPENSSL_sk_new_null)
+     RESOLVEFUNC(OPENSSL_sk_push)
+@@ -1107,7 +1111,15 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(SSL_version)
+     RESOLVEFUNC(SSL_get_error)
+     RESOLVEFUNC(SSL_get_peer_cert_chain)
++
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++    RESOLVEFUNC(SSL_get1_peer_certificate)
++    RESOLVEFUNC(EVP_PKEY_get_base_id)
++#else
+     RESOLVEFUNC(SSL_get_peer_certificate)
++    RESOLVEFUNC(EVP_PKEY_base_id)
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+     RESOLVEFUNC(SSL_get_verify_result)
+     RESOLVEFUNC(SSL_new)
+     RESOLVEFUNC(SSL_get_SSL_CTX)
+@@ -1206,9 +1218,7 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(DH_free)
+     RESOLVEFUNC(d2i_DHparams)
+     RESOLVEFUNC(i2d_DHparams)
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+     RESOLVEFUNC(DH_check)
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+     RESOLVEFUNC(BN_bin2bn)
+ 
+ #ifndef OPENSSL_NO_EC
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h b/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
+index 95e8897a3b..27aeffa18a 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
+@@ -237,7 +237,6 @@ Q_AUTOTEST_EXPORT int q_EVP_PKEY_up_ref(EVP_PKEY *a);
+ EVP_PKEY_CTX *q_EVP_PKEY_CTX_new(EVP_PKEY *pkey, ENGINE *e);
+ void q_EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx);
+ int q_EVP_PKEY_param_check(EVP_PKEY_CTX *ctx);
+-int q_EVP_PKEY_base_id(EVP_PKEY *a);
+ int q_RSA_bits(RSA *a);
+ Q_AUTOTEST_EXPORT int q_OPENSSL_sk_num(OPENSSL_STACK *a);
+ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_pop_free(OPENSSL_STACK *a, void (*b)(void *));
+@@ -246,7 +245,7 @@ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_push(OPENSSL_STACK *st, void *data);
+ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_free(OPENSSL_STACK *a);
+ Q_AUTOTEST_EXPORT void * q_OPENSSL_sk_value(OPENSSL_STACK *a, int b);
+ int q_SSL_session_reused(SSL *a);
+-unsigned long q_SSL_CTX_set_options(SSL_CTX *ctx, unsigned long op);
++qssloptions q_SSL_CTX_set_options(SSL_CTX *ctx, qssloptions op);
+ int q_OPENSSL_init_ssl(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings);
+ size_t q_SSL_get_client_random(SSL *a, unsigned char *out, size_t outlen);
+ size_t q_SSL_SESSION_get_master_key(const SSL_SESSION *session, unsigned char *out, size_t outlen);
+@@ -510,7 +509,6 @@ const SSL_CIPHER *q_SSL_get_current_cipher(SSL *a);
+ int q_SSL_version(const SSL *a);
+ int q_SSL_get_error(SSL *a, int b);
+ STACK_OF(X509) *q_SSL_get_peer_cert_chain(SSL *a);
+-X509 *q_SSL_get_peer_certificate(SSL *a);
+ long q_SSL_get_verify_result(const SSL *a);
+ SSL *q_SSL_new(SSL_CTX *a);
+ SSL_CTX *q_SSL_get_SSL_CTX(SSL *a);
+@@ -582,10 +580,7 @@ DH *q_DH_new();
+ void q_DH_free(DH *dh);
+ DH *q_d2i_DHparams(DH **a, const unsigned char **pp, long length);
+ int q_i2d_DHparams(DH *a, unsigned char **p);
+-
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+ int q_DH_check(DH *dh, int *codes);
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+ 
+ BIGNUM *q_BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret);
+ #define q_SSL_CTX_set_tmp_dh(ctx, dh) q_SSL_CTX_ctrl((ctx), SSL_CTRL_SET_TMP_DH, 0, (char *)dh)
+@@ -754,6 +749,17 @@ void q_CRYPTO_free(void *str, const char *file, int line);
+ int q_SSL_CTX_get_security_level(const SSL_CTX *ctx);
+ void q_SSL_CTX_set_security_level(SSL_CTX *ctx, int level);
+ 
++// Here we have the ones that make difference between OpenSSL pre/post v3:
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++X509 *q_SSL_get1_peer_certificate(SSL *a);
++#define q_SSL_get_peer_certificate q_SSL_get1_peer_certificate
++int q_EVP_PKEY_get_base_id(const EVP_PKEY *pkey);
++#define q_EVP_PKEY_base_id q_EVP_PKEY_get_base_id
++#else
++X509 *q_SSL_get_peer_certificate(SSL *a);
++int q_EVP_PKEY_base_id(EVP_PKEY *a);
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+ QT_END_NAMESPACE
+ 
+ #endif
+diff --git a/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h b/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
+index bf37d07fd8..dbd42fb799 100644
+--- a/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
++++ b/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
+@@ -61,7 +61,11 @@
+ # if !defined(Q_OS_INTEGRITY)
+ #  define WIN_INTERFACE_CUSTOM   // NV
+ # endif // Q_OS_INTEGRITY
+-#endif  // QT_EGL_NO_X11
++#else // QT_EGL_NO_X11
++// If one has an eglplatform.h with https://github.com/KhronosGroup/EGL-Registry/pull/130
++// that needs USE_X11 to be defined.
++# define USE_X11
++#endif
+ 
+ #ifdef QT_EGL_WAYLAND
+ # define WAYLAND // NV
+diff --git a/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+index 159b490ce0..00aa80cd58 100644
+--- a/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
++++ b/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+@@ -567,6 +567,8 @@ void QFontconfigDatabase::populateFontDatabase()
+         fonts = FcFontList(nullptr, pattern, os);
+         FcObjectSetDestroy(os);
+         FcPatternDestroy(pattern);
++        if (!fonts)
++            return;
+     }
+ 
+     for (int i = 0; i < fonts->nfont; i++)
+diff --git a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
+index b713c19447..7cb9a8c79a 100644
+--- a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
++++ b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
+@@ -95,6 +95,7 @@ static constexpr const auto KeyTbl = qMakeArray(
+         Xkb2Qt<XKB_KEY_Clear,                   Qt::Key_Delete>,
+         Xkb2Qt<XKB_KEY_Pause,                   Qt::Key_Pause>,
+         Xkb2Qt<XKB_KEY_Print,                   Qt::Key_Print>,
++        Xkb2Qt<XKB_KEY_Sys_Req,                 Qt::Key_SysReq>,
+         Xkb2Qt<0x1005FF60,                      Qt::Key_SysReq>,         // hardcoded Sun SysReq
+         Xkb2Qt<0x1007ff00,                      Qt::Key_SysReq>,         // hardcoded X386 SysReq
+ 
+@@ -471,7 +472,7 @@ QVector<xkb_keysym_t> QXkbCommon::toKeysym(QKeyEvent *event)
+     } else if (event->modifiers() & Qt::KeypadModifier) {
+         if (qtKey >= Qt::Key_0 && qtKey <= Qt::Key_9)
+             keysyms.append(XKB_KEY_KP_0 + (qtKey - Qt::Key_0));
+-    } else if (isLatin(qtKey) && event->text().isUpper()) {
++    } else if (isLatin1(qtKey) && event->text().isUpper()) {
+         keysyms.append(qtKey);
+     }
+ 
+@@ -523,7 +524,7 @@ int QXkbCommon::keysymToQtKey(xkb_keysym_t keysym, Qt::KeyboardModifiers modifie
+         // With standard shortcuts we should prefer a latin character, this is
+         // for checks like "some qkeyevent == QKeySequence::Copy" to work even
+         // when using for example 'russian' keyboard layout.
+-        if (!QXkbCommon::isLatin(keysym)) {
++        if (!QXkbCommon::isLatin1(keysym)) {
+             xkb_keysym_t latinKeysym = QXkbCommon::lookupLatinKeysym(state, code);
+             if (latinKeysym != XKB_KEY_NoSymbol)
+                 keysym = latinKeysym;
+@@ -546,7 +547,7 @@ static int keysymToQtKey_internal(xkb_keysym_t keysym, Qt::KeyboardModifiers mod
+     } else if (keysym >= XKB_KEY_KP_0 && keysym <= XKB_KEY_KP_9) {
+         // numeric keypad keys
+         qtKey = Qt::Key_0 + (keysym - XKB_KEY_KP_0);
+-    } else if (QXkbCommon::isLatin(keysym)) {
++    } else if (QXkbCommon::isLatin1(keysym)) {
+         qtKey = QXkbCommon::qxkbcommon_xkb_keysym_to_upper(keysym);
+     } else {
+         // check if we have a direct mapping
+@@ -678,7 +679,7 @@ QList<int> QXkbCommon::possibleKeys(xkb_state *state, const QKeyEvent *event,
+         Qt::KeyboardModifiers neededMods = ModsTbl[i];
+         if ((modifiers & neededMods) == neededMods) {
+             if (i == 8) {
+-                if (isLatin(baseQtKey))
++                if (isLatin1(baseQtKey))
+                     continue;
+                 // add a latin key as a fall back key
+                 sym = lookupLatinKeysym(state, keycode);
+@@ -733,7 +734,7 @@ void QXkbCommon::verifyHasLatinLayout(xkb_keymap *keymap)
+     for (xkb_layout_index_t layout = 0; layout < layoutCount; ++layout) {
+         for (xkb_keycode_t code = minKeycode; code < maxKeycode; ++code) {
+             xkb_keymap_key_get_syms_by_level(keymap, code, layout, 0, &keysyms);
+-            if (keysyms && isLatin(keysyms[0]))
++            if (keysyms && isLatin1(keysyms[0]))
+                 nrLatinKeys++;
+             if (nrLatinKeys > 10) // arbitrarily chosen threshold
+                 return;
+@@ -766,7 +767,7 @@ xkb_keysym_t QXkbCommon::lookupLatinKeysym(xkb_state *state, xkb_keycode_t keyco
+         xkb_level_index_t level = xkb_state_key_get_level(state, keycode, layout);
+         if (xkb_keymap_key_get_syms_by_level(keymap, keycode, layout, level, &syms) != 1)
+             continue;
+-        if (isLatin(syms[0])) {
++        if (isLatin1(syms[0])) {
+             sym = syms[0];
+             break;
+         }
+diff --git a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
+index 561eae03db..8389bd8f5a 100644
+--- a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
++++ b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
+@@ -94,8 +94,8 @@ public:
+     static void verifyHasLatinLayout(xkb_keymap *keymap);
+     static xkb_keysym_t lookupLatinKeysym(xkb_state *state, xkb_keycode_t keycode);
+ 
+-    static bool isLatin(xkb_keysym_t sym) {
+-        return ((sym >= 'a' && sym <= 'z') || (sym >= 'A' && sym <= 'Z'));
++    static bool isLatin1(xkb_keysym_t sym) {
++        return sym <= 0xff;
+     }
+     static bool isKeypad(xkb_keysym_t sym) {
+         return sym >= XKB_KEY_KP_Space && sym <= XKB_KEY_KP_9;
+diff --git a/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp b/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
+index 8cd7f9b368..406f84663f 100644
+--- a/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
++++ b/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
+@@ -318,7 +318,7 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources,
+ 
+     if (current < 0 && crtc_mode.clock != 0) {
+         modes << crtc_mode;
+-        current = mode.size() - 1;
++        current = modes.size() - 1;
+     }
+ 
+     if (configuration == OutputConfigCurrent)
+diff --git a/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp b/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
+index 9153fd20bb..255ea5e33e 100644
+--- a/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
++++ b/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
+@@ -194,6 +194,9 @@ QString AtSpiAdaptor::introspect(const QString &path) const
+                 "      <arg direction=\"out\" type=\"(so)\"/>\n"
+                 "      <annotation value=\"QSpiObjectReference\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n"
+                 "    </method>\n"
++                "    <method name=\"GetAccessibleId\">\n"
++                "      <arg direction=\"out\" type=\"s\"/>\n"
++                "    </method>\n"
+                 "  </interface>\n"
+                 );
+ 
+@@ -913,8 +916,17 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+     }
+     case QAccessible::NameChanged: {
+         if (sendObject || sendObject_property_change || sendObject_property_change_accessible_name) {
+-            QString path = pathForInterface(event->accessibleInterface());
+-            QVariantList args = packDBusSignalArguments(QLatin1String("accessible-name"), 0, 0, variantForPath(path));
++            QAccessibleInterface *iface = event->accessibleInterface();
++            if (!iface) {
++                qCDebug(lcAccessibilityAtspi,
++                        "NameChanged event from invalid accessible.");
++                return;
++            }
++
++            QString path = pathForInterface(iface);
++            QVariantList args = packDBusSignalArguments(
++                QLatin1String("accessible-name"), 0, 0,
++                QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Name))));
+             sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                            QLatin1String("PropertyChange"), args);
+         }
+@@ -922,8 +934,17 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+     }
+     case QAccessible::DescriptionChanged: {
+         if (sendObject || sendObject_property_change || sendObject_property_change_accessible_description) {
+-            QString path = pathForInterface(event->accessibleInterface());
+-            QVariantList args = packDBusSignalArguments(QLatin1String("accessible-description"), 0, 0, variantForPath(path));
++            QAccessibleInterface *iface = event->accessibleInterface();
++            if (!iface) {
++                qCDebug(lcAccessibilityAtspi,
++                        "DescriptionChanged event from invalid accessible.");
++                return;
++            }
++
++            QString path = pathForInterface(iface);
++            QVariantList args = packDBusSignalArguments(
++                QLatin1String("accessible-description"), 0, 0,
++                QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Description))));
+             sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                            QLatin1String("PropertyChange"), args);
+         }
+@@ -1038,7 +1059,9 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+                 // Combo Box with AT-SPI likes to be special
+                 // It requires a name-change to update caches and then selection-changed
+                 QString path = pathForInterface(iface);
+-                QVariantList args1 = packDBusSignalArguments(QLatin1String("accessible-name"), 0, 0, variantForPath(path));
++                QVariantList args1 = packDBusSignalArguments(
++                    QLatin1String("accessible-name"), 0, 0,
++                    QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Name))));
+                 sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                                QLatin1String("PropertyChange"), args1);
+                 QVariantList args2 = packDBusSignalArguments(QString(), 0, 0, QVariant::fromValue(QDBusVariant(QVariant(0))));
+@@ -1358,6 +1381,26 @@ void AtSpiAdaptor::registerApplication()
+     delete registry;
+ }
+ 
++namespace {
++QString accessibleIdForAccessible(QAccessibleInterface *accessible)
++{
++    QString result;
++    while (accessible) {
++        if (!result.isEmpty())
++            result.prepend(QLatin1Char('.'));
++        if (auto obj = accessible->object()) {
++            const QString name = obj->objectName();
++            if (!name.isEmpty())
++                result.prepend(name);
++            else
++                result.prepend(QString::fromUtf8(obj->metaObject()->className()));
++        }
++        accessible = accessible->parent();
++    }
++    return result;
++}
++} // namespace
++
+ // Accessible
+ bool AtSpiAdaptor::accessibleInterface(QAccessibleInterface *interface, const QString &function, const QDBusMessage &message, const QDBusConnection &connection)
+ {
+@@ -1441,6 +1484,9 @@ bool AtSpiAdaptor::accessibleInterface(QAccessibleInterface *interface, const QS
+             children << ref;
+         }
+         connection.send(message.createReply(QVariant::fromValue(children)));
++    } else if (function == QLatin1String("GetAccessibleId")) {
++        sendReply(connection, message,
++                  QVariant::fromValue(QDBusVariant(accessibleIdForAccessible(interface))));
+     } else {
+         qCDebug(lcAccessibilityAtspi) << "WARNING: AtSpiAdaptor::accessibleInterface does not implement " << function << message.path();
+         return false;
+diff --git a/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp b/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
+index 45ddc8e496..cc734abc63 100644
+--- a/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
++++ b/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
+@@ -69,6 +69,21 @@ QT_BEGIN_NAMESPACE
+ DBusConnection::DBusConnection(QObject *parent)
+     : QObject(parent), m_a11yConnection(QString()), m_enabled(false)
+ {
++    // If the bus is explicitly set via env var it overrides everything else.
++    QByteArray addressEnv = qgetenv("AT_SPI_BUS_ADDRESS");
++    if (!addressEnv.isEmpty()) {
++        // Only connect on next loop run, connections to our enabled signal are
++        // only established after the ctor returns.
++        QMetaObject::invokeMethod(
++                this,
++                [this, addressEnv] {
++                    m_enabled = true;
++                    connectA11yBus(QString::fromLocal8Bit(addressEnv));
++                },
++                Qt::QueuedConnection);
++        return;
++    }
++
+     // Start monitoring if "org.a11y.Bus" is registered as DBus service.
+     QDBusConnection c = QDBusConnection::sessionBus();
+     if (!c.isConnected()) {
+diff --git a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
+index 1a3cab275d..2abe039126 100644
+--- a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
++++ b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
+@@ -51,6 +51,9 @@
+ #include <QtCore/QStandardPaths>
+ #include <QtCore/QUrl>
+ 
++#include <QtGui/QGuiApplication>
++#include <QtGui/QWindow>
++
+ #if QT_CONFIG(dbus)
+ // These QtCore includes are needed for xdg-desktop-portal support
+ #include <QtCore/private/qcore_unix_p.h>
+@@ -58,6 +61,8 @@
+ #include <QtCore/QFileInfo>
+ #include <QtCore/QUrlQuery>
+ 
++#include <QtGui/QColor>
++
+ #include <QtDBus/QDBusConnection>
+ #include <QtDBus/QDBusMessage>
+ #include <QtDBus/QDBusPendingCall>
+@@ -142,6 +147,8 @@ static inline bool detectWebBrowser(const QByteArray &desktop,
+     }
+ 
+     if (desktop == QByteArray("KDE")) {
++        if (checkExecutable(QStringLiteral("kde-open5"), browser))
++            return true;
+         // Konqueror launcher
+         if (checkExecutable(QStringLiteral("kfmclient"), browser)) {
+             browser->append(QLatin1String(" exec"));
+@@ -296,8 +303,135 @@ static inline QDBusMessage xdgDesktopPortalSendEmail(const QUrl &url)
+ 
+     return QDBusConnection::sessionBus().call(message);
+ }
++
++namespace {
++struct XDGDesktopColor
++{
++    double r = 0;
++    double g = 0;
++    double b = 0;
++
++    QColor toQColor() const
++    {
++        constexpr auto rgbMax = 255;
++        return { static_cast<int>(r * rgbMax), static_cast<int>(g * rgbMax),
++                 static_cast<int>(b * rgbMax) };
++    }
++};
++
++const QDBusArgument &operator>>(const QDBusArgument &argument, XDGDesktopColor &myStruct)
++{
++    argument.beginStructure();
++    argument >> myStruct.r >> myStruct.g >> myStruct.b;
++    argument.endStructure();
++    return argument;
++}
++
++class XdgDesktopPortalColorPicker : public QPlatformServiceColorPicker
++{
++    Q_OBJECT
++public:
++    XdgDesktopPortalColorPicker(const QString &parentWindowId, QWindow *parent)
++        : QPlatformServiceColorPicker(parent), m_parentWindowId(parentWindowId)
++    {
++    }
++
++    void pickColor() override
++    {
++        // DBus signature:
++        // PickColor (IN   s      parent_window,
++        //            IN   a{sv}  options
++        //            OUT  o      handle)
++        // Options:
++        // handle_token (s) -  A string that will be used as the last element of the @handle.
++
++        QDBusMessage message = QDBusMessage::createMethodCall(
++                QStringLiteral("org.freedesktop.portal.Desktop"), QStringLiteral("/org/freedesktop/portal/desktop"),
++                QStringLiteral("org.freedesktop.portal.Screenshot"), QStringLiteral("PickColor"));
++        message << m_parentWindowId << QVariantMap();
++
++        QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
++        auto watcher = new QDBusPendingCallWatcher(pendingCall, this);
++        connect(watcher, &QDBusPendingCallWatcher::finished, this,
++                [this](QDBusPendingCallWatcher *watcher) {
++                    watcher->deleteLater();
++                    QDBusPendingReply<QDBusObjectPath> reply = *watcher;
++                    if (reply.isError()) {
++                        qWarning("DBus call to pick color failed: %s",
++                                 qPrintable(reply.error().message()));
++                        Q_EMIT colorPicked({});
++                    } else {
++                        QDBusConnection::sessionBus().connect(
++                                QStringLiteral("org.freedesktop.portal.Desktop"), reply.value().path(),
++                                QStringLiteral("org.freedesktop.portal.Request"), QStringLiteral("Response"), this,
++                                // clang-format off
++                                SLOT(gotColorResponse(uint,QVariantMap))
++                                // clang-format on
++                        );
++                    }
++                });
++    }
++
++private Q_SLOTS:
++    void gotColorResponse(uint result, const QVariantMap &map)
++    {
++        if (result != 0)
++            return;
++        XDGDesktopColor color{};
++        map.value(QStringLiteral("color")).value<QDBusArgument>() >> color;
++        Q_EMIT colorPicked(color.toQColor());
++        deleteLater();
++    }
++
++private:
++    const QString m_parentWindowId;
++};
++} // namespace
++
+ #endif // QT_CONFIG(dbus)
+ 
++QGenericUnixServices::QGenericUnixServices()
++{
++#if QT_CONFIG(dbus)
++    if (qEnvironmentVariableIntValue("QT_NO_XDG_DESKTOP_PORTAL") > 0) {
++        return;
++    }
++    QDBusMessage message = QDBusMessage::createMethodCall(
++            QStringLiteral("org.freedesktop.portal.Desktop"), QStringLiteral("/org/freedesktop/portal/desktop"),
++            QStringLiteral("org.freedesktop.DBus.Properties"), QStringLiteral("Get"));
++    message << QStringLiteral("org.freedesktop.portal.Screenshot")
++            << QStringLiteral("version");
++
++    QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
++    auto watcher = new QDBusPendingCallWatcher(pendingCall);
++    QObject::connect(watcher, &QDBusPendingCallWatcher::finished, watcher,
++                     [this](QDBusPendingCallWatcher *watcher) {
++                         watcher->deleteLater();
++                         QDBusPendingReply<QVariant> reply = *watcher;
++                         if (!reply.isError() && reply.value().toUInt() >= 2)
++                             m_hasScreenshotPortalWithColorPicking = true;
++                     });
++
++#endif
++}
++
++QPlatformServiceColorPicker *QGenericUnixServices::colorPicker(QWindow *parent)
++{
++#if QT_CONFIG(dbus)
++    // Make double sure that we are in a wayland environment. In particular check
++    // WAYLAND_DISPLAY so also XWayland apps benefit from portal-based color picking.
++    // Outside wayland we'll rather rely on other means than the XDG desktop portal.
++    if (!qEnvironmentVariableIsEmpty("WAYLAND_DISPLAY")
++        || QGuiApplication::platformName().startsWith(QLatin1String("wayland"))) {
++        return new XdgDesktopPortalColorPicker(portalWindowIdentifier(parent), parent);
++    }
++    return nullptr;
++#else
++    Q_UNUSED(parent);
++    return nullptr;
++#endif
++}
++
+ QByteArray QGenericUnixServices::desktopEnvironment() const
+ {
+     static const QByteArray result = detectDesktopEnvironment();
+@@ -352,6 +486,8 @@ bool QGenericUnixServices::openDocument(const QUrl &url)
+ }
+ 
+ #else
++QGenericUnixServices::QGenericUnixServices() = default;
++
+ QByteArray QGenericUnixServices::desktopEnvironment() const
+ {
+     return QByteArrayLiteral("UNKNOWN");
+@@ -371,6 +507,30 @@ bool QGenericUnixServices::openDocument(const QUrl &url)
+     return false;
+ }
+ 
++QPlatformServiceColorPicker *QGenericUnixServices::colorPicker(QWindow *parent)
++{
++    Q_UNUSED(parent);
++    return nullptr;
++}
++
+ #endif // QT_NO_MULTIPROCESS
+ 
++QString QGenericUnixServices::portalWindowIdentifier(QWindow *window)
++{
++    if (QGuiApplication::platformName() == QLatin1String("xcb"))
++        return QStringLiteral("x11:") + QString::number(window->winId(), 16);
++    return QString();
++}
++
++bool QGenericUnixServices::hasCapability(Capability capability) const
++{
++    switch (capability) {
++    case Capability::ColorPicking:
++        return m_hasScreenshotPortalWithColorPicking;
++    }
++    return false;
++}
++
+ QT_END_NAMESPACE
++
++#include "qgenericunixservices.moc"
+diff --git a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
+index 8ac3de6f03..30924e64bd 100644
+--- a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
++++ b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
+@@ -59,16 +59,21 @@ QT_BEGIN_NAMESPACE
+ class QGenericUnixServices : public QPlatformServices
+ {
+ public:
+-    QGenericUnixServices() {}
++    QGenericUnixServices();
+ 
+     QByteArray desktopEnvironment() const override;
+ 
++    bool hasCapability(Capability capability) const override;
+     bool openUrl(const QUrl &url) override;
+     bool openDocument(const QUrl &url) override;
++    QPlatformServiceColorPicker *colorPicker(QWindow *parent = nullptr) override;
++
++    virtual QString portalWindowIdentifier(QWindow *window);
+ 
+ private:
+     QString m_webBrowser;
+     QString m_documentLauncher;
++    bool m_hasScreenshotPortalWithColorPicking = false;
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
+index 09470bccc6..cc7c7d4d8a 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
+@@ -69,6 +69,7 @@ const QString MenuBarPath = QLatin1String("/MenuBar");
+ */
+ QDBusMenuConnection::QDBusMenuConnection(QObject *parent, const QString &serviceName)
+     : QObject(parent)
++    , m_serviceName(serviceName)
+     , m_connection(serviceName.isNull() ? QDBusConnection::sessionBus()
+                                         : QDBusConnection::connectToBus(QDBusConnection::SessionBus, serviceName))
+     , m_dbusWatcher(new QDBusServiceWatcher(StatusNotifierWatcherService, m_connection, QDBusServiceWatcher::WatchForRegistration, this))
+@@ -83,6 +84,12 @@ QDBusMenuConnection::QDBusMenuConnection(QObject *parent, const QString &service
+ #endif
+ }
+ 
++QDBusMenuConnection::~QDBusMenuConnection()
++{
++  if (!m_serviceName.isEmpty() && m_connection.isConnected())
++      QDBusConnection::disconnectFromBus(m_serviceName);
++}
++
+ void QDBusMenuConnection::dbusError(const QDBusError &error)
+ {
+     qWarning() << "QDBusTrayIcon encountered a D-Bus error:" << error;
+@@ -105,13 +112,7 @@ void QDBusMenuConnection::unregisterTrayIconMenu(QDBusTrayIcon *item)
+ 
+ bool QDBusMenuConnection::registerTrayIcon(QDBusTrayIcon *item)
+ {
+-    bool success = connection().registerService(item->instanceId());
+-    if (!success) {
+-        qWarning() << "failed to register service" << item->instanceId();
+-        return false;
+-    }
+-
+-    success = connection().registerObject(StatusNotifierItemPath, item);
++    bool success = connection().registerObject(StatusNotifierItemPath, item);
+     if (!success) {
+         unregisterTrayIcon(item);
+         qWarning() << "failed to register" << item->instanceId() << StatusNotifierItemPath;
+@@ -126,21 +127,18 @@ bool QDBusMenuConnection::registerTrayIcon(QDBusTrayIcon *item)
+ 
+ bool QDBusMenuConnection::registerTrayIconWithWatcher(QDBusTrayIcon *item)
+ {
++    Q_UNUSED(item);
+     QDBusMessage registerMethod = QDBusMessage::createMethodCall(
+                 StatusNotifierWatcherService, StatusNotifierWatcherPath, StatusNotifierWatcherService,
+                 QLatin1String("RegisterStatusNotifierItem"));
+-    registerMethod.setArguments(QVariantList() << item->instanceId());
++    registerMethod.setArguments(QVariantList() << m_connection.baseService());
+     return m_connection.callWithCallback(registerMethod, this, SIGNAL(trayIconRegistered()), SLOT(dbusError(QDBusError)));
+ }
+ 
+-bool QDBusMenuConnection::unregisterTrayIcon(QDBusTrayIcon *item)
++void QDBusMenuConnection::unregisterTrayIcon(QDBusTrayIcon *item)
+ {
+     unregisterTrayIconMenu(item);
+     connection().unregisterObject(StatusNotifierItemPath);
+-    bool success = connection().unregisterService(item->instanceId());
+-    if (!success)
+-        qWarning() << "failed to unregister service" << item->instanceId();
+-    return success;
+ }
+ #endif // QT_NO_SYSTEMTRAYICON
+ 
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
+index f484795fbb..97bdfabb85 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
++++ b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
+@@ -70,6 +70,7 @@ class QDBusMenuConnection : public QObject
+ 
+ public:
+     QDBusMenuConnection(QObject *parent = nullptr, const QString &serviceName = QString());
++    ~QDBusMenuConnection();
+     QDBusConnection connection() const { return m_connection; }
+     QDBusServiceWatcher *dbusWatcher() const { return m_dbusWatcher; }
+     bool isStatusNotifierHostRegistered() const { return m_statusNotifierHostRegistered; }
+@@ -78,7 +79,7 @@ public:
+     void unregisterTrayIconMenu(QDBusTrayIcon *item);
+     bool registerTrayIcon(QDBusTrayIcon *item);
+     bool registerTrayIconWithWatcher(QDBusTrayIcon *item);
+-    bool unregisterTrayIcon(QDBusTrayIcon *item);
++    void unregisterTrayIcon(QDBusTrayIcon *item);
+ #endif // QT_NO_SYSTEMTRAYICON
+ 
+ Q_SIGNALS:
+@@ -90,6 +91,7 @@ private Q_SLOTS:
+     void dbusError(const QDBusError &error);
+ 
+ private:
++    QString m_serviceName;
+     QDBusConnection m_connection;
+     QDBusServiceWatcher *m_dbusWatcher;
+     bool m_statusNotifierHostRegistered;
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp b/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
+index bede70975a..76bfec5e5a 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
+@@ -71,8 +71,12 @@ Q_LOGGING_CATEGORY(qLcTray, "qt.qpa.tray")
+ static QString iconTempPath()
+ {
+     QString tempPath = QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation);
+-    if (!tempPath.isEmpty())
++    if (!tempPath.isEmpty()) {
++        QString flatpakId = qEnvironmentVariable("FLATPAK_ID");
++        if (!flatpakId.isEmpty() && QFileInfo::exists(QLatin1String("/.flatpak-info")))
++            tempPath += QLatin1String("/app/") + flatpakId;
+         return tempPath;
++    }
+ 
+     tempPath = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation);
+ 
+diff --git a/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+index cb1b39db64..6e01af052c 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+@@ -755,6 +755,9 @@ QVariant QGnomeTheme::themeHint(QPlatformTheme::ThemeHint hint) const
+         return QVariant(QChar(0x2022));
+     case QPlatformTheme::UiEffects:
+         return QVariant(int(HoverEffect));
++    case QPlatformTheme::ButtonPressKeys:
++        return QVariant::fromValue(
++                QList<Qt::Key>({ Qt::Key_Space, Qt::Key_Return, Qt::Key_Enter, Qt::Key_Select }));
+     default:
+         break;
+     }
+diff --git a/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp b/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
+index 98e05195ee..1e92f43dec 100644
+--- a/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
++++ b/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
+@@ -343,8 +343,7 @@ void QEglFSCursor::paintOnScreen()
+     // screens are siblings of each other. When not enabled, the sibling list
+     // only contains m_screen itself.
+     for (QPlatformScreen *screen : m_screen->virtualSiblings()) {
+-        if (screen->geometry().contains(cr.topLeft().toPoint() + m_cursor.hotSpot)
+-            && QOpenGLContext::currentContext()->screen() == screen->screen())
++        if (screen->geometry().contains(cr.topLeft().toPoint() + m_cursor.hotSpot))
+         {
+             cr.translate(-screen->geometry().topLeft());
+             const QSize screenSize = screen->geometry().size();
+@@ -468,11 +467,12 @@ void QEglFSCursor::draw(const QRectF &r)
+ {
+     StateSaver stateSaver;
+ 
+-    QEglFSCursorData &gfx = static_cast<QEglFSContext*>(QOpenGLContext::currentContext()->handle())->cursorData;
+-    if (!gfx.program) {
+-        // one time initialization
++    // one time initialization
++    if (!QOpenGLFunctions::d_ptr)
+         initializeOpenGLFunctions();
+ 
++    QEglFSCursorData &gfx = static_cast<QEglFSContext*>(QOpenGLContext::currentContext()->handle())->cursorData;
++    if (!gfx.program) {
+         createShaderPrograms();
+ 
+         if (!gfx.atlasTexture) {
+diff --git a/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp b/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
+index 645a0ae2e9..3e0e406f1a 100644
+--- a/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
++++ b/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
+@@ -179,7 +179,7 @@ void QEglFSKmsEventReader::create(QEglFSKmsDevice *device)
+ 
+     m_device = device;
+ 
+-    qCDebug(qLcEglfsKmsDebug, "Initalizing event reader for device %p fd %d",
++    qCDebug(qLcEglfsKmsDebug, "Initializing event reader for device %p fd %d",
+             m_device, m_device->fd());
+ 
+     m_thread = new QEglFSKmsEventReaderThread(m_device->fd());
+diff --git a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
+index 141fb68a23..d4294d425a 100644
+--- a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
++++ b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
+@@ -122,11 +122,13 @@ QOffscreenIntegration::QOffscreenIntegration()
+ #endif
+     m_services.reset(new QPlatformServices);
+ 
+-    QWindowSystemInterface::handleScreenAdded(new QOffscreenScreen);
++    m_screen = new QOffscreenScreen;
++    QWindowSystemInterface::handleScreenAdded(m_screen);
+ }
+ 
+ QOffscreenIntegration::~QOffscreenIntegration()
+ {
++    QWindowSystemInterface::handleScreenRemoved(m_screen);
+ }
+ 
+ void QOffscreenIntegration::initialize()
+diff --git a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
+index 0ea90f6c2f..fe00fde07c 100644
+--- a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
++++ b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
+@@ -84,6 +84,7 @@ protected:
+ #endif
+     QScopedPointer<QPlatformInputContext> m_inputContext;
+     QScopedPointer<QPlatformServices> m_services;
++    QPlatformScreen *m_screen;
+     mutable QScopedPointer<QPlatformNativeInterface> m_nativeInterface;
+ };
+ 
+diff --git a/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp b/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
+index 6fa5a8a2b3..1f49f0aefd 100644
+--- a/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
++++ b/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
+@@ -48,6 +48,7 @@
+ #include <qpa/qplatformnativeinterface.h>
+ #include <QtPlatformHeaders/qwglnativecontext.h>
+ 
++#include <private/qsystemlibrary_p.h>
+ #include <algorithm>
+ 
+ #include <wingdi.h>
+@@ -162,19 +163,25 @@ QFunctionPointer QWindowsOpengl32DLL::resolve(const char *name)
+ 
+ bool QWindowsOpengl32DLL::init(bool softwareRendering)
+ {
+-    const QByteArray opengl32 = QByteArrayLiteral("opengl32.dll");
+-    const QByteArray swopengl = QByteArrayLiteral("opengl32sw.dll");
++    const QByteArray opengl32 = QByteArrayLiteral("opengl32");
++    const QByteArray swopengl = QByteArrayLiteral("opengl32sw");
++    bool useSystemLib = false;
+ 
+     QByteArray openglDll = qgetenv("QT_OPENGL_DLL");
+-    if (openglDll.isEmpty())
++    if (openglDll.isEmpty()) {
+         openglDll = softwareRendering ? swopengl : opengl32;
++        useSystemLib = !softwareRendering;
++    }
+ 
+     openglDll = openglDll.toLower();
+     m_nonOpengl32 = openglDll != opengl32;
+ 
+     qCDebug(lcQpaGl) << "Qt: Using WGL and OpenGL from" << openglDll;
+ 
+-    m_lib = ::LoadLibraryA(openglDll.constData());
++    if (useSystemLib)
++        m_lib = QSystemLibrary::load((wchar_t*)(QString::fromLatin1(openglDll).utf16()));
++    else
++        m_lib = LoadLibraryA(openglDll.constData());
+     if (!m_lib) {
+         qErrnoWarning(::GetLastError(), "Failed to load %s", openglDll.constData());
+         return false;
+@@ -184,7 +191,7 @@ bool QWindowsOpengl32DLL::init(bool softwareRendering)
+         // Load opengl32.dll always. GDI functions like ChoosePixelFormat do
+         // GetModuleHandle for opengl32.dll and behave differently (and call back into
+         // opengl32) when the module is present. This is fine for dummy contexts and windows.
+-        ::LoadLibraryA("opengl32.dll");
++        QSystemLibrary::load(L"opengl32");
+     }
+ 
+     wglCreateContext = reinterpret_cast<HGLRC (WINAPI *)(HDC)>(resolve("wglCreateContext"));
+diff --git a/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp b/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
+index d7d186e804..9eb4011bf2 100644
+--- a/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
++++ b/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
+@@ -49,6 +49,7 @@
+ #include <QtCore/qstandardpaths.h>
+ #include <QtCore/qlibraryinfo.h>
+ #include <QtCore/qhash.h>
++#include <private/qsystemlibrary_p.h>
+ 
+ #ifndef QT_NO_OPENGL
+ #include <private/qopengl_p.h>
+@@ -396,7 +397,7 @@ bool QWindowsOpenGLTester::testDesktopGL()
+ 
+     // Test #1: Load opengl32.dll and try to resolve an OpenGL 2 function.
+     // This will typically fail on systems that do not have a real OpenGL driver.
+-    lib = LoadLibraryA("opengl32.dll");
++    lib = QSystemLibrary::load(L"opengl32");
+     if (lib) {
+         CreateContext = reinterpret_cast<CreateContextType>(
+             reinterpret_cast<QFunctionPointer>(::GetProcAddress(lib, "wglCreateContext")));
+diff --git a/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp b/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
+index 1afa00cfc9..118af6ce73 100644
+--- a/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
++++ b/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
+@@ -41,6 +41,7 @@
+ 
+ #include <QRect>
+ #include <QList>
++#include <QMap>
+ #include <QDebug>
+ 
+ #include <qmath.h>
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp b/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
+index 9e2a37a6a1..e6e175a118 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
+@@ -488,12 +488,12 @@ void QXcbConnection::printXcbError(const char *message, xcb_generic_error_t *err
+     uint clamped_error_code = qMin<uint>(error->error_code, (sizeof(xcb_errors) / sizeof(xcb_errors[0])) - 1);
+     uint clamped_major_code = qMin<uint>(error->major_code, (sizeof(xcb_protocol_request_codes) / sizeof(xcb_protocol_request_codes[0])) - 1);
+ 
+-    qCWarning(lcQpaXcb, "%s: %d (%s), sequence: %d, resource id: %d, major code: %d (%s), minor code: %d",
+-             message,
+-             int(error->error_code), xcb_errors[clamped_error_code],
+-             int(error->sequence), int(error->resource_id),
+-             int(error->major_code), xcb_protocol_request_codes[clamped_major_code],
+-             int(error->minor_code));
++    qCDebug(lcQpaXcb, "%s: %d (%s), sequence: %d, resource id: %d, major code: %d (%s), minor code: %d",
++            message,
++            int(error->error_code), xcb_errors[clamped_error_code],
++            int(error->sequence), int(error->resource_id),
++            int(error->major_code), xcb_protocol_request_codes[clamped_major_code],
++            int(error->minor_code));
+ }
+ 
+ static Qt::MouseButtons translateMouseButtons(int s)
+@@ -702,6 +702,8 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
+             QXcbVirtualDesktop *virtualDesktop = virtualDesktopForRootWindow(propertyNotify->window);
+             if (virtualDesktop)
+                 virtualDesktop->updateWorkArea();
++        } else if (propertyNotify->atom == atom(QXcbAtom::_NET_SUPPORTED)) {
++            m_wmSupport->updateNetWMAtoms();
+         } else {
+             HANDLE_PLATFORM_WINDOW_EVENT(xcb_property_notify_event_t, window, handlePropertyNotifyEvent);
+         }
+@@ -750,7 +752,7 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
+                 case XCB_XKB_NEW_KEYBOARD_NOTIFY: {
+                     xcb_xkb_new_keyboard_notify_event_t *ev = &xkb_event->new_keyboard_notify;
+                     if (ev->changed & XCB_XKB_NKN_DETAIL_KEYCODES)
+-                        m_keyboard->updateKeymap(ev);
++                        m_keyboard->updateKeymap();
+                     break;
+                 }
+                 default:
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp b/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
+index 76869ced60..02d2eebb56 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
+@@ -274,8 +274,7 @@ QPlatformWindow *QXcbIntegration::createForeignWindow(QWindow *window, WId nativ
+ #ifndef QT_NO_OPENGL
+ QPlatformOpenGLContext *QXcbIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
+ {
+-    QXcbScreen *screen = static_cast<QXcbScreen *>(context->screen()->handle());
+-    QXcbGlIntegration *glIntegration = screen->connection()->glIntegration();
++    QXcbGlIntegration *glIntegration = defaultConnection()->glIntegration();
+     if (!glIntegration) {
+         qWarning("QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled");
+         return nullptr;
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+index efecd7e2d1..e8286381a2 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+@@ -365,17 +365,6 @@ void QXcbKeyboard::updateKeymap(xcb_mapping_notify_event_t *event)
+     updateKeymap();
+ }
+ 
+-void QXcbKeyboard::updateKeymap(xcb_xkb_new_keyboard_notify_event_t *event)
+-{
+-    if (!event)
+-        return;
+-
+-    if (event->deviceID != event->oldDeviceID)
+-        m_config = false;
+-
+-    updateKeymap();
+-}
+-
+ void QXcbKeyboard::updateKeymap()
+ {
+     KeysymModifierMap keysymMods;
+@@ -383,6 +372,8 @@ void QXcbKeyboard::updateKeymap()
+         keysymMods = keysymsToModifiers();
+     updateModifiers(keysymMods);
+ 
++    m_config = true;
++
+     if (!m_xkbContext) {
+         m_xkbContext.reset(xkb_context_new(XKB_CONTEXT_NO_DEFAULT_INCLUDES));
+         if (!m_xkbContext) {
+@@ -398,13 +389,8 @@ void QXcbKeyboard::updateKeymap()
+     if (connection()->hasXKB()) {
+         m_xkbKeymap.reset(xkb_x11_keymap_new_from_device(m_xkbContext.get(), xcb_connection(),
+                                                          core_device_id, XKB_KEYMAP_COMPILE_NO_FLAGS));
+-        if (m_xkbKeymap) {
+-            if (m_config)
+-                m_xkbState.reset(xkb_state_new(m_xkbKeymap.get()));
+-            else
+-                m_xkbState.reset(xkb_x11_state_new_from_device(m_xkbKeymap.get(), xcb_connection(), core_device_id));
+-
+-        }
++        if (m_xkbKeymap)
++            m_xkbState.reset(xkb_x11_state_new_from_device(m_xkbKeymap.get(), xcb_connection(), core_device_id));
+     } else {
+         m_xkbKeymap.reset(keymapFromCore(keysymMods));
+         if (m_xkbKeymap)
+@@ -425,8 +411,6 @@ void QXcbKeyboard::updateKeymap()
+     updateXKBMods();
+ 
+     QXkbCommon::verifyHasLatinLayout(m_xkbKeymap.get());
+-
+-    m_config = true;
+ }
+ 
+ QList<int> QXcbKeyboard::possibleKeys(const QKeyEvent *event) const
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
+index b652c85fe3..0ee08aeff2 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
++++ b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
+@@ -69,7 +69,6 @@ public:
+ 
+     Qt::KeyboardModifiers translateModifiers(int s) const;
+     void updateKeymap(xcb_mapping_notify_event_t *event);
+-    void updateKeymap(xcb_xkb_new_keyboard_notify_event_t *event);
+     void updateKeymap();
+     QList<int> possibleKeys(const QKeyEvent *event) const;
+ 
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp b/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
+index ffda7b6a57..863e961f4c 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
+@@ -564,11 +564,6 @@ void QXcbWindow::setGeometry(const QRect &rect)
+ {
+     QPlatformWindow::setGeometry(rect);
+ 
+-    if (shouldDeferTask(Task::SetGeometry)) {
+-        m_deferredGeometry = rect;
+-        return;
+-    }
+-
+     propagateSizeHints();
+ 
+     QXcbScreen *currentScreen = xcbScreen();
+@@ -693,9 +688,6 @@ void QXcbWindow::setVisible(bool visible)
+ 
+ void QXcbWindow::show()
+ {
+-    if (shouldDeferTask(Task::Map))
+-        return;
+-
+     if (window()->isTopLevel()) {
+ 
+         // update WM_NORMAL_HINTS
+@@ -706,7 +698,7 @@ void QXcbWindow::show()
+         if (isTransient(window())) {
+             const QWindow *tp = window()->transientParent();
+             if (tp && tp->handle())
+-                transientXcbParent = static_cast<const QXcbWindow *>(tp->handle())->winId();
++                transientXcbParent = tp->handle()->winId();
+             // Default to client leader if there is no transient parent, else modal dialogs can
+             // be hidden by their parents.
+             if (!transientXcbParent)
+@@ -746,10 +738,6 @@ void QXcbWindow::show()
+ 
+ void QXcbWindow::hide()
+ {
+-    if (shouldDeferTask(Task::Unmap))
+-        return;
+-
+-    m_wmStateValid = false;
+     xcb_unmap_window(xcb_connection(), m_window);
+ 
+     // send synthetic UnmapNotify event according to icccm 4.1.4
+@@ -909,9 +897,6 @@ QXcbWindow::NetWmStates QXcbWindow::netWmStates()
+ 
+ void QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
+ {
+-    if (shouldDeferTask(Task::SetWindowFlags))
+-        return;
+-
+     Qt::WindowType type = static_cast<Qt::WindowType>(int(flags & Qt::WindowType_Mask));
+ 
+     if (type == Qt::ToolTip)
+@@ -941,8 +926,6 @@ void QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
+ 
+     setTransparentForMouseEvents(flags & Qt::WindowTransparentForInput);
+     updateDoesNotAcceptFocus(flags & Qt::WindowDoesNotAcceptFocus);
+-
+-    m_isWmManagedWindow = !(flags & Qt::X11BypassWindowManagerHint);
+ }
+ 
+ void QXcbWindow::setMotifWmHints(Qt::WindowFlags flags)
+@@ -1142,9 +1125,6 @@ void QXcbWindow::setWindowState(Qt::WindowStates state)
+     if (state == m_windowState)
+         return;
+ 
+-    if (shouldDeferTask(Task::SetWindowState))
+-        return;
+-
+     // unset old state
+     if (m_windowState & Qt::WindowMinimized)
+         xcb_map_window(xcb_connection(), m_window);
+@@ -1350,6 +1330,12 @@ void QXcbWindow::setWindowIcon(const QIcon &icon)
+     }
+ 
+     if (!icon_data.isEmpty()) {
++        // Ignore icon exceeding maximum xcb request length
++        if (icon_data.size() > xcb_get_maximum_request_length(xcb_connection())) {
++            qWarning("Ignoring window icon: Size %llu exceeds maximum xcb request length %u.",
++                     icon_data.size(), xcb_get_maximum_request_length(xcb_connection()));
++            return;
++        }
+         xcb_change_property(xcb_connection(),
+                             XCB_PROP_MODE_REPLACE,
+                             m_window,
+@@ -1639,7 +1625,7 @@ void QXcbWindow::setWmWindowType(QXcbWindowFunctions::WmWindowTypes types, Qt::W
+         break;
+     }
+ 
+-    if ((flags & Qt::FramelessWindowHint) && !(type & QXcbWindowFunctions::KdeOverride)) {
++    if ((flags & Qt::FramelessWindowHint) && !(types & QXcbWindowFunctions::KdeOverride)) {
+         // override netwm type - quick and easy for KDE noborder
+         atoms.append(atom(QXcbAtom::_KDE_NET_WM_WINDOW_TYPE_OVERRIDE));
+     }
+@@ -1894,10 +1880,6 @@ void QXcbWindow::handleUnmapNotifyEvent(const xcb_unmap_notify_event_t *event)
+     if (event->window == m_window) {
+         m_mapped = false;
+         QWindowSystemInterface::handleExposeEvent(window(), QRegion());
+-        if (!m_isWmManagedWindow || parent()) {
+-            m_wmStateValid = true;
+-            handleDeferredTasks();
+-        }
+     }
+ }
+ 
+@@ -2212,98 +2194,30 @@ void QXcbWindow::handleLeaveNotifyEvent(const xcb_leave_notify_event_t *event)
+     handleLeaveNotifyEvent(event->root_x, event->root_y, event->mode, event->detail, event->time);
+ }
+ 
+-bool QXcbWindow::shouldDeferTask(Task task)
+-{
+-    if (m_wmStateValid)
+-        return false;
+-
+-    m_deferredTasks.append(task);
+-    return true;
+-}
+-
+-void QXcbWindow::handleDeferredTasks()
+-{
+-    Q_ASSERT(m_wmStateValid == true);
+-    if (m_deferredTasks.isEmpty())
+-        return;
+-
+-    bool map = false;
+-    bool unmap = false;
+-
+-    QVector<Task> tasks;
+-    for (auto taskIt = m_deferredTasks.rbegin(); taskIt != m_deferredTasks.rend(); ++taskIt) {
+-        if (!tasks.contains(*taskIt))
+-            tasks.prepend(*taskIt);
+-    }
+-
+-    for (Task task : tasks) {
+-        switch (task) {
+-        case Task::Map:
+-            map = true;
+-            unmap = false;
+-            break;
+-        case Task::Unmap:
+-            unmap = true;
+-            map = false;
+-            break;
+-        case Task::SetGeometry:
+-            setGeometry(m_deferredGeometry);
+-            break;
+-        case Task::SetWindowFlags:
+-            setWindowFlags(window()->flags());
+-            break;
+-        case Task::SetWindowState:
+-            setWindowState(window()->windowState());
+-            break;
+-        }
+-    }
+-    m_deferredTasks.clear();
+-
+-    if (map) {
+-        Q_ASSERT(unmap == false);
+-        show();
+-    }
+-    if (unmap) {
+-        Q_ASSERT(map == false);
+-        hide();
+-    }
+-}
+-
+ void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *event)
+ {
+     connection()->setTime(event->time);
+ 
+-    const bool wmStateChanged = event->atom == atom(QXcbAtom::WM_STATE);
+-    const bool netWmStateChanged = event->atom == atom(QXcbAtom::_NET_WM_STATE);
+-    if (netWmStateChanged || wmStateChanged) {
+-        if (wmStateChanged && !m_wmStateValid && m_isWmManagedWindow) {
+-            // ICCCM 4.1.4
+-            // Clients that want to re-use a client window (e.g. by mapping it again)
+-            // after withdrawing it must wait for the withdrawal to be complete before
+-            // proceeding. The preferred method for doing this is for clients to wait for
+-            // a window manager to update or remove the WM_STATE property.
+-            m_wmStateValid = true;
+-            handleDeferredTasks();
+-        }
+-        if (event->state == XCB_PROPERTY_DELETE)
++    const bool propertyDeleted = event->state == XCB_PROPERTY_DELETE;
++
++    if (event->atom == atom(QXcbAtom::_NET_WM_STATE) || event->atom == atom(QXcbAtom::WM_STATE)) {
++        if (propertyDeleted)
+             return;
+ 
+-        if (wmStateChanged) {
++        Qt::WindowStates newState = Qt::WindowNoState;
++
++        if (event->atom == atom(QXcbAtom::WM_STATE)) { // WM_STATE: Quick check for 'Minimize'.
+             auto reply = Q_XCB_REPLY(xcb_get_property, xcb_connection(),
+                                      0, m_window, atom(QXcbAtom::WM_STATE),
+                                      XCB_ATOM_ANY, 0, 1024);
+             if (reply && reply->format == 32 && reply->type == atom(QXcbAtom::WM_STATE)) {
+-                auto data = static_cast<const quint32 *>(xcb_get_property_value(reply.get()));
+-                if (reply->length != 0) {
+-                    const bool changedToWithdrawn = data[0] == XCB_ICCCM_WM_STATE_WITHDRAWN;
+-                    const bool changedToIconic = data[0] == XCB_ICCCM_WM_STATE_ICONIC;
+-                    m_minimized = changedToIconic || (changedToWithdrawn && m_minimized);
+-                }
++                const quint32 *data = (const quint32 *)xcb_get_property_value(reply.get());
++                if (reply->length != 0)
++                    m_minimized = (data[0] == XCB_ICCCM_WM_STATE_ICONIC
++                                   || (data[0] == XCB_ICCCM_WM_STATE_WITHDRAWN && m_minimized));
+             }
+         }
+ 
+-        // _NET_WM_STATE handling
+-        Qt::WindowStates newState = Qt::WindowNoState;
+         const NetWmStates states = netWmStates();
+         // _NET_WM_STATE_HIDDEN should be set by the Window Manager to indicate that a window would
+         // not be visible on the screen if its desktop/viewport were active and its coordinates were
+@@ -2325,6 +2239,7 @@ void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *ev
+             if ((m_windowState & Qt::WindowMinimized) && connection()->mouseGrabber() == this)
+                 connection()->setMouseGrabber(nullptr);
+         }
++        return;
+     } else if (event->atom == atom(QXcbAtom::_NET_FRAME_EXTENTS)) {
+         m_dirtyFrameMargins = true;
+     }
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbwindow.h b/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
+index 55af9279b1..6f5c1f5ed9 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
++++ b/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
+@@ -74,14 +74,6 @@ public:
+ 
+     Q_DECLARE_FLAGS(NetWmStates, NetWmState)
+ 
+-    enum Task {
+-        Map,
+-        Unmap,
+-        SetGeometry,
+-        SetWindowFlags,
+-        SetWindowState
+-    };
+-
+     QXcbWindow(QWindow *window);
+     ~QXcbWindow();
+ 
+@@ -151,9 +143,6 @@ public:
+ 
+     QXcbWindow *toWindow() override;
+ 
+-    bool shouldDeferTask(Task task);
+-    void handleDeferredTasks();
+-
+     void handleMouseEvent(xcb_timestamp_t time, const QPoint &local, const QPoint &global,
+                           Qt::KeyboardModifiers modifiers, QEvent::Type type, Qt::MouseEventSource source);
+ 
+@@ -292,11 +281,6 @@ protected:
+     int m_swapInterval = -1;
+ 
+     qreal m_sizeHintsScaleFactor = 1.0;
+-
+-    bool m_wmStateValid = true;
+-    QVector<Task> m_deferredTasks;
+-    bool m_isWmManagedWindow = true;
+-    QRect m_deferredGeometry;
+ };
+ 
+ class QXcbForeignWindow : public QXcbWindow
+diff --git a/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp b/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
+index d9d117faeb..640b49daa0 100644
+--- a/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
++++ b/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
+@@ -85,6 +85,7 @@ QGtk3MenuItem::QGtk3MenuItem()
+       m_checkable(false),
+       m_checked(false),
+       m_enabled(true),
++      m_exclusive(false),
+       m_underline(false),
+       m_invalid(true),
+       m_menu(nullptr),
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
+index 0048bbc1e6..396e7f6d1c 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
+@@ -102,15 +102,12 @@ const QDBusArgument &operator >>(const QDBusArgument &arg, QXdgDesktopPortalFile
+ class QXdgDesktopPortalFileDialogPrivate
+ {
+ public:
+-    QXdgDesktopPortalFileDialogPrivate(QPlatformFileDialogHelper *nativeFileDialog)
++    QXdgDesktopPortalFileDialogPrivate(QPlatformFileDialogHelper *nativeFileDialog, uint fileChooserPortalVersion)
+         : nativeFileDialog(nativeFileDialog)
++        , fileChooserPortalVersion(fileChooserPortalVersion)
+     { }
+ 
+-    WId winId = 0;
+-    bool directoryMode = false;
+-    bool modal = false;
+-    bool multipleFiles = false;
+-    bool saveFile = false;
++    QEventLoop loop;
+     QString acceptLabel;
+     QString directory;
+     QString title;
+@@ -121,19 +118,27 @@ public:
+     QString selectedMimeTypeFilter;
+     QString selectedNameFilter;
+     QStringList selectedFiles;
+-    QPlatformFileDialogHelper *nativeFileDialog = nullptr;
++    std::unique_ptr<QPlatformFileDialogHelper> nativeFileDialog;
++    uint fileChooserPortalVersion = 0;
++    bool failedToOpen = false;
++    bool directoryMode = false;
++    bool multipleFiles = false;
++    bool saveFile = false;
+ };
+ 
+-QXdgDesktopPortalFileDialog::QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog)
++QXdgDesktopPortalFileDialog::QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog, uint fileChooserPortalVersion)
+     : QPlatformFileDialogHelper()
+-    , d_ptr(new QXdgDesktopPortalFileDialogPrivate(nativeFileDialog))
++    , d_ptr(new QXdgDesktopPortalFileDialogPrivate(nativeFileDialog, fileChooserPortalVersion))
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+     if (d->nativeFileDialog) {
+-        connect(d->nativeFileDialog, SIGNAL(accept()), this, SIGNAL(accept()));
+-        connect(d->nativeFileDialog, SIGNAL(reject()), this, SIGNAL(reject()));
++        connect(d->nativeFileDialog.get(), SIGNAL(accept()), this, SIGNAL(accept()));
++        connect(d->nativeFileDialog.get(), SIGNAL(reject()), this, SIGNAL(reject()));
+     }
++
++    d->loop.connect(this, SIGNAL(accept()), SLOT(quit()));
++    d->loop.connect(this, SIGNAL(reject()), SLOT(quit()));
+ }
+ 
+ QXdgDesktopPortalFileDialog::~QXdgDesktopPortalFileDialog()
+@@ -177,7 +182,7 @@ void QXdgDesktopPortalFileDialog::initializeDialog()
+     setDirectory(options()->initialDirectory());
+ }
+ 
+-void QXdgDesktopPortalFileDialog::openPortal()
++void QXdgDesktopPortalFileDialog::openPortal(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent)
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+@@ -185,13 +190,13 @@ void QXdgDesktopPortalFileDialog::openPortal()
+                                                           QLatin1String("/org/freedesktop/portal/desktop"),
+                                                           QLatin1String("org.freedesktop.portal.FileChooser"),
+                                                           d->saveFile ? QLatin1String("SaveFile") : QLatin1String("OpenFile"));
+-    QString parentWindowId = QLatin1String("x11:") + QString::number(d->winId, 16);
++    QString parentWindowId = QLatin1String("x11:") + QString::number(parent ? parent->winId() : 0, 16);
+ 
+     QVariantMap options;
+     if (!d->acceptLabel.isEmpty())
+         options.insert(QLatin1String("accept_label"), d->acceptLabel);
+ 
+-    options.insert(QLatin1String("modal"), d->modal);
++    options.insert(QLatin1String("modal"), windowModality != Qt::NonModal);
+     options.insert(QLatin1String("multiple"), d->multipleFiles);
+     options.insert(QLatin1String("directory"), d->directoryMode);
+ 
+@@ -290,10 +295,18 @@ void QXdgDesktopPortalFileDialog::openPortal()
+ 
+     QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
+     QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingCall);
+-    connect(watcher, &QDBusPendingCallWatcher::finished, this, [this] (QDBusPendingCallWatcher *watcher) {
++    connect(watcher, &QDBusPendingCallWatcher::finished, this, [=] (QDBusPendingCallWatcher *watcher) {
+         QDBusPendingReply<QDBusObjectPath> reply = *watcher;
+-        if (reply.isError()) {
+-            Q_EMIT reject();
++        // Any error means the dialog is not shown and we need to fallback
++        d->failedToOpen = reply.isError();
++        if (d->failedToOpen) {
++            if (d->nativeFileDialog) {
++                d->nativeFileDialog->show(windowFlags, windowModality, parent);
++                if (d->loop.isRunning())
++                    d->nativeFileDialog->exec();
++            } else {
++                Q_EMIT reject();
++            }
+         } else {
+             QDBusConnection::sessionBus().connect(nullptr,
+                                                   reply.value().path(),
+@@ -302,6 +315,7 @@ void QXdgDesktopPortalFileDialog::openPortal()
+                                                   this,
+                                                   SLOT(gotResponse(uint,QVariantMap)));
+         }
++        watcher->deleteLater();
+     });
+ }
+ 
+@@ -326,7 +340,7 @@ QUrl QXdgDesktopPortalFileDialog::directory() const
+ {
+     Q_D(const QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog())
+         return d->nativeFileDialog->directory();
+ 
+     return d->directory;
+@@ -348,7 +362,7 @@ QList<QUrl> QXdgDesktopPortalFileDialog::selectedFiles() const
+ {
+     Q_D(const QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog())
+         return d->nativeFileDialog->selectedFiles();
+ 
+     QList<QUrl> files;
+@@ -403,16 +417,13 @@ void QXdgDesktopPortalFileDialog::exec()
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly)) {
++    if (d->nativeFileDialog && useNativeFileDialog()) {
+         d->nativeFileDialog->exec();
+         return;
+     }
+ 
+     // HACK we have to avoid returning until we emit that the dialog was accepted or rejected
+-    QEventLoop loop;
+-    loop.connect(this, SIGNAL(accept()), SLOT(quit()));
+-    loop.connect(this, SIGNAL(reject()), SLOT(quit()));
+-    loop.exec();
++    d->loop.exec();
+ }
+ 
+ void QXdgDesktopPortalFileDialog::hide()
+@@ -429,13 +440,10 @@ bool QXdgDesktopPortalFileDialog::show(Qt::WindowFlags windowFlags, Qt::WindowMo
+ 
+     initializeDialog();
+ 
+-    d->modal = windowModality != Qt::NonModal;
+-    d->winId = parent ? parent->winId() : 0;
+-
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog(OpenFallback))
+         return d->nativeFileDialog->show(windowFlags, windowModality, parent);
+ 
+-    openPortal();
++    openPortal(windowFlags, windowModality, parent);
+ 
+     return true;
+ }
+@@ -465,4 +473,21 @@ void QXdgDesktopPortalFileDialog::gotResponse(uint response, const QVariantMap &
+     }
+ }
+ 
++bool QXdgDesktopPortalFileDialog::useNativeFileDialog(QXdgDesktopPortalFileDialog::FallbackType fallbackType) const
++{
++    Q_D(const QXdgDesktopPortalFileDialog);
++
++    if (d->failedToOpen && fallbackType != OpenFallback)
++        return true;
++
++    if (d->fileChooserPortalVersion < 3) {
++        if (options()->fileMode() == QFileDialogOptions::Directory)
++            return true;
++        else if (options()->fileMode() == QFileDialogOptions::DirectoryOnly)
++            return true;
++    }
++
++    return false;
++}
++
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
+index 4f4de96ecf..65e22a5cf2 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
+@@ -51,6 +51,11 @@ class QXdgDesktopPortalFileDialog : public QPlatformFileDialogHelper
+     Q_OBJECT
+     Q_DECLARE_PRIVATE(QXdgDesktopPortalFileDialog)
+ public:
++    enum FallbackType {
++        GenericFallback,
++        OpenFallback
++    };
++
+     enum ConditionType : uint {
+         GlobalPattern = 0,
+         MimeType = 1
+@@ -69,7 +74,7 @@ public:
+     };
+     typedef QVector<Filter> FilterList;
+ 
+-    QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog = nullptr);
++    QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog = nullptr, uint fileChooserPortalVersion = 0);
+     ~QXdgDesktopPortalFileDialog();
+ 
+     bool defaultNameFilterDisables() const override;
+@@ -92,7 +97,8 @@ private Q_SLOTS:
+ 
+ private:
+     void initializeDialog();
+-    void openPortal();
++    void openPortal(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent);
++    bool useNativeFileDialog(FallbackType fallbackType = GenericFallback) const;
+ 
+     QScopedPointer<QXdgDesktopPortalFileDialogPrivate> d_ptr;
+ };
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
+index fb324afbd8..b809503122 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
+@@ -111,6 +111,7 @@ QXdgDesktopPortalTheme::QXdgDesktopPortalTheme()
+         if (reply.isValid()) {
+             d->fileChooserPortalVersion = reply.value().toUInt();
+         }
++        watcher->deleteLater();
+     });
+ }
+ 
+@@ -152,11 +153,12 @@ QPlatformDialogHelper* QXdgDesktopPortalTheme::createPlatformDialogHelper(Dialog
+ {
+     Q_D(const QXdgDesktopPortalTheme);
+ 
+-    if (type == FileDialog) {
++    if (type == FileDialog && d->fileChooserPortalVersion) {
+         // Older versions of FileChooser portal don't support opening directories, therefore we fallback
+         // to native file dialog opened inside the sandbox to open a directory.
+-        if (d->fileChooserPortalVersion < 3 && d->baseTheme->usePlatformNativeDialog(type))
+-            return new QXdgDesktopPortalFileDialog(static_cast<QPlatformFileDialogHelper*>(d->baseTheme->createPlatformDialogHelper(type)));
++        if (d->baseTheme->usePlatformNativeDialog(type))
++            return new QXdgDesktopPortalFileDialog(static_cast<QPlatformFileDialogHelper*>(d->baseTheme->createPlatformDialogHelper(type)),
++                                                   d->fileChooserPortalVersion);
+ 
+         return new QXdgDesktopPortalFileDialog;
+     }
+diff --git a/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp b/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
+index 43d5e119ad..1f9cbc4565 100644
+--- a/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
++++ b/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
+@@ -89,8 +89,10 @@ void QCupsPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &v
+         break;
+     case PPK_Duplex: {
+         QPrint::DuplexMode mode = QPrint::DuplexMode(value.toInt());
+-        if (mode != d->duplex && d->m_printDevice.supportedDuplexModes().contains(mode))
++        if (d->m_printDevice.supportedDuplexModes().contains(mode)) {
+             d->duplex = mode;
++            d->duplexRequestedExplicitly = true;
++        }
+         break;
+     }
+     case PPK_PrinterName:
+@@ -277,9 +279,12 @@ void QCupsPrintEnginePrivate::changePrinter(const QString &newPrinter)
+     m_printDevice.swap(printDevice);
+     printerName = m_printDevice.id();
+ 
+-    // Check if new printer supports current settings, otherwise us defaults
+-    if (duplex != QPrint::DuplexAuto && !m_printDevice.supportedDuplexModes().contains(duplex))
++    // in case a duplex value was explicitly set, check if new printer supports current value,
++    // otherwise use device default
++    if (!duplexRequestedExplicitly || !m_printDevice.supportedDuplexModes().contains(duplex)) {
+         duplex = m_printDevice.defaultDuplexMode();
++        duplexRequestedExplicitly = false;
++    }
+     QPrint::ColorMode colorMode = grayscale ? QPrint::GrayScale : QPrint::Color;
+     if (!m_printDevice.supportedColorModes().contains(colorMode))
+         grayscale = m_printDevice.defaultColorMode() == QPrint::GrayScale;
+diff --git a/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h b/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
+index c021b0c643..8f81fe478d 100644
+--- a/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
++++ b/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
+@@ -100,6 +100,7 @@ private:
+     QStringList cupsOptions;
+     QString cupsTempFile;
+     QPrint::DuplexMode duplex;
++    bool duplexRequestedExplicitly = false;
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp b/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
+index 67e7154fa6..40876152e5 100644
+--- a/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
++++ b/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
+@@ -817,7 +817,7 @@ bool QIBaseResultPrivate::writeArray(int column, const QList<QVariant> &list)
+     ba.resize(int(bufLen));
+ 
+     if (list.size() > arraySize) {
+-        error = QLatin1String("Array size missmatch: size of %1 is %2, size of provided list is %3");
++        error = QLatin1String("Array size mismatch: size of %1 is %2, size of provided list is %3");
+         error = error.arg(QLatin1String(sqlname)).arg(arraySize).arg(list.size());
+         q->setLastError(QSqlError(error, QLatin1String(""), QSqlError::StatementError));
+         return false;
+diff --git a/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp b/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
+index 7ca055eea2..6bc9d46755 100644
+--- a/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
++++ b/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
+@@ -223,7 +223,7 @@ public:
+     struct QMyField
+     {
+         char *outField = nullptr;
+-        MYSQL_FIELD *myField = nullptr;
++        const MYSQL_FIELD *myField = nullptr;
+         QMetaType::Type type = QMetaType::UnknownType;
+         my_bool nullIndicator = false;
+         ulong bufLength = 0ul;
+@@ -361,7 +361,7 @@ static bool qIsInteger(int t)
+ void QMYSQLResultPrivate::bindBlobs()
+ {
+     int i;
+-    MYSQL_FIELD *fieldInfo;
++    const MYSQL_FIELD *fieldInfo;
+     MYSQL_BIND *bind;
+ 
+     for(i = 0; i < fields.count(); ++i) {
+@@ -379,7 +379,6 @@ void QMYSQLResultPrivate::bindBlobs()
+ bool QMYSQLResultPrivate::bindInValues()
+ {
+     MYSQL_BIND *bind;
+-    char *field;
+     int i = 0;
+ 
+     if (!meta)
+@@ -392,35 +391,34 @@ bool QMYSQLResultPrivate::bindInValues()
+     inBinds = new MYSQL_BIND[fields.size()];
+     memset(inBinds, 0, fields.size() * sizeof(MYSQL_BIND));
+ 
+-    MYSQL_FIELD *fieldInfo;
++    const MYSQL_FIELD *fieldInfo;
+ 
+     while((fieldInfo = mysql_fetch_field(meta))) {
++        bind = &inBinds[i];
++
+         QMyField &f = fields[i];
+         f.myField = fieldInfo;
+-
++        bind->buffer_length = f.bufLength = fieldInfo->length + 1;
++        bind->buffer_type = fieldInfo->type;
+         f.type = qDecodeMYSQLType(fieldInfo->type, fieldInfo->flags);
+         if (qIsBlob(fieldInfo->type)) {
+             // the size of a blob-field is available as soon as we call
+             // mysql_stmt_store_result()
+             // after mysql_stmt_exec() in QMYSQLResult::exec()
+-            fieldInfo->length = 0;
++            bind->buffer_length = f.bufLength = 0;
+             hasBlobs = true;
+         } else if (qIsInteger(f.type)) {
+-            fieldInfo->length = 8;
++            bind->buffer_length = f.bufLength = 8;
+         } else {
+-            fieldInfo->type = MYSQL_TYPE_STRING;
++            bind->buffer_type = MYSQL_TYPE_STRING;
+         }
+-        bind = &inBinds[i];
+-        field = new char[fieldInfo->length + 1];
+-        memset(field, 0, fieldInfo->length + 1);
+ 
+-        bind->buffer_type = fieldInfo->type;
+-        bind->buffer = field;
+-        bind->buffer_length = f.bufLength = fieldInfo->length + 1;
+         bind->is_null = &f.nullIndicator;
+         bind->length = &f.bufLength;
+         bind->is_unsigned = fieldInfo->flags & UNSIGNED_FLAG ? 1 : 0;
+-        f.outField=field;
++
++        char *field = new char[bind->buffer_length + 1]{};
++        bind->buffer = f.outField = field;
+ 
+         ++i;
+     }
+@@ -1369,20 +1367,20 @@ bool QMYSQLDriver::open(const QString& db,
+     }
+ 
+ #if MYSQL_VERSION_ID >= 50007
+-    if (mysql_get_client_version() >= 50503 && mysql_get_server_version(d->mysql) >= 50503) {
+-        // force the communication to be utf8mb4 (only utf8mb4 supports 4-byte characters)
+-        mysql_set_character_set(d->mysql, "utf8mb4");
++    // force the communication to be utf8mb4 (only utf8mb4 supports 4-byte characters)
++    if (mysql_set_character_set(d->mysql, "utf8mb4")) {
++        // this failed, try forcing it to utf (BMP only)
++        if (mysql_set_character_set(d->mysql, "utf8"))
++            qWarning() << "MySQL: Unable to set the client character set to utf8.";
+ #if QT_CONFIG(textcodec)
+-        d->tc = QTextCodec::codecForName("UTF-8");
++        else
++            d->tc = codec(d->mysql);
+ #endif
+-    } else
+-    {
+-        // force the communication to be utf8
+-        mysql_set_character_set(d->mysql, "utf8");
++    }
+ #if QT_CONFIG(textcodec)
+-        d->tc = codec(d->mysql);
++    else
++        d->tc = QTextCodec::codecForName("UTF-8");
+ #endif
+-    }
+ #endif  // MYSQL_VERSION_ID >= 50007
+ 
+     d->preparedQuerysEnabled = checkPreparedQueries(d->mysql);
+diff --git a/qtbase/src/printsupport/dialogs/images/print-24.png b/qtbase/src/printsupport/dialogs/images/printer-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/print-24.png
+rename to src/printsupport/dialogs/images/printer-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/print-32.png b/qtbase/src/printsupport/dialogs/images/printer-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/print-32.png
+rename to src/printsupport/dialogs/images/printer-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-sided-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-facing-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-sided-24.png
+rename to src/printsupport/dialogs/images/view-pages-facing-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-sided-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-facing-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-sided-32.png
+rename to src/printsupport/dialogs/images/view-pages-facing-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-multi-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-overview-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-multi-24.png
+rename to src/printsupport/dialogs/images/view-pages-overview-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-multi-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-overview-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-multi-32.png
+rename to src/printsupport/dialogs/images/view-pages-overview-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-one-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-single-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-one-24.png
+rename to src/printsupport/dialogs/images/view-pages-single-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-one-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-single-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-one-32.png
+rename to src/printsupport/dialogs/images/view-pages-single-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-page-24.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-page-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-page-24.png
+rename to src/printsupport/dialogs/images/zoom-fit-page-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-page-32.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-page-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-page-32.png
+rename to src/printsupport/dialogs/images/zoom-fit-page-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-width-24.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-width-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-width-24.png
+rename to src/printsupport/dialogs/images/zoom-fit-width-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-width-32.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-width-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-width-32.png
+rename to src/printsupport/dialogs/images/zoom-fit-width-32.png
+diff --git a/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp b/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
+index 78e5b8d1ef..2a28516719 100644
+--- a/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
++++ b/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
+@@ -532,6 +532,7 @@ void QPageSetupWidget::updateWidget()
+ void QPageSetupWidget::setupPrinter() const
+ {
+     m_printer->setPageLayout(m_pageLayout);
++    m_printer->setPageOrientation(m_pageLayout.orientation());
+ #if QT_CONFIG(cups)
+     QCUPSSupport::PagesPerSheet pagesPerSheet = qvariant_cast<QCUPSSupport::PagesPerSheet>(m_ui.pagesPerSheetCombo->currentData()
+ );
+diff --git a/qtbase/src/printsupport/dialogs/qprintdialog.qrc b/qtbase/src/printsupport/dialogs/qprintdialog.qrc
+index 5a579baa55..10b8e1d341 100644
+--- a/qtbase/src/printsupport/dialogs/qprintdialog.qrc
++++ b/qtbase/src/printsupport/dialogs/qprintdialog.qrc
+@@ -1,9 +1,9 @@
+ <!DOCTYPE RCC><RCC version="1.0">
+ <qresource prefix="/qt-project.org/dialogs/qprintpreviewdialog">
+-<file>images/fit-page-24.png</file>
+-<file>images/fit-page-32.png</file>
+-<file>images/fit-width-24.png</file>
+-<file>images/fit-width-32.png</file>
++<file>images/zoom-fit-page-24.png</file>
++<file>images/zoom-fit-page-32.png</file>
++<file>images/zoom-fit-width-24.png</file>
++<file>images/zoom-fit-width-32.png</file>
+ <file>images/go-first-24.png</file>
+ <file>images/go-first-32.png</file>
+ <file>images/go-last-24.png</file>
+@@ -18,14 +18,14 @@
+ <file>images/layout-portrait-32.png</file>
+ <file>images/page-setup-24.png</file>
+ <file>images/page-setup-32.png</file>
+-<file>images/print-24.png</file>
+-<file>images/print-32.png</file>
+-<file>images/view-page-multi-24.png</file>
+-<file>images/view-page-multi-32.png</file>
+-<file>images/view-page-one-24.png</file>
+-<file>images/view-page-one-32.png</file>
+-<file>images/view-page-sided-24.png</file>
+-<file>images/view-page-sided-32.png</file>
++<file>images/printer-24.png</file>
++<file>images/printer-32.png</file>
++<file>images/view-pages-overview-24.png</file>
++<file>images/view-pages-overview-32.png</file>
++<file>images/view-pages-single-24.png</file>
++<file>images/view-pages-single-32.png</file>
++<file>images/view-pages-facing-24.png</file>
++<file>images/view-pages-facing-32.png</file>
+ <file>images/zoom-in-24.png</file>
+ <file>images/zoom-in-32.png</file>
+ <file>images/zoom-out-24.png</file>
+diff --git a/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp b/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
+index c5b845f4ec..5a5ba1d0a8 100644
+--- a/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
++++ b/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
+@@ -702,13 +702,14 @@ void QPrintDialogPrivate::selectPrinter(const QPrinter::OutputFormat outputForma
+         else
+             options.grayscale->setChecked(true);
+ 
+-        // keep duplex value explicitly set by user, if any, and selected printer supports it;
+-        // use device default otherwise
++        // duplex priorities to be as follows:
++        // 1) a user-selected duplex value in the dialog has highest prority
++        // 2) duplex value set in the QPrinter
+         QPrint::DuplexMode duplex;
+         if (explicitDuplexMode != QPrint::DuplexAuto && supportedDuplexMode.contains(explicitDuplexMode))
+             duplex = explicitDuplexMode;
+         else
+-            duplex = top->d->m_currentPrintDevice.defaultDuplexMode();
++            duplex = static_cast<QPrint::DuplexMode>(p->duplex());
+         switch (duplex) {
+         case QPrint::DuplexNone:
+             options.noDuplex->setChecked(true); break;
+@@ -1242,10 +1243,10 @@ void QUnixPrintWidgetPrivate::_q_printerChanged(int index)
+             QString filename = widget.filename->text();
+             widget.filename->setText(filename);
+             widget.lOutput->setEnabled(true);
+-            if (optionsPane)
+-                optionsPane->selectPrinter(QPrinter::PdfFormat);
+             printer->setOutputFormat(QPrinter::PdfFormat);
+             m_currentPrintDevice = QPrintDevice();
++            if (optionsPane)
++                optionsPane->selectPrinter(QPrinter::PdfFormat);
+             return;
+         }
+     }
+diff --git a/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp b/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
+index 39575d5f57..23b7e89538 100644
+--- a/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
++++ b/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
+@@ -352,7 +352,7 @@ void QPrintPreviewDialogPrivate::init(QPrinter *_printer)
+ static inline void qt_setupActionIcon(QAction *action, QLatin1String name)
+ {
+     QLatin1String imagePrefix(":/qt-project.org/dialogs/qprintpreviewdialog/images/");
+-    QIcon icon;
++    QIcon icon = QIcon::fromTheme(name);
+     icon.addFile(imagePrefix + name + QLatin1String("-24.png"), QSize(24, 24));
+     icon.addFile(imagePrefix + name + QLatin1String("-32.png"), QSize(32, 32));
+     action->setIcon(icon);
+@@ -383,8 +383,8 @@ void QPrintPreviewDialogPrivate::setupActions()
+     fitPageAction->setObjectName(QLatin1String("fitPageAction"));
+     fitWidthAction->setCheckable(true);
+     fitPageAction->setCheckable(true);
+-    qt_setupActionIcon(fitWidthAction, QLatin1String("fit-width"));
+-    qt_setupActionIcon(fitPageAction, QLatin1String("fit-page"));
++    qt_setupActionIcon(fitWidthAction, QLatin1String("zoom-fit-width"));
++    qt_setupActionIcon(fitPageAction, QLatin1String("zoom-fit-page"));
+     QObject::connect(fitGroup, SIGNAL(triggered(QAction*)), q, SLOT(_q_fit(QAction*)));
+ 
+     // Zoom
+@@ -410,9 +410,9 @@ void QPrintPreviewDialogPrivate::setupActions()
+     singleModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show single page"));
+     facingModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show facing pages"));
+     overviewModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show overview of all pages"));
+-    qt_setupActionIcon(singleModeAction, QLatin1String("view-page-one"));
+-    qt_setupActionIcon(facingModeAction, QLatin1String("view-page-sided"));
+-    qt_setupActionIcon(overviewModeAction, QLatin1String("view-page-multi"));
++    qt_setupActionIcon(singleModeAction, QLatin1String("view-pages-single"));
++    qt_setupActionIcon(facingModeAction, QLatin1String("view-pages-facing"));
++    qt_setupActionIcon(overviewModeAction, QLatin1String("view-pages-overview"));
+     singleModeAction->setObjectName(QLatin1String("singleModeAction"));
+     facingModeAction->setObjectName(QLatin1String("facingModeAction"));
+     overviewModeAction->setObjectName(QLatin1String("overviewModeAction"));
+@@ -426,7 +426,7 @@ void QPrintPreviewDialogPrivate::setupActions()
+     printerGroup = new QActionGroup(q);
+     printAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Print"));
+     pageSetupAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Page setup"));
+-    qt_setupActionIcon(printAction, QLatin1String("print"));
++    qt_setupActionIcon(printAction, QLatin1String("printer"));
+     qt_setupActionIcon(pageSetupAction, QLatin1String("page-setup"));
+     QObject::connect(printAction, SIGNAL(triggered(bool)), q, SLOT(_q_print()));
+     QObject::connect(pageSetupAction, SIGNAL(triggered(bool)), q, SLOT(_q_pageSetup()));
+diff --git a/qtbase/src/sql/kernel/qsqlquery.cpp b/qtbase/src/sql/kernel/qsqlquery.cpp
+index 32c6166c79..60afef10c3 100644
+--- a/qtbase/src/sql/kernel/qsqlquery.cpp
++++ b/qtbase/src/sql/kernel/qsqlquery.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2022 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtSql module of the Qt Toolkit.
+@@ -377,6 +377,10 @@ bool QSqlQuery::exec(const QString& query)
+     QElapsedTimer t;
+     t.start();
+ #endif
++    if (!driver()) {
++        qWarning("QSqlQuery::exec: called before driver has been set up");
++        return false;
++    }
+     if (d->ref.loadRelaxed() != 1) {
+         bool fo = isForwardOnly();
+         *this = QSqlQuery(driver()->createResult());
+diff --git a/qtbase/src/testlib/qabstractitemmodeltester.cpp b/qtbase/src/testlib/qabstractitemmodeltester.cpp
+index 8efb9c53d4..ce062f66d7 100644
+--- a/qtbase/src/testlib/qabstractitemmodeltester.cpp
++++ b/qtbase/src/testlib/qabstractitemmodeltester.cpp
+@@ -454,7 +454,7 @@ void QAbstractItemModelTesterPrivate::parent()
+ 
+     // Common error test #2, make sure that a second level index has a parent
+     // that is the first level index.
+-    if (model->rowCount(topIndex) > 0) {
++    if (model->rowCount(topIndex) > 0 && model->columnCount(topIndex) > 0) {
+         QModelIndex childIndex = model->index(0, 0, topIndex);
+         MODELTESTER_VERIFY(childIndex.isValid());
+         MODELTESTER_COMPARE(model->parent(childIndex), topIndex);
+diff --git a/qtbase/src/testlib/qasciikey.cpp b/qtbase/src/testlib/qasciikey.cpp
+index 9a308da2bc..93498b256f 100644
+--- a/qtbase/src/testlib/qasciikey.cpp
++++ b/qtbase/src/testlib/qasciikey.cpp
+@@ -498,6 +498,11 @@ char QTest::keyToAscii(Qt::Key key)
+     case Qt::Key_LaunchE : return 0; // = 0x10b0,
+     case Qt::Key_LaunchF : return 0; // = 0x10b1,
+ 
++    // Keypad navigation keys
++    case Qt::Key_Select : return 0; // = 0x01010000
++    case Qt::Key_Yes : return 0; // = 0x01010001
++    case Qt::Key_No : return 0; // = 0x01010002
++
+     default: QTEST_ASSERT(false); return 0;
+     }
+ }
+diff --git a/qtbase/src/testlib/qtestresult.cpp b/qtbase/src/testlib/qtestresult.cpp
+index 88028aac6e..2e89930776 100644
+--- a/qtbase/src/testlib/qtestresult.cpp
++++ b/qtbase/src/testlib/qtestresult.cpp
+@@ -251,7 +251,8 @@ bool QTestResult::verify(bool statement, const char *statementStr,
+ {
+     QTEST_ASSERT(statementStr);
+ 
+-    char msg[1024] = {'\0'};
++    char msg[1024];
++    msg[0] = '\0';
+ 
+     if (QTestLog::verboseLevel() >= 2) {
+         qsnprintf(msg, 1024, "QVERIFY(%s)", statementStr);
+@@ -309,7 +310,8 @@ static bool compareHelper(bool success, const char *failureMsg,
+                           bool hasValues = true)
+ {
+     const size_t maxMsgLen = 1024;
+-    char msg[maxMsgLen] = {'\0'};
++    char msg[maxMsgLen];
++    msg[0] = '\0';
+ 
+     QTEST_ASSERT(expected);
+     QTEST_ASSERT(actual);
+diff --git a/qtbase/src/widgets/dialogs/qcolordialog.cpp b/qtbase/src/widgets/dialogs/qcolordialog.cpp
+index 4247731275..cb325be85c 100644
+--- a/qtbase/src/widgets/dialogs/qcolordialog.cpp
++++ b/qtbase/src/widgets/dialogs/qcolordialog.cpp
+@@ -78,7 +78,10 @@
+ #include "qwindow.h"
+ 
+ #include "private/qdialog_p.h"
++#include "private/qguiapplication_p.h"
+ 
++#include <qpa/qplatformservices.h>
++#include <qpa/qplatformintegration.h>
+ #include <algorithm>
+ 
+ QT_BEGIN_NAMESPACE
+@@ -1611,6 +1614,20 @@ void QColorDialogPrivate::_q_newStandard(int r, int c)
+ void QColorDialogPrivate::_q_pickScreenColor()
+ {
+     Q_Q(QColorDialog);
++
++    auto *platformServices = QGuiApplicationPrivate::platformIntegration()->services();
++    if (platformServices->hasCapability(QPlatformServices::Capability::ColorPicking)) {
++        if (auto *colorPicker = platformServices->colorPicker(q->windowHandle())) {
++            q->connect(colorPicker, &QPlatformServiceColorPicker::colorPicked, q,
++                       [q, colorPicker](const QColor &color) {
++                           colorPicker->deleteLater();
++                           q->setCurrentColor(color);
++                       });
++            colorPicker->pickColor();
++            return;
++        }
++    }
++
+     if (!colorPickingEventFilter)
+         colorPickingEventFilter = new QColorPickingEventFilter(this, q);
+     q->installEventFilter(colorPickingEventFilter);
+diff --git a/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp b/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
+index e120817edc..8ea36b5427 100644
+--- a/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
++++ b/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
+@@ -400,12 +400,7 @@ bool QAbstractItemDelegate::helpEvent(QHelpEvent *event,
+         const QString tooltip = index.isValid() ?
+               d->textForRole(Qt::ToolTipRole, index.data(Qt::ToolTipRole), option.locale, precision) :
+               QString();
+-        QRect rect;
+-        if (index.isValid()) {
+-            const QRect r = view->visualRect(index);
+-            rect = QRect(view->mapToGlobal(r.topLeft()), r.size());
+-        }
+-        QToolTip::showText(he->globalPos(), tooltip, view, rect);
++        QToolTip::showText(he->globalPos(), tooltip, view->viewport(), option.rect);
+         event->setAccepted(!tooltip.isEmpty());
+         break;
+         }
+diff --git a/qtbase/src/widgets/itemviews/qlistview.cpp b/qtbase/src/widgets/itemviews/qlistview.cpp
+index 2b34476642..eebfaa030e 100644
+--- a/qtbase/src/widgets/itemviews/qlistview.cpp
++++ b/qtbase/src/widgets/itemviews/qlistview.cpp
+@@ -3386,6 +3386,7 @@ void QIconModeViewBase::updateContentsSize()
+ */
+ void QListView::currentChanged(const QModelIndex &current, const QModelIndex &previous)
+ {
++    QAbstractItemView::currentChanged(current, previous);
+ #ifndef QT_NO_ACCESSIBILITY
+     if (QAccessible::isActive()) {
+         if (current.isValid()) {
+@@ -3396,7 +3397,6 @@ void QListView::currentChanged(const QModelIndex &current, const QModelIndex &pr
+         }
+     }
+ #endif
+-    QAbstractItemView::currentChanged(current, previous);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/widgets/itemviews/qtableview.cpp b/qtbase/src/widgets/itemviews/qtableview.cpp
+index 934ac581b2..f79bb24249 100644
+--- a/qtbase/src/widgets/itemviews/qtableview.cpp
++++ b/qtbase/src/widgets/itemviews/qtableview.cpp
+@@ -1013,6 +1013,7 @@ void QTableViewPrivate::drawCell(QPainter *painter, const QStyleOptionViewItem &
+ int QTableViewPrivate::widthHintForIndex(const QModelIndex &index, int hint, const QStyleOptionViewItem &option) const
+ {
+     Q_Q(const QTableView);
++    const int oldHint = hint;
+     QWidget *editor = editorForIndex(index).widget.data();
+     if (editor && persistent.contains(editor)) {
+         hint = qMax(hint, editor->sizeHint().width());
+@@ -1021,6 +1022,17 @@ int QTableViewPrivate::widthHintForIndex(const QModelIndex &index, int hint, con
+         hint = qBound(min, hint, max);
+     }
+     hint = qMax(hint, q->itemDelegate(index)->sizeHint(option, index).width());
++
++    if (hasSpans()) {
++        auto span = spans.spanAt(index.column(), index.row());
++        if (span && span->m_left == index.column() && span->m_top == index.row()) {
++            // spans are screwed up when sections are moved
++            const auto left = logicalColumn(span->m_left);
++            for (int i = 1; i <= span->width(); ++i)
++               hint -= q->columnWidth(visualColumn(left + i));
++        }
++        hint = std::max(hint, oldHint);
++    }
+     return hint;
+ }
+ 
+@@ -1053,6 +1065,11 @@ int QTableViewPrivate::heightHintForIndex(const QModelIndex &index, int hint, QS
+         option.rect.setHeight(height);
+         option.rect.setX(q->columnViewportPosition(index.column()));
+         option.rect.setWidth(q->columnWidth(index.column()));
++        if (hasSpans()) {
++            auto span = spans.spanAt(index.column(), index.row());
++            if (span && span->m_left == index.column() && span->m_top == index.row())
++                option.rect.setWidth(std::max(option.rect.width(), visualSpanRect(*span).width()));
++        }
+         // 1px less space when grid is shown (see drawCell)
+         if (showGrid)
+             option.rect.setWidth(option.rect.width() - 1);
+diff --git a/qtbase/src/widgets/kernel/qaction.h b/qtbase/src/widgets/kernel/qaction.h
+index 258a1ea0a0..737c1e8285 100644
+--- a/qtbase/src/widgets/kernel/qaction.h
++++ b/qtbase/src/widgets/kernel/qaction.h
+@@ -81,7 +81,7 @@ class Q_WIDGETS_EXPORT QAction : public QObject
+     Q_PROPERTY(MenuRole menuRole READ menuRole WRITE setMenuRole NOTIFY changed)
+     Q_PROPERTY(bool iconVisibleInMenu READ isIconVisibleInMenu WRITE setIconVisibleInMenu NOTIFY changed)
+     Q_PROPERTY(bool shortcutVisibleInContextMenu READ isShortcutVisibleInContextMenu WRITE setShortcutVisibleInContextMenu NOTIFY changed)
+-    Q_PROPERTY(Priority priority READ priority WRITE setPriority)
++    Q_PROPERTY(Priority priority READ priority WRITE setPriority NOTIFY changed)
+ 
+ public:
+     // note this is copied into qplatformmenu.h, which must stay in sync
+diff --git a/qtbase/src/widgets/kernel/qwidget.cpp b/qtbase/src/widgets/kernel/qwidget.cpp
+index 9eba1e001e..26f6d27e18 100644
+--- a/qtbase/src/widgets/kernel/qwidget.cpp
++++ b/qtbase/src/widgets/kernel/qwidget.cpp
+@@ -5296,7 +5296,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
+         QWidgetEffectSourcePrivate *sourced = static_cast<QWidgetEffectSourcePrivate *>
+                                                          (source->d_func());
+         if (!sourced->context) {
+-            const QRegion effectRgn(rgn.boundingRect());
++            const QRegion effectRgn((flags & UseEffectRegionBounds) ? rgn.boundingRect() : rgn);
+             QWidgetPaintContext context(pdev, effectRgn, offset, flags, sharedPainter, repaintManager);
+             sourced->context = &context;
+             if (!sharedPainter) {
+@@ -5328,6 +5328,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
+         }
+     }
+ #endif // QT_CONFIG(graphicseffect)
++    flags = flags & ~UseEffectRegionBounds;
+ 
+     const bool alsoOnScreen = flags & DrawPaintOnScreen;
+     const bool recursive = flags & DrawRecursive;
+diff --git a/qtbase/src/widgets/kernel/qwidget_p.h b/qtbase/src/widgets/kernel/qwidget_p.h
+index eef6b8fa2c..c432f4b5d5 100644
+--- a/qtbase/src/widgets/kernel/qwidget_p.h
++++ b/qtbase/src/widgets/kernel/qwidget_p.h
+@@ -229,7 +229,8 @@ public:
+         DontSubtractOpaqueChildren = 0x10,
+         DontDrawOpaqueChildren = 0x20,
+         DontDrawNativeChildren = 0x40,
+-        DontSetCompositionMode = 0x80
++        DontSetCompositionMode = 0x80,
++        UseEffectRegionBounds = 0x100
+     };
+     Q_DECLARE_FLAGS(DrawWidgetFlags, DrawWidgetFlag)
+     Q_FLAG(DrawWidgetFlags)
+diff --git a/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp b/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
+index 02880b34da..0d44e1326d 100644
+--- a/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
++++ b/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
+@@ -1018,7 +1018,8 @@ void QWidgetRepaintManager::paintAndFlush()
+ 
+     // Paint the rest with composition.
+     if (repaintAllWidgets || !dirtyCopy.isEmpty()) {
+-        QWidgetPrivate::DrawWidgetFlags flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive;
++        QWidgetPrivate::DrawWidgetFlags flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive
++                | QWidgetPrivate::UseEffectRegionBounds;
+         tlw->d_func()->drawWidget(store->paintDevice(), dirtyCopy, QPoint(), flags, nullptr, this);
+     }
+ 
+diff --git a/qtbase/src/widgets/styles/qfusionstyle.cpp b/qtbase/src/widgets/styles/qfusionstyle.cpp
+index f4345d97c4..962912c838 100644
+--- a/qtbase/src/widgets/styles/qfusionstyle.cpp
++++ b/qtbase/src/widgets/styles/qfusionstyle.cpp
+@@ -1772,14 +1772,6 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio
+             proxy()->drawControl(CE_PushButtonLabel, &subopt, painter, widget);
+         }
+         break;
+-    case CE_PushButtonLabel:
+-        if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
+-            QStyleOptionButton b(*button);
+-            // no PM_ButtonShiftHorizontal and PM_ButtonShiftVertical for fusion style
+-            b.state &= ~(State_On | State_Sunken);
+-            QCommonStyle::drawControl(element, &b, painter, widget);
+-        }
+-        break;
+     case CE_MenuBarEmptyArea:
+         painter->save();
+     {
+diff --git a/qtbase/src/widgets/util/qcompleter.cpp b/qtbase/src/widgets/util/qcompleter.cpp
+index 18b24063d8..ef7207a8a3 100644
+--- a/qtbase/src/widgets/util/qcompleter.cpp
++++ b/qtbase/src/widgets/util/qcompleter.cpp
+@@ -1120,6 +1120,8 @@ void QCompleter::setModel(QAbstractItemModel *model)
+ {
+     Q_D(QCompleter);
+     QAbstractItemModel *oldModel = d->proxy->sourceModel();
++    if (oldModel == model)
++        return;
+ #if QT_CONFIG(filesystemmodel)
+     if (qobject_cast<const QFileSystemModel *>(oldModel))
+         setCompletionRole(Qt::EditRole); // QTBUG-54642, clear FileNameRole set by QFileSystemModel
+diff --git a/qtbase/src/widgets/widgets/qabstractbutton.cpp b/qtbase/src/widgets/widgets/qabstractbutton.cpp
+index a128b23950..dc40bf62fb 100644
+--- a/qtbase/src/widgets/widgets/qabstractbutton.cpp
++++ b/qtbase/src/widgets/widgets/qabstractbutton.cpp
+@@ -56,6 +56,7 @@
+ #ifndef QT_NO_ACCESSIBILITY
+ #include "qaccessible.h"
+ #endif
++#include <qpa/qplatformtheme.h>
+ 
+ #include <algorithm>
+ 
+@@ -1076,19 +1077,19 @@ void QAbstractButton::keyPressEvent(QKeyEvent *e)
+ {
+     Q_D(QAbstractButton);
+     bool next = true;
+-    switch (e->key()) {
+-    case Qt::Key_Enter:
+-    case Qt::Key_Return:
+-        e->ignore();
+-        break;
+-    case Qt::Key_Select:
+-    case Qt::Key_Space:
+-        if (!e->isAutoRepeat()) {
+-            setDown(true);
+-            repaint();
+-            d->emitPressed();
+-        }
+-        break;
++
++    const auto key = static_cast<Qt::Key>(e->key());
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(key) && !e->isAutoRepeat()) {
++        setDown(true);
++        repaint();
++        d->emitPressed();
++        return;
++    }
++
++    switch (key) {
+     case Qt::Key_Up:
+         next = false;
+         Q_FALLTHROUGH();
+@@ -1153,15 +1154,15 @@ void QAbstractButton::keyReleaseEvent(QKeyEvent *e)
+     if (!e->isAutoRepeat())
+         d->repeatTimer.stop();
+ 
+-    switch (e->key()) {
+-    case Qt::Key_Select:
+-    case Qt::Key_Space:
+-        if (!e->isAutoRepeat() && d->down)
+-            d->click();
+-        break;
+-    default:
+-        e->ignore();
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(static_cast<Qt::Key>(e->key())) && !e->isAutoRepeat() && d->down) {
++        d->click();
++        return;
+     }
++
++    e->ignore();
+ }
+ 
+ /*!\reimp
+diff --git a/qtbase/src/widgets/widgets/qcombobox.cpp b/qtbase/src/widgets/widgets/qcombobox.cpp
+index 7a496c27e0..0a3d96647b 100644
+--- a/qtbase/src/widgets/widgets/qcombobox.cpp
++++ b/qtbase/src/widgets/widgets/qcombobox.cpp
+@@ -3352,7 +3352,23 @@ void QComboBox::keyPressEvent(QKeyEvent *e)
+ 
+     Move move = NoMove;
+     int newIndex = currentIndex();
+-    switch (e->key()) {
++
++    bool pressLikeButton = !d->lineEdit;
++#ifdef QT_KEYPAD_NAVIGATION
++    pressLikeButton |= QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus();
++#endif
++    auto key = static_cast<Qt::Key>(e->key());
++    if (pressLikeButton) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(key)) {
++            showPopup();
++            return;
++        }
++    }
++
++    switch (key) {
+     case Qt::Key_Up:
+         if (e->modifiers() & Qt::ControlModifier)
+             break; // pass to line edit for auto completion
+@@ -3394,26 +3410,11 @@ void QComboBox::keyPressEvent(QKeyEvent *e)
+             return;
+         }
+         break;
+-    case Qt::Key_Space:
+-        if (!d->lineEdit) {
+-            showPopup();
+-            return;
+-        }
+-        break;
+-    case Qt::Key_Enter:
+-    case Qt::Key_Return:
+     case Qt::Key_Escape:
+         if (!d->lineEdit)
+             e->ignore();
+         break;
+ #ifdef QT_KEYPAD_NAVIGATION
+-    case Qt::Key_Select:
+-        if (QApplicationPrivate::keypadNavigationEnabled()
+-                && (!hasEditFocus() || !d->lineEdit)) {
+-            showPopup();
+-            return;
+-        }
+-        break;
+     case Qt::Key_Left:
+     case Qt::Key_Right:
+         if (QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus())
+diff --git a/qtbase/src/widgets/widgets/qdatetimeedit_p.h b/qtbase/src/widgets/widgets/qdatetimeedit_p.h
+index d36b6f8f9a..e0df5b5158 100644
+--- a/qtbase/src/widgets/widgets/qdatetimeedit_p.h
++++ b/qtbase/src/widgets/widgets/qdatetimeedit_p.h
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2018 The Qt Company Ltd.
++** Copyright (C) 2021 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtWidgets module of the Qt Toolkit.
+diff --git a/qtbase/src/widgets/widgets/qgroupbox.cpp b/qtbase/src/widgets/widgets/qgroupbox.cpp
+index 02a0bed325..3f3eccc370 100644
+--- a/qtbase/src/widgets/widgets/qgroupbox.cpp
++++ b/qtbase/src/widgets/widgets/qgroupbox.cpp
+@@ -54,6 +54,8 @@
+ #include "qaccessible.h"
+ #endif
+ #include <private/qwidget_p.h>
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
+ 
+ #include "qdebug.h"
+ 
+@@ -360,7 +362,10 @@ bool QGroupBox::event(QEvent *e)
+         return true;
+     case QEvent::KeyPress: {
+         QKeyEvent *k = static_cast<QKeyEvent*>(e);
+-        if (!k->isAutoRepeat() && (k->key() == Qt::Key_Select || k->key() == Qt::Key_Space)) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (!k->isAutoRepeat() && buttonPressKeys.contains(static_cast<Qt::Key>(k->key()))) {
+             d->pressedControl = QStyle::SC_GroupBoxCheckBox;
+             update(style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxCheckBox, this));
+             return true;
+@@ -369,7 +374,10 @@ bool QGroupBox::event(QEvent *e)
+     }
+     case QEvent::KeyRelease: {
+         QKeyEvent *k = static_cast<QKeyEvent*>(e);
+-        if (!k->isAutoRepeat() && (k->key() == Qt::Key_Select || k->key() == Qt::Key_Space)) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (!k->isAutoRepeat() && buttonPressKeys.contains(static_cast<Qt::Key>(k->key()))) {
+             bool toggle = (d->pressedControl == QStyle::SC_GroupBoxLabel
+                            || d->pressedControl == QStyle::SC_GroupBoxCheckBox);
+             d->pressedControl = QStyle::SC_None;
+diff --git a/qtbase/src/widgets/widgets/qlabel.cpp b/qtbase/src/widgets/widgets/qlabel.cpp
+index 30ff80cbb0..cf2605c17c 100644
+--- a/qtbase/src/widgets/widgets/qlabel.cpp
++++ b/qtbase/src/widgets/widgets/qlabel.cpp
+@@ -421,9 +421,6 @@ void QLabel::setPixmap(const QPixmap &pixmap)
+         d->pixmap = new QPixmap(pixmap);
+     }
+ 
+-    if (d->pixmap->depth() == 1 && !d->pixmap->mask())
+-        d->pixmap->setMask(*((QBitmap *)d->pixmap));
+-
+     d->updateLabel();
+ }
+ 
+diff --git a/qtbase/src/widgets/widgets/qtoolbararealayout.cpp b/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
+index 493c094cc1..d5f4b59017 100644
+--- a/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
++++ b/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
+@@ -1367,7 +1367,7 @@ bool QToolBarAreaLayout::restoreState(QDataStream &stream, const QList<QToolBar*
+                 item.widgetItem = new QWidgetItemV2(toolBar);
+                 toolBar->setOrientation(floating ? ((shown & 2) ? Qt::Vertical : Qt::Horizontal) : dock.o);
+                 toolBar->setVisible(shown & 1);
+-                toolBar->d_func()->setWindowState(floating, true, rect);
++                toolBar->d_func()->setWindowState(floating, false, rect);
+ 
+                 item.preferredSize = item.size;
+                 line.toolBarItems.append(item);
+diff --git a/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp b/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
+index 212c0a2e13..3c77b1ba0b 100644
+--- a/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
++++ b/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
+@@ -126,8 +126,7 @@ public:
+ 
+ void tst_QtConcurrentIterateKernel::instantiate()
+ {
+-    auto future = startThreadEngine(new PrintFor(0, 40)).startAsynchronously();
+-    future.waitForFinished();
++    startThreadEngine(new PrintFor(0, 40)).startBlocking();
+     QCOMPARE(iterations.loadRelaxed(), 40);
+ }
+ 
+@@ -166,10 +165,8 @@ void tst_QtConcurrentIterateKernel::stresstest()
+     const int times = 50;
+     for (int i = 0; i < times; ++i) {
+         counter.storeRelaxed(0);
+-        // ThreadEngine will delete f when it finishes
+-        auto f = new CountFor(0, iterations);
+-        auto future = f->startAsynchronously();
+-        future.waitForFinished();
++        CountFor f(0, iterations);
++        f.startBlocking();
+         QCOMPARE(counter.loadRelaxed(), iterations);
+     }
+ }
+@@ -177,11 +174,8 @@ void tst_QtConcurrentIterateKernel::stresstest()
+ void tst_QtConcurrentIterateKernel::noIterations()
+ {
+     const int times = 20000;
+-    for (int i = 0; i < times; ++i) {
+-        auto future = startThreadEngine(new IterateKernel<TestIterator, void>(0, 0))
+-                              .startAsynchronously();
+-        future.waitForFinished();
+-    }
++    for (int i = 0; i < times; ++i)
++        startThreadEngine(new IterateKernel<TestIterator, void>(0, 0)).startBlocking();
+ }
+ 
+ QMutex threadsMutex;
+@@ -236,10 +230,8 @@ void tst_QtConcurrentIterateKernel::throttling()
+ 
+     threads.clear();
+ 
+-    // ThreadEngine will delete f when it finishes
+-    auto f = new ThrottleFor(0, totalIterations);
+-    auto future = f->startAsynchronously();
+-    future.waitForFinished();
++    ThrottleFor f(0, totalIterations);
++    f.startBlocking();
+ 
+     QCOMPARE(iterations.loadRelaxed(), totalIterations);
+ 
+diff --git a/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp b/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
+index ac7be7acdd..81bc64c8d9 100644
+--- a/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
++++ b/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
+@@ -65,9 +65,16 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::runDirectly()
+ {
+-    PrintUser *engine = new PrintUser();
+-    QFuture<void> f = engine->startAsynchronously();
+-    f.waitForFinished();
++    {
++        PrintUser engine;
++        engine.startSingleThreaded();
++        engine.startBlocking();
++    }
++    {
++        PrintUser *engine = new PrintUser();
++        QFuture<void> f = engine->startAsynchronously();
++        f.waitForFinished();
++    }
+ }
+ 
+ class StringResultUser : public ThreadEngine<QString>
+@@ -99,10 +106,8 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::result()
+ {
+-    // ThreadEngine will delete 'engine' when it finishes
+-    auto engine = new StringResultUser();
+-    auto future = engine->startAsynchronously();
+-    QCOMPARE(future.result(), QString("Foo"));
++    StringResultUser engine;
++    QCOMPARE(*engine.startBlocking(), QString("Foo"));
+ }
+ 
+ class VoidResultUser : public ThreadEngine<void>
+@@ -128,9 +133,17 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::runThroughStarter()
+ {
+-    ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
+-    QFuture<QString> f = starter.startAsynchronously();
+-    QCOMPARE(f.result(), QString("Foo"));
++    {
++        ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
++        QFuture<QString>  f = starter.startAsynchronously();
++        QCOMPARE(f.result(), QString("Foo"));
++    }
++
++    {
++        ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
++        QString str = starter.startBlocking();
++        QCOMPARE(str, QString("Foo"));
++    }
+ }
+ 
+ class CancelUser : public ThreadEngine<void>
+@@ -213,6 +226,12 @@ void tst_QtConcurrentThreadEngine::throttle()
+         f.waitForFinished();
+         QCOMPARE(count.loadRelaxed(), 0);
+     }
++
++    for (int i = 0; i < repeats; ++i) {
++        ThrottleAlwaysUser t;
++        t.startBlocking();
++        QCOMPARE(count.loadRelaxed(), 0);
++    }
+ }
+ 
+ QSet<QThread *> threads;
+@@ -249,17 +268,35 @@ void tst_QtConcurrentThreadEngine::threadCount()
+ {
+     const int repeats = 10;
+     for (int i = 0; i < repeats; ++i) {
++        ThreadCountUser t;
++        t.startBlocking();
++        int count = threads.count();
++        int count_expected = QThreadPool::globalInstance()->maxThreadCount() + 1; // +1 for the main thread.
++        if (count != count_expected)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, count_expected);
++
+         (new ThreadCountUser())->startAsynchronously().waitForFinished();
+-        const auto count = threads.count();
+-        const auto maxThreadCount = QThreadPool::globalInstance()->maxThreadCount();
+-        QVERIFY(count <= maxThreadCount);
+-        QVERIFY(!threads.contains(QThread::currentThread()));
++        count = threads.count();
++        count_expected = QThreadPool::globalInstance()->maxThreadCount();
++        if (count != count_expected)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, count_expected);
+     }
+ 
+     // Set the finish flag immediately, this should give us one thread only.
+     for (int i = 0; i < repeats; ++i) {
++        ThreadCountUser t(true /*finishImmediately*/);
++        t.startBlocking();
++        int count = threads.count();
++        if (count != 1)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, 1);
++
+         (new ThreadCountUser(true /*finishImmediately*/))->startAsynchronously().waitForFinished();
+-        const auto count = threads.count();
++        count = threads.count();
++        if (count != 1)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
+         QCOMPARE(count, 1);
+         QVERIFY(!threads.contains(QThread::currentThread()));
+     }
+@@ -400,6 +437,7 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::exceptions()
+ {
++    // Asynchronous mode:
+     {
+         bool caught = false;
+         try  {
+@@ -412,6 +450,32 @@ void tst_QtConcurrentThreadEngine::exceptions()
+         QVERIFY2(caught, "did not get exception");
+     }
+ 
++    // Blocking mode:
++    // test throwing the exception from a worker thread.
++    {
++        bool caught = false;
++        try  {
++            QtConcurrentExceptionThrower e(QThread::currentThread());
++            e.startBlocking();
++        } catch (const QException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // test throwing the exception from the main thread (different code path)
++    {
++        bool caught = false;
++        try  {
++            QtConcurrentExceptionThrower e(0);
++            e.startBlocking();
++        } catch (const QException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // Asynchronous mode:
+     {
+         bool caught = false;
+         try  {
+@@ -423,6 +487,31 @@ void tst_QtConcurrentThreadEngine::exceptions()
+         }
+         QVERIFY2(caught, "did not get exception");
+     }
++
++    // Blocking mode:
++    // test throwing the exception from a worker thread.
++    {
++        bool caught = false;
++        try  {
++            UnrelatedExceptionThrower e(QThread::currentThread());
++            e.startBlocking();
++        } catch (const QUnhandledException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // test throwing the exception from the main thread (different code path)
++    {
++        bool caught = false;
++        try  {
++            UnrelatedExceptionThrower e(0);
++            e.startBlocking();
++        } catch (const QUnhandledException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
+ }
+ 
+ #endif
+diff --git a/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp b/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
+index 4968742110..f4c3fb711d 100644
+--- a/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
++++ b/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
+@@ -42,6 +42,7 @@ private slots:
+     void writeBlock_data();
+     void writeBlock();
+     void seek();
++    void invalidSeeks();
+     void seekTest_data();
+     void seekTest();
+     void read_rawdata();
+@@ -286,6 +287,29 @@ void tst_QBuffer::seek()
+     QCOMPARE(buffer.size(), pos);
+ }
+ 
++void tst_QBuffer::invalidSeeks()
++{
++    if constexpr (sizeof(qsizetype) == sizeof(qint64)) {
++        // sizeof(qsizetype) == sizeof(qint64), so +1 would overflow
++        QSKIP("This is a 32-bit-only test.");
++    } else {
++        QBuffer buffer;
++        buffer.open(QIODevice::WriteOnly);
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++        constexpr qint64 MaxQByteArrayCapacity = (std::numeric_limits<qsizetype>::max)();
++        // this should fail fast, not after trying to allocate nearly 2 GiB of data,
++        // potentially crashing in the process:
++        QVERIFY(!buffer.seek(2 * MaxQByteArrayCapacity - 1));
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++        // ditto:
++        QVERIFY(!buffer.seek(MaxQByteArrayCapacity + 1));
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++    }
++}
++
+ void tst_QBuffer::seekTest_data()
+ {
+     writeBlock_data();
+diff --git a/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp b/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
+index da5327594c..4a04e0f7c6 100644
+--- a/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
++++ b/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
+@@ -561,7 +561,8 @@ protected:
+     qint64 readData(char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf->size() - offset));
+-        memcpy(data, buf->constData() + offset, maxSize);
++        if (maxSize > 0)
++            memcpy(data, buf->constData() + offset, maxSize);
+         offset += maxSize;
+         return maxSize;
+     }
+@@ -604,13 +605,15 @@ protected:
+     qint64 readData(char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf.size() - pos()));
+-        memcpy(data, buf.constData() + pos(), maxSize);
++        if (maxSize > 0)
++            memcpy(data, buf.constData() + pos(), maxSize);
+         return maxSize;
+     }
+     qint64 writeData(const char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf.size() - pos()));
+-        memcpy(buf.data() + pos(), data, maxSize);
++        if (maxSize > 0)
++            memcpy(buf.data() + pos(), data, maxSize);
+         return maxSize;
+     }
+ 
+diff --git a/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+index db60bead64..f345a44414 100644
+--- a/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
++++ b/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+@@ -1,7 +1,8 @@
+ /****************************************************************************
+ **
+ ** Copyright (C) 2021 The Qt Company Ltd.
+-** Copyright (C) 2020 Intel Corporation.
++** Copyright (C) 2020 The Qt Company Ltd.
++** Copyright (C) 2022 Intel Corporation.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the test suite of the Qt Toolkit.
+@@ -150,6 +151,8 @@ private slots:
+     void startStopStartStopBuffers();
+     void processEventsInAReadyReadSlot_data();
+     void processEventsInAReadyReadSlot();
++    void startFromCurrentWorkingDir_data();
++    void startFromCurrentWorkingDir();
+ 
+     // keep these at the end, since they use lots of processes and sometimes
+     // caused obscure failures to occur in tests that followed them (esp. on the Mac)
+@@ -2731,5 +2734,94 @@ void tst_QProcess::finishProcessBeforeReadingDone_deprecated()
+ 
+ #endif
+ 
++enum class ChdirMode {
++    None = 0,
++    InParent,
++    InChild
++};
++Q_DECLARE_METATYPE(ChdirMode)
++
++void tst_QProcess::startFromCurrentWorkingDir_data()
++{
++    qRegisterMetaType<ChdirMode>();
++    QTest::addColumn<QString>("programPrefix");
++    QTest::addColumn<ChdirMode>("chdirMode");
++    QTest::addColumn<bool>("success");
++
++    constexpr bool IsWindows = true
++#ifdef Q_OS_UNIX
++            && false
++#endif
++            ;
++
++    // baseline: trying to execute the directory, this can't possibly succeed!
++    QTest::newRow("plain-same-cwd") << QString() << ChdirMode::None << false;
++
++    // cross-platform behavior: neither OS searches the setWorkingDirectory()
++    // dir without "./"
++    QTest::newRow("plain-child-chdir") << QString() << ChdirMode::InChild << false;
++
++    // cross-platform behavior: both OSes search the parent's CWD with "./"
++    QTest::newRow("prefixed-parent-chdir") << "./" << ChdirMode::InParent << true;
++
++    // opposite behaviors: Windows searches the parent's CWD and Unix searches
++    // the child's with "./"
++    QTest::newRow("prefixed-child-chdir") << "./" << ChdirMode::InChild << !IsWindows;
++
++    // Windows searches the parent's CWD without "./"
++    QTest::newRow("plain-parent-chdir") << QString() << ChdirMode::InParent << IsWindows;
++}
++
++void tst_QProcess::startFromCurrentWorkingDir()
++{
++    QFETCH(QString, programPrefix);
++    QFETCH(ChdirMode, chdirMode);
++    QFETCH(bool, success);
++
++    QProcess process;
++    qRegisterMetaType<QProcess::ProcessError>();
++    QSignalSpy errorSpy(&process, &QProcess::errorOccurred);
++    QVERIFY(errorSpy.isValid());
++
++    // both the dir name and the executable name
++    const QString target = QStringLiteral("testProcessNormal");
++    process.setProgram(programPrefix + target);
++
++#ifdef Q_OS_UNIX
++    // Reset PATH, to be sure it doesn't contain . or the empty path.
++    // We can't do this on Windows because DLLs are searched in PATH
++    // and Windows always searches "." anyway.
++    auto restoreEnv = qScopeGuard([old = qgetenv("PATH")] {
++        qputenv("PATH", old);
++    });
++    qputenv("PATH", "/");
++#endif
++
++    switch (chdirMode) {
++    case ChdirMode::InParent: {
++        auto restoreCwd = qScopeGuard([old = QDir::currentPath()] {
++            QDir::setCurrent(old);
++        });
++        QVERIFY(QDir::setCurrent(target));
++        process.start();
++        break;
++    }
++    case ChdirMode::InChild:
++        process.setWorkingDirectory(target);
++        Q_FALLTHROUGH();
++    case ChdirMode::None:
++        process.start();
++        break;
++    }
++
++    QCOMPARE(process.waitForStarted(), success);
++    QCOMPARE(errorSpy.count(), int(!success));
++    if (success) {
++        QVERIFY(process.waitForFinished());
++    } else {
++        QCOMPARE(process.error(), QProcess::FailedToStart);
++    }
++}
++
+ QTEST_MAIN(tst_QProcess)
+ #include "tst_qprocess.moc"
+diff --git a/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp b/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp
+index e1ea7a4552..90972caa57 100644
+--- a/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp
++++ b/qtbase/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"
+diff --git a/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+index 9bd66c0835..ed4a0bae5d 100644
+--- a/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
++++ b/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+@@ -158,6 +158,7 @@ private slots:
+     void nullReceiver();
+     void functorReferencesConnection();
+     void disconnectDisconnects();
++    void declarativeData();
+ };
+ 
+ struct QObjectCreatedOnShutdown
+@@ -7679,5 +7680,81 @@ void tst_QObject::disconnectDisconnects()
+ Q_STATIC_ASSERT(QtPrivate::HasQ_OBJECT_Macro<tst_QObject>::Value);
+ Q_STATIC_ASSERT(!QtPrivate::HasQ_OBJECT_Macro<SiblingDeleter>::Value);
+ 
++#ifdef QT_BUILD_INTERNAL
++/*
++    Since QObjectPrivate stores the declarativeData pointer in a union with the pointer
++    to the currently destroyed child, calls to the QtDeclarative handlers need to be
++    correctly guarded. QTBUG-105286
++*/
++namespace QtDeclarative {
++static QAbstractDeclarativeData *theData;
++
++static void destroyed(QAbstractDeclarativeData *data, QObject *)
++{
++    QCOMPARE(data, theData);
++}
++static void signalEmitted(QAbstractDeclarativeData *data, QObject *, int, void **)
++{
++    QCOMPARE(data, theData);
++}
++// we can't use QCOMPARE in the next two functions, as they don't return void
++static int receivers(QAbstractDeclarativeData *data, const QObject *, int)
++{
++    QTest::qCompare(data, theData, "data", "theData", __FILE__, __LINE__);
++    return 0;
++}
++static bool isSignalConnected(QAbstractDeclarativeData *data, const QObject *, int)
++{
++    QTest::qCompare(data, theData, "data", "theData", __FILE__, __LINE__);
++    return true;
++}
++
++class Object : public QObject
++{
++    Q_OBJECT
++public:
++    using QObject::QObject;
++    ~Object()
++    {
++        if (Object *p = static_cast<Object *>(parent()))
++            p->emitSignal();
++    }
++
++    void emitSignal()
++    {
++        emit theSignal();
++    }
++
++signals:
++    void theSignal();
++};
++
++}
++#endif
++
++void tst_QObject::declarativeData()
++{
++#ifdef QT_BUILD_INTERNAL
++    QScopedValueRollback destroyed(QAbstractDeclarativeData::destroyed,
++                                   QtDeclarative::destroyed);
++    QScopedValueRollback signalEmitted(QAbstractDeclarativeData::signalEmitted,
++                                       QtDeclarative::signalEmitted);
++    QScopedValueRollback receivers(QAbstractDeclarativeData::receivers,
++                                   QtDeclarative::receivers);
++    QScopedValueRollback isSignalConnected(QAbstractDeclarativeData::isSignalConnected,
++                                           QtDeclarative::isSignalConnected);
++
++    QtDeclarative::Object p;
++    QObjectPrivate *priv = QObjectPrivate::get(&p);
++    priv->declarativeData = QtDeclarative::theData = new QAbstractDeclarativeData;
++
++    connect(&p, &QtDeclarative::Object::theSignal, &p, []{
++    });
++
++    QtDeclarative::Object *child = new QtDeclarative::Object;
++    child->setParent(&p);
++#endif
++}
++
+ QTEST_MAIN(tst_QObject)
+ #include "tst_qobject.moc"
+diff --git a/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp b/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
+index 0ea422ecbc..1a3256534b 100644
+--- a/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
++++ b/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
+@@ -70,15 +70,15 @@ static inline QString testSuiteWarning()
+ 
+     QString result;
+     QTextStream str(&result);
+-    str << "\nCannot find the shared-mime-info test suite\nstarting from: "
++    str << "\nCannot find the shared-mime-info test suite\nin the parent of: "
+         << QDir::toNativeSeparators(QDir::currentPath()) << "\n"
+            "cd " << QDir::toNativeSeparators(QStringLiteral("tests/auto/corelib/mimetypes/qmimedatabase")) << "\n"
+-           "wget http://cgit.freedesktop.org/xdg/shared-mime-info/snapshot/Release-1-10.zip\n"
+-           "unzip Release-1-10.zip\n";
++           "wget https://gitlab.freedesktop.org/xdg/shared-mime-info/-/archive/2.1/shared-mime-info-2.1.zip\n"
++           "unzip shared-mime-info-2.1.zip\n";
+ #ifdef Q_OS_WIN
+-    str << "mkdir testfiles\nxcopy /s Release-1-10 s-m-i\n";
++    str << "mkdir testfiles\nxcopy /s shared-mime-info-2.1 s-m-i\n";
+ #else
+-    str << "ln -s Release-1-10 s-m-i\n";
++    str << "ln -s shared-mime-info-2.1 s-m-i\n";
+ #endif
+     return result;
+ }
+@@ -154,7 +154,7 @@ void tst_QMimeDatabase::initTestCase()
+     QVERIFY2(copyResourceFile(xmlFileName, xmlTargetFileName, &errorMessage), qPrintable(errorMessage));
+ #endif
+ 
+-    m_testSuite = QFINDTESTDATA("s-m-i/tests");
++    m_testSuite = QFINDTESTDATA("s-m-i/tests/mime-detection");
+     if (m_testSuite.isEmpty())
+         qWarning("%s", qPrintable(testSuiteWarning()));
+ 
+@@ -611,7 +611,7 @@ void tst_QMimeDatabase::allMimeTypes()
+     QVERIFY(!lst.isEmpty());
+ 
+     // Hardcoding this is the only way to check both providers find the same number of mimetypes.
+-    QCOMPARE(lst.count(), 779);
++    QCOMPARE(lst.count(), 811);
+ 
+     foreach (const QMimeType &mime, lst) {
+         const QString name = mime.name();
+@@ -631,10 +631,9 @@ void tst_QMimeDatabase::suffixes_data()
+ 
+     QTest::newRow("mimetype with a single pattern") << "application/pdf" << "*.pdf" << "pdf";
+     QTest::newRow("mimetype with multiple patterns") << "application/x-kpresenter" << "*.kpr;*.kpt" << "kpr";
+-    QTest::newRow("jpeg") << "image/jpeg" << "*.jpe;*.jpg;*.jpeg" << "jpeg";
+-    //if (KMimeType::sharedMimeInfoVersion() > KDE_MAKE_VERSION(0, 60, 0)) {
+-        QTest::newRow("mimetype with many patterns") << "application/vnd.wordperfect" << "*.wp;*.wp4;*.wp5;*.wp6;*.wpd;*.wpp" << "wp";
+-    //}
++    // The preferred suffix for image/jpeg is *.jpg, as per https://bugs.kde.org/show_bug.cgi?id=176737
++    QTest::newRow("jpeg") << "image/jpeg" << "*.jpe;*.jpg;*.jpeg" << "jpg";
++    QTest::newRow("mimetype with many patterns") << "application/vnd.wordperfect" << "*.wp;*.wp4;*.wp5;*.wp6;*.wpd;*.wpp" << "wp";
+     QTest::newRow("oasis text mimetype") << "application/vnd.oasis.opendocument.text" << "*.odt" << "odt";
+     QTest::newRow("oasis presentation mimetype") << "application/vnd.oasis.opendocument.presentation" << "*.odp" << "odp";
+     QTest::newRow("mimetype with multiple patterns") << "text/plain" << "*.asc;*.txt;*,v" << "txt";
+diff --git a/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp b/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
+index 3e58dd03cc..c8f82ef5d5 100644
+--- a/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
++++ b/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
+@@ -176,6 +176,8 @@ private Q_SLOTS:
+     void fromToVariantConversions_data();
+     void fromToVariantConversions();
+ 
++    void noLeakOnNameClash();
++
+ private:
+     QString testDataDir;
+ };
+@@ -3685,5 +3687,23 @@ void tst_QtJson::fromToVariantConversions()
+     }
+ }
+ 
++void tst_QtJson::noLeakOnNameClash()
++{
++    QJsonDocument doc = QJsonDocument::fromJson("{\"\":{\"\":0},\"\":0}");
++    QVERIFY(!doc.isNull());
++    const QJsonObject obj = doc.object();
++
++    // Removed the duplicate key.
++    QCOMPARE(obj.length(), 1);
++
++    // Retained the last of the duplicates.
++    const QJsonValue val = obj.begin().value();
++    QVERIFY(val.isDouble());
++    QCOMPARE(val.toDouble(), 0.0);
++
++    // It should not leak.
++    // In particular it should not forget to deref the container for the inner object.
++}
++
+ QTEST_MAIN(tst_QtJson)
+ #include "tst_qtjson.moc"
+diff --git a/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp b/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
+index a59b58d57f..241c3e84ac 100644
+--- a/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
++++ b/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
+@@ -63,6 +63,7 @@ private slots:
+     void isValidId_data();
+     void isValidId();
+     void malformed();
++    void serialize();
+     // Backend tests
+     void utcTest();
+     void icuTest();
+@@ -947,6 +948,33 @@ void tst_QTimeZone::malformed()
+         barf.offsetFromUtc(now);
+ }
+ 
++void tst_QTimeZone::serialize()
++{
++    int parts = 0;
++#ifndef QT_NO_DEBUG_STREAM
++    qDebug() << QTimeZone(); // to verify no crash
++    parts++;
++#endif
++#ifndef QT_NO_DATASTREAM
++    QByteArray blob;
++    {
++        QDataStream stream(&blob, QIODevice::WriteOnly);
++        stream << QTimeZone("Europe/Oslo") << QTimeZone(420) << QTimeZone() << qint64(-1);
++    }
++    QDataStream stream(&blob, QIODevice::ReadOnly);
++    QTimeZone invalid, offset, oslo;
++    qint64 minusone;
++    stream >> oslo >> offset >> invalid >> minusone;
++    QCOMPARE(oslo, QTimeZone("Europe/Oslo"));
++    QCOMPARE(offset, QTimeZone(420));
++    QVERIFY(!invalid.isValid());
++    QCOMPARE(minusone, qint64(-1));
++    parts++;
++#endif
++    if (!parts)
++        QSKIP("No serialization enabled");
++}
++
+ void tst_QTimeZone::utcTest()
+ {
+ #ifdef QT_BUILD_INTERNAL
+diff --git a/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp b/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
+index 05480c6dd2..70f4c75756 100644
+--- a/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
++++ b/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
+@@ -324,6 +324,13 @@ void tst_QDBusInterface::notValid()
+ 
+     QVERIFY(!interface.isValid());
+     QVERIFY(!QMetaObject::invokeMethod(&interface, "ListNames", Qt::DirectConnection));
++
++    // With a connection, but empty/null service and path specified
++    QDBusConnection con = QDBusConnection::sessionBus();
++    QVERIFY(con.isConnected());
++    QDBusInterface iface({}, {}, {}, con);
++    QVERIFY(!iface.isValid());
++    QVERIFY(!QMetaObject::invokeMethod(&interface, "ListNames", Qt::DirectConnection));
+ }
+ 
+ void tst_QDBusInterface::notValidDerived()
+diff --git a/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp b/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
+index 874468c954..04ceb4ab65 100644
+--- a/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
++++ b/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
+@@ -507,6 +507,10 @@ void tst_QKeySequence::toStringFromKeycode_data()
+     QTest::newRow("Ctrl+Alt+Num+Del") << QKeySequence(Qt::ControlModifier | Qt::AltModifier | Qt::KeypadModifier | Qt::Key_Delete) << "Ctrl+Alt+Num+Del";
+     QTest::newRow("Ctrl+Ins") << QKeySequence(Qt::ControlModifier | Qt::Key_Insert) << "Ctrl+Ins";
+     QTest::newRow("Ctrl+Num+Ins(1)") << QKeySequence(Qt::Key_Insert | Qt::KeypadModifier | Qt::ControlModifier) << "Ctrl+Num+Ins";
++    QTest::newRow("Ctrl") << QKeySequence(Qt::Key_Control) << "Control";
++    QTest::newRow("Alt") << QKeySequence(Qt::Key_Alt) << "Alt";
++    QTest::newRow("Shift") << QKeySequence(Qt::Key_Shift) << "Shift";
++    QTest::newRow("Meta") << QKeySequence(Qt::Key_Meta) << "Meta";
+ }
+ 
+ void tst_QKeySequence::toStringFromKeycode()
+diff --git a/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp b/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+index 15e0ecadaa..b4eca74283 100644
+--- a/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
++++ b/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+@@ -81,6 +81,8 @@ private slots:
+     void registerOpenTypePreferredNamesSystem();
+     void registerOpenTypePreferredNamesApplication();
+ 
++    void stretchRespected();
++
+ private:
+     QString m_ledFont;
+     QString m_testFont;
+@@ -355,6 +357,28 @@ static QString testString()
+     return QStringLiteral("foo bar");
+ }
+ 
++void tst_QFontDatabase::stretchRespected()
++{
++    int italicId = QFontDatabase::addApplicationFont(m_testFontItalic);
++    QVERIFY(italicId != -1);
++
++    QVERIFY(!QFontDatabase::applicationFontFamilies(italicId).isEmpty());
++
++    QString italicFontName = QFontDatabase::applicationFontFamilies(italicId).first();
++
++    QFont italicFont = QFontDatabase().font(italicFontName,
++                                            QString::fromLatin1("Italic"), 14);
++    QVERIFY(italicFont.italic());
++
++    QFont italicStretchedFont = italicFont;
++    italicStretchedFont.setStretch( 400 );
++
++    QVERIFY(QFontMetricsF(italicFont).horizontalAdvance(QStringLiteral("foobar")) <
++            QFontMetricsF(italicStretchedFont).horizontalAdvance(QStringLiteral("foobar")));
++
++    QFontDatabase::removeApplicationFont(italicId);
++}
++
+ void tst_QFontDatabase::condensedFontWidthNoFontMerging()
+ {
+     int regularFontId = QFontDatabase::addApplicationFont(m_testFont);
+diff --git a/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+index 3d4a094c43..b423e11a99 100644
+--- a/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
++++ b/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+@@ -281,6 +281,7 @@ private Q_SLOTS:
+     void ioGetFromFileSpecial();
+     void ioGetFromFile_data();
+     void ioGetFromFile();
++    void ioGetFromFileUrl();
+     void ioGetFromFtp_data();
+     void ioGetFromFtp();
+     void ioGetFromFtpWithReuse();
+@@ -3300,6 +3301,18 @@ void tst_QNetworkReply::ioGetFromFile()
+     QCOMPARE(reader.data, data);
+ }
+ 
++void tst_QNetworkReply::ioGetFromFileUrl()
++{
++    // This immediately fails on non-windows platforms:
++    QNetworkRequest request(QUrl("file://unc-server/some/path"));
++    QNetworkReplyPtr reply(manager.get(request));
++    QSignalSpy finishedSpy(reply.get(), &QNetworkReply::finished);
++    // QTBUG-105618: This would, on non-Windows platforms, never happen because the signal
++    // was emitted before the constructor finished, leaving no chance at all to connect to the
++    // signal
++    QVERIFY(finishedSpy.wait());
++}
++
+ void tst_QNetworkReply::ioGetFromFtp_data()
+ {
+     QTest::addColumn<QString>("fileName");
+diff --git a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
+index 069fa6b341..4cc4d9a5ea 100644
+--- a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
++++ b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
+@@ -1,75 +1,34 @@
+-Certificate:
+-    Data:
+-        Version: 3 (0x2)
+-        Serial Number: 0 (0x0)
+-        Signature Algorithm: sha1WithRSAEncryption
+-        Issuer: C=NO, ST=Oslo, L=Nydalen, O=Nokia Corporation and/or its subsidiary(-ies), OU=Development, CN=fluke.troll.no/emailAddress=ahanssen@trolltech.com
+-        Validity
+-            Not Before: Dec  4 01:10:32 2007 GMT
+-            Not After : Apr 21 01:10:32 2035 GMT
+-        Subject: C=NO, ST=Oslo, O=Nokia Corporation and/or its subsidiary(-ies), OU=Development, CN=fluke.troll.no
+-        Subject Public Key Info:
+-            Public Key Algorithm: rsaEncryption
+-            RSA Public Key: (1024 bit)
+-                Modulus (1024 bit):
+-                    00:a7:c8:a0:4a:c4:19:05:1b:66:ba:32:e2:d2:f1:
+-                    1c:6f:17:82:e4:39:2e:01:51:90:db:04:34:32:11:
+-                    21:c2:0d:6f:59:d8:53:90:54:3f:83:8f:a9:d3:b3:
+-                    d5:ee:1a:9b:80:ae:c3:25:c9:5e:a5:af:4b:60:05:
+-                    aa:a0:d1:91:01:1f:ca:04:83:e3:58:1c:99:32:45:
+-                    84:70:72:58:03:98:4a:63:8b:41:f5:08:49:d2:91:
+-                    02:60:6b:e4:64:fe:dd:a0:aa:74:08:e9:34:4c:91:
+-                    5f:12:3d:37:4d:54:2c:ad:7f:5b:98:60:36:02:8c:
+-                    3b:f6:45:f3:27:6a:9b:94:9d
+-                Exponent: 65537 (0x10001)
+-        X509v3 extensions:
+-            X509v3 Basic Constraints: 
+-                CA:FALSE
+-            Netscape Comment: 
+-                OpenSSL Generated Certificate
+-            X509v3 Subject Key Identifier: 
+-                21:85:04:3D:23:01:66:E5:F7:9F:1A:84:24:8A:AF:0A:79:F4:E5:AC
+-            X509v3 Authority Key Identifier: 
+-                DirName:/C=NO/ST=Oslo/L=Nydalen/O=Nokia Corporation and/or its subsidiary(-ies)/OU=Development/CN=fluke.troll.no/emailAddress=ahanssen@trolltech.com
+-                serial:8E:A8:B4:E8:91:B7:54:2E
+-
+-    Signature Algorithm: sha1WithRSAEncryption
+-        6d:57:5f:d1:05:43:f0:62:05:ec:2a:71:a5:dc:19:08:f2:c4:
+-        a6:bd:bb:25:d9:ca:89:01:0e:e4:cf:1f:c1:8c:c8:24:18:35:
+-        53:59:7b:c0:43:b4:32:e6:98:b2:a6:ef:15:05:0b:48:5f:e1:
+-        a0:0c:97:a9:a1:77:d8:35:18:30:bc:a9:8f:d3:b7:54:c7:f1:
+-        a9:9e:5d:e6:19:bf:f6:3c:5b:2b:d8:e4:3e:62:18:88:8b:d3:
+-        24:e1:40:9b:0c:e6:29:16:62:ab:ea:05:24:70:36:aa:55:93:
+-        ef:02:81:1b:23:10:a2:04:eb:56:95:75:fc:f8:94:b1:5d:42:
+-        c5:3f:36:44:85:5d:3a:2e:90:46:8a:a2:b9:6f:87:ae:0c:15:
+-        40:19:31:90:fc:3b:25:bb:ae:f1:66:13:0d:85:90:d9:49:34:
+-        8f:f2:5d:f9:7a:db:4d:5d:27:f6:76:9d:35:8c:06:a6:4c:a3:
+-        b1:b2:b6:6f:1d:d7:a3:00:fd:72:eb:9e:ea:44:a1:af:21:34:
+-        7d:c7:42:e2:49:91:19:8b:c0:ad:ba:82:80:a8:71:70:f4:35:
+-        31:91:63:84:20:95:e9:60:af:64:8b:cc:ff:3d:8a:76:74:3d:
+-        c8:55:6d:e4:8e:c3:2b:1c:e8:42:18:ae:9f:e6:6b:9c:34:06:
+-        ec:6a:f2:c3
+ -----BEGIN CERTIFICATE-----
+-MIIEEzCCAvugAwIBAgIBADANBgkqhkiG9w0BAQUFADCBnDELMAkGA1UEBhMCTk8x
+-DTALBgNVBAgTBE9zbG8xEDAOBgNVBAcTB055ZGFsZW4xFjAUBgNVBAoTDVRyb2xs
+-dGVjaCBBU0ExFDASBgNVBAsTC0RldmVsb3BtZW50MRcwFQYDVQQDEw5mbHVrZS50
+-cm9sbC5ubzElMCMGCSqGSIb3DQEJARYWYWhhbnNzZW5AdHJvbGx0ZWNoLmNvbTAe
+-Fw0wNzEyMDQwMTEwMzJaFw0zNTA0MjEwMTEwMzJaMGMxCzAJBgNVBAYTAk5PMQ0w
+-CwYDVQQIEwRPc2xvMRYwFAYDVQQKEw1Ucm9sbHRlY2ggQVNBMRQwEgYDVQQLEwtE
+-ZXZlbG9wbWVudDEXMBUGA1UEAxMOZmx1a2UudHJvbGwubm8wgZ8wDQYJKoZIhvcN
+-AQEBBQADgY0AMIGJAoGBAKfIoErEGQUbZroy4tLxHG8XguQ5LgFRkNsENDIRIcIN
+-b1nYU5BUP4OPqdOz1e4am4CuwyXJXqWvS2AFqqDRkQEfygSD41gcmTJFhHByWAOY
+-SmOLQfUISdKRAmBr5GT+3aCqdAjpNEyRXxI9N01ULK1/W5hgNgKMO/ZF8ydqm5Sd
+-AgMBAAGjggEaMIIBFjAJBgNVHRMEAjAAMCwGCWCGSAGG+EIBDQQfFh1PcGVuU1NM
+-IEdlbmVyYXRlZCBDZXJ0aWZpY2F0ZTAdBgNVHQ4EFgQUIYUEPSMBZuX3nxqEJIqv
+-Cnn05awwgbsGA1UdIwSBszCBsKGBoqSBnzCBnDELMAkGA1UEBhMCTk8xDTALBgNV
+-BAgTBE9zbG8xEDAOBgNVBAcTB055ZGFsZW4xFjAUBgNVBAoTDVRyb2xsdGVjaCBB
+-U0ExFDASBgNVBAsTC0RldmVsb3BtZW50MRcwFQYDVQQDEw5mbHVrZS50cm9sbC5u
+-bzElMCMGCSqGSIb3DQEJARYWYWhhbnNzZW5AdHJvbGx0ZWNoLmNvbYIJAI6otOiR
+-t1QuMA0GCSqGSIb3DQEBBQUAA4IBAQBtV1/RBUPwYgXsKnGl3BkI8sSmvbsl2cqJ
+-AQ7kzx/BjMgkGDVTWXvAQ7Qy5piypu8VBQtIX+GgDJepoXfYNRgwvKmP07dUx/Gp
+-nl3mGb/2PFsr2OQ+YhiIi9Mk4UCbDOYpFmKr6gUkcDaqVZPvAoEbIxCiBOtWlXX8
+-+JSxXULFPzZEhV06LpBGiqK5b4euDBVAGTGQ/Dslu67xZhMNhZDZSTSP8l35ettN
+-XSf2dp01jAamTKOxsrZvHdejAP1y657qRKGvITR9x0LiSZEZi8CtuoKAqHFw9DUx
+-kWOEIJXpYK9ki8z/PYp2dD3IVW3kjsMrHOhCGK6f5mucNAbsavLD
++MIIF6zCCA9OgAwIBAgIUfo9amJtJGWqWE6f+SkAO85zkGr4wDQYJKoZIhvcNAQEL
++BQAwgYMxCzAJBgNVBAYTAk5PMQ0wCwYDVQQIDARPc2xvMQ0wCwYDVQQHDARPc2xv
++MRcwFQYDVQQKDA5UaGUgUXQgQ29tcGFueTEMMAoGA1UECwwDUiZEMRIwEAYDVQQD
++DAlIMiBUZXN0ZXIxGzAZBgkqhkiG9w0BCQEWDG1pbmltaUBxdC5pbzAgFw0yMDEw
++MjYxMjAxMzFaGA8yMTIwMTAwMjEyMDEzMVowgYMxCzAJBgNVBAYTAk5PMQ0wCwYD
++VQQIDARPc2xvMQ0wCwYDVQQHDARPc2xvMRcwFQYDVQQKDA5UaGUgUXQgQ29tcGFu
++eTEMMAoGA1UECwwDUiZEMRIwEAYDVQQDDAlIMiBUZXN0ZXIxGzAZBgkqhkiG9w0B
++CQEWDG1pbmltaUBxdC5pbzCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIB
++AOiUp5+E4blouKH7q+rVNR8NoYX2XkBW+q+rpy1zu5ssRSzbqxAjDx9dkht7Qlnf
++VlDT00JvpOWdeuPon5915edQRsY4Unl6mKH29ra3OtUa1/yCJXsGVJTKCj7k4Bxb
++5mZzb/fTlZntMLdTIBMfUbw62FKir1WjKIcJ9fCoG8JaGeKVO4Rh5p0ezd4UUUId
++r1BXl5Nqdqy2vTMsEDnjOsD3egkv8I2SKN4O6n/C3wWYpMOWYZkGoZiKz7rJs/i/
++ez7bsV7JlwdzTlhpJzkcOSVFBP6JlEOxTNNxZ1wtKy7PtZGmsSSATq2e6+bw38Ae
++Op0XnzzqcGjtDDofBmT7OFzZWjS9VZS6+DOOe2QHWle1nCHcHyH4ku6IRlsr9xkR
++NAIlOfnvHHxqJUenoeaZ4oQDjCBKS1KXygJO/tL7BLTQVn/xK1EmPvKNnjzWk4tR
++PnibUhhs5635qpOU/YPqFBh1JjVruZbsWcDAhRcew0uxONXOa9E+4lttQ9ySYa1A
++LvWqJuAX7gu2BsBMLyqfm811YnA7CIFMyO+HlqmkLFfv5L/xIRAXR7l26YGO0VwX
++CGjMfz4NVPMMke4nB7qa9NkpXQBQKMms3Qzd5JW0Hy9Ruj5O8GPcFZmV0twjd1uJ
++PD/cAjkWLaXjdNsJ16QWc2nghQRS6HYqKRX6j+CXOxupAgMBAAGjUzBRMB0GA1Ud
++DgQWBBRSCOU58j9NJZkMamt623qyCrhN3TAfBgNVHSMEGDAWgBRSCOU58j9NJZkM
++amt623qyCrhN3TAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4ICAQCq
++q4jxsWeNDv5Nq14hJtF9HB+ZL64zcZtRjJP1YgNs0QppKICmjPOL2nIMGmI/jKrs
++0eGAL/9XXNVHPxm1OPOncvimMMmU6emZfpMdEtTfKP43+Pg9HgKRjLoQp406vGeQ
++8ki/mbBhrItVPgEm3tu2AFA02XTYi+YxCI9kRZLGkM3FbgtOuTLPl0Z9y+kiPc9F
++uCSC03anBEqv+vDSI8+wODymQ/IJ3Jyz1lxIRDfp4qAekmy0jU2c91VOHHEmOmqq
++kqygGFRdwbe99m9yP63r6q0b5K3X2UnJ6bns0hmTwThYwpVPXLU8jdaTddbMukN2
++/Ef96Tsw8nWOEOPMySHOTIPgwyZRp26b0kA9EmhLwOP401SxXVQCmSRmtwNagmtg
++jJKmZoYBN+//D45ibK8z6Q0oOm9P+Whf/uUXehcRxBxyV3xz7k0wKGQbHj/ddwcy
++IUoIN4lrAlib+lK170kTKN352PDmrpo2gmIzPEsfurKAIMSelDl6H+kih16BtZ8y
++Nz6fh9Soqrg3OSAware8pxV7k51crBMoPLN78KoRV8MFCK4K7Fddq4rRISq6hiXq
++r1nsjoEPuKM9huprmZVZe9t5YcDa2I+wb3IiE3uwpZbAdaLDyQ5n6F/qpsiIkZXn
++gtcF7oqpG5oYrwCcZ53y/ezUgUg7PlSz2XwAGvQtgg==
+ -----END CERTIFICATE-----
+diff --git a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
+index 9d1664d609..337ce541a6 100644
+--- a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
++++ b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
+@@ -1,15 +1,52 @@
+------BEGIN RSA PRIVATE KEY-----
+-MIICXAIBAAKBgQCnyKBKxBkFG2a6MuLS8RxvF4LkOS4BUZDbBDQyESHCDW9Z2FOQ
+-VD+Dj6nTs9XuGpuArsMlyV6lr0tgBaqg0ZEBH8oEg+NYHJkyRYRwclgDmEpji0H1
+-CEnSkQJga+Rk/t2gqnQI6TRMkV8SPTdNVCytf1uYYDYCjDv2RfMnapuUnQIDAQAB
+-AoGANFzLkanTeSGNFM0uttBipFT9F4a00dqHz6JnO7zXAT26I5r8sU1pqQBb6uLz
+-/+Qz5Zwk8RUAQcsMRgJetuPQUb0JZjF6Duv24hNazqXBCu7AZzUenjafwmKC/8ri
+-KpX3fTwqzfzi//FKGgbXQ80yykSSliDL3kn/drATxsLCgQECQQDXhEFWLJ0vVZ1s
+-1Ekf+3NITE+DR16X+LQ4W6vyEHAjTbaNWtcTKdAWLA2l6N4WAAPYSi6awm+zMxx4
+-VomVTsjdAkEAx0z+e7natLeFcrrq8pbU+wa6SAP1VfhQWKitxL1e7u/QO90NCpxE
+-oQYKzMkmmpOOFjQwEMAy1dvFMbm4LHlewQJAC/ksDBaUcQHHqjktCtrUb8rVjAyW
+-A8lscckeB2fEYyG5J6dJVaY4ClNOOs5yMDS2Afk1F6H/xKvtQ/5CzInA/QJATDub
+-K+BPU8jO9q+gpuIi3VIZdupssVGmCgObVCHLakG4uO04y9IyPhV9lA9tALtoIf4c
+-VIvv5fWGXBrZ48kZAQJBAJmVCdzQxd9LZI5vxijUCj5EI4e+x5DRqVUvyP8KCZrC
+-AiNyoDP85T+hBZaSXK3aYGpVwelyj3bvo1GrTNwNWLw=
+------END RSA PRIVATE KEY-----
++-----BEGIN PRIVATE KEY-----
++MIIJQgIBADANBgkqhkiG9w0BAQEFAASCCSwwggkoAgEAAoICAQDolKefhOG5aLih
+++6vq1TUfDaGF9l5AVvqvq6ctc7ubLEUs26sQIw8fXZIbe0JZ31ZQ09NCb6TlnXrj
++6J+fdeXnUEbGOFJ5epih9va2tzrVGtf8giV7BlSUygo+5OAcW+Zmc2/305WZ7TC3
++UyATH1G8OthSoq9VoyiHCfXwqBvCWhnilTuEYeadHs3eFFFCHa9QV5eTanastr0z
++LBA54zrA93oJL/CNkijeDup/wt8FmKTDlmGZBqGYis+6ybP4v3s+27FeyZcHc05Y
++aSc5HDklRQT+iZRDsUzTcWdcLSsuz7WRprEkgE6tnuvm8N/AHjqdF5886nBo7Qw6
++HwZk+zhc2Vo0vVWUuvgzjntkB1pXtZwh3B8h+JLuiEZbK/cZETQCJTn57xx8aiVH
++p6HmmeKEA4wgSktSl8oCTv7S+wS00FZ/8StRJj7yjZ481pOLUT54m1IYbOet+aqT
++lP2D6hQYdSY1a7mW7FnAwIUXHsNLsTjVzmvRPuJbbUPckmGtQC71qibgF+4LtgbA
++TC8qn5vNdWJwOwiBTMjvh5appCxX7+S/8SEQF0e5dumBjtFcFwhozH8+DVTzDJHu
++Jwe6mvTZKV0AUCjJrN0M3eSVtB8vUbo+TvBj3BWZldLcI3dbiTw/3AI5Fi2l43Tb
++CdekFnNp4IUEUuh2KikV+o/glzsbqQIDAQABAoICAFw1q6tr5I48vY7DF+rXsuLn
++5ZUWE1IQ6fzB4lr72nJv/9EEGnMgYzt9PpMUsD6vdCpBgS2C0+6RHArFzJtNA+RM
++iHLIG7K7702veyr/xBx/MwiSlMeMv/XpkFxVI6E6skMGG2s3AMXxKvJTy5CpRx+I
++eQFyLG+Ya1X2lgJes/q+/CpAHkOjCOpcLySQC5NZ74q734V7nSdmn+Zs3tYEh+O/
++eiuwTP/j5b38Te5vVTqDxTciJPmljmXLCwa0N100lWlbcpvw8qbqiTI2Jm3XCbUE
++AzHjW9vmrF3cRS1fXxKFGShw3SRqlkbxjfeWoi8qDPUBS4m8LOr8qG9Wo5Nfon0z
++zLP4bci3zHDvVcaaZrrsUBs/yZbg+Dgka1DmX7ekmeccr2yTdKDFgPupYUyxVbTl
++a9ZLJysjFD7rgBv1ZclHonLp6Vbm+ZoTqvteo4ikAy6L9RtBWJ23XEK34PkP/+c5
++2vWZaOrnjSeBHbFce8cdJSxqWpP+eSCI5I9XbDrYFIsQ/gqKgtzDKy2ihJ2Y8STL
++yO4hyFPFjxc+Gg4/P2PpmT5CY2ty44M0BWs+JGW96CJPrrplf2lmQUQJj5LZY66X
++Z/4C9L7ZYtKZ+bs5SvU46yWugAvQZX22Xm9xLXWyVXRdx3bj+3M3fDnF9di/zdbh
++CgLx7oWPNrXc7FCajnn9AoIBAQD5FMYwRpw9NWT9WDxQwx+cSI4Icbd88ByTW63S
++LzeRwZA0J9/SfwO+aBRupzc9GkGXCiZcGMw3AGsCtig8yFlw8E5KnzN7KlftDMnM
++9NUxxzlR8VwKyLnZfG7sDTl057ZlUujnqhmt/F8F7dIy7FVO1dE/8nngA+FYTCOG
++UZdGjwyBDlDM0JJdUWGY3xslutcpCDN5mzSTKjy9drMvImAshRawxRF6WBpn7vr2
++nC6vciqfx1Mzx1vyk0Jm0ilaydDdLMADjt/iL4Nkr0BEs4k+UzQiKDwp8gu7abQ1
++eBfxd9Iar4htQa2I1Ewl6P01G/q+ZYwgHhJ9RVn4AxQXefILAoIBAQDvCouORdQX
++C8wsyp7MwXlF/3NQeNN5/+B2mhbxrBOf7PmMCXLnkRWcjwJtzypWFqJ0sqai/2+0
++bqbMcjX5maT8stT2shl3zXe/Ejt2e3TBYpc1tyuses8Kb5BMU8hu6tTd3G2CMXpD
++dT6DVemJZCTtwj9aBNIxSizvlgMolJnCpzhPnlfHSI6E+g3m/LTTo3HwbjMSw/Uq
++irgjOpI2wSBB6LZPSgjvfcYPRyWUk16L4A5uSX0cADnovDFLa5/h0wJvN/OoCSQg
++rLCXG5E18EyL5Wc58BCY1ZvxmjG3lQtgPxYu2Jwc36R/y/JKlxW5suER5ZNpbbD4
++uOyTt2VxMQ2bAoIBAQC5+MzRFqdo/AjfL5Y5JrbfVTzXCTDa09xCGd16ZU60QTWN
+++4ed/r+o1sUKqUcRFB2MzEM/2DQBjQpZB/CbEWvWa1XJWXxypXbowveZU+QqOnmN
++uQvj8WLyA3o+PNF9e9QvauwCrHpn8VpxbtPWuaYoKnUFreFZZQxHhPGxRBIS2JOZ
++eDrT8ZaWnkCkh1AZp5smQ71LOprSlmKrg4jd1GjCVMxQR5N5KXbtyv0OTCZ/UFqK
++2aRBsMPyJgkaBChkZPLRcKwc+/wlQRx1fHQb14DNTApMxoXFO7eOwqmOkpAt9iyl
++SBIwoS0UUI5ab88+bBmXNvKcuFdNuQ4nowTJUn9pAoIBADMNkILBXSvS5DeIyuO2
++Sp1tkoZUV+5NfPY3sMDK3KIibaW/+t+EOBZo4L7tKQCb8vRzl21mmsfxfgRaPDbj
++3r3tv9g0b4YLxxBy52pFscj/soXRai17SS7UZwA2QK+XzgDYbDcLNC6mIsTQG4Gx
++dsWk3/zs3KuUSQaehmwrWK+fIUK38c1pLK8v7LoxrLkqxlHwZ04RthHw8KTthH7X
++Pnl1J0LF8CSeOyfWLSuPUfkT0GEzptnNHpEbaHfQM6R6eaGhVJPF6AZme4y6YYgg
++m2ihhSt1n0XVEWpHYWjxFy3mK2mz75unFC4LM+NEY2p2zuUQoCw7NjnY3QYrfCnx
++rRMCggEAXeXsMSLFjjyuoL7iKbAxo52HD/P0fBoy58LyRcwfNVr0lvYan4pYEx+o
++KijIh9K16PqXZXKMA9v003B+ulmF8bJ7SddCZ5NGvnFhUTDe4DdTKgp2RuwQ3Bsc
++3skPIDbhVETyOLCtys34USHrq8U/0DlGY3eLRfxw9GnbKxSBGa/KEu/qQLPNUo50
++7xHZDg7GKeC3kqNJeqKM9rkp0VzIGkEnaD9127LeNDmERDfftxJzFoC/THvUBLfU
++6Sus2ZYwRE8VFvKC30Q45t/c54X3IuhYvAuiCuTmyfE4ruyzyOwKzhUkeeLq1APX
++g0veFbyfzlJ0q8qzD/iffqqIa2ZSmQ==
++-----END PRIVATE KEY-----
+diff --git a/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp b/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
+index 7ba3715e13..752aa122f6 100644
+--- a/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
++++ b/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
+@@ -179,6 +179,7 @@ void tst_QAccessibilityLinux::initTestCase()
+     QVERIFY(!address.isEmpty());
+ 
+     m_window = new AccessibleTestWindow();
++    m_window->setObjectName("mainWindow"_L1);
+     m_window->show();
+ 
+     QVERIFY(QTest::qWaitForWindowExposed(m_window));
+@@ -236,8 +237,11 @@ bool hasState(QDBusInterface *interface, AtspiStateType state)
+ void tst_QAccessibilityLinux::testLabel()
+ {
+     QLabel *l = new QLabel(m_window);
++    l->setObjectName("theObjectName"_L1);
+     l->setText("Hello A11y");
+     m_window->addWidget(l);
++    auto a11yEmpty = new QLabel(m_window);
++    m_window->addWidget(l);
+ 
+     // Application
+     QCOMPARE(getParent(mainWindow), QLatin1String(ATSPI_DBUS_PATH_ROOT));
+@@ -249,6 +253,8 @@ void tst_QAccessibilityLinux::testLabel()
+     QCOMPARE(getChildren(labelInterface).count(), 0);
+     QCOMPARE(labelInterface->call(QDBus::Block, "GetRoleName").arguments().first().toString(), QLatin1String("label"));
+     QCOMPARE(labelInterface->call(QDBus::Block, "GetRole").arguments().first().toUInt(), 29u);
++    QCOMPARE(labelInterface->call(QDBus::Block, "GetAccessibleId").arguments().first().toString(),
++             QLatin1String("mainWindow.theObjectName"));
+     QCOMPARE(getParent(labelInterface), mainWindow->path());
+     QVERIFY(!hasState(labelInterface, ATSPI_STATE_EDITABLE));
+     QVERIFY(hasState(labelInterface, ATSPI_STATE_READ_ONLY));
+@@ -256,7 +262,12 @@ void tst_QAccessibilityLinux::testLabel()
+     l->setText("New text");
+     QCOMPARE(labelInterface->property("Name").toString(), l->text());
+ 
++    auto *a11yEmptyInterface = getInterface(children.at(1), "org.a11y.atspi.Accessible");
++    QCOMPARE(a11yEmptyInterface->call(QDBus::Block, "GetAccessibleId").arguments().first().toString(),
++             QLatin1String("mainWindow.QLabel"));
++
+     m_window->clearChildren();
++    delete a11yEmptyInterface;
+     delete labelInterface;
+ }
+ 
+diff --git a/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+index 76df61c892..6d6d65b791 100644
+--- a/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
++++ b/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2022 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the test suite of the Qt Toolkit.
+@@ -68,6 +68,8 @@ private slots:
+     void query_exec();
+     void execErrorRecovery_data() { generic_data(); }
+     void execErrorRecovery();
++    void prematureExec_data() { generic_data(); }
++    void prematureExec();
+     void first_data() { generic_data(); }
+     void first();
+     void next_data() { generic_data(); }
+@@ -2770,6 +2772,35 @@ void tst_QSqlQuery::execErrorRecovery()
+     QVERIFY_SQL( q, exec() );
+ }
+ 
++void tst_QSqlQuery::prematureExec()
++{
++    QFETCH(QString, dbName);
++    // We only want the engine name, for addDatabase():
++    int cut = dbName.indexOf(QChar('@'));
++    if (cut < 0)
++        QSKIP("Failed to parse database type out of name");
++    dbName.truncate(cut);
++    cut = dbName.indexOf(QChar('_'));
++    if (cut >= 0)
++        dbName = dbName.mid(cut + 1);
++
++    auto db = QSqlDatabase::addDatabase(dbName);
++    QSqlQuery q(db);
++
++    QTest::ignoreMessage(QtWarningMsg,
++                         "QSqlDatabasePrivate::removeDatabase: connection "
++                         "'qt_sql_default_connection' is still in use, all "
++                         "queries will cease to work.");
++    QTest::ignoreMessage(QtWarningMsg,
++                         "QSqlDatabasePrivate::addDatabase: duplicate connection name "
++                         "'qt_sql_default_connection', old connection removed.");
++    auto otherDb = QSqlDatabase::addDatabase(dbName);
++
++    QTest::ignoreMessage(QtWarningMsg, "QSqlQuery::exec: called before driver has been set up");
++    // QTBUG-100037: shouldn't crash !
++    QVERIFY(!q.exec("select stuff from TheVoid"));
++}
++
+ void tst_QSqlQuery::lastInsertId()
+ {
+     QFETCH( QString, dbName );
+diff --git a/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp b/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
+index 4aa3f8d60b..d2050a61aa 100644
+--- a/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
++++ b/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
+@@ -115,6 +115,10 @@ void tst_QAbstractItemModelTester::standardItemModelZeroColumns()
+     // QTBUG-92886
+     model.insertRows(0, 5);
+     model.removeRows(1, 2);
++
++    const QModelIndex parentIndex = model.index(0, 0);
++    model.insertRows(0, 5, parentIndex);
++    model.removeRows(1, 2, parentIndex);
+ }
+ 
+ void tst_QAbstractItemModelTester::testInsertThroughProxy()
+diff --git a/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json b/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
+index 12a4a22a19..ce518e78fb 100644
+--- a/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
++++ b/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
+@@ -668,50 +668,6 @@
+         "inputFile": "task192552.h",
+         "outputRevision": 67
+     },
+-    {
+-        "classes": [
+-            {
+-                "className": "InlineSlotsWithThrowDeclaration",
+-                "object": true,
+-                "qualifiedClassName": "InlineSlotsWithThrowDeclaration",
+-                "slots": [
+-                    {
+-                        "access": "public",
+-                        "name": "a",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "b",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "c",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "d",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "e",
+-                        "returnType": "void"
+-                    }
+-                ],
+-                "superClasses": [
+-                    {
+-                        "access": "public",
+-                        "name": "QObject"
+-                    }
+-                ]
+-            }
+-        ],
+-        "inputFile": "task189996.h",
+-        "outputRevision": 67
+-    },
+     {
+         "classes": [
+             {
+diff --git a/qtbase/tests/auto/tools/moc/moc.pro b/qtbase/tests/auto/tools/moc/moc.pro
+index c324b3a8cd..4aceb78dc0 100644
+--- a/qtbase/tests/auto/tools/moc/moc.pro
++++ b/qtbase/tests/auto/tools/moc/moc.pro
+@@ -15,7 +15,7 @@ cross_compile: DEFINES += MOC_CROSS_COMPILED
+ HEADERS += using-namespaces.h no-keywords.h task87883.h c-comments.h backslash-newlines.h oldstyle-casts.h \
+            slots-with-void-template.h qinvokable.h namespaced-flags.h trigraphs.h \
+            escapes-in-string-literals.h cstyle-enums.h qprivateslots.h gadgetwithnoenums.h \
+-           dir-in-include-path.h single_function_keyword.h task192552.h task189996.h \
++           dir-in-include-path.h single_function_keyword.h task192552.h \
+            task234909.h task240368.h pure-virtual-signals.h cxx11-enums.h \
+            cxx11-final-classes.h \
+            cxx11-explicit-override-control.h \
+diff --git a/qtbase/tests/auto/tools/moc/task189996.h b/qtbase/tests/auto/tools/moc/task189996.h
+deleted file mode 100644
+index f94a051b3a..0000000000
+--- a/qtbase/tests/auto/tools/moc/task189996.h
++++ /dev/null
+@@ -1,47 +0,0 @@
+-/****************************************************************************
+-**
+-** Copyright (C) 2016 The Qt Company Ltd.
+-** Contact: https://www.qt.io/licensing/
+-**
+-** This file is part of the test suite of the Qt Toolkit.
+-**
+-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+-** 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 General Public License Usage
+-** Alternatively, this file may be used under the terms of the GNU
+-** General Public License version 3 as published by the Free Software
+-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+-** 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-3.0.html.
+-**
+-** $QT_END_LICENSE$
+-**
+-****************************************************************************/
+-// inline functions can have throw declarations
+-
+-#ifndef TASK189996_H
+-#define TASK189996_H
+-
+-#include <QObject>
+-
+-class InlineSlotsWithThrowDeclaration : public QObject
+-{
+-    Q_OBJECT
+-
+-public slots:
+-    void a() throw() { }
+-    void b() const throw() { }
+-    void c() throw();
+-    void d() throw(int) { }
+-    void e() const throw(int,double) { }
+-};
+-
+-#endif
+diff --git a/qtbase/tests/auto/tools/moc/tst_moc.cpp b/qtbase/tests/auto/tools/moc/tst_moc.cpp
+index c716aead21..15dd9e41e5 100644
+--- a/qtbase/tests/auto/tools/moc/tst_moc.cpp
++++ b/qtbase/tests/auto/tools/moc/tst_moc.cpp
+@@ -631,7 +631,6 @@ public:
+ private slots:
+     void initTestCase();
+ 
+-    void slotWithException() throw(MyStruct);
+     void dontStripNamespaces();
+     void oldStyleCasts();
+     void warnOnExtraSignalSlotQualifiaction();
+@@ -673,7 +672,6 @@ private slots:
+     void templateGtGt();
+     void qprivateslots();
+     void qprivateproperties();
+-    void inlineSlotsWithThrowDeclaration();
+     void warnOnPropertyWithoutREAD();
+     void constructors();
+     void typenameWithUnsigned();
+@@ -784,12 +782,6 @@ void tst_Moc::initTestCase()
+ #endif
+ }
+ 
+-void tst_Moc::slotWithException() throw(MyStruct)
+-{
+-    // be happy
+-    QVERIFY(true);
+-}
+-
+ void tst_Moc::dontStripNamespaces()
+ {
+     Sender sender;
+@@ -824,7 +816,7 @@ void tst_Moc::oldStyleCasts()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-Wold-style-cast" << "-I" << "."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -894,7 +886,7 @@ void tst_Moc::inputFileNameWithDotsButNoExtension()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-I" << ".."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -1174,7 +1166,7 @@ void tst_Moc::ignoreOptionClashes()
+     QStringList gccArgs;
+     gccArgs << "-c" << "-x" << "c++" << "-I" << ".."
+          << "-I" << qtIncludePath << "-I" << includeDir << "-o" << "/dev/null"
+-         << "-fPIC" << "-std=c++11" <<  "-";
++         << "-fPIC" << "-std=c++1z" <<  "-";
+     proc.start("gcc", gccArgs);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -1593,21 +1585,6 @@ void tst_Moc::qprivateproperties()
+ 
+ }
+ 
+-#include "task189996.h"
+-
+-void InlineSlotsWithThrowDeclaration::c() throw() {}
+-
+-void tst_Moc::inlineSlotsWithThrowDeclaration()
+-{
+-    InlineSlotsWithThrowDeclaration tst;
+-    const QMetaObject *mobj = tst.metaObject();
+-    QVERIFY(mobj->indexOfSlot("a()") != -1);
+-    QVERIFY(mobj->indexOfSlot("b()") != -1);
+-    QVERIFY(mobj->indexOfSlot("c()") != -1);
+-    QVERIFY(mobj->indexOfSlot("d()") != -1);
+-    QVERIFY(mobj->indexOfSlot("e()") != -1);
+-}
+-
+ void tst_Moc::warnOnPropertyWithoutREAD()
+ {
+ #ifdef MOC_CROSS_COMPILED
+@@ -1869,7 +1846,7 @@ void tst_Moc::notifyError()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-I" << "."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+diff --git a/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+index c355ee9665..88c09de8e0 100644
+--- a/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
++++ b/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+@@ -251,6 +251,7 @@ private slots:
+     void testResetCachedSizeHint();
+     void statusTips();
+     void testRemovingColumnsViaLayoutChanged();
++    void testModelMovingColumns();
+ 
+ protected:
+     void setupTestData(bool use_reset_model = false);
+@@ -360,6 +361,12 @@ public:
+         endRemoveColumns();
+     }
+ 
++    void moveColumn(int from, int to)
++    {
++        beginMoveColumns(QModelIndex(), from, from, QModelIndex(), to);
++        endMoveColumns();
++    }
++
+     void cleanup()
+     {
+         emit layoutAboutToBeChanged();
+@@ -3627,5 +3634,18 @@ void tst_QHeaderView::testRemovingColumnsViaLayoutChanged()
+     // The main point of this test is that the section-size restoring code didn't go out of bounds.
+ }
+ 
++void tst_QHeaderView::testModelMovingColumns()
++{
++    QtTestModel model(10, 10);
++    QHeaderView hv(Qt::Horizontal);
++    hv.setModel(&model);
++    hv.resizeSections(QHeaderView::ResizeToContents);
++    hv.show();
++
++    QPersistentModelIndex index3 = model.index(0, 3);
++    model.moveColumn(3, 1);
++    QCOMPARE(index3.column(), 1);
++}
++
+ QTEST_MAIN(tst_QHeaderView)
+ #include "tst_qheaderview.moc"
+diff --git a/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+index 761357b252..06bb706074 100644
+--- a/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
++++ b/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+@@ -397,6 +397,7 @@ private slots:
+     void checkHeaderMinSize();
+ 
+     void resizeToContents();
++    void resizeToContentsSpans();
+ 
+     void tabFocus();
+     void bigModel();
+@@ -3721,6 +3722,70 @@ void tst_QTableView::resizeToContents()
+ 
+ }
+ 
++
++class SpanModel : public QAbstractTableModel
++{
++public:
++    SpanModel(bool sectionsMoved)
++        : _sectionsMoved(sectionsMoved)
++    {}
++    int columnCount(const QModelIndex & = {}) const override { return 2; }
++    int rowCount(const QModelIndex & = {}) const override { return 1; }
++    QVariant data(const QModelIndex &idx, int role = Qt::DisplayRole) const override
++    {
++        if (role != Qt::DisplayRole)
++            return QVariant();
++        const int col = _sectionsMoved ? 1 - idx.column() : idx.column();
++        if (col == 0)
++            return "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.";
++        return QVariant();
++    }
++private:
++    bool _sectionsMoved;
++};
++
++
++void tst_QTableView::resizeToContentsSpans()
++{
++    SpanModel model1(false);
++    SpanModel model2(true);
++    QTableView view1, view2, view3;
++    view1.setModel(&model1);
++    view2.setModel(&model2);
++    view2.horizontalHeader()->moveSection(0, 1);
++    view3.setModel(&model1);
++
++    view1.setSpan(0, 0, 1, 2);
++    view2.setSpan(0, 1, 1, 2);
++    view1.show();
++    view2.show();
++    view3.show();
++    QVERIFY(QTest::qWaitForWindowExposed(&view1));
++    QVERIFY(QTest::qWaitForWindowExposed(&view2));
++    QVERIFY(QTest::qWaitForWindowExposed(&view3));
++    view1.setColumnWidth(0, 100);
++    view1.setColumnWidth(1, 100);
++    view2.setColumnWidth(0, 100);
++    view2.setColumnWidth(1, 100);
++    view3.setColumnWidth(0, 200);
++
++    view1.resizeRowToContents(0);
++    view2.resizeRowToContents(0);
++    view3.resizeRowToContents(0);
++    QCOMPARE(view1.rowHeight(0), view3.rowHeight(0));
++    QCOMPARE(view2.rowHeight(0), view3.rowHeight(0));
++
++    view3.resizeColumnToContents(0);
++    view3.resizeRowToContents(0);
++    // height should be only 1 text line for easy testing
++    view1.setRowHeight(0, view3.verticalHeader()->sectionSize(0));
++    view2.setRowHeight(0, view3.verticalHeader()->sectionSize(0));
++    view1.resizeColumnToContents(0);
++    view2.resizeColumnToContents(1);
++    QCOMPARE(view1.columnWidth(0), view3.columnWidth(0) - view1.columnWidth(1));
++    QCOMPARE(view2.columnWidth(0), view3.columnWidth(0) - view2.columnWidth(1));
++}
++
+ QT_BEGIN_NAMESPACE
+ extern bool Q_WIDGETS_EXPORT qt_tab_all_widgets(); // qapplication.cpp
+ QT_END_NAMESPACE
+diff --git a/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+index a3b8ef78d8..4955cebd5d 100644
+--- a/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
++++ b/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+@@ -1498,7 +1498,7 @@ void tst_QApplication::desktopSettingsAware()
+     environment += QLatin1String("QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM=1");
+     testProcess.setEnvironment(environment);
+ #endif
+-    testProcess.start("desktopsettingsaware_helper");
++    testProcess.start("./desktopsettingsaware_helper");
+     QVERIFY2(testProcess.waitForStarted(),
+              qPrintable(QString::fromLatin1("Cannot start 'desktopsettingsaware_helper': %1").arg(testProcess.errorString())));
+     QVERIFY(testProcess.waitForFinished(10000));
+@@ -2452,7 +2452,7 @@ void tst_QApplication::qtbug_12673()
+ #if QT_CONFIG(process)
+     QProcess testProcess;
+     QStringList arguments;
+-    testProcess.start("modal_helper", arguments);
++    testProcess.start("./modal_helper", arguments);
+     QVERIFY2(testProcess.waitForStarted(),
+              qPrintable(QString::fromLatin1("Cannot start 'modal_helper': %1").arg(testProcess.errorString())));
+     QVERIFY(testProcess.waitForFinished(20000));
+diff --git a/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp b/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
+index eb108a40de..dca5528c1b 100644
+--- a/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
+@@ -41,6 +41,7 @@
+ 
+ #include <private/qguiapplication_p.h>
+ #include <qpa/qplatformintegration.h>
++#include <qpa/qplatformtheme.h>
+ 
+ class tst_QAbstractButton : public QObject
+ {
+@@ -76,6 +77,8 @@ private slots:
+     void keyNavigation();
+ #endif
+ 
++    void buttonPressKeys();
++
+ protected slots:
+     void onClicked();
+     void onToggled( bool on );
+@@ -269,7 +272,13 @@ void tst_QAbstractButton::setAutoRepeat()
+         QCOMPARE(press_count, click_count);
+         QVERIFY(click_count > 1);
+         break;
+-    case 4:
++    case 4: {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(Qt::Key_Enter)) {
++            QSKIP("platform theme has Key_Enter in ButtonPressKeys");
++        }
+         // check that pressing ENTER has no effect when autorepeat is false
+         testWidget->setDown( false );
+         testWidget->setAutoRepeat( false );
+@@ -286,7 +295,14 @@ void tst_QAbstractButton::setAutoRepeat()
+ 
+         QVERIFY( click_count == 0 );
+         break;
+-    case 5:
++    }
++    case 5: {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(Qt::Key_Enter)) {
++            QSKIP("platform theme has Key_Enter in ButtonPressKeys");
++        }
+         // check that pressing ENTER has no effect when autorepeat is true
+         testWidget->setDown( false );
+         testWidget->setAutoRepeat( true );
+@@ -304,6 +320,7 @@ void tst_QAbstractButton::setAutoRepeat()
+ 
+         QVERIFY( click_count == 0 );
+         break;
++    }
+     case 6:
+         // verify autorepeat is off by default.
+         MyButton tmp( 0);
+@@ -651,5 +668,16 @@ void tst_QAbstractButton::keyNavigation()
+ }
+ #endif
+ 
++void tst_QAbstractButton::buttonPressKeys()
++{
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(testWidget, buttonPressKeys[i]);
++        QCOMPARE(click_count, i + 1);
++    }
++}
++
+ QTEST_MAIN(tst_QAbstractButton)
+ #include "tst_qabstractbutton.moc"
+diff --git a/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+index 32437050f5..46b5af6d63 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+@@ -168,6 +168,7 @@ private slots:
+     void checkMenuItemPosWhenStyleSheetIsSet();
+     void checkEmbeddedLineEditWhenStyleSheetIsSet();
+     void propagateStyleChanges();
++    void buttonPressKeys();
+ 
+ private:
+     PlatformInputContext m_platformInputContext;
+@@ -1682,6 +1683,16 @@ void tst_QComboBox::setModel()
+     QCOMPARE(box.rootModelIndex(), rootModelIndex);
+     box.setModel(box.model());
+     QCOMPARE(box.rootModelIndex(), rootModelIndex);
++
++    // check that setting the same model as the completer's doesn't crash
++    QCompleter *completer = new QCompleter(&box);
++    box.setEditable(true);
++    box.setCompleter(completer);
++    auto *listModel = new QStringListModel({ "one", "two" }, completer);
++    completer->setModel(listModel);
++    QCOMPARE(listModel->rowCount(), 2); // make sure it wasn't deleted
++    box.setModel(listModel);
++    QCOMPARE(listModel->rowCount(), 2); // make sure it wasn't deleted
+ }
+ 
+ void tst_QComboBox::setCustomModelAndView()
+@@ -3632,5 +3643,24 @@ void tst_QComboBox::propagateStyleChanges()
+     QVERIFY(frameStyle.inquired);
+ }
+ 
++void tst_QComboBox::buttonPressKeys()
++{
++    QComboBox comboBox;
++    comboBox.setEditable(false);
++    comboBox.addItem(QString::number(1));
++    comboBox.addItem(QString::number(2));
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(&comboBox, buttonPressKeys[i]);
++        // On some platforms, a window will not be immediately visible,
++        // but take some event-loop iterations to complete.
++        // Using QTRY_VERIFY to deal with that.
++        QTRY_VERIFY(comboBox.view()->isVisible());
++        comboBox.hidePopup();
++    }
++}
++
+ QTEST_MAIN(tst_QComboBox)
+ #include "tst_qcombobox.moc"
+diff --git a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
+index be3cfcd104..c228fdfcca 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
++++ b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qcommandlinkbutton
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qcommandlinkbutton.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
+index 0044d33c66..4cf06296e4 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
+@@ -40,6 +40,9 @@
+ #include <QGridLayout>
+ #include <QPainter>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ class tst_QCommandLinkButton : public QObject
+ {
+     Q_OBJECT
+@@ -223,6 +226,13 @@ void tst_QCommandLinkButton::setAutoRepeat()
+     // check that pressing ENTER has no effect
+     resetCounters();
+     testWidget->setDown( false );
++    // Skip after reset if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
+     testWidget->setAutoRepeat( false );
+     QTest::keyPress( testWidget, Qt::Key_Enter );
+ 
+@@ -255,6 +265,14 @@ void tst_QCommandLinkButton::pressed()
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+ 
++    // Skip if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
++
+     QTest::keyPress( testWidget,Qt::Key_Enter );
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+diff --git a/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro b/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
+index 4a5e76ff65..a235fa1fac 100644
+--- a/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
++++ b/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qgroupbox
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qgroupbox.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp b/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
+index 4fb5d262ca..d8d7562b73 100644
+--- a/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
+@@ -35,6 +35,9 @@
+ #include <QRadioButton>
+ #include <QDialog>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ #include "qgroupbox.h"
+ 
+ class tst_QGroupBox : public QObject
+@@ -69,6 +72,7 @@ private slots:
+     void propagateFocus();
+     void task_QTBUG_19170_ignoreMouseReleaseEvent();
+     void task_QTBUG_15519_propagateMouseEvents();
++    void buttonPressKeys();
+ 
+ private:
+     bool checked;
+@@ -610,6 +614,20 @@ void tst_QGroupBox::task_QTBUG_15519_propagateMouseEvents()
+     QCOMPARE(parent.mouseMoved, true);
+ }
+ 
++void tst_QGroupBox::buttonPressKeys()
++{
++    QGroupBox groupBox;
++    groupBox.setCheckable(true);
++    QSignalSpy clickedSpy(&groupBox, &QGroupBox::clicked);
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(&groupBox, buttonPressKeys[i]);
++        QCOMPARE(clickedSpy.length(), i + 1);
++    }
++}
++
+ void tst_QGroupBox::sendMouseMoveEvent(QWidget *widget, const QPoint &localPos)
+ {
+     // Send a MouseMove event without actually moving the pointer
+diff --git a/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro b/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
+index 353ad06ca2..e55f6148f2 100644
+--- a/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
++++ b/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qpushbutton
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qpushbutton.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp b/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
+index e818514a79..4043e9326a 100644
+--- a/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
+@@ -41,6 +41,9 @@
+ #include <QStyleFactory>
+ #include <QTabWidget>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ class tst_QPushButton : public QObject
+ {
+ Q_OBJECT
+@@ -212,6 +215,13 @@ void tst_QPushButton::autoRepeat()
+     // check that pressing ENTER has no effect
+     resetCounters();
+     testWidget->setDown( false );
++    // Skip after reset if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
+     testWidget->setAutoRepeat( false );
+     QTest::keyPress( testWidget, Qt::Key_Enter );
+ 
+@@ -247,6 +257,14 @@ void tst_QPushButton::pressed()
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+ 
++    // Skip if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
++
+     QTest::keyPress( testWidget,Qt::Key_Enter );
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+diff --git a/qtbase/tests/manual/rhi/cubemap_render/buildshader.bat b/qtbase/tests/manual/rhi/cubemap_render/buildshader.bat
+old mode 100755
+new mode 100644
+Submodule qtconnectivity e957d481..056294c0:
+diff --git a/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp b/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
+index e2635fae..a8b8e3b9 100644
+--- a/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
++++ b/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
+@@ -563,9 +563,11 @@ void HciManager::handleHciAclPacket(const quint8 *data, int size)
+ 
+ void HciManager::handleLeMetaEvent(const quint8 *data)
+ {
+-    // Spec v4.2, Vol 2, part E, 7.7.65ff
++    // Spec v5.3, Vol 4, part E, 7.7.65.*
+     switch (*data) {
+-    case 0x1: {
++    case 0x1: // HCI_LE_Connection_Complete
++    case 0xA: // HCI_LE_Enhanced_Connection_Complete
++    {
+         const quint16 handle = bt_get_le16(data + 2);
+         emit connectionComplete(handle);
+         break;
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp b/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
+index 6a93143b..4a18cfc7 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
+@@ -320,7 +320,10 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_finishSdpScan(QBluetoothServiceD
+             for (const QBluetoothUuid &id : serviceClassUuids) {
+                 if (id.minimumSize() == 16) {
+                     serviceInfo.setServiceUuid(id);
+-                    serviceInfo.setServiceName(QBluetoothServiceDiscoveryAgent::tr("Custom Service"));
++                    if (serviceInfo.serviceName().isEmpty()) {
++                        serviceInfo.setServiceName(
++                                    QBluetoothServiceDiscoveryAgent::tr("Custom Service"));
++                    }
+                     QBluetoothServiceInfo::Sequence modSeq =
+                             serviceInfo.attribute(QBluetoothServiceInfo::ServiceClassIds).value<QBluetoothServiceInfo::Sequence>();
+                     modSeq.removeOne(QVariant::fromValue(id));
+@@ -334,8 +337,10 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_finishSdpScan(QBluetoothServiceD
+                 qCDebug(QT_BT_BLUEZ) << "Discovered services" << discoveredDevices.at(0).address().toString()
+                                      << serviceInfo.serviceName() << serviceInfo.serviceUuid()
+                                      << ">>>" << serviceInfo.serviceClassUuids();
+-
+-                emit q->serviceDiscovered(serviceInfo);
++                // Use queued connection to allow us finish the service looping; the application
++                // might call stop() when it has detected the service-of-interest.
++                QMetaObject::invokeMethod(q, "serviceDiscovered", Qt::QueuedConnection,
++                                          Q_ARG(QBluetoothServiceInfo, serviceInfo));
+             }
+         }
+     }
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp b/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
+index e4d85447..aadd4755 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
+@@ -593,7 +593,7 @@ void QBluetoothSocket::setSocketState(QBluetoothSocket::SocketState state)
+ bool QBluetoothSocket::canReadLine() const
+ {
+     Q_D(const QBluetoothSocketBase);
+-    return d->canReadLine();
++    return d->canReadLine() || QIODevice::canReadLine();
+ }
+ 
+ /*!
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp b/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
+index 084aa958..d6aa17a7 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
+@@ -284,6 +284,10 @@ void QBluetoothSocketPrivateBluezDBus::connectToService(
+         return;
+     }
+ 
++    if (service.socketProtocol() != QBluetoothServiceInfo::Protocol::UnknownProtocol)
++        socketType = service.socketProtocol();
++    qCDebug(QT_BT_BLUEZ) << "Socket protocol used:" << socketType;
++
+     connectToService(service.device().address(), targetService, openMode);
+ }
+ 
+diff --git a/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp b/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
+index 05bc1a0f..a7b5ef1f 100644
+--- a/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
++++ b/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
+@@ -142,7 +142,7 @@ void tst_QBluetoothSocket::initTestCase()
+     qDebug() << "Starting discovery";
+ 
+     sda->setUuidFilter(QBluetoothUuid(QString(TEST_SERVICE_UUID)));
+-    sda->start(QBluetoothServiceDiscoveryAgent::MinimalDiscovery);
++    sda->start(QBluetoothServiceDiscoveryAgent::FullDiscovery);
+ 
+     for (int connectTime = MaxConnectTime; !done_discovery && connectTime > 0; connectTime -= 1000)
+         QTest::qWait(1000);
+Submodule qtdeclarative f5701f0d..8defe7bf:
+diff --git a/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h b/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
+index b65b994d6c..15a8cd6878 100644
+--- a/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
++++ b/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
+@@ -86,7 +86,7 @@ public:
+         if (QTypeInfo<T>::isComplex) {
+             for (int i = 0; i < count; ++i)
+                 new (data + i) T(vector.at(i));
+-        } else {
++        } else if (count) {
+             memcpy(data, static_cast<const void*>(vector.constData()), count * sizeof(T));
+         }
+     }
+diff --git a/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp b/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
+index e57cdd8278..94613598af 100644
+--- a/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
++++ b/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
+@@ -1145,8 +1145,7 @@ void Heap::QObjectWrapper::markObjects(Heap::Base *that, QV4::MarkStack *markSta
+ void QObjectWrapper::destroyObject(bool lastCall)
+ {
+     Heap::QObjectWrapper *h = d();
+-    if (!h->internalClass)
+-        return; // destroyObject already got called
++    Q_ASSERT(h->internalClass);
+ 
+     if (h->object()) {
+         QQmlData *ddata = QQmlData::get(h->object(), false);
+@@ -1176,7 +1175,7 @@ void QObjectWrapper::destroyObject(bool lastCall)
+         }
+     }
+ 
+-    h->~Data();
++    h->destroy();
+ }
+ 
+ 
+diff --git a/qtdeclarative/src/qml/memory/qv4mm.cpp b/qtdeclarative/src/qml/memory/qv4mm.cpp
+index 06caf04e5a..da149a67c4 100644
+--- a/qtdeclarative/src/qml/memory/qv4mm.cpp
++++ b/qtdeclarative/src/qml/memory/qv4mm.cpp
+@@ -981,7 +981,7 @@ void MemoryManager::sweep(bool lastSweep, ClassDestroyStatsCallback classCountPt
+ 
+     if (MultiplyWrappedQObjectMap *multiplyWrappedQObjects = engine->m_multiplyWrappedQObjects) {
+         for (MultiplyWrappedQObjectMap::Iterator it = multiplyWrappedQObjects->begin(); it != multiplyWrappedQObjects->end();) {
+-            if (!it.value().isNullOrUndefined())
++            if (it.value().isNullOrUndefined())
+                 it = multiplyWrappedQObjects->erase(it);
+             else
+                 ++it;
+diff --git a/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp b/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
+index 2079a8ed04..a577cb2351 100644
+--- a/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
++++ b/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
+@@ -389,6 +389,12 @@ void QQmlDelegateModelPrivate::connectToAbstractItemModel()
+                       q,  QQmlDelegateModel, SLOT(_q_rowsRemoved(QModelIndex,int,int)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
+                       q,  QQmlDelegateModel, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsInserted(QModelIndex,int,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsInserted(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsRemoved(QModelIndex,int,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsRemoved(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsMoved(QModelIndex,int,int,QModelIndex,int)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
+                       q, QQmlDelegateModel, SLOT(_q_dataChanged(QModelIndex,QModelIndex,QVector<int>)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
+@@ -413,6 +419,12 @@ void QQmlDelegateModelPrivate::disconnectFromAbstractItemModel()
+                         q, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int)));
+     QObject::disconnect(aim, SIGNAL(rowsRemoved(QModelIndex,int,int)),
+                         q, SLOT(_q_rowsRemoved(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsInserted(QModelIndex,int,int)), q,
++                        SLOT(_q_columnsInserted(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsRemoved(QModelIndex,int,int)), q,
++                        SLOT(_q_columnsRemoved(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)), q,
++                        SLOT(_q_columnsMoved(QModelIndex,int,int,QModelIndex,int)));
+     QObject::disconnect(aim, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
+                         q, SLOT(_q_dataChanged(QModelIndex,QModelIndex,QVector<int>)));
+     QObject::disconnect(aim, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
+@@ -1973,6 +1985,38 @@ void QQmlDelegateModel::_q_rowsMoved(
+     }
+ }
+ 
++void QQmlDelegateModel::_q_columnsInserted(const QModelIndex &parent, int begin, int end)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if (parent == d->m_adaptorModel.rootIndex && begin == 0) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
++void QQmlDelegateModel::_q_columnsRemoved(const QModelIndex &parent, int begin, int end)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if (parent == d->m_adaptorModel.rootIndex && begin == 0) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
++void QQmlDelegateModel::_q_columnsMoved(const QModelIndex &parent, int start, int end,
++                                        const QModelIndex &destination, int column)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if ((parent == d->m_adaptorModel.rootIndex && start == 0)
++        || (destination == d->m_adaptorModel.rootIndex && column == 0)) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
+ void QQmlDelegateModel::_q_dataChanged(const QModelIndex &begin, const QModelIndex &end, const QVector<int> &roles)
+ {
+     Q_D(QQmlDelegateModel);
+diff --git a/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h b/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
+index 8aab4badca..d140bfbaaf 100644
+--- a/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
++++ b/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
+@@ -152,6 +152,9 @@ private Q_SLOTS:
+     void _q_itemsMoved(int from, int to, int count);
+     void _q_modelReset();
+     void _q_rowsInserted(const QModelIndex &,int,int);
++    void _q_columnsInserted(const QModelIndex &, int, int);
++    void _q_columnsRemoved(const QModelIndex &, int, int);
++    void _q_columnsMoved(const QModelIndex &, int, int, const QModelIndex &, int);
+     void _q_rowsAboutToBeRemoved(const QModelIndex &parent, int begin, int end);
+     void _q_rowsRemoved(const QModelIndex &,int,int);
+     void _q_rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int);
+diff --git a/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp b/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
+index 85719fdc80..78e2ab302c 100644
+--- a/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
++++ b/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
+@@ -46,6 +46,7 @@
+ #include "QtQuick/private/qquicktextinput_p.h"
+ #include "QtQuick/private/qquickaccessibleattached_p.h"
+ #include "QtQuick/qquicktextdocument.h"
++#include "QtQuick/qquickrendercontrol.h"
+ QT_BEGIN_NAMESPACE
+ 
+ #if QT_CONFIG(accessibility)
+@@ -57,7 +58,19 @@ QAccessibleQuickItem::QAccessibleQuickItem(QQuickItem *item)
+ 
+ QWindow *QAccessibleQuickItem::window() const
+ {
+-    return item()->window();
++    QQuickWindow *window = item()->window();
++
++    // For QQuickWidget the above window will be the offscreen QQuickWindow,
++    // which is not a part of the accessibility tree. Detect this case and
++    // return the window for the QQuickWidget instead.
++    if (window && !window->handle()) {
++        if (QQuickRenderControl *renderControl = QQuickWindowPrivate::get(window)->renderControl) {
++            if (QWindow *renderWindow = renderControl->renderWindow(nullptr))
++                return renderWindow;
++        }
++    }
++
++    return window;
+ }
+ 
+ int QAccessibleQuickItem::childCount() const
+@@ -113,19 +126,15 @@ QAccessibleInterface *QAccessibleQuickItem::childAt(int x, int y) const
+ QAccessibleInterface *QAccessibleQuickItem::parent() const
+ {
+     QQuickItem *parent = item()->parentItem();
+-    QQuickWindow *window = item()->window();
+-    QQuickItem *ci = window ? window->contentItem() : nullptr;
++    QQuickWindow *itemWindow = item()->window();
++    QQuickItem *ci = itemWindow ? itemWindow->contentItem() : nullptr;
+     while (parent && !QQuickItemPrivate::get(parent)->isAccessible && parent != ci)
+         parent = parent->parentItem();
+ 
+     if (parent) {
+         if (parent == ci) {
+-            // Jump out to the scene widget if the parent is the root item.
+-            // There are two root items, QQuickWindow::rootItem and
+-            // QQuickView::declarativeRoot. The former is the true root item,
+-            // but is not a part of the accessibility tree. Check if we hit
+-            // it here and return an interface for the scene instead.
+-            return QAccessible::queryAccessibleInterface(window);
++            // Jump out to the window if the parent is the root item
++            return QAccessible::queryAccessibleInterface(window());
+         } else {
+             while (parent && !parent->d_func()->isAccessible)
+                 parent = parent->parentItem();
+@@ -188,7 +197,7 @@ QAccessible::State QAccessibleQuickItem::state() const
+     QRect viewRect_ = viewRect();
+     QRect itemRect = rect();
+ 
+-    if (viewRect_.isNull() || itemRect.isNull() || !item()->window() || !item()->window()->isVisible() ||!item()->isVisible() || qFuzzyIsNull(item()->opacity()))
++    if (viewRect_.isNull() || itemRect.isNull() || !window() || !window()->isVisible() ||!item()->isVisible() || qFuzzyIsNull(item()->opacity()))
+         state.invisible = true;
+     if (!viewRect_.intersects(itemRect))
+         state.offscreen = true;
+@@ -201,6 +210,10 @@ QAccessible::State QAccessibleQuickItem::state() const
+     if (role() == QAccessible::EditableText)
+         if (auto ti = qobject_cast<QQuickTextInput *>(item()))
+             state.passwordEdit = ti->echoMode() != QQuickTextInput::Normal;
++    if (!item()->isEnabled()) {
++        state.focusable = false;
++        state.disabled = true;
++    }
+     return state;
+ }
+ 
+diff --git a/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h b/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
+index 39ffcaf39c..8baa01330c 100644
+--- a/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
++++ b/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
+@@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE
+ 
+ #if QT_CONFIG(accessibility)
+ 
+-class QAccessibleQuickWindow : public QAccessibleObject
++class Q_QUICK_EXPORT QAccessibleQuickWindow : public QAccessibleObject
+ {
+ public:
+     QAccessibleQuickWindow(QQuickWindow *object);
+diff --git a/qtdeclarative/src/quick/items/qquickdrag.cpp b/qtdeclarative/src/quick/items/qquickdrag.cpp
+index 8321fcfeed..383078b3b9 100644
+--- a/qtdeclarative/src/quick/items/qquickdrag.cpp
++++ b/qtdeclarative/src/quick/items/qquickdrag.cpp
+@@ -481,7 +481,9 @@ void QQuickDragAttached::setKeys(const QStringList &keys)
+     \qmlattachedproperty stringlist QtQuick::Drag::mimeData
+     \since 5.2
+ 
+-    This property holds a map of mimeData that is used during startDrag.
++    This property holds a map from mime type to data that is used during startDrag.
++    The mime data needs to be a \c string, or an \c ArrayBuffer with the data encoded
++    according to the mime type.
+ */
+ 
+ QVariantMap QQuickDragAttached::mimeData() const
+@@ -766,8 +768,12 @@ Qt::DropAction QQuickDragAttachedPrivate::startDrag(Qt::DropActions supportedAct
+     QDrag *drag = new QDrag(source ? source : q);
+     QMimeData *mimeData = new QMimeData();
+ 
+-    for (auto it = externalMimeData.cbegin(), end = externalMimeData.cend(); it != end; ++it)
+-        mimeData->setData(it.key(), it.value().toString().toUtf8());
++    for (auto it = externalMimeData.cbegin(), end = externalMimeData.cend(); it != end; ++it) {
++        if (static_cast<QMetaType::Type>(it.value().type()) == QMetaType::QByteArray)
++            mimeData->setData(it.key(), it.value().toByteArray());
++        else
++            mimeData->setData(it.key(), it.value().toString().toUtf8());
++    }
+ 
+     drag->setMimeData(mimeData);
+     if (pixmapLoader.isReady()) {
+diff --git a/qtdeclarative/src/quick/items/qquickitem.cpp b/qtdeclarative/src/quick/items/qquickitem.cpp
+index 75f1457816..dec0ae19ae 100644
+--- a/qtdeclarative/src/quick/items/qquickitem.cpp
++++ b/qtdeclarative/src/quick/items/qquickitem.cpp
+@@ -59,6 +59,7 @@
+ #include <QtCore/private/qnumeric_p.h>
+ #include <QtGui/qpa/qplatformtheme.h>
+ #include <QtCore/qloggingcategory.h>
++#include <QtCore/private/qduplicatetracker_p.h>
+ 
+ #include <private/qqmlglobal_p.h>
+ #include <private/qqmlengine_p.h>
+@@ -2326,6 +2327,7 @@ QQuickItem::QQuickItem(QQuickItemPrivate &dd, QQuickItem *parent)
+ QQuickItem::~QQuickItem()
+ {
+     Q_D(QQuickItem);
++    d->inDestructor = true;
+ 
+     if (d->windowRefCount > 1)
+         d->windowRefCount = 1; // Make sure window is set to null in next call to derefWindow().
+@@ -2526,6 +2528,7 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo
+     QQuickItem *current = item;
+     qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: startItem:" << startItem;
+     qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: firstFromItem:" << firstFromItem;
++    QDuplicateTracker<QQuickItem *> cycleDetector;
+     do {
+         qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: current:" << current;
+         qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: from:" << from;
+@@ -2592,7 +2595,10 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo
+         // traversed all of the chain (by compare the [current] item with [startItem])
+         // Since the [startItem] might be promoted to its parent if it is invisible,
+         // we still have to check [current] item with original start item
+-        if ((current == startItem || current == originalStartItem) && from == firstFromItem) {
++        // We might also run into a cycle before we reach firstFromItem again
++        // but note that we have to ignore current if we are meant to skip it
++        if (((current == startItem || current == originalStartItem) && from == firstFromItem) ||
++                (!skip && cycleDetector.hasSeen(current))) {
+             // wrapped around, avoid endless loops
+             if (item == contentItem) {
+                 qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: looped, return contentItem";
+@@ -2689,9 +2695,8 @@ void QQuickItem::setParentItem(QQuickItem *parentItem)
+ 
+         const bool wasVisible = isVisible();
+         op->removeChild(this);
+-        if (wasVisible) {
++        if (wasVisible && !op->inDestructor)
+             emit oldParentItem->visibleChildrenChanged();
+-        }
+     } else if (d->window) {
+         QQuickWindowPrivate::get(d->window)->parentlessItems.remove(this);
+     }
+@@ -2768,8 +2773,9 @@ void QQuickItem::setParentItem(QQuickItem *parentItem)
+ 
+     d->itemChange(ItemParentHasChanged, d->parentItem);
+ 
+-    emit parentChanged(d->parentItem);
+-    if (isVisible() && d->parentItem)
++    if (!d->inDestructor)
++        emit parentChanged(d->parentItem);
++    if (isVisible() && d->parentItem && !QQuickItemPrivate::get(d->parentItem)->inDestructor)
+         emit d->parentItem->visibleChildrenChanged();
+ }
+ 
+@@ -2965,7 +2971,8 @@ void QQuickItemPrivate::removeChild(QQuickItem *child)
+ 
+     itemChange(QQuickItem::ItemChildRemovedChange, child);
+ 
+-    emit q->childrenChanged();
++    if (!inDestructor)
++        emit q->childrenChanged();
+ }
+ 
+ void QQuickItemPrivate::refWindow(QQuickWindow *c)
+@@ -3194,6 +3201,7 @@ QQuickItemPrivate::QQuickItemPrivate()
+     , touchEnabled(false)
+ #endif
+     , hasCursorHandler(false)
++    , inDestructor(false)
+     , dirtyAttributes(0)
+     , nextDirtyItem(nullptr)
+     , prevDirtyItem(nullptr)
+@@ -5120,6 +5128,13 @@ void QQuickItem::componentComplete()
+         d->addToDirtyList();
+         QQuickWindowPrivate::get(d->window)->dirtyItem(this);
+     }
++
++#if QT_CONFIG(accessibility)
++    if (d->isAccessible && d->effectiveVisible) {
++        QAccessibleEvent ev(this, QAccessible::ObjectShow);
++        QAccessible::updateAccessibility(&ev);
++    }
++#endif
+ }
+ 
+ QQuickStateGroup *QQuickItemPrivate::_states()
+@@ -6106,9 +6121,11 @@ bool QQuickItemPrivate::setEffectiveVisibleRecur(bool newEffectiveVisible)
+         QAccessible::updateAccessibility(&ev);
+     }
+ #endif
+-    emit q->visibleChanged();
+-    if (childVisibilityChanged)
+-        emit q->visibleChildrenChanged();
++    if (!inDestructor) {
++        emit q->visibleChanged();
++        if (childVisibilityChanged)
++            emit q->visibleChildrenChanged();
++    }
+ 
+     return true;    // effective visibility DID change
+ }
+@@ -6157,6 +6174,15 @@ void QQuickItemPrivate::setEffectiveEnableRecur(QQuickItem *scope, bool newEffec
+     }
+ 
+     itemChange(QQuickItem::ItemEnabledHasChanged, effectiveEnable);
++#if QT_CONFIG(accessibility)
++    if (isAccessible) {
++        QAccessible::State changedState;
++        changedState.disabled = true;
++        changedState.focusable = true;
++        QAccessibleStateChangeEvent ev(q, changedState);
++        QAccessible::updateAccessibility(&ev);
++    }
++#endif
+     emit q->enabledChanged();
+ }
+ 
+diff --git a/qtdeclarative/src/quick/items/qquickitem_p.h b/qtdeclarative/src/quick/items/qquickitem_p.h
+index 841d91bb40..ade8fb61f2 100644
+--- a/qtdeclarative/src/quick/items/qquickitem_p.h
++++ b/qtdeclarative/src/quick/items/qquickitem_p.h
+@@ -472,6 +472,7 @@ public:
+     bool replayingPressEvent:1;
+     bool touchEnabled:1;
+     bool hasCursorHandler:1;
++    quint32 inDestructor:1; // has entered ~QQuickItem
+ 
+     enum DirtyType {
+         TransformOrigin         = 0x00000001,
+diff --git a/qtdeclarative/src/quick/items/qquickitemview.cpp b/qtdeclarative/src/quick/items/qquickitemview.cpp
+index 010a0152e1..f8ad168a17 100644
+--- a/qtdeclarative/src/quick/items/qquickitemview.cpp
++++ b/qtdeclarative/src/quick/items/qquickitemview.cpp
+@@ -1785,7 +1785,7 @@ void QQuickItemViewPrivate::refill(qreal from, qreal to)
+ 
+     do {
+         bufferPause.stop();
+-        if (currentChanges.hasPendingChanges() || bufferedChanges.hasPendingChanges()) {
++        if (currentChanges.hasPendingChanges() || bufferedChanges.hasPendingChanges() || currentChanges.active) {
+             currentChanges.reset();
+             bufferedChanges.reset();
+             releaseVisibleItems(reusableFlag);
+diff --git a/qtdeclarative/src/quick/items/qquickmousearea_p_p.h b/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
+index fba383e268..0d63618622 100644
+--- a/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
++++ b/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
+@@ -61,7 +61,6 @@ QT_BEGIN_NAMESPACE
+ 
+ class QQuickMouseEvent;
+ class QQuickMouseArea;
+-class QQuickPointerMask;
+ class QQuickMouseAreaPrivate : public QQuickItemPrivate
+ {
+     Q_DECLARE_PUBLIC(QQuickMouseArea)
+@@ -100,7 +99,6 @@ public:
+ #if QT_CONFIG(quick_draganddrop)
+     QQuickDrag *drag;
+ #endif
+-    QPointer<QQuickPointerMask> mask;
+     QPointF startScene;
+     QPointF targetStartPos;
+     QPointF lastPos;
+diff --git a/qtdeclarative/src/quick/items/qquicktext.cpp b/qtdeclarative/src/quick/items/qquicktext.cpp
+index 6230186933..e823ca1095 100644
+--- a/qtdeclarative/src/quick/items/qquicktext.cpp
++++ b/qtdeclarative/src/quick/items/qquicktext.cpp
+@@ -2168,7 +2168,7 @@ void QQuickText::resetMaximumLineCount()
+     <img src="" align="top,middle,bottom" width="" height=""> - inline images
+     <ol type="">, <ul type=""> and <li> - ordered and unordered lists
+     <pre></pre> - preformatted
+-    &gt; &lt; &amp;
++    &gt; &lt; &amp; &quot; &nbsp; &apos;
+     \endcode
+ 
+     \c Text.StyledText parser is strict, requiring tags to be correctly nested.
+diff --git a/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp b/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
+index eb4db0f85e..2325a2665b 100644
+--- a/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
++++ b/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
+@@ -446,7 +446,7 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+         const char *textureRecord = allocatorData;
+         for (int i = 0; i < textureCount; ++i, textureRecord += Qtdf::TextureRecordSize) {
+-            if (textureRecord + Qtdf::TextureRecordSize > qtdfTableEnd) {
++            if (qtdfTableEnd - textureRecord < Qtdf::TextureRecordSize) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+@@ -462,7 +462,7 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+         const char *glyphRecord = textureRecord;
+         for (quint32 i = 0; i < glyphCount; ++i, glyphRecord += Qtdf::GlyphRecordSize) {
+-            if (glyphRecord + Qtdf::GlyphRecordSize > qtdfTableEnd) {
++            if (qtdfTableEnd - glyphRecord < Qtdf:: GlyphRecordSize) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+@@ -512,8 +512,8 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+             int width = texInfo->allocatedArea.width();
+             int height = texInfo->allocatedArea.height();
+-            qint64 size = width * height;
+-            if (reinterpret_cast<const char *>(textureData + size) > qtdfTableEnd) {
++            qint64 size = qint64(width) * height;
++            if (qtdfTableEnd - reinterpret_cast<const char *>(textureData) < size) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+diff --git a/qtdeclarative/src/quick/util/qquickstyledtext.cpp b/qtdeclarative/src/quick/util/qquickstyledtext.cpp
+index d531fc9205..a25af90414 100644
+--- a/qtdeclarative/src/quick/util/qquickstyledtext.cpp
++++ b/qtdeclarative/src/quick/util/qquickstyledtext.cpp
+@@ -564,6 +564,8 @@ void QQuickStyledTextPrivate::parseEntity(const QChar *&ch, const QString &textI
+                 textOut += QChar(60);
+             else if (entity == QLatin1String("amp"))
+                 textOut += QChar(38);
++            else if (entity == QLatin1String("apos"))
++                textOut += QChar(39);
+             else if (entity == QLatin1String("quot"))
+                 textOut += QChar(34);
+             else if (entity == QLatin1String("nbsp"))
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp
+new file mode 100644
+index 0000000000..8a1c901880
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp
+@@ -0,0 +1,110 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include "qaccessiblequickwidget_p.h"
++
++#include "qquickwidget_p.h"
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleQuickWidget::QAccessibleQuickWidget(QQuickWidget* widget)
++: QAccessibleWidget(widget)
++, m_accessibleWindow(QQuickWidgetPrivate::get(widget)->offscreenWindow)
++{
++    // NOTE: m_accessibleWindow is a QAccessibleQuickWindow, and not a
++    // QAccessibleQuickWidgetOffscreenWindow (defined below). This means
++    // it will return the Quick item child interfaces, which is what's needed here
++    // (unlike QAccessibleQuickWidgetOffscreenWindow, which will report 0 children).
++}
++
++QAccessibleInterface *QAccessibleQuickWidget::child(int index) const
++{
++    return m_accessibleWindow.child(index);
++}
++
++int QAccessibleQuickWidget::childCount() const
++{
++    return m_accessibleWindow.childCount();
++}
++
++int QAccessibleQuickWidget::indexOfChild(const QAccessibleInterface *iface) const
++{
++    return m_accessibleWindow.indexOfChild(iface);
++}
++
++QAccessibleInterface *QAccessibleQuickWidget::childAt(int x, int y) const
++{
++    return m_accessibleWindow.childAt(x, y);
++}
++
++QAccessibleQuickWidgetOffscreenWindow::QAccessibleQuickWidgetOffscreenWindow(QQuickWindow *window)
++:QAccessibleQuickWindow(window)
++{
++
++}
++
++QAccessibleInterface *QAccessibleQuickWidgetOffscreenWindow::child(int index) const
++{
++    Q_UNUSED(index);
++    return nullptr;
++}
++
++int QAccessibleQuickWidgetOffscreenWindow::childCount() const
++{
++    return 0;
++}
++
++int QAccessibleQuickWidgetOffscreenWindow::indexOfChild(const QAccessibleInterface *iface) const
++{
++    Q_UNUSED(iface);
++    return -1;
++}
++
++QAccessibleInterface *QAccessibleQuickWidgetOffscreenWindow::QAccessibleQuickWidgetOffscreenWindow::childAt(int x, int y) const
++{
++    Q_UNUSED(x);
++    Q_UNUSED(y);
++    return nullptr;
++}
++
++#endif // accessibility
++
++QT_END_NAMESPACE
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h
+new file mode 100644
+index 0000000000..7c2ab930e0
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h
+@@ -0,0 +1,95 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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 QACCESSIBLEQUICKWIDGET_H
++#define QACCESSIBLEQUICKWIDGET_H
++
++//
++//  W A R N I N G
++//  -------------
++//
++// This file is not part of the Qt API.  It exists purely as an
++// implementation detail.  This header file may change from version to
++// version without notice, or even be removed.
++//
++// We mean it.
++//
++
++#include "qquickwidget.h"
++#include <QtWidgets/qaccessiblewidget.h>
++
++#include <private/qaccessiblequickview_p.h>
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++// These classes implement the QQuickWiget accessibility switcharoo,
++// where the child items of the QQuickWidgetOffscreenWindow are reported
++// as child accessible interfaces of the QAccessibleQuickWidget.
++class QAccessibleQuickWidget: public QAccessibleWidget
++{
++public:
++    QAccessibleQuickWidget(QQuickWidget* widget);
++
++    QAccessibleInterface *child(int index) const override;
++    int childCount() const override;
++    int indexOfChild(const QAccessibleInterface *iface) const override;
++    QAccessibleInterface *childAt(int x, int y) const override;
++
++private:
++    QAccessibleQuickWindow m_accessibleWindow;
++    Q_DISABLE_COPY(QAccessibleQuickWidget)
++};
++
++class QAccessibleQuickWidgetOffscreenWindow: public QAccessibleQuickWindow
++{
++public:
++    QAccessibleQuickWidgetOffscreenWindow(QQuickWindow *window);
++    QAccessibleInterface *child(int index) const override;
++    int childCount() const override;
++    int indexOfChild(const QAccessibleInterface *iface) const override;
++    QAccessibleInterface *childAt(int x, int y) const override;
++};
++
++#endif // accessibility
++
++QT_END_NAMESPACE
++
++#endif
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp
+new file mode 100644
+index 0000000000..7ba88a1769
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp
+@@ -0,0 +1,60 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include "qaccessiblequickwidgetfactory_p.h"
++#include "qaccessiblequickwidget_p.h"
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleInterface *qAccessibleQuickWidgetFactory(const QString &classname, QObject *object)
++{
++    if (classname == QLatin1String("QQuickWidget")) {
++        return new QAccessibleQuickWidget(qobject_cast<QQuickWidget *>(object));
++    } else if (classname == QLatin1String("QQuickWidgetOffscreenWindow")) {
++        return new QAccessibleQuickWidgetOffscreenWindow(qobject_cast<QQuickWindow *>(object));
++    }
++    return 0;
++}
++
++#endif // accessibility
++
++QT_END_NAMESPACE
++
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h
+new file mode 100644
+index 0000000000..8c63b09f81
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h
+@@ -0,0 +1,66 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include <QtGui/qaccessible.h>
++
++#ifndef QACCESSIBLEQUICKWIDGETFACTORY_H
++#define QACCESSIBLEQUICKWIDGETFACTORY_H
++
++//
++//  W A R N I N G
++//  -------------
++//
++// This file is not part of the Qt API.  It exists purely as an
++// implementation detail.  This header file may change from version to
++// version without notice, or even be removed.
++//
++// We mean it.
++//
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleInterface *qAccessibleQuickWidgetFactory(const QString &classname, QObject *object);
++
++#endif
++
++QT_END_NAMESPACE
++
++#endif
+diff --git a/qtdeclarative/src/quickwidgets/qquickwidget.cpp b/qtdeclarative/src/quickwidgets/qquickwidget.cpp
+index 39780f8de3..9c97b43518 100644
+--- a/qtdeclarative/src/quickwidgets/qquickwidget.cpp
++++ b/qtdeclarative/src/quickwidgets/qquickwidget.cpp
+@@ -39,6 +39,7 @@
+ 
+ #include "qquickwidget.h"
+ #include "qquickwidget_p.h"
++#include "qaccessiblequickwidgetfactory_p.h"
+ 
+ #include "private/qquickwindow_p.h"
+ #include "private/qquickitem_p.h"
+@@ -75,9 +76,16 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++QQuickWidgetOffscreenWindow::QQuickWidgetOffscreenWindow(QQuickWindowPrivate &dd, QQuickRenderControl *control)
++:QQuickWindow(dd, control)
++{
++    setTitle(QString::fromLatin1("Offscreen"));
++    setObjectName(QString::fromLatin1("QQuickOffScreenWindow"));
++}
++
+ // override setVisble to prevent accidental offscreen window being created
+ // by base class.
+-class QQuickOffcreenWindowPrivate: public QQuickWindowPrivate {
++class QQuickWidgetOffscreenWindowPrivate: public QQuickWindowPrivate {
+ public:
+     void setVisible(bool visible) override {
+         Q_Q(QWindow);
+@@ -105,9 +113,8 @@ void QQuickWidgetPrivate::init(QQmlEngine* e)
+     Q_Q(QQuickWidget);
+ 
+     renderControl = new QQuickWidgetRenderControl(q);
+-    offscreenWindow = new QQuickWindow(*new QQuickOffcreenWindowPrivate(),renderControl);
+-    offscreenWindow->setTitle(QString::fromLatin1("Offscreen"));
+-    offscreenWindow->setObjectName(QString::fromLatin1("QQuickOffScreenWindow"));
++    offscreenWindow = new QQuickWidgetOffscreenWindow(*new QQuickWidgetOffscreenWindowPrivate(), renderControl);
++    offscreenWindow->setScreen(q->screen());
+     // Do not call create() on offscreenWindow.
+ 
+     // Check if the Software Adaptation is being used
+@@ -138,6 +145,10 @@ void QQuickWidgetPrivate::init(QQmlEngine* e)
+     QWidget::connect(offscreenWindow, &QQuickWindow::focusObjectChanged, q, &QQuickWidget::propagateFocusObjectChanged);
+     QObject::connect(renderControl, SIGNAL(renderRequested()), q, SLOT(triggerUpdate()));
+     QObject::connect(renderControl, SIGNAL(sceneChanged()), q, SLOT(triggerUpdate()));
++
++#if QT_CONFIG(accessibility)
++    QAccessible::installFactory(&qAccessibleQuickWidgetFactory);
++#endif
+ }
+ 
+ void QQuickWidgetPrivate::ensureEngine() const
+@@ -901,9 +912,7 @@ void QQuickWidgetPrivate::createContext()
+ 
+         context = new QOpenGLContext;
+         context->setFormat(offscreenWindow->requestedFormat());
+-        const QWindow *win = q->window()->windowHandle();
+-        if (win && win->screen())
+-            context->setScreen(win->screen());
++        context->setScreen(q->screen());
+         QOpenGLContext *shareContext = qt_gl_global_share_context();
+         if (!shareContext)
+             shareContext = QWidgetPrivate::get(q->window())->shareContext();
+@@ -1520,19 +1529,16 @@ bool QQuickWidget::event(QEvent *e)
+         d->handleWindowChange();
+         break;
+ 
+-    case QEvent::ScreenChangeInternal:
+-        if (QWindow *window = this->window()->windowHandle()) {
+-            QScreen *newScreen = window->screen();
+-
+-            if (d->offscreenWindow)
+-                d->offscreenWindow->setScreen(newScreen);
+-            if (d->offscreenSurface)
+-                d->offscreenSurface->setScreen(newScreen);
++    case QEvent::ScreenChangeInternal: {
++        QScreen *newScreen = screen();
++        if (d->offscreenWindow)
++            d->offscreenWindow->setScreen(newScreen);
++        if (d->offscreenSurface)
++            d->offscreenSurface->setScreen(newScreen);
+ #if QT_CONFIG(opengl)
+-            if (d->context)
+-                d->context->setScreen(newScreen);
++        if (d->context)
++            d->context->setScreen(newScreen);
+ #endif
+-        }
+ 
+         if (d->useSoftwareRenderer
+ #if QT_CONFIG(opengl)
+@@ -1545,7 +1551,7 @@ bool QQuickWidget::event(QEvent *e)
+             d->render(true);
+         }
+         break;
+-
++    }
+     case QEvent::Show:
+     case QEvent::Move:
+         d->updatePosition();
+diff --git a/qtdeclarative/src/quickwidgets/qquickwidget_p.h b/qtdeclarative/src/quickwidgets/qquickwidget_p.h
+index 881f7f9220..1a946bcc71 100644
+--- a/qtdeclarative/src/quickwidgets/qquickwidget_p.h
++++ b/qtdeclarative/src/quickwidgets/qquickwidget_p.h
+@@ -148,6 +148,14 @@ public:
+     bool forceFullUpdate;
+ };
+ 
++class QQuickWidgetOffscreenWindow: public QQuickWindow
++{
++    Q_OBJECT
++
++public:
++    QQuickWidgetOffscreenWindow(QQuickWindowPrivate &dd, QQuickRenderControl *control);
++};
++
+ QT_END_NAMESPACE
+ 
+ #endif // QQuickWidget_P_H
+diff --git a/qtdeclarative/src/quickwidgets/quickwidgets.pro b/qtdeclarative/src/quickwidgets/quickwidgets.pro
+index 2438e577ae..85d156b8a3 100644
+--- a/qtdeclarative/src/quickwidgets/quickwidgets.pro
++++ b/qtdeclarative/src/quickwidgets/quickwidgets.pro
+@@ -7,9 +7,13 @@ DEFINES   += QT_NO_URL_CAST_FROM_STRING QT_NO_INTEGER_EVENT_COORDINATES QT_NO_FO
+ HEADERS += \
+     qquickwidget.h \
+     qquickwidget_p.h \
+-    qtquickwidgetsglobal.h
++    qtquickwidgetsglobal.h \
++    qaccessiblequickwidget_p.h \
++    qaccessiblequickwidgetfactory_p.h
+ 
+ SOURCES += \
+-    qquickwidget.cpp
++    qquickwidget.cpp \
++    qaccessiblequickwidget.cpp \
++    qaccessiblequickwidgetfactory.cpp
+ 
+ load(qt_module)
+diff --git a/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+index 3b7d74df63..b75bf820d5 100644
+--- a/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
++++ b/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+@@ -102,6 +102,7 @@ private slots:
+     void valueConversion_RegularExpression();
+     void castWithMultipleInheritance();
+     void collectGarbage();
++    void collectGarbageNestedWrappersTwoEngines();
+     void gcWithNestedDataStructure();
+     void stacktrace();
+     void numberParsing_data();
+@@ -1809,6 +1810,44 @@ void tst_QJSEngine::collectGarbage()
+     QVERIFY(ptr.isNull());
+ }
+ 
++class TestObjectContainer : public QObject
++{
++    Q_OBJECT
++    Q_PROPERTY(QObject *dummy MEMBER m_dummy CONSTANT)
++
++public:
++    TestObjectContainer() : m_dummy(new QObject(this)) {}
++
++private:
++    QObject *m_dummy;
++};
++
++void tst_QJSEngine::collectGarbageNestedWrappersTwoEngines()
++{
++    QJSEngine engine1;
++    QJSEngine engine2;
++
++    TestObjectContainer container;
++    QQmlEngine::setObjectOwnership(&container, QQmlEngine::CppOwnership);
++
++    engine1.globalObject().setProperty("foobar", engine1.newQObject(&container));
++    engine2.globalObject().setProperty("foobar", engine2.newQObject(&container));
++
++    engine1.evaluate("foobar.dummy.baz = 42");
++    engine2.evaluate("foobar.dummy.baz = 43");
++
++    QCOMPARE(engine1.evaluate("foobar.dummy.baz").toInt(), 42);
++    QCOMPARE(engine2.evaluate("foobar.dummy.baz").toInt(), 43);
++
++    engine1.collectGarbage();
++    engine2.collectGarbage();
++
++    // The GC should not collect dummy object wrappers neither in engine1 nor engine2, we
++    // verify that by checking whether the baz property still has its previous value.
++    QCOMPARE(engine1.evaluate("foobar.dummy.baz").toInt(), 42);
++    QCOMPARE(engine2.evaluate("foobar.dummy.baz").toInt(), 43);
++}
++
+ void tst_QJSEngine::gcWithNestedDataStructure()
+ {
+     // The GC must be able to traverse deeply nested objects, otherwise this
+diff --git a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml
+new file mode 100644
+index 0000000000..206133bb39
+--- /dev/null
++++ b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml
+@@ -0,0 +1,11 @@
++import QtQuick 2.8
++
++ListView {
++    id: root
++    width: 200
++    height: 200
++
++    delegate: Text {
++        text: display
++    }
++}
+diff --git a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
+index 35f1e2c94d..1722447830 100644
+--- a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
++++ b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
+@@ -27,6 +27,8 @@
+ ****************************************************************************/
+ 
+ #include <QtTest/qtest.h>
++#include <QtCore/QConcatenateTablesProxyModel>
++#include <QtGui/QStandardItemModel>
+ #include <QtQml/qqmlcomponent.h>
+ #include <QtQmlModels/private/qqmldelegatemodel_p.h>
+ #include <QtQuick/qquickview.h>
+@@ -47,6 +49,7 @@ private slots:
+     void filterOnGroup_removeWhenCompleted();
+     void qtbug_86017();
+     void contextAccessedByHandler();
++    void redrawUponColumnChange();
+ };
+ 
+ class AbstractItemModel : public QAbstractItemModel
+@@ -186,6 +189,30 @@ void tst_QQmlDelegateModel::contextAccessedByHandler()
+     QVERIFY(root->property("works").toBool());
+ }
+ 
++void tst_QQmlDelegateModel::redrawUponColumnChange()
++{
++    QStandardItemModel m1;
++    m1.appendRow({
++            new QStandardItem("Banana"),
++            new QStandardItem("Coconut"),
++    });
++
++    QQuickView view(testFileUrl("redrawUponColumnChange.qml"));
++    QCOMPARE(view.status(), QQuickView::Ready);
++    view.show();
++    QQuickItem *root = view.rootObject();
++    root->setProperty("model", QVariant::fromValue<QObject *>(&m1));
++
++    QObject *item = root->property("currentItem").value<QObject *>();
++    QVERIFY(item);
++    QCOMPARE(item->property("text").toString(), "Banana");
++
++    QVERIFY(root);
++    m1.removeColumn(0);
++
++    QCOMPARE(item->property("text").toString(), "Coconut");
++}
++
+ QTEST_MAIN(tst_QQmlDelegateModel)
+ 
+ #include "tst_qqmldelegatemodel.moc"
+diff --git a/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp b/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
+index 5d635aa63b..824fd89e5b 100644
+--- a/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
++++ b/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
+@@ -76,10 +76,10 @@ void tst_qv4mm::multiWrappedQObjects()
+         QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 1);
+         QCOMPARE(engine2.memoryManager->m_pendingFreedObjectWrapperValue.size(), 0);
+ 
+-        // Moves the additional WeakValue from m_multiplyWrappedQObjects to
+-        // m_pendingFreedObjectWrapperValue. It's still alive after all.
++        // The additional WeakValue from m_multiplyWrappedQObjects hasn't been moved
++        // to m_pendingFreedObjectWrapperValue yet. It's still alive after all.
+         engine1.memoryManager->runGC();
+-        QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 2);
++        QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 1);
+ 
+         // engine2 doesn't own the object as engine1 was the first to wrap it above.
+         // Therefore, no effect here.
+diff --git a/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml b/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml
+new file mode 100644
+index 0000000000..889e480f3b
+--- /dev/null
++++ b/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml
+@@ -0,0 +1,13 @@
++import QtQuick 2.6
++
++Item {
++    visible: true
++    Item {
++        visible: false
++        Item {
++            objectName: "hiddenChild"
++            activeFocusOnTab: true
++            focus: true
++        }
++    }
++}
+diff --git a/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp b/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+index c8f251dbe1..c8ef36ee68 100644
+--- a/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
++++ b/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+@@ -67,6 +67,7 @@ private slots:
+     void activeFocusOnTab10();
+     void activeFocusOnTab_infiniteLoop_data();
+     void activeFocusOnTab_infiniteLoop();
++    void activeFocusOnTab_infiniteLoopControls();
+ 
+     void nextItemInFocusChain();
+     void nextItemInFocusChain2();
+@@ -1057,6 +1058,17 @@ void tst_QQuickItem::activeFocusOnTab_infiniteLoop()
+     QCOMPARE(item, window->rootObject());
+ }
+ 
++
++void tst_QQuickItem::activeFocusOnTab_infiniteLoopControls()
++{
++    auto source = testFileUrl("activeFocusOnTab_infiniteLoop3.qml");
++    QScopedPointer<QQuickView>window(new QQuickView());
++    window->setSource(source);
++    window->show();
++    QVERIFY(window->errors().isEmpty());
++    QTest::keyClick(window.get(), Qt::Key_Tab); // should not hang
++}
++
+ void tst_QQuickItem::nextItemInFocusChain()
+ {
+     if (!qt_tab_all_widgets())
+Submodule qtdoc c0c7bf07...79d6ef69:
+Submodule qtimageformats 2dcf2899..abe44c0f:
+diff --git a/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp b/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
+index dde783c..1bf9074 100644
+--- a/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
+@@ -462,8 +462,12 @@ static bool parseIconEntryInfo(ICNSEntry &icon)
+     if (isIconCompressed(icon))
+         return true;
+     // Icon depth:
+-    if (!depth.isEmpty())
+-        icon.depth = ICNSEntry::Depth(depth.toUInt());
++    if (!depth.isEmpty()) {
++        const uint depthUInt = depth.toUInt();
++        if (depthUInt > 32)
++            return false;
++        icon.depth = ICNSEntry::Depth(depthUInt);
++    }
+     // Try mono if depth not found
+     if (icon.depth == ICNSEntry::DepthUnknown)
+         icon.depth = ICNSEntry::DepthMono;
+@@ -515,6 +519,9 @@ static bool parseIconEntryInfo(ICNSEntry &icon)
+         }
+         icon.height = icon.width;
+     }
++    // Sanity check
++    if (icon.width == 0 || icon.width > 4096)
++        return false;
+     return true;
+ }
+ 
+@@ -685,7 +692,7 @@ bool QICNSHandler::canRead() const
+ bool QICNSHandler::read(QImage *outImage)
+ {
+     QImage img;
+-    if (!ensureScanned()) {
++    if (!ensureScanned() || m_currentIconIndex >= m_icons.size()) {
+         qWarning("QICNSHandler::read(): The device wasn't parsed properly!");
+         return false;
+     }
+@@ -892,7 +899,7 @@ bool QICNSHandler::scanDevice()
+             return false;
+ 
+         const qint64 blockDataOffset = device()->pos();
+-        if (!isBlockHeaderValid(blockHeader)) {
++        if (!isBlockHeaderValid(blockHeader, ICNSBlockHeaderSize + filelength - blockDataOffset)) {
+             qWarning("QICNSHandler::scanDevice(): Failed, bad header at pos %s. OSType \"%s\", length %u",
+                      QByteArray::number(blockDataOffset).constData(),
+                      nameFromOSType(blockHeader.ostype).constData(), blockHeader.length);
+@@ -927,11 +934,14 @@ bool QICNSHandler::scanDevice()
+         case ICNSBlockHeader::TypeOdrp:
+             // Icns container seems to have an embedded icon variant container
+             // Let's start a scan for entries
+-            while (device()->pos() < nextBlockOffset) {
++            while (!stream.atEnd() && device()->pos() < nextBlockOffset) {
+                 ICNSBlockHeader icon;
+                 stream >> icon;
++                if (stream.status() != QDataStream::Ok)
++                    return false;
+                 // Check for incorrect variant entry header and stop scan
+-                if (!isBlockHeaderValid(icon, blockDataLength))
++                quint64 remaining = blockDataLength - (device()->pos() - blockDataOffset);
++                if (!isBlockHeaderValid(icon, ICNSBlockHeaderSize + remaining))
+                     break;
+                 if (!addEntry(icon, device()->pos(), blockHeader.ostype))
+                     return false;
+@@ -1003,7 +1013,7 @@ bool QICNSHandler::scanDevice()
+             break;
+         }
+     }
+-    return true;
++    return (m_icons.size() > 0);
+ }
+ 
+ const ICNSEntry &QICNSHandler::getIconMask(const ICNSEntry &icon) const
+diff --git a/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp b/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
+index 5082023..cb34374 100644
+--- a/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
++++ b/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
+@@ -43,6 +43,7 @@
+ #include "qimage.h"
+ #include "qvariant.h"
+ #include "qcolor.h"
++#include "qimagereader.h"
+ 
+ #include <jasper/jasper.h>
+ #include <math.h> // for pow
+@@ -333,16 +334,46 @@ private:
+ Jpeg2000JasperReader::Jpeg2000JasperReader(QIODevice *iod, SubFormat format)
+     : jasperOk(true), ioDevice(iod), format(format), hasAlpha(false)
+ {
++#if JAS_VERSION_MAJOR < 3
+     if (jas_init()) {
+         jasperOk = false;
+         qDebug("Jasper Library initialization failed");
+     }
++#else
++    jas_conf_clear();
++#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
++    jas_conf_set_max_mem_usage(QImageReader::allocationLimit() * 1024 * 1024);
++#else
++    // 128MB seems to be enough.
++    jas_conf_set_max_mem_usage(128 * 1024 * 1024);
++#endif
++    if (jas_init_library()) {
++        jasperOk = false;
++        qDebug("Jasper library initialization failed");
++    }
++    if (jas_init_thread()) {
++        jas_cleanup_library();
++        jasperOk = false;
++        qDebug("Jasper thread initialization failed");
++    }
++#endif
+ }
+ 
+ Jpeg2000JasperReader::~Jpeg2000JasperReader()
+ {
++#if JAS_VERSION_MAJOR < 3
+     if (jasperOk)
+         jas_cleanup();
++#else
++    if (jasperOk) {
++        if (jas_cleanup_thread()) {
++            qDebug("Jasper thread cleanup failed");
++        }
++        if (jas_cleanup_library()) {
++            qDebug("Jasper library cleanup failed");
++        }
++    }
++#endif
+ }
+ 
+ /*! \internal
+@@ -857,7 +888,7 @@ bool Jpeg2000JasperReader::write(const QImage &image, int quality)
+     }
+ 
+     // Open an empty jasper stream that grows automatically
+-    jas_stream_t * memory_stream = jas_stream_memopen(0, -1);
++    jas_stream_t * memory_stream = jas_stream_memopen(0, 0);
+ 
+     // Jasper wants a non-const string.
+     char *str = qstrdup(jasperFormatString.toLatin1().constData());
+diff --git a/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp b/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
+index 1386750..ac8956c 100644
+--- a/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
+@@ -361,6 +361,8 @@ bool QTiffHandler::read(QImage *image)
+     }
+ 
+     TIFF *const tiff = d->tiff;
++    if (TIFFIsTiled(tiff) && TIFFTileSize64(tiff) > uint64_t(image->sizeInBytes())) // Corrupt image
++        return false;
+     const quint32 width = d->size.width();
+     const quint32 height = d->size.height();
+ 
+diff --git a/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp b/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
+index 82d38cb..d02eb05 100644
+--- a/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
+@@ -45,6 +45,7 @@
+ #include <qdebug.h>
+ #include <qpainter.h>
+ #include <qvariant.h>
++#include <QtEndian>
+ 
+ static const int riffHeaderSize = 12; // RIFF_HEADER_SIZE from webp/format_constants.h
+ 
+@@ -102,21 +103,23 @@ bool QWebpHandler::ensureScanned() const
+ 
+     m_scanState = ScanError;
+ 
+-    if (device()->isSequential()) {
+-        qWarning() << "Sequential devices are not supported";
++    QWebpHandler *that = const_cast<QWebpHandler *>(this);
++    const int headerBytesNeeded = sizeof(WebPBitstreamFeatures);
++    QByteArray header = device()->peek(headerBytesNeeded);
++    if (header.size() < headerBytesNeeded)
+         return false;
+-    }
+ 
+-    qint64 oldPos = device()->pos();
+-    device()->seek(0);
+-
+-    QWebpHandler *that = const_cast<QWebpHandler *>(this);
+-    QByteArray header = device()->peek(sizeof(WebPBitstreamFeatures));
++    // We do no random access during decoding, just a readAll() of the whole image file. So if
++    // if it is all available already, we can accept a sequential device. The riff header contains
++    // the file size minus 8 bytes header
++    qint64 byteSize = qFromLittleEndian<quint32>(header.constData() + 4);
++    if (device()->isSequential() && device()->bytesAvailable() < byteSize + 8) {
++        qWarning() << "QWebpHandler: Insufficient data available in sequential device";
++        return false;
++    }
+     if (WebPGetFeatures((const uint8_t*)header.constData(), header.size(), &(that->m_features)) == VP8_STATUS_OK) {
+         if (m_features.has_animation) {
+             // For animation, we have to read and scan whole file to determine loop count and images count
+-            device()->seek(oldPos);
+-
+             if (that->ensureDemuxer()) {
+                 that->m_loop = WebPDemuxGetI(m_demuxer, WEBP_FF_LOOP_COUNT);
+                 that->m_frameCount = WebPDemuxGetI(m_demuxer, WEBP_FF_FRAME_COUNT);
+@@ -126,17 +129,13 @@ bool QWebpHandler::ensureScanned() const
+                 if (that->m_features.has_alpha)
+                     that->m_composited->fill(Qt::transparent);
+ 
+-                // We do not reset device position since we have read in all data
+                 m_scanState = ScanSuccess;
+-                return true;
+             }
+         } else {
+             m_scanState = ScanSuccess;
+         }
+     }
+ 
+-    device()->seek(oldPos);
+-
+     return m_scanState == ScanSuccess;
+ }
+ 
+@@ -159,7 +158,7 @@ bool QWebpHandler::ensureDemuxer()
+ 
+ bool QWebpHandler::read(QImage *image)
+ {
+-    if (!ensureScanned() || device()->isSequential() || !ensureDemuxer())
++    if (!ensureScanned() || !ensureDemuxer())
+         return false;
+ 
+     QRect prevFrameRect;
+Submodule qtlocation 98a5c511..f991e28c:
+diff --git a/qtlocation/src/location/configure.json b/qtlocation/src/location/configure.json
+index 6d01a9a3..d1e623a1 100644
+--- a/qtlocation/src/location/configure.json
++++ b/qtlocation/src/location/configure.json
+@@ -9,7 +9,7 @@
+             "label": "Qt.labs.location experimental QML plugin",
+             "purpose": "Provides experimental QtLocation QML types",
+             "section": "Location",
+-            "condition": "config.opengl",
++            "condition": "features.opengl",
+             "output": [ "privateFeature" ]
+         },
+         "geoservices_osm": {
+diff --git a/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp b/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
+index a978573d..11e1466f 100644
+--- a/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
++++ b/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
+@@ -158,7 +158,7 @@ void QGeoMapObjectQSGSupport::updateMapObjects(QSGNode *root, QQuickWindow *wind
+     if (!root)
+         return;
+ 
+-    if (m_mapObjectsRootNode && m_mapObjectsRootNode->parent())
++    if (m_mapObjectsRootNode && !m_mapObjectsRootNode->parent())
+         root->appendChildNode(m_mapObjectsRootNode.get());
+ 
+     if (!m_mapObjectsRootNode) {
+diff --git a/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
+index 5a40467e..d123c6a8 100644
+--- a/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
+@@ -59,8 +59,10 @@ QT_BEGIN_NAMESPACE
+ static const QString kPrefixEsri(QStringLiteral("esri."));
+ static const QString kParamUserAgent(kPrefixEsri + QStringLiteral("useragent"));
+ 
+-static const QString kUrlGeocode(QStringLiteral("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates"));
+-static const QString kUrlReverseGeocode(QStringLiteral("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode"));
++static const QString kUrlGeocode(QStringLiteral("https://geocode.arcgis.com/arcgis/rest/services/"
++                                                "World/GeocodeServer/findAddressCandidates"));
++static const QString kUrlReverseGeocode(QStringLiteral(
++        "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode"));
+ 
+ static QString addressToQuery(const QGeoAddress &address)
+ {
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
+index 17492d94..96c12b1b 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
+@@ -46,7 +46,8 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-// JSON reference: http://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
++// JSON reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
+ 
+ static const QString kErrorMessage(QStringLiteral("Error %1: %2."));
+ static const QString kErrorJson(QStringLiteral("Error: invalide JSON document."));
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
+index 8cadfb29..92b6bb13 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
+@@ -44,7 +44,8 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-// JSON reference: http://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
++// JSON reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
+ 
+ GeoRouteReplyEsri::GeoRouteReplyEsri(QNetworkReply *reply, const QGeoRouteRequest &request,
+                                      QObject *parent) :
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
+index 0e6bc2c7..ed613f4b 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
+@@ -48,7 +48,8 @@ static const QString kPrefixEsri(QStringLiteral("esri."));
+ static const QString kParamUserAgent(kPrefixEsri + QStringLiteral("useragent"));
+ static const QString kParamToken(kPrefixEsri + QStringLiteral("token"));
+ 
+-static const QString kUrlRouting(QStringLiteral("http://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve"));
++static const QString kUrlRouting(QStringLiteral(
++        "https://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve"));
+ 
+ GeoRoutingManagerEngineEsri::GeoRoutingManagerEngineEsri(const QVariantMap &parameters,
+                                                          QGeoServiceProvider::Error *error,
+@@ -70,7 +71,8 @@ GeoRoutingManagerEngineEsri::~GeoRoutingManagerEngineEsri()
+ {
+ }
+ 
+-// REST reference: http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
++// REST reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
+ 
+ QGeoRouteReply *GeoRoutingManagerEngineEsri::calculateRoute(const QGeoRouteRequest &request)
+ {
+@@ -125,7 +127,7 @@ void GeoRoutingManagerEngineEsri::replyError(QGeoRouteReply::Error errorCode, co
+ QString GeoRoutingManagerEngineEsri::preferedDirectionLangage()
+ {
+     // list of supported langages is defined in:
+-    // http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
++    // https://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
+     const QStringList supportedLanguages = {
+         "ar", // Generate directions in Arabic
+         "cs", // Generate directions in Czech
+diff --git a/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
+index 5d15835d..24148f95 100644
+--- a/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
+@@ -230,7 +230,8 @@ QGeoMap *GeoTiledMappingManagerEngineEsri::createMap()
+ // ${y} = Y
+ // ${token} = Token
+ 
+-// template = 'http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{{z}}/{{y}}/{{x}}.png'
++// template =
++// 'https://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{{z}}/{{y}}/{{x}}.png'
+ 
+ bool GeoTiledMappingManagerEngineEsri::initializeMapSources(QGeoServiceProvider::Error *error,
+                                                             QString *errorString,
+diff --git a/qtlocation/src/plugins/geoservices/esri/maps.json b/qtlocation/src/plugins/geoservices/esri/maps.json
+index 8167ae7d..862e087d 100644
+--- a/qtlocation/src/plugins/geoservices/esri/maps.json
++++ b/qtlocation/src/plugins/geoservices/esri/maps.json
+@@ -6,8 +6,8 @@
+             "description": "ArcGIS Online World Street Map",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=3b93337983e9436f8db950e38a8629af'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=3b93337983e9436f8db950e38a8629af'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -16,8 +16,8 @@
+             "": "ArcGIS Online World Imagery",
+             "mobile": true,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -26,8 +26,8 @@
+             "description": "ArcGIS Online World Terrain Base",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=c61ad8ab017d49e1a82f580ee1298931'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=c61ad8ab017d49e1a82f580ee1298931'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -36,8 +36,8 @@
+             "description": "ArcGIS Online World Topography",
+             "mobile": true,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=30e5fe3149c34df1ba922e6f5bbf808f'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=30e5fe3149c34df1ba922e6f5bbf808f'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -46,8 +46,8 @@
+             "description": "This map presents land cover and detailed topographic maps for the United States.",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=99cd5fbd98934028802b4f797c4b1732'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=99cd5fbd98934028802b4f797c4b1732'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -56,8 +56,8 @@
+             "description": "National Geographic World Map",
+             "mobile": false,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=b9b1b422198944fbbd5250b3241691b6'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=b9b1b422198944fbbd5250b3241691b6'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -66,8 +66,8 @@
+             "description": "Thematic content providing a neutral background with minimal colors",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=ed712cb1db3e4bae9e85329040fb9a49'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=ed712cb1db3e4bae9e85329040fb9a49'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -76,8 +76,8 @@
+             "description": "Natural Earth physical map for the world",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=c4ec722a1cd34cf0a23904aadf8923a0'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=c4ec722a1cd34cf0a23904aadf8923a0'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -86,8 +86,8 @@
+             "description": "Portrays surface elevation as shaded relief",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=9c5370d0b54f4de1b48a3792d7377ff2'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=9c5370d0b54f4de1b48a3792d7377ff2'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -96,8 +96,8 @@
+             "description": "This map is designed to be used as a basemap by marine GIS professionals and as a reference map by anyone interested in ocean data",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=1e126e7520f9466c9ca28b8f28b5e500'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=1e126e7520f9466c9ca28b8f28b5e500'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -106,8 +106,8 @@
+             "description": "Thematic content providing a neutral background with minimal colors",
+             "mobile": false,
+             "night": true,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=a284a9b99b3446a3910d4144a50990f6'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=a284a9b99b3446a3910d4144a50990f6'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -116,8 +116,8 @@
+             "description": "DeLorme’s topographic basemap is a seamless global data set that portrays transportation, hydrography, jurisdiction boundaries, and major geographic features",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/Specialty/DeLorme_World_Base_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=b165c3df453e4be6b5ac4fdb241effbe'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/Specialty/DeLorme_World_Base_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=b165c3df453e4be6b5ac4fdb241effbe'>Esri</a> contributors"
+         }
+     ]
+ }
+diff --git a/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
+index 3858ddf5..af66f28e 100644
+--- a/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
+@@ -63,8 +63,10 @@ static const QString kCountriesKey(QStringLiteral("detailedCountries"));
+ static const QString kLocalizedNamesKey(QStringLiteral("localizedNames"));
+ static const QString kMaxLocationsKey(QStringLiteral("maxLocations"));
+ 
+-static const QUrl kUrlGeocodeServer("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer?f=pjson");
+-static const QUrl kUrlFindAddressCandidates("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates");
++static const QUrl kUrlGeocodeServer(
++        "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer?f=pjson");
++static const QUrl kUrlFindAddressCandidates("https://geocode.arcgis.com/arcgis/rest/services/World/"
++                                            "GeocodeServer/findAddressCandidates");
+ 
+ PlaceManagerEngineEsri::PlaceManagerEngineEsri(const QVariantMap &parameters, QGeoServiceProvider::Error *error,
+                                                QString *errorString) :
+Submodule qtmultimedia f0344079..0d7cc33a:
+diff --git a/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp b/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
+index 2b5325132..b68b4af1b 100644
+--- a/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
++++ b/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
+@@ -402,6 +402,8 @@ int QPulseAudioInput::bytesReady() const
+ 
+ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ {
++    Q_ASSERT(data != nullptr || len == 0);
++
+     m_bytesAvailable = checkBytesReady();
+ 
+     setError(QAudio::NoError);
+@@ -411,7 +413,8 @@ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ 
+     if (!m_pullMode && !m_tempBuffer.isEmpty()) {
+         readBytes = qMin(static_cast<int>(len), m_tempBuffer.size());
+-        memcpy(data, m_tempBuffer.constData(), readBytes);
++        if (readBytes)
++            memcpy(data, m_tempBuffer.constData(), readBytes);
+         m_totalTimeValue += readBytes;
+ 
+         if (readBytes < m_tempBuffer.size()) {
+@@ -502,9 +505,10 @@ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ 
+ void QPulseAudioInput::applyVolume(const void *src, void *dest, int len)
+ {
++    Q_ASSERT((src && dest) || len == 0);
+     if (m_volume < 1.f)
+         QAudioHelperInternal::qMultiplySamples(m_volume, m_format, src, dest, len);
+-    else
++    else if (len)
+         memcpy(dest, src, len);
+ }
+ 
+Submodule qtpim 02efef5e...f9a8f0fc (commits not present)
+Submodule qtquick3d b85cf622..47defc8b:
+diff --git a/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro b/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
+index ca5c499e..174a075b 100644
+--- a/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
++++ b/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
+@@ -10,7 +10,7 @@ QT_FOR_CONFIG += assetimporters-private
+ include($$OUT_PWD/../qtassetimporters-config.pri)
+ 
+ qtConfig(system-assimp):!if(cross_compile:host_build) {
+-    QMAKE_USE_PRIVATE += assimp
++    QMAKE_USE_PRIVATE += quick3d-assimp
+ } else {
+     include(../../../3rdparty/assimp/assimp.pri)
+ }
+Submodule qtquickcontrols2 3a657dc0..56ce8233:
+diff --git a/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp b/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
+index e5fe734f7..e36922775 100644
+--- a/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
++++ b/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
+@@ -38,6 +38,7 @@
+ #include "qwidgetplatformmenuitem_p.h"
+ 
+ #include <QtGui/qwindow.h>
++#include <QtGui/private/qhighdpiscaling_p.h>
+ #include <QtWidgets/qmenu.h>
+ #include <QtWidgets/qaction.h>
+ 
+@@ -145,7 +146,7 @@ void QWidgetPlatformMenu::showPopup(const QWindow *window, const QRect &targetRe
+ 
+     QPoint targetPos = targetRect.bottomLeft();
+     if (window)
+-        targetPos = window->mapToGlobal(targetPos);
++        targetPos = window->mapToGlobal(QHighDpi::fromNativeLocalPosition(targetPos, window));
+ 
+     const QWidgetPlatformMenuItem *widgetItem = qobject_cast<const QWidgetPlatformMenuItem *>(item);
+     m_menu->popup(targetPos, widgetItem ? widgetItem->action() : nullptr);
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
+index 950e4e099..b81fbea0b 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
+@@ -387,6 +387,17 @@ void QQuickAbstractButtonPrivate::itemImplicitHeightChanged(QQuickItem *item)
+         emit q->implicitIndicatorHeightChanged();
+ }
+ 
++void QQuickAbstractButtonPrivate::itemDestroyed(QQuickItem *item)
++{
++    Q_Q(QQuickAbstractButton);
++    QQuickControlPrivate::itemDestroyed(item);
++    if (item == indicator) {
++        indicator = nullptr;
++        emit q->implicitIndicatorWidthChanged();
++        emit q->implicitIndicatorHeightChanged();
++    }
++}
++
+ QQuickAbstractButton *QQuickAbstractButtonPrivate::findCheckedButton() const
+ {
+     Q_Q(const QQuickAbstractButton);
+@@ -1176,6 +1187,12 @@ QAccessible::Role QQuickAbstractButton::accessibleRole() const
+     }
+     return QAccessible::Button;
+ }
++
++void QQuickAbstractButton::accessiblePressAction()
++{
++    Q_D(QQuickAbstractButton);
++    d->trigger();
++}
+ #endif
+ 
+ QT_END_NAMESPACE
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
+index 0fa48980e..ab66220d0 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
+@@ -209,6 +209,7 @@ protected:
+ #if QT_CONFIG(accessibility)
+     void accessibilityActiveChanged(bool active) override;
+     QAccessible::Role accessibleRole() const override;
++    Q_INVOKABLE void accessiblePressAction();
+ #endif
+ 
+ private:
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
+index 9291c1a87..b729720f2 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
+@@ -109,6 +109,7 @@ public:
+ 
+     void itemImplicitWidthChanged(QQuickItem *item) override;
+     void itemImplicitHeightChanged(QQuickItem *item) override;
++    void itemDestroyed(QQuickItem *item) override;
+ 
+     // copied from qabstractbutton.cpp
+     static const int AUTO_REPEAT_DELAY = 300;
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp b/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
+index 2041e7741..8610cdfae 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
+@@ -145,7 +145,7 @@ int QQuickActionPrivate::ShortcutEntry::shortcutId() const
+ 
+ void QQuickActionPrivate::ShortcutEntry::grab(const QKeySequence &shortcut, bool enabled)
+ {
+-    if (shortcut.isEmpty())
++    if (shortcut.isEmpty() || m_shortcutId)
+         return;
+ 
+     Qt::ShortcutContext context = Qt::WindowShortcut; // TODO
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp b/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
+index f38c2b09c..6eed2a024 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
+@@ -225,6 +225,7 @@ void QQuickContainerPrivate::cleanup()
+     QObject::disconnect(contentModel, &QQmlObjectModel::countChanged, q, &QQuickContainer::countChanged);
+     QObject::disconnect(contentModel, &QQmlObjectModel::childrenChanged, q, &QQuickContainer::contentChildrenChanged);
+     delete contentModel;
++    contentModel = nullptr;
+ }
+ 
+ QQuickItem *QQuickContainerPrivate::itemAt(int index) const
+@@ -436,7 +437,7 @@ void QQuickContainerPrivate::contentChildren_clear(QQmlListProperty<QQuickItem>
+ void QQuickContainerPrivate::updateContentWidth()
+ {
+     Q_Q(QQuickContainer);
+-    if (hasContentWidth || qFuzzyCompare(contentWidth, implicitContentWidth))
++    if (hasContentWidth || qFuzzyCompare(contentWidth, implicitContentWidth) || !contentModel)
+         return;
+ 
+     contentWidth = implicitContentWidth;
+@@ -446,7 +447,7 @@ void QQuickContainerPrivate::updateContentWidth()
+ void QQuickContainerPrivate::updateContentHeight()
+ {
+     Q_Q(QQuickContainer);
+-    if (hasContentHeight || qFuzzyCompare(contentHeight, implicitContentHeight))
++    if (hasContentHeight || qFuzzyCompare(contentHeight, implicitContentHeight) || !contentModel)
+         return;
+ 
+     contentHeight = implicitContentHeight;
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp b/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
+index bbbd0e622..1f4b47343 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
+@@ -845,6 +845,13 @@ void QQuickControlPrivate::executeBackground(bool complete)
+         quickCompleteDeferred(q, backgroundName(), background);
+ }
+ 
++/*
++    \internal
++
++    Hides an item that was replaced by a newer one, rather than
++    deleting it, as the item is typically created in QML and hence
++    we don't own it.
++*/
+ void QQuickControlPrivate::hideOldItem(QQuickItem *item)
+ {
+     if (!item)
+@@ -863,6 +870,29 @@ void QQuickControlPrivate::hideOldItem(QQuickItem *item)
+ #endif
+ }
+ 
++/*
++    \internal
++
++    Named "unhide" because it's used for cases where an item
++    that was previously hidden by \l hideOldItem() wants to be
++    shown by a control again, such as a ScrollBar in ScrollView.
++*/
++void QQuickControlPrivate::unhideOldItem(QQuickControl *control, QQuickItem *item)
++{
++    Q_ASSERT(item);
++    qCDebug(lcItemManagement) << "unhiding old item" << item;
++
++    item->setVisible(true);
++    item->setParentItem(control);
++
++#if QT_CONFIG(accessibility)
++    // Add the item back in to the accessibility tree.
++    QQuickAccessibleAttached *accessible = accessibleAttached(item);
++    if (accessible)
++        accessible->setIgnored(false);
++#endif
++}
++
+ void QQuickControlPrivate::updateBaselineOffset()
+ {
+     Q_Q(QQuickControl);
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h b/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
+index 8e979079e..a6e624c91 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
+@@ -173,6 +173,7 @@ public:
+     virtual void executeBackground(bool complete = false);
+ 
+     static void hideOldItem(QQuickItem *item);
++    static void unhideOldItem(QQuickControl *control, QQuickItem *item);
+ 
+     void updateBaselineOffset();
+ 
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp b/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
+index e6db14eb5..6197d1547 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
+@@ -237,7 +237,7 @@ static QRectF alignedRect(Qt::LayoutDirection direction, Qt::Alignment alignment
+ void QQuickDialogButtonBoxPrivate::resizeContent()
+ {
+     Q_Q(QQuickDialogButtonBox);
+-    if (!contentItem)
++    if (!contentItem || !contentModel)
+         return;
+ 
+     QRectF geometry = q->boundingRect().adjusted(q->leftPadding(), q->topPadding(), -q->rightPadding(), -q->bottomPadding());
+@@ -322,6 +322,9 @@ void QQuickDialogButtonBoxPrivate::updateLayout()
+ qreal QQuickDialogButtonBoxPrivate::getContentWidth() const
+ {
+     Q_Q(const QQuickDialogButtonBox);
++    if (!contentModel)
++        return 0;
++
+     const int count = contentModel->count();
+     const qreal totalSpacing = qMax(0, count - 1) * spacing;
+     qreal totalWidth = totalSpacing;
+@@ -341,6 +344,9 @@ qreal QQuickDialogButtonBoxPrivate::getContentWidth() const
+ qreal QQuickDialogButtonBoxPrivate::getContentHeight() const
+ {
+     Q_Q(const QQuickDialogButtonBox);
++    if (!contentModel)
++        return 0;
++
+     const int count = contentModel->count();
+     qreal maxHeight = 0;
+     for (int i = 0; i < count; ++i) {
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp b/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
+index 91bd59184..0ce518f84 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
+@@ -399,8 +399,11 @@ void QQuickOverlay::itemChange(ItemChange change, const ItemChangeData &data)
+     Q_D(QQuickOverlay);
+     QQuickItem::itemChange(change, data);
+ 
+-    if (change == ItemChildAddedChange || change == ItemChildRemovedChange)
++    if (change == ItemChildAddedChange || change == ItemChildRemovedChange) {
+         setVisible(!d->allDrawers.isEmpty() || !childItems().isEmpty());
++        if (data.item->parent() == d->mouseGrabberPopup)
++            d->setMouseGrabberPopup(nullptr);
++    }
+ }
+ 
+ void QQuickOverlay::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp b/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
+index 4e2f509db..1c4b308cd 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
+@@ -797,6 +797,14 @@ void QQuickScrollBarAttachedPrivate::initHorizontal()
+     if (parent && parent == flickable->parentItem())
+         horizontal->stackAfter(flickable);
+ 
++    // If a scroll bar was previously hidden (due to e.g. setting a new contentItem
++    // on a ScrollView), we need to make sure that we un-hide it.
++    // We don't bother checking if the item is actually the old one, because
++    // if it's not, all of the things the function does (setting parent, visibility, etc.)
++    // should be no-ops anyway.
++    if (auto control = qobject_cast<QQuickControl*>(q_ptr->parent()))
++        QQuickControlPrivate::unhideOldItem(control, horizontal);
++
+     layoutHorizontal();
+     horizontal->setSize(area->property("widthRatio").toReal());
+     horizontal->setPosition(area->property("xPosition").toReal());
+@@ -818,6 +826,9 @@ void QQuickScrollBarAttachedPrivate::initVertical()
+     if (parent && parent == flickable->parentItem())
+         vertical->stackAfter(flickable);
+ 
++    if (auto control = qobject_cast<QQuickControl*>(q_ptr->parent()))
++        QQuickControlPrivate::unhideOldItem(control, vertical);
++
+     layoutVertical();
+     vertical->setSize(area->property("heightRatio").toReal());
+     vertical->setPosition(area->property("yPosition").toReal());
+diff --git a/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml b/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
+index 0e8b08352..cd4931184 100644
+--- a/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
++++ b/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
+@@ -576,4 +576,51 @@ TestCase {
+         verify(newHorizontalScrollBar.visible)
+         verify(!oldHorizontalScrollBar.visible)
+     }
++
++    Component {
++        id: bindingToContentItemAndStandaloneFlickable
++
++        Item {
++            width: 200
++            height: 200
++
++            property alias scrollView: scrollView
++
++            ScrollView {
++                id: scrollView
++                anchors.fill: parent
++                contentItem: listView
++
++                property Item someBinding: contentItem
++            }
++            ListView {
++                id: listView
++                model: 10
++                delegate: ItemDelegate {
++                    text: modelData
++                    width: listView.width
++                }
++            }
++        }
++    }
++
++    // Tests that scroll bars show up for a ScrollView where
++    // - its contentItem is declared as a standalone, separate item
++    // - there is a binding to contentItem (which causes a default Flickable to be created)
++    function test_bindingToContentItemAndStandaloneFlickable() {
++        let root = createTemporaryObject(bindingToContentItemAndStandaloneFlickable, testCase)
++        verify(root)
++
++        let control = root.scrollView
++        let verticalScrollBar = control.ScrollBar.vertical
++        let horizontalScrollBar = control.ScrollBar.horizontal
++        compare(verticalScrollBar.parent, control)
++        compare(horizontalScrollBar.parent, control)
++        verify(verticalScrollBar.visible)
++        verify(horizontalScrollBar.visible)
++
++        mouseDrag(verticalScrollBar, verticalScrollBar.width / 2, verticalScrollBar.height / 2, 0, 50)
++        verify(verticalScrollBar.active)
++        verify(horizontalScrollBar.active)
++    }
+ }
+diff --git a/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml b/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
+index b3fab41ca..10b6baa02 100644
+--- a/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
++++ b/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
+@@ -608,4 +608,27 @@ TestCase {
+         mouseClick(control.indicator)
+         verify(control.activeFocus)
+     }
++
++    Component {
++        id: deletionOrder1
++        Item {
++            Image { id: innerImage }
++            Switch { indicator: innerImage }
++        }
++    }
++
++    Component {
++        id: deletionOrder2
++        Item {
++            Switch { indicator: innerImage }
++            Image { id: innerImage }
++        }
++    }
++
++    function test_deletionOrder() {
++        var control1 = createTemporaryObject(deletionOrder1, testCase)
++        verify(control1)
++        var control2 = createTemporaryObject(deletionOrder2, testCase)
++        verify(control2)
++    }
+ }
+diff --git a/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml b/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml
+new file mode 100644
+index 000000000..9e4598b9f
+--- /dev/null
++++ b/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml
+@@ -0,0 +1,78 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the test suite of the Qt Toolkit.
++**
++** $QT_BEGIN_LICENSE:BSD$
++** Commercial License Usage
++** Licensees holding valid commercial Qt licenses may use this file in
++** accordance with the commercial license agreement provided with the
++** Software or, alternatively, in accordance with the terms contained in
++** a written agreement between you and The Qt Company. For licensing terms
++** and conditions see https://www.qt.io/terms-conditions. For further
++** information use the contact form at https://www.qt.io/contact-us.
++**
++** BSD License Usage
++** Alternatively, you may use this file under the terms of the BSD license
++** as follows:
++**
++** "Redistribution and use in source and binary forms, with or without
++** modification, are permitted provided that the following conditions are
++** met:
++**   * Redistributions of source code must retain the above copyright
++**     notice, this list of conditions and the following disclaimer.
++**   * Redistributions in binary form must reproduce the above copyright
++**     notice, this list of conditions and the following disclaimer in
++**     the documentation and/or other materials provided with the
++**     distribution.
++**   * Neither the name of The Qt Company Ltd nor the names of its
++**     contributors may be used to endorse or promote products derived
++**     from this software without specific prior written permission.
++**
++**
++** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
++** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
++** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
++** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
++** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
++** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
++** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
++** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
++** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
++** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
++** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
++**
++** $QT_END_LICENSE$
++**
++****************************************************************************/
++
++import QtQuick 2.15
++import QtQuick.Controls 2.15
++
++ApplicationWindow {
++    id: window
++    width: 400
++    height: 400
++    title: "releaseAfterExitTransition"
++
++    property alias popup: popup
++    property alias modalPopup: modalPopup
++
++    Popup {
++        id: popup
++        y: parent.height - height
++        width: 50
++        height: 50
++    }
++
++    Popup {
++        id: modalPopup
++        modal: true
++        y: parent.height - height
++        width: 50
++        height: 50
++        exit:  Transition { PauseAnimation { duration: 100 } }
++    }
++}
+diff --git a/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp b/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
+index 54952d128..3d50e2dd4 100644
+--- a/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
++++ b/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
+@@ -100,6 +100,7 @@ private slots:
+     void invisibleToolTipOpen();
+     void centerInOverlayWithinStackViewItem();
+     void destroyDuringExitTransition();
++    void releaseAfterExitTransition();
+ };
+ 
+ void tst_QQuickPopup::initTestCase()
+@@ -1575,6 +1576,34 @@ void tst_QQuickPopup::destroyDuringExitTransition()
+     QVERIFY(!button->isDown());
+ }
+ 
++void tst_QQuickPopup::releaseAfterExitTransition()
++{
++    QQuickApplicationHelper helper(this, "releaseAfterExitTransition.qml");
++    QVERIFY2(helper.ready, helper.failureMessage());
++
++    QQuickWindow *window = helper.window;
++    window->show();
++    QVERIFY(QTest::qWaitForWindowActive(window));
++
++    QQuickOverlay *overlay = QQuickOverlay::overlay(window);
++    QQuickPopup *modalPopup = window->property("modalPopup").value<QQuickPopup *>();
++    QQuickPopup *popup = window->property("popup").value<QQuickPopup *>();
++
++    modalPopup->open();
++    QTRY_VERIFY(modalPopup->isOpened());
++
++    QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++    // wait until the transition is finished and the overlay hides itself
++    QTRY_VERIFY(!overlay->isVisible());
++    QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++
++    popup->open();
++    QTRY_VERIFY(popup->isOpened());
++    QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++    QTRY_VERIFY(!popup->isOpened());
++}
++
++
+ QTEST_QUICKCONTROLS_MAIN(tst_QQuickPopup)
+ 
+ #include "tst_qquickpopup.moc"
+Submodule qtscript 5be95f96...4d8e4bd2 (commits not present)
+Submodule qtspeech 17fc9fde..255845e2:
+diff --git a/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp b/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
+index 6eb74b8..bcc7dd1 100644
+--- a/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
++++ b/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
+@@ -357,7 +357,9 @@ QVector<QLocale> QTextToSpeechEngineSpeechd::availableLocales() const
+ 
+ QVector<QVoice> QTextToSpeechEngineSpeechd::availableVoices() const
+ {
+-    return m_voices.values(m_currentLocale.name()).toVector();
++    QList<QVoice> resultList = m_voices.values(m_currentLocale.name());
++    std::reverse(resultList.begin(), resultList.end());
++    return resultList.toVector();
+ }
+ 
+ // We have no way of knowing our own client_id since speech-dispatcher seems to be incomplete
+Submodule qtsvg 0c05780e..a7a0f249:
+diff --git a/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp b/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
+index 561e77e..12e0574 100644
+--- a/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
++++ b/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
+@@ -191,6 +191,8 @@ bool QSvgIOHandler::read(QImage *image)
+             }
+         }
+         if (!finalSize.isEmpty()) {
++            if (qMax(finalSize.width(), finalSize.height()) > 0xffff)
++                return false; // Assume corrupted file
+             image->fill(d->backColor.rgba());
+             QPainter p(image);
+             d->r.render(&p, bounds);
+diff --git a/qtsvg/src/svg/qsvghandler.cpp b/qtsvg/src/svg/qsvghandler.cpp
+index a5f877f..8dda563 100644
+--- a/qtsvg/src/svg/qsvghandler.cpp
++++ b/qtsvg/src/svg/qsvghandler.cpp
+@@ -1393,9 +1393,10 @@ static void parseFont(QSvgNode *node,
+         case FontSizeNone:
+             break;
+         case FontSizeValue: {
+-            QSvgHandler::LengthType dummy; // should always be pixel size
+-            fontStyle->setSize(qMin(parseLength(attributes.fontSize, dummy, handler),
+-                                    qreal(0xffff)));
++            QSvgHandler::LengthType type;
++            qreal fs = parseLength(attributes.fontSize, type, handler);
++            fs = convertToPixels(fs, true, type);
++            fontStyle->setSize(qMin(fs, qreal(0xffff)));
+         }
+             break;
+         default:
+@@ -2513,6 +2514,8 @@ static bool parseAnimateTransformNode(QSvgNode *parent,
+             ++s;
+         }
+     }
++    if (vals.count() % 3 != 0)
++        return false;
+ 
+     bool ok = true;
+     int begin = parseClockValue(beginStr, &ok);
+@@ -2576,6 +2579,8 @@ static QSvgNode *createCircleNode(QSvgNode *parent,
+     qreal ncx = toDouble(cx);
+     qreal ncy = toDouble(cy);
+     qreal nr  = toDouble(r);
++    if (nr < 0.0)
++        return nullptr;
+ 
+     QRectF rect(ncx-nr, ncy-nr, nr*2, nr*2);
+     QSvgNode *circle = new QSvgCircle(parent, rect);
+@@ -3046,15 +3051,16 @@ static QSvgStyleProperty *createRadialGradientNode(QSvgNode *node,
+ 
+     qreal ncx = 0.5;
+     qreal ncy = 0.5;
+-    qreal nr  = 0.5;
+     if (!cx.isEmpty())
+         ncx = toDouble(cx);
+     if (!cy.isEmpty())
+         ncy = toDouble(cy);
++
++    qreal nr = 0.0;
+     if (!r.isEmpty())
+         nr = toDouble(r);
+-    if (nr < 0.5)
+-        nr = 0.5;
++    if (nr <= 0.0)
++        return nullptr;
+ 
+     qreal nfx = ncx;
+     if (!fx.isEmpty())
+@@ -3350,7 +3356,9 @@ static QSvgNode *createTextNode(QSvgNode *parent,
+     //### editable and rotate not handled
+     QSvgHandler::LengthType type;
+     qreal nx = parseLength(x, type, handler);
++    nx = convertToPixels(nx, true, type);
+     qreal ny = parseLength(y, type, handler);
++    ny = convertToPixels(ny, true, type);
+ 
+     QSvgNode *text = new QSvgText(parent, QPointF(nx, ny));
+     return text;
+@@ -3691,9 +3699,7 @@ void QSvgHandler::parse()
+         case QXmlStreamReader::EndElement:
+             endElement(xml->name());
+             ++remainingUnfinishedElements;
+-            // if we are using somebody else's qxmlstreamreader
+-            // we should not read until the end of the stream
+-            done = !m_ownsReader && (xml->name() == QLatin1String("svg"));
++            done = (xml->name() == QLatin1String("svg"));
+             break;
+         case QXmlStreamReader::Characters:
+             characters(xml->text());
+diff --git a/qtsvg/src/svg/qsvgstructure.cpp b/qtsvg/src/svg/qsvgstructure.cpp
+index b89608b..89c9e4e 100644
+--- a/qtsvg/src/svg/qsvgstructure.cpp
++++ b/qtsvg/src/svg/qsvgstructure.cpp
+@@ -255,9 +255,13 @@ inline static bool isSupportedSvgFeature(const QString &str)
+     };
+ 
+     if (str.length() <= MAX_WORD_LENGTH && str.length() >= MIN_WORD_LENGTH) {
++        const char16_t unicode44 = str.at(44).unicode();
++        const char16_t unicode45 = str.at(45).unicode();
++        if (unicode44 >= sizeof(asso_values) || unicode45 >= sizeof(asso_values))
++            return false;
+         const int key = str.length()
+-                        + asso_values[str.at(45).unicode()]
+-                        + asso_values[str.at(44).unicode()];
++                        + asso_values[unicode45]
++                        + asso_values[unicode44];
+         if (key <= MAX_HASH_VALUE && key >= 0)
+             return str == QLatin1String(wordlist[key]);
+     }
+diff --git a/qtsvg/src/svg/qsvgtinydocument.cpp b/qtsvg/src/svg/qsvgtinydocument.cpp
+index 63d0797..19e7154 100644
+--- a/qtsvg/src/svg/qsvgtinydocument.cpp
++++ b/qtsvg/src/svg/qsvgtinydocument.cpp
+@@ -433,8 +433,16 @@ void QSvgTinyDocument::draw(QPainter *p, QSvgExtraStates &)
+     draw(p);
+ }
+ 
++static bool isValidMatrix(const QTransform &transform)
++{
++    qreal determinant = transform.determinant();
++    return qIsFinite(determinant);
++}
++
+ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect, const QRectF &sourceRect)
+ {
++    QTransform oldTransform = p->worldTransform();
++
+     QRectF target = targetRect;
+     if (target.isEmpty()) {
+         QPaintDevice *dev = p->device();
+@@ -487,6 +495,9 @@ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect,
+         }
+ #endif
+     }
++
++    if (!isValidMatrix(p->worldTransform()))
++        p->setWorldTransform(oldTransform);
+ }
+ 
+ QRectF QSvgTinyDocument::boundsOnElement(const QString &id) const
+diff --git a/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp b/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
+index 36c76ec..db71e02 100644
+--- a/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
++++ b/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
+@@ -86,6 +86,8 @@ private slots:
+     void oss_fuzz_23731();
+     void oss_fuzz_24131();
+     void oss_fuzz_24738();
++    void illegalAnimateTransform_data();
++    void illegalAnimateTransform();
+ 
+ #ifndef QT_NO_COMPRESS
+     void testGzLoading();
+@@ -1646,5 +1648,22 @@ void tst_QSvgRenderer::oss_fuzz_24738()
+     QSvgRenderer().load(QByteArray("<svg><path d=\"a 2 1e-212.....\">"));
+ }
+ 
++void tst_QSvgRenderer::illegalAnimateTransform_data()
++{
++    QTest::addColumn<QByteArray>("svg");
++
++    QTest::newRow("case1") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" values=\"8,0,5,0\">");
++    QTest::newRow("case2") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" values=\"1,2\">");
++    QTest::newRow("case3") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" from=\".. 5 2\" to=\"f\">");
++    QTest::newRow("case4") << QByteArray("<svg><animateTransform type=\"scale\" begin=\"1\" dur=\"2\" by=\"--,..\">");
++}
++
++void tst_QSvgRenderer::illegalAnimateTransform()
++{
++    QFETCH(QByteArray, svg);
++    QSvgRenderer renderer;
++    QVERIFY(!renderer.load(svg)); // also shouldn't assert
++}
++
+ QTEST_MAIN(tst_QSvgRenderer)
+ #include "tst_qsvgrenderer.moc"
+Submodule qttools 6914f7c8..090e526e:
+diff --git a/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp b/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
+index feab1e2d5..cbfb82507 100644
+--- a/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
++++ b/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
+@@ -445,7 +445,9 @@ bool HelpGeneratorPrivate::insertFiles(const QStringList &files, const QString &
+     if (filterSetId < 0)
+         return false;
+     ++filterSetId;
+-    for (int attId : qAsConst(filterAtts)) {
++    QList<int> attValues = filterAtts.values();
++    std::sort(attValues.begin(), attValues.end());
++    for (int attId : qAsConst(attValues)) {
+         m_query->prepare(QLatin1String("INSERT INTO FileAttributeSetTable "
+             "VALUES(?, ?)"));
+         m_query->bindValue(0, filterSetId);
+Submodule qtwayland dfb0129c..2904e1b3:
+diff --git a/qtwayland/src/client/configure.json b/qtwayland/src/client/configure.json
+index 2f424580..29222357 100644
+--- a/qtwayland/src/client/configure.json
++++ b/qtwayland/src/client/configure.json
+@@ -149,8 +149,7 @@
+                     "#endif"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "vulkan-server-buffer": {
+             "label": "Vulkan Buffer Sharing",
+@@ -168,7 +167,8 @@
+                     "exportAllocInfo.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR;",
+                     "return 0;"
+                 ]
+-            }
++            },
++            "use": "wayland-client"
+         },
+         "egl_1_5-wayland": {
+             "label": "EGL 1.5 with Wayland Platform",
+@@ -183,7 +183,7 @@
+                     "eglGetPlatformDisplay(EGL_PLATFORM_WAYLAND_EXT, (struct wl_display *)(nullptr), nullptr);"
+                 ]
+             },
+-            "use": "egl"
++            "use": "egl wayland-client"
+         }
+     },
+ 
+diff --git a/qtwayland/src/client/global/qwaylandclientextension.cpp b/qtwayland/src/client/global/qwaylandclientextension.cpp
+index 125b1e19..edccfe63 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension.cpp
++++ b/qtwayland/src/client/global/qwaylandclientextension.cpp
+@@ -74,7 +74,10 @@ void QWaylandClientExtensionPrivate::handleRegistryGlobal(void *data, ::wl_regis
+ void QWaylandClientExtension::addRegistryListener()
+ {
+     Q_D(QWaylandClientExtension);
+-    d->waylandIntegration->display()->addRegistryListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++    if (!d->registered) {
++        d->waylandIntegration->display()->addRegistryListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++        d->registered = true;
++    }
+ }
+ 
+ QWaylandClientExtension::QWaylandClientExtension(const int ver)
+@@ -88,6 +91,13 @@ QWaylandClientExtension::QWaylandClientExtension(const int ver)
+     QMetaObject::invokeMethod(this, "addRegistryListener", Qt::QueuedConnection);
+ }
+ 
++QWaylandClientExtension::~QWaylandClientExtension()
++{
++    Q_D(QWaylandClientExtension);
++    if (d->registered && !QCoreApplication::closingDown())
++        d->waylandIntegration->display()->removeListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++}
++
+ QtWaylandClient::QWaylandIntegration *QWaylandClientExtension::integration() const
+ {
+     Q_D(const QWaylandClientExtension);
+diff --git a/qtwayland/src/client/global/qwaylandclientextension.h b/qtwayland/src/client/global/qwaylandclientextension.h
+index 98272e57..5bd28398 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension.h
++++ b/qtwayland/src/client/global/qwaylandclientextension.h
+@@ -63,6 +63,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandClientExtension : public QObject
+     Q_PROPERTY(bool active READ isActive NOTIFY activeChanged)
+ public:
+     QWaylandClientExtension(const int version);
++    ~QWaylandClientExtension();
+ 
+     QtWaylandClient::QWaylandIntegration *integration() const;
+     int version() const;
+diff --git a/qtwayland/src/client/global/qwaylandclientextension_p.h b/qtwayland/src/client/global/qwaylandclientextension_p.h
+index 69cc46a0..9091efbe 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension_p.h
++++ b/qtwayland/src/client/global/qwaylandclientextension_p.h
+@@ -68,6 +68,7 @@ public:
+     QtWaylandClient::QWaylandIntegration *waylandIntegration = nullptr;
+     int version = -1;
+     bool active = false;
++    bool registered = false;
+ };
+ 
+ class Q_WAYLAND_CLIENT_EXPORT QWaylandClientExtensionTemplatePrivate : public QWaylandClientExtensionPrivate
+diff --git a/qtwayland/src/client/qwaylanddatadevice.cpp b/qtwayland/src/client/qwaylanddatadevice.cpp
+index 7e2e3308..e3e60ed5 100644
+--- a/qtwayland/src/client/qwaylanddatadevice.cpp
++++ b/qtwayland/src/client/qwaylanddatadevice.cpp
+@@ -72,6 +72,8 @@ QWaylandDataDevice::QWaylandDataDevice(QWaylandDataDeviceManager *manager, QWayl
+ 
+ QWaylandDataDevice::~QWaylandDataDevice()
+ {
++    if (wl_data_device_get_version(object()) >= WL_DATA_DEVICE_RELEASE_SINCE_VERSION)
++        release();
+ }
+ 
+ QWaylandDataOffer *QWaylandDataDevice::selectionOffer() const
+@@ -110,7 +112,7 @@ QWaylandDataOffer *QWaylandDataDevice::dragOffer() const
+     return m_dragOffer.data();
+ }
+ 
+-bool QWaylandDataDevice::startDrag(QMimeData *mimeData, QWaylandWindow *icon)
++bool QWaylandDataDevice::startDrag(QMimeData *mimeData, Qt::DropActions supportedActions, QWaylandWindow *icon)
+ {
+     auto *seat = m_display->currentInputDevice();
+     auto *origin = seat->pointerFocus();
+@@ -123,7 +125,28 @@ bool QWaylandDataDevice::startDrag(QMimeData *mimeData, QWaylandWindow *icon)
+     }
+ 
+     m_dragSource.reset(new QWaylandDataSource(m_display->dndSelectionHandler(), mimeData));
++
++    if (wl_data_device_get_version(object()) >= 3)
++        m_dragSource->set_actions(dropActionsToWl(supportedActions));
++
+     connect(m_dragSource.data(), &QWaylandDataSource::cancelled, this, &QWaylandDataDevice::dragSourceCancelled);
++    connect(m_dragSource.data(), &QWaylandDataSource::dndResponseUpdated, this, [this](bool accepted, Qt::DropAction action) {
++            auto drag = static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag());
++            // in old versions drop action is not set, so we guess
++            if (wl_data_source_get_version(m_dragSource->object()) < 3) {
++                drag->setResponse(accepted);
++            } else {
++                QPlatformDropQtResponse response(accepted, action);
++                drag->setResponse(response);
++            }
++    });
++    connect(m_dragSource.data(), &QWaylandDataSource::dndDropped, this, [](bool accepted, Qt::DropAction action) {
++        QPlatformDropQtResponse response(accepted, action);
++        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setDropResponse(response);
++    });
++    connect(m_dragSource.data(), &QWaylandDataSource::finished, this, []() {
++        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag();
++    });
+ 
+     start_drag(m_dragSource->object(), origin->wlSurface(), icon->wlSurface(), m_display->currentInputDevice()->serial());
+     return true;
+@@ -152,7 +175,7 @@ void QWaylandDataDevice::data_device_drop()
+         supportedActions = drag->supportedActions();
+     } else if (m_dragOffer) {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     } else {
+         return;
+     }
+@@ -162,7 +185,11 @@ void QWaylandDataDevice::data_device_drop()
+                                                                           QGuiApplication::keyboardModifiers());
+ 
+     if (drag) {
+-        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag(response);
++        auto drag =  static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag());
++        drag->setDropResponse(response);
++        drag->finishDrag();
++    } else if (m_dragOffer) {
++        m_dragOffer->finish();
+     }
+ }
+ 
+@@ -186,7 +213,7 @@ void QWaylandDataDevice::data_device_enter(uint32_t serial, wl_surface *surface,
+         supportedActions = drag->supportedActions();
+     } else if (m_dragOffer) {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     }
+ 
+     const QPlatformDragQtResponse &response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
+@@ -197,11 +224,7 @@ void QWaylandDataDevice::data_device_enter(uint32_t serial, wl_surface *surface,
+         static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setResponse(response);
+     }
+ 
+-    if (response.isAccepted()) {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, m_dragOffer->firstFormat().toUtf8().constData());
+-    } else {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, nullptr);
+-    }
++    sendResponse(supportedActions, response);
+ }
+ 
+ void QWaylandDataDevice::data_device_leave()
+@@ -235,10 +258,10 @@ void QWaylandDataDevice::data_device_motion(uint32_t time, wl_fixed_t x, wl_fixe
+         supportedActions = drag->supportedActions();
+     } else {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     }
+ 
+-    QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
++    const QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
+                                                                           QGuiApplication::mouseButtons(),
+                                                                           QGuiApplication::keyboardModifiers());
+ 
+@@ -246,11 +269,7 @@ void QWaylandDataDevice::data_device_motion(uint32_t time, wl_fixed_t x, wl_fixe
+         static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setResponse(response);
+     }
+ 
+-    if (response.isAccepted()) {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, m_dragOffer->firstFormat().toUtf8().constData());
+-    } else {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, nullptr);
+-    }
++    sendResponse(supportedActions, response);
+ }
+ #endif // QT_CONFIG(draganddrop)
+ 
+@@ -277,14 +296,10 @@ void QWaylandDataDevice::selectionSourceCancelled()
+ #if QT_CONFIG(draganddrop)
+ void QWaylandDataDevice::dragSourceCancelled()
+ {
++    static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag();
+     m_dragSource.reset();
+ }
+ 
+-void QWaylandDataDevice::dragSourceTargetChanged(const QString &mimeType)
+-{
+-    static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->updateTarget(mimeType);
+-}
+-
+ QPoint QWaylandDataDevice::calculateDragPosition(int x, int y, QWindow *wnd) const
+ {
+     QPoint pnt(wl_fixed_to_int(x), wl_fixed_to_int(y));
+@@ -297,6 +312,33 @@ QPoint QWaylandDataDevice::calculateDragPosition(int x, int y, QWindow *wnd) con
+     }
+     return pnt;
+ }
++
++void QWaylandDataDevice::sendResponse(Qt::DropActions supportedActions, const QPlatformDragQtResponse &response)
++{
++    if (response.isAccepted()) {
++        if (wl_data_device_get_version(object()) >= 3)
++            m_dragOffer->set_actions(dropActionsToWl(supportedActions), dropActionsToWl(response.acceptedAction()));
++
++        m_dragOffer->accept(m_enterSerial, m_dragOffer->firstFormat());
++    } else {
++        m_dragOffer->accept(m_enterSerial, QString());
++    }
++}
++
++int QWaylandDataDevice::dropActionsToWl(Qt::DropActions actions)
++{
++
++    int wlActions = WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE;
++    if (actions & Qt::CopyAction)
++        wlActions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY;
++    if (actions & (Qt::MoveAction | Qt::TargetMoveAction))
++        wlActions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE;
++
++    // wayland does not support LinkAction at the time of writing
++    return wlActions;
++}
++
++
+ #endif // QT_CONFIG(draganddrop)
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddatadevice_p.h b/qtwayland/src/client/qwaylanddatadevice_p.h
+index 16c3ad28..801dcc2c 100644
+--- a/qtwayland/src/client/qwaylanddatadevice_p.h
++++ b/qtwayland/src/client/qwaylanddatadevice_p.h
+@@ -64,6 +64,7 @@ QT_REQUIRE_CONFIG(wayland_datadevice);
+ QT_BEGIN_NAMESPACE
+ 
+ class QMimeData;
++class QPlatformDragQtResponse;
+ class QWindow;
+ 
+ namespace QtWaylandClient {
+@@ -89,7 +90,7 @@ public:
+ 
+ #if QT_CONFIG(draganddrop)
+     QWaylandDataOffer *dragOffer() const;
+-    bool startDrag(QMimeData *mimeData, QWaylandWindow *icon);
++    bool startDrag(QMimeData *mimeData, Qt::DropActions supportedActions, QWaylandWindow *icon);
+     void cancelDrag();
+ #endif
+ 
+@@ -109,13 +110,16 @@ private Q_SLOTS:
+ 
+ #if QT_CONFIG(draganddrop)
+     void dragSourceCancelled();
+-    void dragSourceTargetChanged(const QString &mimeType);
+ #endif
+ 
+ private:
+ #if QT_CONFIG(draganddrop)
+     QPoint calculateDragPosition(int x, int y, QWindow *wnd) const;
+ #endif
++    void sendResponse(Qt::DropActions supportedActions, const QPlatformDragQtResponse &response);
++
++    static int dropActionsToWl(Qt::DropActions dropActions);
++
+ 
+     QWaylandDisplay *m_display = nullptr;
+     QWaylandInputDevice *m_inputDevice = nullptr;
+diff --git a/qtwayland/src/client/qwaylanddatadevicemanager.cpp b/qtwayland/src/client/qwaylanddatadevicemanager.cpp
+index 35d67307..6dc4f77f 100644
+--- a/qtwayland/src/client/qwaylanddatadevicemanager.cpp
++++ b/qtwayland/src/client/qwaylanddatadevicemanager.cpp
+@@ -50,8 +50,8 @@ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
+-QWaylandDataDeviceManager::QWaylandDataDeviceManager(QWaylandDisplay *display, uint32_t id)
+-    : wl_data_device_manager(display->wl_registry(), id, 1)
++QWaylandDataDeviceManager::QWaylandDataDeviceManager(QWaylandDisplay *display, int version, uint32_t id)
++    : wl_data_device_manager(display->wl_registry(), id, qMin(version, 3))
+     , m_display(display)
+ {
+     // Create transfer devices for all input devices.
+diff --git a/qtwayland/src/client/qwaylanddatadevicemanager_p.h b/qtwayland/src/client/qwaylanddatadevicemanager_p.h
+index bd05c0fb..510d9be4 100644
+--- a/qtwayland/src/client/qwaylanddatadevicemanager_p.h
++++ b/qtwayland/src/client/qwaylanddatadevicemanager_p.h
+@@ -68,7 +68,7 @@ class QWaylandInputDevice;
+ class Q_WAYLAND_CLIENT_EXPORT QWaylandDataDeviceManager : public QtWayland::wl_data_device_manager
+ {
+ public:
+-    QWaylandDataDeviceManager(QWaylandDisplay *display, uint32_t id);
++    QWaylandDataDeviceManager(QWaylandDisplay *display, int version, uint32_t id);
+     ~QWaylandDataDeviceManager() override;
+ 
+     QWaylandDataDevice *getDataDevice(QWaylandInputDevice *inputDevice);
+diff --git a/qtwayland/src/client/qwaylanddataoffer.cpp b/qtwayland/src/client/qwaylanddataoffer.cpp
+index 2297e8a1..fe0ea8c9 100644
+--- a/qtwayland/src/client/qwaylanddataoffer.cpp
++++ b/qtwayland/src/client/qwaylanddataoffer.cpp
+@@ -82,6 +82,15 @@ QMimeData *QWaylandDataOffer::mimeData()
+     return m_mimeData.data();
+ }
+ 
++Qt::DropActions QWaylandDataOffer::supportedActions() const
++{
++    if (wl_data_offer_get_version(const_cast<::wl_data_offer*>(object())) < 3) {
++        return Qt::MoveAction | Qt::CopyAction;
++    }
++
++    return m_supportedActions;
++}
++
+ void QWaylandDataOffer::startReceiving(const QString &mimeType, int fd)
+ {
+     receive(mimeType, fd);
+@@ -93,6 +102,22 @@ void QWaylandDataOffer::data_offer_offer(const QString &mime_type)
+     m_mimeData->appendFormat(mime_type);
+ }
+ 
++void QWaylandDataOffer::data_offer_action(uint32_t dnd_action)
++{
++    Q_UNUSED(dnd_action);
++    // This is the compositor telling the drag target what action it should perform
++    // It does not map nicely into Qt final drop semantics, other than pretending there is only one supported action?
++}
++
++void QWaylandDataOffer::data_offer_source_actions(uint32_t source_actions)
++{
++    m_supportedActions = Qt::DropActions();
++    if (source_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
++        m_supportedActions |= Qt::MoveAction;
++    if (source_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
++        m_supportedActions |= Qt::CopyAction;
++}
++
+ QWaylandMimeData::QWaylandMimeData(QWaylandAbstractDataOffer *dataOffer)
+     : m_dataOffer(dataOffer)
+ {
+@@ -163,17 +188,18 @@ QVariant QWaylandMimeData::retrieveData_sys(const QString &mimeType, QVariant::T
+ 
+ int QWaylandMimeData::readData(int fd, QByteArray &data) const
+ {
+-    fd_set readset;
+-    FD_ZERO(&readset);
+-    FD_SET(fd, &readset);
+-    struct timeval timeout;
++    struct pollfd readset;
++    readset.fd = fd;
++    readset.events = POLLIN;
++    struct timespec timeout;
+     timeout.tv_sec = 1;
+-    timeout.tv_usec = 0;
++    timeout.tv_nsec = 0;
++
+ 
+     Q_FOREVER {
+-        int ready = select(FD_SETSIZE, &readset, nullptr, nullptr, &timeout);
++        int ready = qt_safe_poll(&readset, 1, &timeout);
+         if (ready < 0) {
+-            qWarning() << "QWaylandDataOffer: select() failed";
++            qWarning() << "QWaylandDataOffer: qt_safe_poll() failed";
+             return -1;
+         } else if (ready == 0) {
+             qWarning("QWaylandDataOffer: timeout reading from pipe");
+diff --git a/qtwayland/src/client/qwaylanddataoffer_p.h b/qtwayland/src/client/qwaylanddataoffer_p.h
+index 9cf1483c..6f667398 100644
+--- a/qtwayland/src/client/qwaylanddataoffer_p.h
++++ b/qtwayland/src/client/qwaylanddataoffer_p.h
+@@ -82,6 +82,7 @@ public:
+     explicit QWaylandDataOffer(QWaylandDisplay *display, struct ::wl_data_offer *offer);
+     ~QWaylandDataOffer() override;
+     QMimeData *mimeData() override;
++    Qt::DropActions supportedActions() const;
+ 
+     QString firstFormat() const;
+ 
+@@ -89,10 +90,13 @@ public:
+ 
+ protected:
+     void data_offer_offer(const QString &mime_type) override;
++    void data_offer_source_actions(uint32_t source_actions) override;
++    void data_offer_action(uint32_t dnd_action) override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+     QScopedPointer<QWaylandMimeData> m_mimeData;
++    Qt::DropActions m_supportedActions;
+ };
+ 
+ 
+diff --git a/qtwayland/src/client/qwaylanddatasource.cpp b/qtwayland/src/client/qwaylanddatasource.cpp
+index f45122fb..5599cbd4 100644
+--- a/qtwayland/src/client/qwaylanddatasource.cpp
++++ b/qtwayland/src/client/qwaylanddatasource.cpp
+@@ -101,7 +101,32 @@ void QWaylandDataSource::data_source_send(const QString &mime_type, int32_t fd)
+ 
+ void QWaylandDataSource::data_source_target(const QString &mime_type)
+ {
+-    Q_EMIT targetChanged(mime_type);
++    m_accepted = !mime_type.isEmpty();
++    Q_EMIT dndResponseUpdated(m_accepted, m_dropAction);
++}
++
++void QWaylandDataSource::data_source_action(uint32_t action)
++{
++    Qt::DropAction qtAction = Qt::IgnoreAction;
++
++    if (action == WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
++        qtAction = Qt::MoveAction;
++    else if (action == WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
++        qtAction = Qt::CopyAction;
++
++    m_dropAction = qtAction;
++    Q_EMIT dndResponseUpdated(m_accepted, m_dropAction);
++}
++
++void QWaylandDataSource::data_source_dnd_finished()
++{
++    Q_EMIT finished();
++}
++
++void QWaylandDataSource::data_source_dnd_drop_performed()
++{
++
++    Q_EMIT dndDropped(m_accepted, m_dropAction);
+ }
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddatasource_p.h b/qtwayland/src/client/qwaylanddatasource_p.h
+index 25afff79..96f07bc3 100644
+--- a/qtwayland/src/client/qwaylanddatasource_p.h
++++ b/qtwayland/src/client/qwaylanddatasource_p.h
+@@ -77,17 +77,25 @@ public:
+     QMimeData *mimeData() const;
+ 
+ Q_SIGNALS:
+-    void targetChanged(const QString &mime_type);
+     void cancelled();
++    void finished();
++
++    void dndResponseUpdated(bool accepted, Qt::DropAction action);
++    void dndDropped(bool accepted, Qt::DropAction action);
+ 
+ protected:
+     void data_source_cancelled() override;
+     void data_source_send(const QString &mime_type, int32_t fd) override;
+     void data_source_target(const QString &mime_type) override;
++    void data_source_dnd_drop_performed() override;
++    void data_source_dnd_finished() override;
++    void data_source_action(uint32_t action) override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+     QMimeData *m_mime_data = nullptr;
++    bool m_accepted = false;
++    Qt::DropAction m_dropAction = Qt::IgnoreAction;
+ };
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddisplay.cpp b/qtwayland/src/client/qwaylanddisplay.cpp
+index f10c1f79..c01e238b 100644
+--- a/qtwayland/src/client/qwaylanddisplay.cpp
++++ b/qtwayland/src/client/qwaylanddisplay.cpp
+@@ -85,10 +85,203 @@
+ 
+ #include <errno.h>
+ 
++#include <tuple> // for std::tie
++
++static void checkWaylandError(struct wl_display *display)
++{
++    int ecode = wl_display_get_error(display);
++    if ((ecode == EPIPE || ecode == ECONNRESET)) {
++        // special case this to provide a nicer error
++        qWarning("The Wayland connection broke. Did the Wayland compositor die?");
++    } else {
++        qWarning("The Wayland connection experienced a fatal error: %s", strerror(ecode));
++    }
++    _exit(1);
++}
++
+ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
++class EventThread : public QThread
++{
++    Q_OBJECT
++public:
++    enum OperatingMode {
++        EmitToDispatch, // Emit the signal, allow dispatching in a differnt thread.
++        SelfDispatch, // Dispatch the events inside this thread.
++    };
++
++    EventThread(struct wl_display * wl, struct wl_event_queue * ev_queue,
++                OperatingMode mode)
++        : m_fd(wl_display_get_fd(wl))
++        , m_pipefd{ -1, -1 }
++        , m_wldisplay(wl)
++        , m_wlevqueue(ev_queue)
++        , m_mode(mode)
++        , m_reading(true)
++        , m_quitting(false)
++    {
++        setObjectName(QStringLiteral("WaylandEventThread"));
++    }
++
++    void readAndDispatchEvents()
++    {
++        /*
++         * Dispatch pending events and flush the requests at least once. If the event thread
++         * is not reading, try to call _prepare_read() to allow the event thread to poll().
++         * If that fails, re-try dispatch & flush again until _prepare_read() is successful.
++         *
++         * This allow any call to readAndDispatchEvents() to start event thread's polling,
++         * not only the one issued from event thread's waitForReading(), which means functions
++         * called from dispatch_pending() can safely spin an event loop.
++         */
++        for (;;) {
++            if (dispatchQueuePending() < 0) {
++                checkWaylandError(m_wldisplay);
++                return;
++            }
++
++            wl_display_flush(m_wldisplay);
++
++            // We have to check if event thread is reading every time we dispatch
++            // something, as that may recursively call this function.
++            if (m_reading.loadAcquire())
++                break;
++
++            if (prepareReadQueue() == 0) {
++                QMutexLocker l(&m_mutex);
++                m_reading.storeRelease(true);
++                m_cond.wakeOne();
++                break;
++            }
++        }
++    }
++
++    void stop()
++    {
++        // We have to both write to the pipe and set the flag, as the thread may be
++        // either in the poll() or waiting for _prepare_read().
++        if (m_pipefd[1] != -1 && write(m_pipefd[1], "\0", 1) == -1)
++            qWarning("Failed to write to the pipe: %s.", strerror(errno));
++
++        {
++            QMutexLocker l(&m_mutex);
++            m_quitting = true;
++            m_cond.wakeOne();
++        }
++
++        wait();
++    }
++
++Q_SIGNALS:
++    void needReadAndDispatch();
++
++protected:
++    void run() override
++    {
++        // we use this pipe to make the loop exit otherwise if we simply used a flag on the loop condition, if stop() gets
++        // called while poll() is blocking the thread will never quit since there are no wayland messages coming anymore.
++        struct Pipe
++        {
++            Pipe(int *fds)
++                : fds(fds)
++            {
++                if (qt_safe_pipe(fds) != 0)
++                    qWarning("Pipe creation failed. Quitting may hang.");
++            }
++            ~Pipe()
++            {
++                if (fds[0] != -1) {
++                    close(fds[0]);
++                    close(fds[1]);
++                }
++            }
++
++            int *fds;
++        } pipe(m_pipefd);
++
++        // Make the main thread call wl_prepare_read(), dispatch the pending messages and flush the
++        // outbound ones. Wait until it's done before proceeding, unless we're told to quit.
++        while (waitForReading()) {
++            pollfd fds[2] = { { m_fd, POLLIN, 0 }, { m_pipefd[0], POLLIN, 0 } };
++            poll(fds, 2, -1);
++
++            if (fds[1].revents & POLLIN) {
++                // we don't really care to read the byte that was written here since we're closing down
++                wl_display_cancel_read(m_wldisplay);
++                break;
++            }
++
++            if (fds[0].revents & POLLIN)
++                wl_display_read_events(m_wldisplay);
++                // The polll was succesfull and the event thread did the wl_display_read_events(). On the next iteration of the loop
++                // the event sent to the main thread will cause it to dispatch the messages just read, unless the loop exits in which
++                // case we don't care anymore about them.
++            else
++                wl_display_cancel_read(m_wldisplay);
++        }
++    }
++
++private:
++    bool waitForReading()
++    {
++        Q_ASSERT(QThread::currentThread() == this);
++
++        m_reading.storeRelease(false);
++
++        if (m_mode == SelfDispatch) {
++            readAndDispatchEvents();
++        } else {
++            Q_EMIT needReadAndDispatch();
++
++            QMutexLocker lock(&m_mutex);
++            // m_reading might be set from our emit or some other invocation of
++            // readAndDispatchEvents().
++            while (!m_reading.loadRelaxed() && !m_quitting)
++                m_cond.wait(&m_mutex);
++        }
++
++        return !m_quitting;
++    }
++
++    int dispatchQueuePending()
++    {
++        if (m_wlevqueue)
++            return wl_display_dispatch_queue_pending(m_wldisplay, m_wlevqueue);
++        else
++            return wl_display_dispatch_pending(m_wldisplay);
++    }
++
++    int prepareReadQueue()
++    {
++        if (m_wlevqueue)
++            return wl_display_prepare_read_queue(m_wldisplay, m_wlevqueue);
++        else
++            return wl_display_prepare_read(m_wldisplay);
++    }
++
++    int m_fd;
++    int m_pipefd[2];
++    wl_display *m_wldisplay;
++    wl_event_queue *m_wlevqueue;
++    OperatingMode m_mode;
++
++    /* Concurrency note when operating in EmitToDispatch mode:
++     * m_reading is set to false inside event thread's waitForReading(), and is
++     * set to true inside main thread's readAndDispatchEvents().
++     * The lock is not taken when setting m_reading to false, as the main thread
++     * is not actively waiting for it to turn false. However, the lock is taken
++     * inside readAndDispatchEvents() before setting m_reading to true,
++     * as the event thread is actively waiting for it under the wait condition.
++     */
++
++    QAtomicInteger<bool> m_reading;
++    bool m_quitting;
++    QMutex m_mutex;
++    QWaitCondition m_cond;
++};
++
+ Q_LOGGING_CATEGORY(lcQpaWayland, "qt.qpa.wayland"); // for general (uncategorized) Wayland platform logging
+ 
+ struct wl_surface *QWaylandDisplay::createSurface(void *handle)
+@@ -158,17 +351,16 @@ QWaylandDisplay::QWaylandDisplay(QWaylandIntegration *waylandIntegration)
+     if (!mXkbContext)
+         qCWarning(lcQpaWayland, "failed to create xkb context");
+ #endif
+-
+-    forceRoundTrip();
+-
+-    if (!mWaitingScreens.isEmpty()) {
+-        // Give wl_output.done and zxdg_output_v1.done events a chance to arrive
+-        forceRoundTrip();
+-    }
+ }
+ 
+ QWaylandDisplay::~QWaylandDisplay(void)
+ {
++    if (m_eventThread)
++        m_eventThread->stop();
++
++    if (m_frameEventQueueThread)
++        m_frameEventQueueThread->stop();
++
+     if (mSyncCallback)
+         wl_callback_destroy(mSyncCallback);
+ 
+@@ -187,6 +379,21 @@ QWaylandDisplay::~QWaylandDisplay(void)
+ #endif
+     if (mDisplay)
+         wl_display_disconnect(mDisplay);
++
++    if (m_frameEventQueue)
++        wl_event_queue_destroy(m_frameEventQueue);
++}
++
++// Steps which is called just after constructor. This separates registry_global() out of the constructor
++// so that factory functions in integration can be overridden.
++void QWaylandDisplay::initialize()
++{
++    forceRoundTrip();
++
++    if (!mWaitingScreens.isEmpty()) {
++        // Give wl_output.done and zxdg_output_v1.done events a chance to arrive
++        forceRoundTrip();
++    }
+ }
+ 
+ void QWaylandDisplay::ensureScreen()
+@@ -203,98 +410,37 @@ void QWaylandDisplay::ensureScreen()
+ 
+ void QWaylandDisplay::checkError() const
+ {
+-    int ecode = wl_display_get_error(mDisplay);
+-    if ((ecode == EPIPE || ecode == ECONNRESET)) {
+-        // special case this to provide a nicer error
+-        qWarning("The Wayland connection broke. Did the Wayland compositor die?");
+-    } else {
+-        qWarning("The Wayland connection experienced a fatal error: %s", strerror(ecode));
+-    }
+-    _exit(1);
++    checkWaylandError(mDisplay);
+ }
+ 
++// Called in main thread, either from queued signal or directly.
+ void QWaylandDisplay::flushRequests()
+ {
+-    if (wl_display_prepare_read(mDisplay) == 0) {
+-        wl_display_read_events(mDisplay);
+-    }
+-
+-    if (wl_display_dispatch_pending(mDisplay) < 0)
+-        checkError();
+-
+-    {
+-        QReadLocker locker(&m_frameQueueLock);
+-        for (const FrameQueue &q : mExternalQueues) {
+-            QMutexLocker locker(q.mutex);
+-            while (wl_display_prepare_read_queue(mDisplay, q.queue) != 0)
+-                wl_display_dispatch_queue_pending(mDisplay, q.queue);
+-            wl_display_read_events(mDisplay);
+-            wl_display_dispatch_queue_pending(mDisplay, q.queue);
+-        }
+-    }
+-
+-    wl_display_flush(mDisplay);
+-}
+-
+-void QWaylandDisplay::blockingReadEvents()
+-{
+-    if (wl_display_dispatch(mDisplay) < 0)
+-        checkError();
+-}
+-
+-void QWaylandDisplay::destroyFrameQueue(const QWaylandDisplay::FrameQueue &q)
+-{
+-    QWriteLocker locker(&m_frameQueueLock);
+-    auto it = std::find_if(mExternalQueues.begin(),
+-                           mExternalQueues.end(),
+-                           [&q] (const QWaylandDisplay::FrameQueue &other){ return other.queue == q.queue; });
+-    Q_ASSERT(it != mExternalQueues.end());
+-    mExternalQueues.erase(it);
+-    if (q.queue != nullptr)
+-        wl_event_queue_destroy(q.queue);
+-    delete q.mutex;
++    m_eventThread->readAndDispatchEvents();
+ }
+ 
+-QWaylandDisplay::FrameQueue QWaylandDisplay::createFrameQueue()
++// We have to wait until we have an eventDispatcher before creating the eventThread,
++// otherwise forceRoundTrip() may block inside _events_read() because eventThread is
++// polling.
++void QWaylandDisplay::initEventThread()
+ {
+-    QWriteLocker locker(&m_frameQueueLock);
+-    FrameQueue q{createEventQueue()};
+-    mExternalQueues.append(q);
+-    return q;
+-}
++    m_eventThread.reset(
++            new EventThread(mDisplay, /* default queue */ nullptr, EventThread::EmitToDispatch));
++    connect(m_eventThread.get(), &EventThread::needReadAndDispatch, this,
++            &QWaylandDisplay::flushRequests, Qt::QueuedConnection);
++    m_eventThread->start();
+ 
+-wl_event_queue *QWaylandDisplay::createEventQueue()
+-{
+-    return wl_display_create_queue(mDisplay);
++    // wl_display_disconnect() free this.
++    m_frameEventQueue = wl_display_create_queue(mDisplay);
++    m_frameEventQueueThread.reset(
++            new EventThread(mDisplay, m_frameEventQueue, EventThread::SelfDispatch));
++    m_frameEventQueueThread->start();
+ }
+ 
+-void QWaylandDisplay::dispatchQueueWhile(wl_event_queue *queue, std::function<bool ()> condition, int timeout)
++void QWaylandDisplay::blockingReadEvents()
+ {
+-    if (!condition())
+-        return;
+-
+-    QElapsedTimer timer;
+-    timer.start();
+-    struct pollfd pFd = qt_make_pollfd(wl_display_get_fd(mDisplay), POLLIN);
+-    while (timeout == -1 || timer.elapsed() < timeout) {
+-        while (wl_display_prepare_read_queue(mDisplay, queue) != 0)
+-            wl_display_dispatch_queue_pending(mDisplay, queue);
+-
+-        wl_display_flush(mDisplay);
+-
+-        const int remaining = qMax(timeout - timer.elapsed(), 0ll);
+-        const int pollTimeout = timeout == -1 ? -1 : remaining;
+-        if (qt_poll_msecs(&pFd, 1, pollTimeout) > 0)
+-            wl_display_read_events(mDisplay);
+-        else
+-            wl_display_cancel_read(mDisplay);
+-
+-        if (wl_display_dispatch_queue_pending(mDisplay, queue) < 0)
+-            checkError();
+-
+-        if (!condition())
+-            break;
+-    }
++    if (wl_display_dispatch(mDisplay) < 0)
++        checkWaylandError(mDisplay);
+ }
+ 
+ QWaylandScreen *QWaylandDisplay::screenForOutput(struct wl_output *output) const
+@@ -345,7 +491,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+     if (interface == QStringLiteral("wl_output")) {
+         mWaitingScreens << new QWaylandScreen(this, version, id);
+     } else if (interface == QStringLiteral("wl_compositor")) {
+-        mCompositorVersion = qMin((int)version, 3);
++        mCompositorVersion = qMin((int)version, 4);
+         mCompositor.init(registry, id, mCompositorVersion);
+     } else if (interface == QStringLiteral("wl_shm")) {
+         mShm.reset(new QWaylandShm(this, version, id));
+@@ -354,7 +500,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+         mInputDevices.append(inputDevice);
+ #if QT_CONFIG(wayland_datadevice)
+     } else if (interface == QStringLiteral("wl_data_device_manager")) {
+-        mDndSelectionHandler.reset(new QWaylandDataDeviceManager(this, id));
++        mDndSelectionHandler.reset(new QWaylandDataDeviceManager(this, version, id));
+ #endif
+     } else if (interface == QStringLiteral("qt_surface_extension")) {
+         mWindowExtension.reset(new QtWayland::qt_surface_extension(registry, id, 1));
+@@ -369,6 +515,8 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+ #if QT_CONFIG(wayland_client_primary_selection)
+     } else if (interface == QStringLiteral("zwp_primary_selection_device_manager_v1")) {
+         mPrimarySelectionManager.reset(new QWaylandPrimarySelectionDeviceManagerV1(this, id, 1));
++        for (QWaylandInputDevice *inputDevice : qAsConst(mInputDevices))
++            inputDevice->setPrimarySelectionDevice(mPrimarySelectionManager->createDevice(inputDevice));
+ #endif
+     } else if (interface == QStringLiteral("zwp_text_input_manager_v2") && !mClientSideInputContextRequested) {
+         mTextInputManager.reset(new QtWayland::zwp_text_input_manager_v2(registry, id, 1));
+@@ -427,6 +575,13 @@ void QWaylandDisplay::registry_global_remove(uint32_t id)
+                     inputDevice->setTextInput(nullptr);
+                 mWaylandIntegration->reconfigureInputContext();
+             }
++#if QT_CONFIG(wayland_client_primary_selection)
++            if (global.interface == QStringLiteral("zwp_primary_selection_device_manager_v1")) {
++                mPrimarySelectionManager.reset();
++                for (QWaylandInputDevice *inputDevice : qAsConst(mInputDevices))
++                    inputDevice->setPrimarySelectionDevice(nullptr);
++            }
++#endif
+             mGlobals.removeAt(i);
+             break;
+         }
+@@ -452,9 +607,10 @@ void QWaylandDisplay::addRegistryListener(RegistryListener listener, void *data)
+ 
+ void QWaylandDisplay::removeListener(RegistryListener listener, void *data)
+ {
+-    std::remove_if(mRegistryListeners.begin(), mRegistryListeners.end(), [=](Listener l){
++    auto iter = std::remove_if(mRegistryListeners.begin(), mRegistryListeners.end(), [=](Listener l){
+         return (l.listener == listener && l.data == data);
+     });
++    mRegistryListeners.erase(iter, mRegistryListeners.end());
+ }
+ 
+ uint32_t QWaylandDisplay::currentTimeMillisec()
+@@ -467,50 +623,9 @@ uint32_t QWaylandDisplay::currentTimeMillisec()
+     return 0;
+ }
+ 
+-static void
+-sync_callback(void *data, struct wl_callback *callback, uint32_t serial)
+-{
+-    Q_UNUSED(serial)
+-    bool *done = static_cast<bool *>(data);
+-
+-    *done = true;
+-
+-    // If the wl_callback done event is received after the condition check in the while loop in
+-    // forceRoundTrip(), but before the call to processEvents, the call to processEvents may block
+-    // forever if no more events are posted (eventhough the callback is handled in response to the
+-    // aboutToBlock signal). Hence, we wake up the event dispatcher so forceRoundTrip may return.
+-    // (QTBUG-64696)
+-    if (auto *dispatcher = QThread::currentThread()->eventDispatcher())
+-        dispatcher->wakeUp();
+-
+-    wl_callback_destroy(callback);
+-}
+-
+-static const struct wl_callback_listener sync_listener = {
+-    sync_callback
+-};
+-
+ void QWaylandDisplay::forceRoundTrip()
+ {
+-    // wl_display_roundtrip() works on the main queue only,
+-    // but we use a separate one, so basically reimplement it here
+-    int ret = 0;
+-    bool done = false;
+-    wl_callback *callback = wl_display_sync(mDisplay);
+-    wl_callback_add_listener(callback, &sync_listener, &done);
+-    flushRequests();
+-    if (QThread::currentThread()->eventDispatcher()) {
+-        while (!done && ret >= 0) {
+-            QThread::currentThread()->eventDispatcher()->processEvents(QEventLoop::WaitForMoreEvents);
+-            ret = wl_display_dispatch_pending(mDisplay);
+-        }
+-    } else {
+-        while (!done && ret >= 0)
+-            ret = wl_display_dispatch(mDisplay);
+-    }
+-
+-    if (ret == -1 && !done)
+-        wl_callback_destroy(callback);
++     wl_display_roundtrip(mDisplay);
+ }
+ 
+ bool QWaylandDisplay::supportsWindowDecoration() const
+@@ -574,14 +689,10 @@ void QWaylandDisplay::handleKeyboardFocusChanged(QWaylandInputDevice *inputDevic
+     if (mLastKeyboardFocus == keyboardFocus)
+         return;
+ 
+-    if (mWaylandIntegration->mShellIntegration) {
+-        mWaylandIntegration->mShellIntegration->handleKeyboardFocusChanged(keyboardFocus, mLastKeyboardFocus);
+-    } else {
+-        if (keyboardFocus)
+-            handleWindowActivated(keyboardFocus);
+-        if (mLastKeyboardFocus)
+-            handleWindowDeactivated(mLastKeyboardFocus);
+-    }
++    if (keyboardFocus)
++        handleWindowActivated(keyboardFocus);
++    if (mLastKeyboardFocus)
++        handleWindowDeactivated(mLastKeyboardFocus);
+ 
+     mLastKeyboardFocus = keyboardFocus;
+ }
+@@ -600,6 +711,19 @@ void QWaylandDisplay::handleWaylandSync()
+     QWindow *activeWindow = mActiveWindows.empty() ? nullptr : mActiveWindows.last()->window();
+     if (activeWindow != QGuiApplication::focusWindow())
+         QWindowSystemInterface::handleWindowActivated(activeWindow);
++
++    if (!activeWindow) {
++        if (lastInputDevice()) {
++#if QT_CONFIG(clipboard)
++            if (auto *dataDevice = lastInputDevice()->dataDevice())
++                dataDevice->invalidateSelectionOffer();
++#endif
++#if QT_CONFIG(wayland_client_primary_selection)
++            if (auto *device = lastInputDevice()->primarySelectionDevice())
++                device->invalidateSelectionOffer();
++#endif
++        }
++    }
+ }
+ 
+ const wl_callback_listener QWaylandDisplay::syncCallbackListener = {
+@@ -626,6 +750,13 @@ QWaylandInputDevice *QWaylandDisplay::defaultInputDevice() const
+     return mInputDevices.isEmpty() ? 0 : mInputDevices.first();
+ }
+ 
++bool QWaylandDisplay::isKeyboardAvailable() const
++{
++    return std::any_of(
++            mInputDevices.constBegin(), mInputDevices.constEnd(),
++            [this](const QWaylandInputDevice *device) { return device->keyboard() != nullptr; });
++}
++
+ #if QT_CONFIG(cursor)
+ 
+ QWaylandCursor *QWaylandDisplay::waylandCursor()
+@@ -652,4 +783,6 @@ QWaylandCursorTheme *QWaylandDisplay::loadCursorTheme(const QString &name, int p
+ 
+ } // namespace QtWaylandClient
+ 
++#include "qwaylanddisplay.moc"
++
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/client/qwaylanddisplay_p.h b/qtwayland/src/client/qwaylanddisplay_p.h
+index 3b092bc8..42bc661d 100644
+--- a/qtwayland/src/client/qwaylanddisplay_p.h
++++ b/qtwayland/src/client/qwaylanddisplay_p.h
+@@ -109,6 +109,7 @@ class QWaylandSurface;
+ class QWaylandShellIntegration;
+ class QWaylandCursor;
+ class QWaylandCursorTheme;
++class EventThread;
+ 
+ typedef void (*RegistryListener)(void *data,
+                                  struct wl_registry *registry,
+@@ -120,15 +121,11 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandDisplay : public QObject, public QtWayland
+     Q_OBJECT
+ 
+ public:
+-    struct FrameQueue {
+-        FrameQueue(wl_event_queue *q = nullptr) : queue(q), mutex(new QMutex) {}
+-        wl_event_queue *queue;
+-        QMutex *mutex;
+-    };
+-
+     QWaylandDisplay(QWaylandIntegration *waylandIntegration);
+     ~QWaylandDisplay(void) override;
+ 
++    void initialize();
++
+ #if QT_CONFIG(xkbcommon)
+     struct xkb_context *xkbContext() const { return mXkbContext.get(); }
+ #endif
+@@ -210,11 +207,11 @@ public:
+     void handleKeyboardFocusChanged(QWaylandInputDevice *inputDevice);
+     void handleWindowDestroyed(QWaylandWindow *window);
+ 
+-    wl_event_queue *createEventQueue();
+-    FrameQueue createFrameQueue();
+-    void destroyFrameQueue(const FrameQueue &q);
+-    void dispatchQueueWhile(wl_event_queue *queue, std::function<bool()> condition, int timeout = -1);
++    wl_event_queue *frameEventQueue() { return m_frameEventQueue; };
++
++    bool isKeyboardAvailable() const;
+ 
++    void initEventThread();
+ public slots:
+     void blockingReadEvents();
+     void flushRequests();
+@@ -237,6 +234,9 @@ private:
+     };
+ 
+     struct wl_display *mDisplay = nullptr;
++    QScopedPointer<EventThread> m_eventThread;
++    wl_event_queue *m_frameEventQueue = nullptr;
++    QScopedPointer<EventThread> m_frameEventQueueThread;
+     QtWayland::wl_compositor mCompositor;
+     QScopedPointer<QWaylandShm> mShm;
+     QList<QWaylandScreen *> mWaitingScreens;
+@@ -273,11 +273,9 @@ private:
+     QWaylandInputDevice *mLastInputDevice = nullptr;
+     QPointer<QWaylandWindow> mLastInputWindow;
+     QPointer<QWaylandWindow> mLastKeyboardFocus;
+-    QVector<QWaylandWindow *> mActiveWindows;
+-    QVector<FrameQueue> mExternalQueues;
++    QList<QWaylandWindow *> mActiveWindows;
+     struct wl_callback *mSyncCallback = nullptr;
+     static const wl_callback_listener syncCallbackListener;
+-    QReadWriteLock m_frameQueueLock;
+ 
+     bool mClientSideInputContextRequested = !QPlatformInputContextFactory::requested().isNull();
+ 
+diff --git a/qtwayland/src/client/qwaylanddnd.cpp b/qtwayland/src/client/qwaylanddnd.cpp
+index 6535aa16..7c53f5fa 100644
+--- a/qtwayland/src/client/qwaylanddnd.cpp
++++ b/qtwayland/src/client/qwaylanddnd.cpp
+@@ -66,7 +66,7 @@ void QWaylandDrag::startDrag()
+ {
+     QBasicDrag::startDrag();
+     QWaylandWindow *icon = static_cast<QWaylandWindow *>(shapedPixmapWindow()->handle());
+-    if (m_display->currentInputDevice()->dataDevice()->startDrag(drag()->mimeData(), icon)) {
++    if (m_display->currentInputDevice()->dataDevice()->startDrag(drag()->mimeData(), drag()->supportedActions(), icon)) {
+         icon->addAttachOffset(-drag()->hotSpot());
+     } else {
+         // Cancelling immediately does not work, since the event loop for QDrag::exec is started
+@@ -80,6 +80,9 @@ void QWaylandDrag::cancel()
+     QBasicDrag::cancel();
+ 
+     m_display->currentInputDevice()->dataDevice()->cancelDrag();
++
++    if (drag())
++        drag()->deleteLater();
+ }
+ 
+ void QWaylandDrag::move(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods)
+@@ -103,33 +106,41 @@ void QWaylandDrag::endDrag()
+     m_display->currentInputDevice()->handleEndDrag();
+ }
+ 
+-void QWaylandDrag::updateTarget(const QString &mimeType)
++void QWaylandDrag::setResponse(bool accepted)
+ {
+-    setCanDrop(!mimeType.isEmpty());
+-
+-    if (canDrop()) {
+-        updateCursor(defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers()));
+-    } else {
+-        updateCursor(Qt::IgnoreAction);
+-    }
++    // This method is used for old DataDevices where the drag action is not communicated
++    Qt::DropAction action = defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers());
++    setResponse(QPlatformDropQtResponse(accepted, action));
+ }
+ 
+-void QWaylandDrag::setResponse(const QPlatformDragQtResponse &response)
++void QWaylandDrag::setResponse(const QPlatformDropQtResponse &response)
+ {
+     setCanDrop(response.isAccepted());
+ 
+     if (canDrop()) {
+-        updateCursor(defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers()));
++        updateCursor(response.acceptedAction());
+     } else {
+         updateCursor(Qt::IgnoreAction);
+     }
+ }
+ 
+-void QWaylandDrag::finishDrag(const QPlatformDropQtResponse &response)
++void QWaylandDrag::setDropResponse(const QPlatformDropQtResponse &response)
+ {
+     setExecutedDropAction(response.acceptedAction());
++}
++
++void QWaylandDrag::finishDrag()
++{
+     QKeyEvent event(QEvent::KeyPress, Qt::Key_Escape, Qt::NoModifier);
+     eventFilter(shapedPixmapWindow(), &event);
++
++    if (drag())
++        drag()->deleteLater();
++}
++
++bool QWaylandDrag::ownsDragObject() const
++{
++    return true;
+ }
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddnd_p.h b/qtwayland/src/client/qwaylanddnd_p.h
+index 474fe2ab..46f629ac 100644
+--- a/qtwayland/src/client/qwaylanddnd_p.h
++++ b/qtwayland/src/client/qwaylanddnd_p.h
+@@ -71,9 +71,10 @@ public:
+     QWaylandDrag(QWaylandDisplay *display);
+     ~QWaylandDrag() override;
+ 
+-    void updateTarget(const QString &mimeType);
+-    void setResponse(const QPlatformDragQtResponse &response);
+-    void finishDrag(const QPlatformDropQtResponse &response);
++    void setResponse(bool accepted);
++    void setResponse(const QPlatformDropQtResponse &response);
++    void setDropResponse(const QPlatformDropQtResponse &response);
++    void finishDrag();
+ 
+ protected:
+     void startDrag() override;
+@@ -82,6 +83,7 @@ protected:
+     void drop(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods) override;
+     void endDrag() override;
+ 
++    bool ownsDragObject() const override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+diff --git a/qtwayland/src/client/qwaylandinputdevice.cpp b/qtwayland/src/client/qwaylandinputdevice.cpp
+index 613fe862..4b90de84 100644
+--- a/qtwayland/src/client/qwaylandinputdevice.cpp
++++ b/qtwayland/src/client/qwaylandinputdevice.cpp
+@@ -685,6 +685,11 @@ public:
+ 
+ void QWaylandInputDevice::Pointer::pointer_leave(uint32_t time, struct wl_surface *surface)
+ {
++    invalidateFocus();
++    mButtons = Qt::NoButton;
++
++    mParent->mTime = time;
++
+     // The event may arrive after destroying the window, indicated by
+     // a null surface.
+     if (!surface)
+@@ -696,11 +701,6 @@ void QWaylandInputDevice::Pointer::pointer_leave(uint32_t time, struct wl_surfac
+ 
+     if (!QWaylandWindow::mouseGrab())
+         setFrameEvent(new LeaveEvent(window, mSurfacePos, mGlobalPos));
+-
+-    invalidateFocus();
+-    mButtons = Qt::NoButton;
+-
+-    mParent->mTime = time;
+ }
+ 
+ class MotionEvent : public QWaylandPointerEvent
+@@ -1300,14 +1300,6 @@ void QWaylandInputDevice::Keyboard::handleFocusDestroyed()
+ void QWaylandInputDevice::Keyboard::handleFocusLost()
+ {
+     mFocus = nullptr;
+-#if QT_CONFIG(clipboard)
+-    if (auto *dataDevice = mParent->dataDevice())
+-        dataDevice->invalidateSelectionOffer();
+-#endif
+-#if QT_CONFIG(wayland_client_primary_selection)
+-    if (auto *device = mParent->primarySelectionDevice())
+-        device->invalidateSelectionOffer();
+-#endif
+     mParent->mQDisplay->handleKeyboardFocusChanged(mParent);
+     mRepeatTimer.stop();
+ }
+@@ -1396,6 +1388,7 @@ void QWaylandInputDevice::Touch::touch_cancel()
+     if (touchExt)
+         touchExt->touchCanceled();
+ 
++    mFocus = nullptr;
+     QWindowSystemInterface::handleTouchCancelEvent(nullptr, mParent->mTouchDevice);
+ }
+ 
+diff --git a/qtwayland/src/client/qwaylandintegration.cpp b/qtwayland/src/client/qwaylandintegration.cpp
+index c53ccb78..54861600 100644
+--- a/qtwayland/src/client/qwaylandintegration.cpp
++++ b/qtwayland/src/client/qwaylandintegration.cpp
+@@ -125,6 +125,9 @@ QWaylandIntegration::QWaylandIntegration()
+ #endif
+ 
+     reconfigureInputContext();
++
++    QWaylandWindow::fixedToplevelPositions =
++            !qEnvironmentVariableIsSet("QT_WAYLAND_DISABLE_FIXED_POSITIONS");
+ }
+ 
+ QWaylandIntegration::~QWaylandIntegration()
+@@ -192,14 +195,18 @@ QAbstractEventDispatcher *QWaylandIntegration::createEventDispatcher() const
+ 
+ void QWaylandIntegration::initialize()
+ {
++    mDisplay->initEventThread();
++
++    // Call after eventDispatcher is fully connected, for QWaylandDisplay::forceRoundTrip()
++    mDisplay->initialize();
++
++    // But the aboutToBlock() and awake() should be connected after initializePlatform().
++    // Otherwise the connected flushRequests() may consumes up all events before processEvents starts to wait,
++    // so that processEvents(QEventLoop::WaitForMoreEvents) may be blocked in the forceRoundTrip().
+     QAbstractEventDispatcher *dispatcher = QGuiApplicationPrivate::eventDispatcher;
+     QObject::connect(dispatcher, SIGNAL(aboutToBlock()), mDisplay.data(), SLOT(flushRequests()));
+     QObject::connect(dispatcher, SIGNAL(awake()), mDisplay.data(), SLOT(flushRequests()));
+ 
+-    int fd = wl_display_get_fd(mDisplay->wl_display());
+-    QSocketNotifier *sn = new QSocketNotifier(fd, QSocketNotifier::Read, mDisplay.data());
+-    QObject::connect(sn, SIGNAL(activated(QSocketDescriptor)), mDisplay.data(), SLOT(flushRequests()));
+-
+     // Qt does not support running with no screens
+     mDisplay->ensureScreen();
+ }
+@@ -262,6 +269,14 @@ QWaylandDisplay *QWaylandIntegration::display() const
+     return mDisplay.data();
+ }
+ 
++Qt::KeyboardModifiers QWaylandIntegration::queryKeyboardModifiers() const
++{
++    if (auto *seat = mDisplay->currentInputDevice()) {
++        return seat->modifiers();
++    }
++    return Qt::NoModifier;
++}
++
+ QList<int> QWaylandIntegration::possibleKeys(const QKeyEvent *event) const
+ {
+     if (auto *seat = mDisplay->currentInputDevice())
+@@ -479,7 +494,7 @@ void QWaylandIntegration::reconfigureInputContext()
+     }
+ #endif
+ 
+-    qCDebug(lcQpaWayland) << "using input method:" << inputContext()->metaObject()->className();
++    qCDebug(lcQpaWayland) << "using input method:" << (inputContext() ? inputContext()->metaObject()->className() : "<none>");
+ }
+ 
+ QWaylandShellIntegration *QWaylandIntegration::createShellIntegration(const QString &integrationName)
+diff --git a/qtwayland/src/client/qwaylandintegration_p.h b/qtwayland/src/client/qwaylandintegration_p.h
+index ff70ae25..73b80658 100644
+--- a/qtwayland/src/client/qwaylandintegration_p.h
++++ b/qtwayland/src/client/qwaylandintegration_p.h
+@@ -107,6 +107,8 @@ public:
+ 
+     QWaylandDisplay *display() const;
+ 
++    Qt::KeyboardModifiers queryKeyboardModifiers() const override;
++
+     QList<int> possibleKeys(const QKeyEvent *event) const override;
+ 
+     QStringList themeNames() const override;
+diff --git a/qtwayland/src/client/qwaylandprimaryselectionv1.cpp b/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
+index 832f9678..ea508771 100644
+--- a/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
++++ b/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
+@@ -54,11 +54,6 @@ QWaylandPrimarySelectionDeviceManagerV1::QWaylandPrimarySelectionDeviceManagerV1
+     : zwp_primary_selection_device_manager_v1(display->wl_registry(), id, qMin(version, uint(1)))
+     , m_display(display)
+ {
+-    // Create devices for all seats.
+-    // This only works if we get the global before all devices
+-    const auto seats = m_display->inputDevices();
+-    for (auto *seat : seats)
+-        seat->setPrimarySelectionDevice(createDevice(seat));
+ }
+ 
+ QWaylandPrimarySelectionDeviceV1 *QWaylandPrimarySelectionDeviceManagerV1::createDevice(QWaylandInputDevice *seat)
+diff --git a/qtwayland/src/client/qwaylandscreen.cpp b/qtwayland/src/client/qwaylandscreen.cpp
+index 6cb337de..5537dafd 100644
+--- a/qtwayland/src/client/qwaylandscreen.cpp
++++ b/qtwayland/src/client/qwaylandscreen.cpp
+@@ -60,7 +60,7 @@ QWaylandXdgOutputManagerV1::QWaylandXdgOutputManagerV1(QWaylandDisplay* display,
+ }
+ 
+ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uint32_t id)
+-    : QtWayland::wl_output(waylandDisplay->wl_registry(), id, qMin(version, 2))
++    : QtWayland::wl_output(waylandDisplay->wl_registry(), id, qMin(version, 3))
+     , m_outputId(id)
+     , mWaylandDisplay(waylandDisplay)
+     , mOutputName(QStringLiteral("Screen%1").arg(id))
+@@ -72,7 +72,7 @@ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uin
+         qCWarning(lcQpaWayland) << "wl_output done event not supported by compositor,"
+                                 << "QScreen may not work correctly";
+         mWaylandDisplay->forceRoundTrip(); // Give the compositor a chance to send geometry etc.
+-        mOutputDone = true; // Fake the done event
++        mProcessedEvents |= OutputDoneEvent; // Fake the done event
+         maybeInitialize();
+     }
+ }
+@@ -81,16 +81,29 @@ QWaylandScreen::~QWaylandScreen()
+ {
+     if (zxdg_output_v1::isInitialized())
+         zxdg_output_v1::destroy();
++    if (wl_output::isInitialized() && wl_output_get_version(wl_output::object()) >= WL_OUTPUT_RELEASE_SINCE_VERSION)
++        wl_output::release();
++}
++
++uint QWaylandScreen::requiredEvents() const
++{
++    uint ret = OutputDoneEvent;
++
++    if (mWaylandDisplay->xdgOutputManager()) {
++        ret |= XdgOutputNameEvent;
++
++        if (mWaylandDisplay->xdgOutputManager()->version() < 3)
++            ret |= XdgOutputDoneEvent;
++    }
++    return ret;
+ }
+ 
+ void QWaylandScreen::maybeInitialize()
+ {
+     Q_ASSERT(!mInitialized);
+ 
+-    if (!mOutputDone)
+-        return;
+-
+-    if (mWaylandDisplay->xdgOutputManager() && !mXdgOutputDone)
++    const uint requiredEvents = this->requiredEvents();
++    if ((mProcessedEvents & requiredEvents) != requiredEvents)
+         return;
+ 
+     mInitialized = true;
+@@ -276,9 +289,8 @@ void QWaylandScreen::output_scale(int32_t factor)
+ 
+ void QWaylandScreen::output_done()
+ {
+-    mOutputDone = true;
+-    if (zxdg_output_v1::isInitialized() && mWaylandDisplay->xdgOutputManager()->version() >= 3)
+-        mXdgOutputDone = true;
++    mProcessedEvents |= OutputDoneEvent;
++
+     if (mInitialized) {
+         updateOutputProperties();
+         if (zxdg_output_v1::isInitialized())
+@@ -339,7 +351,7 @@ void QWaylandScreen::zxdg_output_v1_done()
+     if (Q_UNLIKELY(mWaylandDisplay->xdgOutputManager()->version() >= 3))
+         qWarning(lcQpaWayland) << "zxdg_output_v1.done received on version 3 or newer, this is most likely a bug in the compositor";
+ 
+-    mXdgOutputDone = true;
++    mProcessedEvents |= XdgOutputDoneEvent;
+     if (mInitialized)
+         updateXdgOutputProperties();
+     else
+@@ -348,7 +360,11 @@ void QWaylandScreen::zxdg_output_v1_done()
+ 
+ void QWaylandScreen::zxdg_output_v1_name(const QString &name)
+ {
++    if (Q_UNLIKELY(mInitialized))
++        qWarning(lcQpaWayland) << "zxdg_output_v1.name received after output has been initialized, this is most likely a bug in the compositor";
++
+     mOutputName = name;
++    mProcessedEvents |= XdgOutputNameEvent;
+ }
+ 
+ void QWaylandScreen::updateXdgOutputProperties()
+diff --git a/qtwayland/src/client/qwaylandscreen_p.h b/qtwayland/src/client/qwaylandscreen_p.h
+index df1c94f2..050cfdc0 100644
+--- a/qtwayland/src/client/qwaylandscreen_p.h
++++ b/qtwayland/src/client/qwaylandscreen_p.h
+@@ -116,6 +116,13 @@ public:
+     static QWaylandScreen *fromWlOutput(::wl_output *output);
+ 
+ private:
++    enum Event : uint {
++        XdgOutputDoneEvent = 0x1,
++        OutputDoneEvent = 0x2,
++        XdgOutputNameEvent = 0x4,
++    };
++    uint requiredEvents() const;
++
+     void output_mode(uint32_t flags, int width, int height, int refresh) override;
+     void output_geometry(int32_t x, int32_t y,
+                          int32_t width, int32_t height,
+@@ -148,8 +155,7 @@ private:
+     QSize mPhysicalSize;
+     QString mOutputName;
+     Qt::ScreenOrientation m_orientation = Qt::PrimaryOrientation;
+-    bool mOutputDone = false;
+-    bool mXdgOutputDone = false;
++    uint mProcessedEvents = 0;
+     bool mInitialized = false;
+ 
+ #if QT_CONFIG(cursor)
+diff --git a/qtwayland/src/client/qwaylandshmbackingstore.cpp b/qtwayland/src/client/qwaylandshmbackingstore.cpp
+index dc7ff670..41cffdf7 100644
+--- a/qtwayland/src/client/qwaylandshmbackingstore.cpp
++++ b/qtwayland/src/client/qwaylandshmbackingstore.cpp
+@@ -52,6 +52,7 @@
+ 
+ #include <QtWaylandClient/private/wayland-wayland-client-protocol.h>
+ 
++#include <fcntl.h>
+ #include <unistd.h>
+ #include <sys/mman.h>
+ 
+@@ -61,6 +62,9 @@
+ #  ifndef MFD_CLOEXEC
+ #    define MFD_CLOEXEC     0x0001U
+ #  endif
++#  ifndef MFD_ALLOW_SEALING
++#    define MFD_ALLOW_SEALING 0x0002U
++#  endif
+ #endif
+ 
+ QT_BEGIN_NAMESPACE
+@@ -74,8 +78,10 @@ QWaylandShmBuffer::QWaylandShmBuffer(QWaylandDisplay *display,
+     int alloc = stride * size.height();
+     int fd = -1;
+ 
+-#ifdef SYS_memfd_create
+-    fd = syscall(SYS_memfd_create, "wayland-shm", MFD_CLOEXEC);
++#if defined(SYS_memfd_create) && defined(F_SEAL_SEAL)
++    fd = syscall(SYS_memfd_create, "wayland-shm", MFD_CLOEXEC | MFD_ALLOW_SEALING);
++    if (fd >= 0)
++        fcntl(fd, F_ADD_SEALS, F_SEAL_SHRINK | F_SEAL_SEAL);
+ #endif
+ 
+     QScopedPointer<QFile> filePointer;
+diff --git a/qtwayland/src/client/qwaylandwindow.cpp b/qtwayland/src/client/qwaylandwindow.cpp
+index cb82857a..fb2c59dc 100644
+--- a/qtwayland/src/client/qwaylandwindow.cpp
++++ b/qtwayland/src/client/qwaylandwindow.cpp
+@@ -76,7 +76,6 @@ QWaylandWindow *QWaylandWindow::mMouseGrab = nullptr;
+ QWaylandWindow::QWaylandWindow(QWindow *window, QWaylandDisplay *display)
+     : QPlatformWindow(window)
+     , mDisplay(display)
+-    , mFrameQueue(mDisplay->createFrameQueue())
+     , mResizeAfterSwap(qEnvironmentVariableIsSet("QT_WAYLAND_RESIZE_AFTER_SWAP"))
+ {
+     {
+@@ -95,9 +94,6 @@ QWaylandWindow::QWaylandWindow(QWindow *window, QWaylandDisplay *display)
+ 
+ QWaylandWindow::~QWaylandWindow()
+ {
+-    mDisplay->destroyFrameQueue(mFrameQueue);
+-    mDisplay->handleWindowDestroyed(this);
+-
+     delete mWindowDecoration;
+ 
+     if (mSurface)
+@@ -243,6 +239,7 @@ bool QWaylandWindow::shouldCreateSubSurface() const
+ 
+ void QWaylandWindow::reset()
+ {
++    closeChildPopups();
+     delete mShellSurface;
+     mShellSurface = nullptr;
+     delete mSubSurfaceWindow;
+@@ -255,17 +252,22 @@ void QWaylandWindow::reset()
+         mSurface.reset();
+     }
+ 
+-    if (mFrameCallback) {
+-        wl_callback_destroy(mFrameCallback);
+-        mFrameCallback = nullptr;
+-    }
++    {
++        QMutexLocker lock(&mFrameSyncMutex);
++        if (mFrameCallback) {
++            wl_callback_destroy(mFrameCallback);
++            mFrameCallback = nullptr;
++        }
+ 
+-    mFrameCallbackElapsedTimer.invalidate();
+-    mWaitingForFrameCallback = false;
++        mFrameCallbackElapsedTimer.invalidate();
++        mWaitingForFrameCallback = false;
++    }
+     mFrameCallbackTimedOut = false;
+ 
+     mMask = QRegion();
+     mQueuedBuffer = nullptr;
++
++    mDisplay->handleWindowDestroyed(this);
+ }
+ 
+ QWaylandWindow *QWaylandWindow::fromWlSurface(::wl_surface *surface)
+@@ -351,19 +353,25 @@ void QWaylandWindow::setGeometry_helper(const QRect &rect)
+     }
+ }
+ 
+-void QWaylandWindow::setGeometry(const QRect &rect)
++void QWaylandWindow::setGeometry(const QRect &r)
+ {
++    auto rect = r;
++    if (fixedToplevelPositions && !QPlatformWindow::parent() && window()->type() != Qt::Popup
++        && window()->type() != Qt::ToolTip) {
++        rect.moveTo(screen()->geometry().topLeft());
++    }
+     setGeometry_helper(rect);
+ 
+     if (window()->isVisible() && rect.isValid()) {
+         if (mWindowDecoration)
+             mWindowDecoration->update();
+ 
+-        if (mResizeAfterSwap && windowType() == Egl && mSentInitialResize)
++        if (mResizeAfterSwap && windowType() == Egl && mSentInitialResize) {
++            QMutexLocker lock(&mResizeLock);
+             mResizeDirty = true;
+-        else
++        } else {
+             QWindowSystemInterface::handleGeometryChange(window(), geometry());
+-
++        }
+         mSentInitialResize = true;
+     }
+     QRect exposeGeometry(QPoint(), geometry().size());
+@@ -374,7 +382,7 @@ void QWaylandWindow::setGeometry(const QRect &rect)
+         mShellSurface->setWindowGeometry(windowContentGeometry());
+ 
+     if (isOpaque() && mMask.isEmpty())
+-        setOpaqueArea(rect);
++        setOpaqueArea(QRect(QPoint(0, 0), rect.size()));
+ }
+ 
+ void QWaylandWindow::resizeFromApplyConfigure(const QSize &sizeWithMargins, const QPoint &offset)
+@@ -399,21 +407,6 @@ void QWaylandWindow::sendExposeEvent(const QRect &rect)
+     mLastExposeGeometry = rect;
+ }
+ 
+-
+-static QVector<QPointer<QWaylandWindow>> activePopups;
+-
+-void QWaylandWindow::closePopups(QWaylandWindow *parent)
+-{
+-    while (!activePopups.isEmpty()) {
+-        auto popup = activePopups.takeLast();
+-        if (popup.isNull())
+-            continue;
+-        if (popup.data() == parent)
+-            return;
+-        popup->reset();
+-    }
+-}
+-
+ QPlatformScreen *QWaylandWindow::calculateScreenFromSurfaceEvents() const
+ {
+     QReadLocker lock(&mSurfaceLock);
+@@ -433,10 +426,7 @@ void QWaylandWindow::setVisible(bool visible)
+     lastVisible = visible;
+ 
+     if (visible) {
+-        if (window()->type() == Qt::Popup || window()->type() == Qt::ToolTip)
+-            activePopups << this;
+         initWindow();
+-        mDisplay->flushRequests();
+ 
+         setGeometry(windowGeometry());
+         // Don't flush the events here, or else the newly visible window may start drawing, but since
+@@ -444,7 +434,6 @@ void QWaylandWindow::setVisible(bool visible)
+         // QWaylandShmBackingStore::beginPaint().
+     } else {
+         sendExposeEvent(QRect());
+-        closePopups(this);
+         reset();
+     }
+ }
+@@ -556,12 +545,12 @@ void QWaylandWindow::sendRecursiveExposeEvent()
+ 
+ void QWaylandWindow::attach(QWaylandBuffer *buffer, int x, int y)
+ {
+-    Q_ASSERT(!buffer->committed());
+     QReadLocker locker(&mSurfaceLock);
+     if (mSurface == nullptr)
+         return;
+ 
+     if (buffer) {
++        Q_ASSERT(!buffer->committed());
+         handleUpdate();
+         buffer->setBusy();
+ 
+@@ -583,7 +572,11 @@ void QWaylandWindow::damage(const QRect &rect)
+     if (mSurface == nullptr)
+         return;
+ 
+-    mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    const int s = scale();
++    if (mDisplay->compositorVersion() >= 4)
++        mSurface->damage_buffer(s * rect.x(), s * rect.y(), s * rect.width(), s * rect.height());
++    else
++        mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
+ }
+ 
+ void QWaylandWindow::safeCommit(QWaylandBuffer *buffer, const QRegion &damage)
+@@ -619,8 +612,14 @@ void QWaylandWindow::commit(QWaylandBuffer *buffer, const QRegion &damage)
+         return;
+ 
+     attachOffset(buffer);
+-    for (const QRect &rect: damage)
+-        mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    if (mDisplay->compositorVersion() >= 4) {
++        const int s = scale();
++        for (const QRect &rect: damage)
++            mSurface->damage_buffer(s * rect.x(), s * rect.y(), s * rect.width(), s * rect.height());
++    } else {
++        for (const QRect &rect: damage)
++            mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    }
+     Q_ASSERT(!buffer->committed());
+     buffer->setCommitted();
+     mSurface->commit();
+@@ -635,42 +634,53 @@ void QWaylandWindow::commit()
+ 
+ const wl_callback_listener QWaylandWindow::callbackListener = {
+     [](void *data, wl_callback *callback, uint32_t time) {
+-        Q_UNUSED(callback);
+         Q_UNUSED(time);
+         auto *window = static_cast<QWaylandWindow*>(data);
+-        window->handleFrameCallback();
++        window->handleFrameCallback(callback);
+     }
+ };
+ 
+-void QWaylandWindow::handleFrameCallback()
++void QWaylandWindow::handleFrameCallback(wl_callback* callback)
+ {
++    QMutexLocker locker(&mFrameSyncMutex);
++    if (!mFrameCallback) {
++        // This means the callback is already unset by QWaylandWindow::reset.
++        // The wl_callback object will be destroyed there too.
++        return;
++    }
++    Q_ASSERT(callback == mFrameCallback);
++    wl_callback_destroy(callback);
++    mFrameCallback = nullptr;
++
+     mWaitingForFrameCallback = false;
+     mFrameCallbackElapsedTimer.invalidate();
+ 
+     // The rest can wait until we can run it on the correct thread
+-    if (!mWaitingForUpdateDelivery) {
+-        auto doHandleExpose = [this]() {
+-            bool wasExposed = isExposed();
+-            mFrameCallbackTimedOut = false;
+-            if (!wasExposed && isExposed()) // Did setting mFrameCallbackTimedOut make the window exposed?
+-                sendExposeEvent(QRect(QPoint(), geometry().size()));
+-            if (wasExposed && hasPendingUpdateRequest())
+-                deliverUpdateRequest();
+-
+-            mWaitingForUpdateDelivery = false;
+-        };
++    auto doHandleExpose = [this]() {
++        mWaitingForUpdateDelivery.storeRelease(false);
++        bool wasExposed = isExposed();
++        mFrameCallbackTimedOut = false;
++        if (!wasExposed && isExposed()) // Did setting mFrameCallbackTimedOut make the window exposed?
++            sendExposeEvent(QRect(QPoint(), geometry().size()));
++        if (wasExposed && hasPendingUpdateRequest())
++            deliverUpdateRequest();
++    };
+ 
++    if (mWaitingForUpdateDelivery.testAndSetAcquire(false, true)) {
+         // Queued connection, to make sure we don't call handleUpdate() from inside waitForFrameSync()
+         // in the single-threaded case.
+-        mWaitingForUpdateDelivery = true;
+         QMetaObject::invokeMethod(this, doHandleExpose, Qt::QueuedConnection);
+     }
++
++    mFrameSyncWait.notify_all();
+ }
+ 
+ bool QWaylandWindow::waitForFrameSync(int timeout)
+ {
+-    QMutexLocker locker(mFrameQueue.mutex);
+-    mDisplay->dispatchQueueWhile(mFrameQueue.queue, [&]() { return mWaitingForFrameCallback; }, timeout);
++    QMutexLocker locker(&mFrameSyncMutex);
++
++    QDeadlineTimer deadline(timeout);
++    while (mWaitingForFrameCallback && mFrameSyncWait.wait(&mFrameSyncMutex, deadline)) { }
+ 
+     if (mWaitingForFrameCallback) {
+         qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
+@@ -868,6 +878,17 @@ bool QWaylandWindow::createDecoration()
+             subsurf->set_position(pos.x() + m.left(), pos.y() + m.top());
+         }
+         sendExposeEvent(QRect(QPoint(), geometry().size()));
++
++        // This is a special case where the buffer is recreated, but since
++        // the content rect remains the same, the widgets remain the same
++        // size and are not redrawn, leaving the new buffer empty. As a simple
++        // work-around, we trigger a full extra update whenever the client-side
++        // window decorations are toggled while the window is showing.
++        // Note: createDecoration() is sometimes called from the render thread
++        // of Qt Quick. This is essentially wrong and could potentially cause problems,
++        // but until the underlying issue has been fixed, we have to use invokeMethod()
++        // here to avoid asserts.
++        QMetaObject::invokeMethod(window(), &QWindow::requestUpdate);
+     }
+ 
+     return mWindowDecoration;
+@@ -1023,6 +1044,13 @@ void QWaylandWindow::handleScreensChanged()
+ 
+     QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->QPlatformScreen::screen());
+     mLastReportedScreen = newScreen;
++    if (fixedToplevelPositions && !QPlatformWindow::parent() && window()->type() != Qt::Popup
++        && window()->type() != Qt::ToolTip
++        && geometry().topLeft() != newScreen->geometry().topLeft()) {
++        auto geometry = this->geometry();
++        geometry.moveTo(newScreen->geometry().topLeft());
++        setGeometry(geometry);
++    }
+ 
+     int scale = newScreen->isPlaceholder() ? 1 : static_cast<QWaylandScreen *>(newScreen)->scale();
+     if (scale != mScale) {
+@@ -1094,10 +1122,18 @@ bool QWaylandWindow::setMouseGrabEnabled(bool grab)
+     return true;
+ }
+ 
++Qt::WindowStates QWaylandWindow::windowStates() const
++{
++    return mLastReportedWindowStates;
++}
++
+ void QWaylandWindow::handleWindowStatesChanged(Qt::WindowStates states)
+ {
+     createDecoration();
+-    QWindowSystemInterface::handleWindowStateChanged(window(), states, mLastReportedWindowStates);
++    Qt::WindowStates statesWithoutActive = states & ~Qt::WindowActive;
++    Qt::WindowStates lastStatesWithoutActive = mLastReportedWindowStates & ~Qt::WindowActive;
++    QWindowSystemInterface::handleWindowStateChanged(window(), statesWithoutActive,
++                                                     lastStatesWithoutActive);
+     mLastReportedWindowStates = states;
+ }
+ 
+@@ -1139,19 +1175,24 @@ void QWaylandWindow::timerEvent(QTimerEvent *event)
+     if (event->timerId() != mFrameCallbackCheckIntervalTimerId)
+         return;
+ 
+-    bool callbackTimerExpired = mFrameCallbackElapsedTimer.hasExpired(mFrameCallbackTimeout);
+-    if (!mFrameCallbackElapsedTimer.isValid() || callbackTimerExpired ) {
+-        killTimer(mFrameCallbackCheckIntervalTimerId);
+-        mFrameCallbackCheckIntervalTimerId = -1;
+-    }
+-    if (mFrameCallbackElapsedTimer.isValid() && callbackTimerExpired) {
+-        mFrameCallbackElapsedTimer.invalidate();
++    {
++        QMutexLocker lock(&mFrameSyncMutex);
+ 
+-        qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
+-        mFrameCallbackTimedOut = true;
+-        mWaitingForUpdate = false;
+-        sendExposeEvent(QRect());
++        bool callbackTimerExpired = mFrameCallbackElapsedTimer.hasExpired(mFrameCallbackTimeout);
++        if (!mFrameCallbackElapsedTimer.isValid() || callbackTimerExpired ) {
++            killTimer(mFrameCallbackCheckIntervalTimerId);
++            mFrameCallbackCheckIntervalTimerId = -1;
++        }
++        if (!mFrameCallbackElapsedTimer.isValid() || !callbackTimerExpired) {
++            return;
++        }
++        mFrameCallbackElapsedTimer.invalidate();
+     }
++
++    qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
++    mFrameCallbackTimedOut = true;
++    mWaitingForUpdate = false;
++    sendExposeEvent(QRect());
+ }
+ 
+ void QWaylandWindow::requestUpdate()
+@@ -1160,8 +1201,11 @@ void QWaylandWindow::requestUpdate()
+     Q_ASSERT(hasPendingUpdateRequest()); // should be set by QPA
+ 
+     // If we have a frame callback all is good and will be taken care of there
+-    if (mWaitingForFrameCallback)
+-        return;
++    {
++        QMutexLocker locker(&mFrameSyncMutex);
++        if (mWaitingForFrameCallback)
++            return;
++    }
+ 
+     // If we've already called deliverUpdateRequest(), but haven't seen any attach+commit/swap yet
+     // This is a somewhat redundant behavior and might indicate a bug in the calling code, so log
+@@ -1174,7 +1218,12 @@ void QWaylandWindow::requestUpdate()
+     // so use invokeMethod to delay the delivery a bit.
+     QMetaObject::invokeMethod(this, [this] {
+         // Things might have changed in the meantime
+-        if (hasPendingUpdateRequest() && !mWaitingForFrameCallback)
++        {
++            QMutexLocker locker(&mFrameSyncMutex);
++            if (mWaitingForFrameCallback)
++                return;
++        }
++        if (hasPendingUpdateRequest())
+             deliverUpdateRequest();
+     }, Qt::QueuedConnection);
+ }
+@@ -1185,19 +1234,18 @@ void QWaylandWindow::requestUpdate()
+ void QWaylandWindow::handleUpdate()
+ {
+     qCDebug(lcWaylandBackingstore) << "handleUpdate" << QThread::currentThread();
++
+     // TODO: Should sync subsurfaces avoid requesting frame callbacks?
+     QReadLocker lock(&mSurfaceLock);
+     if (!mSurface)
+         return;
+ 
+-    if (mFrameCallback) {
+-        wl_callback_destroy(mFrameCallback);
+-        mFrameCallback = nullptr;
+-    }
++    QMutexLocker locker(&mFrameSyncMutex);
++    if (mWaitingForFrameCallback)
++        return;
+ 
+-    QMutexLocker locker(mFrameQueue.mutex);
+     struct ::wl_surface *wrappedSurface = reinterpret_cast<struct ::wl_surface *>(wl_proxy_create_wrapper(mSurface->object()));
+-    wl_proxy_set_queue(reinterpret_cast<wl_proxy *>(wrappedSurface), mFrameQueue.queue);
++    wl_proxy_set_queue(reinterpret_cast<wl_proxy *>(wrappedSurface), mDisplay->frameEventQueue());
+     mFrameCallback = wl_surface_frame(wrappedSurface);
+     wl_proxy_wrapper_destroy(wrappedSurface);
+     wl_callback_add_listener(mFrameCallback, &QWaylandWindow::callbackListener, this);
+@@ -1207,6 +1255,8 @@ void QWaylandWindow::handleUpdate()
+     // Start a timer for handling the case when the compositor stops sending frame callbacks.
+     if (mFrameCallbackTimeout > 0) {
+         QMetaObject::invokeMethod(this, [this] {
++            QMutexLocker locker(&mFrameSyncMutex);
++
+             if (mWaitingForFrameCallback) {
+                 if (mFrameCallbackCheckIntervalTimerId < 0)
+                     mFrameCallbackCheckIntervalTimerId = startTimer(mFrameCallbackTimeout);
+@@ -1267,6 +1317,20 @@ void QWaylandWindow::setOpaqueArea(const QRegion &opaqueArea)
+     wl_region_destroy(region);
+ }
+ 
++void QWaylandWindow::addChildPopup(QWaylandWindow *surface) {
++    mChildPopups.append(surface);
++}
++
++void QWaylandWindow::removeChildPopup(QWaylandWindow *surface) {
++    mChildPopups.removeAll(surface);
++}
++
++void QWaylandWindow::closeChildPopups() {
++    while (!mChildPopups.isEmpty()) {
++        auto popup = mChildPopups.takeLast();
++        popup->reset();
++    }
++}
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/client/qwaylandwindow_p.h b/qtwayland/src/client/qwaylandwindow_p.h
+index 01337cff..2f219d8c 100644
+--- a/qtwayland/src/client/qwaylandwindow_p.h
++++ b/qtwayland/src/client/qwaylandwindow_p.h
+@@ -98,6 +98,9 @@ public:
+     QWaylandWindow(QWindow *window, QWaylandDisplay *display);
+     ~QWaylandWindow() override;
+ 
++    // Keep Toplevels position on the top left corner of their screen
++    static inline bool fixedToplevelPositions = true;
++
+     virtual WindowType windowType() const = 0;
+     virtual void ensureSize();
+     WId winId() const override;
+@@ -148,6 +151,7 @@ public:
+     void setWindowState(Qt::WindowStates states) override;
+     void setWindowFlags(Qt::WindowFlags flags) override;
+     void handleWindowStatesChanged(Qt::WindowStates states);
++    Qt::WindowStates windowStates() const;
+ 
+     void raise() override;
+     void lower() override;
+@@ -206,6 +210,10 @@ public:
+     void handleUpdate();
+     void deliverUpdateRequest() override;
+ 
++    void addChildPopup(QWaylandWindow* child);
++    void removeChildPopup(QWaylandWindow* child);
++    void closeChildPopups();
++
+ public slots:
+     void applyConfigure();
+ 
+@@ -215,7 +223,11 @@ signals:
+ 
+ protected:
+     QWaylandDisplay *mDisplay = nullptr;
++
++    // mSurface can be written by the main thread. Other threads should claim a read lock for access
++    mutable QReadWriteLock mSurfaceLock;
+     QScopedPointer<QWaylandSurface> mSurface;
++
+     QWaylandShellSurface *mShellSurface = nullptr;
+     QWaylandSubSurface *mSubSurfaceWindow = nullptr;
+     QVector<QWaylandSubSurface *> mChildren;
+@@ -225,13 +237,14 @@ protected:
+     Qt::MouseButtons mMousePressedInContentArea = Qt::NoButton;
+ 
+     WId mWindowId;
+-    bool mWaitingForFrameCallback = false;
+     bool mFrameCallbackTimedOut = false; // Whether the frame callback has timed out
+-    bool mWaitingForUpdateDelivery = false;
+     int mFrameCallbackCheckIntervalTimerId = -1;
+-    QElapsedTimer mFrameCallbackElapsedTimer;
+-    struct ::wl_callback *mFrameCallback = nullptr;
+-    QWaylandDisplay::FrameQueue mFrameQueue;
++    QAtomicInt mWaitingForUpdateDelivery = false;
++
++    bool mWaitingForFrameCallback = false; // Protected by mFrameSyncMutex
++    QElapsedTimer mFrameCallbackElapsedTimer; // Protected by mFrameSyncMutex
++    struct ::wl_callback *mFrameCallback = nullptr; // Protected by mFrameSyncMutex
++    QMutex mFrameSyncMutex;
+     QWaitCondition mFrameSyncWait;
+ 
+     // True when we have called deliverRequestUpdate, but the client has not yet attached a new buffer
+@@ -261,6 +274,8 @@ protected:
+     QWaylandBuffer *mQueuedBuffer = nullptr;
+     QRegion mQueuedBufferDamage;
+ 
++    QList<QPointer<QWaylandWindow>> mChildPopups;
++
+ private:
+     void setGeometry_helper(const QRect &rect);
+     void initWindow();
+@@ -283,12 +298,10 @@ private:
+     QRect mLastExposeGeometry;
+ 
+     static const wl_callback_listener callbackListener;
+-    void handleFrameCallback();
++    void handleFrameCallback(struct ::wl_callback* callback);
+ 
+     static QWaylandWindow *mMouseGrab;
+ 
+-    mutable QReadWriteLock mSurfaceLock;
+-
+     friend class QWaylandSubSurface;
+ };
+ 
+diff --git a/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h b/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
+index ccad0048..4cc9b3b8 100644
+--- a/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
++++ b/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
+@@ -73,11 +73,10 @@ public:
+         return true;
+     }
+     virtual QWaylandShellSurface *createShellSurface(QWaylandWindow *window) = 0;
++    // kept for binary compat with layer-shell-qt
+     virtual void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) {
+-        if (newFocus)
+-            m_display->handleWindowActivated(newFocus);
+-        if (oldFocus)
+-            m_display->handleWindowDeactivated(oldFocus);
++        Q_UNUSED(newFocus);
++        Q_UNUSED(oldFocus);
+     }
+     virtual void *nativeResourceForWindow(const QByteArray &resource, QWindow *window) {
+         Q_UNUSED(resource);
+diff --git a/qtwayland/src/compositor/configure.json b/qtwayland/src/compositor/configure.json
+index bcfd5215..da95d07b 100644
+--- a/qtwayland/src/compositor/configure.json
++++ b/qtwayland/src/compositor/configure.json
+@@ -7,6 +7,31 @@
+     "testDir": "../../config.tests",
+ 
+     "libraries": {
++        "wayland-client": {
++            "label": "Wayland client library",
++            "headers": "wayland-version.h",
++            "test": {
++                "main": [
++                    "#if WAYLAND_VERSION_MAJOR < 1",
++                    "# error Wayland 1.8.0 or higher required",
++                    "#endif",
++                    "#if WAYLAND_VERSION_MAJOR == 1",
++                    "# if WAYLAND_VERSION_MINOR < 8",
++                    "#  error Wayland 1.8.0 or higher required",
++                    "# endif",
++                    "# if WAYLAND_VERSION_MINOR == 8",
++                    "#  if WAYLAND_VERSION_MICRO < 0",
++                    "#   error Wayland 1.8.0 or higher required",
++                    "#  endif",
++                    "# endif",
++                    "#endif"
++                 ]
++            },
++            "sources": [
++                { "type": "pkgConfig", "args": "wayland-client" },
++                "-lwayland-client"
++            ]
++        },
+         "wayland-server": {
+             "label": "wayland-server",
+             "headers": "wayland-version.h",
+@@ -151,8 +176,7 @@
+                     "#endif"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "dmabuf-client-buffer": {
+             "label": "Linux Client dma-buf Buffer Sharing",
+@@ -176,8 +200,7 @@
+                     "return 0;"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "vulkan-server-buffer": {
+             "label": "Vulkan Buffer Sharing",
+@@ -195,7 +218,8 @@
+                     "exportAllocInfo.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR;",
+                     "return 0;"
+                 ]
+-            }
++            },
++            "use": "wayland-client"
+         }
+     },
+ 
+diff --git a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
+index 7889f575..64140672 100644
+--- a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
++++ b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
+@@ -40,6 +40,7 @@
+ #include "qwaylandeglwindow.h"
+ 
+ #include <QtWaylandClient/private/qwaylandscreen_p.h>
++#include <QtWaylandClient/private/qwaylandsurface_p.h>
+ #include "qwaylandglcontext.h"
+ 
+ #include <QtEglSupport/private/qeglconvenience_p.h>
+@@ -124,6 +125,7 @@ void QWaylandEglWindow::updateSurface(bool create)
+         }
+         mOffset = QPoint();
+     } else {
++        QReadLocker locker(&mSurfaceLock);
+         if (m_waylandEglWindow) {
+             int current_width, current_height;
+             static bool disableResizeCheck = qgetenv("QT_WAYLAND_DISABLE_RESIZECHECK").toInt();
+@@ -131,14 +133,16 @@ void QWaylandEglWindow::updateSurface(bool create)
+             if (!disableResizeCheck) {
+                 wl_egl_window_get_attached_size(m_waylandEglWindow, &current_width, &current_height);
+             }
+-            if (disableResizeCheck || (current_width != sizeWithMargins.width() || current_height != sizeWithMargins.height())) {
++            if (disableResizeCheck || (current_width != sizeWithMargins.width() || current_height != sizeWithMargins.height()) || m_requestedSize != sizeWithMargins) {
+                 wl_egl_window_resize(m_waylandEglWindow, sizeWithMargins.width(), sizeWithMargins.height(), mOffset.x(), mOffset.y());
++                m_requestedSize = sizeWithMargins;
+                 mOffset = QPoint();
+ 
+                 m_resize = true;
+             }
+-        } else if (create && wlSurface()) {
+-            m_waylandEglWindow = wl_egl_window_create(wlSurface(), sizeWithMargins.width(), sizeWithMargins.height());
++        } else if (create && mSurface) {
++            m_waylandEglWindow = wl_egl_window_create(mSurface->object(), sizeWithMargins.width(), sizeWithMargins.height());
++            m_requestedSize = sizeWithMargins;
+         }
+ 
+         if (!m_eglSurface && m_waylandEglWindow && create) {
+diff --git a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
+index 5b1f4d56..0079dfef 100644
+--- a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
++++ b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
+@@ -88,6 +88,7 @@ private:
+     mutable QOpenGLFramebufferObject *m_contentFBO = nullptr;
+ 
+     QSurfaceFormat m_format;
++    QSize m_requestedSize;
+ };
+ 
+ }
+diff --git a/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h b/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
+index 56a710c3..c6a8b6c6 100644
+--- a/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
++++ b/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
+@@ -41,6 +41,8 @@
+ #include <QtCore/QTextStream>
+ #include <QtGui/QOpenGLTexture>
+ 
++#include <array>
++
+ #include <EGL/egl.h>
+ #include <EGL/eglext.h>
+ 
+diff --git a/qtwayland/src/plugins/decorations/bradient/main.cpp b/qtwayland/src/plugins/decorations/bradient/main.cpp
+index e75fda3c..fa885143 100644
+--- a/qtwayland/src/plugins/decorations/bradient/main.cpp
++++ b/qtwayland/src/plugins/decorations/bradient/main.cpp
+@@ -164,13 +164,10 @@ void QWaylandBradientDecoration::paint(QPaintDevice *device)
+     // Window icon
+     QIcon icon = waylandWindow()->windowIcon();
+     if (!icon.isNull()) {
+-        QPixmap pixmap = icon.pixmap(QSize(128, 128));
+-        QPixmap scaled = pixmap.scaled(22, 22, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+-
+         QRectF iconRect(0, 0, 22, 22);
+-        p.drawPixmap(iconRect.adjusted(margins().left() + BUTTON_SPACING, 4,
+-                                       margins().left() + BUTTON_SPACING, 4),
+-                     scaled, iconRect);
++        iconRect.adjust(margins().left() + BUTTON_SPACING, 4,
++                        margins().left() + BUTTON_SPACING, 4),
++        icon.paint(&p, iconRect.toRect());
+     }
+ 
+     // Window title
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
+index 85d25e3c..60bdd491 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
+@@ -47,18 +47,21 @@ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
+-QWaylandXdgPopupV5::QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow *window)
++QWaylandXdgPopupV5::QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow* parent, QWaylandWindow *window)
+     : QWaylandShellSurface(window)
+     , QtWayland::xdg_popup_v5(popup)
++    , m_parent(parent)
+     , m_window(window)
+ {
+     if (window->display()->windowExtension())
+         m_extendedWindow = new QWaylandExtendedSurface(window);
++    m_parent->addChildPopup(m_window);
+ }
+ 
+ QWaylandXdgPopupV5::~QWaylandXdgPopupV5()
+ {
+     xdg_popup_destroy(object());
++    m_parent->removeChildPopup(m_window);
+     delete m_extendedWindow;
+ }
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
+index 7494f6a6..d85f130b 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
+@@ -70,7 +70,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgPopupV5 : public QWaylandShellSurface
+ {
+     Q_OBJECT
+ public:
+-    QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow *window);
++    QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow* parent, QWaylandWindow *window);
+     ~QWaylandXdgPopupV5() override;
+ 
+ protected:
+@@ -78,6 +78,7 @@ protected:
+ 
+ private:
+     QWaylandExtendedSurface *m_extendedWindow = nullptr;
++    QWaylandWindow *m_parent = nullptr;
+     QWaylandWindow *m_window = nullptr;
+ };
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
+index 7e242c4a..def8452a 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
+@@ -84,7 +84,7 @@ QWaylandXdgPopupV5 *QWaylandXdgShellV5::createXdgPopup(QWaylandWindow *window, Q
+     int x = position.x() + parentWindow->frameMargins().left();
+     int y = position.y() + parentWindow->frameMargins().top();
+ 
+-    auto popup = new QWaylandXdgPopupV5(get_xdg_popup(window->wlSurface(), parentSurface, seat, m_popupSerial, x, y), window);
++    auto popup = new QWaylandXdgPopupV5(get_xdg_popup(window->wlSurface(), parentSurface, seat, m_popupSerial, x, y), parentWindow, window);
+     m_popups.append(window);
+     QObject::connect(popup, &QWaylandXdgPopupV5::destroyed, [this, window](){
+         m_popups.removeOne(window);
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
+index 4e25949f..cfc60939 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
+@@ -85,13 +85,6 @@ QWaylandShellSurface *QWaylandXdgShellV5Integration::createShellSurface(QWayland
+     return m_xdgShell->createXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellV5Integration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) {
+-    if (newFocus && qobject_cast<QWaylandXdgPopupV5 *>(newFocus->shellSurface()))
+-        m_display->handleWindowActivated(newFocus);
+-    if (oldFocus && qobject_cast<QWaylandXdgPopupV5 *>(oldFocus->shellSurface()))
+-        m_display->handleWindowDeactivated(oldFocus);
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
+index ce6bdb9e..aed88670 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
+@@ -67,7 +67,6 @@ public:
+     QWaylandXdgShellV5Integration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShellV5> m_xdgShell;
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
+index 8c371661..151c78e3 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
+@@ -174,6 +174,7 @@ QWaylandXdgSurfaceV6::Popup::Popup(QWaylandXdgSurfaceV6 *xdgSurface, QWaylandXdg
+     , m_xdgSurface(xdgSurface)
+     , m_parent(parent)
+ {
++    m_parent->window()->addChildPopup(m_xdgSurface->window());
+ }
+ 
+ QWaylandXdgSurfaceV6::Popup::~Popup()
+@@ -181,6 +182,8 @@ QWaylandXdgSurfaceV6::Popup::~Popup()
+     if (isInitialized())
+         destroy();
+ 
++    m_parent->window()->removeChildPopup(m_xdgSurface->window());
++
+     if (m_grabbing) {
+         auto *shell = m_xdgSurface->m_shell;
+         Q_ASSERT(shell->m_topmostGrabbingPopup == this);
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
+index 03164316..e8da8ba1 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
+@@ -68,20 +68,6 @@ QWaylandShellSurface *QWaylandXdgShellV6Integration::createShellSurface(QWayland
+     return m_xdgShell->getXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellV6Integration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus)
+-{
+-    if (newFocus) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurfaceV6 *>(newFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowActivated(newFocus);
+-    }
+-    if (oldFocus && qobject_cast<QWaylandXdgSurfaceV6 *>(oldFocus->shellSurface())) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurfaceV6 *>(oldFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowDeactivated(oldFocus);
+-    }
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
+index 261f8cbb..c1bcd5c6 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
+@@ -65,7 +65,6 @@ public:
+     QWaylandXdgShellV6Integration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShellV6> m_xdgShell;
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
+index f3e3c330..fa6d5808 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
+@@ -67,11 +67,6 @@ QWaylandXdgSurface::Toplevel::Toplevel(QWaylandXdgSurface *xdgSurface)
+ 
+ QWaylandXdgSurface::Toplevel::~Toplevel()
+ {
+-    if (m_applied.states & Qt::WindowActive) {
+-        QWaylandWindow *window = m_xdgSurface->window();
+-        window->display()->handleWindowDeactivated(window);
+-    }
+-
+     // The protocol spec requires that the decoration object is deleted before xdg_toplevel.
+     delete m_decoration;
+     m_decoration = nullptr;
+@@ -85,16 +80,15 @@ void QWaylandXdgSurface::Toplevel::applyConfigure()
+     if (!(m_applied.states & (Qt::WindowMaximized|Qt::WindowFullScreen)))
+         m_normalSize = m_xdgSurface->m_window->windowFrameGeometry().size();
+ 
+-    if ((m_pending.states & Qt::WindowActive) && !(m_applied.states & Qt::WindowActive))
++    if ((m_pending.states & Qt::WindowActive) && !(m_applied.states & Qt::WindowActive)
++        && !m_xdgSurface->m_window->display()->isKeyboardAvailable())
+         m_xdgSurface->m_window->display()->handleWindowActivated(m_xdgSurface->m_window);
+ 
+-    if (!(m_pending.states & Qt::WindowActive) && (m_applied.states & Qt::WindowActive))
++    if (!(m_pending.states & Qt::WindowActive) && (m_applied.states & Qt::WindowActive)
++        && !m_xdgSurface->m_window->display()->isKeyboardAvailable())
+         m_xdgSurface->m_window->display()->handleWindowDeactivated(m_xdgSurface->m_window);
+ 
+-    // TODO: none of the other plugins send WindowActive either, but is it on purpose?
+-    Qt::WindowStates statesWithoutActive = m_pending.states & ~Qt::WindowActive;
+-
+-    m_xdgSurface->m_window->handleWindowStatesChanged(statesWithoutActive);
++    m_xdgSurface->m_window->handleWindowStatesChanged(m_pending.states);
+ 
+     if (m_pending.size.isEmpty()) {
+         // An empty size in the configure means it's up to the client to choose the size
+@@ -105,8 +99,6 @@ void QWaylandXdgSurface::Toplevel::applyConfigure()
+         m_xdgSurface->m_window->resizeFromApplyConfigure(m_pending.size);
+     }
+ 
+-    m_xdgSurface->setSizeHints();
+-
+     m_applied = m_pending;
+     qCDebug(lcQpaWayland) << "Applied pending xdg_toplevel configure event:" << m_applied.size << m_applied.states;
+ }
+@@ -203,12 +195,17 @@ QtWayland::xdg_toplevel::resize_edge QWaylandXdgSurface::Toplevel::convertToResi
+                 | ((edges & Qt::RightEdge) ? resize_edge_right : 0));
+ }
+ 
+-QWaylandXdgSurface::Popup::Popup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parent,
++QWaylandXdgSurface::Popup::Popup(QWaylandXdgSurface *xdgSurface, QWaylandWindow *parent,
+                                  QtWayland::xdg_positioner *positioner)
+-    : xdg_popup(xdgSurface->get_popup(parent->object(), positioner->object()))
+-    , m_xdgSurface(xdgSurface)
++    : m_xdgSurface(xdgSurface)
++    , m_parentXdgSurface(qobject_cast<QWaylandXdgSurface *>(parent->shellSurface()))
+     , m_parent(parent)
+ {
++
++    init(xdgSurface->get_popup(m_parentXdgSurface ? m_parentXdgSurface->object() : nullptr, positioner->object()));
++    if (m_parent) {
++        m_parent->addChildPopup(m_xdgSurface->window());
++    }
+ }
+ 
+ QWaylandXdgSurface::Popup::~Popup()
+@@ -216,10 +213,24 @@ QWaylandXdgSurface::Popup::~Popup()
+     if (isInitialized())
+         destroy();
+ 
++    if (m_parent) {
++        m_parent->removeChildPopup(m_xdgSurface->window());
++    }
++
+     if (m_grabbing) {
+         auto *shell = m_xdgSurface->m_shell;
+         Q_ASSERT(shell->m_topmostGrabbingPopup == this);
+-        shell->m_topmostGrabbingPopup = m_parent->m_popup;
++        shell->m_topmostGrabbingPopup = m_parentXdgSurface ? m_parentXdgSurface->m_popup : nullptr;
++        m_grabbing = false;
++
++        // Synthesize Qt enter/leave events for popup
++        QWindow *leave = nullptr;
++        if (m_xdgSurface && m_xdgSurface->window())
++            leave = m_xdgSurface->window()->window();
++        QWindowSystemInterface::handleLeaveEvent(leave);
++
++        if (QWindow *enter = QGuiApplication::topLevelAt(QCursor::pos()))
++            QWindowSystemInterface::handleEnterEvent(enter, enter->mapFromGlobal(QCursor::pos()), QCursor::pos());
+     }
+ }
+ 
+@@ -257,6 +268,7 @@ QWaylandXdgSurface::QWaylandXdgSurface(QWaylandXdgShell *shell, ::xdg_surface *s
+                 m_toplevel->set_parent(parentXdgSurface->m_toplevel->object());
+         }
+     }
++    setSizeHints();
+ }
+ 
+ QWaylandXdgSurface::~QWaylandXdgSurface()
+@@ -400,8 +412,6 @@ void QWaylandXdgSurface::setPopup(QWaylandWindow *parent)
+ {
+     Q_ASSERT(!m_toplevel && !m_popup);
+ 
+-    auto parentXdgSurface = static_cast<QWaylandXdgSurface *>(parent->shellSurface());
+-
+     auto positioner = new QtWayland::xdg_positioner(m_shell->create_positioner());
+     // set_popup expects a position relative to the parent
+     QPoint transientPos = m_window->geometry().topLeft(); // this is absolute
+@@ -414,8 +424,9 @@ void QWaylandXdgSurface::setPopup(QWaylandWindow *parent)
+     positioner->set_anchor(QtWayland::xdg_positioner::anchor_top_left);
+     positioner->set_gravity(QtWayland::xdg_positioner::gravity_bottom_right);
+     positioner->set_size(m_window->geometry().width(), m_window->geometry().height());
+-    m_popup = new Popup(this, parentXdgSurface, positioner);
++    m_popup = new Popup(this, parent, positioner);
+     positioner->destroy();
++
+     delete positioner;
+ }
+ 
+@@ -437,6 +448,23 @@ void QWaylandXdgSurface::setGrabPopup(QWaylandWindow *parent, QWaylandInputDevic
+     }
+     setPopup(parent);
+     m_popup->grab(device, serial);
++
++    // Synthesize Qt enter/leave events for popup
++    if (!parent)
++        return;
++    QWindow *current = QGuiApplication::topLevelAt(QCursor::pos());
++    QWindow *leave = parent->window();
++    if (current != leave)
++        return;
++
++    QWindowSystemInterface::handleLeaveEvent(leave);
++
++    QWindow *enter = nullptr;
++    if (m_popup && m_popup->m_xdgSurface && m_popup->m_xdgSurface->window())
++        enter = m_popup->m_xdgSurface->window()->window();
++
++    if (enter)
++        QWindowSystemInterface::handleEnterEvent(enter, enter->mapFromGlobal(QCursor::pos()), QCursor::pos());
+ }
+ 
+ void QWaylandXdgSurface::xdg_surface_configure(uint32_t serial)
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
+index 96785205..4b518f0a 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
+@@ -131,14 +131,15 @@ private:
+ 
+     class Popup : public QtWayland::xdg_popup {
+     public:
+-        Popup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parent, QtWayland::xdg_positioner *positioner);
++        Popup(QWaylandXdgSurface *xdgSurface, QWaylandWindow *parent, QtWayland::xdg_positioner *positioner);
+         ~Popup() override;
+ 
+         void grab(QWaylandInputDevice *seat, uint serial);
+         void xdg_popup_popup_done() override;
+ 
+         QWaylandXdgSurface *m_xdgSurface = nullptr;
+-        QWaylandXdgSurface *m_parent = nullptr;
++        QWaylandXdgSurface *m_parentXdgSurface = nullptr;
++        QWaylandWindow *m_parent = nullptr;
+         bool m_grabbing = false;
+     };
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
+index 8769d971..da0dd6a7 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
+@@ -69,20 +69,6 @@ QWaylandShellSurface *QWaylandXdgShellIntegration::createShellSurface(QWaylandWi
+     return m_xdgShell->getXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellIntegration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus)
+-{
+-    if (newFocus) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurface *>(newFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowActivated(newFocus);
+-    }
+-    if (oldFocus && qobject_cast<QWaylandXdgSurface *>(oldFocus->shellSurface())) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurface *>(oldFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowDeactivated(oldFocus);
+-    }
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
+index b6caa6c9..2f929f98 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
+@@ -65,7 +65,6 @@ public:
+     QWaylandXdgShellIntegration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShell> m_xdgShell;
+diff --git a/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp b/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
+index 526d0ef4..f50ccf30 100644
+--- a/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
++++ b/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
+@@ -39,7 +39,10 @@
+ 
+ #include "qwaylandinputmethodeventbuilder_p.h"
+ 
++#include <QBrush>
++#include <QGuiApplication>
+ #include <QInputMethod>
++#include <QPalette>
+ #include <QTextCharFormat>
+ 
+ #ifdef QT_BUILD_WAYLANDCOMPOSITOR_LIB
+@@ -81,32 +84,38 @@ void QWaylandInputMethodEventBuilder::addPreeditStyling(uint32_t index, uint32_t
+     QTextCharFormat format;
+ 
+     switch (style) {
+-    case 0:
+-    case 1:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_NONE:
++        break;
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_DEFAULT:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_UNDERLINE:
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-    case 2:
+-    case 3:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_ACTIVE:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_INACTIVE:
+         format.setFontWeight(QFont::Bold);
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-    case 4:
+-        format.setFontUnderline(true);
+-        format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+-        m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_HIGHLIGHT:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_SELECTION:
++        {
++            format.setFontUnderline(true);
++            format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
++            QPalette palette = qApp->palette();
++            format.setBackground(QBrush(palette.color(QPalette::Active, QPalette::Highlight)));
++            format.setForeground(QBrush(palette.color(QPalette::Active, QPalette::HighlightedText)));
++            m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
++        }
+         break;
+-    case 5:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_INCORRECT:
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::WaveUnderline);
+         format.setUnderlineColor(QColor(Qt::red));
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-//    case QtWayland::wl_text_input::preedit_style_selection:
+-//    case QtWayland::wl_text_input::preedit_style_none:
+     default:
+         break;
+     }
+@@ -153,7 +162,7 @@ QInputMethodEvent QWaylandInputMethodEventBuilder::buildPreedit(const QString &t
+ 
+     if (m_preeditCursor < 0) {
+         attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, 0, QVariant()));
+-    } else if (m_preeditCursor > 0) {
++    } else {
+         attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, indexFromWayland(text, m_preeditCursor), 1, QVariant()));
+     }
+ 
+diff --git a/qtwayland/src/shared/qwaylandmimehelper.cpp b/qtwayland/src/shared/qwaylandmimehelper.cpp
+index a5fdd34d..e2fe1928 100644
+--- a/qtwayland/src/shared/qwaylandmimehelper.cpp
++++ b/qtwayland/src/shared/qwaylandmimehelper.cpp
+@@ -60,7 +60,7 @@ QByteArray QWaylandMimeHelper::getByteArray(QMimeData *mimeData, const QString &
+             buf.open(QIODevice::ReadWrite);
+             QByteArray fmt = "BMP";
+             if (mimeType.startsWith(QLatin1String("image/"))) {
+-                QByteArray imgFmt = mimeType.mid(6).toUpper().toLatin1();
++                QByteArray imgFmt = mimeType.mid(6).toLower().toLatin1();
+                 if (QImageWriter::supportedImageFormats().contains(imgFmt))
+                     fmt = imgFmt;
+             }
+@@ -74,7 +74,7 @@ QByteArray QWaylandMimeHelper::getByteArray(QMimeData *mimeData, const QString &
+         QList<QUrl> urls = mimeData->urls();
+         for (int i = 0; i < urls.count(); ++i) {
+             content.append(urls.at(i).toEncoded());
+-            content.append('\n');
++            content.append("\r\n");
+         }
+     } else {
+         content = mimeData->data(mimeType);
+diff --git a/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp b/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
+index 1568b3b9..067410d0 100644
+--- a/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
++++ b/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
+@@ -35,7 +35,7 @@
+ 
+ using namespace MockCompositor;
+ 
+-constexpr int dataDeviceVersion = 1;
++constexpr int dataDeviceVersion = 3;
+ 
+ class DataDeviceCompositor : public DefaultCompositor {
+ public:
+diff --git a/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp b/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
+index 9312c2e5..2ea382f1 100644
+--- a/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
++++ b/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
+@@ -73,6 +73,7 @@ private slots:
+     void multiTouch();
+     void multiTouchUpAndMotionFrame();
+     void tapAndMoveInSameFrame();
++    void cancelTouch();
+ };
+ 
+ void tst_seatv5::bindsToSeat()
+@@ -646,5 +647,34 @@ void tst_seatv5::tapAndMoveInSameFrame()
+     QTRY_COMPARE(window.m_events.last().touchPoints.first().state(), Qt::TouchPointState::TouchPointReleased);
+ }
+ 
++void tst_seatv5::cancelTouch()
++{
++    TouchWindow window;
++    QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
++
++    exec([=] {
++        auto *t = touch();
++        auto *c = client();
++        t->sendDown(xdgToplevel()->surface(), {32, 32}, 1);
++        t->sendFrame(c);
++        t->sendCancel(c);
++        t->sendFrame(c);
++    });
++
++    QTRY_VERIFY(!window.m_events.empty());
++    {
++        auto e = window.m_events.takeFirst();
++        QCOMPARE(e.type, QEvent::TouchBegin);
++        QCOMPARE(e.touchPointStates, Qt::TouchPointPressed);
++        QCOMPARE(e.touchPoints.length(), 1);
++        QCOMPARE(e.touchPoints.first().pos(), QPointF(32-window.frameMargins().left(), 32-window.frameMargins().top()));
++    }
++    {
++        auto e = window.m_events.takeFirst();
++        QCOMPARE(e.type, QEvent::TouchCancel);
++        QCOMPARE(e.touchPoints.length(), 0);
++    }
++}
++
+ QCOMPOSITOR_TEST_MAIN(tst_seatv5)
+ #include "tst_seatv5.moc"
+diff --git a/qtwayland/tests/auto/client/shared/corecompositor.cpp b/qtwayland/tests/auto/client/shared/corecompositor.cpp
+index 5c6c83ba..fa9b7662 100644
+--- a/qtwayland/tests/auto/client/shared/corecompositor.cpp
++++ b/qtwayland/tests/auto/client/shared/corecompositor.cpp
+@@ -27,6 +27,7 @@
+ ****************************************************************************/
+ 
+ #include "corecompositor.h"
++#include <thread>
+ 
+ namespace MockCompositor {
+ 
+diff --git a/qtwayland/tests/auto/client/shared/coreprotocol.cpp b/qtwayland/tests/auto/client/shared/coreprotocol.cpp
+index 0d988521..d1a2e7cb 100644
+--- a/qtwayland/tests/auto/client/shared/coreprotocol.cpp
++++ b/qtwayland/tests/auto/client/shared/coreprotocol.cpp
+@@ -451,6 +451,13 @@ void Touch::sendFrame(wl_client *client)
+         send_frame(r->handle);
+ }
+ 
++void Touch::sendCancel(wl_client *client)
++{
++    const auto touchResources = resourceMap().values(client);
++    for (auto *r : touchResources)
++        send_cancel(r->handle);
++}
++
+ uint Keyboard::sendEnter(Surface *surface)
+ {
+     auto serial = m_seat->m_compositor->nextSerial();
+diff --git a/qtwayland/tests/auto/client/shared/coreprotocol.h b/qtwayland/tests/auto/client/shared/coreprotocol.h
+index a1af137a..210d8ddb 100644
+--- a/qtwayland/tests/auto/client/shared/coreprotocol.h
++++ b/qtwayland/tests/auto/client/shared/coreprotocol.h
+@@ -158,7 +158,7 @@ class WlCompositor : public Global, public QtWaylandServer::wl_compositor
+ {
+     Q_OBJECT
+ public:
+-    explicit WlCompositor(CoreCompositor *compositor, int version = 3)
++    explicit WlCompositor(CoreCompositor *compositor, int version = 4)
+         : QtWaylandServer::wl_compositor(compositor->m_display, version)
+         , m_compositor(compositor)
+     {}
+@@ -364,6 +364,7 @@ public:
+     uint sendUp(wl_client *client, int id);
+     void sendMotion(wl_client *client, const QPointF &position, int id);
+     void sendFrame(wl_client *client);
++    void sendCancel(wl_client *client);
+ 
+     Seat *m_seat = nullptr;
+ };
+diff --git a/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp b/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
+index a415cbf5..b1d3d07d 100644
+--- a/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
++++ b/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
+@@ -342,7 +342,7 @@ Compositor::Compositor(MockCompositor *mockCompositor)
+         exit(EXIT_FAILURE);
+     }
+ 
+-    wl_global_create(m_display, &wl_compositor_interface, 1, this, bindCompositor);
++    wl_global_create(m_display, &wl_compositor_interface, 4, this, bindCompositor);
+ 
+     m_data_device_manager.reset(new DataDeviceManager(this, m_display));
+ 
+diff --git a/qtwayland/tests/auto/client/shared_old/mocksurface.cpp b/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
+index e9df5f90..c3246e4a 100644
+--- a/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
++++ b/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
+@@ -125,6 +125,16 @@ void Surface::surface_damage(Resource *resource,
+     Q_UNUSED(height);
+ }
+ 
++void Surface::surface_damage_buffer(Resource *resource,
++                                    int32_t x, int32_t y, int32_t width, int32_t height)
++{
++    Q_UNUSED(resource);
++    Q_UNUSED(x);
++    Q_UNUSED(y);
++    Q_UNUSED(width);
++    Q_UNUSED(height);
++}
++
+ void Surface::surface_frame(Resource *resource,
+                             uint32_t callback)
+ {
+diff --git a/qtwayland/tests/auto/client/shared_old/mocksurface.h b/qtwayland/tests/auto/client/shared_old/mocksurface.h
+index 949dc23d..d176837e 100644
+--- a/qtwayland/tests/auto/client/shared_old/mocksurface.h
++++ b/qtwayland/tests/auto/client/shared_old/mocksurface.h
+@@ -65,6 +65,8 @@ protected:
+                         struct wl_resource *buffer, int x, int y) override;
+     void surface_damage(Resource *resource,
+                         int32_t x, int32_t y, int32_t width, int32_t height) override;
++    void surface_damage_buffer(Resource *resource,
++                               int32_t x, int32_t y, int32_t width, int32_t height) override;
+     void surface_frame(Resource *resource,
+                        uint32_t callback) override;
+     void surface_commit(Resource *resource) override;
+diff --git a/qtwayland/tests/auto/client/surface/tst_surface.cpp b/qtwayland/tests/auto/client/surface/tst_surface.cpp
+index 95e4e609..60c672ce 100644
+--- a/qtwayland/tests/auto/client/surface/tst_surface.cpp
++++ b/qtwayland/tests/auto/client/surface/tst_surface.cpp
+@@ -129,6 +129,10 @@ void tst_surface::waitForFrameCallbackGl()
+     // Make sure we follow frame callbacks for some frames
+     for (int i = 0; i < 5; ++i) {
+         xdgPingAndWaitForPong(); // Make sure things have happened on the client
++        if (!qEnvironmentVariableIntValue("QT_WAYLAND_DISABLE_WINDOWDECORATION") && i == 0) {
++            QCOMPARE(bufferSpy.count(), 1);
++            bufferSpy.removeFirst();
++        }
+         exec([&] {
+             QVERIFY(bufferSpy.empty()); // Make sure no extra buffers have arrived
+             QVERIFY(!xdgToplevel()->surface()->m_waitingFrameCallbacks.empty());
+diff --git a/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp b/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
+index 2277bbb8..747875b4 100644
+--- a/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
++++ b/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
+@@ -31,6 +31,7 @@
+ #include <QtGui/QOpenGLWindow>
+ #include <QtGui/qpa/qplatformnativeinterface.h>
+ #include <QtWaylandClient/private/wayland-wayland-client-protocol.h>
++#include <QtWaylandClient/private/qwaylandwindow_p.h>
+ 
+ using namespace MockCompositor;
+ 
+@@ -45,6 +46,7 @@ private slots:
+     void configureStates();
+     void popup();
+     void tooltipOnPopup();
++    void tooltipAndSiblingPopup();
+     void switchPopups();
+     void hidePopupParent();
+     void pongs();
+@@ -138,6 +140,7 @@ void tst_xdgshell::configureSize()
+ 
+ void tst_xdgshell::configureStates()
+ {
++    QVERIFY(qputenv("QT_WAYLAND_FRAME_CALLBACK_TIMEOUT", "0"));
+     QRasterWindow window;
+     window.resize(64, 48);
+     window.show();
+@@ -154,9 +157,12 @@ void tst_xdgshell::configureStates()
+     // Toplevel windows don't know their position on xdg-shell
+ //    QCOMPARE(window.frameGeometry().topLeft(), QPoint()); // TODO: this doesn't currently work when window decorations are enabled
+ 
+-//    QEXPECT_FAIL("", "configure has already been acked, we shouldn't have to wait for isActive", Continue);
+-//    QVERIFY(window.isActive());
+-    QTRY_VERIFY(window.isActive()); // Just make sure it eventually get's set correctly
++    // window.windowstate() is driven by keyboard focus, however for decorations we want to follow
++    // XDGShell this is internal to QtWayland so it is queried directly
++    auto waylandWindow = static_cast<QtWaylandClient::QWaylandWindow *>(window.handle());
++    Q_ASSERT(waylandWindow);
++    QTRY_VERIFY(waylandWindow->windowStates().testFlag(
++            Qt::WindowActive)); // Just make sure it eventually get's set correctly
+ 
+     const QSize screenSize(640, 480);
+     const uint maximizedSerial = exec([=] {
+@@ -186,6 +192,7 @@ void tst_xdgshell::configureStates()
+     QCOMPARE(window.windowStates(), Qt::WindowNoState);
+     QCOMPARE(window.frameGeometry().size(), windowedSize);
+ //    QCOMPARE(window.frameGeometry().topLeft(), QPoint()); // TODO: this doesn't currently work when window decorations are enabled
++    QVERIFY(qunsetenv("QT_WAYLAND_FRAME_CALLBACK_TIMEOUT"));
+ }
+ 
+ void tst_xdgshell::popup()
+@@ -340,6 +347,92 @@ void tst_xdgshell::tooltipOnPopup()
+     QCOMPOSITOR_TRY_COMPARE(xdgPopup(0), nullptr);
+ }
+ 
++void tst_xdgshell::tooltipAndSiblingPopup()
++{
++    class ToolTip : public QRasterWindow {
++    public:
++        explicit ToolTip(QWindow *parent) {
++            setTransientParent(parent);
++            setFlags(Qt::ToolTip);
++            resize(100, 100);
++            show();
++        }
++        void mousePressEvent(QMouseEvent *event) override {
++            QRasterWindow::mousePressEvent(event);
++            m_popup = new QRasterWindow;
++            m_popup->setTransientParent(transientParent());
++            m_popup->setFlags(Qt::Popup);
++            m_popup->resize(100, 100);
++            m_popup->show();
++        }
++
++        QRasterWindow *m_popup = nullptr;
++    };
++
++    class Window : public QRasterWindow {
++    public:
++        void mousePressEvent(QMouseEvent *event) override {
++            QRasterWindow::mousePressEvent(event);
++            m_tooltip = new ToolTip(this);
++        }
++        ToolTip *m_tooltip = nullptr;
++    };
++
++    Window window;
++    window.resize(200, 200);
++    window.show();
++
++    QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
++    exec([=] { xdgToplevel()->sendCompleteConfigure(); });
++    QCOMPOSITOR_TRY_VERIFY(xdgToplevel()->m_xdgSurface->m_committedConfigureSerial);
++
++    exec([=] {
++        auto *surface = xdgToplevel()->surface();
++        auto *p = pointer();
++        auto *c = client();
++        p->sendEnter(surface, {100, 100});
++        p->sendFrame(c);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_pressed);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_released);
++        p->sendFrame(c);
++        p->sendLeave(surface);
++        p->sendFrame(c);
++    });
++
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup());
++    exec([=] { xdgPopup()->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup()->m_xdgSurface->m_committedConfigureSerial);
++    QCOMPOSITOR_TRY_VERIFY(!xdgPopup()->m_grabbed);
++
++    exec([=] {
++        auto *surface = xdgPopup()->surface();
++        auto *p = pointer();
++        auto *c = client();
++        p->sendEnter(surface, {100, 100});
++        p->sendFrame(c);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_pressed);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_released);
++        p->sendFrame(c);
++    });
++
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1));
++    exec([=] { xdgPopup(1)->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1)->m_xdgSurface->m_committedConfigureSerial);
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1)->m_grabbed);
++
++    // Close the middle tooltip (it should not close the sibling popup)
++    window.m_tooltip->close();
++
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(1), nullptr);
++    // Verify the remaining xdg surface is a grab popup..
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(0));
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(0)->m_grabbed);
++
++    window.m_tooltip->m_popup->close();
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(1), nullptr);
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(0), nullptr);
++}
++
+ // QTBUG-65680
+ void tst_xdgshell::switchPopups()
+ {
+@@ -505,7 +598,7 @@ void tst_xdgshell::minMaxSize()
+     window.show();
+     QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
+ 
+-    exec([=] { xdgToplevel()->sendCompleteConfigure(); });
++    // we don't roundtrip with our configuration the initial commit should be correct
+ 
+     QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.minSize, QSize(100, 100));
+     QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.maxSize, QSize(1000, 1000));
+Submodule qtwebchannel 618422ee..f8949655:
+diff --git a/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp b/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
+index 536eb5c..898d769 100644
+--- a/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
++++ b/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
+@@ -186,8 +186,6 @@ Q_DECLARE_TYPEINFO(OverloadResolutionCandidate, Q_MOVABLE_TYPE);
+ QMetaObjectPublisher::QMetaObjectPublisher(QWebChannel *webChannel)
+     : QObject(webChannel)
+     , webChannel(webChannel)
+-    , signalHandler(this)
+-    , clientIsIdle(false)
+     , blockUpdates(false)
+     , propertyUpdatesInitialized(false)
+ {
+@@ -301,17 +299,17 @@ QJsonObject QMetaObjectPublisher::classInfoForObject(const QObject *object, QWeb
+     return data;
+ }
+ 
+-void QMetaObjectPublisher::setClientIsIdle(bool isIdle)
++void QMetaObjectPublisher::setClientIsIdle(bool isIdle, QWebChannelAbstractTransport *transport)
+ {
+-    if (clientIsIdle == isIdle) {
+-        return;
+-    }
+-    clientIsIdle = isIdle;
+-    if (!isIdle && timer.isActive()) {
+-        timer.stop();
+-    } else if (isIdle && !timer.isActive()) {
+-        timer.start(PROPERTY_UPDATE_INTERVAL, this);
+-    }
++    transportState[transport].clientIsIdle = isIdle;
++    if (isIdle)
++        sendEnqueuedPropertyUpdates(transport);
++}
++
++bool QMetaObjectPublisher::isClientIdle(QWebChannelAbstractTransport *transport)
++{
++    auto found = transportState.find(transport);
++    return found != transportState.end() && found.value().clientIsIdle;
+ }
+ 
+ QJsonObject QMetaObjectPublisher::initializeClient(QWebChannelAbstractTransport *transport)
+@@ -333,6 +331,7 @@ QJsonObject QMetaObjectPublisher::initializeClient(QWebChannelAbstractTransport
+ 
+ void QMetaObjectPublisher::initializePropertyUpdates(const QObject *const object, const QJsonObject &objectInfo)
+ {
++    auto *signalHandler = signalHandlerFor(object);
+     foreach (const QJsonValue &propertyInfoVar, objectInfo[KEY_PROPERTIES].toArray()) {
+         const QJsonArray &propertyInfo = propertyInfoVar.toArray();
+         if (propertyInfo.size() < 2) {
+@@ -353,19 +352,19 @@ void QMetaObjectPublisher::initializePropertyUpdates(const QObject *const object
+ 
+         // Only connect for a property update once
+         if (connectedProperties.isEmpty()) {
+-            signalHandler.connectTo(object, signalIndex);
++            signalHandler->connectTo(object, signalIndex);
+         }
+ 
+         connectedProperties.insert(propertyIndex);
+     }
+ 
+     // also always connect to destroyed signal
+-    signalHandler.connectTo(object, s_destroyedSignalIndex);
++    signalHandler->connectTo(object, s_destroyedSignalIndex);
+ }
+ 
+ void QMetaObjectPublisher::sendPendingPropertyUpdates()
+ {
+-    if (blockUpdates || !clientIsIdle || pendingPropertyUpdates.isEmpty()) {
++    if (blockUpdates) {
+         return;
+     }
+ 
+@@ -415,18 +414,19 @@ void QMetaObjectPublisher::sendPendingPropertyUpdates()
+ 
+     // data does not contain specific updates
+     if (!data.isEmpty()) {
+-        setClientIsIdle(false);
+-
+         message[KEY_DATA] = data;
+-        broadcastMessage(message);
++        enqueueBroadcastMessage(message);
+     }
+ 
+     // send every property update which is not supposed to be broadcasted
+     const QHash<QWebChannelAbstractTransport*, QJsonArray>::const_iterator suend = specificUpdates.constEnd();
+     for (QHash<QWebChannelAbstractTransport*, QJsonArray>::const_iterator it = specificUpdates.constBegin(); it != suend; ++it) {
+         message[KEY_DATA] = it.value();
+-        it.key()->sendMessage(message);
++        enqueueMessage(message, it.key());
+     }
++
++    for (auto state = transportState.begin(); state != transportState.end(); ++state)
++        sendEnqueuedPropertyUpdates(state.key());
+ }
+ 
+ QVariant QMetaObjectPublisher::invokeMethod(QObject *const object, const QMetaMethod &method,
+@@ -572,7 +572,7 @@ void QMetaObjectPublisher::signalEmitted(const QObject *object, const int signal
+         }
+     } else {
+         pendingPropertyUpdates[object][signalIndex] = arguments;
+-        if (clientIsIdle && !blockUpdates && !timer.isActive()) {
++        if (!blockUpdates && !timer.isActive()) {
+             timer.start(PROPERTY_UPDATE_INTERVAL, this);
+         }
+     }
+@@ -590,7 +590,7 @@ void QMetaObjectPublisher::objectDestroyed(const QObject *object)
+     // only remove from handler when we initialized the property updates
+     // cf: https://bugreports.qt.io/browse/QTBUG-60250
+     if (propertyUpdatesInitialized) {
+-        signalHandler.remove(object);
++        signalHandlerFor(object)->remove(object);
+         signalToPropertyMap.remove(object);
+     }
+     pendingPropertyUpdates.remove(object);
+@@ -852,6 +852,52 @@ void QMetaObjectPublisher::broadcastMessage(const QJsonObject &message) const
+     }
+ }
+ 
++void QMetaObjectPublisher::enqueueBroadcastMessage(const QJsonObject &message)
++{
++    if (webChannel->d_func()->transports.isEmpty()) {
++        qWarning("QWebChannel is not connected to any transports, cannot send message: %s",
++                 QJsonDocument(message).toJson().constData());
++        return;
++    }
++
++    for (auto *transport : webChannel->d_func()->transports) {
++        auto &state = transportState[transport];
++        state.queuedMessages.append(message);
++    }
++}
++
++void QMetaObjectPublisher::enqueueMessage(const QJsonObject &message,
++                                          QWebChannelAbstractTransport *transport)
++{
++    auto &state = transportState[transport];
++    state.queuedMessages.append(message);
++}
++
++void QMetaObjectPublisher::sendEnqueuedPropertyUpdates(QWebChannelAbstractTransport *transport)
++{
++    auto found = transportState.find(transport);
++    if (found != transportState.end() && found.value().clientIsIdle
++        && !found.value().queuedMessages.isEmpty()) {
++
++        // If the client is connected with an in-process transport, it can
++        // happen that a message triggers a subsequent property change. In
++        // that case, we need to ensure that the queued messages have already
++        // been cleared; otherwise the recursive call will send everythig again.
++        // Case in point: The qmlwebchannel tests fail if we don't clear the
++        // queued messages before sending them out.
++        // For that same reason set the client to "busy" (aka non-idle) just
++        // right before sending out the messages; otherwise a potential
++        // "Idle" type message will not correctly restore the Idle state.
++        const auto messages = std::move(found.value().queuedMessages);
++        Q_ASSERT(found.value().queuedMessages.isEmpty());
++        found.value().clientIsIdle = false;
++
++        for (const auto &message : messages) {
++            transport->sendMessage(message);
++        }
++    }
++}
++
+ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannelAbstractTransport *transport)
+ {
+     if (!webChannel->d_func()->transports.contains(transport)) {
+@@ -866,7 +912,7 @@ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannel
+ 
+     const MessageType type = toType(message.value(KEY_TYPE));
+     if (type == TypeIdle) {
+-        setClientIsIdle(true);
++        setClientIsIdle(true, transport);
+     } else if (type == TypeInit) {
+         if (!message.contains(KEY_ID)) {
+             qWarning("JSON message object is missing the id property: %s",
+@@ -913,9 +959,9 @@ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannel
+                 return;
+             transport->sendMessage(createResponse(message.value(KEY_ID), wrapResult(result, transport)));
+         } else if (type == TypeConnectToSignal) {
+-            signalHandler.connectTo(object, message.value(KEY_SIGNAL).toInt(-1));
++            signalHandlerFor(object)->connectTo(object, message.value(KEY_SIGNAL).toInt(-1));
+         } else if (type == TypeDisconnectFromSignal) {
+-            signalHandler.disconnectFrom(object, message.value(KEY_SIGNAL).toInt(-1));
++            signalHandlerFor(object)->disconnectFrom(object, message.value(KEY_SIGNAL).toInt(-1));
+         } else if (type == TypeSetProperty) {
+             setProperty(object, message.value(KEY_PROPERTY).toInt(-1),
+                         message.value(KEY_VALUE));
+@@ -931,6 +977,7 @@ void QMetaObjectPublisher::setBlockUpdates(bool block)
+     blockUpdates = block;
+ 
+     if (!blockUpdates) {
++        timer.start(PROPERTY_UPDATE_INTERVAL, this);
+         sendPendingPropertyUpdates();
+     } else if (timer.isActive()) {
+         timer.stop();
+@@ -948,4 +995,15 @@ void QMetaObjectPublisher::timerEvent(QTimerEvent *event)
+     }
+ }
+ 
++SignalHandler<QMetaObjectPublisher> *QMetaObjectPublisher::signalHandlerFor(const QObject *object)
++{
++    auto thread = object->thread();
++    auto it = signalHandlers.find(thread);
++    if (it == signalHandlers.end()) {
++        it = signalHandlers.emplace(thread, this).first;
++        it->second.moveToThread(thread);
++    }
++    return &it->second;
++}
++
+ QT_END_NAMESPACE
+diff --git a/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h b/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
+index bbd9875..4713ef1 100644
+--- a/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
++++ b/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
+@@ -59,6 +59,9 @@
+ #include <QBasicTimer>
+ #include <QPointer>
+ #include <QJsonObject>
++#include <QQueue>
++
++#include <unordered_map>
+ 
+ #include "qwebchannelglobal.h"
+ 
+@@ -109,17 +112,36 @@ public:
+      */
+     void broadcastMessage(const QJsonObject &message) const;
+ 
++    /**
++     * Enqueue the given @p message to all known transports.
++     */
++    void enqueueBroadcastMessage(const QJsonObject &message);
++
++    /**
++     * Enqueue the given @p message to @p transport.
++     */
++    void enqueueMessage(const QJsonObject &message, QWebChannelAbstractTransport *transport);
++
++    /**
++     * If client for given @p transport is idle, send queued messaged to @p transport and then mark
++     * the client as not idle.
++     */
++    void sendEnqueuedPropertyUpdates(QWebChannelAbstractTransport *transport);
++
+     /**
+      * Serialize the QMetaObject of @p object and return it in JSON form.
+      */
+     QJsonObject classInfoForObject(const QObject *object, QWebChannelAbstractTransport *transport);
+ 
+     /**
+-     * Set the client to idle or busy, based on the value of @p isIdle.
+-     *
+-     * When the value changed, start/stop the property update timer accordingly.
++     * Set the client to idle or busy for a single @p transport, based on the value of @p isIdle.
++     */
++    void setClientIsIdle(bool isIdle, QWebChannelAbstractTransport *transport);
++
++    /**
++     * Check that client is idle for @p transport.
+      */
+-    void setClientIsIdle(bool isIdle);
++    bool isClientIdle(QWebChannelAbstractTransport *transport);
+ 
+     /**
+      * Initialize clients by sending them the class information of the registered objects.
+@@ -272,10 +294,18 @@ private:
+     friend class TestWebChannel;
+ 
+     QWebChannel *webChannel;
+-    SignalHandler<QMetaObjectPublisher> signalHandler;
++    std::unordered_map<const QThread*, SignalHandler<QMetaObjectPublisher>> signalHandlers;
++    SignalHandler<QMetaObjectPublisher> *signalHandlerFor(const QObject *object);
+ 
+-    // true when the client is idle, false otherwise
+-    bool clientIsIdle;
++    struct TransportState
++    {
++        TransportState() : clientIsIdle(false) { }
++        // true when the client is idle, false otherwise
++        bool clientIsIdle;
++        // messages to send
++        QQueue<QJsonObject> queuedMessages;
++    };
++    QHash<QWebChannelAbstractTransport *, TransportState> transportState;
+ 
+     // true when no property updates should be sent, false otherwise
+     bool blockUpdates;
+diff --git a/qtwebchannel/src/webchannel/signalhandler_p.h b/qtwebchannel/src/webchannel/signalhandler_p.h
+index 27afadb..d77373c 100644
+--- a/qtwebchannel/src/webchannel/signalhandler_p.h
++++ b/qtwebchannel/src/webchannel/signalhandler_p.h
+@@ -56,6 +56,7 @@
+ #include <QVector>
+ #include <QMetaMethod>
+ #include <QDebug>
++#include <QThread>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -71,6 +72,7 @@ static const int s_destroyedSignalIndex = QObject::staticMetaObject.indexOfMetho
+ template<class Receiver>
+ class SignalHandler : public QObject
+ {
++    Q_DISABLE_COPY(SignalHandler)
+ public:
+     SignalHandler(Receiver *receiver, QObject *parent = 0);
+ 
+@@ -268,6 +270,7 @@ int SignalHandler<Receiver>::qt_metacall(QMetaObject::Call call, int methodId, v
+     if (call == QMetaObject::InvokeMetaMethod) {
+         const QObject *object = sender();
+         Q_ASSERT(object);
++        Q_ASSERT(QThread::currentThread() == object->thread());
+         Q_ASSERT(senderSignalIndex() == methodId);
+         Q_ASSERT(m_connectionsCounter.contains(object));
+         Q_ASSERT(m_connectionsCounter.value(object).contains(methodId));
+diff --git a/qtwebchannel/tests/auto/qml/testwebchannel.cpp b/qtwebchannel/tests/auto/qml/testwebchannel.cpp
+index 9891687..3ca81c2 100644
+--- a/qtwebchannel/tests/auto/qml/testwebchannel.cpp
++++ b/qtwebchannel/tests/auto/qml/testwebchannel.cpp
+@@ -46,7 +46,11 @@ TestWebChannel::~TestWebChannel()
+ 
+ bool TestWebChannel::clientIsIdle() const
+ {
+-    return QWebChannel::d_func()->publisher->clientIsIdle;
++    for (auto *transport : QWebChannel::d_func()->transports) {
++        if (QWebChannel::d_func()->publisher->isClientIdle(transport))
++            return true;
++    }
++    return false;
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp b/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
+index 181da9e..37f989a 100644
+--- a/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
++++ b/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
+@@ -785,7 +785,7 @@ void TestWebChannel::testTransportWrapObjectProperties()
+     DummyTransport *dummyTransport = new DummyTransport(this);
+     channel.connectTo(dummyTransport);
+     channel.d_func()->publisher->initializeClient(dummyTransport);
+-    channel.d_func()->publisher->setClientIsIdle(true);
++    channel.d_func()->publisher->setClientIsIdle(true, dummyTransport);
+ 
+     QCOMPARE(channel.d_func()->publisher->transportedWrappedObjects.size(), 0);
+ 
+@@ -943,8 +943,6 @@ void TestWebChannel::testInfiniteRecursion()
+ 
+ void TestWebChannel::testAsyncObject()
+ {
+-    QSKIP("This test is broken. See QTBUG-80729");
+-
+     QWebChannel channel;
+     channel.connectTo(m_dummyTransport);
+ 
+@@ -990,6 +988,50 @@ void TestWebChannel::testAsyncObject()
+     thread.wait();
+ }
+ 
++void TestWebChannel::testPropertyMultipleTransports()
++{
++    DummyTransport transport1;
++    DummyTransport transport2;
++
++    QWebChannel channel;
++    QMetaObjectPublisher *publisher = channel.d_func()->publisher;
++
++    TestObject testObj;
++    testObj.setObjectName("testObject");
++    channel.registerObject(testObj.objectName(), &testObj);
++    channel.connectTo(&transport1);
++    channel.connectTo(&transport2);
++
++    testObj.setProp("Hello");
++
++    publisher->initializeClient(&transport1);
++    publisher->initializeClient(&transport2);
++    publisher->setClientIsIdle(true, &transport1);
++    QCOMPARE(publisher->isClientIdle(&transport1), true);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++    QVERIFY(transport1.messagesSent().isEmpty());
++    QVERIFY(transport2.messagesSent().isEmpty());
++
++    testObj.setProp("World");
++    QTRY_COMPARE_WITH_TIMEOUT(transport1.messagesSent().size(), 1u, 2000);
++    QCOMPARE(transport2.messagesSent().size(), 0u);
++    publisher->setClientIsIdle(true, &transport2);
++    QTRY_COMPARE_WITH_TIMEOUT(transport2.messagesSent().size(), 1u, 2000);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++
++    testObj.setProp("!!!");
++    publisher->setClientIsIdle(true, &transport2);
++    QCOMPARE(publisher->isClientIdle(&transport2), true);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QTRY_COMPARE_WITH_TIMEOUT(transport2.messagesSent().size(), 2u, 2000);
++    QCOMPARE(transport1.messagesSent().size(), 1u);
++    publisher->setClientIsIdle(true, &transport1);
++    QTRY_COMPARE_WITH_TIMEOUT(transport1.messagesSent().size(), 2u, 2000);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++}
++
+ class FunctionWrapper : public QObject
+ {
+     Q_OBJECT
+@@ -1082,7 +1124,7 @@ void TestWebChannel::benchInitializeClients()
+ 
+         publisher->propertyUpdatesInitialized = false;
+         publisher->signalToPropertyMap.clear();
+-        publisher->signalHandler.clear();
++        publisher->signalHandlers.clear();
+     }
+ }
+ 
+@@ -1107,7 +1149,7 @@ void TestWebChannel::benchPropertyUpdates()
+             obj->change();
+         }
+ 
+-        channel.d_func()->publisher->clientIsIdle = true;
++        channel.d_func()->publisher->setClientIsIdle(true, m_dummyTransport);
+         channel.d_func()->publisher->sendPendingPropertyUpdates();
+     }
+ }
+diff --git a/qtwebchannel/tests/auto/webchannel/tst_webchannel.h b/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
+index eae21f4..dd4e690 100644
+--- a/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
++++ b/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
+@@ -348,6 +348,7 @@ private slots:
+     void testJsonToVariant();
+     void testInfiniteRecursion();
+     void testAsyncObject();
++    void testPropertyMultipleTransports();
+     void testDeletionDuringMethodInvocation_data();
+     void testDeletionDuringMethodInvocation();
+ 
+Submodule qtwebengine f328054d...38e0df6c (commits not present)
+Submodule qtwebsockets 65850954..63fb8da1:
+diff --git a/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp b/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
+index 2affdd5..95f1194 100644
+--- a/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
++++ b/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
+@@ -273,6 +273,7 @@ void QWebSocketDataProcessor::clear()
+     if (!m_pConverterState)
+         m_pConverterState = new QTextCodec::ConverterState(QTextCodec::ConvertInvalidToNull |
+                                                            QTextCodec::IgnoreHeader);
++    frame.clear();
+ }
+ 
+ /*!
+diff --git a/qtwebsockets/src/websockets/qwebsocketprotocol.cpp b/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
+index df87a93..d0465f1 100644
+--- a/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
++++ b/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
+@@ -210,7 +210,7 @@ void QWebSocketProtocol::mask(char *payload, quint64 size, quint32 maskingKey)
+                             quint8((maskingKey & 0x0000FF00u) >> 8),
+                             quint8((maskingKey & 0x000000FFu))
+                           };
+-    int i = 0;
++    quint64 i = 0;
+     while (size-- > 0)
+         *payload++ ^= mask[i++ % 4];
+ }
diff --git a/srcpkgs/qt5/template b/srcpkgs/qt5/template
index e0463e1c9198..ca1800ce9dc2 100644
--- a/srcpkgs/qt5/template
+++ b/srcpkgs/qt5/template
@@ -2,11 +2,11 @@
 #
 # revbump libqtxdg after bumping patch version
 pkgname=qt5
-version=5.15.7+20221119
+version=5.15.8
+revision=1
+build_style=meta
 # commit f8c9fb304bc3e53b3aa07f962cd74e9160decccc
 # base repo: https://invent.kde.org/qt/qt/qt5
-revision=4
-build_style=meta
 hostmakedepends="cmake clang flex perl glib-devel pkg-config
  python re2c ruby which"
 makedepends="SDL2-devel Vulkan-Headers alsa-lib-devel double-conversion-devel
@@ -29,8 +29,9 @@ homepage="https://qt.io/"
 # tarball is generated with `git archive-all qt5-$version.tar.gz`
 # to keep the size smaller qtwebengine, qtwebview, qtdocgallery, qtactiveqt and qtpim
 # can be marked with the export-ignore attribute
-distfiles="https://void.johnnynator.dev/distfiles/qt5-${version}.tar.gz"
-checksum=9d57af471c78029a362276b7c99108ea009f511bb9ba6ff6cb884f6ddd255e9f
+#distfiles="https://void.johnnynator.dev/distfiles/qt5-${version}.tar.gz"
+distfiles="https://download.qt.io/archive/qt/5.15/${version}/single/qt-everywhere-opensource-src-${version}.tar.xz"
+checksum=776a9302c336671f9406a53bd30b8e36f825742b2ec44a57c08217bff0fa86b9
 python_version=2 #unverified
 replaces="qt5-doc<5.6.0 qt5-quick1<5.6.0 qt5-quick1-devel<5.6.0 qt5-webkit<5.6.0 qt5-webkit-devel<5.6.0
  qt5-enginio<5.7.1 qt5-enginio-devel<5.7.1 qt5-plugin-gtk<5.7.1 qt5-canvas3d<5.13.0"
@@ -248,7 +249,6 @@ do_configure() {
 	# opts+=" -v"
 	opts+=" -skip qtwebengine"
 	opts+=" -skip qtwebview"
-	opts+=" -skip qtdocgallery"
 	opts+=" -skip qtpim"
 	opts+=" -skip qtsystems"
 	opts+=" -skip qtspeech"

From bc1b61f20e8527594560f24f45043e0e6ef5d0fe Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 078/115] qt6-multimedia: revbump for ffmpeg-6.0

---
 srcpkgs/qt6-multimedia/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-multimedia/template b/srcpkgs/qt6-multimedia/template
index d89e7d54eb5a..aae15e57ca7b 100644
--- a/srcpkgs/qt6-multimedia/template
+++ b/srcpkgs/qt6-multimedia/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-multimedia'
 pkgname=qt6-multimedia
 version=6.4.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DQT_FEATURE_gstreamer=ON"
 hostmakedepends="perl qt6-declarative-host-tools pkg-config qt6-shadertools"

From 9d4d602553af339cd07c691b538f1984292a6466 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 079/115] qtav: revbump for ffmpeg4-4.4.3

---
 srcpkgs/qtav/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtav/template b/srcpkgs/qtav/template
index 34c30b2c0c78..2d00ad104355 100644
--- a/srcpkgs/qtav/template
+++ b/srcpkgs/qtav/template
@@ -1,10 +1,10 @@
 # Template file for 'qtav'
 pkgname=qtav
 version=1.13.0
-revision=1
+revision=2
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel libass-devel libopenal-devel
+makedepends="ffmpeg4-devel libass-devel libopenal-devel
  libva-glx-devel libXv-devel pulseaudio-devel
  qt5-declarative-devel qt5-svg-devel
  qt5-quickcontrols"

From 30c1a8bf19a1a96269d13bb4b8ea5708fc8bf5e7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 080/115] qtox: revbump for ffmpeg-6.0

---
 srcpkgs/qtox/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qtox/template b/srcpkgs/qtox/template
index 16019d7eaec9..5cea0b11b697 100644
--- a/srcpkgs/qtox/template
+++ b/srcpkgs/qtox/template
@@ -1,7 +1,7 @@
 # Template file for 'qtox'
 pkgname=qtox
 version=1.17.6
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DUPDATE_CHECK=OFF
  -DGIT_DESCRIBE=${version}

From e848b0ff4ea790765360a25c63ad70c67519e21c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 081/115] retroarch: revbump for ffmpeg-6.0

---
 srcpkgs/retroarch/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroarch/template b/srcpkgs/retroarch/template
index 240d3df9db00..6d0b16ae2598 100644
--- a/srcpkgs/retroarch/template
+++ b/srcpkgs/retroarch/template
@@ -1,7 +1,7 @@
 # Template file for 'retroarch'
 pkgname=retroarch
 version=1.14.0
-revision=1
+revision=2
 build_style=configure
 configure_args="--prefix=/usr --sysconfdir=/etc --enable-networking
  --enable-udev --disable-builtinflac --disable-builtinglslang

From 5a81d1ee2a40c7d3fbdc00b1746fb58b4999e1e8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 082/115] scrcpy: revbump for ffmpeg-6.0

---
 srcpkgs/scrcpy/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/scrcpy/template b/srcpkgs/scrcpy/template
index ee6e698e387f..8ada5ca4323f 100644
--- a/srcpkgs/scrcpy/template
+++ b/srcpkgs/scrcpy/template
@@ -1,7 +1,7 @@
 # Template file for 'scrcpy'
 pkgname=scrcpy
 version=2.0
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcompile_server=false
  -Dprebuilt_server=/usr/share/scrcpy/scrcpy-server-v${version}"

From 5e7b3a48d0c49ff7847ea1ec1717f14bb506cc63 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 083/115] spek-alternative: revbump for ffmpeg4-4.4.3

---
 srcpkgs/spek-alternative/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/spek-alternative/template b/srcpkgs/spek-alternative/template
index d65086b8f008..05246f1b8d0c 100644
--- a/srcpkgs/spek-alternative/template
+++ b/srcpkgs/spek-alternative/template
@@ -1,11 +1,11 @@
 # Template file for 'spek-alternative'
 pkgname=spek-alternative
 version=0.8.2.3
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake gettext-devel intltool libtool pkg-config wxWidgets-common"
-makedepends="ffmpeg-devel wxWidgets-gtk3-devel"
-depends="ffmpeg"
+makedepends="ffmpeg4-devel wxWidgets-gtk3-devel"
+depends="ffmpeg4"
 short_desc="Acoustic spectrum analyser"
 maintainer="Kartik Singh <kartik.ynwa@gmail.com>"
 license="GPL-3.0-or-later"

From d45e8418d9577a9851b1f7e2529698fd1f8f3c30 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 084/115] ssr: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ssr/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/ssr/template b/srcpkgs/ssr/template
index b055b9ec0774..3448ca110eb0 100644
--- a/srcpkgs/ssr/template
+++ b/srcpkgs/ssr/template
@@ -1,11 +1,11 @@
 # Template file for 'ssr'
 pkgname=ssr
 version=0.4.4
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_QT5=ON"
 hostmakedepends="pkg-config"
-makedepends="alsa-lib-devel ffmpeg-devel glu-devel jack-devel pulseaudio-devel
+makedepends="alsa-lib-devel ffmpeg4-devel glu-devel jack-devel pulseaudio-devel
  qt5-tools-devel qt5-x11extras-devel libXinerama-devel v4l-utils-devel"
 depends="desktop-file-utils hicolor-icon-theme"
 short_desc="Simple Screen Recorder for programs and games"

From 6b4a1fd078cddf3a170a3620aa9a31587e72a993 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 085/115] sumo: revbump for ffmpeg-6.0

---
 srcpkgs/sumo/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/sumo/template b/srcpkgs/sumo/template
index 0f9b9ec815f5..a3fe134aa5ac 100644
--- a/srcpkgs/sumo/template
+++ b/srcpkgs/sumo/template
@@ -1,7 +1,7 @@
 # Template file for 'sumo'
 pkgname=sumo
 version=1.12.0
-revision=5
+revision=6
 build_style=cmake
 hostmakedepends="libgdal-tools pkg-config swig python3-setuptools"
 makedepends="python3-devel ffmpeg-devel fox-devel gl2ps-devel libgdal-devel

From 0518000ffbec1d52ab1f6278f5c02f6a006ea394 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 086/115] synfig: revbump for ffmpeg-6.0 and mlt7

---
 srcpkgs/synfig/patches/ffmpeg6.patch | 71 ++++++++++++++++++++++++++++
 srcpkgs/synfig/template              |  4 +-
 2 files changed, 73 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/synfig/patches/ffmpeg6.patch

diff --git a/srcpkgs/synfig/patches/ffmpeg6.patch b/srcpkgs/synfig/patches/ffmpeg6.patch
new file mode 100644
index 000000000000..10780b42782f
--- /dev/null
+++ b/srcpkgs/synfig/patches/ffmpeg6.patch
@@ -0,0 +1,71 @@
+--- a/src/modules/mod_libavcodec/trgt_av.cpp	2022-10-25 09:14:12.000000000 -0400
++++ b/src/modules/mod_libavcodec/trgt_av.cpp	2023-05-05 21:34:17.899194559 -0400
+@@ -38,6 +41,7 @@
+ extern "C"
+ {
+ #ifdef HAVE_LIBAVFORMAT_AVFORMAT_H
++#	include <libavcodec/avcodec.h>
+ #	include <libavformat/avformat.h>
+ #elif defined(HAVE_AVFORMAT_H)
+ #	include <avformat.h>
+@@ -155,11 +156,11 @@
+     }
+ 
+ 	bool open_video_stream() {
+-		if (avcodec_open2(video_context, NULL, NULL) < 0) {
++		if (avcodec_open2(video_context, nullptr, nullptr) < 0) {
+ 			synfig::error("Target_LibAVCodec: could not open video codec");
+ 			// seems the calling of avcodec_free_context after error will cause crash
+ 			// so just forget about this context
+-			video_context = NULL;
++			video_context = nullptr;
+ 			close();
+ 			return false;
+         }
+@@ -234,15 +235,21 @@
+ 		close();
+ 
+ 		if (!av_registered) {
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 			av_register_all();
++#endif
+ 			av_registered = true;
+ 		}
+ 
+ 		// guess format
+-		AVOutputFormat *format = av_guess_format(NULL, filename.c_str(), NULL);
++#if LIBAVCODEC_VERSION_MAJOR < 59 // FFMPEG < 5.0
++		AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#else
++		const AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#endif
+ 		if (!format) {
+ 			synfig::warning("Target_LibAVCodec: unable to guess the output format, defaulting to MPEG");
+-			format = av_guess_format("mpeg", NULL, NULL);
++			format = av_guess_format("mpeg", nullptr, nullptr);
+ 		}
+ 		if (!format) {
+ 			synfig::error("Target_LibAVCodec: unable to find 'mpeg' output format");
+@@ -254,6 +261,7 @@
+ 		context = avformat_alloc_context();
+ 		assert(context);
+ 		context->oformat = format;
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 		if (filename.size() + 1 > sizeof(context->filename)) {
+ 			synfig::error(
+ 				"Target_LibAVCodec: filename too long, max length is %d, filename is '%s'",
+@@ -263,6 +271,14 @@
+ 			return false;
+ 		}
+ 		memcpy(context->filename, filename.c_str(), filename.size() + 1);
++#else
++		context->url = av_strndup(filename.c_str(), filename.size());
++		if (!context->url) {
++			synfig::error("Target_LibAVCodec: cannot allocate space for filename");
++			close();
++			return false;
++		}
++#endif
+ 
+ 		packet = av_packet_alloc();
+ 		assert(packet);
diff --git a/srcpkgs/synfig/template b/srcpkgs/synfig/template
index 5f5f5bb3f4b2..6e0d713150ae 100644
--- a/srcpkgs/synfig/template
+++ b/srcpkgs/synfig/template
@@ -6,7 +6,7 @@ revision=2
 build_style=gnu-configure
 configure_args="--with-boost-libdir=${XBPS_CROSS_BASE}/usr/lib"
 hostmakedepends="boost-build ImageMagick pkg-config intltool"
-makedepends="ETL gettext-devel libxml++-devel mlt-devel libmagick-devel
+makedepends="ETL gettext-devel libxml++-devel mlt7-devel libmagick-devel
  libmng-devel boost-build boost-devel libopenexr-devel ffmpeg-devel"
 depends="ImageMagick"
 short_desc="CLI 2D vector and timeline-based animation software"
@@ -20,7 +20,7 @@ CXXFLAGS="-std=c++11 -DHAVE_LOCALE_H=1"
 
 synfig-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision}
-	 libopenexr-devel libxml++-devel mlt-devel"
+	 libopenexr-devel libxml++-devel mlt7-devel"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/bin/synfig-config

From 7e41b6e74c8e6eba7e97bdf2eadd5339d1f9391b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 5 May 2023 12:57:57 -0400
Subject: [PATCH 087/115] synfigstudio: revbump for synfig mlt7

---
 srcpkgs/synfigstudio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/synfigstudio/template b/srcpkgs/synfigstudio/template
index 91349169ed2b..af1c5a296ef0 100644
--- a/srcpkgs/synfigstudio/template
+++ b/srcpkgs/synfigstudio/template
@@ -2,7 +2,7 @@
 # Should be kept in sync with 'synfig' and 'ETL'
 pkgname=synfigstudio
 version=1.4.4
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--disable-update-mimedb"
 hostmakedepends="pkg-config intltool gettext synfig"

From 5df937a2be8e803722ff2b2018e0c871a21b8bcf Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 088/115] telegram-desktop: revbump for ffmpeg-6.0

---
 srcpkgs/telegram-desktop/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/telegram-desktop/template b/srcpkgs/telegram-desktop/template
index 60df3278b05e..83aa72a67448 100644
--- a/srcpkgs/telegram-desktop/template
+++ b/srcpkgs/telegram-desktop/template
@@ -1,7 +1,7 @@
 # Template file for 'telegram-desktop'
 pkgname=telegram-desktop
 version=4.8.1
-revision=1
+revision=2
 build_style=cmake
 build_helper="qemu"
 configure_args="-DTDESKTOP_API_ID=209235

From db7ecc0a6e67f49e91efc2712fb0ff7a103b08b1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 089/115] tg_owt: revbump for ffmpeg-6.0

---
 srcpkgs/tg_owt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tg_owt/template b/srcpkgs/tg_owt/template
index 97d195ddb34a..551614b24956 100644
--- a/srcpkgs/tg_owt/template
+++ b/srcpkgs/tg_owt/template
@@ -1,7 +1,7 @@
 # Template file for 'tg_owt'
 pkgname=tg_owt
 version=0.0.0.20230107
-revision=1
+revision=2
 _commit=5098730b9eb6173f0b52068fe2555b7c1015123a
 _libyuv_commit=00950840d1c9bcbb3eb6ebc5aac5793e71166c8b
 _abseil_commit=8c0b94e793a66495e0b1f34a5eb26bd7dc672db0

From 80d2dae7c2952acab8be49fa49bf6b588b663424 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 090/115] timg: revbump for ffmpeg-6.0

---
 srcpkgs/timg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/timg/template b/srcpkgs/timg/template
index 91f1516b2597..334443d3f9bb 100644
--- a/srcpkgs/timg/template
+++ b/srcpkgs/timg/template
@@ -1,7 +1,7 @@
 # Template file for 'timg'
 pkgname=timg
 version=1.4.4
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_OPENSLIDE_SUPPORT=off -Wno-dev"
 hostmakedepends="pkg-config git"

From 502dd1911003ea24f159739244fe8a47373a21cc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 091/115] tvheadend: revbump for ffmpeg4-4.4.3

---
 srcpkgs/tvheadend/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/tvheadend/template b/srcpkgs/tvheadend/template
index e6b16d7ccf3b..46b52b6fb7f9 100644
--- a/srcpkgs/tvheadend/template
+++ b/srcpkgs/tvheadend/template
@@ -1,14 +1,14 @@
 # Template file for 'tvheadend'
 pkgname=tvheadend
 version=4.2.8
-revision=6
+revision=7
 build_style=gnu-configure
 configure_args="--enable-dvbscan --disable-ffmpeg_static
 --disable-hdhomerun_static --disable-bintray_cache --disable-libx264_static
 --disable-libx265_static --disable-libvpx_static --disable-libtheora_static
 --disable-libvorbis_static --disable-libfdkaac_static"
 hostmakedepends="gettext pkg-config python git which"
-makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg-devel"
+makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg4-devel"
 short_desc="TV streaming server"
 maintainer="lemmi <lemmi@nerd2nerd.org>"
 license="GPL-3.0-only"

From d35f3fe4518b1f82f61760bae4c4f18dbc6f180b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 092/115] unpaper: update to 7.0.0.

---
 srcpkgs/unpaper/template | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/srcpkgs/unpaper/template b/srcpkgs/unpaper/template
index 38ed47a58401..1ff910e722af 100644
--- a/srcpkgs/unpaper/template
+++ b/srcpkgs/unpaper/template
@@ -1,13 +1,13 @@
 # Template file for 'unpaper'
 pkgname=unpaper
-version=6.1
-revision=3
-build_style=gnu-configure
+version=7.0.0
+revision=1
+build_style=meson
+hostmakedepends="pkg-config meson libxslt"
+makedepends="ffmpeg-devel python3-Sphinx"
+short_desc="Post-processing tool for scanned sheets of paper"
 maintainer="Orphaned <orphan@voidlinux.org>"
-hostmakedepends="pkg-config libxslt"
-makedepends="ffmpeg-devel"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://www.flameeyes.eu/projects/unpaper"
-short_desc="A post-processing tool for scanned sheets of paper"
 distfiles="https://www.flameeyes.eu/files/${pkgname}-${version}.tar.xz"
-checksum=237c84f5da544b3f7709827f9f12c37c346cdf029b1128fb4633f9bafa5cb930
+checksum=2575fbbf26c22719d1cb882b59602c9900c7f747118ac130883f63419be46a80

From eea586f6c737e2d82f5d2d0c2aa5b0f46a66cde6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 093/115] vba-m: revbump for ffmpeg-6.0

---
 srcpkgs/vba-m/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vba-m/template b/srcpkgs/vba-m/template
index ba153e0b58ca..aa6093645e97 100644
--- a/srcpkgs/vba-m/template
+++ b/srcpkgs/vba-m/template
@@ -2,7 +2,7 @@
 pkgname=vba-m
 reverts=1292_2
 version=2.1.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_GTK=TRUE -DENABLE_FFMPEG=TRUE -DENABLE_LINK=TRUE -DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="gettext pkg-config unzip zip yasm wxWidgets-gtk3-devel"

From dd4e871ae5e48efca9b23b5fdb23f71ad1b9c74e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 094/115] vice: revbump for ffmpeg4-4.4.3

---
 srcpkgs/vice/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/vice/template b/srcpkgs/vice/template
index 0924767cfcfb..5981e45149d0 100644
--- a/srcpkgs/vice/template
+++ b/srcpkgs/vice/template
@@ -1,7 +1,7 @@
 # Template file for 'vice'
 pkgname=vice
 version=3.5
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="
 	$(vopt_enable sdl2 sdlui2)
@@ -28,7 +28,7 @@ makedepends="
 	$(vopt_if gtk3 gtk+3-devel)
 	$(vopt_if gtk3 pulseaudio-devel)
 	$(vopt_if gtk3 pango-devel)
-	$(vopt_if ffmpeg ffmpeg-devel)"
+	$(vopt_if ffmpeg ffmpeg4-devel)"
 short_desc="Emulator for C64, C128, CBM-II, PET, VIC20, Plus4 and C16"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"

From 63cb2d5584bdfc1758c9f1f3fb1a17e0c1dd9a74 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 095/115] waypipe: revbump for ffmpeg-6.0

---
 srcpkgs/waypipe/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waypipe/template b/srcpkgs/waypipe/template
index 5c4161900060..1a46fe27f7d8 100644
--- a/srcpkgs/waypipe/template
+++ b/srcpkgs/waypipe/template
@@ -1,7 +1,7 @@
 # Template file for 'waypipe'
 pkgname=waypipe
 version=0.8.4
-revision=1
+revision=2
 build_style=meson
 # lto is off because it causes linking errors in armv6l and armv7l (due to NEON)
 configure_args="-Dwerror=false -Dwith_dmabuf=enabled -Dwith_lz4=enabled

From 553837596a2b6ddb2946b5dd24242ef853161613 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 096/115] wf-recorder: revbump for ffmpeg-6.0

---
 srcpkgs/wf-recorder/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/wf-recorder/template b/srcpkgs/wf-recorder/template
index e278eb001600..5d014a5f28af 100644
--- a/srcpkgs/wf-recorder/template
+++ b/srcpkgs/wf-recorder/template
@@ -1,7 +1,7 @@
 # Template file for 'wf-recorder'
 pkgname=wf-recorder
 version=0.3.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config scdoc wayland-devel"
 makedepends="wayland-protocols wayland-devel ffmpeg-devel x264-devel

From ac2a750601716f05ba0ad759440fb362a77604f3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 097/115] xpra: revbump for ffmpeg-6.0

---
 srcpkgs/xpra/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xpra/template b/srcpkgs/xpra/template
index 38f83283b1e5..b6e01ff0a813 100644
--- a/srcpkgs/xpra/template
+++ b/srcpkgs/xpra/template
@@ -1,7 +1,7 @@
 # Template file for 'xpra'
 pkgname=xpra
 version=4.4.4
-revision=1
+revision=2
 build_style=python3-module
 make_build_args="--without-cuda_kernels --without-cuda_rebuild"
 make_install_args="$(vopt_with docs) ${make_build_args}"

From ae03605321e65f9c7132a04107990b5823661826 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:07:40 -0400
Subject: [PATCH 098/115] nv-codec-headers: update to 12.0.16.0

---
 srcpkgs/nv-codec-headers/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/nv-codec-headers/template b/srcpkgs/nv-codec-headers/template
index 3d422a61e489..251e057f826f 100644
--- a/srcpkgs/nv-codec-headers/template
+++ b/srcpkgs/nv-codec-headers/template
@@ -1,6 +1,6 @@
 # Template file for 'nv-codec-headers'
 pkgname=nv-codec-headers
-version=11.1.5.1
+version=12.0.16.0
 revision=1
 build_style=gnu-makefile
 short_desc="FFmpeg version of headers required to interface with Nvidias codec APIs"
@@ -8,7 +8,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="MIT"
 homepage="http://git.videolan.org/?p=ffmpeg/nv-codec-headers.git"
 distfiles="https://github.com/FFmpeg/nv-codec-headers/archive/n${version}.tar.gz"
-checksum=d095fbd56aa93772471a323be0ebe65504a0f43f06c76a30b6d25da77b06ae9c
+checksum=2a1533b65f55f9da52956faf0627ed3b74868ac0c7f269990edd21369113b48f
 
 post_install() {
 	sed -n '4,25p' include/ffnvcodec/nvEncodeAPI.h > LICENSE

From f34884257526429d1f688ba1987e352c96aec02e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:08:40 -0400
Subject: [PATCH 099/115] openimagedenoise: revbump for ffmpeg-6.0

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index db5ccdb055cc..cb90045afb63 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,7 +1,7 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
 version=1.4.3
-revision=1
+revision=2
 archs="x86_64*"
 build_style=cmake
 hostmakedepends="ispc python3"

From 967b51da24206060ad271ee224d7068740c1e612 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:30:28 -0400
Subject: [PATCH 100/115] freecad: revbump for qt5-webengine-5.15.13

---
 srcpkgs/freecad/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/freecad/template b/srcpkgs/freecad/template
index f62023ee8ce4..e301f32d3540 100644
--- a/srcpkgs/freecad/template
+++ b/srcpkgs/freecad/template
@@ -1,7 +1,7 @@
 # Template file for 'freecad'
 pkgname=freecad
 version=0.20.2
-revision=3
+revision=4
 build_style=cmake
 
 _inst_prefix=/usr/lib/${pkgname}

From c0bd147974a6c4a8ba17893f41f852a43fdaeb6e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:31:45 -0400
Subject: [PATCH 101/115] shotcut: revbump for mlt7-7.14.0

---
 srcpkgs/shotcut/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/shotcut/template b/srcpkgs/shotcut/template
index 32583277dab2..8d8a7a0ebdeb 100644
--- a/srcpkgs/shotcut/template
+++ b/srcpkgs/shotcut/template
@@ -1,7 +1,7 @@
 # Template file for 'shotcut'
 pkgname=shotcut
 version=22.12.21
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSHOTCUT_VERSION=${version}"
 hostmakedepends="pkg-config qt5-tools-devel"

From f3b03073f118fc856acf6bc05a003ee777c9917b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:30 -0400
Subject: [PATCH 102/115] shiboken2: revbump for qt5-5.15.8

---
 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch | 1 +
 srcpkgs/shiboken2/template                                 | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
 create mode 120000 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
new file mode 120000
index 000000000000..efcf3249bd88
--- /dev/null
+++ b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1 @@
+../../python3-pyside2/patches/importlib-machinery-bypass.patch
\ No newline at end of file
diff --git a/srcpkgs/shiboken2/template b/srcpkgs/shiboken2/template
index 084ecc3ba1e1..2a21998997eb 100644
--- a/srcpkgs/shiboken2/template
+++ b/srcpkgs/shiboken2/template
@@ -1,7 +1,7 @@
 # Template file for 'shiboken2'
 pkgname=shiboken2
 version=5.15.7
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/shiboken2"
 build_style=cmake

From c3fd5c25e7155c836e9c09f7f417b84525f53a7e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:53 -0400
Subject: [PATCH 103/115] python3-pyside2: update to 5.15.8

---
 .../patches/importlib-machinery-bypass.patch      | 15 +++++++++++++++
 srcpkgs/python3-pyside2/template                  |  9 +++++----
 2 files changed, 20 insertions(+), 4 deletions(-)
 create mode 100644 srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
new file mode 100644
index 000000000000..64c429584776
--- /dev/null
+++ b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1,15 @@
+Using this prevents an error around line 220 below it.
+"AttributeError: module 'importlib' has no attribute 'machinery'"
+The old backup logic is in place and compiles without issues.
+--- a/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:09:34.688912402 -0400
++++ b/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:10:03.395529582 -0400
+@@ -170,9 +170,6 @@
+
+     # 'zipstring_sequence' comes from signature.cpp
+     zipbytes = base64.b64decode(''.join(zipstring_sequence))
+-    if sys.version_info[0] >= 3:
+-        vzip = zipfile.ZipFile(io.BytesIO(zipbytes))
+-        return sys.meta_path, EmbeddableZipImporter(vzip)
+
+     # Old version for Python 2.7, only.
+     import os
diff --git a/srcpkgs/python3-pyside2/template b/srcpkgs/python3-pyside2/template
index 50e6ff260d3b..b50e62bd215d 100644
--- a/srcpkgs/python3-pyside2/template
+++ b/srcpkgs/python3-pyside2/template
@@ -1,11 +1,12 @@
 # Template file for 'python3-pyside2'
 pkgname=python3-pyside2
-version=5.15.5
-revision=2
+version=5.15.8
+revision=1
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/pyside2"
 build_style=cmake
-configure_args="-DPYTHON_EXECUTABLE=/usr/bin/python"
+configure_args="-DPYTHON_EXECUTABLE=/usr/bin/python -DCMAKE_BUILD_TYPE=None
+ -DBUILD_TESTS=OFF"
 hostmakedepends="cmake python3 shiboken2"
 makedepends="python3-devel libshiboken2-devel qt5-devel
  qt5-multimedia-devel qt5-tools-devel qt5-plugin-mysql qt5-plugin-odbc
@@ -23,7 +24,7 @@ maintainer="yopito <pierre.bourgin@free.fr>"
 license="LGPL-3.0-or-later"
 homepage="https://wiki.qt.io/Qt_for_Python"
 distfiles="https://download.qt.io/official_releases/QtForPython/pyside2/PySide2-${version}-src/${_pkgname}.tar.xz"
-checksum=3920a4fb353300260c9bc46ff70f1fb975c5e7efa22e9d51222588928ce19b33
+checksum=23436302c8deb5b4cbc769b205d09604e38ba83b40708efccb7bd8c9af6f6b5d
 
 build_options="webengine"
 desc_option_webengine="Build Qt5 WebEngine bindings"

From 63e61b9b897d36f25c69411c103a36fa9cbde6d4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:35 -0400
Subject: [PATCH 104/115] konqueror: revbump for ffmpeg-6.0

---
 srcpkgs/konqueror/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/konqueror/template b/srcpkgs/konqueror/template
index d8d0e73a78ab..c5bdba601d3c 100644
--- a/srcpkgs/konqueror/template
+++ b/srcpkgs/konqueror/template
@@ -1,11 +1,11 @@
 # Template file for 'konqueror'
 pkgname=konqueror
 version=23.04.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DDESKTOPTOJSON_EXECUTABLE=/usr/bin/desktoptojson"
 hostmakedepends="extra-cmake-modules python3 qt5-host-tools qt5-qmake kdoctools
-kcoreaddons kconfig gettext"
+ kcoreaddons kconfig gettext"
 makedepends="qt5-devel qt5-webengine-devel qt5-declarative-devel
  qt5-webchannel-devel qt5-location-devel kcmutils-devel kdelibs4support-devel
  karchive-devel khtml-devel kdesu-devel kactivities5-devel"

From e723d92b42f62af025194c94bd366a56d6a5ea48 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:58 -0400
Subject: [PATCH 105/115] qt5-speech: revbump for qt5-5.15.8

---
 srcpkgs/qt5-speech/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-speech/template b/srcpkgs/qt5-speech/template
index 3ecd10d50650..2d7d4d4d2453 100644
--- a/srcpkgs/qt5-speech/template
+++ b/srcpkgs/qt5-speech/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-speech'
 pkgname=qt5-speech
 version=5.15.7
-revision=2
+revision=3
 _commit=d32f4a479d38a11f547598004b975f4356424a16
 build_style=qmake
 configure_args="-- -flite -flite-alsa -speechd"

From 325bb0d3cda357290757728543f210be8aebb4bc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 18:38:50 -0400
Subject: [PATCH 106/115] qt5-styleplugins: revbump for qt5-5.15.8

---
 srcpkgs/qt5-styleplugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-styleplugins/template b/srcpkgs/qt5-styleplugins/template
index 96ed97d12cd2..30d93660a2a4 100644
--- a/srcpkgs/qt5-styleplugins/template
+++ b/srcpkgs/qt5-styleplugins/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-styleplugins'
 pkgname=qt5-styleplugins
 version=5.0.0
-revision=20
+revision=21
 _gitrev=335dbece103e2cbf6c7cf819ab6672c2956b17b3
 build_style=qmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From d106e08980845c05049d60a3c03b0a203411424f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 27 Apr 2023 21:58:35 -0400
Subject: [PATCH 107/115] blender: update to 3.5.1

---
 srcpkgs/blender/patches/numpy-2.24.patch | 22 ----------------------
 srcpkgs/blender/template                 | 13 +++++++------
 2 files changed, 7 insertions(+), 28 deletions(-)
 delete mode 100644 srcpkgs/blender/patches/numpy-2.24.patch

diff --git a/srcpkgs/blender/patches/numpy-2.24.patch b/srcpkgs/blender/patches/numpy-2.24.patch
deleted file mode 100644
index 716315b74be7..000000000000
--- a/srcpkgs/blender/patches/numpy-2.24.patch
+++ /dev/null
@@ -1,22 +0,0 @@
-From 74e6e07cf7c67b55d384db72f5aa3892db8a3da6 Mon Sep 17 00:00:00 2001
-From: oreo639 <oreo6391@gmail.com>
-Date: Tue, 17 Jan 2023 14:36:54 -0800
-Subject: [PATCH] Remove usage of deprecated np.bool alias
-
----
- addons/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/addons/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py b/addons/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py
-index 6366434a6..8160c9e99 100644
---- a/release/scripts/addons/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py
-+++ b/release/scripts/addons/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py
-@@ -620,7 +620,7 @@ def set_poly_smoothing(gltf, pymesh, mesh, vert_normals, loop_vidxs):
-     # Try to guess which polys should be flat based on the fact that all the
-     # loop normals for a flat poly are = the poly's normal.
- 
--    poly_smooths = np.empty(num_polys, dtype=np.bool)
-+    poly_smooths = np.empty(num_polys, dtype=bool)
- 
-     poly_normals = np.empty(num_polys * 3, dtype=np.float32)
-     mesh.polygons.foreach_get('normal', poly_normals)
diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index d18bc88838ff..900bc17937c3 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -1,7 +1,7 @@
 # Template file for 'blender'
 pkgname=blender
-version=3.4.1
-revision=4
+version=3.5.1
+revision=1
 archs="x86_64* ppc64*"
 build_style="cmake"
 pycompile_dirs="/usr/share/blender/${version%.*}/scripts"
@@ -9,8 +9,8 @@ configure_args="-DWITH_INSTALL_PORTABLE=OFF -DWITH_PYTHON_INSTALL=OFF
  -DWITH_JACK=ON -DWITH_CODEC_FFMPEG=ON -DWITH_CODEC_SNDFILE=ON -DWITH_OPENMP=ON
  -DWITH_FFTW3=ON -DWITH_MOD_OCEANSIM=ON -DWITH_CYCLES_EMBREE=OFF -DWITH_OPENCOLORIO=ON
  -DWITH_IMAGE_OPENEXR=ON -DWITH_IMAGE_OPENJPEG=ON -DWITH_OPENSUBDIV=ON
- -DWITH_OPENCOLLADA=ON -DWITH_SYSTEM_GLEW=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
- -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_LIBDECOR=ON
+ -DWITH_OPENCOLLADA=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
+ -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_WAYLAND_LIBDECOR=ON
  -DWITH_BUILDINFO=OFF -DPYTHON_VERSION=${py3_ver} -DPYTHON_LIBPATH=/usr/lib
  -DPYTHON_LIBRARY='python${py3_ver}${py3_abiver}'
  -DPYTHON_INCLUDE_DIRS=/${py3_inc}"
@@ -22,14 +22,15 @@ makedepends="libgomp-devel libpng-devel tiff-devel python3-devel glu-devel
  opencolorio-devel opencollada-devel python3-numpy libXrender-devel
  OpenSubdiv-devel tbb-devel libxml2-devel openvdb-devel alembic-devel
  pugixml-devel libXxf86vm-devel libepoxy-devel gmp-devel gmpxx-devel
- wayland-protocols wayland-devel libxkbcommon-devel libdecor-devel"
+ wayland-protocols wayland-devel libxkbcommon-devel libdecor-devel
+ level-zero-devel"
 depends="desktop-file-utils hicolor-icon-theme"
 short_desc="3D graphics creation suite"
 maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="https://www.blender.org"
 distfiles="https://download.blender.org/source/blender-${version}.tar.xz"
-checksum=247c4c1228270c9010f4721c985cb5b628ab50abcf9f2678630737142eeb91c3
+checksum=bd7428c7e6cba5a900216269c32111dffaabaf1bdb5472f231965e615174a809
 python_version=3
 LDFLAGS="-Wl,-z,stack-size=2097152"
 # Blender tests are executed against a system installation of blender. This

From cc4c1a61ed63d09a5012651541f45f82eca10980 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 30 Apr 2023 20:22:26 -0400
Subject: [PATCH 108/115] gst-plugins-ugly1: revbump for ffmpeg-6.0

---
 srcpkgs/gst-plugins-ugly1/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-plugins-ugly1/template b/srcpkgs/gst-plugins-ugly1/template
index e254fd40f869..85ae64bc7a0a 100644
--- a/srcpkgs/gst-plugins-ugly1/template
+++ b/srcpkgs/gst-plugins-ugly1/template
@@ -1,6 +1,6 @@
 # Template file for 'gst-plugins-ugly1'
 pkgname=gst-plugins-ugly1
-version=1.20.3
+version=1.22.2
 revision=1
 build_style=meson
 configure_args="-Damrnb=disabled -Damrwbdec=disabled -Dsidplay=disabled"
@@ -15,4 +15,4 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname/1/}/${pkgname/1/}-${version}.tar.xz"
-checksum=8caa20789a09c304b49cf563d33cca9421b1875b84fcc187e4a385fa01d6aefd
+checksum=8f30f44db0bd063709bf6fbe55138e3a98af0abcb61c360f35582bbe10e80691

From f10a956f45f41af81f7157432be1c09a826776ad Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 30 Apr 2023 20:22:26 -0400
Subject: [PATCH 109/115] gst-rtsp-server: revbump for ffmpeg-6.0

---
 srcpkgs/gst-rtsp-server/template | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index 8ceea8d34b4b..980fd72cdd4c 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
-version=1.20.3
-revision=3
+version=1.22.2
+revision=2
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="glib-devel gst-plugins-bad1-devel gobject-introspection
@@ -10,5 +10,5 @@ short_desc="GStreamer multimedia graph framework - rtsp server"
 maintainer="1is7ac3 <isaac.qa13@gmail.com>"
 license="LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
-distfiles="https://gstreamer.freedesktop.org/src/gst-rtsp-server/gst-rtsp-server-${version}.tar.xz"
-checksum=ee402718be9b127f0e5e66ca4c1b4f42e4926ec93ba307b7ccca5dc6cc9794ca
+distfiles="${homepage}/src/${pkgname}/${pkgname}-${version}.tar.xz"
+checksum=2be4aecfb88710100ea7115ed0216403e8094344ebf146094271b8d4d73828bf

From 5ea533534cad672232cbf0dd072c994efd33e993 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 30 Apr 2023 20:22:26 -0400
Subject: [PATCH 110/115] gst-libav: revbump for ffmpeg-6.0

---
 srcpkgs/gst-libav/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index f082bd211c65..04c39bff1489 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,6 +1,6 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
-version=1.20.3
+version=1.22.2
 revision=2
 build_style=meson
 hostmakedepends="pkg-config yasm"
@@ -11,7 +11,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.0-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname}/${pkgname}-${version}.tar.xz"
-checksum=3fedd10560fcdfaa1b6462cbf79a38c4e7b57d7f390359393fc0cef6dbf27dfe
+checksum=fcaaf9878fe8f3bc82317ef13a1558824cb68df1f8968c6797f556c5e33bcffd
 
 case "$XBPS_TARGET_MACHINE" in
 	*-musl) # Required by musl for M_SQRT1_2

From df60a4c0794afb9c9f360c19e27e90b5bf48b011 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 7 May 2023 19:48:01 -0400
Subject: [PATCH 111/115] gtk4: revbump for ffmpeg-6.0

---
 srcpkgs/gtk4/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gtk4/template b/srcpkgs/gtk4/template
index a2566d4042d3..5fafa50f6f33 100644
--- a/srcpkgs/gtk4/template
+++ b/srcpkgs/gtk4/template
@@ -1,7 +1,7 @@
 # Template file for 'gtk4'
 pkgname=gtk4
 version=4.10.3
-revision=1
+revision=2
 build_style=meson
 build_helper="gir"
 configure_args="-Dman-pages=true -Dgtk_doc=true

From 84014ee3a140d3ed0185fb88070cc9b8496c6b14 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 7 May 2023 20:14:14 -0400
Subject: [PATCH 112/115] mlt7: revbump for ffmpeg-6.0

---
 srcpkgs/gst-libav/template             | 2 +-
 srcpkgs/gst-omx/template               | 4 ++--
 srcpkgs/gst-plugins-base1/template     | 4 ++--
 srcpkgs/gst-plugins-good1/template     | 4 ++--
 srcpkgs/gst1-editing-services/template | 4 ++--
 srcpkgs/gst1-python3/template          | 6 +++---
 srcpkgs/gstreamer-vaapi/template       | 4 ++--
 srcpkgs/gstreamer1/template            | 4 ++--
 srcpkgs/mlt7/template                  | 2 +-
 9 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index 04c39bff1489..8c72fc3e97ee 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.22.2
-revision=2
+revision=1
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"
diff --git a/srcpkgs/gst-omx/template b/srcpkgs/gst-omx/template
index 893535c463da..5ad54cc7b9d8 100644
--- a/srcpkgs/gst-omx/template
+++ b/srcpkgs/gst-omx/template
@@ -1,6 +1,6 @@
 # Template file for 'gst-omx'
 pkgname=gst-omx
-version=1.20.3
+version=1.22.2
 revision=1
 build_style=meson
 configure_args="-Dexamples=disabled -Dtarget=generic"
@@ -11,4 +11,4 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.1-only"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname}/${pkgname}-${version}.tar.xz"
-checksum=8db48040bb41f09edf8d17ff6d16c54888d7777ba4501c2c69f0083350ea9a15
+checksum=1b0c57f2cc4ddeec5e7f0c436e502f06665c4e93c73261855b94e04fc94337b2
diff --git a/srcpkgs/gst-plugins-base1/template b/srcpkgs/gst-plugins-base1/template
index 29e8f76bd1fe..2f20ea819849 100644
--- a/srcpkgs/gst-plugins-base1/template
+++ b/srcpkgs/gst-plugins-base1/template
@@ -1,6 +1,6 @@
 # Template file for 'gst-plugins-base1'
 pkgname=gst-plugins-base1
-version=1.20.3
+version=1.22.2
 revision=1
 build_style=meson
 build_helper="gir"
@@ -22,7 +22,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname/1/}/${pkgname/1/}-${version}.tar.xz"
-checksum=7e30b3dd81a70380ff7554f998471d6996ff76bbe6fc5447096f851e24473c9f
+checksum=eb65120c4ee79b7a153c3c1972d5c0158c2151877cc51ec7725bba5749679d49
 
 build_options="cdparanoia gir sndio wayland"
 build_options_default="cdparanoia gir wayland"
diff --git a/srcpkgs/gst-plugins-good1/template b/srcpkgs/gst-plugins-good1/template
index 1f5e620ce1fd..5d0fe1bfe284 100644
--- a/srcpkgs/gst-plugins-good1/template
+++ b/srcpkgs/gst-plugins-good1/template
@@ -1,6 +1,6 @@
 # Template file for 'gst-plugins-good1'
 pkgname=gst-plugins-good1
-version=1.20.3
+version=1.22.2
 revision=1
 build_style=meson
 configure_args="-Ddv=disabled -Ddv1394=disabled -Dshout2=disabled -Dqt5=enabled
@@ -22,7 +22,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname/1/}/${pkgname/1/}-${version}.tar.xz"
-checksum=f8f3c206bf5cdabc00953920b47b3575af0ef15e9f871c0b6966f6d0aa5868b7
+checksum=7c8cc59425f2b232f60ca7d13e56edd615da4f711e73dd01a7cffa46e6bc0cdd
 
 build_options="gtk3 wayland"
 build_options_default="gtk3 wayland"
diff --git a/srcpkgs/gst1-editing-services/template b/srcpkgs/gst1-editing-services/template
index 673b46970f24..102440f7f253 100644
--- a/srcpkgs/gst1-editing-services/template
+++ b/srcpkgs/gst1-editing-services/template
@@ -1,6 +1,6 @@
 # Template file for 'gst1-editing-services'
 pkgname=gst1-editing-services
-version=1.20.3
+version=1.22.2
 revision=1
 build_style=meson
 build_helper="gir"
@@ -12,7 +12,7 @@ maintainer="Toyam Cox <Vaelatern@gmail.com>"
 license="LGPL-2.0-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname/gst1/gst}/${pkgname/gst1/gst}-${version}.tar.xz"
-checksum=5fd896de69fbe24421eb6b0ff8d2f8b4c3cba3f3025ceacd302172f39a8abaa2
+checksum=453b1464fc3857de269a7cb0ebd966afe02171d97bef672a0b8a0a6d43e0cebf
 
 do_check() {
 	: # Tests fail in older versions as well
diff --git a/srcpkgs/gst1-python3/template b/srcpkgs/gst1-python3/template
index 3f564ac64b93..789e40f036ea 100644
--- a/srcpkgs/gst1-python3/template
+++ b/srcpkgs/gst1-python3/template
@@ -1,7 +1,7 @@
 # Template file for 'gst1-python3'
 pkgname=gst1-python3
-version=1.20.3
-revision=2
+version=1.22.2
+revision=1
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="libglib-devel python3-devel python3-gobject-devel gst-plugins-base1-devel"
@@ -11,4 +11,4 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/gst-python/gst-python-${version}.tar.xz"
-checksum=db348120eae955b8cc4de3560a7ea06e36d6e1ddbaa99a7ad96b59846601cfdc
+checksum=bef2b3d82ce4be46b775b1bb56305c1003ee01b535a53a82f9fe8924972153ad
diff --git a/srcpkgs/gstreamer-vaapi/template b/srcpkgs/gstreamer-vaapi/template
index 3cc4e057559a..0a5ee8b1ca3f 100644
--- a/srcpkgs/gstreamer-vaapi/template
+++ b/srcpkgs/gstreamer-vaapi/template
@@ -1,6 +1,6 @@
 # Template file for 'gstreamer-vaapi'
 pkgname=gstreamer-vaapi
-version=1.20.3
+version=1.22.2
 revision=1
 build_style=meson
 hostmakedepends="pkg-config"
@@ -11,7 +11,7 @@ license="LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
 changelog="https://raw.githubusercontent.com/GStreamer/gstreamer-vaapi/master/ChangeLog"
 distfiles="${homepage}/src/gstreamer-vaapi/gstreamer-vaapi-${version}.tar.xz"
-checksum=6ee99eb316abdde9ad37002915bd8c3867918f6fdc74b7cf2ac4c1ae0d690b45
+checksum=d2e642f9745f97d9f73a7f5085e7659a9a31fe209b774e6e45dae041b435df06
 
 pre_check() {
 	# Seems to need certain hardware to pass
diff --git a/srcpkgs/gstreamer1/template b/srcpkgs/gstreamer1/template
index ae8a49cb20e8..571148f2ff33 100644
--- a/srcpkgs/gstreamer1/template
+++ b/srcpkgs/gstreamer1/template
@@ -1,6 +1,6 @@
 # Template file for 'gstreamer1'
 pkgname=gstreamer1
-version=1.20.3
+version=1.22.2
 revision=1
 build_style=meson
 build_helper="gir"
@@ -16,7 +16,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.0-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/gstreamer/gstreamer-${version}.tar.xz"
-checksum=607daf64bbbd5fb18af9d17e21c0d22c4d702fffe83b23cb22d1b1af2ca23a2a
+checksum=b2afe73603921c608ba48969dbb7d743776744bfe5d8059ece241137b7f88e21
 
 pre_check() {
 	# gst_gstdatetime is known to fail according to LFS
diff --git a/srcpkgs/mlt7/template b/srcpkgs/mlt7/template
index 9fb7f60d692e..cca0eb68cfc3 100644
--- a/srcpkgs/mlt7/template
+++ b/srcpkgs/mlt7/template
@@ -1,7 +1,7 @@
 # Template file for 'mlt7'
 pkgname=mlt7
 version=7.14.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSWIG_PYTHON=ON"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which

From 211368a3a80f245ae0cd7677ac4b247360cfa969 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 7 May 2023 20:15:03 -0400
Subject: [PATCH 113/115] qt6-webengine: revbump for ffmpeg-6.0

---
 srcpkgs/qt6-webengine/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-webengine/template b/srcpkgs/qt6-webengine/template
index 96846feaee83..2f85d2e49ba2 100644
--- a/srcpkgs/qt6-webengine/template
+++ b/srcpkgs/qt6-webengine/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-webengine'
 pkgname=qt6-webengine
 version=6.4.2
-revision=2
+revision=3
 build_style=cmake
 configure_args="
  -DQT_FEATURE_webengine_system_ffmpeg=ON

From 698dae0d5267c5794ed12fa9d73ad32c31118b46 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 7 May 2023 20:15:29 -0400
Subject: [PATCH 114/115] tracker-miners: revbump for ffmpeg-6.0

---
 srcpkgs/tracker-miners/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tracker-miners/template b/srcpkgs/tracker-miners/template
index 8c005d697fa4..a6e5aa577702 100644
--- a/srcpkgs/tracker-miners/template
+++ b/srcpkgs/tracker-miners/template
@@ -1,7 +1,7 @@
 # Template file for 'tracker-miners'
 pkgname=tracker-miners
 version=3.5.0
-revision=3
+revision=4
 build_style=meson
 build_helper=qemu
 # missing libgrss for miner_rss

From c44c15e7be63d789f3c77a2a99c14b1317625070 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 7 May 2023 20:20:58 -0400
Subject: [PATCH 115/115] mpd: revbump for ffmpeg-6.0

---
 srcpkgs/mpd/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpd/template b/srcpkgs/mpd/template
index df35e751ea60..c832f608b889 100644
--- a/srcpkgs/mpd/template
+++ b/srcpkgs/mpd/template
@@ -1,7 +1,7 @@
 # Template file for 'mpd'
 pkgname=mpd
 version=0.23.12
-revision=2
+revision=3
 build_style=meson
 configure_args="-Dopus=enabled -Dmikmod=enabled -Dneighbor=true
  -Dsoundcloud=enabled -Dpipe=true -Dtwolame=enabled -Dbzip2=enabled

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (6 preceding siblings ...)
  2023-05-08  0:23 ` zlice
@ 2023-05-29  1:43 ` zlice
  2023-06-04 15:47 ` zlice
                   ` (89 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2023-05-29  1:43 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 3336 bytes --]

There is an updated pull request by zlice against master on the void-packages repository

https://github.com/zlice/void-packages ffmpeg6-split
https://github.com/void-linux/void-packages/pull/43761

ffmpeg6 split
[ci skip]


#### Testing the changes

- I tested the changes in this PR: **YES**

main testing has been vaapi in Firefox Nightly and enc/dec in Shotcut on Intel A770

#### New package

- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**

#### Local build testing

- I built this PR locally for my native architecture, **x86_64**

#### Discussion

Continuation of https://github.com/void-linux/void-packages/pull/36315

`libavresample` is deprecated, but marked as a dependency when trying to build other packages and install `ffmpeg`(6). I think the right way to handle this is make a meta package and the add to removals?


##### Commit naming / misc

~~Commits are 'dirty' right now, running with [gstreamer 1.22.1 updates](https://github.com/void-linux/void-packages/pull/42861) and [Intel OpenCL](https://github.com/void-linux/void-packages/pull/43084). This will also make [intel packages pr](https://github.com/void-linux/void-packages/pull/41132) obsolete.~~ (see Requirements below)

Maintainer for previous ffmpeg(4) was orphaned, I can put my name in there if that matters, though I don't exactly see myself keeping up on ffmpeg.

This updates QT5 which looks like it is usually hosted by Johnny. Not sure if there's any reason to stay there or these sources are fine.

##### STILL FFMPEG4

These are a mix of emulators, games and/or older packages.

- attract (multiple patches in master)
- audacity  (3.2.x+ should work but requires wxWidgets dev 3.1.x)
- ccextractor (master patches? no release)
- vice
- kodi
- mlt (only dep left is flowblade)
- ~~synfig (mlt)~~ (work with mlt7, bump synfigstudio)
- tvheadend
- ssr
- spek-alternative
- ppsspp
- olive
- moc
- mediastreamer
- libextractor
- idjc
- hedgewars
- ~~ffmpegthumbnailer~~ (patches for moviedecoder.xxx files)
- ~~ffmpegthumbs~~ (latest compiles)
- deadbeef
- omxplayer
- qtav (fork has ffmpeg 5 patch - https://github.com/cmguo/QtAV)
- `vlc` (vlc4 will support ffmpeg5, there's a patch to build 3.x with ffmpeg5 but it will lack vaapi)
- `osg` (OpenSceneGraph plus `xine-lib`)


##### HAVE NOT BUILT YET

- omxplayer (rpi only? ffmpeg4)
- kodi (big, but ffmpeg4)


##### UPDATED (for ffmpeg6)

- ~~blender: update to 3.5.1~~ will be revbump with https://github.com/void-linux/void-packages/pull/43992
- unpaper: update to 7.0.0.
- guvcview: update to 2.0.8.
- qt5: update to 5.15.8
- qt5-webengine: update to 5.18.13
- shiboken2: revbump for qt5.15.8 (patch)
- python3-pyside2: update to 5.15.8 (patch)


##### Requirements

- [gstreamer 1.22.2](https://github.com/void-linux/void-packages/pull/42861) - a few packages use ffmpeg-devel and require a revbump

- [Intel Packages](https://github.com/void-linux/void-packages/pull/41132) - ffmpeg4 uses different libraries than 6 (libmfx / Intel-MediaSDK vs only oneVPL that Intel is moving to), both are included here

A patch file from https://github.com/void-linux/void-packages/pull/43761.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ffmpeg6-split-43761.patch --]
[-- Type: text/x-diff, Size: 785284 bytes --]

From d5c6fdefbc13d6594697c10f5253de4d97aa02ab Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:55:46 -0400
Subject: [PATCH 001/113] ffmpeg: update to 6.0.

---
 common/shlibs                                 | 26 +++++---
 srcpkgs/ffmpeg/files/altivec.patch            | 60 -------------------
 .../patches/armv5tel-floating-point.patch     | 18 ------
 .../workaround-mesa-readeon-vaapi-bug.patch   | 28 ---------
 srcpkgs/ffmpeg/template                       | 38 +++++-------
 5 files changed, 32 insertions(+), 138 deletions(-)
 delete mode 100644 srcpkgs/ffmpeg/files/altivec.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch

diff --git a/common/shlibs b/common/shlibs
index f1e825819fb4..371e4ff11aa1 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -390,15 +390,23 @@ libid3tag.so.0 libid3tag-0.15.1b_1
 libgif.so.7 giflib-5.1.0_1
 libImlib2.so.1 imlib2-1.4.2_1
 libmp3lame.so.0 lame-3.98.2_1
-libavdevice.so.58 libavdevice-4.0_1
-libavformat.so.58 libavformat-4.0_1
-libswscale.so.5 libswscale-4.0_1
-libswresample.so.3 libswresample-4.0_1
-libavresample.so.4 libavresample-4.0_1
-libpostproc.so.55 libpostproc-4.0_1
-libavcodec.so.58 libavcodec-4.0_1
-libavutil.so.56 libavutil-4.0_1
-libavfilter.so.7 libavfilter-4.0_1
+libavdevice.so.60 libavdevice-6.0_1
+libavformat.so.60 libavformat-6.0_1
+libswscale.so.7 libswscale-6.0_1
+libswresample.so.4 libswresample-6.0_1
+libpostproc.so.57 libpostproc-6.0_1
+libavcodec.so.60 libavcodec-6.0_1
+libavutil.so.58 libavutil-6.0_1
+libavfilter.so.9 libavfilter-6.0_1
+libavdevice.so.58 libavdevice4-4.0_1
+libavformat.so.58 libavformat4-4.0_1
+libswscale.so.5 libswscale4-4.0_1
+libswresample.so.3 libswresample4-4.0_1
+libavresample.so.4 libavresample4-4.0_1
+libpostproc.so.55 libpostproc4-4.0_1
+libavcodec.so.58 libavcodec4-4.0_1
+libavutil.so.56 libavutil4-4.0_1
+libavfilter.so.7 libavfilter4-4.0_1
 libSDL-1.2.so.0 SDL-1.2.14_1
 libSDL_image-1.2.so.0 SDL_image-1.2.10_1
 libx264.so.157 x264-20190507.2245_1
diff --git a/srcpkgs/ffmpeg/files/altivec.patch b/srcpkgs/ffmpeg/files/altivec.patch
deleted file mode 100644
index 9c5720046332..000000000000
--- a/srcpkgs/ffmpeg/files/altivec.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-revert some altivec specific change on all ppc* except ppc64le*
-
-q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
-conditionally, for ppc* but not ppc64le* (the new code is valid for
-POWER8 VSX which LE targets as a baseline but not BE)"
-
-
-This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
----
- libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
- 1 file changed, 20 insertions(+), 4 deletions(-)
-
-diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
-index 536545293d..c1e2852adb 100644
---- a/libswscale/ppc/yuv2rgb_altivec.c
-+++ b/libswscale/ppc/yuv2rgb_altivec.c
-@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-     vector signed short R1, G1, B1;                                           \
-     vector unsigned char R, G, B;                                             \
-                                                                               \
-+    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
-+    vector unsigned char align_perm;                                          \
-+                                                                              \
-     vector signed short lCY       = c->CY;                                    \
-     vector signed short lOY       = c->OY;                                    \
-     vector signed short lCRV      = c->CRV;                                   \
-@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
-                                                                               \
-         for (j = 0; j < w / 16; j++) {                                        \
--            y0 = vec_xl(0, y1i);                                              \
-+            y1ivP = (const vector unsigned char *) y1i;                       \
-+            y2ivP = (const vector unsigned char *) y2i;                       \
-+            uivP  = (const vector unsigned char *) ui;                        \
-+            vivP  = (const vector unsigned char *) vi;                        \
-+                                                                              \
-+            align_perm = vec_lvsl(0, y1i);                                    \
-+            y0 = (vector unsigned char)                                       \
-+                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
-                                                                               \
--            y1 = vec_xl(0, y2i);                                              \
-+            align_perm = vec_lvsl(0, y2i);                                    \
-+            y1 = (vector unsigned char)                                       \
-+                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
-                                                                               \
--            u = (vector signed char) vec_xl(0, ui);                           \
-+            align_perm = vec_lvsl(0, ui);                                     \
-+            u = (vector signed char)                                          \
-+                    vec_perm(uivP[0], uivP[1], align_perm);                   \
-                                                                               \
--            v = (vector signed char) vec_xl(0, vi);                           \
-+            align_perm = vec_lvsl(0, vi);                                     \
-+            v = (vector signed char)                                          \
-+                    vec_perm(vivP[0], vivP[1], align_perm);                   \
-                                                                               \
-             u = (vector signed char)                                          \
-                     vec_sub(u,                                                \
--- 
-2.27.0
-
diff --git a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
deleted file mode 100644
index 9a55178c74f0..000000000000
--- a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
-+++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
-@@ -39,6 +39,15 @@
- #endif
- #include <fenv.h>
- 
-+#if (FE_ALL_EXCEPT == 0)
-+/* E.g. ARM soft float does not define these */
-+#define FE_INVALID    0
-+#define FE_DIVBYZERO  0
-+#define FE_OVERFLOW   0
-+#define FE_UNDERFLOW  0
-+#define FE_INEXACT    0
-+#endif
-+
- #if CONFIG_LIBFONTCONFIG
- #include <fontconfig/fontconfig.h>
- #endif
diff --git a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
deleted file mode 100644
index 00e3f68a415b..000000000000
--- a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
-From: Rainer Hochecker <fernetmenta@online.de>
-Date: Sat, 26 Jan 2019 19:48:35 +0100
-Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
-
-This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
-It was hit frequently when watching h264 channels received via DVB-X.
-Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
----
- libavcodec/vaapi_h264.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
-index 5854587a255..f12fdc457a4 100644
---- a/libavcodec/vaapi_h264.c
-+++ b/libavcodec/vaapi_h264.c
-@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
-     H264SliceContext *sl = &h->slice_ctx[0];
-     int ret;
- 
-+    if (pic->nb_slices == 0) {
-+        ret = AVERROR_INVALIDDATA;
-+        goto finish;
-+    }
-+
-     ret = ff_vaapi_decode_issue(avctx, pic);
-     if (ret < 0)
-         goto finish;
diff --git a/srcpkgs/ffmpeg/template b/srcpkgs/ffmpeg/template
index df4179d1963a..f742082bb520 100644
--- a/srcpkgs/ffmpeg/template
+++ b/srcpkgs/ffmpeg/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpeg'
 # audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
 pkgname=ffmpeg
-version=4.4.4
+version=6.0
 revision=1
 short_desc="Decoding, encoding and streaming software"
 maintainer="Orphaned <orphan@voidlinux.org>"
@@ -9,7 +9,7 @@ license="GPL-3.0-or-later"
 homepage="https://www.ffmpeg.org"
 changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
 distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
-checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+checksum=57be87c22d9b49c112b6d24bc67d42508660e6b718b3db89c44e47e289137082
 
 hostmakedepends="pkg-config perl"
 makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
@@ -26,12 +26,13 @@ makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-deve
  $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
  $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
  $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
- $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers Vulkan-Tools Vulkan-ValidationLayers')
+ $(vopt_if onevpl 'onevpl onevpl-devel')
  $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
 depends="ffplay>=${version}_${revision}"
 
 build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
- dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec onevpl"
 build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
 desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
 desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
@@ -39,10 +40,8 @@ desc_option_sofa="Enable support for AES SOFA"
 desc_option_webp="Enable support for WebP"
 
 case "$XBPS_TARGET_MACHINE" in
-	i686*|x86_64*)
-		hostmakedepends+=" nasm"
-		build_options_default+=" vaapi vdpau nvenc nvdec"
-		;;
+	i686*) build_options_default+=" vaapi vdpau nvenc nvdec";;
+	x86_64*) build_options_default+=" vaapi vdpau nvenc nvdec onevpl";;
 	ppc64*) build_options_default+=" vaapi vdpau";;
 	mips*) CFLAGS="-mnan=legacy";;
 esac
@@ -117,18 +116,19 @@ do_configure() {
 		$(vopt_enable x265 libx265) \
 		$(vopt_enable v4l2 libv4l2) \
 		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
-		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		--enable-libbs2b --enable-libvidstab \
 		$(vopt_enable dav1d libdav1d) \
 		$(vopt_enable zimg libzimg) \
 		$(vopt_enable webp libwebp) \
 		$(vopt_enable sofa libmysofa) \
 		$(vopt_enable vulkan) \
+		$(vopt_enable onevpl libvpl) \
 		$(vopt_enable drm libdrm) \
 		$(vopt_enable svtav1 libsvtav1) \
 		$(vopt_enable srt libsrt) \
 		$(vopt_enable rist librist) \
-		$(vopt_if nvenc '--enable-nvenc') \
-		$(vopt_if nvdec '--enable-nvdec')
+		$(vopt_enable nvenc nvenc) \
+		$(vopt_enable nvdec nvdec)
 }
 
 do_build() {
@@ -155,10 +155,8 @@ libavdevice_package() {
 }
 
 libavresample_package() {
-	short_desc="FFmpeg audio resampling library"
-	pkg_install() {
-		vmove "usr/lib/libavresample.so.*"
-	}
+	short_desc="Package deprecated, removal needed"
+	build_style=meta
 }
 
 libavformat_package() {
@@ -212,15 +210,9 @@ ffmpeg-devel_package() {
 		libavfilter>=${version}_${revision}
 		libpostproc>=${version}_${revision}
 		libswscale>=${version}_${revision}
-		libswresample>=${version}_${revision}
-		libavresample>=${version}_${revision}"
+		libswresample>=${version}_${revision}"
 	short_desc+=" - development files"
-
-	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
-		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
-		nostrip_files="/usr/lib/libavfilter.a"
-	fi
-
+	conflicts="ffmpeg4-devel"
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig

From 9bc85f30b9a74d000fdaa7b814cd964dbe60e2a9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:56:22 -0400
Subject: [PATCH 002/113] New package: ffmpeg4-4.4.4.

---
 srcpkgs/ffmpeg4-devel                         |   1 +
 srcpkgs/ffmpeg4/files/altivec.patch           |  60 +++++
 .../patches/armv5tel-floating-point.patch     |  18 ++
 .../workaround-mesa-readeon-vaapi-bug.patch   |  28 +++
 srcpkgs/ffmpeg4/template                      | 238 ++++++++++++++++++
 srcpkgs/libavcodec4                           |   1 +
 srcpkgs/libavdevice4                          |   1 +
 srcpkgs/libavfilter4                          |   1 +
 srcpkgs/libavformat4                          |   1 +
 srcpkgs/libavresample4                        |   1 +
 srcpkgs/libavutil4                            |   1 +
 srcpkgs/libpostproc4                          |   1 +
 srcpkgs/libswresample4                        |   1 +
 srcpkgs/libswscale4                           |   1 +
 14 files changed, 354 insertions(+)
 create mode 120000 srcpkgs/ffmpeg4-devel
 create mode 100644 srcpkgs/ffmpeg4/files/altivec.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
 create mode 100644 srcpkgs/ffmpeg4/template
 create mode 120000 srcpkgs/libavcodec4
 create mode 120000 srcpkgs/libavdevice4
 create mode 120000 srcpkgs/libavfilter4
 create mode 120000 srcpkgs/libavformat4
 create mode 120000 srcpkgs/libavresample4
 create mode 120000 srcpkgs/libavutil4
 create mode 120000 srcpkgs/libpostproc4
 create mode 120000 srcpkgs/libswresample4
 create mode 120000 srcpkgs/libswscale4

diff --git a/srcpkgs/ffmpeg4-devel b/srcpkgs/ffmpeg4-devel
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/ffmpeg4-devel
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/ffmpeg4/files/altivec.patch b/srcpkgs/ffmpeg4/files/altivec.patch
new file mode 100644
index 000000000000..9c5720046332
--- /dev/null
+++ b/srcpkgs/ffmpeg4/files/altivec.patch
@@ -0,0 +1,60 @@
+revert some altivec specific change on all ppc* except ppc64le*
+
+q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
+conditionally, for ppc* but not ppc64le* (the new code is valid for
+POWER8 VSX which LE targets as a baseline but not BE)"
+
+
+This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
+---
+ libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
+ 1 file changed, 20 insertions(+), 4 deletions(-)
+
+diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
+index 536545293d..c1e2852adb 100644
+--- a/libswscale/ppc/yuv2rgb_altivec.c
++++ b/libswscale/ppc/yuv2rgb_altivec.c
+@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+     vector signed short R1, G1, B1;                                           \
+     vector unsigned char R, G, B;                                             \
+                                                                               \
++    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
++    vector unsigned char align_perm;                                          \
++                                                                              \
+     vector signed short lCY       = c->CY;                                    \
+     vector signed short lOY       = c->OY;                                    \
+     vector signed short lCRV      = c->CRV;                                   \
+@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
+                                                                               \
+         for (j = 0; j < w / 16; j++) {                                        \
+-            y0 = vec_xl(0, y1i);                                              \
++            y1ivP = (const vector unsigned char *) y1i;                       \
++            y2ivP = (const vector unsigned char *) y2i;                       \
++            uivP  = (const vector unsigned char *) ui;                        \
++            vivP  = (const vector unsigned char *) vi;                        \
++                                                                              \
++            align_perm = vec_lvsl(0, y1i);                                    \
++            y0 = (vector unsigned char)                                       \
++                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
+                                                                               \
+-            y1 = vec_xl(0, y2i);                                              \
++            align_perm = vec_lvsl(0, y2i);                                    \
++            y1 = (vector unsigned char)                                       \
++                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
+                                                                               \
+-            u = (vector signed char) vec_xl(0, ui);                           \
++            align_perm = vec_lvsl(0, ui);                                     \
++            u = (vector signed char)                                          \
++                    vec_perm(uivP[0], uivP[1], align_perm);                   \
+                                                                               \
+-            v = (vector signed char) vec_xl(0, vi);                           \
++            align_perm = vec_lvsl(0, vi);                                     \
++            v = (vector signed char)                                          \
++                    vec_perm(vivP[0], vivP[1], align_perm);                   \
+                                                                               \
+             u = (vector signed char)                                          \
+                     vec_sub(u,                                                \
+-- 
+2.27.0
+
diff --git a/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
new file mode 100644
index 000000000000..9a55178c74f0
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
@@ -0,0 +1,18 @@
+--- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
++++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
+@@ -39,6 +39,15 @@
+ #endif
+ #include <fenv.h>
+ 
++#if (FE_ALL_EXCEPT == 0)
++/* E.g. ARM soft float does not define these */
++#define FE_INVALID    0
++#define FE_DIVBYZERO  0
++#define FE_OVERFLOW   0
++#define FE_UNDERFLOW  0
++#define FE_INEXACT    0
++#endif
++
+ #if CONFIG_LIBFONTCONFIG
+ #include <fontconfig/fontconfig.h>
+ #endif
diff --git a/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
new file mode 100644
index 000000000000..00e3f68a415b
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
@@ -0,0 +1,28 @@
+From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
+From: Rainer Hochecker <fernetmenta@online.de>
+Date: Sat, 26 Jan 2019 19:48:35 +0100
+Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
+
+This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
+It was hit frequently when watching h264 channels received via DVB-X.
+Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
+---
+ libavcodec/vaapi_h264.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
+index 5854587a255..f12fdc457a4 100644
+--- a/libavcodec/vaapi_h264.c
++++ b/libavcodec/vaapi_h264.c
+@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
+     H264SliceContext *sl = &h->slice_ctx[0];
+     int ret;
+ 
++    if (pic->nb_slices == 0) {
++        ret = AVERROR_INVALIDDATA;
++        goto finish;
++    }
++
+     ret = ff_vaapi_decode_issue(avctx, pic);
+     if (ret < 0)
+         goto finish;
diff --git a/srcpkgs/ffmpeg4/template b/srcpkgs/ffmpeg4/template
new file mode 100644
index 000000000000..5228c7df08fb
--- /dev/null
+++ b/srcpkgs/ffmpeg4/template
@@ -0,0 +1,238 @@
+# Template file for 'ffmpeg4'
+# audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
+pkgname=ffmpeg4
+version=4.4.4
+revision=1
+short_desc="Decoding, encoding and streaming software - ffmpeg4 libraries only"
+maintainer="Orphaned <orphan@voidlinux.org>"
+license="GPL-3.0-or-later"
+homepage="https://www.ffmpeg.org"
+changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
+distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
+checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+
+hostmakedepends="pkg-config perl"
+makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
+ libXext-devel libXvMC-devel libxcb-devel lame-devel libtheora-devel
+ libvorbis-devel x264-devel xvidcore-devel jack-devel SDL2-devel
+ libcdio-paranoia-devel librtmp-devel libmodplug-devel gnutls-devel
+ speex-devel celt-devel harfbuzz-devel libass-devel opus-devel ocl-icd-devel
+ libbs2b-devel libvidstab-devel $(vopt_if pulseaudio pulseaudio-devel)
+ $(vopt_if vaapi libva-devel) $(vopt_if vdpau libvdpau-devel)
+ $(vopt_if x265 x265-devel) $(vopt_if v4l2 v4l-utils-devel)
+ $(vopt_if fdk_aac fdk-aac-devel) $(vopt_if vpx libvpx-devel)
+ $(vopt_if aom libaom-devel) $(vopt_if sndio sndio-devel)
+ $(vopt_if dav1d libdav1d-devel) $(vopt_if zimg zimg-devel)
+ $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
+ $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
+ $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if mfx 'libmfx libmfx-devel')
+ $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
+
+build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec mfx"
+build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
+
+desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
+desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
+desc_option_sofa="Enable support for AES SOFA"
+desc_option_webp="Enable support for WebP"
+
+case "$XBPS_TARGET_MACHINE" in
+	i686*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau nvenc nvdec"
+			;;
+	x86_64*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau mfx nvenc nvdec"
+			;;
+	ppc64*) build_options_default+=" vaapi vdpau";;
+	mips*) CFLAGS="-mnan=legacy";;
+esac
+
+if [ "$XBPS_TARGET_WORDSIZE" != "32" ]; then
+	build_options_default+=" svtav1"
+fi
+
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+fi
+
+_apply_patch() {
+	local args="$1" pname="$(basename $2)"
+
+	if [ ! -f ".${pname}_done" ]; then
+		patch -N $args -i $2
+		touch .${pname}_done
+	fi
+}
+
+post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64le*) ;;
+		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
+	esac
+}
+
+do_configure() {
+	# Fix gcc on x86_64-musl only
+	if [ "$XBPS_TARGET_MACHINE" = "x86_64-musl" ]; then
+		vsed -i configure -e "s;_cflags_speed='-O3';_cflags_speed='-O2';"
+	fi
+
+	if [ "$CROSS_BUILD" ]; then
+		case "$XBPS_TARGET_MACHINE" in
+			arm*) _arch="arm";;
+			aarch64*) _arch="aarch64";;
+			mips*) _arch="mips";;
+			ppc64*) _arch="ppc64";;
+			ppc*) _arch="ppc";;
+			*) _arch="${XBPS_TARGET_MACHINE%%-musl}";;
+		esac
+
+		_args+=" --enable-cross-compile
+			--sysroot=$XBPS_CROSS_BASE
+			--cross-prefix=${XBPS_CROSS_TRIPLET}-
+			--target-os=linux --arch=${_arch}"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc|ppc-musl) _args+=" --disable-altivec";;
+	esac
+
+	if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+		_args+=" --extra-libs=-latomic"
+	fi
+
+	./configure --prefix=/usr --disable-debug --enable-gpl --enable-gnutls \
+		--disable-stripping \
+		--enable-libcdio --enable-version3 --enable-runtime-cpudetect \
+		--enable-libmp3lame --enable-libvorbis --enable-libxvid \
+		--enable-libx264 $(vopt_enable vpx libvpx) --enable-libtheora \
+		--enable-shared --enable-static --enable-libxcb \
+		$(vopt_enable pulseaudio libpulse) --enable-libfreetype --enable-libmodplug \
+		--enable-libspeex --enable-libcelt --enable-libass \
+		--enable-libopus --enable-librtmp --enable-libjack \
+		$(vopt_if fdk_aac '--enable-nonfree --enable-libfdk-aac') \
+		--disable-libopencore_amrnb --disable-libopencore_amrwb \
+		--disable-libopenjpeg \
+		--enable-postproc --enable-opencl ${_args} \
+		$(vopt_enable x265 libx265) \
+		$(vopt_enable v4l2 libv4l2) \
+		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
+		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		$(vopt_enable dav1d libdav1d) \
+		$(vopt_enable zimg libzimg) \
+		$(vopt_enable webp libwebp) \
+		$(vopt_enable sofa libmysofa) \
+		$(vopt_enable vulkan) \
+		$(vopt_enable drm libdrm) \
+		$(vopt_enable svtav1 libsvtav1) \
+		$(vopt_enable srt libsrt) \
+		$(vopt_enable rist librist) \
+		$(vopt_enable mfx libmfx) \
+		$(vopt_if nvenc '--enable-nvenc') \
+		$(vopt_if nvdec '--enable-nvdec')
+}
+
+do_build() {
+	make ${makejobs}
+	make doc/ff{mpeg,play}.1
+}
+
+do_install() {
+	make DESTDIR=${DESTDIR} install install-man
+	rm -rf ${DESTDIR}/usr/bin
+}
+
+libavcodec4_package() {
+	short_desc="FFmpeg codec library"
+	pkg_install() {
+		vmove "usr/lib/libavcodec.so.*"
+	}
+}
+
+libavdevice4_package() {
+	short_desc="FFmpeg device handling library"
+	pkg_install() {
+		vmove "usr/lib/libavdevice.so.*"
+	}
+}
+
+libavresample4_package() {
+	short_desc="FFmpeg audio resampling library"
+	pkg_install() {
+		vmove "usr/lib/libavresample.so.*"
+	}
+}
+
+libavformat4_package() {
+	short_desc="FFmpeg file format library"
+	pkg_install() {
+		vmove "usr/lib/libavformat.so.*"
+	}
+}
+
+libavutil4_package() {
+	short_desc="FFmpeg utility library"
+	pkg_install() {
+		vmove "usr/lib/libavutil.so.*"
+	}
+}
+
+libavfilter4_package() {
+	short_desc="FFmpeg audio/video filter library"
+	pkg_install() {
+		vmove "usr/lib/libavfilter.so.*"
+	}
+}
+
+libpostproc4_package() {
+	short_desc="FFmpeg video postprocessing library"
+	pkg_install() {
+		vmove "usr/lib/libpostproc.so.*"
+	}
+}
+
+libswscale4_package() {
+	short_desc="FFmpeg video scaling library"
+	pkg_install() {
+		vmove "usr/lib/libswscale.so.*"
+	}
+}
+
+libswresample4_package() {
+	short_desc="FFmpeg video resampling library"
+	pkg_install() {
+		vmove "usr/lib/libswresample.so.*"
+	}
+}
+
+ffmpeg4-devel_package() {
+	depends="
+		libavcodec4>=${version}_${revision}
+		libavdevice4>=${version}_${revision}
+		libavformat4>=${version}_${revision}
+		libavutil4>=${version}_${revision}
+		libavfilter4>=${version}_${revision}
+		libpostproc4>=${version}_${revision}
+		libswscale4>=${version}_${revision}
+		libswresample4>=${version}_${revision}
+		libavresample4>=${version}_${revision}"
+	short_desc+=" - development files"
+	conflicts="ffmpeg-devel"
+	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
+		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
+		nostrip_files="/usr/lib/libavfilter.a"
+	fi
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.a"
+		vmove "usr/lib/*.so"
+		vmove usr/share/ffmpeg/examples
+		vmove usr/share/man/man3
+	}
+}
diff --git a/srcpkgs/libavcodec4 b/srcpkgs/libavcodec4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavcodec4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavdevice4 b/srcpkgs/libavdevice4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavdevice4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavfilter4 b/srcpkgs/libavfilter4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavfilter4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavformat4 b/srcpkgs/libavformat4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavformat4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavresample4 b/srcpkgs/libavresample4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavutil4 b/srcpkgs/libavutil4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavutil4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libpostproc4 b/srcpkgs/libpostproc4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libpostproc4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswresample4 b/srcpkgs/libswresample4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libswresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswscale4 b/srcpkgs/libswscale4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libswscale4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file

From d8975c8329d4d0565f176ad41881012b0a8a031a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:04 -0400
Subject: [PATCH 003/113] opencv: update to 4.7.0.

---
 common/shlibs           | 104 ++++++++++++++++++++--------------------
 srcpkgs/opencv/template |   8 ++--
 2 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index 371e4ff11aa1..8cb5ff0f7457 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2138,58 +2138,58 @@ libcapstone.so.4 capstone-4.0_1
 libhavege.so.2 libhaveged-1.9.11_1
 libnih.so.1 libnih-1.0.3_1
 libnih-dbus.so.1 libnih-1.0.3_1
-libopencv_quality.so.406 libopencv-4.6.0_1
-libopencv_reg.so.406 libopencv-4.6.0_1
-libopencv_surface_matching.so.406 libopencv-4.6.0_1
-libopencv_xphoto.so.406 libopencv-4.6.0_1
-libopencv_freetype.so.406 libopencv-4.6.0_1
-libopencv_fuzzy.so.406 libopencv-4.6.0_1
-libopencv_hfs.so.406 libopencv-4.6.0_1
-libopencv_img_hash.so.406 libopencv-4.6.0_1
-libopencv_line_descriptor.so.406 libopencv-4.6.0_1
-libopencv_saliency.so.406 libopencv-4.6.0_1
-libopencv_structured_light.so.406 libopencv-4.6.0_1
-libopencv_aruco.so.406 libopencv-4.6.0_1
-libopencv_bgsegm.so.406 libopencv-4.6.0_1
-libopencv_bioinspired.so.406 libopencv-4.6.0_1
-libopencv_ccalib.so.406 libopencv-4.6.0_1
-libopencv_face.so.406 libopencv-4.6.0_1
-libopencv_tracking.so.406 libopencv-4.6.0_1
-libopencv_xfeatures2d.so.406 libopencv-4.6.0_1
-libopencv_optflow.so.406 libopencv-4.6.0_1
-libopencv_ximgproc.so.406 libopencv-4.6.0_1
-libopencv_plot.so.406 libopencv-4.6.0_1
-libopencv_text.so.406 libopencv-4.6.0_1
-libopencv_ml.so.406 libopencv-4.6.0_1
-libopencv_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn.so.406 libopencv-4.6.0_1
-libopencv_shape.so.406 libopencv-4.6.0_1
-libopencv_stitching.so.406 libopencv-4.6.0_1
-libopencv_photo.so.406 libopencv-4.6.0_1
-libopencv_video.so.406 libopencv-4.6.0_1
-libopencv_calib3d.so.406 libopencv-4.6.0_1
-libopencv_features2d.so.406 libopencv-4.6.0_1
-libopencv_flann.so.406 libopencv-4.6.0_1
-libopencv_highgui.so.406 libopencv-4.6.0_1
-libopencv_videoio.so.406 libopencv-4.6.0_1
-libopencv_imgcodecs.so.406 libopencv-4.6.0_1
-libopencv_imgproc.so.406 libopencv-4.6.0_1
-libopencv_core.so.406 libopencv-4.6.0_1
-libopencv_superres.so.406 libopencv-4.6.0_1
-libopencv_videostab.so.406 libopencv-4.6.0_1
-libopencv_gapi.so.406 libopencv-4.6.0_1
-libopencv_xobjdetect.so.406 libopencv-4.6.0_1
-libopencv_datasets.so.406 libopencv-4.6.0_1
-libopencv_dnn_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn_superres.so.406 libopencv-4.6.0_1
-libopencv_dpm.so.406 libopencv-4.6.0_1
-libopencv_phase_unwrapping.so.406 libopencv-4.6.0_1
-libopencv_stereo.so.406 libopencv-4.6.0_1
-libopencv_rapid.so.406 libopencv-4.6.0_1
-libopencv_intensity_transform.so.406 libopencv-4.6.0_1
-libopencv_alphamat.so.406 libopencv-4.6.0_1
-libopencv_barcode.so.406 libopencv-4.6.0_1
-libopencv_mcc.so.406 libopencv-4.6.0_1
+libopencv_quality.so.407 libopencv-4.7.0_1
+libopencv_reg.so.407 libopencv-4.7.0_1
+libopencv_surface_matching.so.407 libopencv-4.7.0_1
+libopencv_xphoto.so.407 libopencv-4.7.0_1
+libopencv_freetype.so.407 libopencv-4.7.0_1
+libopencv_fuzzy.so.407 libopencv-4.7.0_1
+libopencv_hfs.so.407 libopencv-4.7.0_1
+libopencv_img_hash.so.407 libopencv-4.7.0_1
+libopencv_line_descriptor.so.407 libopencv-4.7.0_1
+libopencv_saliency.so.407 libopencv-4.7.0_1
+libopencv_structured_light.so.407 libopencv-4.7.0_1
+libopencv_aruco.so.407 libopencv-4.7.0_1
+libopencv_bgsegm.so.407 libopencv-4.7.0_1
+libopencv_bioinspired.so.407 libopencv-4.7.0_1
+libopencv_ccalib.so.407 libopencv-4.7.0_1
+libopencv_face.so.407 libopencv-4.7.0_1
+libopencv_tracking.so.407 libopencv-4.7.0_1
+libopencv_xfeatures2d.so.407 libopencv-4.7.0_1
+libopencv_optflow.so.407 libopencv-4.7.0_1
+libopencv_ximgproc.so.407 libopencv-4.7.0_1
+libopencv_plot.so.407 libopencv-4.7.0_1
+libopencv_text.so.407 libopencv-4.7.0_1
+libopencv_ml.so.407 libopencv-4.7.0_1
+libopencv_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn.so.407 libopencv-4.7.0_1
+libopencv_shape.so.407 libopencv-4.7.0_1
+libopencv_stitching.so.407 libopencv-4.7.0_1
+libopencv_photo.so.407 libopencv-4.7.0_1
+libopencv_video.so.407 libopencv-4.7.0_1
+libopencv_calib3d.so.407 libopencv-4.7.0_1
+libopencv_features2d.so.407 libopencv-4.7.0_1
+libopencv_flann.so.407 libopencv-4.7.0_1
+libopencv_highgui.so.407 libopencv-4.7.0_1
+libopencv_videoio.so.407 libopencv-4.7.0_1
+libopencv_imgcodecs.so.407 libopencv-4.7.0_1
+libopencv_imgproc.so.407 libopencv-4.7.0_1
+libopencv_core.so.407 libopencv-4.7.0_1
+libopencv_superres.so.407 libopencv-4.7.0_1
+libopencv_videostab.so.407 libopencv-4.7.0_1
+libopencv_gapi.so.407 libopencv-4.7.0_1
+libopencv_xobjdetect.so.407 libopencv-4.7.0_1
+libopencv_datasets.so.407 libopencv-4.7.0_1
+libopencv_dnn_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn_superres.so.407 libopencv-4.7.0_1
+libopencv_dpm.so.407 libopencv-4.7.0_1
+libopencv_phase_unwrapping.so.407 libopencv-4.7.0_1
+libopencv_stereo.so.407 libopencv-4.7.0_1
+libopencv_rapid.so.407 libopencv-4.7.0_1
+libopencv_intensity_transform.so.407 libopencv-4.7.0_1
+libopencv_alphamat.so.407 libopencv-4.7.0_1
+libopencv_barcode.so.407 libopencv-4.7.0_1
+libopencv_mcc.so.407 libopencv-4.7.0_1
 libuniconf.so.4.6 wvstreams-4.6.1_20
 libwvbase.so.4.6 wvstreams-4.6.1_20
 libwvutils.so.4.6 wvstreams-4.6.1_20
diff --git a/srcpkgs/opencv/template b/srcpkgs/opencv/template
index 69c635b1ad2b..41f3183f1582 100644
--- a/srcpkgs/opencv/template
+++ b/srcpkgs/opencv/template
@@ -1,7 +1,7 @@
 # Template file for 'opencv'
 pkgname=opencv
-version=4.6.0
-revision=4
+version=4.7.0
+revision=1
 create_wrksrc=yes
 build_wrksrc=${pkgname}-${version}
 build_style=cmake
@@ -24,8 +24,8 @@ homepage="https://opencv.org"
 changelog="https://github.com/opencv/opencv/wiki/ChangeLog"
 distfiles="https://github.com/opencv/opencv/archive/${version}.tar.gz
  https://github.com/opencv/opencv_contrib/archive/${version}.tar.gz>contrib.tar.gz"
-checksum="1ec1cba65f9f20fe5a41fda1586e01c70ea0c9a6d7b67c9e13edf0cfe2239277
- 1777d5fd2b59029cf537e5fd6f8aa68d707075822f90bde683fcde086f85f7a7"
+checksum="8df0079cdbe179748a18d44731af62a245a45ebf5085223dc03133954c662973
+ 42df840cf9055e59d0e22c249cfb19f04743e1bdad113d31b1573d3934d62584"
 patch_args="-Np1 -d ${build_wrksrc}"
 # tests hang indenfinitely, even with test data included
 make_check=no

From 2d9046a902bb05c5ed2dfe78a51aa7f862a98c1b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 004/113] actiona: revbump for opencv-4.7.0

---
 srcpkgs/actiona/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/actiona/template b/srcpkgs/actiona/template
index cf5f0b7a2ae6..0d899311e6df 100644
--- a/srcpkgs/actiona/template
+++ b/srcpkgs/actiona/template
@@ -1,7 +1,7 @@
 # Template file for 'actiona'
 pkgname=actiona
 version=3.10.1
-revision=2
+revision=3
 build_style=qmake
 configure_args="PKGCONFIG_OPENCV=opencv4"
 hostmakedepends="pkg-config qt5-plugin-mysql qt5-qmake qt5-host-tools"

From 1aa3fb40730d812682a6de2c61101187ebdeccfa Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 005/113] gmic: revbump for opencv-4.7.0

---
 srcpkgs/gmic/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gmic/template b/srcpkgs/gmic/template
index 24a9c7218fdf..0bb4034d5cc8 100644
--- a/srcpkgs/gmic/template
+++ b/srcpkgs/gmic/template
@@ -1,7 +1,7 @@
 # Template file for 'gmic'
 pkgname=gmic
 version=3.1.6
-revision=3
+revision=4
 _zart_hash=34ebf6cce0bafb98abe57cec83c4a02cd1abeca0
 create_wrksrc=yes
 build_wrksrc="src"

From 2e483a731a92414cec2431ef03a2864c46148887 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 006/113] qimgv: revbump for opencv-4.7.0

---
 srcpkgs/qimgv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qimgv/template b/srcpkgs/qimgv/template
index 7eb30db33992..dd341dfe1bfc 100644
--- a/srcpkgs/qimgv/template
+++ b/srcpkgs/qimgv/template
@@ -1,7 +1,7 @@
 # Template file for 'qimgv'
 pkgname=qimgv
 version=1.0.2
-revision=2
+revision=3
 build_style=cmake
 configure_args="$(vopt_if video -DVIDEO_SUPPORT=ON -DVIDEO_SUPPORT=OFF)
  $(vopt_if scale -DOPENCV_SUPPORT=ON -DOPENCV_SUPPORT=OFF)

From 19cae0de21654f98d7ecfd56c1468f2852c9a663 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 007/113] retroshare: revbump for opencv-4.7.0

---
 srcpkgs/retroshare/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroshare/template b/srcpkgs/retroshare/template
index 8a0786c21a08..72023fa98b75 100644
--- a/srcpkgs/retroshare/template
+++ b/srcpkgs/retroshare/template
@@ -1,7 +1,7 @@
 # Template file for 'retroshare'
 pkgname=retroshare
 version=0.6.6
-revision=2
+revision=4
 build_style=qmake
 #XXX broadcast feature requires an ancient udp-discovery-cpp which either needs
 # to be fetched+patched (FTBFS) here or packaged :/

From a9b8cc4bb37271625cd7a2906349ffadb050ca2e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 008/113] siril: revbump for opencv-4.7.0

---
 srcpkgs/siril/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/siril/template b/srcpkgs/siril/template
index e88f30fb6178..84332f79d060 100644
--- a/srcpkgs/siril/template
+++ b/srcpkgs/siril/template
@@ -1,7 +1,7 @@
 # Template file for 'siril'
 pkgname=siril
 version=0.9.12
-revision=9
+revision=10
 build_style=gnu-configure
 hostmakedepends="pkg-config intltool autoconf automake gettext-devel"
 makedepends="fftw-devel libconfig-devel libopencv-devel libffms2-devel

From 3214c1e239c798129a4d04a51476af9d364ce5c1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 009/113] waifu2x-converter-cpp: revbump for opencv-4.7.0

---
 srcpkgs/waifu2x-converter-cpp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waifu2x-converter-cpp/template b/srcpkgs/waifu2x-converter-cpp/template
index 8c095d0d7bab..aa52d8c981a8 100644
--- a/srcpkgs/waifu2x-converter-cpp/template
+++ b/srcpkgs/waifu2x-converter-cpp/template
@@ -1,7 +1,7 @@
 # Template file for 'waifu2x-converter-cpp'
 pkgname=waifu2x-converter-cpp
 version=5.2.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DINSTALL_MODELS=ON"
 hostmakedepends="pkg-config"

From e0d12d4b5cd3ead65c6cf96a47370a9b2086978e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:38 -0400
Subject: [PATCH 010/113] vlc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/vlc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/vlc/template b/srcpkgs/vlc/template
index 210762b0a7e2..855ca5238662 100644
--- a/srcpkgs/vlc/template
+++ b/srcpkgs/vlc/template
@@ -1,7 +1,7 @@
 # Template file for 'vlc'
 pkgname=vlc
 version=3.0.18
-revision=3
+revision=4
 build_style=gnu-configure
 configure_args="--disable-gme --disable-libtar --enable-jack
  --enable-live555 --disable-fluidsynth --enable-dvdread
@@ -25,7 +25,7 @@ lib32disabled=yes
 hostmakedepends="automake libtool pkg-config flex gettext libgcrypt-devel
  live555-devel gettext-devel $(vopt_if lua lua52) $(vopt_if chromecast protobuf)"
 makedepends="
- avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg-devel freefont-ttf
+ avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg4-devel freefont-ttf
  gnutls-devel jack-devel liba52-devel libass-devel libbluray-devel
  libcdio-devel libdca-devel libdvbpsi-devel libdvdnav-devel libmad-devel
  libmatroska-devel libmodplug-devel libmpcdec-devel libmpeg2-devel

From fa941e18d6b52166da41d8ae7e63f8a2cd0c0f2e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:55 -0400
Subject: [PATCH 011/113] osg: revbump for ffmpeg4-4.4.3

---
 srcpkgs/osg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/osg/template b/srcpkgs/osg/template
index a9ebbd287933..755793f7e11b 100644
--- a/srcpkgs/osg/template
+++ b/srcpkgs/osg/template
@@ -8,7 +8,7 @@ build_helper="qemu"
 configure_args="-DLIB_POSTFIX="
 hostmakedepends="pkg-config xrandr"
 makedepends="MesaLib-devel gtkglext-devel libcurl-devel giflib-devel librsvg-devel
- jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg-devel xine-lib-devel
+ jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg4-devel xine-lib-devel
  SDL2-devel gst-plugins-base1-devel
  $(vopt_if openexr libopenexr-devel)
  $(vopt_if poppler poppler-glib-devel)

From a174da9af8aa41c8577b840c470136721afcbe53 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:13 -0400
Subject: [PATCH 012/113] xine-lib: revbump for ffmpeg4-4.4.3

---
 srcpkgs/xine-lib/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/xine-lib/template b/srcpkgs/xine-lib/template
index f713eff49b07..ed6194c17d11 100644
--- a/srcpkgs/xine-lib/template
+++ b/srcpkgs/xine-lib/template
@@ -1,6 +1,6 @@
 # Template file for 'xine-lib'
 pkgname=xine-lib
-version=1.2.12
+version=1.2.13
 revision=1
 build_style=gnu-configure
 configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
@@ -8,7 +8,7 @@ configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
 hostmakedepends="automake gettext-devel libtool pkg-config perl"
 makedepends="
  zlib-devel alsa-lib-devel libxcb-devel libSM-devel libXext-devel libXv-devel
- libXvMC-devel liba52-devel libmad-devel ffmpeg-devel pulseaudio-devel
+ libXvMC-devel liba52-devel libmad-devel ffmpeg4-devel pulseaudio-devel
  jack-devel samba-devel libflac-devel libmodplug-devel libmpcdec-devel
  speex-devel libtheora-devel libvorbis-devel libdca-devel faad2-devel
  libcdio-devel libbluray-devel aalib-devel libcaca-devel libXinerama-devel
@@ -19,7 +19,7 @@ license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="http://www.xine-project.org"
 changelog="https://sourceforge.net/projects/xine/files/xine-lib/${version}/README.txt/view"
 distfiles="${SOURCEFORGE_SITE}/xine/${pkgname}-${version}.tar.xz"
-checksum=d606270468e1540c2a89c0d7f5fdf11e17ecc0c2698cc0bcb1065ff26abee098
+checksum=5f10d6d718a4a51c17ed1b32b031d4f9b80b061e8276535b2be31e5ac4b75e6f
 
 case "$XBPS_TARGET_MACHINE" in
 	i686-musl)

From e0d2dc7db5bd285c88376d01cd3e66f96cdacb5f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 013/113] QMPlay2: revbump for ffmpeg-6.0

---
 srcpkgs/QMPlay2/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/QMPlay2/template b/srcpkgs/QMPlay2/template
index ad73cbb01bae..55284c051161 100644
--- a/srcpkgs/QMPlay2/template
+++ b/srcpkgs/QMPlay2/template
@@ -1,7 +1,7 @@
 # Template file for 'QMPlay2'
 pkgname=QMPlay2
 version=23.02.05
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools"
 makedepends="alsa-lib-devel ffmpeg-devel libass-devel libcdio-devel libgme-devel

From 23d1443cbfdb5a75da2e3c9e78a1b50601d2634c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 014/113] alsa-plugins: revbump for ffmpeg-6.0

---
 srcpkgs/alsa-plugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/alsa-plugins/template b/srcpkgs/alsa-plugins/template
index 0bfa6d9fd264..a5708a7d82a8 100644
--- a/srcpkgs/alsa-plugins/template
+++ b/srcpkgs/alsa-plugins/template
@@ -1,7 +1,7 @@
 # Template file for 'alsa-plugins'
 pkgname=alsa-plugins
 version=1.2.7.1
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--disable-maemo-plugin"
 hostmakedepends="pkg-config"

From c925ef5494ac63f5627378d3e040a81cf847cb44 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 015/113] arcan: revbump for ffmpeg-6.0

---
 srcpkgs/arcan/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/arcan/template b/srcpkgs/arcan/template
index 7be9652eccf3..ccc7df11ceac 100644
--- a/srcpkgs/arcan/template
+++ b/srcpkgs/arcan/template
@@ -2,7 +2,7 @@
 # !! keep synced with: acfgfs aclip aloadimage
 pkgname=arcan
 version=0.6.2.1
-revision=1
+revision=2
 create_wrksrc=yes
 build_wrksrc=arcan/src
 build_style=cmake

From 3ef0e5fc9b03920896ce40120d29ce01b0e2976a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 016/113] attract: revbump for ffmpeg4-4.4.3

---
 srcpkgs/attract/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/attract/template b/srcpkgs/attract/template
index 26144e931a3c..e760bf0d18ae 100644
--- a/srcpkgs/attract/template
+++ b/srcpkgs/attract/template
@@ -1,12 +1,12 @@
 # Template file for 'attract'
 pkgname=attract
 version=2.6.2
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="VERBOSE=1"
 make_use_env=yes
 hostmakedepends="pkg-config"
-makedepends="SFML-devel ffmpeg-devel fontconfig-devel glu-devel libarchive-devel
+makedepends="SFML-devel ffmpeg4-devel fontconfig-devel glu-devel libarchive-devel
  libcurl-devel libjpeg-turbo-devel xine-lib rapidjson libXrandr-devel"
 depends="git"
 short_desc="Attract-Mode is a graphical frontend for emulators"

From 81d6a7a7579319d61b2c81d352cb9c2de071b9ad Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 017/113] aubio: revbump for ffmpeg-6.0

---
 srcpkgs/aubio/patches/ffmpeg5.patch | 25 +++++++++++++++++++++++++
 srcpkgs/aubio/template              |  2 +-
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/aubio/patches/ffmpeg5.patch

diff --git a/srcpkgs/aubio/patches/ffmpeg5.patch b/srcpkgs/aubio/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..aace41a6e6d9
--- /dev/null
+++ b/srcpkgs/aubio/patches/ffmpeg5.patch
@@ -0,0 +1,25 @@
+From 8a05420e5dd8c7b8b2447f82dc919765876511b3 Mon Sep 17 00:00:00 2001
+From: Paul Brossier <piem@piem.org>
+Date: Tue, 25 Jan 2022 18:30:27 +0100
+Subject: [PATCH] [source_avcodec] define FF_API_LAVF_AVCTX for libavcodec >
+ 59, thx @berolinux (closes gh-353)
+
+---
+ src/io/source_avcodec.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/io/source_avcodec.c b/src/io/source_avcodec.c
+index e0ae93b5..1421bd9a 100644
+--- a/src/io/source_avcodec.c
++++ b/src/io/source_avcodec.c
+@@ -68,6 +68,10 @@
+ #define AUBIO_AVCODEC_MAX_BUFFER_SIZE AV_INPUT_BUFFER_MIN_SIZE
+ #endif
+ 
++#if LIBAVCODEC_VERSION_MAJOR >= 59
++#define FF_API_LAVF_AVCTX 1
++#endif
++
+ struct _aubio_source_avcodec_t {
+   uint_t hop_size;
+   uint_t samplerate;
diff --git a/srcpkgs/aubio/template b/srcpkgs/aubio/template
index ad1c4b256991..7d875cc02541 100644
--- a/srcpkgs/aubio/template
+++ b/srcpkgs/aubio/template
@@ -1,7 +1,7 @@
 # Template file for 'aubio'
 pkgname=aubio
 version=0.4.9
-revision=1
+revision=2
 build_style=waf3
 # XXX lash, pure and swig support.
 hostmakedepends="pkg-config txt2man"

From 690a45dccdcfd3be935c60cec2b74017cde993a2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 018/113] audacious-plugins: revbump for ffmpeg-6.0

---
 .../audacious-plugins/patches/ffmpeg5.patch   | 43 +++++++++++++++++++
 srcpkgs/audacious-plugins/template            |  2 +-
 2 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/audacious-plugins/patches/ffmpeg5.patch

diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg5.patch b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..4e5e34099d71
--- /dev/null
+++ b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
@@ -0,0 +1,43 @@
+commit 298aa371c56c2f52c25a33d9bdec4918b11cebdc
+Author: tibequadorian <tibequadorian@posteo.de>
+Date:   Sat Mar 19 18:40:12 2022 +0100
+
+    audacious-plugins: rebuild against ffmpeg-5.0
+
+diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+new file mode 100644
+index 0000000000..617c11215b
+--- /dev/null
++++ b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+@@ -0,0 +1,31 @@
++From f60beb400eeb1e4778bbfd738bc4a4ccef3de539 Mon Sep 17 00:00:00 2001
++From: John Lindgren <john@jlindgren.net>
++Date: Sat, 5 Mar 2022 12:05:34 -0500
++Subject: [PATCH] Fix build with FFmpeg 5.0
++
++---
++ src/ffaudio/ffaudio-core.cc | 4 ++--
++ 1 file changed, 2 insertions(+), 2 deletions(-)
++
++diff --git a/src/ffaudio/ffaudio-core.cc b/src/ffaudio/ffaudio-core.cc
++index 16dc63e3a..a2b95fd6c 100644
++--- a/src/ffaudio/ffaudio-core.cc
+++++ b/src/ffaudio/ffaudio-core.cc
++@@ -274,7 +274,7 @@ static AVInputFormat * get_format_by_content (const char * name, VFSFile & file)
++         AVProbeData d = {name, buf, filled};
++         score = target;
++ 
++-        f = av_probe_input_format2 (& d, true, & score);
+++        f = (AVInputFormat *) av_probe_input_format2 (& d, true, & score);
++         if (f)
++             break;
++ 
++@@ -347,7 +347,7 @@ static bool find_codec (AVFormatContext * c, CodecInfo * cinfo)
++ #endif
++         if (stream && stream->codecpar && stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
++         {
++-            AVCodec * codec = avcodec_find_decoder (stream->codecpar->codec_id);
+++            AVCodec * codec = (AVCodec *) avcodec_find_decoder (stream->codecpar->codec_id);
++ 
++             if (codec)
++             {
diff --git a/srcpkgs/audacious-plugins/template b/srcpkgs/audacious-plugins/template
index 88cbc1671fc6..beebfae59ed4 100644
--- a/srcpkgs/audacious-plugins/template
+++ b/srcpkgs/audacious-plugins/template
@@ -2,7 +2,7 @@
 #Keep in sync with audacious!
 pkgname=audacious-plugins
 version=4.3.1
-revision=1
+revision=2
 build_style=meson
 configure_args="$(vopt_bool gtk3 gtk) $(vopt_bool gtk3)
  $(vopt_bool qt) $(vopt_bool qt qt6)"

From b988a316310239c7c52e48cc6bf0ac4779db6a5d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 019/113] audacity: revbump for ffmpeg4-4.4.3

---
 srcpkgs/audacity/template | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/audacity/template b/srcpkgs/audacity/template
index d509c0a89407..11e20255685b 100644
--- a/srcpkgs/audacity/template
+++ b/srcpkgs/audacity/template
@@ -1,7 +1,7 @@
 # Template file for 'audacity'
 pkgname=audacity
 version=2.4.1
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--with-ffmpeg=system --with-libsndfile=system --with-expat=system
  --with-libsoxr=system --with-lame=system --with-lv2=system ac_cv_path_WX_CONFIG=wx-config-gtk3"
@@ -9,7 +9,7 @@ hostmakedepends="pkg-config cmake gettext libtool m4 which"
 makedepends="jack-devel wxWidgets-gtk3-devel gtk+3-devel
  libmad-devel soundtouch-devel libsoxr-devel
  vamp-plugin-sdk-devel lame-devel libid3tag-devel libflac-devel
- ffmpeg-devel twolame-devel serd-devel lv2 lilv-devel suil-devel"
+ ffmpeg4-devel twolame-devel serd-devel lv2 lilv-devel suil-devel"
 depends="desktop-file-utils hicolor-icon-theme"
 short_desc="Graphical cross-platform audio editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
@@ -33,5 +33,4 @@ post_install() {
 	vcopy plug-ins /usr/share/audacity
 
 	rm ${DESTDIR}/usr/share/doc/audacity/LICENSE.txt
-	vlicense LICENSE.txt LICENSE
 }

From 85b8be67a2c1d4ce6598721614fa59fc7a9577dc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 020/113] avidemux: revbump for ffmpeg-6.0

---
 srcpkgs/avidemux/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/avidemux/template b/srcpkgs/avidemux/template
index 253a0243e225..557285982d2b 100644
--- a/srcpkgs/avidemux/template
+++ b/srcpkgs/avidemux/template
@@ -1,7 +1,7 @@
 # Template file for 'avidemux'
 pkgname=avidemux
 version=2.8.0
-revision=2
+revision=3
 # Can't be compiled for aarch64, arm* or mips*
 archs="x86_64* i686*"
 hostmakedepends="cmake pkg-config qt5-host-tools qt5-devel tar yasm"

From f7c3fa5758a7c359009c9526ab8129c3b55f31a4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 021/113] baresip: revbump for ffmpeg-6.0

---
 srcpkgs/baresip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/baresip/template b/srcpkgs/baresip/template
index f1bd1817048b..b21e22334316 100644
--- a/srcpkgs/baresip/template
+++ b/srcpkgs/baresip/template
@@ -1,7 +1,7 @@
 # Template file for 'baresip'
 pkgname=baresip
 version=2.10.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config glib-devel"
 makedepends="libgsm-devel libpng-devel openssl-devel libsndfile-devel

From 6839e620329230527734dd59a91639d373220982 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 022/113] blender: revbump for ffmpeg-6.0

---
 srcpkgs/blender/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index ec724bb0a6dc..0f72876d4d70 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -1,7 +1,7 @@
 # Template file for 'blender'
 pkgname=blender
 version=3.5.1
-revision=1
+revision=2
 archs="x86_64* ppc64*"
 build_style="cmake"
 pycompile_dirs="/usr/share/blender/${version%.*}/scripts"
@@ -9,8 +9,8 @@ configure_args="-DWITH_INSTALL_PORTABLE=OFF -DWITH_PYTHON_INSTALL=OFF
  -DWITH_JACK=ON -DWITH_CODEC_FFMPEG=ON -DWITH_CODEC_SNDFILE=ON -DWITH_OPENMP=ON
  -DWITH_FFTW3=ON -DWITH_MOD_OCEANSIM=ON -DWITH_CYCLES_EMBREE=OFF -DWITH_OPENCOLORIO=ON
  -DWITH_IMAGE_OPENEXR=ON -DWITH_IMAGE_OPENJPEG=ON -DWITH_OPENSUBDIV=ON
- -DWITH_OPENCOLLADA=ON -DWITH_SYSTEM_GLEW=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
- -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_LIBDECOR=ON
+ -DWITH_OPENCOLLADA=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
+ -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_WAYLAND_LIBDECOR=ON
  -DWITH_BUILDINFO=OFF -DPYTHON_VERSION=${py3_ver} -DPYTHON_LIBPATH=/usr/lib
  -DPYTHON_LIBRARY=python${py3_ver}${py3_abiver} -DPYTHON_INCLUDE_DIRS=/${py3_inc}
  -DWITH_SYSTEM_LZO=ON -DWITH_SYSTEM_EIGEN3=ON -DWITH_SYSTEM_FREETYPE=ON"

From c2f3df750cadc5b0cde59b979dd8bc1d4120db7e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 023/113] cantata: revbump for ffmpeg-6.0

---
 srcpkgs/cantata/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cantata/template b/srcpkgs/cantata/template
index 4b417d80d5c2..8a90aaa4c07a 100644
--- a/srcpkgs/cantata/template
+++ b/srcpkgs/cantata/template
@@ -1,7 +1,7 @@
 # Template file for 'cantata'
 pkgname=cantata
 version=2.5.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools qt5-tools"
 makedepends="qt5-devel qt5-tools-devel qt5-svg-devel qt5-xmlpatterns-devel

From cd8ee1eb823ebaec8872457ff73d47ba673c1832 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 024/113] ccextractor: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ccextractor/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/ccextractor/template b/srcpkgs/ccextractor/template
index 9abcd82852b2..6eccad5885af 100644
--- a/srcpkgs/ccextractor/template
+++ b/srcpkgs/ccextractor/template
@@ -1,12 +1,12 @@
 # Template file for 'ccextractor'
 pkgname=ccextractor
 version=0.93
-revision=1
+revision=2
 build_wrksrc="linux"
 build_style=gnu-configure
 configure_args="--enable-ocr --enable-hardsubx"
 hostmakedepends="automake pkg-config"
-makedepends="leptonica-devel tesseract-ocr-devel ffmpeg-devel"
+makedepends="leptonica-devel tesseract-ocr-devel ffmpeg4-devel"
 short_desc="Extract subtitles from video streams"
 maintainer="newbluemoon <blaumolch@mailbox.org>"
 license="GPL-2.0-or-later"

From 4a432c7e27e4ceaec4aa4c3a2e4b811a4767e879 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 025/113] chromaprint: revbump for ffmpeg-6.0

---
 srcpkgs/chromaprint/patches/ffmpeg5.patch | 569 ++++++++++++++++++++++
 srcpkgs/chromaprint/template              |   2 +-
 2 files changed, 570 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromaprint/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromaprint/patches/ffmpeg5.patch b/srcpkgs/chromaprint/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..a9fd307a23c8
--- /dev/null
+++ b/srcpkgs/chromaprint/patches/ffmpeg5.patch
@@ -0,0 +1,569 @@
+From 8ccad6937177b1b92e40ab8f4447ea27bac009a7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= <lalinsky@gmail.com>
+Date: Fri, 4 Nov 2022 21:47:38 +0100
+Subject: [PATCH] Use FFmpeg 5.x (#120)
+
+* Use FFmpeg 5.1.2 for CI builds
+
+* Build on Ubuntu 20.04
+
+* Upgrade code to FFmpeg 5.x APIs
+
+* Only set FFmpeg include dirs if building tools
+
+* No longer needed
+
+* Use ubuntu 20.04
+---
+ .github/workflows/build.yml                   |   6 +-
+ CMakeLists.txt                                |  16 --
+ package/build.sh                              |   4 +-
+ src/audio/ffmpeg_audio_processor.h            |   2 -
+ src/audio/ffmpeg_audio_processor_avresample.h |  72 -------
+ src/audio/ffmpeg_audio_processor_swresample.h |  18 +-
+ src/audio/ffmpeg_audio_reader.h               | 197 +++++++++---------
+ tests/CMakeLists.txt                          |   6 +
+ 8 files changed, 122 insertions(+), 199 deletions(-)
+ delete mode 100644 src/audio/ffmpeg_audio_processor_avresample.h
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index f8d6a32..4da2405 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -84,9 +84,6 @@ find_package(FFmpeg)
+ if(FFMPEG_LIBRARIES)
+ 	cmake_push_check_state(RESET)
+ 	set(CMAKE_REQUIRED_LIBRARIES ${FFMPEG_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -lm)
+-	check_function_exists(av_packet_unref HAVE_AV_PACKET_UNREF)
+-	check_function_exists(av_frame_alloc HAVE_AV_FRAME_ALLOC)
+-	check_function_exists(av_frame_free HAVE_AV_FRAME_FREE)
+ 	cmake_pop_check_state()
+ endif()
+
+@@ -163,14 +160,11 @@ message(STATUS "Using ${FFT_LIB} for FFT calculations")
+ if(NOT AUDIO_PROCESSOR_LIB)
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+ 		set(AUDIO_PROCESSOR_LIB "swresample")
+-	elseif(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(AUDIO_PROCESSOR_LIB "avresample")
+ 	endif()
+ endif()
+
+ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE OFF)
+ 		set(USE_SWRESAMPLE ON)
+ 		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBSWRESAMPLE_LIBRARIES})
+ 		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBSWRESAMPLE_INCLUDE_DIRS})
+@@ -178,16 +172,6 @@ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+ 	endif()
+ 	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+-elseif(AUDIO_PROCESSOR_LIB STREQUAL "avresample")
+-	if(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE ON)
+-		set(USE_SWRESAMPLE OFF)
+-		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBAVRESAMPLE_LIBRARIES})
+-		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBAVRESAMPLE_INCLUDE_DIRS})
+-	else()
+-		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+-	endif()
+-	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+ else()
+ 	message(STATUS "Building without audio conversion support, please install FFmpeg with libswresample")
+ endif()
+diff --git a/package/build.sh b/package/build.sh
+index da631ae..b41d36e 100755
+--- a/package/build.sh
++++ b/package/build.sh
+@@ -7,8 +7,8 @@ set -eux
+
+ BASE_DIR=$(cd $(dirname $0)/.. && pwd)
+
+-FFMPEG_VERSION=4.4.1
+-FFMPEG_BUILD_TAG=v4.4.1-1
++FFMPEG_VERSION=5.1.2
++FFMPEG_BUILD_TAG=v${FFMPEG_VERSION}-1
+
+ TMP_BUILD_DIR=$BASE_DIR/$(mktemp -d build.XXXXXXXX)
+ trap 'rm -rf $TMP_BUILD_DIR' EXIT
+diff --git a/src/audio/ffmpeg_audio_processor.h b/src/audio/ffmpeg_audio_processor.h
+index 7628fc7..39f4f6d 100644
+--- a/src/audio/ffmpeg_audio_processor.h
++++ b/src/audio/ffmpeg_audio_processor.h
+@@ -10,8 +10,6 @@
+
+ #if defined(USE_SWRESAMPLE)
+ #include "audio/ffmpeg_audio_processor_swresample.h"
+-#elif defined(USE_AVRESAMPLE)
+-#include "audio/ffmpeg_audio_processor_avresample.h"
+ #else
+ #error "no audio processing library"
+ #endif
+diff --git a/src/audio/ffmpeg_audio_processor_avresample.h b/src/audio/ffmpeg_audio_processor_avresample.h
+deleted file mode 100644
+index bd85f92..0000000
+--- a/src/audio/ffmpeg_audio_processor_avresample.h
++++ /dev/null
+@@ -1,72 +0,0 @@
+-// Copyright (C) 2016  Lukas Lalinsky
+-// Distributed under the MIT license, see the LICENSE file for details.
+-
+-#ifndef CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-#define CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-
+-extern "C" {
+-#include <libavresample/avresample.h>
+-}
+-
+-namespace chromaprint {
+-
+-class FFmpegAudioProcessor {
+-public:
+-	FFmpegAudioProcessor() {
+-		m_resample_ctx = avresample_alloc_context();
+-	}
+-
+-	~FFmpegAudioProcessor() {
+-		avresample_free(&m_resample_ctx);
+-	}
+-
+-	void SetCompatibleMode() {
+-		av_opt_set_int(m_resample_ctx, "filter_size", 16, 0);
+-		av_opt_set_int(m_resample_ctx, "phase_shift", 8, 0);
+-		av_opt_set_int(m_resample_ctx, "linear_interp", 1, 0);
+-		av_opt_set_double(m_resample_ctx, "cutoff", 0.8, 0);
+-	}
+-
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "in_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_rate", sample_rate, 0);
+-	}
+-
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "out_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_rate, 0);
+-	}
+-
+-	int Init() {
+-		return avresample_open(m_resample_ctx);
+-	}
+-
+-	int Convert(uint8_t **out, int out_count, const uint8_t **in, int in_count) {
+-		return avresample_convert(m_resample_ctx, out, 0, out_count, (uint8_t **) in, 0, in_count);
+-	}
+-
+-	int Flush(uint8_t **out, int out_count) {
+-		return avresample_read(m_resample_ctx, out, out_count);
+-	}
+-
+-private:
+-	AVAudioResampleContext *m_resample_ctx = nullptr;
+-};
+-
+-}; // namespace chromaprint
+-
+-#endif
+diff --git a/src/audio/ffmpeg_audio_processor_swresample.h b/src/audio/ffmpeg_audio_processor_swresample.h
+index b86266b..b1d4bea 100644
+--- a/src/audio/ffmpeg_audio_processor_swresample.h
++++ b/src/audio/ffmpeg_audio_processor_swresample.h
+@@ -28,30 +28,28 @@ public:
+ 		av_opt_set_double(m_swr_ctx, "cutoff", 0.8, 0);
+ 	}
+
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "icl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "ich", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetInputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "in_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "isf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "in_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "isr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "in_sample_rate", sample_rate, 0);
+ 	}
+
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "ocl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "och", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetOutputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "out_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "osf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "out_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "osr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "out_sample_rate", sample_rate, 0);
+ 	}
+
+ 	int Init() {
+diff --git a/src/audio/ffmpeg_audio_reader.h b/src/audio/ffmpeg_audio_reader.h
+index 5550164..1c6b346 100644
+--- a/src/audio/ffmpeg_audio_reader.h
++++ b/src/audio/ffmpeg_audio_reader.h
+@@ -62,7 +62,7 @@ public:
+ 	bool Read(const int16_t **data, size_t *size);
+
+ 	bool IsOpen() const { return m_opened; }
+-	bool IsFinished() const { return m_finished && !m_got_frame; }
++	bool IsFinished() const { return !m_has_more_packets && !m_has_more_frames; }
+
+ 	std::string GetError() const { return m_error; }
+ 	int GetErrorCode() const { return m_error_code; }
+@@ -74,20 +74,19 @@ private:
+ 	uint8_t *m_convert_buffer[1] = { nullptr };
+ 	int m_convert_buffer_nb_samples = 0;
+
+-	AVInputFormat *m_input_fmt = nullptr;
++	const AVInputFormat *m_input_fmt = nullptr;
+ 	AVDictionary *m_input_opts = nullptr;
+
+ 	AVFormatContext *m_format_ctx = nullptr;
+ 	AVCodecContext *m_codec_ctx = nullptr;
+-	AVFrame *m_frame = nullptr;
+ 	int m_stream_index = -1;
+ 	std::string m_error;
+ 	int m_error_code = 0;
+-	bool m_finished = false;
+ 	bool m_opened = false;
+-	int m_got_frame = 0;
+-	AVPacket m_packet;
+-	AVPacket m_packet0;
++	bool m_has_more_packets = true;
++	bool m_has_more_frames = true;
++	AVPacket *m_packet = nullptr;
++	AVFrame *m_frame = nullptr;
+
+ 	int m_output_sample_rate = 0;
+ 	int m_output_channels = 0;
+@@ -98,19 +97,12 @@ private:
+
+ inline FFmpegAudioReader::FFmpegAudioReader() {
+ 	av_log_set_level(AV_LOG_QUIET);
+-
+-	av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
+ }
+
+ inline FFmpegAudioReader::~FFmpegAudioReader() {
+ 	Close();
+ 	av_dict_free(&m_input_opts);
+ 	av_freep(&m_convert_buffer[0]);
+-	av_packet_unref(&m_packet0);
+ }
+
+ inline bool FFmpegAudioReader::SetInputFormat(const char *name) {
+@@ -135,11 +127,10 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ 	Close();
+
+-    av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
++	m_packet = av_packet_alloc();
++	if (!m_packet) {
++		return false;
++	}
+
+ 	ret = avformat_open_input(&m_format_ctx, file_name.c_str(), m_input_fmt, &m_input_opts);
+ 	if (ret < 0) {
+@@ -153,26 +144,31 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		return false;
+ 	}
+
+-	AVCodec *codec;
++	const AVCodec *codec;
+ 	ret = av_find_best_stream(m_format_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &codec, 0);
+ 	if (ret < 0) {
+ 		SetError("Could not find any audio stream in the file", ret);
+ 		return false;
+ 	}
+ 	m_stream_index = ret;
++	auto stream = m_format_ctx->streams[m_stream_index];
+
+-	m_codec_ctx = m_format_ctx->streams[m_stream_index]->codec;
++	m_codec_ctx = avcodec_alloc_context3(codec);
+ 	m_codec_ctx->request_sample_fmt = AV_SAMPLE_FMT_S16;
+
++	ret = avcodec_parameters_to_context(m_codec_ctx, stream->codecpar);
++	if (ret < 0) {
++		SetError("Could not copy the stream parameters", ret);
++		return false;
++	}
++
+ 	ret = avcodec_open2(m_codec_ctx, codec, nullptr);
+ 	if (ret < 0) {
+ 		SetError("Could not open the codec", ret);
+ 		return false;
+ 	}
+
+-	if (!m_codec_ctx->channel_layout) {
+-		m_codec_ctx->channel_layout = av_get_default_channel_layout(m_codec_ctx->channels);
+-	}
++	av_dump_format(m_format_ctx, 0, "foo", 0);
+
+ 	m_frame = av_frame_alloc();
+ 	if (!m_frame) {
+@@ -183,19 +179,23 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		m_output_sample_rate = m_codec_ctx->sample_rate;
+ 	}
+
+-	if (!m_output_channels) {
+-		m_output_channels = m_codec_ctx->channels;
++	AVChannelLayout output_channel_layout;
++	if (m_output_channels) {
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
++	} else {
++		m_output_channels = m_codec_ctx->ch_layout.nb_channels;
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
+ 	}
+
+-	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
++	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->ch_layout.nb_channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
+ 		m_converter.reset(new FFmpegAudioProcessor());
+ 		m_converter->SetCompatibleMode();
+ 		m_converter->SetInputSampleFormat(m_codec_ctx->sample_fmt);
+ 		m_converter->SetInputSampleRate(m_codec_ctx->sample_rate);
+-		m_converter->SetInputChannelLayout(m_codec_ctx->channel_layout);
++		m_converter->SetInputChannelLayout(&(m_codec_ctx->ch_layout));
+ 		m_converter->SetOutputSampleFormat(AV_SAMPLE_FMT_S16);
+ 		m_converter->SetOutputSampleRate(m_output_sample_rate);
+-		m_converter->SetOutputChannelLayout(av_get_default_channel_layout(m_output_channels));
++		m_converter->SetOutputChannelLayout(&output_channel_layout);
+ 		auto ret = m_converter->Init();
+ 		if (ret != 0) {
+ 			SetError("Could not create an audio converter instance", ret);
+@@ -203,10 +203,11 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		}
+ 	}
+
++	av_channel_layout_uninit(&output_channel_layout);
++
+ 	m_opened = true;
+-	m_finished = false;
+-	m_got_frame = 0;
+-	m_nb_packets = 0;
++	m_has_more_packets = true;
++	m_has_more_frames = true;
+ 	m_decode_error = 0;
+
+ 	return true;
+@@ -214,6 +215,7 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ inline void FFmpegAudioReader::Close() {
+ 	av_frame_free(&m_frame);
++	av_packet_free(&m_packet);
+
+ 	m_stream_index = -1;
+
+@@ -252,91 +254,98 @@ inline bool FFmpegAudioReader::Read(const int16_t **data, size_t *size) {
+ 		return false;
+ 	}
+
++	*data = nullptr;
++	*size = 0;
++
+ 	int ret;
++	bool needs_packet = false;
+ 	while (true) {
+-		while (m_packet.size <= 0) {
+-			av_packet_unref(&m_packet0);
+-			av_init_packet(&m_packet);
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			ret = av_read_frame(m_format_ctx, &m_packet);
++		while (needs_packet && m_packet->size == 0) {
++			ret = av_read_frame(m_format_ctx, m_packet);
+ 			if (ret < 0) {
+ 				if (ret == AVERROR_EOF) {
+-					m_finished = true;
++					needs_packet = false;
++					m_has_more_packets = false;
+ 					break;
+-				} else {
++				}
++				SetError("Error reading from the audio source", ret);
++				return false;
++			}
++			if (m_packet->stream_index == m_stream_index) {
++				needs_packet = false;
++			} else {
++				av_packet_unref(m_packet);
++			}
++		}
++
++		if (m_packet->size != 0) {
++			ret = avcodec_send_packet(m_codec_ctx, m_packet);
++			if (ret < 0) {
++				if (ret != AVERROR(EAGAIN)) {
+ 					SetError("Error reading from the audio source", ret);
+ 					return false;
+ 				}
+-			}
+-			m_packet0 = m_packet;
+-			if (m_packet.stream_index != m_stream_index) {
+-				m_packet.data = nullptr;
+-				m_packet.size = 0;
+ 			} else {
+-				m_nb_packets++;
++				av_packet_unref(m_packet);
+ 			}
+ 		}
+
+-		ret = avcodec_decode_audio4(m_codec_ctx, m_frame, &m_got_frame, &m_packet);
++		ret = avcodec_receive_frame(m_codec_ctx, m_frame);
+ 		if (ret < 0) {
+-			if (m_decode_error) {
+-				SetError("Error decoding audio frame", m_decode_error);
+-				return false;
++			if (ret == AVERROR_EOF) {
++				m_has_more_frames = false;
++			} else if (ret == AVERROR(EAGAIN)) {
++				if (m_has_more_packets) {
++					needs_packet = true;
++					continue;
++				} else {
++					m_has_more_frames = false;
++				}
+ 			}
+-			m_decode_error = ret;
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			continue;
++			SetError("Error decoding the audio source", ret);
++			return false;
+ 		}
+
+-		break;
+-	}
+-
+-	m_decode_error = 0;
+-
+-	const int decoded = std::min(ret, m_packet.size);
+-	m_packet.data += decoded;
+-	m_packet.size -= decoded;
+-
+-	if (m_got_frame) {
+-		if (m_converter) {
+-			if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
+-				int linsize;
+-				av_freep(&m_convert_buffer[0]);
+-				m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
+-				ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
+-				if (ret < 0) {
+-					SetError("Couldn't allocate audio converter buffer", ret);
++		if (m_frame->nb_samples > 0) {
++			if (m_converter) {
++				if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
++					int linsize;
++					av_freep(&m_convert_buffer[0]);
++					m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
++					ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->ch_layout.nb_channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
++					if (ret < 0) {
++						SetError("Couldn't allocate audio converter buffer", ret);
++						return false;
++					}
++				}
++				auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
++				if (nb_samples < 0) {
++					SetError("Couldn't convert audio", ret);
+ 					return false;
+ 				}
+-			}
+-			auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			}
+-			*data = (const int16_t *) m_convert_buffer[0];
+-			*size = nb_samples;
+-		} else {
+-			*data = (const int16_t *) m_frame->data[0];
+-			*size = m_frame->nb_samples;
+-		}
+-	} else {
+-		if (m_finished && m_converter) {
+-			auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			} else if (nb_samples > 0) {
+-				m_got_frame = 1;
+ 				*data = (const int16_t *) m_convert_buffer[0];
+ 				*size = nb_samples;
++			} else {
++				*data = (const int16_t *) m_frame->data[0];
++				*size = m_frame->nb_samples;
++			}
++		} else {
++			if (m_converter) {
++				if (IsFinished()) {
++					auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
++					if (nb_samples < 0) {
++						SetError("Couldn't convert audio", ret);
++						return false;
++					} else if (nb_samples > 0) {
++						*data = (const int16_t *) m_convert_buffer[0];
++						*size = nb_samples;
++					}
++				}
+ 			}
+ 		}
+-	}
+
+-	return true;
++		return true;
++	}
+ }
+
+ inline void FFmpegAudioReader::SetError(const char *message, int errnum) {
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index a2b517b..123e643 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -38,6 +38,12 @@ set(SRCS
+
+ if(BUILD_TOOLS)
+ 	set(SRCS ${SRCS} ../src/audio/ffmpeg_audio_reader_test.cpp)
++    include_directories(
++        ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}
++        ${AUDIO_PROCESSOR_INCLUDE_DIRS}
++    )
+ 	link_libraries(fpcalc_libs)
+ endif()
+
+-- 
+2.38.1
+
+
diff --git a/srcpkgs/chromaprint/template b/srcpkgs/chromaprint/template
index 7ef7838949f3..1f7bbc70a22c 100644
--- a/srcpkgs/chromaprint/template
+++ b/srcpkgs/chromaprint/template
@@ -1,7 +1,7 @@
 # Template file for 'chromaprint'
 pkgname=chromaprint
 version=1.5.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DBUILD_TOOLS=ON"
 make_check_target="check"

From 5d06b9e797a214e01cfe39dec92e9a22e777bdb5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 026/113] chromium: revbump for ffmpeg-6.0

---
 .../patches/chromium-93-ffmpeg-4.4.patch      | 36 --------------
 srcpkgs/chromium/patches/ffmpeg5.patch        | 47 +++++++++++++++++++
 srcpkgs/chromium/template                     |  2 +-
 3 files changed, 48 insertions(+), 37 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch
 create mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch b/srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch
deleted file mode 100644
index f0ec736f98bc..000000000000
--- a/srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch
+++ /dev/null
@@ -1,36 +0,0 @@
-diff --git a/media/filters/ffmpeg_demuxer.cc b/media/filters/ffmpeg_demuxer.cc
-index ac4713b07268..492a9a37d096 100644
---- a/media/filters/ffmpeg_demuxer.cc
-+++ b/media/filters/ffmpeg_demuxer.cc
-@@ -427,11 +427,11 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
-   scoped_refptr<DecoderBuffer> buffer;
- 
-   if (type() == DemuxerStream::TEXT) {
--    size_t id_size = 0;
-+    int id_size = 0;
-     uint8_t* id_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
- 
--    size_t settings_size = 0;
-+    int settings_size = 0;
-     uint8_t* settings_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
- 
-@@ -443,7 +443,7 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
-     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
-                                      side_data.data(), side_data.size());
-   } else {
--    size_t side_data_size = 0;
-+    int side_data_size = 0;
-     uint8_t* side_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
- 
-@@ -504,7 +504,7 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
-                                        packet->size - data_offset);
-     }
- 
--    size_t skip_samples_size = 0;
-+    int skip_samples_size = 0;
-     const uint32_t* skip_samples_ptr =
-         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
-             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..24e2da38e34c
--- /dev/null
+++ b/srcpkgs/chromium/patches/ffmpeg5.patch
@@ -0,0 +1,47 @@
+--- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
++++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
+@@ -92,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+-  if (stream->start_time != kNoFFmpegTimestamp)
++  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -1597,7 +1585,7 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+@@ -1618,7 +1606,7 @@
+     if (stream->type() != DemuxerStream::VIDEO)
+       continue;
+ 
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+ 
+     if (!stream->IsEnabled())
diff --git a/srcpkgs/chromium/template b/srcpkgs/chromium/template
index cafc2fe324c6..9df782b5fd9b 100644
--- a/srcpkgs/chromium/template
+++ b/srcpkgs/chromium/template
@@ -2,7 +2,7 @@
 pkgname=chromium
 # See https://chromiumdash.appspot.com/releases?platform=Linux for the latest version
 version=113.0.5672.92
-revision=1
+revision=2
 archs="i686* x86_64* aarch64* armv7l*"
 hostmakedepends="
  $(vopt_if clang "clang lld llvm15")

From f2e2efe42cbf4aa0b4af713a9a506cdf7d7b7cdb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 027/113] cmus: revbump for ffmpeg-6.0

---
 srcpkgs/cmus/patches/ffmpeg6.patch | 12 ++++++++++++
 srcpkgs/cmus/template              |  2 +-
 2 files changed, 13 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/cmus/patches/ffmpeg6.patch

diff --git a/srcpkgs/cmus/patches/ffmpeg6.patch b/srcpkgs/cmus/patches/ffmpeg6.patch
new file mode 100644
index 000000000000..ffa95ab81110
--- /dev/null
+++ b/srcpkgs/cmus/patches/ffmpeg6.patch
@@ -0,0 +1,12 @@
+--- a/ip/ffmpeg.c
++++ b/ip/ffmpeg.c
+@@ -202,9 +202,6 @@ static int ffmpeg_open(struct input_plugin_data *ip_data)
+ 			break;
+ 		}
+ 
+-		if (codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+-			cc->flags |= AV_CODEC_FLAG_TRUNCATED;
+-
+ 		if (avcodec_open2(cc, codec, NULL) < 0) {
+ 			d_print("could not open codec: %d, %s\n", cc->codec_id, avcodec_get_name(cc->codec_id));
+ 			err = -IP_ERROR_UNSUPPORTED_FILE_TYPE;
diff --git a/srcpkgs/cmus/template b/srcpkgs/cmus/template
index 0fcb424ce336..05b77d0fecae 100644
--- a/srcpkgs/cmus/template
+++ b/srcpkgs/cmus/template
@@ -1,7 +1,7 @@
 # Template file for 'cmus'
 pkgname=cmus
 version=2.10.0
-revision=1
+revision=2
 build_style=configure
 configure_args="prefix=/usr LD=$CC"
 hostmakedepends="pkg-config"

From 14dab0aa98000943de0205d412dc4e40096eae50 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 028/113] cyanrip: revbump for ffmpeg-6.0

---
 srcpkgs/cyanrip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cyanrip/template b/srcpkgs/cyanrip/template
index 9796e3461601..5db30e020d17 100644
--- a/srcpkgs/cyanrip/template
+++ b/srcpkgs/cyanrip/template
@@ -1,7 +1,7 @@
 # Template file for 'cyanrip'
 pkgname=cyanrip
 version=0.9.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config"
 makedepends="ffmpeg-devel libcdio-devel libcdio-paranoia-devel libcurl-devel libmusicbrainz5-devel"

From d4ba82f678407cc94d056ca998fa4f422f5629e3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 029/113] deadbeef: revbump for ffmpeg4-4.4.3

---
 srcpkgs/deadbeef/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/deadbeef/template b/srcpkgs/deadbeef/template
index b664bb1b9bd9..165b3c7b9cad 100644
--- a/srcpkgs/deadbeef/template
+++ b/srcpkgs/deadbeef/template
@@ -1,14 +1,14 @@
 # Template file for 'deadbeef'
 pkgname=deadbeef
 version=1.8.8
-revision=1
+revision=2
 create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-oss --disable-lfm --disable-notify --disable-gtk2"
 hostmakedepends="automake libtool gettext gettext-devel intltool pkg-config
  yasm clang glib-devel"
 makedepends="
- alsa-lib-devel dbus-devel faad2-devel ffmpeg-devel gtk+3-devel imlib2-devel
+ alsa-lib-devel dbus-devel faad2-devel ffmpeg4-devel gtk+3-devel imlib2-devel
  jansson-devel libcddb-devel libcdio-devel libcurl-devel libflac-devel
  libmad-devel libpng-devel libsamplerate-devel libsndfile-devel libvorbis-devel
  libzip-devel mpg123-devel opusfile-devel pulseaudio-devel wavpack-devel"

From d793160a9a3e55424407177a57bd25509f43f8dd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 030/113] dolphin-emu: revbump for ffmpeg-6.0

---
 srcpkgs/dolphin-emu/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/dolphin-emu/template b/srcpkgs/dolphin-emu/template
index 7ea197ceb2a8..7aeb0a5b645e 100644
--- a/srcpkgs/dolphin-emu/template
+++ b/srcpkgs/dolphin-emu/template
@@ -1,7 +1,7 @@
 # Template file for 'dolphin-emu'
 pkgname=dolphin-emu
 version=5.0.16101
-revision=1
+revision=2
 _dolphin_commit=8ecfa537a242de74d2e372e30d9d79b14584b2fb
 _mgba_commit=40d4c430fc36caeb7ea32fd39624947ed487d2f2
 #Version/hash pair can be found at https://dolphin-emu.org/download/

From ecb3d524c6418ca311c76e4aefcc643690c5abdf Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 031/113] droidcam-obs-plugin: revbump for ffmpeg-6.0

---
 srcpkgs/droidcam-obs-plugin/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam-obs-plugin/template b/srcpkgs/droidcam-obs-plugin/template
index fc9c9bf6b9d5..fb0480754df4 100644
--- a/srcpkgs/droidcam-obs-plugin/template
+++ b/srcpkgs/droidcam-obs-plugin/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam-obs-plugin'
 pkgname=droidcam-obs-plugin
 version=2.0.1
-revision=1
+revision=2
 build_style=gnu-makefile
 make_use_env=yes
 make_build_args="ALLOW_STATIC=no"

From ee1262f298f5f745ae325a63b56c2d1d53bd7a29 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 032/113] droidcam: revbump for ffmpeg-6.0

---
 srcpkgs/droidcam/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam/template b/srcpkgs/droidcam/template
index 1c3f1b8b1fc6..32a9220b79a4 100644
--- a/srcpkgs/droidcam/template
+++ b/srcpkgs/droidcam/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam'
 pkgname=droidcam
 version=1.8.2
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="USBMUXD=-lusbmuxd-2.0 JPEG=-lturbojpeg"
 hostmakedepends="pkg-config"

From 7cec78ac4d2a68ef05091e1367f45891845861e1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 033/113] ffmpegthumbnailer: revbump for ffmpeg-6.0

---
 .../ffmpegthumbnailer/patches/ffmpeg6.patch   | 202 ++++++++++++++++++
 srcpkgs/ffmpegthumbnailer/template            |   6 +-
 2 files changed, 205 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch

diff --git a/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
new file mode 100644
index 000000000000..363ff35a2841
--- /dev/null
+++ b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
@@ -0,0 +1,202 @@
+--- a/libffmpegthumbnailer/moviedecoder.cpp	2017-11-21 14:06:57.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.cpp	2023-05-05 13:14:47.946560668 -0400
+@@ -41,11 +41,6 @@
+ namespace ffmpegthumbnailer
+ {
+ 
+-struct SilenceLogLevel
+-{
+-    SilenceLogLevel() { av_log_set_level(AV_LOG_QUIET); }
+-};
+-
+ MovieDecoder::MovieDecoder(AVFormatContext* pavContext)
+ : m_VideoStream(-1)
+ , m_pFormatContext(pavContext)
+@@ -70,8 +65,6 @@
+ 
+ void MovieDecoder::initialize(const string& filename, bool preferEmbeddedMetadata)
+ {
+-    av_register_all();
+-    avcodec_register_all();
+     avformat_network_init();
+ 
+     string inputFile = filename == "-" ? "pipe:" : filename;
+@@ -97,8 +90,7 @@
+ {
+     if (m_pVideoCodecContext)
+     {
+-        avcodec_close(m_pVideoCodecContext);
+-        m_pVideoCodecContext = nullptr;
++        avcodec_free_context(&m_pVideoCodecContext);
+     }
+ 
+     if ((!m_FormatContextWasGiven) && m_pFormatContext)
+@@ -152,10 +144,10 @@
+     for (unsigned int i = 0; i < m_pFormatContext->nb_streams; ++i)
+     {
+         AVStream *stream = m_pFormatContext->streams[i];
+-        auto ctx = m_pFormatContext->streams[i]->codec;
+-        if (ctx->codec_type == AVMEDIA_TYPE_VIDEO)
++        auto par = m_pFormatContext->streams[i]->codecpar;
++        if (par->codec_type == AVMEDIA_TYPE_VIDEO)
+         {
+-            if (!preferEmbeddedMetadata || !isStillImageCodec(ctx->codec_id))
++            if (!preferEmbeddedMetadata || !isStillImageCodec(par->codec_id))
+             {
+                 videoStreams.push_back(i);
+                 continue;
+@@ -203,8 +195,7 @@
+     }
+ 
+     m_pVideoStream = m_pFormatContext->streams[m_VideoStream];
+-    m_pVideoCodecContext = m_pVideoStream->codec;
+-    m_pVideoCodec = avcodec_find_decoder(m_pVideoCodecContext->codec_id);
++    m_pVideoCodec = avcodec_find_decoder(m_pVideoStream->codecpar->codec_id);
+ 
+     if (m_pVideoCodec == nullptr)
+     {
+@@ -214,6 +205,20 @@
+         throw logic_error("Video Codec not found");
+     }
+ 
++    m_pVideoCodecContext = avcodec_alloc_context3(m_pVideoCodec);
++
++    if (m_pVideoCodecContext == nullptr)
++    {
++        destroy();
++        throw logic_error("Could not allocate video codec context");
++    }
++
++    if (avcodec_parameters_to_context(m_pVideoCodecContext, m_pVideoStream->codecpar) < 0)
++    {
++        destroy();
++        throw logic_error("Could not configure video codec context");
++    }
++
+     m_pVideoCodecContext->workaround_bugs = 1;
+ 
+     if (avcodec_open2(m_pVideoCodecContext, m_pVideoCodec, nullptr) < 0)
+@@ -386,13 +391,6 @@
+ 
+ void MovieDecoder::initializeFilterGraph(const AVRational& timeBase, const std::string& size, bool maintainAspectRatio)
+ {
+-    static const AVPixelFormat pixelFormats[] = { AV_PIX_FMT_RGB24, AV_PIX_FMT_NONE };
+-
+-    auto del = [] (AVBufferSinkParams* p) { av_freep(p); };
+-    std::unique_ptr<AVBufferSinkParams, decltype(del)> buffersinkParams(av_buffersink_params_alloc(), del);
+-
+-    avfilter_register_all();
+-
+     m_pFilterGraph = avfilter_graph_alloc();
+     assert(m_pFilterGraph);
+ 
+@@ -404,10 +402,8 @@
+ 
+     checkRc(avfilter_graph_create_filter(&m_pFilterSource, avfilter_get_by_name("buffer"), "thumb_buffer", ss.str().c_str(), nullptr, m_pFilterGraph),
+             "Failed to create filter source");
+-    buffersinkParams->pixel_fmts = pixelFormats;
+-    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, buffersinkParams.get(), m_pFilterGraph),
++    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, nullptr, m_pFilterGraph),
+             "Failed to create filter sink");
+-    buffersinkParams.release();
+ 
+     AVFilterContext* yadifFilter = nullptr;
+     if (m_pFrame->interlaced_frame != 0)
+@@ -500,15 +496,15 @@
+     }
+ 
+     checkRc(av_seek_frame(m_pFormatContext, -1, timestamp, 0), "Seeking in video failed");
+-    avcodec_flush_buffers(m_pFormatContext->streams[m_VideoStream]->codec);
++    avcodec_flush_buffers(m_pVideoCodecContext);
+ 
+     int keyFrameAttempts = 0;
+-    bool gotFrame = 0;
++    bool gotFrame;
+ 
+     do
+     {
+         int count = 0;
+-        gotFrame = 0;
++        gotFrame = false;
+ 
+         while (!gotFrame && count < 20)
+         {
+@@ -552,17 +548,33 @@
+         return false;
+     }
+ 
+-    av_frame_unref(m_pFrame);
+-
+-    int frameFinished;
++    int rc = avcodec_send_packet(m_pVideoCodecContext, m_pPacket);
++    if(rc == AVERROR(EAGAIN))
++    {
++        rc = 0;
++    }
+ 
+-    int bytesDecoded = avcodec_decode_video2(m_pVideoCodecContext, m_pFrame, &frameFinished, m_pPacket);
+-    if (bytesDecoded < 0)
++    if(rc == AVERROR_EOF)
++    {
++        return false;
++    }
++    else if(rc < 0)
+     {
+-        throw logic_error("Failed to decode video frame: bytesDecoded < 0");
++        throw logic_error("Failed to decode video frame: avcodec_send_packet() < 0");
+     }
+ 
+-    return frameFinished > 0;
++    rc = avcodec_receive_frame(m_pVideoCodecContext, m_pFrame);
++    switch(rc)
++    {
++        case 0:
++            return true;
++
++        case AVERROR(EAGAIN):
++            return false;
++
++        default:
++            throw logic_error("Failed to decode video frame: avcodec_receive_frame() < 0");
++    }
+ }
+ 
+ bool MovieDecoder::getVideoPacket()
+@@ -570,8 +582,6 @@
+     bool framesAvailable = true;
+     bool frameDecoded = false;
+ 
+-    int attempts = 0;
+-
+     if (m_pPacket)
+     {
+         av_packet_unref(m_pPacket);
+@@ -580,6 +590,7 @@
+ 
+     m_pPacket = new AVPacket();
+ 
++
+     while (framesAvailable && !frameDecoded)
+     {
+         framesAvailable = av_read_frame(m_pFormatContext, m_pPacket) >= 0;
+@@ -644,7 +655,7 @@
+ 
+ int32_t MovieDecoder::getStreamRotation()
+ {
+-    int32_t* matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
++    auto matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
+     if (matrix)
+     {
+         auto angle = lround(av_display_rotation_get(matrix));
+
+--- a/libffmpegthumbnailer/moviedecoder.h	2017-11-12 04:23:38.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.h	2023-05-05 13:26:07.095529911 -0400
+@@ -78,7 +78,7 @@
+     int                     m_VideoStream;
+     AVFormatContext*        m_pFormatContext;
+     AVCodecContext*         m_pVideoCodecContext;
+-    AVCodec*                m_pVideoCodec;
++    const AVCodec*          m_pVideoCodec;
+     AVFilterGraph*          m_pFilterGraph;
+     AVFilterContext*        m_pFilterSource;
+     AVFilterContext*        m_pFilterSink;
diff --git a/srcpkgs/ffmpegthumbnailer/template b/srcpkgs/ffmpegthumbnailer/template
index 039eea7622b3..35d546018d12 100644
--- a/srcpkgs/ffmpegthumbnailer/template
+++ b/srcpkgs/ffmpegthumbnailer/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbnailer'
 pkgname=ffmpegthumbnailer
 version=2.2.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libpng-devel libjpeg-turbo-devel ffmpeg-devel"
@@ -9,8 +9,8 @@ depends="ffmpeg"
 short_desc="Lightweight video thumbnailer"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
-homepage="https://github.com/dirkvdb/${pkgname}"
-distfiles="${homepage}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
+homepage="https://github.com/dirkvdb"
+distfiles="${homepage}/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
 checksum=1cb24059c38223f657b300c84dd80491b7040d4b69471c4fea69be862bc99b5b
 
 post_install() {

From e09be981a4cd994f9f16029cac74101c3e1d431e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 034/113] ffmpegthumbs: revbump for ffmpeg-6.0

---
 srcpkgs/ffmpegthumbs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ffmpegthumbs/template b/srcpkgs/ffmpegthumbs/template
index 5f0b9414dada..11b88193528f 100644
--- a/srcpkgs/ffmpegthumbs/template
+++ b/srcpkgs/ffmpegthumbs/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbs'
 pkgname=ffmpegthumbs
 version=22.12.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules kcoreaddons kconfig-devel
  pkg-config qt5-host-tools qt5-qmake gettext"

From 9fcc0b702b637a19cbec68dc75589b67d9914dd6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 035/113] ffms2: revbump for ffmpeg-6.0

---
 srcpkgs/ffms2/patches/ffmpeg5.patch | 424 ++++++++++++++++++++++++++++
 srcpkgs/ffms2/template              |   2 +-
 2 files changed, 425 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ffms2/patches/ffmpeg5.patch

diff --git a/srcpkgs/ffms2/patches/ffmpeg5.patch b/srcpkgs/ffms2/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..1479fabcafcb
--- /dev/null
+++ b/srcpkgs/ffms2/patches/ffmpeg5.patch
@@ -0,0 +1,424 @@
+From 45673149e9a2f5586855ad472e3059084eaa36b1 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:41:21 +0100
+Subject: [PATCH] Use auto for AVCodec
+
+The geniuses over at FFmpeg decided to constify this API, so old
+versions of the library will return AVCodec *, while new versions
+of the libary will return const AVCodec *, which, in C++, are not
+OK to convert between.
+
+Rather than use some macro hell in ffmscompat.h, we can work around
+this by using auto.
+
+Gross.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 2 +-
+ src/core/indexing.cpp    | 6 +++---
+ src/core/videosource.cpp | 2 +-
+ 3 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index e4ce97c..ac09666 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -469,7 +469,7 @@ void FFMS_AudioSource::OpenFile() {
+ 
+     LAVFOpenFile(SourceFile.c_str(), FormatContext, TrackNumber);
+ 
+-    AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
++    auto *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
+     if (Codec == nullptr)
+         throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+             "Audio codec not found");
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index e547c5a..59fb4e8 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -384,7 +384,7 @@ FFMS_TrackType FFMS_Indexer::GetTrackType(int Track) {
+ }
+ 
+ const char *FFMS_Indexer::GetTrackCodec(int Track) {
+-    AVCodec *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
++    auto *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
+     return codec ? codec->name : nullptr;
+ }
+ 
+@@ -402,7 +402,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             UseDTS);
+ 
+         if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            AVCodec *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (!VideoCodec) {
+                 FormatContext->streams[i]->discard = AVDISCARD_ALL;
+                 IndexMask.erase(i);
+@@ -433,7 +433,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 IndexMask.insert(i);
+             }
+         } else if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+-            AVCodec *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (AudioCodec == nullptr)
+                 throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_UNSUPPORTED,
+                     "Audio codec not found");
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index b889970..8956c22 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -171,7 +171,7 @@ FFMS_VideoSource::FFMS_VideoSource(const char *SourceFile, FFMS_Index &Index, in
+ 
+         LAVFOpenFile(SourceFile, FormatContext, VideoTrack);
+ 
+-        AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
++        auto *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
+         if (Codec == nullptr)
+             throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+                 "Video codec not found");
+-- 
+2.40.0
+
+From 96cbf38ea9381829a1314f432a2c60495dcefaad Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:12:41 +0100
+Subject: [PATCH] all: Update AVPacket API usage
+
+AVPackets must all be on the heap now, since it is no longer
+part of the libav* ABI.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 16 ++++++----
+ src/core/indexing.cpp    | 63 ++++++++++++++++++++++------------------
+ src/core/indexing.h      |  4 +--
+ src/core/utils.cpp       |  6 ----
+ src/core/utils.h         |  1 -
+ src/core/videosource.cpp | 30 ++++++++++---------
+ 6 files changed, 64 insertions(+), 56 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index 37cf9ae..e4ce97c 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -285,10 +285,15 @@ FFMS_AudioSource::AudioBlock *FFMS_AudioSource::CacheBlock(CacheIterator &pos) {
+ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     CurrentFrame = &Frames[PacketNumber];
+ 
+-    AVPacket Packet;
+-    if (!ReadPacket(&Packet))
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++    if (!ReadPacket(Packet)) {
++        av_packet_free(&Packet);
+         throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_UNKNOWN,
+             "ReadPacket unexpectedly failed to read a packet");
++    }
+ 
+     // ReadPacket may have changed the packet number
+     CurrentFrame = &Frames[PacketNumber];
+@@ -297,8 +302,9 @@ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     int NumberOfSamples = 0;
+     AudioBlock *CachedBlock = nullptr;
+     
+-    int Ret = avcodec_send_packet(CodecContext, &Packet);
+-    av_packet_unref(&Packet);
++    int Ret = avcodec_send_packet(CodecContext, Packet);
++    av_packet_unref(Packet);
++    av_packet_free(&Packet);
+ 
+     av_frame_unref(DecodeFrame);
+     Ret = avcodec_receive_frame(CodecContext, DecodeFrame);
+@@ -513,8 +519,6 @@ void FFMS_AudioSource::Seek() {
+ }
+ 
+ bool FFMS_AudioSource::ReadPacket(AVPacket *Packet) {
+-    InitNullPacket(*Packet);
+-
+     while (av_read_frame(FormatContext, Packet) >= 0) {
+         if (Packet->stream_index == TrackNumber) {
+             // Required because not all audio packets, especially in ogg, have a pts. Use the previous valid packet's pts instead.
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index 23fb95b..e547c5a 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -320,7 +320,7 @@ void FFMS_Indexer::CheckAudioProperties(int Track, AVCodecContext *Context) {
+     }
+ }
+ 
+-void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict,
++void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict,
+                                     int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct) {
+     if (VideoContext.Parser) {
+         uint8_t *OB;
+@@ -330,8 +330,8 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+         av_parser_parse2(VideoContext.Parser,
+             VideoContext.CodecContext,
+             &OB, &OBSize,
+-            pkt.data, pkt.size,
+-            pkt.pts, pkt.dts, pkt.pos);
++            pkt->data, pkt->size,
++            pkt->pts, pkt->dts, pkt->pos);
+ 
+         // H.264 (PAFF) and HEVC may have one field per packet, so we need to track
+         // when we have a full or half frame available, and mark one of them as
+@@ -351,15 +351,15 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+ 
+         *RepeatPict = VideoContext.Parser->repeat_pict;
+         *FrameType = VideoContext.Parser->pict_type;
+-        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt.flags & AV_PKT_FLAG_DISCARD));
++        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt->flags & AV_PKT_FLAG_DISCARD));
+     } else {
+-        *Invisible = !!(pkt.flags & AV_PKT_FLAG_DISCARD);
++        *Invisible = !!(pkt->flags & AV_PKT_FLAG_DISCARD);
+     }
+ 
+     if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP8)
+-        ParseVP8(pkt.data[0], Invisible, FrameType);
++        ParseVP8(pkt->data[0], Invisible, FrameType);
+     else if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP9)
+-        ParseVP9(pkt.data[0], Invisible, FrameType);
++        ParseVP9(pkt->data[0], Invisible, FrameType);
+ }
+ 
+ void FFMS_Indexer::Free() {
+@@ -458,32 +458,36 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+         }
+     }
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
+     std::vector<int64_t> LastValidTS(FormatContext->nb_streams, AV_NOPTS_VALUE);
+ 
+     int64_t filesize = avio_size(FormatContext->pb);
+     enum AVPictureStructure LastPicStruct = AV_PICTURE_STRUCTURE_UNKNOWN;
+-    while (av_read_frame(FormatContext, &Packet) >= 0) {
++    while (av_read_frame(FormatContext, Packet) >= 0) {
+         // Update progress
+         // FormatContext->pb can apparently be NULL when opening images.
+         if (IC && FormatContext->pb) {
+-            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate))
++            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate)) {
++                av_packet_free(&Packet);
+                 throw FFMS_Exception(FFMS_ERROR_CANCELLED, FFMS_ERROR_USER,
+                     "Cancelled by user");
++            }
+         }
+-        if (!IndexMask.count(Packet.stream_index)) {
+-            av_packet_unref(&Packet);
++        if (!IndexMask.count(Packet->stream_index)) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+-        int Track = Packet.stream_index;
++        int Track = Packet->stream_index;
+         FFMS_Track &TrackInfo = (*TrackIndices)[Track];
+-        bool KeyFrame = !!(Packet.flags & AV_PKT_FLAG_KEY);
++        bool KeyFrame = !!(Packet->flags & AV_PKT_FLAG_KEY);
+         ReadTS(Packet, LastValidTS[Track], (*TrackIndices)[Track].UseDTS);
+ 
+         if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            int64_t PTS = TrackInfo.UseDTS ? Packet.dts : Packet.pts;
++            int64_t PTS = TrackInfo.UseDTS ? Packet->dts : Packet->pts;
+             if (PTS == AV_NOPTS_VALUE) {
+                 // VPx alt-refs are output as packets which lack timestmps or durations, since
+                 // they are invisible. Currently, the timestamp mangling code in libavformat
+@@ -495,9 +499,11 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 // FFMS2 currently sorts packets by PTS, which will break decoding, otherwise.
+                 bool HasAltRefs = (FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP8 ||
+                                    FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP9);
+-                if (Packet.duration == 0 && !HasAltRefs)
++                if (Packet->duration == 0 && !HasAltRefs) {
++                    av_packet_free(&Packet);
+                     throw FFMS_Exception(FFMS_ERROR_INDEXING, FFMS_ERROR_PARSER,
+                         "Invalid packet pts, dts, and duration");
++                }
+ 
+                 if (TrackInfo.empty())
+                     PTS = 0;
+@@ -513,7 +519,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             ParseVideoPacket(AVContexts[Track], Packet, &RepeatPict, &FrameType, &Invisible, &LastPicStruct);
+ 
+             TrackInfo.AddVideoFrame(PTS, RepeatPict, KeyFrame,
+-                FrameType, Packet.pos, Invisible);
++                FrameType, Packet->pos, Invisible);
+         } else if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+             // For video seeking timestamps are used only if all packets have
+             // timestamps, while for audio they're used if any have timestamps,
+@@ -522,28 +528,29 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 TrackInfo.HasTS = true;
+ 
+             int64_t StartSample = AVContexts[Track].CurrentSample;
+-            uint32_t SampleCount = IndexAudioPacket(Track, &Packet, AVContexts[Track], *TrackIndices);
++            uint32_t SampleCount = IndexAudioPacket(Track, Packet, AVContexts[Track], *TrackIndices);
+             TrackInfo.SampleRate = AVContexts[Track].CodecContext->sample_rate;
+ 
+             TrackInfo.AddAudioFrame(LastValidTS[Track],
+-                StartSample, SampleCount, KeyFrame, Packet.pos, Packet.flags & AV_PKT_FLAG_DISCARD);
++                StartSample, SampleCount, KeyFrame, Packet->pos, Packet->flags & AV_PKT_FLAG_DISCARD);
+         }
+ 
+-        if (!(Packet.flags & AV_PKT_FLAG_DISCARD))
+-            TrackInfo.LastDuration = Packet.duration;
++        if (!(Packet->flags & AV_PKT_FLAG_DISCARD))
++            TrackInfo.LastDuration = Packet->duration;
+ 
+-        av_packet_unref(&Packet);
++        av_packet_unref(Packet);
+     }
++    av_packet_free(&Packet);
+ 
+     TrackIndices->Finalize(AVContexts, FormatContext->iformat->name);
+     return TrackIndices.release();
+ }
+ 
+-void FFMS_Indexer::ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS) {
+-    if (!UseDTS && Packet.pts != AV_NOPTS_VALUE)
+-        TS = Packet.pts;
++void FFMS_Indexer::ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS) {
++    if (!UseDTS && Packet->pts != AV_NOPTS_VALUE)
++        TS = Packet->pts;
+     if (TS == AV_NOPTS_VALUE)
+         UseDTS = true;
+-    if (UseDTS && Packet.dts != AV_NOPTS_VALUE)
+-        TS = Packet.dts;
++    if (UseDTS && Packet->dts != AV_NOPTS_VALUE)
++        TS = Packet->dts;
+ }
+diff --git a/src/core/indexing.h b/src/core/indexing.h
+index 3cfc3c3..5c06868 100644
+--- a/src/core/indexing.h
++++ b/src/core/indexing.h
+@@ -80,10 +80,10 @@ private:
+     int64_t Filesize;
+     uint8_t Digest[20];
+ 
+-    void ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS);
++    void ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS);
+     void CheckAudioProperties(int Track, AVCodecContext *Context);
+     uint32_t IndexAudioPacket(int Track, AVPacket *Packet, SharedAVContext &Context, FFMS_Index &TrackIndices);
+-    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
++    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
+     void Free();
+ public:
+     FFMS_Indexer(const char *Filename);
+diff --git a/src/core/utils.cpp b/src/core/utils.cpp
+index ce67533..8a2e997 100644
+--- a/src/core/utils.cpp
++++ b/src/core/utils.cpp
+@@ -62,12 +62,6 @@ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo) {
+     }
+ }
+ 
+-void InitNullPacket(AVPacket &pkt) {
+-    av_init_packet(&pkt);
+-    pkt.data = nullptr;
+-    pkt.size = 0;
+-}
+-
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames) {
+     AP.SampleFormat = static_cast<FFMS_SampleFormat>(av_get_packed_sample_fmt(CTX->sample_fmt));
+     AP.BitsPerSample = av_get_bytes_per_sample(CTX->sample_fmt) * 8;
+diff --git a/src/core/utils.h b/src/core/utils.h
+index 9819dc7..003ab79 100644
+--- a/src/core/utils.h
++++ b/src/core/utils.h
+@@ -58,7 +58,6 @@ std::unique_ptr<T> make_unique(Args&&... args) {
+ }
+ 
+ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo);
+-void InitNullPacket(AVPacket &pkt);
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames);
+ 
+ void LAVFOpenFile(const char *SourceFile, AVFormatContext *&FormatContext, int Track);
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index 06bd161..b889970 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -673,30 +673,34 @@ void FFMS_VideoSource::DecodeNextFrame(int64_t &AStartTime, int64_t &Pos) {
+     if (HasPendingDelayedFrames())
+         return;
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
+-
+-    while (ReadFrame(&Packet) >= 0) {
+-        if (Packet.stream_index != VideoTrack) {
+-            av_packet_unref(&Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++
++    while (ReadFrame(Packet) >= 0) {
++        if (Packet->stream_index != VideoTrack) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+         if (AStartTime < 0)
+-            AStartTime = Frames.UseDTS ? Packet.dts : Packet.pts;
++            AStartTime = Frames.UseDTS ? Packet->dts : Packet->pts;
+ 
+         if (Pos < 0)
+-            Pos = Packet.pos;
++            Pos = Packet->pos;
+ 
+-        bool FrameFinished = DecodePacket(&Packet);
+-        av_packet_unref(&Packet);
+-        if (FrameFinished)
++        bool FrameFinished = DecodePacket(Packet);
++        av_packet_unref(Packet);
++        if (FrameFinished) {
++            av_packet_free(&Packet);
+             return;
++        }
+     }
+ 
+     // Flush final frames
+-    InitNullPacket(Packet);
+-    DecodePacket(&Packet);
++    DecodePacket(Packet);
++    av_packet_free(&Packet);
+ }
+ 
+ bool FFMS_VideoSource::SeekTo(int n, int SeekOffset) {
+-- 
+2.40.0
+
+From bf9e03e9e08534c024e5a744a6437c4aac160201 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:20:47 +0100
+Subject: [PATCH 2/3] configure: Remove deprecated API use
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ configure.ac | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index b35ef80bc..d19714d0f 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -102,10 +102,10 @@ CFLAGS="$_CFLAGS $FFMPEG_CFLAGS"
+
+ AC_DEFUN([TEST_FFMPEG],
+          [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+-            #include <libavcodec/avcodec.h>
++            #include <libavformat/avformat.h>
+             #include <libswscale/swscale.h>
+             ]],[[
+-                avcodec_register_all();
++                avformat_network_init();
+                 swscale_version();
+             ]])], [eval $1=yes], [eval $1=no])
+         ])
+
diff --git a/srcpkgs/ffms2/template b/srcpkgs/ffms2/template
index 68e8a0c14bce..2acfadac44b3 100644
--- a/srcpkgs/ffms2/template
+++ b/srcpkgs/ffms2/template
@@ -1,7 +1,7 @@
 # Template file for 'ffms2'
 pkgname=ffms2
 version=2.40
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-shared --disable-static"
 hostmakedepends="pkg-config autoconf automake libtool"

From 7459ee6ae6a5f23c73e85d3753bd9e8f03951d5d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 036/113] freerdp: revbump for ffmpeg-6.0

---
 .../freerdp/patches/ffmpeg6_aa2cb9aa.patch    | 42 +++++++++++++++++++
 srcpkgs/freerdp/template                      |  2 +-
 2 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch

diff --git a/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
new file mode 100644
index 000000000000..a4324da3a882
--- /dev/null
+++ b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
@@ -0,0 +1,42 @@
+From aa2cb9aa5ff5562433598ba168a466e0752bca0e Mon Sep 17 00:00:00 2001
+From: akallabeth <akallabeth@posteo.net>
+Date: Tue, 14 Feb 2023 07:48:54 +0100
+Subject: [PATCH] Fixed #8686: Update h264 to use new FFMPEG API
+
+---
+ channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c | 2 ++
+ libfreerdp/codec/h264_ffmpeg.c            | 2 ++
+ 2 files changed, 4 insertions(+)
+
+diff --git a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+index 339462d865f..beea80b7a1e 100644
+--- a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
++++ b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+@@ -239,8 +239,10 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYP
+ 		}
+ 	}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 	if (mdecoder->codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		mdecoder->codec_context->flags |= AV_CODEC_FLAG_TRUNCATED;
++#endif
+ 
+ 	return TRUE;
+ }
+diff --git a/libfreerdp/codec/h264_ffmpeg.c b/libfreerdp/codec/h264_ffmpeg.c
+index 8a23db2473c..896a333019b 100644
+--- a/libfreerdp/codec/h264_ffmpeg.c
++++ b/libfreerdp/codec/h264_ffmpeg.c
+@@ -615,10 +615,12 @@ static BOOL libavcodec_init(H264_CONTEXT* h264)
+ 			goto EXCEPTION;
+ 		}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 		if (sys->codecDecoder->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		{
+ 			sys->codecDecoderContext->flags |= AV_CODEC_FLAG_TRUNCATED;
+ 		}
++#endif
+ 
+ #ifdef WITH_VAAPI
+ 
diff --git a/srcpkgs/freerdp/template b/srcpkgs/freerdp/template
index 25e8aa9677f0..4d51c8189902 100644
--- a/srcpkgs/freerdp/template
+++ b/srcpkgs/freerdp/template
@@ -1,7 +1,7 @@
 # Template file for 'freerdp'
 pkgname=freerdp
 version=2.10.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_ALSA=ON -DWITH_CUPS=OFF -DWITH_FFMPEG=ON
  -DWITH_GSTREAMER_0_10=OFF -DWITH_GSTREAMER_1_0=OFF -DWITH_JPEG=ON

From fed19b531c5934a2ada8401fa68e11eeeaae642b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 037/113] gerbera: revbump for ffmpeg-6.0

---
 srcpkgs/gerbera/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gerbera/template b/srcpkgs/gerbera/template
index ae14f35c767c..2dc0ac0ce03b 100644
--- a/srcpkgs/gerbera/template
+++ b/srcpkgs/gerbera/template
@@ -1,7 +1,7 @@
 # Template file for 'gerbera'
 pkgname=gerbera
 version=1.12.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_SYSTEMD=0 -DWITH_AVCODEC=1"
 hostmakedepends="pkg-config"

From 14e830a23cb53c2cf3e9b36efee7d095a76be1e2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 038/113] goldendict: revbump for ffmpeg-6.0

---
 srcpkgs/goldendict/patches/ffmpeg4.patch |  21 --
 srcpkgs/goldendict/patches/ffmpeg5.patch | 232 +++++++++++++++++++++++
 srcpkgs/goldendict/template              |   2 +-
 3 files changed, 233 insertions(+), 22 deletions(-)
 delete mode 100644 srcpkgs/goldendict/patches/ffmpeg4.patch
 create mode 100644 srcpkgs/goldendict/patches/ffmpeg5.patch

diff --git a/srcpkgs/goldendict/patches/ffmpeg4.patch b/srcpkgs/goldendict/patches/ffmpeg4.patch
deleted file mode 100644
index f045fa27f54b..000000000000
--- a/srcpkgs/goldendict/patches/ffmpeg4.patch
+++ /dev/null
@@ -1,21 +0,0 @@
---- a/ffmpegaudio.cc.orig 2018-05-09 22:16:13.480659958 +0200
-+++ b/ffmpegaudio.cc      2018-05-09 22:16:50.748322790 +0200
-@@ -143,7 +143,7 @@
-     return false;
-   }
-
--  unsigned char * avioBuffer = ( unsigned char * )av_malloc( kBufferSize + FF_INPUT_BUFFER_PADDING_SIZE );
-+  unsigned char * avioBuffer = ( unsigned char * )av_malloc( kBufferSize + AV_INPUT_BUFFER_PADDING_SIZE );
-   if ( !avioBuffer )
-   {
-     errorString = QObject::tr( "av_malloc() failed." );
-@@ -380,7 +380,7 @@
-   }
-
-   if ( !Qt4x5::AtomicInt::loadAcquire( isCancelled_ ) &&
--       codecContext_->codec->capabilities & CODEC_CAP_DELAY )
-+       codecContext_->codec->capabilities & AV_CODEC_CAP_DELAY )
-   {
-     av_init_packet( &packet );
-     int gotFrame = 0;
-
diff --git a/srcpkgs/goldendict/patches/ffmpeg5.patch b/srcpkgs/goldendict/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..7cfc98ada368
--- /dev/null
+++ b/srcpkgs/goldendict/patches/ffmpeg5.patch
@@ -0,0 +1,232 @@
+From 03bbe01b79a1f07a6780cb60f23a087104c5d77b Mon Sep 17 00:00:00 2001
+From: Abs62 <ottomann@yandex.ru>
+Date: Fri, 30 Mar 2018 22:53:24 +0300
+Subject: [PATCH] Fix warnings while compile with FFMpeg 3.4.2 (issue #978)
+
+---
+ ffmpegaudio.cc | 68 +++++++++++++++++++++++++++++++++++++++++++++-----
+ 1 file changed, 62 insertions(+), 6 deletions(-)
+
+diff --git a/ffmpegaudio.cc b/ffmpegaudio.cc
+index ed1172bdd..56e8f788e 100644
+--- a/ffmpegaudio.cc
++++ b/ffmpegaudio.cc
+@@ -91,6 +91,7 @@ struct DecoderContext
+   QByteArray audioData_;
+   QDataStream audioDataStream_;
+   AVFormatContext * formatContext_;
++  AVCodec * codec_;
+   AVCodecContext * codecContext_;
+   AVIOContext * avioContext_;
+   AVStream * audioStream_;
+@@ -114,6 +115,7 @@ DecoderContext::DecoderContext( QByteArray const & audioData, QAtomicInt & isCan
+   audioData_( audioData ),
+   audioDataStream_( audioData_ ),
+   formatContext_( NULL ),
++  codec_( NULL ),
+   codecContext_( NULL ),
+   avioContext_( NULL ),
+   audioStream_( NULL ),
+@@ -143,7 +145,11 @@ bool DecoderContext::openCodec( QString & errorString )
+     return false;
+   }
+
++#if LIBAVCODEC_VERSION_MAJOR < 56 || ( LIBAVCODEC_VERSION_MAJOR == 56 && LIBAVCODEC_VERSION_MINOR < 56 )
+   unsigned char * avioBuffer = ( unsigned char * )av_malloc( kBufferSize + FF_INPUT_BUFFER_PADDING_SIZE );
++#else
++  unsigned char * avioBuffer = ( unsigned char * )av_malloc( kBufferSize + AV_INPUT_BUFFER_PADDING_SIZE );
++#endif
+   if ( !avioBuffer )
+   {
+     errorString = QObject::tr( "av_malloc() failed." );
+@@ -186,7 +192,11 @@ bool DecoderContext::openCodec( QString & errorString )
+   // Find audio stream, use the first audio stream if available
+   for ( unsigned i = 0; i < formatContext_->nb_streams; i++ )
+   {
++#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 33 )
+     if ( formatContext_->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO )
++#else
++      if ( formatContext_->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO )
++#endif
+     {
+       audioStream_ = formatContext_->streams[i];
+       break;
+@@ -198,22 +208,38 @@ bool DecoderContext::openCodec( QString & errorString )
+     return false;
+   }
+
++#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 33 )
+   codecContext_ = audioStream_->codec;
+-  AVCodec * codec = avcodec_find_decoder( codecContext_->codec_id );
+-  if ( !codec )
++  codec_ = avcodec_find_decoder( codecContext_->codec_id );
++  if ( !codec_ )
+   {
+     errorString = QObject::tr( "Codec [id: %1] not found." ).arg( codecContext_->codec_id );
+     return false;
+   }
++#else
++  codec_ = avcodec_find_decoder( audioStream_->codecpar->codec_id );
++  if ( !codec_ )
++  {
++    errorString = QObject::tr( "Codec [id: %1] not found." ).arg( audioStream_->codecpar->codec_id );
++    return false;
++  }
++  codecContext_ = avcodec_alloc_context3( codec_ );
++  if ( !codecContext_ )
++  {
++    errorString = QObject::tr( "avcodec_alloc_context3() failed." );
++    return false;
++  }
++  avcodec_parameters_to_context( codecContext_, audioStream_->codecpar );
++#endif
+
+-  ret = avcodec_open2( codecContext_, codec, NULL );
++  ret = avcodec_open2( codecContext_, codec_, NULL );
+   if ( ret < 0 )
+   {
+     errorString = QObject::tr( "avcodec_open2() failed: %1." ).arg( avErrorString( ret ) );
+     return false;
+   }
+
+-  av_log( NULL, AV_LOG_INFO, "Codec open: %s: channels: %d, rate: %d, format: %s\n", codec->long_name,
++  av_log( NULL, AV_LOG_INFO, "Codec open: %s: channels: %d, rate: %d, format: %s\n", codec_->long_name,
+           codecContext_->channels, codecContext_->sample_rate, av_get_sample_fmt_name( codecContext_->sample_fmt ) );
+   return true;
+ }
+@@ -252,10 +278,13 @@ void DecoderContext::closeCodec()
+
+   // Closing a codec context without prior avcodec_open2() will result in
+   // a crash in ffmpeg
+-  if ( audioStream_ && audioStream_->codec && audioStream_->codec->codec )
++  if ( audioStream_ && codecContext_ && codec_ )
+   {
+     audioStream_->discard = AVDISCARD_ALL;
+-    avcodec_close( audioStream_->codec );
++    avcodec_close( codecContext_ );
++#if LIBAVCODEC_VERSION_MAJOR > 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR >= 33 )
++    avcodec_free_context( &codecContext_ );
++#endif
+   }
+
+   avformat_close_input( &formatContext_ );
+@@ -356,6 +385,7 @@ bool DecoderContext::play( QString & errorString )
+     if ( packet.stream_index == audioStream_->index )
+     {
+       AVPacket pack = packet;
++#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 37 )
+       int gotFrame = 0;
+       do
+       {
+@@ -370,6 +400,19 @@ bool DecoderContext::play( QString & errorString )
+         pack.data += len;
+       }
+       while( pack.size > 0 );
++#else
++      int ret = avcodec_send_packet( codecContext_, &pack );
++      /* read all the output frames (in general there may be any number of them) */
++      while( ret >= 0 )
++      {
++        ret = avcodec_receive_frame( codecContext_, frame);
++
++        if ( Qt4x5::AtomicInt::loadAcquire( isCancelled_ ) || ret < 0 )
++          break;
++
++        playFrame( frame );
++      }
++#endif
+     }
+     // av_free_packet() must be called after each call to av_read_frame()
+ #if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 7 )
+@@ -379,6 +422,7 @@ bool DecoderContext::play( QString & errorString )
+ #endif
+   }
+
++#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 37 )
+   if ( !Qt4x5::AtomicInt::loadAcquire( isCancelled_ ) &&
+        codecContext_->codec->capabilities & CODEC_CAP_DELAY )
+   {
+@@ -391,6 +435,18 @@ bool DecoderContext::play( QString & errorString )
+       playFrame( frame );
+     }
+   }
++#else
++  /* flush the decoder */
++  av_init_packet( &packet );
++  int ret = avcodec_send_packet(codecContext_, &packet );
++  while( ret >= 0 )
++  {
++    ret = avcodec_receive_frame(codecContext_, frame);
++    if ( Qt4x5::AtomicInt::loadAcquire( isCancelled_ ) || ret < 0 )
++      break;
++    playFrame( frame );
++  }
++#endif
+
+ #if LIBAVCODEC_VERSION_MAJOR < 54
+   av_free( frame );
+32
+srcpkgs/goldendict/patches/ffmpeg5-2.patch
+Comment on this file
+@@ -0,0 +1,32 @@
+From 966f4a8b78e6324b930e5a50f2bb930bd87e565e Mon Sep 17 00:00:00 2001
+From: Abs62 <ottomann@yandex.ru>
+Date: Fri, 27 Sep 2019 17:00:52 +0300
+Subject: [PATCH] FFmpeg player: Fix some crashes on broken files
+
+---
+ ffmpegaudio.cc | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/ffmpegaudio.cc b/ffmpegaudio.cc
+index 56e8f788e..415fc79cb 100644
+--- a/ffmpegaudio.cc
++++ b/ffmpegaudio.cc
+@@ -51,7 +51,9 @@ AudioService & AudioService::instance()
+
+ AudioService::AudioService()
+ {
++#if LIBAVFORMAT_VERSION_MAJOR < 58 || ( LIBAVFORMAT_VERSION_MAJOR == 58 && LIBAVFORMAT_VERSION_MINOR < 9 )
+   av_register_all();
++#endif
+   ao_initialize();
+ }
+
+@@ -438,6 +440,8 @@ bool DecoderContext::play( QString & errorString )
+ #else
+   /* flush the decoder */
+   av_init_packet( &packet );
++  packet.data = NULL;
++  packet.size = 0;
+   int ret = avcodec_send_packet(codecContext_, &packet );
+   while( ret >= 0 )
+   {
+25
+srcpkgs/goldendict/patches/ffmpeg5-3.patch
+Comment on this file
+@@ -0,0 +1,25 @@
+From 8acb288c9e9bdb3c6bf2e803954dd3b6ac273c05 Mon Sep 17 00:00:00 2001
+From: Liao Junxuan <mikeljx@126.com>
+Date: Sun, 20 Feb 2022 12:28:05 +0800
+Subject: [PATCH] add support for ffmpeg 5.0
+
+---
+ ffmpegaudio.cc | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/ffmpegaudio.cc b/ffmpegaudio.cc
+index d550f4a77..7948d2187 100644
+--- a/ffmpegaudio.cc
++++ b/ffmpegaudio.cc
+@@ -94,7 +94,11 @@ struct DecoderContext
+   QByteArray audioData_;
+   QDataStream audioDataStream_;
+   AVFormatContext * formatContext_;
++#if LIBAVCODEC_VERSION_MAJOR < 59
+   AVCodec * codec_;
++#else
++  const AVCodec * codec_;
++#endif
+   AVCodecContext * codecContext_;
+   AVIOContext * avioContext_;
+   AVStream * audioStream_;
diff --git a/srcpkgs/goldendict/template b/srcpkgs/goldendict/template
index 4544ae710ee6..2ca4185e538a 100644
--- a/srcpkgs/goldendict/template
+++ b/srcpkgs/goldendict/template
@@ -9,7 +9,7 @@ makedepends="tiff-devel qt5-devel libvorbis-devel zlib-devel
  libXtst-devel hunspell-devel qt5-tools-devel qt5-declarative-devel
  qt5-webkit-devel lzo-devel bzip2-devel libao-devel qt5-svg-devel
  libeb-devel qt5-x11extras-devel ffmpeg-devel liblzma-devel"
-short_desc="A feature-rich dictionary lookup program"
+short_desc="Feature-rich dictionary lookup program"
 maintainer="John <me@johnnynator.dev>"
 license="GPL-3.0-or-later"
 homepage="http://goldendict.org/"

From f414f6a7f00e7483255eba780ae37452d68f8c7e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 039/113] gst-libav: revbump for ffmpeg-6.0

---
 srcpkgs/gst-libav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index e9a79dc650a5..f082bd211c65 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.20.3
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"

From afa41e7a2a57f2aafc9f8e8cf19cc2bf84dbbba4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 040/113] gst-plugins-bad1: revbump for ffmpeg-6.0

---
 srcpkgs/gst-plugins-bad1/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index f55f82fd4c77..dc9d389734e1 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-plugins-bad1'
 pkgname=gst-plugins-bad1
-version=1.20.3
-revision=3
+version=1.22.2
+revision=2
 build_helper="gir"
 build_style=meson
 configure_args="-Dpackage-origin=https://voidlinux.org -Ddoc=disabled

From bc0672c386d341fa0403d1e36ccdce31b6cdabdb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 041/113] gst-rtsp-server: revbump for ffmpeg-6.0

---
 srcpkgs/gst-rtsp-server/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index 33cd64ceb95e..8ceea8d34b4b 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
 version=1.20.3
-revision=2
+revision=3
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="glib-devel gst-plugins-bad1-devel gobject-introspection

From 09ebfd5b75e04da3ec2f8dd83af6e0ddce34f605 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 042/113] guvcview: update to 2.0.8.

---
 srcpkgs/guvcview/patches/fix-include.patch | 10 ++++++++++
 srcpkgs/guvcview/template                  |  5 ++---
 2 files changed, 12 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/guvcview/patches/fix-include.patch

diff --git a/srcpkgs/guvcview/patches/fix-include.patch b/srcpkgs/guvcview/patches/fix-include.patch
new file mode 100644
index 000000000000..503c2af3b78c
--- /dev/null
+++ b/srcpkgs/guvcview/patches/fix-include.patch
@@ -0,0 +1,10 @@
+--- a/guvcview/guvcview.c
++++ b/guvcview/guvcview.c
+@@ -28,6 +28,7 @@
+ #include <sys/stat.h>
+ #include <sys/resource.h>
+ #include <errno.h>
++#include <locale.h>
+ 
+ #include "gview.h"
+ #include "gviewv4l2core.h"
diff --git a/srcpkgs/guvcview/template b/srcpkgs/guvcview/template
index 345cf6006f24..86a7fd619612 100644
--- a/srcpkgs/guvcview/template
+++ b/srcpkgs/guvcview/template
@@ -1,8 +1,7 @@
 # Template file for 'guvcview'
 pkgname=guvcview
-version=2.0.7
+version=2.0.8
 revision=1
-create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-static --disable-debian-menu"
 hostmakedepends="pkg-config intltool autoconf automake libtool glib-devel"
@@ -14,7 +13,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="http://guvcview.sourceforge.net/"
 distfiles="${SOURCEFORGE_SITE}/${pkgname}/${pkgname}-src-${version}.tar.bz2"
-checksum=f47d51fbd06e44eeaa1a82f4a153c927527c90d94514197a70b2956028cc8ad4
+checksum=a21f4e448286666cf27bafef5290cc953a0a1796b752e5bbe521266dc1230c81
 
 post_patch() {
 	sed '31a#include <locale.h>' -i  guvcview/guvcview.c

From ac5f7f4f9bb7730e3bc2c32050c1758b2ea994df Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 043/113] handbrake: update to 1.6.1

---
 .../patches/fix-missing-x265-link-flag.patch    | 11 ++++++-----
 .../handbrake/patches/libhb-vpl-include.patch   | 15 +++++++++++++++
 srcpkgs/handbrake/template                      | 17 ++++++++++-------
 3 files changed, 31 insertions(+), 12 deletions(-)
 create mode 100644 srcpkgs/handbrake/patches/libhb-vpl-include.patch

diff --git a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
index 26db03867a0c..d6bb2eda627a 100644
--- a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
+++ b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
@@ -1,14 +1,15 @@
 --- a/gtk/configure.ac
 +++ b/gtk/configure.ac
 @@ -203,7 +203,7 @@
- 
+
  AM_CONDITIONAL([MINGW], [test "x$mingw_flag" = "xyes"])
- 
--HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg"
-+HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -ldl"
+
+-HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc"
++HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc -ldl"
  HB_CPPFLAGS="$HB_CPPFLAGS $HBINC"
- 
+
  PKG_CHECK_MODULES([x264], [x264], sys_x264=yes, sys_x264=no)
+
 --- a/test/module.defs
 +++ b/test/module.defs
 @@ -69,6 +69,9 @@
diff --git a/srcpkgs/handbrake/patches/libhb-vpl-include.patch b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
new file mode 100644
index 000000000000..298f9f4ab28f
--- /dev/null
+++ b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
@@ -0,0 +1,15 @@
+--- a/libhb/module.defs	2023-01-22 11:36:49.000000000 -0500
++++ b/libhb/module.defs	2023-04-03 22:37:52.395467010 -0400
+@@ -46,11 +46,7 @@
+ LIBHB.GCC.I += $(LIBHB.build/) $(CONTRIB.build/)include
+ 
+ ifeq (1,$(FEATURE.qsv))
+-    ifeq ($(HOST.system),freebsd))
+-        LIBHB.GCC.I += $(LOCALBASE)/include/vpl
+-    else
+-        LIBHB.GCC.I += $(CONTRIB.build/)include/vpl
+-    endif
++    LIBHB.GCC.I += /usr/include/vpl
+ endif
+ 
+ ifneq (,$(filter $(HOST.system),freebsd netbsd openbsd))
diff --git a/srcpkgs/handbrake/template b/srcpkgs/handbrake/template
index ca5e4571e49c..c32cb1bfa31f 100644
--- a/srcpkgs/handbrake/template
+++ b/srcpkgs/handbrake/template
@@ -1,10 +1,10 @@
 # Template file for 'handbrake'
 pkgname=handbrake
-version=1.5.1
+version=1.6.1
 revision=1
 build_style=gnu-configure
 configure_args="--force --disable-gtk-update-checks --disable-df-fetch --harden
- $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc)"
+ $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc) $(vopt_enable qsv)"
 make_build_args="-C ${XBPS_TRIPLET}"
 make_install_args="-C ${XBPS_TRIPLET}"
 hostmakedepends="automake cmake gettext-devel glib-devel intltool libtool m4 meson nasm pkg-config python3"
@@ -12,8 +12,11 @@ makedepends="bzip2-devel ffmpeg-devel gst-plugins-base1-devel gtk+3-devel
  jansson-devel lame-devel libass-devel libbluray-devel libdav1d-devel
  libdvdnav-devel libdvdread-devel libgudev-devel libnuma-devel
  libsamplerate-devel libtheora-devel libvorbis-devel libvpx-devel libxml2-devel
- opus-devel speex-devel x264-devel x265-devel zimg-devel
+ opus-devel speex-devel x264-devel x265-devel zimg-devel libsvt-av1-devel
  $(vopt_if fdk_aac fdk-aac-devel)
+ $(vopt_if qsv libva-devel)
+ $(vopt_if qsv libdrm-devel)
+ $(vopt_if qsv onevpl-devel)
  $(vopt_if nvenc nv-codec-headers)"
 depends="desktop-file-utils gst-plugins-good1 hicolor-icon-theme"
 short_desc="Multithreaded video transcoder"
@@ -21,15 +24,15 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-2.0-only"
 homepage="https://handbrake.fr/"
 distfiles="https://github.com/HandBrake/HandBrake/releases/download/${version}/HandBrake-${version}-source.tar.bz2"
-checksum=3999fe06d5309c819799a73a968a8ec3840e7840c2b64af8f5cdb7fd8c9430f0
+checksum=94ccfe03db917a91650000c510f7fd53f844da19f19ad4b4be1b8f6bc31a8d4c
 nocross=yes
 
-build_options="fdk_aac nvenc"
+build_options="fdk_aac nvenc qsv"
 
 case "$XBPS_TARGET_MACHINE" in
 	x86_64*|i686*)
 		CFLAGS="-msse"
-		build_options_default="nvenc"
+		build_options_default="nvenc qsv"
 		;;
 esac
 
@@ -37,7 +40,7 @@ pre_configure() {
 	# use system libraries, don't download them
 	rm -rf contrib/
 	for module in fdk-aac ffmpeg libbluray libdav1d libdvdnav libdvdread nvenc \
-		x265 zimg; do
+		x265 zimg svt-av1 libvpl; do
 	    vsed -i "/MODULES += contrib\/${module}/d" make/include/main.defs
 	done
 }

From c977407b468a0a18e120caefbee9a0c25f209707 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 044/113] hedgewars: revbump for ffmpeg4-4.4.3

---
 srcpkgs/hedgewars/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/hedgewars/template b/srcpkgs/hedgewars/template
index 419f29b98b44..926fe4fe3e68 100644
--- a/srcpkgs/hedgewars/template
+++ b/srcpkgs/hedgewars/template
@@ -1,13 +1,13 @@
 # Template file for 'hedgewars'
 pkgname=hedgewars
 version=1.0.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DNOSERVER=1 -DDATA_INSTALL_DIR=/usr/share/${pkgname}
  -DPHYSFS_SYSTEM=1 -DMINIMAL_FLAGS=1"
 make_cmd=make
 hostmakedepends="lua51 pkg-config qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
+makedepends="ffmpeg4-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
  SDL2_mixer-devel SDL2_net-devel SDL2_ttf-devel"
 depends="libfreeglut"
 short_desc="Funny turn-based artillery game, featuring fighting Hedgehogs!"

From 8538d8a0d5b91779361e7d5799a7a5d98f14ef65 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 045/113] idjc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/idjc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/idjc/template b/srcpkgs/idjc/template
index df60318b3db9..36a75baf597c 100644
--- a/srcpkgs/idjc/template
+++ b/srcpkgs/idjc/template
@@ -1,11 +1,11 @@
 # Template file for 'idjc'
 pkgname=idjc
 version=0.9.1
-revision=3
+revision=4
 build_style=gnu-configure
 hostmakedepends="pkg-config git python3 automake gettext-devel libtool"
 makedepends="libvorbis-devel libogg-devel jack-devel libsamplerate-devel
- libflac-devel libsndfile-devel mpg123-devel ffmpeg-devel speex-devel
+ libflac-devel libsndfile-devel mpg123-devel ffmpeg4-devel speex-devel
  glib-devel pixman-devel lame-devel python3-gobject-devel libshout-idjc-devel
  opus-devel twolame-devel python3-mutagen python3-devel"
 depends="python3-gobject python3-mutagen desktop-file-utils shared-mime-info python3-dbus jack"

From fb489f4ca059a5af8bab7f6531476ea4c9af8a52 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 046/113] kfilemetadata5: revbump for ffmpeg-6.0

---
 srcpkgs/kfilemetadata5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kfilemetadata5/template b/srcpkgs/kfilemetadata5/template
index 8980121fbc69..f662a2043f93 100644
--- a/srcpkgs/kfilemetadata5/template
+++ b/srcpkgs/kfilemetadata5/template
@@ -1,7 +1,7 @@
 # Template file for 'kfilemetadata5'
 pkgname=kfilemetadata5
 version=5.105.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="kcoreaddons extra-cmake-modules pkg-config qt5-host-tools qt5-qmake
  gettext kcoreaddons python3"

From 9d82756c8286c2c2784e6efc62078decee54e7c2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 047/113] kid3: revbump for ffmpeg-6.0

---
 srcpkgs/kid3/patches/ffmpeg5.patch | 17 +++++++++++++++++
 srcpkgs/kid3/template              |  2 +-
 2 files changed, 18 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/kid3/patches/ffmpeg5.patch

diff --git a/srcpkgs/kid3/patches/ffmpeg5.patch b/srcpkgs/kid3/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..135fc50e07c9
--- /dev/null
+++ b/srcpkgs/kid3/patches/ffmpeg5.patch
@@ -0,0 +1,17 @@
+# https://aur.archlinux.org/cgit/aur.git/diff/ffmpeg5.patch?h=kid3-cli&id=12410a74906612e7efc0ec8fbce739b4a0fef7e7
+diff --git a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+index e156d424..e12b9abd 100644
+--- a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
++++ b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+@@ -232,7 +232,11 @@ private:
+   friend class Format;
+   friend class Converter;
+   AVCodecContext* m_ptr;
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 0, 0)
+   AVCodec* m_impl;
++#else
++  const AVCodec* m_impl;
++#endif
+   AVFrame* m_frame;
+   bool m_opened;
+ };
diff --git a/srcpkgs/kid3/template b/srcpkgs/kid3/template
index 456206d90e16..f32f9decb0e7 100644
--- a/srcpkgs/kid3/template
+++ b/srcpkgs/kid3/template
@@ -1,7 +1,7 @@
 # Template file for 'kid3'
 pkgname=kid3
 version=3.9.1
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DWITH_APPS='CLI;$(vopt_if KDE KDE Qt)'
  -DWITH_DOCBOOKDIR=/usr/share/xsl/docbook -DWITH_FLAC=$(vopt_if flac ON OFF)

From ac6ea4392514528e8de733d0c4e31e4db9c618f6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 048/113] kodi: revbump for ffmpeg4-4.4.3

---
 srcpkgs/kodi/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/kodi/template b/srcpkgs/kodi/template
index 8057964d78a3..6cc1874be7ba 100644
--- a/srcpkgs/kodi/template
+++ b/srcpkgs/kodi/template
@@ -1,7 +1,7 @@
 # Template file for 'kodi'
 pkgname=kodi
 version=19.4
-revision=6
+revision=7
 _codename="Matrix"
 build_style=cmake
 configure_args="-DWITH_FFMPEG=/usr -DENABLE_LDGOLD=OFF
@@ -54,7 +54,7 @@ makedepends="
  libmad-devel fontconfig-devel libXinerama-devel libsamplerate-devel libmms-devel
  enca-devel boost-devel libcurl-devel libva-devel libvdpau-devel libass-devel
  libbluetooth-devel yajl-devel libplist-devel librtmp-devel tinyxml-devel
- taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg-devel
+ taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg4-devel
  giflib-devel libxslt-devel gnutls-devel libssh-devel libmicrohttpd-devel
  libcec-devel dcadec-devel flatbuffers-devel fmt-devel lcms2-devel
  libfstrcmp-devel rapidjson libcdio-paranoia spdlog libwaylandpp-devel

From b04e2d2ce923099980f0a0b0f8e5f7ddc521ac0b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 049/113] kpipewire: revbump for ffmpeg-6.0

---
 srcpkgs/kpipewire/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kpipewire/template b/srcpkgs/kpipewire/template
index 467ab823a5e1..51827f24db9e 100644
--- a/srcpkgs/kpipewire/template
+++ b/srcpkgs/kpipewire/template
@@ -1,7 +1,7 @@
 # Template file for 'kpipewire'
 pkgname=kpipewire
 version=5.27.4
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules plasma-wayland-protocols gettext
  qt5-qmake qt5-host-tools pkg-config wayland-devel kcoreaddons

From a976f1db88006029cd6781dc39d9e4c180bbc34c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 050/113] libextractor: revbump for ffmpeg4-4.4.3

---
 srcpkgs/libextractor/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libextractor/template b/srcpkgs/libextractor/template
index ddd4790f93e8..1fb9ca56a96a 100644
--- a/srcpkgs/libextractor/template
+++ b/srcpkgs/libextractor/template
@@ -7,7 +7,7 @@ configure_args="--disable-static"
 hostmakedepends="pkg-config"
 makedepends="zlib-devel bzip2-devel exiv2-devel tiff-devel libpng-devel
  libjpeg-turbo-devel libvorbis-devel libflac-devel giflib-devel libmpeg2-devel
- ffmpeg-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
+ ffmpeg4-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
 short_desc="Library used to extract meta data from files"
 maintainer="Martin Riese <grauehaare@gmx.de>"
 license="GPL-3.0-or-later"

From 759165a0bd96f98da94279facbe87e56bf8e2406 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 051/113] libopenal: revbump for ffmpeg-6.0

---
 srcpkgs/libopenal/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenal/template b/srcpkgs/libopenal/template
index 77218f9e539d..3f49ed75a1fd 100644
--- a/srcpkgs/libopenal/template
+++ b/srcpkgs/libopenal/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenal'
 pkgname=libopenal
 version=1.22.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DALSOFT_EXAMPLES=OFF"
 hostmakedepends="pkg-config"

From 4e11aa0b8cc515ac4d453fc0cbbb518a3bb43c65 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 052/113] libopenshot: revbump for ffmpeg-6.0

---
 srcpkgs/libopenshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenshot/template b/srcpkgs/libopenshot/template
index db831f69b474..81aa0d7136d9 100644
--- a/srcpkgs/libopenshot/template
+++ b/srcpkgs/libopenshot/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenshot'
 pkgname=libopenshot
 version=0.3.0
-revision=1
+revision=2
 build_style=cmake
 # Builds fail with Ruby-2.4.1
 configure_args="-DENABLE_RUBY=OFF -DUSE_SYSTEM_JSONCPP=ON"

From b9a1bab81e45cab475ff5a9247a88032e8c9fb3a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 053/113] loudgain: revbump for ffmpeg-6.0

---
 srcpkgs/loudgain/patches/ffmpeg5.patch | 11 +++++++++++
 srcpkgs/loudgain/template              |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/loudgain/patches/ffmpeg5.patch

diff --git a/srcpkgs/loudgain/patches/ffmpeg5.patch b/srcpkgs/loudgain/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..16d4510ee98f
--- /dev/null
+++ b/srcpkgs/loudgain/patches/ffmpeg5.patch
@@ -0,0 +1,11 @@
+--- a/src/scan.c	2019-09-06 11:31:19.000000000 -0400
++++ b/src/scan.c	2023-03-23 11:15:40.867968521 -0400
+@@ -69,8 +69,6 @@
+ 	 * It is now useless
+ 	 * https://github.com/FFmpeg/FFmpeg/blob/70d25268c21cbee5f08304da95be1f647c630c15/doc/APIchanges#L86
+ 	 */
+-  if (avformat_version() < AV_VERSION_INT(58,9,100))
+-    av_register_all();
+ 
+ 	av_log_set_callback(scan_av_log);
+ 
diff --git a/srcpkgs/loudgain/template b/srcpkgs/loudgain/template
index da4f2d56e94c..4d6bf29efb4f 100644
--- a/srcpkgs/loudgain/template
+++ b/srcpkgs/loudgain/template
@@ -1,7 +1,7 @@
 # Template file for 'loudgain'
 pkgname=loudgain
 version=0.6.8
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libebur128-devel taglib-devel ffmpeg-devel"

From 93c971e5dc9f21e91f136ed83262a2bc32809b19 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 054/113] mediastreamer: revbump for ffmpeg4-4.4.3

---
 srcpkgs/mediastreamer/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mediastreamer/template b/srcpkgs/mediastreamer/template
index d0e97e858e29..1bde031443a5 100644
--- a/srcpkgs/mediastreamer/template
+++ b/srcpkgs/mediastreamer/template
@@ -1,11 +1,11 @@
 # Template file for 'mediastreamer'
 pkgname=mediastreamer
 version=5.2.6
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_STRICT=0 -DENABLE_UNIT_TESTS=0"
 hostmakedepends="python3"
-makedepends="bzrtp-devel ffmpeg-devel glew-devel libXv-devel libsrtp-devel
+makedepends="bzrtp-devel ffmpeg4-devel glew-devel libXv-devel libsrtp-devel
  libupnp-devel libvpx-devel mbedtls-devel opus-devel ortp-devel pulseaudio-devel
  libtheora-devel speex-devel v4l-utils-devel bcg729-devel bcmatroska2-devel libgsm-devel"
 # zxing-cpp-devel (1.2.0 probably not compatible, check again after updaing xzing)

From a7398921fd507cc4f99d9ac405b5365a7a9dec71 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 055/113] mgba: revbump for ffmpeg-6.0

---
 srcpkgs/mgba/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mgba/template b/srcpkgs/mgba/template
index ae0504311eee..d31295a0cd3d 100644
--- a/srcpkgs/mgba/template
+++ b/srcpkgs/mgba/template
@@ -1,7 +1,7 @@
 # Template file for 'mgba'
 pkgname=mgba
 version=0.10.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake desktop-file-utils"
 makedepends="SDL2-devel ffmpeg-devel libedit-devel libepoxy-devel libmagick-devel

From 383c3ed41f29b18fb0f53b5af90962affcadc6e2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 056/113] minidlna: revbump for ffmpeg-6.0

---
 srcpkgs/minidlna/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/minidlna/template b/srcpkgs/minidlna/template
index e8081b1cbc67..9ee9714861fd 100644
--- a/srcpkgs/minidlna/template
+++ b/srcpkgs/minidlna/template
@@ -1,7 +1,7 @@
 # Template file for 'minidlna'
 pkgname=minidlna
 version=1.3.2
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="
  --sbindir=/usr/bin

From 69e08351149d93b98af6d905a3a14080653d0e5e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 057/113] mixxx: revbump for ffmpeg-6.0

---
 srcpkgs/mixxx/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mixxx/template b/srcpkgs/mixxx/template
index 619ddca0d332..4b9ea00d3fb3 100644
--- a/srcpkgs/mixxx/template
+++ b/srcpkgs/mixxx/template
@@ -1,7 +1,7 @@
 # Template file for 'mixxx'
 pkgname=mixxx
 version=2.3.3
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="extra-cmake-modules pkg-config protobuf qt5-host-tools qt5-devel"

From 339268db1683a15859ce21a8cdcd55675ebc52bc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 058/113] mlt: revbump for ffmpeg4-4.4.3

---
 srcpkgs/mlt/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mlt/template b/srcpkgs/mlt/template
index 8933eb4e7bb9..73353fedafb5 100644
--- a/srcpkgs/mlt/template
+++ b/srcpkgs/mlt/template
@@ -1,14 +1,14 @@
 # Template file for 'mlt'
 pkgname=mlt
 version=6.26.1
-revision=1
+revision=2
 build_style=configure
 configure_args="--prefix=/usr --libdir=/usr/lib$XBPS_TARGET_WORDSIZE
  --enable-gpl --enable-gpl3 --disable-swfdec --without-kde
  --swig-languages=python"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which"
 # XXX: movit vid.stab
-makedepends="alsa-lib-devel ffmpeg-devel gtk+-devel jack-devel ladspa-sdk
+makedepends="alsa-lib-devel ffmpeg4-devel gtk+-devel jack-devel ladspa-sdk
  libexif-devel libsamplerate-devel libxml2-devel sox-devel SDL_image-devel
  fftw-devel frei0r-plugins python3-devel pulseaudio-devel movit-devel
  libvidstab-devel libatomic-devel"

From 1dcf923887aa8125a2e5463058a63049db5b4bbb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 059/113] moc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/moc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/moc/template b/srcpkgs/moc/template
index c42be650a1d2..d4f0eefbad52 100644
--- a/srcpkgs/moc/template
+++ b/srcpkgs/moc/template
@@ -1,10 +1,10 @@
 # Template file for 'moc'
 pkgname=moc
 version=2.5.2
-revision=6
+revision=7
 build_style=gnu-configure
 hostmakedepends="pkg-config"
-makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg-devel
+makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg4-devel
  jack-devel alsa-lib-devel libltdl-devel libflac-devel libvorbis-devel
  libmad-devel libmpcdec-devel libmodplug-devel libid3tag-devel faad2-devel
  taglib-devel libsndfile-devel wavpack-devel speex-devel libsamplerate-devel

From d23376c278c137073dbd451de087d06b752e01f7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 060/113] motion: revbump for ffmpeg-6.0

---
 srcpkgs/motion/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/motion/template b/srcpkgs/motion/template
index 3cf3c3035c5b..7dca12d851e3 100644
--- a/srcpkgs/motion/template
+++ b/srcpkgs/motion/template
@@ -1,7 +1,7 @@
 # Template file for 'motion'
 pkgname=motion
 version=4.5.1
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake pkg-config gettext-devel tar"
 makedepends="ffmpeg-devel libmicrohttpd-devel v4l-utils-devel gettext-devel"

From 7d055b7a079c04ced1c8a67567b03311f475ad2e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 061/113] mpv: revbump for ffmpeg-6.0

---
 srcpkgs/mpv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpv/template b/srcpkgs/mpv/template
index e163c496c6eb..d4fefbf5e3c7 100644
--- a/srcpkgs/mpv/template
+++ b/srcpkgs/mpv/template
@@ -1,7 +1,7 @@
 # Template file for 'mpv'
 pkgname=mpv
 version=0.35.1
-revision=2
+revision=3
 build_style=meson
 configure_args="-Dcdda=enabled -Ddvbin=enabled -Ddvdnav=enabled
  -Dlibmpv=true -Dcplugins=enabled

From fe527a863bd958c1591544338d983cd9fcd62455 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 062/113] musikcube: revbump for ffmpeg-6.0

---
 srcpkgs/musikcube/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/musikcube/template b/srcpkgs/musikcube/template
index 7c569303c054..a4dea460c371 100644
--- a/srcpkgs/musikcube/template
+++ b/srcpkgs/musikcube/template
@@ -1,7 +1,7 @@
 # Template file for 'musikcube'
 pkgname=musikcube
 version=3.0.0
-revision=1
+revision=2
 build_style=cmake
 make_cmd=make
 configure_args="-DNO_NCURSESW=1"

From e88f6b56be144d38ed94d2cfd21b7a343866839b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 063/113] notcurses: revbump for ffmpeg-6.0

---
 srcpkgs/notcurses/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/notcurses/template b/srcpkgs/notcurses/template
index 6dd8a091319f..3110c30c9aff 100644
--- a/srcpkgs/notcurses/template
+++ b/srcpkgs/notcurses/template
@@ -1,7 +1,7 @@
 # Template file for 'notcurses'
 pkgname=notcurses
 version=3.0.9
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DUSE_STATIC=ON $(vopt_bool man USE_PANDOC)"
 hostmakedepends="pkg-config $(vopt_if man pandoc)"

From 948eb108acbe600687863968224b6bc66d589382 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 064/113] obs: revbump for ffmpeg-6.0

---
 srcpkgs/obs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/obs/template b/srcpkgs/obs/template
index 7ee29ff3eac6..fd06df415301 100644
--- a/srcpkgs/obs/template
+++ b/srcpkgs/obs/template
@@ -1,7 +1,7 @@
 # Template file for 'obs'
 pkgname=obs
 version=29.1.1
-revision=1
+revision=2
 archs="i686* x86_64* ppc64le* aarch64*"
 build_style=cmake
 configure_args="-DOBS_VERSION_OVERRIDE=${version} -DENABLE_JACK=ON

From 642b1d475b863462e185aef8c317136d32fe2b83 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 065/113] olive: revbump for ffmpeg4-4.4.3

---
 srcpkgs/olive/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/olive/template b/srcpkgs/olive/template
index 12a46936c990..5c2917b9c512 100644
--- a/srcpkgs/olive/template
+++ b/srcpkgs/olive/template
@@ -1,10 +1,10 @@
 # Template file for 'olive'
 pkgname=olive
 version=0.1.2
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools pkg-config"
-makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg-devel frei0r-plugins"
+makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg4-devel frei0r-plugins"
 short_desc="Non-linear video editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"

From 5e34fa4b95402f61dc12ec764758bdaa446fd3f5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 066/113] omxplayer: revbump for ffmpeg4-4.4.3

---
 srcpkgs/omxplayer/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/omxplayer/template b/srcpkgs/omxplayer/template
index e70bf7873d4d..0e9bc70e7c8e 100644
--- a/srcpkgs/omxplayer/template
+++ b/srcpkgs/omxplayer/template
@@ -1,10 +1,10 @@
 # Template file for 'omxplayer'
 pkgname=omxplayer
 version=20190102
-revision=1
+revision=2
 short_desc="Commandline OMX player for the Raspberry Pi"
 maintainer="Orphaned <orphan@voidlinux.org>"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://github.com/popcornmix/omxplayer"
 
 _commit="f06235cc9690a6d58187514452df8cf8fcdaacec"
@@ -15,7 +15,7 @@ checksum=af2d9450f8947842ea8c401fe9f71eec444013ebbdee29f2ac828c9c493c1329
 archs="armv6l* armv7l*"
 build_style=gnu-makefile
 hostmakedepends="curl pkg-config"
-makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg-devel dbus-devel"
+makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg4-devel dbus-devel"
 depends="freefont-ttf"
 
 do_build() {

From 30d0a1b84ddc42e6bba853ffe14244f22360d505 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 067/113] openimageio: revbump for ffmpeg-6.0

---
 common/shlibs                | 2 ++
 srcpkgs/openimageio/template | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/shlibs b/common/shlibs
index 8cb5ff0f7457..d7ee22d4426e 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2263,6 +2263,8 @@ libxmp.so.4 libxmp-4.3.7_1
 libKF5ThreadWeaver.so.5 threadweaver-5.26.0_1
 libOpenImageIO_Util.so.2.4 openimageio-2.4.9.0_1
 libOpenImageIO.so.2.4 openimageio-2.4.9.0_1
+libOpenImageIO_Util.so.2.4 openimageio-2.4.8.1_1
+libOpenImageIO.so.2.4 openimageio-2.4.8.1_1
 libOpenColorIO.so.2.1 opencolorio-2.1.2_1
 libpystring.so.1 pystring-1.1.3_1
 libyaml-cpp.so.0.7 yaml-cpp-0.7.0_1
diff --git a/srcpkgs/openimageio/template b/srcpkgs/openimageio/template
index 9b38ace50f7e..c2d36b4b3539 100644
--- a/srcpkgs/openimageio/template
+++ b/srcpkgs/openimageio/template
@@ -1,7 +1,7 @@
 # Template file for 'openimageio'
 pkgname=openimageio
 version=2.4.9.0
-revision=3
+revision=4
 build_style=cmake
 build_helper=qemu
 configure_args="-DUSE_QT=0 -DUSE_PYTHON=0 -DOIIO_BUILD_TESTS=0

From 4234f6fee056b6a7caad12bfedf4efdcaa33340b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 068/113] openshot: revbump for ffmpeg-6.0

---
 srcpkgs/openshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openshot/template b/srcpkgs/openshot/template
index 322717d40abc..c074e0338773 100644
--- a/srcpkgs/openshot/template
+++ b/srcpkgs/openshot/template
@@ -1,7 +1,7 @@
 # Template file for 'openshot'
 pkgname=openshot
 version=3.0.0
-revision=1
+revision=2
 build_style=python3-module
 hostmakedepends="python3 python3-setuptools"
 makedepends="ffmpeg-devel python3-PyQt5"

From faffd94bc5fa34bf2cd94dbfea0c0069c7cd7593 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 069/113] opentoonz: revbump for ffmpeg-6.0

---
 srcpkgs/opentoonz/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/opentoonz/template b/srcpkgs/opentoonz/template
index ee9f7603f55f..3e81834ca0ed 100644
--- a/srcpkgs/opentoonz/template
+++ b/srcpkgs/opentoonz/template
@@ -1,7 +1,7 @@
 # Template file for 'opentoonz'
 pkgname=opentoonz
 version=1.6.0
-revision=2
+revision=3
 build_wrksrc="toonz/sources"
 build_style=cmake
 make_cmd=make

From f98800733cc79de658d0523d44d2db2060452f49 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 070/113] pianobar: revbump for ffmpeg-6.0

---
 srcpkgs/pianobar/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pianobar/template b/srcpkgs/pianobar/template
index a9b29e91993f..81efcd122c4d 100644
--- a/srcpkgs/pianobar/template
+++ b/srcpkgs/pianobar/template
@@ -1,7 +1,7 @@
 # Template file for 'pianobar'
 pkgname=pianobar
 version=2022.04.01
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="V=1"
 hostmakedepends="pkg-config"

From 7f03f4c5e598da017c6ae15527bcdb5262328cc3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 071/113] ppsspp: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ppsspp/template | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/ppsspp/template b/srcpkgs/ppsspp/template
index 7984a733d4be..15a42fd2c993 100644
--- a/srcpkgs/ppsspp/template
+++ b/srcpkgs/ppsspp/template
@@ -1,7 +1,7 @@
 # Template file for 'ppsspp'
 pkgname=ppsspp
 version=1.14.4
-revision=1
+revision=2
 _glslang_commit=dc11adde23c455a24e13dd54de9b4ede8bdd7db8
 _SPIRV_Cross_commit=9acb9ec31f5a8ef80ea6b994bb77be787b08d3d1
 _armips_commit=6719edebaae03330ee5441d9b28280672edf00d5
@@ -13,7 +13,7 @@ configure_args="-DHEADLESS=1 -DUSE_SYSTEM_FFMPEG=1 -DUNITTEST=ON
  -DUSING_QT_UI=$(vopt_if qt ON OFF) -DUSE_SYSTEM_ZSTD=ON
  -DARMIPS_USE_STD_FILESYSTEM=ON"
 hostmakedepends="pkg-config python3 $(vopt_if qt qt5-host-tools)"
-makedepends="zlib-devel glew-devel ffmpeg-devel libzip-devel
+makedepends="zlib-devel glew-devel ffmpeg4-devel libzip-devel
  snappy-devel rapidjson libpng-devel libzstd-devel
  $(vopt_if sdl2 SDL2-devel) $(vopt_if wayland wayland-devel)
  $(vopt_if qt 'qt5-devel qt5-multimedia-devel')"
@@ -62,13 +62,12 @@ post_extract() {
 	mv ${wrksrc}/miniupnp-${_miniupnp_commit} ${wrksrc}/ext/miniupnp
 }
 
-post_patch(){
+post_patch() {
 	# disable git versioning
 	vsed -e 's|find_package(Git)|# &|' -i git-version.cmake
 }
 
 do_install() {
-	vlicense LICENSE.TXT
 	vinstall icons/icon.svg 644 usr/share/pixmaps ppsspp.svg
 	vinstall Qt/PPSSPP.desktop 644 usr/share/applications
 	vbin build/PPSSPPHeadless ppsspp-headless

From 67a235e385b2086ea2d9ec7983310b790d7efc05 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 072/113] pqiv: revbump for ffmpeg-6.0

---
 srcpkgs/pqiv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pqiv/template b/srcpkgs/pqiv/template
index 542fc27a2d32..9308d949b6a1 100644
--- a/srcpkgs/pqiv/template
+++ b/srcpkgs/pqiv/template
@@ -1,7 +1,7 @@
 # Template file for 'pqiv'
 pkgname=pqiv
 version=2.12
-revision=1
+revision=2
 build_style=gnu-makefile
 hostmakedepends="pkg-config"
 makedepends="glib-devel gtk+3-devel $(vopt_if ffmpeg ffmpeg-devel)

From 9cd1ff7447c208e3f5d059261780fb25afe7598b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 073/113] qmmp: revbump for ffmpeg-6.0

---
 srcpkgs/qmmp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qmmp/template b/srcpkgs/qmmp/template
index 26c661ed16be..a150d7441c7a 100644
--- a/srcpkgs/qmmp/template
+++ b/srcpkgs/qmmp/template
@@ -1,7 +1,7 @@
 # Template file for 'qmmp'
 pkgname=qmmp
 version=1.6.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DUSE_HAL:BOOL=FALSE -DQMMP_DEFAULT_UI:STRING=simple"
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From 42fb11f68686570af73ef697926e1ab5ae72bce7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 074/113] qt5-webengine: update to 5.15.13

---
 .../chromium-media-filters-cpp14.patch        |  11 ++
 srcpkgs/qt5-webengine/patches/ffmpeg5.patch   | 179 ++++++++++++++++++
 srcpkgs/qt5-webengine/template                |  10 +-
 3 files changed, 195 insertions(+), 5 deletions(-)
 create mode 100644 srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/ffmpeg5.patch

diff --git a/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
new file mode 100644
index 000000000000..04adc540f2cb
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
@@ -0,0 +1,11 @@
+--- a/src/3rdparty/chromium/media/filters/BUILD.gn	2023-02-27 13:32:59.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/BUILD.gn	2023-04-02 17:21:39.204066384 -0400
+@@ -96,6 +96,8 @@
+     "//ui/gfx/geometry:geometry",
+   ]
+ 
++  cflags_cc = [ "-std=c++14" ]
++
+   libs = []
+ 
+   if (proprietary_codecs) {
diff --git a/srcpkgs/qt5-webengine/patches/ffmpeg5.patch b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..ac55e1634423
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
@@ -0,0 +1,179 @@
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:57.732547446 -0400
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:09.486478995 -0400
+@@ -57,6 +57,8 @@
+ 
+ namespace {
+ 
++constexpr int64_t kRelativeTsBase = static_cast<int64_t>(0x7ffeffffffffffff);
++
+ void SetAVStreamDiscard(AVStream* stream, AVDiscard discard) {
+   DCHECK(stream);
+   stream->discard = discard;
+@@ -90,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+   if (stream->start_time != kNoFFmpegTimestamp)
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (stream->first_dts != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, stream->first_dts);
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -408,11 +398,11 @@
+   scoped_refptr<DecoderBuffer> buffer;
+ 
+   if (type() == DemuxerStream::TEXT) {
+-    int id_size = 0;
++    size_t id_size = 0;
+     uint8_t* id_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
+ 
+-    int settings_size = 0;
++    size_t settings_size = 0;
+     uint8_t* settings_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
+ 
+@@ -424,7 +414,7 @@
+     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
+                                      side_data.data(), side_data.size());
+   } else {
+-    int side_data_size = 0;
++    size_t side_data_size = 0;
+     uint8_t* side_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
+ 
+@@ -485,7 +475,7 @@
+                                        packet->size - data_offset);
+     }
+ 
+-    int skip_samples_size = 0;
++    size_t skip_samples_size = 0;
+     const uint32_t* skip_samples_ptr =
+         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
+             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
+@@ -1587,6 +1577,8 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++      continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+       lowest_start_time_stream = stream.get();
+@@ -1604,6 +1596,8 @@
+     if (stream && stream->type() == DemuxerStream::VIDEO &&
+         stream->IsEnabled()) {
+       video_stream = stream.get();
++      if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++        continue;
+       if (video_stream->start_time() <= seek_time) {
+         return video_stream;
+       }
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h qtwebengine-5.15.10/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h
+--- a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-07-11 22:12:47.917192788 -0500
+@@ -29,6 +29,7 @@ extern "C" {
+ #include <libavformat/avformat.h>
+ #include <libavformat/avio.h>
+ #include <libavutil/avutil.h>
++#include <libavutil/channel_layout.h>
+ #include <libavutil/imgutils.h>
+ #include <libavutil/log.h>
+ #include <libavutil/mastering_display_metadata.h>
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/audio_file_reader.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/audio_file_reader.cc
+--- a/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -85,7 +85,7 @@ bool AudioFileReader::OpenDemuxer() {
+ }
+ 
+ bool AudioFileReader::OpenDecoder() {
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (codec) {
+     // MP3 decodes to S16P which we don't support, tell it to use S16 instead.
+     if (codec_context_->sample_fmt == AV_SAMPLE_FMT_S16P)
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -329,7 +329,7 @@ bool FFmpegAudioDecoder::ConfigureDecode
+     }
+   }
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec ||
+       avcodec_open2(codec_context_.get(), codec, &codec_options) < 0) {
+     DLOG(ERROR) << "Could not initialize audio decoder: "
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -59,7 +59,6 @@ static int64_t AVIOSeekOperation(void* o
+ }
+ 
+ void FFmpegGlue::InitializeFFmpeg() {
+-  av_register_all();
+ }
+ 
+ static void LogContainer(bool is_local_file,
+@@ -95,9 +94,6 @@ FFmpegGlue::FFmpegGlue(FFmpegURLProtocol
+   // Enable fast, but inaccurate seeks for MP3.
+   format_context_->flags |= AVFMT_FLAG_FAST_SEEK;
+ 
+-  // Ensures we can read out various metadata bits like vp8 alpha.
+-  format_context_->flags |= AVFMT_FLAG_KEEP_SIDE_DATA;
+-
+   // Ensures format parsing errors will bail out. From an audit on 11/2017, all
+   // instances were real failures. Solves bugs like http://crbug.com/710791.
+   format_context_->error_recognition |= AV_EF_EXPLODE;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -391,7 +391,7 @@ bool FFmpegVideoDecoder::ConfigureDecode
+   if (decode_nalus_)
+     codec_context_->flags2 |= AV_CODEC_FLAG2_CHUNKS;
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
+     ReleaseFFmpegResources();
+     return false;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/media_file_checker.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/media_file_checker.cc
+--- a/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -68,7 +68,7 @@ bool MediaFileChecker::Start(base::TimeD
+       auto context = AVStreamToAVCodecContext(format_context->streams[i]);
+       if (!context)
+         continue;
+-      AVCodec* codec = avcodec_find_decoder(cp->codec_id);
++      const AVCodec* codec = avcodec_find_decoder(cp->codec_id);
+       if (codec && avcodec_open2(context.get(), codec, nullptr) >= 0) {
+         auto loop = std::make_unique<FFmpegDecodingLoop>(context.get());
+         stream_contexts[i] = {std::move(context), std::move(loop)};
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc qtwebengine-5.15.10/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc
+--- a/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -203,7 +203,7 @@ int32_t H264DecoderImpl::InitDecode(cons
+   // a pointer |this|.
+   av_context_->opaque = this;
+ 
+-  AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
+   if (!codec) {
+     // This is an indication that FFmpeg has not been initialized or it has not
+     // been compiled/initialized with the correct set of codecs.
diff --git a/srcpkgs/qt5-webengine/template b/srcpkgs/qt5-webengine/template
index 85267c7cf8a3..095ab67701e4 100644
--- a/srcpkgs/qt5-webengine/template
+++ b/srcpkgs/qt5-webengine/template
@@ -1,9 +1,9 @@
 # Template file for 'qt5-webengine'
 pkgname=qt5-webengine
-version=5.15.11
-revision=3
+version=5.15.13
+revision=1
 _version="${version}-lts"
-_chromium_commit=be349eaf62e77955791d7bf29f893f1e8a37daf4
+_chromium_commit=e48df7803c7c98b0b2471c94057d32e44a301ad5
 archs="x86_64* i686* armv[67]* ppc64* aarch64*"
 create_wrksrc=yes
 build_style=qmake
@@ -32,8 +32,8 @@ license="GPL-3.0-or-later, LGPL-3.0-or-later"
 homepage="https://qt.io/"
 distfiles="https://github.com/qt/qtwebengine/archive/v${_version}.tar.gz
  https://github.com/qt/qtwebengine-chromium/archive/${_chromium_commit}.tar.gz"
-checksum="aa7466356c450c5f5870f979b93cd7e7e62da1165c328ffcab1a9928db18ad67
- 6f47ed8ab8cc062411f6f206da6353bc8263d6ed6d6290c689a05c01d91f646b"
+checksum="4b59838ed75ef788b59e1e412535a0e42dd9d311661fdeadb191b581ba815c63
+ a91686562b1d4e8b220e0bbcbab5feb64630e2de974b35ac034bf388af771a6c"
 
 no_generic_pkgconfig_link=yes
 build_options="sndio pipewire"

From 2a426ad733494415cdef1b33d7dde6928c055937 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 075/113] qt5: update to 5.15.8

---
 ...erywhere-opensource-src-5.15.8-kf5-1.patch | 12913 ++++++++++++++++
 srcpkgs/qt5/template                          |    12 +-
 2 files changed, 12919 insertions(+), 6 deletions(-)
 create mode 100644 srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch

diff --git a/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch b/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch
new file mode 100644
index 000000000000..966c98bcd3bb
--- /dev/null
+++ b/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch
@@ -0,0 +1,12913 @@
+Submitted By:            Pierre Labastie <pierre_dot_labastie_at_neuf_dot_fr>
+Date:                    2023-01-05
+Initial Package Version: 5.15.8
+Upstream Status:         Applied (according to KDE)
+Origin:                  KDE patch set
+Description:             Patch set maintained by the KDE folks
+see https://dot.kde.org/2021/04/06/announcing-kdes-qt-5-patch-collection
+Patch generated using the procedure in
+https://wiki.linuxfromscratch.org/blfs/ticket/17476#comment:3
+
+Submodule qtbase 4ee4fc18..9cf586d6:
+diff --git a/qtbase/mkspecs/common/android/qplatformdefs.h b/qtbase/mkspecs/common/android/qplatformdefs.h
+index f75bc4093b..2bd59410d4 100644
+--- a/qtbase/mkspecs/common/android/qplatformdefs.h
++++ b/qtbase/mkspecs/common/android/qplatformdefs.h
+@@ -144,11 +144,7 @@
+ #define QT_SIGNAL_ARGS          int
+ #define QT_SIGNAL_IGNORE        SIG_IGN
+ 
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+ #define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+ 
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+diff --git a/qtbase/mkspecs/features/mac/sdk.mk b/qtbase/mkspecs/features/mac/sdk.mk
+index f30b5830b4..a32ceacb6c 100644
+--- a/qtbase/mkspecs/features/mac/sdk.mk
++++ b/qtbase/mkspecs/features/mac/sdk.mk
+@@ -1,6 +1,6 @@
+ 
+ ifeq ($(QT_MAC_SDK_NO_VERSION_CHECK),)
+-    CHECK_SDK_COMMAND = /usr/bin/xcrun --sdk $(EXPORT_QMAKE_MAC_SDK) -show-sdk-version 2>&1
++    CHECK_SDK_COMMAND = /usr/bin/xcrun --sdk $(EXPORT_QMAKE_MAC_SDK) -show-sdk-version 2>/dev/null
+     CURRENT_MAC_SDK_VERSION := $(shell DEVELOPER_DIR=$(EXPORT_QMAKE_XCODE_DEVELOPER_PATH) $(CHECK_SDK_COMMAND))
+     ifneq ($(CURRENT_MAC_SDK_VERSION),$(EXPORT_QMAKE_MAC_SDK_VERSION))
+         # We don't want to complain about out of date SDK unless the target needs to be remade.
+diff --git a/qtbase/mkspecs/linux-clang/qplatformdefs.h b/qtbase/mkspecs/linux-clang/qplatformdefs.h
+index a818d973f0..c1ab72fbc6 100644
+--- a/qtbase/mkspecs/linux-clang/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-clang/qplatformdefs.h
+@@ -79,14 +79,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-g++/qplatformdefs.h b/qtbase/mkspecs/linux-g++/qplatformdefs.h
+index 13523f0702..4d2750d9ec 100644
+--- a/qtbase/mkspecs/linux-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-g++/qplatformdefs.h
+@@ -79,14 +79,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ < 2)
+-#define QT_SOCKLEN_T            int
+-#else
+-#define QT_SOCKLEN_T            socklen_t
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-llvm/qplatformdefs.h b/qtbase/mkspecs/linux-llvm/qplatformdefs.h
+index dc750ab1ef..d3cc39b47f 100644
+--- a/qtbase/mkspecs/linux-llvm/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-llvm/qplatformdefs.h
+@@ -80,14 +80,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h b/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
+index 4c4e53da2a..83baffb3e3 100644
+--- a/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
+@@ -85,16 +85,9 @@
+ #include "../common/posix/qplatformdefs.h"
+ 
+ #undef QT_OPEN_LARGEFILE
+-#undef QT_SOCKLEN_T
+ 
+ #define QT_OPEN_LARGEFILE       0
+ 
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #ifndef SIOCGIFBRDADDR
+ #  define SIOCGIFBRDADDR 0x8919
+ #endif
+diff --git a/qtbase/mkspecs/lynxos-g++/qplatformdefs.h b/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
+index 4339ea2b23..6007af0055 100644
+--- a/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
+@@ -72,14 +72,6 @@
+ 
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp b/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
+index c3c184258f..32af3f8f29 100644
+--- a/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
++++ b/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
+@@ -10,6 +10,7 @@
+ #include "libANGLE/HandleAllocator.h"
+ 
+ #include <algorithm>
++#include <limits>
+ 
+ #include "common/debug.h"
+ 
+diff --git a/qtbase/src/3rdparty/forkfd/forkfd_linux.c b/qtbase/src/3rdparty/forkfd/forkfd_linux.c
+index ffe0e9a5e2..b1f5408d11 100644
+--- a/qtbase/src/3rdparty/forkfd/forkfd_linux.c
++++ b/qtbase/src/3rdparty/forkfd/forkfd_linux.c
+@@ -82,7 +82,8 @@ static int sys_clone(unsigned long cloneflags, int *ptid)
+     return syscall(__NR_clone, cloneflags, child_stack, stack_size, ptid, newtls, ctid);
+ #elif defined(__arc__) || defined(__arm__) || defined(__aarch64__) || defined(__mips__) || \
+     defined(__nds32__) || defined(__hppa__) || defined(__powerpc__) || defined(__i386__) || \
+-    defined(__x86_64__) || defined(__xtensa__) || defined(__alpha__) || defined(__riscv)
++    defined(__x86_64__) || defined(__xtensa__) || defined(__alpha__) || defined(__riscv) || \
++    defined(__loongarch__)
+     /* ctid and newtls are inverted on CONFIG_CLONE_BACKWARDS architectures,
+      * but since both values are 0, there's no harm. */
+     return syscall(__NR_clone, cloneflags, child_stack, ptid, ctid, newtls);
+diff --git a/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java b/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
+index 5792b5b2f5..2f74750fcf 100644
+--- a/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
++++ b/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
+@@ -116,6 +116,7 @@ public class QtNative
+     public static QtThread m_qtThread = new QtThread();
+     private static HashMap<String, Uri> m_cachedUris = new HashMap<String, Uri>();
+     private static ArrayList<String> m_knownDirs = new ArrayList<String>();
++    private static final String NoPermissionErrorMessage = "No permissions to open Uri";
+ 
+     private static final Runnable runPendingCppRunnablesRunnable = new Runnable() {
+         @Override
+@@ -193,11 +194,10 @@ public class QtNative
+                     return iterUri;
+             }
+ 
+-            // Android 6 and earlier could still manage to open the file so we can return the
+-            // parsed uri here
+-            if (Build.VERSION.SDK_INT < 24)
+-                return parsedUri;
+-            return null;
++            // if we only have transient permissions on uri all the above will fail,
++            // but we will be able to read the file anyway, so continue with uri here anyway
++            // and check for SecurityExceptions later
++            return parsedUri;
+         } catch (SecurityException e) {
+             e.printStackTrace();
+             return null;
+@@ -244,7 +244,7 @@ public class QtNative
+         int error = -1;
+ 
+         if (uri == null) {
+-            Log.e(QtTAG, "openFdForContentUrl(): No permissions to open Uri");
++            Log.e(QtTAG, "openFdForContentUrl(): " + NoPermissionErrorMessage);
+             return error;
+         }
+ 
+@@ -254,12 +254,13 @@ public class QtNative
+             return fdDesc.detachFd();
+         } catch (FileNotFoundException e) {
+             e.printStackTrace();
+-            return error;
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "openFdForContentUrl(): Invalid Uri");
+             e.printStackTrace();
+-            return error;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return error;
+     }
+ 
+     public static long getSize(Context context, String contentUrl)
+@@ -270,7 +271,7 @@ public class QtNative
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+ 
+         if (uri == null) {
+-            Log.e(QtTAG, "getSize(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return size;
+         } else if (!m_cachedUris.containsKey(contentUrl)) {
+             m_cachedUris.put(contentUrl, uri);
+@@ -288,12 +289,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "getSize(): Invalid Uri");
+             e.printStackTrace();
+-            return size;
+         }  catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "getSize(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return size;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return size;
+     }
+ 
+     public static boolean checkFileExists(Context context, String contentUrl)
+@@ -303,7 +305,7 @@ public class QtNative
+         if (uri == null)
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+         if (uri == null) {
+-            Log.e(QtTAG, "checkFileExists(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return exists;
+         } else {
+             if (!m_cachedUris.containsKey(contentUrl))
+@@ -321,12 +323,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "checkFileExists(): Invalid Uri");
+             e.printStackTrace();
+-            return exists;
+         } catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "checkFileExists(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return false;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return exists;
+     }
+ 
+     public static boolean checkIfWritable(Context context, String contentUrl)
+@@ -344,7 +347,7 @@ public class QtNative
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+         }
+         if (uri == null) {
+-            Log.e(QtTAG, "isDir(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return isDir;
+         } else {
+             if (!m_cachedUris.containsKey(contentUrl))
+@@ -374,12 +377,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "checkIfDir(): Invalid Uri");
+             e.printStackTrace();
+-            return false;
+         } catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "checkIfDir(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return false;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return false;
+     }
+     public static String[] listContentsFromTreeUri(Context context, String contentUrl)
+     {
+diff --git a/qtbase/src/concurrent/qtconcurrentreducekernel.h b/qtbase/src/concurrent/qtconcurrentreducekernel.h
+index 8f9a938952..a98dedef2e 100644
+--- a/qtbase/src/concurrent/qtconcurrentreducekernel.h
++++ b/qtbase/src/concurrent/qtconcurrentreducekernel.h
+@@ -212,11 +212,13 @@ public:
+ 
+     inline bool shouldThrottle()
+     {
++        std::lock_guard<QMutex> locker(mutex);
+         return (resultsMapSize > (ReduceQueueThrottleLimit * threadCount));
+     }
+ 
+     inline bool shouldStartThread()
+     {
++        std::lock_guard<QMutex> locker(mutex);
+         return (resultsMapSize <= (ReduceQueueStartLimit * threadCount));
+     }
+ };
+diff --git a/qtbase/src/concurrent/qtconcurrentthreadengine.cpp b/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
+index ea6ce3ac42..7f91a2ba68 100644
+--- a/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
++++ b/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
+@@ -176,6 +176,39 @@ void ThreadEngineBase::startSingleThreaded()
+     finish();
+ }
+ 
++void ThreadEngineBase::startBlocking()
++{
++    start();
++    barrier.acquire();
++    startThreads();
++
++    bool throttled = false;
++#ifndef QT_NO_EXCEPTIONS
++    try {
++#endif
++        while (threadFunction() == ThrottleThread) {
++            if (threadThrottleExit()) {
++                throttled = true;
++                break;
++            }
++        }
++#ifndef QT_NO_EXCEPTIONS
++    } catch (QException &e) {
++        handleException(e);
++    } catch (...) {
++        handleException(QUnhandledException());
++    }
++#endif
++
++    if (throttled == false) {
++        barrier.release();
++    }
++
++    barrier.wait();
++    finish();
++    exceptionStore.throwPossibleException();
++}
++
+ void ThreadEngineBase::startThread()
+ {
+     startThreadInternal();
+diff --git a/qtbase/src/concurrent/qtconcurrentthreadengine.h b/qtbase/src/concurrent/qtconcurrentthreadengine.h
+index 7c30cebdbc..a4c8548cc4 100644
+--- a/qtbase/src/concurrent/qtconcurrentthreadengine.h
++++ b/qtbase/src/concurrent/qtconcurrentthreadengine.h
+@@ -91,6 +91,7 @@ public:
+     ThreadEngineBase();
+     virtual ~ThreadEngineBase();
+     void startSingleThreaded();
++    void startBlocking();
+     void startThread();
+     bool isCanceled();
+     void waitForResume();
+@@ -143,6 +144,15 @@ public:
+         return result();
+     }
+ 
++    // Runs the user algorithm using multiple threads.
++    // This function blocks until the algorithm is finished,
++    // and then returns the result.
++    T *startBlocking()
++    {
++        ThreadEngineBase::startBlocking();
++        return result();
++    }
++
+     // Runs the user algorithm using multiple threads.
+     // Does not block, returns a future.
+     QFuture<T> startAsynchronously()
+@@ -223,6 +233,13 @@ class ThreadEngineStarter : public ThreadEngineStarterBase<T>
+ public:
+     ThreadEngineStarter(TypedThreadEngine *eng)
+         : Base(eng) { }
++
++    T startBlocking()
++    {
++        T t = *this->threadEngine->startBlocking();
++        delete this->threadEngine;
++        return t;
++    }
+ };
+ 
+ // Full template specialization where T is void.
+@@ -232,6 +249,12 @@ class ThreadEngineStarter<void> : public ThreadEngineStarterBase<void>
+ public:
+     ThreadEngineStarter(ThreadEngine<void> *_threadEngine)
+         : ThreadEngineStarterBase<void>(_threadEngine) {}
++
++    void startBlocking()
++    {
++        this->threadEngine->startBlocking();
++        delete this->threadEngine;
++    }
+ };
+ 
+ //! [qtconcurrentthreadengine-1]
+diff --git a/qtbase/src/corelib/animation/qvariantanimation.cpp b/qtbase/src/corelib/animation/qvariantanimation.cpp
+index 98b02f0202..eac1524107 100644
+--- a/qtbase/src/corelib/animation/qvariantanimation.cpp
++++ b/qtbase/src/corelib/animation/qvariantanimation.cpp
+@@ -276,7 +276,9 @@ void QVariantAnimationPrivate::setCurrentValueForProgress(const qreal progress)
+ 
+     const qreal startProgress = currentInterval.start.first;
+     const qreal endProgress = currentInterval.end.first;
+-    const qreal localProgress = (progress - startProgress) / (endProgress - startProgress);
++    const qreal localProgress =
++            qIsNull(progress - startProgress) ? 0.0 // avoid 0/0 below
++            /* else */                        : (progress - startProgress) / (endProgress - startProgress);
+ 
+     QVariant ret = q->interpolated(currentInterval.start.second,
+                                    currentInterval.end.second,
+diff --git a/qtbase/src/corelib/global/qnamespace.h b/qtbase/src/corelib/global/qnamespace.h
+index ad4150b317..bf19b1627b 100644
+--- a/qtbase/src/corelib/global/qnamespace.h
++++ b/qtbase/src/corelib/global/qnamespace.h
+@@ -1864,7 +1864,7 @@ public:
+     QT_Q_ENUM(TimerType)
+     QT_Q_ENUM(ScrollPhase)
+     QT_Q_ENUM(MouseEventSource)
+-    QT_Q_FLAG(MouseEventFlag)
++    QT_Q_FLAG(MouseEventFlags)
+     QT_Q_ENUM(ChecksumType)
+     QT_Q_ENUM(HighDpiScaleFactorRoundingPolicy)
+     QT_Q_ENUM(TabFocusBehavior)
+diff --git a/qtbase/src/corelib/global/qrandom.cpp b/qtbase/src/corelib/global/qrandom.cpp
+index 10672c1f92..25f87c7e6a 100644
+--- a/qtbase/src/corelib/global/qrandom.cpp
++++ b/qtbase/src/corelib/global/qrandom.cpp
+@@ -383,7 +383,6 @@ struct QRandomGenerator::SystemAndGlobalGenerators
+ 
+         constexpr SystemAndGlobalGenerators g = {};
+         Q_UNUSED(g);
+-        Q_STATIC_ASSERT(std::is_literal_type<SystemAndGlobalGenerators>::value);
+ #endif
+     }
+ 
+diff --git a/qtbase/src/corelib/io/qbuffer.cpp b/qtbase/src/corelib/io/qbuffer.cpp
+index 595fcd2724..032c0ddd4b 100644
+--- a/qtbase/src/corelib/io/qbuffer.cpp
++++ b/qtbase/src/corelib/io/qbuffer.cpp
+@@ -41,6 +41,8 @@
+ #include <QtCore/qmetaobject.h>
+ #include "private/qiodevice_p.h"
+ 
++#include <limits>
++
+ QT_BEGIN_NAMESPACE
+ 
+ /** QBufferPrivate **/
+@@ -366,7 +368,9 @@ qint64 QBuffer::size() const
+ bool QBuffer::seek(qint64 pos)
+ {
+     Q_D(QBuffer);
+-    if (pos > d->buf->size() && isWritable()) {
++    const auto oldBufSize = d->buf->size();
++    constexpr qint64 MaxSeekPos = (std::numeric_limits<decltype(oldBufSize)>::max)();
++    if (pos <= MaxSeekPos && pos > oldBufSize && isWritable()) {
+         if (seek(d->buf->size())) {
+             const qint64 gapSize = pos - d->buf->size();
+             if (write(QByteArray(gapSize, 0)) != gapSize) {
+@@ -377,7 +381,7 @@ bool QBuffer::seek(qint64 pos)
+             return false;
+         }
+     } else if (pos > d->buf->size() || pos < 0) {
+-        qWarning("QBuffer::seek: Invalid pos: %d", int(pos));
++        qWarning("QBuffer::seek: Invalid pos: %lld", pos);
+         return false;
+     }
+     return QIODevice::seek(pos);
+diff --git a/qtbase/src/corelib/io/qfilesystemengine_win.cpp b/qtbase/src/corelib/io/qfilesystemengine_win.cpp
+index 81d3a71986..c86ed1f9b0 100644
+--- a/qtbase/src/corelib/io/qfilesystemengine_win.cpp
++++ b/qtbase/src/corelib/io/qfilesystemengine_win.cpp
+@@ -664,14 +664,14 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry)
+     return QFileSystemEntry(ret, QFileSystemEntry::FromInternalPath());
+ }
+ 
+-#if defined(Q_CC_MINGW) && WINVER < 0x0602 //  Windows 8 onwards
++#if defined(Q_CC_MINGW) && WINVER < 0x0602 && _WIN32_WINNT < _WIN32_WINNT_WIN8 //  Windows 8 onwards
+ 
+ typedef struct _FILE_ID_INFO {
+     ULONGLONG VolumeSerialNumber;
+     FILE_ID_128 FileId;
+ } FILE_ID_INFO, *PFILE_ID_INFO;
+ 
+-#endif // if defined (Q_CC_MINGW) && WINVER < 0x0602
++#endif // if defined(Q_CC_MINGW) && WINVER < 0x0602 && _WIN32_WINNT < _WIN32_WINNT_WIN8
+ 
+ // File ID for Windows up to version 7 and FAT32 drives
+ static inline QByteArray fileId(HANDLE handle)
+diff --git a/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp b/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
+index 94d9d06bcb..27e0b13b0b 100644
+--- a/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
++++ b/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
+@@ -366,7 +366,9 @@ void QInotifyFileSystemWatcherEngine::readFromInotify()
+     // qDebug("QInotifyFileSystemWatcherEngine::readFromInotify");
+ 
+     int buffSize = 0;
+-    ioctl(inotifyFd, FIONREAD, (char *) &buffSize);
++    if (ioctl(inotifyFd, FIONREAD, (char *) &buffSize) == -1 || buffSize == 0)
++        return;
++
+     QVarLengthArray<char, 4096> buffer(buffSize);
+     buffSize = read(inotifyFd, buffer.data(), buffSize);
+     char *at = buffer.data();
+diff --git a/qtbase/src/corelib/io/qlockfile_win.cpp b/qtbase/src/corelib/io/qlockfile_win.cpp
+index 277f8d4230..38ecef5550 100644
+--- a/qtbase/src/corelib/io/qlockfile_win.cpp
++++ b/qtbase/src/corelib/io/qlockfile_win.cpp
+@@ -48,6 +48,8 @@
+ #include "QtCore/qdebug.h"
+ #include "QtCore/qthread.h"
+ 
++#include "private/qsystemlibrary_p.h"
++
+ QT_BEGIN_NAMESPACE
+ 
+ static inline bool fileExists(const wchar_t *fileName)
+@@ -150,7 +152,7 @@ QString QLockFilePrivate::processNameByPid(qint64 pid)
+ #if !defined(Q_OS_WINRT)
+     typedef DWORD (WINAPI *GetModuleFileNameExFunc)(HANDLE, HMODULE, LPTSTR, DWORD);
+ 
+-    HMODULE hPsapi = LoadLibraryA("psapi");
++    HMODULE hPsapi = QSystemLibrary::load(L"psapi");
+     if (!hPsapi)
+         return QString();
+     GetModuleFileNameExFunc qGetModuleFileNameEx = reinterpret_cast<GetModuleFileNameExFunc>(
+diff --git a/qtbase/src/corelib/io/qprocess_unix.cpp b/qtbase/src/corelib/io/qprocess_unix.cpp
+index 50390e57f5..15c8f30745 100644
+--- a/qtbase/src/corelib/io/qprocess_unix.cpp
++++ b/qtbase/src/corelib/io/qprocess_unix.cpp
+@@ -1,7 +1,7 @@
+ /****************************************************************************
+ **
+ ** Copyright (C) 2016 The Qt Company Ltd.
+-** Copyright (C) 2016 Intel Corporation.
++** Copyright (C) 2022 Intel Corporation.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtCore module of the Qt Toolkit.
+@@ -422,14 +422,15 @@ void QProcessPrivate::startProcess()
+     // Add the program name to the argument list.
+     argv[0] = nullptr;
+     if (!program.contains(QLatin1Char('/'))) {
++        // findExecutable() returns its argument if it's an absolute path,
++        // otherwise it searches $PATH; returns empty if not found (we handle
++        // that case much later)
+         const QString &exeFilePath = QStandardPaths::findExecutable(program);
+-        if (!exeFilePath.isEmpty()) {
+-            const QByteArray &tmp = QFile::encodeName(exeFilePath);
+-            argv[0] = ::strdup(tmp.constData());
+-        }
+-    }
+-    if (!argv[0])
++        const QByteArray &tmp = QFile::encodeName(exeFilePath);
++        argv[0] = ::strdup(tmp.constData());
++    } else {
+         argv[0] = ::strdup(encodedProgramName.constData());
++    }
+ 
+     // Add every argument to the list
+     for (int i = 0; i < arguments.count(); ++i)
+@@ -983,15 +984,16 @@ bool QProcessPrivate::startDetached(qint64 *pid)
+                 envp = _q_dupEnvironment(environment.d.constData()->vars, &envc);
+             }
+ 
+-            QByteArray tmp;
+             if (!program.contains(QLatin1Char('/'))) {
++                // findExecutable() returns its argument if it's an absolute path,
++                // otherwise it searches $PATH; returns empty if not found (we handle
++                // that case much later)
+                 const QString &exeFilePath = QStandardPaths::findExecutable(program);
+-                if (!exeFilePath.isEmpty())
+-                    tmp = QFile::encodeName(exeFilePath);
++                const QByteArray &tmp = QFile::encodeName(exeFilePath);
++                argv[0] = ::strdup(tmp.constData());
++            } else {
++                argv[0] = ::strdup(QFile::encodeName(program));
+             }
+-            if (tmp.isEmpty())
+-                tmp = QFile::encodeName(program);
+-            argv[0] = tmp.data();
+ 
+             if (envp)
+                 qt_safe_execve(argv[0], argv, envp);
+diff --git a/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp b/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
+index 3a79c502af..997a634e76 100644
+--- a/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
++++ b/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
+@@ -3196,9 +3196,8 @@ bool QAbstractItemModel::beginMoveColumns(const QModelIndex &sourceParent, int s
+     destinationChange.needsAdjust = destinationParent.isValid() && destinationParent.row() >= sourceLast && destinationParent.parent() == sourceParent;
+     d->changes.push(destinationChange);
+ 
+-    d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Horizontal);
+-
+     emit columnsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, QPrivateSignal());
++    d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Horizontal);
+     return true;
+ }
+ 
+@@ -3231,7 +3230,6 @@ void QAbstractItemModel::endMoveColumns()
+       adjustedSource = createIndex(adjustedSource.row(), adjustedSource.column() + numMoved, adjustedSource.internalPointer());
+ 
+     d->itemsMoved(adjustedSource, removeChange.first, removeChange.last, adjustedDestination, insertChange.first, Qt::Horizontal);
+-
+     emit columnsMoved(adjustedSource, removeChange.first, removeChange.last, adjustedDestination, insertChange.first, QPrivateSignal());
+ }
+ 
+diff --git a/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+index dc6379d9fb..c5e287ee84 100644
+--- a/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
++++ b/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+@@ -939,8 +939,9 @@ void QSortFilterProxyModelPrivate::insert_source_items(
+                 q->beginInsertColumns(proxy_parent, proxy_start, proxy_end);
+         }
+ 
+-        for (int i = 0; i < source_items.size(); ++i)
+-            proxy_to_source.insert(proxy_start + i, source_items.at(i));
++        // TODO: use the range QList::insert() overload once it is implemented (QTBUG-58633).
++        proxy_to_source.insert(proxy_start, source_items.size(), 0);
++        std::copy(source_items.cbegin(), source_items.cend(), proxy_to_source.begin() + proxy_start);
+ 
+         build_source_to_proxy_mapping(proxy_to_source, source_to_proxy);
+ 
+@@ -3123,8 +3124,9 @@ bool QSortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex &
+ 
+     if (d->filter_data.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();
+@@ -3133,9 +3135,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.hasMatch(key);
+ }
+diff --git a/qtbase/src/corelib/kernel/qcoreapplication.cpp b/qtbase/src/corelib/kernel/qcoreapplication.cpp
+index ca2864df83..132b2eae52 100644
+--- a/qtbase/src/corelib/kernel/qcoreapplication.cpp
++++ b/qtbase/src/corelib/kernel/qcoreapplication.cpp
+@@ -1157,7 +1157,7 @@ static bool doNotify(QObject *receiver, QEvent *event)
+ bool QCoreApplicationPrivate::sendThroughApplicationEventFilters(QObject *receiver, QEvent *event)
+ {
+     // We can't access the application event filters outside of the main thread (race conditions)
+-    Q_ASSERT(receiver->d_func()->threadData.loadRelaxed()->thread.loadAcquire() == mainThread());
++    Q_ASSERT(receiver->d_func()->threadData.loadAcquire()->thread.loadRelaxed() == mainThread());
+ 
+     if (extraData) {
+         // application event filters are only called for objects in the GUI thread
+diff --git a/qtbase/src/corelib/kernel/qobject.cpp b/qtbase/src/corelib/kernel/qobject.cpp
+index 1eb79138d9..36cd780ee1 100644
+--- a/qtbase/src/corelib/kernel/qobject.cpp
++++ b/qtbase/src/corelib/kernel/qobject.cpp
+@@ -1010,7 +1010,7 @@ QObject::~QObject()
+         emit destroyed(this);
+     }
+ 
+-    if (d->declarativeData) {
++    if (!d->isDeletingChildren && d->declarativeData) {
+         if (static_cast<QAbstractDeclarativeDataImpl*>(d->declarativeData)->ownedByQml1) {
+             if (QAbstractDeclarativeData::destroyed_qml1)
+                 QAbstractDeclarativeData::destroyed_qml1(d->declarativeData, this);
+@@ -1580,7 +1580,7 @@ void QObject::moveToThread(QThread *targetThread)
+ 
+     QThreadData *currentData = QThreadData::current();
+     QThreadData *targetData = targetThread ? QThreadData::get2(targetThread) : nullptr;
+-    QThreadData *thisThreadData = d->threadData.loadRelaxed();
++    QThreadData *thisThreadData = d->threadData.loadAcquire();
+     if (!thisThreadData->thread.loadAcquire() && currentData == targetData) {
+         // one exception to the rule: we allow moving objects with no thread affinity to the current thread
+         currentData = d->threadData;
+@@ -2620,7 +2620,7 @@ int QObject::receivers(const char *signal) const
+         if (!d->isSignalConnected(signal_index))
+             return receivers;
+ 
+-        if (d->declarativeData && QAbstractDeclarativeData::receivers) {
++        if (!d->isDeletingChildren && d->declarativeData && QAbstractDeclarativeData::receivers) {
+             receivers += QAbstractDeclarativeData::receivers(d->declarativeData, this,
+                                                              signal_index);
+         }
+diff --git a/qtbase/src/corelib/kernel/qobject_p.h b/qtbase/src/corelib/kernel/qobject_p.h
+index 0b827a52ca..13ffb88999 100644
+--- a/qtbase/src/corelib/kernel/qobject_p.h
++++ b/qtbase/src/corelib/kernel/qobject_p.h
+@@ -444,7 +444,7 @@ inline void QObjectPrivate::checkForIncompatibleLibraryVersion(int version) cons
+ 
+ inline bool QObjectPrivate::isDeclarativeSignalConnected(uint signal_index) const
+ {
+-    return declarativeData && QAbstractDeclarativeData::isSignalConnected
++    return !isDeletingChildren && declarativeData && QAbstractDeclarativeData::isSignalConnected
+             && QAbstractDeclarativeData::isSignalConnected(declarativeData, q_func(), signal_index);
+ }
+ 
+diff --git a/qtbase/src/corelib/kernel/qtranslator.cpp b/qtbase/src/corelib/kernel/qtranslator.cpp
+index 2812ffb7ea..bc0177c5ec 100644
+--- a/qtbase/src/corelib/kernel/qtranslator.cpp
++++ b/qtbase/src/corelib/kernel/qtranslator.cpp
+@@ -902,7 +902,7 @@ static QString getMessage(const uchar *m, const uchar *end, const char *context,
+             goto end;
+         case Tag_Translation: {
+             int len = read32(m);
+-            if (len % 1)
++            if (len & 1)
+                 return QString();
+             m += 4;
+             if (!numerus--) {
+diff --git a/qtbase/src/corelib/mimetypes/qmimedatabase.cpp b/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
+index 9de22cef33..ff868a3268 100644
+--- a/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
+@@ -389,20 +389,23 @@ QMimeType QMimeDatabasePrivate::mimeTypeForFileNameAndData(const QString &fileNa
+         // Disambiguate conflicting extensions (if magic matching found something)
+         if (candidateByData.isValid() && magicAccuracy > 0) {
+             const QString sniffedMime = candidateByData.name();
+-            // If the sniffedMime matches a glob match, use it
++            // If the sniffedMime matches a highest-weight glob match, use it
+             if (candidatesByName.m_matchingMimeTypes.contains(sniffedMime)) {
+                 *accuracyPtr = 100;
+                 return candidateByData;
+             }
+-            for (const QString &m : qAsConst(candidatesByName.m_matchingMimeTypes)) {
++            for (const QString &m : qAsConst(candidatesByName.m_allMatchingMimeTypes)) {
+                 if (inherits(m, sniffedMime)) {
+                     // We have magic + pattern pointing to this, so it's a pretty good match
+                     *accuracyPtr = 100;
+                     return mimeTypeForName(m);
+                 }
+             }
+-            *accuracyPtr = magicAccuracy;
+-            return candidateByData;
++            if (candidatesByName.m_allMatchingMimeTypes.isEmpty()) {
++                // No glob, use magic
++                *accuracyPtr = magicAccuracy;
++                return candidateByData;
++            }
+         }
+     }
+ 
+diff --git a/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp b/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
+index a81112d227..fa8f4c545d 100644
+--- a/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
+@@ -83,7 +83,10 @@ void QMimeGlobMatchResult::addMatch(const QString &mimeType, int weight, const Q
+     }
+     if (!m_matchingMimeTypes.contains(mimeType)) {
+         m_matchingMimeTypes.append(mimeType);
+-        m_allMatchingMimeTypes.append(mimeType);
++        if (replace)
++            m_allMatchingMimeTypes.prepend(mimeType); // highest-weight first
++        else
++            m_allMatchingMimeTypes.append(mimeType);
+         m_knownSuffixLength = knownSuffixLength;
+     }
+ }
+@@ -94,7 +97,7 @@ QMimeGlobPattern::PatternType QMimeGlobPattern::detectPatternType(const QString
+     if (!patternLength)
+         return OtherPattern;
+ 
+-    const bool starCount = pattern.count(QLatin1Char('*')) == 1;
++    const int starCount = pattern.count(QLatin1Char('*'));
+     const bool hasSquareBracket = pattern.indexOf(QLatin1Char('[')) != -1;
+     const bool hasQuestionMark = pattern.indexOf(QLatin1Char('?')) != -1;
+ 
+@@ -106,10 +109,10 @@ QMimeGlobPattern::PatternType QMimeGlobPattern::detectPatternType(const QString
+             // Patterns like "README*" (well this is currently the only one like that...)
+             if (pattern.at(patternLength - 1) == QLatin1Char('*'))
+                 return PrefixPattern;
+-        }
+-        // Names without any wildcards like "README"
+-        if (starCount == 0)
++        } else if (starCount == 0) {
++            // Names without any wildcards like "README"
+             return LiteralPattern;
++        }
+     }
+ 
+     if (pattern == QLatin1String("[0-9][0-9][0-9].vdr"))
+diff --git a/qtbase/src/corelib/mimetypes/qmimeprovider.cpp b/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
+index 258dddf8cb..4642d0f2d0 100644
+--- a/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
+@@ -244,15 +244,18 @@ void QMimeBinaryProvider::addFileNameMatches(const QString &fileName, QMimeGlobM
+     const QString lowerFileName = fileName.toLower();
+     // Check literals (e.g. "Makefile")
+     matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosLiteralListOffset), fileName);
+-    // Check complex globs (e.g. "callgrind.out[0-9]*")
+-    matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosGlobListOffset), fileName);
+     // Check the very common *.txt cases with the suffix tree
+-    const int reverseSuffixTreeOffset = m_cacheFile->getUint32(PosReverseSuffixTreeOffset);
+-    const int numRoots = m_cacheFile->getUint32(reverseSuffixTreeOffset);
+-    const int firstRootOffset = m_cacheFile->getUint32(reverseSuffixTreeOffset + 4);
+-    matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, lowerFileName, lowerFileName.length() - 1, false);
++    if (result.m_matchingMimeTypes.isEmpty()) {
++        const int reverseSuffixTreeOffset = m_cacheFile->getUint32(PosReverseSuffixTreeOffset);
++        const int numRoots = m_cacheFile->getUint32(reverseSuffixTreeOffset);
++        const int firstRootOffset = m_cacheFile->getUint32(reverseSuffixTreeOffset + 4);
++        matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, lowerFileName, lowerFileName.length() - 1, false);
++        if (result.m_matchingMimeTypes.isEmpty())
++            matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, fileName, fileName.length() - 1, true);
++    }
++    // Check complex globs (e.g. "callgrind.out[0-9]*" or "README*")
+     if (result.m_matchingMimeTypes.isEmpty())
+-        matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, fileName, fileName.length() - 1, true);
++        matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosGlobListOffset), fileName);
+ }
+ 
+ void QMimeBinaryProvider::matchGlobList(QMimeGlobMatchResult &result, CacheFile *cacheFile, int off, const QString &fileName)
+diff --git a/qtbase/src/corelib/serialization/qjsonparser.cpp b/qtbase/src/corelib/serialization/qjsonparser.cpp
+index 17e6f111ab..2e40b6c8fb 100644
+--- a/qtbase/src/corelib/serialization/qjsonparser.cpp
++++ b/qtbase/src/corelib/serialization/qjsonparser.cpp
+@@ -379,10 +379,30 @@ error:
+     return QCborValue();
+ }
+ 
++// We need to retain the _last_ value for any duplicate keys and we need to deref containers.
++// Therefore the manual implementation of std::unique().
++template<typename Iterator, typename Compare, typename Assign>
++static Iterator customAssigningUniqueLast(Iterator first, Iterator last,
++                                          Compare compare, Assign assign)
++{
++    first = std::adjacent_find(first, last, compare);
++    if (first == last)
++        return last;
++
++    Iterator result = first;
++    while (++first != last) {
++        if (!compare(*result, *first))
++            ++result;
++        if (result != first)
++            assign(*result, *first);
++    }
++
++    return ++result;
++}
++
+ static void sortContainer(QCborContainerPrivate *container)
+ {
+     using Forward = QJsonPrivate::KeyIterator;
+-    using Reverse = std::reverse_iterator<Forward>;
+     using Value = Forward::value_type;
+ 
+     auto compare = [container](const Value &a, const Value &b)
+@@ -420,17 +440,31 @@ static void sortContainer(QCborContainerPrivate *container)
+         }
+     };
+ 
+-    std::sort(Forward(container->elements.begin()), Forward(container->elements.end()),
+-              [&compare](const Value &a, const Value &b) { return compare(a, b) < 0; });
++    // The elements' containers are owned by the outer container, not by the elements themselves.
++    auto move = [](Forward::reference target, Forward::reference source)
++    {
++        QtCbor::Element &targetValue = target.value();
++
++        // If the target has a container, deref it before overwriting, so that we don't leak.
++        if (targetValue.flags & QtCbor::Element::IsContainer)
++            targetValue.container->deref();
++
++        // Do not move, so that we can clear the value afterwards.
++        target = source;
++
++        // Clear the source value, so that we don't store the same container twice.
++        source.value() = QtCbor::Element();
++    };
++
++    std::stable_sort(
++                Forward(container->elements.begin()), Forward(container->elements.end()),
++                [&compare](const Value &a, const Value &b) { return compare(a, b) < 0; });
+ 
+-    // We need to retain the _last_ value for any duplicate keys. Therefore the reverse dance here.
+-    auto it = std::unique(Reverse(container->elements.end()), Reverse(container->elements.begin()),
+-                          [&compare](const Value &a, const Value &b) {
+-        return compare(a, b) == 0;
+-    }).base().elementsIterator();
++    Forward result = customAssigningUniqueLast(
++                Forward(container->elements.begin()),  Forward(container->elements.end()),
++                [&compare](const Value &a, const Value &b) { return compare(a, b) == 0; }, move);
+ 
+-    // The erase from beginning is expensive but hopefully rare.
+-    container->elements.erase(container->elements.begin(), it);
++    container->elements.erase(result.elementsIterator(), container->elements.end());
+ }
+ 
+ 
+diff --git a/qtbase/src/corelib/serialization/qxmlstream.cpp b/qtbase/src/corelib/serialization/qxmlstream.cpp
+index b2f846544d..7cd457ba3a 100644
+--- a/qtbase/src/corelib/serialization/qxmlstream.cpp
++++ b/qtbase/src/corelib/serialization/qxmlstream.cpp
+@@ -980,7 +980,7 @@ inline uint QXmlStreamReaderPrivate::peekChar()
+ bool QXmlStreamReaderPrivate::scanUntil(const char *str, short tokenToInject)
+ {
+     int pos = textBuffer.size();
+-    int oldLineNumber = lineNumber;
++    const auto oldLineNumber = lineNumber;
+ 
+     uint c;
+     while ((c = getChar()) != StreamEOF) {
+diff --git a/qtbase/src/corelib/text/qstring.cpp b/qtbase/src/corelib/text/qstring.cpp
+index 3e88ab4859..8deeae47bb 100644
+--- a/qtbase/src/corelib/text/qstring.cpp
++++ b/qtbase/src/corelib/text/qstring.cpp
+@@ -12312,7 +12312,7 @@ static qsizetype qLastIndexOf(Haystack haystack0, qsizetype from,
+     const auto needle = needle0.data();
+     const auto *end = haystack;
+     haystack += from;
+-    const std::size_t sl_minus_1 = sl - 1;
++    const std::size_t sl_minus_1 = sl ? sl - 1 : 0;
+     const auto *n = needle + sl_minus_1;
+     const auto *h = haystack + sl_minus_1;
+     std::size_t hashNeedle = 0, hashHaystack = 0;
+diff --git a/qtbase/src/corelib/text/qstringiterator_p.h b/qtbase/src/corelib/text/qstringiterator_p.h
+index 219589b6e4..1d0c66cc78 100644
+--- a/qtbase/src/corelib/text/qstringiterator_p.h
++++ b/qtbase/src/corelib/text/qstringiterator_p.h
+@@ -61,6 +61,8 @@ class QStringIterator
+ {
+     QString::const_iterator i, pos, e;
+     Q_STATIC_ASSERT((std::is_same<QString::const_iterator, const QChar *>::value));
++    static bool less(const QChar *lhs, const QChar *rhs) noexcept
++    { return std::less<QString::const_iterator>{}(lhs, rhs); }
+ public:
+     explicit QStringIterator(QStringView string, qsizetype idx = 0)
+         : i(string.begin()),
+@@ -95,7 +97,8 @@ public:
+ 
+     inline void setPosition(QString::const_iterator position)
+     {
+-        Q_ASSERT_X(i <= position && position <= e, Q_FUNC_INFO, "position out of bounds");
++        Q_ASSERT_X(!less(position, i) && !less(e, position),
++                   Q_FUNC_INFO, "position out of bounds");
+         pos = position;
+     }
+ 
+@@ -103,7 +106,7 @@ public:
+ 
+     inline bool hasNext() const
+     {
+-        return pos < e;
++        return less(pos, e);
+     }
+ 
+     inline void advance()
+@@ -120,16 +123,20 @@ public:
+     {
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+-        if (Q_UNLIKELY((pos++)->isHighSurrogate()))
++        if (Q_UNLIKELY((pos++)->isHighSurrogate())) {
++            Q_ASSERT(hasNext() && pos->isLowSurrogate());
+             ++pos;
++        }
+     }
+ 
+     inline uint peekNextUnchecked() const
+     {
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+-        if (Q_UNLIKELY(pos->isHighSurrogate()))
++        if (Q_UNLIKELY(pos->isHighSurrogate())) {
++            Q_ASSERT(less(pos + 1, e) && pos[1].isLowSurrogate());
+             return QChar::surrogateToUcs4(pos[0], pos[1]);
++        }
+ 
+         return pos->unicode();
+     }
+@@ -155,8 +162,10 @@ public:
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+         const QChar cur = *pos++;
+-        if (Q_UNLIKELY(cur.isHighSurrogate()))
++        if (Q_UNLIKELY(cur.isHighSurrogate())) {
++            Q_ASSERT(hasNext() && pos->isLowSurrogate());
+             return QChar::surrogateToUcs4(cur, *pos++);
++        }
+         return cur.unicode();
+     }
+ 
+@@ -166,7 +175,7 @@ public:
+ 
+         const QChar uc = *pos++;
+         if (Q_UNLIKELY(uc.isSurrogate())) {
+-            if (Q_LIKELY(uc.isHighSurrogate() && pos < e && pos->isLowSurrogate()))
++            if (Q_LIKELY(uc.isHighSurrogate() && hasNext() && pos->isLowSurrogate()))
+                 return QChar::surrogateToUcs4(uc, *pos++);
+             return invalidAs;
+         }
+@@ -178,7 +187,7 @@ public:
+ 
+     inline bool hasPrevious() const
+     {
+-        return pos > i;
++        return less(i, pos);
+     }
+ 
+     inline void recede()
+@@ -196,16 +205,20 @@ public:
+     {
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+-        if (Q_UNLIKELY((--pos)->isLowSurrogate()))
++        if (Q_UNLIKELY((--pos)->isLowSurrogate())) {
++            Q_ASSERT(hasPrevious() && pos[-1].isHighSurrogate());
+             --pos;
++        }
+     }
+ 
+     inline uint peekPreviousUnchecked() const
+     {
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+-        if (Q_UNLIKELY(pos[-1].isLowSurrogate()))
++        if (Q_UNLIKELY(pos[-1].isLowSurrogate())) {
++            Q_ASSERT(less(i + 1, pos) && pos[-2].isHighSurrogate());
+             return QChar::surrogateToUcs4(pos[-2], pos[-1]);
++        }
+         return pos[-1].unicode();
+     }
+ 
+@@ -230,8 +243,10 @@ public:
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+         const QChar cur = *--pos;
+-        if (Q_UNLIKELY(cur.isLowSurrogate()))
++        if (Q_UNLIKELY(cur.isLowSurrogate())) {
++            Q_ASSERT(hasPrevious() && pos[-1].isHighSurrogate());
+             return QChar::surrogateToUcs4(*--pos, cur);
++        }
+         return cur.unicode();
+     }
+ 
+@@ -241,7 +256,7 @@ public:
+ 
+         const QChar uc = *--pos;
+         if (Q_UNLIKELY(uc.isSurrogate())) {
+-            if (Q_LIKELY(uc.isLowSurrogate() && pos > i && pos[-1].isHighSurrogate()))
++            if (Q_LIKELY(uc.isLowSurrogate() && hasPrevious() && pos[-1].isHighSurrogate()))
+                 return QChar::surrogateToUcs4(*--pos, uc);
+             return invalidAs;
+         }
+diff --git a/qtbase/src/corelib/thread/qfutex_p.h b/qtbase/src/corelib/thread/qfutex_p.h
+index f287b752d7..e294537787 100644
+--- a/qtbase/src/corelib/thread/qfutex_p.h
++++ b/qtbase/src/corelib/thread/qfutex_p.h
+@@ -52,6 +52,7 @@
+ //
+ 
+ #include <qglobal.h>
++#include <QtCore/qtsan_impl.h>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -106,16 +107,13 @@ namespace QtLinuxFutex {
+     inline int _q_futex(int *addr, int op, int val, quintptr val2 = 0,
+                         int *addr2 = nullptr, int val3 = 0) noexcept
+     {
+-        // A futex call ensures total ordering on the futex words
+-        // (in either success or failure of the call). Instruct TSAN accordingly,
+-        // as TSAN does not understand the futex(2) syscall.
+-        _q_tsan_release(addr, addr2);
++        QtTsan::futexRelease(addr, addr2);
+ 
+         // we use __NR_futex because some libcs (like Android's bionic) don't
+         // provide SYS_futex etc.
+         int result = syscall(__NR_futex, addr, op | FUTEX_PRIVATE_FLAG, val, val2, addr2, val3);
+ 
+-        _q_tsan_acquire(addr, addr2);
++        QtTsan::futexAcquire(addr, addr2);
+ 
+         return result;
+     }
+diff --git a/qtbase/src/corelib/thread/qmutex.cpp b/qtbase/src/corelib/thread/qmutex.cpp
+index 310d1cb14f..7097122d8e 100644
+--- a/qtbase/src/corelib/thread/qmutex.cpp
++++ b/qtbase/src/corelib/thread/qmutex.cpp
+@@ -152,6 +152,7 @@ public:
+ 
+ /*!
+     \enum QMutex::RecursionMode
++    \obsolete Use QRecursiveMutex to create a recursive mutex.
+ 
+     \value Recursive  In this mode, a thread can lock the same mutex
+                       multiple times and the mutex won't be unlocked
+@@ -173,6 +174,7 @@ public:
+ 
+ /*!
+     Constructs a new mutex. The mutex is created in an unlocked state.
++    \obsolete Use QRecursiveMutex to create a recursive mutex.
+ 
+     If \a mode is QMutex::Recursive, a thread can lock the same mutex
+     multiple times and the mutex won't be unlocked until a
+@@ -197,7 +199,7 @@ QMutex::QMutex(RecursionMode mode)
+ QMutex::~QMutex()
+ {
+     QMutexData *d = d_ptr.loadRelaxed();
+-    if (isRecursive()) {
++    if (QBasicMutex::isRecursive()) {
+         delete static_cast<QRecursiveMutexPrivate *>(d);
+     } else if (d) {
+ #ifndef QT_LINUX_FUTEX
+diff --git a/qtbase/src/corelib/thread/qmutex.h b/qtbase/src/corelib/thread/qmutex.h
+index 73c9e00663..1bae573a03 100644
+--- a/qtbase/src/corelib/thread/qmutex.h
++++ b/qtbase/src/corelib/thread/qmutex.h
+@@ -42,6 +42,7 @@
+ 
+ #include <QtCore/qglobal.h>
+ #include <QtCore/qatomic.h>
++#include <QtCore/qtsan_impl.h>
+ #include <new>
+ 
+ #if __has_include(<chrono>)
+@@ -77,19 +78,37 @@ public:
+ 
+     // BasicLockable concept
+     inline void lock() QT_MUTEX_LOCK_NOEXCEPT {
++        QtTsan::mutexPreLock(this, 0u);
++
+         if (!fastTryLock())
+             lockInternal();
++
++        QtTsan::mutexPostLock(this, 0u, 0);
+     }
+ 
+     // BasicLockable concept
+     inline void unlock() noexcept {
+         Q_ASSERT(d_ptr.loadRelaxed()); //mutex must be locked
++
++        QtTsan::mutexPreUnlock(this, 0u);
++
+         if (!fastTryUnlock())
+             unlockInternal();
++
++        QtTsan::mutexPostUnlock(this, 0u);
+     }
+ 
+     bool tryLock() noexcept {
+-        return fastTryLock();
++        unsigned tsanFlags = QtTsan::TryLock;
++        QtTsan::mutexPreLock(this, tsanFlags);
++
++        const bool success = fastTryLock();
++
++        if (!success)
++            tsanFlags |= QtTsan::TryLockFailed;
++        QtTsan::mutexPostLock(this, tsanFlags, 0);
++
++        return success;
+     }
+ 
+     // Lockable concept
+@@ -134,8 +153,16 @@ public:
+ #else
+     QMutex() { d_ptr.storeRelaxed(nullptr); }
+ #endif
++#if QT_DEPRECATED_SINCE(5,15)
+     enum RecursionMode { NonRecursive, Recursive };
++    QT_DEPRECATED_VERSION_X(5, 15, "Use QRecursiveMutex instead of a recursive QMutex")
+     explicit QMutex(RecursionMode mode);
++
++    QT_DEPRECATED_VERSION_X(5, 15, "Use QRecursiveMutex instead of a recursive QMutex")
++    bool isRecursive() const noexcept
++    { return QBasicMutex::isRecursive(); }
++#endif
++
+     ~QMutex();
+ 
+     // BasicLockable concept
+@@ -166,9 +193,6 @@ public:
+     }
+ #endif
+ 
+-    bool isRecursive() const noexcept
+-    { return QBasicMutex::isRecursive(); }
+-
+ private:
+     Q_DISABLE_COPY(QMutex)
+     friend class QMutexLocker;
+diff --git a/qtbase/src/corelib/thread/qreadwritelock.cpp b/qtbase/src/corelib/thread/qreadwritelock.cpp
+index 8c28507d5a..9dd8503116 100644
+--- a/qtbase/src/corelib/thread/qreadwritelock.cpp
++++ b/qtbase/src/corelib/thread/qreadwritelock.cpp
+@@ -155,7 +155,7 @@ QReadWriteLock::QReadWriteLock(RecursionMode recursionMode)
+ */
+ QReadWriteLock::~QReadWriteLock()
+ {
+-    auto d = d_ptr.loadRelaxed();
++    auto d = d_ptr.loadAcquire();
+     if (isUncontendedLocked(d)) {
+         qWarning("QReadWriteLock: destroying locked QReadWriteLock");
+         return;
+@@ -445,7 +445,7 @@ void QReadWriteLock::unlock()
+ /*! \internal  Helper for QWaitCondition::wait */
+ QReadWriteLock::StateForWaitCondition QReadWriteLock::stateForWaitCondition() const
+ {
+-    QReadWriteLockPrivate *d = d_ptr.loadRelaxed();
++    QReadWriteLockPrivate *d = d_ptr.loadAcquire();
+     switch (quintptr(d) & StateMask) {
+     case StateLockedForRead: return LockedForRead;
+     case StateLockedForWrite: return LockedForWrite;
+@@ -453,6 +453,7 @@ QReadWriteLock::StateForWaitCondition QReadWriteLock::stateForWaitCondition() co
+ 
+     if (!d)
+         return Unlocked;
++    const auto lock = qt_scoped_lock(d->mutex);
+     if (d->writerCount > 1)
+         return RecursivelyLocked;
+     else if (d->writerCount == 1)
+diff --git a/qtbase/src/corelib/thread/qsemaphore.cpp b/qtbase/src/corelib/thread/qsemaphore.cpp
+index 1d01fc1b28..3ecdee3747 100644
+--- a/qtbase/src/corelib/thread/qsemaphore.cpp
++++ b/qtbase/src/corelib/thread/qsemaphore.cpp
+@@ -354,7 +354,12 @@ void QSemaphore::release(int n)
+         quintptr nn = unsigned(n);
+         if (futexHasWaiterCount)
+             nn |= quint64(nn) << 32;    // token count replicated in high word
+-        quintptr prevValue = u.fetchAndAddRelease(nn);
++        quintptr prevValue = u.loadRelaxed();
++        quintptr newValue;
++        do { // loop just to ensure the operations are done atomically
++            newValue = prevValue + nn;
++            newValue &= (futexNeedsWakeAllBit - 1);
++        } while (!u.testAndSetRelease(prevValue, newValue, prevValue));
+         if (futexNeedsWake(prevValue)) {
+ #ifdef FUTEX_OP
+             if (futexHasWaiterCount) {
+@@ -376,7 +381,6 @@ void QSemaphore::release(int n)
+                 quint32 oparg = 0;
+                 quint32 cmp = FUTEX_OP_CMP_NE;
+                 quint32 cmparg = 0;
+-                u.fetchAndAndRelease(futexNeedsWakeAllBit - 1);
+                 futexWakeOp(*futexLow32(&u), n, INT_MAX, *futexHigh32(&u), FUTEX_OP(op, oparg, cmp, cmparg));
+                 return;
+             }
+@@ -388,7 +392,6 @@ 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(futexNeedsWakeAllBit - 1);
+             if (futexHasWaiterCount) {
+                 futexWakeAll(*futexLow32(&u));
+                 futexWakeAll(*futexHigh32(&u));
+diff --git a/qtbase/src/corelib/thread/qthread_p.h b/qtbase/src/corelib/thread/qthread_p.h
+index b2d1628e6e..f32f6f0460 100644
+--- a/qtbase/src/corelib/thread/qthread_p.h
++++ b/qtbase/src/corelib/thread/qthread_p.h
+@@ -174,7 +174,7 @@ public:
+     int returnCode;
+ 
+     uint stackSize;
+-    QThread::Priority priority;
++    std::underlying_type<QThread::Priority>::type priority;
+ 
+     static QThread *threadForId(int id);
+ 
+@@ -213,6 +213,13 @@ public:
+             QCoreApplication::instance()->postEvent(q_ptr, new QEvent(QEvent::Quit));
+         }
+     }
++
++#ifndef Q_OS_INTEGRITY
++private:
++    // Used in QThread(Private)::start to avoid racy access to QObject::objectName,
++    // unset afterwards. On INTEGRITY we set the thread name before starting it.
++    QString objectName;
++#endif
+ };
+ 
+ #else // QT_CONFIG(thread)
+diff --git a/qtbase/src/corelib/thread/qthread_unix.cpp b/qtbase/src/corelib/thread/qthread_unix.cpp
+index 56a8e0a038..610117a640 100644
+--- a/qtbase/src/corelib/thread/qthread_unix.cpp
++++ b/qtbase/src/corelib/thread/qthread_unix.cpp
+@@ -169,8 +169,7 @@ static void set_thread_data(QThreadData *data)
+ 
+ static void clear_thread_data()
+ {
+-    currentThreadData = nullptr;
+-    pthread_setspecific(current_thread_data_key, nullptr);
++    set_thread_data(nullptr);
+ }
+ 
+ template <typename T>
+@@ -296,7 +295,7 @@ void *QThreadPrivate::start(void *arg)
+             QMutexLocker locker(&thr->d_func()->mutex);
+ 
+             // do we need to reset the thread priority?
+-            if (int(thr->d_func()->priority) & ThreadPriorityResetFlag) {
++            if (thr->d_func()->priority & ThreadPriorityResetFlag) {
+                 thr->d_func()->setPriority(QThread::Priority(thr->d_func()->priority & ~ThreadPriorityResetFlag));
+             }
+ 
+@@ -316,10 +315,10 @@ void *QThreadPrivate::start(void *arg)
+             // Sets the name of the current thread. We can only do this
+             // when the thread is starting, as we don't have a cross
+             // platform way of setting the name of an arbitrary thread.
+-            if (Q_LIKELY(thr->objectName().isEmpty()))
++            if (Q_LIKELY(thr->d_func()->objectName.isEmpty()))
+                 setCurrentThreadName(thr->metaObject()->className());
+             else
+-                setCurrentThreadName(thr->objectName().toLocal8Bit());
++                setCurrentThreadName(std::exchange(thr->d_func()->objectName, {}).toLocal8Bit());
+         }
+ #endif
+ 
+@@ -671,7 +670,7 @@ void QThread::start(Priority priority)
+                 // could not set scheduling hints, fallback to inheriting them
+                 // we'll try again from inside the thread
+                 pthread_attr_setinheritsched(&attr, PTHREAD_INHERIT_SCHED);
+-                d->priority = Priority(priority | ThreadPriorityResetFlag);
++                d->priority = static_cast<std::underlying_type<QThread::Priority>::type>(priority) | ThreadPriorityResetFlag;
+             }
+             break;
+         }
+@@ -702,7 +701,10 @@ void QThread::start(Priority priority)
+         pthread_attr_setthreadname(&attr, metaObject()->className());
+     else
+         pthread_attr_setthreadname(&attr, objectName().toLocal8Bit());
++#else
++    d->objectName = objectName();
+ #endif
++
+     pthread_t threadId;
+     int code = pthread_create(&threadId, &attr, QThreadPrivate::start, this);
+     if (code == EPERM) {
+diff --git a/qtbase/src/corelib/thread/qthread_win.cpp b/qtbase/src/corelib/thread/qthread_win.cpp
+index bc70e3178a..4e76972498 100644
+--- a/qtbase/src/corelib/thread/qthread_win.cpp
++++ b/qtbase/src/corelib/thread/qthread_win.cpp
+@@ -394,10 +394,9 @@ unsigned int __stdcall QT_ENSURE_STACK_ALIGNED_FOR_SSE QThreadPrivate::start(voi
+ 
+ #if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) && !defined(Q_OS_WINRT)
+     // sets the name of the current thread.
+-    QByteArray objectName = thr->objectName().toLocal8Bit();
+-    qt_set_thread_name(HANDLE(-1),
+-                       objectName.isEmpty() ?
+-                       thr->metaObject()->className() : objectName.constData());
++    qt_set_thread_name(HANDLE(-1), thr->d_func()->objectName.isEmpty()
++                        ? thr->metaObject()->className()
++                        : std::exchange(thr->d_func()->objectName, {}).toLocal8Bit().constData());
+ #endif
+ 
+     emit thr->started(QThread::QPrivateSignal());
+@@ -503,6 +502,7 @@ void QThread::start(Priority priority)
+     if (d->running)
+         return;
+ 
++    d->objectName = objectName();
+     d->running = true;
+     d->finished = false;
+     d->exited = false;
+@@ -548,7 +548,7 @@ void QThread::start(Priority priority)
+ 
+     int prio;
+     d->priority = priority;
+-    switch (d->priority) {
++    switch (priority) {
+     case IdlePriority:
+         prio = THREAD_PRIORITY_IDLE;
+         break;
+@@ -686,7 +686,7 @@ void QThreadPrivate::setPriority(QThread::Priority threadPriority)
+ 
+     int prio;
+     priority = threadPriority;
+-    switch (priority) {
++    switch (threadPriority) {
+     case QThread::IdlePriority:
+         prio = THREAD_PRIORITY_IDLE;
+         break;
+diff --git a/qtbase/src/corelib/thread/qtsan_impl.h b/qtbase/src/corelib/thread/qtsan_impl.h
+new file mode 100644
+index 0000000000..580a738b91
+--- /dev/null
++++ b/qtbase/src/corelib/thread/qtsan_impl.h
+@@ -0,0 +1,115 @@
++/****************************************************************************
++**
++** Copyright (C) 2017 Intel Corporation.
++** Copyright (C) 2022 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
++** 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 QTSAN_IMPL_H
++#define QTSAN_IMPL_H
++
++#include <QtCore/qglobal.h>
++
++#if (__has_feature(thread_sanitizer) || defined(__SANITIZE_THREAD__)) && __has_include(<sanitizer/tsan_interface.h>)
++#  define QT_BUILDING_UNDER_TSAN
++#  include <sanitizer/tsan_interface.h>
++#endif
++
++QT_BEGIN_NAMESPACE
++
++namespace QtTsan {
++#ifdef QT_BUILDING_UNDER_TSAN
++inline void futexAcquire(void *addr, void *addr2 = nullptr)
++{
++    // A futex call ensures total ordering on the futex words
++    // (in either success or failure of the call). Instruct TSAN accordingly,
++    // as TSAN does not understand the futex(2) syscall (or equivalent).
++    ::__tsan_acquire(addr);
++    if (addr2)
++        ::__tsan_acquire(addr2);
++}
++
++inline void futexRelease(void *addr, void *addr2 = nullptr)
++{
++    if (addr2)
++        ::__tsan_release(addr2);
++    ::__tsan_release(addr);
++}
++
++inline void mutexPreLock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_pre_lock(addr, flags);
++}
++
++inline void mutexPostLock(void *addr, unsigned flags, int recursion)
++{
++    ::__tsan_mutex_post_lock(addr, flags, recursion);
++}
++
++inline void mutexPreUnlock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_pre_unlock(addr, flags);
++}
++
++inline void mutexPostUnlock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_post_unlock(addr, flags);
++}
++
++enum : unsigned {
++    MutexWriteReentrant = ::__tsan_mutex_write_reentrant,
++    TryLock = ::__tsan_mutex_try_lock,
++    TryLockFailed = ::__tsan_mutex_try_lock_failed,
++};
++#else
++inline void futexAcquire(void *, void * = nullptr) {}
++inline void futexRelease(void *, void * = nullptr) {}
++
++enum : unsigned {
++    MutexWriteReentrant,
++    TryLock,
++    TryLockFailed,
++};
++inline void mutexPreLock(void *, unsigned) {}
++inline void mutexPostLock(void *, unsigned, int) {}
++inline void mutexPreUnlock(void *, unsigned) {}
++inline void mutexPostUnlock(void *, unsigned) {}
++#endif // QT_BUILDING_UNDER_TSAN
++} // namespace QtTsan
++
++QT_END_NAMESPACE
++
++#endif // QTSAN_IMPL_H
+diff --git a/qtbase/src/corelib/thread/qwaitcondition_unix.cpp b/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
+index 88b058f410..0f1da4dc9b 100644
+--- a/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
++++ b/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
+@@ -213,7 +213,7 @@ bool QWaitCondition::wait(QMutex *mutex, QDeadlineTimer deadline)
+ {
+     if (! mutex)
+         return false;
+-    if (mutex->isRecursive()) {
++    if (static_cast<QBasicMutex *>(mutex)->isRecursive()) {
+         qWarning("QWaitCondition: cannot wait on recursive mutexes");
+         return false;
+     }
+diff --git a/qtbase/src/corelib/time/qdatetime.cpp b/qtbase/src/corelib/time/qdatetime.cpp
+index ec12569e3f..2c0b098079 100644
+--- a/qtbase/src/corelib/time/qdatetime.cpp
++++ b/qtbase/src/corelib/time/qdatetime.cpp
+@@ -43,6 +43,7 @@
+ #if QT_CONFIG(datetimeparser)
+ #include "private/qdatetimeparser_p.h"
+ #endif
++#include <private/qnumeric_p.h>
+ 
+ #include "qdatastream.h"
+ #include "qset.h"
+@@ -1429,9 +1430,11 @@ QDate QDate::addDays(qint64 ndays) const
+     if (isNull())
+         return QDate();
+ 
+-    // Due to limits on minJd() and maxJd() we know that any overflow
+-    // will be invalid and caught by fromJulianDay().
+-    return fromJulianDay(jd + ndays);
++    qint64 r;
++    if (Q_UNLIKELY(add_overflow(jd, ndays, &r)))
++        return QDate();
++    else
++        return fromJulianDay(r);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/corelib/time/qtimezone.cpp b/qtbase/src/corelib/time/qtimezone.cpp
+index 0309e43e52..3d451696a1 100644
+--- a/qtbase/src/corelib/time/qtimezone.cpp
++++ b/qtbase/src/corelib/time/qtimezone.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2013 John Layt <jlayt@kde.org>
++** Copyright (C) 2020 John Layt <jlayt@kde.org>
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtCore module of the Qt Toolkit.
+@@ -975,9 +975,15 @@ QList<QByteArray> QTimeZone::windowsIdToIanaIds(const QByteArray &windowsId,
+ }
+ 
+ #ifndef QT_NO_DATASTREAM
++// Invalid, as an IANA ID: too long, starts with - and has other invalid characters in it
++static inline QString invalidId() { return QStringLiteral("-No Time Zone Specified!"); }
++
+ QDataStream &operator<<(QDataStream &ds, const QTimeZone &tz)
+ {
+-    tz.d->serialize(ds);
++    if (tz.isValid())
++        tz.d->serialize(ds);
++    else
++        ds << invalidId();
+     return ds;
+ }
+ 
+@@ -985,7 +991,9 @@ QDataStream &operator>>(QDataStream &ds, QTimeZone &tz)
+ {
+     QString ianaId;
+     ds >> ianaId;
+-    if (ianaId == QLatin1String("OffsetFromUtc")) {
++    if (ianaId == invalidId()) {
++        tz = QTimeZone();
++    } else if (ianaId == QLatin1String("OffsetFromUtc")) {
+         int utcOffset;
+         QString name;
+         QString abbreviation;
+diff --git a/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp b/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
+index b1611d7ddb..a7a6a72ccf 100644
+--- a/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
++++ b/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
+@@ -42,6 +42,7 @@
+ #include "qtimezone.h"
+ #include "qtimezoneprivate_p.h"
+ #include "private/qlocale_tools_p.h"
++#include "private/qlocking_p.h"
+ 
+ #include <QtCore/QDataStream>
+ #include <QtCore/QDateTime>
+@@ -62,6 +63,10 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++#if QT_CONFIG(icu)
++static QBasicMutex s_icu_mutex;
++#endif
++
+ /*
+     Private
+ 
+@@ -670,6 +675,9 @@ QTzTimeZonePrivate::~QTzTimeZonePrivate()
+ 
+ QTzTimeZonePrivate *QTzTimeZonePrivate::clone() const
+ {
++#if QT_CONFIG(icu)
++    const auto lock = qt_scoped_lock(s_icu_mutex);
++#endif
+     return new QTzTimeZonePrivate(*this);
+ }
+ 
+@@ -913,12 +921,14 @@ QString QTzTimeZonePrivate::displayName(qint64 atMSecsSinceEpoch,
+                                         const QLocale &locale) const
+ {
+ #if QT_CONFIG(icu)
++    auto lock = qt_unique_lock(s_icu_mutex);
+     if (!m_icu)
+         m_icu = new QIcuTimeZonePrivate(m_id);
+     // TODO small risk may not match if tran times differ due to outdated files
+     // TODO Some valid TZ names are not valid ICU names, use translation table?
+     if (m_icu->isValid())
+         return m_icu->displayName(atMSecsSinceEpoch, nameType, locale);
++    lock.unlock();
+ #else
+     Q_UNUSED(nameType)
+     Q_UNUSED(locale)
+@@ -932,12 +942,14 @@ QString QTzTimeZonePrivate::displayName(QTimeZone::TimeType timeType,
+                                         const QLocale &locale) const
+ {
+ #if QT_CONFIG(icu)
++    auto lock = qt_unique_lock(s_icu_mutex);
+     if (!m_icu)
+         m_icu = new QIcuTimeZonePrivate(m_id);
+     // TODO small risk may not match if tran times differ due to outdated files
+     // TODO Some valid TZ names are not valid ICU names, use translation table?
+     if (m_icu->isValid())
+         return m_icu->displayName(timeType, nameType, locale);
++    lock.unlock();
+ #else
+     Q_UNUSED(timeType)
+     Q_UNUSED(nameType)
+diff --git a/qtbase/src/corelib/tools/qarraydata.h b/qtbase/src/corelib/tools/qarraydata.h
+index dcd95924c1..d01739e7e6 100644
+--- a/qtbase/src/corelib/tools/qarraydata.h
++++ b/qtbase/src/corelib/tools/qarraydata.h
+@@ -42,6 +42,7 @@
+ 
+ #include <QtCore/qrefcount.h>
+ #include <string.h>
++#include <cstdint>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -58,14 +59,14 @@ struct Q_CORE_EXPORT QArrayData
+     {
+         Q_ASSERT(size == 0
+                 || offset < 0 || size_t(offset) >= sizeof(QArrayData));
+-        return reinterpret_cast<char *>(this) + offset;
++        return reinterpret_cast<void *> (reinterpret_cast<uintptr_t>(this) + offset);
+     }
+ 
+     const void *data() const
+     {
+         Q_ASSERT(size == 0
+                 || offset < 0 || size_t(offset) >= sizeof(QArrayData));
+-        return reinterpret_cast<const char *>(this) + offset;
++        return reinterpret_cast<void *> (reinterpret_cast<uintptr_t>(this) + offset);
+     }
+ 
+     // This refers to array data mutability, not "header data" represented by
+diff --git a/qtbase/src/corelib/tools/qfreelist_p.h b/qtbase/src/corelib/tools/qfreelist_p.h
+index 5ba23b344b..9974102136 100644
+--- a/qtbase/src/corelib/tools/qfreelist_p.h
++++ b/qtbase/src/corelib/tools/qfreelist_p.h
+@@ -161,7 +161,7 @@ class QFreeList
+                 return i;
+             x -= size;
+         }
+-        Q_ASSERT(false);
++        Q_UNREACHABLE();
+         return -1;
+     }
+ 
+diff --git a/qtbase/src/corelib/tools/qversionnumber.h b/qtbase/src/corelib/tools/qversionnumber.h
+index d43b86ba51..2843f2b043 100644
+--- a/qtbase/src/corelib/tools/qversionnumber.h
++++ b/qtbase/src/corelib/tools/qversionnumber.h
+@@ -273,10 +273,10 @@ public:
+ 
+     Q_REQUIRED_RESULT Q_CORE_EXPORT QString toString() const;
+ #if QT_STRINGVIEW_LEVEL < 2
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(const QString &string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(const QString &string, int *suffixIndex = nullptr);
+ #endif
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QLatin1String string, int *suffixIndex = nullptr);
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QStringView string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(QLatin1String string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(QStringView string, int *suffixIndex = nullptr);
+ 
+ private:
+ #ifndef QT_NO_DATASTREAM
+diff --git a/qtbase/src/dbus/qdbusintegrator.cpp b/qtbase/src/dbus/qdbusintegrator.cpp
+index 5b66ce971b..28a3b0ffea 100644
+--- a/qtbase/src/dbus/qdbusintegrator.cpp
++++ b/qtbase/src/dbus/qdbusintegrator.cpp
+@@ -1135,7 +1135,13 @@ void QDBusConnectionPrivate::closeConnection()
+         }
+     }
+ 
+-    qDeleteAll(pendingCalls);
++    for (auto it = pendingCalls.begin(); it != pendingCalls.end(); ++it) {
++        auto call = *it;
++        if (!call->ref.deref()) {
++            delete call;
++        }
++    }
++    pendingCalls.clear();
+ 
+     // Disconnect all signals from signal hooks and from the object tree to
+     // avoid QObject::destroyed being sent to dbus daemon thread which has
+@@ -2584,6 +2590,11 @@ QDBusConnectionPrivate::findMetaObject(const QString &service, const QString &pa
+         if (mo)
+             return mo;
+     }
++    if (path.isEmpty()) {
++        error = QDBusError(QDBusError::InvalidObjectPath, QLatin1String("Object path cannot be empty"));
++        lastError = error;
++        return nullptr;
++    }
+ 
+     // introspect the target object
+     QDBusMessage msg = QDBusMessage::createMethodCall(service, path,
+diff --git a/qtbase/src/dbus/qdbusmetaobject.cpp b/qtbase/src/dbus/qdbusmetaobject.cpp
+index 5265568f42..7e9f0f1acc 100644
+--- a/qtbase/src/dbus/qdbusmetaobject.cpp
++++ b/qtbase/src/dbus/qdbusmetaobject.cpp
+@@ -210,6 +210,9 @@ QDBusMetaObjectGenerator::findType(const QByteArray &signature,
+         } else if (signature == "a{ss}") {
+             result.name = "QMap<QString,QString>";
+             type = qMetaTypeId<QMap<QString, QString> >();
++        } else if (signature == "aay") {
++            result.name = "QByteArrayList";
++            type = qMetaTypeId<QByteArrayList>();
+         } else {
+             result.name = "{D-Bus type \"" + signature + "\"}";
+             type = registerComplexDBusType(result.name);
+diff --git a/qtbase/src/gui/accessible/qaccessible.cpp b/qtbase/src/gui/accessible/qaccessible.cpp
+index d705bfccb5..0caf3c808c 100644
+--- a/qtbase/src/gui/accessible/qaccessible.cpp
++++ b/qtbase/src/gui/accessible/qaccessible.cpp
+@@ -54,6 +54,7 @@
+ #include <QtCore/qdebug.h>
+ #include <QtCore/qloggingcategory.h>
+ #include <QtCore/qmetaobject.h>
++#include <QtCore/private/qmetaobject_p.h>
+ #include <QtCore/qhash.h>
+ #include <private/qfactoryloader_p.h>
+ 
+@@ -681,6 +682,25 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
+     // Create a QAccessibleInterface for the object class. Start by the most
+     // derived class and walk up the class hierarchy.
+     const QMetaObject *mo = object->metaObject();
++    const auto *objectPriv = QObjectPrivate::get(object);
++    /*
++     We do not want to cache each and every QML metaobject (Button_QMLTYPE_124,
++     Button_QMLTYPE_125, etc.). Those dynamic metaobjects shouldn't have an
++     accessible interface in any case. Instead, we start the whole checking
++     with the first non-dynamic meta-object. To avoid potential regressions
++     in other areas of Qt that also use dynamic metaobjects, we only do this
++     for objects that are QML-related (approximated by checking whether they
++     have ddata set).
++    */
++    const bool qmlRelated = !objectPriv->isDeletingChildren &&
++                            objectPriv->declarativeData;
++    while (qmlRelated && mo) {
++        auto mop = QMetaObjectPrivate::get(mo);
++        if (!mop || !(mop->flags & DynamicMetaObject))
++            break;
++
++        mo = mo->superClass();
++    };
+     while (mo) {
+         const QString cn = QLatin1String(mo->className());
+ 
+@@ -696,14 +716,15 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
+         // Find a QAccessiblePlugin (factory) for the class name. If there's
+         // no entry in the cache try to create it using the plugin loader.
+         if (!qAccessiblePlugins()->contains(cn)) {
++            QAccessiblePlugin *factory = nullptr; // 0 means "no plugin found". This is cached as well.
+             const int index = loader()->indexOf(cn);
+-            if (index != -1) {
+-                QAccessiblePlugin *factory = qobject_cast<QAccessiblePlugin *>(loader()->instance(index));
+-                qAccessiblePlugins()->insert(cn, factory);
+-            }
++            if (index != -1)
++                factory = qobject_cast<QAccessiblePlugin *>(loader()->instance(index));
++            qAccessiblePlugins()->insert(cn, factory);
+         }
+ 
+         // At this point the cache should contain a valid factory pointer or 0:
++        Q_ASSERT(qAccessiblePlugins()->contains(cn));
+         QAccessiblePlugin *factory = qAccessiblePlugins()->value(cn);
+         if (factory) {
+             QAccessibleInterface *result = factory->create(cn, object);
+diff --git a/qtbase/src/gui/configure.json b/qtbase/src/gui/configure.json
+index 1f08795c57..12c95742d2 100644
+--- a/qtbase/src/gui/configure.json
++++ b/qtbase/src/gui/configure.json
+@@ -834,7 +834,8 @@
+                     "// embedded devices, are not intended to be used together with X. EGL support",
+                     "// has to be disabled in plugins like xcb in this case since the native display,",
+                     "// window and pixmap types will be different than what an X-based platform",
+-                    "// plugin would expect."
++                    "// plugin would expect.",
++                    "#define USE_X11"
+                 ],
+                 "include": [ "EGL/egl.h", "X11/Xlib.h" ],
+                 "main": [
+diff --git a/qtbase/src/gui/image/qbmphandler.cpp b/qtbase/src/gui/image/qbmphandler.cpp
+index 96f1e8cb1d..0e73bbbdb0 100644
+--- a/qtbase/src/gui/image/qbmphandler.cpp
++++ b/qtbase/src/gui/image/qbmphandler.cpp
+@@ -150,16 +150,42 @@ static QDataStream &operator<<(QDataStream &s, const BMP_INFOHDR &bi)
+     return s;
+ }
+ 
+-static int calc_shift(uint mask)
++static uint calc_shift(uint mask)
+ {
+-    int result = 0;
+-    while (mask && !(mask & 1)) {
++    uint result = 0;
++    while ((mask >= 0x100) || (!(mask & 1) && mask)) {
+         result++;
+         mask >>= 1;
+     }
+     return result;
+ }
+ 
++static uint calc_scale(uint low_mask)
++{
++    uint result = 8;
++    while (low_mask && result) {
++        result--;
++        low_mask >>= 1;
++    }
++    return result;
++}
++
++static inline uint apply_scale(uint value, uint scale)
++{
++    if (!(scale & 0x07)) // return immediately if scale == 8 or 0
++        return value;
++
++    uint filled = 8 - scale;
++    uint result = value << scale;
++
++    do {
++        result |= result >> filled;
++        filled <<= 1;
++    } while (filled < 8);
++
++    return result;
++}
++
+ static bool read_dib_fileheader(QDataStream &s, BMP_FILEHDR &bf)
+ {
+     // read BMP file header
+@@ -222,14 +248,14 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+     uint green_mask = 0;
+     uint blue_mask = 0;
+     uint alpha_mask = 0;
+-    int red_shift = 0;
+-    int green_shift = 0;
+-    int blue_shift = 0;
+-    int alpha_shift = 0;
+-    int red_scale = 0;
+-    int green_scale = 0;
+-    int blue_scale = 0;
+-    int alpha_scale = 0;
++    uint red_shift = 0;
++    uint green_shift = 0;
++    uint blue_shift = 0;
++    uint alpha_shift = 0;
++    uint red_scale = 0;
++    uint green_scale = 0;
++    uint blue_scale = 0;
++    uint alpha_scale = 0;
+ 
+     if (!d->isSequential())
+         d->seek(startpos + BMP_FILEHDR_SIZE + bi.biSize); // goto start of colormap or masks
+@@ -308,19 +334,19 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+         red_shift = calc_shift(red_mask);
+         if (((red_mask >> red_shift) + 1) == 0)
+             return false;
+-        red_scale = 256 / ((red_mask >> red_shift) + 1);
++        red_scale = calc_scale(red_mask >> red_shift);
+         green_shift = calc_shift(green_mask);
+         if (((green_mask >> green_shift) + 1) == 0)
+             return false;
+-        green_scale = 256 / ((green_mask >> green_shift) + 1);
++        green_scale = calc_scale(green_mask >> green_shift);
+         blue_shift = calc_shift(blue_mask);
+         if (((blue_mask >> blue_shift) + 1) == 0)
+             return false;
+-        blue_scale = 256 / ((blue_mask >> blue_shift) + 1);
++        blue_scale = calc_scale(blue_mask >> blue_shift);
+         alpha_shift = calc_shift(alpha_mask);
+         if (((alpha_mask >> alpha_shift) + 1) == 0)
+             return false;
+-        alpha_scale = 256 / ((alpha_mask >> alpha_shift) + 1);
++        alpha_scale = calc_scale(alpha_mask >> alpha_shift);
+     } else if (comp == BMP_RGB && (nbits == 24 || nbits == 32)) {
+         blue_mask = 0x000000ff;
+         green_mask = 0x0000ff00;
+@@ -328,17 +354,15 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+         blue_shift = 0;
+         green_shift = 8;
+         red_shift = 16;
+-        blue_scale = green_scale = red_scale = 1;
++        blue_scale = green_scale = red_scale = 0;
+     } else if (comp == BMP_RGB && nbits == 16) {
+         blue_mask = 0x001f;
+         green_mask = 0x03e0;
+         red_mask = 0x7c00;
+         blue_shift = 0;
+-        green_shift = 2;
+-        red_shift = 7;
+-        red_scale = 1;
+-        green_scale = 1;
+-        blue_scale = 8;
++        green_shift = 5;
++        red_shift = 10;
++        blue_scale = green_scale = red_scale = 3;
+     }
+ 
+ #if 0
+@@ -544,10 +568,10 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+                     c |= *(uchar*)(b+2)<<16;
+                 if (nbits > 24)
+                     c |= *(uchar*)(b+3)<<24;
+-                *p++ = qRgba(((c & red_mask) >> red_shift) * red_scale,
+-                                        ((c & green_mask) >> green_shift) * green_scale,
+-                                        ((c & blue_mask) >> blue_shift) * blue_scale,
+-                                        transp ? ((c & alpha_mask) >> alpha_shift) * alpha_scale : 0xff);
++                *p++ = qRgba(apply_scale((c & red_mask) >> red_shift, red_scale),
++                             apply_scale((c & green_mask) >> green_shift, green_scale),
++                             apply_scale((c & blue_mask) >> blue_shift, blue_scale),
++                             transp ? apply_scale((c & alpha_mask) >> alpha_shift, alpha_scale) : 0xff);
+                 b += nbits/8;
+             }
+         }
+diff --git a/qtbase/src/gui/image/qimage.cpp b/qtbase/src/gui/image/qimage.cpp
+index 7152ac1607..0df772564c 100644
+--- a/qtbase/src/gui/image/qimage.cpp
++++ b/qtbase/src/gui/image/qimage.cpp
+@@ -4694,6 +4694,8 @@ QImage QImage::smoothScaled(int w, int h) const {
+ static QImage rotated90(const QImage &image)
+ {
+     QImage out(image.height(), image.width(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+@@ -4722,6 +4724,8 @@ static QImage rotated180(const QImage &image)
+         return image.mirrored(true, true);
+ 
+     QImage out(image.width(), image.height(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+@@ -4734,6 +4738,8 @@ static QImage rotated180(const QImage &image)
+ static QImage rotated270(const QImage &image)
+ {
+     QImage out(image.height(), image.width(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+diff --git a/qtbase/src/gui/kernel/qcursor.cpp b/qtbase/src/gui/kernel/qcursor.cpp
+index d6ccaff8ed..455088241c 100644
+--- a/qtbase/src/gui/kernel/qcursor.cpp
++++ b/qtbase/src/gui/kernel/qcursor.cpp
+@@ -251,7 +251,8 @@ void QCursor::setPos(QScreen *screen, int x, int y)
+ {
+     if (screen) {
+         if (QPlatformCursor *cursor = screen->handle()->cursor()) {
+-            const QPoint devicePos = QHighDpi::toNativePixels(QPoint(x, y), screen);
++            const QPoint pos(x, y);
++            const QPoint devicePos = QHighDpi::toNativePixels(pos, screen->virtualSiblingAt(pos));
+             // Need to check, since some X servers generate null mouse move
+             // events, causing looping in applications which call setPos() on
+             // every mouse move event.
+diff --git a/qtbase/src/gui/kernel/qhighdpiscaling.cpp b/qtbase/src/gui/kernel/qhighdpiscaling.cpp
+index 9bbf2773a9..3ac4a4d8b6 100644
+--- a/qtbase/src/gui/kernel/qhighdpiscaling.cpp
++++ b/qtbase/src/gui/kernel/qhighdpiscaling.cpp
+@@ -580,9 +580,8 @@ void QHighDpiScaling::setScreenFactor(QScreen *screen, qreal factor)
+     else
+         qNamedScreenScaleFactors()->insert(name, factor);
+ 
+-    // hack to force re-evaluation of screen geometry
+     if (screen->handle())
+-        screen->d_func()->setPlatformScreen(screen->handle()); // updates geometries based on scale factor
++        screen->d_func()->updateLogicalDpi();
+ }
+ 
+ QPoint QHighDpiScaling::mapPositionToNative(const QPoint &pos, const QPlatformScreen *platformScreen)
+diff --git a/qtbase/src/gui/kernel/qkeysequence.cpp b/qtbase/src/gui/kernel/qkeysequence.cpp
+index a75b8ef920..4f2d294739 100644
+--- a/qtbase/src/gui/kernel/qkeysequence.cpp
++++ b/qtbase/src/gui/kernel/qkeysequence.cpp
+@@ -701,6 +701,10 @@ static const struct {
+     { Qt::Key_TouchpadToggle,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad Toggle") },
+     { Qt::Key_TouchpadOn,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad On") },
+     { Qt::Key_TouchpadOff,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad Off") },
++    { Qt::Key_Shift,  QT_TRANSLATE_NOOP("QShortcut", "Shift") },
++    { Qt::Key_Control,  QT_TRANSLATE_NOOP("QShortcut", "Control") },
++    { Qt::Key_Alt,  QT_TRANSLATE_NOOP("QShortcut", "Alt") },
++    { Qt::Key_Meta,  QT_TRANSLATE_NOOP("QShortcut", "Meta") },
+ 
+ };
+ static Q_CONSTEXPR int numKeyNames = sizeof keyname / sizeof *keyname;
+diff --git a/qtbase/src/gui/kernel/qplatformservices.cpp b/qtbase/src/gui/kernel/qplatformservices.cpp
+index fdc6a6c4aa..ac47f98c5d 100644
+--- a/qtbase/src/gui/kernel/qplatformservices.cpp
++++ b/qtbase/src/gui/kernel/qplatformservices.cpp
+@@ -55,6 +55,19 @@ QT_BEGIN_NAMESPACE
+     \brief The QPlatformServices provides the backend for desktop-related functionality.
+ */
+ 
++/*!
++    \enum QPlatformServices::Capability
++
++    Capabilities are used to determine a specific platform service's availability.
++
++    \value ColorPickingFromScreen The platform natively supports color picking from screen.
++    This capability indicates that the platform supports "opaque" color picking, where the
++    platform implements a complete user experience for color picking and outputs a color.
++    This is in contrast to the application implementing the color picking user experience
++    (taking care of showing a cross hair, instructing the platform integration to obtain
++    the color at a given pixel, etc.). The related service function is pickColor().
++ */
++
+ QPlatformServices::QPlatformServices()
+ { }
+ 
+@@ -85,5 +98,16 @@ QByteArray QPlatformServices::desktopEnvironment() const
+     return QByteArray("UNKNOWN");
+ }
+ 
++QPlatformServiceColorPicker *QPlatformServices::colorPicker(QWindow *parent)
++{
++    Q_UNUSED(parent);
++    return nullptr;
++}
++
++bool QPlatformServices::hasCapability(Capability capability) const
++{
++    Q_UNUSED(capability)
++    return false;
++}
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/gui/kernel/qplatformservices.h b/qtbase/src/gui/kernel/qplatformservices.h
+index 5de96cfa7d..a8b2a4ce71 100644
+--- a/qtbase/src/gui/kernel/qplatformservices.h
++++ b/qtbase/src/gui/kernel/qplatformservices.h
+@@ -50,16 +50,32 @@
+ //
+ 
+ #include <QtGui/qtguiglobal.h>
++#include <QtCore/qobject.h>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+ class QUrl;
++class QWindow;
++
++class Q_GUI_EXPORT QPlatformServiceColorPicker : public QObject
++{
++    Q_OBJECT
++public:
++    using QObject::QObject;
++    virtual void pickColor() = 0;
++Q_SIGNALS:
++    void colorPicked(const QColor &color);
++};
+ 
+ class Q_GUI_EXPORT QPlatformServices
+ {
+ public:
+     Q_DISABLE_COPY_MOVE(QPlatformServices)
+ 
++    enum Capability {
++        ColorPicking,
++    };
++
+     QPlatformServices();
+     virtual ~QPlatformServices() { }
+ 
+@@ -67,6 +83,10 @@ public:
+     virtual bool openDocument(const QUrl &url);
+ 
+     virtual QByteArray desktopEnvironment() const;
++
++    virtual bool hasCapability(Capability capability) const;
++
++    virtual QPlatformServiceColorPicker *colorPicker(QWindow *parent = nullptr);
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/gui/kernel/qplatformtheme.cpp b/qtbase/src/gui/kernel/qplatformtheme.cpp
+index 71521c0339..2325873245 100644
+--- a/qtbase/src/gui/kernel/qplatformtheme.cpp
++++ b/qtbase/src/gui/kernel/qplatformtheme.cpp
+@@ -163,6 +163,8 @@ QT_BEGIN_NAMESPACE
+ 
+     \value ShowShortcutsInContextMenus (bool) Whether to display shortcut key sequences in context menus.
+ 
++    \value ButtonPressKeys (QList<Qt::Key>) A list of keys that can be used to press buttons via keyboard input.
++
+     \sa themeHint(), QStyle::pixelMetric()
+ */
+ 
+@@ -563,6 +565,8 @@ QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint)
+         }
+     case MouseQuickSelectionThreshold:
+         return QVariant(10);
++    case ButtonPressKeys:
++        return QVariant::fromValue(QList<Qt::Key>({ Qt::Key_Space, Qt::Key_Select }));
+     }
+     return QVariant();
+ }
+diff --git a/qtbase/src/gui/kernel/qplatformtheme.h b/qtbase/src/gui/kernel/qplatformtheme.h
+index 3185fc4541..7e6c9d5740 100644
+--- a/qtbase/src/gui/kernel/qplatformtheme.h
++++ b/qtbase/src/gui/kernel/qplatformtheme.h
+@@ -120,7 +120,8 @@ public:
+         TouchDoubleTapDistance,
+         ShowShortcutsInContextMenus,
+         IconFallbackSearchPaths,
+-        MouseQuickSelectionThreshold
++        MouseQuickSelectionThreshold,
++        ButtonPressKeys
+     };
+ 
+     enum DialogType {
+diff --git a/qtbase/src/gui/kernel/qscreen.cpp b/qtbase/src/gui/kernel/qscreen.cpp
+index 8e0eb35116..5d172a58dd 100644
+--- a/qtbase/src/gui/kernel/qscreen.cpp
++++ b/qtbase/src/gui/kernel/qscreen.cpp
+@@ -77,6 +77,12 @@ QScreen::QScreen(QPlatformScreen *screen)
+     d->setPlatformScreen(screen);
+ }
+ 
++void QScreenPrivate::updateLogicalDpi()
++{
++    logicalDpi = QPlatformScreen::overrideDpi(platformScreen->logicalDpi());
++    updateGeometriesWithSignals(); // updates geometries based on scale factor
++}
++
+ void QScreenPrivate::updateGeometriesWithSignals()
+ {
+     const QRect oldGeometry = geometry;
+diff --git a/qtbase/src/gui/kernel/qscreen_p.h b/qtbase/src/gui/kernel/qscreen_p.h
+index 7da542c25e..e50fc3190b 100644
+--- a/qtbase/src/gui/kernel/qscreen_p.h
++++ b/qtbase/src/gui/kernel/qscreen_p.h
+@@ -70,6 +70,7 @@ public:
+         geometry = platformScreen->deviceIndependentGeometry();
+         availableGeometry = QHighDpi::fromNative(platformScreen->availableGeometry(), QHighDpiScaling::factor(platformScreen), geometry.topLeft());
+     }
++    void updateLogicalDpi();
+ 
+     void updatePrimaryOrientation();
+     void updateGeometriesWithSignals();
+diff --git a/qtbase/src/gui/painting/qblendfunctions_p.h b/qtbase/src/gui/painting/qblendfunctions_p.h
+index 080da98ec4..6997d62b3c 100644
+--- a/qtbase/src/gui/painting/qblendfunctions_p.h
++++ b/qtbase/src/gui/painting/qblendfunctions_p.h
+@@ -246,25 +246,32 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+                                   int dudx, int dvdx, int dudy, int dvdy, int u0, int v0,
+                                   Blender blender)
+ {
+-    int fromY = qMax(qRound(topY), clip.top());
+-    int toY = qMin(qRound(bottomY), clip.top() + clip.height());
++    qint64 fromY = qMax(qRound(topY), clip.top());
++    qint64 toY = qMin(qRound(bottomY), clip.top() + clip.height());
+     if (fromY >= toY)
+         return;
+ 
+     qreal leftSlope = (bottomLeft.x - topLeft.x) / (bottomLeft.y - topLeft.y);
+     qreal rightSlope = (bottomRight.x - topRight.x) / (bottomRight.y - topRight.y);
+-    int dx_l = int(leftSlope * 0x10000);
+-    int dx_r = int(rightSlope * 0x10000);
+-    int x_l = int((topLeft.x + (qreal(0.5) + fromY - topLeft.y) * leftSlope + qreal(0.5)) * 0x10000);
+-    int x_r = int((topRight.x + (qreal(0.5) + fromY - topRight.y) * rightSlope + qreal(0.5)) * 0x10000);
+-
+-    int fromX, toX, x1, x2, u, v, i, ii;
++    qint64 dx_l = qint64(leftSlope * 0x10000);
++    qint64 dx_r = qint64(rightSlope * 0x10000);
++    qint64 x_l = qint64((topLeft.x + (qreal(0.5) + fromY - topLeft.y) * leftSlope + qreal(0.5)) * 0x10000);
++    qint64 x_r = qint64((topRight.x + (qreal(0.5) + fromY - topRight.y) * rightSlope + qreal(0.5)) * 0x10000);
++
++    qint64 sourceRectTop = qint64(sourceRect.top());
++    qint64 sourceRectLeft = qint64(sourceRect.left());
++    qint64 sourceRectWidth = qint64(sourceRect.width());
++    qint64 sourceRectHeight = qint64(sourceRect.height());
++    qint64 clipLeft = qint64(clip.left());
++    qint64 clipWidth = qint64(clip.width());
++
++    qint64 fromX, toX, x1, x2, u, v, i, ii;
+     DestT *line;
+-    for (int y = fromY; y < toY; ++y) {
++    for (qint64 y = fromY; y < toY; ++y) {
+         line = reinterpret_cast<DestT *>(reinterpret_cast<uchar *>(destPixels) + y * dbpl);
+ 
+-        fromX = qMax(x_l >> 16, clip.left());
+-        toX = qMin(x_r >> 16, clip.left() + clip.width());
++        fromX = qMax(x_l >> 16, clipLeft);
++        toX = qMin(x_r >> 16, clipLeft + clipWidth);
+         if (fromX < toX) {
+             // Because of rounding, we can get source coordinates outside the source image.
+             // Clamp these coordinates to the source rect to avoid segmentation fault and
+@@ -275,10 +282,10 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             u = x1 * dudx + y * dudy + u0;
+             v = x1 * dvdx + y * dvdy + v0;
+             for (; x1 < toX; ++x1) {
+-                int uu = u >> 16;
+-                int vv = v >> 16;
+-                if (uu >= sourceRect.left() && uu < sourceRect.left() + sourceRect.width()
+-                    && vv >= sourceRect.top() && vv < sourceRect.top() + sourceRect.height()) {
++                qint64 uu = u >> 16;
++                qint64 vv = v >> 16;
++                if (uu >= sourceRectLeft && uu < sourceRectLeft + sourceRectWidth
++                    && vv >= sourceRectTop && vv < sourceRectTop + sourceRectHeight) {
+                     break;
+                 }
+                 u += dudx;
+@@ -290,10 +297,10 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             u = (x2 - 1) * dudx + y * dudy + u0;
+             v = (x2 - 1) * dvdx + y * dvdy + v0;
+             for (; x2 > x1; --x2) {
+-                int uu = u >> 16;
+-                int vv = v >> 16;
+-                if (uu >= sourceRect.left() && uu < sourceRect.left() + sourceRect.width()
+-                    && vv >= sourceRect.top() && vv < sourceRect.top() + sourceRect.height()) {
++                qint64 uu = u >> 16;
++                qint64 vv = v >> 16;
++                if (uu >= sourceRectLeft && uu < sourceRectLeft + sourceRectWidth
++                    && vv >= sourceRectTop && vv < sourceRectTop + sourceRectHeight) {
+                     break;
+                 }
+                 u -= dudx;
+@@ -308,8 +315,8 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             // Beginning of the scan line, with per-pixel checks.
+             i = x1 - fromX;
+             while (i) {
+-                int uu = qBound(sourceRect.left(), u >> 16, sourceRect.left() + sourceRect.width() - 1);
+-                int vv = qBound(sourceRect.top(), v >> 16, sourceRect.top() + sourceRect.height() - 1);
++                qint64 uu = qBound(sourceRectLeft, u >> 16, sourceRectLeft + sourceRectWidth - 1);
++                qint64 vv = qBound(sourceRectTop, v >> 16, sourceRectTop + sourceRectHeight - 1);
+                 blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + vv * sbpl)[uu]);
+                 u += dudx;
+                 v += dvdx;
+@@ -348,8 +355,8 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             // End of the scan line, with per-pixel checks.
+             i = toX - x2;
+             while (i) {
+-                int uu = qBound(sourceRect.left(), u >> 16, sourceRect.left() + sourceRect.width() - 1);
+-                int vv = qBound(sourceRect.top(), v >> 16, sourceRect.top() + sourceRect.height() - 1);
++                qint64 uu = qBound(sourceRectLeft, u >> 16, sourceRectLeft + sourceRectWidth - 1);
++                qint64 vv = qBound(sourceRectTop, v >> 16, sourceRectTop + sourceRectHeight - 1);
+                 blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + vv * sbpl)[uu]);
+                 u += dudx;
+                 v += dvdx;
+diff --git a/qtbase/src/gui/painting/qcolortrclut_p.h b/qtbase/src/gui/painting/qcolortrclut_p.h
+index 76a6a60803..24fd522e6c 100644
+--- a/qtbase/src/gui/painting/qcolortrclut_p.h
++++ b/qtbase/src/gui/painting/qcolortrclut_p.h
+@@ -118,6 +118,7 @@ public:
+         return QRgba64::fromRgba64(r, g, b, qAlpha(rgb32) * 257);
+ #endif
+     }
++    QRgba64 toLinear64(QRgba64) const = delete;
+ 
+     QRgb toLinear(QRgb rgb32) const
+     {
+diff --git a/qtbase/src/gui/painting/qdrawhelper.cpp b/qtbase/src/gui/painting/qdrawhelper.cpp
+index a61793508a..5ba2d277b7 100644
+--- a/qtbase/src/gui/painting/qdrawhelper.cpp
++++ b/qtbase/src/gui/painting/qdrawhelper.cpp
+@@ -6091,7 +6091,7 @@ static inline void alphargbblend_argb32(quint32 *dst, uint coverage, const QRgba
+ static inline void rgbBlendPixel(QRgba64 &dst, int coverage, QRgba64 slinear, const QColorTrcLut *colorProfile)
+ {
+     // Do a gammacorrected RGB alphablend...
+-    const QRgba64 dlinear = colorProfile ? colorProfile->toLinear64(dst) : dst;
++    const QRgba64 dlinear = colorProfile ? colorProfile->toLinear(dst) : dst;
+ 
+     QRgba64 blend = rgbBlend(dlinear, slinear, coverage);
+ 
+diff --git a/qtbase/src/gui/painting/qpaintengine_raster.cpp b/qtbase/src/gui/painting/qpaintengine_raster.cpp
+index 283923de52..f08eb9cbee 100644
+--- a/qtbase/src/gui/painting/qpaintengine_raster.cpp
++++ b/qtbase/src/gui/painting/qpaintengine_raster.cpp
+@@ -560,31 +560,6 @@ void QRasterPaintEngine::updateMatrix(const QTransform &matrix)
+     QRasterPaintEngineState *s = state();
+     // FALCON: get rid of this line, see drawImage call below.
+     s->matrix = matrix;
+-    QTransform::TransformationType txop = s->matrix.type();
+-
+-    switch (txop) {
+-
+-    case QTransform::TxNone:
+-        s->flags.int_xform = true;
+-        break;
+-
+-    case QTransform::TxTranslate:
+-        s->flags.int_xform = qreal(int(s->matrix.dx())) == s->matrix.dx()
+-                            && qreal(int(s->matrix.dy())) == s->matrix.dy();
+-        break;
+-
+-    case QTransform::TxScale:
+-        s->flags.int_xform = qreal(int(s->matrix.dx())) == s->matrix.dx()
+-                            && qreal(int(s->matrix.dy())) == s->matrix.dy()
+-                            && qreal(int(s->matrix.m11())) == s->matrix.m11()
+-                            && qreal(int(s->matrix.m22())) == s->matrix.m22();
+-        break;
+-
+-    default: // shear / perspective...
+-        s->flags.int_xform = false;
+-        break;
+-    }
+-
+     s->flags.tx_noshear = qt_scaleForTransform(s->matrix, &s->txscale);
+ 
+     ensureOutlineMapper();
+@@ -617,7 +592,6 @@ QRasterPaintEngineState::QRasterPaintEngineState()
+     flags.bilinear = false;
+     flags.legacy_rounding = false;
+     flags.fast_text = true;
+-    flags.int_xform = true;
+     flags.tx_noshear = true;
+     flags.fast_images = true;
+ 
+@@ -1793,7 +1767,7 @@ void QRasterPaintEngine::fill(const QVectorPath &path, const QBrush &brush)
+     QRectF cpRect = path.controlPointRect();
+     const QRectF pathDeviceRect = s->matrix.mapRect(cpRect);
+     // Skip paths that by conservative estimates are completely outside the paint device.
+-    if (!pathDeviceRect.intersects(QRectF(d->deviceRect)))
++    if (!pathDeviceRect.intersects(QRectF(d->deviceRect)) || !pathDeviceRect.isValid())
+         return;
+ 
+     ProcessSpans blend = d->getBrushFunc(pathDeviceRect, &s->brushData);
+diff --git a/qtbase/src/gui/painting/qpaintengine_raster_p.h b/qtbase/src/gui/painting/qpaintengine_raster_p.h
+index 089aadc3f7..bf7363d5aa 100644
+--- a/qtbase/src/gui/painting/qpaintengine_raster_p.h
++++ b/qtbase/src/gui/painting/qpaintengine_raster_p.h
+@@ -111,7 +111,6 @@ public:
+         uint bilinear : 1;
+         uint legacy_rounding : 1;
+         uint fast_text : 1;
+-        uint int_xform : 1;
+         uint tx_noshear : 1;
+         uint fast_images : 1;
+     };
+diff --git a/qtbase/src/gui/painting/qpainterpath.cpp b/qtbase/src/gui/painting/qpainterpath.cpp
+index f9544a3241..d80fafeaf1 100644
+--- a/qtbase/src/gui/painting/qpainterpath.cpp
++++ b/qtbase/src/gui/painting/qpainterpath.cpp
+@@ -1253,7 +1253,7 @@ void QPainterPath::addText(const QPointF &point, const QFont &f, const QString &
+ 
+         if (si.analysis.flags < QScriptAnalysis::TabOrObject) {
+             QGlyphLayout glyphs = eng->shapedGlyphs(&si);
+-            QFontEngine *fe = f.d->engineForScript(si.analysis.script);
++            QFontEngine *fe = eng->fontEngine(si);
+             Q_ASSERT(fe);
+             fe->addOutlineToPath(x, y, glyphs, this,
+                                  si.analysis.bidiLevel % 2
+diff --git a/qtbase/src/gui/painting/qpathclipper_p.h b/qtbase/src/gui/painting/qpathclipper_p.h
+index 9444a87b71..18f64c5e8c 100644
+--- a/qtbase/src/gui/painting/qpathclipper_p.h
++++ b/qtbase/src/gui/painting/qpathclipper_p.h
+@@ -156,7 +156,7 @@ public:
+     int vertex(Direction direction) const;
+ 
+ private:
+-    int m_next[2][2];
++    int m_next[2][2] = { { -1, -1 }, { -1, -1 } };
+ };
+ 
+ class QPathSegments
+@@ -296,10 +296,6 @@ inline QPathEdge::QPathEdge(int a, int b)
+     , angle(0)
+     , invAngle(0)
+ {
+-    m_next[0][0] = -1;
+-    m_next[1][0] = -1;
+-    m_next[0][0] = -1;
+-    m_next[1][0] = -1;
+ }
+ 
+ inline int QPathEdge::next(Traversal traversal, Direction direction) const
+diff --git a/qtbase/src/gui/painting/qpdf.cpp b/qtbase/src/gui/painting/qpdf.cpp
+index 3066744f1b..2c8d3c3b53 100644
+--- a/qtbase/src/gui/painting/qpdf.cpp
++++ b/qtbase/src/gui/painting/qpdf.cpp
+@@ -2760,6 +2760,8 @@ int QPdfEnginePrivate::addBrushPattern(const QTransform &m, bool *specifyColor,
+         return gradientBrush(brush, matrix, gStateObject);
+     }
+ 
++    matrix = brush.transform() * matrix;
++
+     if ((!brush.isOpaque() && brush.style() < Qt::LinearGradientPattern) || opacity != 1.0)
+         *gStateObject = addConstantAlphaObject(qRound(brush.color().alpha() * opacity),
+                                                qRound(pen.color().alpha() * opacity));
+diff --git a/qtbase/src/gui/painting/qstroker.cpp b/qtbase/src/gui/painting/qstroker.cpp
+index cb5d395e80..3b6357a893 100644
+--- a/qtbase/src/gui/painting/qstroker.cpp
++++ b/qtbase/src/gui/painting/qstroker.cpp
+@@ -1182,6 +1182,7 @@ void QDashStroker::processCurrentSubpath()
+         // Check if the entire line should be clipped away or simplified
+         bool clipIt = clipping && !lineIntersectsRect(prev, e, clip_tl, clip_br);
+         bool skipDashing = elen * invSumLength > repetitionLimit();
++        int maxDashes = dashCount;
+         if (skipDashing || clipIt) {
+             // Cut away full dash sequences.
+             elen -= std::floor(elen * invSumLength) * sumLength;
+@@ -1196,7 +1197,7 @@ void QDashStroker::processCurrentSubpath()
+                     pos = estop; // move pos to next path element
+                     done = true;
+                 } else { // Dash is on this line
+-                    pos = dpos + estart;
++                    pos = --maxDashes > 0 ? dpos + estart : estop;
+                     done = pos >= estop;
+                     if (++idash >= dashCount)
+                         idash = 0;
+diff --git a/qtbase/src/gui/painting/qt_attribution.json b/qtbase/src/gui/painting/qt_attribution.json
+index 7b16e8c211..0e87d30aa2 100644
+--- a/qtbase/src/gui/painting/qt_attribution.json
++++ b/qtbase/src/gui/painting/qt_attribution.json
+@@ -10,7 +10,7 @@
+         "Homepage": "http://www.freetype.org",
+         "License": "Freetype Project License or GNU General Public License v2.0 only",
+         "LicenseId": "FTL or GPL-2.0",
+-        "LicenseFile": "../../3rdparty/freetype/docs/LICENSE.TXT",
++        "LicenseFile": "../../3rdparty/freetype/LICENSE.TXT",
+         "Copyright": "Copyright 2000-2016 by David Turner, Robert Wilhelm, and Werner Lemberg."
+     },
+     {
+diff --git a/qtbase/src/gui/rhi/qshader_p_p.h b/qtbase/src/gui/rhi/qshader_p_p.h
+index ec9d25971f..4a5a7a6d51 100644
+--- a/qtbase/src/gui/rhi/qshader_p_p.h
++++ b/qtbase/src/gui/rhi/qshader_p_p.h
+@@ -68,13 +68,13 @@ struct Q_GUI_EXPORT QShaderPrivate
+     {
+     }
+ 
+-    QShaderPrivate(const QShaderPrivate *other)
++    QShaderPrivate(const QShaderPrivate &other)
+         : ref(1),
+-          qsbVersion(other->qsbVersion),
+-          stage(other->stage),
+-          desc(other->desc),
+-          shaders(other->shaders),
+-          bindings(other->bindings)
++          qsbVersion(other.qsbVersion),
++          stage(other.stage),
++          desc(other.desc),
++          shaders(other.shaders),
++          bindings(other.bindings)
+     {
+     }
+ 
+diff --git a/qtbase/src/gui/rhi/qshaderdescription_p_p.h b/qtbase/src/gui/rhi/qshaderdescription_p_p.h
+index ec2b0b6b4c..3da33a8a2b 100644
+--- a/qtbase/src/gui/rhi/qshaderdescription_p_p.h
++++ b/qtbase/src/gui/rhi/qshaderdescription_p_p.h
+@@ -63,16 +63,16 @@ struct Q_GUI_EXPORT QShaderDescriptionPrivate
+         localSize[0] = localSize[1] = localSize[2] = 0;
+     }
+ 
+-    QShaderDescriptionPrivate(const QShaderDescriptionPrivate *other)
++    QShaderDescriptionPrivate(const QShaderDescriptionPrivate &other)
+         : ref(1),
+-          inVars(other->inVars),
+-          outVars(other->outVars),
+-          uniformBlocks(other->uniformBlocks),
+-          pushConstantBlocks(other->pushConstantBlocks),
+-          storageBlocks(other->storageBlocks),
+-          combinedImageSamplers(other->combinedImageSamplers),
+-          storageImages(other->storageImages),
+-          localSize(other->localSize)
++          inVars(other.inVars),
++          outVars(other.outVars),
++          uniformBlocks(other.uniformBlocks),
++          pushConstantBlocks(other.pushConstantBlocks),
++          storageBlocks(other.storageBlocks),
++          combinedImageSamplers(other.combinedImageSamplers),
++          storageImages(other.storageImages),
++          localSize(other.localSize)
+     {
+     }
+ 
+diff --git a/qtbase/src/gui/text/qfontdatabase.cpp b/qtbase/src/gui/text/qfontdatabase.cpp
+index a657a8c516..4fc0100958 100644
+--- a/qtbase/src/gui/text/qfontdatabase.cpp
++++ b/qtbase/src/gui/text/qfontdatabase.cpp
+@@ -983,7 +983,7 @@ QFontEngine *loadSingleEngine(int script,
+         if (style->key.stretch != 0 && request.stretch != 0
+             && (request.styleName.isEmpty() || request.styleName != style->styleName)) {
+             def.stretch = (request.stretch * 100 + style->key.stretch / 2) / style->key.stretch;
+-        } else {
++        } else if (request.stretch == QFont::AnyStretch) {
+             def.stretch = 100;
+         }
+ 
+diff --git a/qtbase/src/gui/text/qtextdocumentlayout.cpp b/qtbase/src/gui/text/qtextdocumentlayout.cpp
+index f3e6ea2100..72267e9380 100644
+--- a/qtbase/src/gui/text/qtextdocumentlayout.cpp
++++ b/qtbase/src/gui/text/qtextdocumentlayout.cpp
+@@ -2123,7 +2123,7 @@ void QTextDocumentLayoutPrivate::drawListItem(const QPointF &offset, QPainter *p
+ {
+     Q_Q(const QTextDocumentLayout);
+     const QTextBlockFormat blockFormat = bl.blockFormat();
+-    const QTextCharFormat charFormat = QTextCursor(bl).charFormat();
++    const QTextCharFormat charFormat = bl.charFormat();
+     QFont font(charFormat.font());
+     if (q->paintDevice())
+         font = QFont(font, q->paintDevice());
+diff --git a/qtbase/src/gui/text/qtextengine.cpp b/qtbase/src/gui/text/qtextengine.cpp
+index ce4abac472..a6c66e5d2d 100644
+--- a/qtbase/src/gui/text/qtextengine.cpp
++++ b/qtbase/src/gui/text/qtextengine.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2021 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtGui module of the Qt Toolkit.
+@@ -1565,6 +1565,12 @@ void QTextEngine::shapeText(int item) const
+         // Overwrite with 0 token to indicate failure
+         QGlyphLayout g = availableGlyphs(&si);
+         g.glyphs[0] = 0;
++        g.attributes[0].clusterStart = true;
++
++        ushort *log_clusters = logClusters(&si);
++        for (int i = 0; i < itemLength; ++i)
++            log_clusters[i] = 0;
++
+         return;
+     }
+ 
+diff --git a/qtbase/src/gui/util/qdesktopservices.cpp b/qtbase/src/gui/util/qdesktopservices.cpp
+index fbb63a9408..4d5fafaaa7 100644
+--- a/qtbase/src/gui/util/qdesktopservices.cpp
++++ b/qtbase/src/gui/util/qdesktopservices.cpp
+@@ -54,6 +54,8 @@
+ #include <qpa/qplatformintegration.h>
+ #include <qdir.h>
+ 
++#include <QtCore/private/qlocking_p.h>
++
+ QT_BEGIN_NAMESPACE
+ 
+ class QOpenUrlHandlerRegistry : public QObject
+@@ -81,6 +83,7 @@ Q_GLOBAL_STATIC(QOpenUrlHandlerRegistry, handlerRegistry)
+ 
+ void QOpenUrlHandlerRegistry::handlerDestroyed(QObject *handler)
+ {
++    const auto lock = qt_scoped_lock(mutex);
+     HandlerHash::Iterator it = handlers.begin();
+     while (it != handlers.end()) {
+         if (it->receiver == handler) {
+@@ -294,7 +297,8 @@ void QDesktopServices::setUrlHandler(const QString &scheme, QObject *receiver, c
+     h.name = method;
+     registry->handlers.insert(scheme.toLower(), h);
+     QObject::connect(receiver, SIGNAL(destroyed(QObject*)),
+-                     registry, SLOT(handlerDestroyed(QObject*)));
++                     registry, SLOT(handlerDestroyed(QObject*)),
++                     Qt::DirectConnection);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/gui/util/qpkmhandler.cpp b/qtbase/src/gui/util/qpkmhandler.cpp
+index e0c3b75efe..3414f9d8ba 100644
+--- a/qtbase/src/gui/util/qpkmhandler.cpp
++++ b/qtbase/src/gui/util/qpkmhandler.cpp
+@@ -57,7 +57,7 @@ struct PkmType
+     quint32 bytesPerBlock;
+ };
+ 
+-static PkmType typeMap[5] = {
++static constexpr PkmType typeMap[5] = {
+     { 0x8D64,  8 },   // GL_ETC1_RGB8_OES
+     { 0x9274,  8 },   // GL_COMPRESSED_RGB8_ETC2
+     { 0, 0 },         // unused (obsolete)
+diff --git a/qtbase/src/network/access/qnetworkreplyfileimpl.cpp b/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
+index b6be93147a..6e69b4c4d3 100644
+--- a/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
++++ b/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
+@@ -89,9 +89,10 @@ QNetworkReplyFileImpl::QNetworkReplyFileImpl(QNetworkAccessManager *manager, con
+         // we handle only local files
+         QString msg = QCoreApplication::translate("QNetworkAccessFileBackend", "Request for opening non-local file %1").arg(url.toString());
+         setError(QNetworkReply::ProtocolInvalidOperationError, msg);
++        setFinished(true); // We're finished, will emit finished() after ctor is done.
+         QMetaObject::invokeMethod(this, "errorOccurred", Qt::QueuedConnection,
+             Q_ARG(QNetworkReply::NetworkError, QNetworkReply::ProtocolInvalidOperationError));
+-        fileOpenFinished(false);
++        QMetaObject::invokeMethod(this, [this](){ fileOpenFinished(false); }, Qt::QueuedConnection);
+         return;
+     }
+ #endif
+diff --git a/qtbase/src/network/access/qnetworkreplyimpl.cpp b/qtbase/src/network/access/qnetworkreplyimpl.cpp
+index bcdf6ee2f1..3b6deb82bd 100644
+--- a/qtbase/src/network/access/qnetworkreplyimpl.cpp
++++ b/qtbase/src/network/access/qnetworkreplyimpl.cpp
+@@ -680,7 +680,7 @@ void QNetworkReplyImplPrivate::appendDownstreamData(QIODevice *data)
+     // read until EOF from data
+     if (Q_UNLIKELY(copyDevice)) {
+         qCritical("QNetworkReplyImpl: copy from QIODevice already in progress -- "
+-                  "backend probly needs to be fixed");
++                  "backend probably needs to be fixed");
+         return;
+     }
+ 
+diff --git a/qtbase/src/network/kernel/qauthenticator.cpp b/qtbase/src/network/kernel/qauthenticator.cpp
+index d9fe7bc47b..ccd04b294a 100644
+--- a/qtbase/src/network/kernel/qauthenticator.cpp
++++ b/qtbase/src/network/kernel/qauthenticator.cpp
+@@ -50,6 +50,7 @@
+ #include <qstring.h>
+ #include <qdatetime.h>
+ #include <qrandom.h>
++#include "private/qsystemlibrary_p.h"
+ 
+ #ifdef Q_OS_WIN
+ #include <qmutex.h>
+@@ -1563,7 +1564,7 @@ static bool q_SSPI_library_load()
+ 
+     // Initialize security interface
+     if (pSecurityFunctionTable == nullptr) {
+-        securityDLLHandle = LoadLibrary(L"secur32.dll");
++        securityDLLHandle = QSystemLibrary::load(L"secur32");
+         if (securityDLLHandle != nullptr) {
+             INIT_SECURITY_INTERFACE pInitSecurityInterface =
+                 reinterpret_cast<INIT_SECURITY_INTERFACE>(
+diff --git a/qtbase/src/network/kernel/qhostinfo_unix.cpp b/qtbase/src/network/kernel/qhostinfo_unix.cpp
+index 9b0a2ee669..73679c9ef1 100644
+--- a/qtbase/src/network/kernel/qhostinfo_unix.cpp
++++ b/qtbase/src/network/kernel/qhostinfo_unix.cpp
+@@ -122,7 +122,6 @@ static QFunctionPointer resolveSymbol(QLibrary &lib, const char *sym)
+ 
+ LibResolv::LibResolv()
+ {
+-    QLibrary lib;
+ #ifdef LIBRESOLV_SO
+     lib.setFileName(QStringLiteral(LIBRESOLV_SO));
+     if (!lib.load())
+diff --git a/qtbase/src/network/socket/qsocks5socketengine.cpp b/qtbase/src/network/socket/qsocks5socketengine.cpp
+index 3a046fd116..97fadca0b3 100644
+--- a/qtbase/src/network/socket/qsocks5socketengine.cpp
++++ b/qtbase/src/network/socket/qsocks5socketengine.cpp
+@@ -1296,7 +1296,7 @@ void QSocks5SocketEnginePrivate::_q_udpSocketReadNotification()
+         int pos = 0;
+         const char *buf = inBuf.constData();
+         if (inBuf.size() < 4) {
+-            QSOCKS5_D_DEBUG << "bugus udp data, discarding";
++            QSOCKS5_D_DEBUG << "bogus udp data, discarding";
+             return;
+         }
+         QSocks5RevivedDatagram datagram;
+diff --git a/qtbase/src/network/ssl/qsslcontext_openssl.cpp b/qtbase/src/network/ssl/qsslcontext_openssl.cpp
+index c9f202f573..c992da9d8e 100644
+--- a/qtbase/src/network/ssl/qsslcontext_openssl.cpp
++++ b/qtbase/src/network/ssl/qsslcontext_openssl.cpp
+@@ -409,7 +409,7 @@ init_context:
+         break;
+     case QSsl::DtlsV1_0OrLater:
+         minVersion = DTLS1_VERSION;
+-        maxVersion = DTLS_MAX_VERSION;
++        maxVersion = 0;
+         break;
+     case QSsl::DtlsV1_2:
+         minVersion = DTLS1_2_VERSION;
+@@ -417,7 +417,7 @@ init_context:
+         break;
+     case QSsl::DtlsV1_2OrLater:
+         minVersion = DTLS1_2_VERSION;
+-        maxVersion = DTLS_MAX_VERSION;
++        maxVersion = 0;
+         break;
+     case QSsl::TlsV1_3OrLater:
+ #ifdef TLS1_3_VERSION
+@@ -455,7 +455,7 @@ init_context:
+     }
+ 
+     // Enable bug workarounds.
+-    long options = QSslSocketBackendPrivate::setupOpenSslOptions(configuration.protocol(), configuration.d->sslOptions);
++    qssloptions options = QSslSocketBackendPrivate::setupOpenSslOptions(configuration.protocol(), configuration.d->sslOptions);
+     q_SSL_CTX_set_options(sslContext->ctx, options);
+ 
+     // Tell OpenSSL to release memory early
+diff --git a/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp b/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
+index aaf8741130..b58935372c 100644
+--- a/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
++++ b/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
+@@ -59,57 +59,6 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-#ifdef OPENSSL_NO_DEPRECATED_3_0
+-
+-static int q_DH_check(DH *dh, int *status)
+-{
+-    // DH_check was first deprecated in OpenSSL 3.0.0, as low-level
+-    // API; the EVP_PKEY family of functions was advised as an alternative.
+-    // As of now EVP_PKEY_params_check ends up calling ... DH_check,
+-    // which is good enough.
+-
+-    Q_ASSERT(dh);
+-    Q_ASSERT(status);
+-
+-    EVP_PKEY *key = q_EVP_PKEY_new();
+-    if (!key) {
+-        qCWarning(lcSsl, "EVP_PKEY_new failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-    const auto keyDeleter = qScopeGuard([key](){
+-        q_EVP_PKEY_free(key);
+-    });
+-    if (!q_EVP_PKEY_set1_DH(key, dh)) {
+-        qCWarning(lcSsl, "EVP_PKEY_set1_DH failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-
+-    EVP_PKEY_CTX *keyCtx = q_EVP_PKEY_CTX_new(key, nullptr);
+-    if (!keyCtx) {
+-        qCWarning(lcSsl, "EVP_PKEY_CTX_new failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-    const auto ctxDeleter = qScopeGuard([keyCtx]{
+-        q_EVP_PKEY_CTX_free(keyCtx);
+-    });
+-
+-    const int result = q_EVP_PKEY_param_check(keyCtx);
+-    QSslSocketBackendPrivate::logAndClearErrorQueue();
+-    // Note: unlike DH_check, we cannot obtain the 'status',
+-    // if the 'result' is 0 (actually the result is 1 only
+-    // if this 'status' was 0). We could probably check the
+-    // errors from the error queue, but it's not needed anyway
+-    // - see the 'isSafeDH' below, how it returns immediately
+-    // on 0.
+-    Q_UNUSED(status)
+-
+-    return result;
+-}
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+-
+ static bool isSafeDH(DH *dh)
+ {
+     int status = 0;
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl.cpp b/qtbase/src/network/ssl/qsslsocket_openssl.cpp
+index 37fad2a68f..8f6858c867 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl.cpp
++++ b/qtbase/src/network/ssl/qsslsocket_openssl.cpp
+@@ -550,9 +550,9 @@ static void q_loadCiphersForConnection(SSL *connection, QList<QSslCipher> &ciphe
+ // Defined in qsslsocket.cpp
+ void q_setDefaultDtlsCiphers(const QList<QSslCipher> &ciphers);
+ 
+-long QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions)
++qssloptions QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions)
+ {
+-    long options;
++    qssloptions options;
+     if (protocol == QSsl::TlsV1SslV3)
+         options = SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3;
+     else if (protocol == QSsl::SecureProtocols)
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_p.h b/qtbase/src/network/ssl/qsslsocket_openssl_p.h
+index 4103de23e8..5547589256 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_p.h
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_p.h
+@@ -107,6 +107,12 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++typedef uint64_t qssloptions;
++#else
++typedef unsigned long qssloptions;
++#endif
++
+ struct QSslErrorEntry {
+     int code;
+     int depth;
+@@ -171,7 +177,7 @@ public:
+     QVector<QSslError> ocspErrors;
+     QByteArray ocspResponseDer;
+ 
+-    Q_AUTOTEST_EXPORT static long setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions);
++    Q_AUTOTEST_EXPORT static qssloptions setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions);
+     static QSslCipher QSslCipher_from_SSL_CIPHER(const SSL_CIPHER *cipher);
+     static QList<QSslCertificate> STACKOFX509_to_QSslCertificates(STACK_OF(X509) *x509);
+     static QList<QSslError> verify(const QList<QSslCertificate> &certificateChain, const QString &hostName);
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp b/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
+index e53fb279f0..459ccd0b19 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
+@@ -148,7 +148,6 @@ DEFINEFUNC(int, EVP_PKEY_up_ref, EVP_PKEY *a, a, return 0, return)
+ DEFINEFUNC2(EVP_PKEY_CTX *, EVP_PKEY_CTX_new, EVP_PKEY *pkey, pkey, ENGINE *e, e, return nullptr, return)
+ DEFINEFUNC(int, EVP_PKEY_param_check, EVP_PKEY_CTX *ctx, ctx, return 0, return)
+ DEFINEFUNC(void, EVP_PKEY_CTX_free, EVP_PKEY_CTX *ctx, ctx, return, return)
+-DEFINEFUNC(int, EVP_PKEY_base_id, EVP_PKEY *a, a, return NID_undef, return)
+ DEFINEFUNC(int, RSA_bits, RSA *a, a, return 0, return)
+ DEFINEFUNC(int, DSA_bits, DSA *a, a, return 0, return)
+ DEFINEFUNC(int, OPENSSL_sk_num, OPENSSL_STACK *a, a, return -1, return)
+@@ -158,7 +157,7 @@ DEFINEFUNC2(void, OPENSSL_sk_push, OPENSSL_STACK *a, a, void *b, b, return, DUMM
+ DEFINEFUNC(void, OPENSSL_sk_free, OPENSSL_STACK *a, a, return, DUMMYARG)
+ DEFINEFUNC2(void *, OPENSSL_sk_value, OPENSSL_STACK *a, a, int b, b, return nullptr, return)
+ DEFINEFUNC(int, SSL_session_reused, SSL *a, a, return 0, return)
+-DEFINEFUNC2(unsigned long, SSL_CTX_set_options, SSL_CTX *ctx, ctx, unsigned long op, op, return 0, return)
++DEFINEFUNC2(qssloptions, SSL_CTX_set_options, SSL_CTX *ctx, ctx, qssloptions op, op, return 0, return)
+ DEFINEFUNC(int, SSL_CTX_get_security_level, const SSL_CTX *ctx, ctx, return -1, return)
+ DEFINEFUNC2(void, SSL_CTX_set_security_level, SSL_CTX *ctx, ctx, int level, level, return, return)
+ #ifdef TLS1_3_VERSION
+@@ -371,7 +370,15 @@ DEFINEFUNC(const SSL_CIPHER *, SSL_get_current_cipher, SSL *a, a, return nullptr
+ DEFINEFUNC(int, SSL_version, const SSL *a, a, return 0, return)
+ DEFINEFUNC2(int, SSL_get_error, SSL *a, a, int b, b, return -1, return)
+ DEFINEFUNC(STACK_OF(X509) *, SSL_get_peer_cert_chain, SSL *a, a, return nullptr, return)
++
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++DEFINEFUNC(X509 *, SSL_get1_peer_certificate, SSL *a, a, return nullptr, return)
++DEFINEFUNC(int, EVP_PKEY_get_base_id, const EVP_PKEY *pkey, pkey, return -1, return)
++#else
+ DEFINEFUNC(X509 *, SSL_get_peer_certificate, SSL *a, a, return nullptr, return)
++DEFINEFUNC(int, EVP_PKEY_base_id, EVP_PKEY *a, a, return NID_undef, return)
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+ DEFINEFUNC(long, SSL_get_verify_result, const SSL *a, a, return -1, return)
+ DEFINEFUNC(SSL *, SSL_new, SSL_CTX *a, a, return nullptr, return)
+ DEFINEFUNC(SSL_CTX *, SSL_get_SSL_CTX, SSL *a, a, return nullptr, return)
+@@ -492,9 +499,7 @@ DEFINEFUNC(DH *, DH_new, DUMMYARG, DUMMYARG, return nullptr, return)
+ DEFINEFUNC(void, DH_free, DH *dh, dh, return, DUMMYARG)
+ DEFINEFUNC3(DH *, d2i_DHparams, DH**a, a, const unsigned char **pp, pp, long length, length, return nullptr, return)
+ DEFINEFUNC2(int, i2d_DHparams, DH *a, a, unsigned char **p, p, return -1, return)
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+ DEFINEFUNC2(int, DH_check, DH *dh, dh, int *codes, codes, return 0, return)
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+ DEFINEFUNC3(BIGNUM *, BN_bin2bn, const unsigned char *s, s, int len, len, BIGNUM *ret, ret, return nullptr, return)
+ 
+ #ifndef OPENSSL_NO_EC
+@@ -868,7 +873,6 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(EVP_PKEY_CTX_new)
+     RESOLVEFUNC(EVP_PKEY_param_check)
+     RESOLVEFUNC(EVP_PKEY_CTX_free)
+-    RESOLVEFUNC(EVP_PKEY_base_id)
+     RESOLVEFUNC(RSA_bits)
+     RESOLVEFUNC(OPENSSL_sk_new_null)
+     RESOLVEFUNC(OPENSSL_sk_push)
+@@ -1107,7 +1111,15 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(SSL_version)
+     RESOLVEFUNC(SSL_get_error)
+     RESOLVEFUNC(SSL_get_peer_cert_chain)
++
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++    RESOLVEFUNC(SSL_get1_peer_certificate)
++    RESOLVEFUNC(EVP_PKEY_get_base_id)
++#else
+     RESOLVEFUNC(SSL_get_peer_certificate)
++    RESOLVEFUNC(EVP_PKEY_base_id)
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+     RESOLVEFUNC(SSL_get_verify_result)
+     RESOLVEFUNC(SSL_new)
+     RESOLVEFUNC(SSL_get_SSL_CTX)
+@@ -1206,9 +1218,7 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(DH_free)
+     RESOLVEFUNC(d2i_DHparams)
+     RESOLVEFUNC(i2d_DHparams)
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+     RESOLVEFUNC(DH_check)
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+     RESOLVEFUNC(BN_bin2bn)
+ 
+ #ifndef OPENSSL_NO_EC
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h b/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
+index 95e8897a3b..27aeffa18a 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
+@@ -237,7 +237,6 @@ Q_AUTOTEST_EXPORT int q_EVP_PKEY_up_ref(EVP_PKEY *a);
+ EVP_PKEY_CTX *q_EVP_PKEY_CTX_new(EVP_PKEY *pkey, ENGINE *e);
+ void q_EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx);
+ int q_EVP_PKEY_param_check(EVP_PKEY_CTX *ctx);
+-int q_EVP_PKEY_base_id(EVP_PKEY *a);
+ int q_RSA_bits(RSA *a);
+ Q_AUTOTEST_EXPORT int q_OPENSSL_sk_num(OPENSSL_STACK *a);
+ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_pop_free(OPENSSL_STACK *a, void (*b)(void *));
+@@ -246,7 +245,7 @@ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_push(OPENSSL_STACK *st, void *data);
+ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_free(OPENSSL_STACK *a);
+ Q_AUTOTEST_EXPORT void * q_OPENSSL_sk_value(OPENSSL_STACK *a, int b);
+ int q_SSL_session_reused(SSL *a);
+-unsigned long q_SSL_CTX_set_options(SSL_CTX *ctx, unsigned long op);
++qssloptions q_SSL_CTX_set_options(SSL_CTX *ctx, qssloptions op);
+ int q_OPENSSL_init_ssl(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings);
+ size_t q_SSL_get_client_random(SSL *a, unsigned char *out, size_t outlen);
+ size_t q_SSL_SESSION_get_master_key(const SSL_SESSION *session, unsigned char *out, size_t outlen);
+@@ -510,7 +509,6 @@ const SSL_CIPHER *q_SSL_get_current_cipher(SSL *a);
+ int q_SSL_version(const SSL *a);
+ int q_SSL_get_error(SSL *a, int b);
+ STACK_OF(X509) *q_SSL_get_peer_cert_chain(SSL *a);
+-X509 *q_SSL_get_peer_certificate(SSL *a);
+ long q_SSL_get_verify_result(const SSL *a);
+ SSL *q_SSL_new(SSL_CTX *a);
+ SSL_CTX *q_SSL_get_SSL_CTX(SSL *a);
+@@ -582,10 +580,7 @@ DH *q_DH_new();
+ void q_DH_free(DH *dh);
+ DH *q_d2i_DHparams(DH **a, const unsigned char **pp, long length);
+ int q_i2d_DHparams(DH *a, unsigned char **p);
+-
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+ int q_DH_check(DH *dh, int *codes);
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+ 
+ BIGNUM *q_BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret);
+ #define q_SSL_CTX_set_tmp_dh(ctx, dh) q_SSL_CTX_ctrl((ctx), SSL_CTRL_SET_TMP_DH, 0, (char *)dh)
+@@ -754,6 +749,17 @@ void q_CRYPTO_free(void *str, const char *file, int line);
+ int q_SSL_CTX_get_security_level(const SSL_CTX *ctx);
+ void q_SSL_CTX_set_security_level(SSL_CTX *ctx, int level);
+ 
++// Here we have the ones that make difference between OpenSSL pre/post v3:
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++X509 *q_SSL_get1_peer_certificate(SSL *a);
++#define q_SSL_get_peer_certificate q_SSL_get1_peer_certificate
++int q_EVP_PKEY_get_base_id(const EVP_PKEY *pkey);
++#define q_EVP_PKEY_base_id q_EVP_PKEY_get_base_id
++#else
++X509 *q_SSL_get_peer_certificate(SSL *a);
++int q_EVP_PKEY_base_id(EVP_PKEY *a);
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+ QT_END_NAMESPACE
+ 
+ #endif
+diff --git a/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h b/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
+index bf37d07fd8..dbd42fb799 100644
+--- a/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
++++ b/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
+@@ -61,7 +61,11 @@
+ # if !defined(Q_OS_INTEGRITY)
+ #  define WIN_INTERFACE_CUSTOM   // NV
+ # endif // Q_OS_INTEGRITY
+-#endif  // QT_EGL_NO_X11
++#else // QT_EGL_NO_X11
++// If one has an eglplatform.h with https://github.com/KhronosGroup/EGL-Registry/pull/130
++// that needs USE_X11 to be defined.
++# define USE_X11
++#endif
+ 
+ #ifdef QT_EGL_WAYLAND
+ # define WAYLAND // NV
+diff --git a/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+index 159b490ce0..00aa80cd58 100644
+--- a/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
++++ b/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+@@ -567,6 +567,8 @@ void QFontconfigDatabase::populateFontDatabase()
+         fonts = FcFontList(nullptr, pattern, os);
+         FcObjectSetDestroy(os);
+         FcPatternDestroy(pattern);
++        if (!fonts)
++            return;
+     }
+ 
+     for (int i = 0; i < fonts->nfont; i++)
+diff --git a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
+index b713c19447..7cb9a8c79a 100644
+--- a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
++++ b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
+@@ -95,6 +95,7 @@ static constexpr const auto KeyTbl = qMakeArray(
+         Xkb2Qt<XKB_KEY_Clear,                   Qt::Key_Delete>,
+         Xkb2Qt<XKB_KEY_Pause,                   Qt::Key_Pause>,
+         Xkb2Qt<XKB_KEY_Print,                   Qt::Key_Print>,
++        Xkb2Qt<XKB_KEY_Sys_Req,                 Qt::Key_SysReq>,
+         Xkb2Qt<0x1005FF60,                      Qt::Key_SysReq>,         // hardcoded Sun SysReq
+         Xkb2Qt<0x1007ff00,                      Qt::Key_SysReq>,         // hardcoded X386 SysReq
+ 
+@@ -471,7 +472,7 @@ QVector<xkb_keysym_t> QXkbCommon::toKeysym(QKeyEvent *event)
+     } else if (event->modifiers() & Qt::KeypadModifier) {
+         if (qtKey >= Qt::Key_0 && qtKey <= Qt::Key_9)
+             keysyms.append(XKB_KEY_KP_0 + (qtKey - Qt::Key_0));
+-    } else if (isLatin(qtKey) && event->text().isUpper()) {
++    } else if (isLatin1(qtKey) && event->text().isUpper()) {
+         keysyms.append(qtKey);
+     }
+ 
+@@ -523,7 +524,7 @@ int QXkbCommon::keysymToQtKey(xkb_keysym_t keysym, Qt::KeyboardModifiers modifie
+         // With standard shortcuts we should prefer a latin character, this is
+         // for checks like "some qkeyevent == QKeySequence::Copy" to work even
+         // when using for example 'russian' keyboard layout.
+-        if (!QXkbCommon::isLatin(keysym)) {
++        if (!QXkbCommon::isLatin1(keysym)) {
+             xkb_keysym_t latinKeysym = QXkbCommon::lookupLatinKeysym(state, code);
+             if (latinKeysym != XKB_KEY_NoSymbol)
+                 keysym = latinKeysym;
+@@ -546,7 +547,7 @@ static int keysymToQtKey_internal(xkb_keysym_t keysym, Qt::KeyboardModifiers mod
+     } else if (keysym >= XKB_KEY_KP_0 && keysym <= XKB_KEY_KP_9) {
+         // numeric keypad keys
+         qtKey = Qt::Key_0 + (keysym - XKB_KEY_KP_0);
+-    } else if (QXkbCommon::isLatin(keysym)) {
++    } else if (QXkbCommon::isLatin1(keysym)) {
+         qtKey = QXkbCommon::qxkbcommon_xkb_keysym_to_upper(keysym);
+     } else {
+         // check if we have a direct mapping
+@@ -678,7 +679,7 @@ QList<int> QXkbCommon::possibleKeys(xkb_state *state, const QKeyEvent *event,
+         Qt::KeyboardModifiers neededMods = ModsTbl[i];
+         if ((modifiers & neededMods) == neededMods) {
+             if (i == 8) {
+-                if (isLatin(baseQtKey))
++                if (isLatin1(baseQtKey))
+                     continue;
+                 // add a latin key as a fall back key
+                 sym = lookupLatinKeysym(state, keycode);
+@@ -733,7 +734,7 @@ void QXkbCommon::verifyHasLatinLayout(xkb_keymap *keymap)
+     for (xkb_layout_index_t layout = 0; layout < layoutCount; ++layout) {
+         for (xkb_keycode_t code = minKeycode; code < maxKeycode; ++code) {
+             xkb_keymap_key_get_syms_by_level(keymap, code, layout, 0, &keysyms);
+-            if (keysyms && isLatin(keysyms[0]))
++            if (keysyms && isLatin1(keysyms[0]))
+                 nrLatinKeys++;
+             if (nrLatinKeys > 10) // arbitrarily chosen threshold
+                 return;
+@@ -766,7 +767,7 @@ xkb_keysym_t QXkbCommon::lookupLatinKeysym(xkb_state *state, xkb_keycode_t keyco
+         xkb_level_index_t level = xkb_state_key_get_level(state, keycode, layout);
+         if (xkb_keymap_key_get_syms_by_level(keymap, keycode, layout, level, &syms) != 1)
+             continue;
+-        if (isLatin(syms[0])) {
++        if (isLatin1(syms[0])) {
+             sym = syms[0];
+             break;
+         }
+diff --git a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
+index 561eae03db..8389bd8f5a 100644
+--- a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
++++ b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
+@@ -94,8 +94,8 @@ public:
+     static void verifyHasLatinLayout(xkb_keymap *keymap);
+     static xkb_keysym_t lookupLatinKeysym(xkb_state *state, xkb_keycode_t keycode);
+ 
+-    static bool isLatin(xkb_keysym_t sym) {
+-        return ((sym >= 'a' && sym <= 'z') || (sym >= 'A' && sym <= 'Z'));
++    static bool isLatin1(xkb_keysym_t sym) {
++        return sym <= 0xff;
+     }
+     static bool isKeypad(xkb_keysym_t sym) {
+         return sym >= XKB_KEY_KP_Space && sym <= XKB_KEY_KP_9;
+diff --git a/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp b/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
+index 8cd7f9b368..406f84663f 100644
+--- a/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
++++ b/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
+@@ -318,7 +318,7 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources,
+ 
+     if (current < 0 && crtc_mode.clock != 0) {
+         modes << crtc_mode;
+-        current = mode.size() - 1;
++        current = modes.size() - 1;
+     }
+ 
+     if (configuration == OutputConfigCurrent)
+diff --git a/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp b/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
+index 9153fd20bb..255ea5e33e 100644
+--- a/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
++++ b/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
+@@ -194,6 +194,9 @@ QString AtSpiAdaptor::introspect(const QString &path) const
+                 "      <arg direction=\"out\" type=\"(so)\"/>\n"
+                 "      <annotation value=\"QSpiObjectReference\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n"
+                 "    </method>\n"
++                "    <method name=\"GetAccessibleId\">\n"
++                "      <arg direction=\"out\" type=\"s\"/>\n"
++                "    </method>\n"
+                 "  </interface>\n"
+                 );
+ 
+@@ -913,8 +916,17 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+     }
+     case QAccessible::NameChanged: {
+         if (sendObject || sendObject_property_change || sendObject_property_change_accessible_name) {
+-            QString path = pathForInterface(event->accessibleInterface());
+-            QVariantList args = packDBusSignalArguments(QLatin1String("accessible-name"), 0, 0, variantForPath(path));
++            QAccessibleInterface *iface = event->accessibleInterface();
++            if (!iface) {
++                qCDebug(lcAccessibilityAtspi,
++                        "NameChanged event from invalid accessible.");
++                return;
++            }
++
++            QString path = pathForInterface(iface);
++            QVariantList args = packDBusSignalArguments(
++                QLatin1String("accessible-name"), 0, 0,
++                QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Name))));
+             sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                            QLatin1String("PropertyChange"), args);
+         }
+@@ -922,8 +934,17 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+     }
+     case QAccessible::DescriptionChanged: {
+         if (sendObject || sendObject_property_change || sendObject_property_change_accessible_description) {
+-            QString path = pathForInterface(event->accessibleInterface());
+-            QVariantList args = packDBusSignalArguments(QLatin1String("accessible-description"), 0, 0, variantForPath(path));
++            QAccessibleInterface *iface = event->accessibleInterface();
++            if (!iface) {
++                qCDebug(lcAccessibilityAtspi,
++                        "DescriptionChanged event from invalid accessible.");
++                return;
++            }
++
++            QString path = pathForInterface(iface);
++            QVariantList args = packDBusSignalArguments(
++                QLatin1String("accessible-description"), 0, 0,
++                QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Description))));
+             sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                            QLatin1String("PropertyChange"), args);
+         }
+@@ -1038,7 +1059,9 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+                 // Combo Box with AT-SPI likes to be special
+                 // It requires a name-change to update caches and then selection-changed
+                 QString path = pathForInterface(iface);
+-                QVariantList args1 = packDBusSignalArguments(QLatin1String("accessible-name"), 0, 0, variantForPath(path));
++                QVariantList args1 = packDBusSignalArguments(
++                    QLatin1String("accessible-name"), 0, 0,
++                    QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Name))));
+                 sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                                QLatin1String("PropertyChange"), args1);
+                 QVariantList args2 = packDBusSignalArguments(QString(), 0, 0, QVariant::fromValue(QDBusVariant(QVariant(0))));
+@@ -1358,6 +1381,26 @@ void AtSpiAdaptor::registerApplication()
+     delete registry;
+ }
+ 
++namespace {
++QString accessibleIdForAccessible(QAccessibleInterface *accessible)
++{
++    QString result;
++    while (accessible) {
++        if (!result.isEmpty())
++            result.prepend(QLatin1Char('.'));
++        if (auto obj = accessible->object()) {
++            const QString name = obj->objectName();
++            if (!name.isEmpty())
++                result.prepend(name);
++            else
++                result.prepend(QString::fromUtf8(obj->metaObject()->className()));
++        }
++        accessible = accessible->parent();
++    }
++    return result;
++}
++} // namespace
++
+ // Accessible
+ bool AtSpiAdaptor::accessibleInterface(QAccessibleInterface *interface, const QString &function, const QDBusMessage &message, const QDBusConnection &connection)
+ {
+@@ -1441,6 +1484,9 @@ bool AtSpiAdaptor::accessibleInterface(QAccessibleInterface *interface, const QS
+             children << ref;
+         }
+         connection.send(message.createReply(QVariant::fromValue(children)));
++    } else if (function == QLatin1String("GetAccessibleId")) {
++        sendReply(connection, message,
++                  QVariant::fromValue(QDBusVariant(accessibleIdForAccessible(interface))));
+     } else {
+         qCDebug(lcAccessibilityAtspi) << "WARNING: AtSpiAdaptor::accessibleInterface does not implement " << function << message.path();
+         return false;
+diff --git a/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp b/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
+index 45ddc8e496..cc734abc63 100644
+--- a/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
++++ b/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
+@@ -69,6 +69,21 @@ QT_BEGIN_NAMESPACE
+ DBusConnection::DBusConnection(QObject *parent)
+     : QObject(parent), m_a11yConnection(QString()), m_enabled(false)
+ {
++    // If the bus is explicitly set via env var it overrides everything else.
++    QByteArray addressEnv = qgetenv("AT_SPI_BUS_ADDRESS");
++    if (!addressEnv.isEmpty()) {
++        // Only connect on next loop run, connections to our enabled signal are
++        // only established after the ctor returns.
++        QMetaObject::invokeMethod(
++                this,
++                [this, addressEnv] {
++                    m_enabled = true;
++                    connectA11yBus(QString::fromLocal8Bit(addressEnv));
++                },
++                Qt::QueuedConnection);
++        return;
++    }
++
+     // Start monitoring if "org.a11y.Bus" is registered as DBus service.
+     QDBusConnection c = QDBusConnection::sessionBus();
+     if (!c.isConnected()) {
+diff --git a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
+index 1a3cab275d..2abe039126 100644
+--- a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
++++ b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
+@@ -51,6 +51,9 @@
+ #include <QtCore/QStandardPaths>
+ #include <QtCore/QUrl>
+ 
++#include <QtGui/QGuiApplication>
++#include <QtGui/QWindow>
++
+ #if QT_CONFIG(dbus)
+ // These QtCore includes are needed for xdg-desktop-portal support
+ #include <QtCore/private/qcore_unix_p.h>
+@@ -58,6 +61,8 @@
+ #include <QtCore/QFileInfo>
+ #include <QtCore/QUrlQuery>
+ 
++#include <QtGui/QColor>
++
+ #include <QtDBus/QDBusConnection>
+ #include <QtDBus/QDBusMessage>
+ #include <QtDBus/QDBusPendingCall>
+@@ -142,6 +147,8 @@ static inline bool detectWebBrowser(const QByteArray &desktop,
+     }
+ 
+     if (desktop == QByteArray("KDE")) {
++        if (checkExecutable(QStringLiteral("kde-open5"), browser))
++            return true;
+         // Konqueror launcher
+         if (checkExecutable(QStringLiteral("kfmclient"), browser)) {
+             browser->append(QLatin1String(" exec"));
+@@ -296,8 +303,135 @@ static inline QDBusMessage xdgDesktopPortalSendEmail(const QUrl &url)
+ 
+     return QDBusConnection::sessionBus().call(message);
+ }
++
++namespace {
++struct XDGDesktopColor
++{
++    double r = 0;
++    double g = 0;
++    double b = 0;
++
++    QColor toQColor() const
++    {
++        constexpr auto rgbMax = 255;
++        return { static_cast<int>(r * rgbMax), static_cast<int>(g * rgbMax),
++                 static_cast<int>(b * rgbMax) };
++    }
++};
++
++const QDBusArgument &operator>>(const QDBusArgument &argument, XDGDesktopColor &myStruct)
++{
++    argument.beginStructure();
++    argument >> myStruct.r >> myStruct.g >> myStruct.b;
++    argument.endStructure();
++    return argument;
++}
++
++class XdgDesktopPortalColorPicker : public QPlatformServiceColorPicker
++{
++    Q_OBJECT
++public:
++    XdgDesktopPortalColorPicker(const QString &parentWindowId, QWindow *parent)
++        : QPlatformServiceColorPicker(parent), m_parentWindowId(parentWindowId)
++    {
++    }
++
++    void pickColor() override
++    {
++        // DBus signature:
++        // PickColor (IN   s      parent_window,
++        //            IN   a{sv}  options
++        //            OUT  o      handle)
++        // Options:
++        // handle_token (s) -  A string that will be used as the last element of the @handle.
++
++        QDBusMessage message = QDBusMessage::createMethodCall(
++                QStringLiteral("org.freedesktop.portal.Desktop"), QStringLiteral("/org/freedesktop/portal/desktop"),
++                QStringLiteral("org.freedesktop.portal.Screenshot"), QStringLiteral("PickColor"));
++        message << m_parentWindowId << QVariantMap();
++
++        QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
++        auto watcher = new QDBusPendingCallWatcher(pendingCall, this);
++        connect(watcher, &QDBusPendingCallWatcher::finished, this,
++                [this](QDBusPendingCallWatcher *watcher) {
++                    watcher->deleteLater();
++                    QDBusPendingReply<QDBusObjectPath> reply = *watcher;
++                    if (reply.isError()) {
++                        qWarning("DBus call to pick color failed: %s",
++                                 qPrintable(reply.error().message()));
++                        Q_EMIT colorPicked({});
++                    } else {
++                        QDBusConnection::sessionBus().connect(
++                                QStringLiteral("org.freedesktop.portal.Desktop"), reply.value().path(),
++                                QStringLiteral("org.freedesktop.portal.Request"), QStringLiteral("Response"), this,
++                                // clang-format off
++                                SLOT(gotColorResponse(uint,QVariantMap))
++                                // clang-format on
++                        );
++                    }
++                });
++    }
++
++private Q_SLOTS:
++    void gotColorResponse(uint result, const QVariantMap &map)
++    {
++        if (result != 0)
++            return;
++        XDGDesktopColor color{};
++        map.value(QStringLiteral("color")).value<QDBusArgument>() >> color;
++        Q_EMIT colorPicked(color.toQColor());
++        deleteLater();
++    }
++
++private:
++    const QString m_parentWindowId;
++};
++} // namespace
++
+ #endif // QT_CONFIG(dbus)
+ 
++QGenericUnixServices::QGenericUnixServices()
++{
++#if QT_CONFIG(dbus)
++    if (qEnvironmentVariableIntValue("QT_NO_XDG_DESKTOP_PORTAL") > 0) {
++        return;
++    }
++    QDBusMessage message = QDBusMessage::createMethodCall(
++            QStringLiteral("org.freedesktop.portal.Desktop"), QStringLiteral("/org/freedesktop/portal/desktop"),
++            QStringLiteral("org.freedesktop.DBus.Properties"), QStringLiteral("Get"));
++    message << QStringLiteral("org.freedesktop.portal.Screenshot")
++            << QStringLiteral("version");
++
++    QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
++    auto watcher = new QDBusPendingCallWatcher(pendingCall);
++    QObject::connect(watcher, &QDBusPendingCallWatcher::finished, watcher,
++                     [this](QDBusPendingCallWatcher *watcher) {
++                         watcher->deleteLater();
++                         QDBusPendingReply<QVariant> reply = *watcher;
++                         if (!reply.isError() && reply.value().toUInt() >= 2)
++                             m_hasScreenshotPortalWithColorPicking = true;
++                     });
++
++#endif
++}
++
++QPlatformServiceColorPicker *QGenericUnixServices::colorPicker(QWindow *parent)
++{
++#if QT_CONFIG(dbus)
++    // Make double sure that we are in a wayland environment. In particular check
++    // WAYLAND_DISPLAY so also XWayland apps benefit from portal-based color picking.
++    // Outside wayland we'll rather rely on other means than the XDG desktop portal.
++    if (!qEnvironmentVariableIsEmpty("WAYLAND_DISPLAY")
++        || QGuiApplication::platformName().startsWith(QLatin1String("wayland"))) {
++        return new XdgDesktopPortalColorPicker(portalWindowIdentifier(parent), parent);
++    }
++    return nullptr;
++#else
++    Q_UNUSED(parent);
++    return nullptr;
++#endif
++}
++
+ QByteArray QGenericUnixServices::desktopEnvironment() const
+ {
+     static const QByteArray result = detectDesktopEnvironment();
+@@ -352,6 +486,8 @@ bool QGenericUnixServices::openDocument(const QUrl &url)
+ }
+ 
+ #else
++QGenericUnixServices::QGenericUnixServices() = default;
++
+ QByteArray QGenericUnixServices::desktopEnvironment() const
+ {
+     return QByteArrayLiteral("UNKNOWN");
+@@ -371,6 +507,30 @@ bool QGenericUnixServices::openDocument(const QUrl &url)
+     return false;
+ }
+ 
++QPlatformServiceColorPicker *QGenericUnixServices::colorPicker(QWindow *parent)
++{
++    Q_UNUSED(parent);
++    return nullptr;
++}
++
+ #endif // QT_NO_MULTIPROCESS
+ 
++QString QGenericUnixServices::portalWindowIdentifier(QWindow *window)
++{
++    if (QGuiApplication::platformName() == QLatin1String("xcb"))
++        return QStringLiteral("x11:") + QString::number(window->winId(), 16);
++    return QString();
++}
++
++bool QGenericUnixServices::hasCapability(Capability capability) const
++{
++    switch (capability) {
++    case Capability::ColorPicking:
++        return m_hasScreenshotPortalWithColorPicking;
++    }
++    return false;
++}
++
+ QT_END_NAMESPACE
++
++#include "qgenericunixservices.moc"
+diff --git a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
+index 8ac3de6f03..30924e64bd 100644
+--- a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
++++ b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
+@@ -59,16 +59,21 @@ QT_BEGIN_NAMESPACE
+ class QGenericUnixServices : public QPlatformServices
+ {
+ public:
+-    QGenericUnixServices() {}
++    QGenericUnixServices();
+ 
+     QByteArray desktopEnvironment() const override;
+ 
++    bool hasCapability(Capability capability) const override;
+     bool openUrl(const QUrl &url) override;
+     bool openDocument(const QUrl &url) override;
++    QPlatformServiceColorPicker *colorPicker(QWindow *parent = nullptr) override;
++
++    virtual QString portalWindowIdentifier(QWindow *window);
+ 
+ private:
+     QString m_webBrowser;
+     QString m_documentLauncher;
++    bool m_hasScreenshotPortalWithColorPicking = false;
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
+index 09470bccc6..cc7c7d4d8a 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
+@@ -69,6 +69,7 @@ const QString MenuBarPath = QLatin1String("/MenuBar");
+ */
+ QDBusMenuConnection::QDBusMenuConnection(QObject *parent, const QString &serviceName)
+     : QObject(parent)
++    , m_serviceName(serviceName)
+     , m_connection(serviceName.isNull() ? QDBusConnection::sessionBus()
+                                         : QDBusConnection::connectToBus(QDBusConnection::SessionBus, serviceName))
+     , m_dbusWatcher(new QDBusServiceWatcher(StatusNotifierWatcherService, m_connection, QDBusServiceWatcher::WatchForRegistration, this))
+@@ -83,6 +84,12 @@ QDBusMenuConnection::QDBusMenuConnection(QObject *parent, const QString &service
+ #endif
+ }
+ 
++QDBusMenuConnection::~QDBusMenuConnection()
++{
++  if (!m_serviceName.isEmpty() && m_connection.isConnected())
++      QDBusConnection::disconnectFromBus(m_serviceName);
++}
++
+ void QDBusMenuConnection::dbusError(const QDBusError &error)
+ {
+     qWarning() << "QDBusTrayIcon encountered a D-Bus error:" << error;
+@@ -105,13 +112,7 @@ void QDBusMenuConnection::unregisterTrayIconMenu(QDBusTrayIcon *item)
+ 
+ bool QDBusMenuConnection::registerTrayIcon(QDBusTrayIcon *item)
+ {
+-    bool success = connection().registerService(item->instanceId());
+-    if (!success) {
+-        qWarning() << "failed to register service" << item->instanceId();
+-        return false;
+-    }
+-
+-    success = connection().registerObject(StatusNotifierItemPath, item);
++    bool success = connection().registerObject(StatusNotifierItemPath, item);
+     if (!success) {
+         unregisterTrayIcon(item);
+         qWarning() << "failed to register" << item->instanceId() << StatusNotifierItemPath;
+@@ -126,21 +127,18 @@ bool QDBusMenuConnection::registerTrayIcon(QDBusTrayIcon *item)
+ 
+ bool QDBusMenuConnection::registerTrayIconWithWatcher(QDBusTrayIcon *item)
+ {
++    Q_UNUSED(item);
+     QDBusMessage registerMethod = QDBusMessage::createMethodCall(
+                 StatusNotifierWatcherService, StatusNotifierWatcherPath, StatusNotifierWatcherService,
+                 QLatin1String("RegisterStatusNotifierItem"));
+-    registerMethod.setArguments(QVariantList() << item->instanceId());
++    registerMethod.setArguments(QVariantList() << m_connection.baseService());
+     return m_connection.callWithCallback(registerMethod, this, SIGNAL(trayIconRegistered()), SLOT(dbusError(QDBusError)));
+ }
+ 
+-bool QDBusMenuConnection::unregisterTrayIcon(QDBusTrayIcon *item)
++void QDBusMenuConnection::unregisterTrayIcon(QDBusTrayIcon *item)
+ {
+     unregisterTrayIconMenu(item);
+     connection().unregisterObject(StatusNotifierItemPath);
+-    bool success = connection().unregisterService(item->instanceId());
+-    if (!success)
+-        qWarning() << "failed to unregister service" << item->instanceId();
+-    return success;
+ }
+ #endif // QT_NO_SYSTEMTRAYICON
+ 
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
+index f484795fbb..97bdfabb85 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
++++ b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
+@@ -70,6 +70,7 @@ class QDBusMenuConnection : public QObject
+ 
+ public:
+     QDBusMenuConnection(QObject *parent = nullptr, const QString &serviceName = QString());
++    ~QDBusMenuConnection();
+     QDBusConnection connection() const { return m_connection; }
+     QDBusServiceWatcher *dbusWatcher() const { return m_dbusWatcher; }
+     bool isStatusNotifierHostRegistered() const { return m_statusNotifierHostRegistered; }
+@@ -78,7 +79,7 @@ public:
+     void unregisterTrayIconMenu(QDBusTrayIcon *item);
+     bool registerTrayIcon(QDBusTrayIcon *item);
+     bool registerTrayIconWithWatcher(QDBusTrayIcon *item);
+-    bool unregisterTrayIcon(QDBusTrayIcon *item);
++    void unregisterTrayIcon(QDBusTrayIcon *item);
+ #endif // QT_NO_SYSTEMTRAYICON
+ 
+ Q_SIGNALS:
+@@ -90,6 +91,7 @@ private Q_SLOTS:
+     void dbusError(const QDBusError &error);
+ 
+ private:
++    QString m_serviceName;
+     QDBusConnection m_connection;
+     QDBusServiceWatcher *m_dbusWatcher;
+     bool m_statusNotifierHostRegistered;
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp b/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
+index bede70975a..76bfec5e5a 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
+@@ -71,8 +71,12 @@ Q_LOGGING_CATEGORY(qLcTray, "qt.qpa.tray")
+ static QString iconTempPath()
+ {
+     QString tempPath = QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation);
+-    if (!tempPath.isEmpty())
++    if (!tempPath.isEmpty()) {
++        QString flatpakId = qEnvironmentVariable("FLATPAK_ID");
++        if (!flatpakId.isEmpty() && QFileInfo::exists(QLatin1String("/.flatpak-info")))
++            tempPath += QLatin1String("/app/") + flatpakId;
+         return tempPath;
++    }
+ 
+     tempPath = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation);
+ 
+diff --git a/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+index cb1b39db64..6e01af052c 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+@@ -755,6 +755,9 @@ QVariant QGnomeTheme::themeHint(QPlatformTheme::ThemeHint hint) const
+         return QVariant(QChar(0x2022));
+     case QPlatformTheme::UiEffects:
+         return QVariant(int(HoverEffect));
++    case QPlatformTheme::ButtonPressKeys:
++        return QVariant::fromValue(
++                QList<Qt::Key>({ Qt::Key_Space, Qt::Key_Return, Qt::Key_Enter, Qt::Key_Select }));
+     default:
+         break;
+     }
+diff --git a/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp b/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
+index 98e05195ee..1e92f43dec 100644
+--- a/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
++++ b/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
+@@ -343,8 +343,7 @@ void QEglFSCursor::paintOnScreen()
+     // screens are siblings of each other. When not enabled, the sibling list
+     // only contains m_screen itself.
+     for (QPlatformScreen *screen : m_screen->virtualSiblings()) {
+-        if (screen->geometry().contains(cr.topLeft().toPoint() + m_cursor.hotSpot)
+-            && QOpenGLContext::currentContext()->screen() == screen->screen())
++        if (screen->geometry().contains(cr.topLeft().toPoint() + m_cursor.hotSpot))
+         {
+             cr.translate(-screen->geometry().topLeft());
+             const QSize screenSize = screen->geometry().size();
+@@ -468,11 +467,12 @@ void QEglFSCursor::draw(const QRectF &r)
+ {
+     StateSaver stateSaver;
+ 
+-    QEglFSCursorData &gfx = static_cast<QEglFSContext*>(QOpenGLContext::currentContext()->handle())->cursorData;
+-    if (!gfx.program) {
+-        // one time initialization
++    // one time initialization
++    if (!QOpenGLFunctions::d_ptr)
+         initializeOpenGLFunctions();
+ 
++    QEglFSCursorData &gfx = static_cast<QEglFSContext*>(QOpenGLContext::currentContext()->handle())->cursorData;
++    if (!gfx.program) {
+         createShaderPrograms();
+ 
+         if (!gfx.atlasTexture) {
+diff --git a/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp b/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
+index 645a0ae2e9..3e0e406f1a 100644
+--- a/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
++++ b/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
+@@ -179,7 +179,7 @@ void QEglFSKmsEventReader::create(QEglFSKmsDevice *device)
+ 
+     m_device = device;
+ 
+-    qCDebug(qLcEglfsKmsDebug, "Initalizing event reader for device %p fd %d",
++    qCDebug(qLcEglfsKmsDebug, "Initializing event reader for device %p fd %d",
+             m_device, m_device->fd());
+ 
+     m_thread = new QEglFSKmsEventReaderThread(m_device->fd());
+diff --git a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
+index 141fb68a23..d4294d425a 100644
+--- a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
++++ b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
+@@ -122,11 +122,13 @@ QOffscreenIntegration::QOffscreenIntegration()
+ #endif
+     m_services.reset(new QPlatformServices);
+ 
+-    QWindowSystemInterface::handleScreenAdded(new QOffscreenScreen);
++    m_screen = new QOffscreenScreen;
++    QWindowSystemInterface::handleScreenAdded(m_screen);
+ }
+ 
+ QOffscreenIntegration::~QOffscreenIntegration()
+ {
++    QWindowSystemInterface::handleScreenRemoved(m_screen);
+ }
+ 
+ void QOffscreenIntegration::initialize()
+diff --git a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
+index 0ea90f6c2f..fe00fde07c 100644
+--- a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
++++ b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
+@@ -84,6 +84,7 @@ protected:
+ #endif
+     QScopedPointer<QPlatformInputContext> m_inputContext;
+     QScopedPointer<QPlatformServices> m_services;
++    QPlatformScreen *m_screen;
+     mutable QScopedPointer<QPlatformNativeInterface> m_nativeInterface;
+ };
+ 
+diff --git a/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp b/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
+index 6fa5a8a2b3..1f49f0aefd 100644
+--- a/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
++++ b/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
+@@ -48,6 +48,7 @@
+ #include <qpa/qplatformnativeinterface.h>
+ #include <QtPlatformHeaders/qwglnativecontext.h>
+ 
++#include <private/qsystemlibrary_p.h>
+ #include <algorithm>
+ 
+ #include <wingdi.h>
+@@ -162,19 +163,25 @@ QFunctionPointer QWindowsOpengl32DLL::resolve(const char *name)
+ 
+ bool QWindowsOpengl32DLL::init(bool softwareRendering)
+ {
+-    const QByteArray opengl32 = QByteArrayLiteral("opengl32.dll");
+-    const QByteArray swopengl = QByteArrayLiteral("opengl32sw.dll");
++    const QByteArray opengl32 = QByteArrayLiteral("opengl32");
++    const QByteArray swopengl = QByteArrayLiteral("opengl32sw");
++    bool useSystemLib = false;
+ 
+     QByteArray openglDll = qgetenv("QT_OPENGL_DLL");
+-    if (openglDll.isEmpty())
++    if (openglDll.isEmpty()) {
+         openglDll = softwareRendering ? swopengl : opengl32;
++        useSystemLib = !softwareRendering;
++    }
+ 
+     openglDll = openglDll.toLower();
+     m_nonOpengl32 = openglDll != opengl32;
+ 
+     qCDebug(lcQpaGl) << "Qt: Using WGL and OpenGL from" << openglDll;
+ 
+-    m_lib = ::LoadLibraryA(openglDll.constData());
++    if (useSystemLib)
++        m_lib = QSystemLibrary::load((wchar_t*)(QString::fromLatin1(openglDll).utf16()));
++    else
++        m_lib = LoadLibraryA(openglDll.constData());
+     if (!m_lib) {
+         qErrnoWarning(::GetLastError(), "Failed to load %s", openglDll.constData());
+         return false;
+@@ -184,7 +191,7 @@ bool QWindowsOpengl32DLL::init(bool softwareRendering)
+         // Load opengl32.dll always. GDI functions like ChoosePixelFormat do
+         // GetModuleHandle for opengl32.dll and behave differently (and call back into
+         // opengl32) when the module is present. This is fine for dummy contexts and windows.
+-        ::LoadLibraryA("opengl32.dll");
++        QSystemLibrary::load(L"opengl32");
+     }
+ 
+     wglCreateContext = reinterpret_cast<HGLRC (WINAPI *)(HDC)>(resolve("wglCreateContext"));
+diff --git a/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp b/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
+index d7d186e804..9eb4011bf2 100644
+--- a/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
++++ b/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
+@@ -49,6 +49,7 @@
+ #include <QtCore/qstandardpaths.h>
+ #include <QtCore/qlibraryinfo.h>
+ #include <QtCore/qhash.h>
++#include <private/qsystemlibrary_p.h>
+ 
+ #ifndef QT_NO_OPENGL
+ #include <private/qopengl_p.h>
+@@ -396,7 +397,7 @@ bool QWindowsOpenGLTester::testDesktopGL()
+ 
+     // Test #1: Load opengl32.dll and try to resolve an OpenGL 2 function.
+     // This will typically fail on systems that do not have a real OpenGL driver.
+-    lib = LoadLibraryA("opengl32.dll");
++    lib = QSystemLibrary::load(L"opengl32");
+     if (lib) {
+         CreateContext = reinterpret_cast<CreateContextType>(
+             reinterpret_cast<QFunctionPointer>(::GetProcAddress(lib, "wglCreateContext")));
+diff --git a/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp b/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
+index 1afa00cfc9..118af6ce73 100644
+--- a/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
++++ b/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
+@@ -41,6 +41,7 @@
+ 
+ #include <QRect>
+ #include <QList>
++#include <QMap>
+ #include <QDebug>
+ 
+ #include <qmath.h>
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp b/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
+index 9e2a37a6a1..e6e175a118 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
+@@ -488,12 +488,12 @@ void QXcbConnection::printXcbError(const char *message, xcb_generic_error_t *err
+     uint clamped_error_code = qMin<uint>(error->error_code, (sizeof(xcb_errors) / sizeof(xcb_errors[0])) - 1);
+     uint clamped_major_code = qMin<uint>(error->major_code, (sizeof(xcb_protocol_request_codes) / sizeof(xcb_protocol_request_codes[0])) - 1);
+ 
+-    qCWarning(lcQpaXcb, "%s: %d (%s), sequence: %d, resource id: %d, major code: %d (%s), minor code: %d",
+-             message,
+-             int(error->error_code), xcb_errors[clamped_error_code],
+-             int(error->sequence), int(error->resource_id),
+-             int(error->major_code), xcb_protocol_request_codes[clamped_major_code],
+-             int(error->minor_code));
++    qCDebug(lcQpaXcb, "%s: %d (%s), sequence: %d, resource id: %d, major code: %d (%s), minor code: %d",
++            message,
++            int(error->error_code), xcb_errors[clamped_error_code],
++            int(error->sequence), int(error->resource_id),
++            int(error->major_code), xcb_protocol_request_codes[clamped_major_code],
++            int(error->minor_code));
+ }
+ 
+ static Qt::MouseButtons translateMouseButtons(int s)
+@@ -702,6 +702,8 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
+             QXcbVirtualDesktop *virtualDesktop = virtualDesktopForRootWindow(propertyNotify->window);
+             if (virtualDesktop)
+                 virtualDesktop->updateWorkArea();
++        } else if (propertyNotify->atom == atom(QXcbAtom::_NET_SUPPORTED)) {
++            m_wmSupport->updateNetWMAtoms();
+         } else {
+             HANDLE_PLATFORM_WINDOW_EVENT(xcb_property_notify_event_t, window, handlePropertyNotifyEvent);
+         }
+@@ -750,7 +752,7 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
+                 case XCB_XKB_NEW_KEYBOARD_NOTIFY: {
+                     xcb_xkb_new_keyboard_notify_event_t *ev = &xkb_event->new_keyboard_notify;
+                     if (ev->changed & XCB_XKB_NKN_DETAIL_KEYCODES)
+-                        m_keyboard->updateKeymap(ev);
++                        m_keyboard->updateKeymap();
+                     break;
+                 }
+                 default:
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp b/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
+index 76869ced60..02d2eebb56 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
+@@ -274,8 +274,7 @@ QPlatformWindow *QXcbIntegration::createForeignWindow(QWindow *window, WId nativ
+ #ifndef QT_NO_OPENGL
+ QPlatformOpenGLContext *QXcbIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
+ {
+-    QXcbScreen *screen = static_cast<QXcbScreen *>(context->screen()->handle());
+-    QXcbGlIntegration *glIntegration = screen->connection()->glIntegration();
++    QXcbGlIntegration *glIntegration = defaultConnection()->glIntegration();
+     if (!glIntegration) {
+         qWarning("QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled");
+         return nullptr;
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+index efecd7e2d1..e8286381a2 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+@@ -365,17 +365,6 @@ void QXcbKeyboard::updateKeymap(xcb_mapping_notify_event_t *event)
+     updateKeymap();
+ }
+ 
+-void QXcbKeyboard::updateKeymap(xcb_xkb_new_keyboard_notify_event_t *event)
+-{
+-    if (!event)
+-        return;
+-
+-    if (event->deviceID != event->oldDeviceID)
+-        m_config = false;
+-
+-    updateKeymap();
+-}
+-
+ void QXcbKeyboard::updateKeymap()
+ {
+     KeysymModifierMap keysymMods;
+@@ -383,6 +372,8 @@ void QXcbKeyboard::updateKeymap()
+         keysymMods = keysymsToModifiers();
+     updateModifiers(keysymMods);
+ 
++    m_config = true;
++
+     if (!m_xkbContext) {
+         m_xkbContext.reset(xkb_context_new(XKB_CONTEXT_NO_DEFAULT_INCLUDES));
+         if (!m_xkbContext) {
+@@ -398,13 +389,8 @@ void QXcbKeyboard::updateKeymap()
+     if (connection()->hasXKB()) {
+         m_xkbKeymap.reset(xkb_x11_keymap_new_from_device(m_xkbContext.get(), xcb_connection(),
+                                                          core_device_id, XKB_KEYMAP_COMPILE_NO_FLAGS));
+-        if (m_xkbKeymap) {
+-            if (m_config)
+-                m_xkbState.reset(xkb_state_new(m_xkbKeymap.get()));
+-            else
+-                m_xkbState.reset(xkb_x11_state_new_from_device(m_xkbKeymap.get(), xcb_connection(), core_device_id));
+-
+-        }
++        if (m_xkbKeymap)
++            m_xkbState.reset(xkb_x11_state_new_from_device(m_xkbKeymap.get(), xcb_connection(), core_device_id));
+     } else {
+         m_xkbKeymap.reset(keymapFromCore(keysymMods));
+         if (m_xkbKeymap)
+@@ -425,8 +411,6 @@ void QXcbKeyboard::updateKeymap()
+     updateXKBMods();
+ 
+     QXkbCommon::verifyHasLatinLayout(m_xkbKeymap.get());
+-
+-    m_config = true;
+ }
+ 
+ QList<int> QXcbKeyboard::possibleKeys(const QKeyEvent *event) const
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
+index b652c85fe3..0ee08aeff2 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
++++ b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
+@@ -69,7 +69,6 @@ public:
+ 
+     Qt::KeyboardModifiers translateModifiers(int s) const;
+     void updateKeymap(xcb_mapping_notify_event_t *event);
+-    void updateKeymap(xcb_xkb_new_keyboard_notify_event_t *event);
+     void updateKeymap();
+     QList<int> possibleKeys(const QKeyEvent *event) const;
+ 
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp b/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
+index ffda7b6a57..863e961f4c 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
+@@ -564,11 +564,6 @@ void QXcbWindow::setGeometry(const QRect &rect)
+ {
+     QPlatformWindow::setGeometry(rect);
+ 
+-    if (shouldDeferTask(Task::SetGeometry)) {
+-        m_deferredGeometry = rect;
+-        return;
+-    }
+-
+     propagateSizeHints();
+ 
+     QXcbScreen *currentScreen = xcbScreen();
+@@ -693,9 +688,6 @@ void QXcbWindow::setVisible(bool visible)
+ 
+ void QXcbWindow::show()
+ {
+-    if (shouldDeferTask(Task::Map))
+-        return;
+-
+     if (window()->isTopLevel()) {
+ 
+         // update WM_NORMAL_HINTS
+@@ -706,7 +698,7 @@ void QXcbWindow::show()
+         if (isTransient(window())) {
+             const QWindow *tp = window()->transientParent();
+             if (tp && tp->handle())
+-                transientXcbParent = static_cast<const QXcbWindow *>(tp->handle())->winId();
++                transientXcbParent = tp->handle()->winId();
+             // Default to client leader if there is no transient parent, else modal dialogs can
+             // be hidden by their parents.
+             if (!transientXcbParent)
+@@ -746,10 +738,6 @@ void QXcbWindow::show()
+ 
+ void QXcbWindow::hide()
+ {
+-    if (shouldDeferTask(Task::Unmap))
+-        return;
+-
+-    m_wmStateValid = false;
+     xcb_unmap_window(xcb_connection(), m_window);
+ 
+     // send synthetic UnmapNotify event according to icccm 4.1.4
+@@ -909,9 +897,6 @@ QXcbWindow::NetWmStates QXcbWindow::netWmStates()
+ 
+ void QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
+ {
+-    if (shouldDeferTask(Task::SetWindowFlags))
+-        return;
+-
+     Qt::WindowType type = static_cast<Qt::WindowType>(int(flags & Qt::WindowType_Mask));
+ 
+     if (type == Qt::ToolTip)
+@@ -941,8 +926,6 @@ void QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
+ 
+     setTransparentForMouseEvents(flags & Qt::WindowTransparentForInput);
+     updateDoesNotAcceptFocus(flags & Qt::WindowDoesNotAcceptFocus);
+-
+-    m_isWmManagedWindow = !(flags & Qt::X11BypassWindowManagerHint);
+ }
+ 
+ void QXcbWindow::setMotifWmHints(Qt::WindowFlags flags)
+@@ -1142,9 +1125,6 @@ void QXcbWindow::setWindowState(Qt::WindowStates state)
+     if (state == m_windowState)
+         return;
+ 
+-    if (shouldDeferTask(Task::SetWindowState))
+-        return;
+-
+     // unset old state
+     if (m_windowState & Qt::WindowMinimized)
+         xcb_map_window(xcb_connection(), m_window);
+@@ -1350,6 +1330,12 @@ void QXcbWindow::setWindowIcon(const QIcon &icon)
+     }
+ 
+     if (!icon_data.isEmpty()) {
++        // Ignore icon exceeding maximum xcb request length
++        if (icon_data.size() > xcb_get_maximum_request_length(xcb_connection())) {
++            qWarning("Ignoring window icon: Size %llu exceeds maximum xcb request length %u.",
++                     icon_data.size(), xcb_get_maximum_request_length(xcb_connection()));
++            return;
++        }
+         xcb_change_property(xcb_connection(),
+                             XCB_PROP_MODE_REPLACE,
+                             m_window,
+@@ -1639,7 +1625,7 @@ void QXcbWindow::setWmWindowType(QXcbWindowFunctions::WmWindowTypes types, Qt::W
+         break;
+     }
+ 
+-    if ((flags & Qt::FramelessWindowHint) && !(type & QXcbWindowFunctions::KdeOverride)) {
++    if ((flags & Qt::FramelessWindowHint) && !(types & QXcbWindowFunctions::KdeOverride)) {
+         // override netwm type - quick and easy for KDE noborder
+         atoms.append(atom(QXcbAtom::_KDE_NET_WM_WINDOW_TYPE_OVERRIDE));
+     }
+@@ -1894,10 +1880,6 @@ void QXcbWindow::handleUnmapNotifyEvent(const xcb_unmap_notify_event_t *event)
+     if (event->window == m_window) {
+         m_mapped = false;
+         QWindowSystemInterface::handleExposeEvent(window(), QRegion());
+-        if (!m_isWmManagedWindow || parent()) {
+-            m_wmStateValid = true;
+-            handleDeferredTasks();
+-        }
+     }
+ }
+ 
+@@ -2212,98 +2194,30 @@ void QXcbWindow::handleLeaveNotifyEvent(const xcb_leave_notify_event_t *event)
+     handleLeaveNotifyEvent(event->root_x, event->root_y, event->mode, event->detail, event->time);
+ }
+ 
+-bool QXcbWindow::shouldDeferTask(Task task)
+-{
+-    if (m_wmStateValid)
+-        return false;
+-
+-    m_deferredTasks.append(task);
+-    return true;
+-}
+-
+-void QXcbWindow::handleDeferredTasks()
+-{
+-    Q_ASSERT(m_wmStateValid == true);
+-    if (m_deferredTasks.isEmpty())
+-        return;
+-
+-    bool map = false;
+-    bool unmap = false;
+-
+-    QVector<Task> tasks;
+-    for (auto taskIt = m_deferredTasks.rbegin(); taskIt != m_deferredTasks.rend(); ++taskIt) {
+-        if (!tasks.contains(*taskIt))
+-            tasks.prepend(*taskIt);
+-    }
+-
+-    for (Task task : tasks) {
+-        switch (task) {
+-        case Task::Map:
+-            map = true;
+-            unmap = false;
+-            break;
+-        case Task::Unmap:
+-            unmap = true;
+-            map = false;
+-            break;
+-        case Task::SetGeometry:
+-            setGeometry(m_deferredGeometry);
+-            break;
+-        case Task::SetWindowFlags:
+-            setWindowFlags(window()->flags());
+-            break;
+-        case Task::SetWindowState:
+-            setWindowState(window()->windowState());
+-            break;
+-        }
+-    }
+-    m_deferredTasks.clear();
+-
+-    if (map) {
+-        Q_ASSERT(unmap == false);
+-        show();
+-    }
+-    if (unmap) {
+-        Q_ASSERT(map == false);
+-        hide();
+-    }
+-}
+-
+ void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *event)
+ {
+     connection()->setTime(event->time);
+ 
+-    const bool wmStateChanged = event->atom == atom(QXcbAtom::WM_STATE);
+-    const bool netWmStateChanged = event->atom == atom(QXcbAtom::_NET_WM_STATE);
+-    if (netWmStateChanged || wmStateChanged) {
+-        if (wmStateChanged && !m_wmStateValid && m_isWmManagedWindow) {
+-            // ICCCM 4.1.4
+-            // Clients that want to re-use a client window (e.g. by mapping it again)
+-            // after withdrawing it must wait for the withdrawal to be complete before
+-            // proceeding. The preferred method for doing this is for clients to wait for
+-            // a window manager to update or remove the WM_STATE property.
+-            m_wmStateValid = true;
+-            handleDeferredTasks();
+-        }
+-        if (event->state == XCB_PROPERTY_DELETE)
++    const bool propertyDeleted = event->state == XCB_PROPERTY_DELETE;
++
++    if (event->atom == atom(QXcbAtom::_NET_WM_STATE) || event->atom == atom(QXcbAtom::WM_STATE)) {
++        if (propertyDeleted)
+             return;
+ 
+-        if (wmStateChanged) {
++        Qt::WindowStates newState = Qt::WindowNoState;
++
++        if (event->atom == atom(QXcbAtom::WM_STATE)) { // WM_STATE: Quick check for 'Minimize'.
+             auto reply = Q_XCB_REPLY(xcb_get_property, xcb_connection(),
+                                      0, m_window, atom(QXcbAtom::WM_STATE),
+                                      XCB_ATOM_ANY, 0, 1024);
+             if (reply && reply->format == 32 && reply->type == atom(QXcbAtom::WM_STATE)) {
+-                auto data = static_cast<const quint32 *>(xcb_get_property_value(reply.get()));
+-                if (reply->length != 0) {
+-                    const bool changedToWithdrawn = data[0] == XCB_ICCCM_WM_STATE_WITHDRAWN;
+-                    const bool changedToIconic = data[0] == XCB_ICCCM_WM_STATE_ICONIC;
+-                    m_minimized = changedToIconic || (changedToWithdrawn && m_minimized);
+-                }
++                const quint32 *data = (const quint32 *)xcb_get_property_value(reply.get());
++                if (reply->length != 0)
++                    m_minimized = (data[0] == XCB_ICCCM_WM_STATE_ICONIC
++                                   || (data[0] == XCB_ICCCM_WM_STATE_WITHDRAWN && m_minimized));
+             }
+         }
+ 
+-        // _NET_WM_STATE handling
+-        Qt::WindowStates newState = Qt::WindowNoState;
+         const NetWmStates states = netWmStates();
+         // _NET_WM_STATE_HIDDEN should be set by the Window Manager to indicate that a window would
+         // not be visible on the screen if its desktop/viewport were active and its coordinates were
+@@ -2325,6 +2239,7 @@ void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *ev
+             if ((m_windowState & Qt::WindowMinimized) && connection()->mouseGrabber() == this)
+                 connection()->setMouseGrabber(nullptr);
+         }
++        return;
+     } else if (event->atom == atom(QXcbAtom::_NET_FRAME_EXTENTS)) {
+         m_dirtyFrameMargins = true;
+     }
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbwindow.h b/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
+index 55af9279b1..6f5c1f5ed9 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
++++ b/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
+@@ -74,14 +74,6 @@ public:
+ 
+     Q_DECLARE_FLAGS(NetWmStates, NetWmState)
+ 
+-    enum Task {
+-        Map,
+-        Unmap,
+-        SetGeometry,
+-        SetWindowFlags,
+-        SetWindowState
+-    };
+-
+     QXcbWindow(QWindow *window);
+     ~QXcbWindow();
+ 
+@@ -151,9 +143,6 @@ public:
+ 
+     QXcbWindow *toWindow() override;
+ 
+-    bool shouldDeferTask(Task task);
+-    void handleDeferredTasks();
+-
+     void handleMouseEvent(xcb_timestamp_t time, const QPoint &local, const QPoint &global,
+                           Qt::KeyboardModifiers modifiers, QEvent::Type type, Qt::MouseEventSource source);
+ 
+@@ -292,11 +281,6 @@ protected:
+     int m_swapInterval = -1;
+ 
+     qreal m_sizeHintsScaleFactor = 1.0;
+-
+-    bool m_wmStateValid = true;
+-    QVector<Task> m_deferredTasks;
+-    bool m_isWmManagedWindow = true;
+-    QRect m_deferredGeometry;
+ };
+ 
+ class QXcbForeignWindow : public QXcbWindow
+diff --git a/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp b/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
+index d9d117faeb..640b49daa0 100644
+--- a/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
++++ b/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
+@@ -85,6 +85,7 @@ QGtk3MenuItem::QGtk3MenuItem()
+       m_checkable(false),
+       m_checked(false),
+       m_enabled(true),
++      m_exclusive(false),
+       m_underline(false),
+       m_invalid(true),
+       m_menu(nullptr),
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
+index 0048bbc1e6..396e7f6d1c 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
+@@ -102,15 +102,12 @@ const QDBusArgument &operator >>(const QDBusArgument &arg, QXdgDesktopPortalFile
+ class QXdgDesktopPortalFileDialogPrivate
+ {
+ public:
+-    QXdgDesktopPortalFileDialogPrivate(QPlatformFileDialogHelper *nativeFileDialog)
++    QXdgDesktopPortalFileDialogPrivate(QPlatformFileDialogHelper *nativeFileDialog, uint fileChooserPortalVersion)
+         : nativeFileDialog(nativeFileDialog)
++        , fileChooserPortalVersion(fileChooserPortalVersion)
+     { }
+ 
+-    WId winId = 0;
+-    bool directoryMode = false;
+-    bool modal = false;
+-    bool multipleFiles = false;
+-    bool saveFile = false;
++    QEventLoop loop;
+     QString acceptLabel;
+     QString directory;
+     QString title;
+@@ -121,19 +118,27 @@ public:
+     QString selectedMimeTypeFilter;
+     QString selectedNameFilter;
+     QStringList selectedFiles;
+-    QPlatformFileDialogHelper *nativeFileDialog = nullptr;
++    std::unique_ptr<QPlatformFileDialogHelper> nativeFileDialog;
++    uint fileChooserPortalVersion = 0;
++    bool failedToOpen = false;
++    bool directoryMode = false;
++    bool multipleFiles = false;
++    bool saveFile = false;
+ };
+ 
+-QXdgDesktopPortalFileDialog::QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog)
++QXdgDesktopPortalFileDialog::QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog, uint fileChooserPortalVersion)
+     : QPlatformFileDialogHelper()
+-    , d_ptr(new QXdgDesktopPortalFileDialogPrivate(nativeFileDialog))
++    , d_ptr(new QXdgDesktopPortalFileDialogPrivate(nativeFileDialog, fileChooserPortalVersion))
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+     if (d->nativeFileDialog) {
+-        connect(d->nativeFileDialog, SIGNAL(accept()), this, SIGNAL(accept()));
+-        connect(d->nativeFileDialog, SIGNAL(reject()), this, SIGNAL(reject()));
++        connect(d->nativeFileDialog.get(), SIGNAL(accept()), this, SIGNAL(accept()));
++        connect(d->nativeFileDialog.get(), SIGNAL(reject()), this, SIGNAL(reject()));
+     }
++
++    d->loop.connect(this, SIGNAL(accept()), SLOT(quit()));
++    d->loop.connect(this, SIGNAL(reject()), SLOT(quit()));
+ }
+ 
+ QXdgDesktopPortalFileDialog::~QXdgDesktopPortalFileDialog()
+@@ -177,7 +182,7 @@ void QXdgDesktopPortalFileDialog::initializeDialog()
+     setDirectory(options()->initialDirectory());
+ }
+ 
+-void QXdgDesktopPortalFileDialog::openPortal()
++void QXdgDesktopPortalFileDialog::openPortal(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent)
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+@@ -185,13 +190,13 @@ void QXdgDesktopPortalFileDialog::openPortal()
+                                                           QLatin1String("/org/freedesktop/portal/desktop"),
+                                                           QLatin1String("org.freedesktop.portal.FileChooser"),
+                                                           d->saveFile ? QLatin1String("SaveFile") : QLatin1String("OpenFile"));
+-    QString parentWindowId = QLatin1String("x11:") + QString::number(d->winId, 16);
++    QString parentWindowId = QLatin1String("x11:") + QString::number(parent ? parent->winId() : 0, 16);
+ 
+     QVariantMap options;
+     if (!d->acceptLabel.isEmpty())
+         options.insert(QLatin1String("accept_label"), d->acceptLabel);
+ 
+-    options.insert(QLatin1String("modal"), d->modal);
++    options.insert(QLatin1String("modal"), windowModality != Qt::NonModal);
+     options.insert(QLatin1String("multiple"), d->multipleFiles);
+     options.insert(QLatin1String("directory"), d->directoryMode);
+ 
+@@ -290,10 +295,18 @@ void QXdgDesktopPortalFileDialog::openPortal()
+ 
+     QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
+     QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingCall);
+-    connect(watcher, &QDBusPendingCallWatcher::finished, this, [this] (QDBusPendingCallWatcher *watcher) {
++    connect(watcher, &QDBusPendingCallWatcher::finished, this, [=] (QDBusPendingCallWatcher *watcher) {
+         QDBusPendingReply<QDBusObjectPath> reply = *watcher;
+-        if (reply.isError()) {
+-            Q_EMIT reject();
++        // Any error means the dialog is not shown and we need to fallback
++        d->failedToOpen = reply.isError();
++        if (d->failedToOpen) {
++            if (d->nativeFileDialog) {
++                d->nativeFileDialog->show(windowFlags, windowModality, parent);
++                if (d->loop.isRunning())
++                    d->nativeFileDialog->exec();
++            } else {
++                Q_EMIT reject();
++            }
+         } else {
+             QDBusConnection::sessionBus().connect(nullptr,
+                                                   reply.value().path(),
+@@ -302,6 +315,7 @@ void QXdgDesktopPortalFileDialog::openPortal()
+                                                   this,
+                                                   SLOT(gotResponse(uint,QVariantMap)));
+         }
++        watcher->deleteLater();
+     });
+ }
+ 
+@@ -326,7 +340,7 @@ QUrl QXdgDesktopPortalFileDialog::directory() const
+ {
+     Q_D(const QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog())
+         return d->nativeFileDialog->directory();
+ 
+     return d->directory;
+@@ -348,7 +362,7 @@ QList<QUrl> QXdgDesktopPortalFileDialog::selectedFiles() const
+ {
+     Q_D(const QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog())
+         return d->nativeFileDialog->selectedFiles();
+ 
+     QList<QUrl> files;
+@@ -403,16 +417,13 @@ void QXdgDesktopPortalFileDialog::exec()
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly)) {
++    if (d->nativeFileDialog && useNativeFileDialog()) {
+         d->nativeFileDialog->exec();
+         return;
+     }
+ 
+     // HACK we have to avoid returning until we emit that the dialog was accepted or rejected
+-    QEventLoop loop;
+-    loop.connect(this, SIGNAL(accept()), SLOT(quit()));
+-    loop.connect(this, SIGNAL(reject()), SLOT(quit()));
+-    loop.exec();
++    d->loop.exec();
+ }
+ 
+ void QXdgDesktopPortalFileDialog::hide()
+@@ -429,13 +440,10 @@ bool QXdgDesktopPortalFileDialog::show(Qt::WindowFlags windowFlags, Qt::WindowMo
+ 
+     initializeDialog();
+ 
+-    d->modal = windowModality != Qt::NonModal;
+-    d->winId = parent ? parent->winId() : 0;
+-
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog(OpenFallback))
+         return d->nativeFileDialog->show(windowFlags, windowModality, parent);
+ 
+-    openPortal();
++    openPortal(windowFlags, windowModality, parent);
+ 
+     return true;
+ }
+@@ -465,4 +473,21 @@ void QXdgDesktopPortalFileDialog::gotResponse(uint response, const QVariantMap &
+     }
+ }
+ 
++bool QXdgDesktopPortalFileDialog::useNativeFileDialog(QXdgDesktopPortalFileDialog::FallbackType fallbackType) const
++{
++    Q_D(const QXdgDesktopPortalFileDialog);
++
++    if (d->failedToOpen && fallbackType != OpenFallback)
++        return true;
++
++    if (d->fileChooserPortalVersion < 3) {
++        if (options()->fileMode() == QFileDialogOptions::Directory)
++            return true;
++        else if (options()->fileMode() == QFileDialogOptions::DirectoryOnly)
++            return true;
++    }
++
++    return false;
++}
++
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
+index 4f4de96ecf..65e22a5cf2 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
+@@ -51,6 +51,11 @@ class QXdgDesktopPortalFileDialog : public QPlatformFileDialogHelper
+     Q_OBJECT
+     Q_DECLARE_PRIVATE(QXdgDesktopPortalFileDialog)
+ public:
++    enum FallbackType {
++        GenericFallback,
++        OpenFallback
++    };
++
+     enum ConditionType : uint {
+         GlobalPattern = 0,
+         MimeType = 1
+@@ -69,7 +74,7 @@ public:
+     };
+     typedef QVector<Filter> FilterList;
+ 
+-    QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog = nullptr);
++    QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog = nullptr, uint fileChooserPortalVersion = 0);
+     ~QXdgDesktopPortalFileDialog();
+ 
+     bool defaultNameFilterDisables() const override;
+@@ -92,7 +97,8 @@ private Q_SLOTS:
+ 
+ private:
+     void initializeDialog();
+-    void openPortal();
++    void openPortal(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent);
++    bool useNativeFileDialog(FallbackType fallbackType = GenericFallback) const;
+ 
+     QScopedPointer<QXdgDesktopPortalFileDialogPrivate> d_ptr;
+ };
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
+index fb324afbd8..b809503122 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
+@@ -111,6 +111,7 @@ QXdgDesktopPortalTheme::QXdgDesktopPortalTheme()
+         if (reply.isValid()) {
+             d->fileChooserPortalVersion = reply.value().toUInt();
+         }
++        watcher->deleteLater();
+     });
+ }
+ 
+@@ -152,11 +153,12 @@ QPlatformDialogHelper* QXdgDesktopPortalTheme::createPlatformDialogHelper(Dialog
+ {
+     Q_D(const QXdgDesktopPortalTheme);
+ 
+-    if (type == FileDialog) {
++    if (type == FileDialog && d->fileChooserPortalVersion) {
+         // Older versions of FileChooser portal don't support opening directories, therefore we fallback
+         // to native file dialog opened inside the sandbox to open a directory.
+-        if (d->fileChooserPortalVersion < 3 && d->baseTheme->usePlatformNativeDialog(type))
+-            return new QXdgDesktopPortalFileDialog(static_cast<QPlatformFileDialogHelper*>(d->baseTheme->createPlatformDialogHelper(type)));
++        if (d->baseTheme->usePlatformNativeDialog(type))
++            return new QXdgDesktopPortalFileDialog(static_cast<QPlatformFileDialogHelper*>(d->baseTheme->createPlatformDialogHelper(type)),
++                                                   d->fileChooserPortalVersion);
+ 
+         return new QXdgDesktopPortalFileDialog;
+     }
+diff --git a/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp b/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
+index 43d5e119ad..1f9cbc4565 100644
+--- a/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
++++ b/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
+@@ -89,8 +89,10 @@ void QCupsPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &v
+         break;
+     case PPK_Duplex: {
+         QPrint::DuplexMode mode = QPrint::DuplexMode(value.toInt());
+-        if (mode != d->duplex && d->m_printDevice.supportedDuplexModes().contains(mode))
++        if (d->m_printDevice.supportedDuplexModes().contains(mode)) {
+             d->duplex = mode;
++            d->duplexRequestedExplicitly = true;
++        }
+         break;
+     }
+     case PPK_PrinterName:
+@@ -277,9 +279,12 @@ void QCupsPrintEnginePrivate::changePrinter(const QString &newPrinter)
+     m_printDevice.swap(printDevice);
+     printerName = m_printDevice.id();
+ 
+-    // Check if new printer supports current settings, otherwise us defaults
+-    if (duplex != QPrint::DuplexAuto && !m_printDevice.supportedDuplexModes().contains(duplex))
++    // in case a duplex value was explicitly set, check if new printer supports current value,
++    // otherwise use device default
++    if (!duplexRequestedExplicitly || !m_printDevice.supportedDuplexModes().contains(duplex)) {
+         duplex = m_printDevice.defaultDuplexMode();
++        duplexRequestedExplicitly = false;
++    }
+     QPrint::ColorMode colorMode = grayscale ? QPrint::GrayScale : QPrint::Color;
+     if (!m_printDevice.supportedColorModes().contains(colorMode))
+         grayscale = m_printDevice.defaultColorMode() == QPrint::GrayScale;
+diff --git a/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h b/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
+index c021b0c643..8f81fe478d 100644
+--- a/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
++++ b/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
+@@ -100,6 +100,7 @@ private:
+     QStringList cupsOptions;
+     QString cupsTempFile;
+     QPrint::DuplexMode duplex;
++    bool duplexRequestedExplicitly = false;
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp b/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
+index 67e7154fa6..40876152e5 100644
+--- a/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
++++ b/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
+@@ -817,7 +817,7 @@ bool QIBaseResultPrivate::writeArray(int column, const QList<QVariant> &list)
+     ba.resize(int(bufLen));
+ 
+     if (list.size() > arraySize) {
+-        error = QLatin1String("Array size missmatch: size of %1 is %2, size of provided list is %3");
++        error = QLatin1String("Array size mismatch: size of %1 is %2, size of provided list is %3");
+         error = error.arg(QLatin1String(sqlname)).arg(arraySize).arg(list.size());
+         q->setLastError(QSqlError(error, QLatin1String(""), QSqlError::StatementError));
+         return false;
+diff --git a/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp b/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
+index 7ca055eea2..6bc9d46755 100644
+--- a/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
++++ b/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
+@@ -223,7 +223,7 @@ public:
+     struct QMyField
+     {
+         char *outField = nullptr;
+-        MYSQL_FIELD *myField = nullptr;
++        const MYSQL_FIELD *myField = nullptr;
+         QMetaType::Type type = QMetaType::UnknownType;
+         my_bool nullIndicator = false;
+         ulong bufLength = 0ul;
+@@ -361,7 +361,7 @@ static bool qIsInteger(int t)
+ void QMYSQLResultPrivate::bindBlobs()
+ {
+     int i;
+-    MYSQL_FIELD *fieldInfo;
++    const MYSQL_FIELD *fieldInfo;
+     MYSQL_BIND *bind;
+ 
+     for(i = 0; i < fields.count(); ++i) {
+@@ -379,7 +379,6 @@ void QMYSQLResultPrivate::bindBlobs()
+ bool QMYSQLResultPrivate::bindInValues()
+ {
+     MYSQL_BIND *bind;
+-    char *field;
+     int i = 0;
+ 
+     if (!meta)
+@@ -392,35 +391,34 @@ bool QMYSQLResultPrivate::bindInValues()
+     inBinds = new MYSQL_BIND[fields.size()];
+     memset(inBinds, 0, fields.size() * sizeof(MYSQL_BIND));
+ 
+-    MYSQL_FIELD *fieldInfo;
++    const MYSQL_FIELD *fieldInfo;
+ 
+     while((fieldInfo = mysql_fetch_field(meta))) {
++        bind = &inBinds[i];
++
+         QMyField &f = fields[i];
+         f.myField = fieldInfo;
+-
++        bind->buffer_length = f.bufLength = fieldInfo->length + 1;
++        bind->buffer_type = fieldInfo->type;
+         f.type = qDecodeMYSQLType(fieldInfo->type, fieldInfo->flags);
+         if (qIsBlob(fieldInfo->type)) {
+             // the size of a blob-field is available as soon as we call
+             // mysql_stmt_store_result()
+             // after mysql_stmt_exec() in QMYSQLResult::exec()
+-            fieldInfo->length = 0;
++            bind->buffer_length = f.bufLength = 0;
+             hasBlobs = true;
+         } else if (qIsInteger(f.type)) {
+-            fieldInfo->length = 8;
++            bind->buffer_length = f.bufLength = 8;
+         } else {
+-            fieldInfo->type = MYSQL_TYPE_STRING;
++            bind->buffer_type = MYSQL_TYPE_STRING;
+         }
+-        bind = &inBinds[i];
+-        field = new char[fieldInfo->length + 1];
+-        memset(field, 0, fieldInfo->length + 1);
+ 
+-        bind->buffer_type = fieldInfo->type;
+-        bind->buffer = field;
+-        bind->buffer_length = f.bufLength = fieldInfo->length + 1;
+         bind->is_null = &f.nullIndicator;
+         bind->length = &f.bufLength;
+         bind->is_unsigned = fieldInfo->flags & UNSIGNED_FLAG ? 1 : 0;
+-        f.outField=field;
++
++        char *field = new char[bind->buffer_length + 1]{};
++        bind->buffer = f.outField = field;
+ 
+         ++i;
+     }
+@@ -1369,20 +1367,20 @@ bool QMYSQLDriver::open(const QString& db,
+     }
+ 
+ #if MYSQL_VERSION_ID >= 50007
+-    if (mysql_get_client_version() >= 50503 && mysql_get_server_version(d->mysql) >= 50503) {
+-        // force the communication to be utf8mb4 (only utf8mb4 supports 4-byte characters)
+-        mysql_set_character_set(d->mysql, "utf8mb4");
++    // force the communication to be utf8mb4 (only utf8mb4 supports 4-byte characters)
++    if (mysql_set_character_set(d->mysql, "utf8mb4")) {
++        // this failed, try forcing it to utf (BMP only)
++        if (mysql_set_character_set(d->mysql, "utf8"))
++            qWarning() << "MySQL: Unable to set the client character set to utf8.";
+ #if QT_CONFIG(textcodec)
+-        d->tc = QTextCodec::codecForName("UTF-8");
++        else
++            d->tc = codec(d->mysql);
+ #endif
+-    } else
+-    {
+-        // force the communication to be utf8
+-        mysql_set_character_set(d->mysql, "utf8");
++    }
+ #if QT_CONFIG(textcodec)
+-        d->tc = codec(d->mysql);
++    else
++        d->tc = QTextCodec::codecForName("UTF-8");
+ #endif
+-    }
+ #endif  // MYSQL_VERSION_ID >= 50007
+ 
+     d->preparedQuerysEnabled = checkPreparedQueries(d->mysql);
+diff --git a/qtbase/src/printsupport/dialogs/images/print-24.png b/qtbase/src/printsupport/dialogs/images/printer-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/print-24.png
+rename to src/printsupport/dialogs/images/printer-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/print-32.png b/qtbase/src/printsupport/dialogs/images/printer-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/print-32.png
+rename to src/printsupport/dialogs/images/printer-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-sided-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-facing-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-sided-24.png
+rename to src/printsupport/dialogs/images/view-pages-facing-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-sided-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-facing-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-sided-32.png
+rename to src/printsupport/dialogs/images/view-pages-facing-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-multi-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-overview-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-multi-24.png
+rename to src/printsupport/dialogs/images/view-pages-overview-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-multi-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-overview-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-multi-32.png
+rename to src/printsupport/dialogs/images/view-pages-overview-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-one-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-single-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-one-24.png
+rename to src/printsupport/dialogs/images/view-pages-single-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-one-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-single-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-one-32.png
+rename to src/printsupport/dialogs/images/view-pages-single-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-page-24.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-page-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-page-24.png
+rename to src/printsupport/dialogs/images/zoom-fit-page-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-page-32.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-page-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-page-32.png
+rename to src/printsupport/dialogs/images/zoom-fit-page-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-width-24.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-width-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-width-24.png
+rename to src/printsupport/dialogs/images/zoom-fit-width-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-width-32.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-width-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-width-32.png
+rename to src/printsupport/dialogs/images/zoom-fit-width-32.png
+diff --git a/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp b/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
+index 78e5b8d1ef..2a28516719 100644
+--- a/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
++++ b/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
+@@ -532,6 +532,7 @@ void QPageSetupWidget::updateWidget()
+ void QPageSetupWidget::setupPrinter() const
+ {
+     m_printer->setPageLayout(m_pageLayout);
++    m_printer->setPageOrientation(m_pageLayout.orientation());
+ #if QT_CONFIG(cups)
+     QCUPSSupport::PagesPerSheet pagesPerSheet = qvariant_cast<QCUPSSupport::PagesPerSheet>(m_ui.pagesPerSheetCombo->currentData()
+ );
+diff --git a/qtbase/src/printsupport/dialogs/qprintdialog.qrc b/qtbase/src/printsupport/dialogs/qprintdialog.qrc
+index 5a579baa55..10b8e1d341 100644
+--- a/qtbase/src/printsupport/dialogs/qprintdialog.qrc
++++ b/qtbase/src/printsupport/dialogs/qprintdialog.qrc
+@@ -1,9 +1,9 @@
+ <!DOCTYPE RCC><RCC version="1.0">
+ <qresource prefix="/qt-project.org/dialogs/qprintpreviewdialog">
+-<file>images/fit-page-24.png</file>
+-<file>images/fit-page-32.png</file>
+-<file>images/fit-width-24.png</file>
+-<file>images/fit-width-32.png</file>
++<file>images/zoom-fit-page-24.png</file>
++<file>images/zoom-fit-page-32.png</file>
++<file>images/zoom-fit-width-24.png</file>
++<file>images/zoom-fit-width-32.png</file>
+ <file>images/go-first-24.png</file>
+ <file>images/go-first-32.png</file>
+ <file>images/go-last-24.png</file>
+@@ -18,14 +18,14 @@
+ <file>images/layout-portrait-32.png</file>
+ <file>images/page-setup-24.png</file>
+ <file>images/page-setup-32.png</file>
+-<file>images/print-24.png</file>
+-<file>images/print-32.png</file>
+-<file>images/view-page-multi-24.png</file>
+-<file>images/view-page-multi-32.png</file>
+-<file>images/view-page-one-24.png</file>
+-<file>images/view-page-one-32.png</file>
+-<file>images/view-page-sided-24.png</file>
+-<file>images/view-page-sided-32.png</file>
++<file>images/printer-24.png</file>
++<file>images/printer-32.png</file>
++<file>images/view-pages-overview-24.png</file>
++<file>images/view-pages-overview-32.png</file>
++<file>images/view-pages-single-24.png</file>
++<file>images/view-pages-single-32.png</file>
++<file>images/view-pages-facing-24.png</file>
++<file>images/view-pages-facing-32.png</file>
+ <file>images/zoom-in-24.png</file>
+ <file>images/zoom-in-32.png</file>
+ <file>images/zoom-out-24.png</file>
+diff --git a/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp b/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
+index c5b845f4ec..5a5ba1d0a8 100644
+--- a/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
++++ b/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
+@@ -702,13 +702,14 @@ void QPrintDialogPrivate::selectPrinter(const QPrinter::OutputFormat outputForma
+         else
+             options.grayscale->setChecked(true);
+ 
+-        // keep duplex value explicitly set by user, if any, and selected printer supports it;
+-        // use device default otherwise
++        // duplex priorities to be as follows:
++        // 1) a user-selected duplex value in the dialog has highest prority
++        // 2) duplex value set in the QPrinter
+         QPrint::DuplexMode duplex;
+         if (explicitDuplexMode != QPrint::DuplexAuto && supportedDuplexMode.contains(explicitDuplexMode))
+             duplex = explicitDuplexMode;
+         else
+-            duplex = top->d->m_currentPrintDevice.defaultDuplexMode();
++            duplex = static_cast<QPrint::DuplexMode>(p->duplex());
+         switch (duplex) {
+         case QPrint::DuplexNone:
+             options.noDuplex->setChecked(true); break;
+@@ -1242,10 +1243,10 @@ void QUnixPrintWidgetPrivate::_q_printerChanged(int index)
+             QString filename = widget.filename->text();
+             widget.filename->setText(filename);
+             widget.lOutput->setEnabled(true);
+-            if (optionsPane)
+-                optionsPane->selectPrinter(QPrinter::PdfFormat);
+             printer->setOutputFormat(QPrinter::PdfFormat);
+             m_currentPrintDevice = QPrintDevice();
++            if (optionsPane)
++                optionsPane->selectPrinter(QPrinter::PdfFormat);
+             return;
+         }
+     }
+diff --git a/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp b/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
+index 39575d5f57..23b7e89538 100644
+--- a/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
++++ b/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
+@@ -352,7 +352,7 @@ void QPrintPreviewDialogPrivate::init(QPrinter *_printer)
+ static inline void qt_setupActionIcon(QAction *action, QLatin1String name)
+ {
+     QLatin1String imagePrefix(":/qt-project.org/dialogs/qprintpreviewdialog/images/");
+-    QIcon icon;
++    QIcon icon = QIcon::fromTheme(name);
+     icon.addFile(imagePrefix + name + QLatin1String("-24.png"), QSize(24, 24));
+     icon.addFile(imagePrefix + name + QLatin1String("-32.png"), QSize(32, 32));
+     action->setIcon(icon);
+@@ -383,8 +383,8 @@ void QPrintPreviewDialogPrivate::setupActions()
+     fitPageAction->setObjectName(QLatin1String("fitPageAction"));
+     fitWidthAction->setCheckable(true);
+     fitPageAction->setCheckable(true);
+-    qt_setupActionIcon(fitWidthAction, QLatin1String("fit-width"));
+-    qt_setupActionIcon(fitPageAction, QLatin1String("fit-page"));
++    qt_setupActionIcon(fitWidthAction, QLatin1String("zoom-fit-width"));
++    qt_setupActionIcon(fitPageAction, QLatin1String("zoom-fit-page"));
+     QObject::connect(fitGroup, SIGNAL(triggered(QAction*)), q, SLOT(_q_fit(QAction*)));
+ 
+     // Zoom
+@@ -410,9 +410,9 @@ void QPrintPreviewDialogPrivate::setupActions()
+     singleModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show single page"));
+     facingModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show facing pages"));
+     overviewModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show overview of all pages"));
+-    qt_setupActionIcon(singleModeAction, QLatin1String("view-page-one"));
+-    qt_setupActionIcon(facingModeAction, QLatin1String("view-page-sided"));
+-    qt_setupActionIcon(overviewModeAction, QLatin1String("view-page-multi"));
++    qt_setupActionIcon(singleModeAction, QLatin1String("view-pages-single"));
++    qt_setupActionIcon(facingModeAction, QLatin1String("view-pages-facing"));
++    qt_setupActionIcon(overviewModeAction, QLatin1String("view-pages-overview"));
+     singleModeAction->setObjectName(QLatin1String("singleModeAction"));
+     facingModeAction->setObjectName(QLatin1String("facingModeAction"));
+     overviewModeAction->setObjectName(QLatin1String("overviewModeAction"));
+@@ -426,7 +426,7 @@ void QPrintPreviewDialogPrivate::setupActions()
+     printerGroup = new QActionGroup(q);
+     printAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Print"));
+     pageSetupAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Page setup"));
+-    qt_setupActionIcon(printAction, QLatin1String("print"));
++    qt_setupActionIcon(printAction, QLatin1String("printer"));
+     qt_setupActionIcon(pageSetupAction, QLatin1String("page-setup"));
+     QObject::connect(printAction, SIGNAL(triggered(bool)), q, SLOT(_q_print()));
+     QObject::connect(pageSetupAction, SIGNAL(triggered(bool)), q, SLOT(_q_pageSetup()));
+diff --git a/qtbase/src/sql/kernel/qsqlquery.cpp b/qtbase/src/sql/kernel/qsqlquery.cpp
+index 32c6166c79..60afef10c3 100644
+--- a/qtbase/src/sql/kernel/qsqlquery.cpp
++++ b/qtbase/src/sql/kernel/qsqlquery.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2022 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtSql module of the Qt Toolkit.
+@@ -377,6 +377,10 @@ bool QSqlQuery::exec(const QString& query)
+     QElapsedTimer t;
+     t.start();
+ #endif
++    if (!driver()) {
++        qWarning("QSqlQuery::exec: called before driver has been set up");
++        return false;
++    }
+     if (d->ref.loadRelaxed() != 1) {
+         bool fo = isForwardOnly();
+         *this = QSqlQuery(driver()->createResult());
+diff --git a/qtbase/src/testlib/qabstractitemmodeltester.cpp b/qtbase/src/testlib/qabstractitemmodeltester.cpp
+index 8efb9c53d4..ce062f66d7 100644
+--- a/qtbase/src/testlib/qabstractitemmodeltester.cpp
++++ b/qtbase/src/testlib/qabstractitemmodeltester.cpp
+@@ -454,7 +454,7 @@ void QAbstractItemModelTesterPrivate::parent()
+ 
+     // Common error test #2, make sure that a second level index has a parent
+     // that is the first level index.
+-    if (model->rowCount(topIndex) > 0) {
++    if (model->rowCount(topIndex) > 0 && model->columnCount(topIndex) > 0) {
+         QModelIndex childIndex = model->index(0, 0, topIndex);
+         MODELTESTER_VERIFY(childIndex.isValid());
+         MODELTESTER_COMPARE(model->parent(childIndex), topIndex);
+diff --git a/qtbase/src/testlib/qasciikey.cpp b/qtbase/src/testlib/qasciikey.cpp
+index 9a308da2bc..93498b256f 100644
+--- a/qtbase/src/testlib/qasciikey.cpp
++++ b/qtbase/src/testlib/qasciikey.cpp
+@@ -498,6 +498,11 @@ char QTest::keyToAscii(Qt::Key key)
+     case Qt::Key_LaunchE : return 0; // = 0x10b0,
+     case Qt::Key_LaunchF : return 0; // = 0x10b1,
+ 
++    // Keypad navigation keys
++    case Qt::Key_Select : return 0; // = 0x01010000
++    case Qt::Key_Yes : return 0; // = 0x01010001
++    case Qt::Key_No : return 0; // = 0x01010002
++
+     default: QTEST_ASSERT(false); return 0;
+     }
+ }
+diff --git a/qtbase/src/testlib/qtestresult.cpp b/qtbase/src/testlib/qtestresult.cpp
+index 88028aac6e..2e89930776 100644
+--- a/qtbase/src/testlib/qtestresult.cpp
++++ b/qtbase/src/testlib/qtestresult.cpp
+@@ -251,7 +251,8 @@ bool QTestResult::verify(bool statement, const char *statementStr,
+ {
+     QTEST_ASSERT(statementStr);
+ 
+-    char msg[1024] = {'\0'};
++    char msg[1024];
++    msg[0] = '\0';
+ 
+     if (QTestLog::verboseLevel() >= 2) {
+         qsnprintf(msg, 1024, "QVERIFY(%s)", statementStr);
+@@ -309,7 +310,8 @@ static bool compareHelper(bool success, const char *failureMsg,
+                           bool hasValues = true)
+ {
+     const size_t maxMsgLen = 1024;
+-    char msg[maxMsgLen] = {'\0'};
++    char msg[maxMsgLen];
++    msg[0] = '\0';
+ 
+     QTEST_ASSERT(expected);
+     QTEST_ASSERT(actual);
+diff --git a/qtbase/src/widgets/dialogs/qcolordialog.cpp b/qtbase/src/widgets/dialogs/qcolordialog.cpp
+index 4247731275..cb325be85c 100644
+--- a/qtbase/src/widgets/dialogs/qcolordialog.cpp
++++ b/qtbase/src/widgets/dialogs/qcolordialog.cpp
+@@ -78,7 +78,10 @@
+ #include "qwindow.h"
+ 
+ #include "private/qdialog_p.h"
++#include "private/qguiapplication_p.h"
+ 
++#include <qpa/qplatformservices.h>
++#include <qpa/qplatformintegration.h>
+ #include <algorithm>
+ 
+ QT_BEGIN_NAMESPACE
+@@ -1611,6 +1614,20 @@ void QColorDialogPrivate::_q_newStandard(int r, int c)
+ void QColorDialogPrivate::_q_pickScreenColor()
+ {
+     Q_Q(QColorDialog);
++
++    auto *platformServices = QGuiApplicationPrivate::platformIntegration()->services();
++    if (platformServices->hasCapability(QPlatformServices::Capability::ColorPicking)) {
++        if (auto *colorPicker = platformServices->colorPicker(q->windowHandle())) {
++            q->connect(colorPicker, &QPlatformServiceColorPicker::colorPicked, q,
++                       [q, colorPicker](const QColor &color) {
++                           colorPicker->deleteLater();
++                           q->setCurrentColor(color);
++                       });
++            colorPicker->pickColor();
++            return;
++        }
++    }
++
+     if (!colorPickingEventFilter)
+         colorPickingEventFilter = new QColorPickingEventFilter(this, q);
+     q->installEventFilter(colorPickingEventFilter);
+diff --git a/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp b/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
+index e120817edc..8ea36b5427 100644
+--- a/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
++++ b/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
+@@ -400,12 +400,7 @@ bool QAbstractItemDelegate::helpEvent(QHelpEvent *event,
+         const QString tooltip = index.isValid() ?
+               d->textForRole(Qt::ToolTipRole, index.data(Qt::ToolTipRole), option.locale, precision) :
+               QString();
+-        QRect rect;
+-        if (index.isValid()) {
+-            const QRect r = view->visualRect(index);
+-            rect = QRect(view->mapToGlobal(r.topLeft()), r.size());
+-        }
+-        QToolTip::showText(he->globalPos(), tooltip, view, rect);
++        QToolTip::showText(he->globalPos(), tooltip, view->viewport(), option.rect);
+         event->setAccepted(!tooltip.isEmpty());
+         break;
+         }
+diff --git a/qtbase/src/widgets/itemviews/qlistview.cpp b/qtbase/src/widgets/itemviews/qlistview.cpp
+index 2b34476642..eebfaa030e 100644
+--- a/qtbase/src/widgets/itemviews/qlistview.cpp
++++ b/qtbase/src/widgets/itemviews/qlistview.cpp
+@@ -3386,6 +3386,7 @@ void QIconModeViewBase::updateContentsSize()
+ */
+ void QListView::currentChanged(const QModelIndex &current, const QModelIndex &previous)
+ {
++    QAbstractItemView::currentChanged(current, previous);
+ #ifndef QT_NO_ACCESSIBILITY
+     if (QAccessible::isActive()) {
+         if (current.isValid()) {
+@@ -3396,7 +3397,6 @@ void QListView::currentChanged(const QModelIndex &current, const QModelIndex &pr
+         }
+     }
+ #endif
+-    QAbstractItemView::currentChanged(current, previous);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/widgets/itemviews/qtableview.cpp b/qtbase/src/widgets/itemviews/qtableview.cpp
+index 934ac581b2..f79bb24249 100644
+--- a/qtbase/src/widgets/itemviews/qtableview.cpp
++++ b/qtbase/src/widgets/itemviews/qtableview.cpp
+@@ -1013,6 +1013,7 @@ void QTableViewPrivate::drawCell(QPainter *painter, const QStyleOptionViewItem &
+ int QTableViewPrivate::widthHintForIndex(const QModelIndex &index, int hint, const QStyleOptionViewItem &option) const
+ {
+     Q_Q(const QTableView);
++    const int oldHint = hint;
+     QWidget *editor = editorForIndex(index).widget.data();
+     if (editor && persistent.contains(editor)) {
+         hint = qMax(hint, editor->sizeHint().width());
+@@ -1021,6 +1022,17 @@ int QTableViewPrivate::widthHintForIndex(const QModelIndex &index, int hint, con
+         hint = qBound(min, hint, max);
+     }
+     hint = qMax(hint, q->itemDelegate(index)->sizeHint(option, index).width());
++
++    if (hasSpans()) {
++        auto span = spans.spanAt(index.column(), index.row());
++        if (span && span->m_left == index.column() && span->m_top == index.row()) {
++            // spans are screwed up when sections are moved
++            const auto left = logicalColumn(span->m_left);
++            for (int i = 1; i <= span->width(); ++i)
++               hint -= q->columnWidth(visualColumn(left + i));
++        }
++        hint = std::max(hint, oldHint);
++    }
+     return hint;
+ }
+ 
+@@ -1053,6 +1065,11 @@ int QTableViewPrivate::heightHintForIndex(const QModelIndex &index, int hint, QS
+         option.rect.setHeight(height);
+         option.rect.setX(q->columnViewportPosition(index.column()));
+         option.rect.setWidth(q->columnWidth(index.column()));
++        if (hasSpans()) {
++            auto span = spans.spanAt(index.column(), index.row());
++            if (span && span->m_left == index.column() && span->m_top == index.row())
++                option.rect.setWidth(std::max(option.rect.width(), visualSpanRect(*span).width()));
++        }
+         // 1px less space when grid is shown (see drawCell)
+         if (showGrid)
+             option.rect.setWidth(option.rect.width() - 1);
+diff --git a/qtbase/src/widgets/kernel/qaction.h b/qtbase/src/widgets/kernel/qaction.h
+index 258a1ea0a0..737c1e8285 100644
+--- a/qtbase/src/widgets/kernel/qaction.h
++++ b/qtbase/src/widgets/kernel/qaction.h
+@@ -81,7 +81,7 @@ class Q_WIDGETS_EXPORT QAction : public QObject
+     Q_PROPERTY(MenuRole menuRole READ menuRole WRITE setMenuRole NOTIFY changed)
+     Q_PROPERTY(bool iconVisibleInMenu READ isIconVisibleInMenu WRITE setIconVisibleInMenu NOTIFY changed)
+     Q_PROPERTY(bool shortcutVisibleInContextMenu READ isShortcutVisibleInContextMenu WRITE setShortcutVisibleInContextMenu NOTIFY changed)
+-    Q_PROPERTY(Priority priority READ priority WRITE setPriority)
++    Q_PROPERTY(Priority priority READ priority WRITE setPriority NOTIFY changed)
+ 
+ public:
+     // note this is copied into qplatformmenu.h, which must stay in sync
+diff --git a/qtbase/src/widgets/kernel/qwidget.cpp b/qtbase/src/widgets/kernel/qwidget.cpp
+index 9eba1e001e..26f6d27e18 100644
+--- a/qtbase/src/widgets/kernel/qwidget.cpp
++++ b/qtbase/src/widgets/kernel/qwidget.cpp
+@@ -5296,7 +5296,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
+         QWidgetEffectSourcePrivate *sourced = static_cast<QWidgetEffectSourcePrivate *>
+                                                          (source->d_func());
+         if (!sourced->context) {
+-            const QRegion effectRgn(rgn.boundingRect());
++            const QRegion effectRgn((flags & UseEffectRegionBounds) ? rgn.boundingRect() : rgn);
+             QWidgetPaintContext context(pdev, effectRgn, offset, flags, sharedPainter, repaintManager);
+             sourced->context = &context;
+             if (!sharedPainter) {
+@@ -5328,6 +5328,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
+         }
+     }
+ #endif // QT_CONFIG(graphicseffect)
++    flags = flags & ~UseEffectRegionBounds;
+ 
+     const bool alsoOnScreen = flags & DrawPaintOnScreen;
+     const bool recursive = flags & DrawRecursive;
+diff --git a/qtbase/src/widgets/kernel/qwidget_p.h b/qtbase/src/widgets/kernel/qwidget_p.h
+index eef6b8fa2c..c432f4b5d5 100644
+--- a/qtbase/src/widgets/kernel/qwidget_p.h
++++ b/qtbase/src/widgets/kernel/qwidget_p.h
+@@ -229,7 +229,8 @@ public:
+         DontSubtractOpaqueChildren = 0x10,
+         DontDrawOpaqueChildren = 0x20,
+         DontDrawNativeChildren = 0x40,
+-        DontSetCompositionMode = 0x80
++        DontSetCompositionMode = 0x80,
++        UseEffectRegionBounds = 0x100
+     };
+     Q_DECLARE_FLAGS(DrawWidgetFlags, DrawWidgetFlag)
+     Q_FLAG(DrawWidgetFlags)
+diff --git a/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp b/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
+index 02880b34da..0d44e1326d 100644
+--- a/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
++++ b/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
+@@ -1018,7 +1018,8 @@ void QWidgetRepaintManager::paintAndFlush()
+ 
+     // Paint the rest with composition.
+     if (repaintAllWidgets || !dirtyCopy.isEmpty()) {
+-        QWidgetPrivate::DrawWidgetFlags flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive;
++        QWidgetPrivate::DrawWidgetFlags flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive
++                | QWidgetPrivate::UseEffectRegionBounds;
+         tlw->d_func()->drawWidget(store->paintDevice(), dirtyCopy, QPoint(), flags, nullptr, this);
+     }
+ 
+diff --git a/qtbase/src/widgets/styles/qfusionstyle.cpp b/qtbase/src/widgets/styles/qfusionstyle.cpp
+index f4345d97c4..962912c838 100644
+--- a/qtbase/src/widgets/styles/qfusionstyle.cpp
++++ b/qtbase/src/widgets/styles/qfusionstyle.cpp
+@@ -1772,14 +1772,6 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio
+             proxy()->drawControl(CE_PushButtonLabel, &subopt, painter, widget);
+         }
+         break;
+-    case CE_PushButtonLabel:
+-        if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
+-            QStyleOptionButton b(*button);
+-            // no PM_ButtonShiftHorizontal and PM_ButtonShiftVertical for fusion style
+-            b.state &= ~(State_On | State_Sunken);
+-            QCommonStyle::drawControl(element, &b, painter, widget);
+-        }
+-        break;
+     case CE_MenuBarEmptyArea:
+         painter->save();
+     {
+diff --git a/qtbase/src/widgets/util/qcompleter.cpp b/qtbase/src/widgets/util/qcompleter.cpp
+index 18b24063d8..ef7207a8a3 100644
+--- a/qtbase/src/widgets/util/qcompleter.cpp
++++ b/qtbase/src/widgets/util/qcompleter.cpp
+@@ -1120,6 +1120,8 @@ void QCompleter::setModel(QAbstractItemModel *model)
+ {
+     Q_D(QCompleter);
+     QAbstractItemModel *oldModel = d->proxy->sourceModel();
++    if (oldModel == model)
++        return;
+ #if QT_CONFIG(filesystemmodel)
+     if (qobject_cast<const QFileSystemModel *>(oldModel))
+         setCompletionRole(Qt::EditRole); // QTBUG-54642, clear FileNameRole set by QFileSystemModel
+diff --git a/qtbase/src/widgets/widgets/qabstractbutton.cpp b/qtbase/src/widgets/widgets/qabstractbutton.cpp
+index a128b23950..dc40bf62fb 100644
+--- a/qtbase/src/widgets/widgets/qabstractbutton.cpp
++++ b/qtbase/src/widgets/widgets/qabstractbutton.cpp
+@@ -56,6 +56,7 @@
+ #ifndef QT_NO_ACCESSIBILITY
+ #include "qaccessible.h"
+ #endif
++#include <qpa/qplatformtheme.h>
+ 
+ #include <algorithm>
+ 
+@@ -1076,19 +1077,19 @@ void QAbstractButton::keyPressEvent(QKeyEvent *e)
+ {
+     Q_D(QAbstractButton);
+     bool next = true;
+-    switch (e->key()) {
+-    case Qt::Key_Enter:
+-    case Qt::Key_Return:
+-        e->ignore();
+-        break;
+-    case Qt::Key_Select:
+-    case Qt::Key_Space:
+-        if (!e->isAutoRepeat()) {
+-            setDown(true);
+-            repaint();
+-            d->emitPressed();
+-        }
+-        break;
++
++    const auto key = static_cast<Qt::Key>(e->key());
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(key) && !e->isAutoRepeat()) {
++        setDown(true);
++        repaint();
++        d->emitPressed();
++        return;
++    }
++
++    switch (key) {
+     case Qt::Key_Up:
+         next = false;
+         Q_FALLTHROUGH();
+@@ -1153,15 +1154,15 @@ void QAbstractButton::keyReleaseEvent(QKeyEvent *e)
+     if (!e->isAutoRepeat())
+         d->repeatTimer.stop();
+ 
+-    switch (e->key()) {
+-    case Qt::Key_Select:
+-    case Qt::Key_Space:
+-        if (!e->isAutoRepeat() && d->down)
+-            d->click();
+-        break;
+-    default:
+-        e->ignore();
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(static_cast<Qt::Key>(e->key())) && !e->isAutoRepeat() && d->down) {
++        d->click();
++        return;
+     }
++
++    e->ignore();
+ }
+ 
+ /*!\reimp
+diff --git a/qtbase/src/widgets/widgets/qcombobox.cpp b/qtbase/src/widgets/widgets/qcombobox.cpp
+index 7a496c27e0..0a3d96647b 100644
+--- a/qtbase/src/widgets/widgets/qcombobox.cpp
++++ b/qtbase/src/widgets/widgets/qcombobox.cpp
+@@ -3352,7 +3352,23 @@ void QComboBox::keyPressEvent(QKeyEvent *e)
+ 
+     Move move = NoMove;
+     int newIndex = currentIndex();
+-    switch (e->key()) {
++
++    bool pressLikeButton = !d->lineEdit;
++#ifdef QT_KEYPAD_NAVIGATION
++    pressLikeButton |= QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus();
++#endif
++    auto key = static_cast<Qt::Key>(e->key());
++    if (pressLikeButton) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(key)) {
++            showPopup();
++            return;
++        }
++    }
++
++    switch (key) {
+     case Qt::Key_Up:
+         if (e->modifiers() & Qt::ControlModifier)
+             break; // pass to line edit for auto completion
+@@ -3394,26 +3410,11 @@ void QComboBox::keyPressEvent(QKeyEvent *e)
+             return;
+         }
+         break;
+-    case Qt::Key_Space:
+-        if (!d->lineEdit) {
+-            showPopup();
+-            return;
+-        }
+-        break;
+-    case Qt::Key_Enter:
+-    case Qt::Key_Return:
+     case Qt::Key_Escape:
+         if (!d->lineEdit)
+             e->ignore();
+         break;
+ #ifdef QT_KEYPAD_NAVIGATION
+-    case Qt::Key_Select:
+-        if (QApplicationPrivate::keypadNavigationEnabled()
+-                && (!hasEditFocus() || !d->lineEdit)) {
+-            showPopup();
+-            return;
+-        }
+-        break;
+     case Qt::Key_Left:
+     case Qt::Key_Right:
+         if (QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus())
+diff --git a/qtbase/src/widgets/widgets/qdatetimeedit_p.h b/qtbase/src/widgets/widgets/qdatetimeedit_p.h
+index d36b6f8f9a..e0df5b5158 100644
+--- a/qtbase/src/widgets/widgets/qdatetimeedit_p.h
++++ b/qtbase/src/widgets/widgets/qdatetimeedit_p.h
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2018 The Qt Company Ltd.
++** Copyright (C) 2021 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtWidgets module of the Qt Toolkit.
+diff --git a/qtbase/src/widgets/widgets/qgroupbox.cpp b/qtbase/src/widgets/widgets/qgroupbox.cpp
+index 02a0bed325..3f3eccc370 100644
+--- a/qtbase/src/widgets/widgets/qgroupbox.cpp
++++ b/qtbase/src/widgets/widgets/qgroupbox.cpp
+@@ -54,6 +54,8 @@
+ #include "qaccessible.h"
+ #endif
+ #include <private/qwidget_p.h>
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
+ 
+ #include "qdebug.h"
+ 
+@@ -360,7 +362,10 @@ bool QGroupBox::event(QEvent *e)
+         return true;
+     case QEvent::KeyPress: {
+         QKeyEvent *k = static_cast<QKeyEvent*>(e);
+-        if (!k->isAutoRepeat() && (k->key() == Qt::Key_Select || k->key() == Qt::Key_Space)) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (!k->isAutoRepeat() && buttonPressKeys.contains(static_cast<Qt::Key>(k->key()))) {
+             d->pressedControl = QStyle::SC_GroupBoxCheckBox;
+             update(style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxCheckBox, this));
+             return true;
+@@ -369,7 +374,10 @@ bool QGroupBox::event(QEvent *e)
+     }
+     case QEvent::KeyRelease: {
+         QKeyEvent *k = static_cast<QKeyEvent*>(e);
+-        if (!k->isAutoRepeat() && (k->key() == Qt::Key_Select || k->key() == Qt::Key_Space)) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (!k->isAutoRepeat() && buttonPressKeys.contains(static_cast<Qt::Key>(k->key()))) {
+             bool toggle = (d->pressedControl == QStyle::SC_GroupBoxLabel
+                            || d->pressedControl == QStyle::SC_GroupBoxCheckBox);
+             d->pressedControl = QStyle::SC_None;
+diff --git a/qtbase/src/widgets/widgets/qlabel.cpp b/qtbase/src/widgets/widgets/qlabel.cpp
+index 30ff80cbb0..cf2605c17c 100644
+--- a/qtbase/src/widgets/widgets/qlabel.cpp
++++ b/qtbase/src/widgets/widgets/qlabel.cpp
+@@ -421,9 +421,6 @@ void QLabel::setPixmap(const QPixmap &pixmap)
+         d->pixmap = new QPixmap(pixmap);
+     }
+ 
+-    if (d->pixmap->depth() == 1 && !d->pixmap->mask())
+-        d->pixmap->setMask(*((QBitmap *)d->pixmap));
+-
+     d->updateLabel();
+ }
+ 
+diff --git a/qtbase/src/widgets/widgets/qtoolbararealayout.cpp b/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
+index 493c094cc1..d5f4b59017 100644
+--- a/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
++++ b/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
+@@ -1367,7 +1367,7 @@ bool QToolBarAreaLayout::restoreState(QDataStream &stream, const QList<QToolBar*
+                 item.widgetItem = new QWidgetItemV2(toolBar);
+                 toolBar->setOrientation(floating ? ((shown & 2) ? Qt::Vertical : Qt::Horizontal) : dock.o);
+                 toolBar->setVisible(shown & 1);
+-                toolBar->d_func()->setWindowState(floating, true, rect);
++                toolBar->d_func()->setWindowState(floating, false, rect);
+ 
+                 item.preferredSize = item.size;
+                 line.toolBarItems.append(item);
+diff --git a/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp b/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
+index 212c0a2e13..3c77b1ba0b 100644
+--- a/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
++++ b/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
+@@ -126,8 +126,7 @@ public:
+ 
+ void tst_QtConcurrentIterateKernel::instantiate()
+ {
+-    auto future = startThreadEngine(new PrintFor(0, 40)).startAsynchronously();
+-    future.waitForFinished();
++    startThreadEngine(new PrintFor(0, 40)).startBlocking();
+     QCOMPARE(iterations.loadRelaxed(), 40);
+ }
+ 
+@@ -166,10 +165,8 @@ void tst_QtConcurrentIterateKernel::stresstest()
+     const int times = 50;
+     for (int i = 0; i < times; ++i) {
+         counter.storeRelaxed(0);
+-        // ThreadEngine will delete f when it finishes
+-        auto f = new CountFor(0, iterations);
+-        auto future = f->startAsynchronously();
+-        future.waitForFinished();
++        CountFor f(0, iterations);
++        f.startBlocking();
+         QCOMPARE(counter.loadRelaxed(), iterations);
+     }
+ }
+@@ -177,11 +174,8 @@ void tst_QtConcurrentIterateKernel::stresstest()
+ void tst_QtConcurrentIterateKernel::noIterations()
+ {
+     const int times = 20000;
+-    for (int i = 0; i < times; ++i) {
+-        auto future = startThreadEngine(new IterateKernel<TestIterator, void>(0, 0))
+-                              .startAsynchronously();
+-        future.waitForFinished();
+-    }
++    for (int i = 0; i < times; ++i)
++        startThreadEngine(new IterateKernel<TestIterator, void>(0, 0)).startBlocking();
+ }
+ 
+ QMutex threadsMutex;
+@@ -236,10 +230,8 @@ void tst_QtConcurrentIterateKernel::throttling()
+ 
+     threads.clear();
+ 
+-    // ThreadEngine will delete f when it finishes
+-    auto f = new ThrottleFor(0, totalIterations);
+-    auto future = f->startAsynchronously();
+-    future.waitForFinished();
++    ThrottleFor f(0, totalIterations);
++    f.startBlocking();
+ 
+     QCOMPARE(iterations.loadRelaxed(), totalIterations);
+ 
+diff --git a/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp b/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
+index ac7be7acdd..81bc64c8d9 100644
+--- a/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
++++ b/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
+@@ -65,9 +65,16 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::runDirectly()
+ {
+-    PrintUser *engine = new PrintUser();
+-    QFuture<void> f = engine->startAsynchronously();
+-    f.waitForFinished();
++    {
++        PrintUser engine;
++        engine.startSingleThreaded();
++        engine.startBlocking();
++    }
++    {
++        PrintUser *engine = new PrintUser();
++        QFuture<void> f = engine->startAsynchronously();
++        f.waitForFinished();
++    }
+ }
+ 
+ class StringResultUser : public ThreadEngine<QString>
+@@ -99,10 +106,8 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::result()
+ {
+-    // ThreadEngine will delete 'engine' when it finishes
+-    auto engine = new StringResultUser();
+-    auto future = engine->startAsynchronously();
+-    QCOMPARE(future.result(), QString("Foo"));
++    StringResultUser engine;
++    QCOMPARE(*engine.startBlocking(), QString("Foo"));
+ }
+ 
+ class VoidResultUser : public ThreadEngine<void>
+@@ -128,9 +133,17 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::runThroughStarter()
+ {
+-    ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
+-    QFuture<QString> f = starter.startAsynchronously();
+-    QCOMPARE(f.result(), QString("Foo"));
++    {
++        ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
++        QFuture<QString>  f = starter.startAsynchronously();
++        QCOMPARE(f.result(), QString("Foo"));
++    }
++
++    {
++        ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
++        QString str = starter.startBlocking();
++        QCOMPARE(str, QString("Foo"));
++    }
+ }
+ 
+ class CancelUser : public ThreadEngine<void>
+@@ -213,6 +226,12 @@ void tst_QtConcurrentThreadEngine::throttle()
+         f.waitForFinished();
+         QCOMPARE(count.loadRelaxed(), 0);
+     }
++
++    for (int i = 0; i < repeats; ++i) {
++        ThrottleAlwaysUser t;
++        t.startBlocking();
++        QCOMPARE(count.loadRelaxed(), 0);
++    }
+ }
+ 
+ QSet<QThread *> threads;
+@@ -249,17 +268,35 @@ void tst_QtConcurrentThreadEngine::threadCount()
+ {
+     const int repeats = 10;
+     for (int i = 0; i < repeats; ++i) {
++        ThreadCountUser t;
++        t.startBlocking();
++        int count = threads.count();
++        int count_expected = QThreadPool::globalInstance()->maxThreadCount() + 1; // +1 for the main thread.
++        if (count != count_expected)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, count_expected);
++
+         (new ThreadCountUser())->startAsynchronously().waitForFinished();
+-        const auto count = threads.count();
+-        const auto maxThreadCount = QThreadPool::globalInstance()->maxThreadCount();
+-        QVERIFY(count <= maxThreadCount);
+-        QVERIFY(!threads.contains(QThread::currentThread()));
++        count = threads.count();
++        count_expected = QThreadPool::globalInstance()->maxThreadCount();
++        if (count != count_expected)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, count_expected);
+     }
+ 
+     // Set the finish flag immediately, this should give us one thread only.
+     for (int i = 0; i < repeats; ++i) {
++        ThreadCountUser t(true /*finishImmediately*/);
++        t.startBlocking();
++        int count = threads.count();
++        if (count != 1)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, 1);
++
+         (new ThreadCountUser(true /*finishImmediately*/))->startAsynchronously().waitForFinished();
+-        const auto count = threads.count();
++        count = threads.count();
++        if (count != 1)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
+         QCOMPARE(count, 1);
+         QVERIFY(!threads.contains(QThread::currentThread()));
+     }
+@@ -400,6 +437,7 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::exceptions()
+ {
++    // Asynchronous mode:
+     {
+         bool caught = false;
+         try  {
+@@ -412,6 +450,32 @@ void tst_QtConcurrentThreadEngine::exceptions()
+         QVERIFY2(caught, "did not get exception");
+     }
+ 
++    // Blocking mode:
++    // test throwing the exception from a worker thread.
++    {
++        bool caught = false;
++        try  {
++            QtConcurrentExceptionThrower e(QThread::currentThread());
++            e.startBlocking();
++        } catch (const QException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // test throwing the exception from the main thread (different code path)
++    {
++        bool caught = false;
++        try  {
++            QtConcurrentExceptionThrower e(0);
++            e.startBlocking();
++        } catch (const QException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // Asynchronous mode:
+     {
+         bool caught = false;
+         try  {
+@@ -423,6 +487,31 @@ void tst_QtConcurrentThreadEngine::exceptions()
+         }
+         QVERIFY2(caught, "did not get exception");
+     }
++
++    // Blocking mode:
++    // test throwing the exception from a worker thread.
++    {
++        bool caught = false;
++        try  {
++            UnrelatedExceptionThrower e(QThread::currentThread());
++            e.startBlocking();
++        } catch (const QUnhandledException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // test throwing the exception from the main thread (different code path)
++    {
++        bool caught = false;
++        try  {
++            UnrelatedExceptionThrower e(0);
++            e.startBlocking();
++        } catch (const QUnhandledException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
+ }
+ 
+ #endif
+diff --git a/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp b/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
+index 4968742110..f4c3fb711d 100644
+--- a/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
++++ b/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
+@@ -42,6 +42,7 @@ private slots:
+     void writeBlock_data();
+     void writeBlock();
+     void seek();
++    void invalidSeeks();
+     void seekTest_data();
+     void seekTest();
+     void read_rawdata();
+@@ -286,6 +287,29 @@ void tst_QBuffer::seek()
+     QCOMPARE(buffer.size(), pos);
+ }
+ 
++void tst_QBuffer::invalidSeeks()
++{
++    if constexpr (sizeof(qsizetype) == sizeof(qint64)) {
++        // sizeof(qsizetype) == sizeof(qint64), so +1 would overflow
++        QSKIP("This is a 32-bit-only test.");
++    } else {
++        QBuffer buffer;
++        buffer.open(QIODevice::WriteOnly);
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++        constexpr qint64 MaxQByteArrayCapacity = (std::numeric_limits<qsizetype>::max)();
++        // this should fail fast, not after trying to allocate nearly 2 GiB of data,
++        // potentially crashing in the process:
++        QVERIFY(!buffer.seek(2 * MaxQByteArrayCapacity - 1));
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++        // ditto:
++        QVERIFY(!buffer.seek(MaxQByteArrayCapacity + 1));
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++    }
++}
++
+ void tst_QBuffer::seekTest_data()
+ {
+     writeBlock_data();
+diff --git a/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp b/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
+index da5327594c..4a04e0f7c6 100644
+--- a/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
++++ b/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
+@@ -561,7 +561,8 @@ protected:
+     qint64 readData(char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf->size() - offset));
+-        memcpy(data, buf->constData() + offset, maxSize);
++        if (maxSize > 0)
++            memcpy(data, buf->constData() + offset, maxSize);
+         offset += maxSize;
+         return maxSize;
+     }
+@@ -604,13 +605,15 @@ protected:
+     qint64 readData(char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf.size() - pos()));
+-        memcpy(data, buf.constData() + pos(), maxSize);
++        if (maxSize > 0)
++            memcpy(data, buf.constData() + pos(), maxSize);
+         return maxSize;
+     }
+     qint64 writeData(const char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf.size() - pos()));
+-        memcpy(buf.data() + pos(), data, maxSize);
++        if (maxSize > 0)
++            memcpy(buf.data() + pos(), data, maxSize);
+         return maxSize;
+     }
+ 
+diff --git a/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+index db60bead64..f345a44414 100644
+--- a/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
++++ b/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+@@ -1,7 +1,8 @@
+ /****************************************************************************
+ **
+ ** Copyright (C) 2021 The Qt Company Ltd.
+-** Copyright (C) 2020 Intel Corporation.
++** Copyright (C) 2020 The Qt Company Ltd.
++** Copyright (C) 2022 Intel Corporation.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the test suite of the Qt Toolkit.
+@@ -150,6 +151,8 @@ private slots:
+     void startStopStartStopBuffers();
+     void processEventsInAReadyReadSlot_data();
+     void processEventsInAReadyReadSlot();
++    void startFromCurrentWorkingDir_data();
++    void startFromCurrentWorkingDir();
+ 
+     // keep these at the end, since they use lots of processes and sometimes
+     // caused obscure failures to occur in tests that followed them (esp. on the Mac)
+@@ -2731,5 +2734,94 @@ void tst_QProcess::finishProcessBeforeReadingDone_deprecated()
+ 
+ #endif
+ 
++enum class ChdirMode {
++    None = 0,
++    InParent,
++    InChild
++};
++Q_DECLARE_METATYPE(ChdirMode)
++
++void tst_QProcess::startFromCurrentWorkingDir_data()
++{
++    qRegisterMetaType<ChdirMode>();
++    QTest::addColumn<QString>("programPrefix");
++    QTest::addColumn<ChdirMode>("chdirMode");
++    QTest::addColumn<bool>("success");
++
++    constexpr bool IsWindows = true
++#ifdef Q_OS_UNIX
++            && false
++#endif
++            ;
++
++    // baseline: trying to execute the directory, this can't possibly succeed!
++    QTest::newRow("plain-same-cwd") << QString() << ChdirMode::None << false;
++
++    // cross-platform behavior: neither OS searches the setWorkingDirectory()
++    // dir without "./"
++    QTest::newRow("plain-child-chdir") << QString() << ChdirMode::InChild << false;
++
++    // cross-platform behavior: both OSes search the parent's CWD with "./"
++    QTest::newRow("prefixed-parent-chdir") << "./" << ChdirMode::InParent << true;
++
++    // opposite behaviors: Windows searches the parent's CWD and Unix searches
++    // the child's with "./"
++    QTest::newRow("prefixed-child-chdir") << "./" << ChdirMode::InChild << !IsWindows;
++
++    // Windows searches the parent's CWD without "./"
++    QTest::newRow("plain-parent-chdir") << QString() << ChdirMode::InParent << IsWindows;
++}
++
++void tst_QProcess::startFromCurrentWorkingDir()
++{
++    QFETCH(QString, programPrefix);
++    QFETCH(ChdirMode, chdirMode);
++    QFETCH(bool, success);
++
++    QProcess process;
++    qRegisterMetaType<QProcess::ProcessError>();
++    QSignalSpy errorSpy(&process, &QProcess::errorOccurred);
++    QVERIFY(errorSpy.isValid());
++
++    // both the dir name and the executable name
++    const QString target = QStringLiteral("testProcessNormal");
++    process.setProgram(programPrefix + target);
++
++#ifdef Q_OS_UNIX
++    // Reset PATH, to be sure it doesn't contain . or the empty path.
++    // We can't do this on Windows because DLLs are searched in PATH
++    // and Windows always searches "." anyway.
++    auto restoreEnv = qScopeGuard([old = qgetenv("PATH")] {
++        qputenv("PATH", old);
++    });
++    qputenv("PATH", "/");
++#endif
++
++    switch (chdirMode) {
++    case ChdirMode::InParent: {
++        auto restoreCwd = qScopeGuard([old = QDir::currentPath()] {
++            QDir::setCurrent(old);
++        });
++        QVERIFY(QDir::setCurrent(target));
++        process.start();
++        break;
++    }
++    case ChdirMode::InChild:
++        process.setWorkingDirectory(target);
++        Q_FALLTHROUGH();
++    case ChdirMode::None:
++        process.start();
++        break;
++    }
++
++    QCOMPARE(process.waitForStarted(), success);
++    QCOMPARE(errorSpy.count(), int(!success));
++    if (success) {
++        QVERIFY(process.waitForFinished());
++    } else {
++        QCOMPARE(process.error(), QProcess::FailedToStart);
++    }
++}
++
+ QTEST_MAIN(tst_QProcess)
+ #include "tst_qprocess.moc"
+diff --git a/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp b/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp
+index e1ea7a4552..90972caa57 100644
+--- a/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp
++++ b/qtbase/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"
+diff --git a/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+index 9bd66c0835..ed4a0bae5d 100644
+--- a/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
++++ b/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+@@ -158,6 +158,7 @@ private slots:
+     void nullReceiver();
+     void functorReferencesConnection();
+     void disconnectDisconnects();
++    void declarativeData();
+ };
+ 
+ struct QObjectCreatedOnShutdown
+@@ -7679,5 +7680,81 @@ void tst_QObject::disconnectDisconnects()
+ Q_STATIC_ASSERT(QtPrivate::HasQ_OBJECT_Macro<tst_QObject>::Value);
+ Q_STATIC_ASSERT(!QtPrivate::HasQ_OBJECT_Macro<SiblingDeleter>::Value);
+ 
++#ifdef QT_BUILD_INTERNAL
++/*
++    Since QObjectPrivate stores the declarativeData pointer in a union with the pointer
++    to the currently destroyed child, calls to the QtDeclarative handlers need to be
++    correctly guarded. QTBUG-105286
++*/
++namespace QtDeclarative {
++static QAbstractDeclarativeData *theData;
++
++static void destroyed(QAbstractDeclarativeData *data, QObject *)
++{
++    QCOMPARE(data, theData);
++}
++static void signalEmitted(QAbstractDeclarativeData *data, QObject *, int, void **)
++{
++    QCOMPARE(data, theData);
++}
++// we can't use QCOMPARE in the next two functions, as they don't return void
++static int receivers(QAbstractDeclarativeData *data, const QObject *, int)
++{
++    QTest::qCompare(data, theData, "data", "theData", __FILE__, __LINE__);
++    return 0;
++}
++static bool isSignalConnected(QAbstractDeclarativeData *data, const QObject *, int)
++{
++    QTest::qCompare(data, theData, "data", "theData", __FILE__, __LINE__);
++    return true;
++}
++
++class Object : public QObject
++{
++    Q_OBJECT
++public:
++    using QObject::QObject;
++    ~Object()
++    {
++        if (Object *p = static_cast<Object *>(parent()))
++            p->emitSignal();
++    }
++
++    void emitSignal()
++    {
++        emit theSignal();
++    }
++
++signals:
++    void theSignal();
++};
++
++}
++#endif
++
++void tst_QObject::declarativeData()
++{
++#ifdef QT_BUILD_INTERNAL
++    QScopedValueRollback destroyed(QAbstractDeclarativeData::destroyed,
++                                   QtDeclarative::destroyed);
++    QScopedValueRollback signalEmitted(QAbstractDeclarativeData::signalEmitted,
++                                       QtDeclarative::signalEmitted);
++    QScopedValueRollback receivers(QAbstractDeclarativeData::receivers,
++                                   QtDeclarative::receivers);
++    QScopedValueRollback isSignalConnected(QAbstractDeclarativeData::isSignalConnected,
++                                           QtDeclarative::isSignalConnected);
++
++    QtDeclarative::Object p;
++    QObjectPrivate *priv = QObjectPrivate::get(&p);
++    priv->declarativeData = QtDeclarative::theData = new QAbstractDeclarativeData;
++
++    connect(&p, &QtDeclarative::Object::theSignal, &p, []{
++    });
++
++    QtDeclarative::Object *child = new QtDeclarative::Object;
++    child->setParent(&p);
++#endif
++}
++
+ QTEST_MAIN(tst_QObject)
+ #include "tst_qobject.moc"
+diff --git a/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp b/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
+index 0ea422ecbc..1a3256534b 100644
+--- a/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
++++ b/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
+@@ -70,15 +70,15 @@ static inline QString testSuiteWarning()
+ 
+     QString result;
+     QTextStream str(&result);
+-    str << "\nCannot find the shared-mime-info test suite\nstarting from: "
++    str << "\nCannot find the shared-mime-info test suite\nin the parent of: "
+         << QDir::toNativeSeparators(QDir::currentPath()) << "\n"
+            "cd " << QDir::toNativeSeparators(QStringLiteral("tests/auto/corelib/mimetypes/qmimedatabase")) << "\n"
+-           "wget http://cgit.freedesktop.org/xdg/shared-mime-info/snapshot/Release-1-10.zip\n"
+-           "unzip Release-1-10.zip\n";
++           "wget https://gitlab.freedesktop.org/xdg/shared-mime-info/-/archive/2.1/shared-mime-info-2.1.zip\n"
++           "unzip shared-mime-info-2.1.zip\n";
+ #ifdef Q_OS_WIN
+-    str << "mkdir testfiles\nxcopy /s Release-1-10 s-m-i\n";
++    str << "mkdir testfiles\nxcopy /s shared-mime-info-2.1 s-m-i\n";
+ #else
+-    str << "ln -s Release-1-10 s-m-i\n";
++    str << "ln -s shared-mime-info-2.1 s-m-i\n";
+ #endif
+     return result;
+ }
+@@ -154,7 +154,7 @@ void tst_QMimeDatabase::initTestCase()
+     QVERIFY2(copyResourceFile(xmlFileName, xmlTargetFileName, &errorMessage), qPrintable(errorMessage));
+ #endif
+ 
+-    m_testSuite = QFINDTESTDATA("s-m-i/tests");
++    m_testSuite = QFINDTESTDATA("s-m-i/tests/mime-detection");
+     if (m_testSuite.isEmpty())
+         qWarning("%s", qPrintable(testSuiteWarning()));
+ 
+@@ -611,7 +611,7 @@ void tst_QMimeDatabase::allMimeTypes()
+     QVERIFY(!lst.isEmpty());
+ 
+     // Hardcoding this is the only way to check both providers find the same number of mimetypes.
+-    QCOMPARE(lst.count(), 779);
++    QCOMPARE(lst.count(), 811);
+ 
+     foreach (const QMimeType &mime, lst) {
+         const QString name = mime.name();
+@@ -631,10 +631,9 @@ void tst_QMimeDatabase::suffixes_data()
+ 
+     QTest::newRow("mimetype with a single pattern") << "application/pdf" << "*.pdf" << "pdf";
+     QTest::newRow("mimetype with multiple patterns") << "application/x-kpresenter" << "*.kpr;*.kpt" << "kpr";
+-    QTest::newRow("jpeg") << "image/jpeg" << "*.jpe;*.jpg;*.jpeg" << "jpeg";
+-    //if (KMimeType::sharedMimeInfoVersion() > KDE_MAKE_VERSION(0, 60, 0)) {
+-        QTest::newRow("mimetype with many patterns") << "application/vnd.wordperfect" << "*.wp;*.wp4;*.wp5;*.wp6;*.wpd;*.wpp" << "wp";
+-    //}
++    // The preferred suffix for image/jpeg is *.jpg, as per https://bugs.kde.org/show_bug.cgi?id=176737
++    QTest::newRow("jpeg") << "image/jpeg" << "*.jpe;*.jpg;*.jpeg" << "jpg";
++    QTest::newRow("mimetype with many patterns") << "application/vnd.wordperfect" << "*.wp;*.wp4;*.wp5;*.wp6;*.wpd;*.wpp" << "wp";
+     QTest::newRow("oasis text mimetype") << "application/vnd.oasis.opendocument.text" << "*.odt" << "odt";
+     QTest::newRow("oasis presentation mimetype") << "application/vnd.oasis.opendocument.presentation" << "*.odp" << "odp";
+     QTest::newRow("mimetype with multiple patterns") << "text/plain" << "*.asc;*.txt;*,v" << "txt";
+diff --git a/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp b/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
+index 3e58dd03cc..c8f82ef5d5 100644
+--- a/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
++++ b/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
+@@ -176,6 +176,8 @@ private Q_SLOTS:
+     void fromToVariantConversions_data();
+     void fromToVariantConversions();
+ 
++    void noLeakOnNameClash();
++
+ private:
+     QString testDataDir;
+ };
+@@ -3685,5 +3687,23 @@ void tst_QtJson::fromToVariantConversions()
+     }
+ }
+ 
++void tst_QtJson::noLeakOnNameClash()
++{
++    QJsonDocument doc = QJsonDocument::fromJson("{\"\":{\"\":0},\"\":0}");
++    QVERIFY(!doc.isNull());
++    const QJsonObject obj = doc.object();
++
++    // Removed the duplicate key.
++    QCOMPARE(obj.length(), 1);
++
++    // Retained the last of the duplicates.
++    const QJsonValue val = obj.begin().value();
++    QVERIFY(val.isDouble());
++    QCOMPARE(val.toDouble(), 0.0);
++
++    // It should not leak.
++    // In particular it should not forget to deref the container for the inner object.
++}
++
+ QTEST_MAIN(tst_QtJson)
+ #include "tst_qtjson.moc"
+diff --git a/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp b/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
+index a59b58d57f..241c3e84ac 100644
+--- a/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
++++ b/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
+@@ -63,6 +63,7 @@ private slots:
+     void isValidId_data();
+     void isValidId();
+     void malformed();
++    void serialize();
+     // Backend tests
+     void utcTest();
+     void icuTest();
+@@ -947,6 +948,33 @@ void tst_QTimeZone::malformed()
+         barf.offsetFromUtc(now);
+ }
+ 
++void tst_QTimeZone::serialize()
++{
++    int parts = 0;
++#ifndef QT_NO_DEBUG_STREAM
++    qDebug() << QTimeZone(); // to verify no crash
++    parts++;
++#endif
++#ifndef QT_NO_DATASTREAM
++    QByteArray blob;
++    {
++        QDataStream stream(&blob, QIODevice::WriteOnly);
++        stream << QTimeZone("Europe/Oslo") << QTimeZone(420) << QTimeZone() << qint64(-1);
++    }
++    QDataStream stream(&blob, QIODevice::ReadOnly);
++    QTimeZone invalid, offset, oslo;
++    qint64 minusone;
++    stream >> oslo >> offset >> invalid >> minusone;
++    QCOMPARE(oslo, QTimeZone("Europe/Oslo"));
++    QCOMPARE(offset, QTimeZone(420));
++    QVERIFY(!invalid.isValid());
++    QCOMPARE(minusone, qint64(-1));
++    parts++;
++#endif
++    if (!parts)
++        QSKIP("No serialization enabled");
++}
++
+ void tst_QTimeZone::utcTest()
+ {
+ #ifdef QT_BUILD_INTERNAL
+diff --git a/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp b/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
+index 05480c6dd2..70f4c75756 100644
+--- a/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
++++ b/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
+@@ -324,6 +324,13 @@ void tst_QDBusInterface::notValid()
+ 
+     QVERIFY(!interface.isValid());
+     QVERIFY(!QMetaObject::invokeMethod(&interface, "ListNames", Qt::DirectConnection));
++
++    // With a connection, but empty/null service and path specified
++    QDBusConnection con = QDBusConnection::sessionBus();
++    QVERIFY(con.isConnected());
++    QDBusInterface iface({}, {}, {}, con);
++    QVERIFY(!iface.isValid());
++    QVERIFY(!QMetaObject::invokeMethod(&interface, "ListNames", Qt::DirectConnection));
+ }
+ 
+ void tst_QDBusInterface::notValidDerived()
+diff --git a/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp b/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
+index 874468c954..04ceb4ab65 100644
+--- a/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
++++ b/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
+@@ -507,6 +507,10 @@ void tst_QKeySequence::toStringFromKeycode_data()
+     QTest::newRow("Ctrl+Alt+Num+Del") << QKeySequence(Qt::ControlModifier | Qt::AltModifier | Qt::KeypadModifier | Qt::Key_Delete) << "Ctrl+Alt+Num+Del";
+     QTest::newRow("Ctrl+Ins") << QKeySequence(Qt::ControlModifier | Qt::Key_Insert) << "Ctrl+Ins";
+     QTest::newRow("Ctrl+Num+Ins(1)") << QKeySequence(Qt::Key_Insert | Qt::KeypadModifier | Qt::ControlModifier) << "Ctrl+Num+Ins";
++    QTest::newRow("Ctrl") << QKeySequence(Qt::Key_Control) << "Control";
++    QTest::newRow("Alt") << QKeySequence(Qt::Key_Alt) << "Alt";
++    QTest::newRow("Shift") << QKeySequence(Qt::Key_Shift) << "Shift";
++    QTest::newRow("Meta") << QKeySequence(Qt::Key_Meta) << "Meta";
+ }
+ 
+ void tst_QKeySequence::toStringFromKeycode()
+diff --git a/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp b/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+index 15e0ecadaa..b4eca74283 100644
+--- a/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
++++ b/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+@@ -81,6 +81,8 @@ private slots:
+     void registerOpenTypePreferredNamesSystem();
+     void registerOpenTypePreferredNamesApplication();
+ 
++    void stretchRespected();
++
+ private:
+     QString m_ledFont;
+     QString m_testFont;
+@@ -355,6 +357,28 @@ static QString testString()
+     return QStringLiteral("foo bar");
+ }
+ 
++void tst_QFontDatabase::stretchRespected()
++{
++    int italicId = QFontDatabase::addApplicationFont(m_testFontItalic);
++    QVERIFY(italicId != -1);
++
++    QVERIFY(!QFontDatabase::applicationFontFamilies(italicId).isEmpty());
++
++    QString italicFontName = QFontDatabase::applicationFontFamilies(italicId).first();
++
++    QFont italicFont = QFontDatabase().font(italicFontName,
++                                            QString::fromLatin1("Italic"), 14);
++    QVERIFY(italicFont.italic());
++
++    QFont italicStretchedFont = italicFont;
++    italicStretchedFont.setStretch( 400 );
++
++    QVERIFY(QFontMetricsF(italicFont).horizontalAdvance(QStringLiteral("foobar")) <
++            QFontMetricsF(italicStretchedFont).horizontalAdvance(QStringLiteral("foobar")));
++
++    QFontDatabase::removeApplicationFont(italicId);
++}
++
+ void tst_QFontDatabase::condensedFontWidthNoFontMerging()
+ {
+     int regularFontId = QFontDatabase::addApplicationFont(m_testFont);
+diff --git a/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+index 3d4a094c43..b423e11a99 100644
+--- a/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
++++ b/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+@@ -281,6 +281,7 @@ private Q_SLOTS:
+     void ioGetFromFileSpecial();
+     void ioGetFromFile_data();
+     void ioGetFromFile();
++    void ioGetFromFileUrl();
+     void ioGetFromFtp_data();
+     void ioGetFromFtp();
+     void ioGetFromFtpWithReuse();
+@@ -3300,6 +3301,18 @@ void tst_QNetworkReply::ioGetFromFile()
+     QCOMPARE(reader.data, data);
+ }
+ 
++void tst_QNetworkReply::ioGetFromFileUrl()
++{
++    // This immediately fails on non-windows platforms:
++    QNetworkRequest request(QUrl("file://unc-server/some/path"));
++    QNetworkReplyPtr reply(manager.get(request));
++    QSignalSpy finishedSpy(reply.get(), &QNetworkReply::finished);
++    // QTBUG-105618: This would, on non-Windows platforms, never happen because the signal
++    // was emitted before the constructor finished, leaving no chance at all to connect to the
++    // signal
++    QVERIFY(finishedSpy.wait());
++}
++
+ void tst_QNetworkReply::ioGetFromFtp_data()
+ {
+     QTest::addColumn<QString>("fileName");
+diff --git a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
+index 069fa6b341..4cc4d9a5ea 100644
+--- a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
++++ b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
+@@ -1,75 +1,34 @@
+-Certificate:
+-    Data:
+-        Version: 3 (0x2)
+-        Serial Number: 0 (0x0)
+-        Signature Algorithm: sha1WithRSAEncryption
+-        Issuer: C=NO, ST=Oslo, L=Nydalen, O=Nokia Corporation and/or its subsidiary(-ies), OU=Development, CN=fluke.troll.no/emailAddress=ahanssen@trolltech.com
+-        Validity
+-            Not Before: Dec  4 01:10:32 2007 GMT
+-            Not After : Apr 21 01:10:32 2035 GMT
+-        Subject: C=NO, ST=Oslo, O=Nokia Corporation and/or its subsidiary(-ies), OU=Development, CN=fluke.troll.no
+-        Subject Public Key Info:
+-            Public Key Algorithm: rsaEncryption
+-            RSA Public Key: (1024 bit)
+-                Modulus (1024 bit):
+-                    00:a7:c8:a0:4a:c4:19:05:1b:66:ba:32:e2:d2:f1:
+-                    1c:6f:17:82:e4:39:2e:01:51:90:db:04:34:32:11:
+-                    21:c2:0d:6f:59:d8:53:90:54:3f:83:8f:a9:d3:b3:
+-                    d5:ee:1a:9b:80:ae:c3:25:c9:5e:a5:af:4b:60:05:
+-                    aa:a0:d1:91:01:1f:ca:04:83:e3:58:1c:99:32:45:
+-                    84:70:72:58:03:98:4a:63:8b:41:f5:08:49:d2:91:
+-                    02:60:6b:e4:64:fe:dd:a0:aa:74:08:e9:34:4c:91:
+-                    5f:12:3d:37:4d:54:2c:ad:7f:5b:98:60:36:02:8c:
+-                    3b:f6:45:f3:27:6a:9b:94:9d
+-                Exponent: 65537 (0x10001)
+-        X509v3 extensions:
+-            X509v3 Basic Constraints: 
+-                CA:FALSE
+-            Netscape Comment: 
+-                OpenSSL Generated Certificate
+-            X509v3 Subject Key Identifier: 
+-                21:85:04:3D:23:01:66:E5:F7:9F:1A:84:24:8A:AF:0A:79:F4:E5:AC
+-            X509v3 Authority Key Identifier: 
+-                DirName:/C=NO/ST=Oslo/L=Nydalen/O=Nokia Corporation and/or its subsidiary(-ies)/OU=Development/CN=fluke.troll.no/emailAddress=ahanssen@trolltech.com
+-                serial:8E:A8:B4:E8:91:B7:54:2E
+-
+-    Signature Algorithm: sha1WithRSAEncryption
+-        6d:57:5f:d1:05:43:f0:62:05:ec:2a:71:a5:dc:19:08:f2:c4:
+-        a6:bd:bb:25:d9:ca:89:01:0e:e4:cf:1f:c1:8c:c8:24:18:35:
+-        53:59:7b:c0:43:b4:32:e6:98:b2:a6:ef:15:05:0b:48:5f:e1:
+-        a0:0c:97:a9:a1:77:d8:35:18:30:bc:a9:8f:d3:b7:54:c7:f1:
+-        a9:9e:5d:e6:19:bf:f6:3c:5b:2b:d8:e4:3e:62:18:88:8b:d3:
+-        24:e1:40:9b:0c:e6:29:16:62:ab:ea:05:24:70:36:aa:55:93:
+-        ef:02:81:1b:23:10:a2:04:eb:56:95:75:fc:f8:94:b1:5d:42:
+-        c5:3f:36:44:85:5d:3a:2e:90:46:8a:a2:b9:6f:87:ae:0c:15:
+-        40:19:31:90:fc:3b:25:bb:ae:f1:66:13:0d:85:90:d9:49:34:
+-        8f:f2:5d:f9:7a:db:4d:5d:27:f6:76:9d:35:8c:06:a6:4c:a3:
+-        b1:b2:b6:6f:1d:d7:a3:00:fd:72:eb:9e:ea:44:a1:af:21:34:
+-        7d:c7:42:e2:49:91:19:8b:c0:ad:ba:82:80:a8:71:70:f4:35:
+-        31:91:63:84:20:95:e9:60:af:64:8b:cc:ff:3d:8a:76:74:3d:
+-        c8:55:6d:e4:8e:c3:2b:1c:e8:42:18:ae:9f:e6:6b:9c:34:06:
+-        ec:6a:f2:c3
+ -----BEGIN CERTIFICATE-----
+-MIIEEzCCAvugAwIBAgIBADANBgkqhkiG9w0BAQUFADCBnDELMAkGA1UEBhMCTk8x
+-DTALBgNVBAgTBE9zbG8xEDAOBgNVBAcTB055ZGFsZW4xFjAUBgNVBAoTDVRyb2xs
+-dGVjaCBBU0ExFDASBgNVBAsTC0RldmVsb3BtZW50MRcwFQYDVQQDEw5mbHVrZS50
+-cm9sbC5ubzElMCMGCSqGSIb3DQEJARYWYWhhbnNzZW5AdHJvbGx0ZWNoLmNvbTAe
+-Fw0wNzEyMDQwMTEwMzJaFw0zNTA0MjEwMTEwMzJaMGMxCzAJBgNVBAYTAk5PMQ0w
+-CwYDVQQIEwRPc2xvMRYwFAYDVQQKEw1Ucm9sbHRlY2ggQVNBMRQwEgYDVQQLEwtE
+-ZXZlbG9wbWVudDEXMBUGA1UEAxMOZmx1a2UudHJvbGwubm8wgZ8wDQYJKoZIhvcN
+-AQEBBQADgY0AMIGJAoGBAKfIoErEGQUbZroy4tLxHG8XguQ5LgFRkNsENDIRIcIN
+-b1nYU5BUP4OPqdOz1e4am4CuwyXJXqWvS2AFqqDRkQEfygSD41gcmTJFhHByWAOY
+-SmOLQfUISdKRAmBr5GT+3aCqdAjpNEyRXxI9N01ULK1/W5hgNgKMO/ZF8ydqm5Sd
+-AgMBAAGjggEaMIIBFjAJBgNVHRMEAjAAMCwGCWCGSAGG+EIBDQQfFh1PcGVuU1NM
+-IEdlbmVyYXRlZCBDZXJ0aWZpY2F0ZTAdBgNVHQ4EFgQUIYUEPSMBZuX3nxqEJIqv
+-Cnn05awwgbsGA1UdIwSBszCBsKGBoqSBnzCBnDELMAkGA1UEBhMCTk8xDTALBgNV
+-BAgTBE9zbG8xEDAOBgNVBAcTB055ZGFsZW4xFjAUBgNVBAoTDVRyb2xsdGVjaCBB
+-U0ExFDASBgNVBAsTC0RldmVsb3BtZW50MRcwFQYDVQQDEw5mbHVrZS50cm9sbC5u
+-bzElMCMGCSqGSIb3DQEJARYWYWhhbnNzZW5AdHJvbGx0ZWNoLmNvbYIJAI6otOiR
+-t1QuMA0GCSqGSIb3DQEBBQUAA4IBAQBtV1/RBUPwYgXsKnGl3BkI8sSmvbsl2cqJ
+-AQ7kzx/BjMgkGDVTWXvAQ7Qy5piypu8VBQtIX+GgDJepoXfYNRgwvKmP07dUx/Gp
+-nl3mGb/2PFsr2OQ+YhiIi9Mk4UCbDOYpFmKr6gUkcDaqVZPvAoEbIxCiBOtWlXX8
+-+JSxXULFPzZEhV06LpBGiqK5b4euDBVAGTGQ/Dslu67xZhMNhZDZSTSP8l35ettN
+-XSf2dp01jAamTKOxsrZvHdejAP1y657qRKGvITR9x0LiSZEZi8CtuoKAqHFw9DUx
+-kWOEIJXpYK9ki8z/PYp2dD3IVW3kjsMrHOhCGK6f5mucNAbsavLD
++MIIF6zCCA9OgAwIBAgIUfo9amJtJGWqWE6f+SkAO85zkGr4wDQYJKoZIhvcNAQEL
++BQAwgYMxCzAJBgNVBAYTAk5PMQ0wCwYDVQQIDARPc2xvMQ0wCwYDVQQHDARPc2xv
++MRcwFQYDVQQKDA5UaGUgUXQgQ29tcGFueTEMMAoGA1UECwwDUiZEMRIwEAYDVQQD
++DAlIMiBUZXN0ZXIxGzAZBgkqhkiG9w0BCQEWDG1pbmltaUBxdC5pbzAgFw0yMDEw
++MjYxMjAxMzFaGA8yMTIwMTAwMjEyMDEzMVowgYMxCzAJBgNVBAYTAk5PMQ0wCwYD
++VQQIDARPc2xvMQ0wCwYDVQQHDARPc2xvMRcwFQYDVQQKDA5UaGUgUXQgQ29tcGFu
++eTEMMAoGA1UECwwDUiZEMRIwEAYDVQQDDAlIMiBUZXN0ZXIxGzAZBgkqhkiG9w0B
++CQEWDG1pbmltaUBxdC5pbzCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIB
++AOiUp5+E4blouKH7q+rVNR8NoYX2XkBW+q+rpy1zu5ssRSzbqxAjDx9dkht7Qlnf
++VlDT00JvpOWdeuPon5915edQRsY4Unl6mKH29ra3OtUa1/yCJXsGVJTKCj7k4Bxb
++5mZzb/fTlZntMLdTIBMfUbw62FKir1WjKIcJ9fCoG8JaGeKVO4Rh5p0ezd4UUUId
++r1BXl5Nqdqy2vTMsEDnjOsD3egkv8I2SKN4O6n/C3wWYpMOWYZkGoZiKz7rJs/i/
++ez7bsV7JlwdzTlhpJzkcOSVFBP6JlEOxTNNxZ1wtKy7PtZGmsSSATq2e6+bw38Ae
++Op0XnzzqcGjtDDofBmT7OFzZWjS9VZS6+DOOe2QHWle1nCHcHyH4ku6IRlsr9xkR
++NAIlOfnvHHxqJUenoeaZ4oQDjCBKS1KXygJO/tL7BLTQVn/xK1EmPvKNnjzWk4tR
++PnibUhhs5635qpOU/YPqFBh1JjVruZbsWcDAhRcew0uxONXOa9E+4lttQ9ySYa1A
++LvWqJuAX7gu2BsBMLyqfm811YnA7CIFMyO+HlqmkLFfv5L/xIRAXR7l26YGO0VwX
++CGjMfz4NVPMMke4nB7qa9NkpXQBQKMms3Qzd5JW0Hy9Ruj5O8GPcFZmV0twjd1uJ
++PD/cAjkWLaXjdNsJ16QWc2nghQRS6HYqKRX6j+CXOxupAgMBAAGjUzBRMB0GA1Ud
++DgQWBBRSCOU58j9NJZkMamt623qyCrhN3TAfBgNVHSMEGDAWgBRSCOU58j9NJZkM
++amt623qyCrhN3TAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4ICAQCq
++q4jxsWeNDv5Nq14hJtF9HB+ZL64zcZtRjJP1YgNs0QppKICmjPOL2nIMGmI/jKrs
++0eGAL/9XXNVHPxm1OPOncvimMMmU6emZfpMdEtTfKP43+Pg9HgKRjLoQp406vGeQ
++8ki/mbBhrItVPgEm3tu2AFA02XTYi+YxCI9kRZLGkM3FbgtOuTLPl0Z9y+kiPc9F
++uCSC03anBEqv+vDSI8+wODymQ/IJ3Jyz1lxIRDfp4qAekmy0jU2c91VOHHEmOmqq
++kqygGFRdwbe99m9yP63r6q0b5K3X2UnJ6bns0hmTwThYwpVPXLU8jdaTddbMukN2
++/Ef96Tsw8nWOEOPMySHOTIPgwyZRp26b0kA9EmhLwOP401SxXVQCmSRmtwNagmtg
++jJKmZoYBN+//D45ibK8z6Q0oOm9P+Whf/uUXehcRxBxyV3xz7k0wKGQbHj/ddwcy
++IUoIN4lrAlib+lK170kTKN352PDmrpo2gmIzPEsfurKAIMSelDl6H+kih16BtZ8y
++Nz6fh9Soqrg3OSAware8pxV7k51crBMoPLN78KoRV8MFCK4K7Fddq4rRISq6hiXq
++r1nsjoEPuKM9huprmZVZe9t5YcDa2I+wb3IiE3uwpZbAdaLDyQ5n6F/qpsiIkZXn
++gtcF7oqpG5oYrwCcZ53y/ezUgUg7PlSz2XwAGvQtgg==
+ -----END CERTIFICATE-----
+diff --git a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
+index 9d1664d609..337ce541a6 100644
+--- a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
++++ b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
+@@ -1,15 +1,52 @@
+------BEGIN RSA PRIVATE KEY-----
+-MIICXAIBAAKBgQCnyKBKxBkFG2a6MuLS8RxvF4LkOS4BUZDbBDQyESHCDW9Z2FOQ
+-VD+Dj6nTs9XuGpuArsMlyV6lr0tgBaqg0ZEBH8oEg+NYHJkyRYRwclgDmEpji0H1
+-CEnSkQJga+Rk/t2gqnQI6TRMkV8SPTdNVCytf1uYYDYCjDv2RfMnapuUnQIDAQAB
+-AoGANFzLkanTeSGNFM0uttBipFT9F4a00dqHz6JnO7zXAT26I5r8sU1pqQBb6uLz
+-/+Qz5Zwk8RUAQcsMRgJetuPQUb0JZjF6Duv24hNazqXBCu7AZzUenjafwmKC/8ri
+-KpX3fTwqzfzi//FKGgbXQ80yykSSliDL3kn/drATxsLCgQECQQDXhEFWLJ0vVZ1s
+-1Ekf+3NITE+DR16X+LQ4W6vyEHAjTbaNWtcTKdAWLA2l6N4WAAPYSi6awm+zMxx4
+-VomVTsjdAkEAx0z+e7natLeFcrrq8pbU+wa6SAP1VfhQWKitxL1e7u/QO90NCpxE
+-oQYKzMkmmpOOFjQwEMAy1dvFMbm4LHlewQJAC/ksDBaUcQHHqjktCtrUb8rVjAyW
+-A8lscckeB2fEYyG5J6dJVaY4ClNOOs5yMDS2Afk1F6H/xKvtQ/5CzInA/QJATDub
+-K+BPU8jO9q+gpuIi3VIZdupssVGmCgObVCHLakG4uO04y9IyPhV9lA9tALtoIf4c
+-VIvv5fWGXBrZ48kZAQJBAJmVCdzQxd9LZI5vxijUCj5EI4e+x5DRqVUvyP8KCZrC
+-AiNyoDP85T+hBZaSXK3aYGpVwelyj3bvo1GrTNwNWLw=
+------END RSA PRIVATE KEY-----
++-----BEGIN PRIVATE KEY-----
++MIIJQgIBADANBgkqhkiG9w0BAQEFAASCCSwwggkoAgEAAoICAQDolKefhOG5aLih
+++6vq1TUfDaGF9l5AVvqvq6ctc7ubLEUs26sQIw8fXZIbe0JZ31ZQ09NCb6TlnXrj
++6J+fdeXnUEbGOFJ5epih9va2tzrVGtf8giV7BlSUygo+5OAcW+Zmc2/305WZ7TC3
++UyATH1G8OthSoq9VoyiHCfXwqBvCWhnilTuEYeadHs3eFFFCHa9QV5eTanastr0z
++LBA54zrA93oJL/CNkijeDup/wt8FmKTDlmGZBqGYis+6ybP4v3s+27FeyZcHc05Y
++aSc5HDklRQT+iZRDsUzTcWdcLSsuz7WRprEkgE6tnuvm8N/AHjqdF5886nBo7Qw6
++HwZk+zhc2Vo0vVWUuvgzjntkB1pXtZwh3B8h+JLuiEZbK/cZETQCJTn57xx8aiVH
++p6HmmeKEA4wgSktSl8oCTv7S+wS00FZ/8StRJj7yjZ481pOLUT54m1IYbOet+aqT
++lP2D6hQYdSY1a7mW7FnAwIUXHsNLsTjVzmvRPuJbbUPckmGtQC71qibgF+4LtgbA
++TC8qn5vNdWJwOwiBTMjvh5appCxX7+S/8SEQF0e5dumBjtFcFwhozH8+DVTzDJHu
++Jwe6mvTZKV0AUCjJrN0M3eSVtB8vUbo+TvBj3BWZldLcI3dbiTw/3AI5Fi2l43Tb
++CdekFnNp4IUEUuh2KikV+o/glzsbqQIDAQABAoICAFw1q6tr5I48vY7DF+rXsuLn
++5ZUWE1IQ6fzB4lr72nJv/9EEGnMgYzt9PpMUsD6vdCpBgS2C0+6RHArFzJtNA+RM
++iHLIG7K7702veyr/xBx/MwiSlMeMv/XpkFxVI6E6skMGG2s3AMXxKvJTy5CpRx+I
++eQFyLG+Ya1X2lgJes/q+/CpAHkOjCOpcLySQC5NZ74q734V7nSdmn+Zs3tYEh+O/
++eiuwTP/j5b38Te5vVTqDxTciJPmljmXLCwa0N100lWlbcpvw8qbqiTI2Jm3XCbUE
++AzHjW9vmrF3cRS1fXxKFGShw3SRqlkbxjfeWoi8qDPUBS4m8LOr8qG9Wo5Nfon0z
++zLP4bci3zHDvVcaaZrrsUBs/yZbg+Dgka1DmX7ekmeccr2yTdKDFgPupYUyxVbTl
++a9ZLJysjFD7rgBv1ZclHonLp6Vbm+ZoTqvteo4ikAy6L9RtBWJ23XEK34PkP/+c5
++2vWZaOrnjSeBHbFce8cdJSxqWpP+eSCI5I9XbDrYFIsQ/gqKgtzDKy2ihJ2Y8STL
++yO4hyFPFjxc+Gg4/P2PpmT5CY2ty44M0BWs+JGW96CJPrrplf2lmQUQJj5LZY66X
++Z/4C9L7ZYtKZ+bs5SvU46yWugAvQZX22Xm9xLXWyVXRdx3bj+3M3fDnF9di/zdbh
++CgLx7oWPNrXc7FCajnn9AoIBAQD5FMYwRpw9NWT9WDxQwx+cSI4Icbd88ByTW63S
++LzeRwZA0J9/SfwO+aBRupzc9GkGXCiZcGMw3AGsCtig8yFlw8E5KnzN7KlftDMnM
++9NUxxzlR8VwKyLnZfG7sDTl057ZlUujnqhmt/F8F7dIy7FVO1dE/8nngA+FYTCOG
++UZdGjwyBDlDM0JJdUWGY3xslutcpCDN5mzSTKjy9drMvImAshRawxRF6WBpn7vr2
++nC6vciqfx1Mzx1vyk0Jm0ilaydDdLMADjt/iL4Nkr0BEs4k+UzQiKDwp8gu7abQ1
++eBfxd9Iar4htQa2I1Ewl6P01G/q+ZYwgHhJ9RVn4AxQXefILAoIBAQDvCouORdQX
++C8wsyp7MwXlF/3NQeNN5/+B2mhbxrBOf7PmMCXLnkRWcjwJtzypWFqJ0sqai/2+0
++bqbMcjX5maT8stT2shl3zXe/Ejt2e3TBYpc1tyuses8Kb5BMU8hu6tTd3G2CMXpD
++dT6DVemJZCTtwj9aBNIxSizvlgMolJnCpzhPnlfHSI6E+g3m/LTTo3HwbjMSw/Uq
++irgjOpI2wSBB6LZPSgjvfcYPRyWUk16L4A5uSX0cADnovDFLa5/h0wJvN/OoCSQg
++rLCXG5E18EyL5Wc58BCY1ZvxmjG3lQtgPxYu2Jwc36R/y/JKlxW5suER5ZNpbbD4
++uOyTt2VxMQ2bAoIBAQC5+MzRFqdo/AjfL5Y5JrbfVTzXCTDa09xCGd16ZU60QTWN
+++4ed/r+o1sUKqUcRFB2MzEM/2DQBjQpZB/CbEWvWa1XJWXxypXbowveZU+QqOnmN
++uQvj8WLyA3o+PNF9e9QvauwCrHpn8VpxbtPWuaYoKnUFreFZZQxHhPGxRBIS2JOZ
++eDrT8ZaWnkCkh1AZp5smQ71LOprSlmKrg4jd1GjCVMxQR5N5KXbtyv0OTCZ/UFqK
++2aRBsMPyJgkaBChkZPLRcKwc+/wlQRx1fHQb14DNTApMxoXFO7eOwqmOkpAt9iyl
++SBIwoS0UUI5ab88+bBmXNvKcuFdNuQ4nowTJUn9pAoIBADMNkILBXSvS5DeIyuO2
++Sp1tkoZUV+5NfPY3sMDK3KIibaW/+t+EOBZo4L7tKQCb8vRzl21mmsfxfgRaPDbj
++3r3tv9g0b4YLxxBy52pFscj/soXRai17SS7UZwA2QK+XzgDYbDcLNC6mIsTQG4Gx
++dsWk3/zs3KuUSQaehmwrWK+fIUK38c1pLK8v7LoxrLkqxlHwZ04RthHw8KTthH7X
++Pnl1J0LF8CSeOyfWLSuPUfkT0GEzptnNHpEbaHfQM6R6eaGhVJPF6AZme4y6YYgg
++m2ihhSt1n0XVEWpHYWjxFy3mK2mz75unFC4LM+NEY2p2zuUQoCw7NjnY3QYrfCnx
++rRMCggEAXeXsMSLFjjyuoL7iKbAxo52HD/P0fBoy58LyRcwfNVr0lvYan4pYEx+o
++KijIh9K16PqXZXKMA9v003B+ulmF8bJ7SddCZ5NGvnFhUTDe4DdTKgp2RuwQ3Bsc
++3skPIDbhVETyOLCtys34USHrq8U/0DlGY3eLRfxw9GnbKxSBGa/KEu/qQLPNUo50
++7xHZDg7GKeC3kqNJeqKM9rkp0VzIGkEnaD9127LeNDmERDfftxJzFoC/THvUBLfU
++6Sus2ZYwRE8VFvKC30Q45t/c54X3IuhYvAuiCuTmyfE4ruyzyOwKzhUkeeLq1APX
++g0veFbyfzlJ0q8qzD/iffqqIa2ZSmQ==
++-----END PRIVATE KEY-----
+diff --git a/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp b/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
+index 7ba3715e13..752aa122f6 100644
+--- a/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
++++ b/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
+@@ -179,6 +179,7 @@ void tst_QAccessibilityLinux::initTestCase()
+     QVERIFY(!address.isEmpty());
+ 
+     m_window = new AccessibleTestWindow();
++    m_window->setObjectName("mainWindow"_L1);
+     m_window->show();
+ 
+     QVERIFY(QTest::qWaitForWindowExposed(m_window));
+@@ -236,8 +237,11 @@ bool hasState(QDBusInterface *interface, AtspiStateType state)
+ void tst_QAccessibilityLinux::testLabel()
+ {
+     QLabel *l = new QLabel(m_window);
++    l->setObjectName("theObjectName"_L1);
+     l->setText("Hello A11y");
+     m_window->addWidget(l);
++    auto a11yEmpty = new QLabel(m_window);
++    m_window->addWidget(l);
+ 
+     // Application
+     QCOMPARE(getParent(mainWindow), QLatin1String(ATSPI_DBUS_PATH_ROOT));
+@@ -249,6 +253,8 @@ void tst_QAccessibilityLinux::testLabel()
+     QCOMPARE(getChildren(labelInterface).count(), 0);
+     QCOMPARE(labelInterface->call(QDBus::Block, "GetRoleName").arguments().first().toString(), QLatin1String("label"));
+     QCOMPARE(labelInterface->call(QDBus::Block, "GetRole").arguments().first().toUInt(), 29u);
++    QCOMPARE(labelInterface->call(QDBus::Block, "GetAccessibleId").arguments().first().toString(),
++             QLatin1String("mainWindow.theObjectName"));
+     QCOMPARE(getParent(labelInterface), mainWindow->path());
+     QVERIFY(!hasState(labelInterface, ATSPI_STATE_EDITABLE));
+     QVERIFY(hasState(labelInterface, ATSPI_STATE_READ_ONLY));
+@@ -256,7 +262,12 @@ void tst_QAccessibilityLinux::testLabel()
+     l->setText("New text");
+     QCOMPARE(labelInterface->property("Name").toString(), l->text());
+ 
++    auto *a11yEmptyInterface = getInterface(children.at(1), "org.a11y.atspi.Accessible");
++    QCOMPARE(a11yEmptyInterface->call(QDBus::Block, "GetAccessibleId").arguments().first().toString(),
++             QLatin1String("mainWindow.QLabel"));
++
+     m_window->clearChildren();
++    delete a11yEmptyInterface;
+     delete labelInterface;
+ }
+ 
+diff --git a/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+index 76df61c892..6d6d65b791 100644
+--- a/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
++++ b/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2022 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the test suite of the Qt Toolkit.
+@@ -68,6 +68,8 @@ private slots:
+     void query_exec();
+     void execErrorRecovery_data() { generic_data(); }
+     void execErrorRecovery();
++    void prematureExec_data() { generic_data(); }
++    void prematureExec();
+     void first_data() { generic_data(); }
+     void first();
+     void next_data() { generic_data(); }
+@@ -2770,6 +2772,35 @@ void tst_QSqlQuery::execErrorRecovery()
+     QVERIFY_SQL( q, exec() );
+ }
+ 
++void tst_QSqlQuery::prematureExec()
++{
++    QFETCH(QString, dbName);
++    // We only want the engine name, for addDatabase():
++    int cut = dbName.indexOf(QChar('@'));
++    if (cut < 0)
++        QSKIP("Failed to parse database type out of name");
++    dbName.truncate(cut);
++    cut = dbName.indexOf(QChar('_'));
++    if (cut >= 0)
++        dbName = dbName.mid(cut + 1);
++
++    auto db = QSqlDatabase::addDatabase(dbName);
++    QSqlQuery q(db);
++
++    QTest::ignoreMessage(QtWarningMsg,
++                         "QSqlDatabasePrivate::removeDatabase: connection "
++                         "'qt_sql_default_connection' is still in use, all "
++                         "queries will cease to work.");
++    QTest::ignoreMessage(QtWarningMsg,
++                         "QSqlDatabasePrivate::addDatabase: duplicate connection name "
++                         "'qt_sql_default_connection', old connection removed.");
++    auto otherDb = QSqlDatabase::addDatabase(dbName);
++
++    QTest::ignoreMessage(QtWarningMsg, "QSqlQuery::exec: called before driver has been set up");
++    // QTBUG-100037: shouldn't crash !
++    QVERIFY(!q.exec("select stuff from TheVoid"));
++}
++
+ void tst_QSqlQuery::lastInsertId()
+ {
+     QFETCH( QString, dbName );
+diff --git a/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp b/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
+index 4aa3f8d60b..d2050a61aa 100644
+--- a/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
++++ b/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
+@@ -115,6 +115,10 @@ void tst_QAbstractItemModelTester::standardItemModelZeroColumns()
+     // QTBUG-92886
+     model.insertRows(0, 5);
+     model.removeRows(1, 2);
++
++    const QModelIndex parentIndex = model.index(0, 0);
++    model.insertRows(0, 5, parentIndex);
++    model.removeRows(1, 2, parentIndex);
+ }
+ 
+ void tst_QAbstractItemModelTester::testInsertThroughProxy()
+diff --git a/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json b/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
+index 12a4a22a19..ce518e78fb 100644
+--- a/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
++++ b/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
+@@ -668,50 +668,6 @@
+         "inputFile": "task192552.h",
+         "outputRevision": 67
+     },
+-    {
+-        "classes": [
+-            {
+-                "className": "InlineSlotsWithThrowDeclaration",
+-                "object": true,
+-                "qualifiedClassName": "InlineSlotsWithThrowDeclaration",
+-                "slots": [
+-                    {
+-                        "access": "public",
+-                        "name": "a",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "b",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "c",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "d",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "e",
+-                        "returnType": "void"
+-                    }
+-                ],
+-                "superClasses": [
+-                    {
+-                        "access": "public",
+-                        "name": "QObject"
+-                    }
+-                ]
+-            }
+-        ],
+-        "inputFile": "task189996.h",
+-        "outputRevision": 67
+-    },
+     {
+         "classes": [
+             {
+diff --git a/qtbase/tests/auto/tools/moc/moc.pro b/qtbase/tests/auto/tools/moc/moc.pro
+index c324b3a8cd..4aceb78dc0 100644
+--- a/qtbase/tests/auto/tools/moc/moc.pro
++++ b/qtbase/tests/auto/tools/moc/moc.pro
+@@ -15,7 +15,7 @@ cross_compile: DEFINES += MOC_CROSS_COMPILED
+ HEADERS += using-namespaces.h no-keywords.h task87883.h c-comments.h backslash-newlines.h oldstyle-casts.h \
+            slots-with-void-template.h qinvokable.h namespaced-flags.h trigraphs.h \
+            escapes-in-string-literals.h cstyle-enums.h qprivateslots.h gadgetwithnoenums.h \
+-           dir-in-include-path.h single_function_keyword.h task192552.h task189996.h \
++           dir-in-include-path.h single_function_keyword.h task192552.h \
+            task234909.h task240368.h pure-virtual-signals.h cxx11-enums.h \
+            cxx11-final-classes.h \
+            cxx11-explicit-override-control.h \
+diff --git a/qtbase/tests/auto/tools/moc/task189996.h b/qtbase/tests/auto/tools/moc/task189996.h
+deleted file mode 100644
+index f94a051b3a..0000000000
+--- a/qtbase/tests/auto/tools/moc/task189996.h
++++ /dev/null
+@@ -1,47 +0,0 @@
+-/****************************************************************************
+-**
+-** Copyright (C) 2016 The Qt Company Ltd.
+-** Contact: https://www.qt.io/licensing/
+-**
+-** This file is part of the test suite of the Qt Toolkit.
+-**
+-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+-** 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 General Public License Usage
+-** Alternatively, this file may be used under the terms of the GNU
+-** General Public License version 3 as published by the Free Software
+-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+-** 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-3.0.html.
+-**
+-** $QT_END_LICENSE$
+-**
+-****************************************************************************/
+-// inline functions can have throw declarations
+-
+-#ifndef TASK189996_H
+-#define TASK189996_H
+-
+-#include <QObject>
+-
+-class InlineSlotsWithThrowDeclaration : public QObject
+-{
+-    Q_OBJECT
+-
+-public slots:
+-    void a() throw() { }
+-    void b() const throw() { }
+-    void c() throw();
+-    void d() throw(int) { }
+-    void e() const throw(int,double) { }
+-};
+-
+-#endif
+diff --git a/qtbase/tests/auto/tools/moc/tst_moc.cpp b/qtbase/tests/auto/tools/moc/tst_moc.cpp
+index c716aead21..15dd9e41e5 100644
+--- a/qtbase/tests/auto/tools/moc/tst_moc.cpp
++++ b/qtbase/tests/auto/tools/moc/tst_moc.cpp
+@@ -631,7 +631,6 @@ public:
+ private slots:
+     void initTestCase();
+ 
+-    void slotWithException() throw(MyStruct);
+     void dontStripNamespaces();
+     void oldStyleCasts();
+     void warnOnExtraSignalSlotQualifiaction();
+@@ -673,7 +672,6 @@ private slots:
+     void templateGtGt();
+     void qprivateslots();
+     void qprivateproperties();
+-    void inlineSlotsWithThrowDeclaration();
+     void warnOnPropertyWithoutREAD();
+     void constructors();
+     void typenameWithUnsigned();
+@@ -784,12 +782,6 @@ void tst_Moc::initTestCase()
+ #endif
+ }
+ 
+-void tst_Moc::slotWithException() throw(MyStruct)
+-{
+-    // be happy
+-    QVERIFY(true);
+-}
+-
+ void tst_Moc::dontStripNamespaces()
+ {
+     Sender sender;
+@@ -824,7 +816,7 @@ void tst_Moc::oldStyleCasts()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-Wold-style-cast" << "-I" << "."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -894,7 +886,7 @@ void tst_Moc::inputFileNameWithDotsButNoExtension()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-I" << ".."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -1174,7 +1166,7 @@ void tst_Moc::ignoreOptionClashes()
+     QStringList gccArgs;
+     gccArgs << "-c" << "-x" << "c++" << "-I" << ".."
+          << "-I" << qtIncludePath << "-I" << includeDir << "-o" << "/dev/null"
+-         << "-fPIC" << "-std=c++11" <<  "-";
++         << "-fPIC" << "-std=c++1z" <<  "-";
+     proc.start("gcc", gccArgs);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -1593,21 +1585,6 @@ void tst_Moc::qprivateproperties()
+ 
+ }
+ 
+-#include "task189996.h"
+-
+-void InlineSlotsWithThrowDeclaration::c() throw() {}
+-
+-void tst_Moc::inlineSlotsWithThrowDeclaration()
+-{
+-    InlineSlotsWithThrowDeclaration tst;
+-    const QMetaObject *mobj = tst.metaObject();
+-    QVERIFY(mobj->indexOfSlot("a()") != -1);
+-    QVERIFY(mobj->indexOfSlot("b()") != -1);
+-    QVERIFY(mobj->indexOfSlot("c()") != -1);
+-    QVERIFY(mobj->indexOfSlot("d()") != -1);
+-    QVERIFY(mobj->indexOfSlot("e()") != -1);
+-}
+-
+ void tst_Moc::warnOnPropertyWithoutREAD()
+ {
+ #ifdef MOC_CROSS_COMPILED
+@@ -1869,7 +1846,7 @@ void tst_Moc::notifyError()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-I" << "."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+diff --git a/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+index c355ee9665..88c09de8e0 100644
+--- a/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
++++ b/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+@@ -251,6 +251,7 @@ private slots:
+     void testResetCachedSizeHint();
+     void statusTips();
+     void testRemovingColumnsViaLayoutChanged();
++    void testModelMovingColumns();
+ 
+ protected:
+     void setupTestData(bool use_reset_model = false);
+@@ -360,6 +361,12 @@ public:
+         endRemoveColumns();
+     }
+ 
++    void moveColumn(int from, int to)
++    {
++        beginMoveColumns(QModelIndex(), from, from, QModelIndex(), to);
++        endMoveColumns();
++    }
++
+     void cleanup()
+     {
+         emit layoutAboutToBeChanged();
+@@ -3627,5 +3634,18 @@ void tst_QHeaderView::testRemovingColumnsViaLayoutChanged()
+     // The main point of this test is that the section-size restoring code didn't go out of bounds.
+ }
+ 
++void tst_QHeaderView::testModelMovingColumns()
++{
++    QtTestModel model(10, 10);
++    QHeaderView hv(Qt::Horizontal);
++    hv.setModel(&model);
++    hv.resizeSections(QHeaderView::ResizeToContents);
++    hv.show();
++
++    QPersistentModelIndex index3 = model.index(0, 3);
++    model.moveColumn(3, 1);
++    QCOMPARE(index3.column(), 1);
++}
++
+ QTEST_MAIN(tst_QHeaderView)
+ #include "tst_qheaderview.moc"
+diff --git a/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+index 761357b252..06bb706074 100644
+--- a/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
++++ b/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+@@ -397,6 +397,7 @@ private slots:
+     void checkHeaderMinSize();
+ 
+     void resizeToContents();
++    void resizeToContentsSpans();
+ 
+     void tabFocus();
+     void bigModel();
+@@ -3721,6 +3722,70 @@ void tst_QTableView::resizeToContents()
+ 
+ }
+ 
++
++class SpanModel : public QAbstractTableModel
++{
++public:
++    SpanModel(bool sectionsMoved)
++        : _sectionsMoved(sectionsMoved)
++    {}
++    int columnCount(const QModelIndex & = {}) const override { return 2; }
++    int rowCount(const QModelIndex & = {}) const override { return 1; }
++    QVariant data(const QModelIndex &idx, int role = Qt::DisplayRole) const override
++    {
++        if (role != Qt::DisplayRole)
++            return QVariant();
++        const int col = _sectionsMoved ? 1 - idx.column() : idx.column();
++        if (col == 0)
++            return "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.";
++        return QVariant();
++    }
++private:
++    bool _sectionsMoved;
++};
++
++
++void tst_QTableView::resizeToContentsSpans()
++{
++    SpanModel model1(false);
++    SpanModel model2(true);
++    QTableView view1, view2, view3;
++    view1.setModel(&model1);
++    view2.setModel(&model2);
++    view2.horizontalHeader()->moveSection(0, 1);
++    view3.setModel(&model1);
++
++    view1.setSpan(0, 0, 1, 2);
++    view2.setSpan(0, 1, 1, 2);
++    view1.show();
++    view2.show();
++    view3.show();
++    QVERIFY(QTest::qWaitForWindowExposed(&view1));
++    QVERIFY(QTest::qWaitForWindowExposed(&view2));
++    QVERIFY(QTest::qWaitForWindowExposed(&view3));
++    view1.setColumnWidth(0, 100);
++    view1.setColumnWidth(1, 100);
++    view2.setColumnWidth(0, 100);
++    view2.setColumnWidth(1, 100);
++    view3.setColumnWidth(0, 200);
++
++    view1.resizeRowToContents(0);
++    view2.resizeRowToContents(0);
++    view3.resizeRowToContents(0);
++    QCOMPARE(view1.rowHeight(0), view3.rowHeight(0));
++    QCOMPARE(view2.rowHeight(0), view3.rowHeight(0));
++
++    view3.resizeColumnToContents(0);
++    view3.resizeRowToContents(0);
++    // height should be only 1 text line for easy testing
++    view1.setRowHeight(0, view3.verticalHeader()->sectionSize(0));
++    view2.setRowHeight(0, view3.verticalHeader()->sectionSize(0));
++    view1.resizeColumnToContents(0);
++    view2.resizeColumnToContents(1);
++    QCOMPARE(view1.columnWidth(0), view3.columnWidth(0) - view1.columnWidth(1));
++    QCOMPARE(view2.columnWidth(0), view3.columnWidth(0) - view2.columnWidth(1));
++}
++
+ QT_BEGIN_NAMESPACE
+ extern bool Q_WIDGETS_EXPORT qt_tab_all_widgets(); // qapplication.cpp
+ QT_END_NAMESPACE
+diff --git a/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+index a3b8ef78d8..4955cebd5d 100644
+--- a/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
++++ b/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+@@ -1498,7 +1498,7 @@ void tst_QApplication::desktopSettingsAware()
+     environment += QLatin1String("QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM=1");
+     testProcess.setEnvironment(environment);
+ #endif
+-    testProcess.start("desktopsettingsaware_helper");
++    testProcess.start("./desktopsettingsaware_helper");
+     QVERIFY2(testProcess.waitForStarted(),
+              qPrintable(QString::fromLatin1("Cannot start 'desktopsettingsaware_helper': %1").arg(testProcess.errorString())));
+     QVERIFY(testProcess.waitForFinished(10000));
+@@ -2452,7 +2452,7 @@ void tst_QApplication::qtbug_12673()
+ #if QT_CONFIG(process)
+     QProcess testProcess;
+     QStringList arguments;
+-    testProcess.start("modal_helper", arguments);
++    testProcess.start("./modal_helper", arguments);
+     QVERIFY2(testProcess.waitForStarted(),
+              qPrintable(QString::fromLatin1("Cannot start 'modal_helper': %1").arg(testProcess.errorString())));
+     QVERIFY(testProcess.waitForFinished(20000));
+diff --git a/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp b/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
+index eb108a40de..dca5528c1b 100644
+--- a/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
+@@ -41,6 +41,7 @@
+ 
+ #include <private/qguiapplication_p.h>
+ #include <qpa/qplatformintegration.h>
++#include <qpa/qplatformtheme.h>
+ 
+ class tst_QAbstractButton : public QObject
+ {
+@@ -76,6 +77,8 @@ private slots:
+     void keyNavigation();
+ #endif
+ 
++    void buttonPressKeys();
++
+ protected slots:
+     void onClicked();
+     void onToggled( bool on );
+@@ -269,7 +272,13 @@ void tst_QAbstractButton::setAutoRepeat()
+         QCOMPARE(press_count, click_count);
+         QVERIFY(click_count > 1);
+         break;
+-    case 4:
++    case 4: {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(Qt::Key_Enter)) {
++            QSKIP("platform theme has Key_Enter in ButtonPressKeys");
++        }
+         // check that pressing ENTER has no effect when autorepeat is false
+         testWidget->setDown( false );
+         testWidget->setAutoRepeat( false );
+@@ -286,7 +295,14 @@ void tst_QAbstractButton::setAutoRepeat()
+ 
+         QVERIFY( click_count == 0 );
+         break;
+-    case 5:
++    }
++    case 5: {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(Qt::Key_Enter)) {
++            QSKIP("platform theme has Key_Enter in ButtonPressKeys");
++        }
+         // check that pressing ENTER has no effect when autorepeat is true
+         testWidget->setDown( false );
+         testWidget->setAutoRepeat( true );
+@@ -304,6 +320,7 @@ void tst_QAbstractButton::setAutoRepeat()
+ 
+         QVERIFY( click_count == 0 );
+         break;
++    }
+     case 6:
+         // verify autorepeat is off by default.
+         MyButton tmp( 0);
+@@ -651,5 +668,16 @@ void tst_QAbstractButton::keyNavigation()
+ }
+ #endif
+ 
++void tst_QAbstractButton::buttonPressKeys()
++{
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(testWidget, buttonPressKeys[i]);
++        QCOMPARE(click_count, i + 1);
++    }
++}
++
+ QTEST_MAIN(tst_QAbstractButton)
+ #include "tst_qabstractbutton.moc"
+diff --git a/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+index 32437050f5..46b5af6d63 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+@@ -168,6 +168,7 @@ private slots:
+     void checkMenuItemPosWhenStyleSheetIsSet();
+     void checkEmbeddedLineEditWhenStyleSheetIsSet();
+     void propagateStyleChanges();
++    void buttonPressKeys();
+ 
+ private:
+     PlatformInputContext m_platformInputContext;
+@@ -1682,6 +1683,16 @@ void tst_QComboBox::setModel()
+     QCOMPARE(box.rootModelIndex(), rootModelIndex);
+     box.setModel(box.model());
+     QCOMPARE(box.rootModelIndex(), rootModelIndex);
++
++    // check that setting the same model as the completer's doesn't crash
++    QCompleter *completer = new QCompleter(&box);
++    box.setEditable(true);
++    box.setCompleter(completer);
++    auto *listModel = new QStringListModel({ "one", "two" }, completer);
++    completer->setModel(listModel);
++    QCOMPARE(listModel->rowCount(), 2); // make sure it wasn't deleted
++    box.setModel(listModel);
++    QCOMPARE(listModel->rowCount(), 2); // make sure it wasn't deleted
+ }
+ 
+ void tst_QComboBox::setCustomModelAndView()
+@@ -3632,5 +3643,24 @@ void tst_QComboBox::propagateStyleChanges()
+     QVERIFY(frameStyle.inquired);
+ }
+ 
++void tst_QComboBox::buttonPressKeys()
++{
++    QComboBox comboBox;
++    comboBox.setEditable(false);
++    comboBox.addItem(QString::number(1));
++    comboBox.addItem(QString::number(2));
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(&comboBox, buttonPressKeys[i]);
++        // On some platforms, a window will not be immediately visible,
++        // but take some event-loop iterations to complete.
++        // Using QTRY_VERIFY to deal with that.
++        QTRY_VERIFY(comboBox.view()->isVisible());
++        comboBox.hidePopup();
++    }
++}
++
+ QTEST_MAIN(tst_QComboBox)
+ #include "tst_qcombobox.moc"
+diff --git a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
+index be3cfcd104..c228fdfcca 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
++++ b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qcommandlinkbutton
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qcommandlinkbutton.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
+index 0044d33c66..4cf06296e4 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
+@@ -40,6 +40,9 @@
+ #include <QGridLayout>
+ #include <QPainter>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ class tst_QCommandLinkButton : public QObject
+ {
+     Q_OBJECT
+@@ -223,6 +226,13 @@ void tst_QCommandLinkButton::setAutoRepeat()
+     // check that pressing ENTER has no effect
+     resetCounters();
+     testWidget->setDown( false );
++    // Skip after reset if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
+     testWidget->setAutoRepeat( false );
+     QTest::keyPress( testWidget, Qt::Key_Enter );
+ 
+@@ -255,6 +265,14 @@ void tst_QCommandLinkButton::pressed()
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+ 
++    // Skip if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
++
+     QTest::keyPress( testWidget,Qt::Key_Enter );
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+diff --git a/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro b/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
+index 4a5e76ff65..a235fa1fac 100644
+--- a/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
++++ b/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qgroupbox
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qgroupbox.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp b/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
+index 4fb5d262ca..d8d7562b73 100644
+--- a/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
+@@ -35,6 +35,9 @@
+ #include <QRadioButton>
+ #include <QDialog>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ #include "qgroupbox.h"
+ 
+ class tst_QGroupBox : public QObject
+@@ -69,6 +72,7 @@ private slots:
+     void propagateFocus();
+     void task_QTBUG_19170_ignoreMouseReleaseEvent();
+     void task_QTBUG_15519_propagateMouseEvents();
++    void buttonPressKeys();
+ 
+ private:
+     bool checked;
+@@ -610,6 +614,20 @@ void tst_QGroupBox::task_QTBUG_15519_propagateMouseEvents()
+     QCOMPARE(parent.mouseMoved, true);
+ }
+ 
++void tst_QGroupBox::buttonPressKeys()
++{
++    QGroupBox groupBox;
++    groupBox.setCheckable(true);
++    QSignalSpy clickedSpy(&groupBox, &QGroupBox::clicked);
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(&groupBox, buttonPressKeys[i]);
++        QCOMPARE(clickedSpy.length(), i + 1);
++    }
++}
++
+ void tst_QGroupBox::sendMouseMoveEvent(QWidget *widget, const QPoint &localPos)
+ {
+     // Send a MouseMove event without actually moving the pointer
+diff --git a/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro b/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
+index 353ad06ca2..e55f6148f2 100644
+--- a/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
++++ b/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qpushbutton
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qpushbutton.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp b/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
+index e818514a79..4043e9326a 100644
+--- a/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
+@@ -41,6 +41,9 @@
+ #include <QStyleFactory>
+ #include <QTabWidget>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ class tst_QPushButton : public QObject
+ {
+ Q_OBJECT
+@@ -212,6 +215,13 @@ void tst_QPushButton::autoRepeat()
+     // check that pressing ENTER has no effect
+     resetCounters();
+     testWidget->setDown( false );
++    // Skip after reset if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
+     testWidget->setAutoRepeat( false );
+     QTest::keyPress( testWidget, Qt::Key_Enter );
+ 
+@@ -247,6 +257,14 @@ void tst_QPushButton::pressed()
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+ 
++    // Skip if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
++
+     QTest::keyPress( testWidget,Qt::Key_Enter );
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+diff --git a/qtbase/tests/manual/rhi/cubemap_render/buildshader.bat b/qtbase/tests/manual/rhi/cubemap_render/buildshader.bat
+old mode 100755
+new mode 100644
+Submodule qtconnectivity e957d481..056294c0:
+diff --git a/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp b/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
+index e2635fae..a8b8e3b9 100644
+--- a/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
++++ b/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
+@@ -563,9 +563,11 @@ void HciManager::handleHciAclPacket(const quint8 *data, int size)
+ 
+ void HciManager::handleLeMetaEvent(const quint8 *data)
+ {
+-    // Spec v4.2, Vol 2, part E, 7.7.65ff
++    // Spec v5.3, Vol 4, part E, 7.7.65.*
+     switch (*data) {
+-    case 0x1: {
++    case 0x1: // HCI_LE_Connection_Complete
++    case 0xA: // HCI_LE_Enhanced_Connection_Complete
++    {
+         const quint16 handle = bt_get_le16(data + 2);
+         emit connectionComplete(handle);
+         break;
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp b/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
+index 6a93143b..4a18cfc7 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
+@@ -320,7 +320,10 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_finishSdpScan(QBluetoothServiceD
+             for (const QBluetoothUuid &id : serviceClassUuids) {
+                 if (id.minimumSize() == 16) {
+                     serviceInfo.setServiceUuid(id);
+-                    serviceInfo.setServiceName(QBluetoothServiceDiscoveryAgent::tr("Custom Service"));
++                    if (serviceInfo.serviceName().isEmpty()) {
++                        serviceInfo.setServiceName(
++                                    QBluetoothServiceDiscoveryAgent::tr("Custom Service"));
++                    }
+                     QBluetoothServiceInfo::Sequence modSeq =
+                             serviceInfo.attribute(QBluetoothServiceInfo::ServiceClassIds).value<QBluetoothServiceInfo::Sequence>();
+                     modSeq.removeOne(QVariant::fromValue(id));
+@@ -334,8 +337,10 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_finishSdpScan(QBluetoothServiceD
+                 qCDebug(QT_BT_BLUEZ) << "Discovered services" << discoveredDevices.at(0).address().toString()
+                                      << serviceInfo.serviceName() << serviceInfo.serviceUuid()
+                                      << ">>>" << serviceInfo.serviceClassUuids();
+-
+-                emit q->serviceDiscovered(serviceInfo);
++                // Use queued connection to allow us finish the service looping; the application
++                // might call stop() when it has detected the service-of-interest.
++                QMetaObject::invokeMethod(q, "serviceDiscovered", Qt::QueuedConnection,
++                                          Q_ARG(QBluetoothServiceInfo, serviceInfo));
+             }
+         }
+     }
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp b/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
+index e4d85447..aadd4755 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
+@@ -593,7 +593,7 @@ void QBluetoothSocket::setSocketState(QBluetoothSocket::SocketState state)
+ bool QBluetoothSocket::canReadLine() const
+ {
+     Q_D(const QBluetoothSocketBase);
+-    return d->canReadLine();
++    return d->canReadLine() || QIODevice::canReadLine();
+ }
+ 
+ /*!
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp b/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
+index 084aa958..d6aa17a7 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
+@@ -284,6 +284,10 @@ void QBluetoothSocketPrivateBluezDBus::connectToService(
+         return;
+     }
+ 
++    if (service.socketProtocol() != QBluetoothServiceInfo::Protocol::UnknownProtocol)
++        socketType = service.socketProtocol();
++    qCDebug(QT_BT_BLUEZ) << "Socket protocol used:" << socketType;
++
+     connectToService(service.device().address(), targetService, openMode);
+ }
+ 
+diff --git a/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp b/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
+index 05bc1a0f..a7b5ef1f 100644
+--- a/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
++++ b/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
+@@ -142,7 +142,7 @@ void tst_QBluetoothSocket::initTestCase()
+     qDebug() << "Starting discovery";
+ 
+     sda->setUuidFilter(QBluetoothUuid(QString(TEST_SERVICE_UUID)));
+-    sda->start(QBluetoothServiceDiscoveryAgent::MinimalDiscovery);
++    sda->start(QBluetoothServiceDiscoveryAgent::FullDiscovery);
+ 
+     for (int connectTime = MaxConnectTime; !done_discovery && connectTime > 0; connectTime -= 1000)
+         QTest::qWait(1000);
+Submodule qtdeclarative f5701f0d..8defe7bf:
+diff --git a/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h b/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
+index b65b994d6c..15a8cd6878 100644
+--- a/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
++++ b/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
+@@ -86,7 +86,7 @@ public:
+         if (QTypeInfo<T>::isComplex) {
+             for (int i = 0; i < count; ++i)
+                 new (data + i) T(vector.at(i));
+-        } else {
++        } else if (count) {
+             memcpy(data, static_cast<const void*>(vector.constData()), count * sizeof(T));
+         }
+     }
+diff --git a/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp b/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
+index e57cdd8278..94613598af 100644
+--- a/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
++++ b/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
+@@ -1145,8 +1145,7 @@ void Heap::QObjectWrapper::markObjects(Heap::Base *that, QV4::MarkStack *markSta
+ void QObjectWrapper::destroyObject(bool lastCall)
+ {
+     Heap::QObjectWrapper *h = d();
+-    if (!h->internalClass)
+-        return; // destroyObject already got called
++    Q_ASSERT(h->internalClass);
+ 
+     if (h->object()) {
+         QQmlData *ddata = QQmlData::get(h->object(), false);
+@@ -1176,7 +1175,7 @@ void QObjectWrapper::destroyObject(bool lastCall)
+         }
+     }
+ 
+-    h->~Data();
++    h->destroy();
+ }
+ 
+ 
+diff --git a/qtdeclarative/src/qml/memory/qv4mm.cpp b/qtdeclarative/src/qml/memory/qv4mm.cpp
+index 06caf04e5a..da149a67c4 100644
+--- a/qtdeclarative/src/qml/memory/qv4mm.cpp
++++ b/qtdeclarative/src/qml/memory/qv4mm.cpp
+@@ -981,7 +981,7 @@ void MemoryManager::sweep(bool lastSweep, ClassDestroyStatsCallback classCountPt
+ 
+     if (MultiplyWrappedQObjectMap *multiplyWrappedQObjects = engine->m_multiplyWrappedQObjects) {
+         for (MultiplyWrappedQObjectMap::Iterator it = multiplyWrappedQObjects->begin(); it != multiplyWrappedQObjects->end();) {
+-            if (!it.value().isNullOrUndefined())
++            if (it.value().isNullOrUndefined())
+                 it = multiplyWrappedQObjects->erase(it);
+             else
+                 ++it;
+diff --git a/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp b/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
+index 2079a8ed04..a577cb2351 100644
+--- a/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
++++ b/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
+@@ -389,6 +389,12 @@ void QQmlDelegateModelPrivate::connectToAbstractItemModel()
+                       q,  QQmlDelegateModel, SLOT(_q_rowsRemoved(QModelIndex,int,int)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
+                       q,  QQmlDelegateModel, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsInserted(QModelIndex,int,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsInserted(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsRemoved(QModelIndex,int,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsRemoved(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsMoved(QModelIndex,int,int,QModelIndex,int)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
+                       q, QQmlDelegateModel, SLOT(_q_dataChanged(QModelIndex,QModelIndex,QVector<int>)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
+@@ -413,6 +419,12 @@ void QQmlDelegateModelPrivate::disconnectFromAbstractItemModel()
+                         q, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int)));
+     QObject::disconnect(aim, SIGNAL(rowsRemoved(QModelIndex,int,int)),
+                         q, SLOT(_q_rowsRemoved(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsInserted(QModelIndex,int,int)), q,
++                        SLOT(_q_columnsInserted(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsRemoved(QModelIndex,int,int)), q,
++                        SLOT(_q_columnsRemoved(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)), q,
++                        SLOT(_q_columnsMoved(QModelIndex,int,int,QModelIndex,int)));
+     QObject::disconnect(aim, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
+                         q, SLOT(_q_dataChanged(QModelIndex,QModelIndex,QVector<int>)));
+     QObject::disconnect(aim, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
+@@ -1973,6 +1985,38 @@ void QQmlDelegateModel::_q_rowsMoved(
+     }
+ }
+ 
++void QQmlDelegateModel::_q_columnsInserted(const QModelIndex &parent, int begin, int end)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if (parent == d->m_adaptorModel.rootIndex && begin == 0) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
++void QQmlDelegateModel::_q_columnsRemoved(const QModelIndex &parent, int begin, int end)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if (parent == d->m_adaptorModel.rootIndex && begin == 0) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
++void QQmlDelegateModel::_q_columnsMoved(const QModelIndex &parent, int start, int end,
++                                        const QModelIndex &destination, int column)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if ((parent == d->m_adaptorModel.rootIndex && start == 0)
++        || (destination == d->m_adaptorModel.rootIndex && column == 0)) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
+ void QQmlDelegateModel::_q_dataChanged(const QModelIndex &begin, const QModelIndex &end, const QVector<int> &roles)
+ {
+     Q_D(QQmlDelegateModel);
+diff --git a/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h b/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
+index 8aab4badca..d140bfbaaf 100644
+--- a/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
++++ b/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
+@@ -152,6 +152,9 @@ private Q_SLOTS:
+     void _q_itemsMoved(int from, int to, int count);
+     void _q_modelReset();
+     void _q_rowsInserted(const QModelIndex &,int,int);
++    void _q_columnsInserted(const QModelIndex &, int, int);
++    void _q_columnsRemoved(const QModelIndex &, int, int);
++    void _q_columnsMoved(const QModelIndex &, int, int, const QModelIndex &, int);
+     void _q_rowsAboutToBeRemoved(const QModelIndex &parent, int begin, int end);
+     void _q_rowsRemoved(const QModelIndex &,int,int);
+     void _q_rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int);
+diff --git a/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp b/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
+index 85719fdc80..78e2ab302c 100644
+--- a/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
++++ b/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
+@@ -46,6 +46,7 @@
+ #include "QtQuick/private/qquicktextinput_p.h"
+ #include "QtQuick/private/qquickaccessibleattached_p.h"
+ #include "QtQuick/qquicktextdocument.h"
++#include "QtQuick/qquickrendercontrol.h"
+ QT_BEGIN_NAMESPACE
+ 
+ #if QT_CONFIG(accessibility)
+@@ -57,7 +58,19 @@ QAccessibleQuickItem::QAccessibleQuickItem(QQuickItem *item)
+ 
+ QWindow *QAccessibleQuickItem::window() const
+ {
+-    return item()->window();
++    QQuickWindow *window = item()->window();
++
++    // For QQuickWidget the above window will be the offscreen QQuickWindow,
++    // which is not a part of the accessibility tree. Detect this case and
++    // return the window for the QQuickWidget instead.
++    if (window && !window->handle()) {
++        if (QQuickRenderControl *renderControl = QQuickWindowPrivate::get(window)->renderControl) {
++            if (QWindow *renderWindow = renderControl->renderWindow(nullptr))
++                return renderWindow;
++        }
++    }
++
++    return window;
+ }
+ 
+ int QAccessibleQuickItem::childCount() const
+@@ -113,19 +126,15 @@ QAccessibleInterface *QAccessibleQuickItem::childAt(int x, int y) const
+ QAccessibleInterface *QAccessibleQuickItem::parent() const
+ {
+     QQuickItem *parent = item()->parentItem();
+-    QQuickWindow *window = item()->window();
+-    QQuickItem *ci = window ? window->contentItem() : nullptr;
++    QQuickWindow *itemWindow = item()->window();
++    QQuickItem *ci = itemWindow ? itemWindow->contentItem() : nullptr;
+     while (parent && !QQuickItemPrivate::get(parent)->isAccessible && parent != ci)
+         parent = parent->parentItem();
+ 
+     if (parent) {
+         if (parent == ci) {
+-            // Jump out to the scene widget if the parent is the root item.
+-            // There are two root items, QQuickWindow::rootItem and
+-            // QQuickView::declarativeRoot. The former is the true root item,
+-            // but is not a part of the accessibility tree. Check if we hit
+-            // it here and return an interface for the scene instead.
+-            return QAccessible::queryAccessibleInterface(window);
++            // Jump out to the window if the parent is the root item
++            return QAccessible::queryAccessibleInterface(window());
+         } else {
+             while (parent && !parent->d_func()->isAccessible)
+                 parent = parent->parentItem();
+@@ -188,7 +197,7 @@ QAccessible::State QAccessibleQuickItem::state() const
+     QRect viewRect_ = viewRect();
+     QRect itemRect = rect();
+ 
+-    if (viewRect_.isNull() || itemRect.isNull() || !item()->window() || !item()->window()->isVisible() ||!item()->isVisible() || qFuzzyIsNull(item()->opacity()))
++    if (viewRect_.isNull() || itemRect.isNull() || !window() || !window()->isVisible() ||!item()->isVisible() || qFuzzyIsNull(item()->opacity()))
+         state.invisible = true;
+     if (!viewRect_.intersects(itemRect))
+         state.offscreen = true;
+@@ -201,6 +210,10 @@ QAccessible::State QAccessibleQuickItem::state() const
+     if (role() == QAccessible::EditableText)
+         if (auto ti = qobject_cast<QQuickTextInput *>(item()))
+             state.passwordEdit = ti->echoMode() != QQuickTextInput::Normal;
++    if (!item()->isEnabled()) {
++        state.focusable = false;
++        state.disabled = true;
++    }
+     return state;
+ }
+ 
+diff --git a/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h b/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
+index 39ffcaf39c..8baa01330c 100644
+--- a/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
++++ b/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
+@@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE
+ 
+ #if QT_CONFIG(accessibility)
+ 
+-class QAccessibleQuickWindow : public QAccessibleObject
++class Q_QUICK_EXPORT QAccessibleQuickWindow : public QAccessibleObject
+ {
+ public:
+     QAccessibleQuickWindow(QQuickWindow *object);
+diff --git a/qtdeclarative/src/quick/items/qquickdrag.cpp b/qtdeclarative/src/quick/items/qquickdrag.cpp
+index 8321fcfeed..383078b3b9 100644
+--- a/qtdeclarative/src/quick/items/qquickdrag.cpp
++++ b/qtdeclarative/src/quick/items/qquickdrag.cpp
+@@ -481,7 +481,9 @@ void QQuickDragAttached::setKeys(const QStringList &keys)
+     \qmlattachedproperty stringlist QtQuick::Drag::mimeData
+     \since 5.2
+ 
+-    This property holds a map of mimeData that is used during startDrag.
++    This property holds a map from mime type to data that is used during startDrag.
++    The mime data needs to be a \c string, or an \c ArrayBuffer with the data encoded
++    according to the mime type.
+ */
+ 
+ QVariantMap QQuickDragAttached::mimeData() const
+@@ -766,8 +768,12 @@ Qt::DropAction QQuickDragAttachedPrivate::startDrag(Qt::DropActions supportedAct
+     QDrag *drag = new QDrag(source ? source : q);
+     QMimeData *mimeData = new QMimeData();
+ 
+-    for (auto it = externalMimeData.cbegin(), end = externalMimeData.cend(); it != end; ++it)
+-        mimeData->setData(it.key(), it.value().toString().toUtf8());
++    for (auto it = externalMimeData.cbegin(), end = externalMimeData.cend(); it != end; ++it) {
++        if (static_cast<QMetaType::Type>(it.value().type()) == QMetaType::QByteArray)
++            mimeData->setData(it.key(), it.value().toByteArray());
++        else
++            mimeData->setData(it.key(), it.value().toString().toUtf8());
++    }
+ 
+     drag->setMimeData(mimeData);
+     if (pixmapLoader.isReady()) {
+diff --git a/qtdeclarative/src/quick/items/qquickitem.cpp b/qtdeclarative/src/quick/items/qquickitem.cpp
+index 75f1457816..dec0ae19ae 100644
+--- a/qtdeclarative/src/quick/items/qquickitem.cpp
++++ b/qtdeclarative/src/quick/items/qquickitem.cpp
+@@ -59,6 +59,7 @@
+ #include <QtCore/private/qnumeric_p.h>
+ #include <QtGui/qpa/qplatformtheme.h>
+ #include <QtCore/qloggingcategory.h>
++#include <QtCore/private/qduplicatetracker_p.h>
+ 
+ #include <private/qqmlglobal_p.h>
+ #include <private/qqmlengine_p.h>
+@@ -2326,6 +2327,7 @@ QQuickItem::QQuickItem(QQuickItemPrivate &dd, QQuickItem *parent)
+ QQuickItem::~QQuickItem()
+ {
+     Q_D(QQuickItem);
++    d->inDestructor = true;
+ 
+     if (d->windowRefCount > 1)
+         d->windowRefCount = 1; // Make sure window is set to null in next call to derefWindow().
+@@ -2526,6 +2528,7 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo
+     QQuickItem *current = item;
+     qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: startItem:" << startItem;
+     qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: firstFromItem:" << firstFromItem;
++    QDuplicateTracker<QQuickItem *> cycleDetector;
+     do {
+         qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: current:" << current;
+         qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: from:" << from;
+@@ -2592,7 +2595,10 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo
+         // traversed all of the chain (by compare the [current] item with [startItem])
+         // Since the [startItem] might be promoted to its parent if it is invisible,
+         // we still have to check [current] item with original start item
+-        if ((current == startItem || current == originalStartItem) && from == firstFromItem) {
++        // We might also run into a cycle before we reach firstFromItem again
++        // but note that we have to ignore current if we are meant to skip it
++        if (((current == startItem || current == originalStartItem) && from == firstFromItem) ||
++                (!skip && cycleDetector.hasSeen(current))) {
+             // wrapped around, avoid endless loops
+             if (item == contentItem) {
+                 qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: looped, return contentItem";
+@@ -2689,9 +2695,8 @@ void QQuickItem::setParentItem(QQuickItem *parentItem)
+ 
+         const bool wasVisible = isVisible();
+         op->removeChild(this);
+-        if (wasVisible) {
++        if (wasVisible && !op->inDestructor)
+             emit oldParentItem->visibleChildrenChanged();
+-        }
+     } else if (d->window) {
+         QQuickWindowPrivate::get(d->window)->parentlessItems.remove(this);
+     }
+@@ -2768,8 +2773,9 @@ void QQuickItem::setParentItem(QQuickItem *parentItem)
+ 
+     d->itemChange(ItemParentHasChanged, d->parentItem);
+ 
+-    emit parentChanged(d->parentItem);
+-    if (isVisible() && d->parentItem)
++    if (!d->inDestructor)
++        emit parentChanged(d->parentItem);
++    if (isVisible() && d->parentItem && !QQuickItemPrivate::get(d->parentItem)->inDestructor)
+         emit d->parentItem->visibleChildrenChanged();
+ }
+ 
+@@ -2965,7 +2971,8 @@ void QQuickItemPrivate::removeChild(QQuickItem *child)
+ 
+     itemChange(QQuickItem::ItemChildRemovedChange, child);
+ 
+-    emit q->childrenChanged();
++    if (!inDestructor)
++        emit q->childrenChanged();
+ }
+ 
+ void QQuickItemPrivate::refWindow(QQuickWindow *c)
+@@ -3194,6 +3201,7 @@ QQuickItemPrivate::QQuickItemPrivate()
+     , touchEnabled(false)
+ #endif
+     , hasCursorHandler(false)
++    , inDestructor(false)
+     , dirtyAttributes(0)
+     , nextDirtyItem(nullptr)
+     , prevDirtyItem(nullptr)
+@@ -5120,6 +5128,13 @@ void QQuickItem::componentComplete()
+         d->addToDirtyList();
+         QQuickWindowPrivate::get(d->window)->dirtyItem(this);
+     }
++
++#if QT_CONFIG(accessibility)
++    if (d->isAccessible && d->effectiveVisible) {
++        QAccessibleEvent ev(this, QAccessible::ObjectShow);
++        QAccessible::updateAccessibility(&ev);
++    }
++#endif
+ }
+ 
+ QQuickStateGroup *QQuickItemPrivate::_states()
+@@ -6106,9 +6121,11 @@ bool QQuickItemPrivate::setEffectiveVisibleRecur(bool newEffectiveVisible)
+         QAccessible::updateAccessibility(&ev);
+     }
+ #endif
+-    emit q->visibleChanged();
+-    if (childVisibilityChanged)
+-        emit q->visibleChildrenChanged();
++    if (!inDestructor) {
++        emit q->visibleChanged();
++        if (childVisibilityChanged)
++            emit q->visibleChildrenChanged();
++    }
+ 
+     return true;    // effective visibility DID change
+ }
+@@ -6157,6 +6174,15 @@ void QQuickItemPrivate::setEffectiveEnableRecur(QQuickItem *scope, bool newEffec
+     }
+ 
+     itemChange(QQuickItem::ItemEnabledHasChanged, effectiveEnable);
++#if QT_CONFIG(accessibility)
++    if (isAccessible) {
++        QAccessible::State changedState;
++        changedState.disabled = true;
++        changedState.focusable = true;
++        QAccessibleStateChangeEvent ev(q, changedState);
++        QAccessible::updateAccessibility(&ev);
++    }
++#endif
+     emit q->enabledChanged();
+ }
+ 
+diff --git a/qtdeclarative/src/quick/items/qquickitem_p.h b/qtdeclarative/src/quick/items/qquickitem_p.h
+index 841d91bb40..ade8fb61f2 100644
+--- a/qtdeclarative/src/quick/items/qquickitem_p.h
++++ b/qtdeclarative/src/quick/items/qquickitem_p.h
+@@ -472,6 +472,7 @@ public:
+     bool replayingPressEvent:1;
+     bool touchEnabled:1;
+     bool hasCursorHandler:1;
++    quint32 inDestructor:1; // has entered ~QQuickItem
+ 
+     enum DirtyType {
+         TransformOrigin         = 0x00000001,
+diff --git a/qtdeclarative/src/quick/items/qquickitemview.cpp b/qtdeclarative/src/quick/items/qquickitemview.cpp
+index 010a0152e1..f8ad168a17 100644
+--- a/qtdeclarative/src/quick/items/qquickitemview.cpp
++++ b/qtdeclarative/src/quick/items/qquickitemview.cpp
+@@ -1785,7 +1785,7 @@ void QQuickItemViewPrivate::refill(qreal from, qreal to)
+ 
+     do {
+         bufferPause.stop();
+-        if (currentChanges.hasPendingChanges() || bufferedChanges.hasPendingChanges()) {
++        if (currentChanges.hasPendingChanges() || bufferedChanges.hasPendingChanges() || currentChanges.active) {
+             currentChanges.reset();
+             bufferedChanges.reset();
+             releaseVisibleItems(reusableFlag);
+diff --git a/qtdeclarative/src/quick/items/qquickmousearea_p_p.h b/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
+index fba383e268..0d63618622 100644
+--- a/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
++++ b/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
+@@ -61,7 +61,6 @@ QT_BEGIN_NAMESPACE
+ 
+ class QQuickMouseEvent;
+ class QQuickMouseArea;
+-class QQuickPointerMask;
+ class QQuickMouseAreaPrivate : public QQuickItemPrivate
+ {
+     Q_DECLARE_PUBLIC(QQuickMouseArea)
+@@ -100,7 +99,6 @@ public:
+ #if QT_CONFIG(quick_draganddrop)
+     QQuickDrag *drag;
+ #endif
+-    QPointer<QQuickPointerMask> mask;
+     QPointF startScene;
+     QPointF targetStartPos;
+     QPointF lastPos;
+diff --git a/qtdeclarative/src/quick/items/qquicktext.cpp b/qtdeclarative/src/quick/items/qquicktext.cpp
+index 6230186933..e823ca1095 100644
+--- a/qtdeclarative/src/quick/items/qquicktext.cpp
++++ b/qtdeclarative/src/quick/items/qquicktext.cpp
+@@ -2168,7 +2168,7 @@ void QQuickText::resetMaximumLineCount()
+     <img src="" align="top,middle,bottom" width="" height=""> - inline images
+     <ol type="">, <ul type=""> and <li> - ordered and unordered lists
+     <pre></pre> - preformatted
+-    &gt; &lt; &amp;
++    &gt; &lt; &amp; &quot; &nbsp; &apos;
+     \endcode
+ 
+     \c Text.StyledText parser is strict, requiring tags to be correctly nested.
+diff --git a/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp b/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
+index eb4db0f85e..2325a2665b 100644
+--- a/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
++++ b/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
+@@ -446,7 +446,7 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+         const char *textureRecord = allocatorData;
+         for (int i = 0; i < textureCount; ++i, textureRecord += Qtdf::TextureRecordSize) {
+-            if (textureRecord + Qtdf::TextureRecordSize > qtdfTableEnd) {
++            if (qtdfTableEnd - textureRecord < Qtdf::TextureRecordSize) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+@@ -462,7 +462,7 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+         const char *glyphRecord = textureRecord;
+         for (quint32 i = 0; i < glyphCount; ++i, glyphRecord += Qtdf::GlyphRecordSize) {
+-            if (glyphRecord + Qtdf::GlyphRecordSize > qtdfTableEnd) {
++            if (qtdfTableEnd - glyphRecord < Qtdf:: GlyphRecordSize) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+@@ -512,8 +512,8 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+             int width = texInfo->allocatedArea.width();
+             int height = texInfo->allocatedArea.height();
+-            qint64 size = width * height;
+-            if (reinterpret_cast<const char *>(textureData + size) > qtdfTableEnd) {
++            qint64 size = qint64(width) * height;
++            if (qtdfTableEnd - reinterpret_cast<const char *>(textureData) < size) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+diff --git a/qtdeclarative/src/quick/util/qquickstyledtext.cpp b/qtdeclarative/src/quick/util/qquickstyledtext.cpp
+index d531fc9205..a25af90414 100644
+--- a/qtdeclarative/src/quick/util/qquickstyledtext.cpp
++++ b/qtdeclarative/src/quick/util/qquickstyledtext.cpp
+@@ -564,6 +564,8 @@ void QQuickStyledTextPrivate::parseEntity(const QChar *&ch, const QString &textI
+                 textOut += QChar(60);
+             else if (entity == QLatin1String("amp"))
+                 textOut += QChar(38);
++            else if (entity == QLatin1String("apos"))
++                textOut += QChar(39);
+             else if (entity == QLatin1String("quot"))
+                 textOut += QChar(34);
+             else if (entity == QLatin1String("nbsp"))
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp
+new file mode 100644
+index 0000000000..8a1c901880
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp
+@@ -0,0 +1,110 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include "qaccessiblequickwidget_p.h"
++
++#include "qquickwidget_p.h"
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleQuickWidget::QAccessibleQuickWidget(QQuickWidget* widget)
++: QAccessibleWidget(widget)
++, m_accessibleWindow(QQuickWidgetPrivate::get(widget)->offscreenWindow)
++{
++    // NOTE: m_accessibleWindow is a QAccessibleQuickWindow, and not a
++    // QAccessibleQuickWidgetOffscreenWindow (defined below). This means
++    // it will return the Quick item child interfaces, which is what's needed here
++    // (unlike QAccessibleQuickWidgetOffscreenWindow, which will report 0 children).
++}
++
++QAccessibleInterface *QAccessibleQuickWidget::child(int index) const
++{
++    return m_accessibleWindow.child(index);
++}
++
++int QAccessibleQuickWidget::childCount() const
++{
++    return m_accessibleWindow.childCount();
++}
++
++int QAccessibleQuickWidget::indexOfChild(const QAccessibleInterface *iface) const
++{
++    return m_accessibleWindow.indexOfChild(iface);
++}
++
++QAccessibleInterface *QAccessibleQuickWidget::childAt(int x, int y) const
++{
++    return m_accessibleWindow.childAt(x, y);
++}
++
++QAccessibleQuickWidgetOffscreenWindow::QAccessibleQuickWidgetOffscreenWindow(QQuickWindow *window)
++:QAccessibleQuickWindow(window)
++{
++
++}
++
++QAccessibleInterface *QAccessibleQuickWidgetOffscreenWindow::child(int index) const
++{
++    Q_UNUSED(index);
++    return nullptr;
++}
++
++int QAccessibleQuickWidgetOffscreenWindow::childCount() const
++{
++    return 0;
++}
++
++int QAccessibleQuickWidgetOffscreenWindow::indexOfChild(const QAccessibleInterface *iface) const
++{
++    Q_UNUSED(iface);
++    return -1;
++}
++
++QAccessibleInterface *QAccessibleQuickWidgetOffscreenWindow::QAccessibleQuickWidgetOffscreenWindow::childAt(int x, int y) const
++{
++    Q_UNUSED(x);
++    Q_UNUSED(y);
++    return nullptr;
++}
++
++#endif // accessibility
++
++QT_END_NAMESPACE
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h
+new file mode 100644
+index 0000000000..7c2ab930e0
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h
+@@ -0,0 +1,95 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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 QACCESSIBLEQUICKWIDGET_H
++#define QACCESSIBLEQUICKWIDGET_H
++
++//
++//  W A R N I N G
++//  -------------
++//
++// This file is not part of the Qt API.  It exists purely as an
++// implementation detail.  This header file may change from version to
++// version without notice, or even be removed.
++//
++// We mean it.
++//
++
++#include "qquickwidget.h"
++#include <QtWidgets/qaccessiblewidget.h>
++
++#include <private/qaccessiblequickview_p.h>
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++// These classes implement the QQuickWiget accessibility switcharoo,
++// where the child items of the QQuickWidgetOffscreenWindow are reported
++// as child accessible interfaces of the QAccessibleQuickWidget.
++class QAccessibleQuickWidget: public QAccessibleWidget
++{
++public:
++    QAccessibleQuickWidget(QQuickWidget* widget);
++
++    QAccessibleInterface *child(int index) const override;
++    int childCount() const override;
++    int indexOfChild(const QAccessibleInterface *iface) const override;
++    QAccessibleInterface *childAt(int x, int y) const override;
++
++private:
++    QAccessibleQuickWindow m_accessibleWindow;
++    Q_DISABLE_COPY(QAccessibleQuickWidget)
++};
++
++class QAccessibleQuickWidgetOffscreenWindow: public QAccessibleQuickWindow
++{
++public:
++    QAccessibleQuickWidgetOffscreenWindow(QQuickWindow *window);
++    QAccessibleInterface *child(int index) const override;
++    int childCount() const override;
++    int indexOfChild(const QAccessibleInterface *iface) const override;
++    QAccessibleInterface *childAt(int x, int y) const override;
++};
++
++#endif // accessibility
++
++QT_END_NAMESPACE
++
++#endif
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp
+new file mode 100644
+index 0000000000..7ba88a1769
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp
+@@ -0,0 +1,60 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include "qaccessiblequickwidgetfactory_p.h"
++#include "qaccessiblequickwidget_p.h"
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleInterface *qAccessibleQuickWidgetFactory(const QString &classname, QObject *object)
++{
++    if (classname == QLatin1String("QQuickWidget")) {
++        return new QAccessibleQuickWidget(qobject_cast<QQuickWidget *>(object));
++    } else if (classname == QLatin1String("QQuickWidgetOffscreenWindow")) {
++        return new QAccessibleQuickWidgetOffscreenWindow(qobject_cast<QQuickWindow *>(object));
++    }
++    return 0;
++}
++
++#endif // accessibility
++
++QT_END_NAMESPACE
++
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h
+new file mode 100644
+index 0000000000..8c63b09f81
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h
+@@ -0,0 +1,66 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include <QtGui/qaccessible.h>
++
++#ifndef QACCESSIBLEQUICKWIDGETFACTORY_H
++#define QACCESSIBLEQUICKWIDGETFACTORY_H
++
++//
++//  W A R N I N G
++//  -------------
++//
++// This file is not part of the Qt API.  It exists purely as an
++// implementation detail.  This header file may change from version to
++// version without notice, or even be removed.
++//
++// We mean it.
++//
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleInterface *qAccessibleQuickWidgetFactory(const QString &classname, QObject *object);
++
++#endif
++
++QT_END_NAMESPACE
++
++#endif
+diff --git a/qtdeclarative/src/quickwidgets/qquickwidget.cpp b/qtdeclarative/src/quickwidgets/qquickwidget.cpp
+index 39780f8de3..9c97b43518 100644
+--- a/qtdeclarative/src/quickwidgets/qquickwidget.cpp
++++ b/qtdeclarative/src/quickwidgets/qquickwidget.cpp
+@@ -39,6 +39,7 @@
+ 
+ #include "qquickwidget.h"
+ #include "qquickwidget_p.h"
++#include "qaccessiblequickwidgetfactory_p.h"
+ 
+ #include "private/qquickwindow_p.h"
+ #include "private/qquickitem_p.h"
+@@ -75,9 +76,16 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++QQuickWidgetOffscreenWindow::QQuickWidgetOffscreenWindow(QQuickWindowPrivate &dd, QQuickRenderControl *control)
++:QQuickWindow(dd, control)
++{
++    setTitle(QString::fromLatin1("Offscreen"));
++    setObjectName(QString::fromLatin1("QQuickOffScreenWindow"));
++}
++
+ // override setVisble to prevent accidental offscreen window being created
+ // by base class.
+-class QQuickOffcreenWindowPrivate: public QQuickWindowPrivate {
++class QQuickWidgetOffscreenWindowPrivate: public QQuickWindowPrivate {
+ public:
+     void setVisible(bool visible) override {
+         Q_Q(QWindow);
+@@ -105,9 +113,8 @@ void QQuickWidgetPrivate::init(QQmlEngine* e)
+     Q_Q(QQuickWidget);
+ 
+     renderControl = new QQuickWidgetRenderControl(q);
+-    offscreenWindow = new QQuickWindow(*new QQuickOffcreenWindowPrivate(),renderControl);
+-    offscreenWindow->setTitle(QString::fromLatin1("Offscreen"));
+-    offscreenWindow->setObjectName(QString::fromLatin1("QQuickOffScreenWindow"));
++    offscreenWindow = new QQuickWidgetOffscreenWindow(*new QQuickWidgetOffscreenWindowPrivate(), renderControl);
++    offscreenWindow->setScreen(q->screen());
+     // Do not call create() on offscreenWindow.
+ 
+     // Check if the Software Adaptation is being used
+@@ -138,6 +145,10 @@ void QQuickWidgetPrivate::init(QQmlEngine* e)
+     QWidget::connect(offscreenWindow, &QQuickWindow::focusObjectChanged, q, &QQuickWidget::propagateFocusObjectChanged);
+     QObject::connect(renderControl, SIGNAL(renderRequested()), q, SLOT(triggerUpdate()));
+     QObject::connect(renderControl, SIGNAL(sceneChanged()), q, SLOT(triggerUpdate()));
++
++#if QT_CONFIG(accessibility)
++    QAccessible::installFactory(&qAccessibleQuickWidgetFactory);
++#endif
+ }
+ 
+ void QQuickWidgetPrivate::ensureEngine() const
+@@ -901,9 +912,7 @@ void QQuickWidgetPrivate::createContext()
+ 
+         context = new QOpenGLContext;
+         context->setFormat(offscreenWindow->requestedFormat());
+-        const QWindow *win = q->window()->windowHandle();
+-        if (win && win->screen())
+-            context->setScreen(win->screen());
++        context->setScreen(q->screen());
+         QOpenGLContext *shareContext = qt_gl_global_share_context();
+         if (!shareContext)
+             shareContext = QWidgetPrivate::get(q->window())->shareContext();
+@@ -1520,19 +1529,16 @@ bool QQuickWidget::event(QEvent *e)
+         d->handleWindowChange();
+         break;
+ 
+-    case QEvent::ScreenChangeInternal:
+-        if (QWindow *window = this->window()->windowHandle()) {
+-            QScreen *newScreen = window->screen();
+-
+-            if (d->offscreenWindow)
+-                d->offscreenWindow->setScreen(newScreen);
+-            if (d->offscreenSurface)
+-                d->offscreenSurface->setScreen(newScreen);
++    case QEvent::ScreenChangeInternal: {
++        QScreen *newScreen = screen();
++        if (d->offscreenWindow)
++            d->offscreenWindow->setScreen(newScreen);
++        if (d->offscreenSurface)
++            d->offscreenSurface->setScreen(newScreen);
+ #if QT_CONFIG(opengl)
+-            if (d->context)
+-                d->context->setScreen(newScreen);
++        if (d->context)
++            d->context->setScreen(newScreen);
+ #endif
+-        }
+ 
+         if (d->useSoftwareRenderer
+ #if QT_CONFIG(opengl)
+@@ -1545,7 +1551,7 @@ bool QQuickWidget::event(QEvent *e)
+             d->render(true);
+         }
+         break;
+-
++    }
+     case QEvent::Show:
+     case QEvent::Move:
+         d->updatePosition();
+diff --git a/qtdeclarative/src/quickwidgets/qquickwidget_p.h b/qtdeclarative/src/quickwidgets/qquickwidget_p.h
+index 881f7f9220..1a946bcc71 100644
+--- a/qtdeclarative/src/quickwidgets/qquickwidget_p.h
++++ b/qtdeclarative/src/quickwidgets/qquickwidget_p.h
+@@ -148,6 +148,14 @@ public:
+     bool forceFullUpdate;
+ };
+ 
++class QQuickWidgetOffscreenWindow: public QQuickWindow
++{
++    Q_OBJECT
++
++public:
++    QQuickWidgetOffscreenWindow(QQuickWindowPrivate &dd, QQuickRenderControl *control);
++};
++
+ QT_END_NAMESPACE
+ 
+ #endif // QQuickWidget_P_H
+diff --git a/qtdeclarative/src/quickwidgets/quickwidgets.pro b/qtdeclarative/src/quickwidgets/quickwidgets.pro
+index 2438e577ae..85d156b8a3 100644
+--- a/qtdeclarative/src/quickwidgets/quickwidgets.pro
++++ b/qtdeclarative/src/quickwidgets/quickwidgets.pro
+@@ -7,9 +7,13 @@ DEFINES   += QT_NO_URL_CAST_FROM_STRING QT_NO_INTEGER_EVENT_COORDINATES QT_NO_FO
+ HEADERS += \
+     qquickwidget.h \
+     qquickwidget_p.h \
+-    qtquickwidgetsglobal.h
++    qtquickwidgetsglobal.h \
++    qaccessiblequickwidget_p.h \
++    qaccessiblequickwidgetfactory_p.h
+ 
+ SOURCES += \
+-    qquickwidget.cpp
++    qquickwidget.cpp \
++    qaccessiblequickwidget.cpp \
++    qaccessiblequickwidgetfactory.cpp
+ 
+ load(qt_module)
+diff --git a/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+index 3b7d74df63..b75bf820d5 100644
+--- a/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
++++ b/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+@@ -102,6 +102,7 @@ private slots:
+     void valueConversion_RegularExpression();
+     void castWithMultipleInheritance();
+     void collectGarbage();
++    void collectGarbageNestedWrappersTwoEngines();
+     void gcWithNestedDataStructure();
+     void stacktrace();
+     void numberParsing_data();
+@@ -1809,6 +1810,44 @@ void tst_QJSEngine::collectGarbage()
+     QVERIFY(ptr.isNull());
+ }
+ 
++class TestObjectContainer : public QObject
++{
++    Q_OBJECT
++    Q_PROPERTY(QObject *dummy MEMBER m_dummy CONSTANT)
++
++public:
++    TestObjectContainer() : m_dummy(new QObject(this)) {}
++
++private:
++    QObject *m_dummy;
++};
++
++void tst_QJSEngine::collectGarbageNestedWrappersTwoEngines()
++{
++    QJSEngine engine1;
++    QJSEngine engine2;
++
++    TestObjectContainer container;
++    QQmlEngine::setObjectOwnership(&container, QQmlEngine::CppOwnership);
++
++    engine1.globalObject().setProperty("foobar", engine1.newQObject(&container));
++    engine2.globalObject().setProperty("foobar", engine2.newQObject(&container));
++
++    engine1.evaluate("foobar.dummy.baz = 42");
++    engine2.evaluate("foobar.dummy.baz = 43");
++
++    QCOMPARE(engine1.evaluate("foobar.dummy.baz").toInt(), 42);
++    QCOMPARE(engine2.evaluate("foobar.dummy.baz").toInt(), 43);
++
++    engine1.collectGarbage();
++    engine2.collectGarbage();
++
++    // The GC should not collect dummy object wrappers neither in engine1 nor engine2, we
++    // verify that by checking whether the baz property still has its previous value.
++    QCOMPARE(engine1.evaluate("foobar.dummy.baz").toInt(), 42);
++    QCOMPARE(engine2.evaluate("foobar.dummy.baz").toInt(), 43);
++}
++
+ void tst_QJSEngine::gcWithNestedDataStructure()
+ {
+     // The GC must be able to traverse deeply nested objects, otherwise this
+diff --git a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml
+new file mode 100644
+index 0000000000..206133bb39
+--- /dev/null
++++ b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml
+@@ -0,0 +1,11 @@
++import QtQuick 2.8
++
++ListView {
++    id: root
++    width: 200
++    height: 200
++
++    delegate: Text {
++        text: display
++    }
++}
+diff --git a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
+index 35f1e2c94d..1722447830 100644
+--- a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
++++ b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
+@@ -27,6 +27,8 @@
+ ****************************************************************************/
+ 
+ #include <QtTest/qtest.h>
++#include <QtCore/QConcatenateTablesProxyModel>
++#include <QtGui/QStandardItemModel>
+ #include <QtQml/qqmlcomponent.h>
+ #include <QtQmlModels/private/qqmldelegatemodel_p.h>
+ #include <QtQuick/qquickview.h>
+@@ -47,6 +49,7 @@ private slots:
+     void filterOnGroup_removeWhenCompleted();
+     void qtbug_86017();
+     void contextAccessedByHandler();
++    void redrawUponColumnChange();
+ };
+ 
+ class AbstractItemModel : public QAbstractItemModel
+@@ -186,6 +189,30 @@ void tst_QQmlDelegateModel::contextAccessedByHandler()
+     QVERIFY(root->property("works").toBool());
+ }
+ 
++void tst_QQmlDelegateModel::redrawUponColumnChange()
++{
++    QStandardItemModel m1;
++    m1.appendRow({
++            new QStandardItem("Banana"),
++            new QStandardItem("Coconut"),
++    });
++
++    QQuickView view(testFileUrl("redrawUponColumnChange.qml"));
++    QCOMPARE(view.status(), QQuickView::Ready);
++    view.show();
++    QQuickItem *root = view.rootObject();
++    root->setProperty("model", QVariant::fromValue<QObject *>(&m1));
++
++    QObject *item = root->property("currentItem").value<QObject *>();
++    QVERIFY(item);
++    QCOMPARE(item->property("text").toString(), "Banana");
++
++    QVERIFY(root);
++    m1.removeColumn(0);
++
++    QCOMPARE(item->property("text").toString(), "Coconut");
++}
++
+ QTEST_MAIN(tst_QQmlDelegateModel)
+ 
+ #include "tst_qqmldelegatemodel.moc"
+diff --git a/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp b/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
+index 5d635aa63b..824fd89e5b 100644
+--- a/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
++++ b/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
+@@ -76,10 +76,10 @@ void tst_qv4mm::multiWrappedQObjects()
+         QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 1);
+         QCOMPARE(engine2.memoryManager->m_pendingFreedObjectWrapperValue.size(), 0);
+ 
+-        // Moves the additional WeakValue from m_multiplyWrappedQObjects to
+-        // m_pendingFreedObjectWrapperValue. It's still alive after all.
++        // The additional WeakValue from m_multiplyWrappedQObjects hasn't been moved
++        // to m_pendingFreedObjectWrapperValue yet. It's still alive after all.
+         engine1.memoryManager->runGC();
+-        QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 2);
++        QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 1);
+ 
+         // engine2 doesn't own the object as engine1 was the first to wrap it above.
+         // Therefore, no effect here.
+diff --git a/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml b/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml
+new file mode 100644
+index 0000000000..889e480f3b
+--- /dev/null
++++ b/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml
+@@ -0,0 +1,13 @@
++import QtQuick 2.6
++
++Item {
++    visible: true
++    Item {
++        visible: false
++        Item {
++            objectName: "hiddenChild"
++            activeFocusOnTab: true
++            focus: true
++        }
++    }
++}
+diff --git a/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp b/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+index c8f251dbe1..c8ef36ee68 100644
+--- a/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
++++ b/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+@@ -67,6 +67,7 @@ private slots:
+     void activeFocusOnTab10();
+     void activeFocusOnTab_infiniteLoop_data();
+     void activeFocusOnTab_infiniteLoop();
++    void activeFocusOnTab_infiniteLoopControls();
+ 
+     void nextItemInFocusChain();
+     void nextItemInFocusChain2();
+@@ -1057,6 +1058,17 @@ void tst_QQuickItem::activeFocusOnTab_infiniteLoop()
+     QCOMPARE(item, window->rootObject());
+ }
+ 
++
++void tst_QQuickItem::activeFocusOnTab_infiniteLoopControls()
++{
++    auto source = testFileUrl("activeFocusOnTab_infiniteLoop3.qml");
++    QScopedPointer<QQuickView>window(new QQuickView());
++    window->setSource(source);
++    window->show();
++    QVERIFY(window->errors().isEmpty());
++    QTest::keyClick(window.get(), Qt::Key_Tab); // should not hang
++}
++
+ void tst_QQuickItem::nextItemInFocusChain()
+ {
+     if (!qt_tab_all_widgets())
+Submodule qtdoc c0c7bf07...79d6ef69:
+Submodule qtimageformats 2dcf2899..abe44c0f:
+diff --git a/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp b/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
+index dde783c..1bf9074 100644
+--- a/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
+@@ -462,8 +462,12 @@ static bool parseIconEntryInfo(ICNSEntry &icon)
+     if (isIconCompressed(icon))
+         return true;
+     // Icon depth:
+-    if (!depth.isEmpty())
+-        icon.depth = ICNSEntry::Depth(depth.toUInt());
++    if (!depth.isEmpty()) {
++        const uint depthUInt = depth.toUInt();
++        if (depthUInt > 32)
++            return false;
++        icon.depth = ICNSEntry::Depth(depthUInt);
++    }
+     // Try mono if depth not found
+     if (icon.depth == ICNSEntry::DepthUnknown)
+         icon.depth = ICNSEntry::DepthMono;
+@@ -515,6 +519,9 @@ static bool parseIconEntryInfo(ICNSEntry &icon)
+         }
+         icon.height = icon.width;
+     }
++    // Sanity check
++    if (icon.width == 0 || icon.width > 4096)
++        return false;
+     return true;
+ }
+ 
+@@ -685,7 +692,7 @@ bool QICNSHandler::canRead() const
+ bool QICNSHandler::read(QImage *outImage)
+ {
+     QImage img;
+-    if (!ensureScanned()) {
++    if (!ensureScanned() || m_currentIconIndex >= m_icons.size()) {
+         qWarning("QICNSHandler::read(): The device wasn't parsed properly!");
+         return false;
+     }
+@@ -892,7 +899,7 @@ bool QICNSHandler::scanDevice()
+             return false;
+ 
+         const qint64 blockDataOffset = device()->pos();
+-        if (!isBlockHeaderValid(blockHeader)) {
++        if (!isBlockHeaderValid(blockHeader, ICNSBlockHeaderSize + filelength - blockDataOffset)) {
+             qWarning("QICNSHandler::scanDevice(): Failed, bad header at pos %s. OSType \"%s\", length %u",
+                      QByteArray::number(blockDataOffset).constData(),
+                      nameFromOSType(blockHeader.ostype).constData(), blockHeader.length);
+@@ -927,11 +934,14 @@ bool QICNSHandler::scanDevice()
+         case ICNSBlockHeader::TypeOdrp:
+             // Icns container seems to have an embedded icon variant container
+             // Let's start a scan for entries
+-            while (device()->pos() < nextBlockOffset) {
++            while (!stream.atEnd() && device()->pos() < nextBlockOffset) {
+                 ICNSBlockHeader icon;
+                 stream >> icon;
++                if (stream.status() != QDataStream::Ok)
++                    return false;
+                 // Check for incorrect variant entry header and stop scan
+-                if (!isBlockHeaderValid(icon, blockDataLength))
++                quint64 remaining = blockDataLength - (device()->pos() - blockDataOffset);
++                if (!isBlockHeaderValid(icon, ICNSBlockHeaderSize + remaining))
+                     break;
+                 if (!addEntry(icon, device()->pos(), blockHeader.ostype))
+                     return false;
+@@ -1003,7 +1013,7 @@ bool QICNSHandler::scanDevice()
+             break;
+         }
+     }
+-    return true;
++    return (m_icons.size() > 0);
+ }
+ 
+ const ICNSEntry &QICNSHandler::getIconMask(const ICNSEntry &icon) const
+diff --git a/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp b/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
+index 5082023..cb34374 100644
+--- a/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
++++ b/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
+@@ -43,6 +43,7 @@
+ #include "qimage.h"
+ #include "qvariant.h"
+ #include "qcolor.h"
++#include "qimagereader.h"
+ 
+ #include <jasper/jasper.h>
+ #include <math.h> // for pow
+@@ -333,16 +334,46 @@ private:
+ Jpeg2000JasperReader::Jpeg2000JasperReader(QIODevice *iod, SubFormat format)
+     : jasperOk(true), ioDevice(iod), format(format), hasAlpha(false)
+ {
++#if JAS_VERSION_MAJOR < 3
+     if (jas_init()) {
+         jasperOk = false;
+         qDebug("Jasper Library initialization failed");
+     }
++#else
++    jas_conf_clear();
++#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
++    jas_conf_set_max_mem_usage(QImageReader::allocationLimit() * 1024 * 1024);
++#else
++    // 128MB seems to be enough.
++    jas_conf_set_max_mem_usage(128 * 1024 * 1024);
++#endif
++    if (jas_init_library()) {
++        jasperOk = false;
++        qDebug("Jasper library initialization failed");
++    }
++    if (jas_init_thread()) {
++        jas_cleanup_library();
++        jasperOk = false;
++        qDebug("Jasper thread initialization failed");
++    }
++#endif
+ }
+ 
+ Jpeg2000JasperReader::~Jpeg2000JasperReader()
+ {
++#if JAS_VERSION_MAJOR < 3
+     if (jasperOk)
+         jas_cleanup();
++#else
++    if (jasperOk) {
++        if (jas_cleanup_thread()) {
++            qDebug("Jasper thread cleanup failed");
++        }
++        if (jas_cleanup_library()) {
++            qDebug("Jasper library cleanup failed");
++        }
++    }
++#endif
+ }
+ 
+ /*! \internal
+@@ -857,7 +888,7 @@ bool Jpeg2000JasperReader::write(const QImage &image, int quality)
+     }
+ 
+     // Open an empty jasper stream that grows automatically
+-    jas_stream_t * memory_stream = jas_stream_memopen(0, -1);
++    jas_stream_t * memory_stream = jas_stream_memopen(0, 0);
+ 
+     // Jasper wants a non-const string.
+     char *str = qstrdup(jasperFormatString.toLatin1().constData());
+diff --git a/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp b/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
+index 1386750..ac8956c 100644
+--- a/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
+@@ -361,6 +361,8 @@ bool QTiffHandler::read(QImage *image)
+     }
+ 
+     TIFF *const tiff = d->tiff;
++    if (TIFFIsTiled(tiff) && TIFFTileSize64(tiff) > uint64_t(image->sizeInBytes())) // Corrupt image
++        return false;
+     const quint32 width = d->size.width();
+     const quint32 height = d->size.height();
+ 
+diff --git a/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp b/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
+index 82d38cb..d02eb05 100644
+--- a/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
+@@ -45,6 +45,7 @@
+ #include <qdebug.h>
+ #include <qpainter.h>
+ #include <qvariant.h>
++#include <QtEndian>
+ 
+ static const int riffHeaderSize = 12; // RIFF_HEADER_SIZE from webp/format_constants.h
+ 
+@@ -102,21 +103,23 @@ bool QWebpHandler::ensureScanned() const
+ 
+     m_scanState = ScanError;
+ 
+-    if (device()->isSequential()) {
+-        qWarning() << "Sequential devices are not supported";
++    QWebpHandler *that = const_cast<QWebpHandler *>(this);
++    const int headerBytesNeeded = sizeof(WebPBitstreamFeatures);
++    QByteArray header = device()->peek(headerBytesNeeded);
++    if (header.size() < headerBytesNeeded)
+         return false;
+-    }
+ 
+-    qint64 oldPos = device()->pos();
+-    device()->seek(0);
+-
+-    QWebpHandler *that = const_cast<QWebpHandler *>(this);
+-    QByteArray header = device()->peek(sizeof(WebPBitstreamFeatures));
++    // We do no random access during decoding, just a readAll() of the whole image file. So if
++    // if it is all available already, we can accept a sequential device. The riff header contains
++    // the file size minus 8 bytes header
++    qint64 byteSize = qFromLittleEndian<quint32>(header.constData() + 4);
++    if (device()->isSequential() && device()->bytesAvailable() < byteSize + 8) {
++        qWarning() << "QWebpHandler: Insufficient data available in sequential device";
++        return false;
++    }
+     if (WebPGetFeatures((const uint8_t*)header.constData(), header.size(), &(that->m_features)) == VP8_STATUS_OK) {
+         if (m_features.has_animation) {
+             // For animation, we have to read and scan whole file to determine loop count and images count
+-            device()->seek(oldPos);
+-
+             if (that->ensureDemuxer()) {
+                 that->m_loop = WebPDemuxGetI(m_demuxer, WEBP_FF_LOOP_COUNT);
+                 that->m_frameCount = WebPDemuxGetI(m_demuxer, WEBP_FF_FRAME_COUNT);
+@@ -126,17 +129,13 @@ bool QWebpHandler::ensureScanned() const
+                 if (that->m_features.has_alpha)
+                     that->m_composited->fill(Qt::transparent);
+ 
+-                // We do not reset device position since we have read in all data
+                 m_scanState = ScanSuccess;
+-                return true;
+             }
+         } else {
+             m_scanState = ScanSuccess;
+         }
+     }
+ 
+-    device()->seek(oldPos);
+-
+     return m_scanState == ScanSuccess;
+ }
+ 
+@@ -159,7 +158,7 @@ bool QWebpHandler::ensureDemuxer()
+ 
+ bool QWebpHandler::read(QImage *image)
+ {
+-    if (!ensureScanned() || device()->isSequential() || !ensureDemuxer())
++    if (!ensureScanned() || !ensureDemuxer())
+         return false;
+ 
+     QRect prevFrameRect;
+Submodule qtlocation 98a5c511..f991e28c:
+diff --git a/qtlocation/src/location/configure.json b/qtlocation/src/location/configure.json
+index 6d01a9a3..d1e623a1 100644
+--- a/qtlocation/src/location/configure.json
++++ b/qtlocation/src/location/configure.json
+@@ -9,7 +9,7 @@
+             "label": "Qt.labs.location experimental QML plugin",
+             "purpose": "Provides experimental QtLocation QML types",
+             "section": "Location",
+-            "condition": "config.opengl",
++            "condition": "features.opengl",
+             "output": [ "privateFeature" ]
+         },
+         "geoservices_osm": {
+diff --git a/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp b/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
+index a978573d..11e1466f 100644
+--- a/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
++++ b/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
+@@ -158,7 +158,7 @@ void QGeoMapObjectQSGSupport::updateMapObjects(QSGNode *root, QQuickWindow *wind
+     if (!root)
+         return;
+ 
+-    if (m_mapObjectsRootNode && m_mapObjectsRootNode->parent())
++    if (m_mapObjectsRootNode && !m_mapObjectsRootNode->parent())
+         root->appendChildNode(m_mapObjectsRootNode.get());
+ 
+     if (!m_mapObjectsRootNode) {
+diff --git a/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
+index 5a40467e..d123c6a8 100644
+--- a/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
+@@ -59,8 +59,10 @@ QT_BEGIN_NAMESPACE
+ static const QString kPrefixEsri(QStringLiteral("esri."));
+ static const QString kParamUserAgent(kPrefixEsri + QStringLiteral("useragent"));
+ 
+-static const QString kUrlGeocode(QStringLiteral("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates"));
+-static const QString kUrlReverseGeocode(QStringLiteral("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode"));
++static const QString kUrlGeocode(QStringLiteral("https://geocode.arcgis.com/arcgis/rest/services/"
++                                                "World/GeocodeServer/findAddressCandidates"));
++static const QString kUrlReverseGeocode(QStringLiteral(
++        "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode"));
+ 
+ static QString addressToQuery(const QGeoAddress &address)
+ {
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
+index 17492d94..96c12b1b 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
+@@ -46,7 +46,8 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-// JSON reference: http://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
++// JSON reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
+ 
+ static const QString kErrorMessage(QStringLiteral("Error %1: %2."));
+ static const QString kErrorJson(QStringLiteral("Error: invalide JSON document."));
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
+index 8cadfb29..92b6bb13 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
+@@ -44,7 +44,8 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-// JSON reference: http://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
++// JSON reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
+ 
+ GeoRouteReplyEsri::GeoRouteReplyEsri(QNetworkReply *reply, const QGeoRouteRequest &request,
+                                      QObject *parent) :
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
+index 0e6bc2c7..ed613f4b 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
+@@ -48,7 +48,8 @@ static const QString kPrefixEsri(QStringLiteral("esri."));
+ static const QString kParamUserAgent(kPrefixEsri + QStringLiteral("useragent"));
+ static const QString kParamToken(kPrefixEsri + QStringLiteral("token"));
+ 
+-static const QString kUrlRouting(QStringLiteral("http://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve"));
++static const QString kUrlRouting(QStringLiteral(
++        "https://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve"));
+ 
+ GeoRoutingManagerEngineEsri::GeoRoutingManagerEngineEsri(const QVariantMap &parameters,
+                                                          QGeoServiceProvider::Error *error,
+@@ -70,7 +71,8 @@ GeoRoutingManagerEngineEsri::~GeoRoutingManagerEngineEsri()
+ {
+ }
+ 
+-// REST reference: http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
++// REST reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
+ 
+ QGeoRouteReply *GeoRoutingManagerEngineEsri::calculateRoute(const QGeoRouteRequest &request)
+ {
+@@ -125,7 +127,7 @@ void GeoRoutingManagerEngineEsri::replyError(QGeoRouteReply::Error errorCode, co
+ QString GeoRoutingManagerEngineEsri::preferedDirectionLangage()
+ {
+     // list of supported langages is defined in:
+-    // http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
++    // https://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
+     const QStringList supportedLanguages = {
+         "ar", // Generate directions in Arabic
+         "cs", // Generate directions in Czech
+diff --git a/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
+index 5d15835d..24148f95 100644
+--- a/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
+@@ -230,7 +230,8 @@ QGeoMap *GeoTiledMappingManagerEngineEsri::createMap()
+ // ${y} = Y
+ // ${token} = Token
+ 
+-// template = 'http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{{z}}/{{y}}/{{x}}.png'
++// template =
++// 'https://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{{z}}/{{y}}/{{x}}.png'
+ 
+ bool GeoTiledMappingManagerEngineEsri::initializeMapSources(QGeoServiceProvider::Error *error,
+                                                             QString *errorString,
+diff --git a/qtlocation/src/plugins/geoservices/esri/maps.json b/qtlocation/src/plugins/geoservices/esri/maps.json
+index 8167ae7d..862e087d 100644
+--- a/qtlocation/src/plugins/geoservices/esri/maps.json
++++ b/qtlocation/src/plugins/geoservices/esri/maps.json
+@@ -6,8 +6,8 @@
+             "description": "ArcGIS Online World Street Map",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=3b93337983e9436f8db950e38a8629af'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=3b93337983e9436f8db950e38a8629af'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -16,8 +16,8 @@
+             "": "ArcGIS Online World Imagery",
+             "mobile": true,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -26,8 +26,8 @@
+             "description": "ArcGIS Online World Terrain Base",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=c61ad8ab017d49e1a82f580ee1298931'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=c61ad8ab017d49e1a82f580ee1298931'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -36,8 +36,8 @@
+             "description": "ArcGIS Online World Topography",
+             "mobile": true,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=30e5fe3149c34df1ba922e6f5bbf808f'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=30e5fe3149c34df1ba922e6f5bbf808f'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -46,8 +46,8 @@
+             "description": "This map presents land cover and detailed topographic maps for the United States.",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=99cd5fbd98934028802b4f797c4b1732'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=99cd5fbd98934028802b4f797c4b1732'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -56,8 +56,8 @@
+             "description": "National Geographic World Map",
+             "mobile": false,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=b9b1b422198944fbbd5250b3241691b6'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=b9b1b422198944fbbd5250b3241691b6'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -66,8 +66,8 @@
+             "description": "Thematic content providing a neutral background with minimal colors",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=ed712cb1db3e4bae9e85329040fb9a49'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=ed712cb1db3e4bae9e85329040fb9a49'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -76,8 +76,8 @@
+             "description": "Natural Earth physical map for the world",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=c4ec722a1cd34cf0a23904aadf8923a0'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=c4ec722a1cd34cf0a23904aadf8923a0'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -86,8 +86,8 @@
+             "description": "Portrays surface elevation as shaded relief",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=9c5370d0b54f4de1b48a3792d7377ff2'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=9c5370d0b54f4de1b48a3792d7377ff2'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -96,8 +96,8 @@
+             "description": "This map is designed to be used as a basemap by marine GIS professionals and as a reference map by anyone interested in ocean data",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=1e126e7520f9466c9ca28b8f28b5e500'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=1e126e7520f9466c9ca28b8f28b5e500'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -106,8 +106,8 @@
+             "description": "Thematic content providing a neutral background with minimal colors",
+             "mobile": false,
+             "night": true,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=a284a9b99b3446a3910d4144a50990f6'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=a284a9b99b3446a3910d4144a50990f6'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -116,8 +116,8 @@
+             "description": "DeLorme’s topographic basemap is a seamless global data set that portrays transportation, hydrography, jurisdiction boundaries, and major geographic features",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/Specialty/DeLorme_World_Base_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=b165c3df453e4be6b5ac4fdb241effbe'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/Specialty/DeLorme_World_Base_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=b165c3df453e4be6b5ac4fdb241effbe'>Esri</a> contributors"
+         }
+     ]
+ }
+diff --git a/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
+index 3858ddf5..af66f28e 100644
+--- a/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
+@@ -63,8 +63,10 @@ static const QString kCountriesKey(QStringLiteral("detailedCountries"));
+ static const QString kLocalizedNamesKey(QStringLiteral("localizedNames"));
+ static const QString kMaxLocationsKey(QStringLiteral("maxLocations"));
+ 
+-static const QUrl kUrlGeocodeServer("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer?f=pjson");
+-static const QUrl kUrlFindAddressCandidates("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates");
++static const QUrl kUrlGeocodeServer(
++        "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer?f=pjson");
++static const QUrl kUrlFindAddressCandidates("https://geocode.arcgis.com/arcgis/rest/services/World/"
++                                            "GeocodeServer/findAddressCandidates");
+ 
+ PlaceManagerEngineEsri::PlaceManagerEngineEsri(const QVariantMap &parameters, QGeoServiceProvider::Error *error,
+                                                QString *errorString) :
+Submodule qtmultimedia f0344079..0d7cc33a:
+diff --git a/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp b/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
+index 2b5325132..b68b4af1b 100644
+--- a/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
++++ b/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
+@@ -402,6 +402,8 @@ int QPulseAudioInput::bytesReady() const
+ 
+ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ {
++    Q_ASSERT(data != nullptr || len == 0);
++
+     m_bytesAvailable = checkBytesReady();
+ 
+     setError(QAudio::NoError);
+@@ -411,7 +413,8 @@ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ 
+     if (!m_pullMode && !m_tempBuffer.isEmpty()) {
+         readBytes = qMin(static_cast<int>(len), m_tempBuffer.size());
+-        memcpy(data, m_tempBuffer.constData(), readBytes);
++        if (readBytes)
++            memcpy(data, m_tempBuffer.constData(), readBytes);
+         m_totalTimeValue += readBytes;
+ 
+         if (readBytes < m_tempBuffer.size()) {
+@@ -502,9 +505,10 @@ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ 
+ void QPulseAudioInput::applyVolume(const void *src, void *dest, int len)
+ {
++    Q_ASSERT((src && dest) || len == 0);
+     if (m_volume < 1.f)
+         QAudioHelperInternal::qMultiplySamples(m_volume, m_format, src, dest, len);
+-    else
++    else if (len)
+         memcpy(dest, src, len);
+ }
+ 
+Submodule qtpim 02efef5e...f9a8f0fc (commits not present)
+Submodule qtquick3d b85cf622..47defc8b:
+diff --git a/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro b/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
+index ca5c499e..174a075b 100644
+--- a/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
++++ b/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
+@@ -10,7 +10,7 @@ QT_FOR_CONFIG += assetimporters-private
+ include($$OUT_PWD/../qtassetimporters-config.pri)
+ 
+ qtConfig(system-assimp):!if(cross_compile:host_build) {
+-    QMAKE_USE_PRIVATE += assimp
++    QMAKE_USE_PRIVATE += quick3d-assimp
+ } else {
+     include(../../../3rdparty/assimp/assimp.pri)
+ }
+Submodule qtquickcontrols2 3a657dc0..56ce8233:
+diff --git a/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp b/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
+index e5fe734f7..e36922775 100644
+--- a/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
++++ b/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
+@@ -38,6 +38,7 @@
+ #include "qwidgetplatformmenuitem_p.h"
+ 
+ #include <QtGui/qwindow.h>
++#include <QtGui/private/qhighdpiscaling_p.h>
+ #include <QtWidgets/qmenu.h>
+ #include <QtWidgets/qaction.h>
+ 
+@@ -145,7 +146,7 @@ void QWidgetPlatformMenu::showPopup(const QWindow *window, const QRect &targetRe
+ 
+     QPoint targetPos = targetRect.bottomLeft();
+     if (window)
+-        targetPos = window->mapToGlobal(targetPos);
++        targetPos = window->mapToGlobal(QHighDpi::fromNativeLocalPosition(targetPos, window));
+ 
+     const QWidgetPlatformMenuItem *widgetItem = qobject_cast<const QWidgetPlatformMenuItem *>(item);
+     m_menu->popup(targetPos, widgetItem ? widgetItem->action() : nullptr);
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
+index 950e4e099..b81fbea0b 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
+@@ -387,6 +387,17 @@ void QQuickAbstractButtonPrivate::itemImplicitHeightChanged(QQuickItem *item)
+         emit q->implicitIndicatorHeightChanged();
+ }
+ 
++void QQuickAbstractButtonPrivate::itemDestroyed(QQuickItem *item)
++{
++    Q_Q(QQuickAbstractButton);
++    QQuickControlPrivate::itemDestroyed(item);
++    if (item == indicator) {
++        indicator = nullptr;
++        emit q->implicitIndicatorWidthChanged();
++        emit q->implicitIndicatorHeightChanged();
++    }
++}
++
+ QQuickAbstractButton *QQuickAbstractButtonPrivate::findCheckedButton() const
+ {
+     Q_Q(const QQuickAbstractButton);
+@@ -1176,6 +1187,12 @@ QAccessible::Role QQuickAbstractButton::accessibleRole() const
+     }
+     return QAccessible::Button;
+ }
++
++void QQuickAbstractButton::accessiblePressAction()
++{
++    Q_D(QQuickAbstractButton);
++    d->trigger();
++}
+ #endif
+ 
+ QT_END_NAMESPACE
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
+index 0fa48980e..ab66220d0 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
+@@ -209,6 +209,7 @@ protected:
+ #if QT_CONFIG(accessibility)
+     void accessibilityActiveChanged(bool active) override;
+     QAccessible::Role accessibleRole() const override;
++    Q_INVOKABLE void accessiblePressAction();
+ #endif
+ 
+ private:
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
+index 9291c1a87..b729720f2 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
+@@ -109,6 +109,7 @@ public:
+ 
+     void itemImplicitWidthChanged(QQuickItem *item) override;
+     void itemImplicitHeightChanged(QQuickItem *item) override;
++    void itemDestroyed(QQuickItem *item) override;
+ 
+     // copied from qabstractbutton.cpp
+     static const int AUTO_REPEAT_DELAY = 300;
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp b/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
+index 2041e7741..8610cdfae 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
+@@ -145,7 +145,7 @@ int QQuickActionPrivate::ShortcutEntry::shortcutId() const
+ 
+ void QQuickActionPrivate::ShortcutEntry::grab(const QKeySequence &shortcut, bool enabled)
+ {
+-    if (shortcut.isEmpty())
++    if (shortcut.isEmpty() || m_shortcutId)
+         return;
+ 
+     Qt::ShortcutContext context = Qt::WindowShortcut; // TODO
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp b/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
+index f38c2b09c..6eed2a024 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
+@@ -225,6 +225,7 @@ void QQuickContainerPrivate::cleanup()
+     QObject::disconnect(contentModel, &QQmlObjectModel::countChanged, q, &QQuickContainer::countChanged);
+     QObject::disconnect(contentModel, &QQmlObjectModel::childrenChanged, q, &QQuickContainer::contentChildrenChanged);
+     delete contentModel;
++    contentModel = nullptr;
+ }
+ 
+ QQuickItem *QQuickContainerPrivate::itemAt(int index) const
+@@ -436,7 +437,7 @@ void QQuickContainerPrivate::contentChildren_clear(QQmlListProperty<QQuickItem>
+ void QQuickContainerPrivate::updateContentWidth()
+ {
+     Q_Q(QQuickContainer);
+-    if (hasContentWidth || qFuzzyCompare(contentWidth, implicitContentWidth))
++    if (hasContentWidth || qFuzzyCompare(contentWidth, implicitContentWidth) || !contentModel)
+         return;
+ 
+     contentWidth = implicitContentWidth;
+@@ -446,7 +447,7 @@ void QQuickContainerPrivate::updateContentWidth()
+ void QQuickContainerPrivate::updateContentHeight()
+ {
+     Q_Q(QQuickContainer);
+-    if (hasContentHeight || qFuzzyCompare(contentHeight, implicitContentHeight))
++    if (hasContentHeight || qFuzzyCompare(contentHeight, implicitContentHeight) || !contentModel)
+         return;
+ 
+     contentHeight = implicitContentHeight;
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp b/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
+index bbbd0e622..1f4b47343 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
+@@ -845,6 +845,13 @@ void QQuickControlPrivate::executeBackground(bool complete)
+         quickCompleteDeferred(q, backgroundName(), background);
+ }
+ 
++/*
++    \internal
++
++    Hides an item that was replaced by a newer one, rather than
++    deleting it, as the item is typically created in QML and hence
++    we don't own it.
++*/
+ void QQuickControlPrivate::hideOldItem(QQuickItem *item)
+ {
+     if (!item)
+@@ -863,6 +870,29 @@ void QQuickControlPrivate::hideOldItem(QQuickItem *item)
+ #endif
+ }
+ 
++/*
++    \internal
++
++    Named "unhide" because it's used for cases where an item
++    that was previously hidden by \l hideOldItem() wants to be
++    shown by a control again, such as a ScrollBar in ScrollView.
++*/
++void QQuickControlPrivate::unhideOldItem(QQuickControl *control, QQuickItem *item)
++{
++    Q_ASSERT(item);
++    qCDebug(lcItemManagement) << "unhiding old item" << item;
++
++    item->setVisible(true);
++    item->setParentItem(control);
++
++#if QT_CONFIG(accessibility)
++    // Add the item back in to the accessibility tree.
++    QQuickAccessibleAttached *accessible = accessibleAttached(item);
++    if (accessible)
++        accessible->setIgnored(false);
++#endif
++}
++
+ void QQuickControlPrivate::updateBaselineOffset()
+ {
+     Q_Q(QQuickControl);
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h b/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
+index 8e979079e..a6e624c91 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
+@@ -173,6 +173,7 @@ public:
+     virtual void executeBackground(bool complete = false);
+ 
+     static void hideOldItem(QQuickItem *item);
++    static void unhideOldItem(QQuickControl *control, QQuickItem *item);
+ 
+     void updateBaselineOffset();
+ 
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp b/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
+index e6db14eb5..6197d1547 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
+@@ -237,7 +237,7 @@ static QRectF alignedRect(Qt::LayoutDirection direction, Qt::Alignment alignment
+ void QQuickDialogButtonBoxPrivate::resizeContent()
+ {
+     Q_Q(QQuickDialogButtonBox);
+-    if (!contentItem)
++    if (!contentItem || !contentModel)
+         return;
+ 
+     QRectF geometry = q->boundingRect().adjusted(q->leftPadding(), q->topPadding(), -q->rightPadding(), -q->bottomPadding());
+@@ -322,6 +322,9 @@ void QQuickDialogButtonBoxPrivate::updateLayout()
+ qreal QQuickDialogButtonBoxPrivate::getContentWidth() const
+ {
+     Q_Q(const QQuickDialogButtonBox);
++    if (!contentModel)
++        return 0;
++
+     const int count = contentModel->count();
+     const qreal totalSpacing = qMax(0, count - 1) * spacing;
+     qreal totalWidth = totalSpacing;
+@@ -341,6 +344,9 @@ qreal QQuickDialogButtonBoxPrivate::getContentWidth() const
+ qreal QQuickDialogButtonBoxPrivate::getContentHeight() const
+ {
+     Q_Q(const QQuickDialogButtonBox);
++    if (!contentModel)
++        return 0;
++
+     const int count = contentModel->count();
+     qreal maxHeight = 0;
+     for (int i = 0; i < count; ++i) {
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp b/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
+index 91bd59184..0ce518f84 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
+@@ -399,8 +399,11 @@ void QQuickOverlay::itemChange(ItemChange change, const ItemChangeData &data)
+     Q_D(QQuickOverlay);
+     QQuickItem::itemChange(change, data);
+ 
+-    if (change == ItemChildAddedChange || change == ItemChildRemovedChange)
++    if (change == ItemChildAddedChange || change == ItemChildRemovedChange) {
+         setVisible(!d->allDrawers.isEmpty() || !childItems().isEmpty());
++        if (data.item->parent() == d->mouseGrabberPopup)
++            d->setMouseGrabberPopup(nullptr);
++    }
+ }
+ 
+ void QQuickOverlay::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp b/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
+index 4e2f509db..1c4b308cd 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
+@@ -797,6 +797,14 @@ void QQuickScrollBarAttachedPrivate::initHorizontal()
+     if (parent && parent == flickable->parentItem())
+         horizontal->stackAfter(flickable);
+ 
++    // If a scroll bar was previously hidden (due to e.g. setting a new contentItem
++    // on a ScrollView), we need to make sure that we un-hide it.
++    // We don't bother checking if the item is actually the old one, because
++    // if it's not, all of the things the function does (setting parent, visibility, etc.)
++    // should be no-ops anyway.
++    if (auto control = qobject_cast<QQuickControl*>(q_ptr->parent()))
++        QQuickControlPrivate::unhideOldItem(control, horizontal);
++
+     layoutHorizontal();
+     horizontal->setSize(area->property("widthRatio").toReal());
+     horizontal->setPosition(area->property("xPosition").toReal());
+@@ -818,6 +826,9 @@ void QQuickScrollBarAttachedPrivate::initVertical()
+     if (parent && parent == flickable->parentItem())
+         vertical->stackAfter(flickable);
+ 
++    if (auto control = qobject_cast<QQuickControl*>(q_ptr->parent()))
++        QQuickControlPrivate::unhideOldItem(control, vertical);
++
+     layoutVertical();
+     vertical->setSize(area->property("heightRatio").toReal());
+     vertical->setPosition(area->property("yPosition").toReal());
+diff --git a/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml b/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
+index 0e8b08352..cd4931184 100644
+--- a/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
++++ b/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
+@@ -576,4 +576,51 @@ TestCase {
+         verify(newHorizontalScrollBar.visible)
+         verify(!oldHorizontalScrollBar.visible)
+     }
++
++    Component {
++        id: bindingToContentItemAndStandaloneFlickable
++
++        Item {
++            width: 200
++            height: 200
++
++            property alias scrollView: scrollView
++
++            ScrollView {
++                id: scrollView
++                anchors.fill: parent
++                contentItem: listView
++
++                property Item someBinding: contentItem
++            }
++            ListView {
++                id: listView
++                model: 10
++                delegate: ItemDelegate {
++                    text: modelData
++                    width: listView.width
++                }
++            }
++        }
++    }
++
++    // Tests that scroll bars show up for a ScrollView where
++    // - its contentItem is declared as a standalone, separate item
++    // - there is a binding to contentItem (which causes a default Flickable to be created)
++    function test_bindingToContentItemAndStandaloneFlickable() {
++        let root = createTemporaryObject(bindingToContentItemAndStandaloneFlickable, testCase)
++        verify(root)
++
++        let control = root.scrollView
++        let verticalScrollBar = control.ScrollBar.vertical
++        let horizontalScrollBar = control.ScrollBar.horizontal
++        compare(verticalScrollBar.parent, control)
++        compare(horizontalScrollBar.parent, control)
++        verify(verticalScrollBar.visible)
++        verify(horizontalScrollBar.visible)
++
++        mouseDrag(verticalScrollBar, verticalScrollBar.width / 2, verticalScrollBar.height / 2, 0, 50)
++        verify(verticalScrollBar.active)
++        verify(horizontalScrollBar.active)
++    }
+ }
+diff --git a/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml b/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
+index b3fab41ca..10b6baa02 100644
+--- a/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
++++ b/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
+@@ -608,4 +608,27 @@ TestCase {
+         mouseClick(control.indicator)
+         verify(control.activeFocus)
+     }
++
++    Component {
++        id: deletionOrder1
++        Item {
++            Image { id: innerImage }
++            Switch { indicator: innerImage }
++        }
++    }
++
++    Component {
++        id: deletionOrder2
++        Item {
++            Switch { indicator: innerImage }
++            Image { id: innerImage }
++        }
++    }
++
++    function test_deletionOrder() {
++        var control1 = createTemporaryObject(deletionOrder1, testCase)
++        verify(control1)
++        var control2 = createTemporaryObject(deletionOrder2, testCase)
++        verify(control2)
++    }
+ }
+diff --git a/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml b/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml
+new file mode 100644
+index 000000000..9e4598b9f
+--- /dev/null
++++ b/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml
+@@ -0,0 +1,78 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the test suite of the Qt Toolkit.
++**
++** $QT_BEGIN_LICENSE:BSD$
++** Commercial License Usage
++** Licensees holding valid commercial Qt licenses may use this file in
++** accordance with the commercial license agreement provided with the
++** Software or, alternatively, in accordance with the terms contained in
++** a written agreement between you and The Qt Company. For licensing terms
++** and conditions see https://www.qt.io/terms-conditions. For further
++** information use the contact form at https://www.qt.io/contact-us.
++**
++** BSD License Usage
++** Alternatively, you may use this file under the terms of the BSD license
++** as follows:
++**
++** "Redistribution and use in source and binary forms, with or without
++** modification, are permitted provided that the following conditions are
++** met:
++**   * Redistributions of source code must retain the above copyright
++**     notice, this list of conditions and the following disclaimer.
++**   * Redistributions in binary form must reproduce the above copyright
++**     notice, this list of conditions and the following disclaimer in
++**     the documentation and/or other materials provided with the
++**     distribution.
++**   * Neither the name of The Qt Company Ltd nor the names of its
++**     contributors may be used to endorse or promote products derived
++**     from this software without specific prior written permission.
++**
++**
++** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
++** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
++** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
++** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
++** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
++** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
++** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
++** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
++** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
++** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
++** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
++**
++** $QT_END_LICENSE$
++**
++****************************************************************************/
++
++import QtQuick 2.15
++import QtQuick.Controls 2.15
++
++ApplicationWindow {
++    id: window
++    width: 400
++    height: 400
++    title: "releaseAfterExitTransition"
++
++    property alias popup: popup
++    property alias modalPopup: modalPopup
++
++    Popup {
++        id: popup
++        y: parent.height - height
++        width: 50
++        height: 50
++    }
++
++    Popup {
++        id: modalPopup
++        modal: true
++        y: parent.height - height
++        width: 50
++        height: 50
++        exit:  Transition { PauseAnimation { duration: 100 } }
++    }
++}
+diff --git a/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp b/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
+index 54952d128..3d50e2dd4 100644
+--- a/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
++++ b/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
+@@ -100,6 +100,7 @@ private slots:
+     void invisibleToolTipOpen();
+     void centerInOverlayWithinStackViewItem();
+     void destroyDuringExitTransition();
++    void releaseAfterExitTransition();
+ };
+ 
+ void tst_QQuickPopup::initTestCase()
+@@ -1575,6 +1576,34 @@ void tst_QQuickPopup::destroyDuringExitTransition()
+     QVERIFY(!button->isDown());
+ }
+ 
++void tst_QQuickPopup::releaseAfterExitTransition()
++{
++    QQuickApplicationHelper helper(this, "releaseAfterExitTransition.qml");
++    QVERIFY2(helper.ready, helper.failureMessage());
++
++    QQuickWindow *window = helper.window;
++    window->show();
++    QVERIFY(QTest::qWaitForWindowActive(window));
++
++    QQuickOverlay *overlay = QQuickOverlay::overlay(window);
++    QQuickPopup *modalPopup = window->property("modalPopup").value<QQuickPopup *>();
++    QQuickPopup *popup = window->property("popup").value<QQuickPopup *>();
++
++    modalPopup->open();
++    QTRY_VERIFY(modalPopup->isOpened());
++
++    QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++    // wait until the transition is finished and the overlay hides itself
++    QTRY_VERIFY(!overlay->isVisible());
++    QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++
++    popup->open();
++    QTRY_VERIFY(popup->isOpened());
++    QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++    QTRY_VERIFY(!popup->isOpened());
++}
++
++
+ QTEST_QUICKCONTROLS_MAIN(tst_QQuickPopup)
+ 
+ #include "tst_qquickpopup.moc"
+Submodule qtscript 5be95f96...4d8e4bd2 (commits not present)
+Submodule qtspeech 17fc9fde..255845e2:
+diff --git a/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp b/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
+index 6eb74b8..bcc7dd1 100644
+--- a/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
++++ b/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
+@@ -357,7 +357,9 @@ QVector<QLocale> QTextToSpeechEngineSpeechd::availableLocales() const
+ 
+ QVector<QVoice> QTextToSpeechEngineSpeechd::availableVoices() const
+ {
+-    return m_voices.values(m_currentLocale.name()).toVector();
++    QList<QVoice> resultList = m_voices.values(m_currentLocale.name());
++    std::reverse(resultList.begin(), resultList.end());
++    return resultList.toVector();
+ }
+ 
+ // We have no way of knowing our own client_id since speech-dispatcher seems to be incomplete
+Submodule qtsvg 0c05780e..a7a0f249:
+diff --git a/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp b/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
+index 561e77e..12e0574 100644
+--- a/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
++++ b/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
+@@ -191,6 +191,8 @@ bool QSvgIOHandler::read(QImage *image)
+             }
+         }
+         if (!finalSize.isEmpty()) {
++            if (qMax(finalSize.width(), finalSize.height()) > 0xffff)
++                return false; // Assume corrupted file
+             image->fill(d->backColor.rgba());
+             QPainter p(image);
+             d->r.render(&p, bounds);
+diff --git a/qtsvg/src/svg/qsvghandler.cpp b/qtsvg/src/svg/qsvghandler.cpp
+index a5f877f..8dda563 100644
+--- a/qtsvg/src/svg/qsvghandler.cpp
++++ b/qtsvg/src/svg/qsvghandler.cpp
+@@ -1393,9 +1393,10 @@ static void parseFont(QSvgNode *node,
+         case FontSizeNone:
+             break;
+         case FontSizeValue: {
+-            QSvgHandler::LengthType dummy; // should always be pixel size
+-            fontStyle->setSize(qMin(parseLength(attributes.fontSize, dummy, handler),
+-                                    qreal(0xffff)));
++            QSvgHandler::LengthType type;
++            qreal fs = parseLength(attributes.fontSize, type, handler);
++            fs = convertToPixels(fs, true, type);
++            fontStyle->setSize(qMin(fs, qreal(0xffff)));
+         }
+             break;
+         default:
+@@ -2513,6 +2514,8 @@ static bool parseAnimateTransformNode(QSvgNode *parent,
+             ++s;
+         }
+     }
++    if (vals.count() % 3 != 0)
++        return false;
+ 
+     bool ok = true;
+     int begin = parseClockValue(beginStr, &ok);
+@@ -2576,6 +2579,8 @@ static QSvgNode *createCircleNode(QSvgNode *parent,
+     qreal ncx = toDouble(cx);
+     qreal ncy = toDouble(cy);
+     qreal nr  = toDouble(r);
++    if (nr < 0.0)
++        return nullptr;
+ 
+     QRectF rect(ncx-nr, ncy-nr, nr*2, nr*2);
+     QSvgNode *circle = new QSvgCircle(parent, rect);
+@@ -3046,15 +3051,16 @@ static QSvgStyleProperty *createRadialGradientNode(QSvgNode *node,
+ 
+     qreal ncx = 0.5;
+     qreal ncy = 0.5;
+-    qreal nr  = 0.5;
+     if (!cx.isEmpty())
+         ncx = toDouble(cx);
+     if (!cy.isEmpty())
+         ncy = toDouble(cy);
++
++    qreal nr = 0.0;
+     if (!r.isEmpty())
+         nr = toDouble(r);
+-    if (nr < 0.5)
+-        nr = 0.5;
++    if (nr <= 0.0)
++        return nullptr;
+ 
+     qreal nfx = ncx;
+     if (!fx.isEmpty())
+@@ -3350,7 +3356,9 @@ static QSvgNode *createTextNode(QSvgNode *parent,
+     //### editable and rotate not handled
+     QSvgHandler::LengthType type;
+     qreal nx = parseLength(x, type, handler);
++    nx = convertToPixels(nx, true, type);
+     qreal ny = parseLength(y, type, handler);
++    ny = convertToPixels(ny, true, type);
+ 
+     QSvgNode *text = new QSvgText(parent, QPointF(nx, ny));
+     return text;
+@@ -3691,9 +3699,7 @@ void QSvgHandler::parse()
+         case QXmlStreamReader::EndElement:
+             endElement(xml->name());
+             ++remainingUnfinishedElements;
+-            // if we are using somebody else's qxmlstreamreader
+-            // we should not read until the end of the stream
+-            done = !m_ownsReader && (xml->name() == QLatin1String("svg"));
++            done = (xml->name() == QLatin1String("svg"));
+             break;
+         case QXmlStreamReader::Characters:
+             characters(xml->text());
+diff --git a/qtsvg/src/svg/qsvgstructure.cpp b/qtsvg/src/svg/qsvgstructure.cpp
+index b89608b..89c9e4e 100644
+--- a/qtsvg/src/svg/qsvgstructure.cpp
++++ b/qtsvg/src/svg/qsvgstructure.cpp
+@@ -255,9 +255,13 @@ inline static bool isSupportedSvgFeature(const QString &str)
+     };
+ 
+     if (str.length() <= MAX_WORD_LENGTH && str.length() >= MIN_WORD_LENGTH) {
++        const char16_t unicode44 = str.at(44).unicode();
++        const char16_t unicode45 = str.at(45).unicode();
++        if (unicode44 >= sizeof(asso_values) || unicode45 >= sizeof(asso_values))
++            return false;
+         const int key = str.length()
+-                        + asso_values[str.at(45).unicode()]
+-                        + asso_values[str.at(44).unicode()];
++                        + asso_values[unicode45]
++                        + asso_values[unicode44];
+         if (key <= MAX_HASH_VALUE && key >= 0)
+             return str == QLatin1String(wordlist[key]);
+     }
+diff --git a/qtsvg/src/svg/qsvgtinydocument.cpp b/qtsvg/src/svg/qsvgtinydocument.cpp
+index 63d0797..19e7154 100644
+--- a/qtsvg/src/svg/qsvgtinydocument.cpp
++++ b/qtsvg/src/svg/qsvgtinydocument.cpp
+@@ -433,8 +433,16 @@ void QSvgTinyDocument::draw(QPainter *p, QSvgExtraStates &)
+     draw(p);
+ }
+ 
++static bool isValidMatrix(const QTransform &transform)
++{
++    qreal determinant = transform.determinant();
++    return qIsFinite(determinant);
++}
++
+ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect, const QRectF &sourceRect)
+ {
++    QTransform oldTransform = p->worldTransform();
++
+     QRectF target = targetRect;
+     if (target.isEmpty()) {
+         QPaintDevice *dev = p->device();
+@@ -487,6 +495,9 @@ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect,
+         }
+ #endif
+     }
++
++    if (!isValidMatrix(p->worldTransform()))
++        p->setWorldTransform(oldTransform);
+ }
+ 
+ QRectF QSvgTinyDocument::boundsOnElement(const QString &id) const
+diff --git a/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp b/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
+index 36c76ec..db71e02 100644
+--- a/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
++++ b/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
+@@ -86,6 +86,8 @@ private slots:
+     void oss_fuzz_23731();
+     void oss_fuzz_24131();
+     void oss_fuzz_24738();
++    void illegalAnimateTransform_data();
++    void illegalAnimateTransform();
+ 
+ #ifndef QT_NO_COMPRESS
+     void testGzLoading();
+@@ -1646,5 +1648,22 @@ void tst_QSvgRenderer::oss_fuzz_24738()
+     QSvgRenderer().load(QByteArray("<svg><path d=\"a 2 1e-212.....\">"));
+ }
+ 
++void tst_QSvgRenderer::illegalAnimateTransform_data()
++{
++    QTest::addColumn<QByteArray>("svg");
++
++    QTest::newRow("case1") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" values=\"8,0,5,0\">");
++    QTest::newRow("case2") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" values=\"1,2\">");
++    QTest::newRow("case3") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" from=\".. 5 2\" to=\"f\">");
++    QTest::newRow("case4") << QByteArray("<svg><animateTransform type=\"scale\" begin=\"1\" dur=\"2\" by=\"--,..\">");
++}
++
++void tst_QSvgRenderer::illegalAnimateTransform()
++{
++    QFETCH(QByteArray, svg);
++    QSvgRenderer renderer;
++    QVERIFY(!renderer.load(svg)); // also shouldn't assert
++}
++
+ QTEST_MAIN(tst_QSvgRenderer)
+ #include "tst_qsvgrenderer.moc"
+Submodule qttools 6914f7c8..090e526e:
+diff --git a/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp b/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
+index feab1e2d5..cbfb82507 100644
+--- a/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
++++ b/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
+@@ -445,7 +445,9 @@ bool HelpGeneratorPrivate::insertFiles(const QStringList &files, const QString &
+     if (filterSetId < 0)
+         return false;
+     ++filterSetId;
+-    for (int attId : qAsConst(filterAtts)) {
++    QList<int> attValues = filterAtts.values();
++    std::sort(attValues.begin(), attValues.end());
++    for (int attId : qAsConst(attValues)) {
+         m_query->prepare(QLatin1String("INSERT INTO FileAttributeSetTable "
+             "VALUES(?, ?)"));
+         m_query->bindValue(0, filterSetId);
+Submodule qtwayland dfb0129c..2904e1b3:
+diff --git a/qtwayland/src/client/configure.json b/qtwayland/src/client/configure.json
+index 2f424580..29222357 100644
+--- a/qtwayland/src/client/configure.json
++++ b/qtwayland/src/client/configure.json
+@@ -149,8 +149,7 @@
+                     "#endif"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "vulkan-server-buffer": {
+             "label": "Vulkan Buffer Sharing",
+@@ -168,7 +167,8 @@
+                     "exportAllocInfo.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR;",
+                     "return 0;"
+                 ]
+-            }
++            },
++            "use": "wayland-client"
+         },
+         "egl_1_5-wayland": {
+             "label": "EGL 1.5 with Wayland Platform",
+@@ -183,7 +183,7 @@
+                     "eglGetPlatformDisplay(EGL_PLATFORM_WAYLAND_EXT, (struct wl_display *)(nullptr), nullptr);"
+                 ]
+             },
+-            "use": "egl"
++            "use": "egl wayland-client"
+         }
+     },
+ 
+diff --git a/qtwayland/src/client/global/qwaylandclientextension.cpp b/qtwayland/src/client/global/qwaylandclientextension.cpp
+index 125b1e19..edccfe63 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension.cpp
++++ b/qtwayland/src/client/global/qwaylandclientextension.cpp
+@@ -74,7 +74,10 @@ void QWaylandClientExtensionPrivate::handleRegistryGlobal(void *data, ::wl_regis
+ void QWaylandClientExtension::addRegistryListener()
+ {
+     Q_D(QWaylandClientExtension);
+-    d->waylandIntegration->display()->addRegistryListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++    if (!d->registered) {
++        d->waylandIntegration->display()->addRegistryListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++        d->registered = true;
++    }
+ }
+ 
+ QWaylandClientExtension::QWaylandClientExtension(const int ver)
+@@ -88,6 +91,13 @@ QWaylandClientExtension::QWaylandClientExtension(const int ver)
+     QMetaObject::invokeMethod(this, "addRegistryListener", Qt::QueuedConnection);
+ }
+ 
++QWaylandClientExtension::~QWaylandClientExtension()
++{
++    Q_D(QWaylandClientExtension);
++    if (d->registered && !QCoreApplication::closingDown())
++        d->waylandIntegration->display()->removeListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++}
++
+ QtWaylandClient::QWaylandIntegration *QWaylandClientExtension::integration() const
+ {
+     Q_D(const QWaylandClientExtension);
+diff --git a/qtwayland/src/client/global/qwaylandclientextension.h b/qtwayland/src/client/global/qwaylandclientextension.h
+index 98272e57..5bd28398 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension.h
++++ b/qtwayland/src/client/global/qwaylandclientextension.h
+@@ -63,6 +63,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandClientExtension : public QObject
+     Q_PROPERTY(bool active READ isActive NOTIFY activeChanged)
+ public:
+     QWaylandClientExtension(const int version);
++    ~QWaylandClientExtension();
+ 
+     QtWaylandClient::QWaylandIntegration *integration() const;
+     int version() const;
+diff --git a/qtwayland/src/client/global/qwaylandclientextension_p.h b/qtwayland/src/client/global/qwaylandclientextension_p.h
+index 69cc46a0..9091efbe 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension_p.h
++++ b/qtwayland/src/client/global/qwaylandclientextension_p.h
+@@ -68,6 +68,7 @@ public:
+     QtWaylandClient::QWaylandIntegration *waylandIntegration = nullptr;
+     int version = -1;
+     bool active = false;
++    bool registered = false;
+ };
+ 
+ class Q_WAYLAND_CLIENT_EXPORT QWaylandClientExtensionTemplatePrivate : public QWaylandClientExtensionPrivate
+diff --git a/qtwayland/src/client/qwaylanddatadevice.cpp b/qtwayland/src/client/qwaylanddatadevice.cpp
+index 7e2e3308..e3e60ed5 100644
+--- a/qtwayland/src/client/qwaylanddatadevice.cpp
++++ b/qtwayland/src/client/qwaylanddatadevice.cpp
+@@ -72,6 +72,8 @@ QWaylandDataDevice::QWaylandDataDevice(QWaylandDataDeviceManager *manager, QWayl
+ 
+ QWaylandDataDevice::~QWaylandDataDevice()
+ {
++    if (wl_data_device_get_version(object()) >= WL_DATA_DEVICE_RELEASE_SINCE_VERSION)
++        release();
+ }
+ 
+ QWaylandDataOffer *QWaylandDataDevice::selectionOffer() const
+@@ -110,7 +112,7 @@ QWaylandDataOffer *QWaylandDataDevice::dragOffer() const
+     return m_dragOffer.data();
+ }
+ 
+-bool QWaylandDataDevice::startDrag(QMimeData *mimeData, QWaylandWindow *icon)
++bool QWaylandDataDevice::startDrag(QMimeData *mimeData, Qt::DropActions supportedActions, QWaylandWindow *icon)
+ {
+     auto *seat = m_display->currentInputDevice();
+     auto *origin = seat->pointerFocus();
+@@ -123,7 +125,28 @@ bool QWaylandDataDevice::startDrag(QMimeData *mimeData, QWaylandWindow *icon)
+     }
+ 
+     m_dragSource.reset(new QWaylandDataSource(m_display->dndSelectionHandler(), mimeData));
++
++    if (wl_data_device_get_version(object()) >= 3)
++        m_dragSource->set_actions(dropActionsToWl(supportedActions));
++
+     connect(m_dragSource.data(), &QWaylandDataSource::cancelled, this, &QWaylandDataDevice::dragSourceCancelled);
++    connect(m_dragSource.data(), &QWaylandDataSource::dndResponseUpdated, this, [this](bool accepted, Qt::DropAction action) {
++            auto drag = static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag());
++            // in old versions drop action is not set, so we guess
++            if (wl_data_source_get_version(m_dragSource->object()) < 3) {
++                drag->setResponse(accepted);
++            } else {
++                QPlatformDropQtResponse response(accepted, action);
++                drag->setResponse(response);
++            }
++    });
++    connect(m_dragSource.data(), &QWaylandDataSource::dndDropped, this, [](bool accepted, Qt::DropAction action) {
++        QPlatformDropQtResponse response(accepted, action);
++        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setDropResponse(response);
++    });
++    connect(m_dragSource.data(), &QWaylandDataSource::finished, this, []() {
++        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag();
++    });
+ 
+     start_drag(m_dragSource->object(), origin->wlSurface(), icon->wlSurface(), m_display->currentInputDevice()->serial());
+     return true;
+@@ -152,7 +175,7 @@ void QWaylandDataDevice::data_device_drop()
+         supportedActions = drag->supportedActions();
+     } else if (m_dragOffer) {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     } else {
+         return;
+     }
+@@ -162,7 +185,11 @@ void QWaylandDataDevice::data_device_drop()
+                                                                           QGuiApplication::keyboardModifiers());
+ 
+     if (drag) {
+-        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag(response);
++        auto drag =  static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag());
++        drag->setDropResponse(response);
++        drag->finishDrag();
++    } else if (m_dragOffer) {
++        m_dragOffer->finish();
+     }
+ }
+ 
+@@ -186,7 +213,7 @@ void QWaylandDataDevice::data_device_enter(uint32_t serial, wl_surface *surface,
+         supportedActions = drag->supportedActions();
+     } else if (m_dragOffer) {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     }
+ 
+     const QPlatformDragQtResponse &response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
+@@ -197,11 +224,7 @@ void QWaylandDataDevice::data_device_enter(uint32_t serial, wl_surface *surface,
+         static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setResponse(response);
+     }
+ 
+-    if (response.isAccepted()) {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, m_dragOffer->firstFormat().toUtf8().constData());
+-    } else {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, nullptr);
+-    }
++    sendResponse(supportedActions, response);
+ }
+ 
+ void QWaylandDataDevice::data_device_leave()
+@@ -235,10 +258,10 @@ void QWaylandDataDevice::data_device_motion(uint32_t time, wl_fixed_t x, wl_fixe
+         supportedActions = drag->supportedActions();
+     } else {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     }
+ 
+-    QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
++    const QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
+                                                                           QGuiApplication::mouseButtons(),
+                                                                           QGuiApplication::keyboardModifiers());
+ 
+@@ -246,11 +269,7 @@ void QWaylandDataDevice::data_device_motion(uint32_t time, wl_fixed_t x, wl_fixe
+         static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setResponse(response);
+     }
+ 
+-    if (response.isAccepted()) {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, m_dragOffer->firstFormat().toUtf8().constData());
+-    } else {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, nullptr);
+-    }
++    sendResponse(supportedActions, response);
+ }
+ #endif // QT_CONFIG(draganddrop)
+ 
+@@ -277,14 +296,10 @@ void QWaylandDataDevice::selectionSourceCancelled()
+ #if QT_CONFIG(draganddrop)
+ void QWaylandDataDevice::dragSourceCancelled()
+ {
++    static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag();
+     m_dragSource.reset();
+ }
+ 
+-void QWaylandDataDevice::dragSourceTargetChanged(const QString &mimeType)
+-{
+-    static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->updateTarget(mimeType);
+-}
+-
+ QPoint QWaylandDataDevice::calculateDragPosition(int x, int y, QWindow *wnd) const
+ {
+     QPoint pnt(wl_fixed_to_int(x), wl_fixed_to_int(y));
+@@ -297,6 +312,33 @@ QPoint QWaylandDataDevice::calculateDragPosition(int x, int y, QWindow *wnd) con
+     }
+     return pnt;
+ }
++
++void QWaylandDataDevice::sendResponse(Qt::DropActions supportedActions, const QPlatformDragQtResponse &response)
++{
++    if (response.isAccepted()) {
++        if (wl_data_device_get_version(object()) >= 3)
++            m_dragOffer->set_actions(dropActionsToWl(supportedActions), dropActionsToWl(response.acceptedAction()));
++
++        m_dragOffer->accept(m_enterSerial, m_dragOffer->firstFormat());
++    } else {
++        m_dragOffer->accept(m_enterSerial, QString());
++    }
++}
++
++int QWaylandDataDevice::dropActionsToWl(Qt::DropActions actions)
++{
++
++    int wlActions = WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE;
++    if (actions & Qt::CopyAction)
++        wlActions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY;
++    if (actions & (Qt::MoveAction | Qt::TargetMoveAction))
++        wlActions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE;
++
++    // wayland does not support LinkAction at the time of writing
++    return wlActions;
++}
++
++
+ #endif // QT_CONFIG(draganddrop)
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddatadevice_p.h b/qtwayland/src/client/qwaylanddatadevice_p.h
+index 16c3ad28..801dcc2c 100644
+--- a/qtwayland/src/client/qwaylanddatadevice_p.h
++++ b/qtwayland/src/client/qwaylanddatadevice_p.h
+@@ -64,6 +64,7 @@ QT_REQUIRE_CONFIG(wayland_datadevice);
+ QT_BEGIN_NAMESPACE
+ 
+ class QMimeData;
++class QPlatformDragQtResponse;
+ class QWindow;
+ 
+ namespace QtWaylandClient {
+@@ -89,7 +90,7 @@ public:
+ 
+ #if QT_CONFIG(draganddrop)
+     QWaylandDataOffer *dragOffer() const;
+-    bool startDrag(QMimeData *mimeData, QWaylandWindow *icon);
++    bool startDrag(QMimeData *mimeData, Qt::DropActions supportedActions, QWaylandWindow *icon);
+     void cancelDrag();
+ #endif
+ 
+@@ -109,13 +110,16 @@ private Q_SLOTS:
+ 
+ #if QT_CONFIG(draganddrop)
+     void dragSourceCancelled();
+-    void dragSourceTargetChanged(const QString &mimeType);
+ #endif
+ 
+ private:
+ #if QT_CONFIG(draganddrop)
+     QPoint calculateDragPosition(int x, int y, QWindow *wnd) const;
+ #endif
++    void sendResponse(Qt::DropActions supportedActions, const QPlatformDragQtResponse &response);
++
++    static int dropActionsToWl(Qt::DropActions dropActions);
++
+ 
+     QWaylandDisplay *m_display = nullptr;
+     QWaylandInputDevice *m_inputDevice = nullptr;
+diff --git a/qtwayland/src/client/qwaylanddatadevicemanager.cpp b/qtwayland/src/client/qwaylanddatadevicemanager.cpp
+index 35d67307..6dc4f77f 100644
+--- a/qtwayland/src/client/qwaylanddatadevicemanager.cpp
++++ b/qtwayland/src/client/qwaylanddatadevicemanager.cpp
+@@ -50,8 +50,8 @@ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
+-QWaylandDataDeviceManager::QWaylandDataDeviceManager(QWaylandDisplay *display, uint32_t id)
+-    : wl_data_device_manager(display->wl_registry(), id, 1)
++QWaylandDataDeviceManager::QWaylandDataDeviceManager(QWaylandDisplay *display, int version, uint32_t id)
++    : wl_data_device_manager(display->wl_registry(), id, qMin(version, 3))
+     , m_display(display)
+ {
+     // Create transfer devices for all input devices.
+diff --git a/qtwayland/src/client/qwaylanddatadevicemanager_p.h b/qtwayland/src/client/qwaylanddatadevicemanager_p.h
+index bd05c0fb..510d9be4 100644
+--- a/qtwayland/src/client/qwaylanddatadevicemanager_p.h
++++ b/qtwayland/src/client/qwaylanddatadevicemanager_p.h
+@@ -68,7 +68,7 @@ class QWaylandInputDevice;
+ class Q_WAYLAND_CLIENT_EXPORT QWaylandDataDeviceManager : public QtWayland::wl_data_device_manager
+ {
+ public:
+-    QWaylandDataDeviceManager(QWaylandDisplay *display, uint32_t id);
++    QWaylandDataDeviceManager(QWaylandDisplay *display, int version, uint32_t id);
+     ~QWaylandDataDeviceManager() override;
+ 
+     QWaylandDataDevice *getDataDevice(QWaylandInputDevice *inputDevice);
+diff --git a/qtwayland/src/client/qwaylanddataoffer.cpp b/qtwayland/src/client/qwaylanddataoffer.cpp
+index 2297e8a1..fe0ea8c9 100644
+--- a/qtwayland/src/client/qwaylanddataoffer.cpp
++++ b/qtwayland/src/client/qwaylanddataoffer.cpp
+@@ -82,6 +82,15 @@ QMimeData *QWaylandDataOffer::mimeData()
+     return m_mimeData.data();
+ }
+ 
++Qt::DropActions QWaylandDataOffer::supportedActions() const
++{
++    if (wl_data_offer_get_version(const_cast<::wl_data_offer*>(object())) < 3) {
++        return Qt::MoveAction | Qt::CopyAction;
++    }
++
++    return m_supportedActions;
++}
++
+ void QWaylandDataOffer::startReceiving(const QString &mimeType, int fd)
+ {
+     receive(mimeType, fd);
+@@ -93,6 +102,22 @@ void QWaylandDataOffer::data_offer_offer(const QString &mime_type)
+     m_mimeData->appendFormat(mime_type);
+ }
+ 
++void QWaylandDataOffer::data_offer_action(uint32_t dnd_action)
++{
++    Q_UNUSED(dnd_action);
++    // This is the compositor telling the drag target what action it should perform
++    // It does not map nicely into Qt final drop semantics, other than pretending there is only one supported action?
++}
++
++void QWaylandDataOffer::data_offer_source_actions(uint32_t source_actions)
++{
++    m_supportedActions = Qt::DropActions();
++    if (source_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
++        m_supportedActions |= Qt::MoveAction;
++    if (source_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
++        m_supportedActions |= Qt::CopyAction;
++}
++
+ QWaylandMimeData::QWaylandMimeData(QWaylandAbstractDataOffer *dataOffer)
+     : m_dataOffer(dataOffer)
+ {
+@@ -163,17 +188,18 @@ QVariant QWaylandMimeData::retrieveData_sys(const QString &mimeType, QVariant::T
+ 
+ int QWaylandMimeData::readData(int fd, QByteArray &data) const
+ {
+-    fd_set readset;
+-    FD_ZERO(&readset);
+-    FD_SET(fd, &readset);
+-    struct timeval timeout;
++    struct pollfd readset;
++    readset.fd = fd;
++    readset.events = POLLIN;
++    struct timespec timeout;
+     timeout.tv_sec = 1;
+-    timeout.tv_usec = 0;
++    timeout.tv_nsec = 0;
++
+ 
+     Q_FOREVER {
+-        int ready = select(FD_SETSIZE, &readset, nullptr, nullptr, &timeout);
++        int ready = qt_safe_poll(&readset, 1, &timeout);
+         if (ready < 0) {
+-            qWarning() << "QWaylandDataOffer: select() failed";
++            qWarning() << "QWaylandDataOffer: qt_safe_poll() failed";
+             return -1;
+         } else if (ready == 0) {
+             qWarning("QWaylandDataOffer: timeout reading from pipe");
+diff --git a/qtwayland/src/client/qwaylanddataoffer_p.h b/qtwayland/src/client/qwaylanddataoffer_p.h
+index 9cf1483c..6f667398 100644
+--- a/qtwayland/src/client/qwaylanddataoffer_p.h
++++ b/qtwayland/src/client/qwaylanddataoffer_p.h
+@@ -82,6 +82,7 @@ public:
+     explicit QWaylandDataOffer(QWaylandDisplay *display, struct ::wl_data_offer *offer);
+     ~QWaylandDataOffer() override;
+     QMimeData *mimeData() override;
++    Qt::DropActions supportedActions() const;
+ 
+     QString firstFormat() const;
+ 
+@@ -89,10 +90,13 @@ public:
+ 
+ protected:
+     void data_offer_offer(const QString &mime_type) override;
++    void data_offer_source_actions(uint32_t source_actions) override;
++    void data_offer_action(uint32_t dnd_action) override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+     QScopedPointer<QWaylandMimeData> m_mimeData;
++    Qt::DropActions m_supportedActions;
+ };
+ 
+ 
+diff --git a/qtwayland/src/client/qwaylanddatasource.cpp b/qtwayland/src/client/qwaylanddatasource.cpp
+index f45122fb..5599cbd4 100644
+--- a/qtwayland/src/client/qwaylanddatasource.cpp
++++ b/qtwayland/src/client/qwaylanddatasource.cpp
+@@ -101,7 +101,32 @@ void QWaylandDataSource::data_source_send(const QString &mime_type, int32_t fd)
+ 
+ void QWaylandDataSource::data_source_target(const QString &mime_type)
+ {
+-    Q_EMIT targetChanged(mime_type);
++    m_accepted = !mime_type.isEmpty();
++    Q_EMIT dndResponseUpdated(m_accepted, m_dropAction);
++}
++
++void QWaylandDataSource::data_source_action(uint32_t action)
++{
++    Qt::DropAction qtAction = Qt::IgnoreAction;
++
++    if (action == WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
++        qtAction = Qt::MoveAction;
++    else if (action == WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
++        qtAction = Qt::CopyAction;
++
++    m_dropAction = qtAction;
++    Q_EMIT dndResponseUpdated(m_accepted, m_dropAction);
++}
++
++void QWaylandDataSource::data_source_dnd_finished()
++{
++    Q_EMIT finished();
++}
++
++void QWaylandDataSource::data_source_dnd_drop_performed()
++{
++
++    Q_EMIT dndDropped(m_accepted, m_dropAction);
+ }
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddatasource_p.h b/qtwayland/src/client/qwaylanddatasource_p.h
+index 25afff79..96f07bc3 100644
+--- a/qtwayland/src/client/qwaylanddatasource_p.h
++++ b/qtwayland/src/client/qwaylanddatasource_p.h
+@@ -77,17 +77,25 @@ public:
+     QMimeData *mimeData() const;
+ 
+ Q_SIGNALS:
+-    void targetChanged(const QString &mime_type);
+     void cancelled();
++    void finished();
++
++    void dndResponseUpdated(bool accepted, Qt::DropAction action);
++    void dndDropped(bool accepted, Qt::DropAction action);
+ 
+ protected:
+     void data_source_cancelled() override;
+     void data_source_send(const QString &mime_type, int32_t fd) override;
+     void data_source_target(const QString &mime_type) override;
++    void data_source_dnd_drop_performed() override;
++    void data_source_dnd_finished() override;
++    void data_source_action(uint32_t action) override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+     QMimeData *m_mime_data = nullptr;
++    bool m_accepted = false;
++    Qt::DropAction m_dropAction = Qt::IgnoreAction;
+ };
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddisplay.cpp b/qtwayland/src/client/qwaylanddisplay.cpp
+index f10c1f79..c01e238b 100644
+--- a/qtwayland/src/client/qwaylanddisplay.cpp
++++ b/qtwayland/src/client/qwaylanddisplay.cpp
+@@ -85,10 +85,203 @@
+ 
+ #include <errno.h>
+ 
++#include <tuple> // for std::tie
++
++static void checkWaylandError(struct wl_display *display)
++{
++    int ecode = wl_display_get_error(display);
++    if ((ecode == EPIPE || ecode == ECONNRESET)) {
++        // special case this to provide a nicer error
++        qWarning("The Wayland connection broke. Did the Wayland compositor die?");
++    } else {
++        qWarning("The Wayland connection experienced a fatal error: %s", strerror(ecode));
++    }
++    _exit(1);
++}
++
+ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
++class EventThread : public QThread
++{
++    Q_OBJECT
++public:
++    enum OperatingMode {
++        EmitToDispatch, // Emit the signal, allow dispatching in a differnt thread.
++        SelfDispatch, // Dispatch the events inside this thread.
++    };
++
++    EventThread(struct wl_display * wl, struct wl_event_queue * ev_queue,
++                OperatingMode mode)
++        : m_fd(wl_display_get_fd(wl))
++        , m_pipefd{ -1, -1 }
++        , m_wldisplay(wl)
++        , m_wlevqueue(ev_queue)
++        , m_mode(mode)
++        , m_reading(true)
++        , m_quitting(false)
++    {
++        setObjectName(QStringLiteral("WaylandEventThread"));
++    }
++
++    void readAndDispatchEvents()
++    {
++        /*
++         * Dispatch pending events and flush the requests at least once. If the event thread
++         * is not reading, try to call _prepare_read() to allow the event thread to poll().
++         * If that fails, re-try dispatch & flush again until _prepare_read() is successful.
++         *
++         * This allow any call to readAndDispatchEvents() to start event thread's polling,
++         * not only the one issued from event thread's waitForReading(), which means functions
++         * called from dispatch_pending() can safely spin an event loop.
++         */
++        for (;;) {
++            if (dispatchQueuePending() < 0) {
++                checkWaylandError(m_wldisplay);
++                return;
++            }
++
++            wl_display_flush(m_wldisplay);
++
++            // We have to check if event thread is reading every time we dispatch
++            // something, as that may recursively call this function.
++            if (m_reading.loadAcquire())
++                break;
++
++            if (prepareReadQueue() == 0) {
++                QMutexLocker l(&m_mutex);
++                m_reading.storeRelease(true);
++                m_cond.wakeOne();
++                break;
++            }
++        }
++    }
++
++    void stop()
++    {
++        // We have to both write to the pipe and set the flag, as the thread may be
++        // either in the poll() or waiting for _prepare_read().
++        if (m_pipefd[1] != -1 && write(m_pipefd[1], "\0", 1) == -1)
++            qWarning("Failed to write to the pipe: %s.", strerror(errno));
++
++        {
++            QMutexLocker l(&m_mutex);
++            m_quitting = true;
++            m_cond.wakeOne();
++        }
++
++        wait();
++    }
++
++Q_SIGNALS:
++    void needReadAndDispatch();
++
++protected:
++    void run() override
++    {
++        // we use this pipe to make the loop exit otherwise if we simply used a flag on the loop condition, if stop() gets
++        // called while poll() is blocking the thread will never quit since there are no wayland messages coming anymore.
++        struct Pipe
++        {
++            Pipe(int *fds)
++                : fds(fds)
++            {
++                if (qt_safe_pipe(fds) != 0)
++                    qWarning("Pipe creation failed. Quitting may hang.");
++            }
++            ~Pipe()
++            {
++                if (fds[0] != -1) {
++                    close(fds[0]);
++                    close(fds[1]);
++                }
++            }
++
++            int *fds;
++        } pipe(m_pipefd);
++
++        // Make the main thread call wl_prepare_read(), dispatch the pending messages and flush the
++        // outbound ones. Wait until it's done before proceeding, unless we're told to quit.
++        while (waitForReading()) {
++            pollfd fds[2] = { { m_fd, POLLIN, 0 }, { m_pipefd[0], POLLIN, 0 } };
++            poll(fds, 2, -1);
++
++            if (fds[1].revents & POLLIN) {
++                // we don't really care to read the byte that was written here since we're closing down
++                wl_display_cancel_read(m_wldisplay);
++                break;
++            }
++
++            if (fds[0].revents & POLLIN)
++                wl_display_read_events(m_wldisplay);
++                // The polll was succesfull and the event thread did the wl_display_read_events(). On the next iteration of the loop
++                // the event sent to the main thread will cause it to dispatch the messages just read, unless the loop exits in which
++                // case we don't care anymore about them.
++            else
++                wl_display_cancel_read(m_wldisplay);
++        }
++    }
++
++private:
++    bool waitForReading()
++    {
++        Q_ASSERT(QThread::currentThread() == this);
++
++        m_reading.storeRelease(false);
++
++        if (m_mode == SelfDispatch) {
++            readAndDispatchEvents();
++        } else {
++            Q_EMIT needReadAndDispatch();
++
++            QMutexLocker lock(&m_mutex);
++            // m_reading might be set from our emit or some other invocation of
++            // readAndDispatchEvents().
++            while (!m_reading.loadRelaxed() && !m_quitting)
++                m_cond.wait(&m_mutex);
++        }
++
++        return !m_quitting;
++    }
++
++    int dispatchQueuePending()
++    {
++        if (m_wlevqueue)
++            return wl_display_dispatch_queue_pending(m_wldisplay, m_wlevqueue);
++        else
++            return wl_display_dispatch_pending(m_wldisplay);
++    }
++
++    int prepareReadQueue()
++    {
++        if (m_wlevqueue)
++            return wl_display_prepare_read_queue(m_wldisplay, m_wlevqueue);
++        else
++            return wl_display_prepare_read(m_wldisplay);
++    }
++
++    int m_fd;
++    int m_pipefd[2];
++    wl_display *m_wldisplay;
++    wl_event_queue *m_wlevqueue;
++    OperatingMode m_mode;
++
++    /* Concurrency note when operating in EmitToDispatch mode:
++     * m_reading is set to false inside event thread's waitForReading(), and is
++     * set to true inside main thread's readAndDispatchEvents().
++     * The lock is not taken when setting m_reading to false, as the main thread
++     * is not actively waiting for it to turn false. However, the lock is taken
++     * inside readAndDispatchEvents() before setting m_reading to true,
++     * as the event thread is actively waiting for it under the wait condition.
++     */
++
++    QAtomicInteger<bool> m_reading;
++    bool m_quitting;
++    QMutex m_mutex;
++    QWaitCondition m_cond;
++};
++
+ Q_LOGGING_CATEGORY(lcQpaWayland, "qt.qpa.wayland"); // for general (uncategorized) Wayland platform logging
+ 
+ struct wl_surface *QWaylandDisplay::createSurface(void *handle)
+@@ -158,17 +351,16 @@ QWaylandDisplay::QWaylandDisplay(QWaylandIntegration *waylandIntegration)
+     if (!mXkbContext)
+         qCWarning(lcQpaWayland, "failed to create xkb context");
+ #endif
+-
+-    forceRoundTrip();
+-
+-    if (!mWaitingScreens.isEmpty()) {
+-        // Give wl_output.done and zxdg_output_v1.done events a chance to arrive
+-        forceRoundTrip();
+-    }
+ }
+ 
+ QWaylandDisplay::~QWaylandDisplay(void)
+ {
++    if (m_eventThread)
++        m_eventThread->stop();
++
++    if (m_frameEventQueueThread)
++        m_frameEventQueueThread->stop();
++
+     if (mSyncCallback)
+         wl_callback_destroy(mSyncCallback);
+ 
+@@ -187,6 +379,21 @@ QWaylandDisplay::~QWaylandDisplay(void)
+ #endif
+     if (mDisplay)
+         wl_display_disconnect(mDisplay);
++
++    if (m_frameEventQueue)
++        wl_event_queue_destroy(m_frameEventQueue);
++}
++
++// Steps which is called just after constructor. This separates registry_global() out of the constructor
++// so that factory functions in integration can be overridden.
++void QWaylandDisplay::initialize()
++{
++    forceRoundTrip();
++
++    if (!mWaitingScreens.isEmpty()) {
++        // Give wl_output.done and zxdg_output_v1.done events a chance to arrive
++        forceRoundTrip();
++    }
+ }
+ 
+ void QWaylandDisplay::ensureScreen()
+@@ -203,98 +410,37 @@ void QWaylandDisplay::ensureScreen()
+ 
+ void QWaylandDisplay::checkError() const
+ {
+-    int ecode = wl_display_get_error(mDisplay);
+-    if ((ecode == EPIPE || ecode == ECONNRESET)) {
+-        // special case this to provide a nicer error
+-        qWarning("The Wayland connection broke. Did the Wayland compositor die?");
+-    } else {
+-        qWarning("The Wayland connection experienced a fatal error: %s", strerror(ecode));
+-    }
+-    _exit(1);
++    checkWaylandError(mDisplay);
+ }
+ 
++// Called in main thread, either from queued signal or directly.
+ void QWaylandDisplay::flushRequests()
+ {
+-    if (wl_display_prepare_read(mDisplay) == 0) {
+-        wl_display_read_events(mDisplay);
+-    }
+-
+-    if (wl_display_dispatch_pending(mDisplay) < 0)
+-        checkError();
+-
+-    {
+-        QReadLocker locker(&m_frameQueueLock);
+-        for (const FrameQueue &q : mExternalQueues) {
+-            QMutexLocker locker(q.mutex);
+-            while (wl_display_prepare_read_queue(mDisplay, q.queue) != 0)
+-                wl_display_dispatch_queue_pending(mDisplay, q.queue);
+-            wl_display_read_events(mDisplay);
+-            wl_display_dispatch_queue_pending(mDisplay, q.queue);
+-        }
+-    }
+-
+-    wl_display_flush(mDisplay);
+-}
+-
+-void QWaylandDisplay::blockingReadEvents()
+-{
+-    if (wl_display_dispatch(mDisplay) < 0)
+-        checkError();
+-}
+-
+-void QWaylandDisplay::destroyFrameQueue(const QWaylandDisplay::FrameQueue &q)
+-{
+-    QWriteLocker locker(&m_frameQueueLock);
+-    auto it = std::find_if(mExternalQueues.begin(),
+-                           mExternalQueues.end(),
+-                           [&q] (const QWaylandDisplay::FrameQueue &other){ return other.queue == q.queue; });
+-    Q_ASSERT(it != mExternalQueues.end());
+-    mExternalQueues.erase(it);
+-    if (q.queue != nullptr)
+-        wl_event_queue_destroy(q.queue);
+-    delete q.mutex;
++    m_eventThread->readAndDispatchEvents();
+ }
+ 
+-QWaylandDisplay::FrameQueue QWaylandDisplay::createFrameQueue()
++// We have to wait until we have an eventDispatcher before creating the eventThread,
++// otherwise forceRoundTrip() may block inside _events_read() because eventThread is
++// polling.
++void QWaylandDisplay::initEventThread()
+ {
+-    QWriteLocker locker(&m_frameQueueLock);
+-    FrameQueue q{createEventQueue()};
+-    mExternalQueues.append(q);
+-    return q;
+-}
++    m_eventThread.reset(
++            new EventThread(mDisplay, /* default queue */ nullptr, EventThread::EmitToDispatch));
++    connect(m_eventThread.get(), &EventThread::needReadAndDispatch, this,
++            &QWaylandDisplay::flushRequests, Qt::QueuedConnection);
++    m_eventThread->start();
+ 
+-wl_event_queue *QWaylandDisplay::createEventQueue()
+-{
+-    return wl_display_create_queue(mDisplay);
++    // wl_display_disconnect() free this.
++    m_frameEventQueue = wl_display_create_queue(mDisplay);
++    m_frameEventQueueThread.reset(
++            new EventThread(mDisplay, m_frameEventQueue, EventThread::SelfDispatch));
++    m_frameEventQueueThread->start();
+ }
+ 
+-void QWaylandDisplay::dispatchQueueWhile(wl_event_queue *queue, std::function<bool ()> condition, int timeout)
++void QWaylandDisplay::blockingReadEvents()
+ {
+-    if (!condition())
+-        return;
+-
+-    QElapsedTimer timer;
+-    timer.start();
+-    struct pollfd pFd = qt_make_pollfd(wl_display_get_fd(mDisplay), POLLIN);
+-    while (timeout == -1 || timer.elapsed() < timeout) {
+-        while (wl_display_prepare_read_queue(mDisplay, queue) != 0)
+-            wl_display_dispatch_queue_pending(mDisplay, queue);
+-
+-        wl_display_flush(mDisplay);
+-
+-        const int remaining = qMax(timeout - timer.elapsed(), 0ll);
+-        const int pollTimeout = timeout == -1 ? -1 : remaining;
+-        if (qt_poll_msecs(&pFd, 1, pollTimeout) > 0)
+-            wl_display_read_events(mDisplay);
+-        else
+-            wl_display_cancel_read(mDisplay);
+-
+-        if (wl_display_dispatch_queue_pending(mDisplay, queue) < 0)
+-            checkError();
+-
+-        if (!condition())
+-            break;
+-    }
++    if (wl_display_dispatch(mDisplay) < 0)
++        checkWaylandError(mDisplay);
+ }
+ 
+ QWaylandScreen *QWaylandDisplay::screenForOutput(struct wl_output *output) const
+@@ -345,7 +491,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+     if (interface == QStringLiteral("wl_output")) {
+         mWaitingScreens << new QWaylandScreen(this, version, id);
+     } else if (interface == QStringLiteral("wl_compositor")) {
+-        mCompositorVersion = qMin((int)version, 3);
++        mCompositorVersion = qMin((int)version, 4);
+         mCompositor.init(registry, id, mCompositorVersion);
+     } else if (interface == QStringLiteral("wl_shm")) {
+         mShm.reset(new QWaylandShm(this, version, id));
+@@ -354,7 +500,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+         mInputDevices.append(inputDevice);
+ #if QT_CONFIG(wayland_datadevice)
+     } else if (interface == QStringLiteral("wl_data_device_manager")) {
+-        mDndSelectionHandler.reset(new QWaylandDataDeviceManager(this, id));
++        mDndSelectionHandler.reset(new QWaylandDataDeviceManager(this, version, id));
+ #endif
+     } else if (interface == QStringLiteral("qt_surface_extension")) {
+         mWindowExtension.reset(new QtWayland::qt_surface_extension(registry, id, 1));
+@@ -369,6 +515,8 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+ #if QT_CONFIG(wayland_client_primary_selection)
+     } else if (interface == QStringLiteral("zwp_primary_selection_device_manager_v1")) {
+         mPrimarySelectionManager.reset(new QWaylandPrimarySelectionDeviceManagerV1(this, id, 1));
++        for (QWaylandInputDevice *inputDevice : qAsConst(mInputDevices))
++            inputDevice->setPrimarySelectionDevice(mPrimarySelectionManager->createDevice(inputDevice));
+ #endif
+     } else if (interface == QStringLiteral("zwp_text_input_manager_v2") && !mClientSideInputContextRequested) {
+         mTextInputManager.reset(new QtWayland::zwp_text_input_manager_v2(registry, id, 1));
+@@ -427,6 +575,13 @@ void QWaylandDisplay::registry_global_remove(uint32_t id)
+                     inputDevice->setTextInput(nullptr);
+                 mWaylandIntegration->reconfigureInputContext();
+             }
++#if QT_CONFIG(wayland_client_primary_selection)
++            if (global.interface == QStringLiteral("zwp_primary_selection_device_manager_v1")) {
++                mPrimarySelectionManager.reset();
++                for (QWaylandInputDevice *inputDevice : qAsConst(mInputDevices))
++                    inputDevice->setPrimarySelectionDevice(nullptr);
++            }
++#endif
+             mGlobals.removeAt(i);
+             break;
+         }
+@@ -452,9 +607,10 @@ void QWaylandDisplay::addRegistryListener(RegistryListener listener, void *data)
+ 
+ void QWaylandDisplay::removeListener(RegistryListener listener, void *data)
+ {
+-    std::remove_if(mRegistryListeners.begin(), mRegistryListeners.end(), [=](Listener l){
++    auto iter = std::remove_if(mRegistryListeners.begin(), mRegistryListeners.end(), [=](Listener l){
+         return (l.listener == listener && l.data == data);
+     });
++    mRegistryListeners.erase(iter, mRegistryListeners.end());
+ }
+ 
+ uint32_t QWaylandDisplay::currentTimeMillisec()
+@@ -467,50 +623,9 @@ uint32_t QWaylandDisplay::currentTimeMillisec()
+     return 0;
+ }
+ 
+-static void
+-sync_callback(void *data, struct wl_callback *callback, uint32_t serial)
+-{
+-    Q_UNUSED(serial)
+-    bool *done = static_cast<bool *>(data);
+-
+-    *done = true;
+-
+-    // If the wl_callback done event is received after the condition check in the while loop in
+-    // forceRoundTrip(), but before the call to processEvents, the call to processEvents may block
+-    // forever if no more events are posted (eventhough the callback is handled in response to the
+-    // aboutToBlock signal). Hence, we wake up the event dispatcher so forceRoundTrip may return.
+-    // (QTBUG-64696)
+-    if (auto *dispatcher = QThread::currentThread()->eventDispatcher())
+-        dispatcher->wakeUp();
+-
+-    wl_callback_destroy(callback);
+-}
+-
+-static const struct wl_callback_listener sync_listener = {
+-    sync_callback
+-};
+-
+ void QWaylandDisplay::forceRoundTrip()
+ {
+-    // wl_display_roundtrip() works on the main queue only,
+-    // but we use a separate one, so basically reimplement it here
+-    int ret = 0;
+-    bool done = false;
+-    wl_callback *callback = wl_display_sync(mDisplay);
+-    wl_callback_add_listener(callback, &sync_listener, &done);
+-    flushRequests();
+-    if (QThread::currentThread()->eventDispatcher()) {
+-        while (!done && ret >= 0) {
+-            QThread::currentThread()->eventDispatcher()->processEvents(QEventLoop::WaitForMoreEvents);
+-            ret = wl_display_dispatch_pending(mDisplay);
+-        }
+-    } else {
+-        while (!done && ret >= 0)
+-            ret = wl_display_dispatch(mDisplay);
+-    }
+-
+-    if (ret == -1 && !done)
+-        wl_callback_destroy(callback);
++     wl_display_roundtrip(mDisplay);
+ }
+ 
+ bool QWaylandDisplay::supportsWindowDecoration() const
+@@ -574,14 +689,10 @@ void QWaylandDisplay::handleKeyboardFocusChanged(QWaylandInputDevice *inputDevic
+     if (mLastKeyboardFocus == keyboardFocus)
+         return;
+ 
+-    if (mWaylandIntegration->mShellIntegration) {
+-        mWaylandIntegration->mShellIntegration->handleKeyboardFocusChanged(keyboardFocus, mLastKeyboardFocus);
+-    } else {
+-        if (keyboardFocus)
+-            handleWindowActivated(keyboardFocus);
+-        if (mLastKeyboardFocus)
+-            handleWindowDeactivated(mLastKeyboardFocus);
+-    }
++    if (keyboardFocus)
++        handleWindowActivated(keyboardFocus);
++    if (mLastKeyboardFocus)
++        handleWindowDeactivated(mLastKeyboardFocus);
+ 
+     mLastKeyboardFocus = keyboardFocus;
+ }
+@@ -600,6 +711,19 @@ void QWaylandDisplay::handleWaylandSync()
+     QWindow *activeWindow = mActiveWindows.empty() ? nullptr : mActiveWindows.last()->window();
+     if (activeWindow != QGuiApplication::focusWindow())
+         QWindowSystemInterface::handleWindowActivated(activeWindow);
++
++    if (!activeWindow) {
++        if (lastInputDevice()) {
++#if QT_CONFIG(clipboard)
++            if (auto *dataDevice = lastInputDevice()->dataDevice())
++                dataDevice->invalidateSelectionOffer();
++#endif
++#if QT_CONFIG(wayland_client_primary_selection)
++            if (auto *device = lastInputDevice()->primarySelectionDevice())
++                device->invalidateSelectionOffer();
++#endif
++        }
++    }
+ }
+ 
+ const wl_callback_listener QWaylandDisplay::syncCallbackListener = {
+@@ -626,6 +750,13 @@ QWaylandInputDevice *QWaylandDisplay::defaultInputDevice() const
+     return mInputDevices.isEmpty() ? 0 : mInputDevices.first();
+ }
+ 
++bool QWaylandDisplay::isKeyboardAvailable() const
++{
++    return std::any_of(
++            mInputDevices.constBegin(), mInputDevices.constEnd(),
++            [this](const QWaylandInputDevice *device) { return device->keyboard() != nullptr; });
++}
++
+ #if QT_CONFIG(cursor)
+ 
+ QWaylandCursor *QWaylandDisplay::waylandCursor()
+@@ -652,4 +783,6 @@ QWaylandCursorTheme *QWaylandDisplay::loadCursorTheme(const QString &name, int p
+ 
+ } // namespace QtWaylandClient
+ 
++#include "qwaylanddisplay.moc"
++
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/client/qwaylanddisplay_p.h b/qtwayland/src/client/qwaylanddisplay_p.h
+index 3b092bc8..42bc661d 100644
+--- a/qtwayland/src/client/qwaylanddisplay_p.h
++++ b/qtwayland/src/client/qwaylanddisplay_p.h
+@@ -109,6 +109,7 @@ class QWaylandSurface;
+ class QWaylandShellIntegration;
+ class QWaylandCursor;
+ class QWaylandCursorTheme;
++class EventThread;
+ 
+ typedef void (*RegistryListener)(void *data,
+                                  struct wl_registry *registry,
+@@ -120,15 +121,11 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandDisplay : public QObject, public QtWayland
+     Q_OBJECT
+ 
+ public:
+-    struct FrameQueue {
+-        FrameQueue(wl_event_queue *q = nullptr) : queue(q), mutex(new QMutex) {}
+-        wl_event_queue *queue;
+-        QMutex *mutex;
+-    };
+-
+     QWaylandDisplay(QWaylandIntegration *waylandIntegration);
+     ~QWaylandDisplay(void) override;
+ 
++    void initialize();
++
+ #if QT_CONFIG(xkbcommon)
+     struct xkb_context *xkbContext() const { return mXkbContext.get(); }
+ #endif
+@@ -210,11 +207,11 @@ public:
+     void handleKeyboardFocusChanged(QWaylandInputDevice *inputDevice);
+     void handleWindowDestroyed(QWaylandWindow *window);
+ 
+-    wl_event_queue *createEventQueue();
+-    FrameQueue createFrameQueue();
+-    void destroyFrameQueue(const FrameQueue &q);
+-    void dispatchQueueWhile(wl_event_queue *queue, std::function<bool()> condition, int timeout = -1);
++    wl_event_queue *frameEventQueue() { return m_frameEventQueue; };
++
++    bool isKeyboardAvailable() const;
+ 
++    void initEventThread();
+ public slots:
+     void blockingReadEvents();
+     void flushRequests();
+@@ -237,6 +234,9 @@ private:
+     };
+ 
+     struct wl_display *mDisplay = nullptr;
++    QScopedPointer<EventThread> m_eventThread;
++    wl_event_queue *m_frameEventQueue = nullptr;
++    QScopedPointer<EventThread> m_frameEventQueueThread;
+     QtWayland::wl_compositor mCompositor;
+     QScopedPointer<QWaylandShm> mShm;
+     QList<QWaylandScreen *> mWaitingScreens;
+@@ -273,11 +273,9 @@ private:
+     QWaylandInputDevice *mLastInputDevice = nullptr;
+     QPointer<QWaylandWindow> mLastInputWindow;
+     QPointer<QWaylandWindow> mLastKeyboardFocus;
+-    QVector<QWaylandWindow *> mActiveWindows;
+-    QVector<FrameQueue> mExternalQueues;
++    QList<QWaylandWindow *> mActiveWindows;
+     struct wl_callback *mSyncCallback = nullptr;
+     static const wl_callback_listener syncCallbackListener;
+-    QReadWriteLock m_frameQueueLock;
+ 
+     bool mClientSideInputContextRequested = !QPlatformInputContextFactory::requested().isNull();
+ 
+diff --git a/qtwayland/src/client/qwaylanddnd.cpp b/qtwayland/src/client/qwaylanddnd.cpp
+index 6535aa16..7c53f5fa 100644
+--- a/qtwayland/src/client/qwaylanddnd.cpp
++++ b/qtwayland/src/client/qwaylanddnd.cpp
+@@ -66,7 +66,7 @@ void QWaylandDrag::startDrag()
+ {
+     QBasicDrag::startDrag();
+     QWaylandWindow *icon = static_cast<QWaylandWindow *>(shapedPixmapWindow()->handle());
+-    if (m_display->currentInputDevice()->dataDevice()->startDrag(drag()->mimeData(), icon)) {
++    if (m_display->currentInputDevice()->dataDevice()->startDrag(drag()->mimeData(), drag()->supportedActions(), icon)) {
+         icon->addAttachOffset(-drag()->hotSpot());
+     } else {
+         // Cancelling immediately does not work, since the event loop for QDrag::exec is started
+@@ -80,6 +80,9 @@ void QWaylandDrag::cancel()
+     QBasicDrag::cancel();
+ 
+     m_display->currentInputDevice()->dataDevice()->cancelDrag();
++
++    if (drag())
++        drag()->deleteLater();
+ }
+ 
+ void QWaylandDrag::move(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods)
+@@ -103,33 +106,41 @@ void QWaylandDrag::endDrag()
+     m_display->currentInputDevice()->handleEndDrag();
+ }
+ 
+-void QWaylandDrag::updateTarget(const QString &mimeType)
++void QWaylandDrag::setResponse(bool accepted)
+ {
+-    setCanDrop(!mimeType.isEmpty());
+-
+-    if (canDrop()) {
+-        updateCursor(defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers()));
+-    } else {
+-        updateCursor(Qt::IgnoreAction);
+-    }
++    // This method is used for old DataDevices where the drag action is not communicated
++    Qt::DropAction action = defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers());
++    setResponse(QPlatformDropQtResponse(accepted, action));
+ }
+ 
+-void QWaylandDrag::setResponse(const QPlatformDragQtResponse &response)
++void QWaylandDrag::setResponse(const QPlatformDropQtResponse &response)
+ {
+     setCanDrop(response.isAccepted());
+ 
+     if (canDrop()) {
+-        updateCursor(defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers()));
++        updateCursor(response.acceptedAction());
+     } else {
+         updateCursor(Qt::IgnoreAction);
+     }
+ }
+ 
+-void QWaylandDrag::finishDrag(const QPlatformDropQtResponse &response)
++void QWaylandDrag::setDropResponse(const QPlatformDropQtResponse &response)
+ {
+     setExecutedDropAction(response.acceptedAction());
++}
++
++void QWaylandDrag::finishDrag()
++{
+     QKeyEvent event(QEvent::KeyPress, Qt::Key_Escape, Qt::NoModifier);
+     eventFilter(shapedPixmapWindow(), &event);
++
++    if (drag())
++        drag()->deleteLater();
++}
++
++bool QWaylandDrag::ownsDragObject() const
++{
++    return true;
+ }
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddnd_p.h b/qtwayland/src/client/qwaylanddnd_p.h
+index 474fe2ab..46f629ac 100644
+--- a/qtwayland/src/client/qwaylanddnd_p.h
++++ b/qtwayland/src/client/qwaylanddnd_p.h
+@@ -71,9 +71,10 @@ public:
+     QWaylandDrag(QWaylandDisplay *display);
+     ~QWaylandDrag() override;
+ 
+-    void updateTarget(const QString &mimeType);
+-    void setResponse(const QPlatformDragQtResponse &response);
+-    void finishDrag(const QPlatformDropQtResponse &response);
++    void setResponse(bool accepted);
++    void setResponse(const QPlatformDropQtResponse &response);
++    void setDropResponse(const QPlatformDropQtResponse &response);
++    void finishDrag();
+ 
+ protected:
+     void startDrag() override;
+@@ -82,6 +83,7 @@ protected:
+     void drop(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods) override;
+     void endDrag() override;
+ 
++    bool ownsDragObject() const override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+diff --git a/qtwayland/src/client/qwaylandinputdevice.cpp b/qtwayland/src/client/qwaylandinputdevice.cpp
+index 613fe862..4b90de84 100644
+--- a/qtwayland/src/client/qwaylandinputdevice.cpp
++++ b/qtwayland/src/client/qwaylandinputdevice.cpp
+@@ -685,6 +685,11 @@ public:
+ 
+ void QWaylandInputDevice::Pointer::pointer_leave(uint32_t time, struct wl_surface *surface)
+ {
++    invalidateFocus();
++    mButtons = Qt::NoButton;
++
++    mParent->mTime = time;
++
+     // The event may arrive after destroying the window, indicated by
+     // a null surface.
+     if (!surface)
+@@ -696,11 +701,6 @@ void QWaylandInputDevice::Pointer::pointer_leave(uint32_t time, struct wl_surfac
+ 
+     if (!QWaylandWindow::mouseGrab())
+         setFrameEvent(new LeaveEvent(window, mSurfacePos, mGlobalPos));
+-
+-    invalidateFocus();
+-    mButtons = Qt::NoButton;
+-
+-    mParent->mTime = time;
+ }
+ 
+ class MotionEvent : public QWaylandPointerEvent
+@@ -1300,14 +1300,6 @@ void QWaylandInputDevice::Keyboard::handleFocusDestroyed()
+ void QWaylandInputDevice::Keyboard::handleFocusLost()
+ {
+     mFocus = nullptr;
+-#if QT_CONFIG(clipboard)
+-    if (auto *dataDevice = mParent->dataDevice())
+-        dataDevice->invalidateSelectionOffer();
+-#endif
+-#if QT_CONFIG(wayland_client_primary_selection)
+-    if (auto *device = mParent->primarySelectionDevice())
+-        device->invalidateSelectionOffer();
+-#endif
+     mParent->mQDisplay->handleKeyboardFocusChanged(mParent);
+     mRepeatTimer.stop();
+ }
+@@ -1396,6 +1388,7 @@ void QWaylandInputDevice::Touch::touch_cancel()
+     if (touchExt)
+         touchExt->touchCanceled();
+ 
++    mFocus = nullptr;
+     QWindowSystemInterface::handleTouchCancelEvent(nullptr, mParent->mTouchDevice);
+ }
+ 
+diff --git a/qtwayland/src/client/qwaylandintegration.cpp b/qtwayland/src/client/qwaylandintegration.cpp
+index c53ccb78..54861600 100644
+--- a/qtwayland/src/client/qwaylandintegration.cpp
++++ b/qtwayland/src/client/qwaylandintegration.cpp
+@@ -125,6 +125,9 @@ QWaylandIntegration::QWaylandIntegration()
+ #endif
+ 
+     reconfigureInputContext();
++
++    QWaylandWindow::fixedToplevelPositions =
++            !qEnvironmentVariableIsSet("QT_WAYLAND_DISABLE_FIXED_POSITIONS");
+ }
+ 
+ QWaylandIntegration::~QWaylandIntegration()
+@@ -192,14 +195,18 @@ QAbstractEventDispatcher *QWaylandIntegration::createEventDispatcher() const
+ 
+ void QWaylandIntegration::initialize()
+ {
++    mDisplay->initEventThread();
++
++    // Call after eventDispatcher is fully connected, for QWaylandDisplay::forceRoundTrip()
++    mDisplay->initialize();
++
++    // But the aboutToBlock() and awake() should be connected after initializePlatform().
++    // Otherwise the connected flushRequests() may consumes up all events before processEvents starts to wait,
++    // so that processEvents(QEventLoop::WaitForMoreEvents) may be blocked in the forceRoundTrip().
+     QAbstractEventDispatcher *dispatcher = QGuiApplicationPrivate::eventDispatcher;
+     QObject::connect(dispatcher, SIGNAL(aboutToBlock()), mDisplay.data(), SLOT(flushRequests()));
+     QObject::connect(dispatcher, SIGNAL(awake()), mDisplay.data(), SLOT(flushRequests()));
+ 
+-    int fd = wl_display_get_fd(mDisplay->wl_display());
+-    QSocketNotifier *sn = new QSocketNotifier(fd, QSocketNotifier::Read, mDisplay.data());
+-    QObject::connect(sn, SIGNAL(activated(QSocketDescriptor)), mDisplay.data(), SLOT(flushRequests()));
+-
+     // Qt does not support running with no screens
+     mDisplay->ensureScreen();
+ }
+@@ -262,6 +269,14 @@ QWaylandDisplay *QWaylandIntegration::display() const
+     return mDisplay.data();
+ }
+ 
++Qt::KeyboardModifiers QWaylandIntegration::queryKeyboardModifiers() const
++{
++    if (auto *seat = mDisplay->currentInputDevice()) {
++        return seat->modifiers();
++    }
++    return Qt::NoModifier;
++}
++
+ QList<int> QWaylandIntegration::possibleKeys(const QKeyEvent *event) const
+ {
+     if (auto *seat = mDisplay->currentInputDevice())
+@@ -479,7 +494,7 @@ void QWaylandIntegration::reconfigureInputContext()
+     }
+ #endif
+ 
+-    qCDebug(lcQpaWayland) << "using input method:" << inputContext()->metaObject()->className();
++    qCDebug(lcQpaWayland) << "using input method:" << (inputContext() ? inputContext()->metaObject()->className() : "<none>");
+ }
+ 
+ QWaylandShellIntegration *QWaylandIntegration::createShellIntegration(const QString &integrationName)
+diff --git a/qtwayland/src/client/qwaylandintegration_p.h b/qtwayland/src/client/qwaylandintegration_p.h
+index ff70ae25..73b80658 100644
+--- a/qtwayland/src/client/qwaylandintegration_p.h
++++ b/qtwayland/src/client/qwaylandintegration_p.h
+@@ -107,6 +107,8 @@ public:
+ 
+     QWaylandDisplay *display() const;
+ 
++    Qt::KeyboardModifiers queryKeyboardModifiers() const override;
++
+     QList<int> possibleKeys(const QKeyEvent *event) const override;
+ 
+     QStringList themeNames() const override;
+diff --git a/qtwayland/src/client/qwaylandprimaryselectionv1.cpp b/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
+index 832f9678..ea508771 100644
+--- a/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
++++ b/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
+@@ -54,11 +54,6 @@ QWaylandPrimarySelectionDeviceManagerV1::QWaylandPrimarySelectionDeviceManagerV1
+     : zwp_primary_selection_device_manager_v1(display->wl_registry(), id, qMin(version, uint(1)))
+     , m_display(display)
+ {
+-    // Create devices for all seats.
+-    // This only works if we get the global before all devices
+-    const auto seats = m_display->inputDevices();
+-    for (auto *seat : seats)
+-        seat->setPrimarySelectionDevice(createDevice(seat));
+ }
+ 
+ QWaylandPrimarySelectionDeviceV1 *QWaylandPrimarySelectionDeviceManagerV1::createDevice(QWaylandInputDevice *seat)
+diff --git a/qtwayland/src/client/qwaylandscreen.cpp b/qtwayland/src/client/qwaylandscreen.cpp
+index 6cb337de..5537dafd 100644
+--- a/qtwayland/src/client/qwaylandscreen.cpp
++++ b/qtwayland/src/client/qwaylandscreen.cpp
+@@ -60,7 +60,7 @@ QWaylandXdgOutputManagerV1::QWaylandXdgOutputManagerV1(QWaylandDisplay* display,
+ }
+ 
+ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uint32_t id)
+-    : QtWayland::wl_output(waylandDisplay->wl_registry(), id, qMin(version, 2))
++    : QtWayland::wl_output(waylandDisplay->wl_registry(), id, qMin(version, 3))
+     , m_outputId(id)
+     , mWaylandDisplay(waylandDisplay)
+     , mOutputName(QStringLiteral("Screen%1").arg(id))
+@@ -72,7 +72,7 @@ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uin
+         qCWarning(lcQpaWayland) << "wl_output done event not supported by compositor,"
+                                 << "QScreen may not work correctly";
+         mWaylandDisplay->forceRoundTrip(); // Give the compositor a chance to send geometry etc.
+-        mOutputDone = true; // Fake the done event
++        mProcessedEvents |= OutputDoneEvent; // Fake the done event
+         maybeInitialize();
+     }
+ }
+@@ -81,16 +81,29 @@ QWaylandScreen::~QWaylandScreen()
+ {
+     if (zxdg_output_v1::isInitialized())
+         zxdg_output_v1::destroy();
++    if (wl_output::isInitialized() && wl_output_get_version(wl_output::object()) >= WL_OUTPUT_RELEASE_SINCE_VERSION)
++        wl_output::release();
++}
++
++uint QWaylandScreen::requiredEvents() const
++{
++    uint ret = OutputDoneEvent;
++
++    if (mWaylandDisplay->xdgOutputManager()) {
++        ret |= XdgOutputNameEvent;
++
++        if (mWaylandDisplay->xdgOutputManager()->version() < 3)
++            ret |= XdgOutputDoneEvent;
++    }
++    return ret;
+ }
+ 
+ void QWaylandScreen::maybeInitialize()
+ {
+     Q_ASSERT(!mInitialized);
+ 
+-    if (!mOutputDone)
+-        return;
+-
+-    if (mWaylandDisplay->xdgOutputManager() && !mXdgOutputDone)
++    const uint requiredEvents = this->requiredEvents();
++    if ((mProcessedEvents & requiredEvents) != requiredEvents)
+         return;
+ 
+     mInitialized = true;
+@@ -276,9 +289,8 @@ void QWaylandScreen::output_scale(int32_t factor)
+ 
+ void QWaylandScreen::output_done()
+ {
+-    mOutputDone = true;
+-    if (zxdg_output_v1::isInitialized() && mWaylandDisplay->xdgOutputManager()->version() >= 3)
+-        mXdgOutputDone = true;
++    mProcessedEvents |= OutputDoneEvent;
++
+     if (mInitialized) {
+         updateOutputProperties();
+         if (zxdg_output_v1::isInitialized())
+@@ -339,7 +351,7 @@ void QWaylandScreen::zxdg_output_v1_done()
+     if (Q_UNLIKELY(mWaylandDisplay->xdgOutputManager()->version() >= 3))
+         qWarning(lcQpaWayland) << "zxdg_output_v1.done received on version 3 or newer, this is most likely a bug in the compositor";
+ 
+-    mXdgOutputDone = true;
++    mProcessedEvents |= XdgOutputDoneEvent;
+     if (mInitialized)
+         updateXdgOutputProperties();
+     else
+@@ -348,7 +360,11 @@ void QWaylandScreen::zxdg_output_v1_done()
+ 
+ void QWaylandScreen::zxdg_output_v1_name(const QString &name)
+ {
++    if (Q_UNLIKELY(mInitialized))
++        qWarning(lcQpaWayland) << "zxdg_output_v1.name received after output has been initialized, this is most likely a bug in the compositor";
++
+     mOutputName = name;
++    mProcessedEvents |= XdgOutputNameEvent;
+ }
+ 
+ void QWaylandScreen::updateXdgOutputProperties()
+diff --git a/qtwayland/src/client/qwaylandscreen_p.h b/qtwayland/src/client/qwaylandscreen_p.h
+index df1c94f2..050cfdc0 100644
+--- a/qtwayland/src/client/qwaylandscreen_p.h
++++ b/qtwayland/src/client/qwaylandscreen_p.h
+@@ -116,6 +116,13 @@ public:
+     static QWaylandScreen *fromWlOutput(::wl_output *output);
+ 
+ private:
++    enum Event : uint {
++        XdgOutputDoneEvent = 0x1,
++        OutputDoneEvent = 0x2,
++        XdgOutputNameEvent = 0x4,
++    };
++    uint requiredEvents() const;
++
+     void output_mode(uint32_t flags, int width, int height, int refresh) override;
+     void output_geometry(int32_t x, int32_t y,
+                          int32_t width, int32_t height,
+@@ -148,8 +155,7 @@ private:
+     QSize mPhysicalSize;
+     QString mOutputName;
+     Qt::ScreenOrientation m_orientation = Qt::PrimaryOrientation;
+-    bool mOutputDone = false;
+-    bool mXdgOutputDone = false;
++    uint mProcessedEvents = 0;
+     bool mInitialized = false;
+ 
+ #if QT_CONFIG(cursor)
+diff --git a/qtwayland/src/client/qwaylandshmbackingstore.cpp b/qtwayland/src/client/qwaylandshmbackingstore.cpp
+index dc7ff670..41cffdf7 100644
+--- a/qtwayland/src/client/qwaylandshmbackingstore.cpp
++++ b/qtwayland/src/client/qwaylandshmbackingstore.cpp
+@@ -52,6 +52,7 @@
+ 
+ #include <QtWaylandClient/private/wayland-wayland-client-protocol.h>
+ 
++#include <fcntl.h>
+ #include <unistd.h>
+ #include <sys/mman.h>
+ 
+@@ -61,6 +62,9 @@
+ #  ifndef MFD_CLOEXEC
+ #    define MFD_CLOEXEC     0x0001U
+ #  endif
++#  ifndef MFD_ALLOW_SEALING
++#    define MFD_ALLOW_SEALING 0x0002U
++#  endif
+ #endif
+ 
+ QT_BEGIN_NAMESPACE
+@@ -74,8 +78,10 @@ QWaylandShmBuffer::QWaylandShmBuffer(QWaylandDisplay *display,
+     int alloc = stride * size.height();
+     int fd = -1;
+ 
+-#ifdef SYS_memfd_create
+-    fd = syscall(SYS_memfd_create, "wayland-shm", MFD_CLOEXEC);
++#if defined(SYS_memfd_create) && defined(F_SEAL_SEAL)
++    fd = syscall(SYS_memfd_create, "wayland-shm", MFD_CLOEXEC | MFD_ALLOW_SEALING);
++    if (fd >= 0)
++        fcntl(fd, F_ADD_SEALS, F_SEAL_SHRINK | F_SEAL_SEAL);
+ #endif
+ 
+     QScopedPointer<QFile> filePointer;
+diff --git a/qtwayland/src/client/qwaylandwindow.cpp b/qtwayland/src/client/qwaylandwindow.cpp
+index cb82857a..fb2c59dc 100644
+--- a/qtwayland/src/client/qwaylandwindow.cpp
++++ b/qtwayland/src/client/qwaylandwindow.cpp
+@@ -76,7 +76,6 @@ QWaylandWindow *QWaylandWindow::mMouseGrab = nullptr;
+ QWaylandWindow::QWaylandWindow(QWindow *window, QWaylandDisplay *display)
+     : QPlatformWindow(window)
+     , mDisplay(display)
+-    , mFrameQueue(mDisplay->createFrameQueue())
+     , mResizeAfterSwap(qEnvironmentVariableIsSet("QT_WAYLAND_RESIZE_AFTER_SWAP"))
+ {
+     {
+@@ -95,9 +94,6 @@ QWaylandWindow::QWaylandWindow(QWindow *window, QWaylandDisplay *display)
+ 
+ QWaylandWindow::~QWaylandWindow()
+ {
+-    mDisplay->destroyFrameQueue(mFrameQueue);
+-    mDisplay->handleWindowDestroyed(this);
+-
+     delete mWindowDecoration;
+ 
+     if (mSurface)
+@@ -243,6 +239,7 @@ bool QWaylandWindow::shouldCreateSubSurface() const
+ 
+ void QWaylandWindow::reset()
+ {
++    closeChildPopups();
+     delete mShellSurface;
+     mShellSurface = nullptr;
+     delete mSubSurfaceWindow;
+@@ -255,17 +252,22 @@ void QWaylandWindow::reset()
+         mSurface.reset();
+     }
+ 
+-    if (mFrameCallback) {
+-        wl_callback_destroy(mFrameCallback);
+-        mFrameCallback = nullptr;
+-    }
++    {
++        QMutexLocker lock(&mFrameSyncMutex);
++        if (mFrameCallback) {
++            wl_callback_destroy(mFrameCallback);
++            mFrameCallback = nullptr;
++        }
+ 
+-    mFrameCallbackElapsedTimer.invalidate();
+-    mWaitingForFrameCallback = false;
++        mFrameCallbackElapsedTimer.invalidate();
++        mWaitingForFrameCallback = false;
++    }
+     mFrameCallbackTimedOut = false;
+ 
+     mMask = QRegion();
+     mQueuedBuffer = nullptr;
++
++    mDisplay->handleWindowDestroyed(this);
+ }
+ 
+ QWaylandWindow *QWaylandWindow::fromWlSurface(::wl_surface *surface)
+@@ -351,19 +353,25 @@ void QWaylandWindow::setGeometry_helper(const QRect &rect)
+     }
+ }
+ 
+-void QWaylandWindow::setGeometry(const QRect &rect)
++void QWaylandWindow::setGeometry(const QRect &r)
+ {
++    auto rect = r;
++    if (fixedToplevelPositions && !QPlatformWindow::parent() && window()->type() != Qt::Popup
++        && window()->type() != Qt::ToolTip) {
++        rect.moveTo(screen()->geometry().topLeft());
++    }
+     setGeometry_helper(rect);
+ 
+     if (window()->isVisible() && rect.isValid()) {
+         if (mWindowDecoration)
+             mWindowDecoration->update();
+ 
+-        if (mResizeAfterSwap && windowType() == Egl && mSentInitialResize)
++        if (mResizeAfterSwap && windowType() == Egl && mSentInitialResize) {
++            QMutexLocker lock(&mResizeLock);
+             mResizeDirty = true;
+-        else
++        } else {
+             QWindowSystemInterface::handleGeometryChange(window(), geometry());
+-
++        }
+         mSentInitialResize = true;
+     }
+     QRect exposeGeometry(QPoint(), geometry().size());
+@@ -374,7 +382,7 @@ void QWaylandWindow::setGeometry(const QRect &rect)
+         mShellSurface->setWindowGeometry(windowContentGeometry());
+ 
+     if (isOpaque() && mMask.isEmpty())
+-        setOpaqueArea(rect);
++        setOpaqueArea(QRect(QPoint(0, 0), rect.size()));
+ }
+ 
+ void QWaylandWindow::resizeFromApplyConfigure(const QSize &sizeWithMargins, const QPoint &offset)
+@@ -399,21 +407,6 @@ void QWaylandWindow::sendExposeEvent(const QRect &rect)
+     mLastExposeGeometry = rect;
+ }
+ 
+-
+-static QVector<QPointer<QWaylandWindow>> activePopups;
+-
+-void QWaylandWindow::closePopups(QWaylandWindow *parent)
+-{
+-    while (!activePopups.isEmpty()) {
+-        auto popup = activePopups.takeLast();
+-        if (popup.isNull())
+-            continue;
+-        if (popup.data() == parent)
+-            return;
+-        popup->reset();
+-    }
+-}
+-
+ QPlatformScreen *QWaylandWindow::calculateScreenFromSurfaceEvents() const
+ {
+     QReadLocker lock(&mSurfaceLock);
+@@ -433,10 +426,7 @@ void QWaylandWindow::setVisible(bool visible)
+     lastVisible = visible;
+ 
+     if (visible) {
+-        if (window()->type() == Qt::Popup || window()->type() == Qt::ToolTip)
+-            activePopups << this;
+         initWindow();
+-        mDisplay->flushRequests();
+ 
+         setGeometry(windowGeometry());
+         // Don't flush the events here, or else the newly visible window may start drawing, but since
+@@ -444,7 +434,6 @@ void QWaylandWindow::setVisible(bool visible)
+         // QWaylandShmBackingStore::beginPaint().
+     } else {
+         sendExposeEvent(QRect());
+-        closePopups(this);
+         reset();
+     }
+ }
+@@ -556,12 +545,12 @@ void QWaylandWindow::sendRecursiveExposeEvent()
+ 
+ void QWaylandWindow::attach(QWaylandBuffer *buffer, int x, int y)
+ {
+-    Q_ASSERT(!buffer->committed());
+     QReadLocker locker(&mSurfaceLock);
+     if (mSurface == nullptr)
+         return;
+ 
+     if (buffer) {
++        Q_ASSERT(!buffer->committed());
+         handleUpdate();
+         buffer->setBusy();
+ 
+@@ -583,7 +572,11 @@ void QWaylandWindow::damage(const QRect &rect)
+     if (mSurface == nullptr)
+         return;
+ 
+-    mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    const int s = scale();
++    if (mDisplay->compositorVersion() >= 4)
++        mSurface->damage_buffer(s * rect.x(), s * rect.y(), s * rect.width(), s * rect.height());
++    else
++        mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
+ }
+ 
+ void QWaylandWindow::safeCommit(QWaylandBuffer *buffer, const QRegion &damage)
+@@ -619,8 +612,14 @@ void QWaylandWindow::commit(QWaylandBuffer *buffer, const QRegion &damage)
+         return;
+ 
+     attachOffset(buffer);
+-    for (const QRect &rect: damage)
+-        mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    if (mDisplay->compositorVersion() >= 4) {
++        const int s = scale();
++        for (const QRect &rect: damage)
++            mSurface->damage_buffer(s * rect.x(), s * rect.y(), s * rect.width(), s * rect.height());
++    } else {
++        for (const QRect &rect: damage)
++            mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    }
+     Q_ASSERT(!buffer->committed());
+     buffer->setCommitted();
+     mSurface->commit();
+@@ -635,42 +634,53 @@ void QWaylandWindow::commit()
+ 
+ const wl_callback_listener QWaylandWindow::callbackListener = {
+     [](void *data, wl_callback *callback, uint32_t time) {
+-        Q_UNUSED(callback);
+         Q_UNUSED(time);
+         auto *window = static_cast<QWaylandWindow*>(data);
+-        window->handleFrameCallback();
++        window->handleFrameCallback(callback);
+     }
+ };
+ 
+-void QWaylandWindow::handleFrameCallback()
++void QWaylandWindow::handleFrameCallback(wl_callback* callback)
+ {
++    QMutexLocker locker(&mFrameSyncMutex);
++    if (!mFrameCallback) {
++        // This means the callback is already unset by QWaylandWindow::reset.
++        // The wl_callback object will be destroyed there too.
++        return;
++    }
++    Q_ASSERT(callback == mFrameCallback);
++    wl_callback_destroy(callback);
++    mFrameCallback = nullptr;
++
+     mWaitingForFrameCallback = false;
+     mFrameCallbackElapsedTimer.invalidate();
+ 
+     // The rest can wait until we can run it on the correct thread
+-    if (!mWaitingForUpdateDelivery) {
+-        auto doHandleExpose = [this]() {
+-            bool wasExposed = isExposed();
+-            mFrameCallbackTimedOut = false;
+-            if (!wasExposed && isExposed()) // Did setting mFrameCallbackTimedOut make the window exposed?
+-                sendExposeEvent(QRect(QPoint(), geometry().size()));
+-            if (wasExposed && hasPendingUpdateRequest())
+-                deliverUpdateRequest();
+-
+-            mWaitingForUpdateDelivery = false;
+-        };
++    auto doHandleExpose = [this]() {
++        mWaitingForUpdateDelivery.storeRelease(false);
++        bool wasExposed = isExposed();
++        mFrameCallbackTimedOut = false;
++        if (!wasExposed && isExposed()) // Did setting mFrameCallbackTimedOut make the window exposed?
++            sendExposeEvent(QRect(QPoint(), geometry().size()));
++        if (wasExposed && hasPendingUpdateRequest())
++            deliverUpdateRequest();
++    };
+ 
++    if (mWaitingForUpdateDelivery.testAndSetAcquire(false, true)) {
+         // Queued connection, to make sure we don't call handleUpdate() from inside waitForFrameSync()
+         // in the single-threaded case.
+-        mWaitingForUpdateDelivery = true;
+         QMetaObject::invokeMethod(this, doHandleExpose, Qt::QueuedConnection);
+     }
++
++    mFrameSyncWait.notify_all();
+ }
+ 
+ bool QWaylandWindow::waitForFrameSync(int timeout)
+ {
+-    QMutexLocker locker(mFrameQueue.mutex);
+-    mDisplay->dispatchQueueWhile(mFrameQueue.queue, [&]() { return mWaitingForFrameCallback; }, timeout);
++    QMutexLocker locker(&mFrameSyncMutex);
++
++    QDeadlineTimer deadline(timeout);
++    while (mWaitingForFrameCallback && mFrameSyncWait.wait(&mFrameSyncMutex, deadline)) { }
+ 
+     if (mWaitingForFrameCallback) {
+         qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
+@@ -868,6 +878,17 @@ bool QWaylandWindow::createDecoration()
+             subsurf->set_position(pos.x() + m.left(), pos.y() + m.top());
+         }
+         sendExposeEvent(QRect(QPoint(), geometry().size()));
++
++        // This is a special case where the buffer is recreated, but since
++        // the content rect remains the same, the widgets remain the same
++        // size and are not redrawn, leaving the new buffer empty. As a simple
++        // work-around, we trigger a full extra update whenever the client-side
++        // window decorations are toggled while the window is showing.
++        // Note: createDecoration() is sometimes called from the render thread
++        // of Qt Quick. This is essentially wrong and could potentially cause problems,
++        // but until the underlying issue has been fixed, we have to use invokeMethod()
++        // here to avoid asserts.
++        QMetaObject::invokeMethod(window(), &QWindow::requestUpdate);
+     }
+ 
+     return mWindowDecoration;
+@@ -1023,6 +1044,13 @@ void QWaylandWindow::handleScreensChanged()
+ 
+     QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->QPlatformScreen::screen());
+     mLastReportedScreen = newScreen;
++    if (fixedToplevelPositions && !QPlatformWindow::parent() && window()->type() != Qt::Popup
++        && window()->type() != Qt::ToolTip
++        && geometry().topLeft() != newScreen->geometry().topLeft()) {
++        auto geometry = this->geometry();
++        geometry.moveTo(newScreen->geometry().topLeft());
++        setGeometry(geometry);
++    }
+ 
+     int scale = newScreen->isPlaceholder() ? 1 : static_cast<QWaylandScreen *>(newScreen)->scale();
+     if (scale != mScale) {
+@@ -1094,10 +1122,18 @@ bool QWaylandWindow::setMouseGrabEnabled(bool grab)
+     return true;
+ }
+ 
++Qt::WindowStates QWaylandWindow::windowStates() const
++{
++    return mLastReportedWindowStates;
++}
++
+ void QWaylandWindow::handleWindowStatesChanged(Qt::WindowStates states)
+ {
+     createDecoration();
+-    QWindowSystemInterface::handleWindowStateChanged(window(), states, mLastReportedWindowStates);
++    Qt::WindowStates statesWithoutActive = states & ~Qt::WindowActive;
++    Qt::WindowStates lastStatesWithoutActive = mLastReportedWindowStates & ~Qt::WindowActive;
++    QWindowSystemInterface::handleWindowStateChanged(window(), statesWithoutActive,
++                                                     lastStatesWithoutActive);
+     mLastReportedWindowStates = states;
+ }
+ 
+@@ -1139,19 +1175,24 @@ void QWaylandWindow::timerEvent(QTimerEvent *event)
+     if (event->timerId() != mFrameCallbackCheckIntervalTimerId)
+         return;
+ 
+-    bool callbackTimerExpired = mFrameCallbackElapsedTimer.hasExpired(mFrameCallbackTimeout);
+-    if (!mFrameCallbackElapsedTimer.isValid() || callbackTimerExpired ) {
+-        killTimer(mFrameCallbackCheckIntervalTimerId);
+-        mFrameCallbackCheckIntervalTimerId = -1;
+-    }
+-    if (mFrameCallbackElapsedTimer.isValid() && callbackTimerExpired) {
+-        mFrameCallbackElapsedTimer.invalidate();
++    {
++        QMutexLocker lock(&mFrameSyncMutex);
+ 
+-        qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
+-        mFrameCallbackTimedOut = true;
+-        mWaitingForUpdate = false;
+-        sendExposeEvent(QRect());
++        bool callbackTimerExpired = mFrameCallbackElapsedTimer.hasExpired(mFrameCallbackTimeout);
++        if (!mFrameCallbackElapsedTimer.isValid() || callbackTimerExpired ) {
++            killTimer(mFrameCallbackCheckIntervalTimerId);
++            mFrameCallbackCheckIntervalTimerId = -1;
++        }
++        if (!mFrameCallbackElapsedTimer.isValid() || !callbackTimerExpired) {
++            return;
++        }
++        mFrameCallbackElapsedTimer.invalidate();
+     }
++
++    qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
++    mFrameCallbackTimedOut = true;
++    mWaitingForUpdate = false;
++    sendExposeEvent(QRect());
+ }
+ 
+ void QWaylandWindow::requestUpdate()
+@@ -1160,8 +1201,11 @@ void QWaylandWindow::requestUpdate()
+     Q_ASSERT(hasPendingUpdateRequest()); // should be set by QPA
+ 
+     // If we have a frame callback all is good and will be taken care of there
+-    if (mWaitingForFrameCallback)
+-        return;
++    {
++        QMutexLocker locker(&mFrameSyncMutex);
++        if (mWaitingForFrameCallback)
++            return;
++    }
+ 
+     // If we've already called deliverUpdateRequest(), but haven't seen any attach+commit/swap yet
+     // This is a somewhat redundant behavior and might indicate a bug in the calling code, so log
+@@ -1174,7 +1218,12 @@ void QWaylandWindow::requestUpdate()
+     // so use invokeMethod to delay the delivery a bit.
+     QMetaObject::invokeMethod(this, [this] {
+         // Things might have changed in the meantime
+-        if (hasPendingUpdateRequest() && !mWaitingForFrameCallback)
++        {
++            QMutexLocker locker(&mFrameSyncMutex);
++            if (mWaitingForFrameCallback)
++                return;
++        }
++        if (hasPendingUpdateRequest())
+             deliverUpdateRequest();
+     }, Qt::QueuedConnection);
+ }
+@@ -1185,19 +1234,18 @@ void QWaylandWindow::requestUpdate()
+ void QWaylandWindow::handleUpdate()
+ {
+     qCDebug(lcWaylandBackingstore) << "handleUpdate" << QThread::currentThread();
++
+     // TODO: Should sync subsurfaces avoid requesting frame callbacks?
+     QReadLocker lock(&mSurfaceLock);
+     if (!mSurface)
+         return;
+ 
+-    if (mFrameCallback) {
+-        wl_callback_destroy(mFrameCallback);
+-        mFrameCallback = nullptr;
+-    }
++    QMutexLocker locker(&mFrameSyncMutex);
++    if (mWaitingForFrameCallback)
++        return;
+ 
+-    QMutexLocker locker(mFrameQueue.mutex);
+     struct ::wl_surface *wrappedSurface = reinterpret_cast<struct ::wl_surface *>(wl_proxy_create_wrapper(mSurface->object()));
+-    wl_proxy_set_queue(reinterpret_cast<wl_proxy *>(wrappedSurface), mFrameQueue.queue);
++    wl_proxy_set_queue(reinterpret_cast<wl_proxy *>(wrappedSurface), mDisplay->frameEventQueue());
+     mFrameCallback = wl_surface_frame(wrappedSurface);
+     wl_proxy_wrapper_destroy(wrappedSurface);
+     wl_callback_add_listener(mFrameCallback, &QWaylandWindow::callbackListener, this);
+@@ -1207,6 +1255,8 @@ void QWaylandWindow::handleUpdate()
+     // Start a timer for handling the case when the compositor stops sending frame callbacks.
+     if (mFrameCallbackTimeout > 0) {
+         QMetaObject::invokeMethod(this, [this] {
++            QMutexLocker locker(&mFrameSyncMutex);
++
+             if (mWaitingForFrameCallback) {
+                 if (mFrameCallbackCheckIntervalTimerId < 0)
+                     mFrameCallbackCheckIntervalTimerId = startTimer(mFrameCallbackTimeout);
+@@ -1267,6 +1317,20 @@ void QWaylandWindow::setOpaqueArea(const QRegion &opaqueArea)
+     wl_region_destroy(region);
+ }
+ 
++void QWaylandWindow::addChildPopup(QWaylandWindow *surface) {
++    mChildPopups.append(surface);
++}
++
++void QWaylandWindow::removeChildPopup(QWaylandWindow *surface) {
++    mChildPopups.removeAll(surface);
++}
++
++void QWaylandWindow::closeChildPopups() {
++    while (!mChildPopups.isEmpty()) {
++        auto popup = mChildPopups.takeLast();
++        popup->reset();
++    }
++}
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/client/qwaylandwindow_p.h b/qtwayland/src/client/qwaylandwindow_p.h
+index 01337cff..2f219d8c 100644
+--- a/qtwayland/src/client/qwaylandwindow_p.h
++++ b/qtwayland/src/client/qwaylandwindow_p.h
+@@ -98,6 +98,9 @@ public:
+     QWaylandWindow(QWindow *window, QWaylandDisplay *display);
+     ~QWaylandWindow() override;
+ 
++    // Keep Toplevels position on the top left corner of their screen
++    static inline bool fixedToplevelPositions = true;
++
+     virtual WindowType windowType() const = 0;
+     virtual void ensureSize();
+     WId winId() const override;
+@@ -148,6 +151,7 @@ public:
+     void setWindowState(Qt::WindowStates states) override;
+     void setWindowFlags(Qt::WindowFlags flags) override;
+     void handleWindowStatesChanged(Qt::WindowStates states);
++    Qt::WindowStates windowStates() const;
+ 
+     void raise() override;
+     void lower() override;
+@@ -206,6 +210,10 @@ public:
+     void handleUpdate();
+     void deliverUpdateRequest() override;
+ 
++    void addChildPopup(QWaylandWindow* child);
++    void removeChildPopup(QWaylandWindow* child);
++    void closeChildPopups();
++
+ public slots:
+     void applyConfigure();
+ 
+@@ -215,7 +223,11 @@ signals:
+ 
+ protected:
+     QWaylandDisplay *mDisplay = nullptr;
++
++    // mSurface can be written by the main thread. Other threads should claim a read lock for access
++    mutable QReadWriteLock mSurfaceLock;
+     QScopedPointer<QWaylandSurface> mSurface;
++
+     QWaylandShellSurface *mShellSurface = nullptr;
+     QWaylandSubSurface *mSubSurfaceWindow = nullptr;
+     QVector<QWaylandSubSurface *> mChildren;
+@@ -225,13 +237,14 @@ protected:
+     Qt::MouseButtons mMousePressedInContentArea = Qt::NoButton;
+ 
+     WId mWindowId;
+-    bool mWaitingForFrameCallback = false;
+     bool mFrameCallbackTimedOut = false; // Whether the frame callback has timed out
+-    bool mWaitingForUpdateDelivery = false;
+     int mFrameCallbackCheckIntervalTimerId = -1;
+-    QElapsedTimer mFrameCallbackElapsedTimer;
+-    struct ::wl_callback *mFrameCallback = nullptr;
+-    QWaylandDisplay::FrameQueue mFrameQueue;
++    QAtomicInt mWaitingForUpdateDelivery = false;
++
++    bool mWaitingForFrameCallback = false; // Protected by mFrameSyncMutex
++    QElapsedTimer mFrameCallbackElapsedTimer; // Protected by mFrameSyncMutex
++    struct ::wl_callback *mFrameCallback = nullptr; // Protected by mFrameSyncMutex
++    QMutex mFrameSyncMutex;
+     QWaitCondition mFrameSyncWait;
+ 
+     // True when we have called deliverRequestUpdate, but the client has not yet attached a new buffer
+@@ -261,6 +274,8 @@ protected:
+     QWaylandBuffer *mQueuedBuffer = nullptr;
+     QRegion mQueuedBufferDamage;
+ 
++    QList<QPointer<QWaylandWindow>> mChildPopups;
++
+ private:
+     void setGeometry_helper(const QRect &rect);
+     void initWindow();
+@@ -283,12 +298,10 @@ private:
+     QRect mLastExposeGeometry;
+ 
+     static const wl_callback_listener callbackListener;
+-    void handleFrameCallback();
++    void handleFrameCallback(struct ::wl_callback* callback);
+ 
+     static QWaylandWindow *mMouseGrab;
+ 
+-    mutable QReadWriteLock mSurfaceLock;
+-
+     friend class QWaylandSubSurface;
+ };
+ 
+diff --git a/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h b/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
+index ccad0048..4cc9b3b8 100644
+--- a/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
++++ b/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
+@@ -73,11 +73,10 @@ public:
+         return true;
+     }
+     virtual QWaylandShellSurface *createShellSurface(QWaylandWindow *window) = 0;
++    // kept for binary compat with layer-shell-qt
+     virtual void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) {
+-        if (newFocus)
+-            m_display->handleWindowActivated(newFocus);
+-        if (oldFocus)
+-            m_display->handleWindowDeactivated(oldFocus);
++        Q_UNUSED(newFocus);
++        Q_UNUSED(oldFocus);
+     }
+     virtual void *nativeResourceForWindow(const QByteArray &resource, QWindow *window) {
+         Q_UNUSED(resource);
+diff --git a/qtwayland/src/compositor/configure.json b/qtwayland/src/compositor/configure.json
+index bcfd5215..da95d07b 100644
+--- a/qtwayland/src/compositor/configure.json
++++ b/qtwayland/src/compositor/configure.json
+@@ -7,6 +7,31 @@
+     "testDir": "../../config.tests",
+ 
+     "libraries": {
++        "wayland-client": {
++            "label": "Wayland client library",
++            "headers": "wayland-version.h",
++            "test": {
++                "main": [
++                    "#if WAYLAND_VERSION_MAJOR < 1",
++                    "# error Wayland 1.8.0 or higher required",
++                    "#endif",
++                    "#if WAYLAND_VERSION_MAJOR == 1",
++                    "# if WAYLAND_VERSION_MINOR < 8",
++                    "#  error Wayland 1.8.0 or higher required",
++                    "# endif",
++                    "# if WAYLAND_VERSION_MINOR == 8",
++                    "#  if WAYLAND_VERSION_MICRO < 0",
++                    "#   error Wayland 1.8.0 or higher required",
++                    "#  endif",
++                    "# endif",
++                    "#endif"
++                 ]
++            },
++            "sources": [
++                { "type": "pkgConfig", "args": "wayland-client" },
++                "-lwayland-client"
++            ]
++        },
+         "wayland-server": {
+             "label": "wayland-server",
+             "headers": "wayland-version.h",
+@@ -151,8 +176,7 @@
+                     "#endif"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "dmabuf-client-buffer": {
+             "label": "Linux Client dma-buf Buffer Sharing",
+@@ -176,8 +200,7 @@
+                     "return 0;"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "vulkan-server-buffer": {
+             "label": "Vulkan Buffer Sharing",
+@@ -195,7 +218,8 @@
+                     "exportAllocInfo.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR;",
+                     "return 0;"
+                 ]
+-            }
++            },
++            "use": "wayland-client"
+         }
+     },
+ 
+diff --git a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
+index 7889f575..64140672 100644
+--- a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
++++ b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
+@@ -40,6 +40,7 @@
+ #include "qwaylandeglwindow.h"
+ 
+ #include <QtWaylandClient/private/qwaylandscreen_p.h>
++#include <QtWaylandClient/private/qwaylandsurface_p.h>
+ #include "qwaylandglcontext.h"
+ 
+ #include <QtEglSupport/private/qeglconvenience_p.h>
+@@ -124,6 +125,7 @@ void QWaylandEglWindow::updateSurface(bool create)
+         }
+         mOffset = QPoint();
+     } else {
++        QReadLocker locker(&mSurfaceLock);
+         if (m_waylandEglWindow) {
+             int current_width, current_height;
+             static bool disableResizeCheck = qgetenv("QT_WAYLAND_DISABLE_RESIZECHECK").toInt();
+@@ -131,14 +133,16 @@ void QWaylandEglWindow::updateSurface(bool create)
+             if (!disableResizeCheck) {
+                 wl_egl_window_get_attached_size(m_waylandEglWindow, &current_width, &current_height);
+             }
+-            if (disableResizeCheck || (current_width != sizeWithMargins.width() || current_height != sizeWithMargins.height())) {
++            if (disableResizeCheck || (current_width != sizeWithMargins.width() || current_height != sizeWithMargins.height()) || m_requestedSize != sizeWithMargins) {
+                 wl_egl_window_resize(m_waylandEglWindow, sizeWithMargins.width(), sizeWithMargins.height(), mOffset.x(), mOffset.y());
++                m_requestedSize = sizeWithMargins;
+                 mOffset = QPoint();
+ 
+                 m_resize = true;
+             }
+-        } else if (create && wlSurface()) {
+-            m_waylandEglWindow = wl_egl_window_create(wlSurface(), sizeWithMargins.width(), sizeWithMargins.height());
++        } else if (create && mSurface) {
++            m_waylandEglWindow = wl_egl_window_create(mSurface->object(), sizeWithMargins.width(), sizeWithMargins.height());
++            m_requestedSize = sizeWithMargins;
+         }
+ 
+         if (!m_eglSurface && m_waylandEglWindow && create) {
+diff --git a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
+index 5b1f4d56..0079dfef 100644
+--- a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
++++ b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
+@@ -88,6 +88,7 @@ private:
+     mutable QOpenGLFramebufferObject *m_contentFBO = nullptr;
+ 
+     QSurfaceFormat m_format;
++    QSize m_requestedSize;
+ };
+ 
+ }
+diff --git a/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h b/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
+index 56a710c3..c6a8b6c6 100644
+--- a/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
++++ b/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
+@@ -41,6 +41,8 @@
+ #include <QtCore/QTextStream>
+ #include <QtGui/QOpenGLTexture>
+ 
++#include <array>
++
+ #include <EGL/egl.h>
+ #include <EGL/eglext.h>
+ 
+diff --git a/qtwayland/src/plugins/decorations/bradient/main.cpp b/qtwayland/src/plugins/decorations/bradient/main.cpp
+index e75fda3c..fa885143 100644
+--- a/qtwayland/src/plugins/decorations/bradient/main.cpp
++++ b/qtwayland/src/plugins/decorations/bradient/main.cpp
+@@ -164,13 +164,10 @@ void QWaylandBradientDecoration::paint(QPaintDevice *device)
+     // Window icon
+     QIcon icon = waylandWindow()->windowIcon();
+     if (!icon.isNull()) {
+-        QPixmap pixmap = icon.pixmap(QSize(128, 128));
+-        QPixmap scaled = pixmap.scaled(22, 22, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+-
+         QRectF iconRect(0, 0, 22, 22);
+-        p.drawPixmap(iconRect.adjusted(margins().left() + BUTTON_SPACING, 4,
+-                                       margins().left() + BUTTON_SPACING, 4),
+-                     scaled, iconRect);
++        iconRect.adjust(margins().left() + BUTTON_SPACING, 4,
++                        margins().left() + BUTTON_SPACING, 4),
++        icon.paint(&p, iconRect.toRect());
+     }
+ 
+     // Window title
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
+index 85d25e3c..60bdd491 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
+@@ -47,18 +47,21 @@ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
+-QWaylandXdgPopupV5::QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow *window)
++QWaylandXdgPopupV5::QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow* parent, QWaylandWindow *window)
+     : QWaylandShellSurface(window)
+     , QtWayland::xdg_popup_v5(popup)
++    , m_parent(parent)
+     , m_window(window)
+ {
+     if (window->display()->windowExtension())
+         m_extendedWindow = new QWaylandExtendedSurface(window);
++    m_parent->addChildPopup(m_window);
+ }
+ 
+ QWaylandXdgPopupV5::~QWaylandXdgPopupV5()
+ {
+     xdg_popup_destroy(object());
++    m_parent->removeChildPopup(m_window);
+     delete m_extendedWindow;
+ }
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
+index 7494f6a6..d85f130b 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
+@@ -70,7 +70,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgPopupV5 : public QWaylandShellSurface
+ {
+     Q_OBJECT
+ public:
+-    QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow *window);
++    QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow* parent, QWaylandWindow *window);
+     ~QWaylandXdgPopupV5() override;
+ 
+ protected:
+@@ -78,6 +78,7 @@ protected:
+ 
+ private:
+     QWaylandExtendedSurface *m_extendedWindow = nullptr;
++    QWaylandWindow *m_parent = nullptr;
+     QWaylandWindow *m_window = nullptr;
+ };
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
+index 7e242c4a..def8452a 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
+@@ -84,7 +84,7 @@ QWaylandXdgPopupV5 *QWaylandXdgShellV5::createXdgPopup(QWaylandWindow *window, Q
+     int x = position.x() + parentWindow->frameMargins().left();
+     int y = position.y() + parentWindow->frameMargins().top();
+ 
+-    auto popup = new QWaylandXdgPopupV5(get_xdg_popup(window->wlSurface(), parentSurface, seat, m_popupSerial, x, y), window);
++    auto popup = new QWaylandXdgPopupV5(get_xdg_popup(window->wlSurface(), parentSurface, seat, m_popupSerial, x, y), parentWindow, window);
+     m_popups.append(window);
+     QObject::connect(popup, &QWaylandXdgPopupV5::destroyed, [this, window](){
+         m_popups.removeOne(window);
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
+index 4e25949f..cfc60939 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
+@@ -85,13 +85,6 @@ QWaylandShellSurface *QWaylandXdgShellV5Integration::createShellSurface(QWayland
+     return m_xdgShell->createXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellV5Integration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) {
+-    if (newFocus && qobject_cast<QWaylandXdgPopupV5 *>(newFocus->shellSurface()))
+-        m_display->handleWindowActivated(newFocus);
+-    if (oldFocus && qobject_cast<QWaylandXdgPopupV5 *>(oldFocus->shellSurface()))
+-        m_display->handleWindowDeactivated(oldFocus);
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
+index ce6bdb9e..aed88670 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
+@@ -67,7 +67,6 @@ public:
+     QWaylandXdgShellV5Integration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShellV5> m_xdgShell;
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
+index 8c371661..151c78e3 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
+@@ -174,6 +174,7 @@ QWaylandXdgSurfaceV6::Popup::Popup(QWaylandXdgSurfaceV6 *xdgSurface, QWaylandXdg
+     , m_xdgSurface(xdgSurface)
+     , m_parent(parent)
+ {
++    m_parent->window()->addChildPopup(m_xdgSurface->window());
+ }
+ 
+ QWaylandXdgSurfaceV6::Popup::~Popup()
+@@ -181,6 +182,8 @@ QWaylandXdgSurfaceV6::Popup::~Popup()
+     if (isInitialized())
+         destroy();
+ 
++    m_parent->window()->removeChildPopup(m_xdgSurface->window());
++
+     if (m_grabbing) {
+         auto *shell = m_xdgSurface->m_shell;
+         Q_ASSERT(shell->m_topmostGrabbingPopup == this);
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
+index 03164316..e8da8ba1 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
+@@ -68,20 +68,6 @@ QWaylandShellSurface *QWaylandXdgShellV6Integration::createShellSurface(QWayland
+     return m_xdgShell->getXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellV6Integration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus)
+-{
+-    if (newFocus) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurfaceV6 *>(newFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowActivated(newFocus);
+-    }
+-    if (oldFocus && qobject_cast<QWaylandXdgSurfaceV6 *>(oldFocus->shellSurface())) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurfaceV6 *>(oldFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowDeactivated(oldFocus);
+-    }
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
+index 261f8cbb..c1bcd5c6 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
+@@ -65,7 +65,6 @@ public:
+     QWaylandXdgShellV6Integration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShellV6> m_xdgShell;
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
+index f3e3c330..fa6d5808 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
+@@ -67,11 +67,6 @@ QWaylandXdgSurface::Toplevel::Toplevel(QWaylandXdgSurface *xdgSurface)
+ 
+ QWaylandXdgSurface::Toplevel::~Toplevel()
+ {
+-    if (m_applied.states & Qt::WindowActive) {
+-        QWaylandWindow *window = m_xdgSurface->window();
+-        window->display()->handleWindowDeactivated(window);
+-    }
+-
+     // The protocol spec requires that the decoration object is deleted before xdg_toplevel.
+     delete m_decoration;
+     m_decoration = nullptr;
+@@ -85,16 +80,15 @@ void QWaylandXdgSurface::Toplevel::applyConfigure()
+     if (!(m_applied.states & (Qt::WindowMaximized|Qt::WindowFullScreen)))
+         m_normalSize = m_xdgSurface->m_window->windowFrameGeometry().size();
+ 
+-    if ((m_pending.states & Qt::WindowActive) && !(m_applied.states & Qt::WindowActive))
++    if ((m_pending.states & Qt::WindowActive) && !(m_applied.states & Qt::WindowActive)
++        && !m_xdgSurface->m_window->display()->isKeyboardAvailable())
+         m_xdgSurface->m_window->display()->handleWindowActivated(m_xdgSurface->m_window);
+ 
+-    if (!(m_pending.states & Qt::WindowActive) && (m_applied.states & Qt::WindowActive))
++    if (!(m_pending.states & Qt::WindowActive) && (m_applied.states & Qt::WindowActive)
++        && !m_xdgSurface->m_window->display()->isKeyboardAvailable())
+         m_xdgSurface->m_window->display()->handleWindowDeactivated(m_xdgSurface->m_window);
+ 
+-    // TODO: none of the other plugins send WindowActive either, but is it on purpose?
+-    Qt::WindowStates statesWithoutActive = m_pending.states & ~Qt::WindowActive;
+-
+-    m_xdgSurface->m_window->handleWindowStatesChanged(statesWithoutActive);
++    m_xdgSurface->m_window->handleWindowStatesChanged(m_pending.states);
+ 
+     if (m_pending.size.isEmpty()) {
+         // An empty size in the configure means it's up to the client to choose the size
+@@ -105,8 +99,6 @@ void QWaylandXdgSurface::Toplevel::applyConfigure()
+         m_xdgSurface->m_window->resizeFromApplyConfigure(m_pending.size);
+     }
+ 
+-    m_xdgSurface->setSizeHints();
+-
+     m_applied = m_pending;
+     qCDebug(lcQpaWayland) << "Applied pending xdg_toplevel configure event:" << m_applied.size << m_applied.states;
+ }
+@@ -203,12 +195,17 @@ QtWayland::xdg_toplevel::resize_edge QWaylandXdgSurface::Toplevel::convertToResi
+                 | ((edges & Qt::RightEdge) ? resize_edge_right : 0));
+ }
+ 
+-QWaylandXdgSurface::Popup::Popup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parent,
++QWaylandXdgSurface::Popup::Popup(QWaylandXdgSurface *xdgSurface, QWaylandWindow *parent,
+                                  QtWayland::xdg_positioner *positioner)
+-    : xdg_popup(xdgSurface->get_popup(parent->object(), positioner->object()))
+-    , m_xdgSurface(xdgSurface)
++    : m_xdgSurface(xdgSurface)
++    , m_parentXdgSurface(qobject_cast<QWaylandXdgSurface *>(parent->shellSurface()))
+     , m_parent(parent)
+ {
++
++    init(xdgSurface->get_popup(m_parentXdgSurface ? m_parentXdgSurface->object() : nullptr, positioner->object()));
++    if (m_parent) {
++        m_parent->addChildPopup(m_xdgSurface->window());
++    }
+ }
+ 
+ QWaylandXdgSurface::Popup::~Popup()
+@@ -216,10 +213,24 @@ QWaylandXdgSurface::Popup::~Popup()
+     if (isInitialized())
+         destroy();
+ 
++    if (m_parent) {
++        m_parent->removeChildPopup(m_xdgSurface->window());
++    }
++
+     if (m_grabbing) {
+         auto *shell = m_xdgSurface->m_shell;
+         Q_ASSERT(shell->m_topmostGrabbingPopup == this);
+-        shell->m_topmostGrabbingPopup = m_parent->m_popup;
++        shell->m_topmostGrabbingPopup = m_parentXdgSurface ? m_parentXdgSurface->m_popup : nullptr;
++        m_grabbing = false;
++
++        // Synthesize Qt enter/leave events for popup
++        QWindow *leave = nullptr;
++        if (m_xdgSurface && m_xdgSurface->window())
++            leave = m_xdgSurface->window()->window();
++        QWindowSystemInterface::handleLeaveEvent(leave);
++
++        if (QWindow *enter = QGuiApplication::topLevelAt(QCursor::pos()))
++            QWindowSystemInterface::handleEnterEvent(enter, enter->mapFromGlobal(QCursor::pos()), QCursor::pos());
+     }
+ }
+ 
+@@ -257,6 +268,7 @@ QWaylandXdgSurface::QWaylandXdgSurface(QWaylandXdgShell *shell, ::xdg_surface *s
+                 m_toplevel->set_parent(parentXdgSurface->m_toplevel->object());
+         }
+     }
++    setSizeHints();
+ }
+ 
+ QWaylandXdgSurface::~QWaylandXdgSurface()
+@@ -400,8 +412,6 @@ void QWaylandXdgSurface::setPopup(QWaylandWindow *parent)
+ {
+     Q_ASSERT(!m_toplevel && !m_popup);
+ 
+-    auto parentXdgSurface = static_cast<QWaylandXdgSurface *>(parent->shellSurface());
+-
+     auto positioner = new QtWayland::xdg_positioner(m_shell->create_positioner());
+     // set_popup expects a position relative to the parent
+     QPoint transientPos = m_window->geometry().topLeft(); // this is absolute
+@@ -414,8 +424,9 @@ void QWaylandXdgSurface::setPopup(QWaylandWindow *parent)
+     positioner->set_anchor(QtWayland::xdg_positioner::anchor_top_left);
+     positioner->set_gravity(QtWayland::xdg_positioner::gravity_bottom_right);
+     positioner->set_size(m_window->geometry().width(), m_window->geometry().height());
+-    m_popup = new Popup(this, parentXdgSurface, positioner);
++    m_popup = new Popup(this, parent, positioner);
+     positioner->destroy();
++
+     delete positioner;
+ }
+ 
+@@ -437,6 +448,23 @@ void QWaylandXdgSurface::setGrabPopup(QWaylandWindow *parent, QWaylandInputDevic
+     }
+     setPopup(parent);
+     m_popup->grab(device, serial);
++
++    // Synthesize Qt enter/leave events for popup
++    if (!parent)
++        return;
++    QWindow *current = QGuiApplication::topLevelAt(QCursor::pos());
++    QWindow *leave = parent->window();
++    if (current != leave)
++        return;
++
++    QWindowSystemInterface::handleLeaveEvent(leave);
++
++    QWindow *enter = nullptr;
++    if (m_popup && m_popup->m_xdgSurface && m_popup->m_xdgSurface->window())
++        enter = m_popup->m_xdgSurface->window()->window();
++
++    if (enter)
++        QWindowSystemInterface::handleEnterEvent(enter, enter->mapFromGlobal(QCursor::pos()), QCursor::pos());
+ }
+ 
+ void QWaylandXdgSurface::xdg_surface_configure(uint32_t serial)
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
+index 96785205..4b518f0a 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
+@@ -131,14 +131,15 @@ private:
+ 
+     class Popup : public QtWayland::xdg_popup {
+     public:
+-        Popup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parent, QtWayland::xdg_positioner *positioner);
++        Popup(QWaylandXdgSurface *xdgSurface, QWaylandWindow *parent, QtWayland::xdg_positioner *positioner);
+         ~Popup() override;
+ 
+         void grab(QWaylandInputDevice *seat, uint serial);
+         void xdg_popup_popup_done() override;
+ 
+         QWaylandXdgSurface *m_xdgSurface = nullptr;
+-        QWaylandXdgSurface *m_parent = nullptr;
++        QWaylandXdgSurface *m_parentXdgSurface = nullptr;
++        QWaylandWindow *m_parent = nullptr;
+         bool m_grabbing = false;
+     };
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
+index 8769d971..da0dd6a7 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
+@@ -69,20 +69,6 @@ QWaylandShellSurface *QWaylandXdgShellIntegration::createShellSurface(QWaylandWi
+     return m_xdgShell->getXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellIntegration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus)
+-{
+-    if (newFocus) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurface *>(newFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowActivated(newFocus);
+-    }
+-    if (oldFocus && qobject_cast<QWaylandXdgSurface *>(oldFocus->shellSurface())) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurface *>(oldFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowDeactivated(oldFocus);
+-    }
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
+index b6caa6c9..2f929f98 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
+@@ -65,7 +65,6 @@ public:
+     QWaylandXdgShellIntegration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShell> m_xdgShell;
+diff --git a/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp b/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
+index 526d0ef4..f50ccf30 100644
+--- a/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
++++ b/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
+@@ -39,7 +39,10 @@
+ 
+ #include "qwaylandinputmethodeventbuilder_p.h"
+ 
++#include <QBrush>
++#include <QGuiApplication>
+ #include <QInputMethod>
++#include <QPalette>
+ #include <QTextCharFormat>
+ 
+ #ifdef QT_BUILD_WAYLANDCOMPOSITOR_LIB
+@@ -81,32 +84,38 @@ void QWaylandInputMethodEventBuilder::addPreeditStyling(uint32_t index, uint32_t
+     QTextCharFormat format;
+ 
+     switch (style) {
+-    case 0:
+-    case 1:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_NONE:
++        break;
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_DEFAULT:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_UNDERLINE:
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-    case 2:
+-    case 3:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_ACTIVE:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_INACTIVE:
+         format.setFontWeight(QFont::Bold);
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-    case 4:
+-        format.setFontUnderline(true);
+-        format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+-        m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_HIGHLIGHT:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_SELECTION:
++        {
++            format.setFontUnderline(true);
++            format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
++            QPalette palette = qApp->palette();
++            format.setBackground(QBrush(palette.color(QPalette::Active, QPalette::Highlight)));
++            format.setForeground(QBrush(palette.color(QPalette::Active, QPalette::HighlightedText)));
++            m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
++        }
+         break;
+-    case 5:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_INCORRECT:
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::WaveUnderline);
+         format.setUnderlineColor(QColor(Qt::red));
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-//    case QtWayland::wl_text_input::preedit_style_selection:
+-//    case QtWayland::wl_text_input::preedit_style_none:
+     default:
+         break;
+     }
+@@ -153,7 +162,7 @@ QInputMethodEvent QWaylandInputMethodEventBuilder::buildPreedit(const QString &t
+ 
+     if (m_preeditCursor < 0) {
+         attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, 0, QVariant()));
+-    } else if (m_preeditCursor > 0) {
++    } else {
+         attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, indexFromWayland(text, m_preeditCursor), 1, QVariant()));
+     }
+ 
+diff --git a/qtwayland/src/shared/qwaylandmimehelper.cpp b/qtwayland/src/shared/qwaylandmimehelper.cpp
+index a5fdd34d..e2fe1928 100644
+--- a/qtwayland/src/shared/qwaylandmimehelper.cpp
++++ b/qtwayland/src/shared/qwaylandmimehelper.cpp
+@@ -60,7 +60,7 @@ QByteArray QWaylandMimeHelper::getByteArray(QMimeData *mimeData, const QString &
+             buf.open(QIODevice::ReadWrite);
+             QByteArray fmt = "BMP";
+             if (mimeType.startsWith(QLatin1String("image/"))) {
+-                QByteArray imgFmt = mimeType.mid(6).toUpper().toLatin1();
++                QByteArray imgFmt = mimeType.mid(6).toLower().toLatin1();
+                 if (QImageWriter::supportedImageFormats().contains(imgFmt))
+                     fmt = imgFmt;
+             }
+@@ -74,7 +74,7 @@ QByteArray QWaylandMimeHelper::getByteArray(QMimeData *mimeData, const QString &
+         QList<QUrl> urls = mimeData->urls();
+         for (int i = 0; i < urls.count(); ++i) {
+             content.append(urls.at(i).toEncoded());
+-            content.append('\n');
++            content.append("\r\n");
+         }
+     } else {
+         content = mimeData->data(mimeType);
+diff --git a/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp b/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
+index 1568b3b9..067410d0 100644
+--- a/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
++++ b/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
+@@ -35,7 +35,7 @@
+ 
+ using namespace MockCompositor;
+ 
+-constexpr int dataDeviceVersion = 1;
++constexpr int dataDeviceVersion = 3;
+ 
+ class DataDeviceCompositor : public DefaultCompositor {
+ public:
+diff --git a/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp b/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
+index 9312c2e5..2ea382f1 100644
+--- a/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
++++ b/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
+@@ -73,6 +73,7 @@ private slots:
+     void multiTouch();
+     void multiTouchUpAndMotionFrame();
+     void tapAndMoveInSameFrame();
++    void cancelTouch();
+ };
+ 
+ void tst_seatv5::bindsToSeat()
+@@ -646,5 +647,34 @@ void tst_seatv5::tapAndMoveInSameFrame()
+     QTRY_COMPARE(window.m_events.last().touchPoints.first().state(), Qt::TouchPointState::TouchPointReleased);
+ }
+ 
++void tst_seatv5::cancelTouch()
++{
++    TouchWindow window;
++    QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
++
++    exec([=] {
++        auto *t = touch();
++        auto *c = client();
++        t->sendDown(xdgToplevel()->surface(), {32, 32}, 1);
++        t->sendFrame(c);
++        t->sendCancel(c);
++        t->sendFrame(c);
++    });
++
++    QTRY_VERIFY(!window.m_events.empty());
++    {
++        auto e = window.m_events.takeFirst();
++        QCOMPARE(e.type, QEvent::TouchBegin);
++        QCOMPARE(e.touchPointStates, Qt::TouchPointPressed);
++        QCOMPARE(e.touchPoints.length(), 1);
++        QCOMPARE(e.touchPoints.first().pos(), QPointF(32-window.frameMargins().left(), 32-window.frameMargins().top()));
++    }
++    {
++        auto e = window.m_events.takeFirst();
++        QCOMPARE(e.type, QEvent::TouchCancel);
++        QCOMPARE(e.touchPoints.length(), 0);
++    }
++}
++
+ QCOMPOSITOR_TEST_MAIN(tst_seatv5)
+ #include "tst_seatv5.moc"
+diff --git a/qtwayland/tests/auto/client/shared/corecompositor.cpp b/qtwayland/tests/auto/client/shared/corecompositor.cpp
+index 5c6c83ba..fa9b7662 100644
+--- a/qtwayland/tests/auto/client/shared/corecompositor.cpp
++++ b/qtwayland/tests/auto/client/shared/corecompositor.cpp
+@@ -27,6 +27,7 @@
+ ****************************************************************************/
+ 
+ #include "corecompositor.h"
++#include <thread>
+ 
+ namespace MockCompositor {
+ 
+diff --git a/qtwayland/tests/auto/client/shared/coreprotocol.cpp b/qtwayland/tests/auto/client/shared/coreprotocol.cpp
+index 0d988521..d1a2e7cb 100644
+--- a/qtwayland/tests/auto/client/shared/coreprotocol.cpp
++++ b/qtwayland/tests/auto/client/shared/coreprotocol.cpp
+@@ -451,6 +451,13 @@ void Touch::sendFrame(wl_client *client)
+         send_frame(r->handle);
+ }
+ 
++void Touch::sendCancel(wl_client *client)
++{
++    const auto touchResources = resourceMap().values(client);
++    for (auto *r : touchResources)
++        send_cancel(r->handle);
++}
++
+ uint Keyboard::sendEnter(Surface *surface)
+ {
+     auto serial = m_seat->m_compositor->nextSerial();
+diff --git a/qtwayland/tests/auto/client/shared/coreprotocol.h b/qtwayland/tests/auto/client/shared/coreprotocol.h
+index a1af137a..210d8ddb 100644
+--- a/qtwayland/tests/auto/client/shared/coreprotocol.h
++++ b/qtwayland/tests/auto/client/shared/coreprotocol.h
+@@ -158,7 +158,7 @@ class WlCompositor : public Global, public QtWaylandServer::wl_compositor
+ {
+     Q_OBJECT
+ public:
+-    explicit WlCompositor(CoreCompositor *compositor, int version = 3)
++    explicit WlCompositor(CoreCompositor *compositor, int version = 4)
+         : QtWaylandServer::wl_compositor(compositor->m_display, version)
+         , m_compositor(compositor)
+     {}
+@@ -364,6 +364,7 @@ public:
+     uint sendUp(wl_client *client, int id);
+     void sendMotion(wl_client *client, const QPointF &position, int id);
+     void sendFrame(wl_client *client);
++    void sendCancel(wl_client *client);
+ 
+     Seat *m_seat = nullptr;
+ };
+diff --git a/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp b/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
+index a415cbf5..b1d3d07d 100644
+--- a/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
++++ b/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
+@@ -342,7 +342,7 @@ Compositor::Compositor(MockCompositor *mockCompositor)
+         exit(EXIT_FAILURE);
+     }
+ 
+-    wl_global_create(m_display, &wl_compositor_interface, 1, this, bindCompositor);
++    wl_global_create(m_display, &wl_compositor_interface, 4, this, bindCompositor);
+ 
+     m_data_device_manager.reset(new DataDeviceManager(this, m_display));
+ 
+diff --git a/qtwayland/tests/auto/client/shared_old/mocksurface.cpp b/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
+index e9df5f90..c3246e4a 100644
+--- a/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
++++ b/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
+@@ -125,6 +125,16 @@ void Surface::surface_damage(Resource *resource,
+     Q_UNUSED(height);
+ }
+ 
++void Surface::surface_damage_buffer(Resource *resource,
++                                    int32_t x, int32_t y, int32_t width, int32_t height)
++{
++    Q_UNUSED(resource);
++    Q_UNUSED(x);
++    Q_UNUSED(y);
++    Q_UNUSED(width);
++    Q_UNUSED(height);
++}
++
+ void Surface::surface_frame(Resource *resource,
+                             uint32_t callback)
+ {
+diff --git a/qtwayland/tests/auto/client/shared_old/mocksurface.h b/qtwayland/tests/auto/client/shared_old/mocksurface.h
+index 949dc23d..d176837e 100644
+--- a/qtwayland/tests/auto/client/shared_old/mocksurface.h
++++ b/qtwayland/tests/auto/client/shared_old/mocksurface.h
+@@ -65,6 +65,8 @@ protected:
+                         struct wl_resource *buffer, int x, int y) override;
+     void surface_damage(Resource *resource,
+                         int32_t x, int32_t y, int32_t width, int32_t height) override;
++    void surface_damage_buffer(Resource *resource,
++                               int32_t x, int32_t y, int32_t width, int32_t height) override;
+     void surface_frame(Resource *resource,
+                        uint32_t callback) override;
+     void surface_commit(Resource *resource) override;
+diff --git a/qtwayland/tests/auto/client/surface/tst_surface.cpp b/qtwayland/tests/auto/client/surface/tst_surface.cpp
+index 95e4e609..60c672ce 100644
+--- a/qtwayland/tests/auto/client/surface/tst_surface.cpp
++++ b/qtwayland/tests/auto/client/surface/tst_surface.cpp
+@@ -129,6 +129,10 @@ void tst_surface::waitForFrameCallbackGl()
+     // Make sure we follow frame callbacks for some frames
+     for (int i = 0; i < 5; ++i) {
+         xdgPingAndWaitForPong(); // Make sure things have happened on the client
++        if (!qEnvironmentVariableIntValue("QT_WAYLAND_DISABLE_WINDOWDECORATION") && i == 0) {
++            QCOMPARE(bufferSpy.count(), 1);
++            bufferSpy.removeFirst();
++        }
+         exec([&] {
+             QVERIFY(bufferSpy.empty()); // Make sure no extra buffers have arrived
+             QVERIFY(!xdgToplevel()->surface()->m_waitingFrameCallbacks.empty());
+diff --git a/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp b/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
+index 2277bbb8..747875b4 100644
+--- a/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
++++ b/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
+@@ -31,6 +31,7 @@
+ #include <QtGui/QOpenGLWindow>
+ #include <QtGui/qpa/qplatformnativeinterface.h>
+ #include <QtWaylandClient/private/wayland-wayland-client-protocol.h>
++#include <QtWaylandClient/private/qwaylandwindow_p.h>
+ 
+ using namespace MockCompositor;
+ 
+@@ -45,6 +46,7 @@ private slots:
+     void configureStates();
+     void popup();
+     void tooltipOnPopup();
++    void tooltipAndSiblingPopup();
+     void switchPopups();
+     void hidePopupParent();
+     void pongs();
+@@ -138,6 +140,7 @@ void tst_xdgshell::configureSize()
+ 
+ void tst_xdgshell::configureStates()
+ {
++    QVERIFY(qputenv("QT_WAYLAND_FRAME_CALLBACK_TIMEOUT", "0"));
+     QRasterWindow window;
+     window.resize(64, 48);
+     window.show();
+@@ -154,9 +157,12 @@ void tst_xdgshell::configureStates()
+     // Toplevel windows don't know their position on xdg-shell
+ //    QCOMPARE(window.frameGeometry().topLeft(), QPoint()); // TODO: this doesn't currently work when window decorations are enabled
+ 
+-//    QEXPECT_FAIL("", "configure has already been acked, we shouldn't have to wait for isActive", Continue);
+-//    QVERIFY(window.isActive());
+-    QTRY_VERIFY(window.isActive()); // Just make sure it eventually get's set correctly
++    // window.windowstate() is driven by keyboard focus, however for decorations we want to follow
++    // XDGShell this is internal to QtWayland so it is queried directly
++    auto waylandWindow = static_cast<QtWaylandClient::QWaylandWindow *>(window.handle());
++    Q_ASSERT(waylandWindow);
++    QTRY_VERIFY(waylandWindow->windowStates().testFlag(
++            Qt::WindowActive)); // Just make sure it eventually get's set correctly
+ 
+     const QSize screenSize(640, 480);
+     const uint maximizedSerial = exec([=] {
+@@ -186,6 +192,7 @@ void tst_xdgshell::configureStates()
+     QCOMPARE(window.windowStates(), Qt::WindowNoState);
+     QCOMPARE(window.frameGeometry().size(), windowedSize);
+ //    QCOMPARE(window.frameGeometry().topLeft(), QPoint()); // TODO: this doesn't currently work when window decorations are enabled
++    QVERIFY(qunsetenv("QT_WAYLAND_FRAME_CALLBACK_TIMEOUT"));
+ }
+ 
+ void tst_xdgshell::popup()
+@@ -340,6 +347,92 @@ void tst_xdgshell::tooltipOnPopup()
+     QCOMPOSITOR_TRY_COMPARE(xdgPopup(0), nullptr);
+ }
+ 
++void tst_xdgshell::tooltipAndSiblingPopup()
++{
++    class ToolTip : public QRasterWindow {
++    public:
++        explicit ToolTip(QWindow *parent) {
++            setTransientParent(parent);
++            setFlags(Qt::ToolTip);
++            resize(100, 100);
++            show();
++        }
++        void mousePressEvent(QMouseEvent *event) override {
++            QRasterWindow::mousePressEvent(event);
++            m_popup = new QRasterWindow;
++            m_popup->setTransientParent(transientParent());
++            m_popup->setFlags(Qt::Popup);
++            m_popup->resize(100, 100);
++            m_popup->show();
++        }
++
++        QRasterWindow *m_popup = nullptr;
++    };
++
++    class Window : public QRasterWindow {
++    public:
++        void mousePressEvent(QMouseEvent *event) override {
++            QRasterWindow::mousePressEvent(event);
++            m_tooltip = new ToolTip(this);
++        }
++        ToolTip *m_tooltip = nullptr;
++    };
++
++    Window window;
++    window.resize(200, 200);
++    window.show();
++
++    QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
++    exec([=] { xdgToplevel()->sendCompleteConfigure(); });
++    QCOMPOSITOR_TRY_VERIFY(xdgToplevel()->m_xdgSurface->m_committedConfigureSerial);
++
++    exec([=] {
++        auto *surface = xdgToplevel()->surface();
++        auto *p = pointer();
++        auto *c = client();
++        p->sendEnter(surface, {100, 100});
++        p->sendFrame(c);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_pressed);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_released);
++        p->sendFrame(c);
++        p->sendLeave(surface);
++        p->sendFrame(c);
++    });
++
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup());
++    exec([=] { xdgPopup()->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup()->m_xdgSurface->m_committedConfigureSerial);
++    QCOMPOSITOR_TRY_VERIFY(!xdgPopup()->m_grabbed);
++
++    exec([=] {
++        auto *surface = xdgPopup()->surface();
++        auto *p = pointer();
++        auto *c = client();
++        p->sendEnter(surface, {100, 100});
++        p->sendFrame(c);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_pressed);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_released);
++        p->sendFrame(c);
++    });
++
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1));
++    exec([=] { xdgPopup(1)->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1)->m_xdgSurface->m_committedConfigureSerial);
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1)->m_grabbed);
++
++    // Close the middle tooltip (it should not close the sibling popup)
++    window.m_tooltip->close();
++
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(1), nullptr);
++    // Verify the remaining xdg surface is a grab popup..
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(0));
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(0)->m_grabbed);
++
++    window.m_tooltip->m_popup->close();
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(1), nullptr);
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(0), nullptr);
++}
++
+ // QTBUG-65680
+ void tst_xdgshell::switchPopups()
+ {
+@@ -505,7 +598,7 @@ void tst_xdgshell::minMaxSize()
+     window.show();
+     QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
+ 
+-    exec([=] { xdgToplevel()->sendCompleteConfigure(); });
++    // we don't roundtrip with our configuration the initial commit should be correct
+ 
+     QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.minSize, QSize(100, 100));
+     QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.maxSize, QSize(1000, 1000));
+Submodule qtwebchannel 618422ee..f8949655:
+diff --git a/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp b/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
+index 536eb5c..898d769 100644
+--- a/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
++++ b/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
+@@ -186,8 +186,6 @@ Q_DECLARE_TYPEINFO(OverloadResolutionCandidate, Q_MOVABLE_TYPE);
+ QMetaObjectPublisher::QMetaObjectPublisher(QWebChannel *webChannel)
+     : QObject(webChannel)
+     , webChannel(webChannel)
+-    , signalHandler(this)
+-    , clientIsIdle(false)
+     , blockUpdates(false)
+     , propertyUpdatesInitialized(false)
+ {
+@@ -301,17 +299,17 @@ QJsonObject QMetaObjectPublisher::classInfoForObject(const QObject *object, QWeb
+     return data;
+ }
+ 
+-void QMetaObjectPublisher::setClientIsIdle(bool isIdle)
++void QMetaObjectPublisher::setClientIsIdle(bool isIdle, QWebChannelAbstractTransport *transport)
+ {
+-    if (clientIsIdle == isIdle) {
+-        return;
+-    }
+-    clientIsIdle = isIdle;
+-    if (!isIdle && timer.isActive()) {
+-        timer.stop();
+-    } else if (isIdle && !timer.isActive()) {
+-        timer.start(PROPERTY_UPDATE_INTERVAL, this);
+-    }
++    transportState[transport].clientIsIdle = isIdle;
++    if (isIdle)
++        sendEnqueuedPropertyUpdates(transport);
++}
++
++bool QMetaObjectPublisher::isClientIdle(QWebChannelAbstractTransport *transport)
++{
++    auto found = transportState.find(transport);
++    return found != transportState.end() && found.value().clientIsIdle;
+ }
+ 
+ QJsonObject QMetaObjectPublisher::initializeClient(QWebChannelAbstractTransport *transport)
+@@ -333,6 +331,7 @@ QJsonObject QMetaObjectPublisher::initializeClient(QWebChannelAbstractTransport
+ 
+ void QMetaObjectPublisher::initializePropertyUpdates(const QObject *const object, const QJsonObject &objectInfo)
+ {
++    auto *signalHandler = signalHandlerFor(object);
+     foreach (const QJsonValue &propertyInfoVar, objectInfo[KEY_PROPERTIES].toArray()) {
+         const QJsonArray &propertyInfo = propertyInfoVar.toArray();
+         if (propertyInfo.size() < 2) {
+@@ -353,19 +352,19 @@ void QMetaObjectPublisher::initializePropertyUpdates(const QObject *const object
+ 
+         // Only connect for a property update once
+         if (connectedProperties.isEmpty()) {
+-            signalHandler.connectTo(object, signalIndex);
++            signalHandler->connectTo(object, signalIndex);
+         }
+ 
+         connectedProperties.insert(propertyIndex);
+     }
+ 
+     // also always connect to destroyed signal
+-    signalHandler.connectTo(object, s_destroyedSignalIndex);
++    signalHandler->connectTo(object, s_destroyedSignalIndex);
+ }
+ 
+ void QMetaObjectPublisher::sendPendingPropertyUpdates()
+ {
+-    if (blockUpdates || !clientIsIdle || pendingPropertyUpdates.isEmpty()) {
++    if (blockUpdates) {
+         return;
+     }
+ 
+@@ -415,18 +414,19 @@ void QMetaObjectPublisher::sendPendingPropertyUpdates()
+ 
+     // data does not contain specific updates
+     if (!data.isEmpty()) {
+-        setClientIsIdle(false);
+-
+         message[KEY_DATA] = data;
+-        broadcastMessage(message);
++        enqueueBroadcastMessage(message);
+     }
+ 
+     // send every property update which is not supposed to be broadcasted
+     const QHash<QWebChannelAbstractTransport*, QJsonArray>::const_iterator suend = specificUpdates.constEnd();
+     for (QHash<QWebChannelAbstractTransport*, QJsonArray>::const_iterator it = specificUpdates.constBegin(); it != suend; ++it) {
+         message[KEY_DATA] = it.value();
+-        it.key()->sendMessage(message);
++        enqueueMessage(message, it.key());
+     }
++
++    for (auto state = transportState.begin(); state != transportState.end(); ++state)
++        sendEnqueuedPropertyUpdates(state.key());
+ }
+ 
+ QVariant QMetaObjectPublisher::invokeMethod(QObject *const object, const QMetaMethod &method,
+@@ -572,7 +572,7 @@ void QMetaObjectPublisher::signalEmitted(const QObject *object, const int signal
+         }
+     } else {
+         pendingPropertyUpdates[object][signalIndex] = arguments;
+-        if (clientIsIdle && !blockUpdates && !timer.isActive()) {
++        if (!blockUpdates && !timer.isActive()) {
+             timer.start(PROPERTY_UPDATE_INTERVAL, this);
+         }
+     }
+@@ -590,7 +590,7 @@ void QMetaObjectPublisher::objectDestroyed(const QObject *object)
+     // only remove from handler when we initialized the property updates
+     // cf: https://bugreports.qt.io/browse/QTBUG-60250
+     if (propertyUpdatesInitialized) {
+-        signalHandler.remove(object);
++        signalHandlerFor(object)->remove(object);
+         signalToPropertyMap.remove(object);
+     }
+     pendingPropertyUpdates.remove(object);
+@@ -852,6 +852,52 @@ void QMetaObjectPublisher::broadcastMessage(const QJsonObject &message) const
+     }
+ }
+ 
++void QMetaObjectPublisher::enqueueBroadcastMessage(const QJsonObject &message)
++{
++    if (webChannel->d_func()->transports.isEmpty()) {
++        qWarning("QWebChannel is not connected to any transports, cannot send message: %s",
++                 QJsonDocument(message).toJson().constData());
++        return;
++    }
++
++    for (auto *transport : webChannel->d_func()->transports) {
++        auto &state = transportState[transport];
++        state.queuedMessages.append(message);
++    }
++}
++
++void QMetaObjectPublisher::enqueueMessage(const QJsonObject &message,
++                                          QWebChannelAbstractTransport *transport)
++{
++    auto &state = transportState[transport];
++    state.queuedMessages.append(message);
++}
++
++void QMetaObjectPublisher::sendEnqueuedPropertyUpdates(QWebChannelAbstractTransport *transport)
++{
++    auto found = transportState.find(transport);
++    if (found != transportState.end() && found.value().clientIsIdle
++        && !found.value().queuedMessages.isEmpty()) {
++
++        // If the client is connected with an in-process transport, it can
++        // happen that a message triggers a subsequent property change. In
++        // that case, we need to ensure that the queued messages have already
++        // been cleared; otherwise the recursive call will send everythig again.
++        // Case in point: The qmlwebchannel tests fail if we don't clear the
++        // queued messages before sending them out.
++        // For that same reason set the client to "busy" (aka non-idle) just
++        // right before sending out the messages; otherwise a potential
++        // "Idle" type message will not correctly restore the Idle state.
++        const auto messages = std::move(found.value().queuedMessages);
++        Q_ASSERT(found.value().queuedMessages.isEmpty());
++        found.value().clientIsIdle = false;
++
++        for (const auto &message : messages) {
++            transport->sendMessage(message);
++        }
++    }
++}
++
+ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannelAbstractTransport *transport)
+ {
+     if (!webChannel->d_func()->transports.contains(transport)) {
+@@ -866,7 +912,7 @@ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannel
+ 
+     const MessageType type = toType(message.value(KEY_TYPE));
+     if (type == TypeIdle) {
+-        setClientIsIdle(true);
++        setClientIsIdle(true, transport);
+     } else if (type == TypeInit) {
+         if (!message.contains(KEY_ID)) {
+             qWarning("JSON message object is missing the id property: %s",
+@@ -913,9 +959,9 @@ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannel
+                 return;
+             transport->sendMessage(createResponse(message.value(KEY_ID), wrapResult(result, transport)));
+         } else if (type == TypeConnectToSignal) {
+-            signalHandler.connectTo(object, message.value(KEY_SIGNAL).toInt(-1));
++            signalHandlerFor(object)->connectTo(object, message.value(KEY_SIGNAL).toInt(-1));
+         } else if (type == TypeDisconnectFromSignal) {
+-            signalHandler.disconnectFrom(object, message.value(KEY_SIGNAL).toInt(-1));
++            signalHandlerFor(object)->disconnectFrom(object, message.value(KEY_SIGNAL).toInt(-1));
+         } else if (type == TypeSetProperty) {
+             setProperty(object, message.value(KEY_PROPERTY).toInt(-1),
+                         message.value(KEY_VALUE));
+@@ -931,6 +977,7 @@ void QMetaObjectPublisher::setBlockUpdates(bool block)
+     blockUpdates = block;
+ 
+     if (!blockUpdates) {
++        timer.start(PROPERTY_UPDATE_INTERVAL, this);
+         sendPendingPropertyUpdates();
+     } else if (timer.isActive()) {
+         timer.stop();
+@@ -948,4 +995,15 @@ void QMetaObjectPublisher::timerEvent(QTimerEvent *event)
+     }
+ }
+ 
++SignalHandler<QMetaObjectPublisher> *QMetaObjectPublisher::signalHandlerFor(const QObject *object)
++{
++    auto thread = object->thread();
++    auto it = signalHandlers.find(thread);
++    if (it == signalHandlers.end()) {
++        it = signalHandlers.emplace(thread, this).first;
++        it->second.moveToThread(thread);
++    }
++    return &it->second;
++}
++
+ QT_END_NAMESPACE
+diff --git a/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h b/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
+index bbd9875..4713ef1 100644
+--- a/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
++++ b/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
+@@ -59,6 +59,9 @@
+ #include <QBasicTimer>
+ #include <QPointer>
+ #include <QJsonObject>
++#include <QQueue>
++
++#include <unordered_map>
+ 
+ #include "qwebchannelglobal.h"
+ 
+@@ -109,17 +112,36 @@ public:
+      */
+     void broadcastMessage(const QJsonObject &message) const;
+ 
++    /**
++     * Enqueue the given @p message to all known transports.
++     */
++    void enqueueBroadcastMessage(const QJsonObject &message);
++
++    /**
++     * Enqueue the given @p message to @p transport.
++     */
++    void enqueueMessage(const QJsonObject &message, QWebChannelAbstractTransport *transport);
++
++    /**
++     * If client for given @p transport is idle, send queued messaged to @p transport and then mark
++     * the client as not idle.
++     */
++    void sendEnqueuedPropertyUpdates(QWebChannelAbstractTransport *transport);
++
+     /**
+      * Serialize the QMetaObject of @p object and return it in JSON form.
+      */
+     QJsonObject classInfoForObject(const QObject *object, QWebChannelAbstractTransport *transport);
+ 
+     /**
+-     * Set the client to idle or busy, based on the value of @p isIdle.
+-     *
+-     * When the value changed, start/stop the property update timer accordingly.
++     * Set the client to idle or busy for a single @p transport, based on the value of @p isIdle.
++     */
++    void setClientIsIdle(bool isIdle, QWebChannelAbstractTransport *transport);
++
++    /**
++     * Check that client is idle for @p transport.
+      */
+-    void setClientIsIdle(bool isIdle);
++    bool isClientIdle(QWebChannelAbstractTransport *transport);
+ 
+     /**
+      * Initialize clients by sending them the class information of the registered objects.
+@@ -272,10 +294,18 @@ private:
+     friend class TestWebChannel;
+ 
+     QWebChannel *webChannel;
+-    SignalHandler<QMetaObjectPublisher> signalHandler;
++    std::unordered_map<const QThread*, SignalHandler<QMetaObjectPublisher>> signalHandlers;
++    SignalHandler<QMetaObjectPublisher> *signalHandlerFor(const QObject *object);
+ 
+-    // true when the client is idle, false otherwise
+-    bool clientIsIdle;
++    struct TransportState
++    {
++        TransportState() : clientIsIdle(false) { }
++        // true when the client is idle, false otherwise
++        bool clientIsIdle;
++        // messages to send
++        QQueue<QJsonObject> queuedMessages;
++    };
++    QHash<QWebChannelAbstractTransport *, TransportState> transportState;
+ 
+     // true when no property updates should be sent, false otherwise
+     bool blockUpdates;
+diff --git a/qtwebchannel/src/webchannel/signalhandler_p.h b/qtwebchannel/src/webchannel/signalhandler_p.h
+index 27afadb..d77373c 100644
+--- a/qtwebchannel/src/webchannel/signalhandler_p.h
++++ b/qtwebchannel/src/webchannel/signalhandler_p.h
+@@ -56,6 +56,7 @@
+ #include <QVector>
+ #include <QMetaMethod>
+ #include <QDebug>
++#include <QThread>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -71,6 +72,7 @@ static const int s_destroyedSignalIndex = QObject::staticMetaObject.indexOfMetho
+ template<class Receiver>
+ class SignalHandler : public QObject
+ {
++    Q_DISABLE_COPY(SignalHandler)
+ public:
+     SignalHandler(Receiver *receiver, QObject *parent = 0);
+ 
+@@ -268,6 +270,7 @@ int SignalHandler<Receiver>::qt_metacall(QMetaObject::Call call, int methodId, v
+     if (call == QMetaObject::InvokeMetaMethod) {
+         const QObject *object = sender();
+         Q_ASSERT(object);
++        Q_ASSERT(QThread::currentThread() == object->thread());
+         Q_ASSERT(senderSignalIndex() == methodId);
+         Q_ASSERT(m_connectionsCounter.contains(object));
+         Q_ASSERT(m_connectionsCounter.value(object).contains(methodId));
+diff --git a/qtwebchannel/tests/auto/qml/testwebchannel.cpp b/qtwebchannel/tests/auto/qml/testwebchannel.cpp
+index 9891687..3ca81c2 100644
+--- a/qtwebchannel/tests/auto/qml/testwebchannel.cpp
++++ b/qtwebchannel/tests/auto/qml/testwebchannel.cpp
+@@ -46,7 +46,11 @@ TestWebChannel::~TestWebChannel()
+ 
+ bool TestWebChannel::clientIsIdle() const
+ {
+-    return QWebChannel::d_func()->publisher->clientIsIdle;
++    for (auto *transport : QWebChannel::d_func()->transports) {
++        if (QWebChannel::d_func()->publisher->isClientIdle(transport))
++            return true;
++    }
++    return false;
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp b/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
+index 181da9e..37f989a 100644
+--- a/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
++++ b/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
+@@ -785,7 +785,7 @@ void TestWebChannel::testTransportWrapObjectProperties()
+     DummyTransport *dummyTransport = new DummyTransport(this);
+     channel.connectTo(dummyTransport);
+     channel.d_func()->publisher->initializeClient(dummyTransport);
+-    channel.d_func()->publisher->setClientIsIdle(true);
++    channel.d_func()->publisher->setClientIsIdle(true, dummyTransport);
+ 
+     QCOMPARE(channel.d_func()->publisher->transportedWrappedObjects.size(), 0);
+ 
+@@ -943,8 +943,6 @@ void TestWebChannel::testInfiniteRecursion()
+ 
+ void TestWebChannel::testAsyncObject()
+ {
+-    QSKIP("This test is broken. See QTBUG-80729");
+-
+     QWebChannel channel;
+     channel.connectTo(m_dummyTransport);
+ 
+@@ -990,6 +988,50 @@ void TestWebChannel::testAsyncObject()
+     thread.wait();
+ }
+ 
++void TestWebChannel::testPropertyMultipleTransports()
++{
++    DummyTransport transport1;
++    DummyTransport transport2;
++
++    QWebChannel channel;
++    QMetaObjectPublisher *publisher = channel.d_func()->publisher;
++
++    TestObject testObj;
++    testObj.setObjectName("testObject");
++    channel.registerObject(testObj.objectName(), &testObj);
++    channel.connectTo(&transport1);
++    channel.connectTo(&transport2);
++
++    testObj.setProp("Hello");
++
++    publisher->initializeClient(&transport1);
++    publisher->initializeClient(&transport2);
++    publisher->setClientIsIdle(true, &transport1);
++    QCOMPARE(publisher->isClientIdle(&transport1), true);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++    QVERIFY(transport1.messagesSent().isEmpty());
++    QVERIFY(transport2.messagesSent().isEmpty());
++
++    testObj.setProp("World");
++    QTRY_COMPARE_WITH_TIMEOUT(transport1.messagesSent().size(), 1u, 2000);
++    QCOMPARE(transport2.messagesSent().size(), 0u);
++    publisher->setClientIsIdle(true, &transport2);
++    QTRY_COMPARE_WITH_TIMEOUT(transport2.messagesSent().size(), 1u, 2000);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++
++    testObj.setProp("!!!");
++    publisher->setClientIsIdle(true, &transport2);
++    QCOMPARE(publisher->isClientIdle(&transport2), true);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QTRY_COMPARE_WITH_TIMEOUT(transport2.messagesSent().size(), 2u, 2000);
++    QCOMPARE(transport1.messagesSent().size(), 1u);
++    publisher->setClientIsIdle(true, &transport1);
++    QTRY_COMPARE_WITH_TIMEOUT(transport1.messagesSent().size(), 2u, 2000);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++}
++
+ class FunctionWrapper : public QObject
+ {
+     Q_OBJECT
+@@ -1082,7 +1124,7 @@ void TestWebChannel::benchInitializeClients()
+ 
+         publisher->propertyUpdatesInitialized = false;
+         publisher->signalToPropertyMap.clear();
+-        publisher->signalHandler.clear();
++        publisher->signalHandlers.clear();
+     }
+ }
+ 
+@@ -1107,7 +1149,7 @@ void TestWebChannel::benchPropertyUpdates()
+             obj->change();
+         }
+ 
+-        channel.d_func()->publisher->clientIsIdle = true;
++        channel.d_func()->publisher->setClientIsIdle(true, m_dummyTransport);
+         channel.d_func()->publisher->sendPendingPropertyUpdates();
+     }
+ }
+diff --git a/qtwebchannel/tests/auto/webchannel/tst_webchannel.h b/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
+index eae21f4..dd4e690 100644
+--- a/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
++++ b/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
+@@ -348,6 +348,7 @@ private slots:
+     void testJsonToVariant();
+     void testInfiniteRecursion();
+     void testAsyncObject();
++    void testPropertyMultipleTransports();
+     void testDeletionDuringMethodInvocation_data();
+     void testDeletionDuringMethodInvocation();
+ 
+Submodule qtwebengine f328054d...38e0df6c (commits not present)
+Submodule qtwebsockets 65850954..63fb8da1:
+diff --git a/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp b/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
+index 2affdd5..95f1194 100644
+--- a/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
++++ b/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
+@@ -273,6 +273,7 @@ void QWebSocketDataProcessor::clear()
+     if (!m_pConverterState)
+         m_pConverterState = new QTextCodec::ConverterState(QTextCodec::ConvertInvalidToNull |
+                                                            QTextCodec::IgnoreHeader);
++    frame.clear();
+ }
+ 
+ /*!
+diff --git a/qtwebsockets/src/websockets/qwebsocketprotocol.cpp b/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
+index df87a93..d0465f1 100644
+--- a/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
++++ b/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
+@@ -210,7 +210,7 @@ void QWebSocketProtocol::mask(char *payload, quint64 size, quint32 maskingKey)
+                             quint8((maskingKey & 0x0000FF00u) >> 8),
+                             quint8((maskingKey & 0x000000FFu))
+                           };
+-    int i = 0;
++    quint64 i = 0;
+     while (size-- > 0)
+         *payload++ ^= mask[i++ % 4];
+ }
diff --git a/srcpkgs/qt5/template b/srcpkgs/qt5/template
index a79d25e69da8..6dddce7f3e46 100644
--- a/srcpkgs/qt5/template
+++ b/srcpkgs/qt5/template
@@ -2,11 +2,11 @@
 #
 # revbump libqtxdg after bumping patch version
 pkgname=qt5
-version=5.15.7+20221119
+version=5.15.8
+revision=1
+build_style=meta
 # commit f8c9fb304bc3e53b3aa07f962cd74e9160decccc
 # base repo: https://invent.kde.org/qt/qt/qt5
-revision=5
-build_style=meta
 hostmakedepends="cmake clang flex perl glib-devel pkg-config
  python re2c ruby which"
 makedepends="SDL2-devel Vulkan-Headers alsa-lib-devel double-conversion-devel
@@ -29,8 +29,9 @@ homepage="https://qt.io/"
 # tarball is generated with `git archive-all qt5-$version.tar.gz`
 # to keep the size smaller qtwebengine, qtwebview, qtdocgallery, qtactiveqt and qtpim
 # can be marked with the export-ignore attribute
-distfiles="https://void.johnnynator.dev/distfiles/qt5-${version}.tar.gz"
-checksum=9d57af471c78029a362276b7c99108ea009f511bb9ba6ff6cb884f6ddd255e9f
+#distfiles="https://void.johnnynator.dev/distfiles/qt5-${version}.tar.gz"
+distfiles="https://download.qt.io/archive/qt/5.15/${version}/single/qt-everywhere-opensource-src-${version}.tar.xz"
+checksum=776a9302c336671f9406a53bd30b8e36f825742b2ec44a57c08217bff0fa86b9
 python_version=2 #unverified
 replaces="qt5-doc<5.6.0 qt5-quick1<5.6.0 qt5-quick1-devel<5.6.0 qt5-webkit<5.6.0 qt5-webkit-devel<5.6.0
  qt5-enginio<5.7.1 qt5-enginio-devel<5.7.1 qt5-plugin-gtk<5.7.1 qt5-canvas3d<5.13.0"
@@ -250,7 +251,6 @@ do_configure() {
 	# opts+=" -v"
 	opts+=" -skip qtwebengine"
 	opts+=" -skip qtwebview"
-	opts+=" -skip qtdocgallery"
 	opts+=" -skip qtpim"
 	opts+=" -skip qtsystems"
 	opts+=" -skip qtspeech"

From debe9f9af2df846f64ede3a1a77d82df9f84afcf Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 076/113] qt6-multimedia: revbump for ffmpeg-6.0

---
 srcpkgs/qt6-multimedia/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-multimedia/template b/srcpkgs/qt6-multimedia/template
index c622b7c9e8fc..f7778738f6d3 100644
--- a/srcpkgs/qt6-multimedia/template
+++ b/srcpkgs/qt6-multimedia/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-multimedia'
 pkgname=qt6-multimedia
 version=6.5.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DQT_FEATURE_gstreamer=ON"
 hostmakedepends="perl qt6-declarative-host-tools pkg-config qt6-shadertools"

From c7d955f86962f540b5e5e3caffaa90171cfc7754 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 077/113] qtav: revbump for ffmpeg4-4.4.3

---
 srcpkgs/qtav/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtav/template b/srcpkgs/qtav/template
index 34c30b2c0c78..2d00ad104355 100644
--- a/srcpkgs/qtav/template
+++ b/srcpkgs/qtav/template
@@ -1,10 +1,10 @@
 # Template file for 'qtav'
 pkgname=qtav
 version=1.13.0
-revision=1
+revision=2
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel libass-devel libopenal-devel
+makedepends="ffmpeg4-devel libass-devel libopenal-devel
  libva-glx-devel libXv-devel pulseaudio-devel
  qt5-declarative-devel qt5-svg-devel
  qt5-quickcontrols"

From 15b1494b3768cb5676530133fea9d2beab961145 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 078/113] qtox: revbump for ffmpeg-6.0

---
 srcpkgs/qtox/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qtox/template b/srcpkgs/qtox/template
index 16019d7eaec9..5cea0b11b697 100644
--- a/srcpkgs/qtox/template
+++ b/srcpkgs/qtox/template
@@ -1,7 +1,7 @@
 # Template file for 'qtox'
 pkgname=qtox
 version=1.17.6
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DUPDATE_CHECK=OFF
  -DGIT_DESCRIBE=${version}

From e95021f5c8ed4662a6992001075c783441bded25 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 079/113] retroarch: revbump for ffmpeg-6.0

---
 srcpkgs/retroarch/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroarch/template b/srcpkgs/retroarch/template
index 240d3df9db00..6d0b16ae2598 100644
--- a/srcpkgs/retroarch/template
+++ b/srcpkgs/retroarch/template
@@ -1,7 +1,7 @@
 # Template file for 'retroarch'
 pkgname=retroarch
 version=1.14.0
-revision=1
+revision=2
 build_style=configure
 configure_args="--prefix=/usr --sysconfdir=/etc --enable-networking
  --enable-udev --disable-builtinflac --disable-builtinglslang

From 82bd6fcca39a35be23108889fd8f91d1a3eeddec Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 080/113] scrcpy: revbump for ffmpeg-6.0

---
 srcpkgs/scrcpy/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/scrcpy/template b/srcpkgs/scrcpy/template
index ee6e698e387f..8ada5ca4323f 100644
--- a/srcpkgs/scrcpy/template
+++ b/srcpkgs/scrcpy/template
@@ -1,7 +1,7 @@
 # Template file for 'scrcpy'
 pkgname=scrcpy
 version=2.0
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcompile_server=false
  -Dprebuilt_server=/usr/share/scrcpy/scrcpy-server-v${version}"

From 115f342c5d457ee7b1c11bcdba69bb20c5b19a2a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 081/113] spek-alternative: revbump for ffmpeg4-4.4.3

---
 srcpkgs/spek-alternative/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/spek-alternative/template b/srcpkgs/spek-alternative/template
index d65086b8f008..05246f1b8d0c 100644
--- a/srcpkgs/spek-alternative/template
+++ b/srcpkgs/spek-alternative/template
@@ -1,11 +1,11 @@
 # Template file for 'spek-alternative'
 pkgname=spek-alternative
 version=0.8.2.3
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake gettext-devel intltool libtool pkg-config wxWidgets-common"
-makedepends="ffmpeg-devel wxWidgets-gtk3-devel"
-depends="ffmpeg"
+makedepends="ffmpeg4-devel wxWidgets-gtk3-devel"
+depends="ffmpeg4"
 short_desc="Acoustic spectrum analyser"
 maintainer="Kartik Singh <kartik.ynwa@gmail.com>"
 license="GPL-3.0-or-later"

From a2e2b17b7048c14ed28cc8cb47c55dc3f9346974 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 082/113] ssr: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ssr/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/ssr/template b/srcpkgs/ssr/template
index b055b9ec0774..3448ca110eb0 100644
--- a/srcpkgs/ssr/template
+++ b/srcpkgs/ssr/template
@@ -1,11 +1,11 @@
 # Template file for 'ssr'
 pkgname=ssr
 version=0.4.4
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_QT5=ON"
 hostmakedepends="pkg-config"
-makedepends="alsa-lib-devel ffmpeg-devel glu-devel jack-devel pulseaudio-devel
+makedepends="alsa-lib-devel ffmpeg4-devel glu-devel jack-devel pulseaudio-devel
  qt5-tools-devel qt5-x11extras-devel libXinerama-devel v4l-utils-devel"
 depends="desktop-file-utils hicolor-icon-theme"
 short_desc="Simple Screen Recorder for programs and games"

From 8f6e84778bd71c232987e3459c17ba1c254f7abc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 083/113] sumo: revbump for ffmpeg-6.0

---
 srcpkgs/sumo/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/sumo/template b/srcpkgs/sumo/template
index 0f9b9ec815f5..a3fe134aa5ac 100644
--- a/srcpkgs/sumo/template
+++ b/srcpkgs/sumo/template
@@ -1,7 +1,7 @@
 # Template file for 'sumo'
 pkgname=sumo
 version=1.12.0
-revision=5
+revision=6
 build_style=cmake
 hostmakedepends="libgdal-tools pkg-config swig python3-setuptools"
 makedepends="python3-devel ffmpeg-devel fox-devel gl2ps-devel libgdal-devel

From e97e4a142b1ae6d85b0e8aeed3968aaa4af504c3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 084/113] synfig: revbump for ffmpeg-6.0 and mlt7

---
 srcpkgs/synfig/patches/ffmpeg6.patch | 71 ++++++++++++++++++++++++++++
 srcpkgs/synfig/template              |  4 +-
 2 files changed, 73 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/synfig/patches/ffmpeg6.patch

diff --git a/srcpkgs/synfig/patches/ffmpeg6.patch b/srcpkgs/synfig/patches/ffmpeg6.patch
new file mode 100644
index 000000000000..10780b42782f
--- /dev/null
+++ b/srcpkgs/synfig/patches/ffmpeg6.patch
@@ -0,0 +1,71 @@
+--- a/src/modules/mod_libavcodec/trgt_av.cpp	2022-10-25 09:14:12.000000000 -0400
++++ b/src/modules/mod_libavcodec/trgt_av.cpp	2023-05-05 21:34:17.899194559 -0400
+@@ -38,6 +41,7 @@
+ extern "C"
+ {
+ #ifdef HAVE_LIBAVFORMAT_AVFORMAT_H
++#	include <libavcodec/avcodec.h>
+ #	include <libavformat/avformat.h>
+ #elif defined(HAVE_AVFORMAT_H)
+ #	include <avformat.h>
+@@ -155,11 +156,11 @@
+     }
+ 
+ 	bool open_video_stream() {
+-		if (avcodec_open2(video_context, NULL, NULL) < 0) {
++		if (avcodec_open2(video_context, nullptr, nullptr) < 0) {
+ 			synfig::error("Target_LibAVCodec: could not open video codec");
+ 			// seems the calling of avcodec_free_context after error will cause crash
+ 			// so just forget about this context
+-			video_context = NULL;
++			video_context = nullptr;
+ 			close();
+ 			return false;
+         }
+@@ -234,15 +235,21 @@
+ 		close();
+ 
+ 		if (!av_registered) {
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 			av_register_all();
++#endif
+ 			av_registered = true;
+ 		}
+ 
+ 		// guess format
+-		AVOutputFormat *format = av_guess_format(NULL, filename.c_str(), NULL);
++#if LIBAVCODEC_VERSION_MAJOR < 59 // FFMPEG < 5.0
++		AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#else
++		const AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#endif
+ 		if (!format) {
+ 			synfig::warning("Target_LibAVCodec: unable to guess the output format, defaulting to MPEG");
+-			format = av_guess_format("mpeg", NULL, NULL);
++			format = av_guess_format("mpeg", nullptr, nullptr);
+ 		}
+ 		if (!format) {
+ 			synfig::error("Target_LibAVCodec: unable to find 'mpeg' output format");
+@@ -254,6 +261,7 @@
+ 		context = avformat_alloc_context();
+ 		assert(context);
+ 		context->oformat = format;
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 		if (filename.size() + 1 > sizeof(context->filename)) {
+ 			synfig::error(
+ 				"Target_LibAVCodec: filename too long, max length is %d, filename is '%s'",
+@@ -263,6 +271,14 @@
+ 			return false;
+ 		}
+ 		memcpy(context->filename, filename.c_str(), filename.size() + 1);
++#else
++		context->url = av_strndup(filename.c_str(), filename.size());
++		if (!context->url) {
++			synfig::error("Target_LibAVCodec: cannot allocate space for filename");
++			close();
++			return false;
++		}
++#endif
+ 
+ 		packet = av_packet_alloc();
+ 		assert(packet);
diff --git a/srcpkgs/synfig/template b/srcpkgs/synfig/template
index 5f5f5bb3f4b2..6e0d713150ae 100644
--- a/srcpkgs/synfig/template
+++ b/srcpkgs/synfig/template
@@ -6,7 +6,7 @@ revision=2
 build_style=gnu-configure
 configure_args="--with-boost-libdir=${XBPS_CROSS_BASE}/usr/lib"
 hostmakedepends="boost-build ImageMagick pkg-config intltool"
-makedepends="ETL gettext-devel libxml++-devel mlt-devel libmagick-devel
+makedepends="ETL gettext-devel libxml++-devel mlt7-devel libmagick-devel
  libmng-devel boost-build boost-devel libopenexr-devel ffmpeg-devel"
 depends="ImageMagick"
 short_desc="CLI 2D vector and timeline-based animation software"
@@ -20,7 +20,7 @@ CXXFLAGS="-std=c++11 -DHAVE_LOCALE_H=1"
 
 synfig-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision}
-	 libopenexr-devel libxml++-devel mlt-devel"
+	 libopenexr-devel libxml++-devel mlt7-devel"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/bin/synfig-config

From 991ab0062f420d22e87799f8f938f5cabc566b3c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 5 May 2023 12:57:57 -0400
Subject: [PATCH 085/113] synfigstudio: revbump for synfig mlt7

---
 srcpkgs/synfigstudio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/synfigstudio/template b/srcpkgs/synfigstudio/template
index 91349169ed2b..af1c5a296ef0 100644
--- a/srcpkgs/synfigstudio/template
+++ b/srcpkgs/synfigstudio/template
@@ -2,7 +2,7 @@
 # Should be kept in sync with 'synfig' and 'ETL'
 pkgname=synfigstudio
 version=1.4.4
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--disable-update-mimedb"
 hostmakedepends="pkg-config intltool gettext synfig"

From 3c8cb20f9e071cf42edcbfb7d5e22927b8e1384b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 086/113] tg_owt: revbump for ffmpeg-6.0

---
 srcpkgs/tg_owt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tg_owt/template b/srcpkgs/tg_owt/template
index 97d195ddb34a..551614b24956 100644
--- a/srcpkgs/tg_owt/template
+++ b/srcpkgs/tg_owt/template
@@ -1,7 +1,7 @@
 # Template file for 'tg_owt'
 pkgname=tg_owt
 version=0.0.0.20230107
-revision=1
+revision=2
 _commit=5098730b9eb6173f0b52068fe2555b7c1015123a
 _libyuv_commit=00950840d1c9bcbb3eb6ebc5aac5793e71166c8b
 _abseil_commit=8c0b94e793a66495e0b1f34a5eb26bd7dc672db0

From f177954ff763c6500bfe85bc0756130e3a3835dc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 087/113] timg: revbump for ffmpeg-6.0

---
 srcpkgs/timg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/timg/template b/srcpkgs/timg/template
index 2a2ab763d2fd..8fb4327535ef 100644
--- a/srcpkgs/timg/template
+++ b/srcpkgs/timg/template
@@ -1,7 +1,7 @@
 # Template file for 'timg'
 pkgname=timg
 version=1.4.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_OPENSLIDE_SUPPORT=off -Wno-dev"
 hostmakedepends="pkg-config git"

From ce5486be602d6c1cbe1d8ccf4ed19ce2626a17d9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 088/113] tvheadend: revbump for ffmpeg4-4.4.3

---
 srcpkgs/tvheadend/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/tvheadend/template b/srcpkgs/tvheadend/template
index e6b16d7ccf3b..46b52b6fb7f9 100644
--- a/srcpkgs/tvheadend/template
+++ b/srcpkgs/tvheadend/template
@@ -1,14 +1,14 @@
 # Template file for 'tvheadend'
 pkgname=tvheadend
 version=4.2.8
-revision=6
+revision=7
 build_style=gnu-configure
 configure_args="--enable-dvbscan --disable-ffmpeg_static
 --disable-hdhomerun_static --disable-bintray_cache --disable-libx264_static
 --disable-libx265_static --disable-libvpx_static --disable-libtheora_static
 --disable-libvorbis_static --disable-libfdkaac_static"
 hostmakedepends="gettext pkg-config python git which"
-makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg-devel"
+makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg4-devel"
 short_desc="TV streaming server"
 maintainer="lemmi <lemmi@nerd2nerd.org>"
 license="GPL-3.0-only"

From 8ddb95844a1f4849939f22842e4b9355c87763ca Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 089/113] unpaper: update to 7.0.0.

---
 srcpkgs/unpaper/template | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/srcpkgs/unpaper/template b/srcpkgs/unpaper/template
index 38ed47a58401..1ff910e722af 100644
--- a/srcpkgs/unpaper/template
+++ b/srcpkgs/unpaper/template
@@ -1,13 +1,13 @@
 # Template file for 'unpaper'
 pkgname=unpaper
-version=6.1
-revision=3
-build_style=gnu-configure
+version=7.0.0
+revision=1
+build_style=meson
+hostmakedepends="pkg-config meson libxslt"
+makedepends="ffmpeg-devel python3-Sphinx"
+short_desc="Post-processing tool for scanned sheets of paper"
 maintainer="Orphaned <orphan@voidlinux.org>"
-hostmakedepends="pkg-config libxslt"
-makedepends="ffmpeg-devel"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://www.flameeyes.eu/projects/unpaper"
-short_desc="A post-processing tool for scanned sheets of paper"
 distfiles="https://www.flameeyes.eu/files/${pkgname}-${version}.tar.xz"
-checksum=237c84f5da544b3f7709827f9f12c37c346cdf029b1128fb4633f9bafa5cb930
+checksum=2575fbbf26c22719d1cb882b59602c9900c7f747118ac130883f63419be46a80

From f37ecf33dd84e18fcbb3cfaddc54cde6bb86d7e3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 090/113] vba-m: revbump for ffmpeg-6.0

---
 srcpkgs/vba-m/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vba-m/template b/srcpkgs/vba-m/template
index ba153e0b58ca..aa6093645e97 100644
--- a/srcpkgs/vba-m/template
+++ b/srcpkgs/vba-m/template
@@ -2,7 +2,7 @@
 pkgname=vba-m
 reverts=1292_2
 version=2.1.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_GTK=TRUE -DENABLE_FFMPEG=TRUE -DENABLE_LINK=TRUE -DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="gettext pkg-config unzip zip yasm wxWidgets-gtk3-devel"

From 99d33fd3f2e7b026cb645129dc4646c58652c646 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 091/113] vice: revbump for ffmpeg4-4.4.3

---
 srcpkgs/vice/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/vice/template b/srcpkgs/vice/template
index 0924767cfcfb..5981e45149d0 100644
--- a/srcpkgs/vice/template
+++ b/srcpkgs/vice/template
@@ -1,7 +1,7 @@
 # Template file for 'vice'
 pkgname=vice
 version=3.5
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="
 	$(vopt_enable sdl2 sdlui2)
@@ -28,7 +28,7 @@ makedepends="
 	$(vopt_if gtk3 gtk+3-devel)
 	$(vopt_if gtk3 pulseaudio-devel)
 	$(vopt_if gtk3 pango-devel)
-	$(vopt_if ffmpeg ffmpeg-devel)"
+	$(vopt_if ffmpeg ffmpeg4-devel)"
 short_desc="Emulator for C64, C128, CBM-II, PET, VIC20, Plus4 and C16"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"

From 4afd6395d009b2aa2e6467967678ee203b86d911 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 092/113] waypipe: revbump for ffmpeg-6.0

---
 srcpkgs/waypipe/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waypipe/template b/srcpkgs/waypipe/template
index 5c4161900060..1a46fe27f7d8 100644
--- a/srcpkgs/waypipe/template
+++ b/srcpkgs/waypipe/template
@@ -1,7 +1,7 @@
 # Template file for 'waypipe'
 pkgname=waypipe
 version=0.8.4
-revision=1
+revision=2
 build_style=meson
 # lto is off because it causes linking errors in armv6l and armv7l (due to NEON)
 configure_args="-Dwerror=false -Dwith_dmabuf=enabled -Dwith_lz4=enabled

From a9f8f6a06b5b0bdf82fb869782ec84fcdf81714c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 093/113] wf-recorder: revbump for ffmpeg-6.0

---
 srcpkgs/wf-recorder/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/wf-recorder/template b/srcpkgs/wf-recorder/template
index e278eb001600..5d014a5f28af 100644
--- a/srcpkgs/wf-recorder/template
+++ b/srcpkgs/wf-recorder/template
@@ -1,7 +1,7 @@
 # Template file for 'wf-recorder'
 pkgname=wf-recorder
 version=0.3.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config scdoc wayland-devel"
 makedepends="wayland-protocols wayland-devel ffmpeg-devel x264-devel

From 4b120a62dd3be3871acbd6a7e7f33265e999d4ee Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 094/113] xpra: revbump for ffmpeg-6.0

---
 srcpkgs/xpra/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xpra/template b/srcpkgs/xpra/template
index 38f83283b1e5..b6e01ff0a813 100644
--- a/srcpkgs/xpra/template
+++ b/srcpkgs/xpra/template
@@ -1,7 +1,7 @@
 # Template file for 'xpra'
 pkgname=xpra
 version=4.4.4
-revision=1
+revision=2
 build_style=python3-module
 make_build_args="--without-cuda_kernels --without-cuda_rebuild"
 make_install_args="$(vopt_with docs) ${make_build_args}"

From 47eebb73665f23462caddd3878a79d491d04b803 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:07:40 -0400
Subject: [PATCH 095/113] nv-codec-headers: update to 12.0.16.0

---
 srcpkgs/nv-codec-headers/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/nv-codec-headers/template b/srcpkgs/nv-codec-headers/template
index 3d422a61e489..251e057f826f 100644
--- a/srcpkgs/nv-codec-headers/template
+++ b/srcpkgs/nv-codec-headers/template
@@ -1,6 +1,6 @@
 # Template file for 'nv-codec-headers'
 pkgname=nv-codec-headers
-version=11.1.5.1
+version=12.0.16.0
 revision=1
 build_style=gnu-makefile
 short_desc="FFmpeg version of headers required to interface with Nvidias codec APIs"
@@ -8,7 +8,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="MIT"
 homepage="http://git.videolan.org/?p=ffmpeg/nv-codec-headers.git"
 distfiles="https://github.com/FFmpeg/nv-codec-headers/archive/n${version}.tar.gz"
-checksum=d095fbd56aa93772471a323be0ebe65504a0f43f06c76a30b6d25da77b06ae9c
+checksum=2a1533b65f55f9da52956faf0627ed3b74868ac0c7f269990edd21369113b48f
 
 post_install() {
 	sed -n '4,25p' include/ffnvcodec/nvEncodeAPI.h > LICENSE

From 59b77ea70b72ec462df61b523b1066e22a6b0414 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:08:40 -0400
Subject: [PATCH 096/113] openimagedenoise: revbump for ffmpeg-6.0

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index db5ccdb055cc..cb90045afb63 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,7 +1,7 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
 version=1.4.3
-revision=1
+revision=2
 archs="x86_64*"
 build_style=cmake
 hostmakedepends="ispc python3"

From 8cfd71968cc4135e36f22395597d812ddc202b72 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:31:45 -0400
Subject: [PATCH 097/113] shotcut: revbump for mlt7-7.14.0

---
 srcpkgs/shotcut/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/shotcut/template b/srcpkgs/shotcut/template
index 99ebf2e8a5af..668383803566 100644
--- a/srcpkgs/shotcut/template
+++ b/srcpkgs/shotcut/template
@@ -1,7 +1,7 @@
 # Template file for 'shotcut'
 pkgname=shotcut
 version=22.12.21
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSHOTCUT_VERSION=${version}"
 hostmakedepends="pkg-config qt5-tools-devel"

From e6d37cfe2711d3be6785bc6f2cfb1333b4bdc168 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:30 -0400
Subject: [PATCH 098/113] shiboken2: revbump for qt5-5.15.8

---
 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch | 1 +
 srcpkgs/shiboken2/template                                 | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
 create mode 120000 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
new file mode 120000
index 000000000000..efcf3249bd88
--- /dev/null
+++ b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1 @@
+../../python3-pyside2/patches/importlib-machinery-bypass.patch
\ No newline at end of file
diff --git a/srcpkgs/shiboken2/template b/srcpkgs/shiboken2/template
index 084ecc3ba1e1..2a21998997eb 100644
--- a/srcpkgs/shiboken2/template
+++ b/srcpkgs/shiboken2/template
@@ -1,7 +1,7 @@
 # Template file for 'shiboken2'
 pkgname=shiboken2
 version=5.15.7
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/shiboken2"
 build_style=cmake

From 82ff41ffb0934cc6bd711e0e462ab6602cc274f8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:53 -0400
Subject: [PATCH 099/113] python3-pyside2: update to 5.15.8

---
 .../patches/importlib-machinery-bypass.patch      | 15 +++++++++++++++
 srcpkgs/python3-pyside2/template                  |  9 +++++----
 2 files changed, 20 insertions(+), 4 deletions(-)
 create mode 100644 srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
new file mode 100644
index 000000000000..64c429584776
--- /dev/null
+++ b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1,15 @@
+Using this prevents an error around line 220 below it.
+"AttributeError: module 'importlib' has no attribute 'machinery'"
+The old backup logic is in place and compiles without issues.
+--- a/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:09:34.688912402 -0400
++++ b/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:10:03.395529582 -0400
+@@ -170,9 +170,6 @@
+
+     # 'zipstring_sequence' comes from signature.cpp
+     zipbytes = base64.b64decode(''.join(zipstring_sequence))
+-    if sys.version_info[0] >= 3:
+-        vzip = zipfile.ZipFile(io.BytesIO(zipbytes))
+-        return sys.meta_path, EmbeddableZipImporter(vzip)
+
+     # Old version for Python 2.7, only.
+     import os
diff --git a/srcpkgs/python3-pyside2/template b/srcpkgs/python3-pyside2/template
index 50e6ff260d3b..b50e62bd215d 100644
--- a/srcpkgs/python3-pyside2/template
+++ b/srcpkgs/python3-pyside2/template
@@ -1,11 +1,12 @@
 # Template file for 'python3-pyside2'
 pkgname=python3-pyside2
-version=5.15.5
-revision=2
+version=5.15.8
+revision=1
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/pyside2"
 build_style=cmake
-configure_args="-DPYTHON_EXECUTABLE=/usr/bin/python"
+configure_args="-DPYTHON_EXECUTABLE=/usr/bin/python -DCMAKE_BUILD_TYPE=None
+ -DBUILD_TESTS=OFF"
 hostmakedepends="cmake python3 shiboken2"
 makedepends="python3-devel libshiboken2-devel qt5-devel
  qt5-multimedia-devel qt5-tools-devel qt5-plugin-mysql qt5-plugin-odbc
@@ -23,7 +24,7 @@ maintainer="yopito <pierre.bourgin@free.fr>"
 license="LGPL-3.0-or-later"
 homepage="https://wiki.qt.io/Qt_for_Python"
 distfiles="https://download.qt.io/official_releases/QtForPython/pyside2/PySide2-${version}-src/${_pkgname}.tar.xz"
-checksum=3920a4fb353300260c9bc46ff70f1fb975c5e7efa22e9d51222588928ce19b33
+checksum=23436302c8deb5b4cbc769b205d09604e38ba83b40708efccb7bd8c9af6f6b5d
 
 build_options="webengine"
 desc_option_webengine="Build Qt5 WebEngine bindings"

From 7ef04e98fb43ea64296a445fb14b2d3397915b66 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:35 -0400
Subject: [PATCH 100/113] konqueror: revbump for ffmpeg-6.0

---
 srcpkgs/konqueror/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/konqueror/template b/srcpkgs/konqueror/template
index d8d0e73a78ab..c5bdba601d3c 100644
--- a/srcpkgs/konqueror/template
+++ b/srcpkgs/konqueror/template
@@ -1,11 +1,11 @@
 # Template file for 'konqueror'
 pkgname=konqueror
 version=23.04.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DDESKTOPTOJSON_EXECUTABLE=/usr/bin/desktoptojson"
 hostmakedepends="extra-cmake-modules python3 qt5-host-tools qt5-qmake kdoctools
-kcoreaddons kconfig gettext"
+ kcoreaddons kconfig gettext"
 makedepends="qt5-devel qt5-webengine-devel qt5-declarative-devel
  qt5-webchannel-devel qt5-location-devel kcmutils-devel kdelibs4support-devel
  karchive-devel khtml-devel kdesu-devel kactivities5-devel"

From 4181b5dabbd8f57ce9b4394542bb805e3b15243f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:58 -0400
Subject: [PATCH 101/113] qt5-speech: revbump for qt5-5.15.8

---
 srcpkgs/qt5-speech/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-speech/template b/srcpkgs/qt5-speech/template
index 3ecd10d50650..2d7d4d4d2453 100644
--- a/srcpkgs/qt5-speech/template
+++ b/srcpkgs/qt5-speech/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-speech'
 pkgname=qt5-speech
 version=5.15.7
-revision=2
+revision=3
 _commit=d32f4a479d38a11f547598004b975f4356424a16
 build_style=qmake
 configure_args="-- -flite -flite-alsa -speechd"

From 0d8a29ef52711ed31b02bbc21c4fd594e7ad7d8d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 18:38:50 -0400
Subject: [PATCH 102/113] qt5-styleplugins: revbump for qt5-5.15.8

---
 srcpkgs/qt5-styleplugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-styleplugins/template b/srcpkgs/qt5-styleplugins/template
index 96ed97d12cd2..30d93660a2a4 100644
--- a/srcpkgs/qt5-styleplugins/template
+++ b/srcpkgs/qt5-styleplugins/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-styleplugins'
 pkgname=qt5-styleplugins
 version=5.0.0
-revision=20
+revision=21
 _gitrev=335dbece103e2cbf6c7cf819ab6672c2956b17b3
 build_style=qmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From 985f6c1544e86f6470c8e301be3b8f881b98dac0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 30 Apr 2023 20:22:26 -0400
Subject: [PATCH 103/113] gst-plugins-ugly1: revbump for ffmpeg-6.0

---
 srcpkgs/gst-plugins-ugly1/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-plugins-ugly1/template b/srcpkgs/gst-plugins-ugly1/template
index e254fd40f869..85ae64bc7a0a 100644
--- a/srcpkgs/gst-plugins-ugly1/template
+++ b/srcpkgs/gst-plugins-ugly1/template
@@ -1,6 +1,6 @@
 # Template file for 'gst-plugins-ugly1'
 pkgname=gst-plugins-ugly1
-version=1.20.3
+version=1.22.2
 revision=1
 build_style=meson
 configure_args="-Damrnb=disabled -Damrwbdec=disabled -Dsidplay=disabled"
@@ -15,4 +15,4 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname/1/}/${pkgname/1/}-${version}.tar.xz"
-checksum=8caa20789a09c304b49cf563d33cca9421b1875b84fcc187e4a385fa01d6aefd
+checksum=8f30f44db0bd063709bf6fbe55138e3a98af0abcb61c360f35582bbe10e80691

From 47141efb3388bb531bfeb33f11adb449c1c7a5e7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 30 Apr 2023 20:22:26 -0400
Subject: [PATCH 104/113] gst-rtsp-server: revbump for ffmpeg-6.0

---
 srcpkgs/gst-rtsp-server/template | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index 8ceea8d34b4b..980fd72cdd4c 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
-version=1.20.3
-revision=3
+version=1.22.2
+revision=2
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="glib-devel gst-plugins-bad1-devel gobject-introspection
@@ -10,5 +10,5 @@ short_desc="GStreamer multimedia graph framework - rtsp server"
 maintainer="1is7ac3 <isaac.qa13@gmail.com>"
 license="LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
-distfiles="https://gstreamer.freedesktop.org/src/gst-rtsp-server/gst-rtsp-server-${version}.tar.xz"
-checksum=ee402718be9b127f0e5e66ca4c1b4f42e4926ec93ba307b7ccca5dc6cc9794ca
+distfiles="${homepage}/src/${pkgname}/${pkgname}-${version}.tar.xz"
+checksum=2be4aecfb88710100ea7115ed0216403e8094344ebf146094271b8d4d73828bf

From c870bfa6c74ce4816ccaf36276a08e3d301bef2f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 30 Apr 2023 20:22:26 -0400
Subject: [PATCH 105/113] gst-libav: revbump for ffmpeg-6.0

---
 srcpkgs/gst-libav/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index f082bd211c65..04c39bff1489 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,6 +1,6 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
-version=1.20.3
+version=1.22.2
 revision=2
 build_style=meson
 hostmakedepends="pkg-config yasm"
@@ -11,7 +11,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.0-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname}/${pkgname}-${version}.tar.xz"
-checksum=3fedd10560fcdfaa1b6462cbf79a38c4e7b57d7f390359393fc0cef6dbf27dfe
+checksum=fcaaf9878fe8f3bc82317ef13a1558824cb68df1f8968c6797f556c5e33bcffd
 
 case "$XBPS_TARGET_MACHINE" in
 	*-musl) # Required by musl for M_SQRT1_2

From 04af70abc94db94a0a8313bd4007b2c31ceff4a3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 7 May 2023 19:48:01 -0400
Subject: [PATCH 106/113] gtk4: revbump for ffmpeg-6.0

---
 srcpkgs/gtk4/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gtk4/template b/srcpkgs/gtk4/template
index a2566d4042d3..5fafa50f6f33 100644
--- a/srcpkgs/gtk4/template
+++ b/srcpkgs/gtk4/template
@@ -1,7 +1,7 @@
 # Template file for 'gtk4'
 pkgname=gtk4
 version=4.10.3
-revision=1
+revision=2
 build_style=meson
 build_helper="gir"
 configure_args="-Dman-pages=true -Dgtk_doc=true

From 5d917a56ddf7df02be84637e463f3a541ad2ee6a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 7 May 2023 20:14:14 -0400
Subject: [PATCH 107/113] mlt7: revbump for ffmpeg-6.0

---
 srcpkgs/gst-libav/template             | 2 +-
 srcpkgs/gst-omx/template               | 4 ++--
 srcpkgs/gst-plugins-base1/template     | 4 ++--
 srcpkgs/gst-plugins-good1/template     | 4 ++--
 srcpkgs/gst1-editing-services/template | 4 ++--
 srcpkgs/gst1-python3/template          | 6 +++---
 srcpkgs/gstreamer-vaapi/template       | 4 ++--
 srcpkgs/gstreamer1/template            | 4 ++--
 srcpkgs/mlt7/template                  | 2 +-
 9 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index 04c39bff1489..8c72fc3e97ee 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.22.2
-revision=2
+revision=1
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"
diff --git a/srcpkgs/gst-omx/template b/srcpkgs/gst-omx/template
index 893535c463da..5ad54cc7b9d8 100644
--- a/srcpkgs/gst-omx/template
+++ b/srcpkgs/gst-omx/template
@@ -1,6 +1,6 @@
 # Template file for 'gst-omx'
 pkgname=gst-omx
-version=1.20.3
+version=1.22.2
 revision=1
 build_style=meson
 configure_args="-Dexamples=disabled -Dtarget=generic"
@@ -11,4 +11,4 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.1-only"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname}/${pkgname}-${version}.tar.xz"
-checksum=8db48040bb41f09edf8d17ff6d16c54888d7777ba4501c2c69f0083350ea9a15
+checksum=1b0c57f2cc4ddeec5e7f0c436e502f06665c4e93c73261855b94e04fc94337b2
diff --git a/srcpkgs/gst-plugins-base1/template b/srcpkgs/gst-plugins-base1/template
index 29e8f76bd1fe..2f20ea819849 100644
--- a/srcpkgs/gst-plugins-base1/template
+++ b/srcpkgs/gst-plugins-base1/template
@@ -1,6 +1,6 @@
 # Template file for 'gst-plugins-base1'
 pkgname=gst-plugins-base1
-version=1.20.3
+version=1.22.2
 revision=1
 build_style=meson
 build_helper="gir"
@@ -22,7 +22,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname/1/}/${pkgname/1/}-${version}.tar.xz"
-checksum=7e30b3dd81a70380ff7554f998471d6996ff76bbe6fc5447096f851e24473c9f
+checksum=eb65120c4ee79b7a153c3c1972d5c0158c2151877cc51ec7725bba5749679d49
 
 build_options="cdparanoia gir sndio wayland"
 build_options_default="cdparanoia gir wayland"
diff --git a/srcpkgs/gst-plugins-good1/template b/srcpkgs/gst-plugins-good1/template
index 1f5e620ce1fd..5d0fe1bfe284 100644
--- a/srcpkgs/gst-plugins-good1/template
+++ b/srcpkgs/gst-plugins-good1/template
@@ -1,6 +1,6 @@
 # Template file for 'gst-plugins-good1'
 pkgname=gst-plugins-good1
-version=1.20.3
+version=1.22.2
 revision=1
 build_style=meson
 configure_args="-Ddv=disabled -Ddv1394=disabled -Dshout2=disabled -Dqt5=enabled
@@ -22,7 +22,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname/1/}/${pkgname/1/}-${version}.tar.xz"
-checksum=f8f3c206bf5cdabc00953920b47b3575af0ef15e9f871c0b6966f6d0aa5868b7
+checksum=7c8cc59425f2b232f60ca7d13e56edd615da4f711e73dd01a7cffa46e6bc0cdd
 
 build_options="gtk3 wayland"
 build_options_default="gtk3 wayland"
diff --git a/srcpkgs/gst1-editing-services/template b/srcpkgs/gst1-editing-services/template
index 673b46970f24..102440f7f253 100644
--- a/srcpkgs/gst1-editing-services/template
+++ b/srcpkgs/gst1-editing-services/template
@@ -1,6 +1,6 @@
 # Template file for 'gst1-editing-services'
 pkgname=gst1-editing-services
-version=1.20.3
+version=1.22.2
 revision=1
 build_style=meson
 build_helper="gir"
@@ -12,7 +12,7 @@ maintainer="Toyam Cox <Vaelatern@gmail.com>"
 license="LGPL-2.0-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname/gst1/gst}/${pkgname/gst1/gst}-${version}.tar.xz"
-checksum=5fd896de69fbe24421eb6b0ff8d2f8b4c3cba3f3025ceacd302172f39a8abaa2
+checksum=453b1464fc3857de269a7cb0ebd966afe02171d97bef672a0b8a0a6d43e0cebf
 
 do_check() {
 	: # Tests fail in older versions as well
diff --git a/srcpkgs/gst1-python3/template b/srcpkgs/gst1-python3/template
index 3f564ac64b93..789e40f036ea 100644
--- a/srcpkgs/gst1-python3/template
+++ b/srcpkgs/gst1-python3/template
@@ -1,7 +1,7 @@
 # Template file for 'gst1-python3'
 pkgname=gst1-python3
-version=1.20.3
-revision=2
+version=1.22.2
+revision=1
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="libglib-devel python3-devel python3-gobject-devel gst-plugins-base1-devel"
@@ -11,4 +11,4 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/gst-python/gst-python-${version}.tar.xz"
-checksum=db348120eae955b8cc4de3560a7ea06e36d6e1ddbaa99a7ad96b59846601cfdc
+checksum=bef2b3d82ce4be46b775b1bb56305c1003ee01b535a53a82f9fe8924972153ad
diff --git a/srcpkgs/gstreamer-vaapi/template b/srcpkgs/gstreamer-vaapi/template
index 3cc4e057559a..0a5ee8b1ca3f 100644
--- a/srcpkgs/gstreamer-vaapi/template
+++ b/srcpkgs/gstreamer-vaapi/template
@@ -1,6 +1,6 @@
 # Template file for 'gstreamer-vaapi'
 pkgname=gstreamer-vaapi
-version=1.20.3
+version=1.22.2
 revision=1
 build_style=meson
 hostmakedepends="pkg-config"
@@ -11,7 +11,7 @@ license="LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
 changelog="https://raw.githubusercontent.com/GStreamer/gstreamer-vaapi/master/ChangeLog"
 distfiles="${homepage}/src/gstreamer-vaapi/gstreamer-vaapi-${version}.tar.xz"
-checksum=6ee99eb316abdde9ad37002915bd8c3867918f6fdc74b7cf2ac4c1ae0d690b45
+checksum=d2e642f9745f97d9f73a7f5085e7659a9a31fe209b774e6e45dae041b435df06
 
 pre_check() {
 	# Seems to need certain hardware to pass
diff --git a/srcpkgs/gstreamer1/template b/srcpkgs/gstreamer1/template
index ae8a49cb20e8..571148f2ff33 100644
--- a/srcpkgs/gstreamer1/template
+++ b/srcpkgs/gstreamer1/template
@@ -1,6 +1,6 @@
 # Template file for 'gstreamer1'
 pkgname=gstreamer1
-version=1.20.3
+version=1.22.2
 revision=1
 build_style=meson
 build_helper="gir"
@@ -16,7 +16,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.0-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/gstreamer/gstreamer-${version}.tar.xz"
-checksum=607daf64bbbd5fb18af9d17e21c0d22c4d702fffe83b23cb22d1b1af2ca23a2a
+checksum=b2afe73603921c608ba48969dbb7d743776744bfe5d8059ece241137b7f88e21
 
 pre_check() {
 	# gst_gstdatetime is known to fail according to LFS
diff --git a/srcpkgs/mlt7/template b/srcpkgs/mlt7/template
index 9fb7f60d692e..cca0eb68cfc3 100644
--- a/srcpkgs/mlt7/template
+++ b/srcpkgs/mlt7/template
@@ -1,7 +1,7 @@
 # Template file for 'mlt7'
 pkgname=mlt7
 version=7.14.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSWIG_PYTHON=ON"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which

From e8aacb7d56889828d70e483ead9ed873174b4d48 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 7 May 2023 20:15:03 -0400
Subject: [PATCH 108/113] qt6-webengine: revbump for ffmpeg-6.0

---
 srcpkgs/qt6-webengine/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-webengine/template b/srcpkgs/qt6-webengine/template
index 4e22cb6e8863..f948dc919a15 100644
--- a/srcpkgs/qt6-webengine/template
+++ b/srcpkgs/qt6-webengine/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-webengine'
 pkgname=qt6-webengine
 version=6.5.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="
  -DQT_FEATURE_webengine_system_ffmpeg=ON

From 487a5feff248cd8b4929a8b48fa94ef1d34aca08 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 7 May 2023 20:15:29 -0400
Subject: [PATCH 109/113] tracker-miners: revbump for ffmpeg-6.0

---
 srcpkgs/tracker-miners/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tracker-miners/template b/srcpkgs/tracker-miners/template
index 8c005d697fa4..a6e5aa577702 100644
--- a/srcpkgs/tracker-miners/template
+++ b/srcpkgs/tracker-miners/template
@@ -1,7 +1,7 @@
 # Template file for 'tracker-miners'
 pkgname=tracker-miners
 version=3.5.0
-revision=3
+revision=4
 build_style=meson
 build_helper=qemu
 # missing libgrss for miner_rss

From c9aa52bd159ee47984791370d724e4a0350f175d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 7 May 2023 20:20:58 -0400
Subject: [PATCH 110/113] mpd: revbump for ffmpeg-6.0

---
 srcpkgs/mpd/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpd/template b/srcpkgs/mpd/template
index 9dbd4c935acc..9f058b62df2f 100644
--- a/srcpkgs/mpd/template
+++ b/srcpkgs/mpd/template
@@ -1,7 +1,7 @@
 # Template file for 'mpd'
 pkgname=mpd
 version=0.23.13
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dopus=enabled -Dmikmod=enabled -Dneighbor=true
  -Dsoundcloud=enabled -Dpipe=true -Dtwolame=enabled -Dbzip2=enabled

From 472d17af737ec65a99418a0de8d00888ed906af0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 11 May 2023 14:05:14 -0400
Subject: [PATCH 111/113] openmw: revbump for ffmpeg-6.0

---
 srcpkgs/openmw/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openmw/template b/srcpkgs/openmw/template
index e3771c7aaf1a..3cbf20b06577 100644
--- a/srcpkgs/openmw/template
+++ b/srcpkgs/openmw/template
@@ -1,7 +1,7 @@
 # Template file for 'openmw'
 pkgname=openmw
 version=0.47.0
-revision=5
+revision=6
 build_style=cmake
 _recast_commit=e75adf86f91eb3082220085e42dda62679f9a3ea
 _bullet_tag=3.17

From c983212766f9259cc01c8356a081d5e287533ed1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 11 May 2023 14:05:39 -0400
Subject: [PATCH 112/113] freecad: revbump for qt5-webengine-5.15.13

---
 srcpkgs/freecad/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/freecad/template b/srcpkgs/freecad/template
index e301f32d3540..a4a3f5f76b29 100644
--- a/srcpkgs/freecad/template
+++ b/srcpkgs/freecad/template
@@ -1,7 +1,7 @@
 # Template file for 'freecad'
 pkgname=freecad
 version=0.20.2
-revision=4
+revision=5
 build_style=cmake
 
 _inst_prefix=/usr/lib/${pkgname}

From 7b3b330c64b1e66e267d6de69abfb045c4679839 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 21 May 2023 12:44:11 -0400
Subject: [PATCH 113/113] electron24: revbump for ffmpeg-6.0

---
 srcpkgs/electron24/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron24/template b/srcpkgs/electron24/template
index bdaa56adc8a6..ff3d5e3ef381 100644
--- a/srcpkgs/electron24/template
+++ b/srcpkgs/electron24/template
@@ -1,7 +1,7 @@
 # Template file for 'electron24'
 pkgname=electron24
 version=24.3.0
-revision=1
+revision=2
 _nodever=18.14.0
 _chromiumver=112.0.5615.165
 archs="x86_64* aarch64*"

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (7 preceding siblings ...)
  2023-05-29  1:43 ` zlice
@ 2023-06-04 15:47 ` zlice
  2023-06-10  5:04 ` zlice
                   ` (88 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2023-06-04 15:47 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 3400 bytes --]

There is an updated pull request by zlice against master on the void-packages repository

https://github.com/zlice/void-packages ffmpeg6-split
https://github.com/void-linux/void-packages/pull/43761

ffmpeg6 split
[ci skip]


#### Testing the changes

- I tested the changes in this PR: **YES**

main testing has been vaapi in Firefox Nightly and enc/dec in Shotcut on Intel A770

#### New package

- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**

#### Local build testing

- I built this PR locally for my native architecture, **x86_64**

#### Discussion

Continuation of https://github.com/void-linux/void-packages/pull/36315

`libavresample` is deprecated, but marked as a dependency when trying to build other packages and install `ffmpeg`(6). I think the right way to handle this is make a meta package and the add to removals?


##### Commit naming / misc

~~Commits are 'dirty' right now, running with [gstreamer 1.22.1 updates](https://github.com/void-linux/void-packages/pull/42861) and [Intel OpenCL](https://github.com/void-linux/void-packages/pull/43084). This will also make [intel packages pr](https://github.com/void-linux/void-packages/pull/41132) obsolete.~~ (see Requirements below)

Maintainer for previous ffmpeg(4) was orphaned, I can put my name in there if that matters, though I don't exactly see myself keeping up on ffmpeg.

This updates QT5 which looks like it is usually hosted by Johnny. Not sure if there's any reason to stay there or these sources are fine.

##### STILL FFMPEG4

These are a mix of emulators, games and/or older packages.

- attract (multiple patches in master)
- audacity (https://github.com/audacity/audacity/issues/2305 and https://sourceforge.net/p/portmedia/wiki/portsmf/ is 'beta')
- ccextractor (master patches? no release)
- vice
- kodi
- mlt (only dep left is flowblade)
- ~~synfig (mlt)~~ (work with mlt7, bump synfigstudio)
- tvheadend
- ssr
- spek-alternative
- ppsspp
- olive
- moc
- mediastreamer
- libextractor
- idjc
- hedgewars
- ~~ffmpegthumbnailer~~ (patches for moviedecoder.xxx files)
- ~~ffmpegthumbs~~ (latest compiles)
- deadbeef
- omxplayer
- qtav (fork has ffmpeg 5 patch - https://github.com/cmguo/QtAV)
- `vlc` (vlc4 will support ffmpeg5, there's a patch to build 3.x with ffmpeg5 but it will lack vaapi)
- `osg` (OpenSceneGraph plus `xine-lib`)


##### HAVE NOT BUILT YET

- omxplayer (rpi only? ffmpeg4)
- kodi (big, but ffmpeg4)


##### UPDATED (for ffmpeg6)

- ~~blender: update to 3.5.1~~ ~~will be revbump with~~ https://github.com/void-linux/void-packages/pull/43992
- unpaper: update to 7.0.0.
- guvcview: update to 2.0.8.
- qt5: update to 5.15.8
- qt5-webengine: update to 5.18.13
- shiboken2: revbump for qt5.15.8 (patch)
- python3-pyside2: update to 5.15.8 (patch)


##### Requirements

- [gstreamer 1.22.2](https://github.com/void-linux/void-packages/pull/42861) - a few packages use ffmpeg-devel and require a revbump

- [Intel Packages](https://github.com/void-linux/void-packages/pull/41132) - ffmpeg4 uses different libraries than 6 (libmfx / Intel-MediaSDK vs only oneVPL that Intel is moving to), both are included here

A patch file from https://github.com/void-linux/void-packages/pull/43761.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ffmpeg6-split-43761.patch --]
[-- Type: text/x-diff, Size: 787729 bytes --]

From d88c83a0c3982f65b3086384b9e361fef226b417 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:55:46 -0400
Subject: [PATCH 001/115] ffmpeg: update to 6.0.

---
 common/shlibs                                 | 26 +++++---
 srcpkgs/ffmpeg/files/altivec.patch            | 60 -------------------
 .../patches/armv5tel-floating-point.patch     | 18 ------
 .../workaround-mesa-readeon-vaapi-bug.patch   | 28 ---------
 srcpkgs/ffmpeg/template                       | 38 +++++-------
 5 files changed, 32 insertions(+), 138 deletions(-)
 delete mode 100644 srcpkgs/ffmpeg/files/altivec.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch

diff --git a/common/shlibs b/common/shlibs
index 16eefd439b2b..93354b4b6122 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -390,15 +390,23 @@ libid3tag.so.0 libid3tag-0.15.1b_1
 libgif.so.7 giflib-5.1.0_1
 libImlib2.so.1 imlib2-1.4.2_1
 libmp3lame.so.0 lame-3.98.2_1
-libavdevice.so.58 libavdevice-4.0_1
-libavformat.so.58 libavformat-4.0_1
-libswscale.so.5 libswscale-4.0_1
-libswresample.so.3 libswresample-4.0_1
-libavresample.so.4 libavresample-4.0_1
-libpostproc.so.55 libpostproc-4.0_1
-libavcodec.so.58 libavcodec-4.0_1
-libavutil.so.56 libavutil-4.0_1
-libavfilter.so.7 libavfilter-4.0_1
+libavdevice.so.60 libavdevice-6.0_1
+libavformat.so.60 libavformat-6.0_1
+libswscale.so.7 libswscale-6.0_1
+libswresample.so.4 libswresample-6.0_1
+libpostproc.so.57 libpostproc-6.0_1
+libavcodec.so.60 libavcodec-6.0_1
+libavutil.so.58 libavutil-6.0_1
+libavfilter.so.9 libavfilter-6.0_1
+libavdevice.so.58 libavdevice4-4.0_1
+libavformat.so.58 libavformat4-4.0_1
+libswscale.so.5 libswscale4-4.0_1
+libswresample.so.3 libswresample4-4.0_1
+libavresample.so.4 libavresample4-4.0_1
+libpostproc.so.55 libpostproc4-4.0_1
+libavcodec.so.58 libavcodec4-4.0_1
+libavutil.so.56 libavutil4-4.0_1
+libavfilter.so.7 libavfilter4-4.0_1
 libSDL-1.2.so.0 SDL-1.2.14_1
 libSDL_image-1.2.so.0 SDL_image-1.2.10_1
 libx264.so.157 x264-20190507.2245_1
diff --git a/srcpkgs/ffmpeg/files/altivec.patch b/srcpkgs/ffmpeg/files/altivec.patch
deleted file mode 100644
index 9c5720046332..000000000000
--- a/srcpkgs/ffmpeg/files/altivec.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-revert some altivec specific change on all ppc* except ppc64le*
-
-q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
-conditionally, for ppc* but not ppc64le* (the new code is valid for
-POWER8 VSX which LE targets as a baseline but not BE)"
-
-
-This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
----
- libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
- 1 file changed, 20 insertions(+), 4 deletions(-)
-
-diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
-index 536545293d..c1e2852adb 100644
---- a/libswscale/ppc/yuv2rgb_altivec.c
-+++ b/libswscale/ppc/yuv2rgb_altivec.c
-@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-     vector signed short R1, G1, B1;                                           \
-     vector unsigned char R, G, B;                                             \
-                                                                               \
-+    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
-+    vector unsigned char align_perm;                                          \
-+                                                                              \
-     vector signed short lCY       = c->CY;                                    \
-     vector signed short lOY       = c->OY;                                    \
-     vector signed short lCRV      = c->CRV;                                   \
-@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
-                                                                               \
-         for (j = 0; j < w / 16; j++) {                                        \
--            y0 = vec_xl(0, y1i);                                              \
-+            y1ivP = (const vector unsigned char *) y1i;                       \
-+            y2ivP = (const vector unsigned char *) y2i;                       \
-+            uivP  = (const vector unsigned char *) ui;                        \
-+            vivP  = (const vector unsigned char *) vi;                        \
-+                                                                              \
-+            align_perm = vec_lvsl(0, y1i);                                    \
-+            y0 = (vector unsigned char)                                       \
-+                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
-                                                                               \
--            y1 = vec_xl(0, y2i);                                              \
-+            align_perm = vec_lvsl(0, y2i);                                    \
-+            y1 = (vector unsigned char)                                       \
-+                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
-                                                                               \
--            u = (vector signed char) vec_xl(0, ui);                           \
-+            align_perm = vec_lvsl(0, ui);                                     \
-+            u = (vector signed char)                                          \
-+                    vec_perm(uivP[0], uivP[1], align_perm);                   \
-                                                                               \
--            v = (vector signed char) vec_xl(0, vi);                           \
-+            align_perm = vec_lvsl(0, vi);                                     \
-+            v = (vector signed char)                                          \
-+                    vec_perm(vivP[0], vivP[1], align_perm);                   \
-                                                                               \
-             u = (vector signed char)                                          \
-                     vec_sub(u,                                                \
--- 
-2.27.0
-
diff --git a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
deleted file mode 100644
index 9a55178c74f0..000000000000
--- a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
-+++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
-@@ -39,6 +39,15 @@
- #endif
- #include <fenv.h>
- 
-+#if (FE_ALL_EXCEPT == 0)
-+/* E.g. ARM soft float does not define these */
-+#define FE_INVALID    0
-+#define FE_DIVBYZERO  0
-+#define FE_OVERFLOW   0
-+#define FE_UNDERFLOW  0
-+#define FE_INEXACT    0
-+#endif
-+
- #if CONFIG_LIBFONTCONFIG
- #include <fontconfig/fontconfig.h>
- #endif
diff --git a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
deleted file mode 100644
index 00e3f68a415b..000000000000
--- a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
-From: Rainer Hochecker <fernetmenta@online.de>
-Date: Sat, 26 Jan 2019 19:48:35 +0100
-Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
-
-This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
-It was hit frequently when watching h264 channels received via DVB-X.
-Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
----
- libavcodec/vaapi_h264.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
-index 5854587a255..f12fdc457a4 100644
---- a/libavcodec/vaapi_h264.c
-+++ b/libavcodec/vaapi_h264.c
-@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
-     H264SliceContext *sl = &h->slice_ctx[0];
-     int ret;
- 
-+    if (pic->nb_slices == 0) {
-+        ret = AVERROR_INVALIDDATA;
-+        goto finish;
-+    }
-+
-     ret = ff_vaapi_decode_issue(avctx, pic);
-     if (ret < 0)
-         goto finish;
diff --git a/srcpkgs/ffmpeg/template b/srcpkgs/ffmpeg/template
index df4179d1963a..f742082bb520 100644
--- a/srcpkgs/ffmpeg/template
+++ b/srcpkgs/ffmpeg/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpeg'
 # audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
 pkgname=ffmpeg
-version=4.4.4
+version=6.0
 revision=1
 short_desc="Decoding, encoding and streaming software"
 maintainer="Orphaned <orphan@voidlinux.org>"
@@ -9,7 +9,7 @@ license="GPL-3.0-or-later"
 homepage="https://www.ffmpeg.org"
 changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
 distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
-checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+checksum=57be87c22d9b49c112b6d24bc67d42508660e6b718b3db89c44e47e289137082
 
 hostmakedepends="pkg-config perl"
 makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
@@ -26,12 +26,13 @@ makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-deve
  $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
  $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
  $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
- $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers Vulkan-Tools Vulkan-ValidationLayers')
+ $(vopt_if onevpl 'onevpl onevpl-devel')
  $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
 depends="ffplay>=${version}_${revision}"
 
 build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
- dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec onevpl"
 build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
 desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
 desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
@@ -39,10 +40,8 @@ desc_option_sofa="Enable support for AES SOFA"
 desc_option_webp="Enable support for WebP"
 
 case "$XBPS_TARGET_MACHINE" in
-	i686*|x86_64*)
-		hostmakedepends+=" nasm"
-		build_options_default+=" vaapi vdpau nvenc nvdec"
-		;;
+	i686*) build_options_default+=" vaapi vdpau nvenc nvdec";;
+	x86_64*) build_options_default+=" vaapi vdpau nvenc nvdec onevpl";;
 	ppc64*) build_options_default+=" vaapi vdpau";;
 	mips*) CFLAGS="-mnan=legacy";;
 esac
@@ -117,18 +116,19 @@ do_configure() {
 		$(vopt_enable x265 libx265) \
 		$(vopt_enable v4l2 libv4l2) \
 		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
-		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		--enable-libbs2b --enable-libvidstab \
 		$(vopt_enable dav1d libdav1d) \
 		$(vopt_enable zimg libzimg) \
 		$(vopt_enable webp libwebp) \
 		$(vopt_enable sofa libmysofa) \
 		$(vopt_enable vulkan) \
+		$(vopt_enable onevpl libvpl) \
 		$(vopt_enable drm libdrm) \
 		$(vopt_enable svtav1 libsvtav1) \
 		$(vopt_enable srt libsrt) \
 		$(vopt_enable rist librist) \
-		$(vopt_if nvenc '--enable-nvenc') \
-		$(vopt_if nvdec '--enable-nvdec')
+		$(vopt_enable nvenc nvenc) \
+		$(vopt_enable nvdec nvdec)
 }
 
 do_build() {
@@ -155,10 +155,8 @@ libavdevice_package() {
 }
 
 libavresample_package() {
-	short_desc="FFmpeg audio resampling library"
-	pkg_install() {
-		vmove "usr/lib/libavresample.so.*"
-	}
+	short_desc="Package deprecated, removal needed"
+	build_style=meta
 }
 
 libavformat_package() {
@@ -212,15 +210,9 @@ ffmpeg-devel_package() {
 		libavfilter>=${version}_${revision}
 		libpostproc>=${version}_${revision}
 		libswscale>=${version}_${revision}
-		libswresample>=${version}_${revision}
-		libavresample>=${version}_${revision}"
+		libswresample>=${version}_${revision}"
 	short_desc+=" - development files"
-
-	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
-		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
-		nostrip_files="/usr/lib/libavfilter.a"
-	fi
-
+	conflicts="ffmpeg4-devel"
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig

From 1db6c0f16c38d60304a3ff87be45ea1e1ff72aa6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:56:22 -0400
Subject: [PATCH 002/115] New package: ffmpeg4-4.4.4.

---
 srcpkgs/ffmpeg4-devel                         |   1 +
 srcpkgs/ffmpeg4/files/altivec.patch           |  60 +++++
 .../patches/armv5tel-floating-point.patch     |  18 ++
 .../workaround-mesa-readeon-vaapi-bug.patch   |  28 +++
 srcpkgs/ffmpeg4/template                      | 238 ++++++++++++++++++
 srcpkgs/libavcodec4                           |   1 +
 srcpkgs/libavdevice4                          |   1 +
 srcpkgs/libavfilter4                          |   1 +
 srcpkgs/libavformat4                          |   1 +
 srcpkgs/libavresample4                        |   1 +
 srcpkgs/libavutil4                            |   1 +
 srcpkgs/libpostproc4                          |   1 +
 srcpkgs/libswresample4                        |   1 +
 srcpkgs/libswscale4                           |   1 +
 14 files changed, 354 insertions(+)
 create mode 120000 srcpkgs/ffmpeg4-devel
 create mode 100644 srcpkgs/ffmpeg4/files/altivec.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
 create mode 100644 srcpkgs/ffmpeg4/template
 create mode 120000 srcpkgs/libavcodec4
 create mode 120000 srcpkgs/libavdevice4
 create mode 120000 srcpkgs/libavfilter4
 create mode 120000 srcpkgs/libavformat4
 create mode 120000 srcpkgs/libavresample4
 create mode 120000 srcpkgs/libavutil4
 create mode 120000 srcpkgs/libpostproc4
 create mode 120000 srcpkgs/libswresample4
 create mode 120000 srcpkgs/libswscale4

diff --git a/srcpkgs/ffmpeg4-devel b/srcpkgs/ffmpeg4-devel
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/ffmpeg4-devel
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/ffmpeg4/files/altivec.patch b/srcpkgs/ffmpeg4/files/altivec.patch
new file mode 100644
index 000000000000..9c5720046332
--- /dev/null
+++ b/srcpkgs/ffmpeg4/files/altivec.patch
@@ -0,0 +1,60 @@
+revert some altivec specific change on all ppc* except ppc64le*
+
+q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
+conditionally, for ppc* but not ppc64le* (the new code is valid for
+POWER8 VSX which LE targets as a baseline but not BE)"
+
+
+This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
+---
+ libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
+ 1 file changed, 20 insertions(+), 4 deletions(-)
+
+diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
+index 536545293d..c1e2852adb 100644
+--- a/libswscale/ppc/yuv2rgb_altivec.c
++++ b/libswscale/ppc/yuv2rgb_altivec.c
+@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+     vector signed short R1, G1, B1;                                           \
+     vector unsigned char R, G, B;                                             \
+                                                                               \
++    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
++    vector unsigned char align_perm;                                          \
++                                                                              \
+     vector signed short lCY       = c->CY;                                    \
+     vector signed short lOY       = c->OY;                                    \
+     vector signed short lCRV      = c->CRV;                                   \
+@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
+                                                                               \
+         for (j = 0; j < w / 16; j++) {                                        \
+-            y0 = vec_xl(0, y1i);                                              \
++            y1ivP = (const vector unsigned char *) y1i;                       \
++            y2ivP = (const vector unsigned char *) y2i;                       \
++            uivP  = (const vector unsigned char *) ui;                        \
++            vivP  = (const vector unsigned char *) vi;                        \
++                                                                              \
++            align_perm = vec_lvsl(0, y1i);                                    \
++            y0 = (vector unsigned char)                                       \
++                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
+                                                                               \
+-            y1 = vec_xl(0, y2i);                                              \
++            align_perm = vec_lvsl(0, y2i);                                    \
++            y1 = (vector unsigned char)                                       \
++                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
+                                                                               \
+-            u = (vector signed char) vec_xl(0, ui);                           \
++            align_perm = vec_lvsl(0, ui);                                     \
++            u = (vector signed char)                                          \
++                    vec_perm(uivP[0], uivP[1], align_perm);                   \
+                                                                               \
+-            v = (vector signed char) vec_xl(0, vi);                           \
++            align_perm = vec_lvsl(0, vi);                                     \
++            v = (vector signed char)                                          \
++                    vec_perm(vivP[0], vivP[1], align_perm);                   \
+                                                                               \
+             u = (vector signed char)                                          \
+                     vec_sub(u,                                                \
+-- 
+2.27.0
+
diff --git a/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
new file mode 100644
index 000000000000..9a55178c74f0
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
@@ -0,0 +1,18 @@
+--- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
++++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
+@@ -39,6 +39,15 @@
+ #endif
+ #include <fenv.h>
+ 
++#if (FE_ALL_EXCEPT == 0)
++/* E.g. ARM soft float does not define these */
++#define FE_INVALID    0
++#define FE_DIVBYZERO  0
++#define FE_OVERFLOW   0
++#define FE_UNDERFLOW  0
++#define FE_INEXACT    0
++#endif
++
+ #if CONFIG_LIBFONTCONFIG
+ #include <fontconfig/fontconfig.h>
+ #endif
diff --git a/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
new file mode 100644
index 000000000000..00e3f68a415b
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
@@ -0,0 +1,28 @@
+From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
+From: Rainer Hochecker <fernetmenta@online.de>
+Date: Sat, 26 Jan 2019 19:48:35 +0100
+Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
+
+This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
+It was hit frequently when watching h264 channels received via DVB-X.
+Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
+---
+ libavcodec/vaapi_h264.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
+index 5854587a255..f12fdc457a4 100644
+--- a/libavcodec/vaapi_h264.c
++++ b/libavcodec/vaapi_h264.c
+@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
+     H264SliceContext *sl = &h->slice_ctx[0];
+     int ret;
+ 
++    if (pic->nb_slices == 0) {
++        ret = AVERROR_INVALIDDATA;
++        goto finish;
++    }
++
+     ret = ff_vaapi_decode_issue(avctx, pic);
+     if (ret < 0)
+         goto finish;
diff --git a/srcpkgs/ffmpeg4/template b/srcpkgs/ffmpeg4/template
new file mode 100644
index 000000000000..5228c7df08fb
--- /dev/null
+++ b/srcpkgs/ffmpeg4/template
@@ -0,0 +1,238 @@
+# Template file for 'ffmpeg4'
+# audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
+pkgname=ffmpeg4
+version=4.4.4
+revision=1
+short_desc="Decoding, encoding and streaming software - ffmpeg4 libraries only"
+maintainer="Orphaned <orphan@voidlinux.org>"
+license="GPL-3.0-or-later"
+homepage="https://www.ffmpeg.org"
+changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
+distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
+checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+
+hostmakedepends="pkg-config perl"
+makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
+ libXext-devel libXvMC-devel libxcb-devel lame-devel libtheora-devel
+ libvorbis-devel x264-devel xvidcore-devel jack-devel SDL2-devel
+ libcdio-paranoia-devel librtmp-devel libmodplug-devel gnutls-devel
+ speex-devel celt-devel harfbuzz-devel libass-devel opus-devel ocl-icd-devel
+ libbs2b-devel libvidstab-devel $(vopt_if pulseaudio pulseaudio-devel)
+ $(vopt_if vaapi libva-devel) $(vopt_if vdpau libvdpau-devel)
+ $(vopt_if x265 x265-devel) $(vopt_if v4l2 v4l-utils-devel)
+ $(vopt_if fdk_aac fdk-aac-devel) $(vopt_if vpx libvpx-devel)
+ $(vopt_if aom libaom-devel) $(vopt_if sndio sndio-devel)
+ $(vopt_if dav1d libdav1d-devel) $(vopt_if zimg zimg-devel)
+ $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
+ $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
+ $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if mfx 'libmfx libmfx-devel')
+ $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
+
+build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec mfx"
+build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
+
+desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
+desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
+desc_option_sofa="Enable support for AES SOFA"
+desc_option_webp="Enable support for WebP"
+
+case "$XBPS_TARGET_MACHINE" in
+	i686*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau nvenc nvdec"
+			;;
+	x86_64*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau mfx nvenc nvdec"
+			;;
+	ppc64*) build_options_default+=" vaapi vdpau";;
+	mips*) CFLAGS="-mnan=legacy";;
+esac
+
+if [ "$XBPS_TARGET_WORDSIZE" != "32" ]; then
+	build_options_default+=" svtav1"
+fi
+
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+fi
+
+_apply_patch() {
+	local args="$1" pname="$(basename $2)"
+
+	if [ ! -f ".${pname}_done" ]; then
+		patch -N $args -i $2
+		touch .${pname}_done
+	fi
+}
+
+post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64le*) ;;
+		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
+	esac
+}
+
+do_configure() {
+	# Fix gcc on x86_64-musl only
+	if [ "$XBPS_TARGET_MACHINE" = "x86_64-musl" ]; then
+		vsed -i configure -e "s;_cflags_speed='-O3';_cflags_speed='-O2';"
+	fi
+
+	if [ "$CROSS_BUILD" ]; then
+		case "$XBPS_TARGET_MACHINE" in
+			arm*) _arch="arm";;
+			aarch64*) _arch="aarch64";;
+			mips*) _arch="mips";;
+			ppc64*) _arch="ppc64";;
+			ppc*) _arch="ppc";;
+			*) _arch="${XBPS_TARGET_MACHINE%%-musl}";;
+		esac
+
+		_args+=" --enable-cross-compile
+			--sysroot=$XBPS_CROSS_BASE
+			--cross-prefix=${XBPS_CROSS_TRIPLET}-
+			--target-os=linux --arch=${_arch}"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc|ppc-musl) _args+=" --disable-altivec";;
+	esac
+
+	if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+		_args+=" --extra-libs=-latomic"
+	fi
+
+	./configure --prefix=/usr --disable-debug --enable-gpl --enable-gnutls \
+		--disable-stripping \
+		--enable-libcdio --enable-version3 --enable-runtime-cpudetect \
+		--enable-libmp3lame --enable-libvorbis --enable-libxvid \
+		--enable-libx264 $(vopt_enable vpx libvpx) --enable-libtheora \
+		--enable-shared --enable-static --enable-libxcb \
+		$(vopt_enable pulseaudio libpulse) --enable-libfreetype --enable-libmodplug \
+		--enable-libspeex --enable-libcelt --enable-libass \
+		--enable-libopus --enable-librtmp --enable-libjack \
+		$(vopt_if fdk_aac '--enable-nonfree --enable-libfdk-aac') \
+		--disable-libopencore_amrnb --disable-libopencore_amrwb \
+		--disable-libopenjpeg \
+		--enable-postproc --enable-opencl ${_args} \
+		$(vopt_enable x265 libx265) \
+		$(vopt_enable v4l2 libv4l2) \
+		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
+		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		$(vopt_enable dav1d libdav1d) \
+		$(vopt_enable zimg libzimg) \
+		$(vopt_enable webp libwebp) \
+		$(vopt_enable sofa libmysofa) \
+		$(vopt_enable vulkan) \
+		$(vopt_enable drm libdrm) \
+		$(vopt_enable svtav1 libsvtav1) \
+		$(vopt_enable srt libsrt) \
+		$(vopt_enable rist librist) \
+		$(vopt_enable mfx libmfx) \
+		$(vopt_if nvenc '--enable-nvenc') \
+		$(vopt_if nvdec '--enable-nvdec')
+}
+
+do_build() {
+	make ${makejobs}
+	make doc/ff{mpeg,play}.1
+}
+
+do_install() {
+	make DESTDIR=${DESTDIR} install install-man
+	rm -rf ${DESTDIR}/usr/bin
+}
+
+libavcodec4_package() {
+	short_desc="FFmpeg codec library"
+	pkg_install() {
+		vmove "usr/lib/libavcodec.so.*"
+	}
+}
+
+libavdevice4_package() {
+	short_desc="FFmpeg device handling library"
+	pkg_install() {
+		vmove "usr/lib/libavdevice.so.*"
+	}
+}
+
+libavresample4_package() {
+	short_desc="FFmpeg audio resampling library"
+	pkg_install() {
+		vmove "usr/lib/libavresample.so.*"
+	}
+}
+
+libavformat4_package() {
+	short_desc="FFmpeg file format library"
+	pkg_install() {
+		vmove "usr/lib/libavformat.so.*"
+	}
+}
+
+libavutil4_package() {
+	short_desc="FFmpeg utility library"
+	pkg_install() {
+		vmove "usr/lib/libavutil.so.*"
+	}
+}
+
+libavfilter4_package() {
+	short_desc="FFmpeg audio/video filter library"
+	pkg_install() {
+		vmove "usr/lib/libavfilter.so.*"
+	}
+}
+
+libpostproc4_package() {
+	short_desc="FFmpeg video postprocessing library"
+	pkg_install() {
+		vmove "usr/lib/libpostproc.so.*"
+	}
+}
+
+libswscale4_package() {
+	short_desc="FFmpeg video scaling library"
+	pkg_install() {
+		vmove "usr/lib/libswscale.so.*"
+	}
+}
+
+libswresample4_package() {
+	short_desc="FFmpeg video resampling library"
+	pkg_install() {
+		vmove "usr/lib/libswresample.so.*"
+	}
+}
+
+ffmpeg4-devel_package() {
+	depends="
+		libavcodec4>=${version}_${revision}
+		libavdevice4>=${version}_${revision}
+		libavformat4>=${version}_${revision}
+		libavutil4>=${version}_${revision}
+		libavfilter4>=${version}_${revision}
+		libpostproc4>=${version}_${revision}
+		libswscale4>=${version}_${revision}
+		libswresample4>=${version}_${revision}
+		libavresample4>=${version}_${revision}"
+	short_desc+=" - development files"
+	conflicts="ffmpeg-devel"
+	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
+		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
+		nostrip_files="/usr/lib/libavfilter.a"
+	fi
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.a"
+		vmove "usr/lib/*.so"
+		vmove usr/share/ffmpeg/examples
+		vmove usr/share/man/man3
+	}
+}
diff --git a/srcpkgs/libavcodec4 b/srcpkgs/libavcodec4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavcodec4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavdevice4 b/srcpkgs/libavdevice4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavdevice4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavfilter4 b/srcpkgs/libavfilter4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavfilter4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavformat4 b/srcpkgs/libavformat4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavformat4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavresample4 b/srcpkgs/libavresample4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavutil4 b/srcpkgs/libavutil4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavutil4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libpostproc4 b/srcpkgs/libpostproc4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libpostproc4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswresample4 b/srcpkgs/libswresample4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libswresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswscale4 b/srcpkgs/libswscale4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libswscale4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file

From bdb60bfe02782dd4a049f8aa1be474aece38a621 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:04 -0400
Subject: [PATCH 003/115] opencv: update to 4.7.0.

---
 common/shlibs           | 104 ++++++++++++++++++++--------------------
 srcpkgs/opencv/template |   8 ++--
 2 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index 93354b4b6122..b570535ed1ef 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2138,58 +2138,58 @@ libcapstone.so.4 capstone-4.0_1
 libhavege.so.2 libhaveged-1.9.11_1
 libnih.so.1 libnih-1.0.3_1
 libnih-dbus.so.1 libnih-1.0.3_1
-libopencv_quality.so.406 libopencv-4.6.0_1
-libopencv_reg.so.406 libopencv-4.6.0_1
-libopencv_surface_matching.so.406 libopencv-4.6.0_1
-libopencv_xphoto.so.406 libopencv-4.6.0_1
-libopencv_freetype.so.406 libopencv-4.6.0_1
-libopencv_fuzzy.so.406 libopencv-4.6.0_1
-libopencv_hfs.so.406 libopencv-4.6.0_1
-libopencv_img_hash.so.406 libopencv-4.6.0_1
-libopencv_line_descriptor.so.406 libopencv-4.6.0_1
-libopencv_saliency.so.406 libopencv-4.6.0_1
-libopencv_structured_light.so.406 libopencv-4.6.0_1
-libopencv_aruco.so.406 libopencv-4.6.0_1
-libopencv_bgsegm.so.406 libopencv-4.6.0_1
-libopencv_bioinspired.so.406 libopencv-4.6.0_1
-libopencv_ccalib.so.406 libopencv-4.6.0_1
-libopencv_face.so.406 libopencv-4.6.0_1
-libopencv_tracking.so.406 libopencv-4.6.0_1
-libopencv_xfeatures2d.so.406 libopencv-4.6.0_1
-libopencv_optflow.so.406 libopencv-4.6.0_1
-libopencv_ximgproc.so.406 libopencv-4.6.0_1
-libopencv_plot.so.406 libopencv-4.6.0_1
-libopencv_text.so.406 libopencv-4.6.0_1
-libopencv_ml.so.406 libopencv-4.6.0_1
-libopencv_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn.so.406 libopencv-4.6.0_1
-libopencv_shape.so.406 libopencv-4.6.0_1
-libopencv_stitching.so.406 libopencv-4.6.0_1
-libopencv_photo.so.406 libopencv-4.6.0_1
-libopencv_video.so.406 libopencv-4.6.0_1
-libopencv_calib3d.so.406 libopencv-4.6.0_1
-libopencv_features2d.so.406 libopencv-4.6.0_1
-libopencv_flann.so.406 libopencv-4.6.0_1
-libopencv_highgui.so.406 libopencv-4.6.0_1
-libopencv_videoio.so.406 libopencv-4.6.0_1
-libopencv_imgcodecs.so.406 libopencv-4.6.0_1
-libopencv_imgproc.so.406 libopencv-4.6.0_1
-libopencv_core.so.406 libopencv-4.6.0_1
-libopencv_superres.so.406 libopencv-4.6.0_1
-libopencv_videostab.so.406 libopencv-4.6.0_1
-libopencv_gapi.so.406 libopencv-4.6.0_1
-libopencv_xobjdetect.so.406 libopencv-4.6.0_1
-libopencv_datasets.so.406 libopencv-4.6.0_1
-libopencv_dnn_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn_superres.so.406 libopencv-4.6.0_1
-libopencv_dpm.so.406 libopencv-4.6.0_1
-libopencv_phase_unwrapping.so.406 libopencv-4.6.0_1
-libopencv_stereo.so.406 libopencv-4.6.0_1
-libopencv_rapid.so.406 libopencv-4.6.0_1
-libopencv_intensity_transform.so.406 libopencv-4.6.0_1
-libopencv_alphamat.so.406 libopencv-4.6.0_1
-libopencv_barcode.so.406 libopencv-4.6.0_1
-libopencv_mcc.so.406 libopencv-4.6.0_1
+libopencv_quality.so.407 libopencv-4.7.0_1
+libopencv_reg.so.407 libopencv-4.7.0_1
+libopencv_surface_matching.so.407 libopencv-4.7.0_1
+libopencv_xphoto.so.407 libopencv-4.7.0_1
+libopencv_freetype.so.407 libopencv-4.7.0_1
+libopencv_fuzzy.so.407 libopencv-4.7.0_1
+libopencv_hfs.so.407 libopencv-4.7.0_1
+libopencv_img_hash.so.407 libopencv-4.7.0_1
+libopencv_line_descriptor.so.407 libopencv-4.7.0_1
+libopencv_saliency.so.407 libopencv-4.7.0_1
+libopencv_structured_light.so.407 libopencv-4.7.0_1
+libopencv_aruco.so.407 libopencv-4.7.0_1
+libopencv_bgsegm.so.407 libopencv-4.7.0_1
+libopencv_bioinspired.so.407 libopencv-4.7.0_1
+libopencv_ccalib.so.407 libopencv-4.7.0_1
+libopencv_face.so.407 libopencv-4.7.0_1
+libopencv_tracking.so.407 libopencv-4.7.0_1
+libopencv_xfeatures2d.so.407 libopencv-4.7.0_1
+libopencv_optflow.so.407 libopencv-4.7.0_1
+libopencv_ximgproc.so.407 libopencv-4.7.0_1
+libopencv_plot.so.407 libopencv-4.7.0_1
+libopencv_text.so.407 libopencv-4.7.0_1
+libopencv_ml.so.407 libopencv-4.7.0_1
+libopencv_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn.so.407 libopencv-4.7.0_1
+libopencv_shape.so.407 libopencv-4.7.0_1
+libopencv_stitching.so.407 libopencv-4.7.0_1
+libopencv_photo.so.407 libopencv-4.7.0_1
+libopencv_video.so.407 libopencv-4.7.0_1
+libopencv_calib3d.so.407 libopencv-4.7.0_1
+libopencv_features2d.so.407 libopencv-4.7.0_1
+libopencv_flann.so.407 libopencv-4.7.0_1
+libopencv_highgui.so.407 libopencv-4.7.0_1
+libopencv_videoio.so.407 libopencv-4.7.0_1
+libopencv_imgcodecs.so.407 libopencv-4.7.0_1
+libopencv_imgproc.so.407 libopencv-4.7.0_1
+libopencv_core.so.407 libopencv-4.7.0_1
+libopencv_superres.so.407 libopencv-4.7.0_1
+libopencv_videostab.so.407 libopencv-4.7.0_1
+libopencv_gapi.so.407 libopencv-4.7.0_1
+libopencv_xobjdetect.so.407 libopencv-4.7.0_1
+libopencv_datasets.so.407 libopencv-4.7.0_1
+libopencv_dnn_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn_superres.so.407 libopencv-4.7.0_1
+libopencv_dpm.so.407 libopencv-4.7.0_1
+libopencv_phase_unwrapping.so.407 libopencv-4.7.0_1
+libopencv_stereo.so.407 libopencv-4.7.0_1
+libopencv_rapid.so.407 libopencv-4.7.0_1
+libopencv_intensity_transform.so.407 libopencv-4.7.0_1
+libopencv_alphamat.so.407 libopencv-4.7.0_1
+libopencv_barcode.so.407 libopencv-4.7.0_1
+libopencv_mcc.so.407 libopencv-4.7.0_1
 libuniconf.so.4.6 wvstreams-4.6.1_20
 libwvbase.so.4.6 wvstreams-4.6.1_20
 libwvutils.so.4.6 wvstreams-4.6.1_20
diff --git a/srcpkgs/opencv/template b/srcpkgs/opencv/template
index 69c635b1ad2b..41f3183f1582 100644
--- a/srcpkgs/opencv/template
+++ b/srcpkgs/opencv/template
@@ -1,7 +1,7 @@
 # Template file for 'opencv'
 pkgname=opencv
-version=4.6.0
-revision=4
+version=4.7.0
+revision=1
 create_wrksrc=yes
 build_wrksrc=${pkgname}-${version}
 build_style=cmake
@@ -24,8 +24,8 @@ homepage="https://opencv.org"
 changelog="https://github.com/opencv/opencv/wiki/ChangeLog"
 distfiles="https://github.com/opencv/opencv/archive/${version}.tar.gz
  https://github.com/opencv/opencv_contrib/archive/${version}.tar.gz>contrib.tar.gz"
-checksum="1ec1cba65f9f20fe5a41fda1586e01c70ea0c9a6d7b67c9e13edf0cfe2239277
- 1777d5fd2b59029cf537e5fd6f8aa68d707075822f90bde683fcde086f85f7a7"
+checksum="8df0079cdbe179748a18d44731af62a245a45ebf5085223dc03133954c662973
+ 42df840cf9055e59d0e22c249cfb19f04743e1bdad113d31b1573d3934d62584"
 patch_args="-Np1 -d ${build_wrksrc}"
 # tests hang indenfinitely, even with test data included
 make_check=no

From 81d2ded434d05c876c9739f2c9da22e980a0b71b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 004/115] actiona: revbump for opencv-4.7.0

---
 srcpkgs/actiona/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/actiona/template b/srcpkgs/actiona/template
index cf5f0b7a2ae6..0d899311e6df 100644
--- a/srcpkgs/actiona/template
+++ b/srcpkgs/actiona/template
@@ -1,7 +1,7 @@
 # Template file for 'actiona'
 pkgname=actiona
 version=3.10.1
-revision=2
+revision=3
 build_style=qmake
 configure_args="PKGCONFIG_OPENCV=opencv4"
 hostmakedepends="pkg-config qt5-plugin-mysql qt5-qmake qt5-host-tools"

From 31f1f622ae1dfd6ec33cf36b20fd6d1cdf35469f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 005/115] gmic: revbump for opencv-4.7.0

---
 srcpkgs/gmic/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gmic/template b/srcpkgs/gmic/template
index 24a9c7218fdf..0bb4034d5cc8 100644
--- a/srcpkgs/gmic/template
+++ b/srcpkgs/gmic/template
@@ -1,7 +1,7 @@
 # Template file for 'gmic'
 pkgname=gmic
 version=3.1.6
-revision=3
+revision=4
 _zart_hash=34ebf6cce0bafb98abe57cec83c4a02cd1abeca0
 create_wrksrc=yes
 build_wrksrc="src"

From abea791dcd2c33bff2a15af4d0cb110eae640a2c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 006/115] qimgv: revbump for opencv-4.7.0

---
 srcpkgs/qimgv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qimgv/template b/srcpkgs/qimgv/template
index 7eb30db33992..dd341dfe1bfc 100644
--- a/srcpkgs/qimgv/template
+++ b/srcpkgs/qimgv/template
@@ -1,7 +1,7 @@
 # Template file for 'qimgv'
 pkgname=qimgv
 version=1.0.2
-revision=2
+revision=3
 build_style=cmake
 configure_args="$(vopt_if video -DVIDEO_SUPPORT=ON -DVIDEO_SUPPORT=OFF)
  $(vopt_if scale -DOPENCV_SUPPORT=ON -DOPENCV_SUPPORT=OFF)

From 6c678e4fd69b77dcfa70e54749711a79b6158023 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 007/115] retroshare: revbump for opencv-4.7.0

---
 srcpkgs/retroshare/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroshare/template b/srcpkgs/retroshare/template
index 8a0786c21a08..72023fa98b75 100644
--- a/srcpkgs/retroshare/template
+++ b/srcpkgs/retroshare/template
@@ -1,7 +1,7 @@
 # Template file for 'retroshare'
 pkgname=retroshare
 version=0.6.6
-revision=2
+revision=4
 build_style=qmake
 #XXX broadcast feature requires an ancient udp-discovery-cpp which either needs
 # to be fetched+patched (FTBFS) here or packaged :/

From a0db3a1b263782a2f3bec5be6db2e62abd8f2fad Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 008/115] waifu2x-converter-cpp: revbump for opencv-4.7.0

---
 srcpkgs/waifu2x-converter-cpp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waifu2x-converter-cpp/template b/srcpkgs/waifu2x-converter-cpp/template
index 8c095d0d7bab..aa52d8c981a8 100644
--- a/srcpkgs/waifu2x-converter-cpp/template
+++ b/srcpkgs/waifu2x-converter-cpp/template
@@ -1,7 +1,7 @@
 # Template file for 'waifu2x-converter-cpp'
 pkgname=waifu2x-converter-cpp
 version=5.2.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DINSTALL_MODELS=ON"
 hostmakedepends="pkg-config"

From 30a4b310b94de46cb676b96d863038c6be0cfc54 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:38 -0400
Subject: [PATCH 009/115] vlc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/vlc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/vlc/template b/srcpkgs/vlc/template
index 210762b0a7e2..855ca5238662 100644
--- a/srcpkgs/vlc/template
+++ b/srcpkgs/vlc/template
@@ -1,7 +1,7 @@
 # Template file for 'vlc'
 pkgname=vlc
 version=3.0.18
-revision=3
+revision=4
 build_style=gnu-configure
 configure_args="--disable-gme --disable-libtar --enable-jack
  --enable-live555 --disable-fluidsynth --enable-dvdread
@@ -25,7 +25,7 @@ lib32disabled=yes
 hostmakedepends="automake libtool pkg-config flex gettext libgcrypt-devel
  live555-devel gettext-devel $(vopt_if lua lua52) $(vopt_if chromecast protobuf)"
 makedepends="
- avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg-devel freefont-ttf
+ avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg4-devel freefont-ttf
  gnutls-devel jack-devel liba52-devel libass-devel libbluray-devel
  libcdio-devel libdca-devel libdvbpsi-devel libdvdnav-devel libmad-devel
  libmatroska-devel libmodplug-devel libmpcdec-devel libmpeg2-devel

From 7bc1290344f92faa3a8b86ef630fb27e95478e6d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:55 -0400
Subject: [PATCH 010/115] osg: revbump for ffmpeg4-4.4.3

---
 srcpkgs/osg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/osg/template b/srcpkgs/osg/template
index a9ebbd287933..755793f7e11b 100644
--- a/srcpkgs/osg/template
+++ b/srcpkgs/osg/template
@@ -8,7 +8,7 @@ build_helper="qemu"
 configure_args="-DLIB_POSTFIX="
 hostmakedepends="pkg-config xrandr"
 makedepends="MesaLib-devel gtkglext-devel libcurl-devel giflib-devel librsvg-devel
- jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg-devel xine-lib-devel
+ jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg4-devel xine-lib-devel
  SDL2-devel gst-plugins-base1-devel
  $(vopt_if openexr libopenexr-devel)
  $(vopt_if poppler poppler-glib-devel)

From 5b3f9184ea6483df7766665ee408b31016d9179c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:13 -0400
Subject: [PATCH 011/115] xine-lib: revbump for ffmpeg4-4.4.3

---
 srcpkgs/xine-lib/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/xine-lib/template b/srcpkgs/xine-lib/template
index f713eff49b07..ed6194c17d11 100644
--- a/srcpkgs/xine-lib/template
+++ b/srcpkgs/xine-lib/template
@@ -1,6 +1,6 @@
 # Template file for 'xine-lib'
 pkgname=xine-lib
-version=1.2.12
+version=1.2.13
 revision=1
 build_style=gnu-configure
 configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
@@ -8,7 +8,7 @@ configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
 hostmakedepends="automake gettext-devel libtool pkg-config perl"
 makedepends="
  zlib-devel alsa-lib-devel libxcb-devel libSM-devel libXext-devel libXv-devel
- libXvMC-devel liba52-devel libmad-devel ffmpeg-devel pulseaudio-devel
+ libXvMC-devel liba52-devel libmad-devel ffmpeg4-devel pulseaudio-devel
  jack-devel samba-devel libflac-devel libmodplug-devel libmpcdec-devel
  speex-devel libtheora-devel libvorbis-devel libdca-devel faad2-devel
  libcdio-devel libbluray-devel aalib-devel libcaca-devel libXinerama-devel
@@ -19,7 +19,7 @@ license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="http://www.xine-project.org"
 changelog="https://sourceforge.net/projects/xine/files/xine-lib/${version}/README.txt/view"
 distfiles="${SOURCEFORGE_SITE}/xine/${pkgname}-${version}.tar.xz"
-checksum=d606270468e1540c2a89c0d7f5fdf11e17ecc0c2698cc0bcb1065ff26abee098
+checksum=5f10d6d718a4a51c17ed1b32b031d4f9b80b061e8276535b2be31e5ac4b75e6f
 
 case "$XBPS_TARGET_MACHINE" in
 	i686-musl)

From 6088d951297117555bbd00be472c38f4b98ce039 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 012/115] QMPlay2: revbump for ffmpeg-6.0

---
 srcpkgs/QMPlay2/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/QMPlay2/template b/srcpkgs/QMPlay2/template
index ad73cbb01bae..55284c051161 100644
--- a/srcpkgs/QMPlay2/template
+++ b/srcpkgs/QMPlay2/template
@@ -1,7 +1,7 @@
 # Template file for 'QMPlay2'
 pkgname=QMPlay2
 version=23.02.05
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools"
 makedepends="alsa-lib-devel ffmpeg-devel libass-devel libcdio-devel libgme-devel

From bde57edb6367e460aa49293c12a3f3b59e26a865 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 013/115] alsa-plugins: revbump for ffmpeg-6.0

---
 srcpkgs/alsa-plugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/alsa-plugins/template b/srcpkgs/alsa-plugins/template
index 0bfa6d9fd264..a5708a7d82a8 100644
--- a/srcpkgs/alsa-plugins/template
+++ b/srcpkgs/alsa-plugins/template
@@ -1,7 +1,7 @@
 # Template file for 'alsa-plugins'
 pkgname=alsa-plugins
 version=1.2.7.1
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--disable-maemo-plugin"
 hostmakedepends="pkg-config"

From 06832f5c1a6c96bc73be3e50522b302cc95bcae9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 014/115] arcan: revbump for ffmpeg-6.0

---
 srcpkgs/arcan/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/arcan/template b/srcpkgs/arcan/template
index 7be9652eccf3..ccc7df11ceac 100644
--- a/srcpkgs/arcan/template
+++ b/srcpkgs/arcan/template
@@ -2,7 +2,7 @@
 # !! keep synced with: acfgfs aclip aloadimage
 pkgname=arcan
 version=0.6.2.1
-revision=1
+revision=2
 create_wrksrc=yes
 build_wrksrc=arcan/src
 build_style=cmake

From 11da6f9b315a638b64a3c5931083c4676b539126 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 015/115] attract: revbump for ffmpeg4-4.4.3

---
 srcpkgs/attract/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/attract/template b/srcpkgs/attract/template
index 26144e931a3c..e760bf0d18ae 100644
--- a/srcpkgs/attract/template
+++ b/srcpkgs/attract/template
@@ -1,12 +1,12 @@
 # Template file for 'attract'
 pkgname=attract
 version=2.6.2
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="VERBOSE=1"
 make_use_env=yes
 hostmakedepends="pkg-config"
-makedepends="SFML-devel ffmpeg-devel fontconfig-devel glu-devel libarchive-devel
+makedepends="SFML-devel ffmpeg4-devel fontconfig-devel glu-devel libarchive-devel
  libcurl-devel libjpeg-turbo-devel xine-lib rapidjson libXrandr-devel"
 depends="git"
 short_desc="Attract-Mode is a graphical frontend for emulators"

From 7d7b8fd197ceff642ac6ababb299325ec20da0fa Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 016/115] aubio: revbump for ffmpeg-6.0

---
 srcpkgs/aubio/patches/ffmpeg5.patch | 25 +++++++++++++++++++++++++
 srcpkgs/aubio/template              |  2 +-
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/aubio/patches/ffmpeg5.patch

diff --git a/srcpkgs/aubio/patches/ffmpeg5.patch b/srcpkgs/aubio/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..aace41a6e6d9
--- /dev/null
+++ b/srcpkgs/aubio/patches/ffmpeg5.patch
@@ -0,0 +1,25 @@
+From 8a05420e5dd8c7b8b2447f82dc919765876511b3 Mon Sep 17 00:00:00 2001
+From: Paul Brossier <piem@piem.org>
+Date: Tue, 25 Jan 2022 18:30:27 +0100
+Subject: [PATCH] [source_avcodec] define FF_API_LAVF_AVCTX for libavcodec >
+ 59, thx @berolinux (closes gh-353)
+
+---
+ src/io/source_avcodec.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/io/source_avcodec.c b/src/io/source_avcodec.c
+index e0ae93b5..1421bd9a 100644
+--- a/src/io/source_avcodec.c
++++ b/src/io/source_avcodec.c
+@@ -68,6 +68,10 @@
+ #define AUBIO_AVCODEC_MAX_BUFFER_SIZE AV_INPUT_BUFFER_MIN_SIZE
+ #endif
+ 
++#if LIBAVCODEC_VERSION_MAJOR >= 59
++#define FF_API_LAVF_AVCTX 1
++#endif
++
+ struct _aubio_source_avcodec_t {
+   uint_t hop_size;
+   uint_t samplerate;
diff --git a/srcpkgs/aubio/template b/srcpkgs/aubio/template
index ad1c4b256991..7d875cc02541 100644
--- a/srcpkgs/aubio/template
+++ b/srcpkgs/aubio/template
@@ -1,7 +1,7 @@
 # Template file for 'aubio'
 pkgname=aubio
 version=0.4.9
-revision=1
+revision=2
 build_style=waf3
 # XXX lash, pure and swig support.
 hostmakedepends="pkg-config txt2man"

From 3c5c34266583a781742447ac475cccdfa2ff3610 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 017/115] audacious-plugins: revbump for ffmpeg-6.0

---
 .../audacious-plugins/patches/ffmpeg5.patch   | 43 +++++++++++++++++++
 srcpkgs/audacious-plugins/template            |  2 +-
 2 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/audacious-plugins/patches/ffmpeg5.patch

diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg5.patch b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..4e5e34099d71
--- /dev/null
+++ b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
@@ -0,0 +1,43 @@
+commit 298aa371c56c2f52c25a33d9bdec4918b11cebdc
+Author: tibequadorian <tibequadorian@posteo.de>
+Date:   Sat Mar 19 18:40:12 2022 +0100
+
+    audacious-plugins: rebuild against ffmpeg-5.0
+
+diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+new file mode 100644
+index 0000000000..617c11215b
+--- /dev/null
++++ b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+@@ -0,0 +1,31 @@
++From f60beb400eeb1e4778bbfd738bc4a4ccef3de539 Mon Sep 17 00:00:00 2001
++From: John Lindgren <john@jlindgren.net>
++Date: Sat, 5 Mar 2022 12:05:34 -0500
++Subject: [PATCH] Fix build with FFmpeg 5.0
++
++---
++ src/ffaudio/ffaudio-core.cc | 4 ++--
++ 1 file changed, 2 insertions(+), 2 deletions(-)
++
++diff --git a/src/ffaudio/ffaudio-core.cc b/src/ffaudio/ffaudio-core.cc
++index 16dc63e3a..a2b95fd6c 100644
++--- a/src/ffaudio/ffaudio-core.cc
+++++ b/src/ffaudio/ffaudio-core.cc
++@@ -274,7 +274,7 @@ static AVInputFormat * get_format_by_content (const char * name, VFSFile & file)
++         AVProbeData d = {name, buf, filled};
++         score = target;
++ 
++-        f = av_probe_input_format2 (& d, true, & score);
+++        f = (AVInputFormat *) av_probe_input_format2 (& d, true, & score);
++         if (f)
++             break;
++ 
++@@ -347,7 +347,7 @@ static bool find_codec (AVFormatContext * c, CodecInfo * cinfo)
++ #endif
++         if (stream && stream->codecpar && stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
++         {
++-            AVCodec * codec = avcodec_find_decoder (stream->codecpar->codec_id);
+++            AVCodec * codec = (AVCodec *) avcodec_find_decoder (stream->codecpar->codec_id);
++ 
++             if (codec)
++             {
diff --git a/srcpkgs/audacious-plugins/template b/srcpkgs/audacious-plugins/template
index 88cbc1671fc6..beebfae59ed4 100644
--- a/srcpkgs/audacious-plugins/template
+++ b/srcpkgs/audacious-plugins/template
@@ -2,7 +2,7 @@
 #Keep in sync with audacious!
 pkgname=audacious-plugins
 version=4.3.1
-revision=1
+revision=2
 build_style=meson
 configure_args="$(vopt_bool gtk3 gtk) $(vopt_bool gtk3)
  $(vopt_bool qt) $(vopt_bool qt qt6)"

From cca52dd8244fe4d305b82987b415289cc46b7b2e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 018/115] audacity: revbump for ffmpeg4-4.4.3

---
 srcpkgs/audacity/template | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/audacity/template b/srcpkgs/audacity/template
index d509c0a89407..11e20255685b 100644
--- a/srcpkgs/audacity/template
+++ b/srcpkgs/audacity/template
@@ -1,7 +1,7 @@
 # Template file for 'audacity'
 pkgname=audacity
 version=2.4.1
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--with-ffmpeg=system --with-libsndfile=system --with-expat=system
  --with-libsoxr=system --with-lame=system --with-lv2=system ac_cv_path_WX_CONFIG=wx-config-gtk3"
@@ -9,7 +9,7 @@ hostmakedepends="pkg-config cmake gettext libtool m4 which"
 makedepends="jack-devel wxWidgets-gtk3-devel gtk+3-devel
  libmad-devel soundtouch-devel libsoxr-devel
  vamp-plugin-sdk-devel lame-devel libid3tag-devel libflac-devel
- ffmpeg-devel twolame-devel serd-devel lv2 lilv-devel suil-devel"
+ ffmpeg4-devel twolame-devel serd-devel lv2 lilv-devel suil-devel"
 depends="desktop-file-utils hicolor-icon-theme"
 short_desc="Graphical cross-platform audio editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
@@ -33,5 +33,4 @@ post_install() {
 	vcopy plug-ins /usr/share/audacity
 
 	rm ${DESTDIR}/usr/share/doc/audacity/LICENSE.txt
-	vlicense LICENSE.txt LICENSE
 }

From f8316cf38e5d121204201dde5aea9290b87f869e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 019/115] avidemux: revbump for ffmpeg-6.0

---
 srcpkgs/avidemux/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/avidemux/template b/srcpkgs/avidemux/template
index 253a0243e225..557285982d2b 100644
--- a/srcpkgs/avidemux/template
+++ b/srcpkgs/avidemux/template
@@ -1,7 +1,7 @@
 # Template file for 'avidemux'
 pkgname=avidemux
 version=2.8.0
-revision=2
+revision=3
 # Can't be compiled for aarch64, arm* or mips*
 archs="x86_64* i686*"
 hostmakedepends="cmake pkg-config qt5-host-tools qt5-devel tar yasm"

From fde3e7ae0c2ba55da3cb4d21975781c695a92470 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 020/115] baresip: revbump for ffmpeg-6.0

---
 srcpkgs/baresip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/baresip/template b/srcpkgs/baresip/template
index f1bd1817048b..b21e22334316 100644
--- a/srcpkgs/baresip/template
+++ b/srcpkgs/baresip/template
@@ -1,7 +1,7 @@
 # Template file for 'baresip'
 pkgname=baresip
 version=2.10.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config glib-devel"
 makedepends="libgsm-devel libpng-devel openssl-devel libsndfile-devel

From 15310261be2f09322ff746b75e4ec666c646f5f7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 021/115] blender: revbump for ffmpeg-6.0

---
 srcpkgs/blender/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index ec724bb0a6dc..0f72876d4d70 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -1,7 +1,7 @@
 # Template file for 'blender'
 pkgname=blender
 version=3.5.1
-revision=1
+revision=2
 archs="x86_64* ppc64*"
 build_style="cmake"
 pycompile_dirs="/usr/share/blender/${version%.*}/scripts"
@@ -9,8 +9,8 @@ configure_args="-DWITH_INSTALL_PORTABLE=OFF -DWITH_PYTHON_INSTALL=OFF
  -DWITH_JACK=ON -DWITH_CODEC_FFMPEG=ON -DWITH_CODEC_SNDFILE=ON -DWITH_OPENMP=ON
  -DWITH_FFTW3=ON -DWITH_MOD_OCEANSIM=ON -DWITH_CYCLES_EMBREE=OFF -DWITH_OPENCOLORIO=ON
  -DWITH_IMAGE_OPENEXR=ON -DWITH_IMAGE_OPENJPEG=ON -DWITH_OPENSUBDIV=ON
- -DWITH_OPENCOLLADA=ON -DWITH_SYSTEM_GLEW=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
- -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_LIBDECOR=ON
+ -DWITH_OPENCOLLADA=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
+ -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_WAYLAND_LIBDECOR=ON
  -DWITH_BUILDINFO=OFF -DPYTHON_VERSION=${py3_ver} -DPYTHON_LIBPATH=/usr/lib
  -DPYTHON_LIBRARY=python${py3_ver}${py3_abiver} -DPYTHON_INCLUDE_DIRS=/${py3_inc}
  -DWITH_SYSTEM_LZO=ON -DWITH_SYSTEM_EIGEN3=ON -DWITH_SYSTEM_FREETYPE=ON"

From 0b4fd191e0d9671d2d507bd8118a9d49baa6f33f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 022/115] cantata: revbump for ffmpeg-6.0

---
 srcpkgs/cantata/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cantata/template b/srcpkgs/cantata/template
index 4b417d80d5c2..8a90aaa4c07a 100644
--- a/srcpkgs/cantata/template
+++ b/srcpkgs/cantata/template
@@ -1,7 +1,7 @@
 # Template file for 'cantata'
 pkgname=cantata
 version=2.5.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools qt5-tools"
 makedepends="qt5-devel qt5-tools-devel qt5-svg-devel qt5-xmlpatterns-devel

From 3e2d44936b534a6315f9d4ba725f1426709bd46d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 023/115] ccextractor: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ccextractor/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/ccextractor/template b/srcpkgs/ccextractor/template
index 9abcd82852b2..6eccad5885af 100644
--- a/srcpkgs/ccextractor/template
+++ b/srcpkgs/ccextractor/template
@@ -1,12 +1,12 @@
 # Template file for 'ccextractor'
 pkgname=ccextractor
 version=0.93
-revision=1
+revision=2
 build_wrksrc="linux"
 build_style=gnu-configure
 configure_args="--enable-ocr --enable-hardsubx"
 hostmakedepends="automake pkg-config"
-makedepends="leptonica-devel tesseract-ocr-devel ffmpeg-devel"
+makedepends="leptonica-devel tesseract-ocr-devel ffmpeg4-devel"
 short_desc="Extract subtitles from video streams"
 maintainer="newbluemoon <blaumolch@mailbox.org>"
 license="GPL-2.0-or-later"

From 20405f0025d3014273d403119595a56a94e188db Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 024/115] chromaprint: revbump for ffmpeg-6.0

---
 srcpkgs/chromaprint/patches/ffmpeg5.patch | 569 ++++++++++++++++++++++
 srcpkgs/chromaprint/template              |   2 +-
 2 files changed, 570 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromaprint/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromaprint/patches/ffmpeg5.patch b/srcpkgs/chromaprint/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..a9fd307a23c8
--- /dev/null
+++ b/srcpkgs/chromaprint/patches/ffmpeg5.patch
@@ -0,0 +1,569 @@
+From 8ccad6937177b1b92e40ab8f4447ea27bac009a7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= <lalinsky@gmail.com>
+Date: Fri, 4 Nov 2022 21:47:38 +0100
+Subject: [PATCH] Use FFmpeg 5.x (#120)
+
+* Use FFmpeg 5.1.2 for CI builds
+
+* Build on Ubuntu 20.04
+
+* Upgrade code to FFmpeg 5.x APIs
+
+* Only set FFmpeg include dirs if building tools
+
+* No longer needed
+
+* Use ubuntu 20.04
+---
+ .github/workflows/build.yml                   |   6 +-
+ CMakeLists.txt                                |  16 --
+ package/build.sh                              |   4 +-
+ src/audio/ffmpeg_audio_processor.h            |   2 -
+ src/audio/ffmpeg_audio_processor_avresample.h |  72 -------
+ src/audio/ffmpeg_audio_processor_swresample.h |  18 +-
+ src/audio/ffmpeg_audio_reader.h               | 197 +++++++++---------
+ tests/CMakeLists.txt                          |   6 +
+ 8 files changed, 122 insertions(+), 199 deletions(-)
+ delete mode 100644 src/audio/ffmpeg_audio_processor_avresample.h
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index f8d6a32..4da2405 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -84,9 +84,6 @@ find_package(FFmpeg)
+ if(FFMPEG_LIBRARIES)
+ 	cmake_push_check_state(RESET)
+ 	set(CMAKE_REQUIRED_LIBRARIES ${FFMPEG_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -lm)
+-	check_function_exists(av_packet_unref HAVE_AV_PACKET_UNREF)
+-	check_function_exists(av_frame_alloc HAVE_AV_FRAME_ALLOC)
+-	check_function_exists(av_frame_free HAVE_AV_FRAME_FREE)
+ 	cmake_pop_check_state()
+ endif()
+
+@@ -163,14 +160,11 @@ message(STATUS "Using ${FFT_LIB} for FFT calculations")
+ if(NOT AUDIO_PROCESSOR_LIB)
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+ 		set(AUDIO_PROCESSOR_LIB "swresample")
+-	elseif(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(AUDIO_PROCESSOR_LIB "avresample")
+ 	endif()
+ endif()
+
+ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE OFF)
+ 		set(USE_SWRESAMPLE ON)
+ 		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBSWRESAMPLE_LIBRARIES})
+ 		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBSWRESAMPLE_INCLUDE_DIRS})
+@@ -178,16 +172,6 @@ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+ 	endif()
+ 	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+-elseif(AUDIO_PROCESSOR_LIB STREQUAL "avresample")
+-	if(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE ON)
+-		set(USE_SWRESAMPLE OFF)
+-		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBAVRESAMPLE_LIBRARIES})
+-		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBAVRESAMPLE_INCLUDE_DIRS})
+-	else()
+-		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+-	endif()
+-	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+ else()
+ 	message(STATUS "Building without audio conversion support, please install FFmpeg with libswresample")
+ endif()
+diff --git a/package/build.sh b/package/build.sh
+index da631ae..b41d36e 100755
+--- a/package/build.sh
++++ b/package/build.sh
+@@ -7,8 +7,8 @@ set -eux
+
+ BASE_DIR=$(cd $(dirname $0)/.. && pwd)
+
+-FFMPEG_VERSION=4.4.1
+-FFMPEG_BUILD_TAG=v4.4.1-1
++FFMPEG_VERSION=5.1.2
++FFMPEG_BUILD_TAG=v${FFMPEG_VERSION}-1
+
+ TMP_BUILD_DIR=$BASE_DIR/$(mktemp -d build.XXXXXXXX)
+ trap 'rm -rf $TMP_BUILD_DIR' EXIT
+diff --git a/src/audio/ffmpeg_audio_processor.h b/src/audio/ffmpeg_audio_processor.h
+index 7628fc7..39f4f6d 100644
+--- a/src/audio/ffmpeg_audio_processor.h
++++ b/src/audio/ffmpeg_audio_processor.h
+@@ -10,8 +10,6 @@
+
+ #if defined(USE_SWRESAMPLE)
+ #include "audio/ffmpeg_audio_processor_swresample.h"
+-#elif defined(USE_AVRESAMPLE)
+-#include "audio/ffmpeg_audio_processor_avresample.h"
+ #else
+ #error "no audio processing library"
+ #endif
+diff --git a/src/audio/ffmpeg_audio_processor_avresample.h b/src/audio/ffmpeg_audio_processor_avresample.h
+deleted file mode 100644
+index bd85f92..0000000
+--- a/src/audio/ffmpeg_audio_processor_avresample.h
++++ /dev/null
+@@ -1,72 +0,0 @@
+-// Copyright (C) 2016  Lukas Lalinsky
+-// Distributed under the MIT license, see the LICENSE file for details.
+-
+-#ifndef CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-#define CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-
+-extern "C" {
+-#include <libavresample/avresample.h>
+-}
+-
+-namespace chromaprint {
+-
+-class FFmpegAudioProcessor {
+-public:
+-	FFmpegAudioProcessor() {
+-		m_resample_ctx = avresample_alloc_context();
+-	}
+-
+-	~FFmpegAudioProcessor() {
+-		avresample_free(&m_resample_ctx);
+-	}
+-
+-	void SetCompatibleMode() {
+-		av_opt_set_int(m_resample_ctx, "filter_size", 16, 0);
+-		av_opt_set_int(m_resample_ctx, "phase_shift", 8, 0);
+-		av_opt_set_int(m_resample_ctx, "linear_interp", 1, 0);
+-		av_opt_set_double(m_resample_ctx, "cutoff", 0.8, 0);
+-	}
+-
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "in_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_rate", sample_rate, 0);
+-	}
+-
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "out_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_rate, 0);
+-	}
+-
+-	int Init() {
+-		return avresample_open(m_resample_ctx);
+-	}
+-
+-	int Convert(uint8_t **out, int out_count, const uint8_t **in, int in_count) {
+-		return avresample_convert(m_resample_ctx, out, 0, out_count, (uint8_t **) in, 0, in_count);
+-	}
+-
+-	int Flush(uint8_t **out, int out_count) {
+-		return avresample_read(m_resample_ctx, out, out_count);
+-	}
+-
+-private:
+-	AVAudioResampleContext *m_resample_ctx = nullptr;
+-};
+-
+-}; // namespace chromaprint
+-
+-#endif
+diff --git a/src/audio/ffmpeg_audio_processor_swresample.h b/src/audio/ffmpeg_audio_processor_swresample.h
+index b86266b..b1d4bea 100644
+--- a/src/audio/ffmpeg_audio_processor_swresample.h
++++ b/src/audio/ffmpeg_audio_processor_swresample.h
+@@ -28,30 +28,28 @@ public:
+ 		av_opt_set_double(m_swr_ctx, "cutoff", 0.8, 0);
+ 	}
+
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "icl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "ich", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetInputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "in_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "isf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "in_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "isr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "in_sample_rate", sample_rate, 0);
+ 	}
+
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "ocl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "och", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetOutputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "out_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "osf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "out_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "osr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "out_sample_rate", sample_rate, 0);
+ 	}
+
+ 	int Init() {
+diff --git a/src/audio/ffmpeg_audio_reader.h b/src/audio/ffmpeg_audio_reader.h
+index 5550164..1c6b346 100644
+--- a/src/audio/ffmpeg_audio_reader.h
++++ b/src/audio/ffmpeg_audio_reader.h
+@@ -62,7 +62,7 @@ public:
+ 	bool Read(const int16_t **data, size_t *size);
+
+ 	bool IsOpen() const { return m_opened; }
+-	bool IsFinished() const { return m_finished && !m_got_frame; }
++	bool IsFinished() const { return !m_has_more_packets && !m_has_more_frames; }
+
+ 	std::string GetError() const { return m_error; }
+ 	int GetErrorCode() const { return m_error_code; }
+@@ -74,20 +74,19 @@ private:
+ 	uint8_t *m_convert_buffer[1] = { nullptr };
+ 	int m_convert_buffer_nb_samples = 0;
+
+-	AVInputFormat *m_input_fmt = nullptr;
++	const AVInputFormat *m_input_fmt = nullptr;
+ 	AVDictionary *m_input_opts = nullptr;
+
+ 	AVFormatContext *m_format_ctx = nullptr;
+ 	AVCodecContext *m_codec_ctx = nullptr;
+-	AVFrame *m_frame = nullptr;
+ 	int m_stream_index = -1;
+ 	std::string m_error;
+ 	int m_error_code = 0;
+-	bool m_finished = false;
+ 	bool m_opened = false;
+-	int m_got_frame = 0;
+-	AVPacket m_packet;
+-	AVPacket m_packet0;
++	bool m_has_more_packets = true;
++	bool m_has_more_frames = true;
++	AVPacket *m_packet = nullptr;
++	AVFrame *m_frame = nullptr;
+
+ 	int m_output_sample_rate = 0;
+ 	int m_output_channels = 0;
+@@ -98,19 +97,12 @@ private:
+
+ inline FFmpegAudioReader::FFmpegAudioReader() {
+ 	av_log_set_level(AV_LOG_QUIET);
+-
+-	av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
+ }
+
+ inline FFmpegAudioReader::~FFmpegAudioReader() {
+ 	Close();
+ 	av_dict_free(&m_input_opts);
+ 	av_freep(&m_convert_buffer[0]);
+-	av_packet_unref(&m_packet0);
+ }
+
+ inline bool FFmpegAudioReader::SetInputFormat(const char *name) {
+@@ -135,11 +127,10 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ 	Close();
+
+-    av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
++	m_packet = av_packet_alloc();
++	if (!m_packet) {
++		return false;
++	}
+
+ 	ret = avformat_open_input(&m_format_ctx, file_name.c_str(), m_input_fmt, &m_input_opts);
+ 	if (ret < 0) {
+@@ -153,26 +144,31 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		return false;
+ 	}
+
+-	AVCodec *codec;
++	const AVCodec *codec;
+ 	ret = av_find_best_stream(m_format_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &codec, 0);
+ 	if (ret < 0) {
+ 		SetError("Could not find any audio stream in the file", ret);
+ 		return false;
+ 	}
+ 	m_stream_index = ret;
++	auto stream = m_format_ctx->streams[m_stream_index];
+
+-	m_codec_ctx = m_format_ctx->streams[m_stream_index]->codec;
++	m_codec_ctx = avcodec_alloc_context3(codec);
+ 	m_codec_ctx->request_sample_fmt = AV_SAMPLE_FMT_S16;
+
++	ret = avcodec_parameters_to_context(m_codec_ctx, stream->codecpar);
++	if (ret < 0) {
++		SetError("Could not copy the stream parameters", ret);
++		return false;
++	}
++
+ 	ret = avcodec_open2(m_codec_ctx, codec, nullptr);
+ 	if (ret < 0) {
+ 		SetError("Could not open the codec", ret);
+ 		return false;
+ 	}
+
+-	if (!m_codec_ctx->channel_layout) {
+-		m_codec_ctx->channel_layout = av_get_default_channel_layout(m_codec_ctx->channels);
+-	}
++	av_dump_format(m_format_ctx, 0, "foo", 0);
+
+ 	m_frame = av_frame_alloc();
+ 	if (!m_frame) {
+@@ -183,19 +179,23 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		m_output_sample_rate = m_codec_ctx->sample_rate;
+ 	}
+
+-	if (!m_output_channels) {
+-		m_output_channels = m_codec_ctx->channels;
++	AVChannelLayout output_channel_layout;
++	if (m_output_channels) {
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
++	} else {
++		m_output_channels = m_codec_ctx->ch_layout.nb_channels;
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
+ 	}
+
+-	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
++	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->ch_layout.nb_channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
+ 		m_converter.reset(new FFmpegAudioProcessor());
+ 		m_converter->SetCompatibleMode();
+ 		m_converter->SetInputSampleFormat(m_codec_ctx->sample_fmt);
+ 		m_converter->SetInputSampleRate(m_codec_ctx->sample_rate);
+-		m_converter->SetInputChannelLayout(m_codec_ctx->channel_layout);
++		m_converter->SetInputChannelLayout(&(m_codec_ctx->ch_layout));
+ 		m_converter->SetOutputSampleFormat(AV_SAMPLE_FMT_S16);
+ 		m_converter->SetOutputSampleRate(m_output_sample_rate);
+-		m_converter->SetOutputChannelLayout(av_get_default_channel_layout(m_output_channels));
++		m_converter->SetOutputChannelLayout(&output_channel_layout);
+ 		auto ret = m_converter->Init();
+ 		if (ret != 0) {
+ 			SetError("Could not create an audio converter instance", ret);
+@@ -203,10 +203,11 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		}
+ 	}
+
++	av_channel_layout_uninit(&output_channel_layout);
++
+ 	m_opened = true;
+-	m_finished = false;
+-	m_got_frame = 0;
+-	m_nb_packets = 0;
++	m_has_more_packets = true;
++	m_has_more_frames = true;
+ 	m_decode_error = 0;
+
+ 	return true;
+@@ -214,6 +215,7 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ inline void FFmpegAudioReader::Close() {
+ 	av_frame_free(&m_frame);
++	av_packet_free(&m_packet);
+
+ 	m_stream_index = -1;
+
+@@ -252,91 +254,98 @@ inline bool FFmpegAudioReader::Read(const int16_t **data, size_t *size) {
+ 		return false;
+ 	}
+
++	*data = nullptr;
++	*size = 0;
++
+ 	int ret;
++	bool needs_packet = false;
+ 	while (true) {
+-		while (m_packet.size <= 0) {
+-			av_packet_unref(&m_packet0);
+-			av_init_packet(&m_packet);
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			ret = av_read_frame(m_format_ctx, &m_packet);
++		while (needs_packet && m_packet->size == 0) {
++			ret = av_read_frame(m_format_ctx, m_packet);
+ 			if (ret < 0) {
+ 				if (ret == AVERROR_EOF) {
+-					m_finished = true;
++					needs_packet = false;
++					m_has_more_packets = false;
+ 					break;
+-				} else {
++				}
++				SetError("Error reading from the audio source", ret);
++				return false;
++			}
++			if (m_packet->stream_index == m_stream_index) {
++				needs_packet = false;
++			} else {
++				av_packet_unref(m_packet);
++			}
++		}
++
++		if (m_packet->size != 0) {
++			ret = avcodec_send_packet(m_codec_ctx, m_packet);
++			if (ret < 0) {
++				if (ret != AVERROR(EAGAIN)) {
+ 					SetError("Error reading from the audio source", ret);
+ 					return false;
+ 				}
+-			}
+-			m_packet0 = m_packet;
+-			if (m_packet.stream_index != m_stream_index) {
+-				m_packet.data = nullptr;
+-				m_packet.size = 0;
+ 			} else {
+-				m_nb_packets++;
++				av_packet_unref(m_packet);
+ 			}
+ 		}
+
+-		ret = avcodec_decode_audio4(m_codec_ctx, m_frame, &m_got_frame, &m_packet);
++		ret = avcodec_receive_frame(m_codec_ctx, m_frame);
+ 		if (ret < 0) {
+-			if (m_decode_error) {
+-				SetError("Error decoding audio frame", m_decode_error);
+-				return false;
++			if (ret == AVERROR_EOF) {
++				m_has_more_frames = false;
++			} else if (ret == AVERROR(EAGAIN)) {
++				if (m_has_more_packets) {
++					needs_packet = true;
++					continue;
++				} else {
++					m_has_more_frames = false;
++				}
+ 			}
+-			m_decode_error = ret;
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			continue;
++			SetError("Error decoding the audio source", ret);
++			return false;
+ 		}
+
+-		break;
+-	}
+-
+-	m_decode_error = 0;
+-
+-	const int decoded = std::min(ret, m_packet.size);
+-	m_packet.data += decoded;
+-	m_packet.size -= decoded;
+-
+-	if (m_got_frame) {
+-		if (m_converter) {
+-			if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
+-				int linsize;
+-				av_freep(&m_convert_buffer[0]);
+-				m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
+-				ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
+-				if (ret < 0) {
+-					SetError("Couldn't allocate audio converter buffer", ret);
++		if (m_frame->nb_samples > 0) {
++			if (m_converter) {
++				if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
++					int linsize;
++					av_freep(&m_convert_buffer[0]);
++					m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
++					ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->ch_layout.nb_channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
++					if (ret < 0) {
++						SetError("Couldn't allocate audio converter buffer", ret);
++						return false;
++					}
++				}
++				auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
++				if (nb_samples < 0) {
++					SetError("Couldn't convert audio", ret);
+ 					return false;
+ 				}
+-			}
+-			auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			}
+-			*data = (const int16_t *) m_convert_buffer[0];
+-			*size = nb_samples;
+-		} else {
+-			*data = (const int16_t *) m_frame->data[0];
+-			*size = m_frame->nb_samples;
+-		}
+-	} else {
+-		if (m_finished && m_converter) {
+-			auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			} else if (nb_samples > 0) {
+-				m_got_frame = 1;
+ 				*data = (const int16_t *) m_convert_buffer[0];
+ 				*size = nb_samples;
++			} else {
++				*data = (const int16_t *) m_frame->data[0];
++				*size = m_frame->nb_samples;
++			}
++		} else {
++			if (m_converter) {
++				if (IsFinished()) {
++					auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
++					if (nb_samples < 0) {
++						SetError("Couldn't convert audio", ret);
++						return false;
++					} else if (nb_samples > 0) {
++						*data = (const int16_t *) m_convert_buffer[0];
++						*size = nb_samples;
++					}
++				}
+ 			}
+ 		}
+-	}
+
+-	return true;
++		return true;
++	}
+ }
+
+ inline void FFmpegAudioReader::SetError(const char *message, int errnum) {
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index a2b517b..123e643 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -38,6 +38,12 @@ set(SRCS
+
+ if(BUILD_TOOLS)
+ 	set(SRCS ${SRCS} ../src/audio/ffmpeg_audio_reader_test.cpp)
++    include_directories(
++        ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}
++        ${AUDIO_PROCESSOR_INCLUDE_DIRS}
++    )
+ 	link_libraries(fpcalc_libs)
+ endif()
+
+-- 
+2.38.1
+
+
diff --git a/srcpkgs/chromaprint/template b/srcpkgs/chromaprint/template
index 7ef7838949f3..1f7bbc70a22c 100644
--- a/srcpkgs/chromaprint/template
+++ b/srcpkgs/chromaprint/template
@@ -1,7 +1,7 @@
 # Template file for 'chromaprint'
 pkgname=chromaprint
 version=1.5.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DBUILD_TOOLS=ON"
 make_check_target="check"

From 50ee42cc14571cef0f7cc621b25c89e175f04309 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 025/115] chromium: revbump for ffmpeg-6.0

---
 .../patches/chromium-93-ffmpeg-4.4.patch      | 36 --------------
 srcpkgs/chromium/patches/ffmpeg5.patch        | 47 +++++++++++++++++++
 srcpkgs/chromium/template                     |  2 +-
 3 files changed, 48 insertions(+), 37 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch
 create mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch b/srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch
deleted file mode 100644
index f0ec736f98bc..000000000000
--- a/srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch
+++ /dev/null
@@ -1,36 +0,0 @@
-diff --git a/media/filters/ffmpeg_demuxer.cc b/media/filters/ffmpeg_demuxer.cc
-index ac4713b07268..492a9a37d096 100644
---- a/media/filters/ffmpeg_demuxer.cc
-+++ b/media/filters/ffmpeg_demuxer.cc
-@@ -427,11 +427,11 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
-   scoped_refptr<DecoderBuffer> buffer;
- 
-   if (type() == DemuxerStream::TEXT) {
--    size_t id_size = 0;
-+    int id_size = 0;
-     uint8_t* id_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
- 
--    size_t settings_size = 0;
-+    int settings_size = 0;
-     uint8_t* settings_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
- 
-@@ -443,7 +443,7 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
-     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
-                                      side_data.data(), side_data.size());
-   } else {
--    size_t side_data_size = 0;
-+    int side_data_size = 0;
-     uint8_t* side_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
- 
-@@ -504,7 +504,7 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
-                                        packet->size - data_offset);
-     }
- 
--    size_t skip_samples_size = 0;
-+    int skip_samples_size = 0;
-     const uint32_t* skip_samples_ptr =
-         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
-             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..24e2da38e34c
--- /dev/null
+++ b/srcpkgs/chromium/patches/ffmpeg5.patch
@@ -0,0 +1,47 @@
+--- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
++++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
+@@ -92,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+-  if (stream->start_time != kNoFFmpegTimestamp)
++  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -1597,7 +1585,7 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+@@ -1618,7 +1606,7 @@
+     if (stream->type() != DemuxerStream::VIDEO)
+       continue;
+ 
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+ 
+     if (!stream->IsEnabled())
diff --git a/srcpkgs/chromium/template b/srcpkgs/chromium/template
index cafc2fe324c6..9df782b5fd9b 100644
--- a/srcpkgs/chromium/template
+++ b/srcpkgs/chromium/template
@@ -2,7 +2,7 @@
 pkgname=chromium
 # See https://chromiumdash.appspot.com/releases?platform=Linux for the latest version
 version=113.0.5672.92
-revision=1
+revision=2
 archs="i686* x86_64* aarch64* armv7l*"
 hostmakedepends="
  $(vopt_if clang "clang lld llvm15")

From 13382cfed052b0c52291b2bcf164cd42c8d20689 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 026/115] cmus: revbump for ffmpeg-6.0

---
 srcpkgs/cmus/patches/ffmpeg6.patch | 12 ++++++++++++
 srcpkgs/cmus/template              |  2 +-
 2 files changed, 13 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/cmus/patches/ffmpeg6.patch

diff --git a/srcpkgs/cmus/patches/ffmpeg6.patch b/srcpkgs/cmus/patches/ffmpeg6.patch
new file mode 100644
index 000000000000..ffa95ab81110
--- /dev/null
+++ b/srcpkgs/cmus/patches/ffmpeg6.patch
@@ -0,0 +1,12 @@
+--- a/ip/ffmpeg.c
++++ b/ip/ffmpeg.c
+@@ -202,9 +202,6 @@ static int ffmpeg_open(struct input_plugin_data *ip_data)
+ 			break;
+ 		}
+ 
+-		if (codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+-			cc->flags |= AV_CODEC_FLAG_TRUNCATED;
+-
+ 		if (avcodec_open2(cc, codec, NULL) < 0) {
+ 			d_print("could not open codec: %d, %s\n", cc->codec_id, avcodec_get_name(cc->codec_id));
+ 			err = -IP_ERROR_UNSUPPORTED_FILE_TYPE;
diff --git a/srcpkgs/cmus/template b/srcpkgs/cmus/template
index 0fcb424ce336..05b77d0fecae 100644
--- a/srcpkgs/cmus/template
+++ b/srcpkgs/cmus/template
@@ -1,7 +1,7 @@
 # Template file for 'cmus'
 pkgname=cmus
 version=2.10.0
-revision=1
+revision=2
 build_style=configure
 configure_args="prefix=/usr LD=$CC"
 hostmakedepends="pkg-config"

From 347e7966eb1fbf0a50f7d26e4e3c2741d34d5d0e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 027/115] cyanrip: revbump for ffmpeg-6.0

---
 srcpkgs/cyanrip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cyanrip/template b/srcpkgs/cyanrip/template
index 9796e3461601..5db30e020d17 100644
--- a/srcpkgs/cyanrip/template
+++ b/srcpkgs/cyanrip/template
@@ -1,7 +1,7 @@
 # Template file for 'cyanrip'
 pkgname=cyanrip
 version=0.9.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config"
 makedepends="ffmpeg-devel libcdio-devel libcdio-paranoia-devel libcurl-devel libmusicbrainz5-devel"

From fb401e8d94fbc234feaa20faabbf4992fa5e7273 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 028/115] deadbeef: revbump for ffmpeg4-4.4.3

---
 srcpkgs/deadbeef/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/deadbeef/template b/srcpkgs/deadbeef/template
index b664bb1b9bd9..165b3c7b9cad 100644
--- a/srcpkgs/deadbeef/template
+++ b/srcpkgs/deadbeef/template
@@ -1,14 +1,14 @@
 # Template file for 'deadbeef'
 pkgname=deadbeef
 version=1.8.8
-revision=1
+revision=2
 create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-oss --disable-lfm --disable-notify --disable-gtk2"
 hostmakedepends="automake libtool gettext gettext-devel intltool pkg-config
  yasm clang glib-devel"
 makedepends="
- alsa-lib-devel dbus-devel faad2-devel ffmpeg-devel gtk+3-devel imlib2-devel
+ alsa-lib-devel dbus-devel faad2-devel ffmpeg4-devel gtk+3-devel imlib2-devel
  jansson-devel libcddb-devel libcdio-devel libcurl-devel libflac-devel
  libmad-devel libpng-devel libsamplerate-devel libsndfile-devel libvorbis-devel
  libzip-devel mpg123-devel opusfile-devel pulseaudio-devel wavpack-devel"

From f9b1aa205054e8cc94b4e9e87916b24a95af9c7b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 029/115] dolphin-emu: revbump for ffmpeg-6.0

---
 srcpkgs/dolphin-emu/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/dolphin-emu/template b/srcpkgs/dolphin-emu/template
index 7ea197ceb2a8..7aeb0a5b645e 100644
--- a/srcpkgs/dolphin-emu/template
+++ b/srcpkgs/dolphin-emu/template
@@ -1,7 +1,7 @@
 # Template file for 'dolphin-emu'
 pkgname=dolphin-emu
 version=5.0.16101
-revision=1
+revision=2
 _dolphin_commit=8ecfa537a242de74d2e372e30d9d79b14584b2fb
 _mgba_commit=40d4c430fc36caeb7ea32fd39624947ed487d2f2
 #Version/hash pair can be found at https://dolphin-emu.org/download/

From 773e1a845fdfc40101b0288ab090ef65e0040eef Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 030/115] droidcam-obs-plugin: revbump for ffmpeg-6.0

---
 srcpkgs/droidcam-obs-plugin/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam-obs-plugin/template b/srcpkgs/droidcam-obs-plugin/template
index fc9c9bf6b9d5..fb0480754df4 100644
--- a/srcpkgs/droidcam-obs-plugin/template
+++ b/srcpkgs/droidcam-obs-plugin/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam-obs-plugin'
 pkgname=droidcam-obs-plugin
 version=2.0.1
-revision=1
+revision=2
 build_style=gnu-makefile
 make_use_env=yes
 make_build_args="ALLOW_STATIC=no"

From b69cfb3f27f53435f0f5118a8a71fdd12c0a132b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 031/115] droidcam: revbump for ffmpeg-6.0

---
 srcpkgs/droidcam/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam/template b/srcpkgs/droidcam/template
index 1c3f1b8b1fc6..32a9220b79a4 100644
--- a/srcpkgs/droidcam/template
+++ b/srcpkgs/droidcam/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam'
 pkgname=droidcam
 version=1.8.2
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="USBMUXD=-lusbmuxd-2.0 JPEG=-lturbojpeg"
 hostmakedepends="pkg-config"

From d5009d2704ba42c7f4c0030a6f50828128df5ae7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 032/115] ffmpegthumbnailer: revbump for ffmpeg-6.0

---
 .../ffmpegthumbnailer/patches/ffmpeg6.patch   | 202 ++++++++++++++++++
 srcpkgs/ffmpegthumbnailer/template            |   6 +-
 2 files changed, 205 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch

diff --git a/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
new file mode 100644
index 000000000000..363ff35a2841
--- /dev/null
+++ b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
@@ -0,0 +1,202 @@
+--- a/libffmpegthumbnailer/moviedecoder.cpp	2017-11-21 14:06:57.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.cpp	2023-05-05 13:14:47.946560668 -0400
+@@ -41,11 +41,6 @@
+ namespace ffmpegthumbnailer
+ {
+ 
+-struct SilenceLogLevel
+-{
+-    SilenceLogLevel() { av_log_set_level(AV_LOG_QUIET); }
+-};
+-
+ MovieDecoder::MovieDecoder(AVFormatContext* pavContext)
+ : m_VideoStream(-1)
+ , m_pFormatContext(pavContext)
+@@ -70,8 +65,6 @@
+ 
+ void MovieDecoder::initialize(const string& filename, bool preferEmbeddedMetadata)
+ {
+-    av_register_all();
+-    avcodec_register_all();
+     avformat_network_init();
+ 
+     string inputFile = filename == "-" ? "pipe:" : filename;
+@@ -97,8 +90,7 @@
+ {
+     if (m_pVideoCodecContext)
+     {
+-        avcodec_close(m_pVideoCodecContext);
+-        m_pVideoCodecContext = nullptr;
++        avcodec_free_context(&m_pVideoCodecContext);
+     }
+ 
+     if ((!m_FormatContextWasGiven) && m_pFormatContext)
+@@ -152,10 +144,10 @@
+     for (unsigned int i = 0; i < m_pFormatContext->nb_streams; ++i)
+     {
+         AVStream *stream = m_pFormatContext->streams[i];
+-        auto ctx = m_pFormatContext->streams[i]->codec;
+-        if (ctx->codec_type == AVMEDIA_TYPE_VIDEO)
++        auto par = m_pFormatContext->streams[i]->codecpar;
++        if (par->codec_type == AVMEDIA_TYPE_VIDEO)
+         {
+-            if (!preferEmbeddedMetadata || !isStillImageCodec(ctx->codec_id))
++            if (!preferEmbeddedMetadata || !isStillImageCodec(par->codec_id))
+             {
+                 videoStreams.push_back(i);
+                 continue;
+@@ -203,8 +195,7 @@
+     }
+ 
+     m_pVideoStream = m_pFormatContext->streams[m_VideoStream];
+-    m_pVideoCodecContext = m_pVideoStream->codec;
+-    m_pVideoCodec = avcodec_find_decoder(m_pVideoCodecContext->codec_id);
++    m_pVideoCodec = avcodec_find_decoder(m_pVideoStream->codecpar->codec_id);
+ 
+     if (m_pVideoCodec == nullptr)
+     {
+@@ -214,6 +205,20 @@
+         throw logic_error("Video Codec not found");
+     }
+ 
++    m_pVideoCodecContext = avcodec_alloc_context3(m_pVideoCodec);
++
++    if (m_pVideoCodecContext == nullptr)
++    {
++        destroy();
++        throw logic_error("Could not allocate video codec context");
++    }
++
++    if (avcodec_parameters_to_context(m_pVideoCodecContext, m_pVideoStream->codecpar) < 0)
++    {
++        destroy();
++        throw logic_error("Could not configure video codec context");
++    }
++
+     m_pVideoCodecContext->workaround_bugs = 1;
+ 
+     if (avcodec_open2(m_pVideoCodecContext, m_pVideoCodec, nullptr) < 0)
+@@ -386,13 +391,6 @@
+ 
+ void MovieDecoder::initializeFilterGraph(const AVRational& timeBase, const std::string& size, bool maintainAspectRatio)
+ {
+-    static const AVPixelFormat pixelFormats[] = { AV_PIX_FMT_RGB24, AV_PIX_FMT_NONE };
+-
+-    auto del = [] (AVBufferSinkParams* p) { av_freep(p); };
+-    std::unique_ptr<AVBufferSinkParams, decltype(del)> buffersinkParams(av_buffersink_params_alloc(), del);
+-
+-    avfilter_register_all();
+-
+     m_pFilterGraph = avfilter_graph_alloc();
+     assert(m_pFilterGraph);
+ 
+@@ -404,10 +402,8 @@
+ 
+     checkRc(avfilter_graph_create_filter(&m_pFilterSource, avfilter_get_by_name("buffer"), "thumb_buffer", ss.str().c_str(), nullptr, m_pFilterGraph),
+             "Failed to create filter source");
+-    buffersinkParams->pixel_fmts = pixelFormats;
+-    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, buffersinkParams.get(), m_pFilterGraph),
++    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, nullptr, m_pFilterGraph),
+             "Failed to create filter sink");
+-    buffersinkParams.release();
+ 
+     AVFilterContext* yadifFilter = nullptr;
+     if (m_pFrame->interlaced_frame != 0)
+@@ -500,15 +496,15 @@
+     }
+ 
+     checkRc(av_seek_frame(m_pFormatContext, -1, timestamp, 0), "Seeking in video failed");
+-    avcodec_flush_buffers(m_pFormatContext->streams[m_VideoStream]->codec);
++    avcodec_flush_buffers(m_pVideoCodecContext);
+ 
+     int keyFrameAttempts = 0;
+-    bool gotFrame = 0;
++    bool gotFrame;
+ 
+     do
+     {
+         int count = 0;
+-        gotFrame = 0;
++        gotFrame = false;
+ 
+         while (!gotFrame && count < 20)
+         {
+@@ -552,17 +548,33 @@
+         return false;
+     }
+ 
+-    av_frame_unref(m_pFrame);
+-
+-    int frameFinished;
++    int rc = avcodec_send_packet(m_pVideoCodecContext, m_pPacket);
++    if(rc == AVERROR(EAGAIN))
++    {
++        rc = 0;
++    }
+ 
+-    int bytesDecoded = avcodec_decode_video2(m_pVideoCodecContext, m_pFrame, &frameFinished, m_pPacket);
+-    if (bytesDecoded < 0)
++    if(rc == AVERROR_EOF)
++    {
++        return false;
++    }
++    else if(rc < 0)
+     {
+-        throw logic_error("Failed to decode video frame: bytesDecoded < 0");
++        throw logic_error("Failed to decode video frame: avcodec_send_packet() < 0");
+     }
+ 
+-    return frameFinished > 0;
++    rc = avcodec_receive_frame(m_pVideoCodecContext, m_pFrame);
++    switch(rc)
++    {
++        case 0:
++            return true;
++
++        case AVERROR(EAGAIN):
++            return false;
++
++        default:
++            throw logic_error("Failed to decode video frame: avcodec_receive_frame() < 0");
++    }
+ }
+ 
+ bool MovieDecoder::getVideoPacket()
+@@ -570,8 +582,6 @@
+     bool framesAvailable = true;
+     bool frameDecoded = false;
+ 
+-    int attempts = 0;
+-
+     if (m_pPacket)
+     {
+         av_packet_unref(m_pPacket);
+@@ -580,6 +590,7 @@
+ 
+     m_pPacket = new AVPacket();
+ 
++
+     while (framesAvailable && !frameDecoded)
+     {
+         framesAvailable = av_read_frame(m_pFormatContext, m_pPacket) >= 0;
+@@ -644,7 +655,7 @@
+ 
+ int32_t MovieDecoder::getStreamRotation()
+ {
+-    int32_t* matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
++    auto matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
+     if (matrix)
+     {
+         auto angle = lround(av_display_rotation_get(matrix));
+
+--- a/libffmpegthumbnailer/moviedecoder.h	2017-11-12 04:23:38.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.h	2023-05-05 13:26:07.095529911 -0400
+@@ -78,7 +78,7 @@
+     int                     m_VideoStream;
+     AVFormatContext*        m_pFormatContext;
+     AVCodecContext*         m_pVideoCodecContext;
+-    AVCodec*                m_pVideoCodec;
++    const AVCodec*          m_pVideoCodec;
+     AVFilterGraph*          m_pFilterGraph;
+     AVFilterContext*        m_pFilterSource;
+     AVFilterContext*        m_pFilterSink;
diff --git a/srcpkgs/ffmpegthumbnailer/template b/srcpkgs/ffmpegthumbnailer/template
index 039eea7622b3..35d546018d12 100644
--- a/srcpkgs/ffmpegthumbnailer/template
+++ b/srcpkgs/ffmpegthumbnailer/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbnailer'
 pkgname=ffmpegthumbnailer
 version=2.2.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libpng-devel libjpeg-turbo-devel ffmpeg-devel"
@@ -9,8 +9,8 @@ depends="ffmpeg"
 short_desc="Lightweight video thumbnailer"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
-homepage="https://github.com/dirkvdb/${pkgname}"
-distfiles="${homepage}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
+homepage="https://github.com/dirkvdb"
+distfiles="${homepage}/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
 checksum=1cb24059c38223f657b300c84dd80491b7040d4b69471c4fea69be862bc99b5b
 
 post_install() {

From b9e08015b85abbd13ba358dac53363ee66ff6833 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 033/115] ffmpegthumbs: revbump for ffmpeg-6.0

---
 srcpkgs/ffmpegthumbs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ffmpegthumbs/template b/srcpkgs/ffmpegthumbs/template
index 5f0b9414dada..11b88193528f 100644
--- a/srcpkgs/ffmpegthumbs/template
+++ b/srcpkgs/ffmpegthumbs/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbs'
 pkgname=ffmpegthumbs
 version=22.12.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules kcoreaddons kconfig-devel
  pkg-config qt5-host-tools qt5-qmake gettext"

From 38b538d95e4853f9258a99740252b20744e4b07c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 034/115] ffms2: revbump for ffmpeg-6.0

---
 srcpkgs/ffms2/patches/ffmpeg5.patch | 424 ++++++++++++++++++++++++++++
 srcpkgs/ffms2/template              |   2 +-
 2 files changed, 425 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ffms2/patches/ffmpeg5.patch

diff --git a/srcpkgs/ffms2/patches/ffmpeg5.patch b/srcpkgs/ffms2/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..1479fabcafcb
--- /dev/null
+++ b/srcpkgs/ffms2/patches/ffmpeg5.patch
@@ -0,0 +1,424 @@
+From 45673149e9a2f5586855ad472e3059084eaa36b1 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:41:21 +0100
+Subject: [PATCH] Use auto for AVCodec
+
+The geniuses over at FFmpeg decided to constify this API, so old
+versions of the library will return AVCodec *, while new versions
+of the libary will return const AVCodec *, which, in C++, are not
+OK to convert between.
+
+Rather than use some macro hell in ffmscompat.h, we can work around
+this by using auto.
+
+Gross.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 2 +-
+ src/core/indexing.cpp    | 6 +++---
+ src/core/videosource.cpp | 2 +-
+ 3 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index e4ce97c..ac09666 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -469,7 +469,7 @@ void FFMS_AudioSource::OpenFile() {
+ 
+     LAVFOpenFile(SourceFile.c_str(), FormatContext, TrackNumber);
+ 
+-    AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
++    auto *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
+     if (Codec == nullptr)
+         throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+             "Audio codec not found");
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index e547c5a..59fb4e8 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -384,7 +384,7 @@ FFMS_TrackType FFMS_Indexer::GetTrackType(int Track) {
+ }
+ 
+ const char *FFMS_Indexer::GetTrackCodec(int Track) {
+-    AVCodec *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
++    auto *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
+     return codec ? codec->name : nullptr;
+ }
+ 
+@@ -402,7 +402,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             UseDTS);
+ 
+         if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            AVCodec *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (!VideoCodec) {
+                 FormatContext->streams[i]->discard = AVDISCARD_ALL;
+                 IndexMask.erase(i);
+@@ -433,7 +433,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 IndexMask.insert(i);
+             }
+         } else if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+-            AVCodec *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (AudioCodec == nullptr)
+                 throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_UNSUPPORTED,
+                     "Audio codec not found");
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index b889970..8956c22 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -171,7 +171,7 @@ FFMS_VideoSource::FFMS_VideoSource(const char *SourceFile, FFMS_Index &Index, in
+ 
+         LAVFOpenFile(SourceFile, FormatContext, VideoTrack);
+ 
+-        AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
++        auto *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
+         if (Codec == nullptr)
+             throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+                 "Video codec not found");
+-- 
+2.40.0
+
+From 96cbf38ea9381829a1314f432a2c60495dcefaad Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:12:41 +0100
+Subject: [PATCH] all: Update AVPacket API usage
+
+AVPackets must all be on the heap now, since it is no longer
+part of the libav* ABI.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 16 ++++++----
+ src/core/indexing.cpp    | 63 ++++++++++++++++++++++------------------
+ src/core/indexing.h      |  4 +--
+ src/core/utils.cpp       |  6 ----
+ src/core/utils.h         |  1 -
+ src/core/videosource.cpp | 30 ++++++++++---------
+ 6 files changed, 64 insertions(+), 56 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index 37cf9ae..e4ce97c 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -285,10 +285,15 @@ FFMS_AudioSource::AudioBlock *FFMS_AudioSource::CacheBlock(CacheIterator &pos) {
+ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     CurrentFrame = &Frames[PacketNumber];
+ 
+-    AVPacket Packet;
+-    if (!ReadPacket(&Packet))
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++    if (!ReadPacket(Packet)) {
++        av_packet_free(&Packet);
+         throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_UNKNOWN,
+             "ReadPacket unexpectedly failed to read a packet");
++    }
+ 
+     // ReadPacket may have changed the packet number
+     CurrentFrame = &Frames[PacketNumber];
+@@ -297,8 +302,9 @@ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     int NumberOfSamples = 0;
+     AudioBlock *CachedBlock = nullptr;
+     
+-    int Ret = avcodec_send_packet(CodecContext, &Packet);
+-    av_packet_unref(&Packet);
++    int Ret = avcodec_send_packet(CodecContext, Packet);
++    av_packet_unref(Packet);
++    av_packet_free(&Packet);
+ 
+     av_frame_unref(DecodeFrame);
+     Ret = avcodec_receive_frame(CodecContext, DecodeFrame);
+@@ -513,8 +519,6 @@ void FFMS_AudioSource::Seek() {
+ }
+ 
+ bool FFMS_AudioSource::ReadPacket(AVPacket *Packet) {
+-    InitNullPacket(*Packet);
+-
+     while (av_read_frame(FormatContext, Packet) >= 0) {
+         if (Packet->stream_index == TrackNumber) {
+             // Required because not all audio packets, especially in ogg, have a pts. Use the previous valid packet's pts instead.
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index 23fb95b..e547c5a 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -320,7 +320,7 @@ void FFMS_Indexer::CheckAudioProperties(int Track, AVCodecContext *Context) {
+     }
+ }
+ 
+-void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict,
++void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict,
+                                     int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct) {
+     if (VideoContext.Parser) {
+         uint8_t *OB;
+@@ -330,8 +330,8 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+         av_parser_parse2(VideoContext.Parser,
+             VideoContext.CodecContext,
+             &OB, &OBSize,
+-            pkt.data, pkt.size,
+-            pkt.pts, pkt.dts, pkt.pos);
++            pkt->data, pkt->size,
++            pkt->pts, pkt->dts, pkt->pos);
+ 
+         // H.264 (PAFF) and HEVC may have one field per packet, so we need to track
+         // when we have a full or half frame available, and mark one of them as
+@@ -351,15 +351,15 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+ 
+         *RepeatPict = VideoContext.Parser->repeat_pict;
+         *FrameType = VideoContext.Parser->pict_type;
+-        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt.flags & AV_PKT_FLAG_DISCARD));
++        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt->flags & AV_PKT_FLAG_DISCARD));
+     } else {
+-        *Invisible = !!(pkt.flags & AV_PKT_FLAG_DISCARD);
++        *Invisible = !!(pkt->flags & AV_PKT_FLAG_DISCARD);
+     }
+ 
+     if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP8)
+-        ParseVP8(pkt.data[0], Invisible, FrameType);
++        ParseVP8(pkt->data[0], Invisible, FrameType);
+     else if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP9)
+-        ParseVP9(pkt.data[0], Invisible, FrameType);
++        ParseVP9(pkt->data[0], Invisible, FrameType);
+ }
+ 
+ void FFMS_Indexer::Free() {
+@@ -458,32 +458,36 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+         }
+     }
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
+     std::vector<int64_t> LastValidTS(FormatContext->nb_streams, AV_NOPTS_VALUE);
+ 
+     int64_t filesize = avio_size(FormatContext->pb);
+     enum AVPictureStructure LastPicStruct = AV_PICTURE_STRUCTURE_UNKNOWN;
+-    while (av_read_frame(FormatContext, &Packet) >= 0) {
++    while (av_read_frame(FormatContext, Packet) >= 0) {
+         // Update progress
+         // FormatContext->pb can apparently be NULL when opening images.
+         if (IC && FormatContext->pb) {
+-            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate))
++            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate)) {
++                av_packet_free(&Packet);
+                 throw FFMS_Exception(FFMS_ERROR_CANCELLED, FFMS_ERROR_USER,
+                     "Cancelled by user");
++            }
+         }
+-        if (!IndexMask.count(Packet.stream_index)) {
+-            av_packet_unref(&Packet);
++        if (!IndexMask.count(Packet->stream_index)) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+-        int Track = Packet.stream_index;
++        int Track = Packet->stream_index;
+         FFMS_Track &TrackInfo = (*TrackIndices)[Track];
+-        bool KeyFrame = !!(Packet.flags & AV_PKT_FLAG_KEY);
++        bool KeyFrame = !!(Packet->flags & AV_PKT_FLAG_KEY);
+         ReadTS(Packet, LastValidTS[Track], (*TrackIndices)[Track].UseDTS);
+ 
+         if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            int64_t PTS = TrackInfo.UseDTS ? Packet.dts : Packet.pts;
++            int64_t PTS = TrackInfo.UseDTS ? Packet->dts : Packet->pts;
+             if (PTS == AV_NOPTS_VALUE) {
+                 // VPx alt-refs are output as packets which lack timestmps or durations, since
+                 // they are invisible. Currently, the timestamp mangling code in libavformat
+@@ -495,9 +499,11 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 // FFMS2 currently sorts packets by PTS, which will break decoding, otherwise.
+                 bool HasAltRefs = (FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP8 ||
+                                    FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP9);
+-                if (Packet.duration == 0 && !HasAltRefs)
++                if (Packet->duration == 0 && !HasAltRefs) {
++                    av_packet_free(&Packet);
+                     throw FFMS_Exception(FFMS_ERROR_INDEXING, FFMS_ERROR_PARSER,
+                         "Invalid packet pts, dts, and duration");
++                }
+ 
+                 if (TrackInfo.empty())
+                     PTS = 0;
+@@ -513,7 +519,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             ParseVideoPacket(AVContexts[Track], Packet, &RepeatPict, &FrameType, &Invisible, &LastPicStruct);
+ 
+             TrackInfo.AddVideoFrame(PTS, RepeatPict, KeyFrame,
+-                FrameType, Packet.pos, Invisible);
++                FrameType, Packet->pos, Invisible);
+         } else if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+             // For video seeking timestamps are used only if all packets have
+             // timestamps, while for audio they're used if any have timestamps,
+@@ -522,28 +528,29 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 TrackInfo.HasTS = true;
+ 
+             int64_t StartSample = AVContexts[Track].CurrentSample;
+-            uint32_t SampleCount = IndexAudioPacket(Track, &Packet, AVContexts[Track], *TrackIndices);
++            uint32_t SampleCount = IndexAudioPacket(Track, Packet, AVContexts[Track], *TrackIndices);
+             TrackInfo.SampleRate = AVContexts[Track].CodecContext->sample_rate;
+ 
+             TrackInfo.AddAudioFrame(LastValidTS[Track],
+-                StartSample, SampleCount, KeyFrame, Packet.pos, Packet.flags & AV_PKT_FLAG_DISCARD);
++                StartSample, SampleCount, KeyFrame, Packet->pos, Packet->flags & AV_PKT_FLAG_DISCARD);
+         }
+ 
+-        if (!(Packet.flags & AV_PKT_FLAG_DISCARD))
+-            TrackInfo.LastDuration = Packet.duration;
++        if (!(Packet->flags & AV_PKT_FLAG_DISCARD))
++            TrackInfo.LastDuration = Packet->duration;
+ 
+-        av_packet_unref(&Packet);
++        av_packet_unref(Packet);
+     }
++    av_packet_free(&Packet);
+ 
+     TrackIndices->Finalize(AVContexts, FormatContext->iformat->name);
+     return TrackIndices.release();
+ }
+ 
+-void FFMS_Indexer::ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS) {
+-    if (!UseDTS && Packet.pts != AV_NOPTS_VALUE)
+-        TS = Packet.pts;
++void FFMS_Indexer::ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS) {
++    if (!UseDTS && Packet->pts != AV_NOPTS_VALUE)
++        TS = Packet->pts;
+     if (TS == AV_NOPTS_VALUE)
+         UseDTS = true;
+-    if (UseDTS && Packet.dts != AV_NOPTS_VALUE)
+-        TS = Packet.dts;
++    if (UseDTS && Packet->dts != AV_NOPTS_VALUE)
++        TS = Packet->dts;
+ }
+diff --git a/src/core/indexing.h b/src/core/indexing.h
+index 3cfc3c3..5c06868 100644
+--- a/src/core/indexing.h
++++ b/src/core/indexing.h
+@@ -80,10 +80,10 @@ private:
+     int64_t Filesize;
+     uint8_t Digest[20];
+ 
+-    void ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS);
++    void ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS);
+     void CheckAudioProperties(int Track, AVCodecContext *Context);
+     uint32_t IndexAudioPacket(int Track, AVPacket *Packet, SharedAVContext &Context, FFMS_Index &TrackIndices);
+-    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
++    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
+     void Free();
+ public:
+     FFMS_Indexer(const char *Filename);
+diff --git a/src/core/utils.cpp b/src/core/utils.cpp
+index ce67533..8a2e997 100644
+--- a/src/core/utils.cpp
++++ b/src/core/utils.cpp
+@@ -62,12 +62,6 @@ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo) {
+     }
+ }
+ 
+-void InitNullPacket(AVPacket &pkt) {
+-    av_init_packet(&pkt);
+-    pkt.data = nullptr;
+-    pkt.size = 0;
+-}
+-
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames) {
+     AP.SampleFormat = static_cast<FFMS_SampleFormat>(av_get_packed_sample_fmt(CTX->sample_fmt));
+     AP.BitsPerSample = av_get_bytes_per_sample(CTX->sample_fmt) * 8;
+diff --git a/src/core/utils.h b/src/core/utils.h
+index 9819dc7..003ab79 100644
+--- a/src/core/utils.h
++++ b/src/core/utils.h
+@@ -58,7 +58,6 @@ std::unique_ptr<T> make_unique(Args&&... args) {
+ }
+ 
+ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo);
+-void InitNullPacket(AVPacket &pkt);
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames);
+ 
+ void LAVFOpenFile(const char *SourceFile, AVFormatContext *&FormatContext, int Track);
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index 06bd161..b889970 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -673,30 +673,34 @@ void FFMS_VideoSource::DecodeNextFrame(int64_t &AStartTime, int64_t &Pos) {
+     if (HasPendingDelayedFrames())
+         return;
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
+-
+-    while (ReadFrame(&Packet) >= 0) {
+-        if (Packet.stream_index != VideoTrack) {
+-            av_packet_unref(&Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++
++    while (ReadFrame(Packet) >= 0) {
++        if (Packet->stream_index != VideoTrack) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+         if (AStartTime < 0)
+-            AStartTime = Frames.UseDTS ? Packet.dts : Packet.pts;
++            AStartTime = Frames.UseDTS ? Packet->dts : Packet->pts;
+ 
+         if (Pos < 0)
+-            Pos = Packet.pos;
++            Pos = Packet->pos;
+ 
+-        bool FrameFinished = DecodePacket(&Packet);
+-        av_packet_unref(&Packet);
+-        if (FrameFinished)
++        bool FrameFinished = DecodePacket(Packet);
++        av_packet_unref(Packet);
++        if (FrameFinished) {
++            av_packet_free(&Packet);
+             return;
++        }
+     }
+ 
+     // Flush final frames
+-    InitNullPacket(Packet);
+-    DecodePacket(&Packet);
++    DecodePacket(Packet);
++    av_packet_free(&Packet);
+ }
+ 
+ bool FFMS_VideoSource::SeekTo(int n, int SeekOffset) {
+-- 
+2.40.0
+
+From bf9e03e9e08534c024e5a744a6437c4aac160201 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:20:47 +0100
+Subject: [PATCH 2/3] configure: Remove deprecated API use
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ configure.ac | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index b35ef80bc..d19714d0f 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -102,10 +102,10 @@ CFLAGS="$_CFLAGS $FFMPEG_CFLAGS"
+
+ AC_DEFUN([TEST_FFMPEG],
+          [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+-            #include <libavcodec/avcodec.h>
++            #include <libavformat/avformat.h>
+             #include <libswscale/swscale.h>
+             ]],[[
+-                avcodec_register_all();
++                avformat_network_init();
+                 swscale_version();
+             ]])], [eval $1=yes], [eval $1=no])
+         ])
+
diff --git a/srcpkgs/ffms2/template b/srcpkgs/ffms2/template
index 68e8a0c14bce..2acfadac44b3 100644
--- a/srcpkgs/ffms2/template
+++ b/srcpkgs/ffms2/template
@@ -1,7 +1,7 @@
 # Template file for 'ffms2'
 pkgname=ffms2
 version=2.40
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-shared --disable-static"
 hostmakedepends="pkg-config autoconf automake libtool"

From 77022e3b06605fb7136dedb2af97f77a28ae9213 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 035/115] freerdp: revbump for ffmpeg-6.0

---
 .../freerdp/patches/ffmpeg6_aa2cb9aa.patch    | 42 +++++++++++++++++++
 srcpkgs/freerdp/template                      |  2 +-
 2 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch

diff --git a/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
new file mode 100644
index 000000000000..a4324da3a882
--- /dev/null
+++ b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
@@ -0,0 +1,42 @@
+From aa2cb9aa5ff5562433598ba168a466e0752bca0e Mon Sep 17 00:00:00 2001
+From: akallabeth <akallabeth@posteo.net>
+Date: Tue, 14 Feb 2023 07:48:54 +0100
+Subject: [PATCH] Fixed #8686: Update h264 to use new FFMPEG API
+
+---
+ channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c | 2 ++
+ libfreerdp/codec/h264_ffmpeg.c            | 2 ++
+ 2 files changed, 4 insertions(+)
+
+diff --git a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+index 339462d865f..beea80b7a1e 100644
+--- a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
++++ b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+@@ -239,8 +239,10 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYP
+ 		}
+ 	}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 	if (mdecoder->codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		mdecoder->codec_context->flags |= AV_CODEC_FLAG_TRUNCATED;
++#endif
+ 
+ 	return TRUE;
+ }
+diff --git a/libfreerdp/codec/h264_ffmpeg.c b/libfreerdp/codec/h264_ffmpeg.c
+index 8a23db2473c..896a333019b 100644
+--- a/libfreerdp/codec/h264_ffmpeg.c
++++ b/libfreerdp/codec/h264_ffmpeg.c
+@@ -615,10 +615,12 @@ static BOOL libavcodec_init(H264_CONTEXT* h264)
+ 			goto EXCEPTION;
+ 		}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 		if (sys->codecDecoder->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		{
+ 			sys->codecDecoderContext->flags |= AV_CODEC_FLAG_TRUNCATED;
+ 		}
++#endif
+ 
+ #ifdef WITH_VAAPI
+ 
diff --git a/srcpkgs/freerdp/template b/srcpkgs/freerdp/template
index 25e8aa9677f0..4d51c8189902 100644
--- a/srcpkgs/freerdp/template
+++ b/srcpkgs/freerdp/template
@@ -1,7 +1,7 @@
 # Template file for 'freerdp'
 pkgname=freerdp
 version=2.10.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_ALSA=ON -DWITH_CUPS=OFF -DWITH_FFMPEG=ON
  -DWITH_GSTREAMER_0_10=OFF -DWITH_GSTREAMER_1_0=OFF -DWITH_JPEG=ON

From e0d5b2fe8f3161cf97a6ec408e545c67685ef5b8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 036/115] gerbera: revbump for ffmpeg-6.0

---
 srcpkgs/gerbera/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gerbera/template b/srcpkgs/gerbera/template
index ae14f35c767c..2dc0ac0ce03b 100644
--- a/srcpkgs/gerbera/template
+++ b/srcpkgs/gerbera/template
@@ -1,7 +1,7 @@
 # Template file for 'gerbera'
 pkgname=gerbera
 version=1.12.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_SYSTEMD=0 -DWITH_AVCODEC=1"
 hostmakedepends="pkg-config"

From 872c374a087c0eafd0f810de1553efac47ed0cd6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 037/115] goldendict: revbump for ffmpeg-6.0

---
 srcpkgs/goldendict/patches/ffmpeg4.patch |  21 --
 srcpkgs/goldendict/patches/ffmpeg5.patch | 232 +++++++++++++++++++++++
 srcpkgs/goldendict/template              |   2 +-
 3 files changed, 233 insertions(+), 22 deletions(-)
 delete mode 100644 srcpkgs/goldendict/patches/ffmpeg4.patch
 create mode 100644 srcpkgs/goldendict/patches/ffmpeg5.patch

diff --git a/srcpkgs/goldendict/patches/ffmpeg4.patch b/srcpkgs/goldendict/patches/ffmpeg4.patch
deleted file mode 100644
index f045fa27f54b..000000000000
--- a/srcpkgs/goldendict/patches/ffmpeg4.patch
+++ /dev/null
@@ -1,21 +0,0 @@
---- a/ffmpegaudio.cc.orig 2018-05-09 22:16:13.480659958 +0200
-+++ b/ffmpegaudio.cc      2018-05-09 22:16:50.748322790 +0200
-@@ -143,7 +143,7 @@
-     return false;
-   }
-
--  unsigned char * avioBuffer = ( unsigned char * )av_malloc( kBufferSize + FF_INPUT_BUFFER_PADDING_SIZE );
-+  unsigned char * avioBuffer = ( unsigned char * )av_malloc( kBufferSize + AV_INPUT_BUFFER_PADDING_SIZE );
-   if ( !avioBuffer )
-   {
-     errorString = QObject::tr( "av_malloc() failed." );
-@@ -380,7 +380,7 @@
-   }
-
-   if ( !Qt4x5::AtomicInt::loadAcquire( isCancelled_ ) &&
--       codecContext_->codec->capabilities & CODEC_CAP_DELAY )
-+       codecContext_->codec->capabilities & AV_CODEC_CAP_DELAY )
-   {
-     av_init_packet( &packet );
-     int gotFrame = 0;
-
diff --git a/srcpkgs/goldendict/patches/ffmpeg5.patch b/srcpkgs/goldendict/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..7cfc98ada368
--- /dev/null
+++ b/srcpkgs/goldendict/patches/ffmpeg5.patch
@@ -0,0 +1,232 @@
+From 03bbe01b79a1f07a6780cb60f23a087104c5d77b Mon Sep 17 00:00:00 2001
+From: Abs62 <ottomann@yandex.ru>
+Date: Fri, 30 Mar 2018 22:53:24 +0300
+Subject: [PATCH] Fix warnings while compile with FFMpeg 3.4.2 (issue #978)
+
+---
+ ffmpegaudio.cc | 68 +++++++++++++++++++++++++++++++++++++++++++++-----
+ 1 file changed, 62 insertions(+), 6 deletions(-)
+
+diff --git a/ffmpegaudio.cc b/ffmpegaudio.cc
+index ed1172bdd..56e8f788e 100644
+--- a/ffmpegaudio.cc
++++ b/ffmpegaudio.cc
+@@ -91,6 +91,7 @@ struct DecoderContext
+   QByteArray audioData_;
+   QDataStream audioDataStream_;
+   AVFormatContext * formatContext_;
++  AVCodec * codec_;
+   AVCodecContext * codecContext_;
+   AVIOContext * avioContext_;
+   AVStream * audioStream_;
+@@ -114,6 +115,7 @@ DecoderContext::DecoderContext( QByteArray const & audioData, QAtomicInt & isCan
+   audioData_( audioData ),
+   audioDataStream_( audioData_ ),
+   formatContext_( NULL ),
++  codec_( NULL ),
+   codecContext_( NULL ),
+   avioContext_( NULL ),
+   audioStream_( NULL ),
+@@ -143,7 +145,11 @@ bool DecoderContext::openCodec( QString & errorString )
+     return false;
+   }
+
++#if LIBAVCODEC_VERSION_MAJOR < 56 || ( LIBAVCODEC_VERSION_MAJOR == 56 && LIBAVCODEC_VERSION_MINOR < 56 )
+   unsigned char * avioBuffer = ( unsigned char * )av_malloc( kBufferSize + FF_INPUT_BUFFER_PADDING_SIZE );
++#else
++  unsigned char * avioBuffer = ( unsigned char * )av_malloc( kBufferSize + AV_INPUT_BUFFER_PADDING_SIZE );
++#endif
+   if ( !avioBuffer )
+   {
+     errorString = QObject::tr( "av_malloc() failed." );
+@@ -186,7 +192,11 @@ bool DecoderContext::openCodec( QString & errorString )
+   // Find audio stream, use the first audio stream if available
+   for ( unsigned i = 0; i < formatContext_->nb_streams; i++ )
+   {
++#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 33 )
+     if ( formatContext_->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO )
++#else
++      if ( formatContext_->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO )
++#endif
+     {
+       audioStream_ = formatContext_->streams[i];
+       break;
+@@ -198,22 +208,38 @@ bool DecoderContext::openCodec( QString & errorString )
+     return false;
+   }
+
++#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 33 )
+   codecContext_ = audioStream_->codec;
+-  AVCodec * codec = avcodec_find_decoder( codecContext_->codec_id );
+-  if ( !codec )
++  codec_ = avcodec_find_decoder( codecContext_->codec_id );
++  if ( !codec_ )
+   {
+     errorString = QObject::tr( "Codec [id: %1] not found." ).arg( codecContext_->codec_id );
+     return false;
+   }
++#else
++  codec_ = avcodec_find_decoder( audioStream_->codecpar->codec_id );
++  if ( !codec_ )
++  {
++    errorString = QObject::tr( "Codec [id: %1] not found." ).arg( audioStream_->codecpar->codec_id );
++    return false;
++  }
++  codecContext_ = avcodec_alloc_context3( codec_ );
++  if ( !codecContext_ )
++  {
++    errorString = QObject::tr( "avcodec_alloc_context3() failed." );
++    return false;
++  }
++  avcodec_parameters_to_context( codecContext_, audioStream_->codecpar );
++#endif
+
+-  ret = avcodec_open2( codecContext_, codec, NULL );
++  ret = avcodec_open2( codecContext_, codec_, NULL );
+   if ( ret < 0 )
+   {
+     errorString = QObject::tr( "avcodec_open2() failed: %1." ).arg( avErrorString( ret ) );
+     return false;
+   }
+
+-  av_log( NULL, AV_LOG_INFO, "Codec open: %s: channels: %d, rate: %d, format: %s\n", codec->long_name,
++  av_log( NULL, AV_LOG_INFO, "Codec open: %s: channels: %d, rate: %d, format: %s\n", codec_->long_name,
+           codecContext_->channels, codecContext_->sample_rate, av_get_sample_fmt_name( codecContext_->sample_fmt ) );
+   return true;
+ }
+@@ -252,10 +278,13 @@ void DecoderContext::closeCodec()
+
+   // Closing a codec context without prior avcodec_open2() will result in
+   // a crash in ffmpeg
+-  if ( audioStream_ && audioStream_->codec && audioStream_->codec->codec )
++  if ( audioStream_ && codecContext_ && codec_ )
+   {
+     audioStream_->discard = AVDISCARD_ALL;
+-    avcodec_close( audioStream_->codec );
++    avcodec_close( codecContext_ );
++#if LIBAVCODEC_VERSION_MAJOR > 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR >= 33 )
++    avcodec_free_context( &codecContext_ );
++#endif
+   }
+
+   avformat_close_input( &formatContext_ );
+@@ -356,6 +385,7 @@ bool DecoderContext::play( QString & errorString )
+     if ( packet.stream_index == audioStream_->index )
+     {
+       AVPacket pack = packet;
++#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 37 )
+       int gotFrame = 0;
+       do
+       {
+@@ -370,6 +400,19 @@ bool DecoderContext::play( QString & errorString )
+         pack.data += len;
+       }
+       while( pack.size > 0 );
++#else
++      int ret = avcodec_send_packet( codecContext_, &pack );
++      /* read all the output frames (in general there may be any number of them) */
++      while( ret >= 0 )
++      {
++        ret = avcodec_receive_frame( codecContext_, frame);
++
++        if ( Qt4x5::AtomicInt::loadAcquire( isCancelled_ ) || ret < 0 )
++          break;
++
++        playFrame( frame );
++      }
++#endif
+     }
+     // av_free_packet() must be called after each call to av_read_frame()
+ #if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 7 )
+@@ -379,6 +422,7 @@ bool DecoderContext::play( QString & errorString )
+ #endif
+   }
+
++#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 37 )
+   if ( !Qt4x5::AtomicInt::loadAcquire( isCancelled_ ) &&
+        codecContext_->codec->capabilities & CODEC_CAP_DELAY )
+   {
+@@ -391,6 +435,18 @@ bool DecoderContext::play( QString & errorString )
+       playFrame( frame );
+     }
+   }
++#else
++  /* flush the decoder */
++  av_init_packet( &packet );
++  int ret = avcodec_send_packet(codecContext_, &packet );
++  while( ret >= 0 )
++  {
++    ret = avcodec_receive_frame(codecContext_, frame);
++    if ( Qt4x5::AtomicInt::loadAcquire( isCancelled_ ) || ret < 0 )
++      break;
++    playFrame( frame );
++  }
++#endif
+
+ #if LIBAVCODEC_VERSION_MAJOR < 54
+   av_free( frame );
+32
+srcpkgs/goldendict/patches/ffmpeg5-2.patch
+Comment on this file
+@@ -0,0 +1,32 @@
+From 966f4a8b78e6324b930e5a50f2bb930bd87e565e Mon Sep 17 00:00:00 2001
+From: Abs62 <ottomann@yandex.ru>
+Date: Fri, 27 Sep 2019 17:00:52 +0300
+Subject: [PATCH] FFmpeg player: Fix some crashes on broken files
+
+---
+ ffmpegaudio.cc | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/ffmpegaudio.cc b/ffmpegaudio.cc
+index 56e8f788e..415fc79cb 100644
+--- a/ffmpegaudio.cc
++++ b/ffmpegaudio.cc
+@@ -51,7 +51,9 @@ AudioService & AudioService::instance()
+
+ AudioService::AudioService()
+ {
++#if LIBAVFORMAT_VERSION_MAJOR < 58 || ( LIBAVFORMAT_VERSION_MAJOR == 58 && LIBAVFORMAT_VERSION_MINOR < 9 )
+   av_register_all();
++#endif
+   ao_initialize();
+ }
+
+@@ -438,6 +440,8 @@ bool DecoderContext::play( QString & errorString )
+ #else
+   /* flush the decoder */
+   av_init_packet( &packet );
++  packet.data = NULL;
++  packet.size = 0;
+   int ret = avcodec_send_packet(codecContext_, &packet );
+   while( ret >= 0 )
+   {
+25
+srcpkgs/goldendict/patches/ffmpeg5-3.patch
+Comment on this file
+@@ -0,0 +1,25 @@
+From 8acb288c9e9bdb3c6bf2e803954dd3b6ac273c05 Mon Sep 17 00:00:00 2001
+From: Liao Junxuan <mikeljx@126.com>
+Date: Sun, 20 Feb 2022 12:28:05 +0800
+Subject: [PATCH] add support for ffmpeg 5.0
+
+---
+ ffmpegaudio.cc | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/ffmpegaudio.cc b/ffmpegaudio.cc
+index d550f4a77..7948d2187 100644
+--- a/ffmpegaudio.cc
++++ b/ffmpegaudio.cc
+@@ -94,7 +94,11 @@ struct DecoderContext
+   QByteArray audioData_;
+   QDataStream audioDataStream_;
+   AVFormatContext * formatContext_;
++#if LIBAVCODEC_VERSION_MAJOR < 59
+   AVCodec * codec_;
++#else
++  const AVCodec * codec_;
++#endif
+   AVCodecContext * codecContext_;
+   AVIOContext * avioContext_;
+   AVStream * audioStream_;
diff --git a/srcpkgs/goldendict/template b/srcpkgs/goldendict/template
index 4544ae710ee6..2ca4185e538a 100644
--- a/srcpkgs/goldendict/template
+++ b/srcpkgs/goldendict/template
@@ -9,7 +9,7 @@ makedepends="tiff-devel qt5-devel libvorbis-devel zlib-devel
  libXtst-devel hunspell-devel qt5-tools-devel qt5-declarative-devel
  qt5-webkit-devel lzo-devel bzip2-devel libao-devel qt5-svg-devel
  libeb-devel qt5-x11extras-devel ffmpeg-devel liblzma-devel"
-short_desc="A feature-rich dictionary lookup program"
+short_desc="Feature-rich dictionary lookup program"
 maintainer="John <me@johnnynator.dev>"
 license="GPL-3.0-or-later"
 homepage="http://goldendict.org/"

From 8e543c52185fd5addb6bd23853d3281b1a409c53 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 038/115] gst-libav: revbump for ffmpeg-6.0

---
 srcpkgs/gst-libav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index e9a79dc650a5..f082bd211c65 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.20.3
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"

From b27c77222a598398b80a26af8e68dade86bd0368 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 039/115] gst-plugins-bad1: revbump for ffmpeg-6.0

---
 srcpkgs/gst-plugins-bad1/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index f55f82fd4c77..dc9d389734e1 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-plugins-bad1'
 pkgname=gst-plugins-bad1
-version=1.20.3
-revision=3
+version=1.22.2
+revision=2
 build_helper="gir"
 build_style=meson
 configure_args="-Dpackage-origin=https://voidlinux.org -Ddoc=disabled

From 14d2c4c80459b8262b50b5941c183e844d246021 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 040/115] gst-rtsp-server: revbump for ffmpeg-6.0

---
 srcpkgs/gst-rtsp-server/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index 33cd64ceb95e..8ceea8d34b4b 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
 version=1.20.3
-revision=2
+revision=3
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="glib-devel gst-plugins-bad1-devel gobject-introspection

From 7f92e03a2fe7bd6a7d0b761ca0443936809e69da Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 041/115] guvcview: update to 2.0.8.

---
 srcpkgs/guvcview/patches/fix-include.patch | 10 ++++++++++
 srcpkgs/guvcview/template                  |  5 ++---
 2 files changed, 12 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/guvcview/patches/fix-include.patch

diff --git a/srcpkgs/guvcview/patches/fix-include.patch b/srcpkgs/guvcview/patches/fix-include.patch
new file mode 100644
index 000000000000..503c2af3b78c
--- /dev/null
+++ b/srcpkgs/guvcview/patches/fix-include.patch
@@ -0,0 +1,10 @@
+--- a/guvcview/guvcview.c
++++ b/guvcview/guvcview.c
+@@ -28,6 +28,7 @@
+ #include <sys/stat.h>
+ #include <sys/resource.h>
+ #include <errno.h>
++#include <locale.h>
+ 
+ #include "gview.h"
+ #include "gviewv4l2core.h"
diff --git a/srcpkgs/guvcview/template b/srcpkgs/guvcview/template
index 345cf6006f24..86a7fd619612 100644
--- a/srcpkgs/guvcview/template
+++ b/srcpkgs/guvcview/template
@@ -1,8 +1,7 @@
 # Template file for 'guvcview'
 pkgname=guvcview
-version=2.0.7
+version=2.0.8
 revision=1
-create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-static --disable-debian-menu"
 hostmakedepends="pkg-config intltool autoconf automake libtool glib-devel"
@@ -14,7 +13,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="http://guvcview.sourceforge.net/"
 distfiles="${SOURCEFORGE_SITE}/${pkgname}/${pkgname}-src-${version}.tar.bz2"
-checksum=f47d51fbd06e44eeaa1a82f4a153c927527c90d94514197a70b2956028cc8ad4
+checksum=a21f4e448286666cf27bafef5290cc953a0a1796b752e5bbe521266dc1230c81
 
 post_patch() {
 	sed '31a#include <locale.h>' -i  guvcview/guvcview.c

From 8798183713e1fa68b9078dd31f134c0f53bbc657 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 042/115] handbrake: update to 1.6.1

---
 .../patches/fix-missing-x265-link-flag.patch    | 11 ++++++-----
 .../handbrake/patches/libhb-vpl-include.patch   | 15 +++++++++++++++
 srcpkgs/handbrake/template                      | 17 ++++++++++-------
 3 files changed, 31 insertions(+), 12 deletions(-)
 create mode 100644 srcpkgs/handbrake/patches/libhb-vpl-include.patch

diff --git a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
index 26db03867a0c..d6bb2eda627a 100644
--- a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
+++ b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
@@ -1,14 +1,15 @@
 --- a/gtk/configure.ac
 +++ b/gtk/configure.ac
 @@ -203,7 +203,7 @@
- 
+
  AM_CONDITIONAL([MINGW], [test "x$mingw_flag" = "xyes"])
- 
--HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg"
-+HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -ldl"
+
+-HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc"
++HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc -ldl"
  HB_CPPFLAGS="$HB_CPPFLAGS $HBINC"
- 
+
  PKG_CHECK_MODULES([x264], [x264], sys_x264=yes, sys_x264=no)
+
 --- a/test/module.defs
 +++ b/test/module.defs
 @@ -69,6 +69,9 @@
diff --git a/srcpkgs/handbrake/patches/libhb-vpl-include.patch b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
new file mode 100644
index 000000000000..298f9f4ab28f
--- /dev/null
+++ b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
@@ -0,0 +1,15 @@
+--- a/libhb/module.defs	2023-01-22 11:36:49.000000000 -0500
++++ b/libhb/module.defs	2023-04-03 22:37:52.395467010 -0400
+@@ -46,11 +46,7 @@
+ LIBHB.GCC.I += $(LIBHB.build/) $(CONTRIB.build/)include
+ 
+ ifeq (1,$(FEATURE.qsv))
+-    ifeq ($(HOST.system),freebsd))
+-        LIBHB.GCC.I += $(LOCALBASE)/include/vpl
+-    else
+-        LIBHB.GCC.I += $(CONTRIB.build/)include/vpl
+-    endif
++    LIBHB.GCC.I += /usr/include/vpl
+ endif
+ 
+ ifneq (,$(filter $(HOST.system),freebsd netbsd openbsd))
diff --git a/srcpkgs/handbrake/template b/srcpkgs/handbrake/template
index ca5e4571e49c..c32cb1bfa31f 100644
--- a/srcpkgs/handbrake/template
+++ b/srcpkgs/handbrake/template
@@ -1,10 +1,10 @@
 # Template file for 'handbrake'
 pkgname=handbrake
-version=1.5.1
+version=1.6.1
 revision=1
 build_style=gnu-configure
 configure_args="--force --disable-gtk-update-checks --disable-df-fetch --harden
- $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc)"
+ $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc) $(vopt_enable qsv)"
 make_build_args="-C ${XBPS_TRIPLET}"
 make_install_args="-C ${XBPS_TRIPLET}"
 hostmakedepends="automake cmake gettext-devel glib-devel intltool libtool m4 meson nasm pkg-config python3"
@@ -12,8 +12,11 @@ makedepends="bzip2-devel ffmpeg-devel gst-plugins-base1-devel gtk+3-devel
  jansson-devel lame-devel libass-devel libbluray-devel libdav1d-devel
  libdvdnav-devel libdvdread-devel libgudev-devel libnuma-devel
  libsamplerate-devel libtheora-devel libvorbis-devel libvpx-devel libxml2-devel
- opus-devel speex-devel x264-devel x265-devel zimg-devel
+ opus-devel speex-devel x264-devel x265-devel zimg-devel libsvt-av1-devel
  $(vopt_if fdk_aac fdk-aac-devel)
+ $(vopt_if qsv libva-devel)
+ $(vopt_if qsv libdrm-devel)
+ $(vopt_if qsv onevpl-devel)
  $(vopt_if nvenc nv-codec-headers)"
 depends="desktop-file-utils gst-plugins-good1 hicolor-icon-theme"
 short_desc="Multithreaded video transcoder"
@@ -21,15 +24,15 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-2.0-only"
 homepage="https://handbrake.fr/"
 distfiles="https://github.com/HandBrake/HandBrake/releases/download/${version}/HandBrake-${version}-source.tar.bz2"
-checksum=3999fe06d5309c819799a73a968a8ec3840e7840c2b64af8f5cdb7fd8c9430f0
+checksum=94ccfe03db917a91650000c510f7fd53f844da19f19ad4b4be1b8f6bc31a8d4c
 nocross=yes
 
-build_options="fdk_aac nvenc"
+build_options="fdk_aac nvenc qsv"
 
 case "$XBPS_TARGET_MACHINE" in
 	x86_64*|i686*)
 		CFLAGS="-msse"
-		build_options_default="nvenc"
+		build_options_default="nvenc qsv"
 		;;
 esac
 
@@ -37,7 +40,7 @@ pre_configure() {
 	# use system libraries, don't download them
 	rm -rf contrib/
 	for module in fdk-aac ffmpeg libbluray libdav1d libdvdnav libdvdread nvenc \
-		x265 zimg; do
+		x265 zimg svt-av1 libvpl; do
 	    vsed -i "/MODULES += contrib\/${module}/d" make/include/main.defs
 	done
 }

From 4cf79efa36af4fcd5e2571b62b1793df3891932d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 043/115] hedgewars: revbump for ffmpeg4-4.4.3

---
 srcpkgs/hedgewars/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/hedgewars/template b/srcpkgs/hedgewars/template
index 419f29b98b44..926fe4fe3e68 100644
--- a/srcpkgs/hedgewars/template
+++ b/srcpkgs/hedgewars/template
@@ -1,13 +1,13 @@
 # Template file for 'hedgewars'
 pkgname=hedgewars
 version=1.0.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DNOSERVER=1 -DDATA_INSTALL_DIR=/usr/share/${pkgname}
  -DPHYSFS_SYSTEM=1 -DMINIMAL_FLAGS=1"
 make_cmd=make
 hostmakedepends="lua51 pkg-config qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
+makedepends="ffmpeg4-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
  SDL2_mixer-devel SDL2_net-devel SDL2_ttf-devel"
 depends="libfreeglut"
 short_desc="Funny turn-based artillery game, featuring fighting Hedgehogs!"

From 170e7b91687e662cc4b7e8a4ba6e6a0af03856f7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 044/115] idjc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/idjc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/idjc/template b/srcpkgs/idjc/template
index df60318b3db9..36a75baf597c 100644
--- a/srcpkgs/idjc/template
+++ b/srcpkgs/idjc/template
@@ -1,11 +1,11 @@
 # Template file for 'idjc'
 pkgname=idjc
 version=0.9.1
-revision=3
+revision=4
 build_style=gnu-configure
 hostmakedepends="pkg-config git python3 automake gettext-devel libtool"
 makedepends="libvorbis-devel libogg-devel jack-devel libsamplerate-devel
- libflac-devel libsndfile-devel mpg123-devel ffmpeg-devel speex-devel
+ libflac-devel libsndfile-devel mpg123-devel ffmpeg4-devel speex-devel
  glib-devel pixman-devel lame-devel python3-gobject-devel libshout-idjc-devel
  opus-devel twolame-devel python3-mutagen python3-devel"
 depends="python3-gobject python3-mutagen desktop-file-utils shared-mime-info python3-dbus jack"

From 5733e09476ff0a52d2f974dd192fbb433ab5e5d0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 045/115] kfilemetadata5: revbump for ffmpeg-6.0

---
 srcpkgs/kfilemetadata5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kfilemetadata5/template b/srcpkgs/kfilemetadata5/template
index 8980121fbc69..f662a2043f93 100644
--- a/srcpkgs/kfilemetadata5/template
+++ b/srcpkgs/kfilemetadata5/template
@@ -1,7 +1,7 @@
 # Template file for 'kfilemetadata5'
 pkgname=kfilemetadata5
 version=5.105.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="kcoreaddons extra-cmake-modules pkg-config qt5-host-tools qt5-qmake
  gettext kcoreaddons python3"

From f3a8d7160b1c2ea575a132a663d0d266c726bbb6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 046/115] kid3: revbump for ffmpeg-6.0

---
 srcpkgs/kid3/patches/ffmpeg5.patch | 17 +++++++++++++++++
 srcpkgs/kid3/template              |  2 +-
 2 files changed, 18 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/kid3/patches/ffmpeg5.patch

diff --git a/srcpkgs/kid3/patches/ffmpeg5.patch b/srcpkgs/kid3/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..135fc50e07c9
--- /dev/null
+++ b/srcpkgs/kid3/patches/ffmpeg5.patch
@@ -0,0 +1,17 @@
+# https://aur.archlinux.org/cgit/aur.git/diff/ffmpeg5.patch?h=kid3-cli&id=12410a74906612e7efc0ec8fbce739b4a0fef7e7
+diff --git a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+index e156d424..e12b9abd 100644
+--- a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
++++ b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+@@ -232,7 +232,11 @@ private:
+   friend class Format;
+   friend class Converter;
+   AVCodecContext* m_ptr;
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 0, 0)
+   AVCodec* m_impl;
++#else
++  const AVCodec* m_impl;
++#endif
+   AVFrame* m_frame;
+   bool m_opened;
+ };
diff --git a/srcpkgs/kid3/template b/srcpkgs/kid3/template
index 456206d90e16..f32f9decb0e7 100644
--- a/srcpkgs/kid3/template
+++ b/srcpkgs/kid3/template
@@ -1,7 +1,7 @@
 # Template file for 'kid3'
 pkgname=kid3
 version=3.9.1
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DWITH_APPS='CLI;$(vopt_if KDE KDE Qt)'
  -DWITH_DOCBOOKDIR=/usr/share/xsl/docbook -DWITH_FLAC=$(vopt_if flac ON OFF)

From c99e790e3361a329cc544d0b5fe56c5aca493a32 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 047/115] kodi: revbump for ffmpeg4-4.4.3

---
 srcpkgs/kodi/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/kodi/template b/srcpkgs/kodi/template
index 8057964d78a3..6cc1874be7ba 100644
--- a/srcpkgs/kodi/template
+++ b/srcpkgs/kodi/template
@@ -1,7 +1,7 @@
 # Template file for 'kodi'
 pkgname=kodi
 version=19.4
-revision=6
+revision=7
 _codename="Matrix"
 build_style=cmake
 configure_args="-DWITH_FFMPEG=/usr -DENABLE_LDGOLD=OFF
@@ -54,7 +54,7 @@ makedepends="
  libmad-devel fontconfig-devel libXinerama-devel libsamplerate-devel libmms-devel
  enca-devel boost-devel libcurl-devel libva-devel libvdpau-devel libass-devel
  libbluetooth-devel yajl-devel libplist-devel librtmp-devel tinyxml-devel
- taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg-devel
+ taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg4-devel
  giflib-devel libxslt-devel gnutls-devel libssh-devel libmicrohttpd-devel
  libcec-devel dcadec-devel flatbuffers-devel fmt-devel lcms2-devel
  libfstrcmp-devel rapidjson libcdio-paranoia spdlog libwaylandpp-devel

From d412205553b455fd95be1c2ff9b8824360e203c4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 048/115] kpipewire: revbump for ffmpeg-6.0

---
 srcpkgs/kpipewire/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kpipewire/template b/srcpkgs/kpipewire/template
index 467ab823a5e1..51827f24db9e 100644
--- a/srcpkgs/kpipewire/template
+++ b/srcpkgs/kpipewire/template
@@ -1,7 +1,7 @@
 # Template file for 'kpipewire'
 pkgname=kpipewire
 version=5.27.4
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules plasma-wayland-protocols gettext
  qt5-qmake qt5-host-tools pkg-config wayland-devel kcoreaddons

From 89b6fa359ec3486922bf1bdcbaeaeece98e10ffc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 049/115] libextractor: revbump for ffmpeg4-4.4.3

---
 srcpkgs/libextractor/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libextractor/template b/srcpkgs/libextractor/template
index ddd4790f93e8..1fb9ca56a96a 100644
--- a/srcpkgs/libextractor/template
+++ b/srcpkgs/libextractor/template
@@ -7,7 +7,7 @@ configure_args="--disable-static"
 hostmakedepends="pkg-config"
 makedepends="zlib-devel bzip2-devel exiv2-devel tiff-devel libpng-devel
  libjpeg-turbo-devel libvorbis-devel libflac-devel giflib-devel libmpeg2-devel
- ffmpeg-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
+ ffmpeg4-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
 short_desc="Library used to extract meta data from files"
 maintainer="Martin Riese <grauehaare@gmx.de>"
 license="GPL-3.0-or-later"

From f3e27a7ebff55806e8a80196b158dfee67b53553 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 050/115] libopenal: revbump for ffmpeg-6.0

---
 srcpkgs/libopenal/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenal/template b/srcpkgs/libopenal/template
index 77218f9e539d..3f49ed75a1fd 100644
--- a/srcpkgs/libopenal/template
+++ b/srcpkgs/libopenal/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenal'
 pkgname=libopenal
 version=1.22.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DALSOFT_EXAMPLES=OFF"
 hostmakedepends="pkg-config"

From 3213e6a0be931081de39d2d3cc2b78fb9f80b8a5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 051/115] libopenshot: revbump for ffmpeg-6.0

---
 srcpkgs/libopenshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenshot/template b/srcpkgs/libopenshot/template
index db831f69b474..81aa0d7136d9 100644
--- a/srcpkgs/libopenshot/template
+++ b/srcpkgs/libopenshot/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenshot'
 pkgname=libopenshot
 version=0.3.0
-revision=1
+revision=2
 build_style=cmake
 # Builds fail with Ruby-2.4.1
 configure_args="-DENABLE_RUBY=OFF -DUSE_SYSTEM_JSONCPP=ON"

From 87715ed217323ba343cce1e8eb30af7da77c9fab Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 052/115] loudgain: revbump for ffmpeg-6.0

---
 srcpkgs/loudgain/patches/ffmpeg5.patch | 11 +++++++++++
 srcpkgs/loudgain/template              |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/loudgain/patches/ffmpeg5.patch

diff --git a/srcpkgs/loudgain/patches/ffmpeg5.patch b/srcpkgs/loudgain/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..16d4510ee98f
--- /dev/null
+++ b/srcpkgs/loudgain/patches/ffmpeg5.patch
@@ -0,0 +1,11 @@
+--- a/src/scan.c	2019-09-06 11:31:19.000000000 -0400
++++ b/src/scan.c	2023-03-23 11:15:40.867968521 -0400
+@@ -69,8 +69,6 @@
+ 	 * It is now useless
+ 	 * https://github.com/FFmpeg/FFmpeg/blob/70d25268c21cbee5f08304da95be1f647c630c15/doc/APIchanges#L86
+ 	 */
+-  if (avformat_version() < AV_VERSION_INT(58,9,100))
+-    av_register_all();
+ 
+ 	av_log_set_callback(scan_av_log);
+ 
diff --git a/srcpkgs/loudgain/template b/srcpkgs/loudgain/template
index da4f2d56e94c..4d6bf29efb4f 100644
--- a/srcpkgs/loudgain/template
+++ b/srcpkgs/loudgain/template
@@ -1,7 +1,7 @@
 # Template file for 'loudgain'
 pkgname=loudgain
 version=0.6.8
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libebur128-devel taglib-devel ffmpeg-devel"

From 5067f987ce68e0dc1c10297558faddbb4f4a449a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 053/115] mediastreamer: revbump for ffmpeg4-4.4.3

---
 srcpkgs/mediastreamer/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mediastreamer/template b/srcpkgs/mediastreamer/template
index d0e97e858e29..1bde031443a5 100644
--- a/srcpkgs/mediastreamer/template
+++ b/srcpkgs/mediastreamer/template
@@ -1,11 +1,11 @@
 # Template file for 'mediastreamer'
 pkgname=mediastreamer
 version=5.2.6
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_STRICT=0 -DENABLE_UNIT_TESTS=0"
 hostmakedepends="python3"
-makedepends="bzrtp-devel ffmpeg-devel glew-devel libXv-devel libsrtp-devel
+makedepends="bzrtp-devel ffmpeg4-devel glew-devel libXv-devel libsrtp-devel
  libupnp-devel libvpx-devel mbedtls-devel opus-devel ortp-devel pulseaudio-devel
  libtheora-devel speex-devel v4l-utils-devel bcg729-devel bcmatroska2-devel libgsm-devel"
 # zxing-cpp-devel (1.2.0 probably not compatible, check again after updaing xzing)

From fd02416dc9e1b38ec374067b0bc785495a0014c7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 054/115] mgba: revbump for ffmpeg-6.0

---
 srcpkgs/mgba/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mgba/template b/srcpkgs/mgba/template
index ae0504311eee..d31295a0cd3d 100644
--- a/srcpkgs/mgba/template
+++ b/srcpkgs/mgba/template
@@ -1,7 +1,7 @@
 # Template file for 'mgba'
 pkgname=mgba
 version=0.10.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake desktop-file-utils"
 makedepends="SDL2-devel ffmpeg-devel libedit-devel libepoxy-devel libmagick-devel

From 5e1feb2ce7cda094a6a0d2920d5a5fea663806ff Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 055/115] minidlna: revbump for ffmpeg-6.0

---
 srcpkgs/minidlna/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/minidlna/template b/srcpkgs/minidlna/template
index e8081b1cbc67..9ee9714861fd 100644
--- a/srcpkgs/minidlna/template
+++ b/srcpkgs/minidlna/template
@@ -1,7 +1,7 @@
 # Template file for 'minidlna'
 pkgname=minidlna
 version=1.3.2
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="
  --sbindir=/usr/bin

From 508b1f5b7ae2dc1bb05ae9985a883c2f5aab794a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 056/115] mixxx: revbump for ffmpeg-6.0

---
 srcpkgs/mixxx/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mixxx/template b/srcpkgs/mixxx/template
index 619ddca0d332..4b9ea00d3fb3 100644
--- a/srcpkgs/mixxx/template
+++ b/srcpkgs/mixxx/template
@@ -1,7 +1,7 @@
 # Template file for 'mixxx'
 pkgname=mixxx
 version=2.3.3
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="extra-cmake-modules pkg-config protobuf qt5-host-tools qt5-devel"

From 6a9a4d0f26c1ab9866aedf55fb917528958cd8d4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 057/115] mlt: revbump for ffmpeg4-4.4.3

---
 srcpkgs/mlt/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mlt/template b/srcpkgs/mlt/template
index 8933eb4e7bb9..73353fedafb5 100644
--- a/srcpkgs/mlt/template
+++ b/srcpkgs/mlt/template
@@ -1,14 +1,14 @@
 # Template file for 'mlt'
 pkgname=mlt
 version=6.26.1
-revision=1
+revision=2
 build_style=configure
 configure_args="--prefix=/usr --libdir=/usr/lib$XBPS_TARGET_WORDSIZE
  --enable-gpl --enable-gpl3 --disable-swfdec --without-kde
  --swig-languages=python"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which"
 # XXX: movit vid.stab
-makedepends="alsa-lib-devel ffmpeg-devel gtk+-devel jack-devel ladspa-sdk
+makedepends="alsa-lib-devel ffmpeg4-devel gtk+-devel jack-devel ladspa-sdk
  libexif-devel libsamplerate-devel libxml2-devel sox-devel SDL_image-devel
  fftw-devel frei0r-plugins python3-devel pulseaudio-devel movit-devel
  libvidstab-devel libatomic-devel"

From 420a077d5c08601171702b150a13c6181c5d97a3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 058/115] moc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/moc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/moc/template b/srcpkgs/moc/template
index c42be650a1d2..d4f0eefbad52 100644
--- a/srcpkgs/moc/template
+++ b/srcpkgs/moc/template
@@ -1,10 +1,10 @@
 # Template file for 'moc'
 pkgname=moc
 version=2.5.2
-revision=6
+revision=7
 build_style=gnu-configure
 hostmakedepends="pkg-config"
-makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg-devel
+makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg4-devel
  jack-devel alsa-lib-devel libltdl-devel libflac-devel libvorbis-devel
  libmad-devel libmpcdec-devel libmodplug-devel libid3tag-devel faad2-devel
  taglib-devel libsndfile-devel wavpack-devel speex-devel libsamplerate-devel

From a9330273b62ab5d97ad83c0012cbb0ea7862d7e6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 059/115] motion: revbump for ffmpeg-6.0

---
 srcpkgs/motion/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/motion/template b/srcpkgs/motion/template
index 3cf3c3035c5b..7dca12d851e3 100644
--- a/srcpkgs/motion/template
+++ b/srcpkgs/motion/template
@@ -1,7 +1,7 @@
 # Template file for 'motion'
 pkgname=motion
 version=4.5.1
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake pkg-config gettext-devel tar"
 makedepends="ffmpeg-devel libmicrohttpd-devel v4l-utils-devel gettext-devel"

From 57c35aa5e6f0bc16e9b50653a255a04616c99605 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 060/115] mpv: revbump for ffmpeg-6.0

---
 srcpkgs/mpv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpv/template b/srcpkgs/mpv/template
index e163c496c6eb..d4fefbf5e3c7 100644
--- a/srcpkgs/mpv/template
+++ b/srcpkgs/mpv/template
@@ -1,7 +1,7 @@
 # Template file for 'mpv'
 pkgname=mpv
 version=0.35.1
-revision=2
+revision=3
 build_style=meson
 configure_args="-Dcdda=enabled -Ddvbin=enabled -Ddvdnav=enabled
  -Dlibmpv=true -Dcplugins=enabled

From d34020b2cb48c36d107e16f69ae069754b541d38 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 061/115] musikcube: revbump for ffmpeg-6.0

---
 srcpkgs/musikcube/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/musikcube/template b/srcpkgs/musikcube/template
index 7c569303c054..a4dea460c371 100644
--- a/srcpkgs/musikcube/template
+++ b/srcpkgs/musikcube/template
@@ -1,7 +1,7 @@
 # Template file for 'musikcube'
 pkgname=musikcube
 version=3.0.0
-revision=1
+revision=2
 build_style=cmake
 make_cmd=make
 configure_args="-DNO_NCURSESW=1"

From 7a16468f8d4b4d73809d4925df438b4c40314fed Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 062/115] notcurses: revbump for ffmpeg-6.0

---
 srcpkgs/notcurses/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/notcurses/template b/srcpkgs/notcurses/template
index 6dd8a091319f..3110c30c9aff 100644
--- a/srcpkgs/notcurses/template
+++ b/srcpkgs/notcurses/template
@@ -1,7 +1,7 @@
 # Template file for 'notcurses'
 pkgname=notcurses
 version=3.0.9
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DUSE_STATIC=ON $(vopt_bool man USE_PANDOC)"
 hostmakedepends="pkg-config $(vopt_if man pandoc)"

From 775f74c8ada5c842a0edbbf3a3d67af2efa46f1c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 063/115] obs: revbump for ffmpeg-6.0

---
 srcpkgs/obs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/obs/template b/srcpkgs/obs/template
index 7ee29ff3eac6..fd06df415301 100644
--- a/srcpkgs/obs/template
+++ b/srcpkgs/obs/template
@@ -1,7 +1,7 @@
 # Template file for 'obs'
 pkgname=obs
 version=29.1.1
-revision=1
+revision=2
 archs="i686* x86_64* ppc64le* aarch64*"
 build_style=cmake
 configure_args="-DOBS_VERSION_OVERRIDE=${version} -DENABLE_JACK=ON

From 3603d360a909f5ed58e1da1defe5b7194632aa7f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 064/115] olive: revbump for ffmpeg4-4.4.3

---
 srcpkgs/olive/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/olive/template b/srcpkgs/olive/template
index 12a46936c990..5c2917b9c512 100644
--- a/srcpkgs/olive/template
+++ b/srcpkgs/olive/template
@@ -1,10 +1,10 @@
 # Template file for 'olive'
 pkgname=olive
 version=0.1.2
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools pkg-config"
-makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg-devel frei0r-plugins"
+makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg4-devel frei0r-plugins"
 short_desc="Non-linear video editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"

From 9bc917602d037daec5a89d2f42889f49d0734ebe Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 065/115] omxplayer: revbump for ffmpeg4-4.4.3

---
 srcpkgs/omxplayer/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/omxplayer/template b/srcpkgs/omxplayer/template
index e70bf7873d4d..0e9bc70e7c8e 100644
--- a/srcpkgs/omxplayer/template
+++ b/srcpkgs/omxplayer/template
@@ -1,10 +1,10 @@
 # Template file for 'omxplayer'
 pkgname=omxplayer
 version=20190102
-revision=1
+revision=2
 short_desc="Commandline OMX player for the Raspberry Pi"
 maintainer="Orphaned <orphan@voidlinux.org>"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://github.com/popcornmix/omxplayer"
 
 _commit="f06235cc9690a6d58187514452df8cf8fcdaacec"
@@ -15,7 +15,7 @@ checksum=af2d9450f8947842ea8c401fe9f71eec444013ebbdee29f2ac828c9c493c1329
 archs="armv6l* armv7l*"
 build_style=gnu-makefile
 hostmakedepends="curl pkg-config"
-makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg-devel dbus-devel"
+makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg4-devel dbus-devel"
 depends="freefont-ttf"
 
 do_build() {

From 287a27928c71bc8c22af9bac8dec985ab5d2b33c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 066/115] openimageio: revbump for ffmpeg-6.0

---
 common/shlibs                | 2 ++
 srcpkgs/openimageio/template | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/shlibs b/common/shlibs
index b570535ed1ef..bb17578f539e 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2263,6 +2263,8 @@ libxmp.so.4 libxmp-4.3.7_1
 libKF5ThreadWeaver.so.5 threadweaver-5.26.0_1
 libOpenImageIO_Util.so.2.4 openimageio-2.4.9.0_1
 libOpenImageIO.so.2.4 openimageio-2.4.9.0_1
+libOpenImageIO_Util.so.2.4 openimageio-2.4.8.1_1
+libOpenImageIO.so.2.4 openimageio-2.4.8.1_1
 libOpenColorIO.so.2.1 opencolorio-2.1.2_1
 libpystring.so.1 pystring-1.1.3_1
 libyaml-cpp.so.0.7 yaml-cpp-0.7.0_1
diff --git a/srcpkgs/openimageio/template b/srcpkgs/openimageio/template
index c2d36b4b3539..0e9e22e9685d 100644
--- a/srcpkgs/openimageio/template
+++ b/srcpkgs/openimageio/template
@@ -1,7 +1,7 @@
 # Template file for 'openimageio'
 pkgname=openimageio
 version=2.4.9.0
-revision=4
+revision=5
 build_style=cmake
 build_helper=qemu
 configure_args="-DUSE_QT=0 -DUSE_PYTHON=0 -DOIIO_BUILD_TESTS=0

From b23fc9dfa0a2d87cc12c34b23f09f94d228e30c6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 067/115] openshot: revbump for ffmpeg-6.0

---
 srcpkgs/openshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openshot/template b/srcpkgs/openshot/template
index 322717d40abc..c074e0338773 100644
--- a/srcpkgs/openshot/template
+++ b/srcpkgs/openshot/template
@@ -1,7 +1,7 @@
 # Template file for 'openshot'
 pkgname=openshot
 version=3.0.0
-revision=1
+revision=2
 build_style=python3-module
 hostmakedepends="python3 python3-setuptools"
 makedepends="ffmpeg-devel python3-PyQt5"

From 86b2f24e7f534af093e0fd6a7473f195e1a658f8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 068/115] opentoonz: revbump for ffmpeg-6.0

---
 srcpkgs/opentoonz/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/opentoonz/template b/srcpkgs/opentoonz/template
index ee9f7603f55f..3e81834ca0ed 100644
--- a/srcpkgs/opentoonz/template
+++ b/srcpkgs/opentoonz/template
@@ -1,7 +1,7 @@
 # Template file for 'opentoonz'
 pkgname=opentoonz
 version=1.6.0
-revision=2
+revision=3
 build_wrksrc="toonz/sources"
 build_style=cmake
 make_cmd=make

From 54420004a1047f03a7874eb046b8a22621d747a8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 069/115] pianobar: revbump for ffmpeg-6.0

---
 srcpkgs/pianobar/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pianobar/template b/srcpkgs/pianobar/template
index a9b29e91993f..81efcd122c4d 100644
--- a/srcpkgs/pianobar/template
+++ b/srcpkgs/pianobar/template
@@ -1,7 +1,7 @@
 # Template file for 'pianobar'
 pkgname=pianobar
 version=2022.04.01
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="V=1"
 hostmakedepends="pkg-config"

From 96a8c11deffeec6e8ce5756fe65d2ebf84410dbf Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 070/115] ppsspp: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ppsspp/template | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/ppsspp/template b/srcpkgs/ppsspp/template
index 7984a733d4be..15a42fd2c993 100644
--- a/srcpkgs/ppsspp/template
+++ b/srcpkgs/ppsspp/template
@@ -1,7 +1,7 @@
 # Template file for 'ppsspp'
 pkgname=ppsspp
 version=1.14.4
-revision=1
+revision=2
 _glslang_commit=dc11adde23c455a24e13dd54de9b4ede8bdd7db8
 _SPIRV_Cross_commit=9acb9ec31f5a8ef80ea6b994bb77be787b08d3d1
 _armips_commit=6719edebaae03330ee5441d9b28280672edf00d5
@@ -13,7 +13,7 @@ configure_args="-DHEADLESS=1 -DUSE_SYSTEM_FFMPEG=1 -DUNITTEST=ON
  -DUSING_QT_UI=$(vopt_if qt ON OFF) -DUSE_SYSTEM_ZSTD=ON
  -DARMIPS_USE_STD_FILESYSTEM=ON"
 hostmakedepends="pkg-config python3 $(vopt_if qt qt5-host-tools)"
-makedepends="zlib-devel glew-devel ffmpeg-devel libzip-devel
+makedepends="zlib-devel glew-devel ffmpeg4-devel libzip-devel
  snappy-devel rapidjson libpng-devel libzstd-devel
  $(vopt_if sdl2 SDL2-devel) $(vopt_if wayland wayland-devel)
  $(vopt_if qt 'qt5-devel qt5-multimedia-devel')"
@@ -62,13 +62,12 @@ post_extract() {
 	mv ${wrksrc}/miniupnp-${_miniupnp_commit} ${wrksrc}/ext/miniupnp
 }
 
-post_patch(){
+post_patch() {
 	# disable git versioning
 	vsed -e 's|find_package(Git)|# &|' -i git-version.cmake
 }
 
 do_install() {
-	vlicense LICENSE.TXT
 	vinstall icons/icon.svg 644 usr/share/pixmaps ppsspp.svg
 	vinstall Qt/PPSSPP.desktop 644 usr/share/applications
 	vbin build/PPSSPPHeadless ppsspp-headless

From 912a2dcf927d92b27d40dcb746f5d5a6424f13b4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 071/115] pqiv: revbump for ffmpeg-6.0

---
 srcpkgs/pqiv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pqiv/template b/srcpkgs/pqiv/template
index 542fc27a2d32..9308d949b6a1 100644
--- a/srcpkgs/pqiv/template
+++ b/srcpkgs/pqiv/template
@@ -1,7 +1,7 @@
 # Template file for 'pqiv'
 pkgname=pqiv
 version=2.12
-revision=1
+revision=2
 build_style=gnu-makefile
 hostmakedepends="pkg-config"
 makedepends="glib-devel gtk+3-devel $(vopt_if ffmpeg ffmpeg-devel)

From 607c4ff28753095d9d45e928de4b707639955986 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 072/115] qmmp: revbump for ffmpeg-6.0

---
 srcpkgs/qmmp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qmmp/template b/srcpkgs/qmmp/template
index 26c661ed16be..a150d7441c7a 100644
--- a/srcpkgs/qmmp/template
+++ b/srcpkgs/qmmp/template
@@ -1,7 +1,7 @@
 # Template file for 'qmmp'
 pkgname=qmmp
 version=1.6.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DUSE_HAL:BOOL=FALSE -DQMMP_DEFAULT_UI:STRING=simple"
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From 498086214004f2f0811a3f104bba4b4512268bab Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 073/115] qt5-webengine: update to 5.15.13

---
 .../chromium-media-filters-cpp14.patch        |  11 ++
 srcpkgs/qt5-webengine/patches/ffmpeg5.patch   | 179 ++++++++++++++++++
 srcpkgs/qt5-webengine/template                |  10 +-
 3 files changed, 195 insertions(+), 5 deletions(-)
 create mode 100644 srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/ffmpeg5.patch

diff --git a/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
new file mode 100644
index 000000000000..04adc540f2cb
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
@@ -0,0 +1,11 @@
+--- a/src/3rdparty/chromium/media/filters/BUILD.gn	2023-02-27 13:32:59.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/BUILD.gn	2023-04-02 17:21:39.204066384 -0400
+@@ -96,6 +96,8 @@
+     "//ui/gfx/geometry:geometry",
+   ]
+ 
++  cflags_cc = [ "-std=c++14" ]
++
+   libs = []
+ 
+   if (proprietary_codecs) {
diff --git a/srcpkgs/qt5-webengine/patches/ffmpeg5.patch b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..ac55e1634423
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
@@ -0,0 +1,179 @@
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:57.732547446 -0400
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:09.486478995 -0400
+@@ -57,6 +57,8 @@
+ 
+ namespace {
+ 
++constexpr int64_t kRelativeTsBase = static_cast<int64_t>(0x7ffeffffffffffff);
++
+ void SetAVStreamDiscard(AVStream* stream, AVDiscard discard) {
+   DCHECK(stream);
+   stream->discard = discard;
+@@ -90,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+   if (stream->start_time != kNoFFmpegTimestamp)
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (stream->first_dts != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, stream->first_dts);
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -408,11 +398,11 @@
+   scoped_refptr<DecoderBuffer> buffer;
+ 
+   if (type() == DemuxerStream::TEXT) {
+-    int id_size = 0;
++    size_t id_size = 0;
+     uint8_t* id_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
+ 
+-    int settings_size = 0;
++    size_t settings_size = 0;
+     uint8_t* settings_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
+ 
+@@ -424,7 +414,7 @@
+     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
+                                      side_data.data(), side_data.size());
+   } else {
+-    int side_data_size = 0;
++    size_t side_data_size = 0;
+     uint8_t* side_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
+ 
+@@ -485,7 +475,7 @@
+                                        packet->size - data_offset);
+     }
+ 
+-    int skip_samples_size = 0;
++    size_t skip_samples_size = 0;
+     const uint32_t* skip_samples_ptr =
+         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
+             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
+@@ -1587,6 +1577,8 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++      continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+       lowest_start_time_stream = stream.get();
+@@ -1604,6 +1596,8 @@
+     if (stream && stream->type() == DemuxerStream::VIDEO &&
+         stream->IsEnabled()) {
+       video_stream = stream.get();
++      if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++        continue;
+       if (video_stream->start_time() <= seek_time) {
+         return video_stream;
+       }
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h qtwebengine-5.15.10/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h
+--- a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-07-11 22:12:47.917192788 -0500
+@@ -29,6 +29,7 @@ extern "C" {
+ #include <libavformat/avformat.h>
+ #include <libavformat/avio.h>
+ #include <libavutil/avutil.h>
++#include <libavutil/channel_layout.h>
+ #include <libavutil/imgutils.h>
+ #include <libavutil/log.h>
+ #include <libavutil/mastering_display_metadata.h>
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/audio_file_reader.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/audio_file_reader.cc
+--- a/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -85,7 +85,7 @@ bool AudioFileReader::OpenDemuxer() {
+ }
+ 
+ bool AudioFileReader::OpenDecoder() {
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (codec) {
+     // MP3 decodes to S16P which we don't support, tell it to use S16 instead.
+     if (codec_context_->sample_fmt == AV_SAMPLE_FMT_S16P)
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -329,7 +329,7 @@ bool FFmpegAudioDecoder::ConfigureDecode
+     }
+   }
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec ||
+       avcodec_open2(codec_context_.get(), codec, &codec_options) < 0) {
+     DLOG(ERROR) << "Could not initialize audio decoder: "
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -59,7 +59,6 @@ static int64_t AVIOSeekOperation(void* o
+ }
+ 
+ void FFmpegGlue::InitializeFFmpeg() {
+-  av_register_all();
+ }
+ 
+ static void LogContainer(bool is_local_file,
+@@ -95,9 +94,6 @@ FFmpegGlue::FFmpegGlue(FFmpegURLProtocol
+   // Enable fast, but inaccurate seeks for MP3.
+   format_context_->flags |= AVFMT_FLAG_FAST_SEEK;
+ 
+-  // Ensures we can read out various metadata bits like vp8 alpha.
+-  format_context_->flags |= AVFMT_FLAG_KEEP_SIDE_DATA;
+-
+   // Ensures format parsing errors will bail out. From an audit on 11/2017, all
+   // instances were real failures. Solves bugs like http://crbug.com/710791.
+   format_context_->error_recognition |= AV_EF_EXPLODE;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -391,7 +391,7 @@ bool FFmpegVideoDecoder::ConfigureDecode
+   if (decode_nalus_)
+     codec_context_->flags2 |= AV_CODEC_FLAG2_CHUNKS;
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
+     ReleaseFFmpegResources();
+     return false;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/media_file_checker.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/media_file_checker.cc
+--- a/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -68,7 +68,7 @@ bool MediaFileChecker::Start(base::TimeD
+       auto context = AVStreamToAVCodecContext(format_context->streams[i]);
+       if (!context)
+         continue;
+-      AVCodec* codec = avcodec_find_decoder(cp->codec_id);
++      const AVCodec* codec = avcodec_find_decoder(cp->codec_id);
+       if (codec && avcodec_open2(context.get(), codec, nullptr) >= 0) {
+         auto loop = std::make_unique<FFmpegDecodingLoop>(context.get());
+         stream_contexts[i] = {std::move(context), std::move(loop)};
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc qtwebengine-5.15.10/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc
+--- a/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -203,7 +203,7 @@ int32_t H264DecoderImpl::InitDecode(cons
+   // a pointer |this|.
+   av_context_->opaque = this;
+ 
+-  AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
+   if (!codec) {
+     // This is an indication that FFmpeg has not been initialized or it has not
+     // been compiled/initialized with the correct set of codecs.
diff --git a/srcpkgs/qt5-webengine/template b/srcpkgs/qt5-webengine/template
index 85267c7cf8a3..095ab67701e4 100644
--- a/srcpkgs/qt5-webengine/template
+++ b/srcpkgs/qt5-webengine/template
@@ -1,9 +1,9 @@
 # Template file for 'qt5-webengine'
 pkgname=qt5-webengine
-version=5.15.11
-revision=3
+version=5.15.13
+revision=1
 _version="${version}-lts"
-_chromium_commit=be349eaf62e77955791d7bf29f893f1e8a37daf4
+_chromium_commit=e48df7803c7c98b0b2471c94057d32e44a301ad5
 archs="x86_64* i686* armv[67]* ppc64* aarch64*"
 create_wrksrc=yes
 build_style=qmake
@@ -32,8 +32,8 @@ license="GPL-3.0-or-later, LGPL-3.0-or-later"
 homepage="https://qt.io/"
 distfiles="https://github.com/qt/qtwebengine/archive/v${_version}.tar.gz
  https://github.com/qt/qtwebengine-chromium/archive/${_chromium_commit}.tar.gz"
-checksum="aa7466356c450c5f5870f979b93cd7e7e62da1165c328ffcab1a9928db18ad67
- 6f47ed8ab8cc062411f6f206da6353bc8263d6ed6d6290c689a05c01d91f646b"
+checksum="4b59838ed75ef788b59e1e412535a0e42dd9d311661fdeadb191b581ba815c63
+ a91686562b1d4e8b220e0bbcbab5feb64630e2de974b35ac034bf388af771a6c"
 
 no_generic_pkgconfig_link=yes
 build_options="sndio pipewire"

From ad135f122d43121d7e9e663f5a8b403d1ba0cb7a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 074/115] qt5: update to 5.15.8

---
 ...erywhere-opensource-src-5.15.8-kf5-1.patch | 12913 ++++++++++++++++
 srcpkgs/qt5/template                          |    12 +-
 2 files changed, 12919 insertions(+), 6 deletions(-)
 create mode 100644 srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch

diff --git a/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch b/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch
new file mode 100644
index 000000000000..966c98bcd3bb
--- /dev/null
+++ b/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch
@@ -0,0 +1,12913 @@
+Submitted By:            Pierre Labastie <pierre_dot_labastie_at_neuf_dot_fr>
+Date:                    2023-01-05
+Initial Package Version: 5.15.8
+Upstream Status:         Applied (according to KDE)
+Origin:                  KDE patch set
+Description:             Patch set maintained by the KDE folks
+see https://dot.kde.org/2021/04/06/announcing-kdes-qt-5-patch-collection
+Patch generated using the procedure in
+https://wiki.linuxfromscratch.org/blfs/ticket/17476#comment:3
+
+Submodule qtbase 4ee4fc18..9cf586d6:
+diff --git a/qtbase/mkspecs/common/android/qplatformdefs.h b/qtbase/mkspecs/common/android/qplatformdefs.h
+index f75bc4093b..2bd59410d4 100644
+--- a/qtbase/mkspecs/common/android/qplatformdefs.h
++++ b/qtbase/mkspecs/common/android/qplatformdefs.h
+@@ -144,11 +144,7 @@
+ #define QT_SIGNAL_ARGS          int
+ #define QT_SIGNAL_IGNORE        SIG_IGN
+ 
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+ #define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+ 
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+diff --git a/qtbase/mkspecs/features/mac/sdk.mk b/qtbase/mkspecs/features/mac/sdk.mk
+index f30b5830b4..a32ceacb6c 100644
+--- a/qtbase/mkspecs/features/mac/sdk.mk
++++ b/qtbase/mkspecs/features/mac/sdk.mk
+@@ -1,6 +1,6 @@
+ 
+ ifeq ($(QT_MAC_SDK_NO_VERSION_CHECK),)
+-    CHECK_SDK_COMMAND = /usr/bin/xcrun --sdk $(EXPORT_QMAKE_MAC_SDK) -show-sdk-version 2>&1
++    CHECK_SDK_COMMAND = /usr/bin/xcrun --sdk $(EXPORT_QMAKE_MAC_SDK) -show-sdk-version 2>/dev/null
+     CURRENT_MAC_SDK_VERSION := $(shell DEVELOPER_DIR=$(EXPORT_QMAKE_XCODE_DEVELOPER_PATH) $(CHECK_SDK_COMMAND))
+     ifneq ($(CURRENT_MAC_SDK_VERSION),$(EXPORT_QMAKE_MAC_SDK_VERSION))
+         # We don't want to complain about out of date SDK unless the target needs to be remade.
+diff --git a/qtbase/mkspecs/linux-clang/qplatformdefs.h b/qtbase/mkspecs/linux-clang/qplatformdefs.h
+index a818d973f0..c1ab72fbc6 100644
+--- a/qtbase/mkspecs/linux-clang/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-clang/qplatformdefs.h
+@@ -79,14 +79,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-g++/qplatformdefs.h b/qtbase/mkspecs/linux-g++/qplatformdefs.h
+index 13523f0702..4d2750d9ec 100644
+--- a/qtbase/mkspecs/linux-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-g++/qplatformdefs.h
+@@ -79,14 +79,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ < 2)
+-#define QT_SOCKLEN_T            int
+-#else
+-#define QT_SOCKLEN_T            socklen_t
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-llvm/qplatformdefs.h b/qtbase/mkspecs/linux-llvm/qplatformdefs.h
+index dc750ab1ef..d3cc39b47f 100644
+--- a/qtbase/mkspecs/linux-llvm/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-llvm/qplatformdefs.h
+@@ -80,14 +80,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h b/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
+index 4c4e53da2a..83baffb3e3 100644
+--- a/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
+@@ -85,16 +85,9 @@
+ #include "../common/posix/qplatformdefs.h"
+ 
+ #undef QT_OPEN_LARGEFILE
+-#undef QT_SOCKLEN_T
+ 
+ #define QT_OPEN_LARGEFILE       0
+ 
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #ifndef SIOCGIFBRDADDR
+ #  define SIOCGIFBRDADDR 0x8919
+ #endif
+diff --git a/qtbase/mkspecs/lynxos-g++/qplatformdefs.h b/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
+index 4339ea2b23..6007af0055 100644
+--- a/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
+@@ -72,14 +72,6 @@
+ 
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp b/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
+index c3c184258f..32af3f8f29 100644
+--- a/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
++++ b/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
+@@ -10,6 +10,7 @@
+ #include "libANGLE/HandleAllocator.h"
+ 
+ #include <algorithm>
++#include <limits>
+ 
+ #include "common/debug.h"
+ 
+diff --git a/qtbase/src/3rdparty/forkfd/forkfd_linux.c b/qtbase/src/3rdparty/forkfd/forkfd_linux.c
+index ffe0e9a5e2..b1f5408d11 100644
+--- a/qtbase/src/3rdparty/forkfd/forkfd_linux.c
++++ b/qtbase/src/3rdparty/forkfd/forkfd_linux.c
+@@ -82,7 +82,8 @@ static int sys_clone(unsigned long cloneflags, int *ptid)
+     return syscall(__NR_clone, cloneflags, child_stack, stack_size, ptid, newtls, ctid);
+ #elif defined(__arc__) || defined(__arm__) || defined(__aarch64__) || defined(__mips__) || \
+     defined(__nds32__) || defined(__hppa__) || defined(__powerpc__) || defined(__i386__) || \
+-    defined(__x86_64__) || defined(__xtensa__) || defined(__alpha__) || defined(__riscv)
++    defined(__x86_64__) || defined(__xtensa__) || defined(__alpha__) || defined(__riscv) || \
++    defined(__loongarch__)
+     /* ctid and newtls are inverted on CONFIG_CLONE_BACKWARDS architectures,
+      * but since both values are 0, there's no harm. */
+     return syscall(__NR_clone, cloneflags, child_stack, ptid, ctid, newtls);
+diff --git a/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java b/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
+index 5792b5b2f5..2f74750fcf 100644
+--- a/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
++++ b/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
+@@ -116,6 +116,7 @@ public class QtNative
+     public static QtThread m_qtThread = new QtThread();
+     private static HashMap<String, Uri> m_cachedUris = new HashMap<String, Uri>();
+     private static ArrayList<String> m_knownDirs = new ArrayList<String>();
++    private static final String NoPermissionErrorMessage = "No permissions to open Uri";
+ 
+     private static final Runnable runPendingCppRunnablesRunnable = new Runnable() {
+         @Override
+@@ -193,11 +194,10 @@ public class QtNative
+                     return iterUri;
+             }
+ 
+-            // Android 6 and earlier could still manage to open the file so we can return the
+-            // parsed uri here
+-            if (Build.VERSION.SDK_INT < 24)
+-                return parsedUri;
+-            return null;
++            // if we only have transient permissions on uri all the above will fail,
++            // but we will be able to read the file anyway, so continue with uri here anyway
++            // and check for SecurityExceptions later
++            return parsedUri;
+         } catch (SecurityException e) {
+             e.printStackTrace();
+             return null;
+@@ -244,7 +244,7 @@ public class QtNative
+         int error = -1;
+ 
+         if (uri == null) {
+-            Log.e(QtTAG, "openFdForContentUrl(): No permissions to open Uri");
++            Log.e(QtTAG, "openFdForContentUrl(): " + NoPermissionErrorMessage);
+             return error;
+         }
+ 
+@@ -254,12 +254,13 @@ public class QtNative
+             return fdDesc.detachFd();
+         } catch (FileNotFoundException e) {
+             e.printStackTrace();
+-            return error;
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "openFdForContentUrl(): Invalid Uri");
+             e.printStackTrace();
+-            return error;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return error;
+     }
+ 
+     public static long getSize(Context context, String contentUrl)
+@@ -270,7 +271,7 @@ public class QtNative
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+ 
+         if (uri == null) {
+-            Log.e(QtTAG, "getSize(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return size;
+         } else if (!m_cachedUris.containsKey(contentUrl)) {
+             m_cachedUris.put(contentUrl, uri);
+@@ -288,12 +289,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "getSize(): Invalid Uri");
+             e.printStackTrace();
+-            return size;
+         }  catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "getSize(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return size;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return size;
+     }
+ 
+     public static boolean checkFileExists(Context context, String contentUrl)
+@@ -303,7 +305,7 @@ public class QtNative
+         if (uri == null)
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+         if (uri == null) {
+-            Log.e(QtTAG, "checkFileExists(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return exists;
+         } else {
+             if (!m_cachedUris.containsKey(contentUrl))
+@@ -321,12 +323,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "checkFileExists(): Invalid Uri");
+             e.printStackTrace();
+-            return exists;
+         } catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "checkFileExists(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return false;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return exists;
+     }
+ 
+     public static boolean checkIfWritable(Context context, String contentUrl)
+@@ -344,7 +347,7 @@ public class QtNative
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+         }
+         if (uri == null) {
+-            Log.e(QtTAG, "isDir(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return isDir;
+         } else {
+             if (!m_cachedUris.containsKey(contentUrl))
+@@ -374,12 +377,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "checkIfDir(): Invalid Uri");
+             e.printStackTrace();
+-            return false;
+         } catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "checkIfDir(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return false;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return false;
+     }
+     public static String[] listContentsFromTreeUri(Context context, String contentUrl)
+     {
+diff --git a/qtbase/src/concurrent/qtconcurrentreducekernel.h b/qtbase/src/concurrent/qtconcurrentreducekernel.h
+index 8f9a938952..a98dedef2e 100644
+--- a/qtbase/src/concurrent/qtconcurrentreducekernel.h
++++ b/qtbase/src/concurrent/qtconcurrentreducekernel.h
+@@ -212,11 +212,13 @@ public:
+ 
+     inline bool shouldThrottle()
+     {
++        std::lock_guard<QMutex> locker(mutex);
+         return (resultsMapSize > (ReduceQueueThrottleLimit * threadCount));
+     }
+ 
+     inline bool shouldStartThread()
+     {
++        std::lock_guard<QMutex> locker(mutex);
+         return (resultsMapSize <= (ReduceQueueStartLimit * threadCount));
+     }
+ };
+diff --git a/qtbase/src/concurrent/qtconcurrentthreadengine.cpp b/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
+index ea6ce3ac42..7f91a2ba68 100644
+--- a/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
++++ b/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
+@@ -176,6 +176,39 @@ void ThreadEngineBase::startSingleThreaded()
+     finish();
+ }
+ 
++void ThreadEngineBase::startBlocking()
++{
++    start();
++    barrier.acquire();
++    startThreads();
++
++    bool throttled = false;
++#ifndef QT_NO_EXCEPTIONS
++    try {
++#endif
++        while (threadFunction() == ThrottleThread) {
++            if (threadThrottleExit()) {
++                throttled = true;
++                break;
++            }
++        }
++#ifndef QT_NO_EXCEPTIONS
++    } catch (QException &e) {
++        handleException(e);
++    } catch (...) {
++        handleException(QUnhandledException());
++    }
++#endif
++
++    if (throttled == false) {
++        barrier.release();
++    }
++
++    barrier.wait();
++    finish();
++    exceptionStore.throwPossibleException();
++}
++
+ void ThreadEngineBase::startThread()
+ {
+     startThreadInternal();
+diff --git a/qtbase/src/concurrent/qtconcurrentthreadengine.h b/qtbase/src/concurrent/qtconcurrentthreadengine.h
+index 7c30cebdbc..a4c8548cc4 100644
+--- a/qtbase/src/concurrent/qtconcurrentthreadengine.h
++++ b/qtbase/src/concurrent/qtconcurrentthreadengine.h
+@@ -91,6 +91,7 @@ public:
+     ThreadEngineBase();
+     virtual ~ThreadEngineBase();
+     void startSingleThreaded();
++    void startBlocking();
+     void startThread();
+     bool isCanceled();
+     void waitForResume();
+@@ -143,6 +144,15 @@ public:
+         return result();
+     }
+ 
++    // Runs the user algorithm using multiple threads.
++    // This function blocks until the algorithm is finished,
++    // and then returns the result.
++    T *startBlocking()
++    {
++        ThreadEngineBase::startBlocking();
++        return result();
++    }
++
+     // Runs the user algorithm using multiple threads.
+     // Does not block, returns a future.
+     QFuture<T> startAsynchronously()
+@@ -223,6 +233,13 @@ class ThreadEngineStarter : public ThreadEngineStarterBase<T>
+ public:
+     ThreadEngineStarter(TypedThreadEngine *eng)
+         : Base(eng) { }
++
++    T startBlocking()
++    {
++        T t = *this->threadEngine->startBlocking();
++        delete this->threadEngine;
++        return t;
++    }
+ };
+ 
+ // Full template specialization where T is void.
+@@ -232,6 +249,12 @@ class ThreadEngineStarter<void> : public ThreadEngineStarterBase<void>
+ public:
+     ThreadEngineStarter(ThreadEngine<void> *_threadEngine)
+         : ThreadEngineStarterBase<void>(_threadEngine) {}
++
++    void startBlocking()
++    {
++        this->threadEngine->startBlocking();
++        delete this->threadEngine;
++    }
+ };
+ 
+ //! [qtconcurrentthreadengine-1]
+diff --git a/qtbase/src/corelib/animation/qvariantanimation.cpp b/qtbase/src/corelib/animation/qvariantanimation.cpp
+index 98b02f0202..eac1524107 100644
+--- a/qtbase/src/corelib/animation/qvariantanimation.cpp
++++ b/qtbase/src/corelib/animation/qvariantanimation.cpp
+@@ -276,7 +276,9 @@ void QVariantAnimationPrivate::setCurrentValueForProgress(const qreal progress)
+ 
+     const qreal startProgress = currentInterval.start.first;
+     const qreal endProgress = currentInterval.end.first;
+-    const qreal localProgress = (progress - startProgress) / (endProgress - startProgress);
++    const qreal localProgress =
++            qIsNull(progress - startProgress) ? 0.0 // avoid 0/0 below
++            /* else */                        : (progress - startProgress) / (endProgress - startProgress);
+ 
+     QVariant ret = q->interpolated(currentInterval.start.second,
+                                    currentInterval.end.second,
+diff --git a/qtbase/src/corelib/global/qnamespace.h b/qtbase/src/corelib/global/qnamespace.h
+index ad4150b317..bf19b1627b 100644
+--- a/qtbase/src/corelib/global/qnamespace.h
++++ b/qtbase/src/corelib/global/qnamespace.h
+@@ -1864,7 +1864,7 @@ public:
+     QT_Q_ENUM(TimerType)
+     QT_Q_ENUM(ScrollPhase)
+     QT_Q_ENUM(MouseEventSource)
+-    QT_Q_FLAG(MouseEventFlag)
++    QT_Q_FLAG(MouseEventFlags)
+     QT_Q_ENUM(ChecksumType)
+     QT_Q_ENUM(HighDpiScaleFactorRoundingPolicy)
+     QT_Q_ENUM(TabFocusBehavior)
+diff --git a/qtbase/src/corelib/global/qrandom.cpp b/qtbase/src/corelib/global/qrandom.cpp
+index 10672c1f92..25f87c7e6a 100644
+--- a/qtbase/src/corelib/global/qrandom.cpp
++++ b/qtbase/src/corelib/global/qrandom.cpp
+@@ -383,7 +383,6 @@ struct QRandomGenerator::SystemAndGlobalGenerators
+ 
+         constexpr SystemAndGlobalGenerators g = {};
+         Q_UNUSED(g);
+-        Q_STATIC_ASSERT(std::is_literal_type<SystemAndGlobalGenerators>::value);
+ #endif
+     }
+ 
+diff --git a/qtbase/src/corelib/io/qbuffer.cpp b/qtbase/src/corelib/io/qbuffer.cpp
+index 595fcd2724..032c0ddd4b 100644
+--- a/qtbase/src/corelib/io/qbuffer.cpp
++++ b/qtbase/src/corelib/io/qbuffer.cpp
+@@ -41,6 +41,8 @@
+ #include <QtCore/qmetaobject.h>
+ #include "private/qiodevice_p.h"
+ 
++#include <limits>
++
+ QT_BEGIN_NAMESPACE
+ 
+ /** QBufferPrivate **/
+@@ -366,7 +368,9 @@ qint64 QBuffer::size() const
+ bool QBuffer::seek(qint64 pos)
+ {
+     Q_D(QBuffer);
+-    if (pos > d->buf->size() && isWritable()) {
++    const auto oldBufSize = d->buf->size();
++    constexpr qint64 MaxSeekPos = (std::numeric_limits<decltype(oldBufSize)>::max)();
++    if (pos <= MaxSeekPos && pos > oldBufSize && isWritable()) {
+         if (seek(d->buf->size())) {
+             const qint64 gapSize = pos - d->buf->size();
+             if (write(QByteArray(gapSize, 0)) != gapSize) {
+@@ -377,7 +381,7 @@ bool QBuffer::seek(qint64 pos)
+             return false;
+         }
+     } else if (pos > d->buf->size() || pos < 0) {
+-        qWarning("QBuffer::seek: Invalid pos: %d", int(pos));
++        qWarning("QBuffer::seek: Invalid pos: %lld", pos);
+         return false;
+     }
+     return QIODevice::seek(pos);
+diff --git a/qtbase/src/corelib/io/qfilesystemengine_win.cpp b/qtbase/src/corelib/io/qfilesystemengine_win.cpp
+index 81d3a71986..c86ed1f9b0 100644
+--- a/qtbase/src/corelib/io/qfilesystemengine_win.cpp
++++ b/qtbase/src/corelib/io/qfilesystemengine_win.cpp
+@@ -664,14 +664,14 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry)
+     return QFileSystemEntry(ret, QFileSystemEntry::FromInternalPath());
+ }
+ 
+-#if defined(Q_CC_MINGW) && WINVER < 0x0602 //  Windows 8 onwards
++#if defined(Q_CC_MINGW) && WINVER < 0x0602 && _WIN32_WINNT < _WIN32_WINNT_WIN8 //  Windows 8 onwards
+ 
+ typedef struct _FILE_ID_INFO {
+     ULONGLONG VolumeSerialNumber;
+     FILE_ID_128 FileId;
+ } FILE_ID_INFO, *PFILE_ID_INFO;
+ 
+-#endif // if defined (Q_CC_MINGW) && WINVER < 0x0602
++#endif // if defined(Q_CC_MINGW) && WINVER < 0x0602 && _WIN32_WINNT < _WIN32_WINNT_WIN8
+ 
+ // File ID for Windows up to version 7 and FAT32 drives
+ static inline QByteArray fileId(HANDLE handle)
+diff --git a/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp b/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
+index 94d9d06bcb..27e0b13b0b 100644
+--- a/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
++++ b/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
+@@ -366,7 +366,9 @@ void QInotifyFileSystemWatcherEngine::readFromInotify()
+     // qDebug("QInotifyFileSystemWatcherEngine::readFromInotify");
+ 
+     int buffSize = 0;
+-    ioctl(inotifyFd, FIONREAD, (char *) &buffSize);
++    if (ioctl(inotifyFd, FIONREAD, (char *) &buffSize) == -1 || buffSize == 0)
++        return;
++
+     QVarLengthArray<char, 4096> buffer(buffSize);
+     buffSize = read(inotifyFd, buffer.data(), buffSize);
+     char *at = buffer.data();
+diff --git a/qtbase/src/corelib/io/qlockfile_win.cpp b/qtbase/src/corelib/io/qlockfile_win.cpp
+index 277f8d4230..38ecef5550 100644
+--- a/qtbase/src/corelib/io/qlockfile_win.cpp
++++ b/qtbase/src/corelib/io/qlockfile_win.cpp
+@@ -48,6 +48,8 @@
+ #include "QtCore/qdebug.h"
+ #include "QtCore/qthread.h"
+ 
++#include "private/qsystemlibrary_p.h"
++
+ QT_BEGIN_NAMESPACE
+ 
+ static inline bool fileExists(const wchar_t *fileName)
+@@ -150,7 +152,7 @@ QString QLockFilePrivate::processNameByPid(qint64 pid)
+ #if !defined(Q_OS_WINRT)
+     typedef DWORD (WINAPI *GetModuleFileNameExFunc)(HANDLE, HMODULE, LPTSTR, DWORD);
+ 
+-    HMODULE hPsapi = LoadLibraryA("psapi");
++    HMODULE hPsapi = QSystemLibrary::load(L"psapi");
+     if (!hPsapi)
+         return QString();
+     GetModuleFileNameExFunc qGetModuleFileNameEx = reinterpret_cast<GetModuleFileNameExFunc>(
+diff --git a/qtbase/src/corelib/io/qprocess_unix.cpp b/qtbase/src/corelib/io/qprocess_unix.cpp
+index 50390e57f5..15c8f30745 100644
+--- a/qtbase/src/corelib/io/qprocess_unix.cpp
++++ b/qtbase/src/corelib/io/qprocess_unix.cpp
+@@ -1,7 +1,7 @@
+ /****************************************************************************
+ **
+ ** Copyright (C) 2016 The Qt Company Ltd.
+-** Copyright (C) 2016 Intel Corporation.
++** Copyright (C) 2022 Intel Corporation.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtCore module of the Qt Toolkit.
+@@ -422,14 +422,15 @@ void QProcessPrivate::startProcess()
+     // Add the program name to the argument list.
+     argv[0] = nullptr;
+     if (!program.contains(QLatin1Char('/'))) {
++        // findExecutable() returns its argument if it's an absolute path,
++        // otherwise it searches $PATH; returns empty if not found (we handle
++        // that case much later)
+         const QString &exeFilePath = QStandardPaths::findExecutable(program);
+-        if (!exeFilePath.isEmpty()) {
+-            const QByteArray &tmp = QFile::encodeName(exeFilePath);
+-            argv[0] = ::strdup(tmp.constData());
+-        }
+-    }
+-    if (!argv[0])
++        const QByteArray &tmp = QFile::encodeName(exeFilePath);
++        argv[0] = ::strdup(tmp.constData());
++    } else {
+         argv[0] = ::strdup(encodedProgramName.constData());
++    }
+ 
+     // Add every argument to the list
+     for (int i = 0; i < arguments.count(); ++i)
+@@ -983,15 +984,16 @@ bool QProcessPrivate::startDetached(qint64 *pid)
+                 envp = _q_dupEnvironment(environment.d.constData()->vars, &envc);
+             }
+ 
+-            QByteArray tmp;
+             if (!program.contains(QLatin1Char('/'))) {
++                // findExecutable() returns its argument if it's an absolute path,
++                // otherwise it searches $PATH; returns empty if not found (we handle
++                // that case much later)
+                 const QString &exeFilePath = QStandardPaths::findExecutable(program);
+-                if (!exeFilePath.isEmpty())
+-                    tmp = QFile::encodeName(exeFilePath);
++                const QByteArray &tmp = QFile::encodeName(exeFilePath);
++                argv[0] = ::strdup(tmp.constData());
++            } else {
++                argv[0] = ::strdup(QFile::encodeName(program));
+             }
+-            if (tmp.isEmpty())
+-                tmp = QFile::encodeName(program);
+-            argv[0] = tmp.data();
+ 
+             if (envp)
+                 qt_safe_execve(argv[0], argv, envp);
+diff --git a/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp b/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
+index 3a79c502af..997a634e76 100644
+--- a/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
++++ b/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
+@@ -3196,9 +3196,8 @@ bool QAbstractItemModel::beginMoveColumns(const QModelIndex &sourceParent, int s
+     destinationChange.needsAdjust = destinationParent.isValid() && destinationParent.row() >= sourceLast && destinationParent.parent() == sourceParent;
+     d->changes.push(destinationChange);
+ 
+-    d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Horizontal);
+-
+     emit columnsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, QPrivateSignal());
++    d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Horizontal);
+     return true;
+ }
+ 
+@@ -3231,7 +3230,6 @@ void QAbstractItemModel::endMoveColumns()
+       adjustedSource = createIndex(adjustedSource.row(), adjustedSource.column() + numMoved, adjustedSource.internalPointer());
+ 
+     d->itemsMoved(adjustedSource, removeChange.first, removeChange.last, adjustedDestination, insertChange.first, Qt::Horizontal);
+-
+     emit columnsMoved(adjustedSource, removeChange.first, removeChange.last, adjustedDestination, insertChange.first, QPrivateSignal());
+ }
+ 
+diff --git a/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+index dc6379d9fb..c5e287ee84 100644
+--- a/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
++++ b/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+@@ -939,8 +939,9 @@ void QSortFilterProxyModelPrivate::insert_source_items(
+                 q->beginInsertColumns(proxy_parent, proxy_start, proxy_end);
+         }
+ 
+-        for (int i = 0; i < source_items.size(); ++i)
+-            proxy_to_source.insert(proxy_start + i, source_items.at(i));
++        // TODO: use the range QList::insert() overload once it is implemented (QTBUG-58633).
++        proxy_to_source.insert(proxy_start, source_items.size(), 0);
++        std::copy(source_items.cbegin(), source_items.cend(), proxy_to_source.begin() + proxy_start);
+ 
+         build_source_to_proxy_mapping(proxy_to_source, source_to_proxy);
+ 
+@@ -3123,8 +3124,9 @@ bool QSortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex &
+ 
+     if (d->filter_data.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();
+@@ -3133,9 +3135,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.hasMatch(key);
+ }
+diff --git a/qtbase/src/corelib/kernel/qcoreapplication.cpp b/qtbase/src/corelib/kernel/qcoreapplication.cpp
+index ca2864df83..132b2eae52 100644
+--- a/qtbase/src/corelib/kernel/qcoreapplication.cpp
++++ b/qtbase/src/corelib/kernel/qcoreapplication.cpp
+@@ -1157,7 +1157,7 @@ static bool doNotify(QObject *receiver, QEvent *event)
+ bool QCoreApplicationPrivate::sendThroughApplicationEventFilters(QObject *receiver, QEvent *event)
+ {
+     // We can't access the application event filters outside of the main thread (race conditions)
+-    Q_ASSERT(receiver->d_func()->threadData.loadRelaxed()->thread.loadAcquire() == mainThread());
++    Q_ASSERT(receiver->d_func()->threadData.loadAcquire()->thread.loadRelaxed() == mainThread());
+ 
+     if (extraData) {
+         // application event filters are only called for objects in the GUI thread
+diff --git a/qtbase/src/corelib/kernel/qobject.cpp b/qtbase/src/corelib/kernel/qobject.cpp
+index 1eb79138d9..36cd780ee1 100644
+--- a/qtbase/src/corelib/kernel/qobject.cpp
++++ b/qtbase/src/corelib/kernel/qobject.cpp
+@@ -1010,7 +1010,7 @@ QObject::~QObject()
+         emit destroyed(this);
+     }
+ 
+-    if (d->declarativeData) {
++    if (!d->isDeletingChildren && d->declarativeData) {
+         if (static_cast<QAbstractDeclarativeDataImpl*>(d->declarativeData)->ownedByQml1) {
+             if (QAbstractDeclarativeData::destroyed_qml1)
+                 QAbstractDeclarativeData::destroyed_qml1(d->declarativeData, this);
+@@ -1580,7 +1580,7 @@ void QObject::moveToThread(QThread *targetThread)
+ 
+     QThreadData *currentData = QThreadData::current();
+     QThreadData *targetData = targetThread ? QThreadData::get2(targetThread) : nullptr;
+-    QThreadData *thisThreadData = d->threadData.loadRelaxed();
++    QThreadData *thisThreadData = d->threadData.loadAcquire();
+     if (!thisThreadData->thread.loadAcquire() && currentData == targetData) {
+         // one exception to the rule: we allow moving objects with no thread affinity to the current thread
+         currentData = d->threadData;
+@@ -2620,7 +2620,7 @@ int QObject::receivers(const char *signal) const
+         if (!d->isSignalConnected(signal_index))
+             return receivers;
+ 
+-        if (d->declarativeData && QAbstractDeclarativeData::receivers) {
++        if (!d->isDeletingChildren && d->declarativeData && QAbstractDeclarativeData::receivers) {
+             receivers += QAbstractDeclarativeData::receivers(d->declarativeData, this,
+                                                              signal_index);
+         }
+diff --git a/qtbase/src/corelib/kernel/qobject_p.h b/qtbase/src/corelib/kernel/qobject_p.h
+index 0b827a52ca..13ffb88999 100644
+--- a/qtbase/src/corelib/kernel/qobject_p.h
++++ b/qtbase/src/corelib/kernel/qobject_p.h
+@@ -444,7 +444,7 @@ inline void QObjectPrivate::checkForIncompatibleLibraryVersion(int version) cons
+ 
+ inline bool QObjectPrivate::isDeclarativeSignalConnected(uint signal_index) const
+ {
+-    return declarativeData && QAbstractDeclarativeData::isSignalConnected
++    return !isDeletingChildren && declarativeData && QAbstractDeclarativeData::isSignalConnected
+             && QAbstractDeclarativeData::isSignalConnected(declarativeData, q_func(), signal_index);
+ }
+ 
+diff --git a/qtbase/src/corelib/kernel/qtranslator.cpp b/qtbase/src/corelib/kernel/qtranslator.cpp
+index 2812ffb7ea..bc0177c5ec 100644
+--- a/qtbase/src/corelib/kernel/qtranslator.cpp
++++ b/qtbase/src/corelib/kernel/qtranslator.cpp
+@@ -902,7 +902,7 @@ static QString getMessage(const uchar *m, const uchar *end, const char *context,
+             goto end;
+         case Tag_Translation: {
+             int len = read32(m);
+-            if (len % 1)
++            if (len & 1)
+                 return QString();
+             m += 4;
+             if (!numerus--) {
+diff --git a/qtbase/src/corelib/mimetypes/qmimedatabase.cpp b/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
+index 9de22cef33..ff868a3268 100644
+--- a/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
+@@ -389,20 +389,23 @@ QMimeType QMimeDatabasePrivate::mimeTypeForFileNameAndData(const QString &fileNa
+         // Disambiguate conflicting extensions (if magic matching found something)
+         if (candidateByData.isValid() && magicAccuracy > 0) {
+             const QString sniffedMime = candidateByData.name();
+-            // If the sniffedMime matches a glob match, use it
++            // If the sniffedMime matches a highest-weight glob match, use it
+             if (candidatesByName.m_matchingMimeTypes.contains(sniffedMime)) {
+                 *accuracyPtr = 100;
+                 return candidateByData;
+             }
+-            for (const QString &m : qAsConst(candidatesByName.m_matchingMimeTypes)) {
++            for (const QString &m : qAsConst(candidatesByName.m_allMatchingMimeTypes)) {
+                 if (inherits(m, sniffedMime)) {
+                     // We have magic + pattern pointing to this, so it's a pretty good match
+                     *accuracyPtr = 100;
+                     return mimeTypeForName(m);
+                 }
+             }
+-            *accuracyPtr = magicAccuracy;
+-            return candidateByData;
++            if (candidatesByName.m_allMatchingMimeTypes.isEmpty()) {
++                // No glob, use magic
++                *accuracyPtr = magicAccuracy;
++                return candidateByData;
++            }
+         }
+     }
+ 
+diff --git a/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp b/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
+index a81112d227..fa8f4c545d 100644
+--- a/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
+@@ -83,7 +83,10 @@ void QMimeGlobMatchResult::addMatch(const QString &mimeType, int weight, const Q
+     }
+     if (!m_matchingMimeTypes.contains(mimeType)) {
+         m_matchingMimeTypes.append(mimeType);
+-        m_allMatchingMimeTypes.append(mimeType);
++        if (replace)
++            m_allMatchingMimeTypes.prepend(mimeType); // highest-weight first
++        else
++            m_allMatchingMimeTypes.append(mimeType);
+         m_knownSuffixLength = knownSuffixLength;
+     }
+ }
+@@ -94,7 +97,7 @@ QMimeGlobPattern::PatternType QMimeGlobPattern::detectPatternType(const QString
+     if (!patternLength)
+         return OtherPattern;
+ 
+-    const bool starCount = pattern.count(QLatin1Char('*')) == 1;
++    const int starCount = pattern.count(QLatin1Char('*'));
+     const bool hasSquareBracket = pattern.indexOf(QLatin1Char('[')) != -1;
+     const bool hasQuestionMark = pattern.indexOf(QLatin1Char('?')) != -1;
+ 
+@@ -106,10 +109,10 @@ QMimeGlobPattern::PatternType QMimeGlobPattern::detectPatternType(const QString
+             // Patterns like "README*" (well this is currently the only one like that...)
+             if (pattern.at(patternLength - 1) == QLatin1Char('*'))
+                 return PrefixPattern;
+-        }
+-        // Names without any wildcards like "README"
+-        if (starCount == 0)
++        } else if (starCount == 0) {
++            // Names without any wildcards like "README"
+             return LiteralPattern;
++        }
+     }
+ 
+     if (pattern == QLatin1String("[0-9][0-9][0-9].vdr"))
+diff --git a/qtbase/src/corelib/mimetypes/qmimeprovider.cpp b/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
+index 258dddf8cb..4642d0f2d0 100644
+--- a/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
+@@ -244,15 +244,18 @@ void QMimeBinaryProvider::addFileNameMatches(const QString &fileName, QMimeGlobM
+     const QString lowerFileName = fileName.toLower();
+     // Check literals (e.g. "Makefile")
+     matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosLiteralListOffset), fileName);
+-    // Check complex globs (e.g. "callgrind.out[0-9]*")
+-    matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosGlobListOffset), fileName);
+     // Check the very common *.txt cases with the suffix tree
+-    const int reverseSuffixTreeOffset = m_cacheFile->getUint32(PosReverseSuffixTreeOffset);
+-    const int numRoots = m_cacheFile->getUint32(reverseSuffixTreeOffset);
+-    const int firstRootOffset = m_cacheFile->getUint32(reverseSuffixTreeOffset + 4);
+-    matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, lowerFileName, lowerFileName.length() - 1, false);
++    if (result.m_matchingMimeTypes.isEmpty()) {
++        const int reverseSuffixTreeOffset = m_cacheFile->getUint32(PosReverseSuffixTreeOffset);
++        const int numRoots = m_cacheFile->getUint32(reverseSuffixTreeOffset);
++        const int firstRootOffset = m_cacheFile->getUint32(reverseSuffixTreeOffset + 4);
++        matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, lowerFileName, lowerFileName.length() - 1, false);
++        if (result.m_matchingMimeTypes.isEmpty())
++            matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, fileName, fileName.length() - 1, true);
++    }
++    // Check complex globs (e.g. "callgrind.out[0-9]*" or "README*")
+     if (result.m_matchingMimeTypes.isEmpty())
+-        matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, fileName, fileName.length() - 1, true);
++        matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosGlobListOffset), fileName);
+ }
+ 
+ void QMimeBinaryProvider::matchGlobList(QMimeGlobMatchResult &result, CacheFile *cacheFile, int off, const QString &fileName)
+diff --git a/qtbase/src/corelib/serialization/qjsonparser.cpp b/qtbase/src/corelib/serialization/qjsonparser.cpp
+index 17e6f111ab..2e40b6c8fb 100644
+--- a/qtbase/src/corelib/serialization/qjsonparser.cpp
++++ b/qtbase/src/corelib/serialization/qjsonparser.cpp
+@@ -379,10 +379,30 @@ error:
+     return QCborValue();
+ }
+ 
++// We need to retain the _last_ value for any duplicate keys and we need to deref containers.
++// Therefore the manual implementation of std::unique().
++template<typename Iterator, typename Compare, typename Assign>
++static Iterator customAssigningUniqueLast(Iterator first, Iterator last,
++                                          Compare compare, Assign assign)
++{
++    first = std::adjacent_find(first, last, compare);
++    if (first == last)
++        return last;
++
++    Iterator result = first;
++    while (++first != last) {
++        if (!compare(*result, *first))
++            ++result;
++        if (result != first)
++            assign(*result, *first);
++    }
++
++    return ++result;
++}
++
+ static void sortContainer(QCborContainerPrivate *container)
+ {
+     using Forward = QJsonPrivate::KeyIterator;
+-    using Reverse = std::reverse_iterator<Forward>;
+     using Value = Forward::value_type;
+ 
+     auto compare = [container](const Value &a, const Value &b)
+@@ -420,17 +440,31 @@ static void sortContainer(QCborContainerPrivate *container)
+         }
+     };
+ 
+-    std::sort(Forward(container->elements.begin()), Forward(container->elements.end()),
+-              [&compare](const Value &a, const Value &b) { return compare(a, b) < 0; });
++    // The elements' containers are owned by the outer container, not by the elements themselves.
++    auto move = [](Forward::reference target, Forward::reference source)
++    {
++        QtCbor::Element &targetValue = target.value();
++
++        // If the target has a container, deref it before overwriting, so that we don't leak.
++        if (targetValue.flags & QtCbor::Element::IsContainer)
++            targetValue.container->deref();
++
++        // Do not move, so that we can clear the value afterwards.
++        target = source;
++
++        // Clear the source value, so that we don't store the same container twice.
++        source.value() = QtCbor::Element();
++    };
++
++    std::stable_sort(
++                Forward(container->elements.begin()), Forward(container->elements.end()),
++                [&compare](const Value &a, const Value &b) { return compare(a, b) < 0; });
+ 
+-    // We need to retain the _last_ value for any duplicate keys. Therefore the reverse dance here.
+-    auto it = std::unique(Reverse(container->elements.end()), Reverse(container->elements.begin()),
+-                          [&compare](const Value &a, const Value &b) {
+-        return compare(a, b) == 0;
+-    }).base().elementsIterator();
++    Forward result = customAssigningUniqueLast(
++                Forward(container->elements.begin()),  Forward(container->elements.end()),
++                [&compare](const Value &a, const Value &b) { return compare(a, b) == 0; }, move);
+ 
+-    // The erase from beginning is expensive but hopefully rare.
+-    container->elements.erase(container->elements.begin(), it);
++    container->elements.erase(result.elementsIterator(), container->elements.end());
+ }
+ 
+ 
+diff --git a/qtbase/src/corelib/serialization/qxmlstream.cpp b/qtbase/src/corelib/serialization/qxmlstream.cpp
+index b2f846544d..7cd457ba3a 100644
+--- a/qtbase/src/corelib/serialization/qxmlstream.cpp
++++ b/qtbase/src/corelib/serialization/qxmlstream.cpp
+@@ -980,7 +980,7 @@ inline uint QXmlStreamReaderPrivate::peekChar()
+ bool QXmlStreamReaderPrivate::scanUntil(const char *str, short tokenToInject)
+ {
+     int pos = textBuffer.size();
+-    int oldLineNumber = lineNumber;
++    const auto oldLineNumber = lineNumber;
+ 
+     uint c;
+     while ((c = getChar()) != StreamEOF) {
+diff --git a/qtbase/src/corelib/text/qstring.cpp b/qtbase/src/corelib/text/qstring.cpp
+index 3e88ab4859..8deeae47bb 100644
+--- a/qtbase/src/corelib/text/qstring.cpp
++++ b/qtbase/src/corelib/text/qstring.cpp
+@@ -12312,7 +12312,7 @@ static qsizetype qLastIndexOf(Haystack haystack0, qsizetype from,
+     const auto needle = needle0.data();
+     const auto *end = haystack;
+     haystack += from;
+-    const std::size_t sl_minus_1 = sl - 1;
++    const std::size_t sl_minus_1 = sl ? sl - 1 : 0;
+     const auto *n = needle + sl_minus_1;
+     const auto *h = haystack + sl_minus_1;
+     std::size_t hashNeedle = 0, hashHaystack = 0;
+diff --git a/qtbase/src/corelib/text/qstringiterator_p.h b/qtbase/src/corelib/text/qstringiterator_p.h
+index 219589b6e4..1d0c66cc78 100644
+--- a/qtbase/src/corelib/text/qstringiterator_p.h
++++ b/qtbase/src/corelib/text/qstringiterator_p.h
+@@ -61,6 +61,8 @@ class QStringIterator
+ {
+     QString::const_iterator i, pos, e;
+     Q_STATIC_ASSERT((std::is_same<QString::const_iterator, const QChar *>::value));
++    static bool less(const QChar *lhs, const QChar *rhs) noexcept
++    { return std::less<QString::const_iterator>{}(lhs, rhs); }
+ public:
+     explicit QStringIterator(QStringView string, qsizetype idx = 0)
+         : i(string.begin()),
+@@ -95,7 +97,8 @@ public:
+ 
+     inline void setPosition(QString::const_iterator position)
+     {
+-        Q_ASSERT_X(i <= position && position <= e, Q_FUNC_INFO, "position out of bounds");
++        Q_ASSERT_X(!less(position, i) && !less(e, position),
++                   Q_FUNC_INFO, "position out of bounds");
+         pos = position;
+     }
+ 
+@@ -103,7 +106,7 @@ public:
+ 
+     inline bool hasNext() const
+     {
+-        return pos < e;
++        return less(pos, e);
+     }
+ 
+     inline void advance()
+@@ -120,16 +123,20 @@ public:
+     {
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+-        if (Q_UNLIKELY((pos++)->isHighSurrogate()))
++        if (Q_UNLIKELY((pos++)->isHighSurrogate())) {
++            Q_ASSERT(hasNext() && pos->isLowSurrogate());
+             ++pos;
++        }
+     }
+ 
+     inline uint peekNextUnchecked() const
+     {
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+-        if (Q_UNLIKELY(pos->isHighSurrogate()))
++        if (Q_UNLIKELY(pos->isHighSurrogate())) {
++            Q_ASSERT(less(pos + 1, e) && pos[1].isLowSurrogate());
+             return QChar::surrogateToUcs4(pos[0], pos[1]);
++        }
+ 
+         return pos->unicode();
+     }
+@@ -155,8 +162,10 @@ public:
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+         const QChar cur = *pos++;
+-        if (Q_UNLIKELY(cur.isHighSurrogate()))
++        if (Q_UNLIKELY(cur.isHighSurrogate())) {
++            Q_ASSERT(hasNext() && pos->isLowSurrogate());
+             return QChar::surrogateToUcs4(cur, *pos++);
++        }
+         return cur.unicode();
+     }
+ 
+@@ -166,7 +175,7 @@ public:
+ 
+         const QChar uc = *pos++;
+         if (Q_UNLIKELY(uc.isSurrogate())) {
+-            if (Q_LIKELY(uc.isHighSurrogate() && pos < e && pos->isLowSurrogate()))
++            if (Q_LIKELY(uc.isHighSurrogate() && hasNext() && pos->isLowSurrogate()))
+                 return QChar::surrogateToUcs4(uc, *pos++);
+             return invalidAs;
+         }
+@@ -178,7 +187,7 @@ public:
+ 
+     inline bool hasPrevious() const
+     {
+-        return pos > i;
++        return less(i, pos);
+     }
+ 
+     inline void recede()
+@@ -196,16 +205,20 @@ public:
+     {
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+-        if (Q_UNLIKELY((--pos)->isLowSurrogate()))
++        if (Q_UNLIKELY((--pos)->isLowSurrogate())) {
++            Q_ASSERT(hasPrevious() && pos[-1].isHighSurrogate());
+             --pos;
++        }
+     }
+ 
+     inline uint peekPreviousUnchecked() const
+     {
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+-        if (Q_UNLIKELY(pos[-1].isLowSurrogate()))
++        if (Q_UNLIKELY(pos[-1].isLowSurrogate())) {
++            Q_ASSERT(less(i + 1, pos) && pos[-2].isHighSurrogate());
+             return QChar::surrogateToUcs4(pos[-2], pos[-1]);
++        }
+         return pos[-1].unicode();
+     }
+ 
+@@ -230,8 +243,10 @@ public:
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+         const QChar cur = *--pos;
+-        if (Q_UNLIKELY(cur.isLowSurrogate()))
++        if (Q_UNLIKELY(cur.isLowSurrogate())) {
++            Q_ASSERT(hasPrevious() && pos[-1].isHighSurrogate());
+             return QChar::surrogateToUcs4(*--pos, cur);
++        }
+         return cur.unicode();
+     }
+ 
+@@ -241,7 +256,7 @@ public:
+ 
+         const QChar uc = *--pos;
+         if (Q_UNLIKELY(uc.isSurrogate())) {
+-            if (Q_LIKELY(uc.isLowSurrogate() && pos > i && pos[-1].isHighSurrogate()))
++            if (Q_LIKELY(uc.isLowSurrogate() && hasPrevious() && pos[-1].isHighSurrogate()))
+                 return QChar::surrogateToUcs4(*--pos, uc);
+             return invalidAs;
+         }
+diff --git a/qtbase/src/corelib/thread/qfutex_p.h b/qtbase/src/corelib/thread/qfutex_p.h
+index f287b752d7..e294537787 100644
+--- a/qtbase/src/corelib/thread/qfutex_p.h
++++ b/qtbase/src/corelib/thread/qfutex_p.h
+@@ -52,6 +52,7 @@
+ //
+ 
+ #include <qglobal.h>
++#include <QtCore/qtsan_impl.h>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -106,16 +107,13 @@ namespace QtLinuxFutex {
+     inline int _q_futex(int *addr, int op, int val, quintptr val2 = 0,
+                         int *addr2 = nullptr, int val3 = 0) noexcept
+     {
+-        // A futex call ensures total ordering on the futex words
+-        // (in either success or failure of the call). Instruct TSAN accordingly,
+-        // as TSAN does not understand the futex(2) syscall.
+-        _q_tsan_release(addr, addr2);
++        QtTsan::futexRelease(addr, addr2);
+ 
+         // we use __NR_futex because some libcs (like Android's bionic) don't
+         // provide SYS_futex etc.
+         int result = syscall(__NR_futex, addr, op | FUTEX_PRIVATE_FLAG, val, val2, addr2, val3);
+ 
+-        _q_tsan_acquire(addr, addr2);
++        QtTsan::futexAcquire(addr, addr2);
+ 
+         return result;
+     }
+diff --git a/qtbase/src/corelib/thread/qmutex.cpp b/qtbase/src/corelib/thread/qmutex.cpp
+index 310d1cb14f..7097122d8e 100644
+--- a/qtbase/src/corelib/thread/qmutex.cpp
++++ b/qtbase/src/corelib/thread/qmutex.cpp
+@@ -152,6 +152,7 @@ public:
+ 
+ /*!
+     \enum QMutex::RecursionMode
++    \obsolete Use QRecursiveMutex to create a recursive mutex.
+ 
+     \value Recursive  In this mode, a thread can lock the same mutex
+                       multiple times and the mutex won't be unlocked
+@@ -173,6 +174,7 @@ public:
+ 
+ /*!
+     Constructs a new mutex. The mutex is created in an unlocked state.
++    \obsolete Use QRecursiveMutex to create a recursive mutex.
+ 
+     If \a mode is QMutex::Recursive, a thread can lock the same mutex
+     multiple times and the mutex won't be unlocked until a
+@@ -197,7 +199,7 @@ QMutex::QMutex(RecursionMode mode)
+ QMutex::~QMutex()
+ {
+     QMutexData *d = d_ptr.loadRelaxed();
+-    if (isRecursive()) {
++    if (QBasicMutex::isRecursive()) {
+         delete static_cast<QRecursiveMutexPrivate *>(d);
+     } else if (d) {
+ #ifndef QT_LINUX_FUTEX
+diff --git a/qtbase/src/corelib/thread/qmutex.h b/qtbase/src/corelib/thread/qmutex.h
+index 73c9e00663..1bae573a03 100644
+--- a/qtbase/src/corelib/thread/qmutex.h
++++ b/qtbase/src/corelib/thread/qmutex.h
+@@ -42,6 +42,7 @@
+ 
+ #include <QtCore/qglobal.h>
+ #include <QtCore/qatomic.h>
++#include <QtCore/qtsan_impl.h>
+ #include <new>
+ 
+ #if __has_include(<chrono>)
+@@ -77,19 +78,37 @@ public:
+ 
+     // BasicLockable concept
+     inline void lock() QT_MUTEX_LOCK_NOEXCEPT {
++        QtTsan::mutexPreLock(this, 0u);
++
+         if (!fastTryLock())
+             lockInternal();
++
++        QtTsan::mutexPostLock(this, 0u, 0);
+     }
+ 
+     // BasicLockable concept
+     inline void unlock() noexcept {
+         Q_ASSERT(d_ptr.loadRelaxed()); //mutex must be locked
++
++        QtTsan::mutexPreUnlock(this, 0u);
++
+         if (!fastTryUnlock())
+             unlockInternal();
++
++        QtTsan::mutexPostUnlock(this, 0u);
+     }
+ 
+     bool tryLock() noexcept {
+-        return fastTryLock();
++        unsigned tsanFlags = QtTsan::TryLock;
++        QtTsan::mutexPreLock(this, tsanFlags);
++
++        const bool success = fastTryLock();
++
++        if (!success)
++            tsanFlags |= QtTsan::TryLockFailed;
++        QtTsan::mutexPostLock(this, tsanFlags, 0);
++
++        return success;
+     }
+ 
+     // Lockable concept
+@@ -134,8 +153,16 @@ public:
+ #else
+     QMutex() { d_ptr.storeRelaxed(nullptr); }
+ #endif
++#if QT_DEPRECATED_SINCE(5,15)
+     enum RecursionMode { NonRecursive, Recursive };
++    QT_DEPRECATED_VERSION_X(5, 15, "Use QRecursiveMutex instead of a recursive QMutex")
+     explicit QMutex(RecursionMode mode);
++
++    QT_DEPRECATED_VERSION_X(5, 15, "Use QRecursiveMutex instead of a recursive QMutex")
++    bool isRecursive() const noexcept
++    { return QBasicMutex::isRecursive(); }
++#endif
++
+     ~QMutex();
+ 
+     // BasicLockable concept
+@@ -166,9 +193,6 @@ public:
+     }
+ #endif
+ 
+-    bool isRecursive() const noexcept
+-    { return QBasicMutex::isRecursive(); }
+-
+ private:
+     Q_DISABLE_COPY(QMutex)
+     friend class QMutexLocker;
+diff --git a/qtbase/src/corelib/thread/qreadwritelock.cpp b/qtbase/src/corelib/thread/qreadwritelock.cpp
+index 8c28507d5a..9dd8503116 100644
+--- a/qtbase/src/corelib/thread/qreadwritelock.cpp
++++ b/qtbase/src/corelib/thread/qreadwritelock.cpp
+@@ -155,7 +155,7 @@ QReadWriteLock::QReadWriteLock(RecursionMode recursionMode)
+ */
+ QReadWriteLock::~QReadWriteLock()
+ {
+-    auto d = d_ptr.loadRelaxed();
++    auto d = d_ptr.loadAcquire();
+     if (isUncontendedLocked(d)) {
+         qWarning("QReadWriteLock: destroying locked QReadWriteLock");
+         return;
+@@ -445,7 +445,7 @@ void QReadWriteLock::unlock()
+ /*! \internal  Helper for QWaitCondition::wait */
+ QReadWriteLock::StateForWaitCondition QReadWriteLock::stateForWaitCondition() const
+ {
+-    QReadWriteLockPrivate *d = d_ptr.loadRelaxed();
++    QReadWriteLockPrivate *d = d_ptr.loadAcquire();
+     switch (quintptr(d) & StateMask) {
+     case StateLockedForRead: return LockedForRead;
+     case StateLockedForWrite: return LockedForWrite;
+@@ -453,6 +453,7 @@ QReadWriteLock::StateForWaitCondition QReadWriteLock::stateForWaitCondition() co
+ 
+     if (!d)
+         return Unlocked;
++    const auto lock = qt_scoped_lock(d->mutex);
+     if (d->writerCount > 1)
+         return RecursivelyLocked;
+     else if (d->writerCount == 1)
+diff --git a/qtbase/src/corelib/thread/qsemaphore.cpp b/qtbase/src/corelib/thread/qsemaphore.cpp
+index 1d01fc1b28..3ecdee3747 100644
+--- a/qtbase/src/corelib/thread/qsemaphore.cpp
++++ b/qtbase/src/corelib/thread/qsemaphore.cpp
+@@ -354,7 +354,12 @@ void QSemaphore::release(int n)
+         quintptr nn = unsigned(n);
+         if (futexHasWaiterCount)
+             nn |= quint64(nn) << 32;    // token count replicated in high word
+-        quintptr prevValue = u.fetchAndAddRelease(nn);
++        quintptr prevValue = u.loadRelaxed();
++        quintptr newValue;
++        do { // loop just to ensure the operations are done atomically
++            newValue = prevValue + nn;
++            newValue &= (futexNeedsWakeAllBit - 1);
++        } while (!u.testAndSetRelease(prevValue, newValue, prevValue));
+         if (futexNeedsWake(prevValue)) {
+ #ifdef FUTEX_OP
+             if (futexHasWaiterCount) {
+@@ -376,7 +381,6 @@ void QSemaphore::release(int n)
+                 quint32 oparg = 0;
+                 quint32 cmp = FUTEX_OP_CMP_NE;
+                 quint32 cmparg = 0;
+-                u.fetchAndAndRelease(futexNeedsWakeAllBit - 1);
+                 futexWakeOp(*futexLow32(&u), n, INT_MAX, *futexHigh32(&u), FUTEX_OP(op, oparg, cmp, cmparg));
+                 return;
+             }
+@@ -388,7 +392,6 @@ 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(futexNeedsWakeAllBit - 1);
+             if (futexHasWaiterCount) {
+                 futexWakeAll(*futexLow32(&u));
+                 futexWakeAll(*futexHigh32(&u));
+diff --git a/qtbase/src/corelib/thread/qthread_p.h b/qtbase/src/corelib/thread/qthread_p.h
+index b2d1628e6e..f32f6f0460 100644
+--- a/qtbase/src/corelib/thread/qthread_p.h
++++ b/qtbase/src/corelib/thread/qthread_p.h
+@@ -174,7 +174,7 @@ public:
+     int returnCode;
+ 
+     uint stackSize;
+-    QThread::Priority priority;
++    std::underlying_type<QThread::Priority>::type priority;
+ 
+     static QThread *threadForId(int id);
+ 
+@@ -213,6 +213,13 @@ public:
+             QCoreApplication::instance()->postEvent(q_ptr, new QEvent(QEvent::Quit));
+         }
+     }
++
++#ifndef Q_OS_INTEGRITY
++private:
++    // Used in QThread(Private)::start to avoid racy access to QObject::objectName,
++    // unset afterwards. On INTEGRITY we set the thread name before starting it.
++    QString objectName;
++#endif
+ };
+ 
+ #else // QT_CONFIG(thread)
+diff --git a/qtbase/src/corelib/thread/qthread_unix.cpp b/qtbase/src/corelib/thread/qthread_unix.cpp
+index 56a8e0a038..610117a640 100644
+--- a/qtbase/src/corelib/thread/qthread_unix.cpp
++++ b/qtbase/src/corelib/thread/qthread_unix.cpp
+@@ -169,8 +169,7 @@ static void set_thread_data(QThreadData *data)
+ 
+ static void clear_thread_data()
+ {
+-    currentThreadData = nullptr;
+-    pthread_setspecific(current_thread_data_key, nullptr);
++    set_thread_data(nullptr);
+ }
+ 
+ template <typename T>
+@@ -296,7 +295,7 @@ void *QThreadPrivate::start(void *arg)
+             QMutexLocker locker(&thr->d_func()->mutex);
+ 
+             // do we need to reset the thread priority?
+-            if (int(thr->d_func()->priority) & ThreadPriorityResetFlag) {
++            if (thr->d_func()->priority & ThreadPriorityResetFlag) {
+                 thr->d_func()->setPriority(QThread::Priority(thr->d_func()->priority & ~ThreadPriorityResetFlag));
+             }
+ 
+@@ -316,10 +315,10 @@ void *QThreadPrivate::start(void *arg)
+             // Sets the name of the current thread. We can only do this
+             // when the thread is starting, as we don't have a cross
+             // platform way of setting the name of an arbitrary thread.
+-            if (Q_LIKELY(thr->objectName().isEmpty()))
++            if (Q_LIKELY(thr->d_func()->objectName.isEmpty()))
+                 setCurrentThreadName(thr->metaObject()->className());
+             else
+-                setCurrentThreadName(thr->objectName().toLocal8Bit());
++                setCurrentThreadName(std::exchange(thr->d_func()->objectName, {}).toLocal8Bit());
+         }
+ #endif
+ 
+@@ -671,7 +670,7 @@ void QThread::start(Priority priority)
+                 // could not set scheduling hints, fallback to inheriting them
+                 // we'll try again from inside the thread
+                 pthread_attr_setinheritsched(&attr, PTHREAD_INHERIT_SCHED);
+-                d->priority = Priority(priority | ThreadPriorityResetFlag);
++                d->priority = static_cast<std::underlying_type<QThread::Priority>::type>(priority) | ThreadPriorityResetFlag;
+             }
+             break;
+         }
+@@ -702,7 +701,10 @@ void QThread::start(Priority priority)
+         pthread_attr_setthreadname(&attr, metaObject()->className());
+     else
+         pthread_attr_setthreadname(&attr, objectName().toLocal8Bit());
++#else
++    d->objectName = objectName();
+ #endif
++
+     pthread_t threadId;
+     int code = pthread_create(&threadId, &attr, QThreadPrivate::start, this);
+     if (code == EPERM) {
+diff --git a/qtbase/src/corelib/thread/qthread_win.cpp b/qtbase/src/corelib/thread/qthread_win.cpp
+index bc70e3178a..4e76972498 100644
+--- a/qtbase/src/corelib/thread/qthread_win.cpp
++++ b/qtbase/src/corelib/thread/qthread_win.cpp
+@@ -394,10 +394,9 @@ unsigned int __stdcall QT_ENSURE_STACK_ALIGNED_FOR_SSE QThreadPrivate::start(voi
+ 
+ #if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) && !defined(Q_OS_WINRT)
+     // sets the name of the current thread.
+-    QByteArray objectName = thr->objectName().toLocal8Bit();
+-    qt_set_thread_name(HANDLE(-1),
+-                       objectName.isEmpty() ?
+-                       thr->metaObject()->className() : objectName.constData());
++    qt_set_thread_name(HANDLE(-1), thr->d_func()->objectName.isEmpty()
++                        ? thr->metaObject()->className()
++                        : std::exchange(thr->d_func()->objectName, {}).toLocal8Bit().constData());
+ #endif
+ 
+     emit thr->started(QThread::QPrivateSignal());
+@@ -503,6 +502,7 @@ void QThread::start(Priority priority)
+     if (d->running)
+         return;
+ 
++    d->objectName = objectName();
+     d->running = true;
+     d->finished = false;
+     d->exited = false;
+@@ -548,7 +548,7 @@ void QThread::start(Priority priority)
+ 
+     int prio;
+     d->priority = priority;
+-    switch (d->priority) {
++    switch (priority) {
+     case IdlePriority:
+         prio = THREAD_PRIORITY_IDLE;
+         break;
+@@ -686,7 +686,7 @@ void QThreadPrivate::setPriority(QThread::Priority threadPriority)
+ 
+     int prio;
+     priority = threadPriority;
+-    switch (priority) {
++    switch (threadPriority) {
+     case QThread::IdlePriority:
+         prio = THREAD_PRIORITY_IDLE;
+         break;
+diff --git a/qtbase/src/corelib/thread/qtsan_impl.h b/qtbase/src/corelib/thread/qtsan_impl.h
+new file mode 100644
+index 0000000000..580a738b91
+--- /dev/null
++++ b/qtbase/src/corelib/thread/qtsan_impl.h
+@@ -0,0 +1,115 @@
++/****************************************************************************
++**
++** Copyright (C) 2017 Intel Corporation.
++** Copyright (C) 2022 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
++** 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 QTSAN_IMPL_H
++#define QTSAN_IMPL_H
++
++#include <QtCore/qglobal.h>
++
++#if (__has_feature(thread_sanitizer) || defined(__SANITIZE_THREAD__)) && __has_include(<sanitizer/tsan_interface.h>)
++#  define QT_BUILDING_UNDER_TSAN
++#  include <sanitizer/tsan_interface.h>
++#endif
++
++QT_BEGIN_NAMESPACE
++
++namespace QtTsan {
++#ifdef QT_BUILDING_UNDER_TSAN
++inline void futexAcquire(void *addr, void *addr2 = nullptr)
++{
++    // A futex call ensures total ordering on the futex words
++    // (in either success or failure of the call). Instruct TSAN accordingly,
++    // as TSAN does not understand the futex(2) syscall (or equivalent).
++    ::__tsan_acquire(addr);
++    if (addr2)
++        ::__tsan_acquire(addr2);
++}
++
++inline void futexRelease(void *addr, void *addr2 = nullptr)
++{
++    if (addr2)
++        ::__tsan_release(addr2);
++    ::__tsan_release(addr);
++}
++
++inline void mutexPreLock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_pre_lock(addr, flags);
++}
++
++inline void mutexPostLock(void *addr, unsigned flags, int recursion)
++{
++    ::__tsan_mutex_post_lock(addr, flags, recursion);
++}
++
++inline void mutexPreUnlock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_pre_unlock(addr, flags);
++}
++
++inline void mutexPostUnlock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_post_unlock(addr, flags);
++}
++
++enum : unsigned {
++    MutexWriteReentrant = ::__tsan_mutex_write_reentrant,
++    TryLock = ::__tsan_mutex_try_lock,
++    TryLockFailed = ::__tsan_mutex_try_lock_failed,
++};
++#else
++inline void futexAcquire(void *, void * = nullptr) {}
++inline void futexRelease(void *, void * = nullptr) {}
++
++enum : unsigned {
++    MutexWriteReentrant,
++    TryLock,
++    TryLockFailed,
++};
++inline void mutexPreLock(void *, unsigned) {}
++inline void mutexPostLock(void *, unsigned, int) {}
++inline void mutexPreUnlock(void *, unsigned) {}
++inline void mutexPostUnlock(void *, unsigned) {}
++#endif // QT_BUILDING_UNDER_TSAN
++} // namespace QtTsan
++
++QT_END_NAMESPACE
++
++#endif // QTSAN_IMPL_H
+diff --git a/qtbase/src/corelib/thread/qwaitcondition_unix.cpp b/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
+index 88b058f410..0f1da4dc9b 100644
+--- a/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
++++ b/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
+@@ -213,7 +213,7 @@ bool QWaitCondition::wait(QMutex *mutex, QDeadlineTimer deadline)
+ {
+     if (! mutex)
+         return false;
+-    if (mutex->isRecursive()) {
++    if (static_cast<QBasicMutex *>(mutex)->isRecursive()) {
+         qWarning("QWaitCondition: cannot wait on recursive mutexes");
+         return false;
+     }
+diff --git a/qtbase/src/corelib/time/qdatetime.cpp b/qtbase/src/corelib/time/qdatetime.cpp
+index ec12569e3f..2c0b098079 100644
+--- a/qtbase/src/corelib/time/qdatetime.cpp
++++ b/qtbase/src/corelib/time/qdatetime.cpp
+@@ -43,6 +43,7 @@
+ #if QT_CONFIG(datetimeparser)
+ #include "private/qdatetimeparser_p.h"
+ #endif
++#include <private/qnumeric_p.h>
+ 
+ #include "qdatastream.h"
+ #include "qset.h"
+@@ -1429,9 +1430,11 @@ QDate QDate::addDays(qint64 ndays) const
+     if (isNull())
+         return QDate();
+ 
+-    // Due to limits on minJd() and maxJd() we know that any overflow
+-    // will be invalid and caught by fromJulianDay().
+-    return fromJulianDay(jd + ndays);
++    qint64 r;
++    if (Q_UNLIKELY(add_overflow(jd, ndays, &r)))
++        return QDate();
++    else
++        return fromJulianDay(r);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/corelib/time/qtimezone.cpp b/qtbase/src/corelib/time/qtimezone.cpp
+index 0309e43e52..3d451696a1 100644
+--- a/qtbase/src/corelib/time/qtimezone.cpp
++++ b/qtbase/src/corelib/time/qtimezone.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2013 John Layt <jlayt@kde.org>
++** Copyright (C) 2020 John Layt <jlayt@kde.org>
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtCore module of the Qt Toolkit.
+@@ -975,9 +975,15 @@ QList<QByteArray> QTimeZone::windowsIdToIanaIds(const QByteArray &windowsId,
+ }
+ 
+ #ifndef QT_NO_DATASTREAM
++// Invalid, as an IANA ID: too long, starts with - and has other invalid characters in it
++static inline QString invalidId() { return QStringLiteral("-No Time Zone Specified!"); }
++
+ QDataStream &operator<<(QDataStream &ds, const QTimeZone &tz)
+ {
+-    tz.d->serialize(ds);
++    if (tz.isValid())
++        tz.d->serialize(ds);
++    else
++        ds << invalidId();
+     return ds;
+ }
+ 
+@@ -985,7 +991,9 @@ QDataStream &operator>>(QDataStream &ds, QTimeZone &tz)
+ {
+     QString ianaId;
+     ds >> ianaId;
+-    if (ianaId == QLatin1String("OffsetFromUtc")) {
++    if (ianaId == invalidId()) {
++        tz = QTimeZone();
++    } else if (ianaId == QLatin1String("OffsetFromUtc")) {
+         int utcOffset;
+         QString name;
+         QString abbreviation;
+diff --git a/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp b/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
+index b1611d7ddb..a7a6a72ccf 100644
+--- a/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
++++ b/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
+@@ -42,6 +42,7 @@
+ #include "qtimezone.h"
+ #include "qtimezoneprivate_p.h"
+ #include "private/qlocale_tools_p.h"
++#include "private/qlocking_p.h"
+ 
+ #include <QtCore/QDataStream>
+ #include <QtCore/QDateTime>
+@@ -62,6 +63,10 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++#if QT_CONFIG(icu)
++static QBasicMutex s_icu_mutex;
++#endif
++
+ /*
+     Private
+ 
+@@ -670,6 +675,9 @@ QTzTimeZonePrivate::~QTzTimeZonePrivate()
+ 
+ QTzTimeZonePrivate *QTzTimeZonePrivate::clone() const
+ {
++#if QT_CONFIG(icu)
++    const auto lock = qt_scoped_lock(s_icu_mutex);
++#endif
+     return new QTzTimeZonePrivate(*this);
+ }
+ 
+@@ -913,12 +921,14 @@ QString QTzTimeZonePrivate::displayName(qint64 atMSecsSinceEpoch,
+                                         const QLocale &locale) const
+ {
+ #if QT_CONFIG(icu)
++    auto lock = qt_unique_lock(s_icu_mutex);
+     if (!m_icu)
+         m_icu = new QIcuTimeZonePrivate(m_id);
+     // TODO small risk may not match if tran times differ due to outdated files
+     // TODO Some valid TZ names are not valid ICU names, use translation table?
+     if (m_icu->isValid())
+         return m_icu->displayName(atMSecsSinceEpoch, nameType, locale);
++    lock.unlock();
+ #else
+     Q_UNUSED(nameType)
+     Q_UNUSED(locale)
+@@ -932,12 +942,14 @@ QString QTzTimeZonePrivate::displayName(QTimeZone::TimeType timeType,
+                                         const QLocale &locale) const
+ {
+ #if QT_CONFIG(icu)
++    auto lock = qt_unique_lock(s_icu_mutex);
+     if (!m_icu)
+         m_icu = new QIcuTimeZonePrivate(m_id);
+     // TODO small risk may not match if tran times differ due to outdated files
+     // TODO Some valid TZ names are not valid ICU names, use translation table?
+     if (m_icu->isValid())
+         return m_icu->displayName(timeType, nameType, locale);
++    lock.unlock();
+ #else
+     Q_UNUSED(timeType)
+     Q_UNUSED(nameType)
+diff --git a/qtbase/src/corelib/tools/qarraydata.h b/qtbase/src/corelib/tools/qarraydata.h
+index dcd95924c1..d01739e7e6 100644
+--- a/qtbase/src/corelib/tools/qarraydata.h
++++ b/qtbase/src/corelib/tools/qarraydata.h
+@@ -42,6 +42,7 @@
+ 
+ #include <QtCore/qrefcount.h>
+ #include <string.h>
++#include <cstdint>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -58,14 +59,14 @@ struct Q_CORE_EXPORT QArrayData
+     {
+         Q_ASSERT(size == 0
+                 || offset < 0 || size_t(offset) >= sizeof(QArrayData));
+-        return reinterpret_cast<char *>(this) + offset;
++        return reinterpret_cast<void *> (reinterpret_cast<uintptr_t>(this) + offset);
+     }
+ 
+     const void *data() const
+     {
+         Q_ASSERT(size == 0
+                 || offset < 0 || size_t(offset) >= sizeof(QArrayData));
+-        return reinterpret_cast<const char *>(this) + offset;
++        return reinterpret_cast<void *> (reinterpret_cast<uintptr_t>(this) + offset);
+     }
+ 
+     // This refers to array data mutability, not "header data" represented by
+diff --git a/qtbase/src/corelib/tools/qfreelist_p.h b/qtbase/src/corelib/tools/qfreelist_p.h
+index 5ba23b344b..9974102136 100644
+--- a/qtbase/src/corelib/tools/qfreelist_p.h
++++ b/qtbase/src/corelib/tools/qfreelist_p.h
+@@ -161,7 +161,7 @@ class QFreeList
+                 return i;
+             x -= size;
+         }
+-        Q_ASSERT(false);
++        Q_UNREACHABLE();
+         return -1;
+     }
+ 
+diff --git a/qtbase/src/corelib/tools/qversionnumber.h b/qtbase/src/corelib/tools/qversionnumber.h
+index d43b86ba51..2843f2b043 100644
+--- a/qtbase/src/corelib/tools/qversionnumber.h
++++ b/qtbase/src/corelib/tools/qversionnumber.h
+@@ -273,10 +273,10 @@ public:
+ 
+     Q_REQUIRED_RESULT Q_CORE_EXPORT QString toString() const;
+ #if QT_STRINGVIEW_LEVEL < 2
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(const QString &string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(const QString &string, int *suffixIndex = nullptr);
+ #endif
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QLatin1String string, int *suffixIndex = nullptr);
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QStringView string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(QLatin1String string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(QStringView string, int *suffixIndex = nullptr);
+ 
+ private:
+ #ifndef QT_NO_DATASTREAM
+diff --git a/qtbase/src/dbus/qdbusintegrator.cpp b/qtbase/src/dbus/qdbusintegrator.cpp
+index 5b66ce971b..28a3b0ffea 100644
+--- a/qtbase/src/dbus/qdbusintegrator.cpp
++++ b/qtbase/src/dbus/qdbusintegrator.cpp
+@@ -1135,7 +1135,13 @@ void QDBusConnectionPrivate::closeConnection()
+         }
+     }
+ 
+-    qDeleteAll(pendingCalls);
++    for (auto it = pendingCalls.begin(); it != pendingCalls.end(); ++it) {
++        auto call = *it;
++        if (!call->ref.deref()) {
++            delete call;
++        }
++    }
++    pendingCalls.clear();
+ 
+     // Disconnect all signals from signal hooks and from the object tree to
+     // avoid QObject::destroyed being sent to dbus daemon thread which has
+@@ -2584,6 +2590,11 @@ QDBusConnectionPrivate::findMetaObject(const QString &service, const QString &pa
+         if (mo)
+             return mo;
+     }
++    if (path.isEmpty()) {
++        error = QDBusError(QDBusError::InvalidObjectPath, QLatin1String("Object path cannot be empty"));
++        lastError = error;
++        return nullptr;
++    }
+ 
+     // introspect the target object
+     QDBusMessage msg = QDBusMessage::createMethodCall(service, path,
+diff --git a/qtbase/src/dbus/qdbusmetaobject.cpp b/qtbase/src/dbus/qdbusmetaobject.cpp
+index 5265568f42..7e9f0f1acc 100644
+--- a/qtbase/src/dbus/qdbusmetaobject.cpp
++++ b/qtbase/src/dbus/qdbusmetaobject.cpp
+@@ -210,6 +210,9 @@ QDBusMetaObjectGenerator::findType(const QByteArray &signature,
+         } else if (signature == "a{ss}") {
+             result.name = "QMap<QString,QString>";
+             type = qMetaTypeId<QMap<QString, QString> >();
++        } else if (signature == "aay") {
++            result.name = "QByteArrayList";
++            type = qMetaTypeId<QByteArrayList>();
+         } else {
+             result.name = "{D-Bus type \"" + signature + "\"}";
+             type = registerComplexDBusType(result.name);
+diff --git a/qtbase/src/gui/accessible/qaccessible.cpp b/qtbase/src/gui/accessible/qaccessible.cpp
+index d705bfccb5..0caf3c808c 100644
+--- a/qtbase/src/gui/accessible/qaccessible.cpp
++++ b/qtbase/src/gui/accessible/qaccessible.cpp
+@@ -54,6 +54,7 @@
+ #include <QtCore/qdebug.h>
+ #include <QtCore/qloggingcategory.h>
+ #include <QtCore/qmetaobject.h>
++#include <QtCore/private/qmetaobject_p.h>
+ #include <QtCore/qhash.h>
+ #include <private/qfactoryloader_p.h>
+ 
+@@ -681,6 +682,25 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
+     // Create a QAccessibleInterface for the object class. Start by the most
+     // derived class and walk up the class hierarchy.
+     const QMetaObject *mo = object->metaObject();
++    const auto *objectPriv = QObjectPrivate::get(object);
++    /*
++     We do not want to cache each and every QML metaobject (Button_QMLTYPE_124,
++     Button_QMLTYPE_125, etc.). Those dynamic metaobjects shouldn't have an
++     accessible interface in any case. Instead, we start the whole checking
++     with the first non-dynamic meta-object. To avoid potential regressions
++     in other areas of Qt that also use dynamic metaobjects, we only do this
++     for objects that are QML-related (approximated by checking whether they
++     have ddata set).
++    */
++    const bool qmlRelated = !objectPriv->isDeletingChildren &&
++                            objectPriv->declarativeData;
++    while (qmlRelated && mo) {
++        auto mop = QMetaObjectPrivate::get(mo);
++        if (!mop || !(mop->flags & DynamicMetaObject))
++            break;
++
++        mo = mo->superClass();
++    };
+     while (mo) {
+         const QString cn = QLatin1String(mo->className());
+ 
+@@ -696,14 +716,15 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
+         // Find a QAccessiblePlugin (factory) for the class name. If there's
+         // no entry in the cache try to create it using the plugin loader.
+         if (!qAccessiblePlugins()->contains(cn)) {
++            QAccessiblePlugin *factory = nullptr; // 0 means "no plugin found". This is cached as well.
+             const int index = loader()->indexOf(cn);
+-            if (index != -1) {
+-                QAccessiblePlugin *factory = qobject_cast<QAccessiblePlugin *>(loader()->instance(index));
+-                qAccessiblePlugins()->insert(cn, factory);
+-            }
++            if (index != -1)
++                factory = qobject_cast<QAccessiblePlugin *>(loader()->instance(index));
++            qAccessiblePlugins()->insert(cn, factory);
+         }
+ 
+         // At this point the cache should contain a valid factory pointer or 0:
++        Q_ASSERT(qAccessiblePlugins()->contains(cn));
+         QAccessiblePlugin *factory = qAccessiblePlugins()->value(cn);
+         if (factory) {
+             QAccessibleInterface *result = factory->create(cn, object);
+diff --git a/qtbase/src/gui/configure.json b/qtbase/src/gui/configure.json
+index 1f08795c57..12c95742d2 100644
+--- a/qtbase/src/gui/configure.json
++++ b/qtbase/src/gui/configure.json
+@@ -834,7 +834,8 @@
+                     "// embedded devices, are not intended to be used together with X. EGL support",
+                     "// has to be disabled in plugins like xcb in this case since the native display,",
+                     "// window and pixmap types will be different than what an X-based platform",
+-                    "// plugin would expect."
++                    "// plugin would expect.",
++                    "#define USE_X11"
+                 ],
+                 "include": [ "EGL/egl.h", "X11/Xlib.h" ],
+                 "main": [
+diff --git a/qtbase/src/gui/image/qbmphandler.cpp b/qtbase/src/gui/image/qbmphandler.cpp
+index 96f1e8cb1d..0e73bbbdb0 100644
+--- a/qtbase/src/gui/image/qbmphandler.cpp
++++ b/qtbase/src/gui/image/qbmphandler.cpp
+@@ -150,16 +150,42 @@ static QDataStream &operator<<(QDataStream &s, const BMP_INFOHDR &bi)
+     return s;
+ }
+ 
+-static int calc_shift(uint mask)
++static uint calc_shift(uint mask)
+ {
+-    int result = 0;
+-    while (mask && !(mask & 1)) {
++    uint result = 0;
++    while ((mask >= 0x100) || (!(mask & 1) && mask)) {
+         result++;
+         mask >>= 1;
+     }
+     return result;
+ }
+ 
++static uint calc_scale(uint low_mask)
++{
++    uint result = 8;
++    while (low_mask && result) {
++        result--;
++        low_mask >>= 1;
++    }
++    return result;
++}
++
++static inline uint apply_scale(uint value, uint scale)
++{
++    if (!(scale & 0x07)) // return immediately if scale == 8 or 0
++        return value;
++
++    uint filled = 8 - scale;
++    uint result = value << scale;
++
++    do {
++        result |= result >> filled;
++        filled <<= 1;
++    } while (filled < 8);
++
++    return result;
++}
++
+ static bool read_dib_fileheader(QDataStream &s, BMP_FILEHDR &bf)
+ {
+     // read BMP file header
+@@ -222,14 +248,14 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+     uint green_mask = 0;
+     uint blue_mask = 0;
+     uint alpha_mask = 0;
+-    int red_shift = 0;
+-    int green_shift = 0;
+-    int blue_shift = 0;
+-    int alpha_shift = 0;
+-    int red_scale = 0;
+-    int green_scale = 0;
+-    int blue_scale = 0;
+-    int alpha_scale = 0;
++    uint red_shift = 0;
++    uint green_shift = 0;
++    uint blue_shift = 0;
++    uint alpha_shift = 0;
++    uint red_scale = 0;
++    uint green_scale = 0;
++    uint blue_scale = 0;
++    uint alpha_scale = 0;
+ 
+     if (!d->isSequential())
+         d->seek(startpos + BMP_FILEHDR_SIZE + bi.biSize); // goto start of colormap or masks
+@@ -308,19 +334,19 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+         red_shift = calc_shift(red_mask);
+         if (((red_mask >> red_shift) + 1) == 0)
+             return false;
+-        red_scale = 256 / ((red_mask >> red_shift) + 1);
++        red_scale = calc_scale(red_mask >> red_shift);
+         green_shift = calc_shift(green_mask);
+         if (((green_mask >> green_shift) + 1) == 0)
+             return false;
+-        green_scale = 256 / ((green_mask >> green_shift) + 1);
++        green_scale = calc_scale(green_mask >> green_shift);
+         blue_shift = calc_shift(blue_mask);
+         if (((blue_mask >> blue_shift) + 1) == 0)
+             return false;
+-        blue_scale = 256 / ((blue_mask >> blue_shift) + 1);
++        blue_scale = calc_scale(blue_mask >> blue_shift);
+         alpha_shift = calc_shift(alpha_mask);
+         if (((alpha_mask >> alpha_shift) + 1) == 0)
+             return false;
+-        alpha_scale = 256 / ((alpha_mask >> alpha_shift) + 1);
++        alpha_scale = calc_scale(alpha_mask >> alpha_shift);
+     } else if (comp == BMP_RGB && (nbits == 24 || nbits == 32)) {
+         blue_mask = 0x000000ff;
+         green_mask = 0x0000ff00;
+@@ -328,17 +354,15 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+         blue_shift = 0;
+         green_shift = 8;
+         red_shift = 16;
+-        blue_scale = green_scale = red_scale = 1;
++        blue_scale = green_scale = red_scale = 0;
+     } else if (comp == BMP_RGB && nbits == 16) {
+         blue_mask = 0x001f;
+         green_mask = 0x03e0;
+         red_mask = 0x7c00;
+         blue_shift = 0;
+-        green_shift = 2;
+-        red_shift = 7;
+-        red_scale = 1;
+-        green_scale = 1;
+-        blue_scale = 8;
++        green_shift = 5;
++        red_shift = 10;
++        blue_scale = green_scale = red_scale = 3;
+     }
+ 
+ #if 0
+@@ -544,10 +568,10 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+                     c |= *(uchar*)(b+2)<<16;
+                 if (nbits > 24)
+                     c |= *(uchar*)(b+3)<<24;
+-                *p++ = qRgba(((c & red_mask) >> red_shift) * red_scale,
+-                                        ((c & green_mask) >> green_shift) * green_scale,
+-                                        ((c & blue_mask) >> blue_shift) * blue_scale,
+-                                        transp ? ((c & alpha_mask) >> alpha_shift) * alpha_scale : 0xff);
++                *p++ = qRgba(apply_scale((c & red_mask) >> red_shift, red_scale),
++                             apply_scale((c & green_mask) >> green_shift, green_scale),
++                             apply_scale((c & blue_mask) >> blue_shift, blue_scale),
++                             transp ? apply_scale((c & alpha_mask) >> alpha_shift, alpha_scale) : 0xff);
+                 b += nbits/8;
+             }
+         }
+diff --git a/qtbase/src/gui/image/qimage.cpp b/qtbase/src/gui/image/qimage.cpp
+index 7152ac1607..0df772564c 100644
+--- a/qtbase/src/gui/image/qimage.cpp
++++ b/qtbase/src/gui/image/qimage.cpp
+@@ -4694,6 +4694,8 @@ QImage QImage::smoothScaled(int w, int h) const {
+ static QImage rotated90(const QImage &image)
+ {
+     QImage out(image.height(), image.width(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+@@ -4722,6 +4724,8 @@ static QImage rotated180(const QImage &image)
+         return image.mirrored(true, true);
+ 
+     QImage out(image.width(), image.height(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+@@ -4734,6 +4738,8 @@ static QImage rotated180(const QImage &image)
+ static QImage rotated270(const QImage &image)
+ {
+     QImage out(image.height(), image.width(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+diff --git a/qtbase/src/gui/kernel/qcursor.cpp b/qtbase/src/gui/kernel/qcursor.cpp
+index d6ccaff8ed..455088241c 100644
+--- a/qtbase/src/gui/kernel/qcursor.cpp
++++ b/qtbase/src/gui/kernel/qcursor.cpp
+@@ -251,7 +251,8 @@ void QCursor::setPos(QScreen *screen, int x, int y)
+ {
+     if (screen) {
+         if (QPlatformCursor *cursor = screen->handle()->cursor()) {
+-            const QPoint devicePos = QHighDpi::toNativePixels(QPoint(x, y), screen);
++            const QPoint pos(x, y);
++            const QPoint devicePos = QHighDpi::toNativePixels(pos, screen->virtualSiblingAt(pos));
+             // Need to check, since some X servers generate null mouse move
+             // events, causing looping in applications which call setPos() on
+             // every mouse move event.
+diff --git a/qtbase/src/gui/kernel/qhighdpiscaling.cpp b/qtbase/src/gui/kernel/qhighdpiscaling.cpp
+index 9bbf2773a9..3ac4a4d8b6 100644
+--- a/qtbase/src/gui/kernel/qhighdpiscaling.cpp
++++ b/qtbase/src/gui/kernel/qhighdpiscaling.cpp
+@@ -580,9 +580,8 @@ void QHighDpiScaling::setScreenFactor(QScreen *screen, qreal factor)
+     else
+         qNamedScreenScaleFactors()->insert(name, factor);
+ 
+-    // hack to force re-evaluation of screen geometry
+     if (screen->handle())
+-        screen->d_func()->setPlatformScreen(screen->handle()); // updates geometries based on scale factor
++        screen->d_func()->updateLogicalDpi();
+ }
+ 
+ QPoint QHighDpiScaling::mapPositionToNative(const QPoint &pos, const QPlatformScreen *platformScreen)
+diff --git a/qtbase/src/gui/kernel/qkeysequence.cpp b/qtbase/src/gui/kernel/qkeysequence.cpp
+index a75b8ef920..4f2d294739 100644
+--- a/qtbase/src/gui/kernel/qkeysequence.cpp
++++ b/qtbase/src/gui/kernel/qkeysequence.cpp
+@@ -701,6 +701,10 @@ static const struct {
+     { Qt::Key_TouchpadToggle,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad Toggle") },
+     { Qt::Key_TouchpadOn,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad On") },
+     { Qt::Key_TouchpadOff,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad Off") },
++    { Qt::Key_Shift,  QT_TRANSLATE_NOOP("QShortcut", "Shift") },
++    { Qt::Key_Control,  QT_TRANSLATE_NOOP("QShortcut", "Control") },
++    { Qt::Key_Alt,  QT_TRANSLATE_NOOP("QShortcut", "Alt") },
++    { Qt::Key_Meta,  QT_TRANSLATE_NOOP("QShortcut", "Meta") },
+ 
+ };
+ static Q_CONSTEXPR int numKeyNames = sizeof keyname / sizeof *keyname;
+diff --git a/qtbase/src/gui/kernel/qplatformservices.cpp b/qtbase/src/gui/kernel/qplatformservices.cpp
+index fdc6a6c4aa..ac47f98c5d 100644
+--- a/qtbase/src/gui/kernel/qplatformservices.cpp
++++ b/qtbase/src/gui/kernel/qplatformservices.cpp
+@@ -55,6 +55,19 @@ QT_BEGIN_NAMESPACE
+     \brief The QPlatformServices provides the backend for desktop-related functionality.
+ */
+ 
++/*!
++    \enum QPlatformServices::Capability
++
++    Capabilities are used to determine a specific platform service's availability.
++
++    \value ColorPickingFromScreen The platform natively supports color picking from screen.
++    This capability indicates that the platform supports "opaque" color picking, where the
++    platform implements a complete user experience for color picking and outputs a color.
++    This is in contrast to the application implementing the color picking user experience
++    (taking care of showing a cross hair, instructing the platform integration to obtain
++    the color at a given pixel, etc.). The related service function is pickColor().
++ */
++
+ QPlatformServices::QPlatformServices()
+ { }
+ 
+@@ -85,5 +98,16 @@ QByteArray QPlatformServices::desktopEnvironment() const
+     return QByteArray("UNKNOWN");
+ }
+ 
++QPlatformServiceColorPicker *QPlatformServices::colorPicker(QWindow *parent)
++{
++    Q_UNUSED(parent);
++    return nullptr;
++}
++
++bool QPlatformServices::hasCapability(Capability capability) const
++{
++    Q_UNUSED(capability)
++    return false;
++}
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/gui/kernel/qplatformservices.h b/qtbase/src/gui/kernel/qplatformservices.h
+index 5de96cfa7d..a8b2a4ce71 100644
+--- a/qtbase/src/gui/kernel/qplatformservices.h
++++ b/qtbase/src/gui/kernel/qplatformservices.h
+@@ -50,16 +50,32 @@
+ //
+ 
+ #include <QtGui/qtguiglobal.h>
++#include <QtCore/qobject.h>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+ class QUrl;
++class QWindow;
++
++class Q_GUI_EXPORT QPlatformServiceColorPicker : public QObject
++{
++    Q_OBJECT
++public:
++    using QObject::QObject;
++    virtual void pickColor() = 0;
++Q_SIGNALS:
++    void colorPicked(const QColor &color);
++};
+ 
+ class Q_GUI_EXPORT QPlatformServices
+ {
+ public:
+     Q_DISABLE_COPY_MOVE(QPlatformServices)
+ 
++    enum Capability {
++        ColorPicking,
++    };
++
+     QPlatformServices();
+     virtual ~QPlatformServices() { }
+ 
+@@ -67,6 +83,10 @@ public:
+     virtual bool openDocument(const QUrl &url);
+ 
+     virtual QByteArray desktopEnvironment() const;
++
++    virtual bool hasCapability(Capability capability) const;
++
++    virtual QPlatformServiceColorPicker *colorPicker(QWindow *parent = nullptr);
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/gui/kernel/qplatformtheme.cpp b/qtbase/src/gui/kernel/qplatformtheme.cpp
+index 71521c0339..2325873245 100644
+--- a/qtbase/src/gui/kernel/qplatformtheme.cpp
++++ b/qtbase/src/gui/kernel/qplatformtheme.cpp
+@@ -163,6 +163,8 @@ QT_BEGIN_NAMESPACE
+ 
+     \value ShowShortcutsInContextMenus (bool) Whether to display shortcut key sequences in context menus.
+ 
++    \value ButtonPressKeys (QList<Qt::Key>) A list of keys that can be used to press buttons via keyboard input.
++
+     \sa themeHint(), QStyle::pixelMetric()
+ */
+ 
+@@ -563,6 +565,8 @@ QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint)
+         }
+     case MouseQuickSelectionThreshold:
+         return QVariant(10);
++    case ButtonPressKeys:
++        return QVariant::fromValue(QList<Qt::Key>({ Qt::Key_Space, Qt::Key_Select }));
+     }
+     return QVariant();
+ }
+diff --git a/qtbase/src/gui/kernel/qplatformtheme.h b/qtbase/src/gui/kernel/qplatformtheme.h
+index 3185fc4541..7e6c9d5740 100644
+--- a/qtbase/src/gui/kernel/qplatformtheme.h
++++ b/qtbase/src/gui/kernel/qplatformtheme.h
+@@ -120,7 +120,8 @@ public:
+         TouchDoubleTapDistance,
+         ShowShortcutsInContextMenus,
+         IconFallbackSearchPaths,
+-        MouseQuickSelectionThreshold
++        MouseQuickSelectionThreshold,
++        ButtonPressKeys
+     };
+ 
+     enum DialogType {
+diff --git a/qtbase/src/gui/kernel/qscreen.cpp b/qtbase/src/gui/kernel/qscreen.cpp
+index 8e0eb35116..5d172a58dd 100644
+--- a/qtbase/src/gui/kernel/qscreen.cpp
++++ b/qtbase/src/gui/kernel/qscreen.cpp
+@@ -77,6 +77,12 @@ QScreen::QScreen(QPlatformScreen *screen)
+     d->setPlatformScreen(screen);
+ }
+ 
++void QScreenPrivate::updateLogicalDpi()
++{
++    logicalDpi = QPlatformScreen::overrideDpi(platformScreen->logicalDpi());
++    updateGeometriesWithSignals(); // updates geometries based on scale factor
++}
++
+ void QScreenPrivate::updateGeometriesWithSignals()
+ {
+     const QRect oldGeometry = geometry;
+diff --git a/qtbase/src/gui/kernel/qscreen_p.h b/qtbase/src/gui/kernel/qscreen_p.h
+index 7da542c25e..e50fc3190b 100644
+--- a/qtbase/src/gui/kernel/qscreen_p.h
++++ b/qtbase/src/gui/kernel/qscreen_p.h
+@@ -70,6 +70,7 @@ public:
+         geometry = platformScreen->deviceIndependentGeometry();
+         availableGeometry = QHighDpi::fromNative(platformScreen->availableGeometry(), QHighDpiScaling::factor(platformScreen), geometry.topLeft());
+     }
++    void updateLogicalDpi();
+ 
+     void updatePrimaryOrientation();
+     void updateGeometriesWithSignals();
+diff --git a/qtbase/src/gui/painting/qblendfunctions_p.h b/qtbase/src/gui/painting/qblendfunctions_p.h
+index 080da98ec4..6997d62b3c 100644
+--- a/qtbase/src/gui/painting/qblendfunctions_p.h
++++ b/qtbase/src/gui/painting/qblendfunctions_p.h
+@@ -246,25 +246,32 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+                                   int dudx, int dvdx, int dudy, int dvdy, int u0, int v0,
+                                   Blender blender)
+ {
+-    int fromY = qMax(qRound(topY), clip.top());
+-    int toY = qMin(qRound(bottomY), clip.top() + clip.height());
++    qint64 fromY = qMax(qRound(topY), clip.top());
++    qint64 toY = qMin(qRound(bottomY), clip.top() + clip.height());
+     if (fromY >= toY)
+         return;
+ 
+     qreal leftSlope = (bottomLeft.x - topLeft.x) / (bottomLeft.y - topLeft.y);
+     qreal rightSlope = (bottomRight.x - topRight.x) / (bottomRight.y - topRight.y);
+-    int dx_l = int(leftSlope * 0x10000);
+-    int dx_r = int(rightSlope * 0x10000);
+-    int x_l = int((topLeft.x + (qreal(0.5) + fromY - topLeft.y) * leftSlope + qreal(0.5)) * 0x10000);
+-    int x_r = int((topRight.x + (qreal(0.5) + fromY - topRight.y) * rightSlope + qreal(0.5)) * 0x10000);
+-
+-    int fromX, toX, x1, x2, u, v, i, ii;
++    qint64 dx_l = qint64(leftSlope * 0x10000);
++    qint64 dx_r = qint64(rightSlope * 0x10000);
++    qint64 x_l = qint64((topLeft.x + (qreal(0.5) + fromY - topLeft.y) * leftSlope + qreal(0.5)) * 0x10000);
++    qint64 x_r = qint64((topRight.x + (qreal(0.5) + fromY - topRight.y) * rightSlope + qreal(0.5)) * 0x10000);
++
++    qint64 sourceRectTop = qint64(sourceRect.top());
++    qint64 sourceRectLeft = qint64(sourceRect.left());
++    qint64 sourceRectWidth = qint64(sourceRect.width());
++    qint64 sourceRectHeight = qint64(sourceRect.height());
++    qint64 clipLeft = qint64(clip.left());
++    qint64 clipWidth = qint64(clip.width());
++
++    qint64 fromX, toX, x1, x2, u, v, i, ii;
+     DestT *line;
+-    for (int y = fromY; y < toY; ++y) {
++    for (qint64 y = fromY; y < toY; ++y) {
+         line = reinterpret_cast<DestT *>(reinterpret_cast<uchar *>(destPixels) + y * dbpl);
+ 
+-        fromX = qMax(x_l >> 16, clip.left());
+-        toX = qMin(x_r >> 16, clip.left() + clip.width());
++        fromX = qMax(x_l >> 16, clipLeft);
++        toX = qMin(x_r >> 16, clipLeft + clipWidth);
+         if (fromX < toX) {
+             // Because of rounding, we can get source coordinates outside the source image.
+             // Clamp these coordinates to the source rect to avoid segmentation fault and
+@@ -275,10 +282,10 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             u = x1 * dudx + y * dudy + u0;
+             v = x1 * dvdx + y * dvdy + v0;
+             for (; x1 < toX; ++x1) {
+-                int uu = u >> 16;
+-                int vv = v >> 16;
+-                if (uu >= sourceRect.left() && uu < sourceRect.left() + sourceRect.width()
+-                    && vv >= sourceRect.top() && vv < sourceRect.top() + sourceRect.height()) {
++                qint64 uu = u >> 16;
++                qint64 vv = v >> 16;
++                if (uu >= sourceRectLeft && uu < sourceRectLeft + sourceRectWidth
++                    && vv >= sourceRectTop && vv < sourceRectTop + sourceRectHeight) {
+                     break;
+                 }
+                 u += dudx;
+@@ -290,10 +297,10 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             u = (x2 - 1) * dudx + y * dudy + u0;
+             v = (x2 - 1) * dvdx + y * dvdy + v0;
+             for (; x2 > x1; --x2) {
+-                int uu = u >> 16;
+-                int vv = v >> 16;
+-                if (uu >= sourceRect.left() && uu < sourceRect.left() + sourceRect.width()
+-                    && vv >= sourceRect.top() && vv < sourceRect.top() + sourceRect.height()) {
++                qint64 uu = u >> 16;
++                qint64 vv = v >> 16;
++                if (uu >= sourceRectLeft && uu < sourceRectLeft + sourceRectWidth
++                    && vv >= sourceRectTop && vv < sourceRectTop + sourceRectHeight) {
+                     break;
+                 }
+                 u -= dudx;
+@@ -308,8 +315,8 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             // Beginning of the scan line, with per-pixel checks.
+             i = x1 - fromX;
+             while (i) {
+-                int uu = qBound(sourceRect.left(), u >> 16, sourceRect.left() + sourceRect.width() - 1);
+-                int vv = qBound(sourceRect.top(), v >> 16, sourceRect.top() + sourceRect.height() - 1);
++                qint64 uu = qBound(sourceRectLeft, u >> 16, sourceRectLeft + sourceRectWidth - 1);
++                qint64 vv = qBound(sourceRectTop, v >> 16, sourceRectTop + sourceRectHeight - 1);
+                 blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + vv * sbpl)[uu]);
+                 u += dudx;
+                 v += dvdx;
+@@ -348,8 +355,8 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             // End of the scan line, with per-pixel checks.
+             i = toX - x2;
+             while (i) {
+-                int uu = qBound(sourceRect.left(), u >> 16, sourceRect.left() + sourceRect.width() - 1);
+-                int vv = qBound(sourceRect.top(), v >> 16, sourceRect.top() + sourceRect.height() - 1);
++                qint64 uu = qBound(sourceRectLeft, u >> 16, sourceRectLeft + sourceRectWidth - 1);
++                qint64 vv = qBound(sourceRectTop, v >> 16, sourceRectTop + sourceRectHeight - 1);
+                 blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + vv * sbpl)[uu]);
+                 u += dudx;
+                 v += dvdx;
+diff --git a/qtbase/src/gui/painting/qcolortrclut_p.h b/qtbase/src/gui/painting/qcolortrclut_p.h
+index 76a6a60803..24fd522e6c 100644
+--- a/qtbase/src/gui/painting/qcolortrclut_p.h
++++ b/qtbase/src/gui/painting/qcolortrclut_p.h
+@@ -118,6 +118,7 @@ public:
+         return QRgba64::fromRgba64(r, g, b, qAlpha(rgb32) * 257);
+ #endif
+     }
++    QRgba64 toLinear64(QRgba64) const = delete;
+ 
+     QRgb toLinear(QRgb rgb32) const
+     {
+diff --git a/qtbase/src/gui/painting/qdrawhelper.cpp b/qtbase/src/gui/painting/qdrawhelper.cpp
+index a61793508a..5ba2d277b7 100644
+--- a/qtbase/src/gui/painting/qdrawhelper.cpp
++++ b/qtbase/src/gui/painting/qdrawhelper.cpp
+@@ -6091,7 +6091,7 @@ static inline void alphargbblend_argb32(quint32 *dst, uint coverage, const QRgba
+ static inline void rgbBlendPixel(QRgba64 &dst, int coverage, QRgba64 slinear, const QColorTrcLut *colorProfile)
+ {
+     // Do a gammacorrected RGB alphablend...
+-    const QRgba64 dlinear = colorProfile ? colorProfile->toLinear64(dst) : dst;
++    const QRgba64 dlinear = colorProfile ? colorProfile->toLinear(dst) : dst;
+ 
+     QRgba64 blend = rgbBlend(dlinear, slinear, coverage);
+ 
+diff --git a/qtbase/src/gui/painting/qpaintengine_raster.cpp b/qtbase/src/gui/painting/qpaintengine_raster.cpp
+index 283923de52..f08eb9cbee 100644
+--- a/qtbase/src/gui/painting/qpaintengine_raster.cpp
++++ b/qtbase/src/gui/painting/qpaintengine_raster.cpp
+@@ -560,31 +560,6 @@ void QRasterPaintEngine::updateMatrix(const QTransform &matrix)
+     QRasterPaintEngineState *s = state();
+     // FALCON: get rid of this line, see drawImage call below.
+     s->matrix = matrix;
+-    QTransform::TransformationType txop = s->matrix.type();
+-
+-    switch (txop) {
+-
+-    case QTransform::TxNone:
+-        s->flags.int_xform = true;
+-        break;
+-
+-    case QTransform::TxTranslate:
+-        s->flags.int_xform = qreal(int(s->matrix.dx())) == s->matrix.dx()
+-                            && qreal(int(s->matrix.dy())) == s->matrix.dy();
+-        break;
+-
+-    case QTransform::TxScale:
+-        s->flags.int_xform = qreal(int(s->matrix.dx())) == s->matrix.dx()
+-                            && qreal(int(s->matrix.dy())) == s->matrix.dy()
+-                            && qreal(int(s->matrix.m11())) == s->matrix.m11()
+-                            && qreal(int(s->matrix.m22())) == s->matrix.m22();
+-        break;
+-
+-    default: // shear / perspective...
+-        s->flags.int_xform = false;
+-        break;
+-    }
+-
+     s->flags.tx_noshear = qt_scaleForTransform(s->matrix, &s->txscale);
+ 
+     ensureOutlineMapper();
+@@ -617,7 +592,6 @@ QRasterPaintEngineState::QRasterPaintEngineState()
+     flags.bilinear = false;
+     flags.legacy_rounding = false;
+     flags.fast_text = true;
+-    flags.int_xform = true;
+     flags.tx_noshear = true;
+     flags.fast_images = true;
+ 
+@@ -1793,7 +1767,7 @@ void QRasterPaintEngine::fill(const QVectorPath &path, const QBrush &brush)
+     QRectF cpRect = path.controlPointRect();
+     const QRectF pathDeviceRect = s->matrix.mapRect(cpRect);
+     // Skip paths that by conservative estimates are completely outside the paint device.
+-    if (!pathDeviceRect.intersects(QRectF(d->deviceRect)))
++    if (!pathDeviceRect.intersects(QRectF(d->deviceRect)) || !pathDeviceRect.isValid())
+         return;
+ 
+     ProcessSpans blend = d->getBrushFunc(pathDeviceRect, &s->brushData);
+diff --git a/qtbase/src/gui/painting/qpaintengine_raster_p.h b/qtbase/src/gui/painting/qpaintengine_raster_p.h
+index 089aadc3f7..bf7363d5aa 100644
+--- a/qtbase/src/gui/painting/qpaintengine_raster_p.h
++++ b/qtbase/src/gui/painting/qpaintengine_raster_p.h
+@@ -111,7 +111,6 @@ public:
+         uint bilinear : 1;
+         uint legacy_rounding : 1;
+         uint fast_text : 1;
+-        uint int_xform : 1;
+         uint tx_noshear : 1;
+         uint fast_images : 1;
+     };
+diff --git a/qtbase/src/gui/painting/qpainterpath.cpp b/qtbase/src/gui/painting/qpainterpath.cpp
+index f9544a3241..d80fafeaf1 100644
+--- a/qtbase/src/gui/painting/qpainterpath.cpp
++++ b/qtbase/src/gui/painting/qpainterpath.cpp
+@@ -1253,7 +1253,7 @@ void QPainterPath::addText(const QPointF &point, const QFont &f, const QString &
+ 
+         if (si.analysis.flags < QScriptAnalysis::TabOrObject) {
+             QGlyphLayout glyphs = eng->shapedGlyphs(&si);
+-            QFontEngine *fe = f.d->engineForScript(si.analysis.script);
++            QFontEngine *fe = eng->fontEngine(si);
+             Q_ASSERT(fe);
+             fe->addOutlineToPath(x, y, glyphs, this,
+                                  si.analysis.bidiLevel % 2
+diff --git a/qtbase/src/gui/painting/qpathclipper_p.h b/qtbase/src/gui/painting/qpathclipper_p.h
+index 9444a87b71..18f64c5e8c 100644
+--- a/qtbase/src/gui/painting/qpathclipper_p.h
++++ b/qtbase/src/gui/painting/qpathclipper_p.h
+@@ -156,7 +156,7 @@ public:
+     int vertex(Direction direction) const;
+ 
+ private:
+-    int m_next[2][2];
++    int m_next[2][2] = { { -1, -1 }, { -1, -1 } };
+ };
+ 
+ class QPathSegments
+@@ -296,10 +296,6 @@ inline QPathEdge::QPathEdge(int a, int b)
+     , angle(0)
+     , invAngle(0)
+ {
+-    m_next[0][0] = -1;
+-    m_next[1][0] = -1;
+-    m_next[0][0] = -1;
+-    m_next[1][0] = -1;
+ }
+ 
+ inline int QPathEdge::next(Traversal traversal, Direction direction) const
+diff --git a/qtbase/src/gui/painting/qpdf.cpp b/qtbase/src/gui/painting/qpdf.cpp
+index 3066744f1b..2c8d3c3b53 100644
+--- a/qtbase/src/gui/painting/qpdf.cpp
++++ b/qtbase/src/gui/painting/qpdf.cpp
+@@ -2760,6 +2760,8 @@ int QPdfEnginePrivate::addBrushPattern(const QTransform &m, bool *specifyColor,
+         return gradientBrush(brush, matrix, gStateObject);
+     }
+ 
++    matrix = brush.transform() * matrix;
++
+     if ((!brush.isOpaque() && brush.style() < Qt::LinearGradientPattern) || opacity != 1.0)
+         *gStateObject = addConstantAlphaObject(qRound(brush.color().alpha() * opacity),
+                                                qRound(pen.color().alpha() * opacity));
+diff --git a/qtbase/src/gui/painting/qstroker.cpp b/qtbase/src/gui/painting/qstroker.cpp
+index cb5d395e80..3b6357a893 100644
+--- a/qtbase/src/gui/painting/qstroker.cpp
++++ b/qtbase/src/gui/painting/qstroker.cpp
+@@ -1182,6 +1182,7 @@ void QDashStroker::processCurrentSubpath()
+         // Check if the entire line should be clipped away or simplified
+         bool clipIt = clipping && !lineIntersectsRect(prev, e, clip_tl, clip_br);
+         bool skipDashing = elen * invSumLength > repetitionLimit();
++        int maxDashes = dashCount;
+         if (skipDashing || clipIt) {
+             // Cut away full dash sequences.
+             elen -= std::floor(elen * invSumLength) * sumLength;
+@@ -1196,7 +1197,7 @@ void QDashStroker::processCurrentSubpath()
+                     pos = estop; // move pos to next path element
+                     done = true;
+                 } else { // Dash is on this line
+-                    pos = dpos + estart;
++                    pos = --maxDashes > 0 ? dpos + estart : estop;
+                     done = pos >= estop;
+                     if (++idash >= dashCount)
+                         idash = 0;
+diff --git a/qtbase/src/gui/painting/qt_attribution.json b/qtbase/src/gui/painting/qt_attribution.json
+index 7b16e8c211..0e87d30aa2 100644
+--- a/qtbase/src/gui/painting/qt_attribution.json
++++ b/qtbase/src/gui/painting/qt_attribution.json
+@@ -10,7 +10,7 @@
+         "Homepage": "http://www.freetype.org",
+         "License": "Freetype Project License or GNU General Public License v2.0 only",
+         "LicenseId": "FTL or GPL-2.0",
+-        "LicenseFile": "../../3rdparty/freetype/docs/LICENSE.TXT",
++        "LicenseFile": "../../3rdparty/freetype/LICENSE.TXT",
+         "Copyright": "Copyright 2000-2016 by David Turner, Robert Wilhelm, and Werner Lemberg."
+     },
+     {
+diff --git a/qtbase/src/gui/rhi/qshader_p_p.h b/qtbase/src/gui/rhi/qshader_p_p.h
+index ec9d25971f..4a5a7a6d51 100644
+--- a/qtbase/src/gui/rhi/qshader_p_p.h
++++ b/qtbase/src/gui/rhi/qshader_p_p.h
+@@ -68,13 +68,13 @@ struct Q_GUI_EXPORT QShaderPrivate
+     {
+     }
+ 
+-    QShaderPrivate(const QShaderPrivate *other)
++    QShaderPrivate(const QShaderPrivate &other)
+         : ref(1),
+-          qsbVersion(other->qsbVersion),
+-          stage(other->stage),
+-          desc(other->desc),
+-          shaders(other->shaders),
+-          bindings(other->bindings)
++          qsbVersion(other.qsbVersion),
++          stage(other.stage),
++          desc(other.desc),
++          shaders(other.shaders),
++          bindings(other.bindings)
+     {
+     }
+ 
+diff --git a/qtbase/src/gui/rhi/qshaderdescription_p_p.h b/qtbase/src/gui/rhi/qshaderdescription_p_p.h
+index ec2b0b6b4c..3da33a8a2b 100644
+--- a/qtbase/src/gui/rhi/qshaderdescription_p_p.h
++++ b/qtbase/src/gui/rhi/qshaderdescription_p_p.h
+@@ -63,16 +63,16 @@ struct Q_GUI_EXPORT QShaderDescriptionPrivate
+         localSize[0] = localSize[1] = localSize[2] = 0;
+     }
+ 
+-    QShaderDescriptionPrivate(const QShaderDescriptionPrivate *other)
++    QShaderDescriptionPrivate(const QShaderDescriptionPrivate &other)
+         : ref(1),
+-          inVars(other->inVars),
+-          outVars(other->outVars),
+-          uniformBlocks(other->uniformBlocks),
+-          pushConstantBlocks(other->pushConstantBlocks),
+-          storageBlocks(other->storageBlocks),
+-          combinedImageSamplers(other->combinedImageSamplers),
+-          storageImages(other->storageImages),
+-          localSize(other->localSize)
++          inVars(other.inVars),
++          outVars(other.outVars),
++          uniformBlocks(other.uniformBlocks),
++          pushConstantBlocks(other.pushConstantBlocks),
++          storageBlocks(other.storageBlocks),
++          combinedImageSamplers(other.combinedImageSamplers),
++          storageImages(other.storageImages),
++          localSize(other.localSize)
+     {
+     }
+ 
+diff --git a/qtbase/src/gui/text/qfontdatabase.cpp b/qtbase/src/gui/text/qfontdatabase.cpp
+index a657a8c516..4fc0100958 100644
+--- a/qtbase/src/gui/text/qfontdatabase.cpp
++++ b/qtbase/src/gui/text/qfontdatabase.cpp
+@@ -983,7 +983,7 @@ QFontEngine *loadSingleEngine(int script,
+         if (style->key.stretch != 0 && request.stretch != 0
+             && (request.styleName.isEmpty() || request.styleName != style->styleName)) {
+             def.stretch = (request.stretch * 100 + style->key.stretch / 2) / style->key.stretch;
+-        } else {
++        } else if (request.stretch == QFont::AnyStretch) {
+             def.stretch = 100;
+         }
+ 
+diff --git a/qtbase/src/gui/text/qtextdocumentlayout.cpp b/qtbase/src/gui/text/qtextdocumentlayout.cpp
+index f3e6ea2100..72267e9380 100644
+--- a/qtbase/src/gui/text/qtextdocumentlayout.cpp
++++ b/qtbase/src/gui/text/qtextdocumentlayout.cpp
+@@ -2123,7 +2123,7 @@ void QTextDocumentLayoutPrivate::drawListItem(const QPointF &offset, QPainter *p
+ {
+     Q_Q(const QTextDocumentLayout);
+     const QTextBlockFormat blockFormat = bl.blockFormat();
+-    const QTextCharFormat charFormat = QTextCursor(bl).charFormat();
++    const QTextCharFormat charFormat = bl.charFormat();
+     QFont font(charFormat.font());
+     if (q->paintDevice())
+         font = QFont(font, q->paintDevice());
+diff --git a/qtbase/src/gui/text/qtextengine.cpp b/qtbase/src/gui/text/qtextengine.cpp
+index ce4abac472..a6c66e5d2d 100644
+--- a/qtbase/src/gui/text/qtextengine.cpp
++++ b/qtbase/src/gui/text/qtextengine.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2021 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtGui module of the Qt Toolkit.
+@@ -1565,6 +1565,12 @@ void QTextEngine::shapeText(int item) const
+         // Overwrite with 0 token to indicate failure
+         QGlyphLayout g = availableGlyphs(&si);
+         g.glyphs[0] = 0;
++        g.attributes[0].clusterStart = true;
++
++        ushort *log_clusters = logClusters(&si);
++        for (int i = 0; i < itemLength; ++i)
++            log_clusters[i] = 0;
++
+         return;
+     }
+ 
+diff --git a/qtbase/src/gui/util/qdesktopservices.cpp b/qtbase/src/gui/util/qdesktopservices.cpp
+index fbb63a9408..4d5fafaaa7 100644
+--- a/qtbase/src/gui/util/qdesktopservices.cpp
++++ b/qtbase/src/gui/util/qdesktopservices.cpp
+@@ -54,6 +54,8 @@
+ #include <qpa/qplatformintegration.h>
+ #include <qdir.h>
+ 
++#include <QtCore/private/qlocking_p.h>
++
+ QT_BEGIN_NAMESPACE
+ 
+ class QOpenUrlHandlerRegistry : public QObject
+@@ -81,6 +83,7 @@ Q_GLOBAL_STATIC(QOpenUrlHandlerRegistry, handlerRegistry)
+ 
+ void QOpenUrlHandlerRegistry::handlerDestroyed(QObject *handler)
+ {
++    const auto lock = qt_scoped_lock(mutex);
+     HandlerHash::Iterator it = handlers.begin();
+     while (it != handlers.end()) {
+         if (it->receiver == handler) {
+@@ -294,7 +297,8 @@ void QDesktopServices::setUrlHandler(const QString &scheme, QObject *receiver, c
+     h.name = method;
+     registry->handlers.insert(scheme.toLower(), h);
+     QObject::connect(receiver, SIGNAL(destroyed(QObject*)),
+-                     registry, SLOT(handlerDestroyed(QObject*)));
++                     registry, SLOT(handlerDestroyed(QObject*)),
++                     Qt::DirectConnection);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/gui/util/qpkmhandler.cpp b/qtbase/src/gui/util/qpkmhandler.cpp
+index e0c3b75efe..3414f9d8ba 100644
+--- a/qtbase/src/gui/util/qpkmhandler.cpp
++++ b/qtbase/src/gui/util/qpkmhandler.cpp
+@@ -57,7 +57,7 @@ struct PkmType
+     quint32 bytesPerBlock;
+ };
+ 
+-static PkmType typeMap[5] = {
++static constexpr PkmType typeMap[5] = {
+     { 0x8D64,  8 },   // GL_ETC1_RGB8_OES
+     { 0x9274,  8 },   // GL_COMPRESSED_RGB8_ETC2
+     { 0, 0 },         // unused (obsolete)
+diff --git a/qtbase/src/network/access/qnetworkreplyfileimpl.cpp b/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
+index b6be93147a..6e69b4c4d3 100644
+--- a/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
++++ b/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
+@@ -89,9 +89,10 @@ QNetworkReplyFileImpl::QNetworkReplyFileImpl(QNetworkAccessManager *manager, con
+         // we handle only local files
+         QString msg = QCoreApplication::translate("QNetworkAccessFileBackend", "Request for opening non-local file %1").arg(url.toString());
+         setError(QNetworkReply::ProtocolInvalidOperationError, msg);
++        setFinished(true); // We're finished, will emit finished() after ctor is done.
+         QMetaObject::invokeMethod(this, "errorOccurred", Qt::QueuedConnection,
+             Q_ARG(QNetworkReply::NetworkError, QNetworkReply::ProtocolInvalidOperationError));
+-        fileOpenFinished(false);
++        QMetaObject::invokeMethod(this, [this](){ fileOpenFinished(false); }, Qt::QueuedConnection);
+         return;
+     }
+ #endif
+diff --git a/qtbase/src/network/access/qnetworkreplyimpl.cpp b/qtbase/src/network/access/qnetworkreplyimpl.cpp
+index bcdf6ee2f1..3b6deb82bd 100644
+--- a/qtbase/src/network/access/qnetworkreplyimpl.cpp
++++ b/qtbase/src/network/access/qnetworkreplyimpl.cpp
+@@ -680,7 +680,7 @@ void QNetworkReplyImplPrivate::appendDownstreamData(QIODevice *data)
+     // read until EOF from data
+     if (Q_UNLIKELY(copyDevice)) {
+         qCritical("QNetworkReplyImpl: copy from QIODevice already in progress -- "
+-                  "backend probly needs to be fixed");
++                  "backend probably needs to be fixed");
+         return;
+     }
+ 
+diff --git a/qtbase/src/network/kernel/qauthenticator.cpp b/qtbase/src/network/kernel/qauthenticator.cpp
+index d9fe7bc47b..ccd04b294a 100644
+--- a/qtbase/src/network/kernel/qauthenticator.cpp
++++ b/qtbase/src/network/kernel/qauthenticator.cpp
+@@ -50,6 +50,7 @@
+ #include <qstring.h>
+ #include <qdatetime.h>
+ #include <qrandom.h>
++#include "private/qsystemlibrary_p.h"
+ 
+ #ifdef Q_OS_WIN
+ #include <qmutex.h>
+@@ -1563,7 +1564,7 @@ static bool q_SSPI_library_load()
+ 
+     // Initialize security interface
+     if (pSecurityFunctionTable == nullptr) {
+-        securityDLLHandle = LoadLibrary(L"secur32.dll");
++        securityDLLHandle = QSystemLibrary::load(L"secur32");
+         if (securityDLLHandle != nullptr) {
+             INIT_SECURITY_INTERFACE pInitSecurityInterface =
+                 reinterpret_cast<INIT_SECURITY_INTERFACE>(
+diff --git a/qtbase/src/network/kernel/qhostinfo_unix.cpp b/qtbase/src/network/kernel/qhostinfo_unix.cpp
+index 9b0a2ee669..73679c9ef1 100644
+--- a/qtbase/src/network/kernel/qhostinfo_unix.cpp
++++ b/qtbase/src/network/kernel/qhostinfo_unix.cpp
+@@ -122,7 +122,6 @@ static QFunctionPointer resolveSymbol(QLibrary &lib, const char *sym)
+ 
+ LibResolv::LibResolv()
+ {
+-    QLibrary lib;
+ #ifdef LIBRESOLV_SO
+     lib.setFileName(QStringLiteral(LIBRESOLV_SO));
+     if (!lib.load())
+diff --git a/qtbase/src/network/socket/qsocks5socketengine.cpp b/qtbase/src/network/socket/qsocks5socketengine.cpp
+index 3a046fd116..97fadca0b3 100644
+--- a/qtbase/src/network/socket/qsocks5socketengine.cpp
++++ b/qtbase/src/network/socket/qsocks5socketengine.cpp
+@@ -1296,7 +1296,7 @@ void QSocks5SocketEnginePrivate::_q_udpSocketReadNotification()
+         int pos = 0;
+         const char *buf = inBuf.constData();
+         if (inBuf.size() < 4) {
+-            QSOCKS5_D_DEBUG << "bugus udp data, discarding";
++            QSOCKS5_D_DEBUG << "bogus udp data, discarding";
+             return;
+         }
+         QSocks5RevivedDatagram datagram;
+diff --git a/qtbase/src/network/ssl/qsslcontext_openssl.cpp b/qtbase/src/network/ssl/qsslcontext_openssl.cpp
+index c9f202f573..c992da9d8e 100644
+--- a/qtbase/src/network/ssl/qsslcontext_openssl.cpp
++++ b/qtbase/src/network/ssl/qsslcontext_openssl.cpp
+@@ -409,7 +409,7 @@ init_context:
+         break;
+     case QSsl::DtlsV1_0OrLater:
+         minVersion = DTLS1_VERSION;
+-        maxVersion = DTLS_MAX_VERSION;
++        maxVersion = 0;
+         break;
+     case QSsl::DtlsV1_2:
+         minVersion = DTLS1_2_VERSION;
+@@ -417,7 +417,7 @@ init_context:
+         break;
+     case QSsl::DtlsV1_2OrLater:
+         minVersion = DTLS1_2_VERSION;
+-        maxVersion = DTLS_MAX_VERSION;
++        maxVersion = 0;
+         break;
+     case QSsl::TlsV1_3OrLater:
+ #ifdef TLS1_3_VERSION
+@@ -455,7 +455,7 @@ init_context:
+     }
+ 
+     // Enable bug workarounds.
+-    long options = QSslSocketBackendPrivate::setupOpenSslOptions(configuration.protocol(), configuration.d->sslOptions);
++    qssloptions options = QSslSocketBackendPrivate::setupOpenSslOptions(configuration.protocol(), configuration.d->sslOptions);
+     q_SSL_CTX_set_options(sslContext->ctx, options);
+ 
+     // Tell OpenSSL to release memory early
+diff --git a/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp b/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
+index aaf8741130..b58935372c 100644
+--- a/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
++++ b/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
+@@ -59,57 +59,6 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-#ifdef OPENSSL_NO_DEPRECATED_3_0
+-
+-static int q_DH_check(DH *dh, int *status)
+-{
+-    // DH_check was first deprecated in OpenSSL 3.0.0, as low-level
+-    // API; the EVP_PKEY family of functions was advised as an alternative.
+-    // As of now EVP_PKEY_params_check ends up calling ... DH_check,
+-    // which is good enough.
+-
+-    Q_ASSERT(dh);
+-    Q_ASSERT(status);
+-
+-    EVP_PKEY *key = q_EVP_PKEY_new();
+-    if (!key) {
+-        qCWarning(lcSsl, "EVP_PKEY_new failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-    const auto keyDeleter = qScopeGuard([key](){
+-        q_EVP_PKEY_free(key);
+-    });
+-    if (!q_EVP_PKEY_set1_DH(key, dh)) {
+-        qCWarning(lcSsl, "EVP_PKEY_set1_DH failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-
+-    EVP_PKEY_CTX *keyCtx = q_EVP_PKEY_CTX_new(key, nullptr);
+-    if (!keyCtx) {
+-        qCWarning(lcSsl, "EVP_PKEY_CTX_new failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-    const auto ctxDeleter = qScopeGuard([keyCtx]{
+-        q_EVP_PKEY_CTX_free(keyCtx);
+-    });
+-
+-    const int result = q_EVP_PKEY_param_check(keyCtx);
+-    QSslSocketBackendPrivate::logAndClearErrorQueue();
+-    // Note: unlike DH_check, we cannot obtain the 'status',
+-    // if the 'result' is 0 (actually the result is 1 only
+-    // if this 'status' was 0). We could probably check the
+-    // errors from the error queue, but it's not needed anyway
+-    // - see the 'isSafeDH' below, how it returns immediately
+-    // on 0.
+-    Q_UNUSED(status)
+-
+-    return result;
+-}
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+-
+ static bool isSafeDH(DH *dh)
+ {
+     int status = 0;
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl.cpp b/qtbase/src/network/ssl/qsslsocket_openssl.cpp
+index 37fad2a68f..8f6858c867 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl.cpp
++++ b/qtbase/src/network/ssl/qsslsocket_openssl.cpp
+@@ -550,9 +550,9 @@ static void q_loadCiphersForConnection(SSL *connection, QList<QSslCipher> &ciphe
+ // Defined in qsslsocket.cpp
+ void q_setDefaultDtlsCiphers(const QList<QSslCipher> &ciphers);
+ 
+-long QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions)
++qssloptions QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions)
+ {
+-    long options;
++    qssloptions options;
+     if (protocol == QSsl::TlsV1SslV3)
+         options = SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3;
+     else if (protocol == QSsl::SecureProtocols)
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_p.h b/qtbase/src/network/ssl/qsslsocket_openssl_p.h
+index 4103de23e8..5547589256 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_p.h
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_p.h
+@@ -107,6 +107,12 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++typedef uint64_t qssloptions;
++#else
++typedef unsigned long qssloptions;
++#endif
++
+ struct QSslErrorEntry {
+     int code;
+     int depth;
+@@ -171,7 +177,7 @@ public:
+     QVector<QSslError> ocspErrors;
+     QByteArray ocspResponseDer;
+ 
+-    Q_AUTOTEST_EXPORT static long setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions);
++    Q_AUTOTEST_EXPORT static qssloptions setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions);
+     static QSslCipher QSslCipher_from_SSL_CIPHER(const SSL_CIPHER *cipher);
+     static QList<QSslCertificate> STACKOFX509_to_QSslCertificates(STACK_OF(X509) *x509);
+     static QList<QSslError> verify(const QList<QSslCertificate> &certificateChain, const QString &hostName);
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp b/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
+index e53fb279f0..459ccd0b19 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
+@@ -148,7 +148,6 @@ DEFINEFUNC(int, EVP_PKEY_up_ref, EVP_PKEY *a, a, return 0, return)
+ DEFINEFUNC2(EVP_PKEY_CTX *, EVP_PKEY_CTX_new, EVP_PKEY *pkey, pkey, ENGINE *e, e, return nullptr, return)
+ DEFINEFUNC(int, EVP_PKEY_param_check, EVP_PKEY_CTX *ctx, ctx, return 0, return)
+ DEFINEFUNC(void, EVP_PKEY_CTX_free, EVP_PKEY_CTX *ctx, ctx, return, return)
+-DEFINEFUNC(int, EVP_PKEY_base_id, EVP_PKEY *a, a, return NID_undef, return)
+ DEFINEFUNC(int, RSA_bits, RSA *a, a, return 0, return)
+ DEFINEFUNC(int, DSA_bits, DSA *a, a, return 0, return)
+ DEFINEFUNC(int, OPENSSL_sk_num, OPENSSL_STACK *a, a, return -1, return)
+@@ -158,7 +157,7 @@ DEFINEFUNC2(void, OPENSSL_sk_push, OPENSSL_STACK *a, a, void *b, b, return, DUMM
+ DEFINEFUNC(void, OPENSSL_sk_free, OPENSSL_STACK *a, a, return, DUMMYARG)
+ DEFINEFUNC2(void *, OPENSSL_sk_value, OPENSSL_STACK *a, a, int b, b, return nullptr, return)
+ DEFINEFUNC(int, SSL_session_reused, SSL *a, a, return 0, return)
+-DEFINEFUNC2(unsigned long, SSL_CTX_set_options, SSL_CTX *ctx, ctx, unsigned long op, op, return 0, return)
++DEFINEFUNC2(qssloptions, SSL_CTX_set_options, SSL_CTX *ctx, ctx, qssloptions op, op, return 0, return)
+ DEFINEFUNC(int, SSL_CTX_get_security_level, const SSL_CTX *ctx, ctx, return -1, return)
+ DEFINEFUNC2(void, SSL_CTX_set_security_level, SSL_CTX *ctx, ctx, int level, level, return, return)
+ #ifdef TLS1_3_VERSION
+@@ -371,7 +370,15 @@ DEFINEFUNC(const SSL_CIPHER *, SSL_get_current_cipher, SSL *a, a, return nullptr
+ DEFINEFUNC(int, SSL_version, const SSL *a, a, return 0, return)
+ DEFINEFUNC2(int, SSL_get_error, SSL *a, a, int b, b, return -1, return)
+ DEFINEFUNC(STACK_OF(X509) *, SSL_get_peer_cert_chain, SSL *a, a, return nullptr, return)
++
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++DEFINEFUNC(X509 *, SSL_get1_peer_certificate, SSL *a, a, return nullptr, return)
++DEFINEFUNC(int, EVP_PKEY_get_base_id, const EVP_PKEY *pkey, pkey, return -1, return)
++#else
+ DEFINEFUNC(X509 *, SSL_get_peer_certificate, SSL *a, a, return nullptr, return)
++DEFINEFUNC(int, EVP_PKEY_base_id, EVP_PKEY *a, a, return NID_undef, return)
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+ DEFINEFUNC(long, SSL_get_verify_result, const SSL *a, a, return -1, return)
+ DEFINEFUNC(SSL *, SSL_new, SSL_CTX *a, a, return nullptr, return)
+ DEFINEFUNC(SSL_CTX *, SSL_get_SSL_CTX, SSL *a, a, return nullptr, return)
+@@ -492,9 +499,7 @@ DEFINEFUNC(DH *, DH_new, DUMMYARG, DUMMYARG, return nullptr, return)
+ DEFINEFUNC(void, DH_free, DH *dh, dh, return, DUMMYARG)
+ DEFINEFUNC3(DH *, d2i_DHparams, DH**a, a, const unsigned char **pp, pp, long length, length, return nullptr, return)
+ DEFINEFUNC2(int, i2d_DHparams, DH *a, a, unsigned char **p, p, return -1, return)
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+ DEFINEFUNC2(int, DH_check, DH *dh, dh, int *codes, codes, return 0, return)
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+ DEFINEFUNC3(BIGNUM *, BN_bin2bn, const unsigned char *s, s, int len, len, BIGNUM *ret, ret, return nullptr, return)
+ 
+ #ifndef OPENSSL_NO_EC
+@@ -868,7 +873,6 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(EVP_PKEY_CTX_new)
+     RESOLVEFUNC(EVP_PKEY_param_check)
+     RESOLVEFUNC(EVP_PKEY_CTX_free)
+-    RESOLVEFUNC(EVP_PKEY_base_id)
+     RESOLVEFUNC(RSA_bits)
+     RESOLVEFUNC(OPENSSL_sk_new_null)
+     RESOLVEFUNC(OPENSSL_sk_push)
+@@ -1107,7 +1111,15 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(SSL_version)
+     RESOLVEFUNC(SSL_get_error)
+     RESOLVEFUNC(SSL_get_peer_cert_chain)
++
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++    RESOLVEFUNC(SSL_get1_peer_certificate)
++    RESOLVEFUNC(EVP_PKEY_get_base_id)
++#else
+     RESOLVEFUNC(SSL_get_peer_certificate)
++    RESOLVEFUNC(EVP_PKEY_base_id)
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+     RESOLVEFUNC(SSL_get_verify_result)
+     RESOLVEFUNC(SSL_new)
+     RESOLVEFUNC(SSL_get_SSL_CTX)
+@@ -1206,9 +1218,7 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(DH_free)
+     RESOLVEFUNC(d2i_DHparams)
+     RESOLVEFUNC(i2d_DHparams)
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+     RESOLVEFUNC(DH_check)
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+     RESOLVEFUNC(BN_bin2bn)
+ 
+ #ifndef OPENSSL_NO_EC
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h b/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
+index 95e8897a3b..27aeffa18a 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
+@@ -237,7 +237,6 @@ Q_AUTOTEST_EXPORT int q_EVP_PKEY_up_ref(EVP_PKEY *a);
+ EVP_PKEY_CTX *q_EVP_PKEY_CTX_new(EVP_PKEY *pkey, ENGINE *e);
+ void q_EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx);
+ int q_EVP_PKEY_param_check(EVP_PKEY_CTX *ctx);
+-int q_EVP_PKEY_base_id(EVP_PKEY *a);
+ int q_RSA_bits(RSA *a);
+ Q_AUTOTEST_EXPORT int q_OPENSSL_sk_num(OPENSSL_STACK *a);
+ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_pop_free(OPENSSL_STACK *a, void (*b)(void *));
+@@ -246,7 +245,7 @@ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_push(OPENSSL_STACK *st, void *data);
+ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_free(OPENSSL_STACK *a);
+ Q_AUTOTEST_EXPORT void * q_OPENSSL_sk_value(OPENSSL_STACK *a, int b);
+ int q_SSL_session_reused(SSL *a);
+-unsigned long q_SSL_CTX_set_options(SSL_CTX *ctx, unsigned long op);
++qssloptions q_SSL_CTX_set_options(SSL_CTX *ctx, qssloptions op);
+ int q_OPENSSL_init_ssl(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings);
+ size_t q_SSL_get_client_random(SSL *a, unsigned char *out, size_t outlen);
+ size_t q_SSL_SESSION_get_master_key(const SSL_SESSION *session, unsigned char *out, size_t outlen);
+@@ -510,7 +509,6 @@ const SSL_CIPHER *q_SSL_get_current_cipher(SSL *a);
+ int q_SSL_version(const SSL *a);
+ int q_SSL_get_error(SSL *a, int b);
+ STACK_OF(X509) *q_SSL_get_peer_cert_chain(SSL *a);
+-X509 *q_SSL_get_peer_certificate(SSL *a);
+ long q_SSL_get_verify_result(const SSL *a);
+ SSL *q_SSL_new(SSL_CTX *a);
+ SSL_CTX *q_SSL_get_SSL_CTX(SSL *a);
+@@ -582,10 +580,7 @@ DH *q_DH_new();
+ void q_DH_free(DH *dh);
+ DH *q_d2i_DHparams(DH **a, const unsigned char **pp, long length);
+ int q_i2d_DHparams(DH *a, unsigned char **p);
+-
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+ int q_DH_check(DH *dh, int *codes);
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+ 
+ BIGNUM *q_BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret);
+ #define q_SSL_CTX_set_tmp_dh(ctx, dh) q_SSL_CTX_ctrl((ctx), SSL_CTRL_SET_TMP_DH, 0, (char *)dh)
+@@ -754,6 +749,17 @@ void q_CRYPTO_free(void *str, const char *file, int line);
+ int q_SSL_CTX_get_security_level(const SSL_CTX *ctx);
+ void q_SSL_CTX_set_security_level(SSL_CTX *ctx, int level);
+ 
++// Here we have the ones that make difference between OpenSSL pre/post v3:
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++X509 *q_SSL_get1_peer_certificate(SSL *a);
++#define q_SSL_get_peer_certificate q_SSL_get1_peer_certificate
++int q_EVP_PKEY_get_base_id(const EVP_PKEY *pkey);
++#define q_EVP_PKEY_base_id q_EVP_PKEY_get_base_id
++#else
++X509 *q_SSL_get_peer_certificate(SSL *a);
++int q_EVP_PKEY_base_id(EVP_PKEY *a);
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+ QT_END_NAMESPACE
+ 
+ #endif
+diff --git a/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h b/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
+index bf37d07fd8..dbd42fb799 100644
+--- a/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
++++ b/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
+@@ -61,7 +61,11 @@
+ # if !defined(Q_OS_INTEGRITY)
+ #  define WIN_INTERFACE_CUSTOM   // NV
+ # endif // Q_OS_INTEGRITY
+-#endif  // QT_EGL_NO_X11
++#else // QT_EGL_NO_X11
++// If one has an eglplatform.h with https://github.com/KhronosGroup/EGL-Registry/pull/130
++// that needs USE_X11 to be defined.
++# define USE_X11
++#endif
+ 
+ #ifdef QT_EGL_WAYLAND
+ # define WAYLAND // NV
+diff --git a/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+index 159b490ce0..00aa80cd58 100644
+--- a/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
++++ b/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+@@ -567,6 +567,8 @@ void QFontconfigDatabase::populateFontDatabase()
+         fonts = FcFontList(nullptr, pattern, os);
+         FcObjectSetDestroy(os);
+         FcPatternDestroy(pattern);
++        if (!fonts)
++            return;
+     }
+ 
+     for (int i = 0; i < fonts->nfont; i++)
+diff --git a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
+index b713c19447..7cb9a8c79a 100644
+--- a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
++++ b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
+@@ -95,6 +95,7 @@ static constexpr const auto KeyTbl = qMakeArray(
+         Xkb2Qt<XKB_KEY_Clear,                   Qt::Key_Delete>,
+         Xkb2Qt<XKB_KEY_Pause,                   Qt::Key_Pause>,
+         Xkb2Qt<XKB_KEY_Print,                   Qt::Key_Print>,
++        Xkb2Qt<XKB_KEY_Sys_Req,                 Qt::Key_SysReq>,
+         Xkb2Qt<0x1005FF60,                      Qt::Key_SysReq>,         // hardcoded Sun SysReq
+         Xkb2Qt<0x1007ff00,                      Qt::Key_SysReq>,         // hardcoded X386 SysReq
+ 
+@@ -471,7 +472,7 @@ QVector<xkb_keysym_t> QXkbCommon::toKeysym(QKeyEvent *event)
+     } else if (event->modifiers() & Qt::KeypadModifier) {
+         if (qtKey >= Qt::Key_0 && qtKey <= Qt::Key_9)
+             keysyms.append(XKB_KEY_KP_0 + (qtKey - Qt::Key_0));
+-    } else if (isLatin(qtKey) && event->text().isUpper()) {
++    } else if (isLatin1(qtKey) && event->text().isUpper()) {
+         keysyms.append(qtKey);
+     }
+ 
+@@ -523,7 +524,7 @@ int QXkbCommon::keysymToQtKey(xkb_keysym_t keysym, Qt::KeyboardModifiers modifie
+         // With standard shortcuts we should prefer a latin character, this is
+         // for checks like "some qkeyevent == QKeySequence::Copy" to work even
+         // when using for example 'russian' keyboard layout.
+-        if (!QXkbCommon::isLatin(keysym)) {
++        if (!QXkbCommon::isLatin1(keysym)) {
+             xkb_keysym_t latinKeysym = QXkbCommon::lookupLatinKeysym(state, code);
+             if (latinKeysym != XKB_KEY_NoSymbol)
+                 keysym = latinKeysym;
+@@ -546,7 +547,7 @@ static int keysymToQtKey_internal(xkb_keysym_t keysym, Qt::KeyboardModifiers mod
+     } else if (keysym >= XKB_KEY_KP_0 && keysym <= XKB_KEY_KP_9) {
+         // numeric keypad keys
+         qtKey = Qt::Key_0 + (keysym - XKB_KEY_KP_0);
+-    } else if (QXkbCommon::isLatin(keysym)) {
++    } else if (QXkbCommon::isLatin1(keysym)) {
+         qtKey = QXkbCommon::qxkbcommon_xkb_keysym_to_upper(keysym);
+     } else {
+         // check if we have a direct mapping
+@@ -678,7 +679,7 @@ QList<int> QXkbCommon::possibleKeys(xkb_state *state, const QKeyEvent *event,
+         Qt::KeyboardModifiers neededMods = ModsTbl[i];
+         if ((modifiers & neededMods) == neededMods) {
+             if (i == 8) {
+-                if (isLatin(baseQtKey))
++                if (isLatin1(baseQtKey))
+                     continue;
+                 // add a latin key as a fall back key
+                 sym = lookupLatinKeysym(state, keycode);
+@@ -733,7 +734,7 @@ void QXkbCommon::verifyHasLatinLayout(xkb_keymap *keymap)
+     for (xkb_layout_index_t layout = 0; layout < layoutCount; ++layout) {
+         for (xkb_keycode_t code = minKeycode; code < maxKeycode; ++code) {
+             xkb_keymap_key_get_syms_by_level(keymap, code, layout, 0, &keysyms);
+-            if (keysyms && isLatin(keysyms[0]))
++            if (keysyms && isLatin1(keysyms[0]))
+                 nrLatinKeys++;
+             if (nrLatinKeys > 10) // arbitrarily chosen threshold
+                 return;
+@@ -766,7 +767,7 @@ xkb_keysym_t QXkbCommon::lookupLatinKeysym(xkb_state *state, xkb_keycode_t keyco
+         xkb_level_index_t level = xkb_state_key_get_level(state, keycode, layout);
+         if (xkb_keymap_key_get_syms_by_level(keymap, keycode, layout, level, &syms) != 1)
+             continue;
+-        if (isLatin(syms[0])) {
++        if (isLatin1(syms[0])) {
+             sym = syms[0];
+             break;
+         }
+diff --git a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
+index 561eae03db..8389bd8f5a 100644
+--- a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
++++ b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
+@@ -94,8 +94,8 @@ public:
+     static void verifyHasLatinLayout(xkb_keymap *keymap);
+     static xkb_keysym_t lookupLatinKeysym(xkb_state *state, xkb_keycode_t keycode);
+ 
+-    static bool isLatin(xkb_keysym_t sym) {
+-        return ((sym >= 'a' && sym <= 'z') || (sym >= 'A' && sym <= 'Z'));
++    static bool isLatin1(xkb_keysym_t sym) {
++        return sym <= 0xff;
+     }
+     static bool isKeypad(xkb_keysym_t sym) {
+         return sym >= XKB_KEY_KP_Space && sym <= XKB_KEY_KP_9;
+diff --git a/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp b/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
+index 8cd7f9b368..406f84663f 100644
+--- a/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
++++ b/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
+@@ -318,7 +318,7 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources,
+ 
+     if (current < 0 && crtc_mode.clock != 0) {
+         modes << crtc_mode;
+-        current = mode.size() - 1;
++        current = modes.size() - 1;
+     }
+ 
+     if (configuration == OutputConfigCurrent)
+diff --git a/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp b/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
+index 9153fd20bb..255ea5e33e 100644
+--- a/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
++++ b/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
+@@ -194,6 +194,9 @@ QString AtSpiAdaptor::introspect(const QString &path) const
+                 "      <arg direction=\"out\" type=\"(so)\"/>\n"
+                 "      <annotation value=\"QSpiObjectReference\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n"
+                 "    </method>\n"
++                "    <method name=\"GetAccessibleId\">\n"
++                "      <arg direction=\"out\" type=\"s\"/>\n"
++                "    </method>\n"
+                 "  </interface>\n"
+                 );
+ 
+@@ -913,8 +916,17 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+     }
+     case QAccessible::NameChanged: {
+         if (sendObject || sendObject_property_change || sendObject_property_change_accessible_name) {
+-            QString path = pathForInterface(event->accessibleInterface());
+-            QVariantList args = packDBusSignalArguments(QLatin1String("accessible-name"), 0, 0, variantForPath(path));
++            QAccessibleInterface *iface = event->accessibleInterface();
++            if (!iface) {
++                qCDebug(lcAccessibilityAtspi,
++                        "NameChanged event from invalid accessible.");
++                return;
++            }
++
++            QString path = pathForInterface(iface);
++            QVariantList args = packDBusSignalArguments(
++                QLatin1String("accessible-name"), 0, 0,
++                QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Name))));
+             sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                            QLatin1String("PropertyChange"), args);
+         }
+@@ -922,8 +934,17 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+     }
+     case QAccessible::DescriptionChanged: {
+         if (sendObject || sendObject_property_change || sendObject_property_change_accessible_description) {
+-            QString path = pathForInterface(event->accessibleInterface());
+-            QVariantList args = packDBusSignalArguments(QLatin1String("accessible-description"), 0, 0, variantForPath(path));
++            QAccessibleInterface *iface = event->accessibleInterface();
++            if (!iface) {
++                qCDebug(lcAccessibilityAtspi,
++                        "DescriptionChanged event from invalid accessible.");
++                return;
++            }
++
++            QString path = pathForInterface(iface);
++            QVariantList args = packDBusSignalArguments(
++                QLatin1String("accessible-description"), 0, 0,
++                QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Description))));
+             sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                            QLatin1String("PropertyChange"), args);
+         }
+@@ -1038,7 +1059,9 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+                 // Combo Box with AT-SPI likes to be special
+                 // It requires a name-change to update caches and then selection-changed
+                 QString path = pathForInterface(iface);
+-                QVariantList args1 = packDBusSignalArguments(QLatin1String("accessible-name"), 0, 0, variantForPath(path));
++                QVariantList args1 = packDBusSignalArguments(
++                    QLatin1String("accessible-name"), 0, 0,
++                    QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Name))));
+                 sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                                QLatin1String("PropertyChange"), args1);
+                 QVariantList args2 = packDBusSignalArguments(QString(), 0, 0, QVariant::fromValue(QDBusVariant(QVariant(0))));
+@@ -1358,6 +1381,26 @@ void AtSpiAdaptor::registerApplication()
+     delete registry;
+ }
+ 
++namespace {
++QString accessibleIdForAccessible(QAccessibleInterface *accessible)
++{
++    QString result;
++    while (accessible) {
++        if (!result.isEmpty())
++            result.prepend(QLatin1Char('.'));
++        if (auto obj = accessible->object()) {
++            const QString name = obj->objectName();
++            if (!name.isEmpty())
++                result.prepend(name);
++            else
++                result.prepend(QString::fromUtf8(obj->metaObject()->className()));
++        }
++        accessible = accessible->parent();
++    }
++    return result;
++}
++} // namespace
++
+ // Accessible
+ bool AtSpiAdaptor::accessibleInterface(QAccessibleInterface *interface, const QString &function, const QDBusMessage &message, const QDBusConnection &connection)
+ {
+@@ -1441,6 +1484,9 @@ bool AtSpiAdaptor::accessibleInterface(QAccessibleInterface *interface, const QS
+             children << ref;
+         }
+         connection.send(message.createReply(QVariant::fromValue(children)));
++    } else if (function == QLatin1String("GetAccessibleId")) {
++        sendReply(connection, message,
++                  QVariant::fromValue(QDBusVariant(accessibleIdForAccessible(interface))));
+     } else {
+         qCDebug(lcAccessibilityAtspi) << "WARNING: AtSpiAdaptor::accessibleInterface does not implement " << function << message.path();
+         return false;
+diff --git a/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp b/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
+index 45ddc8e496..cc734abc63 100644
+--- a/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
++++ b/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
+@@ -69,6 +69,21 @@ QT_BEGIN_NAMESPACE
+ DBusConnection::DBusConnection(QObject *parent)
+     : QObject(parent), m_a11yConnection(QString()), m_enabled(false)
+ {
++    // If the bus is explicitly set via env var it overrides everything else.
++    QByteArray addressEnv = qgetenv("AT_SPI_BUS_ADDRESS");
++    if (!addressEnv.isEmpty()) {
++        // Only connect on next loop run, connections to our enabled signal are
++        // only established after the ctor returns.
++        QMetaObject::invokeMethod(
++                this,
++                [this, addressEnv] {
++                    m_enabled = true;
++                    connectA11yBus(QString::fromLocal8Bit(addressEnv));
++                },
++                Qt::QueuedConnection);
++        return;
++    }
++
+     // Start monitoring if "org.a11y.Bus" is registered as DBus service.
+     QDBusConnection c = QDBusConnection::sessionBus();
+     if (!c.isConnected()) {
+diff --git a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
+index 1a3cab275d..2abe039126 100644
+--- a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
++++ b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
+@@ -51,6 +51,9 @@
+ #include <QtCore/QStandardPaths>
+ #include <QtCore/QUrl>
+ 
++#include <QtGui/QGuiApplication>
++#include <QtGui/QWindow>
++
+ #if QT_CONFIG(dbus)
+ // These QtCore includes are needed for xdg-desktop-portal support
+ #include <QtCore/private/qcore_unix_p.h>
+@@ -58,6 +61,8 @@
+ #include <QtCore/QFileInfo>
+ #include <QtCore/QUrlQuery>
+ 
++#include <QtGui/QColor>
++
+ #include <QtDBus/QDBusConnection>
+ #include <QtDBus/QDBusMessage>
+ #include <QtDBus/QDBusPendingCall>
+@@ -142,6 +147,8 @@ static inline bool detectWebBrowser(const QByteArray &desktop,
+     }
+ 
+     if (desktop == QByteArray("KDE")) {
++        if (checkExecutable(QStringLiteral("kde-open5"), browser))
++            return true;
+         // Konqueror launcher
+         if (checkExecutable(QStringLiteral("kfmclient"), browser)) {
+             browser->append(QLatin1String(" exec"));
+@@ -296,8 +303,135 @@ static inline QDBusMessage xdgDesktopPortalSendEmail(const QUrl &url)
+ 
+     return QDBusConnection::sessionBus().call(message);
+ }
++
++namespace {
++struct XDGDesktopColor
++{
++    double r = 0;
++    double g = 0;
++    double b = 0;
++
++    QColor toQColor() const
++    {
++        constexpr auto rgbMax = 255;
++        return { static_cast<int>(r * rgbMax), static_cast<int>(g * rgbMax),
++                 static_cast<int>(b * rgbMax) };
++    }
++};
++
++const QDBusArgument &operator>>(const QDBusArgument &argument, XDGDesktopColor &myStruct)
++{
++    argument.beginStructure();
++    argument >> myStruct.r >> myStruct.g >> myStruct.b;
++    argument.endStructure();
++    return argument;
++}
++
++class XdgDesktopPortalColorPicker : public QPlatformServiceColorPicker
++{
++    Q_OBJECT
++public:
++    XdgDesktopPortalColorPicker(const QString &parentWindowId, QWindow *parent)
++        : QPlatformServiceColorPicker(parent), m_parentWindowId(parentWindowId)
++    {
++    }
++
++    void pickColor() override
++    {
++        // DBus signature:
++        // PickColor (IN   s      parent_window,
++        //            IN   a{sv}  options
++        //            OUT  o      handle)
++        // Options:
++        // handle_token (s) -  A string that will be used as the last element of the @handle.
++
++        QDBusMessage message = QDBusMessage::createMethodCall(
++                QStringLiteral("org.freedesktop.portal.Desktop"), QStringLiteral("/org/freedesktop/portal/desktop"),
++                QStringLiteral("org.freedesktop.portal.Screenshot"), QStringLiteral("PickColor"));
++        message << m_parentWindowId << QVariantMap();
++
++        QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
++        auto watcher = new QDBusPendingCallWatcher(pendingCall, this);
++        connect(watcher, &QDBusPendingCallWatcher::finished, this,
++                [this](QDBusPendingCallWatcher *watcher) {
++                    watcher->deleteLater();
++                    QDBusPendingReply<QDBusObjectPath> reply = *watcher;
++                    if (reply.isError()) {
++                        qWarning("DBus call to pick color failed: %s",
++                                 qPrintable(reply.error().message()));
++                        Q_EMIT colorPicked({});
++                    } else {
++                        QDBusConnection::sessionBus().connect(
++                                QStringLiteral("org.freedesktop.portal.Desktop"), reply.value().path(),
++                                QStringLiteral("org.freedesktop.portal.Request"), QStringLiteral("Response"), this,
++                                // clang-format off
++                                SLOT(gotColorResponse(uint,QVariantMap))
++                                // clang-format on
++                        );
++                    }
++                });
++    }
++
++private Q_SLOTS:
++    void gotColorResponse(uint result, const QVariantMap &map)
++    {
++        if (result != 0)
++            return;
++        XDGDesktopColor color{};
++        map.value(QStringLiteral("color")).value<QDBusArgument>() >> color;
++        Q_EMIT colorPicked(color.toQColor());
++        deleteLater();
++    }
++
++private:
++    const QString m_parentWindowId;
++};
++} // namespace
++
+ #endif // QT_CONFIG(dbus)
+ 
++QGenericUnixServices::QGenericUnixServices()
++{
++#if QT_CONFIG(dbus)
++    if (qEnvironmentVariableIntValue("QT_NO_XDG_DESKTOP_PORTAL") > 0) {
++        return;
++    }
++    QDBusMessage message = QDBusMessage::createMethodCall(
++            QStringLiteral("org.freedesktop.portal.Desktop"), QStringLiteral("/org/freedesktop/portal/desktop"),
++            QStringLiteral("org.freedesktop.DBus.Properties"), QStringLiteral("Get"));
++    message << QStringLiteral("org.freedesktop.portal.Screenshot")
++            << QStringLiteral("version");
++
++    QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
++    auto watcher = new QDBusPendingCallWatcher(pendingCall);
++    QObject::connect(watcher, &QDBusPendingCallWatcher::finished, watcher,
++                     [this](QDBusPendingCallWatcher *watcher) {
++                         watcher->deleteLater();
++                         QDBusPendingReply<QVariant> reply = *watcher;
++                         if (!reply.isError() && reply.value().toUInt() >= 2)
++                             m_hasScreenshotPortalWithColorPicking = true;
++                     });
++
++#endif
++}
++
++QPlatformServiceColorPicker *QGenericUnixServices::colorPicker(QWindow *parent)
++{
++#if QT_CONFIG(dbus)
++    // Make double sure that we are in a wayland environment. In particular check
++    // WAYLAND_DISPLAY so also XWayland apps benefit from portal-based color picking.
++    // Outside wayland we'll rather rely on other means than the XDG desktop portal.
++    if (!qEnvironmentVariableIsEmpty("WAYLAND_DISPLAY")
++        || QGuiApplication::platformName().startsWith(QLatin1String("wayland"))) {
++        return new XdgDesktopPortalColorPicker(portalWindowIdentifier(parent), parent);
++    }
++    return nullptr;
++#else
++    Q_UNUSED(parent);
++    return nullptr;
++#endif
++}
++
+ QByteArray QGenericUnixServices::desktopEnvironment() const
+ {
+     static const QByteArray result = detectDesktopEnvironment();
+@@ -352,6 +486,8 @@ bool QGenericUnixServices::openDocument(const QUrl &url)
+ }
+ 
+ #else
++QGenericUnixServices::QGenericUnixServices() = default;
++
+ QByteArray QGenericUnixServices::desktopEnvironment() const
+ {
+     return QByteArrayLiteral("UNKNOWN");
+@@ -371,6 +507,30 @@ bool QGenericUnixServices::openDocument(const QUrl &url)
+     return false;
+ }
+ 
++QPlatformServiceColorPicker *QGenericUnixServices::colorPicker(QWindow *parent)
++{
++    Q_UNUSED(parent);
++    return nullptr;
++}
++
+ #endif // QT_NO_MULTIPROCESS
+ 
++QString QGenericUnixServices::portalWindowIdentifier(QWindow *window)
++{
++    if (QGuiApplication::platformName() == QLatin1String("xcb"))
++        return QStringLiteral("x11:") + QString::number(window->winId(), 16);
++    return QString();
++}
++
++bool QGenericUnixServices::hasCapability(Capability capability) const
++{
++    switch (capability) {
++    case Capability::ColorPicking:
++        return m_hasScreenshotPortalWithColorPicking;
++    }
++    return false;
++}
++
+ QT_END_NAMESPACE
++
++#include "qgenericunixservices.moc"
+diff --git a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
+index 8ac3de6f03..30924e64bd 100644
+--- a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
++++ b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
+@@ -59,16 +59,21 @@ QT_BEGIN_NAMESPACE
+ class QGenericUnixServices : public QPlatformServices
+ {
+ public:
+-    QGenericUnixServices() {}
++    QGenericUnixServices();
+ 
+     QByteArray desktopEnvironment() const override;
+ 
++    bool hasCapability(Capability capability) const override;
+     bool openUrl(const QUrl &url) override;
+     bool openDocument(const QUrl &url) override;
++    QPlatformServiceColorPicker *colorPicker(QWindow *parent = nullptr) override;
++
++    virtual QString portalWindowIdentifier(QWindow *window);
+ 
+ private:
+     QString m_webBrowser;
+     QString m_documentLauncher;
++    bool m_hasScreenshotPortalWithColorPicking = false;
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
+index 09470bccc6..cc7c7d4d8a 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
+@@ -69,6 +69,7 @@ const QString MenuBarPath = QLatin1String("/MenuBar");
+ */
+ QDBusMenuConnection::QDBusMenuConnection(QObject *parent, const QString &serviceName)
+     : QObject(parent)
++    , m_serviceName(serviceName)
+     , m_connection(serviceName.isNull() ? QDBusConnection::sessionBus()
+                                         : QDBusConnection::connectToBus(QDBusConnection::SessionBus, serviceName))
+     , m_dbusWatcher(new QDBusServiceWatcher(StatusNotifierWatcherService, m_connection, QDBusServiceWatcher::WatchForRegistration, this))
+@@ -83,6 +84,12 @@ QDBusMenuConnection::QDBusMenuConnection(QObject *parent, const QString &service
+ #endif
+ }
+ 
++QDBusMenuConnection::~QDBusMenuConnection()
++{
++  if (!m_serviceName.isEmpty() && m_connection.isConnected())
++      QDBusConnection::disconnectFromBus(m_serviceName);
++}
++
+ void QDBusMenuConnection::dbusError(const QDBusError &error)
+ {
+     qWarning() << "QDBusTrayIcon encountered a D-Bus error:" << error;
+@@ -105,13 +112,7 @@ void QDBusMenuConnection::unregisterTrayIconMenu(QDBusTrayIcon *item)
+ 
+ bool QDBusMenuConnection::registerTrayIcon(QDBusTrayIcon *item)
+ {
+-    bool success = connection().registerService(item->instanceId());
+-    if (!success) {
+-        qWarning() << "failed to register service" << item->instanceId();
+-        return false;
+-    }
+-
+-    success = connection().registerObject(StatusNotifierItemPath, item);
++    bool success = connection().registerObject(StatusNotifierItemPath, item);
+     if (!success) {
+         unregisterTrayIcon(item);
+         qWarning() << "failed to register" << item->instanceId() << StatusNotifierItemPath;
+@@ -126,21 +127,18 @@ bool QDBusMenuConnection::registerTrayIcon(QDBusTrayIcon *item)
+ 
+ bool QDBusMenuConnection::registerTrayIconWithWatcher(QDBusTrayIcon *item)
+ {
++    Q_UNUSED(item);
+     QDBusMessage registerMethod = QDBusMessage::createMethodCall(
+                 StatusNotifierWatcherService, StatusNotifierWatcherPath, StatusNotifierWatcherService,
+                 QLatin1String("RegisterStatusNotifierItem"));
+-    registerMethod.setArguments(QVariantList() << item->instanceId());
++    registerMethod.setArguments(QVariantList() << m_connection.baseService());
+     return m_connection.callWithCallback(registerMethod, this, SIGNAL(trayIconRegistered()), SLOT(dbusError(QDBusError)));
+ }
+ 
+-bool QDBusMenuConnection::unregisterTrayIcon(QDBusTrayIcon *item)
++void QDBusMenuConnection::unregisterTrayIcon(QDBusTrayIcon *item)
+ {
+     unregisterTrayIconMenu(item);
+     connection().unregisterObject(StatusNotifierItemPath);
+-    bool success = connection().unregisterService(item->instanceId());
+-    if (!success)
+-        qWarning() << "failed to unregister service" << item->instanceId();
+-    return success;
+ }
+ #endif // QT_NO_SYSTEMTRAYICON
+ 
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
+index f484795fbb..97bdfabb85 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
++++ b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
+@@ -70,6 +70,7 @@ class QDBusMenuConnection : public QObject
+ 
+ public:
+     QDBusMenuConnection(QObject *parent = nullptr, const QString &serviceName = QString());
++    ~QDBusMenuConnection();
+     QDBusConnection connection() const { return m_connection; }
+     QDBusServiceWatcher *dbusWatcher() const { return m_dbusWatcher; }
+     bool isStatusNotifierHostRegistered() const { return m_statusNotifierHostRegistered; }
+@@ -78,7 +79,7 @@ public:
+     void unregisterTrayIconMenu(QDBusTrayIcon *item);
+     bool registerTrayIcon(QDBusTrayIcon *item);
+     bool registerTrayIconWithWatcher(QDBusTrayIcon *item);
+-    bool unregisterTrayIcon(QDBusTrayIcon *item);
++    void unregisterTrayIcon(QDBusTrayIcon *item);
+ #endif // QT_NO_SYSTEMTRAYICON
+ 
+ Q_SIGNALS:
+@@ -90,6 +91,7 @@ private Q_SLOTS:
+     void dbusError(const QDBusError &error);
+ 
+ private:
++    QString m_serviceName;
+     QDBusConnection m_connection;
+     QDBusServiceWatcher *m_dbusWatcher;
+     bool m_statusNotifierHostRegistered;
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp b/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
+index bede70975a..76bfec5e5a 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
+@@ -71,8 +71,12 @@ Q_LOGGING_CATEGORY(qLcTray, "qt.qpa.tray")
+ static QString iconTempPath()
+ {
+     QString tempPath = QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation);
+-    if (!tempPath.isEmpty())
++    if (!tempPath.isEmpty()) {
++        QString flatpakId = qEnvironmentVariable("FLATPAK_ID");
++        if (!flatpakId.isEmpty() && QFileInfo::exists(QLatin1String("/.flatpak-info")))
++            tempPath += QLatin1String("/app/") + flatpakId;
+         return tempPath;
++    }
+ 
+     tempPath = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation);
+ 
+diff --git a/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+index cb1b39db64..6e01af052c 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+@@ -755,6 +755,9 @@ QVariant QGnomeTheme::themeHint(QPlatformTheme::ThemeHint hint) const
+         return QVariant(QChar(0x2022));
+     case QPlatformTheme::UiEffects:
+         return QVariant(int(HoverEffect));
++    case QPlatformTheme::ButtonPressKeys:
++        return QVariant::fromValue(
++                QList<Qt::Key>({ Qt::Key_Space, Qt::Key_Return, Qt::Key_Enter, Qt::Key_Select }));
+     default:
+         break;
+     }
+diff --git a/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp b/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
+index 98e05195ee..1e92f43dec 100644
+--- a/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
++++ b/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
+@@ -343,8 +343,7 @@ void QEglFSCursor::paintOnScreen()
+     // screens are siblings of each other. When not enabled, the sibling list
+     // only contains m_screen itself.
+     for (QPlatformScreen *screen : m_screen->virtualSiblings()) {
+-        if (screen->geometry().contains(cr.topLeft().toPoint() + m_cursor.hotSpot)
+-            && QOpenGLContext::currentContext()->screen() == screen->screen())
++        if (screen->geometry().contains(cr.topLeft().toPoint() + m_cursor.hotSpot))
+         {
+             cr.translate(-screen->geometry().topLeft());
+             const QSize screenSize = screen->geometry().size();
+@@ -468,11 +467,12 @@ void QEglFSCursor::draw(const QRectF &r)
+ {
+     StateSaver stateSaver;
+ 
+-    QEglFSCursorData &gfx = static_cast<QEglFSContext*>(QOpenGLContext::currentContext()->handle())->cursorData;
+-    if (!gfx.program) {
+-        // one time initialization
++    // one time initialization
++    if (!QOpenGLFunctions::d_ptr)
+         initializeOpenGLFunctions();
+ 
++    QEglFSCursorData &gfx = static_cast<QEglFSContext*>(QOpenGLContext::currentContext()->handle())->cursorData;
++    if (!gfx.program) {
+         createShaderPrograms();
+ 
+         if (!gfx.atlasTexture) {
+diff --git a/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp b/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
+index 645a0ae2e9..3e0e406f1a 100644
+--- a/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
++++ b/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
+@@ -179,7 +179,7 @@ void QEglFSKmsEventReader::create(QEglFSKmsDevice *device)
+ 
+     m_device = device;
+ 
+-    qCDebug(qLcEglfsKmsDebug, "Initalizing event reader for device %p fd %d",
++    qCDebug(qLcEglfsKmsDebug, "Initializing event reader for device %p fd %d",
+             m_device, m_device->fd());
+ 
+     m_thread = new QEglFSKmsEventReaderThread(m_device->fd());
+diff --git a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
+index 141fb68a23..d4294d425a 100644
+--- a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
++++ b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
+@@ -122,11 +122,13 @@ QOffscreenIntegration::QOffscreenIntegration()
+ #endif
+     m_services.reset(new QPlatformServices);
+ 
+-    QWindowSystemInterface::handleScreenAdded(new QOffscreenScreen);
++    m_screen = new QOffscreenScreen;
++    QWindowSystemInterface::handleScreenAdded(m_screen);
+ }
+ 
+ QOffscreenIntegration::~QOffscreenIntegration()
+ {
++    QWindowSystemInterface::handleScreenRemoved(m_screen);
+ }
+ 
+ void QOffscreenIntegration::initialize()
+diff --git a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
+index 0ea90f6c2f..fe00fde07c 100644
+--- a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
++++ b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
+@@ -84,6 +84,7 @@ protected:
+ #endif
+     QScopedPointer<QPlatformInputContext> m_inputContext;
+     QScopedPointer<QPlatformServices> m_services;
++    QPlatformScreen *m_screen;
+     mutable QScopedPointer<QPlatformNativeInterface> m_nativeInterface;
+ };
+ 
+diff --git a/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp b/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
+index 6fa5a8a2b3..1f49f0aefd 100644
+--- a/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
++++ b/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
+@@ -48,6 +48,7 @@
+ #include <qpa/qplatformnativeinterface.h>
+ #include <QtPlatformHeaders/qwglnativecontext.h>
+ 
++#include <private/qsystemlibrary_p.h>
+ #include <algorithm>
+ 
+ #include <wingdi.h>
+@@ -162,19 +163,25 @@ QFunctionPointer QWindowsOpengl32DLL::resolve(const char *name)
+ 
+ bool QWindowsOpengl32DLL::init(bool softwareRendering)
+ {
+-    const QByteArray opengl32 = QByteArrayLiteral("opengl32.dll");
+-    const QByteArray swopengl = QByteArrayLiteral("opengl32sw.dll");
++    const QByteArray opengl32 = QByteArrayLiteral("opengl32");
++    const QByteArray swopengl = QByteArrayLiteral("opengl32sw");
++    bool useSystemLib = false;
+ 
+     QByteArray openglDll = qgetenv("QT_OPENGL_DLL");
+-    if (openglDll.isEmpty())
++    if (openglDll.isEmpty()) {
+         openglDll = softwareRendering ? swopengl : opengl32;
++        useSystemLib = !softwareRendering;
++    }
+ 
+     openglDll = openglDll.toLower();
+     m_nonOpengl32 = openglDll != opengl32;
+ 
+     qCDebug(lcQpaGl) << "Qt: Using WGL and OpenGL from" << openglDll;
+ 
+-    m_lib = ::LoadLibraryA(openglDll.constData());
++    if (useSystemLib)
++        m_lib = QSystemLibrary::load((wchar_t*)(QString::fromLatin1(openglDll).utf16()));
++    else
++        m_lib = LoadLibraryA(openglDll.constData());
+     if (!m_lib) {
+         qErrnoWarning(::GetLastError(), "Failed to load %s", openglDll.constData());
+         return false;
+@@ -184,7 +191,7 @@ bool QWindowsOpengl32DLL::init(bool softwareRendering)
+         // Load opengl32.dll always. GDI functions like ChoosePixelFormat do
+         // GetModuleHandle for opengl32.dll and behave differently (and call back into
+         // opengl32) when the module is present. This is fine for dummy contexts and windows.
+-        ::LoadLibraryA("opengl32.dll");
++        QSystemLibrary::load(L"opengl32");
+     }
+ 
+     wglCreateContext = reinterpret_cast<HGLRC (WINAPI *)(HDC)>(resolve("wglCreateContext"));
+diff --git a/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp b/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
+index d7d186e804..9eb4011bf2 100644
+--- a/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
++++ b/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
+@@ -49,6 +49,7 @@
+ #include <QtCore/qstandardpaths.h>
+ #include <QtCore/qlibraryinfo.h>
+ #include <QtCore/qhash.h>
++#include <private/qsystemlibrary_p.h>
+ 
+ #ifndef QT_NO_OPENGL
+ #include <private/qopengl_p.h>
+@@ -396,7 +397,7 @@ bool QWindowsOpenGLTester::testDesktopGL()
+ 
+     // Test #1: Load opengl32.dll and try to resolve an OpenGL 2 function.
+     // This will typically fail on systems that do not have a real OpenGL driver.
+-    lib = LoadLibraryA("opengl32.dll");
++    lib = QSystemLibrary::load(L"opengl32");
+     if (lib) {
+         CreateContext = reinterpret_cast<CreateContextType>(
+             reinterpret_cast<QFunctionPointer>(::GetProcAddress(lib, "wglCreateContext")));
+diff --git a/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp b/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
+index 1afa00cfc9..118af6ce73 100644
+--- a/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
++++ b/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
+@@ -41,6 +41,7 @@
+ 
+ #include <QRect>
+ #include <QList>
++#include <QMap>
+ #include <QDebug>
+ 
+ #include <qmath.h>
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp b/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
+index 9e2a37a6a1..e6e175a118 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
+@@ -488,12 +488,12 @@ void QXcbConnection::printXcbError(const char *message, xcb_generic_error_t *err
+     uint clamped_error_code = qMin<uint>(error->error_code, (sizeof(xcb_errors) / sizeof(xcb_errors[0])) - 1);
+     uint clamped_major_code = qMin<uint>(error->major_code, (sizeof(xcb_protocol_request_codes) / sizeof(xcb_protocol_request_codes[0])) - 1);
+ 
+-    qCWarning(lcQpaXcb, "%s: %d (%s), sequence: %d, resource id: %d, major code: %d (%s), minor code: %d",
+-             message,
+-             int(error->error_code), xcb_errors[clamped_error_code],
+-             int(error->sequence), int(error->resource_id),
+-             int(error->major_code), xcb_protocol_request_codes[clamped_major_code],
+-             int(error->minor_code));
++    qCDebug(lcQpaXcb, "%s: %d (%s), sequence: %d, resource id: %d, major code: %d (%s), minor code: %d",
++            message,
++            int(error->error_code), xcb_errors[clamped_error_code],
++            int(error->sequence), int(error->resource_id),
++            int(error->major_code), xcb_protocol_request_codes[clamped_major_code],
++            int(error->minor_code));
+ }
+ 
+ static Qt::MouseButtons translateMouseButtons(int s)
+@@ -702,6 +702,8 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
+             QXcbVirtualDesktop *virtualDesktop = virtualDesktopForRootWindow(propertyNotify->window);
+             if (virtualDesktop)
+                 virtualDesktop->updateWorkArea();
++        } else if (propertyNotify->atom == atom(QXcbAtom::_NET_SUPPORTED)) {
++            m_wmSupport->updateNetWMAtoms();
+         } else {
+             HANDLE_PLATFORM_WINDOW_EVENT(xcb_property_notify_event_t, window, handlePropertyNotifyEvent);
+         }
+@@ -750,7 +752,7 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
+                 case XCB_XKB_NEW_KEYBOARD_NOTIFY: {
+                     xcb_xkb_new_keyboard_notify_event_t *ev = &xkb_event->new_keyboard_notify;
+                     if (ev->changed & XCB_XKB_NKN_DETAIL_KEYCODES)
+-                        m_keyboard->updateKeymap(ev);
++                        m_keyboard->updateKeymap();
+                     break;
+                 }
+                 default:
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp b/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
+index 76869ced60..02d2eebb56 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
+@@ -274,8 +274,7 @@ QPlatformWindow *QXcbIntegration::createForeignWindow(QWindow *window, WId nativ
+ #ifndef QT_NO_OPENGL
+ QPlatformOpenGLContext *QXcbIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
+ {
+-    QXcbScreen *screen = static_cast<QXcbScreen *>(context->screen()->handle());
+-    QXcbGlIntegration *glIntegration = screen->connection()->glIntegration();
++    QXcbGlIntegration *glIntegration = defaultConnection()->glIntegration();
+     if (!glIntegration) {
+         qWarning("QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled");
+         return nullptr;
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+index efecd7e2d1..e8286381a2 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+@@ -365,17 +365,6 @@ void QXcbKeyboard::updateKeymap(xcb_mapping_notify_event_t *event)
+     updateKeymap();
+ }
+ 
+-void QXcbKeyboard::updateKeymap(xcb_xkb_new_keyboard_notify_event_t *event)
+-{
+-    if (!event)
+-        return;
+-
+-    if (event->deviceID != event->oldDeviceID)
+-        m_config = false;
+-
+-    updateKeymap();
+-}
+-
+ void QXcbKeyboard::updateKeymap()
+ {
+     KeysymModifierMap keysymMods;
+@@ -383,6 +372,8 @@ void QXcbKeyboard::updateKeymap()
+         keysymMods = keysymsToModifiers();
+     updateModifiers(keysymMods);
+ 
++    m_config = true;
++
+     if (!m_xkbContext) {
+         m_xkbContext.reset(xkb_context_new(XKB_CONTEXT_NO_DEFAULT_INCLUDES));
+         if (!m_xkbContext) {
+@@ -398,13 +389,8 @@ void QXcbKeyboard::updateKeymap()
+     if (connection()->hasXKB()) {
+         m_xkbKeymap.reset(xkb_x11_keymap_new_from_device(m_xkbContext.get(), xcb_connection(),
+                                                          core_device_id, XKB_KEYMAP_COMPILE_NO_FLAGS));
+-        if (m_xkbKeymap) {
+-            if (m_config)
+-                m_xkbState.reset(xkb_state_new(m_xkbKeymap.get()));
+-            else
+-                m_xkbState.reset(xkb_x11_state_new_from_device(m_xkbKeymap.get(), xcb_connection(), core_device_id));
+-
+-        }
++        if (m_xkbKeymap)
++            m_xkbState.reset(xkb_x11_state_new_from_device(m_xkbKeymap.get(), xcb_connection(), core_device_id));
+     } else {
+         m_xkbKeymap.reset(keymapFromCore(keysymMods));
+         if (m_xkbKeymap)
+@@ -425,8 +411,6 @@ void QXcbKeyboard::updateKeymap()
+     updateXKBMods();
+ 
+     QXkbCommon::verifyHasLatinLayout(m_xkbKeymap.get());
+-
+-    m_config = true;
+ }
+ 
+ QList<int> QXcbKeyboard::possibleKeys(const QKeyEvent *event) const
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
+index b652c85fe3..0ee08aeff2 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
++++ b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
+@@ -69,7 +69,6 @@ public:
+ 
+     Qt::KeyboardModifiers translateModifiers(int s) const;
+     void updateKeymap(xcb_mapping_notify_event_t *event);
+-    void updateKeymap(xcb_xkb_new_keyboard_notify_event_t *event);
+     void updateKeymap();
+     QList<int> possibleKeys(const QKeyEvent *event) const;
+ 
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp b/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
+index ffda7b6a57..863e961f4c 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
+@@ -564,11 +564,6 @@ void QXcbWindow::setGeometry(const QRect &rect)
+ {
+     QPlatformWindow::setGeometry(rect);
+ 
+-    if (shouldDeferTask(Task::SetGeometry)) {
+-        m_deferredGeometry = rect;
+-        return;
+-    }
+-
+     propagateSizeHints();
+ 
+     QXcbScreen *currentScreen = xcbScreen();
+@@ -693,9 +688,6 @@ void QXcbWindow::setVisible(bool visible)
+ 
+ void QXcbWindow::show()
+ {
+-    if (shouldDeferTask(Task::Map))
+-        return;
+-
+     if (window()->isTopLevel()) {
+ 
+         // update WM_NORMAL_HINTS
+@@ -706,7 +698,7 @@ void QXcbWindow::show()
+         if (isTransient(window())) {
+             const QWindow *tp = window()->transientParent();
+             if (tp && tp->handle())
+-                transientXcbParent = static_cast<const QXcbWindow *>(tp->handle())->winId();
++                transientXcbParent = tp->handle()->winId();
+             // Default to client leader if there is no transient parent, else modal dialogs can
+             // be hidden by their parents.
+             if (!transientXcbParent)
+@@ -746,10 +738,6 @@ void QXcbWindow::show()
+ 
+ void QXcbWindow::hide()
+ {
+-    if (shouldDeferTask(Task::Unmap))
+-        return;
+-
+-    m_wmStateValid = false;
+     xcb_unmap_window(xcb_connection(), m_window);
+ 
+     // send synthetic UnmapNotify event according to icccm 4.1.4
+@@ -909,9 +897,6 @@ QXcbWindow::NetWmStates QXcbWindow::netWmStates()
+ 
+ void QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
+ {
+-    if (shouldDeferTask(Task::SetWindowFlags))
+-        return;
+-
+     Qt::WindowType type = static_cast<Qt::WindowType>(int(flags & Qt::WindowType_Mask));
+ 
+     if (type == Qt::ToolTip)
+@@ -941,8 +926,6 @@ void QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
+ 
+     setTransparentForMouseEvents(flags & Qt::WindowTransparentForInput);
+     updateDoesNotAcceptFocus(flags & Qt::WindowDoesNotAcceptFocus);
+-
+-    m_isWmManagedWindow = !(flags & Qt::X11BypassWindowManagerHint);
+ }
+ 
+ void QXcbWindow::setMotifWmHints(Qt::WindowFlags flags)
+@@ -1142,9 +1125,6 @@ void QXcbWindow::setWindowState(Qt::WindowStates state)
+     if (state == m_windowState)
+         return;
+ 
+-    if (shouldDeferTask(Task::SetWindowState))
+-        return;
+-
+     // unset old state
+     if (m_windowState & Qt::WindowMinimized)
+         xcb_map_window(xcb_connection(), m_window);
+@@ -1350,6 +1330,12 @@ void QXcbWindow::setWindowIcon(const QIcon &icon)
+     }
+ 
+     if (!icon_data.isEmpty()) {
++        // Ignore icon exceeding maximum xcb request length
++        if (icon_data.size() > xcb_get_maximum_request_length(xcb_connection())) {
++            qWarning("Ignoring window icon: Size %llu exceeds maximum xcb request length %u.",
++                     icon_data.size(), xcb_get_maximum_request_length(xcb_connection()));
++            return;
++        }
+         xcb_change_property(xcb_connection(),
+                             XCB_PROP_MODE_REPLACE,
+                             m_window,
+@@ -1639,7 +1625,7 @@ void QXcbWindow::setWmWindowType(QXcbWindowFunctions::WmWindowTypes types, Qt::W
+         break;
+     }
+ 
+-    if ((flags & Qt::FramelessWindowHint) && !(type & QXcbWindowFunctions::KdeOverride)) {
++    if ((flags & Qt::FramelessWindowHint) && !(types & QXcbWindowFunctions::KdeOverride)) {
+         // override netwm type - quick and easy for KDE noborder
+         atoms.append(atom(QXcbAtom::_KDE_NET_WM_WINDOW_TYPE_OVERRIDE));
+     }
+@@ -1894,10 +1880,6 @@ void QXcbWindow::handleUnmapNotifyEvent(const xcb_unmap_notify_event_t *event)
+     if (event->window == m_window) {
+         m_mapped = false;
+         QWindowSystemInterface::handleExposeEvent(window(), QRegion());
+-        if (!m_isWmManagedWindow || parent()) {
+-            m_wmStateValid = true;
+-            handleDeferredTasks();
+-        }
+     }
+ }
+ 
+@@ -2212,98 +2194,30 @@ void QXcbWindow::handleLeaveNotifyEvent(const xcb_leave_notify_event_t *event)
+     handleLeaveNotifyEvent(event->root_x, event->root_y, event->mode, event->detail, event->time);
+ }
+ 
+-bool QXcbWindow::shouldDeferTask(Task task)
+-{
+-    if (m_wmStateValid)
+-        return false;
+-
+-    m_deferredTasks.append(task);
+-    return true;
+-}
+-
+-void QXcbWindow::handleDeferredTasks()
+-{
+-    Q_ASSERT(m_wmStateValid == true);
+-    if (m_deferredTasks.isEmpty())
+-        return;
+-
+-    bool map = false;
+-    bool unmap = false;
+-
+-    QVector<Task> tasks;
+-    for (auto taskIt = m_deferredTasks.rbegin(); taskIt != m_deferredTasks.rend(); ++taskIt) {
+-        if (!tasks.contains(*taskIt))
+-            tasks.prepend(*taskIt);
+-    }
+-
+-    for (Task task : tasks) {
+-        switch (task) {
+-        case Task::Map:
+-            map = true;
+-            unmap = false;
+-            break;
+-        case Task::Unmap:
+-            unmap = true;
+-            map = false;
+-            break;
+-        case Task::SetGeometry:
+-            setGeometry(m_deferredGeometry);
+-            break;
+-        case Task::SetWindowFlags:
+-            setWindowFlags(window()->flags());
+-            break;
+-        case Task::SetWindowState:
+-            setWindowState(window()->windowState());
+-            break;
+-        }
+-    }
+-    m_deferredTasks.clear();
+-
+-    if (map) {
+-        Q_ASSERT(unmap == false);
+-        show();
+-    }
+-    if (unmap) {
+-        Q_ASSERT(map == false);
+-        hide();
+-    }
+-}
+-
+ void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *event)
+ {
+     connection()->setTime(event->time);
+ 
+-    const bool wmStateChanged = event->atom == atom(QXcbAtom::WM_STATE);
+-    const bool netWmStateChanged = event->atom == atom(QXcbAtom::_NET_WM_STATE);
+-    if (netWmStateChanged || wmStateChanged) {
+-        if (wmStateChanged && !m_wmStateValid && m_isWmManagedWindow) {
+-            // ICCCM 4.1.4
+-            // Clients that want to re-use a client window (e.g. by mapping it again)
+-            // after withdrawing it must wait for the withdrawal to be complete before
+-            // proceeding. The preferred method for doing this is for clients to wait for
+-            // a window manager to update or remove the WM_STATE property.
+-            m_wmStateValid = true;
+-            handleDeferredTasks();
+-        }
+-        if (event->state == XCB_PROPERTY_DELETE)
++    const bool propertyDeleted = event->state == XCB_PROPERTY_DELETE;
++
++    if (event->atom == atom(QXcbAtom::_NET_WM_STATE) || event->atom == atom(QXcbAtom::WM_STATE)) {
++        if (propertyDeleted)
+             return;
+ 
+-        if (wmStateChanged) {
++        Qt::WindowStates newState = Qt::WindowNoState;
++
++        if (event->atom == atom(QXcbAtom::WM_STATE)) { // WM_STATE: Quick check for 'Minimize'.
+             auto reply = Q_XCB_REPLY(xcb_get_property, xcb_connection(),
+                                      0, m_window, atom(QXcbAtom::WM_STATE),
+                                      XCB_ATOM_ANY, 0, 1024);
+             if (reply && reply->format == 32 && reply->type == atom(QXcbAtom::WM_STATE)) {
+-                auto data = static_cast<const quint32 *>(xcb_get_property_value(reply.get()));
+-                if (reply->length != 0) {
+-                    const bool changedToWithdrawn = data[0] == XCB_ICCCM_WM_STATE_WITHDRAWN;
+-                    const bool changedToIconic = data[0] == XCB_ICCCM_WM_STATE_ICONIC;
+-                    m_minimized = changedToIconic || (changedToWithdrawn && m_minimized);
+-                }
++                const quint32 *data = (const quint32 *)xcb_get_property_value(reply.get());
++                if (reply->length != 0)
++                    m_minimized = (data[0] == XCB_ICCCM_WM_STATE_ICONIC
++                                   || (data[0] == XCB_ICCCM_WM_STATE_WITHDRAWN && m_minimized));
+             }
+         }
+ 
+-        // _NET_WM_STATE handling
+-        Qt::WindowStates newState = Qt::WindowNoState;
+         const NetWmStates states = netWmStates();
+         // _NET_WM_STATE_HIDDEN should be set by the Window Manager to indicate that a window would
+         // not be visible on the screen if its desktop/viewport were active and its coordinates were
+@@ -2325,6 +2239,7 @@ void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *ev
+             if ((m_windowState & Qt::WindowMinimized) && connection()->mouseGrabber() == this)
+                 connection()->setMouseGrabber(nullptr);
+         }
++        return;
+     } else if (event->atom == atom(QXcbAtom::_NET_FRAME_EXTENTS)) {
+         m_dirtyFrameMargins = true;
+     }
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbwindow.h b/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
+index 55af9279b1..6f5c1f5ed9 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
++++ b/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
+@@ -74,14 +74,6 @@ public:
+ 
+     Q_DECLARE_FLAGS(NetWmStates, NetWmState)
+ 
+-    enum Task {
+-        Map,
+-        Unmap,
+-        SetGeometry,
+-        SetWindowFlags,
+-        SetWindowState
+-    };
+-
+     QXcbWindow(QWindow *window);
+     ~QXcbWindow();
+ 
+@@ -151,9 +143,6 @@ public:
+ 
+     QXcbWindow *toWindow() override;
+ 
+-    bool shouldDeferTask(Task task);
+-    void handleDeferredTasks();
+-
+     void handleMouseEvent(xcb_timestamp_t time, const QPoint &local, const QPoint &global,
+                           Qt::KeyboardModifiers modifiers, QEvent::Type type, Qt::MouseEventSource source);
+ 
+@@ -292,11 +281,6 @@ protected:
+     int m_swapInterval = -1;
+ 
+     qreal m_sizeHintsScaleFactor = 1.0;
+-
+-    bool m_wmStateValid = true;
+-    QVector<Task> m_deferredTasks;
+-    bool m_isWmManagedWindow = true;
+-    QRect m_deferredGeometry;
+ };
+ 
+ class QXcbForeignWindow : public QXcbWindow
+diff --git a/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp b/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
+index d9d117faeb..640b49daa0 100644
+--- a/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
++++ b/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
+@@ -85,6 +85,7 @@ QGtk3MenuItem::QGtk3MenuItem()
+       m_checkable(false),
+       m_checked(false),
+       m_enabled(true),
++      m_exclusive(false),
+       m_underline(false),
+       m_invalid(true),
+       m_menu(nullptr),
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
+index 0048bbc1e6..396e7f6d1c 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
+@@ -102,15 +102,12 @@ const QDBusArgument &operator >>(const QDBusArgument &arg, QXdgDesktopPortalFile
+ class QXdgDesktopPortalFileDialogPrivate
+ {
+ public:
+-    QXdgDesktopPortalFileDialogPrivate(QPlatformFileDialogHelper *nativeFileDialog)
++    QXdgDesktopPortalFileDialogPrivate(QPlatformFileDialogHelper *nativeFileDialog, uint fileChooserPortalVersion)
+         : nativeFileDialog(nativeFileDialog)
++        , fileChooserPortalVersion(fileChooserPortalVersion)
+     { }
+ 
+-    WId winId = 0;
+-    bool directoryMode = false;
+-    bool modal = false;
+-    bool multipleFiles = false;
+-    bool saveFile = false;
++    QEventLoop loop;
+     QString acceptLabel;
+     QString directory;
+     QString title;
+@@ -121,19 +118,27 @@ public:
+     QString selectedMimeTypeFilter;
+     QString selectedNameFilter;
+     QStringList selectedFiles;
+-    QPlatformFileDialogHelper *nativeFileDialog = nullptr;
++    std::unique_ptr<QPlatformFileDialogHelper> nativeFileDialog;
++    uint fileChooserPortalVersion = 0;
++    bool failedToOpen = false;
++    bool directoryMode = false;
++    bool multipleFiles = false;
++    bool saveFile = false;
+ };
+ 
+-QXdgDesktopPortalFileDialog::QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog)
++QXdgDesktopPortalFileDialog::QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog, uint fileChooserPortalVersion)
+     : QPlatformFileDialogHelper()
+-    , d_ptr(new QXdgDesktopPortalFileDialogPrivate(nativeFileDialog))
++    , d_ptr(new QXdgDesktopPortalFileDialogPrivate(nativeFileDialog, fileChooserPortalVersion))
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+     if (d->nativeFileDialog) {
+-        connect(d->nativeFileDialog, SIGNAL(accept()), this, SIGNAL(accept()));
+-        connect(d->nativeFileDialog, SIGNAL(reject()), this, SIGNAL(reject()));
++        connect(d->nativeFileDialog.get(), SIGNAL(accept()), this, SIGNAL(accept()));
++        connect(d->nativeFileDialog.get(), SIGNAL(reject()), this, SIGNAL(reject()));
+     }
++
++    d->loop.connect(this, SIGNAL(accept()), SLOT(quit()));
++    d->loop.connect(this, SIGNAL(reject()), SLOT(quit()));
+ }
+ 
+ QXdgDesktopPortalFileDialog::~QXdgDesktopPortalFileDialog()
+@@ -177,7 +182,7 @@ void QXdgDesktopPortalFileDialog::initializeDialog()
+     setDirectory(options()->initialDirectory());
+ }
+ 
+-void QXdgDesktopPortalFileDialog::openPortal()
++void QXdgDesktopPortalFileDialog::openPortal(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent)
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+@@ -185,13 +190,13 @@ void QXdgDesktopPortalFileDialog::openPortal()
+                                                           QLatin1String("/org/freedesktop/portal/desktop"),
+                                                           QLatin1String("org.freedesktop.portal.FileChooser"),
+                                                           d->saveFile ? QLatin1String("SaveFile") : QLatin1String("OpenFile"));
+-    QString parentWindowId = QLatin1String("x11:") + QString::number(d->winId, 16);
++    QString parentWindowId = QLatin1String("x11:") + QString::number(parent ? parent->winId() : 0, 16);
+ 
+     QVariantMap options;
+     if (!d->acceptLabel.isEmpty())
+         options.insert(QLatin1String("accept_label"), d->acceptLabel);
+ 
+-    options.insert(QLatin1String("modal"), d->modal);
++    options.insert(QLatin1String("modal"), windowModality != Qt::NonModal);
+     options.insert(QLatin1String("multiple"), d->multipleFiles);
+     options.insert(QLatin1String("directory"), d->directoryMode);
+ 
+@@ -290,10 +295,18 @@ void QXdgDesktopPortalFileDialog::openPortal()
+ 
+     QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
+     QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingCall);
+-    connect(watcher, &QDBusPendingCallWatcher::finished, this, [this] (QDBusPendingCallWatcher *watcher) {
++    connect(watcher, &QDBusPendingCallWatcher::finished, this, [=] (QDBusPendingCallWatcher *watcher) {
+         QDBusPendingReply<QDBusObjectPath> reply = *watcher;
+-        if (reply.isError()) {
+-            Q_EMIT reject();
++        // Any error means the dialog is not shown and we need to fallback
++        d->failedToOpen = reply.isError();
++        if (d->failedToOpen) {
++            if (d->nativeFileDialog) {
++                d->nativeFileDialog->show(windowFlags, windowModality, parent);
++                if (d->loop.isRunning())
++                    d->nativeFileDialog->exec();
++            } else {
++                Q_EMIT reject();
++            }
+         } else {
+             QDBusConnection::sessionBus().connect(nullptr,
+                                                   reply.value().path(),
+@@ -302,6 +315,7 @@ void QXdgDesktopPortalFileDialog::openPortal()
+                                                   this,
+                                                   SLOT(gotResponse(uint,QVariantMap)));
+         }
++        watcher->deleteLater();
+     });
+ }
+ 
+@@ -326,7 +340,7 @@ QUrl QXdgDesktopPortalFileDialog::directory() const
+ {
+     Q_D(const QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog())
+         return d->nativeFileDialog->directory();
+ 
+     return d->directory;
+@@ -348,7 +362,7 @@ QList<QUrl> QXdgDesktopPortalFileDialog::selectedFiles() const
+ {
+     Q_D(const QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog())
+         return d->nativeFileDialog->selectedFiles();
+ 
+     QList<QUrl> files;
+@@ -403,16 +417,13 @@ void QXdgDesktopPortalFileDialog::exec()
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly)) {
++    if (d->nativeFileDialog && useNativeFileDialog()) {
+         d->nativeFileDialog->exec();
+         return;
+     }
+ 
+     // HACK we have to avoid returning until we emit that the dialog was accepted or rejected
+-    QEventLoop loop;
+-    loop.connect(this, SIGNAL(accept()), SLOT(quit()));
+-    loop.connect(this, SIGNAL(reject()), SLOT(quit()));
+-    loop.exec();
++    d->loop.exec();
+ }
+ 
+ void QXdgDesktopPortalFileDialog::hide()
+@@ -429,13 +440,10 @@ bool QXdgDesktopPortalFileDialog::show(Qt::WindowFlags windowFlags, Qt::WindowMo
+ 
+     initializeDialog();
+ 
+-    d->modal = windowModality != Qt::NonModal;
+-    d->winId = parent ? parent->winId() : 0;
+-
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog(OpenFallback))
+         return d->nativeFileDialog->show(windowFlags, windowModality, parent);
+ 
+-    openPortal();
++    openPortal(windowFlags, windowModality, parent);
+ 
+     return true;
+ }
+@@ -465,4 +473,21 @@ void QXdgDesktopPortalFileDialog::gotResponse(uint response, const QVariantMap &
+     }
+ }
+ 
++bool QXdgDesktopPortalFileDialog::useNativeFileDialog(QXdgDesktopPortalFileDialog::FallbackType fallbackType) const
++{
++    Q_D(const QXdgDesktopPortalFileDialog);
++
++    if (d->failedToOpen && fallbackType != OpenFallback)
++        return true;
++
++    if (d->fileChooserPortalVersion < 3) {
++        if (options()->fileMode() == QFileDialogOptions::Directory)
++            return true;
++        else if (options()->fileMode() == QFileDialogOptions::DirectoryOnly)
++            return true;
++    }
++
++    return false;
++}
++
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
+index 4f4de96ecf..65e22a5cf2 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
+@@ -51,6 +51,11 @@ class QXdgDesktopPortalFileDialog : public QPlatformFileDialogHelper
+     Q_OBJECT
+     Q_DECLARE_PRIVATE(QXdgDesktopPortalFileDialog)
+ public:
++    enum FallbackType {
++        GenericFallback,
++        OpenFallback
++    };
++
+     enum ConditionType : uint {
+         GlobalPattern = 0,
+         MimeType = 1
+@@ -69,7 +74,7 @@ public:
+     };
+     typedef QVector<Filter> FilterList;
+ 
+-    QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog = nullptr);
++    QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog = nullptr, uint fileChooserPortalVersion = 0);
+     ~QXdgDesktopPortalFileDialog();
+ 
+     bool defaultNameFilterDisables() const override;
+@@ -92,7 +97,8 @@ private Q_SLOTS:
+ 
+ private:
+     void initializeDialog();
+-    void openPortal();
++    void openPortal(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent);
++    bool useNativeFileDialog(FallbackType fallbackType = GenericFallback) const;
+ 
+     QScopedPointer<QXdgDesktopPortalFileDialogPrivate> d_ptr;
+ };
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
+index fb324afbd8..b809503122 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
+@@ -111,6 +111,7 @@ QXdgDesktopPortalTheme::QXdgDesktopPortalTheme()
+         if (reply.isValid()) {
+             d->fileChooserPortalVersion = reply.value().toUInt();
+         }
++        watcher->deleteLater();
+     });
+ }
+ 
+@@ -152,11 +153,12 @@ QPlatformDialogHelper* QXdgDesktopPortalTheme::createPlatformDialogHelper(Dialog
+ {
+     Q_D(const QXdgDesktopPortalTheme);
+ 
+-    if (type == FileDialog) {
++    if (type == FileDialog && d->fileChooserPortalVersion) {
+         // Older versions of FileChooser portal don't support opening directories, therefore we fallback
+         // to native file dialog opened inside the sandbox to open a directory.
+-        if (d->fileChooserPortalVersion < 3 && d->baseTheme->usePlatformNativeDialog(type))
+-            return new QXdgDesktopPortalFileDialog(static_cast<QPlatformFileDialogHelper*>(d->baseTheme->createPlatformDialogHelper(type)));
++        if (d->baseTheme->usePlatformNativeDialog(type))
++            return new QXdgDesktopPortalFileDialog(static_cast<QPlatformFileDialogHelper*>(d->baseTheme->createPlatformDialogHelper(type)),
++                                                   d->fileChooserPortalVersion);
+ 
+         return new QXdgDesktopPortalFileDialog;
+     }
+diff --git a/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp b/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
+index 43d5e119ad..1f9cbc4565 100644
+--- a/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
++++ b/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
+@@ -89,8 +89,10 @@ void QCupsPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &v
+         break;
+     case PPK_Duplex: {
+         QPrint::DuplexMode mode = QPrint::DuplexMode(value.toInt());
+-        if (mode != d->duplex && d->m_printDevice.supportedDuplexModes().contains(mode))
++        if (d->m_printDevice.supportedDuplexModes().contains(mode)) {
+             d->duplex = mode;
++            d->duplexRequestedExplicitly = true;
++        }
+         break;
+     }
+     case PPK_PrinterName:
+@@ -277,9 +279,12 @@ void QCupsPrintEnginePrivate::changePrinter(const QString &newPrinter)
+     m_printDevice.swap(printDevice);
+     printerName = m_printDevice.id();
+ 
+-    // Check if new printer supports current settings, otherwise us defaults
+-    if (duplex != QPrint::DuplexAuto && !m_printDevice.supportedDuplexModes().contains(duplex))
++    // in case a duplex value was explicitly set, check if new printer supports current value,
++    // otherwise use device default
++    if (!duplexRequestedExplicitly || !m_printDevice.supportedDuplexModes().contains(duplex)) {
+         duplex = m_printDevice.defaultDuplexMode();
++        duplexRequestedExplicitly = false;
++    }
+     QPrint::ColorMode colorMode = grayscale ? QPrint::GrayScale : QPrint::Color;
+     if (!m_printDevice.supportedColorModes().contains(colorMode))
+         grayscale = m_printDevice.defaultColorMode() == QPrint::GrayScale;
+diff --git a/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h b/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
+index c021b0c643..8f81fe478d 100644
+--- a/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
++++ b/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
+@@ -100,6 +100,7 @@ private:
+     QStringList cupsOptions;
+     QString cupsTempFile;
+     QPrint::DuplexMode duplex;
++    bool duplexRequestedExplicitly = false;
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp b/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
+index 67e7154fa6..40876152e5 100644
+--- a/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
++++ b/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
+@@ -817,7 +817,7 @@ bool QIBaseResultPrivate::writeArray(int column, const QList<QVariant> &list)
+     ba.resize(int(bufLen));
+ 
+     if (list.size() > arraySize) {
+-        error = QLatin1String("Array size missmatch: size of %1 is %2, size of provided list is %3");
++        error = QLatin1String("Array size mismatch: size of %1 is %2, size of provided list is %3");
+         error = error.arg(QLatin1String(sqlname)).arg(arraySize).arg(list.size());
+         q->setLastError(QSqlError(error, QLatin1String(""), QSqlError::StatementError));
+         return false;
+diff --git a/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp b/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
+index 7ca055eea2..6bc9d46755 100644
+--- a/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
++++ b/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
+@@ -223,7 +223,7 @@ public:
+     struct QMyField
+     {
+         char *outField = nullptr;
+-        MYSQL_FIELD *myField = nullptr;
++        const MYSQL_FIELD *myField = nullptr;
+         QMetaType::Type type = QMetaType::UnknownType;
+         my_bool nullIndicator = false;
+         ulong bufLength = 0ul;
+@@ -361,7 +361,7 @@ static bool qIsInteger(int t)
+ void QMYSQLResultPrivate::bindBlobs()
+ {
+     int i;
+-    MYSQL_FIELD *fieldInfo;
++    const MYSQL_FIELD *fieldInfo;
+     MYSQL_BIND *bind;
+ 
+     for(i = 0; i < fields.count(); ++i) {
+@@ -379,7 +379,6 @@ void QMYSQLResultPrivate::bindBlobs()
+ bool QMYSQLResultPrivate::bindInValues()
+ {
+     MYSQL_BIND *bind;
+-    char *field;
+     int i = 0;
+ 
+     if (!meta)
+@@ -392,35 +391,34 @@ bool QMYSQLResultPrivate::bindInValues()
+     inBinds = new MYSQL_BIND[fields.size()];
+     memset(inBinds, 0, fields.size() * sizeof(MYSQL_BIND));
+ 
+-    MYSQL_FIELD *fieldInfo;
++    const MYSQL_FIELD *fieldInfo;
+ 
+     while((fieldInfo = mysql_fetch_field(meta))) {
++        bind = &inBinds[i];
++
+         QMyField &f = fields[i];
+         f.myField = fieldInfo;
+-
++        bind->buffer_length = f.bufLength = fieldInfo->length + 1;
++        bind->buffer_type = fieldInfo->type;
+         f.type = qDecodeMYSQLType(fieldInfo->type, fieldInfo->flags);
+         if (qIsBlob(fieldInfo->type)) {
+             // the size of a blob-field is available as soon as we call
+             // mysql_stmt_store_result()
+             // after mysql_stmt_exec() in QMYSQLResult::exec()
+-            fieldInfo->length = 0;
++            bind->buffer_length = f.bufLength = 0;
+             hasBlobs = true;
+         } else if (qIsInteger(f.type)) {
+-            fieldInfo->length = 8;
++            bind->buffer_length = f.bufLength = 8;
+         } else {
+-            fieldInfo->type = MYSQL_TYPE_STRING;
++            bind->buffer_type = MYSQL_TYPE_STRING;
+         }
+-        bind = &inBinds[i];
+-        field = new char[fieldInfo->length + 1];
+-        memset(field, 0, fieldInfo->length + 1);
+ 
+-        bind->buffer_type = fieldInfo->type;
+-        bind->buffer = field;
+-        bind->buffer_length = f.bufLength = fieldInfo->length + 1;
+         bind->is_null = &f.nullIndicator;
+         bind->length = &f.bufLength;
+         bind->is_unsigned = fieldInfo->flags & UNSIGNED_FLAG ? 1 : 0;
+-        f.outField=field;
++
++        char *field = new char[bind->buffer_length + 1]{};
++        bind->buffer = f.outField = field;
+ 
+         ++i;
+     }
+@@ -1369,20 +1367,20 @@ bool QMYSQLDriver::open(const QString& db,
+     }
+ 
+ #if MYSQL_VERSION_ID >= 50007
+-    if (mysql_get_client_version() >= 50503 && mysql_get_server_version(d->mysql) >= 50503) {
+-        // force the communication to be utf8mb4 (only utf8mb4 supports 4-byte characters)
+-        mysql_set_character_set(d->mysql, "utf8mb4");
++    // force the communication to be utf8mb4 (only utf8mb4 supports 4-byte characters)
++    if (mysql_set_character_set(d->mysql, "utf8mb4")) {
++        // this failed, try forcing it to utf (BMP only)
++        if (mysql_set_character_set(d->mysql, "utf8"))
++            qWarning() << "MySQL: Unable to set the client character set to utf8.";
+ #if QT_CONFIG(textcodec)
+-        d->tc = QTextCodec::codecForName("UTF-8");
++        else
++            d->tc = codec(d->mysql);
+ #endif
+-    } else
+-    {
+-        // force the communication to be utf8
+-        mysql_set_character_set(d->mysql, "utf8");
++    }
+ #if QT_CONFIG(textcodec)
+-        d->tc = codec(d->mysql);
++    else
++        d->tc = QTextCodec::codecForName("UTF-8");
+ #endif
+-    }
+ #endif  // MYSQL_VERSION_ID >= 50007
+ 
+     d->preparedQuerysEnabled = checkPreparedQueries(d->mysql);
+diff --git a/qtbase/src/printsupport/dialogs/images/print-24.png b/qtbase/src/printsupport/dialogs/images/printer-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/print-24.png
+rename to src/printsupport/dialogs/images/printer-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/print-32.png b/qtbase/src/printsupport/dialogs/images/printer-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/print-32.png
+rename to src/printsupport/dialogs/images/printer-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-sided-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-facing-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-sided-24.png
+rename to src/printsupport/dialogs/images/view-pages-facing-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-sided-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-facing-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-sided-32.png
+rename to src/printsupport/dialogs/images/view-pages-facing-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-multi-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-overview-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-multi-24.png
+rename to src/printsupport/dialogs/images/view-pages-overview-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-multi-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-overview-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-multi-32.png
+rename to src/printsupport/dialogs/images/view-pages-overview-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-one-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-single-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-one-24.png
+rename to src/printsupport/dialogs/images/view-pages-single-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-one-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-single-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-one-32.png
+rename to src/printsupport/dialogs/images/view-pages-single-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-page-24.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-page-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-page-24.png
+rename to src/printsupport/dialogs/images/zoom-fit-page-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-page-32.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-page-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-page-32.png
+rename to src/printsupport/dialogs/images/zoom-fit-page-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-width-24.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-width-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-width-24.png
+rename to src/printsupport/dialogs/images/zoom-fit-width-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-width-32.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-width-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-width-32.png
+rename to src/printsupport/dialogs/images/zoom-fit-width-32.png
+diff --git a/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp b/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
+index 78e5b8d1ef..2a28516719 100644
+--- a/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
++++ b/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
+@@ -532,6 +532,7 @@ void QPageSetupWidget::updateWidget()
+ void QPageSetupWidget::setupPrinter() const
+ {
+     m_printer->setPageLayout(m_pageLayout);
++    m_printer->setPageOrientation(m_pageLayout.orientation());
+ #if QT_CONFIG(cups)
+     QCUPSSupport::PagesPerSheet pagesPerSheet = qvariant_cast<QCUPSSupport::PagesPerSheet>(m_ui.pagesPerSheetCombo->currentData()
+ );
+diff --git a/qtbase/src/printsupport/dialogs/qprintdialog.qrc b/qtbase/src/printsupport/dialogs/qprintdialog.qrc
+index 5a579baa55..10b8e1d341 100644
+--- a/qtbase/src/printsupport/dialogs/qprintdialog.qrc
++++ b/qtbase/src/printsupport/dialogs/qprintdialog.qrc
+@@ -1,9 +1,9 @@
+ <!DOCTYPE RCC><RCC version="1.0">
+ <qresource prefix="/qt-project.org/dialogs/qprintpreviewdialog">
+-<file>images/fit-page-24.png</file>
+-<file>images/fit-page-32.png</file>
+-<file>images/fit-width-24.png</file>
+-<file>images/fit-width-32.png</file>
++<file>images/zoom-fit-page-24.png</file>
++<file>images/zoom-fit-page-32.png</file>
++<file>images/zoom-fit-width-24.png</file>
++<file>images/zoom-fit-width-32.png</file>
+ <file>images/go-first-24.png</file>
+ <file>images/go-first-32.png</file>
+ <file>images/go-last-24.png</file>
+@@ -18,14 +18,14 @@
+ <file>images/layout-portrait-32.png</file>
+ <file>images/page-setup-24.png</file>
+ <file>images/page-setup-32.png</file>
+-<file>images/print-24.png</file>
+-<file>images/print-32.png</file>
+-<file>images/view-page-multi-24.png</file>
+-<file>images/view-page-multi-32.png</file>
+-<file>images/view-page-one-24.png</file>
+-<file>images/view-page-one-32.png</file>
+-<file>images/view-page-sided-24.png</file>
+-<file>images/view-page-sided-32.png</file>
++<file>images/printer-24.png</file>
++<file>images/printer-32.png</file>
++<file>images/view-pages-overview-24.png</file>
++<file>images/view-pages-overview-32.png</file>
++<file>images/view-pages-single-24.png</file>
++<file>images/view-pages-single-32.png</file>
++<file>images/view-pages-facing-24.png</file>
++<file>images/view-pages-facing-32.png</file>
+ <file>images/zoom-in-24.png</file>
+ <file>images/zoom-in-32.png</file>
+ <file>images/zoom-out-24.png</file>
+diff --git a/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp b/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
+index c5b845f4ec..5a5ba1d0a8 100644
+--- a/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
++++ b/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
+@@ -702,13 +702,14 @@ void QPrintDialogPrivate::selectPrinter(const QPrinter::OutputFormat outputForma
+         else
+             options.grayscale->setChecked(true);
+ 
+-        // keep duplex value explicitly set by user, if any, and selected printer supports it;
+-        // use device default otherwise
++        // duplex priorities to be as follows:
++        // 1) a user-selected duplex value in the dialog has highest prority
++        // 2) duplex value set in the QPrinter
+         QPrint::DuplexMode duplex;
+         if (explicitDuplexMode != QPrint::DuplexAuto && supportedDuplexMode.contains(explicitDuplexMode))
+             duplex = explicitDuplexMode;
+         else
+-            duplex = top->d->m_currentPrintDevice.defaultDuplexMode();
++            duplex = static_cast<QPrint::DuplexMode>(p->duplex());
+         switch (duplex) {
+         case QPrint::DuplexNone:
+             options.noDuplex->setChecked(true); break;
+@@ -1242,10 +1243,10 @@ void QUnixPrintWidgetPrivate::_q_printerChanged(int index)
+             QString filename = widget.filename->text();
+             widget.filename->setText(filename);
+             widget.lOutput->setEnabled(true);
+-            if (optionsPane)
+-                optionsPane->selectPrinter(QPrinter::PdfFormat);
+             printer->setOutputFormat(QPrinter::PdfFormat);
+             m_currentPrintDevice = QPrintDevice();
++            if (optionsPane)
++                optionsPane->selectPrinter(QPrinter::PdfFormat);
+             return;
+         }
+     }
+diff --git a/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp b/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
+index 39575d5f57..23b7e89538 100644
+--- a/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
++++ b/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
+@@ -352,7 +352,7 @@ void QPrintPreviewDialogPrivate::init(QPrinter *_printer)
+ static inline void qt_setupActionIcon(QAction *action, QLatin1String name)
+ {
+     QLatin1String imagePrefix(":/qt-project.org/dialogs/qprintpreviewdialog/images/");
+-    QIcon icon;
++    QIcon icon = QIcon::fromTheme(name);
+     icon.addFile(imagePrefix + name + QLatin1String("-24.png"), QSize(24, 24));
+     icon.addFile(imagePrefix + name + QLatin1String("-32.png"), QSize(32, 32));
+     action->setIcon(icon);
+@@ -383,8 +383,8 @@ void QPrintPreviewDialogPrivate::setupActions()
+     fitPageAction->setObjectName(QLatin1String("fitPageAction"));
+     fitWidthAction->setCheckable(true);
+     fitPageAction->setCheckable(true);
+-    qt_setupActionIcon(fitWidthAction, QLatin1String("fit-width"));
+-    qt_setupActionIcon(fitPageAction, QLatin1String("fit-page"));
++    qt_setupActionIcon(fitWidthAction, QLatin1String("zoom-fit-width"));
++    qt_setupActionIcon(fitPageAction, QLatin1String("zoom-fit-page"));
+     QObject::connect(fitGroup, SIGNAL(triggered(QAction*)), q, SLOT(_q_fit(QAction*)));
+ 
+     // Zoom
+@@ -410,9 +410,9 @@ void QPrintPreviewDialogPrivate::setupActions()
+     singleModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show single page"));
+     facingModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show facing pages"));
+     overviewModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show overview of all pages"));
+-    qt_setupActionIcon(singleModeAction, QLatin1String("view-page-one"));
+-    qt_setupActionIcon(facingModeAction, QLatin1String("view-page-sided"));
+-    qt_setupActionIcon(overviewModeAction, QLatin1String("view-page-multi"));
++    qt_setupActionIcon(singleModeAction, QLatin1String("view-pages-single"));
++    qt_setupActionIcon(facingModeAction, QLatin1String("view-pages-facing"));
++    qt_setupActionIcon(overviewModeAction, QLatin1String("view-pages-overview"));
+     singleModeAction->setObjectName(QLatin1String("singleModeAction"));
+     facingModeAction->setObjectName(QLatin1String("facingModeAction"));
+     overviewModeAction->setObjectName(QLatin1String("overviewModeAction"));
+@@ -426,7 +426,7 @@ void QPrintPreviewDialogPrivate::setupActions()
+     printerGroup = new QActionGroup(q);
+     printAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Print"));
+     pageSetupAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Page setup"));
+-    qt_setupActionIcon(printAction, QLatin1String("print"));
++    qt_setupActionIcon(printAction, QLatin1String("printer"));
+     qt_setupActionIcon(pageSetupAction, QLatin1String("page-setup"));
+     QObject::connect(printAction, SIGNAL(triggered(bool)), q, SLOT(_q_print()));
+     QObject::connect(pageSetupAction, SIGNAL(triggered(bool)), q, SLOT(_q_pageSetup()));
+diff --git a/qtbase/src/sql/kernel/qsqlquery.cpp b/qtbase/src/sql/kernel/qsqlquery.cpp
+index 32c6166c79..60afef10c3 100644
+--- a/qtbase/src/sql/kernel/qsqlquery.cpp
++++ b/qtbase/src/sql/kernel/qsqlquery.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2022 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtSql module of the Qt Toolkit.
+@@ -377,6 +377,10 @@ bool QSqlQuery::exec(const QString& query)
+     QElapsedTimer t;
+     t.start();
+ #endif
++    if (!driver()) {
++        qWarning("QSqlQuery::exec: called before driver has been set up");
++        return false;
++    }
+     if (d->ref.loadRelaxed() != 1) {
+         bool fo = isForwardOnly();
+         *this = QSqlQuery(driver()->createResult());
+diff --git a/qtbase/src/testlib/qabstractitemmodeltester.cpp b/qtbase/src/testlib/qabstractitemmodeltester.cpp
+index 8efb9c53d4..ce062f66d7 100644
+--- a/qtbase/src/testlib/qabstractitemmodeltester.cpp
++++ b/qtbase/src/testlib/qabstractitemmodeltester.cpp
+@@ -454,7 +454,7 @@ void QAbstractItemModelTesterPrivate::parent()
+ 
+     // Common error test #2, make sure that a second level index has a parent
+     // that is the first level index.
+-    if (model->rowCount(topIndex) > 0) {
++    if (model->rowCount(topIndex) > 0 && model->columnCount(topIndex) > 0) {
+         QModelIndex childIndex = model->index(0, 0, topIndex);
+         MODELTESTER_VERIFY(childIndex.isValid());
+         MODELTESTER_COMPARE(model->parent(childIndex), topIndex);
+diff --git a/qtbase/src/testlib/qasciikey.cpp b/qtbase/src/testlib/qasciikey.cpp
+index 9a308da2bc..93498b256f 100644
+--- a/qtbase/src/testlib/qasciikey.cpp
++++ b/qtbase/src/testlib/qasciikey.cpp
+@@ -498,6 +498,11 @@ char QTest::keyToAscii(Qt::Key key)
+     case Qt::Key_LaunchE : return 0; // = 0x10b0,
+     case Qt::Key_LaunchF : return 0; // = 0x10b1,
+ 
++    // Keypad navigation keys
++    case Qt::Key_Select : return 0; // = 0x01010000
++    case Qt::Key_Yes : return 0; // = 0x01010001
++    case Qt::Key_No : return 0; // = 0x01010002
++
+     default: QTEST_ASSERT(false); return 0;
+     }
+ }
+diff --git a/qtbase/src/testlib/qtestresult.cpp b/qtbase/src/testlib/qtestresult.cpp
+index 88028aac6e..2e89930776 100644
+--- a/qtbase/src/testlib/qtestresult.cpp
++++ b/qtbase/src/testlib/qtestresult.cpp
+@@ -251,7 +251,8 @@ bool QTestResult::verify(bool statement, const char *statementStr,
+ {
+     QTEST_ASSERT(statementStr);
+ 
+-    char msg[1024] = {'\0'};
++    char msg[1024];
++    msg[0] = '\0';
+ 
+     if (QTestLog::verboseLevel() >= 2) {
+         qsnprintf(msg, 1024, "QVERIFY(%s)", statementStr);
+@@ -309,7 +310,8 @@ static bool compareHelper(bool success, const char *failureMsg,
+                           bool hasValues = true)
+ {
+     const size_t maxMsgLen = 1024;
+-    char msg[maxMsgLen] = {'\0'};
++    char msg[maxMsgLen];
++    msg[0] = '\0';
+ 
+     QTEST_ASSERT(expected);
+     QTEST_ASSERT(actual);
+diff --git a/qtbase/src/widgets/dialogs/qcolordialog.cpp b/qtbase/src/widgets/dialogs/qcolordialog.cpp
+index 4247731275..cb325be85c 100644
+--- a/qtbase/src/widgets/dialogs/qcolordialog.cpp
++++ b/qtbase/src/widgets/dialogs/qcolordialog.cpp
+@@ -78,7 +78,10 @@
+ #include "qwindow.h"
+ 
+ #include "private/qdialog_p.h"
++#include "private/qguiapplication_p.h"
+ 
++#include <qpa/qplatformservices.h>
++#include <qpa/qplatformintegration.h>
+ #include <algorithm>
+ 
+ QT_BEGIN_NAMESPACE
+@@ -1611,6 +1614,20 @@ void QColorDialogPrivate::_q_newStandard(int r, int c)
+ void QColorDialogPrivate::_q_pickScreenColor()
+ {
+     Q_Q(QColorDialog);
++
++    auto *platformServices = QGuiApplicationPrivate::platformIntegration()->services();
++    if (platformServices->hasCapability(QPlatformServices::Capability::ColorPicking)) {
++        if (auto *colorPicker = platformServices->colorPicker(q->windowHandle())) {
++            q->connect(colorPicker, &QPlatformServiceColorPicker::colorPicked, q,
++                       [q, colorPicker](const QColor &color) {
++                           colorPicker->deleteLater();
++                           q->setCurrentColor(color);
++                       });
++            colorPicker->pickColor();
++            return;
++        }
++    }
++
+     if (!colorPickingEventFilter)
+         colorPickingEventFilter = new QColorPickingEventFilter(this, q);
+     q->installEventFilter(colorPickingEventFilter);
+diff --git a/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp b/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
+index e120817edc..8ea36b5427 100644
+--- a/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
++++ b/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
+@@ -400,12 +400,7 @@ bool QAbstractItemDelegate::helpEvent(QHelpEvent *event,
+         const QString tooltip = index.isValid() ?
+               d->textForRole(Qt::ToolTipRole, index.data(Qt::ToolTipRole), option.locale, precision) :
+               QString();
+-        QRect rect;
+-        if (index.isValid()) {
+-            const QRect r = view->visualRect(index);
+-            rect = QRect(view->mapToGlobal(r.topLeft()), r.size());
+-        }
+-        QToolTip::showText(he->globalPos(), tooltip, view, rect);
++        QToolTip::showText(he->globalPos(), tooltip, view->viewport(), option.rect);
+         event->setAccepted(!tooltip.isEmpty());
+         break;
+         }
+diff --git a/qtbase/src/widgets/itemviews/qlistview.cpp b/qtbase/src/widgets/itemviews/qlistview.cpp
+index 2b34476642..eebfaa030e 100644
+--- a/qtbase/src/widgets/itemviews/qlistview.cpp
++++ b/qtbase/src/widgets/itemviews/qlistview.cpp
+@@ -3386,6 +3386,7 @@ void QIconModeViewBase::updateContentsSize()
+ */
+ void QListView::currentChanged(const QModelIndex &current, const QModelIndex &previous)
+ {
++    QAbstractItemView::currentChanged(current, previous);
+ #ifndef QT_NO_ACCESSIBILITY
+     if (QAccessible::isActive()) {
+         if (current.isValid()) {
+@@ -3396,7 +3397,6 @@ void QListView::currentChanged(const QModelIndex &current, const QModelIndex &pr
+         }
+     }
+ #endif
+-    QAbstractItemView::currentChanged(current, previous);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/widgets/itemviews/qtableview.cpp b/qtbase/src/widgets/itemviews/qtableview.cpp
+index 934ac581b2..f79bb24249 100644
+--- a/qtbase/src/widgets/itemviews/qtableview.cpp
++++ b/qtbase/src/widgets/itemviews/qtableview.cpp
+@@ -1013,6 +1013,7 @@ void QTableViewPrivate::drawCell(QPainter *painter, const QStyleOptionViewItem &
+ int QTableViewPrivate::widthHintForIndex(const QModelIndex &index, int hint, const QStyleOptionViewItem &option) const
+ {
+     Q_Q(const QTableView);
++    const int oldHint = hint;
+     QWidget *editor = editorForIndex(index).widget.data();
+     if (editor && persistent.contains(editor)) {
+         hint = qMax(hint, editor->sizeHint().width());
+@@ -1021,6 +1022,17 @@ int QTableViewPrivate::widthHintForIndex(const QModelIndex &index, int hint, con
+         hint = qBound(min, hint, max);
+     }
+     hint = qMax(hint, q->itemDelegate(index)->sizeHint(option, index).width());
++
++    if (hasSpans()) {
++        auto span = spans.spanAt(index.column(), index.row());
++        if (span && span->m_left == index.column() && span->m_top == index.row()) {
++            // spans are screwed up when sections are moved
++            const auto left = logicalColumn(span->m_left);
++            for (int i = 1; i <= span->width(); ++i)
++               hint -= q->columnWidth(visualColumn(left + i));
++        }
++        hint = std::max(hint, oldHint);
++    }
+     return hint;
+ }
+ 
+@@ -1053,6 +1065,11 @@ int QTableViewPrivate::heightHintForIndex(const QModelIndex &index, int hint, QS
+         option.rect.setHeight(height);
+         option.rect.setX(q->columnViewportPosition(index.column()));
+         option.rect.setWidth(q->columnWidth(index.column()));
++        if (hasSpans()) {
++            auto span = spans.spanAt(index.column(), index.row());
++            if (span && span->m_left == index.column() && span->m_top == index.row())
++                option.rect.setWidth(std::max(option.rect.width(), visualSpanRect(*span).width()));
++        }
+         // 1px less space when grid is shown (see drawCell)
+         if (showGrid)
+             option.rect.setWidth(option.rect.width() - 1);
+diff --git a/qtbase/src/widgets/kernel/qaction.h b/qtbase/src/widgets/kernel/qaction.h
+index 258a1ea0a0..737c1e8285 100644
+--- a/qtbase/src/widgets/kernel/qaction.h
++++ b/qtbase/src/widgets/kernel/qaction.h
+@@ -81,7 +81,7 @@ class Q_WIDGETS_EXPORT QAction : public QObject
+     Q_PROPERTY(MenuRole menuRole READ menuRole WRITE setMenuRole NOTIFY changed)
+     Q_PROPERTY(bool iconVisibleInMenu READ isIconVisibleInMenu WRITE setIconVisibleInMenu NOTIFY changed)
+     Q_PROPERTY(bool shortcutVisibleInContextMenu READ isShortcutVisibleInContextMenu WRITE setShortcutVisibleInContextMenu NOTIFY changed)
+-    Q_PROPERTY(Priority priority READ priority WRITE setPriority)
++    Q_PROPERTY(Priority priority READ priority WRITE setPriority NOTIFY changed)
+ 
+ public:
+     // note this is copied into qplatformmenu.h, which must stay in sync
+diff --git a/qtbase/src/widgets/kernel/qwidget.cpp b/qtbase/src/widgets/kernel/qwidget.cpp
+index 9eba1e001e..26f6d27e18 100644
+--- a/qtbase/src/widgets/kernel/qwidget.cpp
++++ b/qtbase/src/widgets/kernel/qwidget.cpp
+@@ -5296,7 +5296,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
+         QWidgetEffectSourcePrivate *sourced = static_cast<QWidgetEffectSourcePrivate *>
+                                                          (source->d_func());
+         if (!sourced->context) {
+-            const QRegion effectRgn(rgn.boundingRect());
++            const QRegion effectRgn((flags & UseEffectRegionBounds) ? rgn.boundingRect() : rgn);
+             QWidgetPaintContext context(pdev, effectRgn, offset, flags, sharedPainter, repaintManager);
+             sourced->context = &context;
+             if (!sharedPainter) {
+@@ -5328,6 +5328,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
+         }
+     }
+ #endif // QT_CONFIG(graphicseffect)
++    flags = flags & ~UseEffectRegionBounds;
+ 
+     const bool alsoOnScreen = flags & DrawPaintOnScreen;
+     const bool recursive = flags & DrawRecursive;
+diff --git a/qtbase/src/widgets/kernel/qwidget_p.h b/qtbase/src/widgets/kernel/qwidget_p.h
+index eef6b8fa2c..c432f4b5d5 100644
+--- a/qtbase/src/widgets/kernel/qwidget_p.h
++++ b/qtbase/src/widgets/kernel/qwidget_p.h
+@@ -229,7 +229,8 @@ public:
+         DontSubtractOpaqueChildren = 0x10,
+         DontDrawOpaqueChildren = 0x20,
+         DontDrawNativeChildren = 0x40,
+-        DontSetCompositionMode = 0x80
++        DontSetCompositionMode = 0x80,
++        UseEffectRegionBounds = 0x100
+     };
+     Q_DECLARE_FLAGS(DrawWidgetFlags, DrawWidgetFlag)
+     Q_FLAG(DrawWidgetFlags)
+diff --git a/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp b/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
+index 02880b34da..0d44e1326d 100644
+--- a/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
++++ b/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
+@@ -1018,7 +1018,8 @@ void QWidgetRepaintManager::paintAndFlush()
+ 
+     // Paint the rest with composition.
+     if (repaintAllWidgets || !dirtyCopy.isEmpty()) {
+-        QWidgetPrivate::DrawWidgetFlags flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive;
++        QWidgetPrivate::DrawWidgetFlags flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive
++                | QWidgetPrivate::UseEffectRegionBounds;
+         tlw->d_func()->drawWidget(store->paintDevice(), dirtyCopy, QPoint(), flags, nullptr, this);
+     }
+ 
+diff --git a/qtbase/src/widgets/styles/qfusionstyle.cpp b/qtbase/src/widgets/styles/qfusionstyle.cpp
+index f4345d97c4..962912c838 100644
+--- a/qtbase/src/widgets/styles/qfusionstyle.cpp
++++ b/qtbase/src/widgets/styles/qfusionstyle.cpp
+@@ -1772,14 +1772,6 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio
+             proxy()->drawControl(CE_PushButtonLabel, &subopt, painter, widget);
+         }
+         break;
+-    case CE_PushButtonLabel:
+-        if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
+-            QStyleOptionButton b(*button);
+-            // no PM_ButtonShiftHorizontal and PM_ButtonShiftVertical for fusion style
+-            b.state &= ~(State_On | State_Sunken);
+-            QCommonStyle::drawControl(element, &b, painter, widget);
+-        }
+-        break;
+     case CE_MenuBarEmptyArea:
+         painter->save();
+     {
+diff --git a/qtbase/src/widgets/util/qcompleter.cpp b/qtbase/src/widgets/util/qcompleter.cpp
+index 18b24063d8..ef7207a8a3 100644
+--- a/qtbase/src/widgets/util/qcompleter.cpp
++++ b/qtbase/src/widgets/util/qcompleter.cpp
+@@ -1120,6 +1120,8 @@ void QCompleter::setModel(QAbstractItemModel *model)
+ {
+     Q_D(QCompleter);
+     QAbstractItemModel *oldModel = d->proxy->sourceModel();
++    if (oldModel == model)
++        return;
+ #if QT_CONFIG(filesystemmodel)
+     if (qobject_cast<const QFileSystemModel *>(oldModel))
+         setCompletionRole(Qt::EditRole); // QTBUG-54642, clear FileNameRole set by QFileSystemModel
+diff --git a/qtbase/src/widgets/widgets/qabstractbutton.cpp b/qtbase/src/widgets/widgets/qabstractbutton.cpp
+index a128b23950..dc40bf62fb 100644
+--- a/qtbase/src/widgets/widgets/qabstractbutton.cpp
++++ b/qtbase/src/widgets/widgets/qabstractbutton.cpp
+@@ -56,6 +56,7 @@
+ #ifndef QT_NO_ACCESSIBILITY
+ #include "qaccessible.h"
+ #endif
++#include <qpa/qplatformtheme.h>
+ 
+ #include <algorithm>
+ 
+@@ -1076,19 +1077,19 @@ void QAbstractButton::keyPressEvent(QKeyEvent *e)
+ {
+     Q_D(QAbstractButton);
+     bool next = true;
+-    switch (e->key()) {
+-    case Qt::Key_Enter:
+-    case Qt::Key_Return:
+-        e->ignore();
+-        break;
+-    case Qt::Key_Select:
+-    case Qt::Key_Space:
+-        if (!e->isAutoRepeat()) {
+-            setDown(true);
+-            repaint();
+-            d->emitPressed();
+-        }
+-        break;
++
++    const auto key = static_cast<Qt::Key>(e->key());
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(key) && !e->isAutoRepeat()) {
++        setDown(true);
++        repaint();
++        d->emitPressed();
++        return;
++    }
++
++    switch (key) {
+     case Qt::Key_Up:
+         next = false;
+         Q_FALLTHROUGH();
+@@ -1153,15 +1154,15 @@ void QAbstractButton::keyReleaseEvent(QKeyEvent *e)
+     if (!e->isAutoRepeat())
+         d->repeatTimer.stop();
+ 
+-    switch (e->key()) {
+-    case Qt::Key_Select:
+-    case Qt::Key_Space:
+-        if (!e->isAutoRepeat() && d->down)
+-            d->click();
+-        break;
+-    default:
+-        e->ignore();
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(static_cast<Qt::Key>(e->key())) && !e->isAutoRepeat() && d->down) {
++        d->click();
++        return;
+     }
++
++    e->ignore();
+ }
+ 
+ /*!\reimp
+diff --git a/qtbase/src/widgets/widgets/qcombobox.cpp b/qtbase/src/widgets/widgets/qcombobox.cpp
+index 7a496c27e0..0a3d96647b 100644
+--- a/qtbase/src/widgets/widgets/qcombobox.cpp
++++ b/qtbase/src/widgets/widgets/qcombobox.cpp
+@@ -3352,7 +3352,23 @@ void QComboBox::keyPressEvent(QKeyEvent *e)
+ 
+     Move move = NoMove;
+     int newIndex = currentIndex();
+-    switch (e->key()) {
++
++    bool pressLikeButton = !d->lineEdit;
++#ifdef QT_KEYPAD_NAVIGATION
++    pressLikeButton |= QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus();
++#endif
++    auto key = static_cast<Qt::Key>(e->key());
++    if (pressLikeButton) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(key)) {
++            showPopup();
++            return;
++        }
++    }
++
++    switch (key) {
+     case Qt::Key_Up:
+         if (e->modifiers() & Qt::ControlModifier)
+             break; // pass to line edit for auto completion
+@@ -3394,26 +3410,11 @@ void QComboBox::keyPressEvent(QKeyEvent *e)
+             return;
+         }
+         break;
+-    case Qt::Key_Space:
+-        if (!d->lineEdit) {
+-            showPopup();
+-            return;
+-        }
+-        break;
+-    case Qt::Key_Enter:
+-    case Qt::Key_Return:
+     case Qt::Key_Escape:
+         if (!d->lineEdit)
+             e->ignore();
+         break;
+ #ifdef QT_KEYPAD_NAVIGATION
+-    case Qt::Key_Select:
+-        if (QApplicationPrivate::keypadNavigationEnabled()
+-                && (!hasEditFocus() || !d->lineEdit)) {
+-            showPopup();
+-            return;
+-        }
+-        break;
+     case Qt::Key_Left:
+     case Qt::Key_Right:
+         if (QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus())
+diff --git a/qtbase/src/widgets/widgets/qdatetimeedit_p.h b/qtbase/src/widgets/widgets/qdatetimeedit_p.h
+index d36b6f8f9a..e0df5b5158 100644
+--- a/qtbase/src/widgets/widgets/qdatetimeedit_p.h
++++ b/qtbase/src/widgets/widgets/qdatetimeedit_p.h
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2018 The Qt Company Ltd.
++** Copyright (C) 2021 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtWidgets module of the Qt Toolkit.
+diff --git a/qtbase/src/widgets/widgets/qgroupbox.cpp b/qtbase/src/widgets/widgets/qgroupbox.cpp
+index 02a0bed325..3f3eccc370 100644
+--- a/qtbase/src/widgets/widgets/qgroupbox.cpp
++++ b/qtbase/src/widgets/widgets/qgroupbox.cpp
+@@ -54,6 +54,8 @@
+ #include "qaccessible.h"
+ #endif
+ #include <private/qwidget_p.h>
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
+ 
+ #include "qdebug.h"
+ 
+@@ -360,7 +362,10 @@ bool QGroupBox::event(QEvent *e)
+         return true;
+     case QEvent::KeyPress: {
+         QKeyEvent *k = static_cast<QKeyEvent*>(e);
+-        if (!k->isAutoRepeat() && (k->key() == Qt::Key_Select || k->key() == Qt::Key_Space)) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (!k->isAutoRepeat() && buttonPressKeys.contains(static_cast<Qt::Key>(k->key()))) {
+             d->pressedControl = QStyle::SC_GroupBoxCheckBox;
+             update(style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxCheckBox, this));
+             return true;
+@@ -369,7 +374,10 @@ bool QGroupBox::event(QEvent *e)
+     }
+     case QEvent::KeyRelease: {
+         QKeyEvent *k = static_cast<QKeyEvent*>(e);
+-        if (!k->isAutoRepeat() && (k->key() == Qt::Key_Select || k->key() == Qt::Key_Space)) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (!k->isAutoRepeat() && buttonPressKeys.contains(static_cast<Qt::Key>(k->key()))) {
+             bool toggle = (d->pressedControl == QStyle::SC_GroupBoxLabel
+                            || d->pressedControl == QStyle::SC_GroupBoxCheckBox);
+             d->pressedControl = QStyle::SC_None;
+diff --git a/qtbase/src/widgets/widgets/qlabel.cpp b/qtbase/src/widgets/widgets/qlabel.cpp
+index 30ff80cbb0..cf2605c17c 100644
+--- a/qtbase/src/widgets/widgets/qlabel.cpp
++++ b/qtbase/src/widgets/widgets/qlabel.cpp
+@@ -421,9 +421,6 @@ void QLabel::setPixmap(const QPixmap &pixmap)
+         d->pixmap = new QPixmap(pixmap);
+     }
+ 
+-    if (d->pixmap->depth() == 1 && !d->pixmap->mask())
+-        d->pixmap->setMask(*((QBitmap *)d->pixmap));
+-
+     d->updateLabel();
+ }
+ 
+diff --git a/qtbase/src/widgets/widgets/qtoolbararealayout.cpp b/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
+index 493c094cc1..d5f4b59017 100644
+--- a/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
++++ b/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
+@@ -1367,7 +1367,7 @@ bool QToolBarAreaLayout::restoreState(QDataStream &stream, const QList<QToolBar*
+                 item.widgetItem = new QWidgetItemV2(toolBar);
+                 toolBar->setOrientation(floating ? ((shown & 2) ? Qt::Vertical : Qt::Horizontal) : dock.o);
+                 toolBar->setVisible(shown & 1);
+-                toolBar->d_func()->setWindowState(floating, true, rect);
++                toolBar->d_func()->setWindowState(floating, false, rect);
+ 
+                 item.preferredSize = item.size;
+                 line.toolBarItems.append(item);
+diff --git a/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp b/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
+index 212c0a2e13..3c77b1ba0b 100644
+--- a/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
++++ b/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
+@@ -126,8 +126,7 @@ public:
+ 
+ void tst_QtConcurrentIterateKernel::instantiate()
+ {
+-    auto future = startThreadEngine(new PrintFor(0, 40)).startAsynchronously();
+-    future.waitForFinished();
++    startThreadEngine(new PrintFor(0, 40)).startBlocking();
+     QCOMPARE(iterations.loadRelaxed(), 40);
+ }
+ 
+@@ -166,10 +165,8 @@ void tst_QtConcurrentIterateKernel::stresstest()
+     const int times = 50;
+     for (int i = 0; i < times; ++i) {
+         counter.storeRelaxed(0);
+-        // ThreadEngine will delete f when it finishes
+-        auto f = new CountFor(0, iterations);
+-        auto future = f->startAsynchronously();
+-        future.waitForFinished();
++        CountFor f(0, iterations);
++        f.startBlocking();
+         QCOMPARE(counter.loadRelaxed(), iterations);
+     }
+ }
+@@ -177,11 +174,8 @@ void tst_QtConcurrentIterateKernel::stresstest()
+ void tst_QtConcurrentIterateKernel::noIterations()
+ {
+     const int times = 20000;
+-    for (int i = 0; i < times; ++i) {
+-        auto future = startThreadEngine(new IterateKernel<TestIterator, void>(0, 0))
+-                              .startAsynchronously();
+-        future.waitForFinished();
+-    }
++    for (int i = 0; i < times; ++i)
++        startThreadEngine(new IterateKernel<TestIterator, void>(0, 0)).startBlocking();
+ }
+ 
+ QMutex threadsMutex;
+@@ -236,10 +230,8 @@ void tst_QtConcurrentIterateKernel::throttling()
+ 
+     threads.clear();
+ 
+-    // ThreadEngine will delete f when it finishes
+-    auto f = new ThrottleFor(0, totalIterations);
+-    auto future = f->startAsynchronously();
+-    future.waitForFinished();
++    ThrottleFor f(0, totalIterations);
++    f.startBlocking();
+ 
+     QCOMPARE(iterations.loadRelaxed(), totalIterations);
+ 
+diff --git a/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp b/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
+index ac7be7acdd..81bc64c8d9 100644
+--- a/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
++++ b/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
+@@ -65,9 +65,16 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::runDirectly()
+ {
+-    PrintUser *engine = new PrintUser();
+-    QFuture<void> f = engine->startAsynchronously();
+-    f.waitForFinished();
++    {
++        PrintUser engine;
++        engine.startSingleThreaded();
++        engine.startBlocking();
++    }
++    {
++        PrintUser *engine = new PrintUser();
++        QFuture<void> f = engine->startAsynchronously();
++        f.waitForFinished();
++    }
+ }
+ 
+ class StringResultUser : public ThreadEngine<QString>
+@@ -99,10 +106,8 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::result()
+ {
+-    // ThreadEngine will delete 'engine' when it finishes
+-    auto engine = new StringResultUser();
+-    auto future = engine->startAsynchronously();
+-    QCOMPARE(future.result(), QString("Foo"));
++    StringResultUser engine;
++    QCOMPARE(*engine.startBlocking(), QString("Foo"));
+ }
+ 
+ class VoidResultUser : public ThreadEngine<void>
+@@ -128,9 +133,17 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::runThroughStarter()
+ {
+-    ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
+-    QFuture<QString> f = starter.startAsynchronously();
+-    QCOMPARE(f.result(), QString("Foo"));
++    {
++        ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
++        QFuture<QString>  f = starter.startAsynchronously();
++        QCOMPARE(f.result(), QString("Foo"));
++    }
++
++    {
++        ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
++        QString str = starter.startBlocking();
++        QCOMPARE(str, QString("Foo"));
++    }
+ }
+ 
+ class CancelUser : public ThreadEngine<void>
+@@ -213,6 +226,12 @@ void tst_QtConcurrentThreadEngine::throttle()
+         f.waitForFinished();
+         QCOMPARE(count.loadRelaxed(), 0);
+     }
++
++    for (int i = 0; i < repeats; ++i) {
++        ThrottleAlwaysUser t;
++        t.startBlocking();
++        QCOMPARE(count.loadRelaxed(), 0);
++    }
+ }
+ 
+ QSet<QThread *> threads;
+@@ -249,17 +268,35 @@ void tst_QtConcurrentThreadEngine::threadCount()
+ {
+     const int repeats = 10;
+     for (int i = 0; i < repeats; ++i) {
++        ThreadCountUser t;
++        t.startBlocking();
++        int count = threads.count();
++        int count_expected = QThreadPool::globalInstance()->maxThreadCount() + 1; // +1 for the main thread.
++        if (count != count_expected)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, count_expected);
++
+         (new ThreadCountUser())->startAsynchronously().waitForFinished();
+-        const auto count = threads.count();
+-        const auto maxThreadCount = QThreadPool::globalInstance()->maxThreadCount();
+-        QVERIFY(count <= maxThreadCount);
+-        QVERIFY(!threads.contains(QThread::currentThread()));
++        count = threads.count();
++        count_expected = QThreadPool::globalInstance()->maxThreadCount();
++        if (count != count_expected)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, count_expected);
+     }
+ 
+     // Set the finish flag immediately, this should give us one thread only.
+     for (int i = 0; i < repeats; ++i) {
++        ThreadCountUser t(true /*finishImmediately*/);
++        t.startBlocking();
++        int count = threads.count();
++        if (count != 1)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, 1);
++
+         (new ThreadCountUser(true /*finishImmediately*/))->startAsynchronously().waitForFinished();
+-        const auto count = threads.count();
++        count = threads.count();
++        if (count != 1)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
+         QCOMPARE(count, 1);
+         QVERIFY(!threads.contains(QThread::currentThread()));
+     }
+@@ -400,6 +437,7 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::exceptions()
+ {
++    // Asynchronous mode:
+     {
+         bool caught = false;
+         try  {
+@@ -412,6 +450,32 @@ void tst_QtConcurrentThreadEngine::exceptions()
+         QVERIFY2(caught, "did not get exception");
+     }
+ 
++    // Blocking mode:
++    // test throwing the exception from a worker thread.
++    {
++        bool caught = false;
++        try  {
++            QtConcurrentExceptionThrower e(QThread::currentThread());
++            e.startBlocking();
++        } catch (const QException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // test throwing the exception from the main thread (different code path)
++    {
++        bool caught = false;
++        try  {
++            QtConcurrentExceptionThrower e(0);
++            e.startBlocking();
++        } catch (const QException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // Asynchronous mode:
+     {
+         bool caught = false;
+         try  {
+@@ -423,6 +487,31 @@ void tst_QtConcurrentThreadEngine::exceptions()
+         }
+         QVERIFY2(caught, "did not get exception");
+     }
++
++    // Blocking mode:
++    // test throwing the exception from a worker thread.
++    {
++        bool caught = false;
++        try  {
++            UnrelatedExceptionThrower e(QThread::currentThread());
++            e.startBlocking();
++        } catch (const QUnhandledException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // test throwing the exception from the main thread (different code path)
++    {
++        bool caught = false;
++        try  {
++            UnrelatedExceptionThrower e(0);
++            e.startBlocking();
++        } catch (const QUnhandledException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
+ }
+ 
+ #endif
+diff --git a/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp b/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
+index 4968742110..f4c3fb711d 100644
+--- a/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
++++ b/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
+@@ -42,6 +42,7 @@ private slots:
+     void writeBlock_data();
+     void writeBlock();
+     void seek();
++    void invalidSeeks();
+     void seekTest_data();
+     void seekTest();
+     void read_rawdata();
+@@ -286,6 +287,29 @@ void tst_QBuffer::seek()
+     QCOMPARE(buffer.size(), pos);
+ }
+ 
++void tst_QBuffer::invalidSeeks()
++{
++    if constexpr (sizeof(qsizetype) == sizeof(qint64)) {
++        // sizeof(qsizetype) == sizeof(qint64), so +1 would overflow
++        QSKIP("This is a 32-bit-only test.");
++    } else {
++        QBuffer buffer;
++        buffer.open(QIODevice::WriteOnly);
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++        constexpr qint64 MaxQByteArrayCapacity = (std::numeric_limits<qsizetype>::max)();
++        // this should fail fast, not after trying to allocate nearly 2 GiB of data,
++        // potentially crashing in the process:
++        QVERIFY(!buffer.seek(2 * MaxQByteArrayCapacity - 1));
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++        // ditto:
++        QVERIFY(!buffer.seek(MaxQByteArrayCapacity + 1));
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++    }
++}
++
+ void tst_QBuffer::seekTest_data()
+ {
+     writeBlock_data();
+diff --git a/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp b/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
+index da5327594c..4a04e0f7c6 100644
+--- a/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
++++ b/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
+@@ -561,7 +561,8 @@ protected:
+     qint64 readData(char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf->size() - offset));
+-        memcpy(data, buf->constData() + offset, maxSize);
++        if (maxSize > 0)
++            memcpy(data, buf->constData() + offset, maxSize);
+         offset += maxSize;
+         return maxSize;
+     }
+@@ -604,13 +605,15 @@ protected:
+     qint64 readData(char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf.size() - pos()));
+-        memcpy(data, buf.constData() + pos(), maxSize);
++        if (maxSize > 0)
++            memcpy(data, buf.constData() + pos(), maxSize);
+         return maxSize;
+     }
+     qint64 writeData(const char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf.size() - pos()));
+-        memcpy(buf.data() + pos(), data, maxSize);
++        if (maxSize > 0)
++            memcpy(buf.data() + pos(), data, maxSize);
+         return maxSize;
+     }
+ 
+diff --git a/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+index db60bead64..f345a44414 100644
+--- a/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
++++ b/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+@@ -1,7 +1,8 @@
+ /****************************************************************************
+ **
+ ** Copyright (C) 2021 The Qt Company Ltd.
+-** Copyright (C) 2020 Intel Corporation.
++** Copyright (C) 2020 The Qt Company Ltd.
++** Copyright (C) 2022 Intel Corporation.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the test suite of the Qt Toolkit.
+@@ -150,6 +151,8 @@ private slots:
+     void startStopStartStopBuffers();
+     void processEventsInAReadyReadSlot_data();
+     void processEventsInAReadyReadSlot();
++    void startFromCurrentWorkingDir_data();
++    void startFromCurrentWorkingDir();
+ 
+     // keep these at the end, since they use lots of processes and sometimes
+     // caused obscure failures to occur in tests that followed them (esp. on the Mac)
+@@ -2731,5 +2734,94 @@ void tst_QProcess::finishProcessBeforeReadingDone_deprecated()
+ 
+ #endif
+ 
++enum class ChdirMode {
++    None = 0,
++    InParent,
++    InChild
++};
++Q_DECLARE_METATYPE(ChdirMode)
++
++void tst_QProcess::startFromCurrentWorkingDir_data()
++{
++    qRegisterMetaType<ChdirMode>();
++    QTest::addColumn<QString>("programPrefix");
++    QTest::addColumn<ChdirMode>("chdirMode");
++    QTest::addColumn<bool>("success");
++
++    constexpr bool IsWindows = true
++#ifdef Q_OS_UNIX
++            && false
++#endif
++            ;
++
++    // baseline: trying to execute the directory, this can't possibly succeed!
++    QTest::newRow("plain-same-cwd") << QString() << ChdirMode::None << false;
++
++    // cross-platform behavior: neither OS searches the setWorkingDirectory()
++    // dir without "./"
++    QTest::newRow("plain-child-chdir") << QString() << ChdirMode::InChild << false;
++
++    // cross-platform behavior: both OSes search the parent's CWD with "./"
++    QTest::newRow("prefixed-parent-chdir") << "./" << ChdirMode::InParent << true;
++
++    // opposite behaviors: Windows searches the parent's CWD and Unix searches
++    // the child's with "./"
++    QTest::newRow("prefixed-child-chdir") << "./" << ChdirMode::InChild << !IsWindows;
++
++    // Windows searches the parent's CWD without "./"
++    QTest::newRow("plain-parent-chdir") << QString() << ChdirMode::InParent << IsWindows;
++}
++
++void tst_QProcess::startFromCurrentWorkingDir()
++{
++    QFETCH(QString, programPrefix);
++    QFETCH(ChdirMode, chdirMode);
++    QFETCH(bool, success);
++
++    QProcess process;
++    qRegisterMetaType<QProcess::ProcessError>();
++    QSignalSpy errorSpy(&process, &QProcess::errorOccurred);
++    QVERIFY(errorSpy.isValid());
++
++    // both the dir name and the executable name
++    const QString target = QStringLiteral("testProcessNormal");
++    process.setProgram(programPrefix + target);
++
++#ifdef Q_OS_UNIX
++    // Reset PATH, to be sure it doesn't contain . or the empty path.
++    // We can't do this on Windows because DLLs are searched in PATH
++    // and Windows always searches "." anyway.
++    auto restoreEnv = qScopeGuard([old = qgetenv("PATH")] {
++        qputenv("PATH", old);
++    });
++    qputenv("PATH", "/");
++#endif
++
++    switch (chdirMode) {
++    case ChdirMode::InParent: {
++        auto restoreCwd = qScopeGuard([old = QDir::currentPath()] {
++            QDir::setCurrent(old);
++        });
++        QVERIFY(QDir::setCurrent(target));
++        process.start();
++        break;
++    }
++    case ChdirMode::InChild:
++        process.setWorkingDirectory(target);
++        Q_FALLTHROUGH();
++    case ChdirMode::None:
++        process.start();
++        break;
++    }
++
++    QCOMPARE(process.waitForStarted(), success);
++    QCOMPARE(errorSpy.count(), int(!success));
++    if (success) {
++        QVERIFY(process.waitForFinished());
++    } else {
++        QCOMPARE(process.error(), QProcess::FailedToStart);
++    }
++}
++
+ QTEST_MAIN(tst_QProcess)
+ #include "tst_qprocess.moc"
+diff --git a/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp b/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp
+index e1ea7a4552..90972caa57 100644
+--- a/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp
++++ b/qtbase/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"
+diff --git a/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+index 9bd66c0835..ed4a0bae5d 100644
+--- a/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
++++ b/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+@@ -158,6 +158,7 @@ private slots:
+     void nullReceiver();
+     void functorReferencesConnection();
+     void disconnectDisconnects();
++    void declarativeData();
+ };
+ 
+ struct QObjectCreatedOnShutdown
+@@ -7679,5 +7680,81 @@ void tst_QObject::disconnectDisconnects()
+ Q_STATIC_ASSERT(QtPrivate::HasQ_OBJECT_Macro<tst_QObject>::Value);
+ Q_STATIC_ASSERT(!QtPrivate::HasQ_OBJECT_Macro<SiblingDeleter>::Value);
+ 
++#ifdef QT_BUILD_INTERNAL
++/*
++    Since QObjectPrivate stores the declarativeData pointer in a union with the pointer
++    to the currently destroyed child, calls to the QtDeclarative handlers need to be
++    correctly guarded. QTBUG-105286
++*/
++namespace QtDeclarative {
++static QAbstractDeclarativeData *theData;
++
++static void destroyed(QAbstractDeclarativeData *data, QObject *)
++{
++    QCOMPARE(data, theData);
++}
++static void signalEmitted(QAbstractDeclarativeData *data, QObject *, int, void **)
++{
++    QCOMPARE(data, theData);
++}
++// we can't use QCOMPARE in the next two functions, as they don't return void
++static int receivers(QAbstractDeclarativeData *data, const QObject *, int)
++{
++    QTest::qCompare(data, theData, "data", "theData", __FILE__, __LINE__);
++    return 0;
++}
++static bool isSignalConnected(QAbstractDeclarativeData *data, const QObject *, int)
++{
++    QTest::qCompare(data, theData, "data", "theData", __FILE__, __LINE__);
++    return true;
++}
++
++class Object : public QObject
++{
++    Q_OBJECT
++public:
++    using QObject::QObject;
++    ~Object()
++    {
++        if (Object *p = static_cast<Object *>(parent()))
++            p->emitSignal();
++    }
++
++    void emitSignal()
++    {
++        emit theSignal();
++    }
++
++signals:
++    void theSignal();
++};
++
++}
++#endif
++
++void tst_QObject::declarativeData()
++{
++#ifdef QT_BUILD_INTERNAL
++    QScopedValueRollback destroyed(QAbstractDeclarativeData::destroyed,
++                                   QtDeclarative::destroyed);
++    QScopedValueRollback signalEmitted(QAbstractDeclarativeData::signalEmitted,
++                                       QtDeclarative::signalEmitted);
++    QScopedValueRollback receivers(QAbstractDeclarativeData::receivers,
++                                   QtDeclarative::receivers);
++    QScopedValueRollback isSignalConnected(QAbstractDeclarativeData::isSignalConnected,
++                                           QtDeclarative::isSignalConnected);
++
++    QtDeclarative::Object p;
++    QObjectPrivate *priv = QObjectPrivate::get(&p);
++    priv->declarativeData = QtDeclarative::theData = new QAbstractDeclarativeData;
++
++    connect(&p, &QtDeclarative::Object::theSignal, &p, []{
++    });
++
++    QtDeclarative::Object *child = new QtDeclarative::Object;
++    child->setParent(&p);
++#endif
++}
++
+ QTEST_MAIN(tst_QObject)
+ #include "tst_qobject.moc"
+diff --git a/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp b/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
+index 0ea422ecbc..1a3256534b 100644
+--- a/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
++++ b/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
+@@ -70,15 +70,15 @@ static inline QString testSuiteWarning()
+ 
+     QString result;
+     QTextStream str(&result);
+-    str << "\nCannot find the shared-mime-info test suite\nstarting from: "
++    str << "\nCannot find the shared-mime-info test suite\nin the parent of: "
+         << QDir::toNativeSeparators(QDir::currentPath()) << "\n"
+            "cd " << QDir::toNativeSeparators(QStringLiteral("tests/auto/corelib/mimetypes/qmimedatabase")) << "\n"
+-           "wget http://cgit.freedesktop.org/xdg/shared-mime-info/snapshot/Release-1-10.zip\n"
+-           "unzip Release-1-10.zip\n";
++           "wget https://gitlab.freedesktop.org/xdg/shared-mime-info/-/archive/2.1/shared-mime-info-2.1.zip\n"
++           "unzip shared-mime-info-2.1.zip\n";
+ #ifdef Q_OS_WIN
+-    str << "mkdir testfiles\nxcopy /s Release-1-10 s-m-i\n";
++    str << "mkdir testfiles\nxcopy /s shared-mime-info-2.1 s-m-i\n";
+ #else
+-    str << "ln -s Release-1-10 s-m-i\n";
++    str << "ln -s shared-mime-info-2.1 s-m-i\n";
+ #endif
+     return result;
+ }
+@@ -154,7 +154,7 @@ void tst_QMimeDatabase::initTestCase()
+     QVERIFY2(copyResourceFile(xmlFileName, xmlTargetFileName, &errorMessage), qPrintable(errorMessage));
+ #endif
+ 
+-    m_testSuite = QFINDTESTDATA("s-m-i/tests");
++    m_testSuite = QFINDTESTDATA("s-m-i/tests/mime-detection");
+     if (m_testSuite.isEmpty())
+         qWarning("%s", qPrintable(testSuiteWarning()));
+ 
+@@ -611,7 +611,7 @@ void tst_QMimeDatabase::allMimeTypes()
+     QVERIFY(!lst.isEmpty());
+ 
+     // Hardcoding this is the only way to check both providers find the same number of mimetypes.
+-    QCOMPARE(lst.count(), 779);
++    QCOMPARE(lst.count(), 811);
+ 
+     foreach (const QMimeType &mime, lst) {
+         const QString name = mime.name();
+@@ -631,10 +631,9 @@ void tst_QMimeDatabase::suffixes_data()
+ 
+     QTest::newRow("mimetype with a single pattern") << "application/pdf" << "*.pdf" << "pdf";
+     QTest::newRow("mimetype with multiple patterns") << "application/x-kpresenter" << "*.kpr;*.kpt" << "kpr";
+-    QTest::newRow("jpeg") << "image/jpeg" << "*.jpe;*.jpg;*.jpeg" << "jpeg";
+-    //if (KMimeType::sharedMimeInfoVersion() > KDE_MAKE_VERSION(0, 60, 0)) {
+-        QTest::newRow("mimetype with many patterns") << "application/vnd.wordperfect" << "*.wp;*.wp4;*.wp5;*.wp6;*.wpd;*.wpp" << "wp";
+-    //}
++    // The preferred suffix for image/jpeg is *.jpg, as per https://bugs.kde.org/show_bug.cgi?id=176737
++    QTest::newRow("jpeg") << "image/jpeg" << "*.jpe;*.jpg;*.jpeg" << "jpg";
++    QTest::newRow("mimetype with many patterns") << "application/vnd.wordperfect" << "*.wp;*.wp4;*.wp5;*.wp6;*.wpd;*.wpp" << "wp";
+     QTest::newRow("oasis text mimetype") << "application/vnd.oasis.opendocument.text" << "*.odt" << "odt";
+     QTest::newRow("oasis presentation mimetype") << "application/vnd.oasis.opendocument.presentation" << "*.odp" << "odp";
+     QTest::newRow("mimetype with multiple patterns") << "text/plain" << "*.asc;*.txt;*,v" << "txt";
+diff --git a/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp b/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
+index 3e58dd03cc..c8f82ef5d5 100644
+--- a/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
++++ b/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
+@@ -176,6 +176,8 @@ private Q_SLOTS:
+     void fromToVariantConversions_data();
+     void fromToVariantConversions();
+ 
++    void noLeakOnNameClash();
++
+ private:
+     QString testDataDir;
+ };
+@@ -3685,5 +3687,23 @@ void tst_QtJson::fromToVariantConversions()
+     }
+ }
+ 
++void tst_QtJson::noLeakOnNameClash()
++{
++    QJsonDocument doc = QJsonDocument::fromJson("{\"\":{\"\":0},\"\":0}");
++    QVERIFY(!doc.isNull());
++    const QJsonObject obj = doc.object();
++
++    // Removed the duplicate key.
++    QCOMPARE(obj.length(), 1);
++
++    // Retained the last of the duplicates.
++    const QJsonValue val = obj.begin().value();
++    QVERIFY(val.isDouble());
++    QCOMPARE(val.toDouble(), 0.0);
++
++    // It should not leak.
++    // In particular it should not forget to deref the container for the inner object.
++}
++
+ QTEST_MAIN(tst_QtJson)
+ #include "tst_qtjson.moc"
+diff --git a/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp b/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
+index a59b58d57f..241c3e84ac 100644
+--- a/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
++++ b/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
+@@ -63,6 +63,7 @@ private slots:
+     void isValidId_data();
+     void isValidId();
+     void malformed();
++    void serialize();
+     // Backend tests
+     void utcTest();
+     void icuTest();
+@@ -947,6 +948,33 @@ void tst_QTimeZone::malformed()
+         barf.offsetFromUtc(now);
+ }
+ 
++void tst_QTimeZone::serialize()
++{
++    int parts = 0;
++#ifndef QT_NO_DEBUG_STREAM
++    qDebug() << QTimeZone(); // to verify no crash
++    parts++;
++#endif
++#ifndef QT_NO_DATASTREAM
++    QByteArray blob;
++    {
++        QDataStream stream(&blob, QIODevice::WriteOnly);
++        stream << QTimeZone("Europe/Oslo") << QTimeZone(420) << QTimeZone() << qint64(-1);
++    }
++    QDataStream stream(&blob, QIODevice::ReadOnly);
++    QTimeZone invalid, offset, oslo;
++    qint64 minusone;
++    stream >> oslo >> offset >> invalid >> minusone;
++    QCOMPARE(oslo, QTimeZone("Europe/Oslo"));
++    QCOMPARE(offset, QTimeZone(420));
++    QVERIFY(!invalid.isValid());
++    QCOMPARE(minusone, qint64(-1));
++    parts++;
++#endif
++    if (!parts)
++        QSKIP("No serialization enabled");
++}
++
+ void tst_QTimeZone::utcTest()
+ {
+ #ifdef QT_BUILD_INTERNAL
+diff --git a/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp b/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
+index 05480c6dd2..70f4c75756 100644
+--- a/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
++++ b/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
+@@ -324,6 +324,13 @@ void tst_QDBusInterface::notValid()
+ 
+     QVERIFY(!interface.isValid());
+     QVERIFY(!QMetaObject::invokeMethod(&interface, "ListNames", Qt::DirectConnection));
++
++    // With a connection, but empty/null service and path specified
++    QDBusConnection con = QDBusConnection::sessionBus();
++    QVERIFY(con.isConnected());
++    QDBusInterface iface({}, {}, {}, con);
++    QVERIFY(!iface.isValid());
++    QVERIFY(!QMetaObject::invokeMethod(&interface, "ListNames", Qt::DirectConnection));
+ }
+ 
+ void tst_QDBusInterface::notValidDerived()
+diff --git a/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp b/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
+index 874468c954..04ceb4ab65 100644
+--- a/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
++++ b/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
+@@ -507,6 +507,10 @@ void tst_QKeySequence::toStringFromKeycode_data()
+     QTest::newRow("Ctrl+Alt+Num+Del") << QKeySequence(Qt::ControlModifier | Qt::AltModifier | Qt::KeypadModifier | Qt::Key_Delete) << "Ctrl+Alt+Num+Del";
+     QTest::newRow("Ctrl+Ins") << QKeySequence(Qt::ControlModifier | Qt::Key_Insert) << "Ctrl+Ins";
+     QTest::newRow("Ctrl+Num+Ins(1)") << QKeySequence(Qt::Key_Insert | Qt::KeypadModifier | Qt::ControlModifier) << "Ctrl+Num+Ins";
++    QTest::newRow("Ctrl") << QKeySequence(Qt::Key_Control) << "Control";
++    QTest::newRow("Alt") << QKeySequence(Qt::Key_Alt) << "Alt";
++    QTest::newRow("Shift") << QKeySequence(Qt::Key_Shift) << "Shift";
++    QTest::newRow("Meta") << QKeySequence(Qt::Key_Meta) << "Meta";
+ }
+ 
+ void tst_QKeySequence::toStringFromKeycode()
+diff --git a/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp b/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+index 15e0ecadaa..b4eca74283 100644
+--- a/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
++++ b/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+@@ -81,6 +81,8 @@ private slots:
+     void registerOpenTypePreferredNamesSystem();
+     void registerOpenTypePreferredNamesApplication();
+ 
++    void stretchRespected();
++
+ private:
+     QString m_ledFont;
+     QString m_testFont;
+@@ -355,6 +357,28 @@ static QString testString()
+     return QStringLiteral("foo bar");
+ }
+ 
++void tst_QFontDatabase::stretchRespected()
++{
++    int italicId = QFontDatabase::addApplicationFont(m_testFontItalic);
++    QVERIFY(italicId != -1);
++
++    QVERIFY(!QFontDatabase::applicationFontFamilies(italicId).isEmpty());
++
++    QString italicFontName = QFontDatabase::applicationFontFamilies(italicId).first();
++
++    QFont italicFont = QFontDatabase().font(italicFontName,
++                                            QString::fromLatin1("Italic"), 14);
++    QVERIFY(italicFont.italic());
++
++    QFont italicStretchedFont = italicFont;
++    italicStretchedFont.setStretch( 400 );
++
++    QVERIFY(QFontMetricsF(italicFont).horizontalAdvance(QStringLiteral("foobar")) <
++            QFontMetricsF(italicStretchedFont).horizontalAdvance(QStringLiteral("foobar")));
++
++    QFontDatabase::removeApplicationFont(italicId);
++}
++
+ void tst_QFontDatabase::condensedFontWidthNoFontMerging()
+ {
+     int regularFontId = QFontDatabase::addApplicationFont(m_testFont);
+diff --git a/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+index 3d4a094c43..b423e11a99 100644
+--- a/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
++++ b/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+@@ -281,6 +281,7 @@ private Q_SLOTS:
+     void ioGetFromFileSpecial();
+     void ioGetFromFile_data();
+     void ioGetFromFile();
++    void ioGetFromFileUrl();
+     void ioGetFromFtp_data();
+     void ioGetFromFtp();
+     void ioGetFromFtpWithReuse();
+@@ -3300,6 +3301,18 @@ void tst_QNetworkReply::ioGetFromFile()
+     QCOMPARE(reader.data, data);
+ }
+ 
++void tst_QNetworkReply::ioGetFromFileUrl()
++{
++    // This immediately fails on non-windows platforms:
++    QNetworkRequest request(QUrl("file://unc-server/some/path"));
++    QNetworkReplyPtr reply(manager.get(request));
++    QSignalSpy finishedSpy(reply.get(), &QNetworkReply::finished);
++    // QTBUG-105618: This would, on non-Windows platforms, never happen because the signal
++    // was emitted before the constructor finished, leaving no chance at all to connect to the
++    // signal
++    QVERIFY(finishedSpy.wait());
++}
++
+ void tst_QNetworkReply::ioGetFromFtp_data()
+ {
+     QTest::addColumn<QString>("fileName");
+diff --git a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
+index 069fa6b341..4cc4d9a5ea 100644
+--- a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
++++ b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
+@@ -1,75 +1,34 @@
+-Certificate:
+-    Data:
+-        Version: 3 (0x2)
+-        Serial Number: 0 (0x0)
+-        Signature Algorithm: sha1WithRSAEncryption
+-        Issuer: C=NO, ST=Oslo, L=Nydalen, O=Nokia Corporation and/or its subsidiary(-ies), OU=Development, CN=fluke.troll.no/emailAddress=ahanssen@trolltech.com
+-        Validity
+-            Not Before: Dec  4 01:10:32 2007 GMT
+-            Not After : Apr 21 01:10:32 2035 GMT
+-        Subject: C=NO, ST=Oslo, O=Nokia Corporation and/or its subsidiary(-ies), OU=Development, CN=fluke.troll.no
+-        Subject Public Key Info:
+-            Public Key Algorithm: rsaEncryption
+-            RSA Public Key: (1024 bit)
+-                Modulus (1024 bit):
+-                    00:a7:c8:a0:4a:c4:19:05:1b:66:ba:32:e2:d2:f1:
+-                    1c:6f:17:82:e4:39:2e:01:51:90:db:04:34:32:11:
+-                    21:c2:0d:6f:59:d8:53:90:54:3f:83:8f:a9:d3:b3:
+-                    d5:ee:1a:9b:80:ae:c3:25:c9:5e:a5:af:4b:60:05:
+-                    aa:a0:d1:91:01:1f:ca:04:83:e3:58:1c:99:32:45:
+-                    84:70:72:58:03:98:4a:63:8b:41:f5:08:49:d2:91:
+-                    02:60:6b:e4:64:fe:dd:a0:aa:74:08:e9:34:4c:91:
+-                    5f:12:3d:37:4d:54:2c:ad:7f:5b:98:60:36:02:8c:
+-                    3b:f6:45:f3:27:6a:9b:94:9d
+-                Exponent: 65537 (0x10001)
+-        X509v3 extensions:
+-            X509v3 Basic Constraints: 
+-                CA:FALSE
+-            Netscape Comment: 
+-                OpenSSL Generated Certificate
+-            X509v3 Subject Key Identifier: 
+-                21:85:04:3D:23:01:66:E5:F7:9F:1A:84:24:8A:AF:0A:79:F4:E5:AC
+-            X509v3 Authority Key Identifier: 
+-                DirName:/C=NO/ST=Oslo/L=Nydalen/O=Nokia Corporation and/or its subsidiary(-ies)/OU=Development/CN=fluke.troll.no/emailAddress=ahanssen@trolltech.com
+-                serial:8E:A8:B4:E8:91:B7:54:2E
+-
+-    Signature Algorithm: sha1WithRSAEncryption
+-        6d:57:5f:d1:05:43:f0:62:05:ec:2a:71:a5:dc:19:08:f2:c4:
+-        a6:bd:bb:25:d9:ca:89:01:0e:e4:cf:1f:c1:8c:c8:24:18:35:
+-        53:59:7b:c0:43:b4:32:e6:98:b2:a6:ef:15:05:0b:48:5f:e1:
+-        a0:0c:97:a9:a1:77:d8:35:18:30:bc:a9:8f:d3:b7:54:c7:f1:
+-        a9:9e:5d:e6:19:bf:f6:3c:5b:2b:d8:e4:3e:62:18:88:8b:d3:
+-        24:e1:40:9b:0c:e6:29:16:62:ab:ea:05:24:70:36:aa:55:93:
+-        ef:02:81:1b:23:10:a2:04:eb:56:95:75:fc:f8:94:b1:5d:42:
+-        c5:3f:36:44:85:5d:3a:2e:90:46:8a:a2:b9:6f:87:ae:0c:15:
+-        40:19:31:90:fc:3b:25:bb:ae:f1:66:13:0d:85:90:d9:49:34:
+-        8f:f2:5d:f9:7a:db:4d:5d:27:f6:76:9d:35:8c:06:a6:4c:a3:
+-        b1:b2:b6:6f:1d:d7:a3:00:fd:72:eb:9e:ea:44:a1:af:21:34:
+-        7d:c7:42:e2:49:91:19:8b:c0:ad:ba:82:80:a8:71:70:f4:35:
+-        31:91:63:84:20:95:e9:60:af:64:8b:cc:ff:3d:8a:76:74:3d:
+-        c8:55:6d:e4:8e:c3:2b:1c:e8:42:18:ae:9f:e6:6b:9c:34:06:
+-        ec:6a:f2:c3
+ -----BEGIN CERTIFICATE-----
+-MIIEEzCCAvugAwIBAgIBADANBgkqhkiG9w0BAQUFADCBnDELMAkGA1UEBhMCTk8x
+-DTALBgNVBAgTBE9zbG8xEDAOBgNVBAcTB055ZGFsZW4xFjAUBgNVBAoTDVRyb2xs
+-dGVjaCBBU0ExFDASBgNVBAsTC0RldmVsb3BtZW50MRcwFQYDVQQDEw5mbHVrZS50
+-cm9sbC5ubzElMCMGCSqGSIb3DQEJARYWYWhhbnNzZW5AdHJvbGx0ZWNoLmNvbTAe
+-Fw0wNzEyMDQwMTEwMzJaFw0zNTA0MjEwMTEwMzJaMGMxCzAJBgNVBAYTAk5PMQ0w
+-CwYDVQQIEwRPc2xvMRYwFAYDVQQKEw1Ucm9sbHRlY2ggQVNBMRQwEgYDVQQLEwtE
+-ZXZlbG9wbWVudDEXMBUGA1UEAxMOZmx1a2UudHJvbGwubm8wgZ8wDQYJKoZIhvcN
+-AQEBBQADgY0AMIGJAoGBAKfIoErEGQUbZroy4tLxHG8XguQ5LgFRkNsENDIRIcIN
+-b1nYU5BUP4OPqdOz1e4am4CuwyXJXqWvS2AFqqDRkQEfygSD41gcmTJFhHByWAOY
+-SmOLQfUISdKRAmBr5GT+3aCqdAjpNEyRXxI9N01ULK1/W5hgNgKMO/ZF8ydqm5Sd
+-AgMBAAGjggEaMIIBFjAJBgNVHRMEAjAAMCwGCWCGSAGG+EIBDQQfFh1PcGVuU1NM
+-IEdlbmVyYXRlZCBDZXJ0aWZpY2F0ZTAdBgNVHQ4EFgQUIYUEPSMBZuX3nxqEJIqv
+-Cnn05awwgbsGA1UdIwSBszCBsKGBoqSBnzCBnDELMAkGA1UEBhMCTk8xDTALBgNV
+-BAgTBE9zbG8xEDAOBgNVBAcTB055ZGFsZW4xFjAUBgNVBAoTDVRyb2xsdGVjaCBB
+-U0ExFDASBgNVBAsTC0RldmVsb3BtZW50MRcwFQYDVQQDEw5mbHVrZS50cm9sbC5u
+-bzElMCMGCSqGSIb3DQEJARYWYWhhbnNzZW5AdHJvbGx0ZWNoLmNvbYIJAI6otOiR
+-t1QuMA0GCSqGSIb3DQEBBQUAA4IBAQBtV1/RBUPwYgXsKnGl3BkI8sSmvbsl2cqJ
+-AQ7kzx/BjMgkGDVTWXvAQ7Qy5piypu8VBQtIX+GgDJepoXfYNRgwvKmP07dUx/Gp
+-nl3mGb/2PFsr2OQ+YhiIi9Mk4UCbDOYpFmKr6gUkcDaqVZPvAoEbIxCiBOtWlXX8
+-+JSxXULFPzZEhV06LpBGiqK5b4euDBVAGTGQ/Dslu67xZhMNhZDZSTSP8l35ettN
+-XSf2dp01jAamTKOxsrZvHdejAP1y657qRKGvITR9x0LiSZEZi8CtuoKAqHFw9DUx
+-kWOEIJXpYK9ki8z/PYp2dD3IVW3kjsMrHOhCGK6f5mucNAbsavLD
++MIIF6zCCA9OgAwIBAgIUfo9amJtJGWqWE6f+SkAO85zkGr4wDQYJKoZIhvcNAQEL
++BQAwgYMxCzAJBgNVBAYTAk5PMQ0wCwYDVQQIDARPc2xvMQ0wCwYDVQQHDARPc2xv
++MRcwFQYDVQQKDA5UaGUgUXQgQ29tcGFueTEMMAoGA1UECwwDUiZEMRIwEAYDVQQD
++DAlIMiBUZXN0ZXIxGzAZBgkqhkiG9w0BCQEWDG1pbmltaUBxdC5pbzAgFw0yMDEw
++MjYxMjAxMzFaGA8yMTIwMTAwMjEyMDEzMVowgYMxCzAJBgNVBAYTAk5PMQ0wCwYD
++VQQIDARPc2xvMQ0wCwYDVQQHDARPc2xvMRcwFQYDVQQKDA5UaGUgUXQgQ29tcGFu
++eTEMMAoGA1UECwwDUiZEMRIwEAYDVQQDDAlIMiBUZXN0ZXIxGzAZBgkqhkiG9w0B
++CQEWDG1pbmltaUBxdC5pbzCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIB
++AOiUp5+E4blouKH7q+rVNR8NoYX2XkBW+q+rpy1zu5ssRSzbqxAjDx9dkht7Qlnf
++VlDT00JvpOWdeuPon5915edQRsY4Unl6mKH29ra3OtUa1/yCJXsGVJTKCj7k4Bxb
++5mZzb/fTlZntMLdTIBMfUbw62FKir1WjKIcJ9fCoG8JaGeKVO4Rh5p0ezd4UUUId
++r1BXl5Nqdqy2vTMsEDnjOsD3egkv8I2SKN4O6n/C3wWYpMOWYZkGoZiKz7rJs/i/
++ez7bsV7JlwdzTlhpJzkcOSVFBP6JlEOxTNNxZ1wtKy7PtZGmsSSATq2e6+bw38Ae
++Op0XnzzqcGjtDDofBmT7OFzZWjS9VZS6+DOOe2QHWle1nCHcHyH4ku6IRlsr9xkR
++NAIlOfnvHHxqJUenoeaZ4oQDjCBKS1KXygJO/tL7BLTQVn/xK1EmPvKNnjzWk4tR
++PnibUhhs5635qpOU/YPqFBh1JjVruZbsWcDAhRcew0uxONXOa9E+4lttQ9ySYa1A
++LvWqJuAX7gu2BsBMLyqfm811YnA7CIFMyO+HlqmkLFfv5L/xIRAXR7l26YGO0VwX
++CGjMfz4NVPMMke4nB7qa9NkpXQBQKMms3Qzd5JW0Hy9Ruj5O8GPcFZmV0twjd1uJ
++PD/cAjkWLaXjdNsJ16QWc2nghQRS6HYqKRX6j+CXOxupAgMBAAGjUzBRMB0GA1Ud
++DgQWBBRSCOU58j9NJZkMamt623qyCrhN3TAfBgNVHSMEGDAWgBRSCOU58j9NJZkM
++amt623qyCrhN3TAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4ICAQCq
++q4jxsWeNDv5Nq14hJtF9HB+ZL64zcZtRjJP1YgNs0QppKICmjPOL2nIMGmI/jKrs
++0eGAL/9XXNVHPxm1OPOncvimMMmU6emZfpMdEtTfKP43+Pg9HgKRjLoQp406vGeQ
++8ki/mbBhrItVPgEm3tu2AFA02XTYi+YxCI9kRZLGkM3FbgtOuTLPl0Z9y+kiPc9F
++uCSC03anBEqv+vDSI8+wODymQ/IJ3Jyz1lxIRDfp4qAekmy0jU2c91VOHHEmOmqq
++kqygGFRdwbe99m9yP63r6q0b5K3X2UnJ6bns0hmTwThYwpVPXLU8jdaTddbMukN2
++/Ef96Tsw8nWOEOPMySHOTIPgwyZRp26b0kA9EmhLwOP401SxXVQCmSRmtwNagmtg
++jJKmZoYBN+//D45ibK8z6Q0oOm9P+Whf/uUXehcRxBxyV3xz7k0wKGQbHj/ddwcy
++IUoIN4lrAlib+lK170kTKN352PDmrpo2gmIzPEsfurKAIMSelDl6H+kih16BtZ8y
++Nz6fh9Soqrg3OSAware8pxV7k51crBMoPLN78KoRV8MFCK4K7Fddq4rRISq6hiXq
++r1nsjoEPuKM9huprmZVZe9t5YcDa2I+wb3IiE3uwpZbAdaLDyQ5n6F/qpsiIkZXn
++gtcF7oqpG5oYrwCcZ53y/ezUgUg7PlSz2XwAGvQtgg==
+ -----END CERTIFICATE-----
+diff --git a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
+index 9d1664d609..337ce541a6 100644
+--- a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
++++ b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
+@@ -1,15 +1,52 @@
+------BEGIN RSA PRIVATE KEY-----
+-MIICXAIBAAKBgQCnyKBKxBkFG2a6MuLS8RxvF4LkOS4BUZDbBDQyESHCDW9Z2FOQ
+-VD+Dj6nTs9XuGpuArsMlyV6lr0tgBaqg0ZEBH8oEg+NYHJkyRYRwclgDmEpji0H1
+-CEnSkQJga+Rk/t2gqnQI6TRMkV8SPTdNVCytf1uYYDYCjDv2RfMnapuUnQIDAQAB
+-AoGANFzLkanTeSGNFM0uttBipFT9F4a00dqHz6JnO7zXAT26I5r8sU1pqQBb6uLz
+-/+Qz5Zwk8RUAQcsMRgJetuPQUb0JZjF6Duv24hNazqXBCu7AZzUenjafwmKC/8ri
+-KpX3fTwqzfzi//FKGgbXQ80yykSSliDL3kn/drATxsLCgQECQQDXhEFWLJ0vVZ1s
+-1Ekf+3NITE+DR16X+LQ4W6vyEHAjTbaNWtcTKdAWLA2l6N4WAAPYSi6awm+zMxx4
+-VomVTsjdAkEAx0z+e7natLeFcrrq8pbU+wa6SAP1VfhQWKitxL1e7u/QO90NCpxE
+-oQYKzMkmmpOOFjQwEMAy1dvFMbm4LHlewQJAC/ksDBaUcQHHqjktCtrUb8rVjAyW
+-A8lscckeB2fEYyG5J6dJVaY4ClNOOs5yMDS2Afk1F6H/xKvtQ/5CzInA/QJATDub
+-K+BPU8jO9q+gpuIi3VIZdupssVGmCgObVCHLakG4uO04y9IyPhV9lA9tALtoIf4c
+-VIvv5fWGXBrZ48kZAQJBAJmVCdzQxd9LZI5vxijUCj5EI4e+x5DRqVUvyP8KCZrC
+-AiNyoDP85T+hBZaSXK3aYGpVwelyj3bvo1GrTNwNWLw=
+------END RSA PRIVATE KEY-----
++-----BEGIN PRIVATE KEY-----
++MIIJQgIBADANBgkqhkiG9w0BAQEFAASCCSwwggkoAgEAAoICAQDolKefhOG5aLih
+++6vq1TUfDaGF9l5AVvqvq6ctc7ubLEUs26sQIw8fXZIbe0JZ31ZQ09NCb6TlnXrj
++6J+fdeXnUEbGOFJ5epih9va2tzrVGtf8giV7BlSUygo+5OAcW+Zmc2/305WZ7TC3
++UyATH1G8OthSoq9VoyiHCfXwqBvCWhnilTuEYeadHs3eFFFCHa9QV5eTanastr0z
++LBA54zrA93oJL/CNkijeDup/wt8FmKTDlmGZBqGYis+6ybP4v3s+27FeyZcHc05Y
++aSc5HDklRQT+iZRDsUzTcWdcLSsuz7WRprEkgE6tnuvm8N/AHjqdF5886nBo7Qw6
++HwZk+zhc2Vo0vVWUuvgzjntkB1pXtZwh3B8h+JLuiEZbK/cZETQCJTn57xx8aiVH
++p6HmmeKEA4wgSktSl8oCTv7S+wS00FZ/8StRJj7yjZ481pOLUT54m1IYbOet+aqT
++lP2D6hQYdSY1a7mW7FnAwIUXHsNLsTjVzmvRPuJbbUPckmGtQC71qibgF+4LtgbA
++TC8qn5vNdWJwOwiBTMjvh5appCxX7+S/8SEQF0e5dumBjtFcFwhozH8+DVTzDJHu
++Jwe6mvTZKV0AUCjJrN0M3eSVtB8vUbo+TvBj3BWZldLcI3dbiTw/3AI5Fi2l43Tb
++CdekFnNp4IUEUuh2KikV+o/glzsbqQIDAQABAoICAFw1q6tr5I48vY7DF+rXsuLn
++5ZUWE1IQ6fzB4lr72nJv/9EEGnMgYzt9PpMUsD6vdCpBgS2C0+6RHArFzJtNA+RM
++iHLIG7K7702veyr/xBx/MwiSlMeMv/XpkFxVI6E6skMGG2s3AMXxKvJTy5CpRx+I
++eQFyLG+Ya1X2lgJes/q+/CpAHkOjCOpcLySQC5NZ74q734V7nSdmn+Zs3tYEh+O/
++eiuwTP/j5b38Te5vVTqDxTciJPmljmXLCwa0N100lWlbcpvw8qbqiTI2Jm3XCbUE
++AzHjW9vmrF3cRS1fXxKFGShw3SRqlkbxjfeWoi8qDPUBS4m8LOr8qG9Wo5Nfon0z
++zLP4bci3zHDvVcaaZrrsUBs/yZbg+Dgka1DmX7ekmeccr2yTdKDFgPupYUyxVbTl
++a9ZLJysjFD7rgBv1ZclHonLp6Vbm+ZoTqvteo4ikAy6L9RtBWJ23XEK34PkP/+c5
++2vWZaOrnjSeBHbFce8cdJSxqWpP+eSCI5I9XbDrYFIsQ/gqKgtzDKy2ihJ2Y8STL
++yO4hyFPFjxc+Gg4/P2PpmT5CY2ty44M0BWs+JGW96CJPrrplf2lmQUQJj5LZY66X
++Z/4C9L7ZYtKZ+bs5SvU46yWugAvQZX22Xm9xLXWyVXRdx3bj+3M3fDnF9di/zdbh
++CgLx7oWPNrXc7FCajnn9AoIBAQD5FMYwRpw9NWT9WDxQwx+cSI4Icbd88ByTW63S
++LzeRwZA0J9/SfwO+aBRupzc9GkGXCiZcGMw3AGsCtig8yFlw8E5KnzN7KlftDMnM
++9NUxxzlR8VwKyLnZfG7sDTl057ZlUujnqhmt/F8F7dIy7FVO1dE/8nngA+FYTCOG
++UZdGjwyBDlDM0JJdUWGY3xslutcpCDN5mzSTKjy9drMvImAshRawxRF6WBpn7vr2
++nC6vciqfx1Mzx1vyk0Jm0ilaydDdLMADjt/iL4Nkr0BEs4k+UzQiKDwp8gu7abQ1
++eBfxd9Iar4htQa2I1Ewl6P01G/q+ZYwgHhJ9RVn4AxQXefILAoIBAQDvCouORdQX
++C8wsyp7MwXlF/3NQeNN5/+B2mhbxrBOf7PmMCXLnkRWcjwJtzypWFqJ0sqai/2+0
++bqbMcjX5maT8stT2shl3zXe/Ejt2e3TBYpc1tyuses8Kb5BMU8hu6tTd3G2CMXpD
++dT6DVemJZCTtwj9aBNIxSizvlgMolJnCpzhPnlfHSI6E+g3m/LTTo3HwbjMSw/Uq
++irgjOpI2wSBB6LZPSgjvfcYPRyWUk16L4A5uSX0cADnovDFLa5/h0wJvN/OoCSQg
++rLCXG5E18EyL5Wc58BCY1ZvxmjG3lQtgPxYu2Jwc36R/y/JKlxW5suER5ZNpbbD4
++uOyTt2VxMQ2bAoIBAQC5+MzRFqdo/AjfL5Y5JrbfVTzXCTDa09xCGd16ZU60QTWN
+++4ed/r+o1sUKqUcRFB2MzEM/2DQBjQpZB/CbEWvWa1XJWXxypXbowveZU+QqOnmN
++uQvj8WLyA3o+PNF9e9QvauwCrHpn8VpxbtPWuaYoKnUFreFZZQxHhPGxRBIS2JOZ
++eDrT8ZaWnkCkh1AZp5smQ71LOprSlmKrg4jd1GjCVMxQR5N5KXbtyv0OTCZ/UFqK
++2aRBsMPyJgkaBChkZPLRcKwc+/wlQRx1fHQb14DNTApMxoXFO7eOwqmOkpAt9iyl
++SBIwoS0UUI5ab88+bBmXNvKcuFdNuQ4nowTJUn9pAoIBADMNkILBXSvS5DeIyuO2
++Sp1tkoZUV+5NfPY3sMDK3KIibaW/+t+EOBZo4L7tKQCb8vRzl21mmsfxfgRaPDbj
++3r3tv9g0b4YLxxBy52pFscj/soXRai17SS7UZwA2QK+XzgDYbDcLNC6mIsTQG4Gx
++dsWk3/zs3KuUSQaehmwrWK+fIUK38c1pLK8v7LoxrLkqxlHwZ04RthHw8KTthH7X
++Pnl1J0LF8CSeOyfWLSuPUfkT0GEzptnNHpEbaHfQM6R6eaGhVJPF6AZme4y6YYgg
++m2ihhSt1n0XVEWpHYWjxFy3mK2mz75unFC4LM+NEY2p2zuUQoCw7NjnY3QYrfCnx
++rRMCggEAXeXsMSLFjjyuoL7iKbAxo52HD/P0fBoy58LyRcwfNVr0lvYan4pYEx+o
++KijIh9K16PqXZXKMA9v003B+ulmF8bJ7SddCZ5NGvnFhUTDe4DdTKgp2RuwQ3Bsc
++3skPIDbhVETyOLCtys34USHrq8U/0DlGY3eLRfxw9GnbKxSBGa/KEu/qQLPNUo50
++7xHZDg7GKeC3kqNJeqKM9rkp0VzIGkEnaD9127LeNDmERDfftxJzFoC/THvUBLfU
++6Sus2ZYwRE8VFvKC30Q45t/c54X3IuhYvAuiCuTmyfE4ruyzyOwKzhUkeeLq1APX
++g0veFbyfzlJ0q8qzD/iffqqIa2ZSmQ==
++-----END PRIVATE KEY-----
+diff --git a/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp b/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
+index 7ba3715e13..752aa122f6 100644
+--- a/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
++++ b/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
+@@ -179,6 +179,7 @@ void tst_QAccessibilityLinux::initTestCase()
+     QVERIFY(!address.isEmpty());
+ 
+     m_window = new AccessibleTestWindow();
++    m_window->setObjectName("mainWindow"_L1);
+     m_window->show();
+ 
+     QVERIFY(QTest::qWaitForWindowExposed(m_window));
+@@ -236,8 +237,11 @@ bool hasState(QDBusInterface *interface, AtspiStateType state)
+ void tst_QAccessibilityLinux::testLabel()
+ {
+     QLabel *l = new QLabel(m_window);
++    l->setObjectName("theObjectName"_L1);
+     l->setText("Hello A11y");
+     m_window->addWidget(l);
++    auto a11yEmpty = new QLabel(m_window);
++    m_window->addWidget(l);
+ 
+     // Application
+     QCOMPARE(getParent(mainWindow), QLatin1String(ATSPI_DBUS_PATH_ROOT));
+@@ -249,6 +253,8 @@ void tst_QAccessibilityLinux::testLabel()
+     QCOMPARE(getChildren(labelInterface).count(), 0);
+     QCOMPARE(labelInterface->call(QDBus::Block, "GetRoleName").arguments().first().toString(), QLatin1String("label"));
+     QCOMPARE(labelInterface->call(QDBus::Block, "GetRole").arguments().first().toUInt(), 29u);
++    QCOMPARE(labelInterface->call(QDBus::Block, "GetAccessibleId").arguments().first().toString(),
++             QLatin1String("mainWindow.theObjectName"));
+     QCOMPARE(getParent(labelInterface), mainWindow->path());
+     QVERIFY(!hasState(labelInterface, ATSPI_STATE_EDITABLE));
+     QVERIFY(hasState(labelInterface, ATSPI_STATE_READ_ONLY));
+@@ -256,7 +262,12 @@ void tst_QAccessibilityLinux::testLabel()
+     l->setText("New text");
+     QCOMPARE(labelInterface->property("Name").toString(), l->text());
+ 
++    auto *a11yEmptyInterface = getInterface(children.at(1), "org.a11y.atspi.Accessible");
++    QCOMPARE(a11yEmptyInterface->call(QDBus::Block, "GetAccessibleId").arguments().first().toString(),
++             QLatin1String("mainWindow.QLabel"));
++
+     m_window->clearChildren();
++    delete a11yEmptyInterface;
+     delete labelInterface;
+ }
+ 
+diff --git a/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+index 76df61c892..6d6d65b791 100644
+--- a/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
++++ b/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2022 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the test suite of the Qt Toolkit.
+@@ -68,6 +68,8 @@ private slots:
+     void query_exec();
+     void execErrorRecovery_data() { generic_data(); }
+     void execErrorRecovery();
++    void prematureExec_data() { generic_data(); }
++    void prematureExec();
+     void first_data() { generic_data(); }
+     void first();
+     void next_data() { generic_data(); }
+@@ -2770,6 +2772,35 @@ void tst_QSqlQuery::execErrorRecovery()
+     QVERIFY_SQL( q, exec() );
+ }
+ 
++void tst_QSqlQuery::prematureExec()
++{
++    QFETCH(QString, dbName);
++    // We only want the engine name, for addDatabase():
++    int cut = dbName.indexOf(QChar('@'));
++    if (cut < 0)
++        QSKIP("Failed to parse database type out of name");
++    dbName.truncate(cut);
++    cut = dbName.indexOf(QChar('_'));
++    if (cut >= 0)
++        dbName = dbName.mid(cut + 1);
++
++    auto db = QSqlDatabase::addDatabase(dbName);
++    QSqlQuery q(db);
++
++    QTest::ignoreMessage(QtWarningMsg,
++                         "QSqlDatabasePrivate::removeDatabase: connection "
++                         "'qt_sql_default_connection' is still in use, all "
++                         "queries will cease to work.");
++    QTest::ignoreMessage(QtWarningMsg,
++                         "QSqlDatabasePrivate::addDatabase: duplicate connection name "
++                         "'qt_sql_default_connection', old connection removed.");
++    auto otherDb = QSqlDatabase::addDatabase(dbName);
++
++    QTest::ignoreMessage(QtWarningMsg, "QSqlQuery::exec: called before driver has been set up");
++    // QTBUG-100037: shouldn't crash !
++    QVERIFY(!q.exec("select stuff from TheVoid"));
++}
++
+ void tst_QSqlQuery::lastInsertId()
+ {
+     QFETCH( QString, dbName );
+diff --git a/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp b/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
+index 4aa3f8d60b..d2050a61aa 100644
+--- a/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
++++ b/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
+@@ -115,6 +115,10 @@ void tst_QAbstractItemModelTester::standardItemModelZeroColumns()
+     // QTBUG-92886
+     model.insertRows(0, 5);
+     model.removeRows(1, 2);
++
++    const QModelIndex parentIndex = model.index(0, 0);
++    model.insertRows(0, 5, parentIndex);
++    model.removeRows(1, 2, parentIndex);
+ }
+ 
+ void tst_QAbstractItemModelTester::testInsertThroughProxy()
+diff --git a/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json b/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
+index 12a4a22a19..ce518e78fb 100644
+--- a/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
++++ b/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
+@@ -668,50 +668,6 @@
+         "inputFile": "task192552.h",
+         "outputRevision": 67
+     },
+-    {
+-        "classes": [
+-            {
+-                "className": "InlineSlotsWithThrowDeclaration",
+-                "object": true,
+-                "qualifiedClassName": "InlineSlotsWithThrowDeclaration",
+-                "slots": [
+-                    {
+-                        "access": "public",
+-                        "name": "a",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "b",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "c",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "d",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "e",
+-                        "returnType": "void"
+-                    }
+-                ],
+-                "superClasses": [
+-                    {
+-                        "access": "public",
+-                        "name": "QObject"
+-                    }
+-                ]
+-            }
+-        ],
+-        "inputFile": "task189996.h",
+-        "outputRevision": 67
+-    },
+     {
+         "classes": [
+             {
+diff --git a/qtbase/tests/auto/tools/moc/moc.pro b/qtbase/tests/auto/tools/moc/moc.pro
+index c324b3a8cd..4aceb78dc0 100644
+--- a/qtbase/tests/auto/tools/moc/moc.pro
++++ b/qtbase/tests/auto/tools/moc/moc.pro
+@@ -15,7 +15,7 @@ cross_compile: DEFINES += MOC_CROSS_COMPILED
+ HEADERS += using-namespaces.h no-keywords.h task87883.h c-comments.h backslash-newlines.h oldstyle-casts.h \
+            slots-with-void-template.h qinvokable.h namespaced-flags.h trigraphs.h \
+            escapes-in-string-literals.h cstyle-enums.h qprivateslots.h gadgetwithnoenums.h \
+-           dir-in-include-path.h single_function_keyword.h task192552.h task189996.h \
++           dir-in-include-path.h single_function_keyword.h task192552.h \
+            task234909.h task240368.h pure-virtual-signals.h cxx11-enums.h \
+            cxx11-final-classes.h \
+            cxx11-explicit-override-control.h \
+diff --git a/qtbase/tests/auto/tools/moc/task189996.h b/qtbase/tests/auto/tools/moc/task189996.h
+deleted file mode 100644
+index f94a051b3a..0000000000
+--- a/qtbase/tests/auto/tools/moc/task189996.h
++++ /dev/null
+@@ -1,47 +0,0 @@
+-/****************************************************************************
+-**
+-** Copyright (C) 2016 The Qt Company Ltd.
+-** Contact: https://www.qt.io/licensing/
+-**
+-** This file is part of the test suite of the Qt Toolkit.
+-**
+-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+-** 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 General Public License Usage
+-** Alternatively, this file may be used under the terms of the GNU
+-** General Public License version 3 as published by the Free Software
+-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+-** 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-3.0.html.
+-**
+-** $QT_END_LICENSE$
+-**
+-****************************************************************************/
+-// inline functions can have throw declarations
+-
+-#ifndef TASK189996_H
+-#define TASK189996_H
+-
+-#include <QObject>
+-
+-class InlineSlotsWithThrowDeclaration : public QObject
+-{
+-    Q_OBJECT
+-
+-public slots:
+-    void a() throw() { }
+-    void b() const throw() { }
+-    void c() throw();
+-    void d() throw(int) { }
+-    void e() const throw(int,double) { }
+-};
+-
+-#endif
+diff --git a/qtbase/tests/auto/tools/moc/tst_moc.cpp b/qtbase/tests/auto/tools/moc/tst_moc.cpp
+index c716aead21..15dd9e41e5 100644
+--- a/qtbase/tests/auto/tools/moc/tst_moc.cpp
++++ b/qtbase/tests/auto/tools/moc/tst_moc.cpp
+@@ -631,7 +631,6 @@ public:
+ private slots:
+     void initTestCase();
+ 
+-    void slotWithException() throw(MyStruct);
+     void dontStripNamespaces();
+     void oldStyleCasts();
+     void warnOnExtraSignalSlotQualifiaction();
+@@ -673,7 +672,6 @@ private slots:
+     void templateGtGt();
+     void qprivateslots();
+     void qprivateproperties();
+-    void inlineSlotsWithThrowDeclaration();
+     void warnOnPropertyWithoutREAD();
+     void constructors();
+     void typenameWithUnsigned();
+@@ -784,12 +782,6 @@ void tst_Moc::initTestCase()
+ #endif
+ }
+ 
+-void tst_Moc::slotWithException() throw(MyStruct)
+-{
+-    // be happy
+-    QVERIFY(true);
+-}
+-
+ void tst_Moc::dontStripNamespaces()
+ {
+     Sender sender;
+@@ -824,7 +816,7 @@ void tst_Moc::oldStyleCasts()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-Wold-style-cast" << "-I" << "."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -894,7 +886,7 @@ void tst_Moc::inputFileNameWithDotsButNoExtension()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-I" << ".."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -1174,7 +1166,7 @@ void tst_Moc::ignoreOptionClashes()
+     QStringList gccArgs;
+     gccArgs << "-c" << "-x" << "c++" << "-I" << ".."
+          << "-I" << qtIncludePath << "-I" << includeDir << "-o" << "/dev/null"
+-         << "-fPIC" << "-std=c++11" <<  "-";
++         << "-fPIC" << "-std=c++1z" <<  "-";
+     proc.start("gcc", gccArgs);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -1593,21 +1585,6 @@ void tst_Moc::qprivateproperties()
+ 
+ }
+ 
+-#include "task189996.h"
+-
+-void InlineSlotsWithThrowDeclaration::c() throw() {}
+-
+-void tst_Moc::inlineSlotsWithThrowDeclaration()
+-{
+-    InlineSlotsWithThrowDeclaration tst;
+-    const QMetaObject *mobj = tst.metaObject();
+-    QVERIFY(mobj->indexOfSlot("a()") != -1);
+-    QVERIFY(mobj->indexOfSlot("b()") != -1);
+-    QVERIFY(mobj->indexOfSlot("c()") != -1);
+-    QVERIFY(mobj->indexOfSlot("d()") != -1);
+-    QVERIFY(mobj->indexOfSlot("e()") != -1);
+-}
+-
+ void tst_Moc::warnOnPropertyWithoutREAD()
+ {
+ #ifdef MOC_CROSS_COMPILED
+@@ -1869,7 +1846,7 @@ void tst_Moc::notifyError()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-I" << "."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+diff --git a/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+index c355ee9665..88c09de8e0 100644
+--- a/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
++++ b/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+@@ -251,6 +251,7 @@ private slots:
+     void testResetCachedSizeHint();
+     void statusTips();
+     void testRemovingColumnsViaLayoutChanged();
++    void testModelMovingColumns();
+ 
+ protected:
+     void setupTestData(bool use_reset_model = false);
+@@ -360,6 +361,12 @@ public:
+         endRemoveColumns();
+     }
+ 
++    void moveColumn(int from, int to)
++    {
++        beginMoveColumns(QModelIndex(), from, from, QModelIndex(), to);
++        endMoveColumns();
++    }
++
+     void cleanup()
+     {
+         emit layoutAboutToBeChanged();
+@@ -3627,5 +3634,18 @@ void tst_QHeaderView::testRemovingColumnsViaLayoutChanged()
+     // The main point of this test is that the section-size restoring code didn't go out of bounds.
+ }
+ 
++void tst_QHeaderView::testModelMovingColumns()
++{
++    QtTestModel model(10, 10);
++    QHeaderView hv(Qt::Horizontal);
++    hv.setModel(&model);
++    hv.resizeSections(QHeaderView::ResizeToContents);
++    hv.show();
++
++    QPersistentModelIndex index3 = model.index(0, 3);
++    model.moveColumn(3, 1);
++    QCOMPARE(index3.column(), 1);
++}
++
+ QTEST_MAIN(tst_QHeaderView)
+ #include "tst_qheaderview.moc"
+diff --git a/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+index 761357b252..06bb706074 100644
+--- a/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
++++ b/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+@@ -397,6 +397,7 @@ private slots:
+     void checkHeaderMinSize();
+ 
+     void resizeToContents();
++    void resizeToContentsSpans();
+ 
+     void tabFocus();
+     void bigModel();
+@@ -3721,6 +3722,70 @@ void tst_QTableView::resizeToContents()
+ 
+ }
+ 
++
++class SpanModel : public QAbstractTableModel
++{
++public:
++    SpanModel(bool sectionsMoved)
++        : _sectionsMoved(sectionsMoved)
++    {}
++    int columnCount(const QModelIndex & = {}) const override { return 2; }
++    int rowCount(const QModelIndex & = {}) const override { return 1; }
++    QVariant data(const QModelIndex &idx, int role = Qt::DisplayRole) const override
++    {
++        if (role != Qt::DisplayRole)
++            return QVariant();
++        const int col = _sectionsMoved ? 1 - idx.column() : idx.column();
++        if (col == 0)
++            return "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.";
++        return QVariant();
++    }
++private:
++    bool _sectionsMoved;
++};
++
++
++void tst_QTableView::resizeToContentsSpans()
++{
++    SpanModel model1(false);
++    SpanModel model2(true);
++    QTableView view1, view2, view3;
++    view1.setModel(&model1);
++    view2.setModel(&model2);
++    view2.horizontalHeader()->moveSection(0, 1);
++    view3.setModel(&model1);
++
++    view1.setSpan(0, 0, 1, 2);
++    view2.setSpan(0, 1, 1, 2);
++    view1.show();
++    view2.show();
++    view3.show();
++    QVERIFY(QTest::qWaitForWindowExposed(&view1));
++    QVERIFY(QTest::qWaitForWindowExposed(&view2));
++    QVERIFY(QTest::qWaitForWindowExposed(&view3));
++    view1.setColumnWidth(0, 100);
++    view1.setColumnWidth(1, 100);
++    view2.setColumnWidth(0, 100);
++    view2.setColumnWidth(1, 100);
++    view3.setColumnWidth(0, 200);
++
++    view1.resizeRowToContents(0);
++    view2.resizeRowToContents(0);
++    view3.resizeRowToContents(0);
++    QCOMPARE(view1.rowHeight(0), view3.rowHeight(0));
++    QCOMPARE(view2.rowHeight(0), view3.rowHeight(0));
++
++    view3.resizeColumnToContents(0);
++    view3.resizeRowToContents(0);
++    // height should be only 1 text line for easy testing
++    view1.setRowHeight(0, view3.verticalHeader()->sectionSize(0));
++    view2.setRowHeight(0, view3.verticalHeader()->sectionSize(0));
++    view1.resizeColumnToContents(0);
++    view2.resizeColumnToContents(1);
++    QCOMPARE(view1.columnWidth(0), view3.columnWidth(0) - view1.columnWidth(1));
++    QCOMPARE(view2.columnWidth(0), view3.columnWidth(0) - view2.columnWidth(1));
++}
++
+ QT_BEGIN_NAMESPACE
+ extern bool Q_WIDGETS_EXPORT qt_tab_all_widgets(); // qapplication.cpp
+ QT_END_NAMESPACE
+diff --git a/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+index a3b8ef78d8..4955cebd5d 100644
+--- a/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
++++ b/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+@@ -1498,7 +1498,7 @@ void tst_QApplication::desktopSettingsAware()
+     environment += QLatin1String("QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM=1");
+     testProcess.setEnvironment(environment);
+ #endif
+-    testProcess.start("desktopsettingsaware_helper");
++    testProcess.start("./desktopsettingsaware_helper");
+     QVERIFY2(testProcess.waitForStarted(),
+              qPrintable(QString::fromLatin1("Cannot start 'desktopsettingsaware_helper': %1").arg(testProcess.errorString())));
+     QVERIFY(testProcess.waitForFinished(10000));
+@@ -2452,7 +2452,7 @@ void tst_QApplication::qtbug_12673()
+ #if QT_CONFIG(process)
+     QProcess testProcess;
+     QStringList arguments;
+-    testProcess.start("modal_helper", arguments);
++    testProcess.start("./modal_helper", arguments);
+     QVERIFY2(testProcess.waitForStarted(),
+              qPrintable(QString::fromLatin1("Cannot start 'modal_helper': %1").arg(testProcess.errorString())));
+     QVERIFY(testProcess.waitForFinished(20000));
+diff --git a/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp b/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
+index eb108a40de..dca5528c1b 100644
+--- a/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
+@@ -41,6 +41,7 @@
+ 
+ #include <private/qguiapplication_p.h>
+ #include <qpa/qplatformintegration.h>
++#include <qpa/qplatformtheme.h>
+ 
+ class tst_QAbstractButton : public QObject
+ {
+@@ -76,6 +77,8 @@ private slots:
+     void keyNavigation();
+ #endif
+ 
++    void buttonPressKeys();
++
+ protected slots:
+     void onClicked();
+     void onToggled( bool on );
+@@ -269,7 +272,13 @@ void tst_QAbstractButton::setAutoRepeat()
+         QCOMPARE(press_count, click_count);
+         QVERIFY(click_count > 1);
+         break;
+-    case 4:
++    case 4: {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(Qt::Key_Enter)) {
++            QSKIP("platform theme has Key_Enter in ButtonPressKeys");
++        }
+         // check that pressing ENTER has no effect when autorepeat is false
+         testWidget->setDown( false );
+         testWidget->setAutoRepeat( false );
+@@ -286,7 +295,14 @@ void tst_QAbstractButton::setAutoRepeat()
+ 
+         QVERIFY( click_count == 0 );
+         break;
+-    case 5:
++    }
++    case 5: {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(Qt::Key_Enter)) {
++            QSKIP("platform theme has Key_Enter in ButtonPressKeys");
++        }
+         // check that pressing ENTER has no effect when autorepeat is true
+         testWidget->setDown( false );
+         testWidget->setAutoRepeat( true );
+@@ -304,6 +320,7 @@ void tst_QAbstractButton::setAutoRepeat()
+ 
+         QVERIFY( click_count == 0 );
+         break;
++    }
+     case 6:
+         // verify autorepeat is off by default.
+         MyButton tmp( 0);
+@@ -651,5 +668,16 @@ void tst_QAbstractButton::keyNavigation()
+ }
+ #endif
+ 
++void tst_QAbstractButton::buttonPressKeys()
++{
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(testWidget, buttonPressKeys[i]);
++        QCOMPARE(click_count, i + 1);
++    }
++}
++
+ QTEST_MAIN(tst_QAbstractButton)
+ #include "tst_qabstractbutton.moc"
+diff --git a/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+index 32437050f5..46b5af6d63 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+@@ -168,6 +168,7 @@ private slots:
+     void checkMenuItemPosWhenStyleSheetIsSet();
+     void checkEmbeddedLineEditWhenStyleSheetIsSet();
+     void propagateStyleChanges();
++    void buttonPressKeys();
+ 
+ private:
+     PlatformInputContext m_platformInputContext;
+@@ -1682,6 +1683,16 @@ void tst_QComboBox::setModel()
+     QCOMPARE(box.rootModelIndex(), rootModelIndex);
+     box.setModel(box.model());
+     QCOMPARE(box.rootModelIndex(), rootModelIndex);
++
++    // check that setting the same model as the completer's doesn't crash
++    QCompleter *completer = new QCompleter(&box);
++    box.setEditable(true);
++    box.setCompleter(completer);
++    auto *listModel = new QStringListModel({ "one", "two" }, completer);
++    completer->setModel(listModel);
++    QCOMPARE(listModel->rowCount(), 2); // make sure it wasn't deleted
++    box.setModel(listModel);
++    QCOMPARE(listModel->rowCount(), 2); // make sure it wasn't deleted
+ }
+ 
+ void tst_QComboBox::setCustomModelAndView()
+@@ -3632,5 +3643,24 @@ void tst_QComboBox::propagateStyleChanges()
+     QVERIFY(frameStyle.inquired);
+ }
+ 
++void tst_QComboBox::buttonPressKeys()
++{
++    QComboBox comboBox;
++    comboBox.setEditable(false);
++    comboBox.addItem(QString::number(1));
++    comboBox.addItem(QString::number(2));
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(&comboBox, buttonPressKeys[i]);
++        // On some platforms, a window will not be immediately visible,
++        // but take some event-loop iterations to complete.
++        // Using QTRY_VERIFY to deal with that.
++        QTRY_VERIFY(comboBox.view()->isVisible());
++        comboBox.hidePopup();
++    }
++}
++
+ QTEST_MAIN(tst_QComboBox)
+ #include "tst_qcombobox.moc"
+diff --git a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
+index be3cfcd104..c228fdfcca 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
++++ b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qcommandlinkbutton
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qcommandlinkbutton.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
+index 0044d33c66..4cf06296e4 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
+@@ -40,6 +40,9 @@
+ #include <QGridLayout>
+ #include <QPainter>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ class tst_QCommandLinkButton : public QObject
+ {
+     Q_OBJECT
+@@ -223,6 +226,13 @@ void tst_QCommandLinkButton::setAutoRepeat()
+     // check that pressing ENTER has no effect
+     resetCounters();
+     testWidget->setDown( false );
++    // Skip after reset if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
+     testWidget->setAutoRepeat( false );
+     QTest::keyPress( testWidget, Qt::Key_Enter );
+ 
+@@ -255,6 +265,14 @@ void tst_QCommandLinkButton::pressed()
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+ 
++    // Skip if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
++
+     QTest::keyPress( testWidget,Qt::Key_Enter );
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+diff --git a/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro b/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
+index 4a5e76ff65..a235fa1fac 100644
+--- a/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
++++ b/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qgroupbox
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qgroupbox.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp b/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
+index 4fb5d262ca..d8d7562b73 100644
+--- a/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
+@@ -35,6 +35,9 @@
+ #include <QRadioButton>
+ #include <QDialog>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ #include "qgroupbox.h"
+ 
+ class tst_QGroupBox : public QObject
+@@ -69,6 +72,7 @@ private slots:
+     void propagateFocus();
+     void task_QTBUG_19170_ignoreMouseReleaseEvent();
+     void task_QTBUG_15519_propagateMouseEvents();
++    void buttonPressKeys();
+ 
+ private:
+     bool checked;
+@@ -610,6 +614,20 @@ void tst_QGroupBox::task_QTBUG_15519_propagateMouseEvents()
+     QCOMPARE(parent.mouseMoved, true);
+ }
+ 
++void tst_QGroupBox::buttonPressKeys()
++{
++    QGroupBox groupBox;
++    groupBox.setCheckable(true);
++    QSignalSpy clickedSpy(&groupBox, &QGroupBox::clicked);
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(&groupBox, buttonPressKeys[i]);
++        QCOMPARE(clickedSpy.length(), i + 1);
++    }
++}
++
+ void tst_QGroupBox::sendMouseMoveEvent(QWidget *widget, const QPoint &localPos)
+ {
+     // Send a MouseMove event without actually moving the pointer
+diff --git a/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro b/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
+index 353ad06ca2..e55f6148f2 100644
+--- a/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
++++ b/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qpushbutton
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qpushbutton.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp b/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
+index e818514a79..4043e9326a 100644
+--- a/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
+@@ -41,6 +41,9 @@
+ #include <QStyleFactory>
+ #include <QTabWidget>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ class tst_QPushButton : public QObject
+ {
+ Q_OBJECT
+@@ -212,6 +215,13 @@ void tst_QPushButton::autoRepeat()
+     // check that pressing ENTER has no effect
+     resetCounters();
+     testWidget->setDown( false );
++    // Skip after reset if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
+     testWidget->setAutoRepeat( false );
+     QTest::keyPress( testWidget, Qt::Key_Enter );
+ 
+@@ -247,6 +257,14 @@ void tst_QPushButton::pressed()
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+ 
++    // Skip if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
++
+     QTest::keyPress( testWidget,Qt::Key_Enter );
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+diff --git a/qtbase/tests/manual/rhi/cubemap_render/buildshader.bat b/qtbase/tests/manual/rhi/cubemap_render/buildshader.bat
+old mode 100755
+new mode 100644
+Submodule qtconnectivity e957d481..056294c0:
+diff --git a/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp b/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
+index e2635fae..a8b8e3b9 100644
+--- a/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
++++ b/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
+@@ -563,9 +563,11 @@ void HciManager::handleHciAclPacket(const quint8 *data, int size)
+ 
+ void HciManager::handleLeMetaEvent(const quint8 *data)
+ {
+-    // Spec v4.2, Vol 2, part E, 7.7.65ff
++    // Spec v5.3, Vol 4, part E, 7.7.65.*
+     switch (*data) {
+-    case 0x1: {
++    case 0x1: // HCI_LE_Connection_Complete
++    case 0xA: // HCI_LE_Enhanced_Connection_Complete
++    {
+         const quint16 handle = bt_get_le16(data + 2);
+         emit connectionComplete(handle);
+         break;
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp b/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
+index 6a93143b..4a18cfc7 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
+@@ -320,7 +320,10 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_finishSdpScan(QBluetoothServiceD
+             for (const QBluetoothUuid &id : serviceClassUuids) {
+                 if (id.minimumSize() == 16) {
+                     serviceInfo.setServiceUuid(id);
+-                    serviceInfo.setServiceName(QBluetoothServiceDiscoveryAgent::tr("Custom Service"));
++                    if (serviceInfo.serviceName().isEmpty()) {
++                        serviceInfo.setServiceName(
++                                    QBluetoothServiceDiscoveryAgent::tr("Custom Service"));
++                    }
+                     QBluetoothServiceInfo::Sequence modSeq =
+                             serviceInfo.attribute(QBluetoothServiceInfo::ServiceClassIds).value<QBluetoothServiceInfo::Sequence>();
+                     modSeq.removeOne(QVariant::fromValue(id));
+@@ -334,8 +337,10 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_finishSdpScan(QBluetoothServiceD
+                 qCDebug(QT_BT_BLUEZ) << "Discovered services" << discoveredDevices.at(0).address().toString()
+                                      << serviceInfo.serviceName() << serviceInfo.serviceUuid()
+                                      << ">>>" << serviceInfo.serviceClassUuids();
+-
+-                emit q->serviceDiscovered(serviceInfo);
++                // Use queued connection to allow us finish the service looping; the application
++                // might call stop() when it has detected the service-of-interest.
++                QMetaObject::invokeMethod(q, "serviceDiscovered", Qt::QueuedConnection,
++                                          Q_ARG(QBluetoothServiceInfo, serviceInfo));
+             }
+         }
+     }
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp b/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
+index e4d85447..aadd4755 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
+@@ -593,7 +593,7 @@ void QBluetoothSocket::setSocketState(QBluetoothSocket::SocketState state)
+ bool QBluetoothSocket::canReadLine() const
+ {
+     Q_D(const QBluetoothSocketBase);
+-    return d->canReadLine();
++    return d->canReadLine() || QIODevice::canReadLine();
+ }
+ 
+ /*!
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp b/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
+index 084aa958..d6aa17a7 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
+@@ -284,6 +284,10 @@ void QBluetoothSocketPrivateBluezDBus::connectToService(
+         return;
+     }
+ 
++    if (service.socketProtocol() != QBluetoothServiceInfo::Protocol::UnknownProtocol)
++        socketType = service.socketProtocol();
++    qCDebug(QT_BT_BLUEZ) << "Socket protocol used:" << socketType;
++
+     connectToService(service.device().address(), targetService, openMode);
+ }
+ 
+diff --git a/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp b/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
+index 05bc1a0f..a7b5ef1f 100644
+--- a/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
++++ b/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
+@@ -142,7 +142,7 @@ void tst_QBluetoothSocket::initTestCase()
+     qDebug() << "Starting discovery";
+ 
+     sda->setUuidFilter(QBluetoothUuid(QString(TEST_SERVICE_UUID)));
+-    sda->start(QBluetoothServiceDiscoveryAgent::MinimalDiscovery);
++    sda->start(QBluetoothServiceDiscoveryAgent::FullDiscovery);
+ 
+     for (int connectTime = MaxConnectTime; !done_discovery && connectTime > 0; connectTime -= 1000)
+         QTest::qWait(1000);
+Submodule qtdeclarative f5701f0d..8defe7bf:
+diff --git a/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h b/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
+index b65b994d6c..15a8cd6878 100644
+--- a/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
++++ b/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
+@@ -86,7 +86,7 @@ public:
+         if (QTypeInfo<T>::isComplex) {
+             for (int i = 0; i < count; ++i)
+                 new (data + i) T(vector.at(i));
+-        } else {
++        } else if (count) {
+             memcpy(data, static_cast<const void*>(vector.constData()), count * sizeof(T));
+         }
+     }
+diff --git a/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp b/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
+index e57cdd8278..94613598af 100644
+--- a/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
++++ b/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
+@@ -1145,8 +1145,7 @@ void Heap::QObjectWrapper::markObjects(Heap::Base *that, QV4::MarkStack *markSta
+ void QObjectWrapper::destroyObject(bool lastCall)
+ {
+     Heap::QObjectWrapper *h = d();
+-    if (!h->internalClass)
+-        return; // destroyObject already got called
++    Q_ASSERT(h->internalClass);
+ 
+     if (h->object()) {
+         QQmlData *ddata = QQmlData::get(h->object(), false);
+@@ -1176,7 +1175,7 @@ void QObjectWrapper::destroyObject(bool lastCall)
+         }
+     }
+ 
+-    h->~Data();
++    h->destroy();
+ }
+ 
+ 
+diff --git a/qtdeclarative/src/qml/memory/qv4mm.cpp b/qtdeclarative/src/qml/memory/qv4mm.cpp
+index 06caf04e5a..da149a67c4 100644
+--- a/qtdeclarative/src/qml/memory/qv4mm.cpp
++++ b/qtdeclarative/src/qml/memory/qv4mm.cpp
+@@ -981,7 +981,7 @@ void MemoryManager::sweep(bool lastSweep, ClassDestroyStatsCallback classCountPt
+ 
+     if (MultiplyWrappedQObjectMap *multiplyWrappedQObjects = engine->m_multiplyWrappedQObjects) {
+         for (MultiplyWrappedQObjectMap::Iterator it = multiplyWrappedQObjects->begin(); it != multiplyWrappedQObjects->end();) {
+-            if (!it.value().isNullOrUndefined())
++            if (it.value().isNullOrUndefined())
+                 it = multiplyWrappedQObjects->erase(it);
+             else
+                 ++it;
+diff --git a/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp b/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
+index 2079a8ed04..a577cb2351 100644
+--- a/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
++++ b/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
+@@ -389,6 +389,12 @@ void QQmlDelegateModelPrivate::connectToAbstractItemModel()
+                       q,  QQmlDelegateModel, SLOT(_q_rowsRemoved(QModelIndex,int,int)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
+                       q,  QQmlDelegateModel, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsInserted(QModelIndex,int,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsInserted(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsRemoved(QModelIndex,int,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsRemoved(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsMoved(QModelIndex,int,int,QModelIndex,int)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
+                       q, QQmlDelegateModel, SLOT(_q_dataChanged(QModelIndex,QModelIndex,QVector<int>)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
+@@ -413,6 +419,12 @@ void QQmlDelegateModelPrivate::disconnectFromAbstractItemModel()
+                         q, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int)));
+     QObject::disconnect(aim, SIGNAL(rowsRemoved(QModelIndex,int,int)),
+                         q, SLOT(_q_rowsRemoved(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsInserted(QModelIndex,int,int)), q,
++                        SLOT(_q_columnsInserted(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsRemoved(QModelIndex,int,int)), q,
++                        SLOT(_q_columnsRemoved(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)), q,
++                        SLOT(_q_columnsMoved(QModelIndex,int,int,QModelIndex,int)));
+     QObject::disconnect(aim, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
+                         q, SLOT(_q_dataChanged(QModelIndex,QModelIndex,QVector<int>)));
+     QObject::disconnect(aim, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
+@@ -1973,6 +1985,38 @@ void QQmlDelegateModel::_q_rowsMoved(
+     }
+ }
+ 
++void QQmlDelegateModel::_q_columnsInserted(const QModelIndex &parent, int begin, int end)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if (parent == d->m_adaptorModel.rootIndex && begin == 0) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
++void QQmlDelegateModel::_q_columnsRemoved(const QModelIndex &parent, int begin, int end)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if (parent == d->m_adaptorModel.rootIndex && begin == 0) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
++void QQmlDelegateModel::_q_columnsMoved(const QModelIndex &parent, int start, int end,
++                                        const QModelIndex &destination, int column)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if ((parent == d->m_adaptorModel.rootIndex && start == 0)
++        || (destination == d->m_adaptorModel.rootIndex && column == 0)) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
+ void QQmlDelegateModel::_q_dataChanged(const QModelIndex &begin, const QModelIndex &end, const QVector<int> &roles)
+ {
+     Q_D(QQmlDelegateModel);
+diff --git a/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h b/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
+index 8aab4badca..d140bfbaaf 100644
+--- a/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
++++ b/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
+@@ -152,6 +152,9 @@ private Q_SLOTS:
+     void _q_itemsMoved(int from, int to, int count);
+     void _q_modelReset();
+     void _q_rowsInserted(const QModelIndex &,int,int);
++    void _q_columnsInserted(const QModelIndex &, int, int);
++    void _q_columnsRemoved(const QModelIndex &, int, int);
++    void _q_columnsMoved(const QModelIndex &, int, int, const QModelIndex &, int);
+     void _q_rowsAboutToBeRemoved(const QModelIndex &parent, int begin, int end);
+     void _q_rowsRemoved(const QModelIndex &,int,int);
+     void _q_rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int);
+diff --git a/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp b/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
+index 85719fdc80..78e2ab302c 100644
+--- a/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
++++ b/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
+@@ -46,6 +46,7 @@
+ #include "QtQuick/private/qquicktextinput_p.h"
+ #include "QtQuick/private/qquickaccessibleattached_p.h"
+ #include "QtQuick/qquicktextdocument.h"
++#include "QtQuick/qquickrendercontrol.h"
+ QT_BEGIN_NAMESPACE
+ 
+ #if QT_CONFIG(accessibility)
+@@ -57,7 +58,19 @@ QAccessibleQuickItem::QAccessibleQuickItem(QQuickItem *item)
+ 
+ QWindow *QAccessibleQuickItem::window() const
+ {
+-    return item()->window();
++    QQuickWindow *window = item()->window();
++
++    // For QQuickWidget the above window will be the offscreen QQuickWindow,
++    // which is not a part of the accessibility tree. Detect this case and
++    // return the window for the QQuickWidget instead.
++    if (window && !window->handle()) {
++        if (QQuickRenderControl *renderControl = QQuickWindowPrivate::get(window)->renderControl) {
++            if (QWindow *renderWindow = renderControl->renderWindow(nullptr))
++                return renderWindow;
++        }
++    }
++
++    return window;
+ }
+ 
+ int QAccessibleQuickItem::childCount() const
+@@ -113,19 +126,15 @@ QAccessibleInterface *QAccessibleQuickItem::childAt(int x, int y) const
+ QAccessibleInterface *QAccessibleQuickItem::parent() const
+ {
+     QQuickItem *parent = item()->parentItem();
+-    QQuickWindow *window = item()->window();
+-    QQuickItem *ci = window ? window->contentItem() : nullptr;
++    QQuickWindow *itemWindow = item()->window();
++    QQuickItem *ci = itemWindow ? itemWindow->contentItem() : nullptr;
+     while (parent && !QQuickItemPrivate::get(parent)->isAccessible && parent != ci)
+         parent = parent->parentItem();
+ 
+     if (parent) {
+         if (parent == ci) {
+-            // Jump out to the scene widget if the parent is the root item.
+-            // There are two root items, QQuickWindow::rootItem and
+-            // QQuickView::declarativeRoot. The former is the true root item,
+-            // but is not a part of the accessibility tree. Check if we hit
+-            // it here and return an interface for the scene instead.
+-            return QAccessible::queryAccessibleInterface(window);
++            // Jump out to the window if the parent is the root item
++            return QAccessible::queryAccessibleInterface(window());
+         } else {
+             while (parent && !parent->d_func()->isAccessible)
+                 parent = parent->parentItem();
+@@ -188,7 +197,7 @@ QAccessible::State QAccessibleQuickItem::state() const
+     QRect viewRect_ = viewRect();
+     QRect itemRect = rect();
+ 
+-    if (viewRect_.isNull() || itemRect.isNull() || !item()->window() || !item()->window()->isVisible() ||!item()->isVisible() || qFuzzyIsNull(item()->opacity()))
++    if (viewRect_.isNull() || itemRect.isNull() || !window() || !window()->isVisible() ||!item()->isVisible() || qFuzzyIsNull(item()->opacity()))
+         state.invisible = true;
+     if (!viewRect_.intersects(itemRect))
+         state.offscreen = true;
+@@ -201,6 +210,10 @@ QAccessible::State QAccessibleQuickItem::state() const
+     if (role() == QAccessible::EditableText)
+         if (auto ti = qobject_cast<QQuickTextInput *>(item()))
+             state.passwordEdit = ti->echoMode() != QQuickTextInput::Normal;
++    if (!item()->isEnabled()) {
++        state.focusable = false;
++        state.disabled = true;
++    }
+     return state;
+ }
+ 
+diff --git a/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h b/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
+index 39ffcaf39c..8baa01330c 100644
+--- a/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
++++ b/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
+@@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE
+ 
+ #if QT_CONFIG(accessibility)
+ 
+-class QAccessibleQuickWindow : public QAccessibleObject
++class Q_QUICK_EXPORT QAccessibleQuickWindow : public QAccessibleObject
+ {
+ public:
+     QAccessibleQuickWindow(QQuickWindow *object);
+diff --git a/qtdeclarative/src/quick/items/qquickdrag.cpp b/qtdeclarative/src/quick/items/qquickdrag.cpp
+index 8321fcfeed..383078b3b9 100644
+--- a/qtdeclarative/src/quick/items/qquickdrag.cpp
++++ b/qtdeclarative/src/quick/items/qquickdrag.cpp
+@@ -481,7 +481,9 @@ void QQuickDragAttached::setKeys(const QStringList &keys)
+     \qmlattachedproperty stringlist QtQuick::Drag::mimeData
+     \since 5.2
+ 
+-    This property holds a map of mimeData that is used during startDrag.
++    This property holds a map from mime type to data that is used during startDrag.
++    The mime data needs to be a \c string, or an \c ArrayBuffer with the data encoded
++    according to the mime type.
+ */
+ 
+ QVariantMap QQuickDragAttached::mimeData() const
+@@ -766,8 +768,12 @@ Qt::DropAction QQuickDragAttachedPrivate::startDrag(Qt::DropActions supportedAct
+     QDrag *drag = new QDrag(source ? source : q);
+     QMimeData *mimeData = new QMimeData();
+ 
+-    for (auto it = externalMimeData.cbegin(), end = externalMimeData.cend(); it != end; ++it)
+-        mimeData->setData(it.key(), it.value().toString().toUtf8());
++    for (auto it = externalMimeData.cbegin(), end = externalMimeData.cend(); it != end; ++it) {
++        if (static_cast<QMetaType::Type>(it.value().type()) == QMetaType::QByteArray)
++            mimeData->setData(it.key(), it.value().toByteArray());
++        else
++            mimeData->setData(it.key(), it.value().toString().toUtf8());
++    }
+ 
+     drag->setMimeData(mimeData);
+     if (pixmapLoader.isReady()) {
+diff --git a/qtdeclarative/src/quick/items/qquickitem.cpp b/qtdeclarative/src/quick/items/qquickitem.cpp
+index 75f1457816..dec0ae19ae 100644
+--- a/qtdeclarative/src/quick/items/qquickitem.cpp
++++ b/qtdeclarative/src/quick/items/qquickitem.cpp
+@@ -59,6 +59,7 @@
+ #include <QtCore/private/qnumeric_p.h>
+ #include <QtGui/qpa/qplatformtheme.h>
+ #include <QtCore/qloggingcategory.h>
++#include <QtCore/private/qduplicatetracker_p.h>
+ 
+ #include <private/qqmlglobal_p.h>
+ #include <private/qqmlengine_p.h>
+@@ -2326,6 +2327,7 @@ QQuickItem::QQuickItem(QQuickItemPrivate &dd, QQuickItem *parent)
+ QQuickItem::~QQuickItem()
+ {
+     Q_D(QQuickItem);
++    d->inDestructor = true;
+ 
+     if (d->windowRefCount > 1)
+         d->windowRefCount = 1; // Make sure window is set to null in next call to derefWindow().
+@@ -2526,6 +2528,7 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo
+     QQuickItem *current = item;
+     qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: startItem:" << startItem;
+     qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: firstFromItem:" << firstFromItem;
++    QDuplicateTracker<QQuickItem *> cycleDetector;
+     do {
+         qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: current:" << current;
+         qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: from:" << from;
+@@ -2592,7 +2595,10 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo
+         // traversed all of the chain (by compare the [current] item with [startItem])
+         // Since the [startItem] might be promoted to its parent if it is invisible,
+         // we still have to check [current] item with original start item
+-        if ((current == startItem || current == originalStartItem) && from == firstFromItem) {
++        // We might also run into a cycle before we reach firstFromItem again
++        // but note that we have to ignore current if we are meant to skip it
++        if (((current == startItem || current == originalStartItem) && from == firstFromItem) ||
++                (!skip && cycleDetector.hasSeen(current))) {
+             // wrapped around, avoid endless loops
+             if (item == contentItem) {
+                 qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: looped, return contentItem";
+@@ -2689,9 +2695,8 @@ void QQuickItem::setParentItem(QQuickItem *parentItem)
+ 
+         const bool wasVisible = isVisible();
+         op->removeChild(this);
+-        if (wasVisible) {
++        if (wasVisible && !op->inDestructor)
+             emit oldParentItem->visibleChildrenChanged();
+-        }
+     } else if (d->window) {
+         QQuickWindowPrivate::get(d->window)->parentlessItems.remove(this);
+     }
+@@ -2768,8 +2773,9 @@ void QQuickItem::setParentItem(QQuickItem *parentItem)
+ 
+     d->itemChange(ItemParentHasChanged, d->parentItem);
+ 
+-    emit parentChanged(d->parentItem);
+-    if (isVisible() && d->parentItem)
++    if (!d->inDestructor)
++        emit parentChanged(d->parentItem);
++    if (isVisible() && d->parentItem && !QQuickItemPrivate::get(d->parentItem)->inDestructor)
+         emit d->parentItem->visibleChildrenChanged();
+ }
+ 
+@@ -2965,7 +2971,8 @@ void QQuickItemPrivate::removeChild(QQuickItem *child)
+ 
+     itemChange(QQuickItem::ItemChildRemovedChange, child);
+ 
+-    emit q->childrenChanged();
++    if (!inDestructor)
++        emit q->childrenChanged();
+ }
+ 
+ void QQuickItemPrivate::refWindow(QQuickWindow *c)
+@@ -3194,6 +3201,7 @@ QQuickItemPrivate::QQuickItemPrivate()
+     , touchEnabled(false)
+ #endif
+     , hasCursorHandler(false)
++    , inDestructor(false)
+     , dirtyAttributes(0)
+     , nextDirtyItem(nullptr)
+     , prevDirtyItem(nullptr)
+@@ -5120,6 +5128,13 @@ void QQuickItem::componentComplete()
+         d->addToDirtyList();
+         QQuickWindowPrivate::get(d->window)->dirtyItem(this);
+     }
++
++#if QT_CONFIG(accessibility)
++    if (d->isAccessible && d->effectiveVisible) {
++        QAccessibleEvent ev(this, QAccessible::ObjectShow);
++        QAccessible::updateAccessibility(&ev);
++    }
++#endif
+ }
+ 
+ QQuickStateGroup *QQuickItemPrivate::_states()
+@@ -6106,9 +6121,11 @@ bool QQuickItemPrivate::setEffectiveVisibleRecur(bool newEffectiveVisible)
+         QAccessible::updateAccessibility(&ev);
+     }
+ #endif
+-    emit q->visibleChanged();
+-    if (childVisibilityChanged)
+-        emit q->visibleChildrenChanged();
++    if (!inDestructor) {
++        emit q->visibleChanged();
++        if (childVisibilityChanged)
++            emit q->visibleChildrenChanged();
++    }
+ 
+     return true;    // effective visibility DID change
+ }
+@@ -6157,6 +6174,15 @@ void QQuickItemPrivate::setEffectiveEnableRecur(QQuickItem *scope, bool newEffec
+     }
+ 
+     itemChange(QQuickItem::ItemEnabledHasChanged, effectiveEnable);
++#if QT_CONFIG(accessibility)
++    if (isAccessible) {
++        QAccessible::State changedState;
++        changedState.disabled = true;
++        changedState.focusable = true;
++        QAccessibleStateChangeEvent ev(q, changedState);
++        QAccessible::updateAccessibility(&ev);
++    }
++#endif
+     emit q->enabledChanged();
+ }
+ 
+diff --git a/qtdeclarative/src/quick/items/qquickitem_p.h b/qtdeclarative/src/quick/items/qquickitem_p.h
+index 841d91bb40..ade8fb61f2 100644
+--- a/qtdeclarative/src/quick/items/qquickitem_p.h
++++ b/qtdeclarative/src/quick/items/qquickitem_p.h
+@@ -472,6 +472,7 @@ public:
+     bool replayingPressEvent:1;
+     bool touchEnabled:1;
+     bool hasCursorHandler:1;
++    quint32 inDestructor:1; // has entered ~QQuickItem
+ 
+     enum DirtyType {
+         TransformOrigin         = 0x00000001,
+diff --git a/qtdeclarative/src/quick/items/qquickitemview.cpp b/qtdeclarative/src/quick/items/qquickitemview.cpp
+index 010a0152e1..f8ad168a17 100644
+--- a/qtdeclarative/src/quick/items/qquickitemview.cpp
++++ b/qtdeclarative/src/quick/items/qquickitemview.cpp
+@@ -1785,7 +1785,7 @@ void QQuickItemViewPrivate::refill(qreal from, qreal to)
+ 
+     do {
+         bufferPause.stop();
+-        if (currentChanges.hasPendingChanges() || bufferedChanges.hasPendingChanges()) {
++        if (currentChanges.hasPendingChanges() || bufferedChanges.hasPendingChanges() || currentChanges.active) {
+             currentChanges.reset();
+             bufferedChanges.reset();
+             releaseVisibleItems(reusableFlag);
+diff --git a/qtdeclarative/src/quick/items/qquickmousearea_p_p.h b/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
+index fba383e268..0d63618622 100644
+--- a/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
++++ b/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
+@@ -61,7 +61,6 @@ QT_BEGIN_NAMESPACE
+ 
+ class QQuickMouseEvent;
+ class QQuickMouseArea;
+-class QQuickPointerMask;
+ class QQuickMouseAreaPrivate : public QQuickItemPrivate
+ {
+     Q_DECLARE_PUBLIC(QQuickMouseArea)
+@@ -100,7 +99,6 @@ public:
+ #if QT_CONFIG(quick_draganddrop)
+     QQuickDrag *drag;
+ #endif
+-    QPointer<QQuickPointerMask> mask;
+     QPointF startScene;
+     QPointF targetStartPos;
+     QPointF lastPos;
+diff --git a/qtdeclarative/src/quick/items/qquicktext.cpp b/qtdeclarative/src/quick/items/qquicktext.cpp
+index 6230186933..e823ca1095 100644
+--- a/qtdeclarative/src/quick/items/qquicktext.cpp
++++ b/qtdeclarative/src/quick/items/qquicktext.cpp
+@@ -2168,7 +2168,7 @@ void QQuickText::resetMaximumLineCount()
+     <img src="" align="top,middle,bottom" width="" height=""> - inline images
+     <ol type="">, <ul type=""> and <li> - ordered and unordered lists
+     <pre></pre> - preformatted
+-    &gt; &lt; &amp;
++    &gt; &lt; &amp; &quot; &nbsp; &apos;
+     \endcode
+ 
+     \c Text.StyledText parser is strict, requiring tags to be correctly nested.
+diff --git a/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp b/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
+index eb4db0f85e..2325a2665b 100644
+--- a/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
++++ b/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
+@@ -446,7 +446,7 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+         const char *textureRecord = allocatorData;
+         for (int i = 0; i < textureCount; ++i, textureRecord += Qtdf::TextureRecordSize) {
+-            if (textureRecord + Qtdf::TextureRecordSize > qtdfTableEnd) {
++            if (qtdfTableEnd - textureRecord < Qtdf::TextureRecordSize) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+@@ -462,7 +462,7 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+         const char *glyphRecord = textureRecord;
+         for (quint32 i = 0; i < glyphCount; ++i, glyphRecord += Qtdf::GlyphRecordSize) {
+-            if (glyphRecord + Qtdf::GlyphRecordSize > qtdfTableEnd) {
++            if (qtdfTableEnd - glyphRecord < Qtdf:: GlyphRecordSize) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+@@ -512,8 +512,8 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+             int width = texInfo->allocatedArea.width();
+             int height = texInfo->allocatedArea.height();
+-            qint64 size = width * height;
+-            if (reinterpret_cast<const char *>(textureData + size) > qtdfTableEnd) {
++            qint64 size = qint64(width) * height;
++            if (qtdfTableEnd - reinterpret_cast<const char *>(textureData) < size) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+diff --git a/qtdeclarative/src/quick/util/qquickstyledtext.cpp b/qtdeclarative/src/quick/util/qquickstyledtext.cpp
+index d531fc9205..a25af90414 100644
+--- a/qtdeclarative/src/quick/util/qquickstyledtext.cpp
++++ b/qtdeclarative/src/quick/util/qquickstyledtext.cpp
+@@ -564,6 +564,8 @@ void QQuickStyledTextPrivate::parseEntity(const QChar *&ch, const QString &textI
+                 textOut += QChar(60);
+             else if (entity == QLatin1String("amp"))
+                 textOut += QChar(38);
++            else if (entity == QLatin1String("apos"))
++                textOut += QChar(39);
+             else if (entity == QLatin1String("quot"))
+                 textOut += QChar(34);
+             else if (entity == QLatin1String("nbsp"))
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp
+new file mode 100644
+index 0000000000..8a1c901880
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp
+@@ -0,0 +1,110 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include "qaccessiblequickwidget_p.h"
++
++#include "qquickwidget_p.h"
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleQuickWidget::QAccessibleQuickWidget(QQuickWidget* widget)
++: QAccessibleWidget(widget)
++, m_accessibleWindow(QQuickWidgetPrivate::get(widget)->offscreenWindow)
++{
++    // NOTE: m_accessibleWindow is a QAccessibleQuickWindow, and not a
++    // QAccessibleQuickWidgetOffscreenWindow (defined below). This means
++    // it will return the Quick item child interfaces, which is what's needed here
++    // (unlike QAccessibleQuickWidgetOffscreenWindow, which will report 0 children).
++}
++
++QAccessibleInterface *QAccessibleQuickWidget::child(int index) const
++{
++    return m_accessibleWindow.child(index);
++}
++
++int QAccessibleQuickWidget::childCount() const
++{
++    return m_accessibleWindow.childCount();
++}
++
++int QAccessibleQuickWidget::indexOfChild(const QAccessibleInterface *iface) const
++{
++    return m_accessibleWindow.indexOfChild(iface);
++}
++
++QAccessibleInterface *QAccessibleQuickWidget::childAt(int x, int y) const
++{
++    return m_accessibleWindow.childAt(x, y);
++}
++
++QAccessibleQuickWidgetOffscreenWindow::QAccessibleQuickWidgetOffscreenWindow(QQuickWindow *window)
++:QAccessibleQuickWindow(window)
++{
++
++}
++
++QAccessibleInterface *QAccessibleQuickWidgetOffscreenWindow::child(int index) const
++{
++    Q_UNUSED(index);
++    return nullptr;
++}
++
++int QAccessibleQuickWidgetOffscreenWindow::childCount() const
++{
++    return 0;
++}
++
++int QAccessibleQuickWidgetOffscreenWindow::indexOfChild(const QAccessibleInterface *iface) const
++{
++    Q_UNUSED(iface);
++    return -1;
++}
++
++QAccessibleInterface *QAccessibleQuickWidgetOffscreenWindow::QAccessibleQuickWidgetOffscreenWindow::childAt(int x, int y) const
++{
++    Q_UNUSED(x);
++    Q_UNUSED(y);
++    return nullptr;
++}
++
++#endif // accessibility
++
++QT_END_NAMESPACE
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h
+new file mode 100644
+index 0000000000..7c2ab930e0
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h
+@@ -0,0 +1,95 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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 QACCESSIBLEQUICKWIDGET_H
++#define QACCESSIBLEQUICKWIDGET_H
++
++//
++//  W A R N I N G
++//  -------------
++//
++// This file is not part of the Qt API.  It exists purely as an
++// implementation detail.  This header file may change from version to
++// version without notice, or even be removed.
++//
++// We mean it.
++//
++
++#include "qquickwidget.h"
++#include <QtWidgets/qaccessiblewidget.h>
++
++#include <private/qaccessiblequickview_p.h>
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++// These classes implement the QQuickWiget accessibility switcharoo,
++// where the child items of the QQuickWidgetOffscreenWindow are reported
++// as child accessible interfaces of the QAccessibleQuickWidget.
++class QAccessibleQuickWidget: public QAccessibleWidget
++{
++public:
++    QAccessibleQuickWidget(QQuickWidget* widget);
++
++    QAccessibleInterface *child(int index) const override;
++    int childCount() const override;
++    int indexOfChild(const QAccessibleInterface *iface) const override;
++    QAccessibleInterface *childAt(int x, int y) const override;
++
++private:
++    QAccessibleQuickWindow m_accessibleWindow;
++    Q_DISABLE_COPY(QAccessibleQuickWidget)
++};
++
++class QAccessibleQuickWidgetOffscreenWindow: public QAccessibleQuickWindow
++{
++public:
++    QAccessibleQuickWidgetOffscreenWindow(QQuickWindow *window);
++    QAccessibleInterface *child(int index) const override;
++    int childCount() const override;
++    int indexOfChild(const QAccessibleInterface *iface) const override;
++    QAccessibleInterface *childAt(int x, int y) const override;
++};
++
++#endif // accessibility
++
++QT_END_NAMESPACE
++
++#endif
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp
+new file mode 100644
+index 0000000000..7ba88a1769
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp
+@@ -0,0 +1,60 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include "qaccessiblequickwidgetfactory_p.h"
++#include "qaccessiblequickwidget_p.h"
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleInterface *qAccessibleQuickWidgetFactory(const QString &classname, QObject *object)
++{
++    if (classname == QLatin1String("QQuickWidget")) {
++        return new QAccessibleQuickWidget(qobject_cast<QQuickWidget *>(object));
++    } else if (classname == QLatin1String("QQuickWidgetOffscreenWindow")) {
++        return new QAccessibleQuickWidgetOffscreenWindow(qobject_cast<QQuickWindow *>(object));
++    }
++    return 0;
++}
++
++#endif // accessibility
++
++QT_END_NAMESPACE
++
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h
+new file mode 100644
+index 0000000000..8c63b09f81
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h
+@@ -0,0 +1,66 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include <QtGui/qaccessible.h>
++
++#ifndef QACCESSIBLEQUICKWIDGETFACTORY_H
++#define QACCESSIBLEQUICKWIDGETFACTORY_H
++
++//
++//  W A R N I N G
++//  -------------
++//
++// This file is not part of the Qt API.  It exists purely as an
++// implementation detail.  This header file may change from version to
++// version without notice, or even be removed.
++//
++// We mean it.
++//
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleInterface *qAccessibleQuickWidgetFactory(const QString &classname, QObject *object);
++
++#endif
++
++QT_END_NAMESPACE
++
++#endif
+diff --git a/qtdeclarative/src/quickwidgets/qquickwidget.cpp b/qtdeclarative/src/quickwidgets/qquickwidget.cpp
+index 39780f8de3..9c97b43518 100644
+--- a/qtdeclarative/src/quickwidgets/qquickwidget.cpp
++++ b/qtdeclarative/src/quickwidgets/qquickwidget.cpp
+@@ -39,6 +39,7 @@
+ 
+ #include "qquickwidget.h"
+ #include "qquickwidget_p.h"
++#include "qaccessiblequickwidgetfactory_p.h"
+ 
+ #include "private/qquickwindow_p.h"
+ #include "private/qquickitem_p.h"
+@@ -75,9 +76,16 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++QQuickWidgetOffscreenWindow::QQuickWidgetOffscreenWindow(QQuickWindowPrivate &dd, QQuickRenderControl *control)
++:QQuickWindow(dd, control)
++{
++    setTitle(QString::fromLatin1("Offscreen"));
++    setObjectName(QString::fromLatin1("QQuickOffScreenWindow"));
++}
++
+ // override setVisble to prevent accidental offscreen window being created
+ // by base class.
+-class QQuickOffcreenWindowPrivate: public QQuickWindowPrivate {
++class QQuickWidgetOffscreenWindowPrivate: public QQuickWindowPrivate {
+ public:
+     void setVisible(bool visible) override {
+         Q_Q(QWindow);
+@@ -105,9 +113,8 @@ void QQuickWidgetPrivate::init(QQmlEngine* e)
+     Q_Q(QQuickWidget);
+ 
+     renderControl = new QQuickWidgetRenderControl(q);
+-    offscreenWindow = new QQuickWindow(*new QQuickOffcreenWindowPrivate(),renderControl);
+-    offscreenWindow->setTitle(QString::fromLatin1("Offscreen"));
+-    offscreenWindow->setObjectName(QString::fromLatin1("QQuickOffScreenWindow"));
++    offscreenWindow = new QQuickWidgetOffscreenWindow(*new QQuickWidgetOffscreenWindowPrivate(), renderControl);
++    offscreenWindow->setScreen(q->screen());
+     // Do not call create() on offscreenWindow.
+ 
+     // Check if the Software Adaptation is being used
+@@ -138,6 +145,10 @@ void QQuickWidgetPrivate::init(QQmlEngine* e)
+     QWidget::connect(offscreenWindow, &QQuickWindow::focusObjectChanged, q, &QQuickWidget::propagateFocusObjectChanged);
+     QObject::connect(renderControl, SIGNAL(renderRequested()), q, SLOT(triggerUpdate()));
+     QObject::connect(renderControl, SIGNAL(sceneChanged()), q, SLOT(triggerUpdate()));
++
++#if QT_CONFIG(accessibility)
++    QAccessible::installFactory(&qAccessibleQuickWidgetFactory);
++#endif
+ }
+ 
+ void QQuickWidgetPrivate::ensureEngine() const
+@@ -901,9 +912,7 @@ void QQuickWidgetPrivate::createContext()
+ 
+         context = new QOpenGLContext;
+         context->setFormat(offscreenWindow->requestedFormat());
+-        const QWindow *win = q->window()->windowHandle();
+-        if (win && win->screen())
+-            context->setScreen(win->screen());
++        context->setScreen(q->screen());
+         QOpenGLContext *shareContext = qt_gl_global_share_context();
+         if (!shareContext)
+             shareContext = QWidgetPrivate::get(q->window())->shareContext();
+@@ -1520,19 +1529,16 @@ bool QQuickWidget::event(QEvent *e)
+         d->handleWindowChange();
+         break;
+ 
+-    case QEvent::ScreenChangeInternal:
+-        if (QWindow *window = this->window()->windowHandle()) {
+-            QScreen *newScreen = window->screen();
+-
+-            if (d->offscreenWindow)
+-                d->offscreenWindow->setScreen(newScreen);
+-            if (d->offscreenSurface)
+-                d->offscreenSurface->setScreen(newScreen);
++    case QEvent::ScreenChangeInternal: {
++        QScreen *newScreen = screen();
++        if (d->offscreenWindow)
++            d->offscreenWindow->setScreen(newScreen);
++        if (d->offscreenSurface)
++            d->offscreenSurface->setScreen(newScreen);
+ #if QT_CONFIG(opengl)
+-            if (d->context)
+-                d->context->setScreen(newScreen);
++        if (d->context)
++            d->context->setScreen(newScreen);
+ #endif
+-        }
+ 
+         if (d->useSoftwareRenderer
+ #if QT_CONFIG(opengl)
+@@ -1545,7 +1551,7 @@ bool QQuickWidget::event(QEvent *e)
+             d->render(true);
+         }
+         break;
+-
++    }
+     case QEvent::Show:
+     case QEvent::Move:
+         d->updatePosition();
+diff --git a/qtdeclarative/src/quickwidgets/qquickwidget_p.h b/qtdeclarative/src/quickwidgets/qquickwidget_p.h
+index 881f7f9220..1a946bcc71 100644
+--- a/qtdeclarative/src/quickwidgets/qquickwidget_p.h
++++ b/qtdeclarative/src/quickwidgets/qquickwidget_p.h
+@@ -148,6 +148,14 @@ public:
+     bool forceFullUpdate;
+ };
+ 
++class QQuickWidgetOffscreenWindow: public QQuickWindow
++{
++    Q_OBJECT
++
++public:
++    QQuickWidgetOffscreenWindow(QQuickWindowPrivate &dd, QQuickRenderControl *control);
++};
++
+ QT_END_NAMESPACE
+ 
+ #endif // QQuickWidget_P_H
+diff --git a/qtdeclarative/src/quickwidgets/quickwidgets.pro b/qtdeclarative/src/quickwidgets/quickwidgets.pro
+index 2438e577ae..85d156b8a3 100644
+--- a/qtdeclarative/src/quickwidgets/quickwidgets.pro
++++ b/qtdeclarative/src/quickwidgets/quickwidgets.pro
+@@ -7,9 +7,13 @@ DEFINES   += QT_NO_URL_CAST_FROM_STRING QT_NO_INTEGER_EVENT_COORDINATES QT_NO_FO
+ HEADERS += \
+     qquickwidget.h \
+     qquickwidget_p.h \
+-    qtquickwidgetsglobal.h
++    qtquickwidgetsglobal.h \
++    qaccessiblequickwidget_p.h \
++    qaccessiblequickwidgetfactory_p.h
+ 
+ SOURCES += \
+-    qquickwidget.cpp
++    qquickwidget.cpp \
++    qaccessiblequickwidget.cpp \
++    qaccessiblequickwidgetfactory.cpp
+ 
+ load(qt_module)
+diff --git a/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+index 3b7d74df63..b75bf820d5 100644
+--- a/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
++++ b/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+@@ -102,6 +102,7 @@ private slots:
+     void valueConversion_RegularExpression();
+     void castWithMultipleInheritance();
+     void collectGarbage();
++    void collectGarbageNestedWrappersTwoEngines();
+     void gcWithNestedDataStructure();
+     void stacktrace();
+     void numberParsing_data();
+@@ -1809,6 +1810,44 @@ void tst_QJSEngine::collectGarbage()
+     QVERIFY(ptr.isNull());
+ }
+ 
++class TestObjectContainer : public QObject
++{
++    Q_OBJECT
++    Q_PROPERTY(QObject *dummy MEMBER m_dummy CONSTANT)
++
++public:
++    TestObjectContainer() : m_dummy(new QObject(this)) {}
++
++private:
++    QObject *m_dummy;
++};
++
++void tst_QJSEngine::collectGarbageNestedWrappersTwoEngines()
++{
++    QJSEngine engine1;
++    QJSEngine engine2;
++
++    TestObjectContainer container;
++    QQmlEngine::setObjectOwnership(&container, QQmlEngine::CppOwnership);
++
++    engine1.globalObject().setProperty("foobar", engine1.newQObject(&container));
++    engine2.globalObject().setProperty("foobar", engine2.newQObject(&container));
++
++    engine1.evaluate("foobar.dummy.baz = 42");
++    engine2.evaluate("foobar.dummy.baz = 43");
++
++    QCOMPARE(engine1.evaluate("foobar.dummy.baz").toInt(), 42);
++    QCOMPARE(engine2.evaluate("foobar.dummy.baz").toInt(), 43);
++
++    engine1.collectGarbage();
++    engine2.collectGarbage();
++
++    // The GC should not collect dummy object wrappers neither in engine1 nor engine2, we
++    // verify that by checking whether the baz property still has its previous value.
++    QCOMPARE(engine1.evaluate("foobar.dummy.baz").toInt(), 42);
++    QCOMPARE(engine2.evaluate("foobar.dummy.baz").toInt(), 43);
++}
++
+ void tst_QJSEngine::gcWithNestedDataStructure()
+ {
+     // The GC must be able to traverse deeply nested objects, otherwise this
+diff --git a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml
+new file mode 100644
+index 0000000000..206133bb39
+--- /dev/null
++++ b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml
+@@ -0,0 +1,11 @@
++import QtQuick 2.8
++
++ListView {
++    id: root
++    width: 200
++    height: 200
++
++    delegate: Text {
++        text: display
++    }
++}
+diff --git a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
+index 35f1e2c94d..1722447830 100644
+--- a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
++++ b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
+@@ -27,6 +27,8 @@
+ ****************************************************************************/
+ 
+ #include <QtTest/qtest.h>
++#include <QtCore/QConcatenateTablesProxyModel>
++#include <QtGui/QStandardItemModel>
+ #include <QtQml/qqmlcomponent.h>
+ #include <QtQmlModels/private/qqmldelegatemodel_p.h>
+ #include <QtQuick/qquickview.h>
+@@ -47,6 +49,7 @@ private slots:
+     void filterOnGroup_removeWhenCompleted();
+     void qtbug_86017();
+     void contextAccessedByHandler();
++    void redrawUponColumnChange();
+ };
+ 
+ class AbstractItemModel : public QAbstractItemModel
+@@ -186,6 +189,30 @@ void tst_QQmlDelegateModel::contextAccessedByHandler()
+     QVERIFY(root->property("works").toBool());
+ }
+ 
++void tst_QQmlDelegateModel::redrawUponColumnChange()
++{
++    QStandardItemModel m1;
++    m1.appendRow({
++            new QStandardItem("Banana"),
++            new QStandardItem("Coconut"),
++    });
++
++    QQuickView view(testFileUrl("redrawUponColumnChange.qml"));
++    QCOMPARE(view.status(), QQuickView::Ready);
++    view.show();
++    QQuickItem *root = view.rootObject();
++    root->setProperty("model", QVariant::fromValue<QObject *>(&m1));
++
++    QObject *item = root->property("currentItem").value<QObject *>();
++    QVERIFY(item);
++    QCOMPARE(item->property("text").toString(), "Banana");
++
++    QVERIFY(root);
++    m1.removeColumn(0);
++
++    QCOMPARE(item->property("text").toString(), "Coconut");
++}
++
+ QTEST_MAIN(tst_QQmlDelegateModel)
+ 
+ #include "tst_qqmldelegatemodel.moc"
+diff --git a/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp b/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
+index 5d635aa63b..824fd89e5b 100644
+--- a/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
++++ b/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
+@@ -76,10 +76,10 @@ void tst_qv4mm::multiWrappedQObjects()
+         QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 1);
+         QCOMPARE(engine2.memoryManager->m_pendingFreedObjectWrapperValue.size(), 0);
+ 
+-        // Moves the additional WeakValue from m_multiplyWrappedQObjects to
+-        // m_pendingFreedObjectWrapperValue. It's still alive after all.
++        // The additional WeakValue from m_multiplyWrappedQObjects hasn't been moved
++        // to m_pendingFreedObjectWrapperValue yet. It's still alive after all.
+         engine1.memoryManager->runGC();
+-        QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 2);
++        QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 1);
+ 
+         // engine2 doesn't own the object as engine1 was the first to wrap it above.
+         // Therefore, no effect here.
+diff --git a/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml b/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml
+new file mode 100644
+index 0000000000..889e480f3b
+--- /dev/null
++++ b/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml
+@@ -0,0 +1,13 @@
++import QtQuick 2.6
++
++Item {
++    visible: true
++    Item {
++        visible: false
++        Item {
++            objectName: "hiddenChild"
++            activeFocusOnTab: true
++            focus: true
++        }
++    }
++}
+diff --git a/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp b/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+index c8f251dbe1..c8ef36ee68 100644
+--- a/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
++++ b/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+@@ -67,6 +67,7 @@ private slots:
+     void activeFocusOnTab10();
+     void activeFocusOnTab_infiniteLoop_data();
+     void activeFocusOnTab_infiniteLoop();
++    void activeFocusOnTab_infiniteLoopControls();
+ 
+     void nextItemInFocusChain();
+     void nextItemInFocusChain2();
+@@ -1057,6 +1058,17 @@ void tst_QQuickItem::activeFocusOnTab_infiniteLoop()
+     QCOMPARE(item, window->rootObject());
+ }
+ 
++
++void tst_QQuickItem::activeFocusOnTab_infiniteLoopControls()
++{
++    auto source = testFileUrl("activeFocusOnTab_infiniteLoop3.qml");
++    QScopedPointer<QQuickView>window(new QQuickView());
++    window->setSource(source);
++    window->show();
++    QVERIFY(window->errors().isEmpty());
++    QTest::keyClick(window.get(), Qt::Key_Tab); // should not hang
++}
++
+ void tst_QQuickItem::nextItemInFocusChain()
+ {
+     if (!qt_tab_all_widgets())
+Submodule qtdoc c0c7bf07...79d6ef69:
+Submodule qtimageformats 2dcf2899..abe44c0f:
+diff --git a/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp b/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
+index dde783c..1bf9074 100644
+--- a/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
+@@ -462,8 +462,12 @@ static bool parseIconEntryInfo(ICNSEntry &icon)
+     if (isIconCompressed(icon))
+         return true;
+     // Icon depth:
+-    if (!depth.isEmpty())
+-        icon.depth = ICNSEntry::Depth(depth.toUInt());
++    if (!depth.isEmpty()) {
++        const uint depthUInt = depth.toUInt();
++        if (depthUInt > 32)
++            return false;
++        icon.depth = ICNSEntry::Depth(depthUInt);
++    }
+     // Try mono if depth not found
+     if (icon.depth == ICNSEntry::DepthUnknown)
+         icon.depth = ICNSEntry::DepthMono;
+@@ -515,6 +519,9 @@ static bool parseIconEntryInfo(ICNSEntry &icon)
+         }
+         icon.height = icon.width;
+     }
++    // Sanity check
++    if (icon.width == 0 || icon.width > 4096)
++        return false;
+     return true;
+ }
+ 
+@@ -685,7 +692,7 @@ bool QICNSHandler::canRead() const
+ bool QICNSHandler::read(QImage *outImage)
+ {
+     QImage img;
+-    if (!ensureScanned()) {
++    if (!ensureScanned() || m_currentIconIndex >= m_icons.size()) {
+         qWarning("QICNSHandler::read(): The device wasn't parsed properly!");
+         return false;
+     }
+@@ -892,7 +899,7 @@ bool QICNSHandler::scanDevice()
+             return false;
+ 
+         const qint64 blockDataOffset = device()->pos();
+-        if (!isBlockHeaderValid(blockHeader)) {
++        if (!isBlockHeaderValid(blockHeader, ICNSBlockHeaderSize + filelength - blockDataOffset)) {
+             qWarning("QICNSHandler::scanDevice(): Failed, bad header at pos %s. OSType \"%s\", length %u",
+                      QByteArray::number(blockDataOffset).constData(),
+                      nameFromOSType(blockHeader.ostype).constData(), blockHeader.length);
+@@ -927,11 +934,14 @@ bool QICNSHandler::scanDevice()
+         case ICNSBlockHeader::TypeOdrp:
+             // Icns container seems to have an embedded icon variant container
+             // Let's start a scan for entries
+-            while (device()->pos() < nextBlockOffset) {
++            while (!stream.atEnd() && device()->pos() < nextBlockOffset) {
+                 ICNSBlockHeader icon;
+                 stream >> icon;
++                if (stream.status() != QDataStream::Ok)
++                    return false;
+                 // Check for incorrect variant entry header and stop scan
+-                if (!isBlockHeaderValid(icon, blockDataLength))
++                quint64 remaining = blockDataLength - (device()->pos() - blockDataOffset);
++                if (!isBlockHeaderValid(icon, ICNSBlockHeaderSize + remaining))
+                     break;
+                 if (!addEntry(icon, device()->pos(), blockHeader.ostype))
+                     return false;
+@@ -1003,7 +1013,7 @@ bool QICNSHandler::scanDevice()
+             break;
+         }
+     }
+-    return true;
++    return (m_icons.size() > 0);
+ }
+ 
+ const ICNSEntry &QICNSHandler::getIconMask(const ICNSEntry &icon) const
+diff --git a/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp b/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
+index 5082023..cb34374 100644
+--- a/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
++++ b/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
+@@ -43,6 +43,7 @@
+ #include "qimage.h"
+ #include "qvariant.h"
+ #include "qcolor.h"
++#include "qimagereader.h"
+ 
+ #include <jasper/jasper.h>
+ #include <math.h> // for pow
+@@ -333,16 +334,46 @@ private:
+ Jpeg2000JasperReader::Jpeg2000JasperReader(QIODevice *iod, SubFormat format)
+     : jasperOk(true), ioDevice(iod), format(format), hasAlpha(false)
+ {
++#if JAS_VERSION_MAJOR < 3
+     if (jas_init()) {
+         jasperOk = false;
+         qDebug("Jasper Library initialization failed");
+     }
++#else
++    jas_conf_clear();
++#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
++    jas_conf_set_max_mem_usage(QImageReader::allocationLimit() * 1024 * 1024);
++#else
++    // 128MB seems to be enough.
++    jas_conf_set_max_mem_usage(128 * 1024 * 1024);
++#endif
++    if (jas_init_library()) {
++        jasperOk = false;
++        qDebug("Jasper library initialization failed");
++    }
++    if (jas_init_thread()) {
++        jas_cleanup_library();
++        jasperOk = false;
++        qDebug("Jasper thread initialization failed");
++    }
++#endif
+ }
+ 
+ Jpeg2000JasperReader::~Jpeg2000JasperReader()
+ {
++#if JAS_VERSION_MAJOR < 3
+     if (jasperOk)
+         jas_cleanup();
++#else
++    if (jasperOk) {
++        if (jas_cleanup_thread()) {
++            qDebug("Jasper thread cleanup failed");
++        }
++        if (jas_cleanup_library()) {
++            qDebug("Jasper library cleanup failed");
++        }
++    }
++#endif
+ }
+ 
+ /*! \internal
+@@ -857,7 +888,7 @@ bool Jpeg2000JasperReader::write(const QImage &image, int quality)
+     }
+ 
+     // Open an empty jasper stream that grows automatically
+-    jas_stream_t * memory_stream = jas_stream_memopen(0, -1);
++    jas_stream_t * memory_stream = jas_stream_memopen(0, 0);
+ 
+     // Jasper wants a non-const string.
+     char *str = qstrdup(jasperFormatString.toLatin1().constData());
+diff --git a/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp b/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
+index 1386750..ac8956c 100644
+--- a/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
+@@ -361,6 +361,8 @@ bool QTiffHandler::read(QImage *image)
+     }
+ 
+     TIFF *const tiff = d->tiff;
++    if (TIFFIsTiled(tiff) && TIFFTileSize64(tiff) > uint64_t(image->sizeInBytes())) // Corrupt image
++        return false;
+     const quint32 width = d->size.width();
+     const quint32 height = d->size.height();
+ 
+diff --git a/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp b/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
+index 82d38cb..d02eb05 100644
+--- a/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
+@@ -45,6 +45,7 @@
+ #include <qdebug.h>
+ #include <qpainter.h>
+ #include <qvariant.h>
++#include <QtEndian>
+ 
+ static const int riffHeaderSize = 12; // RIFF_HEADER_SIZE from webp/format_constants.h
+ 
+@@ -102,21 +103,23 @@ bool QWebpHandler::ensureScanned() const
+ 
+     m_scanState = ScanError;
+ 
+-    if (device()->isSequential()) {
+-        qWarning() << "Sequential devices are not supported";
++    QWebpHandler *that = const_cast<QWebpHandler *>(this);
++    const int headerBytesNeeded = sizeof(WebPBitstreamFeatures);
++    QByteArray header = device()->peek(headerBytesNeeded);
++    if (header.size() < headerBytesNeeded)
+         return false;
+-    }
+ 
+-    qint64 oldPos = device()->pos();
+-    device()->seek(0);
+-
+-    QWebpHandler *that = const_cast<QWebpHandler *>(this);
+-    QByteArray header = device()->peek(sizeof(WebPBitstreamFeatures));
++    // We do no random access during decoding, just a readAll() of the whole image file. So if
++    // if it is all available already, we can accept a sequential device. The riff header contains
++    // the file size minus 8 bytes header
++    qint64 byteSize = qFromLittleEndian<quint32>(header.constData() + 4);
++    if (device()->isSequential() && device()->bytesAvailable() < byteSize + 8) {
++        qWarning() << "QWebpHandler: Insufficient data available in sequential device";
++        return false;
++    }
+     if (WebPGetFeatures((const uint8_t*)header.constData(), header.size(), &(that->m_features)) == VP8_STATUS_OK) {
+         if (m_features.has_animation) {
+             // For animation, we have to read and scan whole file to determine loop count and images count
+-            device()->seek(oldPos);
+-
+             if (that->ensureDemuxer()) {
+                 that->m_loop = WebPDemuxGetI(m_demuxer, WEBP_FF_LOOP_COUNT);
+                 that->m_frameCount = WebPDemuxGetI(m_demuxer, WEBP_FF_FRAME_COUNT);
+@@ -126,17 +129,13 @@ bool QWebpHandler::ensureScanned() const
+                 if (that->m_features.has_alpha)
+                     that->m_composited->fill(Qt::transparent);
+ 
+-                // We do not reset device position since we have read in all data
+                 m_scanState = ScanSuccess;
+-                return true;
+             }
+         } else {
+             m_scanState = ScanSuccess;
+         }
+     }
+ 
+-    device()->seek(oldPos);
+-
+     return m_scanState == ScanSuccess;
+ }
+ 
+@@ -159,7 +158,7 @@ bool QWebpHandler::ensureDemuxer()
+ 
+ bool QWebpHandler::read(QImage *image)
+ {
+-    if (!ensureScanned() || device()->isSequential() || !ensureDemuxer())
++    if (!ensureScanned() || !ensureDemuxer())
+         return false;
+ 
+     QRect prevFrameRect;
+Submodule qtlocation 98a5c511..f991e28c:
+diff --git a/qtlocation/src/location/configure.json b/qtlocation/src/location/configure.json
+index 6d01a9a3..d1e623a1 100644
+--- a/qtlocation/src/location/configure.json
++++ b/qtlocation/src/location/configure.json
+@@ -9,7 +9,7 @@
+             "label": "Qt.labs.location experimental QML plugin",
+             "purpose": "Provides experimental QtLocation QML types",
+             "section": "Location",
+-            "condition": "config.opengl",
++            "condition": "features.opengl",
+             "output": [ "privateFeature" ]
+         },
+         "geoservices_osm": {
+diff --git a/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp b/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
+index a978573d..11e1466f 100644
+--- a/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
++++ b/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
+@@ -158,7 +158,7 @@ void QGeoMapObjectQSGSupport::updateMapObjects(QSGNode *root, QQuickWindow *wind
+     if (!root)
+         return;
+ 
+-    if (m_mapObjectsRootNode && m_mapObjectsRootNode->parent())
++    if (m_mapObjectsRootNode && !m_mapObjectsRootNode->parent())
+         root->appendChildNode(m_mapObjectsRootNode.get());
+ 
+     if (!m_mapObjectsRootNode) {
+diff --git a/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
+index 5a40467e..d123c6a8 100644
+--- a/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
+@@ -59,8 +59,10 @@ QT_BEGIN_NAMESPACE
+ static const QString kPrefixEsri(QStringLiteral("esri."));
+ static const QString kParamUserAgent(kPrefixEsri + QStringLiteral("useragent"));
+ 
+-static const QString kUrlGeocode(QStringLiteral("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates"));
+-static const QString kUrlReverseGeocode(QStringLiteral("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode"));
++static const QString kUrlGeocode(QStringLiteral("https://geocode.arcgis.com/arcgis/rest/services/"
++                                                "World/GeocodeServer/findAddressCandidates"));
++static const QString kUrlReverseGeocode(QStringLiteral(
++        "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode"));
+ 
+ static QString addressToQuery(const QGeoAddress &address)
+ {
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
+index 17492d94..96c12b1b 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
+@@ -46,7 +46,8 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-// JSON reference: http://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
++// JSON reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
+ 
+ static const QString kErrorMessage(QStringLiteral("Error %1: %2."));
+ static const QString kErrorJson(QStringLiteral("Error: invalide JSON document."));
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
+index 8cadfb29..92b6bb13 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
+@@ -44,7 +44,8 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-// JSON reference: http://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
++// JSON reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
+ 
+ GeoRouteReplyEsri::GeoRouteReplyEsri(QNetworkReply *reply, const QGeoRouteRequest &request,
+                                      QObject *parent) :
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
+index 0e6bc2c7..ed613f4b 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
+@@ -48,7 +48,8 @@ static const QString kPrefixEsri(QStringLiteral("esri."));
+ static const QString kParamUserAgent(kPrefixEsri + QStringLiteral("useragent"));
+ static const QString kParamToken(kPrefixEsri + QStringLiteral("token"));
+ 
+-static const QString kUrlRouting(QStringLiteral("http://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve"));
++static const QString kUrlRouting(QStringLiteral(
++        "https://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve"));
+ 
+ GeoRoutingManagerEngineEsri::GeoRoutingManagerEngineEsri(const QVariantMap &parameters,
+                                                          QGeoServiceProvider::Error *error,
+@@ -70,7 +71,8 @@ GeoRoutingManagerEngineEsri::~GeoRoutingManagerEngineEsri()
+ {
+ }
+ 
+-// REST reference: http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
++// REST reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
+ 
+ QGeoRouteReply *GeoRoutingManagerEngineEsri::calculateRoute(const QGeoRouteRequest &request)
+ {
+@@ -125,7 +127,7 @@ void GeoRoutingManagerEngineEsri::replyError(QGeoRouteReply::Error errorCode, co
+ QString GeoRoutingManagerEngineEsri::preferedDirectionLangage()
+ {
+     // list of supported langages is defined in:
+-    // http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
++    // https://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
+     const QStringList supportedLanguages = {
+         "ar", // Generate directions in Arabic
+         "cs", // Generate directions in Czech
+diff --git a/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
+index 5d15835d..24148f95 100644
+--- a/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
+@@ -230,7 +230,8 @@ QGeoMap *GeoTiledMappingManagerEngineEsri::createMap()
+ // ${y} = Y
+ // ${token} = Token
+ 
+-// template = 'http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{{z}}/{{y}}/{{x}}.png'
++// template =
++// 'https://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{{z}}/{{y}}/{{x}}.png'
+ 
+ bool GeoTiledMappingManagerEngineEsri::initializeMapSources(QGeoServiceProvider::Error *error,
+                                                             QString *errorString,
+diff --git a/qtlocation/src/plugins/geoservices/esri/maps.json b/qtlocation/src/plugins/geoservices/esri/maps.json
+index 8167ae7d..862e087d 100644
+--- a/qtlocation/src/plugins/geoservices/esri/maps.json
++++ b/qtlocation/src/plugins/geoservices/esri/maps.json
+@@ -6,8 +6,8 @@
+             "description": "ArcGIS Online World Street Map",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=3b93337983e9436f8db950e38a8629af'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=3b93337983e9436f8db950e38a8629af'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -16,8 +16,8 @@
+             "": "ArcGIS Online World Imagery",
+             "mobile": true,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -26,8 +26,8 @@
+             "description": "ArcGIS Online World Terrain Base",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=c61ad8ab017d49e1a82f580ee1298931'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=c61ad8ab017d49e1a82f580ee1298931'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -36,8 +36,8 @@
+             "description": "ArcGIS Online World Topography",
+             "mobile": true,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=30e5fe3149c34df1ba922e6f5bbf808f'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=30e5fe3149c34df1ba922e6f5bbf808f'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -46,8 +46,8 @@
+             "description": "This map presents land cover and detailed topographic maps for the United States.",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=99cd5fbd98934028802b4f797c4b1732'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=99cd5fbd98934028802b4f797c4b1732'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -56,8 +56,8 @@
+             "description": "National Geographic World Map",
+             "mobile": false,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=b9b1b422198944fbbd5250b3241691b6'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=b9b1b422198944fbbd5250b3241691b6'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -66,8 +66,8 @@
+             "description": "Thematic content providing a neutral background with minimal colors",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=ed712cb1db3e4bae9e85329040fb9a49'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=ed712cb1db3e4bae9e85329040fb9a49'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -76,8 +76,8 @@
+             "description": "Natural Earth physical map for the world",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=c4ec722a1cd34cf0a23904aadf8923a0'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=c4ec722a1cd34cf0a23904aadf8923a0'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -86,8 +86,8 @@
+             "description": "Portrays surface elevation as shaded relief",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=9c5370d0b54f4de1b48a3792d7377ff2'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=9c5370d0b54f4de1b48a3792d7377ff2'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -96,8 +96,8 @@
+             "description": "This map is designed to be used as a basemap by marine GIS professionals and as a reference map by anyone interested in ocean data",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=1e126e7520f9466c9ca28b8f28b5e500'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=1e126e7520f9466c9ca28b8f28b5e500'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -106,8 +106,8 @@
+             "description": "Thematic content providing a neutral background with minimal colors",
+             "mobile": false,
+             "night": true,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=a284a9b99b3446a3910d4144a50990f6'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=a284a9b99b3446a3910d4144a50990f6'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -116,8 +116,8 @@
+             "description": "DeLorme’s topographic basemap is a seamless global data set that portrays transportation, hydrography, jurisdiction boundaries, and major geographic features",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/Specialty/DeLorme_World_Base_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=b165c3df453e4be6b5ac4fdb241effbe'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/Specialty/DeLorme_World_Base_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=b165c3df453e4be6b5ac4fdb241effbe'>Esri</a> contributors"
+         }
+     ]
+ }
+diff --git a/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
+index 3858ddf5..af66f28e 100644
+--- a/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
+@@ -63,8 +63,10 @@ static const QString kCountriesKey(QStringLiteral("detailedCountries"));
+ static const QString kLocalizedNamesKey(QStringLiteral("localizedNames"));
+ static const QString kMaxLocationsKey(QStringLiteral("maxLocations"));
+ 
+-static const QUrl kUrlGeocodeServer("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer?f=pjson");
+-static const QUrl kUrlFindAddressCandidates("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates");
++static const QUrl kUrlGeocodeServer(
++        "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer?f=pjson");
++static const QUrl kUrlFindAddressCandidates("https://geocode.arcgis.com/arcgis/rest/services/World/"
++                                            "GeocodeServer/findAddressCandidates");
+ 
+ PlaceManagerEngineEsri::PlaceManagerEngineEsri(const QVariantMap &parameters, QGeoServiceProvider::Error *error,
+                                                QString *errorString) :
+Submodule qtmultimedia f0344079..0d7cc33a:
+diff --git a/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp b/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
+index 2b5325132..b68b4af1b 100644
+--- a/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
++++ b/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
+@@ -402,6 +402,8 @@ int QPulseAudioInput::bytesReady() const
+ 
+ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ {
++    Q_ASSERT(data != nullptr || len == 0);
++
+     m_bytesAvailable = checkBytesReady();
+ 
+     setError(QAudio::NoError);
+@@ -411,7 +413,8 @@ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ 
+     if (!m_pullMode && !m_tempBuffer.isEmpty()) {
+         readBytes = qMin(static_cast<int>(len), m_tempBuffer.size());
+-        memcpy(data, m_tempBuffer.constData(), readBytes);
++        if (readBytes)
++            memcpy(data, m_tempBuffer.constData(), readBytes);
+         m_totalTimeValue += readBytes;
+ 
+         if (readBytes < m_tempBuffer.size()) {
+@@ -502,9 +505,10 @@ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ 
+ void QPulseAudioInput::applyVolume(const void *src, void *dest, int len)
+ {
++    Q_ASSERT((src && dest) || len == 0);
+     if (m_volume < 1.f)
+         QAudioHelperInternal::qMultiplySamples(m_volume, m_format, src, dest, len);
+-    else
++    else if (len)
+         memcpy(dest, src, len);
+ }
+ 
+Submodule qtpim 02efef5e...f9a8f0fc (commits not present)
+Submodule qtquick3d b85cf622..47defc8b:
+diff --git a/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro b/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
+index ca5c499e..174a075b 100644
+--- a/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
++++ b/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
+@@ -10,7 +10,7 @@ QT_FOR_CONFIG += assetimporters-private
+ include($$OUT_PWD/../qtassetimporters-config.pri)
+ 
+ qtConfig(system-assimp):!if(cross_compile:host_build) {
+-    QMAKE_USE_PRIVATE += assimp
++    QMAKE_USE_PRIVATE += quick3d-assimp
+ } else {
+     include(../../../3rdparty/assimp/assimp.pri)
+ }
+Submodule qtquickcontrols2 3a657dc0..56ce8233:
+diff --git a/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp b/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
+index e5fe734f7..e36922775 100644
+--- a/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
++++ b/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
+@@ -38,6 +38,7 @@
+ #include "qwidgetplatformmenuitem_p.h"
+ 
+ #include <QtGui/qwindow.h>
++#include <QtGui/private/qhighdpiscaling_p.h>
+ #include <QtWidgets/qmenu.h>
+ #include <QtWidgets/qaction.h>
+ 
+@@ -145,7 +146,7 @@ void QWidgetPlatformMenu::showPopup(const QWindow *window, const QRect &targetRe
+ 
+     QPoint targetPos = targetRect.bottomLeft();
+     if (window)
+-        targetPos = window->mapToGlobal(targetPos);
++        targetPos = window->mapToGlobal(QHighDpi::fromNativeLocalPosition(targetPos, window));
+ 
+     const QWidgetPlatformMenuItem *widgetItem = qobject_cast<const QWidgetPlatformMenuItem *>(item);
+     m_menu->popup(targetPos, widgetItem ? widgetItem->action() : nullptr);
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
+index 950e4e099..b81fbea0b 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
+@@ -387,6 +387,17 @@ void QQuickAbstractButtonPrivate::itemImplicitHeightChanged(QQuickItem *item)
+         emit q->implicitIndicatorHeightChanged();
+ }
+ 
++void QQuickAbstractButtonPrivate::itemDestroyed(QQuickItem *item)
++{
++    Q_Q(QQuickAbstractButton);
++    QQuickControlPrivate::itemDestroyed(item);
++    if (item == indicator) {
++        indicator = nullptr;
++        emit q->implicitIndicatorWidthChanged();
++        emit q->implicitIndicatorHeightChanged();
++    }
++}
++
+ QQuickAbstractButton *QQuickAbstractButtonPrivate::findCheckedButton() const
+ {
+     Q_Q(const QQuickAbstractButton);
+@@ -1176,6 +1187,12 @@ QAccessible::Role QQuickAbstractButton::accessibleRole() const
+     }
+     return QAccessible::Button;
+ }
++
++void QQuickAbstractButton::accessiblePressAction()
++{
++    Q_D(QQuickAbstractButton);
++    d->trigger();
++}
+ #endif
+ 
+ QT_END_NAMESPACE
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
+index 0fa48980e..ab66220d0 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
+@@ -209,6 +209,7 @@ protected:
+ #if QT_CONFIG(accessibility)
+     void accessibilityActiveChanged(bool active) override;
+     QAccessible::Role accessibleRole() const override;
++    Q_INVOKABLE void accessiblePressAction();
+ #endif
+ 
+ private:
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
+index 9291c1a87..b729720f2 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
+@@ -109,6 +109,7 @@ public:
+ 
+     void itemImplicitWidthChanged(QQuickItem *item) override;
+     void itemImplicitHeightChanged(QQuickItem *item) override;
++    void itemDestroyed(QQuickItem *item) override;
+ 
+     // copied from qabstractbutton.cpp
+     static const int AUTO_REPEAT_DELAY = 300;
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp b/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
+index 2041e7741..8610cdfae 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
+@@ -145,7 +145,7 @@ int QQuickActionPrivate::ShortcutEntry::shortcutId() const
+ 
+ void QQuickActionPrivate::ShortcutEntry::grab(const QKeySequence &shortcut, bool enabled)
+ {
+-    if (shortcut.isEmpty())
++    if (shortcut.isEmpty() || m_shortcutId)
+         return;
+ 
+     Qt::ShortcutContext context = Qt::WindowShortcut; // TODO
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp b/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
+index f38c2b09c..6eed2a024 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
+@@ -225,6 +225,7 @@ void QQuickContainerPrivate::cleanup()
+     QObject::disconnect(contentModel, &QQmlObjectModel::countChanged, q, &QQuickContainer::countChanged);
+     QObject::disconnect(contentModel, &QQmlObjectModel::childrenChanged, q, &QQuickContainer::contentChildrenChanged);
+     delete contentModel;
++    contentModel = nullptr;
+ }
+ 
+ QQuickItem *QQuickContainerPrivate::itemAt(int index) const
+@@ -436,7 +437,7 @@ void QQuickContainerPrivate::contentChildren_clear(QQmlListProperty<QQuickItem>
+ void QQuickContainerPrivate::updateContentWidth()
+ {
+     Q_Q(QQuickContainer);
+-    if (hasContentWidth || qFuzzyCompare(contentWidth, implicitContentWidth))
++    if (hasContentWidth || qFuzzyCompare(contentWidth, implicitContentWidth) || !contentModel)
+         return;
+ 
+     contentWidth = implicitContentWidth;
+@@ -446,7 +447,7 @@ void QQuickContainerPrivate::updateContentWidth()
+ void QQuickContainerPrivate::updateContentHeight()
+ {
+     Q_Q(QQuickContainer);
+-    if (hasContentHeight || qFuzzyCompare(contentHeight, implicitContentHeight))
++    if (hasContentHeight || qFuzzyCompare(contentHeight, implicitContentHeight) || !contentModel)
+         return;
+ 
+     contentHeight = implicitContentHeight;
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp b/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
+index bbbd0e622..1f4b47343 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
+@@ -845,6 +845,13 @@ void QQuickControlPrivate::executeBackground(bool complete)
+         quickCompleteDeferred(q, backgroundName(), background);
+ }
+ 
++/*
++    \internal
++
++    Hides an item that was replaced by a newer one, rather than
++    deleting it, as the item is typically created in QML and hence
++    we don't own it.
++*/
+ void QQuickControlPrivate::hideOldItem(QQuickItem *item)
+ {
+     if (!item)
+@@ -863,6 +870,29 @@ void QQuickControlPrivate::hideOldItem(QQuickItem *item)
+ #endif
+ }
+ 
++/*
++    \internal
++
++    Named "unhide" because it's used for cases where an item
++    that was previously hidden by \l hideOldItem() wants to be
++    shown by a control again, such as a ScrollBar in ScrollView.
++*/
++void QQuickControlPrivate::unhideOldItem(QQuickControl *control, QQuickItem *item)
++{
++    Q_ASSERT(item);
++    qCDebug(lcItemManagement) << "unhiding old item" << item;
++
++    item->setVisible(true);
++    item->setParentItem(control);
++
++#if QT_CONFIG(accessibility)
++    // Add the item back in to the accessibility tree.
++    QQuickAccessibleAttached *accessible = accessibleAttached(item);
++    if (accessible)
++        accessible->setIgnored(false);
++#endif
++}
++
+ void QQuickControlPrivate::updateBaselineOffset()
+ {
+     Q_Q(QQuickControl);
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h b/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
+index 8e979079e..a6e624c91 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
+@@ -173,6 +173,7 @@ public:
+     virtual void executeBackground(bool complete = false);
+ 
+     static void hideOldItem(QQuickItem *item);
++    static void unhideOldItem(QQuickControl *control, QQuickItem *item);
+ 
+     void updateBaselineOffset();
+ 
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp b/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
+index e6db14eb5..6197d1547 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
+@@ -237,7 +237,7 @@ static QRectF alignedRect(Qt::LayoutDirection direction, Qt::Alignment alignment
+ void QQuickDialogButtonBoxPrivate::resizeContent()
+ {
+     Q_Q(QQuickDialogButtonBox);
+-    if (!contentItem)
++    if (!contentItem || !contentModel)
+         return;
+ 
+     QRectF geometry = q->boundingRect().adjusted(q->leftPadding(), q->topPadding(), -q->rightPadding(), -q->bottomPadding());
+@@ -322,6 +322,9 @@ void QQuickDialogButtonBoxPrivate::updateLayout()
+ qreal QQuickDialogButtonBoxPrivate::getContentWidth() const
+ {
+     Q_Q(const QQuickDialogButtonBox);
++    if (!contentModel)
++        return 0;
++
+     const int count = contentModel->count();
+     const qreal totalSpacing = qMax(0, count - 1) * spacing;
+     qreal totalWidth = totalSpacing;
+@@ -341,6 +344,9 @@ qreal QQuickDialogButtonBoxPrivate::getContentWidth() const
+ qreal QQuickDialogButtonBoxPrivate::getContentHeight() const
+ {
+     Q_Q(const QQuickDialogButtonBox);
++    if (!contentModel)
++        return 0;
++
+     const int count = contentModel->count();
+     qreal maxHeight = 0;
+     for (int i = 0; i < count; ++i) {
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp b/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
+index 91bd59184..0ce518f84 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
+@@ -399,8 +399,11 @@ void QQuickOverlay::itemChange(ItemChange change, const ItemChangeData &data)
+     Q_D(QQuickOverlay);
+     QQuickItem::itemChange(change, data);
+ 
+-    if (change == ItemChildAddedChange || change == ItemChildRemovedChange)
++    if (change == ItemChildAddedChange || change == ItemChildRemovedChange) {
+         setVisible(!d->allDrawers.isEmpty() || !childItems().isEmpty());
++        if (data.item->parent() == d->mouseGrabberPopup)
++            d->setMouseGrabberPopup(nullptr);
++    }
+ }
+ 
+ void QQuickOverlay::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp b/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
+index 4e2f509db..1c4b308cd 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
+@@ -797,6 +797,14 @@ void QQuickScrollBarAttachedPrivate::initHorizontal()
+     if (parent && parent == flickable->parentItem())
+         horizontal->stackAfter(flickable);
+ 
++    // If a scroll bar was previously hidden (due to e.g. setting a new contentItem
++    // on a ScrollView), we need to make sure that we un-hide it.
++    // We don't bother checking if the item is actually the old one, because
++    // if it's not, all of the things the function does (setting parent, visibility, etc.)
++    // should be no-ops anyway.
++    if (auto control = qobject_cast<QQuickControl*>(q_ptr->parent()))
++        QQuickControlPrivate::unhideOldItem(control, horizontal);
++
+     layoutHorizontal();
+     horizontal->setSize(area->property("widthRatio").toReal());
+     horizontal->setPosition(area->property("xPosition").toReal());
+@@ -818,6 +826,9 @@ void QQuickScrollBarAttachedPrivate::initVertical()
+     if (parent && parent == flickable->parentItem())
+         vertical->stackAfter(flickable);
+ 
++    if (auto control = qobject_cast<QQuickControl*>(q_ptr->parent()))
++        QQuickControlPrivate::unhideOldItem(control, vertical);
++
+     layoutVertical();
+     vertical->setSize(area->property("heightRatio").toReal());
+     vertical->setPosition(area->property("yPosition").toReal());
+diff --git a/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml b/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
+index 0e8b08352..cd4931184 100644
+--- a/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
++++ b/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
+@@ -576,4 +576,51 @@ TestCase {
+         verify(newHorizontalScrollBar.visible)
+         verify(!oldHorizontalScrollBar.visible)
+     }
++
++    Component {
++        id: bindingToContentItemAndStandaloneFlickable
++
++        Item {
++            width: 200
++            height: 200
++
++            property alias scrollView: scrollView
++
++            ScrollView {
++                id: scrollView
++                anchors.fill: parent
++                contentItem: listView
++
++                property Item someBinding: contentItem
++            }
++            ListView {
++                id: listView
++                model: 10
++                delegate: ItemDelegate {
++                    text: modelData
++                    width: listView.width
++                }
++            }
++        }
++    }
++
++    // Tests that scroll bars show up for a ScrollView where
++    // - its contentItem is declared as a standalone, separate item
++    // - there is a binding to contentItem (which causes a default Flickable to be created)
++    function test_bindingToContentItemAndStandaloneFlickable() {
++        let root = createTemporaryObject(bindingToContentItemAndStandaloneFlickable, testCase)
++        verify(root)
++
++        let control = root.scrollView
++        let verticalScrollBar = control.ScrollBar.vertical
++        let horizontalScrollBar = control.ScrollBar.horizontal
++        compare(verticalScrollBar.parent, control)
++        compare(horizontalScrollBar.parent, control)
++        verify(verticalScrollBar.visible)
++        verify(horizontalScrollBar.visible)
++
++        mouseDrag(verticalScrollBar, verticalScrollBar.width / 2, verticalScrollBar.height / 2, 0, 50)
++        verify(verticalScrollBar.active)
++        verify(horizontalScrollBar.active)
++    }
+ }
+diff --git a/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml b/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
+index b3fab41ca..10b6baa02 100644
+--- a/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
++++ b/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
+@@ -608,4 +608,27 @@ TestCase {
+         mouseClick(control.indicator)
+         verify(control.activeFocus)
+     }
++
++    Component {
++        id: deletionOrder1
++        Item {
++            Image { id: innerImage }
++            Switch { indicator: innerImage }
++        }
++    }
++
++    Component {
++        id: deletionOrder2
++        Item {
++            Switch { indicator: innerImage }
++            Image { id: innerImage }
++        }
++    }
++
++    function test_deletionOrder() {
++        var control1 = createTemporaryObject(deletionOrder1, testCase)
++        verify(control1)
++        var control2 = createTemporaryObject(deletionOrder2, testCase)
++        verify(control2)
++    }
+ }
+diff --git a/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml b/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml
+new file mode 100644
+index 000000000..9e4598b9f
+--- /dev/null
++++ b/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml
+@@ -0,0 +1,78 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the test suite of the Qt Toolkit.
++**
++** $QT_BEGIN_LICENSE:BSD$
++** Commercial License Usage
++** Licensees holding valid commercial Qt licenses may use this file in
++** accordance with the commercial license agreement provided with the
++** Software or, alternatively, in accordance with the terms contained in
++** a written agreement between you and The Qt Company. For licensing terms
++** and conditions see https://www.qt.io/terms-conditions. For further
++** information use the contact form at https://www.qt.io/contact-us.
++**
++** BSD License Usage
++** Alternatively, you may use this file under the terms of the BSD license
++** as follows:
++**
++** "Redistribution and use in source and binary forms, with or without
++** modification, are permitted provided that the following conditions are
++** met:
++**   * Redistributions of source code must retain the above copyright
++**     notice, this list of conditions and the following disclaimer.
++**   * Redistributions in binary form must reproduce the above copyright
++**     notice, this list of conditions and the following disclaimer in
++**     the documentation and/or other materials provided with the
++**     distribution.
++**   * Neither the name of The Qt Company Ltd nor the names of its
++**     contributors may be used to endorse or promote products derived
++**     from this software without specific prior written permission.
++**
++**
++** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
++** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
++** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
++** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
++** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
++** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
++** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
++** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
++** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
++** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
++** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
++**
++** $QT_END_LICENSE$
++**
++****************************************************************************/
++
++import QtQuick 2.15
++import QtQuick.Controls 2.15
++
++ApplicationWindow {
++    id: window
++    width: 400
++    height: 400
++    title: "releaseAfterExitTransition"
++
++    property alias popup: popup
++    property alias modalPopup: modalPopup
++
++    Popup {
++        id: popup
++        y: parent.height - height
++        width: 50
++        height: 50
++    }
++
++    Popup {
++        id: modalPopup
++        modal: true
++        y: parent.height - height
++        width: 50
++        height: 50
++        exit:  Transition { PauseAnimation { duration: 100 } }
++    }
++}
+diff --git a/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp b/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
+index 54952d128..3d50e2dd4 100644
+--- a/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
++++ b/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
+@@ -100,6 +100,7 @@ private slots:
+     void invisibleToolTipOpen();
+     void centerInOverlayWithinStackViewItem();
+     void destroyDuringExitTransition();
++    void releaseAfterExitTransition();
+ };
+ 
+ void tst_QQuickPopup::initTestCase()
+@@ -1575,6 +1576,34 @@ void tst_QQuickPopup::destroyDuringExitTransition()
+     QVERIFY(!button->isDown());
+ }
+ 
++void tst_QQuickPopup::releaseAfterExitTransition()
++{
++    QQuickApplicationHelper helper(this, "releaseAfterExitTransition.qml");
++    QVERIFY2(helper.ready, helper.failureMessage());
++
++    QQuickWindow *window = helper.window;
++    window->show();
++    QVERIFY(QTest::qWaitForWindowActive(window));
++
++    QQuickOverlay *overlay = QQuickOverlay::overlay(window);
++    QQuickPopup *modalPopup = window->property("modalPopup").value<QQuickPopup *>();
++    QQuickPopup *popup = window->property("popup").value<QQuickPopup *>();
++
++    modalPopup->open();
++    QTRY_VERIFY(modalPopup->isOpened());
++
++    QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++    // wait until the transition is finished and the overlay hides itself
++    QTRY_VERIFY(!overlay->isVisible());
++    QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++
++    popup->open();
++    QTRY_VERIFY(popup->isOpened());
++    QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++    QTRY_VERIFY(!popup->isOpened());
++}
++
++
+ QTEST_QUICKCONTROLS_MAIN(tst_QQuickPopup)
+ 
+ #include "tst_qquickpopup.moc"
+Submodule qtscript 5be95f96...4d8e4bd2 (commits not present)
+Submodule qtspeech 17fc9fde..255845e2:
+diff --git a/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp b/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
+index 6eb74b8..bcc7dd1 100644
+--- a/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
++++ b/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
+@@ -357,7 +357,9 @@ QVector<QLocale> QTextToSpeechEngineSpeechd::availableLocales() const
+ 
+ QVector<QVoice> QTextToSpeechEngineSpeechd::availableVoices() const
+ {
+-    return m_voices.values(m_currentLocale.name()).toVector();
++    QList<QVoice> resultList = m_voices.values(m_currentLocale.name());
++    std::reverse(resultList.begin(), resultList.end());
++    return resultList.toVector();
+ }
+ 
+ // We have no way of knowing our own client_id since speech-dispatcher seems to be incomplete
+Submodule qtsvg 0c05780e..a7a0f249:
+diff --git a/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp b/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
+index 561e77e..12e0574 100644
+--- a/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
++++ b/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
+@@ -191,6 +191,8 @@ bool QSvgIOHandler::read(QImage *image)
+             }
+         }
+         if (!finalSize.isEmpty()) {
++            if (qMax(finalSize.width(), finalSize.height()) > 0xffff)
++                return false; // Assume corrupted file
+             image->fill(d->backColor.rgba());
+             QPainter p(image);
+             d->r.render(&p, bounds);
+diff --git a/qtsvg/src/svg/qsvghandler.cpp b/qtsvg/src/svg/qsvghandler.cpp
+index a5f877f..8dda563 100644
+--- a/qtsvg/src/svg/qsvghandler.cpp
++++ b/qtsvg/src/svg/qsvghandler.cpp
+@@ -1393,9 +1393,10 @@ static void parseFont(QSvgNode *node,
+         case FontSizeNone:
+             break;
+         case FontSizeValue: {
+-            QSvgHandler::LengthType dummy; // should always be pixel size
+-            fontStyle->setSize(qMin(parseLength(attributes.fontSize, dummy, handler),
+-                                    qreal(0xffff)));
++            QSvgHandler::LengthType type;
++            qreal fs = parseLength(attributes.fontSize, type, handler);
++            fs = convertToPixels(fs, true, type);
++            fontStyle->setSize(qMin(fs, qreal(0xffff)));
+         }
+             break;
+         default:
+@@ -2513,6 +2514,8 @@ static bool parseAnimateTransformNode(QSvgNode *parent,
+             ++s;
+         }
+     }
++    if (vals.count() % 3 != 0)
++        return false;
+ 
+     bool ok = true;
+     int begin = parseClockValue(beginStr, &ok);
+@@ -2576,6 +2579,8 @@ static QSvgNode *createCircleNode(QSvgNode *parent,
+     qreal ncx = toDouble(cx);
+     qreal ncy = toDouble(cy);
+     qreal nr  = toDouble(r);
++    if (nr < 0.0)
++        return nullptr;
+ 
+     QRectF rect(ncx-nr, ncy-nr, nr*2, nr*2);
+     QSvgNode *circle = new QSvgCircle(parent, rect);
+@@ -3046,15 +3051,16 @@ static QSvgStyleProperty *createRadialGradientNode(QSvgNode *node,
+ 
+     qreal ncx = 0.5;
+     qreal ncy = 0.5;
+-    qreal nr  = 0.5;
+     if (!cx.isEmpty())
+         ncx = toDouble(cx);
+     if (!cy.isEmpty())
+         ncy = toDouble(cy);
++
++    qreal nr = 0.0;
+     if (!r.isEmpty())
+         nr = toDouble(r);
+-    if (nr < 0.5)
+-        nr = 0.5;
++    if (nr <= 0.0)
++        return nullptr;
+ 
+     qreal nfx = ncx;
+     if (!fx.isEmpty())
+@@ -3350,7 +3356,9 @@ static QSvgNode *createTextNode(QSvgNode *parent,
+     //### editable and rotate not handled
+     QSvgHandler::LengthType type;
+     qreal nx = parseLength(x, type, handler);
++    nx = convertToPixels(nx, true, type);
+     qreal ny = parseLength(y, type, handler);
++    ny = convertToPixels(ny, true, type);
+ 
+     QSvgNode *text = new QSvgText(parent, QPointF(nx, ny));
+     return text;
+@@ -3691,9 +3699,7 @@ void QSvgHandler::parse()
+         case QXmlStreamReader::EndElement:
+             endElement(xml->name());
+             ++remainingUnfinishedElements;
+-            // if we are using somebody else's qxmlstreamreader
+-            // we should not read until the end of the stream
+-            done = !m_ownsReader && (xml->name() == QLatin1String("svg"));
++            done = (xml->name() == QLatin1String("svg"));
+             break;
+         case QXmlStreamReader::Characters:
+             characters(xml->text());
+diff --git a/qtsvg/src/svg/qsvgstructure.cpp b/qtsvg/src/svg/qsvgstructure.cpp
+index b89608b..89c9e4e 100644
+--- a/qtsvg/src/svg/qsvgstructure.cpp
++++ b/qtsvg/src/svg/qsvgstructure.cpp
+@@ -255,9 +255,13 @@ inline static bool isSupportedSvgFeature(const QString &str)
+     };
+ 
+     if (str.length() <= MAX_WORD_LENGTH && str.length() >= MIN_WORD_LENGTH) {
++        const char16_t unicode44 = str.at(44).unicode();
++        const char16_t unicode45 = str.at(45).unicode();
++        if (unicode44 >= sizeof(asso_values) || unicode45 >= sizeof(asso_values))
++            return false;
+         const int key = str.length()
+-                        + asso_values[str.at(45).unicode()]
+-                        + asso_values[str.at(44).unicode()];
++                        + asso_values[unicode45]
++                        + asso_values[unicode44];
+         if (key <= MAX_HASH_VALUE && key >= 0)
+             return str == QLatin1String(wordlist[key]);
+     }
+diff --git a/qtsvg/src/svg/qsvgtinydocument.cpp b/qtsvg/src/svg/qsvgtinydocument.cpp
+index 63d0797..19e7154 100644
+--- a/qtsvg/src/svg/qsvgtinydocument.cpp
++++ b/qtsvg/src/svg/qsvgtinydocument.cpp
+@@ -433,8 +433,16 @@ void QSvgTinyDocument::draw(QPainter *p, QSvgExtraStates &)
+     draw(p);
+ }
+ 
++static bool isValidMatrix(const QTransform &transform)
++{
++    qreal determinant = transform.determinant();
++    return qIsFinite(determinant);
++}
++
+ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect, const QRectF &sourceRect)
+ {
++    QTransform oldTransform = p->worldTransform();
++
+     QRectF target = targetRect;
+     if (target.isEmpty()) {
+         QPaintDevice *dev = p->device();
+@@ -487,6 +495,9 @@ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect,
+         }
+ #endif
+     }
++
++    if (!isValidMatrix(p->worldTransform()))
++        p->setWorldTransform(oldTransform);
+ }
+ 
+ QRectF QSvgTinyDocument::boundsOnElement(const QString &id) const
+diff --git a/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp b/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
+index 36c76ec..db71e02 100644
+--- a/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
++++ b/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
+@@ -86,6 +86,8 @@ private slots:
+     void oss_fuzz_23731();
+     void oss_fuzz_24131();
+     void oss_fuzz_24738();
++    void illegalAnimateTransform_data();
++    void illegalAnimateTransform();
+ 
+ #ifndef QT_NO_COMPRESS
+     void testGzLoading();
+@@ -1646,5 +1648,22 @@ void tst_QSvgRenderer::oss_fuzz_24738()
+     QSvgRenderer().load(QByteArray("<svg><path d=\"a 2 1e-212.....\">"));
+ }
+ 
++void tst_QSvgRenderer::illegalAnimateTransform_data()
++{
++    QTest::addColumn<QByteArray>("svg");
++
++    QTest::newRow("case1") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" values=\"8,0,5,0\">");
++    QTest::newRow("case2") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" values=\"1,2\">");
++    QTest::newRow("case3") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" from=\".. 5 2\" to=\"f\">");
++    QTest::newRow("case4") << QByteArray("<svg><animateTransform type=\"scale\" begin=\"1\" dur=\"2\" by=\"--,..\">");
++}
++
++void tst_QSvgRenderer::illegalAnimateTransform()
++{
++    QFETCH(QByteArray, svg);
++    QSvgRenderer renderer;
++    QVERIFY(!renderer.load(svg)); // also shouldn't assert
++}
++
+ QTEST_MAIN(tst_QSvgRenderer)
+ #include "tst_qsvgrenderer.moc"
+Submodule qttools 6914f7c8..090e526e:
+diff --git a/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp b/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
+index feab1e2d5..cbfb82507 100644
+--- a/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
++++ b/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
+@@ -445,7 +445,9 @@ bool HelpGeneratorPrivate::insertFiles(const QStringList &files, const QString &
+     if (filterSetId < 0)
+         return false;
+     ++filterSetId;
+-    for (int attId : qAsConst(filterAtts)) {
++    QList<int> attValues = filterAtts.values();
++    std::sort(attValues.begin(), attValues.end());
++    for (int attId : qAsConst(attValues)) {
+         m_query->prepare(QLatin1String("INSERT INTO FileAttributeSetTable "
+             "VALUES(?, ?)"));
+         m_query->bindValue(0, filterSetId);
+Submodule qtwayland dfb0129c..2904e1b3:
+diff --git a/qtwayland/src/client/configure.json b/qtwayland/src/client/configure.json
+index 2f424580..29222357 100644
+--- a/qtwayland/src/client/configure.json
++++ b/qtwayland/src/client/configure.json
+@@ -149,8 +149,7 @@
+                     "#endif"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "vulkan-server-buffer": {
+             "label": "Vulkan Buffer Sharing",
+@@ -168,7 +167,8 @@
+                     "exportAllocInfo.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR;",
+                     "return 0;"
+                 ]
+-            }
++            },
++            "use": "wayland-client"
+         },
+         "egl_1_5-wayland": {
+             "label": "EGL 1.5 with Wayland Platform",
+@@ -183,7 +183,7 @@
+                     "eglGetPlatformDisplay(EGL_PLATFORM_WAYLAND_EXT, (struct wl_display *)(nullptr), nullptr);"
+                 ]
+             },
+-            "use": "egl"
++            "use": "egl wayland-client"
+         }
+     },
+ 
+diff --git a/qtwayland/src/client/global/qwaylandclientextension.cpp b/qtwayland/src/client/global/qwaylandclientextension.cpp
+index 125b1e19..edccfe63 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension.cpp
++++ b/qtwayland/src/client/global/qwaylandclientextension.cpp
+@@ -74,7 +74,10 @@ void QWaylandClientExtensionPrivate::handleRegistryGlobal(void *data, ::wl_regis
+ void QWaylandClientExtension::addRegistryListener()
+ {
+     Q_D(QWaylandClientExtension);
+-    d->waylandIntegration->display()->addRegistryListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++    if (!d->registered) {
++        d->waylandIntegration->display()->addRegistryListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++        d->registered = true;
++    }
+ }
+ 
+ QWaylandClientExtension::QWaylandClientExtension(const int ver)
+@@ -88,6 +91,13 @@ QWaylandClientExtension::QWaylandClientExtension(const int ver)
+     QMetaObject::invokeMethod(this, "addRegistryListener", Qt::QueuedConnection);
+ }
+ 
++QWaylandClientExtension::~QWaylandClientExtension()
++{
++    Q_D(QWaylandClientExtension);
++    if (d->registered && !QCoreApplication::closingDown())
++        d->waylandIntegration->display()->removeListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++}
++
+ QtWaylandClient::QWaylandIntegration *QWaylandClientExtension::integration() const
+ {
+     Q_D(const QWaylandClientExtension);
+diff --git a/qtwayland/src/client/global/qwaylandclientextension.h b/qtwayland/src/client/global/qwaylandclientextension.h
+index 98272e57..5bd28398 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension.h
++++ b/qtwayland/src/client/global/qwaylandclientextension.h
+@@ -63,6 +63,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandClientExtension : public QObject
+     Q_PROPERTY(bool active READ isActive NOTIFY activeChanged)
+ public:
+     QWaylandClientExtension(const int version);
++    ~QWaylandClientExtension();
+ 
+     QtWaylandClient::QWaylandIntegration *integration() const;
+     int version() const;
+diff --git a/qtwayland/src/client/global/qwaylandclientextension_p.h b/qtwayland/src/client/global/qwaylandclientextension_p.h
+index 69cc46a0..9091efbe 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension_p.h
++++ b/qtwayland/src/client/global/qwaylandclientextension_p.h
+@@ -68,6 +68,7 @@ public:
+     QtWaylandClient::QWaylandIntegration *waylandIntegration = nullptr;
+     int version = -1;
+     bool active = false;
++    bool registered = false;
+ };
+ 
+ class Q_WAYLAND_CLIENT_EXPORT QWaylandClientExtensionTemplatePrivate : public QWaylandClientExtensionPrivate
+diff --git a/qtwayland/src/client/qwaylanddatadevice.cpp b/qtwayland/src/client/qwaylanddatadevice.cpp
+index 7e2e3308..e3e60ed5 100644
+--- a/qtwayland/src/client/qwaylanddatadevice.cpp
++++ b/qtwayland/src/client/qwaylanddatadevice.cpp
+@@ -72,6 +72,8 @@ QWaylandDataDevice::QWaylandDataDevice(QWaylandDataDeviceManager *manager, QWayl
+ 
+ QWaylandDataDevice::~QWaylandDataDevice()
+ {
++    if (wl_data_device_get_version(object()) >= WL_DATA_DEVICE_RELEASE_SINCE_VERSION)
++        release();
+ }
+ 
+ QWaylandDataOffer *QWaylandDataDevice::selectionOffer() const
+@@ -110,7 +112,7 @@ QWaylandDataOffer *QWaylandDataDevice::dragOffer() const
+     return m_dragOffer.data();
+ }
+ 
+-bool QWaylandDataDevice::startDrag(QMimeData *mimeData, QWaylandWindow *icon)
++bool QWaylandDataDevice::startDrag(QMimeData *mimeData, Qt::DropActions supportedActions, QWaylandWindow *icon)
+ {
+     auto *seat = m_display->currentInputDevice();
+     auto *origin = seat->pointerFocus();
+@@ -123,7 +125,28 @@ bool QWaylandDataDevice::startDrag(QMimeData *mimeData, QWaylandWindow *icon)
+     }
+ 
+     m_dragSource.reset(new QWaylandDataSource(m_display->dndSelectionHandler(), mimeData));
++
++    if (wl_data_device_get_version(object()) >= 3)
++        m_dragSource->set_actions(dropActionsToWl(supportedActions));
++
+     connect(m_dragSource.data(), &QWaylandDataSource::cancelled, this, &QWaylandDataDevice::dragSourceCancelled);
++    connect(m_dragSource.data(), &QWaylandDataSource::dndResponseUpdated, this, [this](bool accepted, Qt::DropAction action) {
++            auto drag = static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag());
++            // in old versions drop action is not set, so we guess
++            if (wl_data_source_get_version(m_dragSource->object()) < 3) {
++                drag->setResponse(accepted);
++            } else {
++                QPlatformDropQtResponse response(accepted, action);
++                drag->setResponse(response);
++            }
++    });
++    connect(m_dragSource.data(), &QWaylandDataSource::dndDropped, this, [](bool accepted, Qt::DropAction action) {
++        QPlatformDropQtResponse response(accepted, action);
++        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setDropResponse(response);
++    });
++    connect(m_dragSource.data(), &QWaylandDataSource::finished, this, []() {
++        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag();
++    });
+ 
+     start_drag(m_dragSource->object(), origin->wlSurface(), icon->wlSurface(), m_display->currentInputDevice()->serial());
+     return true;
+@@ -152,7 +175,7 @@ void QWaylandDataDevice::data_device_drop()
+         supportedActions = drag->supportedActions();
+     } else if (m_dragOffer) {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     } else {
+         return;
+     }
+@@ -162,7 +185,11 @@ void QWaylandDataDevice::data_device_drop()
+                                                                           QGuiApplication::keyboardModifiers());
+ 
+     if (drag) {
+-        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag(response);
++        auto drag =  static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag());
++        drag->setDropResponse(response);
++        drag->finishDrag();
++    } else if (m_dragOffer) {
++        m_dragOffer->finish();
+     }
+ }
+ 
+@@ -186,7 +213,7 @@ void QWaylandDataDevice::data_device_enter(uint32_t serial, wl_surface *surface,
+         supportedActions = drag->supportedActions();
+     } else if (m_dragOffer) {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     }
+ 
+     const QPlatformDragQtResponse &response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
+@@ -197,11 +224,7 @@ void QWaylandDataDevice::data_device_enter(uint32_t serial, wl_surface *surface,
+         static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setResponse(response);
+     }
+ 
+-    if (response.isAccepted()) {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, m_dragOffer->firstFormat().toUtf8().constData());
+-    } else {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, nullptr);
+-    }
++    sendResponse(supportedActions, response);
+ }
+ 
+ void QWaylandDataDevice::data_device_leave()
+@@ -235,10 +258,10 @@ void QWaylandDataDevice::data_device_motion(uint32_t time, wl_fixed_t x, wl_fixe
+         supportedActions = drag->supportedActions();
+     } else {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     }
+ 
+-    QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
++    const QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
+                                                                           QGuiApplication::mouseButtons(),
+                                                                           QGuiApplication::keyboardModifiers());
+ 
+@@ -246,11 +269,7 @@ void QWaylandDataDevice::data_device_motion(uint32_t time, wl_fixed_t x, wl_fixe
+         static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setResponse(response);
+     }
+ 
+-    if (response.isAccepted()) {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, m_dragOffer->firstFormat().toUtf8().constData());
+-    } else {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, nullptr);
+-    }
++    sendResponse(supportedActions, response);
+ }
+ #endif // QT_CONFIG(draganddrop)
+ 
+@@ -277,14 +296,10 @@ void QWaylandDataDevice::selectionSourceCancelled()
+ #if QT_CONFIG(draganddrop)
+ void QWaylandDataDevice::dragSourceCancelled()
+ {
++    static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag();
+     m_dragSource.reset();
+ }
+ 
+-void QWaylandDataDevice::dragSourceTargetChanged(const QString &mimeType)
+-{
+-    static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->updateTarget(mimeType);
+-}
+-
+ QPoint QWaylandDataDevice::calculateDragPosition(int x, int y, QWindow *wnd) const
+ {
+     QPoint pnt(wl_fixed_to_int(x), wl_fixed_to_int(y));
+@@ -297,6 +312,33 @@ QPoint QWaylandDataDevice::calculateDragPosition(int x, int y, QWindow *wnd) con
+     }
+     return pnt;
+ }
++
++void QWaylandDataDevice::sendResponse(Qt::DropActions supportedActions, const QPlatformDragQtResponse &response)
++{
++    if (response.isAccepted()) {
++        if (wl_data_device_get_version(object()) >= 3)
++            m_dragOffer->set_actions(dropActionsToWl(supportedActions), dropActionsToWl(response.acceptedAction()));
++
++        m_dragOffer->accept(m_enterSerial, m_dragOffer->firstFormat());
++    } else {
++        m_dragOffer->accept(m_enterSerial, QString());
++    }
++}
++
++int QWaylandDataDevice::dropActionsToWl(Qt::DropActions actions)
++{
++
++    int wlActions = WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE;
++    if (actions & Qt::CopyAction)
++        wlActions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY;
++    if (actions & (Qt::MoveAction | Qt::TargetMoveAction))
++        wlActions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE;
++
++    // wayland does not support LinkAction at the time of writing
++    return wlActions;
++}
++
++
+ #endif // QT_CONFIG(draganddrop)
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddatadevice_p.h b/qtwayland/src/client/qwaylanddatadevice_p.h
+index 16c3ad28..801dcc2c 100644
+--- a/qtwayland/src/client/qwaylanddatadevice_p.h
++++ b/qtwayland/src/client/qwaylanddatadevice_p.h
+@@ -64,6 +64,7 @@ QT_REQUIRE_CONFIG(wayland_datadevice);
+ QT_BEGIN_NAMESPACE
+ 
+ class QMimeData;
++class QPlatformDragQtResponse;
+ class QWindow;
+ 
+ namespace QtWaylandClient {
+@@ -89,7 +90,7 @@ public:
+ 
+ #if QT_CONFIG(draganddrop)
+     QWaylandDataOffer *dragOffer() const;
+-    bool startDrag(QMimeData *mimeData, QWaylandWindow *icon);
++    bool startDrag(QMimeData *mimeData, Qt::DropActions supportedActions, QWaylandWindow *icon);
+     void cancelDrag();
+ #endif
+ 
+@@ -109,13 +110,16 @@ private Q_SLOTS:
+ 
+ #if QT_CONFIG(draganddrop)
+     void dragSourceCancelled();
+-    void dragSourceTargetChanged(const QString &mimeType);
+ #endif
+ 
+ private:
+ #if QT_CONFIG(draganddrop)
+     QPoint calculateDragPosition(int x, int y, QWindow *wnd) const;
+ #endif
++    void sendResponse(Qt::DropActions supportedActions, const QPlatformDragQtResponse &response);
++
++    static int dropActionsToWl(Qt::DropActions dropActions);
++
+ 
+     QWaylandDisplay *m_display = nullptr;
+     QWaylandInputDevice *m_inputDevice = nullptr;
+diff --git a/qtwayland/src/client/qwaylanddatadevicemanager.cpp b/qtwayland/src/client/qwaylanddatadevicemanager.cpp
+index 35d67307..6dc4f77f 100644
+--- a/qtwayland/src/client/qwaylanddatadevicemanager.cpp
++++ b/qtwayland/src/client/qwaylanddatadevicemanager.cpp
+@@ -50,8 +50,8 @@ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
+-QWaylandDataDeviceManager::QWaylandDataDeviceManager(QWaylandDisplay *display, uint32_t id)
+-    : wl_data_device_manager(display->wl_registry(), id, 1)
++QWaylandDataDeviceManager::QWaylandDataDeviceManager(QWaylandDisplay *display, int version, uint32_t id)
++    : wl_data_device_manager(display->wl_registry(), id, qMin(version, 3))
+     , m_display(display)
+ {
+     // Create transfer devices for all input devices.
+diff --git a/qtwayland/src/client/qwaylanddatadevicemanager_p.h b/qtwayland/src/client/qwaylanddatadevicemanager_p.h
+index bd05c0fb..510d9be4 100644
+--- a/qtwayland/src/client/qwaylanddatadevicemanager_p.h
++++ b/qtwayland/src/client/qwaylanddatadevicemanager_p.h
+@@ -68,7 +68,7 @@ class QWaylandInputDevice;
+ class Q_WAYLAND_CLIENT_EXPORT QWaylandDataDeviceManager : public QtWayland::wl_data_device_manager
+ {
+ public:
+-    QWaylandDataDeviceManager(QWaylandDisplay *display, uint32_t id);
++    QWaylandDataDeviceManager(QWaylandDisplay *display, int version, uint32_t id);
+     ~QWaylandDataDeviceManager() override;
+ 
+     QWaylandDataDevice *getDataDevice(QWaylandInputDevice *inputDevice);
+diff --git a/qtwayland/src/client/qwaylanddataoffer.cpp b/qtwayland/src/client/qwaylanddataoffer.cpp
+index 2297e8a1..fe0ea8c9 100644
+--- a/qtwayland/src/client/qwaylanddataoffer.cpp
++++ b/qtwayland/src/client/qwaylanddataoffer.cpp
+@@ -82,6 +82,15 @@ QMimeData *QWaylandDataOffer::mimeData()
+     return m_mimeData.data();
+ }
+ 
++Qt::DropActions QWaylandDataOffer::supportedActions() const
++{
++    if (wl_data_offer_get_version(const_cast<::wl_data_offer*>(object())) < 3) {
++        return Qt::MoveAction | Qt::CopyAction;
++    }
++
++    return m_supportedActions;
++}
++
+ void QWaylandDataOffer::startReceiving(const QString &mimeType, int fd)
+ {
+     receive(mimeType, fd);
+@@ -93,6 +102,22 @@ void QWaylandDataOffer::data_offer_offer(const QString &mime_type)
+     m_mimeData->appendFormat(mime_type);
+ }
+ 
++void QWaylandDataOffer::data_offer_action(uint32_t dnd_action)
++{
++    Q_UNUSED(dnd_action);
++    // This is the compositor telling the drag target what action it should perform
++    // It does not map nicely into Qt final drop semantics, other than pretending there is only one supported action?
++}
++
++void QWaylandDataOffer::data_offer_source_actions(uint32_t source_actions)
++{
++    m_supportedActions = Qt::DropActions();
++    if (source_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
++        m_supportedActions |= Qt::MoveAction;
++    if (source_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
++        m_supportedActions |= Qt::CopyAction;
++}
++
+ QWaylandMimeData::QWaylandMimeData(QWaylandAbstractDataOffer *dataOffer)
+     : m_dataOffer(dataOffer)
+ {
+@@ -163,17 +188,18 @@ QVariant QWaylandMimeData::retrieveData_sys(const QString &mimeType, QVariant::T
+ 
+ int QWaylandMimeData::readData(int fd, QByteArray &data) const
+ {
+-    fd_set readset;
+-    FD_ZERO(&readset);
+-    FD_SET(fd, &readset);
+-    struct timeval timeout;
++    struct pollfd readset;
++    readset.fd = fd;
++    readset.events = POLLIN;
++    struct timespec timeout;
+     timeout.tv_sec = 1;
+-    timeout.tv_usec = 0;
++    timeout.tv_nsec = 0;
++
+ 
+     Q_FOREVER {
+-        int ready = select(FD_SETSIZE, &readset, nullptr, nullptr, &timeout);
++        int ready = qt_safe_poll(&readset, 1, &timeout);
+         if (ready < 0) {
+-            qWarning() << "QWaylandDataOffer: select() failed";
++            qWarning() << "QWaylandDataOffer: qt_safe_poll() failed";
+             return -1;
+         } else if (ready == 0) {
+             qWarning("QWaylandDataOffer: timeout reading from pipe");
+diff --git a/qtwayland/src/client/qwaylanddataoffer_p.h b/qtwayland/src/client/qwaylanddataoffer_p.h
+index 9cf1483c..6f667398 100644
+--- a/qtwayland/src/client/qwaylanddataoffer_p.h
++++ b/qtwayland/src/client/qwaylanddataoffer_p.h
+@@ -82,6 +82,7 @@ public:
+     explicit QWaylandDataOffer(QWaylandDisplay *display, struct ::wl_data_offer *offer);
+     ~QWaylandDataOffer() override;
+     QMimeData *mimeData() override;
++    Qt::DropActions supportedActions() const;
+ 
+     QString firstFormat() const;
+ 
+@@ -89,10 +90,13 @@ public:
+ 
+ protected:
+     void data_offer_offer(const QString &mime_type) override;
++    void data_offer_source_actions(uint32_t source_actions) override;
++    void data_offer_action(uint32_t dnd_action) override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+     QScopedPointer<QWaylandMimeData> m_mimeData;
++    Qt::DropActions m_supportedActions;
+ };
+ 
+ 
+diff --git a/qtwayland/src/client/qwaylanddatasource.cpp b/qtwayland/src/client/qwaylanddatasource.cpp
+index f45122fb..5599cbd4 100644
+--- a/qtwayland/src/client/qwaylanddatasource.cpp
++++ b/qtwayland/src/client/qwaylanddatasource.cpp
+@@ -101,7 +101,32 @@ void QWaylandDataSource::data_source_send(const QString &mime_type, int32_t fd)
+ 
+ void QWaylandDataSource::data_source_target(const QString &mime_type)
+ {
+-    Q_EMIT targetChanged(mime_type);
++    m_accepted = !mime_type.isEmpty();
++    Q_EMIT dndResponseUpdated(m_accepted, m_dropAction);
++}
++
++void QWaylandDataSource::data_source_action(uint32_t action)
++{
++    Qt::DropAction qtAction = Qt::IgnoreAction;
++
++    if (action == WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
++        qtAction = Qt::MoveAction;
++    else if (action == WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
++        qtAction = Qt::CopyAction;
++
++    m_dropAction = qtAction;
++    Q_EMIT dndResponseUpdated(m_accepted, m_dropAction);
++}
++
++void QWaylandDataSource::data_source_dnd_finished()
++{
++    Q_EMIT finished();
++}
++
++void QWaylandDataSource::data_source_dnd_drop_performed()
++{
++
++    Q_EMIT dndDropped(m_accepted, m_dropAction);
+ }
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddatasource_p.h b/qtwayland/src/client/qwaylanddatasource_p.h
+index 25afff79..96f07bc3 100644
+--- a/qtwayland/src/client/qwaylanddatasource_p.h
++++ b/qtwayland/src/client/qwaylanddatasource_p.h
+@@ -77,17 +77,25 @@ public:
+     QMimeData *mimeData() const;
+ 
+ Q_SIGNALS:
+-    void targetChanged(const QString &mime_type);
+     void cancelled();
++    void finished();
++
++    void dndResponseUpdated(bool accepted, Qt::DropAction action);
++    void dndDropped(bool accepted, Qt::DropAction action);
+ 
+ protected:
+     void data_source_cancelled() override;
+     void data_source_send(const QString &mime_type, int32_t fd) override;
+     void data_source_target(const QString &mime_type) override;
++    void data_source_dnd_drop_performed() override;
++    void data_source_dnd_finished() override;
++    void data_source_action(uint32_t action) override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+     QMimeData *m_mime_data = nullptr;
++    bool m_accepted = false;
++    Qt::DropAction m_dropAction = Qt::IgnoreAction;
+ };
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddisplay.cpp b/qtwayland/src/client/qwaylanddisplay.cpp
+index f10c1f79..c01e238b 100644
+--- a/qtwayland/src/client/qwaylanddisplay.cpp
++++ b/qtwayland/src/client/qwaylanddisplay.cpp
+@@ -85,10 +85,203 @@
+ 
+ #include <errno.h>
+ 
++#include <tuple> // for std::tie
++
++static void checkWaylandError(struct wl_display *display)
++{
++    int ecode = wl_display_get_error(display);
++    if ((ecode == EPIPE || ecode == ECONNRESET)) {
++        // special case this to provide a nicer error
++        qWarning("The Wayland connection broke. Did the Wayland compositor die?");
++    } else {
++        qWarning("The Wayland connection experienced a fatal error: %s", strerror(ecode));
++    }
++    _exit(1);
++}
++
+ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
++class EventThread : public QThread
++{
++    Q_OBJECT
++public:
++    enum OperatingMode {
++        EmitToDispatch, // Emit the signal, allow dispatching in a differnt thread.
++        SelfDispatch, // Dispatch the events inside this thread.
++    };
++
++    EventThread(struct wl_display * wl, struct wl_event_queue * ev_queue,
++                OperatingMode mode)
++        : m_fd(wl_display_get_fd(wl))
++        , m_pipefd{ -1, -1 }
++        , m_wldisplay(wl)
++        , m_wlevqueue(ev_queue)
++        , m_mode(mode)
++        , m_reading(true)
++        , m_quitting(false)
++    {
++        setObjectName(QStringLiteral("WaylandEventThread"));
++    }
++
++    void readAndDispatchEvents()
++    {
++        /*
++         * Dispatch pending events and flush the requests at least once. If the event thread
++         * is not reading, try to call _prepare_read() to allow the event thread to poll().
++         * If that fails, re-try dispatch & flush again until _prepare_read() is successful.
++         *
++         * This allow any call to readAndDispatchEvents() to start event thread's polling,
++         * not only the one issued from event thread's waitForReading(), which means functions
++         * called from dispatch_pending() can safely spin an event loop.
++         */
++        for (;;) {
++            if (dispatchQueuePending() < 0) {
++                checkWaylandError(m_wldisplay);
++                return;
++            }
++
++            wl_display_flush(m_wldisplay);
++
++            // We have to check if event thread is reading every time we dispatch
++            // something, as that may recursively call this function.
++            if (m_reading.loadAcquire())
++                break;
++
++            if (prepareReadQueue() == 0) {
++                QMutexLocker l(&m_mutex);
++                m_reading.storeRelease(true);
++                m_cond.wakeOne();
++                break;
++            }
++        }
++    }
++
++    void stop()
++    {
++        // We have to both write to the pipe and set the flag, as the thread may be
++        // either in the poll() or waiting for _prepare_read().
++        if (m_pipefd[1] != -1 && write(m_pipefd[1], "\0", 1) == -1)
++            qWarning("Failed to write to the pipe: %s.", strerror(errno));
++
++        {
++            QMutexLocker l(&m_mutex);
++            m_quitting = true;
++            m_cond.wakeOne();
++        }
++
++        wait();
++    }
++
++Q_SIGNALS:
++    void needReadAndDispatch();
++
++protected:
++    void run() override
++    {
++        // we use this pipe to make the loop exit otherwise if we simply used a flag on the loop condition, if stop() gets
++        // called while poll() is blocking the thread will never quit since there are no wayland messages coming anymore.
++        struct Pipe
++        {
++            Pipe(int *fds)
++                : fds(fds)
++            {
++                if (qt_safe_pipe(fds) != 0)
++                    qWarning("Pipe creation failed. Quitting may hang.");
++            }
++            ~Pipe()
++            {
++                if (fds[0] != -1) {
++                    close(fds[0]);
++                    close(fds[1]);
++                }
++            }
++
++            int *fds;
++        } pipe(m_pipefd);
++
++        // Make the main thread call wl_prepare_read(), dispatch the pending messages and flush the
++        // outbound ones. Wait until it's done before proceeding, unless we're told to quit.
++        while (waitForReading()) {
++            pollfd fds[2] = { { m_fd, POLLIN, 0 }, { m_pipefd[0], POLLIN, 0 } };
++            poll(fds, 2, -1);
++
++            if (fds[1].revents & POLLIN) {
++                // we don't really care to read the byte that was written here since we're closing down
++                wl_display_cancel_read(m_wldisplay);
++                break;
++            }
++
++            if (fds[0].revents & POLLIN)
++                wl_display_read_events(m_wldisplay);
++                // The polll was succesfull and the event thread did the wl_display_read_events(). On the next iteration of the loop
++                // the event sent to the main thread will cause it to dispatch the messages just read, unless the loop exits in which
++                // case we don't care anymore about them.
++            else
++                wl_display_cancel_read(m_wldisplay);
++        }
++    }
++
++private:
++    bool waitForReading()
++    {
++        Q_ASSERT(QThread::currentThread() == this);
++
++        m_reading.storeRelease(false);
++
++        if (m_mode == SelfDispatch) {
++            readAndDispatchEvents();
++        } else {
++            Q_EMIT needReadAndDispatch();
++
++            QMutexLocker lock(&m_mutex);
++            // m_reading might be set from our emit or some other invocation of
++            // readAndDispatchEvents().
++            while (!m_reading.loadRelaxed() && !m_quitting)
++                m_cond.wait(&m_mutex);
++        }
++
++        return !m_quitting;
++    }
++
++    int dispatchQueuePending()
++    {
++        if (m_wlevqueue)
++            return wl_display_dispatch_queue_pending(m_wldisplay, m_wlevqueue);
++        else
++            return wl_display_dispatch_pending(m_wldisplay);
++    }
++
++    int prepareReadQueue()
++    {
++        if (m_wlevqueue)
++            return wl_display_prepare_read_queue(m_wldisplay, m_wlevqueue);
++        else
++            return wl_display_prepare_read(m_wldisplay);
++    }
++
++    int m_fd;
++    int m_pipefd[2];
++    wl_display *m_wldisplay;
++    wl_event_queue *m_wlevqueue;
++    OperatingMode m_mode;
++
++    /* Concurrency note when operating in EmitToDispatch mode:
++     * m_reading is set to false inside event thread's waitForReading(), and is
++     * set to true inside main thread's readAndDispatchEvents().
++     * The lock is not taken when setting m_reading to false, as the main thread
++     * is not actively waiting for it to turn false. However, the lock is taken
++     * inside readAndDispatchEvents() before setting m_reading to true,
++     * as the event thread is actively waiting for it under the wait condition.
++     */
++
++    QAtomicInteger<bool> m_reading;
++    bool m_quitting;
++    QMutex m_mutex;
++    QWaitCondition m_cond;
++};
++
+ Q_LOGGING_CATEGORY(lcQpaWayland, "qt.qpa.wayland"); // for general (uncategorized) Wayland platform logging
+ 
+ struct wl_surface *QWaylandDisplay::createSurface(void *handle)
+@@ -158,17 +351,16 @@ QWaylandDisplay::QWaylandDisplay(QWaylandIntegration *waylandIntegration)
+     if (!mXkbContext)
+         qCWarning(lcQpaWayland, "failed to create xkb context");
+ #endif
+-
+-    forceRoundTrip();
+-
+-    if (!mWaitingScreens.isEmpty()) {
+-        // Give wl_output.done and zxdg_output_v1.done events a chance to arrive
+-        forceRoundTrip();
+-    }
+ }
+ 
+ QWaylandDisplay::~QWaylandDisplay(void)
+ {
++    if (m_eventThread)
++        m_eventThread->stop();
++
++    if (m_frameEventQueueThread)
++        m_frameEventQueueThread->stop();
++
+     if (mSyncCallback)
+         wl_callback_destroy(mSyncCallback);
+ 
+@@ -187,6 +379,21 @@ QWaylandDisplay::~QWaylandDisplay(void)
+ #endif
+     if (mDisplay)
+         wl_display_disconnect(mDisplay);
++
++    if (m_frameEventQueue)
++        wl_event_queue_destroy(m_frameEventQueue);
++}
++
++// Steps which is called just after constructor. This separates registry_global() out of the constructor
++// so that factory functions in integration can be overridden.
++void QWaylandDisplay::initialize()
++{
++    forceRoundTrip();
++
++    if (!mWaitingScreens.isEmpty()) {
++        // Give wl_output.done and zxdg_output_v1.done events a chance to arrive
++        forceRoundTrip();
++    }
+ }
+ 
+ void QWaylandDisplay::ensureScreen()
+@@ -203,98 +410,37 @@ void QWaylandDisplay::ensureScreen()
+ 
+ void QWaylandDisplay::checkError() const
+ {
+-    int ecode = wl_display_get_error(mDisplay);
+-    if ((ecode == EPIPE || ecode == ECONNRESET)) {
+-        // special case this to provide a nicer error
+-        qWarning("The Wayland connection broke. Did the Wayland compositor die?");
+-    } else {
+-        qWarning("The Wayland connection experienced a fatal error: %s", strerror(ecode));
+-    }
+-    _exit(1);
++    checkWaylandError(mDisplay);
+ }
+ 
++// Called in main thread, either from queued signal or directly.
+ void QWaylandDisplay::flushRequests()
+ {
+-    if (wl_display_prepare_read(mDisplay) == 0) {
+-        wl_display_read_events(mDisplay);
+-    }
+-
+-    if (wl_display_dispatch_pending(mDisplay) < 0)
+-        checkError();
+-
+-    {
+-        QReadLocker locker(&m_frameQueueLock);
+-        for (const FrameQueue &q : mExternalQueues) {
+-            QMutexLocker locker(q.mutex);
+-            while (wl_display_prepare_read_queue(mDisplay, q.queue) != 0)
+-                wl_display_dispatch_queue_pending(mDisplay, q.queue);
+-            wl_display_read_events(mDisplay);
+-            wl_display_dispatch_queue_pending(mDisplay, q.queue);
+-        }
+-    }
+-
+-    wl_display_flush(mDisplay);
+-}
+-
+-void QWaylandDisplay::blockingReadEvents()
+-{
+-    if (wl_display_dispatch(mDisplay) < 0)
+-        checkError();
+-}
+-
+-void QWaylandDisplay::destroyFrameQueue(const QWaylandDisplay::FrameQueue &q)
+-{
+-    QWriteLocker locker(&m_frameQueueLock);
+-    auto it = std::find_if(mExternalQueues.begin(),
+-                           mExternalQueues.end(),
+-                           [&q] (const QWaylandDisplay::FrameQueue &other){ return other.queue == q.queue; });
+-    Q_ASSERT(it != mExternalQueues.end());
+-    mExternalQueues.erase(it);
+-    if (q.queue != nullptr)
+-        wl_event_queue_destroy(q.queue);
+-    delete q.mutex;
++    m_eventThread->readAndDispatchEvents();
+ }
+ 
+-QWaylandDisplay::FrameQueue QWaylandDisplay::createFrameQueue()
++// We have to wait until we have an eventDispatcher before creating the eventThread,
++// otherwise forceRoundTrip() may block inside _events_read() because eventThread is
++// polling.
++void QWaylandDisplay::initEventThread()
+ {
+-    QWriteLocker locker(&m_frameQueueLock);
+-    FrameQueue q{createEventQueue()};
+-    mExternalQueues.append(q);
+-    return q;
+-}
++    m_eventThread.reset(
++            new EventThread(mDisplay, /* default queue */ nullptr, EventThread::EmitToDispatch));
++    connect(m_eventThread.get(), &EventThread::needReadAndDispatch, this,
++            &QWaylandDisplay::flushRequests, Qt::QueuedConnection);
++    m_eventThread->start();
+ 
+-wl_event_queue *QWaylandDisplay::createEventQueue()
+-{
+-    return wl_display_create_queue(mDisplay);
++    // wl_display_disconnect() free this.
++    m_frameEventQueue = wl_display_create_queue(mDisplay);
++    m_frameEventQueueThread.reset(
++            new EventThread(mDisplay, m_frameEventQueue, EventThread::SelfDispatch));
++    m_frameEventQueueThread->start();
+ }
+ 
+-void QWaylandDisplay::dispatchQueueWhile(wl_event_queue *queue, std::function<bool ()> condition, int timeout)
++void QWaylandDisplay::blockingReadEvents()
+ {
+-    if (!condition())
+-        return;
+-
+-    QElapsedTimer timer;
+-    timer.start();
+-    struct pollfd pFd = qt_make_pollfd(wl_display_get_fd(mDisplay), POLLIN);
+-    while (timeout == -1 || timer.elapsed() < timeout) {
+-        while (wl_display_prepare_read_queue(mDisplay, queue) != 0)
+-            wl_display_dispatch_queue_pending(mDisplay, queue);
+-
+-        wl_display_flush(mDisplay);
+-
+-        const int remaining = qMax(timeout - timer.elapsed(), 0ll);
+-        const int pollTimeout = timeout == -1 ? -1 : remaining;
+-        if (qt_poll_msecs(&pFd, 1, pollTimeout) > 0)
+-            wl_display_read_events(mDisplay);
+-        else
+-            wl_display_cancel_read(mDisplay);
+-
+-        if (wl_display_dispatch_queue_pending(mDisplay, queue) < 0)
+-            checkError();
+-
+-        if (!condition())
+-            break;
+-    }
++    if (wl_display_dispatch(mDisplay) < 0)
++        checkWaylandError(mDisplay);
+ }
+ 
+ QWaylandScreen *QWaylandDisplay::screenForOutput(struct wl_output *output) const
+@@ -345,7 +491,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+     if (interface == QStringLiteral("wl_output")) {
+         mWaitingScreens << new QWaylandScreen(this, version, id);
+     } else if (interface == QStringLiteral("wl_compositor")) {
+-        mCompositorVersion = qMin((int)version, 3);
++        mCompositorVersion = qMin((int)version, 4);
+         mCompositor.init(registry, id, mCompositorVersion);
+     } else if (interface == QStringLiteral("wl_shm")) {
+         mShm.reset(new QWaylandShm(this, version, id));
+@@ -354,7 +500,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+         mInputDevices.append(inputDevice);
+ #if QT_CONFIG(wayland_datadevice)
+     } else if (interface == QStringLiteral("wl_data_device_manager")) {
+-        mDndSelectionHandler.reset(new QWaylandDataDeviceManager(this, id));
++        mDndSelectionHandler.reset(new QWaylandDataDeviceManager(this, version, id));
+ #endif
+     } else if (interface == QStringLiteral("qt_surface_extension")) {
+         mWindowExtension.reset(new QtWayland::qt_surface_extension(registry, id, 1));
+@@ -369,6 +515,8 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+ #if QT_CONFIG(wayland_client_primary_selection)
+     } else if (interface == QStringLiteral("zwp_primary_selection_device_manager_v1")) {
+         mPrimarySelectionManager.reset(new QWaylandPrimarySelectionDeviceManagerV1(this, id, 1));
++        for (QWaylandInputDevice *inputDevice : qAsConst(mInputDevices))
++            inputDevice->setPrimarySelectionDevice(mPrimarySelectionManager->createDevice(inputDevice));
+ #endif
+     } else if (interface == QStringLiteral("zwp_text_input_manager_v2") && !mClientSideInputContextRequested) {
+         mTextInputManager.reset(new QtWayland::zwp_text_input_manager_v2(registry, id, 1));
+@@ -427,6 +575,13 @@ void QWaylandDisplay::registry_global_remove(uint32_t id)
+                     inputDevice->setTextInput(nullptr);
+                 mWaylandIntegration->reconfigureInputContext();
+             }
++#if QT_CONFIG(wayland_client_primary_selection)
++            if (global.interface == QStringLiteral("zwp_primary_selection_device_manager_v1")) {
++                mPrimarySelectionManager.reset();
++                for (QWaylandInputDevice *inputDevice : qAsConst(mInputDevices))
++                    inputDevice->setPrimarySelectionDevice(nullptr);
++            }
++#endif
+             mGlobals.removeAt(i);
+             break;
+         }
+@@ -452,9 +607,10 @@ void QWaylandDisplay::addRegistryListener(RegistryListener listener, void *data)
+ 
+ void QWaylandDisplay::removeListener(RegistryListener listener, void *data)
+ {
+-    std::remove_if(mRegistryListeners.begin(), mRegistryListeners.end(), [=](Listener l){
++    auto iter = std::remove_if(mRegistryListeners.begin(), mRegistryListeners.end(), [=](Listener l){
+         return (l.listener == listener && l.data == data);
+     });
++    mRegistryListeners.erase(iter, mRegistryListeners.end());
+ }
+ 
+ uint32_t QWaylandDisplay::currentTimeMillisec()
+@@ -467,50 +623,9 @@ uint32_t QWaylandDisplay::currentTimeMillisec()
+     return 0;
+ }
+ 
+-static void
+-sync_callback(void *data, struct wl_callback *callback, uint32_t serial)
+-{
+-    Q_UNUSED(serial)
+-    bool *done = static_cast<bool *>(data);
+-
+-    *done = true;
+-
+-    // If the wl_callback done event is received after the condition check in the while loop in
+-    // forceRoundTrip(), but before the call to processEvents, the call to processEvents may block
+-    // forever if no more events are posted (eventhough the callback is handled in response to the
+-    // aboutToBlock signal). Hence, we wake up the event dispatcher so forceRoundTrip may return.
+-    // (QTBUG-64696)
+-    if (auto *dispatcher = QThread::currentThread()->eventDispatcher())
+-        dispatcher->wakeUp();
+-
+-    wl_callback_destroy(callback);
+-}
+-
+-static const struct wl_callback_listener sync_listener = {
+-    sync_callback
+-};
+-
+ void QWaylandDisplay::forceRoundTrip()
+ {
+-    // wl_display_roundtrip() works on the main queue only,
+-    // but we use a separate one, so basically reimplement it here
+-    int ret = 0;
+-    bool done = false;
+-    wl_callback *callback = wl_display_sync(mDisplay);
+-    wl_callback_add_listener(callback, &sync_listener, &done);
+-    flushRequests();
+-    if (QThread::currentThread()->eventDispatcher()) {
+-        while (!done && ret >= 0) {
+-            QThread::currentThread()->eventDispatcher()->processEvents(QEventLoop::WaitForMoreEvents);
+-            ret = wl_display_dispatch_pending(mDisplay);
+-        }
+-    } else {
+-        while (!done && ret >= 0)
+-            ret = wl_display_dispatch(mDisplay);
+-    }
+-
+-    if (ret == -1 && !done)
+-        wl_callback_destroy(callback);
++     wl_display_roundtrip(mDisplay);
+ }
+ 
+ bool QWaylandDisplay::supportsWindowDecoration() const
+@@ -574,14 +689,10 @@ void QWaylandDisplay::handleKeyboardFocusChanged(QWaylandInputDevice *inputDevic
+     if (mLastKeyboardFocus == keyboardFocus)
+         return;
+ 
+-    if (mWaylandIntegration->mShellIntegration) {
+-        mWaylandIntegration->mShellIntegration->handleKeyboardFocusChanged(keyboardFocus, mLastKeyboardFocus);
+-    } else {
+-        if (keyboardFocus)
+-            handleWindowActivated(keyboardFocus);
+-        if (mLastKeyboardFocus)
+-            handleWindowDeactivated(mLastKeyboardFocus);
+-    }
++    if (keyboardFocus)
++        handleWindowActivated(keyboardFocus);
++    if (mLastKeyboardFocus)
++        handleWindowDeactivated(mLastKeyboardFocus);
+ 
+     mLastKeyboardFocus = keyboardFocus;
+ }
+@@ -600,6 +711,19 @@ void QWaylandDisplay::handleWaylandSync()
+     QWindow *activeWindow = mActiveWindows.empty() ? nullptr : mActiveWindows.last()->window();
+     if (activeWindow != QGuiApplication::focusWindow())
+         QWindowSystemInterface::handleWindowActivated(activeWindow);
++
++    if (!activeWindow) {
++        if (lastInputDevice()) {
++#if QT_CONFIG(clipboard)
++            if (auto *dataDevice = lastInputDevice()->dataDevice())
++                dataDevice->invalidateSelectionOffer();
++#endif
++#if QT_CONFIG(wayland_client_primary_selection)
++            if (auto *device = lastInputDevice()->primarySelectionDevice())
++                device->invalidateSelectionOffer();
++#endif
++        }
++    }
+ }
+ 
+ const wl_callback_listener QWaylandDisplay::syncCallbackListener = {
+@@ -626,6 +750,13 @@ QWaylandInputDevice *QWaylandDisplay::defaultInputDevice() const
+     return mInputDevices.isEmpty() ? 0 : mInputDevices.first();
+ }
+ 
++bool QWaylandDisplay::isKeyboardAvailable() const
++{
++    return std::any_of(
++            mInputDevices.constBegin(), mInputDevices.constEnd(),
++            [this](const QWaylandInputDevice *device) { return device->keyboard() != nullptr; });
++}
++
+ #if QT_CONFIG(cursor)
+ 
+ QWaylandCursor *QWaylandDisplay::waylandCursor()
+@@ -652,4 +783,6 @@ QWaylandCursorTheme *QWaylandDisplay::loadCursorTheme(const QString &name, int p
+ 
+ } // namespace QtWaylandClient
+ 
++#include "qwaylanddisplay.moc"
++
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/client/qwaylanddisplay_p.h b/qtwayland/src/client/qwaylanddisplay_p.h
+index 3b092bc8..42bc661d 100644
+--- a/qtwayland/src/client/qwaylanddisplay_p.h
++++ b/qtwayland/src/client/qwaylanddisplay_p.h
+@@ -109,6 +109,7 @@ class QWaylandSurface;
+ class QWaylandShellIntegration;
+ class QWaylandCursor;
+ class QWaylandCursorTheme;
++class EventThread;
+ 
+ typedef void (*RegistryListener)(void *data,
+                                  struct wl_registry *registry,
+@@ -120,15 +121,11 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandDisplay : public QObject, public QtWayland
+     Q_OBJECT
+ 
+ public:
+-    struct FrameQueue {
+-        FrameQueue(wl_event_queue *q = nullptr) : queue(q), mutex(new QMutex) {}
+-        wl_event_queue *queue;
+-        QMutex *mutex;
+-    };
+-
+     QWaylandDisplay(QWaylandIntegration *waylandIntegration);
+     ~QWaylandDisplay(void) override;
+ 
++    void initialize();
++
+ #if QT_CONFIG(xkbcommon)
+     struct xkb_context *xkbContext() const { return mXkbContext.get(); }
+ #endif
+@@ -210,11 +207,11 @@ public:
+     void handleKeyboardFocusChanged(QWaylandInputDevice *inputDevice);
+     void handleWindowDestroyed(QWaylandWindow *window);
+ 
+-    wl_event_queue *createEventQueue();
+-    FrameQueue createFrameQueue();
+-    void destroyFrameQueue(const FrameQueue &q);
+-    void dispatchQueueWhile(wl_event_queue *queue, std::function<bool()> condition, int timeout = -1);
++    wl_event_queue *frameEventQueue() { return m_frameEventQueue; };
++
++    bool isKeyboardAvailable() const;
+ 
++    void initEventThread();
+ public slots:
+     void blockingReadEvents();
+     void flushRequests();
+@@ -237,6 +234,9 @@ private:
+     };
+ 
+     struct wl_display *mDisplay = nullptr;
++    QScopedPointer<EventThread> m_eventThread;
++    wl_event_queue *m_frameEventQueue = nullptr;
++    QScopedPointer<EventThread> m_frameEventQueueThread;
+     QtWayland::wl_compositor mCompositor;
+     QScopedPointer<QWaylandShm> mShm;
+     QList<QWaylandScreen *> mWaitingScreens;
+@@ -273,11 +273,9 @@ private:
+     QWaylandInputDevice *mLastInputDevice = nullptr;
+     QPointer<QWaylandWindow> mLastInputWindow;
+     QPointer<QWaylandWindow> mLastKeyboardFocus;
+-    QVector<QWaylandWindow *> mActiveWindows;
+-    QVector<FrameQueue> mExternalQueues;
++    QList<QWaylandWindow *> mActiveWindows;
+     struct wl_callback *mSyncCallback = nullptr;
+     static const wl_callback_listener syncCallbackListener;
+-    QReadWriteLock m_frameQueueLock;
+ 
+     bool mClientSideInputContextRequested = !QPlatformInputContextFactory::requested().isNull();
+ 
+diff --git a/qtwayland/src/client/qwaylanddnd.cpp b/qtwayland/src/client/qwaylanddnd.cpp
+index 6535aa16..7c53f5fa 100644
+--- a/qtwayland/src/client/qwaylanddnd.cpp
++++ b/qtwayland/src/client/qwaylanddnd.cpp
+@@ -66,7 +66,7 @@ void QWaylandDrag::startDrag()
+ {
+     QBasicDrag::startDrag();
+     QWaylandWindow *icon = static_cast<QWaylandWindow *>(shapedPixmapWindow()->handle());
+-    if (m_display->currentInputDevice()->dataDevice()->startDrag(drag()->mimeData(), icon)) {
++    if (m_display->currentInputDevice()->dataDevice()->startDrag(drag()->mimeData(), drag()->supportedActions(), icon)) {
+         icon->addAttachOffset(-drag()->hotSpot());
+     } else {
+         // Cancelling immediately does not work, since the event loop for QDrag::exec is started
+@@ -80,6 +80,9 @@ void QWaylandDrag::cancel()
+     QBasicDrag::cancel();
+ 
+     m_display->currentInputDevice()->dataDevice()->cancelDrag();
++
++    if (drag())
++        drag()->deleteLater();
+ }
+ 
+ void QWaylandDrag::move(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods)
+@@ -103,33 +106,41 @@ void QWaylandDrag::endDrag()
+     m_display->currentInputDevice()->handleEndDrag();
+ }
+ 
+-void QWaylandDrag::updateTarget(const QString &mimeType)
++void QWaylandDrag::setResponse(bool accepted)
+ {
+-    setCanDrop(!mimeType.isEmpty());
+-
+-    if (canDrop()) {
+-        updateCursor(defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers()));
+-    } else {
+-        updateCursor(Qt::IgnoreAction);
+-    }
++    // This method is used for old DataDevices where the drag action is not communicated
++    Qt::DropAction action = defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers());
++    setResponse(QPlatformDropQtResponse(accepted, action));
+ }
+ 
+-void QWaylandDrag::setResponse(const QPlatformDragQtResponse &response)
++void QWaylandDrag::setResponse(const QPlatformDropQtResponse &response)
+ {
+     setCanDrop(response.isAccepted());
+ 
+     if (canDrop()) {
+-        updateCursor(defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers()));
++        updateCursor(response.acceptedAction());
+     } else {
+         updateCursor(Qt::IgnoreAction);
+     }
+ }
+ 
+-void QWaylandDrag::finishDrag(const QPlatformDropQtResponse &response)
++void QWaylandDrag::setDropResponse(const QPlatformDropQtResponse &response)
+ {
+     setExecutedDropAction(response.acceptedAction());
++}
++
++void QWaylandDrag::finishDrag()
++{
+     QKeyEvent event(QEvent::KeyPress, Qt::Key_Escape, Qt::NoModifier);
+     eventFilter(shapedPixmapWindow(), &event);
++
++    if (drag())
++        drag()->deleteLater();
++}
++
++bool QWaylandDrag::ownsDragObject() const
++{
++    return true;
+ }
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddnd_p.h b/qtwayland/src/client/qwaylanddnd_p.h
+index 474fe2ab..46f629ac 100644
+--- a/qtwayland/src/client/qwaylanddnd_p.h
++++ b/qtwayland/src/client/qwaylanddnd_p.h
+@@ -71,9 +71,10 @@ public:
+     QWaylandDrag(QWaylandDisplay *display);
+     ~QWaylandDrag() override;
+ 
+-    void updateTarget(const QString &mimeType);
+-    void setResponse(const QPlatformDragQtResponse &response);
+-    void finishDrag(const QPlatformDropQtResponse &response);
++    void setResponse(bool accepted);
++    void setResponse(const QPlatformDropQtResponse &response);
++    void setDropResponse(const QPlatformDropQtResponse &response);
++    void finishDrag();
+ 
+ protected:
+     void startDrag() override;
+@@ -82,6 +83,7 @@ protected:
+     void drop(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods) override;
+     void endDrag() override;
+ 
++    bool ownsDragObject() const override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+diff --git a/qtwayland/src/client/qwaylandinputdevice.cpp b/qtwayland/src/client/qwaylandinputdevice.cpp
+index 613fe862..4b90de84 100644
+--- a/qtwayland/src/client/qwaylandinputdevice.cpp
++++ b/qtwayland/src/client/qwaylandinputdevice.cpp
+@@ -685,6 +685,11 @@ public:
+ 
+ void QWaylandInputDevice::Pointer::pointer_leave(uint32_t time, struct wl_surface *surface)
+ {
++    invalidateFocus();
++    mButtons = Qt::NoButton;
++
++    mParent->mTime = time;
++
+     // The event may arrive after destroying the window, indicated by
+     // a null surface.
+     if (!surface)
+@@ -696,11 +701,6 @@ void QWaylandInputDevice::Pointer::pointer_leave(uint32_t time, struct wl_surfac
+ 
+     if (!QWaylandWindow::mouseGrab())
+         setFrameEvent(new LeaveEvent(window, mSurfacePos, mGlobalPos));
+-
+-    invalidateFocus();
+-    mButtons = Qt::NoButton;
+-
+-    mParent->mTime = time;
+ }
+ 
+ class MotionEvent : public QWaylandPointerEvent
+@@ -1300,14 +1300,6 @@ void QWaylandInputDevice::Keyboard::handleFocusDestroyed()
+ void QWaylandInputDevice::Keyboard::handleFocusLost()
+ {
+     mFocus = nullptr;
+-#if QT_CONFIG(clipboard)
+-    if (auto *dataDevice = mParent->dataDevice())
+-        dataDevice->invalidateSelectionOffer();
+-#endif
+-#if QT_CONFIG(wayland_client_primary_selection)
+-    if (auto *device = mParent->primarySelectionDevice())
+-        device->invalidateSelectionOffer();
+-#endif
+     mParent->mQDisplay->handleKeyboardFocusChanged(mParent);
+     mRepeatTimer.stop();
+ }
+@@ -1396,6 +1388,7 @@ void QWaylandInputDevice::Touch::touch_cancel()
+     if (touchExt)
+         touchExt->touchCanceled();
+ 
++    mFocus = nullptr;
+     QWindowSystemInterface::handleTouchCancelEvent(nullptr, mParent->mTouchDevice);
+ }
+ 
+diff --git a/qtwayland/src/client/qwaylandintegration.cpp b/qtwayland/src/client/qwaylandintegration.cpp
+index c53ccb78..54861600 100644
+--- a/qtwayland/src/client/qwaylandintegration.cpp
++++ b/qtwayland/src/client/qwaylandintegration.cpp
+@@ -125,6 +125,9 @@ QWaylandIntegration::QWaylandIntegration()
+ #endif
+ 
+     reconfigureInputContext();
++
++    QWaylandWindow::fixedToplevelPositions =
++            !qEnvironmentVariableIsSet("QT_WAYLAND_DISABLE_FIXED_POSITIONS");
+ }
+ 
+ QWaylandIntegration::~QWaylandIntegration()
+@@ -192,14 +195,18 @@ QAbstractEventDispatcher *QWaylandIntegration::createEventDispatcher() const
+ 
+ void QWaylandIntegration::initialize()
+ {
++    mDisplay->initEventThread();
++
++    // Call after eventDispatcher is fully connected, for QWaylandDisplay::forceRoundTrip()
++    mDisplay->initialize();
++
++    // But the aboutToBlock() and awake() should be connected after initializePlatform().
++    // Otherwise the connected flushRequests() may consumes up all events before processEvents starts to wait,
++    // so that processEvents(QEventLoop::WaitForMoreEvents) may be blocked in the forceRoundTrip().
+     QAbstractEventDispatcher *dispatcher = QGuiApplicationPrivate::eventDispatcher;
+     QObject::connect(dispatcher, SIGNAL(aboutToBlock()), mDisplay.data(), SLOT(flushRequests()));
+     QObject::connect(dispatcher, SIGNAL(awake()), mDisplay.data(), SLOT(flushRequests()));
+ 
+-    int fd = wl_display_get_fd(mDisplay->wl_display());
+-    QSocketNotifier *sn = new QSocketNotifier(fd, QSocketNotifier::Read, mDisplay.data());
+-    QObject::connect(sn, SIGNAL(activated(QSocketDescriptor)), mDisplay.data(), SLOT(flushRequests()));
+-
+     // Qt does not support running with no screens
+     mDisplay->ensureScreen();
+ }
+@@ -262,6 +269,14 @@ QWaylandDisplay *QWaylandIntegration::display() const
+     return mDisplay.data();
+ }
+ 
++Qt::KeyboardModifiers QWaylandIntegration::queryKeyboardModifiers() const
++{
++    if (auto *seat = mDisplay->currentInputDevice()) {
++        return seat->modifiers();
++    }
++    return Qt::NoModifier;
++}
++
+ QList<int> QWaylandIntegration::possibleKeys(const QKeyEvent *event) const
+ {
+     if (auto *seat = mDisplay->currentInputDevice())
+@@ -479,7 +494,7 @@ void QWaylandIntegration::reconfigureInputContext()
+     }
+ #endif
+ 
+-    qCDebug(lcQpaWayland) << "using input method:" << inputContext()->metaObject()->className();
++    qCDebug(lcQpaWayland) << "using input method:" << (inputContext() ? inputContext()->metaObject()->className() : "<none>");
+ }
+ 
+ QWaylandShellIntegration *QWaylandIntegration::createShellIntegration(const QString &integrationName)
+diff --git a/qtwayland/src/client/qwaylandintegration_p.h b/qtwayland/src/client/qwaylandintegration_p.h
+index ff70ae25..73b80658 100644
+--- a/qtwayland/src/client/qwaylandintegration_p.h
++++ b/qtwayland/src/client/qwaylandintegration_p.h
+@@ -107,6 +107,8 @@ public:
+ 
+     QWaylandDisplay *display() const;
+ 
++    Qt::KeyboardModifiers queryKeyboardModifiers() const override;
++
+     QList<int> possibleKeys(const QKeyEvent *event) const override;
+ 
+     QStringList themeNames() const override;
+diff --git a/qtwayland/src/client/qwaylandprimaryselectionv1.cpp b/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
+index 832f9678..ea508771 100644
+--- a/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
++++ b/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
+@@ -54,11 +54,6 @@ QWaylandPrimarySelectionDeviceManagerV1::QWaylandPrimarySelectionDeviceManagerV1
+     : zwp_primary_selection_device_manager_v1(display->wl_registry(), id, qMin(version, uint(1)))
+     , m_display(display)
+ {
+-    // Create devices for all seats.
+-    // This only works if we get the global before all devices
+-    const auto seats = m_display->inputDevices();
+-    for (auto *seat : seats)
+-        seat->setPrimarySelectionDevice(createDevice(seat));
+ }
+ 
+ QWaylandPrimarySelectionDeviceV1 *QWaylandPrimarySelectionDeviceManagerV1::createDevice(QWaylandInputDevice *seat)
+diff --git a/qtwayland/src/client/qwaylandscreen.cpp b/qtwayland/src/client/qwaylandscreen.cpp
+index 6cb337de..5537dafd 100644
+--- a/qtwayland/src/client/qwaylandscreen.cpp
++++ b/qtwayland/src/client/qwaylandscreen.cpp
+@@ -60,7 +60,7 @@ QWaylandXdgOutputManagerV1::QWaylandXdgOutputManagerV1(QWaylandDisplay* display,
+ }
+ 
+ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uint32_t id)
+-    : QtWayland::wl_output(waylandDisplay->wl_registry(), id, qMin(version, 2))
++    : QtWayland::wl_output(waylandDisplay->wl_registry(), id, qMin(version, 3))
+     , m_outputId(id)
+     , mWaylandDisplay(waylandDisplay)
+     , mOutputName(QStringLiteral("Screen%1").arg(id))
+@@ -72,7 +72,7 @@ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uin
+         qCWarning(lcQpaWayland) << "wl_output done event not supported by compositor,"
+                                 << "QScreen may not work correctly";
+         mWaylandDisplay->forceRoundTrip(); // Give the compositor a chance to send geometry etc.
+-        mOutputDone = true; // Fake the done event
++        mProcessedEvents |= OutputDoneEvent; // Fake the done event
+         maybeInitialize();
+     }
+ }
+@@ -81,16 +81,29 @@ QWaylandScreen::~QWaylandScreen()
+ {
+     if (zxdg_output_v1::isInitialized())
+         zxdg_output_v1::destroy();
++    if (wl_output::isInitialized() && wl_output_get_version(wl_output::object()) >= WL_OUTPUT_RELEASE_SINCE_VERSION)
++        wl_output::release();
++}
++
++uint QWaylandScreen::requiredEvents() const
++{
++    uint ret = OutputDoneEvent;
++
++    if (mWaylandDisplay->xdgOutputManager()) {
++        ret |= XdgOutputNameEvent;
++
++        if (mWaylandDisplay->xdgOutputManager()->version() < 3)
++            ret |= XdgOutputDoneEvent;
++    }
++    return ret;
+ }
+ 
+ void QWaylandScreen::maybeInitialize()
+ {
+     Q_ASSERT(!mInitialized);
+ 
+-    if (!mOutputDone)
+-        return;
+-
+-    if (mWaylandDisplay->xdgOutputManager() && !mXdgOutputDone)
++    const uint requiredEvents = this->requiredEvents();
++    if ((mProcessedEvents & requiredEvents) != requiredEvents)
+         return;
+ 
+     mInitialized = true;
+@@ -276,9 +289,8 @@ void QWaylandScreen::output_scale(int32_t factor)
+ 
+ void QWaylandScreen::output_done()
+ {
+-    mOutputDone = true;
+-    if (zxdg_output_v1::isInitialized() && mWaylandDisplay->xdgOutputManager()->version() >= 3)
+-        mXdgOutputDone = true;
++    mProcessedEvents |= OutputDoneEvent;
++
+     if (mInitialized) {
+         updateOutputProperties();
+         if (zxdg_output_v1::isInitialized())
+@@ -339,7 +351,7 @@ void QWaylandScreen::zxdg_output_v1_done()
+     if (Q_UNLIKELY(mWaylandDisplay->xdgOutputManager()->version() >= 3))
+         qWarning(lcQpaWayland) << "zxdg_output_v1.done received on version 3 or newer, this is most likely a bug in the compositor";
+ 
+-    mXdgOutputDone = true;
++    mProcessedEvents |= XdgOutputDoneEvent;
+     if (mInitialized)
+         updateXdgOutputProperties();
+     else
+@@ -348,7 +360,11 @@ void QWaylandScreen::zxdg_output_v1_done()
+ 
+ void QWaylandScreen::zxdg_output_v1_name(const QString &name)
+ {
++    if (Q_UNLIKELY(mInitialized))
++        qWarning(lcQpaWayland) << "zxdg_output_v1.name received after output has been initialized, this is most likely a bug in the compositor";
++
+     mOutputName = name;
++    mProcessedEvents |= XdgOutputNameEvent;
+ }
+ 
+ void QWaylandScreen::updateXdgOutputProperties()
+diff --git a/qtwayland/src/client/qwaylandscreen_p.h b/qtwayland/src/client/qwaylandscreen_p.h
+index df1c94f2..050cfdc0 100644
+--- a/qtwayland/src/client/qwaylandscreen_p.h
++++ b/qtwayland/src/client/qwaylandscreen_p.h
+@@ -116,6 +116,13 @@ public:
+     static QWaylandScreen *fromWlOutput(::wl_output *output);
+ 
+ private:
++    enum Event : uint {
++        XdgOutputDoneEvent = 0x1,
++        OutputDoneEvent = 0x2,
++        XdgOutputNameEvent = 0x4,
++    };
++    uint requiredEvents() const;
++
+     void output_mode(uint32_t flags, int width, int height, int refresh) override;
+     void output_geometry(int32_t x, int32_t y,
+                          int32_t width, int32_t height,
+@@ -148,8 +155,7 @@ private:
+     QSize mPhysicalSize;
+     QString mOutputName;
+     Qt::ScreenOrientation m_orientation = Qt::PrimaryOrientation;
+-    bool mOutputDone = false;
+-    bool mXdgOutputDone = false;
++    uint mProcessedEvents = 0;
+     bool mInitialized = false;
+ 
+ #if QT_CONFIG(cursor)
+diff --git a/qtwayland/src/client/qwaylandshmbackingstore.cpp b/qtwayland/src/client/qwaylandshmbackingstore.cpp
+index dc7ff670..41cffdf7 100644
+--- a/qtwayland/src/client/qwaylandshmbackingstore.cpp
++++ b/qtwayland/src/client/qwaylandshmbackingstore.cpp
+@@ -52,6 +52,7 @@
+ 
+ #include <QtWaylandClient/private/wayland-wayland-client-protocol.h>
+ 
++#include <fcntl.h>
+ #include <unistd.h>
+ #include <sys/mman.h>
+ 
+@@ -61,6 +62,9 @@
+ #  ifndef MFD_CLOEXEC
+ #    define MFD_CLOEXEC     0x0001U
+ #  endif
++#  ifndef MFD_ALLOW_SEALING
++#    define MFD_ALLOW_SEALING 0x0002U
++#  endif
+ #endif
+ 
+ QT_BEGIN_NAMESPACE
+@@ -74,8 +78,10 @@ QWaylandShmBuffer::QWaylandShmBuffer(QWaylandDisplay *display,
+     int alloc = stride * size.height();
+     int fd = -1;
+ 
+-#ifdef SYS_memfd_create
+-    fd = syscall(SYS_memfd_create, "wayland-shm", MFD_CLOEXEC);
++#if defined(SYS_memfd_create) && defined(F_SEAL_SEAL)
++    fd = syscall(SYS_memfd_create, "wayland-shm", MFD_CLOEXEC | MFD_ALLOW_SEALING);
++    if (fd >= 0)
++        fcntl(fd, F_ADD_SEALS, F_SEAL_SHRINK | F_SEAL_SEAL);
+ #endif
+ 
+     QScopedPointer<QFile> filePointer;
+diff --git a/qtwayland/src/client/qwaylandwindow.cpp b/qtwayland/src/client/qwaylandwindow.cpp
+index cb82857a..fb2c59dc 100644
+--- a/qtwayland/src/client/qwaylandwindow.cpp
++++ b/qtwayland/src/client/qwaylandwindow.cpp
+@@ -76,7 +76,6 @@ QWaylandWindow *QWaylandWindow::mMouseGrab = nullptr;
+ QWaylandWindow::QWaylandWindow(QWindow *window, QWaylandDisplay *display)
+     : QPlatformWindow(window)
+     , mDisplay(display)
+-    , mFrameQueue(mDisplay->createFrameQueue())
+     , mResizeAfterSwap(qEnvironmentVariableIsSet("QT_WAYLAND_RESIZE_AFTER_SWAP"))
+ {
+     {
+@@ -95,9 +94,6 @@ QWaylandWindow::QWaylandWindow(QWindow *window, QWaylandDisplay *display)
+ 
+ QWaylandWindow::~QWaylandWindow()
+ {
+-    mDisplay->destroyFrameQueue(mFrameQueue);
+-    mDisplay->handleWindowDestroyed(this);
+-
+     delete mWindowDecoration;
+ 
+     if (mSurface)
+@@ -243,6 +239,7 @@ bool QWaylandWindow::shouldCreateSubSurface() const
+ 
+ void QWaylandWindow::reset()
+ {
++    closeChildPopups();
+     delete mShellSurface;
+     mShellSurface = nullptr;
+     delete mSubSurfaceWindow;
+@@ -255,17 +252,22 @@ void QWaylandWindow::reset()
+         mSurface.reset();
+     }
+ 
+-    if (mFrameCallback) {
+-        wl_callback_destroy(mFrameCallback);
+-        mFrameCallback = nullptr;
+-    }
++    {
++        QMutexLocker lock(&mFrameSyncMutex);
++        if (mFrameCallback) {
++            wl_callback_destroy(mFrameCallback);
++            mFrameCallback = nullptr;
++        }
+ 
+-    mFrameCallbackElapsedTimer.invalidate();
+-    mWaitingForFrameCallback = false;
++        mFrameCallbackElapsedTimer.invalidate();
++        mWaitingForFrameCallback = false;
++    }
+     mFrameCallbackTimedOut = false;
+ 
+     mMask = QRegion();
+     mQueuedBuffer = nullptr;
++
++    mDisplay->handleWindowDestroyed(this);
+ }
+ 
+ QWaylandWindow *QWaylandWindow::fromWlSurface(::wl_surface *surface)
+@@ -351,19 +353,25 @@ void QWaylandWindow::setGeometry_helper(const QRect &rect)
+     }
+ }
+ 
+-void QWaylandWindow::setGeometry(const QRect &rect)
++void QWaylandWindow::setGeometry(const QRect &r)
+ {
++    auto rect = r;
++    if (fixedToplevelPositions && !QPlatformWindow::parent() && window()->type() != Qt::Popup
++        && window()->type() != Qt::ToolTip) {
++        rect.moveTo(screen()->geometry().topLeft());
++    }
+     setGeometry_helper(rect);
+ 
+     if (window()->isVisible() && rect.isValid()) {
+         if (mWindowDecoration)
+             mWindowDecoration->update();
+ 
+-        if (mResizeAfterSwap && windowType() == Egl && mSentInitialResize)
++        if (mResizeAfterSwap && windowType() == Egl && mSentInitialResize) {
++            QMutexLocker lock(&mResizeLock);
+             mResizeDirty = true;
+-        else
++        } else {
+             QWindowSystemInterface::handleGeometryChange(window(), geometry());
+-
++        }
+         mSentInitialResize = true;
+     }
+     QRect exposeGeometry(QPoint(), geometry().size());
+@@ -374,7 +382,7 @@ void QWaylandWindow::setGeometry(const QRect &rect)
+         mShellSurface->setWindowGeometry(windowContentGeometry());
+ 
+     if (isOpaque() && mMask.isEmpty())
+-        setOpaqueArea(rect);
++        setOpaqueArea(QRect(QPoint(0, 0), rect.size()));
+ }
+ 
+ void QWaylandWindow::resizeFromApplyConfigure(const QSize &sizeWithMargins, const QPoint &offset)
+@@ -399,21 +407,6 @@ void QWaylandWindow::sendExposeEvent(const QRect &rect)
+     mLastExposeGeometry = rect;
+ }
+ 
+-
+-static QVector<QPointer<QWaylandWindow>> activePopups;
+-
+-void QWaylandWindow::closePopups(QWaylandWindow *parent)
+-{
+-    while (!activePopups.isEmpty()) {
+-        auto popup = activePopups.takeLast();
+-        if (popup.isNull())
+-            continue;
+-        if (popup.data() == parent)
+-            return;
+-        popup->reset();
+-    }
+-}
+-
+ QPlatformScreen *QWaylandWindow::calculateScreenFromSurfaceEvents() const
+ {
+     QReadLocker lock(&mSurfaceLock);
+@@ -433,10 +426,7 @@ void QWaylandWindow::setVisible(bool visible)
+     lastVisible = visible;
+ 
+     if (visible) {
+-        if (window()->type() == Qt::Popup || window()->type() == Qt::ToolTip)
+-            activePopups << this;
+         initWindow();
+-        mDisplay->flushRequests();
+ 
+         setGeometry(windowGeometry());
+         // Don't flush the events here, or else the newly visible window may start drawing, but since
+@@ -444,7 +434,6 @@ void QWaylandWindow::setVisible(bool visible)
+         // QWaylandShmBackingStore::beginPaint().
+     } else {
+         sendExposeEvent(QRect());
+-        closePopups(this);
+         reset();
+     }
+ }
+@@ -556,12 +545,12 @@ void QWaylandWindow::sendRecursiveExposeEvent()
+ 
+ void QWaylandWindow::attach(QWaylandBuffer *buffer, int x, int y)
+ {
+-    Q_ASSERT(!buffer->committed());
+     QReadLocker locker(&mSurfaceLock);
+     if (mSurface == nullptr)
+         return;
+ 
+     if (buffer) {
++        Q_ASSERT(!buffer->committed());
+         handleUpdate();
+         buffer->setBusy();
+ 
+@@ -583,7 +572,11 @@ void QWaylandWindow::damage(const QRect &rect)
+     if (mSurface == nullptr)
+         return;
+ 
+-    mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    const int s = scale();
++    if (mDisplay->compositorVersion() >= 4)
++        mSurface->damage_buffer(s * rect.x(), s * rect.y(), s * rect.width(), s * rect.height());
++    else
++        mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
+ }
+ 
+ void QWaylandWindow::safeCommit(QWaylandBuffer *buffer, const QRegion &damage)
+@@ -619,8 +612,14 @@ void QWaylandWindow::commit(QWaylandBuffer *buffer, const QRegion &damage)
+         return;
+ 
+     attachOffset(buffer);
+-    for (const QRect &rect: damage)
+-        mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    if (mDisplay->compositorVersion() >= 4) {
++        const int s = scale();
++        for (const QRect &rect: damage)
++            mSurface->damage_buffer(s * rect.x(), s * rect.y(), s * rect.width(), s * rect.height());
++    } else {
++        for (const QRect &rect: damage)
++            mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    }
+     Q_ASSERT(!buffer->committed());
+     buffer->setCommitted();
+     mSurface->commit();
+@@ -635,42 +634,53 @@ void QWaylandWindow::commit()
+ 
+ const wl_callback_listener QWaylandWindow::callbackListener = {
+     [](void *data, wl_callback *callback, uint32_t time) {
+-        Q_UNUSED(callback);
+         Q_UNUSED(time);
+         auto *window = static_cast<QWaylandWindow*>(data);
+-        window->handleFrameCallback();
++        window->handleFrameCallback(callback);
+     }
+ };
+ 
+-void QWaylandWindow::handleFrameCallback()
++void QWaylandWindow::handleFrameCallback(wl_callback* callback)
+ {
++    QMutexLocker locker(&mFrameSyncMutex);
++    if (!mFrameCallback) {
++        // This means the callback is already unset by QWaylandWindow::reset.
++        // The wl_callback object will be destroyed there too.
++        return;
++    }
++    Q_ASSERT(callback == mFrameCallback);
++    wl_callback_destroy(callback);
++    mFrameCallback = nullptr;
++
+     mWaitingForFrameCallback = false;
+     mFrameCallbackElapsedTimer.invalidate();
+ 
+     // The rest can wait until we can run it on the correct thread
+-    if (!mWaitingForUpdateDelivery) {
+-        auto doHandleExpose = [this]() {
+-            bool wasExposed = isExposed();
+-            mFrameCallbackTimedOut = false;
+-            if (!wasExposed && isExposed()) // Did setting mFrameCallbackTimedOut make the window exposed?
+-                sendExposeEvent(QRect(QPoint(), geometry().size()));
+-            if (wasExposed && hasPendingUpdateRequest())
+-                deliverUpdateRequest();
+-
+-            mWaitingForUpdateDelivery = false;
+-        };
++    auto doHandleExpose = [this]() {
++        mWaitingForUpdateDelivery.storeRelease(false);
++        bool wasExposed = isExposed();
++        mFrameCallbackTimedOut = false;
++        if (!wasExposed && isExposed()) // Did setting mFrameCallbackTimedOut make the window exposed?
++            sendExposeEvent(QRect(QPoint(), geometry().size()));
++        if (wasExposed && hasPendingUpdateRequest())
++            deliverUpdateRequest();
++    };
+ 
++    if (mWaitingForUpdateDelivery.testAndSetAcquire(false, true)) {
+         // Queued connection, to make sure we don't call handleUpdate() from inside waitForFrameSync()
+         // in the single-threaded case.
+-        mWaitingForUpdateDelivery = true;
+         QMetaObject::invokeMethod(this, doHandleExpose, Qt::QueuedConnection);
+     }
++
++    mFrameSyncWait.notify_all();
+ }
+ 
+ bool QWaylandWindow::waitForFrameSync(int timeout)
+ {
+-    QMutexLocker locker(mFrameQueue.mutex);
+-    mDisplay->dispatchQueueWhile(mFrameQueue.queue, [&]() { return mWaitingForFrameCallback; }, timeout);
++    QMutexLocker locker(&mFrameSyncMutex);
++
++    QDeadlineTimer deadline(timeout);
++    while (mWaitingForFrameCallback && mFrameSyncWait.wait(&mFrameSyncMutex, deadline)) { }
+ 
+     if (mWaitingForFrameCallback) {
+         qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
+@@ -868,6 +878,17 @@ bool QWaylandWindow::createDecoration()
+             subsurf->set_position(pos.x() + m.left(), pos.y() + m.top());
+         }
+         sendExposeEvent(QRect(QPoint(), geometry().size()));
++
++        // This is a special case where the buffer is recreated, but since
++        // the content rect remains the same, the widgets remain the same
++        // size and are not redrawn, leaving the new buffer empty. As a simple
++        // work-around, we trigger a full extra update whenever the client-side
++        // window decorations are toggled while the window is showing.
++        // Note: createDecoration() is sometimes called from the render thread
++        // of Qt Quick. This is essentially wrong and could potentially cause problems,
++        // but until the underlying issue has been fixed, we have to use invokeMethod()
++        // here to avoid asserts.
++        QMetaObject::invokeMethod(window(), &QWindow::requestUpdate);
+     }
+ 
+     return mWindowDecoration;
+@@ -1023,6 +1044,13 @@ void QWaylandWindow::handleScreensChanged()
+ 
+     QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->QPlatformScreen::screen());
+     mLastReportedScreen = newScreen;
++    if (fixedToplevelPositions && !QPlatformWindow::parent() && window()->type() != Qt::Popup
++        && window()->type() != Qt::ToolTip
++        && geometry().topLeft() != newScreen->geometry().topLeft()) {
++        auto geometry = this->geometry();
++        geometry.moveTo(newScreen->geometry().topLeft());
++        setGeometry(geometry);
++    }
+ 
+     int scale = newScreen->isPlaceholder() ? 1 : static_cast<QWaylandScreen *>(newScreen)->scale();
+     if (scale != mScale) {
+@@ -1094,10 +1122,18 @@ bool QWaylandWindow::setMouseGrabEnabled(bool grab)
+     return true;
+ }
+ 
++Qt::WindowStates QWaylandWindow::windowStates() const
++{
++    return mLastReportedWindowStates;
++}
++
+ void QWaylandWindow::handleWindowStatesChanged(Qt::WindowStates states)
+ {
+     createDecoration();
+-    QWindowSystemInterface::handleWindowStateChanged(window(), states, mLastReportedWindowStates);
++    Qt::WindowStates statesWithoutActive = states & ~Qt::WindowActive;
++    Qt::WindowStates lastStatesWithoutActive = mLastReportedWindowStates & ~Qt::WindowActive;
++    QWindowSystemInterface::handleWindowStateChanged(window(), statesWithoutActive,
++                                                     lastStatesWithoutActive);
+     mLastReportedWindowStates = states;
+ }
+ 
+@@ -1139,19 +1175,24 @@ void QWaylandWindow::timerEvent(QTimerEvent *event)
+     if (event->timerId() != mFrameCallbackCheckIntervalTimerId)
+         return;
+ 
+-    bool callbackTimerExpired = mFrameCallbackElapsedTimer.hasExpired(mFrameCallbackTimeout);
+-    if (!mFrameCallbackElapsedTimer.isValid() || callbackTimerExpired ) {
+-        killTimer(mFrameCallbackCheckIntervalTimerId);
+-        mFrameCallbackCheckIntervalTimerId = -1;
+-    }
+-    if (mFrameCallbackElapsedTimer.isValid() && callbackTimerExpired) {
+-        mFrameCallbackElapsedTimer.invalidate();
++    {
++        QMutexLocker lock(&mFrameSyncMutex);
+ 
+-        qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
+-        mFrameCallbackTimedOut = true;
+-        mWaitingForUpdate = false;
+-        sendExposeEvent(QRect());
++        bool callbackTimerExpired = mFrameCallbackElapsedTimer.hasExpired(mFrameCallbackTimeout);
++        if (!mFrameCallbackElapsedTimer.isValid() || callbackTimerExpired ) {
++            killTimer(mFrameCallbackCheckIntervalTimerId);
++            mFrameCallbackCheckIntervalTimerId = -1;
++        }
++        if (!mFrameCallbackElapsedTimer.isValid() || !callbackTimerExpired) {
++            return;
++        }
++        mFrameCallbackElapsedTimer.invalidate();
+     }
++
++    qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
++    mFrameCallbackTimedOut = true;
++    mWaitingForUpdate = false;
++    sendExposeEvent(QRect());
+ }
+ 
+ void QWaylandWindow::requestUpdate()
+@@ -1160,8 +1201,11 @@ void QWaylandWindow::requestUpdate()
+     Q_ASSERT(hasPendingUpdateRequest()); // should be set by QPA
+ 
+     // If we have a frame callback all is good and will be taken care of there
+-    if (mWaitingForFrameCallback)
+-        return;
++    {
++        QMutexLocker locker(&mFrameSyncMutex);
++        if (mWaitingForFrameCallback)
++            return;
++    }
+ 
+     // If we've already called deliverUpdateRequest(), but haven't seen any attach+commit/swap yet
+     // This is a somewhat redundant behavior and might indicate a bug in the calling code, so log
+@@ -1174,7 +1218,12 @@ void QWaylandWindow::requestUpdate()
+     // so use invokeMethod to delay the delivery a bit.
+     QMetaObject::invokeMethod(this, [this] {
+         // Things might have changed in the meantime
+-        if (hasPendingUpdateRequest() && !mWaitingForFrameCallback)
++        {
++            QMutexLocker locker(&mFrameSyncMutex);
++            if (mWaitingForFrameCallback)
++                return;
++        }
++        if (hasPendingUpdateRequest())
+             deliverUpdateRequest();
+     }, Qt::QueuedConnection);
+ }
+@@ -1185,19 +1234,18 @@ void QWaylandWindow::requestUpdate()
+ void QWaylandWindow::handleUpdate()
+ {
+     qCDebug(lcWaylandBackingstore) << "handleUpdate" << QThread::currentThread();
++
+     // TODO: Should sync subsurfaces avoid requesting frame callbacks?
+     QReadLocker lock(&mSurfaceLock);
+     if (!mSurface)
+         return;
+ 
+-    if (mFrameCallback) {
+-        wl_callback_destroy(mFrameCallback);
+-        mFrameCallback = nullptr;
+-    }
++    QMutexLocker locker(&mFrameSyncMutex);
++    if (mWaitingForFrameCallback)
++        return;
+ 
+-    QMutexLocker locker(mFrameQueue.mutex);
+     struct ::wl_surface *wrappedSurface = reinterpret_cast<struct ::wl_surface *>(wl_proxy_create_wrapper(mSurface->object()));
+-    wl_proxy_set_queue(reinterpret_cast<wl_proxy *>(wrappedSurface), mFrameQueue.queue);
++    wl_proxy_set_queue(reinterpret_cast<wl_proxy *>(wrappedSurface), mDisplay->frameEventQueue());
+     mFrameCallback = wl_surface_frame(wrappedSurface);
+     wl_proxy_wrapper_destroy(wrappedSurface);
+     wl_callback_add_listener(mFrameCallback, &QWaylandWindow::callbackListener, this);
+@@ -1207,6 +1255,8 @@ void QWaylandWindow::handleUpdate()
+     // Start a timer for handling the case when the compositor stops sending frame callbacks.
+     if (mFrameCallbackTimeout > 0) {
+         QMetaObject::invokeMethod(this, [this] {
++            QMutexLocker locker(&mFrameSyncMutex);
++
+             if (mWaitingForFrameCallback) {
+                 if (mFrameCallbackCheckIntervalTimerId < 0)
+                     mFrameCallbackCheckIntervalTimerId = startTimer(mFrameCallbackTimeout);
+@@ -1267,6 +1317,20 @@ void QWaylandWindow::setOpaqueArea(const QRegion &opaqueArea)
+     wl_region_destroy(region);
+ }
+ 
++void QWaylandWindow::addChildPopup(QWaylandWindow *surface) {
++    mChildPopups.append(surface);
++}
++
++void QWaylandWindow::removeChildPopup(QWaylandWindow *surface) {
++    mChildPopups.removeAll(surface);
++}
++
++void QWaylandWindow::closeChildPopups() {
++    while (!mChildPopups.isEmpty()) {
++        auto popup = mChildPopups.takeLast();
++        popup->reset();
++    }
++}
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/client/qwaylandwindow_p.h b/qtwayland/src/client/qwaylandwindow_p.h
+index 01337cff..2f219d8c 100644
+--- a/qtwayland/src/client/qwaylandwindow_p.h
++++ b/qtwayland/src/client/qwaylandwindow_p.h
+@@ -98,6 +98,9 @@ public:
+     QWaylandWindow(QWindow *window, QWaylandDisplay *display);
+     ~QWaylandWindow() override;
+ 
++    // Keep Toplevels position on the top left corner of their screen
++    static inline bool fixedToplevelPositions = true;
++
+     virtual WindowType windowType() const = 0;
+     virtual void ensureSize();
+     WId winId() const override;
+@@ -148,6 +151,7 @@ public:
+     void setWindowState(Qt::WindowStates states) override;
+     void setWindowFlags(Qt::WindowFlags flags) override;
+     void handleWindowStatesChanged(Qt::WindowStates states);
++    Qt::WindowStates windowStates() const;
+ 
+     void raise() override;
+     void lower() override;
+@@ -206,6 +210,10 @@ public:
+     void handleUpdate();
+     void deliverUpdateRequest() override;
+ 
++    void addChildPopup(QWaylandWindow* child);
++    void removeChildPopup(QWaylandWindow* child);
++    void closeChildPopups();
++
+ public slots:
+     void applyConfigure();
+ 
+@@ -215,7 +223,11 @@ signals:
+ 
+ protected:
+     QWaylandDisplay *mDisplay = nullptr;
++
++    // mSurface can be written by the main thread. Other threads should claim a read lock for access
++    mutable QReadWriteLock mSurfaceLock;
+     QScopedPointer<QWaylandSurface> mSurface;
++
+     QWaylandShellSurface *mShellSurface = nullptr;
+     QWaylandSubSurface *mSubSurfaceWindow = nullptr;
+     QVector<QWaylandSubSurface *> mChildren;
+@@ -225,13 +237,14 @@ protected:
+     Qt::MouseButtons mMousePressedInContentArea = Qt::NoButton;
+ 
+     WId mWindowId;
+-    bool mWaitingForFrameCallback = false;
+     bool mFrameCallbackTimedOut = false; // Whether the frame callback has timed out
+-    bool mWaitingForUpdateDelivery = false;
+     int mFrameCallbackCheckIntervalTimerId = -1;
+-    QElapsedTimer mFrameCallbackElapsedTimer;
+-    struct ::wl_callback *mFrameCallback = nullptr;
+-    QWaylandDisplay::FrameQueue mFrameQueue;
++    QAtomicInt mWaitingForUpdateDelivery = false;
++
++    bool mWaitingForFrameCallback = false; // Protected by mFrameSyncMutex
++    QElapsedTimer mFrameCallbackElapsedTimer; // Protected by mFrameSyncMutex
++    struct ::wl_callback *mFrameCallback = nullptr; // Protected by mFrameSyncMutex
++    QMutex mFrameSyncMutex;
+     QWaitCondition mFrameSyncWait;
+ 
+     // True when we have called deliverRequestUpdate, but the client has not yet attached a new buffer
+@@ -261,6 +274,8 @@ protected:
+     QWaylandBuffer *mQueuedBuffer = nullptr;
+     QRegion mQueuedBufferDamage;
+ 
++    QList<QPointer<QWaylandWindow>> mChildPopups;
++
+ private:
+     void setGeometry_helper(const QRect &rect);
+     void initWindow();
+@@ -283,12 +298,10 @@ private:
+     QRect mLastExposeGeometry;
+ 
+     static const wl_callback_listener callbackListener;
+-    void handleFrameCallback();
++    void handleFrameCallback(struct ::wl_callback* callback);
+ 
+     static QWaylandWindow *mMouseGrab;
+ 
+-    mutable QReadWriteLock mSurfaceLock;
+-
+     friend class QWaylandSubSurface;
+ };
+ 
+diff --git a/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h b/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
+index ccad0048..4cc9b3b8 100644
+--- a/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
++++ b/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
+@@ -73,11 +73,10 @@ public:
+         return true;
+     }
+     virtual QWaylandShellSurface *createShellSurface(QWaylandWindow *window) = 0;
++    // kept for binary compat with layer-shell-qt
+     virtual void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) {
+-        if (newFocus)
+-            m_display->handleWindowActivated(newFocus);
+-        if (oldFocus)
+-            m_display->handleWindowDeactivated(oldFocus);
++        Q_UNUSED(newFocus);
++        Q_UNUSED(oldFocus);
+     }
+     virtual void *nativeResourceForWindow(const QByteArray &resource, QWindow *window) {
+         Q_UNUSED(resource);
+diff --git a/qtwayland/src/compositor/configure.json b/qtwayland/src/compositor/configure.json
+index bcfd5215..da95d07b 100644
+--- a/qtwayland/src/compositor/configure.json
++++ b/qtwayland/src/compositor/configure.json
+@@ -7,6 +7,31 @@
+     "testDir": "../../config.tests",
+ 
+     "libraries": {
++        "wayland-client": {
++            "label": "Wayland client library",
++            "headers": "wayland-version.h",
++            "test": {
++                "main": [
++                    "#if WAYLAND_VERSION_MAJOR < 1",
++                    "# error Wayland 1.8.0 or higher required",
++                    "#endif",
++                    "#if WAYLAND_VERSION_MAJOR == 1",
++                    "# if WAYLAND_VERSION_MINOR < 8",
++                    "#  error Wayland 1.8.0 or higher required",
++                    "# endif",
++                    "# if WAYLAND_VERSION_MINOR == 8",
++                    "#  if WAYLAND_VERSION_MICRO < 0",
++                    "#   error Wayland 1.8.0 or higher required",
++                    "#  endif",
++                    "# endif",
++                    "#endif"
++                 ]
++            },
++            "sources": [
++                { "type": "pkgConfig", "args": "wayland-client" },
++                "-lwayland-client"
++            ]
++        },
+         "wayland-server": {
+             "label": "wayland-server",
+             "headers": "wayland-version.h",
+@@ -151,8 +176,7 @@
+                     "#endif"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "dmabuf-client-buffer": {
+             "label": "Linux Client dma-buf Buffer Sharing",
+@@ -176,8 +200,7 @@
+                     "return 0;"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "vulkan-server-buffer": {
+             "label": "Vulkan Buffer Sharing",
+@@ -195,7 +218,8 @@
+                     "exportAllocInfo.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR;",
+                     "return 0;"
+                 ]
+-            }
++            },
++            "use": "wayland-client"
+         }
+     },
+ 
+diff --git a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
+index 7889f575..64140672 100644
+--- a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
++++ b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
+@@ -40,6 +40,7 @@
+ #include "qwaylandeglwindow.h"
+ 
+ #include <QtWaylandClient/private/qwaylandscreen_p.h>
++#include <QtWaylandClient/private/qwaylandsurface_p.h>
+ #include "qwaylandglcontext.h"
+ 
+ #include <QtEglSupport/private/qeglconvenience_p.h>
+@@ -124,6 +125,7 @@ void QWaylandEglWindow::updateSurface(bool create)
+         }
+         mOffset = QPoint();
+     } else {
++        QReadLocker locker(&mSurfaceLock);
+         if (m_waylandEglWindow) {
+             int current_width, current_height;
+             static bool disableResizeCheck = qgetenv("QT_WAYLAND_DISABLE_RESIZECHECK").toInt();
+@@ -131,14 +133,16 @@ void QWaylandEglWindow::updateSurface(bool create)
+             if (!disableResizeCheck) {
+                 wl_egl_window_get_attached_size(m_waylandEglWindow, &current_width, &current_height);
+             }
+-            if (disableResizeCheck || (current_width != sizeWithMargins.width() || current_height != sizeWithMargins.height())) {
++            if (disableResizeCheck || (current_width != sizeWithMargins.width() || current_height != sizeWithMargins.height()) || m_requestedSize != sizeWithMargins) {
+                 wl_egl_window_resize(m_waylandEglWindow, sizeWithMargins.width(), sizeWithMargins.height(), mOffset.x(), mOffset.y());
++                m_requestedSize = sizeWithMargins;
+                 mOffset = QPoint();
+ 
+                 m_resize = true;
+             }
+-        } else if (create && wlSurface()) {
+-            m_waylandEglWindow = wl_egl_window_create(wlSurface(), sizeWithMargins.width(), sizeWithMargins.height());
++        } else if (create && mSurface) {
++            m_waylandEglWindow = wl_egl_window_create(mSurface->object(), sizeWithMargins.width(), sizeWithMargins.height());
++            m_requestedSize = sizeWithMargins;
+         }
+ 
+         if (!m_eglSurface && m_waylandEglWindow && create) {
+diff --git a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
+index 5b1f4d56..0079dfef 100644
+--- a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
++++ b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
+@@ -88,6 +88,7 @@ private:
+     mutable QOpenGLFramebufferObject *m_contentFBO = nullptr;
+ 
+     QSurfaceFormat m_format;
++    QSize m_requestedSize;
+ };
+ 
+ }
+diff --git a/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h b/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
+index 56a710c3..c6a8b6c6 100644
+--- a/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
++++ b/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
+@@ -41,6 +41,8 @@
+ #include <QtCore/QTextStream>
+ #include <QtGui/QOpenGLTexture>
+ 
++#include <array>
++
+ #include <EGL/egl.h>
+ #include <EGL/eglext.h>
+ 
+diff --git a/qtwayland/src/plugins/decorations/bradient/main.cpp b/qtwayland/src/plugins/decorations/bradient/main.cpp
+index e75fda3c..fa885143 100644
+--- a/qtwayland/src/plugins/decorations/bradient/main.cpp
++++ b/qtwayland/src/plugins/decorations/bradient/main.cpp
+@@ -164,13 +164,10 @@ void QWaylandBradientDecoration::paint(QPaintDevice *device)
+     // Window icon
+     QIcon icon = waylandWindow()->windowIcon();
+     if (!icon.isNull()) {
+-        QPixmap pixmap = icon.pixmap(QSize(128, 128));
+-        QPixmap scaled = pixmap.scaled(22, 22, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+-
+         QRectF iconRect(0, 0, 22, 22);
+-        p.drawPixmap(iconRect.adjusted(margins().left() + BUTTON_SPACING, 4,
+-                                       margins().left() + BUTTON_SPACING, 4),
+-                     scaled, iconRect);
++        iconRect.adjust(margins().left() + BUTTON_SPACING, 4,
++                        margins().left() + BUTTON_SPACING, 4),
++        icon.paint(&p, iconRect.toRect());
+     }
+ 
+     // Window title
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
+index 85d25e3c..60bdd491 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
+@@ -47,18 +47,21 @@ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
+-QWaylandXdgPopupV5::QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow *window)
++QWaylandXdgPopupV5::QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow* parent, QWaylandWindow *window)
+     : QWaylandShellSurface(window)
+     , QtWayland::xdg_popup_v5(popup)
++    , m_parent(parent)
+     , m_window(window)
+ {
+     if (window->display()->windowExtension())
+         m_extendedWindow = new QWaylandExtendedSurface(window);
++    m_parent->addChildPopup(m_window);
+ }
+ 
+ QWaylandXdgPopupV5::~QWaylandXdgPopupV5()
+ {
+     xdg_popup_destroy(object());
++    m_parent->removeChildPopup(m_window);
+     delete m_extendedWindow;
+ }
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
+index 7494f6a6..d85f130b 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
+@@ -70,7 +70,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgPopupV5 : public QWaylandShellSurface
+ {
+     Q_OBJECT
+ public:
+-    QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow *window);
++    QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow* parent, QWaylandWindow *window);
+     ~QWaylandXdgPopupV5() override;
+ 
+ protected:
+@@ -78,6 +78,7 @@ protected:
+ 
+ private:
+     QWaylandExtendedSurface *m_extendedWindow = nullptr;
++    QWaylandWindow *m_parent = nullptr;
+     QWaylandWindow *m_window = nullptr;
+ };
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
+index 7e242c4a..def8452a 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
+@@ -84,7 +84,7 @@ QWaylandXdgPopupV5 *QWaylandXdgShellV5::createXdgPopup(QWaylandWindow *window, Q
+     int x = position.x() + parentWindow->frameMargins().left();
+     int y = position.y() + parentWindow->frameMargins().top();
+ 
+-    auto popup = new QWaylandXdgPopupV5(get_xdg_popup(window->wlSurface(), parentSurface, seat, m_popupSerial, x, y), window);
++    auto popup = new QWaylandXdgPopupV5(get_xdg_popup(window->wlSurface(), parentSurface, seat, m_popupSerial, x, y), parentWindow, window);
+     m_popups.append(window);
+     QObject::connect(popup, &QWaylandXdgPopupV5::destroyed, [this, window](){
+         m_popups.removeOne(window);
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
+index 4e25949f..cfc60939 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
+@@ -85,13 +85,6 @@ QWaylandShellSurface *QWaylandXdgShellV5Integration::createShellSurface(QWayland
+     return m_xdgShell->createXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellV5Integration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) {
+-    if (newFocus && qobject_cast<QWaylandXdgPopupV5 *>(newFocus->shellSurface()))
+-        m_display->handleWindowActivated(newFocus);
+-    if (oldFocus && qobject_cast<QWaylandXdgPopupV5 *>(oldFocus->shellSurface()))
+-        m_display->handleWindowDeactivated(oldFocus);
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
+index ce6bdb9e..aed88670 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
+@@ -67,7 +67,6 @@ public:
+     QWaylandXdgShellV5Integration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShellV5> m_xdgShell;
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
+index 8c371661..151c78e3 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
+@@ -174,6 +174,7 @@ QWaylandXdgSurfaceV6::Popup::Popup(QWaylandXdgSurfaceV6 *xdgSurface, QWaylandXdg
+     , m_xdgSurface(xdgSurface)
+     , m_parent(parent)
+ {
++    m_parent->window()->addChildPopup(m_xdgSurface->window());
+ }
+ 
+ QWaylandXdgSurfaceV6::Popup::~Popup()
+@@ -181,6 +182,8 @@ QWaylandXdgSurfaceV6::Popup::~Popup()
+     if (isInitialized())
+         destroy();
+ 
++    m_parent->window()->removeChildPopup(m_xdgSurface->window());
++
+     if (m_grabbing) {
+         auto *shell = m_xdgSurface->m_shell;
+         Q_ASSERT(shell->m_topmostGrabbingPopup == this);
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
+index 03164316..e8da8ba1 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
+@@ -68,20 +68,6 @@ QWaylandShellSurface *QWaylandXdgShellV6Integration::createShellSurface(QWayland
+     return m_xdgShell->getXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellV6Integration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus)
+-{
+-    if (newFocus) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurfaceV6 *>(newFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowActivated(newFocus);
+-    }
+-    if (oldFocus && qobject_cast<QWaylandXdgSurfaceV6 *>(oldFocus->shellSurface())) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurfaceV6 *>(oldFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowDeactivated(oldFocus);
+-    }
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
+index 261f8cbb..c1bcd5c6 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
+@@ -65,7 +65,6 @@ public:
+     QWaylandXdgShellV6Integration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShellV6> m_xdgShell;
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
+index f3e3c330..fa6d5808 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
+@@ -67,11 +67,6 @@ QWaylandXdgSurface::Toplevel::Toplevel(QWaylandXdgSurface *xdgSurface)
+ 
+ QWaylandXdgSurface::Toplevel::~Toplevel()
+ {
+-    if (m_applied.states & Qt::WindowActive) {
+-        QWaylandWindow *window = m_xdgSurface->window();
+-        window->display()->handleWindowDeactivated(window);
+-    }
+-
+     // The protocol spec requires that the decoration object is deleted before xdg_toplevel.
+     delete m_decoration;
+     m_decoration = nullptr;
+@@ -85,16 +80,15 @@ void QWaylandXdgSurface::Toplevel::applyConfigure()
+     if (!(m_applied.states & (Qt::WindowMaximized|Qt::WindowFullScreen)))
+         m_normalSize = m_xdgSurface->m_window->windowFrameGeometry().size();
+ 
+-    if ((m_pending.states & Qt::WindowActive) && !(m_applied.states & Qt::WindowActive))
++    if ((m_pending.states & Qt::WindowActive) && !(m_applied.states & Qt::WindowActive)
++        && !m_xdgSurface->m_window->display()->isKeyboardAvailable())
+         m_xdgSurface->m_window->display()->handleWindowActivated(m_xdgSurface->m_window);
+ 
+-    if (!(m_pending.states & Qt::WindowActive) && (m_applied.states & Qt::WindowActive))
++    if (!(m_pending.states & Qt::WindowActive) && (m_applied.states & Qt::WindowActive)
++        && !m_xdgSurface->m_window->display()->isKeyboardAvailable())
+         m_xdgSurface->m_window->display()->handleWindowDeactivated(m_xdgSurface->m_window);
+ 
+-    // TODO: none of the other plugins send WindowActive either, but is it on purpose?
+-    Qt::WindowStates statesWithoutActive = m_pending.states & ~Qt::WindowActive;
+-
+-    m_xdgSurface->m_window->handleWindowStatesChanged(statesWithoutActive);
++    m_xdgSurface->m_window->handleWindowStatesChanged(m_pending.states);
+ 
+     if (m_pending.size.isEmpty()) {
+         // An empty size in the configure means it's up to the client to choose the size
+@@ -105,8 +99,6 @@ void QWaylandXdgSurface::Toplevel::applyConfigure()
+         m_xdgSurface->m_window->resizeFromApplyConfigure(m_pending.size);
+     }
+ 
+-    m_xdgSurface->setSizeHints();
+-
+     m_applied = m_pending;
+     qCDebug(lcQpaWayland) << "Applied pending xdg_toplevel configure event:" << m_applied.size << m_applied.states;
+ }
+@@ -203,12 +195,17 @@ QtWayland::xdg_toplevel::resize_edge QWaylandXdgSurface::Toplevel::convertToResi
+                 | ((edges & Qt::RightEdge) ? resize_edge_right : 0));
+ }
+ 
+-QWaylandXdgSurface::Popup::Popup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parent,
++QWaylandXdgSurface::Popup::Popup(QWaylandXdgSurface *xdgSurface, QWaylandWindow *parent,
+                                  QtWayland::xdg_positioner *positioner)
+-    : xdg_popup(xdgSurface->get_popup(parent->object(), positioner->object()))
+-    , m_xdgSurface(xdgSurface)
++    : m_xdgSurface(xdgSurface)
++    , m_parentXdgSurface(qobject_cast<QWaylandXdgSurface *>(parent->shellSurface()))
+     , m_parent(parent)
+ {
++
++    init(xdgSurface->get_popup(m_parentXdgSurface ? m_parentXdgSurface->object() : nullptr, positioner->object()));
++    if (m_parent) {
++        m_parent->addChildPopup(m_xdgSurface->window());
++    }
+ }
+ 
+ QWaylandXdgSurface::Popup::~Popup()
+@@ -216,10 +213,24 @@ QWaylandXdgSurface::Popup::~Popup()
+     if (isInitialized())
+         destroy();
+ 
++    if (m_parent) {
++        m_parent->removeChildPopup(m_xdgSurface->window());
++    }
++
+     if (m_grabbing) {
+         auto *shell = m_xdgSurface->m_shell;
+         Q_ASSERT(shell->m_topmostGrabbingPopup == this);
+-        shell->m_topmostGrabbingPopup = m_parent->m_popup;
++        shell->m_topmostGrabbingPopup = m_parentXdgSurface ? m_parentXdgSurface->m_popup : nullptr;
++        m_grabbing = false;
++
++        // Synthesize Qt enter/leave events for popup
++        QWindow *leave = nullptr;
++        if (m_xdgSurface && m_xdgSurface->window())
++            leave = m_xdgSurface->window()->window();
++        QWindowSystemInterface::handleLeaveEvent(leave);
++
++        if (QWindow *enter = QGuiApplication::topLevelAt(QCursor::pos()))
++            QWindowSystemInterface::handleEnterEvent(enter, enter->mapFromGlobal(QCursor::pos()), QCursor::pos());
+     }
+ }
+ 
+@@ -257,6 +268,7 @@ QWaylandXdgSurface::QWaylandXdgSurface(QWaylandXdgShell *shell, ::xdg_surface *s
+                 m_toplevel->set_parent(parentXdgSurface->m_toplevel->object());
+         }
+     }
++    setSizeHints();
+ }
+ 
+ QWaylandXdgSurface::~QWaylandXdgSurface()
+@@ -400,8 +412,6 @@ void QWaylandXdgSurface::setPopup(QWaylandWindow *parent)
+ {
+     Q_ASSERT(!m_toplevel && !m_popup);
+ 
+-    auto parentXdgSurface = static_cast<QWaylandXdgSurface *>(parent->shellSurface());
+-
+     auto positioner = new QtWayland::xdg_positioner(m_shell->create_positioner());
+     // set_popup expects a position relative to the parent
+     QPoint transientPos = m_window->geometry().topLeft(); // this is absolute
+@@ -414,8 +424,9 @@ void QWaylandXdgSurface::setPopup(QWaylandWindow *parent)
+     positioner->set_anchor(QtWayland::xdg_positioner::anchor_top_left);
+     positioner->set_gravity(QtWayland::xdg_positioner::gravity_bottom_right);
+     positioner->set_size(m_window->geometry().width(), m_window->geometry().height());
+-    m_popup = new Popup(this, parentXdgSurface, positioner);
++    m_popup = new Popup(this, parent, positioner);
+     positioner->destroy();
++
+     delete positioner;
+ }
+ 
+@@ -437,6 +448,23 @@ void QWaylandXdgSurface::setGrabPopup(QWaylandWindow *parent, QWaylandInputDevic
+     }
+     setPopup(parent);
+     m_popup->grab(device, serial);
++
++    // Synthesize Qt enter/leave events for popup
++    if (!parent)
++        return;
++    QWindow *current = QGuiApplication::topLevelAt(QCursor::pos());
++    QWindow *leave = parent->window();
++    if (current != leave)
++        return;
++
++    QWindowSystemInterface::handleLeaveEvent(leave);
++
++    QWindow *enter = nullptr;
++    if (m_popup && m_popup->m_xdgSurface && m_popup->m_xdgSurface->window())
++        enter = m_popup->m_xdgSurface->window()->window();
++
++    if (enter)
++        QWindowSystemInterface::handleEnterEvent(enter, enter->mapFromGlobal(QCursor::pos()), QCursor::pos());
+ }
+ 
+ void QWaylandXdgSurface::xdg_surface_configure(uint32_t serial)
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
+index 96785205..4b518f0a 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
+@@ -131,14 +131,15 @@ private:
+ 
+     class Popup : public QtWayland::xdg_popup {
+     public:
+-        Popup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parent, QtWayland::xdg_positioner *positioner);
++        Popup(QWaylandXdgSurface *xdgSurface, QWaylandWindow *parent, QtWayland::xdg_positioner *positioner);
+         ~Popup() override;
+ 
+         void grab(QWaylandInputDevice *seat, uint serial);
+         void xdg_popup_popup_done() override;
+ 
+         QWaylandXdgSurface *m_xdgSurface = nullptr;
+-        QWaylandXdgSurface *m_parent = nullptr;
++        QWaylandXdgSurface *m_parentXdgSurface = nullptr;
++        QWaylandWindow *m_parent = nullptr;
+         bool m_grabbing = false;
+     };
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
+index 8769d971..da0dd6a7 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
+@@ -69,20 +69,6 @@ QWaylandShellSurface *QWaylandXdgShellIntegration::createShellSurface(QWaylandWi
+     return m_xdgShell->getXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellIntegration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus)
+-{
+-    if (newFocus) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurface *>(newFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowActivated(newFocus);
+-    }
+-    if (oldFocus && qobject_cast<QWaylandXdgSurface *>(oldFocus->shellSurface())) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurface *>(oldFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowDeactivated(oldFocus);
+-    }
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
+index b6caa6c9..2f929f98 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
+@@ -65,7 +65,6 @@ public:
+     QWaylandXdgShellIntegration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShell> m_xdgShell;
+diff --git a/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp b/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
+index 526d0ef4..f50ccf30 100644
+--- a/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
++++ b/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
+@@ -39,7 +39,10 @@
+ 
+ #include "qwaylandinputmethodeventbuilder_p.h"
+ 
++#include <QBrush>
++#include <QGuiApplication>
+ #include <QInputMethod>
++#include <QPalette>
+ #include <QTextCharFormat>
+ 
+ #ifdef QT_BUILD_WAYLANDCOMPOSITOR_LIB
+@@ -81,32 +84,38 @@ void QWaylandInputMethodEventBuilder::addPreeditStyling(uint32_t index, uint32_t
+     QTextCharFormat format;
+ 
+     switch (style) {
+-    case 0:
+-    case 1:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_NONE:
++        break;
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_DEFAULT:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_UNDERLINE:
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-    case 2:
+-    case 3:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_ACTIVE:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_INACTIVE:
+         format.setFontWeight(QFont::Bold);
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-    case 4:
+-        format.setFontUnderline(true);
+-        format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+-        m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_HIGHLIGHT:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_SELECTION:
++        {
++            format.setFontUnderline(true);
++            format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
++            QPalette palette = qApp->palette();
++            format.setBackground(QBrush(palette.color(QPalette::Active, QPalette::Highlight)));
++            format.setForeground(QBrush(palette.color(QPalette::Active, QPalette::HighlightedText)));
++            m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
++        }
+         break;
+-    case 5:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_INCORRECT:
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::WaveUnderline);
+         format.setUnderlineColor(QColor(Qt::red));
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-//    case QtWayland::wl_text_input::preedit_style_selection:
+-//    case QtWayland::wl_text_input::preedit_style_none:
+     default:
+         break;
+     }
+@@ -153,7 +162,7 @@ QInputMethodEvent QWaylandInputMethodEventBuilder::buildPreedit(const QString &t
+ 
+     if (m_preeditCursor < 0) {
+         attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, 0, QVariant()));
+-    } else if (m_preeditCursor > 0) {
++    } else {
+         attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, indexFromWayland(text, m_preeditCursor), 1, QVariant()));
+     }
+ 
+diff --git a/qtwayland/src/shared/qwaylandmimehelper.cpp b/qtwayland/src/shared/qwaylandmimehelper.cpp
+index a5fdd34d..e2fe1928 100644
+--- a/qtwayland/src/shared/qwaylandmimehelper.cpp
++++ b/qtwayland/src/shared/qwaylandmimehelper.cpp
+@@ -60,7 +60,7 @@ QByteArray QWaylandMimeHelper::getByteArray(QMimeData *mimeData, const QString &
+             buf.open(QIODevice::ReadWrite);
+             QByteArray fmt = "BMP";
+             if (mimeType.startsWith(QLatin1String("image/"))) {
+-                QByteArray imgFmt = mimeType.mid(6).toUpper().toLatin1();
++                QByteArray imgFmt = mimeType.mid(6).toLower().toLatin1();
+                 if (QImageWriter::supportedImageFormats().contains(imgFmt))
+                     fmt = imgFmt;
+             }
+@@ -74,7 +74,7 @@ QByteArray QWaylandMimeHelper::getByteArray(QMimeData *mimeData, const QString &
+         QList<QUrl> urls = mimeData->urls();
+         for (int i = 0; i < urls.count(); ++i) {
+             content.append(urls.at(i).toEncoded());
+-            content.append('\n');
++            content.append("\r\n");
+         }
+     } else {
+         content = mimeData->data(mimeType);
+diff --git a/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp b/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
+index 1568b3b9..067410d0 100644
+--- a/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
++++ b/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
+@@ -35,7 +35,7 @@
+ 
+ using namespace MockCompositor;
+ 
+-constexpr int dataDeviceVersion = 1;
++constexpr int dataDeviceVersion = 3;
+ 
+ class DataDeviceCompositor : public DefaultCompositor {
+ public:
+diff --git a/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp b/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
+index 9312c2e5..2ea382f1 100644
+--- a/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
++++ b/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
+@@ -73,6 +73,7 @@ private slots:
+     void multiTouch();
+     void multiTouchUpAndMotionFrame();
+     void tapAndMoveInSameFrame();
++    void cancelTouch();
+ };
+ 
+ void tst_seatv5::bindsToSeat()
+@@ -646,5 +647,34 @@ void tst_seatv5::tapAndMoveInSameFrame()
+     QTRY_COMPARE(window.m_events.last().touchPoints.first().state(), Qt::TouchPointState::TouchPointReleased);
+ }
+ 
++void tst_seatv5::cancelTouch()
++{
++    TouchWindow window;
++    QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
++
++    exec([=] {
++        auto *t = touch();
++        auto *c = client();
++        t->sendDown(xdgToplevel()->surface(), {32, 32}, 1);
++        t->sendFrame(c);
++        t->sendCancel(c);
++        t->sendFrame(c);
++    });
++
++    QTRY_VERIFY(!window.m_events.empty());
++    {
++        auto e = window.m_events.takeFirst();
++        QCOMPARE(e.type, QEvent::TouchBegin);
++        QCOMPARE(e.touchPointStates, Qt::TouchPointPressed);
++        QCOMPARE(e.touchPoints.length(), 1);
++        QCOMPARE(e.touchPoints.first().pos(), QPointF(32-window.frameMargins().left(), 32-window.frameMargins().top()));
++    }
++    {
++        auto e = window.m_events.takeFirst();
++        QCOMPARE(e.type, QEvent::TouchCancel);
++        QCOMPARE(e.touchPoints.length(), 0);
++    }
++}
++
+ QCOMPOSITOR_TEST_MAIN(tst_seatv5)
+ #include "tst_seatv5.moc"
+diff --git a/qtwayland/tests/auto/client/shared/corecompositor.cpp b/qtwayland/tests/auto/client/shared/corecompositor.cpp
+index 5c6c83ba..fa9b7662 100644
+--- a/qtwayland/tests/auto/client/shared/corecompositor.cpp
++++ b/qtwayland/tests/auto/client/shared/corecompositor.cpp
+@@ -27,6 +27,7 @@
+ ****************************************************************************/
+ 
+ #include "corecompositor.h"
++#include <thread>
+ 
+ namespace MockCompositor {
+ 
+diff --git a/qtwayland/tests/auto/client/shared/coreprotocol.cpp b/qtwayland/tests/auto/client/shared/coreprotocol.cpp
+index 0d988521..d1a2e7cb 100644
+--- a/qtwayland/tests/auto/client/shared/coreprotocol.cpp
++++ b/qtwayland/tests/auto/client/shared/coreprotocol.cpp
+@@ -451,6 +451,13 @@ void Touch::sendFrame(wl_client *client)
+         send_frame(r->handle);
+ }
+ 
++void Touch::sendCancel(wl_client *client)
++{
++    const auto touchResources = resourceMap().values(client);
++    for (auto *r : touchResources)
++        send_cancel(r->handle);
++}
++
+ uint Keyboard::sendEnter(Surface *surface)
+ {
+     auto serial = m_seat->m_compositor->nextSerial();
+diff --git a/qtwayland/tests/auto/client/shared/coreprotocol.h b/qtwayland/tests/auto/client/shared/coreprotocol.h
+index a1af137a..210d8ddb 100644
+--- a/qtwayland/tests/auto/client/shared/coreprotocol.h
++++ b/qtwayland/tests/auto/client/shared/coreprotocol.h
+@@ -158,7 +158,7 @@ class WlCompositor : public Global, public QtWaylandServer::wl_compositor
+ {
+     Q_OBJECT
+ public:
+-    explicit WlCompositor(CoreCompositor *compositor, int version = 3)
++    explicit WlCompositor(CoreCompositor *compositor, int version = 4)
+         : QtWaylandServer::wl_compositor(compositor->m_display, version)
+         , m_compositor(compositor)
+     {}
+@@ -364,6 +364,7 @@ public:
+     uint sendUp(wl_client *client, int id);
+     void sendMotion(wl_client *client, const QPointF &position, int id);
+     void sendFrame(wl_client *client);
++    void sendCancel(wl_client *client);
+ 
+     Seat *m_seat = nullptr;
+ };
+diff --git a/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp b/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
+index a415cbf5..b1d3d07d 100644
+--- a/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
++++ b/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
+@@ -342,7 +342,7 @@ Compositor::Compositor(MockCompositor *mockCompositor)
+         exit(EXIT_FAILURE);
+     }
+ 
+-    wl_global_create(m_display, &wl_compositor_interface, 1, this, bindCompositor);
++    wl_global_create(m_display, &wl_compositor_interface, 4, this, bindCompositor);
+ 
+     m_data_device_manager.reset(new DataDeviceManager(this, m_display));
+ 
+diff --git a/qtwayland/tests/auto/client/shared_old/mocksurface.cpp b/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
+index e9df5f90..c3246e4a 100644
+--- a/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
++++ b/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
+@@ -125,6 +125,16 @@ void Surface::surface_damage(Resource *resource,
+     Q_UNUSED(height);
+ }
+ 
++void Surface::surface_damage_buffer(Resource *resource,
++                                    int32_t x, int32_t y, int32_t width, int32_t height)
++{
++    Q_UNUSED(resource);
++    Q_UNUSED(x);
++    Q_UNUSED(y);
++    Q_UNUSED(width);
++    Q_UNUSED(height);
++}
++
+ void Surface::surface_frame(Resource *resource,
+                             uint32_t callback)
+ {
+diff --git a/qtwayland/tests/auto/client/shared_old/mocksurface.h b/qtwayland/tests/auto/client/shared_old/mocksurface.h
+index 949dc23d..d176837e 100644
+--- a/qtwayland/tests/auto/client/shared_old/mocksurface.h
++++ b/qtwayland/tests/auto/client/shared_old/mocksurface.h
+@@ -65,6 +65,8 @@ protected:
+                         struct wl_resource *buffer, int x, int y) override;
+     void surface_damage(Resource *resource,
+                         int32_t x, int32_t y, int32_t width, int32_t height) override;
++    void surface_damage_buffer(Resource *resource,
++                               int32_t x, int32_t y, int32_t width, int32_t height) override;
+     void surface_frame(Resource *resource,
+                        uint32_t callback) override;
+     void surface_commit(Resource *resource) override;
+diff --git a/qtwayland/tests/auto/client/surface/tst_surface.cpp b/qtwayland/tests/auto/client/surface/tst_surface.cpp
+index 95e4e609..60c672ce 100644
+--- a/qtwayland/tests/auto/client/surface/tst_surface.cpp
++++ b/qtwayland/tests/auto/client/surface/tst_surface.cpp
+@@ -129,6 +129,10 @@ void tst_surface::waitForFrameCallbackGl()
+     // Make sure we follow frame callbacks for some frames
+     for (int i = 0; i < 5; ++i) {
+         xdgPingAndWaitForPong(); // Make sure things have happened on the client
++        if (!qEnvironmentVariableIntValue("QT_WAYLAND_DISABLE_WINDOWDECORATION") && i == 0) {
++            QCOMPARE(bufferSpy.count(), 1);
++            bufferSpy.removeFirst();
++        }
+         exec([&] {
+             QVERIFY(bufferSpy.empty()); // Make sure no extra buffers have arrived
+             QVERIFY(!xdgToplevel()->surface()->m_waitingFrameCallbacks.empty());
+diff --git a/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp b/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
+index 2277bbb8..747875b4 100644
+--- a/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
++++ b/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
+@@ -31,6 +31,7 @@
+ #include <QtGui/QOpenGLWindow>
+ #include <QtGui/qpa/qplatformnativeinterface.h>
+ #include <QtWaylandClient/private/wayland-wayland-client-protocol.h>
++#include <QtWaylandClient/private/qwaylandwindow_p.h>
+ 
+ using namespace MockCompositor;
+ 
+@@ -45,6 +46,7 @@ private slots:
+     void configureStates();
+     void popup();
+     void tooltipOnPopup();
++    void tooltipAndSiblingPopup();
+     void switchPopups();
+     void hidePopupParent();
+     void pongs();
+@@ -138,6 +140,7 @@ void tst_xdgshell::configureSize()
+ 
+ void tst_xdgshell::configureStates()
+ {
++    QVERIFY(qputenv("QT_WAYLAND_FRAME_CALLBACK_TIMEOUT", "0"));
+     QRasterWindow window;
+     window.resize(64, 48);
+     window.show();
+@@ -154,9 +157,12 @@ void tst_xdgshell::configureStates()
+     // Toplevel windows don't know their position on xdg-shell
+ //    QCOMPARE(window.frameGeometry().topLeft(), QPoint()); // TODO: this doesn't currently work when window decorations are enabled
+ 
+-//    QEXPECT_FAIL("", "configure has already been acked, we shouldn't have to wait for isActive", Continue);
+-//    QVERIFY(window.isActive());
+-    QTRY_VERIFY(window.isActive()); // Just make sure it eventually get's set correctly
++    // window.windowstate() is driven by keyboard focus, however for decorations we want to follow
++    // XDGShell this is internal to QtWayland so it is queried directly
++    auto waylandWindow = static_cast<QtWaylandClient::QWaylandWindow *>(window.handle());
++    Q_ASSERT(waylandWindow);
++    QTRY_VERIFY(waylandWindow->windowStates().testFlag(
++            Qt::WindowActive)); // Just make sure it eventually get's set correctly
+ 
+     const QSize screenSize(640, 480);
+     const uint maximizedSerial = exec([=] {
+@@ -186,6 +192,7 @@ void tst_xdgshell::configureStates()
+     QCOMPARE(window.windowStates(), Qt::WindowNoState);
+     QCOMPARE(window.frameGeometry().size(), windowedSize);
+ //    QCOMPARE(window.frameGeometry().topLeft(), QPoint()); // TODO: this doesn't currently work when window decorations are enabled
++    QVERIFY(qunsetenv("QT_WAYLAND_FRAME_CALLBACK_TIMEOUT"));
+ }
+ 
+ void tst_xdgshell::popup()
+@@ -340,6 +347,92 @@ void tst_xdgshell::tooltipOnPopup()
+     QCOMPOSITOR_TRY_COMPARE(xdgPopup(0), nullptr);
+ }
+ 
++void tst_xdgshell::tooltipAndSiblingPopup()
++{
++    class ToolTip : public QRasterWindow {
++    public:
++        explicit ToolTip(QWindow *parent) {
++            setTransientParent(parent);
++            setFlags(Qt::ToolTip);
++            resize(100, 100);
++            show();
++        }
++        void mousePressEvent(QMouseEvent *event) override {
++            QRasterWindow::mousePressEvent(event);
++            m_popup = new QRasterWindow;
++            m_popup->setTransientParent(transientParent());
++            m_popup->setFlags(Qt::Popup);
++            m_popup->resize(100, 100);
++            m_popup->show();
++        }
++
++        QRasterWindow *m_popup = nullptr;
++    };
++
++    class Window : public QRasterWindow {
++    public:
++        void mousePressEvent(QMouseEvent *event) override {
++            QRasterWindow::mousePressEvent(event);
++            m_tooltip = new ToolTip(this);
++        }
++        ToolTip *m_tooltip = nullptr;
++    };
++
++    Window window;
++    window.resize(200, 200);
++    window.show();
++
++    QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
++    exec([=] { xdgToplevel()->sendCompleteConfigure(); });
++    QCOMPOSITOR_TRY_VERIFY(xdgToplevel()->m_xdgSurface->m_committedConfigureSerial);
++
++    exec([=] {
++        auto *surface = xdgToplevel()->surface();
++        auto *p = pointer();
++        auto *c = client();
++        p->sendEnter(surface, {100, 100});
++        p->sendFrame(c);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_pressed);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_released);
++        p->sendFrame(c);
++        p->sendLeave(surface);
++        p->sendFrame(c);
++    });
++
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup());
++    exec([=] { xdgPopup()->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup()->m_xdgSurface->m_committedConfigureSerial);
++    QCOMPOSITOR_TRY_VERIFY(!xdgPopup()->m_grabbed);
++
++    exec([=] {
++        auto *surface = xdgPopup()->surface();
++        auto *p = pointer();
++        auto *c = client();
++        p->sendEnter(surface, {100, 100});
++        p->sendFrame(c);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_pressed);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_released);
++        p->sendFrame(c);
++    });
++
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1));
++    exec([=] { xdgPopup(1)->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1)->m_xdgSurface->m_committedConfigureSerial);
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1)->m_grabbed);
++
++    // Close the middle tooltip (it should not close the sibling popup)
++    window.m_tooltip->close();
++
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(1), nullptr);
++    // Verify the remaining xdg surface is a grab popup..
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(0));
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(0)->m_grabbed);
++
++    window.m_tooltip->m_popup->close();
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(1), nullptr);
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(0), nullptr);
++}
++
+ // QTBUG-65680
+ void tst_xdgshell::switchPopups()
+ {
+@@ -505,7 +598,7 @@ void tst_xdgshell::minMaxSize()
+     window.show();
+     QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
+ 
+-    exec([=] { xdgToplevel()->sendCompleteConfigure(); });
++    // we don't roundtrip with our configuration the initial commit should be correct
+ 
+     QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.minSize, QSize(100, 100));
+     QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.maxSize, QSize(1000, 1000));
+Submodule qtwebchannel 618422ee..f8949655:
+diff --git a/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp b/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
+index 536eb5c..898d769 100644
+--- a/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
++++ b/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
+@@ -186,8 +186,6 @@ Q_DECLARE_TYPEINFO(OverloadResolutionCandidate, Q_MOVABLE_TYPE);
+ QMetaObjectPublisher::QMetaObjectPublisher(QWebChannel *webChannel)
+     : QObject(webChannel)
+     , webChannel(webChannel)
+-    , signalHandler(this)
+-    , clientIsIdle(false)
+     , blockUpdates(false)
+     , propertyUpdatesInitialized(false)
+ {
+@@ -301,17 +299,17 @@ QJsonObject QMetaObjectPublisher::classInfoForObject(const QObject *object, QWeb
+     return data;
+ }
+ 
+-void QMetaObjectPublisher::setClientIsIdle(bool isIdle)
++void QMetaObjectPublisher::setClientIsIdle(bool isIdle, QWebChannelAbstractTransport *transport)
+ {
+-    if (clientIsIdle == isIdle) {
+-        return;
+-    }
+-    clientIsIdle = isIdle;
+-    if (!isIdle && timer.isActive()) {
+-        timer.stop();
+-    } else if (isIdle && !timer.isActive()) {
+-        timer.start(PROPERTY_UPDATE_INTERVAL, this);
+-    }
++    transportState[transport].clientIsIdle = isIdle;
++    if (isIdle)
++        sendEnqueuedPropertyUpdates(transport);
++}
++
++bool QMetaObjectPublisher::isClientIdle(QWebChannelAbstractTransport *transport)
++{
++    auto found = transportState.find(transport);
++    return found != transportState.end() && found.value().clientIsIdle;
+ }
+ 
+ QJsonObject QMetaObjectPublisher::initializeClient(QWebChannelAbstractTransport *transport)
+@@ -333,6 +331,7 @@ QJsonObject QMetaObjectPublisher::initializeClient(QWebChannelAbstractTransport
+ 
+ void QMetaObjectPublisher::initializePropertyUpdates(const QObject *const object, const QJsonObject &objectInfo)
+ {
++    auto *signalHandler = signalHandlerFor(object);
+     foreach (const QJsonValue &propertyInfoVar, objectInfo[KEY_PROPERTIES].toArray()) {
+         const QJsonArray &propertyInfo = propertyInfoVar.toArray();
+         if (propertyInfo.size() < 2) {
+@@ -353,19 +352,19 @@ void QMetaObjectPublisher::initializePropertyUpdates(const QObject *const object
+ 
+         // Only connect for a property update once
+         if (connectedProperties.isEmpty()) {
+-            signalHandler.connectTo(object, signalIndex);
++            signalHandler->connectTo(object, signalIndex);
+         }
+ 
+         connectedProperties.insert(propertyIndex);
+     }
+ 
+     // also always connect to destroyed signal
+-    signalHandler.connectTo(object, s_destroyedSignalIndex);
++    signalHandler->connectTo(object, s_destroyedSignalIndex);
+ }
+ 
+ void QMetaObjectPublisher::sendPendingPropertyUpdates()
+ {
+-    if (blockUpdates || !clientIsIdle || pendingPropertyUpdates.isEmpty()) {
++    if (blockUpdates) {
+         return;
+     }
+ 
+@@ -415,18 +414,19 @@ void QMetaObjectPublisher::sendPendingPropertyUpdates()
+ 
+     // data does not contain specific updates
+     if (!data.isEmpty()) {
+-        setClientIsIdle(false);
+-
+         message[KEY_DATA] = data;
+-        broadcastMessage(message);
++        enqueueBroadcastMessage(message);
+     }
+ 
+     // send every property update which is not supposed to be broadcasted
+     const QHash<QWebChannelAbstractTransport*, QJsonArray>::const_iterator suend = specificUpdates.constEnd();
+     for (QHash<QWebChannelAbstractTransport*, QJsonArray>::const_iterator it = specificUpdates.constBegin(); it != suend; ++it) {
+         message[KEY_DATA] = it.value();
+-        it.key()->sendMessage(message);
++        enqueueMessage(message, it.key());
+     }
++
++    for (auto state = transportState.begin(); state != transportState.end(); ++state)
++        sendEnqueuedPropertyUpdates(state.key());
+ }
+ 
+ QVariant QMetaObjectPublisher::invokeMethod(QObject *const object, const QMetaMethod &method,
+@@ -572,7 +572,7 @@ void QMetaObjectPublisher::signalEmitted(const QObject *object, const int signal
+         }
+     } else {
+         pendingPropertyUpdates[object][signalIndex] = arguments;
+-        if (clientIsIdle && !blockUpdates && !timer.isActive()) {
++        if (!blockUpdates && !timer.isActive()) {
+             timer.start(PROPERTY_UPDATE_INTERVAL, this);
+         }
+     }
+@@ -590,7 +590,7 @@ void QMetaObjectPublisher::objectDestroyed(const QObject *object)
+     // only remove from handler when we initialized the property updates
+     // cf: https://bugreports.qt.io/browse/QTBUG-60250
+     if (propertyUpdatesInitialized) {
+-        signalHandler.remove(object);
++        signalHandlerFor(object)->remove(object);
+         signalToPropertyMap.remove(object);
+     }
+     pendingPropertyUpdates.remove(object);
+@@ -852,6 +852,52 @@ void QMetaObjectPublisher::broadcastMessage(const QJsonObject &message) const
+     }
+ }
+ 
++void QMetaObjectPublisher::enqueueBroadcastMessage(const QJsonObject &message)
++{
++    if (webChannel->d_func()->transports.isEmpty()) {
++        qWarning("QWebChannel is not connected to any transports, cannot send message: %s",
++                 QJsonDocument(message).toJson().constData());
++        return;
++    }
++
++    for (auto *transport : webChannel->d_func()->transports) {
++        auto &state = transportState[transport];
++        state.queuedMessages.append(message);
++    }
++}
++
++void QMetaObjectPublisher::enqueueMessage(const QJsonObject &message,
++                                          QWebChannelAbstractTransport *transport)
++{
++    auto &state = transportState[transport];
++    state.queuedMessages.append(message);
++}
++
++void QMetaObjectPublisher::sendEnqueuedPropertyUpdates(QWebChannelAbstractTransport *transport)
++{
++    auto found = transportState.find(transport);
++    if (found != transportState.end() && found.value().clientIsIdle
++        && !found.value().queuedMessages.isEmpty()) {
++
++        // If the client is connected with an in-process transport, it can
++        // happen that a message triggers a subsequent property change. In
++        // that case, we need to ensure that the queued messages have already
++        // been cleared; otherwise the recursive call will send everythig again.
++        // Case in point: The qmlwebchannel tests fail if we don't clear the
++        // queued messages before sending them out.
++        // For that same reason set the client to "busy" (aka non-idle) just
++        // right before sending out the messages; otherwise a potential
++        // "Idle" type message will not correctly restore the Idle state.
++        const auto messages = std::move(found.value().queuedMessages);
++        Q_ASSERT(found.value().queuedMessages.isEmpty());
++        found.value().clientIsIdle = false;
++
++        for (const auto &message : messages) {
++            transport->sendMessage(message);
++        }
++    }
++}
++
+ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannelAbstractTransport *transport)
+ {
+     if (!webChannel->d_func()->transports.contains(transport)) {
+@@ -866,7 +912,7 @@ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannel
+ 
+     const MessageType type = toType(message.value(KEY_TYPE));
+     if (type == TypeIdle) {
+-        setClientIsIdle(true);
++        setClientIsIdle(true, transport);
+     } else if (type == TypeInit) {
+         if (!message.contains(KEY_ID)) {
+             qWarning("JSON message object is missing the id property: %s",
+@@ -913,9 +959,9 @@ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannel
+                 return;
+             transport->sendMessage(createResponse(message.value(KEY_ID), wrapResult(result, transport)));
+         } else if (type == TypeConnectToSignal) {
+-            signalHandler.connectTo(object, message.value(KEY_SIGNAL).toInt(-1));
++            signalHandlerFor(object)->connectTo(object, message.value(KEY_SIGNAL).toInt(-1));
+         } else if (type == TypeDisconnectFromSignal) {
+-            signalHandler.disconnectFrom(object, message.value(KEY_SIGNAL).toInt(-1));
++            signalHandlerFor(object)->disconnectFrom(object, message.value(KEY_SIGNAL).toInt(-1));
+         } else if (type == TypeSetProperty) {
+             setProperty(object, message.value(KEY_PROPERTY).toInt(-1),
+                         message.value(KEY_VALUE));
+@@ -931,6 +977,7 @@ void QMetaObjectPublisher::setBlockUpdates(bool block)
+     blockUpdates = block;
+ 
+     if (!blockUpdates) {
++        timer.start(PROPERTY_UPDATE_INTERVAL, this);
+         sendPendingPropertyUpdates();
+     } else if (timer.isActive()) {
+         timer.stop();
+@@ -948,4 +995,15 @@ void QMetaObjectPublisher::timerEvent(QTimerEvent *event)
+     }
+ }
+ 
++SignalHandler<QMetaObjectPublisher> *QMetaObjectPublisher::signalHandlerFor(const QObject *object)
++{
++    auto thread = object->thread();
++    auto it = signalHandlers.find(thread);
++    if (it == signalHandlers.end()) {
++        it = signalHandlers.emplace(thread, this).first;
++        it->second.moveToThread(thread);
++    }
++    return &it->second;
++}
++
+ QT_END_NAMESPACE
+diff --git a/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h b/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
+index bbd9875..4713ef1 100644
+--- a/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
++++ b/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
+@@ -59,6 +59,9 @@
+ #include <QBasicTimer>
+ #include <QPointer>
+ #include <QJsonObject>
++#include <QQueue>
++
++#include <unordered_map>
+ 
+ #include "qwebchannelglobal.h"
+ 
+@@ -109,17 +112,36 @@ public:
+      */
+     void broadcastMessage(const QJsonObject &message) const;
+ 
++    /**
++     * Enqueue the given @p message to all known transports.
++     */
++    void enqueueBroadcastMessage(const QJsonObject &message);
++
++    /**
++     * Enqueue the given @p message to @p transport.
++     */
++    void enqueueMessage(const QJsonObject &message, QWebChannelAbstractTransport *transport);
++
++    /**
++     * If client for given @p transport is idle, send queued messaged to @p transport and then mark
++     * the client as not idle.
++     */
++    void sendEnqueuedPropertyUpdates(QWebChannelAbstractTransport *transport);
++
+     /**
+      * Serialize the QMetaObject of @p object and return it in JSON form.
+      */
+     QJsonObject classInfoForObject(const QObject *object, QWebChannelAbstractTransport *transport);
+ 
+     /**
+-     * Set the client to idle or busy, based on the value of @p isIdle.
+-     *
+-     * When the value changed, start/stop the property update timer accordingly.
++     * Set the client to idle or busy for a single @p transport, based on the value of @p isIdle.
++     */
++    void setClientIsIdle(bool isIdle, QWebChannelAbstractTransport *transport);
++
++    /**
++     * Check that client is idle for @p transport.
+      */
+-    void setClientIsIdle(bool isIdle);
++    bool isClientIdle(QWebChannelAbstractTransport *transport);
+ 
+     /**
+      * Initialize clients by sending them the class information of the registered objects.
+@@ -272,10 +294,18 @@ private:
+     friend class TestWebChannel;
+ 
+     QWebChannel *webChannel;
+-    SignalHandler<QMetaObjectPublisher> signalHandler;
++    std::unordered_map<const QThread*, SignalHandler<QMetaObjectPublisher>> signalHandlers;
++    SignalHandler<QMetaObjectPublisher> *signalHandlerFor(const QObject *object);
+ 
+-    // true when the client is idle, false otherwise
+-    bool clientIsIdle;
++    struct TransportState
++    {
++        TransportState() : clientIsIdle(false) { }
++        // true when the client is idle, false otherwise
++        bool clientIsIdle;
++        // messages to send
++        QQueue<QJsonObject> queuedMessages;
++    };
++    QHash<QWebChannelAbstractTransport *, TransportState> transportState;
+ 
+     // true when no property updates should be sent, false otherwise
+     bool blockUpdates;
+diff --git a/qtwebchannel/src/webchannel/signalhandler_p.h b/qtwebchannel/src/webchannel/signalhandler_p.h
+index 27afadb..d77373c 100644
+--- a/qtwebchannel/src/webchannel/signalhandler_p.h
++++ b/qtwebchannel/src/webchannel/signalhandler_p.h
+@@ -56,6 +56,7 @@
+ #include <QVector>
+ #include <QMetaMethod>
+ #include <QDebug>
++#include <QThread>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -71,6 +72,7 @@ static const int s_destroyedSignalIndex = QObject::staticMetaObject.indexOfMetho
+ template<class Receiver>
+ class SignalHandler : public QObject
+ {
++    Q_DISABLE_COPY(SignalHandler)
+ public:
+     SignalHandler(Receiver *receiver, QObject *parent = 0);
+ 
+@@ -268,6 +270,7 @@ int SignalHandler<Receiver>::qt_metacall(QMetaObject::Call call, int methodId, v
+     if (call == QMetaObject::InvokeMetaMethod) {
+         const QObject *object = sender();
+         Q_ASSERT(object);
++        Q_ASSERT(QThread::currentThread() == object->thread());
+         Q_ASSERT(senderSignalIndex() == methodId);
+         Q_ASSERT(m_connectionsCounter.contains(object));
+         Q_ASSERT(m_connectionsCounter.value(object).contains(methodId));
+diff --git a/qtwebchannel/tests/auto/qml/testwebchannel.cpp b/qtwebchannel/tests/auto/qml/testwebchannel.cpp
+index 9891687..3ca81c2 100644
+--- a/qtwebchannel/tests/auto/qml/testwebchannel.cpp
++++ b/qtwebchannel/tests/auto/qml/testwebchannel.cpp
+@@ -46,7 +46,11 @@ TestWebChannel::~TestWebChannel()
+ 
+ bool TestWebChannel::clientIsIdle() const
+ {
+-    return QWebChannel::d_func()->publisher->clientIsIdle;
++    for (auto *transport : QWebChannel::d_func()->transports) {
++        if (QWebChannel::d_func()->publisher->isClientIdle(transport))
++            return true;
++    }
++    return false;
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp b/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
+index 181da9e..37f989a 100644
+--- a/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
++++ b/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
+@@ -785,7 +785,7 @@ void TestWebChannel::testTransportWrapObjectProperties()
+     DummyTransport *dummyTransport = new DummyTransport(this);
+     channel.connectTo(dummyTransport);
+     channel.d_func()->publisher->initializeClient(dummyTransport);
+-    channel.d_func()->publisher->setClientIsIdle(true);
++    channel.d_func()->publisher->setClientIsIdle(true, dummyTransport);
+ 
+     QCOMPARE(channel.d_func()->publisher->transportedWrappedObjects.size(), 0);
+ 
+@@ -943,8 +943,6 @@ void TestWebChannel::testInfiniteRecursion()
+ 
+ void TestWebChannel::testAsyncObject()
+ {
+-    QSKIP("This test is broken. See QTBUG-80729");
+-
+     QWebChannel channel;
+     channel.connectTo(m_dummyTransport);
+ 
+@@ -990,6 +988,50 @@ void TestWebChannel::testAsyncObject()
+     thread.wait();
+ }
+ 
++void TestWebChannel::testPropertyMultipleTransports()
++{
++    DummyTransport transport1;
++    DummyTransport transport2;
++
++    QWebChannel channel;
++    QMetaObjectPublisher *publisher = channel.d_func()->publisher;
++
++    TestObject testObj;
++    testObj.setObjectName("testObject");
++    channel.registerObject(testObj.objectName(), &testObj);
++    channel.connectTo(&transport1);
++    channel.connectTo(&transport2);
++
++    testObj.setProp("Hello");
++
++    publisher->initializeClient(&transport1);
++    publisher->initializeClient(&transport2);
++    publisher->setClientIsIdle(true, &transport1);
++    QCOMPARE(publisher->isClientIdle(&transport1), true);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++    QVERIFY(transport1.messagesSent().isEmpty());
++    QVERIFY(transport2.messagesSent().isEmpty());
++
++    testObj.setProp("World");
++    QTRY_COMPARE_WITH_TIMEOUT(transport1.messagesSent().size(), 1u, 2000);
++    QCOMPARE(transport2.messagesSent().size(), 0u);
++    publisher->setClientIsIdle(true, &transport2);
++    QTRY_COMPARE_WITH_TIMEOUT(transport2.messagesSent().size(), 1u, 2000);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++
++    testObj.setProp("!!!");
++    publisher->setClientIsIdle(true, &transport2);
++    QCOMPARE(publisher->isClientIdle(&transport2), true);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QTRY_COMPARE_WITH_TIMEOUT(transport2.messagesSent().size(), 2u, 2000);
++    QCOMPARE(transport1.messagesSent().size(), 1u);
++    publisher->setClientIsIdle(true, &transport1);
++    QTRY_COMPARE_WITH_TIMEOUT(transport1.messagesSent().size(), 2u, 2000);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++}
++
+ class FunctionWrapper : public QObject
+ {
+     Q_OBJECT
+@@ -1082,7 +1124,7 @@ void TestWebChannel::benchInitializeClients()
+ 
+         publisher->propertyUpdatesInitialized = false;
+         publisher->signalToPropertyMap.clear();
+-        publisher->signalHandler.clear();
++        publisher->signalHandlers.clear();
+     }
+ }
+ 
+@@ -1107,7 +1149,7 @@ void TestWebChannel::benchPropertyUpdates()
+             obj->change();
+         }
+ 
+-        channel.d_func()->publisher->clientIsIdle = true;
++        channel.d_func()->publisher->setClientIsIdle(true, m_dummyTransport);
+         channel.d_func()->publisher->sendPendingPropertyUpdates();
+     }
+ }
+diff --git a/qtwebchannel/tests/auto/webchannel/tst_webchannel.h b/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
+index eae21f4..dd4e690 100644
+--- a/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
++++ b/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
+@@ -348,6 +348,7 @@ private slots:
+     void testJsonToVariant();
+     void testInfiniteRecursion();
+     void testAsyncObject();
++    void testPropertyMultipleTransports();
+     void testDeletionDuringMethodInvocation_data();
+     void testDeletionDuringMethodInvocation();
+ 
+Submodule qtwebengine f328054d...38e0df6c (commits not present)
+Submodule qtwebsockets 65850954..63fb8da1:
+diff --git a/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp b/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
+index 2affdd5..95f1194 100644
+--- a/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
++++ b/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
+@@ -273,6 +273,7 @@ void QWebSocketDataProcessor::clear()
+     if (!m_pConverterState)
+         m_pConverterState = new QTextCodec::ConverterState(QTextCodec::ConvertInvalidToNull |
+                                                            QTextCodec::IgnoreHeader);
++    frame.clear();
+ }
+ 
+ /*!
+diff --git a/qtwebsockets/src/websockets/qwebsocketprotocol.cpp b/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
+index df87a93..d0465f1 100644
+--- a/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
++++ b/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
+@@ -210,7 +210,7 @@ void QWebSocketProtocol::mask(char *payload, quint64 size, quint32 maskingKey)
+                             quint8((maskingKey & 0x0000FF00u) >> 8),
+                             quint8((maskingKey & 0x000000FFu))
+                           };
+-    int i = 0;
++    quint64 i = 0;
+     while (size-- > 0)
+         *payload++ ^= mask[i++ % 4];
+ }
diff --git a/srcpkgs/qt5/template b/srcpkgs/qt5/template
index a79d25e69da8..6dddce7f3e46 100644
--- a/srcpkgs/qt5/template
+++ b/srcpkgs/qt5/template
@@ -2,11 +2,11 @@
 #
 # revbump libqtxdg after bumping patch version
 pkgname=qt5
-version=5.15.7+20221119
+version=5.15.8
+revision=1
+build_style=meta
 # commit f8c9fb304bc3e53b3aa07f962cd74e9160decccc
 # base repo: https://invent.kde.org/qt/qt/qt5
-revision=5
-build_style=meta
 hostmakedepends="cmake clang flex perl glib-devel pkg-config
  python re2c ruby which"
 makedepends="SDL2-devel Vulkan-Headers alsa-lib-devel double-conversion-devel
@@ -29,8 +29,9 @@ homepage="https://qt.io/"
 # tarball is generated with `git archive-all qt5-$version.tar.gz`
 # to keep the size smaller qtwebengine, qtwebview, qtdocgallery, qtactiveqt and qtpim
 # can be marked with the export-ignore attribute
-distfiles="https://void.johnnynator.dev/distfiles/qt5-${version}.tar.gz"
-checksum=9d57af471c78029a362276b7c99108ea009f511bb9ba6ff6cb884f6ddd255e9f
+#distfiles="https://void.johnnynator.dev/distfiles/qt5-${version}.tar.gz"
+distfiles="https://download.qt.io/archive/qt/5.15/${version}/single/qt-everywhere-opensource-src-${version}.tar.xz"
+checksum=776a9302c336671f9406a53bd30b8e36f825742b2ec44a57c08217bff0fa86b9
 python_version=2 #unverified
 replaces="qt5-doc<5.6.0 qt5-quick1<5.6.0 qt5-quick1-devel<5.6.0 qt5-webkit<5.6.0 qt5-webkit-devel<5.6.0
  qt5-enginio<5.7.1 qt5-enginio-devel<5.7.1 qt5-plugin-gtk<5.7.1 qt5-canvas3d<5.13.0"
@@ -250,7 +251,6 @@ do_configure() {
 	# opts+=" -v"
 	opts+=" -skip qtwebengine"
 	opts+=" -skip qtwebview"
-	opts+=" -skip qtdocgallery"
 	opts+=" -skip qtpim"
 	opts+=" -skip qtsystems"
 	opts+=" -skip qtspeech"

From ecb24240b46fa79c561f7d26d4b133102194bb06 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 075/115] qt6-multimedia: revbump for ffmpeg-6.0

---
 srcpkgs/qt6-multimedia/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-multimedia/template b/srcpkgs/qt6-multimedia/template
index c622b7c9e8fc..f7778738f6d3 100644
--- a/srcpkgs/qt6-multimedia/template
+++ b/srcpkgs/qt6-multimedia/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-multimedia'
 pkgname=qt6-multimedia
 version=6.5.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DQT_FEATURE_gstreamer=ON"
 hostmakedepends="perl qt6-declarative-host-tools pkg-config qt6-shadertools"

From 767c90d3b445f07cf9722e935b2b32c8801456c6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 076/115] qtav: revbump for ffmpeg4-4.4.3

---
 srcpkgs/qtav/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtav/template b/srcpkgs/qtav/template
index 34c30b2c0c78..2d00ad104355 100644
--- a/srcpkgs/qtav/template
+++ b/srcpkgs/qtav/template
@@ -1,10 +1,10 @@
 # Template file for 'qtav'
 pkgname=qtav
 version=1.13.0
-revision=1
+revision=2
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel libass-devel libopenal-devel
+makedepends="ffmpeg4-devel libass-devel libopenal-devel
  libva-glx-devel libXv-devel pulseaudio-devel
  qt5-declarative-devel qt5-svg-devel
  qt5-quickcontrols"

From 9ea19eb5d78eb11cdbfa0e8ebfee98c2d0f206b8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 077/115] qtox: revbump for ffmpeg-6.0

---
 srcpkgs/qtox/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qtox/template b/srcpkgs/qtox/template
index 16019d7eaec9..5cea0b11b697 100644
--- a/srcpkgs/qtox/template
+++ b/srcpkgs/qtox/template
@@ -1,7 +1,7 @@
 # Template file for 'qtox'
 pkgname=qtox
 version=1.17.6
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DUPDATE_CHECK=OFF
  -DGIT_DESCRIBE=${version}

From 056e683e19d499b5637c60fe631383206549b8ea Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 078/115] retroarch: revbump for ffmpeg-6.0

---
 srcpkgs/retroarch/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroarch/template b/srcpkgs/retroarch/template
index 240d3df9db00..6d0b16ae2598 100644
--- a/srcpkgs/retroarch/template
+++ b/srcpkgs/retroarch/template
@@ -1,7 +1,7 @@
 # Template file for 'retroarch'
 pkgname=retroarch
 version=1.14.0
-revision=1
+revision=2
 build_style=configure
 configure_args="--prefix=/usr --sysconfdir=/etc --enable-networking
  --enable-udev --disable-builtinflac --disable-builtinglslang

From 7cda820ba128725813c8ae7af71565d85a671543 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 079/115] scrcpy: revbump for ffmpeg-6.0

---
 srcpkgs/scrcpy/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/scrcpy/template b/srcpkgs/scrcpy/template
index ee6e698e387f..8ada5ca4323f 100644
--- a/srcpkgs/scrcpy/template
+++ b/srcpkgs/scrcpy/template
@@ -1,7 +1,7 @@
 # Template file for 'scrcpy'
 pkgname=scrcpy
 version=2.0
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcompile_server=false
  -Dprebuilt_server=/usr/share/scrcpy/scrcpy-server-v${version}"

From 38619650a92bd920a7d1644a94e44d404d192c5d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 080/115] spek-alternative: revbump for ffmpeg4-4.4.3

---
 srcpkgs/spek-alternative/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/spek-alternative/template b/srcpkgs/spek-alternative/template
index d65086b8f008..05246f1b8d0c 100644
--- a/srcpkgs/spek-alternative/template
+++ b/srcpkgs/spek-alternative/template
@@ -1,11 +1,11 @@
 # Template file for 'spek-alternative'
 pkgname=spek-alternative
 version=0.8.2.3
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake gettext-devel intltool libtool pkg-config wxWidgets-common"
-makedepends="ffmpeg-devel wxWidgets-gtk3-devel"
-depends="ffmpeg"
+makedepends="ffmpeg4-devel wxWidgets-gtk3-devel"
+depends="ffmpeg4"
 short_desc="Acoustic spectrum analyser"
 maintainer="Kartik Singh <kartik.ynwa@gmail.com>"
 license="GPL-3.0-or-later"

From cacafd990232c1936e6b82dfdafc2ae614504355 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 081/115] ssr: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ssr/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/ssr/template b/srcpkgs/ssr/template
index b055b9ec0774..3448ca110eb0 100644
--- a/srcpkgs/ssr/template
+++ b/srcpkgs/ssr/template
@@ -1,11 +1,11 @@
 # Template file for 'ssr'
 pkgname=ssr
 version=0.4.4
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_QT5=ON"
 hostmakedepends="pkg-config"
-makedepends="alsa-lib-devel ffmpeg-devel glu-devel jack-devel pulseaudio-devel
+makedepends="alsa-lib-devel ffmpeg4-devel glu-devel jack-devel pulseaudio-devel
  qt5-tools-devel qt5-x11extras-devel libXinerama-devel v4l-utils-devel"
 depends="desktop-file-utils hicolor-icon-theme"
 short_desc="Simple Screen Recorder for programs and games"

From 344cb6f1c8402ee1e1caa8f0e0560d0ae5b5e4c3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 082/115] sumo: revbump for ffmpeg-6.0

---
 srcpkgs/sumo/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/sumo/template b/srcpkgs/sumo/template
index 0f9b9ec815f5..a3fe134aa5ac 100644
--- a/srcpkgs/sumo/template
+++ b/srcpkgs/sumo/template
@@ -1,7 +1,7 @@
 # Template file for 'sumo'
 pkgname=sumo
 version=1.12.0
-revision=5
+revision=6
 build_style=cmake
 hostmakedepends="libgdal-tools pkg-config swig python3-setuptools"
 makedepends="python3-devel ffmpeg-devel fox-devel gl2ps-devel libgdal-devel

From 94242939d68d138f8e10699a7fe7c041f0ab94db Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 083/115] synfig: revbump for ffmpeg-6.0 and mlt7

---
 srcpkgs/synfig/patches/ffmpeg6.patch | 71 ++++++++++++++++++++++++++++
 srcpkgs/synfig/template              |  4 +-
 2 files changed, 73 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/synfig/patches/ffmpeg6.patch

diff --git a/srcpkgs/synfig/patches/ffmpeg6.patch b/srcpkgs/synfig/patches/ffmpeg6.patch
new file mode 100644
index 000000000000..10780b42782f
--- /dev/null
+++ b/srcpkgs/synfig/patches/ffmpeg6.patch
@@ -0,0 +1,71 @@
+--- a/src/modules/mod_libavcodec/trgt_av.cpp	2022-10-25 09:14:12.000000000 -0400
++++ b/src/modules/mod_libavcodec/trgt_av.cpp	2023-05-05 21:34:17.899194559 -0400
+@@ -38,6 +41,7 @@
+ extern "C"
+ {
+ #ifdef HAVE_LIBAVFORMAT_AVFORMAT_H
++#	include <libavcodec/avcodec.h>
+ #	include <libavformat/avformat.h>
+ #elif defined(HAVE_AVFORMAT_H)
+ #	include <avformat.h>
+@@ -155,11 +156,11 @@
+     }
+ 
+ 	bool open_video_stream() {
+-		if (avcodec_open2(video_context, NULL, NULL) < 0) {
++		if (avcodec_open2(video_context, nullptr, nullptr) < 0) {
+ 			synfig::error("Target_LibAVCodec: could not open video codec");
+ 			// seems the calling of avcodec_free_context after error will cause crash
+ 			// so just forget about this context
+-			video_context = NULL;
++			video_context = nullptr;
+ 			close();
+ 			return false;
+         }
+@@ -234,15 +235,21 @@
+ 		close();
+ 
+ 		if (!av_registered) {
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 			av_register_all();
++#endif
+ 			av_registered = true;
+ 		}
+ 
+ 		// guess format
+-		AVOutputFormat *format = av_guess_format(NULL, filename.c_str(), NULL);
++#if LIBAVCODEC_VERSION_MAJOR < 59 // FFMPEG < 5.0
++		AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#else
++		const AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#endif
+ 		if (!format) {
+ 			synfig::warning("Target_LibAVCodec: unable to guess the output format, defaulting to MPEG");
+-			format = av_guess_format("mpeg", NULL, NULL);
++			format = av_guess_format("mpeg", nullptr, nullptr);
+ 		}
+ 		if (!format) {
+ 			synfig::error("Target_LibAVCodec: unable to find 'mpeg' output format");
+@@ -254,6 +261,7 @@
+ 		context = avformat_alloc_context();
+ 		assert(context);
+ 		context->oformat = format;
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 		if (filename.size() + 1 > sizeof(context->filename)) {
+ 			synfig::error(
+ 				"Target_LibAVCodec: filename too long, max length is %d, filename is '%s'",
+@@ -263,6 +271,14 @@
+ 			return false;
+ 		}
+ 		memcpy(context->filename, filename.c_str(), filename.size() + 1);
++#else
++		context->url = av_strndup(filename.c_str(), filename.size());
++		if (!context->url) {
++			synfig::error("Target_LibAVCodec: cannot allocate space for filename");
++			close();
++			return false;
++		}
++#endif
+ 
+ 		packet = av_packet_alloc();
+ 		assert(packet);
diff --git a/srcpkgs/synfig/template b/srcpkgs/synfig/template
index 5f5f5bb3f4b2..6e0d713150ae 100644
--- a/srcpkgs/synfig/template
+++ b/srcpkgs/synfig/template
@@ -6,7 +6,7 @@ revision=2
 build_style=gnu-configure
 configure_args="--with-boost-libdir=${XBPS_CROSS_BASE}/usr/lib"
 hostmakedepends="boost-build ImageMagick pkg-config intltool"
-makedepends="ETL gettext-devel libxml++-devel mlt-devel libmagick-devel
+makedepends="ETL gettext-devel libxml++-devel mlt7-devel libmagick-devel
  libmng-devel boost-build boost-devel libopenexr-devel ffmpeg-devel"
 depends="ImageMagick"
 short_desc="CLI 2D vector and timeline-based animation software"
@@ -20,7 +20,7 @@ CXXFLAGS="-std=c++11 -DHAVE_LOCALE_H=1"
 
 synfig-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision}
-	 libopenexr-devel libxml++-devel mlt-devel"
+	 libopenexr-devel libxml++-devel mlt7-devel"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/bin/synfig-config

From 0b88e4efd4b9488ad72f2543604bb4eba9f3b7b7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 5 May 2023 12:57:57 -0400
Subject: [PATCH 084/115] synfigstudio: revbump for synfig mlt7

---
 srcpkgs/synfigstudio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/synfigstudio/template b/srcpkgs/synfigstudio/template
index 91349169ed2b..af1c5a296ef0 100644
--- a/srcpkgs/synfigstudio/template
+++ b/srcpkgs/synfigstudio/template
@@ -2,7 +2,7 @@
 # Should be kept in sync with 'synfig' and 'ETL'
 pkgname=synfigstudio
 version=1.4.4
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--disable-update-mimedb"
 hostmakedepends="pkg-config intltool gettext synfig"

From 792aa261a6a51844f91ce7615f3758e8a02d0792 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 085/115] tg_owt: revbump for ffmpeg-6.0

---
 srcpkgs/tg_owt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tg_owt/template b/srcpkgs/tg_owt/template
index 97d195ddb34a..551614b24956 100644
--- a/srcpkgs/tg_owt/template
+++ b/srcpkgs/tg_owt/template
@@ -1,7 +1,7 @@
 # Template file for 'tg_owt'
 pkgname=tg_owt
 version=0.0.0.20230107
-revision=1
+revision=2
 _commit=5098730b9eb6173f0b52068fe2555b7c1015123a
 _libyuv_commit=00950840d1c9bcbb3eb6ebc5aac5793e71166c8b
 _abseil_commit=8c0b94e793a66495e0b1f34a5eb26bd7dc672db0

From bc6ea5e22ba2045078f45c1d075f7e63787f3e77 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 086/115] timg: revbump for ffmpeg-6.0

---
 srcpkgs/timg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/timg/template b/srcpkgs/timg/template
index 2a2ab763d2fd..8fb4327535ef 100644
--- a/srcpkgs/timg/template
+++ b/srcpkgs/timg/template
@@ -1,7 +1,7 @@
 # Template file for 'timg'
 pkgname=timg
 version=1.4.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_OPENSLIDE_SUPPORT=off -Wno-dev"
 hostmakedepends="pkg-config git"

From 7188ee1dc22599b9e6aec757314c004394b6d344 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 087/115] tvheadend: revbump for ffmpeg4-4.4.3

---
 srcpkgs/tvheadend/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/tvheadend/template b/srcpkgs/tvheadend/template
index e6b16d7ccf3b..46b52b6fb7f9 100644
--- a/srcpkgs/tvheadend/template
+++ b/srcpkgs/tvheadend/template
@@ -1,14 +1,14 @@
 # Template file for 'tvheadend'
 pkgname=tvheadend
 version=4.2.8
-revision=6
+revision=7
 build_style=gnu-configure
 configure_args="--enable-dvbscan --disable-ffmpeg_static
 --disable-hdhomerun_static --disable-bintray_cache --disable-libx264_static
 --disable-libx265_static --disable-libvpx_static --disable-libtheora_static
 --disable-libvorbis_static --disable-libfdkaac_static"
 hostmakedepends="gettext pkg-config python git which"
-makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg-devel"
+makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg4-devel"
 short_desc="TV streaming server"
 maintainer="lemmi <lemmi@nerd2nerd.org>"
 license="GPL-3.0-only"

From c7b50ffe3fb128e763b0affb40139149a75bfc51 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 088/115] unpaper: update to 7.0.0.

---
 srcpkgs/unpaper/template | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/srcpkgs/unpaper/template b/srcpkgs/unpaper/template
index 38ed47a58401..1ff910e722af 100644
--- a/srcpkgs/unpaper/template
+++ b/srcpkgs/unpaper/template
@@ -1,13 +1,13 @@
 # Template file for 'unpaper'
 pkgname=unpaper
-version=6.1
-revision=3
-build_style=gnu-configure
+version=7.0.0
+revision=1
+build_style=meson
+hostmakedepends="pkg-config meson libxslt"
+makedepends="ffmpeg-devel python3-Sphinx"
+short_desc="Post-processing tool for scanned sheets of paper"
 maintainer="Orphaned <orphan@voidlinux.org>"
-hostmakedepends="pkg-config libxslt"
-makedepends="ffmpeg-devel"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://www.flameeyes.eu/projects/unpaper"
-short_desc="A post-processing tool for scanned sheets of paper"
 distfiles="https://www.flameeyes.eu/files/${pkgname}-${version}.tar.xz"
-checksum=237c84f5da544b3f7709827f9f12c37c346cdf029b1128fb4633f9bafa5cb930
+checksum=2575fbbf26c22719d1cb882b59602c9900c7f747118ac130883f63419be46a80

From d99c85da6900e1c874ddc6ea60212869a71f0c62 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 089/115] vba-m: revbump for ffmpeg-6.0

---
 srcpkgs/vba-m/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vba-m/template b/srcpkgs/vba-m/template
index ba153e0b58ca..aa6093645e97 100644
--- a/srcpkgs/vba-m/template
+++ b/srcpkgs/vba-m/template
@@ -2,7 +2,7 @@
 pkgname=vba-m
 reverts=1292_2
 version=2.1.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_GTK=TRUE -DENABLE_FFMPEG=TRUE -DENABLE_LINK=TRUE -DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="gettext pkg-config unzip zip yasm wxWidgets-gtk3-devel"

From fd7c25b305a63598b4ffe1210854999d7e31524f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 090/115] vice: revbump for ffmpeg4-4.4.3

---
 srcpkgs/vice/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/vice/template b/srcpkgs/vice/template
index 0924767cfcfb..5981e45149d0 100644
--- a/srcpkgs/vice/template
+++ b/srcpkgs/vice/template
@@ -1,7 +1,7 @@
 # Template file for 'vice'
 pkgname=vice
 version=3.5
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="
 	$(vopt_enable sdl2 sdlui2)
@@ -28,7 +28,7 @@ makedepends="
 	$(vopt_if gtk3 gtk+3-devel)
 	$(vopt_if gtk3 pulseaudio-devel)
 	$(vopt_if gtk3 pango-devel)
-	$(vopt_if ffmpeg ffmpeg-devel)"
+	$(vopt_if ffmpeg ffmpeg4-devel)"
 short_desc="Emulator for C64, C128, CBM-II, PET, VIC20, Plus4 and C16"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"

From 393ce7613c5477112accd3a6603eda3d605f08e5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 091/115] waypipe: revbump for ffmpeg-6.0

---
 srcpkgs/waypipe/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waypipe/template b/srcpkgs/waypipe/template
index 5c4161900060..1a46fe27f7d8 100644
--- a/srcpkgs/waypipe/template
+++ b/srcpkgs/waypipe/template
@@ -1,7 +1,7 @@
 # Template file for 'waypipe'
 pkgname=waypipe
 version=0.8.4
-revision=1
+revision=2
 build_style=meson
 # lto is off because it causes linking errors in armv6l and armv7l (due to NEON)
 configure_args="-Dwerror=false -Dwith_dmabuf=enabled -Dwith_lz4=enabled

From 756e47c88fe8ffe6b09aa762becffba5fd377068 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 092/115] wf-recorder: revbump for ffmpeg-6.0

---
 srcpkgs/wf-recorder/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/wf-recorder/template b/srcpkgs/wf-recorder/template
index e278eb001600..5d014a5f28af 100644
--- a/srcpkgs/wf-recorder/template
+++ b/srcpkgs/wf-recorder/template
@@ -1,7 +1,7 @@
 # Template file for 'wf-recorder'
 pkgname=wf-recorder
 version=0.3.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config scdoc wayland-devel"
 makedepends="wayland-protocols wayland-devel ffmpeg-devel x264-devel

From d2f8e94039d1c3e768e5b2e793fbd7be4a0ed70b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 093/115] xpra: revbump for ffmpeg-6.0

---
 srcpkgs/xpra/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xpra/template b/srcpkgs/xpra/template
index ee8ce4ec78a9..c02482ad4b39 100644
--- a/srcpkgs/xpra/template
+++ b/srcpkgs/xpra/template
@@ -1,7 +1,7 @@
 # Template file for 'xpra'
 pkgname=xpra
 version=4.4.5
-revision=1
+revision=2
 build_style=python3-module
 make_build_args="--without-cuda_kernels --without-cuda_rebuild"
 make_install_args="$(vopt_with docs) ${make_build_args}"

From a2560a5c189aa21363f01c8fa430e71fcc73fb28 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:07:40 -0400
Subject: [PATCH 094/115] nv-codec-headers: update to 12.0.16.0

---
 srcpkgs/nv-codec-headers/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/nv-codec-headers/template b/srcpkgs/nv-codec-headers/template
index 3d422a61e489..251e057f826f 100644
--- a/srcpkgs/nv-codec-headers/template
+++ b/srcpkgs/nv-codec-headers/template
@@ -1,6 +1,6 @@
 # Template file for 'nv-codec-headers'
 pkgname=nv-codec-headers
-version=11.1.5.1
+version=12.0.16.0
 revision=1
 build_style=gnu-makefile
 short_desc="FFmpeg version of headers required to interface with Nvidias codec APIs"
@@ -8,7 +8,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="MIT"
 homepage="http://git.videolan.org/?p=ffmpeg/nv-codec-headers.git"
 distfiles="https://github.com/FFmpeg/nv-codec-headers/archive/n${version}.tar.gz"
-checksum=d095fbd56aa93772471a323be0ebe65504a0f43f06c76a30b6d25da77b06ae9c
+checksum=2a1533b65f55f9da52956faf0627ed3b74868ac0c7f269990edd21369113b48f
 
 post_install() {
 	sed -n '4,25p' include/ffnvcodec/nvEncodeAPI.h > LICENSE

From cc5306d3fe8b7a2b9eeef5ff6c8581ddfa7c56b9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:08:40 -0400
Subject: [PATCH 095/115] openimagedenoise: revbump for ffmpeg-6.0

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index db5ccdb055cc..cb90045afb63 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,7 +1,7 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
 version=1.4.3
-revision=1
+revision=2
 archs="x86_64*"
 build_style=cmake
 hostmakedepends="ispc python3"

From 211856180de06ec7f7ae2b1e93bb1ce128f49b94 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:31:45 -0400
Subject: [PATCH 096/115] shotcut: revbump for ffmpeg-6.0

---
 srcpkgs/shotcut/template | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/srcpkgs/shotcut/template b/srcpkgs/shotcut/template
index 99ebf2e8a5af..c416c906ff73 100644
--- a/srcpkgs/shotcut/template
+++ b/srcpkgs/shotcut/template
@@ -1,20 +1,20 @@
 # Template file for 'shotcut'
 pkgname=shotcut
-version=22.12.21
-revision=1
+version=23.05.14
+revision=2
 build_style=cmake
 configure_args="-DSHOTCUT_VERSION=${version}"
-hostmakedepends="pkg-config qt5-tools-devel"
-makedepends="mlt7-devel qt5-declarative-devel qt5-multimedia-devel
- qt5-quickcontrols2-devel qt5-websockets-devel qt5-plugin-mysql qt5-plugin-odbc
- qt5-plugin-pgsql qt5-plugin-sqlite qt5-plugin-tds"
-depends="ffmpeg frei0r-plugins qt5-graphicaleffects qt5-quickcontrols"
+hostmakedepends="pkg-config qt6-tools-devel"
+makedepends="mlt7-devel qt6-declarative-devel qt6-multimedia-devel
+ qt6-websockets-devel qt6-plugin-mysql qt6-plugin-odbc
+ qt6-plugin-pgsql qt6-plugin-sqlite"
+depends="ffmpeg frei0r-plugins qt6-declarative"
 short_desc="Free, open source, cross-platform video editor"
 maintainer="John <me@johnnynator.dev>"
 license="GPL-3.0-or-later"
 homepage="https://www.shotcut.org"
 changelog="https://github.com/mltframework/shotcut/releases"
 distfiles="https://github.com/mltframework/shotcut/archive/v${version}.tar.gz"
-checksum=1b9a4f87b16a9751f9cb41588f22af4c00f085105d82cf21d095d9f3c280bc86
+checksum=94632bd69cc8f3b2cba0668b9e8d051493efa5a9c9554c02822c346fe64c1ce0
 
 CXXFLAGS="-DHAVE_LOCALE_H=1 -DSHOTCUT_NOUPGRADE"

From b0673dac6c3ab09aaf6b8d3b1d65223a3353993e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:30 -0400
Subject: [PATCH 097/115] shiboken2: revbump for qt5-5.15.8

---
 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch | 1 +
 srcpkgs/shiboken2/template                                 | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
 create mode 120000 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
new file mode 120000
index 000000000000..efcf3249bd88
--- /dev/null
+++ b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1 @@
+../../python3-pyside2/patches/importlib-machinery-bypass.patch
\ No newline at end of file
diff --git a/srcpkgs/shiboken2/template b/srcpkgs/shiboken2/template
index 084ecc3ba1e1..2a21998997eb 100644
--- a/srcpkgs/shiboken2/template
+++ b/srcpkgs/shiboken2/template
@@ -1,7 +1,7 @@
 # Template file for 'shiboken2'
 pkgname=shiboken2
 version=5.15.7
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/shiboken2"
 build_style=cmake

From cb8b2ec6651a355db7735222c521a9aae5499ab5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:53 -0400
Subject: [PATCH 098/115] python3-pyside2: update to 5.15.8

---
 .../patches/importlib-machinery-bypass.patch      | 15 +++++++++++++++
 srcpkgs/python3-pyside2/template                  |  9 +++++----
 2 files changed, 20 insertions(+), 4 deletions(-)
 create mode 100644 srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
new file mode 100644
index 000000000000..64c429584776
--- /dev/null
+++ b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1,15 @@
+Using this prevents an error around line 220 below it.
+"AttributeError: module 'importlib' has no attribute 'machinery'"
+The old backup logic is in place and compiles without issues.
+--- a/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:09:34.688912402 -0400
++++ b/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:10:03.395529582 -0400
+@@ -170,9 +170,6 @@
+
+     # 'zipstring_sequence' comes from signature.cpp
+     zipbytes = base64.b64decode(''.join(zipstring_sequence))
+-    if sys.version_info[0] >= 3:
+-        vzip = zipfile.ZipFile(io.BytesIO(zipbytes))
+-        return sys.meta_path, EmbeddableZipImporter(vzip)
+
+     # Old version for Python 2.7, only.
+     import os
diff --git a/srcpkgs/python3-pyside2/template b/srcpkgs/python3-pyside2/template
index 50e6ff260d3b..b50e62bd215d 100644
--- a/srcpkgs/python3-pyside2/template
+++ b/srcpkgs/python3-pyside2/template
@@ -1,11 +1,12 @@
 # Template file for 'python3-pyside2'
 pkgname=python3-pyside2
-version=5.15.5
-revision=2
+version=5.15.8
+revision=1
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/pyside2"
 build_style=cmake
-configure_args="-DPYTHON_EXECUTABLE=/usr/bin/python"
+configure_args="-DPYTHON_EXECUTABLE=/usr/bin/python -DCMAKE_BUILD_TYPE=None
+ -DBUILD_TESTS=OFF"
 hostmakedepends="cmake python3 shiboken2"
 makedepends="python3-devel libshiboken2-devel qt5-devel
  qt5-multimedia-devel qt5-tools-devel qt5-plugin-mysql qt5-plugin-odbc
@@ -23,7 +24,7 @@ maintainer="yopito <pierre.bourgin@free.fr>"
 license="LGPL-3.0-or-later"
 homepage="https://wiki.qt.io/Qt_for_Python"
 distfiles="https://download.qt.io/official_releases/QtForPython/pyside2/PySide2-${version}-src/${_pkgname}.tar.xz"
-checksum=3920a4fb353300260c9bc46ff70f1fb975c5e7efa22e9d51222588928ce19b33
+checksum=23436302c8deb5b4cbc769b205d09604e38ba83b40708efccb7bd8c9af6f6b5d
 
 build_options="webengine"
 desc_option_webengine="Build Qt5 WebEngine bindings"

From f85712f337d1f2625bbe1fc0390025156504242e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:35 -0400
Subject: [PATCH 099/115] konqueror: revbump for ffmpeg-6.0

---
 srcpkgs/konqueror/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/konqueror/template b/srcpkgs/konqueror/template
index d8d0e73a78ab..c5bdba601d3c 100644
--- a/srcpkgs/konqueror/template
+++ b/srcpkgs/konqueror/template
@@ -1,11 +1,11 @@
 # Template file for 'konqueror'
 pkgname=konqueror
 version=23.04.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DDESKTOPTOJSON_EXECUTABLE=/usr/bin/desktoptojson"
 hostmakedepends="extra-cmake-modules python3 qt5-host-tools qt5-qmake kdoctools
-kcoreaddons kconfig gettext"
+ kcoreaddons kconfig gettext"
 makedepends="qt5-devel qt5-webengine-devel qt5-declarative-devel
  qt5-webchannel-devel qt5-location-devel kcmutils-devel kdelibs4support-devel
  karchive-devel khtml-devel kdesu-devel kactivities5-devel"

From 05493cf1433845da847516dda8ce5b9cc17378a8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:58 -0400
Subject: [PATCH 100/115] qt5-speech: revbump for qt5-5.15.8

---
 srcpkgs/qt5-speech/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-speech/template b/srcpkgs/qt5-speech/template
index 3ecd10d50650..2d7d4d4d2453 100644
--- a/srcpkgs/qt5-speech/template
+++ b/srcpkgs/qt5-speech/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-speech'
 pkgname=qt5-speech
 version=5.15.7
-revision=2
+revision=3
 _commit=d32f4a479d38a11f547598004b975f4356424a16
 build_style=qmake
 configure_args="-- -flite -flite-alsa -speechd"

From 539264af038a4edc6f45774f71baaa2e5f46da3d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 18:38:50 -0400
Subject: [PATCH 101/115] qt5-styleplugins: revbump for qt5-5.15.8

---
 srcpkgs/qt5-styleplugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-styleplugins/template b/srcpkgs/qt5-styleplugins/template
index 96ed97d12cd2..30d93660a2a4 100644
--- a/srcpkgs/qt5-styleplugins/template
+++ b/srcpkgs/qt5-styleplugins/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-styleplugins'
 pkgname=qt5-styleplugins
 version=5.0.0
-revision=20
+revision=21
 _gitrev=335dbece103e2cbf6c7cf819ab6672c2956b17b3
 build_style=qmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From f4358c0d73690a68d36a963f285d7604ec2c5e8e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 30 Apr 2023 20:22:26 -0400
Subject: [PATCH 102/115] gst-plugins-ugly1: revbump for ffmpeg-6.0

---
 srcpkgs/gst-plugins-ugly1/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-plugins-ugly1/template b/srcpkgs/gst-plugins-ugly1/template
index e254fd40f869..85ae64bc7a0a 100644
--- a/srcpkgs/gst-plugins-ugly1/template
+++ b/srcpkgs/gst-plugins-ugly1/template
@@ -1,6 +1,6 @@
 # Template file for 'gst-plugins-ugly1'
 pkgname=gst-plugins-ugly1
-version=1.20.3
+version=1.22.2
 revision=1
 build_style=meson
 configure_args="-Damrnb=disabled -Damrwbdec=disabled -Dsidplay=disabled"
@@ -15,4 +15,4 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname/1/}/${pkgname/1/}-${version}.tar.xz"
-checksum=8caa20789a09c304b49cf563d33cca9421b1875b84fcc187e4a385fa01d6aefd
+checksum=8f30f44db0bd063709bf6fbe55138e3a98af0abcb61c360f35582bbe10e80691

From 4d1b0c455a5f529b3dee7b5704a7772e2a01ecd3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 30 Apr 2023 20:22:26 -0400
Subject: [PATCH 103/115] gst-rtsp-server: revbump for ffmpeg-6.0

---
 srcpkgs/gst-rtsp-server/template | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index 8ceea8d34b4b..980fd72cdd4c 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
-version=1.20.3
-revision=3
+version=1.22.2
+revision=2
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="glib-devel gst-plugins-bad1-devel gobject-introspection
@@ -10,5 +10,5 @@ short_desc="GStreamer multimedia graph framework - rtsp server"
 maintainer="1is7ac3 <isaac.qa13@gmail.com>"
 license="LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
-distfiles="https://gstreamer.freedesktop.org/src/gst-rtsp-server/gst-rtsp-server-${version}.tar.xz"
-checksum=ee402718be9b127f0e5e66ca4c1b4f42e4926ec93ba307b7ccca5dc6cc9794ca
+distfiles="${homepage}/src/${pkgname}/${pkgname}-${version}.tar.xz"
+checksum=2be4aecfb88710100ea7115ed0216403e8094344ebf146094271b8d4d73828bf

From 9993149052135033298de50a359d99483ece2672 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 30 Apr 2023 20:22:26 -0400
Subject: [PATCH 104/115] gst-libav: revbump for ffmpeg-6.0

---
 srcpkgs/gst-libav/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index f082bd211c65..04c39bff1489 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,6 +1,6 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
-version=1.20.3
+version=1.22.2
 revision=2
 build_style=meson
 hostmakedepends="pkg-config yasm"
@@ -11,7 +11,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.0-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname}/${pkgname}-${version}.tar.xz"
-checksum=3fedd10560fcdfaa1b6462cbf79a38c4e7b57d7f390359393fc0cef6dbf27dfe
+checksum=fcaaf9878fe8f3bc82317ef13a1558824cb68df1f8968c6797f556c5e33bcffd
 
 case "$XBPS_TARGET_MACHINE" in
 	*-musl) # Required by musl for M_SQRT1_2

From ff8a6c60fd54b7cb23538d50b11f2ed2576f27c1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 7 May 2023 20:14:14 -0400
Subject: [PATCH 105/115] mlt7: revbump for ffmpeg-6.0

---
 srcpkgs/gst-libav/template             | 2 +-
 srcpkgs/gst-omx/template               | 4 ++--
 srcpkgs/gst-plugins-base1/template     | 4 ++--
 srcpkgs/gst-plugins-good1/template     | 4 ++--
 srcpkgs/gst1-editing-services/template | 4 ++--
 srcpkgs/gst1-python3/template          | 6 +++---
 srcpkgs/gstreamer-vaapi/template       | 4 ++--
 srcpkgs/gstreamer1/template            | 4 ++--
 srcpkgs/mlt7/template                  | 2 +-
 9 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index 04c39bff1489..8c72fc3e97ee 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.22.2
-revision=2
+revision=1
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"
diff --git a/srcpkgs/gst-omx/template b/srcpkgs/gst-omx/template
index 893535c463da..5ad54cc7b9d8 100644
--- a/srcpkgs/gst-omx/template
+++ b/srcpkgs/gst-omx/template
@@ -1,6 +1,6 @@
 # Template file for 'gst-omx'
 pkgname=gst-omx
-version=1.20.3
+version=1.22.2
 revision=1
 build_style=meson
 configure_args="-Dexamples=disabled -Dtarget=generic"
@@ -11,4 +11,4 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.1-only"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname}/${pkgname}-${version}.tar.xz"
-checksum=8db48040bb41f09edf8d17ff6d16c54888d7777ba4501c2c69f0083350ea9a15
+checksum=1b0c57f2cc4ddeec5e7f0c436e502f06665c4e93c73261855b94e04fc94337b2
diff --git a/srcpkgs/gst-plugins-base1/template b/srcpkgs/gst-plugins-base1/template
index 29e8f76bd1fe..2f20ea819849 100644
--- a/srcpkgs/gst-plugins-base1/template
+++ b/srcpkgs/gst-plugins-base1/template
@@ -1,6 +1,6 @@
 # Template file for 'gst-plugins-base1'
 pkgname=gst-plugins-base1
-version=1.20.3
+version=1.22.2
 revision=1
 build_style=meson
 build_helper="gir"
@@ -22,7 +22,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname/1/}/${pkgname/1/}-${version}.tar.xz"
-checksum=7e30b3dd81a70380ff7554f998471d6996ff76bbe6fc5447096f851e24473c9f
+checksum=eb65120c4ee79b7a153c3c1972d5c0158c2151877cc51ec7725bba5749679d49
 
 build_options="cdparanoia gir sndio wayland"
 build_options_default="cdparanoia gir wayland"
diff --git a/srcpkgs/gst-plugins-good1/template b/srcpkgs/gst-plugins-good1/template
index 1f5e620ce1fd..5d0fe1bfe284 100644
--- a/srcpkgs/gst-plugins-good1/template
+++ b/srcpkgs/gst-plugins-good1/template
@@ -1,6 +1,6 @@
 # Template file for 'gst-plugins-good1'
 pkgname=gst-plugins-good1
-version=1.20.3
+version=1.22.2
 revision=1
 build_style=meson
 configure_args="-Ddv=disabled -Ddv1394=disabled -Dshout2=disabled -Dqt5=enabled
@@ -22,7 +22,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname/1/}/${pkgname/1/}-${version}.tar.xz"
-checksum=f8f3c206bf5cdabc00953920b47b3575af0ef15e9f871c0b6966f6d0aa5868b7
+checksum=7c8cc59425f2b232f60ca7d13e56edd615da4f711e73dd01a7cffa46e6bc0cdd
 
 build_options="gtk3 wayland"
 build_options_default="gtk3 wayland"
diff --git a/srcpkgs/gst1-editing-services/template b/srcpkgs/gst1-editing-services/template
index 673b46970f24..102440f7f253 100644
--- a/srcpkgs/gst1-editing-services/template
+++ b/srcpkgs/gst1-editing-services/template
@@ -1,6 +1,6 @@
 # Template file for 'gst1-editing-services'
 pkgname=gst1-editing-services
-version=1.20.3
+version=1.22.2
 revision=1
 build_style=meson
 build_helper="gir"
@@ -12,7 +12,7 @@ maintainer="Toyam Cox <Vaelatern@gmail.com>"
 license="LGPL-2.0-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname/gst1/gst}/${pkgname/gst1/gst}-${version}.tar.xz"
-checksum=5fd896de69fbe24421eb6b0ff8d2f8b4c3cba3f3025ceacd302172f39a8abaa2
+checksum=453b1464fc3857de269a7cb0ebd966afe02171d97bef672a0b8a0a6d43e0cebf
 
 do_check() {
 	: # Tests fail in older versions as well
diff --git a/srcpkgs/gst1-python3/template b/srcpkgs/gst1-python3/template
index 3f564ac64b93..789e40f036ea 100644
--- a/srcpkgs/gst1-python3/template
+++ b/srcpkgs/gst1-python3/template
@@ -1,7 +1,7 @@
 # Template file for 'gst1-python3'
 pkgname=gst1-python3
-version=1.20.3
-revision=2
+version=1.22.2
+revision=1
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="libglib-devel python3-devel python3-gobject-devel gst-plugins-base1-devel"
@@ -11,4 +11,4 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/gst-python/gst-python-${version}.tar.xz"
-checksum=db348120eae955b8cc4de3560a7ea06e36d6e1ddbaa99a7ad96b59846601cfdc
+checksum=bef2b3d82ce4be46b775b1bb56305c1003ee01b535a53a82f9fe8924972153ad
diff --git a/srcpkgs/gstreamer-vaapi/template b/srcpkgs/gstreamer-vaapi/template
index 3cc4e057559a..0a5ee8b1ca3f 100644
--- a/srcpkgs/gstreamer-vaapi/template
+++ b/srcpkgs/gstreamer-vaapi/template
@@ -1,6 +1,6 @@
 # Template file for 'gstreamer-vaapi'
 pkgname=gstreamer-vaapi
-version=1.20.3
+version=1.22.2
 revision=1
 build_style=meson
 hostmakedepends="pkg-config"
@@ -11,7 +11,7 @@ license="LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
 changelog="https://raw.githubusercontent.com/GStreamer/gstreamer-vaapi/master/ChangeLog"
 distfiles="${homepage}/src/gstreamer-vaapi/gstreamer-vaapi-${version}.tar.xz"
-checksum=6ee99eb316abdde9ad37002915bd8c3867918f6fdc74b7cf2ac4c1ae0d690b45
+checksum=d2e642f9745f97d9f73a7f5085e7659a9a31fe209b774e6e45dae041b435df06
 
 pre_check() {
 	# Seems to need certain hardware to pass
diff --git a/srcpkgs/gstreamer1/template b/srcpkgs/gstreamer1/template
index ae8a49cb20e8..571148f2ff33 100644
--- a/srcpkgs/gstreamer1/template
+++ b/srcpkgs/gstreamer1/template
@@ -1,6 +1,6 @@
 # Template file for 'gstreamer1'
 pkgname=gstreamer1
-version=1.20.3
+version=1.22.2
 revision=1
 build_style=meson
 build_helper="gir"
@@ -16,7 +16,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.0-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/gstreamer/gstreamer-${version}.tar.xz"
-checksum=607daf64bbbd5fb18af9d17e21c0d22c4d702fffe83b23cb22d1b1af2ca23a2a
+checksum=b2afe73603921c608ba48969dbb7d743776744bfe5d8059ece241137b7f88e21
 
 pre_check() {
 	# gst_gstdatetime is known to fail according to LFS
diff --git a/srcpkgs/mlt7/template b/srcpkgs/mlt7/template
index 9fb7f60d692e..cca0eb68cfc3 100644
--- a/srcpkgs/mlt7/template
+++ b/srcpkgs/mlt7/template
@@ -1,7 +1,7 @@
 # Template file for 'mlt7'
 pkgname=mlt7
 version=7.14.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSWIG_PYTHON=ON"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which

From 7f6bdf08a22d2376ef383ad60e03bc739edcd797 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 7 May 2023 20:15:03 -0400
Subject: [PATCH 106/115] qt6-webengine: revbump for ffmpeg-6.0

---
 srcpkgs/qt6-webengine/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-webengine/template b/srcpkgs/qt6-webengine/template
index 4e22cb6e8863..f948dc919a15 100644
--- a/srcpkgs/qt6-webengine/template
+++ b/srcpkgs/qt6-webengine/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-webengine'
 pkgname=qt6-webengine
 version=6.5.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="
  -DQT_FEATURE_webengine_system_ffmpeg=ON

From 9aa822b9619141796a4558d4bf1b841ff41900af Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 7 May 2023 20:15:29 -0400
Subject: [PATCH 107/115] tracker-miners: revbump for ffmpeg-6.0

---
 srcpkgs/tracker-miners/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tracker-miners/template b/srcpkgs/tracker-miners/template
index 8c005d697fa4..a6e5aa577702 100644
--- a/srcpkgs/tracker-miners/template
+++ b/srcpkgs/tracker-miners/template
@@ -1,7 +1,7 @@
 # Template file for 'tracker-miners'
 pkgname=tracker-miners
 version=3.5.0
-revision=3
+revision=4
 build_style=meson
 build_helper=qemu
 # missing libgrss for miner_rss

From 71150b608f7508cefc23d4646691fcdaf813f10e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 7 May 2023 20:20:58 -0400
Subject: [PATCH 108/115] mpd: revbump for ffmpeg-6.0

---
 srcpkgs/mpd/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpd/template b/srcpkgs/mpd/template
index 9dbd4c935acc..9f058b62df2f 100644
--- a/srcpkgs/mpd/template
+++ b/srcpkgs/mpd/template
@@ -1,7 +1,7 @@
 # Template file for 'mpd'
 pkgname=mpd
 version=0.23.13
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dopus=enabled -Dmikmod=enabled -Dneighbor=true
  -Dsoundcloud=enabled -Dpipe=true -Dtwolame=enabled -Dbzip2=enabled

From 1758f5d0ab2fdc7b5af7764f61424009062d4eb4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 11 May 2023 14:05:14 -0400
Subject: [PATCH 109/115] openmw: revbump for ffmpeg-6.0

---
 srcpkgs/openmw/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openmw/template b/srcpkgs/openmw/template
index e3771c7aaf1a..3cbf20b06577 100644
--- a/srcpkgs/openmw/template
+++ b/srcpkgs/openmw/template
@@ -1,7 +1,7 @@
 # Template file for 'openmw'
 pkgname=openmw
 version=0.47.0
-revision=5
+revision=6
 build_style=cmake
 _recast_commit=e75adf86f91eb3082220085e42dda62679f9a3ea
 _bullet_tag=3.17

From a899530f9f4a8d2c22fc55684e452705ffb22110 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 11 May 2023 14:05:39 -0400
Subject: [PATCH 110/115] freecad: revbump for qt5-webengine-5.15.13

---
 srcpkgs/freecad/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/freecad/template b/srcpkgs/freecad/template
index e301f32d3540..a4a3f5f76b29 100644
--- a/srcpkgs/freecad/template
+++ b/srcpkgs/freecad/template
@@ -1,7 +1,7 @@
 # Template file for 'freecad'
 pkgname=freecad
 version=0.20.2
-revision=4
+revision=5
 build_style=cmake
 
 _inst_prefix=/usr/lib/${pkgname}

From b6199612dfb724c6e0f1b99af85286fc4dde422d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 21 May 2023 12:44:11 -0400
Subject: [PATCH 111/115] electron24: revbump for ffmpeg-6.0

---
 srcpkgs/electron24/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron24/template b/srcpkgs/electron24/template
index bdaa56adc8a6..ff3d5e3ef381 100644
--- a/srcpkgs/electron24/template
+++ b/srcpkgs/electron24/template
@@ -1,7 +1,7 @@
 # Template file for 'electron24'
 pkgname=electron24
 version=24.3.0
-revision=1
+revision=2
 _nodever=18.14.0
 _chromiumver=112.0.5615.165
 archs="x86_64* aarch64*"

From cfc44ad6367aa74d6f5aa0f814072543ecb8d846 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Jun 2023 08:20:22 -0400
Subject: [PATCH 112/115] gtk4: revbump for ffmpeg-6.0

---
 srcpkgs/gtk4/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gtk4/template b/srcpkgs/gtk4/template
index 5fafa50f6f33..5e5523aa4403 100644
--- a/srcpkgs/gtk4/template
+++ b/srcpkgs/gtk4/template
@@ -1,7 +1,7 @@
 # Template file for 'gtk4'
 pkgname=gtk4
 version=4.10.3
-revision=2
+revision=3
 build_style=meson
 build_helper="gir"
 configure_args="-Dman-pages=true -Dgtk_doc=true

From 8ece52cf1e80a6d76927308e2ff8b67f5828d96b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:25:50 -0400
Subject: [PATCH 113/115] electron19: revbump for ffmpeg-6.0

---
 srcpkgs/electron19/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron19/template b/srcpkgs/electron19/template
index 32ce301e730c..ab7f308f5e8a 100644
--- a/srcpkgs/electron19/template
+++ b/srcpkgs/electron19/template
@@ -1,7 +1,7 @@
 # Template file for 'electron19'
 pkgname=electron19
 version=19.0.8
-revision=3
+revision=4
 _nodever=16.14.2
 _chromiumver=102.0.5005.125
 archs="x86_64* aarch64* ppc64le*"

From c8e98294d8bd8e70fb30602b6f956d297f59f839 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:28:26 -0400
Subject: [PATCH 114/115] siril: revbump for ffmpeg-6.0

---
 srcpkgs/siril/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/siril/template b/srcpkgs/siril/template
index 84332f79d060..62750dd24754 100644
--- a/srcpkgs/siril/template
+++ b/srcpkgs/siril/template
@@ -1,7 +1,7 @@
 # Template file for 'siril'
 pkgname=siril
 version=0.9.12
-revision=10
+revision=11
 build_style=gnu-configure
 hostmakedepends="pkg-config intltool autoconf automake gettext-devel"
 makedepends="fftw-devel libconfig-devel libopencv-devel libffms2-devel

From 26fa1298080f0b9cc895dc8fca32e0a9a0382846 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:29:08 -0400
Subject: [PATCH 115/115] telegram-desktop: revbump for ffmpeg-6.0

---
 srcpkgs/telegram-desktop/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/telegram-desktop/template b/srcpkgs/telegram-desktop/template
index f114b2341dc5..9db9f80c1a53 100644
--- a/srcpkgs/telegram-desktop/template
+++ b/srcpkgs/telegram-desktop/template
@@ -1,7 +1,7 @@
 # Template file for 'telegram-desktop'
 pkgname=telegram-desktop
 version=4.8.1
-revision=3
+revision=4
 build_style=cmake
 build_helper="qemu"
 configure_args="-DTDESKTOP_API_ID=209235

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (8 preceding siblings ...)
  2023-06-04 15:47 ` zlice
@ 2023-06-10  5:04 ` zlice
  2023-06-17 19:17 ` zlice
                   ` (87 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2023-06-10  5:04 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 3480 bytes --]

There is an updated pull request by zlice against master on the void-packages repository

https://github.com/zlice/void-packages ffmpeg6-split
https://github.com/void-linux/void-packages/pull/43761

ffmpeg6 split
[ci skip]


#### Testing the changes

- I tested the changes in this PR: **YES**

main testing has been vaapi in Firefox Nightly and enc/dec in Shotcut on Intel A770

#### New package

- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**

#### Local build testing

- I built this PR locally for my native architecture, **x86_64**

#### Discussion

Continuation of https://github.com/void-linux/void-packages/pull/36315

`libavresample` is deprecated, but marked as a dependency when trying to build other packages and install `ffmpeg`(6). I think the right way to handle this is make a meta package and the add to removals?


##### Commit naming / misc

~~Commits are 'dirty' right now, running with [gstreamer 1.22.1 updates](https://github.com/void-linux/void-packages/pull/42861) and [Intel OpenCL](https://github.com/void-linux/void-packages/pull/43084). This will also make [intel packages pr](https://github.com/void-linux/void-packages/pull/41132) obsolete.~~ (see Requirements below)

Maintainer for previous ffmpeg(4) was orphaned, I can put my name in there if that matters, though I don't exactly see myself keeping up on ffmpeg.

This updates QT5 which looks like it is usually hosted by Johnny. Not sure if there's any reason to stay there or these sources are fine.

##### STILL FFMPEG4

These are a mix of emulators, games and/or older packages.

- attract (multiple patches in master)
- audacity (https://github.com/audacity/audacity/issues/2305 and https://sourceforge.net/p/portmedia/wiki/portsmf/ is 'beta')
- ccextractor (master patches? no release)
- vice
- kodi
- mlt (only dep left is flowblade)
- ~~synfig (mlt)~~ (work with mlt7, bump synfigstudio)
- tvheadend
- ssr
- spek-alternative
- ppsspp
- olive
- moc
- mediastreamer
- libextractor
- idjc
- hedgewars
- ~~ffmpegthumbnailer~~ (patches for moviedecoder.xxx files)
- ~~ffmpegthumbs~~ (latest compiles)
- deadbeef
- omxplayer
- qtav (fork has ffmpeg 5 patch - https://github.com/cmguo/QtAV)
- `vlc` (vlc4 will support ffmpeg5, there's a patch to build 3.x with ffmpeg5 but it will lack vaapi)
- `osg` (OpenSceneGraph plus `xine-lib`)


##### HAVE NOT BUILT YET

- omxplayer (rpi only? ffmpeg4)
- kodi (big, but ffmpeg4)


##### UPDATED (for ffmpeg6)

- ~~blender: update to 3.5.1~~ ~~will be revbump with~~ https://github.com/void-linux/void-packages/pull/43992
- unpaper: update to 7.0.0.
- guvcview: update to 2.0.8.
- qt5: update to 5.15.8
- qt5-webengine: update to 5.18.13
- shiboken2: revbump for qt5.15.8 (patch)
- python3-pyside2: update to 5.15.8 (patch)


##### Requirements

- [gstreamer 1.22.2](https://github.com/void-linux/void-packages/pull/42861) - a few packages use ffmpeg-devel and require a revbump

- [Intel Packages](https://github.com/void-linux/void-packages/pull/41132) - ffmpeg4 uses different libraries than 6 (libmfx / Intel-MediaSDK vs only oneVPL that Intel is moving to), both are included here

- [shotcut 23.05.14](https://github.com/void-linux/void-packages/pull/44260)

A patch file from https://github.com/void-linux/void-packages/pull/43761.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ffmpeg6-split-43761.patch --]
[-- Type: text/x-diff, Size: 787730 bytes --]

From e807f0f98de85d51a95303a3821977224574cd05 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:55:46 -0400
Subject: [PATCH 001/115] ffmpeg: update to 6.0.

---
 common/shlibs                                 | 26 +++++---
 srcpkgs/ffmpeg/files/altivec.patch            | 60 -------------------
 .../patches/armv5tel-floating-point.patch     | 18 ------
 .../workaround-mesa-readeon-vaapi-bug.patch   | 28 ---------
 srcpkgs/ffmpeg/template                       | 38 +++++-------
 5 files changed, 32 insertions(+), 138 deletions(-)
 delete mode 100644 srcpkgs/ffmpeg/files/altivec.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch

diff --git a/common/shlibs b/common/shlibs
index 0b1bca75e5d6..e0beebc157c7 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -390,15 +390,23 @@ libid3tag.so.0 libid3tag-0.15.1b_1
 libgif.so.7 giflib-5.1.0_1
 libImlib2.so.1 imlib2-1.4.2_1
 libmp3lame.so.0 lame-3.98.2_1
-libavdevice.so.58 libavdevice-4.0_1
-libavformat.so.58 libavformat-4.0_1
-libswscale.so.5 libswscale-4.0_1
-libswresample.so.3 libswresample-4.0_1
-libavresample.so.4 libavresample-4.0_1
-libpostproc.so.55 libpostproc-4.0_1
-libavcodec.so.58 libavcodec-4.0_1
-libavutil.so.56 libavutil-4.0_1
-libavfilter.so.7 libavfilter-4.0_1
+libavdevice.so.60 libavdevice-6.0_1
+libavformat.so.60 libavformat-6.0_1
+libswscale.so.7 libswscale-6.0_1
+libswresample.so.4 libswresample-6.0_1
+libpostproc.so.57 libpostproc-6.0_1
+libavcodec.so.60 libavcodec-6.0_1
+libavutil.so.58 libavutil-6.0_1
+libavfilter.so.9 libavfilter-6.0_1
+libavdevice.so.58 libavdevice4-4.0_1
+libavformat.so.58 libavformat4-4.0_1
+libswscale.so.5 libswscale4-4.0_1
+libswresample.so.3 libswresample4-4.0_1
+libavresample.so.4 libavresample4-4.0_1
+libpostproc.so.55 libpostproc4-4.0_1
+libavcodec.so.58 libavcodec4-4.0_1
+libavutil.so.56 libavutil4-4.0_1
+libavfilter.so.7 libavfilter4-4.0_1
 libSDL-1.2.so.0 SDL-1.2.14_1
 libSDL_image-1.2.so.0 SDL_image-1.2.10_1
 libx264.so.157 x264-20190507.2245_1
diff --git a/srcpkgs/ffmpeg/files/altivec.patch b/srcpkgs/ffmpeg/files/altivec.patch
deleted file mode 100644
index 9c5720046332..000000000000
--- a/srcpkgs/ffmpeg/files/altivec.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-revert some altivec specific change on all ppc* except ppc64le*
-
-q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
-conditionally, for ppc* but not ppc64le* (the new code is valid for
-POWER8 VSX which LE targets as a baseline but not BE)"
-
-
-This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
----
- libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
- 1 file changed, 20 insertions(+), 4 deletions(-)
-
-diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
-index 536545293d..c1e2852adb 100644
---- a/libswscale/ppc/yuv2rgb_altivec.c
-+++ b/libswscale/ppc/yuv2rgb_altivec.c
-@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-     vector signed short R1, G1, B1;                                           \
-     vector unsigned char R, G, B;                                             \
-                                                                               \
-+    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
-+    vector unsigned char align_perm;                                          \
-+                                                                              \
-     vector signed short lCY       = c->CY;                                    \
-     vector signed short lOY       = c->OY;                                    \
-     vector signed short lCRV      = c->CRV;                                   \
-@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
-                                                                               \
-         for (j = 0; j < w / 16; j++) {                                        \
--            y0 = vec_xl(0, y1i);                                              \
-+            y1ivP = (const vector unsigned char *) y1i;                       \
-+            y2ivP = (const vector unsigned char *) y2i;                       \
-+            uivP  = (const vector unsigned char *) ui;                        \
-+            vivP  = (const vector unsigned char *) vi;                        \
-+                                                                              \
-+            align_perm = vec_lvsl(0, y1i);                                    \
-+            y0 = (vector unsigned char)                                       \
-+                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
-                                                                               \
--            y1 = vec_xl(0, y2i);                                              \
-+            align_perm = vec_lvsl(0, y2i);                                    \
-+            y1 = (vector unsigned char)                                       \
-+                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
-                                                                               \
--            u = (vector signed char) vec_xl(0, ui);                           \
-+            align_perm = vec_lvsl(0, ui);                                     \
-+            u = (vector signed char)                                          \
-+                    vec_perm(uivP[0], uivP[1], align_perm);                   \
-                                                                               \
--            v = (vector signed char) vec_xl(0, vi);                           \
-+            align_perm = vec_lvsl(0, vi);                                     \
-+            v = (vector signed char)                                          \
-+                    vec_perm(vivP[0], vivP[1], align_perm);                   \
-                                                                               \
-             u = (vector signed char)                                          \
-                     vec_sub(u,                                                \
--- 
-2.27.0
-
diff --git a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
deleted file mode 100644
index 9a55178c74f0..000000000000
--- a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
-+++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
-@@ -39,6 +39,15 @@
- #endif
- #include <fenv.h>
- 
-+#if (FE_ALL_EXCEPT == 0)
-+/* E.g. ARM soft float does not define these */
-+#define FE_INVALID    0
-+#define FE_DIVBYZERO  0
-+#define FE_OVERFLOW   0
-+#define FE_UNDERFLOW  0
-+#define FE_INEXACT    0
-+#endif
-+
- #if CONFIG_LIBFONTCONFIG
- #include <fontconfig/fontconfig.h>
- #endif
diff --git a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
deleted file mode 100644
index 00e3f68a415b..000000000000
--- a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
-From: Rainer Hochecker <fernetmenta@online.de>
-Date: Sat, 26 Jan 2019 19:48:35 +0100
-Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
-
-This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
-It was hit frequently when watching h264 channels received via DVB-X.
-Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
----
- libavcodec/vaapi_h264.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
-index 5854587a255..f12fdc457a4 100644
---- a/libavcodec/vaapi_h264.c
-+++ b/libavcodec/vaapi_h264.c
-@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
-     H264SliceContext *sl = &h->slice_ctx[0];
-     int ret;
- 
-+    if (pic->nb_slices == 0) {
-+        ret = AVERROR_INVALIDDATA;
-+        goto finish;
-+    }
-+
-     ret = ff_vaapi_decode_issue(avctx, pic);
-     if (ret < 0)
-         goto finish;
diff --git a/srcpkgs/ffmpeg/template b/srcpkgs/ffmpeg/template
index df4179d1963a..f742082bb520 100644
--- a/srcpkgs/ffmpeg/template
+++ b/srcpkgs/ffmpeg/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpeg'
 # audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
 pkgname=ffmpeg
-version=4.4.4
+version=6.0
 revision=1
 short_desc="Decoding, encoding and streaming software"
 maintainer="Orphaned <orphan@voidlinux.org>"
@@ -9,7 +9,7 @@ license="GPL-3.0-or-later"
 homepage="https://www.ffmpeg.org"
 changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
 distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
-checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+checksum=57be87c22d9b49c112b6d24bc67d42508660e6b718b3db89c44e47e289137082
 
 hostmakedepends="pkg-config perl"
 makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
@@ -26,12 +26,13 @@ makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-deve
  $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
  $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
  $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
- $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers Vulkan-Tools Vulkan-ValidationLayers')
+ $(vopt_if onevpl 'onevpl onevpl-devel')
  $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
 depends="ffplay>=${version}_${revision}"
 
 build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
- dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec onevpl"
 build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
 desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
 desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
@@ -39,10 +40,8 @@ desc_option_sofa="Enable support for AES SOFA"
 desc_option_webp="Enable support for WebP"
 
 case "$XBPS_TARGET_MACHINE" in
-	i686*|x86_64*)
-		hostmakedepends+=" nasm"
-		build_options_default+=" vaapi vdpau nvenc nvdec"
-		;;
+	i686*) build_options_default+=" vaapi vdpau nvenc nvdec";;
+	x86_64*) build_options_default+=" vaapi vdpau nvenc nvdec onevpl";;
 	ppc64*) build_options_default+=" vaapi vdpau";;
 	mips*) CFLAGS="-mnan=legacy";;
 esac
@@ -117,18 +116,19 @@ do_configure() {
 		$(vopt_enable x265 libx265) \
 		$(vopt_enable v4l2 libv4l2) \
 		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
-		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		--enable-libbs2b --enable-libvidstab \
 		$(vopt_enable dav1d libdav1d) \
 		$(vopt_enable zimg libzimg) \
 		$(vopt_enable webp libwebp) \
 		$(vopt_enable sofa libmysofa) \
 		$(vopt_enable vulkan) \
+		$(vopt_enable onevpl libvpl) \
 		$(vopt_enable drm libdrm) \
 		$(vopt_enable svtav1 libsvtav1) \
 		$(vopt_enable srt libsrt) \
 		$(vopt_enable rist librist) \
-		$(vopt_if nvenc '--enable-nvenc') \
-		$(vopt_if nvdec '--enable-nvdec')
+		$(vopt_enable nvenc nvenc) \
+		$(vopt_enable nvdec nvdec)
 }
 
 do_build() {
@@ -155,10 +155,8 @@ libavdevice_package() {
 }
 
 libavresample_package() {
-	short_desc="FFmpeg audio resampling library"
-	pkg_install() {
-		vmove "usr/lib/libavresample.so.*"
-	}
+	short_desc="Package deprecated, removal needed"
+	build_style=meta
 }
 
 libavformat_package() {
@@ -212,15 +210,9 @@ ffmpeg-devel_package() {
 		libavfilter>=${version}_${revision}
 		libpostproc>=${version}_${revision}
 		libswscale>=${version}_${revision}
-		libswresample>=${version}_${revision}
-		libavresample>=${version}_${revision}"
+		libswresample>=${version}_${revision}"
 	short_desc+=" - development files"
-
-	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
-		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
-		nostrip_files="/usr/lib/libavfilter.a"
-	fi
-
+	conflicts="ffmpeg4-devel"
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig

From bd5bedae0da7e9357a6be3fdab715cc89a01b120 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:56:22 -0400
Subject: [PATCH 002/115] New package: ffmpeg4-4.4.4.

---
 srcpkgs/ffmpeg4-devel                         |   1 +
 srcpkgs/ffmpeg4/files/altivec.patch           |  60 +++++
 .../patches/armv5tel-floating-point.patch     |  18 ++
 .../workaround-mesa-readeon-vaapi-bug.patch   |  28 +++
 srcpkgs/ffmpeg4/template                      | 238 ++++++++++++++++++
 srcpkgs/libavcodec4                           |   1 +
 srcpkgs/libavdevice4                          |   1 +
 srcpkgs/libavfilter4                          |   1 +
 srcpkgs/libavformat4                          |   1 +
 srcpkgs/libavresample4                        |   1 +
 srcpkgs/libavutil4                            |   1 +
 srcpkgs/libpostproc4                          |   1 +
 srcpkgs/libswresample4                        |   1 +
 srcpkgs/libswscale4                           |   1 +
 14 files changed, 354 insertions(+)
 create mode 120000 srcpkgs/ffmpeg4-devel
 create mode 100644 srcpkgs/ffmpeg4/files/altivec.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
 create mode 100644 srcpkgs/ffmpeg4/template
 create mode 120000 srcpkgs/libavcodec4
 create mode 120000 srcpkgs/libavdevice4
 create mode 120000 srcpkgs/libavfilter4
 create mode 120000 srcpkgs/libavformat4
 create mode 120000 srcpkgs/libavresample4
 create mode 120000 srcpkgs/libavutil4
 create mode 120000 srcpkgs/libpostproc4
 create mode 120000 srcpkgs/libswresample4
 create mode 120000 srcpkgs/libswscale4

diff --git a/srcpkgs/ffmpeg4-devel b/srcpkgs/ffmpeg4-devel
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/ffmpeg4-devel
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/ffmpeg4/files/altivec.patch b/srcpkgs/ffmpeg4/files/altivec.patch
new file mode 100644
index 000000000000..9c5720046332
--- /dev/null
+++ b/srcpkgs/ffmpeg4/files/altivec.patch
@@ -0,0 +1,60 @@
+revert some altivec specific change on all ppc* except ppc64le*
+
+q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
+conditionally, for ppc* but not ppc64le* (the new code is valid for
+POWER8 VSX which LE targets as a baseline but not BE)"
+
+
+This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
+---
+ libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
+ 1 file changed, 20 insertions(+), 4 deletions(-)
+
+diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
+index 536545293d..c1e2852adb 100644
+--- a/libswscale/ppc/yuv2rgb_altivec.c
++++ b/libswscale/ppc/yuv2rgb_altivec.c
+@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+     vector signed short R1, G1, B1;                                           \
+     vector unsigned char R, G, B;                                             \
+                                                                               \
++    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
++    vector unsigned char align_perm;                                          \
++                                                                              \
+     vector signed short lCY       = c->CY;                                    \
+     vector signed short lOY       = c->OY;                                    \
+     vector signed short lCRV      = c->CRV;                                   \
+@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
+                                                                               \
+         for (j = 0; j < w / 16; j++) {                                        \
+-            y0 = vec_xl(0, y1i);                                              \
++            y1ivP = (const vector unsigned char *) y1i;                       \
++            y2ivP = (const vector unsigned char *) y2i;                       \
++            uivP  = (const vector unsigned char *) ui;                        \
++            vivP  = (const vector unsigned char *) vi;                        \
++                                                                              \
++            align_perm = vec_lvsl(0, y1i);                                    \
++            y0 = (vector unsigned char)                                       \
++                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
+                                                                               \
+-            y1 = vec_xl(0, y2i);                                              \
++            align_perm = vec_lvsl(0, y2i);                                    \
++            y1 = (vector unsigned char)                                       \
++                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
+                                                                               \
+-            u = (vector signed char) vec_xl(0, ui);                           \
++            align_perm = vec_lvsl(0, ui);                                     \
++            u = (vector signed char)                                          \
++                    vec_perm(uivP[0], uivP[1], align_perm);                   \
+                                                                               \
+-            v = (vector signed char) vec_xl(0, vi);                           \
++            align_perm = vec_lvsl(0, vi);                                     \
++            v = (vector signed char)                                          \
++                    vec_perm(vivP[0], vivP[1], align_perm);                   \
+                                                                               \
+             u = (vector signed char)                                          \
+                     vec_sub(u,                                                \
+-- 
+2.27.0
+
diff --git a/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
new file mode 100644
index 000000000000..9a55178c74f0
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
@@ -0,0 +1,18 @@
+--- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
++++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
+@@ -39,6 +39,15 @@
+ #endif
+ #include <fenv.h>
+ 
++#if (FE_ALL_EXCEPT == 0)
++/* E.g. ARM soft float does not define these */
++#define FE_INVALID    0
++#define FE_DIVBYZERO  0
++#define FE_OVERFLOW   0
++#define FE_UNDERFLOW  0
++#define FE_INEXACT    0
++#endif
++
+ #if CONFIG_LIBFONTCONFIG
+ #include <fontconfig/fontconfig.h>
+ #endif
diff --git a/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
new file mode 100644
index 000000000000..00e3f68a415b
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
@@ -0,0 +1,28 @@
+From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
+From: Rainer Hochecker <fernetmenta@online.de>
+Date: Sat, 26 Jan 2019 19:48:35 +0100
+Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
+
+This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
+It was hit frequently when watching h264 channels received via DVB-X.
+Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
+---
+ libavcodec/vaapi_h264.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
+index 5854587a255..f12fdc457a4 100644
+--- a/libavcodec/vaapi_h264.c
++++ b/libavcodec/vaapi_h264.c
+@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
+     H264SliceContext *sl = &h->slice_ctx[0];
+     int ret;
+ 
++    if (pic->nb_slices == 0) {
++        ret = AVERROR_INVALIDDATA;
++        goto finish;
++    }
++
+     ret = ff_vaapi_decode_issue(avctx, pic);
+     if (ret < 0)
+         goto finish;
diff --git a/srcpkgs/ffmpeg4/template b/srcpkgs/ffmpeg4/template
new file mode 100644
index 000000000000..5228c7df08fb
--- /dev/null
+++ b/srcpkgs/ffmpeg4/template
@@ -0,0 +1,238 @@
+# Template file for 'ffmpeg4'
+# audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
+pkgname=ffmpeg4
+version=4.4.4
+revision=1
+short_desc="Decoding, encoding and streaming software - ffmpeg4 libraries only"
+maintainer="Orphaned <orphan@voidlinux.org>"
+license="GPL-3.0-or-later"
+homepage="https://www.ffmpeg.org"
+changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
+distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
+checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+
+hostmakedepends="pkg-config perl"
+makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
+ libXext-devel libXvMC-devel libxcb-devel lame-devel libtheora-devel
+ libvorbis-devel x264-devel xvidcore-devel jack-devel SDL2-devel
+ libcdio-paranoia-devel librtmp-devel libmodplug-devel gnutls-devel
+ speex-devel celt-devel harfbuzz-devel libass-devel opus-devel ocl-icd-devel
+ libbs2b-devel libvidstab-devel $(vopt_if pulseaudio pulseaudio-devel)
+ $(vopt_if vaapi libva-devel) $(vopt_if vdpau libvdpau-devel)
+ $(vopt_if x265 x265-devel) $(vopt_if v4l2 v4l-utils-devel)
+ $(vopt_if fdk_aac fdk-aac-devel) $(vopt_if vpx libvpx-devel)
+ $(vopt_if aom libaom-devel) $(vopt_if sndio sndio-devel)
+ $(vopt_if dav1d libdav1d-devel) $(vopt_if zimg zimg-devel)
+ $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
+ $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
+ $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if mfx 'libmfx libmfx-devel')
+ $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
+
+build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec mfx"
+build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
+
+desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
+desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
+desc_option_sofa="Enable support for AES SOFA"
+desc_option_webp="Enable support for WebP"
+
+case "$XBPS_TARGET_MACHINE" in
+	i686*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau nvenc nvdec"
+			;;
+	x86_64*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau mfx nvenc nvdec"
+			;;
+	ppc64*) build_options_default+=" vaapi vdpau";;
+	mips*) CFLAGS="-mnan=legacy";;
+esac
+
+if [ "$XBPS_TARGET_WORDSIZE" != "32" ]; then
+	build_options_default+=" svtav1"
+fi
+
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+fi
+
+_apply_patch() {
+	local args="$1" pname="$(basename $2)"
+
+	if [ ! -f ".${pname}_done" ]; then
+		patch -N $args -i $2
+		touch .${pname}_done
+	fi
+}
+
+post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64le*) ;;
+		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
+	esac
+}
+
+do_configure() {
+	# Fix gcc on x86_64-musl only
+	if [ "$XBPS_TARGET_MACHINE" = "x86_64-musl" ]; then
+		vsed -i configure -e "s;_cflags_speed='-O3';_cflags_speed='-O2';"
+	fi
+
+	if [ "$CROSS_BUILD" ]; then
+		case "$XBPS_TARGET_MACHINE" in
+			arm*) _arch="arm";;
+			aarch64*) _arch="aarch64";;
+			mips*) _arch="mips";;
+			ppc64*) _arch="ppc64";;
+			ppc*) _arch="ppc";;
+			*) _arch="${XBPS_TARGET_MACHINE%%-musl}";;
+		esac
+
+		_args+=" --enable-cross-compile
+			--sysroot=$XBPS_CROSS_BASE
+			--cross-prefix=${XBPS_CROSS_TRIPLET}-
+			--target-os=linux --arch=${_arch}"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc|ppc-musl) _args+=" --disable-altivec";;
+	esac
+
+	if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+		_args+=" --extra-libs=-latomic"
+	fi
+
+	./configure --prefix=/usr --disable-debug --enable-gpl --enable-gnutls \
+		--disable-stripping \
+		--enable-libcdio --enable-version3 --enable-runtime-cpudetect \
+		--enable-libmp3lame --enable-libvorbis --enable-libxvid \
+		--enable-libx264 $(vopt_enable vpx libvpx) --enable-libtheora \
+		--enable-shared --enable-static --enable-libxcb \
+		$(vopt_enable pulseaudio libpulse) --enable-libfreetype --enable-libmodplug \
+		--enable-libspeex --enable-libcelt --enable-libass \
+		--enable-libopus --enable-librtmp --enable-libjack \
+		$(vopt_if fdk_aac '--enable-nonfree --enable-libfdk-aac') \
+		--disable-libopencore_amrnb --disable-libopencore_amrwb \
+		--disable-libopenjpeg \
+		--enable-postproc --enable-opencl ${_args} \
+		$(vopt_enable x265 libx265) \
+		$(vopt_enable v4l2 libv4l2) \
+		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
+		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		$(vopt_enable dav1d libdav1d) \
+		$(vopt_enable zimg libzimg) \
+		$(vopt_enable webp libwebp) \
+		$(vopt_enable sofa libmysofa) \
+		$(vopt_enable vulkan) \
+		$(vopt_enable drm libdrm) \
+		$(vopt_enable svtav1 libsvtav1) \
+		$(vopt_enable srt libsrt) \
+		$(vopt_enable rist librist) \
+		$(vopt_enable mfx libmfx) \
+		$(vopt_if nvenc '--enable-nvenc') \
+		$(vopt_if nvdec '--enable-nvdec')
+}
+
+do_build() {
+	make ${makejobs}
+	make doc/ff{mpeg,play}.1
+}
+
+do_install() {
+	make DESTDIR=${DESTDIR} install install-man
+	rm -rf ${DESTDIR}/usr/bin
+}
+
+libavcodec4_package() {
+	short_desc="FFmpeg codec library"
+	pkg_install() {
+		vmove "usr/lib/libavcodec.so.*"
+	}
+}
+
+libavdevice4_package() {
+	short_desc="FFmpeg device handling library"
+	pkg_install() {
+		vmove "usr/lib/libavdevice.so.*"
+	}
+}
+
+libavresample4_package() {
+	short_desc="FFmpeg audio resampling library"
+	pkg_install() {
+		vmove "usr/lib/libavresample.so.*"
+	}
+}
+
+libavformat4_package() {
+	short_desc="FFmpeg file format library"
+	pkg_install() {
+		vmove "usr/lib/libavformat.so.*"
+	}
+}
+
+libavutil4_package() {
+	short_desc="FFmpeg utility library"
+	pkg_install() {
+		vmove "usr/lib/libavutil.so.*"
+	}
+}
+
+libavfilter4_package() {
+	short_desc="FFmpeg audio/video filter library"
+	pkg_install() {
+		vmove "usr/lib/libavfilter.so.*"
+	}
+}
+
+libpostproc4_package() {
+	short_desc="FFmpeg video postprocessing library"
+	pkg_install() {
+		vmove "usr/lib/libpostproc.so.*"
+	}
+}
+
+libswscale4_package() {
+	short_desc="FFmpeg video scaling library"
+	pkg_install() {
+		vmove "usr/lib/libswscale.so.*"
+	}
+}
+
+libswresample4_package() {
+	short_desc="FFmpeg video resampling library"
+	pkg_install() {
+		vmove "usr/lib/libswresample.so.*"
+	}
+}
+
+ffmpeg4-devel_package() {
+	depends="
+		libavcodec4>=${version}_${revision}
+		libavdevice4>=${version}_${revision}
+		libavformat4>=${version}_${revision}
+		libavutil4>=${version}_${revision}
+		libavfilter4>=${version}_${revision}
+		libpostproc4>=${version}_${revision}
+		libswscale4>=${version}_${revision}
+		libswresample4>=${version}_${revision}
+		libavresample4>=${version}_${revision}"
+	short_desc+=" - development files"
+	conflicts="ffmpeg-devel"
+	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
+		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
+		nostrip_files="/usr/lib/libavfilter.a"
+	fi
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.a"
+		vmove "usr/lib/*.so"
+		vmove usr/share/ffmpeg/examples
+		vmove usr/share/man/man3
+	}
+}
diff --git a/srcpkgs/libavcodec4 b/srcpkgs/libavcodec4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavcodec4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavdevice4 b/srcpkgs/libavdevice4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavdevice4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavfilter4 b/srcpkgs/libavfilter4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavfilter4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavformat4 b/srcpkgs/libavformat4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavformat4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavresample4 b/srcpkgs/libavresample4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavutil4 b/srcpkgs/libavutil4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavutil4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libpostproc4 b/srcpkgs/libpostproc4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libpostproc4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswresample4 b/srcpkgs/libswresample4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libswresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswscale4 b/srcpkgs/libswscale4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libswscale4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file

From 95281767b50c1f944bbebee01e938e1fa14901aa Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:04 -0400
Subject: [PATCH 003/115] opencv: update to 4.7.0.

---
 common/shlibs           | 104 ++++++++++++++++++++--------------------
 srcpkgs/opencv/template |   8 ++--
 2 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index e0beebc157c7..2888a24dd1c4 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2138,58 +2138,58 @@ libcapstone.so.4 capstone-4.0_1
 libhavege.so.2 libhaveged-1.9.11_1
 libnih.so.1 libnih-1.0.3_1
 libnih-dbus.so.1 libnih-1.0.3_1
-libopencv_quality.so.406 libopencv-4.6.0_1
-libopencv_reg.so.406 libopencv-4.6.0_1
-libopencv_surface_matching.so.406 libopencv-4.6.0_1
-libopencv_xphoto.so.406 libopencv-4.6.0_1
-libopencv_freetype.so.406 libopencv-4.6.0_1
-libopencv_fuzzy.so.406 libopencv-4.6.0_1
-libopencv_hfs.so.406 libopencv-4.6.0_1
-libopencv_img_hash.so.406 libopencv-4.6.0_1
-libopencv_line_descriptor.so.406 libopencv-4.6.0_1
-libopencv_saliency.so.406 libopencv-4.6.0_1
-libopencv_structured_light.so.406 libopencv-4.6.0_1
-libopencv_aruco.so.406 libopencv-4.6.0_1
-libopencv_bgsegm.so.406 libopencv-4.6.0_1
-libopencv_bioinspired.so.406 libopencv-4.6.0_1
-libopencv_ccalib.so.406 libopencv-4.6.0_1
-libopencv_face.so.406 libopencv-4.6.0_1
-libopencv_tracking.so.406 libopencv-4.6.0_1
-libopencv_xfeatures2d.so.406 libopencv-4.6.0_1
-libopencv_optflow.so.406 libopencv-4.6.0_1
-libopencv_ximgproc.so.406 libopencv-4.6.0_1
-libopencv_plot.so.406 libopencv-4.6.0_1
-libopencv_text.so.406 libopencv-4.6.0_1
-libopencv_ml.so.406 libopencv-4.6.0_1
-libopencv_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn.so.406 libopencv-4.6.0_1
-libopencv_shape.so.406 libopencv-4.6.0_1
-libopencv_stitching.so.406 libopencv-4.6.0_1
-libopencv_photo.so.406 libopencv-4.6.0_1
-libopencv_video.so.406 libopencv-4.6.0_1
-libopencv_calib3d.so.406 libopencv-4.6.0_1
-libopencv_features2d.so.406 libopencv-4.6.0_1
-libopencv_flann.so.406 libopencv-4.6.0_1
-libopencv_highgui.so.406 libopencv-4.6.0_1
-libopencv_videoio.so.406 libopencv-4.6.0_1
-libopencv_imgcodecs.so.406 libopencv-4.6.0_1
-libopencv_imgproc.so.406 libopencv-4.6.0_1
-libopencv_core.so.406 libopencv-4.6.0_1
-libopencv_superres.so.406 libopencv-4.6.0_1
-libopencv_videostab.so.406 libopencv-4.6.0_1
-libopencv_gapi.so.406 libopencv-4.6.0_1
-libopencv_xobjdetect.so.406 libopencv-4.6.0_1
-libopencv_datasets.so.406 libopencv-4.6.0_1
-libopencv_dnn_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn_superres.so.406 libopencv-4.6.0_1
-libopencv_dpm.so.406 libopencv-4.6.0_1
-libopencv_phase_unwrapping.so.406 libopencv-4.6.0_1
-libopencv_stereo.so.406 libopencv-4.6.0_1
-libopencv_rapid.so.406 libopencv-4.6.0_1
-libopencv_intensity_transform.so.406 libopencv-4.6.0_1
-libopencv_alphamat.so.406 libopencv-4.6.0_1
-libopencv_barcode.so.406 libopencv-4.6.0_1
-libopencv_mcc.so.406 libopencv-4.6.0_1
+libopencv_quality.so.407 libopencv-4.7.0_1
+libopencv_reg.so.407 libopencv-4.7.0_1
+libopencv_surface_matching.so.407 libopencv-4.7.0_1
+libopencv_xphoto.so.407 libopencv-4.7.0_1
+libopencv_freetype.so.407 libopencv-4.7.0_1
+libopencv_fuzzy.so.407 libopencv-4.7.0_1
+libopencv_hfs.so.407 libopencv-4.7.0_1
+libopencv_img_hash.so.407 libopencv-4.7.0_1
+libopencv_line_descriptor.so.407 libopencv-4.7.0_1
+libopencv_saliency.so.407 libopencv-4.7.0_1
+libopencv_structured_light.so.407 libopencv-4.7.0_1
+libopencv_aruco.so.407 libopencv-4.7.0_1
+libopencv_bgsegm.so.407 libopencv-4.7.0_1
+libopencv_bioinspired.so.407 libopencv-4.7.0_1
+libopencv_ccalib.so.407 libopencv-4.7.0_1
+libopencv_face.so.407 libopencv-4.7.0_1
+libopencv_tracking.so.407 libopencv-4.7.0_1
+libopencv_xfeatures2d.so.407 libopencv-4.7.0_1
+libopencv_optflow.so.407 libopencv-4.7.0_1
+libopencv_ximgproc.so.407 libopencv-4.7.0_1
+libopencv_plot.so.407 libopencv-4.7.0_1
+libopencv_text.so.407 libopencv-4.7.0_1
+libopencv_ml.so.407 libopencv-4.7.0_1
+libopencv_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn.so.407 libopencv-4.7.0_1
+libopencv_shape.so.407 libopencv-4.7.0_1
+libopencv_stitching.so.407 libopencv-4.7.0_1
+libopencv_photo.so.407 libopencv-4.7.0_1
+libopencv_video.so.407 libopencv-4.7.0_1
+libopencv_calib3d.so.407 libopencv-4.7.0_1
+libopencv_features2d.so.407 libopencv-4.7.0_1
+libopencv_flann.so.407 libopencv-4.7.0_1
+libopencv_highgui.so.407 libopencv-4.7.0_1
+libopencv_videoio.so.407 libopencv-4.7.0_1
+libopencv_imgcodecs.so.407 libopencv-4.7.0_1
+libopencv_imgproc.so.407 libopencv-4.7.0_1
+libopencv_core.so.407 libopencv-4.7.0_1
+libopencv_superres.so.407 libopencv-4.7.0_1
+libopencv_videostab.so.407 libopencv-4.7.0_1
+libopencv_gapi.so.407 libopencv-4.7.0_1
+libopencv_xobjdetect.so.407 libopencv-4.7.0_1
+libopencv_datasets.so.407 libopencv-4.7.0_1
+libopencv_dnn_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn_superres.so.407 libopencv-4.7.0_1
+libopencv_dpm.so.407 libopencv-4.7.0_1
+libopencv_phase_unwrapping.so.407 libopencv-4.7.0_1
+libopencv_stereo.so.407 libopencv-4.7.0_1
+libopencv_rapid.so.407 libopencv-4.7.0_1
+libopencv_intensity_transform.so.407 libopencv-4.7.0_1
+libopencv_alphamat.so.407 libopencv-4.7.0_1
+libopencv_barcode.so.407 libopencv-4.7.0_1
+libopencv_mcc.so.407 libopencv-4.7.0_1
 libuniconf.so.4.6 wvstreams-4.6.1_20
 libwvbase.so.4.6 wvstreams-4.6.1_20
 libwvutils.so.4.6 wvstreams-4.6.1_20
diff --git a/srcpkgs/opencv/template b/srcpkgs/opencv/template
index 69c635b1ad2b..41f3183f1582 100644
--- a/srcpkgs/opencv/template
+++ b/srcpkgs/opencv/template
@@ -1,7 +1,7 @@
 # Template file for 'opencv'
 pkgname=opencv
-version=4.6.0
-revision=4
+version=4.7.0
+revision=1
 create_wrksrc=yes
 build_wrksrc=${pkgname}-${version}
 build_style=cmake
@@ -24,8 +24,8 @@ homepage="https://opencv.org"
 changelog="https://github.com/opencv/opencv/wiki/ChangeLog"
 distfiles="https://github.com/opencv/opencv/archive/${version}.tar.gz
  https://github.com/opencv/opencv_contrib/archive/${version}.tar.gz>contrib.tar.gz"
-checksum="1ec1cba65f9f20fe5a41fda1586e01c70ea0c9a6d7b67c9e13edf0cfe2239277
- 1777d5fd2b59029cf537e5fd6f8aa68d707075822f90bde683fcde086f85f7a7"
+checksum="8df0079cdbe179748a18d44731af62a245a45ebf5085223dc03133954c662973
+ 42df840cf9055e59d0e22c249cfb19f04743e1bdad113d31b1573d3934d62584"
 patch_args="-Np1 -d ${build_wrksrc}"
 # tests hang indenfinitely, even with test data included
 make_check=no

From c8d7b7125c5ce868420e40e1e9d34429e607da17 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 004/115] actiona: revbump for opencv-4.7.0

---
 srcpkgs/actiona/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/actiona/template b/srcpkgs/actiona/template
index cf5f0b7a2ae6..0d899311e6df 100644
--- a/srcpkgs/actiona/template
+++ b/srcpkgs/actiona/template
@@ -1,7 +1,7 @@
 # Template file for 'actiona'
 pkgname=actiona
 version=3.10.1
-revision=2
+revision=3
 build_style=qmake
 configure_args="PKGCONFIG_OPENCV=opencv4"
 hostmakedepends="pkg-config qt5-plugin-mysql qt5-qmake qt5-host-tools"

From 6d6623c8c31e3a450c5716713ca43b90ae7f1b88 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 005/115] gmic: revbump for opencv-4.7.0

---
 srcpkgs/gmic/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gmic/template b/srcpkgs/gmic/template
index 24a9c7218fdf..0bb4034d5cc8 100644
--- a/srcpkgs/gmic/template
+++ b/srcpkgs/gmic/template
@@ -1,7 +1,7 @@
 # Template file for 'gmic'
 pkgname=gmic
 version=3.1.6
-revision=3
+revision=4
 _zart_hash=34ebf6cce0bafb98abe57cec83c4a02cd1abeca0
 create_wrksrc=yes
 build_wrksrc="src"

From b9609161add95b37e5a540bcb0bb76cd18caa058 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 006/115] qimgv: revbump for opencv-4.7.0

---
 srcpkgs/qimgv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qimgv/template b/srcpkgs/qimgv/template
index 7eb30db33992..dd341dfe1bfc 100644
--- a/srcpkgs/qimgv/template
+++ b/srcpkgs/qimgv/template
@@ -1,7 +1,7 @@
 # Template file for 'qimgv'
 pkgname=qimgv
 version=1.0.2
-revision=2
+revision=3
 build_style=cmake
 configure_args="$(vopt_if video -DVIDEO_SUPPORT=ON -DVIDEO_SUPPORT=OFF)
  $(vopt_if scale -DOPENCV_SUPPORT=ON -DOPENCV_SUPPORT=OFF)

From 771875f4e921211a1430c03f676e346cf84a5a4f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 007/115] retroshare: revbump for opencv-4.7.0

---
 srcpkgs/retroshare/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroshare/template b/srcpkgs/retroshare/template
index 8a0786c21a08..72023fa98b75 100644
--- a/srcpkgs/retroshare/template
+++ b/srcpkgs/retroshare/template
@@ -1,7 +1,7 @@
 # Template file for 'retroshare'
 pkgname=retroshare
 version=0.6.6
-revision=2
+revision=4
 build_style=qmake
 #XXX broadcast feature requires an ancient udp-discovery-cpp which either needs
 # to be fetched+patched (FTBFS) here or packaged :/

From 822782ef7c9e30db471c4471c6e5a3b023db9b5f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 008/115] waifu2x-converter-cpp: revbump for opencv-4.7.0

---
 srcpkgs/waifu2x-converter-cpp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waifu2x-converter-cpp/template b/srcpkgs/waifu2x-converter-cpp/template
index 8c095d0d7bab..aa52d8c981a8 100644
--- a/srcpkgs/waifu2x-converter-cpp/template
+++ b/srcpkgs/waifu2x-converter-cpp/template
@@ -1,7 +1,7 @@
 # Template file for 'waifu2x-converter-cpp'
 pkgname=waifu2x-converter-cpp
 version=5.2.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DINSTALL_MODELS=ON"
 hostmakedepends="pkg-config"

From b7d2590ac44cf24d140e52ae5e9e088cf0be3db2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:38 -0400
Subject: [PATCH 009/115] vlc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/vlc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/vlc/template b/srcpkgs/vlc/template
index 210762b0a7e2..855ca5238662 100644
--- a/srcpkgs/vlc/template
+++ b/srcpkgs/vlc/template
@@ -1,7 +1,7 @@
 # Template file for 'vlc'
 pkgname=vlc
 version=3.0.18
-revision=3
+revision=4
 build_style=gnu-configure
 configure_args="--disable-gme --disable-libtar --enable-jack
  --enable-live555 --disable-fluidsynth --enable-dvdread
@@ -25,7 +25,7 @@ lib32disabled=yes
 hostmakedepends="automake libtool pkg-config flex gettext libgcrypt-devel
  live555-devel gettext-devel $(vopt_if lua lua52) $(vopt_if chromecast protobuf)"
 makedepends="
- avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg-devel freefont-ttf
+ avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg4-devel freefont-ttf
  gnutls-devel jack-devel liba52-devel libass-devel libbluray-devel
  libcdio-devel libdca-devel libdvbpsi-devel libdvdnav-devel libmad-devel
  libmatroska-devel libmodplug-devel libmpcdec-devel libmpeg2-devel

From f27622aa080be81268bd3b0f8ec2335a0c03a8bd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:55 -0400
Subject: [PATCH 010/115] osg: revbump for ffmpeg4-4.4.3

---
 srcpkgs/osg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/osg/template b/srcpkgs/osg/template
index a9ebbd287933..755793f7e11b 100644
--- a/srcpkgs/osg/template
+++ b/srcpkgs/osg/template
@@ -8,7 +8,7 @@ build_helper="qemu"
 configure_args="-DLIB_POSTFIX="
 hostmakedepends="pkg-config xrandr"
 makedepends="MesaLib-devel gtkglext-devel libcurl-devel giflib-devel librsvg-devel
- jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg-devel xine-lib-devel
+ jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg4-devel xine-lib-devel
  SDL2-devel gst-plugins-base1-devel
  $(vopt_if openexr libopenexr-devel)
  $(vopt_if poppler poppler-glib-devel)

From 017988d4f03657cf878449047e8cece3d69bef76 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:13 -0400
Subject: [PATCH 011/115] xine-lib: revbump for ffmpeg4-4.4.3

---
 srcpkgs/xine-lib/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/xine-lib/template b/srcpkgs/xine-lib/template
index f713eff49b07..ed6194c17d11 100644
--- a/srcpkgs/xine-lib/template
+++ b/srcpkgs/xine-lib/template
@@ -1,6 +1,6 @@
 # Template file for 'xine-lib'
 pkgname=xine-lib
-version=1.2.12
+version=1.2.13
 revision=1
 build_style=gnu-configure
 configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
@@ -8,7 +8,7 @@ configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
 hostmakedepends="automake gettext-devel libtool pkg-config perl"
 makedepends="
  zlib-devel alsa-lib-devel libxcb-devel libSM-devel libXext-devel libXv-devel
- libXvMC-devel liba52-devel libmad-devel ffmpeg-devel pulseaudio-devel
+ libXvMC-devel liba52-devel libmad-devel ffmpeg4-devel pulseaudio-devel
  jack-devel samba-devel libflac-devel libmodplug-devel libmpcdec-devel
  speex-devel libtheora-devel libvorbis-devel libdca-devel faad2-devel
  libcdio-devel libbluray-devel aalib-devel libcaca-devel libXinerama-devel
@@ -19,7 +19,7 @@ license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="http://www.xine-project.org"
 changelog="https://sourceforge.net/projects/xine/files/xine-lib/${version}/README.txt/view"
 distfiles="${SOURCEFORGE_SITE}/xine/${pkgname}-${version}.tar.xz"
-checksum=d606270468e1540c2a89c0d7f5fdf11e17ecc0c2698cc0bcb1065ff26abee098
+checksum=5f10d6d718a4a51c17ed1b32b031d4f9b80b061e8276535b2be31e5ac4b75e6f
 
 case "$XBPS_TARGET_MACHINE" in
 	i686-musl)

From f8edfb75e789c78b6483e10e219797e86d3f0b36 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 012/115] QMPlay2: revbump for ffmpeg-6.0

---
 srcpkgs/QMPlay2/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/QMPlay2/template b/srcpkgs/QMPlay2/template
index 17879a25093d..7c387a57b8bd 100644
--- a/srcpkgs/QMPlay2/template
+++ b/srcpkgs/QMPlay2/template
@@ -1,7 +1,7 @@
 # Template file for 'QMPlay2'
 pkgname=QMPlay2
 version=23.06.04
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools"
 makedepends="alsa-lib-devel ffmpeg-devel libass-devel libcdio-devel libgme-devel

From c3aed4d4734460267e1f7442ed7094d171e75de0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 013/115] alsa-plugins: revbump for ffmpeg-6.0

---
 srcpkgs/alsa-plugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/alsa-plugins/template b/srcpkgs/alsa-plugins/template
index 0bfa6d9fd264..a5708a7d82a8 100644
--- a/srcpkgs/alsa-plugins/template
+++ b/srcpkgs/alsa-plugins/template
@@ -1,7 +1,7 @@
 # Template file for 'alsa-plugins'
 pkgname=alsa-plugins
 version=1.2.7.1
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--disable-maemo-plugin"
 hostmakedepends="pkg-config"

From 874efee0caf3fbd92cc04b5d7b9d1c965b2d26b9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 014/115] arcan: revbump for ffmpeg-6.0

---
 srcpkgs/arcan/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/arcan/template b/srcpkgs/arcan/template
index 7be9652eccf3..ccc7df11ceac 100644
--- a/srcpkgs/arcan/template
+++ b/srcpkgs/arcan/template
@@ -2,7 +2,7 @@
 # !! keep synced with: acfgfs aclip aloadimage
 pkgname=arcan
 version=0.6.2.1
-revision=1
+revision=2
 create_wrksrc=yes
 build_wrksrc=arcan/src
 build_style=cmake

From a4f138fabb777c38fecb9e932e3b738a4cf24ca0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 015/115] attract: revbump for ffmpeg4-4.4.3

---
 srcpkgs/attract/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/attract/template b/srcpkgs/attract/template
index 26144e931a3c..e760bf0d18ae 100644
--- a/srcpkgs/attract/template
+++ b/srcpkgs/attract/template
@@ -1,12 +1,12 @@
 # Template file for 'attract'
 pkgname=attract
 version=2.6.2
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="VERBOSE=1"
 make_use_env=yes
 hostmakedepends="pkg-config"
-makedepends="SFML-devel ffmpeg-devel fontconfig-devel glu-devel libarchive-devel
+makedepends="SFML-devel ffmpeg4-devel fontconfig-devel glu-devel libarchive-devel
  libcurl-devel libjpeg-turbo-devel xine-lib rapidjson libXrandr-devel"
 depends="git"
 short_desc="Attract-Mode is a graphical frontend for emulators"

From 719b787e5dc87c3380e059b0436b936cf9ed3e4b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 016/115] aubio: revbump for ffmpeg-6.0

---
 srcpkgs/aubio/patches/ffmpeg5.patch | 25 +++++++++++++++++++++++++
 srcpkgs/aubio/template              |  2 +-
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/aubio/patches/ffmpeg5.patch

diff --git a/srcpkgs/aubio/patches/ffmpeg5.patch b/srcpkgs/aubio/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..aace41a6e6d9
--- /dev/null
+++ b/srcpkgs/aubio/patches/ffmpeg5.patch
@@ -0,0 +1,25 @@
+From 8a05420e5dd8c7b8b2447f82dc919765876511b3 Mon Sep 17 00:00:00 2001
+From: Paul Brossier <piem@piem.org>
+Date: Tue, 25 Jan 2022 18:30:27 +0100
+Subject: [PATCH] [source_avcodec] define FF_API_LAVF_AVCTX for libavcodec >
+ 59, thx @berolinux (closes gh-353)
+
+---
+ src/io/source_avcodec.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/io/source_avcodec.c b/src/io/source_avcodec.c
+index e0ae93b5..1421bd9a 100644
+--- a/src/io/source_avcodec.c
++++ b/src/io/source_avcodec.c
+@@ -68,6 +68,10 @@
+ #define AUBIO_AVCODEC_MAX_BUFFER_SIZE AV_INPUT_BUFFER_MIN_SIZE
+ #endif
+ 
++#if LIBAVCODEC_VERSION_MAJOR >= 59
++#define FF_API_LAVF_AVCTX 1
++#endif
++
+ struct _aubio_source_avcodec_t {
+   uint_t hop_size;
+   uint_t samplerate;
diff --git a/srcpkgs/aubio/template b/srcpkgs/aubio/template
index ad1c4b256991..7d875cc02541 100644
--- a/srcpkgs/aubio/template
+++ b/srcpkgs/aubio/template
@@ -1,7 +1,7 @@
 # Template file for 'aubio'
 pkgname=aubio
 version=0.4.9
-revision=1
+revision=2
 build_style=waf3
 # XXX lash, pure and swig support.
 hostmakedepends="pkg-config txt2man"

From e398ea1e47a509dec2016e3421aa43652b73bb8d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 017/115] audacious-plugins: revbump for ffmpeg-6.0

---
 .../audacious-plugins/patches/ffmpeg5.patch   | 43 +++++++++++++++++++
 srcpkgs/audacious-plugins/template            |  2 +-
 2 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/audacious-plugins/patches/ffmpeg5.patch

diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg5.patch b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..4e5e34099d71
--- /dev/null
+++ b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
@@ -0,0 +1,43 @@
+commit 298aa371c56c2f52c25a33d9bdec4918b11cebdc
+Author: tibequadorian <tibequadorian@posteo.de>
+Date:   Sat Mar 19 18:40:12 2022 +0100
+
+    audacious-plugins: rebuild against ffmpeg-5.0
+
+diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+new file mode 100644
+index 0000000000..617c11215b
+--- /dev/null
++++ b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+@@ -0,0 +1,31 @@
++From f60beb400eeb1e4778bbfd738bc4a4ccef3de539 Mon Sep 17 00:00:00 2001
++From: John Lindgren <john@jlindgren.net>
++Date: Sat, 5 Mar 2022 12:05:34 -0500
++Subject: [PATCH] Fix build with FFmpeg 5.0
++
++---
++ src/ffaudio/ffaudio-core.cc | 4 ++--
++ 1 file changed, 2 insertions(+), 2 deletions(-)
++
++diff --git a/src/ffaudio/ffaudio-core.cc b/src/ffaudio/ffaudio-core.cc
++index 16dc63e3a..a2b95fd6c 100644
++--- a/src/ffaudio/ffaudio-core.cc
+++++ b/src/ffaudio/ffaudio-core.cc
++@@ -274,7 +274,7 @@ static AVInputFormat * get_format_by_content (const char * name, VFSFile & file)
++         AVProbeData d = {name, buf, filled};
++         score = target;
++ 
++-        f = av_probe_input_format2 (& d, true, & score);
+++        f = (AVInputFormat *) av_probe_input_format2 (& d, true, & score);
++         if (f)
++             break;
++ 
++@@ -347,7 +347,7 @@ static bool find_codec (AVFormatContext * c, CodecInfo * cinfo)
++ #endif
++         if (stream && stream->codecpar && stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
++         {
++-            AVCodec * codec = avcodec_find_decoder (stream->codecpar->codec_id);
+++            AVCodec * codec = (AVCodec *) avcodec_find_decoder (stream->codecpar->codec_id);
++ 
++             if (codec)
++             {
diff --git a/srcpkgs/audacious-plugins/template b/srcpkgs/audacious-plugins/template
index 88cbc1671fc6..beebfae59ed4 100644
--- a/srcpkgs/audacious-plugins/template
+++ b/srcpkgs/audacious-plugins/template
@@ -2,7 +2,7 @@
 #Keep in sync with audacious!
 pkgname=audacious-plugins
 version=4.3.1
-revision=1
+revision=2
 build_style=meson
 configure_args="$(vopt_bool gtk3 gtk) $(vopt_bool gtk3)
  $(vopt_bool qt) $(vopt_bool qt qt6)"

From 021ea8123528c2dcf687f702ff37bc44ba9e006a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 018/115] audacity: revbump for ffmpeg4-4.4.3

---
 srcpkgs/audacity/template | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/audacity/template b/srcpkgs/audacity/template
index d509c0a89407..11e20255685b 100644
--- a/srcpkgs/audacity/template
+++ b/srcpkgs/audacity/template
@@ -1,7 +1,7 @@
 # Template file for 'audacity'
 pkgname=audacity
 version=2.4.1
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--with-ffmpeg=system --with-libsndfile=system --with-expat=system
  --with-libsoxr=system --with-lame=system --with-lv2=system ac_cv_path_WX_CONFIG=wx-config-gtk3"
@@ -9,7 +9,7 @@ hostmakedepends="pkg-config cmake gettext libtool m4 which"
 makedepends="jack-devel wxWidgets-gtk3-devel gtk+3-devel
  libmad-devel soundtouch-devel libsoxr-devel
  vamp-plugin-sdk-devel lame-devel libid3tag-devel libflac-devel
- ffmpeg-devel twolame-devel serd-devel lv2 lilv-devel suil-devel"
+ ffmpeg4-devel twolame-devel serd-devel lv2 lilv-devel suil-devel"
 depends="desktop-file-utils hicolor-icon-theme"
 short_desc="Graphical cross-platform audio editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
@@ -33,5 +33,4 @@ post_install() {
 	vcopy plug-ins /usr/share/audacity
 
 	rm ${DESTDIR}/usr/share/doc/audacity/LICENSE.txt
-	vlicense LICENSE.txt LICENSE
 }

From ba72a69e4f463320971fd95d1242f517004cdf70 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 019/115] avidemux: revbump for ffmpeg-6.0

---
 srcpkgs/avidemux/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/avidemux/template b/srcpkgs/avidemux/template
index 253a0243e225..557285982d2b 100644
--- a/srcpkgs/avidemux/template
+++ b/srcpkgs/avidemux/template
@@ -1,7 +1,7 @@
 # Template file for 'avidemux'
 pkgname=avidemux
 version=2.8.0
-revision=2
+revision=3
 # Can't be compiled for aarch64, arm* or mips*
 archs="x86_64* i686*"
 hostmakedepends="cmake pkg-config qt5-host-tools qt5-devel tar yasm"

From ddb405b403901172f30915e542cd55054bf77a9f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 020/115] baresip: revbump for ffmpeg-6.0

---
 srcpkgs/baresip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/baresip/template b/srcpkgs/baresip/template
index f1bd1817048b..b21e22334316 100644
--- a/srcpkgs/baresip/template
+++ b/srcpkgs/baresip/template
@@ -1,7 +1,7 @@
 # Template file for 'baresip'
 pkgname=baresip
 version=2.10.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config glib-devel"
 makedepends="libgsm-devel libpng-devel openssl-devel libsndfile-devel

From f94090b03c03b89f75da0c52e9deab5754599106 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 021/115] blender: revbump for ffmpeg-6.0

---
 srcpkgs/blender/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index ec724bb0a6dc..0f72876d4d70 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -1,7 +1,7 @@
 # Template file for 'blender'
 pkgname=blender
 version=3.5.1
-revision=1
+revision=2
 archs="x86_64* ppc64*"
 build_style="cmake"
 pycompile_dirs="/usr/share/blender/${version%.*}/scripts"
@@ -9,8 +9,8 @@ configure_args="-DWITH_INSTALL_PORTABLE=OFF -DWITH_PYTHON_INSTALL=OFF
  -DWITH_JACK=ON -DWITH_CODEC_FFMPEG=ON -DWITH_CODEC_SNDFILE=ON -DWITH_OPENMP=ON
  -DWITH_FFTW3=ON -DWITH_MOD_OCEANSIM=ON -DWITH_CYCLES_EMBREE=OFF -DWITH_OPENCOLORIO=ON
  -DWITH_IMAGE_OPENEXR=ON -DWITH_IMAGE_OPENJPEG=ON -DWITH_OPENSUBDIV=ON
- -DWITH_OPENCOLLADA=ON -DWITH_SYSTEM_GLEW=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
- -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_LIBDECOR=ON
+ -DWITH_OPENCOLLADA=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
+ -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_WAYLAND_LIBDECOR=ON
  -DWITH_BUILDINFO=OFF -DPYTHON_VERSION=${py3_ver} -DPYTHON_LIBPATH=/usr/lib
  -DPYTHON_LIBRARY=python${py3_ver}${py3_abiver} -DPYTHON_INCLUDE_DIRS=/${py3_inc}
  -DWITH_SYSTEM_LZO=ON -DWITH_SYSTEM_EIGEN3=ON -DWITH_SYSTEM_FREETYPE=ON"

From ce8e16104f283c15f810d641ab571efadb3ba106 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 022/115] cantata: revbump for ffmpeg-6.0

---
 srcpkgs/cantata/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cantata/template b/srcpkgs/cantata/template
index 4b417d80d5c2..8a90aaa4c07a 100644
--- a/srcpkgs/cantata/template
+++ b/srcpkgs/cantata/template
@@ -1,7 +1,7 @@
 # Template file for 'cantata'
 pkgname=cantata
 version=2.5.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools qt5-tools"
 makedepends="qt5-devel qt5-tools-devel qt5-svg-devel qt5-xmlpatterns-devel

From 9b014b59cd3e25fd36bc474bda852a67d0e0c8df Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 023/115] ccextractor: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ccextractor/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/ccextractor/template b/srcpkgs/ccextractor/template
index 9abcd82852b2..6eccad5885af 100644
--- a/srcpkgs/ccextractor/template
+++ b/srcpkgs/ccextractor/template
@@ -1,12 +1,12 @@
 # Template file for 'ccextractor'
 pkgname=ccextractor
 version=0.93
-revision=1
+revision=2
 build_wrksrc="linux"
 build_style=gnu-configure
 configure_args="--enable-ocr --enable-hardsubx"
 hostmakedepends="automake pkg-config"
-makedepends="leptonica-devel tesseract-ocr-devel ffmpeg-devel"
+makedepends="leptonica-devel tesseract-ocr-devel ffmpeg4-devel"
 short_desc="Extract subtitles from video streams"
 maintainer="newbluemoon <blaumolch@mailbox.org>"
 license="GPL-2.0-or-later"

From 8d07032716a4d9bf9e3ebbfb31cce6888c91612b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 024/115] chromaprint: revbump for ffmpeg-6.0

---
 srcpkgs/chromaprint/patches/ffmpeg5.patch | 569 ++++++++++++++++++++++
 srcpkgs/chromaprint/template              |   2 +-
 2 files changed, 570 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromaprint/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromaprint/patches/ffmpeg5.patch b/srcpkgs/chromaprint/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..a9fd307a23c8
--- /dev/null
+++ b/srcpkgs/chromaprint/patches/ffmpeg5.patch
@@ -0,0 +1,569 @@
+From 8ccad6937177b1b92e40ab8f4447ea27bac009a7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= <lalinsky@gmail.com>
+Date: Fri, 4 Nov 2022 21:47:38 +0100
+Subject: [PATCH] Use FFmpeg 5.x (#120)
+
+* Use FFmpeg 5.1.2 for CI builds
+
+* Build on Ubuntu 20.04
+
+* Upgrade code to FFmpeg 5.x APIs
+
+* Only set FFmpeg include dirs if building tools
+
+* No longer needed
+
+* Use ubuntu 20.04
+---
+ .github/workflows/build.yml                   |   6 +-
+ CMakeLists.txt                                |  16 --
+ package/build.sh                              |   4 +-
+ src/audio/ffmpeg_audio_processor.h            |   2 -
+ src/audio/ffmpeg_audio_processor_avresample.h |  72 -------
+ src/audio/ffmpeg_audio_processor_swresample.h |  18 +-
+ src/audio/ffmpeg_audio_reader.h               | 197 +++++++++---------
+ tests/CMakeLists.txt                          |   6 +
+ 8 files changed, 122 insertions(+), 199 deletions(-)
+ delete mode 100644 src/audio/ffmpeg_audio_processor_avresample.h
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index f8d6a32..4da2405 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -84,9 +84,6 @@ find_package(FFmpeg)
+ if(FFMPEG_LIBRARIES)
+ 	cmake_push_check_state(RESET)
+ 	set(CMAKE_REQUIRED_LIBRARIES ${FFMPEG_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -lm)
+-	check_function_exists(av_packet_unref HAVE_AV_PACKET_UNREF)
+-	check_function_exists(av_frame_alloc HAVE_AV_FRAME_ALLOC)
+-	check_function_exists(av_frame_free HAVE_AV_FRAME_FREE)
+ 	cmake_pop_check_state()
+ endif()
+
+@@ -163,14 +160,11 @@ message(STATUS "Using ${FFT_LIB} for FFT calculations")
+ if(NOT AUDIO_PROCESSOR_LIB)
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+ 		set(AUDIO_PROCESSOR_LIB "swresample")
+-	elseif(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(AUDIO_PROCESSOR_LIB "avresample")
+ 	endif()
+ endif()
+
+ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE OFF)
+ 		set(USE_SWRESAMPLE ON)
+ 		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBSWRESAMPLE_LIBRARIES})
+ 		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBSWRESAMPLE_INCLUDE_DIRS})
+@@ -178,16 +172,6 @@ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+ 	endif()
+ 	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+-elseif(AUDIO_PROCESSOR_LIB STREQUAL "avresample")
+-	if(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE ON)
+-		set(USE_SWRESAMPLE OFF)
+-		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBAVRESAMPLE_LIBRARIES})
+-		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBAVRESAMPLE_INCLUDE_DIRS})
+-	else()
+-		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+-	endif()
+-	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+ else()
+ 	message(STATUS "Building without audio conversion support, please install FFmpeg with libswresample")
+ endif()
+diff --git a/package/build.sh b/package/build.sh
+index da631ae..b41d36e 100755
+--- a/package/build.sh
++++ b/package/build.sh
+@@ -7,8 +7,8 @@ set -eux
+
+ BASE_DIR=$(cd $(dirname $0)/.. && pwd)
+
+-FFMPEG_VERSION=4.4.1
+-FFMPEG_BUILD_TAG=v4.4.1-1
++FFMPEG_VERSION=5.1.2
++FFMPEG_BUILD_TAG=v${FFMPEG_VERSION}-1
+
+ TMP_BUILD_DIR=$BASE_DIR/$(mktemp -d build.XXXXXXXX)
+ trap 'rm -rf $TMP_BUILD_DIR' EXIT
+diff --git a/src/audio/ffmpeg_audio_processor.h b/src/audio/ffmpeg_audio_processor.h
+index 7628fc7..39f4f6d 100644
+--- a/src/audio/ffmpeg_audio_processor.h
++++ b/src/audio/ffmpeg_audio_processor.h
+@@ -10,8 +10,6 @@
+
+ #if defined(USE_SWRESAMPLE)
+ #include "audio/ffmpeg_audio_processor_swresample.h"
+-#elif defined(USE_AVRESAMPLE)
+-#include "audio/ffmpeg_audio_processor_avresample.h"
+ #else
+ #error "no audio processing library"
+ #endif
+diff --git a/src/audio/ffmpeg_audio_processor_avresample.h b/src/audio/ffmpeg_audio_processor_avresample.h
+deleted file mode 100644
+index bd85f92..0000000
+--- a/src/audio/ffmpeg_audio_processor_avresample.h
++++ /dev/null
+@@ -1,72 +0,0 @@
+-// Copyright (C) 2016  Lukas Lalinsky
+-// Distributed under the MIT license, see the LICENSE file for details.
+-
+-#ifndef CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-#define CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-
+-extern "C" {
+-#include <libavresample/avresample.h>
+-}
+-
+-namespace chromaprint {
+-
+-class FFmpegAudioProcessor {
+-public:
+-	FFmpegAudioProcessor() {
+-		m_resample_ctx = avresample_alloc_context();
+-	}
+-
+-	~FFmpegAudioProcessor() {
+-		avresample_free(&m_resample_ctx);
+-	}
+-
+-	void SetCompatibleMode() {
+-		av_opt_set_int(m_resample_ctx, "filter_size", 16, 0);
+-		av_opt_set_int(m_resample_ctx, "phase_shift", 8, 0);
+-		av_opt_set_int(m_resample_ctx, "linear_interp", 1, 0);
+-		av_opt_set_double(m_resample_ctx, "cutoff", 0.8, 0);
+-	}
+-
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "in_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_rate", sample_rate, 0);
+-	}
+-
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "out_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_rate, 0);
+-	}
+-
+-	int Init() {
+-		return avresample_open(m_resample_ctx);
+-	}
+-
+-	int Convert(uint8_t **out, int out_count, const uint8_t **in, int in_count) {
+-		return avresample_convert(m_resample_ctx, out, 0, out_count, (uint8_t **) in, 0, in_count);
+-	}
+-
+-	int Flush(uint8_t **out, int out_count) {
+-		return avresample_read(m_resample_ctx, out, out_count);
+-	}
+-
+-private:
+-	AVAudioResampleContext *m_resample_ctx = nullptr;
+-};
+-
+-}; // namespace chromaprint
+-
+-#endif
+diff --git a/src/audio/ffmpeg_audio_processor_swresample.h b/src/audio/ffmpeg_audio_processor_swresample.h
+index b86266b..b1d4bea 100644
+--- a/src/audio/ffmpeg_audio_processor_swresample.h
++++ b/src/audio/ffmpeg_audio_processor_swresample.h
+@@ -28,30 +28,28 @@ public:
+ 		av_opt_set_double(m_swr_ctx, "cutoff", 0.8, 0);
+ 	}
+
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "icl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "ich", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetInputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "in_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "isf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "in_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "isr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "in_sample_rate", sample_rate, 0);
+ 	}
+
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "ocl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "och", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetOutputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "out_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "osf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "out_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "osr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "out_sample_rate", sample_rate, 0);
+ 	}
+
+ 	int Init() {
+diff --git a/src/audio/ffmpeg_audio_reader.h b/src/audio/ffmpeg_audio_reader.h
+index 5550164..1c6b346 100644
+--- a/src/audio/ffmpeg_audio_reader.h
++++ b/src/audio/ffmpeg_audio_reader.h
+@@ -62,7 +62,7 @@ public:
+ 	bool Read(const int16_t **data, size_t *size);
+
+ 	bool IsOpen() const { return m_opened; }
+-	bool IsFinished() const { return m_finished && !m_got_frame; }
++	bool IsFinished() const { return !m_has_more_packets && !m_has_more_frames; }
+
+ 	std::string GetError() const { return m_error; }
+ 	int GetErrorCode() const { return m_error_code; }
+@@ -74,20 +74,19 @@ private:
+ 	uint8_t *m_convert_buffer[1] = { nullptr };
+ 	int m_convert_buffer_nb_samples = 0;
+
+-	AVInputFormat *m_input_fmt = nullptr;
++	const AVInputFormat *m_input_fmt = nullptr;
+ 	AVDictionary *m_input_opts = nullptr;
+
+ 	AVFormatContext *m_format_ctx = nullptr;
+ 	AVCodecContext *m_codec_ctx = nullptr;
+-	AVFrame *m_frame = nullptr;
+ 	int m_stream_index = -1;
+ 	std::string m_error;
+ 	int m_error_code = 0;
+-	bool m_finished = false;
+ 	bool m_opened = false;
+-	int m_got_frame = 0;
+-	AVPacket m_packet;
+-	AVPacket m_packet0;
++	bool m_has_more_packets = true;
++	bool m_has_more_frames = true;
++	AVPacket *m_packet = nullptr;
++	AVFrame *m_frame = nullptr;
+
+ 	int m_output_sample_rate = 0;
+ 	int m_output_channels = 0;
+@@ -98,19 +97,12 @@ private:
+
+ inline FFmpegAudioReader::FFmpegAudioReader() {
+ 	av_log_set_level(AV_LOG_QUIET);
+-
+-	av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
+ }
+
+ inline FFmpegAudioReader::~FFmpegAudioReader() {
+ 	Close();
+ 	av_dict_free(&m_input_opts);
+ 	av_freep(&m_convert_buffer[0]);
+-	av_packet_unref(&m_packet0);
+ }
+
+ inline bool FFmpegAudioReader::SetInputFormat(const char *name) {
+@@ -135,11 +127,10 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ 	Close();
+
+-    av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
++	m_packet = av_packet_alloc();
++	if (!m_packet) {
++		return false;
++	}
+
+ 	ret = avformat_open_input(&m_format_ctx, file_name.c_str(), m_input_fmt, &m_input_opts);
+ 	if (ret < 0) {
+@@ -153,26 +144,31 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		return false;
+ 	}
+
+-	AVCodec *codec;
++	const AVCodec *codec;
+ 	ret = av_find_best_stream(m_format_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &codec, 0);
+ 	if (ret < 0) {
+ 		SetError("Could not find any audio stream in the file", ret);
+ 		return false;
+ 	}
+ 	m_stream_index = ret;
++	auto stream = m_format_ctx->streams[m_stream_index];
+
+-	m_codec_ctx = m_format_ctx->streams[m_stream_index]->codec;
++	m_codec_ctx = avcodec_alloc_context3(codec);
+ 	m_codec_ctx->request_sample_fmt = AV_SAMPLE_FMT_S16;
+
++	ret = avcodec_parameters_to_context(m_codec_ctx, stream->codecpar);
++	if (ret < 0) {
++		SetError("Could not copy the stream parameters", ret);
++		return false;
++	}
++
+ 	ret = avcodec_open2(m_codec_ctx, codec, nullptr);
+ 	if (ret < 0) {
+ 		SetError("Could not open the codec", ret);
+ 		return false;
+ 	}
+
+-	if (!m_codec_ctx->channel_layout) {
+-		m_codec_ctx->channel_layout = av_get_default_channel_layout(m_codec_ctx->channels);
+-	}
++	av_dump_format(m_format_ctx, 0, "foo", 0);
+
+ 	m_frame = av_frame_alloc();
+ 	if (!m_frame) {
+@@ -183,19 +179,23 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		m_output_sample_rate = m_codec_ctx->sample_rate;
+ 	}
+
+-	if (!m_output_channels) {
+-		m_output_channels = m_codec_ctx->channels;
++	AVChannelLayout output_channel_layout;
++	if (m_output_channels) {
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
++	} else {
++		m_output_channels = m_codec_ctx->ch_layout.nb_channels;
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
+ 	}
+
+-	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
++	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->ch_layout.nb_channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
+ 		m_converter.reset(new FFmpegAudioProcessor());
+ 		m_converter->SetCompatibleMode();
+ 		m_converter->SetInputSampleFormat(m_codec_ctx->sample_fmt);
+ 		m_converter->SetInputSampleRate(m_codec_ctx->sample_rate);
+-		m_converter->SetInputChannelLayout(m_codec_ctx->channel_layout);
++		m_converter->SetInputChannelLayout(&(m_codec_ctx->ch_layout));
+ 		m_converter->SetOutputSampleFormat(AV_SAMPLE_FMT_S16);
+ 		m_converter->SetOutputSampleRate(m_output_sample_rate);
+-		m_converter->SetOutputChannelLayout(av_get_default_channel_layout(m_output_channels));
++		m_converter->SetOutputChannelLayout(&output_channel_layout);
+ 		auto ret = m_converter->Init();
+ 		if (ret != 0) {
+ 			SetError("Could not create an audio converter instance", ret);
+@@ -203,10 +203,11 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		}
+ 	}
+
++	av_channel_layout_uninit(&output_channel_layout);
++
+ 	m_opened = true;
+-	m_finished = false;
+-	m_got_frame = 0;
+-	m_nb_packets = 0;
++	m_has_more_packets = true;
++	m_has_more_frames = true;
+ 	m_decode_error = 0;
+
+ 	return true;
+@@ -214,6 +215,7 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ inline void FFmpegAudioReader::Close() {
+ 	av_frame_free(&m_frame);
++	av_packet_free(&m_packet);
+
+ 	m_stream_index = -1;
+
+@@ -252,91 +254,98 @@ inline bool FFmpegAudioReader::Read(const int16_t **data, size_t *size) {
+ 		return false;
+ 	}
+
++	*data = nullptr;
++	*size = 0;
++
+ 	int ret;
++	bool needs_packet = false;
+ 	while (true) {
+-		while (m_packet.size <= 0) {
+-			av_packet_unref(&m_packet0);
+-			av_init_packet(&m_packet);
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			ret = av_read_frame(m_format_ctx, &m_packet);
++		while (needs_packet && m_packet->size == 0) {
++			ret = av_read_frame(m_format_ctx, m_packet);
+ 			if (ret < 0) {
+ 				if (ret == AVERROR_EOF) {
+-					m_finished = true;
++					needs_packet = false;
++					m_has_more_packets = false;
+ 					break;
+-				} else {
++				}
++				SetError("Error reading from the audio source", ret);
++				return false;
++			}
++			if (m_packet->stream_index == m_stream_index) {
++				needs_packet = false;
++			} else {
++				av_packet_unref(m_packet);
++			}
++		}
++
++		if (m_packet->size != 0) {
++			ret = avcodec_send_packet(m_codec_ctx, m_packet);
++			if (ret < 0) {
++				if (ret != AVERROR(EAGAIN)) {
+ 					SetError("Error reading from the audio source", ret);
+ 					return false;
+ 				}
+-			}
+-			m_packet0 = m_packet;
+-			if (m_packet.stream_index != m_stream_index) {
+-				m_packet.data = nullptr;
+-				m_packet.size = 0;
+ 			} else {
+-				m_nb_packets++;
++				av_packet_unref(m_packet);
+ 			}
+ 		}
+
+-		ret = avcodec_decode_audio4(m_codec_ctx, m_frame, &m_got_frame, &m_packet);
++		ret = avcodec_receive_frame(m_codec_ctx, m_frame);
+ 		if (ret < 0) {
+-			if (m_decode_error) {
+-				SetError("Error decoding audio frame", m_decode_error);
+-				return false;
++			if (ret == AVERROR_EOF) {
++				m_has_more_frames = false;
++			} else if (ret == AVERROR(EAGAIN)) {
++				if (m_has_more_packets) {
++					needs_packet = true;
++					continue;
++				} else {
++					m_has_more_frames = false;
++				}
+ 			}
+-			m_decode_error = ret;
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			continue;
++			SetError("Error decoding the audio source", ret);
++			return false;
+ 		}
+
+-		break;
+-	}
+-
+-	m_decode_error = 0;
+-
+-	const int decoded = std::min(ret, m_packet.size);
+-	m_packet.data += decoded;
+-	m_packet.size -= decoded;
+-
+-	if (m_got_frame) {
+-		if (m_converter) {
+-			if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
+-				int linsize;
+-				av_freep(&m_convert_buffer[0]);
+-				m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
+-				ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
+-				if (ret < 0) {
+-					SetError("Couldn't allocate audio converter buffer", ret);
++		if (m_frame->nb_samples > 0) {
++			if (m_converter) {
++				if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
++					int linsize;
++					av_freep(&m_convert_buffer[0]);
++					m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
++					ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->ch_layout.nb_channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
++					if (ret < 0) {
++						SetError("Couldn't allocate audio converter buffer", ret);
++						return false;
++					}
++				}
++				auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
++				if (nb_samples < 0) {
++					SetError("Couldn't convert audio", ret);
+ 					return false;
+ 				}
+-			}
+-			auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			}
+-			*data = (const int16_t *) m_convert_buffer[0];
+-			*size = nb_samples;
+-		} else {
+-			*data = (const int16_t *) m_frame->data[0];
+-			*size = m_frame->nb_samples;
+-		}
+-	} else {
+-		if (m_finished && m_converter) {
+-			auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			} else if (nb_samples > 0) {
+-				m_got_frame = 1;
+ 				*data = (const int16_t *) m_convert_buffer[0];
+ 				*size = nb_samples;
++			} else {
++				*data = (const int16_t *) m_frame->data[0];
++				*size = m_frame->nb_samples;
++			}
++		} else {
++			if (m_converter) {
++				if (IsFinished()) {
++					auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
++					if (nb_samples < 0) {
++						SetError("Couldn't convert audio", ret);
++						return false;
++					} else if (nb_samples > 0) {
++						*data = (const int16_t *) m_convert_buffer[0];
++						*size = nb_samples;
++					}
++				}
+ 			}
+ 		}
+-	}
+
+-	return true;
++		return true;
++	}
+ }
+
+ inline void FFmpegAudioReader::SetError(const char *message, int errnum) {
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index a2b517b..123e643 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -38,6 +38,12 @@ set(SRCS
+
+ if(BUILD_TOOLS)
+ 	set(SRCS ${SRCS} ../src/audio/ffmpeg_audio_reader_test.cpp)
++    include_directories(
++        ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}
++        ${AUDIO_PROCESSOR_INCLUDE_DIRS}
++    )
+ 	link_libraries(fpcalc_libs)
+ endif()
+
+-- 
+2.38.1
+
+
diff --git a/srcpkgs/chromaprint/template b/srcpkgs/chromaprint/template
index 7ef7838949f3..1f7bbc70a22c 100644
--- a/srcpkgs/chromaprint/template
+++ b/srcpkgs/chromaprint/template
@@ -1,7 +1,7 @@
 # Template file for 'chromaprint'
 pkgname=chromaprint
 version=1.5.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DBUILD_TOOLS=ON"
 make_check_target="check"

From 2db7d33ed779ce4b14aa6115e8638c04b32274cd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 025/115] chromium: revbump for ffmpeg-6.0

---
 .../patches/chromium-93-ffmpeg-4.4.patch      | 36 --------------
 srcpkgs/chromium/patches/ffmpeg5.patch        | 47 +++++++++++++++++++
 srcpkgs/chromium/template                     |  2 +-
 3 files changed, 48 insertions(+), 37 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch
 create mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch b/srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch
deleted file mode 100644
index f0ec736f98bc..000000000000
--- a/srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch
+++ /dev/null
@@ -1,36 +0,0 @@
-diff --git a/media/filters/ffmpeg_demuxer.cc b/media/filters/ffmpeg_demuxer.cc
-index ac4713b07268..492a9a37d096 100644
---- a/media/filters/ffmpeg_demuxer.cc
-+++ b/media/filters/ffmpeg_demuxer.cc
-@@ -427,11 +427,11 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
-   scoped_refptr<DecoderBuffer> buffer;
- 
-   if (type() == DemuxerStream::TEXT) {
--    size_t id_size = 0;
-+    int id_size = 0;
-     uint8_t* id_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
- 
--    size_t settings_size = 0;
-+    int settings_size = 0;
-     uint8_t* settings_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
- 
-@@ -443,7 +443,7 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
-     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
-                                      side_data.data(), side_data.size());
-   } else {
--    size_t side_data_size = 0;
-+    int side_data_size = 0;
-     uint8_t* side_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
- 
-@@ -504,7 +504,7 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
-                                        packet->size - data_offset);
-     }
- 
--    size_t skip_samples_size = 0;
-+    int skip_samples_size = 0;
-     const uint32_t* skip_samples_ptr =
-         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
-             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..24e2da38e34c
--- /dev/null
+++ b/srcpkgs/chromium/patches/ffmpeg5.patch
@@ -0,0 +1,47 @@
+--- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
++++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
+@@ -92,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+-  if (stream->start_time != kNoFFmpegTimestamp)
++  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -1597,7 +1585,7 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+@@ -1618,7 +1606,7 @@
+     if (stream->type() != DemuxerStream::VIDEO)
+       continue;
+ 
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+ 
+     if (!stream->IsEnabled())
diff --git a/srcpkgs/chromium/template b/srcpkgs/chromium/template
index b4a39dfd3815..c29453cd1f50 100644
--- a/srcpkgs/chromium/template
+++ b/srcpkgs/chromium/template
@@ -2,7 +2,7 @@
 pkgname=chromium
 # See https://chromiumdash.appspot.com/releases?platform=Linux for the latest version
 version=114.0.5735.106
-revision=1
+revision=2
 archs="i686* x86_64* aarch64* armv7l*"
 hostmakedepends="
  $(vopt_if clang "clang lld llvm15")

From e700a0b404f107078b39a3f8bf07a4e04ddab653 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 026/115] cmus: revbump for ffmpeg-6.0

---
 srcpkgs/cmus/patches/ffmpeg6.patch | 12 ++++++++++++
 srcpkgs/cmus/template              |  2 +-
 2 files changed, 13 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/cmus/patches/ffmpeg6.patch

diff --git a/srcpkgs/cmus/patches/ffmpeg6.patch b/srcpkgs/cmus/patches/ffmpeg6.patch
new file mode 100644
index 000000000000..ffa95ab81110
--- /dev/null
+++ b/srcpkgs/cmus/patches/ffmpeg6.patch
@@ -0,0 +1,12 @@
+--- a/ip/ffmpeg.c
++++ b/ip/ffmpeg.c
+@@ -202,9 +202,6 @@ static int ffmpeg_open(struct input_plugin_data *ip_data)
+ 			break;
+ 		}
+ 
+-		if (codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+-			cc->flags |= AV_CODEC_FLAG_TRUNCATED;
+-
+ 		if (avcodec_open2(cc, codec, NULL) < 0) {
+ 			d_print("could not open codec: %d, %s\n", cc->codec_id, avcodec_get_name(cc->codec_id));
+ 			err = -IP_ERROR_UNSUPPORTED_FILE_TYPE;
diff --git a/srcpkgs/cmus/template b/srcpkgs/cmus/template
index 0fcb424ce336..05b77d0fecae 100644
--- a/srcpkgs/cmus/template
+++ b/srcpkgs/cmus/template
@@ -1,7 +1,7 @@
 # Template file for 'cmus'
 pkgname=cmus
 version=2.10.0
-revision=1
+revision=2
 build_style=configure
 configure_args="prefix=/usr LD=$CC"
 hostmakedepends="pkg-config"

From def08d51d1f7c23f51c3abf2f65b34f4d379df94 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 027/115] cyanrip: revbump for ffmpeg-6.0

---
 srcpkgs/cyanrip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cyanrip/template b/srcpkgs/cyanrip/template
index 9796e3461601..5db30e020d17 100644
--- a/srcpkgs/cyanrip/template
+++ b/srcpkgs/cyanrip/template
@@ -1,7 +1,7 @@
 # Template file for 'cyanrip'
 pkgname=cyanrip
 version=0.9.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config"
 makedepends="ffmpeg-devel libcdio-devel libcdio-paranoia-devel libcurl-devel libmusicbrainz5-devel"

From 5df9fa41df1d370c36e79d602cec3693cd2417f9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 028/115] deadbeef: revbump for ffmpeg4-4.4.3

---
 srcpkgs/deadbeef/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/deadbeef/template b/srcpkgs/deadbeef/template
index b664bb1b9bd9..165b3c7b9cad 100644
--- a/srcpkgs/deadbeef/template
+++ b/srcpkgs/deadbeef/template
@@ -1,14 +1,14 @@
 # Template file for 'deadbeef'
 pkgname=deadbeef
 version=1.8.8
-revision=1
+revision=2
 create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-oss --disable-lfm --disable-notify --disable-gtk2"
 hostmakedepends="automake libtool gettext gettext-devel intltool pkg-config
  yasm clang glib-devel"
 makedepends="
- alsa-lib-devel dbus-devel faad2-devel ffmpeg-devel gtk+3-devel imlib2-devel
+ alsa-lib-devel dbus-devel faad2-devel ffmpeg4-devel gtk+3-devel imlib2-devel
  jansson-devel libcddb-devel libcdio-devel libcurl-devel libflac-devel
  libmad-devel libpng-devel libsamplerate-devel libsndfile-devel libvorbis-devel
  libzip-devel mpg123-devel opusfile-devel pulseaudio-devel wavpack-devel"

From b81f32e1fdc2e98691aa5925c2a9521fbda7c096 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 029/115] dolphin-emu: revbump for ffmpeg-6.0

---
 srcpkgs/dolphin-emu/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/dolphin-emu/template b/srcpkgs/dolphin-emu/template
index 7ea197ceb2a8..7aeb0a5b645e 100644
--- a/srcpkgs/dolphin-emu/template
+++ b/srcpkgs/dolphin-emu/template
@@ -1,7 +1,7 @@
 # Template file for 'dolphin-emu'
 pkgname=dolphin-emu
 version=5.0.16101
-revision=1
+revision=2
 _dolphin_commit=8ecfa537a242de74d2e372e30d9d79b14584b2fb
 _mgba_commit=40d4c430fc36caeb7ea32fd39624947ed487d2f2
 #Version/hash pair can be found at https://dolphin-emu.org/download/

From cf5828756e53624e6e21974cc397af7c77633c15 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 030/115] droidcam-obs-plugin: revbump for ffmpeg-6.0

---
 srcpkgs/droidcam-obs-plugin/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam-obs-plugin/template b/srcpkgs/droidcam-obs-plugin/template
index fc9c9bf6b9d5..fb0480754df4 100644
--- a/srcpkgs/droidcam-obs-plugin/template
+++ b/srcpkgs/droidcam-obs-plugin/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam-obs-plugin'
 pkgname=droidcam-obs-plugin
 version=2.0.1
-revision=1
+revision=2
 build_style=gnu-makefile
 make_use_env=yes
 make_build_args="ALLOW_STATIC=no"

From 741dbd19e089f4ce7c894e019ce079015063dbc2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 031/115] droidcam: revbump for ffmpeg-6.0

---
 srcpkgs/droidcam/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam/template b/srcpkgs/droidcam/template
index 1c3f1b8b1fc6..32a9220b79a4 100644
--- a/srcpkgs/droidcam/template
+++ b/srcpkgs/droidcam/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam'
 pkgname=droidcam
 version=1.8.2
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="USBMUXD=-lusbmuxd-2.0 JPEG=-lturbojpeg"
 hostmakedepends="pkg-config"

From ca538eec27a532d657a0b4d7504457a7816f6be0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 032/115] ffmpegthumbnailer: revbump for ffmpeg-6.0

---
 .../ffmpegthumbnailer/patches/ffmpeg6.patch   | 202 ++++++++++++++++++
 srcpkgs/ffmpegthumbnailer/template            |   6 +-
 2 files changed, 205 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch

diff --git a/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
new file mode 100644
index 000000000000..363ff35a2841
--- /dev/null
+++ b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
@@ -0,0 +1,202 @@
+--- a/libffmpegthumbnailer/moviedecoder.cpp	2017-11-21 14:06:57.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.cpp	2023-05-05 13:14:47.946560668 -0400
+@@ -41,11 +41,6 @@
+ namespace ffmpegthumbnailer
+ {
+ 
+-struct SilenceLogLevel
+-{
+-    SilenceLogLevel() { av_log_set_level(AV_LOG_QUIET); }
+-};
+-
+ MovieDecoder::MovieDecoder(AVFormatContext* pavContext)
+ : m_VideoStream(-1)
+ , m_pFormatContext(pavContext)
+@@ -70,8 +65,6 @@
+ 
+ void MovieDecoder::initialize(const string& filename, bool preferEmbeddedMetadata)
+ {
+-    av_register_all();
+-    avcodec_register_all();
+     avformat_network_init();
+ 
+     string inputFile = filename == "-" ? "pipe:" : filename;
+@@ -97,8 +90,7 @@
+ {
+     if (m_pVideoCodecContext)
+     {
+-        avcodec_close(m_pVideoCodecContext);
+-        m_pVideoCodecContext = nullptr;
++        avcodec_free_context(&m_pVideoCodecContext);
+     }
+ 
+     if ((!m_FormatContextWasGiven) && m_pFormatContext)
+@@ -152,10 +144,10 @@
+     for (unsigned int i = 0; i < m_pFormatContext->nb_streams; ++i)
+     {
+         AVStream *stream = m_pFormatContext->streams[i];
+-        auto ctx = m_pFormatContext->streams[i]->codec;
+-        if (ctx->codec_type == AVMEDIA_TYPE_VIDEO)
++        auto par = m_pFormatContext->streams[i]->codecpar;
++        if (par->codec_type == AVMEDIA_TYPE_VIDEO)
+         {
+-            if (!preferEmbeddedMetadata || !isStillImageCodec(ctx->codec_id))
++            if (!preferEmbeddedMetadata || !isStillImageCodec(par->codec_id))
+             {
+                 videoStreams.push_back(i);
+                 continue;
+@@ -203,8 +195,7 @@
+     }
+ 
+     m_pVideoStream = m_pFormatContext->streams[m_VideoStream];
+-    m_pVideoCodecContext = m_pVideoStream->codec;
+-    m_pVideoCodec = avcodec_find_decoder(m_pVideoCodecContext->codec_id);
++    m_pVideoCodec = avcodec_find_decoder(m_pVideoStream->codecpar->codec_id);
+ 
+     if (m_pVideoCodec == nullptr)
+     {
+@@ -214,6 +205,20 @@
+         throw logic_error("Video Codec not found");
+     }
+ 
++    m_pVideoCodecContext = avcodec_alloc_context3(m_pVideoCodec);
++
++    if (m_pVideoCodecContext == nullptr)
++    {
++        destroy();
++        throw logic_error("Could not allocate video codec context");
++    }
++
++    if (avcodec_parameters_to_context(m_pVideoCodecContext, m_pVideoStream->codecpar) < 0)
++    {
++        destroy();
++        throw logic_error("Could not configure video codec context");
++    }
++
+     m_pVideoCodecContext->workaround_bugs = 1;
+ 
+     if (avcodec_open2(m_pVideoCodecContext, m_pVideoCodec, nullptr) < 0)
+@@ -386,13 +391,6 @@
+ 
+ void MovieDecoder::initializeFilterGraph(const AVRational& timeBase, const std::string& size, bool maintainAspectRatio)
+ {
+-    static const AVPixelFormat pixelFormats[] = { AV_PIX_FMT_RGB24, AV_PIX_FMT_NONE };
+-
+-    auto del = [] (AVBufferSinkParams* p) { av_freep(p); };
+-    std::unique_ptr<AVBufferSinkParams, decltype(del)> buffersinkParams(av_buffersink_params_alloc(), del);
+-
+-    avfilter_register_all();
+-
+     m_pFilterGraph = avfilter_graph_alloc();
+     assert(m_pFilterGraph);
+ 
+@@ -404,10 +402,8 @@
+ 
+     checkRc(avfilter_graph_create_filter(&m_pFilterSource, avfilter_get_by_name("buffer"), "thumb_buffer", ss.str().c_str(), nullptr, m_pFilterGraph),
+             "Failed to create filter source");
+-    buffersinkParams->pixel_fmts = pixelFormats;
+-    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, buffersinkParams.get(), m_pFilterGraph),
++    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, nullptr, m_pFilterGraph),
+             "Failed to create filter sink");
+-    buffersinkParams.release();
+ 
+     AVFilterContext* yadifFilter = nullptr;
+     if (m_pFrame->interlaced_frame != 0)
+@@ -500,15 +496,15 @@
+     }
+ 
+     checkRc(av_seek_frame(m_pFormatContext, -1, timestamp, 0), "Seeking in video failed");
+-    avcodec_flush_buffers(m_pFormatContext->streams[m_VideoStream]->codec);
++    avcodec_flush_buffers(m_pVideoCodecContext);
+ 
+     int keyFrameAttempts = 0;
+-    bool gotFrame = 0;
++    bool gotFrame;
+ 
+     do
+     {
+         int count = 0;
+-        gotFrame = 0;
++        gotFrame = false;
+ 
+         while (!gotFrame && count < 20)
+         {
+@@ -552,17 +548,33 @@
+         return false;
+     }
+ 
+-    av_frame_unref(m_pFrame);
+-
+-    int frameFinished;
++    int rc = avcodec_send_packet(m_pVideoCodecContext, m_pPacket);
++    if(rc == AVERROR(EAGAIN))
++    {
++        rc = 0;
++    }
+ 
+-    int bytesDecoded = avcodec_decode_video2(m_pVideoCodecContext, m_pFrame, &frameFinished, m_pPacket);
+-    if (bytesDecoded < 0)
++    if(rc == AVERROR_EOF)
++    {
++        return false;
++    }
++    else if(rc < 0)
+     {
+-        throw logic_error("Failed to decode video frame: bytesDecoded < 0");
++        throw logic_error("Failed to decode video frame: avcodec_send_packet() < 0");
+     }
+ 
+-    return frameFinished > 0;
++    rc = avcodec_receive_frame(m_pVideoCodecContext, m_pFrame);
++    switch(rc)
++    {
++        case 0:
++            return true;
++
++        case AVERROR(EAGAIN):
++            return false;
++
++        default:
++            throw logic_error("Failed to decode video frame: avcodec_receive_frame() < 0");
++    }
+ }
+ 
+ bool MovieDecoder::getVideoPacket()
+@@ -570,8 +582,6 @@
+     bool framesAvailable = true;
+     bool frameDecoded = false;
+ 
+-    int attempts = 0;
+-
+     if (m_pPacket)
+     {
+         av_packet_unref(m_pPacket);
+@@ -580,6 +590,7 @@
+ 
+     m_pPacket = new AVPacket();
+ 
++
+     while (framesAvailable && !frameDecoded)
+     {
+         framesAvailable = av_read_frame(m_pFormatContext, m_pPacket) >= 0;
+@@ -644,7 +655,7 @@
+ 
+ int32_t MovieDecoder::getStreamRotation()
+ {
+-    int32_t* matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
++    auto matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
+     if (matrix)
+     {
+         auto angle = lround(av_display_rotation_get(matrix));
+
+--- a/libffmpegthumbnailer/moviedecoder.h	2017-11-12 04:23:38.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.h	2023-05-05 13:26:07.095529911 -0400
+@@ -78,7 +78,7 @@
+     int                     m_VideoStream;
+     AVFormatContext*        m_pFormatContext;
+     AVCodecContext*         m_pVideoCodecContext;
+-    AVCodec*                m_pVideoCodec;
++    const AVCodec*          m_pVideoCodec;
+     AVFilterGraph*          m_pFilterGraph;
+     AVFilterContext*        m_pFilterSource;
+     AVFilterContext*        m_pFilterSink;
diff --git a/srcpkgs/ffmpegthumbnailer/template b/srcpkgs/ffmpegthumbnailer/template
index 039eea7622b3..35d546018d12 100644
--- a/srcpkgs/ffmpegthumbnailer/template
+++ b/srcpkgs/ffmpegthumbnailer/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbnailer'
 pkgname=ffmpegthumbnailer
 version=2.2.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libpng-devel libjpeg-turbo-devel ffmpeg-devel"
@@ -9,8 +9,8 @@ depends="ffmpeg"
 short_desc="Lightweight video thumbnailer"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
-homepage="https://github.com/dirkvdb/${pkgname}"
-distfiles="${homepage}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
+homepage="https://github.com/dirkvdb"
+distfiles="${homepage}/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
 checksum=1cb24059c38223f657b300c84dd80491b7040d4b69471c4fea69be862bc99b5b
 
 post_install() {

From 6d19efb88f17fbc9bfa076064f65d2a40a0e4428 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 033/115] ffmpegthumbs: revbump for ffmpeg-6.0

---
 srcpkgs/ffmpegthumbs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ffmpegthumbs/template b/srcpkgs/ffmpegthumbs/template
index 5f0b9414dada..11b88193528f 100644
--- a/srcpkgs/ffmpegthumbs/template
+++ b/srcpkgs/ffmpegthumbs/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbs'
 pkgname=ffmpegthumbs
 version=22.12.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules kcoreaddons kconfig-devel
  pkg-config qt5-host-tools qt5-qmake gettext"

From 83a030583caa2b518ca6a7d0290270528ca6e809 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 034/115] ffms2: revbump for ffmpeg-6.0

---
 srcpkgs/ffms2/patches/ffmpeg5.patch | 424 ++++++++++++++++++++++++++++
 srcpkgs/ffms2/template              |   2 +-
 2 files changed, 425 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ffms2/patches/ffmpeg5.patch

diff --git a/srcpkgs/ffms2/patches/ffmpeg5.patch b/srcpkgs/ffms2/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..1479fabcafcb
--- /dev/null
+++ b/srcpkgs/ffms2/patches/ffmpeg5.patch
@@ -0,0 +1,424 @@
+From 45673149e9a2f5586855ad472e3059084eaa36b1 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:41:21 +0100
+Subject: [PATCH] Use auto for AVCodec
+
+The geniuses over at FFmpeg decided to constify this API, so old
+versions of the library will return AVCodec *, while new versions
+of the libary will return const AVCodec *, which, in C++, are not
+OK to convert between.
+
+Rather than use some macro hell in ffmscompat.h, we can work around
+this by using auto.
+
+Gross.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 2 +-
+ src/core/indexing.cpp    | 6 +++---
+ src/core/videosource.cpp | 2 +-
+ 3 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index e4ce97c..ac09666 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -469,7 +469,7 @@ void FFMS_AudioSource::OpenFile() {
+ 
+     LAVFOpenFile(SourceFile.c_str(), FormatContext, TrackNumber);
+ 
+-    AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
++    auto *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
+     if (Codec == nullptr)
+         throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+             "Audio codec not found");
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index e547c5a..59fb4e8 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -384,7 +384,7 @@ FFMS_TrackType FFMS_Indexer::GetTrackType(int Track) {
+ }
+ 
+ const char *FFMS_Indexer::GetTrackCodec(int Track) {
+-    AVCodec *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
++    auto *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
+     return codec ? codec->name : nullptr;
+ }
+ 
+@@ -402,7 +402,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             UseDTS);
+ 
+         if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            AVCodec *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (!VideoCodec) {
+                 FormatContext->streams[i]->discard = AVDISCARD_ALL;
+                 IndexMask.erase(i);
+@@ -433,7 +433,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 IndexMask.insert(i);
+             }
+         } else if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+-            AVCodec *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (AudioCodec == nullptr)
+                 throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_UNSUPPORTED,
+                     "Audio codec not found");
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index b889970..8956c22 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -171,7 +171,7 @@ FFMS_VideoSource::FFMS_VideoSource(const char *SourceFile, FFMS_Index &Index, in
+ 
+         LAVFOpenFile(SourceFile, FormatContext, VideoTrack);
+ 
+-        AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
++        auto *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
+         if (Codec == nullptr)
+             throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+                 "Video codec not found");
+-- 
+2.40.0
+
+From 96cbf38ea9381829a1314f432a2c60495dcefaad Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:12:41 +0100
+Subject: [PATCH] all: Update AVPacket API usage
+
+AVPackets must all be on the heap now, since it is no longer
+part of the libav* ABI.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 16 ++++++----
+ src/core/indexing.cpp    | 63 ++++++++++++++++++++++------------------
+ src/core/indexing.h      |  4 +--
+ src/core/utils.cpp       |  6 ----
+ src/core/utils.h         |  1 -
+ src/core/videosource.cpp | 30 ++++++++++---------
+ 6 files changed, 64 insertions(+), 56 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index 37cf9ae..e4ce97c 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -285,10 +285,15 @@ FFMS_AudioSource::AudioBlock *FFMS_AudioSource::CacheBlock(CacheIterator &pos) {
+ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     CurrentFrame = &Frames[PacketNumber];
+ 
+-    AVPacket Packet;
+-    if (!ReadPacket(&Packet))
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++    if (!ReadPacket(Packet)) {
++        av_packet_free(&Packet);
+         throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_UNKNOWN,
+             "ReadPacket unexpectedly failed to read a packet");
++    }
+ 
+     // ReadPacket may have changed the packet number
+     CurrentFrame = &Frames[PacketNumber];
+@@ -297,8 +302,9 @@ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     int NumberOfSamples = 0;
+     AudioBlock *CachedBlock = nullptr;
+     
+-    int Ret = avcodec_send_packet(CodecContext, &Packet);
+-    av_packet_unref(&Packet);
++    int Ret = avcodec_send_packet(CodecContext, Packet);
++    av_packet_unref(Packet);
++    av_packet_free(&Packet);
+ 
+     av_frame_unref(DecodeFrame);
+     Ret = avcodec_receive_frame(CodecContext, DecodeFrame);
+@@ -513,8 +519,6 @@ void FFMS_AudioSource::Seek() {
+ }
+ 
+ bool FFMS_AudioSource::ReadPacket(AVPacket *Packet) {
+-    InitNullPacket(*Packet);
+-
+     while (av_read_frame(FormatContext, Packet) >= 0) {
+         if (Packet->stream_index == TrackNumber) {
+             // Required because not all audio packets, especially in ogg, have a pts. Use the previous valid packet's pts instead.
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index 23fb95b..e547c5a 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -320,7 +320,7 @@ void FFMS_Indexer::CheckAudioProperties(int Track, AVCodecContext *Context) {
+     }
+ }
+ 
+-void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict,
++void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict,
+                                     int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct) {
+     if (VideoContext.Parser) {
+         uint8_t *OB;
+@@ -330,8 +330,8 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+         av_parser_parse2(VideoContext.Parser,
+             VideoContext.CodecContext,
+             &OB, &OBSize,
+-            pkt.data, pkt.size,
+-            pkt.pts, pkt.dts, pkt.pos);
++            pkt->data, pkt->size,
++            pkt->pts, pkt->dts, pkt->pos);
+ 
+         // H.264 (PAFF) and HEVC may have one field per packet, so we need to track
+         // when we have a full or half frame available, and mark one of them as
+@@ -351,15 +351,15 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+ 
+         *RepeatPict = VideoContext.Parser->repeat_pict;
+         *FrameType = VideoContext.Parser->pict_type;
+-        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt.flags & AV_PKT_FLAG_DISCARD));
++        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt->flags & AV_PKT_FLAG_DISCARD));
+     } else {
+-        *Invisible = !!(pkt.flags & AV_PKT_FLAG_DISCARD);
++        *Invisible = !!(pkt->flags & AV_PKT_FLAG_DISCARD);
+     }
+ 
+     if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP8)
+-        ParseVP8(pkt.data[0], Invisible, FrameType);
++        ParseVP8(pkt->data[0], Invisible, FrameType);
+     else if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP9)
+-        ParseVP9(pkt.data[0], Invisible, FrameType);
++        ParseVP9(pkt->data[0], Invisible, FrameType);
+ }
+ 
+ void FFMS_Indexer::Free() {
+@@ -458,32 +458,36 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+         }
+     }
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
+     std::vector<int64_t> LastValidTS(FormatContext->nb_streams, AV_NOPTS_VALUE);
+ 
+     int64_t filesize = avio_size(FormatContext->pb);
+     enum AVPictureStructure LastPicStruct = AV_PICTURE_STRUCTURE_UNKNOWN;
+-    while (av_read_frame(FormatContext, &Packet) >= 0) {
++    while (av_read_frame(FormatContext, Packet) >= 0) {
+         // Update progress
+         // FormatContext->pb can apparently be NULL when opening images.
+         if (IC && FormatContext->pb) {
+-            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate))
++            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate)) {
++                av_packet_free(&Packet);
+                 throw FFMS_Exception(FFMS_ERROR_CANCELLED, FFMS_ERROR_USER,
+                     "Cancelled by user");
++            }
+         }
+-        if (!IndexMask.count(Packet.stream_index)) {
+-            av_packet_unref(&Packet);
++        if (!IndexMask.count(Packet->stream_index)) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+-        int Track = Packet.stream_index;
++        int Track = Packet->stream_index;
+         FFMS_Track &TrackInfo = (*TrackIndices)[Track];
+-        bool KeyFrame = !!(Packet.flags & AV_PKT_FLAG_KEY);
++        bool KeyFrame = !!(Packet->flags & AV_PKT_FLAG_KEY);
+         ReadTS(Packet, LastValidTS[Track], (*TrackIndices)[Track].UseDTS);
+ 
+         if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            int64_t PTS = TrackInfo.UseDTS ? Packet.dts : Packet.pts;
++            int64_t PTS = TrackInfo.UseDTS ? Packet->dts : Packet->pts;
+             if (PTS == AV_NOPTS_VALUE) {
+                 // VPx alt-refs are output as packets which lack timestmps or durations, since
+                 // they are invisible. Currently, the timestamp mangling code in libavformat
+@@ -495,9 +499,11 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 // FFMS2 currently sorts packets by PTS, which will break decoding, otherwise.
+                 bool HasAltRefs = (FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP8 ||
+                                    FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP9);
+-                if (Packet.duration == 0 && !HasAltRefs)
++                if (Packet->duration == 0 && !HasAltRefs) {
++                    av_packet_free(&Packet);
+                     throw FFMS_Exception(FFMS_ERROR_INDEXING, FFMS_ERROR_PARSER,
+                         "Invalid packet pts, dts, and duration");
++                }
+ 
+                 if (TrackInfo.empty())
+                     PTS = 0;
+@@ -513,7 +519,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             ParseVideoPacket(AVContexts[Track], Packet, &RepeatPict, &FrameType, &Invisible, &LastPicStruct);
+ 
+             TrackInfo.AddVideoFrame(PTS, RepeatPict, KeyFrame,
+-                FrameType, Packet.pos, Invisible);
++                FrameType, Packet->pos, Invisible);
+         } else if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+             // For video seeking timestamps are used only if all packets have
+             // timestamps, while for audio they're used if any have timestamps,
+@@ -522,28 +528,29 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 TrackInfo.HasTS = true;
+ 
+             int64_t StartSample = AVContexts[Track].CurrentSample;
+-            uint32_t SampleCount = IndexAudioPacket(Track, &Packet, AVContexts[Track], *TrackIndices);
++            uint32_t SampleCount = IndexAudioPacket(Track, Packet, AVContexts[Track], *TrackIndices);
+             TrackInfo.SampleRate = AVContexts[Track].CodecContext->sample_rate;
+ 
+             TrackInfo.AddAudioFrame(LastValidTS[Track],
+-                StartSample, SampleCount, KeyFrame, Packet.pos, Packet.flags & AV_PKT_FLAG_DISCARD);
++                StartSample, SampleCount, KeyFrame, Packet->pos, Packet->flags & AV_PKT_FLAG_DISCARD);
+         }
+ 
+-        if (!(Packet.flags & AV_PKT_FLAG_DISCARD))
+-            TrackInfo.LastDuration = Packet.duration;
++        if (!(Packet->flags & AV_PKT_FLAG_DISCARD))
++            TrackInfo.LastDuration = Packet->duration;
+ 
+-        av_packet_unref(&Packet);
++        av_packet_unref(Packet);
+     }
++    av_packet_free(&Packet);
+ 
+     TrackIndices->Finalize(AVContexts, FormatContext->iformat->name);
+     return TrackIndices.release();
+ }
+ 
+-void FFMS_Indexer::ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS) {
+-    if (!UseDTS && Packet.pts != AV_NOPTS_VALUE)
+-        TS = Packet.pts;
++void FFMS_Indexer::ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS) {
++    if (!UseDTS && Packet->pts != AV_NOPTS_VALUE)
++        TS = Packet->pts;
+     if (TS == AV_NOPTS_VALUE)
+         UseDTS = true;
+-    if (UseDTS && Packet.dts != AV_NOPTS_VALUE)
+-        TS = Packet.dts;
++    if (UseDTS && Packet->dts != AV_NOPTS_VALUE)
++        TS = Packet->dts;
+ }
+diff --git a/src/core/indexing.h b/src/core/indexing.h
+index 3cfc3c3..5c06868 100644
+--- a/src/core/indexing.h
++++ b/src/core/indexing.h
+@@ -80,10 +80,10 @@ private:
+     int64_t Filesize;
+     uint8_t Digest[20];
+ 
+-    void ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS);
++    void ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS);
+     void CheckAudioProperties(int Track, AVCodecContext *Context);
+     uint32_t IndexAudioPacket(int Track, AVPacket *Packet, SharedAVContext &Context, FFMS_Index &TrackIndices);
+-    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
++    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
+     void Free();
+ public:
+     FFMS_Indexer(const char *Filename);
+diff --git a/src/core/utils.cpp b/src/core/utils.cpp
+index ce67533..8a2e997 100644
+--- a/src/core/utils.cpp
++++ b/src/core/utils.cpp
+@@ -62,12 +62,6 @@ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo) {
+     }
+ }
+ 
+-void InitNullPacket(AVPacket &pkt) {
+-    av_init_packet(&pkt);
+-    pkt.data = nullptr;
+-    pkt.size = 0;
+-}
+-
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames) {
+     AP.SampleFormat = static_cast<FFMS_SampleFormat>(av_get_packed_sample_fmt(CTX->sample_fmt));
+     AP.BitsPerSample = av_get_bytes_per_sample(CTX->sample_fmt) * 8;
+diff --git a/src/core/utils.h b/src/core/utils.h
+index 9819dc7..003ab79 100644
+--- a/src/core/utils.h
++++ b/src/core/utils.h
+@@ -58,7 +58,6 @@ std::unique_ptr<T> make_unique(Args&&... args) {
+ }
+ 
+ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo);
+-void InitNullPacket(AVPacket &pkt);
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames);
+ 
+ void LAVFOpenFile(const char *SourceFile, AVFormatContext *&FormatContext, int Track);
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index 06bd161..b889970 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -673,30 +673,34 @@ void FFMS_VideoSource::DecodeNextFrame(int64_t &AStartTime, int64_t &Pos) {
+     if (HasPendingDelayedFrames())
+         return;
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
+-
+-    while (ReadFrame(&Packet) >= 0) {
+-        if (Packet.stream_index != VideoTrack) {
+-            av_packet_unref(&Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++
++    while (ReadFrame(Packet) >= 0) {
++        if (Packet->stream_index != VideoTrack) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+         if (AStartTime < 0)
+-            AStartTime = Frames.UseDTS ? Packet.dts : Packet.pts;
++            AStartTime = Frames.UseDTS ? Packet->dts : Packet->pts;
+ 
+         if (Pos < 0)
+-            Pos = Packet.pos;
++            Pos = Packet->pos;
+ 
+-        bool FrameFinished = DecodePacket(&Packet);
+-        av_packet_unref(&Packet);
+-        if (FrameFinished)
++        bool FrameFinished = DecodePacket(Packet);
++        av_packet_unref(Packet);
++        if (FrameFinished) {
++            av_packet_free(&Packet);
+             return;
++        }
+     }
+ 
+     // Flush final frames
+-    InitNullPacket(Packet);
+-    DecodePacket(&Packet);
++    DecodePacket(Packet);
++    av_packet_free(&Packet);
+ }
+ 
+ bool FFMS_VideoSource::SeekTo(int n, int SeekOffset) {
+-- 
+2.40.0
+
+From bf9e03e9e08534c024e5a744a6437c4aac160201 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:20:47 +0100
+Subject: [PATCH 2/3] configure: Remove deprecated API use
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ configure.ac | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index b35ef80bc..d19714d0f 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -102,10 +102,10 @@ CFLAGS="$_CFLAGS $FFMPEG_CFLAGS"
+
+ AC_DEFUN([TEST_FFMPEG],
+          [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+-            #include <libavcodec/avcodec.h>
++            #include <libavformat/avformat.h>
+             #include <libswscale/swscale.h>
+             ]],[[
+-                avcodec_register_all();
++                avformat_network_init();
+                 swscale_version();
+             ]])], [eval $1=yes], [eval $1=no])
+         ])
+
diff --git a/srcpkgs/ffms2/template b/srcpkgs/ffms2/template
index 68e8a0c14bce..2acfadac44b3 100644
--- a/srcpkgs/ffms2/template
+++ b/srcpkgs/ffms2/template
@@ -1,7 +1,7 @@
 # Template file for 'ffms2'
 pkgname=ffms2
 version=2.40
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-shared --disable-static"
 hostmakedepends="pkg-config autoconf automake libtool"

From c283911b3b4aaad23cfb7b4add62dc259f457b46 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 035/115] freerdp: revbump for ffmpeg-6.0

---
 .../freerdp/patches/ffmpeg6_aa2cb9aa.patch    | 42 +++++++++++++++++++
 srcpkgs/freerdp/template                      |  2 +-
 2 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch

diff --git a/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
new file mode 100644
index 000000000000..a4324da3a882
--- /dev/null
+++ b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
@@ -0,0 +1,42 @@
+From aa2cb9aa5ff5562433598ba168a466e0752bca0e Mon Sep 17 00:00:00 2001
+From: akallabeth <akallabeth@posteo.net>
+Date: Tue, 14 Feb 2023 07:48:54 +0100
+Subject: [PATCH] Fixed #8686: Update h264 to use new FFMPEG API
+
+---
+ channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c | 2 ++
+ libfreerdp/codec/h264_ffmpeg.c            | 2 ++
+ 2 files changed, 4 insertions(+)
+
+diff --git a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+index 339462d865f..beea80b7a1e 100644
+--- a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
++++ b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+@@ -239,8 +239,10 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYP
+ 		}
+ 	}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 	if (mdecoder->codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		mdecoder->codec_context->flags |= AV_CODEC_FLAG_TRUNCATED;
++#endif
+ 
+ 	return TRUE;
+ }
+diff --git a/libfreerdp/codec/h264_ffmpeg.c b/libfreerdp/codec/h264_ffmpeg.c
+index 8a23db2473c..896a333019b 100644
+--- a/libfreerdp/codec/h264_ffmpeg.c
++++ b/libfreerdp/codec/h264_ffmpeg.c
+@@ -615,10 +615,12 @@ static BOOL libavcodec_init(H264_CONTEXT* h264)
+ 			goto EXCEPTION;
+ 		}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 		if (sys->codecDecoder->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		{
+ 			sys->codecDecoderContext->flags |= AV_CODEC_FLAG_TRUNCATED;
+ 		}
++#endif
+ 
+ #ifdef WITH_VAAPI
+ 
diff --git a/srcpkgs/freerdp/template b/srcpkgs/freerdp/template
index 25e8aa9677f0..4d51c8189902 100644
--- a/srcpkgs/freerdp/template
+++ b/srcpkgs/freerdp/template
@@ -1,7 +1,7 @@
 # Template file for 'freerdp'
 pkgname=freerdp
 version=2.10.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_ALSA=ON -DWITH_CUPS=OFF -DWITH_FFMPEG=ON
  -DWITH_GSTREAMER_0_10=OFF -DWITH_GSTREAMER_1_0=OFF -DWITH_JPEG=ON

From 8229348cd208c64f53dd21553cbbf1863401b82f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 036/115] gerbera: revbump for ffmpeg-6.0

---
 srcpkgs/gerbera/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gerbera/template b/srcpkgs/gerbera/template
index ae14f35c767c..2dc0ac0ce03b 100644
--- a/srcpkgs/gerbera/template
+++ b/srcpkgs/gerbera/template
@@ -1,7 +1,7 @@
 # Template file for 'gerbera'
 pkgname=gerbera
 version=1.12.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_SYSTEMD=0 -DWITH_AVCODEC=1"
 hostmakedepends="pkg-config"

From 5f03ac501432b6e20b6b41d0f8cb668b5d36d89a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 037/115] goldendict: revbump for ffmpeg-6.0

---
 srcpkgs/goldendict/patches/ffmpeg4.patch |  21 --
 srcpkgs/goldendict/patches/ffmpeg5.patch | 232 +++++++++++++++++++++++
 srcpkgs/goldendict/template              |   2 +-
 3 files changed, 233 insertions(+), 22 deletions(-)
 delete mode 100644 srcpkgs/goldendict/patches/ffmpeg4.patch
 create mode 100644 srcpkgs/goldendict/patches/ffmpeg5.patch

diff --git a/srcpkgs/goldendict/patches/ffmpeg4.patch b/srcpkgs/goldendict/patches/ffmpeg4.patch
deleted file mode 100644
index f045fa27f54b..000000000000
--- a/srcpkgs/goldendict/patches/ffmpeg4.patch
+++ /dev/null
@@ -1,21 +0,0 @@
---- a/ffmpegaudio.cc.orig 2018-05-09 22:16:13.480659958 +0200
-+++ b/ffmpegaudio.cc      2018-05-09 22:16:50.748322790 +0200
-@@ -143,7 +143,7 @@
-     return false;
-   }
-
--  unsigned char * avioBuffer = ( unsigned char * )av_malloc( kBufferSize + FF_INPUT_BUFFER_PADDING_SIZE );
-+  unsigned char * avioBuffer = ( unsigned char * )av_malloc( kBufferSize + AV_INPUT_BUFFER_PADDING_SIZE );
-   if ( !avioBuffer )
-   {
-     errorString = QObject::tr( "av_malloc() failed." );
-@@ -380,7 +380,7 @@
-   }
-
-   if ( !Qt4x5::AtomicInt::loadAcquire( isCancelled_ ) &&
--       codecContext_->codec->capabilities & CODEC_CAP_DELAY )
-+       codecContext_->codec->capabilities & AV_CODEC_CAP_DELAY )
-   {
-     av_init_packet( &packet );
-     int gotFrame = 0;
-
diff --git a/srcpkgs/goldendict/patches/ffmpeg5.patch b/srcpkgs/goldendict/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..7cfc98ada368
--- /dev/null
+++ b/srcpkgs/goldendict/patches/ffmpeg5.patch
@@ -0,0 +1,232 @@
+From 03bbe01b79a1f07a6780cb60f23a087104c5d77b Mon Sep 17 00:00:00 2001
+From: Abs62 <ottomann@yandex.ru>
+Date: Fri, 30 Mar 2018 22:53:24 +0300
+Subject: [PATCH] Fix warnings while compile with FFMpeg 3.4.2 (issue #978)
+
+---
+ ffmpegaudio.cc | 68 +++++++++++++++++++++++++++++++++++++++++++++-----
+ 1 file changed, 62 insertions(+), 6 deletions(-)
+
+diff --git a/ffmpegaudio.cc b/ffmpegaudio.cc
+index ed1172bdd..56e8f788e 100644
+--- a/ffmpegaudio.cc
++++ b/ffmpegaudio.cc
+@@ -91,6 +91,7 @@ struct DecoderContext
+   QByteArray audioData_;
+   QDataStream audioDataStream_;
+   AVFormatContext * formatContext_;
++  AVCodec * codec_;
+   AVCodecContext * codecContext_;
+   AVIOContext * avioContext_;
+   AVStream * audioStream_;
+@@ -114,6 +115,7 @@ DecoderContext::DecoderContext( QByteArray const & audioData, QAtomicInt & isCan
+   audioData_( audioData ),
+   audioDataStream_( audioData_ ),
+   formatContext_( NULL ),
++  codec_( NULL ),
+   codecContext_( NULL ),
+   avioContext_( NULL ),
+   audioStream_( NULL ),
+@@ -143,7 +145,11 @@ bool DecoderContext::openCodec( QString & errorString )
+     return false;
+   }
+
++#if LIBAVCODEC_VERSION_MAJOR < 56 || ( LIBAVCODEC_VERSION_MAJOR == 56 && LIBAVCODEC_VERSION_MINOR < 56 )
+   unsigned char * avioBuffer = ( unsigned char * )av_malloc( kBufferSize + FF_INPUT_BUFFER_PADDING_SIZE );
++#else
++  unsigned char * avioBuffer = ( unsigned char * )av_malloc( kBufferSize + AV_INPUT_BUFFER_PADDING_SIZE );
++#endif
+   if ( !avioBuffer )
+   {
+     errorString = QObject::tr( "av_malloc() failed." );
+@@ -186,7 +192,11 @@ bool DecoderContext::openCodec( QString & errorString )
+   // Find audio stream, use the first audio stream if available
+   for ( unsigned i = 0; i < formatContext_->nb_streams; i++ )
+   {
++#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 33 )
+     if ( formatContext_->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO )
++#else
++      if ( formatContext_->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO )
++#endif
+     {
+       audioStream_ = formatContext_->streams[i];
+       break;
+@@ -198,22 +208,38 @@ bool DecoderContext::openCodec( QString & errorString )
+     return false;
+   }
+
++#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 33 )
+   codecContext_ = audioStream_->codec;
+-  AVCodec * codec = avcodec_find_decoder( codecContext_->codec_id );
+-  if ( !codec )
++  codec_ = avcodec_find_decoder( codecContext_->codec_id );
++  if ( !codec_ )
+   {
+     errorString = QObject::tr( "Codec [id: %1] not found." ).arg( codecContext_->codec_id );
+     return false;
+   }
++#else
++  codec_ = avcodec_find_decoder( audioStream_->codecpar->codec_id );
++  if ( !codec_ )
++  {
++    errorString = QObject::tr( "Codec [id: %1] not found." ).arg( audioStream_->codecpar->codec_id );
++    return false;
++  }
++  codecContext_ = avcodec_alloc_context3( codec_ );
++  if ( !codecContext_ )
++  {
++    errorString = QObject::tr( "avcodec_alloc_context3() failed." );
++    return false;
++  }
++  avcodec_parameters_to_context( codecContext_, audioStream_->codecpar );
++#endif
+
+-  ret = avcodec_open2( codecContext_, codec, NULL );
++  ret = avcodec_open2( codecContext_, codec_, NULL );
+   if ( ret < 0 )
+   {
+     errorString = QObject::tr( "avcodec_open2() failed: %1." ).arg( avErrorString( ret ) );
+     return false;
+   }
+
+-  av_log( NULL, AV_LOG_INFO, "Codec open: %s: channels: %d, rate: %d, format: %s\n", codec->long_name,
++  av_log( NULL, AV_LOG_INFO, "Codec open: %s: channels: %d, rate: %d, format: %s\n", codec_->long_name,
+           codecContext_->channels, codecContext_->sample_rate, av_get_sample_fmt_name( codecContext_->sample_fmt ) );
+   return true;
+ }
+@@ -252,10 +278,13 @@ void DecoderContext::closeCodec()
+
+   // Closing a codec context without prior avcodec_open2() will result in
+   // a crash in ffmpeg
+-  if ( audioStream_ && audioStream_->codec && audioStream_->codec->codec )
++  if ( audioStream_ && codecContext_ && codec_ )
+   {
+     audioStream_->discard = AVDISCARD_ALL;
+-    avcodec_close( audioStream_->codec );
++    avcodec_close( codecContext_ );
++#if LIBAVCODEC_VERSION_MAJOR > 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR >= 33 )
++    avcodec_free_context( &codecContext_ );
++#endif
+   }
+
+   avformat_close_input( &formatContext_ );
+@@ -356,6 +385,7 @@ bool DecoderContext::play( QString & errorString )
+     if ( packet.stream_index == audioStream_->index )
+     {
+       AVPacket pack = packet;
++#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 37 )
+       int gotFrame = 0;
+       do
+       {
+@@ -370,6 +400,19 @@ bool DecoderContext::play( QString & errorString )
+         pack.data += len;
+       }
+       while( pack.size > 0 );
++#else
++      int ret = avcodec_send_packet( codecContext_, &pack );
++      /* read all the output frames (in general there may be any number of them) */
++      while( ret >= 0 )
++      {
++        ret = avcodec_receive_frame( codecContext_, frame);
++
++        if ( Qt4x5::AtomicInt::loadAcquire( isCancelled_ ) || ret < 0 )
++          break;
++
++        playFrame( frame );
++      }
++#endif
+     }
+     // av_free_packet() must be called after each call to av_read_frame()
+ #if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 7 )
+@@ -379,6 +422,7 @@ bool DecoderContext::play( QString & errorString )
+ #endif
+   }
+
++#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 37 )
+   if ( !Qt4x5::AtomicInt::loadAcquire( isCancelled_ ) &&
+        codecContext_->codec->capabilities & CODEC_CAP_DELAY )
+   {
+@@ -391,6 +435,18 @@ bool DecoderContext::play( QString & errorString )
+       playFrame( frame );
+     }
+   }
++#else
++  /* flush the decoder */
++  av_init_packet( &packet );
++  int ret = avcodec_send_packet(codecContext_, &packet );
++  while( ret >= 0 )
++  {
++    ret = avcodec_receive_frame(codecContext_, frame);
++    if ( Qt4x5::AtomicInt::loadAcquire( isCancelled_ ) || ret < 0 )
++      break;
++    playFrame( frame );
++  }
++#endif
+
+ #if LIBAVCODEC_VERSION_MAJOR < 54
+   av_free( frame );
+32
+srcpkgs/goldendict/patches/ffmpeg5-2.patch
+Comment on this file
+@@ -0,0 +1,32 @@
+From 966f4a8b78e6324b930e5a50f2bb930bd87e565e Mon Sep 17 00:00:00 2001
+From: Abs62 <ottomann@yandex.ru>
+Date: Fri, 27 Sep 2019 17:00:52 +0300
+Subject: [PATCH] FFmpeg player: Fix some crashes on broken files
+
+---
+ ffmpegaudio.cc | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/ffmpegaudio.cc b/ffmpegaudio.cc
+index 56e8f788e..415fc79cb 100644
+--- a/ffmpegaudio.cc
++++ b/ffmpegaudio.cc
+@@ -51,7 +51,9 @@ AudioService & AudioService::instance()
+
+ AudioService::AudioService()
+ {
++#if LIBAVFORMAT_VERSION_MAJOR < 58 || ( LIBAVFORMAT_VERSION_MAJOR == 58 && LIBAVFORMAT_VERSION_MINOR < 9 )
+   av_register_all();
++#endif
+   ao_initialize();
+ }
+
+@@ -438,6 +440,8 @@ bool DecoderContext::play( QString & errorString )
+ #else
+   /* flush the decoder */
+   av_init_packet( &packet );
++  packet.data = NULL;
++  packet.size = 0;
+   int ret = avcodec_send_packet(codecContext_, &packet );
+   while( ret >= 0 )
+   {
+25
+srcpkgs/goldendict/patches/ffmpeg5-3.patch
+Comment on this file
+@@ -0,0 +1,25 @@
+From 8acb288c9e9bdb3c6bf2e803954dd3b6ac273c05 Mon Sep 17 00:00:00 2001
+From: Liao Junxuan <mikeljx@126.com>
+Date: Sun, 20 Feb 2022 12:28:05 +0800
+Subject: [PATCH] add support for ffmpeg 5.0
+
+---
+ ffmpegaudio.cc | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/ffmpegaudio.cc b/ffmpegaudio.cc
+index d550f4a77..7948d2187 100644
+--- a/ffmpegaudio.cc
++++ b/ffmpegaudio.cc
+@@ -94,7 +94,11 @@ struct DecoderContext
+   QByteArray audioData_;
+   QDataStream audioDataStream_;
+   AVFormatContext * formatContext_;
++#if LIBAVCODEC_VERSION_MAJOR < 59
+   AVCodec * codec_;
++#else
++  const AVCodec * codec_;
++#endif
+   AVCodecContext * codecContext_;
+   AVIOContext * avioContext_;
+   AVStream * audioStream_;
diff --git a/srcpkgs/goldendict/template b/srcpkgs/goldendict/template
index 4544ae710ee6..2ca4185e538a 100644
--- a/srcpkgs/goldendict/template
+++ b/srcpkgs/goldendict/template
@@ -9,7 +9,7 @@ makedepends="tiff-devel qt5-devel libvorbis-devel zlib-devel
  libXtst-devel hunspell-devel qt5-tools-devel qt5-declarative-devel
  qt5-webkit-devel lzo-devel bzip2-devel libao-devel qt5-svg-devel
  libeb-devel qt5-x11extras-devel ffmpeg-devel liblzma-devel"
-short_desc="A feature-rich dictionary lookup program"
+short_desc="Feature-rich dictionary lookup program"
 maintainer="John <me@johnnynator.dev>"
 license="GPL-3.0-or-later"
 homepage="http://goldendict.org/"

From ea247676b2937bf69f5c1cda5fa60f084603d20b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 038/115] gst-libav: revbump for ffmpeg-6.0

---
 srcpkgs/gst-libav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index e9a79dc650a5..f082bd211c65 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.20.3
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"

From f862b7061a1c5ac994a6f5a35fc3580f4de6e53c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 039/115] gst-plugins-bad1: revbump for ffmpeg-6.0

---
 srcpkgs/gst-plugins-bad1/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index f55f82fd4c77..dc9d389734e1 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-plugins-bad1'
 pkgname=gst-plugins-bad1
-version=1.20.3
-revision=3
+version=1.22.2
+revision=2
 build_helper="gir"
 build_style=meson
 configure_args="-Dpackage-origin=https://voidlinux.org -Ddoc=disabled

From 4e0d5c5c9414472221d63fbbf9278bf4b0bb7f03 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 040/115] gst-rtsp-server: revbump for ffmpeg-6.0

---
 srcpkgs/gst-rtsp-server/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index 33cd64ceb95e..8ceea8d34b4b 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
 version=1.20.3
-revision=2
+revision=3
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="glib-devel gst-plugins-bad1-devel gobject-introspection

From bb2b2727e4ea99d7d3ef8c000696fc13180e053c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 041/115] guvcview: update to 2.0.8.

---
 srcpkgs/guvcview/patches/fix-include.patch | 10 ++++++++++
 srcpkgs/guvcview/template                  |  5 ++---
 2 files changed, 12 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/guvcview/patches/fix-include.patch

diff --git a/srcpkgs/guvcview/patches/fix-include.patch b/srcpkgs/guvcview/patches/fix-include.patch
new file mode 100644
index 000000000000..503c2af3b78c
--- /dev/null
+++ b/srcpkgs/guvcview/patches/fix-include.patch
@@ -0,0 +1,10 @@
+--- a/guvcview/guvcview.c
++++ b/guvcview/guvcview.c
+@@ -28,6 +28,7 @@
+ #include <sys/stat.h>
+ #include <sys/resource.h>
+ #include <errno.h>
++#include <locale.h>
+ 
+ #include "gview.h"
+ #include "gviewv4l2core.h"
diff --git a/srcpkgs/guvcview/template b/srcpkgs/guvcview/template
index 345cf6006f24..86a7fd619612 100644
--- a/srcpkgs/guvcview/template
+++ b/srcpkgs/guvcview/template
@@ -1,8 +1,7 @@
 # Template file for 'guvcview'
 pkgname=guvcview
-version=2.0.7
+version=2.0.8
 revision=1
-create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-static --disable-debian-menu"
 hostmakedepends="pkg-config intltool autoconf automake libtool glib-devel"
@@ -14,7 +13,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="http://guvcview.sourceforge.net/"
 distfiles="${SOURCEFORGE_SITE}/${pkgname}/${pkgname}-src-${version}.tar.bz2"
-checksum=f47d51fbd06e44eeaa1a82f4a153c927527c90d94514197a70b2956028cc8ad4
+checksum=a21f4e448286666cf27bafef5290cc953a0a1796b752e5bbe521266dc1230c81
 
 post_patch() {
 	sed '31a#include <locale.h>' -i  guvcview/guvcview.c

From bce6e9ef6c38dd53cf6a6e54266d825afaf28b78 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 042/115] handbrake: update to 1.6.1

---
 .../patches/fix-missing-x265-link-flag.patch    | 11 ++++++-----
 .../handbrake/patches/libhb-vpl-include.patch   | 15 +++++++++++++++
 srcpkgs/handbrake/template                      | 17 ++++++++++-------
 3 files changed, 31 insertions(+), 12 deletions(-)
 create mode 100644 srcpkgs/handbrake/patches/libhb-vpl-include.patch

diff --git a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
index 26db03867a0c..d6bb2eda627a 100644
--- a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
+++ b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
@@ -1,14 +1,15 @@
 --- a/gtk/configure.ac
 +++ b/gtk/configure.ac
 @@ -203,7 +203,7 @@
- 
+
  AM_CONDITIONAL([MINGW], [test "x$mingw_flag" = "xyes"])
- 
--HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg"
-+HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -ldl"
+
+-HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc"
++HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc -ldl"
  HB_CPPFLAGS="$HB_CPPFLAGS $HBINC"
- 
+
  PKG_CHECK_MODULES([x264], [x264], sys_x264=yes, sys_x264=no)
+
 --- a/test/module.defs
 +++ b/test/module.defs
 @@ -69,6 +69,9 @@
diff --git a/srcpkgs/handbrake/patches/libhb-vpl-include.patch b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
new file mode 100644
index 000000000000..298f9f4ab28f
--- /dev/null
+++ b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
@@ -0,0 +1,15 @@
+--- a/libhb/module.defs	2023-01-22 11:36:49.000000000 -0500
++++ b/libhb/module.defs	2023-04-03 22:37:52.395467010 -0400
+@@ -46,11 +46,7 @@
+ LIBHB.GCC.I += $(LIBHB.build/) $(CONTRIB.build/)include
+ 
+ ifeq (1,$(FEATURE.qsv))
+-    ifeq ($(HOST.system),freebsd))
+-        LIBHB.GCC.I += $(LOCALBASE)/include/vpl
+-    else
+-        LIBHB.GCC.I += $(CONTRIB.build/)include/vpl
+-    endif
++    LIBHB.GCC.I += /usr/include/vpl
+ endif
+ 
+ ifneq (,$(filter $(HOST.system),freebsd netbsd openbsd))
diff --git a/srcpkgs/handbrake/template b/srcpkgs/handbrake/template
index ca5e4571e49c..c32cb1bfa31f 100644
--- a/srcpkgs/handbrake/template
+++ b/srcpkgs/handbrake/template
@@ -1,10 +1,10 @@
 # Template file for 'handbrake'
 pkgname=handbrake
-version=1.5.1
+version=1.6.1
 revision=1
 build_style=gnu-configure
 configure_args="--force --disable-gtk-update-checks --disable-df-fetch --harden
- $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc)"
+ $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc) $(vopt_enable qsv)"
 make_build_args="-C ${XBPS_TRIPLET}"
 make_install_args="-C ${XBPS_TRIPLET}"
 hostmakedepends="automake cmake gettext-devel glib-devel intltool libtool m4 meson nasm pkg-config python3"
@@ -12,8 +12,11 @@ makedepends="bzip2-devel ffmpeg-devel gst-plugins-base1-devel gtk+3-devel
  jansson-devel lame-devel libass-devel libbluray-devel libdav1d-devel
  libdvdnav-devel libdvdread-devel libgudev-devel libnuma-devel
  libsamplerate-devel libtheora-devel libvorbis-devel libvpx-devel libxml2-devel
- opus-devel speex-devel x264-devel x265-devel zimg-devel
+ opus-devel speex-devel x264-devel x265-devel zimg-devel libsvt-av1-devel
  $(vopt_if fdk_aac fdk-aac-devel)
+ $(vopt_if qsv libva-devel)
+ $(vopt_if qsv libdrm-devel)
+ $(vopt_if qsv onevpl-devel)
  $(vopt_if nvenc nv-codec-headers)"
 depends="desktop-file-utils gst-plugins-good1 hicolor-icon-theme"
 short_desc="Multithreaded video transcoder"
@@ -21,15 +24,15 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-2.0-only"
 homepage="https://handbrake.fr/"
 distfiles="https://github.com/HandBrake/HandBrake/releases/download/${version}/HandBrake-${version}-source.tar.bz2"
-checksum=3999fe06d5309c819799a73a968a8ec3840e7840c2b64af8f5cdb7fd8c9430f0
+checksum=94ccfe03db917a91650000c510f7fd53f844da19f19ad4b4be1b8f6bc31a8d4c
 nocross=yes
 
-build_options="fdk_aac nvenc"
+build_options="fdk_aac nvenc qsv"
 
 case "$XBPS_TARGET_MACHINE" in
 	x86_64*|i686*)
 		CFLAGS="-msse"
-		build_options_default="nvenc"
+		build_options_default="nvenc qsv"
 		;;
 esac
 
@@ -37,7 +40,7 @@ pre_configure() {
 	# use system libraries, don't download them
 	rm -rf contrib/
 	for module in fdk-aac ffmpeg libbluray libdav1d libdvdnav libdvdread nvenc \
-		x265 zimg; do
+		x265 zimg svt-av1 libvpl; do
 	    vsed -i "/MODULES += contrib\/${module}/d" make/include/main.defs
 	done
 }

From 598fe819eeabb5075a1e0b4a7219ddc89381cc83 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 043/115] hedgewars: revbump for ffmpeg4-4.4.3

---
 srcpkgs/hedgewars/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/hedgewars/template b/srcpkgs/hedgewars/template
index 419f29b98b44..926fe4fe3e68 100644
--- a/srcpkgs/hedgewars/template
+++ b/srcpkgs/hedgewars/template
@@ -1,13 +1,13 @@
 # Template file for 'hedgewars'
 pkgname=hedgewars
 version=1.0.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DNOSERVER=1 -DDATA_INSTALL_DIR=/usr/share/${pkgname}
  -DPHYSFS_SYSTEM=1 -DMINIMAL_FLAGS=1"
 make_cmd=make
 hostmakedepends="lua51 pkg-config qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
+makedepends="ffmpeg4-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
  SDL2_mixer-devel SDL2_net-devel SDL2_ttf-devel"
 depends="libfreeglut"
 short_desc="Funny turn-based artillery game, featuring fighting Hedgehogs!"

From dca53e4654d534643b740e92e8a227190e0c07ad Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 044/115] idjc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/idjc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/idjc/template b/srcpkgs/idjc/template
index df60318b3db9..36a75baf597c 100644
--- a/srcpkgs/idjc/template
+++ b/srcpkgs/idjc/template
@@ -1,11 +1,11 @@
 # Template file for 'idjc'
 pkgname=idjc
 version=0.9.1
-revision=3
+revision=4
 build_style=gnu-configure
 hostmakedepends="pkg-config git python3 automake gettext-devel libtool"
 makedepends="libvorbis-devel libogg-devel jack-devel libsamplerate-devel
- libflac-devel libsndfile-devel mpg123-devel ffmpeg-devel speex-devel
+ libflac-devel libsndfile-devel mpg123-devel ffmpeg4-devel speex-devel
  glib-devel pixman-devel lame-devel python3-gobject-devel libshout-idjc-devel
  opus-devel twolame-devel python3-mutagen python3-devel"
 depends="python3-gobject python3-mutagen desktop-file-utils shared-mime-info python3-dbus jack"

From ce1e1cde8e6296b757c2215b83cbde361e2fc912 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 045/115] kfilemetadata5: revbump for ffmpeg-6.0

---
 srcpkgs/kfilemetadata5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kfilemetadata5/template b/srcpkgs/kfilemetadata5/template
index 8980121fbc69..f662a2043f93 100644
--- a/srcpkgs/kfilemetadata5/template
+++ b/srcpkgs/kfilemetadata5/template
@@ -1,7 +1,7 @@
 # Template file for 'kfilemetadata5'
 pkgname=kfilemetadata5
 version=5.105.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="kcoreaddons extra-cmake-modules pkg-config qt5-host-tools qt5-qmake
  gettext kcoreaddons python3"

From 6bb5ceb8ff87d9e30f6cd55318dbee4d9f5af4b5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 046/115] kid3: revbump for ffmpeg-6.0

---
 srcpkgs/kid3/patches/ffmpeg5.patch | 17 +++++++++++++++++
 srcpkgs/kid3/template              |  2 +-
 2 files changed, 18 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/kid3/patches/ffmpeg5.patch

diff --git a/srcpkgs/kid3/patches/ffmpeg5.patch b/srcpkgs/kid3/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..135fc50e07c9
--- /dev/null
+++ b/srcpkgs/kid3/patches/ffmpeg5.patch
@@ -0,0 +1,17 @@
+# https://aur.archlinux.org/cgit/aur.git/diff/ffmpeg5.patch?h=kid3-cli&id=12410a74906612e7efc0ec8fbce739b4a0fef7e7
+diff --git a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+index e156d424..e12b9abd 100644
+--- a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
++++ b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+@@ -232,7 +232,11 @@ private:
+   friend class Format;
+   friend class Converter;
+   AVCodecContext* m_ptr;
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 0, 0)
+   AVCodec* m_impl;
++#else
++  const AVCodec* m_impl;
++#endif
+   AVFrame* m_frame;
+   bool m_opened;
+ };
diff --git a/srcpkgs/kid3/template b/srcpkgs/kid3/template
index 456206d90e16..f32f9decb0e7 100644
--- a/srcpkgs/kid3/template
+++ b/srcpkgs/kid3/template
@@ -1,7 +1,7 @@
 # Template file for 'kid3'
 pkgname=kid3
 version=3.9.1
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DWITH_APPS='CLI;$(vopt_if KDE KDE Qt)'
  -DWITH_DOCBOOKDIR=/usr/share/xsl/docbook -DWITH_FLAC=$(vopt_if flac ON OFF)

From 231df7aa1d602ce37afc148330d805c303541398 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 047/115] kodi: revbump for ffmpeg4-4.4.3

---
 srcpkgs/kodi/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/kodi/template b/srcpkgs/kodi/template
index 8057964d78a3..6cc1874be7ba 100644
--- a/srcpkgs/kodi/template
+++ b/srcpkgs/kodi/template
@@ -1,7 +1,7 @@
 # Template file for 'kodi'
 pkgname=kodi
 version=19.4
-revision=6
+revision=7
 _codename="Matrix"
 build_style=cmake
 configure_args="-DWITH_FFMPEG=/usr -DENABLE_LDGOLD=OFF
@@ -54,7 +54,7 @@ makedepends="
  libmad-devel fontconfig-devel libXinerama-devel libsamplerate-devel libmms-devel
  enca-devel boost-devel libcurl-devel libva-devel libvdpau-devel libass-devel
  libbluetooth-devel yajl-devel libplist-devel librtmp-devel tinyxml-devel
- taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg-devel
+ taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg4-devel
  giflib-devel libxslt-devel gnutls-devel libssh-devel libmicrohttpd-devel
  libcec-devel dcadec-devel flatbuffers-devel fmt-devel lcms2-devel
  libfstrcmp-devel rapidjson libcdio-paranoia spdlog libwaylandpp-devel

From 7c4fe406401211ce12ee996a0e0a610652d4b4aa Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 048/115] kpipewire: revbump for ffmpeg-6.0

---
 srcpkgs/kpipewire/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kpipewire/template b/srcpkgs/kpipewire/template
index 05ad025944da..7aa120e6ba94 100644
--- a/srcpkgs/kpipewire/template
+++ b/srcpkgs/kpipewire/template
@@ -1,7 +1,7 @@
 # Template file for 'kpipewire'
 pkgname=kpipewire
 version=5.27.5
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules plasma-wayland-protocols gettext
  qt5-qmake qt5-host-tools pkg-config wayland-devel kcoreaddons

From 8ce4a81392a2a11296685222498ec731e286aae9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 049/115] libextractor: revbump for ffmpeg4-4.4.3

---
 srcpkgs/libextractor/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libextractor/template b/srcpkgs/libextractor/template
index ddd4790f93e8..1fb9ca56a96a 100644
--- a/srcpkgs/libextractor/template
+++ b/srcpkgs/libextractor/template
@@ -7,7 +7,7 @@ configure_args="--disable-static"
 hostmakedepends="pkg-config"
 makedepends="zlib-devel bzip2-devel exiv2-devel tiff-devel libpng-devel
  libjpeg-turbo-devel libvorbis-devel libflac-devel giflib-devel libmpeg2-devel
- ffmpeg-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
+ ffmpeg4-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
 short_desc="Library used to extract meta data from files"
 maintainer="Martin Riese <grauehaare@gmx.de>"
 license="GPL-3.0-or-later"

From 21dc0c07a9a99ff23fb35b405a223e1ce0d25d64 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 050/115] libopenal: revbump for ffmpeg-6.0

---
 srcpkgs/libopenal/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenal/template b/srcpkgs/libopenal/template
index 77218f9e539d..3f49ed75a1fd 100644
--- a/srcpkgs/libopenal/template
+++ b/srcpkgs/libopenal/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenal'
 pkgname=libopenal
 version=1.22.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DALSOFT_EXAMPLES=OFF"
 hostmakedepends="pkg-config"

From 760972ce8ce80b16f0b0ee9ead5679f00fe1659e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 051/115] libopenshot: revbump for ffmpeg-6.0

---
 srcpkgs/libopenshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenshot/template b/srcpkgs/libopenshot/template
index db831f69b474..81aa0d7136d9 100644
--- a/srcpkgs/libopenshot/template
+++ b/srcpkgs/libopenshot/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenshot'
 pkgname=libopenshot
 version=0.3.0
-revision=1
+revision=2
 build_style=cmake
 # Builds fail with Ruby-2.4.1
 configure_args="-DENABLE_RUBY=OFF -DUSE_SYSTEM_JSONCPP=ON"

From 4a27b751fa57f3327222bc8815e5c89350e90b01 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 052/115] loudgain: revbump for ffmpeg-6.0

---
 srcpkgs/loudgain/patches/ffmpeg5.patch | 11 +++++++++++
 srcpkgs/loudgain/template              |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/loudgain/patches/ffmpeg5.patch

diff --git a/srcpkgs/loudgain/patches/ffmpeg5.patch b/srcpkgs/loudgain/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..16d4510ee98f
--- /dev/null
+++ b/srcpkgs/loudgain/patches/ffmpeg5.patch
@@ -0,0 +1,11 @@
+--- a/src/scan.c	2019-09-06 11:31:19.000000000 -0400
++++ b/src/scan.c	2023-03-23 11:15:40.867968521 -0400
+@@ -69,8 +69,6 @@
+ 	 * It is now useless
+ 	 * https://github.com/FFmpeg/FFmpeg/blob/70d25268c21cbee5f08304da95be1f647c630c15/doc/APIchanges#L86
+ 	 */
+-  if (avformat_version() < AV_VERSION_INT(58,9,100))
+-    av_register_all();
+ 
+ 	av_log_set_callback(scan_av_log);
+ 
diff --git a/srcpkgs/loudgain/template b/srcpkgs/loudgain/template
index da4f2d56e94c..4d6bf29efb4f 100644
--- a/srcpkgs/loudgain/template
+++ b/srcpkgs/loudgain/template
@@ -1,7 +1,7 @@
 # Template file for 'loudgain'
 pkgname=loudgain
 version=0.6.8
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libebur128-devel taglib-devel ffmpeg-devel"

From 7aa75a7cf2c7bea2d13c7707b48bc97e4aead14c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 053/115] mediastreamer: revbump for ffmpeg4-4.4.3

---
 srcpkgs/mediastreamer/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mediastreamer/template b/srcpkgs/mediastreamer/template
index d0e97e858e29..1bde031443a5 100644
--- a/srcpkgs/mediastreamer/template
+++ b/srcpkgs/mediastreamer/template
@@ -1,11 +1,11 @@
 # Template file for 'mediastreamer'
 pkgname=mediastreamer
 version=5.2.6
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_STRICT=0 -DENABLE_UNIT_TESTS=0"
 hostmakedepends="python3"
-makedepends="bzrtp-devel ffmpeg-devel glew-devel libXv-devel libsrtp-devel
+makedepends="bzrtp-devel ffmpeg4-devel glew-devel libXv-devel libsrtp-devel
  libupnp-devel libvpx-devel mbedtls-devel opus-devel ortp-devel pulseaudio-devel
  libtheora-devel speex-devel v4l-utils-devel bcg729-devel bcmatroska2-devel libgsm-devel"
 # zxing-cpp-devel (1.2.0 probably not compatible, check again after updaing xzing)

From 48c5815a7facce4d04b49968c7cc7acf0dfeb117 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 054/115] mgba: revbump for ffmpeg-6.0

---
 srcpkgs/mgba/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mgba/template b/srcpkgs/mgba/template
index ae0504311eee..d31295a0cd3d 100644
--- a/srcpkgs/mgba/template
+++ b/srcpkgs/mgba/template
@@ -1,7 +1,7 @@
 # Template file for 'mgba'
 pkgname=mgba
 version=0.10.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake desktop-file-utils"
 makedepends="SDL2-devel ffmpeg-devel libedit-devel libepoxy-devel libmagick-devel

From 1f586ea5f011f5967536db337d427df12316eea8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 055/115] minidlna: revbump for ffmpeg-6.0

---
 srcpkgs/minidlna/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/minidlna/template b/srcpkgs/minidlna/template
index e8081b1cbc67..9ee9714861fd 100644
--- a/srcpkgs/minidlna/template
+++ b/srcpkgs/minidlna/template
@@ -1,7 +1,7 @@
 # Template file for 'minidlna'
 pkgname=minidlna
 version=1.3.2
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="
  --sbindir=/usr/bin

From 64ae1193ed37f1015901580b61bcadd027cbeec2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 056/115] mixxx: revbump for ffmpeg-6.0

---
 srcpkgs/mixxx/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mixxx/template b/srcpkgs/mixxx/template
index 619ddca0d332..4b9ea00d3fb3 100644
--- a/srcpkgs/mixxx/template
+++ b/srcpkgs/mixxx/template
@@ -1,7 +1,7 @@
 # Template file for 'mixxx'
 pkgname=mixxx
 version=2.3.3
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="extra-cmake-modules pkg-config protobuf qt5-host-tools qt5-devel"

From ec39f1e018f8bc5de535dfb3592dca2087af05b0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 057/115] mlt: revbump for ffmpeg4-4.4.3

---
 srcpkgs/mlt/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mlt/template b/srcpkgs/mlt/template
index 8933eb4e7bb9..73353fedafb5 100644
--- a/srcpkgs/mlt/template
+++ b/srcpkgs/mlt/template
@@ -1,14 +1,14 @@
 # Template file for 'mlt'
 pkgname=mlt
 version=6.26.1
-revision=1
+revision=2
 build_style=configure
 configure_args="--prefix=/usr --libdir=/usr/lib$XBPS_TARGET_WORDSIZE
  --enable-gpl --enable-gpl3 --disable-swfdec --without-kde
  --swig-languages=python"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which"
 # XXX: movit vid.stab
-makedepends="alsa-lib-devel ffmpeg-devel gtk+-devel jack-devel ladspa-sdk
+makedepends="alsa-lib-devel ffmpeg4-devel gtk+-devel jack-devel ladspa-sdk
  libexif-devel libsamplerate-devel libxml2-devel sox-devel SDL_image-devel
  fftw-devel frei0r-plugins python3-devel pulseaudio-devel movit-devel
  libvidstab-devel libatomic-devel"

From 65ff5a4af4eaba361a189adc66f1af09017216a0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 058/115] moc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/moc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/moc/template b/srcpkgs/moc/template
index c42be650a1d2..d4f0eefbad52 100644
--- a/srcpkgs/moc/template
+++ b/srcpkgs/moc/template
@@ -1,10 +1,10 @@
 # Template file for 'moc'
 pkgname=moc
 version=2.5.2
-revision=6
+revision=7
 build_style=gnu-configure
 hostmakedepends="pkg-config"
-makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg-devel
+makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg4-devel
  jack-devel alsa-lib-devel libltdl-devel libflac-devel libvorbis-devel
  libmad-devel libmpcdec-devel libmodplug-devel libid3tag-devel faad2-devel
  taglib-devel libsndfile-devel wavpack-devel speex-devel libsamplerate-devel

From 03417b0645b3a17afe8e6be0a2931a76d577af5d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 059/115] motion: revbump for ffmpeg-6.0

---
 srcpkgs/motion/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/motion/template b/srcpkgs/motion/template
index 3cf3c3035c5b..7dca12d851e3 100644
--- a/srcpkgs/motion/template
+++ b/srcpkgs/motion/template
@@ -1,7 +1,7 @@
 # Template file for 'motion'
 pkgname=motion
 version=4.5.1
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake pkg-config gettext-devel tar"
 makedepends="ffmpeg-devel libmicrohttpd-devel v4l-utils-devel gettext-devel"

From 9fc3376d9f8a8a46506e1b940150e90eeff8cf15 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 060/115] mpv: revbump for ffmpeg-6.0

---
 srcpkgs/mpv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpv/template b/srcpkgs/mpv/template
index e163c496c6eb..d4fefbf5e3c7 100644
--- a/srcpkgs/mpv/template
+++ b/srcpkgs/mpv/template
@@ -1,7 +1,7 @@
 # Template file for 'mpv'
 pkgname=mpv
 version=0.35.1
-revision=2
+revision=3
 build_style=meson
 configure_args="-Dcdda=enabled -Ddvbin=enabled -Ddvdnav=enabled
  -Dlibmpv=true -Dcplugins=enabled

From 4a2cd674765ca6f8d602acf1922e9c8a0655378a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 061/115] musikcube: revbump for ffmpeg-6.0

---
 srcpkgs/musikcube/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/musikcube/template b/srcpkgs/musikcube/template
index 7c569303c054..a4dea460c371 100644
--- a/srcpkgs/musikcube/template
+++ b/srcpkgs/musikcube/template
@@ -1,7 +1,7 @@
 # Template file for 'musikcube'
 pkgname=musikcube
 version=3.0.0
-revision=1
+revision=2
 build_style=cmake
 make_cmd=make
 configure_args="-DNO_NCURSESW=1"

From 7f1be92aeb90ca1fe4ba2f641ecb8befb914b5ed Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 062/115] notcurses: revbump for ffmpeg-6.0

---
 srcpkgs/notcurses/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/notcurses/template b/srcpkgs/notcurses/template
index 6dd8a091319f..3110c30c9aff 100644
--- a/srcpkgs/notcurses/template
+++ b/srcpkgs/notcurses/template
@@ -1,7 +1,7 @@
 # Template file for 'notcurses'
 pkgname=notcurses
 version=3.0.9
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DUSE_STATIC=ON $(vopt_bool man USE_PANDOC)"
 hostmakedepends="pkg-config $(vopt_if man pandoc)"

From 223a984baa81d44fccd2ad6ad4570475bbc17f70 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 063/115] obs: revbump for ffmpeg-6.0

---
 srcpkgs/obs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/obs/template b/srcpkgs/obs/template
index 7b69c630d30d..2c8d68d71f3a 100644
--- a/srcpkgs/obs/template
+++ b/srcpkgs/obs/template
@@ -1,7 +1,7 @@
 # Template file for 'obs'
 pkgname=obs
 version=29.1.2
-revision=1
+revision=2
 archs="i686* x86_64* ppc64le* aarch64*"
 build_style=cmake
 configure_args="-DOBS_VERSION_OVERRIDE=${version} -DENABLE_JACK=ON

From 588f2fd1a22eb3ab086940dcd03a30a094a6cc77 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 064/115] olive: revbump for ffmpeg4-4.4.3

---
 srcpkgs/olive/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/olive/template b/srcpkgs/olive/template
index 12a46936c990..5c2917b9c512 100644
--- a/srcpkgs/olive/template
+++ b/srcpkgs/olive/template
@@ -1,10 +1,10 @@
 # Template file for 'olive'
 pkgname=olive
 version=0.1.2
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools pkg-config"
-makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg-devel frei0r-plugins"
+makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg4-devel frei0r-plugins"
 short_desc="Non-linear video editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"

From c47b7195ebf0e9d85b26a809c2a0009f8e3f7f06 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 065/115] omxplayer: revbump for ffmpeg4-4.4.3

---
 srcpkgs/omxplayer/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/omxplayer/template b/srcpkgs/omxplayer/template
index e70bf7873d4d..0e9bc70e7c8e 100644
--- a/srcpkgs/omxplayer/template
+++ b/srcpkgs/omxplayer/template
@@ -1,10 +1,10 @@
 # Template file for 'omxplayer'
 pkgname=omxplayer
 version=20190102
-revision=1
+revision=2
 short_desc="Commandline OMX player for the Raspberry Pi"
 maintainer="Orphaned <orphan@voidlinux.org>"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://github.com/popcornmix/omxplayer"
 
 _commit="f06235cc9690a6d58187514452df8cf8fcdaacec"
@@ -15,7 +15,7 @@ checksum=af2d9450f8947842ea8c401fe9f71eec444013ebbdee29f2ac828c9c493c1329
 archs="armv6l* armv7l*"
 build_style=gnu-makefile
 hostmakedepends="curl pkg-config"
-makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg-devel dbus-devel"
+makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg4-devel dbus-devel"
 depends="freefont-ttf"
 
 do_build() {

From f1b1b10819b6d609fc6ee5d7c31cbf25964aacfc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 066/115] openimageio: revbump for ffmpeg-6.0

---
 common/shlibs                | 2 ++
 srcpkgs/openimageio/template | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/shlibs b/common/shlibs
index 2888a24dd1c4..c54567fd5617 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2263,6 +2263,8 @@ libxmp.so.4 libxmp-4.3.7_1
 libKF5ThreadWeaver.so.5 threadweaver-5.26.0_1
 libOpenImageIO_Util.so.2.4 openimageio-2.4.9.0_1
 libOpenImageIO.so.2.4 openimageio-2.4.9.0_1
+libOpenImageIO_Util.so.2.4 openimageio-2.4.8.1_1
+libOpenImageIO.so.2.4 openimageio-2.4.8.1_1
 libOpenColorIO.so.2.1 opencolorio-2.1.2_1
 libpystring.so.1 pystring-1.1.3_1
 libyaml-cpp.so.0.7 yaml-cpp-0.7.0_1
diff --git a/srcpkgs/openimageio/template b/srcpkgs/openimageio/template
index c2d36b4b3539..0e9e22e9685d 100644
--- a/srcpkgs/openimageio/template
+++ b/srcpkgs/openimageio/template
@@ -1,7 +1,7 @@
 # Template file for 'openimageio'
 pkgname=openimageio
 version=2.4.9.0
-revision=4
+revision=5
 build_style=cmake
 build_helper=qemu
 configure_args="-DUSE_QT=0 -DUSE_PYTHON=0 -DOIIO_BUILD_TESTS=0

From 9c976923614e54c40d072abb1cc2c173cec29bb6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 067/115] openshot: revbump for ffmpeg-6.0

---
 srcpkgs/openshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openshot/template b/srcpkgs/openshot/template
index 322717d40abc..c074e0338773 100644
--- a/srcpkgs/openshot/template
+++ b/srcpkgs/openshot/template
@@ -1,7 +1,7 @@
 # Template file for 'openshot'
 pkgname=openshot
 version=3.0.0
-revision=1
+revision=2
 build_style=python3-module
 hostmakedepends="python3 python3-setuptools"
 makedepends="ffmpeg-devel python3-PyQt5"

From 45769be18749a1d17b0437a5f39cdf0eb8f48836 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 068/115] opentoonz: revbump for ffmpeg-6.0

---
 srcpkgs/opentoonz/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/opentoonz/template b/srcpkgs/opentoonz/template
index ee9f7603f55f..3e81834ca0ed 100644
--- a/srcpkgs/opentoonz/template
+++ b/srcpkgs/opentoonz/template
@@ -1,7 +1,7 @@
 # Template file for 'opentoonz'
 pkgname=opentoonz
 version=1.6.0
-revision=2
+revision=3
 build_wrksrc="toonz/sources"
 build_style=cmake
 make_cmd=make

From de66dbcf401ce76c339f6867ffc712c2d6dbeb94 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 069/115] pianobar: revbump for ffmpeg-6.0

---
 srcpkgs/pianobar/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pianobar/template b/srcpkgs/pianobar/template
index a9b29e91993f..81efcd122c4d 100644
--- a/srcpkgs/pianobar/template
+++ b/srcpkgs/pianobar/template
@@ -1,7 +1,7 @@
 # Template file for 'pianobar'
 pkgname=pianobar
 version=2022.04.01
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="V=1"
 hostmakedepends="pkg-config"

From 80cbf68c2b276fa4730f71a6f588a902a81b56bc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 070/115] ppsspp: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ppsspp/template | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/ppsspp/template b/srcpkgs/ppsspp/template
index 7984a733d4be..15a42fd2c993 100644
--- a/srcpkgs/ppsspp/template
+++ b/srcpkgs/ppsspp/template
@@ -1,7 +1,7 @@
 # Template file for 'ppsspp'
 pkgname=ppsspp
 version=1.14.4
-revision=1
+revision=2
 _glslang_commit=dc11adde23c455a24e13dd54de9b4ede8bdd7db8
 _SPIRV_Cross_commit=9acb9ec31f5a8ef80ea6b994bb77be787b08d3d1
 _armips_commit=6719edebaae03330ee5441d9b28280672edf00d5
@@ -13,7 +13,7 @@ configure_args="-DHEADLESS=1 -DUSE_SYSTEM_FFMPEG=1 -DUNITTEST=ON
  -DUSING_QT_UI=$(vopt_if qt ON OFF) -DUSE_SYSTEM_ZSTD=ON
  -DARMIPS_USE_STD_FILESYSTEM=ON"
 hostmakedepends="pkg-config python3 $(vopt_if qt qt5-host-tools)"
-makedepends="zlib-devel glew-devel ffmpeg-devel libzip-devel
+makedepends="zlib-devel glew-devel ffmpeg4-devel libzip-devel
  snappy-devel rapidjson libpng-devel libzstd-devel
  $(vopt_if sdl2 SDL2-devel) $(vopt_if wayland wayland-devel)
  $(vopt_if qt 'qt5-devel qt5-multimedia-devel')"
@@ -62,13 +62,12 @@ post_extract() {
 	mv ${wrksrc}/miniupnp-${_miniupnp_commit} ${wrksrc}/ext/miniupnp
 }
 
-post_patch(){
+post_patch() {
 	# disable git versioning
 	vsed -e 's|find_package(Git)|# &|' -i git-version.cmake
 }
 
 do_install() {
-	vlicense LICENSE.TXT
 	vinstall icons/icon.svg 644 usr/share/pixmaps ppsspp.svg
 	vinstall Qt/PPSSPP.desktop 644 usr/share/applications
 	vbin build/PPSSPPHeadless ppsspp-headless

From 426f9bdaa228679f88d975d39eb10c92c687c00c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 071/115] pqiv: revbump for ffmpeg-6.0

---
 srcpkgs/pqiv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pqiv/template b/srcpkgs/pqiv/template
index 542fc27a2d32..9308d949b6a1 100644
--- a/srcpkgs/pqiv/template
+++ b/srcpkgs/pqiv/template
@@ -1,7 +1,7 @@
 # Template file for 'pqiv'
 pkgname=pqiv
 version=2.12
-revision=1
+revision=2
 build_style=gnu-makefile
 hostmakedepends="pkg-config"
 makedepends="glib-devel gtk+3-devel $(vopt_if ffmpeg ffmpeg-devel)

From 62f4df610b608c7ff5a3b97044e7908762c208c3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 072/115] qmmp: revbump for ffmpeg-6.0

---
 srcpkgs/qmmp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qmmp/template b/srcpkgs/qmmp/template
index 26c661ed16be..a150d7441c7a 100644
--- a/srcpkgs/qmmp/template
+++ b/srcpkgs/qmmp/template
@@ -1,7 +1,7 @@
 # Template file for 'qmmp'
 pkgname=qmmp
 version=1.6.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DUSE_HAL:BOOL=FALSE -DQMMP_DEFAULT_UI:STRING=simple"
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From 3c7ea08eba11d87c272dabeaa6547438b8839b6e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 073/115] qt5-webengine: update to 5.15.13

---
 .../chromium-media-filters-cpp14.patch        |  11 ++
 srcpkgs/qt5-webengine/patches/ffmpeg5.patch   | 179 ++++++++++++++++++
 srcpkgs/qt5-webengine/template                |  10 +-
 3 files changed, 195 insertions(+), 5 deletions(-)
 create mode 100644 srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/ffmpeg5.patch

diff --git a/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
new file mode 100644
index 000000000000..04adc540f2cb
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
@@ -0,0 +1,11 @@
+--- a/src/3rdparty/chromium/media/filters/BUILD.gn	2023-02-27 13:32:59.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/BUILD.gn	2023-04-02 17:21:39.204066384 -0400
+@@ -96,6 +96,8 @@
+     "//ui/gfx/geometry:geometry",
+   ]
+ 
++  cflags_cc = [ "-std=c++14" ]
++
+   libs = []
+ 
+   if (proprietary_codecs) {
diff --git a/srcpkgs/qt5-webengine/patches/ffmpeg5.patch b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..ac55e1634423
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
@@ -0,0 +1,179 @@
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:57.732547446 -0400
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:09.486478995 -0400
+@@ -57,6 +57,8 @@
+ 
+ namespace {
+ 
++constexpr int64_t kRelativeTsBase = static_cast<int64_t>(0x7ffeffffffffffff);
++
+ void SetAVStreamDiscard(AVStream* stream, AVDiscard discard) {
+   DCHECK(stream);
+   stream->discard = discard;
+@@ -90,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+   if (stream->start_time != kNoFFmpegTimestamp)
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (stream->first_dts != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, stream->first_dts);
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -408,11 +398,11 @@
+   scoped_refptr<DecoderBuffer> buffer;
+ 
+   if (type() == DemuxerStream::TEXT) {
+-    int id_size = 0;
++    size_t id_size = 0;
+     uint8_t* id_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
+ 
+-    int settings_size = 0;
++    size_t settings_size = 0;
+     uint8_t* settings_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
+ 
+@@ -424,7 +414,7 @@
+     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
+                                      side_data.data(), side_data.size());
+   } else {
+-    int side_data_size = 0;
++    size_t side_data_size = 0;
+     uint8_t* side_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
+ 
+@@ -485,7 +475,7 @@
+                                        packet->size - data_offset);
+     }
+ 
+-    int skip_samples_size = 0;
++    size_t skip_samples_size = 0;
+     const uint32_t* skip_samples_ptr =
+         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
+             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
+@@ -1587,6 +1577,8 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++      continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+       lowest_start_time_stream = stream.get();
+@@ -1604,6 +1596,8 @@
+     if (stream && stream->type() == DemuxerStream::VIDEO &&
+         stream->IsEnabled()) {
+       video_stream = stream.get();
++      if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++        continue;
+       if (video_stream->start_time() <= seek_time) {
+         return video_stream;
+       }
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h qtwebengine-5.15.10/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h
+--- a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-07-11 22:12:47.917192788 -0500
+@@ -29,6 +29,7 @@ extern "C" {
+ #include <libavformat/avformat.h>
+ #include <libavformat/avio.h>
+ #include <libavutil/avutil.h>
++#include <libavutil/channel_layout.h>
+ #include <libavutil/imgutils.h>
+ #include <libavutil/log.h>
+ #include <libavutil/mastering_display_metadata.h>
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/audio_file_reader.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/audio_file_reader.cc
+--- a/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -85,7 +85,7 @@ bool AudioFileReader::OpenDemuxer() {
+ }
+ 
+ bool AudioFileReader::OpenDecoder() {
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (codec) {
+     // MP3 decodes to S16P which we don't support, tell it to use S16 instead.
+     if (codec_context_->sample_fmt == AV_SAMPLE_FMT_S16P)
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -329,7 +329,7 @@ bool FFmpegAudioDecoder::ConfigureDecode
+     }
+   }
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec ||
+       avcodec_open2(codec_context_.get(), codec, &codec_options) < 0) {
+     DLOG(ERROR) << "Could not initialize audio decoder: "
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -59,7 +59,6 @@ static int64_t AVIOSeekOperation(void* o
+ }
+ 
+ void FFmpegGlue::InitializeFFmpeg() {
+-  av_register_all();
+ }
+ 
+ static void LogContainer(bool is_local_file,
+@@ -95,9 +94,6 @@ FFmpegGlue::FFmpegGlue(FFmpegURLProtocol
+   // Enable fast, but inaccurate seeks for MP3.
+   format_context_->flags |= AVFMT_FLAG_FAST_SEEK;
+ 
+-  // Ensures we can read out various metadata bits like vp8 alpha.
+-  format_context_->flags |= AVFMT_FLAG_KEEP_SIDE_DATA;
+-
+   // Ensures format parsing errors will bail out. From an audit on 11/2017, all
+   // instances were real failures. Solves bugs like http://crbug.com/710791.
+   format_context_->error_recognition |= AV_EF_EXPLODE;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -391,7 +391,7 @@ bool FFmpegVideoDecoder::ConfigureDecode
+   if (decode_nalus_)
+     codec_context_->flags2 |= AV_CODEC_FLAG2_CHUNKS;
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
+     ReleaseFFmpegResources();
+     return false;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/media_file_checker.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/media_file_checker.cc
+--- a/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -68,7 +68,7 @@ bool MediaFileChecker::Start(base::TimeD
+       auto context = AVStreamToAVCodecContext(format_context->streams[i]);
+       if (!context)
+         continue;
+-      AVCodec* codec = avcodec_find_decoder(cp->codec_id);
++      const AVCodec* codec = avcodec_find_decoder(cp->codec_id);
+       if (codec && avcodec_open2(context.get(), codec, nullptr) >= 0) {
+         auto loop = std::make_unique<FFmpegDecodingLoop>(context.get());
+         stream_contexts[i] = {std::move(context), std::move(loop)};
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc qtwebengine-5.15.10/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc
+--- a/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -203,7 +203,7 @@ int32_t H264DecoderImpl::InitDecode(cons
+   // a pointer |this|.
+   av_context_->opaque = this;
+ 
+-  AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
+   if (!codec) {
+     // This is an indication that FFmpeg has not been initialized or it has not
+     // been compiled/initialized with the correct set of codecs.
diff --git a/srcpkgs/qt5-webengine/template b/srcpkgs/qt5-webengine/template
index 85267c7cf8a3..095ab67701e4 100644
--- a/srcpkgs/qt5-webengine/template
+++ b/srcpkgs/qt5-webengine/template
@@ -1,9 +1,9 @@
 # Template file for 'qt5-webengine'
 pkgname=qt5-webengine
-version=5.15.11
-revision=3
+version=5.15.13
+revision=1
 _version="${version}-lts"
-_chromium_commit=be349eaf62e77955791d7bf29f893f1e8a37daf4
+_chromium_commit=e48df7803c7c98b0b2471c94057d32e44a301ad5
 archs="x86_64* i686* armv[67]* ppc64* aarch64*"
 create_wrksrc=yes
 build_style=qmake
@@ -32,8 +32,8 @@ license="GPL-3.0-or-later, LGPL-3.0-or-later"
 homepage="https://qt.io/"
 distfiles="https://github.com/qt/qtwebengine/archive/v${_version}.tar.gz
  https://github.com/qt/qtwebengine-chromium/archive/${_chromium_commit}.tar.gz"
-checksum="aa7466356c450c5f5870f979b93cd7e7e62da1165c328ffcab1a9928db18ad67
- 6f47ed8ab8cc062411f6f206da6353bc8263d6ed6d6290c689a05c01d91f646b"
+checksum="4b59838ed75ef788b59e1e412535a0e42dd9d311661fdeadb191b581ba815c63
+ a91686562b1d4e8b220e0bbcbab5feb64630e2de974b35ac034bf388af771a6c"
 
 no_generic_pkgconfig_link=yes
 build_options="sndio pipewire"

From fca16a743f6ae67621ad5b4a70b6b97dad90b7e4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 074/115] qt5: update to 5.15.8

---
 ...erywhere-opensource-src-5.15.8-kf5-1.patch | 12913 ++++++++++++++++
 srcpkgs/qt5/template                          |    12 +-
 2 files changed, 12919 insertions(+), 6 deletions(-)
 create mode 100644 srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch

diff --git a/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch b/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch
new file mode 100644
index 000000000000..966c98bcd3bb
--- /dev/null
+++ b/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch
@@ -0,0 +1,12913 @@
+Submitted By:            Pierre Labastie <pierre_dot_labastie_at_neuf_dot_fr>
+Date:                    2023-01-05
+Initial Package Version: 5.15.8
+Upstream Status:         Applied (according to KDE)
+Origin:                  KDE patch set
+Description:             Patch set maintained by the KDE folks
+see https://dot.kde.org/2021/04/06/announcing-kdes-qt-5-patch-collection
+Patch generated using the procedure in
+https://wiki.linuxfromscratch.org/blfs/ticket/17476#comment:3
+
+Submodule qtbase 4ee4fc18..9cf586d6:
+diff --git a/qtbase/mkspecs/common/android/qplatformdefs.h b/qtbase/mkspecs/common/android/qplatformdefs.h
+index f75bc4093b..2bd59410d4 100644
+--- a/qtbase/mkspecs/common/android/qplatformdefs.h
++++ b/qtbase/mkspecs/common/android/qplatformdefs.h
+@@ -144,11 +144,7 @@
+ #define QT_SIGNAL_ARGS          int
+ #define QT_SIGNAL_IGNORE        SIG_IGN
+ 
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+ #define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+ 
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+diff --git a/qtbase/mkspecs/features/mac/sdk.mk b/qtbase/mkspecs/features/mac/sdk.mk
+index f30b5830b4..a32ceacb6c 100644
+--- a/qtbase/mkspecs/features/mac/sdk.mk
++++ b/qtbase/mkspecs/features/mac/sdk.mk
+@@ -1,6 +1,6 @@
+ 
+ ifeq ($(QT_MAC_SDK_NO_VERSION_CHECK),)
+-    CHECK_SDK_COMMAND = /usr/bin/xcrun --sdk $(EXPORT_QMAKE_MAC_SDK) -show-sdk-version 2>&1
++    CHECK_SDK_COMMAND = /usr/bin/xcrun --sdk $(EXPORT_QMAKE_MAC_SDK) -show-sdk-version 2>/dev/null
+     CURRENT_MAC_SDK_VERSION := $(shell DEVELOPER_DIR=$(EXPORT_QMAKE_XCODE_DEVELOPER_PATH) $(CHECK_SDK_COMMAND))
+     ifneq ($(CURRENT_MAC_SDK_VERSION),$(EXPORT_QMAKE_MAC_SDK_VERSION))
+         # We don't want to complain about out of date SDK unless the target needs to be remade.
+diff --git a/qtbase/mkspecs/linux-clang/qplatformdefs.h b/qtbase/mkspecs/linux-clang/qplatformdefs.h
+index a818d973f0..c1ab72fbc6 100644
+--- a/qtbase/mkspecs/linux-clang/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-clang/qplatformdefs.h
+@@ -79,14 +79,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-g++/qplatformdefs.h b/qtbase/mkspecs/linux-g++/qplatformdefs.h
+index 13523f0702..4d2750d9ec 100644
+--- a/qtbase/mkspecs/linux-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-g++/qplatformdefs.h
+@@ -79,14 +79,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ < 2)
+-#define QT_SOCKLEN_T            int
+-#else
+-#define QT_SOCKLEN_T            socklen_t
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-llvm/qplatformdefs.h b/qtbase/mkspecs/linux-llvm/qplatformdefs.h
+index dc750ab1ef..d3cc39b47f 100644
+--- a/qtbase/mkspecs/linux-llvm/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-llvm/qplatformdefs.h
+@@ -80,14 +80,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h b/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
+index 4c4e53da2a..83baffb3e3 100644
+--- a/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
+@@ -85,16 +85,9 @@
+ #include "../common/posix/qplatformdefs.h"
+ 
+ #undef QT_OPEN_LARGEFILE
+-#undef QT_SOCKLEN_T
+ 
+ #define QT_OPEN_LARGEFILE       0
+ 
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #ifndef SIOCGIFBRDADDR
+ #  define SIOCGIFBRDADDR 0x8919
+ #endif
+diff --git a/qtbase/mkspecs/lynxos-g++/qplatformdefs.h b/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
+index 4339ea2b23..6007af0055 100644
+--- a/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
+@@ -72,14 +72,6 @@
+ 
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp b/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
+index c3c184258f..32af3f8f29 100644
+--- a/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
++++ b/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
+@@ -10,6 +10,7 @@
+ #include "libANGLE/HandleAllocator.h"
+ 
+ #include <algorithm>
++#include <limits>
+ 
+ #include "common/debug.h"
+ 
+diff --git a/qtbase/src/3rdparty/forkfd/forkfd_linux.c b/qtbase/src/3rdparty/forkfd/forkfd_linux.c
+index ffe0e9a5e2..b1f5408d11 100644
+--- a/qtbase/src/3rdparty/forkfd/forkfd_linux.c
++++ b/qtbase/src/3rdparty/forkfd/forkfd_linux.c
+@@ -82,7 +82,8 @@ static int sys_clone(unsigned long cloneflags, int *ptid)
+     return syscall(__NR_clone, cloneflags, child_stack, stack_size, ptid, newtls, ctid);
+ #elif defined(__arc__) || defined(__arm__) || defined(__aarch64__) || defined(__mips__) || \
+     defined(__nds32__) || defined(__hppa__) || defined(__powerpc__) || defined(__i386__) || \
+-    defined(__x86_64__) || defined(__xtensa__) || defined(__alpha__) || defined(__riscv)
++    defined(__x86_64__) || defined(__xtensa__) || defined(__alpha__) || defined(__riscv) || \
++    defined(__loongarch__)
+     /* ctid and newtls are inverted on CONFIG_CLONE_BACKWARDS architectures,
+      * but since both values are 0, there's no harm. */
+     return syscall(__NR_clone, cloneflags, child_stack, ptid, ctid, newtls);
+diff --git a/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java b/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
+index 5792b5b2f5..2f74750fcf 100644
+--- a/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
++++ b/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
+@@ -116,6 +116,7 @@ public class QtNative
+     public static QtThread m_qtThread = new QtThread();
+     private static HashMap<String, Uri> m_cachedUris = new HashMap<String, Uri>();
+     private static ArrayList<String> m_knownDirs = new ArrayList<String>();
++    private static final String NoPermissionErrorMessage = "No permissions to open Uri";
+ 
+     private static final Runnable runPendingCppRunnablesRunnable = new Runnable() {
+         @Override
+@@ -193,11 +194,10 @@ public class QtNative
+                     return iterUri;
+             }
+ 
+-            // Android 6 and earlier could still manage to open the file so we can return the
+-            // parsed uri here
+-            if (Build.VERSION.SDK_INT < 24)
+-                return parsedUri;
+-            return null;
++            // if we only have transient permissions on uri all the above will fail,
++            // but we will be able to read the file anyway, so continue with uri here anyway
++            // and check for SecurityExceptions later
++            return parsedUri;
+         } catch (SecurityException e) {
+             e.printStackTrace();
+             return null;
+@@ -244,7 +244,7 @@ public class QtNative
+         int error = -1;
+ 
+         if (uri == null) {
+-            Log.e(QtTAG, "openFdForContentUrl(): No permissions to open Uri");
++            Log.e(QtTAG, "openFdForContentUrl(): " + NoPermissionErrorMessage);
+             return error;
+         }
+ 
+@@ -254,12 +254,13 @@ public class QtNative
+             return fdDesc.detachFd();
+         } catch (FileNotFoundException e) {
+             e.printStackTrace();
+-            return error;
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "openFdForContentUrl(): Invalid Uri");
+             e.printStackTrace();
+-            return error;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return error;
+     }
+ 
+     public static long getSize(Context context, String contentUrl)
+@@ -270,7 +271,7 @@ public class QtNative
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+ 
+         if (uri == null) {
+-            Log.e(QtTAG, "getSize(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return size;
+         } else if (!m_cachedUris.containsKey(contentUrl)) {
+             m_cachedUris.put(contentUrl, uri);
+@@ -288,12 +289,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "getSize(): Invalid Uri");
+             e.printStackTrace();
+-            return size;
+         }  catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "getSize(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return size;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return size;
+     }
+ 
+     public static boolean checkFileExists(Context context, String contentUrl)
+@@ -303,7 +305,7 @@ public class QtNative
+         if (uri == null)
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+         if (uri == null) {
+-            Log.e(QtTAG, "checkFileExists(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return exists;
+         } else {
+             if (!m_cachedUris.containsKey(contentUrl))
+@@ -321,12 +323,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "checkFileExists(): Invalid Uri");
+             e.printStackTrace();
+-            return exists;
+         } catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "checkFileExists(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return false;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return exists;
+     }
+ 
+     public static boolean checkIfWritable(Context context, String contentUrl)
+@@ -344,7 +347,7 @@ public class QtNative
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+         }
+         if (uri == null) {
+-            Log.e(QtTAG, "isDir(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return isDir;
+         } else {
+             if (!m_cachedUris.containsKey(contentUrl))
+@@ -374,12 +377,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "checkIfDir(): Invalid Uri");
+             e.printStackTrace();
+-            return false;
+         } catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "checkIfDir(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return false;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return false;
+     }
+     public static String[] listContentsFromTreeUri(Context context, String contentUrl)
+     {
+diff --git a/qtbase/src/concurrent/qtconcurrentreducekernel.h b/qtbase/src/concurrent/qtconcurrentreducekernel.h
+index 8f9a938952..a98dedef2e 100644
+--- a/qtbase/src/concurrent/qtconcurrentreducekernel.h
++++ b/qtbase/src/concurrent/qtconcurrentreducekernel.h
+@@ -212,11 +212,13 @@ public:
+ 
+     inline bool shouldThrottle()
+     {
++        std::lock_guard<QMutex> locker(mutex);
+         return (resultsMapSize > (ReduceQueueThrottleLimit * threadCount));
+     }
+ 
+     inline bool shouldStartThread()
+     {
++        std::lock_guard<QMutex> locker(mutex);
+         return (resultsMapSize <= (ReduceQueueStartLimit * threadCount));
+     }
+ };
+diff --git a/qtbase/src/concurrent/qtconcurrentthreadengine.cpp b/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
+index ea6ce3ac42..7f91a2ba68 100644
+--- a/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
++++ b/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
+@@ -176,6 +176,39 @@ void ThreadEngineBase::startSingleThreaded()
+     finish();
+ }
+ 
++void ThreadEngineBase::startBlocking()
++{
++    start();
++    barrier.acquire();
++    startThreads();
++
++    bool throttled = false;
++#ifndef QT_NO_EXCEPTIONS
++    try {
++#endif
++        while (threadFunction() == ThrottleThread) {
++            if (threadThrottleExit()) {
++                throttled = true;
++                break;
++            }
++        }
++#ifndef QT_NO_EXCEPTIONS
++    } catch (QException &e) {
++        handleException(e);
++    } catch (...) {
++        handleException(QUnhandledException());
++    }
++#endif
++
++    if (throttled == false) {
++        barrier.release();
++    }
++
++    barrier.wait();
++    finish();
++    exceptionStore.throwPossibleException();
++}
++
+ void ThreadEngineBase::startThread()
+ {
+     startThreadInternal();
+diff --git a/qtbase/src/concurrent/qtconcurrentthreadengine.h b/qtbase/src/concurrent/qtconcurrentthreadengine.h
+index 7c30cebdbc..a4c8548cc4 100644
+--- a/qtbase/src/concurrent/qtconcurrentthreadengine.h
++++ b/qtbase/src/concurrent/qtconcurrentthreadengine.h
+@@ -91,6 +91,7 @@ public:
+     ThreadEngineBase();
+     virtual ~ThreadEngineBase();
+     void startSingleThreaded();
++    void startBlocking();
+     void startThread();
+     bool isCanceled();
+     void waitForResume();
+@@ -143,6 +144,15 @@ public:
+         return result();
+     }
+ 
++    // Runs the user algorithm using multiple threads.
++    // This function blocks until the algorithm is finished,
++    // and then returns the result.
++    T *startBlocking()
++    {
++        ThreadEngineBase::startBlocking();
++        return result();
++    }
++
+     // Runs the user algorithm using multiple threads.
+     // Does not block, returns a future.
+     QFuture<T> startAsynchronously()
+@@ -223,6 +233,13 @@ class ThreadEngineStarter : public ThreadEngineStarterBase<T>
+ public:
+     ThreadEngineStarter(TypedThreadEngine *eng)
+         : Base(eng) { }
++
++    T startBlocking()
++    {
++        T t = *this->threadEngine->startBlocking();
++        delete this->threadEngine;
++        return t;
++    }
+ };
+ 
+ // Full template specialization where T is void.
+@@ -232,6 +249,12 @@ class ThreadEngineStarter<void> : public ThreadEngineStarterBase<void>
+ public:
+     ThreadEngineStarter(ThreadEngine<void> *_threadEngine)
+         : ThreadEngineStarterBase<void>(_threadEngine) {}
++
++    void startBlocking()
++    {
++        this->threadEngine->startBlocking();
++        delete this->threadEngine;
++    }
+ };
+ 
+ //! [qtconcurrentthreadengine-1]
+diff --git a/qtbase/src/corelib/animation/qvariantanimation.cpp b/qtbase/src/corelib/animation/qvariantanimation.cpp
+index 98b02f0202..eac1524107 100644
+--- a/qtbase/src/corelib/animation/qvariantanimation.cpp
++++ b/qtbase/src/corelib/animation/qvariantanimation.cpp
+@@ -276,7 +276,9 @@ void QVariantAnimationPrivate::setCurrentValueForProgress(const qreal progress)
+ 
+     const qreal startProgress = currentInterval.start.first;
+     const qreal endProgress = currentInterval.end.first;
+-    const qreal localProgress = (progress - startProgress) / (endProgress - startProgress);
++    const qreal localProgress =
++            qIsNull(progress - startProgress) ? 0.0 // avoid 0/0 below
++            /* else */                        : (progress - startProgress) / (endProgress - startProgress);
+ 
+     QVariant ret = q->interpolated(currentInterval.start.second,
+                                    currentInterval.end.second,
+diff --git a/qtbase/src/corelib/global/qnamespace.h b/qtbase/src/corelib/global/qnamespace.h
+index ad4150b317..bf19b1627b 100644
+--- a/qtbase/src/corelib/global/qnamespace.h
++++ b/qtbase/src/corelib/global/qnamespace.h
+@@ -1864,7 +1864,7 @@ public:
+     QT_Q_ENUM(TimerType)
+     QT_Q_ENUM(ScrollPhase)
+     QT_Q_ENUM(MouseEventSource)
+-    QT_Q_FLAG(MouseEventFlag)
++    QT_Q_FLAG(MouseEventFlags)
+     QT_Q_ENUM(ChecksumType)
+     QT_Q_ENUM(HighDpiScaleFactorRoundingPolicy)
+     QT_Q_ENUM(TabFocusBehavior)
+diff --git a/qtbase/src/corelib/global/qrandom.cpp b/qtbase/src/corelib/global/qrandom.cpp
+index 10672c1f92..25f87c7e6a 100644
+--- a/qtbase/src/corelib/global/qrandom.cpp
++++ b/qtbase/src/corelib/global/qrandom.cpp
+@@ -383,7 +383,6 @@ struct QRandomGenerator::SystemAndGlobalGenerators
+ 
+         constexpr SystemAndGlobalGenerators g = {};
+         Q_UNUSED(g);
+-        Q_STATIC_ASSERT(std::is_literal_type<SystemAndGlobalGenerators>::value);
+ #endif
+     }
+ 
+diff --git a/qtbase/src/corelib/io/qbuffer.cpp b/qtbase/src/corelib/io/qbuffer.cpp
+index 595fcd2724..032c0ddd4b 100644
+--- a/qtbase/src/corelib/io/qbuffer.cpp
++++ b/qtbase/src/corelib/io/qbuffer.cpp
+@@ -41,6 +41,8 @@
+ #include <QtCore/qmetaobject.h>
+ #include "private/qiodevice_p.h"
+ 
++#include <limits>
++
+ QT_BEGIN_NAMESPACE
+ 
+ /** QBufferPrivate **/
+@@ -366,7 +368,9 @@ qint64 QBuffer::size() const
+ bool QBuffer::seek(qint64 pos)
+ {
+     Q_D(QBuffer);
+-    if (pos > d->buf->size() && isWritable()) {
++    const auto oldBufSize = d->buf->size();
++    constexpr qint64 MaxSeekPos = (std::numeric_limits<decltype(oldBufSize)>::max)();
++    if (pos <= MaxSeekPos && pos > oldBufSize && isWritable()) {
+         if (seek(d->buf->size())) {
+             const qint64 gapSize = pos - d->buf->size();
+             if (write(QByteArray(gapSize, 0)) != gapSize) {
+@@ -377,7 +381,7 @@ bool QBuffer::seek(qint64 pos)
+             return false;
+         }
+     } else if (pos > d->buf->size() || pos < 0) {
+-        qWarning("QBuffer::seek: Invalid pos: %d", int(pos));
++        qWarning("QBuffer::seek: Invalid pos: %lld", pos);
+         return false;
+     }
+     return QIODevice::seek(pos);
+diff --git a/qtbase/src/corelib/io/qfilesystemengine_win.cpp b/qtbase/src/corelib/io/qfilesystemengine_win.cpp
+index 81d3a71986..c86ed1f9b0 100644
+--- a/qtbase/src/corelib/io/qfilesystemengine_win.cpp
++++ b/qtbase/src/corelib/io/qfilesystemengine_win.cpp
+@@ -664,14 +664,14 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry)
+     return QFileSystemEntry(ret, QFileSystemEntry::FromInternalPath());
+ }
+ 
+-#if defined(Q_CC_MINGW) && WINVER < 0x0602 //  Windows 8 onwards
++#if defined(Q_CC_MINGW) && WINVER < 0x0602 && _WIN32_WINNT < _WIN32_WINNT_WIN8 //  Windows 8 onwards
+ 
+ typedef struct _FILE_ID_INFO {
+     ULONGLONG VolumeSerialNumber;
+     FILE_ID_128 FileId;
+ } FILE_ID_INFO, *PFILE_ID_INFO;
+ 
+-#endif // if defined (Q_CC_MINGW) && WINVER < 0x0602
++#endif // if defined(Q_CC_MINGW) && WINVER < 0x0602 && _WIN32_WINNT < _WIN32_WINNT_WIN8
+ 
+ // File ID for Windows up to version 7 and FAT32 drives
+ static inline QByteArray fileId(HANDLE handle)
+diff --git a/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp b/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
+index 94d9d06bcb..27e0b13b0b 100644
+--- a/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
++++ b/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
+@@ -366,7 +366,9 @@ void QInotifyFileSystemWatcherEngine::readFromInotify()
+     // qDebug("QInotifyFileSystemWatcherEngine::readFromInotify");
+ 
+     int buffSize = 0;
+-    ioctl(inotifyFd, FIONREAD, (char *) &buffSize);
++    if (ioctl(inotifyFd, FIONREAD, (char *) &buffSize) == -1 || buffSize == 0)
++        return;
++
+     QVarLengthArray<char, 4096> buffer(buffSize);
+     buffSize = read(inotifyFd, buffer.data(), buffSize);
+     char *at = buffer.data();
+diff --git a/qtbase/src/corelib/io/qlockfile_win.cpp b/qtbase/src/corelib/io/qlockfile_win.cpp
+index 277f8d4230..38ecef5550 100644
+--- a/qtbase/src/corelib/io/qlockfile_win.cpp
++++ b/qtbase/src/corelib/io/qlockfile_win.cpp
+@@ -48,6 +48,8 @@
+ #include "QtCore/qdebug.h"
+ #include "QtCore/qthread.h"
+ 
++#include "private/qsystemlibrary_p.h"
++
+ QT_BEGIN_NAMESPACE
+ 
+ static inline bool fileExists(const wchar_t *fileName)
+@@ -150,7 +152,7 @@ QString QLockFilePrivate::processNameByPid(qint64 pid)
+ #if !defined(Q_OS_WINRT)
+     typedef DWORD (WINAPI *GetModuleFileNameExFunc)(HANDLE, HMODULE, LPTSTR, DWORD);
+ 
+-    HMODULE hPsapi = LoadLibraryA("psapi");
++    HMODULE hPsapi = QSystemLibrary::load(L"psapi");
+     if (!hPsapi)
+         return QString();
+     GetModuleFileNameExFunc qGetModuleFileNameEx = reinterpret_cast<GetModuleFileNameExFunc>(
+diff --git a/qtbase/src/corelib/io/qprocess_unix.cpp b/qtbase/src/corelib/io/qprocess_unix.cpp
+index 50390e57f5..15c8f30745 100644
+--- a/qtbase/src/corelib/io/qprocess_unix.cpp
++++ b/qtbase/src/corelib/io/qprocess_unix.cpp
+@@ -1,7 +1,7 @@
+ /****************************************************************************
+ **
+ ** Copyright (C) 2016 The Qt Company Ltd.
+-** Copyright (C) 2016 Intel Corporation.
++** Copyright (C) 2022 Intel Corporation.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtCore module of the Qt Toolkit.
+@@ -422,14 +422,15 @@ void QProcessPrivate::startProcess()
+     // Add the program name to the argument list.
+     argv[0] = nullptr;
+     if (!program.contains(QLatin1Char('/'))) {
++        // findExecutable() returns its argument if it's an absolute path,
++        // otherwise it searches $PATH; returns empty if not found (we handle
++        // that case much later)
+         const QString &exeFilePath = QStandardPaths::findExecutable(program);
+-        if (!exeFilePath.isEmpty()) {
+-            const QByteArray &tmp = QFile::encodeName(exeFilePath);
+-            argv[0] = ::strdup(tmp.constData());
+-        }
+-    }
+-    if (!argv[0])
++        const QByteArray &tmp = QFile::encodeName(exeFilePath);
++        argv[0] = ::strdup(tmp.constData());
++    } else {
+         argv[0] = ::strdup(encodedProgramName.constData());
++    }
+ 
+     // Add every argument to the list
+     for (int i = 0; i < arguments.count(); ++i)
+@@ -983,15 +984,16 @@ bool QProcessPrivate::startDetached(qint64 *pid)
+                 envp = _q_dupEnvironment(environment.d.constData()->vars, &envc);
+             }
+ 
+-            QByteArray tmp;
+             if (!program.contains(QLatin1Char('/'))) {
++                // findExecutable() returns its argument if it's an absolute path,
++                // otherwise it searches $PATH; returns empty if not found (we handle
++                // that case much later)
+                 const QString &exeFilePath = QStandardPaths::findExecutable(program);
+-                if (!exeFilePath.isEmpty())
+-                    tmp = QFile::encodeName(exeFilePath);
++                const QByteArray &tmp = QFile::encodeName(exeFilePath);
++                argv[0] = ::strdup(tmp.constData());
++            } else {
++                argv[0] = ::strdup(QFile::encodeName(program));
+             }
+-            if (tmp.isEmpty())
+-                tmp = QFile::encodeName(program);
+-            argv[0] = tmp.data();
+ 
+             if (envp)
+                 qt_safe_execve(argv[0], argv, envp);
+diff --git a/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp b/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
+index 3a79c502af..997a634e76 100644
+--- a/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
++++ b/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
+@@ -3196,9 +3196,8 @@ bool QAbstractItemModel::beginMoveColumns(const QModelIndex &sourceParent, int s
+     destinationChange.needsAdjust = destinationParent.isValid() && destinationParent.row() >= sourceLast && destinationParent.parent() == sourceParent;
+     d->changes.push(destinationChange);
+ 
+-    d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Horizontal);
+-
+     emit columnsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, QPrivateSignal());
++    d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Horizontal);
+     return true;
+ }
+ 
+@@ -3231,7 +3230,6 @@ void QAbstractItemModel::endMoveColumns()
+       adjustedSource = createIndex(adjustedSource.row(), adjustedSource.column() + numMoved, adjustedSource.internalPointer());
+ 
+     d->itemsMoved(adjustedSource, removeChange.first, removeChange.last, adjustedDestination, insertChange.first, Qt::Horizontal);
+-
+     emit columnsMoved(adjustedSource, removeChange.first, removeChange.last, adjustedDestination, insertChange.first, QPrivateSignal());
+ }
+ 
+diff --git a/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+index dc6379d9fb..c5e287ee84 100644
+--- a/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
++++ b/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+@@ -939,8 +939,9 @@ void QSortFilterProxyModelPrivate::insert_source_items(
+                 q->beginInsertColumns(proxy_parent, proxy_start, proxy_end);
+         }
+ 
+-        for (int i = 0; i < source_items.size(); ++i)
+-            proxy_to_source.insert(proxy_start + i, source_items.at(i));
++        // TODO: use the range QList::insert() overload once it is implemented (QTBUG-58633).
++        proxy_to_source.insert(proxy_start, source_items.size(), 0);
++        std::copy(source_items.cbegin(), source_items.cend(), proxy_to_source.begin() + proxy_start);
+ 
+         build_source_to_proxy_mapping(proxy_to_source, source_to_proxy);
+ 
+@@ -3123,8 +3124,9 @@ bool QSortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex &
+ 
+     if (d->filter_data.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();
+@@ -3133,9 +3135,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.hasMatch(key);
+ }
+diff --git a/qtbase/src/corelib/kernel/qcoreapplication.cpp b/qtbase/src/corelib/kernel/qcoreapplication.cpp
+index ca2864df83..132b2eae52 100644
+--- a/qtbase/src/corelib/kernel/qcoreapplication.cpp
++++ b/qtbase/src/corelib/kernel/qcoreapplication.cpp
+@@ -1157,7 +1157,7 @@ static bool doNotify(QObject *receiver, QEvent *event)
+ bool QCoreApplicationPrivate::sendThroughApplicationEventFilters(QObject *receiver, QEvent *event)
+ {
+     // We can't access the application event filters outside of the main thread (race conditions)
+-    Q_ASSERT(receiver->d_func()->threadData.loadRelaxed()->thread.loadAcquire() == mainThread());
++    Q_ASSERT(receiver->d_func()->threadData.loadAcquire()->thread.loadRelaxed() == mainThread());
+ 
+     if (extraData) {
+         // application event filters are only called for objects in the GUI thread
+diff --git a/qtbase/src/corelib/kernel/qobject.cpp b/qtbase/src/corelib/kernel/qobject.cpp
+index 1eb79138d9..36cd780ee1 100644
+--- a/qtbase/src/corelib/kernel/qobject.cpp
++++ b/qtbase/src/corelib/kernel/qobject.cpp
+@@ -1010,7 +1010,7 @@ QObject::~QObject()
+         emit destroyed(this);
+     }
+ 
+-    if (d->declarativeData) {
++    if (!d->isDeletingChildren && d->declarativeData) {
+         if (static_cast<QAbstractDeclarativeDataImpl*>(d->declarativeData)->ownedByQml1) {
+             if (QAbstractDeclarativeData::destroyed_qml1)
+                 QAbstractDeclarativeData::destroyed_qml1(d->declarativeData, this);
+@@ -1580,7 +1580,7 @@ void QObject::moveToThread(QThread *targetThread)
+ 
+     QThreadData *currentData = QThreadData::current();
+     QThreadData *targetData = targetThread ? QThreadData::get2(targetThread) : nullptr;
+-    QThreadData *thisThreadData = d->threadData.loadRelaxed();
++    QThreadData *thisThreadData = d->threadData.loadAcquire();
+     if (!thisThreadData->thread.loadAcquire() && currentData == targetData) {
+         // one exception to the rule: we allow moving objects with no thread affinity to the current thread
+         currentData = d->threadData;
+@@ -2620,7 +2620,7 @@ int QObject::receivers(const char *signal) const
+         if (!d->isSignalConnected(signal_index))
+             return receivers;
+ 
+-        if (d->declarativeData && QAbstractDeclarativeData::receivers) {
++        if (!d->isDeletingChildren && d->declarativeData && QAbstractDeclarativeData::receivers) {
+             receivers += QAbstractDeclarativeData::receivers(d->declarativeData, this,
+                                                              signal_index);
+         }
+diff --git a/qtbase/src/corelib/kernel/qobject_p.h b/qtbase/src/corelib/kernel/qobject_p.h
+index 0b827a52ca..13ffb88999 100644
+--- a/qtbase/src/corelib/kernel/qobject_p.h
++++ b/qtbase/src/corelib/kernel/qobject_p.h
+@@ -444,7 +444,7 @@ inline void QObjectPrivate::checkForIncompatibleLibraryVersion(int version) cons
+ 
+ inline bool QObjectPrivate::isDeclarativeSignalConnected(uint signal_index) const
+ {
+-    return declarativeData && QAbstractDeclarativeData::isSignalConnected
++    return !isDeletingChildren && declarativeData && QAbstractDeclarativeData::isSignalConnected
+             && QAbstractDeclarativeData::isSignalConnected(declarativeData, q_func(), signal_index);
+ }
+ 
+diff --git a/qtbase/src/corelib/kernel/qtranslator.cpp b/qtbase/src/corelib/kernel/qtranslator.cpp
+index 2812ffb7ea..bc0177c5ec 100644
+--- a/qtbase/src/corelib/kernel/qtranslator.cpp
++++ b/qtbase/src/corelib/kernel/qtranslator.cpp
+@@ -902,7 +902,7 @@ static QString getMessage(const uchar *m, const uchar *end, const char *context,
+             goto end;
+         case Tag_Translation: {
+             int len = read32(m);
+-            if (len % 1)
++            if (len & 1)
+                 return QString();
+             m += 4;
+             if (!numerus--) {
+diff --git a/qtbase/src/corelib/mimetypes/qmimedatabase.cpp b/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
+index 9de22cef33..ff868a3268 100644
+--- a/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
+@@ -389,20 +389,23 @@ QMimeType QMimeDatabasePrivate::mimeTypeForFileNameAndData(const QString &fileNa
+         // Disambiguate conflicting extensions (if magic matching found something)
+         if (candidateByData.isValid() && magicAccuracy > 0) {
+             const QString sniffedMime = candidateByData.name();
+-            // If the sniffedMime matches a glob match, use it
++            // If the sniffedMime matches a highest-weight glob match, use it
+             if (candidatesByName.m_matchingMimeTypes.contains(sniffedMime)) {
+                 *accuracyPtr = 100;
+                 return candidateByData;
+             }
+-            for (const QString &m : qAsConst(candidatesByName.m_matchingMimeTypes)) {
++            for (const QString &m : qAsConst(candidatesByName.m_allMatchingMimeTypes)) {
+                 if (inherits(m, sniffedMime)) {
+                     // We have magic + pattern pointing to this, so it's a pretty good match
+                     *accuracyPtr = 100;
+                     return mimeTypeForName(m);
+                 }
+             }
+-            *accuracyPtr = magicAccuracy;
+-            return candidateByData;
++            if (candidatesByName.m_allMatchingMimeTypes.isEmpty()) {
++                // No glob, use magic
++                *accuracyPtr = magicAccuracy;
++                return candidateByData;
++            }
+         }
+     }
+ 
+diff --git a/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp b/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
+index a81112d227..fa8f4c545d 100644
+--- a/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
+@@ -83,7 +83,10 @@ void QMimeGlobMatchResult::addMatch(const QString &mimeType, int weight, const Q
+     }
+     if (!m_matchingMimeTypes.contains(mimeType)) {
+         m_matchingMimeTypes.append(mimeType);
+-        m_allMatchingMimeTypes.append(mimeType);
++        if (replace)
++            m_allMatchingMimeTypes.prepend(mimeType); // highest-weight first
++        else
++            m_allMatchingMimeTypes.append(mimeType);
+         m_knownSuffixLength = knownSuffixLength;
+     }
+ }
+@@ -94,7 +97,7 @@ QMimeGlobPattern::PatternType QMimeGlobPattern::detectPatternType(const QString
+     if (!patternLength)
+         return OtherPattern;
+ 
+-    const bool starCount = pattern.count(QLatin1Char('*')) == 1;
++    const int starCount = pattern.count(QLatin1Char('*'));
+     const bool hasSquareBracket = pattern.indexOf(QLatin1Char('[')) != -1;
+     const bool hasQuestionMark = pattern.indexOf(QLatin1Char('?')) != -1;
+ 
+@@ -106,10 +109,10 @@ QMimeGlobPattern::PatternType QMimeGlobPattern::detectPatternType(const QString
+             // Patterns like "README*" (well this is currently the only one like that...)
+             if (pattern.at(patternLength - 1) == QLatin1Char('*'))
+                 return PrefixPattern;
+-        }
+-        // Names without any wildcards like "README"
+-        if (starCount == 0)
++        } else if (starCount == 0) {
++            // Names without any wildcards like "README"
+             return LiteralPattern;
++        }
+     }
+ 
+     if (pattern == QLatin1String("[0-9][0-9][0-9].vdr"))
+diff --git a/qtbase/src/corelib/mimetypes/qmimeprovider.cpp b/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
+index 258dddf8cb..4642d0f2d0 100644
+--- a/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
+@@ -244,15 +244,18 @@ void QMimeBinaryProvider::addFileNameMatches(const QString &fileName, QMimeGlobM
+     const QString lowerFileName = fileName.toLower();
+     // Check literals (e.g. "Makefile")
+     matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosLiteralListOffset), fileName);
+-    // Check complex globs (e.g. "callgrind.out[0-9]*")
+-    matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosGlobListOffset), fileName);
+     // Check the very common *.txt cases with the suffix tree
+-    const int reverseSuffixTreeOffset = m_cacheFile->getUint32(PosReverseSuffixTreeOffset);
+-    const int numRoots = m_cacheFile->getUint32(reverseSuffixTreeOffset);
+-    const int firstRootOffset = m_cacheFile->getUint32(reverseSuffixTreeOffset + 4);
+-    matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, lowerFileName, lowerFileName.length() - 1, false);
++    if (result.m_matchingMimeTypes.isEmpty()) {
++        const int reverseSuffixTreeOffset = m_cacheFile->getUint32(PosReverseSuffixTreeOffset);
++        const int numRoots = m_cacheFile->getUint32(reverseSuffixTreeOffset);
++        const int firstRootOffset = m_cacheFile->getUint32(reverseSuffixTreeOffset + 4);
++        matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, lowerFileName, lowerFileName.length() - 1, false);
++        if (result.m_matchingMimeTypes.isEmpty())
++            matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, fileName, fileName.length() - 1, true);
++    }
++    // Check complex globs (e.g. "callgrind.out[0-9]*" or "README*")
+     if (result.m_matchingMimeTypes.isEmpty())
+-        matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, fileName, fileName.length() - 1, true);
++        matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosGlobListOffset), fileName);
+ }
+ 
+ void QMimeBinaryProvider::matchGlobList(QMimeGlobMatchResult &result, CacheFile *cacheFile, int off, const QString &fileName)
+diff --git a/qtbase/src/corelib/serialization/qjsonparser.cpp b/qtbase/src/corelib/serialization/qjsonparser.cpp
+index 17e6f111ab..2e40b6c8fb 100644
+--- a/qtbase/src/corelib/serialization/qjsonparser.cpp
++++ b/qtbase/src/corelib/serialization/qjsonparser.cpp
+@@ -379,10 +379,30 @@ error:
+     return QCborValue();
+ }
+ 
++// We need to retain the _last_ value for any duplicate keys and we need to deref containers.
++// Therefore the manual implementation of std::unique().
++template<typename Iterator, typename Compare, typename Assign>
++static Iterator customAssigningUniqueLast(Iterator first, Iterator last,
++                                          Compare compare, Assign assign)
++{
++    first = std::adjacent_find(first, last, compare);
++    if (first == last)
++        return last;
++
++    Iterator result = first;
++    while (++first != last) {
++        if (!compare(*result, *first))
++            ++result;
++        if (result != first)
++            assign(*result, *first);
++    }
++
++    return ++result;
++}
++
+ static void sortContainer(QCborContainerPrivate *container)
+ {
+     using Forward = QJsonPrivate::KeyIterator;
+-    using Reverse = std::reverse_iterator<Forward>;
+     using Value = Forward::value_type;
+ 
+     auto compare = [container](const Value &a, const Value &b)
+@@ -420,17 +440,31 @@ static void sortContainer(QCborContainerPrivate *container)
+         }
+     };
+ 
+-    std::sort(Forward(container->elements.begin()), Forward(container->elements.end()),
+-              [&compare](const Value &a, const Value &b) { return compare(a, b) < 0; });
++    // The elements' containers are owned by the outer container, not by the elements themselves.
++    auto move = [](Forward::reference target, Forward::reference source)
++    {
++        QtCbor::Element &targetValue = target.value();
++
++        // If the target has a container, deref it before overwriting, so that we don't leak.
++        if (targetValue.flags & QtCbor::Element::IsContainer)
++            targetValue.container->deref();
++
++        // Do not move, so that we can clear the value afterwards.
++        target = source;
++
++        // Clear the source value, so that we don't store the same container twice.
++        source.value() = QtCbor::Element();
++    };
++
++    std::stable_sort(
++                Forward(container->elements.begin()), Forward(container->elements.end()),
++                [&compare](const Value &a, const Value &b) { return compare(a, b) < 0; });
+ 
+-    // We need to retain the _last_ value for any duplicate keys. Therefore the reverse dance here.
+-    auto it = std::unique(Reverse(container->elements.end()), Reverse(container->elements.begin()),
+-                          [&compare](const Value &a, const Value &b) {
+-        return compare(a, b) == 0;
+-    }).base().elementsIterator();
++    Forward result = customAssigningUniqueLast(
++                Forward(container->elements.begin()),  Forward(container->elements.end()),
++                [&compare](const Value &a, const Value &b) { return compare(a, b) == 0; }, move);
+ 
+-    // The erase from beginning is expensive but hopefully rare.
+-    container->elements.erase(container->elements.begin(), it);
++    container->elements.erase(result.elementsIterator(), container->elements.end());
+ }
+ 
+ 
+diff --git a/qtbase/src/corelib/serialization/qxmlstream.cpp b/qtbase/src/corelib/serialization/qxmlstream.cpp
+index b2f846544d..7cd457ba3a 100644
+--- a/qtbase/src/corelib/serialization/qxmlstream.cpp
++++ b/qtbase/src/corelib/serialization/qxmlstream.cpp
+@@ -980,7 +980,7 @@ inline uint QXmlStreamReaderPrivate::peekChar()
+ bool QXmlStreamReaderPrivate::scanUntil(const char *str, short tokenToInject)
+ {
+     int pos = textBuffer.size();
+-    int oldLineNumber = lineNumber;
++    const auto oldLineNumber = lineNumber;
+ 
+     uint c;
+     while ((c = getChar()) != StreamEOF) {
+diff --git a/qtbase/src/corelib/text/qstring.cpp b/qtbase/src/corelib/text/qstring.cpp
+index 3e88ab4859..8deeae47bb 100644
+--- a/qtbase/src/corelib/text/qstring.cpp
++++ b/qtbase/src/corelib/text/qstring.cpp
+@@ -12312,7 +12312,7 @@ static qsizetype qLastIndexOf(Haystack haystack0, qsizetype from,
+     const auto needle = needle0.data();
+     const auto *end = haystack;
+     haystack += from;
+-    const std::size_t sl_minus_1 = sl - 1;
++    const std::size_t sl_minus_1 = sl ? sl - 1 : 0;
+     const auto *n = needle + sl_minus_1;
+     const auto *h = haystack + sl_minus_1;
+     std::size_t hashNeedle = 0, hashHaystack = 0;
+diff --git a/qtbase/src/corelib/text/qstringiterator_p.h b/qtbase/src/corelib/text/qstringiterator_p.h
+index 219589b6e4..1d0c66cc78 100644
+--- a/qtbase/src/corelib/text/qstringiterator_p.h
++++ b/qtbase/src/corelib/text/qstringiterator_p.h
+@@ -61,6 +61,8 @@ class QStringIterator
+ {
+     QString::const_iterator i, pos, e;
+     Q_STATIC_ASSERT((std::is_same<QString::const_iterator, const QChar *>::value));
++    static bool less(const QChar *lhs, const QChar *rhs) noexcept
++    { return std::less<QString::const_iterator>{}(lhs, rhs); }
+ public:
+     explicit QStringIterator(QStringView string, qsizetype idx = 0)
+         : i(string.begin()),
+@@ -95,7 +97,8 @@ public:
+ 
+     inline void setPosition(QString::const_iterator position)
+     {
+-        Q_ASSERT_X(i <= position && position <= e, Q_FUNC_INFO, "position out of bounds");
++        Q_ASSERT_X(!less(position, i) && !less(e, position),
++                   Q_FUNC_INFO, "position out of bounds");
+         pos = position;
+     }
+ 
+@@ -103,7 +106,7 @@ public:
+ 
+     inline bool hasNext() const
+     {
+-        return pos < e;
++        return less(pos, e);
+     }
+ 
+     inline void advance()
+@@ -120,16 +123,20 @@ public:
+     {
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+-        if (Q_UNLIKELY((pos++)->isHighSurrogate()))
++        if (Q_UNLIKELY((pos++)->isHighSurrogate())) {
++            Q_ASSERT(hasNext() && pos->isLowSurrogate());
+             ++pos;
++        }
+     }
+ 
+     inline uint peekNextUnchecked() const
+     {
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+-        if (Q_UNLIKELY(pos->isHighSurrogate()))
++        if (Q_UNLIKELY(pos->isHighSurrogate())) {
++            Q_ASSERT(less(pos + 1, e) && pos[1].isLowSurrogate());
+             return QChar::surrogateToUcs4(pos[0], pos[1]);
++        }
+ 
+         return pos->unicode();
+     }
+@@ -155,8 +162,10 @@ public:
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+         const QChar cur = *pos++;
+-        if (Q_UNLIKELY(cur.isHighSurrogate()))
++        if (Q_UNLIKELY(cur.isHighSurrogate())) {
++            Q_ASSERT(hasNext() && pos->isLowSurrogate());
+             return QChar::surrogateToUcs4(cur, *pos++);
++        }
+         return cur.unicode();
+     }
+ 
+@@ -166,7 +175,7 @@ public:
+ 
+         const QChar uc = *pos++;
+         if (Q_UNLIKELY(uc.isSurrogate())) {
+-            if (Q_LIKELY(uc.isHighSurrogate() && pos < e && pos->isLowSurrogate()))
++            if (Q_LIKELY(uc.isHighSurrogate() && hasNext() && pos->isLowSurrogate()))
+                 return QChar::surrogateToUcs4(uc, *pos++);
+             return invalidAs;
+         }
+@@ -178,7 +187,7 @@ public:
+ 
+     inline bool hasPrevious() const
+     {
+-        return pos > i;
++        return less(i, pos);
+     }
+ 
+     inline void recede()
+@@ -196,16 +205,20 @@ public:
+     {
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+-        if (Q_UNLIKELY((--pos)->isLowSurrogate()))
++        if (Q_UNLIKELY((--pos)->isLowSurrogate())) {
++            Q_ASSERT(hasPrevious() && pos[-1].isHighSurrogate());
+             --pos;
++        }
+     }
+ 
+     inline uint peekPreviousUnchecked() const
+     {
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+-        if (Q_UNLIKELY(pos[-1].isLowSurrogate()))
++        if (Q_UNLIKELY(pos[-1].isLowSurrogate())) {
++            Q_ASSERT(less(i + 1, pos) && pos[-2].isHighSurrogate());
+             return QChar::surrogateToUcs4(pos[-2], pos[-1]);
++        }
+         return pos[-1].unicode();
+     }
+ 
+@@ -230,8 +243,10 @@ public:
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+         const QChar cur = *--pos;
+-        if (Q_UNLIKELY(cur.isLowSurrogate()))
++        if (Q_UNLIKELY(cur.isLowSurrogate())) {
++            Q_ASSERT(hasPrevious() && pos[-1].isHighSurrogate());
+             return QChar::surrogateToUcs4(*--pos, cur);
++        }
+         return cur.unicode();
+     }
+ 
+@@ -241,7 +256,7 @@ public:
+ 
+         const QChar uc = *--pos;
+         if (Q_UNLIKELY(uc.isSurrogate())) {
+-            if (Q_LIKELY(uc.isLowSurrogate() && pos > i && pos[-1].isHighSurrogate()))
++            if (Q_LIKELY(uc.isLowSurrogate() && hasPrevious() && pos[-1].isHighSurrogate()))
+                 return QChar::surrogateToUcs4(*--pos, uc);
+             return invalidAs;
+         }
+diff --git a/qtbase/src/corelib/thread/qfutex_p.h b/qtbase/src/corelib/thread/qfutex_p.h
+index f287b752d7..e294537787 100644
+--- a/qtbase/src/corelib/thread/qfutex_p.h
++++ b/qtbase/src/corelib/thread/qfutex_p.h
+@@ -52,6 +52,7 @@
+ //
+ 
+ #include <qglobal.h>
++#include <QtCore/qtsan_impl.h>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -106,16 +107,13 @@ namespace QtLinuxFutex {
+     inline int _q_futex(int *addr, int op, int val, quintptr val2 = 0,
+                         int *addr2 = nullptr, int val3 = 0) noexcept
+     {
+-        // A futex call ensures total ordering on the futex words
+-        // (in either success or failure of the call). Instruct TSAN accordingly,
+-        // as TSAN does not understand the futex(2) syscall.
+-        _q_tsan_release(addr, addr2);
++        QtTsan::futexRelease(addr, addr2);
+ 
+         // we use __NR_futex because some libcs (like Android's bionic) don't
+         // provide SYS_futex etc.
+         int result = syscall(__NR_futex, addr, op | FUTEX_PRIVATE_FLAG, val, val2, addr2, val3);
+ 
+-        _q_tsan_acquire(addr, addr2);
++        QtTsan::futexAcquire(addr, addr2);
+ 
+         return result;
+     }
+diff --git a/qtbase/src/corelib/thread/qmutex.cpp b/qtbase/src/corelib/thread/qmutex.cpp
+index 310d1cb14f..7097122d8e 100644
+--- a/qtbase/src/corelib/thread/qmutex.cpp
++++ b/qtbase/src/corelib/thread/qmutex.cpp
+@@ -152,6 +152,7 @@ public:
+ 
+ /*!
+     \enum QMutex::RecursionMode
++    \obsolete Use QRecursiveMutex to create a recursive mutex.
+ 
+     \value Recursive  In this mode, a thread can lock the same mutex
+                       multiple times and the mutex won't be unlocked
+@@ -173,6 +174,7 @@ public:
+ 
+ /*!
+     Constructs a new mutex. The mutex is created in an unlocked state.
++    \obsolete Use QRecursiveMutex to create a recursive mutex.
+ 
+     If \a mode is QMutex::Recursive, a thread can lock the same mutex
+     multiple times and the mutex won't be unlocked until a
+@@ -197,7 +199,7 @@ QMutex::QMutex(RecursionMode mode)
+ QMutex::~QMutex()
+ {
+     QMutexData *d = d_ptr.loadRelaxed();
+-    if (isRecursive()) {
++    if (QBasicMutex::isRecursive()) {
+         delete static_cast<QRecursiveMutexPrivate *>(d);
+     } else if (d) {
+ #ifndef QT_LINUX_FUTEX
+diff --git a/qtbase/src/corelib/thread/qmutex.h b/qtbase/src/corelib/thread/qmutex.h
+index 73c9e00663..1bae573a03 100644
+--- a/qtbase/src/corelib/thread/qmutex.h
++++ b/qtbase/src/corelib/thread/qmutex.h
+@@ -42,6 +42,7 @@
+ 
+ #include <QtCore/qglobal.h>
+ #include <QtCore/qatomic.h>
++#include <QtCore/qtsan_impl.h>
+ #include <new>
+ 
+ #if __has_include(<chrono>)
+@@ -77,19 +78,37 @@ public:
+ 
+     // BasicLockable concept
+     inline void lock() QT_MUTEX_LOCK_NOEXCEPT {
++        QtTsan::mutexPreLock(this, 0u);
++
+         if (!fastTryLock())
+             lockInternal();
++
++        QtTsan::mutexPostLock(this, 0u, 0);
+     }
+ 
+     // BasicLockable concept
+     inline void unlock() noexcept {
+         Q_ASSERT(d_ptr.loadRelaxed()); //mutex must be locked
++
++        QtTsan::mutexPreUnlock(this, 0u);
++
+         if (!fastTryUnlock())
+             unlockInternal();
++
++        QtTsan::mutexPostUnlock(this, 0u);
+     }
+ 
+     bool tryLock() noexcept {
+-        return fastTryLock();
++        unsigned tsanFlags = QtTsan::TryLock;
++        QtTsan::mutexPreLock(this, tsanFlags);
++
++        const bool success = fastTryLock();
++
++        if (!success)
++            tsanFlags |= QtTsan::TryLockFailed;
++        QtTsan::mutexPostLock(this, tsanFlags, 0);
++
++        return success;
+     }
+ 
+     // Lockable concept
+@@ -134,8 +153,16 @@ public:
+ #else
+     QMutex() { d_ptr.storeRelaxed(nullptr); }
+ #endif
++#if QT_DEPRECATED_SINCE(5,15)
+     enum RecursionMode { NonRecursive, Recursive };
++    QT_DEPRECATED_VERSION_X(5, 15, "Use QRecursiveMutex instead of a recursive QMutex")
+     explicit QMutex(RecursionMode mode);
++
++    QT_DEPRECATED_VERSION_X(5, 15, "Use QRecursiveMutex instead of a recursive QMutex")
++    bool isRecursive() const noexcept
++    { return QBasicMutex::isRecursive(); }
++#endif
++
+     ~QMutex();
+ 
+     // BasicLockable concept
+@@ -166,9 +193,6 @@ public:
+     }
+ #endif
+ 
+-    bool isRecursive() const noexcept
+-    { return QBasicMutex::isRecursive(); }
+-
+ private:
+     Q_DISABLE_COPY(QMutex)
+     friend class QMutexLocker;
+diff --git a/qtbase/src/corelib/thread/qreadwritelock.cpp b/qtbase/src/corelib/thread/qreadwritelock.cpp
+index 8c28507d5a..9dd8503116 100644
+--- a/qtbase/src/corelib/thread/qreadwritelock.cpp
++++ b/qtbase/src/corelib/thread/qreadwritelock.cpp
+@@ -155,7 +155,7 @@ QReadWriteLock::QReadWriteLock(RecursionMode recursionMode)
+ */
+ QReadWriteLock::~QReadWriteLock()
+ {
+-    auto d = d_ptr.loadRelaxed();
++    auto d = d_ptr.loadAcquire();
+     if (isUncontendedLocked(d)) {
+         qWarning("QReadWriteLock: destroying locked QReadWriteLock");
+         return;
+@@ -445,7 +445,7 @@ void QReadWriteLock::unlock()
+ /*! \internal  Helper for QWaitCondition::wait */
+ QReadWriteLock::StateForWaitCondition QReadWriteLock::stateForWaitCondition() const
+ {
+-    QReadWriteLockPrivate *d = d_ptr.loadRelaxed();
++    QReadWriteLockPrivate *d = d_ptr.loadAcquire();
+     switch (quintptr(d) & StateMask) {
+     case StateLockedForRead: return LockedForRead;
+     case StateLockedForWrite: return LockedForWrite;
+@@ -453,6 +453,7 @@ QReadWriteLock::StateForWaitCondition QReadWriteLock::stateForWaitCondition() co
+ 
+     if (!d)
+         return Unlocked;
++    const auto lock = qt_scoped_lock(d->mutex);
+     if (d->writerCount > 1)
+         return RecursivelyLocked;
+     else if (d->writerCount == 1)
+diff --git a/qtbase/src/corelib/thread/qsemaphore.cpp b/qtbase/src/corelib/thread/qsemaphore.cpp
+index 1d01fc1b28..3ecdee3747 100644
+--- a/qtbase/src/corelib/thread/qsemaphore.cpp
++++ b/qtbase/src/corelib/thread/qsemaphore.cpp
+@@ -354,7 +354,12 @@ void QSemaphore::release(int n)
+         quintptr nn = unsigned(n);
+         if (futexHasWaiterCount)
+             nn |= quint64(nn) << 32;    // token count replicated in high word
+-        quintptr prevValue = u.fetchAndAddRelease(nn);
++        quintptr prevValue = u.loadRelaxed();
++        quintptr newValue;
++        do { // loop just to ensure the operations are done atomically
++            newValue = prevValue + nn;
++            newValue &= (futexNeedsWakeAllBit - 1);
++        } while (!u.testAndSetRelease(prevValue, newValue, prevValue));
+         if (futexNeedsWake(prevValue)) {
+ #ifdef FUTEX_OP
+             if (futexHasWaiterCount) {
+@@ -376,7 +381,6 @@ void QSemaphore::release(int n)
+                 quint32 oparg = 0;
+                 quint32 cmp = FUTEX_OP_CMP_NE;
+                 quint32 cmparg = 0;
+-                u.fetchAndAndRelease(futexNeedsWakeAllBit - 1);
+                 futexWakeOp(*futexLow32(&u), n, INT_MAX, *futexHigh32(&u), FUTEX_OP(op, oparg, cmp, cmparg));
+                 return;
+             }
+@@ -388,7 +392,6 @@ 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(futexNeedsWakeAllBit - 1);
+             if (futexHasWaiterCount) {
+                 futexWakeAll(*futexLow32(&u));
+                 futexWakeAll(*futexHigh32(&u));
+diff --git a/qtbase/src/corelib/thread/qthread_p.h b/qtbase/src/corelib/thread/qthread_p.h
+index b2d1628e6e..f32f6f0460 100644
+--- a/qtbase/src/corelib/thread/qthread_p.h
++++ b/qtbase/src/corelib/thread/qthread_p.h
+@@ -174,7 +174,7 @@ public:
+     int returnCode;
+ 
+     uint stackSize;
+-    QThread::Priority priority;
++    std::underlying_type<QThread::Priority>::type priority;
+ 
+     static QThread *threadForId(int id);
+ 
+@@ -213,6 +213,13 @@ public:
+             QCoreApplication::instance()->postEvent(q_ptr, new QEvent(QEvent::Quit));
+         }
+     }
++
++#ifndef Q_OS_INTEGRITY
++private:
++    // Used in QThread(Private)::start to avoid racy access to QObject::objectName,
++    // unset afterwards. On INTEGRITY we set the thread name before starting it.
++    QString objectName;
++#endif
+ };
+ 
+ #else // QT_CONFIG(thread)
+diff --git a/qtbase/src/corelib/thread/qthread_unix.cpp b/qtbase/src/corelib/thread/qthread_unix.cpp
+index 56a8e0a038..610117a640 100644
+--- a/qtbase/src/corelib/thread/qthread_unix.cpp
++++ b/qtbase/src/corelib/thread/qthread_unix.cpp
+@@ -169,8 +169,7 @@ static void set_thread_data(QThreadData *data)
+ 
+ static void clear_thread_data()
+ {
+-    currentThreadData = nullptr;
+-    pthread_setspecific(current_thread_data_key, nullptr);
++    set_thread_data(nullptr);
+ }
+ 
+ template <typename T>
+@@ -296,7 +295,7 @@ void *QThreadPrivate::start(void *arg)
+             QMutexLocker locker(&thr->d_func()->mutex);
+ 
+             // do we need to reset the thread priority?
+-            if (int(thr->d_func()->priority) & ThreadPriorityResetFlag) {
++            if (thr->d_func()->priority & ThreadPriorityResetFlag) {
+                 thr->d_func()->setPriority(QThread::Priority(thr->d_func()->priority & ~ThreadPriorityResetFlag));
+             }
+ 
+@@ -316,10 +315,10 @@ void *QThreadPrivate::start(void *arg)
+             // Sets the name of the current thread. We can only do this
+             // when the thread is starting, as we don't have a cross
+             // platform way of setting the name of an arbitrary thread.
+-            if (Q_LIKELY(thr->objectName().isEmpty()))
++            if (Q_LIKELY(thr->d_func()->objectName.isEmpty()))
+                 setCurrentThreadName(thr->metaObject()->className());
+             else
+-                setCurrentThreadName(thr->objectName().toLocal8Bit());
++                setCurrentThreadName(std::exchange(thr->d_func()->objectName, {}).toLocal8Bit());
+         }
+ #endif
+ 
+@@ -671,7 +670,7 @@ void QThread::start(Priority priority)
+                 // could not set scheduling hints, fallback to inheriting them
+                 // we'll try again from inside the thread
+                 pthread_attr_setinheritsched(&attr, PTHREAD_INHERIT_SCHED);
+-                d->priority = Priority(priority | ThreadPriorityResetFlag);
++                d->priority = static_cast<std::underlying_type<QThread::Priority>::type>(priority) | ThreadPriorityResetFlag;
+             }
+             break;
+         }
+@@ -702,7 +701,10 @@ void QThread::start(Priority priority)
+         pthread_attr_setthreadname(&attr, metaObject()->className());
+     else
+         pthread_attr_setthreadname(&attr, objectName().toLocal8Bit());
++#else
++    d->objectName = objectName();
+ #endif
++
+     pthread_t threadId;
+     int code = pthread_create(&threadId, &attr, QThreadPrivate::start, this);
+     if (code == EPERM) {
+diff --git a/qtbase/src/corelib/thread/qthread_win.cpp b/qtbase/src/corelib/thread/qthread_win.cpp
+index bc70e3178a..4e76972498 100644
+--- a/qtbase/src/corelib/thread/qthread_win.cpp
++++ b/qtbase/src/corelib/thread/qthread_win.cpp
+@@ -394,10 +394,9 @@ unsigned int __stdcall QT_ENSURE_STACK_ALIGNED_FOR_SSE QThreadPrivate::start(voi
+ 
+ #if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) && !defined(Q_OS_WINRT)
+     // sets the name of the current thread.
+-    QByteArray objectName = thr->objectName().toLocal8Bit();
+-    qt_set_thread_name(HANDLE(-1),
+-                       objectName.isEmpty() ?
+-                       thr->metaObject()->className() : objectName.constData());
++    qt_set_thread_name(HANDLE(-1), thr->d_func()->objectName.isEmpty()
++                        ? thr->metaObject()->className()
++                        : std::exchange(thr->d_func()->objectName, {}).toLocal8Bit().constData());
+ #endif
+ 
+     emit thr->started(QThread::QPrivateSignal());
+@@ -503,6 +502,7 @@ void QThread::start(Priority priority)
+     if (d->running)
+         return;
+ 
++    d->objectName = objectName();
+     d->running = true;
+     d->finished = false;
+     d->exited = false;
+@@ -548,7 +548,7 @@ void QThread::start(Priority priority)
+ 
+     int prio;
+     d->priority = priority;
+-    switch (d->priority) {
++    switch (priority) {
+     case IdlePriority:
+         prio = THREAD_PRIORITY_IDLE;
+         break;
+@@ -686,7 +686,7 @@ void QThreadPrivate::setPriority(QThread::Priority threadPriority)
+ 
+     int prio;
+     priority = threadPriority;
+-    switch (priority) {
++    switch (threadPriority) {
+     case QThread::IdlePriority:
+         prio = THREAD_PRIORITY_IDLE;
+         break;
+diff --git a/qtbase/src/corelib/thread/qtsan_impl.h b/qtbase/src/corelib/thread/qtsan_impl.h
+new file mode 100644
+index 0000000000..580a738b91
+--- /dev/null
++++ b/qtbase/src/corelib/thread/qtsan_impl.h
+@@ -0,0 +1,115 @@
++/****************************************************************************
++**
++** Copyright (C) 2017 Intel Corporation.
++** Copyright (C) 2022 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
++** 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 QTSAN_IMPL_H
++#define QTSAN_IMPL_H
++
++#include <QtCore/qglobal.h>
++
++#if (__has_feature(thread_sanitizer) || defined(__SANITIZE_THREAD__)) && __has_include(<sanitizer/tsan_interface.h>)
++#  define QT_BUILDING_UNDER_TSAN
++#  include <sanitizer/tsan_interface.h>
++#endif
++
++QT_BEGIN_NAMESPACE
++
++namespace QtTsan {
++#ifdef QT_BUILDING_UNDER_TSAN
++inline void futexAcquire(void *addr, void *addr2 = nullptr)
++{
++    // A futex call ensures total ordering on the futex words
++    // (in either success or failure of the call). Instruct TSAN accordingly,
++    // as TSAN does not understand the futex(2) syscall (or equivalent).
++    ::__tsan_acquire(addr);
++    if (addr2)
++        ::__tsan_acquire(addr2);
++}
++
++inline void futexRelease(void *addr, void *addr2 = nullptr)
++{
++    if (addr2)
++        ::__tsan_release(addr2);
++    ::__tsan_release(addr);
++}
++
++inline void mutexPreLock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_pre_lock(addr, flags);
++}
++
++inline void mutexPostLock(void *addr, unsigned flags, int recursion)
++{
++    ::__tsan_mutex_post_lock(addr, flags, recursion);
++}
++
++inline void mutexPreUnlock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_pre_unlock(addr, flags);
++}
++
++inline void mutexPostUnlock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_post_unlock(addr, flags);
++}
++
++enum : unsigned {
++    MutexWriteReentrant = ::__tsan_mutex_write_reentrant,
++    TryLock = ::__tsan_mutex_try_lock,
++    TryLockFailed = ::__tsan_mutex_try_lock_failed,
++};
++#else
++inline void futexAcquire(void *, void * = nullptr) {}
++inline void futexRelease(void *, void * = nullptr) {}
++
++enum : unsigned {
++    MutexWriteReentrant,
++    TryLock,
++    TryLockFailed,
++};
++inline void mutexPreLock(void *, unsigned) {}
++inline void mutexPostLock(void *, unsigned, int) {}
++inline void mutexPreUnlock(void *, unsigned) {}
++inline void mutexPostUnlock(void *, unsigned) {}
++#endif // QT_BUILDING_UNDER_TSAN
++} // namespace QtTsan
++
++QT_END_NAMESPACE
++
++#endif // QTSAN_IMPL_H
+diff --git a/qtbase/src/corelib/thread/qwaitcondition_unix.cpp b/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
+index 88b058f410..0f1da4dc9b 100644
+--- a/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
++++ b/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
+@@ -213,7 +213,7 @@ bool QWaitCondition::wait(QMutex *mutex, QDeadlineTimer deadline)
+ {
+     if (! mutex)
+         return false;
+-    if (mutex->isRecursive()) {
++    if (static_cast<QBasicMutex *>(mutex)->isRecursive()) {
+         qWarning("QWaitCondition: cannot wait on recursive mutexes");
+         return false;
+     }
+diff --git a/qtbase/src/corelib/time/qdatetime.cpp b/qtbase/src/corelib/time/qdatetime.cpp
+index ec12569e3f..2c0b098079 100644
+--- a/qtbase/src/corelib/time/qdatetime.cpp
++++ b/qtbase/src/corelib/time/qdatetime.cpp
+@@ -43,6 +43,7 @@
+ #if QT_CONFIG(datetimeparser)
+ #include "private/qdatetimeparser_p.h"
+ #endif
++#include <private/qnumeric_p.h>
+ 
+ #include "qdatastream.h"
+ #include "qset.h"
+@@ -1429,9 +1430,11 @@ QDate QDate::addDays(qint64 ndays) const
+     if (isNull())
+         return QDate();
+ 
+-    // Due to limits on minJd() and maxJd() we know that any overflow
+-    // will be invalid and caught by fromJulianDay().
+-    return fromJulianDay(jd + ndays);
++    qint64 r;
++    if (Q_UNLIKELY(add_overflow(jd, ndays, &r)))
++        return QDate();
++    else
++        return fromJulianDay(r);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/corelib/time/qtimezone.cpp b/qtbase/src/corelib/time/qtimezone.cpp
+index 0309e43e52..3d451696a1 100644
+--- a/qtbase/src/corelib/time/qtimezone.cpp
++++ b/qtbase/src/corelib/time/qtimezone.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2013 John Layt <jlayt@kde.org>
++** Copyright (C) 2020 John Layt <jlayt@kde.org>
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtCore module of the Qt Toolkit.
+@@ -975,9 +975,15 @@ QList<QByteArray> QTimeZone::windowsIdToIanaIds(const QByteArray &windowsId,
+ }
+ 
+ #ifndef QT_NO_DATASTREAM
++// Invalid, as an IANA ID: too long, starts with - and has other invalid characters in it
++static inline QString invalidId() { return QStringLiteral("-No Time Zone Specified!"); }
++
+ QDataStream &operator<<(QDataStream &ds, const QTimeZone &tz)
+ {
+-    tz.d->serialize(ds);
++    if (tz.isValid())
++        tz.d->serialize(ds);
++    else
++        ds << invalidId();
+     return ds;
+ }
+ 
+@@ -985,7 +991,9 @@ QDataStream &operator>>(QDataStream &ds, QTimeZone &tz)
+ {
+     QString ianaId;
+     ds >> ianaId;
+-    if (ianaId == QLatin1String("OffsetFromUtc")) {
++    if (ianaId == invalidId()) {
++        tz = QTimeZone();
++    } else if (ianaId == QLatin1String("OffsetFromUtc")) {
+         int utcOffset;
+         QString name;
+         QString abbreviation;
+diff --git a/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp b/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
+index b1611d7ddb..a7a6a72ccf 100644
+--- a/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
++++ b/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
+@@ -42,6 +42,7 @@
+ #include "qtimezone.h"
+ #include "qtimezoneprivate_p.h"
+ #include "private/qlocale_tools_p.h"
++#include "private/qlocking_p.h"
+ 
+ #include <QtCore/QDataStream>
+ #include <QtCore/QDateTime>
+@@ -62,6 +63,10 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++#if QT_CONFIG(icu)
++static QBasicMutex s_icu_mutex;
++#endif
++
+ /*
+     Private
+ 
+@@ -670,6 +675,9 @@ QTzTimeZonePrivate::~QTzTimeZonePrivate()
+ 
+ QTzTimeZonePrivate *QTzTimeZonePrivate::clone() const
+ {
++#if QT_CONFIG(icu)
++    const auto lock = qt_scoped_lock(s_icu_mutex);
++#endif
+     return new QTzTimeZonePrivate(*this);
+ }
+ 
+@@ -913,12 +921,14 @@ QString QTzTimeZonePrivate::displayName(qint64 atMSecsSinceEpoch,
+                                         const QLocale &locale) const
+ {
+ #if QT_CONFIG(icu)
++    auto lock = qt_unique_lock(s_icu_mutex);
+     if (!m_icu)
+         m_icu = new QIcuTimeZonePrivate(m_id);
+     // TODO small risk may not match if tran times differ due to outdated files
+     // TODO Some valid TZ names are not valid ICU names, use translation table?
+     if (m_icu->isValid())
+         return m_icu->displayName(atMSecsSinceEpoch, nameType, locale);
++    lock.unlock();
+ #else
+     Q_UNUSED(nameType)
+     Q_UNUSED(locale)
+@@ -932,12 +942,14 @@ QString QTzTimeZonePrivate::displayName(QTimeZone::TimeType timeType,
+                                         const QLocale &locale) const
+ {
+ #if QT_CONFIG(icu)
++    auto lock = qt_unique_lock(s_icu_mutex);
+     if (!m_icu)
+         m_icu = new QIcuTimeZonePrivate(m_id);
+     // TODO small risk may not match if tran times differ due to outdated files
+     // TODO Some valid TZ names are not valid ICU names, use translation table?
+     if (m_icu->isValid())
+         return m_icu->displayName(timeType, nameType, locale);
++    lock.unlock();
+ #else
+     Q_UNUSED(timeType)
+     Q_UNUSED(nameType)
+diff --git a/qtbase/src/corelib/tools/qarraydata.h b/qtbase/src/corelib/tools/qarraydata.h
+index dcd95924c1..d01739e7e6 100644
+--- a/qtbase/src/corelib/tools/qarraydata.h
++++ b/qtbase/src/corelib/tools/qarraydata.h
+@@ -42,6 +42,7 @@
+ 
+ #include <QtCore/qrefcount.h>
+ #include <string.h>
++#include <cstdint>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -58,14 +59,14 @@ struct Q_CORE_EXPORT QArrayData
+     {
+         Q_ASSERT(size == 0
+                 || offset < 0 || size_t(offset) >= sizeof(QArrayData));
+-        return reinterpret_cast<char *>(this) + offset;
++        return reinterpret_cast<void *> (reinterpret_cast<uintptr_t>(this) + offset);
+     }
+ 
+     const void *data() const
+     {
+         Q_ASSERT(size == 0
+                 || offset < 0 || size_t(offset) >= sizeof(QArrayData));
+-        return reinterpret_cast<const char *>(this) + offset;
++        return reinterpret_cast<void *> (reinterpret_cast<uintptr_t>(this) + offset);
+     }
+ 
+     // This refers to array data mutability, not "header data" represented by
+diff --git a/qtbase/src/corelib/tools/qfreelist_p.h b/qtbase/src/corelib/tools/qfreelist_p.h
+index 5ba23b344b..9974102136 100644
+--- a/qtbase/src/corelib/tools/qfreelist_p.h
++++ b/qtbase/src/corelib/tools/qfreelist_p.h
+@@ -161,7 +161,7 @@ class QFreeList
+                 return i;
+             x -= size;
+         }
+-        Q_ASSERT(false);
++        Q_UNREACHABLE();
+         return -1;
+     }
+ 
+diff --git a/qtbase/src/corelib/tools/qversionnumber.h b/qtbase/src/corelib/tools/qversionnumber.h
+index d43b86ba51..2843f2b043 100644
+--- a/qtbase/src/corelib/tools/qversionnumber.h
++++ b/qtbase/src/corelib/tools/qversionnumber.h
+@@ -273,10 +273,10 @@ public:
+ 
+     Q_REQUIRED_RESULT Q_CORE_EXPORT QString toString() const;
+ #if QT_STRINGVIEW_LEVEL < 2
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(const QString &string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(const QString &string, int *suffixIndex = nullptr);
+ #endif
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QLatin1String string, int *suffixIndex = nullptr);
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QStringView string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(QLatin1String string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(QStringView string, int *suffixIndex = nullptr);
+ 
+ private:
+ #ifndef QT_NO_DATASTREAM
+diff --git a/qtbase/src/dbus/qdbusintegrator.cpp b/qtbase/src/dbus/qdbusintegrator.cpp
+index 5b66ce971b..28a3b0ffea 100644
+--- a/qtbase/src/dbus/qdbusintegrator.cpp
++++ b/qtbase/src/dbus/qdbusintegrator.cpp
+@@ -1135,7 +1135,13 @@ void QDBusConnectionPrivate::closeConnection()
+         }
+     }
+ 
+-    qDeleteAll(pendingCalls);
++    for (auto it = pendingCalls.begin(); it != pendingCalls.end(); ++it) {
++        auto call = *it;
++        if (!call->ref.deref()) {
++            delete call;
++        }
++    }
++    pendingCalls.clear();
+ 
+     // Disconnect all signals from signal hooks and from the object tree to
+     // avoid QObject::destroyed being sent to dbus daemon thread which has
+@@ -2584,6 +2590,11 @@ QDBusConnectionPrivate::findMetaObject(const QString &service, const QString &pa
+         if (mo)
+             return mo;
+     }
++    if (path.isEmpty()) {
++        error = QDBusError(QDBusError::InvalidObjectPath, QLatin1String("Object path cannot be empty"));
++        lastError = error;
++        return nullptr;
++    }
+ 
+     // introspect the target object
+     QDBusMessage msg = QDBusMessage::createMethodCall(service, path,
+diff --git a/qtbase/src/dbus/qdbusmetaobject.cpp b/qtbase/src/dbus/qdbusmetaobject.cpp
+index 5265568f42..7e9f0f1acc 100644
+--- a/qtbase/src/dbus/qdbusmetaobject.cpp
++++ b/qtbase/src/dbus/qdbusmetaobject.cpp
+@@ -210,6 +210,9 @@ QDBusMetaObjectGenerator::findType(const QByteArray &signature,
+         } else if (signature == "a{ss}") {
+             result.name = "QMap<QString,QString>";
+             type = qMetaTypeId<QMap<QString, QString> >();
++        } else if (signature == "aay") {
++            result.name = "QByteArrayList";
++            type = qMetaTypeId<QByteArrayList>();
+         } else {
+             result.name = "{D-Bus type \"" + signature + "\"}";
+             type = registerComplexDBusType(result.name);
+diff --git a/qtbase/src/gui/accessible/qaccessible.cpp b/qtbase/src/gui/accessible/qaccessible.cpp
+index d705bfccb5..0caf3c808c 100644
+--- a/qtbase/src/gui/accessible/qaccessible.cpp
++++ b/qtbase/src/gui/accessible/qaccessible.cpp
+@@ -54,6 +54,7 @@
+ #include <QtCore/qdebug.h>
+ #include <QtCore/qloggingcategory.h>
+ #include <QtCore/qmetaobject.h>
++#include <QtCore/private/qmetaobject_p.h>
+ #include <QtCore/qhash.h>
+ #include <private/qfactoryloader_p.h>
+ 
+@@ -681,6 +682,25 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
+     // Create a QAccessibleInterface for the object class. Start by the most
+     // derived class and walk up the class hierarchy.
+     const QMetaObject *mo = object->metaObject();
++    const auto *objectPriv = QObjectPrivate::get(object);
++    /*
++     We do not want to cache each and every QML metaobject (Button_QMLTYPE_124,
++     Button_QMLTYPE_125, etc.). Those dynamic metaobjects shouldn't have an
++     accessible interface in any case. Instead, we start the whole checking
++     with the first non-dynamic meta-object. To avoid potential regressions
++     in other areas of Qt that also use dynamic metaobjects, we only do this
++     for objects that are QML-related (approximated by checking whether they
++     have ddata set).
++    */
++    const bool qmlRelated = !objectPriv->isDeletingChildren &&
++                            objectPriv->declarativeData;
++    while (qmlRelated && mo) {
++        auto mop = QMetaObjectPrivate::get(mo);
++        if (!mop || !(mop->flags & DynamicMetaObject))
++            break;
++
++        mo = mo->superClass();
++    };
+     while (mo) {
+         const QString cn = QLatin1String(mo->className());
+ 
+@@ -696,14 +716,15 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
+         // Find a QAccessiblePlugin (factory) for the class name. If there's
+         // no entry in the cache try to create it using the plugin loader.
+         if (!qAccessiblePlugins()->contains(cn)) {
++            QAccessiblePlugin *factory = nullptr; // 0 means "no plugin found". This is cached as well.
+             const int index = loader()->indexOf(cn);
+-            if (index != -1) {
+-                QAccessiblePlugin *factory = qobject_cast<QAccessiblePlugin *>(loader()->instance(index));
+-                qAccessiblePlugins()->insert(cn, factory);
+-            }
++            if (index != -1)
++                factory = qobject_cast<QAccessiblePlugin *>(loader()->instance(index));
++            qAccessiblePlugins()->insert(cn, factory);
+         }
+ 
+         // At this point the cache should contain a valid factory pointer or 0:
++        Q_ASSERT(qAccessiblePlugins()->contains(cn));
+         QAccessiblePlugin *factory = qAccessiblePlugins()->value(cn);
+         if (factory) {
+             QAccessibleInterface *result = factory->create(cn, object);
+diff --git a/qtbase/src/gui/configure.json b/qtbase/src/gui/configure.json
+index 1f08795c57..12c95742d2 100644
+--- a/qtbase/src/gui/configure.json
++++ b/qtbase/src/gui/configure.json
+@@ -834,7 +834,8 @@
+                     "// embedded devices, are not intended to be used together with X. EGL support",
+                     "// has to be disabled in plugins like xcb in this case since the native display,",
+                     "// window and pixmap types will be different than what an X-based platform",
+-                    "// plugin would expect."
++                    "// plugin would expect.",
++                    "#define USE_X11"
+                 ],
+                 "include": [ "EGL/egl.h", "X11/Xlib.h" ],
+                 "main": [
+diff --git a/qtbase/src/gui/image/qbmphandler.cpp b/qtbase/src/gui/image/qbmphandler.cpp
+index 96f1e8cb1d..0e73bbbdb0 100644
+--- a/qtbase/src/gui/image/qbmphandler.cpp
++++ b/qtbase/src/gui/image/qbmphandler.cpp
+@@ -150,16 +150,42 @@ static QDataStream &operator<<(QDataStream &s, const BMP_INFOHDR &bi)
+     return s;
+ }
+ 
+-static int calc_shift(uint mask)
++static uint calc_shift(uint mask)
+ {
+-    int result = 0;
+-    while (mask && !(mask & 1)) {
++    uint result = 0;
++    while ((mask >= 0x100) || (!(mask & 1) && mask)) {
+         result++;
+         mask >>= 1;
+     }
+     return result;
+ }
+ 
++static uint calc_scale(uint low_mask)
++{
++    uint result = 8;
++    while (low_mask && result) {
++        result--;
++        low_mask >>= 1;
++    }
++    return result;
++}
++
++static inline uint apply_scale(uint value, uint scale)
++{
++    if (!(scale & 0x07)) // return immediately if scale == 8 or 0
++        return value;
++
++    uint filled = 8 - scale;
++    uint result = value << scale;
++
++    do {
++        result |= result >> filled;
++        filled <<= 1;
++    } while (filled < 8);
++
++    return result;
++}
++
+ static bool read_dib_fileheader(QDataStream &s, BMP_FILEHDR &bf)
+ {
+     // read BMP file header
+@@ -222,14 +248,14 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+     uint green_mask = 0;
+     uint blue_mask = 0;
+     uint alpha_mask = 0;
+-    int red_shift = 0;
+-    int green_shift = 0;
+-    int blue_shift = 0;
+-    int alpha_shift = 0;
+-    int red_scale = 0;
+-    int green_scale = 0;
+-    int blue_scale = 0;
+-    int alpha_scale = 0;
++    uint red_shift = 0;
++    uint green_shift = 0;
++    uint blue_shift = 0;
++    uint alpha_shift = 0;
++    uint red_scale = 0;
++    uint green_scale = 0;
++    uint blue_scale = 0;
++    uint alpha_scale = 0;
+ 
+     if (!d->isSequential())
+         d->seek(startpos + BMP_FILEHDR_SIZE + bi.biSize); // goto start of colormap or masks
+@@ -308,19 +334,19 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+         red_shift = calc_shift(red_mask);
+         if (((red_mask >> red_shift) + 1) == 0)
+             return false;
+-        red_scale = 256 / ((red_mask >> red_shift) + 1);
++        red_scale = calc_scale(red_mask >> red_shift);
+         green_shift = calc_shift(green_mask);
+         if (((green_mask >> green_shift) + 1) == 0)
+             return false;
+-        green_scale = 256 / ((green_mask >> green_shift) + 1);
++        green_scale = calc_scale(green_mask >> green_shift);
+         blue_shift = calc_shift(blue_mask);
+         if (((blue_mask >> blue_shift) + 1) == 0)
+             return false;
+-        blue_scale = 256 / ((blue_mask >> blue_shift) + 1);
++        blue_scale = calc_scale(blue_mask >> blue_shift);
+         alpha_shift = calc_shift(alpha_mask);
+         if (((alpha_mask >> alpha_shift) + 1) == 0)
+             return false;
+-        alpha_scale = 256 / ((alpha_mask >> alpha_shift) + 1);
++        alpha_scale = calc_scale(alpha_mask >> alpha_shift);
+     } else if (comp == BMP_RGB && (nbits == 24 || nbits == 32)) {
+         blue_mask = 0x000000ff;
+         green_mask = 0x0000ff00;
+@@ -328,17 +354,15 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+         blue_shift = 0;
+         green_shift = 8;
+         red_shift = 16;
+-        blue_scale = green_scale = red_scale = 1;
++        blue_scale = green_scale = red_scale = 0;
+     } else if (comp == BMP_RGB && nbits == 16) {
+         blue_mask = 0x001f;
+         green_mask = 0x03e0;
+         red_mask = 0x7c00;
+         blue_shift = 0;
+-        green_shift = 2;
+-        red_shift = 7;
+-        red_scale = 1;
+-        green_scale = 1;
+-        blue_scale = 8;
++        green_shift = 5;
++        red_shift = 10;
++        blue_scale = green_scale = red_scale = 3;
+     }
+ 
+ #if 0
+@@ -544,10 +568,10 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+                     c |= *(uchar*)(b+2)<<16;
+                 if (nbits > 24)
+                     c |= *(uchar*)(b+3)<<24;
+-                *p++ = qRgba(((c & red_mask) >> red_shift) * red_scale,
+-                                        ((c & green_mask) >> green_shift) * green_scale,
+-                                        ((c & blue_mask) >> blue_shift) * blue_scale,
+-                                        transp ? ((c & alpha_mask) >> alpha_shift) * alpha_scale : 0xff);
++                *p++ = qRgba(apply_scale((c & red_mask) >> red_shift, red_scale),
++                             apply_scale((c & green_mask) >> green_shift, green_scale),
++                             apply_scale((c & blue_mask) >> blue_shift, blue_scale),
++                             transp ? apply_scale((c & alpha_mask) >> alpha_shift, alpha_scale) : 0xff);
+                 b += nbits/8;
+             }
+         }
+diff --git a/qtbase/src/gui/image/qimage.cpp b/qtbase/src/gui/image/qimage.cpp
+index 7152ac1607..0df772564c 100644
+--- a/qtbase/src/gui/image/qimage.cpp
++++ b/qtbase/src/gui/image/qimage.cpp
+@@ -4694,6 +4694,8 @@ QImage QImage::smoothScaled(int w, int h) const {
+ static QImage rotated90(const QImage &image)
+ {
+     QImage out(image.height(), image.width(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+@@ -4722,6 +4724,8 @@ static QImage rotated180(const QImage &image)
+         return image.mirrored(true, true);
+ 
+     QImage out(image.width(), image.height(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+@@ -4734,6 +4738,8 @@ static QImage rotated180(const QImage &image)
+ static QImage rotated270(const QImage &image)
+ {
+     QImage out(image.height(), image.width(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+diff --git a/qtbase/src/gui/kernel/qcursor.cpp b/qtbase/src/gui/kernel/qcursor.cpp
+index d6ccaff8ed..455088241c 100644
+--- a/qtbase/src/gui/kernel/qcursor.cpp
++++ b/qtbase/src/gui/kernel/qcursor.cpp
+@@ -251,7 +251,8 @@ void QCursor::setPos(QScreen *screen, int x, int y)
+ {
+     if (screen) {
+         if (QPlatformCursor *cursor = screen->handle()->cursor()) {
+-            const QPoint devicePos = QHighDpi::toNativePixels(QPoint(x, y), screen);
++            const QPoint pos(x, y);
++            const QPoint devicePos = QHighDpi::toNativePixels(pos, screen->virtualSiblingAt(pos));
+             // Need to check, since some X servers generate null mouse move
+             // events, causing looping in applications which call setPos() on
+             // every mouse move event.
+diff --git a/qtbase/src/gui/kernel/qhighdpiscaling.cpp b/qtbase/src/gui/kernel/qhighdpiscaling.cpp
+index 9bbf2773a9..3ac4a4d8b6 100644
+--- a/qtbase/src/gui/kernel/qhighdpiscaling.cpp
++++ b/qtbase/src/gui/kernel/qhighdpiscaling.cpp
+@@ -580,9 +580,8 @@ void QHighDpiScaling::setScreenFactor(QScreen *screen, qreal factor)
+     else
+         qNamedScreenScaleFactors()->insert(name, factor);
+ 
+-    // hack to force re-evaluation of screen geometry
+     if (screen->handle())
+-        screen->d_func()->setPlatformScreen(screen->handle()); // updates geometries based on scale factor
++        screen->d_func()->updateLogicalDpi();
+ }
+ 
+ QPoint QHighDpiScaling::mapPositionToNative(const QPoint &pos, const QPlatformScreen *platformScreen)
+diff --git a/qtbase/src/gui/kernel/qkeysequence.cpp b/qtbase/src/gui/kernel/qkeysequence.cpp
+index a75b8ef920..4f2d294739 100644
+--- a/qtbase/src/gui/kernel/qkeysequence.cpp
++++ b/qtbase/src/gui/kernel/qkeysequence.cpp
+@@ -701,6 +701,10 @@ static const struct {
+     { Qt::Key_TouchpadToggle,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad Toggle") },
+     { Qt::Key_TouchpadOn,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad On") },
+     { Qt::Key_TouchpadOff,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad Off") },
++    { Qt::Key_Shift,  QT_TRANSLATE_NOOP("QShortcut", "Shift") },
++    { Qt::Key_Control,  QT_TRANSLATE_NOOP("QShortcut", "Control") },
++    { Qt::Key_Alt,  QT_TRANSLATE_NOOP("QShortcut", "Alt") },
++    { Qt::Key_Meta,  QT_TRANSLATE_NOOP("QShortcut", "Meta") },
+ 
+ };
+ static Q_CONSTEXPR int numKeyNames = sizeof keyname / sizeof *keyname;
+diff --git a/qtbase/src/gui/kernel/qplatformservices.cpp b/qtbase/src/gui/kernel/qplatformservices.cpp
+index fdc6a6c4aa..ac47f98c5d 100644
+--- a/qtbase/src/gui/kernel/qplatformservices.cpp
++++ b/qtbase/src/gui/kernel/qplatformservices.cpp
+@@ -55,6 +55,19 @@ QT_BEGIN_NAMESPACE
+     \brief The QPlatformServices provides the backend for desktop-related functionality.
+ */
+ 
++/*!
++    \enum QPlatformServices::Capability
++
++    Capabilities are used to determine a specific platform service's availability.
++
++    \value ColorPickingFromScreen The platform natively supports color picking from screen.
++    This capability indicates that the platform supports "opaque" color picking, where the
++    platform implements a complete user experience for color picking and outputs a color.
++    This is in contrast to the application implementing the color picking user experience
++    (taking care of showing a cross hair, instructing the platform integration to obtain
++    the color at a given pixel, etc.). The related service function is pickColor().
++ */
++
+ QPlatformServices::QPlatformServices()
+ { }
+ 
+@@ -85,5 +98,16 @@ QByteArray QPlatformServices::desktopEnvironment() const
+     return QByteArray("UNKNOWN");
+ }
+ 
++QPlatformServiceColorPicker *QPlatformServices::colorPicker(QWindow *parent)
++{
++    Q_UNUSED(parent);
++    return nullptr;
++}
++
++bool QPlatformServices::hasCapability(Capability capability) const
++{
++    Q_UNUSED(capability)
++    return false;
++}
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/gui/kernel/qplatformservices.h b/qtbase/src/gui/kernel/qplatformservices.h
+index 5de96cfa7d..a8b2a4ce71 100644
+--- a/qtbase/src/gui/kernel/qplatformservices.h
++++ b/qtbase/src/gui/kernel/qplatformservices.h
+@@ -50,16 +50,32 @@
+ //
+ 
+ #include <QtGui/qtguiglobal.h>
++#include <QtCore/qobject.h>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+ class QUrl;
++class QWindow;
++
++class Q_GUI_EXPORT QPlatformServiceColorPicker : public QObject
++{
++    Q_OBJECT
++public:
++    using QObject::QObject;
++    virtual void pickColor() = 0;
++Q_SIGNALS:
++    void colorPicked(const QColor &color);
++};
+ 
+ class Q_GUI_EXPORT QPlatformServices
+ {
+ public:
+     Q_DISABLE_COPY_MOVE(QPlatformServices)
+ 
++    enum Capability {
++        ColorPicking,
++    };
++
+     QPlatformServices();
+     virtual ~QPlatformServices() { }
+ 
+@@ -67,6 +83,10 @@ public:
+     virtual bool openDocument(const QUrl &url);
+ 
+     virtual QByteArray desktopEnvironment() const;
++
++    virtual bool hasCapability(Capability capability) const;
++
++    virtual QPlatformServiceColorPicker *colorPicker(QWindow *parent = nullptr);
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/gui/kernel/qplatformtheme.cpp b/qtbase/src/gui/kernel/qplatformtheme.cpp
+index 71521c0339..2325873245 100644
+--- a/qtbase/src/gui/kernel/qplatformtheme.cpp
++++ b/qtbase/src/gui/kernel/qplatformtheme.cpp
+@@ -163,6 +163,8 @@ QT_BEGIN_NAMESPACE
+ 
+     \value ShowShortcutsInContextMenus (bool) Whether to display shortcut key sequences in context menus.
+ 
++    \value ButtonPressKeys (QList<Qt::Key>) A list of keys that can be used to press buttons via keyboard input.
++
+     \sa themeHint(), QStyle::pixelMetric()
+ */
+ 
+@@ -563,6 +565,8 @@ QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint)
+         }
+     case MouseQuickSelectionThreshold:
+         return QVariant(10);
++    case ButtonPressKeys:
++        return QVariant::fromValue(QList<Qt::Key>({ Qt::Key_Space, Qt::Key_Select }));
+     }
+     return QVariant();
+ }
+diff --git a/qtbase/src/gui/kernel/qplatformtheme.h b/qtbase/src/gui/kernel/qplatformtheme.h
+index 3185fc4541..7e6c9d5740 100644
+--- a/qtbase/src/gui/kernel/qplatformtheme.h
++++ b/qtbase/src/gui/kernel/qplatformtheme.h
+@@ -120,7 +120,8 @@ public:
+         TouchDoubleTapDistance,
+         ShowShortcutsInContextMenus,
+         IconFallbackSearchPaths,
+-        MouseQuickSelectionThreshold
++        MouseQuickSelectionThreshold,
++        ButtonPressKeys
+     };
+ 
+     enum DialogType {
+diff --git a/qtbase/src/gui/kernel/qscreen.cpp b/qtbase/src/gui/kernel/qscreen.cpp
+index 8e0eb35116..5d172a58dd 100644
+--- a/qtbase/src/gui/kernel/qscreen.cpp
++++ b/qtbase/src/gui/kernel/qscreen.cpp
+@@ -77,6 +77,12 @@ QScreen::QScreen(QPlatformScreen *screen)
+     d->setPlatformScreen(screen);
+ }
+ 
++void QScreenPrivate::updateLogicalDpi()
++{
++    logicalDpi = QPlatformScreen::overrideDpi(platformScreen->logicalDpi());
++    updateGeometriesWithSignals(); // updates geometries based on scale factor
++}
++
+ void QScreenPrivate::updateGeometriesWithSignals()
+ {
+     const QRect oldGeometry = geometry;
+diff --git a/qtbase/src/gui/kernel/qscreen_p.h b/qtbase/src/gui/kernel/qscreen_p.h
+index 7da542c25e..e50fc3190b 100644
+--- a/qtbase/src/gui/kernel/qscreen_p.h
++++ b/qtbase/src/gui/kernel/qscreen_p.h
+@@ -70,6 +70,7 @@ public:
+         geometry = platformScreen->deviceIndependentGeometry();
+         availableGeometry = QHighDpi::fromNative(platformScreen->availableGeometry(), QHighDpiScaling::factor(platformScreen), geometry.topLeft());
+     }
++    void updateLogicalDpi();
+ 
+     void updatePrimaryOrientation();
+     void updateGeometriesWithSignals();
+diff --git a/qtbase/src/gui/painting/qblendfunctions_p.h b/qtbase/src/gui/painting/qblendfunctions_p.h
+index 080da98ec4..6997d62b3c 100644
+--- a/qtbase/src/gui/painting/qblendfunctions_p.h
++++ b/qtbase/src/gui/painting/qblendfunctions_p.h
+@@ -246,25 +246,32 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+                                   int dudx, int dvdx, int dudy, int dvdy, int u0, int v0,
+                                   Blender blender)
+ {
+-    int fromY = qMax(qRound(topY), clip.top());
+-    int toY = qMin(qRound(bottomY), clip.top() + clip.height());
++    qint64 fromY = qMax(qRound(topY), clip.top());
++    qint64 toY = qMin(qRound(bottomY), clip.top() + clip.height());
+     if (fromY >= toY)
+         return;
+ 
+     qreal leftSlope = (bottomLeft.x - topLeft.x) / (bottomLeft.y - topLeft.y);
+     qreal rightSlope = (bottomRight.x - topRight.x) / (bottomRight.y - topRight.y);
+-    int dx_l = int(leftSlope * 0x10000);
+-    int dx_r = int(rightSlope * 0x10000);
+-    int x_l = int((topLeft.x + (qreal(0.5) + fromY - topLeft.y) * leftSlope + qreal(0.5)) * 0x10000);
+-    int x_r = int((topRight.x + (qreal(0.5) + fromY - topRight.y) * rightSlope + qreal(0.5)) * 0x10000);
+-
+-    int fromX, toX, x1, x2, u, v, i, ii;
++    qint64 dx_l = qint64(leftSlope * 0x10000);
++    qint64 dx_r = qint64(rightSlope * 0x10000);
++    qint64 x_l = qint64((topLeft.x + (qreal(0.5) + fromY - topLeft.y) * leftSlope + qreal(0.5)) * 0x10000);
++    qint64 x_r = qint64((topRight.x + (qreal(0.5) + fromY - topRight.y) * rightSlope + qreal(0.5)) * 0x10000);
++
++    qint64 sourceRectTop = qint64(sourceRect.top());
++    qint64 sourceRectLeft = qint64(sourceRect.left());
++    qint64 sourceRectWidth = qint64(sourceRect.width());
++    qint64 sourceRectHeight = qint64(sourceRect.height());
++    qint64 clipLeft = qint64(clip.left());
++    qint64 clipWidth = qint64(clip.width());
++
++    qint64 fromX, toX, x1, x2, u, v, i, ii;
+     DestT *line;
+-    for (int y = fromY; y < toY; ++y) {
++    for (qint64 y = fromY; y < toY; ++y) {
+         line = reinterpret_cast<DestT *>(reinterpret_cast<uchar *>(destPixels) + y * dbpl);
+ 
+-        fromX = qMax(x_l >> 16, clip.left());
+-        toX = qMin(x_r >> 16, clip.left() + clip.width());
++        fromX = qMax(x_l >> 16, clipLeft);
++        toX = qMin(x_r >> 16, clipLeft + clipWidth);
+         if (fromX < toX) {
+             // Because of rounding, we can get source coordinates outside the source image.
+             // Clamp these coordinates to the source rect to avoid segmentation fault and
+@@ -275,10 +282,10 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             u = x1 * dudx + y * dudy + u0;
+             v = x1 * dvdx + y * dvdy + v0;
+             for (; x1 < toX; ++x1) {
+-                int uu = u >> 16;
+-                int vv = v >> 16;
+-                if (uu >= sourceRect.left() && uu < sourceRect.left() + sourceRect.width()
+-                    && vv >= sourceRect.top() && vv < sourceRect.top() + sourceRect.height()) {
++                qint64 uu = u >> 16;
++                qint64 vv = v >> 16;
++                if (uu >= sourceRectLeft && uu < sourceRectLeft + sourceRectWidth
++                    && vv >= sourceRectTop && vv < sourceRectTop + sourceRectHeight) {
+                     break;
+                 }
+                 u += dudx;
+@@ -290,10 +297,10 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             u = (x2 - 1) * dudx + y * dudy + u0;
+             v = (x2 - 1) * dvdx + y * dvdy + v0;
+             for (; x2 > x1; --x2) {
+-                int uu = u >> 16;
+-                int vv = v >> 16;
+-                if (uu >= sourceRect.left() && uu < sourceRect.left() + sourceRect.width()
+-                    && vv >= sourceRect.top() && vv < sourceRect.top() + sourceRect.height()) {
++                qint64 uu = u >> 16;
++                qint64 vv = v >> 16;
++                if (uu >= sourceRectLeft && uu < sourceRectLeft + sourceRectWidth
++                    && vv >= sourceRectTop && vv < sourceRectTop + sourceRectHeight) {
+                     break;
+                 }
+                 u -= dudx;
+@@ -308,8 +315,8 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             // Beginning of the scan line, with per-pixel checks.
+             i = x1 - fromX;
+             while (i) {
+-                int uu = qBound(sourceRect.left(), u >> 16, sourceRect.left() + sourceRect.width() - 1);
+-                int vv = qBound(sourceRect.top(), v >> 16, sourceRect.top() + sourceRect.height() - 1);
++                qint64 uu = qBound(sourceRectLeft, u >> 16, sourceRectLeft + sourceRectWidth - 1);
++                qint64 vv = qBound(sourceRectTop, v >> 16, sourceRectTop + sourceRectHeight - 1);
+                 blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + vv * sbpl)[uu]);
+                 u += dudx;
+                 v += dvdx;
+@@ -348,8 +355,8 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             // End of the scan line, with per-pixel checks.
+             i = toX - x2;
+             while (i) {
+-                int uu = qBound(sourceRect.left(), u >> 16, sourceRect.left() + sourceRect.width() - 1);
+-                int vv = qBound(sourceRect.top(), v >> 16, sourceRect.top() + sourceRect.height() - 1);
++                qint64 uu = qBound(sourceRectLeft, u >> 16, sourceRectLeft + sourceRectWidth - 1);
++                qint64 vv = qBound(sourceRectTop, v >> 16, sourceRectTop + sourceRectHeight - 1);
+                 blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + vv * sbpl)[uu]);
+                 u += dudx;
+                 v += dvdx;
+diff --git a/qtbase/src/gui/painting/qcolortrclut_p.h b/qtbase/src/gui/painting/qcolortrclut_p.h
+index 76a6a60803..24fd522e6c 100644
+--- a/qtbase/src/gui/painting/qcolortrclut_p.h
++++ b/qtbase/src/gui/painting/qcolortrclut_p.h
+@@ -118,6 +118,7 @@ public:
+         return QRgba64::fromRgba64(r, g, b, qAlpha(rgb32) * 257);
+ #endif
+     }
++    QRgba64 toLinear64(QRgba64) const = delete;
+ 
+     QRgb toLinear(QRgb rgb32) const
+     {
+diff --git a/qtbase/src/gui/painting/qdrawhelper.cpp b/qtbase/src/gui/painting/qdrawhelper.cpp
+index a61793508a..5ba2d277b7 100644
+--- a/qtbase/src/gui/painting/qdrawhelper.cpp
++++ b/qtbase/src/gui/painting/qdrawhelper.cpp
+@@ -6091,7 +6091,7 @@ static inline void alphargbblend_argb32(quint32 *dst, uint coverage, const QRgba
+ static inline void rgbBlendPixel(QRgba64 &dst, int coverage, QRgba64 slinear, const QColorTrcLut *colorProfile)
+ {
+     // Do a gammacorrected RGB alphablend...
+-    const QRgba64 dlinear = colorProfile ? colorProfile->toLinear64(dst) : dst;
++    const QRgba64 dlinear = colorProfile ? colorProfile->toLinear(dst) : dst;
+ 
+     QRgba64 blend = rgbBlend(dlinear, slinear, coverage);
+ 
+diff --git a/qtbase/src/gui/painting/qpaintengine_raster.cpp b/qtbase/src/gui/painting/qpaintengine_raster.cpp
+index 283923de52..f08eb9cbee 100644
+--- a/qtbase/src/gui/painting/qpaintengine_raster.cpp
++++ b/qtbase/src/gui/painting/qpaintengine_raster.cpp
+@@ -560,31 +560,6 @@ void QRasterPaintEngine::updateMatrix(const QTransform &matrix)
+     QRasterPaintEngineState *s = state();
+     // FALCON: get rid of this line, see drawImage call below.
+     s->matrix = matrix;
+-    QTransform::TransformationType txop = s->matrix.type();
+-
+-    switch (txop) {
+-
+-    case QTransform::TxNone:
+-        s->flags.int_xform = true;
+-        break;
+-
+-    case QTransform::TxTranslate:
+-        s->flags.int_xform = qreal(int(s->matrix.dx())) == s->matrix.dx()
+-                            && qreal(int(s->matrix.dy())) == s->matrix.dy();
+-        break;
+-
+-    case QTransform::TxScale:
+-        s->flags.int_xform = qreal(int(s->matrix.dx())) == s->matrix.dx()
+-                            && qreal(int(s->matrix.dy())) == s->matrix.dy()
+-                            && qreal(int(s->matrix.m11())) == s->matrix.m11()
+-                            && qreal(int(s->matrix.m22())) == s->matrix.m22();
+-        break;
+-
+-    default: // shear / perspective...
+-        s->flags.int_xform = false;
+-        break;
+-    }
+-
+     s->flags.tx_noshear = qt_scaleForTransform(s->matrix, &s->txscale);
+ 
+     ensureOutlineMapper();
+@@ -617,7 +592,6 @@ QRasterPaintEngineState::QRasterPaintEngineState()
+     flags.bilinear = false;
+     flags.legacy_rounding = false;
+     flags.fast_text = true;
+-    flags.int_xform = true;
+     flags.tx_noshear = true;
+     flags.fast_images = true;
+ 
+@@ -1793,7 +1767,7 @@ void QRasterPaintEngine::fill(const QVectorPath &path, const QBrush &brush)
+     QRectF cpRect = path.controlPointRect();
+     const QRectF pathDeviceRect = s->matrix.mapRect(cpRect);
+     // Skip paths that by conservative estimates are completely outside the paint device.
+-    if (!pathDeviceRect.intersects(QRectF(d->deviceRect)))
++    if (!pathDeviceRect.intersects(QRectF(d->deviceRect)) || !pathDeviceRect.isValid())
+         return;
+ 
+     ProcessSpans blend = d->getBrushFunc(pathDeviceRect, &s->brushData);
+diff --git a/qtbase/src/gui/painting/qpaintengine_raster_p.h b/qtbase/src/gui/painting/qpaintengine_raster_p.h
+index 089aadc3f7..bf7363d5aa 100644
+--- a/qtbase/src/gui/painting/qpaintengine_raster_p.h
++++ b/qtbase/src/gui/painting/qpaintengine_raster_p.h
+@@ -111,7 +111,6 @@ public:
+         uint bilinear : 1;
+         uint legacy_rounding : 1;
+         uint fast_text : 1;
+-        uint int_xform : 1;
+         uint tx_noshear : 1;
+         uint fast_images : 1;
+     };
+diff --git a/qtbase/src/gui/painting/qpainterpath.cpp b/qtbase/src/gui/painting/qpainterpath.cpp
+index f9544a3241..d80fafeaf1 100644
+--- a/qtbase/src/gui/painting/qpainterpath.cpp
++++ b/qtbase/src/gui/painting/qpainterpath.cpp
+@@ -1253,7 +1253,7 @@ void QPainterPath::addText(const QPointF &point, const QFont &f, const QString &
+ 
+         if (si.analysis.flags < QScriptAnalysis::TabOrObject) {
+             QGlyphLayout glyphs = eng->shapedGlyphs(&si);
+-            QFontEngine *fe = f.d->engineForScript(si.analysis.script);
++            QFontEngine *fe = eng->fontEngine(si);
+             Q_ASSERT(fe);
+             fe->addOutlineToPath(x, y, glyphs, this,
+                                  si.analysis.bidiLevel % 2
+diff --git a/qtbase/src/gui/painting/qpathclipper_p.h b/qtbase/src/gui/painting/qpathclipper_p.h
+index 9444a87b71..18f64c5e8c 100644
+--- a/qtbase/src/gui/painting/qpathclipper_p.h
++++ b/qtbase/src/gui/painting/qpathclipper_p.h
+@@ -156,7 +156,7 @@ public:
+     int vertex(Direction direction) const;
+ 
+ private:
+-    int m_next[2][2];
++    int m_next[2][2] = { { -1, -1 }, { -1, -1 } };
+ };
+ 
+ class QPathSegments
+@@ -296,10 +296,6 @@ inline QPathEdge::QPathEdge(int a, int b)
+     , angle(0)
+     , invAngle(0)
+ {
+-    m_next[0][0] = -1;
+-    m_next[1][0] = -1;
+-    m_next[0][0] = -1;
+-    m_next[1][0] = -1;
+ }
+ 
+ inline int QPathEdge::next(Traversal traversal, Direction direction) const
+diff --git a/qtbase/src/gui/painting/qpdf.cpp b/qtbase/src/gui/painting/qpdf.cpp
+index 3066744f1b..2c8d3c3b53 100644
+--- a/qtbase/src/gui/painting/qpdf.cpp
++++ b/qtbase/src/gui/painting/qpdf.cpp
+@@ -2760,6 +2760,8 @@ int QPdfEnginePrivate::addBrushPattern(const QTransform &m, bool *specifyColor,
+         return gradientBrush(brush, matrix, gStateObject);
+     }
+ 
++    matrix = brush.transform() * matrix;
++
+     if ((!brush.isOpaque() && brush.style() < Qt::LinearGradientPattern) || opacity != 1.0)
+         *gStateObject = addConstantAlphaObject(qRound(brush.color().alpha() * opacity),
+                                                qRound(pen.color().alpha() * opacity));
+diff --git a/qtbase/src/gui/painting/qstroker.cpp b/qtbase/src/gui/painting/qstroker.cpp
+index cb5d395e80..3b6357a893 100644
+--- a/qtbase/src/gui/painting/qstroker.cpp
++++ b/qtbase/src/gui/painting/qstroker.cpp
+@@ -1182,6 +1182,7 @@ void QDashStroker::processCurrentSubpath()
+         // Check if the entire line should be clipped away or simplified
+         bool clipIt = clipping && !lineIntersectsRect(prev, e, clip_tl, clip_br);
+         bool skipDashing = elen * invSumLength > repetitionLimit();
++        int maxDashes = dashCount;
+         if (skipDashing || clipIt) {
+             // Cut away full dash sequences.
+             elen -= std::floor(elen * invSumLength) * sumLength;
+@@ -1196,7 +1197,7 @@ void QDashStroker::processCurrentSubpath()
+                     pos = estop; // move pos to next path element
+                     done = true;
+                 } else { // Dash is on this line
+-                    pos = dpos + estart;
++                    pos = --maxDashes > 0 ? dpos + estart : estop;
+                     done = pos >= estop;
+                     if (++idash >= dashCount)
+                         idash = 0;
+diff --git a/qtbase/src/gui/painting/qt_attribution.json b/qtbase/src/gui/painting/qt_attribution.json
+index 7b16e8c211..0e87d30aa2 100644
+--- a/qtbase/src/gui/painting/qt_attribution.json
++++ b/qtbase/src/gui/painting/qt_attribution.json
+@@ -10,7 +10,7 @@
+         "Homepage": "http://www.freetype.org",
+         "License": "Freetype Project License or GNU General Public License v2.0 only",
+         "LicenseId": "FTL or GPL-2.0",
+-        "LicenseFile": "../../3rdparty/freetype/docs/LICENSE.TXT",
++        "LicenseFile": "../../3rdparty/freetype/LICENSE.TXT",
+         "Copyright": "Copyright 2000-2016 by David Turner, Robert Wilhelm, and Werner Lemberg."
+     },
+     {
+diff --git a/qtbase/src/gui/rhi/qshader_p_p.h b/qtbase/src/gui/rhi/qshader_p_p.h
+index ec9d25971f..4a5a7a6d51 100644
+--- a/qtbase/src/gui/rhi/qshader_p_p.h
++++ b/qtbase/src/gui/rhi/qshader_p_p.h
+@@ -68,13 +68,13 @@ struct Q_GUI_EXPORT QShaderPrivate
+     {
+     }
+ 
+-    QShaderPrivate(const QShaderPrivate *other)
++    QShaderPrivate(const QShaderPrivate &other)
+         : ref(1),
+-          qsbVersion(other->qsbVersion),
+-          stage(other->stage),
+-          desc(other->desc),
+-          shaders(other->shaders),
+-          bindings(other->bindings)
++          qsbVersion(other.qsbVersion),
++          stage(other.stage),
++          desc(other.desc),
++          shaders(other.shaders),
++          bindings(other.bindings)
+     {
+     }
+ 
+diff --git a/qtbase/src/gui/rhi/qshaderdescription_p_p.h b/qtbase/src/gui/rhi/qshaderdescription_p_p.h
+index ec2b0b6b4c..3da33a8a2b 100644
+--- a/qtbase/src/gui/rhi/qshaderdescription_p_p.h
++++ b/qtbase/src/gui/rhi/qshaderdescription_p_p.h
+@@ -63,16 +63,16 @@ struct Q_GUI_EXPORT QShaderDescriptionPrivate
+         localSize[0] = localSize[1] = localSize[2] = 0;
+     }
+ 
+-    QShaderDescriptionPrivate(const QShaderDescriptionPrivate *other)
++    QShaderDescriptionPrivate(const QShaderDescriptionPrivate &other)
+         : ref(1),
+-          inVars(other->inVars),
+-          outVars(other->outVars),
+-          uniformBlocks(other->uniformBlocks),
+-          pushConstantBlocks(other->pushConstantBlocks),
+-          storageBlocks(other->storageBlocks),
+-          combinedImageSamplers(other->combinedImageSamplers),
+-          storageImages(other->storageImages),
+-          localSize(other->localSize)
++          inVars(other.inVars),
++          outVars(other.outVars),
++          uniformBlocks(other.uniformBlocks),
++          pushConstantBlocks(other.pushConstantBlocks),
++          storageBlocks(other.storageBlocks),
++          combinedImageSamplers(other.combinedImageSamplers),
++          storageImages(other.storageImages),
++          localSize(other.localSize)
+     {
+     }
+ 
+diff --git a/qtbase/src/gui/text/qfontdatabase.cpp b/qtbase/src/gui/text/qfontdatabase.cpp
+index a657a8c516..4fc0100958 100644
+--- a/qtbase/src/gui/text/qfontdatabase.cpp
++++ b/qtbase/src/gui/text/qfontdatabase.cpp
+@@ -983,7 +983,7 @@ QFontEngine *loadSingleEngine(int script,
+         if (style->key.stretch != 0 && request.stretch != 0
+             && (request.styleName.isEmpty() || request.styleName != style->styleName)) {
+             def.stretch = (request.stretch * 100 + style->key.stretch / 2) / style->key.stretch;
+-        } else {
++        } else if (request.stretch == QFont::AnyStretch) {
+             def.stretch = 100;
+         }
+ 
+diff --git a/qtbase/src/gui/text/qtextdocumentlayout.cpp b/qtbase/src/gui/text/qtextdocumentlayout.cpp
+index f3e6ea2100..72267e9380 100644
+--- a/qtbase/src/gui/text/qtextdocumentlayout.cpp
++++ b/qtbase/src/gui/text/qtextdocumentlayout.cpp
+@@ -2123,7 +2123,7 @@ void QTextDocumentLayoutPrivate::drawListItem(const QPointF &offset, QPainter *p
+ {
+     Q_Q(const QTextDocumentLayout);
+     const QTextBlockFormat blockFormat = bl.blockFormat();
+-    const QTextCharFormat charFormat = QTextCursor(bl).charFormat();
++    const QTextCharFormat charFormat = bl.charFormat();
+     QFont font(charFormat.font());
+     if (q->paintDevice())
+         font = QFont(font, q->paintDevice());
+diff --git a/qtbase/src/gui/text/qtextengine.cpp b/qtbase/src/gui/text/qtextengine.cpp
+index ce4abac472..a6c66e5d2d 100644
+--- a/qtbase/src/gui/text/qtextengine.cpp
++++ b/qtbase/src/gui/text/qtextengine.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2021 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtGui module of the Qt Toolkit.
+@@ -1565,6 +1565,12 @@ void QTextEngine::shapeText(int item) const
+         // Overwrite with 0 token to indicate failure
+         QGlyphLayout g = availableGlyphs(&si);
+         g.glyphs[0] = 0;
++        g.attributes[0].clusterStart = true;
++
++        ushort *log_clusters = logClusters(&si);
++        for (int i = 0; i < itemLength; ++i)
++            log_clusters[i] = 0;
++
+         return;
+     }
+ 
+diff --git a/qtbase/src/gui/util/qdesktopservices.cpp b/qtbase/src/gui/util/qdesktopservices.cpp
+index fbb63a9408..4d5fafaaa7 100644
+--- a/qtbase/src/gui/util/qdesktopservices.cpp
++++ b/qtbase/src/gui/util/qdesktopservices.cpp
+@@ -54,6 +54,8 @@
+ #include <qpa/qplatformintegration.h>
+ #include <qdir.h>
+ 
++#include <QtCore/private/qlocking_p.h>
++
+ QT_BEGIN_NAMESPACE
+ 
+ class QOpenUrlHandlerRegistry : public QObject
+@@ -81,6 +83,7 @@ Q_GLOBAL_STATIC(QOpenUrlHandlerRegistry, handlerRegistry)
+ 
+ void QOpenUrlHandlerRegistry::handlerDestroyed(QObject *handler)
+ {
++    const auto lock = qt_scoped_lock(mutex);
+     HandlerHash::Iterator it = handlers.begin();
+     while (it != handlers.end()) {
+         if (it->receiver == handler) {
+@@ -294,7 +297,8 @@ void QDesktopServices::setUrlHandler(const QString &scheme, QObject *receiver, c
+     h.name = method;
+     registry->handlers.insert(scheme.toLower(), h);
+     QObject::connect(receiver, SIGNAL(destroyed(QObject*)),
+-                     registry, SLOT(handlerDestroyed(QObject*)));
++                     registry, SLOT(handlerDestroyed(QObject*)),
++                     Qt::DirectConnection);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/gui/util/qpkmhandler.cpp b/qtbase/src/gui/util/qpkmhandler.cpp
+index e0c3b75efe..3414f9d8ba 100644
+--- a/qtbase/src/gui/util/qpkmhandler.cpp
++++ b/qtbase/src/gui/util/qpkmhandler.cpp
+@@ -57,7 +57,7 @@ struct PkmType
+     quint32 bytesPerBlock;
+ };
+ 
+-static PkmType typeMap[5] = {
++static constexpr PkmType typeMap[5] = {
+     { 0x8D64,  8 },   // GL_ETC1_RGB8_OES
+     { 0x9274,  8 },   // GL_COMPRESSED_RGB8_ETC2
+     { 0, 0 },         // unused (obsolete)
+diff --git a/qtbase/src/network/access/qnetworkreplyfileimpl.cpp b/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
+index b6be93147a..6e69b4c4d3 100644
+--- a/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
++++ b/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
+@@ -89,9 +89,10 @@ QNetworkReplyFileImpl::QNetworkReplyFileImpl(QNetworkAccessManager *manager, con
+         // we handle only local files
+         QString msg = QCoreApplication::translate("QNetworkAccessFileBackend", "Request for opening non-local file %1").arg(url.toString());
+         setError(QNetworkReply::ProtocolInvalidOperationError, msg);
++        setFinished(true); // We're finished, will emit finished() after ctor is done.
+         QMetaObject::invokeMethod(this, "errorOccurred", Qt::QueuedConnection,
+             Q_ARG(QNetworkReply::NetworkError, QNetworkReply::ProtocolInvalidOperationError));
+-        fileOpenFinished(false);
++        QMetaObject::invokeMethod(this, [this](){ fileOpenFinished(false); }, Qt::QueuedConnection);
+         return;
+     }
+ #endif
+diff --git a/qtbase/src/network/access/qnetworkreplyimpl.cpp b/qtbase/src/network/access/qnetworkreplyimpl.cpp
+index bcdf6ee2f1..3b6deb82bd 100644
+--- a/qtbase/src/network/access/qnetworkreplyimpl.cpp
++++ b/qtbase/src/network/access/qnetworkreplyimpl.cpp
+@@ -680,7 +680,7 @@ void QNetworkReplyImplPrivate::appendDownstreamData(QIODevice *data)
+     // read until EOF from data
+     if (Q_UNLIKELY(copyDevice)) {
+         qCritical("QNetworkReplyImpl: copy from QIODevice already in progress -- "
+-                  "backend probly needs to be fixed");
++                  "backend probably needs to be fixed");
+         return;
+     }
+ 
+diff --git a/qtbase/src/network/kernel/qauthenticator.cpp b/qtbase/src/network/kernel/qauthenticator.cpp
+index d9fe7bc47b..ccd04b294a 100644
+--- a/qtbase/src/network/kernel/qauthenticator.cpp
++++ b/qtbase/src/network/kernel/qauthenticator.cpp
+@@ -50,6 +50,7 @@
+ #include <qstring.h>
+ #include <qdatetime.h>
+ #include <qrandom.h>
++#include "private/qsystemlibrary_p.h"
+ 
+ #ifdef Q_OS_WIN
+ #include <qmutex.h>
+@@ -1563,7 +1564,7 @@ static bool q_SSPI_library_load()
+ 
+     // Initialize security interface
+     if (pSecurityFunctionTable == nullptr) {
+-        securityDLLHandle = LoadLibrary(L"secur32.dll");
++        securityDLLHandle = QSystemLibrary::load(L"secur32");
+         if (securityDLLHandle != nullptr) {
+             INIT_SECURITY_INTERFACE pInitSecurityInterface =
+                 reinterpret_cast<INIT_SECURITY_INTERFACE>(
+diff --git a/qtbase/src/network/kernel/qhostinfo_unix.cpp b/qtbase/src/network/kernel/qhostinfo_unix.cpp
+index 9b0a2ee669..73679c9ef1 100644
+--- a/qtbase/src/network/kernel/qhostinfo_unix.cpp
++++ b/qtbase/src/network/kernel/qhostinfo_unix.cpp
+@@ -122,7 +122,6 @@ static QFunctionPointer resolveSymbol(QLibrary &lib, const char *sym)
+ 
+ LibResolv::LibResolv()
+ {
+-    QLibrary lib;
+ #ifdef LIBRESOLV_SO
+     lib.setFileName(QStringLiteral(LIBRESOLV_SO));
+     if (!lib.load())
+diff --git a/qtbase/src/network/socket/qsocks5socketengine.cpp b/qtbase/src/network/socket/qsocks5socketengine.cpp
+index 3a046fd116..97fadca0b3 100644
+--- a/qtbase/src/network/socket/qsocks5socketengine.cpp
++++ b/qtbase/src/network/socket/qsocks5socketengine.cpp
+@@ -1296,7 +1296,7 @@ void QSocks5SocketEnginePrivate::_q_udpSocketReadNotification()
+         int pos = 0;
+         const char *buf = inBuf.constData();
+         if (inBuf.size() < 4) {
+-            QSOCKS5_D_DEBUG << "bugus udp data, discarding";
++            QSOCKS5_D_DEBUG << "bogus udp data, discarding";
+             return;
+         }
+         QSocks5RevivedDatagram datagram;
+diff --git a/qtbase/src/network/ssl/qsslcontext_openssl.cpp b/qtbase/src/network/ssl/qsslcontext_openssl.cpp
+index c9f202f573..c992da9d8e 100644
+--- a/qtbase/src/network/ssl/qsslcontext_openssl.cpp
++++ b/qtbase/src/network/ssl/qsslcontext_openssl.cpp
+@@ -409,7 +409,7 @@ init_context:
+         break;
+     case QSsl::DtlsV1_0OrLater:
+         minVersion = DTLS1_VERSION;
+-        maxVersion = DTLS_MAX_VERSION;
++        maxVersion = 0;
+         break;
+     case QSsl::DtlsV1_2:
+         minVersion = DTLS1_2_VERSION;
+@@ -417,7 +417,7 @@ init_context:
+         break;
+     case QSsl::DtlsV1_2OrLater:
+         minVersion = DTLS1_2_VERSION;
+-        maxVersion = DTLS_MAX_VERSION;
++        maxVersion = 0;
+         break;
+     case QSsl::TlsV1_3OrLater:
+ #ifdef TLS1_3_VERSION
+@@ -455,7 +455,7 @@ init_context:
+     }
+ 
+     // Enable bug workarounds.
+-    long options = QSslSocketBackendPrivate::setupOpenSslOptions(configuration.protocol(), configuration.d->sslOptions);
++    qssloptions options = QSslSocketBackendPrivate::setupOpenSslOptions(configuration.protocol(), configuration.d->sslOptions);
+     q_SSL_CTX_set_options(sslContext->ctx, options);
+ 
+     // Tell OpenSSL to release memory early
+diff --git a/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp b/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
+index aaf8741130..b58935372c 100644
+--- a/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
++++ b/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
+@@ -59,57 +59,6 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-#ifdef OPENSSL_NO_DEPRECATED_3_0
+-
+-static int q_DH_check(DH *dh, int *status)
+-{
+-    // DH_check was first deprecated in OpenSSL 3.0.0, as low-level
+-    // API; the EVP_PKEY family of functions was advised as an alternative.
+-    // As of now EVP_PKEY_params_check ends up calling ... DH_check,
+-    // which is good enough.
+-
+-    Q_ASSERT(dh);
+-    Q_ASSERT(status);
+-
+-    EVP_PKEY *key = q_EVP_PKEY_new();
+-    if (!key) {
+-        qCWarning(lcSsl, "EVP_PKEY_new failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-    const auto keyDeleter = qScopeGuard([key](){
+-        q_EVP_PKEY_free(key);
+-    });
+-    if (!q_EVP_PKEY_set1_DH(key, dh)) {
+-        qCWarning(lcSsl, "EVP_PKEY_set1_DH failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-
+-    EVP_PKEY_CTX *keyCtx = q_EVP_PKEY_CTX_new(key, nullptr);
+-    if (!keyCtx) {
+-        qCWarning(lcSsl, "EVP_PKEY_CTX_new failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-    const auto ctxDeleter = qScopeGuard([keyCtx]{
+-        q_EVP_PKEY_CTX_free(keyCtx);
+-    });
+-
+-    const int result = q_EVP_PKEY_param_check(keyCtx);
+-    QSslSocketBackendPrivate::logAndClearErrorQueue();
+-    // Note: unlike DH_check, we cannot obtain the 'status',
+-    // if the 'result' is 0 (actually the result is 1 only
+-    // if this 'status' was 0). We could probably check the
+-    // errors from the error queue, but it's not needed anyway
+-    // - see the 'isSafeDH' below, how it returns immediately
+-    // on 0.
+-    Q_UNUSED(status)
+-
+-    return result;
+-}
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+-
+ static bool isSafeDH(DH *dh)
+ {
+     int status = 0;
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl.cpp b/qtbase/src/network/ssl/qsslsocket_openssl.cpp
+index 37fad2a68f..8f6858c867 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl.cpp
++++ b/qtbase/src/network/ssl/qsslsocket_openssl.cpp
+@@ -550,9 +550,9 @@ static void q_loadCiphersForConnection(SSL *connection, QList<QSslCipher> &ciphe
+ // Defined in qsslsocket.cpp
+ void q_setDefaultDtlsCiphers(const QList<QSslCipher> &ciphers);
+ 
+-long QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions)
++qssloptions QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions)
+ {
+-    long options;
++    qssloptions options;
+     if (protocol == QSsl::TlsV1SslV3)
+         options = SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3;
+     else if (protocol == QSsl::SecureProtocols)
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_p.h b/qtbase/src/network/ssl/qsslsocket_openssl_p.h
+index 4103de23e8..5547589256 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_p.h
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_p.h
+@@ -107,6 +107,12 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++typedef uint64_t qssloptions;
++#else
++typedef unsigned long qssloptions;
++#endif
++
+ struct QSslErrorEntry {
+     int code;
+     int depth;
+@@ -171,7 +177,7 @@ public:
+     QVector<QSslError> ocspErrors;
+     QByteArray ocspResponseDer;
+ 
+-    Q_AUTOTEST_EXPORT static long setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions);
++    Q_AUTOTEST_EXPORT static qssloptions setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions);
+     static QSslCipher QSslCipher_from_SSL_CIPHER(const SSL_CIPHER *cipher);
+     static QList<QSslCertificate> STACKOFX509_to_QSslCertificates(STACK_OF(X509) *x509);
+     static QList<QSslError> verify(const QList<QSslCertificate> &certificateChain, const QString &hostName);
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp b/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
+index e53fb279f0..459ccd0b19 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
+@@ -148,7 +148,6 @@ DEFINEFUNC(int, EVP_PKEY_up_ref, EVP_PKEY *a, a, return 0, return)
+ DEFINEFUNC2(EVP_PKEY_CTX *, EVP_PKEY_CTX_new, EVP_PKEY *pkey, pkey, ENGINE *e, e, return nullptr, return)
+ DEFINEFUNC(int, EVP_PKEY_param_check, EVP_PKEY_CTX *ctx, ctx, return 0, return)
+ DEFINEFUNC(void, EVP_PKEY_CTX_free, EVP_PKEY_CTX *ctx, ctx, return, return)
+-DEFINEFUNC(int, EVP_PKEY_base_id, EVP_PKEY *a, a, return NID_undef, return)
+ DEFINEFUNC(int, RSA_bits, RSA *a, a, return 0, return)
+ DEFINEFUNC(int, DSA_bits, DSA *a, a, return 0, return)
+ DEFINEFUNC(int, OPENSSL_sk_num, OPENSSL_STACK *a, a, return -1, return)
+@@ -158,7 +157,7 @@ DEFINEFUNC2(void, OPENSSL_sk_push, OPENSSL_STACK *a, a, void *b, b, return, DUMM
+ DEFINEFUNC(void, OPENSSL_sk_free, OPENSSL_STACK *a, a, return, DUMMYARG)
+ DEFINEFUNC2(void *, OPENSSL_sk_value, OPENSSL_STACK *a, a, int b, b, return nullptr, return)
+ DEFINEFUNC(int, SSL_session_reused, SSL *a, a, return 0, return)
+-DEFINEFUNC2(unsigned long, SSL_CTX_set_options, SSL_CTX *ctx, ctx, unsigned long op, op, return 0, return)
++DEFINEFUNC2(qssloptions, SSL_CTX_set_options, SSL_CTX *ctx, ctx, qssloptions op, op, return 0, return)
+ DEFINEFUNC(int, SSL_CTX_get_security_level, const SSL_CTX *ctx, ctx, return -1, return)
+ DEFINEFUNC2(void, SSL_CTX_set_security_level, SSL_CTX *ctx, ctx, int level, level, return, return)
+ #ifdef TLS1_3_VERSION
+@@ -371,7 +370,15 @@ DEFINEFUNC(const SSL_CIPHER *, SSL_get_current_cipher, SSL *a, a, return nullptr
+ DEFINEFUNC(int, SSL_version, const SSL *a, a, return 0, return)
+ DEFINEFUNC2(int, SSL_get_error, SSL *a, a, int b, b, return -1, return)
+ DEFINEFUNC(STACK_OF(X509) *, SSL_get_peer_cert_chain, SSL *a, a, return nullptr, return)
++
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++DEFINEFUNC(X509 *, SSL_get1_peer_certificate, SSL *a, a, return nullptr, return)
++DEFINEFUNC(int, EVP_PKEY_get_base_id, const EVP_PKEY *pkey, pkey, return -1, return)
++#else
+ DEFINEFUNC(X509 *, SSL_get_peer_certificate, SSL *a, a, return nullptr, return)
++DEFINEFUNC(int, EVP_PKEY_base_id, EVP_PKEY *a, a, return NID_undef, return)
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+ DEFINEFUNC(long, SSL_get_verify_result, const SSL *a, a, return -1, return)
+ DEFINEFUNC(SSL *, SSL_new, SSL_CTX *a, a, return nullptr, return)
+ DEFINEFUNC(SSL_CTX *, SSL_get_SSL_CTX, SSL *a, a, return nullptr, return)
+@@ -492,9 +499,7 @@ DEFINEFUNC(DH *, DH_new, DUMMYARG, DUMMYARG, return nullptr, return)
+ DEFINEFUNC(void, DH_free, DH *dh, dh, return, DUMMYARG)
+ DEFINEFUNC3(DH *, d2i_DHparams, DH**a, a, const unsigned char **pp, pp, long length, length, return nullptr, return)
+ DEFINEFUNC2(int, i2d_DHparams, DH *a, a, unsigned char **p, p, return -1, return)
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+ DEFINEFUNC2(int, DH_check, DH *dh, dh, int *codes, codes, return 0, return)
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+ DEFINEFUNC3(BIGNUM *, BN_bin2bn, const unsigned char *s, s, int len, len, BIGNUM *ret, ret, return nullptr, return)
+ 
+ #ifndef OPENSSL_NO_EC
+@@ -868,7 +873,6 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(EVP_PKEY_CTX_new)
+     RESOLVEFUNC(EVP_PKEY_param_check)
+     RESOLVEFUNC(EVP_PKEY_CTX_free)
+-    RESOLVEFUNC(EVP_PKEY_base_id)
+     RESOLVEFUNC(RSA_bits)
+     RESOLVEFUNC(OPENSSL_sk_new_null)
+     RESOLVEFUNC(OPENSSL_sk_push)
+@@ -1107,7 +1111,15 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(SSL_version)
+     RESOLVEFUNC(SSL_get_error)
+     RESOLVEFUNC(SSL_get_peer_cert_chain)
++
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++    RESOLVEFUNC(SSL_get1_peer_certificate)
++    RESOLVEFUNC(EVP_PKEY_get_base_id)
++#else
+     RESOLVEFUNC(SSL_get_peer_certificate)
++    RESOLVEFUNC(EVP_PKEY_base_id)
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+     RESOLVEFUNC(SSL_get_verify_result)
+     RESOLVEFUNC(SSL_new)
+     RESOLVEFUNC(SSL_get_SSL_CTX)
+@@ -1206,9 +1218,7 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(DH_free)
+     RESOLVEFUNC(d2i_DHparams)
+     RESOLVEFUNC(i2d_DHparams)
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+     RESOLVEFUNC(DH_check)
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+     RESOLVEFUNC(BN_bin2bn)
+ 
+ #ifndef OPENSSL_NO_EC
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h b/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
+index 95e8897a3b..27aeffa18a 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
+@@ -237,7 +237,6 @@ Q_AUTOTEST_EXPORT int q_EVP_PKEY_up_ref(EVP_PKEY *a);
+ EVP_PKEY_CTX *q_EVP_PKEY_CTX_new(EVP_PKEY *pkey, ENGINE *e);
+ void q_EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx);
+ int q_EVP_PKEY_param_check(EVP_PKEY_CTX *ctx);
+-int q_EVP_PKEY_base_id(EVP_PKEY *a);
+ int q_RSA_bits(RSA *a);
+ Q_AUTOTEST_EXPORT int q_OPENSSL_sk_num(OPENSSL_STACK *a);
+ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_pop_free(OPENSSL_STACK *a, void (*b)(void *));
+@@ -246,7 +245,7 @@ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_push(OPENSSL_STACK *st, void *data);
+ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_free(OPENSSL_STACK *a);
+ Q_AUTOTEST_EXPORT void * q_OPENSSL_sk_value(OPENSSL_STACK *a, int b);
+ int q_SSL_session_reused(SSL *a);
+-unsigned long q_SSL_CTX_set_options(SSL_CTX *ctx, unsigned long op);
++qssloptions q_SSL_CTX_set_options(SSL_CTX *ctx, qssloptions op);
+ int q_OPENSSL_init_ssl(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings);
+ size_t q_SSL_get_client_random(SSL *a, unsigned char *out, size_t outlen);
+ size_t q_SSL_SESSION_get_master_key(const SSL_SESSION *session, unsigned char *out, size_t outlen);
+@@ -510,7 +509,6 @@ const SSL_CIPHER *q_SSL_get_current_cipher(SSL *a);
+ int q_SSL_version(const SSL *a);
+ int q_SSL_get_error(SSL *a, int b);
+ STACK_OF(X509) *q_SSL_get_peer_cert_chain(SSL *a);
+-X509 *q_SSL_get_peer_certificate(SSL *a);
+ long q_SSL_get_verify_result(const SSL *a);
+ SSL *q_SSL_new(SSL_CTX *a);
+ SSL_CTX *q_SSL_get_SSL_CTX(SSL *a);
+@@ -582,10 +580,7 @@ DH *q_DH_new();
+ void q_DH_free(DH *dh);
+ DH *q_d2i_DHparams(DH **a, const unsigned char **pp, long length);
+ int q_i2d_DHparams(DH *a, unsigned char **p);
+-
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+ int q_DH_check(DH *dh, int *codes);
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+ 
+ BIGNUM *q_BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret);
+ #define q_SSL_CTX_set_tmp_dh(ctx, dh) q_SSL_CTX_ctrl((ctx), SSL_CTRL_SET_TMP_DH, 0, (char *)dh)
+@@ -754,6 +749,17 @@ void q_CRYPTO_free(void *str, const char *file, int line);
+ int q_SSL_CTX_get_security_level(const SSL_CTX *ctx);
+ void q_SSL_CTX_set_security_level(SSL_CTX *ctx, int level);
+ 
++// Here we have the ones that make difference between OpenSSL pre/post v3:
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++X509 *q_SSL_get1_peer_certificate(SSL *a);
++#define q_SSL_get_peer_certificate q_SSL_get1_peer_certificate
++int q_EVP_PKEY_get_base_id(const EVP_PKEY *pkey);
++#define q_EVP_PKEY_base_id q_EVP_PKEY_get_base_id
++#else
++X509 *q_SSL_get_peer_certificate(SSL *a);
++int q_EVP_PKEY_base_id(EVP_PKEY *a);
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+ QT_END_NAMESPACE
+ 
+ #endif
+diff --git a/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h b/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
+index bf37d07fd8..dbd42fb799 100644
+--- a/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
++++ b/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
+@@ -61,7 +61,11 @@
+ # if !defined(Q_OS_INTEGRITY)
+ #  define WIN_INTERFACE_CUSTOM   // NV
+ # endif // Q_OS_INTEGRITY
+-#endif  // QT_EGL_NO_X11
++#else // QT_EGL_NO_X11
++// If one has an eglplatform.h with https://github.com/KhronosGroup/EGL-Registry/pull/130
++// that needs USE_X11 to be defined.
++# define USE_X11
++#endif
+ 
+ #ifdef QT_EGL_WAYLAND
+ # define WAYLAND // NV
+diff --git a/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+index 159b490ce0..00aa80cd58 100644
+--- a/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
++++ b/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+@@ -567,6 +567,8 @@ void QFontconfigDatabase::populateFontDatabase()
+         fonts = FcFontList(nullptr, pattern, os);
+         FcObjectSetDestroy(os);
+         FcPatternDestroy(pattern);
++        if (!fonts)
++            return;
+     }
+ 
+     for (int i = 0; i < fonts->nfont; i++)
+diff --git a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
+index b713c19447..7cb9a8c79a 100644
+--- a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
++++ b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
+@@ -95,6 +95,7 @@ static constexpr const auto KeyTbl = qMakeArray(
+         Xkb2Qt<XKB_KEY_Clear,                   Qt::Key_Delete>,
+         Xkb2Qt<XKB_KEY_Pause,                   Qt::Key_Pause>,
+         Xkb2Qt<XKB_KEY_Print,                   Qt::Key_Print>,
++        Xkb2Qt<XKB_KEY_Sys_Req,                 Qt::Key_SysReq>,
+         Xkb2Qt<0x1005FF60,                      Qt::Key_SysReq>,         // hardcoded Sun SysReq
+         Xkb2Qt<0x1007ff00,                      Qt::Key_SysReq>,         // hardcoded X386 SysReq
+ 
+@@ -471,7 +472,7 @@ QVector<xkb_keysym_t> QXkbCommon::toKeysym(QKeyEvent *event)
+     } else if (event->modifiers() & Qt::KeypadModifier) {
+         if (qtKey >= Qt::Key_0 && qtKey <= Qt::Key_9)
+             keysyms.append(XKB_KEY_KP_0 + (qtKey - Qt::Key_0));
+-    } else if (isLatin(qtKey) && event->text().isUpper()) {
++    } else if (isLatin1(qtKey) && event->text().isUpper()) {
+         keysyms.append(qtKey);
+     }
+ 
+@@ -523,7 +524,7 @@ int QXkbCommon::keysymToQtKey(xkb_keysym_t keysym, Qt::KeyboardModifiers modifie
+         // With standard shortcuts we should prefer a latin character, this is
+         // for checks like "some qkeyevent == QKeySequence::Copy" to work even
+         // when using for example 'russian' keyboard layout.
+-        if (!QXkbCommon::isLatin(keysym)) {
++        if (!QXkbCommon::isLatin1(keysym)) {
+             xkb_keysym_t latinKeysym = QXkbCommon::lookupLatinKeysym(state, code);
+             if (latinKeysym != XKB_KEY_NoSymbol)
+                 keysym = latinKeysym;
+@@ -546,7 +547,7 @@ static int keysymToQtKey_internal(xkb_keysym_t keysym, Qt::KeyboardModifiers mod
+     } else if (keysym >= XKB_KEY_KP_0 && keysym <= XKB_KEY_KP_9) {
+         // numeric keypad keys
+         qtKey = Qt::Key_0 + (keysym - XKB_KEY_KP_0);
+-    } else if (QXkbCommon::isLatin(keysym)) {
++    } else if (QXkbCommon::isLatin1(keysym)) {
+         qtKey = QXkbCommon::qxkbcommon_xkb_keysym_to_upper(keysym);
+     } else {
+         // check if we have a direct mapping
+@@ -678,7 +679,7 @@ QList<int> QXkbCommon::possibleKeys(xkb_state *state, const QKeyEvent *event,
+         Qt::KeyboardModifiers neededMods = ModsTbl[i];
+         if ((modifiers & neededMods) == neededMods) {
+             if (i == 8) {
+-                if (isLatin(baseQtKey))
++                if (isLatin1(baseQtKey))
+                     continue;
+                 // add a latin key as a fall back key
+                 sym = lookupLatinKeysym(state, keycode);
+@@ -733,7 +734,7 @@ void QXkbCommon::verifyHasLatinLayout(xkb_keymap *keymap)
+     for (xkb_layout_index_t layout = 0; layout < layoutCount; ++layout) {
+         for (xkb_keycode_t code = minKeycode; code < maxKeycode; ++code) {
+             xkb_keymap_key_get_syms_by_level(keymap, code, layout, 0, &keysyms);
+-            if (keysyms && isLatin(keysyms[0]))
++            if (keysyms && isLatin1(keysyms[0]))
+                 nrLatinKeys++;
+             if (nrLatinKeys > 10) // arbitrarily chosen threshold
+                 return;
+@@ -766,7 +767,7 @@ xkb_keysym_t QXkbCommon::lookupLatinKeysym(xkb_state *state, xkb_keycode_t keyco
+         xkb_level_index_t level = xkb_state_key_get_level(state, keycode, layout);
+         if (xkb_keymap_key_get_syms_by_level(keymap, keycode, layout, level, &syms) != 1)
+             continue;
+-        if (isLatin(syms[0])) {
++        if (isLatin1(syms[0])) {
+             sym = syms[0];
+             break;
+         }
+diff --git a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
+index 561eae03db..8389bd8f5a 100644
+--- a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
++++ b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
+@@ -94,8 +94,8 @@ public:
+     static void verifyHasLatinLayout(xkb_keymap *keymap);
+     static xkb_keysym_t lookupLatinKeysym(xkb_state *state, xkb_keycode_t keycode);
+ 
+-    static bool isLatin(xkb_keysym_t sym) {
+-        return ((sym >= 'a' && sym <= 'z') || (sym >= 'A' && sym <= 'Z'));
++    static bool isLatin1(xkb_keysym_t sym) {
++        return sym <= 0xff;
+     }
+     static bool isKeypad(xkb_keysym_t sym) {
+         return sym >= XKB_KEY_KP_Space && sym <= XKB_KEY_KP_9;
+diff --git a/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp b/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
+index 8cd7f9b368..406f84663f 100644
+--- a/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
++++ b/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
+@@ -318,7 +318,7 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources,
+ 
+     if (current < 0 && crtc_mode.clock != 0) {
+         modes << crtc_mode;
+-        current = mode.size() - 1;
++        current = modes.size() - 1;
+     }
+ 
+     if (configuration == OutputConfigCurrent)
+diff --git a/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp b/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
+index 9153fd20bb..255ea5e33e 100644
+--- a/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
++++ b/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
+@@ -194,6 +194,9 @@ QString AtSpiAdaptor::introspect(const QString &path) const
+                 "      <arg direction=\"out\" type=\"(so)\"/>\n"
+                 "      <annotation value=\"QSpiObjectReference\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n"
+                 "    </method>\n"
++                "    <method name=\"GetAccessibleId\">\n"
++                "      <arg direction=\"out\" type=\"s\"/>\n"
++                "    </method>\n"
+                 "  </interface>\n"
+                 );
+ 
+@@ -913,8 +916,17 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+     }
+     case QAccessible::NameChanged: {
+         if (sendObject || sendObject_property_change || sendObject_property_change_accessible_name) {
+-            QString path = pathForInterface(event->accessibleInterface());
+-            QVariantList args = packDBusSignalArguments(QLatin1String("accessible-name"), 0, 0, variantForPath(path));
++            QAccessibleInterface *iface = event->accessibleInterface();
++            if (!iface) {
++                qCDebug(lcAccessibilityAtspi,
++                        "NameChanged event from invalid accessible.");
++                return;
++            }
++
++            QString path = pathForInterface(iface);
++            QVariantList args = packDBusSignalArguments(
++                QLatin1String("accessible-name"), 0, 0,
++                QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Name))));
+             sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                            QLatin1String("PropertyChange"), args);
+         }
+@@ -922,8 +934,17 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+     }
+     case QAccessible::DescriptionChanged: {
+         if (sendObject || sendObject_property_change || sendObject_property_change_accessible_description) {
+-            QString path = pathForInterface(event->accessibleInterface());
+-            QVariantList args = packDBusSignalArguments(QLatin1String("accessible-description"), 0, 0, variantForPath(path));
++            QAccessibleInterface *iface = event->accessibleInterface();
++            if (!iface) {
++                qCDebug(lcAccessibilityAtspi,
++                        "DescriptionChanged event from invalid accessible.");
++                return;
++            }
++
++            QString path = pathForInterface(iface);
++            QVariantList args = packDBusSignalArguments(
++                QLatin1String("accessible-description"), 0, 0,
++                QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Description))));
+             sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                            QLatin1String("PropertyChange"), args);
+         }
+@@ -1038,7 +1059,9 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+                 // Combo Box with AT-SPI likes to be special
+                 // It requires a name-change to update caches and then selection-changed
+                 QString path = pathForInterface(iface);
+-                QVariantList args1 = packDBusSignalArguments(QLatin1String("accessible-name"), 0, 0, variantForPath(path));
++                QVariantList args1 = packDBusSignalArguments(
++                    QLatin1String("accessible-name"), 0, 0,
++                    QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Name))));
+                 sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                                QLatin1String("PropertyChange"), args1);
+                 QVariantList args2 = packDBusSignalArguments(QString(), 0, 0, QVariant::fromValue(QDBusVariant(QVariant(0))));
+@@ -1358,6 +1381,26 @@ void AtSpiAdaptor::registerApplication()
+     delete registry;
+ }
+ 
++namespace {
++QString accessibleIdForAccessible(QAccessibleInterface *accessible)
++{
++    QString result;
++    while (accessible) {
++        if (!result.isEmpty())
++            result.prepend(QLatin1Char('.'));
++        if (auto obj = accessible->object()) {
++            const QString name = obj->objectName();
++            if (!name.isEmpty())
++                result.prepend(name);
++            else
++                result.prepend(QString::fromUtf8(obj->metaObject()->className()));
++        }
++        accessible = accessible->parent();
++    }
++    return result;
++}
++} // namespace
++
+ // Accessible
+ bool AtSpiAdaptor::accessibleInterface(QAccessibleInterface *interface, const QString &function, const QDBusMessage &message, const QDBusConnection &connection)
+ {
+@@ -1441,6 +1484,9 @@ bool AtSpiAdaptor::accessibleInterface(QAccessibleInterface *interface, const QS
+             children << ref;
+         }
+         connection.send(message.createReply(QVariant::fromValue(children)));
++    } else if (function == QLatin1String("GetAccessibleId")) {
++        sendReply(connection, message,
++                  QVariant::fromValue(QDBusVariant(accessibleIdForAccessible(interface))));
+     } else {
+         qCDebug(lcAccessibilityAtspi) << "WARNING: AtSpiAdaptor::accessibleInterface does not implement " << function << message.path();
+         return false;
+diff --git a/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp b/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
+index 45ddc8e496..cc734abc63 100644
+--- a/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
++++ b/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
+@@ -69,6 +69,21 @@ QT_BEGIN_NAMESPACE
+ DBusConnection::DBusConnection(QObject *parent)
+     : QObject(parent), m_a11yConnection(QString()), m_enabled(false)
+ {
++    // If the bus is explicitly set via env var it overrides everything else.
++    QByteArray addressEnv = qgetenv("AT_SPI_BUS_ADDRESS");
++    if (!addressEnv.isEmpty()) {
++        // Only connect on next loop run, connections to our enabled signal are
++        // only established after the ctor returns.
++        QMetaObject::invokeMethod(
++                this,
++                [this, addressEnv] {
++                    m_enabled = true;
++                    connectA11yBus(QString::fromLocal8Bit(addressEnv));
++                },
++                Qt::QueuedConnection);
++        return;
++    }
++
+     // Start monitoring if "org.a11y.Bus" is registered as DBus service.
+     QDBusConnection c = QDBusConnection::sessionBus();
+     if (!c.isConnected()) {
+diff --git a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
+index 1a3cab275d..2abe039126 100644
+--- a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
++++ b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
+@@ -51,6 +51,9 @@
+ #include <QtCore/QStandardPaths>
+ #include <QtCore/QUrl>
+ 
++#include <QtGui/QGuiApplication>
++#include <QtGui/QWindow>
++
+ #if QT_CONFIG(dbus)
+ // These QtCore includes are needed for xdg-desktop-portal support
+ #include <QtCore/private/qcore_unix_p.h>
+@@ -58,6 +61,8 @@
+ #include <QtCore/QFileInfo>
+ #include <QtCore/QUrlQuery>
+ 
++#include <QtGui/QColor>
++
+ #include <QtDBus/QDBusConnection>
+ #include <QtDBus/QDBusMessage>
+ #include <QtDBus/QDBusPendingCall>
+@@ -142,6 +147,8 @@ static inline bool detectWebBrowser(const QByteArray &desktop,
+     }
+ 
+     if (desktop == QByteArray("KDE")) {
++        if (checkExecutable(QStringLiteral("kde-open5"), browser))
++            return true;
+         // Konqueror launcher
+         if (checkExecutable(QStringLiteral("kfmclient"), browser)) {
+             browser->append(QLatin1String(" exec"));
+@@ -296,8 +303,135 @@ static inline QDBusMessage xdgDesktopPortalSendEmail(const QUrl &url)
+ 
+     return QDBusConnection::sessionBus().call(message);
+ }
++
++namespace {
++struct XDGDesktopColor
++{
++    double r = 0;
++    double g = 0;
++    double b = 0;
++
++    QColor toQColor() const
++    {
++        constexpr auto rgbMax = 255;
++        return { static_cast<int>(r * rgbMax), static_cast<int>(g * rgbMax),
++                 static_cast<int>(b * rgbMax) };
++    }
++};
++
++const QDBusArgument &operator>>(const QDBusArgument &argument, XDGDesktopColor &myStruct)
++{
++    argument.beginStructure();
++    argument >> myStruct.r >> myStruct.g >> myStruct.b;
++    argument.endStructure();
++    return argument;
++}
++
++class XdgDesktopPortalColorPicker : public QPlatformServiceColorPicker
++{
++    Q_OBJECT
++public:
++    XdgDesktopPortalColorPicker(const QString &parentWindowId, QWindow *parent)
++        : QPlatformServiceColorPicker(parent), m_parentWindowId(parentWindowId)
++    {
++    }
++
++    void pickColor() override
++    {
++        // DBus signature:
++        // PickColor (IN   s      parent_window,
++        //            IN   a{sv}  options
++        //            OUT  o      handle)
++        // Options:
++        // handle_token (s) -  A string that will be used as the last element of the @handle.
++
++        QDBusMessage message = QDBusMessage::createMethodCall(
++                QStringLiteral("org.freedesktop.portal.Desktop"), QStringLiteral("/org/freedesktop/portal/desktop"),
++                QStringLiteral("org.freedesktop.portal.Screenshot"), QStringLiteral("PickColor"));
++        message << m_parentWindowId << QVariantMap();
++
++        QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
++        auto watcher = new QDBusPendingCallWatcher(pendingCall, this);
++        connect(watcher, &QDBusPendingCallWatcher::finished, this,
++                [this](QDBusPendingCallWatcher *watcher) {
++                    watcher->deleteLater();
++                    QDBusPendingReply<QDBusObjectPath> reply = *watcher;
++                    if (reply.isError()) {
++                        qWarning("DBus call to pick color failed: %s",
++                                 qPrintable(reply.error().message()));
++                        Q_EMIT colorPicked({});
++                    } else {
++                        QDBusConnection::sessionBus().connect(
++                                QStringLiteral("org.freedesktop.portal.Desktop"), reply.value().path(),
++                                QStringLiteral("org.freedesktop.portal.Request"), QStringLiteral("Response"), this,
++                                // clang-format off
++                                SLOT(gotColorResponse(uint,QVariantMap))
++                                // clang-format on
++                        );
++                    }
++                });
++    }
++
++private Q_SLOTS:
++    void gotColorResponse(uint result, const QVariantMap &map)
++    {
++        if (result != 0)
++            return;
++        XDGDesktopColor color{};
++        map.value(QStringLiteral("color")).value<QDBusArgument>() >> color;
++        Q_EMIT colorPicked(color.toQColor());
++        deleteLater();
++    }
++
++private:
++    const QString m_parentWindowId;
++};
++} // namespace
++
+ #endif // QT_CONFIG(dbus)
+ 
++QGenericUnixServices::QGenericUnixServices()
++{
++#if QT_CONFIG(dbus)
++    if (qEnvironmentVariableIntValue("QT_NO_XDG_DESKTOP_PORTAL") > 0) {
++        return;
++    }
++    QDBusMessage message = QDBusMessage::createMethodCall(
++            QStringLiteral("org.freedesktop.portal.Desktop"), QStringLiteral("/org/freedesktop/portal/desktop"),
++            QStringLiteral("org.freedesktop.DBus.Properties"), QStringLiteral("Get"));
++    message << QStringLiteral("org.freedesktop.portal.Screenshot")
++            << QStringLiteral("version");
++
++    QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
++    auto watcher = new QDBusPendingCallWatcher(pendingCall);
++    QObject::connect(watcher, &QDBusPendingCallWatcher::finished, watcher,
++                     [this](QDBusPendingCallWatcher *watcher) {
++                         watcher->deleteLater();
++                         QDBusPendingReply<QVariant> reply = *watcher;
++                         if (!reply.isError() && reply.value().toUInt() >= 2)
++                             m_hasScreenshotPortalWithColorPicking = true;
++                     });
++
++#endif
++}
++
++QPlatformServiceColorPicker *QGenericUnixServices::colorPicker(QWindow *parent)
++{
++#if QT_CONFIG(dbus)
++    // Make double sure that we are in a wayland environment. In particular check
++    // WAYLAND_DISPLAY so also XWayland apps benefit from portal-based color picking.
++    // Outside wayland we'll rather rely on other means than the XDG desktop portal.
++    if (!qEnvironmentVariableIsEmpty("WAYLAND_DISPLAY")
++        || QGuiApplication::platformName().startsWith(QLatin1String("wayland"))) {
++        return new XdgDesktopPortalColorPicker(portalWindowIdentifier(parent), parent);
++    }
++    return nullptr;
++#else
++    Q_UNUSED(parent);
++    return nullptr;
++#endif
++}
++
+ QByteArray QGenericUnixServices::desktopEnvironment() const
+ {
+     static const QByteArray result = detectDesktopEnvironment();
+@@ -352,6 +486,8 @@ bool QGenericUnixServices::openDocument(const QUrl &url)
+ }
+ 
+ #else
++QGenericUnixServices::QGenericUnixServices() = default;
++
+ QByteArray QGenericUnixServices::desktopEnvironment() const
+ {
+     return QByteArrayLiteral("UNKNOWN");
+@@ -371,6 +507,30 @@ bool QGenericUnixServices::openDocument(const QUrl &url)
+     return false;
+ }
+ 
++QPlatformServiceColorPicker *QGenericUnixServices::colorPicker(QWindow *parent)
++{
++    Q_UNUSED(parent);
++    return nullptr;
++}
++
+ #endif // QT_NO_MULTIPROCESS
+ 
++QString QGenericUnixServices::portalWindowIdentifier(QWindow *window)
++{
++    if (QGuiApplication::platformName() == QLatin1String("xcb"))
++        return QStringLiteral("x11:") + QString::number(window->winId(), 16);
++    return QString();
++}
++
++bool QGenericUnixServices::hasCapability(Capability capability) const
++{
++    switch (capability) {
++    case Capability::ColorPicking:
++        return m_hasScreenshotPortalWithColorPicking;
++    }
++    return false;
++}
++
+ QT_END_NAMESPACE
++
++#include "qgenericunixservices.moc"
+diff --git a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
+index 8ac3de6f03..30924e64bd 100644
+--- a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
++++ b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
+@@ -59,16 +59,21 @@ QT_BEGIN_NAMESPACE
+ class QGenericUnixServices : public QPlatformServices
+ {
+ public:
+-    QGenericUnixServices() {}
++    QGenericUnixServices();
+ 
+     QByteArray desktopEnvironment() const override;
+ 
++    bool hasCapability(Capability capability) const override;
+     bool openUrl(const QUrl &url) override;
+     bool openDocument(const QUrl &url) override;
++    QPlatformServiceColorPicker *colorPicker(QWindow *parent = nullptr) override;
++
++    virtual QString portalWindowIdentifier(QWindow *window);
+ 
+ private:
+     QString m_webBrowser;
+     QString m_documentLauncher;
++    bool m_hasScreenshotPortalWithColorPicking = false;
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
+index 09470bccc6..cc7c7d4d8a 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
+@@ -69,6 +69,7 @@ const QString MenuBarPath = QLatin1String("/MenuBar");
+ */
+ QDBusMenuConnection::QDBusMenuConnection(QObject *parent, const QString &serviceName)
+     : QObject(parent)
++    , m_serviceName(serviceName)
+     , m_connection(serviceName.isNull() ? QDBusConnection::sessionBus()
+                                         : QDBusConnection::connectToBus(QDBusConnection::SessionBus, serviceName))
+     , m_dbusWatcher(new QDBusServiceWatcher(StatusNotifierWatcherService, m_connection, QDBusServiceWatcher::WatchForRegistration, this))
+@@ -83,6 +84,12 @@ QDBusMenuConnection::QDBusMenuConnection(QObject *parent, const QString &service
+ #endif
+ }
+ 
++QDBusMenuConnection::~QDBusMenuConnection()
++{
++  if (!m_serviceName.isEmpty() && m_connection.isConnected())
++      QDBusConnection::disconnectFromBus(m_serviceName);
++}
++
+ void QDBusMenuConnection::dbusError(const QDBusError &error)
+ {
+     qWarning() << "QDBusTrayIcon encountered a D-Bus error:" << error;
+@@ -105,13 +112,7 @@ void QDBusMenuConnection::unregisterTrayIconMenu(QDBusTrayIcon *item)
+ 
+ bool QDBusMenuConnection::registerTrayIcon(QDBusTrayIcon *item)
+ {
+-    bool success = connection().registerService(item->instanceId());
+-    if (!success) {
+-        qWarning() << "failed to register service" << item->instanceId();
+-        return false;
+-    }
+-
+-    success = connection().registerObject(StatusNotifierItemPath, item);
++    bool success = connection().registerObject(StatusNotifierItemPath, item);
+     if (!success) {
+         unregisterTrayIcon(item);
+         qWarning() << "failed to register" << item->instanceId() << StatusNotifierItemPath;
+@@ -126,21 +127,18 @@ bool QDBusMenuConnection::registerTrayIcon(QDBusTrayIcon *item)
+ 
+ bool QDBusMenuConnection::registerTrayIconWithWatcher(QDBusTrayIcon *item)
+ {
++    Q_UNUSED(item);
+     QDBusMessage registerMethod = QDBusMessage::createMethodCall(
+                 StatusNotifierWatcherService, StatusNotifierWatcherPath, StatusNotifierWatcherService,
+                 QLatin1String("RegisterStatusNotifierItem"));
+-    registerMethod.setArguments(QVariantList() << item->instanceId());
++    registerMethod.setArguments(QVariantList() << m_connection.baseService());
+     return m_connection.callWithCallback(registerMethod, this, SIGNAL(trayIconRegistered()), SLOT(dbusError(QDBusError)));
+ }
+ 
+-bool QDBusMenuConnection::unregisterTrayIcon(QDBusTrayIcon *item)
++void QDBusMenuConnection::unregisterTrayIcon(QDBusTrayIcon *item)
+ {
+     unregisterTrayIconMenu(item);
+     connection().unregisterObject(StatusNotifierItemPath);
+-    bool success = connection().unregisterService(item->instanceId());
+-    if (!success)
+-        qWarning() << "failed to unregister service" << item->instanceId();
+-    return success;
+ }
+ #endif // QT_NO_SYSTEMTRAYICON
+ 
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
+index f484795fbb..97bdfabb85 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
++++ b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
+@@ -70,6 +70,7 @@ class QDBusMenuConnection : public QObject
+ 
+ public:
+     QDBusMenuConnection(QObject *parent = nullptr, const QString &serviceName = QString());
++    ~QDBusMenuConnection();
+     QDBusConnection connection() const { return m_connection; }
+     QDBusServiceWatcher *dbusWatcher() const { return m_dbusWatcher; }
+     bool isStatusNotifierHostRegistered() const { return m_statusNotifierHostRegistered; }
+@@ -78,7 +79,7 @@ public:
+     void unregisterTrayIconMenu(QDBusTrayIcon *item);
+     bool registerTrayIcon(QDBusTrayIcon *item);
+     bool registerTrayIconWithWatcher(QDBusTrayIcon *item);
+-    bool unregisterTrayIcon(QDBusTrayIcon *item);
++    void unregisterTrayIcon(QDBusTrayIcon *item);
+ #endif // QT_NO_SYSTEMTRAYICON
+ 
+ Q_SIGNALS:
+@@ -90,6 +91,7 @@ private Q_SLOTS:
+     void dbusError(const QDBusError &error);
+ 
+ private:
++    QString m_serviceName;
+     QDBusConnection m_connection;
+     QDBusServiceWatcher *m_dbusWatcher;
+     bool m_statusNotifierHostRegistered;
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp b/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
+index bede70975a..76bfec5e5a 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
+@@ -71,8 +71,12 @@ Q_LOGGING_CATEGORY(qLcTray, "qt.qpa.tray")
+ static QString iconTempPath()
+ {
+     QString tempPath = QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation);
+-    if (!tempPath.isEmpty())
++    if (!tempPath.isEmpty()) {
++        QString flatpakId = qEnvironmentVariable("FLATPAK_ID");
++        if (!flatpakId.isEmpty() && QFileInfo::exists(QLatin1String("/.flatpak-info")))
++            tempPath += QLatin1String("/app/") + flatpakId;
+         return tempPath;
++    }
+ 
+     tempPath = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation);
+ 
+diff --git a/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+index cb1b39db64..6e01af052c 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+@@ -755,6 +755,9 @@ QVariant QGnomeTheme::themeHint(QPlatformTheme::ThemeHint hint) const
+         return QVariant(QChar(0x2022));
+     case QPlatformTheme::UiEffects:
+         return QVariant(int(HoverEffect));
++    case QPlatformTheme::ButtonPressKeys:
++        return QVariant::fromValue(
++                QList<Qt::Key>({ Qt::Key_Space, Qt::Key_Return, Qt::Key_Enter, Qt::Key_Select }));
+     default:
+         break;
+     }
+diff --git a/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp b/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
+index 98e05195ee..1e92f43dec 100644
+--- a/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
++++ b/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
+@@ -343,8 +343,7 @@ void QEglFSCursor::paintOnScreen()
+     // screens are siblings of each other. When not enabled, the sibling list
+     // only contains m_screen itself.
+     for (QPlatformScreen *screen : m_screen->virtualSiblings()) {
+-        if (screen->geometry().contains(cr.topLeft().toPoint() + m_cursor.hotSpot)
+-            && QOpenGLContext::currentContext()->screen() == screen->screen())
++        if (screen->geometry().contains(cr.topLeft().toPoint() + m_cursor.hotSpot))
+         {
+             cr.translate(-screen->geometry().topLeft());
+             const QSize screenSize = screen->geometry().size();
+@@ -468,11 +467,12 @@ void QEglFSCursor::draw(const QRectF &r)
+ {
+     StateSaver stateSaver;
+ 
+-    QEglFSCursorData &gfx = static_cast<QEglFSContext*>(QOpenGLContext::currentContext()->handle())->cursorData;
+-    if (!gfx.program) {
+-        // one time initialization
++    // one time initialization
++    if (!QOpenGLFunctions::d_ptr)
+         initializeOpenGLFunctions();
+ 
++    QEglFSCursorData &gfx = static_cast<QEglFSContext*>(QOpenGLContext::currentContext()->handle())->cursorData;
++    if (!gfx.program) {
+         createShaderPrograms();
+ 
+         if (!gfx.atlasTexture) {
+diff --git a/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp b/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
+index 645a0ae2e9..3e0e406f1a 100644
+--- a/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
++++ b/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
+@@ -179,7 +179,7 @@ void QEglFSKmsEventReader::create(QEglFSKmsDevice *device)
+ 
+     m_device = device;
+ 
+-    qCDebug(qLcEglfsKmsDebug, "Initalizing event reader for device %p fd %d",
++    qCDebug(qLcEglfsKmsDebug, "Initializing event reader for device %p fd %d",
+             m_device, m_device->fd());
+ 
+     m_thread = new QEglFSKmsEventReaderThread(m_device->fd());
+diff --git a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
+index 141fb68a23..d4294d425a 100644
+--- a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
++++ b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
+@@ -122,11 +122,13 @@ QOffscreenIntegration::QOffscreenIntegration()
+ #endif
+     m_services.reset(new QPlatformServices);
+ 
+-    QWindowSystemInterface::handleScreenAdded(new QOffscreenScreen);
++    m_screen = new QOffscreenScreen;
++    QWindowSystemInterface::handleScreenAdded(m_screen);
+ }
+ 
+ QOffscreenIntegration::~QOffscreenIntegration()
+ {
++    QWindowSystemInterface::handleScreenRemoved(m_screen);
+ }
+ 
+ void QOffscreenIntegration::initialize()
+diff --git a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
+index 0ea90f6c2f..fe00fde07c 100644
+--- a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
++++ b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
+@@ -84,6 +84,7 @@ protected:
+ #endif
+     QScopedPointer<QPlatformInputContext> m_inputContext;
+     QScopedPointer<QPlatformServices> m_services;
++    QPlatformScreen *m_screen;
+     mutable QScopedPointer<QPlatformNativeInterface> m_nativeInterface;
+ };
+ 
+diff --git a/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp b/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
+index 6fa5a8a2b3..1f49f0aefd 100644
+--- a/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
++++ b/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
+@@ -48,6 +48,7 @@
+ #include <qpa/qplatformnativeinterface.h>
+ #include <QtPlatformHeaders/qwglnativecontext.h>
+ 
++#include <private/qsystemlibrary_p.h>
+ #include <algorithm>
+ 
+ #include <wingdi.h>
+@@ -162,19 +163,25 @@ QFunctionPointer QWindowsOpengl32DLL::resolve(const char *name)
+ 
+ bool QWindowsOpengl32DLL::init(bool softwareRendering)
+ {
+-    const QByteArray opengl32 = QByteArrayLiteral("opengl32.dll");
+-    const QByteArray swopengl = QByteArrayLiteral("opengl32sw.dll");
++    const QByteArray opengl32 = QByteArrayLiteral("opengl32");
++    const QByteArray swopengl = QByteArrayLiteral("opengl32sw");
++    bool useSystemLib = false;
+ 
+     QByteArray openglDll = qgetenv("QT_OPENGL_DLL");
+-    if (openglDll.isEmpty())
++    if (openglDll.isEmpty()) {
+         openglDll = softwareRendering ? swopengl : opengl32;
++        useSystemLib = !softwareRendering;
++    }
+ 
+     openglDll = openglDll.toLower();
+     m_nonOpengl32 = openglDll != opengl32;
+ 
+     qCDebug(lcQpaGl) << "Qt: Using WGL and OpenGL from" << openglDll;
+ 
+-    m_lib = ::LoadLibraryA(openglDll.constData());
++    if (useSystemLib)
++        m_lib = QSystemLibrary::load((wchar_t*)(QString::fromLatin1(openglDll).utf16()));
++    else
++        m_lib = LoadLibraryA(openglDll.constData());
+     if (!m_lib) {
+         qErrnoWarning(::GetLastError(), "Failed to load %s", openglDll.constData());
+         return false;
+@@ -184,7 +191,7 @@ bool QWindowsOpengl32DLL::init(bool softwareRendering)
+         // Load opengl32.dll always. GDI functions like ChoosePixelFormat do
+         // GetModuleHandle for opengl32.dll and behave differently (and call back into
+         // opengl32) when the module is present. This is fine for dummy contexts and windows.
+-        ::LoadLibraryA("opengl32.dll");
++        QSystemLibrary::load(L"opengl32");
+     }
+ 
+     wglCreateContext = reinterpret_cast<HGLRC (WINAPI *)(HDC)>(resolve("wglCreateContext"));
+diff --git a/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp b/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
+index d7d186e804..9eb4011bf2 100644
+--- a/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
++++ b/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
+@@ -49,6 +49,7 @@
+ #include <QtCore/qstandardpaths.h>
+ #include <QtCore/qlibraryinfo.h>
+ #include <QtCore/qhash.h>
++#include <private/qsystemlibrary_p.h>
+ 
+ #ifndef QT_NO_OPENGL
+ #include <private/qopengl_p.h>
+@@ -396,7 +397,7 @@ bool QWindowsOpenGLTester::testDesktopGL()
+ 
+     // Test #1: Load opengl32.dll and try to resolve an OpenGL 2 function.
+     // This will typically fail on systems that do not have a real OpenGL driver.
+-    lib = LoadLibraryA("opengl32.dll");
++    lib = QSystemLibrary::load(L"opengl32");
+     if (lib) {
+         CreateContext = reinterpret_cast<CreateContextType>(
+             reinterpret_cast<QFunctionPointer>(::GetProcAddress(lib, "wglCreateContext")));
+diff --git a/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp b/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
+index 1afa00cfc9..118af6ce73 100644
+--- a/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
++++ b/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
+@@ -41,6 +41,7 @@
+ 
+ #include <QRect>
+ #include <QList>
++#include <QMap>
+ #include <QDebug>
+ 
+ #include <qmath.h>
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp b/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
+index 9e2a37a6a1..e6e175a118 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
+@@ -488,12 +488,12 @@ void QXcbConnection::printXcbError(const char *message, xcb_generic_error_t *err
+     uint clamped_error_code = qMin<uint>(error->error_code, (sizeof(xcb_errors) / sizeof(xcb_errors[0])) - 1);
+     uint clamped_major_code = qMin<uint>(error->major_code, (sizeof(xcb_protocol_request_codes) / sizeof(xcb_protocol_request_codes[0])) - 1);
+ 
+-    qCWarning(lcQpaXcb, "%s: %d (%s), sequence: %d, resource id: %d, major code: %d (%s), minor code: %d",
+-             message,
+-             int(error->error_code), xcb_errors[clamped_error_code],
+-             int(error->sequence), int(error->resource_id),
+-             int(error->major_code), xcb_protocol_request_codes[clamped_major_code],
+-             int(error->minor_code));
++    qCDebug(lcQpaXcb, "%s: %d (%s), sequence: %d, resource id: %d, major code: %d (%s), minor code: %d",
++            message,
++            int(error->error_code), xcb_errors[clamped_error_code],
++            int(error->sequence), int(error->resource_id),
++            int(error->major_code), xcb_protocol_request_codes[clamped_major_code],
++            int(error->minor_code));
+ }
+ 
+ static Qt::MouseButtons translateMouseButtons(int s)
+@@ -702,6 +702,8 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
+             QXcbVirtualDesktop *virtualDesktop = virtualDesktopForRootWindow(propertyNotify->window);
+             if (virtualDesktop)
+                 virtualDesktop->updateWorkArea();
++        } else if (propertyNotify->atom == atom(QXcbAtom::_NET_SUPPORTED)) {
++            m_wmSupport->updateNetWMAtoms();
+         } else {
+             HANDLE_PLATFORM_WINDOW_EVENT(xcb_property_notify_event_t, window, handlePropertyNotifyEvent);
+         }
+@@ -750,7 +752,7 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
+                 case XCB_XKB_NEW_KEYBOARD_NOTIFY: {
+                     xcb_xkb_new_keyboard_notify_event_t *ev = &xkb_event->new_keyboard_notify;
+                     if (ev->changed & XCB_XKB_NKN_DETAIL_KEYCODES)
+-                        m_keyboard->updateKeymap(ev);
++                        m_keyboard->updateKeymap();
+                     break;
+                 }
+                 default:
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp b/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
+index 76869ced60..02d2eebb56 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
+@@ -274,8 +274,7 @@ QPlatformWindow *QXcbIntegration::createForeignWindow(QWindow *window, WId nativ
+ #ifndef QT_NO_OPENGL
+ QPlatformOpenGLContext *QXcbIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
+ {
+-    QXcbScreen *screen = static_cast<QXcbScreen *>(context->screen()->handle());
+-    QXcbGlIntegration *glIntegration = screen->connection()->glIntegration();
++    QXcbGlIntegration *glIntegration = defaultConnection()->glIntegration();
+     if (!glIntegration) {
+         qWarning("QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled");
+         return nullptr;
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+index efecd7e2d1..e8286381a2 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+@@ -365,17 +365,6 @@ void QXcbKeyboard::updateKeymap(xcb_mapping_notify_event_t *event)
+     updateKeymap();
+ }
+ 
+-void QXcbKeyboard::updateKeymap(xcb_xkb_new_keyboard_notify_event_t *event)
+-{
+-    if (!event)
+-        return;
+-
+-    if (event->deviceID != event->oldDeviceID)
+-        m_config = false;
+-
+-    updateKeymap();
+-}
+-
+ void QXcbKeyboard::updateKeymap()
+ {
+     KeysymModifierMap keysymMods;
+@@ -383,6 +372,8 @@ void QXcbKeyboard::updateKeymap()
+         keysymMods = keysymsToModifiers();
+     updateModifiers(keysymMods);
+ 
++    m_config = true;
++
+     if (!m_xkbContext) {
+         m_xkbContext.reset(xkb_context_new(XKB_CONTEXT_NO_DEFAULT_INCLUDES));
+         if (!m_xkbContext) {
+@@ -398,13 +389,8 @@ void QXcbKeyboard::updateKeymap()
+     if (connection()->hasXKB()) {
+         m_xkbKeymap.reset(xkb_x11_keymap_new_from_device(m_xkbContext.get(), xcb_connection(),
+                                                          core_device_id, XKB_KEYMAP_COMPILE_NO_FLAGS));
+-        if (m_xkbKeymap) {
+-            if (m_config)
+-                m_xkbState.reset(xkb_state_new(m_xkbKeymap.get()));
+-            else
+-                m_xkbState.reset(xkb_x11_state_new_from_device(m_xkbKeymap.get(), xcb_connection(), core_device_id));
+-
+-        }
++        if (m_xkbKeymap)
++            m_xkbState.reset(xkb_x11_state_new_from_device(m_xkbKeymap.get(), xcb_connection(), core_device_id));
+     } else {
+         m_xkbKeymap.reset(keymapFromCore(keysymMods));
+         if (m_xkbKeymap)
+@@ -425,8 +411,6 @@ void QXcbKeyboard::updateKeymap()
+     updateXKBMods();
+ 
+     QXkbCommon::verifyHasLatinLayout(m_xkbKeymap.get());
+-
+-    m_config = true;
+ }
+ 
+ QList<int> QXcbKeyboard::possibleKeys(const QKeyEvent *event) const
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
+index b652c85fe3..0ee08aeff2 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
++++ b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
+@@ -69,7 +69,6 @@ public:
+ 
+     Qt::KeyboardModifiers translateModifiers(int s) const;
+     void updateKeymap(xcb_mapping_notify_event_t *event);
+-    void updateKeymap(xcb_xkb_new_keyboard_notify_event_t *event);
+     void updateKeymap();
+     QList<int> possibleKeys(const QKeyEvent *event) const;
+ 
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp b/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
+index ffda7b6a57..863e961f4c 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
+@@ -564,11 +564,6 @@ void QXcbWindow::setGeometry(const QRect &rect)
+ {
+     QPlatformWindow::setGeometry(rect);
+ 
+-    if (shouldDeferTask(Task::SetGeometry)) {
+-        m_deferredGeometry = rect;
+-        return;
+-    }
+-
+     propagateSizeHints();
+ 
+     QXcbScreen *currentScreen = xcbScreen();
+@@ -693,9 +688,6 @@ void QXcbWindow::setVisible(bool visible)
+ 
+ void QXcbWindow::show()
+ {
+-    if (shouldDeferTask(Task::Map))
+-        return;
+-
+     if (window()->isTopLevel()) {
+ 
+         // update WM_NORMAL_HINTS
+@@ -706,7 +698,7 @@ void QXcbWindow::show()
+         if (isTransient(window())) {
+             const QWindow *tp = window()->transientParent();
+             if (tp && tp->handle())
+-                transientXcbParent = static_cast<const QXcbWindow *>(tp->handle())->winId();
++                transientXcbParent = tp->handle()->winId();
+             // Default to client leader if there is no transient parent, else modal dialogs can
+             // be hidden by their parents.
+             if (!transientXcbParent)
+@@ -746,10 +738,6 @@ void QXcbWindow::show()
+ 
+ void QXcbWindow::hide()
+ {
+-    if (shouldDeferTask(Task::Unmap))
+-        return;
+-
+-    m_wmStateValid = false;
+     xcb_unmap_window(xcb_connection(), m_window);
+ 
+     // send synthetic UnmapNotify event according to icccm 4.1.4
+@@ -909,9 +897,6 @@ QXcbWindow::NetWmStates QXcbWindow::netWmStates()
+ 
+ void QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
+ {
+-    if (shouldDeferTask(Task::SetWindowFlags))
+-        return;
+-
+     Qt::WindowType type = static_cast<Qt::WindowType>(int(flags & Qt::WindowType_Mask));
+ 
+     if (type == Qt::ToolTip)
+@@ -941,8 +926,6 @@ void QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
+ 
+     setTransparentForMouseEvents(flags & Qt::WindowTransparentForInput);
+     updateDoesNotAcceptFocus(flags & Qt::WindowDoesNotAcceptFocus);
+-
+-    m_isWmManagedWindow = !(flags & Qt::X11BypassWindowManagerHint);
+ }
+ 
+ void QXcbWindow::setMotifWmHints(Qt::WindowFlags flags)
+@@ -1142,9 +1125,6 @@ void QXcbWindow::setWindowState(Qt::WindowStates state)
+     if (state == m_windowState)
+         return;
+ 
+-    if (shouldDeferTask(Task::SetWindowState))
+-        return;
+-
+     // unset old state
+     if (m_windowState & Qt::WindowMinimized)
+         xcb_map_window(xcb_connection(), m_window);
+@@ -1350,6 +1330,12 @@ void QXcbWindow::setWindowIcon(const QIcon &icon)
+     }
+ 
+     if (!icon_data.isEmpty()) {
++        // Ignore icon exceeding maximum xcb request length
++        if (icon_data.size() > xcb_get_maximum_request_length(xcb_connection())) {
++            qWarning("Ignoring window icon: Size %llu exceeds maximum xcb request length %u.",
++                     icon_data.size(), xcb_get_maximum_request_length(xcb_connection()));
++            return;
++        }
+         xcb_change_property(xcb_connection(),
+                             XCB_PROP_MODE_REPLACE,
+                             m_window,
+@@ -1639,7 +1625,7 @@ void QXcbWindow::setWmWindowType(QXcbWindowFunctions::WmWindowTypes types, Qt::W
+         break;
+     }
+ 
+-    if ((flags & Qt::FramelessWindowHint) && !(type & QXcbWindowFunctions::KdeOverride)) {
++    if ((flags & Qt::FramelessWindowHint) && !(types & QXcbWindowFunctions::KdeOverride)) {
+         // override netwm type - quick and easy for KDE noborder
+         atoms.append(atom(QXcbAtom::_KDE_NET_WM_WINDOW_TYPE_OVERRIDE));
+     }
+@@ -1894,10 +1880,6 @@ void QXcbWindow::handleUnmapNotifyEvent(const xcb_unmap_notify_event_t *event)
+     if (event->window == m_window) {
+         m_mapped = false;
+         QWindowSystemInterface::handleExposeEvent(window(), QRegion());
+-        if (!m_isWmManagedWindow || parent()) {
+-            m_wmStateValid = true;
+-            handleDeferredTasks();
+-        }
+     }
+ }
+ 
+@@ -2212,98 +2194,30 @@ void QXcbWindow::handleLeaveNotifyEvent(const xcb_leave_notify_event_t *event)
+     handleLeaveNotifyEvent(event->root_x, event->root_y, event->mode, event->detail, event->time);
+ }
+ 
+-bool QXcbWindow::shouldDeferTask(Task task)
+-{
+-    if (m_wmStateValid)
+-        return false;
+-
+-    m_deferredTasks.append(task);
+-    return true;
+-}
+-
+-void QXcbWindow::handleDeferredTasks()
+-{
+-    Q_ASSERT(m_wmStateValid == true);
+-    if (m_deferredTasks.isEmpty())
+-        return;
+-
+-    bool map = false;
+-    bool unmap = false;
+-
+-    QVector<Task> tasks;
+-    for (auto taskIt = m_deferredTasks.rbegin(); taskIt != m_deferredTasks.rend(); ++taskIt) {
+-        if (!tasks.contains(*taskIt))
+-            tasks.prepend(*taskIt);
+-    }
+-
+-    for (Task task : tasks) {
+-        switch (task) {
+-        case Task::Map:
+-            map = true;
+-            unmap = false;
+-            break;
+-        case Task::Unmap:
+-            unmap = true;
+-            map = false;
+-            break;
+-        case Task::SetGeometry:
+-            setGeometry(m_deferredGeometry);
+-            break;
+-        case Task::SetWindowFlags:
+-            setWindowFlags(window()->flags());
+-            break;
+-        case Task::SetWindowState:
+-            setWindowState(window()->windowState());
+-            break;
+-        }
+-    }
+-    m_deferredTasks.clear();
+-
+-    if (map) {
+-        Q_ASSERT(unmap == false);
+-        show();
+-    }
+-    if (unmap) {
+-        Q_ASSERT(map == false);
+-        hide();
+-    }
+-}
+-
+ void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *event)
+ {
+     connection()->setTime(event->time);
+ 
+-    const bool wmStateChanged = event->atom == atom(QXcbAtom::WM_STATE);
+-    const bool netWmStateChanged = event->atom == atom(QXcbAtom::_NET_WM_STATE);
+-    if (netWmStateChanged || wmStateChanged) {
+-        if (wmStateChanged && !m_wmStateValid && m_isWmManagedWindow) {
+-            // ICCCM 4.1.4
+-            // Clients that want to re-use a client window (e.g. by mapping it again)
+-            // after withdrawing it must wait for the withdrawal to be complete before
+-            // proceeding. The preferred method for doing this is for clients to wait for
+-            // a window manager to update or remove the WM_STATE property.
+-            m_wmStateValid = true;
+-            handleDeferredTasks();
+-        }
+-        if (event->state == XCB_PROPERTY_DELETE)
++    const bool propertyDeleted = event->state == XCB_PROPERTY_DELETE;
++
++    if (event->atom == atom(QXcbAtom::_NET_WM_STATE) || event->atom == atom(QXcbAtom::WM_STATE)) {
++        if (propertyDeleted)
+             return;
+ 
+-        if (wmStateChanged) {
++        Qt::WindowStates newState = Qt::WindowNoState;
++
++        if (event->atom == atom(QXcbAtom::WM_STATE)) { // WM_STATE: Quick check for 'Minimize'.
+             auto reply = Q_XCB_REPLY(xcb_get_property, xcb_connection(),
+                                      0, m_window, atom(QXcbAtom::WM_STATE),
+                                      XCB_ATOM_ANY, 0, 1024);
+             if (reply && reply->format == 32 && reply->type == atom(QXcbAtom::WM_STATE)) {
+-                auto data = static_cast<const quint32 *>(xcb_get_property_value(reply.get()));
+-                if (reply->length != 0) {
+-                    const bool changedToWithdrawn = data[0] == XCB_ICCCM_WM_STATE_WITHDRAWN;
+-                    const bool changedToIconic = data[0] == XCB_ICCCM_WM_STATE_ICONIC;
+-                    m_minimized = changedToIconic || (changedToWithdrawn && m_minimized);
+-                }
++                const quint32 *data = (const quint32 *)xcb_get_property_value(reply.get());
++                if (reply->length != 0)
++                    m_minimized = (data[0] == XCB_ICCCM_WM_STATE_ICONIC
++                                   || (data[0] == XCB_ICCCM_WM_STATE_WITHDRAWN && m_minimized));
+             }
+         }
+ 
+-        // _NET_WM_STATE handling
+-        Qt::WindowStates newState = Qt::WindowNoState;
+         const NetWmStates states = netWmStates();
+         // _NET_WM_STATE_HIDDEN should be set by the Window Manager to indicate that a window would
+         // not be visible on the screen if its desktop/viewport were active and its coordinates were
+@@ -2325,6 +2239,7 @@ void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *ev
+             if ((m_windowState & Qt::WindowMinimized) && connection()->mouseGrabber() == this)
+                 connection()->setMouseGrabber(nullptr);
+         }
++        return;
+     } else if (event->atom == atom(QXcbAtom::_NET_FRAME_EXTENTS)) {
+         m_dirtyFrameMargins = true;
+     }
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbwindow.h b/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
+index 55af9279b1..6f5c1f5ed9 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
++++ b/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
+@@ -74,14 +74,6 @@ public:
+ 
+     Q_DECLARE_FLAGS(NetWmStates, NetWmState)
+ 
+-    enum Task {
+-        Map,
+-        Unmap,
+-        SetGeometry,
+-        SetWindowFlags,
+-        SetWindowState
+-    };
+-
+     QXcbWindow(QWindow *window);
+     ~QXcbWindow();
+ 
+@@ -151,9 +143,6 @@ public:
+ 
+     QXcbWindow *toWindow() override;
+ 
+-    bool shouldDeferTask(Task task);
+-    void handleDeferredTasks();
+-
+     void handleMouseEvent(xcb_timestamp_t time, const QPoint &local, const QPoint &global,
+                           Qt::KeyboardModifiers modifiers, QEvent::Type type, Qt::MouseEventSource source);
+ 
+@@ -292,11 +281,6 @@ protected:
+     int m_swapInterval = -1;
+ 
+     qreal m_sizeHintsScaleFactor = 1.0;
+-
+-    bool m_wmStateValid = true;
+-    QVector<Task> m_deferredTasks;
+-    bool m_isWmManagedWindow = true;
+-    QRect m_deferredGeometry;
+ };
+ 
+ class QXcbForeignWindow : public QXcbWindow
+diff --git a/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp b/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
+index d9d117faeb..640b49daa0 100644
+--- a/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
++++ b/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
+@@ -85,6 +85,7 @@ QGtk3MenuItem::QGtk3MenuItem()
+       m_checkable(false),
+       m_checked(false),
+       m_enabled(true),
++      m_exclusive(false),
+       m_underline(false),
+       m_invalid(true),
+       m_menu(nullptr),
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
+index 0048bbc1e6..396e7f6d1c 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
+@@ -102,15 +102,12 @@ const QDBusArgument &operator >>(const QDBusArgument &arg, QXdgDesktopPortalFile
+ class QXdgDesktopPortalFileDialogPrivate
+ {
+ public:
+-    QXdgDesktopPortalFileDialogPrivate(QPlatformFileDialogHelper *nativeFileDialog)
++    QXdgDesktopPortalFileDialogPrivate(QPlatformFileDialogHelper *nativeFileDialog, uint fileChooserPortalVersion)
+         : nativeFileDialog(nativeFileDialog)
++        , fileChooserPortalVersion(fileChooserPortalVersion)
+     { }
+ 
+-    WId winId = 0;
+-    bool directoryMode = false;
+-    bool modal = false;
+-    bool multipleFiles = false;
+-    bool saveFile = false;
++    QEventLoop loop;
+     QString acceptLabel;
+     QString directory;
+     QString title;
+@@ -121,19 +118,27 @@ public:
+     QString selectedMimeTypeFilter;
+     QString selectedNameFilter;
+     QStringList selectedFiles;
+-    QPlatformFileDialogHelper *nativeFileDialog = nullptr;
++    std::unique_ptr<QPlatformFileDialogHelper> nativeFileDialog;
++    uint fileChooserPortalVersion = 0;
++    bool failedToOpen = false;
++    bool directoryMode = false;
++    bool multipleFiles = false;
++    bool saveFile = false;
+ };
+ 
+-QXdgDesktopPortalFileDialog::QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog)
++QXdgDesktopPortalFileDialog::QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog, uint fileChooserPortalVersion)
+     : QPlatformFileDialogHelper()
+-    , d_ptr(new QXdgDesktopPortalFileDialogPrivate(nativeFileDialog))
++    , d_ptr(new QXdgDesktopPortalFileDialogPrivate(nativeFileDialog, fileChooserPortalVersion))
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+     if (d->nativeFileDialog) {
+-        connect(d->nativeFileDialog, SIGNAL(accept()), this, SIGNAL(accept()));
+-        connect(d->nativeFileDialog, SIGNAL(reject()), this, SIGNAL(reject()));
++        connect(d->nativeFileDialog.get(), SIGNAL(accept()), this, SIGNAL(accept()));
++        connect(d->nativeFileDialog.get(), SIGNAL(reject()), this, SIGNAL(reject()));
+     }
++
++    d->loop.connect(this, SIGNAL(accept()), SLOT(quit()));
++    d->loop.connect(this, SIGNAL(reject()), SLOT(quit()));
+ }
+ 
+ QXdgDesktopPortalFileDialog::~QXdgDesktopPortalFileDialog()
+@@ -177,7 +182,7 @@ void QXdgDesktopPortalFileDialog::initializeDialog()
+     setDirectory(options()->initialDirectory());
+ }
+ 
+-void QXdgDesktopPortalFileDialog::openPortal()
++void QXdgDesktopPortalFileDialog::openPortal(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent)
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+@@ -185,13 +190,13 @@ void QXdgDesktopPortalFileDialog::openPortal()
+                                                           QLatin1String("/org/freedesktop/portal/desktop"),
+                                                           QLatin1String("org.freedesktop.portal.FileChooser"),
+                                                           d->saveFile ? QLatin1String("SaveFile") : QLatin1String("OpenFile"));
+-    QString parentWindowId = QLatin1String("x11:") + QString::number(d->winId, 16);
++    QString parentWindowId = QLatin1String("x11:") + QString::number(parent ? parent->winId() : 0, 16);
+ 
+     QVariantMap options;
+     if (!d->acceptLabel.isEmpty())
+         options.insert(QLatin1String("accept_label"), d->acceptLabel);
+ 
+-    options.insert(QLatin1String("modal"), d->modal);
++    options.insert(QLatin1String("modal"), windowModality != Qt::NonModal);
+     options.insert(QLatin1String("multiple"), d->multipleFiles);
+     options.insert(QLatin1String("directory"), d->directoryMode);
+ 
+@@ -290,10 +295,18 @@ void QXdgDesktopPortalFileDialog::openPortal()
+ 
+     QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
+     QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingCall);
+-    connect(watcher, &QDBusPendingCallWatcher::finished, this, [this] (QDBusPendingCallWatcher *watcher) {
++    connect(watcher, &QDBusPendingCallWatcher::finished, this, [=] (QDBusPendingCallWatcher *watcher) {
+         QDBusPendingReply<QDBusObjectPath> reply = *watcher;
+-        if (reply.isError()) {
+-            Q_EMIT reject();
++        // Any error means the dialog is not shown and we need to fallback
++        d->failedToOpen = reply.isError();
++        if (d->failedToOpen) {
++            if (d->nativeFileDialog) {
++                d->nativeFileDialog->show(windowFlags, windowModality, parent);
++                if (d->loop.isRunning())
++                    d->nativeFileDialog->exec();
++            } else {
++                Q_EMIT reject();
++            }
+         } else {
+             QDBusConnection::sessionBus().connect(nullptr,
+                                                   reply.value().path(),
+@@ -302,6 +315,7 @@ void QXdgDesktopPortalFileDialog::openPortal()
+                                                   this,
+                                                   SLOT(gotResponse(uint,QVariantMap)));
+         }
++        watcher->deleteLater();
+     });
+ }
+ 
+@@ -326,7 +340,7 @@ QUrl QXdgDesktopPortalFileDialog::directory() const
+ {
+     Q_D(const QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog())
+         return d->nativeFileDialog->directory();
+ 
+     return d->directory;
+@@ -348,7 +362,7 @@ QList<QUrl> QXdgDesktopPortalFileDialog::selectedFiles() const
+ {
+     Q_D(const QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog())
+         return d->nativeFileDialog->selectedFiles();
+ 
+     QList<QUrl> files;
+@@ -403,16 +417,13 @@ void QXdgDesktopPortalFileDialog::exec()
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly)) {
++    if (d->nativeFileDialog && useNativeFileDialog()) {
+         d->nativeFileDialog->exec();
+         return;
+     }
+ 
+     // HACK we have to avoid returning until we emit that the dialog was accepted or rejected
+-    QEventLoop loop;
+-    loop.connect(this, SIGNAL(accept()), SLOT(quit()));
+-    loop.connect(this, SIGNAL(reject()), SLOT(quit()));
+-    loop.exec();
++    d->loop.exec();
+ }
+ 
+ void QXdgDesktopPortalFileDialog::hide()
+@@ -429,13 +440,10 @@ bool QXdgDesktopPortalFileDialog::show(Qt::WindowFlags windowFlags, Qt::WindowMo
+ 
+     initializeDialog();
+ 
+-    d->modal = windowModality != Qt::NonModal;
+-    d->winId = parent ? parent->winId() : 0;
+-
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog(OpenFallback))
+         return d->nativeFileDialog->show(windowFlags, windowModality, parent);
+ 
+-    openPortal();
++    openPortal(windowFlags, windowModality, parent);
+ 
+     return true;
+ }
+@@ -465,4 +473,21 @@ void QXdgDesktopPortalFileDialog::gotResponse(uint response, const QVariantMap &
+     }
+ }
+ 
++bool QXdgDesktopPortalFileDialog::useNativeFileDialog(QXdgDesktopPortalFileDialog::FallbackType fallbackType) const
++{
++    Q_D(const QXdgDesktopPortalFileDialog);
++
++    if (d->failedToOpen && fallbackType != OpenFallback)
++        return true;
++
++    if (d->fileChooserPortalVersion < 3) {
++        if (options()->fileMode() == QFileDialogOptions::Directory)
++            return true;
++        else if (options()->fileMode() == QFileDialogOptions::DirectoryOnly)
++            return true;
++    }
++
++    return false;
++}
++
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
+index 4f4de96ecf..65e22a5cf2 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
+@@ -51,6 +51,11 @@ class QXdgDesktopPortalFileDialog : public QPlatformFileDialogHelper
+     Q_OBJECT
+     Q_DECLARE_PRIVATE(QXdgDesktopPortalFileDialog)
+ public:
++    enum FallbackType {
++        GenericFallback,
++        OpenFallback
++    };
++
+     enum ConditionType : uint {
+         GlobalPattern = 0,
+         MimeType = 1
+@@ -69,7 +74,7 @@ public:
+     };
+     typedef QVector<Filter> FilterList;
+ 
+-    QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog = nullptr);
++    QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog = nullptr, uint fileChooserPortalVersion = 0);
+     ~QXdgDesktopPortalFileDialog();
+ 
+     bool defaultNameFilterDisables() const override;
+@@ -92,7 +97,8 @@ private Q_SLOTS:
+ 
+ private:
+     void initializeDialog();
+-    void openPortal();
++    void openPortal(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent);
++    bool useNativeFileDialog(FallbackType fallbackType = GenericFallback) const;
+ 
+     QScopedPointer<QXdgDesktopPortalFileDialogPrivate> d_ptr;
+ };
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
+index fb324afbd8..b809503122 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
+@@ -111,6 +111,7 @@ QXdgDesktopPortalTheme::QXdgDesktopPortalTheme()
+         if (reply.isValid()) {
+             d->fileChooserPortalVersion = reply.value().toUInt();
+         }
++        watcher->deleteLater();
+     });
+ }
+ 
+@@ -152,11 +153,12 @@ QPlatformDialogHelper* QXdgDesktopPortalTheme::createPlatformDialogHelper(Dialog
+ {
+     Q_D(const QXdgDesktopPortalTheme);
+ 
+-    if (type == FileDialog) {
++    if (type == FileDialog && d->fileChooserPortalVersion) {
+         // Older versions of FileChooser portal don't support opening directories, therefore we fallback
+         // to native file dialog opened inside the sandbox to open a directory.
+-        if (d->fileChooserPortalVersion < 3 && d->baseTheme->usePlatformNativeDialog(type))
+-            return new QXdgDesktopPortalFileDialog(static_cast<QPlatformFileDialogHelper*>(d->baseTheme->createPlatformDialogHelper(type)));
++        if (d->baseTheme->usePlatformNativeDialog(type))
++            return new QXdgDesktopPortalFileDialog(static_cast<QPlatformFileDialogHelper*>(d->baseTheme->createPlatformDialogHelper(type)),
++                                                   d->fileChooserPortalVersion);
+ 
+         return new QXdgDesktopPortalFileDialog;
+     }
+diff --git a/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp b/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
+index 43d5e119ad..1f9cbc4565 100644
+--- a/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
++++ b/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
+@@ -89,8 +89,10 @@ void QCupsPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &v
+         break;
+     case PPK_Duplex: {
+         QPrint::DuplexMode mode = QPrint::DuplexMode(value.toInt());
+-        if (mode != d->duplex && d->m_printDevice.supportedDuplexModes().contains(mode))
++        if (d->m_printDevice.supportedDuplexModes().contains(mode)) {
+             d->duplex = mode;
++            d->duplexRequestedExplicitly = true;
++        }
+         break;
+     }
+     case PPK_PrinterName:
+@@ -277,9 +279,12 @@ void QCupsPrintEnginePrivate::changePrinter(const QString &newPrinter)
+     m_printDevice.swap(printDevice);
+     printerName = m_printDevice.id();
+ 
+-    // Check if new printer supports current settings, otherwise us defaults
+-    if (duplex != QPrint::DuplexAuto && !m_printDevice.supportedDuplexModes().contains(duplex))
++    // in case a duplex value was explicitly set, check if new printer supports current value,
++    // otherwise use device default
++    if (!duplexRequestedExplicitly || !m_printDevice.supportedDuplexModes().contains(duplex)) {
+         duplex = m_printDevice.defaultDuplexMode();
++        duplexRequestedExplicitly = false;
++    }
+     QPrint::ColorMode colorMode = grayscale ? QPrint::GrayScale : QPrint::Color;
+     if (!m_printDevice.supportedColorModes().contains(colorMode))
+         grayscale = m_printDevice.defaultColorMode() == QPrint::GrayScale;
+diff --git a/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h b/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
+index c021b0c643..8f81fe478d 100644
+--- a/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
++++ b/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
+@@ -100,6 +100,7 @@ private:
+     QStringList cupsOptions;
+     QString cupsTempFile;
+     QPrint::DuplexMode duplex;
++    bool duplexRequestedExplicitly = false;
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp b/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
+index 67e7154fa6..40876152e5 100644
+--- a/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
++++ b/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
+@@ -817,7 +817,7 @@ bool QIBaseResultPrivate::writeArray(int column, const QList<QVariant> &list)
+     ba.resize(int(bufLen));
+ 
+     if (list.size() > arraySize) {
+-        error = QLatin1String("Array size missmatch: size of %1 is %2, size of provided list is %3");
++        error = QLatin1String("Array size mismatch: size of %1 is %2, size of provided list is %3");
+         error = error.arg(QLatin1String(sqlname)).arg(arraySize).arg(list.size());
+         q->setLastError(QSqlError(error, QLatin1String(""), QSqlError::StatementError));
+         return false;
+diff --git a/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp b/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
+index 7ca055eea2..6bc9d46755 100644
+--- a/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
++++ b/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
+@@ -223,7 +223,7 @@ public:
+     struct QMyField
+     {
+         char *outField = nullptr;
+-        MYSQL_FIELD *myField = nullptr;
++        const MYSQL_FIELD *myField = nullptr;
+         QMetaType::Type type = QMetaType::UnknownType;
+         my_bool nullIndicator = false;
+         ulong bufLength = 0ul;
+@@ -361,7 +361,7 @@ static bool qIsInteger(int t)
+ void QMYSQLResultPrivate::bindBlobs()
+ {
+     int i;
+-    MYSQL_FIELD *fieldInfo;
++    const MYSQL_FIELD *fieldInfo;
+     MYSQL_BIND *bind;
+ 
+     for(i = 0; i < fields.count(); ++i) {
+@@ -379,7 +379,6 @@ void QMYSQLResultPrivate::bindBlobs()
+ bool QMYSQLResultPrivate::bindInValues()
+ {
+     MYSQL_BIND *bind;
+-    char *field;
+     int i = 0;
+ 
+     if (!meta)
+@@ -392,35 +391,34 @@ bool QMYSQLResultPrivate::bindInValues()
+     inBinds = new MYSQL_BIND[fields.size()];
+     memset(inBinds, 0, fields.size() * sizeof(MYSQL_BIND));
+ 
+-    MYSQL_FIELD *fieldInfo;
++    const MYSQL_FIELD *fieldInfo;
+ 
+     while((fieldInfo = mysql_fetch_field(meta))) {
++        bind = &inBinds[i];
++
+         QMyField &f = fields[i];
+         f.myField = fieldInfo;
+-
++        bind->buffer_length = f.bufLength = fieldInfo->length + 1;
++        bind->buffer_type = fieldInfo->type;
+         f.type = qDecodeMYSQLType(fieldInfo->type, fieldInfo->flags);
+         if (qIsBlob(fieldInfo->type)) {
+             // the size of a blob-field is available as soon as we call
+             // mysql_stmt_store_result()
+             // after mysql_stmt_exec() in QMYSQLResult::exec()
+-            fieldInfo->length = 0;
++            bind->buffer_length = f.bufLength = 0;
+             hasBlobs = true;
+         } else if (qIsInteger(f.type)) {
+-            fieldInfo->length = 8;
++            bind->buffer_length = f.bufLength = 8;
+         } else {
+-            fieldInfo->type = MYSQL_TYPE_STRING;
++            bind->buffer_type = MYSQL_TYPE_STRING;
+         }
+-        bind = &inBinds[i];
+-        field = new char[fieldInfo->length + 1];
+-        memset(field, 0, fieldInfo->length + 1);
+ 
+-        bind->buffer_type = fieldInfo->type;
+-        bind->buffer = field;
+-        bind->buffer_length = f.bufLength = fieldInfo->length + 1;
+         bind->is_null = &f.nullIndicator;
+         bind->length = &f.bufLength;
+         bind->is_unsigned = fieldInfo->flags & UNSIGNED_FLAG ? 1 : 0;
+-        f.outField=field;
++
++        char *field = new char[bind->buffer_length + 1]{};
++        bind->buffer = f.outField = field;
+ 
+         ++i;
+     }
+@@ -1369,20 +1367,20 @@ bool QMYSQLDriver::open(const QString& db,
+     }
+ 
+ #if MYSQL_VERSION_ID >= 50007
+-    if (mysql_get_client_version() >= 50503 && mysql_get_server_version(d->mysql) >= 50503) {
+-        // force the communication to be utf8mb4 (only utf8mb4 supports 4-byte characters)
+-        mysql_set_character_set(d->mysql, "utf8mb4");
++    // force the communication to be utf8mb4 (only utf8mb4 supports 4-byte characters)
++    if (mysql_set_character_set(d->mysql, "utf8mb4")) {
++        // this failed, try forcing it to utf (BMP only)
++        if (mysql_set_character_set(d->mysql, "utf8"))
++            qWarning() << "MySQL: Unable to set the client character set to utf8.";
+ #if QT_CONFIG(textcodec)
+-        d->tc = QTextCodec::codecForName("UTF-8");
++        else
++            d->tc = codec(d->mysql);
+ #endif
+-    } else
+-    {
+-        // force the communication to be utf8
+-        mysql_set_character_set(d->mysql, "utf8");
++    }
+ #if QT_CONFIG(textcodec)
+-        d->tc = codec(d->mysql);
++    else
++        d->tc = QTextCodec::codecForName("UTF-8");
+ #endif
+-    }
+ #endif  // MYSQL_VERSION_ID >= 50007
+ 
+     d->preparedQuerysEnabled = checkPreparedQueries(d->mysql);
+diff --git a/qtbase/src/printsupport/dialogs/images/print-24.png b/qtbase/src/printsupport/dialogs/images/printer-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/print-24.png
+rename to src/printsupport/dialogs/images/printer-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/print-32.png b/qtbase/src/printsupport/dialogs/images/printer-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/print-32.png
+rename to src/printsupport/dialogs/images/printer-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-sided-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-facing-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-sided-24.png
+rename to src/printsupport/dialogs/images/view-pages-facing-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-sided-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-facing-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-sided-32.png
+rename to src/printsupport/dialogs/images/view-pages-facing-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-multi-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-overview-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-multi-24.png
+rename to src/printsupport/dialogs/images/view-pages-overview-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-multi-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-overview-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-multi-32.png
+rename to src/printsupport/dialogs/images/view-pages-overview-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-one-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-single-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-one-24.png
+rename to src/printsupport/dialogs/images/view-pages-single-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-one-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-single-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-one-32.png
+rename to src/printsupport/dialogs/images/view-pages-single-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-page-24.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-page-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-page-24.png
+rename to src/printsupport/dialogs/images/zoom-fit-page-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-page-32.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-page-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-page-32.png
+rename to src/printsupport/dialogs/images/zoom-fit-page-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-width-24.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-width-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-width-24.png
+rename to src/printsupport/dialogs/images/zoom-fit-width-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-width-32.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-width-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-width-32.png
+rename to src/printsupport/dialogs/images/zoom-fit-width-32.png
+diff --git a/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp b/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
+index 78e5b8d1ef..2a28516719 100644
+--- a/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
++++ b/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
+@@ -532,6 +532,7 @@ void QPageSetupWidget::updateWidget()
+ void QPageSetupWidget::setupPrinter() const
+ {
+     m_printer->setPageLayout(m_pageLayout);
++    m_printer->setPageOrientation(m_pageLayout.orientation());
+ #if QT_CONFIG(cups)
+     QCUPSSupport::PagesPerSheet pagesPerSheet = qvariant_cast<QCUPSSupport::PagesPerSheet>(m_ui.pagesPerSheetCombo->currentData()
+ );
+diff --git a/qtbase/src/printsupport/dialogs/qprintdialog.qrc b/qtbase/src/printsupport/dialogs/qprintdialog.qrc
+index 5a579baa55..10b8e1d341 100644
+--- a/qtbase/src/printsupport/dialogs/qprintdialog.qrc
++++ b/qtbase/src/printsupport/dialogs/qprintdialog.qrc
+@@ -1,9 +1,9 @@
+ <!DOCTYPE RCC><RCC version="1.0">
+ <qresource prefix="/qt-project.org/dialogs/qprintpreviewdialog">
+-<file>images/fit-page-24.png</file>
+-<file>images/fit-page-32.png</file>
+-<file>images/fit-width-24.png</file>
+-<file>images/fit-width-32.png</file>
++<file>images/zoom-fit-page-24.png</file>
++<file>images/zoom-fit-page-32.png</file>
++<file>images/zoom-fit-width-24.png</file>
++<file>images/zoom-fit-width-32.png</file>
+ <file>images/go-first-24.png</file>
+ <file>images/go-first-32.png</file>
+ <file>images/go-last-24.png</file>
+@@ -18,14 +18,14 @@
+ <file>images/layout-portrait-32.png</file>
+ <file>images/page-setup-24.png</file>
+ <file>images/page-setup-32.png</file>
+-<file>images/print-24.png</file>
+-<file>images/print-32.png</file>
+-<file>images/view-page-multi-24.png</file>
+-<file>images/view-page-multi-32.png</file>
+-<file>images/view-page-one-24.png</file>
+-<file>images/view-page-one-32.png</file>
+-<file>images/view-page-sided-24.png</file>
+-<file>images/view-page-sided-32.png</file>
++<file>images/printer-24.png</file>
++<file>images/printer-32.png</file>
++<file>images/view-pages-overview-24.png</file>
++<file>images/view-pages-overview-32.png</file>
++<file>images/view-pages-single-24.png</file>
++<file>images/view-pages-single-32.png</file>
++<file>images/view-pages-facing-24.png</file>
++<file>images/view-pages-facing-32.png</file>
+ <file>images/zoom-in-24.png</file>
+ <file>images/zoom-in-32.png</file>
+ <file>images/zoom-out-24.png</file>
+diff --git a/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp b/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
+index c5b845f4ec..5a5ba1d0a8 100644
+--- a/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
++++ b/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
+@@ -702,13 +702,14 @@ void QPrintDialogPrivate::selectPrinter(const QPrinter::OutputFormat outputForma
+         else
+             options.grayscale->setChecked(true);
+ 
+-        // keep duplex value explicitly set by user, if any, and selected printer supports it;
+-        // use device default otherwise
++        // duplex priorities to be as follows:
++        // 1) a user-selected duplex value in the dialog has highest prority
++        // 2) duplex value set in the QPrinter
+         QPrint::DuplexMode duplex;
+         if (explicitDuplexMode != QPrint::DuplexAuto && supportedDuplexMode.contains(explicitDuplexMode))
+             duplex = explicitDuplexMode;
+         else
+-            duplex = top->d->m_currentPrintDevice.defaultDuplexMode();
++            duplex = static_cast<QPrint::DuplexMode>(p->duplex());
+         switch (duplex) {
+         case QPrint::DuplexNone:
+             options.noDuplex->setChecked(true); break;
+@@ -1242,10 +1243,10 @@ void QUnixPrintWidgetPrivate::_q_printerChanged(int index)
+             QString filename = widget.filename->text();
+             widget.filename->setText(filename);
+             widget.lOutput->setEnabled(true);
+-            if (optionsPane)
+-                optionsPane->selectPrinter(QPrinter::PdfFormat);
+             printer->setOutputFormat(QPrinter::PdfFormat);
+             m_currentPrintDevice = QPrintDevice();
++            if (optionsPane)
++                optionsPane->selectPrinter(QPrinter::PdfFormat);
+             return;
+         }
+     }
+diff --git a/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp b/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
+index 39575d5f57..23b7e89538 100644
+--- a/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
++++ b/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
+@@ -352,7 +352,7 @@ void QPrintPreviewDialogPrivate::init(QPrinter *_printer)
+ static inline void qt_setupActionIcon(QAction *action, QLatin1String name)
+ {
+     QLatin1String imagePrefix(":/qt-project.org/dialogs/qprintpreviewdialog/images/");
+-    QIcon icon;
++    QIcon icon = QIcon::fromTheme(name);
+     icon.addFile(imagePrefix + name + QLatin1String("-24.png"), QSize(24, 24));
+     icon.addFile(imagePrefix + name + QLatin1String("-32.png"), QSize(32, 32));
+     action->setIcon(icon);
+@@ -383,8 +383,8 @@ void QPrintPreviewDialogPrivate::setupActions()
+     fitPageAction->setObjectName(QLatin1String("fitPageAction"));
+     fitWidthAction->setCheckable(true);
+     fitPageAction->setCheckable(true);
+-    qt_setupActionIcon(fitWidthAction, QLatin1String("fit-width"));
+-    qt_setupActionIcon(fitPageAction, QLatin1String("fit-page"));
++    qt_setupActionIcon(fitWidthAction, QLatin1String("zoom-fit-width"));
++    qt_setupActionIcon(fitPageAction, QLatin1String("zoom-fit-page"));
+     QObject::connect(fitGroup, SIGNAL(triggered(QAction*)), q, SLOT(_q_fit(QAction*)));
+ 
+     // Zoom
+@@ -410,9 +410,9 @@ void QPrintPreviewDialogPrivate::setupActions()
+     singleModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show single page"));
+     facingModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show facing pages"));
+     overviewModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show overview of all pages"));
+-    qt_setupActionIcon(singleModeAction, QLatin1String("view-page-one"));
+-    qt_setupActionIcon(facingModeAction, QLatin1String("view-page-sided"));
+-    qt_setupActionIcon(overviewModeAction, QLatin1String("view-page-multi"));
++    qt_setupActionIcon(singleModeAction, QLatin1String("view-pages-single"));
++    qt_setupActionIcon(facingModeAction, QLatin1String("view-pages-facing"));
++    qt_setupActionIcon(overviewModeAction, QLatin1String("view-pages-overview"));
+     singleModeAction->setObjectName(QLatin1String("singleModeAction"));
+     facingModeAction->setObjectName(QLatin1String("facingModeAction"));
+     overviewModeAction->setObjectName(QLatin1String("overviewModeAction"));
+@@ -426,7 +426,7 @@ void QPrintPreviewDialogPrivate::setupActions()
+     printerGroup = new QActionGroup(q);
+     printAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Print"));
+     pageSetupAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Page setup"));
+-    qt_setupActionIcon(printAction, QLatin1String("print"));
++    qt_setupActionIcon(printAction, QLatin1String("printer"));
+     qt_setupActionIcon(pageSetupAction, QLatin1String("page-setup"));
+     QObject::connect(printAction, SIGNAL(triggered(bool)), q, SLOT(_q_print()));
+     QObject::connect(pageSetupAction, SIGNAL(triggered(bool)), q, SLOT(_q_pageSetup()));
+diff --git a/qtbase/src/sql/kernel/qsqlquery.cpp b/qtbase/src/sql/kernel/qsqlquery.cpp
+index 32c6166c79..60afef10c3 100644
+--- a/qtbase/src/sql/kernel/qsqlquery.cpp
++++ b/qtbase/src/sql/kernel/qsqlquery.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2022 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtSql module of the Qt Toolkit.
+@@ -377,6 +377,10 @@ bool QSqlQuery::exec(const QString& query)
+     QElapsedTimer t;
+     t.start();
+ #endif
++    if (!driver()) {
++        qWarning("QSqlQuery::exec: called before driver has been set up");
++        return false;
++    }
+     if (d->ref.loadRelaxed() != 1) {
+         bool fo = isForwardOnly();
+         *this = QSqlQuery(driver()->createResult());
+diff --git a/qtbase/src/testlib/qabstractitemmodeltester.cpp b/qtbase/src/testlib/qabstractitemmodeltester.cpp
+index 8efb9c53d4..ce062f66d7 100644
+--- a/qtbase/src/testlib/qabstractitemmodeltester.cpp
++++ b/qtbase/src/testlib/qabstractitemmodeltester.cpp
+@@ -454,7 +454,7 @@ void QAbstractItemModelTesterPrivate::parent()
+ 
+     // Common error test #2, make sure that a second level index has a parent
+     // that is the first level index.
+-    if (model->rowCount(topIndex) > 0) {
++    if (model->rowCount(topIndex) > 0 && model->columnCount(topIndex) > 0) {
+         QModelIndex childIndex = model->index(0, 0, topIndex);
+         MODELTESTER_VERIFY(childIndex.isValid());
+         MODELTESTER_COMPARE(model->parent(childIndex), topIndex);
+diff --git a/qtbase/src/testlib/qasciikey.cpp b/qtbase/src/testlib/qasciikey.cpp
+index 9a308da2bc..93498b256f 100644
+--- a/qtbase/src/testlib/qasciikey.cpp
++++ b/qtbase/src/testlib/qasciikey.cpp
+@@ -498,6 +498,11 @@ char QTest::keyToAscii(Qt::Key key)
+     case Qt::Key_LaunchE : return 0; // = 0x10b0,
+     case Qt::Key_LaunchF : return 0; // = 0x10b1,
+ 
++    // Keypad navigation keys
++    case Qt::Key_Select : return 0; // = 0x01010000
++    case Qt::Key_Yes : return 0; // = 0x01010001
++    case Qt::Key_No : return 0; // = 0x01010002
++
+     default: QTEST_ASSERT(false); return 0;
+     }
+ }
+diff --git a/qtbase/src/testlib/qtestresult.cpp b/qtbase/src/testlib/qtestresult.cpp
+index 88028aac6e..2e89930776 100644
+--- a/qtbase/src/testlib/qtestresult.cpp
++++ b/qtbase/src/testlib/qtestresult.cpp
+@@ -251,7 +251,8 @@ bool QTestResult::verify(bool statement, const char *statementStr,
+ {
+     QTEST_ASSERT(statementStr);
+ 
+-    char msg[1024] = {'\0'};
++    char msg[1024];
++    msg[0] = '\0';
+ 
+     if (QTestLog::verboseLevel() >= 2) {
+         qsnprintf(msg, 1024, "QVERIFY(%s)", statementStr);
+@@ -309,7 +310,8 @@ static bool compareHelper(bool success, const char *failureMsg,
+                           bool hasValues = true)
+ {
+     const size_t maxMsgLen = 1024;
+-    char msg[maxMsgLen] = {'\0'};
++    char msg[maxMsgLen];
++    msg[0] = '\0';
+ 
+     QTEST_ASSERT(expected);
+     QTEST_ASSERT(actual);
+diff --git a/qtbase/src/widgets/dialogs/qcolordialog.cpp b/qtbase/src/widgets/dialogs/qcolordialog.cpp
+index 4247731275..cb325be85c 100644
+--- a/qtbase/src/widgets/dialogs/qcolordialog.cpp
++++ b/qtbase/src/widgets/dialogs/qcolordialog.cpp
+@@ -78,7 +78,10 @@
+ #include "qwindow.h"
+ 
+ #include "private/qdialog_p.h"
++#include "private/qguiapplication_p.h"
+ 
++#include <qpa/qplatformservices.h>
++#include <qpa/qplatformintegration.h>
+ #include <algorithm>
+ 
+ QT_BEGIN_NAMESPACE
+@@ -1611,6 +1614,20 @@ void QColorDialogPrivate::_q_newStandard(int r, int c)
+ void QColorDialogPrivate::_q_pickScreenColor()
+ {
+     Q_Q(QColorDialog);
++
++    auto *platformServices = QGuiApplicationPrivate::platformIntegration()->services();
++    if (platformServices->hasCapability(QPlatformServices::Capability::ColorPicking)) {
++        if (auto *colorPicker = platformServices->colorPicker(q->windowHandle())) {
++            q->connect(colorPicker, &QPlatformServiceColorPicker::colorPicked, q,
++                       [q, colorPicker](const QColor &color) {
++                           colorPicker->deleteLater();
++                           q->setCurrentColor(color);
++                       });
++            colorPicker->pickColor();
++            return;
++        }
++    }
++
+     if (!colorPickingEventFilter)
+         colorPickingEventFilter = new QColorPickingEventFilter(this, q);
+     q->installEventFilter(colorPickingEventFilter);
+diff --git a/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp b/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
+index e120817edc..8ea36b5427 100644
+--- a/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
++++ b/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
+@@ -400,12 +400,7 @@ bool QAbstractItemDelegate::helpEvent(QHelpEvent *event,
+         const QString tooltip = index.isValid() ?
+               d->textForRole(Qt::ToolTipRole, index.data(Qt::ToolTipRole), option.locale, precision) :
+               QString();
+-        QRect rect;
+-        if (index.isValid()) {
+-            const QRect r = view->visualRect(index);
+-            rect = QRect(view->mapToGlobal(r.topLeft()), r.size());
+-        }
+-        QToolTip::showText(he->globalPos(), tooltip, view, rect);
++        QToolTip::showText(he->globalPos(), tooltip, view->viewport(), option.rect);
+         event->setAccepted(!tooltip.isEmpty());
+         break;
+         }
+diff --git a/qtbase/src/widgets/itemviews/qlistview.cpp b/qtbase/src/widgets/itemviews/qlistview.cpp
+index 2b34476642..eebfaa030e 100644
+--- a/qtbase/src/widgets/itemviews/qlistview.cpp
++++ b/qtbase/src/widgets/itemviews/qlistview.cpp
+@@ -3386,6 +3386,7 @@ void QIconModeViewBase::updateContentsSize()
+ */
+ void QListView::currentChanged(const QModelIndex &current, const QModelIndex &previous)
+ {
++    QAbstractItemView::currentChanged(current, previous);
+ #ifndef QT_NO_ACCESSIBILITY
+     if (QAccessible::isActive()) {
+         if (current.isValid()) {
+@@ -3396,7 +3397,6 @@ void QListView::currentChanged(const QModelIndex &current, const QModelIndex &pr
+         }
+     }
+ #endif
+-    QAbstractItemView::currentChanged(current, previous);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/widgets/itemviews/qtableview.cpp b/qtbase/src/widgets/itemviews/qtableview.cpp
+index 934ac581b2..f79bb24249 100644
+--- a/qtbase/src/widgets/itemviews/qtableview.cpp
++++ b/qtbase/src/widgets/itemviews/qtableview.cpp
+@@ -1013,6 +1013,7 @@ void QTableViewPrivate::drawCell(QPainter *painter, const QStyleOptionViewItem &
+ int QTableViewPrivate::widthHintForIndex(const QModelIndex &index, int hint, const QStyleOptionViewItem &option) const
+ {
+     Q_Q(const QTableView);
++    const int oldHint = hint;
+     QWidget *editor = editorForIndex(index).widget.data();
+     if (editor && persistent.contains(editor)) {
+         hint = qMax(hint, editor->sizeHint().width());
+@@ -1021,6 +1022,17 @@ int QTableViewPrivate::widthHintForIndex(const QModelIndex &index, int hint, con
+         hint = qBound(min, hint, max);
+     }
+     hint = qMax(hint, q->itemDelegate(index)->sizeHint(option, index).width());
++
++    if (hasSpans()) {
++        auto span = spans.spanAt(index.column(), index.row());
++        if (span && span->m_left == index.column() && span->m_top == index.row()) {
++            // spans are screwed up when sections are moved
++            const auto left = logicalColumn(span->m_left);
++            for (int i = 1; i <= span->width(); ++i)
++               hint -= q->columnWidth(visualColumn(left + i));
++        }
++        hint = std::max(hint, oldHint);
++    }
+     return hint;
+ }
+ 
+@@ -1053,6 +1065,11 @@ int QTableViewPrivate::heightHintForIndex(const QModelIndex &index, int hint, QS
+         option.rect.setHeight(height);
+         option.rect.setX(q->columnViewportPosition(index.column()));
+         option.rect.setWidth(q->columnWidth(index.column()));
++        if (hasSpans()) {
++            auto span = spans.spanAt(index.column(), index.row());
++            if (span && span->m_left == index.column() && span->m_top == index.row())
++                option.rect.setWidth(std::max(option.rect.width(), visualSpanRect(*span).width()));
++        }
+         // 1px less space when grid is shown (see drawCell)
+         if (showGrid)
+             option.rect.setWidth(option.rect.width() - 1);
+diff --git a/qtbase/src/widgets/kernel/qaction.h b/qtbase/src/widgets/kernel/qaction.h
+index 258a1ea0a0..737c1e8285 100644
+--- a/qtbase/src/widgets/kernel/qaction.h
++++ b/qtbase/src/widgets/kernel/qaction.h
+@@ -81,7 +81,7 @@ class Q_WIDGETS_EXPORT QAction : public QObject
+     Q_PROPERTY(MenuRole menuRole READ menuRole WRITE setMenuRole NOTIFY changed)
+     Q_PROPERTY(bool iconVisibleInMenu READ isIconVisibleInMenu WRITE setIconVisibleInMenu NOTIFY changed)
+     Q_PROPERTY(bool shortcutVisibleInContextMenu READ isShortcutVisibleInContextMenu WRITE setShortcutVisibleInContextMenu NOTIFY changed)
+-    Q_PROPERTY(Priority priority READ priority WRITE setPriority)
++    Q_PROPERTY(Priority priority READ priority WRITE setPriority NOTIFY changed)
+ 
+ public:
+     // note this is copied into qplatformmenu.h, which must stay in sync
+diff --git a/qtbase/src/widgets/kernel/qwidget.cpp b/qtbase/src/widgets/kernel/qwidget.cpp
+index 9eba1e001e..26f6d27e18 100644
+--- a/qtbase/src/widgets/kernel/qwidget.cpp
++++ b/qtbase/src/widgets/kernel/qwidget.cpp
+@@ -5296,7 +5296,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
+         QWidgetEffectSourcePrivate *sourced = static_cast<QWidgetEffectSourcePrivate *>
+                                                          (source->d_func());
+         if (!sourced->context) {
+-            const QRegion effectRgn(rgn.boundingRect());
++            const QRegion effectRgn((flags & UseEffectRegionBounds) ? rgn.boundingRect() : rgn);
+             QWidgetPaintContext context(pdev, effectRgn, offset, flags, sharedPainter, repaintManager);
+             sourced->context = &context;
+             if (!sharedPainter) {
+@@ -5328,6 +5328,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
+         }
+     }
+ #endif // QT_CONFIG(graphicseffect)
++    flags = flags & ~UseEffectRegionBounds;
+ 
+     const bool alsoOnScreen = flags & DrawPaintOnScreen;
+     const bool recursive = flags & DrawRecursive;
+diff --git a/qtbase/src/widgets/kernel/qwidget_p.h b/qtbase/src/widgets/kernel/qwidget_p.h
+index eef6b8fa2c..c432f4b5d5 100644
+--- a/qtbase/src/widgets/kernel/qwidget_p.h
++++ b/qtbase/src/widgets/kernel/qwidget_p.h
+@@ -229,7 +229,8 @@ public:
+         DontSubtractOpaqueChildren = 0x10,
+         DontDrawOpaqueChildren = 0x20,
+         DontDrawNativeChildren = 0x40,
+-        DontSetCompositionMode = 0x80
++        DontSetCompositionMode = 0x80,
++        UseEffectRegionBounds = 0x100
+     };
+     Q_DECLARE_FLAGS(DrawWidgetFlags, DrawWidgetFlag)
+     Q_FLAG(DrawWidgetFlags)
+diff --git a/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp b/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
+index 02880b34da..0d44e1326d 100644
+--- a/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
++++ b/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
+@@ -1018,7 +1018,8 @@ void QWidgetRepaintManager::paintAndFlush()
+ 
+     // Paint the rest with composition.
+     if (repaintAllWidgets || !dirtyCopy.isEmpty()) {
+-        QWidgetPrivate::DrawWidgetFlags flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive;
++        QWidgetPrivate::DrawWidgetFlags flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive
++                | QWidgetPrivate::UseEffectRegionBounds;
+         tlw->d_func()->drawWidget(store->paintDevice(), dirtyCopy, QPoint(), flags, nullptr, this);
+     }
+ 
+diff --git a/qtbase/src/widgets/styles/qfusionstyle.cpp b/qtbase/src/widgets/styles/qfusionstyle.cpp
+index f4345d97c4..962912c838 100644
+--- a/qtbase/src/widgets/styles/qfusionstyle.cpp
++++ b/qtbase/src/widgets/styles/qfusionstyle.cpp
+@@ -1772,14 +1772,6 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio
+             proxy()->drawControl(CE_PushButtonLabel, &subopt, painter, widget);
+         }
+         break;
+-    case CE_PushButtonLabel:
+-        if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
+-            QStyleOptionButton b(*button);
+-            // no PM_ButtonShiftHorizontal and PM_ButtonShiftVertical for fusion style
+-            b.state &= ~(State_On | State_Sunken);
+-            QCommonStyle::drawControl(element, &b, painter, widget);
+-        }
+-        break;
+     case CE_MenuBarEmptyArea:
+         painter->save();
+     {
+diff --git a/qtbase/src/widgets/util/qcompleter.cpp b/qtbase/src/widgets/util/qcompleter.cpp
+index 18b24063d8..ef7207a8a3 100644
+--- a/qtbase/src/widgets/util/qcompleter.cpp
++++ b/qtbase/src/widgets/util/qcompleter.cpp
+@@ -1120,6 +1120,8 @@ void QCompleter::setModel(QAbstractItemModel *model)
+ {
+     Q_D(QCompleter);
+     QAbstractItemModel *oldModel = d->proxy->sourceModel();
++    if (oldModel == model)
++        return;
+ #if QT_CONFIG(filesystemmodel)
+     if (qobject_cast<const QFileSystemModel *>(oldModel))
+         setCompletionRole(Qt::EditRole); // QTBUG-54642, clear FileNameRole set by QFileSystemModel
+diff --git a/qtbase/src/widgets/widgets/qabstractbutton.cpp b/qtbase/src/widgets/widgets/qabstractbutton.cpp
+index a128b23950..dc40bf62fb 100644
+--- a/qtbase/src/widgets/widgets/qabstractbutton.cpp
++++ b/qtbase/src/widgets/widgets/qabstractbutton.cpp
+@@ -56,6 +56,7 @@
+ #ifndef QT_NO_ACCESSIBILITY
+ #include "qaccessible.h"
+ #endif
++#include <qpa/qplatformtheme.h>
+ 
+ #include <algorithm>
+ 
+@@ -1076,19 +1077,19 @@ void QAbstractButton::keyPressEvent(QKeyEvent *e)
+ {
+     Q_D(QAbstractButton);
+     bool next = true;
+-    switch (e->key()) {
+-    case Qt::Key_Enter:
+-    case Qt::Key_Return:
+-        e->ignore();
+-        break;
+-    case Qt::Key_Select:
+-    case Qt::Key_Space:
+-        if (!e->isAutoRepeat()) {
+-            setDown(true);
+-            repaint();
+-            d->emitPressed();
+-        }
+-        break;
++
++    const auto key = static_cast<Qt::Key>(e->key());
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(key) && !e->isAutoRepeat()) {
++        setDown(true);
++        repaint();
++        d->emitPressed();
++        return;
++    }
++
++    switch (key) {
+     case Qt::Key_Up:
+         next = false;
+         Q_FALLTHROUGH();
+@@ -1153,15 +1154,15 @@ void QAbstractButton::keyReleaseEvent(QKeyEvent *e)
+     if (!e->isAutoRepeat())
+         d->repeatTimer.stop();
+ 
+-    switch (e->key()) {
+-    case Qt::Key_Select:
+-    case Qt::Key_Space:
+-        if (!e->isAutoRepeat() && d->down)
+-            d->click();
+-        break;
+-    default:
+-        e->ignore();
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(static_cast<Qt::Key>(e->key())) && !e->isAutoRepeat() && d->down) {
++        d->click();
++        return;
+     }
++
++    e->ignore();
+ }
+ 
+ /*!\reimp
+diff --git a/qtbase/src/widgets/widgets/qcombobox.cpp b/qtbase/src/widgets/widgets/qcombobox.cpp
+index 7a496c27e0..0a3d96647b 100644
+--- a/qtbase/src/widgets/widgets/qcombobox.cpp
++++ b/qtbase/src/widgets/widgets/qcombobox.cpp
+@@ -3352,7 +3352,23 @@ void QComboBox::keyPressEvent(QKeyEvent *e)
+ 
+     Move move = NoMove;
+     int newIndex = currentIndex();
+-    switch (e->key()) {
++
++    bool pressLikeButton = !d->lineEdit;
++#ifdef QT_KEYPAD_NAVIGATION
++    pressLikeButton |= QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus();
++#endif
++    auto key = static_cast<Qt::Key>(e->key());
++    if (pressLikeButton) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(key)) {
++            showPopup();
++            return;
++        }
++    }
++
++    switch (key) {
+     case Qt::Key_Up:
+         if (e->modifiers() & Qt::ControlModifier)
+             break; // pass to line edit for auto completion
+@@ -3394,26 +3410,11 @@ void QComboBox::keyPressEvent(QKeyEvent *e)
+             return;
+         }
+         break;
+-    case Qt::Key_Space:
+-        if (!d->lineEdit) {
+-            showPopup();
+-            return;
+-        }
+-        break;
+-    case Qt::Key_Enter:
+-    case Qt::Key_Return:
+     case Qt::Key_Escape:
+         if (!d->lineEdit)
+             e->ignore();
+         break;
+ #ifdef QT_KEYPAD_NAVIGATION
+-    case Qt::Key_Select:
+-        if (QApplicationPrivate::keypadNavigationEnabled()
+-                && (!hasEditFocus() || !d->lineEdit)) {
+-            showPopup();
+-            return;
+-        }
+-        break;
+     case Qt::Key_Left:
+     case Qt::Key_Right:
+         if (QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus())
+diff --git a/qtbase/src/widgets/widgets/qdatetimeedit_p.h b/qtbase/src/widgets/widgets/qdatetimeedit_p.h
+index d36b6f8f9a..e0df5b5158 100644
+--- a/qtbase/src/widgets/widgets/qdatetimeedit_p.h
++++ b/qtbase/src/widgets/widgets/qdatetimeedit_p.h
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2018 The Qt Company Ltd.
++** Copyright (C) 2021 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtWidgets module of the Qt Toolkit.
+diff --git a/qtbase/src/widgets/widgets/qgroupbox.cpp b/qtbase/src/widgets/widgets/qgroupbox.cpp
+index 02a0bed325..3f3eccc370 100644
+--- a/qtbase/src/widgets/widgets/qgroupbox.cpp
++++ b/qtbase/src/widgets/widgets/qgroupbox.cpp
+@@ -54,6 +54,8 @@
+ #include "qaccessible.h"
+ #endif
+ #include <private/qwidget_p.h>
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
+ 
+ #include "qdebug.h"
+ 
+@@ -360,7 +362,10 @@ bool QGroupBox::event(QEvent *e)
+         return true;
+     case QEvent::KeyPress: {
+         QKeyEvent *k = static_cast<QKeyEvent*>(e);
+-        if (!k->isAutoRepeat() && (k->key() == Qt::Key_Select || k->key() == Qt::Key_Space)) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (!k->isAutoRepeat() && buttonPressKeys.contains(static_cast<Qt::Key>(k->key()))) {
+             d->pressedControl = QStyle::SC_GroupBoxCheckBox;
+             update(style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxCheckBox, this));
+             return true;
+@@ -369,7 +374,10 @@ bool QGroupBox::event(QEvent *e)
+     }
+     case QEvent::KeyRelease: {
+         QKeyEvent *k = static_cast<QKeyEvent*>(e);
+-        if (!k->isAutoRepeat() && (k->key() == Qt::Key_Select || k->key() == Qt::Key_Space)) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (!k->isAutoRepeat() && buttonPressKeys.contains(static_cast<Qt::Key>(k->key()))) {
+             bool toggle = (d->pressedControl == QStyle::SC_GroupBoxLabel
+                            || d->pressedControl == QStyle::SC_GroupBoxCheckBox);
+             d->pressedControl = QStyle::SC_None;
+diff --git a/qtbase/src/widgets/widgets/qlabel.cpp b/qtbase/src/widgets/widgets/qlabel.cpp
+index 30ff80cbb0..cf2605c17c 100644
+--- a/qtbase/src/widgets/widgets/qlabel.cpp
++++ b/qtbase/src/widgets/widgets/qlabel.cpp
+@@ -421,9 +421,6 @@ void QLabel::setPixmap(const QPixmap &pixmap)
+         d->pixmap = new QPixmap(pixmap);
+     }
+ 
+-    if (d->pixmap->depth() == 1 && !d->pixmap->mask())
+-        d->pixmap->setMask(*((QBitmap *)d->pixmap));
+-
+     d->updateLabel();
+ }
+ 
+diff --git a/qtbase/src/widgets/widgets/qtoolbararealayout.cpp b/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
+index 493c094cc1..d5f4b59017 100644
+--- a/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
++++ b/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
+@@ -1367,7 +1367,7 @@ bool QToolBarAreaLayout::restoreState(QDataStream &stream, const QList<QToolBar*
+                 item.widgetItem = new QWidgetItemV2(toolBar);
+                 toolBar->setOrientation(floating ? ((shown & 2) ? Qt::Vertical : Qt::Horizontal) : dock.o);
+                 toolBar->setVisible(shown & 1);
+-                toolBar->d_func()->setWindowState(floating, true, rect);
++                toolBar->d_func()->setWindowState(floating, false, rect);
+ 
+                 item.preferredSize = item.size;
+                 line.toolBarItems.append(item);
+diff --git a/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp b/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
+index 212c0a2e13..3c77b1ba0b 100644
+--- a/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
++++ b/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
+@@ -126,8 +126,7 @@ public:
+ 
+ void tst_QtConcurrentIterateKernel::instantiate()
+ {
+-    auto future = startThreadEngine(new PrintFor(0, 40)).startAsynchronously();
+-    future.waitForFinished();
++    startThreadEngine(new PrintFor(0, 40)).startBlocking();
+     QCOMPARE(iterations.loadRelaxed(), 40);
+ }
+ 
+@@ -166,10 +165,8 @@ void tst_QtConcurrentIterateKernel::stresstest()
+     const int times = 50;
+     for (int i = 0; i < times; ++i) {
+         counter.storeRelaxed(0);
+-        // ThreadEngine will delete f when it finishes
+-        auto f = new CountFor(0, iterations);
+-        auto future = f->startAsynchronously();
+-        future.waitForFinished();
++        CountFor f(0, iterations);
++        f.startBlocking();
+         QCOMPARE(counter.loadRelaxed(), iterations);
+     }
+ }
+@@ -177,11 +174,8 @@ void tst_QtConcurrentIterateKernel::stresstest()
+ void tst_QtConcurrentIterateKernel::noIterations()
+ {
+     const int times = 20000;
+-    for (int i = 0; i < times; ++i) {
+-        auto future = startThreadEngine(new IterateKernel<TestIterator, void>(0, 0))
+-                              .startAsynchronously();
+-        future.waitForFinished();
+-    }
++    for (int i = 0; i < times; ++i)
++        startThreadEngine(new IterateKernel<TestIterator, void>(0, 0)).startBlocking();
+ }
+ 
+ QMutex threadsMutex;
+@@ -236,10 +230,8 @@ void tst_QtConcurrentIterateKernel::throttling()
+ 
+     threads.clear();
+ 
+-    // ThreadEngine will delete f when it finishes
+-    auto f = new ThrottleFor(0, totalIterations);
+-    auto future = f->startAsynchronously();
+-    future.waitForFinished();
++    ThrottleFor f(0, totalIterations);
++    f.startBlocking();
+ 
+     QCOMPARE(iterations.loadRelaxed(), totalIterations);
+ 
+diff --git a/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp b/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
+index ac7be7acdd..81bc64c8d9 100644
+--- a/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
++++ b/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
+@@ -65,9 +65,16 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::runDirectly()
+ {
+-    PrintUser *engine = new PrintUser();
+-    QFuture<void> f = engine->startAsynchronously();
+-    f.waitForFinished();
++    {
++        PrintUser engine;
++        engine.startSingleThreaded();
++        engine.startBlocking();
++    }
++    {
++        PrintUser *engine = new PrintUser();
++        QFuture<void> f = engine->startAsynchronously();
++        f.waitForFinished();
++    }
+ }
+ 
+ class StringResultUser : public ThreadEngine<QString>
+@@ -99,10 +106,8 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::result()
+ {
+-    // ThreadEngine will delete 'engine' when it finishes
+-    auto engine = new StringResultUser();
+-    auto future = engine->startAsynchronously();
+-    QCOMPARE(future.result(), QString("Foo"));
++    StringResultUser engine;
++    QCOMPARE(*engine.startBlocking(), QString("Foo"));
+ }
+ 
+ class VoidResultUser : public ThreadEngine<void>
+@@ -128,9 +133,17 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::runThroughStarter()
+ {
+-    ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
+-    QFuture<QString> f = starter.startAsynchronously();
+-    QCOMPARE(f.result(), QString("Foo"));
++    {
++        ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
++        QFuture<QString>  f = starter.startAsynchronously();
++        QCOMPARE(f.result(), QString("Foo"));
++    }
++
++    {
++        ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
++        QString str = starter.startBlocking();
++        QCOMPARE(str, QString("Foo"));
++    }
+ }
+ 
+ class CancelUser : public ThreadEngine<void>
+@@ -213,6 +226,12 @@ void tst_QtConcurrentThreadEngine::throttle()
+         f.waitForFinished();
+         QCOMPARE(count.loadRelaxed(), 0);
+     }
++
++    for (int i = 0; i < repeats; ++i) {
++        ThrottleAlwaysUser t;
++        t.startBlocking();
++        QCOMPARE(count.loadRelaxed(), 0);
++    }
+ }
+ 
+ QSet<QThread *> threads;
+@@ -249,17 +268,35 @@ void tst_QtConcurrentThreadEngine::threadCount()
+ {
+     const int repeats = 10;
+     for (int i = 0; i < repeats; ++i) {
++        ThreadCountUser t;
++        t.startBlocking();
++        int count = threads.count();
++        int count_expected = QThreadPool::globalInstance()->maxThreadCount() + 1; // +1 for the main thread.
++        if (count != count_expected)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, count_expected);
++
+         (new ThreadCountUser())->startAsynchronously().waitForFinished();
+-        const auto count = threads.count();
+-        const auto maxThreadCount = QThreadPool::globalInstance()->maxThreadCount();
+-        QVERIFY(count <= maxThreadCount);
+-        QVERIFY(!threads.contains(QThread::currentThread()));
++        count = threads.count();
++        count_expected = QThreadPool::globalInstance()->maxThreadCount();
++        if (count != count_expected)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, count_expected);
+     }
+ 
+     // Set the finish flag immediately, this should give us one thread only.
+     for (int i = 0; i < repeats; ++i) {
++        ThreadCountUser t(true /*finishImmediately*/);
++        t.startBlocking();
++        int count = threads.count();
++        if (count != 1)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, 1);
++
+         (new ThreadCountUser(true /*finishImmediately*/))->startAsynchronously().waitForFinished();
+-        const auto count = threads.count();
++        count = threads.count();
++        if (count != 1)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
+         QCOMPARE(count, 1);
+         QVERIFY(!threads.contains(QThread::currentThread()));
+     }
+@@ -400,6 +437,7 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::exceptions()
+ {
++    // Asynchronous mode:
+     {
+         bool caught = false;
+         try  {
+@@ -412,6 +450,32 @@ void tst_QtConcurrentThreadEngine::exceptions()
+         QVERIFY2(caught, "did not get exception");
+     }
+ 
++    // Blocking mode:
++    // test throwing the exception from a worker thread.
++    {
++        bool caught = false;
++        try  {
++            QtConcurrentExceptionThrower e(QThread::currentThread());
++            e.startBlocking();
++        } catch (const QException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // test throwing the exception from the main thread (different code path)
++    {
++        bool caught = false;
++        try  {
++            QtConcurrentExceptionThrower e(0);
++            e.startBlocking();
++        } catch (const QException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // Asynchronous mode:
+     {
+         bool caught = false;
+         try  {
+@@ -423,6 +487,31 @@ void tst_QtConcurrentThreadEngine::exceptions()
+         }
+         QVERIFY2(caught, "did not get exception");
+     }
++
++    // Blocking mode:
++    // test throwing the exception from a worker thread.
++    {
++        bool caught = false;
++        try  {
++            UnrelatedExceptionThrower e(QThread::currentThread());
++            e.startBlocking();
++        } catch (const QUnhandledException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // test throwing the exception from the main thread (different code path)
++    {
++        bool caught = false;
++        try  {
++            UnrelatedExceptionThrower e(0);
++            e.startBlocking();
++        } catch (const QUnhandledException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
+ }
+ 
+ #endif
+diff --git a/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp b/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
+index 4968742110..f4c3fb711d 100644
+--- a/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
++++ b/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
+@@ -42,6 +42,7 @@ private slots:
+     void writeBlock_data();
+     void writeBlock();
+     void seek();
++    void invalidSeeks();
+     void seekTest_data();
+     void seekTest();
+     void read_rawdata();
+@@ -286,6 +287,29 @@ void tst_QBuffer::seek()
+     QCOMPARE(buffer.size(), pos);
+ }
+ 
++void tst_QBuffer::invalidSeeks()
++{
++    if constexpr (sizeof(qsizetype) == sizeof(qint64)) {
++        // sizeof(qsizetype) == sizeof(qint64), so +1 would overflow
++        QSKIP("This is a 32-bit-only test.");
++    } else {
++        QBuffer buffer;
++        buffer.open(QIODevice::WriteOnly);
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++        constexpr qint64 MaxQByteArrayCapacity = (std::numeric_limits<qsizetype>::max)();
++        // this should fail fast, not after trying to allocate nearly 2 GiB of data,
++        // potentially crashing in the process:
++        QVERIFY(!buffer.seek(2 * MaxQByteArrayCapacity - 1));
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++        // ditto:
++        QVERIFY(!buffer.seek(MaxQByteArrayCapacity + 1));
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++    }
++}
++
+ void tst_QBuffer::seekTest_data()
+ {
+     writeBlock_data();
+diff --git a/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp b/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
+index da5327594c..4a04e0f7c6 100644
+--- a/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
++++ b/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
+@@ -561,7 +561,8 @@ protected:
+     qint64 readData(char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf->size() - offset));
+-        memcpy(data, buf->constData() + offset, maxSize);
++        if (maxSize > 0)
++            memcpy(data, buf->constData() + offset, maxSize);
+         offset += maxSize;
+         return maxSize;
+     }
+@@ -604,13 +605,15 @@ protected:
+     qint64 readData(char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf.size() - pos()));
+-        memcpy(data, buf.constData() + pos(), maxSize);
++        if (maxSize > 0)
++            memcpy(data, buf.constData() + pos(), maxSize);
+         return maxSize;
+     }
+     qint64 writeData(const char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf.size() - pos()));
+-        memcpy(buf.data() + pos(), data, maxSize);
++        if (maxSize > 0)
++            memcpy(buf.data() + pos(), data, maxSize);
+         return maxSize;
+     }
+ 
+diff --git a/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+index db60bead64..f345a44414 100644
+--- a/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
++++ b/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+@@ -1,7 +1,8 @@
+ /****************************************************************************
+ **
+ ** Copyright (C) 2021 The Qt Company Ltd.
+-** Copyright (C) 2020 Intel Corporation.
++** Copyright (C) 2020 The Qt Company Ltd.
++** Copyright (C) 2022 Intel Corporation.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the test suite of the Qt Toolkit.
+@@ -150,6 +151,8 @@ private slots:
+     void startStopStartStopBuffers();
+     void processEventsInAReadyReadSlot_data();
+     void processEventsInAReadyReadSlot();
++    void startFromCurrentWorkingDir_data();
++    void startFromCurrentWorkingDir();
+ 
+     // keep these at the end, since they use lots of processes and sometimes
+     // caused obscure failures to occur in tests that followed them (esp. on the Mac)
+@@ -2731,5 +2734,94 @@ void tst_QProcess::finishProcessBeforeReadingDone_deprecated()
+ 
+ #endif
+ 
++enum class ChdirMode {
++    None = 0,
++    InParent,
++    InChild
++};
++Q_DECLARE_METATYPE(ChdirMode)
++
++void tst_QProcess::startFromCurrentWorkingDir_data()
++{
++    qRegisterMetaType<ChdirMode>();
++    QTest::addColumn<QString>("programPrefix");
++    QTest::addColumn<ChdirMode>("chdirMode");
++    QTest::addColumn<bool>("success");
++
++    constexpr bool IsWindows = true
++#ifdef Q_OS_UNIX
++            && false
++#endif
++            ;
++
++    // baseline: trying to execute the directory, this can't possibly succeed!
++    QTest::newRow("plain-same-cwd") << QString() << ChdirMode::None << false;
++
++    // cross-platform behavior: neither OS searches the setWorkingDirectory()
++    // dir without "./"
++    QTest::newRow("plain-child-chdir") << QString() << ChdirMode::InChild << false;
++
++    // cross-platform behavior: both OSes search the parent's CWD with "./"
++    QTest::newRow("prefixed-parent-chdir") << "./" << ChdirMode::InParent << true;
++
++    // opposite behaviors: Windows searches the parent's CWD and Unix searches
++    // the child's with "./"
++    QTest::newRow("prefixed-child-chdir") << "./" << ChdirMode::InChild << !IsWindows;
++
++    // Windows searches the parent's CWD without "./"
++    QTest::newRow("plain-parent-chdir") << QString() << ChdirMode::InParent << IsWindows;
++}
++
++void tst_QProcess::startFromCurrentWorkingDir()
++{
++    QFETCH(QString, programPrefix);
++    QFETCH(ChdirMode, chdirMode);
++    QFETCH(bool, success);
++
++    QProcess process;
++    qRegisterMetaType<QProcess::ProcessError>();
++    QSignalSpy errorSpy(&process, &QProcess::errorOccurred);
++    QVERIFY(errorSpy.isValid());
++
++    // both the dir name and the executable name
++    const QString target = QStringLiteral("testProcessNormal");
++    process.setProgram(programPrefix + target);
++
++#ifdef Q_OS_UNIX
++    // Reset PATH, to be sure it doesn't contain . or the empty path.
++    // We can't do this on Windows because DLLs are searched in PATH
++    // and Windows always searches "." anyway.
++    auto restoreEnv = qScopeGuard([old = qgetenv("PATH")] {
++        qputenv("PATH", old);
++    });
++    qputenv("PATH", "/");
++#endif
++
++    switch (chdirMode) {
++    case ChdirMode::InParent: {
++        auto restoreCwd = qScopeGuard([old = QDir::currentPath()] {
++            QDir::setCurrent(old);
++        });
++        QVERIFY(QDir::setCurrent(target));
++        process.start();
++        break;
++    }
++    case ChdirMode::InChild:
++        process.setWorkingDirectory(target);
++        Q_FALLTHROUGH();
++    case ChdirMode::None:
++        process.start();
++        break;
++    }
++
++    QCOMPARE(process.waitForStarted(), success);
++    QCOMPARE(errorSpy.count(), int(!success));
++    if (success) {
++        QVERIFY(process.waitForFinished());
++    } else {
++        QCOMPARE(process.error(), QProcess::FailedToStart);
++    }
++}
++
+ QTEST_MAIN(tst_QProcess)
+ #include "tst_qprocess.moc"
+diff --git a/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp b/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp
+index e1ea7a4552..90972caa57 100644
+--- a/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp
++++ b/qtbase/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"
+diff --git a/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+index 9bd66c0835..ed4a0bae5d 100644
+--- a/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
++++ b/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+@@ -158,6 +158,7 @@ private slots:
+     void nullReceiver();
+     void functorReferencesConnection();
+     void disconnectDisconnects();
++    void declarativeData();
+ };
+ 
+ struct QObjectCreatedOnShutdown
+@@ -7679,5 +7680,81 @@ void tst_QObject::disconnectDisconnects()
+ Q_STATIC_ASSERT(QtPrivate::HasQ_OBJECT_Macro<tst_QObject>::Value);
+ Q_STATIC_ASSERT(!QtPrivate::HasQ_OBJECT_Macro<SiblingDeleter>::Value);
+ 
++#ifdef QT_BUILD_INTERNAL
++/*
++    Since QObjectPrivate stores the declarativeData pointer in a union with the pointer
++    to the currently destroyed child, calls to the QtDeclarative handlers need to be
++    correctly guarded. QTBUG-105286
++*/
++namespace QtDeclarative {
++static QAbstractDeclarativeData *theData;
++
++static void destroyed(QAbstractDeclarativeData *data, QObject *)
++{
++    QCOMPARE(data, theData);
++}
++static void signalEmitted(QAbstractDeclarativeData *data, QObject *, int, void **)
++{
++    QCOMPARE(data, theData);
++}
++// we can't use QCOMPARE in the next two functions, as they don't return void
++static int receivers(QAbstractDeclarativeData *data, const QObject *, int)
++{
++    QTest::qCompare(data, theData, "data", "theData", __FILE__, __LINE__);
++    return 0;
++}
++static bool isSignalConnected(QAbstractDeclarativeData *data, const QObject *, int)
++{
++    QTest::qCompare(data, theData, "data", "theData", __FILE__, __LINE__);
++    return true;
++}
++
++class Object : public QObject
++{
++    Q_OBJECT
++public:
++    using QObject::QObject;
++    ~Object()
++    {
++        if (Object *p = static_cast<Object *>(parent()))
++            p->emitSignal();
++    }
++
++    void emitSignal()
++    {
++        emit theSignal();
++    }
++
++signals:
++    void theSignal();
++};
++
++}
++#endif
++
++void tst_QObject::declarativeData()
++{
++#ifdef QT_BUILD_INTERNAL
++    QScopedValueRollback destroyed(QAbstractDeclarativeData::destroyed,
++                                   QtDeclarative::destroyed);
++    QScopedValueRollback signalEmitted(QAbstractDeclarativeData::signalEmitted,
++                                       QtDeclarative::signalEmitted);
++    QScopedValueRollback receivers(QAbstractDeclarativeData::receivers,
++                                   QtDeclarative::receivers);
++    QScopedValueRollback isSignalConnected(QAbstractDeclarativeData::isSignalConnected,
++                                           QtDeclarative::isSignalConnected);
++
++    QtDeclarative::Object p;
++    QObjectPrivate *priv = QObjectPrivate::get(&p);
++    priv->declarativeData = QtDeclarative::theData = new QAbstractDeclarativeData;
++
++    connect(&p, &QtDeclarative::Object::theSignal, &p, []{
++    });
++
++    QtDeclarative::Object *child = new QtDeclarative::Object;
++    child->setParent(&p);
++#endif
++}
++
+ QTEST_MAIN(tst_QObject)
+ #include "tst_qobject.moc"
+diff --git a/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp b/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
+index 0ea422ecbc..1a3256534b 100644
+--- a/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
++++ b/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
+@@ -70,15 +70,15 @@ static inline QString testSuiteWarning()
+ 
+     QString result;
+     QTextStream str(&result);
+-    str << "\nCannot find the shared-mime-info test suite\nstarting from: "
++    str << "\nCannot find the shared-mime-info test suite\nin the parent of: "
+         << QDir::toNativeSeparators(QDir::currentPath()) << "\n"
+            "cd " << QDir::toNativeSeparators(QStringLiteral("tests/auto/corelib/mimetypes/qmimedatabase")) << "\n"
+-           "wget http://cgit.freedesktop.org/xdg/shared-mime-info/snapshot/Release-1-10.zip\n"
+-           "unzip Release-1-10.zip\n";
++           "wget https://gitlab.freedesktop.org/xdg/shared-mime-info/-/archive/2.1/shared-mime-info-2.1.zip\n"
++           "unzip shared-mime-info-2.1.zip\n";
+ #ifdef Q_OS_WIN
+-    str << "mkdir testfiles\nxcopy /s Release-1-10 s-m-i\n";
++    str << "mkdir testfiles\nxcopy /s shared-mime-info-2.1 s-m-i\n";
+ #else
+-    str << "ln -s Release-1-10 s-m-i\n";
++    str << "ln -s shared-mime-info-2.1 s-m-i\n";
+ #endif
+     return result;
+ }
+@@ -154,7 +154,7 @@ void tst_QMimeDatabase::initTestCase()
+     QVERIFY2(copyResourceFile(xmlFileName, xmlTargetFileName, &errorMessage), qPrintable(errorMessage));
+ #endif
+ 
+-    m_testSuite = QFINDTESTDATA("s-m-i/tests");
++    m_testSuite = QFINDTESTDATA("s-m-i/tests/mime-detection");
+     if (m_testSuite.isEmpty())
+         qWarning("%s", qPrintable(testSuiteWarning()));
+ 
+@@ -611,7 +611,7 @@ void tst_QMimeDatabase::allMimeTypes()
+     QVERIFY(!lst.isEmpty());
+ 
+     // Hardcoding this is the only way to check both providers find the same number of mimetypes.
+-    QCOMPARE(lst.count(), 779);
++    QCOMPARE(lst.count(), 811);
+ 
+     foreach (const QMimeType &mime, lst) {
+         const QString name = mime.name();
+@@ -631,10 +631,9 @@ void tst_QMimeDatabase::suffixes_data()
+ 
+     QTest::newRow("mimetype with a single pattern") << "application/pdf" << "*.pdf" << "pdf";
+     QTest::newRow("mimetype with multiple patterns") << "application/x-kpresenter" << "*.kpr;*.kpt" << "kpr";
+-    QTest::newRow("jpeg") << "image/jpeg" << "*.jpe;*.jpg;*.jpeg" << "jpeg";
+-    //if (KMimeType::sharedMimeInfoVersion() > KDE_MAKE_VERSION(0, 60, 0)) {
+-        QTest::newRow("mimetype with many patterns") << "application/vnd.wordperfect" << "*.wp;*.wp4;*.wp5;*.wp6;*.wpd;*.wpp" << "wp";
+-    //}
++    // The preferred suffix for image/jpeg is *.jpg, as per https://bugs.kde.org/show_bug.cgi?id=176737
++    QTest::newRow("jpeg") << "image/jpeg" << "*.jpe;*.jpg;*.jpeg" << "jpg";
++    QTest::newRow("mimetype with many patterns") << "application/vnd.wordperfect" << "*.wp;*.wp4;*.wp5;*.wp6;*.wpd;*.wpp" << "wp";
+     QTest::newRow("oasis text mimetype") << "application/vnd.oasis.opendocument.text" << "*.odt" << "odt";
+     QTest::newRow("oasis presentation mimetype") << "application/vnd.oasis.opendocument.presentation" << "*.odp" << "odp";
+     QTest::newRow("mimetype with multiple patterns") << "text/plain" << "*.asc;*.txt;*,v" << "txt";
+diff --git a/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp b/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
+index 3e58dd03cc..c8f82ef5d5 100644
+--- a/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
++++ b/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
+@@ -176,6 +176,8 @@ private Q_SLOTS:
+     void fromToVariantConversions_data();
+     void fromToVariantConversions();
+ 
++    void noLeakOnNameClash();
++
+ private:
+     QString testDataDir;
+ };
+@@ -3685,5 +3687,23 @@ void tst_QtJson::fromToVariantConversions()
+     }
+ }
+ 
++void tst_QtJson::noLeakOnNameClash()
++{
++    QJsonDocument doc = QJsonDocument::fromJson("{\"\":{\"\":0},\"\":0}");
++    QVERIFY(!doc.isNull());
++    const QJsonObject obj = doc.object();
++
++    // Removed the duplicate key.
++    QCOMPARE(obj.length(), 1);
++
++    // Retained the last of the duplicates.
++    const QJsonValue val = obj.begin().value();
++    QVERIFY(val.isDouble());
++    QCOMPARE(val.toDouble(), 0.0);
++
++    // It should not leak.
++    // In particular it should not forget to deref the container for the inner object.
++}
++
+ QTEST_MAIN(tst_QtJson)
+ #include "tst_qtjson.moc"
+diff --git a/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp b/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
+index a59b58d57f..241c3e84ac 100644
+--- a/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
++++ b/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
+@@ -63,6 +63,7 @@ private slots:
+     void isValidId_data();
+     void isValidId();
+     void malformed();
++    void serialize();
+     // Backend tests
+     void utcTest();
+     void icuTest();
+@@ -947,6 +948,33 @@ void tst_QTimeZone::malformed()
+         barf.offsetFromUtc(now);
+ }
+ 
++void tst_QTimeZone::serialize()
++{
++    int parts = 0;
++#ifndef QT_NO_DEBUG_STREAM
++    qDebug() << QTimeZone(); // to verify no crash
++    parts++;
++#endif
++#ifndef QT_NO_DATASTREAM
++    QByteArray blob;
++    {
++        QDataStream stream(&blob, QIODevice::WriteOnly);
++        stream << QTimeZone("Europe/Oslo") << QTimeZone(420) << QTimeZone() << qint64(-1);
++    }
++    QDataStream stream(&blob, QIODevice::ReadOnly);
++    QTimeZone invalid, offset, oslo;
++    qint64 minusone;
++    stream >> oslo >> offset >> invalid >> minusone;
++    QCOMPARE(oslo, QTimeZone("Europe/Oslo"));
++    QCOMPARE(offset, QTimeZone(420));
++    QVERIFY(!invalid.isValid());
++    QCOMPARE(minusone, qint64(-1));
++    parts++;
++#endif
++    if (!parts)
++        QSKIP("No serialization enabled");
++}
++
+ void tst_QTimeZone::utcTest()
+ {
+ #ifdef QT_BUILD_INTERNAL
+diff --git a/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp b/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
+index 05480c6dd2..70f4c75756 100644
+--- a/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
++++ b/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
+@@ -324,6 +324,13 @@ void tst_QDBusInterface::notValid()
+ 
+     QVERIFY(!interface.isValid());
+     QVERIFY(!QMetaObject::invokeMethod(&interface, "ListNames", Qt::DirectConnection));
++
++    // With a connection, but empty/null service and path specified
++    QDBusConnection con = QDBusConnection::sessionBus();
++    QVERIFY(con.isConnected());
++    QDBusInterface iface({}, {}, {}, con);
++    QVERIFY(!iface.isValid());
++    QVERIFY(!QMetaObject::invokeMethod(&interface, "ListNames", Qt::DirectConnection));
+ }
+ 
+ void tst_QDBusInterface::notValidDerived()
+diff --git a/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp b/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
+index 874468c954..04ceb4ab65 100644
+--- a/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
++++ b/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
+@@ -507,6 +507,10 @@ void tst_QKeySequence::toStringFromKeycode_data()
+     QTest::newRow("Ctrl+Alt+Num+Del") << QKeySequence(Qt::ControlModifier | Qt::AltModifier | Qt::KeypadModifier | Qt::Key_Delete) << "Ctrl+Alt+Num+Del";
+     QTest::newRow("Ctrl+Ins") << QKeySequence(Qt::ControlModifier | Qt::Key_Insert) << "Ctrl+Ins";
+     QTest::newRow("Ctrl+Num+Ins(1)") << QKeySequence(Qt::Key_Insert | Qt::KeypadModifier | Qt::ControlModifier) << "Ctrl+Num+Ins";
++    QTest::newRow("Ctrl") << QKeySequence(Qt::Key_Control) << "Control";
++    QTest::newRow("Alt") << QKeySequence(Qt::Key_Alt) << "Alt";
++    QTest::newRow("Shift") << QKeySequence(Qt::Key_Shift) << "Shift";
++    QTest::newRow("Meta") << QKeySequence(Qt::Key_Meta) << "Meta";
+ }
+ 
+ void tst_QKeySequence::toStringFromKeycode()
+diff --git a/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp b/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+index 15e0ecadaa..b4eca74283 100644
+--- a/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
++++ b/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+@@ -81,6 +81,8 @@ private slots:
+     void registerOpenTypePreferredNamesSystem();
+     void registerOpenTypePreferredNamesApplication();
+ 
++    void stretchRespected();
++
+ private:
+     QString m_ledFont;
+     QString m_testFont;
+@@ -355,6 +357,28 @@ static QString testString()
+     return QStringLiteral("foo bar");
+ }
+ 
++void tst_QFontDatabase::stretchRespected()
++{
++    int italicId = QFontDatabase::addApplicationFont(m_testFontItalic);
++    QVERIFY(italicId != -1);
++
++    QVERIFY(!QFontDatabase::applicationFontFamilies(italicId).isEmpty());
++
++    QString italicFontName = QFontDatabase::applicationFontFamilies(italicId).first();
++
++    QFont italicFont = QFontDatabase().font(italicFontName,
++                                            QString::fromLatin1("Italic"), 14);
++    QVERIFY(italicFont.italic());
++
++    QFont italicStretchedFont = italicFont;
++    italicStretchedFont.setStretch( 400 );
++
++    QVERIFY(QFontMetricsF(italicFont).horizontalAdvance(QStringLiteral("foobar")) <
++            QFontMetricsF(italicStretchedFont).horizontalAdvance(QStringLiteral("foobar")));
++
++    QFontDatabase::removeApplicationFont(italicId);
++}
++
+ void tst_QFontDatabase::condensedFontWidthNoFontMerging()
+ {
+     int regularFontId = QFontDatabase::addApplicationFont(m_testFont);
+diff --git a/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+index 3d4a094c43..b423e11a99 100644
+--- a/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
++++ b/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+@@ -281,6 +281,7 @@ private Q_SLOTS:
+     void ioGetFromFileSpecial();
+     void ioGetFromFile_data();
+     void ioGetFromFile();
++    void ioGetFromFileUrl();
+     void ioGetFromFtp_data();
+     void ioGetFromFtp();
+     void ioGetFromFtpWithReuse();
+@@ -3300,6 +3301,18 @@ void tst_QNetworkReply::ioGetFromFile()
+     QCOMPARE(reader.data, data);
+ }
+ 
++void tst_QNetworkReply::ioGetFromFileUrl()
++{
++    // This immediately fails on non-windows platforms:
++    QNetworkRequest request(QUrl("file://unc-server/some/path"));
++    QNetworkReplyPtr reply(manager.get(request));
++    QSignalSpy finishedSpy(reply.get(), &QNetworkReply::finished);
++    // QTBUG-105618: This would, on non-Windows platforms, never happen because the signal
++    // was emitted before the constructor finished, leaving no chance at all to connect to the
++    // signal
++    QVERIFY(finishedSpy.wait());
++}
++
+ void tst_QNetworkReply::ioGetFromFtp_data()
+ {
+     QTest::addColumn<QString>("fileName");
+diff --git a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
+index 069fa6b341..4cc4d9a5ea 100644
+--- a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
++++ b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
+@@ -1,75 +1,34 @@
+-Certificate:
+-    Data:
+-        Version: 3 (0x2)
+-        Serial Number: 0 (0x0)
+-        Signature Algorithm: sha1WithRSAEncryption
+-        Issuer: C=NO, ST=Oslo, L=Nydalen, O=Nokia Corporation and/or its subsidiary(-ies), OU=Development, CN=fluke.troll.no/emailAddress=ahanssen@trolltech.com
+-        Validity
+-            Not Before: Dec  4 01:10:32 2007 GMT
+-            Not After : Apr 21 01:10:32 2035 GMT
+-        Subject: C=NO, ST=Oslo, O=Nokia Corporation and/or its subsidiary(-ies), OU=Development, CN=fluke.troll.no
+-        Subject Public Key Info:
+-            Public Key Algorithm: rsaEncryption
+-            RSA Public Key: (1024 bit)
+-                Modulus (1024 bit):
+-                    00:a7:c8:a0:4a:c4:19:05:1b:66:ba:32:e2:d2:f1:
+-                    1c:6f:17:82:e4:39:2e:01:51:90:db:04:34:32:11:
+-                    21:c2:0d:6f:59:d8:53:90:54:3f:83:8f:a9:d3:b3:
+-                    d5:ee:1a:9b:80:ae:c3:25:c9:5e:a5:af:4b:60:05:
+-                    aa:a0:d1:91:01:1f:ca:04:83:e3:58:1c:99:32:45:
+-                    84:70:72:58:03:98:4a:63:8b:41:f5:08:49:d2:91:
+-                    02:60:6b:e4:64:fe:dd:a0:aa:74:08:e9:34:4c:91:
+-                    5f:12:3d:37:4d:54:2c:ad:7f:5b:98:60:36:02:8c:
+-                    3b:f6:45:f3:27:6a:9b:94:9d
+-                Exponent: 65537 (0x10001)
+-        X509v3 extensions:
+-            X509v3 Basic Constraints: 
+-                CA:FALSE
+-            Netscape Comment: 
+-                OpenSSL Generated Certificate
+-            X509v3 Subject Key Identifier: 
+-                21:85:04:3D:23:01:66:E5:F7:9F:1A:84:24:8A:AF:0A:79:F4:E5:AC
+-            X509v3 Authority Key Identifier: 
+-                DirName:/C=NO/ST=Oslo/L=Nydalen/O=Nokia Corporation and/or its subsidiary(-ies)/OU=Development/CN=fluke.troll.no/emailAddress=ahanssen@trolltech.com
+-                serial:8E:A8:B4:E8:91:B7:54:2E
+-
+-    Signature Algorithm: sha1WithRSAEncryption
+-        6d:57:5f:d1:05:43:f0:62:05:ec:2a:71:a5:dc:19:08:f2:c4:
+-        a6:bd:bb:25:d9:ca:89:01:0e:e4:cf:1f:c1:8c:c8:24:18:35:
+-        53:59:7b:c0:43:b4:32:e6:98:b2:a6:ef:15:05:0b:48:5f:e1:
+-        a0:0c:97:a9:a1:77:d8:35:18:30:bc:a9:8f:d3:b7:54:c7:f1:
+-        a9:9e:5d:e6:19:bf:f6:3c:5b:2b:d8:e4:3e:62:18:88:8b:d3:
+-        24:e1:40:9b:0c:e6:29:16:62:ab:ea:05:24:70:36:aa:55:93:
+-        ef:02:81:1b:23:10:a2:04:eb:56:95:75:fc:f8:94:b1:5d:42:
+-        c5:3f:36:44:85:5d:3a:2e:90:46:8a:a2:b9:6f:87:ae:0c:15:
+-        40:19:31:90:fc:3b:25:bb:ae:f1:66:13:0d:85:90:d9:49:34:
+-        8f:f2:5d:f9:7a:db:4d:5d:27:f6:76:9d:35:8c:06:a6:4c:a3:
+-        b1:b2:b6:6f:1d:d7:a3:00:fd:72:eb:9e:ea:44:a1:af:21:34:
+-        7d:c7:42:e2:49:91:19:8b:c0:ad:ba:82:80:a8:71:70:f4:35:
+-        31:91:63:84:20:95:e9:60:af:64:8b:cc:ff:3d:8a:76:74:3d:
+-        c8:55:6d:e4:8e:c3:2b:1c:e8:42:18:ae:9f:e6:6b:9c:34:06:
+-        ec:6a:f2:c3
+ -----BEGIN CERTIFICATE-----
+-MIIEEzCCAvugAwIBAgIBADANBgkqhkiG9w0BAQUFADCBnDELMAkGA1UEBhMCTk8x
+-DTALBgNVBAgTBE9zbG8xEDAOBgNVBAcTB055ZGFsZW4xFjAUBgNVBAoTDVRyb2xs
+-dGVjaCBBU0ExFDASBgNVBAsTC0RldmVsb3BtZW50MRcwFQYDVQQDEw5mbHVrZS50
+-cm9sbC5ubzElMCMGCSqGSIb3DQEJARYWYWhhbnNzZW5AdHJvbGx0ZWNoLmNvbTAe
+-Fw0wNzEyMDQwMTEwMzJaFw0zNTA0MjEwMTEwMzJaMGMxCzAJBgNVBAYTAk5PMQ0w
+-CwYDVQQIEwRPc2xvMRYwFAYDVQQKEw1Ucm9sbHRlY2ggQVNBMRQwEgYDVQQLEwtE
+-ZXZlbG9wbWVudDEXMBUGA1UEAxMOZmx1a2UudHJvbGwubm8wgZ8wDQYJKoZIhvcN
+-AQEBBQADgY0AMIGJAoGBAKfIoErEGQUbZroy4tLxHG8XguQ5LgFRkNsENDIRIcIN
+-b1nYU5BUP4OPqdOz1e4am4CuwyXJXqWvS2AFqqDRkQEfygSD41gcmTJFhHByWAOY
+-SmOLQfUISdKRAmBr5GT+3aCqdAjpNEyRXxI9N01ULK1/W5hgNgKMO/ZF8ydqm5Sd
+-AgMBAAGjggEaMIIBFjAJBgNVHRMEAjAAMCwGCWCGSAGG+EIBDQQfFh1PcGVuU1NM
+-IEdlbmVyYXRlZCBDZXJ0aWZpY2F0ZTAdBgNVHQ4EFgQUIYUEPSMBZuX3nxqEJIqv
+-Cnn05awwgbsGA1UdIwSBszCBsKGBoqSBnzCBnDELMAkGA1UEBhMCTk8xDTALBgNV
+-BAgTBE9zbG8xEDAOBgNVBAcTB055ZGFsZW4xFjAUBgNVBAoTDVRyb2xsdGVjaCBB
+-U0ExFDASBgNVBAsTC0RldmVsb3BtZW50MRcwFQYDVQQDEw5mbHVrZS50cm9sbC5u
+-bzElMCMGCSqGSIb3DQEJARYWYWhhbnNzZW5AdHJvbGx0ZWNoLmNvbYIJAI6otOiR
+-t1QuMA0GCSqGSIb3DQEBBQUAA4IBAQBtV1/RBUPwYgXsKnGl3BkI8sSmvbsl2cqJ
+-AQ7kzx/BjMgkGDVTWXvAQ7Qy5piypu8VBQtIX+GgDJepoXfYNRgwvKmP07dUx/Gp
+-nl3mGb/2PFsr2OQ+YhiIi9Mk4UCbDOYpFmKr6gUkcDaqVZPvAoEbIxCiBOtWlXX8
+-+JSxXULFPzZEhV06LpBGiqK5b4euDBVAGTGQ/Dslu67xZhMNhZDZSTSP8l35ettN
+-XSf2dp01jAamTKOxsrZvHdejAP1y657qRKGvITR9x0LiSZEZi8CtuoKAqHFw9DUx
+-kWOEIJXpYK9ki8z/PYp2dD3IVW3kjsMrHOhCGK6f5mucNAbsavLD
++MIIF6zCCA9OgAwIBAgIUfo9amJtJGWqWE6f+SkAO85zkGr4wDQYJKoZIhvcNAQEL
++BQAwgYMxCzAJBgNVBAYTAk5PMQ0wCwYDVQQIDARPc2xvMQ0wCwYDVQQHDARPc2xv
++MRcwFQYDVQQKDA5UaGUgUXQgQ29tcGFueTEMMAoGA1UECwwDUiZEMRIwEAYDVQQD
++DAlIMiBUZXN0ZXIxGzAZBgkqhkiG9w0BCQEWDG1pbmltaUBxdC5pbzAgFw0yMDEw
++MjYxMjAxMzFaGA8yMTIwMTAwMjEyMDEzMVowgYMxCzAJBgNVBAYTAk5PMQ0wCwYD
++VQQIDARPc2xvMQ0wCwYDVQQHDARPc2xvMRcwFQYDVQQKDA5UaGUgUXQgQ29tcGFu
++eTEMMAoGA1UECwwDUiZEMRIwEAYDVQQDDAlIMiBUZXN0ZXIxGzAZBgkqhkiG9w0B
++CQEWDG1pbmltaUBxdC5pbzCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIB
++AOiUp5+E4blouKH7q+rVNR8NoYX2XkBW+q+rpy1zu5ssRSzbqxAjDx9dkht7Qlnf
++VlDT00JvpOWdeuPon5915edQRsY4Unl6mKH29ra3OtUa1/yCJXsGVJTKCj7k4Bxb
++5mZzb/fTlZntMLdTIBMfUbw62FKir1WjKIcJ9fCoG8JaGeKVO4Rh5p0ezd4UUUId
++r1BXl5Nqdqy2vTMsEDnjOsD3egkv8I2SKN4O6n/C3wWYpMOWYZkGoZiKz7rJs/i/
++ez7bsV7JlwdzTlhpJzkcOSVFBP6JlEOxTNNxZ1wtKy7PtZGmsSSATq2e6+bw38Ae
++Op0XnzzqcGjtDDofBmT7OFzZWjS9VZS6+DOOe2QHWle1nCHcHyH4ku6IRlsr9xkR
++NAIlOfnvHHxqJUenoeaZ4oQDjCBKS1KXygJO/tL7BLTQVn/xK1EmPvKNnjzWk4tR
++PnibUhhs5635qpOU/YPqFBh1JjVruZbsWcDAhRcew0uxONXOa9E+4lttQ9ySYa1A
++LvWqJuAX7gu2BsBMLyqfm811YnA7CIFMyO+HlqmkLFfv5L/xIRAXR7l26YGO0VwX
++CGjMfz4NVPMMke4nB7qa9NkpXQBQKMms3Qzd5JW0Hy9Ruj5O8GPcFZmV0twjd1uJ
++PD/cAjkWLaXjdNsJ16QWc2nghQRS6HYqKRX6j+CXOxupAgMBAAGjUzBRMB0GA1Ud
++DgQWBBRSCOU58j9NJZkMamt623qyCrhN3TAfBgNVHSMEGDAWgBRSCOU58j9NJZkM
++amt623qyCrhN3TAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4ICAQCq
++q4jxsWeNDv5Nq14hJtF9HB+ZL64zcZtRjJP1YgNs0QppKICmjPOL2nIMGmI/jKrs
++0eGAL/9XXNVHPxm1OPOncvimMMmU6emZfpMdEtTfKP43+Pg9HgKRjLoQp406vGeQ
++8ki/mbBhrItVPgEm3tu2AFA02XTYi+YxCI9kRZLGkM3FbgtOuTLPl0Z9y+kiPc9F
++uCSC03anBEqv+vDSI8+wODymQ/IJ3Jyz1lxIRDfp4qAekmy0jU2c91VOHHEmOmqq
++kqygGFRdwbe99m9yP63r6q0b5K3X2UnJ6bns0hmTwThYwpVPXLU8jdaTddbMukN2
++/Ef96Tsw8nWOEOPMySHOTIPgwyZRp26b0kA9EmhLwOP401SxXVQCmSRmtwNagmtg
++jJKmZoYBN+//D45ibK8z6Q0oOm9P+Whf/uUXehcRxBxyV3xz7k0wKGQbHj/ddwcy
++IUoIN4lrAlib+lK170kTKN352PDmrpo2gmIzPEsfurKAIMSelDl6H+kih16BtZ8y
++Nz6fh9Soqrg3OSAware8pxV7k51crBMoPLN78KoRV8MFCK4K7Fddq4rRISq6hiXq
++r1nsjoEPuKM9huprmZVZe9t5YcDa2I+wb3IiE3uwpZbAdaLDyQ5n6F/qpsiIkZXn
++gtcF7oqpG5oYrwCcZ53y/ezUgUg7PlSz2XwAGvQtgg==
+ -----END CERTIFICATE-----
+diff --git a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
+index 9d1664d609..337ce541a6 100644
+--- a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
++++ b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
+@@ -1,15 +1,52 @@
+------BEGIN RSA PRIVATE KEY-----
+-MIICXAIBAAKBgQCnyKBKxBkFG2a6MuLS8RxvF4LkOS4BUZDbBDQyESHCDW9Z2FOQ
+-VD+Dj6nTs9XuGpuArsMlyV6lr0tgBaqg0ZEBH8oEg+NYHJkyRYRwclgDmEpji0H1
+-CEnSkQJga+Rk/t2gqnQI6TRMkV8SPTdNVCytf1uYYDYCjDv2RfMnapuUnQIDAQAB
+-AoGANFzLkanTeSGNFM0uttBipFT9F4a00dqHz6JnO7zXAT26I5r8sU1pqQBb6uLz
+-/+Qz5Zwk8RUAQcsMRgJetuPQUb0JZjF6Duv24hNazqXBCu7AZzUenjafwmKC/8ri
+-KpX3fTwqzfzi//FKGgbXQ80yykSSliDL3kn/drATxsLCgQECQQDXhEFWLJ0vVZ1s
+-1Ekf+3NITE+DR16X+LQ4W6vyEHAjTbaNWtcTKdAWLA2l6N4WAAPYSi6awm+zMxx4
+-VomVTsjdAkEAx0z+e7natLeFcrrq8pbU+wa6SAP1VfhQWKitxL1e7u/QO90NCpxE
+-oQYKzMkmmpOOFjQwEMAy1dvFMbm4LHlewQJAC/ksDBaUcQHHqjktCtrUb8rVjAyW
+-A8lscckeB2fEYyG5J6dJVaY4ClNOOs5yMDS2Afk1F6H/xKvtQ/5CzInA/QJATDub
+-K+BPU8jO9q+gpuIi3VIZdupssVGmCgObVCHLakG4uO04y9IyPhV9lA9tALtoIf4c
+-VIvv5fWGXBrZ48kZAQJBAJmVCdzQxd9LZI5vxijUCj5EI4e+x5DRqVUvyP8KCZrC
+-AiNyoDP85T+hBZaSXK3aYGpVwelyj3bvo1GrTNwNWLw=
+------END RSA PRIVATE KEY-----
++-----BEGIN PRIVATE KEY-----
++MIIJQgIBADANBgkqhkiG9w0BAQEFAASCCSwwggkoAgEAAoICAQDolKefhOG5aLih
+++6vq1TUfDaGF9l5AVvqvq6ctc7ubLEUs26sQIw8fXZIbe0JZ31ZQ09NCb6TlnXrj
++6J+fdeXnUEbGOFJ5epih9va2tzrVGtf8giV7BlSUygo+5OAcW+Zmc2/305WZ7TC3
++UyATH1G8OthSoq9VoyiHCfXwqBvCWhnilTuEYeadHs3eFFFCHa9QV5eTanastr0z
++LBA54zrA93oJL/CNkijeDup/wt8FmKTDlmGZBqGYis+6ybP4v3s+27FeyZcHc05Y
++aSc5HDklRQT+iZRDsUzTcWdcLSsuz7WRprEkgE6tnuvm8N/AHjqdF5886nBo7Qw6
++HwZk+zhc2Vo0vVWUuvgzjntkB1pXtZwh3B8h+JLuiEZbK/cZETQCJTn57xx8aiVH
++p6HmmeKEA4wgSktSl8oCTv7S+wS00FZ/8StRJj7yjZ481pOLUT54m1IYbOet+aqT
++lP2D6hQYdSY1a7mW7FnAwIUXHsNLsTjVzmvRPuJbbUPckmGtQC71qibgF+4LtgbA
++TC8qn5vNdWJwOwiBTMjvh5appCxX7+S/8SEQF0e5dumBjtFcFwhozH8+DVTzDJHu
++Jwe6mvTZKV0AUCjJrN0M3eSVtB8vUbo+TvBj3BWZldLcI3dbiTw/3AI5Fi2l43Tb
++CdekFnNp4IUEUuh2KikV+o/glzsbqQIDAQABAoICAFw1q6tr5I48vY7DF+rXsuLn
++5ZUWE1IQ6fzB4lr72nJv/9EEGnMgYzt9PpMUsD6vdCpBgS2C0+6RHArFzJtNA+RM
++iHLIG7K7702veyr/xBx/MwiSlMeMv/XpkFxVI6E6skMGG2s3AMXxKvJTy5CpRx+I
++eQFyLG+Ya1X2lgJes/q+/CpAHkOjCOpcLySQC5NZ74q734V7nSdmn+Zs3tYEh+O/
++eiuwTP/j5b38Te5vVTqDxTciJPmljmXLCwa0N100lWlbcpvw8qbqiTI2Jm3XCbUE
++AzHjW9vmrF3cRS1fXxKFGShw3SRqlkbxjfeWoi8qDPUBS4m8LOr8qG9Wo5Nfon0z
++zLP4bci3zHDvVcaaZrrsUBs/yZbg+Dgka1DmX7ekmeccr2yTdKDFgPupYUyxVbTl
++a9ZLJysjFD7rgBv1ZclHonLp6Vbm+ZoTqvteo4ikAy6L9RtBWJ23XEK34PkP/+c5
++2vWZaOrnjSeBHbFce8cdJSxqWpP+eSCI5I9XbDrYFIsQ/gqKgtzDKy2ihJ2Y8STL
++yO4hyFPFjxc+Gg4/P2PpmT5CY2ty44M0BWs+JGW96CJPrrplf2lmQUQJj5LZY66X
++Z/4C9L7ZYtKZ+bs5SvU46yWugAvQZX22Xm9xLXWyVXRdx3bj+3M3fDnF9di/zdbh
++CgLx7oWPNrXc7FCajnn9AoIBAQD5FMYwRpw9NWT9WDxQwx+cSI4Icbd88ByTW63S
++LzeRwZA0J9/SfwO+aBRupzc9GkGXCiZcGMw3AGsCtig8yFlw8E5KnzN7KlftDMnM
++9NUxxzlR8VwKyLnZfG7sDTl057ZlUujnqhmt/F8F7dIy7FVO1dE/8nngA+FYTCOG
++UZdGjwyBDlDM0JJdUWGY3xslutcpCDN5mzSTKjy9drMvImAshRawxRF6WBpn7vr2
++nC6vciqfx1Mzx1vyk0Jm0ilaydDdLMADjt/iL4Nkr0BEs4k+UzQiKDwp8gu7abQ1
++eBfxd9Iar4htQa2I1Ewl6P01G/q+ZYwgHhJ9RVn4AxQXefILAoIBAQDvCouORdQX
++C8wsyp7MwXlF/3NQeNN5/+B2mhbxrBOf7PmMCXLnkRWcjwJtzypWFqJ0sqai/2+0
++bqbMcjX5maT8stT2shl3zXe/Ejt2e3TBYpc1tyuses8Kb5BMU8hu6tTd3G2CMXpD
++dT6DVemJZCTtwj9aBNIxSizvlgMolJnCpzhPnlfHSI6E+g3m/LTTo3HwbjMSw/Uq
++irgjOpI2wSBB6LZPSgjvfcYPRyWUk16L4A5uSX0cADnovDFLa5/h0wJvN/OoCSQg
++rLCXG5E18EyL5Wc58BCY1ZvxmjG3lQtgPxYu2Jwc36R/y/JKlxW5suER5ZNpbbD4
++uOyTt2VxMQ2bAoIBAQC5+MzRFqdo/AjfL5Y5JrbfVTzXCTDa09xCGd16ZU60QTWN
+++4ed/r+o1sUKqUcRFB2MzEM/2DQBjQpZB/CbEWvWa1XJWXxypXbowveZU+QqOnmN
++uQvj8WLyA3o+PNF9e9QvauwCrHpn8VpxbtPWuaYoKnUFreFZZQxHhPGxRBIS2JOZ
++eDrT8ZaWnkCkh1AZp5smQ71LOprSlmKrg4jd1GjCVMxQR5N5KXbtyv0OTCZ/UFqK
++2aRBsMPyJgkaBChkZPLRcKwc+/wlQRx1fHQb14DNTApMxoXFO7eOwqmOkpAt9iyl
++SBIwoS0UUI5ab88+bBmXNvKcuFdNuQ4nowTJUn9pAoIBADMNkILBXSvS5DeIyuO2
++Sp1tkoZUV+5NfPY3sMDK3KIibaW/+t+EOBZo4L7tKQCb8vRzl21mmsfxfgRaPDbj
++3r3tv9g0b4YLxxBy52pFscj/soXRai17SS7UZwA2QK+XzgDYbDcLNC6mIsTQG4Gx
++dsWk3/zs3KuUSQaehmwrWK+fIUK38c1pLK8v7LoxrLkqxlHwZ04RthHw8KTthH7X
++Pnl1J0LF8CSeOyfWLSuPUfkT0GEzptnNHpEbaHfQM6R6eaGhVJPF6AZme4y6YYgg
++m2ihhSt1n0XVEWpHYWjxFy3mK2mz75unFC4LM+NEY2p2zuUQoCw7NjnY3QYrfCnx
++rRMCggEAXeXsMSLFjjyuoL7iKbAxo52HD/P0fBoy58LyRcwfNVr0lvYan4pYEx+o
++KijIh9K16PqXZXKMA9v003B+ulmF8bJ7SddCZ5NGvnFhUTDe4DdTKgp2RuwQ3Bsc
++3skPIDbhVETyOLCtys34USHrq8U/0DlGY3eLRfxw9GnbKxSBGa/KEu/qQLPNUo50
++7xHZDg7GKeC3kqNJeqKM9rkp0VzIGkEnaD9127LeNDmERDfftxJzFoC/THvUBLfU
++6Sus2ZYwRE8VFvKC30Q45t/c54X3IuhYvAuiCuTmyfE4ruyzyOwKzhUkeeLq1APX
++g0veFbyfzlJ0q8qzD/iffqqIa2ZSmQ==
++-----END PRIVATE KEY-----
+diff --git a/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp b/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
+index 7ba3715e13..752aa122f6 100644
+--- a/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
++++ b/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
+@@ -179,6 +179,7 @@ void tst_QAccessibilityLinux::initTestCase()
+     QVERIFY(!address.isEmpty());
+ 
+     m_window = new AccessibleTestWindow();
++    m_window->setObjectName("mainWindow"_L1);
+     m_window->show();
+ 
+     QVERIFY(QTest::qWaitForWindowExposed(m_window));
+@@ -236,8 +237,11 @@ bool hasState(QDBusInterface *interface, AtspiStateType state)
+ void tst_QAccessibilityLinux::testLabel()
+ {
+     QLabel *l = new QLabel(m_window);
++    l->setObjectName("theObjectName"_L1);
+     l->setText("Hello A11y");
+     m_window->addWidget(l);
++    auto a11yEmpty = new QLabel(m_window);
++    m_window->addWidget(l);
+ 
+     // Application
+     QCOMPARE(getParent(mainWindow), QLatin1String(ATSPI_DBUS_PATH_ROOT));
+@@ -249,6 +253,8 @@ void tst_QAccessibilityLinux::testLabel()
+     QCOMPARE(getChildren(labelInterface).count(), 0);
+     QCOMPARE(labelInterface->call(QDBus::Block, "GetRoleName").arguments().first().toString(), QLatin1String("label"));
+     QCOMPARE(labelInterface->call(QDBus::Block, "GetRole").arguments().first().toUInt(), 29u);
++    QCOMPARE(labelInterface->call(QDBus::Block, "GetAccessibleId").arguments().first().toString(),
++             QLatin1String("mainWindow.theObjectName"));
+     QCOMPARE(getParent(labelInterface), mainWindow->path());
+     QVERIFY(!hasState(labelInterface, ATSPI_STATE_EDITABLE));
+     QVERIFY(hasState(labelInterface, ATSPI_STATE_READ_ONLY));
+@@ -256,7 +262,12 @@ void tst_QAccessibilityLinux::testLabel()
+     l->setText("New text");
+     QCOMPARE(labelInterface->property("Name").toString(), l->text());
+ 
++    auto *a11yEmptyInterface = getInterface(children.at(1), "org.a11y.atspi.Accessible");
++    QCOMPARE(a11yEmptyInterface->call(QDBus::Block, "GetAccessibleId").arguments().first().toString(),
++             QLatin1String("mainWindow.QLabel"));
++
+     m_window->clearChildren();
++    delete a11yEmptyInterface;
+     delete labelInterface;
+ }
+ 
+diff --git a/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+index 76df61c892..6d6d65b791 100644
+--- a/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
++++ b/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2022 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the test suite of the Qt Toolkit.
+@@ -68,6 +68,8 @@ private slots:
+     void query_exec();
+     void execErrorRecovery_data() { generic_data(); }
+     void execErrorRecovery();
++    void prematureExec_data() { generic_data(); }
++    void prematureExec();
+     void first_data() { generic_data(); }
+     void first();
+     void next_data() { generic_data(); }
+@@ -2770,6 +2772,35 @@ void tst_QSqlQuery::execErrorRecovery()
+     QVERIFY_SQL( q, exec() );
+ }
+ 
++void tst_QSqlQuery::prematureExec()
++{
++    QFETCH(QString, dbName);
++    // We only want the engine name, for addDatabase():
++    int cut = dbName.indexOf(QChar('@'));
++    if (cut < 0)
++        QSKIP("Failed to parse database type out of name");
++    dbName.truncate(cut);
++    cut = dbName.indexOf(QChar('_'));
++    if (cut >= 0)
++        dbName = dbName.mid(cut + 1);
++
++    auto db = QSqlDatabase::addDatabase(dbName);
++    QSqlQuery q(db);
++
++    QTest::ignoreMessage(QtWarningMsg,
++                         "QSqlDatabasePrivate::removeDatabase: connection "
++                         "'qt_sql_default_connection' is still in use, all "
++                         "queries will cease to work.");
++    QTest::ignoreMessage(QtWarningMsg,
++                         "QSqlDatabasePrivate::addDatabase: duplicate connection name "
++                         "'qt_sql_default_connection', old connection removed.");
++    auto otherDb = QSqlDatabase::addDatabase(dbName);
++
++    QTest::ignoreMessage(QtWarningMsg, "QSqlQuery::exec: called before driver has been set up");
++    // QTBUG-100037: shouldn't crash !
++    QVERIFY(!q.exec("select stuff from TheVoid"));
++}
++
+ void tst_QSqlQuery::lastInsertId()
+ {
+     QFETCH( QString, dbName );
+diff --git a/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp b/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
+index 4aa3f8d60b..d2050a61aa 100644
+--- a/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
++++ b/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
+@@ -115,6 +115,10 @@ void tst_QAbstractItemModelTester::standardItemModelZeroColumns()
+     // QTBUG-92886
+     model.insertRows(0, 5);
+     model.removeRows(1, 2);
++
++    const QModelIndex parentIndex = model.index(0, 0);
++    model.insertRows(0, 5, parentIndex);
++    model.removeRows(1, 2, parentIndex);
+ }
+ 
+ void tst_QAbstractItemModelTester::testInsertThroughProxy()
+diff --git a/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json b/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
+index 12a4a22a19..ce518e78fb 100644
+--- a/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
++++ b/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
+@@ -668,50 +668,6 @@
+         "inputFile": "task192552.h",
+         "outputRevision": 67
+     },
+-    {
+-        "classes": [
+-            {
+-                "className": "InlineSlotsWithThrowDeclaration",
+-                "object": true,
+-                "qualifiedClassName": "InlineSlotsWithThrowDeclaration",
+-                "slots": [
+-                    {
+-                        "access": "public",
+-                        "name": "a",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "b",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "c",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "d",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "e",
+-                        "returnType": "void"
+-                    }
+-                ],
+-                "superClasses": [
+-                    {
+-                        "access": "public",
+-                        "name": "QObject"
+-                    }
+-                ]
+-            }
+-        ],
+-        "inputFile": "task189996.h",
+-        "outputRevision": 67
+-    },
+     {
+         "classes": [
+             {
+diff --git a/qtbase/tests/auto/tools/moc/moc.pro b/qtbase/tests/auto/tools/moc/moc.pro
+index c324b3a8cd..4aceb78dc0 100644
+--- a/qtbase/tests/auto/tools/moc/moc.pro
++++ b/qtbase/tests/auto/tools/moc/moc.pro
+@@ -15,7 +15,7 @@ cross_compile: DEFINES += MOC_CROSS_COMPILED
+ HEADERS += using-namespaces.h no-keywords.h task87883.h c-comments.h backslash-newlines.h oldstyle-casts.h \
+            slots-with-void-template.h qinvokable.h namespaced-flags.h trigraphs.h \
+            escapes-in-string-literals.h cstyle-enums.h qprivateslots.h gadgetwithnoenums.h \
+-           dir-in-include-path.h single_function_keyword.h task192552.h task189996.h \
++           dir-in-include-path.h single_function_keyword.h task192552.h \
+            task234909.h task240368.h pure-virtual-signals.h cxx11-enums.h \
+            cxx11-final-classes.h \
+            cxx11-explicit-override-control.h \
+diff --git a/qtbase/tests/auto/tools/moc/task189996.h b/qtbase/tests/auto/tools/moc/task189996.h
+deleted file mode 100644
+index f94a051b3a..0000000000
+--- a/qtbase/tests/auto/tools/moc/task189996.h
++++ /dev/null
+@@ -1,47 +0,0 @@
+-/****************************************************************************
+-**
+-** Copyright (C) 2016 The Qt Company Ltd.
+-** Contact: https://www.qt.io/licensing/
+-**
+-** This file is part of the test suite of the Qt Toolkit.
+-**
+-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+-** 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 General Public License Usage
+-** Alternatively, this file may be used under the terms of the GNU
+-** General Public License version 3 as published by the Free Software
+-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+-** 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-3.0.html.
+-**
+-** $QT_END_LICENSE$
+-**
+-****************************************************************************/
+-// inline functions can have throw declarations
+-
+-#ifndef TASK189996_H
+-#define TASK189996_H
+-
+-#include <QObject>
+-
+-class InlineSlotsWithThrowDeclaration : public QObject
+-{
+-    Q_OBJECT
+-
+-public slots:
+-    void a() throw() { }
+-    void b() const throw() { }
+-    void c() throw();
+-    void d() throw(int) { }
+-    void e() const throw(int,double) { }
+-};
+-
+-#endif
+diff --git a/qtbase/tests/auto/tools/moc/tst_moc.cpp b/qtbase/tests/auto/tools/moc/tst_moc.cpp
+index c716aead21..15dd9e41e5 100644
+--- a/qtbase/tests/auto/tools/moc/tst_moc.cpp
++++ b/qtbase/tests/auto/tools/moc/tst_moc.cpp
+@@ -631,7 +631,6 @@ public:
+ private slots:
+     void initTestCase();
+ 
+-    void slotWithException() throw(MyStruct);
+     void dontStripNamespaces();
+     void oldStyleCasts();
+     void warnOnExtraSignalSlotQualifiaction();
+@@ -673,7 +672,6 @@ private slots:
+     void templateGtGt();
+     void qprivateslots();
+     void qprivateproperties();
+-    void inlineSlotsWithThrowDeclaration();
+     void warnOnPropertyWithoutREAD();
+     void constructors();
+     void typenameWithUnsigned();
+@@ -784,12 +782,6 @@ void tst_Moc::initTestCase()
+ #endif
+ }
+ 
+-void tst_Moc::slotWithException() throw(MyStruct)
+-{
+-    // be happy
+-    QVERIFY(true);
+-}
+-
+ void tst_Moc::dontStripNamespaces()
+ {
+     Sender sender;
+@@ -824,7 +816,7 @@ void tst_Moc::oldStyleCasts()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-Wold-style-cast" << "-I" << "."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -894,7 +886,7 @@ void tst_Moc::inputFileNameWithDotsButNoExtension()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-I" << ".."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -1174,7 +1166,7 @@ void tst_Moc::ignoreOptionClashes()
+     QStringList gccArgs;
+     gccArgs << "-c" << "-x" << "c++" << "-I" << ".."
+          << "-I" << qtIncludePath << "-I" << includeDir << "-o" << "/dev/null"
+-         << "-fPIC" << "-std=c++11" <<  "-";
++         << "-fPIC" << "-std=c++1z" <<  "-";
+     proc.start("gcc", gccArgs);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -1593,21 +1585,6 @@ void tst_Moc::qprivateproperties()
+ 
+ }
+ 
+-#include "task189996.h"
+-
+-void InlineSlotsWithThrowDeclaration::c() throw() {}
+-
+-void tst_Moc::inlineSlotsWithThrowDeclaration()
+-{
+-    InlineSlotsWithThrowDeclaration tst;
+-    const QMetaObject *mobj = tst.metaObject();
+-    QVERIFY(mobj->indexOfSlot("a()") != -1);
+-    QVERIFY(mobj->indexOfSlot("b()") != -1);
+-    QVERIFY(mobj->indexOfSlot("c()") != -1);
+-    QVERIFY(mobj->indexOfSlot("d()") != -1);
+-    QVERIFY(mobj->indexOfSlot("e()") != -1);
+-}
+-
+ void tst_Moc::warnOnPropertyWithoutREAD()
+ {
+ #ifdef MOC_CROSS_COMPILED
+@@ -1869,7 +1846,7 @@ void tst_Moc::notifyError()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-I" << "."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+diff --git a/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+index c355ee9665..88c09de8e0 100644
+--- a/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
++++ b/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+@@ -251,6 +251,7 @@ private slots:
+     void testResetCachedSizeHint();
+     void statusTips();
+     void testRemovingColumnsViaLayoutChanged();
++    void testModelMovingColumns();
+ 
+ protected:
+     void setupTestData(bool use_reset_model = false);
+@@ -360,6 +361,12 @@ public:
+         endRemoveColumns();
+     }
+ 
++    void moveColumn(int from, int to)
++    {
++        beginMoveColumns(QModelIndex(), from, from, QModelIndex(), to);
++        endMoveColumns();
++    }
++
+     void cleanup()
+     {
+         emit layoutAboutToBeChanged();
+@@ -3627,5 +3634,18 @@ void tst_QHeaderView::testRemovingColumnsViaLayoutChanged()
+     // The main point of this test is that the section-size restoring code didn't go out of bounds.
+ }
+ 
++void tst_QHeaderView::testModelMovingColumns()
++{
++    QtTestModel model(10, 10);
++    QHeaderView hv(Qt::Horizontal);
++    hv.setModel(&model);
++    hv.resizeSections(QHeaderView::ResizeToContents);
++    hv.show();
++
++    QPersistentModelIndex index3 = model.index(0, 3);
++    model.moveColumn(3, 1);
++    QCOMPARE(index3.column(), 1);
++}
++
+ QTEST_MAIN(tst_QHeaderView)
+ #include "tst_qheaderview.moc"
+diff --git a/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+index 761357b252..06bb706074 100644
+--- a/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
++++ b/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+@@ -397,6 +397,7 @@ private slots:
+     void checkHeaderMinSize();
+ 
+     void resizeToContents();
++    void resizeToContentsSpans();
+ 
+     void tabFocus();
+     void bigModel();
+@@ -3721,6 +3722,70 @@ void tst_QTableView::resizeToContents()
+ 
+ }
+ 
++
++class SpanModel : public QAbstractTableModel
++{
++public:
++    SpanModel(bool sectionsMoved)
++        : _sectionsMoved(sectionsMoved)
++    {}
++    int columnCount(const QModelIndex & = {}) const override { return 2; }
++    int rowCount(const QModelIndex & = {}) const override { return 1; }
++    QVariant data(const QModelIndex &idx, int role = Qt::DisplayRole) const override
++    {
++        if (role != Qt::DisplayRole)
++            return QVariant();
++        const int col = _sectionsMoved ? 1 - idx.column() : idx.column();
++        if (col == 0)
++            return "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.";
++        return QVariant();
++    }
++private:
++    bool _sectionsMoved;
++};
++
++
++void tst_QTableView::resizeToContentsSpans()
++{
++    SpanModel model1(false);
++    SpanModel model2(true);
++    QTableView view1, view2, view3;
++    view1.setModel(&model1);
++    view2.setModel(&model2);
++    view2.horizontalHeader()->moveSection(0, 1);
++    view3.setModel(&model1);
++
++    view1.setSpan(0, 0, 1, 2);
++    view2.setSpan(0, 1, 1, 2);
++    view1.show();
++    view2.show();
++    view3.show();
++    QVERIFY(QTest::qWaitForWindowExposed(&view1));
++    QVERIFY(QTest::qWaitForWindowExposed(&view2));
++    QVERIFY(QTest::qWaitForWindowExposed(&view3));
++    view1.setColumnWidth(0, 100);
++    view1.setColumnWidth(1, 100);
++    view2.setColumnWidth(0, 100);
++    view2.setColumnWidth(1, 100);
++    view3.setColumnWidth(0, 200);
++
++    view1.resizeRowToContents(0);
++    view2.resizeRowToContents(0);
++    view3.resizeRowToContents(0);
++    QCOMPARE(view1.rowHeight(0), view3.rowHeight(0));
++    QCOMPARE(view2.rowHeight(0), view3.rowHeight(0));
++
++    view3.resizeColumnToContents(0);
++    view3.resizeRowToContents(0);
++    // height should be only 1 text line for easy testing
++    view1.setRowHeight(0, view3.verticalHeader()->sectionSize(0));
++    view2.setRowHeight(0, view3.verticalHeader()->sectionSize(0));
++    view1.resizeColumnToContents(0);
++    view2.resizeColumnToContents(1);
++    QCOMPARE(view1.columnWidth(0), view3.columnWidth(0) - view1.columnWidth(1));
++    QCOMPARE(view2.columnWidth(0), view3.columnWidth(0) - view2.columnWidth(1));
++}
++
+ QT_BEGIN_NAMESPACE
+ extern bool Q_WIDGETS_EXPORT qt_tab_all_widgets(); // qapplication.cpp
+ QT_END_NAMESPACE
+diff --git a/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+index a3b8ef78d8..4955cebd5d 100644
+--- a/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
++++ b/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+@@ -1498,7 +1498,7 @@ void tst_QApplication::desktopSettingsAware()
+     environment += QLatin1String("QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM=1");
+     testProcess.setEnvironment(environment);
+ #endif
+-    testProcess.start("desktopsettingsaware_helper");
++    testProcess.start("./desktopsettingsaware_helper");
+     QVERIFY2(testProcess.waitForStarted(),
+              qPrintable(QString::fromLatin1("Cannot start 'desktopsettingsaware_helper': %1").arg(testProcess.errorString())));
+     QVERIFY(testProcess.waitForFinished(10000));
+@@ -2452,7 +2452,7 @@ void tst_QApplication::qtbug_12673()
+ #if QT_CONFIG(process)
+     QProcess testProcess;
+     QStringList arguments;
+-    testProcess.start("modal_helper", arguments);
++    testProcess.start("./modal_helper", arguments);
+     QVERIFY2(testProcess.waitForStarted(),
+              qPrintable(QString::fromLatin1("Cannot start 'modal_helper': %1").arg(testProcess.errorString())));
+     QVERIFY(testProcess.waitForFinished(20000));
+diff --git a/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp b/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
+index eb108a40de..dca5528c1b 100644
+--- a/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
+@@ -41,6 +41,7 @@
+ 
+ #include <private/qguiapplication_p.h>
+ #include <qpa/qplatformintegration.h>
++#include <qpa/qplatformtheme.h>
+ 
+ class tst_QAbstractButton : public QObject
+ {
+@@ -76,6 +77,8 @@ private slots:
+     void keyNavigation();
+ #endif
+ 
++    void buttonPressKeys();
++
+ protected slots:
+     void onClicked();
+     void onToggled( bool on );
+@@ -269,7 +272,13 @@ void tst_QAbstractButton::setAutoRepeat()
+         QCOMPARE(press_count, click_count);
+         QVERIFY(click_count > 1);
+         break;
+-    case 4:
++    case 4: {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(Qt::Key_Enter)) {
++            QSKIP("platform theme has Key_Enter in ButtonPressKeys");
++        }
+         // check that pressing ENTER has no effect when autorepeat is false
+         testWidget->setDown( false );
+         testWidget->setAutoRepeat( false );
+@@ -286,7 +295,14 @@ void tst_QAbstractButton::setAutoRepeat()
+ 
+         QVERIFY( click_count == 0 );
+         break;
+-    case 5:
++    }
++    case 5: {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(Qt::Key_Enter)) {
++            QSKIP("platform theme has Key_Enter in ButtonPressKeys");
++        }
+         // check that pressing ENTER has no effect when autorepeat is true
+         testWidget->setDown( false );
+         testWidget->setAutoRepeat( true );
+@@ -304,6 +320,7 @@ void tst_QAbstractButton::setAutoRepeat()
+ 
+         QVERIFY( click_count == 0 );
+         break;
++    }
+     case 6:
+         // verify autorepeat is off by default.
+         MyButton tmp( 0);
+@@ -651,5 +668,16 @@ void tst_QAbstractButton::keyNavigation()
+ }
+ #endif
+ 
++void tst_QAbstractButton::buttonPressKeys()
++{
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(testWidget, buttonPressKeys[i]);
++        QCOMPARE(click_count, i + 1);
++    }
++}
++
+ QTEST_MAIN(tst_QAbstractButton)
+ #include "tst_qabstractbutton.moc"
+diff --git a/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+index 32437050f5..46b5af6d63 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+@@ -168,6 +168,7 @@ private slots:
+     void checkMenuItemPosWhenStyleSheetIsSet();
+     void checkEmbeddedLineEditWhenStyleSheetIsSet();
+     void propagateStyleChanges();
++    void buttonPressKeys();
+ 
+ private:
+     PlatformInputContext m_platformInputContext;
+@@ -1682,6 +1683,16 @@ void tst_QComboBox::setModel()
+     QCOMPARE(box.rootModelIndex(), rootModelIndex);
+     box.setModel(box.model());
+     QCOMPARE(box.rootModelIndex(), rootModelIndex);
++
++    // check that setting the same model as the completer's doesn't crash
++    QCompleter *completer = new QCompleter(&box);
++    box.setEditable(true);
++    box.setCompleter(completer);
++    auto *listModel = new QStringListModel({ "one", "two" }, completer);
++    completer->setModel(listModel);
++    QCOMPARE(listModel->rowCount(), 2); // make sure it wasn't deleted
++    box.setModel(listModel);
++    QCOMPARE(listModel->rowCount(), 2); // make sure it wasn't deleted
+ }
+ 
+ void tst_QComboBox::setCustomModelAndView()
+@@ -3632,5 +3643,24 @@ void tst_QComboBox::propagateStyleChanges()
+     QVERIFY(frameStyle.inquired);
+ }
+ 
++void tst_QComboBox::buttonPressKeys()
++{
++    QComboBox comboBox;
++    comboBox.setEditable(false);
++    comboBox.addItem(QString::number(1));
++    comboBox.addItem(QString::number(2));
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(&comboBox, buttonPressKeys[i]);
++        // On some platforms, a window will not be immediately visible,
++        // but take some event-loop iterations to complete.
++        // Using QTRY_VERIFY to deal with that.
++        QTRY_VERIFY(comboBox.view()->isVisible());
++        comboBox.hidePopup();
++    }
++}
++
+ QTEST_MAIN(tst_QComboBox)
+ #include "tst_qcombobox.moc"
+diff --git a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
+index be3cfcd104..c228fdfcca 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
++++ b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qcommandlinkbutton
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qcommandlinkbutton.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
+index 0044d33c66..4cf06296e4 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
+@@ -40,6 +40,9 @@
+ #include <QGridLayout>
+ #include <QPainter>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ class tst_QCommandLinkButton : public QObject
+ {
+     Q_OBJECT
+@@ -223,6 +226,13 @@ void tst_QCommandLinkButton::setAutoRepeat()
+     // check that pressing ENTER has no effect
+     resetCounters();
+     testWidget->setDown( false );
++    // Skip after reset if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
+     testWidget->setAutoRepeat( false );
+     QTest::keyPress( testWidget, Qt::Key_Enter );
+ 
+@@ -255,6 +265,14 @@ void tst_QCommandLinkButton::pressed()
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+ 
++    // Skip if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
++
+     QTest::keyPress( testWidget,Qt::Key_Enter );
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+diff --git a/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro b/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
+index 4a5e76ff65..a235fa1fac 100644
+--- a/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
++++ b/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qgroupbox
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qgroupbox.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp b/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
+index 4fb5d262ca..d8d7562b73 100644
+--- a/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
+@@ -35,6 +35,9 @@
+ #include <QRadioButton>
+ #include <QDialog>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ #include "qgroupbox.h"
+ 
+ class tst_QGroupBox : public QObject
+@@ -69,6 +72,7 @@ private slots:
+     void propagateFocus();
+     void task_QTBUG_19170_ignoreMouseReleaseEvent();
+     void task_QTBUG_15519_propagateMouseEvents();
++    void buttonPressKeys();
+ 
+ private:
+     bool checked;
+@@ -610,6 +614,20 @@ void tst_QGroupBox::task_QTBUG_15519_propagateMouseEvents()
+     QCOMPARE(parent.mouseMoved, true);
+ }
+ 
++void tst_QGroupBox::buttonPressKeys()
++{
++    QGroupBox groupBox;
++    groupBox.setCheckable(true);
++    QSignalSpy clickedSpy(&groupBox, &QGroupBox::clicked);
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(&groupBox, buttonPressKeys[i]);
++        QCOMPARE(clickedSpy.length(), i + 1);
++    }
++}
++
+ void tst_QGroupBox::sendMouseMoveEvent(QWidget *widget, const QPoint &localPos)
+ {
+     // Send a MouseMove event without actually moving the pointer
+diff --git a/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro b/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
+index 353ad06ca2..e55f6148f2 100644
+--- a/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
++++ b/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qpushbutton
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qpushbutton.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp b/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
+index e818514a79..4043e9326a 100644
+--- a/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
+@@ -41,6 +41,9 @@
+ #include <QStyleFactory>
+ #include <QTabWidget>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ class tst_QPushButton : public QObject
+ {
+ Q_OBJECT
+@@ -212,6 +215,13 @@ void tst_QPushButton::autoRepeat()
+     // check that pressing ENTER has no effect
+     resetCounters();
+     testWidget->setDown( false );
++    // Skip after reset if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
+     testWidget->setAutoRepeat( false );
+     QTest::keyPress( testWidget, Qt::Key_Enter );
+ 
+@@ -247,6 +257,14 @@ void tst_QPushButton::pressed()
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+ 
++    // Skip if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
++
+     QTest::keyPress( testWidget,Qt::Key_Enter );
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+diff --git a/qtbase/tests/manual/rhi/cubemap_render/buildshader.bat b/qtbase/tests/manual/rhi/cubemap_render/buildshader.bat
+old mode 100755
+new mode 100644
+Submodule qtconnectivity e957d481..056294c0:
+diff --git a/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp b/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
+index e2635fae..a8b8e3b9 100644
+--- a/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
++++ b/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
+@@ -563,9 +563,11 @@ void HciManager::handleHciAclPacket(const quint8 *data, int size)
+ 
+ void HciManager::handleLeMetaEvent(const quint8 *data)
+ {
+-    // Spec v4.2, Vol 2, part E, 7.7.65ff
++    // Spec v5.3, Vol 4, part E, 7.7.65.*
+     switch (*data) {
+-    case 0x1: {
++    case 0x1: // HCI_LE_Connection_Complete
++    case 0xA: // HCI_LE_Enhanced_Connection_Complete
++    {
+         const quint16 handle = bt_get_le16(data + 2);
+         emit connectionComplete(handle);
+         break;
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp b/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
+index 6a93143b..4a18cfc7 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
+@@ -320,7 +320,10 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_finishSdpScan(QBluetoothServiceD
+             for (const QBluetoothUuid &id : serviceClassUuids) {
+                 if (id.minimumSize() == 16) {
+                     serviceInfo.setServiceUuid(id);
+-                    serviceInfo.setServiceName(QBluetoothServiceDiscoveryAgent::tr("Custom Service"));
++                    if (serviceInfo.serviceName().isEmpty()) {
++                        serviceInfo.setServiceName(
++                                    QBluetoothServiceDiscoveryAgent::tr("Custom Service"));
++                    }
+                     QBluetoothServiceInfo::Sequence modSeq =
+                             serviceInfo.attribute(QBluetoothServiceInfo::ServiceClassIds).value<QBluetoothServiceInfo::Sequence>();
+                     modSeq.removeOne(QVariant::fromValue(id));
+@@ -334,8 +337,10 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_finishSdpScan(QBluetoothServiceD
+                 qCDebug(QT_BT_BLUEZ) << "Discovered services" << discoveredDevices.at(0).address().toString()
+                                      << serviceInfo.serviceName() << serviceInfo.serviceUuid()
+                                      << ">>>" << serviceInfo.serviceClassUuids();
+-
+-                emit q->serviceDiscovered(serviceInfo);
++                // Use queued connection to allow us finish the service looping; the application
++                // might call stop() when it has detected the service-of-interest.
++                QMetaObject::invokeMethod(q, "serviceDiscovered", Qt::QueuedConnection,
++                                          Q_ARG(QBluetoothServiceInfo, serviceInfo));
+             }
+         }
+     }
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp b/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
+index e4d85447..aadd4755 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
+@@ -593,7 +593,7 @@ void QBluetoothSocket::setSocketState(QBluetoothSocket::SocketState state)
+ bool QBluetoothSocket::canReadLine() const
+ {
+     Q_D(const QBluetoothSocketBase);
+-    return d->canReadLine();
++    return d->canReadLine() || QIODevice::canReadLine();
+ }
+ 
+ /*!
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp b/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
+index 084aa958..d6aa17a7 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
+@@ -284,6 +284,10 @@ void QBluetoothSocketPrivateBluezDBus::connectToService(
+         return;
+     }
+ 
++    if (service.socketProtocol() != QBluetoothServiceInfo::Protocol::UnknownProtocol)
++        socketType = service.socketProtocol();
++    qCDebug(QT_BT_BLUEZ) << "Socket protocol used:" << socketType;
++
+     connectToService(service.device().address(), targetService, openMode);
+ }
+ 
+diff --git a/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp b/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
+index 05bc1a0f..a7b5ef1f 100644
+--- a/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
++++ b/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
+@@ -142,7 +142,7 @@ void tst_QBluetoothSocket::initTestCase()
+     qDebug() << "Starting discovery";
+ 
+     sda->setUuidFilter(QBluetoothUuid(QString(TEST_SERVICE_UUID)));
+-    sda->start(QBluetoothServiceDiscoveryAgent::MinimalDiscovery);
++    sda->start(QBluetoothServiceDiscoveryAgent::FullDiscovery);
+ 
+     for (int connectTime = MaxConnectTime; !done_discovery && connectTime > 0; connectTime -= 1000)
+         QTest::qWait(1000);
+Submodule qtdeclarative f5701f0d..8defe7bf:
+diff --git a/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h b/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
+index b65b994d6c..15a8cd6878 100644
+--- a/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
++++ b/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
+@@ -86,7 +86,7 @@ public:
+         if (QTypeInfo<T>::isComplex) {
+             for (int i = 0; i < count; ++i)
+                 new (data + i) T(vector.at(i));
+-        } else {
++        } else if (count) {
+             memcpy(data, static_cast<const void*>(vector.constData()), count * sizeof(T));
+         }
+     }
+diff --git a/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp b/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
+index e57cdd8278..94613598af 100644
+--- a/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
++++ b/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
+@@ -1145,8 +1145,7 @@ void Heap::QObjectWrapper::markObjects(Heap::Base *that, QV4::MarkStack *markSta
+ void QObjectWrapper::destroyObject(bool lastCall)
+ {
+     Heap::QObjectWrapper *h = d();
+-    if (!h->internalClass)
+-        return; // destroyObject already got called
++    Q_ASSERT(h->internalClass);
+ 
+     if (h->object()) {
+         QQmlData *ddata = QQmlData::get(h->object(), false);
+@@ -1176,7 +1175,7 @@ void QObjectWrapper::destroyObject(bool lastCall)
+         }
+     }
+ 
+-    h->~Data();
++    h->destroy();
+ }
+ 
+ 
+diff --git a/qtdeclarative/src/qml/memory/qv4mm.cpp b/qtdeclarative/src/qml/memory/qv4mm.cpp
+index 06caf04e5a..da149a67c4 100644
+--- a/qtdeclarative/src/qml/memory/qv4mm.cpp
++++ b/qtdeclarative/src/qml/memory/qv4mm.cpp
+@@ -981,7 +981,7 @@ void MemoryManager::sweep(bool lastSweep, ClassDestroyStatsCallback classCountPt
+ 
+     if (MultiplyWrappedQObjectMap *multiplyWrappedQObjects = engine->m_multiplyWrappedQObjects) {
+         for (MultiplyWrappedQObjectMap::Iterator it = multiplyWrappedQObjects->begin(); it != multiplyWrappedQObjects->end();) {
+-            if (!it.value().isNullOrUndefined())
++            if (it.value().isNullOrUndefined())
+                 it = multiplyWrappedQObjects->erase(it);
+             else
+                 ++it;
+diff --git a/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp b/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
+index 2079a8ed04..a577cb2351 100644
+--- a/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
++++ b/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
+@@ -389,6 +389,12 @@ void QQmlDelegateModelPrivate::connectToAbstractItemModel()
+                       q,  QQmlDelegateModel, SLOT(_q_rowsRemoved(QModelIndex,int,int)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
+                       q,  QQmlDelegateModel, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsInserted(QModelIndex,int,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsInserted(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsRemoved(QModelIndex,int,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsRemoved(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsMoved(QModelIndex,int,int,QModelIndex,int)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
+                       q, QQmlDelegateModel, SLOT(_q_dataChanged(QModelIndex,QModelIndex,QVector<int>)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
+@@ -413,6 +419,12 @@ void QQmlDelegateModelPrivate::disconnectFromAbstractItemModel()
+                         q, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int)));
+     QObject::disconnect(aim, SIGNAL(rowsRemoved(QModelIndex,int,int)),
+                         q, SLOT(_q_rowsRemoved(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsInserted(QModelIndex,int,int)), q,
++                        SLOT(_q_columnsInserted(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsRemoved(QModelIndex,int,int)), q,
++                        SLOT(_q_columnsRemoved(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)), q,
++                        SLOT(_q_columnsMoved(QModelIndex,int,int,QModelIndex,int)));
+     QObject::disconnect(aim, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
+                         q, SLOT(_q_dataChanged(QModelIndex,QModelIndex,QVector<int>)));
+     QObject::disconnect(aim, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
+@@ -1973,6 +1985,38 @@ void QQmlDelegateModel::_q_rowsMoved(
+     }
+ }
+ 
++void QQmlDelegateModel::_q_columnsInserted(const QModelIndex &parent, int begin, int end)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if (parent == d->m_adaptorModel.rootIndex && begin == 0) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
++void QQmlDelegateModel::_q_columnsRemoved(const QModelIndex &parent, int begin, int end)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if (parent == d->m_adaptorModel.rootIndex && begin == 0) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
++void QQmlDelegateModel::_q_columnsMoved(const QModelIndex &parent, int start, int end,
++                                        const QModelIndex &destination, int column)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if ((parent == d->m_adaptorModel.rootIndex && start == 0)
++        || (destination == d->m_adaptorModel.rootIndex && column == 0)) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
+ void QQmlDelegateModel::_q_dataChanged(const QModelIndex &begin, const QModelIndex &end, const QVector<int> &roles)
+ {
+     Q_D(QQmlDelegateModel);
+diff --git a/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h b/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
+index 8aab4badca..d140bfbaaf 100644
+--- a/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
++++ b/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
+@@ -152,6 +152,9 @@ private Q_SLOTS:
+     void _q_itemsMoved(int from, int to, int count);
+     void _q_modelReset();
+     void _q_rowsInserted(const QModelIndex &,int,int);
++    void _q_columnsInserted(const QModelIndex &, int, int);
++    void _q_columnsRemoved(const QModelIndex &, int, int);
++    void _q_columnsMoved(const QModelIndex &, int, int, const QModelIndex &, int);
+     void _q_rowsAboutToBeRemoved(const QModelIndex &parent, int begin, int end);
+     void _q_rowsRemoved(const QModelIndex &,int,int);
+     void _q_rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int);
+diff --git a/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp b/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
+index 85719fdc80..78e2ab302c 100644
+--- a/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
++++ b/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
+@@ -46,6 +46,7 @@
+ #include "QtQuick/private/qquicktextinput_p.h"
+ #include "QtQuick/private/qquickaccessibleattached_p.h"
+ #include "QtQuick/qquicktextdocument.h"
++#include "QtQuick/qquickrendercontrol.h"
+ QT_BEGIN_NAMESPACE
+ 
+ #if QT_CONFIG(accessibility)
+@@ -57,7 +58,19 @@ QAccessibleQuickItem::QAccessibleQuickItem(QQuickItem *item)
+ 
+ QWindow *QAccessibleQuickItem::window() const
+ {
+-    return item()->window();
++    QQuickWindow *window = item()->window();
++
++    // For QQuickWidget the above window will be the offscreen QQuickWindow,
++    // which is not a part of the accessibility tree. Detect this case and
++    // return the window for the QQuickWidget instead.
++    if (window && !window->handle()) {
++        if (QQuickRenderControl *renderControl = QQuickWindowPrivate::get(window)->renderControl) {
++            if (QWindow *renderWindow = renderControl->renderWindow(nullptr))
++                return renderWindow;
++        }
++    }
++
++    return window;
+ }
+ 
+ int QAccessibleQuickItem::childCount() const
+@@ -113,19 +126,15 @@ QAccessibleInterface *QAccessibleQuickItem::childAt(int x, int y) const
+ QAccessibleInterface *QAccessibleQuickItem::parent() const
+ {
+     QQuickItem *parent = item()->parentItem();
+-    QQuickWindow *window = item()->window();
+-    QQuickItem *ci = window ? window->contentItem() : nullptr;
++    QQuickWindow *itemWindow = item()->window();
++    QQuickItem *ci = itemWindow ? itemWindow->contentItem() : nullptr;
+     while (parent && !QQuickItemPrivate::get(parent)->isAccessible && parent != ci)
+         parent = parent->parentItem();
+ 
+     if (parent) {
+         if (parent == ci) {
+-            // Jump out to the scene widget if the parent is the root item.
+-            // There are two root items, QQuickWindow::rootItem and
+-            // QQuickView::declarativeRoot. The former is the true root item,
+-            // but is not a part of the accessibility tree. Check if we hit
+-            // it here and return an interface for the scene instead.
+-            return QAccessible::queryAccessibleInterface(window);
++            // Jump out to the window if the parent is the root item
++            return QAccessible::queryAccessibleInterface(window());
+         } else {
+             while (parent && !parent->d_func()->isAccessible)
+                 parent = parent->parentItem();
+@@ -188,7 +197,7 @@ QAccessible::State QAccessibleQuickItem::state() const
+     QRect viewRect_ = viewRect();
+     QRect itemRect = rect();
+ 
+-    if (viewRect_.isNull() || itemRect.isNull() || !item()->window() || !item()->window()->isVisible() ||!item()->isVisible() || qFuzzyIsNull(item()->opacity()))
++    if (viewRect_.isNull() || itemRect.isNull() || !window() || !window()->isVisible() ||!item()->isVisible() || qFuzzyIsNull(item()->opacity()))
+         state.invisible = true;
+     if (!viewRect_.intersects(itemRect))
+         state.offscreen = true;
+@@ -201,6 +210,10 @@ QAccessible::State QAccessibleQuickItem::state() const
+     if (role() == QAccessible::EditableText)
+         if (auto ti = qobject_cast<QQuickTextInput *>(item()))
+             state.passwordEdit = ti->echoMode() != QQuickTextInput::Normal;
++    if (!item()->isEnabled()) {
++        state.focusable = false;
++        state.disabled = true;
++    }
+     return state;
+ }
+ 
+diff --git a/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h b/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
+index 39ffcaf39c..8baa01330c 100644
+--- a/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
++++ b/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
+@@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE
+ 
+ #if QT_CONFIG(accessibility)
+ 
+-class QAccessibleQuickWindow : public QAccessibleObject
++class Q_QUICK_EXPORT QAccessibleQuickWindow : public QAccessibleObject
+ {
+ public:
+     QAccessibleQuickWindow(QQuickWindow *object);
+diff --git a/qtdeclarative/src/quick/items/qquickdrag.cpp b/qtdeclarative/src/quick/items/qquickdrag.cpp
+index 8321fcfeed..383078b3b9 100644
+--- a/qtdeclarative/src/quick/items/qquickdrag.cpp
++++ b/qtdeclarative/src/quick/items/qquickdrag.cpp
+@@ -481,7 +481,9 @@ void QQuickDragAttached::setKeys(const QStringList &keys)
+     \qmlattachedproperty stringlist QtQuick::Drag::mimeData
+     \since 5.2
+ 
+-    This property holds a map of mimeData that is used during startDrag.
++    This property holds a map from mime type to data that is used during startDrag.
++    The mime data needs to be a \c string, or an \c ArrayBuffer with the data encoded
++    according to the mime type.
+ */
+ 
+ QVariantMap QQuickDragAttached::mimeData() const
+@@ -766,8 +768,12 @@ Qt::DropAction QQuickDragAttachedPrivate::startDrag(Qt::DropActions supportedAct
+     QDrag *drag = new QDrag(source ? source : q);
+     QMimeData *mimeData = new QMimeData();
+ 
+-    for (auto it = externalMimeData.cbegin(), end = externalMimeData.cend(); it != end; ++it)
+-        mimeData->setData(it.key(), it.value().toString().toUtf8());
++    for (auto it = externalMimeData.cbegin(), end = externalMimeData.cend(); it != end; ++it) {
++        if (static_cast<QMetaType::Type>(it.value().type()) == QMetaType::QByteArray)
++            mimeData->setData(it.key(), it.value().toByteArray());
++        else
++            mimeData->setData(it.key(), it.value().toString().toUtf8());
++    }
+ 
+     drag->setMimeData(mimeData);
+     if (pixmapLoader.isReady()) {
+diff --git a/qtdeclarative/src/quick/items/qquickitem.cpp b/qtdeclarative/src/quick/items/qquickitem.cpp
+index 75f1457816..dec0ae19ae 100644
+--- a/qtdeclarative/src/quick/items/qquickitem.cpp
++++ b/qtdeclarative/src/quick/items/qquickitem.cpp
+@@ -59,6 +59,7 @@
+ #include <QtCore/private/qnumeric_p.h>
+ #include <QtGui/qpa/qplatformtheme.h>
+ #include <QtCore/qloggingcategory.h>
++#include <QtCore/private/qduplicatetracker_p.h>
+ 
+ #include <private/qqmlglobal_p.h>
+ #include <private/qqmlengine_p.h>
+@@ -2326,6 +2327,7 @@ QQuickItem::QQuickItem(QQuickItemPrivate &dd, QQuickItem *parent)
+ QQuickItem::~QQuickItem()
+ {
+     Q_D(QQuickItem);
++    d->inDestructor = true;
+ 
+     if (d->windowRefCount > 1)
+         d->windowRefCount = 1; // Make sure window is set to null in next call to derefWindow().
+@@ -2526,6 +2528,7 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo
+     QQuickItem *current = item;
+     qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: startItem:" << startItem;
+     qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: firstFromItem:" << firstFromItem;
++    QDuplicateTracker<QQuickItem *> cycleDetector;
+     do {
+         qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: current:" << current;
+         qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: from:" << from;
+@@ -2592,7 +2595,10 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo
+         // traversed all of the chain (by compare the [current] item with [startItem])
+         // Since the [startItem] might be promoted to its parent if it is invisible,
+         // we still have to check [current] item with original start item
+-        if ((current == startItem || current == originalStartItem) && from == firstFromItem) {
++        // We might also run into a cycle before we reach firstFromItem again
++        // but note that we have to ignore current if we are meant to skip it
++        if (((current == startItem || current == originalStartItem) && from == firstFromItem) ||
++                (!skip && cycleDetector.hasSeen(current))) {
+             // wrapped around, avoid endless loops
+             if (item == contentItem) {
+                 qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: looped, return contentItem";
+@@ -2689,9 +2695,8 @@ void QQuickItem::setParentItem(QQuickItem *parentItem)
+ 
+         const bool wasVisible = isVisible();
+         op->removeChild(this);
+-        if (wasVisible) {
++        if (wasVisible && !op->inDestructor)
+             emit oldParentItem->visibleChildrenChanged();
+-        }
+     } else if (d->window) {
+         QQuickWindowPrivate::get(d->window)->parentlessItems.remove(this);
+     }
+@@ -2768,8 +2773,9 @@ void QQuickItem::setParentItem(QQuickItem *parentItem)
+ 
+     d->itemChange(ItemParentHasChanged, d->parentItem);
+ 
+-    emit parentChanged(d->parentItem);
+-    if (isVisible() && d->parentItem)
++    if (!d->inDestructor)
++        emit parentChanged(d->parentItem);
++    if (isVisible() && d->parentItem && !QQuickItemPrivate::get(d->parentItem)->inDestructor)
+         emit d->parentItem->visibleChildrenChanged();
+ }
+ 
+@@ -2965,7 +2971,8 @@ void QQuickItemPrivate::removeChild(QQuickItem *child)
+ 
+     itemChange(QQuickItem::ItemChildRemovedChange, child);
+ 
+-    emit q->childrenChanged();
++    if (!inDestructor)
++        emit q->childrenChanged();
+ }
+ 
+ void QQuickItemPrivate::refWindow(QQuickWindow *c)
+@@ -3194,6 +3201,7 @@ QQuickItemPrivate::QQuickItemPrivate()
+     , touchEnabled(false)
+ #endif
+     , hasCursorHandler(false)
++    , inDestructor(false)
+     , dirtyAttributes(0)
+     , nextDirtyItem(nullptr)
+     , prevDirtyItem(nullptr)
+@@ -5120,6 +5128,13 @@ void QQuickItem::componentComplete()
+         d->addToDirtyList();
+         QQuickWindowPrivate::get(d->window)->dirtyItem(this);
+     }
++
++#if QT_CONFIG(accessibility)
++    if (d->isAccessible && d->effectiveVisible) {
++        QAccessibleEvent ev(this, QAccessible::ObjectShow);
++        QAccessible::updateAccessibility(&ev);
++    }
++#endif
+ }
+ 
+ QQuickStateGroup *QQuickItemPrivate::_states()
+@@ -6106,9 +6121,11 @@ bool QQuickItemPrivate::setEffectiveVisibleRecur(bool newEffectiveVisible)
+         QAccessible::updateAccessibility(&ev);
+     }
+ #endif
+-    emit q->visibleChanged();
+-    if (childVisibilityChanged)
+-        emit q->visibleChildrenChanged();
++    if (!inDestructor) {
++        emit q->visibleChanged();
++        if (childVisibilityChanged)
++            emit q->visibleChildrenChanged();
++    }
+ 
+     return true;    // effective visibility DID change
+ }
+@@ -6157,6 +6174,15 @@ void QQuickItemPrivate::setEffectiveEnableRecur(QQuickItem *scope, bool newEffec
+     }
+ 
+     itemChange(QQuickItem::ItemEnabledHasChanged, effectiveEnable);
++#if QT_CONFIG(accessibility)
++    if (isAccessible) {
++        QAccessible::State changedState;
++        changedState.disabled = true;
++        changedState.focusable = true;
++        QAccessibleStateChangeEvent ev(q, changedState);
++        QAccessible::updateAccessibility(&ev);
++    }
++#endif
+     emit q->enabledChanged();
+ }
+ 
+diff --git a/qtdeclarative/src/quick/items/qquickitem_p.h b/qtdeclarative/src/quick/items/qquickitem_p.h
+index 841d91bb40..ade8fb61f2 100644
+--- a/qtdeclarative/src/quick/items/qquickitem_p.h
++++ b/qtdeclarative/src/quick/items/qquickitem_p.h
+@@ -472,6 +472,7 @@ public:
+     bool replayingPressEvent:1;
+     bool touchEnabled:1;
+     bool hasCursorHandler:1;
++    quint32 inDestructor:1; // has entered ~QQuickItem
+ 
+     enum DirtyType {
+         TransformOrigin         = 0x00000001,
+diff --git a/qtdeclarative/src/quick/items/qquickitemview.cpp b/qtdeclarative/src/quick/items/qquickitemview.cpp
+index 010a0152e1..f8ad168a17 100644
+--- a/qtdeclarative/src/quick/items/qquickitemview.cpp
++++ b/qtdeclarative/src/quick/items/qquickitemview.cpp
+@@ -1785,7 +1785,7 @@ void QQuickItemViewPrivate::refill(qreal from, qreal to)
+ 
+     do {
+         bufferPause.stop();
+-        if (currentChanges.hasPendingChanges() || bufferedChanges.hasPendingChanges()) {
++        if (currentChanges.hasPendingChanges() || bufferedChanges.hasPendingChanges() || currentChanges.active) {
+             currentChanges.reset();
+             bufferedChanges.reset();
+             releaseVisibleItems(reusableFlag);
+diff --git a/qtdeclarative/src/quick/items/qquickmousearea_p_p.h b/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
+index fba383e268..0d63618622 100644
+--- a/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
++++ b/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
+@@ -61,7 +61,6 @@ QT_BEGIN_NAMESPACE
+ 
+ class QQuickMouseEvent;
+ class QQuickMouseArea;
+-class QQuickPointerMask;
+ class QQuickMouseAreaPrivate : public QQuickItemPrivate
+ {
+     Q_DECLARE_PUBLIC(QQuickMouseArea)
+@@ -100,7 +99,6 @@ public:
+ #if QT_CONFIG(quick_draganddrop)
+     QQuickDrag *drag;
+ #endif
+-    QPointer<QQuickPointerMask> mask;
+     QPointF startScene;
+     QPointF targetStartPos;
+     QPointF lastPos;
+diff --git a/qtdeclarative/src/quick/items/qquicktext.cpp b/qtdeclarative/src/quick/items/qquicktext.cpp
+index 6230186933..e823ca1095 100644
+--- a/qtdeclarative/src/quick/items/qquicktext.cpp
++++ b/qtdeclarative/src/quick/items/qquicktext.cpp
+@@ -2168,7 +2168,7 @@ void QQuickText::resetMaximumLineCount()
+     <img src="" align="top,middle,bottom" width="" height=""> - inline images
+     <ol type="">, <ul type=""> and <li> - ordered and unordered lists
+     <pre></pre> - preformatted
+-    &gt; &lt; &amp;
++    &gt; &lt; &amp; &quot; &nbsp; &apos;
+     \endcode
+ 
+     \c Text.StyledText parser is strict, requiring tags to be correctly nested.
+diff --git a/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp b/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
+index eb4db0f85e..2325a2665b 100644
+--- a/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
++++ b/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
+@@ -446,7 +446,7 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+         const char *textureRecord = allocatorData;
+         for (int i = 0; i < textureCount; ++i, textureRecord += Qtdf::TextureRecordSize) {
+-            if (textureRecord + Qtdf::TextureRecordSize > qtdfTableEnd) {
++            if (qtdfTableEnd - textureRecord < Qtdf::TextureRecordSize) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+@@ -462,7 +462,7 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+         const char *glyphRecord = textureRecord;
+         for (quint32 i = 0; i < glyphCount; ++i, glyphRecord += Qtdf::GlyphRecordSize) {
+-            if (glyphRecord + Qtdf::GlyphRecordSize > qtdfTableEnd) {
++            if (qtdfTableEnd - glyphRecord < Qtdf:: GlyphRecordSize) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+@@ -512,8 +512,8 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+             int width = texInfo->allocatedArea.width();
+             int height = texInfo->allocatedArea.height();
+-            qint64 size = width * height;
+-            if (reinterpret_cast<const char *>(textureData + size) > qtdfTableEnd) {
++            qint64 size = qint64(width) * height;
++            if (qtdfTableEnd - reinterpret_cast<const char *>(textureData) < size) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+diff --git a/qtdeclarative/src/quick/util/qquickstyledtext.cpp b/qtdeclarative/src/quick/util/qquickstyledtext.cpp
+index d531fc9205..a25af90414 100644
+--- a/qtdeclarative/src/quick/util/qquickstyledtext.cpp
++++ b/qtdeclarative/src/quick/util/qquickstyledtext.cpp
+@@ -564,6 +564,8 @@ void QQuickStyledTextPrivate::parseEntity(const QChar *&ch, const QString &textI
+                 textOut += QChar(60);
+             else if (entity == QLatin1String("amp"))
+                 textOut += QChar(38);
++            else if (entity == QLatin1String("apos"))
++                textOut += QChar(39);
+             else if (entity == QLatin1String("quot"))
+                 textOut += QChar(34);
+             else if (entity == QLatin1String("nbsp"))
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp
+new file mode 100644
+index 0000000000..8a1c901880
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp
+@@ -0,0 +1,110 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include "qaccessiblequickwidget_p.h"
++
++#include "qquickwidget_p.h"
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleQuickWidget::QAccessibleQuickWidget(QQuickWidget* widget)
++: QAccessibleWidget(widget)
++, m_accessibleWindow(QQuickWidgetPrivate::get(widget)->offscreenWindow)
++{
++    // NOTE: m_accessibleWindow is a QAccessibleQuickWindow, and not a
++    // QAccessibleQuickWidgetOffscreenWindow (defined below). This means
++    // it will return the Quick item child interfaces, which is what's needed here
++    // (unlike QAccessibleQuickWidgetOffscreenWindow, which will report 0 children).
++}
++
++QAccessibleInterface *QAccessibleQuickWidget::child(int index) const
++{
++    return m_accessibleWindow.child(index);
++}
++
++int QAccessibleQuickWidget::childCount() const
++{
++    return m_accessibleWindow.childCount();
++}
++
++int QAccessibleQuickWidget::indexOfChild(const QAccessibleInterface *iface) const
++{
++    return m_accessibleWindow.indexOfChild(iface);
++}
++
++QAccessibleInterface *QAccessibleQuickWidget::childAt(int x, int y) const
++{
++    return m_accessibleWindow.childAt(x, y);
++}
++
++QAccessibleQuickWidgetOffscreenWindow::QAccessibleQuickWidgetOffscreenWindow(QQuickWindow *window)
++:QAccessibleQuickWindow(window)
++{
++
++}
++
++QAccessibleInterface *QAccessibleQuickWidgetOffscreenWindow::child(int index) const
++{
++    Q_UNUSED(index);
++    return nullptr;
++}
++
++int QAccessibleQuickWidgetOffscreenWindow::childCount() const
++{
++    return 0;
++}
++
++int QAccessibleQuickWidgetOffscreenWindow::indexOfChild(const QAccessibleInterface *iface) const
++{
++    Q_UNUSED(iface);
++    return -1;
++}
++
++QAccessibleInterface *QAccessibleQuickWidgetOffscreenWindow::QAccessibleQuickWidgetOffscreenWindow::childAt(int x, int y) const
++{
++    Q_UNUSED(x);
++    Q_UNUSED(y);
++    return nullptr;
++}
++
++#endif // accessibility
++
++QT_END_NAMESPACE
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h
+new file mode 100644
+index 0000000000..7c2ab930e0
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h
+@@ -0,0 +1,95 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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 QACCESSIBLEQUICKWIDGET_H
++#define QACCESSIBLEQUICKWIDGET_H
++
++//
++//  W A R N I N G
++//  -------------
++//
++// This file is not part of the Qt API.  It exists purely as an
++// implementation detail.  This header file may change from version to
++// version without notice, or even be removed.
++//
++// We mean it.
++//
++
++#include "qquickwidget.h"
++#include <QtWidgets/qaccessiblewidget.h>
++
++#include <private/qaccessiblequickview_p.h>
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++// These classes implement the QQuickWiget accessibility switcharoo,
++// where the child items of the QQuickWidgetOffscreenWindow are reported
++// as child accessible interfaces of the QAccessibleQuickWidget.
++class QAccessibleQuickWidget: public QAccessibleWidget
++{
++public:
++    QAccessibleQuickWidget(QQuickWidget* widget);
++
++    QAccessibleInterface *child(int index) const override;
++    int childCount() const override;
++    int indexOfChild(const QAccessibleInterface *iface) const override;
++    QAccessibleInterface *childAt(int x, int y) const override;
++
++private:
++    QAccessibleQuickWindow m_accessibleWindow;
++    Q_DISABLE_COPY(QAccessibleQuickWidget)
++};
++
++class QAccessibleQuickWidgetOffscreenWindow: public QAccessibleQuickWindow
++{
++public:
++    QAccessibleQuickWidgetOffscreenWindow(QQuickWindow *window);
++    QAccessibleInterface *child(int index) const override;
++    int childCount() const override;
++    int indexOfChild(const QAccessibleInterface *iface) const override;
++    QAccessibleInterface *childAt(int x, int y) const override;
++};
++
++#endif // accessibility
++
++QT_END_NAMESPACE
++
++#endif
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp
+new file mode 100644
+index 0000000000..7ba88a1769
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp
+@@ -0,0 +1,60 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include "qaccessiblequickwidgetfactory_p.h"
++#include "qaccessiblequickwidget_p.h"
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleInterface *qAccessibleQuickWidgetFactory(const QString &classname, QObject *object)
++{
++    if (classname == QLatin1String("QQuickWidget")) {
++        return new QAccessibleQuickWidget(qobject_cast<QQuickWidget *>(object));
++    } else if (classname == QLatin1String("QQuickWidgetOffscreenWindow")) {
++        return new QAccessibleQuickWidgetOffscreenWindow(qobject_cast<QQuickWindow *>(object));
++    }
++    return 0;
++}
++
++#endif // accessibility
++
++QT_END_NAMESPACE
++
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h
+new file mode 100644
+index 0000000000..8c63b09f81
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h
+@@ -0,0 +1,66 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include <QtGui/qaccessible.h>
++
++#ifndef QACCESSIBLEQUICKWIDGETFACTORY_H
++#define QACCESSIBLEQUICKWIDGETFACTORY_H
++
++//
++//  W A R N I N G
++//  -------------
++//
++// This file is not part of the Qt API.  It exists purely as an
++// implementation detail.  This header file may change from version to
++// version without notice, or even be removed.
++//
++// We mean it.
++//
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleInterface *qAccessibleQuickWidgetFactory(const QString &classname, QObject *object);
++
++#endif
++
++QT_END_NAMESPACE
++
++#endif
+diff --git a/qtdeclarative/src/quickwidgets/qquickwidget.cpp b/qtdeclarative/src/quickwidgets/qquickwidget.cpp
+index 39780f8de3..9c97b43518 100644
+--- a/qtdeclarative/src/quickwidgets/qquickwidget.cpp
++++ b/qtdeclarative/src/quickwidgets/qquickwidget.cpp
+@@ -39,6 +39,7 @@
+ 
+ #include "qquickwidget.h"
+ #include "qquickwidget_p.h"
++#include "qaccessiblequickwidgetfactory_p.h"
+ 
+ #include "private/qquickwindow_p.h"
+ #include "private/qquickitem_p.h"
+@@ -75,9 +76,16 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++QQuickWidgetOffscreenWindow::QQuickWidgetOffscreenWindow(QQuickWindowPrivate &dd, QQuickRenderControl *control)
++:QQuickWindow(dd, control)
++{
++    setTitle(QString::fromLatin1("Offscreen"));
++    setObjectName(QString::fromLatin1("QQuickOffScreenWindow"));
++}
++
+ // override setVisble to prevent accidental offscreen window being created
+ // by base class.
+-class QQuickOffcreenWindowPrivate: public QQuickWindowPrivate {
++class QQuickWidgetOffscreenWindowPrivate: public QQuickWindowPrivate {
+ public:
+     void setVisible(bool visible) override {
+         Q_Q(QWindow);
+@@ -105,9 +113,8 @@ void QQuickWidgetPrivate::init(QQmlEngine* e)
+     Q_Q(QQuickWidget);
+ 
+     renderControl = new QQuickWidgetRenderControl(q);
+-    offscreenWindow = new QQuickWindow(*new QQuickOffcreenWindowPrivate(),renderControl);
+-    offscreenWindow->setTitle(QString::fromLatin1("Offscreen"));
+-    offscreenWindow->setObjectName(QString::fromLatin1("QQuickOffScreenWindow"));
++    offscreenWindow = new QQuickWidgetOffscreenWindow(*new QQuickWidgetOffscreenWindowPrivate(), renderControl);
++    offscreenWindow->setScreen(q->screen());
+     // Do not call create() on offscreenWindow.
+ 
+     // Check if the Software Adaptation is being used
+@@ -138,6 +145,10 @@ void QQuickWidgetPrivate::init(QQmlEngine* e)
+     QWidget::connect(offscreenWindow, &QQuickWindow::focusObjectChanged, q, &QQuickWidget::propagateFocusObjectChanged);
+     QObject::connect(renderControl, SIGNAL(renderRequested()), q, SLOT(triggerUpdate()));
+     QObject::connect(renderControl, SIGNAL(sceneChanged()), q, SLOT(triggerUpdate()));
++
++#if QT_CONFIG(accessibility)
++    QAccessible::installFactory(&qAccessibleQuickWidgetFactory);
++#endif
+ }
+ 
+ void QQuickWidgetPrivate::ensureEngine() const
+@@ -901,9 +912,7 @@ void QQuickWidgetPrivate::createContext()
+ 
+         context = new QOpenGLContext;
+         context->setFormat(offscreenWindow->requestedFormat());
+-        const QWindow *win = q->window()->windowHandle();
+-        if (win && win->screen())
+-            context->setScreen(win->screen());
++        context->setScreen(q->screen());
+         QOpenGLContext *shareContext = qt_gl_global_share_context();
+         if (!shareContext)
+             shareContext = QWidgetPrivate::get(q->window())->shareContext();
+@@ -1520,19 +1529,16 @@ bool QQuickWidget::event(QEvent *e)
+         d->handleWindowChange();
+         break;
+ 
+-    case QEvent::ScreenChangeInternal:
+-        if (QWindow *window = this->window()->windowHandle()) {
+-            QScreen *newScreen = window->screen();
+-
+-            if (d->offscreenWindow)
+-                d->offscreenWindow->setScreen(newScreen);
+-            if (d->offscreenSurface)
+-                d->offscreenSurface->setScreen(newScreen);
++    case QEvent::ScreenChangeInternal: {
++        QScreen *newScreen = screen();
++        if (d->offscreenWindow)
++            d->offscreenWindow->setScreen(newScreen);
++        if (d->offscreenSurface)
++            d->offscreenSurface->setScreen(newScreen);
+ #if QT_CONFIG(opengl)
+-            if (d->context)
+-                d->context->setScreen(newScreen);
++        if (d->context)
++            d->context->setScreen(newScreen);
+ #endif
+-        }
+ 
+         if (d->useSoftwareRenderer
+ #if QT_CONFIG(opengl)
+@@ -1545,7 +1551,7 @@ bool QQuickWidget::event(QEvent *e)
+             d->render(true);
+         }
+         break;
+-
++    }
+     case QEvent::Show:
+     case QEvent::Move:
+         d->updatePosition();
+diff --git a/qtdeclarative/src/quickwidgets/qquickwidget_p.h b/qtdeclarative/src/quickwidgets/qquickwidget_p.h
+index 881f7f9220..1a946bcc71 100644
+--- a/qtdeclarative/src/quickwidgets/qquickwidget_p.h
++++ b/qtdeclarative/src/quickwidgets/qquickwidget_p.h
+@@ -148,6 +148,14 @@ public:
+     bool forceFullUpdate;
+ };
+ 
++class QQuickWidgetOffscreenWindow: public QQuickWindow
++{
++    Q_OBJECT
++
++public:
++    QQuickWidgetOffscreenWindow(QQuickWindowPrivate &dd, QQuickRenderControl *control);
++};
++
+ QT_END_NAMESPACE
+ 
+ #endif // QQuickWidget_P_H
+diff --git a/qtdeclarative/src/quickwidgets/quickwidgets.pro b/qtdeclarative/src/quickwidgets/quickwidgets.pro
+index 2438e577ae..85d156b8a3 100644
+--- a/qtdeclarative/src/quickwidgets/quickwidgets.pro
++++ b/qtdeclarative/src/quickwidgets/quickwidgets.pro
+@@ -7,9 +7,13 @@ DEFINES   += QT_NO_URL_CAST_FROM_STRING QT_NO_INTEGER_EVENT_COORDINATES QT_NO_FO
+ HEADERS += \
+     qquickwidget.h \
+     qquickwidget_p.h \
+-    qtquickwidgetsglobal.h
++    qtquickwidgetsglobal.h \
++    qaccessiblequickwidget_p.h \
++    qaccessiblequickwidgetfactory_p.h
+ 
+ SOURCES += \
+-    qquickwidget.cpp
++    qquickwidget.cpp \
++    qaccessiblequickwidget.cpp \
++    qaccessiblequickwidgetfactory.cpp
+ 
+ load(qt_module)
+diff --git a/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+index 3b7d74df63..b75bf820d5 100644
+--- a/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
++++ b/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+@@ -102,6 +102,7 @@ private slots:
+     void valueConversion_RegularExpression();
+     void castWithMultipleInheritance();
+     void collectGarbage();
++    void collectGarbageNestedWrappersTwoEngines();
+     void gcWithNestedDataStructure();
+     void stacktrace();
+     void numberParsing_data();
+@@ -1809,6 +1810,44 @@ void tst_QJSEngine::collectGarbage()
+     QVERIFY(ptr.isNull());
+ }
+ 
++class TestObjectContainer : public QObject
++{
++    Q_OBJECT
++    Q_PROPERTY(QObject *dummy MEMBER m_dummy CONSTANT)
++
++public:
++    TestObjectContainer() : m_dummy(new QObject(this)) {}
++
++private:
++    QObject *m_dummy;
++};
++
++void tst_QJSEngine::collectGarbageNestedWrappersTwoEngines()
++{
++    QJSEngine engine1;
++    QJSEngine engine2;
++
++    TestObjectContainer container;
++    QQmlEngine::setObjectOwnership(&container, QQmlEngine::CppOwnership);
++
++    engine1.globalObject().setProperty("foobar", engine1.newQObject(&container));
++    engine2.globalObject().setProperty("foobar", engine2.newQObject(&container));
++
++    engine1.evaluate("foobar.dummy.baz = 42");
++    engine2.evaluate("foobar.dummy.baz = 43");
++
++    QCOMPARE(engine1.evaluate("foobar.dummy.baz").toInt(), 42);
++    QCOMPARE(engine2.evaluate("foobar.dummy.baz").toInt(), 43);
++
++    engine1.collectGarbage();
++    engine2.collectGarbage();
++
++    // The GC should not collect dummy object wrappers neither in engine1 nor engine2, we
++    // verify that by checking whether the baz property still has its previous value.
++    QCOMPARE(engine1.evaluate("foobar.dummy.baz").toInt(), 42);
++    QCOMPARE(engine2.evaluate("foobar.dummy.baz").toInt(), 43);
++}
++
+ void tst_QJSEngine::gcWithNestedDataStructure()
+ {
+     // The GC must be able to traverse deeply nested objects, otherwise this
+diff --git a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml
+new file mode 100644
+index 0000000000..206133bb39
+--- /dev/null
++++ b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml
+@@ -0,0 +1,11 @@
++import QtQuick 2.8
++
++ListView {
++    id: root
++    width: 200
++    height: 200
++
++    delegate: Text {
++        text: display
++    }
++}
+diff --git a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
+index 35f1e2c94d..1722447830 100644
+--- a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
++++ b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
+@@ -27,6 +27,8 @@
+ ****************************************************************************/
+ 
+ #include <QtTest/qtest.h>
++#include <QtCore/QConcatenateTablesProxyModel>
++#include <QtGui/QStandardItemModel>
+ #include <QtQml/qqmlcomponent.h>
+ #include <QtQmlModels/private/qqmldelegatemodel_p.h>
+ #include <QtQuick/qquickview.h>
+@@ -47,6 +49,7 @@ private slots:
+     void filterOnGroup_removeWhenCompleted();
+     void qtbug_86017();
+     void contextAccessedByHandler();
++    void redrawUponColumnChange();
+ };
+ 
+ class AbstractItemModel : public QAbstractItemModel
+@@ -186,6 +189,30 @@ void tst_QQmlDelegateModel::contextAccessedByHandler()
+     QVERIFY(root->property("works").toBool());
+ }
+ 
++void tst_QQmlDelegateModel::redrawUponColumnChange()
++{
++    QStandardItemModel m1;
++    m1.appendRow({
++            new QStandardItem("Banana"),
++            new QStandardItem("Coconut"),
++    });
++
++    QQuickView view(testFileUrl("redrawUponColumnChange.qml"));
++    QCOMPARE(view.status(), QQuickView::Ready);
++    view.show();
++    QQuickItem *root = view.rootObject();
++    root->setProperty("model", QVariant::fromValue<QObject *>(&m1));
++
++    QObject *item = root->property("currentItem").value<QObject *>();
++    QVERIFY(item);
++    QCOMPARE(item->property("text").toString(), "Banana");
++
++    QVERIFY(root);
++    m1.removeColumn(0);
++
++    QCOMPARE(item->property("text").toString(), "Coconut");
++}
++
+ QTEST_MAIN(tst_QQmlDelegateModel)
+ 
+ #include "tst_qqmldelegatemodel.moc"
+diff --git a/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp b/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
+index 5d635aa63b..824fd89e5b 100644
+--- a/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
++++ b/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
+@@ -76,10 +76,10 @@ void tst_qv4mm::multiWrappedQObjects()
+         QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 1);
+         QCOMPARE(engine2.memoryManager->m_pendingFreedObjectWrapperValue.size(), 0);
+ 
+-        // Moves the additional WeakValue from m_multiplyWrappedQObjects to
+-        // m_pendingFreedObjectWrapperValue. It's still alive after all.
++        // The additional WeakValue from m_multiplyWrappedQObjects hasn't been moved
++        // to m_pendingFreedObjectWrapperValue yet. It's still alive after all.
+         engine1.memoryManager->runGC();
+-        QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 2);
++        QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 1);
+ 
+         // engine2 doesn't own the object as engine1 was the first to wrap it above.
+         // Therefore, no effect here.
+diff --git a/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml b/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml
+new file mode 100644
+index 0000000000..889e480f3b
+--- /dev/null
++++ b/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml
+@@ -0,0 +1,13 @@
++import QtQuick 2.6
++
++Item {
++    visible: true
++    Item {
++        visible: false
++        Item {
++            objectName: "hiddenChild"
++            activeFocusOnTab: true
++            focus: true
++        }
++    }
++}
+diff --git a/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp b/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+index c8f251dbe1..c8ef36ee68 100644
+--- a/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
++++ b/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+@@ -67,6 +67,7 @@ private slots:
+     void activeFocusOnTab10();
+     void activeFocusOnTab_infiniteLoop_data();
+     void activeFocusOnTab_infiniteLoop();
++    void activeFocusOnTab_infiniteLoopControls();
+ 
+     void nextItemInFocusChain();
+     void nextItemInFocusChain2();
+@@ -1057,6 +1058,17 @@ void tst_QQuickItem::activeFocusOnTab_infiniteLoop()
+     QCOMPARE(item, window->rootObject());
+ }
+ 
++
++void tst_QQuickItem::activeFocusOnTab_infiniteLoopControls()
++{
++    auto source = testFileUrl("activeFocusOnTab_infiniteLoop3.qml");
++    QScopedPointer<QQuickView>window(new QQuickView());
++    window->setSource(source);
++    window->show();
++    QVERIFY(window->errors().isEmpty());
++    QTest::keyClick(window.get(), Qt::Key_Tab); // should not hang
++}
++
+ void tst_QQuickItem::nextItemInFocusChain()
+ {
+     if (!qt_tab_all_widgets())
+Submodule qtdoc c0c7bf07...79d6ef69:
+Submodule qtimageformats 2dcf2899..abe44c0f:
+diff --git a/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp b/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
+index dde783c..1bf9074 100644
+--- a/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
+@@ -462,8 +462,12 @@ static bool parseIconEntryInfo(ICNSEntry &icon)
+     if (isIconCompressed(icon))
+         return true;
+     // Icon depth:
+-    if (!depth.isEmpty())
+-        icon.depth = ICNSEntry::Depth(depth.toUInt());
++    if (!depth.isEmpty()) {
++        const uint depthUInt = depth.toUInt();
++        if (depthUInt > 32)
++            return false;
++        icon.depth = ICNSEntry::Depth(depthUInt);
++    }
+     // Try mono if depth not found
+     if (icon.depth == ICNSEntry::DepthUnknown)
+         icon.depth = ICNSEntry::DepthMono;
+@@ -515,6 +519,9 @@ static bool parseIconEntryInfo(ICNSEntry &icon)
+         }
+         icon.height = icon.width;
+     }
++    // Sanity check
++    if (icon.width == 0 || icon.width > 4096)
++        return false;
+     return true;
+ }
+ 
+@@ -685,7 +692,7 @@ bool QICNSHandler::canRead() const
+ bool QICNSHandler::read(QImage *outImage)
+ {
+     QImage img;
+-    if (!ensureScanned()) {
++    if (!ensureScanned() || m_currentIconIndex >= m_icons.size()) {
+         qWarning("QICNSHandler::read(): The device wasn't parsed properly!");
+         return false;
+     }
+@@ -892,7 +899,7 @@ bool QICNSHandler::scanDevice()
+             return false;
+ 
+         const qint64 blockDataOffset = device()->pos();
+-        if (!isBlockHeaderValid(blockHeader)) {
++        if (!isBlockHeaderValid(blockHeader, ICNSBlockHeaderSize + filelength - blockDataOffset)) {
+             qWarning("QICNSHandler::scanDevice(): Failed, bad header at pos %s. OSType \"%s\", length %u",
+                      QByteArray::number(blockDataOffset).constData(),
+                      nameFromOSType(blockHeader.ostype).constData(), blockHeader.length);
+@@ -927,11 +934,14 @@ bool QICNSHandler::scanDevice()
+         case ICNSBlockHeader::TypeOdrp:
+             // Icns container seems to have an embedded icon variant container
+             // Let's start a scan for entries
+-            while (device()->pos() < nextBlockOffset) {
++            while (!stream.atEnd() && device()->pos() < nextBlockOffset) {
+                 ICNSBlockHeader icon;
+                 stream >> icon;
++                if (stream.status() != QDataStream::Ok)
++                    return false;
+                 // Check for incorrect variant entry header and stop scan
+-                if (!isBlockHeaderValid(icon, blockDataLength))
++                quint64 remaining = blockDataLength - (device()->pos() - blockDataOffset);
++                if (!isBlockHeaderValid(icon, ICNSBlockHeaderSize + remaining))
+                     break;
+                 if (!addEntry(icon, device()->pos(), blockHeader.ostype))
+                     return false;
+@@ -1003,7 +1013,7 @@ bool QICNSHandler::scanDevice()
+             break;
+         }
+     }
+-    return true;
++    return (m_icons.size() > 0);
+ }
+ 
+ const ICNSEntry &QICNSHandler::getIconMask(const ICNSEntry &icon) const
+diff --git a/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp b/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
+index 5082023..cb34374 100644
+--- a/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
++++ b/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
+@@ -43,6 +43,7 @@
+ #include "qimage.h"
+ #include "qvariant.h"
+ #include "qcolor.h"
++#include "qimagereader.h"
+ 
+ #include <jasper/jasper.h>
+ #include <math.h> // for pow
+@@ -333,16 +334,46 @@ private:
+ Jpeg2000JasperReader::Jpeg2000JasperReader(QIODevice *iod, SubFormat format)
+     : jasperOk(true), ioDevice(iod), format(format), hasAlpha(false)
+ {
++#if JAS_VERSION_MAJOR < 3
+     if (jas_init()) {
+         jasperOk = false;
+         qDebug("Jasper Library initialization failed");
+     }
++#else
++    jas_conf_clear();
++#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
++    jas_conf_set_max_mem_usage(QImageReader::allocationLimit() * 1024 * 1024);
++#else
++    // 128MB seems to be enough.
++    jas_conf_set_max_mem_usage(128 * 1024 * 1024);
++#endif
++    if (jas_init_library()) {
++        jasperOk = false;
++        qDebug("Jasper library initialization failed");
++    }
++    if (jas_init_thread()) {
++        jas_cleanup_library();
++        jasperOk = false;
++        qDebug("Jasper thread initialization failed");
++    }
++#endif
+ }
+ 
+ Jpeg2000JasperReader::~Jpeg2000JasperReader()
+ {
++#if JAS_VERSION_MAJOR < 3
+     if (jasperOk)
+         jas_cleanup();
++#else
++    if (jasperOk) {
++        if (jas_cleanup_thread()) {
++            qDebug("Jasper thread cleanup failed");
++        }
++        if (jas_cleanup_library()) {
++            qDebug("Jasper library cleanup failed");
++        }
++    }
++#endif
+ }
+ 
+ /*! \internal
+@@ -857,7 +888,7 @@ bool Jpeg2000JasperReader::write(const QImage &image, int quality)
+     }
+ 
+     // Open an empty jasper stream that grows automatically
+-    jas_stream_t * memory_stream = jas_stream_memopen(0, -1);
++    jas_stream_t * memory_stream = jas_stream_memopen(0, 0);
+ 
+     // Jasper wants a non-const string.
+     char *str = qstrdup(jasperFormatString.toLatin1().constData());
+diff --git a/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp b/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
+index 1386750..ac8956c 100644
+--- a/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
+@@ -361,6 +361,8 @@ bool QTiffHandler::read(QImage *image)
+     }
+ 
+     TIFF *const tiff = d->tiff;
++    if (TIFFIsTiled(tiff) && TIFFTileSize64(tiff) > uint64_t(image->sizeInBytes())) // Corrupt image
++        return false;
+     const quint32 width = d->size.width();
+     const quint32 height = d->size.height();
+ 
+diff --git a/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp b/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
+index 82d38cb..d02eb05 100644
+--- a/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
+@@ -45,6 +45,7 @@
+ #include <qdebug.h>
+ #include <qpainter.h>
+ #include <qvariant.h>
++#include <QtEndian>
+ 
+ static const int riffHeaderSize = 12; // RIFF_HEADER_SIZE from webp/format_constants.h
+ 
+@@ -102,21 +103,23 @@ bool QWebpHandler::ensureScanned() const
+ 
+     m_scanState = ScanError;
+ 
+-    if (device()->isSequential()) {
+-        qWarning() << "Sequential devices are not supported";
++    QWebpHandler *that = const_cast<QWebpHandler *>(this);
++    const int headerBytesNeeded = sizeof(WebPBitstreamFeatures);
++    QByteArray header = device()->peek(headerBytesNeeded);
++    if (header.size() < headerBytesNeeded)
+         return false;
+-    }
+ 
+-    qint64 oldPos = device()->pos();
+-    device()->seek(0);
+-
+-    QWebpHandler *that = const_cast<QWebpHandler *>(this);
+-    QByteArray header = device()->peek(sizeof(WebPBitstreamFeatures));
++    // We do no random access during decoding, just a readAll() of the whole image file. So if
++    // if it is all available already, we can accept a sequential device. The riff header contains
++    // the file size minus 8 bytes header
++    qint64 byteSize = qFromLittleEndian<quint32>(header.constData() + 4);
++    if (device()->isSequential() && device()->bytesAvailable() < byteSize + 8) {
++        qWarning() << "QWebpHandler: Insufficient data available in sequential device";
++        return false;
++    }
+     if (WebPGetFeatures((const uint8_t*)header.constData(), header.size(), &(that->m_features)) == VP8_STATUS_OK) {
+         if (m_features.has_animation) {
+             // For animation, we have to read and scan whole file to determine loop count and images count
+-            device()->seek(oldPos);
+-
+             if (that->ensureDemuxer()) {
+                 that->m_loop = WebPDemuxGetI(m_demuxer, WEBP_FF_LOOP_COUNT);
+                 that->m_frameCount = WebPDemuxGetI(m_demuxer, WEBP_FF_FRAME_COUNT);
+@@ -126,17 +129,13 @@ bool QWebpHandler::ensureScanned() const
+                 if (that->m_features.has_alpha)
+                     that->m_composited->fill(Qt::transparent);
+ 
+-                // We do not reset device position since we have read in all data
+                 m_scanState = ScanSuccess;
+-                return true;
+             }
+         } else {
+             m_scanState = ScanSuccess;
+         }
+     }
+ 
+-    device()->seek(oldPos);
+-
+     return m_scanState == ScanSuccess;
+ }
+ 
+@@ -159,7 +158,7 @@ bool QWebpHandler::ensureDemuxer()
+ 
+ bool QWebpHandler::read(QImage *image)
+ {
+-    if (!ensureScanned() || device()->isSequential() || !ensureDemuxer())
++    if (!ensureScanned() || !ensureDemuxer())
+         return false;
+ 
+     QRect prevFrameRect;
+Submodule qtlocation 98a5c511..f991e28c:
+diff --git a/qtlocation/src/location/configure.json b/qtlocation/src/location/configure.json
+index 6d01a9a3..d1e623a1 100644
+--- a/qtlocation/src/location/configure.json
++++ b/qtlocation/src/location/configure.json
+@@ -9,7 +9,7 @@
+             "label": "Qt.labs.location experimental QML plugin",
+             "purpose": "Provides experimental QtLocation QML types",
+             "section": "Location",
+-            "condition": "config.opengl",
++            "condition": "features.opengl",
+             "output": [ "privateFeature" ]
+         },
+         "geoservices_osm": {
+diff --git a/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp b/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
+index a978573d..11e1466f 100644
+--- a/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
++++ b/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
+@@ -158,7 +158,7 @@ void QGeoMapObjectQSGSupport::updateMapObjects(QSGNode *root, QQuickWindow *wind
+     if (!root)
+         return;
+ 
+-    if (m_mapObjectsRootNode && m_mapObjectsRootNode->parent())
++    if (m_mapObjectsRootNode && !m_mapObjectsRootNode->parent())
+         root->appendChildNode(m_mapObjectsRootNode.get());
+ 
+     if (!m_mapObjectsRootNode) {
+diff --git a/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
+index 5a40467e..d123c6a8 100644
+--- a/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
+@@ -59,8 +59,10 @@ QT_BEGIN_NAMESPACE
+ static const QString kPrefixEsri(QStringLiteral("esri."));
+ static const QString kParamUserAgent(kPrefixEsri + QStringLiteral("useragent"));
+ 
+-static const QString kUrlGeocode(QStringLiteral("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates"));
+-static const QString kUrlReverseGeocode(QStringLiteral("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode"));
++static const QString kUrlGeocode(QStringLiteral("https://geocode.arcgis.com/arcgis/rest/services/"
++                                                "World/GeocodeServer/findAddressCandidates"));
++static const QString kUrlReverseGeocode(QStringLiteral(
++        "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode"));
+ 
+ static QString addressToQuery(const QGeoAddress &address)
+ {
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
+index 17492d94..96c12b1b 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
+@@ -46,7 +46,8 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-// JSON reference: http://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
++// JSON reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
+ 
+ static const QString kErrorMessage(QStringLiteral("Error %1: %2."));
+ static const QString kErrorJson(QStringLiteral("Error: invalide JSON document."));
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
+index 8cadfb29..92b6bb13 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
+@@ -44,7 +44,8 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-// JSON reference: http://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
++// JSON reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
+ 
+ GeoRouteReplyEsri::GeoRouteReplyEsri(QNetworkReply *reply, const QGeoRouteRequest &request,
+                                      QObject *parent) :
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
+index 0e6bc2c7..ed613f4b 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
+@@ -48,7 +48,8 @@ static const QString kPrefixEsri(QStringLiteral("esri."));
+ static const QString kParamUserAgent(kPrefixEsri + QStringLiteral("useragent"));
+ static const QString kParamToken(kPrefixEsri + QStringLiteral("token"));
+ 
+-static const QString kUrlRouting(QStringLiteral("http://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve"));
++static const QString kUrlRouting(QStringLiteral(
++        "https://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve"));
+ 
+ GeoRoutingManagerEngineEsri::GeoRoutingManagerEngineEsri(const QVariantMap &parameters,
+                                                          QGeoServiceProvider::Error *error,
+@@ -70,7 +71,8 @@ GeoRoutingManagerEngineEsri::~GeoRoutingManagerEngineEsri()
+ {
+ }
+ 
+-// REST reference: http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
++// REST reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
+ 
+ QGeoRouteReply *GeoRoutingManagerEngineEsri::calculateRoute(const QGeoRouteRequest &request)
+ {
+@@ -125,7 +127,7 @@ void GeoRoutingManagerEngineEsri::replyError(QGeoRouteReply::Error errorCode, co
+ QString GeoRoutingManagerEngineEsri::preferedDirectionLangage()
+ {
+     // list of supported langages is defined in:
+-    // http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
++    // https://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
+     const QStringList supportedLanguages = {
+         "ar", // Generate directions in Arabic
+         "cs", // Generate directions in Czech
+diff --git a/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
+index 5d15835d..24148f95 100644
+--- a/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
+@@ -230,7 +230,8 @@ QGeoMap *GeoTiledMappingManagerEngineEsri::createMap()
+ // ${y} = Y
+ // ${token} = Token
+ 
+-// template = 'http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{{z}}/{{y}}/{{x}}.png'
++// template =
++// 'https://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{{z}}/{{y}}/{{x}}.png'
+ 
+ bool GeoTiledMappingManagerEngineEsri::initializeMapSources(QGeoServiceProvider::Error *error,
+                                                             QString *errorString,
+diff --git a/qtlocation/src/plugins/geoservices/esri/maps.json b/qtlocation/src/plugins/geoservices/esri/maps.json
+index 8167ae7d..862e087d 100644
+--- a/qtlocation/src/plugins/geoservices/esri/maps.json
++++ b/qtlocation/src/plugins/geoservices/esri/maps.json
+@@ -6,8 +6,8 @@
+             "description": "ArcGIS Online World Street Map",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=3b93337983e9436f8db950e38a8629af'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=3b93337983e9436f8db950e38a8629af'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -16,8 +16,8 @@
+             "": "ArcGIS Online World Imagery",
+             "mobile": true,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -26,8 +26,8 @@
+             "description": "ArcGIS Online World Terrain Base",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=c61ad8ab017d49e1a82f580ee1298931'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=c61ad8ab017d49e1a82f580ee1298931'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -36,8 +36,8 @@
+             "description": "ArcGIS Online World Topography",
+             "mobile": true,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=30e5fe3149c34df1ba922e6f5bbf808f'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=30e5fe3149c34df1ba922e6f5bbf808f'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -46,8 +46,8 @@
+             "description": "This map presents land cover and detailed topographic maps for the United States.",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=99cd5fbd98934028802b4f797c4b1732'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=99cd5fbd98934028802b4f797c4b1732'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -56,8 +56,8 @@
+             "description": "National Geographic World Map",
+             "mobile": false,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=b9b1b422198944fbbd5250b3241691b6'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=b9b1b422198944fbbd5250b3241691b6'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -66,8 +66,8 @@
+             "description": "Thematic content providing a neutral background with minimal colors",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=ed712cb1db3e4bae9e85329040fb9a49'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=ed712cb1db3e4bae9e85329040fb9a49'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -76,8 +76,8 @@
+             "description": "Natural Earth physical map for the world",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=c4ec722a1cd34cf0a23904aadf8923a0'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=c4ec722a1cd34cf0a23904aadf8923a0'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -86,8 +86,8 @@
+             "description": "Portrays surface elevation as shaded relief",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=9c5370d0b54f4de1b48a3792d7377ff2'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=9c5370d0b54f4de1b48a3792d7377ff2'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -96,8 +96,8 @@
+             "description": "This map is designed to be used as a basemap by marine GIS professionals and as a reference map by anyone interested in ocean data",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=1e126e7520f9466c9ca28b8f28b5e500'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=1e126e7520f9466c9ca28b8f28b5e500'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -106,8 +106,8 @@
+             "description": "Thematic content providing a neutral background with minimal colors",
+             "mobile": false,
+             "night": true,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=a284a9b99b3446a3910d4144a50990f6'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=a284a9b99b3446a3910d4144a50990f6'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -116,8 +116,8 @@
+             "description": "DeLorme’s topographic basemap is a seamless global data set that portrays transportation, hydrography, jurisdiction boundaries, and major geographic features",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/Specialty/DeLorme_World_Base_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=b165c3df453e4be6b5ac4fdb241effbe'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/Specialty/DeLorme_World_Base_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=b165c3df453e4be6b5ac4fdb241effbe'>Esri</a> contributors"
+         }
+     ]
+ }
+diff --git a/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
+index 3858ddf5..af66f28e 100644
+--- a/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
+@@ -63,8 +63,10 @@ static const QString kCountriesKey(QStringLiteral("detailedCountries"));
+ static const QString kLocalizedNamesKey(QStringLiteral("localizedNames"));
+ static const QString kMaxLocationsKey(QStringLiteral("maxLocations"));
+ 
+-static const QUrl kUrlGeocodeServer("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer?f=pjson");
+-static const QUrl kUrlFindAddressCandidates("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates");
++static const QUrl kUrlGeocodeServer(
++        "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer?f=pjson");
++static const QUrl kUrlFindAddressCandidates("https://geocode.arcgis.com/arcgis/rest/services/World/"
++                                            "GeocodeServer/findAddressCandidates");
+ 
+ PlaceManagerEngineEsri::PlaceManagerEngineEsri(const QVariantMap &parameters, QGeoServiceProvider::Error *error,
+                                                QString *errorString) :
+Submodule qtmultimedia f0344079..0d7cc33a:
+diff --git a/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp b/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
+index 2b5325132..b68b4af1b 100644
+--- a/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
++++ b/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
+@@ -402,6 +402,8 @@ int QPulseAudioInput::bytesReady() const
+ 
+ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ {
++    Q_ASSERT(data != nullptr || len == 0);
++
+     m_bytesAvailable = checkBytesReady();
+ 
+     setError(QAudio::NoError);
+@@ -411,7 +413,8 @@ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ 
+     if (!m_pullMode && !m_tempBuffer.isEmpty()) {
+         readBytes = qMin(static_cast<int>(len), m_tempBuffer.size());
+-        memcpy(data, m_tempBuffer.constData(), readBytes);
++        if (readBytes)
++            memcpy(data, m_tempBuffer.constData(), readBytes);
+         m_totalTimeValue += readBytes;
+ 
+         if (readBytes < m_tempBuffer.size()) {
+@@ -502,9 +505,10 @@ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ 
+ void QPulseAudioInput::applyVolume(const void *src, void *dest, int len)
+ {
++    Q_ASSERT((src && dest) || len == 0);
+     if (m_volume < 1.f)
+         QAudioHelperInternal::qMultiplySamples(m_volume, m_format, src, dest, len);
+-    else
++    else if (len)
+         memcpy(dest, src, len);
+ }
+ 
+Submodule qtpim 02efef5e...f9a8f0fc (commits not present)
+Submodule qtquick3d b85cf622..47defc8b:
+diff --git a/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro b/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
+index ca5c499e..174a075b 100644
+--- a/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
++++ b/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
+@@ -10,7 +10,7 @@ QT_FOR_CONFIG += assetimporters-private
+ include($$OUT_PWD/../qtassetimporters-config.pri)
+ 
+ qtConfig(system-assimp):!if(cross_compile:host_build) {
+-    QMAKE_USE_PRIVATE += assimp
++    QMAKE_USE_PRIVATE += quick3d-assimp
+ } else {
+     include(../../../3rdparty/assimp/assimp.pri)
+ }
+Submodule qtquickcontrols2 3a657dc0..56ce8233:
+diff --git a/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp b/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
+index e5fe734f7..e36922775 100644
+--- a/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
++++ b/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
+@@ -38,6 +38,7 @@
+ #include "qwidgetplatformmenuitem_p.h"
+ 
+ #include <QtGui/qwindow.h>
++#include <QtGui/private/qhighdpiscaling_p.h>
+ #include <QtWidgets/qmenu.h>
+ #include <QtWidgets/qaction.h>
+ 
+@@ -145,7 +146,7 @@ void QWidgetPlatformMenu::showPopup(const QWindow *window, const QRect &targetRe
+ 
+     QPoint targetPos = targetRect.bottomLeft();
+     if (window)
+-        targetPos = window->mapToGlobal(targetPos);
++        targetPos = window->mapToGlobal(QHighDpi::fromNativeLocalPosition(targetPos, window));
+ 
+     const QWidgetPlatformMenuItem *widgetItem = qobject_cast<const QWidgetPlatformMenuItem *>(item);
+     m_menu->popup(targetPos, widgetItem ? widgetItem->action() : nullptr);
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
+index 950e4e099..b81fbea0b 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
+@@ -387,6 +387,17 @@ void QQuickAbstractButtonPrivate::itemImplicitHeightChanged(QQuickItem *item)
+         emit q->implicitIndicatorHeightChanged();
+ }
+ 
++void QQuickAbstractButtonPrivate::itemDestroyed(QQuickItem *item)
++{
++    Q_Q(QQuickAbstractButton);
++    QQuickControlPrivate::itemDestroyed(item);
++    if (item == indicator) {
++        indicator = nullptr;
++        emit q->implicitIndicatorWidthChanged();
++        emit q->implicitIndicatorHeightChanged();
++    }
++}
++
+ QQuickAbstractButton *QQuickAbstractButtonPrivate::findCheckedButton() const
+ {
+     Q_Q(const QQuickAbstractButton);
+@@ -1176,6 +1187,12 @@ QAccessible::Role QQuickAbstractButton::accessibleRole() const
+     }
+     return QAccessible::Button;
+ }
++
++void QQuickAbstractButton::accessiblePressAction()
++{
++    Q_D(QQuickAbstractButton);
++    d->trigger();
++}
+ #endif
+ 
+ QT_END_NAMESPACE
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
+index 0fa48980e..ab66220d0 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
+@@ -209,6 +209,7 @@ protected:
+ #if QT_CONFIG(accessibility)
+     void accessibilityActiveChanged(bool active) override;
+     QAccessible::Role accessibleRole() const override;
++    Q_INVOKABLE void accessiblePressAction();
+ #endif
+ 
+ private:
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
+index 9291c1a87..b729720f2 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
+@@ -109,6 +109,7 @@ public:
+ 
+     void itemImplicitWidthChanged(QQuickItem *item) override;
+     void itemImplicitHeightChanged(QQuickItem *item) override;
++    void itemDestroyed(QQuickItem *item) override;
+ 
+     // copied from qabstractbutton.cpp
+     static const int AUTO_REPEAT_DELAY = 300;
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp b/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
+index 2041e7741..8610cdfae 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
+@@ -145,7 +145,7 @@ int QQuickActionPrivate::ShortcutEntry::shortcutId() const
+ 
+ void QQuickActionPrivate::ShortcutEntry::grab(const QKeySequence &shortcut, bool enabled)
+ {
+-    if (shortcut.isEmpty())
++    if (shortcut.isEmpty() || m_shortcutId)
+         return;
+ 
+     Qt::ShortcutContext context = Qt::WindowShortcut; // TODO
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp b/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
+index f38c2b09c..6eed2a024 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
+@@ -225,6 +225,7 @@ void QQuickContainerPrivate::cleanup()
+     QObject::disconnect(contentModel, &QQmlObjectModel::countChanged, q, &QQuickContainer::countChanged);
+     QObject::disconnect(contentModel, &QQmlObjectModel::childrenChanged, q, &QQuickContainer::contentChildrenChanged);
+     delete contentModel;
++    contentModel = nullptr;
+ }
+ 
+ QQuickItem *QQuickContainerPrivate::itemAt(int index) const
+@@ -436,7 +437,7 @@ void QQuickContainerPrivate::contentChildren_clear(QQmlListProperty<QQuickItem>
+ void QQuickContainerPrivate::updateContentWidth()
+ {
+     Q_Q(QQuickContainer);
+-    if (hasContentWidth || qFuzzyCompare(contentWidth, implicitContentWidth))
++    if (hasContentWidth || qFuzzyCompare(contentWidth, implicitContentWidth) || !contentModel)
+         return;
+ 
+     contentWidth = implicitContentWidth;
+@@ -446,7 +447,7 @@ void QQuickContainerPrivate::updateContentWidth()
+ void QQuickContainerPrivate::updateContentHeight()
+ {
+     Q_Q(QQuickContainer);
+-    if (hasContentHeight || qFuzzyCompare(contentHeight, implicitContentHeight))
++    if (hasContentHeight || qFuzzyCompare(contentHeight, implicitContentHeight) || !contentModel)
+         return;
+ 
+     contentHeight = implicitContentHeight;
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp b/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
+index bbbd0e622..1f4b47343 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
+@@ -845,6 +845,13 @@ void QQuickControlPrivate::executeBackground(bool complete)
+         quickCompleteDeferred(q, backgroundName(), background);
+ }
+ 
++/*
++    \internal
++
++    Hides an item that was replaced by a newer one, rather than
++    deleting it, as the item is typically created in QML and hence
++    we don't own it.
++*/
+ void QQuickControlPrivate::hideOldItem(QQuickItem *item)
+ {
+     if (!item)
+@@ -863,6 +870,29 @@ void QQuickControlPrivate::hideOldItem(QQuickItem *item)
+ #endif
+ }
+ 
++/*
++    \internal
++
++    Named "unhide" because it's used for cases where an item
++    that was previously hidden by \l hideOldItem() wants to be
++    shown by a control again, such as a ScrollBar in ScrollView.
++*/
++void QQuickControlPrivate::unhideOldItem(QQuickControl *control, QQuickItem *item)
++{
++    Q_ASSERT(item);
++    qCDebug(lcItemManagement) << "unhiding old item" << item;
++
++    item->setVisible(true);
++    item->setParentItem(control);
++
++#if QT_CONFIG(accessibility)
++    // Add the item back in to the accessibility tree.
++    QQuickAccessibleAttached *accessible = accessibleAttached(item);
++    if (accessible)
++        accessible->setIgnored(false);
++#endif
++}
++
+ void QQuickControlPrivate::updateBaselineOffset()
+ {
+     Q_Q(QQuickControl);
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h b/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
+index 8e979079e..a6e624c91 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
+@@ -173,6 +173,7 @@ public:
+     virtual void executeBackground(bool complete = false);
+ 
+     static void hideOldItem(QQuickItem *item);
++    static void unhideOldItem(QQuickControl *control, QQuickItem *item);
+ 
+     void updateBaselineOffset();
+ 
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp b/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
+index e6db14eb5..6197d1547 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
+@@ -237,7 +237,7 @@ static QRectF alignedRect(Qt::LayoutDirection direction, Qt::Alignment alignment
+ void QQuickDialogButtonBoxPrivate::resizeContent()
+ {
+     Q_Q(QQuickDialogButtonBox);
+-    if (!contentItem)
++    if (!contentItem || !contentModel)
+         return;
+ 
+     QRectF geometry = q->boundingRect().adjusted(q->leftPadding(), q->topPadding(), -q->rightPadding(), -q->bottomPadding());
+@@ -322,6 +322,9 @@ void QQuickDialogButtonBoxPrivate::updateLayout()
+ qreal QQuickDialogButtonBoxPrivate::getContentWidth() const
+ {
+     Q_Q(const QQuickDialogButtonBox);
++    if (!contentModel)
++        return 0;
++
+     const int count = contentModel->count();
+     const qreal totalSpacing = qMax(0, count - 1) * spacing;
+     qreal totalWidth = totalSpacing;
+@@ -341,6 +344,9 @@ qreal QQuickDialogButtonBoxPrivate::getContentWidth() const
+ qreal QQuickDialogButtonBoxPrivate::getContentHeight() const
+ {
+     Q_Q(const QQuickDialogButtonBox);
++    if (!contentModel)
++        return 0;
++
+     const int count = contentModel->count();
+     qreal maxHeight = 0;
+     for (int i = 0; i < count; ++i) {
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp b/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
+index 91bd59184..0ce518f84 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
+@@ -399,8 +399,11 @@ void QQuickOverlay::itemChange(ItemChange change, const ItemChangeData &data)
+     Q_D(QQuickOverlay);
+     QQuickItem::itemChange(change, data);
+ 
+-    if (change == ItemChildAddedChange || change == ItemChildRemovedChange)
++    if (change == ItemChildAddedChange || change == ItemChildRemovedChange) {
+         setVisible(!d->allDrawers.isEmpty() || !childItems().isEmpty());
++        if (data.item->parent() == d->mouseGrabberPopup)
++            d->setMouseGrabberPopup(nullptr);
++    }
+ }
+ 
+ void QQuickOverlay::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp b/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
+index 4e2f509db..1c4b308cd 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
+@@ -797,6 +797,14 @@ void QQuickScrollBarAttachedPrivate::initHorizontal()
+     if (parent && parent == flickable->parentItem())
+         horizontal->stackAfter(flickable);
+ 
++    // If a scroll bar was previously hidden (due to e.g. setting a new contentItem
++    // on a ScrollView), we need to make sure that we un-hide it.
++    // We don't bother checking if the item is actually the old one, because
++    // if it's not, all of the things the function does (setting parent, visibility, etc.)
++    // should be no-ops anyway.
++    if (auto control = qobject_cast<QQuickControl*>(q_ptr->parent()))
++        QQuickControlPrivate::unhideOldItem(control, horizontal);
++
+     layoutHorizontal();
+     horizontal->setSize(area->property("widthRatio").toReal());
+     horizontal->setPosition(area->property("xPosition").toReal());
+@@ -818,6 +826,9 @@ void QQuickScrollBarAttachedPrivate::initVertical()
+     if (parent && parent == flickable->parentItem())
+         vertical->stackAfter(flickable);
+ 
++    if (auto control = qobject_cast<QQuickControl*>(q_ptr->parent()))
++        QQuickControlPrivate::unhideOldItem(control, vertical);
++
+     layoutVertical();
+     vertical->setSize(area->property("heightRatio").toReal());
+     vertical->setPosition(area->property("yPosition").toReal());
+diff --git a/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml b/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
+index 0e8b08352..cd4931184 100644
+--- a/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
++++ b/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
+@@ -576,4 +576,51 @@ TestCase {
+         verify(newHorizontalScrollBar.visible)
+         verify(!oldHorizontalScrollBar.visible)
+     }
++
++    Component {
++        id: bindingToContentItemAndStandaloneFlickable
++
++        Item {
++            width: 200
++            height: 200
++
++            property alias scrollView: scrollView
++
++            ScrollView {
++                id: scrollView
++                anchors.fill: parent
++                contentItem: listView
++
++                property Item someBinding: contentItem
++            }
++            ListView {
++                id: listView
++                model: 10
++                delegate: ItemDelegate {
++                    text: modelData
++                    width: listView.width
++                }
++            }
++        }
++    }
++
++    // Tests that scroll bars show up for a ScrollView where
++    // - its contentItem is declared as a standalone, separate item
++    // - there is a binding to contentItem (which causes a default Flickable to be created)
++    function test_bindingToContentItemAndStandaloneFlickable() {
++        let root = createTemporaryObject(bindingToContentItemAndStandaloneFlickable, testCase)
++        verify(root)
++
++        let control = root.scrollView
++        let verticalScrollBar = control.ScrollBar.vertical
++        let horizontalScrollBar = control.ScrollBar.horizontal
++        compare(verticalScrollBar.parent, control)
++        compare(horizontalScrollBar.parent, control)
++        verify(verticalScrollBar.visible)
++        verify(horizontalScrollBar.visible)
++
++        mouseDrag(verticalScrollBar, verticalScrollBar.width / 2, verticalScrollBar.height / 2, 0, 50)
++        verify(verticalScrollBar.active)
++        verify(horizontalScrollBar.active)
++    }
+ }
+diff --git a/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml b/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
+index b3fab41ca..10b6baa02 100644
+--- a/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
++++ b/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
+@@ -608,4 +608,27 @@ TestCase {
+         mouseClick(control.indicator)
+         verify(control.activeFocus)
+     }
++
++    Component {
++        id: deletionOrder1
++        Item {
++            Image { id: innerImage }
++            Switch { indicator: innerImage }
++        }
++    }
++
++    Component {
++        id: deletionOrder2
++        Item {
++            Switch { indicator: innerImage }
++            Image { id: innerImage }
++        }
++    }
++
++    function test_deletionOrder() {
++        var control1 = createTemporaryObject(deletionOrder1, testCase)
++        verify(control1)
++        var control2 = createTemporaryObject(deletionOrder2, testCase)
++        verify(control2)
++    }
+ }
+diff --git a/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml b/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml
+new file mode 100644
+index 000000000..9e4598b9f
+--- /dev/null
++++ b/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml
+@@ -0,0 +1,78 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the test suite of the Qt Toolkit.
++**
++** $QT_BEGIN_LICENSE:BSD$
++** Commercial License Usage
++** Licensees holding valid commercial Qt licenses may use this file in
++** accordance with the commercial license agreement provided with the
++** Software or, alternatively, in accordance with the terms contained in
++** a written agreement between you and The Qt Company. For licensing terms
++** and conditions see https://www.qt.io/terms-conditions. For further
++** information use the contact form at https://www.qt.io/contact-us.
++**
++** BSD License Usage
++** Alternatively, you may use this file under the terms of the BSD license
++** as follows:
++**
++** "Redistribution and use in source and binary forms, with or without
++** modification, are permitted provided that the following conditions are
++** met:
++**   * Redistributions of source code must retain the above copyright
++**     notice, this list of conditions and the following disclaimer.
++**   * Redistributions in binary form must reproduce the above copyright
++**     notice, this list of conditions and the following disclaimer in
++**     the documentation and/or other materials provided with the
++**     distribution.
++**   * Neither the name of The Qt Company Ltd nor the names of its
++**     contributors may be used to endorse or promote products derived
++**     from this software without specific prior written permission.
++**
++**
++** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
++** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
++** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
++** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
++** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
++** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
++** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
++** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
++** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
++** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
++** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
++**
++** $QT_END_LICENSE$
++**
++****************************************************************************/
++
++import QtQuick 2.15
++import QtQuick.Controls 2.15
++
++ApplicationWindow {
++    id: window
++    width: 400
++    height: 400
++    title: "releaseAfterExitTransition"
++
++    property alias popup: popup
++    property alias modalPopup: modalPopup
++
++    Popup {
++        id: popup
++        y: parent.height - height
++        width: 50
++        height: 50
++    }
++
++    Popup {
++        id: modalPopup
++        modal: true
++        y: parent.height - height
++        width: 50
++        height: 50
++        exit:  Transition { PauseAnimation { duration: 100 } }
++    }
++}
+diff --git a/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp b/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
+index 54952d128..3d50e2dd4 100644
+--- a/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
++++ b/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
+@@ -100,6 +100,7 @@ private slots:
+     void invisibleToolTipOpen();
+     void centerInOverlayWithinStackViewItem();
+     void destroyDuringExitTransition();
++    void releaseAfterExitTransition();
+ };
+ 
+ void tst_QQuickPopup::initTestCase()
+@@ -1575,6 +1576,34 @@ void tst_QQuickPopup::destroyDuringExitTransition()
+     QVERIFY(!button->isDown());
+ }
+ 
++void tst_QQuickPopup::releaseAfterExitTransition()
++{
++    QQuickApplicationHelper helper(this, "releaseAfterExitTransition.qml");
++    QVERIFY2(helper.ready, helper.failureMessage());
++
++    QQuickWindow *window = helper.window;
++    window->show();
++    QVERIFY(QTest::qWaitForWindowActive(window));
++
++    QQuickOverlay *overlay = QQuickOverlay::overlay(window);
++    QQuickPopup *modalPopup = window->property("modalPopup").value<QQuickPopup *>();
++    QQuickPopup *popup = window->property("popup").value<QQuickPopup *>();
++
++    modalPopup->open();
++    QTRY_VERIFY(modalPopup->isOpened());
++
++    QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++    // wait until the transition is finished and the overlay hides itself
++    QTRY_VERIFY(!overlay->isVisible());
++    QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++
++    popup->open();
++    QTRY_VERIFY(popup->isOpened());
++    QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++    QTRY_VERIFY(!popup->isOpened());
++}
++
++
+ QTEST_QUICKCONTROLS_MAIN(tst_QQuickPopup)
+ 
+ #include "tst_qquickpopup.moc"
+Submodule qtscript 5be95f96...4d8e4bd2 (commits not present)
+Submodule qtspeech 17fc9fde..255845e2:
+diff --git a/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp b/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
+index 6eb74b8..bcc7dd1 100644
+--- a/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
++++ b/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
+@@ -357,7 +357,9 @@ QVector<QLocale> QTextToSpeechEngineSpeechd::availableLocales() const
+ 
+ QVector<QVoice> QTextToSpeechEngineSpeechd::availableVoices() const
+ {
+-    return m_voices.values(m_currentLocale.name()).toVector();
++    QList<QVoice> resultList = m_voices.values(m_currentLocale.name());
++    std::reverse(resultList.begin(), resultList.end());
++    return resultList.toVector();
+ }
+ 
+ // We have no way of knowing our own client_id since speech-dispatcher seems to be incomplete
+Submodule qtsvg 0c05780e..a7a0f249:
+diff --git a/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp b/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
+index 561e77e..12e0574 100644
+--- a/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
++++ b/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
+@@ -191,6 +191,8 @@ bool QSvgIOHandler::read(QImage *image)
+             }
+         }
+         if (!finalSize.isEmpty()) {
++            if (qMax(finalSize.width(), finalSize.height()) > 0xffff)
++                return false; // Assume corrupted file
+             image->fill(d->backColor.rgba());
+             QPainter p(image);
+             d->r.render(&p, bounds);
+diff --git a/qtsvg/src/svg/qsvghandler.cpp b/qtsvg/src/svg/qsvghandler.cpp
+index a5f877f..8dda563 100644
+--- a/qtsvg/src/svg/qsvghandler.cpp
++++ b/qtsvg/src/svg/qsvghandler.cpp
+@@ -1393,9 +1393,10 @@ static void parseFont(QSvgNode *node,
+         case FontSizeNone:
+             break;
+         case FontSizeValue: {
+-            QSvgHandler::LengthType dummy; // should always be pixel size
+-            fontStyle->setSize(qMin(parseLength(attributes.fontSize, dummy, handler),
+-                                    qreal(0xffff)));
++            QSvgHandler::LengthType type;
++            qreal fs = parseLength(attributes.fontSize, type, handler);
++            fs = convertToPixels(fs, true, type);
++            fontStyle->setSize(qMin(fs, qreal(0xffff)));
+         }
+             break;
+         default:
+@@ -2513,6 +2514,8 @@ static bool parseAnimateTransformNode(QSvgNode *parent,
+             ++s;
+         }
+     }
++    if (vals.count() % 3 != 0)
++        return false;
+ 
+     bool ok = true;
+     int begin = parseClockValue(beginStr, &ok);
+@@ -2576,6 +2579,8 @@ static QSvgNode *createCircleNode(QSvgNode *parent,
+     qreal ncx = toDouble(cx);
+     qreal ncy = toDouble(cy);
+     qreal nr  = toDouble(r);
++    if (nr < 0.0)
++        return nullptr;
+ 
+     QRectF rect(ncx-nr, ncy-nr, nr*2, nr*2);
+     QSvgNode *circle = new QSvgCircle(parent, rect);
+@@ -3046,15 +3051,16 @@ static QSvgStyleProperty *createRadialGradientNode(QSvgNode *node,
+ 
+     qreal ncx = 0.5;
+     qreal ncy = 0.5;
+-    qreal nr  = 0.5;
+     if (!cx.isEmpty())
+         ncx = toDouble(cx);
+     if (!cy.isEmpty())
+         ncy = toDouble(cy);
++
++    qreal nr = 0.0;
+     if (!r.isEmpty())
+         nr = toDouble(r);
+-    if (nr < 0.5)
+-        nr = 0.5;
++    if (nr <= 0.0)
++        return nullptr;
+ 
+     qreal nfx = ncx;
+     if (!fx.isEmpty())
+@@ -3350,7 +3356,9 @@ static QSvgNode *createTextNode(QSvgNode *parent,
+     //### editable and rotate not handled
+     QSvgHandler::LengthType type;
+     qreal nx = parseLength(x, type, handler);
++    nx = convertToPixels(nx, true, type);
+     qreal ny = parseLength(y, type, handler);
++    ny = convertToPixels(ny, true, type);
+ 
+     QSvgNode *text = new QSvgText(parent, QPointF(nx, ny));
+     return text;
+@@ -3691,9 +3699,7 @@ void QSvgHandler::parse()
+         case QXmlStreamReader::EndElement:
+             endElement(xml->name());
+             ++remainingUnfinishedElements;
+-            // if we are using somebody else's qxmlstreamreader
+-            // we should not read until the end of the stream
+-            done = !m_ownsReader && (xml->name() == QLatin1String("svg"));
++            done = (xml->name() == QLatin1String("svg"));
+             break;
+         case QXmlStreamReader::Characters:
+             characters(xml->text());
+diff --git a/qtsvg/src/svg/qsvgstructure.cpp b/qtsvg/src/svg/qsvgstructure.cpp
+index b89608b..89c9e4e 100644
+--- a/qtsvg/src/svg/qsvgstructure.cpp
++++ b/qtsvg/src/svg/qsvgstructure.cpp
+@@ -255,9 +255,13 @@ inline static bool isSupportedSvgFeature(const QString &str)
+     };
+ 
+     if (str.length() <= MAX_WORD_LENGTH && str.length() >= MIN_WORD_LENGTH) {
++        const char16_t unicode44 = str.at(44).unicode();
++        const char16_t unicode45 = str.at(45).unicode();
++        if (unicode44 >= sizeof(asso_values) || unicode45 >= sizeof(asso_values))
++            return false;
+         const int key = str.length()
+-                        + asso_values[str.at(45).unicode()]
+-                        + asso_values[str.at(44).unicode()];
++                        + asso_values[unicode45]
++                        + asso_values[unicode44];
+         if (key <= MAX_HASH_VALUE && key >= 0)
+             return str == QLatin1String(wordlist[key]);
+     }
+diff --git a/qtsvg/src/svg/qsvgtinydocument.cpp b/qtsvg/src/svg/qsvgtinydocument.cpp
+index 63d0797..19e7154 100644
+--- a/qtsvg/src/svg/qsvgtinydocument.cpp
++++ b/qtsvg/src/svg/qsvgtinydocument.cpp
+@@ -433,8 +433,16 @@ void QSvgTinyDocument::draw(QPainter *p, QSvgExtraStates &)
+     draw(p);
+ }
+ 
++static bool isValidMatrix(const QTransform &transform)
++{
++    qreal determinant = transform.determinant();
++    return qIsFinite(determinant);
++}
++
+ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect, const QRectF &sourceRect)
+ {
++    QTransform oldTransform = p->worldTransform();
++
+     QRectF target = targetRect;
+     if (target.isEmpty()) {
+         QPaintDevice *dev = p->device();
+@@ -487,6 +495,9 @@ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect,
+         }
+ #endif
+     }
++
++    if (!isValidMatrix(p->worldTransform()))
++        p->setWorldTransform(oldTransform);
+ }
+ 
+ QRectF QSvgTinyDocument::boundsOnElement(const QString &id) const
+diff --git a/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp b/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
+index 36c76ec..db71e02 100644
+--- a/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
++++ b/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
+@@ -86,6 +86,8 @@ private slots:
+     void oss_fuzz_23731();
+     void oss_fuzz_24131();
+     void oss_fuzz_24738();
++    void illegalAnimateTransform_data();
++    void illegalAnimateTransform();
+ 
+ #ifndef QT_NO_COMPRESS
+     void testGzLoading();
+@@ -1646,5 +1648,22 @@ void tst_QSvgRenderer::oss_fuzz_24738()
+     QSvgRenderer().load(QByteArray("<svg><path d=\"a 2 1e-212.....\">"));
+ }
+ 
++void tst_QSvgRenderer::illegalAnimateTransform_data()
++{
++    QTest::addColumn<QByteArray>("svg");
++
++    QTest::newRow("case1") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" values=\"8,0,5,0\">");
++    QTest::newRow("case2") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" values=\"1,2\">");
++    QTest::newRow("case3") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" from=\".. 5 2\" to=\"f\">");
++    QTest::newRow("case4") << QByteArray("<svg><animateTransform type=\"scale\" begin=\"1\" dur=\"2\" by=\"--,..\">");
++}
++
++void tst_QSvgRenderer::illegalAnimateTransform()
++{
++    QFETCH(QByteArray, svg);
++    QSvgRenderer renderer;
++    QVERIFY(!renderer.load(svg)); // also shouldn't assert
++}
++
+ QTEST_MAIN(tst_QSvgRenderer)
+ #include "tst_qsvgrenderer.moc"
+Submodule qttools 6914f7c8..090e526e:
+diff --git a/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp b/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
+index feab1e2d5..cbfb82507 100644
+--- a/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
++++ b/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
+@@ -445,7 +445,9 @@ bool HelpGeneratorPrivate::insertFiles(const QStringList &files, const QString &
+     if (filterSetId < 0)
+         return false;
+     ++filterSetId;
+-    for (int attId : qAsConst(filterAtts)) {
++    QList<int> attValues = filterAtts.values();
++    std::sort(attValues.begin(), attValues.end());
++    for (int attId : qAsConst(attValues)) {
+         m_query->prepare(QLatin1String("INSERT INTO FileAttributeSetTable "
+             "VALUES(?, ?)"));
+         m_query->bindValue(0, filterSetId);
+Submodule qtwayland dfb0129c..2904e1b3:
+diff --git a/qtwayland/src/client/configure.json b/qtwayland/src/client/configure.json
+index 2f424580..29222357 100644
+--- a/qtwayland/src/client/configure.json
++++ b/qtwayland/src/client/configure.json
+@@ -149,8 +149,7 @@
+                     "#endif"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "vulkan-server-buffer": {
+             "label": "Vulkan Buffer Sharing",
+@@ -168,7 +167,8 @@
+                     "exportAllocInfo.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR;",
+                     "return 0;"
+                 ]
+-            }
++            },
++            "use": "wayland-client"
+         },
+         "egl_1_5-wayland": {
+             "label": "EGL 1.5 with Wayland Platform",
+@@ -183,7 +183,7 @@
+                     "eglGetPlatformDisplay(EGL_PLATFORM_WAYLAND_EXT, (struct wl_display *)(nullptr), nullptr);"
+                 ]
+             },
+-            "use": "egl"
++            "use": "egl wayland-client"
+         }
+     },
+ 
+diff --git a/qtwayland/src/client/global/qwaylandclientextension.cpp b/qtwayland/src/client/global/qwaylandclientextension.cpp
+index 125b1e19..edccfe63 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension.cpp
++++ b/qtwayland/src/client/global/qwaylandclientextension.cpp
+@@ -74,7 +74,10 @@ void QWaylandClientExtensionPrivate::handleRegistryGlobal(void *data, ::wl_regis
+ void QWaylandClientExtension::addRegistryListener()
+ {
+     Q_D(QWaylandClientExtension);
+-    d->waylandIntegration->display()->addRegistryListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++    if (!d->registered) {
++        d->waylandIntegration->display()->addRegistryListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++        d->registered = true;
++    }
+ }
+ 
+ QWaylandClientExtension::QWaylandClientExtension(const int ver)
+@@ -88,6 +91,13 @@ QWaylandClientExtension::QWaylandClientExtension(const int ver)
+     QMetaObject::invokeMethod(this, "addRegistryListener", Qt::QueuedConnection);
+ }
+ 
++QWaylandClientExtension::~QWaylandClientExtension()
++{
++    Q_D(QWaylandClientExtension);
++    if (d->registered && !QCoreApplication::closingDown())
++        d->waylandIntegration->display()->removeListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++}
++
+ QtWaylandClient::QWaylandIntegration *QWaylandClientExtension::integration() const
+ {
+     Q_D(const QWaylandClientExtension);
+diff --git a/qtwayland/src/client/global/qwaylandclientextension.h b/qtwayland/src/client/global/qwaylandclientextension.h
+index 98272e57..5bd28398 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension.h
++++ b/qtwayland/src/client/global/qwaylandclientextension.h
+@@ -63,6 +63,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandClientExtension : public QObject
+     Q_PROPERTY(bool active READ isActive NOTIFY activeChanged)
+ public:
+     QWaylandClientExtension(const int version);
++    ~QWaylandClientExtension();
+ 
+     QtWaylandClient::QWaylandIntegration *integration() const;
+     int version() const;
+diff --git a/qtwayland/src/client/global/qwaylandclientextension_p.h b/qtwayland/src/client/global/qwaylandclientextension_p.h
+index 69cc46a0..9091efbe 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension_p.h
++++ b/qtwayland/src/client/global/qwaylandclientextension_p.h
+@@ -68,6 +68,7 @@ public:
+     QtWaylandClient::QWaylandIntegration *waylandIntegration = nullptr;
+     int version = -1;
+     bool active = false;
++    bool registered = false;
+ };
+ 
+ class Q_WAYLAND_CLIENT_EXPORT QWaylandClientExtensionTemplatePrivate : public QWaylandClientExtensionPrivate
+diff --git a/qtwayland/src/client/qwaylanddatadevice.cpp b/qtwayland/src/client/qwaylanddatadevice.cpp
+index 7e2e3308..e3e60ed5 100644
+--- a/qtwayland/src/client/qwaylanddatadevice.cpp
++++ b/qtwayland/src/client/qwaylanddatadevice.cpp
+@@ -72,6 +72,8 @@ QWaylandDataDevice::QWaylandDataDevice(QWaylandDataDeviceManager *manager, QWayl
+ 
+ QWaylandDataDevice::~QWaylandDataDevice()
+ {
++    if (wl_data_device_get_version(object()) >= WL_DATA_DEVICE_RELEASE_SINCE_VERSION)
++        release();
+ }
+ 
+ QWaylandDataOffer *QWaylandDataDevice::selectionOffer() const
+@@ -110,7 +112,7 @@ QWaylandDataOffer *QWaylandDataDevice::dragOffer() const
+     return m_dragOffer.data();
+ }
+ 
+-bool QWaylandDataDevice::startDrag(QMimeData *mimeData, QWaylandWindow *icon)
++bool QWaylandDataDevice::startDrag(QMimeData *mimeData, Qt::DropActions supportedActions, QWaylandWindow *icon)
+ {
+     auto *seat = m_display->currentInputDevice();
+     auto *origin = seat->pointerFocus();
+@@ -123,7 +125,28 @@ bool QWaylandDataDevice::startDrag(QMimeData *mimeData, QWaylandWindow *icon)
+     }
+ 
+     m_dragSource.reset(new QWaylandDataSource(m_display->dndSelectionHandler(), mimeData));
++
++    if (wl_data_device_get_version(object()) >= 3)
++        m_dragSource->set_actions(dropActionsToWl(supportedActions));
++
+     connect(m_dragSource.data(), &QWaylandDataSource::cancelled, this, &QWaylandDataDevice::dragSourceCancelled);
++    connect(m_dragSource.data(), &QWaylandDataSource::dndResponseUpdated, this, [this](bool accepted, Qt::DropAction action) {
++            auto drag = static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag());
++            // in old versions drop action is not set, so we guess
++            if (wl_data_source_get_version(m_dragSource->object()) < 3) {
++                drag->setResponse(accepted);
++            } else {
++                QPlatformDropQtResponse response(accepted, action);
++                drag->setResponse(response);
++            }
++    });
++    connect(m_dragSource.data(), &QWaylandDataSource::dndDropped, this, [](bool accepted, Qt::DropAction action) {
++        QPlatformDropQtResponse response(accepted, action);
++        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setDropResponse(response);
++    });
++    connect(m_dragSource.data(), &QWaylandDataSource::finished, this, []() {
++        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag();
++    });
+ 
+     start_drag(m_dragSource->object(), origin->wlSurface(), icon->wlSurface(), m_display->currentInputDevice()->serial());
+     return true;
+@@ -152,7 +175,7 @@ void QWaylandDataDevice::data_device_drop()
+         supportedActions = drag->supportedActions();
+     } else if (m_dragOffer) {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     } else {
+         return;
+     }
+@@ -162,7 +185,11 @@ void QWaylandDataDevice::data_device_drop()
+                                                                           QGuiApplication::keyboardModifiers());
+ 
+     if (drag) {
+-        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag(response);
++        auto drag =  static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag());
++        drag->setDropResponse(response);
++        drag->finishDrag();
++    } else if (m_dragOffer) {
++        m_dragOffer->finish();
+     }
+ }
+ 
+@@ -186,7 +213,7 @@ void QWaylandDataDevice::data_device_enter(uint32_t serial, wl_surface *surface,
+         supportedActions = drag->supportedActions();
+     } else if (m_dragOffer) {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     }
+ 
+     const QPlatformDragQtResponse &response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
+@@ -197,11 +224,7 @@ void QWaylandDataDevice::data_device_enter(uint32_t serial, wl_surface *surface,
+         static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setResponse(response);
+     }
+ 
+-    if (response.isAccepted()) {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, m_dragOffer->firstFormat().toUtf8().constData());
+-    } else {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, nullptr);
+-    }
++    sendResponse(supportedActions, response);
+ }
+ 
+ void QWaylandDataDevice::data_device_leave()
+@@ -235,10 +258,10 @@ void QWaylandDataDevice::data_device_motion(uint32_t time, wl_fixed_t x, wl_fixe
+         supportedActions = drag->supportedActions();
+     } else {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     }
+ 
+-    QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
++    const QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
+                                                                           QGuiApplication::mouseButtons(),
+                                                                           QGuiApplication::keyboardModifiers());
+ 
+@@ -246,11 +269,7 @@ void QWaylandDataDevice::data_device_motion(uint32_t time, wl_fixed_t x, wl_fixe
+         static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setResponse(response);
+     }
+ 
+-    if (response.isAccepted()) {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, m_dragOffer->firstFormat().toUtf8().constData());
+-    } else {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, nullptr);
+-    }
++    sendResponse(supportedActions, response);
+ }
+ #endif // QT_CONFIG(draganddrop)
+ 
+@@ -277,14 +296,10 @@ void QWaylandDataDevice::selectionSourceCancelled()
+ #if QT_CONFIG(draganddrop)
+ void QWaylandDataDevice::dragSourceCancelled()
+ {
++    static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag();
+     m_dragSource.reset();
+ }
+ 
+-void QWaylandDataDevice::dragSourceTargetChanged(const QString &mimeType)
+-{
+-    static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->updateTarget(mimeType);
+-}
+-
+ QPoint QWaylandDataDevice::calculateDragPosition(int x, int y, QWindow *wnd) const
+ {
+     QPoint pnt(wl_fixed_to_int(x), wl_fixed_to_int(y));
+@@ -297,6 +312,33 @@ QPoint QWaylandDataDevice::calculateDragPosition(int x, int y, QWindow *wnd) con
+     }
+     return pnt;
+ }
++
++void QWaylandDataDevice::sendResponse(Qt::DropActions supportedActions, const QPlatformDragQtResponse &response)
++{
++    if (response.isAccepted()) {
++        if (wl_data_device_get_version(object()) >= 3)
++            m_dragOffer->set_actions(dropActionsToWl(supportedActions), dropActionsToWl(response.acceptedAction()));
++
++        m_dragOffer->accept(m_enterSerial, m_dragOffer->firstFormat());
++    } else {
++        m_dragOffer->accept(m_enterSerial, QString());
++    }
++}
++
++int QWaylandDataDevice::dropActionsToWl(Qt::DropActions actions)
++{
++
++    int wlActions = WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE;
++    if (actions & Qt::CopyAction)
++        wlActions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY;
++    if (actions & (Qt::MoveAction | Qt::TargetMoveAction))
++        wlActions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE;
++
++    // wayland does not support LinkAction at the time of writing
++    return wlActions;
++}
++
++
+ #endif // QT_CONFIG(draganddrop)
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddatadevice_p.h b/qtwayland/src/client/qwaylanddatadevice_p.h
+index 16c3ad28..801dcc2c 100644
+--- a/qtwayland/src/client/qwaylanddatadevice_p.h
++++ b/qtwayland/src/client/qwaylanddatadevice_p.h
+@@ -64,6 +64,7 @@ QT_REQUIRE_CONFIG(wayland_datadevice);
+ QT_BEGIN_NAMESPACE
+ 
+ class QMimeData;
++class QPlatformDragQtResponse;
+ class QWindow;
+ 
+ namespace QtWaylandClient {
+@@ -89,7 +90,7 @@ public:
+ 
+ #if QT_CONFIG(draganddrop)
+     QWaylandDataOffer *dragOffer() const;
+-    bool startDrag(QMimeData *mimeData, QWaylandWindow *icon);
++    bool startDrag(QMimeData *mimeData, Qt::DropActions supportedActions, QWaylandWindow *icon);
+     void cancelDrag();
+ #endif
+ 
+@@ -109,13 +110,16 @@ private Q_SLOTS:
+ 
+ #if QT_CONFIG(draganddrop)
+     void dragSourceCancelled();
+-    void dragSourceTargetChanged(const QString &mimeType);
+ #endif
+ 
+ private:
+ #if QT_CONFIG(draganddrop)
+     QPoint calculateDragPosition(int x, int y, QWindow *wnd) const;
+ #endif
++    void sendResponse(Qt::DropActions supportedActions, const QPlatformDragQtResponse &response);
++
++    static int dropActionsToWl(Qt::DropActions dropActions);
++
+ 
+     QWaylandDisplay *m_display = nullptr;
+     QWaylandInputDevice *m_inputDevice = nullptr;
+diff --git a/qtwayland/src/client/qwaylanddatadevicemanager.cpp b/qtwayland/src/client/qwaylanddatadevicemanager.cpp
+index 35d67307..6dc4f77f 100644
+--- a/qtwayland/src/client/qwaylanddatadevicemanager.cpp
++++ b/qtwayland/src/client/qwaylanddatadevicemanager.cpp
+@@ -50,8 +50,8 @@ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
+-QWaylandDataDeviceManager::QWaylandDataDeviceManager(QWaylandDisplay *display, uint32_t id)
+-    : wl_data_device_manager(display->wl_registry(), id, 1)
++QWaylandDataDeviceManager::QWaylandDataDeviceManager(QWaylandDisplay *display, int version, uint32_t id)
++    : wl_data_device_manager(display->wl_registry(), id, qMin(version, 3))
+     , m_display(display)
+ {
+     // Create transfer devices for all input devices.
+diff --git a/qtwayland/src/client/qwaylanddatadevicemanager_p.h b/qtwayland/src/client/qwaylanddatadevicemanager_p.h
+index bd05c0fb..510d9be4 100644
+--- a/qtwayland/src/client/qwaylanddatadevicemanager_p.h
++++ b/qtwayland/src/client/qwaylanddatadevicemanager_p.h
+@@ -68,7 +68,7 @@ class QWaylandInputDevice;
+ class Q_WAYLAND_CLIENT_EXPORT QWaylandDataDeviceManager : public QtWayland::wl_data_device_manager
+ {
+ public:
+-    QWaylandDataDeviceManager(QWaylandDisplay *display, uint32_t id);
++    QWaylandDataDeviceManager(QWaylandDisplay *display, int version, uint32_t id);
+     ~QWaylandDataDeviceManager() override;
+ 
+     QWaylandDataDevice *getDataDevice(QWaylandInputDevice *inputDevice);
+diff --git a/qtwayland/src/client/qwaylanddataoffer.cpp b/qtwayland/src/client/qwaylanddataoffer.cpp
+index 2297e8a1..fe0ea8c9 100644
+--- a/qtwayland/src/client/qwaylanddataoffer.cpp
++++ b/qtwayland/src/client/qwaylanddataoffer.cpp
+@@ -82,6 +82,15 @@ QMimeData *QWaylandDataOffer::mimeData()
+     return m_mimeData.data();
+ }
+ 
++Qt::DropActions QWaylandDataOffer::supportedActions() const
++{
++    if (wl_data_offer_get_version(const_cast<::wl_data_offer*>(object())) < 3) {
++        return Qt::MoveAction | Qt::CopyAction;
++    }
++
++    return m_supportedActions;
++}
++
+ void QWaylandDataOffer::startReceiving(const QString &mimeType, int fd)
+ {
+     receive(mimeType, fd);
+@@ -93,6 +102,22 @@ void QWaylandDataOffer::data_offer_offer(const QString &mime_type)
+     m_mimeData->appendFormat(mime_type);
+ }
+ 
++void QWaylandDataOffer::data_offer_action(uint32_t dnd_action)
++{
++    Q_UNUSED(dnd_action);
++    // This is the compositor telling the drag target what action it should perform
++    // It does not map nicely into Qt final drop semantics, other than pretending there is only one supported action?
++}
++
++void QWaylandDataOffer::data_offer_source_actions(uint32_t source_actions)
++{
++    m_supportedActions = Qt::DropActions();
++    if (source_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
++        m_supportedActions |= Qt::MoveAction;
++    if (source_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
++        m_supportedActions |= Qt::CopyAction;
++}
++
+ QWaylandMimeData::QWaylandMimeData(QWaylandAbstractDataOffer *dataOffer)
+     : m_dataOffer(dataOffer)
+ {
+@@ -163,17 +188,18 @@ QVariant QWaylandMimeData::retrieveData_sys(const QString &mimeType, QVariant::T
+ 
+ int QWaylandMimeData::readData(int fd, QByteArray &data) const
+ {
+-    fd_set readset;
+-    FD_ZERO(&readset);
+-    FD_SET(fd, &readset);
+-    struct timeval timeout;
++    struct pollfd readset;
++    readset.fd = fd;
++    readset.events = POLLIN;
++    struct timespec timeout;
+     timeout.tv_sec = 1;
+-    timeout.tv_usec = 0;
++    timeout.tv_nsec = 0;
++
+ 
+     Q_FOREVER {
+-        int ready = select(FD_SETSIZE, &readset, nullptr, nullptr, &timeout);
++        int ready = qt_safe_poll(&readset, 1, &timeout);
+         if (ready < 0) {
+-            qWarning() << "QWaylandDataOffer: select() failed";
++            qWarning() << "QWaylandDataOffer: qt_safe_poll() failed";
+             return -1;
+         } else if (ready == 0) {
+             qWarning("QWaylandDataOffer: timeout reading from pipe");
+diff --git a/qtwayland/src/client/qwaylanddataoffer_p.h b/qtwayland/src/client/qwaylanddataoffer_p.h
+index 9cf1483c..6f667398 100644
+--- a/qtwayland/src/client/qwaylanddataoffer_p.h
++++ b/qtwayland/src/client/qwaylanddataoffer_p.h
+@@ -82,6 +82,7 @@ public:
+     explicit QWaylandDataOffer(QWaylandDisplay *display, struct ::wl_data_offer *offer);
+     ~QWaylandDataOffer() override;
+     QMimeData *mimeData() override;
++    Qt::DropActions supportedActions() const;
+ 
+     QString firstFormat() const;
+ 
+@@ -89,10 +90,13 @@ public:
+ 
+ protected:
+     void data_offer_offer(const QString &mime_type) override;
++    void data_offer_source_actions(uint32_t source_actions) override;
++    void data_offer_action(uint32_t dnd_action) override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+     QScopedPointer<QWaylandMimeData> m_mimeData;
++    Qt::DropActions m_supportedActions;
+ };
+ 
+ 
+diff --git a/qtwayland/src/client/qwaylanddatasource.cpp b/qtwayland/src/client/qwaylanddatasource.cpp
+index f45122fb..5599cbd4 100644
+--- a/qtwayland/src/client/qwaylanddatasource.cpp
++++ b/qtwayland/src/client/qwaylanddatasource.cpp
+@@ -101,7 +101,32 @@ void QWaylandDataSource::data_source_send(const QString &mime_type, int32_t fd)
+ 
+ void QWaylandDataSource::data_source_target(const QString &mime_type)
+ {
+-    Q_EMIT targetChanged(mime_type);
++    m_accepted = !mime_type.isEmpty();
++    Q_EMIT dndResponseUpdated(m_accepted, m_dropAction);
++}
++
++void QWaylandDataSource::data_source_action(uint32_t action)
++{
++    Qt::DropAction qtAction = Qt::IgnoreAction;
++
++    if (action == WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
++        qtAction = Qt::MoveAction;
++    else if (action == WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
++        qtAction = Qt::CopyAction;
++
++    m_dropAction = qtAction;
++    Q_EMIT dndResponseUpdated(m_accepted, m_dropAction);
++}
++
++void QWaylandDataSource::data_source_dnd_finished()
++{
++    Q_EMIT finished();
++}
++
++void QWaylandDataSource::data_source_dnd_drop_performed()
++{
++
++    Q_EMIT dndDropped(m_accepted, m_dropAction);
+ }
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddatasource_p.h b/qtwayland/src/client/qwaylanddatasource_p.h
+index 25afff79..96f07bc3 100644
+--- a/qtwayland/src/client/qwaylanddatasource_p.h
++++ b/qtwayland/src/client/qwaylanddatasource_p.h
+@@ -77,17 +77,25 @@ public:
+     QMimeData *mimeData() const;
+ 
+ Q_SIGNALS:
+-    void targetChanged(const QString &mime_type);
+     void cancelled();
++    void finished();
++
++    void dndResponseUpdated(bool accepted, Qt::DropAction action);
++    void dndDropped(bool accepted, Qt::DropAction action);
+ 
+ protected:
+     void data_source_cancelled() override;
+     void data_source_send(const QString &mime_type, int32_t fd) override;
+     void data_source_target(const QString &mime_type) override;
++    void data_source_dnd_drop_performed() override;
++    void data_source_dnd_finished() override;
++    void data_source_action(uint32_t action) override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+     QMimeData *m_mime_data = nullptr;
++    bool m_accepted = false;
++    Qt::DropAction m_dropAction = Qt::IgnoreAction;
+ };
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddisplay.cpp b/qtwayland/src/client/qwaylanddisplay.cpp
+index f10c1f79..c01e238b 100644
+--- a/qtwayland/src/client/qwaylanddisplay.cpp
++++ b/qtwayland/src/client/qwaylanddisplay.cpp
+@@ -85,10 +85,203 @@
+ 
+ #include <errno.h>
+ 
++#include <tuple> // for std::tie
++
++static void checkWaylandError(struct wl_display *display)
++{
++    int ecode = wl_display_get_error(display);
++    if ((ecode == EPIPE || ecode == ECONNRESET)) {
++        // special case this to provide a nicer error
++        qWarning("The Wayland connection broke. Did the Wayland compositor die?");
++    } else {
++        qWarning("The Wayland connection experienced a fatal error: %s", strerror(ecode));
++    }
++    _exit(1);
++}
++
+ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
++class EventThread : public QThread
++{
++    Q_OBJECT
++public:
++    enum OperatingMode {
++        EmitToDispatch, // Emit the signal, allow dispatching in a differnt thread.
++        SelfDispatch, // Dispatch the events inside this thread.
++    };
++
++    EventThread(struct wl_display * wl, struct wl_event_queue * ev_queue,
++                OperatingMode mode)
++        : m_fd(wl_display_get_fd(wl))
++        , m_pipefd{ -1, -1 }
++        , m_wldisplay(wl)
++        , m_wlevqueue(ev_queue)
++        , m_mode(mode)
++        , m_reading(true)
++        , m_quitting(false)
++    {
++        setObjectName(QStringLiteral("WaylandEventThread"));
++    }
++
++    void readAndDispatchEvents()
++    {
++        /*
++         * Dispatch pending events and flush the requests at least once. If the event thread
++         * is not reading, try to call _prepare_read() to allow the event thread to poll().
++         * If that fails, re-try dispatch & flush again until _prepare_read() is successful.
++         *
++         * This allow any call to readAndDispatchEvents() to start event thread's polling,
++         * not only the one issued from event thread's waitForReading(), which means functions
++         * called from dispatch_pending() can safely spin an event loop.
++         */
++        for (;;) {
++            if (dispatchQueuePending() < 0) {
++                checkWaylandError(m_wldisplay);
++                return;
++            }
++
++            wl_display_flush(m_wldisplay);
++
++            // We have to check if event thread is reading every time we dispatch
++            // something, as that may recursively call this function.
++            if (m_reading.loadAcquire())
++                break;
++
++            if (prepareReadQueue() == 0) {
++                QMutexLocker l(&m_mutex);
++                m_reading.storeRelease(true);
++                m_cond.wakeOne();
++                break;
++            }
++        }
++    }
++
++    void stop()
++    {
++        // We have to both write to the pipe and set the flag, as the thread may be
++        // either in the poll() or waiting for _prepare_read().
++        if (m_pipefd[1] != -1 && write(m_pipefd[1], "\0", 1) == -1)
++            qWarning("Failed to write to the pipe: %s.", strerror(errno));
++
++        {
++            QMutexLocker l(&m_mutex);
++            m_quitting = true;
++            m_cond.wakeOne();
++        }
++
++        wait();
++    }
++
++Q_SIGNALS:
++    void needReadAndDispatch();
++
++protected:
++    void run() override
++    {
++        // we use this pipe to make the loop exit otherwise if we simply used a flag on the loop condition, if stop() gets
++        // called while poll() is blocking the thread will never quit since there are no wayland messages coming anymore.
++        struct Pipe
++        {
++            Pipe(int *fds)
++                : fds(fds)
++            {
++                if (qt_safe_pipe(fds) != 0)
++                    qWarning("Pipe creation failed. Quitting may hang.");
++            }
++            ~Pipe()
++            {
++                if (fds[0] != -1) {
++                    close(fds[0]);
++                    close(fds[1]);
++                }
++            }
++
++            int *fds;
++        } pipe(m_pipefd);
++
++        // Make the main thread call wl_prepare_read(), dispatch the pending messages and flush the
++        // outbound ones. Wait until it's done before proceeding, unless we're told to quit.
++        while (waitForReading()) {
++            pollfd fds[2] = { { m_fd, POLLIN, 0 }, { m_pipefd[0], POLLIN, 0 } };
++            poll(fds, 2, -1);
++
++            if (fds[1].revents & POLLIN) {
++                // we don't really care to read the byte that was written here since we're closing down
++                wl_display_cancel_read(m_wldisplay);
++                break;
++            }
++
++            if (fds[0].revents & POLLIN)
++                wl_display_read_events(m_wldisplay);
++                // The polll was succesfull and the event thread did the wl_display_read_events(). On the next iteration of the loop
++                // the event sent to the main thread will cause it to dispatch the messages just read, unless the loop exits in which
++                // case we don't care anymore about them.
++            else
++                wl_display_cancel_read(m_wldisplay);
++        }
++    }
++
++private:
++    bool waitForReading()
++    {
++        Q_ASSERT(QThread::currentThread() == this);
++
++        m_reading.storeRelease(false);
++
++        if (m_mode == SelfDispatch) {
++            readAndDispatchEvents();
++        } else {
++            Q_EMIT needReadAndDispatch();
++
++            QMutexLocker lock(&m_mutex);
++            // m_reading might be set from our emit or some other invocation of
++            // readAndDispatchEvents().
++            while (!m_reading.loadRelaxed() && !m_quitting)
++                m_cond.wait(&m_mutex);
++        }
++
++        return !m_quitting;
++    }
++
++    int dispatchQueuePending()
++    {
++        if (m_wlevqueue)
++            return wl_display_dispatch_queue_pending(m_wldisplay, m_wlevqueue);
++        else
++            return wl_display_dispatch_pending(m_wldisplay);
++    }
++
++    int prepareReadQueue()
++    {
++        if (m_wlevqueue)
++            return wl_display_prepare_read_queue(m_wldisplay, m_wlevqueue);
++        else
++            return wl_display_prepare_read(m_wldisplay);
++    }
++
++    int m_fd;
++    int m_pipefd[2];
++    wl_display *m_wldisplay;
++    wl_event_queue *m_wlevqueue;
++    OperatingMode m_mode;
++
++    /* Concurrency note when operating in EmitToDispatch mode:
++     * m_reading is set to false inside event thread's waitForReading(), and is
++     * set to true inside main thread's readAndDispatchEvents().
++     * The lock is not taken when setting m_reading to false, as the main thread
++     * is not actively waiting for it to turn false. However, the lock is taken
++     * inside readAndDispatchEvents() before setting m_reading to true,
++     * as the event thread is actively waiting for it under the wait condition.
++     */
++
++    QAtomicInteger<bool> m_reading;
++    bool m_quitting;
++    QMutex m_mutex;
++    QWaitCondition m_cond;
++};
++
+ Q_LOGGING_CATEGORY(lcQpaWayland, "qt.qpa.wayland"); // for general (uncategorized) Wayland platform logging
+ 
+ struct wl_surface *QWaylandDisplay::createSurface(void *handle)
+@@ -158,17 +351,16 @@ QWaylandDisplay::QWaylandDisplay(QWaylandIntegration *waylandIntegration)
+     if (!mXkbContext)
+         qCWarning(lcQpaWayland, "failed to create xkb context");
+ #endif
+-
+-    forceRoundTrip();
+-
+-    if (!mWaitingScreens.isEmpty()) {
+-        // Give wl_output.done and zxdg_output_v1.done events a chance to arrive
+-        forceRoundTrip();
+-    }
+ }
+ 
+ QWaylandDisplay::~QWaylandDisplay(void)
+ {
++    if (m_eventThread)
++        m_eventThread->stop();
++
++    if (m_frameEventQueueThread)
++        m_frameEventQueueThread->stop();
++
+     if (mSyncCallback)
+         wl_callback_destroy(mSyncCallback);
+ 
+@@ -187,6 +379,21 @@ QWaylandDisplay::~QWaylandDisplay(void)
+ #endif
+     if (mDisplay)
+         wl_display_disconnect(mDisplay);
++
++    if (m_frameEventQueue)
++        wl_event_queue_destroy(m_frameEventQueue);
++}
++
++// Steps which is called just after constructor. This separates registry_global() out of the constructor
++// so that factory functions in integration can be overridden.
++void QWaylandDisplay::initialize()
++{
++    forceRoundTrip();
++
++    if (!mWaitingScreens.isEmpty()) {
++        // Give wl_output.done and zxdg_output_v1.done events a chance to arrive
++        forceRoundTrip();
++    }
+ }
+ 
+ void QWaylandDisplay::ensureScreen()
+@@ -203,98 +410,37 @@ void QWaylandDisplay::ensureScreen()
+ 
+ void QWaylandDisplay::checkError() const
+ {
+-    int ecode = wl_display_get_error(mDisplay);
+-    if ((ecode == EPIPE || ecode == ECONNRESET)) {
+-        // special case this to provide a nicer error
+-        qWarning("The Wayland connection broke. Did the Wayland compositor die?");
+-    } else {
+-        qWarning("The Wayland connection experienced a fatal error: %s", strerror(ecode));
+-    }
+-    _exit(1);
++    checkWaylandError(mDisplay);
+ }
+ 
++// Called in main thread, either from queued signal or directly.
+ void QWaylandDisplay::flushRequests()
+ {
+-    if (wl_display_prepare_read(mDisplay) == 0) {
+-        wl_display_read_events(mDisplay);
+-    }
+-
+-    if (wl_display_dispatch_pending(mDisplay) < 0)
+-        checkError();
+-
+-    {
+-        QReadLocker locker(&m_frameQueueLock);
+-        for (const FrameQueue &q : mExternalQueues) {
+-            QMutexLocker locker(q.mutex);
+-            while (wl_display_prepare_read_queue(mDisplay, q.queue) != 0)
+-                wl_display_dispatch_queue_pending(mDisplay, q.queue);
+-            wl_display_read_events(mDisplay);
+-            wl_display_dispatch_queue_pending(mDisplay, q.queue);
+-        }
+-    }
+-
+-    wl_display_flush(mDisplay);
+-}
+-
+-void QWaylandDisplay::blockingReadEvents()
+-{
+-    if (wl_display_dispatch(mDisplay) < 0)
+-        checkError();
+-}
+-
+-void QWaylandDisplay::destroyFrameQueue(const QWaylandDisplay::FrameQueue &q)
+-{
+-    QWriteLocker locker(&m_frameQueueLock);
+-    auto it = std::find_if(mExternalQueues.begin(),
+-                           mExternalQueues.end(),
+-                           [&q] (const QWaylandDisplay::FrameQueue &other){ return other.queue == q.queue; });
+-    Q_ASSERT(it != mExternalQueues.end());
+-    mExternalQueues.erase(it);
+-    if (q.queue != nullptr)
+-        wl_event_queue_destroy(q.queue);
+-    delete q.mutex;
++    m_eventThread->readAndDispatchEvents();
+ }
+ 
+-QWaylandDisplay::FrameQueue QWaylandDisplay::createFrameQueue()
++// We have to wait until we have an eventDispatcher before creating the eventThread,
++// otherwise forceRoundTrip() may block inside _events_read() because eventThread is
++// polling.
++void QWaylandDisplay::initEventThread()
+ {
+-    QWriteLocker locker(&m_frameQueueLock);
+-    FrameQueue q{createEventQueue()};
+-    mExternalQueues.append(q);
+-    return q;
+-}
++    m_eventThread.reset(
++            new EventThread(mDisplay, /* default queue */ nullptr, EventThread::EmitToDispatch));
++    connect(m_eventThread.get(), &EventThread::needReadAndDispatch, this,
++            &QWaylandDisplay::flushRequests, Qt::QueuedConnection);
++    m_eventThread->start();
+ 
+-wl_event_queue *QWaylandDisplay::createEventQueue()
+-{
+-    return wl_display_create_queue(mDisplay);
++    // wl_display_disconnect() free this.
++    m_frameEventQueue = wl_display_create_queue(mDisplay);
++    m_frameEventQueueThread.reset(
++            new EventThread(mDisplay, m_frameEventQueue, EventThread::SelfDispatch));
++    m_frameEventQueueThread->start();
+ }
+ 
+-void QWaylandDisplay::dispatchQueueWhile(wl_event_queue *queue, std::function<bool ()> condition, int timeout)
++void QWaylandDisplay::blockingReadEvents()
+ {
+-    if (!condition())
+-        return;
+-
+-    QElapsedTimer timer;
+-    timer.start();
+-    struct pollfd pFd = qt_make_pollfd(wl_display_get_fd(mDisplay), POLLIN);
+-    while (timeout == -1 || timer.elapsed() < timeout) {
+-        while (wl_display_prepare_read_queue(mDisplay, queue) != 0)
+-            wl_display_dispatch_queue_pending(mDisplay, queue);
+-
+-        wl_display_flush(mDisplay);
+-
+-        const int remaining = qMax(timeout - timer.elapsed(), 0ll);
+-        const int pollTimeout = timeout == -1 ? -1 : remaining;
+-        if (qt_poll_msecs(&pFd, 1, pollTimeout) > 0)
+-            wl_display_read_events(mDisplay);
+-        else
+-            wl_display_cancel_read(mDisplay);
+-
+-        if (wl_display_dispatch_queue_pending(mDisplay, queue) < 0)
+-            checkError();
+-
+-        if (!condition())
+-            break;
+-    }
++    if (wl_display_dispatch(mDisplay) < 0)
++        checkWaylandError(mDisplay);
+ }
+ 
+ QWaylandScreen *QWaylandDisplay::screenForOutput(struct wl_output *output) const
+@@ -345,7 +491,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+     if (interface == QStringLiteral("wl_output")) {
+         mWaitingScreens << new QWaylandScreen(this, version, id);
+     } else if (interface == QStringLiteral("wl_compositor")) {
+-        mCompositorVersion = qMin((int)version, 3);
++        mCompositorVersion = qMin((int)version, 4);
+         mCompositor.init(registry, id, mCompositorVersion);
+     } else if (interface == QStringLiteral("wl_shm")) {
+         mShm.reset(new QWaylandShm(this, version, id));
+@@ -354,7 +500,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+         mInputDevices.append(inputDevice);
+ #if QT_CONFIG(wayland_datadevice)
+     } else if (interface == QStringLiteral("wl_data_device_manager")) {
+-        mDndSelectionHandler.reset(new QWaylandDataDeviceManager(this, id));
++        mDndSelectionHandler.reset(new QWaylandDataDeviceManager(this, version, id));
+ #endif
+     } else if (interface == QStringLiteral("qt_surface_extension")) {
+         mWindowExtension.reset(new QtWayland::qt_surface_extension(registry, id, 1));
+@@ -369,6 +515,8 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+ #if QT_CONFIG(wayland_client_primary_selection)
+     } else if (interface == QStringLiteral("zwp_primary_selection_device_manager_v1")) {
+         mPrimarySelectionManager.reset(new QWaylandPrimarySelectionDeviceManagerV1(this, id, 1));
++        for (QWaylandInputDevice *inputDevice : qAsConst(mInputDevices))
++            inputDevice->setPrimarySelectionDevice(mPrimarySelectionManager->createDevice(inputDevice));
+ #endif
+     } else if (interface == QStringLiteral("zwp_text_input_manager_v2") && !mClientSideInputContextRequested) {
+         mTextInputManager.reset(new QtWayland::zwp_text_input_manager_v2(registry, id, 1));
+@@ -427,6 +575,13 @@ void QWaylandDisplay::registry_global_remove(uint32_t id)
+                     inputDevice->setTextInput(nullptr);
+                 mWaylandIntegration->reconfigureInputContext();
+             }
++#if QT_CONFIG(wayland_client_primary_selection)
++            if (global.interface == QStringLiteral("zwp_primary_selection_device_manager_v1")) {
++                mPrimarySelectionManager.reset();
++                for (QWaylandInputDevice *inputDevice : qAsConst(mInputDevices))
++                    inputDevice->setPrimarySelectionDevice(nullptr);
++            }
++#endif
+             mGlobals.removeAt(i);
+             break;
+         }
+@@ -452,9 +607,10 @@ void QWaylandDisplay::addRegistryListener(RegistryListener listener, void *data)
+ 
+ void QWaylandDisplay::removeListener(RegistryListener listener, void *data)
+ {
+-    std::remove_if(mRegistryListeners.begin(), mRegistryListeners.end(), [=](Listener l){
++    auto iter = std::remove_if(mRegistryListeners.begin(), mRegistryListeners.end(), [=](Listener l){
+         return (l.listener == listener && l.data == data);
+     });
++    mRegistryListeners.erase(iter, mRegistryListeners.end());
+ }
+ 
+ uint32_t QWaylandDisplay::currentTimeMillisec()
+@@ -467,50 +623,9 @@ uint32_t QWaylandDisplay::currentTimeMillisec()
+     return 0;
+ }
+ 
+-static void
+-sync_callback(void *data, struct wl_callback *callback, uint32_t serial)
+-{
+-    Q_UNUSED(serial)
+-    bool *done = static_cast<bool *>(data);
+-
+-    *done = true;
+-
+-    // If the wl_callback done event is received after the condition check in the while loop in
+-    // forceRoundTrip(), but before the call to processEvents, the call to processEvents may block
+-    // forever if no more events are posted (eventhough the callback is handled in response to the
+-    // aboutToBlock signal). Hence, we wake up the event dispatcher so forceRoundTrip may return.
+-    // (QTBUG-64696)
+-    if (auto *dispatcher = QThread::currentThread()->eventDispatcher())
+-        dispatcher->wakeUp();
+-
+-    wl_callback_destroy(callback);
+-}
+-
+-static const struct wl_callback_listener sync_listener = {
+-    sync_callback
+-};
+-
+ void QWaylandDisplay::forceRoundTrip()
+ {
+-    // wl_display_roundtrip() works on the main queue only,
+-    // but we use a separate one, so basically reimplement it here
+-    int ret = 0;
+-    bool done = false;
+-    wl_callback *callback = wl_display_sync(mDisplay);
+-    wl_callback_add_listener(callback, &sync_listener, &done);
+-    flushRequests();
+-    if (QThread::currentThread()->eventDispatcher()) {
+-        while (!done && ret >= 0) {
+-            QThread::currentThread()->eventDispatcher()->processEvents(QEventLoop::WaitForMoreEvents);
+-            ret = wl_display_dispatch_pending(mDisplay);
+-        }
+-    } else {
+-        while (!done && ret >= 0)
+-            ret = wl_display_dispatch(mDisplay);
+-    }
+-
+-    if (ret == -1 && !done)
+-        wl_callback_destroy(callback);
++     wl_display_roundtrip(mDisplay);
+ }
+ 
+ bool QWaylandDisplay::supportsWindowDecoration() const
+@@ -574,14 +689,10 @@ void QWaylandDisplay::handleKeyboardFocusChanged(QWaylandInputDevice *inputDevic
+     if (mLastKeyboardFocus == keyboardFocus)
+         return;
+ 
+-    if (mWaylandIntegration->mShellIntegration) {
+-        mWaylandIntegration->mShellIntegration->handleKeyboardFocusChanged(keyboardFocus, mLastKeyboardFocus);
+-    } else {
+-        if (keyboardFocus)
+-            handleWindowActivated(keyboardFocus);
+-        if (mLastKeyboardFocus)
+-            handleWindowDeactivated(mLastKeyboardFocus);
+-    }
++    if (keyboardFocus)
++        handleWindowActivated(keyboardFocus);
++    if (mLastKeyboardFocus)
++        handleWindowDeactivated(mLastKeyboardFocus);
+ 
+     mLastKeyboardFocus = keyboardFocus;
+ }
+@@ -600,6 +711,19 @@ void QWaylandDisplay::handleWaylandSync()
+     QWindow *activeWindow = mActiveWindows.empty() ? nullptr : mActiveWindows.last()->window();
+     if (activeWindow != QGuiApplication::focusWindow())
+         QWindowSystemInterface::handleWindowActivated(activeWindow);
++
++    if (!activeWindow) {
++        if (lastInputDevice()) {
++#if QT_CONFIG(clipboard)
++            if (auto *dataDevice = lastInputDevice()->dataDevice())
++                dataDevice->invalidateSelectionOffer();
++#endif
++#if QT_CONFIG(wayland_client_primary_selection)
++            if (auto *device = lastInputDevice()->primarySelectionDevice())
++                device->invalidateSelectionOffer();
++#endif
++        }
++    }
+ }
+ 
+ const wl_callback_listener QWaylandDisplay::syncCallbackListener = {
+@@ -626,6 +750,13 @@ QWaylandInputDevice *QWaylandDisplay::defaultInputDevice() const
+     return mInputDevices.isEmpty() ? 0 : mInputDevices.first();
+ }
+ 
++bool QWaylandDisplay::isKeyboardAvailable() const
++{
++    return std::any_of(
++            mInputDevices.constBegin(), mInputDevices.constEnd(),
++            [this](const QWaylandInputDevice *device) { return device->keyboard() != nullptr; });
++}
++
+ #if QT_CONFIG(cursor)
+ 
+ QWaylandCursor *QWaylandDisplay::waylandCursor()
+@@ -652,4 +783,6 @@ QWaylandCursorTheme *QWaylandDisplay::loadCursorTheme(const QString &name, int p
+ 
+ } // namespace QtWaylandClient
+ 
++#include "qwaylanddisplay.moc"
++
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/client/qwaylanddisplay_p.h b/qtwayland/src/client/qwaylanddisplay_p.h
+index 3b092bc8..42bc661d 100644
+--- a/qtwayland/src/client/qwaylanddisplay_p.h
++++ b/qtwayland/src/client/qwaylanddisplay_p.h
+@@ -109,6 +109,7 @@ class QWaylandSurface;
+ class QWaylandShellIntegration;
+ class QWaylandCursor;
+ class QWaylandCursorTheme;
++class EventThread;
+ 
+ typedef void (*RegistryListener)(void *data,
+                                  struct wl_registry *registry,
+@@ -120,15 +121,11 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandDisplay : public QObject, public QtWayland
+     Q_OBJECT
+ 
+ public:
+-    struct FrameQueue {
+-        FrameQueue(wl_event_queue *q = nullptr) : queue(q), mutex(new QMutex) {}
+-        wl_event_queue *queue;
+-        QMutex *mutex;
+-    };
+-
+     QWaylandDisplay(QWaylandIntegration *waylandIntegration);
+     ~QWaylandDisplay(void) override;
+ 
++    void initialize();
++
+ #if QT_CONFIG(xkbcommon)
+     struct xkb_context *xkbContext() const { return mXkbContext.get(); }
+ #endif
+@@ -210,11 +207,11 @@ public:
+     void handleKeyboardFocusChanged(QWaylandInputDevice *inputDevice);
+     void handleWindowDestroyed(QWaylandWindow *window);
+ 
+-    wl_event_queue *createEventQueue();
+-    FrameQueue createFrameQueue();
+-    void destroyFrameQueue(const FrameQueue &q);
+-    void dispatchQueueWhile(wl_event_queue *queue, std::function<bool()> condition, int timeout = -1);
++    wl_event_queue *frameEventQueue() { return m_frameEventQueue; };
++
++    bool isKeyboardAvailable() const;
+ 
++    void initEventThread();
+ public slots:
+     void blockingReadEvents();
+     void flushRequests();
+@@ -237,6 +234,9 @@ private:
+     };
+ 
+     struct wl_display *mDisplay = nullptr;
++    QScopedPointer<EventThread> m_eventThread;
++    wl_event_queue *m_frameEventQueue = nullptr;
++    QScopedPointer<EventThread> m_frameEventQueueThread;
+     QtWayland::wl_compositor mCompositor;
+     QScopedPointer<QWaylandShm> mShm;
+     QList<QWaylandScreen *> mWaitingScreens;
+@@ -273,11 +273,9 @@ private:
+     QWaylandInputDevice *mLastInputDevice = nullptr;
+     QPointer<QWaylandWindow> mLastInputWindow;
+     QPointer<QWaylandWindow> mLastKeyboardFocus;
+-    QVector<QWaylandWindow *> mActiveWindows;
+-    QVector<FrameQueue> mExternalQueues;
++    QList<QWaylandWindow *> mActiveWindows;
+     struct wl_callback *mSyncCallback = nullptr;
+     static const wl_callback_listener syncCallbackListener;
+-    QReadWriteLock m_frameQueueLock;
+ 
+     bool mClientSideInputContextRequested = !QPlatformInputContextFactory::requested().isNull();
+ 
+diff --git a/qtwayland/src/client/qwaylanddnd.cpp b/qtwayland/src/client/qwaylanddnd.cpp
+index 6535aa16..7c53f5fa 100644
+--- a/qtwayland/src/client/qwaylanddnd.cpp
++++ b/qtwayland/src/client/qwaylanddnd.cpp
+@@ -66,7 +66,7 @@ void QWaylandDrag::startDrag()
+ {
+     QBasicDrag::startDrag();
+     QWaylandWindow *icon = static_cast<QWaylandWindow *>(shapedPixmapWindow()->handle());
+-    if (m_display->currentInputDevice()->dataDevice()->startDrag(drag()->mimeData(), icon)) {
++    if (m_display->currentInputDevice()->dataDevice()->startDrag(drag()->mimeData(), drag()->supportedActions(), icon)) {
+         icon->addAttachOffset(-drag()->hotSpot());
+     } else {
+         // Cancelling immediately does not work, since the event loop for QDrag::exec is started
+@@ -80,6 +80,9 @@ void QWaylandDrag::cancel()
+     QBasicDrag::cancel();
+ 
+     m_display->currentInputDevice()->dataDevice()->cancelDrag();
++
++    if (drag())
++        drag()->deleteLater();
+ }
+ 
+ void QWaylandDrag::move(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods)
+@@ -103,33 +106,41 @@ void QWaylandDrag::endDrag()
+     m_display->currentInputDevice()->handleEndDrag();
+ }
+ 
+-void QWaylandDrag::updateTarget(const QString &mimeType)
++void QWaylandDrag::setResponse(bool accepted)
+ {
+-    setCanDrop(!mimeType.isEmpty());
+-
+-    if (canDrop()) {
+-        updateCursor(defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers()));
+-    } else {
+-        updateCursor(Qt::IgnoreAction);
+-    }
++    // This method is used for old DataDevices where the drag action is not communicated
++    Qt::DropAction action = defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers());
++    setResponse(QPlatformDropQtResponse(accepted, action));
+ }
+ 
+-void QWaylandDrag::setResponse(const QPlatformDragQtResponse &response)
++void QWaylandDrag::setResponse(const QPlatformDropQtResponse &response)
+ {
+     setCanDrop(response.isAccepted());
+ 
+     if (canDrop()) {
+-        updateCursor(defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers()));
++        updateCursor(response.acceptedAction());
+     } else {
+         updateCursor(Qt::IgnoreAction);
+     }
+ }
+ 
+-void QWaylandDrag::finishDrag(const QPlatformDropQtResponse &response)
++void QWaylandDrag::setDropResponse(const QPlatformDropQtResponse &response)
+ {
+     setExecutedDropAction(response.acceptedAction());
++}
++
++void QWaylandDrag::finishDrag()
++{
+     QKeyEvent event(QEvent::KeyPress, Qt::Key_Escape, Qt::NoModifier);
+     eventFilter(shapedPixmapWindow(), &event);
++
++    if (drag())
++        drag()->deleteLater();
++}
++
++bool QWaylandDrag::ownsDragObject() const
++{
++    return true;
+ }
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddnd_p.h b/qtwayland/src/client/qwaylanddnd_p.h
+index 474fe2ab..46f629ac 100644
+--- a/qtwayland/src/client/qwaylanddnd_p.h
++++ b/qtwayland/src/client/qwaylanddnd_p.h
+@@ -71,9 +71,10 @@ public:
+     QWaylandDrag(QWaylandDisplay *display);
+     ~QWaylandDrag() override;
+ 
+-    void updateTarget(const QString &mimeType);
+-    void setResponse(const QPlatformDragQtResponse &response);
+-    void finishDrag(const QPlatformDropQtResponse &response);
++    void setResponse(bool accepted);
++    void setResponse(const QPlatformDropQtResponse &response);
++    void setDropResponse(const QPlatformDropQtResponse &response);
++    void finishDrag();
+ 
+ protected:
+     void startDrag() override;
+@@ -82,6 +83,7 @@ protected:
+     void drop(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods) override;
+     void endDrag() override;
+ 
++    bool ownsDragObject() const override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+diff --git a/qtwayland/src/client/qwaylandinputdevice.cpp b/qtwayland/src/client/qwaylandinputdevice.cpp
+index 613fe862..4b90de84 100644
+--- a/qtwayland/src/client/qwaylandinputdevice.cpp
++++ b/qtwayland/src/client/qwaylandinputdevice.cpp
+@@ -685,6 +685,11 @@ public:
+ 
+ void QWaylandInputDevice::Pointer::pointer_leave(uint32_t time, struct wl_surface *surface)
+ {
++    invalidateFocus();
++    mButtons = Qt::NoButton;
++
++    mParent->mTime = time;
++
+     // The event may arrive after destroying the window, indicated by
+     // a null surface.
+     if (!surface)
+@@ -696,11 +701,6 @@ void QWaylandInputDevice::Pointer::pointer_leave(uint32_t time, struct wl_surfac
+ 
+     if (!QWaylandWindow::mouseGrab())
+         setFrameEvent(new LeaveEvent(window, mSurfacePos, mGlobalPos));
+-
+-    invalidateFocus();
+-    mButtons = Qt::NoButton;
+-
+-    mParent->mTime = time;
+ }
+ 
+ class MotionEvent : public QWaylandPointerEvent
+@@ -1300,14 +1300,6 @@ void QWaylandInputDevice::Keyboard::handleFocusDestroyed()
+ void QWaylandInputDevice::Keyboard::handleFocusLost()
+ {
+     mFocus = nullptr;
+-#if QT_CONFIG(clipboard)
+-    if (auto *dataDevice = mParent->dataDevice())
+-        dataDevice->invalidateSelectionOffer();
+-#endif
+-#if QT_CONFIG(wayland_client_primary_selection)
+-    if (auto *device = mParent->primarySelectionDevice())
+-        device->invalidateSelectionOffer();
+-#endif
+     mParent->mQDisplay->handleKeyboardFocusChanged(mParent);
+     mRepeatTimer.stop();
+ }
+@@ -1396,6 +1388,7 @@ void QWaylandInputDevice::Touch::touch_cancel()
+     if (touchExt)
+         touchExt->touchCanceled();
+ 
++    mFocus = nullptr;
+     QWindowSystemInterface::handleTouchCancelEvent(nullptr, mParent->mTouchDevice);
+ }
+ 
+diff --git a/qtwayland/src/client/qwaylandintegration.cpp b/qtwayland/src/client/qwaylandintegration.cpp
+index c53ccb78..54861600 100644
+--- a/qtwayland/src/client/qwaylandintegration.cpp
++++ b/qtwayland/src/client/qwaylandintegration.cpp
+@@ -125,6 +125,9 @@ QWaylandIntegration::QWaylandIntegration()
+ #endif
+ 
+     reconfigureInputContext();
++
++    QWaylandWindow::fixedToplevelPositions =
++            !qEnvironmentVariableIsSet("QT_WAYLAND_DISABLE_FIXED_POSITIONS");
+ }
+ 
+ QWaylandIntegration::~QWaylandIntegration()
+@@ -192,14 +195,18 @@ QAbstractEventDispatcher *QWaylandIntegration::createEventDispatcher() const
+ 
+ void QWaylandIntegration::initialize()
+ {
++    mDisplay->initEventThread();
++
++    // Call after eventDispatcher is fully connected, for QWaylandDisplay::forceRoundTrip()
++    mDisplay->initialize();
++
++    // But the aboutToBlock() and awake() should be connected after initializePlatform().
++    // Otherwise the connected flushRequests() may consumes up all events before processEvents starts to wait,
++    // so that processEvents(QEventLoop::WaitForMoreEvents) may be blocked in the forceRoundTrip().
+     QAbstractEventDispatcher *dispatcher = QGuiApplicationPrivate::eventDispatcher;
+     QObject::connect(dispatcher, SIGNAL(aboutToBlock()), mDisplay.data(), SLOT(flushRequests()));
+     QObject::connect(dispatcher, SIGNAL(awake()), mDisplay.data(), SLOT(flushRequests()));
+ 
+-    int fd = wl_display_get_fd(mDisplay->wl_display());
+-    QSocketNotifier *sn = new QSocketNotifier(fd, QSocketNotifier::Read, mDisplay.data());
+-    QObject::connect(sn, SIGNAL(activated(QSocketDescriptor)), mDisplay.data(), SLOT(flushRequests()));
+-
+     // Qt does not support running with no screens
+     mDisplay->ensureScreen();
+ }
+@@ -262,6 +269,14 @@ QWaylandDisplay *QWaylandIntegration::display() const
+     return mDisplay.data();
+ }
+ 
++Qt::KeyboardModifiers QWaylandIntegration::queryKeyboardModifiers() const
++{
++    if (auto *seat = mDisplay->currentInputDevice()) {
++        return seat->modifiers();
++    }
++    return Qt::NoModifier;
++}
++
+ QList<int> QWaylandIntegration::possibleKeys(const QKeyEvent *event) const
+ {
+     if (auto *seat = mDisplay->currentInputDevice())
+@@ -479,7 +494,7 @@ void QWaylandIntegration::reconfigureInputContext()
+     }
+ #endif
+ 
+-    qCDebug(lcQpaWayland) << "using input method:" << inputContext()->metaObject()->className();
++    qCDebug(lcQpaWayland) << "using input method:" << (inputContext() ? inputContext()->metaObject()->className() : "<none>");
+ }
+ 
+ QWaylandShellIntegration *QWaylandIntegration::createShellIntegration(const QString &integrationName)
+diff --git a/qtwayland/src/client/qwaylandintegration_p.h b/qtwayland/src/client/qwaylandintegration_p.h
+index ff70ae25..73b80658 100644
+--- a/qtwayland/src/client/qwaylandintegration_p.h
++++ b/qtwayland/src/client/qwaylandintegration_p.h
+@@ -107,6 +107,8 @@ public:
+ 
+     QWaylandDisplay *display() const;
+ 
++    Qt::KeyboardModifiers queryKeyboardModifiers() const override;
++
+     QList<int> possibleKeys(const QKeyEvent *event) const override;
+ 
+     QStringList themeNames() const override;
+diff --git a/qtwayland/src/client/qwaylandprimaryselectionv1.cpp b/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
+index 832f9678..ea508771 100644
+--- a/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
++++ b/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
+@@ -54,11 +54,6 @@ QWaylandPrimarySelectionDeviceManagerV1::QWaylandPrimarySelectionDeviceManagerV1
+     : zwp_primary_selection_device_manager_v1(display->wl_registry(), id, qMin(version, uint(1)))
+     , m_display(display)
+ {
+-    // Create devices for all seats.
+-    // This only works if we get the global before all devices
+-    const auto seats = m_display->inputDevices();
+-    for (auto *seat : seats)
+-        seat->setPrimarySelectionDevice(createDevice(seat));
+ }
+ 
+ QWaylandPrimarySelectionDeviceV1 *QWaylandPrimarySelectionDeviceManagerV1::createDevice(QWaylandInputDevice *seat)
+diff --git a/qtwayland/src/client/qwaylandscreen.cpp b/qtwayland/src/client/qwaylandscreen.cpp
+index 6cb337de..5537dafd 100644
+--- a/qtwayland/src/client/qwaylandscreen.cpp
++++ b/qtwayland/src/client/qwaylandscreen.cpp
+@@ -60,7 +60,7 @@ QWaylandXdgOutputManagerV1::QWaylandXdgOutputManagerV1(QWaylandDisplay* display,
+ }
+ 
+ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uint32_t id)
+-    : QtWayland::wl_output(waylandDisplay->wl_registry(), id, qMin(version, 2))
++    : QtWayland::wl_output(waylandDisplay->wl_registry(), id, qMin(version, 3))
+     , m_outputId(id)
+     , mWaylandDisplay(waylandDisplay)
+     , mOutputName(QStringLiteral("Screen%1").arg(id))
+@@ -72,7 +72,7 @@ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uin
+         qCWarning(lcQpaWayland) << "wl_output done event not supported by compositor,"
+                                 << "QScreen may not work correctly";
+         mWaylandDisplay->forceRoundTrip(); // Give the compositor a chance to send geometry etc.
+-        mOutputDone = true; // Fake the done event
++        mProcessedEvents |= OutputDoneEvent; // Fake the done event
+         maybeInitialize();
+     }
+ }
+@@ -81,16 +81,29 @@ QWaylandScreen::~QWaylandScreen()
+ {
+     if (zxdg_output_v1::isInitialized())
+         zxdg_output_v1::destroy();
++    if (wl_output::isInitialized() && wl_output_get_version(wl_output::object()) >= WL_OUTPUT_RELEASE_SINCE_VERSION)
++        wl_output::release();
++}
++
++uint QWaylandScreen::requiredEvents() const
++{
++    uint ret = OutputDoneEvent;
++
++    if (mWaylandDisplay->xdgOutputManager()) {
++        ret |= XdgOutputNameEvent;
++
++        if (mWaylandDisplay->xdgOutputManager()->version() < 3)
++            ret |= XdgOutputDoneEvent;
++    }
++    return ret;
+ }
+ 
+ void QWaylandScreen::maybeInitialize()
+ {
+     Q_ASSERT(!mInitialized);
+ 
+-    if (!mOutputDone)
+-        return;
+-
+-    if (mWaylandDisplay->xdgOutputManager() && !mXdgOutputDone)
++    const uint requiredEvents = this->requiredEvents();
++    if ((mProcessedEvents & requiredEvents) != requiredEvents)
+         return;
+ 
+     mInitialized = true;
+@@ -276,9 +289,8 @@ void QWaylandScreen::output_scale(int32_t factor)
+ 
+ void QWaylandScreen::output_done()
+ {
+-    mOutputDone = true;
+-    if (zxdg_output_v1::isInitialized() && mWaylandDisplay->xdgOutputManager()->version() >= 3)
+-        mXdgOutputDone = true;
++    mProcessedEvents |= OutputDoneEvent;
++
+     if (mInitialized) {
+         updateOutputProperties();
+         if (zxdg_output_v1::isInitialized())
+@@ -339,7 +351,7 @@ void QWaylandScreen::zxdg_output_v1_done()
+     if (Q_UNLIKELY(mWaylandDisplay->xdgOutputManager()->version() >= 3))
+         qWarning(lcQpaWayland) << "zxdg_output_v1.done received on version 3 or newer, this is most likely a bug in the compositor";
+ 
+-    mXdgOutputDone = true;
++    mProcessedEvents |= XdgOutputDoneEvent;
+     if (mInitialized)
+         updateXdgOutputProperties();
+     else
+@@ -348,7 +360,11 @@ void QWaylandScreen::zxdg_output_v1_done()
+ 
+ void QWaylandScreen::zxdg_output_v1_name(const QString &name)
+ {
++    if (Q_UNLIKELY(mInitialized))
++        qWarning(lcQpaWayland) << "zxdg_output_v1.name received after output has been initialized, this is most likely a bug in the compositor";
++
+     mOutputName = name;
++    mProcessedEvents |= XdgOutputNameEvent;
+ }
+ 
+ void QWaylandScreen::updateXdgOutputProperties()
+diff --git a/qtwayland/src/client/qwaylandscreen_p.h b/qtwayland/src/client/qwaylandscreen_p.h
+index df1c94f2..050cfdc0 100644
+--- a/qtwayland/src/client/qwaylandscreen_p.h
++++ b/qtwayland/src/client/qwaylandscreen_p.h
+@@ -116,6 +116,13 @@ public:
+     static QWaylandScreen *fromWlOutput(::wl_output *output);
+ 
+ private:
++    enum Event : uint {
++        XdgOutputDoneEvent = 0x1,
++        OutputDoneEvent = 0x2,
++        XdgOutputNameEvent = 0x4,
++    };
++    uint requiredEvents() const;
++
+     void output_mode(uint32_t flags, int width, int height, int refresh) override;
+     void output_geometry(int32_t x, int32_t y,
+                          int32_t width, int32_t height,
+@@ -148,8 +155,7 @@ private:
+     QSize mPhysicalSize;
+     QString mOutputName;
+     Qt::ScreenOrientation m_orientation = Qt::PrimaryOrientation;
+-    bool mOutputDone = false;
+-    bool mXdgOutputDone = false;
++    uint mProcessedEvents = 0;
+     bool mInitialized = false;
+ 
+ #if QT_CONFIG(cursor)
+diff --git a/qtwayland/src/client/qwaylandshmbackingstore.cpp b/qtwayland/src/client/qwaylandshmbackingstore.cpp
+index dc7ff670..41cffdf7 100644
+--- a/qtwayland/src/client/qwaylandshmbackingstore.cpp
++++ b/qtwayland/src/client/qwaylandshmbackingstore.cpp
+@@ -52,6 +52,7 @@
+ 
+ #include <QtWaylandClient/private/wayland-wayland-client-protocol.h>
+ 
++#include <fcntl.h>
+ #include <unistd.h>
+ #include <sys/mman.h>
+ 
+@@ -61,6 +62,9 @@
+ #  ifndef MFD_CLOEXEC
+ #    define MFD_CLOEXEC     0x0001U
+ #  endif
++#  ifndef MFD_ALLOW_SEALING
++#    define MFD_ALLOW_SEALING 0x0002U
++#  endif
+ #endif
+ 
+ QT_BEGIN_NAMESPACE
+@@ -74,8 +78,10 @@ QWaylandShmBuffer::QWaylandShmBuffer(QWaylandDisplay *display,
+     int alloc = stride * size.height();
+     int fd = -1;
+ 
+-#ifdef SYS_memfd_create
+-    fd = syscall(SYS_memfd_create, "wayland-shm", MFD_CLOEXEC);
++#if defined(SYS_memfd_create) && defined(F_SEAL_SEAL)
++    fd = syscall(SYS_memfd_create, "wayland-shm", MFD_CLOEXEC | MFD_ALLOW_SEALING);
++    if (fd >= 0)
++        fcntl(fd, F_ADD_SEALS, F_SEAL_SHRINK | F_SEAL_SEAL);
+ #endif
+ 
+     QScopedPointer<QFile> filePointer;
+diff --git a/qtwayland/src/client/qwaylandwindow.cpp b/qtwayland/src/client/qwaylandwindow.cpp
+index cb82857a..fb2c59dc 100644
+--- a/qtwayland/src/client/qwaylandwindow.cpp
++++ b/qtwayland/src/client/qwaylandwindow.cpp
+@@ -76,7 +76,6 @@ QWaylandWindow *QWaylandWindow::mMouseGrab = nullptr;
+ QWaylandWindow::QWaylandWindow(QWindow *window, QWaylandDisplay *display)
+     : QPlatformWindow(window)
+     , mDisplay(display)
+-    , mFrameQueue(mDisplay->createFrameQueue())
+     , mResizeAfterSwap(qEnvironmentVariableIsSet("QT_WAYLAND_RESIZE_AFTER_SWAP"))
+ {
+     {
+@@ -95,9 +94,6 @@ QWaylandWindow::QWaylandWindow(QWindow *window, QWaylandDisplay *display)
+ 
+ QWaylandWindow::~QWaylandWindow()
+ {
+-    mDisplay->destroyFrameQueue(mFrameQueue);
+-    mDisplay->handleWindowDestroyed(this);
+-
+     delete mWindowDecoration;
+ 
+     if (mSurface)
+@@ -243,6 +239,7 @@ bool QWaylandWindow::shouldCreateSubSurface() const
+ 
+ void QWaylandWindow::reset()
+ {
++    closeChildPopups();
+     delete mShellSurface;
+     mShellSurface = nullptr;
+     delete mSubSurfaceWindow;
+@@ -255,17 +252,22 @@ void QWaylandWindow::reset()
+         mSurface.reset();
+     }
+ 
+-    if (mFrameCallback) {
+-        wl_callback_destroy(mFrameCallback);
+-        mFrameCallback = nullptr;
+-    }
++    {
++        QMutexLocker lock(&mFrameSyncMutex);
++        if (mFrameCallback) {
++            wl_callback_destroy(mFrameCallback);
++            mFrameCallback = nullptr;
++        }
+ 
+-    mFrameCallbackElapsedTimer.invalidate();
+-    mWaitingForFrameCallback = false;
++        mFrameCallbackElapsedTimer.invalidate();
++        mWaitingForFrameCallback = false;
++    }
+     mFrameCallbackTimedOut = false;
+ 
+     mMask = QRegion();
+     mQueuedBuffer = nullptr;
++
++    mDisplay->handleWindowDestroyed(this);
+ }
+ 
+ QWaylandWindow *QWaylandWindow::fromWlSurface(::wl_surface *surface)
+@@ -351,19 +353,25 @@ void QWaylandWindow::setGeometry_helper(const QRect &rect)
+     }
+ }
+ 
+-void QWaylandWindow::setGeometry(const QRect &rect)
++void QWaylandWindow::setGeometry(const QRect &r)
+ {
++    auto rect = r;
++    if (fixedToplevelPositions && !QPlatformWindow::parent() && window()->type() != Qt::Popup
++        && window()->type() != Qt::ToolTip) {
++        rect.moveTo(screen()->geometry().topLeft());
++    }
+     setGeometry_helper(rect);
+ 
+     if (window()->isVisible() && rect.isValid()) {
+         if (mWindowDecoration)
+             mWindowDecoration->update();
+ 
+-        if (mResizeAfterSwap && windowType() == Egl && mSentInitialResize)
++        if (mResizeAfterSwap && windowType() == Egl && mSentInitialResize) {
++            QMutexLocker lock(&mResizeLock);
+             mResizeDirty = true;
+-        else
++        } else {
+             QWindowSystemInterface::handleGeometryChange(window(), geometry());
+-
++        }
+         mSentInitialResize = true;
+     }
+     QRect exposeGeometry(QPoint(), geometry().size());
+@@ -374,7 +382,7 @@ void QWaylandWindow::setGeometry(const QRect &rect)
+         mShellSurface->setWindowGeometry(windowContentGeometry());
+ 
+     if (isOpaque() && mMask.isEmpty())
+-        setOpaqueArea(rect);
++        setOpaqueArea(QRect(QPoint(0, 0), rect.size()));
+ }
+ 
+ void QWaylandWindow::resizeFromApplyConfigure(const QSize &sizeWithMargins, const QPoint &offset)
+@@ -399,21 +407,6 @@ void QWaylandWindow::sendExposeEvent(const QRect &rect)
+     mLastExposeGeometry = rect;
+ }
+ 
+-
+-static QVector<QPointer<QWaylandWindow>> activePopups;
+-
+-void QWaylandWindow::closePopups(QWaylandWindow *parent)
+-{
+-    while (!activePopups.isEmpty()) {
+-        auto popup = activePopups.takeLast();
+-        if (popup.isNull())
+-            continue;
+-        if (popup.data() == parent)
+-            return;
+-        popup->reset();
+-    }
+-}
+-
+ QPlatformScreen *QWaylandWindow::calculateScreenFromSurfaceEvents() const
+ {
+     QReadLocker lock(&mSurfaceLock);
+@@ -433,10 +426,7 @@ void QWaylandWindow::setVisible(bool visible)
+     lastVisible = visible;
+ 
+     if (visible) {
+-        if (window()->type() == Qt::Popup || window()->type() == Qt::ToolTip)
+-            activePopups << this;
+         initWindow();
+-        mDisplay->flushRequests();
+ 
+         setGeometry(windowGeometry());
+         // Don't flush the events here, or else the newly visible window may start drawing, but since
+@@ -444,7 +434,6 @@ void QWaylandWindow::setVisible(bool visible)
+         // QWaylandShmBackingStore::beginPaint().
+     } else {
+         sendExposeEvent(QRect());
+-        closePopups(this);
+         reset();
+     }
+ }
+@@ -556,12 +545,12 @@ void QWaylandWindow::sendRecursiveExposeEvent()
+ 
+ void QWaylandWindow::attach(QWaylandBuffer *buffer, int x, int y)
+ {
+-    Q_ASSERT(!buffer->committed());
+     QReadLocker locker(&mSurfaceLock);
+     if (mSurface == nullptr)
+         return;
+ 
+     if (buffer) {
++        Q_ASSERT(!buffer->committed());
+         handleUpdate();
+         buffer->setBusy();
+ 
+@@ -583,7 +572,11 @@ void QWaylandWindow::damage(const QRect &rect)
+     if (mSurface == nullptr)
+         return;
+ 
+-    mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    const int s = scale();
++    if (mDisplay->compositorVersion() >= 4)
++        mSurface->damage_buffer(s * rect.x(), s * rect.y(), s * rect.width(), s * rect.height());
++    else
++        mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
+ }
+ 
+ void QWaylandWindow::safeCommit(QWaylandBuffer *buffer, const QRegion &damage)
+@@ -619,8 +612,14 @@ void QWaylandWindow::commit(QWaylandBuffer *buffer, const QRegion &damage)
+         return;
+ 
+     attachOffset(buffer);
+-    for (const QRect &rect: damage)
+-        mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    if (mDisplay->compositorVersion() >= 4) {
++        const int s = scale();
++        for (const QRect &rect: damage)
++            mSurface->damage_buffer(s * rect.x(), s * rect.y(), s * rect.width(), s * rect.height());
++    } else {
++        for (const QRect &rect: damage)
++            mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    }
+     Q_ASSERT(!buffer->committed());
+     buffer->setCommitted();
+     mSurface->commit();
+@@ -635,42 +634,53 @@ void QWaylandWindow::commit()
+ 
+ const wl_callback_listener QWaylandWindow::callbackListener = {
+     [](void *data, wl_callback *callback, uint32_t time) {
+-        Q_UNUSED(callback);
+         Q_UNUSED(time);
+         auto *window = static_cast<QWaylandWindow*>(data);
+-        window->handleFrameCallback();
++        window->handleFrameCallback(callback);
+     }
+ };
+ 
+-void QWaylandWindow::handleFrameCallback()
++void QWaylandWindow::handleFrameCallback(wl_callback* callback)
+ {
++    QMutexLocker locker(&mFrameSyncMutex);
++    if (!mFrameCallback) {
++        // This means the callback is already unset by QWaylandWindow::reset.
++        // The wl_callback object will be destroyed there too.
++        return;
++    }
++    Q_ASSERT(callback == mFrameCallback);
++    wl_callback_destroy(callback);
++    mFrameCallback = nullptr;
++
+     mWaitingForFrameCallback = false;
+     mFrameCallbackElapsedTimer.invalidate();
+ 
+     // The rest can wait until we can run it on the correct thread
+-    if (!mWaitingForUpdateDelivery) {
+-        auto doHandleExpose = [this]() {
+-            bool wasExposed = isExposed();
+-            mFrameCallbackTimedOut = false;
+-            if (!wasExposed && isExposed()) // Did setting mFrameCallbackTimedOut make the window exposed?
+-                sendExposeEvent(QRect(QPoint(), geometry().size()));
+-            if (wasExposed && hasPendingUpdateRequest())
+-                deliverUpdateRequest();
+-
+-            mWaitingForUpdateDelivery = false;
+-        };
++    auto doHandleExpose = [this]() {
++        mWaitingForUpdateDelivery.storeRelease(false);
++        bool wasExposed = isExposed();
++        mFrameCallbackTimedOut = false;
++        if (!wasExposed && isExposed()) // Did setting mFrameCallbackTimedOut make the window exposed?
++            sendExposeEvent(QRect(QPoint(), geometry().size()));
++        if (wasExposed && hasPendingUpdateRequest())
++            deliverUpdateRequest();
++    };
+ 
++    if (mWaitingForUpdateDelivery.testAndSetAcquire(false, true)) {
+         // Queued connection, to make sure we don't call handleUpdate() from inside waitForFrameSync()
+         // in the single-threaded case.
+-        mWaitingForUpdateDelivery = true;
+         QMetaObject::invokeMethod(this, doHandleExpose, Qt::QueuedConnection);
+     }
++
++    mFrameSyncWait.notify_all();
+ }
+ 
+ bool QWaylandWindow::waitForFrameSync(int timeout)
+ {
+-    QMutexLocker locker(mFrameQueue.mutex);
+-    mDisplay->dispatchQueueWhile(mFrameQueue.queue, [&]() { return mWaitingForFrameCallback; }, timeout);
++    QMutexLocker locker(&mFrameSyncMutex);
++
++    QDeadlineTimer deadline(timeout);
++    while (mWaitingForFrameCallback && mFrameSyncWait.wait(&mFrameSyncMutex, deadline)) { }
+ 
+     if (mWaitingForFrameCallback) {
+         qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
+@@ -868,6 +878,17 @@ bool QWaylandWindow::createDecoration()
+             subsurf->set_position(pos.x() + m.left(), pos.y() + m.top());
+         }
+         sendExposeEvent(QRect(QPoint(), geometry().size()));
++
++        // This is a special case where the buffer is recreated, but since
++        // the content rect remains the same, the widgets remain the same
++        // size and are not redrawn, leaving the new buffer empty. As a simple
++        // work-around, we trigger a full extra update whenever the client-side
++        // window decorations are toggled while the window is showing.
++        // Note: createDecoration() is sometimes called from the render thread
++        // of Qt Quick. This is essentially wrong and could potentially cause problems,
++        // but until the underlying issue has been fixed, we have to use invokeMethod()
++        // here to avoid asserts.
++        QMetaObject::invokeMethod(window(), &QWindow::requestUpdate);
+     }
+ 
+     return mWindowDecoration;
+@@ -1023,6 +1044,13 @@ void QWaylandWindow::handleScreensChanged()
+ 
+     QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->QPlatformScreen::screen());
+     mLastReportedScreen = newScreen;
++    if (fixedToplevelPositions && !QPlatformWindow::parent() && window()->type() != Qt::Popup
++        && window()->type() != Qt::ToolTip
++        && geometry().topLeft() != newScreen->geometry().topLeft()) {
++        auto geometry = this->geometry();
++        geometry.moveTo(newScreen->geometry().topLeft());
++        setGeometry(geometry);
++    }
+ 
+     int scale = newScreen->isPlaceholder() ? 1 : static_cast<QWaylandScreen *>(newScreen)->scale();
+     if (scale != mScale) {
+@@ -1094,10 +1122,18 @@ bool QWaylandWindow::setMouseGrabEnabled(bool grab)
+     return true;
+ }
+ 
++Qt::WindowStates QWaylandWindow::windowStates() const
++{
++    return mLastReportedWindowStates;
++}
++
+ void QWaylandWindow::handleWindowStatesChanged(Qt::WindowStates states)
+ {
+     createDecoration();
+-    QWindowSystemInterface::handleWindowStateChanged(window(), states, mLastReportedWindowStates);
++    Qt::WindowStates statesWithoutActive = states & ~Qt::WindowActive;
++    Qt::WindowStates lastStatesWithoutActive = mLastReportedWindowStates & ~Qt::WindowActive;
++    QWindowSystemInterface::handleWindowStateChanged(window(), statesWithoutActive,
++                                                     lastStatesWithoutActive);
+     mLastReportedWindowStates = states;
+ }
+ 
+@@ -1139,19 +1175,24 @@ void QWaylandWindow::timerEvent(QTimerEvent *event)
+     if (event->timerId() != mFrameCallbackCheckIntervalTimerId)
+         return;
+ 
+-    bool callbackTimerExpired = mFrameCallbackElapsedTimer.hasExpired(mFrameCallbackTimeout);
+-    if (!mFrameCallbackElapsedTimer.isValid() || callbackTimerExpired ) {
+-        killTimer(mFrameCallbackCheckIntervalTimerId);
+-        mFrameCallbackCheckIntervalTimerId = -1;
+-    }
+-    if (mFrameCallbackElapsedTimer.isValid() && callbackTimerExpired) {
+-        mFrameCallbackElapsedTimer.invalidate();
++    {
++        QMutexLocker lock(&mFrameSyncMutex);
+ 
+-        qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
+-        mFrameCallbackTimedOut = true;
+-        mWaitingForUpdate = false;
+-        sendExposeEvent(QRect());
++        bool callbackTimerExpired = mFrameCallbackElapsedTimer.hasExpired(mFrameCallbackTimeout);
++        if (!mFrameCallbackElapsedTimer.isValid() || callbackTimerExpired ) {
++            killTimer(mFrameCallbackCheckIntervalTimerId);
++            mFrameCallbackCheckIntervalTimerId = -1;
++        }
++        if (!mFrameCallbackElapsedTimer.isValid() || !callbackTimerExpired) {
++            return;
++        }
++        mFrameCallbackElapsedTimer.invalidate();
+     }
++
++    qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
++    mFrameCallbackTimedOut = true;
++    mWaitingForUpdate = false;
++    sendExposeEvent(QRect());
+ }
+ 
+ void QWaylandWindow::requestUpdate()
+@@ -1160,8 +1201,11 @@ void QWaylandWindow::requestUpdate()
+     Q_ASSERT(hasPendingUpdateRequest()); // should be set by QPA
+ 
+     // If we have a frame callback all is good and will be taken care of there
+-    if (mWaitingForFrameCallback)
+-        return;
++    {
++        QMutexLocker locker(&mFrameSyncMutex);
++        if (mWaitingForFrameCallback)
++            return;
++    }
+ 
+     // If we've already called deliverUpdateRequest(), but haven't seen any attach+commit/swap yet
+     // This is a somewhat redundant behavior and might indicate a bug in the calling code, so log
+@@ -1174,7 +1218,12 @@ void QWaylandWindow::requestUpdate()
+     // so use invokeMethod to delay the delivery a bit.
+     QMetaObject::invokeMethod(this, [this] {
+         // Things might have changed in the meantime
+-        if (hasPendingUpdateRequest() && !mWaitingForFrameCallback)
++        {
++            QMutexLocker locker(&mFrameSyncMutex);
++            if (mWaitingForFrameCallback)
++                return;
++        }
++        if (hasPendingUpdateRequest())
+             deliverUpdateRequest();
+     }, Qt::QueuedConnection);
+ }
+@@ -1185,19 +1234,18 @@ void QWaylandWindow::requestUpdate()
+ void QWaylandWindow::handleUpdate()
+ {
+     qCDebug(lcWaylandBackingstore) << "handleUpdate" << QThread::currentThread();
++
+     // TODO: Should sync subsurfaces avoid requesting frame callbacks?
+     QReadLocker lock(&mSurfaceLock);
+     if (!mSurface)
+         return;
+ 
+-    if (mFrameCallback) {
+-        wl_callback_destroy(mFrameCallback);
+-        mFrameCallback = nullptr;
+-    }
++    QMutexLocker locker(&mFrameSyncMutex);
++    if (mWaitingForFrameCallback)
++        return;
+ 
+-    QMutexLocker locker(mFrameQueue.mutex);
+     struct ::wl_surface *wrappedSurface = reinterpret_cast<struct ::wl_surface *>(wl_proxy_create_wrapper(mSurface->object()));
+-    wl_proxy_set_queue(reinterpret_cast<wl_proxy *>(wrappedSurface), mFrameQueue.queue);
++    wl_proxy_set_queue(reinterpret_cast<wl_proxy *>(wrappedSurface), mDisplay->frameEventQueue());
+     mFrameCallback = wl_surface_frame(wrappedSurface);
+     wl_proxy_wrapper_destroy(wrappedSurface);
+     wl_callback_add_listener(mFrameCallback, &QWaylandWindow::callbackListener, this);
+@@ -1207,6 +1255,8 @@ void QWaylandWindow::handleUpdate()
+     // Start a timer for handling the case when the compositor stops sending frame callbacks.
+     if (mFrameCallbackTimeout > 0) {
+         QMetaObject::invokeMethod(this, [this] {
++            QMutexLocker locker(&mFrameSyncMutex);
++
+             if (mWaitingForFrameCallback) {
+                 if (mFrameCallbackCheckIntervalTimerId < 0)
+                     mFrameCallbackCheckIntervalTimerId = startTimer(mFrameCallbackTimeout);
+@@ -1267,6 +1317,20 @@ void QWaylandWindow::setOpaqueArea(const QRegion &opaqueArea)
+     wl_region_destroy(region);
+ }
+ 
++void QWaylandWindow::addChildPopup(QWaylandWindow *surface) {
++    mChildPopups.append(surface);
++}
++
++void QWaylandWindow::removeChildPopup(QWaylandWindow *surface) {
++    mChildPopups.removeAll(surface);
++}
++
++void QWaylandWindow::closeChildPopups() {
++    while (!mChildPopups.isEmpty()) {
++        auto popup = mChildPopups.takeLast();
++        popup->reset();
++    }
++}
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/client/qwaylandwindow_p.h b/qtwayland/src/client/qwaylandwindow_p.h
+index 01337cff..2f219d8c 100644
+--- a/qtwayland/src/client/qwaylandwindow_p.h
++++ b/qtwayland/src/client/qwaylandwindow_p.h
+@@ -98,6 +98,9 @@ public:
+     QWaylandWindow(QWindow *window, QWaylandDisplay *display);
+     ~QWaylandWindow() override;
+ 
++    // Keep Toplevels position on the top left corner of their screen
++    static inline bool fixedToplevelPositions = true;
++
+     virtual WindowType windowType() const = 0;
+     virtual void ensureSize();
+     WId winId() const override;
+@@ -148,6 +151,7 @@ public:
+     void setWindowState(Qt::WindowStates states) override;
+     void setWindowFlags(Qt::WindowFlags flags) override;
+     void handleWindowStatesChanged(Qt::WindowStates states);
++    Qt::WindowStates windowStates() const;
+ 
+     void raise() override;
+     void lower() override;
+@@ -206,6 +210,10 @@ public:
+     void handleUpdate();
+     void deliverUpdateRequest() override;
+ 
++    void addChildPopup(QWaylandWindow* child);
++    void removeChildPopup(QWaylandWindow* child);
++    void closeChildPopups();
++
+ public slots:
+     void applyConfigure();
+ 
+@@ -215,7 +223,11 @@ signals:
+ 
+ protected:
+     QWaylandDisplay *mDisplay = nullptr;
++
++    // mSurface can be written by the main thread. Other threads should claim a read lock for access
++    mutable QReadWriteLock mSurfaceLock;
+     QScopedPointer<QWaylandSurface> mSurface;
++
+     QWaylandShellSurface *mShellSurface = nullptr;
+     QWaylandSubSurface *mSubSurfaceWindow = nullptr;
+     QVector<QWaylandSubSurface *> mChildren;
+@@ -225,13 +237,14 @@ protected:
+     Qt::MouseButtons mMousePressedInContentArea = Qt::NoButton;
+ 
+     WId mWindowId;
+-    bool mWaitingForFrameCallback = false;
+     bool mFrameCallbackTimedOut = false; // Whether the frame callback has timed out
+-    bool mWaitingForUpdateDelivery = false;
+     int mFrameCallbackCheckIntervalTimerId = -1;
+-    QElapsedTimer mFrameCallbackElapsedTimer;
+-    struct ::wl_callback *mFrameCallback = nullptr;
+-    QWaylandDisplay::FrameQueue mFrameQueue;
++    QAtomicInt mWaitingForUpdateDelivery = false;
++
++    bool mWaitingForFrameCallback = false; // Protected by mFrameSyncMutex
++    QElapsedTimer mFrameCallbackElapsedTimer; // Protected by mFrameSyncMutex
++    struct ::wl_callback *mFrameCallback = nullptr; // Protected by mFrameSyncMutex
++    QMutex mFrameSyncMutex;
+     QWaitCondition mFrameSyncWait;
+ 
+     // True when we have called deliverRequestUpdate, but the client has not yet attached a new buffer
+@@ -261,6 +274,8 @@ protected:
+     QWaylandBuffer *mQueuedBuffer = nullptr;
+     QRegion mQueuedBufferDamage;
+ 
++    QList<QPointer<QWaylandWindow>> mChildPopups;
++
+ private:
+     void setGeometry_helper(const QRect &rect);
+     void initWindow();
+@@ -283,12 +298,10 @@ private:
+     QRect mLastExposeGeometry;
+ 
+     static const wl_callback_listener callbackListener;
+-    void handleFrameCallback();
++    void handleFrameCallback(struct ::wl_callback* callback);
+ 
+     static QWaylandWindow *mMouseGrab;
+ 
+-    mutable QReadWriteLock mSurfaceLock;
+-
+     friend class QWaylandSubSurface;
+ };
+ 
+diff --git a/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h b/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
+index ccad0048..4cc9b3b8 100644
+--- a/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
++++ b/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
+@@ -73,11 +73,10 @@ public:
+         return true;
+     }
+     virtual QWaylandShellSurface *createShellSurface(QWaylandWindow *window) = 0;
++    // kept for binary compat with layer-shell-qt
+     virtual void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) {
+-        if (newFocus)
+-            m_display->handleWindowActivated(newFocus);
+-        if (oldFocus)
+-            m_display->handleWindowDeactivated(oldFocus);
++        Q_UNUSED(newFocus);
++        Q_UNUSED(oldFocus);
+     }
+     virtual void *nativeResourceForWindow(const QByteArray &resource, QWindow *window) {
+         Q_UNUSED(resource);
+diff --git a/qtwayland/src/compositor/configure.json b/qtwayland/src/compositor/configure.json
+index bcfd5215..da95d07b 100644
+--- a/qtwayland/src/compositor/configure.json
++++ b/qtwayland/src/compositor/configure.json
+@@ -7,6 +7,31 @@
+     "testDir": "../../config.tests",
+ 
+     "libraries": {
++        "wayland-client": {
++            "label": "Wayland client library",
++            "headers": "wayland-version.h",
++            "test": {
++                "main": [
++                    "#if WAYLAND_VERSION_MAJOR < 1",
++                    "# error Wayland 1.8.0 or higher required",
++                    "#endif",
++                    "#if WAYLAND_VERSION_MAJOR == 1",
++                    "# if WAYLAND_VERSION_MINOR < 8",
++                    "#  error Wayland 1.8.0 or higher required",
++                    "# endif",
++                    "# if WAYLAND_VERSION_MINOR == 8",
++                    "#  if WAYLAND_VERSION_MICRO < 0",
++                    "#   error Wayland 1.8.0 or higher required",
++                    "#  endif",
++                    "# endif",
++                    "#endif"
++                 ]
++            },
++            "sources": [
++                { "type": "pkgConfig", "args": "wayland-client" },
++                "-lwayland-client"
++            ]
++        },
+         "wayland-server": {
+             "label": "wayland-server",
+             "headers": "wayland-version.h",
+@@ -151,8 +176,7 @@
+                     "#endif"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "dmabuf-client-buffer": {
+             "label": "Linux Client dma-buf Buffer Sharing",
+@@ -176,8 +200,7 @@
+                     "return 0;"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "vulkan-server-buffer": {
+             "label": "Vulkan Buffer Sharing",
+@@ -195,7 +218,8 @@
+                     "exportAllocInfo.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR;",
+                     "return 0;"
+                 ]
+-            }
++            },
++            "use": "wayland-client"
+         }
+     },
+ 
+diff --git a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
+index 7889f575..64140672 100644
+--- a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
++++ b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
+@@ -40,6 +40,7 @@
+ #include "qwaylandeglwindow.h"
+ 
+ #include <QtWaylandClient/private/qwaylandscreen_p.h>
++#include <QtWaylandClient/private/qwaylandsurface_p.h>
+ #include "qwaylandglcontext.h"
+ 
+ #include <QtEglSupport/private/qeglconvenience_p.h>
+@@ -124,6 +125,7 @@ void QWaylandEglWindow::updateSurface(bool create)
+         }
+         mOffset = QPoint();
+     } else {
++        QReadLocker locker(&mSurfaceLock);
+         if (m_waylandEglWindow) {
+             int current_width, current_height;
+             static bool disableResizeCheck = qgetenv("QT_WAYLAND_DISABLE_RESIZECHECK").toInt();
+@@ -131,14 +133,16 @@ void QWaylandEglWindow::updateSurface(bool create)
+             if (!disableResizeCheck) {
+                 wl_egl_window_get_attached_size(m_waylandEglWindow, &current_width, &current_height);
+             }
+-            if (disableResizeCheck || (current_width != sizeWithMargins.width() || current_height != sizeWithMargins.height())) {
++            if (disableResizeCheck || (current_width != sizeWithMargins.width() || current_height != sizeWithMargins.height()) || m_requestedSize != sizeWithMargins) {
+                 wl_egl_window_resize(m_waylandEglWindow, sizeWithMargins.width(), sizeWithMargins.height(), mOffset.x(), mOffset.y());
++                m_requestedSize = sizeWithMargins;
+                 mOffset = QPoint();
+ 
+                 m_resize = true;
+             }
+-        } else if (create && wlSurface()) {
+-            m_waylandEglWindow = wl_egl_window_create(wlSurface(), sizeWithMargins.width(), sizeWithMargins.height());
++        } else if (create && mSurface) {
++            m_waylandEglWindow = wl_egl_window_create(mSurface->object(), sizeWithMargins.width(), sizeWithMargins.height());
++            m_requestedSize = sizeWithMargins;
+         }
+ 
+         if (!m_eglSurface && m_waylandEglWindow && create) {
+diff --git a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
+index 5b1f4d56..0079dfef 100644
+--- a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
++++ b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
+@@ -88,6 +88,7 @@ private:
+     mutable QOpenGLFramebufferObject *m_contentFBO = nullptr;
+ 
+     QSurfaceFormat m_format;
++    QSize m_requestedSize;
+ };
+ 
+ }
+diff --git a/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h b/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
+index 56a710c3..c6a8b6c6 100644
+--- a/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
++++ b/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
+@@ -41,6 +41,8 @@
+ #include <QtCore/QTextStream>
+ #include <QtGui/QOpenGLTexture>
+ 
++#include <array>
++
+ #include <EGL/egl.h>
+ #include <EGL/eglext.h>
+ 
+diff --git a/qtwayland/src/plugins/decorations/bradient/main.cpp b/qtwayland/src/plugins/decorations/bradient/main.cpp
+index e75fda3c..fa885143 100644
+--- a/qtwayland/src/plugins/decorations/bradient/main.cpp
++++ b/qtwayland/src/plugins/decorations/bradient/main.cpp
+@@ -164,13 +164,10 @@ void QWaylandBradientDecoration::paint(QPaintDevice *device)
+     // Window icon
+     QIcon icon = waylandWindow()->windowIcon();
+     if (!icon.isNull()) {
+-        QPixmap pixmap = icon.pixmap(QSize(128, 128));
+-        QPixmap scaled = pixmap.scaled(22, 22, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+-
+         QRectF iconRect(0, 0, 22, 22);
+-        p.drawPixmap(iconRect.adjusted(margins().left() + BUTTON_SPACING, 4,
+-                                       margins().left() + BUTTON_SPACING, 4),
+-                     scaled, iconRect);
++        iconRect.adjust(margins().left() + BUTTON_SPACING, 4,
++                        margins().left() + BUTTON_SPACING, 4),
++        icon.paint(&p, iconRect.toRect());
+     }
+ 
+     // Window title
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
+index 85d25e3c..60bdd491 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
+@@ -47,18 +47,21 @@ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
+-QWaylandXdgPopupV5::QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow *window)
++QWaylandXdgPopupV5::QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow* parent, QWaylandWindow *window)
+     : QWaylandShellSurface(window)
+     , QtWayland::xdg_popup_v5(popup)
++    , m_parent(parent)
+     , m_window(window)
+ {
+     if (window->display()->windowExtension())
+         m_extendedWindow = new QWaylandExtendedSurface(window);
++    m_parent->addChildPopup(m_window);
+ }
+ 
+ QWaylandXdgPopupV5::~QWaylandXdgPopupV5()
+ {
+     xdg_popup_destroy(object());
++    m_parent->removeChildPopup(m_window);
+     delete m_extendedWindow;
+ }
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
+index 7494f6a6..d85f130b 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
+@@ -70,7 +70,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgPopupV5 : public QWaylandShellSurface
+ {
+     Q_OBJECT
+ public:
+-    QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow *window);
++    QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow* parent, QWaylandWindow *window);
+     ~QWaylandXdgPopupV5() override;
+ 
+ protected:
+@@ -78,6 +78,7 @@ protected:
+ 
+ private:
+     QWaylandExtendedSurface *m_extendedWindow = nullptr;
++    QWaylandWindow *m_parent = nullptr;
+     QWaylandWindow *m_window = nullptr;
+ };
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
+index 7e242c4a..def8452a 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
+@@ -84,7 +84,7 @@ QWaylandXdgPopupV5 *QWaylandXdgShellV5::createXdgPopup(QWaylandWindow *window, Q
+     int x = position.x() + parentWindow->frameMargins().left();
+     int y = position.y() + parentWindow->frameMargins().top();
+ 
+-    auto popup = new QWaylandXdgPopupV5(get_xdg_popup(window->wlSurface(), parentSurface, seat, m_popupSerial, x, y), window);
++    auto popup = new QWaylandXdgPopupV5(get_xdg_popup(window->wlSurface(), parentSurface, seat, m_popupSerial, x, y), parentWindow, window);
+     m_popups.append(window);
+     QObject::connect(popup, &QWaylandXdgPopupV5::destroyed, [this, window](){
+         m_popups.removeOne(window);
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
+index 4e25949f..cfc60939 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
+@@ -85,13 +85,6 @@ QWaylandShellSurface *QWaylandXdgShellV5Integration::createShellSurface(QWayland
+     return m_xdgShell->createXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellV5Integration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) {
+-    if (newFocus && qobject_cast<QWaylandXdgPopupV5 *>(newFocus->shellSurface()))
+-        m_display->handleWindowActivated(newFocus);
+-    if (oldFocus && qobject_cast<QWaylandXdgPopupV5 *>(oldFocus->shellSurface()))
+-        m_display->handleWindowDeactivated(oldFocus);
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
+index ce6bdb9e..aed88670 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
+@@ -67,7 +67,6 @@ public:
+     QWaylandXdgShellV5Integration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShellV5> m_xdgShell;
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
+index 8c371661..151c78e3 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
+@@ -174,6 +174,7 @@ QWaylandXdgSurfaceV6::Popup::Popup(QWaylandXdgSurfaceV6 *xdgSurface, QWaylandXdg
+     , m_xdgSurface(xdgSurface)
+     , m_parent(parent)
+ {
++    m_parent->window()->addChildPopup(m_xdgSurface->window());
+ }
+ 
+ QWaylandXdgSurfaceV6::Popup::~Popup()
+@@ -181,6 +182,8 @@ QWaylandXdgSurfaceV6::Popup::~Popup()
+     if (isInitialized())
+         destroy();
+ 
++    m_parent->window()->removeChildPopup(m_xdgSurface->window());
++
+     if (m_grabbing) {
+         auto *shell = m_xdgSurface->m_shell;
+         Q_ASSERT(shell->m_topmostGrabbingPopup == this);
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
+index 03164316..e8da8ba1 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
+@@ -68,20 +68,6 @@ QWaylandShellSurface *QWaylandXdgShellV6Integration::createShellSurface(QWayland
+     return m_xdgShell->getXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellV6Integration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus)
+-{
+-    if (newFocus) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurfaceV6 *>(newFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowActivated(newFocus);
+-    }
+-    if (oldFocus && qobject_cast<QWaylandXdgSurfaceV6 *>(oldFocus->shellSurface())) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurfaceV6 *>(oldFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowDeactivated(oldFocus);
+-    }
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
+index 261f8cbb..c1bcd5c6 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
+@@ -65,7 +65,6 @@ public:
+     QWaylandXdgShellV6Integration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShellV6> m_xdgShell;
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
+index f3e3c330..fa6d5808 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
+@@ -67,11 +67,6 @@ QWaylandXdgSurface::Toplevel::Toplevel(QWaylandXdgSurface *xdgSurface)
+ 
+ QWaylandXdgSurface::Toplevel::~Toplevel()
+ {
+-    if (m_applied.states & Qt::WindowActive) {
+-        QWaylandWindow *window = m_xdgSurface->window();
+-        window->display()->handleWindowDeactivated(window);
+-    }
+-
+     // The protocol spec requires that the decoration object is deleted before xdg_toplevel.
+     delete m_decoration;
+     m_decoration = nullptr;
+@@ -85,16 +80,15 @@ void QWaylandXdgSurface::Toplevel::applyConfigure()
+     if (!(m_applied.states & (Qt::WindowMaximized|Qt::WindowFullScreen)))
+         m_normalSize = m_xdgSurface->m_window->windowFrameGeometry().size();
+ 
+-    if ((m_pending.states & Qt::WindowActive) && !(m_applied.states & Qt::WindowActive))
++    if ((m_pending.states & Qt::WindowActive) && !(m_applied.states & Qt::WindowActive)
++        && !m_xdgSurface->m_window->display()->isKeyboardAvailable())
+         m_xdgSurface->m_window->display()->handleWindowActivated(m_xdgSurface->m_window);
+ 
+-    if (!(m_pending.states & Qt::WindowActive) && (m_applied.states & Qt::WindowActive))
++    if (!(m_pending.states & Qt::WindowActive) && (m_applied.states & Qt::WindowActive)
++        && !m_xdgSurface->m_window->display()->isKeyboardAvailable())
+         m_xdgSurface->m_window->display()->handleWindowDeactivated(m_xdgSurface->m_window);
+ 
+-    // TODO: none of the other plugins send WindowActive either, but is it on purpose?
+-    Qt::WindowStates statesWithoutActive = m_pending.states & ~Qt::WindowActive;
+-
+-    m_xdgSurface->m_window->handleWindowStatesChanged(statesWithoutActive);
++    m_xdgSurface->m_window->handleWindowStatesChanged(m_pending.states);
+ 
+     if (m_pending.size.isEmpty()) {
+         // An empty size in the configure means it's up to the client to choose the size
+@@ -105,8 +99,6 @@ void QWaylandXdgSurface::Toplevel::applyConfigure()
+         m_xdgSurface->m_window->resizeFromApplyConfigure(m_pending.size);
+     }
+ 
+-    m_xdgSurface->setSizeHints();
+-
+     m_applied = m_pending;
+     qCDebug(lcQpaWayland) << "Applied pending xdg_toplevel configure event:" << m_applied.size << m_applied.states;
+ }
+@@ -203,12 +195,17 @@ QtWayland::xdg_toplevel::resize_edge QWaylandXdgSurface::Toplevel::convertToResi
+                 | ((edges & Qt::RightEdge) ? resize_edge_right : 0));
+ }
+ 
+-QWaylandXdgSurface::Popup::Popup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parent,
++QWaylandXdgSurface::Popup::Popup(QWaylandXdgSurface *xdgSurface, QWaylandWindow *parent,
+                                  QtWayland::xdg_positioner *positioner)
+-    : xdg_popup(xdgSurface->get_popup(parent->object(), positioner->object()))
+-    , m_xdgSurface(xdgSurface)
++    : m_xdgSurface(xdgSurface)
++    , m_parentXdgSurface(qobject_cast<QWaylandXdgSurface *>(parent->shellSurface()))
+     , m_parent(parent)
+ {
++
++    init(xdgSurface->get_popup(m_parentXdgSurface ? m_parentXdgSurface->object() : nullptr, positioner->object()));
++    if (m_parent) {
++        m_parent->addChildPopup(m_xdgSurface->window());
++    }
+ }
+ 
+ QWaylandXdgSurface::Popup::~Popup()
+@@ -216,10 +213,24 @@ QWaylandXdgSurface::Popup::~Popup()
+     if (isInitialized())
+         destroy();
+ 
++    if (m_parent) {
++        m_parent->removeChildPopup(m_xdgSurface->window());
++    }
++
+     if (m_grabbing) {
+         auto *shell = m_xdgSurface->m_shell;
+         Q_ASSERT(shell->m_topmostGrabbingPopup == this);
+-        shell->m_topmostGrabbingPopup = m_parent->m_popup;
++        shell->m_topmostGrabbingPopup = m_parentXdgSurface ? m_parentXdgSurface->m_popup : nullptr;
++        m_grabbing = false;
++
++        // Synthesize Qt enter/leave events for popup
++        QWindow *leave = nullptr;
++        if (m_xdgSurface && m_xdgSurface->window())
++            leave = m_xdgSurface->window()->window();
++        QWindowSystemInterface::handleLeaveEvent(leave);
++
++        if (QWindow *enter = QGuiApplication::topLevelAt(QCursor::pos()))
++            QWindowSystemInterface::handleEnterEvent(enter, enter->mapFromGlobal(QCursor::pos()), QCursor::pos());
+     }
+ }
+ 
+@@ -257,6 +268,7 @@ QWaylandXdgSurface::QWaylandXdgSurface(QWaylandXdgShell *shell, ::xdg_surface *s
+                 m_toplevel->set_parent(parentXdgSurface->m_toplevel->object());
+         }
+     }
++    setSizeHints();
+ }
+ 
+ QWaylandXdgSurface::~QWaylandXdgSurface()
+@@ -400,8 +412,6 @@ void QWaylandXdgSurface::setPopup(QWaylandWindow *parent)
+ {
+     Q_ASSERT(!m_toplevel && !m_popup);
+ 
+-    auto parentXdgSurface = static_cast<QWaylandXdgSurface *>(parent->shellSurface());
+-
+     auto positioner = new QtWayland::xdg_positioner(m_shell->create_positioner());
+     // set_popup expects a position relative to the parent
+     QPoint transientPos = m_window->geometry().topLeft(); // this is absolute
+@@ -414,8 +424,9 @@ void QWaylandXdgSurface::setPopup(QWaylandWindow *parent)
+     positioner->set_anchor(QtWayland::xdg_positioner::anchor_top_left);
+     positioner->set_gravity(QtWayland::xdg_positioner::gravity_bottom_right);
+     positioner->set_size(m_window->geometry().width(), m_window->geometry().height());
+-    m_popup = new Popup(this, parentXdgSurface, positioner);
++    m_popup = new Popup(this, parent, positioner);
+     positioner->destroy();
++
+     delete positioner;
+ }
+ 
+@@ -437,6 +448,23 @@ void QWaylandXdgSurface::setGrabPopup(QWaylandWindow *parent, QWaylandInputDevic
+     }
+     setPopup(parent);
+     m_popup->grab(device, serial);
++
++    // Synthesize Qt enter/leave events for popup
++    if (!parent)
++        return;
++    QWindow *current = QGuiApplication::topLevelAt(QCursor::pos());
++    QWindow *leave = parent->window();
++    if (current != leave)
++        return;
++
++    QWindowSystemInterface::handleLeaveEvent(leave);
++
++    QWindow *enter = nullptr;
++    if (m_popup && m_popup->m_xdgSurface && m_popup->m_xdgSurface->window())
++        enter = m_popup->m_xdgSurface->window()->window();
++
++    if (enter)
++        QWindowSystemInterface::handleEnterEvent(enter, enter->mapFromGlobal(QCursor::pos()), QCursor::pos());
+ }
+ 
+ void QWaylandXdgSurface::xdg_surface_configure(uint32_t serial)
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
+index 96785205..4b518f0a 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
+@@ -131,14 +131,15 @@ private:
+ 
+     class Popup : public QtWayland::xdg_popup {
+     public:
+-        Popup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parent, QtWayland::xdg_positioner *positioner);
++        Popup(QWaylandXdgSurface *xdgSurface, QWaylandWindow *parent, QtWayland::xdg_positioner *positioner);
+         ~Popup() override;
+ 
+         void grab(QWaylandInputDevice *seat, uint serial);
+         void xdg_popup_popup_done() override;
+ 
+         QWaylandXdgSurface *m_xdgSurface = nullptr;
+-        QWaylandXdgSurface *m_parent = nullptr;
++        QWaylandXdgSurface *m_parentXdgSurface = nullptr;
++        QWaylandWindow *m_parent = nullptr;
+         bool m_grabbing = false;
+     };
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
+index 8769d971..da0dd6a7 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
+@@ -69,20 +69,6 @@ QWaylandShellSurface *QWaylandXdgShellIntegration::createShellSurface(QWaylandWi
+     return m_xdgShell->getXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellIntegration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus)
+-{
+-    if (newFocus) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurface *>(newFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowActivated(newFocus);
+-    }
+-    if (oldFocus && qobject_cast<QWaylandXdgSurface *>(oldFocus->shellSurface())) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurface *>(oldFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowDeactivated(oldFocus);
+-    }
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
+index b6caa6c9..2f929f98 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
+@@ -65,7 +65,6 @@ public:
+     QWaylandXdgShellIntegration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShell> m_xdgShell;
+diff --git a/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp b/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
+index 526d0ef4..f50ccf30 100644
+--- a/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
++++ b/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
+@@ -39,7 +39,10 @@
+ 
+ #include "qwaylandinputmethodeventbuilder_p.h"
+ 
++#include <QBrush>
++#include <QGuiApplication>
+ #include <QInputMethod>
++#include <QPalette>
+ #include <QTextCharFormat>
+ 
+ #ifdef QT_BUILD_WAYLANDCOMPOSITOR_LIB
+@@ -81,32 +84,38 @@ void QWaylandInputMethodEventBuilder::addPreeditStyling(uint32_t index, uint32_t
+     QTextCharFormat format;
+ 
+     switch (style) {
+-    case 0:
+-    case 1:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_NONE:
++        break;
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_DEFAULT:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_UNDERLINE:
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-    case 2:
+-    case 3:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_ACTIVE:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_INACTIVE:
+         format.setFontWeight(QFont::Bold);
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-    case 4:
+-        format.setFontUnderline(true);
+-        format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+-        m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_HIGHLIGHT:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_SELECTION:
++        {
++            format.setFontUnderline(true);
++            format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
++            QPalette palette = qApp->palette();
++            format.setBackground(QBrush(palette.color(QPalette::Active, QPalette::Highlight)));
++            format.setForeground(QBrush(palette.color(QPalette::Active, QPalette::HighlightedText)));
++            m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
++        }
+         break;
+-    case 5:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_INCORRECT:
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::WaveUnderline);
+         format.setUnderlineColor(QColor(Qt::red));
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-//    case QtWayland::wl_text_input::preedit_style_selection:
+-//    case QtWayland::wl_text_input::preedit_style_none:
+     default:
+         break;
+     }
+@@ -153,7 +162,7 @@ QInputMethodEvent QWaylandInputMethodEventBuilder::buildPreedit(const QString &t
+ 
+     if (m_preeditCursor < 0) {
+         attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, 0, QVariant()));
+-    } else if (m_preeditCursor > 0) {
++    } else {
+         attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, indexFromWayland(text, m_preeditCursor), 1, QVariant()));
+     }
+ 
+diff --git a/qtwayland/src/shared/qwaylandmimehelper.cpp b/qtwayland/src/shared/qwaylandmimehelper.cpp
+index a5fdd34d..e2fe1928 100644
+--- a/qtwayland/src/shared/qwaylandmimehelper.cpp
++++ b/qtwayland/src/shared/qwaylandmimehelper.cpp
+@@ -60,7 +60,7 @@ QByteArray QWaylandMimeHelper::getByteArray(QMimeData *mimeData, const QString &
+             buf.open(QIODevice::ReadWrite);
+             QByteArray fmt = "BMP";
+             if (mimeType.startsWith(QLatin1String("image/"))) {
+-                QByteArray imgFmt = mimeType.mid(6).toUpper().toLatin1();
++                QByteArray imgFmt = mimeType.mid(6).toLower().toLatin1();
+                 if (QImageWriter::supportedImageFormats().contains(imgFmt))
+                     fmt = imgFmt;
+             }
+@@ -74,7 +74,7 @@ QByteArray QWaylandMimeHelper::getByteArray(QMimeData *mimeData, const QString &
+         QList<QUrl> urls = mimeData->urls();
+         for (int i = 0; i < urls.count(); ++i) {
+             content.append(urls.at(i).toEncoded());
+-            content.append('\n');
++            content.append("\r\n");
+         }
+     } else {
+         content = mimeData->data(mimeType);
+diff --git a/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp b/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
+index 1568b3b9..067410d0 100644
+--- a/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
++++ b/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
+@@ -35,7 +35,7 @@
+ 
+ using namespace MockCompositor;
+ 
+-constexpr int dataDeviceVersion = 1;
++constexpr int dataDeviceVersion = 3;
+ 
+ class DataDeviceCompositor : public DefaultCompositor {
+ public:
+diff --git a/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp b/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
+index 9312c2e5..2ea382f1 100644
+--- a/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
++++ b/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
+@@ -73,6 +73,7 @@ private slots:
+     void multiTouch();
+     void multiTouchUpAndMotionFrame();
+     void tapAndMoveInSameFrame();
++    void cancelTouch();
+ };
+ 
+ void tst_seatv5::bindsToSeat()
+@@ -646,5 +647,34 @@ void tst_seatv5::tapAndMoveInSameFrame()
+     QTRY_COMPARE(window.m_events.last().touchPoints.first().state(), Qt::TouchPointState::TouchPointReleased);
+ }
+ 
++void tst_seatv5::cancelTouch()
++{
++    TouchWindow window;
++    QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
++
++    exec([=] {
++        auto *t = touch();
++        auto *c = client();
++        t->sendDown(xdgToplevel()->surface(), {32, 32}, 1);
++        t->sendFrame(c);
++        t->sendCancel(c);
++        t->sendFrame(c);
++    });
++
++    QTRY_VERIFY(!window.m_events.empty());
++    {
++        auto e = window.m_events.takeFirst();
++        QCOMPARE(e.type, QEvent::TouchBegin);
++        QCOMPARE(e.touchPointStates, Qt::TouchPointPressed);
++        QCOMPARE(e.touchPoints.length(), 1);
++        QCOMPARE(e.touchPoints.first().pos(), QPointF(32-window.frameMargins().left(), 32-window.frameMargins().top()));
++    }
++    {
++        auto e = window.m_events.takeFirst();
++        QCOMPARE(e.type, QEvent::TouchCancel);
++        QCOMPARE(e.touchPoints.length(), 0);
++    }
++}
++
+ QCOMPOSITOR_TEST_MAIN(tst_seatv5)
+ #include "tst_seatv5.moc"
+diff --git a/qtwayland/tests/auto/client/shared/corecompositor.cpp b/qtwayland/tests/auto/client/shared/corecompositor.cpp
+index 5c6c83ba..fa9b7662 100644
+--- a/qtwayland/tests/auto/client/shared/corecompositor.cpp
++++ b/qtwayland/tests/auto/client/shared/corecompositor.cpp
+@@ -27,6 +27,7 @@
+ ****************************************************************************/
+ 
+ #include "corecompositor.h"
++#include <thread>
+ 
+ namespace MockCompositor {
+ 
+diff --git a/qtwayland/tests/auto/client/shared/coreprotocol.cpp b/qtwayland/tests/auto/client/shared/coreprotocol.cpp
+index 0d988521..d1a2e7cb 100644
+--- a/qtwayland/tests/auto/client/shared/coreprotocol.cpp
++++ b/qtwayland/tests/auto/client/shared/coreprotocol.cpp
+@@ -451,6 +451,13 @@ void Touch::sendFrame(wl_client *client)
+         send_frame(r->handle);
+ }
+ 
++void Touch::sendCancel(wl_client *client)
++{
++    const auto touchResources = resourceMap().values(client);
++    for (auto *r : touchResources)
++        send_cancel(r->handle);
++}
++
+ uint Keyboard::sendEnter(Surface *surface)
+ {
+     auto serial = m_seat->m_compositor->nextSerial();
+diff --git a/qtwayland/tests/auto/client/shared/coreprotocol.h b/qtwayland/tests/auto/client/shared/coreprotocol.h
+index a1af137a..210d8ddb 100644
+--- a/qtwayland/tests/auto/client/shared/coreprotocol.h
++++ b/qtwayland/tests/auto/client/shared/coreprotocol.h
+@@ -158,7 +158,7 @@ class WlCompositor : public Global, public QtWaylandServer::wl_compositor
+ {
+     Q_OBJECT
+ public:
+-    explicit WlCompositor(CoreCompositor *compositor, int version = 3)
++    explicit WlCompositor(CoreCompositor *compositor, int version = 4)
+         : QtWaylandServer::wl_compositor(compositor->m_display, version)
+         , m_compositor(compositor)
+     {}
+@@ -364,6 +364,7 @@ public:
+     uint sendUp(wl_client *client, int id);
+     void sendMotion(wl_client *client, const QPointF &position, int id);
+     void sendFrame(wl_client *client);
++    void sendCancel(wl_client *client);
+ 
+     Seat *m_seat = nullptr;
+ };
+diff --git a/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp b/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
+index a415cbf5..b1d3d07d 100644
+--- a/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
++++ b/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
+@@ -342,7 +342,7 @@ Compositor::Compositor(MockCompositor *mockCompositor)
+         exit(EXIT_FAILURE);
+     }
+ 
+-    wl_global_create(m_display, &wl_compositor_interface, 1, this, bindCompositor);
++    wl_global_create(m_display, &wl_compositor_interface, 4, this, bindCompositor);
+ 
+     m_data_device_manager.reset(new DataDeviceManager(this, m_display));
+ 
+diff --git a/qtwayland/tests/auto/client/shared_old/mocksurface.cpp b/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
+index e9df5f90..c3246e4a 100644
+--- a/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
++++ b/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
+@@ -125,6 +125,16 @@ void Surface::surface_damage(Resource *resource,
+     Q_UNUSED(height);
+ }
+ 
++void Surface::surface_damage_buffer(Resource *resource,
++                                    int32_t x, int32_t y, int32_t width, int32_t height)
++{
++    Q_UNUSED(resource);
++    Q_UNUSED(x);
++    Q_UNUSED(y);
++    Q_UNUSED(width);
++    Q_UNUSED(height);
++}
++
+ void Surface::surface_frame(Resource *resource,
+                             uint32_t callback)
+ {
+diff --git a/qtwayland/tests/auto/client/shared_old/mocksurface.h b/qtwayland/tests/auto/client/shared_old/mocksurface.h
+index 949dc23d..d176837e 100644
+--- a/qtwayland/tests/auto/client/shared_old/mocksurface.h
++++ b/qtwayland/tests/auto/client/shared_old/mocksurface.h
+@@ -65,6 +65,8 @@ protected:
+                         struct wl_resource *buffer, int x, int y) override;
+     void surface_damage(Resource *resource,
+                         int32_t x, int32_t y, int32_t width, int32_t height) override;
++    void surface_damage_buffer(Resource *resource,
++                               int32_t x, int32_t y, int32_t width, int32_t height) override;
+     void surface_frame(Resource *resource,
+                        uint32_t callback) override;
+     void surface_commit(Resource *resource) override;
+diff --git a/qtwayland/tests/auto/client/surface/tst_surface.cpp b/qtwayland/tests/auto/client/surface/tst_surface.cpp
+index 95e4e609..60c672ce 100644
+--- a/qtwayland/tests/auto/client/surface/tst_surface.cpp
++++ b/qtwayland/tests/auto/client/surface/tst_surface.cpp
+@@ -129,6 +129,10 @@ void tst_surface::waitForFrameCallbackGl()
+     // Make sure we follow frame callbacks for some frames
+     for (int i = 0; i < 5; ++i) {
+         xdgPingAndWaitForPong(); // Make sure things have happened on the client
++        if (!qEnvironmentVariableIntValue("QT_WAYLAND_DISABLE_WINDOWDECORATION") && i == 0) {
++            QCOMPARE(bufferSpy.count(), 1);
++            bufferSpy.removeFirst();
++        }
+         exec([&] {
+             QVERIFY(bufferSpy.empty()); // Make sure no extra buffers have arrived
+             QVERIFY(!xdgToplevel()->surface()->m_waitingFrameCallbacks.empty());
+diff --git a/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp b/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
+index 2277bbb8..747875b4 100644
+--- a/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
++++ b/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
+@@ -31,6 +31,7 @@
+ #include <QtGui/QOpenGLWindow>
+ #include <QtGui/qpa/qplatformnativeinterface.h>
+ #include <QtWaylandClient/private/wayland-wayland-client-protocol.h>
++#include <QtWaylandClient/private/qwaylandwindow_p.h>
+ 
+ using namespace MockCompositor;
+ 
+@@ -45,6 +46,7 @@ private slots:
+     void configureStates();
+     void popup();
+     void tooltipOnPopup();
++    void tooltipAndSiblingPopup();
+     void switchPopups();
+     void hidePopupParent();
+     void pongs();
+@@ -138,6 +140,7 @@ void tst_xdgshell::configureSize()
+ 
+ void tst_xdgshell::configureStates()
+ {
++    QVERIFY(qputenv("QT_WAYLAND_FRAME_CALLBACK_TIMEOUT", "0"));
+     QRasterWindow window;
+     window.resize(64, 48);
+     window.show();
+@@ -154,9 +157,12 @@ void tst_xdgshell::configureStates()
+     // Toplevel windows don't know their position on xdg-shell
+ //    QCOMPARE(window.frameGeometry().topLeft(), QPoint()); // TODO: this doesn't currently work when window decorations are enabled
+ 
+-//    QEXPECT_FAIL("", "configure has already been acked, we shouldn't have to wait for isActive", Continue);
+-//    QVERIFY(window.isActive());
+-    QTRY_VERIFY(window.isActive()); // Just make sure it eventually get's set correctly
++    // window.windowstate() is driven by keyboard focus, however for decorations we want to follow
++    // XDGShell this is internal to QtWayland so it is queried directly
++    auto waylandWindow = static_cast<QtWaylandClient::QWaylandWindow *>(window.handle());
++    Q_ASSERT(waylandWindow);
++    QTRY_VERIFY(waylandWindow->windowStates().testFlag(
++            Qt::WindowActive)); // Just make sure it eventually get's set correctly
+ 
+     const QSize screenSize(640, 480);
+     const uint maximizedSerial = exec([=] {
+@@ -186,6 +192,7 @@ void tst_xdgshell::configureStates()
+     QCOMPARE(window.windowStates(), Qt::WindowNoState);
+     QCOMPARE(window.frameGeometry().size(), windowedSize);
+ //    QCOMPARE(window.frameGeometry().topLeft(), QPoint()); // TODO: this doesn't currently work when window decorations are enabled
++    QVERIFY(qunsetenv("QT_WAYLAND_FRAME_CALLBACK_TIMEOUT"));
+ }
+ 
+ void tst_xdgshell::popup()
+@@ -340,6 +347,92 @@ void tst_xdgshell::tooltipOnPopup()
+     QCOMPOSITOR_TRY_COMPARE(xdgPopup(0), nullptr);
+ }
+ 
++void tst_xdgshell::tooltipAndSiblingPopup()
++{
++    class ToolTip : public QRasterWindow {
++    public:
++        explicit ToolTip(QWindow *parent) {
++            setTransientParent(parent);
++            setFlags(Qt::ToolTip);
++            resize(100, 100);
++            show();
++        }
++        void mousePressEvent(QMouseEvent *event) override {
++            QRasterWindow::mousePressEvent(event);
++            m_popup = new QRasterWindow;
++            m_popup->setTransientParent(transientParent());
++            m_popup->setFlags(Qt::Popup);
++            m_popup->resize(100, 100);
++            m_popup->show();
++        }
++
++        QRasterWindow *m_popup = nullptr;
++    };
++
++    class Window : public QRasterWindow {
++    public:
++        void mousePressEvent(QMouseEvent *event) override {
++            QRasterWindow::mousePressEvent(event);
++            m_tooltip = new ToolTip(this);
++        }
++        ToolTip *m_tooltip = nullptr;
++    };
++
++    Window window;
++    window.resize(200, 200);
++    window.show();
++
++    QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
++    exec([=] { xdgToplevel()->sendCompleteConfigure(); });
++    QCOMPOSITOR_TRY_VERIFY(xdgToplevel()->m_xdgSurface->m_committedConfigureSerial);
++
++    exec([=] {
++        auto *surface = xdgToplevel()->surface();
++        auto *p = pointer();
++        auto *c = client();
++        p->sendEnter(surface, {100, 100});
++        p->sendFrame(c);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_pressed);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_released);
++        p->sendFrame(c);
++        p->sendLeave(surface);
++        p->sendFrame(c);
++    });
++
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup());
++    exec([=] { xdgPopup()->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup()->m_xdgSurface->m_committedConfigureSerial);
++    QCOMPOSITOR_TRY_VERIFY(!xdgPopup()->m_grabbed);
++
++    exec([=] {
++        auto *surface = xdgPopup()->surface();
++        auto *p = pointer();
++        auto *c = client();
++        p->sendEnter(surface, {100, 100});
++        p->sendFrame(c);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_pressed);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_released);
++        p->sendFrame(c);
++    });
++
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1));
++    exec([=] { xdgPopup(1)->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1)->m_xdgSurface->m_committedConfigureSerial);
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1)->m_grabbed);
++
++    // Close the middle tooltip (it should not close the sibling popup)
++    window.m_tooltip->close();
++
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(1), nullptr);
++    // Verify the remaining xdg surface is a grab popup..
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(0));
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(0)->m_grabbed);
++
++    window.m_tooltip->m_popup->close();
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(1), nullptr);
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(0), nullptr);
++}
++
+ // QTBUG-65680
+ void tst_xdgshell::switchPopups()
+ {
+@@ -505,7 +598,7 @@ void tst_xdgshell::minMaxSize()
+     window.show();
+     QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
+ 
+-    exec([=] { xdgToplevel()->sendCompleteConfigure(); });
++    // we don't roundtrip with our configuration the initial commit should be correct
+ 
+     QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.minSize, QSize(100, 100));
+     QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.maxSize, QSize(1000, 1000));
+Submodule qtwebchannel 618422ee..f8949655:
+diff --git a/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp b/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
+index 536eb5c..898d769 100644
+--- a/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
++++ b/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
+@@ -186,8 +186,6 @@ Q_DECLARE_TYPEINFO(OverloadResolutionCandidate, Q_MOVABLE_TYPE);
+ QMetaObjectPublisher::QMetaObjectPublisher(QWebChannel *webChannel)
+     : QObject(webChannel)
+     , webChannel(webChannel)
+-    , signalHandler(this)
+-    , clientIsIdle(false)
+     , blockUpdates(false)
+     , propertyUpdatesInitialized(false)
+ {
+@@ -301,17 +299,17 @@ QJsonObject QMetaObjectPublisher::classInfoForObject(const QObject *object, QWeb
+     return data;
+ }
+ 
+-void QMetaObjectPublisher::setClientIsIdle(bool isIdle)
++void QMetaObjectPublisher::setClientIsIdle(bool isIdle, QWebChannelAbstractTransport *transport)
+ {
+-    if (clientIsIdle == isIdle) {
+-        return;
+-    }
+-    clientIsIdle = isIdle;
+-    if (!isIdle && timer.isActive()) {
+-        timer.stop();
+-    } else if (isIdle && !timer.isActive()) {
+-        timer.start(PROPERTY_UPDATE_INTERVAL, this);
+-    }
++    transportState[transport].clientIsIdle = isIdle;
++    if (isIdle)
++        sendEnqueuedPropertyUpdates(transport);
++}
++
++bool QMetaObjectPublisher::isClientIdle(QWebChannelAbstractTransport *transport)
++{
++    auto found = transportState.find(transport);
++    return found != transportState.end() && found.value().clientIsIdle;
+ }
+ 
+ QJsonObject QMetaObjectPublisher::initializeClient(QWebChannelAbstractTransport *transport)
+@@ -333,6 +331,7 @@ QJsonObject QMetaObjectPublisher::initializeClient(QWebChannelAbstractTransport
+ 
+ void QMetaObjectPublisher::initializePropertyUpdates(const QObject *const object, const QJsonObject &objectInfo)
+ {
++    auto *signalHandler = signalHandlerFor(object);
+     foreach (const QJsonValue &propertyInfoVar, objectInfo[KEY_PROPERTIES].toArray()) {
+         const QJsonArray &propertyInfo = propertyInfoVar.toArray();
+         if (propertyInfo.size() < 2) {
+@@ -353,19 +352,19 @@ void QMetaObjectPublisher::initializePropertyUpdates(const QObject *const object
+ 
+         // Only connect for a property update once
+         if (connectedProperties.isEmpty()) {
+-            signalHandler.connectTo(object, signalIndex);
++            signalHandler->connectTo(object, signalIndex);
+         }
+ 
+         connectedProperties.insert(propertyIndex);
+     }
+ 
+     // also always connect to destroyed signal
+-    signalHandler.connectTo(object, s_destroyedSignalIndex);
++    signalHandler->connectTo(object, s_destroyedSignalIndex);
+ }
+ 
+ void QMetaObjectPublisher::sendPendingPropertyUpdates()
+ {
+-    if (blockUpdates || !clientIsIdle || pendingPropertyUpdates.isEmpty()) {
++    if (blockUpdates) {
+         return;
+     }
+ 
+@@ -415,18 +414,19 @@ void QMetaObjectPublisher::sendPendingPropertyUpdates()
+ 
+     // data does not contain specific updates
+     if (!data.isEmpty()) {
+-        setClientIsIdle(false);
+-
+         message[KEY_DATA] = data;
+-        broadcastMessage(message);
++        enqueueBroadcastMessage(message);
+     }
+ 
+     // send every property update which is not supposed to be broadcasted
+     const QHash<QWebChannelAbstractTransport*, QJsonArray>::const_iterator suend = specificUpdates.constEnd();
+     for (QHash<QWebChannelAbstractTransport*, QJsonArray>::const_iterator it = specificUpdates.constBegin(); it != suend; ++it) {
+         message[KEY_DATA] = it.value();
+-        it.key()->sendMessage(message);
++        enqueueMessage(message, it.key());
+     }
++
++    for (auto state = transportState.begin(); state != transportState.end(); ++state)
++        sendEnqueuedPropertyUpdates(state.key());
+ }
+ 
+ QVariant QMetaObjectPublisher::invokeMethod(QObject *const object, const QMetaMethod &method,
+@@ -572,7 +572,7 @@ void QMetaObjectPublisher::signalEmitted(const QObject *object, const int signal
+         }
+     } else {
+         pendingPropertyUpdates[object][signalIndex] = arguments;
+-        if (clientIsIdle && !blockUpdates && !timer.isActive()) {
++        if (!blockUpdates && !timer.isActive()) {
+             timer.start(PROPERTY_UPDATE_INTERVAL, this);
+         }
+     }
+@@ -590,7 +590,7 @@ void QMetaObjectPublisher::objectDestroyed(const QObject *object)
+     // only remove from handler when we initialized the property updates
+     // cf: https://bugreports.qt.io/browse/QTBUG-60250
+     if (propertyUpdatesInitialized) {
+-        signalHandler.remove(object);
++        signalHandlerFor(object)->remove(object);
+         signalToPropertyMap.remove(object);
+     }
+     pendingPropertyUpdates.remove(object);
+@@ -852,6 +852,52 @@ void QMetaObjectPublisher::broadcastMessage(const QJsonObject &message) const
+     }
+ }
+ 
++void QMetaObjectPublisher::enqueueBroadcastMessage(const QJsonObject &message)
++{
++    if (webChannel->d_func()->transports.isEmpty()) {
++        qWarning("QWebChannel is not connected to any transports, cannot send message: %s",
++                 QJsonDocument(message).toJson().constData());
++        return;
++    }
++
++    for (auto *transport : webChannel->d_func()->transports) {
++        auto &state = transportState[transport];
++        state.queuedMessages.append(message);
++    }
++}
++
++void QMetaObjectPublisher::enqueueMessage(const QJsonObject &message,
++                                          QWebChannelAbstractTransport *transport)
++{
++    auto &state = transportState[transport];
++    state.queuedMessages.append(message);
++}
++
++void QMetaObjectPublisher::sendEnqueuedPropertyUpdates(QWebChannelAbstractTransport *transport)
++{
++    auto found = transportState.find(transport);
++    if (found != transportState.end() && found.value().clientIsIdle
++        && !found.value().queuedMessages.isEmpty()) {
++
++        // If the client is connected with an in-process transport, it can
++        // happen that a message triggers a subsequent property change. In
++        // that case, we need to ensure that the queued messages have already
++        // been cleared; otherwise the recursive call will send everythig again.
++        // Case in point: The qmlwebchannel tests fail if we don't clear the
++        // queued messages before sending them out.
++        // For that same reason set the client to "busy" (aka non-idle) just
++        // right before sending out the messages; otherwise a potential
++        // "Idle" type message will not correctly restore the Idle state.
++        const auto messages = std::move(found.value().queuedMessages);
++        Q_ASSERT(found.value().queuedMessages.isEmpty());
++        found.value().clientIsIdle = false;
++
++        for (const auto &message : messages) {
++            transport->sendMessage(message);
++        }
++    }
++}
++
+ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannelAbstractTransport *transport)
+ {
+     if (!webChannel->d_func()->transports.contains(transport)) {
+@@ -866,7 +912,7 @@ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannel
+ 
+     const MessageType type = toType(message.value(KEY_TYPE));
+     if (type == TypeIdle) {
+-        setClientIsIdle(true);
++        setClientIsIdle(true, transport);
+     } else if (type == TypeInit) {
+         if (!message.contains(KEY_ID)) {
+             qWarning("JSON message object is missing the id property: %s",
+@@ -913,9 +959,9 @@ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannel
+                 return;
+             transport->sendMessage(createResponse(message.value(KEY_ID), wrapResult(result, transport)));
+         } else if (type == TypeConnectToSignal) {
+-            signalHandler.connectTo(object, message.value(KEY_SIGNAL).toInt(-1));
++            signalHandlerFor(object)->connectTo(object, message.value(KEY_SIGNAL).toInt(-1));
+         } else if (type == TypeDisconnectFromSignal) {
+-            signalHandler.disconnectFrom(object, message.value(KEY_SIGNAL).toInt(-1));
++            signalHandlerFor(object)->disconnectFrom(object, message.value(KEY_SIGNAL).toInt(-1));
+         } else if (type == TypeSetProperty) {
+             setProperty(object, message.value(KEY_PROPERTY).toInt(-1),
+                         message.value(KEY_VALUE));
+@@ -931,6 +977,7 @@ void QMetaObjectPublisher::setBlockUpdates(bool block)
+     blockUpdates = block;
+ 
+     if (!blockUpdates) {
++        timer.start(PROPERTY_UPDATE_INTERVAL, this);
+         sendPendingPropertyUpdates();
+     } else if (timer.isActive()) {
+         timer.stop();
+@@ -948,4 +995,15 @@ void QMetaObjectPublisher::timerEvent(QTimerEvent *event)
+     }
+ }
+ 
++SignalHandler<QMetaObjectPublisher> *QMetaObjectPublisher::signalHandlerFor(const QObject *object)
++{
++    auto thread = object->thread();
++    auto it = signalHandlers.find(thread);
++    if (it == signalHandlers.end()) {
++        it = signalHandlers.emplace(thread, this).first;
++        it->second.moveToThread(thread);
++    }
++    return &it->second;
++}
++
+ QT_END_NAMESPACE
+diff --git a/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h b/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
+index bbd9875..4713ef1 100644
+--- a/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
++++ b/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
+@@ -59,6 +59,9 @@
+ #include <QBasicTimer>
+ #include <QPointer>
+ #include <QJsonObject>
++#include <QQueue>
++
++#include <unordered_map>
+ 
+ #include "qwebchannelglobal.h"
+ 
+@@ -109,17 +112,36 @@ public:
+      */
+     void broadcastMessage(const QJsonObject &message) const;
+ 
++    /**
++     * Enqueue the given @p message to all known transports.
++     */
++    void enqueueBroadcastMessage(const QJsonObject &message);
++
++    /**
++     * Enqueue the given @p message to @p transport.
++     */
++    void enqueueMessage(const QJsonObject &message, QWebChannelAbstractTransport *transport);
++
++    /**
++     * If client for given @p transport is idle, send queued messaged to @p transport and then mark
++     * the client as not idle.
++     */
++    void sendEnqueuedPropertyUpdates(QWebChannelAbstractTransport *transport);
++
+     /**
+      * Serialize the QMetaObject of @p object and return it in JSON form.
+      */
+     QJsonObject classInfoForObject(const QObject *object, QWebChannelAbstractTransport *transport);
+ 
+     /**
+-     * Set the client to idle or busy, based on the value of @p isIdle.
+-     *
+-     * When the value changed, start/stop the property update timer accordingly.
++     * Set the client to idle or busy for a single @p transport, based on the value of @p isIdle.
++     */
++    void setClientIsIdle(bool isIdle, QWebChannelAbstractTransport *transport);
++
++    /**
++     * Check that client is idle for @p transport.
+      */
+-    void setClientIsIdle(bool isIdle);
++    bool isClientIdle(QWebChannelAbstractTransport *transport);
+ 
+     /**
+      * Initialize clients by sending them the class information of the registered objects.
+@@ -272,10 +294,18 @@ private:
+     friend class TestWebChannel;
+ 
+     QWebChannel *webChannel;
+-    SignalHandler<QMetaObjectPublisher> signalHandler;
++    std::unordered_map<const QThread*, SignalHandler<QMetaObjectPublisher>> signalHandlers;
++    SignalHandler<QMetaObjectPublisher> *signalHandlerFor(const QObject *object);
+ 
+-    // true when the client is idle, false otherwise
+-    bool clientIsIdle;
++    struct TransportState
++    {
++        TransportState() : clientIsIdle(false) { }
++        // true when the client is idle, false otherwise
++        bool clientIsIdle;
++        // messages to send
++        QQueue<QJsonObject> queuedMessages;
++    };
++    QHash<QWebChannelAbstractTransport *, TransportState> transportState;
+ 
+     // true when no property updates should be sent, false otherwise
+     bool blockUpdates;
+diff --git a/qtwebchannel/src/webchannel/signalhandler_p.h b/qtwebchannel/src/webchannel/signalhandler_p.h
+index 27afadb..d77373c 100644
+--- a/qtwebchannel/src/webchannel/signalhandler_p.h
++++ b/qtwebchannel/src/webchannel/signalhandler_p.h
+@@ -56,6 +56,7 @@
+ #include <QVector>
+ #include <QMetaMethod>
+ #include <QDebug>
++#include <QThread>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -71,6 +72,7 @@ static const int s_destroyedSignalIndex = QObject::staticMetaObject.indexOfMetho
+ template<class Receiver>
+ class SignalHandler : public QObject
+ {
++    Q_DISABLE_COPY(SignalHandler)
+ public:
+     SignalHandler(Receiver *receiver, QObject *parent = 0);
+ 
+@@ -268,6 +270,7 @@ int SignalHandler<Receiver>::qt_metacall(QMetaObject::Call call, int methodId, v
+     if (call == QMetaObject::InvokeMetaMethod) {
+         const QObject *object = sender();
+         Q_ASSERT(object);
++        Q_ASSERT(QThread::currentThread() == object->thread());
+         Q_ASSERT(senderSignalIndex() == methodId);
+         Q_ASSERT(m_connectionsCounter.contains(object));
+         Q_ASSERT(m_connectionsCounter.value(object).contains(methodId));
+diff --git a/qtwebchannel/tests/auto/qml/testwebchannel.cpp b/qtwebchannel/tests/auto/qml/testwebchannel.cpp
+index 9891687..3ca81c2 100644
+--- a/qtwebchannel/tests/auto/qml/testwebchannel.cpp
++++ b/qtwebchannel/tests/auto/qml/testwebchannel.cpp
+@@ -46,7 +46,11 @@ TestWebChannel::~TestWebChannel()
+ 
+ bool TestWebChannel::clientIsIdle() const
+ {
+-    return QWebChannel::d_func()->publisher->clientIsIdle;
++    for (auto *transport : QWebChannel::d_func()->transports) {
++        if (QWebChannel::d_func()->publisher->isClientIdle(transport))
++            return true;
++    }
++    return false;
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp b/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
+index 181da9e..37f989a 100644
+--- a/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
++++ b/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
+@@ -785,7 +785,7 @@ void TestWebChannel::testTransportWrapObjectProperties()
+     DummyTransport *dummyTransport = new DummyTransport(this);
+     channel.connectTo(dummyTransport);
+     channel.d_func()->publisher->initializeClient(dummyTransport);
+-    channel.d_func()->publisher->setClientIsIdle(true);
++    channel.d_func()->publisher->setClientIsIdle(true, dummyTransport);
+ 
+     QCOMPARE(channel.d_func()->publisher->transportedWrappedObjects.size(), 0);
+ 
+@@ -943,8 +943,6 @@ void TestWebChannel::testInfiniteRecursion()
+ 
+ void TestWebChannel::testAsyncObject()
+ {
+-    QSKIP("This test is broken. See QTBUG-80729");
+-
+     QWebChannel channel;
+     channel.connectTo(m_dummyTransport);
+ 
+@@ -990,6 +988,50 @@ void TestWebChannel::testAsyncObject()
+     thread.wait();
+ }
+ 
++void TestWebChannel::testPropertyMultipleTransports()
++{
++    DummyTransport transport1;
++    DummyTransport transport2;
++
++    QWebChannel channel;
++    QMetaObjectPublisher *publisher = channel.d_func()->publisher;
++
++    TestObject testObj;
++    testObj.setObjectName("testObject");
++    channel.registerObject(testObj.objectName(), &testObj);
++    channel.connectTo(&transport1);
++    channel.connectTo(&transport2);
++
++    testObj.setProp("Hello");
++
++    publisher->initializeClient(&transport1);
++    publisher->initializeClient(&transport2);
++    publisher->setClientIsIdle(true, &transport1);
++    QCOMPARE(publisher->isClientIdle(&transport1), true);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++    QVERIFY(transport1.messagesSent().isEmpty());
++    QVERIFY(transport2.messagesSent().isEmpty());
++
++    testObj.setProp("World");
++    QTRY_COMPARE_WITH_TIMEOUT(transport1.messagesSent().size(), 1u, 2000);
++    QCOMPARE(transport2.messagesSent().size(), 0u);
++    publisher->setClientIsIdle(true, &transport2);
++    QTRY_COMPARE_WITH_TIMEOUT(transport2.messagesSent().size(), 1u, 2000);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++
++    testObj.setProp("!!!");
++    publisher->setClientIsIdle(true, &transport2);
++    QCOMPARE(publisher->isClientIdle(&transport2), true);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QTRY_COMPARE_WITH_TIMEOUT(transport2.messagesSent().size(), 2u, 2000);
++    QCOMPARE(transport1.messagesSent().size(), 1u);
++    publisher->setClientIsIdle(true, &transport1);
++    QTRY_COMPARE_WITH_TIMEOUT(transport1.messagesSent().size(), 2u, 2000);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++}
++
+ class FunctionWrapper : public QObject
+ {
+     Q_OBJECT
+@@ -1082,7 +1124,7 @@ void TestWebChannel::benchInitializeClients()
+ 
+         publisher->propertyUpdatesInitialized = false;
+         publisher->signalToPropertyMap.clear();
+-        publisher->signalHandler.clear();
++        publisher->signalHandlers.clear();
+     }
+ }
+ 
+@@ -1107,7 +1149,7 @@ void TestWebChannel::benchPropertyUpdates()
+             obj->change();
+         }
+ 
+-        channel.d_func()->publisher->clientIsIdle = true;
++        channel.d_func()->publisher->setClientIsIdle(true, m_dummyTransport);
+         channel.d_func()->publisher->sendPendingPropertyUpdates();
+     }
+ }
+diff --git a/qtwebchannel/tests/auto/webchannel/tst_webchannel.h b/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
+index eae21f4..dd4e690 100644
+--- a/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
++++ b/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
+@@ -348,6 +348,7 @@ private slots:
+     void testJsonToVariant();
+     void testInfiniteRecursion();
+     void testAsyncObject();
++    void testPropertyMultipleTransports();
+     void testDeletionDuringMethodInvocation_data();
+     void testDeletionDuringMethodInvocation();
+ 
+Submodule qtwebengine f328054d...38e0df6c (commits not present)
+Submodule qtwebsockets 65850954..63fb8da1:
+diff --git a/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp b/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
+index 2affdd5..95f1194 100644
+--- a/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
++++ b/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
+@@ -273,6 +273,7 @@ void QWebSocketDataProcessor::clear()
+     if (!m_pConverterState)
+         m_pConverterState = new QTextCodec::ConverterState(QTextCodec::ConvertInvalidToNull |
+                                                            QTextCodec::IgnoreHeader);
++    frame.clear();
+ }
+ 
+ /*!
+diff --git a/qtwebsockets/src/websockets/qwebsocketprotocol.cpp b/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
+index df87a93..d0465f1 100644
+--- a/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
++++ b/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
+@@ -210,7 +210,7 @@ void QWebSocketProtocol::mask(char *payload, quint64 size, quint32 maskingKey)
+                             quint8((maskingKey & 0x0000FF00u) >> 8),
+                             quint8((maskingKey & 0x000000FFu))
+                           };
+-    int i = 0;
++    quint64 i = 0;
+     while (size-- > 0)
+         *payload++ ^= mask[i++ % 4];
+ }
diff --git a/srcpkgs/qt5/template b/srcpkgs/qt5/template
index a79d25e69da8..6dddce7f3e46 100644
--- a/srcpkgs/qt5/template
+++ b/srcpkgs/qt5/template
@@ -2,11 +2,11 @@
 #
 # revbump libqtxdg after bumping patch version
 pkgname=qt5
-version=5.15.7+20221119
+version=5.15.8
+revision=1
+build_style=meta
 # commit f8c9fb304bc3e53b3aa07f962cd74e9160decccc
 # base repo: https://invent.kde.org/qt/qt/qt5
-revision=5
-build_style=meta
 hostmakedepends="cmake clang flex perl glib-devel pkg-config
  python re2c ruby which"
 makedepends="SDL2-devel Vulkan-Headers alsa-lib-devel double-conversion-devel
@@ -29,8 +29,9 @@ homepage="https://qt.io/"
 # tarball is generated with `git archive-all qt5-$version.tar.gz`
 # to keep the size smaller qtwebengine, qtwebview, qtdocgallery, qtactiveqt and qtpim
 # can be marked with the export-ignore attribute
-distfiles="https://void.johnnynator.dev/distfiles/qt5-${version}.tar.gz"
-checksum=9d57af471c78029a362276b7c99108ea009f511bb9ba6ff6cb884f6ddd255e9f
+#distfiles="https://void.johnnynator.dev/distfiles/qt5-${version}.tar.gz"
+distfiles="https://download.qt.io/archive/qt/5.15/${version}/single/qt-everywhere-opensource-src-${version}.tar.xz"
+checksum=776a9302c336671f9406a53bd30b8e36f825742b2ec44a57c08217bff0fa86b9
 python_version=2 #unverified
 replaces="qt5-doc<5.6.0 qt5-quick1<5.6.0 qt5-quick1-devel<5.6.0 qt5-webkit<5.6.0 qt5-webkit-devel<5.6.0
  qt5-enginio<5.7.1 qt5-enginio-devel<5.7.1 qt5-plugin-gtk<5.7.1 qt5-canvas3d<5.13.0"
@@ -250,7 +251,6 @@ do_configure() {
 	# opts+=" -v"
 	opts+=" -skip qtwebengine"
 	opts+=" -skip qtwebview"
-	opts+=" -skip qtdocgallery"
 	opts+=" -skip qtpim"
 	opts+=" -skip qtsystems"
 	opts+=" -skip qtspeech"

From 38a7370d40fcda1b07371217a0261575d6b9e511 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 075/115] qtav: revbump for ffmpeg4-4.4.3

---
 srcpkgs/qtav/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtav/template b/srcpkgs/qtav/template
index 34c30b2c0c78..2d00ad104355 100644
--- a/srcpkgs/qtav/template
+++ b/srcpkgs/qtav/template
@@ -1,10 +1,10 @@
 # Template file for 'qtav'
 pkgname=qtav
 version=1.13.0
-revision=1
+revision=2
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel libass-devel libopenal-devel
+makedepends="ffmpeg4-devel libass-devel libopenal-devel
  libva-glx-devel libXv-devel pulseaudio-devel
  qt5-declarative-devel qt5-svg-devel
  qt5-quickcontrols"

From 44069f3bd15bc55a7cef77f0e8ba7dc57401823f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 076/115] qtox: revbump for ffmpeg-6.0

---
 srcpkgs/qtox/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qtox/template b/srcpkgs/qtox/template
index 16019d7eaec9..5cea0b11b697 100644
--- a/srcpkgs/qtox/template
+++ b/srcpkgs/qtox/template
@@ -1,7 +1,7 @@
 # Template file for 'qtox'
 pkgname=qtox
 version=1.17.6
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DUPDATE_CHECK=OFF
  -DGIT_DESCRIBE=${version}

From 00653568998937352a64789acd076321077032f6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 077/115] retroarch: revbump for ffmpeg-6.0

---
 srcpkgs/retroarch/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroarch/template b/srcpkgs/retroarch/template
index 28016aa0129e..20a1415913be 100644
--- a/srcpkgs/retroarch/template
+++ b/srcpkgs/retroarch/template
@@ -1,7 +1,7 @@
 # Template file for 'retroarch'
 pkgname=retroarch
 version=1.15.0
-revision=1
+revision=2
 build_style=configure
 configure_args="--prefix=/usr --sysconfdir=/etc --enable-networking
  --enable-udev --disable-builtinflac --disable-builtinglslang

From 708fdaf3578ee50c34afa38010eeec38320bc014 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 078/115] scrcpy: revbump for ffmpeg-6.0

---
 srcpkgs/scrcpy/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/scrcpy/template b/srcpkgs/scrcpy/template
index ee6e698e387f..8ada5ca4323f 100644
--- a/srcpkgs/scrcpy/template
+++ b/srcpkgs/scrcpy/template
@@ -1,7 +1,7 @@
 # Template file for 'scrcpy'
 pkgname=scrcpy
 version=2.0
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcompile_server=false
  -Dprebuilt_server=/usr/share/scrcpy/scrcpy-server-v${version}"

From 7f6bfcd876c3c220c4e374cb4a2021584ab1dc8c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 079/115] spek-alternative: revbump for ffmpeg4-4.4.3

---
 srcpkgs/spek-alternative/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/spek-alternative/template b/srcpkgs/spek-alternative/template
index d65086b8f008..05246f1b8d0c 100644
--- a/srcpkgs/spek-alternative/template
+++ b/srcpkgs/spek-alternative/template
@@ -1,11 +1,11 @@
 # Template file for 'spek-alternative'
 pkgname=spek-alternative
 version=0.8.2.3
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake gettext-devel intltool libtool pkg-config wxWidgets-common"
-makedepends="ffmpeg-devel wxWidgets-gtk3-devel"
-depends="ffmpeg"
+makedepends="ffmpeg4-devel wxWidgets-gtk3-devel"
+depends="ffmpeg4"
 short_desc="Acoustic spectrum analyser"
 maintainer="Kartik Singh <kartik.ynwa@gmail.com>"
 license="GPL-3.0-or-later"

From 4e69f0033ea2a13786057e4954347866dfbbb48c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 080/115] ssr: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ssr/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/ssr/template b/srcpkgs/ssr/template
index b055b9ec0774..3448ca110eb0 100644
--- a/srcpkgs/ssr/template
+++ b/srcpkgs/ssr/template
@@ -1,11 +1,11 @@
 # Template file for 'ssr'
 pkgname=ssr
 version=0.4.4
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_QT5=ON"
 hostmakedepends="pkg-config"
-makedepends="alsa-lib-devel ffmpeg-devel glu-devel jack-devel pulseaudio-devel
+makedepends="alsa-lib-devel ffmpeg4-devel glu-devel jack-devel pulseaudio-devel
  qt5-tools-devel qt5-x11extras-devel libXinerama-devel v4l-utils-devel"
 depends="desktop-file-utils hicolor-icon-theme"
 short_desc="Simple Screen Recorder for programs and games"

From 264f5ee5deddfb24504f15fb33609456b5a588f8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 081/115] sumo: revbump for ffmpeg-6.0

---
 srcpkgs/sumo/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/sumo/template b/srcpkgs/sumo/template
index 0f9b9ec815f5..a3fe134aa5ac 100644
--- a/srcpkgs/sumo/template
+++ b/srcpkgs/sumo/template
@@ -1,7 +1,7 @@
 # Template file for 'sumo'
 pkgname=sumo
 version=1.12.0
-revision=5
+revision=6
 build_style=cmake
 hostmakedepends="libgdal-tools pkg-config swig python3-setuptools"
 makedepends="python3-devel ffmpeg-devel fox-devel gl2ps-devel libgdal-devel

From ff49ecac8aad0e352112a599a1c29a581bed87d4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 082/115] synfig: revbump for ffmpeg-6.0 and mlt7

---
 srcpkgs/synfig/patches/ffmpeg6.patch | 71 ++++++++++++++++++++++++++++
 srcpkgs/synfig/template              |  4 +-
 2 files changed, 73 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/synfig/patches/ffmpeg6.patch

diff --git a/srcpkgs/synfig/patches/ffmpeg6.patch b/srcpkgs/synfig/patches/ffmpeg6.patch
new file mode 100644
index 000000000000..10780b42782f
--- /dev/null
+++ b/srcpkgs/synfig/patches/ffmpeg6.patch
@@ -0,0 +1,71 @@
+--- a/src/modules/mod_libavcodec/trgt_av.cpp	2022-10-25 09:14:12.000000000 -0400
++++ b/src/modules/mod_libavcodec/trgt_av.cpp	2023-05-05 21:34:17.899194559 -0400
+@@ -38,6 +41,7 @@
+ extern "C"
+ {
+ #ifdef HAVE_LIBAVFORMAT_AVFORMAT_H
++#	include <libavcodec/avcodec.h>
+ #	include <libavformat/avformat.h>
+ #elif defined(HAVE_AVFORMAT_H)
+ #	include <avformat.h>
+@@ -155,11 +156,11 @@
+     }
+ 
+ 	bool open_video_stream() {
+-		if (avcodec_open2(video_context, NULL, NULL) < 0) {
++		if (avcodec_open2(video_context, nullptr, nullptr) < 0) {
+ 			synfig::error("Target_LibAVCodec: could not open video codec");
+ 			// seems the calling of avcodec_free_context after error will cause crash
+ 			// so just forget about this context
+-			video_context = NULL;
++			video_context = nullptr;
+ 			close();
+ 			return false;
+         }
+@@ -234,15 +235,21 @@
+ 		close();
+ 
+ 		if (!av_registered) {
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 			av_register_all();
++#endif
+ 			av_registered = true;
+ 		}
+ 
+ 		// guess format
+-		AVOutputFormat *format = av_guess_format(NULL, filename.c_str(), NULL);
++#if LIBAVCODEC_VERSION_MAJOR < 59 // FFMPEG < 5.0
++		AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#else
++		const AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#endif
+ 		if (!format) {
+ 			synfig::warning("Target_LibAVCodec: unable to guess the output format, defaulting to MPEG");
+-			format = av_guess_format("mpeg", NULL, NULL);
++			format = av_guess_format("mpeg", nullptr, nullptr);
+ 		}
+ 		if (!format) {
+ 			synfig::error("Target_LibAVCodec: unable to find 'mpeg' output format");
+@@ -254,6 +261,7 @@
+ 		context = avformat_alloc_context();
+ 		assert(context);
+ 		context->oformat = format;
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 		if (filename.size() + 1 > sizeof(context->filename)) {
+ 			synfig::error(
+ 				"Target_LibAVCodec: filename too long, max length is %d, filename is '%s'",
+@@ -263,6 +271,14 @@
+ 			return false;
+ 		}
+ 		memcpy(context->filename, filename.c_str(), filename.size() + 1);
++#else
++		context->url = av_strndup(filename.c_str(), filename.size());
++		if (!context->url) {
++			synfig::error("Target_LibAVCodec: cannot allocate space for filename");
++			close();
++			return false;
++		}
++#endif
+ 
+ 		packet = av_packet_alloc();
+ 		assert(packet);
diff --git a/srcpkgs/synfig/template b/srcpkgs/synfig/template
index 5f5f5bb3f4b2..6e0d713150ae 100644
--- a/srcpkgs/synfig/template
+++ b/srcpkgs/synfig/template
@@ -6,7 +6,7 @@ revision=2
 build_style=gnu-configure
 configure_args="--with-boost-libdir=${XBPS_CROSS_BASE}/usr/lib"
 hostmakedepends="boost-build ImageMagick pkg-config intltool"
-makedepends="ETL gettext-devel libxml++-devel mlt-devel libmagick-devel
+makedepends="ETL gettext-devel libxml++-devel mlt7-devel libmagick-devel
  libmng-devel boost-build boost-devel libopenexr-devel ffmpeg-devel"
 depends="ImageMagick"
 short_desc="CLI 2D vector and timeline-based animation software"
@@ -20,7 +20,7 @@ CXXFLAGS="-std=c++11 -DHAVE_LOCALE_H=1"
 
 synfig-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision}
-	 libopenexr-devel libxml++-devel mlt-devel"
+	 libopenexr-devel libxml++-devel mlt7-devel"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/bin/synfig-config

From 4324fc961b89ae6eed3ec3755a5b5ee021bbc831 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 5 May 2023 12:57:57 -0400
Subject: [PATCH 083/115] synfigstudio: revbump for synfig mlt7

---
 srcpkgs/synfigstudio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/synfigstudio/template b/srcpkgs/synfigstudio/template
index 91349169ed2b..af1c5a296ef0 100644
--- a/srcpkgs/synfigstudio/template
+++ b/srcpkgs/synfigstudio/template
@@ -2,7 +2,7 @@
 # Should be kept in sync with 'synfig' and 'ETL'
 pkgname=synfigstudio
 version=1.4.4
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--disable-update-mimedb"
 hostmakedepends="pkg-config intltool gettext synfig"

From 16baa2900bbe038c59d03e1e2f0b397fa2ea1886 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 084/115] tg_owt: revbump for ffmpeg-6.0

---
 srcpkgs/tg_owt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tg_owt/template b/srcpkgs/tg_owt/template
index 97d195ddb34a..551614b24956 100644
--- a/srcpkgs/tg_owt/template
+++ b/srcpkgs/tg_owt/template
@@ -1,7 +1,7 @@
 # Template file for 'tg_owt'
 pkgname=tg_owt
 version=0.0.0.20230107
-revision=1
+revision=2
 _commit=5098730b9eb6173f0b52068fe2555b7c1015123a
 _libyuv_commit=00950840d1c9bcbb3eb6ebc5aac5793e71166c8b
 _abseil_commit=8c0b94e793a66495e0b1f34a5eb26bd7dc672db0

From 25523bc91e232eeb09cec268f71bea7692073252 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 085/115] timg: revbump for ffmpeg-6.0

---
 srcpkgs/timg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/timg/template b/srcpkgs/timg/template
index 2a2ab763d2fd..8fb4327535ef 100644
--- a/srcpkgs/timg/template
+++ b/srcpkgs/timg/template
@@ -1,7 +1,7 @@
 # Template file for 'timg'
 pkgname=timg
 version=1.4.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_OPENSLIDE_SUPPORT=off -Wno-dev"
 hostmakedepends="pkg-config git"

From 718c314499fc4fb9eb73db31f41b5ad59d6fc100 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 086/115] tvheadend: revbump for ffmpeg4-4.4.3

---
 srcpkgs/tvheadend/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/tvheadend/template b/srcpkgs/tvheadend/template
index e6b16d7ccf3b..46b52b6fb7f9 100644
--- a/srcpkgs/tvheadend/template
+++ b/srcpkgs/tvheadend/template
@@ -1,14 +1,14 @@
 # Template file for 'tvheadend'
 pkgname=tvheadend
 version=4.2.8
-revision=6
+revision=7
 build_style=gnu-configure
 configure_args="--enable-dvbscan --disable-ffmpeg_static
 --disable-hdhomerun_static --disable-bintray_cache --disable-libx264_static
 --disable-libx265_static --disable-libvpx_static --disable-libtheora_static
 --disable-libvorbis_static --disable-libfdkaac_static"
 hostmakedepends="gettext pkg-config python git which"
-makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg-devel"
+makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg4-devel"
 short_desc="TV streaming server"
 maintainer="lemmi <lemmi@nerd2nerd.org>"
 license="GPL-3.0-only"

From c644555cf6b6be5b214961381c5c9938b48a1372 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 087/115] unpaper: update to 7.0.0.

---
 srcpkgs/unpaper/template | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/srcpkgs/unpaper/template b/srcpkgs/unpaper/template
index 38ed47a58401..1ff910e722af 100644
--- a/srcpkgs/unpaper/template
+++ b/srcpkgs/unpaper/template
@@ -1,13 +1,13 @@
 # Template file for 'unpaper'
 pkgname=unpaper
-version=6.1
-revision=3
-build_style=gnu-configure
+version=7.0.0
+revision=1
+build_style=meson
+hostmakedepends="pkg-config meson libxslt"
+makedepends="ffmpeg-devel python3-Sphinx"
+short_desc="Post-processing tool for scanned sheets of paper"
 maintainer="Orphaned <orphan@voidlinux.org>"
-hostmakedepends="pkg-config libxslt"
-makedepends="ffmpeg-devel"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://www.flameeyes.eu/projects/unpaper"
-short_desc="A post-processing tool for scanned sheets of paper"
 distfiles="https://www.flameeyes.eu/files/${pkgname}-${version}.tar.xz"
-checksum=237c84f5da544b3f7709827f9f12c37c346cdf029b1128fb4633f9bafa5cb930
+checksum=2575fbbf26c22719d1cb882b59602c9900c7f747118ac130883f63419be46a80

From cb5bd6d3a2bab75fbe68d6e69e1317e7523310a3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 088/115] vba-m: revbump for ffmpeg-6.0

---
 srcpkgs/vba-m/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vba-m/template b/srcpkgs/vba-m/template
index ba153e0b58ca..aa6093645e97 100644
--- a/srcpkgs/vba-m/template
+++ b/srcpkgs/vba-m/template
@@ -2,7 +2,7 @@
 pkgname=vba-m
 reverts=1292_2
 version=2.1.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_GTK=TRUE -DENABLE_FFMPEG=TRUE -DENABLE_LINK=TRUE -DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="gettext pkg-config unzip zip yasm wxWidgets-gtk3-devel"

From 6b21a32310dbcdcf058faa785c2b88abc205d28f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 089/115] vice: revbump for ffmpeg4-4.4.3

---
 srcpkgs/vice/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/vice/template b/srcpkgs/vice/template
index 0924767cfcfb..5981e45149d0 100644
--- a/srcpkgs/vice/template
+++ b/srcpkgs/vice/template
@@ -1,7 +1,7 @@
 # Template file for 'vice'
 pkgname=vice
 version=3.5
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="
 	$(vopt_enable sdl2 sdlui2)
@@ -28,7 +28,7 @@ makedepends="
 	$(vopt_if gtk3 gtk+3-devel)
 	$(vopt_if gtk3 pulseaudio-devel)
 	$(vopt_if gtk3 pango-devel)
-	$(vopt_if ffmpeg ffmpeg-devel)"
+	$(vopt_if ffmpeg ffmpeg4-devel)"
 short_desc="Emulator for C64, C128, CBM-II, PET, VIC20, Plus4 and C16"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"

From 472c8e6446dd5243b5a93d020acd4bad367c9318 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 090/115] waypipe: revbump for ffmpeg-6.0

---
 srcpkgs/waypipe/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waypipe/template b/srcpkgs/waypipe/template
index 5c4161900060..1a46fe27f7d8 100644
--- a/srcpkgs/waypipe/template
+++ b/srcpkgs/waypipe/template
@@ -1,7 +1,7 @@
 # Template file for 'waypipe'
 pkgname=waypipe
 version=0.8.4
-revision=1
+revision=2
 build_style=meson
 # lto is off because it causes linking errors in armv6l and armv7l (due to NEON)
 configure_args="-Dwerror=false -Dwith_dmabuf=enabled -Dwith_lz4=enabled

From 4294b8ffcb8df95e0ffd50251d8878ed2aa29c30 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 091/115] wf-recorder: revbump for ffmpeg-6.0

---
 srcpkgs/wf-recorder/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/wf-recorder/template b/srcpkgs/wf-recorder/template
index e278eb001600..5d014a5f28af 100644
--- a/srcpkgs/wf-recorder/template
+++ b/srcpkgs/wf-recorder/template
@@ -1,7 +1,7 @@
 # Template file for 'wf-recorder'
 pkgname=wf-recorder
 version=0.3.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config scdoc wayland-devel"
 makedepends="wayland-protocols wayland-devel ffmpeg-devel x264-devel

From b0ba548e38c866d37c9075268175aa7a57e42e23 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 092/115] xpra: revbump for ffmpeg-6.0

---
 srcpkgs/xpra/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xpra/template b/srcpkgs/xpra/template
index ee8ce4ec78a9..c02482ad4b39 100644
--- a/srcpkgs/xpra/template
+++ b/srcpkgs/xpra/template
@@ -1,7 +1,7 @@
 # Template file for 'xpra'
 pkgname=xpra
 version=4.4.5
-revision=1
+revision=2
 build_style=python3-module
 make_build_args="--without-cuda_kernels --without-cuda_rebuild"
 make_install_args="$(vopt_with docs) ${make_build_args}"

From 81fa4273ed394de9abe4ba5390e2e5d33b67d316 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:07:40 -0400
Subject: [PATCH 093/115] nv-codec-headers: update to 12.0.16.0

---
 srcpkgs/nv-codec-headers/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/nv-codec-headers/template b/srcpkgs/nv-codec-headers/template
index 3d422a61e489..251e057f826f 100644
--- a/srcpkgs/nv-codec-headers/template
+++ b/srcpkgs/nv-codec-headers/template
@@ -1,6 +1,6 @@
 # Template file for 'nv-codec-headers'
 pkgname=nv-codec-headers
-version=11.1.5.1
+version=12.0.16.0
 revision=1
 build_style=gnu-makefile
 short_desc="FFmpeg version of headers required to interface with Nvidias codec APIs"
@@ -8,7 +8,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="MIT"
 homepage="http://git.videolan.org/?p=ffmpeg/nv-codec-headers.git"
 distfiles="https://github.com/FFmpeg/nv-codec-headers/archive/n${version}.tar.gz"
-checksum=d095fbd56aa93772471a323be0ebe65504a0f43f06c76a30b6d25da77b06ae9c
+checksum=2a1533b65f55f9da52956faf0627ed3b74868ac0c7f269990edd21369113b48f
 
 post_install() {
 	sed -n '4,25p' include/ffnvcodec/nvEncodeAPI.h > LICENSE

From fbccd63c14b55a3a19eb735efa65fe8d729615e3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:08:40 -0400
Subject: [PATCH 094/115] openimagedenoise: revbump for ffmpeg-6.0

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index db5ccdb055cc..cb90045afb63 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,7 +1,7 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
 version=1.4.3
-revision=1
+revision=2
 archs="x86_64*"
 build_style=cmake
 hostmakedepends="ispc python3"

From bab86c5cc1852df4975f5180fb2f70000abbd379 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:31:45 -0400
Subject: [PATCH 095/115] shotcut: revbump for ffmpeg-6.0

---
 srcpkgs/shotcut/template | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/srcpkgs/shotcut/template b/srcpkgs/shotcut/template
index 99ebf2e8a5af..c416c906ff73 100644
--- a/srcpkgs/shotcut/template
+++ b/srcpkgs/shotcut/template
@@ -1,20 +1,20 @@
 # Template file for 'shotcut'
 pkgname=shotcut
-version=22.12.21
-revision=1
+version=23.05.14
+revision=2
 build_style=cmake
 configure_args="-DSHOTCUT_VERSION=${version}"
-hostmakedepends="pkg-config qt5-tools-devel"
-makedepends="mlt7-devel qt5-declarative-devel qt5-multimedia-devel
- qt5-quickcontrols2-devel qt5-websockets-devel qt5-plugin-mysql qt5-plugin-odbc
- qt5-plugin-pgsql qt5-plugin-sqlite qt5-plugin-tds"
-depends="ffmpeg frei0r-plugins qt5-graphicaleffects qt5-quickcontrols"
+hostmakedepends="pkg-config qt6-tools-devel"
+makedepends="mlt7-devel qt6-declarative-devel qt6-multimedia-devel
+ qt6-websockets-devel qt6-plugin-mysql qt6-plugin-odbc
+ qt6-plugin-pgsql qt6-plugin-sqlite"
+depends="ffmpeg frei0r-plugins qt6-declarative"
 short_desc="Free, open source, cross-platform video editor"
 maintainer="John <me@johnnynator.dev>"
 license="GPL-3.0-or-later"
 homepage="https://www.shotcut.org"
 changelog="https://github.com/mltframework/shotcut/releases"
 distfiles="https://github.com/mltframework/shotcut/archive/v${version}.tar.gz"
-checksum=1b9a4f87b16a9751f9cb41588f22af4c00f085105d82cf21d095d9f3c280bc86
+checksum=94632bd69cc8f3b2cba0668b9e8d051493efa5a9c9554c02822c346fe64c1ce0
 
 CXXFLAGS="-DHAVE_LOCALE_H=1 -DSHOTCUT_NOUPGRADE"

From 900eebefaef94bd18c581f598c435b706b71216f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:30 -0400
Subject: [PATCH 096/115] shiboken2: revbump for qt5-5.15.8

---
 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch | 1 +
 srcpkgs/shiboken2/template                                 | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
 create mode 120000 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
new file mode 120000
index 000000000000..efcf3249bd88
--- /dev/null
+++ b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1 @@
+../../python3-pyside2/patches/importlib-machinery-bypass.patch
\ No newline at end of file
diff --git a/srcpkgs/shiboken2/template b/srcpkgs/shiboken2/template
index 084ecc3ba1e1..2a21998997eb 100644
--- a/srcpkgs/shiboken2/template
+++ b/srcpkgs/shiboken2/template
@@ -1,7 +1,7 @@
 # Template file for 'shiboken2'
 pkgname=shiboken2
 version=5.15.7
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/shiboken2"
 build_style=cmake

From a73794932977336de64be976cebb01dead962ddb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:53 -0400
Subject: [PATCH 097/115] python3-pyside2: update to 5.15.8

---
 .../patches/importlib-machinery-bypass.patch      | 15 +++++++++++++++
 srcpkgs/python3-pyside2/template                  |  9 +++++----
 2 files changed, 20 insertions(+), 4 deletions(-)
 create mode 100644 srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
new file mode 100644
index 000000000000..64c429584776
--- /dev/null
+++ b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1,15 @@
+Using this prevents an error around line 220 below it.
+"AttributeError: module 'importlib' has no attribute 'machinery'"
+The old backup logic is in place and compiles without issues.
+--- a/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:09:34.688912402 -0400
++++ b/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:10:03.395529582 -0400
+@@ -170,9 +170,6 @@
+
+     # 'zipstring_sequence' comes from signature.cpp
+     zipbytes = base64.b64decode(''.join(zipstring_sequence))
+-    if sys.version_info[0] >= 3:
+-        vzip = zipfile.ZipFile(io.BytesIO(zipbytes))
+-        return sys.meta_path, EmbeddableZipImporter(vzip)
+
+     # Old version for Python 2.7, only.
+     import os
diff --git a/srcpkgs/python3-pyside2/template b/srcpkgs/python3-pyside2/template
index 50e6ff260d3b..b50e62bd215d 100644
--- a/srcpkgs/python3-pyside2/template
+++ b/srcpkgs/python3-pyside2/template
@@ -1,11 +1,12 @@
 # Template file for 'python3-pyside2'
 pkgname=python3-pyside2
-version=5.15.5
-revision=2
+version=5.15.8
+revision=1
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/pyside2"
 build_style=cmake
-configure_args="-DPYTHON_EXECUTABLE=/usr/bin/python"
+configure_args="-DPYTHON_EXECUTABLE=/usr/bin/python -DCMAKE_BUILD_TYPE=None
+ -DBUILD_TESTS=OFF"
 hostmakedepends="cmake python3 shiboken2"
 makedepends="python3-devel libshiboken2-devel qt5-devel
  qt5-multimedia-devel qt5-tools-devel qt5-plugin-mysql qt5-plugin-odbc
@@ -23,7 +24,7 @@ maintainer="yopito <pierre.bourgin@free.fr>"
 license="LGPL-3.0-or-later"
 homepage="https://wiki.qt.io/Qt_for_Python"
 distfiles="https://download.qt.io/official_releases/QtForPython/pyside2/PySide2-${version}-src/${_pkgname}.tar.xz"
-checksum=3920a4fb353300260c9bc46ff70f1fb975c5e7efa22e9d51222588928ce19b33
+checksum=23436302c8deb5b4cbc769b205d09604e38ba83b40708efccb7bd8c9af6f6b5d
 
 build_options="webengine"
 desc_option_webengine="Build Qt5 WebEngine bindings"

From 14320581855abf014c8a5bc7b5e3f955f536dd0e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:35 -0400
Subject: [PATCH 098/115] konqueror: revbump for ffmpeg-6.0

---
 srcpkgs/konqueror/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/konqueror/template b/srcpkgs/konqueror/template
index d8d0e73a78ab..c5bdba601d3c 100644
--- a/srcpkgs/konqueror/template
+++ b/srcpkgs/konqueror/template
@@ -1,11 +1,11 @@
 # Template file for 'konqueror'
 pkgname=konqueror
 version=23.04.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DDESKTOPTOJSON_EXECUTABLE=/usr/bin/desktoptojson"
 hostmakedepends="extra-cmake-modules python3 qt5-host-tools qt5-qmake kdoctools
-kcoreaddons kconfig gettext"
+ kcoreaddons kconfig gettext"
 makedepends="qt5-devel qt5-webengine-devel qt5-declarative-devel
  qt5-webchannel-devel qt5-location-devel kcmutils-devel kdelibs4support-devel
  karchive-devel khtml-devel kdesu-devel kactivities5-devel"

From d5269859cccd4433f7f70af05d511b823f6fcb6c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:58 -0400
Subject: [PATCH 099/115] qt5-speech: revbump for qt5-5.15.8

---
 srcpkgs/qt5-speech/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-speech/template b/srcpkgs/qt5-speech/template
index 3ecd10d50650..2d7d4d4d2453 100644
--- a/srcpkgs/qt5-speech/template
+++ b/srcpkgs/qt5-speech/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-speech'
 pkgname=qt5-speech
 version=5.15.7
-revision=2
+revision=3
 _commit=d32f4a479d38a11f547598004b975f4356424a16
 build_style=qmake
 configure_args="-- -flite -flite-alsa -speechd"

From 49c3dce46da6d4db9ecc6bc0ae1cf57ee06a8e18 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 18:38:50 -0400
Subject: [PATCH 100/115] qt5-styleplugins: revbump for qt5-5.15.8

---
 srcpkgs/qt5-styleplugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-styleplugins/template b/srcpkgs/qt5-styleplugins/template
index 96ed97d12cd2..30d93660a2a4 100644
--- a/srcpkgs/qt5-styleplugins/template
+++ b/srcpkgs/qt5-styleplugins/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-styleplugins'
 pkgname=qt5-styleplugins
 version=5.0.0
-revision=20
+revision=21
 _gitrev=335dbece103e2cbf6c7cf819ab6672c2956b17b3
 build_style=qmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From 72df853e9019f192c7d5b1c89037a921117a458d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 30 Apr 2023 20:22:26 -0400
Subject: [PATCH 101/115] gst-plugins-ugly1: revbump for ffmpeg-6.0

---
 srcpkgs/gst-plugins-ugly1/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-plugins-ugly1/template b/srcpkgs/gst-plugins-ugly1/template
index e254fd40f869..85ae64bc7a0a 100644
--- a/srcpkgs/gst-plugins-ugly1/template
+++ b/srcpkgs/gst-plugins-ugly1/template
@@ -1,6 +1,6 @@
 # Template file for 'gst-plugins-ugly1'
 pkgname=gst-plugins-ugly1
-version=1.20.3
+version=1.22.2
 revision=1
 build_style=meson
 configure_args="-Damrnb=disabled -Damrwbdec=disabled -Dsidplay=disabled"
@@ -15,4 +15,4 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname/1/}/${pkgname/1/}-${version}.tar.xz"
-checksum=8caa20789a09c304b49cf563d33cca9421b1875b84fcc187e4a385fa01d6aefd
+checksum=8f30f44db0bd063709bf6fbe55138e3a98af0abcb61c360f35582bbe10e80691

From e11c06f742a80e763f230d8fc3d43974395d727f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 30 Apr 2023 20:22:26 -0400
Subject: [PATCH 102/115] gst-rtsp-server: revbump for ffmpeg-6.0

---
 srcpkgs/gst-rtsp-server/template | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index 8ceea8d34b4b..980fd72cdd4c 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
-version=1.20.3
-revision=3
+version=1.22.2
+revision=2
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="glib-devel gst-plugins-bad1-devel gobject-introspection
@@ -10,5 +10,5 @@ short_desc="GStreamer multimedia graph framework - rtsp server"
 maintainer="1is7ac3 <isaac.qa13@gmail.com>"
 license="LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
-distfiles="https://gstreamer.freedesktop.org/src/gst-rtsp-server/gst-rtsp-server-${version}.tar.xz"
-checksum=ee402718be9b127f0e5e66ca4c1b4f42e4926ec93ba307b7ccca5dc6cc9794ca
+distfiles="${homepage}/src/${pkgname}/${pkgname}-${version}.tar.xz"
+checksum=2be4aecfb88710100ea7115ed0216403e8094344ebf146094271b8d4d73828bf

From 5b7b0f1f2bec468bb6b55c6959c3059b71eb8964 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 30 Apr 2023 20:22:26 -0400
Subject: [PATCH 103/115] gst-libav: revbump for ffmpeg-6.0

---
 srcpkgs/gst-libav/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index f082bd211c65..04c39bff1489 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,6 +1,6 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
-version=1.20.3
+version=1.22.2
 revision=2
 build_style=meson
 hostmakedepends="pkg-config yasm"
@@ -11,7 +11,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.0-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname}/${pkgname}-${version}.tar.xz"
-checksum=3fedd10560fcdfaa1b6462cbf79a38c4e7b57d7f390359393fc0cef6dbf27dfe
+checksum=fcaaf9878fe8f3bc82317ef13a1558824cb68df1f8968c6797f556c5e33bcffd
 
 case "$XBPS_TARGET_MACHINE" in
 	*-musl) # Required by musl for M_SQRT1_2

From 9cc26044370de68b85a69a655ce2f1ed624830c6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 7 May 2023 20:14:14 -0400
Subject: [PATCH 104/115] mlt7: revbump for ffmpeg-6.0

---
 srcpkgs/gst-libav/template             | 2 +-
 srcpkgs/gst-omx/template               | 4 ++--
 srcpkgs/gst-plugins-base1/template     | 4 ++--
 srcpkgs/gst-plugins-good1/template     | 4 ++--
 srcpkgs/gst1-editing-services/template | 4 ++--
 srcpkgs/gst1-python3/template          | 6 +++---
 srcpkgs/gstreamer-vaapi/template       | 4 ++--
 srcpkgs/gstreamer1/template            | 4 ++--
 srcpkgs/mlt7/template                  | 2 +-
 9 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index 04c39bff1489..8c72fc3e97ee 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.22.2
-revision=2
+revision=1
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"
diff --git a/srcpkgs/gst-omx/template b/srcpkgs/gst-omx/template
index 893535c463da..5ad54cc7b9d8 100644
--- a/srcpkgs/gst-omx/template
+++ b/srcpkgs/gst-omx/template
@@ -1,6 +1,6 @@
 # Template file for 'gst-omx'
 pkgname=gst-omx
-version=1.20.3
+version=1.22.2
 revision=1
 build_style=meson
 configure_args="-Dexamples=disabled -Dtarget=generic"
@@ -11,4 +11,4 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.1-only"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname}/${pkgname}-${version}.tar.xz"
-checksum=8db48040bb41f09edf8d17ff6d16c54888d7777ba4501c2c69f0083350ea9a15
+checksum=1b0c57f2cc4ddeec5e7f0c436e502f06665c4e93c73261855b94e04fc94337b2
diff --git a/srcpkgs/gst-plugins-base1/template b/srcpkgs/gst-plugins-base1/template
index 29e8f76bd1fe..2f20ea819849 100644
--- a/srcpkgs/gst-plugins-base1/template
+++ b/srcpkgs/gst-plugins-base1/template
@@ -1,6 +1,6 @@
 # Template file for 'gst-plugins-base1'
 pkgname=gst-plugins-base1
-version=1.20.3
+version=1.22.2
 revision=1
 build_style=meson
 build_helper="gir"
@@ -22,7 +22,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname/1/}/${pkgname/1/}-${version}.tar.xz"
-checksum=7e30b3dd81a70380ff7554f998471d6996ff76bbe6fc5447096f851e24473c9f
+checksum=eb65120c4ee79b7a153c3c1972d5c0158c2151877cc51ec7725bba5749679d49
 
 build_options="cdparanoia gir sndio wayland"
 build_options_default="cdparanoia gir wayland"
diff --git a/srcpkgs/gst-plugins-good1/template b/srcpkgs/gst-plugins-good1/template
index 1f5e620ce1fd..5d0fe1bfe284 100644
--- a/srcpkgs/gst-plugins-good1/template
+++ b/srcpkgs/gst-plugins-good1/template
@@ -1,6 +1,6 @@
 # Template file for 'gst-plugins-good1'
 pkgname=gst-plugins-good1
-version=1.20.3
+version=1.22.2
 revision=1
 build_style=meson
 configure_args="-Ddv=disabled -Ddv1394=disabled -Dshout2=disabled -Dqt5=enabled
@@ -22,7 +22,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname/1/}/${pkgname/1/}-${version}.tar.xz"
-checksum=f8f3c206bf5cdabc00953920b47b3575af0ef15e9f871c0b6966f6d0aa5868b7
+checksum=7c8cc59425f2b232f60ca7d13e56edd615da4f711e73dd01a7cffa46e6bc0cdd
 
 build_options="gtk3 wayland"
 build_options_default="gtk3 wayland"
diff --git a/srcpkgs/gst1-editing-services/template b/srcpkgs/gst1-editing-services/template
index 673b46970f24..102440f7f253 100644
--- a/srcpkgs/gst1-editing-services/template
+++ b/srcpkgs/gst1-editing-services/template
@@ -1,6 +1,6 @@
 # Template file for 'gst1-editing-services'
 pkgname=gst1-editing-services
-version=1.20.3
+version=1.22.2
 revision=1
 build_style=meson
 build_helper="gir"
@@ -12,7 +12,7 @@ maintainer="Toyam Cox <Vaelatern@gmail.com>"
 license="LGPL-2.0-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname/gst1/gst}/${pkgname/gst1/gst}-${version}.tar.xz"
-checksum=5fd896de69fbe24421eb6b0ff8d2f8b4c3cba3f3025ceacd302172f39a8abaa2
+checksum=453b1464fc3857de269a7cb0ebd966afe02171d97bef672a0b8a0a6d43e0cebf
 
 do_check() {
 	: # Tests fail in older versions as well
diff --git a/srcpkgs/gst1-python3/template b/srcpkgs/gst1-python3/template
index 3f564ac64b93..789e40f036ea 100644
--- a/srcpkgs/gst1-python3/template
+++ b/srcpkgs/gst1-python3/template
@@ -1,7 +1,7 @@
 # Template file for 'gst1-python3'
 pkgname=gst1-python3
-version=1.20.3
-revision=2
+version=1.22.2
+revision=1
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="libglib-devel python3-devel python3-gobject-devel gst-plugins-base1-devel"
@@ -11,4 +11,4 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/gst-python/gst-python-${version}.tar.xz"
-checksum=db348120eae955b8cc4de3560a7ea06e36d6e1ddbaa99a7ad96b59846601cfdc
+checksum=bef2b3d82ce4be46b775b1bb56305c1003ee01b535a53a82f9fe8924972153ad
diff --git a/srcpkgs/gstreamer-vaapi/template b/srcpkgs/gstreamer-vaapi/template
index 3cc4e057559a..0a5ee8b1ca3f 100644
--- a/srcpkgs/gstreamer-vaapi/template
+++ b/srcpkgs/gstreamer-vaapi/template
@@ -1,6 +1,6 @@
 # Template file for 'gstreamer-vaapi'
 pkgname=gstreamer-vaapi
-version=1.20.3
+version=1.22.2
 revision=1
 build_style=meson
 hostmakedepends="pkg-config"
@@ -11,7 +11,7 @@ license="LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
 changelog="https://raw.githubusercontent.com/GStreamer/gstreamer-vaapi/master/ChangeLog"
 distfiles="${homepage}/src/gstreamer-vaapi/gstreamer-vaapi-${version}.tar.xz"
-checksum=6ee99eb316abdde9ad37002915bd8c3867918f6fdc74b7cf2ac4c1ae0d690b45
+checksum=d2e642f9745f97d9f73a7f5085e7659a9a31fe209b774e6e45dae041b435df06
 
 pre_check() {
 	# Seems to need certain hardware to pass
diff --git a/srcpkgs/gstreamer1/template b/srcpkgs/gstreamer1/template
index ae8a49cb20e8..571148f2ff33 100644
--- a/srcpkgs/gstreamer1/template
+++ b/srcpkgs/gstreamer1/template
@@ -1,6 +1,6 @@
 # Template file for 'gstreamer1'
 pkgname=gstreamer1
-version=1.20.3
+version=1.22.2
 revision=1
 build_style=meson
 build_helper="gir"
@@ -16,7 +16,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.0-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/gstreamer/gstreamer-${version}.tar.xz"
-checksum=607daf64bbbd5fb18af9d17e21c0d22c4d702fffe83b23cb22d1b1af2ca23a2a
+checksum=b2afe73603921c608ba48969dbb7d743776744bfe5d8059ece241137b7f88e21
 
 pre_check() {
 	# gst_gstdatetime is known to fail according to LFS
diff --git a/srcpkgs/mlt7/template b/srcpkgs/mlt7/template
index 9fb7f60d692e..cca0eb68cfc3 100644
--- a/srcpkgs/mlt7/template
+++ b/srcpkgs/mlt7/template
@@ -1,7 +1,7 @@
 # Template file for 'mlt7'
 pkgname=mlt7
 version=7.14.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSWIG_PYTHON=ON"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which

From f0eb256cc70ea72a6d1f48b46957c1f1339ab9ab Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 7 May 2023 20:15:03 -0400
Subject: [PATCH 105/115] qt6-webengine: revbump for ffmpeg-6.0

---
 srcpkgs/qt6-webengine/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-webengine/template b/srcpkgs/qt6-webengine/template
index 4e22cb6e8863..f948dc919a15 100644
--- a/srcpkgs/qt6-webengine/template
+++ b/srcpkgs/qt6-webengine/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-webengine'
 pkgname=qt6-webengine
 version=6.5.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="
  -DQT_FEATURE_webengine_system_ffmpeg=ON

From 47966b10797463c4126b940ab031771e80cc559a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 7 May 2023 20:15:29 -0400
Subject: [PATCH 106/115] tracker-miners: revbump for ffmpeg-6.0

---
 srcpkgs/tracker-miners/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tracker-miners/template b/srcpkgs/tracker-miners/template
index 8c005d697fa4..a6e5aa577702 100644
--- a/srcpkgs/tracker-miners/template
+++ b/srcpkgs/tracker-miners/template
@@ -1,7 +1,7 @@
 # Template file for 'tracker-miners'
 pkgname=tracker-miners
 version=3.5.0
-revision=3
+revision=4
 build_style=meson
 build_helper=qemu
 # missing libgrss for miner_rss

From d8edbab70cba768a996361efe8e64dea0ce9d6f5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 7 May 2023 20:20:58 -0400
Subject: [PATCH 107/115] mpd: revbump for ffmpeg-6.0

---
 srcpkgs/mpd/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpd/template b/srcpkgs/mpd/template
index 9dbd4c935acc..9f058b62df2f 100644
--- a/srcpkgs/mpd/template
+++ b/srcpkgs/mpd/template
@@ -1,7 +1,7 @@
 # Template file for 'mpd'
 pkgname=mpd
 version=0.23.13
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dopus=enabled -Dmikmod=enabled -Dneighbor=true
  -Dsoundcloud=enabled -Dpipe=true -Dtwolame=enabled -Dbzip2=enabled

From 3cd5fecc28b288b90aded25873c4bdc26abdb44b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 11 May 2023 14:05:14 -0400
Subject: [PATCH 108/115] openmw: revbump for ffmpeg-6.0

---
 srcpkgs/openmw/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openmw/template b/srcpkgs/openmw/template
index e3771c7aaf1a..3cbf20b06577 100644
--- a/srcpkgs/openmw/template
+++ b/srcpkgs/openmw/template
@@ -1,7 +1,7 @@
 # Template file for 'openmw'
 pkgname=openmw
 version=0.47.0
-revision=5
+revision=6
 build_style=cmake
 _recast_commit=e75adf86f91eb3082220085e42dda62679f9a3ea
 _bullet_tag=3.17

From 1150f2ab585ead27488072bd6fb95de109dcc4e2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 21 May 2023 12:44:11 -0400
Subject: [PATCH 109/115] electron24: revbump for ffmpeg-6.0

---
 srcpkgs/electron24/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron24/template b/srcpkgs/electron24/template
index bdaa56adc8a6..ff3d5e3ef381 100644
--- a/srcpkgs/electron24/template
+++ b/srcpkgs/electron24/template
@@ -1,7 +1,7 @@
 # Template file for 'electron24'
 pkgname=electron24
 version=24.3.0
-revision=1
+revision=2
 _nodever=18.14.0
 _chromiumver=112.0.5615.165
 archs="x86_64* aarch64*"

From 3e4ecbe41896172800a4cf5a885c675f768d4cd4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Jun 2023 08:20:22 -0400
Subject: [PATCH 110/115] gtk4: revbump for ffmpeg-6.0

---
 srcpkgs/gtk4/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gtk4/template b/srcpkgs/gtk4/template
index 5fafa50f6f33..5e5523aa4403 100644
--- a/srcpkgs/gtk4/template
+++ b/srcpkgs/gtk4/template
@@ -1,7 +1,7 @@
 # Template file for 'gtk4'
 pkgname=gtk4
 version=4.10.3
-revision=2
+revision=3
 build_style=meson
 build_helper="gir"
 configure_args="-Dman-pages=true -Dgtk_doc=true

From 449613327fe91ccafbda2c7e9bd5a92d9dc3b140 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:25:50 -0400
Subject: [PATCH 111/115] electron19: revbump for ffmpeg-6.0

---
 srcpkgs/electron19/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron19/template b/srcpkgs/electron19/template
index 32ce301e730c..ab7f308f5e8a 100644
--- a/srcpkgs/electron19/template
+++ b/srcpkgs/electron19/template
@@ -1,7 +1,7 @@
 # Template file for 'electron19'
 pkgname=electron19
 version=19.0.8
-revision=3
+revision=4
 _nodever=16.14.2
 _chromiumver=102.0.5005.125
 archs="x86_64* aarch64* ppc64le*"

From 46b248f66dc3faa6438cbb1e66fd812da9a99139 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:28:26 -0400
Subject: [PATCH 112/115] siril: revbump for ffmpeg-6.0

---
 srcpkgs/siril/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/siril/template b/srcpkgs/siril/template
index 84332f79d060..62750dd24754 100644
--- a/srcpkgs/siril/template
+++ b/srcpkgs/siril/template
@@ -1,7 +1,7 @@
 # Template file for 'siril'
 pkgname=siril
 version=0.9.12
-revision=10
+revision=11
 build_style=gnu-configure
 hostmakedepends="pkg-config intltool autoconf automake gettext-devel"
 makedepends="fftw-devel libconfig-devel libopencv-devel libffms2-devel

From 05b073e35d68ab2c57ebef022049a2635bc3e944 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:29:08 -0400
Subject: [PATCH 113/115] telegram-desktop: revbump for ffmpeg-6.0

---
 srcpkgs/telegram-desktop/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/telegram-desktop/template b/srcpkgs/telegram-desktop/template
index f114b2341dc5..9db9f80c1a53 100644
--- a/srcpkgs/telegram-desktop/template
+++ b/srcpkgs/telegram-desktop/template
@@ -1,7 +1,7 @@
 # Template file for 'telegram-desktop'
 pkgname=telegram-desktop
 version=4.8.1
-revision=3
+revision=4
 build_style=cmake
 build_helper="qemu"
 configure_args="-DTDESKTOP_API_ID=209235

From 796a44563a8806155ee91c8a551998318d0548ff Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 10 Jun 2023 00:40:39 -0400
Subject: [PATCH 114/115] freecad: revbump for qt5-webengine-5.15.13

---
 srcpkgs/freecad/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/freecad/template b/srcpkgs/freecad/template
index a4a3f5f76b29..8608d1670c87 100644
--- a/srcpkgs/freecad/template
+++ b/srcpkgs/freecad/template
@@ -1,7 +1,7 @@
 # Template file for 'freecad'
 pkgname=freecad
 version=0.20.2
-revision=5
+revision=6
 build_style=cmake
 
 _inst_prefix=/usr/lib/${pkgname}

From f6af48d6422d0c002144f80bd423d96733292387 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 10 Jun 2023 00:57:09 -0400
Subject: [PATCH 115/115] qt6-multimedia: revbump for ffmpeg-6.0

---
 srcpkgs/qt6-multimedia/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-multimedia/template b/srcpkgs/qt6-multimedia/template
index a6832fdd69bf..c9ffac914ab8 100644
--- a/srcpkgs/qt6-multimedia/template
+++ b/srcpkgs/qt6-multimedia/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-multimedia'
 pkgname=qt6-multimedia
 version=6.5.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DQT_FEATURE_gstreamer=ON"
 hostmakedepends="perl qt6-declarative-host-tools pkg-config qt6-shadertools"

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (9 preceding siblings ...)
  2023-06-10  5:04 ` zlice
@ 2023-06-17 19:17 ` zlice
  2023-06-17 19:28 ` zlice
                   ` (86 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2023-06-17 19:17 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 3480 bytes --]

There is an updated pull request by zlice against master on the void-packages repository

https://github.com/zlice/void-packages ffmpeg6-split
https://github.com/void-linux/void-packages/pull/43761

ffmpeg6 split
[ci skip]


#### Testing the changes

- I tested the changes in this PR: **YES**

main testing has been vaapi in Firefox Nightly and enc/dec in Shotcut on Intel A770

#### New package

- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**

#### Local build testing

- I built this PR locally for my native architecture, **x86_64**

#### Discussion

Continuation of https://github.com/void-linux/void-packages/pull/36315

`libavresample` is deprecated, but marked as a dependency when trying to build other packages and install `ffmpeg`(6). I think the right way to handle this is make a meta package and the add to removals?


##### Commit naming / misc

~~Commits are 'dirty' right now, running with [gstreamer 1.22.1 updates](https://github.com/void-linux/void-packages/pull/42861) and [Intel OpenCL](https://github.com/void-linux/void-packages/pull/43084). This will also make [intel packages pr](https://github.com/void-linux/void-packages/pull/41132) obsolete.~~ (see Requirements below)

Maintainer for previous ffmpeg(4) was orphaned, I can put my name in there if that matters, though I don't exactly see myself keeping up on ffmpeg.

This updates QT5 which looks like it is usually hosted by Johnny. Not sure if there's any reason to stay there or these sources are fine.

##### STILL FFMPEG4

These are a mix of emulators, games and/or older packages.

- attract (multiple patches in master)
- audacity (https://github.com/audacity/audacity/issues/2305 and https://sourceforge.net/p/portmedia/wiki/portsmf/ is 'beta')
- ccextractor (master patches? no release)
- vice
- kodi
- mlt (only dep left is flowblade)
- ~~synfig (mlt)~~ (work with mlt7, bump synfigstudio)
- tvheadend
- ssr
- spek-alternative
- ppsspp
- olive
- moc
- mediastreamer
- libextractor
- idjc
- hedgewars
- ~~ffmpegthumbnailer~~ (patches for moviedecoder.xxx files)
- ~~ffmpegthumbs~~ (latest compiles)
- deadbeef
- omxplayer
- qtav (fork has ffmpeg 5 patch - https://github.com/cmguo/QtAV)
- `vlc` (vlc4 will support ffmpeg5, there's a patch to build 3.x with ffmpeg5 but it will lack vaapi)
- `osg` (OpenSceneGraph plus `xine-lib`)


##### HAVE NOT BUILT YET

- omxplayer (rpi only? ffmpeg4)
- kodi (big, but ffmpeg4)


##### UPDATED (for ffmpeg6)

- ~~blender: update to 3.5.1~~ ~~will be revbump with~~ https://github.com/void-linux/void-packages/pull/43992
- unpaper: update to 7.0.0.
- guvcview: update to 2.0.8.
- qt5: update to 5.15.8
- qt5-webengine: update to 5.18.13
- shiboken2: revbump for qt5.15.8 (patch)
- python3-pyside2: update to 5.15.8 (patch)


##### Requirements

- [gstreamer 1.22.2](https://github.com/void-linux/void-packages/pull/42861) - a few packages use ffmpeg-devel and require a revbump

- [Intel Packages](https://github.com/void-linux/void-packages/pull/41132) - ffmpeg4 uses different libraries than 6 (libmfx / Intel-MediaSDK vs only oneVPL that Intel is moving to), both are included here

- [shotcut 23.05.14](https://github.com/void-linux/void-packages/pull/44260)

A patch file from https://github.com/void-linux/void-packages/pull/43761.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ffmpeg6-split-43761.patch --]
[-- Type: text/x-diff, Size: 789492 bytes --]

From fd64bfe0f7c92696f57fc9da3eb00bfbdc02ad17 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:55:46 -0400
Subject: [PATCH 001/116] ffmpeg: update to 6.0.

---
 common/shlibs                                 | 26 +++++---
 srcpkgs/ffmpeg/files/altivec.patch            | 60 -------------------
 .../patches/armv5tel-floating-point.patch     | 18 ------
 .../workaround-mesa-readeon-vaapi-bug.patch   | 28 ---------
 srcpkgs/ffmpeg/template                       | 38 +++++-------
 5 files changed, 32 insertions(+), 138 deletions(-)
 delete mode 100644 srcpkgs/ffmpeg/files/altivec.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch

diff --git a/common/shlibs b/common/shlibs
index 494e99b89550..892e119802cb 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -387,15 +387,23 @@ libid3tag.so.0 libid3tag-0.15.1b_1
 libgif.so.7 giflib-5.1.0_1
 libImlib2.so.1 imlib2-1.4.2_1
 libmp3lame.so.0 lame-3.98.2_1
-libavdevice.so.58 libavdevice-4.0_1
-libavformat.so.58 libavformat-4.0_1
-libswscale.so.5 libswscale-4.0_1
-libswresample.so.3 libswresample-4.0_1
-libavresample.so.4 libavresample-4.0_1
-libpostproc.so.55 libpostproc-4.0_1
-libavcodec.so.58 libavcodec-4.0_1
-libavutil.so.56 libavutil-4.0_1
-libavfilter.so.7 libavfilter-4.0_1
+libavdevice.so.60 libavdevice-6.0_1
+libavformat.so.60 libavformat-6.0_1
+libswscale.so.7 libswscale-6.0_1
+libswresample.so.4 libswresample-6.0_1
+libpostproc.so.57 libpostproc-6.0_1
+libavcodec.so.60 libavcodec-6.0_1
+libavutil.so.58 libavutil-6.0_1
+libavfilter.so.9 libavfilter-6.0_1
+libavdevice.so.58 libavdevice4-4.0_1
+libavformat.so.58 libavformat4-4.0_1
+libswscale.so.5 libswscale4-4.0_1
+libswresample.so.3 libswresample4-4.0_1
+libavresample.so.4 libavresample4-4.0_1
+libpostproc.so.55 libpostproc4-4.0_1
+libavcodec.so.58 libavcodec4-4.0_1
+libavutil.so.56 libavutil4-4.0_1
+libavfilter.so.7 libavfilter4-4.0_1
 libSDL-1.2.so.0 SDL-1.2.14_1
 libSDL_image-1.2.so.0 SDL_image-1.2.10_1
 libx264.so.157 x264-20190507.2245_1
diff --git a/srcpkgs/ffmpeg/files/altivec.patch b/srcpkgs/ffmpeg/files/altivec.patch
deleted file mode 100644
index 9c5720046332..000000000000
--- a/srcpkgs/ffmpeg/files/altivec.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-revert some altivec specific change on all ppc* except ppc64le*
-
-q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
-conditionally, for ppc* but not ppc64le* (the new code is valid for
-POWER8 VSX which LE targets as a baseline but not BE)"
-
-
-This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
----
- libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
- 1 file changed, 20 insertions(+), 4 deletions(-)
-
-diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
-index 536545293d..c1e2852adb 100644
---- a/libswscale/ppc/yuv2rgb_altivec.c
-+++ b/libswscale/ppc/yuv2rgb_altivec.c
-@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-     vector signed short R1, G1, B1;                                           \
-     vector unsigned char R, G, B;                                             \
-                                                                               \
-+    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
-+    vector unsigned char align_perm;                                          \
-+                                                                              \
-     vector signed short lCY       = c->CY;                                    \
-     vector signed short lOY       = c->OY;                                    \
-     vector signed short lCRV      = c->CRV;                                   \
-@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
-                                                                               \
-         for (j = 0; j < w / 16; j++) {                                        \
--            y0 = vec_xl(0, y1i);                                              \
-+            y1ivP = (const vector unsigned char *) y1i;                       \
-+            y2ivP = (const vector unsigned char *) y2i;                       \
-+            uivP  = (const vector unsigned char *) ui;                        \
-+            vivP  = (const vector unsigned char *) vi;                        \
-+                                                                              \
-+            align_perm = vec_lvsl(0, y1i);                                    \
-+            y0 = (vector unsigned char)                                       \
-+                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
-                                                                               \
--            y1 = vec_xl(0, y2i);                                              \
-+            align_perm = vec_lvsl(0, y2i);                                    \
-+            y1 = (vector unsigned char)                                       \
-+                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
-                                                                               \
--            u = (vector signed char) vec_xl(0, ui);                           \
-+            align_perm = vec_lvsl(0, ui);                                     \
-+            u = (vector signed char)                                          \
-+                    vec_perm(uivP[0], uivP[1], align_perm);                   \
-                                                                               \
--            v = (vector signed char) vec_xl(0, vi);                           \
-+            align_perm = vec_lvsl(0, vi);                                     \
-+            v = (vector signed char)                                          \
-+                    vec_perm(vivP[0], vivP[1], align_perm);                   \
-                                                                               \
-             u = (vector signed char)                                          \
-                     vec_sub(u,                                                \
--- 
-2.27.0
-
diff --git a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
deleted file mode 100644
index 9a55178c74f0..000000000000
--- a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
-+++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
-@@ -39,6 +39,15 @@
- #endif
- #include <fenv.h>
- 
-+#if (FE_ALL_EXCEPT == 0)
-+/* E.g. ARM soft float does not define these */
-+#define FE_INVALID    0
-+#define FE_DIVBYZERO  0
-+#define FE_OVERFLOW   0
-+#define FE_UNDERFLOW  0
-+#define FE_INEXACT    0
-+#endif
-+
- #if CONFIG_LIBFONTCONFIG
- #include <fontconfig/fontconfig.h>
- #endif
diff --git a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
deleted file mode 100644
index 00e3f68a415b..000000000000
--- a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
-From: Rainer Hochecker <fernetmenta@online.de>
-Date: Sat, 26 Jan 2019 19:48:35 +0100
-Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
-
-This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
-It was hit frequently when watching h264 channels received via DVB-X.
-Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
----
- libavcodec/vaapi_h264.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
-index 5854587a255..f12fdc457a4 100644
---- a/libavcodec/vaapi_h264.c
-+++ b/libavcodec/vaapi_h264.c
-@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
-     H264SliceContext *sl = &h->slice_ctx[0];
-     int ret;
- 
-+    if (pic->nb_slices == 0) {
-+        ret = AVERROR_INVALIDDATA;
-+        goto finish;
-+    }
-+
-     ret = ff_vaapi_decode_issue(avctx, pic);
-     if (ret < 0)
-         goto finish;
diff --git a/srcpkgs/ffmpeg/template b/srcpkgs/ffmpeg/template
index df4179d1963a..f742082bb520 100644
--- a/srcpkgs/ffmpeg/template
+++ b/srcpkgs/ffmpeg/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpeg'
 # audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
 pkgname=ffmpeg
-version=4.4.4
+version=6.0
 revision=1
 short_desc="Decoding, encoding and streaming software"
 maintainer="Orphaned <orphan@voidlinux.org>"
@@ -9,7 +9,7 @@ license="GPL-3.0-or-later"
 homepage="https://www.ffmpeg.org"
 changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
 distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
-checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+checksum=57be87c22d9b49c112b6d24bc67d42508660e6b718b3db89c44e47e289137082
 
 hostmakedepends="pkg-config perl"
 makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
@@ -26,12 +26,13 @@ makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-deve
  $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
  $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
  $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
- $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers Vulkan-Tools Vulkan-ValidationLayers')
+ $(vopt_if onevpl 'onevpl onevpl-devel')
  $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
 depends="ffplay>=${version}_${revision}"
 
 build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
- dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec onevpl"
 build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
 desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
 desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
@@ -39,10 +40,8 @@ desc_option_sofa="Enable support for AES SOFA"
 desc_option_webp="Enable support for WebP"
 
 case "$XBPS_TARGET_MACHINE" in
-	i686*|x86_64*)
-		hostmakedepends+=" nasm"
-		build_options_default+=" vaapi vdpau nvenc nvdec"
-		;;
+	i686*) build_options_default+=" vaapi vdpau nvenc nvdec";;
+	x86_64*) build_options_default+=" vaapi vdpau nvenc nvdec onevpl";;
 	ppc64*) build_options_default+=" vaapi vdpau";;
 	mips*) CFLAGS="-mnan=legacy";;
 esac
@@ -117,18 +116,19 @@ do_configure() {
 		$(vopt_enable x265 libx265) \
 		$(vopt_enable v4l2 libv4l2) \
 		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
-		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		--enable-libbs2b --enable-libvidstab \
 		$(vopt_enable dav1d libdav1d) \
 		$(vopt_enable zimg libzimg) \
 		$(vopt_enable webp libwebp) \
 		$(vopt_enable sofa libmysofa) \
 		$(vopt_enable vulkan) \
+		$(vopt_enable onevpl libvpl) \
 		$(vopt_enable drm libdrm) \
 		$(vopt_enable svtav1 libsvtav1) \
 		$(vopt_enable srt libsrt) \
 		$(vopt_enable rist librist) \
-		$(vopt_if nvenc '--enable-nvenc') \
-		$(vopt_if nvdec '--enable-nvdec')
+		$(vopt_enable nvenc nvenc) \
+		$(vopt_enable nvdec nvdec)
 }
 
 do_build() {
@@ -155,10 +155,8 @@ libavdevice_package() {
 }
 
 libavresample_package() {
-	short_desc="FFmpeg audio resampling library"
-	pkg_install() {
-		vmove "usr/lib/libavresample.so.*"
-	}
+	short_desc="Package deprecated, removal needed"
+	build_style=meta
 }
 
 libavformat_package() {
@@ -212,15 +210,9 @@ ffmpeg-devel_package() {
 		libavfilter>=${version}_${revision}
 		libpostproc>=${version}_${revision}
 		libswscale>=${version}_${revision}
-		libswresample>=${version}_${revision}
-		libavresample>=${version}_${revision}"
+		libswresample>=${version}_${revision}"
 	short_desc+=" - development files"
-
-	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
-		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
-		nostrip_files="/usr/lib/libavfilter.a"
-	fi
-
+	conflicts="ffmpeg4-devel"
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig

From 16d419759bb8d3973544d460394a0b1f7246b816 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:56:22 -0400
Subject: [PATCH 002/116] New package: ffmpeg4-4.4.4.

---
 srcpkgs/ffmpeg4-devel                         |   1 +
 srcpkgs/ffmpeg4/files/altivec.patch           |  60 +++++
 .../patches/armv5tel-floating-point.patch     |  18 ++
 .../workaround-mesa-readeon-vaapi-bug.patch   |  28 +++
 srcpkgs/ffmpeg4/template                      | 238 ++++++++++++++++++
 srcpkgs/libavcodec4                           |   1 +
 srcpkgs/libavdevice4                          |   1 +
 srcpkgs/libavfilter4                          |   1 +
 srcpkgs/libavformat4                          |   1 +
 srcpkgs/libavresample4                        |   1 +
 srcpkgs/libavutil4                            |   1 +
 srcpkgs/libpostproc4                          |   1 +
 srcpkgs/libswresample4                        |   1 +
 srcpkgs/libswscale4                           |   1 +
 14 files changed, 354 insertions(+)
 create mode 120000 srcpkgs/ffmpeg4-devel
 create mode 100644 srcpkgs/ffmpeg4/files/altivec.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
 create mode 100644 srcpkgs/ffmpeg4/template
 create mode 120000 srcpkgs/libavcodec4
 create mode 120000 srcpkgs/libavdevice4
 create mode 120000 srcpkgs/libavfilter4
 create mode 120000 srcpkgs/libavformat4
 create mode 120000 srcpkgs/libavresample4
 create mode 120000 srcpkgs/libavutil4
 create mode 120000 srcpkgs/libpostproc4
 create mode 120000 srcpkgs/libswresample4
 create mode 120000 srcpkgs/libswscale4

diff --git a/srcpkgs/ffmpeg4-devel b/srcpkgs/ffmpeg4-devel
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/ffmpeg4-devel
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/ffmpeg4/files/altivec.patch b/srcpkgs/ffmpeg4/files/altivec.patch
new file mode 100644
index 000000000000..9c5720046332
--- /dev/null
+++ b/srcpkgs/ffmpeg4/files/altivec.patch
@@ -0,0 +1,60 @@
+revert some altivec specific change on all ppc* except ppc64le*
+
+q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
+conditionally, for ppc* but not ppc64le* (the new code is valid for
+POWER8 VSX which LE targets as a baseline but not BE)"
+
+
+This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
+---
+ libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
+ 1 file changed, 20 insertions(+), 4 deletions(-)
+
+diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
+index 536545293d..c1e2852adb 100644
+--- a/libswscale/ppc/yuv2rgb_altivec.c
++++ b/libswscale/ppc/yuv2rgb_altivec.c
+@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+     vector signed short R1, G1, B1;                                           \
+     vector unsigned char R, G, B;                                             \
+                                                                               \
++    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
++    vector unsigned char align_perm;                                          \
++                                                                              \
+     vector signed short lCY       = c->CY;                                    \
+     vector signed short lOY       = c->OY;                                    \
+     vector signed short lCRV      = c->CRV;                                   \
+@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
+                                                                               \
+         for (j = 0; j < w / 16; j++) {                                        \
+-            y0 = vec_xl(0, y1i);                                              \
++            y1ivP = (const vector unsigned char *) y1i;                       \
++            y2ivP = (const vector unsigned char *) y2i;                       \
++            uivP  = (const vector unsigned char *) ui;                        \
++            vivP  = (const vector unsigned char *) vi;                        \
++                                                                              \
++            align_perm = vec_lvsl(0, y1i);                                    \
++            y0 = (vector unsigned char)                                       \
++                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
+                                                                               \
+-            y1 = vec_xl(0, y2i);                                              \
++            align_perm = vec_lvsl(0, y2i);                                    \
++            y1 = (vector unsigned char)                                       \
++                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
+                                                                               \
+-            u = (vector signed char) vec_xl(0, ui);                           \
++            align_perm = vec_lvsl(0, ui);                                     \
++            u = (vector signed char)                                          \
++                    vec_perm(uivP[0], uivP[1], align_perm);                   \
+                                                                               \
+-            v = (vector signed char) vec_xl(0, vi);                           \
++            align_perm = vec_lvsl(0, vi);                                     \
++            v = (vector signed char)                                          \
++                    vec_perm(vivP[0], vivP[1], align_perm);                   \
+                                                                               \
+             u = (vector signed char)                                          \
+                     vec_sub(u,                                                \
+-- 
+2.27.0
+
diff --git a/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
new file mode 100644
index 000000000000..9a55178c74f0
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
@@ -0,0 +1,18 @@
+--- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
++++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
+@@ -39,6 +39,15 @@
+ #endif
+ #include <fenv.h>
+ 
++#if (FE_ALL_EXCEPT == 0)
++/* E.g. ARM soft float does not define these */
++#define FE_INVALID    0
++#define FE_DIVBYZERO  0
++#define FE_OVERFLOW   0
++#define FE_UNDERFLOW  0
++#define FE_INEXACT    0
++#endif
++
+ #if CONFIG_LIBFONTCONFIG
+ #include <fontconfig/fontconfig.h>
+ #endif
diff --git a/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
new file mode 100644
index 000000000000..00e3f68a415b
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
@@ -0,0 +1,28 @@
+From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
+From: Rainer Hochecker <fernetmenta@online.de>
+Date: Sat, 26 Jan 2019 19:48:35 +0100
+Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
+
+This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
+It was hit frequently when watching h264 channels received via DVB-X.
+Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
+---
+ libavcodec/vaapi_h264.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
+index 5854587a255..f12fdc457a4 100644
+--- a/libavcodec/vaapi_h264.c
++++ b/libavcodec/vaapi_h264.c
+@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
+     H264SliceContext *sl = &h->slice_ctx[0];
+     int ret;
+ 
++    if (pic->nb_slices == 0) {
++        ret = AVERROR_INVALIDDATA;
++        goto finish;
++    }
++
+     ret = ff_vaapi_decode_issue(avctx, pic);
+     if (ret < 0)
+         goto finish;
diff --git a/srcpkgs/ffmpeg4/template b/srcpkgs/ffmpeg4/template
new file mode 100644
index 000000000000..5228c7df08fb
--- /dev/null
+++ b/srcpkgs/ffmpeg4/template
@@ -0,0 +1,238 @@
+# Template file for 'ffmpeg4'
+# audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
+pkgname=ffmpeg4
+version=4.4.4
+revision=1
+short_desc="Decoding, encoding and streaming software - ffmpeg4 libraries only"
+maintainer="Orphaned <orphan@voidlinux.org>"
+license="GPL-3.0-or-later"
+homepage="https://www.ffmpeg.org"
+changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
+distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
+checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+
+hostmakedepends="pkg-config perl"
+makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
+ libXext-devel libXvMC-devel libxcb-devel lame-devel libtheora-devel
+ libvorbis-devel x264-devel xvidcore-devel jack-devel SDL2-devel
+ libcdio-paranoia-devel librtmp-devel libmodplug-devel gnutls-devel
+ speex-devel celt-devel harfbuzz-devel libass-devel opus-devel ocl-icd-devel
+ libbs2b-devel libvidstab-devel $(vopt_if pulseaudio pulseaudio-devel)
+ $(vopt_if vaapi libva-devel) $(vopt_if vdpau libvdpau-devel)
+ $(vopt_if x265 x265-devel) $(vopt_if v4l2 v4l-utils-devel)
+ $(vopt_if fdk_aac fdk-aac-devel) $(vopt_if vpx libvpx-devel)
+ $(vopt_if aom libaom-devel) $(vopt_if sndio sndio-devel)
+ $(vopt_if dav1d libdav1d-devel) $(vopt_if zimg zimg-devel)
+ $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
+ $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
+ $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if mfx 'libmfx libmfx-devel')
+ $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
+
+build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec mfx"
+build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
+
+desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
+desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
+desc_option_sofa="Enable support for AES SOFA"
+desc_option_webp="Enable support for WebP"
+
+case "$XBPS_TARGET_MACHINE" in
+	i686*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau nvenc nvdec"
+			;;
+	x86_64*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau mfx nvenc nvdec"
+			;;
+	ppc64*) build_options_default+=" vaapi vdpau";;
+	mips*) CFLAGS="-mnan=legacy";;
+esac
+
+if [ "$XBPS_TARGET_WORDSIZE" != "32" ]; then
+	build_options_default+=" svtav1"
+fi
+
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+fi
+
+_apply_patch() {
+	local args="$1" pname="$(basename $2)"
+
+	if [ ! -f ".${pname}_done" ]; then
+		patch -N $args -i $2
+		touch .${pname}_done
+	fi
+}
+
+post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64le*) ;;
+		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
+	esac
+}
+
+do_configure() {
+	# Fix gcc on x86_64-musl only
+	if [ "$XBPS_TARGET_MACHINE" = "x86_64-musl" ]; then
+		vsed -i configure -e "s;_cflags_speed='-O3';_cflags_speed='-O2';"
+	fi
+
+	if [ "$CROSS_BUILD" ]; then
+		case "$XBPS_TARGET_MACHINE" in
+			arm*) _arch="arm";;
+			aarch64*) _arch="aarch64";;
+			mips*) _arch="mips";;
+			ppc64*) _arch="ppc64";;
+			ppc*) _arch="ppc";;
+			*) _arch="${XBPS_TARGET_MACHINE%%-musl}";;
+		esac
+
+		_args+=" --enable-cross-compile
+			--sysroot=$XBPS_CROSS_BASE
+			--cross-prefix=${XBPS_CROSS_TRIPLET}-
+			--target-os=linux --arch=${_arch}"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc|ppc-musl) _args+=" --disable-altivec";;
+	esac
+
+	if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+		_args+=" --extra-libs=-latomic"
+	fi
+
+	./configure --prefix=/usr --disable-debug --enable-gpl --enable-gnutls \
+		--disable-stripping \
+		--enable-libcdio --enable-version3 --enable-runtime-cpudetect \
+		--enable-libmp3lame --enable-libvorbis --enable-libxvid \
+		--enable-libx264 $(vopt_enable vpx libvpx) --enable-libtheora \
+		--enable-shared --enable-static --enable-libxcb \
+		$(vopt_enable pulseaudio libpulse) --enable-libfreetype --enable-libmodplug \
+		--enable-libspeex --enable-libcelt --enable-libass \
+		--enable-libopus --enable-librtmp --enable-libjack \
+		$(vopt_if fdk_aac '--enable-nonfree --enable-libfdk-aac') \
+		--disable-libopencore_amrnb --disable-libopencore_amrwb \
+		--disable-libopenjpeg \
+		--enable-postproc --enable-opencl ${_args} \
+		$(vopt_enable x265 libx265) \
+		$(vopt_enable v4l2 libv4l2) \
+		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
+		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		$(vopt_enable dav1d libdav1d) \
+		$(vopt_enable zimg libzimg) \
+		$(vopt_enable webp libwebp) \
+		$(vopt_enable sofa libmysofa) \
+		$(vopt_enable vulkan) \
+		$(vopt_enable drm libdrm) \
+		$(vopt_enable svtav1 libsvtav1) \
+		$(vopt_enable srt libsrt) \
+		$(vopt_enable rist librist) \
+		$(vopt_enable mfx libmfx) \
+		$(vopt_if nvenc '--enable-nvenc') \
+		$(vopt_if nvdec '--enable-nvdec')
+}
+
+do_build() {
+	make ${makejobs}
+	make doc/ff{mpeg,play}.1
+}
+
+do_install() {
+	make DESTDIR=${DESTDIR} install install-man
+	rm -rf ${DESTDIR}/usr/bin
+}
+
+libavcodec4_package() {
+	short_desc="FFmpeg codec library"
+	pkg_install() {
+		vmove "usr/lib/libavcodec.so.*"
+	}
+}
+
+libavdevice4_package() {
+	short_desc="FFmpeg device handling library"
+	pkg_install() {
+		vmove "usr/lib/libavdevice.so.*"
+	}
+}
+
+libavresample4_package() {
+	short_desc="FFmpeg audio resampling library"
+	pkg_install() {
+		vmove "usr/lib/libavresample.so.*"
+	}
+}
+
+libavformat4_package() {
+	short_desc="FFmpeg file format library"
+	pkg_install() {
+		vmove "usr/lib/libavformat.so.*"
+	}
+}
+
+libavutil4_package() {
+	short_desc="FFmpeg utility library"
+	pkg_install() {
+		vmove "usr/lib/libavutil.so.*"
+	}
+}
+
+libavfilter4_package() {
+	short_desc="FFmpeg audio/video filter library"
+	pkg_install() {
+		vmove "usr/lib/libavfilter.so.*"
+	}
+}
+
+libpostproc4_package() {
+	short_desc="FFmpeg video postprocessing library"
+	pkg_install() {
+		vmove "usr/lib/libpostproc.so.*"
+	}
+}
+
+libswscale4_package() {
+	short_desc="FFmpeg video scaling library"
+	pkg_install() {
+		vmove "usr/lib/libswscale.so.*"
+	}
+}
+
+libswresample4_package() {
+	short_desc="FFmpeg video resampling library"
+	pkg_install() {
+		vmove "usr/lib/libswresample.so.*"
+	}
+}
+
+ffmpeg4-devel_package() {
+	depends="
+		libavcodec4>=${version}_${revision}
+		libavdevice4>=${version}_${revision}
+		libavformat4>=${version}_${revision}
+		libavutil4>=${version}_${revision}
+		libavfilter4>=${version}_${revision}
+		libpostproc4>=${version}_${revision}
+		libswscale4>=${version}_${revision}
+		libswresample4>=${version}_${revision}
+		libavresample4>=${version}_${revision}"
+	short_desc+=" - development files"
+	conflicts="ffmpeg-devel"
+	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
+		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
+		nostrip_files="/usr/lib/libavfilter.a"
+	fi
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.a"
+		vmove "usr/lib/*.so"
+		vmove usr/share/ffmpeg/examples
+		vmove usr/share/man/man3
+	}
+}
diff --git a/srcpkgs/libavcodec4 b/srcpkgs/libavcodec4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavcodec4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavdevice4 b/srcpkgs/libavdevice4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavdevice4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavfilter4 b/srcpkgs/libavfilter4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavfilter4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavformat4 b/srcpkgs/libavformat4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavformat4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavresample4 b/srcpkgs/libavresample4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavutil4 b/srcpkgs/libavutil4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavutil4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libpostproc4 b/srcpkgs/libpostproc4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libpostproc4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswresample4 b/srcpkgs/libswresample4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libswresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswscale4 b/srcpkgs/libswscale4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libswscale4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file

From c6cb02810ef41dcab2642f78032148528531ad5b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:04 -0400
Subject: [PATCH 003/116] opencv: update to 4.7.0.

---
 common/shlibs           | 104 ++++++++++++++++++++--------------------
 srcpkgs/opencv/template |   8 ++--
 2 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index 892e119802cb..ce0c518f00ef 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2134,58 +2134,58 @@ libcapstone.so.4 capstone-4.0_1
 libhavege.so.2 libhaveged-1.9.11_1
 libnih.so.1 libnih-1.0.3_1
 libnih-dbus.so.1 libnih-1.0.3_1
-libopencv_quality.so.406 libopencv-4.6.0_1
-libopencv_reg.so.406 libopencv-4.6.0_1
-libopencv_surface_matching.so.406 libopencv-4.6.0_1
-libopencv_xphoto.so.406 libopencv-4.6.0_1
-libopencv_freetype.so.406 libopencv-4.6.0_1
-libopencv_fuzzy.so.406 libopencv-4.6.0_1
-libopencv_hfs.so.406 libopencv-4.6.0_1
-libopencv_img_hash.so.406 libopencv-4.6.0_1
-libopencv_line_descriptor.so.406 libopencv-4.6.0_1
-libopencv_saliency.so.406 libopencv-4.6.0_1
-libopencv_structured_light.so.406 libopencv-4.6.0_1
-libopencv_aruco.so.406 libopencv-4.6.0_1
-libopencv_bgsegm.so.406 libopencv-4.6.0_1
-libopencv_bioinspired.so.406 libopencv-4.6.0_1
-libopencv_ccalib.so.406 libopencv-4.6.0_1
-libopencv_face.so.406 libopencv-4.6.0_1
-libopencv_tracking.so.406 libopencv-4.6.0_1
-libopencv_xfeatures2d.so.406 libopencv-4.6.0_1
-libopencv_optflow.so.406 libopencv-4.6.0_1
-libopencv_ximgproc.so.406 libopencv-4.6.0_1
-libopencv_plot.so.406 libopencv-4.6.0_1
-libopencv_text.so.406 libopencv-4.6.0_1
-libopencv_ml.so.406 libopencv-4.6.0_1
-libopencv_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn.so.406 libopencv-4.6.0_1
-libopencv_shape.so.406 libopencv-4.6.0_1
-libopencv_stitching.so.406 libopencv-4.6.0_1
-libopencv_photo.so.406 libopencv-4.6.0_1
-libopencv_video.so.406 libopencv-4.6.0_1
-libopencv_calib3d.so.406 libopencv-4.6.0_1
-libopencv_features2d.so.406 libopencv-4.6.0_1
-libopencv_flann.so.406 libopencv-4.6.0_1
-libopencv_highgui.so.406 libopencv-4.6.0_1
-libopencv_videoio.so.406 libopencv-4.6.0_1
-libopencv_imgcodecs.so.406 libopencv-4.6.0_1
-libopencv_imgproc.so.406 libopencv-4.6.0_1
-libopencv_core.so.406 libopencv-4.6.0_1
-libopencv_superres.so.406 libopencv-4.6.0_1
-libopencv_videostab.so.406 libopencv-4.6.0_1
-libopencv_gapi.so.406 libopencv-4.6.0_1
-libopencv_xobjdetect.so.406 libopencv-4.6.0_1
-libopencv_datasets.so.406 libopencv-4.6.0_1
-libopencv_dnn_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn_superres.so.406 libopencv-4.6.0_1
-libopencv_dpm.so.406 libopencv-4.6.0_1
-libopencv_phase_unwrapping.so.406 libopencv-4.6.0_1
-libopencv_stereo.so.406 libopencv-4.6.0_1
-libopencv_rapid.so.406 libopencv-4.6.0_1
-libopencv_intensity_transform.so.406 libopencv-4.6.0_1
-libopencv_alphamat.so.406 libopencv-4.6.0_1
-libopencv_barcode.so.406 libopencv-4.6.0_1
-libopencv_mcc.so.406 libopencv-4.6.0_1
+libopencv_quality.so.407 libopencv-4.7.0_1
+libopencv_reg.so.407 libopencv-4.7.0_1
+libopencv_surface_matching.so.407 libopencv-4.7.0_1
+libopencv_xphoto.so.407 libopencv-4.7.0_1
+libopencv_freetype.so.407 libopencv-4.7.0_1
+libopencv_fuzzy.so.407 libopencv-4.7.0_1
+libopencv_hfs.so.407 libopencv-4.7.0_1
+libopencv_img_hash.so.407 libopencv-4.7.0_1
+libopencv_line_descriptor.so.407 libopencv-4.7.0_1
+libopencv_saliency.so.407 libopencv-4.7.0_1
+libopencv_structured_light.so.407 libopencv-4.7.0_1
+libopencv_aruco.so.407 libopencv-4.7.0_1
+libopencv_bgsegm.so.407 libopencv-4.7.0_1
+libopencv_bioinspired.so.407 libopencv-4.7.0_1
+libopencv_ccalib.so.407 libopencv-4.7.0_1
+libopencv_face.so.407 libopencv-4.7.0_1
+libopencv_tracking.so.407 libopencv-4.7.0_1
+libopencv_xfeatures2d.so.407 libopencv-4.7.0_1
+libopencv_optflow.so.407 libopencv-4.7.0_1
+libopencv_ximgproc.so.407 libopencv-4.7.0_1
+libopencv_plot.so.407 libopencv-4.7.0_1
+libopencv_text.so.407 libopencv-4.7.0_1
+libopencv_ml.so.407 libopencv-4.7.0_1
+libopencv_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn.so.407 libopencv-4.7.0_1
+libopencv_shape.so.407 libopencv-4.7.0_1
+libopencv_stitching.so.407 libopencv-4.7.0_1
+libopencv_photo.so.407 libopencv-4.7.0_1
+libopencv_video.so.407 libopencv-4.7.0_1
+libopencv_calib3d.so.407 libopencv-4.7.0_1
+libopencv_features2d.so.407 libopencv-4.7.0_1
+libopencv_flann.so.407 libopencv-4.7.0_1
+libopencv_highgui.so.407 libopencv-4.7.0_1
+libopencv_videoio.so.407 libopencv-4.7.0_1
+libopencv_imgcodecs.so.407 libopencv-4.7.0_1
+libopencv_imgproc.so.407 libopencv-4.7.0_1
+libopencv_core.so.407 libopencv-4.7.0_1
+libopencv_superres.so.407 libopencv-4.7.0_1
+libopencv_videostab.so.407 libopencv-4.7.0_1
+libopencv_gapi.so.407 libopencv-4.7.0_1
+libopencv_xobjdetect.so.407 libopencv-4.7.0_1
+libopencv_datasets.so.407 libopencv-4.7.0_1
+libopencv_dnn_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn_superres.so.407 libopencv-4.7.0_1
+libopencv_dpm.so.407 libopencv-4.7.0_1
+libopencv_phase_unwrapping.so.407 libopencv-4.7.0_1
+libopencv_stereo.so.407 libopencv-4.7.0_1
+libopencv_rapid.so.407 libopencv-4.7.0_1
+libopencv_intensity_transform.so.407 libopencv-4.7.0_1
+libopencv_alphamat.so.407 libopencv-4.7.0_1
+libopencv_barcode.so.407 libopencv-4.7.0_1
+libopencv_mcc.so.407 libopencv-4.7.0_1
 libuniconf.so.4.6 wvstreams-4.6.1_20
 libwvbase.so.4.6 wvstreams-4.6.1_20
 libwvutils.so.4.6 wvstreams-4.6.1_20
diff --git a/srcpkgs/opencv/template b/srcpkgs/opencv/template
index 69c635b1ad2b..41f3183f1582 100644
--- a/srcpkgs/opencv/template
+++ b/srcpkgs/opencv/template
@@ -1,7 +1,7 @@
 # Template file for 'opencv'
 pkgname=opencv
-version=4.6.0
-revision=4
+version=4.7.0
+revision=1
 create_wrksrc=yes
 build_wrksrc=${pkgname}-${version}
 build_style=cmake
@@ -24,8 +24,8 @@ homepage="https://opencv.org"
 changelog="https://github.com/opencv/opencv/wiki/ChangeLog"
 distfiles="https://github.com/opencv/opencv/archive/${version}.tar.gz
  https://github.com/opencv/opencv_contrib/archive/${version}.tar.gz>contrib.tar.gz"
-checksum="1ec1cba65f9f20fe5a41fda1586e01c70ea0c9a6d7b67c9e13edf0cfe2239277
- 1777d5fd2b59029cf537e5fd6f8aa68d707075822f90bde683fcde086f85f7a7"
+checksum="8df0079cdbe179748a18d44731af62a245a45ebf5085223dc03133954c662973
+ 42df840cf9055e59d0e22c249cfb19f04743e1bdad113d31b1573d3934d62584"
 patch_args="-Np1 -d ${build_wrksrc}"
 # tests hang indenfinitely, even with test data included
 make_check=no

From bb1f2cff9f20a3171df98ae133b8fb6bc1651594 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 004/116] actiona: revbump for opencv-4.7.0

---
 srcpkgs/actiona/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/actiona/template b/srcpkgs/actiona/template
index cf5f0b7a2ae6..0d899311e6df 100644
--- a/srcpkgs/actiona/template
+++ b/srcpkgs/actiona/template
@@ -1,7 +1,7 @@
 # Template file for 'actiona'
 pkgname=actiona
 version=3.10.1
-revision=2
+revision=3
 build_style=qmake
 configure_args="PKGCONFIG_OPENCV=opencv4"
 hostmakedepends="pkg-config qt5-plugin-mysql qt5-qmake qt5-host-tools"

From 5dad514f850ed4f8d80fe382bc80d67cfde609b8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 005/116] gmic: revbump for opencv-4.7.0

---
 srcpkgs/gmic/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gmic/template b/srcpkgs/gmic/template
index 24a9c7218fdf..0bb4034d5cc8 100644
--- a/srcpkgs/gmic/template
+++ b/srcpkgs/gmic/template
@@ -1,7 +1,7 @@
 # Template file for 'gmic'
 pkgname=gmic
 version=3.1.6
-revision=3
+revision=4
 _zart_hash=34ebf6cce0bafb98abe57cec83c4a02cd1abeca0
 create_wrksrc=yes
 build_wrksrc="src"

From 13538d1d05a8c90004d67a86d7581b9203e321c2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 006/116] qimgv: revbump for opencv-4.7.0

---
 srcpkgs/qimgv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qimgv/template b/srcpkgs/qimgv/template
index 7eb30db33992..dd341dfe1bfc 100644
--- a/srcpkgs/qimgv/template
+++ b/srcpkgs/qimgv/template
@@ -1,7 +1,7 @@
 # Template file for 'qimgv'
 pkgname=qimgv
 version=1.0.2
-revision=2
+revision=3
 build_style=cmake
 configure_args="$(vopt_if video -DVIDEO_SUPPORT=ON -DVIDEO_SUPPORT=OFF)
  $(vopt_if scale -DOPENCV_SUPPORT=ON -DOPENCV_SUPPORT=OFF)

From 4724f17a08d978a1e94cb1257b8b24b1890f30e6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 007/116] retroshare: revbump for opencv-4.7.0

---
 srcpkgs/retroshare/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroshare/template b/srcpkgs/retroshare/template
index 8a0786c21a08..72023fa98b75 100644
--- a/srcpkgs/retroshare/template
+++ b/srcpkgs/retroshare/template
@@ -1,7 +1,7 @@
 # Template file for 'retroshare'
 pkgname=retroshare
 version=0.6.6
-revision=2
+revision=4
 build_style=qmake
 #XXX broadcast feature requires an ancient udp-discovery-cpp which either needs
 # to be fetched+patched (FTBFS) here or packaged :/

From d0f162a5caeb00630c9c02431c8651e19e25ca78 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 008/116] waifu2x-converter-cpp: revbump for opencv-4.7.0

---
 srcpkgs/waifu2x-converter-cpp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waifu2x-converter-cpp/template b/srcpkgs/waifu2x-converter-cpp/template
index 8c095d0d7bab..aa52d8c981a8 100644
--- a/srcpkgs/waifu2x-converter-cpp/template
+++ b/srcpkgs/waifu2x-converter-cpp/template
@@ -1,7 +1,7 @@
 # Template file for 'waifu2x-converter-cpp'
 pkgname=waifu2x-converter-cpp
 version=5.2.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DINSTALL_MODELS=ON"
 hostmakedepends="pkg-config"

From 8eadc4c48e633c5eb38899811146aa5656d962ff Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:38 -0400
Subject: [PATCH 009/116] vlc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/vlc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/vlc/template b/srcpkgs/vlc/template
index 210762b0a7e2..855ca5238662 100644
--- a/srcpkgs/vlc/template
+++ b/srcpkgs/vlc/template
@@ -1,7 +1,7 @@
 # Template file for 'vlc'
 pkgname=vlc
 version=3.0.18
-revision=3
+revision=4
 build_style=gnu-configure
 configure_args="--disable-gme --disable-libtar --enable-jack
  --enable-live555 --disable-fluidsynth --enable-dvdread
@@ -25,7 +25,7 @@ lib32disabled=yes
 hostmakedepends="automake libtool pkg-config flex gettext libgcrypt-devel
  live555-devel gettext-devel $(vopt_if lua lua52) $(vopt_if chromecast protobuf)"
 makedepends="
- avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg-devel freefont-ttf
+ avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg4-devel freefont-ttf
  gnutls-devel jack-devel liba52-devel libass-devel libbluray-devel
  libcdio-devel libdca-devel libdvbpsi-devel libdvdnav-devel libmad-devel
  libmatroska-devel libmodplug-devel libmpcdec-devel libmpeg2-devel

From 4194a7e435d0f3188f78358786b68a1bb6e8f718 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:55 -0400
Subject: [PATCH 010/116] osg: revbump for ffmpeg4-4.4.3

---
 srcpkgs/osg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/osg/template b/srcpkgs/osg/template
index a9ebbd287933..755793f7e11b 100644
--- a/srcpkgs/osg/template
+++ b/srcpkgs/osg/template
@@ -8,7 +8,7 @@ build_helper="qemu"
 configure_args="-DLIB_POSTFIX="
 hostmakedepends="pkg-config xrandr"
 makedepends="MesaLib-devel gtkglext-devel libcurl-devel giflib-devel librsvg-devel
- jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg-devel xine-lib-devel
+ jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg4-devel xine-lib-devel
  SDL2-devel gst-plugins-base1-devel
  $(vopt_if openexr libopenexr-devel)
  $(vopt_if poppler poppler-glib-devel)

From 69ebdebf2265a5e57fe275d7ed4c188f3a98a744 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:13 -0400
Subject: [PATCH 011/116] xine-lib: revbump for ffmpeg4-4.4.3

---
 srcpkgs/xine-lib/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/xine-lib/template b/srcpkgs/xine-lib/template
index f713eff49b07..ed6194c17d11 100644
--- a/srcpkgs/xine-lib/template
+++ b/srcpkgs/xine-lib/template
@@ -1,6 +1,6 @@
 # Template file for 'xine-lib'
 pkgname=xine-lib
-version=1.2.12
+version=1.2.13
 revision=1
 build_style=gnu-configure
 configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
@@ -8,7 +8,7 @@ configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
 hostmakedepends="automake gettext-devel libtool pkg-config perl"
 makedepends="
  zlib-devel alsa-lib-devel libxcb-devel libSM-devel libXext-devel libXv-devel
- libXvMC-devel liba52-devel libmad-devel ffmpeg-devel pulseaudio-devel
+ libXvMC-devel liba52-devel libmad-devel ffmpeg4-devel pulseaudio-devel
  jack-devel samba-devel libflac-devel libmodplug-devel libmpcdec-devel
  speex-devel libtheora-devel libvorbis-devel libdca-devel faad2-devel
  libcdio-devel libbluray-devel aalib-devel libcaca-devel libXinerama-devel
@@ -19,7 +19,7 @@ license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="http://www.xine-project.org"
 changelog="https://sourceforge.net/projects/xine/files/xine-lib/${version}/README.txt/view"
 distfiles="${SOURCEFORGE_SITE}/xine/${pkgname}-${version}.tar.xz"
-checksum=d606270468e1540c2a89c0d7f5fdf11e17ecc0c2698cc0bcb1065ff26abee098
+checksum=5f10d6d718a4a51c17ed1b32b031d4f9b80b061e8276535b2be31e5ac4b75e6f
 
 case "$XBPS_TARGET_MACHINE" in
 	i686-musl)

From 4896081e695e82dd385c554dafc7de5a1be77627 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 012/116] QMPlay2: revbump for ffmpeg-6.0

---
 srcpkgs/QMPlay2/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/QMPlay2/template b/srcpkgs/QMPlay2/template
index 17879a25093d..7c387a57b8bd 100644
--- a/srcpkgs/QMPlay2/template
+++ b/srcpkgs/QMPlay2/template
@@ -1,7 +1,7 @@
 # Template file for 'QMPlay2'
 pkgname=QMPlay2
 version=23.06.04
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools"
 makedepends="alsa-lib-devel ffmpeg-devel libass-devel libcdio-devel libgme-devel

From 52e216c303c775e5a7f8970404a6e57e64ce248f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 013/116] alsa-plugins: revbump for ffmpeg-6.0

---
 srcpkgs/alsa-plugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/alsa-plugins/template b/srcpkgs/alsa-plugins/template
index 0bfa6d9fd264..a5708a7d82a8 100644
--- a/srcpkgs/alsa-plugins/template
+++ b/srcpkgs/alsa-plugins/template
@@ -1,7 +1,7 @@
 # Template file for 'alsa-plugins'
 pkgname=alsa-plugins
 version=1.2.7.1
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--disable-maemo-plugin"
 hostmakedepends="pkg-config"

From 9595f6c97f7ac31a2d7ae53d402bfb38839938da Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 014/116] arcan: revbump for ffmpeg-6.0

---
 srcpkgs/arcan/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/arcan/template b/srcpkgs/arcan/template
index 7be9652eccf3..ccc7df11ceac 100644
--- a/srcpkgs/arcan/template
+++ b/srcpkgs/arcan/template
@@ -2,7 +2,7 @@
 # !! keep synced with: acfgfs aclip aloadimage
 pkgname=arcan
 version=0.6.2.1
-revision=1
+revision=2
 create_wrksrc=yes
 build_wrksrc=arcan/src
 build_style=cmake

From 6a04982b909c36732591e59b5eee2c49827333ad Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 015/116] attract: revbump for ffmpeg4-4.4.3

---
 srcpkgs/attract/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/attract/template b/srcpkgs/attract/template
index 26144e931a3c..e760bf0d18ae 100644
--- a/srcpkgs/attract/template
+++ b/srcpkgs/attract/template
@@ -1,12 +1,12 @@
 # Template file for 'attract'
 pkgname=attract
 version=2.6.2
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="VERBOSE=1"
 make_use_env=yes
 hostmakedepends="pkg-config"
-makedepends="SFML-devel ffmpeg-devel fontconfig-devel glu-devel libarchive-devel
+makedepends="SFML-devel ffmpeg4-devel fontconfig-devel glu-devel libarchive-devel
  libcurl-devel libjpeg-turbo-devel xine-lib rapidjson libXrandr-devel"
 depends="git"
 short_desc="Attract-Mode is a graphical frontend for emulators"

From 746c1163de93a1d3184aa71e8fba4b5ba2984ddc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 016/116] aubio: revbump for ffmpeg-6.0

---
 srcpkgs/aubio/patches/ffmpeg5.patch | 25 +++++++++++++++++++++++++
 srcpkgs/aubio/template              |  2 +-
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/aubio/patches/ffmpeg5.patch

diff --git a/srcpkgs/aubio/patches/ffmpeg5.patch b/srcpkgs/aubio/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..aace41a6e6d9
--- /dev/null
+++ b/srcpkgs/aubio/patches/ffmpeg5.patch
@@ -0,0 +1,25 @@
+From 8a05420e5dd8c7b8b2447f82dc919765876511b3 Mon Sep 17 00:00:00 2001
+From: Paul Brossier <piem@piem.org>
+Date: Tue, 25 Jan 2022 18:30:27 +0100
+Subject: [PATCH] [source_avcodec] define FF_API_LAVF_AVCTX for libavcodec >
+ 59, thx @berolinux (closes gh-353)
+
+---
+ src/io/source_avcodec.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/io/source_avcodec.c b/src/io/source_avcodec.c
+index e0ae93b5..1421bd9a 100644
+--- a/src/io/source_avcodec.c
++++ b/src/io/source_avcodec.c
+@@ -68,6 +68,10 @@
+ #define AUBIO_AVCODEC_MAX_BUFFER_SIZE AV_INPUT_BUFFER_MIN_SIZE
+ #endif
+ 
++#if LIBAVCODEC_VERSION_MAJOR >= 59
++#define FF_API_LAVF_AVCTX 1
++#endif
++
+ struct _aubio_source_avcodec_t {
+   uint_t hop_size;
+   uint_t samplerate;
diff --git a/srcpkgs/aubio/template b/srcpkgs/aubio/template
index ad1c4b256991..7d875cc02541 100644
--- a/srcpkgs/aubio/template
+++ b/srcpkgs/aubio/template
@@ -1,7 +1,7 @@
 # Template file for 'aubio'
 pkgname=aubio
 version=0.4.9
-revision=1
+revision=2
 build_style=waf3
 # XXX lash, pure and swig support.
 hostmakedepends="pkg-config txt2man"

From aa56e0691464a5665e49ec65d14c346578528866 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 017/116] audacious-plugins: revbump for ffmpeg-6.0

---
 .../audacious-plugins/patches/ffmpeg5.patch   | 43 +++++++++++++++++++
 srcpkgs/audacious-plugins/template            |  2 +-
 2 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/audacious-plugins/patches/ffmpeg5.patch

diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg5.patch b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..4e5e34099d71
--- /dev/null
+++ b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
@@ -0,0 +1,43 @@
+commit 298aa371c56c2f52c25a33d9bdec4918b11cebdc
+Author: tibequadorian <tibequadorian@posteo.de>
+Date:   Sat Mar 19 18:40:12 2022 +0100
+
+    audacious-plugins: rebuild against ffmpeg-5.0
+
+diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+new file mode 100644
+index 0000000000..617c11215b
+--- /dev/null
++++ b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+@@ -0,0 +1,31 @@
++From f60beb400eeb1e4778bbfd738bc4a4ccef3de539 Mon Sep 17 00:00:00 2001
++From: John Lindgren <john@jlindgren.net>
++Date: Sat, 5 Mar 2022 12:05:34 -0500
++Subject: [PATCH] Fix build with FFmpeg 5.0
++
++---
++ src/ffaudio/ffaudio-core.cc | 4 ++--
++ 1 file changed, 2 insertions(+), 2 deletions(-)
++
++diff --git a/src/ffaudio/ffaudio-core.cc b/src/ffaudio/ffaudio-core.cc
++index 16dc63e3a..a2b95fd6c 100644
++--- a/src/ffaudio/ffaudio-core.cc
+++++ b/src/ffaudio/ffaudio-core.cc
++@@ -274,7 +274,7 @@ static AVInputFormat * get_format_by_content (const char * name, VFSFile & file)
++         AVProbeData d = {name, buf, filled};
++         score = target;
++ 
++-        f = av_probe_input_format2 (& d, true, & score);
+++        f = (AVInputFormat *) av_probe_input_format2 (& d, true, & score);
++         if (f)
++             break;
++ 
++@@ -347,7 +347,7 @@ static bool find_codec (AVFormatContext * c, CodecInfo * cinfo)
++ #endif
++         if (stream && stream->codecpar && stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
++         {
++-            AVCodec * codec = avcodec_find_decoder (stream->codecpar->codec_id);
+++            AVCodec * codec = (AVCodec *) avcodec_find_decoder (stream->codecpar->codec_id);
++ 
++             if (codec)
++             {
diff --git a/srcpkgs/audacious-plugins/template b/srcpkgs/audacious-plugins/template
index 88cbc1671fc6..beebfae59ed4 100644
--- a/srcpkgs/audacious-plugins/template
+++ b/srcpkgs/audacious-plugins/template
@@ -2,7 +2,7 @@
 #Keep in sync with audacious!
 pkgname=audacious-plugins
 version=4.3.1
-revision=1
+revision=2
 build_style=meson
 configure_args="$(vopt_bool gtk3 gtk) $(vopt_bool gtk3)
  $(vopt_bool qt) $(vopt_bool qt qt6)"

From e65ad07bc075175974c79f6efb9140c4209cd3f9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 018/116] audacity: revbump for ffmpeg4-4.4.3

---
 srcpkgs/audacity/template | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/audacity/template b/srcpkgs/audacity/template
index d509c0a89407..11e20255685b 100644
--- a/srcpkgs/audacity/template
+++ b/srcpkgs/audacity/template
@@ -1,7 +1,7 @@
 # Template file for 'audacity'
 pkgname=audacity
 version=2.4.1
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--with-ffmpeg=system --with-libsndfile=system --with-expat=system
  --with-libsoxr=system --with-lame=system --with-lv2=system ac_cv_path_WX_CONFIG=wx-config-gtk3"
@@ -9,7 +9,7 @@ hostmakedepends="pkg-config cmake gettext libtool m4 which"
 makedepends="jack-devel wxWidgets-gtk3-devel gtk+3-devel
  libmad-devel soundtouch-devel libsoxr-devel
  vamp-plugin-sdk-devel lame-devel libid3tag-devel libflac-devel
- ffmpeg-devel twolame-devel serd-devel lv2 lilv-devel suil-devel"
+ ffmpeg4-devel twolame-devel serd-devel lv2 lilv-devel suil-devel"
 depends="desktop-file-utils hicolor-icon-theme"
 short_desc="Graphical cross-platform audio editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
@@ -33,5 +33,4 @@ post_install() {
 	vcopy plug-ins /usr/share/audacity
 
 	rm ${DESTDIR}/usr/share/doc/audacity/LICENSE.txt
-	vlicense LICENSE.txt LICENSE
 }

From b50d2dd063e7314136fc776f85cd65ac11171c32 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 019/116] avidemux: revbump for ffmpeg-6.0

---
 srcpkgs/avidemux/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/avidemux/template b/srcpkgs/avidemux/template
index 253a0243e225..557285982d2b 100644
--- a/srcpkgs/avidemux/template
+++ b/srcpkgs/avidemux/template
@@ -1,7 +1,7 @@
 # Template file for 'avidemux'
 pkgname=avidemux
 version=2.8.0
-revision=2
+revision=3
 # Can't be compiled for aarch64, arm* or mips*
 archs="x86_64* i686*"
 hostmakedepends="cmake pkg-config qt5-host-tools qt5-devel tar yasm"

From c87f46b4eb26708fee8d3000d30effff1b734e5b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 020/116] baresip: revbump for ffmpeg-6.0

---
 srcpkgs/baresip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/baresip/template b/srcpkgs/baresip/template
index f1bd1817048b..b21e22334316 100644
--- a/srcpkgs/baresip/template
+++ b/srcpkgs/baresip/template
@@ -1,7 +1,7 @@
 # Template file for 'baresip'
 pkgname=baresip
 version=2.10.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config glib-devel"
 makedepends="libgsm-devel libpng-devel openssl-devel libsndfile-devel

From cd73b78ad79cc8ba1efe107fc0056fd3ff3e1d43 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 021/116] blender: revbump for ffmpeg-6.0

---
 srcpkgs/blender/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index ec724bb0a6dc..0f72876d4d70 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -1,7 +1,7 @@
 # Template file for 'blender'
 pkgname=blender
 version=3.5.1
-revision=1
+revision=2
 archs="x86_64* ppc64*"
 build_style="cmake"
 pycompile_dirs="/usr/share/blender/${version%.*}/scripts"
@@ -9,8 +9,8 @@ configure_args="-DWITH_INSTALL_PORTABLE=OFF -DWITH_PYTHON_INSTALL=OFF
  -DWITH_JACK=ON -DWITH_CODEC_FFMPEG=ON -DWITH_CODEC_SNDFILE=ON -DWITH_OPENMP=ON
  -DWITH_FFTW3=ON -DWITH_MOD_OCEANSIM=ON -DWITH_CYCLES_EMBREE=OFF -DWITH_OPENCOLORIO=ON
  -DWITH_IMAGE_OPENEXR=ON -DWITH_IMAGE_OPENJPEG=ON -DWITH_OPENSUBDIV=ON
- -DWITH_OPENCOLLADA=ON -DWITH_SYSTEM_GLEW=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
- -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_LIBDECOR=ON
+ -DWITH_OPENCOLLADA=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
+ -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_WAYLAND_LIBDECOR=ON
  -DWITH_BUILDINFO=OFF -DPYTHON_VERSION=${py3_ver} -DPYTHON_LIBPATH=/usr/lib
  -DPYTHON_LIBRARY=python${py3_ver}${py3_abiver} -DPYTHON_INCLUDE_DIRS=/${py3_inc}
  -DWITH_SYSTEM_LZO=ON -DWITH_SYSTEM_EIGEN3=ON -DWITH_SYSTEM_FREETYPE=ON"

From 7be47d44fdc110fe6981d9902aa513453fb0982a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 022/116] cantata: revbump for ffmpeg-6.0

---
 srcpkgs/cantata/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cantata/template b/srcpkgs/cantata/template
index 4b417d80d5c2..8a90aaa4c07a 100644
--- a/srcpkgs/cantata/template
+++ b/srcpkgs/cantata/template
@@ -1,7 +1,7 @@
 # Template file for 'cantata'
 pkgname=cantata
 version=2.5.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools qt5-tools"
 makedepends="qt5-devel qt5-tools-devel qt5-svg-devel qt5-xmlpatterns-devel

From aa954092e5986923a2fc623f00562ea78d5a0b23 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 023/116] ccextractor: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ccextractor/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/ccextractor/template b/srcpkgs/ccextractor/template
index 9abcd82852b2..6eccad5885af 100644
--- a/srcpkgs/ccextractor/template
+++ b/srcpkgs/ccextractor/template
@@ -1,12 +1,12 @@
 # Template file for 'ccextractor'
 pkgname=ccextractor
 version=0.93
-revision=1
+revision=2
 build_wrksrc="linux"
 build_style=gnu-configure
 configure_args="--enable-ocr --enable-hardsubx"
 hostmakedepends="automake pkg-config"
-makedepends="leptonica-devel tesseract-ocr-devel ffmpeg-devel"
+makedepends="leptonica-devel tesseract-ocr-devel ffmpeg4-devel"
 short_desc="Extract subtitles from video streams"
 maintainer="newbluemoon <blaumolch@mailbox.org>"
 license="GPL-2.0-or-later"

From 962d52f3a3fb40f84bbd5d87ea12c02ab2b44a6c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 024/116] chromaprint: revbump for ffmpeg-6.0

---
 srcpkgs/chromaprint/patches/ffmpeg5.patch | 569 ++++++++++++++++++++++
 srcpkgs/chromaprint/template              |   2 +-
 2 files changed, 570 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromaprint/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromaprint/patches/ffmpeg5.patch b/srcpkgs/chromaprint/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..a9fd307a23c8
--- /dev/null
+++ b/srcpkgs/chromaprint/patches/ffmpeg5.patch
@@ -0,0 +1,569 @@
+From 8ccad6937177b1b92e40ab8f4447ea27bac009a7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= <lalinsky@gmail.com>
+Date: Fri, 4 Nov 2022 21:47:38 +0100
+Subject: [PATCH] Use FFmpeg 5.x (#120)
+
+* Use FFmpeg 5.1.2 for CI builds
+
+* Build on Ubuntu 20.04
+
+* Upgrade code to FFmpeg 5.x APIs
+
+* Only set FFmpeg include dirs if building tools
+
+* No longer needed
+
+* Use ubuntu 20.04
+---
+ .github/workflows/build.yml                   |   6 +-
+ CMakeLists.txt                                |  16 --
+ package/build.sh                              |   4 +-
+ src/audio/ffmpeg_audio_processor.h            |   2 -
+ src/audio/ffmpeg_audio_processor_avresample.h |  72 -------
+ src/audio/ffmpeg_audio_processor_swresample.h |  18 +-
+ src/audio/ffmpeg_audio_reader.h               | 197 +++++++++---------
+ tests/CMakeLists.txt                          |   6 +
+ 8 files changed, 122 insertions(+), 199 deletions(-)
+ delete mode 100644 src/audio/ffmpeg_audio_processor_avresample.h
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index f8d6a32..4da2405 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -84,9 +84,6 @@ find_package(FFmpeg)
+ if(FFMPEG_LIBRARIES)
+ 	cmake_push_check_state(RESET)
+ 	set(CMAKE_REQUIRED_LIBRARIES ${FFMPEG_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -lm)
+-	check_function_exists(av_packet_unref HAVE_AV_PACKET_UNREF)
+-	check_function_exists(av_frame_alloc HAVE_AV_FRAME_ALLOC)
+-	check_function_exists(av_frame_free HAVE_AV_FRAME_FREE)
+ 	cmake_pop_check_state()
+ endif()
+
+@@ -163,14 +160,11 @@ message(STATUS "Using ${FFT_LIB} for FFT calculations")
+ if(NOT AUDIO_PROCESSOR_LIB)
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+ 		set(AUDIO_PROCESSOR_LIB "swresample")
+-	elseif(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(AUDIO_PROCESSOR_LIB "avresample")
+ 	endif()
+ endif()
+
+ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE OFF)
+ 		set(USE_SWRESAMPLE ON)
+ 		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBSWRESAMPLE_LIBRARIES})
+ 		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBSWRESAMPLE_INCLUDE_DIRS})
+@@ -178,16 +172,6 @@ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+ 	endif()
+ 	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+-elseif(AUDIO_PROCESSOR_LIB STREQUAL "avresample")
+-	if(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE ON)
+-		set(USE_SWRESAMPLE OFF)
+-		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBAVRESAMPLE_LIBRARIES})
+-		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBAVRESAMPLE_INCLUDE_DIRS})
+-	else()
+-		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+-	endif()
+-	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+ else()
+ 	message(STATUS "Building without audio conversion support, please install FFmpeg with libswresample")
+ endif()
+diff --git a/package/build.sh b/package/build.sh
+index da631ae..b41d36e 100755
+--- a/package/build.sh
++++ b/package/build.sh
+@@ -7,8 +7,8 @@ set -eux
+
+ BASE_DIR=$(cd $(dirname $0)/.. && pwd)
+
+-FFMPEG_VERSION=4.4.1
+-FFMPEG_BUILD_TAG=v4.4.1-1
++FFMPEG_VERSION=5.1.2
++FFMPEG_BUILD_TAG=v${FFMPEG_VERSION}-1
+
+ TMP_BUILD_DIR=$BASE_DIR/$(mktemp -d build.XXXXXXXX)
+ trap 'rm -rf $TMP_BUILD_DIR' EXIT
+diff --git a/src/audio/ffmpeg_audio_processor.h b/src/audio/ffmpeg_audio_processor.h
+index 7628fc7..39f4f6d 100644
+--- a/src/audio/ffmpeg_audio_processor.h
++++ b/src/audio/ffmpeg_audio_processor.h
+@@ -10,8 +10,6 @@
+
+ #if defined(USE_SWRESAMPLE)
+ #include "audio/ffmpeg_audio_processor_swresample.h"
+-#elif defined(USE_AVRESAMPLE)
+-#include "audio/ffmpeg_audio_processor_avresample.h"
+ #else
+ #error "no audio processing library"
+ #endif
+diff --git a/src/audio/ffmpeg_audio_processor_avresample.h b/src/audio/ffmpeg_audio_processor_avresample.h
+deleted file mode 100644
+index bd85f92..0000000
+--- a/src/audio/ffmpeg_audio_processor_avresample.h
++++ /dev/null
+@@ -1,72 +0,0 @@
+-// Copyright (C) 2016  Lukas Lalinsky
+-// Distributed under the MIT license, see the LICENSE file for details.
+-
+-#ifndef CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-#define CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-
+-extern "C" {
+-#include <libavresample/avresample.h>
+-}
+-
+-namespace chromaprint {
+-
+-class FFmpegAudioProcessor {
+-public:
+-	FFmpegAudioProcessor() {
+-		m_resample_ctx = avresample_alloc_context();
+-	}
+-
+-	~FFmpegAudioProcessor() {
+-		avresample_free(&m_resample_ctx);
+-	}
+-
+-	void SetCompatibleMode() {
+-		av_opt_set_int(m_resample_ctx, "filter_size", 16, 0);
+-		av_opt_set_int(m_resample_ctx, "phase_shift", 8, 0);
+-		av_opt_set_int(m_resample_ctx, "linear_interp", 1, 0);
+-		av_opt_set_double(m_resample_ctx, "cutoff", 0.8, 0);
+-	}
+-
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "in_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_rate", sample_rate, 0);
+-	}
+-
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "out_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_rate, 0);
+-	}
+-
+-	int Init() {
+-		return avresample_open(m_resample_ctx);
+-	}
+-
+-	int Convert(uint8_t **out, int out_count, const uint8_t **in, int in_count) {
+-		return avresample_convert(m_resample_ctx, out, 0, out_count, (uint8_t **) in, 0, in_count);
+-	}
+-
+-	int Flush(uint8_t **out, int out_count) {
+-		return avresample_read(m_resample_ctx, out, out_count);
+-	}
+-
+-private:
+-	AVAudioResampleContext *m_resample_ctx = nullptr;
+-};
+-
+-}; // namespace chromaprint
+-
+-#endif
+diff --git a/src/audio/ffmpeg_audio_processor_swresample.h b/src/audio/ffmpeg_audio_processor_swresample.h
+index b86266b..b1d4bea 100644
+--- a/src/audio/ffmpeg_audio_processor_swresample.h
++++ b/src/audio/ffmpeg_audio_processor_swresample.h
+@@ -28,30 +28,28 @@ public:
+ 		av_opt_set_double(m_swr_ctx, "cutoff", 0.8, 0);
+ 	}
+
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "icl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "ich", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetInputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "in_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "isf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "in_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "isr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "in_sample_rate", sample_rate, 0);
+ 	}
+
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "ocl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "och", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetOutputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "out_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "osf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "out_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "osr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "out_sample_rate", sample_rate, 0);
+ 	}
+
+ 	int Init() {
+diff --git a/src/audio/ffmpeg_audio_reader.h b/src/audio/ffmpeg_audio_reader.h
+index 5550164..1c6b346 100644
+--- a/src/audio/ffmpeg_audio_reader.h
++++ b/src/audio/ffmpeg_audio_reader.h
+@@ -62,7 +62,7 @@ public:
+ 	bool Read(const int16_t **data, size_t *size);
+
+ 	bool IsOpen() const { return m_opened; }
+-	bool IsFinished() const { return m_finished && !m_got_frame; }
++	bool IsFinished() const { return !m_has_more_packets && !m_has_more_frames; }
+
+ 	std::string GetError() const { return m_error; }
+ 	int GetErrorCode() const { return m_error_code; }
+@@ -74,20 +74,19 @@ private:
+ 	uint8_t *m_convert_buffer[1] = { nullptr };
+ 	int m_convert_buffer_nb_samples = 0;
+
+-	AVInputFormat *m_input_fmt = nullptr;
++	const AVInputFormat *m_input_fmt = nullptr;
+ 	AVDictionary *m_input_opts = nullptr;
+
+ 	AVFormatContext *m_format_ctx = nullptr;
+ 	AVCodecContext *m_codec_ctx = nullptr;
+-	AVFrame *m_frame = nullptr;
+ 	int m_stream_index = -1;
+ 	std::string m_error;
+ 	int m_error_code = 0;
+-	bool m_finished = false;
+ 	bool m_opened = false;
+-	int m_got_frame = 0;
+-	AVPacket m_packet;
+-	AVPacket m_packet0;
++	bool m_has_more_packets = true;
++	bool m_has_more_frames = true;
++	AVPacket *m_packet = nullptr;
++	AVFrame *m_frame = nullptr;
+
+ 	int m_output_sample_rate = 0;
+ 	int m_output_channels = 0;
+@@ -98,19 +97,12 @@ private:
+
+ inline FFmpegAudioReader::FFmpegAudioReader() {
+ 	av_log_set_level(AV_LOG_QUIET);
+-
+-	av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
+ }
+
+ inline FFmpegAudioReader::~FFmpegAudioReader() {
+ 	Close();
+ 	av_dict_free(&m_input_opts);
+ 	av_freep(&m_convert_buffer[0]);
+-	av_packet_unref(&m_packet0);
+ }
+
+ inline bool FFmpegAudioReader::SetInputFormat(const char *name) {
+@@ -135,11 +127,10 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ 	Close();
+
+-    av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
++	m_packet = av_packet_alloc();
++	if (!m_packet) {
++		return false;
++	}
+
+ 	ret = avformat_open_input(&m_format_ctx, file_name.c_str(), m_input_fmt, &m_input_opts);
+ 	if (ret < 0) {
+@@ -153,26 +144,31 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		return false;
+ 	}
+
+-	AVCodec *codec;
++	const AVCodec *codec;
+ 	ret = av_find_best_stream(m_format_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &codec, 0);
+ 	if (ret < 0) {
+ 		SetError("Could not find any audio stream in the file", ret);
+ 		return false;
+ 	}
+ 	m_stream_index = ret;
++	auto stream = m_format_ctx->streams[m_stream_index];
+
+-	m_codec_ctx = m_format_ctx->streams[m_stream_index]->codec;
++	m_codec_ctx = avcodec_alloc_context3(codec);
+ 	m_codec_ctx->request_sample_fmt = AV_SAMPLE_FMT_S16;
+
++	ret = avcodec_parameters_to_context(m_codec_ctx, stream->codecpar);
++	if (ret < 0) {
++		SetError("Could not copy the stream parameters", ret);
++		return false;
++	}
++
+ 	ret = avcodec_open2(m_codec_ctx, codec, nullptr);
+ 	if (ret < 0) {
+ 		SetError("Could not open the codec", ret);
+ 		return false;
+ 	}
+
+-	if (!m_codec_ctx->channel_layout) {
+-		m_codec_ctx->channel_layout = av_get_default_channel_layout(m_codec_ctx->channels);
+-	}
++	av_dump_format(m_format_ctx, 0, "foo", 0);
+
+ 	m_frame = av_frame_alloc();
+ 	if (!m_frame) {
+@@ -183,19 +179,23 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		m_output_sample_rate = m_codec_ctx->sample_rate;
+ 	}
+
+-	if (!m_output_channels) {
+-		m_output_channels = m_codec_ctx->channels;
++	AVChannelLayout output_channel_layout;
++	if (m_output_channels) {
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
++	} else {
++		m_output_channels = m_codec_ctx->ch_layout.nb_channels;
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
+ 	}
+
+-	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
++	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->ch_layout.nb_channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
+ 		m_converter.reset(new FFmpegAudioProcessor());
+ 		m_converter->SetCompatibleMode();
+ 		m_converter->SetInputSampleFormat(m_codec_ctx->sample_fmt);
+ 		m_converter->SetInputSampleRate(m_codec_ctx->sample_rate);
+-		m_converter->SetInputChannelLayout(m_codec_ctx->channel_layout);
++		m_converter->SetInputChannelLayout(&(m_codec_ctx->ch_layout));
+ 		m_converter->SetOutputSampleFormat(AV_SAMPLE_FMT_S16);
+ 		m_converter->SetOutputSampleRate(m_output_sample_rate);
+-		m_converter->SetOutputChannelLayout(av_get_default_channel_layout(m_output_channels));
++		m_converter->SetOutputChannelLayout(&output_channel_layout);
+ 		auto ret = m_converter->Init();
+ 		if (ret != 0) {
+ 			SetError("Could not create an audio converter instance", ret);
+@@ -203,10 +203,11 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		}
+ 	}
+
++	av_channel_layout_uninit(&output_channel_layout);
++
+ 	m_opened = true;
+-	m_finished = false;
+-	m_got_frame = 0;
+-	m_nb_packets = 0;
++	m_has_more_packets = true;
++	m_has_more_frames = true;
+ 	m_decode_error = 0;
+
+ 	return true;
+@@ -214,6 +215,7 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ inline void FFmpegAudioReader::Close() {
+ 	av_frame_free(&m_frame);
++	av_packet_free(&m_packet);
+
+ 	m_stream_index = -1;
+
+@@ -252,91 +254,98 @@ inline bool FFmpegAudioReader::Read(const int16_t **data, size_t *size) {
+ 		return false;
+ 	}
+
++	*data = nullptr;
++	*size = 0;
++
+ 	int ret;
++	bool needs_packet = false;
+ 	while (true) {
+-		while (m_packet.size <= 0) {
+-			av_packet_unref(&m_packet0);
+-			av_init_packet(&m_packet);
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			ret = av_read_frame(m_format_ctx, &m_packet);
++		while (needs_packet && m_packet->size == 0) {
++			ret = av_read_frame(m_format_ctx, m_packet);
+ 			if (ret < 0) {
+ 				if (ret == AVERROR_EOF) {
+-					m_finished = true;
++					needs_packet = false;
++					m_has_more_packets = false;
+ 					break;
+-				} else {
++				}
++				SetError("Error reading from the audio source", ret);
++				return false;
++			}
++			if (m_packet->stream_index == m_stream_index) {
++				needs_packet = false;
++			} else {
++				av_packet_unref(m_packet);
++			}
++		}
++
++		if (m_packet->size != 0) {
++			ret = avcodec_send_packet(m_codec_ctx, m_packet);
++			if (ret < 0) {
++				if (ret != AVERROR(EAGAIN)) {
+ 					SetError("Error reading from the audio source", ret);
+ 					return false;
+ 				}
+-			}
+-			m_packet0 = m_packet;
+-			if (m_packet.stream_index != m_stream_index) {
+-				m_packet.data = nullptr;
+-				m_packet.size = 0;
+ 			} else {
+-				m_nb_packets++;
++				av_packet_unref(m_packet);
+ 			}
+ 		}
+
+-		ret = avcodec_decode_audio4(m_codec_ctx, m_frame, &m_got_frame, &m_packet);
++		ret = avcodec_receive_frame(m_codec_ctx, m_frame);
+ 		if (ret < 0) {
+-			if (m_decode_error) {
+-				SetError("Error decoding audio frame", m_decode_error);
+-				return false;
++			if (ret == AVERROR_EOF) {
++				m_has_more_frames = false;
++			} else if (ret == AVERROR(EAGAIN)) {
++				if (m_has_more_packets) {
++					needs_packet = true;
++					continue;
++				} else {
++					m_has_more_frames = false;
++				}
+ 			}
+-			m_decode_error = ret;
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			continue;
++			SetError("Error decoding the audio source", ret);
++			return false;
+ 		}
+
+-		break;
+-	}
+-
+-	m_decode_error = 0;
+-
+-	const int decoded = std::min(ret, m_packet.size);
+-	m_packet.data += decoded;
+-	m_packet.size -= decoded;
+-
+-	if (m_got_frame) {
+-		if (m_converter) {
+-			if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
+-				int linsize;
+-				av_freep(&m_convert_buffer[0]);
+-				m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
+-				ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
+-				if (ret < 0) {
+-					SetError("Couldn't allocate audio converter buffer", ret);
++		if (m_frame->nb_samples > 0) {
++			if (m_converter) {
++				if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
++					int linsize;
++					av_freep(&m_convert_buffer[0]);
++					m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
++					ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->ch_layout.nb_channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
++					if (ret < 0) {
++						SetError("Couldn't allocate audio converter buffer", ret);
++						return false;
++					}
++				}
++				auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
++				if (nb_samples < 0) {
++					SetError("Couldn't convert audio", ret);
+ 					return false;
+ 				}
+-			}
+-			auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			}
+-			*data = (const int16_t *) m_convert_buffer[0];
+-			*size = nb_samples;
+-		} else {
+-			*data = (const int16_t *) m_frame->data[0];
+-			*size = m_frame->nb_samples;
+-		}
+-	} else {
+-		if (m_finished && m_converter) {
+-			auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			} else if (nb_samples > 0) {
+-				m_got_frame = 1;
+ 				*data = (const int16_t *) m_convert_buffer[0];
+ 				*size = nb_samples;
++			} else {
++				*data = (const int16_t *) m_frame->data[0];
++				*size = m_frame->nb_samples;
++			}
++		} else {
++			if (m_converter) {
++				if (IsFinished()) {
++					auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
++					if (nb_samples < 0) {
++						SetError("Couldn't convert audio", ret);
++						return false;
++					} else if (nb_samples > 0) {
++						*data = (const int16_t *) m_convert_buffer[0];
++						*size = nb_samples;
++					}
++				}
+ 			}
+ 		}
+-	}
+
+-	return true;
++		return true;
++	}
+ }
+
+ inline void FFmpegAudioReader::SetError(const char *message, int errnum) {
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index a2b517b..123e643 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -38,6 +38,12 @@ set(SRCS
+
+ if(BUILD_TOOLS)
+ 	set(SRCS ${SRCS} ../src/audio/ffmpeg_audio_reader_test.cpp)
++    include_directories(
++        ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}
++        ${AUDIO_PROCESSOR_INCLUDE_DIRS}
++    )
+ 	link_libraries(fpcalc_libs)
+ endif()
+
+-- 
+2.38.1
+
+
diff --git a/srcpkgs/chromaprint/template b/srcpkgs/chromaprint/template
index 7ef7838949f3..1f7bbc70a22c 100644
--- a/srcpkgs/chromaprint/template
+++ b/srcpkgs/chromaprint/template
@@ -1,7 +1,7 @@
 # Template file for 'chromaprint'
 pkgname=chromaprint
 version=1.5.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DBUILD_TOOLS=ON"
 make_check_target="check"

From 8c63923c8158977b2e9037f38d1567b9392a0f07 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 025/116] chromium: revbump for ffmpeg-6.0

---
 .../patches/chromium-93-ffmpeg-4.4.patch      | 36 --------------
 srcpkgs/chromium/patches/ffmpeg5.patch        | 47 +++++++++++++++++++
 srcpkgs/chromium/template                     |  2 +-
 3 files changed, 48 insertions(+), 37 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch
 create mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch b/srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch
deleted file mode 100644
index f0ec736f98bc..000000000000
--- a/srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch
+++ /dev/null
@@ -1,36 +0,0 @@
-diff --git a/media/filters/ffmpeg_demuxer.cc b/media/filters/ffmpeg_demuxer.cc
-index ac4713b07268..492a9a37d096 100644
---- a/media/filters/ffmpeg_demuxer.cc
-+++ b/media/filters/ffmpeg_demuxer.cc
-@@ -427,11 +427,11 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
-   scoped_refptr<DecoderBuffer> buffer;
- 
-   if (type() == DemuxerStream::TEXT) {
--    size_t id_size = 0;
-+    int id_size = 0;
-     uint8_t* id_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
- 
--    size_t settings_size = 0;
-+    int settings_size = 0;
-     uint8_t* settings_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
- 
-@@ -443,7 +443,7 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
-     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
-                                      side_data.data(), side_data.size());
-   } else {
--    size_t side_data_size = 0;
-+    int side_data_size = 0;
-     uint8_t* side_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
- 
-@@ -504,7 +504,7 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
-                                        packet->size - data_offset);
-     }
- 
--    size_t skip_samples_size = 0;
-+    int skip_samples_size = 0;
-     const uint32_t* skip_samples_ptr =
-         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
-             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..24e2da38e34c
--- /dev/null
+++ b/srcpkgs/chromium/patches/ffmpeg5.patch
@@ -0,0 +1,47 @@
+--- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
++++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
+@@ -92,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+-  if (stream->start_time != kNoFFmpegTimestamp)
++  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -1597,7 +1585,7 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+@@ -1618,7 +1606,7 @@
+     if (stream->type() != DemuxerStream::VIDEO)
+       continue;
+ 
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+ 
+     if (!stream->IsEnabled())
diff --git a/srcpkgs/chromium/template b/srcpkgs/chromium/template
index b4a39dfd3815..c29453cd1f50 100644
--- a/srcpkgs/chromium/template
+++ b/srcpkgs/chromium/template
@@ -2,7 +2,7 @@
 pkgname=chromium
 # See https://chromiumdash.appspot.com/releases?platform=Linux for the latest version
 version=114.0.5735.106
-revision=1
+revision=2
 archs="i686* x86_64* aarch64* armv7l*"
 hostmakedepends="
  $(vopt_if clang "clang lld llvm15")

From be8e39afdd58ba0d10a9de59c9290de9b508df55 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 026/116] cmus: revbump for ffmpeg-6.0

---
 srcpkgs/cmus/patches/ffmpeg6.patch | 12 ++++++++++++
 srcpkgs/cmus/template              |  2 +-
 2 files changed, 13 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/cmus/patches/ffmpeg6.patch

diff --git a/srcpkgs/cmus/patches/ffmpeg6.patch b/srcpkgs/cmus/patches/ffmpeg6.patch
new file mode 100644
index 000000000000..ffa95ab81110
--- /dev/null
+++ b/srcpkgs/cmus/patches/ffmpeg6.patch
@@ -0,0 +1,12 @@
+--- a/ip/ffmpeg.c
++++ b/ip/ffmpeg.c
+@@ -202,9 +202,6 @@ static int ffmpeg_open(struct input_plugin_data *ip_data)
+ 			break;
+ 		}
+ 
+-		if (codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+-			cc->flags |= AV_CODEC_FLAG_TRUNCATED;
+-
+ 		if (avcodec_open2(cc, codec, NULL) < 0) {
+ 			d_print("could not open codec: %d, %s\n", cc->codec_id, avcodec_get_name(cc->codec_id));
+ 			err = -IP_ERROR_UNSUPPORTED_FILE_TYPE;
diff --git a/srcpkgs/cmus/template b/srcpkgs/cmus/template
index 0fcb424ce336..05b77d0fecae 100644
--- a/srcpkgs/cmus/template
+++ b/srcpkgs/cmus/template
@@ -1,7 +1,7 @@
 # Template file for 'cmus'
 pkgname=cmus
 version=2.10.0
-revision=1
+revision=2
 build_style=configure
 configure_args="prefix=/usr LD=$CC"
 hostmakedepends="pkg-config"

From 72a9488894d4f275daa35b382e9e9174d6e540c0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 027/116] cyanrip: revbump for ffmpeg-6.0

---
 srcpkgs/cyanrip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cyanrip/template b/srcpkgs/cyanrip/template
index 9796e3461601..5db30e020d17 100644
--- a/srcpkgs/cyanrip/template
+++ b/srcpkgs/cyanrip/template
@@ -1,7 +1,7 @@
 # Template file for 'cyanrip'
 pkgname=cyanrip
 version=0.9.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config"
 makedepends="ffmpeg-devel libcdio-devel libcdio-paranoia-devel libcurl-devel libmusicbrainz5-devel"

From 6dc22cfa6a1d0082366b286b1a4ae0bad9da201d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 028/116] deadbeef: revbump for ffmpeg4-4.4.3

---
 srcpkgs/deadbeef/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/deadbeef/template b/srcpkgs/deadbeef/template
index b664bb1b9bd9..165b3c7b9cad 100644
--- a/srcpkgs/deadbeef/template
+++ b/srcpkgs/deadbeef/template
@@ -1,14 +1,14 @@
 # Template file for 'deadbeef'
 pkgname=deadbeef
 version=1.8.8
-revision=1
+revision=2
 create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-oss --disable-lfm --disable-notify --disable-gtk2"
 hostmakedepends="automake libtool gettext gettext-devel intltool pkg-config
  yasm clang glib-devel"
 makedepends="
- alsa-lib-devel dbus-devel faad2-devel ffmpeg-devel gtk+3-devel imlib2-devel
+ alsa-lib-devel dbus-devel faad2-devel ffmpeg4-devel gtk+3-devel imlib2-devel
  jansson-devel libcddb-devel libcdio-devel libcurl-devel libflac-devel
  libmad-devel libpng-devel libsamplerate-devel libsndfile-devel libvorbis-devel
  libzip-devel mpg123-devel opusfile-devel pulseaudio-devel wavpack-devel"

From 0087f52c285eb97ac9c2df74cdbdc2e3e506d24a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 029/116] dolphin-emu: revbump for ffmpeg-6.0

---
 srcpkgs/dolphin-emu/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/dolphin-emu/template b/srcpkgs/dolphin-emu/template
index 7ea197ceb2a8..7aeb0a5b645e 100644
--- a/srcpkgs/dolphin-emu/template
+++ b/srcpkgs/dolphin-emu/template
@@ -1,7 +1,7 @@
 # Template file for 'dolphin-emu'
 pkgname=dolphin-emu
 version=5.0.16101
-revision=1
+revision=2
 _dolphin_commit=8ecfa537a242de74d2e372e30d9d79b14584b2fb
 _mgba_commit=40d4c430fc36caeb7ea32fd39624947ed487d2f2
 #Version/hash pair can be found at https://dolphin-emu.org/download/

From 07e905b6546aa105a59eee7163f2e33d40fd79e8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 030/116] droidcam-obs-plugin: revbump for ffmpeg-6.0

---
 srcpkgs/droidcam-obs-plugin/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam-obs-plugin/template b/srcpkgs/droidcam-obs-plugin/template
index fc9c9bf6b9d5..fb0480754df4 100644
--- a/srcpkgs/droidcam-obs-plugin/template
+++ b/srcpkgs/droidcam-obs-plugin/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam-obs-plugin'
 pkgname=droidcam-obs-plugin
 version=2.0.1
-revision=1
+revision=2
 build_style=gnu-makefile
 make_use_env=yes
 make_build_args="ALLOW_STATIC=no"

From 297fae5b548f7a590649916b0ad416781aed2ad6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 031/116] droidcam: revbump for ffmpeg-6.0

---
 srcpkgs/droidcam/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam/template b/srcpkgs/droidcam/template
index 1c3f1b8b1fc6..32a9220b79a4 100644
--- a/srcpkgs/droidcam/template
+++ b/srcpkgs/droidcam/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam'
 pkgname=droidcam
 version=1.8.2
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="USBMUXD=-lusbmuxd-2.0 JPEG=-lturbojpeg"
 hostmakedepends="pkg-config"

From c469bb015af37f0817b4d01a290bf8825994b272 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 032/116] ffmpegthumbnailer: revbump for ffmpeg-6.0

---
 .../ffmpegthumbnailer/patches/ffmpeg6.patch   | 202 ++++++++++++++++++
 srcpkgs/ffmpegthumbnailer/template            |   6 +-
 2 files changed, 205 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch

diff --git a/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
new file mode 100644
index 000000000000..363ff35a2841
--- /dev/null
+++ b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
@@ -0,0 +1,202 @@
+--- a/libffmpegthumbnailer/moviedecoder.cpp	2017-11-21 14:06:57.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.cpp	2023-05-05 13:14:47.946560668 -0400
+@@ -41,11 +41,6 @@
+ namespace ffmpegthumbnailer
+ {
+ 
+-struct SilenceLogLevel
+-{
+-    SilenceLogLevel() { av_log_set_level(AV_LOG_QUIET); }
+-};
+-
+ MovieDecoder::MovieDecoder(AVFormatContext* pavContext)
+ : m_VideoStream(-1)
+ , m_pFormatContext(pavContext)
+@@ -70,8 +65,6 @@
+ 
+ void MovieDecoder::initialize(const string& filename, bool preferEmbeddedMetadata)
+ {
+-    av_register_all();
+-    avcodec_register_all();
+     avformat_network_init();
+ 
+     string inputFile = filename == "-" ? "pipe:" : filename;
+@@ -97,8 +90,7 @@
+ {
+     if (m_pVideoCodecContext)
+     {
+-        avcodec_close(m_pVideoCodecContext);
+-        m_pVideoCodecContext = nullptr;
++        avcodec_free_context(&m_pVideoCodecContext);
+     }
+ 
+     if ((!m_FormatContextWasGiven) && m_pFormatContext)
+@@ -152,10 +144,10 @@
+     for (unsigned int i = 0; i < m_pFormatContext->nb_streams; ++i)
+     {
+         AVStream *stream = m_pFormatContext->streams[i];
+-        auto ctx = m_pFormatContext->streams[i]->codec;
+-        if (ctx->codec_type == AVMEDIA_TYPE_VIDEO)
++        auto par = m_pFormatContext->streams[i]->codecpar;
++        if (par->codec_type == AVMEDIA_TYPE_VIDEO)
+         {
+-            if (!preferEmbeddedMetadata || !isStillImageCodec(ctx->codec_id))
++            if (!preferEmbeddedMetadata || !isStillImageCodec(par->codec_id))
+             {
+                 videoStreams.push_back(i);
+                 continue;
+@@ -203,8 +195,7 @@
+     }
+ 
+     m_pVideoStream = m_pFormatContext->streams[m_VideoStream];
+-    m_pVideoCodecContext = m_pVideoStream->codec;
+-    m_pVideoCodec = avcodec_find_decoder(m_pVideoCodecContext->codec_id);
++    m_pVideoCodec = avcodec_find_decoder(m_pVideoStream->codecpar->codec_id);
+ 
+     if (m_pVideoCodec == nullptr)
+     {
+@@ -214,6 +205,20 @@
+         throw logic_error("Video Codec not found");
+     }
+ 
++    m_pVideoCodecContext = avcodec_alloc_context3(m_pVideoCodec);
++
++    if (m_pVideoCodecContext == nullptr)
++    {
++        destroy();
++        throw logic_error("Could not allocate video codec context");
++    }
++
++    if (avcodec_parameters_to_context(m_pVideoCodecContext, m_pVideoStream->codecpar) < 0)
++    {
++        destroy();
++        throw logic_error("Could not configure video codec context");
++    }
++
+     m_pVideoCodecContext->workaround_bugs = 1;
+ 
+     if (avcodec_open2(m_pVideoCodecContext, m_pVideoCodec, nullptr) < 0)
+@@ -386,13 +391,6 @@
+ 
+ void MovieDecoder::initializeFilterGraph(const AVRational& timeBase, const std::string& size, bool maintainAspectRatio)
+ {
+-    static const AVPixelFormat pixelFormats[] = { AV_PIX_FMT_RGB24, AV_PIX_FMT_NONE };
+-
+-    auto del = [] (AVBufferSinkParams* p) { av_freep(p); };
+-    std::unique_ptr<AVBufferSinkParams, decltype(del)> buffersinkParams(av_buffersink_params_alloc(), del);
+-
+-    avfilter_register_all();
+-
+     m_pFilterGraph = avfilter_graph_alloc();
+     assert(m_pFilterGraph);
+ 
+@@ -404,10 +402,8 @@
+ 
+     checkRc(avfilter_graph_create_filter(&m_pFilterSource, avfilter_get_by_name("buffer"), "thumb_buffer", ss.str().c_str(), nullptr, m_pFilterGraph),
+             "Failed to create filter source");
+-    buffersinkParams->pixel_fmts = pixelFormats;
+-    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, buffersinkParams.get(), m_pFilterGraph),
++    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, nullptr, m_pFilterGraph),
+             "Failed to create filter sink");
+-    buffersinkParams.release();
+ 
+     AVFilterContext* yadifFilter = nullptr;
+     if (m_pFrame->interlaced_frame != 0)
+@@ -500,15 +496,15 @@
+     }
+ 
+     checkRc(av_seek_frame(m_pFormatContext, -1, timestamp, 0), "Seeking in video failed");
+-    avcodec_flush_buffers(m_pFormatContext->streams[m_VideoStream]->codec);
++    avcodec_flush_buffers(m_pVideoCodecContext);
+ 
+     int keyFrameAttempts = 0;
+-    bool gotFrame = 0;
++    bool gotFrame;
+ 
+     do
+     {
+         int count = 0;
+-        gotFrame = 0;
++        gotFrame = false;
+ 
+         while (!gotFrame && count < 20)
+         {
+@@ -552,17 +548,33 @@
+         return false;
+     }
+ 
+-    av_frame_unref(m_pFrame);
+-
+-    int frameFinished;
++    int rc = avcodec_send_packet(m_pVideoCodecContext, m_pPacket);
++    if(rc == AVERROR(EAGAIN))
++    {
++        rc = 0;
++    }
+ 
+-    int bytesDecoded = avcodec_decode_video2(m_pVideoCodecContext, m_pFrame, &frameFinished, m_pPacket);
+-    if (bytesDecoded < 0)
++    if(rc == AVERROR_EOF)
++    {
++        return false;
++    }
++    else if(rc < 0)
+     {
+-        throw logic_error("Failed to decode video frame: bytesDecoded < 0");
++        throw logic_error("Failed to decode video frame: avcodec_send_packet() < 0");
+     }
+ 
+-    return frameFinished > 0;
++    rc = avcodec_receive_frame(m_pVideoCodecContext, m_pFrame);
++    switch(rc)
++    {
++        case 0:
++            return true;
++
++        case AVERROR(EAGAIN):
++            return false;
++
++        default:
++            throw logic_error("Failed to decode video frame: avcodec_receive_frame() < 0");
++    }
+ }
+ 
+ bool MovieDecoder::getVideoPacket()
+@@ -570,8 +582,6 @@
+     bool framesAvailable = true;
+     bool frameDecoded = false;
+ 
+-    int attempts = 0;
+-
+     if (m_pPacket)
+     {
+         av_packet_unref(m_pPacket);
+@@ -580,6 +590,7 @@
+ 
+     m_pPacket = new AVPacket();
+ 
++
+     while (framesAvailable && !frameDecoded)
+     {
+         framesAvailable = av_read_frame(m_pFormatContext, m_pPacket) >= 0;
+@@ -644,7 +655,7 @@
+ 
+ int32_t MovieDecoder::getStreamRotation()
+ {
+-    int32_t* matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
++    auto matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
+     if (matrix)
+     {
+         auto angle = lround(av_display_rotation_get(matrix));
+
+--- a/libffmpegthumbnailer/moviedecoder.h	2017-11-12 04:23:38.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.h	2023-05-05 13:26:07.095529911 -0400
+@@ -78,7 +78,7 @@
+     int                     m_VideoStream;
+     AVFormatContext*        m_pFormatContext;
+     AVCodecContext*         m_pVideoCodecContext;
+-    AVCodec*                m_pVideoCodec;
++    const AVCodec*          m_pVideoCodec;
+     AVFilterGraph*          m_pFilterGraph;
+     AVFilterContext*        m_pFilterSource;
+     AVFilterContext*        m_pFilterSink;
diff --git a/srcpkgs/ffmpegthumbnailer/template b/srcpkgs/ffmpegthumbnailer/template
index 039eea7622b3..35d546018d12 100644
--- a/srcpkgs/ffmpegthumbnailer/template
+++ b/srcpkgs/ffmpegthumbnailer/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbnailer'
 pkgname=ffmpegthumbnailer
 version=2.2.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libpng-devel libjpeg-turbo-devel ffmpeg-devel"
@@ -9,8 +9,8 @@ depends="ffmpeg"
 short_desc="Lightweight video thumbnailer"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
-homepage="https://github.com/dirkvdb/${pkgname}"
-distfiles="${homepage}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
+homepage="https://github.com/dirkvdb"
+distfiles="${homepage}/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
 checksum=1cb24059c38223f657b300c84dd80491b7040d4b69471c4fea69be862bc99b5b
 
 post_install() {

From 0f16ac67cc220339edeab79f939d30c262a51acb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 033/116] ffmpegthumbs: revbump for ffmpeg-6.0

---
 srcpkgs/ffmpegthumbs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ffmpegthumbs/template b/srcpkgs/ffmpegthumbs/template
index 5f0b9414dada..11b88193528f 100644
--- a/srcpkgs/ffmpegthumbs/template
+++ b/srcpkgs/ffmpegthumbs/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbs'
 pkgname=ffmpegthumbs
 version=22.12.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules kcoreaddons kconfig-devel
  pkg-config qt5-host-tools qt5-qmake gettext"

From f807a2223dc04af66790d52e257949d8f0cc4e25 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 034/116] ffms2: revbump for ffmpeg-6.0

---
 srcpkgs/ffms2/patches/ffmpeg5.patch | 424 ++++++++++++++++++++++++++++
 srcpkgs/ffms2/template              |   2 +-
 2 files changed, 425 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ffms2/patches/ffmpeg5.patch

diff --git a/srcpkgs/ffms2/patches/ffmpeg5.patch b/srcpkgs/ffms2/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..1479fabcafcb
--- /dev/null
+++ b/srcpkgs/ffms2/patches/ffmpeg5.patch
@@ -0,0 +1,424 @@
+From 45673149e9a2f5586855ad472e3059084eaa36b1 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:41:21 +0100
+Subject: [PATCH] Use auto for AVCodec
+
+The geniuses over at FFmpeg decided to constify this API, so old
+versions of the library will return AVCodec *, while new versions
+of the libary will return const AVCodec *, which, in C++, are not
+OK to convert between.
+
+Rather than use some macro hell in ffmscompat.h, we can work around
+this by using auto.
+
+Gross.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 2 +-
+ src/core/indexing.cpp    | 6 +++---
+ src/core/videosource.cpp | 2 +-
+ 3 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index e4ce97c..ac09666 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -469,7 +469,7 @@ void FFMS_AudioSource::OpenFile() {
+ 
+     LAVFOpenFile(SourceFile.c_str(), FormatContext, TrackNumber);
+ 
+-    AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
++    auto *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
+     if (Codec == nullptr)
+         throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+             "Audio codec not found");
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index e547c5a..59fb4e8 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -384,7 +384,7 @@ FFMS_TrackType FFMS_Indexer::GetTrackType(int Track) {
+ }
+ 
+ const char *FFMS_Indexer::GetTrackCodec(int Track) {
+-    AVCodec *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
++    auto *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
+     return codec ? codec->name : nullptr;
+ }
+ 
+@@ -402,7 +402,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             UseDTS);
+ 
+         if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            AVCodec *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (!VideoCodec) {
+                 FormatContext->streams[i]->discard = AVDISCARD_ALL;
+                 IndexMask.erase(i);
+@@ -433,7 +433,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 IndexMask.insert(i);
+             }
+         } else if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+-            AVCodec *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (AudioCodec == nullptr)
+                 throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_UNSUPPORTED,
+                     "Audio codec not found");
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index b889970..8956c22 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -171,7 +171,7 @@ FFMS_VideoSource::FFMS_VideoSource(const char *SourceFile, FFMS_Index &Index, in
+ 
+         LAVFOpenFile(SourceFile, FormatContext, VideoTrack);
+ 
+-        AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
++        auto *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
+         if (Codec == nullptr)
+             throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+                 "Video codec not found");
+-- 
+2.40.0
+
+From 96cbf38ea9381829a1314f432a2c60495dcefaad Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:12:41 +0100
+Subject: [PATCH] all: Update AVPacket API usage
+
+AVPackets must all be on the heap now, since it is no longer
+part of the libav* ABI.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 16 ++++++----
+ src/core/indexing.cpp    | 63 ++++++++++++++++++++++------------------
+ src/core/indexing.h      |  4 +--
+ src/core/utils.cpp       |  6 ----
+ src/core/utils.h         |  1 -
+ src/core/videosource.cpp | 30 ++++++++++---------
+ 6 files changed, 64 insertions(+), 56 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index 37cf9ae..e4ce97c 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -285,10 +285,15 @@ FFMS_AudioSource::AudioBlock *FFMS_AudioSource::CacheBlock(CacheIterator &pos) {
+ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     CurrentFrame = &Frames[PacketNumber];
+ 
+-    AVPacket Packet;
+-    if (!ReadPacket(&Packet))
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++    if (!ReadPacket(Packet)) {
++        av_packet_free(&Packet);
+         throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_UNKNOWN,
+             "ReadPacket unexpectedly failed to read a packet");
++    }
+ 
+     // ReadPacket may have changed the packet number
+     CurrentFrame = &Frames[PacketNumber];
+@@ -297,8 +302,9 @@ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     int NumberOfSamples = 0;
+     AudioBlock *CachedBlock = nullptr;
+     
+-    int Ret = avcodec_send_packet(CodecContext, &Packet);
+-    av_packet_unref(&Packet);
++    int Ret = avcodec_send_packet(CodecContext, Packet);
++    av_packet_unref(Packet);
++    av_packet_free(&Packet);
+ 
+     av_frame_unref(DecodeFrame);
+     Ret = avcodec_receive_frame(CodecContext, DecodeFrame);
+@@ -513,8 +519,6 @@ void FFMS_AudioSource::Seek() {
+ }
+ 
+ bool FFMS_AudioSource::ReadPacket(AVPacket *Packet) {
+-    InitNullPacket(*Packet);
+-
+     while (av_read_frame(FormatContext, Packet) >= 0) {
+         if (Packet->stream_index == TrackNumber) {
+             // Required because not all audio packets, especially in ogg, have a pts. Use the previous valid packet's pts instead.
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index 23fb95b..e547c5a 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -320,7 +320,7 @@ void FFMS_Indexer::CheckAudioProperties(int Track, AVCodecContext *Context) {
+     }
+ }
+ 
+-void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict,
++void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict,
+                                     int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct) {
+     if (VideoContext.Parser) {
+         uint8_t *OB;
+@@ -330,8 +330,8 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+         av_parser_parse2(VideoContext.Parser,
+             VideoContext.CodecContext,
+             &OB, &OBSize,
+-            pkt.data, pkt.size,
+-            pkt.pts, pkt.dts, pkt.pos);
++            pkt->data, pkt->size,
++            pkt->pts, pkt->dts, pkt->pos);
+ 
+         // H.264 (PAFF) and HEVC may have one field per packet, so we need to track
+         // when we have a full or half frame available, and mark one of them as
+@@ -351,15 +351,15 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+ 
+         *RepeatPict = VideoContext.Parser->repeat_pict;
+         *FrameType = VideoContext.Parser->pict_type;
+-        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt.flags & AV_PKT_FLAG_DISCARD));
++        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt->flags & AV_PKT_FLAG_DISCARD));
+     } else {
+-        *Invisible = !!(pkt.flags & AV_PKT_FLAG_DISCARD);
++        *Invisible = !!(pkt->flags & AV_PKT_FLAG_DISCARD);
+     }
+ 
+     if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP8)
+-        ParseVP8(pkt.data[0], Invisible, FrameType);
++        ParseVP8(pkt->data[0], Invisible, FrameType);
+     else if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP9)
+-        ParseVP9(pkt.data[0], Invisible, FrameType);
++        ParseVP9(pkt->data[0], Invisible, FrameType);
+ }
+ 
+ void FFMS_Indexer::Free() {
+@@ -458,32 +458,36 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+         }
+     }
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
+     std::vector<int64_t> LastValidTS(FormatContext->nb_streams, AV_NOPTS_VALUE);
+ 
+     int64_t filesize = avio_size(FormatContext->pb);
+     enum AVPictureStructure LastPicStruct = AV_PICTURE_STRUCTURE_UNKNOWN;
+-    while (av_read_frame(FormatContext, &Packet) >= 0) {
++    while (av_read_frame(FormatContext, Packet) >= 0) {
+         // Update progress
+         // FormatContext->pb can apparently be NULL when opening images.
+         if (IC && FormatContext->pb) {
+-            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate))
++            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate)) {
++                av_packet_free(&Packet);
+                 throw FFMS_Exception(FFMS_ERROR_CANCELLED, FFMS_ERROR_USER,
+                     "Cancelled by user");
++            }
+         }
+-        if (!IndexMask.count(Packet.stream_index)) {
+-            av_packet_unref(&Packet);
++        if (!IndexMask.count(Packet->stream_index)) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+-        int Track = Packet.stream_index;
++        int Track = Packet->stream_index;
+         FFMS_Track &TrackInfo = (*TrackIndices)[Track];
+-        bool KeyFrame = !!(Packet.flags & AV_PKT_FLAG_KEY);
++        bool KeyFrame = !!(Packet->flags & AV_PKT_FLAG_KEY);
+         ReadTS(Packet, LastValidTS[Track], (*TrackIndices)[Track].UseDTS);
+ 
+         if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            int64_t PTS = TrackInfo.UseDTS ? Packet.dts : Packet.pts;
++            int64_t PTS = TrackInfo.UseDTS ? Packet->dts : Packet->pts;
+             if (PTS == AV_NOPTS_VALUE) {
+                 // VPx alt-refs are output as packets which lack timestmps or durations, since
+                 // they are invisible. Currently, the timestamp mangling code in libavformat
+@@ -495,9 +499,11 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 // FFMS2 currently sorts packets by PTS, which will break decoding, otherwise.
+                 bool HasAltRefs = (FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP8 ||
+                                    FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP9);
+-                if (Packet.duration == 0 && !HasAltRefs)
++                if (Packet->duration == 0 && !HasAltRefs) {
++                    av_packet_free(&Packet);
+                     throw FFMS_Exception(FFMS_ERROR_INDEXING, FFMS_ERROR_PARSER,
+                         "Invalid packet pts, dts, and duration");
++                }
+ 
+                 if (TrackInfo.empty())
+                     PTS = 0;
+@@ -513,7 +519,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             ParseVideoPacket(AVContexts[Track], Packet, &RepeatPict, &FrameType, &Invisible, &LastPicStruct);
+ 
+             TrackInfo.AddVideoFrame(PTS, RepeatPict, KeyFrame,
+-                FrameType, Packet.pos, Invisible);
++                FrameType, Packet->pos, Invisible);
+         } else if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+             // For video seeking timestamps are used only if all packets have
+             // timestamps, while for audio they're used if any have timestamps,
+@@ -522,28 +528,29 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 TrackInfo.HasTS = true;
+ 
+             int64_t StartSample = AVContexts[Track].CurrentSample;
+-            uint32_t SampleCount = IndexAudioPacket(Track, &Packet, AVContexts[Track], *TrackIndices);
++            uint32_t SampleCount = IndexAudioPacket(Track, Packet, AVContexts[Track], *TrackIndices);
+             TrackInfo.SampleRate = AVContexts[Track].CodecContext->sample_rate;
+ 
+             TrackInfo.AddAudioFrame(LastValidTS[Track],
+-                StartSample, SampleCount, KeyFrame, Packet.pos, Packet.flags & AV_PKT_FLAG_DISCARD);
++                StartSample, SampleCount, KeyFrame, Packet->pos, Packet->flags & AV_PKT_FLAG_DISCARD);
+         }
+ 
+-        if (!(Packet.flags & AV_PKT_FLAG_DISCARD))
+-            TrackInfo.LastDuration = Packet.duration;
++        if (!(Packet->flags & AV_PKT_FLAG_DISCARD))
++            TrackInfo.LastDuration = Packet->duration;
+ 
+-        av_packet_unref(&Packet);
++        av_packet_unref(Packet);
+     }
++    av_packet_free(&Packet);
+ 
+     TrackIndices->Finalize(AVContexts, FormatContext->iformat->name);
+     return TrackIndices.release();
+ }
+ 
+-void FFMS_Indexer::ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS) {
+-    if (!UseDTS && Packet.pts != AV_NOPTS_VALUE)
+-        TS = Packet.pts;
++void FFMS_Indexer::ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS) {
++    if (!UseDTS && Packet->pts != AV_NOPTS_VALUE)
++        TS = Packet->pts;
+     if (TS == AV_NOPTS_VALUE)
+         UseDTS = true;
+-    if (UseDTS && Packet.dts != AV_NOPTS_VALUE)
+-        TS = Packet.dts;
++    if (UseDTS && Packet->dts != AV_NOPTS_VALUE)
++        TS = Packet->dts;
+ }
+diff --git a/src/core/indexing.h b/src/core/indexing.h
+index 3cfc3c3..5c06868 100644
+--- a/src/core/indexing.h
++++ b/src/core/indexing.h
+@@ -80,10 +80,10 @@ private:
+     int64_t Filesize;
+     uint8_t Digest[20];
+ 
+-    void ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS);
++    void ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS);
+     void CheckAudioProperties(int Track, AVCodecContext *Context);
+     uint32_t IndexAudioPacket(int Track, AVPacket *Packet, SharedAVContext &Context, FFMS_Index &TrackIndices);
+-    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
++    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
+     void Free();
+ public:
+     FFMS_Indexer(const char *Filename);
+diff --git a/src/core/utils.cpp b/src/core/utils.cpp
+index ce67533..8a2e997 100644
+--- a/src/core/utils.cpp
++++ b/src/core/utils.cpp
+@@ -62,12 +62,6 @@ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo) {
+     }
+ }
+ 
+-void InitNullPacket(AVPacket &pkt) {
+-    av_init_packet(&pkt);
+-    pkt.data = nullptr;
+-    pkt.size = 0;
+-}
+-
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames) {
+     AP.SampleFormat = static_cast<FFMS_SampleFormat>(av_get_packed_sample_fmt(CTX->sample_fmt));
+     AP.BitsPerSample = av_get_bytes_per_sample(CTX->sample_fmt) * 8;
+diff --git a/src/core/utils.h b/src/core/utils.h
+index 9819dc7..003ab79 100644
+--- a/src/core/utils.h
++++ b/src/core/utils.h
+@@ -58,7 +58,6 @@ std::unique_ptr<T> make_unique(Args&&... args) {
+ }
+ 
+ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo);
+-void InitNullPacket(AVPacket &pkt);
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames);
+ 
+ void LAVFOpenFile(const char *SourceFile, AVFormatContext *&FormatContext, int Track);
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index 06bd161..b889970 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -673,30 +673,34 @@ void FFMS_VideoSource::DecodeNextFrame(int64_t &AStartTime, int64_t &Pos) {
+     if (HasPendingDelayedFrames())
+         return;
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
+-
+-    while (ReadFrame(&Packet) >= 0) {
+-        if (Packet.stream_index != VideoTrack) {
+-            av_packet_unref(&Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++
++    while (ReadFrame(Packet) >= 0) {
++        if (Packet->stream_index != VideoTrack) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+         if (AStartTime < 0)
+-            AStartTime = Frames.UseDTS ? Packet.dts : Packet.pts;
++            AStartTime = Frames.UseDTS ? Packet->dts : Packet->pts;
+ 
+         if (Pos < 0)
+-            Pos = Packet.pos;
++            Pos = Packet->pos;
+ 
+-        bool FrameFinished = DecodePacket(&Packet);
+-        av_packet_unref(&Packet);
+-        if (FrameFinished)
++        bool FrameFinished = DecodePacket(Packet);
++        av_packet_unref(Packet);
++        if (FrameFinished) {
++            av_packet_free(&Packet);
+             return;
++        }
+     }
+ 
+     // Flush final frames
+-    InitNullPacket(Packet);
+-    DecodePacket(&Packet);
++    DecodePacket(Packet);
++    av_packet_free(&Packet);
+ }
+ 
+ bool FFMS_VideoSource::SeekTo(int n, int SeekOffset) {
+-- 
+2.40.0
+
+From bf9e03e9e08534c024e5a744a6437c4aac160201 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:20:47 +0100
+Subject: [PATCH 2/3] configure: Remove deprecated API use
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ configure.ac | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index b35ef80bc..d19714d0f 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -102,10 +102,10 @@ CFLAGS="$_CFLAGS $FFMPEG_CFLAGS"
+
+ AC_DEFUN([TEST_FFMPEG],
+          [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+-            #include <libavcodec/avcodec.h>
++            #include <libavformat/avformat.h>
+             #include <libswscale/swscale.h>
+             ]],[[
+-                avcodec_register_all();
++                avformat_network_init();
+                 swscale_version();
+             ]])], [eval $1=yes], [eval $1=no])
+         ])
+
diff --git a/srcpkgs/ffms2/template b/srcpkgs/ffms2/template
index 68e8a0c14bce..2acfadac44b3 100644
--- a/srcpkgs/ffms2/template
+++ b/srcpkgs/ffms2/template
@@ -1,7 +1,7 @@
 # Template file for 'ffms2'
 pkgname=ffms2
 version=2.40
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-shared --disable-static"
 hostmakedepends="pkg-config autoconf automake libtool"

From c5838d25f94c29e5e6f8d01b264795071047435e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 035/116] freerdp: revbump for ffmpeg-6.0

---
 .../freerdp/patches/ffmpeg6_aa2cb9aa.patch    | 42 +++++++++++++++++++
 srcpkgs/freerdp/template                      |  2 +-
 2 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch

diff --git a/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
new file mode 100644
index 000000000000..a4324da3a882
--- /dev/null
+++ b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
@@ -0,0 +1,42 @@
+From aa2cb9aa5ff5562433598ba168a466e0752bca0e Mon Sep 17 00:00:00 2001
+From: akallabeth <akallabeth@posteo.net>
+Date: Tue, 14 Feb 2023 07:48:54 +0100
+Subject: [PATCH] Fixed #8686: Update h264 to use new FFMPEG API
+
+---
+ channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c | 2 ++
+ libfreerdp/codec/h264_ffmpeg.c            | 2 ++
+ 2 files changed, 4 insertions(+)
+
+diff --git a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+index 339462d865f..beea80b7a1e 100644
+--- a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
++++ b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+@@ -239,8 +239,10 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYP
+ 		}
+ 	}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 	if (mdecoder->codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		mdecoder->codec_context->flags |= AV_CODEC_FLAG_TRUNCATED;
++#endif
+ 
+ 	return TRUE;
+ }
+diff --git a/libfreerdp/codec/h264_ffmpeg.c b/libfreerdp/codec/h264_ffmpeg.c
+index 8a23db2473c..896a333019b 100644
+--- a/libfreerdp/codec/h264_ffmpeg.c
++++ b/libfreerdp/codec/h264_ffmpeg.c
+@@ -615,10 +615,12 @@ static BOOL libavcodec_init(H264_CONTEXT* h264)
+ 			goto EXCEPTION;
+ 		}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 		if (sys->codecDecoder->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		{
+ 			sys->codecDecoderContext->flags |= AV_CODEC_FLAG_TRUNCATED;
+ 		}
++#endif
+ 
+ #ifdef WITH_VAAPI
+ 
diff --git a/srcpkgs/freerdp/template b/srcpkgs/freerdp/template
index 25e8aa9677f0..4d51c8189902 100644
--- a/srcpkgs/freerdp/template
+++ b/srcpkgs/freerdp/template
@@ -1,7 +1,7 @@
 # Template file for 'freerdp'
 pkgname=freerdp
 version=2.10.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_ALSA=ON -DWITH_CUPS=OFF -DWITH_FFMPEG=ON
  -DWITH_GSTREAMER_0_10=OFF -DWITH_GSTREAMER_1_0=OFF -DWITH_JPEG=ON

From 3212c26d8457baef7888b82d007dc73ff4eda3bf Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 036/116] gerbera: revbump for ffmpeg-6.0

---
 srcpkgs/gerbera/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gerbera/template b/srcpkgs/gerbera/template
index ae14f35c767c..2dc0ac0ce03b 100644
--- a/srcpkgs/gerbera/template
+++ b/srcpkgs/gerbera/template
@@ -1,7 +1,7 @@
 # Template file for 'gerbera'
 pkgname=gerbera
 version=1.12.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_SYSTEMD=0 -DWITH_AVCODEC=1"
 hostmakedepends="pkg-config"

From d27e72b70f07fb1af5a6bb66cfe433083966f942 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 037/116] goldendict: revbump for ffmpeg-6.0

---
 srcpkgs/goldendict/patches/ffmpeg4.patch |  21 --
 srcpkgs/goldendict/patches/ffmpeg5.patch | 232 +++++++++++++++++++++++
 srcpkgs/goldendict/template              |   2 +-
 3 files changed, 233 insertions(+), 22 deletions(-)
 delete mode 100644 srcpkgs/goldendict/patches/ffmpeg4.patch
 create mode 100644 srcpkgs/goldendict/patches/ffmpeg5.patch

diff --git a/srcpkgs/goldendict/patches/ffmpeg4.patch b/srcpkgs/goldendict/patches/ffmpeg4.patch
deleted file mode 100644
index f045fa27f54b..000000000000
--- a/srcpkgs/goldendict/patches/ffmpeg4.patch
+++ /dev/null
@@ -1,21 +0,0 @@
---- a/ffmpegaudio.cc.orig 2018-05-09 22:16:13.480659958 +0200
-+++ b/ffmpegaudio.cc      2018-05-09 22:16:50.748322790 +0200
-@@ -143,7 +143,7 @@
-     return false;
-   }
-
--  unsigned char * avioBuffer = ( unsigned char * )av_malloc( kBufferSize + FF_INPUT_BUFFER_PADDING_SIZE );
-+  unsigned char * avioBuffer = ( unsigned char * )av_malloc( kBufferSize + AV_INPUT_BUFFER_PADDING_SIZE );
-   if ( !avioBuffer )
-   {
-     errorString = QObject::tr( "av_malloc() failed." );
-@@ -380,7 +380,7 @@
-   }
-
-   if ( !Qt4x5::AtomicInt::loadAcquire( isCancelled_ ) &&
--       codecContext_->codec->capabilities & CODEC_CAP_DELAY )
-+       codecContext_->codec->capabilities & AV_CODEC_CAP_DELAY )
-   {
-     av_init_packet( &packet );
-     int gotFrame = 0;
-
diff --git a/srcpkgs/goldendict/patches/ffmpeg5.patch b/srcpkgs/goldendict/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..7cfc98ada368
--- /dev/null
+++ b/srcpkgs/goldendict/patches/ffmpeg5.patch
@@ -0,0 +1,232 @@
+From 03bbe01b79a1f07a6780cb60f23a087104c5d77b Mon Sep 17 00:00:00 2001
+From: Abs62 <ottomann@yandex.ru>
+Date: Fri, 30 Mar 2018 22:53:24 +0300
+Subject: [PATCH] Fix warnings while compile with FFMpeg 3.4.2 (issue #978)
+
+---
+ ffmpegaudio.cc | 68 +++++++++++++++++++++++++++++++++++++++++++++-----
+ 1 file changed, 62 insertions(+), 6 deletions(-)
+
+diff --git a/ffmpegaudio.cc b/ffmpegaudio.cc
+index ed1172bdd..56e8f788e 100644
+--- a/ffmpegaudio.cc
++++ b/ffmpegaudio.cc
+@@ -91,6 +91,7 @@ struct DecoderContext
+   QByteArray audioData_;
+   QDataStream audioDataStream_;
+   AVFormatContext * formatContext_;
++  AVCodec * codec_;
+   AVCodecContext * codecContext_;
+   AVIOContext * avioContext_;
+   AVStream * audioStream_;
+@@ -114,6 +115,7 @@ DecoderContext::DecoderContext( QByteArray const & audioData, QAtomicInt & isCan
+   audioData_( audioData ),
+   audioDataStream_( audioData_ ),
+   formatContext_( NULL ),
++  codec_( NULL ),
+   codecContext_( NULL ),
+   avioContext_( NULL ),
+   audioStream_( NULL ),
+@@ -143,7 +145,11 @@ bool DecoderContext::openCodec( QString & errorString )
+     return false;
+   }
+
++#if LIBAVCODEC_VERSION_MAJOR < 56 || ( LIBAVCODEC_VERSION_MAJOR == 56 && LIBAVCODEC_VERSION_MINOR < 56 )
+   unsigned char * avioBuffer = ( unsigned char * )av_malloc( kBufferSize + FF_INPUT_BUFFER_PADDING_SIZE );
++#else
++  unsigned char * avioBuffer = ( unsigned char * )av_malloc( kBufferSize + AV_INPUT_BUFFER_PADDING_SIZE );
++#endif
+   if ( !avioBuffer )
+   {
+     errorString = QObject::tr( "av_malloc() failed." );
+@@ -186,7 +192,11 @@ bool DecoderContext::openCodec( QString & errorString )
+   // Find audio stream, use the first audio stream if available
+   for ( unsigned i = 0; i < formatContext_->nb_streams; i++ )
+   {
++#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 33 )
+     if ( formatContext_->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO )
++#else
++      if ( formatContext_->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO )
++#endif
+     {
+       audioStream_ = formatContext_->streams[i];
+       break;
+@@ -198,22 +208,38 @@ bool DecoderContext::openCodec( QString & errorString )
+     return false;
+   }
+
++#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 33 )
+   codecContext_ = audioStream_->codec;
+-  AVCodec * codec = avcodec_find_decoder( codecContext_->codec_id );
+-  if ( !codec )
++  codec_ = avcodec_find_decoder( codecContext_->codec_id );
++  if ( !codec_ )
+   {
+     errorString = QObject::tr( "Codec [id: %1] not found." ).arg( codecContext_->codec_id );
+     return false;
+   }
++#else
++  codec_ = avcodec_find_decoder( audioStream_->codecpar->codec_id );
++  if ( !codec_ )
++  {
++    errorString = QObject::tr( "Codec [id: %1] not found." ).arg( audioStream_->codecpar->codec_id );
++    return false;
++  }
++  codecContext_ = avcodec_alloc_context3( codec_ );
++  if ( !codecContext_ )
++  {
++    errorString = QObject::tr( "avcodec_alloc_context3() failed." );
++    return false;
++  }
++  avcodec_parameters_to_context( codecContext_, audioStream_->codecpar );
++#endif
+
+-  ret = avcodec_open2( codecContext_, codec, NULL );
++  ret = avcodec_open2( codecContext_, codec_, NULL );
+   if ( ret < 0 )
+   {
+     errorString = QObject::tr( "avcodec_open2() failed: %1." ).arg( avErrorString( ret ) );
+     return false;
+   }
+
+-  av_log( NULL, AV_LOG_INFO, "Codec open: %s: channels: %d, rate: %d, format: %s\n", codec->long_name,
++  av_log( NULL, AV_LOG_INFO, "Codec open: %s: channels: %d, rate: %d, format: %s\n", codec_->long_name,
+           codecContext_->channels, codecContext_->sample_rate, av_get_sample_fmt_name( codecContext_->sample_fmt ) );
+   return true;
+ }
+@@ -252,10 +278,13 @@ void DecoderContext::closeCodec()
+
+   // Closing a codec context without prior avcodec_open2() will result in
+   // a crash in ffmpeg
+-  if ( audioStream_ && audioStream_->codec && audioStream_->codec->codec )
++  if ( audioStream_ && codecContext_ && codec_ )
+   {
+     audioStream_->discard = AVDISCARD_ALL;
+-    avcodec_close( audioStream_->codec );
++    avcodec_close( codecContext_ );
++#if LIBAVCODEC_VERSION_MAJOR > 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR >= 33 )
++    avcodec_free_context( &codecContext_ );
++#endif
+   }
+
+   avformat_close_input( &formatContext_ );
+@@ -356,6 +385,7 @@ bool DecoderContext::play( QString & errorString )
+     if ( packet.stream_index == audioStream_->index )
+     {
+       AVPacket pack = packet;
++#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 37 )
+       int gotFrame = 0;
+       do
+       {
+@@ -370,6 +400,19 @@ bool DecoderContext::play( QString & errorString )
+         pack.data += len;
+       }
+       while( pack.size > 0 );
++#else
++      int ret = avcodec_send_packet( codecContext_, &pack );
++      /* read all the output frames (in general there may be any number of them) */
++      while( ret >= 0 )
++      {
++        ret = avcodec_receive_frame( codecContext_, frame);
++
++        if ( Qt4x5::AtomicInt::loadAcquire( isCancelled_ ) || ret < 0 )
++          break;
++
++        playFrame( frame );
++      }
++#endif
+     }
+     // av_free_packet() must be called after each call to av_read_frame()
+ #if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 7 )
+@@ -379,6 +422,7 @@ bool DecoderContext::play( QString & errorString )
+ #endif
+   }
+
++#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 37 )
+   if ( !Qt4x5::AtomicInt::loadAcquire( isCancelled_ ) &&
+        codecContext_->codec->capabilities & CODEC_CAP_DELAY )
+   {
+@@ -391,6 +435,18 @@ bool DecoderContext::play( QString & errorString )
+       playFrame( frame );
+     }
+   }
++#else
++  /* flush the decoder */
++  av_init_packet( &packet );
++  int ret = avcodec_send_packet(codecContext_, &packet );
++  while( ret >= 0 )
++  {
++    ret = avcodec_receive_frame(codecContext_, frame);
++    if ( Qt4x5::AtomicInt::loadAcquire( isCancelled_ ) || ret < 0 )
++      break;
++    playFrame( frame );
++  }
++#endif
+
+ #if LIBAVCODEC_VERSION_MAJOR < 54
+   av_free( frame );
+32
+srcpkgs/goldendict/patches/ffmpeg5-2.patch
+Comment on this file
+@@ -0,0 +1,32 @@
+From 966f4a8b78e6324b930e5a50f2bb930bd87e565e Mon Sep 17 00:00:00 2001
+From: Abs62 <ottomann@yandex.ru>
+Date: Fri, 27 Sep 2019 17:00:52 +0300
+Subject: [PATCH] FFmpeg player: Fix some crashes on broken files
+
+---
+ ffmpegaudio.cc | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/ffmpegaudio.cc b/ffmpegaudio.cc
+index 56e8f788e..415fc79cb 100644
+--- a/ffmpegaudio.cc
++++ b/ffmpegaudio.cc
+@@ -51,7 +51,9 @@ AudioService & AudioService::instance()
+
+ AudioService::AudioService()
+ {
++#if LIBAVFORMAT_VERSION_MAJOR < 58 || ( LIBAVFORMAT_VERSION_MAJOR == 58 && LIBAVFORMAT_VERSION_MINOR < 9 )
+   av_register_all();
++#endif
+   ao_initialize();
+ }
+
+@@ -438,6 +440,8 @@ bool DecoderContext::play( QString & errorString )
+ #else
+   /* flush the decoder */
+   av_init_packet( &packet );
++  packet.data = NULL;
++  packet.size = 0;
+   int ret = avcodec_send_packet(codecContext_, &packet );
+   while( ret >= 0 )
+   {
+25
+srcpkgs/goldendict/patches/ffmpeg5-3.patch
+Comment on this file
+@@ -0,0 +1,25 @@
+From 8acb288c9e9bdb3c6bf2e803954dd3b6ac273c05 Mon Sep 17 00:00:00 2001
+From: Liao Junxuan <mikeljx@126.com>
+Date: Sun, 20 Feb 2022 12:28:05 +0800
+Subject: [PATCH] add support for ffmpeg 5.0
+
+---
+ ffmpegaudio.cc | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/ffmpegaudio.cc b/ffmpegaudio.cc
+index d550f4a77..7948d2187 100644
+--- a/ffmpegaudio.cc
++++ b/ffmpegaudio.cc
+@@ -94,7 +94,11 @@ struct DecoderContext
+   QByteArray audioData_;
+   QDataStream audioDataStream_;
+   AVFormatContext * formatContext_;
++#if LIBAVCODEC_VERSION_MAJOR < 59
+   AVCodec * codec_;
++#else
++  const AVCodec * codec_;
++#endif
+   AVCodecContext * codecContext_;
+   AVIOContext * avioContext_;
+   AVStream * audioStream_;
diff --git a/srcpkgs/goldendict/template b/srcpkgs/goldendict/template
index 4544ae710ee6..2ca4185e538a 100644
--- a/srcpkgs/goldendict/template
+++ b/srcpkgs/goldendict/template
@@ -9,7 +9,7 @@ makedepends="tiff-devel qt5-devel libvorbis-devel zlib-devel
  libXtst-devel hunspell-devel qt5-tools-devel qt5-declarative-devel
  qt5-webkit-devel lzo-devel bzip2-devel libao-devel qt5-svg-devel
  libeb-devel qt5-x11extras-devel ffmpeg-devel liblzma-devel"
-short_desc="A feature-rich dictionary lookup program"
+short_desc="Feature-rich dictionary lookup program"
 maintainer="John <me@johnnynator.dev>"
 license="GPL-3.0-or-later"
 homepage="http://goldendict.org/"

From 410ff9417abdfe5601746e1cc9640f61443195c2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 038/116] gst-libav: revbump for ffmpeg-6.0

---
 srcpkgs/gst-libav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index e9a79dc650a5..f082bd211c65 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.20.3
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"

From 3ca229f9cbb1b82d355cfedd400042f39bc0c93c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 039/116] gst-plugins-bad1: revbump for ffmpeg-6.0

---
 srcpkgs/gst-plugins-bad1/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index f55f82fd4c77..dc9d389734e1 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-plugins-bad1'
 pkgname=gst-plugins-bad1
-version=1.20.3
-revision=3
+version=1.22.2
+revision=2
 build_helper="gir"
 build_style=meson
 configure_args="-Dpackage-origin=https://voidlinux.org -Ddoc=disabled

From dba45aa016b4106a9b4b537119a73668a5b84f3d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 040/116] gst-rtsp-server: revbump for ffmpeg-6.0

---
 srcpkgs/gst-rtsp-server/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index 33cd64ceb95e..8ceea8d34b4b 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
 version=1.20.3
-revision=2
+revision=3
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="glib-devel gst-plugins-bad1-devel gobject-introspection

From ed9ee577d0e123c846f1277b048fcc3ae5588e3c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 041/116] guvcview: update to 2.0.8.

---
 srcpkgs/guvcview/patches/fix-include.patch | 10 ++++++++++
 srcpkgs/guvcview/template                  |  5 ++---
 2 files changed, 12 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/guvcview/patches/fix-include.patch

diff --git a/srcpkgs/guvcview/patches/fix-include.patch b/srcpkgs/guvcview/patches/fix-include.patch
new file mode 100644
index 000000000000..503c2af3b78c
--- /dev/null
+++ b/srcpkgs/guvcview/patches/fix-include.patch
@@ -0,0 +1,10 @@
+--- a/guvcview/guvcview.c
++++ b/guvcview/guvcview.c
+@@ -28,6 +28,7 @@
+ #include <sys/stat.h>
+ #include <sys/resource.h>
+ #include <errno.h>
++#include <locale.h>
+ 
+ #include "gview.h"
+ #include "gviewv4l2core.h"
diff --git a/srcpkgs/guvcview/template b/srcpkgs/guvcview/template
index 345cf6006f24..86a7fd619612 100644
--- a/srcpkgs/guvcview/template
+++ b/srcpkgs/guvcview/template
@@ -1,8 +1,7 @@
 # Template file for 'guvcview'
 pkgname=guvcview
-version=2.0.7
+version=2.0.8
 revision=1
-create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-static --disable-debian-menu"
 hostmakedepends="pkg-config intltool autoconf automake libtool glib-devel"
@@ -14,7 +13,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="http://guvcview.sourceforge.net/"
 distfiles="${SOURCEFORGE_SITE}/${pkgname}/${pkgname}-src-${version}.tar.bz2"
-checksum=f47d51fbd06e44eeaa1a82f4a153c927527c90d94514197a70b2956028cc8ad4
+checksum=a21f4e448286666cf27bafef5290cc953a0a1796b752e5bbe521266dc1230c81
 
 post_patch() {
 	sed '31a#include <locale.h>' -i  guvcview/guvcview.c

From 3763ee371670e1a2c5cf111cbac598e276f6bf47 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 042/116] handbrake: update to 1.6.1

---
 .../patches/fix-missing-x265-link-flag.patch    | 11 ++++++-----
 .../handbrake/patches/libhb-vpl-include.patch   | 15 +++++++++++++++
 srcpkgs/handbrake/template                      | 17 ++++++++++-------
 3 files changed, 31 insertions(+), 12 deletions(-)
 create mode 100644 srcpkgs/handbrake/patches/libhb-vpl-include.patch

diff --git a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
index 26db03867a0c..d6bb2eda627a 100644
--- a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
+++ b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
@@ -1,14 +1,15 @@
 --- a/gtk/configure.ac
 +++ b/gtk/configure.ac
 @@ -203,7 +203,7 @@
- 
+
  AM_CONDITIONAL([MINGW], [test "x$mingw_flag" = "xyes"])
- 
--HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg"
-+HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -ldl"
+
+-HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc"
++HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc -ldl"
  HB_CPPFLAGS="$HB_CPPFLAGS $HBINC"
- 
+
  PKG_CHECK_MODULES([x264], [x264], sys_x264=yes, sys_x264=no)
+
 --- a/test/module.defs
 +++ b/test/module.defs
 @@ -69,6 +69,9 @@
diff --git a/srcpkgs/handbrake/patches/libhb-vpl-include.patch b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
new file mode 100644
index 000000000000..298f9f4ab28f
--- /dev/null
+++ b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
@@ -0,0 +1,15 @@
+--- a/libhb/module.defs	2023-01-22 11:36:49.000000000 -0500
++++ b/libhb/module.defs	2023-04-03 22:37:52.395467010 -0400
+@@ -46,11 +46,7 @@
+ LIBHB.GCC.I += $(LIBHB.build/) $(CONTRIB.build/)include
+ 
+ ifeq (1,$(FEATURE.qsv))
+-    ifeq ($(HOST.system),freebsd))
+-        LIBHB.GCC.I += $(LOCALBASE)/include/vpl
+-    else
+-        LIBHB.GCC.I += $(CONTRIB.build/)include/vpl
+-    endif
++    LIBHB.GCC.I += /usr/include/vpl
+ endif
+ 
+ ifneq (,$(filter $(HOST.system),freebsd netbsd openbsd))
diff --git a/srcpkgs/handbrake/template b/srcpkgs/handbrake/template
index ca5e4571e49c..c32cb1bfa31f 100644
--- a/srcpkgs/handbrake/template
+++ b/srcpkgs/handbrake/template
@@ -1,10 +1,10 @@
 # Template file for 'handbrake'
 pkgname=handbrake
-version=1.5.1
+version=1.6.1
 revision=1
 build_style=gnu-configure
 configure_args="--force --disable-gtk-update-checks --disable-df-fetch --harden
- $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc)"
+ $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc) $(vopt_enable qsv)"
 make_build_args="-C ${XBPS_TRIPLET}"
 make_install_args="-C ${XBPS_TRIPLET}"
 hostmakedepends="automake cmake gettext-devel glib-devel intltool libtool m4 meson nasm pkg-config python3"
@@ -12,8 +12,11 @@ makedepends="bzip2-devel ffmpeg-devel gst-plugins-base1-devel gtk+3-devel
  jansson-devel lame-devel libass-devel libbluray-devel libdav1d-devel
  libdvdnav-devel libdvdread-devel libgudev-devel libnuma-devel
  libsamplerate-devel libtheora-devel libvorbis-devel libvpx-devel libxml2-devel
- opus-devel speex-devel x264-devel x265-devel zimg-devel
+ opus-devel speex-devel x264-devel x265-devel zimg-devel libsvt-av1-devel
  $(vopt_if fdk_aac fdk-aac-devel)
+ $(vopt_if qsv libva-devel)
+ $(vopt_if qsv libdrm-devel)
+ $(vopt_if qsv onevpl-devel)
  $(vopt_if nvenc nv-codec-headers)"
 depends="desktop-file-utils gst-plugins-good1 hicolor-icon-theme"
 short_desc="Multithreaded video transcoder"
@@ -21,15 +24,15 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-2.0-only"
 homepage="https://handbrake.fr/"
 distfiles="https://github.com/HandBrake/HandBrake/releases/download/${version}/HandBrake-${version}-source.tar.bz2"
-checksum=3999fe06d5309c819799a73a968a8ec3840e7840c2b64af8f5cdb7fd8c9430f0
+checksum=94ccfe03db917a91650000c510f7fd53f844da19f19ad4b4be1b8f6bc31a8d4c
 nocross=yes
 
-build_options="fdk_aac nvenc"
+build_options="fdk_aac nvenc qsv"
 
 case "$XBPS_TARGET_MACHINE" in
 	x86_64*|i686*)
 		CFLAGS="-msse"
-		build_options_default="nvenc"
+		build_options_default="nvenc qsv"
 		;;
 esac
 
@@ -37,7 +40,7 @@ pre_configure() {
 	# use system libraries, don't download them
 	rm -rf contrib/
 	for module in fdk-aac ffmpeg libbluray libdav1d libdvdnav libdvdread nvenc \
-		x265 zimg; do
+		x265 zimg svt-av1 libvpl; do
 	    vsed -i "/MODULES += contrib\/${module}/d" make/include/main.defs
 	done
 }

From a70373f366cfaefb473ff92a2e020b14edcb0c46 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 043/116] hedgewars: revbump for ffmpeg4-4.4.3

---
 srcpkgs/hedgewars/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/hedgewars/template b/srcpkgs/hedgewars/template
index 419f29b98b44..926fe4fe3e68 100644
--- a/srcpkgs/hedgewars/template
+++ b/srcpkgs/hedgewars/template
@@ -1,13 +1,13 @@
 # Template file for 'hedgewars'
 pkgname=hedgewars
 version=1.0.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DNOSERVER=1 -DDATA_INSTALL_DIR=/usr/share/${pkgname}
  -DPHYSFS_SYSTEM=1 -DMINIMAL_FLAGS=1"
 make_cmd=make
 hostmakedepends="lua51 pkg-config qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
+makedepends="ffmpeg4-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
  SDL2_mixer-devel SDL2_net-devel SDL2_ttf-devel"
 depends="libfreeglut"
 short_desc="Funny turn-based artillery game, featuring fighting Hedgehogs!"

From 42189440ee2ae946575745013b00a66dd20c53f9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 044/116] idjc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/idjc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/idjc/template b/srcpkgs/idjc/template
index df60318b3db9..36a75baf597c 100644
--- a/srcpkgs/idjc/template
+++ b/srcpkgs/idjc/template
@@ -1,11 +1,11 @@
 # Template file for 'idjc'
 pkgname=idjc
 version=0.9.1
-revision=3
+revision=4
 build_style=gnu-configure
 hostmakedepends="pkg-config git python3 automake gettext-devel libtool"
 makedepends="libvorbis-devel libogg-devel jack-devel libsamplerate-devel
- libflac-devel libsndfile-devel mpg123-devel ffmpeg-devel speex-devel
+ libflac-devel libsndfile-devel mpg123-devel ffmpeg4-devel speex-devel
  glib-devel pixman-devel lame-devel python3-gobject-devel libshout-idjc-devel
  opus-devel twolame-devel python3-mutagen python3-devel"
 depends="python3-gobject python3-mutagen desktop-file-utils shared-mime-info python3-dbus jack"

From 7b09d9e3024100afd0a60a35b8194ede23fb651b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 045/116] kfilemetadata5: revbump for ffmpeg-6.0

---
 srcpkgs/kfilemetadata5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kfilemetadata5/template b/srcpkgs/kfilemetadata5/template
index 4b91cf19f298..a3671a38ce59 100644
--- a/srcpkgs/kfilemetadata5/template
+++ b/srcpkgs/kfilemetadata5/template
@@ -1,7 +1,7 @@
 # Template file for 'kfilemetadata5'
 pkgname=kfilemetadata5
 version=5.107.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="kcoreaddons extra-cmake-modules pkg-config qt5-host-tools qt5-qmake
  gettext kcoreaddons python3"

From c6e9505bff93aa5b56f4c27c668aa11c5580320a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 046/116] kid3: revbump for ffmpeg-6.0

---
 srcpkgs/kid3/patches/ffmpeg5.patch | 17 +++++++++++++++++
 srcpkgs/kid3/template              |  2 +-
 2 files changed, 18 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/kid3/patches/ffmpeg5.patch

diff --git a/srcpkgs/kid3/patches/ffmpeg5.patch b/srcpkgs/kid3/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..135fc50e07c9
--- /dev/null
+++ b/srcpkgs/kid3/patches/ffmpeg5.patch
@@ -0,0 +1,17 @@
+# https://aur.archlinux.org/cgit/aur.git/diff/ffmpeg5.patch?h=kid3-cli&id=12410a74906612e7efc0ec8fbce739b4a0fef7e7
+diff --git a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+index e156d424..e12b9abd 100644
+--- a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
++++ b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+@@ -232,7 +232,11 @@ private:
+   friend class Format;
+   friend class Converter;
+   AVCodecContext* m_ptr;
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 0, 0)
+   AVCodec* m_impl;
++#else
++  const AVCodec* m_impl;
++#endif
+   AVFrame* m_frame;
+   bool m_opened;
+ };
diff --git a/srcpkgs/kid3/template b/srcpkgs/kid3/template
index 456206d90e16..f32f9decb0e7 100644
--- a/srcpkgs/kid3/template
+++ b/srcpkgs/kid3/template
@@ -1,7 +1,7 @@
 # Template file for 'kid3'
 pkgname=kid3
 version=3.9.1
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DWITH_APPS='CLI;$(vopt_if KDE KDE Qt)'
  -DWITH_DOCBOOKDIR=/usr/share/xsl/docbook -DWITH_FLAC=$(vopt_if flac ON OFF)

From 4baabab6405255cdb5013f34d0aa54aa1929e84b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 047/116] kodi: revbump for ffmpeg4-4.4.3

---
 srcpkgs/kodi/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/kodi/template b/srcpkgs/kodi/template
index 8057964d78a3..6cc1874be7ba 100644
--- a/srcpkgs/kodi/template
+++ b/srcpkgs/kodi/template
@@ -1,7 +1,7 @@
 # Template file for 'kodi'
 pkgname=kodi
 version=19.4
-revision=6
+revision=7
 _codename="Matrix"
 build_style=cmake
 configure_args="-DWITH_FFMPEG=/usr -DENABLE_LDGOLD=OFF
@@ -54,7 +54,7 @@ makedepends="
  libmad-devel fontconfig-devel libXinerama-devel libsamplerate-devel libmms-devel
  enca-devel boost-devel libcurl-devel libva-devel libvdpau-devel libass-devel
  libbluetooth-devel yajl-devel libplist-devel librtmp-devel tinyxml-devel
- taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg-devel
+ taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg4-devel
  giflib-devel libxslt-devel gnutls-devel libssh-devel libmicrohttpd-devel
  libcec-devel dcadec-devel flatbuffers-devel fmt-devel lcms2-devel
  libfstrcmp-devel rapidjson libcdio-paranoia spdlog libwaylandpp-devel

From a4932ae5644f02e0eecabb54dc5b1f74e9ff1db1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 048/116] kpipewire: revbump for ffmpeg-6.0

---
 srcpkgs/kpipewire/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kpipewire/template b/srcpkgs/kpipewire/template
index 05ad025944da..7aa120e6ba94 100644
--- a/srcpkgs/kpipewire/template
+++ b/srcpkgs/kpipewire/template
@@ -1,7 +1,7 @@
 # Template file for 'kpipewire'
 pkgname=kpipewire
 version=5.27.5
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules plasma-wayland-protocols gettext
  qt5-qmake qt5-host-tools pkg-config wayland-devel kcoreaddons

From 4416565a2b487616152e9e6fc8bc78c20cc6ca75 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 049/116] libextractor: revbump for ffmpeg4-4.4.3

---
 srcpkgs/libextractor/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libextractor/template b/srcpkgs/libextractor/template
index ddd4790f93e8..1fb9ca56a96a 100644
--- a/srcpkgs/libextractor/template
+++ b/srcpkgs/libextractor/template
@@ -7,7 +7,7 @@ configure_args="--disable-static"
 hostmakedepends="pkg-config"
 makedepends="zlib-devel bzip2-devel exiv2-devel tiff-devel libpng-devel
  libjpeg-turbo-devel libvorbis-devel libflac-devel giflib-devel libmpeg2-devel
- ffmpeg-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
+ ffmpeg4-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
 short_desc="Library used to extract meta data from files"
 maintainer="Martin Riese <grauehaare@gmx.de>"
 license="GPL-3.0-or-later"

From a6f57548d2f982182620b83174f0371a738aef5a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 050/116] libopenal: revbump for ffmpeg-6.0

---
 srcpkgs/libopenal/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenal/template b/srcpkgs/libopenal/template
index 77218f9e539d..3f49ed75a1fd 100644
--- a/srcpkgs/libopenal/template
+++ b/srcpkgs/libopenal/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenal'
 pkgname=libopenal
 version=1.22.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DALSOFT_EXAMPLES=OFF"
 hostmakedepends="pkg-config"

From 6d909f4b710f7d3d18b2e34e733352f33bfe1bbd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 051/116] libopenshot: revbump for ffmpeg-6.0

---
 srcpkgs/libopenshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenshot/template b/srcpkgs/libopenshot/template
index db831f69b474..81aa0d7136d9 100644
--- a/srcpkgs/libopenshot/template
+++ b/srcpkgs/libopenshot/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenshot'
 pkgname=libopenshot
 version=0.3.0
-revision=1
+revision=2
 build_style=cmake
 # Builds fail with Ruby-2.4.1
 configure_args="-DENABLE_RUBY=OFF -DUSE_SYSTEM_JSONCPP=ON"

From 31280e2a8f98ab01a63e72a4b9f62bc04037324b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 052/116] loudgain: revbump for ffmpeg-6.0

---
 srcpkgs/loudgain/patches/ffmpeg5.patch | 11 +++++++++++
 srcpkgs/loudgain/template              |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/loudgain/patches/ffmpeg5.patch

diff --git a/srcpkgs/loudgain/patches/ffmpeg5.patch b/srcpkgs/loudgain/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..16d4510ee98f
--- /dev/null
+++ b/srcpkgs/loudgain/patches/ffmpeg5.patch
@@ -0,0 +1,11 @@
+--- a/src/scan.c	2019-09-06 11:31:19.000000000 -0400
++++ b/src/scan.c	2023-03-23 11:15:40.867968521 -0400
+@@ -69,8 +69,6 @@
+ 	 * It is now useless
+ 	 * https://github.com/FFmpeg/FFmpeg/blob/70d25268c21cbee5f08304da95be1f647c630c15/doc/APIchanges#L86
+ 	 */
+-  if (avformat_version() < AV_VERSION_INT(58,9,100))
+-    av_register_all();
+ 
+ 	av_log_set_callback(scan_av_log);
+ 
diff --git a/srcpkgs/loudgain/template b/srcpkgs/loudgain/template
index da4f2d56e94c..4d6bf29efb4f 100644
--- a/srcpkgs/loudgain/template
+++ b/srcpkgs/loudgain/template
@@ -1,7 +1,7 @@
 # Template file for 'loudgain'
 pkgname=loudgain
 version=0.6.8
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libebur128-devel taglib-devel ffmpeg-devel"

From 77ba832ffbc237050ebc6e2cdf529577e4e9091f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 053/116] mediastreamer: revbump for ffmpeg4-4.4.3

---
 srcpkgs/mediastreamer/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mediastreamer/template b/srcpkgs/mediastreamer/template
index d0e97e858e29..1bde031443a5 100644
--- a/srcpkgs/mediastreamer/template
+++ b/srcpkgs/mediastreamer/template
@@ -1,11 +1,11 @@
 # Template file for 'mediastreamer'
 pkgname=mediastreamer
 version=5.2.6
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_STRICT=0 -DENABLE_UNIT_TESTS=0"
 hostmakedepends="python3"
-makedepends="bzrtp-devel ffmpeg-devel glew-devel libXv-devel libsrtp-devel
+makedepends="bzrtp-devel ffmpeg4-devel glew-devel libXv-devel libsrtp-devel
  libupnp-devel libvpx-devel mbedtls-devel opus-devel ortp-devel pulseaudio-devel
  libtheora-devel speex-devel v4l-utils-devel bcg729-devel bcmatroska2-devel libgsm-devel"
 # zxing-cpp-devel (1.2.0 probably not compatible, check again after updaing xzing)

From ba16569021e631c12608de3859250d9e218ab3cd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 054/116] mgba: revbump for ffmpeg-6.0

---
 srcpkgs/mgba/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mgba/template b/srcpkgs/mgba/template
index ae0504311eee..d31295a0cd3d 100644
--- a/srcpkgs/mgba/template
+++ b/srcpkgs/mgba/template
@@ -1,7 +1,7 @@
 # Template file for 'mgba'
 pkgname=mgba
 version=0.10.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake desktop-file-utils"
 makedepends="SDL2-devel ffmpeg-devel libedit-devel libepoxy-devel libmagick-devel

From b8bc50342c39aad2ec682a72c3036d598dad3494 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 055/116] minidlna: revbump for ffmpeg-6.0

---
 srcpkgs/minidlna/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/minidlna/template b/srcpkgs/minidlna/template
index e8081b1cbc67..9ee9714861fd 100644
--- a/srcpkgs/minidlna/template
+++ b/srcpkgs/minidlna/template
@@ -1,7 +1,7 @@
 # Template file for 'minidlna'
 pkgname=minidlna
 version=1.3.2
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="
  --sbindir=/usr/bin

From ca9dda719ec4c709d91b1c39fed31747d6f7a3df Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 056/116] mixxx: revbump for ffmpeg-6.0

---
 srcpkgs/mixxx/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mixxx/template b/srcpkgs/mixxx/template
index 619ddca0d332..4b9ea00d3fb3 100644
--- a/srcpkgs/mixxx/template
+++ b/srcpkgs/mixxx/template
@@ -1,7 +1,7 @@
 # Template file for 'mixxx'
 pkgname=mixxx
 version=2.3.3
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="extra-cmake-modules pkg-config protobuf qt5-host-tools qt5-devel"

From d3689448ee7c7b2cb8d3e37b7a943a8b5666e14b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 057/116] mlt: revbump for ffmpeg4-4.4.3

---
 srcpkgs/mlt/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mlt/template b/srcpkgs/mlt/template
index 8933eb4e7bb9..73353fedafb5 100644
--- a/srcpkgs/mlt/template
+++ b/srcpkgs/mlt/template
@@ -1,14 +1,14 @@
 # Template file for 'mlt'
 pkgname=mlt
 version=6.26.1
-revision=1
+revision=2
 build_style=configure
 configure_args="--prefix=/usr --libdir=/usr/lib$XBPS_TARGET_WORDSIZE
  --enable-gpl --enable-gpl3 --disable-swfdec --without-kde
  --swig-languages=python"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which"
 # XXX: movit vid.stab
-makedepends="alsa-lib-devel ffmpeg-devel gtk+-devel jack-devel ladspa-sdk
+makedepends="alsa-lib-devel ffmpeg4-devel gtk+-devel jack-devel ladspa-sdk
  libexif-devel libsamplerate-devel libxml2-devel sox-devel SDL_image-devel
  fftw-devel frei0r-plugins python3-devel pulseaudio-devel movit-devel
  libvidstab-devel libatomic-devel"

From 29861bc3572526793c4af06263113d08a36dd627 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 058/116] moc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/moc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/moc/template b/srcpkgs/moc/template
index c42be650a1d2..d4f0eefbad52 100644
--- a/srcpkgs/moc/template
+++ b/srcpkgs/moc/template
@@ -1,10 +1,10 @@
 # Template file for 'moc'
 pkgname=moc
 version=2.5.2
-revision=6
+revision=7
 build_style=gnu-configure
 hostmakedepends="pkg-config"
-makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg-devel
+makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg4-devel
  jack-devel alsa-lib-devel libltdl-devel libflac-devel libvorbis-devel
  libmad-devel libmpcdec-devel libmodplug-devel libid3tag-devel faad2-devel
  taglib-devel libsndfile-devel wavpack-devel speex-devel libsamplerate-devel

From 950200b5c1feb31dc547c5765fc33b85208894fb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 059/116] motion: revbump for ffmpeg-6.0

---
 srcpkgs/motion/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/motion/template b/srcpkgs/motion/template
index 3cf3c3035c5b..7dca12d851e3 100644
--- a/srcpkgs/motion/template
+++ b/srcpkgs/motion/template
@@ -1,7 +1,7 @@
 # Template file for 'motion'
 pkgname=motion
 version=4.5.1
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake pkg-config gettext-devel tar"
 makedepends="ffmpeg-devel libmicrohttpd-devel v4l-utils-devel gettext-devel"

From 6adc08cf921cf1e5562e91e15e1680a90c33ca3b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 060/116] mpv: revbump for ffmpeg-6.0

---
 srcpkgs/mpv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpv/template b/srcpkgs/mpv/template
index e163c496c6eb..d4fefbf5e3c7 100644
--- a/srcpkgs/mpv/template
+++ b/srcpkgs/mpv/template
@@ -1,7 +1,7 @@
 # Template file for 'mpv'
 pkgname=mpv
 version=0.35.1
-revision=2
+revision=3
 build_style=meson
 configure_args="-Dcdda=enabled -Ddvbin=enabled -Ddvdnav=enabled
  -Dlibmpv=true -Dcplugins=enabled

From 183097904e73843b681e8c131e5c7f3efc950121 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 061/116] musikcube: revbump for ffmpeg-6.0

---
 srcpkgs/musikcube/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/musikcube/template b/srcpkgs/musikcube/template
index 7c569303c054..a4dea460c371 100644
--- a/srcpkgs/musikcube/template
+++ b/srcpkgs/musikcube/template
@@ -1,7 +1,7 @@
 # Template file for 'musikcube'
 pkgname=musikcube
 version=3.0.0
-revision=1
+revision=2
 build_style=cmake
 make_cmd=make
 configure_args="-DNO_NCURSESW=1"

From d2f0dcdc6db172eb73dab3e3449c02e11d7b18b8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 062/116] notcurses: revbump for ffmpeg-6.0

---
 srcpkgs/notcurses/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/notcurses/template b/srcpkgs/notcurses/template
index 6dd8a091319f..3110c30c9aff 100644
--- a/srcpkgs/notcurses/template
+++ b/srcpkgs/notcurses/template
@@ -1,7 +1,7 @@
 # Template file for 'notcurses'
 pkgname=notcurses
 version=3.0.9
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DUSE_STATIC=ON $(vopt_bool man USE_PANDOC)"
 hostmakedepends="pkg-config $(vopt_if man pandoc)"

From 5bd54c528311c6739754e9e92eb798b98db41561 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 063/116] obs: revbump for ffmpeg-6.0

---
 srcpkgs/obs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/obs/template b/srcpkgs/obs/template
index 7b69c630d30d..2c8d68d71f3a 100644
--- a/srcpkgs/obs/template
+++ b/srcpkgs/obs/template
@@ -1,7 +1,7 @@
 # Template file for 'obs'
 pkgname=obs
 version=29.1.2
-revision=1
+revision=2
 archs="i686* x86_64* ppc64le* aarch64*"
 build_style=cmake
 configure_args="-DOBS_VERSION_OVERRIDE=${version} -DENABLE_JACK=ON

From 6eba96ee56a77c3df9e9202754c893f50bd4eb75 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 064/116] olive: revbump for ffmpeg4-4.4.3

---
 srcpkgs/olive/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/olive/template b/srcpkgs/olive/template
index 12a46936c990..5c2917b9c512 100644
--- a/srcpkgs/olive/template
+++ b/srcpkgs/olive/template
@@ -1,10 +1,10 @@
 # Template file for 'olive'
 pkgname=olive
 version=0.1.2
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools pkg-config"
-makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg-devel frei0r-plugins"
+makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg4-devel frei0r-plugins"
 short_desc="Non-linear video editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"

From 71228bf6e4134e003748b31cc0c4147006da02bd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 065/116] omxplayer: revbump for ffmpeg4-4.4.3

---
 srcpkgs/omxplayer/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/omxplayer/template b/srcpkgs/omxplayer/template
index e70bf7873d4d..0e9bc70e7c8e 100644
--- a/srcpkgs/omxplayer/template
+++ b/srcpkgs/omxplayer/template
@@ -1,10 +1,10 @@
 # Template file for 'omxplayer'
 pkgname=omxplayer
 version=20190102
-revision=1
+revision=2
 short_desc="Commandline OMX player for the Raspberry Pi"
 maintainer="Orphaned <orphan@voidlinux.org>"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://github.com/popcornmix/omxplayer"
 
 _commit="f06235cc9690a6d58187514452df8cf8fcdaacec"
@@ -15,7 +15,7 @@ checksum=af2d9450f8947842ea8c401fe9f71eec444013ebbdee29f2ac828c9c493c1329
 archs="armv6l* armv7l*"
 build_style=gnu-makefile
 hostmakedepends="curl pkg-config"
-makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg-devel dbus-devel"
+makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg4-devel dbus-devel"
 depends="freefont-ttf"
 
 do_build() {

From 13c6631c0f5e5f971bae22b19e4240557656409f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 066/116] openimageio: revbump for ffmpeg-6.0

---
 common/shlibs                | 2 ++
 srcpkgs/openimageio/template | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/shlibs b/common/shlibs
index ce0c518f00ef..2820e834d136 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2259,6 +2259,8 @@ libxmp.so.4 libxmp-4.3.7_1
 libKF5ThreadWeaver.so.5 threadweaver-5.26.0_1
 libOpenImageIO_Util.so.2.4 openimageio-2.4.9.0_1
 libOpenImageIO.so.2.4 openimageio-2.4.9.0_1
+libOpenImageIO_Util.so.2.4 openimageio-2.4.8.1_1
+libOpenImageIO.so.2.4 openimageio-2.4.8.1_1
 libOpenColorIO.so.2.1 opencolorio-2.1.2_1
 libpystring.so.1 pystring-1.1.3_1
 libyaml-cpp.so.0.7 yaml-cpp-0.7.0_1
diff --git a/srcpkgs/openimageio/template b/srcpkgs/openimageio/template
index c2d36b4b3539..0e9e22e9685d 100644
--- a/srcpkgs/openimageio/template
+++ b/srcpkgs/openimageio/template
@@ -1,7 +1,7 @@
 # Template file for 'openimageio'
 pkgname=openimageio
 version=2.4.9.0
-revision=4
+revision=5
 build_style=cmake
 build_helper=qemu
 configure_args="-DUSE_QT=0 -DUSE_PYTHON=0 -DOIIO_BUILD_TESTS=0

From 1ee0d8161c471a5692be6bb6e45b69e9a62bf902 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 067/116] openshot: revbump for ffmpeg-6.0

---
 srcpkgs/openshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openshot/template b/srcpkgs/openshot/template
index 322717d40abc..c074e0338773 100644
--- a/srcpkgs/openshot/template
+++ b/srcpkgs/openshot/template
@@ -1,7 +1,7 @@
 # Template file for 'openshot'
 pkgname=openshot
 version=3.0.0
-revision=1
+revision=2
 build_style=python3-module
 hostmakedepends="python3 python3-setuptools"
 makedepends="ffmpeg-devel python3-PyQt5"

From c7a6759e25aefaf38821bf92081dde79495ef27d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 068/116] opentoonz: revbump for ffmpeg-6.0

---
 srcpkgs/opentoonz/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/opentoonz/template b/srcpkgs/opentoonz/template
index ee9f7603f55f..3e81834ca0ed 100644
--- a/srcpkgs/opentoonz/template
+++ b/srcpkgs/opentoonz/template
@@ -1,7 +1,7 @@
 # Template file for 'opentoonz'
 pkgname=opentoonz
 version=1.6.0
-revision=2
+revision=3
 build_wrksrc="toonz/sources"
 build_style=cmake
 make_cmd=make

From fad508c83a45f4bfaf30e7e50cfa334bcda260dd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 069/116] pianobar: revbump for ffmpeg-6.0

---
 srcpkgs/pianobar/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pianobar/template b/srcpkgs/pianobar/template
index a9b29e91993f..81efcd122c4d 100644
--- a/srcpkgs/pianobar/template
+++ b/srcpkgs/pianobar/template
@@ -1,7 +1,7 @@
 # Template file for 'pianobar'
 pkgname=pianobar
 version=2022.04.01
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="V=1"
 hostmakedepends="pkg-config"

From 67e78de87557110085901b1adad873d7dd3f7159 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 070/116] ppsspp: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ppsspp/template | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/ppsspp/template b/srcpkgs/ppsspp/template
index 7984a733d4be..15a42fd2c993 100644
--- a/srcpkgs/ppsspp/template
+++ b/srcpkgs/ppsspp/template
@@ -1,7 +1,7 @@
 # Template file for 'ppsspp'
 pkgname=ppsspp
 version=1.14.4
-revision=1
+revision=2
 _glslang_commit=dc11adde23c455a24e13dd54de9b4ede8bdd7db8
 _SPIRV_Cross_commit=9acb9ec31f5a8ef80ea6b994bb77be787b08d3d1
 _armips_commit=6719edebaae03330ee5441d9b28280672edf00d5
@@ -13,7 +13,7 @@ configure_args="-DHEADLESS=1 -DUSE_SYSTEM_FFMPEG=1 -DUNITTEST=ON
  -DUSING_QT_UI=$(vopt_if qt ON OFF) -DUSE_SYSTEM_ZSTD=ON
  -DARMIPS_USE_STD_FILESYSTEM=ON"
 hostmakedepends="pkg-config python3 $(vopt_if qt qt5-host-tools)"
-makedepends="zlib-devel glew-devel ffmpeg-devel libzip-devel
+makedepends="zlib-devel glew-devel ffmpeg4-devel libzip-devel
  snappy-devel rapidjson libpng-devel libzstd-devel
  $(vopt_if sdl2 SDL2-devel) $(vopt_if wayland wayland-devel)
  $(vopt_if qt 'qt5-devel qt5-multimedia-devel')"
@@ -62,13 +62,12 @@ post_extract() {
 	mv ${wrksrc}/miniupnp-${_miniupnp_commit} ${wrksrc}/ext/miniupnp
 }
 
-post_patch(){
+post_patch() {
 	# disable git versioning
 	vsed -e 's|find_package(Git)|# &|' -i git-version.cmake
 }
 
 do_install() {
-	vlicense LICENSE.TXT
 	vinstall icons/icon.svg 644 usr/share/pixmaps ppsspp.svg
 	vinstall Qt/PPSSPP.desktop 644 usr/share/applications
 	vbin build/PPSSPPHeadless ppsspp-headless

From 2bdb128835e369e030c53dd1f7abbec835d585ee Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 071/116] pqiv: revbump for ffmpeg-6.0

---
 srcpkgs/pqiv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pqiv/template b/srcpkgs/pqiv/template
index 542fc27a2d32..9308d949b6a1 100644
--- a/srcpkgs/pqiv/template
+++ b/srcpkgs/pqiv/template
@@ -1,7 +1,7 @@
 # Template file for 'pqiv'
 pkgname=pqiv
 version=2.12
-revision=1
+revision=2
 build_style=gnu-makefile
 hostmakedepends="pkg-config"
 makedepends="glib-devel gtk+3-devel $(vopt_if ffmpeg ffmpeg-devel)

From 81506c89203f93e795e5fcec85835fd725820a51 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 072/116] qmmp: revbump for ffmpeg-6.0

---
 srcpkgs/qmmp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qmmp/template b/srcpkgs/qmmp/template
index 26c661ed16be..a150d7441c7a 100644
--- a/srcpkgs/qmmp/template
+++ b/srcpkgs/qmmp/template
@@ -1,7 +1,7 @@
 # Template file for 'qmmp'
 pkgname=qmmp
 version=1.6.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DUSE_HAL:BOOL=FALSE -DQMMP_DEFAULT_UI:STRING=simple"
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From 7bedda21dcae720db1bf93bc610b35a5c68afe7e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 073/116] qt5-webengine: update to 5.15.13

---
 .../chromium-media-filters-cpp14.patch        |  11 ++
 srcpkgs/qt5-webengine/patches/ffmpeg5.patch   | 179 ++++++++++++++++++
 srcpkgs/qt5-webengine/template                |  10 +-
 3 files changed, 195 insertions(+), 5 deletions(-)
 create mode 100644 srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/ffmpeg5.patch

diff --git a/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
new file mode 100644
index 000000000000..04adc540f2cb
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
@@ -0,0 +1,11 @@
+--- a/src/3rdparty/chromium/media/filters/BUILD.gn	2023-02-27 13:32:59.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/BUILD.gn	2023-04-02 17:21:39.204066384 -0400
+@@ -96,6 +96,8 @@
+     "//ui/gfx/geometry:geometry",
+   ]
+ 
++  cflags_cc = [ "-std=c++14" ]
++
+   libs = []
+ 
+   if (proprietary_codecs) {
diff --git a/srcpkgs/qt5-webengine/patches/ffmpeg5.patch b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..ac55e1634423
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
@@ -0,0 +1,179 @@
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:57.732547446 -0400
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:09.486478995 -0400
+@@ -57,6 +57,8 @@
+ 
+ namespace {
+ 
++constexpr int64_t kRelativeTsBase = static_cast<int64_t>(0x7ffeffffffffffff);
++
+ void SetAVStreamDiscard(AVStream* stream, AVDiscard discard) {
+   DCHECK(stream);
+   stream->discard = discard;
+@@ -90,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+   if (stream->start_time != kNoFFmpegTimestamp)
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (stream->first_dts != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, stream->first_dts);
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -408,11 +398,11 @@
+   scoped_refptr<DecoderBuffer> buffer;
+ 
+   if (type() == DemuxerStream::TEXT) {
+-    int id_size = 0;
++    size_t id_size = 0;
+     uint8_t* id_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
+ 
+-    int settings_size = 0;
++    size_t settings_size = 0;
+     uint8_t* settings_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
+ 
+@@ -424,7 +414,7 @@
+     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
+                                      side_data.data(), side_data.size());
+   } else {
+-    int side_data_size = 0;
++    size_t side_data_size = 0;
+     uint8_t* side_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
+ 
+@@ -485,7 +475,7 @@
+                                        packet->size - data_offset);
+     }
+ 
+-    int skip_samples_size = 0;
++    size_t skip_samples_size = 0;
+     const uint32_t* skip_samples_ptr =
+         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
+             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
+@@ -1587,6 +1577,8 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++      continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+       lowest_start_time_stream = stream.get();
+@@ -1604,6 +1596,8 @@
+     if (stream && stream->type() == DemuxerStream::VIDEO &&
+         stream->IsEnabled()) {
+       video_stream = stream.get();
++      if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++        continue;
+       if (video_stream->start_time() <= seek_time) {
+         return video_stream;
+       }
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h qtwebengine-5.15.10/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h
+--- a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-07-11 22:12:47.917192788 -0500
+@@ -29,6 +29,7 @@ extern "C" {
+ #include <libavformat/avformat.h>
+ #include <libavformat/avio.h>
+ #include <libavutil/avutil.h>
++#include <libavutil/channel_layout.h>
+ #include <libavutil/imgutils.h>
+ #include <libavutil/log.h>
+ #include <libavutil/mastering_display_metadata.h>
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/audio_file_reader.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/audio_file_reader.cc
+--- a/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -85,7 +85,7 @@ bool AudioFileReader::OpenDemuxer() {
+ }
+ 
+ bool AudioFileReader::OpenDecoder() {
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (codec) {
+     // MP3 decodes to S16P which we don't support, tell it to use S16 instead.
+     if (codec_context_->sample_fmt == AV_SAMPLE_FMT_S16P)
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -329,7 +329,7 @@ bool FFmpegAudioDecoder::ConfigureDecode
+     }
+   }
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec ||
+       avcodec_open2(codec_context_.get(), codec, &codec_options) < 0) {
+     DLOG(ERROR) << "Could not initialize audio decoder: "
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -59,7 +59,6 @@ static int64_t AVIOSeekOperation(void* o
+ }
+ 
+ void FFmpegGlue::InitializeFFmpeg() {
+-  av_register_all();
+ }
+ 
+ static void LogContainer(bool is_local_file,
+@@ -95,9 +94,6 @@ FFmpegGlue::FFmpegGlue(FFmpegURLProtocol
+   // Enable fast, but inaccurate seeks for MP3.
+   format_context_->flags |= AVFMT_FLAG_FAST_SEEK;
+ 
+-  // Ensures we can read out various metadata bits like vp8 alpha.
+-  format_context_->flags |= AVFMT_FLAG_KEEP_SIDE_DATA;
+-
+   // Ensures format parsing errors will bail out. From an audit on 11/2017, all
+   // instances were real failures. Solves bugs like http://crbug.com/710791.
+   format_context_->error_recognition |= AV_EF_EXPLODE;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -391,7 +391,7 @@ bool FFmpegVideoDecoder::ConfigureDecode
+   if (decode_nalus_)
+     codec_context_->flags2 |= AV_CODEC_FLAG2_CHUNKS;
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
+     ReleaseFFmpegResources();
+     return false;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/media_file_checker.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/media_file_checker.cc
+--- a/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -68,7 +68,7 @@ bool MediaFileChecker::Start(base::TimeD
+       auto context = AVStreamToAVCodecContext(format_context->streams[i]);
+       if (!context)
+         continue;
+-      AVCodec* codec = avcodec_find_decoder(cp->codec_id);
++      const AVCodec* codec = avcodec_find_decoder(cp->codec_id);
+       if (codec && avcodec_open2(context.get(), codec, nullptr) >= 0) {
+         auto loop = std::make_unique<FFmpegDecodingLoop>(context.get());
+         stream_contexts[i] = {std::move(context), std::move(loop)};
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc qtwebengine-5.15.10/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc
+--- a/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -203,7 +203,7 @@ int32_t H264DecoderImpl::InitDecode(cons
+   // a pointer |this|.
+   av_context_->opaque = this;
+ 
+-  AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
+   if (!codec) {
+     // This is an indication that FFmpeg has not been initialized or it has not
+     // been compiled/initialized with the correct set of codecs.
diff --git a/srcpkgs/qt5-webengine/template b/srcpkgs/qt5-webengine/template
index 85267c7cf8a3..095ab67701e4 100644
--- a/srcpkgs/qt5-webengine/template
+++ b/srcpkgs/qt5-webengine/template
@@ -1,9 +1,9 @@
 # Template file for 'qt5-webengine'
 pkgname=qt5-webengine
-version=5.15.11
-revision=3
+version=5.15.13
+revision=1
 _version="${version}-lts"
-_chromium_commit=be349eaf62e77955791d7bf29f893f1e8a37daf4
+_chromium_commit=e48df7803c7c98b0b2471c94057d32e44a301ad5
 archs="x86_64* i686* armv[67]* ppc64* aarch64*"
 create_wrksrc=yes
 build_style=qmake
@@ -32,8 +32,8 @@ license="GPL-3.0-or-later, LGPL-3.0-or-later"
 homepage="https://qt.io/"
 distfiles="https://github.com/qt/qtwebengine/archive/v${_version}.tar.gz
  https://github.com/qt/qtwebengine-chromium/archive/${_chromium_commit}.tar.gz"
-checksum="aa7466356c450c5f5870f979b93cd7e7e62da1165c328ffcab1a9928db18ad67
- 6f47ed8ab8cc062411f6f206da6353bc8263d6ed6d6290c689a05c01d91f646b"
+checksum="4b59838ed75ef788b59e1e412535a0e42dd9d311661fdeadb191b581ba815c63
+ a91686562b1d4e8b220e0bbcbab5feb64630e2de974b35ac034bf388af771a6c"
 
 no_generic_pkgconfig_link=yes
 build_options="sndio pipewire"

From 6455e1a069d9c4034895b4d5387ec5e4fe56b4d2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 074/116] qt5: update to 5.15.8

---
 ...erywhere-opensource-src-5.15.8-kf5-1.patch | 12913 ++++++++++++++++
 srcpkgs/qt5/template                          |    12 +-
 2 files changed, 12919 insertions(+), 6 deletions(-)
 create mode 100644 srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch

diff --git a/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch b/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch
new file mode 100644
index 000000000000..966c98bcd3bb
--- /dev/null
+++ b/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch
@@ -0,0 +1,12913 @@
+Submitted By:            Pierre Labastie <pierre_dot_labastie_at_neuf_dot_fr>
+Date:                    2023-01-05
+Initial Package Version: 5.15.8
+Upstream Status:         Applied (according to KDE)
+Origin:                  KDE patch set
+Description:             Patch set maintained by the KDE folks
+see https://dot.kde.org/2021/04/06/announcing-kdes-qt-5-patch-collection
+Patch generated using the procedure in
+https://wiki.linuxfromscratch.org/blfs/ticket/17476#comment:3
+
+Submodule qtbase 4ee4fc18..9cf586d6:
+diff --git a/qtbase/mkspecs/common/android/qplatformdefs.h b/qtbase/mkspecs/common/android/qplatformdefs.h
+index f75bc4093b..2bd59410d4 100644
+--- a/qtbase/mkspecs/common/android/qplatformdefs.h
++++ b/qtbase/mkspecs/common/android/qplatformdefs.h
+@@ -144,11 +144,7 @@
+ #define QT_SIGNAL_ARGS          int
+ #define QT_SIGNAL_IGNORE        SIG_IGN
+ 
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+ #define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+ 
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+diff --git a/qtbase/mkspecs/features/mac/sdk.mk b/qtbase/mkspecs/features/mac/sdk.mk
+index f30b5830b4..a32ceacb6c 100644
+--- a/qtbase/mkspecs/features/mac/sdk.mk
++++ b/qtbase/mkspecs/features/mac/sdk.mk
+@@ -1,6 +1,6 @@
+ 
+ ifeq ($(QT_MAC_SDK_NO_VERSION_CHECK),)
+-    CHECK_SDK_COMMAND = /usr/bin/xcrun --sdk $(EXPORT_QMAKE_MAC_SDK) -show-sdk-version 2>&1
++    CHECK_SDK_COMMAND = /usr/bin/xcrun --sdk $(EXPORT_QMAKE_MAC_SDK) -show-sdk-version 2>/dev/null
+     CURRENT_MAC_SDK_VERSION := $(shell DEVELOPER_DIR=$(EXPORT_QMAKE_XCODE_DEVELOPER_PATH) $(CHECK_SDK_COMMAND))
+     ifneq ($(CURRENT_MAC_SDK_VERSION),$(EXPORT_QMAKE_MAC_SDK_VERSION))
+         # We don't want to complain about out of date SDK unless the target needs to be remade.
+diff --git a/qtbase/mkspecs/linux-clang/qplatformdefs.h b/qtbase/mkspecs/linux-clang/qplatformdefs.h
+index a818d973f0..c1ab72fbc6 100644
+--- a/qtbase/mkspecs/linux-clang/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-clang/qplatformdefs.h
+@@ -79,14 +79,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-g++/qplatformdefs.h b/qtbase/mkspecs/linux-g++/qplatformdefs.h
+index 13523f0702..4d2750d9ec 100644
+--- a/qtbase/mkspecs/linux-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-g++/qplatformdefs.h
+@@ -79,14 +79,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ < 2)
+-#define QT_SOCKLEN_T            int
+-#else
+-#define QT_SOCKLEN_T            socklen_t
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-llvm/qplatformdefs.h b/qtbase/mkspecs/linux-llvm/qplatformdefs.h
+index dc750ab1ef..d3cc39b47f 100644
+--- a/qtbase/mkspecs/linux-llvm/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-llvm/qplatformdefs.h
+@@ -80,14 +80,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h b/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
+index 4c4e53da2a..83baffb3e3 100644
+--- a/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
+@@ -85,16 +85,9 @@
+ #include "../common/posix/qplatformdefs.h"
+ 
+ #undef QT_OPEN_LARGEFILE
+-#undef QT_SOCKLEN_T
+ 
+ #define QT_OPEN_LARGEFILE       0
+ 
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #ifndef SIOCGIFBRDADDR
+ #  define SIOCGIFBRDADDR 0x8919
+ #endif
+diff --git a/qtbase/mkspecs/lynxos-g++/qplatformdefs.h b/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
+index 4339ea2b23..6007af0055 100644
+--- a/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
+@@ -72,14 +72,6 @@
+ 
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp b/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
+index c3c184258f..32af3f8f29 100644
+--- a/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
++++ b/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
+@@ -10,6 +10,7 @@
+ #include "libANGLE/HandleAllocator.h"
+ 
+ #include <algorithm>
++#include <limits>
+ 
+ #include "common/debug.h"
+ 
+diff --git a/qtbase/src/3rdparty/forkfd/forkfd_linux.c b/qtbase/src/3rdparty/forkfd/forkfd_linux.c
+index ffe0e9a5e2..b1f5408d11 100644
+--- a/qtbase/src/3rdparty/forkfd/forkfd_linux.c
++++ b/qtbase/src/3rdparty/forkfd/forkfd_linux.c
+@@ -82,7 +82,8 @@ static int sys_clone(unsigned long cloneflags, int *ptid)
+     return syscall(__NR_clone, cloneflags, child_stack, stack_size, ptid, newtls, ctid);
+ #elif defined(__arc__) || defined(__arm__) || defined(__aarch64__) || defined(__mips__) || \
+     defined(__nds32__) || defined(__hppa__) || defined(__powerpc__) || defined(__i386__) || \
+-    defined(__x86_64__) || defined(__xtensa__) || defined(__alpha__) || defined(__riscv)
++    defined(__x86_64__) || defined(__xtensa__) || defined(__alpha__) || defined(__riscv) || \
++    defined(__loongarch__)
+     /* ctid and newtls are inverted on CONFIG_CLONE_BACKWARDS architectures,
+      * but since both values are 0, there's no harm. */
+     return syscall(__NR_clone, cloneflags, child_stack, ptid, ctid, newtls);
+diff --git a/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java b/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
+index 5792b5b2f5..2f74750fcf 100644
+--- a/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
++++ b/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
+@@ -116,6 +116,7 @@ public class QtNative
+     public static QtThread m_qtThread = new QtThread();
+     private static HashMap<String, Uri> m_cachedUris = new HashMap<String, Uri>();
+     private static ArrayList<String> m_knownDirs = new ArrayList<String>();
++    private static final String NoPermissionErrorMessage = "No permissions to open Uri";
+ 
+     private static final Runnable runPendingCppRunnablesRunnable = new Runnable() {
+         @Override
+@@ -193,11 +194,10 @@ public class QtNative
+                     return iterUri;
+             }
+ 
+-            // Android 6 and earlier could still manage to open the file so we can return the
+-            // parsed uri here
+-            if (Build.VERSION.SDK_INT < 24)
+-                return parsedUri;
+-            return null;
++            // if we only have transient permissions on uri all the above will fail,
++            // but we will be able to read the file anyway, so continue with uri here anyway
++            // and check for SecurityExceptions later
++            return parsedUri;
+         } catch (SecurityException e) {
+             e.printStackTrace();
+             return null;
+@@ -244,7 +244,7 @@ public class QtNative
+         int error = -1;
+ 
+         if (uri == null) {
+-            Log.e(QtTAG, "openFdForContentUrl(): No permissions to open Uri");
++            Log.e(QtTAG, "openFdForContentUrl(): " + NoPermissionErrorMessage);
+             return error;
+         }
+ 
+@@ -254,12 +254,13 @@ public class QtNative
+             return fdDesc.detachFd();
+         } catch (FileNotFoundException e) {
+             e.printStackTrace();
+-            return error;
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "openFdForContentUrl(): Invalid Uri");
+             e.printStackTrace();
+-            return error;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return error;
+     }
+ 
+     public static long getSize(Context context, String contentUrl)
+@@ -270,7 +271,7 @@ public class QtNative
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+ 
+         if (uri == null) {
+-            Log.e(QtTAG, "getSize(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return size;
+         } else if (!m_cachedUris.containsKey(contentUrl)) {
+             m_cachedUris.put(contentUrl, uri);
+@@ -288,12 +289,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "getSize(): Invalid Uri");
+             e.printStackTrace();
+-            return size;
+         }  catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "getSize(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return size;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return size;
+     }
+ 
+     public static boolean checkFileExists(Context context, String contentUrl)
+@@ -303,7 +305,7 @@ public class QtNative
+         if (uri == null)
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+         if (uri == null) {
+-            Log.e(QtTAG, "checkFileExists(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return exists;
+         } else {
+             if (!m_cachedUris.containsKey(contentUrl))
+@@ -321,12 +323,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "checkFileExists(): Invalid Uri");
+             e.printStackTrace();
+-            return exists;
+         } catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "checkFileExists(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return false;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return exists;
+     }
+ 
+     public static boolean checkIfWritable(Context context, String contentUrl)
+@@ -344,7 +347,7 @@ public class QtNative
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+         }
+         if (uri == null) {
+-            Log.e(QtTAG, "isDir(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return isDir;
+         } else {
+             if (!m_cachedUris.containsKey(contentUrl))
+@@ -374,12 +377,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "checkIfDir(): Invalid Uri");
+             e.printStackTrace();
+-            return false;
+         } catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "checkIfDir(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return false;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return false;
+     }
+     public static String[] listContentsFromTreeUri(Context context, String contentUrl)
+     {
+diff --git a/qtbase/src/concurrent/qtconcurrentreducekernel.h b/qtbase/src/concurrent/qtconcurrentreducekernel.h
+index 8f9a938952..a98dedef2e 100644
+--- a/qtbase/src/concurrent/qtconcurrentreducekernel.h
++++ b/qtbase/src/concurrent/qtconcurrentreducekernel.h
+@@ -212,11 +212,13 @@ public:
+ 
+     inline bool shouldThrottle()
+     {
++        std::lock_guard<QMutex> locker(mutex);
+         return (resultsMapSize > (ReduceQueueThrottleLimit * threadCount));
+     }
+ 
+     inline bool shouldStartThread()
+     {
++        std::lock_guard<QMutex> locker(mutex);
+         return (resultsMapSize <= (ReduceQueueStartLimit * threadCount));
+     }
+ };
+diff --git a/qtbase/src/concurrent/qtconcurrentthreadengine.cpp b/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
+index ea6ce3ac42..7f91a2ba68 100644
+--- a/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
++++ b/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
+@@ -176,6 +176,39 @@ void ThreadEngineBase::startSingleThreaded()
+     finish();
+ }
+ 
++void ThreadEngineBase::startBlocking()
++{
++    start();
++    barrier.acquire();
++    startThreads();
++
++    bool throttled = false;
++#ifndef QT_NO_EXCEPTIONS
++    try {
++#endif
++        while (threadFunction() == ThrottleThread) {
++            if (threadThrottleExit()) {
++                throttled = true;
++                break;
++            }
++        }
++#ifndef QT_NO_EXCEPTIONS
++    } catch (QException &e) {
++        handleException(e);
++    } catch (...) {
++        handleException(QUnhandledException());
++    }
++#endif
++
++    if (throttled == false) {
++        barrier.release();
++    }
++
++    barrier.wait();
++    finish();
++    exceptionStore.throwPossibleException();
++}
++
+ void ThreadEngineBase::startThread()
+ {
+     startThreadInternal();
+diff --git a/qtbase/src/concurrent/qtconcurrentthreadengine.h b/qtbase/src/concurrent/qtconcurrentthreadengine.h
+index 7c30cebdbc..a4c8548cc4 100644
+--- a/qtbase/src/concurrent/qtconcurrentthreadengine.h
++++ b/qtbase/src/concurrent/qtconcurrentthreadengine.h
+@@ -91,6 +91,7 @@ public:
+     ThreadEngineBase();
+     virtual ~ThreadEngineBase();
+     void startSingleThreaded();
++    void startBlocking();
+     void startThread();
+     bool isCanceled();
+     void waitForResume();
+@@ -143,6 +144,15 @@ public:
+         return result();
+     }
+ 
++    // Runs the user algorithm using multiple threads.
++    // This function blocks until the algorithm is finished,
++    // and then returns the result.
++    T *startBlocking()
++    {
++        ThreadEngineBase::startBlocking();
++        return result();
++    }
++
+     // Runs the user algorithm using multiple threads.
+     // Does not block, returns a future.
+     QFuture<T> startAsynchronously()
+@@ -223,6 +233,13 @@ class ThreadEngineStarter : public ThreadEngineStarterBase<T>
+ public:
+     ThreadEngineStarter(TypedThreadEngine *eng)
+         : Base(eng) { }
++
++    T startBlocking()
++    {
++        T t = *this->threadEngine->startBlocking();
++        delete this->threadEngine;
++        return t;
++    }
+ };
+ 
+ // Full template specialization where T is void.
+@@ -232,6 +249,12 @@ class ThreadEngineStarter<void> : public ThreadEngineStarterBase<void>
+ public:
+     ThreadEngineStarter(ThreadEngine<void> *_threadEngine)
+         : ThreadEngineStarterBase<void>(_threadEngine) {}
++
++    void startBlocking()
++    {
++        this->threadEngine->startBlocking();
++        delete this->threadEngine;
++    }
+ };
+ 
+ //! [qtconcurrentthreadengine-1]
+diff --git a/qtbase/src/corelib/animation/qvariantanimation.cpp b/qtbase/src/corelib/animation/qvariantanimation.cpp
+index 98b02f0202..eac1524107 100644
+--- a/qtbase/src/corelib/animation/qvariantanimation.cpp
++++ b/qtbase/src/corelib/animation/qvariantanimation.cpp
+@@ -276,7 +276,9 @@ void QVariantAnimationPrivate::setCurrentValueForProgress(const qreal progress)
+ 
+     const qreal startProgress = currentInterval.start.first;
+     const qreal endProgress = currentInterval.end.first;
+-    const qreal localProgress = (progress - startProgress) / (endProgress - startProgress);
++    const qreal localProgress =
++            qIsNull(progress - startProgress) ? 0.0 // avoid 0/0 below
++            /* else */                        : (progress - startProgress) / (endProgress - startProgress);
+ 
+     QVariant ret = q->interpolated(currentInterval.start.second,
+                                    currentInterval.end.second,
+diff --git a/qtbase/src/corelib/global/qnamespace.h b/qtbase/src/corelib/global/qnamespace.h
+index ad4150b317..bf19b1627b 100644
+--- a/qtbase/src/corelib/global/qnamespace.h
++++ b/qtbase/src/corelib/global/qnamespace.h
+@@ -1864,7 +1864,7 @@ public:
+     QT_Q_ENUM(TimerType)
+     QT_Q_ENUM(ScrollPhase)
+     QT_Q_ENUM(MouseEventSource)
+-    QT_Q_FLAG(MouseEventFlag)
++    QT_Q_FLAG(MouseEventFlags)
+     QT_Q_ENUM(ChecksumType)
+     QT_Q_ENUM(HighDpiScaleFactorRoundingPolicy)
+     QT_Q_ENUM(TabFocusBehavior)
+diff --git a/qtbase/src/corelib/global/qrandom.cpp b/qtbase/src/corelib/global/qrandom.cpp
+index 10672c1f92..25f87c7e6a 100644
+--- a/qtbase/src/corelib/global/qrandom.cpp
++++ b/qtbase/src/corelib/global/qrandom.cpp
+@@ -383,7 +383,6 @@ struct QRandomGenerator::SystemAndGlobalGenerators
+ 
+         constexpr SystemAndGlobalGenerators g = {};
+         Q_UNUSED(g);
+-        Q_STATIC_ASSERT(std::is_literal_type<SystemAndGlobalGenerators>::value);
+ #endif
+     }
+ 
+diff --git a/qtbase/src/corelib/io/qbuffer.cpp b/qtbase/src/corelib/io/qbuffer.cpp
+index 595fcd2724..032c0ddd4b 100644
+--- a/qtbase/src/corelib/io/qbuffer.cpp
++++ b/qtbase/src/corelib/io/qbuffer.cpp
+@@ -41,6 +41,8 @@
+ #include <QtCore/qmetaobject.h>
+ #include "private/qiodevice_p.h"
+ 
++#include <limits>
++
+ QT_BEGIN_NAMESPACE
+ 
+ /** QBufferPrivate **/
+@@ -366,7 +368,9 @@ qint64 QBuffer::size() const
+ bool QBuffer::seek(qint64 pos)
+ {
+     Q_D(QBuffer);
+-    if (pos > d->buf->size() && isWritable()) {
++    const auto oldBufSize = d->buf->size();
++    constexpr qint64 MaxSeekPos = (std::numeric_limits<decltype(oldBufSize)>::max)();
++    if (pos <= MaxSeekPos && pos > oldBufSize && isWritable()) {
+         if (seek(d->buf->size())) {
+             const qint64 gapSize = pos - d->buf->size();
+             if (write(QByteArray(gapSize, 0)) != gapSize) {
+@@ -377,7 +381,7 @@ bool QBuffer::seek(qint64 pos)
+             return false;
+         }
+     } else if (pos > d->buf->size() || pos < 0) {
+-        qWarning("QBuffer::seek: Invalid pos: %d", int(pos));
++        qWarning("QBuffer::seek: Invalid pos: %lld", pos);
+         return false;
+     }
+     return QIODevice::seek(pos);
+diff --git a/qtbase/src/corelib/io/qfilesystemengine_win.cpp b/qtbase/src/corelib/io/qfilesystemengine_win.cpp
+index 81d3a71986..c86ed1f9b0 100644
+--- a/qtbase/src/corelib/io/qfilesystemengine_win.cpp
++++ b/qtbase/src/corelib/io/qfilesystemengine_win.cpp
+@@ -664,14 +664,14 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry)
+     return QFileSystemEntry(ret, QFileSystemEntry::FromInternalPath());
+ }
+ 
+-#if defined(Q_CC_MINGW) && WINVER < 0x0602 //  Windows 8 onwards
++#if defined(Q_CC_MINGW) && WINVER < 0x0602 && _WIN32_WINNT < _WIN32_WINNT_WIN8 //  Windows 8 onwards
+ 
+ typedef struct _FILE_ID_INFO {
+     ULONGLONG VolumeSerialNumber;
+     FILE_ID_128 FileId;
+ } FILE_ID_INFO, *PFILE_ID_INFO;
+ 
+-#endif // if defined (Q_CC_MINGW) && WINVER < 0x0602
++#endif // if defined(Q_CC_MINGW) && WINVER < 0x0602 && _WIN32_WINNT < _WIN32_WINNT_WIN8
+ 
+ // File ID for Windows up to version 7 and FAT32 drives
+ static inline QByteArray fileId(HANDLE handle)
+diff --git a/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp b/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
+index 94d9d06bcb..27e0b13b0b 100644
+--- a/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
++++ b/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
+@@ -366,7 +366,9 @@ void QInotifyFileSystemWatcherEngine::readFromInotify()
+     // qDebug("QInotifyFileSystemWatcherEngine::readFromInotify");
+ 
+     int buffSize = 0;
+-    ioctl(inotifyFd, FIONREAD, (char *) &buffSize);
++    if (ioctl(inotifyFd, FIONREAD, (char *) &buffSize) == -1 || buffSize == 0)
++        return;
++
+     QVarLengthArray<char, 4096> buffer(buffSize);
+     buffSize = read(inotifyFd, buffer.data(), buffSize);
+     char *at = buffer.data();
+diff --git a/qtbase/src/corelib/io/qlockfile_win.cpp b/qtbase/src/corelib/io/qlockfile_win.cpp
+index 277f8d4230..38ecef5550 100644
+--- a/qtbase/src/corelib/io/qlockfile_win.cpp
++++ b/qtbase/src/corelib/io/qlockfile_win.cpp
+@@ -48,6 +48,8 @@
+ #include "QtCore/qdebug.h"
+ #include "QtCore/qthread.h"
+ 
++#include "private/qsystemlibrary_p.h"
++
+ QT_BEGIN_NAMESPACE
+ 
+ static inline bool fileExists(const wchar_t *fileName)
+@@ -150,7 +152,7 @@ QString QLockFilePrivate::processNameByPid(qint64 pid)
+ #if !defined(Q_OS_WINRT)
+     typedef DWORD (WINAPI *GetModuleFileNameExFunc)(HANDLE, HMODULE, LPTSTR, DWORD);
+ 
+-    HMODULE hPsapi = LoadLibraryA("psapi");
++    HMODULE hPsapi = QSystemLibrary::load(L"psapi");
+     if (!hPsapi)
+         return QString();
+     GetModuleFileNameExFunc qGetModuleFileNameEx = reinterpret_cast<GetModuleFileNameExFunc>(
+diff --git a/qtbase/src/corelib/io/qprocess_unix.cpp b/qtbase/src/corelib/io/qprocess_unix.cpp
+index 50390e57f5..15c8f30745 100644
+--- a/qtbase/src/corelib/io/qprocess_unix.cpp
++++ b/qtbase/src/corelib/io/qprocess_unix.cpp
+@@ -1,7 +1,7 @@
+ /****************************************************************************
+ **
+ ** Copyright (C) 2016 The Qt Company Ltd.
+-** Copyright (C) 2016 Intel Corporation.
++** Copyright (C) 2022 Intel Corporation.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtCore module of the Qt Toolkit.
+@@ -422,14 +422,15 @@ void QProcessPrivate::startProcess()
+     // Add the program name to the argument list.
+     argv[0] = nullptr;
+     if (!program.contains(QLatin1Char('/'))) {
++        // findExecutable() returns its argument if it's an absolute path,
++        // otherwise it searches $PATH; returns empty if not found (we handle
++        // that case much later)
+         const QString &exeFilePath = QStandardPaths::findExecutable(program);
+-        if (!exeFilePath.isEmpty()) {
+-            const QByteArray &tmp = QFile::encodeName(exeFilePath);
+-            argv[0] = ::strdup(tmp.constData());
+-        }
+-    }
+-    if (!argv[0])
++        const QByteArray &tmp = QFile::encodeName(exeFilePath);
++        argv[0] = ::strdup(tmp.constData());
++    } else {
+         argv[0] = ::strdup(encodedProgramName.constData());
++    }
+ 
+     // Add every argument to the list
+     for (int i = 0; i < arguments.count(); ++i)
+@@ -983,15 +984,16 @@ bool QProcessPrivate::startDetached(qint64 *pid)
+                 envp = _q_dupEnvironment(environment.d.constData()->vars, &envc);
+             }
+ 
+-            QByteArray tmp;
+             if (!program.contains(QLatin1Char('/'))) {
++                // findExecutable() returns its argument if it's an absolute path,
++                // otherwise it searches $PATH; returns empty if not found (we handle
++                // that case much later)
+                 const QString &exeFilePath = QStandardPaths::findExecutable(program);
+-                if (!exeFilePath.isEmpty())
+-                    tmp = QFile::encodeName(exeFilePath);
++                const QByteArray &tmp = QFile::encodeName(exeFilePath);
++                argv[0] = ::strdup(tmp.constData());
++            } else {
++                argv[0] = ::strdup(QFile::encodeName(program));
+             }
+-            if (tmp.isEmpty())
+-                tmp = QFile::encodeName(program);
+-            argv[0] = tmp.data();
+ 
+             if (envp)
+                 qt_safe_execve(argv[0], argv, envp);
+diff --git a/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp b/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
+index 3a79c502af..997a634e76 100644
+--- a/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
++++ b/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
+@@ -3196,9 +3196,8 @@ bool QAbstractItemModel::beginMoveColumns(const QModelIndex &sourceParent, int s
+     destinationChange.needsAdjust = destinationParent.isValid() && destinationParent.row() >= sourceLast && destinationParent.parent() == sourceParent;
+     d->changes.push(destinationChange);
+ 
+-    d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Horizontal);
+-
+     emit columnsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, QPrivateSignal());
++    d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Horizontal);
+     return true;
+ }
+ 
+@@ -3231,7 +3230,6 @@ void QAbstractItemModel::endMoveColumns()
+       adjustedSource = createIndex(adjustedSource.row(), adjustedSource.column() + numMoved, adjustedSource.internalPointer());
+ 
+     d->itemsMoved(adjustedSource, removeChange.first, removeChange.last, adjustedDestination, insertChange.first, Qt::Horizontal);
+-
+     emit columnsMoved(adjustedSource, removeChange.first, removeChange.last, adjustedDestination, insertChange.first, QPrivateSignal());
+ }
+ 
+diff --git a/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+index dc6379d9fb..c5e287ee84 100644
+--- a/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
++++ b/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+@@ -939,8 +939,9 @@ void QSortFilterProxyModelPrivate::insert_source_items(
+                 q->beginInsertColumns(proxy_parent, proxy_start, proxy_end);
+         }
+ 
+-        for (int i = 0; i < source_items.size(); ++i)
+-            proxy_to_source.insert(proxy_start + i, source_items.at(i));
++        // TODO: use the range QList::insert() overload once it is implemented (QTBUG-58633).
++        proxy_to_source.insert(proxy_start, source_items.size(), 0);
++        std::copy(source_items.cbegin(), source_items.cend(), proxy_to_source.begin() + proxy_start);
+ 
+         build_source_to_proxy_mapping(proxy_to_source, source_to_proxy);
+ 
+@@ -3123,8 +3124,9 @@ bool QSortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex &
+ 
+     if (d->filter_data.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();
+@@ -3133,9 +3135,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.hasMatch(key);
+ }
+diff --git a/qtbase/src/corelib/kernel/qcoreapplication.cpp b/qtbase/src/corelib/kernel/qcoreapplication.cpp
+index ca2864df83..132b2eae52 100644
+--- a/qtbase/src/corelib/kernel/qcoreapplication.cpp
++++ b/qtbase/src/corelib/kernel/qcoreapplication.cpp
+@@ -1157,7 +1157,7 @@ static bool doNotify(QObject *receiver, QEvent *event)
+ bool QCoreApplicationPrivate::sendThroughApplicationEventFilters(QObject *receiver, QEvent *event)
+ {
+     // We can't access the application event filters outside of the main thread (race conditions)
+-    Q_ASSERT(receiver->d_func()->threadData.loadRelaxed()->thread.loadAcquire() == mainThread());
++    Q_ASSERT(receiver->d_func()->threadData.loadAcquire()->thread.loadRelaxed() == mainThread());
+ 
+     if (extraData) {
+         // application event filters are only called for objects in the GUI thread
+diff --git a/qtbase/src/corelib/kernel/qobject.cpp b/qtbase/src/corelib/kernel/qobject.cpp
+index 1eb79138d9..36cd780ee1 100644
+--- a/qtbase/src/corelib/kernel/qobject.cpp
++++ b/qtbase/src/corelib/kernel/qobject.cpp
+@@ -1010,7 +1010,7 @@ QObject::~QObject()
+         emit destroyed(this);
+     }
+ 
+-    if (d->declarativeData) {
++    if (!d->isDeletingChildren && d->declarativeData) {
+         if (static_cast<QAbstractDeclarativeDataImpl*>(d->declarativeData)->ownedByQml1) {
+             if (QAbstractDeclarativeData::destroyed_qml1)
+                 QAbstractDeclarativeData::destroyed_qml1(d->declarativeData, this);
+@@ -1580,7 +1580,7 @@ void QObject::moveToThread(QThread *targetThread)
+ 
+     QThreadData *currentData = QThreadData::current();
+     QThreadData *targetData = targetThread ? QThreadData::get2(targetThread) : nullptr;
+-    QThreadData *thisThreadData = d->threadData.loadRelaxed();
++    QThreadData *thisThreadData = d->threadData.loadAcquire();
+     if (!thisThreadData->thread.loadAcquire() && currentData == targetData) {
+         // one exception to the rule: we allow moving objects with no thread affinity to the current thread
+         currentData = d->threadData;
+@@ -2620,7 +2620,7 @@ int QObject::receivers(const char *signal) const
+         if (!d->isSignalConnected(signal_index))
+             return receivers;
+ 
+-        if (d->declarativeData && QAbstractDeclarativeData::receivers) {
++        if (!d->isDeletingChildren && d->declarativeData && QAbstractDeclarativeData::receivers) {
+             receivers += QAbstractDeclarativeData::receivers(d->declarativeData, this,
+                                                              signal_index);
+         }
+diff --git a/qtbase/src/corelib/kernel/qobject_p.h b/qtbase/src/corelib/kernel/qobject_p.h
+index 0b827a52ca..13ffb88999 100644
+--- a/qtbase/src/corelib/kernel/qobject_p.h
++++ b/qtbase/src/corelib/kernel/qobject_p.h
+@@ -444,7 +444,7 @@ inline void QObjectPrivate::checkForIncompatibleLibraryVersion(int version) cons
+ 
+ inline bool QObjectPrivate::isDeclarativeSignalConnected(uint signal_index) const
+ {
+-    return declarativeData && QAbstractDeclarativeData::isSignalConnected
++    return !isDeletingChildren && declarativeData && QAbstractDeclarativeData::isSignalConnected
+             && QAbstractDeclarativeData::isSignalConnected(declarativeData, q_func(), signal_index);
+ }
+ 
+diff --git a/qtbase/src/corelib/kernel/qtranslator.cpp b/qtbase/src/corelib/kernel/qtranslator.cpp
+index 2812ffb7ea..bc0177c5ec 100644
+--- a/qtbase/src/corelib/kernel/qtranslator.cpp
++++ b/qtbase/src/corelib/kernel/qtranslator.cpp
+@@ -902,7 +902,7 @@ static QString getMessage(const uchar *m, const uchar *end, const char *context,
+             goto end;
+         case Tag_Translation: {
+             int len = read32(m);
+-            if (len % 1)
++            if (len & 1)
+                 return QString();
+             m += 4;
+             if (!numerus--) {
+diff --git a/qtbase/src/corelib/mimetypes/qmimedatabase.cpp b/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
+index 9de22cef33..ff868a3268 100644
+--- a/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
+@@ -389,20 +389,23 @@ QMimeType QMimeDatabasePrivate::mimeTypeForFileNameAndData(const QString &fileNa
+         // Disambiguate conflicting extensions (if magic matching found something)
+         if (candidateByData.isValid() && magicAccuracy > 0) {
+             const QString sniffedMime = candidateByData.name();
+-            // If the sniffedMime matches a glob match, use it
++            // If the sniffedMime matches a highest-weight glob match, use it
+             if (candidatesByName.m_matchingMimeTypes.contains(sniffedMime)) {
+                 *accuracyPtr = 100;
+                 return candidateByData;
+             }
+-            for (const QString &m : qAsConst(candidatesByName.m_matchingMimeTypes)) {
++            for (const QString &m : qAsConst(candidatesByName.m_allMatchingMimeTypes)) {
+                 if (inherits(m, sniffedMime)) {
+                     // We have magic + pattern pointing to this, so it's a pretty good match
+                     *accuracyPtr = 100;
+                     return mimeTypeForName(m);
+                 }
+             }
+-            *accuracyPtr = magicAccuracy;
+-            return candidateByData;
++            if (candidatesByName.m_allMatchingMimeTypes.isEmpty()) {
++                // No glob, use magic
++                *accuracyPtr = magicAccuracy;
++                return candidateByData;
++            }
+         }
+     }
+ 
+diff --git a/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp b/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
+index a81112d227..fa8f4c545d 100644
+--- a/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
+@@ -83,7 +83,10 @@ void QMimeGlobMatchResult::addMatch(const QString &mimeType, int weight, const Q
+     }
+     if (!m_matchingMimeTypes.contains(mimeType)) {
+         m_matchingMimeTypes.append(mimeType);
+-        m_allMatchingMimeTypes.append(mimeType);
++        if (replace)
++            m_allMatchingMimeTypes.prepend(mimeType); // highest-weight first
++        else
++            m_allMatchingMimeTypes.append(mimeType);
+         m_knownSuffixLength = knownSuffixLength;
+     }
+ }
+@@ -94,7 +97,7 @@ QMimeGlobPattern::PatternType QMimeGlobPattern::detectPatternType(const QString
+     if (!patternLength)
+         return OtherPattern;
+ 
+-    const bool starCount = pattern.count(QLatin1Char('*')) == 1;
++    const int starCount = pattern.count(QLatin1Char('*'));
+     const bool hasSquareBracket = pattern.indexOf(QLatin1Char('[')) != -1;
+     const bool hasQuestionMark = pattern.indexOf(QLatin1Char('?')) != -1;
+ 
+@@ -106,10 +109,10 @@ QMimeGlobPattern::PatternType QMimeGlobPattern::detectPatternType(const QString
+             // Patterns like "README*" (well this is currently the only one like that...)
+             if (pattern.at(patternLength - 1) == QLatin1Char('*'))
+                 return PrefixPattern;
+-        }
+-        // Names without any wildcards like "README"
+-        if (starCount == 0)
++        } else if (starCount == 0) {
++            // Names without any wildcards like "README"
+             return LiteralPattern;
++        }
+     }
+ 
+     if (pattern == QLatin1String("[0-9][0-9][0-9].vdr"))
+diff --git a/qtbase/src/corelib/mimetypes/qmimeprovider.cpp b/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
+index 258dddf8cb..4642d0f2d0 100644
+--- a/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
+@@ -244,15 +244,18 @@ void QMimeBinaryProvider::addFileNameMatches(const QString &fileName, QMimeGlobM
+     const QString lowerFileName = fileName.toLower();
+     // Check literals (e.g. "Makefile")
+     matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosLiteralListOffset), fileName);
+-    // Check complex globs (e.g. "callgrind.out[0-9]*")
+-    matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosGlobListOffset), fileName);
+     // Check the very common *.txt cases with the suffix tree
+-    const int reverseSuffixTreeOffset = m_cacheFile->getUint32(PosReverseSuffixTreeOffset);
+-    const int numRoots = m_cacheFile->getUint32(reverseSuffixTreeOffset);
+-    const int firstRootOffset = m_cacheFile->getUint32(reverseSuffixTreeOffset + 4);
+-    matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, lowerFileName, lowerFileName.length() - 1, false);
++    if (result.m_matchingMimeTypes.isEmpty()) {
++        const int reverseSuffixTreeOffset = m_cacheFile->getUint32(PosReverseSuffixTreeOffset);
++        const int numRoots = m_cacheFile->getUint32(reverseSuffixTreeOffset);
++        const int firstRootOffset = m_cacheFile->getUint32(reverseSuffixTreeOffset + 4);
++        matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, lowerFileName, lowerFileName.length() - 1, false);
++        if (result.m_matchingMimeTypes.isEmpty())
++            matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, fileName, fileName.length() - 1, true);
++    }
++    // Check complex globs (e.g. "callgrind.out[0-9]*" or "README*")
+     if (result.m_matchingMimeTypes.isEmpty())
+-        matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, fileName, fileName.length() - 1, true);
++        matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosGlobListOffset), fileName);
+ }
+ 
+ void QMimeBinaryProvider::matchGlobList(QMimeGlobMatchResult &result, CacheFile *cacheFile, int off, const QString &fileName)
+diff --git a/qtbase/src/corelib/serialization/qjsonparser.cpp b/qtbase/src/corelib/serialization/qjsonparser.cpp
+index 17e6f111ab..2e40b6c8fb 100644
+--- a/qtbase/src/corelib/serialization/qjsonparser.cpp
++++ b/qtbase/src/corelib/serialization/qjsonparser.cpp
+@@ -379,10 +379,30 @@ error:
+     return QCborValue();
+ }
+ 
++// We need to retain the _last_ value for any duplicate keys and we need to deref containers.
++// Therefore the manual implementation of std::unique().
++template<typename Iterator, typename Compare, typename Assign>
++static Iterator customAssigningUniqueLast(Iterator first, Iterator last,
++                                          Compare compare, Assign assign)
++{
++    first = std::adjacent_find(first, last, compare);
++    if (first == last)
++        return last;
++
++    Iterator result = first;
++    while (++first != last) {
++        if (!compare(*result, *first))
++            ++result;
++        if (result != first)
++            assign(*result, *first);
++    }
++
++    return ++result;
++}
++
+ static void sortContainer(QCborContainerPrivate *container)
+ {
+     using Forward = QJsonPrivate::KeyIterator;
+-    using Reverse = std::reverse_iterator<Forward>;
+     using Value = Forward::value_type;
+ 
+     auto compare = [container](const Value &a, const Value &b)
+@@ -420,17 +440,31 @@ static void sortContainer(QCborContainerPrivate *container)
+         }
+     };
+ 
+-    std::sort(Forward(container->elements.begin()), Forward(container->elements.end()),
+-              [&compare](const Value &a, const Value &b) { return compare(a, b) < 0; });
++    // The elements' containers are owned by the outer container, not by the elements themselves.
++    auto move = [](Forward::reference target, Forward::reference source)
++    {
++        QtCbor::Element &targetValue = target.value();
++
++        // If the target has a container, deref it before overwriting, so that we don't leak.
++        if (targetValue.flags & QtCbor::Element::IsContainer)
++            targetValue.container->deref();
++
++        // Do not move, so that we can clear the value afterwards.
++        target = source;
++
++        // Clear the source value, so that we don't store the same container twice.
++        source.value() = QtCbor::Element();
++    };
++
++    std::stable_sort(
++                Forward(container->elements.begin()), Forward(container->elements.end()),
++                [&compare](const Value &a, const Value &b) { return compare(a, b) < 0; });
+ 
+-    // We need to retain the _last_ value for any duplicate keys. Therefore the reverse dance here.
+-    auto it = std::unique(Reverse(container->elements.end()), Reverse(container->elements.begin()),
+-                          [&compare](const Value &a, const Value &b) {
+-        return compare(a, b) == 0;
+-    }).base().elementsIterator();
++    Forward result = customAssigningUniqueLast(
++                Forward(container->elements.begin()),  Forward(container->elements.end()),
++                [&compare](const Value &a, const Value &b) { return compare(a, b) == 0; }, move);
+ 
+-    // The erase from beginning is expensive but hopefully rare.
+-    container->elements.erase(container->elements.begin(), it);
++    container->elements.erase(result.elementsIterator(), container->elements.end());
+ }
+ 
+ 
+diff --git a/qtbase/src/corelib/serialization/qxmlstream.cpp b/qtbase/src/corelib/serialization/qxmlstream.cpp
+index b2f846544d..7cd457ba3a 100644
+--- a/qtbase/src/corelib/serialization/qxmlstream.cpp
++++ b/qtbase/src/corelib/serialization/qxmlstream.cpp
+@@ -980,7 +980,7 @@ inline uint QXmlStreamReaderPrivate::peekChar()
+ bool QXmlStreamReaderPrivate::scanUntil(const char *str, short tokenToInject)
+ {
+     int pos = textBuffer.size();
+-    int oldLineNumber = lineNumber;
++    const auto oldLineNumber = lineNumber;
+ 
+     uint c;
+     while ((c = getChar()) != StreamEOF) {
+diff --git a/qtbase/src/corelib/text/qstring.cpp b/qtbase/src/corelib/text/qstring.cpp
+index 3e88ab4859..8deeae47bb 100644
+--- a/qtbase/src/corelib/text/qstring.cpp
++++ b/qtbase/src/corelib/text/qstring.cpp
+@@ -12312,7 +12312,7 @@ static qsizetype qLastIndexOf(Haystack haystack0, qsizetype from,
+     const auto needle = needle0.data();
+     const auto *end = haystack;
+     haystack += from;
+-    const std::size_t sl_minus_1 = sl - 1;
++    const std::size_t sl_minus_1 = sl ? sl - 1 : 0;
+     const auto *n = needle + sl_minus_1;
+     const auto *h = haystack + sl_minus_1;
+     std::size_t hashNeedle = 0, hashHaystack = 0;
+diff --git a/qtbase/src/corelib/text/qstringiterator_p.h b/qtbase/src/corelib/text/qstringiterator_p.h
+index 219589b6e4..1d0c66cc78 100644
+--- a/qtbase/src/corelib/text/qstringiterator_p.h
++++ b/qtbase/src/corelib/text/qstringiterator_p.h
+@@ -61,6 +61,8 @@ class QStringIterator
+ {
+     QString::const_iterator i, pos, e;
+     Q_STATIC_ASSERT((std::is_same<QString::const_iterator, const QChar *>::value));
++    static bool less(const QChar *lhs, const QChar *rhs) noexcept
++    { return std::less<QString::const_iterator>{}(lhs, rhs); }
+ public:
+     explicit QStringIterator(QStringView string, qsizetype idx = 0)
+         : i(string.begin()),
+@@ -95,7 +97,8 @@ public:
+ 
+     inline void setPosition(QString::const_iterator position)
+     {
+-        Q_ASSERT_X(i <= position && position <= e, Q_FUNC_INFO, "position out of bounds");
++        Q_ASSERT_X(!less(position, i) && !less(e, position),
++                   Q_FUNC_INFO, "position out of bounds");
+         pos = position;
+     }
+ 
+@@ -103,7 +106,7 @@ public:
+ 
+     inline bool hasNext() const
+     {
+-        return pos < e;
++        return less(pos, e);
+     }
+ 
+     inline void advance()
+@@ -120,16 +123,20 @@ public:
+     {
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+-        if (Q_UNLIKELY((pos++)->isHighSurrogate()))
++        if (Q_UNLIKELY((pos++)->isHighSurrogate())) {
++            Q_ASSERT(hasNext() && pos->isLowSurrogate());
+             ++pos;
++        }
+     }
+ 
+     inline uint peekNextUnchecked() const
+     {
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+-        if (Q_UNLIKELY(pos->isHighSurrogate()))
++        if (Q_UNLIKELY(pos->isHighSurrogate())) {
++            Q_ASSERT(less(pos + 1, e) && pos[1].isLowSurrogate());
+             return QChar::surrogateToUcs4(pos[0], pos[1]);
++        }
+ 
+         return pos->unicode();
+     }
+@@ -155,8 +162,10 @@ public:
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+         const QChar cur = *pos++;
+-        if (Q_UNLIKELY(cur.isHighSurrogate()))
++        if (Q_UNLIKELY(cur.isHighSurrogate())) {
++            Q_ASSERT(hasNext() && pos->isLowSurrogate());
+             return QChar::surrogateToUcs4(cur, *pos++);
++        }
+         return cur.unicode();
+     }
+ 
+@@ -166,7 +175,7 @@ public:
+ 
+         const QChar uc = *pos++;
+         if (Q_UNLIKELY(uc.isSurrogate())) {
+-            if (Q_LIKELY(uc.isHighSurrogate() && pos < e && pos->isLowSurrogate()))
++            if (Q_LIKELY(uc.isHighSurrogate() && hasNext() && pos->isLowSurrogate()))
+                 return QChar::surrogateToUcs4(uc, *pos++);
+             return invalidAs;
+         }
+@@ -178,7 +187,7 @@ public:
+ 
+     inline bool hasPrevious() const
+     {
+-        return pos > i;
++        return less(i, pos);
+     }
+ 
+     inline void recede()
+@@ -196,16 +205,20 @@ public:
+     {
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+-        if (Q_UNLIKELY((--pos)->isLowSurrogate()))
++        if (Q_UNLIKELY((--pos)->isLowSurrogate())) {
++            Q_ASSERT(hasPrevious() && pos[-1].isHighSurrogate());
+             --pos;
++        }
+     }
+ 
+     inline uint peekPreviousUnchecked() const
+     {
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+-        if (Q_UNLIKELY(pos[-1].isLowSurrogate()))
++        if (Q_UNLIKELY(pos[-1].isLowSurrogate())) {
++            Q_ASSERT(less(i + 1, pos) && pos[-2].isHighSurrogate());
+             return QChar::surrogateToUcs4(pos[-2], pos[-1]);
++        }
+         return pos[-1].unicode();
+     }
+ 
+@@ -230,8 +243,10 @@ public:
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+         const QChar cur = *--pos;
+-        if (Q_UNLIKELY(cur.isLowSurrogate()))
++        if (Q_UNLIKELY(cur.isLowSurrogate())) {
++            Q_ASSERT(hasPrevious() && pos[-1].isHighSurrogate());
+             return QChar::surrogateToUcs4(*--pos, cur);
++        }
+         return cur.unicode();
+     }
+ 
+@@ -241,7 +256,7 @@ public:
+ 
+         const QChar uc = *--pos;
+         if (Q_UNLIKELY(uc.isSurrogate())) {
+-            if (Q_LIKELY(uc.isLowSurrogate() && pos > i && pos[-1].isHighSurrogate()))
++            if (Q_LIKELY(uc.isLowSurrogate() && hasPrevious() && pos[-1].isHighSurrogate()))
+                 return QChar::surrogateToUcs4(*--pos, uc);
+             return invalidAs;
+         }
+diff --git a/qtbase/src/corelib/thread/qfutex_p.h b/qtbase/src/corelib/thread/qfutex_p.h
+index f287b752d7..e294537787 100644
+--- a/qtbase/src/corelib/thread/qfutex_p.h
++++ b/qtbase/src/corelib/thread/qfutex_p.h
+@@ -52,6 +52,7 @@
+ //
+ 
+ #include <qglobal.h>
++#include <QtCore/qtsan_impl.h>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -106,16 +107,13 @@ namespace QtLinuxFutex {
+     inline int _q_futex(int *addr, int op, int val, quintptr val2 = 0,
+                         int *addr2 = nullptr, int val3 = 0) noexcept
+     {
+-        // A futex call ensures total ordering on the futex words
+-        // (in either success or failure of the call). Instruct TSAN accordingly,
+-        // as TSAN does not understand the futex(2) syscall.
+-        _q_tsan_release(addr, addr2);
++        QtTsan::futexRelease(addr, addr2);
+ 
+         // we use __NR_futex because some libcs (like Android's bionic) don't
+         // provide SYS_futex etc.
+         int result = syscall(__NR_futex, addr, op | FUTEX_PRIVATE_FLAG, val, val2, addr2, val3);
+ 
+-        _q_tsan_acquire(addr, addr2);
++        QtTsan::futexAcquire(addr, addr2);
+ 
+         return result;
+     }
+diff --git a/qtbase/src/corelib/thread/qmutex.cpp b/qtbase/src/corelib/thread/qmutex.cpp
+index 310d1cb14f..7097122d8e 100644
+--- a/qtbase/src/corelib/thread/qmutex.cpp
++++ b/qtbase/src/corelib/thread/qmutex.cpp
+@@ -152,6 +152,7 @@ public:
+ 
+ /*!
+     \enum QMutex::RecursionMode
++    \obsolete Use QRecursiveMutex to create a recursive mutex.
+ 
+     \value Recursive  In this mode, a thread can lock the same mutex
+                       multiple times and the mutex won't be unlocked
+@@ -173,6 +174,7 @@ public:
+ 
+ /*!
+     Constructs a new mutex. The mutex is created in an unlocked state.
++    \obsolete Use QRecursiveMutex to create a recursive mutex.
+ 
+     If \a mode is QMutex::Recursive, a thread can lock the same mutex
+     multiple times and the mutex won't be unlocked until a
+@@ -197,7 +199,7 @@ QMutex::QMutex(RecursionMode mode)
+ QMutex::~QMutex()
+ {
+     QMutexData *d = d_ptr.loadRelaxed();
+-    if (isRecursive()) {
++    if (QBasicMutex::isRecursive()) {
+         delete static_cast<QRecursiveMutexPrivate *>(d);
+     } else if (d) {
+ #ifndef QT_LINUX_FUTEX
+diff --git a/qtbase/src/corelib/thread/qmutex.h b/qtbase/src/corelib/thread/qmutex.h
+index 73c9e00663..1bae573a03 100644
+--- a/qtbase/src/corelib/thread/qmutex.h
++++ b/qtbase/src/corelib/thread/qmutex.h
+@@ -42,6 +42,7 @@
+ 
+ #include <QtCore/qglobal.h>
+ #include <QtCore/qatomic.h>
++#include <QtCore/qtsan_impl.h>
+ #include <new>
+ 
+ #if __has_include(<chrono>)
+@@ -77,19 +78,37 @@ public:
+ 
+     // BasicLockable concept
+     inline void lock() QT_MUTEX_LOCK_NOEXCEPT {
++        QtTsan::mutexPreLock(this, 0u);
++
+         if (!fastTryLock())
+             lockInternal();
++
++        QtTsan::mutexPostLock(this, 0u, 0);
+     }
+ 
+     // BasicLockable concept
+     inline void unlock() noexcept {
+         Q_ASSERT(d_ptr.loadRelaxed()); //mutex must be locked
++
++        QtTsan::mutexPreUnlock(this, 0u);
++
+         if (!fastTryUnlock())
+             unlockInternal();
++
++        QtTsan::mutexPostUnlock(this, 0u);
+     }
+ 
+     bool tryLock() noexcept {
+-        return fastTryLock();
++        unsigned tsanFlags = QtTsan::TryLock;
++        QtTsan::mutexPreLock(this, tsanFlags);
++
++        const bool success = fastTryLock();
++
++        if (!success)
++            tsanFlags |= QtTsan::TryLockFailed;
++        QtTsan::mutexPostLock(this, tsanFlags, 0);
++
++        return success;
+     }
+ 
+     // Lockable concept
+@@ -134,8 +153,16 @@ public:
+ #else
+     QMutex() { d_ptr.storeRelaxed(nullptr); }
+ #endif
++#if QT_DEPRECATED_SINCE(5,15)
+     enum RecursionMode { NonRecursive, Recursive };
++    QT_DEPRECATED_VERSION_X(5, 15, "Use QRecursiveMutex instead of a recursive QMutex")
+     explicit QMutex(RecursionMode mode);
++
++    QT_DEPRECATED_VERSION_X(5, 15, "Use QRecursiveMutex instead of a recursive QMutex")
++    bool isRecursive() const noexcept
++    { return QBasicMutex::isRecursive(); }
++#endif
++
+     ~QMutex();
+ 
+     // BasicLockable concept
+@@ -166,9 +193,6 @@ public:
+     }
+ #endif
+ 
+-    bool isRecursive() const noexcept
+-    { return QBasicMutex::isRecursive(); }
+-
+ private:
+     Q_DISABLE_COPY(QMutex)
+     friend class QMutexLocker;
+diff --git a/qtbase/src/corelib/thread/qreadwritelock.cpp b/qtbase/src/corelib/thread/qreadwritelock.cpp
+index 8c28507d5a..9dd8503116 100644
+--- a/qtbase/src/corelib/thread/qreadwritelock.cpp
++++ b/qtbase/src/corelib/thread/qreadwritelock.cpp
+@@ -155,7 +155,7 @@ QReadWriteLock::QReadWriteLock(RecursionMode recursionMode)
+ */
+ QReadWriteLock::~QReadWriteLock()
+ {
+-    auto d = d_ptr.loadRelaxed();
++    auto d = d_ptr.loadAcquire();
+     if (isUncontendedLocked(d)) {
+         qWarning("QReadWriteLock: destroying locked QReadWriteLock");
+         return;
+@@ -445,7 +445,7 @@ void QReadWriteLock::unlock()
+ /*! \internal  Helper for QWaitCondition::wait */
+ QReadWriteLock::StateForWaitCondition QReadWriteLock::stateForWaitCondition() const
+ {
+-    QReadWriteLockPrivate *d = d_ptr.loadRelaxed();
++    QReadWriteLockPrivate *d = d_ptr.loadAcquire();
+     switch (quintptr(d) & StateMask) {
+     case StateLockedForRead: return LockedForRead;
+     case StateLockedForWrite: return LockedForWrite;
+@@ -453,6 +453,7 @@ QReadWriteLock::StateForWaitCondition QReadWriteLock::stateForWaitCondition() co
+ 
+     if (!d)
+         return Unlocked;
++    const auto lock = qt_scoped_lock(d->mutex);
+     if (d->writerCount > 1)
+         return RecursivelyLocked;
+     else if (d->writerCount == 1)
+diff --git a/qtbase/src/corelib/thread/qsemaphore.cpp b/qtbase/src/corelib/thread/qsemaphore.cpp
+index 1d01fc1b28..3ecdee3747 100644
+--- a/qtbase/src/corelib/thread/qsemaphore.cpp
++++ b/qtbase/src/corelib/thread/qsemaphore.cpp
+@@ -354,7 +354,12 @@ void QSemaphore::release(int n)
+         quintptr nn = unsigned(n);
+         if (futexHasWaiterCount)
+             nn |= quint64(nn) << 32;    // token count replicated in high word
+-        quintptr prevValue = u.fetchAndAddRelease(nn);
++        quintptr prevValue = u.loadRelaxed();
++        quintptr newValue;
++        do { // loop just to ensure the operations are done atomically
++            newValue = prevValue + nn;
++            newValue &= (futexNeedsWakeAllBit - 1);
++        } while (!u.testAndSetRelease(prevValue, newValue, prevValue));
+         if (futexNeedsWake(prevValue)) {
+ #ifdef FUTEX_OP
+             if (futexHasWaiterCount) {
+@@ -376,7 +381,6 @@ void QSemaphore::release(int n)
+                 quint32 oparg = 0;
+                 quint32 cmp = FUTEX_OP_CMP_NE;
+                 quint32 cmparg = 0;
+-                u.fetchAndAndRelease(futexNeedsWakeAllBit - 1);
+                 futexWakeOp(*futexLow32(&u), n, INT_MAX, *futexHigh32(&u), FUTEX_OP(op, oparg, cmp, cmparg));
+                 return;
+             }
+@@ -388,7 +392,6 @@ 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(futexNeedsWakeAllBit - 1);
+             if (futexHasWaiterCount) {
+                 futexWakeAll(*futexLow32(&u));
+                 futexWakeAll(*futexHigh32(&u));
+diff --git a/qtbase/src/corelib/thread/qthread_p.h b/qtbase/src/corelib/thread/qthread_p.h
+index b2d1628e6e..f32f6f0460 100644
+--- a/qtbase/src/corelib/thread/qthread_p.h
++++ b/qtbase/src/corelib/thread/qthread_p.h
+@@ -174,7 +174,7 @@ public:
+     int returnCode;
+ 
+     uint stackSize;
+-    QThread::Priority priority;
++    std::underlying_type<QThread::Priority>::type priority;
+ 
+     static QThread *threadForId(int id);
+ 
+@@ -213,6 +213,13 @@ public:
+             QCoreApplication::instance()->postEvent(q_ptr, new QEvent(QEvent::Quit));
+         }
+     }
++
++#ifndef Q_OS_INTEGRITY
++private:
++    // Used in QThread(Private)::start to avoid racy access to QObject::objectName,
++    // unset afterwards. On INTEGRITY we set the thread name before starting it.
++    QString objectName;
++#endif
+ };
+ 
+ #else // QT_CONFIG(thread)
+diff --git a/qtbase/src/corelib/thread/qthread_unix.cpp b/qtbase/src/corelib/thread/qthread_unix.cpp
+index 56a8e0a038..610117a640 100644
+--- a/qtbase/src/corelib/thread/qthread_unix.cpp
++++ b/qtbase/src/corelib/thread/qthread_unix.cpp
+@@ -169,8 +169,7 @@ static void set_thread_data(QThreadData *data)
+ 
+ static void clear_thread_data()
+ {
+-    currentThreadData = nullptr;
+-    pthread_setspecific(current_thread_data_key, nullptr);
++    set_thread_data(nullptr);
+ }
+ 
+ template <typename T>
+@@ -296,7 +295,7 @@ void *QThreadPrivate::start(void *arg)
+             QMutexLocker locker(&thr->d_func()->mutex);
+ 
+             // do we need to reset the thread priority?
+-            if (int(thr->d_func()->priority) & ThreadPriorityResetFlag) {
++            if (thr->d_func()->priority & ThreadPriorityResetFlag) {
+                 thr->d_func()->setPriority(QThread::Priority(thr->d_func()->priority & ~ThreadPriorityResetFlag));
+             }
+ 
+@@ -316,10 +315,10 @@ void *QThreadPrivate::start(void *arg)
+             // Sets the name of the current thread. We can only do this
+             // when the thread is starting, as we don't have a cross
+             // platform way of setting the name of an arbitrary thread.
+-            if (Q_LIKELY(thr->objectName().isEmpty()))
++            if (Q_LIKELY(thr->d_func()->objectName.isEmpty()))
+                 setCurrentThreadName(thr->metaObject()->className());
+             else
+-                setCurrentThreadName(thr->objectName().toLocal8Bit());
++                setCurrentThreadName(std::exchange(thr->d_func()->objectName, {}).toLocal8Bit());
+         }
+ #endif
+ 
+@@ -671,7 +670,7 @@ void QThread::start(Priority priority)
+                 // could not set scheduling hints, fallback to inheriting them
+                 // we'll try again from inside the thread
+                 pthread_attr_setinheritsched(&attr, PTHREAD_INHERIT_SCHED);
+-                d->priority = Priority(priority | ThreadPriorityResetFlag);
++                d->priority = static_cast<std::underlying_type<QThread::Priority>::type>(priority) | ThreadPriorityResetFlag;
+             }
+             break;
+         }
+@@ -702,7 +701,10 @@ void QThread::start(Priority priority)
+         pthread_attr_setthreadname(&attr, metaObject()->className());
+     else
+         pthread_attr_setthreadname(&attr, objectName().toLocal8Bit());
++#else
++    d->objectName = objectName();
+ #endif
++
+     pthread_t threadId;
+     int code = pthread_create(&threadId, &attr, QThreadPrivate::start, this);
+     if (code == EPERM) {
+diff --git a/qtbase/src/corelib/thread/qthread_win.cpp b/qtbase/src/corelib/thread/qthread_win.cpp
+index bc70e3178a..4e76972498 100644
+--- a/qtbase/src/corelib/thread/qthread_win.cpp
++++ b/qtbase/src/corelib/thread/qthread_win.cpp
+@@ -394,10 +394,9 @@ unsigned int __stdcall QT_ENSURE_STACK_ALIGNED_FOR_SSE QThreadPrivate::start(voi
+ 
+ #if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) && !defined(Q_OS_WINRT)
+     // sets the name of the current thread.
+-    QByteArray objectName = thr->objectName().toLocal8Bit();
+-    qt_set_thread_name(HANDLE(-1),
+-                       objectName.isEmpty() ?
+-                       thr->metaObject()->className() : objectName.constData());
++    qt_set_thread_name(HANDLE(-1), thr->d_func()->objectName.isEmpty()
++                        ? thr->metaObject()->className()
++                        : std::exchange(thr->d_func()->objectName, {}).toLocal8Bit().constData());
+ #endif
+ 
+     emit thr->started(QThread::QPrivateSignal());
+@@ -503,6 +502,7 @@ void QThread::start(Priority priority)
+     if (d->running)
+         return;
+ 
++    d->objectName = objectName();
+     d->running = true;
+     d->finished = false;
+     d->exited = false;
+@@ -548,7 +548,7 @@ void QThread::start(Priority priority)
+ 
+     int prio;
+     d->priority = priority;
+-    switch (d->priority) {
++    switch (priority) {
+     case IdlePriority:
+         prio = THREAD_PRIORITY_IDLE;
+         break;
+@@ -686,7 +686,7 @@ void QThreadPrivate::setPriority(QThread::Priority threadPriority)
+ 
+     int prio;
+     priority = threadPriority;
+-    switch (priority) {
++    switch (threadPriority) {
+     case QThread::IdlePriority:
+         prio = THREAD_PRIORITY_IDLE;
+         break;
+diff --git a/qtbase/src/corelib/thread/qtsan_impl.h b/qtbase/src/corelib/thread/qtsan_impl.h
+new file mode 100644
+index 0000000000..580a738b91
+--- /dev/null
++++ b/qtbase/src/corelib/thread/qtsan_impl.h
+@@ -0,0 +1,115 @@
++/****************************************************************************
++**
++** Copyright (C) 2017 Intel Corporation.
++** Copyright (C) 2022 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
++** 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 QTSAN_IMPL_H
++#define QTSAN_IMPL_H
++
++#include <QtCore/qglobal.h>
++
++#if (__has_feature(thread_sanitizer) || defined(__SANITIZE_THREAD__)) && __has_include(<sanitizer/tsan_interface.h>)
++#  define QT_BUILDING_UNDER_TSAN
++#  include <sanitizer/tsan_interface.h>
++#endif
++
++QT_BEGIN_NAMESPACE
++
++namespace QtTsan {
++#ifdef QT_BUILDING_UNDER_TSAN
++inline void futexAcquire(void *addr, void *addr2 = nullptr)
++{
++    // A futex call ensures total ordering on the futex words
++    // (in either success or failure of the call). Instruct TSAN accordingly,
++    // as TSAN does not understand the futex(2) syscall (or equivalent).
++    ::__tsan_acquire(addr);
++    if (addr2)
++        ::__tsan_acquire(addr2);
++}
++
++inline void futexRelease(void *addr, void *addr2 = nullptr)
++{
++    if (addr2)
++        ::__tsan_release(addr2);
++    ::__tsan_release(addr);
++}
++
++inline void mutexPreLock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_pre_lock(addr, flags);
++}
++
++inline void mutexPostLock(void *addr, unsigned flags, int recursion)
++{
++    ::__tsan_mutex_post_lock(addr, flags, recursion);
++}
++
++inline void mutexPreUnlock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_pre_unlock(addr, flags);
++}
++
++inline void mutexPostUnlock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_post_unlock(addr, flags);
++}
++
++enum : unsigned {
++    MutexWriteReentrant = ::__tsan_mutex_write_reentrant,
++    TryLock = ::__tsan_mutex_try_lock,
++    TryLockFailed = ::__tsan_mutex_try_lock_failed,
++};
++#else
++inline void futexAcquire(void *, void * = nullptr) {}
++inline void futexRelease(void *, void * = nullptr) {}
++
++enum : unsigned {
++    MutexWriteReentrant,
++    TryLock,
++    TryLockFailed,
++};
++inline void mutexPreLock(void *, unsigned) {}
++inline void mutexPostLock(void *, unsigned, int) {}
++inline void mutexPreUnlock(void *, unsigned) {}
++inline void mutexPostUnlock(void *, unsigned) {}
++#endif // QT_BUILDING_UNDER_TSAN
++} // namespace QtTsan
++
++QT_END_NAMESPACE
++
++#endif // QTSAN_IMPL_H
+diff --git a/qtbase/src/corelib/thread/qwaitcondition_unix.cpp b/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
+index 88b058f410..0f1da4dc9b 100644
+--- a/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
++++ b/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
+@@ -213,7 +213,7 @@ bool QWaitCondition::wait(QMutex *mutex, QDeadlineTimer deadline)
+ {
+     if (! mutex)
+         return false;
+-    if (mutex->isRecursive()) {
++    if (static_cast<QBasicMutex *>(mutex)->isRecursive()) {
+         qWarning("QWaitCondition: cannot wait on recursive mutexes");
+         return false;
+     }
+diff --git a/qtbase/src/corelib/time/qdatetime.cpp b/qtbase/src/corelib/time/qdatetime.cpp
+index ec12569e3f..2c0b098079 100644
+--- a/qtbase/src/corelib/time/qdatetime.cpp
++++ b/qtbase/src/corelib/time/qdatetime.cpp
+@@ -43,6 +43,7 @@
+ #if QT_CONFIG(datetimeparser)
+ #include "private/qdatetimeparser_p.h"
+ #endif
++#include <private/qnumeric_p.h>
+ 
+ #include "qdatastream.h"
+ #include "qset.h"
+@@ -1429,9 +1430,11 @@ QDate QDate::addDays(qint64 ndays) const
+     if (isNull())
+         return QDate();
+ 
+-    // Due to limits on minJd() and maxJd() we know that any overflow
+-    // will be invalid and caught by fromJulianDay().
+-    return fromJulianDay(jd + ndays);
++    qint64 r;
++    if (Q_UNLIKELY(add_overflow(jd, ndays, &r)))
++        return QDate();
++    else
++        return fromJulianDay(r);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/corelib/time/qtimezone.cpp b/qtbase/src/corelib/time/qtimezone.cpp
+index 0309e43e52..3d451696a1 100644
+--- a/qtbase/src/corelib/time/qtimezone.cpp
++++ b/qtbase/src/corelib/time/qtimezone.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2013 John Layt <jlayt@kde.org>
++** Copyright (C) 2020 John Layt <jlayt@kde.org>
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtCore module of the Qt Toolkit.
+@@ -975,9 +975,15 @@ QList<QByteArray> QTimeZone::windowsIdToIanaIds(const QByteArray &windowsId,
+ }
+ 
+ #ifndef QT_NO_DATASTREAM
++// Invalid, as an IANA ID: too long, starts with - and has other invalid characters in it
++static inline QString invalidId() { return QStringLiteral("-No Time Zone Specified!"); }
++
+ QDataStream &operator<<(QDataStream &ds, const QTimeZone &tz)
+ {
+-    tz.d->serialize(ds);
++    if (tz.isValid())
++        tz.d->serialize(ds);
++    else
++        ds << invalidId();
+     return ds;
+ }
+ 
+@@ -985,7 +991,9 @@ QDataStream &operator>>(QDataStream &ds, QTimeZone &tz)
+ {
+     QString ianaId;
+     ds >> ianaId;
+-    if (ianaId == QLatin1String("OffsetFromUtc")) {
++    if (ianaId == invalidId()) {
++        tz = QTimeZone();
++    } else if (ianaId == QLatin1String("OffsetFromUtc")) {
+         int utcOffset;
+         QString name;
+         QString abbreviation;
+diff --git a/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp b/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
+index b1611d7ddb..a7a6a72ccf 100644
+--- a/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
++++ b/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
+@@ -42,6 +42,7 @@
+ #include "qtimezone.h"
+ #include "qtimezoneprivate_p.h"
+ #include "private/qlocale_tools_p.h"
++#include "private/qlocking_p.h"
+ 
+ #include <QtCore/QDataStream>
+ #include <QtCore/QDateTime>
+@@ -62,6 +63,10 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++#if QT_CONFIG(icu)
++static QBasicMutex s_icu_mutex;
++#endif
++
+ /*
+     Private
+ 
+@@ -670,6 +675,9 @@ QTzTimeZonePrivate::~QTzTimeZonePrivate()
+ 
+ QTzTimeZonePrivate *QTzTimeZonePrivate::clone() const
+ {
++#if QT_CONFIG(icu)
++    const auto lock = qt_scoped_lock(s_icu_mutex);
++#endif
+     return new QTzTimeZonePrivate(*this);
+ }
+ 
+@@ -913,12 +921,14 @@ QString QTzTimeZonePrivate::displayName(qint64 atMSecsSinceEpoch,
+                                         const QLocale &locale) const
+ {
+ #if QT_CONFIG(icu)
++    auto lock = qt_unique_lock(s_icu_mutex);
+     if (!m_icu)
+         m_icu = new QIcuTimeZonePrivate(m_id);
+     // TODO small risk may not match if tran times differ due to outdated files
+     // TODO Some valid TZ names are not valid ICU names, use translation table?
+     if (m_icu->isValid())
+         return m_icu->displayName(atMSecsSinceEpoch, nameType, locale);
++    lock.unlock();
+ #else
+     Q_UNUSED(nameType)
+     Q_UNUSED(locale)
+@@ -932,12 +942,14 @@ QString QTzTimeZonePrivate::displayName(QTimeZone::TimeType timeType,
+                                         const QLocale &locale) const
+ {
+ #if QT_CONFIG(icu)
++    auto lock = qt_unique_lock(s_icu_mutex);
+     if (!m_icu)
+         m_icu = new QIcuTimeZonePrivate(m_id);
+     // TODO small risk may not match if tran times differ due to outdated files
+     // TODO Some valid TZ names are not valid ICU names, use translation table?
+     if (m_icu->isValid())
+         return m_icu->displayName(timeType, nameType, locale);
++    lock.unlock();
+ #else
+     Q_UNUSED(timeType)
+     Q_UNUSED(nameType)
+diff --git a/qtbase/src/corelib/tools/qarraydata.h b/qtbase/src/corelib/tools/qarraydata.h
+index dcd95924c1..d01739e7e6 100644
+--- a/qtbase/src/corelib/tools/qarraydata.h
++++ b/qtbase/src/corelib/tools/qarraydata.h
+@@ -42,6 +42,7 @@
+ 
+ #include <QtCore/qrefcount.h>
+ #include <string.h>
++#include <cstdint>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -58,14 +59,14 @@ struct Q_CORE_EXPORT QArrayData
+     {
+         Q_ASSERT(size == 0
+                 || offset < 0 || size_t(offset) >= sizeof(QArrayData));
+-        return reinterpret_cast<char *>(this) + offset;
++        return reinterpret_cast<void *> (reinterpret_cast<uintptr_t>(this) + offset);
+     }
+ 
+     const void *data() const
+     {
+         Q_ASSERT(size == 0
+                 || offset < 0 || size_t(offset) >= sizeof(QArrayData));
+-        return reinterpret_cast<const char *>(this) + offset;
++        return reinterpret_cast<void *> (reinterpret_cast<uintptr_t>(this) + offset);
+     }
+ 
+     // This refers to array data mutability, not "header data" represented by
+diff --git a/qtbase/src/corelib/tools/qfreelist_p.h b/qtbase/src/corelib/tools/qfreelist_p.h
+index 5ba23b344b..9974102136 100644
+--- a/qtbase/src/corelib/tools/qfreelist_p.h
++++ b/qtbase/src/corelib/tools/qfreelist_p.h
+@@ -161,7 +161,7 @@ class QFreeList
+                 return i;
+             x -= size;
+         }
+-        Q_ASSERT(false);
++        Q_UNREACHABLE();
+         return -1;
+     }
+ 
+diff --git a/qtbase/src/corelib/tools/qversionnumber.h b/qtbase/src/corelib/tools/qversionnumber.h
+index d43b86ba51..2843f2b043 100644
+--- a/qtbase/src/corelib/tools/qversionnumber.h
++++ b/qtbase/src/corelib/tools/qversionnumber.h
+@@ -273,10 +273,10 @@ public:
+ 
+     Q_REQUIRED_RESULT Q_CORE_EXPORT QString toString() const;
+ #if QT_STRINGVIEW_LEVEL < 2
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(const QString &string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(const QString &string, int *suffixIndex = nullptr);
+ #endif
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QLatin1String string, int *suffixIndex = nullptr);
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QStringView string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(QLatin1String string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(QStringView string, int *suffixIndex = nullptr);
+ 
+ private:
+ #ifndef QT_NO_DATASTREAM
+diff --git a/qtbase/src/dbus/qdbusintegrator.cpp b/qtbase/src/dbus/qdbusintegrator.cpp
+index 5b66ce971b..28a3b0ffea 100644
+--- a/qtbase/src/dbus/qdbusintegrator.cpp
++++ b/qtbase/src/dbus/qdbusintegrator.cpp
+@@ -1135,7 +1135,13 @@ void QDBusConnectionPrivate::closeConnection()
+         }
+     }
+ 
+-    qDeleteAll(pendingCalls);
++    for (auto it = pendingCalls.begin(); it != pendingCalls.end(); ++it) {
++        auto call = *it;
++        if (!call->ref.deref()) {
++            delete call;
++        }
++    }
++    pendingCalls.clear();
+ 
+     // Disconnect all signals from signal hooks and from the object tree to
+     // avoid QObject::destroyed being sent to dbus daemon thread which has
+@@ -2584,6 +2590,11 @@ QDBusConnectionPrivate::findMetaObject(const QString &service, const QString &pa
+         if (mo)
+             return mo;
+     }
++    if (path.isEmpty()) {
++        error = QDBusError(QDBusError::InvalidObjectPath, QLatin1String("Object path cannot be empty"));
++        lastError = error;
++        return nullptr;
++    }
+ 
+     // introspect the target object
+     QDBusMessage msg = QDBusMessage::createMethodCall(service, path,
+diff --git a/qtbase/src/dbus/qdbusmetaobject.cpp b/qtbase/src/dbus/qdbusmetaobject.cpp
+index 5265568f42..7e9f0f1acc 100644
+--- a/qtbase/src/dbus/qdbusmetaobject.cpp
++++ b/qtbase/src/dbus/qdbusmetaobject.cpp
+@@ -210,6 +210,9 @@ QDBusMetaObjectGenerator::findType(const QByteArray &signature,
+         } else if (signature == "a{ss}") {
+             result.name = "QMap<QString,QString>";
+             type = qMetaTypeId<QMap<QString, QString> >();
++        } else if (signature == "aay") {
++            result.name = "QByteArrayList";
++            type = qMetaTypeId<QByteArrayList>();
+         } else {
+             result.name = "{D-Bus type \"" + signature + "\"}";
+             type = registerComplexDBusType(result.name);
+diff --git a/qtbase/src/gui/accessible/qaccessible.cpp b/qtbase/src/gui/accessible/qaccessible.cpp
+index d705bfccb5..0caf3c808c 100644
+--- a/qtbase/src/gui/accessible/qaccessible.cpp
++++ b/qtbase/src/gui/accessible/qaccessible.cpp
+@@ -54,6 +54,7 @@
+ #include <QtCore/qdebug.h>
+ #include <QtCore/qloggingcategory.h>
+ #include <QtCore/qmetaobject.h>
++#include <QtCore/private/qmetaobject_p.h>
+ #include <QtCore/qhash.h>
+ #include <private/qfactoryloader_p.h>
+ 
+@@ -681,6 +682,25 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
+     // Create a QAccessibleInterface for the object class. Start by the most
+     // derived class and walk up the class hierarchy.
+     const QMetaObject *mo = object->metaObject();
++    const auto *objectPriv = QObjectPrivate::get(object);
++    /*
++     We do not want to cache each and every QML metaobject (Button_QMLTYPE_124,
++     Button_QMLTYPE_125, etc.). Those dynamic metaobjects shouldn't have an
++     accessible interface in any case. Instead, we start the whole checking
++     with the first non-dynamic meta-object. To avoid potential regressions
++     in other areas of Qt that also use dynamic metaobjects, we only do this
++     for objects that are QML-related (approximated by checking whether they
++     have ddata set).
++    */
++    const bool qmlRelated = !objectPriv->isDeletingChildren &&
++                            objectPriv->declarativeData;
++    while (qmlRelated && mo) {
++        auto mop = QMetaObjectPrivate::get(mo);
++        if (!mop || !(mop->flags & DynamicMetaObject))
++            break;
++
++        mo = mo->superClass();
++    };
+     while (mo) {
+         const QString cn = QLatin1String(mo->className());
+ 
+@@ -696,14 +716,15 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
+         // Find a QAccessiblePlugin (factory) for the class name. If there's
+         // no entry in the cache try to create it using the plugin loader.
+         if (!qAccessiblePlugins()->contains(cn)) {
++            QAccessiblePlugin *factory = nullptr; // 0 means "no plugin found". This is cached as well.
+             const int index = loader()->indexOf(cn);
+-            if (index != -1) {
+-                QAccessiblePlugin *factory = qobject_cast<QAccessiblePlugin *>(loader()->instance(index));
+-                qAccessiblePlugins()->insert(cn, factory);
+-            }
++            if (index != -1)
++                factory = qobject_cast<QAccessiblePlugin *>(loader()->instance(index));
++            qAccessiblePlugins()->insert(cn, factory);
+         }
+ 
+         // At this point the cache should contain a valid factory pointer or 0:
++        Q_ASSERT(qAccessiblePlugins()->contains(cn));
+         QAccessiblePlugin *factory = qAccessiblePlugins()->value(cn);
+         if (factory) {
+             QAccessibleInterface *result = factory->create(cn, object);
+diff --git a/qtbase/src/gui/configure.json b/qtbase/src/gui/configure.json
+index 1f08795c57..12c95742d2 100644
+--- a/qtbase/src/gui/configure.json
++++ b/qtbase/src/gui/configure.json
+@@ -834,7 +834,8 @@
+                     "// embedded devices, are not intended to be used together with X. EGL support",
+                     "// has to be disabled in plugins like xcb in this case since the native display,",
+                     "// window and pixmap types will be different than what an X-based platform",
+-                    "// plugin would expect."
++                    "// plugin would expect.",
++                    "#define USE_X11"
+                 ],
+                 "include": [ "EGL/egl.h", "X11/Xlib.h" ],
+                 "main": [
+diff --git a/qtbase/src/gui/image/qbmphandler.cpp b/qtbase/src/gui/image/qbmphandler.cpp
+index 96f1e8cb1d..0e73bbbdb0 100644
+--- a/qtbase/src/gui/image/qbmphandler.cpp
++++ b/qtbase/src/gui/image/qbmphandler.cpp
+@@ -150,16 +150,42 @@ static QDataStream &operator<<(QDataStream &s, const BMP_INFOHDR &bi)
+     return s;
+ }
+ 
+-static int calc_shift(uint mask)
++static uint calc_shift(uint mask)
+ {
+-    int result = 0;
+-    while (mask && !(mask & 1)) {
++    uint result = 0;
++    while ((mask >= 0x100) || (!(mask & 1) && mask)) {
+         result++;
+         mask >>= 1;
+     }
+     return result;
+ }
+ 
++static uint calc_scale(uint low_mask)
++{
++    uint result = 8;
++    while (low_mask && result) {
++        result--;
++        low_mask >>= 1;
++    }
++    return result;
++}
++
++static inline uint apply_scale(uint value, uint scale)
++{
++    if (!(scale & 0x07)) // return immediately if scale == 8 or 0
++        return value;
++
++    uint filled = 8 - scale;
++    uint result = value << scale;
++
++    do {
++        result |= result >> filled;
++        filled <<= 1;
++    } while (filled < 8);
++
++    return result;
++}
++
+ static bool read_dib_fileheader(QDataStream &s, BMP_FILEHDR &bf)
+ {
+     // read BMP file header
+@@ -222,14 +248,14 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+     uint green_mask = 0;
+     uint blue_mask = 0;
+     uint alpha_mask = 0;
+-    int red_shift = 0;
+-    int green_shift = 0;
+-    int blue_shift = 0;
+-    int alpha_shift = 0;
+-    int red_scale = 0;
+-    int green_scale = 0;
+-    int blue_scale = 0;
+-    int alpha_scale = 0;
++    uint red_shift = 0;
++    uint green_shift = 0;
++    uint blue_shift = 0;
++    uint alpha_shift = 0;
++    uint red_scale = 0;
++    uint green_scale = 0;
++    uint blue_scale = 0;
++    uint alpha_scale = 0;
+ 
+     if (!d->isSequential())
+         d->seek(startpos + BMP_FILEHDR_SIZE + bi.biSize); // goto start of colormap or masks
+@@ -308,19 +334,19 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+         red_shift = calc_shift(red_mask);
+         if (((red_mask >> red_shift) + 1) == 0)
+             return false;
+-        red_scale = 256 / ((red_mask >> red_shift) + 1);
++        red_scale = calc_scale(red_mask >> red_shift);
+         green_shift = calc_shift(green_mask);
+         if (((green_mask >> green_shift) + 1) == 0)
+             return false;
+-        green_scale = 256 / ((green_mask >> green_shift) + 1);
++        green_scale = calc_scale(green_mask >> green_shift);
+         blue_shift = calc_shift(blue_mask);
+         if (((blue_mask >> blue_shift) + 1) == 0)
+             return false;
+-        blue_scale = 256 / ((blue_mask >> blue_shift) + 1);
++        blue_scale = calc_scale(blue_mask >> blue_shift);
+         alpha_shift = calc_shift(alpha_mask);
+         if (((alpha_mask >> alpha_shift) + 1) == 0)
+             return false;
+-        alpha_scale = 256 / ((alpha_mask >> alpha_shift) + 1);
++        alpha_scale = calc_scale(alpha_mask >> alpha_shift);
+     } else if (comp == BMP_RGB && (nbits == 24 || nbits == 32)) {
+         blue_mask = 0x000000ff;
+         green_mask = 0x0000ff00;
+@@ -328,17 +354,15 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+         blue_shift = 0;
+         green_shift = 8;
+         red_shift = 16;
+-        blue_scale = green_scale = red_scale = 1;
++        blue_scale = green_scale = red_scale = 0;
+     } else if (comp == BMP_RGB && nbits == 16) {
+         blue_mask = 0x001f;
+         green_mask = 0x03e0;
+         red_mask = 0x7c00;
+         blue_shift = 0;
+-        green_shift = 2;
+-        red_shift = 7;
+-        red_scale = 1;
+-        green_scale = 1;
+-        blue_scale = 8;
++        green_shift = 5;
++        red_shift = 10;
++        blue_scale = green_scale = red_scale = 3;
+     }
+ 
+ #if 0
+@@ -544,10 +568,10 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+                     c |= *(uchar*)(b+2)<<16;
+                 if (nbits > 24)
+                     c |= *(uchar*)(b+3)<<24;
+-                *p++ = qRgba(((c & red_mask) >> red_shift) * red_scale,
+-                                        ((c & green_mask) >> green_shift) * green_scale,
+-                                        ((c & blue_mask) >> blue_shift) * blue_scale,
+-                                        transp ? ((c & alpha_mask) >> alpha_shift) * alpha_scale : 0xff);
++                *p++ = qRgba(apply_scale((c & red_mask) >> red_shift, red_scale),
++                             apply_scale((c & green_mask) >> green_shift, green_scale),
++                             apply_scale((c & blue_mask) >> blue_shift, blue_scale),
++                             transp ? apply_scale((c & alpha_mask) >> alpha_shift, alpha_scale) : 0xff);
+                 b += nbits/8;
+             }
+         }
+diff --git a/qtbase/src/gui/image/qimage.cpp b/qtbase/src/gui/image/qimage.cpp
+index 7152ac1607..0df772564c 100644
+--- a/qtbase/src/gui/image/qimage.cpp
++++ b/qtbase/src/gui/image/qimage.cpp
+@@ -4694,6 +4694,8 @@ QImage QImage::smoothScaled(int w, int h) const {
+ static QImage rotated90(const QImage &image)
+ {
+     QImage out(image.height(), image.width(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+@@ -4722,6 +4724,8 @@ static QImage rotated180(const QImage &image)
+         return image.mirrored(true, true);
+ 
+     QImage out(image.width(), image.height(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+@@ -4734,6 +4738,8 @@ static QImage rotated180(const QImage &image)
+ static QImage rotated270(const QImage &image)
+ {
+     QImage out(image.height(), image.width(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+diff --git a/qtbase/src/gui/kernel/qcursor.cpp b/qtbase/src/gui/kernel/qcursor.cpp
+index d6ccaff8ed..455088241c 100644
+--- a/qtbase/src/gui/kernel/qcursor.cpp
++++ b/qtbase/src/gui/kernel/qcursor.cpp
+@@ -251,7 +251,8 @@ void QCursor::setPos(QScreen *screen, int x, int y)
+ {
+     if (screen) {
+         if (QPlatformCursor *cursor = screen->handle()->cursor()) {
+-            const QPoint devicePos = QHighDpi::toNativePixels(QPoint(x, y), screen);
++            const QPoint pos(x, y);
++            const QPoint devicePos = QHighDpi::toNativePixels(pos, screen->virtualSiblingAt(pos));
+             // Need to check, since some X servers generate null mouse move
+             // events, causing looping in applications which call setPos() on
+             // every mouse move event.
+diff --git a/qtbase/src/gui/kernel/qhighdpiscaling.cpp b/qtbase/src/gui/kernel/qhighdpiscaling.cpp
+index 9bbf2773a9..3ac4a4d8b6 100644
+--- a/qtbase/src/gui/kernel/qhighdpiscaling.cpp
++++ b/qtbase/src/gui/kernel/qhighdpiscaling.cpp
+@@ -580,9 +580,8 @@ void QHighDpiScaling::setScreenFactor(QScreen *screen, qreal factor)
+     else
+         qNamedScreenScaleFactors()->insert(name, factor);
+ 
+-    // hack to force re-evaluation of screen geometry
+     if (screen->handle())
+-        screen->d_func()->setPlatformScreen(screen->handle()); // updates geometries based on scale factor
++        screen->d_func()->updateLogicalDpi();
+ }
+ 
+ QPoint QHighDpiScaling::mapPositionToNative(const QPoint &pos, const QPlatformScreen *platformScreen)
+diff --git a/qtbase/src/gui/kernel/qkeysequence.cpp b/qtbase/src/gui/kernel/qkeysequence.cpp
+index a75b8ef920..4f2d294739 100644
+--- a/qtbase/src/gui/kernel/qkeysequence.cpp
++++ b/qtbase/src/gui/kernel/qkeysequence.cpp
+@@ -701,6 +701,10 @@ static const struct {
+     { Qt::Key_TouchpadToggle,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad Toggle") },
+     { Qt::Key_TouchpadOn,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad On") },
+     { Qt::Key_TouchpadOff,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad Off") },
++    { Qt::Key_Shift,  QT_TRANSLATE_NOOP("QShortcut", "Shift") },
++    { Qt::Key_Control,  QT_TRANSLATE_NOOP("QShortcut", "Control") },
++    { Qt::Key_Alt,  QT_TRANSLATE_NOOP("QShortcut", "Alt") },
++    { Qt::Key_Meta,  QT_TRANSLATE_NOOP("QShortcut", "Meta") },
+ 
+ };
+ static Q_CONSTEXPR int numKeyNames = sizeof keyname / sizeof *keyname;
+diff --git a/qtbase/src/gui/kernel/qplatformservices.cpp b/qtbase/src/gui/kernel/qplatformservices.cpp
+index fdc6a6c4aa..ac47f98c5d 100644
+--- a/qtbase/src/gui/kernel/qplatformservices.cpp
++++ b/qtbase/src/gui/kernel/qplatformservices.cpp
+@@ -55,6 +55,19 @@ QT_BEGIN_NAMESPACE
+     \brief The QPlatformServices provides the backend for desktop-related functionality.
+ */
+ 
++/*!
++    \enum QPlatformServices::Capability
++
++    Capabilities are used to determine a specific platform service's availability.
++
++    \value ColorPickingFromScreen The platform natively supports color picking from screen.
++    This capability indicates that the platform supports "opaque" color picking, where the
++    platform implements a complete user experience for color picking and outputs a color.
++    This is in contrast to the application implementing the color picking user experience
++    (taking care of showing a cross hair, instructing the platform integration to obtain
++    the color at a given pixel, etc.). The related service function is pickColor().
++ */
++
+ QPlatformServices::QPlatformServices()
+ { }
+ 
+@@ -85,5 +98,16 @@ QByteArray QPlatformServices::desktopEnvironment() const
+     return QByteArray("UNKNOWN");
+ }
+ 
++QPlatformServiceColorPicker *QPlatformServices::colorPicker(QWindow *parent)
++{
++    Q_UNUSED(parent);
++    return nullptr;
++}
++
++bool QPlatformServices::hasCapability(Capability capability) const
++{
++    Q_UNUSED(capability)
++    return false;
++}
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/gui/kernel/qplatformservices.h b/qtbase/src/gui/kernel/qplatformservices.h
+index 5de96cfa7d..a8b2a4ce71 100644
+--- a/qtbase/src/gui/kernel/qplatformservices.h
++++ b/qtbase/src/gui/kernel/qplatformservices.h
+@@ -50,16 +50,32 @@
+ //
+ 
+ #include <QtGui/qtguiglobal.h>
++#include <QtCore/qobject.h>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+ class QUrl;
++class QWindow;
++
++class Q_GUI_EXPORT QPlatformServiceColorPicker : public QObject
++{
++    Q_OBJECT
++public:
++    using QObject::QObject;
++    virtual void pickColor() = 0;
++Q_SIGNALS:
++    void colorPicked(const QColor &color);
++};
+ 
+ class Q_GUI_EXPORT QPlatformServices
+ {
+ public:
+     Q_DISABLE_COPY_MOVE(QPlatformServices)
+ 
++    enum Capability {
++        ColorPicking,
++    };
++
+     QPlatformServices();
+     virtual ~QPlatformServices() { }
+ 
+@@ -67,6 +83,10 @@ public:
+     virtual bool openDocument(const QUrl &url);
+ 
+     virtual QByteArray desktopEnvironment() const;
++
++    virtual bool hasCapability(Capability capability) const;
++
++    virtual QPlatformServiceColorPicker *colorPicker(QWindow *parent = nullptr);
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/gui/kernel/qplatformtheme.cpp b/qtbase/src/gui/kernel/qplatformtheme.cpp
+index 71521c0339..2325873245 100644
+--- a/qtbase/src/gui/kernel/qplatformtheme.cpp
++++ b/qtbase/src/gui/kernel/qplatformtheme.cpp
+@@ -163,6 +163,8 @@ QT_BEGIN_NAMESPACE
+ 
+     \value ShowShortcutsInContextMenus (bool) Whether to display shortcut key sequences in context menus.
+ 
++    \value ButtonPressKeys (QList<Qt::Key>) A list of keys that can be used to press buttons via keyboard input.
++
+     \sa themeHint(), QStyle::pixelMetric()
+ */
+ 
+@@ -563,6 +565,8 @@ QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint)
+         }
+     case MouseQuickSelectionThreshold:
+         return QVariant(10);
++    case ButtonPressKeys:
++        return QVariant::fromValue(QList<Qt::Key>({ Qt::Key_Space, Qt::Key_Select }));
+     }
+     return QVariant();
+ }
+diff --git a/qtbase/src/gui/kernel/qplatformtheme.h b/qtbase/src/gui/kernel/qplatformtheme.h
+index 3185fc4541..7e6c9d5740 100644
+--- a/qtbase/src/gui/kernel/qplatformtheme.h
++++ b/qtbase/src/gui/kernel/qplatformtheme.h
+@@ -120,7 +120,8 @@ public:
+         TouchDoubleTapDistance,
+         ShowShortcutsInContextMenus,
+         IconFallbackSearchPaths,
+-        MouseQuickSelectionThreshold
++        MouseQuickSelectionThreshold,
++        ButtonPressKeys
+     };
+ 
+     enum DialogType {
+diff --git a/qtbase/src/gui/kernel/qscreen.cpp b/qtbase/src/gui/kernel/qscreen.cpp
+index 8e0eb35116..5d172a58dd 100644
+--- a/qtbase/src/gui/kernel/qscreen.cpp
++++ b/qtbase/src/gui/kernel/qscreen.cpp
+@@ -77,6 +77,12 @@ QScreen::QScreen(QPlatformScreen *screen)
+     d->setPlatformScreen(screen);
+ }
+ 
++void QScreenPrivate::updateLogicalDpi()
++{
++    logicalDpi = QPlatformScreen::overrideDpi(platformScreen->logicalDpi());
++    updateGeometriesWithSignals(); // updates geometries based on scale factor
++}
++
+ void QScreenPrivate::updateGeometriesWithSignals()
+ {
+     const QRect oldGeometry = geometry;
+diff --git a/qtbase/src/gui/kernel/qscreen_p.h b/qtbase/src/gui/kernel/qscreen_p.h
+index 7da542c25e..e50fc3190b 100644
+--- a/qtbase/src/gui/kernel/qscreen_p.h
++++ b/qtbase/src/gui/kernel/qscreen_p.h
+@@ -70,6 +70,7 @@ public:
+         geometry = platformScreen->deviceIndependentGeometry();
+         availableGeometry = QHighDpi::fromNative(platformScreen->availableGeometry(), QHighDpiScaling::factor(platformScreen), geometry.topLeft());
+     }
++    void updateLogicalDpi();
+ 
+     void updatePrimaryOrientation();
+     void updateGeometriesWithSignals();
+diff --git a/qtbase/src/gui/painting/qblendfunctions_p.h b/qtbase/src/gui/painting/qblendfunctions_p.h
+index 080da98ec4..6997d62b3c 100644
+--- a/qtbase/src/gui/painting/qblendfunctions_p.h
++++ b/qtbase/src/gui/painting/qblendfunctions_p.h
+@@ -246,25 +246,32 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+                                   int dudx, int dvdx, int dudy, int dvdy, int u0, int v0,
+                                   Blender blender)
+ {
+-    int fromY = qMax(qRound(topY), clip.top());
+-    int toY = qMin(qRound(bottomY), clip.top() + clip.height());
++    qint64 fromY = qMax(qRound(topY), clip.top());
++    qint64 toY = qMin(qRound(bottomY), clip.top() + clip.height());
+     if (fromY >= toY)
+         return;
+ 
+     qreal leftSlope = (bottomLeft.x - topLeft.x) / (bottomLeft.y - topLeft.y);
+     qreal rightSlope = (bottomRight.x - topRight.x) / (bottomRight.y - topRight.y);
+-    int dx_l = int(leftSlope * 0x10000);
+-    int dx_r = int(rightSlope * 0x10000);
+-    int x_l = int((topLeft.x + (qreal(0.5) + fromY - topLeft.y) * leftSlope + qreal(0.5)) * 0x10000);
+-    int x_r = int((topRight.x + (qreal(0.5) + fromY - topRight.y) * rightSlope + qreal(0.5)) * 0x10000);
+-
+-    int fromX, toX, x1, x2, u, v, i, ii;
++    qint64 dx_l = qint64(leftSlope * 0x10000);
++    qint64 dx_r = qint64(rightSlope * 0x10000);
++    qint64 x_l = qint64((topLeft.x + (qreal(0.5) + fromY - topLeft.y) * leftSlope + qreal(0.5)) * 0x10000);
++    qint64 x_r = qint64((topRight.x + (qreal(0.5) + fromY - topRight.y) * rightSlope + qreal(0.5)) * 0x10000);
++
++    qint64 sourceRectTop = qint64(sourceRect.top());
++    qint64 sourceRectLeft = qint64(sourceRect.left());
++    qint64 sourceRectWidth = qint64(sourceRect.width());
++    qint64 sourceRectHeight = qint64(sourceRect.height());
++    qint64 clipLeft = qint64(clip.left());
++    qint64 clipWidth = qint64(clip.width());
++
++    qint64 fromX, toX, x1, x2, u, v, i, ii;
+     DestT *line;
+-    for (int y = fromY; y < toY; ++y) {
++    for (qint64 y = fromY; y < toY; ++y) {
+         line = reinterpret_cast<DestT *>(reinterpret_cast<uchar *>(destPixels) + y * dbpl);
+ 
+-        fromX = qMax(x_l >> 16, clip.left());
+-        toX = qMin(x_r >> 16, clip.left() + clip.width());
++        fromX = qMax(x_l >> 16, clipLeft);
++        toX = qMin(x_r >> 16, clipLeft + clipWidth);
+         if (fromX < toX) {
+             // Because of rounding, we can get source coordinates outside the source image.
+             // Clamp these coordinates to the source rect to avoid segmentation fault and
+@@ -275,10 +282,10 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             u = x1 * dudx + y * dudy + u0;
+             v = x1 * dvdx + y * dvdy + v0;
+             for (; x1 < toX; ++x1) {
+-                int uu = u >> 16;
+-                int vv = v >> 16;
+-                if (uu >= sourceRect.left() && uu < sourceRect.left() + sourceRect.width()
+-                    && vv >= sourceRect.top() && vv < sourceRect.top() + sourceRect.height()) {
++                qint64 uu = u >> 16;
++                qint64 vv = v >> 16;
++                if (uu >= sourceRectLeft && uu < sourceRectLeft + sourceRectWidth
++                    && vv >= sourceRectTop && vv < sourceRectTop + sourceRectHeight) {
+                     break;
+                 }
+                 u += dudx;
+@@ -290,10 +297,10 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             u = (x2 - 1) * dudx + y * dudy + u0;
+             v = (x2 - 1) * dvdx + y * dvdy + v0;
+             for (; x2 > x1; --x2) {
+-                int uu = u >> 16;
+-                int vv = v >> 16;
+-                if (uu >= sourceRect.left() && uu < sourceRect.left() + sourceRect.width()
+-                    && vv >= sourceRect.top() && vv < sourceRect.top() + sourceRect.height()) {
++                qint64 uu = u >> 16;
++                qint64 vv = v >> 16;
++                if (uu >= sourceRectLeft && uu < sourceRectLeft + sourceRectWidth
++                    && vv >= sourceRectTop && vv < sourceRectTop + sourceRectHeight) {
+                     break;
+                 }
+                 u -= dudx;
+@@ -308,8 +315,8 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             // Beginning of the scan line, with per-pixel checks.
+             i = x1 - fromX;
+             while (i) {
+-                int uu = qBound(sourceRect.left(), u >> 16, sourceRect.left() + sourceRect.width() - 1);
+-                int vv = qBound(sourceRect.top(), v >> 16, sourceRect.top() + sourceRect.height() - 1);
++                qint64 uu = qBound(sourceRectLeft, u >> 16, sourceRectLeft + sourceRectWidth - 1);
++                qint64 vv = qBound(sourceRectTop, v >> 16, sourceRectTop + sourceRectHeight - 1);
+                 blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + vv * sbpl)[uu]);
+                 u += dudx;
+                 v += dvdx;
+@@ -348,8 +355,8 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             // End of the scan line, with per-pixel checks.
+             i = toX - x2;
+             while (i) {
+-                int uu = qBound(sourceRect.left(), u >> 16, sourceRect.left() + sourceRect.width() - 1);
+-                int vv = qBound(sourceRect.top(), v >> 16, sourceRect.top() + sourceRect.height() - 1);
++                qint64 uu = qBound(sourceRectLeft, u >> 16, sourceRectLeft + sourceRectWidth - 1);
++                qint64 vv = qBound(sourceRectTop, v >> 16, sourceRectTop + sourceRectHeight - 1);
+                 blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + vv * sbpl)[uu]);
+                 u += dudx;
+                 v += dvdx;
+diff --git a/qtbase/src/gui/painting/qcolortrclut_p.h b/qtbase/src/gui/painting/qcolortrclut_p.h
+index 76a6a60803..24fd522e6c 100644
+--- a/qtbase/src/gui/painting/qcolortrclut_p.h
++++ b/qtbase/src/gui/painting/qcolortrclut_p.h
+@@ -118,6 +118,7 @@ public:
+         return QRgba64::fromRgba64(r, g, b, qAlpha(rgb32) * 257);
+ #endif
+     }
++    QRgba64 toLinear64(QRgba64) const = delete;
+ 
+     QRgb toLinear(QRgb rgb32) const
+     {
+diff --git a/qtbase/src/gui/painting/qdrawhelper.cpp b/qtbase/src/gui/painting/qdrawhelper.cpp
+index a61793508a..5ba2d277b7 100644
+--- a/qtbase/src/gui/painting/qdrawhelper.cpp
++++ b/qtbase/src/gui/painting/qdrawhelper.cpp
+@@ -6091,7 +6091,7 @@ static inline void alphargbblend_argb32(quint32 *dst, uint coverage, const QRgba
+ static inline void rgbBlendPixel(QRgba64 &dst, int coverage, QRgba64 slinear, const QColorTrcLut *colorProfile)
+ {
+     // Do a gammacorrected RGB alphablend...
+-    const QRgba64 dlinear = colorProfile ? colorProfile->toLinear64(dst) : dst;
++    const QRgba64 dlinear = colorProfile ? colorProfile->toLinear(dst) : dst;
+ 
+     QRgba64 blend = rgbBlend(dlinear, slinear, coverage);
+ 
+diff --git a/qtbase/src/gui/painting/qpaintengine_raster.cpp b/qtbase/src/gui/painting/qpaintengine_raster.cpp
+index 283923de52..f08eb9cbee 100644
+--- a/qtbase/src/gui/painting/qpaintengine_raster.cpp
++++ b/qtbase/src/gui/painting/qpaintengine_raster.cpp
+@@ -560,31 +560,6 @@ void QRasterPaintEngine::updateMatrix(const QTransform &matrix)
+     QRasterPaintEngineState *s = state();
+     // FALCON: get rid of this line, see drawImage call below.
+     s->matrix = matrix;
+-    QTransform::TransformationType txop = s->matrix.type();
+-
+-    switch (txop) {
+-
+-    case QTransform::TxNone:
+-        s->flags.int_xform = true;
+-        break;
+-
+-    case QTransform::TxTranslate:
+-        s->flags.int_xform = qreal(int(s->matrix.dx())) == s->matrix.dx()
+-                            && qreal(int(s->matrix.dy())) == s->matrix.dy();
+-        break;
+-
+-    case QTransform::TxScale:
+-        s->flags.int_xform = qreal(int(s->matrix.dx())) == s->matrix.dx()
+-                            && qreal(int(s->matrix.dy())) == s->matrix.dy()
+-                            && qreal(int(s->matrix.m11())) == s->matrix.m11()
+-                            && qreal(int(s->matrix.m22())) == s->matrix.m22();
+-        break;
+-
+-    default: // shear / perspective...
+-        s->flags.int_xform = false;
+-        break;
+-    }
+-
+     s->flags.tx_noshear = qt_scaleForTransform(s->matrix, &s->txscale);
+ 
+     ensureOutlineMapper();
+@@ -617,7 +592,6 @@ QRasterPaintEngineState::QRasterPaintEngineState()
+     flags.bilinear = false;
+     flags.legacy_rounding = false;
+     flags.fast_text = true;
+-    flags.int_xform = true;
+     flags.tx_noshear = true;
+     flags.fast_images = true;
+ 
+@@ -1793,7 +1767,7 @@ void QRasterPaintEngine::fill(const QVectorPath &path, const QBrush &brush)
+     QRectF cpRect = path.controlPointRect();
+     const QRectF pathDeviceRect = s->matrix.mapRect(cpRect);
+     // Skip paths that by conservative estimates are completely outside the paint device.
+-    if (!pathDeviceRect.intersects(QRectF(d->deviceRect)))
++    if (!pathDeviceRect.intersects(QRectF(d->deviceRect)) || !pathDeviceRect.isValid())
+         return;
+ 
+     ProcessSpans blend = d->getBrushFunc(pathDeviceRect, &s->brushData);
+diff --git a/qtbase/src/gui/painting/qpaintengine_raster_p.h b/qtbase/src/gui/painting/qpaintengine_raster_p.h
+index 089aadc3f7..bf7363d5aa 100644
+--- a/qtbase/src/gui/painting/qpaintengine_raster_p.h
++++ b/qtbase/src/gui/painting/qpaintengine_raster_p.h
+@@ -111,7 +111,6 @@ public:
+         uint bilinear : 1;
+         uint legacy_rounding : 1;
+         uint fast_text : 1;
+-        uint int_xform : 1;
+         uint tx_noshear : 1;
+         uint fast_images : 1;
+     };
+diff --git a/qtbase/src/gui/painting/qpainterpath.cpp b/qtbase/src/gui/painting/qpainterpath.cpp
+index f9544a3241..d80fafeaf1 100644
+--- a/qtbase/src/gui/painting/qpainterpath.cpp
++++ b/qtbase/src/gui/painting/qpainterpath.cpp
+@@ -1253,7 +1253,7 @@ void QPainterPath::addText(const QPointF &point, const QFont &f, const QString &
+ 
+         if (si.analysis.flags < QScriptAnalysis::TabOrObject) {
+             QGlyphLayout glyphs = eng->shapedGlyphs(&si);
+-            QFontEngine *fe = f.d->engineForScript(si.analysis.script);
++            QFontEngine *fe = eng->fontEngine(si);
+             Q_ASSERT(fe);
+             fe->addOutlineToPath(x, y, glyphs, this,
+                                  si.analysis.bidiLevel % 2
+diff --git a/qtbase/src/gui/painting/qpathclipper_p.h b/qtbase/src/gui/painting/qpathclipper_p.h
+index 9444a87b71..18f64c5e8c 100644
+--- a/qtbase/src/gui/painting/qpathclipper_p.h
++++ b/qtbase/src/gui/painting/qpathclipper_p.h
+@@ -156,7 +156,7 @@ public:
+     int vertex(Direction direction) const;
+ 
+ private:
+-    int m_next[2][2];
++    int m_next[2][2] = { { -1, -1 }, { -1, -1 } };
+ };
+ 
+ class QPathSegments
+@@ -296,10 +296,6 @@ inline QPathEdge::QPathEdge(int a, int b)
+     , angle(0)
+     , invAngle(0)
+ {
+-    m_next[0][0] = -1;
+-    m_next[1][0] = -1;
+-    m_next[0][0] = -1;
+-    m_next[1][0] = -1;
+ }
+ 
+ inline int QPathEdge::next(Traversal traversal, Direction direction) const
+diff --git a/qtbase/src/gui/painting/qpdf.cpp b/qtbase/src/gui/painting/qpdf.cpp
+index 3066744f1b..2c8d3c3b53 100644
+--- a/qtbase/src/gui/painting/qpdf.cpp
++++ b/qtbase/src/gui/painting/qpdf.cpp
+@@ -2760,6 +2760,8 @@ int QPdfEnginePrivate::addBrushPattern(const QTransform &m, bool *specifyColor,
+         return gradientBrush(brush, matrix, gStateObject);
+     }
+ 
++    matrix = brush.transform() * matrix;
++
+     if ((!brush.isOpaque() && brush.style() < Qt::LinearGradientPattern) || opacity != 1.0)
+         *gStateObject = addConstantAlphaObject(qRound(brush.color().alpha() * opacity),
+                                                qRound(pen.color().alpha() * opacity));
+diff --git a/qtbase/src/gui/painting/qstroker.cpp b/qtbase/src/gui/painting/qstroker.cpp
+index cb5d395e80..3b6357a893 100644
+--- a/qtbase/src/gui/painting/qstroker.cpp
++++ b/qtbase/src/gui/painting/qstroker.cpp
+@@ -1182,6 +1182,7 @@ void QDashStroker::processCurrentSubpath()
+         // Check if the entire line should be clipped away or simplified
+         bool clipIt = clipping && !lineIntersectsRect(prev, e, clip_tl, clip_br);
+         bool skipDashing = elen * invSumLength > repetitionLimit();
++        int maxDashes = dashCount;
+         if (skipDashing || clipIt) {
+             // Cut away full dash sequences.
+             elen -= std::floor(elen * invSumLength) * sumLength;
+@@ -1196,7 +1197,7 @@ void QDashStroker::processCurrentSubpath()
+                     pos = estop; // move pos to next path element
+                     done = true;
+                 } else { // Dash is on this line
+-                    pos = dpos + estart;
++                    pos = --maxDashes > 0 ? dpos + estart : estop;
+                     done = pos >= estop;
+                     if (++idash >= dashCount)
+                         idash = 0;
+diff --git a/qtbase/src/gui/painting/qt_attribution.json b/qtbase/src/gui/painting/qt_attribution.json
+index 7b16e8c211..0e87d30aa2 100644
+--- a/qtbase/src/gui/painting/qt_attribution.json
++++ b/qtbase/src/gui/painting/qt_attribution.json
+@@ -10,7 +10,7 @@
+         "Homepage": "http://www.freetype.org",
+         "License": "Freetype Project License or GNU General Public License v2.0 only",
+         "LicenseId": "FTL or GPL-2.0",
+-        "LicenseFile": "../../3rdparty/freetype/docs/LICENSE.TXT",
++        "LicenseFile": "../../3rdparty/freetype/LICENSE.TXT",
+         "Copyright": "Copyright 2000-2016 by David Turner, Robert Wilhelm, and Werner Lemberg."
+     },
+     {
+diff --git a/qtbase/src/gui/rhi/qshader_p_p.h b/qtbase/src/gui/rhi/qshader_p_p.h
+index ec9d25971f..4a5a7a6d51 100644
+--- a/qtbase/src/gui/rhi/qshader_p_p.h
++++ b/qtbase/src/gui/rhi/qshader_p_p.h
+@@ -68,13 +68,13 @@ struct Q_GUI_EXPORT QShaderPrivate
+     {
+     }
+ 
+-    QShaderPrivate(const QShaderPrivate *other)
++    QShaderPrivate(const QShaderPrivate &other)
+         : ref(1),
+-          qsbVersion(other->qsbVersion),
+-          stage(other->stage),
+-          desc(other->desc),
+-          shaders(other->shaders),
+-          bindings(other->bindings)
++          qsbVersion(other.qsbVersion),
++          stage(other.stage),
++          desc(other.desc),
++          shaders(other.shaders),
++          bindings(other.bindings)
+     {
+     }
+ 
+diff --git a/qtbase/src/gui/rhi/qshaderdescription_p_p.h b/qtbase/src/gui/rhi/qshaderdescription_p_p.h
+index ec2b0b6b4c..3da33a8a2b 100644
+--- a/qtbase/src/gui/rhi/qshaderdescription_p_p.h
++++ b/qtbase/src/gui/rhi/qshaderdescription_p_p.h
+@@ -63,16 +63,16 @@ struct Q_GUI_EXPORT QShaderDescriptionPrivate
+         localSize[0] = localSize[1] = localSize[2] = 0;
+     }
+ 
+-    QShaderDescriptionPrivate(const QShaderDescriptionPrivate *other)
++    QShaderDescriptionPrivate(const QShaderDescriptionPrivate &other)
+         : ref(1),
+-          inVars(other->inVars),
+-          outVars(other->outVars),
+-          uniformBlocks(other->uniformBlocks),
+-          pushConstantBlocks(other->pushConstantBlocks),
+-          storageBlocks(other->storageBlocks),
+-          combinedImageSamplers(other->combinedImageSamplers),
+-          storageImages(other->storageImages),
+-          localSize(other->localSize)
++          inVars(other.inVars),
++          outVars(other.outVars),
++          uniformBlocks(other.uniformBlocks),
++          pushConstantBlocks(other.pushConstantBlocks),
++          storageBlocks(other.storageBlocks),
++          combinedImageSamplers(other.combinedImageSamplers),
++          storageImages(other.storageImages),
++          localSize(other.localSize)
+     {
+     }
+ 
+diff --git a/qtbase/src/gui/text/qfontdatabase.cpp b/qtbase/src/gui/text/qfontdatabase.cpp
+index a657a8c516..4fc0100958 100644
+--- a/qtbase/src/gui/text/qfontdatabase.cpp
++++ b/qtbase/src/gui/text/qfontdatabase.cpp
+@@ -983,7 +983,7 @@ QFontEngine *loadSingleEngine(int script,
+         if (style->key.stretch != 0 && request.stretch != 0
+             && (request.styleName.isEmpty() || request.styleName != style->styleName)) {
+             def.stretch = (request.stretch * 100 + style->key.stretch / 2) / style->key.stretch;
+-        } else {
++        } else if (request.stretch == QFont::AnyStretch) {
+             def.stretch = 100;
+         }
+ 
+diff --git a/qtbase/src/gui/text/qtextdocumentlayout.cpp b/qtbase/src/gui/text/qtextdocumentlayout.cpp
+index f3e6ea2100..72267e9380 100644
+--- a/qtbase/src/gui/text/qtextdocumentlayout.cpp
++++ b/qtbase/src/gui/text/qtextdocumentlayout.cpp
+@@ -2123,7 +2123,7 @@ void QTextDocumentLayoutPrivate::drawListItem(const QPointF &offset, QPainter *p
+ {
+     Q_Q(const QTextDocumentLayout);
+     const QTextBlockFormat blockFormat = bl.blockFormat();
+-    const QTextCharFormat charFormat = QTextCursor(bl).charFormat();
++    const QTextCharFormat charFormat = bl.charFormat();
+     QFont font(charFormat.font());
+     if (q->paintDevice())
+         font = QFont(font, q->paintDevice());
+diff --git a/qtbase/src/gui/text/qtextengine.cpp b/qtbase/src/gui/text/qtextengine.cpp
+index ce4abac472..a6c66e5d2d 100644
+--- a/qtbase/src/gui/text/qtextengine.cpp
++++ b/qtbase/src/gui/text/qtextengine.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2021 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtGui module of the Qt Toolkit.
+@@ -1565,6 +1565,12 @@ void QTextEngine::shapeText(int item) const
+         // Overwrite with 0 token to indicate failure
+         QGlyphLayout g = availableGlyphs(&si);
+         g.glyphs[0] = 0;
++        g.attributes[0].clusterStart = true;
++
++        ushort *log_clusters = logClusters(&si);
++        for (int i = 0; i < itemLength; ++i)
++            log_clusters[i] = 0;
++
+         return;
+     }
+ 
+diff --git a/qtbase/src/gui/util/qdesktopservices.cpp b/qtbase/src/gui/util/qdesktopservices.cpp
+index fbb63a9408..4d5fafaaa7 100644
+--- a/qtbase/src/gui/util/qdesktopservices.cpp
++++ b/qtbase/src/gui/util/qdesktopservices.cpp
+@@ -54,6 +54,8 @@
+ #include <qpa/qplatformintegration.h>
+ #include <qdir.h>
+ 
++#include <QtCore/private/qlocking_p.h>
++
+ QT_BEGIN_NAMESPACE
+ 
+ class QOpenUrlHandlerRegistry : public QObject
+@@ -81,6 +83,7 @@ Q_GLOBAL_STATIC(QOpenUrlHandlerRegistry, handlerRegistry)
+ 
+ void QOpenUrlHandlerRegistry::handlerDestroyed(QObject *handler)
+ {
++    const auto lock = qt_scoped_lock(mutex);
+     HandlerHash::Iterator it = handlers.begin();
+     while (it != handlers.end()) {
+         if (it->receiver == handler) {
+@@ -294,7 +297,8 @@ void QDesktopServices::setUrlHandler(const QString &scheme, QObject *receiver, c
+     h.name = method;
+     registry->handlers.insert(scheme.toLower(), h);
+     QObject::connect(receiver, SIGNAL(destroyed(QObject*)),
+-                     registry, SLOT(handlerDestroyed(QObject*)));
++                     registry, SLOT(handlerDestroyed(QObject*)),
++                     Qt::DirectConnection);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/gui/util/qpkmhandler.cpp b/qtbase/src/gui/util/qpkmhandler.cpp
+index e0c3b75efe..3414f9d8ba 100644
+--- a/qtbase/src/gui/util/qpkmhandler.cpp
++++ b/qtbase/src/gui/util/qpkmhandler.cpp
+@@ -57,7 +57,7 @@ struct PkmType
+     quint32 bytesPerBlock;
+ };
+ 
+-static PkmType typeMap[5] = {
++static constexpr PkmType typeMap[5] = {
+     { 0x8D64,  8 },   // GL_ETC1_RGB8_OES
+     { 0x9274,  8 },   // GL_COMPRESSED_RGB8_ETC2
+     { 0, 0 },         // unused (obsolete)
+diff --git a/qtbase/src/network/access/qnetworkreplyfileimpl.cpp b/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
+index b6be93147a..6e69b4c4d3 100644
+--- a/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
++++ b/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
+@@ -89,9 +89,10 @@ QNetworkReplyFileImpl::QNetworkReplyFileImpl(QNetworkAccessManager *manager, con
+         // we handle only local files
+         QString msg = QCoreApplication::translate("QNetworkAccessFileBackend", "Request for opening non-local file %1").arg(url.toString());
+         setError(QNetworkReply::ProtocolInvalidOperationError, msg);
++        setFinished(true); // We're finished, will emit finished() after ctor is done.
+         QMetaObject::invokeMethod(this, "errorOccurred", Qt::QueuedConnection,
+             Q_ARG(QNetworkReply::NetworkError, QNetworkReply::ProtocolInvalidOperationError));
+-        fileOpenFinished(false);
++        QMetaObject::invokeMethod(this, [this](){ fileOpenFinished(false); }, Qt::QueuedConnection);
+         return;
+     }
+ #endif
+diff --git a/qtbase/src/network/access/qnetworkreplyimpl.cpp b/qtbase/src/network/access/qnetworkreplyimpl.cpp
+index bcdf6ee2f1..3b6deb82bd 100644
+--- a/qtbase/src/network/access/qnetworkreplyimpl.cpp
++++ b/qtbase/src/network/access/qnetworkreplyimpl.cpp
+@@ -680,7 +680,7 @@ void QNetworkReplyImplPrivate::appendDownstreamData(QIODevice *data)
+     // read until EOF from data
+     if (Q_UNLIKELY(copyDevice)) {
+         qCritical("QNetworkReplyImpl: copy from QIODevice already in progress -- "
+-                  "backend probly needs to be fixed");
++                  "backend probably needs to be fixed");
+         return;
+     }
+ 
+diff --git a/qtbase/src/network/kernel/qauthenticator.cpp b/qtbase/src/network/kernel/qauthenticator.cpp
+index d9fe7bc47b..ccd04b294a 100644
+--- a/qtbase/src/network/kernel/qauthenticator.cpp
++++ b/qtbase/src/network/kernel/qauthenticator.cpp
+@@ -50,6 +50,7 @@
+ #include <qstring.h>
+ #include <qdatetime.h>
+ #include <qrandom.h>
++#include "private/qsystemlibrary_p.h"
+ 
+ #ifdef Q_OS_WIN
+ #include <qmutex.h>
+@@ -1563,7 +1564,7 @@ static bool q_SSPI_library_load()
+ 
+     // Initialize security interface
+     if (pSecurityFunctionTable == nullptr) {
+-        securityDLLHandle = LoadLibrary(L"secur32.dll");
++        securityDLLHandle = QSystemLibrary::load(L"secur32");
+         if (securityDLLHandle != nullptr) {
+             INIT_SECURITY_INTERFACE pInitSecurityInterface =
+                 reinterpret_cast<INIT_SECURITY_INTERFACE>(
+diff --git a/qtbase/src/network/kernel/qhostinfo_unix.cpp b/qtbase/src/network/kernel/qhostinfo_unix.cpp
+index 9b0a2ee669..73679c9ef1 100644
+--- a/qtbase/src/network/kernel/qhostinfo_unix.cpp
++++ b/qtbase/src/network/kernel/qhostinfo_unix.cpp
+@@ -122,7 +122,6 @@ static QFunctionPointer resolveSymbol(QLibrary &lib, const char *sym)
+ 
+ LibResolv::LibResolv()
+ {
+-    QLibrary lib;
+ #ifdef LIBRESOLV_SO
+     lib.setFileName(QStringLiteral(LIBRESOLV_SO));
+     if (!lib.load())
+diff --git a/qtbase/src/network/socket/qsocks5socketengine.cpp b/qtbase/src/network/socket/qsocks5socketengine.cpp
+index 3a046fd116..97fadca0b3 100644
+--- a/qtbase/src/network/socket/qsocks5socketengine.cpp
++++ b/qtbase/src/network/socket/qsocks5socketengine.cpp
+@@ -1296,7 +1296,7 @@ void QSocks5SocketEnginePrivate::_q_udpSocketReadNotification()
+         int pos = 0;
+         const char *buf = inBuf.constData();
+         if (inBuf.size() < 4) {
+-            QSOCKS5_D_DEBUG << "bugus udp data, discarding";
++            QSOCKS5_D_DEBUG << "bogus udp data, discarding";
+             return;
+         }
+         QSocks5RevivedDatagram datagram;
+diff --git a/qtbase/src/network/ssl/qsslcontext_openssl.cpp b/qtbase/src/network/ssl/qsslcontext_openssl.cpp
+index c9f202f573..c992da9d8e 100644
+--- a/qtbase/src/network/ssl/qsslcontext_openssl.cpp
++++ b/qtbase/src/network/ssl/qsslcontext_openssl.cpp
+@@ -409,7 +409,7 @@ init_context:
+         break;
+     case QSsl::DtlsV1_0OrLater:
+         minVersion = DTLS1_VERSION;
+-        maxVersion = DTLS_MAX_VERSION;
++        maxVersion = 0;
+         break;
+     case QSsl::DtlsV1_2:
+         minVersion = DTLS1_2_VERSION;
+@@ -417,7 +417,7 @@ init_context:
+         break;
+     case QSsl::DtlsV1_2OrLater:
+         minVersion = DTLS1_2_VERSION;
+-        maxVersion = DTLS_MAX_VERSION;
++        maxVersion = 0;
+         break;
+     case QSsl::TlsV1_3OrLater:
+ #ifdef TLS1_3_VERSION
+@@ -455,7 +455,7 @@ init_context:
+     }
+ 
+     // Enable bug workarounds.
+-    long options = QSslSocketBackendPrivate::setupOpenSslOptions(configuration.protocol(), configuration.d->sslOptions);
++    qssloptions options = QSslSocketBackendPrivate::setupOpenSslOptions(configuration.protocol(), configuration.d->sslOptions);
+     q_SSL_CTX_set_options(sslContext->ctx, options);
+ 
+     // Tell OpenSSL to release memory early
+diff --git a/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp b/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
+index aaf8741130..b58935372c 100644
+--- a/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
++++ b/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
+@@ -59,57 +59,6 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-#ifdef OPENSSL_NO_DEPRECATED_3_0
+-
+-static int q_DH_check(DH *dh, int *status)
+-{
+-    // DH_check was first deprecated in OpenSSL 3.0.0, as low-level
+-    // API; the EVP_PKEY family of functions was advised as an alternative.
+-    // As of now EVP_PKEY_params_check ends up calling ... DH_check,
+-    // which is good enough.
+-
+-    Q_ASSERT(dh);
+-    Q_ASSERT(status);
+-
+-    EVP_PKEY *key = q_EVP_PKEY_new();
+-    if (!key) {
+-        qCWarning(lcSsl, "EVP_PKEY_new failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-    const auto keyDeleter = qScopeGuard([key](){
+-        q_EVP_PKEY_free(key);
+-    });
+-    if (!q_EVP_PKEY_set1_DH(key, dh)) {
+-        qCWarning(lcSsl, "EVP_PKEY_set1_DH failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-
+-    EVP_PKEY_CTX *keyCtx = q_EVP_PKEY_CTX_new(key, nullptr);
+-    if (!keyCtx) {
+-        qCWarning(lcSsl, "EVP_PKEY_CTX_new failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-    const auto ctxDeleter = qScopeGuard([keyCtx]{
+-        q_EVP_PKEY_CTX_free(keyCtx);
+-    });
+-
+-    const int result = q_EVP_PKEY_param_check(keyCtx);
+-    QSslSocketBackendPrivate::logAndClearErrorQueue();
+-    // Note: unlike DH_check, we cannot obtain the 'status',
+-    // if the 'result' is 0 (actually the result is 1 only
+-    // if this 'status' was 0). We could probably check the
+-    // errors from the error queue, but it's not needed anyway
+-    // - see the 'isSafeDH' below, how it returns immediately
+-    // on 0.
+-    Q_UNUSED(status)
+-
+-    return result;
+-}
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+-
+ static bool isSafeDH(DH *dh)
+ {
+     int status = 0;
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl.cpp b/qtbase/src/network/ssl/qsslsocket_openssl.cpp
+index 37fad2a68f..8f6858c867 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl.cpp
++++ b/qtbase/src/network/ssl/qsslsocket_openssl.cpp
+@@ -550,9 +550,9 @@ static void q_loadCiphersForConnection(SSL *connection, QList<QSslCipher> &ciphe
+ // Defined in qsslsocket.cpp
+ void q_setDefaultDtlsCiphers(const QList<QSslCipher> &ciphers);
+ 
+-long QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions)
++qssloptions QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions)
+ {
+-    long options;
++    qssloptions options;
+     if (protocol == QSsl::TlsV1SslV3)
+         options = SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3;
+     else if (protocol == QSsl::SecureProtocols)
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_p.h b/qtbase/src/network/ssl/qsslsocket_openssl_p.h
+index 4103de23e8..5547589256 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_p.h
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_p.h
+@@ -107,6 +107,12 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++typedef uint64_t qssloptions;
++#else
++typedef unsigned long qssloptions;
++#endif
++
+ struct QSslErrorEntry {
+     int code;
+     int depth;
+@@ -171,7 +177,7 @@ public:
+     QVector<QSslError> ocspErrors;
+     QByteArray ocspResponseDer;
+ 
+-    Q_AUTOTEST_EXPORT static long setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions);
++    Q_AUTOTEST_EXPORT static qssloptions setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions);
+     static QSslCipher QSslCipher_from_SSL_CIPHER(const SSL_CIPHER *cipher);
+     static QList<QSslCertificate> STACKOFX509_to_QSslCertificates(STACK_OF(X509) *x509);
+     static QList<QSslError> verify(const QList<QSslCertificate> &certificateChain, const QString &hostName);
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp b/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
+index e53fb279f0..459ccd0b19 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
+@@ -148,7 +148,6 @@ DEFINEFUNC(int, EVP_PKEY_up_ref, EVP_PKEY *a, a, return 0, return)
+ DEFINEFUNC2(EVP_PKEY_CTX *, EVP_PKEY_CTX_new, EVP_PKEY *pkey, pkey, ENGINE *e, e, return nullptr, return)
+ DEFINEFUNC(int, EVP_PKEY_param_check, EVP_PKEY_CTX *ctx, ctx, return 0, return)
+ DEFINEFUNC(void, EVP_PKEY_CTX_free, EVP_PKEY_CTX *ctx, ctx, return, return)
+-DEFINEFUNC(int, EVP_PKEY_base_id, EVP_PKEY *a, a, return NID_undef, return)
+ DEFINEFUNC(int, RSA_bits, RSA *a, a, return 0, return)
+ DEFINEFUNC(int, DSA_bits, DSA *a, a, return 0, return)
+ DEFINEFUNC(int, OPENSSL_sk_num, OPENSSL_STACK *a, a, return -1, return)
+@@ -158,7 +157,7 @@ DEFINEFUNC2(void, OPENSSL_sk_push, OPENSSL_STACK *a, a, void *b, b, return, DUMM
+ DEFINEFUNC(void, OPENSSL_sk_free, OPENSSL_STACK *a, a, return, DUMMYARG)
+ DEFINEFUNC2(void *, OPENSSL_sk_value, OPENSSL_STACK *a, a, int b, b, return nullptr, return)
+ DEFINEFUNC(int, SSL_session_reused, SSL *a, a, return 0, return)
+-DEFINEFUNC2(unsigned long, SSL_CTX_set_options, SSL_CTX *ctx, ctx, unsigned long op, op, return 0, return)
++DEFINEFUNC2(qssloptions, SSL_CTX_set_options, SSL_CTX *ctx, ctx, qssloptions op, op, return 0, return)
+ DEFINEFUNC(int, SSL_CTX_get_security_level, const SSL_CTX *ctx, ctx, return -1, return)
+ DEFINEFUNC2(void, SSL_CTX_set_security_level, SSL_CTX *ctx, ctx, int level, level, return, return)
+ #ifdef TLS1_3_VERSION
+@@ -371,7 +370,15 @@ DEFINEFUNC(const SSL_CIPHER *, SSL_get_current_cipher, SSL *a, a, return nullptr
+ DEFINEFUNC(int, SSL_version, const SSL *a, a, return 0, return)
+ DEFINEFUNC2(int, SSL_get_error, SSL *a, a, int b, b, return -1, return)
+ DEFINEFUNC(STACK_OF(X509) *, SSL_get_peer_cert_chain, SSL *a, a, return nullptr, return)
++
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++DEFINEFUNC(X509 *, SSL_get1_peer_certificate, SSL *a, a, return nullptr, return)
++DEFINEFUNC(int, EVP_PKEY_get_base_id, const EVP_PKEY *pkey, pkey, return -1, return)
++#else
+ DEFINEFUNC(X509 *, SSL_get_peer_certificate, SSL *a, a, return nullptr, return)
++DEFINEFUNC(int, EVP_PKEY_base_id, EVP_PKEY *a, a, return NID_undef, return)
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+ DEFINEFUNC(long, SSL_get_verify_result, const SSL *a, a, return -1, return)
+ DEFINEFUNC(SSL *, SSL_new, SSL_CTX *a, a, return nullptr, return)
+ DEFINEFUNC(SSL_CTX *, SSL_get_SSL_CTX, SSL *a, a, return nullptr, return)
+@@ -492,9 +499,7 @@ DEFINEFUNC(DH *, DH_new, DUMMYARG, DUMMYARG, return nullptr, return)
+ DEFINEFUNC(void, DH_free, DH *dh, dh, return, DUMMYARG)
+ DEFINEFUNC3(DH *, d2i_DHparams, DH**a, a, const unsigned char **pp, pp, long length, length, return nullptr, return)
+ DEFINEFUNC2(int, i2d_DHparams, DH *a, a, unsigned char **p, p, return -1, return)
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+ DEFINEFUNC2(int, DH_check, DH *dh, dh, int *codes, codes, return 0, return)
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+ DEFINEFUNC3(BIGNUM *, BN_bin2bn, const unsigned char *s, s, int len, len, BIGNUM *ret, ret, return nullptr, return)
+ 
+ #ifndef OPENSSL_NO_EC
+@@ -868,7 +873,6 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(EVP_PKEY_CTX_new)
+     RESOLVEFUNC(EVP_PKEY_param_check)
+     RESOLVEFUNC(EVP_PKEY_CTX_free)
+-    RESOLVEFUNC(EVP_PKEY_base_id)
+     RESOLVEFUNC(RSA_bits)
+     RESOLVEFUNC(OPENSSL_sk_new_null)
+     RESOLVEFUNC(OPENSSL_sk_push)
+@@ -1107,7 +1111,15 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(SSL_version)
+     RESOLVEFUNC(SSL_get_error)
+     RESOLVEFUNC(SSL_get_peer_cert_chain)
++
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++    RESOLVEFUNC(SSL_get1_peer_certificate)
++    RESOLVEFUNC(EVP_PKEY_get_base_id)
++#else
+     RESOLVEFUNC(SSL_get_peer_certificate)
++    RESOLVEFUNC(EVP_PKEY_base_id)
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+     RESOLVEFUNC(SSL_get_verify_result)
+     RESOLVEFUNC(SSL_new)
+     RESOLVEFUNC(SSL_get_SSL_CTX)
+@@ -1206,9 +1218,7 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(DH_free)
+     RESOLVEFUNC(d2i_DHparams)
+     RESOLVEFUNC(i2d_DHparams)
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+     RESOLVEFUNC(DH_check)
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+     RESOLVEFUNC(BN_bin2bn)
+ 
+ #ifndef OPENSSL_NO_EC
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h b/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
+index 95e8897a3b..27aeffa18a 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
+@@ -237,7 +237,6 @@ Q_AUTOTEST_EXPORT int q_EVP_PKEY_up_ref(EVP_PKEY *a);
+ EVP_PKEY_CTX *q_EVP_PKEY_CTX_new(EVP_PKEY *pkey, ENGINE *e);
+ void q_EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx);
+ int q_EVP_PKEY_param_check(EVP_PKEY_CTX *ctx);
+-int q_EVP_PKEY_base_id(EVP_PKEY *a);
+ int q_RSA_bits(RSA *a);
+ Q_AUTOTEST_EXPORT int q_OPENSSL_sk_num(OPENSSL_STACK *a);
+ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_pop_free(OPENSSL_STACK *a, void (*b)(void *));
+@@ -246,7 +245,7 @@ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_push(OPENSSL_STACK *st, void *data);
+ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_free(OPENSSL_STACK *a);
+ Q_AUTOTEST_EXPORT void * q_OPENSSL_sk_value(OPENSSL_STACK *a, int b);
+ int q_SSL_session_reused(SSL *a);
+-unsigned long q_SSL_CTX_set_options(SSL_CTX *ctx, unsigned long op);
++qssloptions q_SSL_CTX_set_options(SSL_CTX *ctx, qssloptions op);
+ int q_OPENSSL_init_ssl(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings);
+ size_t q_SSL_get_client_random(SSL *a, unsigned char *out, size_t outlen);
+ size_t q_SSL_SESSION_get_master_key(const SSL_SESSION *session, unsigned char *out, size_t outlen);
+@@ -510,7 +509,6 @@ const SSL_CIPHER *q_SSL_get_current_cipher(SSL *a);
+ int q_SSL_version(const SSL *a);
+ int q_SSL_get_error(SSL *a, int b);
+ STACK_OF(X509) *q_SSL_get_peer_cert_chain(SSL *a);
+-X509 *q_SSL_get_peer_certificate(SSL *a);
+ long q_SSL_get_verify_result(const SSL *a);
+ SSL *q_SSL_new(SSL_CTX *a);
+ SSL_CTX *q_SSL_get_SSL_CTX(SSL *a);
+@@ -582,10 +580,7 @@ DH *q_DH_new();
+ void q_DH_free(DH *dh);
+ DH *q_d2i_DHparams(DH **a, const unsigned char **pp, long length);
+ int q_i2d_DHparams(DH *a, unsigned char **p);
+-
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+ int q_DH_check(DH *dh, int *codes);
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+ 
+ BIGNUM *q_BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret);
+ #define q_SSL_CTX_set_tmp_dh(ctx, dh) q_SSL_CTX_ctrl((ctx), SSL_CTRL_SET_TMP_DH, 0, (char *)dh)
+@@ -754,6 +749,17 @@ void q_CRYPTO_free(void *str, const char *file, int line);
+ int q_SSL_CTX_get_security_level(const SSL_CTX *ctx);
+ void q_SSL_CTX_set_security_level(SSL_CTX *ctx, int level);
+ 
++// Here we have the ones that make difference between OpenSSL pre/post v3:
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++X509 *q_SSL_get1_peer_certificate(SSL *a);
++#define q_SSL_get_peer_certificate q_SSL_get1_peer_certificate
++int q_EVP_PKEY_get_base_id(const EVP_PKEY *pkey);
++#define q_EVP_PKEY_base_id q_EVP_PKEY_get_base_id
++#else
++X509 *q_SSL_get_peer_certificate(SSL *a);
++int q_EVP_PKEY_base_id(EVP_PKEY *a);
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+ QT_END_NAMESPACE
+ 
+ #endif
+diff --git a/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h b/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
+index bf37d07fd8..dbd42fb799 100644
+--- a/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
++++ b/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
+@@ -61,7 +61,11 @@
+ # if !defined(Q_OS_INTEGRITY)
+ #  define WIN_INTERFACE_CUSTOM   // NV
+ # endif // Q_OS_INTEGRITY
+-#endif  // QT_EGL_NO_X11
++#else // QT_EGL_NO_X11
++// If one has an eglplatform.h with https://github.com/KhronosGroup/EGL-Registry/pull/130
++// that needs USE_X11 to be defined.
++# define USE_X11
++#endif
+ 
+ #ifdef QT_EGL_WAYLAND
+ # define WAYLAND // NV
+diff --git a/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+index 159b490ce0..00aa80cd58 100644
+--- a/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
++++ b/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+@@ -567,6 +567,8 @@ void QFontconfigDatabase::populateFontDatabase()
+         fonts = FcFontList(nullptr, pattern, os);
+         FcObjectSetDestroy(os);
+         FcPatternDestroy(pattern);
++        if (!fonts)
++            return;
+     }
+ 
+     for (int i = 0; i < fonts->nfont; i++)
+diff --git a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
+index b713c19447..7cb9a8c79a 100644
+--- a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
++++ b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
+@@ -95,6 +95,7 @@ static constexpr const auto KeyTbl = qMakeArray(
+         Xkb2Qt<XKB_KEY_Clear,                   Qt::Key_Delete>,
+         Xkb2Qt<XKB_KEY_Pause,                   Qt::Key_Pause>,
+         Xkb2Qt<XKB_KEY_Print,                   Qt::Key_Print>,
++        Xkb2Qt<XKB_KEY_Sys_Req,                 Qt::Key_SysReq>,
+         Xkb2Qt<0x1005FF60,                      Qt::Key_SysReq>,         // hardcoded Sun SysReq
+         Xkb2Qt<0x1007ff00,                      Qt::Key_SysReq>,         // hardcoded X386 SysReq
+ 
+@@ -471,7 +472,7 @@ QVector<xkb_keysym_t> QXkbCommon::toKeysym(QKeyEvent *event)
+     } else if (event->modifiers() & Qt::KeypadModifier) {
+         if (qtKey >= Qt::Key_0 && qtKey <= Qt::Key_9)
+             keysyms.append(XKB_KEY_KP_0 + (qtKey - Qt::Key_0));
+-    } else if (isLatin(qtKey) && event->text().isUpper()) {
++    } else if (isLatin1(qtKey) && event->text().isUpper()) {
+         keysyms.append(qtKey);
+     }
+ 
+@@ -523,7 +524,7 @@ int QXkbCommon::keysymToQtKey(xkb_keysym_t keysym, Qt::KeyboardModifiers modifie
+         // With standard shortcuts we should prefer a latin character, this is
+         // for checks like "some qkeyevent == QKeySequence::Copy" to work even
+         // when using for example 'russian' keyboard layout.
+-        if (!QXkbCommon::isLatin(keysym)) {
++        if (!QXkbCommon::isLatin1(keysym)) {
+             xkb_keysym_t latinKeysym = QXkbCommon::lookupLatinKeysym(state, code);
+             if (latinKeysym != XKB_KEY_NoSymbol)
+                 keysym = latinKeysym;
+@@ -546,7 +547,7 @@ static int keysymToQtKey_internal(xkb_keysym_t keysym, Qt::KeyboardModifiers mod
+     } else if (keysym >= XKB_KEY_KP_0 && keysym <= XKB_KEY_KP_9) {
+         // numeric keypad keys
+         qtKey = Qt::Key_0 + (keysym - XKB_KEY_KP_0);
+-    } else if (QXkbCommon::isLatin(keysym)) {
++    } else if (QXkbCommon::isLatin1(keysym)) {
+         qtKey = QXkbCommon::qxkbcommon_xkb_keysym_to_upper(keysym);
+     } else {
+         // check if we have a direct mapping
+@@ -678,7 +679,7 @@ QList<int> QXkbCommon::possibleKeys(xkb_state *state, const QKeyEvent *event,
+         Qt::KeyboardModifiers neededMods = ModsTbl[i];
+         if ((modifiers & neededMods) == neededMods) {
+             if (i == 8) {
+-                if (isLatin(baseQtKey))
++                if (isLatin1(baseQtKey))
+                     continue;
+                 // add a latin key as a fall back key
+                 sym = lookupLatinKeysym(state, keycode);
+@@ -733,7 +734,7 @@ void QXkbCommon::verifyHasLatinLayout(xkb_keymap *keymap)
+     for (xkb_layout_index_t layout = 0; layout < layoutCount; ++layout) {
+         for (xkb_keycode_t code = minKeycode; code < maxKeycode; ++code) {
+             xkb_keymap_key_get_syms_by_level(keymap, code, layout, 0, &keysyms);
+-            if (keysyms && isLatin(keysyms[0]))
++            if (keysyms && isLatin1(keysyms[0]))
+                 nrLatinKeys++;
+             if (nrLatinKeys > 10) // arbitrarily chosen threshold
+                 return;
+@@ -766,7 +767,7 @@ xkb_keysym_t QXkbCommon::lookupLatinKeysym(xkb_state *state, xkb_keycode_t keyco
+         xkb_level_index_t level = xkb_state_key_get_level(state, keycode, layout);
+         if (xkb_keymap_key_get_syms_by_level(keymap, keycode, layout, level, &syms) != 1)
+             continue;
+-        if (isLatin(syms[0])) {
++        if (isLatin1(syms[0])) {
+             sym = syms[0];
+             break;
+         }
+diff --git a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
+index 561eae03db..8389bd8f5a 100644
+--- a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
++++ b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
+@@ -94,8 +94,8 @@ public:
+     static void verifyHasLatinLayout(xkb_keymap *keymap);
+     static xkb_keysym_t lookupLatinKeysym(xkb_state *state, xkb_keycode_t keycode);
+ 
+-    static bool isLatin(xkb_keysym_t sym) {
+-        return ((sym >= 'a' && sym <= 'z') || (sym >= 'A' && sym <= 'Z'));
++    static bool isLatin1(xkb_keysym_t sym) {
++        return sym <= 0xff;
+     }
+     static bool isKeypad(xkb_keysym_t sym) {
+         return sym >= XKB_KEY_KP_Space && sym <= XKB_KEY_KP_9;
+diff --git a/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp b/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
+index 8cd7f9b368..406f84663f 100644
+--- a/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
++++ b/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
+@@ -318,7 +318,7 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources,
+ 
+     if (current < 0 && crtc_mode.clock != 0) {
+         modes << crtc_mode;
+-        current = mode.size() - 1;
++        current = modes.size() - 1;
+     }
+ 
+     if (configuration == OutputConfigCurrent)
+diff --git a/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp b/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
+index 9153fd20bb..255ea5e33e 100644
+--- a/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
++++ b/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
+@@ -194,6 +194,9 @@ QString AtSpiAdaptor::introspect(const QString &path) const
+                 "      <arg direction=\"out\" type=\"(so)\"/>\n"
+                 "      <annotation value=\"QSpiObjectReference\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n"
+                 "    </method>\n"
++                "    <method name=\"GetAccessibleId\">\n"
++                "      <arg direction=\"out\" type=\"s\"/>\n"
++                "    </method>\n"
+                 "  </interface>\n"
+                 );
+ 
+@@ -913,8 +916,17 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+     }
+     case QAccessible::NameChanged: {
+         if (sendObject || sendObject_property_change || sendObject_property_change_accessible_name) {
+-            QString path = pathForInterface(event->accessibleInterface());
+-            QVariantList args = packDBusSignalArguments(QLatin1String("accessible-name"), 0, 0, variantForPath(path));
++            QAccessibleInterface *iface = event->accessibleInterface();
++            if (!iface) {
++                qCDebug(lcAccessibilityAtspi,
++                        "NameChanged event from invalid accessible.");
++                return;
++            }
++
++            QString path = pathForInterface(iface);
++            QVariantList args = packDBusSignalArguments(
++                QLatin1String("accessible-name"), 0, 0,
++                QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Name))));
+             sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                            QLatin1String("PropertyChange"), args);
+         }
+@@ -922,8 +934,17 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+     }
+     case QAccessible::DescriptionChanged: {
+         if (sendObject || sendObject_property_change || sendObject_property_change_accessible_description) {
+-            QString path = pathForInterface(event->accessibleInterface());
+-            QVariantList args = packDBusSignalArguments(QLatin1String("accessible-description"), 0, 0, variantForPath(path));
++            QAccessibleInterface *iface = event->accessibleInterface();
++            if (!iface) {
++                qCDebug(lcAccessibilityAtspi,
++                        "DescriptionChanged event from invalid accessible.");
++                return;
++            }
++
++            QString path = pathForInterface(iface);
++            QVariantList args = packDBusSignalArguments(
++                QLatin1String("accessible-description"), 0, 0,
++                QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Description))));
+             sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                            QLatin1String("PropertyChange"), args);
+         }
+@@ -1038,7 +1059,9 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+                 // Combo Box with AT-SPI likes to be special
+                 // It requires a name-change to update caches and then selection-changed
+                 QString path = pathForInterface(iface);
+-                QVariantList args1 = packDBusSignalArguments(QLatin1String("accessible-name"), 0, 0, variantForPath(path));
++                QVariantList args1 = packDBusSignalArguments(
++                    QLatin1String("accessible-name"), 0, 0,
++                    QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Name))));
+                 sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                                QLatin1String("PropertyChange"), args1);
+                 QVariantList args2 = packDBusSignalArguments(QString(), 0, 0, QVariant::fromValue(QDBusVariant(QVariant(0))));
+@@ -1358,6 +1381,26 @@ void AtSpiAdaptor::registerApplication()
+     delete registry;
+ }
+ 
++namespace {
++QString accessibleIdForAccessible(QAccessibleInterface *accessible)
++{
++    QString result;
++    while (accessible) {
++        if (!result.isEmpty())
++            result.prepend(QLatin1Char('.'));
++        if (auto obj = accessible->object()) {
++            const QString name = obj->objectName();
++            if (!name.isEmpty())
++                result.prepend(name);
++            else
++                result.prepend(QString::fromUtf8(obj->metaObject()->className()));
++        }
++        accessible = accessible->parent();
++    }
++    return result;
++}
++} // namespace
++
+ // Accessible
+ bool AtSpiAdaptor::accessibleInterface(QAccessibleInterface *interface, const QString &function, const QDBusMessage &message, const QDBusConnection &connection)
+ {
+@@ -1441,6 +1484,9 @@ bool AtSpiAdaptor::accessibleInterface(QAccessibleInterface *interface, const QS
+             children << ref;
+         }
+         connection.send(message.createReply(QVariant::fromValue(children)));
++    } else if (function == QLatin1String("GetAccessibleId")) {
++        sendReply(connection, message,
++                  QVariant::fromValue(QDBusVariant(accessibleIdForAccessible(interface))));
+     } else {
+         qCDebug(lcAccessibilityAtspi) << "WARNING: AtSpiAdaptor::accessibleInterface does not implement " << function << message.path();
+         return false;
+diff --git a/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp b/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
+index 45ddc8e496..cc734abc63 100644
+--- a/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
++++ b/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
+@@ -69,6 +69,21 @@ QT_BEGIN_NAMESPACE
+ DBusConnection::DBusConnection(QObject *parent)
+     : QObject(parent), m_a11yConnection(QString()), m_enabled(false)
+ {
++    // If the bus is explicitly set via env var it overrides everything else.
++    QByteArray addressEnv = qgetenv("AT_SPI_BUS_ADDRESS");
++    if (!addressEnv.isEmpty()) {
++        // Only connect on next loop run, connections to our enabled signal are
++        // only established after the ctor returns.
++        QMetaObject::invokeMethod(
++                this,
++                [this, addressEnv] {
++                    m_enabled = true;
++                    connectA11yBus(QString::fromLocal8Bit(addressEnv));
++                },
++                Qt::QueuedConnection);
++        return;
++    }
++
+     // Start monitoring if "org.a11y.Bus" is registered as DBus service.
+     QDBusConnection c = QDBusConnection::sessionBus();
+     if (!c.isConnected()) {
+diff --git a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
+index 1a3cab275d..2abe039126 100644
+--- a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
++++ b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
+@@ -51,6 +51,9 @@
+ #include <QtCore/QStandardPaths>
+ #include <QtCore/QUrl>
+ 
++#include <QtGui/QGuiApplication>
++#include <QtGui/QWindow>
++
+ #if QT_CONFIG(dbus)
+ // These QtCore includes are needed for xdg-desktop-portal support
+ #include <QtCore/private/qcore_unix_p.h>
+@@ -58,6 +61,8 @@
+ #include <QtCore/QFileInfo>
+ #include <QtCore/QUrlQuery>
+ 
++#include <QtGui/QColor>
++
+ #include <QtDBus/QDBusConnection>
+ #include <QtDBus/QDBusMessage>
+ #include <QtDBus/QDBusPendingCall>
+@@ -142,6 +147,8 @@ static inline bool detectWebBrowser(const QByteArray &desktop,
+     }
+ 
+     if (desktop == QByteArray("KDE")) {
++        if (checkExecutable(QStringLiteral("kde-open5"), browser))
++            return true;
+         // Konqueror launcher
+         if (checkExecutable(QStringLiteral("kfmclient"), browser)) {
+             browser->append(QLatin1String(" exec"));
+@@ -296,8 +303,135 @@ static inline QDBusMessage xdgDesktopPortalSendEmail(const QUrl &url)
+ 
+     return QDBusConnection::sessionBus().call(message);
+ }
++
++namespace {
++struct XDGDesktopColor
++{
++    double r = 0;
++    double g = 0;
++    double b = 0;
++
++    QColor toQColor() const
++    {
++        constexpr auto rgbMax = 255;
++        return { static_cast<int>(r * rgbMax), static_cast<int>(g * rgbMax),
++                 static_cast<int>(b * rgbMax) };
++    }
++};
++
++const QDBusArgument &operator>>(const QDBusArgument &argument, XDGDesktopColor &myStruct)
++{
++    argument.beginStructure();
++    argument >> myStruct.r >> myStruct.g >> myStruct.b;
++    argument.endStructure();
++    return argument;
++}
++
++class XdgDesktopPortalColorPicker : public QPlatformServiceColorPicker
++{
++    Q_OBJECT
++public:
++    XdgDesktopPortalColorPicker(const QString &parentWindowId, QWindow *parent)
++        : QPlatformServiceColorPicker(parent), m_parentWindowId(parentWindowId)
++    {
++    }
++
++    void pickColor() override
++    {
++        // DBus signature:
++        // PickColor (IN   s      parent_window,
++        //            IN   a{sv}  options
++        //            OUT  o      handle)
++        // Options:
++        // handle_token (s) -  A string that will be used as the last element of the @handle.
++
++        QDBusMessage message = QDBusMessage::createMethodCall(
++                QStringLiteral("org.freedesktop.portal.Desktop"), QStringLiteral("/org/freedesktop/portal/desktop"),
++                QStringLiteral("org.freedesktop.portal.Screenshot"), QStringLiteral("PickColor"));
++        message << m_parentWindowId << QVariantMap();
++
++        QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
++        auto watcher = new QDBusPendingCallWatcher(pendingCall, this);
++        connect(watcher, &QDBusPendingCallWatcher::finished, this,
++                [this](QDBusPendingCallWatcher *watcher) {
++                    watcher->deleteLater();
++                    QDBusPendingReply<QDBusObjectPath> reply = *watcher;
++                    if (reply.isError()) {
++                        qWarning("DBus call to pick color failed: %s",
++                                 qPrintable(reply.error().message()));
++                        Q_EMIT colorPicked({});
++                    } else {
++                        QDBusConnection::sessionBus().connect(
++                                QStringLiteral("org.freedesktop.portal.Desktop"), reply.value().path(),
++                                QStringLiteral("org.freedesktop.portal.Request"), QStringLiteral("Response"), this,
++                                // clang-format off
++                                SLOT(gotColorResponse(uint,QVariantMap))
++                                // clang-format on
++                        );
++                    }
++                });
++    }
++
++private Q_SLOTS:
++    void gotColorResponse(uint result, const QVariantMap &map)
++    {
++        if (result != 0)
++            return;
++        XDGDesktopColor color{};
++        map.value(QStringLiteral("color")).value<QDBusArgument>() >> color;
++        Q_EMIT colorPicked(color.toQColor());
++        deleteLater();
++    }
++
++private:
++    const QString m_parentWindowId;
++};
++} // namespace
++
+ #endif // QT_CONFIG(dbus)
+ 
++QGenericUnixServices::QGenericUnixServices()
++{
++#if QT_CONFIG(dbus)
++    if (qEnvironmentVariableIntValue("QT_NO_XDG_DESKTOP_PORTAL") > 0) {
++        return;
++    }
++    QDBusMessage message = QDBusMessage::createMethodCall(
++            QStringLiteral("org.freedesktop.portal.Desktop"), QStringLiteral("/org/freedesktop/portal/desktop"),
++            QStringLiteral("org.freedesktop.DBus.Properties"), QStringLiteral("Get"));
++    message << QStringLiteral("org.freedesktop.portal.Screenshot")
++            << QStringLiteral("version");
++
++    QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
++    auto watcher = new QDBusPendingCallWatcher(pendingCall);
++    QObject::connect(watcher, &QDBusPendingCallWatcher::finished, watcher,
++                     [this](QDBusPendingCallWatcher *watcher) {
++                         watcher->deleteLater();
++                         QDBusPendingReply<QVariant> reply = *watcher;
++                         if (!reply.isError() && reply.value().toUInt() >= 2)
++                             m_hasScreenshotPortalWithColorPicking = true;
++                     });
++
++#endif
++}
++
++QPlatformServiceColorPicker *QGenericUnixServices::colorPicker(QWindow *parent)
++{
++#if QT_CONFIG(dbus)
++    // Make double sure that we are in a wayland environment. In particular check
++    // WAYLAND_DISPLAY so also XWayland apps benefit from portal-based color picking.
++    // Outside wayland we'll rather rely on other means than the XDG desktop portal.
++    if (!qEnvironmentVariableIsEmpty("WAYLAND_DISPLAY")
++        || QGuiApplication::platformName().startsWith(QLatin1String("wayland"))) {
++        return new XdgDesktopPortalColorPicker(portalWindowIdentifier(parent), parent);
++    }
++    return nullptr;
++#else
++    Q_UNUSED(parent);
++    return nullptr;
++#endif
++}
++
+ QByteArray QGenericUnixServices::desktopEnvironment() const
+ {
+     static const QByteArray result = detectDesktopEnvironment();
+@@ -352,6 +486,8 @@ bool QGenericUnixServices::openDocument(const QUrl &url)
+ }
+ 
+ #else
++QGenericUnixServices::QGenericUnixServices() = default;
++
+ QByteArray QGenericUnixServices::desktopEnvironment() const
+ {
+     return QByteArrayLiteral("UNKNOWN");
+@@ -371,6 +507,30 @@ bool QGenericUnixServices::openDocument(const QUrl &url)
+     return false;
+ }
+ 
++QPlatformServiceColorPicker *QGenericUnixServices::colorPicker(QWindow *parent)
++{
++    Q_UNUSED(parent);
++    return nullptr;
++}
++
+ #endif // QT_NO_MULTIPROCESS
+ 
++QString QGenericUnixServices::portalWindowIdentifier(QWindow *window)
++{
++    if (QGuiApplication::platformName() == QLatin1String("xcb"))
++        return QStringLiteral("x11:") + QString::number(window->winId(), 16);
++    return QString();
++}
++
++bool QGenericUnixServices::hasCapability(Capability capability) const
++{
++    switch (capability) {
++    case Capability::ColorPicking:
++        return m_hasScreenshotPortalWithColorPicking;
++    }
++    return false;
++}
++
+ QT_END_NAMESPACE
++
++#include "qgenericunixservices.moc"
+diff --git a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
+index 8ac3de6f03..30924e64bd 100644
+--- a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
++++ b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
+@@ -59,16 +59,21 @@ QT_BEGIN_NAMESPACE
+ class QGenericUnixServices : public QPlatformServices
+ {
+ public:
+-    QGenericUnixServices() {}
++    QGenericUnixServices();
+ 
+     QByteArray desktopEnvironment() const override;
+ 
++    bool hasCapability(Capability capability) const override;
+     bool openUrl(const QUrl &url) override;
+     bool openDocument(const QUrl &url) override;
++    QPlatformServiceColorPicker *colorPicker(QWindow *parent = nullptr) override;
++
++    virtual QString portalWindowIdentifier(QWindow *window);
+ 
+ private:
+     QString m_webBrowser;
+     QString m_documentLauncher;
++    bool m_hasScreenshotPortalWithColorPicking = false;
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
+index 09470bccc6..cc7c7d4d8a 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
+@@ -69,6 +69,7 @@ const QString MenuBarPath = QLatin1String("/MenuBar");
+ */
+ QDBusMenuConnection::QDBusMenuConnection(QObject *parent, const QString &serviceName)
+     : QObject(parent)
++    , m_serviceName(serviceName)
+     , m_connection(serviceName.isNull() ? QDBusConnection::sessionBus()
+                                         : QDBusConnection::connectToBus(QDBusConnection::SessionBus, serviceName))
+     , m_dbusWatcher(new QDBusServiceWatcher(StatusNotifierWatcherService, m_connection, QDBusServiceWatcher::WatchForRegistration, this))
+@@ -83,6 +84,12 @@ QDBusMenuConnection::QDBusMenuConnection(QObject *parent, const QString &service
+ #endif
+ }
+ 
++QDBusMenuConnection::~QDBusMenuConnection()
++{
++  if (!m_serviceName.isEmpty() && m_connection.isConnected())
++      QDBusConnection::disconnectFromBus(m_serviceName);
++}
++
+ void QDBusMenuConnection::dbusError(const QDBusError &error)
+ {
+     qWarning() << "QDBusTrayIcon encountered a D-Bus error:" << error;
+@@ -105,13 +112,7 @@ void QDBusMenuConnection::unregisterTrayIconMenu(QDBusTrayIcon *item)
+ 
+ bool QDBusMenuConnection::registerTrayIcon(QDBusTrayIcon *item)
+ {
+-    bool success = connection().registerService(item->instanceId());
+-    if (!success) {
+-        qWarning() << "failed to register service" << item->instanceId();
+-        return false;
+-    }
+-
+-    success = connection().registerObject(StatusNotifierItemPath, item);
++    bool success = connection().registerObject(StatusNotifierItemPath, item);
+     if (!success) {
+         unregisterTrayIcon(item);
+         qWarning() << "failed to register" << item->instanceId() << StatusNotifierItemPath;
+@@ -126,21 +127,18 @@ bool QDBusMenuConnection::registerTrayIcon(QDBusTrayIcon *item)
+ 
+ bool QDBusMenuConnection::registerTrayIconWithWatcher(QDBusTrayIcon *item)
+ {
++    Q_UNUSED(item);
+     QDBusMessage registerMethod = QDBusMessage::createMethodCall(
+                 StatusNotifierWatcherService, StatusNotifierWatcherPath, StatusNotifierWatcherService,
+                 QLatin1String("RegisterStatusNotifierItem"));
+-    registerMethod.setArguments(QVariantList() << item->instanceId());
++    registerMethod.setArguments(QVariantList() << m_connection.baseService());
+     return m_connection.callWithCallback(registerMethod, this, SIGNAL(trayIconRegistered()), SLOT(dbusError(QDBusError)));
+ }
+ 
+-bool QDBusMenuConnection::unregisterTrayIcon(QDBusTrayIcon *item)
++void QDBusMenuConnection::unregisterTrayIcon(QDBusTrayIcon *item)
+ {
+     unregisterTrayIconMenu(item);
+     connection().unregisterObject(StatusNotifierItemPath);
+-    bool success = connection().unregisterService(item->instanceId());
+-    if (!success)
+-        qWarning() << "failed to unregister service" << item->instanceId();
+-    return success;
+ }
+ #endif // QT_NO_SYSTEMTRAYICON
+ 
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
+index f484795fbb..97bdfabb85 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
++++ b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
+@@ -70,6 +70,7 @@ class QDBusMenuConnection : public QObject
+ 
+ public:
+     QDBusMenuConnection(QObject *parent = nullptr, const QString &serviceName = QString());
++    ~QDBusMenuConnection();
+     QDBusConnection connection() const { return m_connection; }
+     QDBusServiceWatcher *dbusWatcher() const { return m_dbusWatcher; }
+     bool isStatusNotifierHostRegistered() const { return m_statusNotifierHostRegistered; }
+@@ -78,7 +79,7 @@ public:
+     void unregisterTrayIconMenu(QDBusTrayIcon *item);
+     bool registerTrayIcon(QDBusTrayIcon *item);
+     bool registerTrayIconWithWatcher(QDBusTrayIcon *item);
+-    bool unregisterTrayIcon(QDBusTrayIcon *item);
++    void unregisterTrayIcon(QDBusTrayIcon *item);
+ #endif // QT_NO_SYSTEMTRAYICON
+ 
+ Q_SIGNALS:
+@@ -90,6 +91,7 @@ private Q_SLOTS:
+     void dbusError(const QDBusError &error);
+ 
+ private:
++    QString m_serviceName;
+     QDBusConnection m_connection;
+     QDBusServiceWatcher *m_dbusWatcher;
+     bool m_statusNotifierHostRegistered;
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp b/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
+index bede70975a..76bfec5e5a 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
+@@ -71,8 +71,12 @@ Q_LOGGING_CATEGORY(qLcTray, "qt.qpa.tray")
+ static QString iconTempPath()
+ {
+     QString tempPath = QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation);
+-    if (!tempPath.isEmpty())
++    if (!tempPath.isEmpty()) {
++        QString flatpakId = qEnvironmentVariable("FLATPAK_ID");
++        if (!flatpakId.isEmpty() && QFileInfo::exists(QLatin1String("/.flatpak-info")))
++            tempPath += QLatin1String("/app/") + flatpakId;
+         return tempPath;
++    }
+ 
+     tempPath = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation);
+ 
+diff --git a/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+index cb1b39db64..6e01af052c 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+@@ -755,6 +755,9 @@ QVariant QGnomeTheme::themeHint(QPlatformTheme::ThemeHint hint) const
+         return QVariant(QChar(0x2022));
+     case QPlatformTheme::UiEffects:
+         return QVariant(int(HoverEffect));
++    case QPlatformTheme::ButtonPressKeys:
++        return QVariant::fromValue(
++                QList<Qt::Key>({ Qt::Key_Space, Qt::Key_Return, Qt::Key_Enter, Qt::Key_Select }));
+     default:
+         break;
+     }
+diff --git a/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp b/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
+index 98e05195ee..1e92f43dec 100644
+--- a/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
++++ b/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
+@@ -343,8 +343,7 @@ void QEglFSCursor::paintOnScreen()
+     // screens are siblings of each other. When not enabled, the sibling list
+     // only contains m_screen itself.
+     for (QPlatformScreen *screen : m_screen->virtualSiblings()) {
+-        if (screen->geometry().contains(cr.topLeft().toPoint() + m_cursor.hotSpot)
+-            && QOpenGLContext::currentContext()->screen() == screen->screen())
++        if (screen->geometry().contains(cr.topLeft().toPoint() + m_cursor.hotSpot))
+         {
+             cr.translate(-screen->geometry().topLeft());
+             const QSize screenSize = screen->geometry().size();
+@@ -468,11 +467,12 @@ void QEglFSCursor::draw(const QRectF &r)
+ {
+     StateSaver stateSaver;
+ 
+-    QEglFSCursorData &gfx = static_cast<QEglFSContext*>(QOpenGLContext::currentContext()->handle())->cursorData;
+-    if (!gfx.program) {
+-        // one time initialization
++    // one time initialization
++    if (!QOpenGLFunctions::d_ptr)
+         initializeOpenGLFunctions();
+ 
++    QEglFSCursorData &gfx = static_cast<QEglFSContext*>(QOpenGLContext::currentContext()->handle())->cursorData;
++    if (!gfx.program) {
+         createShaderPrograms();
+ 
+         if (!gfx.atlasTexture) {
+diff --git a/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp b/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
+index 645a0ae2e9..3e0e406f1a 100644
+--- a/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
++++ b/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
+@@ -179,7 +179,7 @@ void QEglFSKmsEventReader::create(QEglFSKmsDevice *device)
+ 
+     m_device = device;
+ 
+-    qCDebug(qLcEglfsKmsDebug, "Initalizing event reader for device %p fd %d",
++    qCDebug(qLcEglfsKmsDebug, "Initializing event reader for device %p fd %d",
+             m_device, m_device->fd());
+ 
+     m_thread = new QEglFSKmsEventReaderThread(m_device->fd());
+diff --git a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
+index 141fb68a23..d4294d425a 100644
+--- a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
++++ b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
+@@ -122,11 +122,13 @@ QOffscreenIntegration::QOffscreenIntegration()
+ #endif
+     m_services.reset(new QPlatformServices);
+ 
+-    QWindowSystemInterface::handleScreenAdded(new QOffscreenScreen);
++    m_screen = new QOffscreenScreen;
++    QWindowSystemInterface::handleScreenAdded(m_screen);
+ }
+ 
+ QOffscreenIntegration::~QOffscreenIntegration()
+ {
++    QWindowSystemInterface::handleScreenRemoved(m_screen);
+ }
+ 
+ void QOffscreenIntegration::initialize()
+diff --git a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
+index 0ea90f6c2f..fe00fde07c 100644
+--- a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
++++ b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
+@@ -84,6 +84,7 @@ protected:
+ #endif
+     QScopedPointer<QPlatformInputContext> m_inputContext;
+     QScopedPointer<QPlatformServices> m_services;
++    QPlatformScreen *m_screen;
+     mutable QScopedPointer<QPlatformNativeInterface> m_nativeInterface;
+ };
+ 
+diff --git a/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp b/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
+index 6fa5a8a2b3..1f49f0aefd 100644
+--- a/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
++++ b/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
+@@ -48,6 +48,7 @@
+ #include <qpa/qplatformnativeinterface.h>
+ #include <QtPlatformHeaders/qwglnativecontext.h>
+ 
++#include <private/qsystemlibrary_p.h>
+ #include <algorithm>
+ 
+ #include <wingdi.h>
+@@ -162,19 +163,25 @@ QFunctionPointer QWindowsOpengl32DLL::resolve(const char *name)
+ 
+ bool QWindowsOpengl32DLL::init(bool softwareRendering)
+ {
+-    const QByteArray opengl32 = QByteArrayLiteral("opengl32.dll");
+-    const QByteArray swopengl = QByteArrayLiteral("opengl32sw.dll");
++    const QByteArray opengl32 = QByteArrayLiteral("opengl32");
++    const QByteArray swopengl = QByteArrayLiteral("opengl32sw");
++    bool useSystemLib = false;
+ 
+     QByteArray openglDll = qgetenv("QT_OPENGL_DLL");
+-    if (openglDll.isEmpty())
++    if (openglDll.isEmpty()) {
+         openglDll = softwareRendering ? swopengl : opengl32;
++        useSystemLib = !softwareRendering;
++    }
+ 
+     openglDll = openglDll.toLower();
+     m_nonOpengl32 = openglDll != opengl32;
+ 
+     qCDebug(lcQpaGl) << "Qt: Using WGL and OpenGL from" << openglDll;
+ 
+-    m_lib = ::LoadLibraryA(openglDll.constData());
++    if (useSystemLib)
++        m_lib = QSystemLibrary::load((wchar_t*)(QString::fromLatin1(openglDll).utf16()));
++    else
++        m_lib = LoadLibraryA(openglDll.constData());
+     if (!m_lib) {
+         qErrnoWarning(::GetLastError(), "Failed to load %s", openglDll.constData());
+         return false;
+@@ -184,7 +191,7 @@ bool QWindowsOpengl32DLL::init(bool softwareRendering)
+         // Load opengl32.dll always. GDI functions like ChoosePixelFormat do
+         // GetModuleHandle for opengl32.dll and behave differently (and call back into
+         // opengl32) when the module is present. This is fine for dummy contexts and windows.
+-        ::LoadLibraryA("opengl32.dll");
++        QSystemLibrary::load(L"opengl32");
+     }
+ 
+     wglCreateContext = reinterpret_cast<HGLRC (WINAPI *)(HDC)>(resolve("wglCreateContext"));
+diff --git a/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp b/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
+index d7d186e804..9eb4011bf2 100644
+--- a/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
++++ b/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
+@@ -49,6 +49,7 @@
+ #include <QtCore/qstandardpaths.h>
+ #include <QtCore/qlibraryinfo.h>
+ #include <QtCore/qhash.h>
++#include <private/qsystemlibrary_p.h>
+ 
+ #ifndef QT_NO_OPENGL
+ #include <private/qopengl_p.h>
+@@ -396,7 +397,7 @@ bool QWindowsOpenGLTester::testDesktopGL()
+ 
+     // Test #1: Load opengl32.dll and try to resolve an OpenGL 2 function.
+     // This will typically fail on systems that do not have a real OpenGL driver.
+-    lib = LoadLibraryA("opengl32.dll");
++    lib = QSystemLibrary::load(L"opengl32");
+     if (lib) {
+         CreateContext = reinterpret_cast<CreateContextType>(
+             reinterpret_cast<QFunctionPointer>(::GetProcAddress(lib, "wglCreateContext")));
+diff --git a/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp b/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
+index 1afa00cfc9..118af6ce73 100644
+--- a/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
++++ b/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
+@@ -41,6 +41,7 @@
+ 
+ #include <QRect>
+ #include <QList>
++#include <QMap>
+ #include <QDebug>
+ 
+ #include <qmath.h>
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp b/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
+index 9e2a37a6a1..e6e175a118 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
+@@ -488,12 +488,12 @@ void QXcbConnection::printXcbError(const char *message, xcb_generic_error_t *err
+     uint clamped_error_code = qMin<uint>(error->error_code, (sizeof(xcb_errors) / sizeof(xcb_errors[0])) - 1);
+     uint clamped_major_code = qMin<uint>(error->major_code, (sizeof(xcb_protocol_request_codes) / sizeof(xcb_protocol_request_codes[0])) - 1);
+ 
+-    qCWarning(lcQpaXcb, "%s: %d (%s), sequence: %d, resource id: %d, major code: %d (%s), minor code: %d",
+-             message,
+-             int(error->error_code), xcb_errors[clamped_error_code],
+-             int(error->sequence), int(error->resource_id),
+-             int(error->major_code), xcb_protocol_request_codes[clamped_major_code],
+-             int(error->minor_code));
++    qCDebug(lcQpaXcb, "%s: %d (%s), sequence: %d, resource id: %d, major code: %d (%s), minor code: %d",
++            message,
++            int(error->error_code), xcb_errors[clamped_error_code],
++            int(error->sequence), int(error->resource_id),
++            int(error->major_code), xcb_protocol_request_codes[clamped_major_code],
++            int(error->minor_code));
+ }
+ 
+ static Qt::MouseButtons translateMouseButtons(int s)
+@@ -702,6 +702,8 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
+             QXcbVirtualDesktop *virtualDesktop = virtualDesktopForRootWindow(propertyNotify->window);
+             if (virtualDesktop)
+                 virtualDesktop->updateWorkArea();
++        } else if (propertyNotify->atom == atom(QXcbAtom::_NET_SUPPORTED)) {
++            m_wmSupport->updateNetWMAtoms();
+         } else {
+             HANDLE_PLATFORM_WINDOW_EVENT(xcb_property_notify_event_t, window, handlePropertyNotifyEvent);
+         }
+@@ -750,7 +752,7 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
+                 case XCB_XKB_NEW_KEYBOARD_NOTIFY: {
+                     xcb_xkb_new_keyboard_notify_event_t *ev = &xkb_event->new_keyboard_notify;
+                     if (ev->changed & XCB_XKB_NKN_DETAIL_KEYCODES)
+-                        m_keyboard->updateKeymap(ev);
++                        m_keyboard->updateKeymap();
+                     break;
+                 }
+                 default:
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp b/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
+index 76869ced60..02d2eebb56 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
+@@ -274,8 +274,7 @@ QPlatformWindow *QXcbIntegration::createForeignWindow(QWindow *window, WId nativ
+ #ifndef QT_NO_OPENGL
+ QPlatformOpenGLContext *QXcbIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
+ {
+-    QXcbScreen *screen = static_cast<QXcbScreen *>(context->screen()->handle());
+-    QXcbGlIntegration *glIntegration = screen->connection()->glIntegration();
++    QXcbGlIntegration *glIntegration = defaultConnection()->glIntegration();
+     if (!glIntegration) {
+         qWarning("QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled");
+         return nullptr;
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+index efecd7e2d1..e8286381a2 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+@@ -365,17 +365,6 @@ void QXcbKeyboard::updateKeymap(xcb_mapping_notify_event_t *event)
+     updateKeymap();
+ }
+ 
+-void QXcbKeyboard::updateKeymap(xcb_xkb_new_keyboard_notify_event_t *event)
+-{
+-    if (!event)
+-        return;
+-
+-    if (event->deviceID != event->oldDeviceID)
+-        m_config = false;
+-
+-    updateKeymap();
+-}
+-
+ void QXcbKeyboard::updateKeymap()
+ {
+     KeysymModifierMap keysymMods;
+@@ -383,6 +372,8 @@ void QXcbKeyboard::updateKeymap()
+         keysymMods = keysymsToModifiers();
+     updateModifiers(keysymMods);
+ 
++    m_config = true;
++
+     if (!m_xkbContext) {
+         m_xkbContext.reset(xkb_context_new(XKB_CONTEXT_NO_DEFAULT_INCLUDES));
+         if (!m_xkbContext) {
+@@ -398,13 +389,8 @@ void QXcbKeyboard::updateKeymap()
+     if (connection()->hasXKB()) {
+         m_xkbKeymap.reset(xkb_x11_keymap_new_from_device(m_xkbContext.get(), xcb_connection(),
+                                                          core_device_id, XKB_KEYMAP_COMPILE_NO_FLAGS));
+-        if (m_xkbKeymap) {
+-            if (m_config)
+-                m_xkbState.reset(xkb_state_new(m_xkbKeymap.get()));
+-            else
+-                m_xkbState.reset(xkb_x11_state_new_from_device(m_xkbKeymap.get(), xcb_connection(), core_device_id));
+-
+-        }
++        if (m_xkbKeymap)
++            m_xkbState.reset(xkb_x11_state_new_from_device(m_xkbKeymap.get(), xcb_connection(), core_device_id));
+     } else {
+         m_xkbKeymap.reset(keymapFromCore(keysymMods));
+         if (m_xkbKeymap)
+@@ -425,8 +411,6 @@ void QXcbKeyboard::updateKeymap()
+     updateXKBMods();
+ 
+     QXkbCommon::verifyHasLatinLayout(m_xkbKeymap.get());
+-
+-    m_config = true;
+ }
+ 
+ QList<int> QXcbKeyboard::possibleKeys(const QKeyEvent *event) const
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
+index b652c85fe3..0ee08aeff2 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
++++ b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
+@@ -69,7 +69,6 @@ public:
+ 
+     Qt::KeyboardModifiers translateModifiers(int s) const;
+     void updateKeymap(xcb_mapping_notify_event_t *event);
+-    void updateKeymap(xcb_xkb_new_keyboard_notify_event_t *event);
+     void updateKeymap();
+     QList<int> possibleKeys(const QKeyEvent *event) const;
+ 
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp b/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
+index ffda7b6a57..863e961f4c 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
+@@ -564,11 +564,6 @@ void QXcbWindow::setGeometry(const QRect &rect)
+ {
+     QPlatformWindow::setGeometry(rect);
+ 
+-    if (shouldDeferTask(Task::SetGeometry)) {
+-        m_deferredGeometry = rect;
+-        return;
+-    }
+-
+     propagateSizeHints();
+ 
+     QXcbScreen *currentScreen = xcbScreen();
+@@ -693,9 +688,6 @@ void QXcbWindow::setVisible(bool visible)
+ 
+ void QXcbWindow::show()
+ {
+-    if (shouldDeferTask(Task::Map))
+-        return;
+-
+     if (window()->isTopLevel()) {
+ 
+         // update WM_NORMAL_HINTS
+@@ -706,7 +698,7 @@ void QXcbWindow::show()
+         if (isTransient(window())) {
+             const QWindow *tp = window()->transientParent();
+             if (tp && tp->handle())
+-                transientXcbParent = static_cast<const QXcbWindow *>(tp->handle())->winId();
++                transientXcbParent = tp->handle()->winId();
+             // Default to client leader if there is no transient parent, else modal dialogs can
+             // be hidden by their parents.
+             if (!transientXcbParent)
+@@ -746,10 +738,6 @@ void QXcbWindow::show()
+ 
+ void QXcbWindow::hide()
+ {
+-    if (shouldDeferTask(Task::Unmap))
+-        return;
+-
+-    m_wmStateValid = false;
+     xcb_unmap_window(xcb_connection(), m_window);
+ 
+     // send synthetic UnmapNotify event according to icccm 4.1.4
+@@ -909,9 +897,6 @@ QXcbWindow::NetWmStates QXcbWindow::netWmStates()
+ 
+ void QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
+ {
+-    if (shouldDeferTask(Task::SetWindowFlags))
+-        return;
+-
+     Qt::WindowType type = static_cast<Qt::WindowType>(int(flags & Qt::WindowType_Mask));
+ 
+     if (type == Qt::ToolTip)
+@@ -941,8 +926,6 @@ void QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
+ 
+     setTransparentForMouseEvents(flags & Qt::WindowTransparentForInput);
+     updateDoesNotAcceptFocus(flags & Qt::WindowDoesNotAcceptFocus);
+-
+-    m_isWmManagedWindow = !(flags & Qt::X11BypassWindowManagerHint);
+ }
+ 
+ void QXcbWindow::setMotifWmHints(Qt::WindowFlags flags)
+@@ -1142,9 +1125,6 @@ void QXcbWindow::setWindowState(Qt::WindowStates state)
+     if (state == m_windowState)
+         return;
+ 
+-    if (shouldDeferTask(Task::SetWindowState))
+-        return;
+-
+     // unset old state
+     if (m_windowState & Qt::WindowMinimized)
+         xcb_map_window(xcb_connection(), m_window);
+@@ -1350,6 +1330,12 @@ void QXcbWindow::setWindowIcon(const QIcon &icon)
+     }
+ 
+     if (!icon_data.isEmpty()) {
++        // Ignore icon exceeding maximum xcb request length
++        if (icon_data.size() > xcb_get_maximum_request_length(xcb_connection())) {
++            qWarning("Ignoring window icon: Size %llu exceeds maximum xcb request length %u.",
++                     icon_data.size(), xcb_get_maximum_request_length(xcb_connection()));
++            return;
++        }
+         xcb_change_property(xcb_connection(),
+                             XCB_PROP_MODE_REPLACE,
+                             m_window,
+@@ -1639,7 +1625,7 @@ void QXcbWindow::setWmWindowType(QXcbWindowFunctions::WmWindowTypes types, Qt::W
+         break;
+     }
+ 
+-    if ((flags & Qt::FramelessWindowHint) && !(type & QXcbWindowFunctions::KdeOverride)) {
++    if ((flags & Qt::FramelessWindowHint) && !(types & QXcbWindowFunctions::KdeOverride)) {
+         // override netwm type - quick and easy for KDE noborder
+         atoms.append(atom(QXcbAtom::_KDE_NET_WM_WINDOW_TYPE_OVERRIDE));
+     }
+@@ -1894,10 +1880,6 @@ void QXcbWindow::handleUnmapNotifyEvent(const xcb_unmap_notify_event_t *event)
+     if (event->window == m_window) {
+         m_mapped = false;
+         QWindowSystemInterface::handleExposeEvent(window(), QRegion());
+-        if (!m_isWmManagedWindow || parent()) {
+-            m_wmStateValid = true;
+-            handleDeferredTasks();
+-        }
+     }
+ }
+ 
+@@ -2212,98 +2194,30 @@ void QXcbWindow::handleLeaveNotifyEvent(const xcb_leave_notify_event_t *event)
+     handleLeaveNotifyEvent(event->root_x, event->root_y, event->mode, event->detail, event->time);
+ }
+ 
+-bool QXcbWindow::shouldDeferTask(Task task)
+-{
+-    if (m_wmStateValid)
+-        return false;
+-
+-    m_deferredTasks.append(task);
+-    return true;
+-}
+-
+-void QXcbWindow::handleDeferredTasks()
+-{
+-    Q_ASSERT(m_wmStateValid == true);
+-    if (m_deferredTasks.isEmpty())
+-        return;
+-
+-    bool map = false;
+-    bool unmap = false;
+-
+-    QVector<Task> tasks;
+-    for (auto taskIt = m_deferredTasks.rbegin(); taskIt != m_deferredTasks.rend(); ++taskIt) {
+-        if (!tasks.contains(*taskIt))
+-            tasks.prepend(*taskIt);
+-    }
+-
+-    for (Task task : tasks) {
+-        switch (task) {
+-        case Task::Map:
+-            map = true;
+-            unmap = false;
+-            break;
+-        case Task::Unmap:
+-            unmap = true;
+-            map = false;
+-            break;
+-        case Task::SetGeometry:
+-            setGeometry(m_deferredGeometry);
+-            break;
+-        case Task::SetWindowFlags:
+-            setWindowFlags(window()->flags());
+-            break;
+-        case Task::SetWindowState:
+-            setWindowState(window()->windowState());
+-            break;
+-        }
+-    }
+-    m_deferredTasks.clear();
+-
+-    if (map) {
+-        Q_ASSERT(unmap == false);
+-        show();
+-    }
+-    if (unmap) {
+-        Q_ASSERT(map == false);
+-        hide();
+-    }
+-}
+-
+ void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *event)
+ {
+     connection()->setTime(event->time);
+ 
+-    const bool wmStateChanged = event->atom == atom(QXcbAtom::WM_STATE);
+-    const bool netWmStateChanged = event->atom == atom(QXcbAtom::_NET_WM_STATE);
+-    if (netWmStateChanged || wmStateChanged) {
+-        if (wmStateChanged && !m_wmStateValid && m_isWmManagedWindow) {
+-            // ICCCM 4.1.4
+-            // Clients that want to re-use a client window (e.g. by mapping it again)
+-            // after withdrawing it must wait for the withdrawal to be complete before
+-            // proceeding. The preferred method for doing this is for clients to wait for
+-            // a window manager to update or remove the WM_STATE property.
+-            m_wmStateValid = true;
+-            handleDeferredTasks();
+-        }
+-        if (event->state == XCB_PROPERTY_DELETE)
++    const bool propertyDeleted = event->state == XCB_PROPERTY_DELETE;
++
++    if (event->atom == atom(QXcbAtom::_NET_WM_STATE) || event->atom == atom(QXcbAtom::WM_STATE)) {
++        if (propertyDeleted)
+             return;
+ 
+-        if (wmStateChanged) {
++        Qt::WindowStates newState = Qt::WindowNoState;
++
++        if (event->atom == atom(QXcbAtom::WM_STATE)) { // WM_STATE: Quick check for 'Minimize'.
+             auto reply = Q_XCB_REPLY(xcb_get_property, xcb_connection(),
+                                      0, m_window, atom(QXcbAtom::WM_STATE),
+                                      XCB_ATOM_ANY, 0, 1024);
+             if (reply && reply->format == 32 && reply->type == atom(QXcbAtom::WM_STATE)) {
+-                auto data = static_cast<const quint32 *>(xcb_get_property_value(reply.get()));
+-                if (reply->length != 0) {
+-                    const bool changedToWithdrawn = data[0] == XCB_ICCCM_WM_STATE_WITHDRAWN;
+-                    const bool changedToIconic = data[0] == XCB_ICCCM_WM_STATE_ICONIC;
+-                    m_minimized = changedToIconic || (changedToWithdrawn && m_minimized);
+-                }
++                const quint32 *data = (const quint32 *)xcb_get_property_value(reply.get());
++                if (reply->length != 0)
++                    m_minimized = (data[0] == XCB_ICCCM_WM_STATE_ICONIC
++                                   || (data[0] == XCB_ICCCM_WM_STATE_WITHDRAWN && m_minimized));
+             }
+         }
+ 
+-        // _NET_WM_STATE handling
+-        Qt::WindowStates newState = Qt::WindowNoState;
+         const NetWmStates states = netWmStates();
+         // _NET_WM_STATE_HIDDEN should be set by the Window Manager to indicate that a window would
+         // not be visible on the screen if its desktop/viewport were active and its coordinates were
+@@ -2325,6 +2239,7 @@ void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *ev
+             if ((m_windowState & Qt::WindowMinimized) && connection()->mouseGrabber() == this)
+                 connection()->setMouseGrabber(nullptr);
+         }
++        return;
+     } else if (event->atom == atom(QXcbAtom::_NET_FRAME_EXTENTS)) {
+         m_dirtyFrameMargins = true;
+     }
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbwindow.h b/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
+index 55af9279b1..6f5c1f5ed9 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
++++ b/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
+@@ -74,14 +74,6 @@ public:
+ 
+     Q_DECLARE_FLAGS(NetWmStates, NetWmState)
+ 
+-    enum Task {
+-        Map,
+-        Unmap,
+-        SetGeometry,
+-        SetWindowFlags,
+-        SetWindowState
+-    };
+-
+     QXcbWindow(QWindow *window);
+     ~QXcbWindow();
+ 
+@@ -151,9 +143,6 @@ public:
+ 
+     QXcbWindow *toWindow() override;
+ 
+-    bool shouldDeferTask(Task task);
+-    void handleDeferredTasks();
+-
+     void handleMouseEvent(xcb_timestamp_t time, const QPoint &local, const QPoint &global,
+                           Qt::KeyboardModifiers modifiers, QEvent::Type type, Qt::MouseEventSource source);
+ 
+@@ -292,11 +281,6 @@ protected:
+     int m_swapInterval = -1;
+ 
+     qreal m_sizeHintsScaleFactor = 1.0;
+-
+-    bool m_wmStateValid = true;
+-    QVector<Task> m_deferredTasks;
+-    bool m_isWmManagedWindow = true;
+-    QRect m_deferredGeometry;
+ };
+ 
+ class QXcbForeignWindow : public QXcbWindow
+diff --git a/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp b/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
+index d9d117faeb..640b49daa0 100644
+--- a/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
++++ b/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
+@@ -85,6 +85,7 @@ QGtk3MenuItem::QGtk3MenuItem()
+       m_checkable(false),
+       m_checked(false),
+       m_enabled(true),
++      m_exclusive(false),
+       m_underline(false),
+       m_invalid(true),
+       m_menu(nullptr),
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
+index 0048bbc1e6..396e7f6d1c 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
+@@ -102,15 +102,12 @@ const QDBusArgument &operator >>(const QDBusArgument &arg, QXdgDesktopPortalFile
+ class QXdgDesktopPortalFileDialogPrivate
+ {
+ public:
+-    QXdgDesktopPortalFileDialogPrivate(QPlatformFileDialogHelper *nativeFileDialog)
++    QXdgDesktopPortalFileDialogPrivate(QPlatformFileDialogHelper *nativeFileDialog, uint fileChooserPortalVersion)
+         : nativeFileDialog(nativeFileDialog)
++        , fileChooserPortalVersion(fileChooserPortalVersion)
+     { }
+ 
+-    WId winId = 0;
+-    bool directoryMode = false;
+-    bool modal = false;
+-    bool multipleFiles = false;
+-    bool saveFile = false;
++    QEventLoop loop;
+     QString acceptLabel;
+     QString directory;
+     QString title;
+@@ -121,19 +118,27 @@ public:
+     QString selectedMimeTypeFilter;
+     QString selectedNameFilter;
+     QStringList selectedFiles;
+-    QPlatformFileDialogHelper *nativeFileDialog = nullptr;
++    std::unique_ptr<QPlatformFileDialogHelper> nativeFileDialog;
++    uint fileChooserPortalVersion = 0;
++    bool failedToOpen = false;
++    bool directoryMode = false;
++    bool multipleFiles = false;
++    bool saveFile = false;
+ };
+ 
+-QXdgDesktopPortalFileDialog::QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog)
++QXdgDesktopPortalFileDialog::QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog, uint fileChooserPortalVersion)
+     : QPlatformFileDialogHelper()
+-    , d_ptr(new QXdgDesktopPortalFileDialogPrivate(nativeFileDialog))
++    , d_ptr(new QXdgDesktopPortalFileDialogPrivate(nativeFileDialog, fileChooserPortalVersion))
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+     if (d->nativeFileDialog) {
+-        connect(d->nativeFileDialog, SIGNAL(accept()), this, SIGNAL(accept()));
+-        connect(d->nativeFileDialog, SIGNAL(reject()), this, SIGNAL(reject()));
++        connect(d->nativeFileDialog.get(), SIGNAL(accept()), this, SIGNAL(accept()));
++        connect(d->nativeFileDialog.get(), SIGNAL(reject()), this, SIGNAL(reject()));
+     }
++
++    d->loop.connect(this, SIGNAL(accept()), SLOT(quit()));
++    d->loop.connect(this, SIGNAL(reject()), SLOT(quit()));
+ }
+ 
+ QXdgDesktopPortalFileDialog::~QXdgDesktopPortalFileDialog()
+@@ -177,7 +182,7 @@ void QXdgDesktopPortalFileDialog::initializeDialog()
+     setDirectory(options()->initialDirectory());
+ }
+ 
+-void QXdgDesktopPortalFileDialog::openPortal()
++void QXdgDesktopPortalFileDialog::openPortal(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent)
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+@@ -185,13 +190,13 @@ void QXdgDesktopPortalFileDialog::openPortal()
+                                                           QLatin1String("/org/freedesktop/portal/desktop"),
+                                                           QLatin1String("org.freedesktop.portal.FileChooser"),
+                                                           d->saveFile ? QLatin1String("SaveFile") : QLatin1String("OpenFile"));
+-    QString parentWindowId = QLatin1String("x11:") + QString::number(d->winId, 16);
++    QString parentWindowId = QLatin1String("x11:") + QString::number(parent ? parent->winId() : 0, 16);
+ 
+     QVariantMap options;
+     if (!d->acceptLabel.isEmpty())
+         options.insert(QLatin1String("accept_label"), d->acceptLabel);
+ 
+-    options.insert(QLatin1String("modal"), d->modal);
++    options.insert(QLatin1String("modal"), windowModality != Qt::NonModal);
+     options.insert(QLatin1String("multiple"), d->multipleFiles);
+     options.insert(QLatin1String("directory"), d->directoryMode);
+ 
+@@ -290,10 +295,18 @@ void QXdgDesktopPortalFileDialog::openPortal()
+ 
+     QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
+     QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingCall);
+-    connect(watcher, &QDBusPendingCallWatcher::finished, this, [this] (QDBusPendingCallWatcher *watcher) {
++    connect(watcher, &QDBusPendingCallWatcher::finished, this, [=] (QDBusPendingCallWatcher *watcher) {
+         QDBusPendingReply<QDBusObjectPath> reply = *watcher;
+-        if (reply.isError()) {
+-            Q_EMIT reject();
++        // Any error means the dialog is not shown and we need to fallback
++        d->failedToOpen = reply.isError();
++        if (d->failedToOpen) {
++            if (d->nativeFileDialog) {
++                d->nativeFileDialog->show(windowFlags, windowModality, parent);
++                if (d->loop.isRunning())
++                    d->nativeFileDialog->exec();
++            } else {
++                Q_EMIT reject();
++            }
+         } else {
+             QDBusConnection::sessionBus().connect(nullptr,
+                                                   reply.value().path(),
+@@ -302,6 +315,7 @@ void QXdgDesktopPortalFileDialog::openPortal()
+                                                   this,
+                                                   SLOT(gotResponse(uint,QVariantMap)));
+         }
++        watcher->deleteLater();
+     });
+ }
+ 
+@@ -326,7 +340,7 @@ QUrl QXdgDesktopPortalFileDialog::directory() const
+ {
+     Q_D(const QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog())
+         return d->nativeFileDialog->directory();
+ 
+     return d->directory;
+@@ -348,7 +362,7 @@ QList<QUrl> QXdgDesktopPortalFileDialog::selectedFiles() const
+ {
+     Q_D(const QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog())
+         return d->nativeFileDialog->selectedFiles();
+ 
+     QList<QUrl> files;
+@@ -403,16 +417,13 @@ void QXdgDesktopPortalFileDialog::exec()
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly)) {
++    if (d->nativeFileDialog && useNativeFileDialog()) {
+         d->nativeFileDialog->exec();
+         return;
+     }
+ 
+     // HACK we have to avoid returning until we emit that the dialog was accepted or rejected
+-    QEventLoop loop;
+-    loop.connect(this, SIGNAL(accept()), SLOT(quit()));
+-    loop.connect(this, SIGNAL(reject()), SLOT(quit()));
+-    loop.exec();
++    d->loop.exec();
+ }
+ 
+ void QXdgDesktopPortalFileDialog::hide()
+@@ -429,13 +440,10 @@ bool QXdgDesktopPortalFileDialog::show(Qt::WindowFlags windowFlags, Qt::WindowMo
+ 
+     initializeDialog();
+ 
+-    d->modal = windowModality != Qt::NonModal;
+-    d->winId = parent ? parent->winId() : 0;
+-
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog(OpenFallback))
+         return d->nativeFileDialog->show(windowFlags, windowModality, parent);
+ 
+-    openPortal();
++    openPortal(windowFlags, windowModality, parent);
+ 
+     return true;
+ }
+@@ -465,4 +473,21 @@ void QXdgDesktopPortalFileDialog::gotResponse(uint response, const QVariantMap &
+     }
+ }
+ 
++bool QXdgDesktopPortalFileDialog::useNativeFileDialog(QXdgDesktopPortalFileDialog::FallbackType fallbackType) const
++{
++    Q_D(const QXdgDesktopPortalFileDialog);
++
++    if (d->failedToOpen && fallbackType != OpenFallback)
++        return true;
++
++    if (d->fileChooserPortalVersion < 3) {
++        if (options()->fileMode() == QFileDialogOptions::Directory)
++            return true;
++        else if (options()->fileMode() == QFileDialogOptions::DirectoryOnly)
++            return true;
++    }
++
++    return false;
++}
++
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
+index 4f4de96ecf..65e22a5cf2 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
+@@ -51,6 +51,11 @@ class QXdgDesktopPortalFileDialog : public QPlatformFileDialogHelper
+     Q_OBJECT
+     Q_DECLARE_PRIVATE(QXdgDesktopPortalFileDialog)
+ public:
++    enum FallbackType {
++        GenericFallback,
++        OpenFallback
++    };
++
+     enum ConditionType : uint {
+         GlobalPattern = 0,
+         MimeType = 1
+@@ -69,7 +74,7 @@ public:
+     };
+     typedef QVector<Filter> FilterList;
+ 
+-    QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog = nullptr);
++    QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog = nullptr, uint fileChooserPortalVersion = 0);
+     ~QXdgDesktopPortalFileDialog();
+ 
+     bool defaultNameFilterDisables() const override;
+@@ -92,7 +97,8 @@ private Q_SLOTS:
+ 
+ private:
+     void initializeDialog();
+-    void openPortal();
++    void openPortal(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent);
++    bool useNativeFileDialog(FallbackType fallbackType = GenericFallback) const;
+ 
+     QScopedPointer<QXdgDesktopPortalFileDialogPrivate> d_ptr;
+ };
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
+index fb324afbd8..b809503122 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
+@@ -111,6 +111,7 @@ QXdgDesktopPortalTheme::QXdgDesktopPortalTheme()
+         if (reply.isValid()) {
+             d->fileChooserPortalVersion = reply.value().toUInt();
+         }
++        watcher->deleteLater();
+     });
+ }
+ 
+@@ -152,11 +153,12 @@ QPlatformDialogHelper* QXdgDesktopPortalTheme::createPlatformDialogHelper(Dialog
+ {
+     Q_D(const QXdgDesktopPortalTheme);
+ 
+-    if (type == FileDialog) {
++    if (type == FileDialog && d->fileChooserPortalVersion) {
+         // Older versions of FileChooser portal don't support opening directories, therefore we fallback
+         // to native file dialog opened inside the sandbox to open a directory.
+-        if (d->fileChooserPortalVersion < 3 && d->baseTheme->usePlatformNativeDialog(type))
+-            return new QXdgDesktopPortalFileDialog(static_cast<QPlatformFileDialogHelper*>(d->baseTheme->createPlatformDialogHelper(type)));
++        if (d->baseTheme->usePlatformNativeDialog(type))
++            return new QXdgDesktopPortalFileDialog(static_cast<QPlatformFileDialogHelper*>(d->baseTheme->createPlatformDialogHelper(type)),
++                                                   d->fileChooserPortalVersion);
+ 
+         return new QXdgDesktopPortalFileDialog;
+     }
+diff --git a/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp b/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
+index 43d5e119ad..1f9cbc4565 100644
+--- a/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
++++ b/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
+@@ -89,8 +89,10 @@ void QCupsPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &v
+         break;
+     case PPK_Duplex: {
+         QPrint::DuplexMode mode = QPrint::DuplexMode(value.toInt());
+-        if (mode != d->duplex && d->m_printDevice.supportedDuplexModes().contains(mode))
++        if (d->m_printDevice.supportedDuplexModes().contains(mode)) {
+             d->duplex = mode;
++            d->duplexRequestedExplicitly = true;
++        }
+         break;
+     }
+     case PPK_PrinterName:
+@@ -277,9 +279,12 @@ void QCupsPrintEnginePrivate::changePrinter(const QString &newPrinter)
+     m_printDevice.swap(printDevice);
+     printerName = m_printDevice.id();
+ 
+-    // Check if new printer supports current settings, otherwise us defaults
+-    if (duplex != QPrint::DuplexAuto && !m_printDevice.supportedDuplexModes().contains(duplex))
++    // in case a duplex value was explicitly set, check if new printer supports current value,
++    // otherwise use device default
++    if (!duplexRequestedExplicitly || !m_printDevice.supportedDuplexModes().contains(duplex)) {
+         duplex = m_printDevice.defaultDuplexMode();
++        duplexRequestedExplicitly = false;
++    }
+     QPrint::ColorMode colorMode = grayscale ? QPrint::GrayScale : QPrint::Color;
+     if (!m_printDevice.supportedColorModes().contains(colorMode))
+         grayscale = m_printDevice.defaultColorMode() == QPrint::GrayScale;
+diff --git a/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h b/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
+index c021b0c643..8f81fe478d 100644
+--- a/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
++++ b/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
+@@ -100,6 +100,7 @@ private:
+     QStringList cupsOptions;
+     QString cupsTempFile;
+     QPrint::DuplexMode duplex;
++    bool duplexRequestedExplicitly = false;
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp b/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
+index 67e7154fa6..40876152e5 100644
+--- a/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
++++ b/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
+@@ -817,7 +817,7 @@ bool QIBaseResultPrivate::writeArray(int column, const QList<QVariant> &list)
+     ba.resize(int(bufLen));
+ 
+     if (list.size() > arraySize) {
+-        error = QLatin1String("Array size missmatch: size of %1 is %2, size of provided list is %3");
++        error = QLatin1String("Array size mismatch: size of %1 is %2, size of provided list is %3");
+         error = error.arg(QLatin1String(sqlname)).arg(arraySize).arg(list.size());
+         q->setLastError(QSqlError(error, QLatin1String(""), QSqlError::StatementError));
+         return false;
+diff --git a/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp b/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
+index 7ca055eea2..6bc9d46755 100644
+--- a/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
++++ b/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
+@@ -223,7 +223,7 @@ public:
+     struct QMyField
+     {
+         char *outField = nullptr;
+-        MYSQL_FIELD *myField = nullptr;
++        const MYSQL_FIELD *myField = nullptr;
+         QMetaType::Type type = QMetaType::UnknownType;
+         my_bool nullIndicator = false;
+         ulong bufLength = 0ul;
+@@ -361,7 +361,7 @@ static bool qIsInteger(int t)
+ void QMYSQLResultPrivate::bindBlobs()
+ {
+     int i;
+-    MYSQL_FIELD *fieldInfo;
++    const MYSQL_FIELD *fieldInfo;
+     MYSQL_BIND *bind;
+ 
+     for(i = 0; i < fields.count(); ++i) {
+@@ -379,7 +379,6 @@ void QMYSQLResultPrivate::bindBlobs()
+ bool QMYSQLResultPrivate::bindInValues()
+ {
+     MYSQL_BIND *bind;
+-    char *field;
+     int i = 0;
+ 
+     if (!meta)
+@@ -392,35 +391,34 @@ bool QMYSQLResultPrivate::bindInValues()
+     inBinds = new MYSQL_BIND[fields.size()];
+     memset(inBinds, 0, fields.size() * sizeof(MYSQL_BIND));
+ 
+-    MYSQL_FIELD *fieldInfo;
++    const MYSQL_FIELD *fieldInfo;
+ 
+     while((fieldInfo = mysql_fetch_field(meta))) {
++        bind = &inBinds[i];
++
+         QMyField &f = fields[i];
+         f.myField = fieldInfo;
+-
++        bind->buffer_length = f.bufLength = fieldInfo->length + 1;
++        bind->buffer_type = fieldInfo->type;
+         f.type = qDecodeMYSQLType(fieldInfo->type, fieldInfo->flags);
+         if (qIsBlob(fieldInfo->type)) {
+             // the size of a blob-field is available as soon as we call
+             // mysql_stmt_store_result()
+             // after mysql_stmt_exec() in QMYSQLResult::exec()
+-            fieldInfo->length = 0;
++            bind->buffer_length = f.bufLength = 0;
+             hasBlobs = true;
+         } else if (qIsInteger(f.type)) {
+-            fieldInfo->length = 8;
++            bind->buffer_length = f.bufLength = 8;
+         } else {
+-            fieldInfo->type = MYSQL_TYPE_STRING;
++            bind->buffer_type = MYSQL_TYPE_STRING;
+         }
+-        bind = &inBinds[i];
+-        field = new char[fieldInfo->length + 1];
+-        memset(field, 0, fieldInfo->length + 1);
+ 
+-        bind->buffer_type = fieldInfo->type;
+-        bind->buffer = field;
+-        bind->buffer_length = f.bufLength = fieldInfo->length + 1;
+         bind->is_null = &f.nullIndicator;
+         bind->length = &f.bufLength;
+         bind->is_unsigned = fieldInfo->flags & UNSIGNED_FLAG ? 1 : 0;
+-        f.outField=field;
++
++        char *field = new char[bind->buffer_length + 1]{};
++        bind->buffer = f.outField = field;
+ 
+         ++i;
+     }
+@@ -1369,20 +1367,20 @@ bool QMYSQLDriver::open(const QString& db,
+     }
+ 
+ #if MYSQL_VERSION_ID >= 50007
+-    if (mysql_get_client_version() >= 50503 && mysql_get_server_version(d->mysql) >= 50503) {
+-        // force the communication to be utf8mb4 (only utf8mb4 supports 4-byte characters)
+-        mysql_set_character_set(d->mysql, "utf8mb4");
++    // force the communication to be utf8mb4 (only utf8mb4 supports 4-byte characters)
++    if (mysql_set_character_set(d->mysql, "utf8mb4")) {
++        // this failed, try forcing it to utf (BMP only)
++        if (mysql_set_character_set(d->mysql, "utf8"))
++            qWarning() << "MySQL: Unable to set the client character set to utf8.";
+ #if QT_CONFIG(textcodec)
+-        d->tc = QTextCodec::codecForName("UTF-8");
++        else
++            d->tc = codec(d->mysql);
+ #endif
+-    } else
+-    {
+-        // force the communication to be utf8
+-        mysql_set_character_set(d->mysql, "utf8");
++    }
+ #if QT_CONFIG(textcodec)
+-        d->tc = codec(d->mysql);
++    else
++        d->tc = QTextCodec::codecForName("UTF-8");
+ #endif
+-    }
+ #endif  // MYSQL_VERSION_ID >= 50007
+ 
+     d->preparedQuerysEnabled = checkPreparedQueries(d->mysql);
+diff --git a/qtbase/src/printsupport/dialogs/images/print-24.png b/qtbase/src/printsupport/dialogs/images/printer-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/print-24.png
+rename to src/printsupport/dialogs/images/printer-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/print-32.png b/qtbase/src/printsupport/dialogs/images/printer-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/print-32.png
+rename to src/printsupport/dialogs/images/printer-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-sided-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-facing-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-sided-24.png
+rename to src/printsupport/dialogs/images/view-pages-facing-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-sided-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-facing-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-sided-32.png
+rename to src/printsupport/dialogs/images/view-pages-facing-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-multi-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-overview-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-multi-24.png
+rename to src/printsupport/dialogs/images/view-pages-overview-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-multi-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-overview-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-multi-32.png
+rename to src/printsupport/dialogs/images/view-pages-overview-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-one-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-single-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-one-24.png
+rename to src/printsupport/dialogs/images/view-pages-single-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-one-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-single-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-one-32.png
+rename to src/printsupport/dialogs/images/view-pages-single-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-page-24.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-page-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-page-24.png
+rename to src/printsupport/dialogs/images/zoom-fit-page-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-page-32.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-page-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-page-32.png
+rename to src/printsupport/dialogs/images/zoom-fit-page-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-width-24.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-width-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-width-24.png
+rename to src/printsupport/dialogs/images/zoom-fit-width-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-width-32.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-width-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-width-32.png
+rename to src/printsupport/dialogs/images/zoom-fit-width-32.png
+diff --git a/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp b/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
+index 78e5b8d1ef..2a28516719 100644
+--- a/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
++++ b/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
+@@ -532,6 +532,7 @@ void QPageSetupWidget::updateWidget()
+ void QPageSetupWidget::setupPrinter() const
+ {
+     m_printer->setPageLayout(m_pageLayout);
++    m_printer->setPageOrientation(m_pageLayout.orientation());
+ #if QT_CONFIG(cups)
+     QCUPSSupport::PagesPerSheet pagesPerSheet = qvariant_cast<QCUPSSupport::PagesPerSheet>(m_ui.pagesPerSheetCombo->currentData()
+ );
+diff --git a/qtbase/src/printsupport/dialogs/qprintdialog.qrc b/qtbase/src/printsupport/dialogs/qprintdialog.qrc
+index 5a579baa55..10b8e1d341 100644
+--- a/qtbase/src/printsupport/dialogs/qprintdialog.qrc
++++ b/qtbase/src/printsupport/dialogs/qprintdialog.qrc
+@@ -1,9 +1,9 @@
+ <!DOCTYPE RCC><RCC version="1.0">
+ <qresource prefix="/qt-project.org/dialogs/qprintpreviewdialog">
+-<file>images/fit-page-24.png</file>
+-<file>images/fit-page-32.png</file>
+-<file>images/fit-width-24.png</file>
+-<file>images/fit-width-32.png</file>
++<file>images/zoom-fit-page-24.png</file>
++<file>images/zoom-fit-page-32.png</file>
++<file>images/zoom-fit-width-24.png</file>
++<file>images/zoom-fit-width-32.png</file>
+ <file>images/go-first-24.png</file>
+ <file>images/go-first-32.png</file>
+ <file>images/go-last-24.png</file>
+@@ -18,14 +18,14 @@
+ <file>images/layout-portrait-32.png</file>
+ <file>images/page-setup-24.png</file>
+ <file>images/page-setup-32.png</file>
+-<file>images/print-24.png</file>
+-<file>images/print-32.png</file>
+-<file>images/view-page-multi-24.png</file>
+-<file>images/view-page-multi-32.png</file>
+-<file>images/view-page-one-24.png</file>
+-<file>images/view-page-one-32.png</file>
+-<file>images/view-page-sided-24.png</file>
+-<file>images/view-page-sided-32.png</file>
++<file>images/printer-24.png</file>
++<file>images/printer-32.png</file>
++<file>images/view-pages-overview-24.png</file>
++<file>images/view-pages-overview-32.png</file>
++<file>images/view-pages-single-24.png</file>
++<file>images/view-pages-single-32.png</file>
++<file>images/view-pages-facing-24.png</file>
++<file>images/view-pages-facing-32.png</file>
+ <file>images/zoom-in-24.png</file>
+ <file>images/zoom-in-32.png</file>
+ <file>images/zoom-out-24.png</file>
+diff --git a/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp b/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
+index c5b845f4ec..5a5ba1d0a8 100644
+--- a/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
++++ b/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
+@@ -702,13 +702,14 @@ void QPrintDialogPrivate::selectPrinter(const QPrinter::OutputFormat outputForma
+         else
+             options.grayscale->setChecked(true);
+ 
+-        // keep duplex value explicitly set by user, if any, and selected printer supports it;
+-        // use device default otherwise
++        // duplex priorities to be as follows:
++        // 1) a user-selected duplex value in the dialog has highest prority
++        // 2) duplex value set in the QPrinter
+         QPrint::DuplexMode duplex;
+         if (explicitDuplexMode != QPrint::DuplexAuto && supportedDuplexMode.contains(explicitDuplexMode))
+             duplex = explicitDuplexMode;
+         else
+-            duplex = top->d->m_currentPrintDevice.defaultDuplexMode();
++            duplex = static_cast<QPrint::DuplexMode>(p->duplex());
+         switch (duplex) {
+         case QPrint::DuplexNone:
+             options.noDuplex->setChecked(true); break;
+@@ -1242,10 +1243,10 @@ void QUnixPrintWidgetPrivate::_q_printerChanged(int index)
+             QString filename = widget.filename->text();
+             widget.filename->setText(filename);
+             widget.lOutput->setEnabled(true);
+-            if (optionsPane)
+-                optionsPane->selectPrinter(QPrinter::PdfFormat);
+             printer->setOutputFormat(QPrinter::PdfFormat);
+             m_currentPrintDevice = QPrintDevice();
++            if (optionsPane)
++                optionsPane->selectPrinter(QPrinter::PdfFormat);
+             return;
+         }
+     }
+diff --git a/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp b/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
+index 39575d5f57..23b7e89538 100644
+--- a/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
++++ b/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
+@@ -352,7 +352,7 @@ void QPrintPreviewDialogPrivate::init(QPrinter *_printer)
+ static inline void qt_setupActionIcon(QAction *action, QLatin1String name)
+ {
+     QLatin1String imagePrefix(":/qt-project.org/dialogs/qprintpreviewdialog/images/");
+-    QIcon icon;
++    QIcon icon = QIcon::fromTheme(name);
+     icon.addFile(imagePrefix + name + QLatin1String("-24.png"), QSize(24, 24));
+     icon.addFile(imagePrefix + name + QLatin1String("-32.png"), QSize(32, 32));
+     action->setIcon(icon);
+@@ -383,8 +383,8 @@ void QPrintPreviewDialogPrivate::setupActions()
+     fitPageAction->setObjectName(QLatin1String("fitPageAction"));
+     fitWidthAction->setCheckable(true);
+     fitPageAction->setCheckable(true);
+-    qt_setupActionIcon(fitWidthAction, QLatin1String("fit-width"));
+-    qt_setupActionIcon(fitPageAction, QLatin1String("fit-page"));
++    qt_setupActionIcon(fitWidthAction, QLatin1String("zoom-fit-width"));
++    qt_setupActionIcon(fitPageAction, QLatin1String("zoom-fit-page"));
+     QObject::connect(fitGroup, SIGNAL(triggered(QAction*)), q, SLOT(_q_fit(QAction*)));
+ 
+     // Zoom
+@@ -410,9 +410,9 @@ void QPrintPreviewDialogPrivate::setupActions()
+     singleModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show single page"));
+     facingModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show facing pages"));
+     overviewModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show overview of all pages"));
+-    qt_setupActionIcon(singleModeAction, QLatin1String("view-page-one"));
+-    qt_setupActionIcon(facingModeAction, QLatin1String("view-page-sided"));
+-    qt_setupActionIcon(overviewModeAction, QLatin1String("view-page-multi"));
++    qt_setupActionIcon(singleModeAction, QLatin1String("view-pages-single"));
++    qt_setupActionIcon(facingModeAction, QLatin1String("view-pages-facing"));
++    qt_setupActionIcon(overviewModeAction, QLatin1String("view-pages-overview"));
+     singleModeAction->setObjectName(QLatin1String("singleModeAction"));
+     facingModeAction->setObjectName(QLatin1String("facingModeAction"));
+     overviewModeAction->setObjectName(QLatin1String("overviewModeAction"));
+@@ -426,7 +426,7 @@ void QPrintPreviewDialogPrivate::setupActions()
+     printerGroup = new QActionGroup(q);
+     printAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Print"));
+     pageSetupAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Page setup"));
+-    qt_setupActionIcon(printAction, QLatin1String("print"));
++    qt_setupActionIcon(printAction, QLatin1String("printer"));
+     qt_setupActionIcon(pageSetupAction, QLatin1String("page-setup"));
+     QObject::connect(printAction, SIGNAL(triggered(bool)), q, SLOT(_q_print()));
+     QObject::connect(pageSetupAction, SIGNAL(triggered(bool)), q, SLOT(_q_pageSetup()));
+diff --git a/qtbase/src/sql/kernel/qsqlquery.cpp b/qtbase/src/sql/kernel/qsqlquery.cpp
+index 32c6166c79..60afef10c3 100644
+--- a/qtbase/src/sql/kernel/qsqlquery.cpp
++++ b/qtbase/src/sql/kernel/qsqlquery.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2022 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtSql module of the Qt Toolkit.
+@@ -377,6 +377,10 @@ bool QSqlQuery::exec(const QString& query)
+     QElapsedTimer t;
+     t.start();
+ #endif
++    if (!driver()) {
++        qWarning("QSqlQuery::exec: called before driver has been set up");
++        return false;
++    }
+     if (d->ref.loadRelaxed() != 1) {
+         bool fo = isForwardOnly();
+         *this = QSqlQuery(driver()->createResult());
+diff --git a/qtbase/src/testlib/qabstractitemmodeltester.cpp b/qtbase/src/testlib/qabstractitemmodeltester.cpp
+index 8efb9c53d4..ce062f66d7 100644
+--- a/qtbase/src/testlib/qabstractitemmodeltester.cpp
++++ b/qtbase/src/testlib/qabstractitemmodeltester.cpp
+@@ -454,7 +454,7 @@ void QAbstractItemModelTesterPrivate::parent()
+ 
+     // Common error test #2, make sure that a second level index has a parent
+     // that is the first level index.
+-    if (model->rowCount(topIndex) > 0) {
++    if (model->rowCount(topIndex) > 0 && model->columnCount(topIndex) > 0) {
+         QModelIndex childIndex = model->index(0, 0, topIndex);
+         MODELTESTER_VERIFY(childIndex.isValid());
+         MODELTESTER_COMPARE(model->parent(childIndex), topIndex);
+diff --git a/qtbase/src/testlib/qasciikey.cpp b/qtbase/src/testlib/qasciikey.cpp
+index 9a308da2bc..93498b256f 100644
+--- a/qtbase/src/testlib/qasciikey.cpp
++++ b/qtbase/src/testlib/qasciikey.cpp
+@@ -498,6 +498,11 @@ char QTest::keyToAscii(Qt::Key key)
+     case Qt::Key_LaunchE : return 0; // = 0x10b0,
+     case Qt::Key_LaunchF : return 0; // = 0x10b1,
+ 
++    // Keypad navigation keys
++    case Qt::Key_Select : return 0; // = 0x01010000
++    case Qt::Key_Yes : return 0; // = 0x01010001
++    case Qt::Key_No : return 0; // = 0x01010002
++
+     default: QTEST_ASSERT(false); return 0;
+     }
+ }
+diff --git a/qtbase/src/testlib/qtestresult.cpp b/qtbase/src/testlib/qtestresult.cpp
+index 88028aac6e..2e89930776 100644
+--- a/qtbase/src/testlib/qtestresult.cpp
++++ b/qtbase/src/testlib/qtestresult.cpp
+@@ -251,7 +251,8 @@ bool QTestResult::verify(bool statement, const char *statementStr,
+ {
+     QTEST_ASSERT(statementStr);
+ 
+-    char msg[1024] = {'\0'};
++    char msg[1024];
++    msg[0] = '\0';
+ 
+     if (QTestLog::verboseLevel() >= 2) {
+         qsnprintf(msg, 1024, "QVERIFY(%s)", statementStr);
+@@ -309,7 +310,8 @@ static bool compareHelper(bool success, const char *failureMsg,
+                           bool hasValues = true)
+ {
+     const size_t maxMsgLen = 1024;
+-    char msg[maxMsgLen] = {'\0'};
++    char msg[maxMsgLen];
++    msg[0] = '\0';
+ 
+     QTEST_ASSERT(expected);
+     QTEST_ASSERT(actual);
+diff --git a/qtbase/src/widgets/dialogs/qcolordialog.cpp b/qtbase/src/widgets/dialogs/qcolordialog.cpp
+index 4247731275..cb325be85c 100644
+--- a/qtbase/src/widgets/dialogs/qcolordialog.cpp
++++ b/qtbase/src/widgets/dialogs/qcolordialog.cpp
+@@ -78,7 +78,10 @@
+ #include "qwindow.h"
+ 
+ #include "private/qdialog_p.h"
++#include "private/qguiapplication_p.h"
+ 
++#include <qpa/qplatformservices.h>
++#include <qpa/qplatformintegration.h>
+ #include <algorithm>
+ 
+ QT_BEGIN_NAMESPACE
+@@ -1611,6 +1614,20 @@ void QColorDialogPrivate::_q_newStandard(int r, int c)
+ void QColorDialogPrivate::_q_pickScreenColor()
+ {
+     Q_Q(QColorDialog);
++
++    auto *platformServices = QGuiApplicationPrivate::platformIntegration()->services();
++    if (platformServices->hasCapability(QPlatformServices::Capability::ColorPicking)) {
++        if (auto *colorPicker = platformServices->colorPicker(q->windowHandle())) {
++            q->connect(colorPicker, &QPlatformServiceColorPicker::colorPicked, q,
++                       [q, colorPicker](const QColor &color) {
++                           colorPicker->deleteLater();
++                           q->setCurrentColor(color);
++                       });
++            colorPicker->pickColor();
++            return;
++        }
++    }
++
+     if (!colorPickingEventFilter)
+         colorPickingEventFilter = new QColorPickingEventFilter(this, q);
+     q->installEventFilter(colorPickingEventFilter);
+diff --git a/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp b/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
+index e120817edc..8ea36b5427 100644
+--- a/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
++++ b/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
+@@ -400,12 +400,7 @@ bool QAbstractItemDelegate::helpEvent(QHelpEvent *event,
+         const QString tooltip = index.isValid() ?
+               d->textForRole(Qt::ToolTipRole, index.data(Qt::ToolTipRole), option.locale, precision) :
+               QString();
+-        QRect rect;
+-        if (index.isValid()) {
+-            const QRect r = view->visualRect(index);
+-            rect = QRect(view->mapToGlobal(r.topLeft()), r.size());
+-        }
+-        QToolTip::showText(he->globalPos(), tooltip, view, rect);
++        QToolTip::showText(he->globalPos(), tooltip, view->viewport(), option.rect);
+         event->setAccepted(!tooltip.isEmpty());
+         break;
+         }
+diff --git a/qtbase/src/widgets/itemviews/qlistview.cpp b/qtbase/src/widgets/itemviews/qlistview.cpp
+index 2b34476642..eebfaa030e 100644
+--- a/qtbase/src/widgets/itemviews/qlistview.cpp
++++ b/qtbase/src/widgets/itemviews/qlistview.cpp
+@@ -3386,6 +3386,7 @@ void QIconModeViewBase::updateContentsSize()
+ */
+ void QListView::currentChanged(const QModelIndex &current, const QModelIndex &previous)
+ {
++    QAbstractItemView::currentChanged(current, previous);
+ #ifndef QT_NO_ACCESSIBILITY
+     if (QAccessible::isActive()) {
+         if (current.isValid()) {
+@@ -3396,7 +3397,6 @@ void QListView::currentChanged(const QModelIndex &current, const QModelIndex &pr
+         }
+     }
+ #endif
+-    QAbstractItemView::currentChanged(current, previous);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/widgets/itemviews/qtableview.cpp b/qtbase/src/widgets/itemviews/qtableview.cpp
+index 934ac581b2..f79bb24249 100644
+--- a/qtbase/src/widgets/itemviews/qtableview.cpp
++++ b/qtbase/src/widgets/itemviews/qtableview.cpp
+@@ -1013,6 +1013,7 @@ void QTableViewPrivate::drawCell(QPainter *painter, const QStyleOptionViewItem &
+ int QTableViewPrivate::widthHintForIndex(const QModelIndex &index, int hint, const QStyleOptionViewItem &option) const
+ {
+     Q_Q(const QTableView);
++    const int oldHint = hint;
+     QWidget *editor = editorForIndex(index).widget.data();
+     if (editor && persistent.contains(editor)) {
+         hint = qMax(hint, editor->sizeHint().width());
+@@ -1021,6 +1022,17 @@ int QTableViewPrivate::widthHintForIndex(const QModelIndex &index, int hint, con
+         hint = qBound(min, hint, max);
+     }
+     hint = qMax(hint, q->itemDelegate(index)->sizeHint(option, index).width());
++
++    if (hasSpans()) {
++        auto span = spans.spanAt(index.column(), index.row());
++        if (span && span->m_left == index.column() && span->m_top == index.row()) {
++            // spans are screwed up when sections are moved
++            const auto left = logicalColumn(span->m_left);
++            for (int i = 1; i <= span->width(); ++i)
++               hint -= q->columnWidth(visualColumn(left + i));
++        }
++        hint = std::max(hint, oldHint);
++    }
+     return hint;
+ }
+ 
+@@ -1053,6 +1065,11 @@ int QTableViewPrivate::heightHintForIndex(const QModelIndex &index, int hint, QS
+         option.rect.setHeight(height);
+         option.rect.setX(q->columnViewportPosition(index.column()));
+         option.rect.setWidth(q->columnWidth(index.column()));
++        if (hasSpans()) {
++            auto span = spans.spanAt(index.column(), index.row());
++            if (span && span->m_left == index.column() && span->m_top == index.row())
++                option.rect.setWidth(std::max(option.rect.width(), visualSpanRect(*span).width()));
++        }
+         // 1px less space when grid is shown (see drawCell)
+         if (showGrid)
+             option.rect.setWidth(option.rect.width() - 1);
+diff --git a/qtbase/src/widgets/kernel/qaction.h b/qtbase/src/widgets/kernel/qaction.h
+index 258a1ea0a0..737c1e8285 100644
+--- a/qtbase/src/widgets/kernel/qaction.h
++++ b/qtbase/src/widgets/kernel/qaction.h
+@@ -81,7 +81,7 @@ class Q_WIDGETS_EXPORT QAction : public QObject
+     Q_PROPERTY(MenuRole menuRole READ menuRole WRITE setMenuRole NOTIFY changed)
+     Q_PROPERTY(bool iconVisibleInMenu READ isIconVisibleInMenu WRITE setIconVisibleInMenu NOTIFY changed)
+     Q_PROPERTY(bool shortcutVisibleInContextMenu READ isShortcutVisibleInContextMenu WRITE setShortcutVisibleInContextMenu NOTIFY changed)
+-    Q_PROPERTY(Priority priority READ priority WRITE setPriority)
++    Q_PROPERTY(Priority priority READ priority WRITE setPriority NOTIFY changed)
+ 
+ public:
+     // note this is copied into qplatformmenu.h, which must stay in sync
+diff --git a/qtbase/src/widgets/kernel/qwidget.cpp b/qtbase/src/widgets/kernel/qwidget.cpp
+index 9eba1e001e..26f6d27e18 100644
+--- a/qtbase/src/widgets/kernel/qwidget.cpp
++++ b/qtbase/src/widgets/kernel/qwidget.cpp
+@@ -5296,7 +5296,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
+         QWidgetEffectSourcePrivate *sourced = static_cast<QWidgetEffectSourcePrivate *>
+                                                          (source->d_func());
+         if (!sourced->context) {
+-            const QRegion effectRgn(rgn.boundingRect());
++            const QRegion effectRgn((flags & UseEffectRegionBounds) ? rgn.boundingRect() : rgn);
+             QWidgetPaintContext context(pdev, effectRgn, offset, flags, sharedPainter, repaintManager);
+             sourced->context = &context;
+             if (!sharedPainter) {
+@@ -5328,6 +5328,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
+         }
+     }
+ #endif // QT_CONFIG(graphicseffect)
++    flags = flags & ~UseEffectRegionBounds;
+ 
+     const bool alsoOnScreen = flags & DrawPaintOnScreen;
+     const bool recursive = flags & DrawRecursive;
+diff --git a/qtbase/src/widgets/kernel/qwidget_p.h b/qtbase/src/widgets/kernel/qwidget_p.h
+index eef6b8fa2c..c432f4b5d5 100644
+--- a/qtbase/src/widgets/kernel/qwidget_p.h
++++ b/qtbase/src/widgets/kernel/qwidget_p.h
+@@ -229,7 +229,8 @@ public:
+         DontSubtractOpaqueChildren = 0x10,
+         DontDrawOpaqueChildren = 0x20,
+         DontDrawNativeChildren = 0x40,
+-        DontSetCompositionMode = 0x80
++        DontSetCompositionMode = 0x80,
++        UseEffectRegionBounds = 0x100
+     };
+     Q_DECLARE_FLAGS(DrawWidgetFlags, DrawWidgetFlag)
+     Q_FLAG(DrawWidgetFlags)
+diff --git a/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp b/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
+index 02880b34da..0d44e1326d 100644
+--- a/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
++++ b/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
+@@ -1018,7 +1018,8 @@ void QWidgetRepaintManager::paintAndFlush()
+ 
+     // Paint the rest with composition.
+     if (repaintAllWidgets || !dirtyCopy.isEmpty()) {
+-        QWidgetPrivate::DrawWidgetFlags flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive;
++        QWidgetPrivate::DrawWidgetFlags flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive
++                | QWidgetPrivate::UseEffectRegionBounds;
+         tlw->d_func()->drawWidget(store->paintDevice(), dirtyCopy, QPoint(), flags, nullptr, this);
+     }
+ 
+diff --git a/qtbase/src/widgets/styles/qfusionstyle.cpp b/qtbase/src/widgets/styles/qfusionstyle.cpp
+index f4345d97c4..962912c838 100644
+--- a/qtbase/src/widgets/styles/qfusionstyle.cpp
++++ b/qtbase/src/widgets/styles/qfusionstyle.cpp
+@@ -1772,14 +1772,6 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio
+             proxy()->drawControl(CE_PushButtonLabel, &subopt, painter, widget);
+         }
+         break;
+-    case CE_PushButtonLabel:
+-        if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
+-            QStyleOptionButton b(*button);
+-            // no PM_ButtonShiftHorizontal and PM_ButtonShiftVertical for fusion style
+-            b.state &= ~(State_On | State_Sunken);
+-            QCommonStyle::drawControl(element, &b, painter, widget);
+-        }
+-        break;
+     case CE_MenuBarEmptyArea:
+         painter->save();
+     {
+diff --git a/qtbase/src/widgets/util/qcompleter.cpp b/qtbase/src/widgets/util/qcompleter.cpp
+index 18b24063d8..ef7207a8a3 100644
+--- a/qtbase/src/widgets/util/qcompleter.cpp
++++ b/qtbase/src/widgets/util/qcompleter.cpp
+@@ -1120,6 +1120,8 @@ void QCompleter::setModel(QAbstractItemModel *model)
+ {
+     Q_D(QCompleter);
+     QAbstractItemModel *oldModel = d->proxy->sourceModel();
++    if (oldModel == model)
++        return;
+ #if QT_CONFIG(filesystemmodel)
+     if (qobject_cast<const QFileSystemModel *>(oldModel))
+         setCompletionRole(Qt::EditRole); // QTBUG-54642, clear FileNameRole set by QFileSystemModel
+diff --git a/qtbase/src/widgets/widgets/qabstractbutton.cpp b/qtbase/src/widgets/widgets/qabstractbutton.cpp
+index a128b23950..dc40bf62fb 100644
+--- a/qtbase/src/widgets/widgets/qabstractbutton.cpp
++++ b/qtbase/src/widgets/widgets/qabstractbutton.cpp
+@@ -56,6 +56,7 @@
+ #ifndef QT_NO_ACCESSIBILITY
+ #include "qaccessible.h"
+ #endif
++#include <qpa/qplatformtheme.h>
+ 
+ #include <algorithm>
+ 
+@@ -1076,19 +1077,19 @@ void QAbstractButton::keyPressEvent(QKeyEvent *e)
+ {
+     Q_D(QAbstractButton);
+     bool next = true;
+-    switch (e->key()) {
+-    case Qt::Key_Enter:
+-    case Qt::Key_Return:
+-        e->ignore();
+-        break;
+-    case Qt::Key_Select:
+-    case Qt::Key_Space:
+-        if (!e->isAutoRepeat()) {
+-            setDown(true);
+-            repaint();
+-            d->emitPressed();
+-        }
+-        break;
++
++    const auto key = static_cast<Qt::Key>(e->key());
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(key) && !e->isAutoRepeat()) {
++        setDown(true);
++        repaint();
++        d->emitPressed();
++        return;
++    }
++
++    switch (key) {
+     case Qt::Key_Up:
+         next = false;
+         Q_FALLTHROUGH();
+@@ -1153,15 +1154,15 @@ void QAbstractButton::keyReleaseEvent(QKeyEvent *e)
+     if (!e->isAutoRepeat())
+         d->repeatTimer.stop();
+ 
+-    switch (e->key()) {
+-    case Qt::Key_Select:
+-    case Qt::Key_Space:
+-        if (!e->isAutoRepeat() && d->down)
+-            d->click();
+-        break;
+-    default:
+-        e->ignore();
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(static_cast<Qt::Key>(e->key())) && !e->isAutoRepeat() && d->down) {
++        d->click();
++        return;
+     }
++
++    e->ignore();
+ }
+ 
+ /*!\reimp
+diff --git a/qtbase/src/widgets/widgets/qcombobox.cpp b/qtbase/src/widgets/widgets/qcombobox.cpp
+index 7a496c27e0..0a3d96647b 100644
+--- a/qtbase/src/widgets/widgets/qcombobox.cpp
++++ b/qtbase/src/widgets/widgets/qcombobox.cpp
+@@ -3352,7 +3352,23 @@ void QComboBox::keyPressEvent(QKeyEvent *e)
+ 
+     Move move = NoMove;
+     int newIndex = currentIndex();
+-    switch (e->key()) {
++
++    bool pressLikeButton = !d->lineEdit;
++#ifdef QT_KEYPAD_NAVIGATION
++    pressLikeButton |= QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus();
++#endif
++    auto key = static_cast<Qt::Key>(e->key());
++    if (pressLikeButton) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(key)) {
++            showPopup();
++            return;
++        }
++    }
++
++    switch (key) {
+     case Qt::Key_Up:
+         if (e->modifiers() & Qt::ControlModifier)
+             break; // pass to line edit for auto completion
+@@ -3394,26 +3410,11 @@ void QComboBox::keyPressEvent(QKeyEvent *e)
+             return;
+         }
+         break;
+-    case Qt::Key_Space:
+-        if (!d->lineEdit) {
+-            showPopup();
+-            return;
+-        }
+-        break;
+-    case Qt::Key_Enter:
+-    case Qt::Key_Return:
+     case Qt::Key_Escape:
+         if (!d->lineEdit)
+             e->ignore();
+         break;
+ #ifdef QT_KEYPAD_NAVIGATION
+-    case Qt::Key_Select:
+-        if (QApplicationPrivate::keypadNavigationEnabled()
+-                && (!hasEditFocus() || !d->lineEdit)) {
+-            showPopup();
+-            return;
+-        }
+-        break;
+     case Qt::Key_Left:
+     case Qt::Key_Right:
+         if (QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus())
+diff --git a/qtbase/src/widgets/widgets/qdatetimeedit_p.h b/qtbase/src/widgets/widgets/qdatetimeedit_p.h
+index d36b6f8f9a..e0df5b5158 100644
+--- a/qtbase/src/widgets/widgets/qdatetimeedit_p.h
++++ b/qtbase/src/widgets/widgets/qdatetimeedit_p.h
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2018 The Qt Company Ltd.
++** Copyright (C) 2021 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtWidgets module of the Qt Toolkit.
+diff --git a/qtbase/src/widgets/widgets/qgroupbox.cpp b/qtbase/src/widgets/widgets/qgroupbox.cpp
+index 02a0bed325..3f3eccc370 100644
+--- a/qtbase/src/widgets/widgets/qgroupbox.cpp
++++ b/qtbase/src/widgets/widgets/qgroupbox.cpp
+@@ -54,6 +54,8 @@
+ #include "qaccessible.h"
+ #endif
+ #include <private/qwidget_p.h>
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
+ 
+ #include "qdebug.h"
+ 
+@@ -360,7 +362,10 @@ bool QGroupBox::event(QEvent *e)
+         return true;
+     case QEvent::KeyPress: {
+         QKeyEvent *k = static_cast<QKeyEvent*>(e);
+-        if (!k->isAutoRepeat() && (k->key() == Qt::Key_Select || k->key() == Qt::Key_Space)) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (!k->isAutoRepeat() && buttonPressKeys.contains(static_cast<Qt::Key>(k->key()))) {
+             d->pressedControl = QStyle::SC_GroupBoxCheckBox;
+             update(style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxCheckBox, this));
+             return true;
+@@ -369,7 +374,10 @@ bool QGroupBox::event(QEvent *e)
+     }
+     case QEvent::KeyRelease: {
+         QKeyEvent *k = static_cast<QKeyEvent*>(e);
+-        if (!k->isAutoRepeat() && (k->key() == Qt::Key_Select || k->key() == Qt::Key_Space)) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (!k->isAutoRepeat() && buttonPressKeys.contains(static_cast<Qt::Key>(k->key()))) {
+             bool toggle = (d->pressedControl == QStyle::SC_GroupBoxLabel
+                            || d->pressedControl == QStyle::SC_GroupBoxCheckBox);
+             d->pressedControl = QStyle::SC_None;
+diff --git a/qtbase/src/widgets/widgets/qlabel.cpp b/qtbase/src/widgets/widgets/qlabel.cpp
+index 30ff80cbb0..cf2605c17c 100644
+--- a/qtbase/src/widgets/widgets/qlabel.cpp
++++ b/qtbase/src/widgets/widgets/qlabel.cpp
+@@ -421,9 +421,6 @@ void QLabel::setPixmap(const QPixmap &pixmap)
+         d->pixmap = new QPixmap(pixmap);
+     }
+ 
+-    if (d->pixmap->depth() == 1 && !d->pixmap->mask())
+-        d->pixmap->setMask(*((QBitmap *)d->pixmap));
+-
+     d->updateLabel();
+ }
+ 
+diff --git a/qtbase/src/widgets/widgets/qtoolbararealayout.cpp b/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
+index 493c094cc1..d5f4b59017 100644
+--- a/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
++++ b/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
+@@ -1367,7 +1367,7 @@ bool QToolBarAreaLayout::restoreState(QDataStream &stream, const QList<QToolBar*
+                 item.widgetItem = new QWidgetItemV2(toolBar);
+                 toolBar->setOrientation(floating ? ((shown & 2) ? Qt::Vertical : Qt::Horizontal) : dock.o);
+                 toolBar->setVisible(shown & 1);
+-                toolBar->d_func()->setWindowState(floating, true, rect);
++                toolBar->d_func()->setWindowState(floating, false, rect);
+ 
+                 item.preferredSize = item.size;
+                 line.toolBarItems.append(item);
+diff --git a/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp b/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
+index 212c0a2e13..3c77b1ba0b 100644
+--- a/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
++++ b/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
+@@ -126,8 +126,7 @@ public:
+ 
+ void tst_QtConcurrentIterateKernel::instantiate()
+ {
+-    auto future = startThreadEngine(new PrintFor(0, 40)).startAsynchronously();
+-    future.waitForFinished();
++    startThreadEngine(new PrintFor(0, 40)).startBlocking();
+     QCOMPARE(iterations.loadRelaxed(), 40);
+ }
+ 
+@@ -166,10 +165,8 @@ void tst_QtConcurrentIterateKernel::stresstest()
+     const int times = 50;
+     for (int i = 0; i < times; ++i) {
+         counter.storeRelaxed(0);
+-        // ThreadEngine will delete f when it finishes
+-        auto f = new CountFor(0, iterations);
+-        auto future = f->startAsynchronously();
+-        future.waitForFinished();
++        CountFor f(0, iterations);
++        f.startBlocking();
+         QCOMPARE(counter.loadRelaxed(), iterations);
+     }
+ }
+@@ -177,11 +174,8 @@ void tst_QtConcurrentIterateKernel::stresstest()
+ void tst_QtConcurrentIterateKernel::noIterations()
+ {
+     const int times = 20000;
+-    for (int i = 0; i < times; ++i) {
+-        auto future = startThreadEngine(new IterateKernel<TestIterator, void>(0, 0))
+-                              .startAsynchronously();
+-        future.waitForFinished();
+-    }
++    for (int i = 0; i < times; ++i)
++        startThreadEngine(new IterateKernel<TestIterator, void>(0, 0)).startBlocking();
+ }
+ 
+ QMutex threadsMutex;
+@@ -236,10 +230,8 @@ void tst_QtConcurrentIterateKernel::throttling()
+ 
+     threads.clear();
+ 
+-    // ThreadEngine will delete f when it finishes
+-    auto f = new ThrottleFor(0, totalIterations);
+-    auto future = f->startAsynchronously();
+-    future.waitForFinished();
++    ThrottleFor f(0, totalIterations);
++    f.startBlocking();
+ 
+     QCOMPARE(iterations.loadRelaxed(), totalIterations);
+ 
+diff --git a/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp b/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
+index ac7be7acdd..81bc64c8d9 100644
+--- a/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
++++ b/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
+@@ -65,9 +65,16 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::runDirectly()
+ {
+-    PrintUser *engine = new PrintUser();
+-    QFuture<void> f = engine->startAsynchronously();
+-    f.waitForFinished();
++    {
++        PrintUser engine;
++        engine.startSingleThreaded();
++        engine.startBlocking();
++    }
++    {
++        PrintUser *engine = new PrintUser();
++        QFuture<void> f = engine->startAsynchronously();
++        f.waitForFinished();
++    }
+ }
+ 
+ class StringResultUser : public ThreadEngine<QString>
+@@ -99,10 +106,8 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::result()
+ {
+-    // ThreadEngine will delete 'engine' when it finishes
+-    auto engine = new StringResultUser();
+-    auto future = engine->startAsynchronously();
+-    QCOMPARE(future.result(), QString("Foo"));
++    StringResultUser engine;
++    QCOMPARE(*engine.startBlocking(), QString("Foo"));
+ }
+ 
+ class VoidResultUser : public ThreadEngine<void>
+@@ -128,9 +133,17 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::runThroughStarter()
+ {
+-    ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
+-    QFuture<QString> f = starter.startAsynchronously();
+-    QCOMPARE(f.result(), QString("Foo"));
++    {
++        ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
++        QFuture<QString>  f = starter.startAsynchronously();
++        QCOMPARE(f.result(), QString("Foo"));
++    }
++
++    {
++        ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
++        QString str = starter.startBlocking();
++        QCOMPARE(str, QString("Foo"));
++    }
+ }
+ 
+ class CancelUser : public ThreadEngine<void>
+@@ -213,6 +226,12 @@ void tst_QtConcurrentThreadEngine::throttle()
+         f.waitForFinished();
+         QCOMPARE(count.loadRelaxed(), 0);
+     }
++
++    for (int i = 0; i < repeats; ++i) {
++        ThrottleAlwaysUser t;
++        t.startBlocking();
++        QCOMPARE(count.loadRelaxed(), 0);
++    }
+ }
+ 
+ QSet<QThread *> threads;
+@@ -249,17 +268,35 @@ void tst_QtConcurrentThreadEngine::threadCount()
+ {
+     const int repeats = 10;
+     for (int i = 0; i < repeats; ++i) {
++        ThreadCountUser t;
++        t.startBlocking();
++        int count = threads.count();
++        int count_expected = QThreadPool::globalInstance()->maxThreadCount() + 1; // +1 for the main thread.
++        if (count != count_expected)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, count_expected);
++
+         (new ThreadCountUser())->startAsynchronously().waitForFinished();
+-        const auto count = threads.count();
+-        const auto maxThreadCount = QThreadPool::globalInstance()->maxThreadCount();
+-        QVERIFY(count <= maxThreadCount);
+-        QVERIFY(!threads.contains(QThread::currentThread()));
++        count = threads.count();
++        count_expected = QThreadPool::globalInstance()->maxThreadCount();
++        if (count != count_expected)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, count_expected);
+     }
+ 
+     // Set the finish flag immediately, this should give us one thread only.
+     for (int i = 0; i < repeats; ++i) {
++        ThreadCountUser t(true /*finishImmediately*/);
++        t.startBlocking();
++        int count = threads.count();
++        if (count != 1)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, 1);
++
+         (new ThreadCountUser(true /*finishImmediately*/))->startAsynchronously().waitForFinished();
+-        const auto count = threads.count();
++        count = threads.count();
++        if (count != 1)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
+         QCOMPARE(count, 1);
+         QVERIFY(!threads.contains(QThread::currentThread()));
+     }
+@@ -400,6 +437,7 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::exceptions()
+ {
++    // Asynchronous mode:
+     {
+         bool caught = false;
+         try  {
+@@ -412,6 +450,32 @@ void tst_QtConcurrentThreadEngine::exceptions()
+         QVERIFY2(caught, "did not get exception");
+     }
+ 
++    // Blocking mode:
++    // test throwing the exception from a worker thread.
++    {
++        bool caught = false;
++        try  {
++            QtConcurrentExceptionThrower e(QThread::currentThread());
++            e.startBlocking();
++        } catch (const QException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // test throwing the exception from the main thread (different code path)
++    {
++        bool caught = false;
++        try  {
++            QtConcurrentExceptionThrower e(0);
++            e.startBlocking();
++        } catch (const QException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // Asynchronous mode:
+     {
+         bool caught = false;
+         try  {
+@@ -423,6 +487,31 @@ void tst_QtConcurrentThreadEngine::exceptions()
+         }
+         QVERIFY2(caught, "did not get exception");
+     }
++
++    // Blocking mode:
++    // test throwing the exception from a worker thread.
++    {
++        bool caught = false;
++        try  {
++            UnrelatedExceptionThrower e(QThread::currentThread());
++            e.startBlocking();
++        } catch (const QUnhandledException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // test throwing the exception from the main thread (different code path)
++    {
++        bool caught = false;
++        try  {
++            UnrelatedExceptionThrower e(0);
++            e.startBlocking();
++        } catch (const QUnhandledException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
+ }
+ 
+ #endif
+diff --git a/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp b/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
+index 4968742110..f4c3fb711d 100644
+--- a/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
++++ b/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
+@@ -42,6 +42,7 @@ private slots:
+     void writeBlock_data();
+     void writeBlock();
+     void seek();
++    void invalidSeeks();
+     void seekTest_data();
+     void seekTest();
+     void read_rawdata();
+@@ -286,6 +287,29 @@ void tst_QBuffer::seek()
+     QCOMPARE(buffer.size(), pos);
+ }
+ 
++void tst_QBuffer::invalidSeeks()
++{
++    if constexpr (sizeof(qsizetype) == sizeof(qint64)) {
++        // sizeof(qsizetype) == sizeof(qint64), so +1 would overflow
++        QSKIP("This is a 32-bit-only test.");
++    } else {
++        QBuffer buffer;
++        buffer.open(QIODevice::WriteOnly);
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++        constexpr qint64 MaxQByteArrayCapacity = (std::numeric_limits<qsizetype>::max)();
++        // this should fail fast, not after trying to allocate nearly 2 GiB of data,
++        // potentially crashing in the process:
++        QVERIFY(!buffer.seek(2 * MaxQByteArrayCapacity - 1));
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++        // ditto:
++        QVERIFY(!buffer.seek(MaxQByteArrayCapacity + 1));
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++    }
++}
++
+ void tst_QBuffer::seekTest_data()
+ {
+     writeBlock_data();
+diff --git a/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp b/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
+index da5327594c..4a04e0f7c6 100644
+--- a/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
++++ b/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
+@@ -561,7 +561,8 @@ protected:
+     qint64 readData(char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf->size() - offset));
+-        memcpy(data, buf->constData() + offset, maxSize);
++        if (maxSize > 0)
++            memcpy(data, buf->constData() + offset, maxSize);
+         offset += maxSize;
+         return maxSize;
+     }
+@@ -604,13 +605,15 @@ protected:
+     qint64 readData(char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf.size() - pos()));
+-        memcpy(data, buf.constData() + pos(), maxSize);
++        if (maxSize > 0)
++            memcpy(data, buf.constData() + pos(), maxSize);
+         return maxSize;
+     }
+     qint64 writeData(const char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf.size() - pos()));
+-        memcpy(buf.data() + pos(), data, maxSize);
++        if (maxSize > 0)
++            memcpy(buf.data() + pos(), data, maxSize);
+         return maxSize;
+     }
+ 
+diff --git a/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+index db60bead64..f345a44414 100644
+--- a/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
++++ b/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+@@ -1,7 +1,8 @@
+ /****************************************************************************
+ **
+ ** Copyright (C) 2021 The Qt Company Ltd.
+-** Copyright (C) 2020 Intel Corporation.
++** Copyright (C) 2020 The Qt Company Ltd.
++** Copyright (C) 2022 Intel Corporation.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the test suite of the Qt Toolkit.
+@@ -150,6 +151,8 @@ private slots:
+     void startStopStartStopBuffers();
+     void processEventsInAReadyReadSlot_data();
+     void processEventsInAReadyReadSlot();
++    void startFromCurrentWorkingDir_data();
++    void startFromCurrentWorkingDir();
+ 
+     // keep these at the end, since they use lots of processes and sometimes
+     // caused obscure failures to occur in tests that followed them (esp. on the Mac)
+@@ -2731,5 +2734,94 @@ void tst_QProcess::finishProcessBeforeReadingDone_deprecated()
+ 
+ #endif
+ 
++enum class ChdirMode {
++    None = 0,
++    InParent,
++    InChild
++};
++Q_DECLARE_METATYPE(ChdirMode)
++
++void tst_QProcess::startFromCurrentWorkingDir_data()
++{
++    qRegisterMetaType<ChdirMode>();
++    QTest::addColumn<QString>("programPrefix");
++    QTest::addColumn<ChdirMode>("chdirMode");
++    QTest::addColumn<bool>("success");
++
++    constexpr bool IsWindows = true
++#ifdef Q_OS_UNIX
++            && false
++#endif
++            ;
++
++    // baseline: trying to execute the directory, this can't possibly succeed!
++    QTest::newRow("plain-same-cwd") << QString() << ChdirMode::None << false;
++
++    // cross-platform behavior: neither OS searches the setWorkingDirectory()
++    // dir without "./"
++    QTest::newRow("plain-child-chdir") << QString() << ChdirMode::InChild << false;
++
++    // cross-platform behavior: both OSes search the parent's CWD with "./"
++    QTest::newRow("prefixed-parent-chdir") << "./" << ChdirMode::InParent << true;
++
++    // opposite behaviors: Windows searches the parent's CWD and Unix searches
++    // the child's with "./"
++    QTest::newRow("prefixed-child-chdir") << "./" << ChdirMode::InChild << !IsWindows;
++
++    // Windows searches the parent's CWD without "./"
++    QTest::newRow("plain-parent-chdir") << QString() << ChdirMode::InParent << IsWindows;
++}
++
++void tst_QProcess::startFromCurrentWorkingDir()
++{
++    QFETCH(QString, programPrefix);
++    QFETCH(ChdirMode, chdirMode);
++    QFETCH(bool, success);
++
++    QProcess process;
++    qRegisterMetaType<QProcess::ProcessError>();
++    QSignalSpy errorSpy(&process, &QProcess::errorOccurred);
++    QVERIFY(errorSpy.isValid());
++
++    // both the dir name and the executable name
++    const QString target = QStringLiteral("testProcessNormal");
++    process.setProgram(programPrefix + target);
++
++#ifdef Q_OS_UNIX
++    // Reset PATH, to be sure it doesn't contain . or the empty path.
++    // We can't do this on Windows because DLLs are searched in PATH
++    // and Windows always searches "." anyway.
++    auto restoreEnv = qScopeGuard([old = qgetenv("PATH")] {
++        qputenv("PATH", old);
++    });
++    qputenv("PATH", "/");
++#endif
++
++    switch (chdirMode) {
++    case ChdirMode::InParent: {
++        auto restoreCwd = qScopeGuard([old = QDir::currentPath()] {
++            QDir::setCurrent(old);
++        });
++        QVERIFY(QDir::setCurrent(target));
++        process.start();
++        break;
++    }
++    case ChdirMode::InChild:
++        process.setWorkingDirectory(target);
++        Q_FALLTHROUGH();
++    case ChdirMode::None:
++        process.start();
++        break;
++    }
++
++    QCOMPARE(process.waitForStarted(), success);
++    QCOMPARE(errorSpy.count(), int(!success));
++    if (success) {
++        QVERIFY(process.waitForFinished());
++    } else {
++        QCOMPARE(process.error(), QProcess::FailedToStart);
++    }
++}
++
+ QTEST_MAIN(tst_QProcess)
+ #include "tst_qprocess.moc"
+diff --git a/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp b/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp
+index e1ea7a4552..90972caa57 100644
+--- a/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp
++++ b/qtbase/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"
+diff --git a/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+index 9bd66c0835..ed4a0bae5d 100644
+--- a/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
++++ b/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+@@ -158,6 +158,7 @@ private slots:
+     void nullReceiver();
+     void functorReferencesConnection();
+     void disconnectDisconnects();
++    void declarativeData();
+ };
+ 
+ struct QObjectCreatedOnShutdown
+@@ -7679,5 +7680,81 @@ void tst_QObject::disconnectDisconnects()
+ Q_STATIC_ASSERT(QtPrivate::HasQ_OBJECT_Macro<tst_QObject>::Value);
+ Q_STATIC_ASSERT(!QtPrivate::HasQ_OBJECT_Macro<SiblingDeleter>::Value);
+ 
++#ifdef QT_BUILD_INTERNAL
++/*
++    Since QObjectPrivate stores the declarativeData pointer in a union with the pointer
++    to the currently destroyed child, calls to the QtDeclarative handlers need to be
++    correctly guarded. QTBUG-105286
++*/
++namespace QtDeclarative {
++static QAbstractDeclarativeData *theData;
++
++static void destroyed(QAbstractDeclarativeData *data, QObject *)
++{
++    QCOMPARE(data, theData);
++}
++static void signalEmitted(QAbstractDeclarativeData *data, QObject *, int, void **)
++{
++    QCOMPARE(data, theData);
++}
++// we can't use QCOMPARE in the next two functions, as they don't return void
++static int receivers(QAbstractDeclarativeData *data, const QObject *, int)
++{
++    QTest::qCompare(data, theData, "data", "theData", __FILE__, __LINE__);
++    return 0;
++}
++static bool isSignalConnected(QAbstractDeclarativeData *data, const QObject *, int)
++{
++    QTest::qCompare(data, theData, "data", "theData", __FILE__, __LINE__);
++    return true;
++}
++
++class Object : public QObject
++{
++    Q_OBJECT
++public:
++    using QObject::QObject;
++    ~Object()
++    {
++        if (Object *p = static_cast<Object *>(parent()))
++            p->emitSignal();
++    }
++
++    void emitSignal()
++    {
++        emit theSignal();
++    }
++
++signals:
++    void theSignal();
++};
++
++}
++#endif
++
++void tst_QObject::declarativeData()
++{
++#ifdef QT_BUILD_INTERNAL
++    QScopedValueRollback destroyed(QAbstractDeclarativeData::destroyed,
++                                   QtDeclarative::destroyed);
++    QScopedValueRollback signalEmitted(QAbstractDeclarativeData::signalEmitted,
++                                       QtDeclarative::signalEmitted);
++    QScopedValueRollback receivers(QAbstractDeclarativeData::receivers,
++                                   QtDeclarative::receivers);
++    QScopedValueRollback isSignalConnected(QAbstractDeclarativeData::isSignalConnected,
++                                           QtDeclarative::isSignalConnected);
++
++    QtDeclarative::Object p;
++    QObjectPrivate *priv = QObjectPrivate::get(&p);
++    priv->declarativeData = QtDeclarative::theData = new QAbstractDeclarativeData;
++
++    connect(&p, &QtDeclarative::Object::theSignal, &p, []{
++    });
++
++    QtDeclarative::Object *child = new QtDeclarative::Object;
++    child->setParent(&p);
++#endif
++}
++
+ QTEST_MAIN(tst_QObject)
+ #include "tst_qobject.moc"
+diff --git a/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp b/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
+index 0ea422ecbc..1a3256534b 100644
+--- a/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
++++ b/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
+@@ -70,15 +70,15 @@ static inline QString testSuiteWarning()
+ 
+     QString result;
+     QTextStream str(&result);
+-    str << "\nCannot find the shared-mime-info test suite\nstarting from: "
++    str << "\nCannot find the shared-mime-info test suite\nin the parent of: "
+         << QDir::toNativeSeparators(QDir::currentPath()) << "\n"
+            "cd " << QDir::toNativeSeparators(QStringLiteral("tests/auto/corelib/mimetypes/qmimedatabase")) << "\n"
+-           "wget http://cgit.freedesktop.org/xdg/shared-mime-info/snapshot/Release-1-10.zip\n"
+-           "unzip Release-1-10.zip\n";
++           "wget https://gitlab.freedesktop.org/xdg/shared-mime-info/-/archive/2.1/shared-mime-info-2.1.zip\n"
++           "unzip shared-mime-info-2.1.zip\n";
+ #ifdef Q_OS_WIN
+-    str << "mkdir testfiles\nxcopy /s Release-1-10 s-m-i\n";
++    str << "mkdir testfiles\nxcopy /s shared-mime-info-2.1 s-m-i\n";
+ #else
+-    str << "ln -s Release-1-10 s-m-i\n";
++    str << "ln -s shared-mime-info-2.1 s-m-i\n";
+ #endif
+     return result;
+ }
+@@ -154,7 +154,7 @@ void tst_QMimeDatabase::initTestCase()
+     QVERIFY2(copyResourceFile(xmlFileName, xmlTargetFileName, &errorMessage), qPrintable(errorMessage));
+ #endif
+ 
+-    m_testSuite = QFINDTESTDATA("s-m-i/tests");
++    m_testSuite = QFINDTESTDATA("s-m-i/tests/mime-detection");
+     if (m_testSuite.isEmpty())
+         qWarning("%s", qPrintable(testSuiteWarning()));
+ 
+@@ -611,7 +611,7 @@ void tst_QMimeDatabase::allMimeTypes()
+     QVERIFY(!lst.isEmpty());
+ 
+     // Hardcoding this is the only way to check both providers find the same number of mimetypes.
+-    QCOMPARE(lst.count(), 779);
++    QCOMPARE(lst.count(), 811);
+ 
+     foreach (const QMimeType &mime, lst) {
+         const QString name = mime.name();
+@@ -631,10 +631,9 @@ void tst_QMimeDatabase::suffixes_data()
+ 
+     QTest::newRow("mimetype with a single pattern") << "application/pdf" << "*.pdf" << "pdf";
+     QTest::newRow("mimetype with multiple patterns") << "application/x-kpresenter" << "*.kpr;*.kpt" << "kpr";
+-    QTest::newRow("jpeg") << "image/jpeg" << "*.jpe;*.jpg;*.jpeg" << "jpeg";
+-    //if (KMimeType::sharedMimeInfoVersion() > KDE_MAKE_VERSION(0, 60, 0)) {
+-        QTest::newRow("mimetype with many patterns") << "application/vnd.wordperfect" << "*.wp;*.wp4;*.wp5;*.wp6;*.wpd;*.wpp" << "wp";
+-    //}
++    // The preferred suffix for image/jpeg is *.jpg, as per https://bugs.kde.org/show_bug.cgi?id=176737
++    QTest::newRow("jpeg") << "image/jpeg" << "*.jpe;*.jpg;*.jpeg" << "jpg";
++    QTest::newRow("mimetype with many patterns") << "application/vnd.wordperfect" << "*.wp;*.wp4;*.wp5;*.wp6;*.wpd;*.wpp" << "wp";
+     QTest::newRow("oasis text mimetype") << "application/vnd.oasis.opendocument.text" << "*.odt" << "odt";
+     QTest::newRow("oasis presentation mimetype") << "application/vnd.oasis.opendocument.presentation" << "*.odp" << "odp";
+     QTest::newRow("mimetype with multiple patterns") << "text/plain" << "*.asc;*.txt;*,v" << "txt";
+diff --git a/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp b/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
+index 3e58dd03cc..c8f82ef5d5 100644
+--- a/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
++++ b/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
+@@ -176,6 +176,8 @@ private Q_SLOTS:
+     void fromToVariantConversions_data();
+     void fromToVariantConversions();
+ 
++    void noLeakOnNameClash();
++
+ private:
+     QString testDataDir;
+ };
+@@ -3685,5 +3687,23 @@ void tst_QtJson::fromToVariantConversions()
+     }
+ }
+ 
++void tst_QtJson::noLeakOnNameClash()
++{
++    QJsonDocument doc = QJsonDocument::fromJson("{\"\":{\"\":0},\"\":0}");
++    QVERIFY(!doc.isNull());
++    const QJsonObject obj = doc.object();
++
++    // Removed the duplicate key.
++    QCOMPARE(obj.length(), 1);
++
++    // Retained the last of the duplicates.
++    const QJsonValue val = obj.begin().value();
++    QVERIFY(val.isDouble());
++    QCOMPARE(val.toDouble(), 0.0);
++
++    // It should not leak.
++    // In particular it should not forget to deref the container for the inner object.
++}
++
+ QTEST_MAIN(tst_QtJson)
+ #include "tst_qtjson.moc"
+diff --git a/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp b/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
+index a59b58d57f..241c3e84ac 100644
+--- a/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
++++ b/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
+@@ -63,6 +63,7 @@ private slots:
+     void isValidId_data();
+     void isValidId();
+     void malformed();
++    void serialize();
+     // Backend tests
+     void utcTest();
+     void icuTest();
+@@ -947,6 +948,33 @@ void tst_QTimeZone::malformed()
+         barf.offsetFromUtc(now);
+ }
+ 
++void tst_QTimeZone::serialize()
++{
++    int parts = 0;
++#ifndef QT_NO_DEBUG_STREAM
++    qDebug() << QTimeZone(); // to verify no crash
++    parts++;
++#endif
++#ifndef QT_NO_DATASTREAM
++    QByteArray blob;
++    {
++        QDataStream stream(&blob, QIODevice::WriteOnly);
++        stream << QTimeZone("Europe/Oslo") << QTimeZone(420) << QTimeZone() << qint64(-1);
++    }
++    QDataStream stream(&blob, QIODevice::ReadOnly);
++    QTimeZone invalid, offset, oslo;
++    qint64 minusone;
++    stream >> oslo >> offset >> invalid >> minusone;
++    QCOMPARE(oslo, QTimeZone("Europe/Oslo"));
++    QCOMPARE(offset, QTimeZone(420));
++    QVERIFY(!invalid.isValid());
++    QCOMPARE(minusone, qint64(-1));
++    parts++;
++#endif
++    if (!parts)
++        QSKIP("No serialization enabled");
++}
++
+ void tst_QTimeZone::utcTest()
+ {
+ #ifdef QT_BUILD_INTERNAL
+diff --git a/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp b/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
+index 05480c6dd2..70f4c75756 100644
+--- a/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
++++ b/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
+@@ -324,6 +324,13 @@ void tst_QDBusInterface::notValid()
+ 
+     QVERIFY(!interface.isValid());
+     QVERIFY(!QMetaObject::invokeMethod(&interface, "ListNames", Qt::DirectConnection));
++
++    // With a connection, but empty/null service and path specified
++    QDBusConnection con = QDBusConnection::sessionBus();
++    QVERIFY(con.isConnected());
++    QDBusInterface iface({}, {}, {}, con);
++    QVERIFY(!iface.isValid());
++    QVERIFY(!QMetaObject::invokeMethod(&interface, "ListNames", Qt::DirectConnection));
+ }
+ 
+ void tst_QDBusInterface::notValidDerived()
+diff --git a/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp b/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
+index 874468c954..04ceb4ab65 100644
+--- a/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
++++ b/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
+@@ -507,6 +507,10 @@ void tst_QKeySequence::toStringFromKeycode_data()
+     QTest::newRow("Ctrl+Alt+Num+Del") << QKeySequence(Qt::ControlModifier | Qt::AltModifier | Qt::KeypadModifier | Qt::Key_Delete) << "Ctrl+Alt+Num+Del";
+     QTest::newRow("Ctrl+Ins") << QKeySequence(Qt::ControlModifier | Qt::Key_Insert) << "Ctrl+Ins";
+     QTest::newRow("Ctrl+Num+Ins(1)") << QKeySequence(Qt::Key_Insert | Qt::KeypadModifier | Qt::ControlModifier) << "Ctrl+Num+Ins";
++    QTest::newRow("Ctrl") << QKeySequence(Qt::Key_Control) << "Control";
++    QTest::newRow("Alt") << QKeySequence(Qt::Key_Alt) << "Alt";
++    QTest::newRow("Shift") << QKeySequence(Qt::Key_Shift) << "Shift";
++    QTest::newRow("Meta") << QKeySequence(Qt::Key_Meta) << "Meta";
+ }
+ 
+ void tst_QKeySequence::toStringFromKeycode()
+diff --git a/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp b/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+index 15e0ecadaa..b4eca74283 100644
+--- a/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
++++ b/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+@@ -81,6 +81,8 @@ private slots:
+     void registerOpenTypePreferredNamesSystem();
+     void registerOpenTypePreferredNamesApplication();
+ 
++    void stretchRespected();
++
+ private:
+     QString m_ledFont;
+     QString m_testFont;
+@@ -355,6 +357,28 @@ static QString testString()
+     return QStringLiteral("foo bar");
+ }
+ 
++void tst_QFontDatabase::stretchRespected()
++{
++    int italicId = QFontDatabase::addApplicationFont(m_testFontItalic);
++    QVERIFY(italicId != -1);
++
++    QVERIFY(!QFontDatabase::applicationFontFamilies(italicId).isEmpty());
++
++    QString italicFontName = QFontDatabase::applicationFontFamilies(italicId).first();
++
++    QFont italicFont = QFontDatabase().font(italicFontName,
++                                            QString::fromLatin1("Italic"), 14);
++    QVERIFY(italicFont.italic());
++
++    QFont italicStretchedFont = italicFont;
++    italicStretchedFont.setStretch( 400 );
++
++    QVERIFY(QFontMetricsF(italicFont).horizontalAdvance(QStringLiteral("foobar")) <
++            QFontMetricsF(italicStretchedFont).horizontalAdvance(QStringLiteral("foobar")));
++
++    QFontDatabase::removeApplicationFont(italicId);
++}
++
+ void tst_QFontDatabase::condensedFontWidthNoFontMerging()
+ {
+     int regularFontId = QFontDatabase::addApplicationFont(m_testFont);
+diff --git a/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+index 3d4a094c43..b423e11a99 100644
+--- a/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
++++ b/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+@@ -281,6 +281,7 @@ private Q_SLOTS:
+     void ioGetFromFileSpecial();
+     void ioGetFromFile_data();
+     void ioGetFromFile();
++    void ioGetFromFileUrl();
+     void ioGetFromFtp_data();
+     void ioGetFromFtp();
+     void ioGetFromFtpWithReuse();
+@@ -3300,6 +3301,18 @@ void tst_QNetworkReply::ioGetFromFile()
+     QCOMPARE(reader.data, data);
+ }
+ 
++void tst_QNetworkReply::ioGetFromFileUrl()
++{
++    // This immediately fails on non-windows platforms:
++    QNetworkRequest request(QUrl("file://unc-server/some/path"));
++    QNetworkReplyPtr reply(manager.get(request));
++    QSignalSpy finishedSpy(reply.get(), &QNetworkReply::finished);
++    // QTBUG-105618: This would, on non-Windows platforms, never happen because the signal
++    // was emitted before the constructor finished, leaving no chance at all to connect to the
++    // signal
++    QVERIFY(finishedSpy.wait());
++}
++
+ void tst_QNetworkReply::ioGetFromFtp_data()
+ {
+     QTest::addColumn<QString>("fileName");
+diff --git a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
+index 069fa6b341..4cc4d9a5ea 100644
+--- a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
++++ b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
+@@ -1,75 +1,34 @@
+-Certificate:
+-    Data:
+-        Version: 3 (0x2)
+-        Serial Number: 0 (0x0)
+-        Signature Algorithm: sha1WithRSAEncryption
+-        Issuer: C=NO, ST=Oslo, L=Nydalen, O=Nokia Corporation and/or its subsidiary(-ies), OU=Development, CN=fluke.troll.no/emailAddress=ahanssen@trolltech.com
+-        Validity
+-            Not Before: Dec  4 01:10:32 2007 GMT
+-            Not After : Apr 21 01:10:32 2035 GMT
+-        Subject: C=NO, ST=Oslo, O=Nokia Corporation and/or its subsidiary(-ies), OU=Development, CN=fluke.troll.no
+-        Subject Public Key Info:
+-            Public Key Algorithm: rsaEncryption
+-            RSA Public Key: (1024 bit)
+-                Modulus (1024 bit):
+-                    00:a7:c8:a0:4a:c4:19:05:1b:66:ba:32:e2:d2:f1:
+-                    1c:6f:17:82:e4:39:2e:01:51:90:db:04:34:32:11:
+-                    21:c2:0d:6f:59:d8:53:90:54:3f:83:8f:a9:d3:b3:
+-                    d5:ee:1a:9b:80:ae:c3:25:c9:5e:a5:af:4b:60:05:
+-                    aa:a0:d1:91:01:1f:ca:04:83:e3:58:1c:99:32:45:
+-                    84:70:72:58:03:98:4a:63:8b:41:f5:08:49:d2:91:
+-                    02:60:6b:e4:64:fe:dd:a0:aa:74:08:e9:34:4c:91:
+-                    5f:12:3d:37:4d:54:2c:ad:7f:5b:98:60:36:02:8c:
+-                    3b:f6:45:f3:27:6a:9b:94:9d
+-                Exponent: 65537 (0x10001)
+-        X509v3 extensions:
+-            X509v3 Basic Constraints: 
+-                CA:FALSE
+-            Netscape Comment: 
+-                OpenSSL Generated Certificate
+-            X509v3 Subject Key Identifier: 
+-                21:85:04:3D:23:01:66:E5:F7:9F:1A:84:24:8A:AF:0A:79:F4:E5:AC
+-            X509v3 Authority Key Identifier: 
+-                DirName:/C=NO/ST=Oslo/L=Nydalen/O=Nokia Corporation and/or its subsidiary(-ies)/OU=Development/CN=fluke.troll.no/emailAddress=ahanssen@trolltech.com
+-                serial:8E:A8:B4:E8:91:B7:54:2E
+-
+-    Signature Algorithm: sha1WithRSAEncryption
+-        6d:57:5f:d1:05:43:f0:62:05:ec:2a:71:a5:dc:19:08:f2:c4:
+-        a6:bd:bb:25:d9:ca:89:01:0e:e4:cf:1f:c1:8c:c8:24:18:35:
+-        53:59:7b:c0:43:b4:32:e6:98:b2:a6:ef:15:05:0b:48:5f:e1:
+-        a0:0c:97:a9:a1:77:d8:35:18:30:bc:a9:8f:d3:b7:54:c7:f1:
+-        a9:9e:5d:e6:19:bf:f6:3c:5b:2b:d8:e4:3e:62:18:88:8b:d3:
+-        24:e1:40:9b:0c:e6:29:16:62:ab:ea:05:24:70:36:aa:55:93:
+-        ef:02:81:1b:23:10:a2:04:eb:56:95:75:fc:f8:94:b1:5d:42:
+-        c5:3f:36:44:85:5d:3a:2e:90:46:8a:a2:b9:6f:87:ae:0c:15:
+-        40:19:31:90:fc:3b:25:bb:ae:f1:66:13:0d:85:90:d9:49:34:
+-        8f:f2:5d:f9:7a:db:4d:5d:27:f6:76:9d:35:8c:06:a6:4c:a3:
+-        b1:b2:b6:6f:1d:d7:a3:00:fd:72:eb:9e:ea:44:a1:af:21:34:
+-        7d:c7:42:e2:49:91:19:8b:c0:ad:ba:82:80:a8:71:70:f4:35:
+-        31:91:63:84:20:95:e9:60:af:64:8b:cc:ff:3d:8a:76:74:3d:
+-        c8:55:6d:e4:8e:c3:2b:1c:e8:42:18:ae:9f:e6:6b:9c:34:06:
+-        ec:6a:f2:c3
+ -----BEGIN CERTIFICATE-----
+-MIIEEzCCAvugAwIBAgIBADANBgkqhkiG9w0BAQUFADCBnDELMAkGA1UEBhMCTk8x
+-DTALBgNVBAgTBE9zbG8xEDAOBgNVBAcTB055ZGFsZW4xFjAUBgNVBAoTDVRyb2xs
+-dGVjaCBBU0ExFDASBgNVBAsTC0RldmVsb3BtZW50MRcwFQYDVQQDEw5mbHVrZS50
+-cm9sbC5ubzElMCMGCSqGSIb3DQEJARYWYWhhbnNzZW5AdHJvbGx0ZWNoLmNvbTAe
+-Fw0wNzEyMDQwMTEwMzJaFw0zNTA0MjEwMTEwMzJaMGMxCzAJBgNVBAYTAk5PMQ0w
+-CwYDVQQIEwRPc2xvMRYwFAYDVQQKEw1Ucm9sbHRlY2ggQVNBMRQwEgYDVQQLEwtE
+-ZXZlbG9wbWVudDEXMBUGA1UEAxMOZmx1a2UudHJvbGwubm8wgZ8wDQYJKoZIhvcN
+-AQEBBQADgY0AMIGJAoGBAKfIoErEGQUbZroy4tLxHG8XguQ5LgFRkNsENDIRIcIN
+-b1nYU5BUP4OPqdOz1e4am4CuwyXJXqWvS2AFqqDRkQEfygSD41gcmTJFhHByWAOY
+-SmOLQfUISdKRAmBr5GT+3aCqdAjpNEyRXxI9N01ULK1/W5hgNgKMO/ZF8ydqm5Sd
+-AgMBAAGjggEaMIIBFjAJBgNVHRMEAjAAMCwGCWCGSAGG+EIBDQQfFh1PcGVuU1NM
+-IEdlbmVyYXRlZCBDZXJ0aWZpY2F0ZTAdBgNVHQ4EFgQUIYUEPSMBZuX3nxqEJIqv
+-Cnn05awwgbsGA1UdIwSBszCBsKGBoqSBnzCBnDELMAkGA1UEBhMCTk8xDTALBgNV
+-BAgTBE9zbG8xEDAOBgNVBAcTB055ZGFsZW4xFjAUBgNVBAoTDVRyb2xsdGVjaCBB
+-U0ExFDASBgNVBAsTC0RldmVsb3BtZW50MRcwFQYDVQQDEw5mbHVrZS50cm9sbC5u
+-bzElMCMGCSqGSIb3DQEJARYWYWhhbnNzZW5AdHJvbGx0ZWNoLmNvbYIJAI6otOiR
+-t1QuMA0GCSqGSIb3DQEBBQUAA4IBAQBtV1/RBUPwYgXsKnGl3BkI8sSmvbsl2cqJ
+-AQ7kzx/BjMgkGDVTWXvAQ7Qy5piypu8VBQtIX+GgDJepoXfYNRgwvKmP07dUx/Gp
+-nl3mGb/2PFsr2OQ+YhiIi9Mk4UCbDOYpFmKr6gUkcDaqVZPvAoEbIxCiBOtWlXX8
+-+JSxXULFPzZEhV06LpBGiqK5b4euDBVAGTGQ/Dslu67xZhMNhZDZSTSP8l35ettN
+-XSf2dp01jAamTKOxsrZvHdejAP1y657qRKGvITR9x0LiSZEZi8CtuoKAqHFw9DUx
+-kWOEIJXpYK9ki8z/PYp2dD3IVW3kjsMrHOhCGK6f5mucNAbsavLD
++MIIF6zCCA9OgAwIBAgIUfo9amJtJGWqWE6f+SkAO85zkGr4wDQYJKoZIhvcNAQEL
++BQAwgYMxCzAJBgNVBAYTAk5PMQ0wCwYDVQQIDARPc2xvMQ0wCwYDVQQHDARPc2xv
++MRcwFQYDVQQKDA5UaGUgUXQgQ29tcGFueTEMMAoGA1UECwwDUiZEMRIwEAYDVQQD
++DAlIMiBUZXN0ZXIxGzAZBgkqhkiG9w0BCQEWDG1pbmltaUBxdC5pbzAgFw0yMDEw
++MjYxMjAxMzFaGA8yMTIwMTAwMjEyMDEzMVowgYMxCzAJBgNVBAYTAk5PMQ0wCwYD
++VQQIDARPc2xvMQ0wCwYDVQQHDARPc2xvMRcwFQYDVQQKDA5UaGUgUXQgQ29tcGFu
++eTEMMAoGA1UECwwDUiZEMRIwEAYDVQQDDAlIMiBUZXN0ZXIxGzAZBgkqhkiG9w0B
++CQEWDG1pbmltaUBxdC5pbzCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIB
++AOiUp5+E4blouKH7q+rVNR8NoYX2XkBW+q+rpy1zu5ssRSzbqxAjDx9dkht7Qlnf
++VlDT00JvpOWdeuPon5915edQRsY4Unl6mKH29ra3OtUa1/yCJXsGVJTKCj7k4Bxb
++5mZzb/fTlZntMLdTIBMfUbw62FKir1WjKIcJ9fCoG8JaGeKVO4Rh5p0ezd4UUUId
++r1BXl5Nqdqy2vTMsEDnjOsD3egkv8I2SKN4O6n/C3wWYpMOWYZkGoZiKz7rJs/i/
++ez7bsV7JlwdzTlhpJzkcOSVFBP6JlEOxTNNxZ1wtKy7PtZGmsSSATq2e6+bw38Ae
++Op0XnzzqcGjtDDofBmT7OFzZWjS9VZS6+DOOe2QHWle1nCHcHyH4ku6IRlsr9xkR
++NAIlOfnvHHxqJUenoeaZ4oQDjCBKS1KXygJO/tL7BLTQVn/xK1EmPvKNnjzWk4tR
++PnibUhhs5635qpOU/YPqFBh1JjVruZbsWcDAhRcew0uxONXOa9E+4lttQ9ySYa1A
++LvWqJuAX7gu2BsBMLyqfm811YnA7CIFMyO+HlqmkLFfv5L/xIRAXR7l26YGO0VwX
++CGjMfz4NVPMMke4nB7qa9NkpXQBQKMms3Qzd5JW0Hy9Ruj5O8GPcFZmV0twjd1uJ
++PD/cAjkWLaXjdNsJ16QWc2nghQRS6HYqKRX6j+CXOxupAgMBAAGjUzBRMB0GA1Ud
++DgQWBBRSCOU58j9NJZkMamt623qyCrhN3TAfBgNVHSMEGDAWgBRSCOU58j9NJZkM
++amt623qyCrhN3TAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4ICAQCq
++q4jxsWeNDv5Nq14hJtF9HB+ZL64zcZtRjJP1YgNs0QppKICmjPOL2nIMGmI/jKrs
++0eGAL/9XXNVHPxm1OPOncvimMMmU6emZfpMdEtTfKP43+Pg9HgKRjLoQp406vGeQ
++8ki/mbBhrItVPgEm3tu2AFA02XTYi+YxCI9kRZLGkM3FbgtOuTLPl0Z9y+kiPc9F
++uCSC03anBEqv+vDSI8+wODymQ/IJ3Jyz1lxIRDfp4qAekmy0jU2c91VOHHEmOmqq
++kqygGFRdwbe99m9yP63r6q0b5K3X2UnJ6bns0hmTwThYwpVPXLU8jdaTddbMukN2
++/Ef96Tsw8nWOEOPMySHOTIPgwyZRp26b0kA9EmhLwOP401SxXVQCmSRmtwNagmtg
++jJKmZoYBN+//D45ibK8z6Q0oOm9P+Whf/uUXehcRxBxyV3xz7k0wKGQbHj/ddwcy
++IUoIN4lrAlib+lK170kTKN352PDmrpo2gmIzPEsfurKAIMSelDl6H+kih16BtZ8y
++Nz6fh9Soqrg3OSAware8pxV7k51crBMoPLN78KoRV8MFCK4K7Fddq4rRISq6hiXq
++r1nsjoEPuKM9huprmZVZe9t5YcDa2I+wb3IiE3uwpZbAdaLDyQ5n6F/qpsiIkZXn
++gtcF7oqpG5oYrwCcZ53y/ezUgUg7PlSz2XwAGvQtgg==
+ -----END CERTIFICATE-----
+diff --git a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
+index 9d1664d609..337ce541a6 100644
+--- a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
++++ b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
+@@ -1,15 +1,52 @@
+------BEGIN RSA PRIVATE KEY-----
+-MIICXAIBAAKBgQCnyKBKxBkFG2a6MuLS8RxvF4LkOS4BUZDbBDQyESHCDW9Z2FOQ
+-VD+Dj6nTs9XuGpuArsMlyV6lr0tgBaqg0ZEBH8oEg+NYHJkyRYRwclgDmEpji0H1
+-CEnSkQJga+Rk/t2gqnQI6TRMkV8SPTdNVCytf1uYYDYCjDv2RfMnapuUnQIDAQAB
+-AoGANFzLkanTeSGNFM0uttBipFT9F4a00dqHz6JnO7zXAT26I5r8sU1pqQBb6uLz
+-/+Qz5Zwk8RUAQcsMRgJetuPQUb0JZjF6Duv24hNazqXBCu7AZzUenjafwmKC/8ri
+-KpX3fTwqzfzi//FKGgbXQ80yykSSliDL3kn/drATxsLCgQECQQDXhEFWLJ0vVZ1s
+-1Ekf+3NITE+DR16X+LQ4W6vyEHAjTbaNWtcTKdAWLA2l6N4WAAPYSi6awm+zMxx4
+-VomVTsjdAkEAx0z+e7natLeFcrrq8pbU+wa6SAP1VfhQWKitxL1e7u/QO90NCpxE
+-oQYKzMkmmpOOFjQwEMAy1dvFMbm4LHlewQJAC/ksDBaUcQHHqjktCtrUb8rVjAyW
+-A8lscckeB2fEYyG5J6dJVaY4ClNOOs5yMDS2Afk1F6H/xKvtQ/5CzInA/QJATDub
+-K+BPU8jO9q+gpuIi3VIZdupssVGmCgObVCHLakG4uO04y9IyPhV9lA9tALtoIf4c
+-VIvv5fWGXBrZ48kZAQJBAJmVCdzQxd9LZI5vxijUCj5EI4e+x5DRqVUvyP8KCZrC
+-AiNyoDP85T+hBZaSXK3aYGpVwelyj3bvo1GrTNwNWLw=
+------END RSA PRIVATE KEY-----
++-----BEGIN PRIVATE KEY-----
++MIIJQgIBADANBgkqhkiG9w0BAQEFAASCCSwwggkoAgEAAoICAQDolKefhOG5aLih
+++6vq1TUfDaGF9l5AVvqvq6ctc7ubLEUs26sQIw8fXZIbe0JZ31ZQ09NCb6TlnXrj
++6J+fdeXnUEbGOFJ5epih9va2tzrVGtf8giV7BlSUygo+5OAcW+Zmc2/305WZ7TC3
++UyATH1G8OthSoq9VoyiHCfXwqBvCWhnilTuEYeadHs3eFFFCHa9QV5eTanastr0z
++LBA54zrA93oJL/CNkijeDup/wt8FmKTDlmGZBqGYis+6ybP4v3s+27FeyZcHc05Y
++aSc5HDklRQT+iZRDsUzTcWdcLSsuz7WRprEkgE6tnuvm8N/AHjqdF5886nBo7Qw6
++HwZk+zhc2Vo0vVWUuvgzjntkB1pXtZwh3B8h+JLuiEZbK/cZETQCJTn57xx8aiVH
++p6HmmeKEA4wgSktSl8oCTv7S+wS00FZ/8StRJj7yjZ481pOLUT54m1IYbOet+aqT
++lP2D6hQYdSY1a7mW7FnAwIUXHsNLsTjVzmvRPuJbbUPckmGtQC71qibgF+4LtgbA
++TC8qn5vNdWJwOwiBTMjvh5appCxX7+S/8SEQF0e5dumBjtFcFwhozH8+DVTzDJHu
++Jwe6mvTZKV0AUCjJrN0M3eSVtB8vUbo+TvBj3BWZldLcI3dbiTw/3AI5Fi2l43Tb
++CdekFnNp4IUEUuh2KikV+o/glzsbqQIDAQABAoICAFw1q6tr5I48vY7DF+rXsuLn
++5ZUWE1IQ6fzB4lr72nJv/9EEGnMgYzt9PpMUsD6vdCpBgS2C0+6RHArFzJtNA+RM
++iHLIG7K7702veyr/xBx/MwiSlMeMv/XpkFxVI6E6skMGG2s3AMXxKvJTy5CpRx+I
++eQFyLG+Ya1X2lgJes/q+/CpAHkOjCOpcLySQC5NZ74q734V7nSdmn+Zs3tYEh+O/
++eiuwTP/j5b38Te5vVTqDxTciJPmljmXLCwa0N100lWlbcpvw8qbqiTI2Jm3XCbUE
++AzHjW9vmrF3cRS1fXxKFGShw3SRqlkbxjfeWoi8qDPUBS4m8LOr8qG9Wo5Nfon0z
++zLP4bci3zHDvVcaaZrrsUBs/yZbg+Dgka1DmX7ekmeccr2yTdKDFgPupYUyxVbTl
++a9ZLJysjFD7rgBv1ZclHonLp6Vbm+ZoTqvteo4ikAy6L9RtBWJ23XEK34PkP/+c5
++2vWZaOrnjSeBHbFce8cdJSxqWpP+eSCI5I9XbDrYFIsQ/gqKgtzDKy2ihJ2Y8STL
++yO4hyFPFjxc+Gg4/P2PpmT5CY2ty44M0BWs+JGW96CJPrrplf2lmQUQJj5LZY66X
++Z/4C9L7ZYtKZ+bs5SvU46yWugAvQZX22Xm9xLXWyVXRdx3bj+3M3fDnF9di/zdbh
++CgLx7oWPNrXc7FCajnn9AoIBAQD5FMYwRpw9NWT9WDxQwx+cSI4Icbd88ByTW63S
++LzeRwZA0J9/SfwO+aBRupzc9GkGXCiZcGMw3AGsCtig8yFlw8E5KnzN7KlftDMnM
++9NUxxzlR8VwKyLnZfG7sDTl057ZlUujnqhmt/F8F7dIy7FVO1dE/8nngA+FYTCOG
++UZdGjwyBDlDM0JJdUWGY3xslutcpCDN5mzSTKjy9drMvImAshRawxRF6WBpn7vr2
++nC6vciqfx1Mzx1vyk0Jm0ilaydDdLMADjt/iL4Nkr0BEs4k+UzQiKDwp8gu7abQ1
++eBfxd9Iar4htQa2I1Ewl6P01G/q+ZYwgHhJ9RVn4AxQXefILAoIBAQDvCouORdQX
++C8wsyp7MwXlF/3NQeNN5/+B2mhbxrBOf7PmMCXLnkRWcjwJtzypWFqJ0sqai/2+0
++bqbMcjX5maT8stT2shl3zXe/Ejt2e3TBYpc1tyuses8Kb5BMU8hu6tTd3G2CMXpD
++dT6DVemJZCTtwj9aBNIxSizvlgMolJnCpzhPnlfHSI6E+g3m/LTTo3HwbjMSw/Uq
++irgjOpI2wSBB6LZPSgjvfcYPRyWUk16L4A5uSX0cADnovDFLa5/h0wJvN/OoCSQg
++rLCXG5E18EyL5Wc58BCY1ZvxmjG3lQtgPxYu2Jwc36R/y/JKlxW5suER5ZNpbbD4
++uOyTt2VxMQ2bAoIBAQC5+MzRFqdo/AjfL5Y5JrbfVTzXCTDa09xCGd16ZU60QTWN
+++4ed/r+o1sUKqUcRFB2MzEM/2DQBjQpZB/CbEWvWa1XJWXxypXbowveZU+QqOnmN
++uQvj8WLyA3o+PNF9e9QvauwCrHpn8VpxbtPWuaYoKnUFreFZZQxHhPGxRBIS2JOZ
++eDrT8ZaWnkCkh1AZp5smQ71LOprSlmKrg4jd1GjCVMxQR5N5KXbtyv0OTCZ/UFqK
++2aRBsMPyJgkaBChkZPLRcKwc+/wlQRx1fHQb14DNTApMxoXFO7eOwqmOkpAt9iyl
++SBIwoS0UUI5ab88+bBmXNvKcuFdNuQ4nowTJUn9pAoIBADMNkILBXSvS5DeIyuO2
++Sp1tkoZUV+5NfPY3sMDK3KIibaW/+t+EOBZo4L7tKQCb8vRzl21mmsfxfgRaPDbj
++3r3tv9g0b4YLxxBy52pFscj/soXRai17SS7UZwA2QK+XzgDYbDcLNC6mIsTQG4Gx
++dsWk3/zs3KuUSQaehmwrWK+fIUK38c1pLK8v7LoxrLkqxlHwZ04RthHw8KTthH7X
++Pnl1J0LF8CSeOyfWLSuPUfkT0GEzptnNHpEbaHfQM6R6eaGhVJPF6AZme4y6YYgg
++m2ihhSt1n0XVEWpHYWjxFy3mK2mz75unFC4LM+NEY2p2zuUQoCw7NjnY3QYrfCnx
++rRMCggEAXeXsMSLFjjyuoL7iKbAxo52HD/P0fBoy58LyRcwfNVr0lvYan4pYEx+o
++KijIh9K16PqXZXKMA9v003B+ulmF8bJ7SddCZ5NGvnFhUTDe4DdTKgp2RuwQ3Bsc
++3skPIDbhVETyOLCtys34USHrq8U/0DlGY3eLRfxw9GnbKxSBGa/KEu/qQLPNUo50
++7xHZDg7GKeC3kqNJeqKM9rkp0VzIGkEnaD9127LeNDmERDfftxJzFoC/THvUBLfU
++6Sus2ZYwRE8VFvKC30Q45t/c54X3IuhYvAuiCuTmyfE4ruyzyOwKzhUkeeLq1APX
++g0veFbyfzlJ0q8qzD/iffqqIa2ZSmQ==
++-----END PRIVATE KEY-----
+diff --git a/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp b/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
+index 7ba3715e13..752aa122f6 100644
+--- a/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
++++ b/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
+@@ -179,6 +179,7 @@ void tst_QAccessibilityLinux::initTestCase()
+     QVERIFY(!address.isEmpty());
+ 
+     m_window = new AccessibleTestWindow();
++    m_window->setObjectName("mainWindow"_L1);
+     m_window->show();
+ 
+     QVERIFY(QTest::qWaitForWindowExposed(m_window));
+@@ -236,8 +237,11 @@ bool hasState(QDBusInterface *interface, AtspiStateType state)
+ void tst_QAccessibilityLinux::testLabel()
+ {
+     QLabel *l = new QLabel(m_window);
++    l->setObjectName("theObjectName"_L1);
+     l->setText("Hello A11y");
+     m_window->addWidget(l);
++    auto a11yEmpty = new QLabel(m_window);
++    m_window->addWidget(l);
+ 
+     // Application
+     QCOMPARE(getParent(mainWindow), QLatin1String(ATSPI_DBUS_PATH_ROOT));
+@@ -249,6 +253,8 @@ void tst_QAccessibilityLinux::testLabel()
+     QCOMPARE(getChildren(labelInterface).count(), 0);
+     QCOMPARE(labelInterface->call(QDBus::Block, "GetRoleName").arguments().first().toString(), QLatin1String("label"));
+     QCOMPARE(labelInterface->call(QDBus::Block, "GetRole").arguments().first().toUInt(), 29u);
++    QCOMPARE(labelInterface->call(QDBus::Block, "GetAccessibleId").arguments().first().toString(),
++             QLatin1String("mainWindow.theObjectName"));
+     QCOMPARE(getParent(labelInterface), mainWindow->path());
+     QVERIFY(!hasState(labelInterface, ATSPI_STATE_EDITABLE));
+     QVERIFY(hasState(labelInterface, ATSPI_STATE_READ_ONLY));
+@@ -256,7 +262,12 @@ void tst_QAccessibilityLinux::testLabel()
+     l->setText("New text");
+     QCOMPARE(labelInterface->property("Name").toString(), l->text());
+ 
++    auto *a11yEmptyInterface = getInterface(children.at(1), "org.a11y.atspi.Accessible");
++    QCOMPARE(a11yEmptyInterface->call(QDBus::Block, "GetAccessibleId").arguments().first().toString(),
++             QLatin1String("mainWindow.QLabel"));
++
+     m_window->clearChildren();
++    delete a11yEmptyInterface;
+     delete labelInterface;
+ }
+ 
+diff --git a/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+index 76df61c892..6d6d65b791 100644
+--- a/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
++++ b/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2022 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the test suite of the Qt Toolkit.
+@@ -68,6 +68,8 @@ private slots:
+     void query_exec();
+     void execErrorRecovery_data() { generic_data(); }
+     void execErrorRecovery();
++    void prematureExec_data() { generic_data(); }
++    void prematureExec();
+     void first_data() { generic_data(); }
+     void first();
+     void next_data() { generic_data(); }
+@@ -2770,6 +2772,35 @@ void tst_QSqlQuery::execErrorRecovery()
+     QVERIFY_SQL( q, exec() );
+ }
+ 
++void tst_QSqlQuery::prematureExec()
++{
++    QFETCH(QString, dbName);
++    // We only want the engine name, for addDatabase():
++    int cut = dbName.indexOf(QChar('@'));
++    if (cut < 0)
++        QSKIP("Failed to parse database type out of name");
++    dbName.truncate(cut);
++    cut = dbName.indexOf(QChar('_'));
++    if (cut >= 0)
++        dbName = dbName.mid(cut + 1);
++
++    auto db = QSqlDatabase::addDatabase(dbName);
++    QSqlQuery q(db);
++
++    QTest::ignoreMessage(QtWarningMsg,
++                         "QSqlDatabasePrivate::removeDatabase: connection "
++                         "'qt_sql_default_connection' is still in use, all "
++                         "queries will cease to work.");
++    QTest::ignoreMessage(QtWarningMsg,
++                         "QSqlDatabasePrivate::addDatabase: duplicate connection name "
++                         "'qt_sql_default_connection', old connection removed.");
++    auto otherDb = QSqlDatabase::addDatabase(dbName);
++
++    QTest::ignoreMessage(QtWarningMsg, "QSqlQuery::exec: called before driver has been set up");
++    // QTBUG-100037: shouldn't crash !
++    QVERIFY(!q.exec("select stuff from TheVoid"));
++}
++
+ void tst_QSqlQuery::lastInsertId()
+ {
+     QFETCH( QString, dbName );
+diff --git a/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp b/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
+index 4aa3f8d60b..d2050a61aa 100644
+--- a/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
++++ b/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
+@@ -115,6 +115,10 @@ void tst_QAbstractItemModelTester::standardItemModelZeroColumns()
+     // QTBUG-92886
+     model.insertRows(0, 5);
+     model.removeRows(1, 2);
++
++    const QModelIndex parentIndex = model.index(0, 0);
++    model.insertRows(0, 5, parentIndex);
++    model.removeRows(1, 2, parentIndex);
+ }
+ 
+ void tst_QAbstractItemModelTester::testInsertThroughProxy()
+diff --git a/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json b/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
+index 12a4a22a19..ce518e78fb 100644
+--- a/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
++++ b/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
+@@ -668,50 +668,6 @@
+         "inputFile": "task192552.h",
+         "outputRevision": 67
+     },
+-    {
+-        "classes": [
+-            {
+-                "className": "InlineSlotsWithThrowDeclaration",
+-                "object": true,
+-                "qualifiedClassName": "InlineSlotsWithThrowDeclaration",
+-                "slots": [
+-                    {
+-                        "access": "public",
+-                        "name": "a",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "b",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "c",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "d",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "e",
+-                        "returnType": "void"
+-                    }
+-                ],
+-                "superClasses": [
+-                    {
+-                        "access": "public",
+-                        "name": "QObject"
+-                    }
+-                ]
+-            }
+-        ],
+-        "inputFile": "task189996.h",
+-        "outputRevision": 67
+-    },
+     {
+         "classes": [
+             {
+diff --git a/qtbase/tests/auto/tools/moc/moc.pro b/qtbase/tests/auto/tools/moc/moc.pro
+index c324b3a8cd..4aceb78dc0 100644
+--- a/qtbase/tests/auto/tools/moc/moc.pro
++++ b/qtbase/tests/auto/tools/moc/moc.pro
+@@ -15,7 +15,7 @@ cross_compile: DEFINES += MOC_CROSS_COMPILED
+ HEADERS += using-namespaces.h no-keywords.h task87883.h c-comments.h backslash-newlines.h oldstyle-casts.h \
+            slots-with-void-template.h qinvokable.h namespaced-flags.h trigraphs.h \
+            escapes-in-string-literals.h cstyle-enums.h qprivateslots.h gadgetwithnoenums.h \
+-           dir-in-include-path.h single_function_keyword.h task192552.h task189996.h \
++           dir-in-include-path.h single_function_keyword.h task192552.h \
+            task234909.h task240368.h pure-virtual-signals.h cxx11-enums.h \
+            cxx11-final-classes.h \
+            cxx11-explicit-override-control.h \
+diff --git a/qtbase/tests/auto/tools/moc/task189996.h b/qtbase/tests/auto/tools/moc/task189996.h
+deleted file mode 100644
+index f94a051b3a..0000000000
+--- a/qtbase/tests/auto/tools/moc/task189996.h
++++ /dev/null
+@@ -1,47 +0,0 @@
+-/****************************************************************************
+-**
+-** Copyright (C) 2016 The Qt Company Ltd.
+-** Contact: https://www.qt.io/licensing/
+-**
+-** This file is part of the test suite of the Qt Toolkit.
+-**
+-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+-** 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 General Public License Usage
+-** Alternatively, this file may be used under the terms of the GNU
+-** General Public License version 3 as published by the Free Software
+-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+-** 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-3.0.html.
+-**
+-** $QT_END_LICENSE$
+-**
+-****************************************************************************/
+-// inline functions can have throw declarations
+-
+-#ifndef TASK189996_H
+-#define TASK189996_H
+-
+-#include <QObject>
+-
+-class InlineSlotsWithThrowDeclaration : public QObject
+-{
+-    Q_OBJECT
+-
+-public slots:
+-    void a() throw() { }
+-    void b() const throw() { }
+-    void c() throw();
+-    void d() throw(int) { }
+-    void e() const throw(int,double) { }
+-};
+-
+-#endif
+diff --git a/qtbase/tests/auto/tools/moc/tst_moc.cpp b/qtbase/tests/auto/tools/moc/tst_moc.cpp
+index c716aead21..15dd9e41e5 100644
+--- a/qtbase/tests/auto/tools/moc/tst_moc.cpp
++++ b/qtbase/tests/auto/tools/moc/tst_moc.cpp
+@@ -631,7 +631,6 @@ public:
+ private slots:
+     void initTestCase();
+ 
+-    void slotWithException() throw(MyStruct);
+     void dontStripNamespaces();
+     void oldStyleCasts();
+     void warnOnExtraSignalSlotQualifiaction();
+@@ -673,7 +672,6 @@ private slots:
+     void templateGtGt();
+     void qprivateslots();
+     void qprivateproperties();
+-    void inlineSlotsWithThrowDeclaration();
+     void warnOnPropertyWithoutREAD();
+     void constructors();
+     void typenameWithUnsigned();
+@@ -784,12 +782,6 @@ void tst_Moc::initTestCase()
+ #endif
+ }
+ 
+-void tst_Moc::slotWithException() throw(MyStruct)
+-{
+-    // be happy
+-    QVERIFY(true);
+-}
+-
+ void tst_Moc::dontStripNamespaces()
+ {
+     Sender sender;
+@@ -824,7 +816,7 @@ void tst_Moc::oldStyleCasts()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-Wold-style-cast" << "-I" << "."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -894,7 +886,7 @@ void tst_Moc::inputFileNameWithDotsButNoExtension()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-I" << ".."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -1174,7 +1166,7 @@ void tst_Moc::ignoreOptionClashes()
+     QStringList gccArgs;
+     gccArgs << "-c" << "-x" << "c++" << "-I" << ".."
+          << "-I" << qtIncludePath << "-I" << includeDir << "-o" << "/dev/null"
+-         << "-fPIC" << "-std=c++11" <<  "-";
++         << "-fPIC" << "-std=c++1z" <<  "-";
+     proc.start("gcc", gccArgs);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -1593,21 +1585,6 @@ void tst_Moc::qprivateproperties()
+ 
+ }
+ 
+-#include "task189996.h"
+-
+-void InlineSlotsWithThrowDeclaration::c() throw() {}
+-
+-void tst_Moc::inlineSlotsWithThrowDeclaration()
+-{
+-    InlineSlotsWithThrowDeclaration tst;
+-    const QMetaObject *mobj = tst.metaObject();
+-    QVERIFY(mobj->indexOfSlot("a()") != -1);
+-    QVERIFY(mobj->indexOfSlot("b()") != -1);
+-    QVERIFY(mobj->indexOfSlot("c()") != -1);
+-    QVERIFY(mobj->indexOfSlot("d()") != -1);
+-    QVERIFY(mobj->indexOfSlot("e()") != -1);
+-}
+-
+ void tst_Moc::warnOnPropertyWithoutREAD()
+ {
+ #ifdef MOC_CROSS_COMPILED
+@@ -1869,7 +1846,7 @@ void tst_Moc::notifyError()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-I" << "."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+diff --git a/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+index c355ee9665..88c09de8e0 100644
+--- a/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
++++ b/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+@@ -251,6 +251,7 @@ private slots:
+     void testResetCachedSizeHint();
+     void statusTips();
+     void testRemovingColumnsViaLayoutChanged();
++    void testModelMovingColumns();
+ 
+ protected:
+     void setupTestData(bool use_reset_model = false);
+@@ -360,6 +361,12 @@ public:
+         endRemoveColumns();
+     }
+ 
++    void moveColumn(int from, int to)
++    {
++        beginMoveColumns(QModelIndex(), from, from, QModelIndex(), to);
++        endMoveColumns();
++    }
++
+     void cleanup()
+     {
+         emit layoutAboutToBeChanged();
+@@ -3627,5 +3634,18 @@ void tst_QHeaderView::testRemovingColumnsViaLayoutChanged()
+     // The main point of this test is that the section-size restoring code didn't go out of bounds.
+ }
+ 
++void tst_QHeaderView::testModelMovingColumns()
++{
++    QtTestModel model(10, 10);
++    QHeaderView hv(Qt::Horizontal);
++    hv.setModel(&model);
++    hv.resizeSections(QHeaderView::ResizeToContents);
++    hv.show();
++
++    QPersistentModelIndex index3 = model.index(0, 3);
++    model.moveColumn(3, 1);
++    QCOMPARE(index3.column(), 1);
++}
++
+ QTEST_MAIN(tst_QHeaderView)
+ #include "tst_qheaderview.moc"
+diff --git a/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+index 761357b252..06bb706074 100644
+--- a/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
++++ b/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+@@ -397,6 +397,7 @@ private slots:
+     void checkHeaderMinSize();
+ 
+     void resizeToContents();
++    void resizeToContentsSpans();
+ 
+     void tabFocus();
+     void bigModel();
+@@ -3721,6 +3722,70 @@ void tst_QTableView::resizeToContents()
+ 
+ }
+ 
++
++class SpanModel : public QAbstractTableModel
++{
++public:
++    SpanModel(bool sectionsMoved)
++        : _sectionsMoved(sectionsMoved)
++    {}
++    int columnCount(const QModelIndex & = {}) const override { return 2; }
++    int rowCount(const QModelIndex & = {}) const override { return 1; }
++    QVariant data(const QModelIndex &idx, int role = Qt::DisplayRole) const override
++    {
++        if (role != Qt::DisplayRole)
++            return QVariant();
++        const int col = _sectionsMoved ? 1 - idx.column() : idx.column();
++        if (col == 0)
++            return "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.";
++        return QVariant();
++    }
++private:
++    bool _sectionsMoved;
++};
++
++
++void tst_QTableView::resizeToContentsSpans()
++{
++    SpanModel model1(false);
++    SpanModel model2(true);
++    QTableView view1, view2, view3;
++    view1.setModel(&model1);
++    view2.setModel(&model2);
++    view2.horizontalHeader()->moveSection(0, 1);
++    view3.setModel(&model1);
++
++    view1.setSpan(0, 0, 1, 2);
++    view2.setSpan(0, 1, 1, 2);
++    view1.show();
++    view2.show();
++    view3.show();
++    QVERIFY(QTest::qWaitForWindowExposed(&view1));
++    QVERIFY(QTest::qWaitForWindowExposed(&view2));
++    QVERIFY(QTest::qWaitForWindowExposed(&view3));
++    view1.setColumnWidth(0, 100);
++    view1.setColumnWidth(1, 100);
++    view2.setColumnWidth(0, 100);
++    view2.setColumnWidth(1, 100);
++    view3.setColumnWidth(0, 200);
++
++    view1.resizeRowToContents(0);
++    view2.resizeRowToContents(0);
++    view3.resizeRowToContents(0);
++    QCOMPARE(view1.rowHeight(0), view3.rowHeight(0));
++    QCOMPARE(view2.rowHeight(0), view3.rowHeight(0));
++
++    view3.resizeColumnToContents(0);
++    view3.resizeRowToContents(0);
++    // height should be only 1 text line for easy testing
++    view1.setRowHeight(0, view3.verticalHeader()->sectionSize(0));
++    view2.setRowHeight(0, view3.verticalHeader()->sectionSize(0));
++    view1.resizeColumnToContents(0);
++    view2.resizeColumnToContents(1);
++    QCOMPARE(view1.columnWidth(0), view3.columnWidth(0) - view1.columnWidth(1));
++    QCOMPARE(view2.columnWidth(0), view3.columnWidth(0) - view2.columnWidth(1));
++}
++
+ QT_BEGIN_NAMESPACE
+ extern bool Q_WIDGETS_EXPORT qt_tab_all_widgets(); // qapplication.cpp
+ QT_END_NAMESPACE
+diff --git a/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+index a3b8ef78d8..4955cebd5d 100644
+--- a/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
++++ b/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+@@ -1498,7 +1498,7 @@ void tst_QApplication::desktopSettingsAware()
+     environment += QLatin1String("QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM=1");
+     testProcess.setEnvironment(environment);
+ #endif
+-    testProcess.start("desktopsettingsaware_helper");
++    testProcess.start("./desktopsettingsaware_helper");
+     QVERIFY2(testProcess.waitForStarted(),
+              qPrintable(QString::fromLatin1("Cannot start 'desktopsettingsaware_helper': %1").arg(testProcess.errorString())));
+     QVERIFY(testProcess.waitForFinished(10000));
+@@ -2452,7 +2452,7 @@ void tst_QApplication::qtbug_12673()
+ #if QT_CONFIG(process)
+     QProcess testProcess;
+     QStringList arguments;
+-    testProcess.start("modal_helper", arguments);
++    testProcess.start("./modal_helper", arguments);
+     QVERIFY2(testProcess.waitForStarted(),
+              qPrintable(QString::fromLatin1("Cannot start 'modal_helper': %1").arg(testProcess.errorString())));
+     QVERIFY(testProcess.waitForFinished(20000));
+diff --git a/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp b/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
+index eb108a40de..dca5528c1b 100644
+--- a/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
+@@ -41,6 +41,7 @@
+ 
+ #include <private/qguiapplication_p.h>
+ #include <qpa/qplatformintegration.h>
++#include <qpa/qplatformtheme.h>
+ 
+ class tst_QAbstractButton : public QObject
+ {
+@@ -76,6 +77,8 @@ private slots:
+     void keyNavigation();
+ #endif
+ 
++    void buttonPressKeys();
++
+ protected slots:
+     void onClicked();
+     void onToggled( bool on );
+@@ -269,7 +272,13 @@ void tst_QAbstractButton::setAutoRepeat()
+         QCOMPARE(press_count, click_count);
+         QVERIFY(click_count > 1);
+         break;
+-    case 4:
++    case 4: {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(Qt::Key_Enter)) {
++            QSKIP("platform theme has Key_Enter in ButtonPressKeys");
++        }
+         // check that pressing ENTER has no effect when autorepeat is false
+         testWidget->setDown( false );
+         testWidget->setAutoRepeat( false );
+@@ -286,7 +295,14 @@ void tst_QAbstractButton::setAutoRepeat()
+ 
+         QVERIFY( click_count == 0 );
+         break;
+-    case 5:
++    }
++    case 5: {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(Qt::Key_Enter)) {
++            QSKIP("platform theme has Key_Enter in ButtonPressKeys");
++        }
+         // check that pressing ENTER has no effect when autorepeat is true
+         testWidget->setDown( false );
+         testWidget->setAutoRepeat( true );
+@@ -304,6 +320,7 @@ void tst_QAbstractButton::setAutoRepeat()
+ 
+         QVERIFY( click_count == 0 );
+         break;
++    }
+     case 6:
+         // verify autorepeat is off by default.
+         MyButton tmp( 0);
+@@ -651,5 +668,16 @@ void tst_QAbstractButton::keyNavigation()
+ }
+ #endif
+ 
++void tst_QAbstractButton::buttonPressKeys()
++{
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(testWidget, buttonPressKeys[i]);
++        QCOMPARE(click_count, i + 1);
++    }
++}
++
+ QTEST_MAIN(tst_QAbstractButton)
+ #include "tst_qabstractbutton.moc"
+diff --git a/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+index 32437050f5..46b5af6d63 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+@@ -168,6 +168,7 @@ private slots:
+     void checkMenuItemPosWhenStyleSheetIsSet();
+     void checkEmbeddedLineEditWhenStyleSheetIsSet();
+     void propagateStyleChanges();
++    void buttonPressKeys();
+ 
+ private:
+     PlatformInputContext m_platformInputContext;
+@@ -1682,6 +1683,16 @@ void tst_QComboBox::setModel()
+     QCOMPARE(box.rootModelIndex(), rootModelIndex);
+     box.setModel(box.model());
+     QCOMPARE(box.rootModelIndex(), rootModelIndex);
++
++    // check that setting the same model as the completer's doesn't crash
++    QCompleter *completer = new QCompleter(&box);
++    box.setEditable(true);
++    box.setCompleter(completer);
++    auto *listModel = new QStringListModel({ "one", "two" }, completer);
++    completer->setModel(listModel);
++    QCOMPARE(listModel->rowCount(), 2); // make sure it wasn't deleted
++    box.setModel(listModel);
++    QCOMPARE(listModel->rowCount(), 2); // make sure it wasn't deleted
+ }
+ 
+ void tst_QComboBox::setCustomModelAndView()
+@@ -3632,5 +3643,24 @@ void tst_QComboBox::propagateStyleChanges()
+     QVERIFY(frameStyle.inquired);
+ }
+ 
++void tst_QComboBox::buttonPressKeys()
++{
++    QComboBox comboBox;
++    comboBox.setEditable(false);
++    comboBox.addItem(QString::number(1));
++    comboBox.addItem(QString::number(2));
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(&comboBox, buttonPressKeys[i]);
++        // On some platforms, a window will not be immediately visible,
++        // but take some event-loop iterations to complete.
++        // Using QTRY_VERIFY to deal with that.
++        QTRY_VERIFY(comboBox.view()->isVisible());
++        comboBox.hidePopup();
++    }
++}
++
+ QTEST_MAIN(tst_QComboBox)
+ #include "tst_qcombobox.moc"
+diff --git a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
+index be3cfcd104..c228fdfcca 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
++++ b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qcommandlinkbutton
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qcommandlinkbutton.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
+index 0044d33c66..4cf06296e4 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
+@@ -40,6 +40,9 @@
+ #include <QGridLayout>
+ #include <QPainter>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ class tst_QCommandLinkButton : public QObject
+ {
+     Q_OBJECT
+@@ -223,6 +226,13 @@ void tst_QCommandLinkButton::setAutoRepeat()
+     // check that pressing ENTER has no effect
+     resetCounters();
+     testWidget->setDown( false );
++    // Skip after reset if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
+     testWidget->setAutoRepeat( false );
+     QTest::keyPress( testWidget, Qt::Key_Enter );
+ 
+@@ -255,6 +265,14 @@ void tst_QCommandLinkButton::pressed()
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+ 
++    // Skip if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
++
+     QTest::keyPress( testWidget,Qt::Key_Enter );
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+diff --git a/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro b/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
+index 4a5e76ff65..a235fa1fac 100644
+--- a/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
++++ b/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qgroupbox
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qgroupbox.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp b/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
+index 4fb5d262ca..d8d7562b73 100644
+--- a/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
+@@ -35,6 +35,9 @@
+ #include <QRadioButton>
+ #include <QDialog>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ #include "qgroupbox.h"
+ 
+ class tst_QGroupBox : public QObject
+@@ -69,6 +72,7 @@ private slots:
+     void propagateFocus();
+     void task_QTBUG_19170_ignoreMouseReleaseEvent();
+     void task_QTBUG_15519_propagateMouseEvents();
++    void buttonPressKeys();
+ 
+ private:
+     bool checked;
+@@ -610,6 +614,20 @@ void tst_QGroupBox::task_QTBUG_15519_propagateMouseEvents()
+     QCOMPARE(parent.mouseMoved, true);
+ }
+ 
++void tst_QGroupBox::buttonPressKeys()
++{
++    QGroupBox groupBox;
++    groupBox.setCheckable(true);
++    QSignalSpy clickedSpy(&groupBox, &QGroupBox::clicked);
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(&groupBox, buttonPressKeys[i]);
++        QCOMPARE(clickedSpy.length(), i + 1);
++    }
++}
++
+ void tst_QGroupBox::sendMouseMoveEvent(QWidget *widget, const QPoint &localPos)
+ {
+     // Send a MouseMove event without actually moving the pointer
+diff --git a/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro b/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
+index 353ad06ca2..e55f6148f2 100644
+--- a/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
++++ b/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qpushbutton
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qpushbutton.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp b/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
+index e818514a79..4043e9326a 100644
+--- a/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
+@@ -41,6 +41,9 @@
+ #include <QStyleFactory>
+ #include <QTabWidget>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ class tst_QPushButton : public QObject
+ {
+ Q_OBJECT
+@@ -212,6 +215,13 @@ void tst_QPushButton::autoRepeat()
+     // check that pressing ENTER has no effect
+     resetCounters();
+     testWidget->setDown( false );
++    // Skip after reset if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
+     testWidget->setAutoRepeat( false );
+     QTest::keyPress( testWidget, Qt::Key_Enter );
+ 
+@@ -247,6 +257,14 @@ void tst_QPushButton::pressed()
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+ 
++    // Skip if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
++
+     QTest::keyPress( testWidget,Qt::Key_Enter );
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+diff --git a/qtbase/tests/manual/rhi/cubemap_render/buildshader.bat b/qtbase/tests/manual/rhi/cubemap_render/buildshader.bat
+old mode 100755
+new mode 100644
+Submodule qtconnectivity e957d481..056294c0:
+diff --git a/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp b/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
+index e2635fae..a8b8e3b9 100644
+--- a/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
++++ b/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
+@@ -563,9 +563,11 @@ void HciManager::handleHciAclPacket(const quint8 *data, int size)
+ 
+ void HciManager::handleLeMetaEvent(const quint8 *data)
+ {
+-    // Spec v4.2, Vol 2, part E, 7.7.65ff
++    // Spec v5.3, Vol 4, part E, 7.7.65.*
+     switch (*data) {
+-    case 0x1: {
++    case 0x1: // HCI_LE_Connection_Complete
++    case 0xA: // HCI_LE_Enhanced_Connection_Complete
++    {
+         const quint16 handle = bt_get_le16(data + 2);
+         emit connectionComplete(handle);
+         break;
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp b/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
+index 6a93143b..4a18cfc7 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
+@@ -320,7 +320,10 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_finishSdpScan(QBluetoothServiceD
+             for (const QBluetoothUuid &id : serviceClassUuids) {
+                 if (id.minimumSize() == 16) {
+                     serviceInfo.setServiceUuid(id);
+-                    serviceInfo.setServiceName(QBluetoothServiceDiscoveryAgent::tr("Custom Service"));
++                    if (serviceInfo.serviceName().isEmpty()) {
++                        serviceInfo.setServiceName(
++                                    QBluetoothServiceDiscoveryAgent::tr("Custom Service"));
++                    }
+                     QBluetoothServiceInfo::Sequence modSeq =
+                             serviceInfo.attribute(QBluetoothServiceInfo::ServiceClassIds).value<QBluetoothServiceInfo::Sequence>();
+                     modSeq.removeOne(QVariant::fromValue(id));
+@@ -334,8 +337,10 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_finishSdpScan(QBluetoothServiceD
+                 qCDebug(QT_BT_BLUEZ) << "Discovered services" << discoveredDevices.at(0).address().toString()
+                                      << serviceInfo.serviceName() << serviceInfo.serviceUuid()
+                                      << ">>>" << serviceInfo.serviceClassUuids();
+-
+-                emit q->serviceDiscovered(serviceInfo);
++                // Use queued connection to allow us finish the service looping; the application
++                // might call stop() when it has detected the service-of-interest.
++                QMetaObject::invokeMethod(q, "serviceDiscovered", Qt::QueuedConnection,
++                                          Q_ARG(QBluetoothServiceInfo, serviceInfo));
+             }
+         }
+     }
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp b/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
+index e4d85447..aadd4755 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
+@@ -593,7 +593,7 @@ void QBluetoothSocket::setSocketState(QBluetoothSocket::SocketState state)
+ bool QBluetoothSocket::canReadLine() const
+ {
+     Q_D(const QBluetoothSocketBase);
+-    return d->canReadLine();
++    return d->canReadLine() || QIODevice::canReadLine();
+ }
+ 
+ /*!
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp b/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
+index 084aa958..d6aa17a7 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
+@@ -284,6 +284,10 @@ void QBluetoothSocketPrivateBluezDBus::connectToService(
+         return;
+     }
+ 
++    if (service.socketProtocol() != QBluetoothServiceInfo::Protocol::UnknownProtocol)
++        socketType = service.socketProtocol();
++    qCDebug(QT_BT_BLUEZ) << "Socket protocol used:" << socketType;
++
+     connectToService(service.device().address(), targetService, openMode);
+ }
+ 
+diff --git a/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp b/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
+index 05bc1a0f..a7b5ef1f 100644
+--- a/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
++++ b/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
+@@ -142,7 +142,7 @@ void tst_QBluetoothSocket::initTestCase()
+     qDebug() << "Starting discovery";
+ 
+     sda->setUuidFilter(QBluetoothUuid(QString(TEST_SERVICE_UUID)));
+-    sda->start(QBluetoothServiceDiscoveryAgent::MinimalDiscovery);
++    sda->start(QBluetoothServiceDiscoveryAgent::FullDiscovery);
+ 
+     for (int connectTime = MaxConnectTime; !done_discovery && connectTime > 0; connectTime -= 1000)
+         QTest::qWait(1000);
+Submodule qtdeclarative f5701f0d..8defe7bf:
+diff --git a/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h b/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
+index b65b994d6c..15a8cd6878 100644
+--- a/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
++++ b/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
+@@ -86,7 +86,7 @@ public:
+         if (QTypeInfo<T>::isComplex) {
+             for (int i = 0; i < count; ++i)
+                 new (data + i) T(vector.at(i));
+-        } else {
++        } else if (count) {
+             memcpy(data, static_cast<const void*>(vector.constData()), count * sizeof(T));
+         }
+     }
+diff --git a/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp b/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
+index e57cdd8278..94613598af 100644
+--- a/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
++++ b/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
+@@ -1145,8 +1145,7 @@ void Heap::QObjectWrapper::markObjects(Heap::Base *that, QV4::MarkStack *markSta
+ void QObjectWrapper::destroyObject(bool lastCall)
+ {
+     Heap::QObjectWrapper *h = d();
+-    if (!h->internalClass)
+-        return; // destroyObject already got called
++    Q_ASSERT(h->internalClass);
+ 
+     if (h->object()) {
+         QQmlData *ddata = QQmlData::get(h->object(), false);
+@@ -1176,7 +1175,7 @@ void QObjectWrapper::destroyObject(bool lastCall)
+         }
+     }
+ 
+-    h->~Data();
++    h->destroy();
+ }
+ 
+ 
+diff --git a/qtdeclarative/src/qml/memory/qv4mm.cpp b/qtdeclarative/src/qml/memory/qv4mm.cpp
+index 06caf04e5a..da149a67c4 100644
+--- a/qtdeclarative/src/qml/memory/qv4mm.cpp
++++ b/qtdeclarative/src/qml/memory/qv4mm.cpp
+@@ -981,7 +981,7 @@ void MemoryManager::sweep(bool lastSweep, ClassDestroyStatsCallback classCountPt
+ 
+     if (MultiplyWrappedQObjectMap *multiplyWrappedQObjects = engine->m_multiplyWrappedQObjects) {
+         for (MultiplyWrappedQObjectMap::Iterator it = multiplyWrappedQObjects->begin(); it != multiplyWrappedQObjects->end();) {
+-            if (!it.value().isNullOrUndefined())
++            if (it.value().isNullOrUndefined())
+                 it = multiplyWrappedQObjects->erase(it);
+             else
+                 ++it;
+diff --git a/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp b/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
+index 2079a8ed04..a577cb2351 100644
+--- a/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
++++ b/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
+@@ -389,6 +389,12 @@ void QQmlDelegateModelPrivate::connectToAbstractItemModel()
+                       q,  QQmlDelegateModel, SLOT(_q_rowsRemoved(QModelIndex,int,int)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
+                       q,  QQmlDelegateModel, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsInserted(QModelIndex,int,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsInserted(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsRemoved(QModelIndex,int,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsRemoved(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsMoved(QModelIndex,int,int,QModelIndex,int)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
+                       q, QQmlDelegateModel, SLOT(_q_dataChanged(QModelIndex,QModelIndex,QVector<int>)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
+@@ -413,6 +419,12 @@ void QQmlDelegateModelPrivate::disconnectFromAbstractItemModel()
+                         q, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int)));
+     QObject::disconnect(aim, SIGNAL(rowsRemoved(QModelIndex,int,int)),
+                         q, SLOT(_q_rowsRemoved(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsInserted(QModelIndex,int,int)), q,
++                        SLOT(_q_columnsInserted(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsRemoved(QModelIndex,int,int)), q,
++                        SLOT(_q_columnsRemoved(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)), q,
++                        SLOT(_q_columnsMoved(QModelIndex,int,int,QModelIndex,int)));
+     QObject::disconnect(aim, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
+                         q, SLOT(_q_dataChanged(QModelIndex,QModelIndex,QVector<int>)));
+     QObject::disconnect(aim, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
+@@ -1973,6 +1985,38 @@ void QQmlDelegateModel::_q_rowsMoved(
+     }
+ }
+ 
++void QQmlDelegateModel::_q_columnsInserted(const QModelIndex &parent, int begin, int end)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if (parent == d->m_adaptorModel.rootIndex && begin == 0) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
++void QQmlDelegateModel::_q_columnsRemoved(const QModelIndex &parent, int begin, int end)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if (parent == d->m_adaptorModel.rootIndex && begin == 0) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
++void QQmlDelegateModel::_q_columnsMoved(const QModelIndex &parent, int start, int end,
++                                        const QModelIndex &destination, int column)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if ((parent == d->m_adaptorModel.rootIndex && start == 0)
++        || (destination == d->m_adaptorModel.rootIndex && column == 0)) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
+ void QQmlDelegateModel::_q_dataChanged(const QModelIndex &begin, const QModelIndex &end, const QVector<int> &roles)
+ {
+     Q_D(QQmlDelegateModel);
+diff --git a/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h b/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
+index 8aab4badca..d140bfbaaf 100644
+--- a/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
++++ b/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
+@@ -152,6 +152,9 @@ private Q_SLOTS:
+     void _q_itemsMoved(int from, int to, int count);
+     void _q_modelReset();
+     void _q_rowsInserted(const QModelIndex &,int,int);
++    void _q_columnsInserted(const QModelIndex &, int, int);
++    void _q_columnsRemoved(const QModelIndex &, int, int);
++    void _q_columnsMoved(const QModelIndex &, int, int, const QModelIndex &, int);
+     void _q_rowsAboutToBeRemoved(const QModelIndex &parent, int begin, int end);
+     void _q_rowsRemoved(const QModelIndex &,int,int);
+     void _q_rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int);
+diff --git a/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp b/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
+index 85719fdc80..78e2ab302c 100644
+--- a/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
++++ b/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
+@@ -46,6 +46,7 @@
+ #include "QtQuick/private/qquicktextinput_p.h"
+ #include "QtQuick/private/qquickaccessibleattached_p.h"
+ #include "QtQuick/qquicktextdocument.h"
++#include "QtQuick/qquickrendercontrol.h"
+ QT_BEGIN_NAMESPACE
+ 
+ #if QT_CONFIG(accessibility)
+@@ -57,7 +58,19 @@ QAccessibleQuickItem::QAccessibleQuickItem(QQuickItem *item)
+ 
+ QWindow *QAccessibleQuickItem::window() const
+ {
+-    return item()->window();
++    QQuickWindow *window = item()->window();
++
++    // For QQuickWidget the above window will be the offscreen QQuickWindow,
++    // which is not a part of the accessibility tree. Detect this case and
++    // return the window for the QQuickWidget instead.
++    if (window && !window->handle()) {
++        if (QQuickRenderControl *renderControl = QQuickWindowPrivate::get(window)->renderControl) {
++            if (QWindow *renderWindow = renderControl->renderWindow(nullptr))
++                return renderWindow;
++        }
++    }
++
++    return window;
+ }
+ 
+ int QAccessibleQuickItem::childCount() const
+@@ -113,19 +126,15 @@ QAccessibleInterface *QAccessibleQuickItem::childAt(int x, int y) const
+ QAccessibleInterface *QAccessibleQuickItem::parent() const
+ {
+     QQuickItem *parent = item()->parentItem();
+-    QQuickWindow *window = item()->window();
+-    QQuickItem *ci = window ? window->contentItem() : nullptr;
++    QQuickWindow *itemWindow = item()->window();
++    QQuickItem *ci = itemWindow ? itemWindow->contentItem() : nullptr;
+     while (parent && !QQuickItemPrivate::get(parent)->isAccessible && parent != ci)
+         parent = parent->parentItem();
+ 
+     if (parent) {
+         if (parent == ci) {
+-            // Jump out to the scene widget if the parent is the root item.
+-            // There are two root items, QQuickWindow::rootItem and
+-            // QQuickView::declarativeRoot. The former is the true root item,
+-            // but is not a part of the accessibility tree. Check if we hit
+-            // it here and return an interface for the scene instead.
+-            return QAccessible::queryAccessibleInterface(window);
++            // Jump out to the window if the parent is the root item
++            return QAccessible::queryAccessibleInterface(window());
+         } else {
+             while (parent && !parent->d_func()->isAccessible)
+                 parent = parent->parentItem();
+@@ -188,7 +197,7 @@ QAccessible::State QAccessibleQuickItem::state() const
+     QRect viewRect_ = viewRect();
+     QRect itemRect = rect();
+ 
+-    if (viewRect_.isNull() || itemRect.isNull() || !item()->window() || !item()->window()->isVisible() ||!item()->isVisible() || qFuzzyIsNull(item()->opacity()))
++    if (viewRect_.isNull() || itemRect.isNull() || !window() || !window()->isVisible() ||!item()->isVisible() || qFuzzyIsNull(item()->opacity()))
+         state.invisible = true;
+     if (!viewRect_.intersects(itemRect))
+         state.offscreen = true;
+@@ -201,6 +210,10 @@ QAccessible::State QAccessibleQuickItem::state() const
+     if (role() == QAccessible::EditableText)
+         if (auto ti = qobject_cast<QQuickTextInput *>(item()))
+             state.passwordEdit = ti->echoMode() != QQuickTextInput::Normal;
++    if (!item()->isEnabled()) {
++        state.focusable = false;
++        state.disabled = true;
++    }
+     return state;
+ }
+ 
+diff --git a/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h b/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
+index 39ffcaf39c..8baa01330c 100644
+--- a/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
++++ b/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
+@@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE
+ 
+ #if QT_CONFIG(accessibility)
+ 
+-class QAccessibleQuickWindow : public QAccessibleObject
++class Q_QUICK_EXPORT QAccessibleQuickWindow : public QAccessibleObject
+ {
+ public:
+     QAccessibleQuickWindow(QQuickWindow *object);
+diff --git a/qtdeclarative/src/quick/items/qquickdrag.cpp b/qtdeclarative/src/quick/items/qquickdrag.cpp
+index 8321fcfeed..383078b3b9 100644
+--- a/qtdeclarative/src/quick/items/qquickdrag.cpp
++++ b/qtdeclarative/src/quick/items/qquickdrag.cpp
+@@ -481,7 +481,9 @@ void QQuickDragAttached::setKeys(const QStringList &keys)
+     \qmlattachedproperty stringlist QtQuick::Drag::mimeData
+     \since 5.2
+ 
+-    This property holds a map of mimeData that is used during startDrag.
++    This property holds a map from mime type to data that is used during startDrag.
++    The mime data needs to be a \c string, or an \c ArrayBuffer with the data encoded
++    according to the mime type.
+ */
+ 
+ QVariantMap QQuickDragAttached::mimeData() const
+@@ -766,8 +768,12 @@ Qt::DropAction QQuickDragAttachedPrivate::startDrag(Qt::DropActions supportedAct
+     QDrag *drag = new QDrag(source ? source : q);
+     QMimeData *mimeData = new QMimeData();
+ 
+-    for (auto it = externalMimeData.cbegin(), end = externalMimeData.cend(); it != end; ++it)
+-        mimeData->setData(it.key(), it.value().toString().toUtf8());
++    for (auto it = externalMimeData.cbegin(), end = externalMimeData.cend(); it != end; ++it) {
++        if (static_cast<QMetaType::Type>(it.value().type()) == QMetaType::QByteArray)
++            mimeData->setData(it.key(), it.value().toByteArray());
++        else
++            mimeData->setData(it.key(), it.value().toString().toUtf8());
++    }
+ 
+     drag->setMimeData(mimeData);
+     if (pixmapLoader.isReady()) {
+diff --git a/qtdeclarative/src/quick/items/qquickitem.cpp b/qtdeclarative/src/quick/items/qquickitem.cpp
+index 75f1457816..dec0ae19ae 100644
+--- a/qtdeclarative/src/quick/items/qquickitem.cpp
++++ b/qtdeclarative/src/quick/items/qquickitem.cpp
+@@ -59,6 +59,7 @@
+ #include <QtCore/private/qnumeric_p.h>
+ #include <QtGui/qpa/qplatformtheme.h>
+ #include <QtCore/qloggingcategory.h>
++#include <QtCore/private/qduplicatetracker_p.h>
+ 
+ #include <private/qqmlglobal_p.h>
+ #include <private/qqmlengine_p.h>
+@@ -2326,6 +2327,7 @@ QQuickItem::QQuickItem(QQuickItemPrivate &dd, QQuickItem *parent)
+ QQuickItem::~QQuickItem()
+ {
+     Q_D(QQuickItem);
++    d->inDestructor = true;
+ 
+     if (d->windowRefCount > 1)
+         d->windowRefCount = 1; // Make sure window is set to null in next call to derefWindow().
+@@ -2526,6 +2528,7 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo
+     QQuickItem *current = item;
+     qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: startItem:" << startItem;
+     qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: firstFromItem:" << firstFromItem;
++    QDuplicateTracker<QQuickItem *> cycleDetector;
+     do {
+         qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: current:" << current;
+         qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: from:" << from;
+@@ -2592,7 +2595,10 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo
+         // traversed all of the chain (by compare the [current] item with [startItem])
+         // Since the [startItem] might be promoted to its parent if it is invisible,
+         // we still have to check [current] item with original start item
+-        if ((current == startItem || current == originalStartItem) && from == firstFromItem) {
++        // We might also run into a cycle before we reach firstFromItem again
++        // but note that we have to ignore current if we are meant to skip it
++        if (((current == startItem || current == originalStartItem) && from == firstFromItem) ||
++                (!skip && cycleDetector.hasSeen(current))) {
+             // wrapped around, avoid endless loops
+             if (item == contentItem) {
+                 qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: looped, return contentItem";
+@@ -2689,9 +2695,8 @@ void QQuickItem::setParentItem(QQuickItem *parentItem)
+ 
+         const bool wasVisible = isVisible();
+         op->removeChild(this);
+-        if (wasVisible) {
++        if (wasVisible && !op->inDestructor)
+             emit oldParentItem->visibleChildrenChanged();
+-        }
+     } else if (d->window) {
+         QQuickWindowPrivate::get(d->window)->parentlessItems.remove(this);
+     }
+@@ -2768,8 +2773,9 @@ void QQuickItem::setParentItem(QQuickItem *parentItem)
+ 
+     d->itemChange(ItemParentHasChanged, d->parentItem);
+ 
+-    emit parentChanged(d->parentItem);
+-    if (isVisible() && d->parentItem)
++    if (!d->inDestructor)
++        emit parentChanged(d->parentItem);
++    if (isVisible() && d->parentItem && !QQuickItemPrivate::get(d->parentItem)->inDestructor)
+         emit d->parentItem->visibleChildrenChanged();
+ }
+ 
+@@ -2965,7 +2971,8 @@ void QQuickItemPrivate::removeChild(QQuickItem *child)
+ 
+     itemChange(QQuickItem::ItemChildRemovedChange, child);
+ 
+-    emit q->childrenChanged();
++    if (!inDestructor)
++        emit q->childrenChanged();
+ }
+ 
+ void QQuickItemPrivate::refWindow(QQuickWindow *c)
+@@ -3194,6 +3201,7 @@ QQuickItemPrivate::QQuickItemPrivate()
+     , touchEnabled(false)
+ #endif
+     , hasCursorHandler(false)
++    , inDestructor(false)
+     , dirtyAttributes(0)
+     , nextDirtyItem(nullptr)
+     , prevDirtyItem(nullptr)
+@@ -5120,6 +5128,13 @@ void QQuickItem::componentComplete()
+         d->addToDirtyList();
+         QQuickWindowPrivate::get(d->window)->dirtyItem(this);
+     }
++
++#if QT_CONFIG(accessibility)
++    if (d->isAccessible && d->effectiveVisible) {
++        QAccessibleEvent ev(this, QAccessible::ObjectShow);
++        QAccessible::updateAccessibility(&ev);
++    }
++#endif
+ }
+ 
+ QQuickStateGroup *QQuickItemPrivate::_states()
+@@ -6106,9 +6121,11 @@ bool QQuickItemPrivate::setEffectiveVisibleRecur(bool newEffectiveVisible)
+         QAccessible::updateAccessibility(&ev);
+     }
+ #endif
+-    emit q->visibleChanged();
+-    if (childVisibilityChanged)
+-        emit q->visibleChildrenChanged();
++    if (!inDestructor) {
++        emit q->visibleChanged();
++        if (childVisibilityChanged)
++            emit q->visibleChildrenChanged();
++    }
+ 
+     return true;    // effective visibility DID change
+ }
+@@ -6157,6 +6174,15 @@ void QQuickItemPrivate::setEffectiveEnableRecur(QQuickItem *scope, bool newEffec
+     }
+ 
+     itemChange(QQuickItem::ItemEnabledHasChanged, effectiveEnable);
++#if QT_CONFIG(accessibility)
++    if (isAccessible) {
++        QAccessible::State changedState;
++        changedState.disabled = true;
++        changedState.focusable = true;
++        QAccessibleStateChangeEvent ev(q, changedState);
++        QAccessible::updateAccessibility(&ev);
++    }
++#endif
+     emit q->enabledChanged();
+ }
+ 
+diff --git a/qtdeclarative/src/quick/items/qquickitem_p.h b/qtdeclarative/src/quick/items/qquickitem_p.h
+index 841d91bb40..ade8fb61f2 100644
+--- a/qtdeclarative/src/quick/items/qquickitem_p.h
++++ b/qtdeclarative/src/quick/items/qquickitem_p.h
+@@ -472,6 +472,7 @@ public:
+     bool replayingPressEvent:1;
+     bool touchEnabled:1;
+     bool hasCursorHandler:1;
++    quint32 inDestructor:1; // has entered ~QQuickItem
+ 
+     enum DirtyType {
+         TransformOrigin         = 0x00000001,
+diff --git a/qtdeclarative/src/quick/items/qquickitemview.cpp b/qtdeclarative/src/quick/items/qquickitemview.cpp
+index 010a0152e1..f8ad168a17 100644
+--- a/qtdeclarative/src/quick/items/qquickitemview.cpp
++++ b/qtdeclarative/src/quick/items/qquickitemview.cpp
+@@ -1785,7 +1785,7 @@ void QQuickItemViewPrivate::refill(qreal from, qreal to)
+ 
+     do {
+         bufferPause.stop();
+-        if (currentChanges.hasPendingChanges() || bufferedChanges.hasPendingChanges()) {
++        if (currentChanges.hasPendingChanges() || bufferedChanges.hasPendingChanges() || currentChanges.active) {
+             currentChanges.reset();
+             bufferedChanges.reset();
+             releaseVisibleItems(reusableFlag);
+diff --git a/qtdeclarative/src/quick/items/qquickmousearea_p_p.h b/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
+index fba383e268..0d63618622 100644
+--- a/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
++++ b/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
+@@ -61,7 +61,6 @@ QT_BEGIN_NAMESPACE
+ 
+ class QQuickMouseEvent;
+ class QQuickMouseArea;
+-class QQuickPointerMask;
+ class QQuickMouseAreaPrivate : public QQuickItemPrivate
+ {
+     Q_DECLARE_PUBLIC(QQuickMouseArea)
+@@ -100,7 +99,6 @@ public:
+ #if QT_CONFIG(quick_draganddrop)
+     QQuickDrag *drag;
+ #endif
+-    QPointer<QQuickPointerMask> mask;
+     QPointF startScene;
+     QPointF targetStartPos;
+     QPointF lastPos;
+diff --git a/qtdeclarative/src/quick/items/qquicktext.cpp b/qtdeclarative/src/quick/items/qquicktext.cpp
+index 6230186933..e823ca1095 100644
+--- a/qtdeclarative/src/quick/items/qquicktext.cpp
++++ b/qtdeclarative/src/quick/items/qquicktext.cpp
+@@ -2168,7 +2168,7 @@ void QQuickText::resetMaximumLineCount()
+     <img src="" align="top,middle,bottom" width="" height=""> - inline images
+     <ol type="">, <ul type=""> and <li> - ordered and unordered lists
+     <pre></pre> - preformatted
+-    &gt; &lt; &amp;
++    &gt; &lt; &amp; &quot; &nbsp; &apos;
+     \endcode
+ 
+     \c Text.StyledText parser is strict, requiring tags to be correctly nested.
+diff --git a/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp b/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
+index eb4db0f85e..2325a2665b 100644
+--- a/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
++++ b/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
+@@ -446,7 +446,7 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+         const char *textureRecord = allocatorData;
+         for (int i = 0; i < textureCount; ++i, textureRecord += Qtdf::TextureRecordSize) {
+-            if (textureRecord + Qtdf::TextureRecordSize > qtdfTableEnd) {
++            if (qtdfTableEnd - textureRecord < Qtdf::TextureRecordSize) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+@@ -462,7 +462,7 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+         const char *glyphRecord = textureRecord;
+         for (quint32 i = 0; i < glyphCount; ++i, glyphRecord += Qtdf::GlyphRecordSize) {
+-            if (glyphRecord + Qtdf::GlyphRecordSize > qtdfTableEnd) {
++            if (qtdfTableEnd - glyphRecord < Qtdf:: GlyphRecordSize) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+@@ -512,8 +512,8 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+             int width = texInfo->allocatedArea.width();
+             int height = texInfo->allocatedArea.height();
+-            qint64 size = width * height;
+-            if (reinterpret_cast<const char *>(textureData + size) > qtdfTableEnd) {
++            qint64 size = qint64(width) * height;
++            if (qtdfTableEnd - reinterpret_cast<const char *>(textureData) < size) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+diff --git a/qtdeclarative/src/quick/util/qquickstyledtext.cpp b/qtdeclarative/src/quick/util/qquickstyledtext.cpp
+index d531fc9205..a25af90414 100644
+--- a/qtdeclarative/src/quick/util/qquickstyledtext.cpp
++++ b/qtdeclarative/src/quick/util/qquickstyledtext.cpp
+@@ -564,6 +564,8 @@ void QQuickStyledTextPrivate::parseEntity(const QChar *&ch, const QString &textI
+                 textOut += QChar(60);
+             else if (entity == QLatin1String("amp"))
+                 textOut += QChar(38);
++            else if (entity == QLatin1String("apos"))
++                textOut += QChar(39);
+             else if (entity == QLatin1String("quot"))
+                 textOut += QChar(34);
+             else if (entity == QLatin1String("nbsp"))
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp
+new file mode 100644
+index 0000000000..8a1c901880
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp
+@@ -0,0 +1,110 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include "qaccessiblequickwidget_p.h"
++
++#include "qquickwidget_p.h"
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleQuickWidget::QAccessibleQuickWidget(QQuickWidget* widget)
++: QAccessibleWidget(widget)
++, m_accessibleWindow(QQuickWidgetPrivate::get(widget)->offscreenWindow)
++{
++    // NOTE: m_accessibleWindow is a QAccessibleQuickWindow, and not a
++    // QAccessibleQuickWidgetOffscreenWindow (defined below). This means
++    // it will return the Quick item child interfaces, which is what's needed here
++    // (unlike QAccessibleQuickWidgetOffscreenWindow, which will report 0 children).
++}
++
++QAccessibleInterface *QAccessibleQuickWidget::child(int index) const
++{
++    return m_accessibleWindow.child(index);
++}
++
++int QAccessibleQuickWidget::childCount() const
++{
++    return m_accessibleWindow.childCount();
++}
++
++int QAccessibleQuickWidget::indexOfChild(const QAccessibleInterface *iface) const
++{
++    return m_accessibleWindow.indexOfChild(iface);
++}
++
++QAccessibleInterface *QAccessibleQuickWidget::childAt(int x, int y) const
++{
++    return m_accessibleWindow.childAt(x, y);
++}
++
++QAccessibleQuickWidgetOffscreenWindow::QAccessibleQuickWidgetOffscreenWindow(QQuickWindow *window)
++:QAccessibleQuickWindow(window)
++{
++
++}
++
++QAccessibleInterface *QAccessibleQuickWidgetOffscreenWindow::child(int index) const
++{
++    Q_UNUSED(index);
++    return nullptr;
++}
++
++int QAccessibleQuickWidgetOffscreenWindow::childCount() const
++{
++    return 0;
++}
++
++int QAccessibleQuickWidgetOffscreenWindow::indexOfChild(const QAccessibleInterface *iface) const
++{
++    Q_UNUSED(iface);
++    return -1;
++}
++
++QAccessibleInterface *QAccessibleQuickWidgetOffscreenWindow::QAccessibleQuickWidgetOffscreenWindow::childAt(int x, int y) const
++{
++    Q_UNUSED(x);
++    Q_UNUSED(y);
++    return nullptr;
++}
++
++#endif // accessibility
++
++QT_END_NAMESPACE
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h
+new file mode 100644
+index 0000000000..7c2ab930e0
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h
+@@ -0,0 +1,95 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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 QACCESSIBLEQUICKWIDGET_H
++#define QACCESSIBLEQUICKWIDGET_H
++
++//
++//  W A R N I N G
++//  -------------
++//
++// This file is not part of the Qt API.  It exists purely as an
++// implementation detail.  This header file may change from version to
++// version without notice, or even be removed.
++//
++// We mean it.
++//
++
++#include "qquickwidget.h"
++#include <QtWidgets/qaccessiblewidget.h>
++
++#include <private/qaccessiblequickview_p.h>
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++// These classes implement the QQuickWiget accessibility switcharoo,
++// where the child items of the QQuickWidgetOffscreenWindow are reported
++// as child accessible interfaces of the QAccessibleQuickWidget.
++class QAccessibleQuickWidget: public QAccessibleWidget
++{
++public:
++    QAccessibleQuickWidget(QQuickWidget* widget);
++
++    QAccessibleInterface *child(int index) const override;
++    int childCount() const override;
++    int indexOfChild(const QAccessibleInterface *iface) const override;
++    QAccessibleInterface *childAt(int x, int y) const override;
++
++private:
++    QAccessibleQuickWindow m_accessibleWindow;
++    Q_DISABLE_COPY(QAccessibleQuickWidget)
++};
++
++class QAccessibleQuickWidgetOffscreenWindow: public QAccessibleQuickWindow
++{
++public:
++    QAccessibleQuickWidgetOffscreenWindow(QQuickWindow *window);
++    QAccessibleInterface *child(int index) const override;
++    int childCount() const override;
++    int indexOfChild(const QAccessibleInterface *iface) const override;
++    QAccessibleInterface *childAt(int x, int y) const override;
++};
++
++#endif // accessibility
++
++QT_END_NAMESPACE
++
++#endif
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp
+new file mode 100644
+index 0000000000..7ba88a1769
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp
+@@ -0,0 +1,60 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include "qaccessiblequickwidgetfactory_p.h"
++#include "qaccessiblequickwidget_p.h"
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleInterface *qAccessibleQuickWidgetFactory(const QString &classname, QObject *object)
++{
++    if (classname == QLatin1String("QQuickWidget")) {
++        return new QAccessibleQuickWidget(qobject_cast<QQuickWidget *>(object));
++    } else if (classname == QLatin1String("QQuickWidgetOffscreenWindow")) {
++        return new QAccessibleQuickWidgetOffscreenWindow(qobject_cast<QQuickWindow *>(object));
++    }
++    return 0;
++}
++
++#endif // accessibility
++
++QT_END_NAMESPACE
++
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h
+new file mode 100644
+index 0000000000..8c63b09f81
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h
+@@ -0,0 +1,66 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include <QtGui/qaccessible.h>
++
++#ifndef QACCESSIBLEQUICKWIDGETFACTORY_H
++#define QACCESSIBLEQUICKWIDGETFACTORY_H
++
++//
++//  W A R N I N G
++//  -------------
++//
++// This file is not part of the Qt API.  It exists purely as an
++// implementation detail.  This header file may change from version to
++// version without notice, or even be removed.
++//
++// We mean it.
++//
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleInterface *qAccessibleQuickWidgetFactory(const QString &classname, QObject *object);
++
++#endif
++
++QT_END_NAMESPACE
++
++#endif
+diff --git a/qtdeclarative/src/quickwidgets/qquickwidget.cpp b/qtdeclarative/src/quickwidgets/qquickwidget.cpp
+index 39780f8de3..9c97b43518 100644
+--- a/qtdeclarative/src/quickwidgets/qquickwidget.cpp
++++ b/qtdeclarative/src/quickwidgets/qquickwidget.cpp
+@@ -39,6 +39,7 @@
+ 
+ #include "qquickwidget.h"
+ #include "qquickwidget_p.h"
++#include "qaccessiblequickwidgetfactory_p.h"
+ 
+ #include "private/qquickwindow_p.h"
+ #include "private/qquickitem_p.h"
+@@ -75,9 +76,16 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++QQuickWidgetOffscreenWindow::QQuickWidgetOffscreenWindow(QQuickWindowPrivate &dd, QQuickRenderControl *control)
++:QQuickWindow(dd, control)
++{
++    setTitle(QString::fromLatin1("Offscreen"));
++    setObjectName(QString::fromLatin1("QQuickOffScreenWindow"));
++}
++
+ // override setVisble to prevent accidental offscreen window being created
+ // by base class.
+-class QQuickOffcreenWindowPrivate: public QQuickWindowPrivate {
++class QQuickWidgetOffscreenWindowPrivate: public QQuickWindowPrivate {
+ public:
+     void setVisible(bool visible) override {
+         Q_Q(QWindow);
+@@ -105,9 +113,8 @@ void QQuickWidgetPrivate::init(QQmlEngine* e)
+     Q_Q(QQuickWidget);
+ 
+     renderControl = new QQuickWidgetRenderControl(q);
+-    offscreenWindow = new QQuickWindow(*new QQuickOffcreenWindowPrivate(),renderControl);
+-    offscreenWindow->setTitle(QString::fromLatin1("Offscreen"));
+-    offscreenWindow->setObjectName(QString::fromLatin1("QQuickOffScreenWindow"));
++    offscreenWindow = new QQuickWidgetOffscreenWindow(*new QQuickWidgetOffscreenWindowPrivate(), renderControl);
++    offscreenWindow->setScreen(q->screen());
+     // Do not call create() on offscreenWindow.
+ 
+     // Check if the Software Adaptation is being used
+@@ -138,6 +145,10 @@ void QQuickWidgetPrivate::init(QQmlEngine* e)
+     QWidget::connect(offscreenWindow, &QQuickWindow::focusObjectChanged, q, &QQuickWidget::propagateFocusObjectChanged);
+     QObject::connect(renderControl, SIGNAL(renderRequested()), q, SLOT(triggerUpdate()));
+     QObject::connect(renderControl, SIGNAL(sceneChanged()), q, SLOT(triggerUpdate()));
++
++#if QT_CONFIG(accessibility)
++    QAccessible::installFactory(&qAccessibleQuickWidgetFactory);
++#endif
+ }
+ 
+ void QQuickWidgetPrivate::ensureEngine() const
+@@ -901,9 +912,7 @@ void QQuickWidgetPrivate::createContext()
+ 
+         context = new QOpenGLContext;
+         context->setFormat(offscreenWindow->requestedFormat());
+-        const QWindow *win = q->window()->windowHandle();
+-        if (win && win->screen())
+-            context->setScreen(win->screen());
++        context->setScreen(q->screen());
+         QOpenGLContext *shareContext = qt_gl_global_share_context();
+         if (!shareContext)
+             shareContext = QWidgetPrivate::get(q->window())->shareContext();
+@@ -1520,19 +1529,16 @@ bool QQuickWidget::event(QEvent *e)
+         d->handleWindowChange();
+         break;
+ 
+-    case QEvent::ScreenChangeInternal:
+-        if (QWindow *window = this->window()->windowHandle()) {
+-            QScreen *newScreen = window->screen();
+-
+-            if (d->offscreenWindow)
+-                d->offscreenWindow->setScreen(newScreen);
+-            if (d->offscreenSurface)
+-                d->offscreenSurface->setScreen(newScreen);
++    case QEvent::ScreenChangeInternal: {
++        QScreen *newScreen = screen();
++        if (d->offscreenWindow)
++            d->offscreenWindow->setScreen(newScreen);
++        if (d->offscreenSurface)
++            d->offscreenSurface->setScreen(newScreen);
+ #if QT_CONFIG(opengl)
+-            if (d->context)
+-                d->context->setScreen(newScreen);
++        if (d->context)
++            d->context->setScreen(newScreen);
+ #endif
+-        }
+ 
+         if (d->useSoftwareRenderer
+ #if QT_CONFIG(opengl)
+@@ -1545,7 +1551,7 @@ bool QQuickWidget::event(QEvent *e)
+             d->render(true);
+         }
+         break;
+-
++    }
+     case QEvent::Show:
+     case QEvent::Move:
+         d->updatePosition();
+diff --git a/qtdeclarative/src/quickwidgets/qquickwidget_p.h b/qtdeclarative/src/quickwidgets/qquickwidget_p.h
+index 881f7f9220..1a946bcc71 100644
+--- a/qtdeclarative/src/quickwidgets/qquickwidget_p.h
++++ b/qtdeclarative/src/quickwidgets/qquickwidget_p.h
+@@ -148,6 +148,14 @@ public:
+     bool forceFullUpdate;
+ };
+ 
++class QQuickWidgetOffscreenWindow: public QQuickWindow
++{
++    Q_OBJECT
++
++public:
++    QQuickWidgetOffscreenWindow(QQuickWindowPrivate &dd, QQuickRenderControl *control);
++};
++
+ QT_END_NAMESPACE
+ 
+ #endif // QQuickWidget_P_H
+diff --git a/qtdeclarative/src/quickwidgets/quickwidgets.pro b/qtdeclarative/src/quickwidgets/quickwidgets.pro
+index 2438e577ae..85d156b8a3 100644
+--- a/qtdeclarative/src/quickwidgets/quickwidgets.pro
++++ b/qtdeclarative/src/quickwidgets/quickwidgets.pro
+@@ -7,9 +7,13 @@ DEFINES   += QT_NO_URL_CAST_FROM_STRING QT_NO_INTEGER_EVENT_COORDINATES QT_NO_FO
+ HEADERS += \
+     qquickwidget.h \
+     qquickwidget_p.h \
+-    qtquickwidgetsglobal.h
++    qtquickwidgetsglobal.h \
++    qaccessiblequickwidget_p.h \
++    qaccessiblequickwidgetfactory_p.h
+ 
+ SOURCES += \
+-    qquickwidget.cpp
++    qquickwidget.cpp \
++    qaccessiblequickwidget.cpp \
++    qaccessiblequickwidgetfactory.cpp
+ 
+ load(qt_module)
+diff --git a/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+index 3b7d74df63..b75bf820d5 100644
+--- a/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
++++ b/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+@@ -102,6 +102,7 @@ private slots:
+     void valueConversion_RegularExpression();
+     void castWithMultipleInheritance();
+     void collectGarbage();
++    void collectGarbageNestedWrappersTwoEngines();
+     void gcWithNestedDataStructure();
+     void stacktrace();
+     void numberParsing_data();
+@@ -1809,6 +1810,44 @@ void tst_QJSEngine::collectGarbage()
+     QVERIFY(ptr.isNull());
+ }
+ 
++class TestObjectContainer : public QObject
++{
++    Q_OBJECT
++    Q_PROPERTY(QObject *dummy MEMBER m_dummy CONSTANT)
++
++public:
++    TestObjectContainer() : m_dummy(new QObject(this)) {}
++
++private:
++    QObject *m_dummy;
++};
++
++void tst_QJSEngine::collectGarbageNestedWrappersTwoEngines()
++{
++    QJSEngine engine1;
++    QJSEngine engine2;
++
++    TestObjectContainer container;
++    QQmlEngine::setObjectOwnership(&container, QQmlEngine::CppOwnership);
++
++    engine1.globalObject().setProperty("foobar", engine1.newQObject(&container));
++    engine2.globalObject().setProperty("foobar", engine2.newQObject(&container));
++
++    engine1.evaluate("foobar.dummy.baz = 42");
++    engine2.evaluate("foobar.dummy.baz = 43");
++
++    QCOMPARE(engine1.evaluate("foobar.dummy.baz").toInt(), 42);
++    QCOMPARE(engine2.evaluate("foobar.dummy.baz").toInt(), 43);
++
++    engine1.collectGarbage();
++    engine2.collectGarbage();
++
++    // The GC should not collect dummy object wrappers neither in engine1 nor engine2, we
++    // verify that by checking whether the baz property still has its previous value.
++    QCOMPARE(engine1.evaluate("foobar.dummy.baz").toInt(), 42);
++    QCOMPARE(engine2.evaluate("foobar.dummy.baz").toInt(), 43);
++}
++
+ void tst_QJSEngine::gcWithNestedDataStructure()
+ {
+     // The GC must be able to traverse deeply nested objects, otherwise this
+diff --git a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml
+new file mode 100644
+index 0000000000..206133bb39
+--- /dev/null
++++ b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml
+@@ -0,0 +1,11 @@
++import QtQuick 2.8
++
++ListView {
++    id: root
++    width: 200
++    height: 200
++
++    delegate: Text {
++        text: display
++    }
++}
+diff --git a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
+index 35f1e2c94d..1722447830 100644
+--- a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
++++ b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
+@@ -27,6 +27,8 @@
+ ****************************************************************************/
+ 
+ #include <QtTest/qtest.h>
++#include <QtCore/QConcatenateTablesProxyModel>
++#include <QtGui/QStandardItemModel>
+ #include <QtQml/qqmlcomponent.h>
+ #include <QtQmlModels/private/qqmldelegatemodel_p.h>
+ #include <QtQuick/qquickview.h>
+@@ -47,6 +49,7 @@ private slots:
+     void filterOnGroup_removeWhenCompleted();
+     void qtbug_86017();
+     void contextAccessedByHandler();
++    void redrawUponColumnChange();
+ };
+ 
+ class AbstractItemModel : public QAbstractItemModel
+@@ -186,6 +189,30 @@ void tst_QQmlDelegateModel::contextAccessedByHandler()
+     QVERIFY(root->property("works").toBool());
+ }
+ 
++void tst_QQmlDelegateModel::redrawUponColumnChange()
++{
++    QStandardItemModel m1;
++    m1.appendRow({
++            new QStandardItem("Banana"),
++            new QStandardItem("Coconut"),
++    });
++
++    QQuickView view(testFileUrl("redrawUponColumnChange.qml"));
++    QCOMPARE(view.status(), QQuickView::Ready);
++    view.show();
++    QQuickItem *root = view.rootObject();
++    root->setProperty("model", QVariant::fromValue<QObject *>(&m1));
++
++    QObject *item = root->property("currentItem").value<QObject *>();
++    QVERIFY(item);
++    QCOMPARE(item->property("text").toString(), "Banana");
++
++    QVERIFY(root);
++    m1.removeColumn(0);
++
++    QCOMPARE(item->property("text").toString(), "Coconut");
++}
++
+ QTEST_MAIN(tst_QQmlDelegateModel)
+ 
+ #include "tst_qqmldelegatemodel.moc"
+diff --git a/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp b/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
+index 5d635aa63b..824fd89e5b 100644
+--- a/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
++++ b/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
+@@ -76,10 +76,10 @@ void tst_qv4mm::multiWrappedQObjects()
+         QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 1);
+         QCOMPARE(engine2.memoryManager->m_pendingFreedObjectWrapperValue.size(), 0);
+ 
+-        // Moves the additional WeakValue from m_multiplyWrappedQObjects to
+-        // m_pendingFreedObjectWrapperValue. It's still alive after all.
++        // The additional WeakValue from m_multiplyWrappedQObjects hasn't been moved
++        // to m_pendingFreedObjectWrapperValue yet. It's still alive after all.
+         engine1.memoryManager->runGC();
+-        QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 2);
++        QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 1);
+ 
+         // engine2 doesn't own the object as engine1 was the first to wrap it above.
+         // Therefore, no effect here.
+diff --git a/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml b/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml
+new file mode 100644
+index 0000000000..889e480f3b
+--- /dev/null
++++ b/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml
+@@ -0,0 +1,13 @@
++import QtQuick 2.6
++
++Item {
++    visible: true
++    Item {
++        visible: false
++        Item {
++            objectName: "hiddenChild"
++            activeFocusOnTab: true
++            focus: true
++        }
++    }
++}
+diff --git a/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp b/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+index c8f251dbe1..c8ef36ee68 100644
+--- a/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
++++ b/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+@@ -67,6 +67,7 @@ private slots:
+     void activeFocusOnTab10();
+     void activeFocusOnTab_infiniteLoop_data();
+     void activeFocusOnTab_infiniteLoop();
++    void activeFocusOnTab_infiniteLoopControls();
+ 
+     void nextItemInFocusChain();
+     void nextItemInFocusChain2();
+@@ -1057,6 +1058,17 @@ void tst_QQuickItem::activeFocusOnTab_infiniteLoop()
+     QCOMPARE(item, window->rootObject());
+ }
+ 
++
++void tst_QQuickItem::activeFocusOnTab_infiniteLoopControls()
++{
++    auto source = testFileUrl("activeFocusOnTab_infiniteLoop3.qml");
++    QScopedPointer<QQuickView>window(new QQuickView());
++    window->setSource(source);
++    window->show();
++    QVERIFY(window->errors().isEmpty());
++    QTest::keyClick(window.get(), Qt::Key_Tab); // should not hang
++}
++
+ void tst_QQuickItem::nextItemInFocusChain()
+ {
+     if (!qt_tab_all_widgets())
+Submodule qtdoc c0c7bf07...79d6ef69:
+Submodule qtimageformats 2dcf2899..abe44c0f:
+diff --git a/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp b/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
+index dde783c..1bf9074 100644
+--- a/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
+@@ -462,8 +462,12 @@ static bool parseIconEntryInfo(ICNSEntry &icon)
+     if (isIconCompressed(icon))
+         return true;
+     // Icon depth:
+-    if (!depth.isEmpty())
+-        icon.depth = ICNSEntry::Depth(depth.toUInt());
++    if (!depth.isEmpty()) {
++        const uint depthUInt = depth.toUInt();
++        if (depthUInt > 32)
++            return false;
++        icon.depth = ICNSEntry::Depth(depthUInt);
++    }
+     // Try mono if depth not found
+     if (icon.depth == ICNSEntry::DepthUnknown)
+         icon.depth = ICNSEntry::DepthMono;
+@@ -515,6 +519,9 @@ static bool parseIconEntryInfo(ICNSEntry &icon)
+         }
+         icon.height = icon.width;
+     }
++    // Sanity check
++    if (icon.width == 0 || icon.width > 4096)
++        return false;
+     return true;
+ }
+ 
+@@ -685,7 +692,7 @@ bool QICNSHandler::canRead() const
+ bool QICNSHandler::read(QImage *outImage)
+ {
+     QImage img;
+-    if (!ensureScanned()) {
++    if (!ensureScanned() || m_currentIconIndex >= m_icons.size()) {
+         qWarning("QICNSHandler::read(): The device wasn't parsed properly!");
+         return false;
+     }
+@@ -892,7 +899,7 @@ bool QICNSHandler::scanDevice()
+             return false;
+ 
+         const qint64 blockDataOffset = device()->pos();
+-        if (!isBlockHeaderValid(blockHeader)) {
++        if (!isBlockHeaderValid(blockHeader, ICNSBlockHeaderSize + filelength - blockDataOffset)) {
+             qWarning("QICNSHandler::scanDevice(): Failed, bad header at pos %s. OSType \"%s\", length %u",
+                      QByteArray::number(blockDataOffset).constData(),
+                      nameFromOSType(blockHeader.ostype).constData(), blockHeader.length);
+@@ -927,11 +934,14 @@ bool QICNSHandler::scanDevice()
+         case ICNSBlockHeader::TypeOdrp:
+             // Icns container seems to have an embedded icon variant container
+             // Let's start a scan for entries
+-            while (device()->pos() < nextBlockOffset) {
++            while (!stream.atEnd() && device()->pos() < nextBlockOffset) {
+                 ICNSBlockHeader icon;
+                 stream >> icon;
++                if (stream.status() != QDataStream::Ok)
++                    return false;
+                 // Check for incorrect variant entry header and stop scan
+-                if (!isBlockHeaderValid(icon, blockDataLength))
++                quint64 remaining = blockDataLength - (device()->pos() - blockDataOffset);
++                if (!isBlockHeaderValid(icon, ICNSBlockHeaderSize + remaining))
+                     break;
+                 if (!addEntry(icon, device()->pos(), blockHeader.ostype))
+                     return false;
+@@ -1003,7 +1013,7 @@ bool QICNSHandler::scanDevice()
+             break;
+         }
+     }
+-    return true;
++    return (m_icons.size() > 0);
+ }
+ 
+ const ICNSEntry &QICNSHandler::getIconMask(const ICNSEntry &icon) const
+diff --git a/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp b/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
+index 5082023..cb34374 100644
+--- a/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
++++ b/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
+@@ -43,6 +43,7 @@
+ #include "qimage.h"
+ #include "qvariant.h"
+ #include "qcolor.h"
++#include "qimagereader.h"
+ 
+ #include <jasper/jasper.h>
+ #include <math.h> // for pow
+@@ -333,16 +334,46 @@ private:
+ Jpeg2000JasperReader::Jpeg2000JasperReader(QIODevice *iod, SubFormat format)
+     : jasperOk(true), ioDevice(iod), format(format), hasAlpha(false)
+ {
++#if JAS_VERSION_MAJOR < 3
+     if (jas_init()) {
+         jasperOk = false;
+         qDebug("Jasper Library initialization failed");
+     }
++#else
++    jas_conf_clear();
++#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
++    jas_conf_set_max_mem_usage(QImageReader::allocationLimit() * 1024 * 1024);
++#else
++    // 128MB seems to be enough.
++    jas_conf_set_max_mem_usage(128 * 1024 * 1024);
++#endif
++    if (jas_init_library()) {
++        jasperOk = false;
++        qDebug("Jasper library initialization failed");
++    }
++    if (jas_init_thread()) {
++        jas_cleanup_library();
++        jasperOk = false;
++        qDebug("Jasper thread initialization failed");
++    }
++#endif
+ }
+ 
+ Jpeg2000JasperReader::~Jpeg2000JasperReader()
+ {
++#if JAS_VERSION_MAJOR < 3
+     if (jasperOk)
+         jas_cleanup();
++#else
++    if (jasperOk) {
++        if (jas_cleanup_thread()) {
++            qDebug("Jasper thread cleanup failed");
++        }
++        if (jas_cleanup_library()) {
++            qDebug("Jasper library cleanup failed");
++        }
++    }
++#endif
+ }
+ 
+ /*! \internal
+@@ -857,7 +888,7 @@ bool Jpeg2000JasperReader::write(const QImage &image, int quality)
+     }
+ 
+     // Open an empty jasper stream that grows automatically
+-    jas_stream_t * memory_stream = jas_stream_memopen(0, -1);
++    jas_stream_t * memory_stream = jas_stream_memopen(0, 0);
+ 
+     // Jasper wants a non-const string.
+     char *str = qstrdup(jasperFormatString.toLatin1().constData());
+diff --git a/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp b/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
+index 1386750..ac8956c 100644
+--- a/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
+@@ -361,6 +361,8 @@ bool QTiffHandler::read(QImage *image)
+     }
+ 
+     TIFF *const tiff = d->tiff;
++    if (TIFFIsTiled(tiff) && TIFFTileSize64(tiff) > uint64_t(image->sizeInBytes())) // Corrupt image
++        return false;
+     const quint32 width = d->size.width();
+     const quint32 height = d->size.height();
+ 
+diff --git a/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp b/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
+index 82d38cb..d02eb05 100644
+--- a/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
+@@ -45,6 +45,7 @@
+ #include <qdebug.h>
+ #include <qpainter.h>
+ #include <qvariant.h>
++#include <QtEndian>
+ 
+ static const int riffHeaderSize = 12; // RIFF_HEADER_SIZE from webp/format_constants.h
+ 
+@@ -102,21 +103,23 @@ bool QWebpHandler::ensureScanned() const
+ 
+     m_scanState = ScanError;
+ 
+-    if (device()->isSequential()) {
+-        qWarning() << "Sequential devices are not supported";
++    QWebpHandler *that = const_cast<QWebpHandler *>(this);
++    const int headerBytesNeeded = sizeof(WebPBitstreamFeatures);
++    QByteArray header = device()->peek(headerBytesNeeded);
++    if (header.size() < headerBytesNeeded)
+         return false;
+-    }
+ 
+-    qint64 oldPos = device()->pos();
+-    device()->seek(0);
+-
+-    QWebpHandler *that = const_cast<QWebpHandler *>(this);
+-    QByteArray header = device()->peek(sizeof(WebPBitstreamFeatures));
++    // We do no random access during decoding, just a readAll() of the whole image file. So if
++    // if it is all available already, we can accept a sequential device. The riff header contains
++    // the file size minus 8 bytes header
++    qint64 byteSize = qFromLittleEndian<quint32>(header.constData() + 4);
++    if (device()->isSequential() && device()->bytesAvailable() < byteSize + 8) {
++        qWarning() << "QWebpHandler: Insufficient data available in sequential device";
++        return false;
++    }
+     if (WebPGetFeatures((const uint8_t*)header.constData(), header.size(), &(that->m_features)) == VP8_STATUS_OK) {
+         if (m_features.has_animation) {
+             // For animation, we have to read and scan whole file to determine loop count and images count
+-            device()->seek(oldPos);
+-
+             if (that->ensureDemuxer()) {
+                 that->m_loop = WebPDemuxGetI(m_demuxer, WEBP_FF_LOOP_COUNT);
+                 that->m_frameCount = WebPDemuxGetI(m_demuxer, WEBP_FF_FRAME_COUNT);
+@@ -126,17 +129,13 @@ bool QWebpHandler::ensureScanned() const
+                 if (that->m_features.has_alpha)
+                     that->m_composited->fill(Qt::transparent);
+ 
+-                // We do not reset device position since we have read in all data
+                 m_scanState = ScanSuccess;
+-                return true;
+             }
+         } else {
+             m_scanState = ScanSuccess;
+         }
+     }
+ 
+-    device()->seek(oldPos);
+-
+     return m_scanState == ScanSuccess;
+ }
+ 
+@@ -159,7 +158,7 @@ bool QWebpHandler::ensureDemuxer()
+ 
+ bool QWebpHandler::read(QImage *image)
+ {
+-    if (!ensureScanned() || device()->isSequential() || !ensureDemuxer())
++    if (!ensureScanned() || !ensureDemuxer())
+         return false;
+ 
+     QRect prevFrameRect;
+Submodule qtlocation 98a5c511..f991e28c:
+diff --git a/qtlocation/src/location/configure.json b/qtlocation/src/location/configure.json
+index 6d01a9a3..d1e623a1 100644
+--- a/qtlocation/src/location/configure.json
++++ b/qtlocation/src/location/configure.json
+@@ -9,7 +9,7 @@
+             "label": "Qt.labs.location experimental QML plugin",
+             "purpose": "Provides experimental QtLocation QML types",
+             "section": "Location",
+-            "condition": "config.opengl",
++            "condition": "features.opengl",
+             "output": [ "privateFeature" ]
+         },
+         "geoservices_osm": {
+diff --git a/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp b/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
+index a978573d..11e1466f 100644
+--- a/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
++++ b/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
+@@ -158,7 +158,7 @@ void QGeoMapObjectQSGSupport::updateMapObjects(QSGNode *root, QQuickWindow *wind
+     if (!root)
+         return;
+ 
+-    if (m_mapObjectsRootNode && m_mapObjectsRootNode->parent())
++    if (m_mapObjectsRootNode && !m_mapObjectsRootNode->parent())
+         root->appendChildNode(m_mapObjectsRootNode.get());
+ 
+     if (!m_mapObjectsRootNode) {
+diff --git a/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
+index 5a40467e..d123c6a8 100644
+--- a/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
+@@ -59,8 +59,10 @@ QT_BEGIN_NAMESPACE
+ static const QString kPrefixEsri(QStringLiteral("esri."));
+ static const QString kParamUserAgent(kPrefixEsri + QStringLiteral("useragent"));
+ 
+-static const QString kUrlGeocode(QStringLiteral("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates"));
+-static const QString kUrlReverseGeocode(QStringLiteral("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode"));
++static const QString kUrlGeocode(QStringLiteral("https://geocode.arcgis.com/arcgis/rest/services/"
++                                                "World/GeocodeServer/findAddressCandidates"));
++static const QString kUrlReverseGeocode(QStringLiteral(
++        "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode"));
+ 
+ static QString addressToQuery(const QGeoAddress &address)
+ {
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
+index 17492d94..96c12b1b 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
+@@ -46,7 +46,8 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-// JSON reference: http://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
++// JSON reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
+ 
+ static const QString kErrorMessage(QStringLiteral("Error %1: %2."));
+ static const QString kErrorJson(QStringLiteral("Error: invalide JSON document."));
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
+index 8cadfb29..92b6bb13 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
+@@ -44,7 +44,8 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-// JSON reference: http://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
++// JSON reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
+ 
+ GeoRouteReplyEsri::GeoRouteReplyEsri(QNetworkReply *reply, const QGeoRouteRequest &request,
+                                      QObject *parent) :
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
+index 0e6bc2c7..ed613f4b 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
+@@ -48,7 +48,8 @@ static const QString kPrefixEsri(QStringLiteral("esri."));
+ static const QString kParamUserAgent(kPrefixEsri + QStringLiteral("useragent"));
+ static const QString kParamToken(kPrefixEsri + QStringLiteral("token"));
+ 
+-static const QString kUrlRouting(QStringLiteral("http://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve"));
++static const QString kUrlRouting(QStringLiteral(
++        "https://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve"));
+ 
+ GeoRoutingManagerEngineEsri::GeoRoutingManagerEngineEsri(const QVariantMap &parameters,
+                                                          QGeoServiceProvider::Error *error,
+@@ -70,7 +71,8 @@ GeoRoutingManagerEngineEsri::~GeoRoutingManagerEngineEsri()
+ {
+ }
+ 
+-// REST reference: http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
++// REST reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
+ 
+ QGeoRouteReply *GeoRoutingManagerEngineEsri::calculateRoute(const QGeoRouteRequest &request)
+ {
+@@ -125,7 +127,7 @@ void GeoRoutingManagerEngineEsri::replyError(QGeoRouteReply::Error errorCode, co
+ QString GeoRoutingManagerEngineEsri::preferedDirectionLangage()
+ {
+     // list of supported langages is defined in:
+-    // http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
++    // https://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
+     const QStringList supportedLanguages = {
+         "ar", // Generate directions in Arabic
+         "cs", // Generate directions in Czech
+diff --git a/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
+index 5d15835d..24148f95 100644
+--- a/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
+@@ -230,7 +230,8 @@ QGeoMap *GeoTiledMappingManagerEngineEsri::createMap()
+ // ${y} = Y
+ // ${token} = Token
+ 
+-// template = 'http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{{z}}/{{y}}/{{x}}.png'
++// template =
++// 'https://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{{z}}/{{y}}/{{x}}.png'
+ 
+ bool GeoTiledMappingManagerEngineEsri::initializeMapSources(QGeoServiceProvider::Error *error,
+                                                             QString *errorString,
+diff --git a/qtlocation/src/plugins/geoservices/esri/maps.json b/qtlocation/src/plugins/geoservices/esri/maps.json
+index 8167ae7d..862e087d 100644
+--- a/qtlocation/src/plugins/geoservices/esri/maps.json
++++ b/qtlocation/src/plugins/geoservices/esri/maps.json
+@@ -6,8 +6,8 @@
+             "description": "ArcGIS Online World Street Map",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=3b93337983e9436f8db950e38a8629af'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=3b93337983e9436f8db950e38a8629af'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -16,8 +16,8 @@
+             "": "ArcGIS Online World Imagery",
+             "mobile": true,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -26,8 +26,8 @@
+             "description": "ArcGIS Online World Terrain Base",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=c61ad8ab017d49e1a82f580ee1298931'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=c61ad8ab017d49e1a82f580ee1298931'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -36,8 +36,8 @@
+             "description": "ArcGIS Online World Topography",
+             "mobile": true,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=30e5fe3149c34df1ba922e6f5bbf808f'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=30e5fe3149c34df1ba922e6f5bbf808f'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -46,8 +46,8 @@
+             "description": "This map presents land cover and detailed topographic maps for the United States.",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=99cd5fbd98934028802b4f797c4b1732'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=99cd5fbd98934028802b4f797c4b1732'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -56,8 +56,8 @@
+             "description": "National Geographic World Map",
+             "mobile": false,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=b9b1b422198944fbbd5250b3241691b6'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=b9b1b422198944fbbd5250b3241691b6'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -66,8 +66,8 @@
+             "description": "Thematic content providing a neutral background with minimal colors",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=ed712cb1db3e4bae9e85329040fb9a49'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=ed712cb1db3e4bae9e85329040fb9a49'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -76,8 +76,8 @@
+             "description": "Natural Earth physical map for the world",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=c4ec722a1cd34cf0a23904aadf8923a0'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=c4ec722a1cd34cf0a23904aadf8923a0'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -86,8 +86,8 @@
+             "description": "Portrays surface elevation as shaded relief",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=9c5370d0b54f4de1b48a3792d7377ff2'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=9c5370d0b54f4de1b48a3792d7377ff2'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -96,8 +96,8 @@
+             "description": "This map is designed to be used as a basemap by marine GIS professionals and as a reference map by anyone interested in ocean data",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=1e126e7520f9466c9ca28b8f28b5e500'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=1e126e7520f9466c9ca28b8f28b5e500'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -106,8 +106,8 @@
+             "description": "Thematic content providing a neutral background with minimal colors",
+             "mobile": false,
+             "night": true,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=a284a9b99b3446a3910d4144a50990f6'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=a284a9b99b3446a3910d4144a50990f6'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -116,8 +116,8 @@
+             "description": "DeLorme’s topographic basemap is a seamless global data set that portrays transportation, hydrography, jurisdiction boundaries, and major geographic features",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/Specialty/DeLorme_World_Base_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=b165c3df453e4be6b5ac4fdb241effbe'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/Specialty/DeLorme_World_Base_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=b165c3df453e4be6b5ac4fdb241effbe'>Esri</a> contributors"
+         }
+     ]
+ }
+diff --git a/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
+index 3858ddf5..af66f28e 100644
+--- a/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
+@@ -63,8 +63,10 @@ static const QString kCountriesKey(QStringLiteral("detailedCountries"));
+ static const QString kLocalizedNamesKey(QStringLiteral("localizedNames"));
+ static const QString kMaxLocationsKey(QStringLiteral("maxLocations"));
+ 
+-static const QUrl kUrlGeocodeServer("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer?f=pjson");
+-static const QUrl kUrlFindAddressCandidates("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates");
++static const QUrl kUrlGeocodeServer(
++        "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer?f=pjson");
++static const QUrl kUrlFindAddressCandidates("https://geocode.arcgis.com/arcgis/rest/services/World/"
++                                            "GeocodeServer/findAddressCandidates");
+ 
+ PlaceManagerEngineEsri::PlaceManagerEngineEsri(const QVariantMap &parameters, QGeoServiceProvider::Error *error,
+                                                QString *errorString) :
+Submodule qtmultimedia f0344079..0d7cc33a:
+diff --git a/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp b/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
+index 2b5325132..b68b4af1b 100644
+--- a/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
++++ b/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
+@@ -402,6 +402,8 @@ int QPulseAudioInput::bytesReady() const
+ 
+ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ {
++    Q_ASSERT(data != nullptr || len == 0);
++
+     m_bytesAvailable = checkBytesReady();
+ 
+     setError(QAudio::NoError);
+@@ -411,7 +413,8 @@ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ 
+     if (!m_pullMode && !m_tempBuffer.isEmpty()) {
+         readBytes = qMin(static_cast<int>(len), m_tempBuffer.size());
+-        memcpy(data, m_tempBuffer.constData(), readBytes);
++        if (readBytes)
++            memcpy(data, m_tempBuffer.constData(), readBytes);
+         m_totalTimeValue += readBytes;
+ 
+         if (readBytes < m_tempBuffer.size()) {
+@@ -502,9 +505,10 @@ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ 
+ void QPulseAudioInput::applyVolume(const void *src, void *dest, int len)
+ {
++    Q_ASSERT((src && dest) || len == 0);
+     if (m_volume < 1.f)
+         QAudioHelperInternal::qMultiplySamples(m_volume, m_format, src, dest, len);
+-    else
++    else if (len)
+         memcpy(dest, src, len);
+ }
+ 
+Submodule qtpim 02efef5e...f9a8f0fc (commits not present)
+Submodule qtquick3d b85cf622..47defc8b:
+diff --git a/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro b/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
+index ca5c499e..174a075b 100644
+--- a/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
++++ b/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
+@@ -10,7 +10,7 @@ QT_FOR_CONFIG += assetimporters-private
+ include($$OUT_PWD/../qtassetimporters-config.pri)
+ 
+ qtConfig(system-assimp):!if(cross_compile:host_build) {
+-    QMAKE_USE_PRIVATE += assimp
++    QMAKE_USE_PRIVATE += quick3d-assimp
+ } else {
+     include(../../../3rdparty/assimp/assimp.pri)
+ }
+Submodule qtquickcontrols2 3a657dc0..56ce8233:
+diff --git a/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp b/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
+index e5fe734f7..e36922775 100644
+--- a/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
++++ b/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
+@@ -38,6 +38,7 @@
+ #include "qwidgetplatformmenuitem_p.h"
+ 
+ #include <QtGui/qwindow.h>
++#include <QtGui/private/qhighdpiscaling_p.h>
+ #include <QtWidgets/qmenu.h>
+ #include <QtWidgets/qaction.h>
+ 
+@@ -145,7 +146,7 @@ void QWidgetPlatformMenu::showPopup(const QWindow *window, const QRect &targetRe
+ 
+     QPoint targetPos = targetRect.bottomLeft();
+     if (window)
+-        targetPos = window->mapToGlobal(targetPos);
++        targetPos = window->mapToGlobal(QHighDpi::fromNativeLocalPosition(targetPos, window));
+ 
+     const QWidgetPlatformMenuItem *widgetItem = qobject_cast<const QWidgetPlatformMenuItem *>(item);
+     m_menu->popup(targetPos, widgetItem ? widgetItem->action() : nullptr);
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
+index 950e4e099..b81fbea0b 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
+@@ -387,6 +387,17 @@ void QQuickAbstractButtonPrivate::itemImplicitHeightChanged(QQuickItem *item)
+         emit q->implicitIndicatorHeightChanged();
+ }
+ 
++void QQuickAbstractButtonPrivate::itemDestroyed(QQuickItem *item)
++{
++    Q_Q(QQuickAbstractButton);
++    QQuickControlPrivate::itemDestroyed(item);
++    if (item == indicator) {
++        indicator = nullptr;
++        emit q->implicitIndicatorWidthChanged();
++        emit q->implicitIndicatorHeightChanged();
++    }
++}
++
+ QQuickAbstractButton *QQuickAbstractButtonPrivate::findCheckedButton() const
+ {
+     Q_Q(const QQuickAbstractButton);
+@@ -1176,6 +1187,12 @@ QAccessible::Role QQuickAbstractButton::accessibleRole() const
+     }
+     return QAccessible::Button;
+ }
++
++void QQuickAbstractButton::accessiblePressAction()
++{
++    Q_D(QQuickAbstractButton);
++    d->trigger();
++}
+ #endif
+ 
+ QT_END_NAMESPACE
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
+index 0fa48980e..ab66220d0 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
+@@ -209,6 +209,7 @@ protected:
+ #if QT_CONFIG(accessibility)
+     void accessibilityActiveChanged(bool active) override;
+     QAccessible::Role accessibleRole() const override;
++    Q_INVOKABLE void accessiblePressAction();
+ #endif
+ 
+ private:
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
+index 9291c1a87..b729720f2 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
+@@ -109,6 +109,7 @@ public:
+ 
+     void itemImplicitWidthChanged(QQuickItem *item) override;
+     void itemImplicitHeightChanged(QQuickItem *item) override;
++    void itemDestroyed(QQuickItem *item) override;
+ 
+     // copied from qabstractbutton.cpp
+     static const int AUTO_REPEAT_DELAY = 300;
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp b/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
+index 2041e7741..8610cdfae 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
+@@ -145,7 +145,7 @@ int QQuickActionPrivate::ShortcutEntry::shortcutId() const
+ 
+ void QQuickActionPrivate::ShortcutEntry::grab(const QKeySequence &shortcut, bool enabled)
+ {
+-    if (shortcut.isEmpty())
++    if (shortcut.isEmpty() || m_shortcutId)
+         return;
+ 
+     Qt::ShortcutContext context = Qt::WindowShortcut; // TODO
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp b/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
+index f38c2b09c..6eed2a024 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
+@@ -225,6 +225,7 @@ void QQuickContainerPrivate::cleanup()
+     QObject::disconnect(contentModel, &QQmlObjectModel::countChanged, q, &QQuickContainer::countChanged);
+     QObject::disconnect(contentModel, &QQmlObjectModel::childrenChanged, q, &QQuickContainer::contentChildrenChanged);
+     delete contentModel;
++    contentModel = nullptr;
+ }
+ 
+ QQuickItem *QQuickContainerPrivate::itemAt(int index) const
+@@ -436,7 +437,7 @@ void QQuickContainerPrivate::contentChildren_clear(QQmlListProperty<QQuickItem>
+ void QQuickContainerPrivate::updateContentWidth()
+ {
+     Q_Q(QQuickContainer);
+-    if (hasContentWidth || qFuzzyCompare(contentWidth, implicitContentWidth))
++    if (hasContentWidth || qFuzzyCompare(contentWidth, implicitContentWidth) || !contentModel)
+         return;
+ 
+     contentWidth = implicitContentWidth;
+@@ -446,7 +447,7 @@ void QQuickContainerPrivate::updateContentWidth()
+ void QQuickContainerPrivate::updateContentHeight()
+ {
+     Q_Q(QQuickContainer);
+-    if (hasContentHeight || qFuzzyCompare(contentHeight, implicitContentHeight))
++    if (hasContentHeight || qFuzzyCompare(contentHeight, implicitContentHeight) || !contentModel)
+         return;
+ 
+     contentHeight = implicitContentHeight;
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp b/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
+index bbbd0e622..1f4b47343 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
+@@ -845,6 +845,13 @@ void QQuickControlPrivate::executeBackground(bool complete)
+         quickCompleteDeferred(q, backgroundName(), background);
+ }
+ 
++/*
++    \internal
++
++    Hides an item that was replaced by a newer one, rather than
++    deleting it, as the item is typically created in QML and hence
++    we don't own it.
++*/
+ void QQuickControlPrivate::hideOldItem(QQuickItem *item)
+ {
+     if (!item)
+@@ -863,6 +870,29 @@ void QQuickControlPrivate::hideOldItem(QQuickItem *item)
+ #endif
+ }
+ 
++/*
++    \internal
++
++    Named "unhide" because it's used for cases where an item
++    that was previously hidden by \l hideOldItem() wants to be
++    shown by a control again, such as a ScrollBar in ScrollView.
++*/
++void QQuickControlPrivate::unhideOldItem(QQuickControl *control, QQuickItem *item)
++{
++    Q_ASSERT(item);
++    qCDebug(lcItemManagement) << "unhiding old item" << item;
++
++    item->setVisible(true);
++    item->setParentItem(control);
++
++#if QT_CONFIG(accessibility)
++    // Add the item back in to the accessibility tree.
++    QQuickAccessibleAttached *accessible = accessibleAttached(item);
++    if (accessible)
++        accessible->setIgnored(false);
++#endif
++}
++
+ void QQuickControlPrivate::updateBaselineOffset()
+ {
+     Q_Q(QQuickControl);
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h b/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
+index 8e979079e..a6e624c91 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
+@@ -173,6 +173,7 @@ public:
+     virtual void executeBackground(bool complete = false);
+ 
+     static void hideOldItem(QQuickItem *item);
++    static void unhideOldItem(QQuickControl *control, QQuickItem *item);
+ 
+     void updateBaselineOffset();
+ 
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp b/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
+index e6db14eb5..6197d1547 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
+@@ -237,7 +237,7 @@ static QRectF alignedRect(Qt::LayoutDirection direction, Qt::Alignment alignment
+ void QQuickDialogButtonBoxPrivate::resizeContent()
+ {
+     Q_Q(QQuickDialogButtonBox);
+-    if (!contentItem)
++    if (!contentItem || !contentModel)
+         return;
+ 
+     QRectF geometry = q->boundingRect().adjusted(q->leftPadding(), q->topPadding(), -q->rightPadding(), -q->bottomPadding());
+@@ -322,6 +322,9 @@ void QQuickDialogButtonBoxPrivate::updateLayout()
+ qreal QQuickDialogButtonBoxPrivate::getContentWidth() const
+ {
+     Q_Q(const QQuickDialogButtonBox);
++    if (!contentModel)
++        return 0;
++
+     const int count = contentModel->count();
+     const qreal totalSpacing = qMax(0, count - 1) * spacing;
+     qreal totalWidth = totalSpacing;
+@@ -341,6 +344,9 @@ qreal QQuickDialogButtonBoxPrivate::getContentWidth() const
+ qreal QQuickDialogButtonBoxPrivate::getContentHeight() const
+ {
+     Q_Q(const QQuickDialogButtonBox);
++    if (!contentModel)
++        return 0;
++
+     const int count = contentModel->count();
+     qreal maxHeight = 0;
+     for (int i = 0; i < count; ++i) {
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp b/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
+index 91bd59184..0ce518f84 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
+@@ -399,8 +399,11 @@ void QQuickOverlay::itemChange(ItemChange change, const ItemChangeData &data)
+     Q_D(QQuickOverlay);
+     QQuickItem::itemChange(change, data);
+ 
+-    if (change == ItemChildAddedChange || change == ItemChildRemovedChange)
++    if (change == ItemChildAddedChange || change == ItemChildRemovedChange) {
+         setVisible(!d->allDrawers.isEmpty() || !childItems().isEmpty());
++        if (data.item->parent() == d->mouseGrabberPopup)
++            d->setMouseGrabberPopup(nullptr);
++    }
+ }
+ 
+ void QQuickOverlay::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp b/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
+index 4e2f509db..1c4b308cd 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
+@@ -797,6 +797,14 @@ void QQuickScrollBarAttachedPrivate::initHorizontal()
+     if (parent && parent == flickable->parentItem())
+         horizontal->stackAfter(flickable);
+ 
++    // If a scroll bar was previously hidden (due to e.g. setting a new contentItem
++    // on a ScrollView), we need to make sure that we un-hide it.
++    // We don't bother checking if the item is actually the old one, because
++    // if it's not, all of the things the function does (setting parent, visibility, etc.)
++    // should be no-ops anyway.
++    if (auto control = qobject_cast<QQuickControl*>(q_ptr->parent()))
++        QQuickControlPrivate::unhideOldItem(control, horizontal);
++
+     layoutHorizontal();
+     horizontal->setSize(area->property("widthRatio").toReal());
+     horizontal->setPosition(area->property("xPosition").toReal());
+@@ -818,6 +826,9 @@ void QQuickScrollBarAttachedPrivate::initVertical()
+     if (parent && parent == flickable->parentItem())
+         vertical->stackAfter(flickable);
+ 
++    if (auto control = qobject_cast<QQuickControl*>(q_ptr->parent()))
++        QQuickControlPrivate::unhideOldItem(control, vertical);
++
+     layoutVertical();
+     vertical->setSize(area->property("heightRatio").toReal());
+     vertical->setPosition(area->property("yPosition").toReal());
+diff --git a/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml b/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
+index 0e8b08352..cd4931184 100644
+--- a/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
++++ b/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
+@@ -576,4 +576,51 @@ TestCase {
+         verify(newHorizontalScrollBar.visible)
+         verify(!oldHorizontalScrollBar.visible)
+     }
++
++    Component {
++        id: bindingToContentItemAndStandaloneFlickable
++
++        Item {
++            width: 200
++            height: 200
++
++            property alias scrollView: scrollView
++
++            ScrollView {
++                id: scrollView
++                anchors.fill: parent
++                contentItem: listView
++
++                property Item someBinding: contentItem
++            }
++            ListView {
++                id: listView
++                model: 10
++                delegate: ItemDelegate {
++                    text: modelData
++                    width: listView.width
++                }
++            }
++        }
++    }
++
++    // Tests that scroll bars show up for a ScrollView where
++    // - its contentItem is declared as a standalone, separate item
++    // - there is a binding to contentItem (which causes a default Flickable to be created)
++    function test_bindingToContentItemAndStandaloneFlickable() {
++        let root = createTemporaryObject(bindingToContentItemAndStandaloneFlickable, testCase)
++        verify(root)
++
++        let control = root.scrollView
++        let verticalScrollBar = control.ScrollBar.vertical
++        let horizontalScrollBar = control.ScrollBar.horizontal
++        compare(verticalScrollBar.parent, control)
++        compare(horizontalScrollBar.parent, control)
++        verify(verticalScrollBar.visible)
++        verify(horizontalScrollBar.visible)
++
++        mouseDrag(verticalScrollBar, verticalScrollBar.width / 2, verticalScrollBar.height / 2, 0, 50)
++        verify(verticalScrollBar.active)
++        verify(horizontalScrollBar.active)
++    }
+ }
+diff --git a/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml b/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
+index b3fab41ca..10b6baa02 100644
+--- a/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
++++ b/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
+@@ -608,4 +608,27 @@ TestCase {
+         mouseClick(control.indicator)
+         verify(control.activeFocus)
+     }
++
++    Component {
++        id: deletionOrder1
++        Item {
++            Image { id: innerImage }
++            Switch { indicator: innerImage }
++        }
++    }
++
++    Component {
++        id: deletionOrder2
++        Item {
++            Switch { indicator: innerImage }
++            Image { id: innerImage }
++        }
++    }
++
++    function test_deletionOrder() {
++        var control1 = createTemporaryObject(deletionOrder1, testCase)
++        verify(control1)
++        var control2 = createTemporaryObject(deletionOrder2, testCase)
++        verify(control2)
++    }
+ }
+diff --git a/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml b/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml
+new file mode 100644
+index 000000000..9e4598b9f
+--- /dev/null
++++ b/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml
+@@ -0,0 +1,78 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the test suite of the Qt Toolkit.
++**
++** $QT_BEGIN_LICENSE:BSD$
++** Commercial License Usage
++** Licensees holding valid commercial Qt licenses may use this file in
++** accordance with the commercial license agreement provided with the
++** Software or, alternatively, in accordance with the terms contained in
++** a written agreement between you and The Qt Company. For licensing terms
++** and conditions see https://www.qt.io/terms-conditions. For further
++** information use the contact form at https://www.qt.io/contact-us.
++**
++** BSD License Usage
++** Alternatively, you may use this file under the terms of the BSD license
++** as follows:
++**
++** "Redistribution and use in source and binary forms, with or without
++** modification, are permitted provided that the following conditions are
++** met:
++**   * Redistributions of source code must retain the above copyright
++**     notice, this list of conditions and the following disclaimer.
++**   * Redistributions in binary form must reproduce the above copyright
++**     notice, this list of conditions and the following disclaimer in
++**     the documentation and/or other materials provided with the
++**     distribution.
++**   * Neither the name of The Qt Company Ltd nor the names of its
++**     contributors may be used to endorse or promote products derived
++**     from this software without specific prior written permission.
++**
++**
++** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
++** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
++** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
++** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
++** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
++** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
++** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
++** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
++** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
++** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
++** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
++**
++** $QT_END_LICENSE$
++**
++****************************************************************************/
++
++import QtQuick 2.15
++import QtQuick.Controls 2.15
++
++ApplicationWindow {
++    id: window
++    width: 400
++    height: 400
++    title: "releaseAfterExitTransition"
++
++    property alias popup: popup
++    property alias modalPopup: modalPopup
++
++    Popup {
++        id: popup
++        y: parent.height - height
++        width: 50
++        height: 50
++    }
++
++    Popup {
++        id: modalPopup
++        modal: true
++        y: parent.height - height
++        width: 50
++        height: 50
++        exit:  Transition { PauseAnimation { duration: 100 } }
++    }
++}
+diff --git a/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp b/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
+index 54952d128..3d50e2dd4 100644
+--- a/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
++++ b/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
+@@ -100,6 +100,7 @@ private slots:
+     void invisibleToolTipOpen();
+     void centerInOverlayWithinStackViewItem();
+     void destroyDuringExitTransition();
++    void releaseAfterExitTransition();
+ };
+ 
+ void tst_QQuickPopup::initTestCase()
+@@ -1575,6 +1576,34 @@ void tst_QQuickPopup::destroyDuringExitTransition()
+     QVERIFY(!button->isDown());
+ }
+ 
++void tst_QQuickPopup::releaseAfterExitTransition()
++{
++    QQuickApplicationHelper helper(this, "releaseAfterExitTransition.qml");
++    QVERIFY2(helper.ready, helper.failureMessage());
++
++    QQuickWindow *window = helper.window;
++    window->show();
++    QVERIFY(QTest::qWaitForWindowActive(window));
++
++    QQuickOverlay *overlay = QQuickOverlay::overlay(window);
++    QQuickPopup *modalPopup = window->property("modalPopup").value<QQuickPopup *>();
++    QQuickPopup *popup = window->property("popup").value<QQuickPopup *>();
++
++    modalPopup->open();
++    QTRY_VERIFY(modalPopup->isOpened());
++
++    QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++    // wait until the transition is finished and the overlay hides itself
++    QTRY_VERIFY(!overlay->isVisible());
++    QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++
++    popup->open();
++    QTRY_VERIFY(popup->isOpened());
++    QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++    QTRY_VERIFY(!popup->isOpened());
++}
++
++
+ QTEST_QUICKCONTROLS_MAIN(tst_QQuickPopup)
+ 
+ #include "tst_qquickpopup.moc"
+Submodule qtscript 5be95f96...4d8e4bd2 (commits not present)
+Submodule qtspeech 17fc9fde..255845e2:
+diff --git a/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp b/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
+index 6eb74b8..bcc7dd1 100644
+--- a/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
++++ b/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
+@@ -357,7 +357,9 @@ QVector<QLocale> QTextToSpeechEngineSpeechd::availableLocales() const
+ 
+ QVector<QVoice> QTextToSpeechEngineSpeechd::availableVoices() const
+ {
+-    return m_voices.values(m_currentLocale.name()).toVector();
++    QList<QVoice> resultList = m_voices.values(m_currentLocale.name());
++    std::reverse(resultList.begin(), resultList.end());
++    return resultList.toVector();
+ }
+ 
+ // We have no way of knowing our own client_id since speech-dispatcher seems to be incomplete
+Submodule qtsvg 0c05780e..a7a0f249:
+diff --git a/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp b/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
+index 561e77e..12e0574 100644
+--- a/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
++++ b/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
+@@ -191,6 +191,8 @@ bool QSvgIOHandler::read(QImage *image)
+             }
+         }
+         if (!finalSize.isEmpty()) {
++            if (qMax(finalSize.width(), finalSize.height()) > 0xffff)
++                return false; // Assume corrupted file
+             image->fill(d->backColor.rgba());
+             QPainter p(image);
+             d->r.render(&p, bounds);
+diff --git a/qtsvg/src/svg/qsvghandler.cpp b/qtsvg/src/svg/qsvghandler.cpp
+index a5f877f..8dda563 100644
+--- a/qtsvg/src/svg/qsvghandler.cpp
++++ b/qtsvg/src/svg/qsvghandler.cpp
+@@ -1393,9 +1393,10 @@ static void parseFont(QSvgNode *node,
+         case FontSizeNone:
+             break;
+         case FontSizeValue: {
+-            QSvgHandler::LengthType dummy; // should always be pixel size
+-            fontStyle->setSize(qMin(parseLength(attributes.fontSize, dummy, handler),
+-                                    qreal(0xffff)));
++            QSvgHandler::LengthType type;
++            qreal fs = parseLength(attributes.fontSize, type, handler);
++            fs = convertToPixels(fs, true, type);
++            fontStyle->setSize(qMin(fs, qreal(0xffff)));
+         }
+             break;
+         default:
+@@ -2513,6 +2514,8 @@ static bool parseAnimateTransformNode(QSvgNode *parent,
+             ++s;
+         }
+     }
++    if (vals.count() % 3 != 0)
++        return false;
+ 
+     bool ok = true;
+     int begin = parseClockValue(beginStr, &ok);
+@@ -2576,6 +2579,8 @@ static QSvgNode *createCircleNode(QSvgNode *parent,
+     qreal ncx = toDouble(cx);
+     qreal ncy = toDouble(cy);
+     qreal nr  = toDouble(r);
++    if (nr < 0.0)
++        return nullptr;
+ 
+     QRectF rect(ncx-nr, ncy-nr, nr*2, nr*2);
+     QSvgNode *circle = new QSvgCircle(parent, rect);
+@@ -3046,15 +3051,16 @@ static QSvgStyleProperty *createRadialGradientNode(QSvgNode *node,
+ 
+     qreal ncx = 0.5;
+     qreal ncy = 0.5;
+-    qreal nr  = 0.5;
+     if (!cx.isEmpty())
+         ncx = toDouble(cx);
+     if (!cy.isEmpty())
+         ncy = toDouble(cy);
++
++    qreal nr = 0.0;
+     if (!r.isEmpty())
+         nr = toDouble(r);
+-    if (nr < 0.5)
+-        nr = 0.5;
++    if (nr <= 0.0)
++        return nullptr;
+ 
+     qreal nfx = ncx;
+     if (!fx.isEmpty())
+@@ -3350,7 +3356,9 @@ static QSvgNode *createTextNode(QSvgNode *parent,
+     //### editable and rotate not handled
+     QSvgHandler::LengthType type;
+     qreal nx = parseLength(x, type, handler);
++    nx = convertToPixels(nx, true, type);
+     qreal ny = parseLength(y, type, handler);
++    ny = convertToPixels(ny, true, type);
+ 
+     QSvgNode *text = new QSvgText(parent, QPointF(nx, ny));
+     return text;
+@@ -3691,9 +3699,7 @@ void QSvgHandler::parse()
+         case QXmlStreamReader::EndElement:
+             endElement(xml->name());
+             ++remainingUnfinishedElements;
+-            // if we are using somebody else's qxmlstreamreader
+-            // we should not read until the end of the stream
+-            done = !m_ownsReader && (xml->name() == QLatin1String("svg"));
++            done = (xml->name() == QLatin1String("svg"));
+             break;
+         case QXmlStreamReader::Characters:
+             characters(xml->text());
+diff --git a/qtsvg/src/svg/qsvgstructure.cpp b/qtsvg/src/svg/qsvgstructure.cpp
+index b89608b..89c9e4e 100644
+--- a/qtsvg/src/svg/qsvgstructure.cpp
++++ b/qtsvg/src/svg/qsvgstructure.cpp
+@@ -255,9 +255,13 @@ inline static bool isSupportedSvgFeature(const QString &str)
+     };
+ 
+     if (str.length() <= MAX_WORD_LENGTH && str.length() >= MIN_WORD_LENGTH) {
++        const char16_t unicode44 = str.at(44).unicode();
++        const char16_t unicode45 = str.at(45).unicode();
++        if (unicode44 >= sizeof(asso_values) || unicode45 >= sizeof(asso_values))
++            return false;
+         const int key = str.length()
+-                        + asso_values[str.at(45).unicode()]
+-                        + asso_values[str.at(44).unicode()];
++                        + asso_values[unicode45]
++                        + asso_values[unicode44];
+         if (key <= MAX_HASH_VALUE && key >= 0)
+             return str == QLatin1String(wordlist[key]);
+     }
+diff --git a/qtsvg/src/svg/qsvgtinydocument.cpp b/qtsvg/src/svg/qsvgtinydocument.cpp
+index 63d0797..19e7154 100644
+--- a/qtsvg/src/svg/qsvgtinydocument.cpp
++++ b/qtsvg/src/svg/qsvgtinydocument.cpp
+@@ -433,8 +433,16 @@ void QSvgTinyDocument::draw(QPainter *p, QSvgExtraStates &)
+     draw(p);
+ }
+ 
++static bool isValidMatrix(const QTransform &transform)
++{
++    qreal determinant = transform.determinant();
++    return qIsFinite(determinant);
++}
++
+ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect, const QRectF &sourceRect)
+ {
++    QTransform oldTransform = p->worldTransform();
++
+     QRectF target = targetRect;
+     if (target.isEmpty()) {
+         QPaintDevice *dev = p->device();
+@@ -487,6 +495,9 @@ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect,
+         }
+ #endif
+     }
++
++    if (!isValidMatrix(p->worldTransform()))
++        p->setWorldTransform(oldTransform);
+ }
+ 
+ QRectF QSvgTinyDocument::boundsOnElement(const QString &id) const
+diff --git a/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp b/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
+index 36c76ec..db71e02 100644
+--- a/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
++++ b/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
+@@ -86,6 +86,8 @@ private slots:
+     void oss_fuzz_23731();
+     void oss_fuzz_24131();
+     void oss_fuzz_24738();
++    void illegalAnimateTransform_data();
++    void illegalAnimateTransform();
+ 
+ #ifndef QT_NO_COMPRESS
+     void testGzLoading();
+@@ -1646,5 +1648,22 @@ void tst_QSvgRenderer::oss_fuzz_24738()
+     QSvgRenderer().load(QByteArray("<svg><path d=\"a 2 1e-212.....\">"));
+ }
+ 
++void tst_QSvgRenderer::illegalAnimateTransform_data()
++{
++    QTest::addColumn<QByteArray>("svg");
++
++    QTest::newRow("case1") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" values=\"8,0,5,0\">");
++    QTest::newRow("case2") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" values=\"1,2\">");
++    QTest::newRow("case3") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" from=\".. 5 2\" to=\"f\">");
++    QTest::newRow("case4") << QByteArray("<svg><animateTransform type=\"scale\" begin=\"1\" dur=\"2\" by=\"--,..\">");
++}
++
++void tst_QSvgRenderer::illegalAnimateTransform()
++{
++    QFETCH(QByteArray, svg);
++    QSvgRenderer renderer;
++    QVERIFY(!renderer.load(svg)); // also shouldn't assert
++}
++
+ QTEST_MAIN(tst_QSvgRenderer)
+ #include "tst_qsvgrenderer.moc"
+Submodule qttools 6914f7c8..090e526e:
+diff --git a/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp b/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
+index feab1e2d5..cbfb82507 100644
+--- a/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
++++ b/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
+@@ -445,7 +445,9 @@ bool HelpGeneratorPrivate::insertFiles(const QStringList &files, const QString &
+     if (filterSetId < 0)
+         return false;
+     ++filterSetId;
+-    for (int attId : qAsConst(filterAtts)) {
++    QList<int> attValues = filterAtts.values();
++    std::sort(attValues.begin(), attValues.end());
++    for (int attId : qAsConst(attValues)) {
+         m_query->prepare(QLatin1String("INSERT INTO FileAttributeSetTable "
+             "VALUES(?, ?)"));
+         m_query->bindValue(0, filterSetId);
+Submodule qtwayland dfb0129c..2904e1b3:
+diff --git a/qtwayland/src/client/configure.json b/qtwayland/src/client/configure.json
+index 2f424580..29222357 100644
+--- a/qtwayland/src/client/configure.json
++++ b/qtwayland/src/client/configure.json
+@@ -149,8 +149,7 @@
+                     "#endif"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "vulkan-server-buffer": {
+             "label": "Vulkan Buffer Sharing",
+@@ -168,7 +167,8 @@
+                     "exportAllocInfo.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR;",
+                     "return 0;"
+                 ]
+-            }
++            },
++            "use": "wayland-client"
+         },
+         "egl_1_5-wayland": {
+             "label": "EGL 1.5 with Wayland Platform",
+@@ -183,7 +183,7 @@
+                     "eglGetPlatformDisplay(EGL_PLATFORM_WAYLAND_EXT, (struct wl_display *)(nullptr), nullptr);"
+                 ]
+             },
+-            "use": "egl"
++            "use": "egl wayland-client"
+         }
+     },
+ 
+diff --git a/qtwayland/src/client/global/qwaylandclientextension.cpp b/qtwayland/src/client/global/qwaylandclientextension.cpp
+index 125b1e19..edccfe63 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension.cpp
++++ b/qtwayland/src/client/global/qwaylandclientextension.cpp
+@@ -74,7 +74,10 @@ void QWaylandClientExtensionPrivate::handleRegistryGlobal(void *data, ::wl_regis
+ void QWaylandClientExtension::addRegistryListener()
+ {
+     Q_D(QWaylandClientExtension);
+-    d->waylandIntegration->display()->addRegistryListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++    if (!d->registered) {
++        d->waylandIntegration->display()->addRegistryListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++        d->registered = true;
++    }
+ }
+ 
+ QWaylandClientExtension::QWaylandClientExtension(const int ver)
+@@ -88,6 +91,13 @@ QWaylandClientExtension::QWaylandClientExtension(const int ver)
+     QMetaObject::invokeMethod(this, "addRegistryListener", Qt::QueuedConnection);
+ }
+ 
++QWaylandClientExtension::~QWaylandClientExtension()
++{
++    Q_D(QWaylandClientExtension);
++    if (d->registered && !QCoreApplication::closingDown())
++        d->waylandIntegration->display()->removeListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++}
++
+ QtWaylandClient::QWaylandIntegration *QWaylandClientExtension::integration() const
+ {
+     Q_D(const QWaylandClientExtension);
+diff --git a/qtwayland/src/client/global/qwaylandclientextension.h b/qtwayland/src/client/global/qwaylandclientextension.h
+index 98272e57..5bd28398 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension.h
++++ b/qtwayland/src/client/global/qwaylandclientextension.h
+@@ -63,6 +63,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandClientExtension : public QObject
+     Q_PROPERTY(bool active READ isActive NOTIFY activeChanged)
+ public:
+     QWaylandClientExtension(const int version);
++    ~QWaylandClientExtension();
+ 
+     QtWaylandClient::QWaylandIntegration *integration() const;
+     int version() const;
+diff --git a/qtwayland/src/client/global/qwaylandclientextension_p.h b/qtwayland/src/client/global/qwaylandclientextension_p.h
+index 69cc46a0..9091efbe 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension_p.h
++++ b/qtwayland/src/client/global/qwaylandclientextension_p.h
+@@ -68,6 +68,7 @@ public:
+     QtWaylandClient::QWaylandIntegration *waylandIntegration = nullptr;
+     int version = -1;
+     bool active = false;
++    bool registered = false;
+ };
+ 
+ class Q_WAYLAND_CLIENT_EXPORT QWaylandClientExtensionTemplatePrivate : public QWaylandClientExtensionPrivate
+diff --git a/qtwayland/src/client/qwaylanddatadevice.cpp b/qtwayland/src/client/qwaylanddatadevice.cpp
+index 7e2e3308..e3e60ed5 100644
+--- a/qtwayland/src/client/qwaylanddatadevice.cpp
++++ b/qtwayland/src/client/qwaylanddatadevice.cpp
+@@ -72,6 +72,8 @@ QWaylandDataDevice::QWaylandDataDevice(QWaylandDataDeviceManager *manager, QWayl
+ 
+ QWaylandDataDevice::~QWaylandDataDevice()
+ {
++    if (wl_data_device_get_version(object()) >= WL_DATA_DEVICE_RELEASE_SINCE_VERSION)
++        release();
+ }
+ 
+ QWaylandDataOffer *QWaylandDataDevice::selectionOffer() const
+@@ -110,7 +112,7 @@ QWaylandDataOffer *QWaylandDataDevice::dragOffer() const
+     return m_dragOffer.data();
+ }
+ 
+-bool QWaylandDataDevice::startDrag(QMimeData *mimeData, QWaylandWindow *icon)
++bool QWaylandDataDevice::startDrag(QMimeData *mimeData, Qt::DropActions supportedActions, QWaylandWindow *icon)
+ {
+     auto *seat = m_display->currentInputDevice();
+     auto *origin = seat->pointerFocus();
+@@ -123,7 +125,28 @@ bool QWaylandDataDevice::startDrag(QMimeData *mimeData, QWaylandWindow *icon)
+     }
+ 
+     m_dragSource.reset(new QWaylandDataSource(m_display->dndSelectionHandler(), mimeData));
++
++    if (wl_data_device_get_version(object()) >= 3)
++        m_dragSource->set_actions(dropActionsToWl(supportedActions));
++
+     connect(m_dragSource.data(), &QWaylandDataSource::cancelled, this, &QWaylandDataDevice::dragSourceCancelled);
++    connect(m_dragSource.data(), &QWaylandDataSource::dndResponseUpdated, this, [this](bool accepted, Qt::DropAction action) {
++            auto drag = static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag());
++            // in old versions drop action is not set, so we guess
++            if (wl_data_source_get_version(m_dragSource->object()) < 3) {
++                drag->setResponse(accepted);
++            } else {
++                QPlatformDropQtResponse response(accepted, action);
++                drag->setResponse(response);
++            }
++    });
++    connect(m_dragSource.data(), &QWaylandDataSource::dndDropped, this, [](bool accepted, Qt::DropAction action) {
++        QPlatformDropQtResponse response(accepted, action);
++        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setDropResponse(response);
++    });
++    connect(m_dragSource.data(), &QWaylandDataSource::finished, this, []() {
++        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag();
++    });
+ 
+     start_drag(m_dragSource->object(), origin->wlSurface(), icon->wlSurface(), m_display->currentInputDevice()->serial());
+     return true;
+@@ -152,7 +175,7 @@ void QWaylandDataDevice::data_device_drop()
+         supportedActions = drag->supportedActions();
+     } else if (m_dragOffer) {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     } else {
+         return;
+     }
+@@ -162,7 +185,11 @@ void QWaylandDataDevice::data_device_drop()
+                                                                           QGuiApplication::keyboardModifiers());
+ 
+     if (drag) {
+-        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag(response);
++        auto drag =  static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag());
++        drag->setDropResponse(response);
++        drag->finishDrag();
++    } else if (m_dragOffer) {
++        m_dragOffer->finish();
+     }
+ }
+ 
+@@ -186,7 +213,7 @@ void QWaylandDataDevice::data_device_enter(uint32_t serial, wl_surface *surface,
+         supportedActions = drag->supportedActions();
+     } else if (m_dragOffer) {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     }
+ 
+     const QPlatformDragQtResponse &response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
+@@ -197,11 +224,7 @@ void QWaylandDataDevice::data_device_enter(uint32_t serial, wl_surface *surface,
+         static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setResponse(response);
+     }
+ 
+-    if (response.isAccepted()) {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, m_dragOffer->firstFormat().toUtf8().constData());
+-    } else {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, nullptr);
+-    }
++    sendResponse(supportedActions, response);
+ }
+ 
+ void QWaylandDataDevice::data_device_leave()
+@@ -235,10 +258,10 @@ void QWaylandDataDevice::data_device_motion(uint32_t time, wl_fixed_t x, wl_fixe
+         supportedActions = drag->supportedActions();
+     } else {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     }
+ 
+-    QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
++    const QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
+                                                                           QGuiApplication::mouseButtons(),
+                                                                           QGuiApplication::keyboardModifiers());
+ 
+@@ -246,11 +269,7 @@ void QWaylandDataDevice::data_device_motion(uint32_t time, wl_fixed_t x, wl_fixe
+         static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setResponse(response);
+     }
+ 
+-    if (response.isAccepted()) {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, m_dragOffer->firstFormat().toUtf8().constData());
+-    } else {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, nullptr);
+-    }
++    sendResponse(supportedActions, response);
+ }
+ #endif // QT_CONFIG(draganddrop)
+ 
+@@ -277,14 +296,10 @@ void QWaylandDataDevice::selectionSourceCancelled()
+ #if QT_CONFIG(draganddrop)
+ void QWaylandDataDevice::dragSourceCancelled()
+ {
++    static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag();
+     m_dragSource.reset();
+ }
+ 
+-void QWaylandDataDevice::dragSourceTargetChanged(const QString &mimeType)
+-{
+-    static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->updateTarget(mimeType);
+-}
+-
+ QPoint QWaylandDataDevice::calculateDragPosition(int x, int y, QWindow *wnd) const
+ {
+     QPoint pnt(wl_fixed_to_int(x), wl_fixed_to_int(y));
+@@ -297,6 +312,33 @@ QPoint QWaylandDataDevice::calculateDragPosition(int x, int y, QWindow *wnd) con
+     }
+     return pnt;
+ }
++
++void QWaylandDataDevice::sendResponse(Qt::DropActions supportedActions, const QPlatformDragQtResponse &response)
++{
++    if (response.isAccepted()) {
++        if (wl_data_device_get_version(object()) >= 3)
++            m_dragOffer->set_actions(dropActionsToWl(supportedActions), dropActionsToWl(response.acceptedAction()));
++
++        m_dragOffer->accept(m_enterSerial, m_dragOffer->firstFormat());
++    } else {
++        m_dragOffer->accept(m_enterSerial, QString());
++    }
++}
++
++int QWaylandDataDevice::dropActionsToWl(Qt::DropActions actions)
++{
++
++    int wlActions = WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE;
++    if (actions & Qt::CopyAction)
++        wlActions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY;
++    if (actions & (Qt::MoveAction | Qt::TargetMoveAction))
++        wlActions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE;
++
++    // wayland does not support LinkAction at the time of writing
++    return wlActions;
++}
++
++
+ #endif // QT_CONFIG(draganddrop)
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddatadevice_p.h b/qtwayland/src/client/qwaylanddatadevice_p.h
+index 16c3ad28..801dcc2c 100644
+--- a/qtwayland/src/client/qwaylanddatadevice_p.h
++++ b/qtwayland/src/client/qwaylanddatadevice_p.h
+@@ -64,6 +64,7 @@ QT_REQUIRE_CONFIG(wayland_datadevice);
+ QT_BEGIN_NAMESPACE
+ 
+ class QMimeData;
++class QPlatformDragQtResponse;
+ class QWindow;
+ 
+ namespace QtWaylandClient {
+@@ -89,7 +90,7 @@ public:
+ 
+ #if QT_CONFIG(draganddrop)
+     QWaylandDataOffer *dragOffer() const;
+-    bool startDrag(QMimeData *mimeData, QWaylandWindow *icon);
++    bool startDrag(QMimeData *mimeData, Qt::DropActions supportedActions, QWaylandWindow *icon);
+     void cancelDrag();
+ #endif
+ 
+@@ -109,13 +110,16 @@ private Q_SLOTS:
+ 
+ #if QT_CONFIG(draganddrop)
+     void dragSourceCancelled();
+-    void dragSourceTargetChanged(const QString &mimeType);
+ #endif
+ 
+ private:
+ #if QT_CONFIG(draganddrop)
+     QPoint calculateDragPosition(int x, int y, QWindow *wnd) const;
+ #endif
++    void sendResponse(Qt::DropActions supportedActions, const QPlatformDragQtResponse &response);
++
++    static int dropActionsToWl(Qt::DropActions dropActions);
++
+ 
+     QWaylandDisplay *m_display = nullptr;
+     QWaylandInputDevice *m_inputDevice = nullptr;
+diff --git a/qtwayland/src/client/qwaylanddatadevicemanager.cpp b/qtwayland/src/client/qwaylanddatadevicemanager.cpp
+index 35d67307..6dc4f77f 100644
+--- a/qtwayland/src/client/qwaylanddatadevicemanager.cpp
++++ b/qtwayland/src/client/qwaylanddatadevicemanager.cpp
+@@ -50,8 +50,8 @@ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
+-QWaylandDataDeviceManager::QWaylandDataDeviceManager(QWaylandDisplay *display, uint32_t id)
+-    : wl_data_device_manager(display->wl_registry(), id, 1)
++QWaylandDataDeviceManager::QWaylandDataDeviceManager(QWaylandDisplay *display, int version, uint32_t id)
++    : wl_data_device_manager(display->wl_registry(), id, qMin(version, 3))
+     , m_display(display)
+ {
+     // Create transfer devices for all input devices.
+diff --git a/qtwayland/src/client/qwaylanddatadevicemanager_p.h b/qtwayland/src/client/qwaylanddatadevicemanager_p.h
+index bd05c0fb..510d9be4 100644
+--- a/qtwayland/src/client/qwaylanddatadevicemanager_p.h
++++ b/qtwayland/src/client/qwaylanddatadevicemanager_p.h
+@@ -68,7 +68,7 @@ class QWaylandInputDevice;
+ class Q_WAYLAND_CLIENT_EXPORT QWaylandDataDeviceManager : public QtWayland::wl_data_device_manager
+ {
+ public:
+-    QWaylandDataDeviceManager(QWaylandDisplay *display, uint32_t id);
++    QWaylandDataDeviceManager(QWaylandDisplay *display, int version, uint32_t id);
+     ~QWaylandDataDeviceManager() override;
+ 
+     QWaylandDataDevice *getDataDevice(QWaylandInputDevice *inputDevice);
+diff --git a/qtwayland/src/client/qwaylanddataoffer.cpp b/qtwayland/src/client/qwaylanddataoffer.cpp
+index 2297e8a1..fe0ea8c9 100644
+--- a/qtwayland/src/client/qwaylanddataoffer.cpp
++++ b/qtwayland/src/client/qwaylanddataoffer.cpp
+@@ -82,6 +82,15 @@ QMimeData *QWaylandDataOffer::mimeData()
+     return m_mimeData.data();
+ }
+ 
++Qt::DropActions QWaylandDataOffer::supportedActions() const
++{
++    if (wl_data_offer_get_version(const_cast<::wl_data_offer*>(object())) < 3) {
++        return Qt::MoveAction | Qt::CopyAction;
++    }
++
++    return m_supportedActions;
++}
++
+ void QWaylandDataOffer::startReceiving(const QString &mimeType, int fd)
+ {
+     receive(mimeType, fd);
+@@ -93,6 +102,22 @@ void QWaylandDataOffer::data_offer_offer(const QString &mime_type)
+     m_mimeData->appendFormat(mime_type);
+ }
+ 
++void QWaylandDataOffer::data_offer_action(uint32_t dnd_action)
++{
++    Q_UNUSED(dnd_action);
++    // This is the compositor telling the drag target what action it should perform
++    // It does not map nicely into Qt final drop semantics, other than pretending there is only one supported action?
++}
++
++void QWaylandDataOffer::data_offer_source_actions(uint32_t source_actions)
++{
++    m_supportedActions = Qt::DropActions();
++    if (source_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
++        m_supportedActions |= Qt::MoveAction;
++    if (source_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
++        m_supportedActions |= Qt::CopyAction;
++}
++
+ QWaylandMimeData::QWaylandMimeData(QWaylandAbstractDataOffer *dataOffer)
+     : m_dataOffer(dataOffer)
+ {
+@@ -163,17 +188,18 @@ QVariant QWaylandMimeData::retrieveData_sys(const QString &mimeType, QVariant::T
+ 
+ int QWaylandMimeData::readData(int fd, QByteArray &data) const
+ {
+-    fd_set readset;
+-    FD_ZERO(&readset);
+-    FD_SET(fd, &readset);
+-    struct timeval timeout;
++    struct pollfd readset;
++    readset.fd = fd;
++    readset.events = POLLIN;
++    struct timespec timeout;
+     timeout.tv_sec = 1;
+-    timeout.tv_usec = 0;
++    timeout.tv_nsec = 0;
++
+ 
+     Q_FOREVER {
+-        int ready = select(FD_SETSIZE, &readset, nullptr, nullptr, &timeout);
++        int ready = qt_safe_poll(&readset, 1, &timeout);
+         if (ready < 0) {
+-            qWarning() << "QWaylandDataOffer: select() failed";
++            qWarning() << "QWaylandDataOffer: qt_safe_poll() failed";
+             return -1;
+         } else if (ready == 0) {
+             qWarning("QWaylandDataOffer: timeout reading from pipe");
+diff --git a/qtwayland/src/client/qwaylanddataoffer_p.h b/qtwayland/src/client/qwaylanddataoffer_p.h
+index 9cf1483c..6f667398 100644
+--- a/qtwayland/src/client/qwaylanddataoffer_p.h
++++ b/qtwayland/src/client/qwaylanddataoffer_p.h
+@@ -82,6 +82,7 @@ public:
+     explicit QWaylandDataOffer(QWaylandDisplay *display, struct ::wl_data_offer *offer);
+     ~QWaylandDataOffer() override;
+     QMimeData *mimeData() override;
++    Qt::DropActions supportedActions() const;
+ 
+     QString firstFormat() const;
+ 
+@@ -89,10 +90,13 @@ public:
+ 
+ protected:
+     void data_offer_offer(const QString &mime_type) override;
++    void data_offer_source_actions(uint32_t source_actions) override;
++    void data_offer_action(uint32_t dnd_action) override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+     QScopedPointer<QWaylandMimeData> m_mimeData;
++    Qt::DropActions m_supportedActions;
+ };
+ 
+ 
+diff --git a/qtwayland/src/client/qwaylanddatasource.cpp b/qtwayland/src/client/qwaylanddatasource.cpp
+index f45122fb..5599cbd4 100644
+--- a/qtwayland/src/client/qwaylanddatasource.cpp
++++ b/qtwayland/src/client/qwaylanddatasource.cpp
+@@ -101,7 +101,32 @@ void QWaylandDataSource::data_source_send(const QString &mime_type, int32_t fd)
+ 
+ void QWaylandDataSource::data_source_target(const QString &mime_type)
+ {
+-    Q_EMIT targetChanged(mime_type);
++    m_accepted = !mime_type.isEmpty();
++    Q_EMIT dndResponseUpdated(m_accepted, m_dropAction);
++}
++
++void QWaylandDataSource::data_source_action(uint32_t action)
++{
++    Qt::DropAction qtAction = Qt::IgnoreAction;
++
++    if (action == WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
++        qtAction = Qt::MoveAction;
++    else if (action == WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
++        qtAction = Qt::CopyAction;
++
++    m_dropAction = qtAction;
++    Q_EMIT dndResponseUpdated(m_accepted, m_dropAction);
++}
++
++void QWaylandDataSource::data_source_dnd_finished()
++{
++    Q_EMIT finished();
++}
++
++void QWaylandDataSource::data_source_dnd_drop_performed()
++{
++
++    Q_EMIT dndDropped(m_accepted, m_dropAction);
+ }
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddatasource_p.h b/qtwayland/src/client/qwaylanddatasource_p.h
+index 25afff79..96f07bc3 100644
+--- a/qtwayland/src/client/qwaylanddatasource_p.h
++++ b/qtwayland/src/client/qwaylanddatasource_p.h
+@@ -77,17 +77,25 @@ public:
+     QMimeData *mimeData() const;
+ 
+ Q_SIGNALS:
+-    void targetChanged(const QString &mime_type);
+     void cancelled();
++    void finished();
++
++    void dndResponseUpdated(bool accepted, Qt::DropAction action);
++    void dndDropped(bool accepted, Qt::DropAction action);
+ 
+ protected:
+     void data_source_cancelled() override;
+     void data_source_send(const QString &mime_type, int32_t fd) override;
+     void data_source_target(const QString &mime_type) override;
++    void data_source_dnd_drop_performed() override;
++    void data_source_dnd_finished() override;
++    void data_source_action(uint32_t action) override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+     QMimeData *m_mime_data = nullptr;
++    bool m_accepted = false;
++    Qt::DropAction m_dropAction = Qt::IgnoreAction;
+ };
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddisplay.cpp b/qtwayland/src/client/qwaylanddisplay.cpp
+index f10c1f79..c01e238b 100644
+--- a/qtwayland/src/client/qwaylanddisplay.cpp
++++ b/qtwayland/src/client/qwaylanddisplay.cpp
+@@ -85,10 +85,203 @@
+ 
+ #include <errno.h>
+ 
++#include <tuple> // for std::tie
++
++static void checkWaylandError(struct wl_display *display)
++{
++    int ecode = wl_display_get_error(display);
++    if ((ecode == EPIPE || ecode == ECONNRESET)) {
++        // special case this to provide a nicer error
++        qWarning("The Wayland connection broke. Did the Wayland compositor die?");
++    } else {
++        qWarning("The Wayland connection experienced a fatal error: %s", strerror(ecode));
++    }
++    _exit(1);
++}
++
+ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
++class EventThread : public QThread
++{
++    Q_OBJECT
++public:
++    enum OperatingMode {
++        EmitToDispatch, // Emit the signal, allow dispatching in a differnt thread.
++        SelfDispatch, // Dispatch the events inside this thread.
++    };
++
++    EventThread(struct wl_display * wl, struct wl_event_queue * ev_queue,
++                OperatingMode mode)
++        : m_fd(wl_display_get_fd(wl))
++        , m_pipefd{ -1, -1 }
++        , m_wldisplay(wl)
++        , m_wlevqueue(ev_queue)
++        , m_mode(mode)
++        , m_reading(true)
++        , m_quitting(false)
++    {
++        setObjectName(QStringLiteral("WaylandEventThread"));
++    }
++
++    void readAndDispatchEvents()
++    {
++        /*
++         * Dispatch pending events and flush the requests at least once. If the event thread
++         * is not reading, try to call _prepare_read() to allow the event thread to poll().
++         * If that fails, re-try dispatch & flush again until _prepare_read() is successful.
++         *
++         * This allow any call to readAndDispatchEvents() to start event thread's polling,
++         * not only the one issued from event thread's waitForReading(), which means functions
++         * called from dispatch_pending() can safely spin an event loop.
++         */
++        for (;;) {
++            if (dispatchQueuePending() < 0) {
++                checkWaylandError(m_wldisplay);
++                return;
++            }
++
++            wl_display_flush(m_wldisplay);
++
++            // We have to check if event thread is reading every time we dispatch
++            // something, as that may recursively call this function.
++            if (m_reading.loadAcquire())
++                break;
++
++            if (prepareReadQueue() == 0) {
++                QMutexLocker l(&m_mutex);
++                m_reading.storeRelease(true);
++                m_cond.wakeOne();
++                break;
++            }
++        }
++    }
++
++    void stop()
++    {
++        // We have to both write to the pipe and set the flag, as the thread may be
++        // either in the poll() or waiting for _prepare_read().
++        if (m_pipefd[1] != -1 && write(m_pipefd[1], "\0", 1) == -1)
++            qWarning("Failed to write to the pipe: %s.", strerror(errno));
++
++        {
++            QMutexLocker l(&m_mutex);
++            m_quitting = true;
++            m_cond.wakeOne();
++        }
++
++        wait();
++    }
++
++Q_SIGNALS:
++    void needReadAndDispatch();
++
++protected:
++    void run() override
++    {
++        // we use this pipe to make the loop exit otherwise if we simply used a flag on the loop condition, if stop() gets
++        // called while poll() is blocking the thread will never quit since there are no wayland messages coming anymore.
++        struct Pipe
++        {
++            Pipe(int *fds)
++                : fds(fds)
++            {
++                if (qt_safe_pipe(fds) != 0)
++                    qWarning("Pipe creation failed. Quitting may hang.");
++            }
++            ~Pipe()
++            {
++                if (fds[0] != -1) {
++                    close(fds[0]);
++                    close(fds[1]);
++                }
++            }
++
++            int *fds;
++        } pipe(m_pipefd);
++
++        // Make the main thread call wl_prepare_read(), dispatch the pending messages and flush the
++        // outbound ones. Wait until it's done before proceeding, unless we're told to quit.
++        while (waitForReading()) {
++            pollfd fds[2] = { { m_fd, POLLIN, 0 }, { m_pipefd[0], POLLIN, 0 } };
++            poll(fds, 2, -1);
++
++            if (fds[1].revents & POLLIN) {
++                // we don't really care to read the byte that was written here since we're closing down
++                wl_display_cancel_read(m_wldisplay);
++                break;
++            }
++
++            if (fds[0].revents & POLLIN)
++                wl_display_read_events(m_wldisplay);
++                // The polll was succesfull and the event thread did the wl_display_read_events(). On the next iteration of the loop
++                // the event sent to the main thread will cause it to dispatch the messages just read, unless the loop exits in which
++                // case we don't care anymore about them.
++            else
++                wl_display_cancel_read(m_wldisplay);
++        }
++    }
++
++private:
++    bool waitForReading()
++    {
++        Q_ASSERT(QThread::currentThread() == this);
++
++        m_reading.storeRelease(false);
++
++        if (m_mode == SelfDispatch) {
++            readAndDispatchEvents();
++        } else {
++            Q_EMIT needReadAndDispatch();
++
++            QMutexLocker lock(&m_mutex);
++            // m_reading might be set from our emit or some other invocation of
++            // readAndDispatchEvents().
++            while (!m_reading.loadRelaxed() && !m_quitting)
++                m_cond.wait(&m_mutex);
++        }
++
++        return !m_quitting;
++    }
++
++    int dispatchQueuePending()
++    {
++        if (m_wlevqueue)
++            return wl_display_dispatch_queue_pending(m_wldisplay, m_wlevqueue);
++        else
++            return wl_display_dispatch_pending(m_wldisplay);
++    }
++
++    int prepareReadQueue()
++    {
++        if (m_wlevqueue)
++            return wl_display_prepare_read_queue(m_wldisplay, m_wlevqueue);
++        else
++            return wl_display_prepare_read(m_wldisplay);
++    }
++
++    int m_fd;
++    int m_pipefd[2];
++    wl_display *m_wldisplay;
++    wl_event_queue *m_wlevqueue;
++    OperatingMode m_mode;
++
++    /* Concurrency note when operating in EmitToDispatch mode:
++     * m_reading is set to false inside event thread's waitForReading(), and is
++     * set to true inside main thread's readAndDispatchEvents().
++     * The lock is not taken when setting m_reading to false, as the main thread
++     * is not actively waiting for it to turn false. However, the lock is taken
++     * inside readAndDispatchEvents() before setting m_reading to true,
++     * as the event thread is actively waiting for it under the wait condition.
++     */
++
++    QAtomicInteger<bool> m_reading;
++    bool m_quitting;
++    QMutex m_mutex;
++    QWaitCondition m_cond;
++};
++
+ Q_LOGGING_CATEGORY(lcQpaWayland, "qt.qpa.wayland"); // for general (uncategorized) Wayland platform logging
+ 
+ struct wl_surface *QWaylandDisplay::createSurface(void *handle)
+@@ -158,17 +351,16 @@ QWaylandDisplay::QWaylandDisplay(QWaylandIntegration *waylandIntegration)
+     if (!mXkbContext)
+         qCWarning(lcQpaWayland, "failed to create xkb context");
+ #endif
+-
+-    forceRoundTrip();
+-
+-    if (!mWaitingScreens.isEmpty()) {
+-        // Give wl_output.done and zxdg_output_v1.done events a chance to arrive
+-        forceRoundTrip();
+-    }
+ }
+ 
+ QWaylandDisplay::~QWaylandDisplay(void)
+ {
++    if (m_eventThread)
++        m_eventThread->stop();
++
++    if (m_frameEventQueueThread)
++        m_frameEventQueueThread->stop();
++
+     if (mSyncCallback)
+         wl_callback_destroy(mSyncCallback);
+ 
+@@ -187,6 +379,21 @@ QWaylandDisplay::~QWaylandDisplay(void)
+ #endif
+     if (mDisplay)
+         wl_display_disconnect(mDisplay);
++
++    if (m_frameEventQueue)
++        wl_event_queue_destroy(m_frameEventQueue);
++}
++
++// Steps which is called just after constructor. This separates registry_global() out of the constructor
++// so that factory functions in integration can be overridden.
++void QWaylandDisplay::initialize()
++{
++    forceRoundTrip();
++
++    if (!mWaitingScreens.isEmpty()) {
++        // Give wl_output.done and zxdg_output_v1.done events a chance to arrive
++        forceRoundTrip();
++    }
+ }
+ 
+ void QWaylandDisplay::ensureScreen()
+@@ -203,98 +410,37 @@ void QWaylandDisplay::ensureScreen()
+ 
+ void QWaylandDisplay::checkError() const
+ {
+-    int ecode = wl_display_get_error(mDisplay);
+-    if ((ecode == EPIPE || ecode == ECONNRESET)) {
+-        // special case this to provide a nicer error
+-        qWarning("The Wayland connection broke. Did the Wayland compositor die?");
+-    } else {
+-        qWarning("The Wayland connection experienced a fatal error: %s", strerror(ecode));
+-    }
+-    _exit(1);
++    checkWaylandError(mDisplay);
+ }
+ 
++// Called in main thread, either from queued signal or directly.
+ void QWaylandDisplay::flushRequests()
+ {
+-    if (wl_display_prepare_read(mDisplay) == 0) {
+-        wl_display_read_events(mDisplay);
+-    }
+-
+-    if (wl_display_dispatch_pending(mDisplay) < 0)
+-        checkError();
+-
+-    {
+-        QReadLocker locker(&m_frameQueueLock);
+-        for (const FrameQueue &q : mExternalQueues) {
+-            QMutexLocker locker(q.mutex);
+-            while (wl_display_prepare_read_queue(mDisplay, q.queue) != 0)
+-                wl_display_dispatch_queue_pending(mDisplay, q.queue);
+-            wl_display_read_events(mDisplay);
+-            wl_display_dispatch_queue_pending(mDisplay, q.queue);
+-        }
+-    }
+-
+-    wl_display_flush(mDisplay);
+-}
+-
+-void QWaylandDisplay::blockingReadEvents()
+-{
+-    if (wl_display_dispatch(mDisplay) < 0)
+-        checkError();
+-}
+-
+-void QWaylandDisplay::destroyFrameQueue(const QWaylandDisplay::FrameQueue &q)
+-{
+-    QWriteLocker locker(&m_frameQueueLock);
+-    auto it = std::find_if(mExternalQueues.begin(),
+-                           mExternalQueues.end(),
+-                           [&q] (const QWaylandDisplay::FrameQueue &other){ return other.queue == q.queue; });
+-    Q_ASSERT(it != mExternalQueues.end());
+-    mExternalQueues.erase(it);
+-    if (q.queue != nullptr)
+-        wl_event_queue_destroy(q.queue);
+-    delete q.mutex;
++    m_eventThread->readAndDispatchEvents();
+ }
+ 
+-QWaylandDisplay::FrameQueue QWaylandDisplay::createFrameQueue()
++// We have to wait until we have an eventDispatcher before creating the eventThread,
++// otherwise forceRoundTrip() may block inside _events_read() because eventThread is
++// polling.
++void QWaylandDisplay::initEventThread()
+ {
+-    QWriteLocker locker(&m_frameQueueLock);
+-    FrameQueue q{createEventQueue()};
+-    mExternalQueues.append(q);
+-    return q;
+-}
++    m_eventThread.reset(
++            new EventThread(mDisplay, /* default queue */ nullptr, EventThread::EmitToDispatch));
++    connect(m_eventThread.get(), &EventThread::needReadAndDispatch, this,
++            &QWaylandDisplay::flushRequests, Qt::QueuedConnection);
++    m_eventThread->start();
+ 
+-wl_event_queue *QWaylandDisplay::createEventQueue()
+-{
+-    return wl_display_create_queue(mDisplay);
++    // wl_display_disconnect() free this.
++    m_frameEventQueue = wl_display_create_queue(mDisplay);
++    m_frameEventQueueThread.reset(
++            new EventThread(mDisplay, m_frameEventQueue, EventThread::SelfDispatch));
++    m_frameEventQueueThread->start();
+ }
+ 
+-void QWaylandDisplay::dispatchQueueWhile(wl_event_queue *queue, std::function<bool ()> condition, int timeout)
++void QWaylandDisplay::blockingReadEvents()
+ {
+-    if (!condition())
+-        return;
+-
+-    QElapsedTimer timer;
+-    timer.start();
+-    struct pollfd pFd = qt_make_pollfd(wl_display_get_fd(mDisplay), POLLIN);
+-    while (timeout == -1 || timer.elapsed() < timeout) {
+-        while (wl_display_prepare_read_queue(mDisplay, queue) != 0)
+-            wl_display_dispatch_queue_pending(mDisplay, queue);
+-
+-        wl_display_flush(mDisplay);
+-
+-        const int remaining = qMax(timeout - timer.elapsed(), 0ll);
+-        const int pollTimeout = timeout == -1 ? -1 : remaining;
+-        if (qt_poll_msecs(&pFd, 1, pollTimeout) > 0)
+-            wl_display_read_events(mDisplay);
+-        else
+-            wl_display_cancel_read(mDisplay);
+-
+-        if (wl_display_dispatch_queue_pending(mDisplay, queue) < 0)
+-            checkError();
+-
+-        if (!condition())
+-            break;
+-    }
++    if (wl_display_dispatch(mDisplay) < 0)
++        checkWaylandError(mDisplay);
+ }
+ 
+ QWaylandScreen *QWaylandDisplay::screenForOutput(struct wl_output *output) const
+@@ -345,7 +491,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+     if (interface == QStringLiteral("wl_output")) {
+         mWaitingScreens << new QWaylandScreen(this, version, id);
+     } else if (interface == QStringLiteral("wl_compositor")) {
+-        mCompositorVersion = qMin((int)version, 3);
++        mCompositorVersion = qMin((int)version, 4);
+         mCompositor.init(registry, id, mCompositorVersion);
+     } else if (interface == QStringLiteral("wl_shm")) {
+         mShm.reset(new QWaylandShm(this, version, id));
+@@ -354,7 +500,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+         mInputDevices.append(inputDevice);
+ #if QT_CONFIG(wayland_datadevice)
+     } else if (interface == QStringLiteral("wl_data_device_manager")) {
+-        mDndSelectionHandler.reset(new QWaylandDataDeviceManager(this, id));
++        mDndSelectionHandler.reset(new QWaylandDataDeviceManager(this, version, id));
+ #endif
+     } else if (interface == QStringLiteral("qt_surface_extension")) {
+         mWindowExtension.reset(new QtWayland::qt_surface_extension(registry, id, 1));
+@@ -369,6 +515,8 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+ #if QT_CONFIG(wayland_client_primary_selection)
+     } else if (interface == QStringLiteral("zwp_primary_selection_device_manager_v1")) {
+         mPrimarySelectionManager.reset(new QWaylandPrimarySelectionDeviceManagerV1(this, id, 1));
++        for (QWaylandInputDevice *inputDevice : qAsConst(mInputDevices))
++            inputDevice->setPrimarySelectionDevice(mPrimarySelectionManager->createDevice(inputDevice));
+ #endif
+     } else if (interface == QStringLiteral("zwp_text_input_manager_v2") && !mClientSideInputContextRequested) {
+         mTextInputManager.reset(new QtWayland::zwp_text_input_manager_v2(registry, id, 1));
+@@ -427,6 +575,13 @@ void QWaylandDisplay::registry_global_remove(uint32_t id)
+                     inputDevice->setTextInput(nullptr);
+                 mWaylandIntegration->reconfigureInputContext();
+             }
++#if QT_CONFIG(wayland_client_primary_selection)
++            if (global.interface == QStringLiteral("zwp_primary_selection_device_manager_v1")) {
++                mPrimarySelectionManager.reset();
++                for (QWaylandInputDevice *inputDevice : qAsConst(mInputDevices))
++                    inputDevice->setPrimarySelectionDevice(nullptr);
++            }
++#endif
+             mGlobals.removeAt(i);
+             break;
+         }
+@@ -452,9 +607,10 @@ void QWaylandDisplay::addRegistryListener(RegistryListener listener, void *data)
+ 
+ void QWaylandDisplay::removeListener(RegistryListener listener, void *data)
+ {
+-    std::remove_if(mRegistryListeners.begin(), mRegistryListeners.end(), [=](Listener l){
++    auto iter = std::remove_if(mRegistryListeners.begin(), mRegistryListeners.end(), [=](Listener l){
+         return (l.listener == listener && l.data == data);
+     });
++    mRegistryListeners.erase(iter, mRegistryListeners.end());
+ }
+ 
+ uint32_t QWaylandDisplay::currentTimeMillisec()
+@@ -467,50 +623,9 @@ uint32_t QWaylandDisplay::currentTimeMillisec()
+     return 0;
+ }
+ 
+-static void
+-sync_callback(void *data, struct wl_callback *callback, uint32_t serial)
+-{
+-    Q_UNUSED(serial)
+-    bool *done = static_cast<bool *>(data);
+-
+-    *done = true;
+-
+-    // If the wl_callback done event is received after the condition check in the while loop in
+-    // forceRoundTrip(), but before the call to processEvents, the call to processEvents may block
+-    // forever if no more events are posted (eventhough the callback is handled in response to the
+-    // aboutToBlock signal). Hence, we wake up the event dispatcher so forceRoundTrip may return.
+-    // (QTBUG-64696)
+-    if (auto *dispatcher = QThread::currentThread()->eventDispatcher())
+-        dispatcher->wakeUp();
+-
+-    wl_callback_destroy(callback);
+-}
+-
+-static const struct wl_callback_listener sync_listener = {
+-    sync_callback
+-};
+-
+ void QWaylandDisplay::forceRoundTrip()
+ {
+-    // wl_display_roundtrip() works on the main queue only,
+-    // but we use a separate one, so basically reimplement it here
+-    int ret = 0;
+-    bool done = false;
+-    wl_callback *callback = wl_display_sync(mDisplay);
+-    wl_callback_add_listener(callback, &sync_listener, &done);
+-    flushRequests();
+-    if (QThread::currentThread()->eventDispatcher()) {
+-        while (!done && ret >= 0) {
+-            QThread::currentThread()->eventDispatcher()->processEvents(QEventLoop::WaitForMoreEvents);
+-            ret = wl_display_dispatch_pending(mDisplay);
+-        }
+-    } else {
+-        while (!done && ret >= 0)
+-            ret = wl_display_dispatch(mDisplay);
+-    }
+-
+-    if (ret == -1 && !done)
+-        wl_callback_destroy(callback);
++     wl_display_roundtrip(mDisplay);
+ }
+ 
+ bool QWaylandDisplay::supportsWindowDecoration() const
+@@ -574,14 +689,10 @@ void QWaylandDisplay::handleKeyboardFocusChanged(QWaylandInputDevice *inputDevic
+     if (mLastKeyboardFocus == keyboardFocus)
+         return;
+ 
+-    if (mWaylandIntegration->mShellIntegration) {
+-        mWaylandIntegration->mShellIntegration->handleKeyboardFocusChanged(keyboardFocus, mLastKeyboardFocus);
+-    } else {
+-        if (keyboardFocus)
+-            handleWindowActivated(keyboardFocus);
+-        if (mLastKeyboardFocus)
+-            handleWindowDeactivated(mLastKeyboardFocus);
+-    }
++    if (keyboardFocus)
++        handleWindowActivated(keyboardFocus);
++    if (mLastKeyboardFocus)
++        handleWindowDeactivated(mLastKeyboardFocus);
+ 
+     mLastKeyboardFocus = keyboardFocus;
+ }
+@@ -600,6 +711,19 @@ void QWaylandDisplay::handleWaylandSync()
+     QWindow *activeWindow = mActiveWindows.empty() ? nullptr : mActiveWindows.last()->window();
+     if (activeWindow != QGuiApplication::focusWindow())
+         QWindowSystemInterface::handleWindowActivated(activeWindow);
++
++    if (!activeWindow) {
++        if (lastInputDevice()) {
++#if QT_CONFIG(clipboard)
++            if (auto *dataDevice = lastInputDevice()->dataDevice())
++                dataDevice->invalidateSelectionOffer();
++#endif
++#if QT_CONFIG(wayland_client_primary_selection)
++            if (auto *device = lastInputDevice()->primarySelectionDevice())
++                device->invalidateSelectionOffer();
++#endif
++        }
++    }
+ }
+ 
+ const wl_callback_listener QWaylandDisplay::syncCallbackListener = {
+@@ -626,6 +750,13 @@ QWaylandInputDevice *QWaylandDisplay::defaultInputDevice() const
+     return mInputDevices.isEmpty() ? 0 : mInputDevices.first();
+ }
+ 
++bool QWaylandDisplay::isKeyboardAvailable() const
++{
++    return std::any_of(
++            mInputDevices.constBegin(), mInputDevices.constEnd(),
++            [this](const QWaylandInputDevice *device) { return device->keyboard() != nullptr; });
++}
++
+ #if QT_CONFIG(cursor)
+ 
+ QWaylandCursor *QWaylandDisplay::waylandCursor()
+@@ -652,4 +783,6 @@ QWaylandCursorTheme *QWaylandDisplay::loadCursorTheme(const QString &name, int p
+ 
+ } // namespace QtWaylandClient
+ 
++#include "qwaylanddisplay.moc"
++
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/client/qwaylanddisplay_p.h b/qtwayland/src/client/qwaylanddisplay_p.h
+index 3b092bc8..42bc661d 100644
+--- a/qtwayland/src/client/qwaylanddisplay_p.h
++++ b/qtwayland/src/client/qwaylanddisplay_p.h
+@@ -109,6 +109,7 @@ class QWaylandSurface;
+ class QWaylandShellIntegration;
+ class QWaylandCursor;
+ class QWaylandCursorTheme;
++class EventThread;
+ 
+ typedef void (*RegistryListener)(void *data,
+                                  struct wl_registry *registry,
+@@ -120,15 +121,11 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandDisplay : public QObject, public QtWayland
+     Q_OBJECT
+ 
+ public:
+-    struct FrameQueue {
+-        FrameQueue(wl_event_queue *q = nullptr) : queue(q), mutex(new QMutex) {}
+-        wl_event_queue *queue;
+-        QMutex *mutex;
+-    };
+-
+     QWaylandDisplay(QWaylandIntegration *waylandIntegration);
+     ~QWaylandDisplay(void) override;
+ 
++    void initialize();
++
+ #if QT_CONFIG(xkbcommon)
+     struct xkb_context *xkbContext() const { return mXkbContext.get(); }
+ #endif
+@@ -210,11 +207,11 @@ public:
+     void handleKeyboardFocusChanged(QWaylandInputDevice *inputDevice);
+     void handleWindowDestroyed(QWaylandWindow *window);
+ 
+-    wl_event_queue *createEventQueue();
+-    FrameQueue createFrameQueue();
+-    void destroyFrameQueue(const FrameQueue &q);
+-    void dispatchQueueWhile(wl_event_queue *queue, std::function<bool()> condition, int timeout = -1);
++    wl_event_queue *frameEventQueue() { return m_frameEventQueue; };
++
++    bool isKeyboardAvailable() const;
+ 
++    void initEventThread();
+ public slots:
+     void blockingReadEvents();
+     void flushRequests();
+@@ -237,6 +234,9 @@ private:
+     };
+ 
+     struct wl_display *mDisplay = nullptr;
++    QScopedPointer<EventThread> m_eventThread;
++    wl_event_queue *m_frameEventQueue = nullptr;
++    QScopedPointer<EventThread> m_frameEventQueueThread;
+     QtWayland::wl_compositor mCompositor;
+     QScopedPointer<QWaylandShm> mShm;
+     QList<QWaylandScreen *> mWaitingScreens;
+@@ -273,11 +273,9 @@ private:
+     QWaylandInputDevice *mLastInputDevice = nullptr;
+     QPointer<QWaylandWindow> mLastInputWindow;
+     QPointer<QWaylandWindow> mLastKeyboardFocus;
+-    QVector<QWaylandWindow *> mActiveWindows;
+-    QVector<FrameQueue> mExternalQueues;
++    QList<QWaylandWindow *> mActiveWindows;
+     struct wl_callback *mSyncCallback = nullptr;
+     static const wl_callback_listener syncCallbackListener;
+-    QReadWriteLock m_frameQueueLock;
+ 
+     bool mClientSideInputContextRequested = !QPlatformInputContextFactory::requested().isNull();
+ 
+diff --git a/qtwayland/src/client/qwaylanddnd.cpp b/qtwayland/src/client/qwaylanddnd.cpp
+index 6535aa16..7c53f5fa 100644
+--- a/qtwayland/src/client/qwaylanddnd.cpp
++++ b/qtwayland/src/client/qwaylanddnd.cpp
+@@ -66,7 +66,7 @@ void QWaylandDrag::startDrag()
+ {
+     QBasicDrag::startDrag();
+     QWaylandWindow *icon = static_cast<QWaylandWindow *>(shapedPixmapWindow()->handle());
+-    if (m_display->currentInputDevice()->dataDevice()->startDrag(drag()->mimeData(), icon)) {
++    if (m_display->currentInputDevice()->dataDevice()->startDrag(drag()->mimeData(), drag()->supportedActions(), icon)) {
+         icon->addAttachOffset(-drag()->hotSpot());
+     } else {
+         // Cancelling immediately does not work, since the event loop for QDrag::exec is started
+@@ -80,6 +80,9 @@ void QWaylandDrag::cancel()
+     QBasicDrag::cancel();
+ 
+     m_display->currentInputDevice()->dataDevice()->cancelDrag();
++
++    if (drag())
++        drag()->deleteLater();
+ }
+ 
+ void QWaylandDrag::move(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods)
+@@ -103,33 +106,41 @@ void QWaylandDrag::endDrag()
+     m_display->currentInputDevice()->handleEndDrag();
+ }
+ 
+-void QWaylandDrag::updateTarget(const QString &mimeType)
++void QWaylandDrag::setResponse(bool accepted)
+ {
+-    setCanDrop(!mimeType.isEmpty());
+-
+-    if (canDrop()) {
+-        updateCursor(defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers()));
+-    } else {
+-        updateCursor(Qt::IgnoreAction);
+-    }
++    // This method is used for old DataDevices where the drag action is not communicated
++    Qt::DropAction action = defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers());
++    setResponse(QPlatformDropQtResponse(accepted, action));
+ }
+ 
+-void QWaylandDrag::setResponse(const QPlatformDragQtResponse &response)
++void QWaylandDrag::setResponse(const QPlatformDropQtResponse &response)
+ {
+     setCanDrop(response.isAccepted());
+ 
+     if (canDrop()) {
+-        updateCursor(defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers()));
++        updateCursor(response.acceptedAction());
+     } else {
+         updateCursor(Qt::IgnoreAction);
+     }
+ }
+ 
+-void QWaylandDrag::finishDrag(const QPlatformDropQtResponse &response)
++void QWaylandDrag::setDropResponse(const QPlatformDropQtResponse &response)
+ {
+     setExecutedDropAction(response.acceptedAction());
++}
++
++void QWaylandDrag::finishDrag()
++{
+     QKeyEvent event(QEvent::KeyPress, Qt::Key_Escape, Qt::NoModifier);
+     eventFilter(shapedPixmapWindow(), &event);
++
++    if (drag())
++        drag()->deleteLater();
++}
++
++bool QWaylandDrag::ownsDragObject() const
++{
++    return true;
+ }
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddnd_p.h b/qtwayland/src/client/qwaylanddnd_p.h
+index 474fe2ab..46f629ac 100644
+--- a/qtwayland/src/client/qwaylanddnd_p.h
++++ b/qtwayland/src/client/qwaylanddnd_p.h
+@@ -71,9 +71,10 @@ public:
+     QWaylandDrag(QWaylandDisplay *display);
+     ~QWaylandDrag() override;
+ 
+-    void updateTarget(const QString &mimeType);
+-    void setResponse(const QPlatformDragQtResponse &response);
+-    void finishDrag(const QPlatformDropQtResponse &response);
++    void setResponse(bool accepted);
++    void setResponse(const QPlatformDropQtResponse &response);
++    void setDropResponse(const QPlatformDropQtResponse &response);
++    void finishDrag();
+ 
+ protected:
+     void startDrag() override;
+@@ -82,6 +83,7 @@ protected:
+     void drop(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods) override;
+     void endDrag() override;
+ 
++    bool ownsDragObject() const override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+diff --git a/qtwayland/src/client/qwaylandinputdevice.cpp b/qtwayland/src/client/qwaylandinputdevice.cpp
+index 613fe862..4b90de84 100644
+--- a/qtwayland/src/client/qwaylandinputdevice.cpp
++++ b/qtwayland/src/client/qwaylandinputdevice.cpp
+@@ -685,6 +685,11 @@ public:
+ 
+ void QWaylandInputDevice::Pointer::pointer_leave(uint32_t time, struct wl_surface *surface)
+ {
++    invalidateFocus();
++    mButtons = Qt::NoButton;
++
++    mParent->mTime = time;
++
+     // The event may arrive after destroying the window, indicated by
+     // a null surface.
+     if (!surface)
+@@ -696,11 +701,6 @@ void QWaylandInputDevice::Pointer::pointer_leave(uint32_t time, struct wl_surfac
+ 
+     if (!QWaylandWindow::mouseGrab())
+         setFrameEvent(new LeaveEvent(window, mSurfacePos, mGlobalPos));
+-
+-    invalidateFocus();
+-    mButtons = Qt::NoButton;
+-
+-    mParent->mTime = time;
+ }
+ 
+ class MotionEvent : public QWaylandPointerEvent
+@@ -1300,14 +1300,6 @@ void QWaylandInputDevice::Keyboard::handleFocusDestroyed()
+ void QWaylandInputDevice::Keyboard::handleFocusLost()
+ {
+     mFocus = nullptr;
+-#if QT_CONFIG(clipboard)
+-    if (auto *dataDevice = mParent->dataDevice())
+-        dataDevice->invalidateSelectionOffer();
+-#endif
+-#if QT_CONFIG(wayland_client_primary_selection)
+-    if (auto *device = mParent->primarySelectionDevice())
+-        device->invalidateSelectionOffer();
+-#endif
+     mParent->mQDisplay->handleKeyboardFocusChanged(mParent);
+     mRepeatTimer.stop();
+ }
+@@ -1396,6 +1388,7 @@ void QWaylandInputDevice::Touch::touch_cancel()
+     if (touchExt)
+         touchExt->touchCanceled();
+ 
++    mFocus = nullptr;
+     QWindowSystemInterface::handleTouchCancelEvent(nullptr, mParent->mTouchDevice);
+ }
+ 
+diff --git a/qtwayland/src/client/qwaylandintegration.cpp b/qtwayland/src/client/qwaylandintegration.cpp
+index c53ccb78..54861600 100644
+--- a/qtwayland/src/client/qwaylandintegration.cpp
++++ b/qtwayland/src/client/qwaylandintegration.cpp
+@@ -125,6 +125,9 @@ QWaylandIntegration::QWaylandIntegration()
+ #endif
+ 
+     reconfigureInputContext();
++
++    QWaylandWindow::fixedToplevelPositions =
++            !qEnvironmentVariableIsSet("QT_WAYLAND_DISABLE_FIXED_POSITIONS");
+ }
+ 
+ QWaylandIntegration::~QWaylandIntegration()
+@@ -192,14 +195,18 @@ QAbstractEventDispatcher *QWaylandIntegration::createEventDispatcher() const
+ 
+ void QWaylandIntegration::initialize()
+ {
++    mDisplay->initEventThread();
++
++    // Call after eventDispatcher is fully connected, for QWaylandDisplay::forceRoundTrip()
++    mDisplay->initialize();
++
++    // But the aboutToBlock() and awake() should be connected after initializePlatform().
++    // Otherwise the connected flushRequests() may consumes up all events before processEvents starts to wait,
++    // so that processEvents(QEventLoop::WaitForMoreEvents) may be blocked in the forceRoundTrip().
+     QAbstractEventDispatcher *dispatcher = QGuiApplicationPrivate::eventDispatcher;
+     QObject::connect(dispatcher, SIGNAL(aboutToBlock()), mDisplay.data(), SLOT(flushRequests()));
+     QObject::connect(dispatcher, SIGNAL(awake()), mDisplay.data(), SLOT(flushRequests()));
+ 
+-    int fd = wl_display_get_fd(mDisplay->wl_display());
+-    QSocketNotifier *sn = new QSocketNotifier(fd, QSocketNotifier::Read, mDisplay.data());
+-    QObject::connect(sn, SIGNAL(activated(QSocketDescriptor)), mDisplay.data(), SLOT(flushRequests()));
+-
+     // Qt does not support running with no screens
+     mDisplay->ensureScreen();
+ }
+@@ -262,6 +269,14 @@ QWaylandDisplay *QWaylandIntegration::display() const
+     return mDisplay.data();
+ }
+ 
++Qt::KeyboardModifiers QWaylandIntegration::queryKeyboardModifiers() const
++{
++    if (auto *seat = mDisplay->currentInputDevice()) {
++        return seat->modifiers();
++    }
++    return Qt::NoModifier;
++}
++
+ QList<int> QWaylandIntegration::possibleKeys(const QKeyEvent *event) const
+ {
+     if (auto *seat = mDisplay->currentInputDevice())
+@@ -479,7 +494,7 @@ void QWaylandIntegration::reconfigureInputContext()
+     }
+ #endif
+ 
+-    qCDebug(lcQpaWayland) << "using input method:" << inputContext()->metaObject()->className();
++    qCDebug(lcQpaWayland) << "using input method:" << (inputContext() ? inputContext()->metaObject()->className() : "<none>");
+ }
+ 
+ QWaylandShellIntegration *QWaylandIntegration::createShellIntegration(const QString &integrationName)
+diff --git a/qtwayland/src/client/qwaylandintegration_p.h b/qtwayland/src/client/qwaylandintegration_p.h
+index ff70ae25..73b80658 100644
+--- a/qtwayland/src/client/qwaylandintegration_p.h
++++ b/qtwayland/src/client/qwaylandintegration_p.h
+@@ -107,6 +107,8 @@ public:
+ 
+     QWaylandDisplay *display() const;
+ 
++    Qt::KeyboardModifiers queryKeyboardModifiers() const override;
++
+     QList<int> possibleKeys(const QKeyEvent *event) const override;
+ 
+     QStringList themeNames() const override;
+diff --git a/qtwayland/src/client/qwaylandprimaryselectionv1.cpp b/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
+index 832f9678..ea508771 100644
+--- a/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
++++ b/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
+@@ -54,11 +54,6 @@ QWaylandPrimarySelectionDeviceManagerV1::QWaylandPrimarySelectionDeviceManagerV1
+     : zwp_primary_selection_device_manager_v1(display->wl_registry(), id, qMin(version, uint(1)))
+     , m_display(display)
+ {
+-    // Create devices for all seats.
+-    // This only works if we get the global before all devices
+-    const auto seats = m_display->inputDevices();
+-    for (auto *seat : seats)
+-        seat->setPrimarySelectionDevice(createDevice(seat));
+ }
+ 
+ QWaylandPrimarySelectionDeviceV1 *QWaylandPrimarySelectionDeviceManagerV1::createDevice(QWaylandInputDevice *seat)
+diff --git a/qtwayland/src/client/qwaylandscreen.cpp b/qtwayland/src/client/qwaylandscreen.cpp
+index 6cb337de..5537dafd 100644
+--- a/qtwayland/src/client/qwaylandscreen.cpp
++++ b/qtwayland/src/client/qwaylandscreen.cpp
+@@ -60,7 +60,7 @@ QWaylandXdgOutputManagerV1::QWaylandXdgOutputManagerV1(QWaylandDisplay* display,
+ }
+ 
+ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uint32_t id)
+-    : QtWayland::wl_output(waylandDisplay->wl_registry(), id, qMin(version, 2))
++    : QtWayland::wl_output(waylandDisplay->wl_registry(), id, qMin(version, 3))
+     , m_outputId(id)
+     , mWaylandDisplay(waylandDisplay)
+     , mOutputName(QStringLiteral("Screen%1").arg(id))
+@@ -72,7 +72,7 @@ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uin
+         qCWarning(lcQpaWayland) << "wl_output done event not supported by compositor,"
+                                 << "QScreen may not work correctly";
+         mWaylandDisplay->forceRoundTrip(); // Give the compositor a chance to send geometry etc.
+-        mOutputDone = true; // Fake the done event
++        mProcessedEvents |= OutputDoneEvent; // Fake the done event
+         maybeInitialize();
+     }
+ }
+@@ -81,16 +81,29 @@ QWaylandScreen::~QWaylandScreen()
+ {
+     if (zxdg_output_v1::isInitialized())
+         zxdg_output_v1::destroy();
++    if (wl_output::isInitialized() && wl_output_get_version(wl_output::object()) >= WL_OUTPUT_RELEASE_SINCE_VERSION)
++        wl_output::release();
++}
++
++uint QWaylandScreen::requiredEvents() const
++{
++    uint ret = OutputDoneEvent;
++
++    if (mWaylandDisplay->xdgOutputManager()) {
++        ret |= XdgOutputNameEvent;
++
++        if (mWaylandDisplay->xdgOutputManager()->version() < 3)
++            ret |= XdgOutputDoneEvent;
++    }
++    return ret;
+ }
+ 
+ void QWaylandScreen::maybeInitialize()
+ {
+     Q_ASSERT(!mInitialized);
+ 
+-    if (!mOutputDone)
+-        return;
+-
+-    if (mWaylandDisplay->xdgOutputManager() && !mXdgOutputDone)
++    const uint requiredEvents = this->requiredEvents();
++    if ((mProcessedEvents & requiredEvents) != requiredEvents)
+         return;
+ 
+     mInitialized = true;
+@@ -276,9 +289,8 @@ void QWaylandScreen::output_scale(int32_t factor)
+ 
+ void QWaylandScreen::output_done()
+ {
+-    mOutputDone = true;
+-    if (zxdg_output_v1::isInitialized() && mWaylandDisplay->xdgOutputManager()->version() >= 3)
+-        mXdgOutputDone = true;
++    mProcessedEvents |= OutputDoneEvent;
++
+     if (mInitialized) {
+         updateOutputProperties();
+         if (zxdg_output_v1::isInitialized())
+@@ -339,7 +351,7 @@ void QWaylandScreen::zxdg_output_v1_done()
+     if (Q_UNLIKELY(mWaylandDisplay->xdgOutputManager()->version() >= 3))
+         qWarning(lcQpaWayland) << "zxdg_output_v1.done received on version 3 or newer, this is most likely a bug in the compositor";
+ 
+-    mXdgOutputDone = true;
++    mProcessedEvents |= XdgOutputDoneEvent;
+     if (mInitialized)
+         updateXdgOutputProperties();
+     else
+@@ -348,7 +360,11 @@ void QWaylandScreen::zxdg_output_v1_done()
+ 
+ void QWaylandScreen::zxdg_output_v1_name(const QString &name)
+ {
++    if (Q_UNLIKELY(mInitialized))
++        qWarning(lcQpaWayland) << "zxdg_output_v1.name received after output has been initialized, this is most likely a bug in the compositor";
++
+     mOutputName = name;
++    mProcessedEvents |= XdgOutputNameEvent;
+ }
+ 
+ void QWaylandScreen::updateXdgOutputProperties()
+diff --git a/qtwayland/src/client/qwaylandscreen_p.h b/qtwayland/src/client/qwaylandscreen_p.h
+index df1c94f2..050cfdc0 100644
+--- a/qtwayland/src/client/qwaylandscreen_p.h
++++ b/qtwayland/src/client/qwaylandscreen_p.h
+@@ -116,6 +116,13 @@ public:
+     static QWaylandScreen *fromWlOutput(::wl_output *output);
+ 
+ private:
++    enum Event : uint {
++        XdgOutputDoneEvent = 0x1,
++        OutputDoneEvent = 0x2,
++        XdgOutputNameEvent = 0x4,
++    };
++    uint requiredEvents() const;
++
+     void output_mode(uint32_t flags, int width, int height, int refresh) override;
+     void output_geometry(int32_t x, int32_t y,
+                          int32_t width, int32_t height,
+@@ -148,8 +155,7 @@ private:
+     QSize mPhysicalSize;
+     QString mOutputName;
+     Qt::ScreenOrientation m_orientation = Qt::PrimaryOrientation;
+-    bool mOutputDone = false;
+-    bool mXdgOutputDone = false;
++    uint mProcessedEvents = 0;
+     bool mInitialized = false;
+ 
+ #if QT_CONFIG(cursor)
+diff --git a/qtwayland/src/client/qwaylandshmbackingstore.cpp b/qtwayland/src/client/qwaylandshmbackingstore.cpp
+index dc7ff670..41cffdf7 100644
+--- a/qtwayland/src/client/qwaylandshmbackingstore.cpp
++++ b/qtwayland/src/client/qwaylandshmbackingstore.cpp
+@@ -52,6 +52,7 @@
+ 
+ #include <QtWaylandClient/private/wayland-wayland-client-protocol.h>
+ 
++#include <fcntl.h>
+ #include <unistd.h>
+ #include <sys/mman.h>
+ 
+@@ -61,6 +62,9 @@
+ #  ifndef MFD_CLOEXEC
+ #    define MFD_CLOEXEC     0x0001U
+ #  endif
++#  ifndef MFD_ALLOW_SEALING
++#    define MFD_ALLOW_SEALING 0x0002U
++#  endif
+ #endif
+ 
+ QT_BEGIN_NAMESPACE
+@@ -74,8 +78,10 @@ QWaylandShmBuffer::QWaylandShmBuffer(QWaylandDisplay *display,
+     int alloc = stride * size.height();
+     int fd = -1;
+ 
+-#ifdef SYS_memfd_create
+-    fd = syscall(SYS_memfd_create, "wayland-shm", MFD_CLOEXEC);
++#if defined(SYS_memfd_create) && defined(F_SEAL_SEAL)
++    fd = syscall(SYS_memfd_create, "wayland-shm", MFD_CLOEXEC | MFD_ALLOW_SEALING);
++    if (fd >= 0)
++        fcntl(fd, F_ADD_SEALS, F_SEAL_SHRINK | F_SEAL_SEAL);
+ #endif
+ 
+     QScopedPointer<QFile> filePointer;
+diff --git a/qtwayland/src/client/qwaylandwindow.cpp b/qtwayland/src/client/qwaylandwindow.cpp
+index cb82857a..fb2c59dc 100644
+--- a/qtwayland/src/client/qwaylandwindow.cpp
++++ b/qtwayland/src/client/qwaylandwindow.cpp
+@@ -76,7 +76,6 @@ QWaylandWindow *QWaylandWindow::mMouseGrab = nullptr;
+ QWaylandWindow::QWaylandWindow(QWindow *window, QWaylandDisplay *display)
+     : QPlatformWindow(window)
+     , mDisplay(display)
+-    , mFrameQueue(mDisplay->createFrameQueue())
+     , mResizeAfterSwap(qEnvironmentVariableIsSet("QT_WAYLAND_RESIZE_AFTER_SWAP"))
+ {
+     {
+@@ -95,9 +94,6 @@ QWaylandWindow::QWaylandWindow(QWindow *window, QWaylandDisplay *display)
+ 
+ QWaylandWindow::~QWaylandWindow()
+ {
+-    mDisplay->destroyFrameQueue(mFrameQueue);
+-    mDisplay->handleWindowDestroyed(this);
+-
+     delete mWindowDecoration;
+ 
+     if (mSurface)
+@@ -243,6 +239,7 @@ bool QWaylandWindow::shouldCreateSubSurface() const
+ 
+ void QWaylandWindow::reset()
+ {
++    closeChildPopups();
+     delete mShellSurface;
+     mShellSurface = nullptr;
+     delete mSubSurfaceWindow;
+@@ -255,17 +252,22 @@ void QWaylandWindow::reset()
+         mSurface.reset();
+     }
+ 
+-    if (mFrameCallback) {
+-        wl_callback_destroy(mFrameCallback);
+-        mFrameCallback = nullptr;
+-    }
++    {
++        QMutexLocker lock(&mFrameSyncMutex);
++        if (mFrameCallback) {
++            wl_callback_destroy(mFrameCallback);
++            mFrameCallback = nullptr;
++        }
+ 
+-    mFrameCallbackElapsedTimer.invalidate();
+-    mWaitingForFrameCallback = false;
++        mFrameCallbackElapsedTimer.invalidate();
++        mWaitingForFrameCallback = false;
++    }
+     mFrameCallbackTimedOut = false;
+ 
+     mMask = QRegion();
+     mQueuedBuffer = nullptr;
++
++    mDisplay->handleWindowDestroyed(this);
+ }
+ 
+ QWaylandWindow *QWaylandWindow::fromWlSurface(::wl_surface *surface)
+@@ -351,19 +353,25 @@ void QWaylandWindow::setGeometry_helper(const QRect &rect)
+     }
+ }
+ 
+-void QWaylandWindow::setGeometry(const QRect &rect)
++void QWaylandWindow::setGeometry(const QRect &r)
+ {
++    auto rect = r;
++    if (fixedToplevelPositions && !QPlatformWindow::parent() && window()->type() != Qt::Popup
++        && window()->type() != Qt::ToolTip) {
++        rect.moveTo(screen()->geometry().topLeft());
++    }
+     setGeometry_helper(rect);
+ 
+     if (window()->isVisible() && rect.isValid()) {
+         if (mWindowDecoration)
+             mWindowDecoration->update();
+ 
+-        if (mResizeAfterSwap && windowType() == Egl && mSentInitialResize)
++        if (mResizeAfterSwap && windowType() == Egl && mSentInitialResize) {
++            QMutexLocker lock(&mResizeLock);
+             mResizeDirty = true;
+-        else
++        } else {
+             QWindowSystemInterface::handleGeometryChange(window(), geometry());
+-
++        }
+         mSentInitialResize = true;
+     }
+     QRect exposeGeometry(QPoint(), geometry().size());
+@@ -374,7 +382,7 @@ void QWaylandWindow::setGeometry(const QRect &rect)
+         mShellSurface->setWindowGeometry(windowContentGeometry());
+ 
+     if (isOpaque() && mMask.isEmpty())
+-        setOpaqueArea(rect);
++        setOpaqueArea(QRect(QPoint(0, 0), rect.size()));
+ }
+ 
+ void QWaylandWindow::resizeFromApplyConfigure(const QSize &sizeWithMargins, const QPoint &offset)
+@@ -399,21 +407,6 @@ void QWaylandWindow::sendExposeEvent(const QRect &rect)
+     mLastExposeGeometry = rect;
+ }
+ 
+-
+-static QVector<QPointer<QWaylandWindow>> activePopups;
+-
+-void QWaylandWindow::closePopups(QWaylandWindow *parent)
+-{
+-    while (!activePopups.isEmpty()) {
+-        auto popup = activePopups.takeLast();
+-        if (popup.isNull())
+-            continue;
+-        if (popup.data() == parent)
+-            return;
+-        popup->reset();
+-    }
+-}
+-
+ QPlatformScreen *QWaylandWindow::calculateScreenFromSurfaceEvents() const
+ {
+     QReadLocker lock(&mSurfaceLock);
+@@ -433,10 +426,7 @@ void QWaylandWindow::setVisible(bool visible)
+     lastVisible = visible;
+ 
+     if (visible) {
+-        if (window()->type() == Qt::Popup || window()->type() == Qt::ToolTip)
+-            activePopups << this;
+         initWindow();
+-        mDisplay->flushRequests();
+ 
+         setGeometry(windowGeometry());
+         // Don't flush the events here, or else the newly visible window may start drawing, but since
+@@ -444,7 +434,6 @@ void QWaylandWindow::setVisible(bool visible)
+         // QWaylandShmBackingStore::beginPaint().
+     } else {
+         sendExposeEvent(QRect());
+-        closePopups(this);
+         reset();
+     }
+ }
+@@ -556,12 +545,12 @@ void QWaylandWindow::sendRecursiveExposeEvent()
+ 
+ void QWaylandWindow::attach(QWaylandBuffer *buffer, int x, int y)
+ {
+-    Q_ASSERT(!buffer->committed());
+     QReadLocker locker(&mSurfaceLock);
+     if (mSurface == nullptr)
+         return;
+ 
+     if (buffer) {
++        Q_ASSERT(!buffer->committed());
+         handleUpdate();
+         buffer->setBusy();
+ 
+@@ -583,7 +572,11 @@ void QWaylandWindow::damage(const QRect &rect)
+     if (mSurface == nullptr)
+         return;
+ 
+-    mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    const int s = scale();
++    if (mDisplay->compositorVersion() >= 4)
++        mSurface->damage_buffer(s * rect.x(), s * rect.y(), s * rect.width(), s * rect.height());
++    else
++        mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
+ }
+ 
+ void QWaylandWindow::safeCommit(QWaylandBuffer *buffer, const QRegion &damage)
+@@ -619,8 +612,14 @@ void QWaylandWindow::commit(QWaylandBuffer *buffer, const QRegion &damage)
+         return;
+ 
+     attachOffset(buffer);
+-    for (const QRect &rect: damage)
+-        mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    if (mDisplay->compositorVersion() >= 4) {
++        const int s = scale();
++        for (const QRect &rect: damage)
++            mSurface->damage_buffer(s * rect.x(), s * rect.y(), s * rect.width(), s * rect.height());
++    } else {
++        for (const QRect &rect: damage)
++            mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    }
+     Q_ASSERT(!buffer->committed());
+     buffer->setCommitted();
+     mSurface->commit();
+@@ -635,42 +634,53 @@ void QWaylandWindow::commit()
+ 
+ const wl_callback_listener QWaylandWindow::callbackListener = {
+     [](void *data, wl_callback *callback, uint32_t time) {
+-        Q_UNUSED(callback);
+         Q_UNUSED(time);
+         auto *window = static_cast<QWaylandWindow*>(data);
+-        window->handleFrameCallback();
++        window->handleFrameCallback(callback);
+     }
+ };
+ 
+-void QWaylandWindow::handleFrameCallback()
++void QWaylandWindow::handleFrameCallback(wl_callback* callback)
+ {
++    QMutexLocker locker(&mFrameSyncMutex);
++    if (!mFrameCallback) {
++        // This means the callback is already unset by QWaylandWindow::reset.
++        // The wl_callback object will be destroyed there too.
++        return;
++    }
++    Q_ASSERT(callback == mFrameCallback);
++    wl_callback_destroy(callback);
++    mFrameCallback = nullptr;
++
+     mWaitingForFrameCallback = false;
+     mFrameCallbackElapsedTimer.invalidate();
+ 
+     // The rest can wait until we can run it on the correct thread
+-    if (!mWaitingForUpdateDelivery) {
+-        auto doHandleExpose = [this]() {
+-            bool wasExposed = isExposed();
+-            mFrameCallbackTimedOut = false;
+-            if (!wasExposed && isExposed()) // Did setting mFrameCallbackTimedOut make the window exposed?
+-                sendExposeEvent(QRect(QPoint(), geometry().size()));
+-            if (wasExposed && hasPendingUpdateRequest())
+-                deliverUpdateRequest();
+-
+-            mWaitingForUpdateDelivery = false;
+-        };
++    auto doHandleExpose = [this]() {
++        mWaitingForUpdateDelivery.storeRelease(false);
++        bool wasExposed = isExposed();
++        mFrameCallbackTimedOut = false;
++        if (!wasExposed && isExposed()) // Did setting mFrameCallbackTimedOut make the window exposed?
++            sendExposeEvent(QRect(QPoint(), geometry().size()));
++        if (wasExposed && hasPendingUpdateRequest())
++            deliverUpdateRequest();
++    };
+ 
++    if (mWaitingForUpdateDelivery.testAndSetAcquire(false, true)) {
+         // Queued connection, to make sure we don't call handleUpdate() from inside waitForFrameSync()
+         // in the single-threaded case.
+-        mWaitingForUpdateDelivery = true;
+         QMetaObject::invokeMethod(this, doHandleExpose, Qt::QueuedConnection);
+     }
++
++    mFrameSyncWait.notify_all();
+ }
+ 
+ bool QWaylandWindow::waitForFrameSync(int timeout)
+ {
+-    QMutexLocker locker(mFrameQueue.mutex);
+-    mDisplay->dispatchQueueWhile(mFrameQueue.queue, [&]() { return mWaitingForFrameCallback; }, timeout);
++    QMutexLocker locker(&mFrameSyncMutex);
++
++    QDeadlineTimer deadline(timeout);
++    while (mWaitingForFrameCallback && mFrameSyncWait.wait(&mFrameSyncMutex, deadline)) { }
+ 
+     if (mWaitingForFrameCallback) {
+         qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
+@@ -868,6 +878,17 @@ bool QWaylandWindow::createDecoration()
+             subsurf->set_position(pos.x() + m.left(), pos.y() + m.top());
+         }
+         sendExposeEvent(QRect(QPoint(), geometry().size()));
++
++        // This is a special case where the buffer is recreated, but since
++        // the content rect remains the same, the widgets remain the same
++        // size and are not redrawn, leaving the new buffer empty. As a simple
++        // work-around, we trigger a full extra update whenever the client-side
++        // window decorations are toggled while the window is showing.
++        // Note: createDecoration() is sometimes called from the render thread
++        // of Qt Quick. This is essentially wrong and could potentially cause problems,
++        // but until the underlying issue has been fixed, we have to use invokeMethod()
++        // here to avoid asserts.
++        QMetaObject::invokeMethod(window(), &QWindow::requestUpdate);
+     }
+ 
+     return mWindowDecoration;
+@@ -1023,6 +1044,13 @@ void QWaylandWindow::handleScreensChanged()
+ 
+     QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->QPlatformScreen::screen());
+     mLastReportedScreen = newScreen;
++    if (fixedToplevelPositions && !QPlatformWindow::parent() && window()->type() != Qt::Popup
++        && window()->type() != Qt::ToolTip
++        && geometry().topLeft() != newScreen->geometry().topLeft()) {
++        auto geometry = this->geometry();
++        geometry.moveTo(newScreen->geometry().topLeft());
++        setGeometry(geometry);
++    }
+ 
+     int scale = newScreen->isPlaceholder() ? 1 : static_cast<QWaylandScreen *>(newScreen)->scale();
+     if (scale != mScale) {
+@@ -1094,10 +1122,18 @@ bool QWaylandWindow::setMouseGrabEnabled(bool grab)
+     return true;
+ }
+ 
++Qt::WindowStates QWaylandWindow::windowStates() const
++{
++    return mLastReportedWindowStates;
++}
++
+ void QWaylandWindow::handleWindowStatesChanged(Qt::WindowStates states)
+ {
+     createDecoration();
+-    QWindowSystemInterface::handleWindowStateChanged(window(), states, mLastReportedWindowStates);
++    Qt::WindowStates statesWithoutActive = states & ~Qt::WindowActive;
++    Qt::WindowStates lastStatesWithoutActive = mLastReportedWindowStates & ~Qt::WindowActive;
++    QWindowSystemInterface::handleWindowStateChanged(window(), statesWithoutActive,
++                                                     lastStatesWithoutActive);
+     mLastReportedWindowStates = states;
+ }
+ 
+@@ -1139,19 +1175,24 @@ void QWaylandWindow::timerEvent(QTimerEvent *event)
+     if (event->timerId() != mFrameCallbackCheckIntervalTimerId)
+         return;
+ 
+-    bool callbackTimerExpired = mFrameCallbackElapsedTimer.hasExpired(mFrameCallbackTimeout);
+-    if (!mFrameCallbackElapsedTimer.isValid() || callbackTimerExpired ) {
+-        killTimer(mFrameCallbackCheckIntervalTimerId);
+-        mFrameCallbackCheckIntervalTimerId = -1;
+-    }
+-    if (mFrameCallbackElapsedTimer.isValid() && callbackTimerExpired) {
+-        mFrameCallbackElapsedTimer.invalidate();
++    {
++        QMutexLocker lock(&mFrameSyncMutex);
+ 
+-        qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
+-        mFrameCallbackTimedOut = true;
+-        mWaitingForUpdate = false;
+-        sendExposeEvent(QRect());
++        bool callbackTimerExpired = mFrameCallbackElapsedTimer.hasExpired(mFrameCallbackTimeout);
++        if (!mFrameCallbackElapsedTimer.isValid() || callbackTimerExpired ) {
++            killTimer(mFrameCallbackCheckIntervalTimerId);
++            mFrameCallbackCheckIntervalTimerId = -1;
++        }
++        if (!mFrameCallbackElapsedTimer.isValid() || !callbackTimerExpired) {
++            return;
++        }
++        mFrameCallbackElapsedTimer.invalidate();
+     }
++
++    qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
++    mFrameCallbackTimedOut = true;
++    mWaitingForUpdate = false;
++    sendExposeEvent(QRect());
+ }
+ 
+ void QWaylandWindow::requestUpdate()
+@@ -1160,8 +1201,11 @@ void QWaylandWindow::requestUpdate()
+     Q_ASSERT(hasPendingUpdateRequest()); // should be set by QPA
+ 
+     // If we have a frame callback all is good and will be taken care of there
+-    if (mWaitingForFrameCallback)
+-        return;
++    {
++        QMutexLocker locker(&mFrameSyncMutex);
++        if (mWaitingForFrameCallback)
++            return;
++    }
+ 
+     // If we've already called deliverUpdateRequest(), but haven't seen any attach+commit/swap yet
+     // This is a somewhat redundant behavior and might indicate a bug in the calling code, so log
+@@ -1174,7 +1218,12 @@ void QWaylandWindow::requestUpdate()
+     // so use invokeMethod to delay the delivery a bit.
+     QMetaObject::invokeMethod(this, [this] {
+         // Things might have changed in the meantime
+-        if (hasPendingUpdateRequest() && !mWaitingForFrameCallback)
++        {
++            QMutexLocker locker(&mFrameSyncMutex);
++            if (mWaitingForFrameCallback)
++                return;
++        }
++        if (hasPendingUpdateRequest())
+             deliverUpdateRequest();
+     }, Qt::QueuedConnection);
+ }
+@@ -1185,19 +1234,18 @@ void QWaylandWindow::requestUpdate()
+ void QWaylandWindow::handleUpdate()
+ {
+     qCDebug(lcWaylandBackingstore) << "handleUpdate" << QThread::currentThread();
++
+     // TODO: Should sync subsurfaces avoid requesting frame callbacks?
+     QReadLocker lock(&mSurfaceLock);
+     if (!mSurface)
+         return;
+ 
+-    if (mFrameCallback) {
+-        wl_callback_destroy(mFrameCallback);
+-        mFrameCallback = nullptr;
+-    }
++    QMutexLocker locker(&mFrameSyncMutex);
++    if (mWaitingForFrameCallback)
++        return;
+ 
+-    QMutexLocker locker(mFrameQueue.mutex);
+     struct ::wl_surface *wrappedSurface = reinterpret_cast<struct ::wl_surface *>(wl_proxy_create_wrapper(mSurface->object()));
+-    wl_proxy_set_queue(reinterpret_cast<wl_proxy *>(wrappedSurface), mFrameQueue.queue);
++    wl_proxy_set_queue(reinterpret_cast<wl_proxy *>(wrappedSurface), mDisplay->frameEventQueue());
+     mFrameCallback = wl_surface_frame(wrappedSurface);
+     wl_proxy_wrapper_destroy(wrappedSurface);
+     wl_callback_add_listener(mFrameCallback, &QWaylandWindow::callbackListener, this);
+@@ -1207,6 +1255,8 @@ void QWaylandWindow::handleUpdate()
+     // Start a timer for handling the case when the compositor stops sending frame callbacks.
+     if (mFrameCallbackTimeout > 0) {
+         QMetaObject::invokeMethod(this, [this] {
++            QMutexLocker locker(&mFrameSyncMutex);
++
+             if (mWaitingForFrameCallback) {
+                 if (mFrameCallbackCheckIntervalTimerId < 0)
+                     mFrameCallbackCheckIntervalTimerId = startTimer(mFrameCallbackTimeout);
+@@ -1267,6 +1317,20 @@ void QWaylandWindow::setOpaqueArea(const QRegion &opaqueArea)
+     wl_region_destroy(region);
+ }
+ 
++void QWaylandWindow::addChildPopup(QWaylandWindow *surface) {
++    mChildPopups.append(surface);
++}
++
++void QWaylandWindow::removeChildPopup(QWaylandWindow *surface) {
++    mChildPopups.removeAll(surface);
++}
++
++void QWaylandWindow::closeChildPopups() {
++    while (!mChildPopups.isEmpty()) {
++        auto popup = mChildPopups.takeLast();
++        popup->reset();
++    }
++}
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/client/qwaylandwindow_p.h b/qtwayland/src/client/qwaylandwindow_p.h
+index 01337cff..2f219d8c 100644
+--- a/qtwayland/src/client/qwaylandwindow_p.h
++++ b/qtwayland/src/client/qwaylandwindow_p.h
+@@ -98,6 +98,9 @@ public:
+     QWaylandWindow(QWindow *window, QWaylandDisplay *display);
+     ~QWaylandWindow() override;
+ 
++    // Keep Toplevels position on the top left corner of their screen
++    static inline bool fixedToplevelPositions = true;
++
+     virtual WindowType windowType() const = 0;
+     virtual void ensureSize();
+     WId winId() const override;
+@@ -148,6 +151,7 @@ public:
+     void setWindowState(Qt::WindowStates states) override;
+     void setWindowFlags(Qt::WindowFlags flags) override;
+     void handleWindowStatesChanged(Qt::WindowStates states);
++    Qt::WindowStates windowStates() const;
+ 
+     void raise() override;
+     void lower() override;
+@@ -206,6 +210,10 @@ public:
+     void handleUpdate();
+     void deliverUpdateRequest() override;
+ 
++    void addChildPopup(QWaylandWindow* child);
++    void removeChildPopup(QWaylandWindow* child);
++    void closeChildPopups();
++
+ public slots:
+     void applyConfigure();
+ 
+@@ -215,7 +223,11 @@ signals:
+ 
+ protected:
+     QWaylandDisplay *mDisplay = nullptr;
++
++    // mSurface can be written by the main thread. Other threads should claim a read lock for access
++    mutable QReadWriteLock mSurfaceLock;
+     QScopedPointer<QWaylandSurface> mSurface;
++
+     QWaylandShellSurface *mShellSurface = nullptr;
+     QWaylandSubSurface *mSubSurfaceWindow = nullptr;
+     QVector<QWaylandSubSurface *> mChildren;
+@@ -225,13 +237,14 @@ protected:
+     Qt::MouseButtons mMousePressedInContentArea = Qt::NoButton;
+ 
+     WId mWindowId;
+-    bool mWaitingForFrameCallback = false;
+     bool mFrameCallbackTimedOut = false; // Whether the frame callback has timed out
+-    bool mWaitingForUpdateDelivery = false;
+     int mFrameCallbackCheckIntervalTimerId = -1;
+-    QElapsedTimer mFrameCallbackElapsedTimer;
+-    struct ::wl_callback *mFrameCallback = nullptr;
+-    QWaylandDisplay::FrameQueue mFrameQueue;
++    QAtomicInt mWaitingForUpdateDelivery = false;
++
++    bool mWaitingForFrameCallback = false; // Protected by mFrameSyncMutex
++    QElapsedTimer mFrameCallbackElapsedTimer; // Protected by mFrameSyncMutex
++    struct ::wl_callback *mFrameCallback = nullptr; // Protected by mFrameSyncMutex
++    QMutex mFrameSyncMutex;
+     QWaitCondition mFrameSyncWait;
+ 
+     // True when we have called deliverRequestUpdate, but the client has not yet attached a new buffer
+@@ -261,6 +274,8 @@ protected:
+     QWaylandBuffer *mQueuedBuffer = nullptr;
+     QRegion mQueuedBufferDamage;
+ 
++    QList<QPointer<QWaylandWindow>> mChildPopups;
++
+ private:
+     void setGeometry_helper(const QRect &rect);
+     void initWindow();
+@@ -283,12 +298,10 @@ private:
+     QRect mLastExposeGeometry;
+ 
+     static const wl_callback_listener callbackListener;
+-    void handleFrameCallback();
++    void handleFrameCallback(struct ::wl_callback* callback);
+ 
+     static QWaylandWindow *mMouseGrab;
+ 
+-    mutable QReadWriteLock mSurfaceLock;
+-
+     friend class QWaylandSubSurface;
+ };
+ 
+diff --git a/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h b/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
+index ccad0048..4cc9b3b8 100644
+--- a/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
++++ b/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
+@@ -73,11 +73,10 @@ public:
+         return true;
+     }
+     virtual QWaylandShellSurface *createShellSurface(QWaylandWindow *window) = 0;
++    // kept for binary compat with layer-shell-qt
+     virtual void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) {
+-        if (newFocus)
+-            m_display->handleWindowActivated(newFocus);
+-        if (oldFocus)
+-            m_display->handleWindowDeactivated(oldFocus);
++        Q_UNUSED(newFocus);
++        Q_UNUSED(oldFocus);
+     }
+     virtual void *nativeResourceForWindow(const QByteArray &resource, QWindow *window) {
+         Q_UNUSED(resource);
+diff --git a/qtwayland/src/compositor/configure.json b/qtwayland/src/compositor/configure.json
+index bcfd5215..da95d07b 100644
+--- a/qtwayland/src/compositor/configure.json
++++ b/qtwayland/src/compositor/configure.json
+@@ -7,6 +7,31 @@
+     "testDir": "../../config.tests",
+ 
+     "libraries": {
++        "wayland-client": {
++            "label": "Wayland client library",
++            "headers": "wayland-version.h",
++            "test": {
++                "main": [
++                    "#if WAYLAND_VERSION_MAJOR < 1",
++                    "# error Wayland 1.8.0 or higher required",
++                    "#endif",
++                    "#if WAYLAND_VERSION_MAJOR == 1",
++                    "# if WAYLAND_VERSION_MINOR < 8",
++                    "#  error Wayland 1.8.0 or higher required",
++                    "# endif",
++                    "# if WAYLAND_VERSION_MINOR == 8",
++                    "#  if WAYLAND_VERSION_MICRO < 0",
++                    "#   error Wayland 1.8.0 or higher required",
++                    "#  endif",
++                    "# endif",
++                    "#endif"
++                 ]
++            },
++            "sources": [
++                { "type": "pkgConfig", "args": "wayland-client" },
++                "-lwayland-client"
++            ]
++        },
+         "wayland-server": {
+             "label": "wayland-server",
+             "headers": "wayland-version.h",
+@@ -151,8 +176,7 @@
+                     "#endif"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "dmabuf-client-buffer": {
+             "label": "Linux Client dma-buf Buffer Sharing",
+@@ -176,8 +200,7 @@
+                     "return 0;"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "vulkan-server-buffer": {
+             "label": "Vulkan Buffer Sharing",
+@@ -195,7 +218,8 @@
+                     "exportAllocInfo.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR;",
+                     "return 0;"
+                 ]
+-            }
++            },
++            "use": "wayland-client"
+         }
+     },
+ 
+diff --git a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
+index 7889f575..64140672 100644
+--- a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
++++ b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
+@@ -40,6 +40,7 @@
+ #include "qwaylandeglwindow.h"
+ 
+ #include <QtWaylandClient/private/qwaylandscreen_p.h>
++#include <QtWaylandClient/private/qwaylandsurface_p.h>
+ #include "qwaylandglcontext.h"
+ 
+ #include <QtEglSupport/private/qeglconvenience_p.h>
+@@ -124,6 +125,7 @@ void QWaylandEglWindow::updateSurface(bool create)
+         }
+         mOffset = QPoint();
+     } else {
++        QReadLocker locker(&mSurfaceLock);
+         if (m_waylandEglWindow) {
+             int current_width, current_height;
+             static bool disableResizeCheck = qgetenv("QT_WAYLAND_DISABLE_RESIZECHECK").toInt();
+@@ -131,14 +133,16 @@ void QWaylandEglWindow::updateSurface(bool create)
+             if (!disableResizeCheck) {
+                 wl_egl_window_get_attached_size(m_waylandEglWindow, &current_width, &current_height);
+             }
+-            if (disableResizeCheck || (current_width != sizeWithMargins.width() || current_height != sizeWithMargins.height())) {
++            if (disableResizeCheck || (current_width != sizeWithMargins.width() || current_height != sizeWithMargins.height()) || m_requestedSize != sizeWithMargins) {
+                 wl_egl_window_resize(m_waylandEglWindow, sizeWithMargins.width(), sizeWithMargins.height(), mOffset.x(), mOffset.y());
++                m_requestedSize = sizeWithMargins;
+                 mOffset = QPoint();
+ 
+                 m_resize = true;
+             }
+-        } else if (create && wlSurface()) {
+-            m_waylandEglWindow = wl_egl_window_create(wlSurface(), sizeWithMargins.width(), sizeWithMargins.height());
++        } else if (create && mSurface) {
++            m_waylandEglWindow = wl_egl_window_create(mSurface->object(), sizeWithMargins.width(), sizeWithMargins.height());
++            m_requestedSize = sizeWithMargins;
+         }
+ 
+         if (!m_eglSurface && m_waylandEglWindow && create) {
+diff --git a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
+index 5b1f4d56..0079dfef 100644
+--- a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
++++ b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
+@@ -88,6 +88,7 @@ private:
+     mutable QOpenGLFramebufferObject *m_contentFBO = nullptr;
+ 
+     QSurfaceFormat m_format;
++    QSize m_requestedSize;
+ };
+ 
+ }
+diff --git a/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h b/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
+index 56a710c3..c6a8b6c6 100644
+--- a/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
++++ b/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
+@@ -41,6 +41,8 @@
+ #include <QtCore/QTextStream>
+ #include <QtGui/QOpenGLTexture>
+ 
++#include <array>
++
+ #include <EGL/egl.h>
+ #include <EGL/eglext.h>
+ 
+diff --git a/qtwayland/src/plugins/decorations/bradient/main.cpp b/qtwayland/src/plugins/decorations/bradient/main.cpp
+index e75fda3c..fa885143 100644
+--- a/qtwayland/src/plugins/decorations/bradient/main.cpp
++++ b/qtwayland/src/plugins/decorations/bradient/main.cpp
+@@ -164,13 +164,10 @@ void QWaylandBradientDecoration::paint(QPaintDevice *device)
+     // Window icon
+     QIcon icon = waylandWindow()->windowIcon();
+     if (!icon.isNull()) {
+-        QPixmap pixmap = icon.pixmap(QSize(128, 128));
+-        QPixmap scaled = pixmap.scaled(22, 22, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+-
+         QRectF iconRect(0, 0, 22, 22);
+-        p.drawPixmap(iconRect.adjusted(margins().left() + BUTTON_SPACING, 4,
+-                                       margins().left() + BUTTON_SPACING, 4),
+-                     scaled, iconRect);
++        iconRect.adjust(margins().left() + BUTTON_SPACING, 4,
++                        margins().left() + BUTTON_SPACING, 4),
++        icon.paint(&p, iconRect.toRect());
+     }
+ 
+     // Window title
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
+index 85d25e3c..60bdd491 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
+@@ -47,18 +47,21 @@ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
+-QWaylandXdgPopupV5::QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow *window)
++QWaylandXdgPopupV5::QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow* parent, QWaylandWindow *window)
+     : QWaylandShellSurface(window)
+     , QtWayland::xdg_popup_v5(popup)
++    , m_parent(parent)
+     , m_window(window)
+ {
+     if (window->display()->windowExtension())
+         m_extendedWindow = new QWaylandExtendedSurface(window);
++    m_parent->addChildPopup(m_window);
+ }
+ 
+ QWaylandXdgPopupV5::~QWaylandXdgPopupV5()
+ {
+     xdg_popup_destroy(object());
++    m_parent->removeChildPopup(m_window);
+     delete m_extendedWindow;
+ }
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
+index 7494f6a6..d85f130b 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
+@@ -70,7 +70,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgPopupV5 : public QWaylandShellSurface
+ {
+     Q_OBJECT
+ public:
+-    QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow *window);
++    QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow* parent, QWaylandWindow *window);
+     ~QWaylandXdgPopupV5() override;
+ 
+ protected:
+@@ -78,6 +78,7 @@ protected:
+ 
+ private:
+     QWaylandExtendedSurface *m_extendedWindow = nullptr;
++    QWaylandWindow *m_parent = nullptr;
+     QWaylandWindow *m_window = nullptr;
+ };
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
+index 7e242c4a..def8452a 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
+@@ -84,7 +84,7 @@ QWaylandXdgPopupV5 *QWaylandXdgShellV5::createXdgPopup(QWaylandWindow *window, Q
+     int x = position.x() + parentWindow->frameMargins().left();
+     int y = position.y() + parentWindow->frameMargins().top();
+ 
+-    auto popup = new QWaylandXdgPopupV5(get_xdg_popup(window->wlSurface(), parentSurface, seat, m_popupSerial, x, y), window);
++    auto popup = new QWaylandXdgPopupV5(get_xdg_popup(window->wlSurface(), parentSurface, seat, m_popupSerial, x, y), parentWindow, window);
+     m_popups.append(window);
+     QObject::connect(popup, &QWaylandXdgPopupV5::destroyed, [this, window](){
+         m_popups.removeOne(window);
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
+index 4e25949f..cfc60939 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
+@@ -85,13 +85,6 @@ QWaylandShellSurface *QWaylandXdgShellV5Integration::createShellSurface(QWayland
+     return m_xdgShell->createXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellV5Integration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) {
+-    if (newFocus && qobject_cast<QWaylandXdgPopupV5 *>(newFocus->shellSurface()))
+-        m_display->handleWindowActivated(newFocus);
+-    if (oldFocus && qobject_cast<QWaylandXdgPopupV5 *>(oldFocus->shellSurface()))
+-        m_display->handleWindowDeactivated(oldFocus);
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
+index ce6bdb9e..aed88670 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
+@@ -67,7 +67,6 @@ public:
+     QWaylandXdgShellV5Integration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShellV5> m_xdgShell;
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
+index 8c371661..151c78e3 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
+@@ -174,6 +174,7 @@ QWaylandXdgSurfaceV6::Popup::Popup(QWaylandXdgSurfaceV6 *xdgSurface, QWaylandXdg
+     , m_xdgSurface(xdgSurface)
+     , m_parent(parent)
+ {
++    m_parent->window()->addChildPopup(m_xdgSurface->window());
+ }
+ 
+ QWaylandXdgSurfaceV6::Popup::~Popup()
+@@ -181,6 +182,8 @@ QWaylandXdgSurfaceV6::Popup::~Popup()
+     if (isInitialized())
+         destroy();
+ 
++    m_parent->window()->removeChildPopup(m_xdgSurface->window());
++
+     if (m_grabbing) {
+         auto *shell = m_xdgSurface->m_shell;
+         Q_ASSERT(shell->m_topmostGrabbingPopup == this);
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
+index 03164316..e8da8ba1 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
+@@ -68,20 +68,6 @@ QWaylandShellSurface *QWaylandXdgShellV6Integration::createShellSurface(QWayland
+     return m_xdgShell->getXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellV6Integration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus)
+-{
+-    if (newFocus) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurfaceV6 *>(newFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowActivated(newFocus);
+-    }
+-    if (oldFocus && qobject_cast<QWaylandXdgSurfaceV6 *>(oldFocus->shellSurface())) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurfaceV6 *>(oldFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowDeactivated(oldFocus);
+-    }
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
+index 261f8cbb..c1bcd5c6 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
+@@ -65,7 +65,6 @@ public:
+     QWaylandXdgShellV6Integration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShellV6> m_xdgShell;
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
+index f3e3c330..fa6d5808 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
+@@ -67,11 +67,6 @@ QWaylandXdgSurface::Toplevel::Toplevel(QWaylandXdgSurface *xdgSurface)
+ 
+ QWaylandXdgSurface::Toplevel::~Toplevel()
+ {
+-    if (m_applied.states & Qt::WindowActive) {
+-        QWaylandWindow *window = m_xdgSurface->window();
+-        window->display()->handleWindowDeactivated(window);
+-    }
+-
+     // The protocol spec requires that the decoration object is deleted before xdg_toplevel.
+     delete m_decoration;
+     m_decoration = nullptr;
+@@ -85,16 +80,15 @@ void QWaylandXdgSurface::Toplevel::applyConfigure()
+     if (!(m_applied.states & (Qt::WindowMaximized|Qt::WindowFullScreen)))
+         m_normalSize = m_xdgSurface->m_window->windowFrameGeometry().size();
+ 
+-    if ((m_pending.states & Qt::WindowActive) && !(m_applied.states & Qt::WindowActive))
++    if ((m_pending.states & Qt::WindowActive) && !(m_applied.states & Qt::WindowActive)
++        && !m_xdgSurface->m_window->display()->isKeyboardAvailable())
+         m_xdgSurface->m_window->display()->handleWindowActivated(m_xdgSurface->m_window);
+ 
+-    if (!(m_pending.states & Qt::WindowActive) && (m_applied.states & Qt::WindowActive))
++    if (!(m_pending.states & Qt::WindowActive) && (m_applied.states & Qt::WindowActive)
++        && !m_xdgSurface->m_window->display()->isKeyboardAvailable())
+         m_xdgSurface->m_window->display()->handleWindowDeactivated(m_xdgSurface->m_window);
+ 
+-    // TODO: none of the other plugins send WindowActive either, but is it on purpose?
+-    Qt::WindowStates statesWithoutActive = m_pending.states & ~Qt::WindowActive;
+-
+-    m_xdgSurface->m_window->handleWindowStatesChanged(statesWithoutActive);
++    m_xdgSurface->m_window->handleWindowStatesChanged(m_pending.states);
+ 
+     if (m_pending.size.isEmpty()) {
+         // An empty size in the configure means it's up to the client to choose the size
+@@ -105,8 +99,6 @@ void QWaylandXdgSurface::Toplevel::applyConfigure()
+         m_xdgSurface->m_window->resizeFromApplyConfigure(m_pending.size);
+     }
+ 
+-    m_xdgSurface->setSizeHints();
+-
+     m_applied = m_pending;
+     qCDebug(lcQpaWayland) << "Applied pending xdg_toplevel configure event:" << m_applied.size << m_applied.states;
+ }
+@@ -203,12 +195,17 @@ QtWayland::xdg_toplevel::resize_edge QWaylandXdgSurface::Toplevel::convertToResi
+                 | ((edges & Qt::RightEdge) ? resize_edge_right : 0));
+ }
+ 
+-QWaylandXdgSurface::Popup::Popup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parent,
++QWaylandXdgSurface::Popup::Popup(QWaylandXdgSurface *xdgSurface, QWaylandWindow *parent,
+                                  QtWayland::xdg_positioner *positioner)
+-    : xdg_popup(xdgSurface->get_popup(parent->object(), positioner->object()))
+-    , m_xdgSurface(xdgSurface)
++    : m_xdgSurface(xdgSurface)
++    , m_parentXdgSurface(qobject_cast<QWaylandXdgSurface *>(parent->shellSurface()))
+     , m_parent(parent)
+ {
++
++    init(xdgSurface->get_popup(m_parentXdgSurface ? m_parentXdgSurface->object() : nullptr, positioner->object()));
++    if (m_parent) {
++        m_parent->addChildPopup(m_xdgSurface->window());
++    }
+ }
+ 
+ QWaylandXdgSurface::Popup::~Popup()
+@@ -216,10 +213,24 @@ QWaylandXdgSurface::Popup::~Popup()
+     if (isInitialized())
+         destroy();
+ 
++    if (m_parent) {
++        m_parent->removeChildPopup(m_xdgSurface->window());
++    }
++
+     if (m_grabbing) {
+         auto *shell = m_xdgSurface->m_shell;
+         Q_ASSERT(shell->m_topmostGrabbingPopup == this);
+-        shell->m_topmostGrabbingPopup = m_parent->m_popup;
++        shell->m_topmostGrabbingPopup = m_parentXdgSurface ? m_parentXdgSurface->m_popup : nullptr;
++        m_grabbing = false;
++
++        // Synthesize Qt enter/leave events for popup
++        QWindow *leave = nullptr;
++        if (m_xdgSurface && m_xdgSurface->window())
++            leave = m_xdgSurface->window()->window();
++        QWindowSystemInterface::handleLeaveEvent(leave);
++
++        if (QWindow *enter = QGuiApplication::topLevelAt(QCursor::pos()))
++            QWindowSystemInterface::handleEnterEvent(enter, enter->mapFromGlobal(QCursor::pos()), QCursor::pos());
+     }
+ }
+ 
+@@ -257,6 +268,7 @@ QWaylandXdgSurface::QWaylandXdgSurface(QWaylandXdgShell *shell, ::xdg_surface *s
+                 m_toplevel->set_parent(parentXdgSurface->m_toplevel->object());
+         }
+     }
++    setSizeHints();
+ }
+ 
+ QWaylandXdgSurface::~QWaylandXdgSurface()
+@@ -400,8 +412,6 @@ void QWaylandXdgSurface::setPopup(QWaylandWindow *parent)
+ {
+     Q_ASSERT(!m_toplevel && !m_popup);
+ 
+-    auto parentXdgSurface = static_cast<QWaylandXdgSurface *>(parent->shellSurface());
+-
+     auto positioner = new QtWayland::xdg_positioner(m_shell->create_positioner());
+     // set_popup expects a position relative to the parent
+     QPoint transientPos = m_window->geometry().topLeft(); // this is absolute
+@@ -414,8 +424,9 @@ void QWaylandXdgSurface::setPopup(QWaylandWindow *parent)
+     positioner->set_anchor(QtWayland::xdg_positioner::anchor_top_left);
+     positioner->set_gravity(QtWayland::xdg_positioner::gravity_bottom_right);
+     positioner->set_size(m_window->geometry().width(), m_window->geometry().height());
+-    m_popup = new Popup(this, parentXdgSurface, positioner);
++    m_popup = new Popup(this, parent, positioner);
+     positioner->destroy();
++
+     delete positioner;
+ }
+ 
+@@ -437,6 +448,23 @@ void QWaylandXdgSurface::setGrabPopup(QWaylandWindow *parent, QWaylandInputDevic
+     }
+     setPopup(parent);
+     m_popup->grab(device, serial);
++
++    // Synthesize Qt enter/leave events for popup
++    if (!parent)
++        return;
++    QWindow *current = QGuiApplication::topLevelAt(QCursor::pos());
++    QWindow *leave = parent->window();
++    if (current != leave)
++        return;
++
++    QWindowSystemInterface::handleLeaveEvent(leave);
++
++    QWindow *enter = nullptr;
++    if (m_popup && m_popup->m_xdgSurface && m_popup->m_xdgSurface->window())
++        enter = m_popup->m_xdgSurface->window()->window();
++
++    if (enter)
++        QWindowSystemInterface::handleEnterEvent(enter, enter->mapFromGlobal(QCursor::pos()), QCursor::pos());
+ }
+ 
+ void QWaylandXdgSurface::xdg_surface_configure(uint32_t serial)
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
+index 96785205..4b518f0a 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
+@@ -131,14 +131,15 @@ private:
+ 
+     class Popup : public QtWayland::xdg_popup {
+     public:
+-        Popup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parent, QtWayland::xdg_positioner *positioner);
++        Popup(QWaylandXdgSurface *xdgSurface, QWaylandWindow *parent, QtWayland::xdg_positioner *positioner);
+         ~Popup() override;
+ 
+         void grab(QWaylandInputDevice *seat, uint serial);
+         void xdg_popup_popup_done() override;
+ 
+         QWaylandXdgSurface *m_xdgSurface = nullptr;
+-        QWaylandXdgSurface *m_parent = nullptr;
++        QWaylandXdgSurface *m_parentXdgSurface = nullptr;
++        QWaylandWindow *m_parent = nullptr;
+         bool m_grabbing = false;
+     };
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
+index 8769d971..da0dd6a7 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
+@@ -69,20 +69,6 @@ QWaylandShellSurface *QWaylandXdgShellIntegration::createShellSurface(QWaylandWi
+     return m_xdgShell->getXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellIntegration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus)
+-{
+-    if (newFocus) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurface *>(newFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowActivated(newFocus);
+-    }
+-    if (oldFocus && qobject_cast<QWaylandXdgSurface *>(oldFocus->shellSurface())) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurface *>(oldFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowDeactivated(oldFocus);
+-    }
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
+index b6caa6c9..2f929f98 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
+@@ -65,7 +65,6 @@ public:
+     QWaylandXdgShellIntegration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShell> m_xdgShell;
+diff --git a/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp b/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
+index 526d0ef4..f50ccf30 100644
+--- a/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
++++ b/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
+@@ -39,7 +39,10 @@
+ 
+ #include "qwaylandinputmethodeventbuilder_p.h"
+ 
++#include <QBrush>
++#include <QGuiApplication>
+ #include <QInputMethod>
++#include <QPalette>
+ #include <QTextCharFormat>
+ 
+ #ifdef QT_BUILD_WAYLANDCOMPOSITOR_LIB
+@@ -81,32 +84,38 @@ void QWaylandInputMethodEventBuilder::addPreeditStyling(uint32_t index, uint32_t
+     QTextCharFormat format;
+ 
+     switch (style) {
+-    case 0:
+-    case 1:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_NONE:
++        break;
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_DEFAULT:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_UNDERLINE:
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-    case 2:
+-    case 3:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_ACTIVE:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_INACTIVE:
+         format.setFontWeight(QFont::Bold);
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-    case 4:
+-        format.setFontUnderline(true);
+-        format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+-        m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_HIGHLIGHT:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_SELECTION:
++        {
++            format.setFontUnderline(true);
++            format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
++            QPalette palette = qApp->palette();
++            format.setBackground(QBrush(palette.color(QPalette::Active, QPalette::Highlight)));
++            format.setForeground(QBrush(palette.color(QPalette::Active, QPalette::HighlightedText)));
++            m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
++        }
+         break;
+-    case 5:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_INCORRECT:
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::WaveUnderline);
+         format.setUnderlineColor(QColor(Qt::red));
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-//    case QtWayland::wl_text_input::preedit_style_selection:
+-//    case QtWayland::wl_text_input::preedit_style_none:
+     default:
+         break;
+     }
+@@ -153,7 +162,7 @@ QInputMethodEvent QWaylandInputMethodEventBuilder::buildPreedit(const QString &t
+ 
+     if (m_preeditCursor < 0) {
+         attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, 0, QVariant()));
+-    } else if (m_preeditCursor > 0) {
++    } else {
+         attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, indexFromWayland(text, m_preeditCursor), 1, QVariant()));
+     }
+ 
+diff --git a/qtwayland/src/shared/qwaylandmimehelper.cpp b/qtwayland/src/shared/qwaylandmimehelper.cpp
+index a5fdd34d..e2fe1928 100644
+--- a/qtwayland/src/shared/qwaylandmimehelper.cpp
++++ b/qtwayland/src/shared/qwaylandmimehelper.cpp
+@@ -60,7 +60,7 @@ QByteArray QWaylandMimeHelper::getByteArray(QMimeData *mimeData, const QString &
+             buf.open(QIODevice::ReadWrite);
+             QByteArray fmt = "BMP";
+             if (mimeType.startsWith(QLatin1String("image/"))) {
+-                QByteArray imgFmt = mimeType.mid(6).toUpper().toLatin1();
++                QByteArray imgFmt = mimeType.mid(6).toLower().toLatin1();
+                 if (QImageWriter::supportedImageFormats().contains(imgFmt))
+                     fmt = imgFmt;
+             }
+@@ -74,7 +74,7 @@ QByteArray QWaylandMimeHelper::getByteArray(QMimeData *mimeData, const QString &
+         QList<QUrl> urls = mimeData->urls();
+         for (int i = 0; i < urls.count(); ++i) {
+             content.append(urls.at(i).toEncoded());
+-            content.append('\n');
++            content.append("\r\n");
+         }
+     } else {
+         content = mimeData->data(mimeType);
+diff --git a/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp b/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
+index 1568b3b9..067410d0 100644
+--- a/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
++++ b/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
+@@ -35,7 +35,7 @@
+ 
+ using namespace MockCompositor;
+ 
+-constexpr int dataDeviceVersion = 1;
++constexpr int dataDeviceVersion = 3;
+ 
+ class DataDeviceCompositor : public DefaultCompositor {
+ public:
+diff --git a/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp b/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
+index 9312c2e5..2ea382f1 100644
+--- a/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
++++ b/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
+@@ -73,6 +73,7 @@ private slots:
+     void multiTouch();
+     void multiTouchUpAndMotionFrame();
+     void tapAndMoveInSameFrame();
++    void cancelTouch();
+ };
+ 
+ void tst_seatv5::bindsToSeat()
+@@ -646,5 +647,34 @@ void tst_seatv5::tapAndMoveInSameFrame()
+     QTRY_COMPARE(window.m_events.last().touchPoints.first().state(), Qt::TouchPointState::TouchPointReleased);
+ }
+ 
++void tst_seatv5::cancelTouch()
++{
++    TouchWindow window;
++    QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
++
++    exec([=] {
++        auto *t = touch();
++        auto *c = client();
++        t->sendDown(xdgToplevel()->surface(), {32, 32}, 1);
++        t->sendFrame(c);
++        t->sendCancel(c);
++        t->sendFrame(c);
++    });
++
++    QTRY_VERIFY(!window.m_events.empty());
++    {
++        auto e = window.m_events.takeFirst();
++        QCOMPARE(e.type, QEvent::TouchBegin);
++        QCOMPARE(e.touchPointStates, Qt::TouchPointPressed);
++        QCOMPARE(e.touchPoints.length(), 1);
++        QCOMPARE(e.touchPoints.first().pos(), QPointF(32-window.frameMargins().left(), 32-window.frameMargins().top()));
++    }
++    {
++        auto e = window.m_events.takeFirst();
++        QCOMPARE(e.type, QEvent::TouchCancel);
++        QCOMPARE(e.touchPoints.length(), 0);
++    }
++}
++
+ QCOMPOSITOR_TEST_MAIN(tst_seatv5)
+ #include "tst_seatv5.moc"
+diff --git a/qtwayland/tests/auto/client/shared/corecompositor.cpp b/qtwayland/tests/auto/client/shared/corecompositor.cpp
+index 5c6c83ba..fa9b7662 100644
+--- a/qtwayland/tests/auto/client/shared/corecompositor.cpp
++++ b/qtwayland/tests/auto/client/shared/corecompositor.cpp
+@@ -27,6 +27,7 @@
+ ****************************************************************************/
+ 
+ #include "corecompositor.h"
++#include <thread>
+ 
+ namespace MockCompositor {
+ 
+diff --git a/qtwayland/tests/auto/client/shared/coreprotocol.cpp b/qtwayland/tests/auto/client/shared/coreprotocol.cpp
+index 0d988521..d1a2e7cb 100644
+--- a/qtwayland/tests/auto/client/shared/coreprotocol.cpp
++++ b/qtwayland/tests/auto/client/shared/coreprotocol.cpp
+@@ -451,6 +451,13 @@ void Touch::sendFrame(wl_client *client)
+         send_frame(r->handle);
+ }
+ 
++void Touch::sendCancel(wl_client *client)
++{
++    const auto touchResources = resourceMap().values(client);
++    for (auto *r : touchResources)
++        send_cancel(r->handle);
++}
++
+ uint Keyboard::sendEnter(Surface *surface)
+ {
+     auto serial = m_seat->m_compositor->nextSerial();
+diff --git a/qtwayland/tests/auto/client/shared/coreprotocol.h b/qtwayland/tests/auto/client/shared/coreprotocol.h
+index a1af137a..210d8ddb 100644
+--- a/qtwayland/tests/auto/client/shared/coreprotocol.h
++++ b/qtwayland/tests/auto/client/shared/coreprotocol.h
+@@ -158,7 +158,7 @@ class WlCompositor : public Global, public QtWaylandServer::wl_compositor
+ {
+     Q_OBJECT
+ public:
+-    explicit WlCompositor(CoreCompositor *compositor, int version = 3)
++    explicit WlCompositor(CoreCompositor *compositor, int version = 4)
+         : QtWaylandServer::wl_compositor(compositor->m_display, version)
+         , m_compositor(compositor)
+     {}
+@@ -364,6 +364,7 @@ public:
+     uint sendUp(wl_client *client, int id);
+     void sendMotion(wl_client *client, const QPointF &position, int id);
+     void sendFrame(wl_client *client);
++    void sendCancel(wl_client *client);
+ 
+     Seat *m_seat = nullptr;
+ };
+diff --git a/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp b/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
+index a415cbf5..b1d3d07d 100644
+--- a/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
++++ b/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
+@@ -342,7 +342,7 @@ Compositor::Compositor(MockCompositor *mockCompositor)
+         exit(EXIT_FAILURE);
+     }
+ 
+-    wl_global_create(m_display, &wl_compositor_interface, 1, this, bindCompositor);
++    wl_global_create(m_display, &wl_compositor_interface, 4, this, bindCompositor);
+ 
+     m_data_device_manager.reset(new DataDeviceManager(this, m_display));
+ 
+diff --git a/qtwayland/tests/auto/client/shared_old/mocksurface.cpp b/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
+index e9df5f90..c3246e4a 100644
+--- a/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
++++ b/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
+@@ -125,6 +125,16 @@ void Surface::surface_damage(Resource *resource,
+     Q_UNUSED(height);
+ }
+ 
++void Surface::surface_damage_buffer(Resource *resource,
++                                    int32_t x, int32_t y, int32_t width, int32_t height)
++{
++    Q_UNUSED(resource);
++    Q_UNUSED(x);
++    Q_UNUSED(y);
++    Q_UNUSED(width);
++    Q_UNUSED(height);
++}
++
+ void Surface::surface_frame(Resource *resource,
+                             uint32_t callback)
+ {
+diff --git a/qtwayland/tests/auto/client/shared_old/mocksurface.h b/qtwayland/tests/auto/client/shared_old/mocksurface.h
+index 949dc23d..d176837e 100644
+--- a/qtwayland/tests/auto/client/shared_old/mocksurface.h
++++ b/qtwayland/tests/auto/client/shared_old/mocksurface.h
+@@ -65,6 +65,8 @@ protected:
+                         struct wl_resource *buffer, int x, int y) override;
+     void surface_damage(Resource *resource,
+                         int32_t x, int32_t y, int32_t width, int32_t height) override;
++    void surface_damage_buffer(Resource *resource,
++                               int32_t x, int32_t y, int32_t width, int32_t height) override;
+     void surface_frame(Resource *resource,
+                        uint32_t callback) override;
+     void surface_commit(Resource *resource) override;
+diff --git a/qtwayland/tests/auto/client/surface/tst_surface.cpp b/qtwayland/tests/auto/client/surface/tst_surface.cpp
+index 95e4e609..60c672ce 100644
+--- a/qtwayland/tests/auto/client/surface/tst_surface.cpp
++++ b/qtwayland/tests/auto/client/surface/tst_surface.cpp
+@@ -129,6 +129,10 @@ void tst_surface::waitForFrameCallbackGl()
+     // Make sure we follow frame callbacks for some frames
+     for (int i = 0; i < 5; ++i) {
+         xdgPingAndWaitForPong(); // Make sure things have happened on the client
++        if (!qEnvironmentVariableIntValue("QT_WAYLAND_DISABLE_WINDOWDECORATION") && i == 0) {
++            QCOMPARE(bufferSpy.count(), 1);
++            bufferSpy.removeFirst();
++        }
+         exec([&] {
+             QVERIFY(bufferSpy.empty()); // Make sure no extra buffers have arrived
+             QVERIFY(!xdgToplevel()->surface()->m_waitingFrameCallbacks.empty());
+diff --git a/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp b/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
+index 2277bbb8..747875b4 100644
+--- a/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
++++ b/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
+@@ -31,6 +31,7 @@
+ #include <QtGui/QOpenGLWindow>
+ #include <QtGui/qpa/qplatformnativeinterface.h>
+ #include <QtWaylandClient/private/wayland-wayland-client-protocol.h>
++#include <QtWaylandClient/private/qwaylandwindow_p.h>
+ 
+ using namespace MockCompositor;
+ 
+@@ -45,6 +46,7 @@ private slots:
+     void configureStates();
+     void popup();
+     void tooltipOnPopup();
++    void tooltipAndSiblingPopup();
+     void switchPopups();
+     void hidePopupParent();
+     void pongs();
+@@ -138,6 +140,7 @@ void tst_xdgshell::configureSize()
+ 
+ void tst_xdgshell::configureStates()
+ {
++    QVERIFY(qputenv("QT_WAYLAND_FRAME_CALLBACK_TIMEOUT", "0"));
+     QRasterWindow window;
+     window.resize(64, 48);
+     window.show();
+@@ -154,9 +157,12 @@ void tst_xdgshell::configureStates()
+     // Toplevel windows don't know their position on xdg-shell
+ //    QCOMPARE(window.frameGeometry().topLeft(), QPoint()); // TODO: this doesn't currently work when window decorations are enabled
+ 
+-//    QEXPECT_FAIL("", "configure has already been acked, we shouldn't have to wait for isActive", Continue);
+-//    QVERIFY(window.isActive());
+-    QTRY_VERIFY(window.isActive()); // Just make sure it eventually get's set correctly
++    // window.windowstate() is driven by keyboard focus, however for decorations we want to follow
++    // XDGShell this is internal to QtWayland so it is queried directly
++    auto waylandWindow = static_cast<QtWaylandClient::QWaylandWindow *>(window.handle());
++    Q_ASSERT(waylandWindow);
++    QTRY_VERIFY(waylandWindow->windowStates().testFlag(
++            Qt::WindowActive)); // Just make sure it eventually get's set correctly
+ 
+     const QSize screenSize(640, 480);
+     const uint maximizedSerial = exec([=] {
+@@ -186,6 +192,7 @@ void tst_xdgshell::configureStates()
+     QCOMPARE(window.windowStates(), Qt::WindowNoState);
+     QCOMPARE(window.frameGeometry().size(), windowedSize);
+ //    QCOMPARE(window.frameGeometry().topLeft(), QPoint()); // TODO: this doesn't currently work when window decorations are enabled
++    QVERIFY(qunsetenv("QT_WAYLAND_FRAME_CALLBACK_TIMEOUT"));
+ }
+ 
+ void tst_xdgshell::popup()
+@@ -340,6 +347,92 @@ void tst_xdgshell::tooltipOnPopup()
+     QCOMPOSITOR_TRY_COMPARE(xdgPopup(0), nullptr);
+ }
+ 
++void tst_xdgshell::tooltipAndSiblingPopup()
++{
++    class ToolTip : public QRasterWindow {
++    public:
++        explicit ToolTip(QWindow *parent) {
++            setTransientParent(parent);
++            setFlags(Qt::ToolTip);
++            resize(100, 100);
++            show();
++        }
++        void mousePressEvent(QMouseEvent *event) override {
++            QRasterWindow::mousePressEvent(event);
++            m_popup = new QRasterWindow;
++            m_popup->setTransientParent(transientParent());
++            m_popup->setFlags(Qt::Popup);
++            m_popup->resize(100, 100);
++            m_popup->show();
++        }
++
++        QRasterWindow *m_popup = nullptr;
++    };
++
++    class Window : public QRasterWindow {
++    public:
++        void mousePressEvent(QMouseEvent *event) override {
++            QRasterWindow::mousePressEvent(event);
++            m_tooltip = new ToolTip(this);
++        }
++        ToolTip *m_tooltip = nullptr;
++    };
++
++    Window window;
++    window.resize(200, 200);
++    window.show();
++
++    QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
++    exec([=] { xdgToplevel()->sendCompleteConfigure(); });
++    QCOMPOSITOR_TRY_VERIFY(xdgToplevel()->m_xdgSurface->m_committedConfigureSerial);
++
++    exec([=] {
++        auto *surface = xdgToplevel()->surface();
++        auto *p = pointer();
++        auto *c = client();
++        p->sendEnter(surface, {100, 100});
++        p->sendFrame(c);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_pressed);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_released);
++        p->sendFrame(c);
++        p->sendLeave(surface);
++        p->sendFrame(c);
++    });
++
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup());
++    exec([=] { xdgPopup()->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup()->m_xdgSurface->m_committedConfigureSerial);
++    QCOMPOSITOR_TRY_VERIFY(!xdgPopup()->m_grabbed);
++
++    exec([=] {
++        auto *surface = xdgPopup()->surface();
++        auto *p = pointer();
++        auto *c = client();
++        p->sendEnter(surface, {100, 100});
++        p->sendFrame(c);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_pressed);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_released);
++        p->sendFrame(c);
++    });
++
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1));
++    exec([=] { xdgPopup(1)->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1)->m_xdgSurface->m_committedConfigureSerial);
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1)->m_grabbed);
++
++    // Close the middle tooltip (it should not close the sibling popup)
++    window.m_tooltip->close();
++
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(1), nullptr);
++    // Verify the remaining xdg surface is a grab popup..
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(0));
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(0)->m_grabbed);
++
++    window.m_tooltip->m_popup->close();
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(1), nullptr);
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(0), nullptr);
++}
++
+ // QTBUG-65680
+ void tst_xdgshell::switchPopups()
+ {
+@@ -505,7 +598,7 @@ void tst_xdgshell::minMaxSize()
+     window.show();
+     QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
+ 
+-    exec([=] { xdgToplevel()->sendCompleteConfigure(); });
++    // we don't roundtrip with our configuration the initial commit should be correct
+ 
+     QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.minSize, QSize(100, 100));
+     QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.maxSize, QSize(1000, 1000));
+Submodule qtwebchannel 618422ee..f8949655:
+diff --git a/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp b/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
+index 536eb5c..898d769 100644
+--- a/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
++++ b/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
+@@ -186,8 +186,6 @@ Q_DECLARE_TYPEINFO(OverloadResolutionCandidate, Q_MOVABLE_TYPE);
+ QMetaObjectPublisher::QMetaObjectPublisher(QWebChannel *webChannel)
+     : QObject(webChannel)
+     , webChannel(webChannel)
+-    , signalHandler(this)
+-    , clientIsIdle(false)
+     , blockUpdates(false)
+     , propertyUpdatesInitialized(false)
+ {
+@@ -301,17 +299,17 @@ QJsonObject QMetaObjectPublisher::classInfoForObject(const QObject *object, QWeb
+     return data;
+ }
+ 
+-void QMetaObjectPublisher::setClientIsIdle(bool isIdle)
++void QMetaObjectPublisher::setClientIsIdle(bool isIdle, QWebChannelAbstractTransport *transport)
+ {
+-    if (clientIsIdle == isIdle) {
+-        return;
+-    }
+-    clientIsIdle = isIdle;
+-    if (!isIdle && timer.isActive()) {
+-        timer.stop();
+-    } else if (isIdle && !timer.isActive()) {
+-        timer.start(PROPERTY_UPDATE_INTERVAL, this);
+-    }
++    transportState[transport].clientIsIdle = isIdle;
++    if (isIdle)
++        sendEnqueuedPropertyUpdates(transport);
++}
++
++bool QMetaObjectPublisher::isClientIdle(QWebChannelAbstractTransport *transport)
++{
++    auto found = transportState.find(transport);
++    return found != transportState.end() && found.value().clientIsIdle;
+ }
+ 
+ QJsonObject QMetaObjectPublisher::initializeClient(QWebChannelAbstractTransport *transport)
+@@ -333,6 +331,7 @@ QJsonObject QMetaObjectPublisher::initializeClient(QWebChannelAbstractTransport
+ 
+ void QMetaObjectPublisher::initializePropertyUpdates(const QObject *const object, const QJsonObject &objectInfo)
+ {
++    auto *signalHandler = signalHandlerFor(object);
+     foreach (const QJsonValue &propertyInfoVar, objectInfo[KEY_PROPERTIES].toArray()) {
+         const QJsonArray &propertyInfo = propertyInfoVar.toArray();
+         if (propertyInfo.size() < 2) {
+@@ -353,19 +352,19 @@ void QMetaObjectPublisher::initializePropertyUpdates(const QObject *const object
+ 
+         // Only connect for a property update once
+         if (connectedProperties.isEmpty()) {
+-            signalHandler.connectTo(object, signalIndex);
++            signalHandler->connectTo(object, signalIndex);
+         }
+ 
+         connectedProperties.insert(propertyIndex);
+     }
+ 
+     // also always connect to destroyed signal
+-    signalHandler.connectTo(object, s_destroyedSignalIndex);
++    signalHandler->connectTo(object, s_destroyedSignalIndex);
+ }
+ 
+ void QMetaObjectPublisher::sendPendingPropertyUpdates()
+ {
+-    if (blockUpdates || !clientIsIdle || pendingPropertyUpdates.isEmpty()) {
++    if (blockUpdates) {
+         return;
+     }
+ 
+@@ -415,18 +414,19 @@ void QMetaObjectPublisher::sendPendingPropertyUpdates()
+ 
+     // data does not contain specific updates
+     if (!data.isEmpty()) {
+-        setClientIsIdle(false);
+-
+         message[KEY_DATA] = data;
+-        broadcastMessage(message);
++        enqueueBroadcastMessage(message);
+     }
+ 
+     // send every property update which is not supposed to be broadcasted
+     const QHash<QWebChannelAbstractTransport*, QJsonArray>::const_iterator suend = specificUpdates.constEnd();
+     for (QHash<QWebChannelAbstractTransport*, QJsonArray>::const_iterator it = specificUpdates.constBegin(); it != suend; ++it) {
+         message[KEY_DATA] = it.value();
+-        it.key()->sendMessage(message);
++        enqueueMessage(message, it.key());
+     }
++
++    for (auto state = transportState.begin(); state != transportState.end(); ++state)
++        sendEnqueuedPropertyUpdates(state.key());
+ }
+ 
+ QVariant QMetaObjectPublisher::invokeMethod(QObject *const object, const QMetaMethod &method,
+@@ -572,7 +572,7 @@ void QMetaObjectPublisher::signalEmitted(const QObject *object, const int signal
+         }
+     } else {
+         pendingPropertyUpdates[object][signalIndex] = arguments;
+-        if (clientIsIdle && !blockUpdates && !timer.isActive()) {
++        if (!blockUpdates && !timer.isActive()) {
+             timer.start(PROPERTY_UPDATE_INTERVAL, this);
+         }
+     }
+@@ -590,7 +590,7 @@ void QMetaObjectPublisher::objectDestroyed(const QObject *object)
+     // only remove from handler when we initialized the property updates
+     // cf: https://bugreports.qt.io/browse/QTBUG-60250
+     if (propertyUpdatesInitialized) {
+-        signalHandler.remove(object);
++        signalHandlerFor(object)->remove(object);
+         signalToPropertyMap.remove(object);
+     }
+     pendingPropertyUpdates.remove(object);
+@@ -852,6 +852,52 @@ void QMetaObjectPublisher::broadcastMessage(const QJsonObject &message) const
+     }
+ }
+ 
++void QMetaObjectPublisher::enqueueBroadcastMessage(const QJsonObject &message)
++{
++    if (webChannel->d_func()->transports.isEmpty()) {
++        qWarning("QWebChannel is not connected to any transports, cannot send message: %s",
++                 QJsonDocument(message).toJson().constData());
++        return;
++    }
++
++    for (auto *transport : webChannel->d_func()->transports) {
++        auto &state = transportState[transport];
++        state.queuedMessages.append(message);
++    }
++}
++
++void QMetaObjectPublisher::enqueueMessage(const QJsonObject &message,
++                                          QWebChannelAbstractTransport *transport)
++{
++    auto &state = transportState[transport];
++    state.queuedMessages.append(message);
++}
++
++void QMetaObjectPublisher::sendEnqueuedPropertyUpdates(QWebChannelAbstractTransport *transport)
++{
++    auto found = transportState.find(transport);
++    if (found != transportState.end() && found.value().clientIsIdle
++        && !found.value().queuedMessages.isEmpty()) {
++
++        // If the client is connected with an in-process transport, it can
++        // happen that a message triggers a subsequent property change. In
++        // that case, we need to ensure that the queued messages have already
++        // been cleared; otherwise the recursive call will send everythig again.
++        // Case in point: The qmlwebchannel tests fail if we don't clear the
++        // queued messages before sending them out.
++        // For that same reason set the client to "busy" (aka non-idle) just
++        // right before sending out the messages; otherwise a potential
++        // "Idle" type message will not correctly restore the Idle state.
++        const auto messages = std::move(found.value().queuedMessages);
++        Q_ASSERT(found.value().queuedMessages.isEmpty());
++        found.value().clientIsIdle = false;
++
++        for (const auto &message : messages) {
++            transport->sendMessage(message);
++        }
++    }
++}
++
+ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannelAbstractTransport *transport)
+ {
+     if (!webChannel->d_func()->transports.contains(transport)) {
+@@ -866,7 +912,7 @@ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannel
+ 
+     const MessageType type = toType(message.value(KEY_TYPE));
+     if (type == TypeIdle) {
+-        setClientIsIdle(true);
++        setClientIsIdle(true, transport);
+     } else if (type == TypeInit) {
+         if (!message.contains(KEY_ID)) {
+             qWarning("JSON message object is missing the id property: %s",
+@@ -913,9 +959,9 @@ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannel
+                 return;
+             transport->sendMessage(createResponse(message.value(KEY_ID), wrapResult(result, transport)));
+         } else if (type == TypeConnectToSignal) {
+-            signalHandler.connectTo(object, message.value(KEY_SIGNAL).toInt(-1));
++            signalHandlerFor(object)->connectTo(object, message.value(KEY_SIGNAL).toInt(-1));
+         } else if (type == TypeDisconnectFromSignal) {
+-            signalHandler.disconnectFrom(object, message.value(KEY_SIGNAL).toInt(-1));
++            signalHandlerFor(object)->disconnectFrom(object, message.value(KEY_SIGNAL).toInt(-1));
+         } else if (type == TypeSetProperty) {
+             setProperty(object, message.value(KEY_PROPERTY).toInt(-1),
+                         message.value(KEY_VALUE));
+@@ -931,6 +977,7 @@ void QMetaObjectPublisher::setBlockUpdates(bool block)
+     blockUpdates = block;
+ 
+     if (!blockUpdates) {
++        timer.start(PROPERTY_UPDATE_INTERVAL, this);
+         sendPendingPropertyUpdates();
+     } else if (timer.isActive()) {
+         timer.stop();
+@@ -948,4 +995,15 @@ void QMetaObjectPublisher::timerEvent(QTimerEvent *event)
+     }
+ }
+ 
++SignalHandler<QMetaObjectPublisher> *QMetaObjectPublisher::signalHandlerFor(const QObject *object)
++{
++    auto thread = object->thread();
++    auto it = signalHandlers.find(thread);
++    if (it == signalHandlers.end()) {
++        it = signalHandlers.emplace(thread, this).first;
++        it->second.moveToThread(thread);
++    }
++    return &it->second;
++}
++
+ QT_END_NAMESPACE
+diff --git a/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h b/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
+index bbd9875..4713ef1 100644
+--- a/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
++++ b/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
+@@ -59,6 +59,9 @@
+ #include <QBasicTimer>
+ #include <QPointer>
+ #include <QJsonObject>
++#include <QQueue>
++
++#include <unordered_map>
+ 
+ #include "qwebchannelglobal.h"
+ 
+@@ -109,17 +112,36 @@ public:
+      */
+     void broadcastMessage(const QJsonObject &message) const;
+ 
++    /**
++     * Enqueue the given @p message to all known transports.
++     */
++    void enqueueBroadcastMessage(const QJsonObject &message);
++
++    /**
++     * Enqueue the given @p message to @p transport.
++     */
++    void enqueueMessage(const QJsonObject &message, QWebChannelAbstractTransport *transport);
++
++    /**
++     * If client for given @p transport is idle, send queued messaged to @p transport and then mark
++     * the client as not idle.
++     */
++    void sendEnqueuedPropertyUpdates(QWebChannelAbstractTransport *transport);
++
+     /**
+      * Serialize the QMetaObject of @p object and return it in JSON form.
+      */
+     QJsonObject classInfoForObject(const QObject *object, QWebChannelAbstractTransport *transport);
+ 
+     /**
+-     * Set the client to idle or busy, based on the value of @p isIdle.
+-     *
+-     * When the value changed, start/stop the property update timer accordingly.
++     * Set the client to idle or busy for a single @p transport, based on the value of @p isIdle.
++     */
++    void setClientIsIdle(bool isIdle, QWebChannelAbstractTransport *transport);
++
++    /**
++     * Check that client is idle for @p transport.
+      */
+-    void setClientIsIdle(bool isIdle);
++    bool isClientIdle(QWebChannelAbstractTransport *transport);
+ 
+     /**
+      * Initialize clients by sending them the class information of the registered objects.
+@@ -272,10 +294,18 @@ private:
+     friend class TestWebChannel;
+ 
+     QWebChannel *webChannel;
+-    SignalHandler<QMetaObjectPublisher> signalHandler;
++    std::unordered_map<const QThread*, SignalHandler<QMetaObjectPublisher>> signalHandlers;
++    SignalHandler<QMetaObjectPublisher> *signalHandlerFor(const QObject *object);
+ 
+-    // true when the client is idle, false otherwise
+-    bool clientIsIdle;
++    struct TransportState
++    {
++        TransportState() : clientIsIdle(false) { }
++        // true when the client is idle, false otherwise
++        bool clientIsIdle;
++        // messages to send
++        QQueue<QJsonObject> queuedMessages;
++    };
++    QHash<QWebChannelAbstractTransport *, TransportState> transportState;
+ 
+     // true when no property updates should be sent, false otherwise
+     bool blockUpdates;
+diff --git a/qtwebchannel/src/webchannel/signalhandler_p.h b/qtwebchannel/src/webchannel/signalhandler_p.h
+index 27afadb..d77373c 100644
+--- a/qtwebchannel/src/webchannel/signalhandler_p.h
++++ b/qtwebchannel/src/webchannel/signalhandler_p.h
+@@ -56,6 +56,7 @@
+ #include <QVector>
+ #include <QMetaMethod>
+ #include <QDebug>
++#include <QThread>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -71,6 +72,7 @@ static const int s_destroyedSignalIndex = QObject::staticMetaObject.indexOfMetho
+ template<class Receiver>
+ class SignalHandler : public QObject
+ {
++    Q_DISABLE_COPY(SignalHandler)
+ public:
+     SignalHandler(Receiver *receiver, QObject *parent = 0);
+ 
+@@ -268,6 +270,7 @@ int SignalHandler<Receiver>::qt_metacall(QMetaObject::Call call, int methodId, v
+     if (call == QMetaObject::InvokeMetaMethod) {
+         const QObject *object = sender();
+         Q_ASSERT(object);
++        Q_ASSERT(QThread::currentThread() == object->thread());
+         Q_ASSERT(senderSignalIndex() == methodId);
+         Q_ASSERT(m_connectionsCounter.contains(object));
+         Q_ASSERT(m_connectionsCounter.value(object).contains(methodId));
+diff --git a/qtwebchannel/tests/auto/qml/testwebchannel.cpp b/qtwebchannel/tests/auto/qml/testwebchannel.cpp
+index 9891687..3ca81c2 100644
+--- a/qtwebchannel/tests/auto/qml/testwebchannel.cpp
++++ b/qtwebchannel/tests/auto/qml/testwebchannel.cpp
+@@ -46,7 +46,11 @@ TestWebChannel::~TestWebChannel()
+ 
+ bool TestWebChannel::clientIsIdle() const
+ {
+-    return QWebChannel::d_func()->publisher->clientIsIdle;
++    for (auto *transport : QWebChannel::d_func()->transports) {
++        if (QWebChannel::d_func()->publisher->isClientIdle(transport))
++            return true;
++    }
++    return false;
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp b/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
+index 181da9e..37f989a 100644
+--- a/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
++++ b/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
+@@ -785,7 +785,7 @@ void TestWebChannel::testTransportWrapObjectProperties()
+     DummyTransport *dummyTransport = new DummyTransport(this);
+     channel.connectTo(dummyTransport);
+     channel.d_func()->publisher->initializeClient(dummyTransport);
+-    channel.d_func()->publisher->setClientIsIdle(true);
++    channel.d_func()->publisher->setClientIsIdle(true, dummyTransport);
+ 
+     QCOMPARE(channel.d_func()->publisher->transportedWrappedObjects.size(), 0);
+ 
+@@ -943,8 +943,6 @@ void TestWebChannel::testInfiniteRecursion()
+ 
+ void TestWebChannel::testAsyncObject()
+ {
+-    QSKIP("This test is broken. See QTBUG-80729");
+-
+     QWebChannel channel;
+     channel.connectTo(m_dummyTransport);
+ 
+@@ -990,6 +988,50 @@ void TestWebChannel::testAsyncObject()
+     thread.wait();
+ }
+ 
++void TestWebChannel::testPropertyMultipleTransports()
++{
++    DummyTransport transport1;
++    DummyTransport transport2;
++
++    QWebChannel channel;
++    QMetaObjectPublisher *publisher = channel.d_func()->publisher;
++
++    TestObject testObj;
++    testObj.setObjectName("testObject");
++    channel.registerObject(testObj.objectName(), &testObj);
++    channel.connectTo(&transport1);
++    channel.connectTo(&transport2);
++
++    testObj.setProp("Hello");
++
++    publisher->initializeClient(&transport1);
++    publisher->initializeClient(&transport2);
++    publisher->setClientIsIdle(true, &transport1);
++    QCOMPARE(publisher->isClientIdle(&transport1), true);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++    QVERIFY(transport1.messagesSent().isEmpty());
++    QVERIFY(transport2.messagesSent().isEmpty());
++
++    testObj.setProp("World");
++    QTRY_COMPARE_WITH_TIMEOUT(transport1.messagesSent().size(), 1u, 2000);
++    QCOMPARE(transport2.messagesSent().size(), 0u);
++    publisher->setClientIsIdle(true, &transport2);
++    QTRY_COMPARE_WITH_TIMEOUT(transport2.messagesSent().size(), 1u, 2000);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++
++    testObj.setProp("!!!");
++    publisher->setClientIsIdle(true, &transport2);
++    QCOMPARE(publisher->isClientIdle(&transport2), true);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QTRY_COMPARE_WITH_TIMEOUT(transport2.messagesSent().size(), 2u, 2000);
++    QCOMPARE(transport1.messagesSent().size(), 1u);
++    publisher->setClientIsIdle(true, &transport1);
++    QTRY_COMPARE_WITH_TIMEOUT(transport1.messagesSent().size(), 2u, 2000);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++}
++
+ class FunctionWrapper : public QObject
+ {
+     Q_OBJECT
+@@ -1082,7 +1124,7 @@ void TestWebChannel::benchInitializeClients()
+ 
+         publisher->propertyUpdatesInitialized = false;
+         publisher->signalToPropertyMap.clear();
+-        publisher->signalHandler.clear();
++        publisher->signalHandlers.clear();
+     }
+ }
+ 
+@@ -1107,7 +1149,7 @@ void TestWebChannel::benchPropertyUpdates()
+             obj->change();
+         }
+ 
+-        channel.d_func()->publisher->clientIsIdle = true;
++        channel.d_func()->publisher->setClientIsIdle(true, m_dummyTransport);
+         channel.d_func()->publisher->sendPendingPropertyUpdates();
+     }
+ }
+diff --git a/qtwebchannel/tests/auto/webchannel/tst_webchannel.h b/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
+index eae21f4..dd4e690 100644
+--- a/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
++++ b/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
+@@ -348,6 +348,7 @@ private slots:
+     void testJsonToVariant();
+     void testInfiniteRecursion();
+     void testAsyncObject();
++    void testPropertyMultipleTransports();
+     void testDeletionDuringMethodInvocation_data();
+     void testDeletionDuringMethodInvocation();
+ 
+Submodule qtwebengine f328054d...38e0df6c (commits not present)
+Submodule qtwebsockets 65850954..63fb8da1:
+diff --git a/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp b/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
+index 2affdd5..95f1194 100644
+--- a/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
++++ b/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
+@@ -273,6 +273,7 @@ void QWebSocketDataProcessor::clear()
+     if (!m_pConverterState)
+         m_pConverterState = new QTextCodec::ConverterState(QTextCodec::ConvertInvalidToNull |
+                                                            QTextCodec::IgnoreHeader);
++    frame.clear();
+ }
+ 
+ /*!
+diff --git a/qtwebsockets/src/websockets/qwebsocketprotocol.cpp b/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
+index df87a93..d0465f1 100644
+--- a/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
++++ b/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
+@@ -210,7 +210,7 @@ void QWebSocketProtocol::mask(char *payload, quint64 size, quint32 maskingKey)
+                             quint8((maskingKey & 0x0000FF00u) >> 8),
+                             quint8((maskingKey & 0x000000FFu))
+                           };
+-    int i = 0;
++    quint64 i = 0;
+     while (size-- > 0)
+         *payload++ ^= mask[i++ % 4];
+ }
diff --git a/srcpkgs/qt5/template b/srcpkgs/qt5/template
index a79d25e69da8..6dddce7f3e46 100644
--- a/srcpkgs/qt5/template
+++ b/srcpkgs/qt5/template
@@ -2,11 +2,11 @@
 #
 # revbump libqtxdg after bumping patch version
 pkgname=qt5
-version=5.15.7+20221119
+version=5.15.8
+revision=1
+build_style=meta
 # commit f8c9fb304bc3e53b3aa07f962cd74e9160decccc
 # base repo: https://invent.kde.org/qt/qt/qt5
-revision=5
-build_style=meta
 hostmakedepends="cmake clang flex perl glib-devel pkg-config
  python re2c ruby which"
 makedepends="SDL2-devel Vulkan-Headers alsa-lib-devel double-conversion-devel
@@ -29,8 +29,9 @@ homepage="https://qt.io/"
 # tarball is generated with `git archive-all qt5-$version.tar.gz`
 # to keep the size smaller qtwebengine, qtwebview, qtdocgallery, qtactiveqt and qtpim
 # can be marked with the export-ignore attribute
-distfiles="https://void.johnnynator.dev/distfiles/qt5-${version}.tar.gz"
-checksum=9d57af471c78029a362276b7c99108ea009f511bb9ba6ff6cb884f6ddd255e9f
+#distfiles="https://void.johnnynator.dev/distfiles/qt5-${version}.tar.gz"
+distfiles="https://download.qt.io/archive/qt/5.15/${version}/single/qt-everywhere-opensource-src-${version}.tar.xz"
+checksum=776a9302c336671f9406a53bd30b8e36f825742b2ec44a57c08217bff0fa86b9
 python_version=2 #unverified
 replaces="qt5-doc<5.6.0 qt5-quick1<5.6.0 qt5-quick1-devel<5.6.0 qt5-webkit<5.6.0 qt5-webkit-devel<5.6.0
  qt5-enginio<5.7.1 qt5-enginio-devel<5.7.1 qt5-plugin-gtk<5.7.1 qt5-canvas3d<5.13.0"
@@ -250,7 +251,6 @@ do_configure() {
 	# opts+=" -v"
 	opts+=" -skip qtwebengine"
 	opts+=" -skip qtwebview"
-	opts+=" -skip qtdocgallery"
 	opts+=" -skip qtpim"
 	opts+=" -skip qtsystems"
 	opts+=" -skip qtspeech"

From fcd34b55acd8cf79e4264a7975beefc860c6a9c9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 075/116] qtav: revbump for ffmpeg4-4.4.3

---
 srcpkgs/qtav/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtav/template b/srcpkgs/qtav/template
index 34c30b2c0c78..2d00ad104355 100644
--- a/srcpkgs/qtav/template
+++ b/srcpkgs/qtav/template
@@ -1,10 +1,10 @@
 # Template file for 'qtav'
 pkgname=qtav
 version=1.13.0
-revision=1
+revision=2
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel libass-devel libopenal-devel
+makedepends="ffmpeg4-devel libass-devel libopenal-devel
  libva-glx-devel libXv-devel pulseaudio-devel
  qt5-declarative-devel qt5-svg-devel
  qt5-quickcontrols"

From b4dc3065639ad230b626a38b31bb5d4547a505e4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 076/116] qtox: revbump for ffmpeg-6.0

---
 srcpkgs/qtox/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qtox/template b/srcpkgs/qtox/template
index 16019d7eaec9..5cea0b11b697 100644
--- a/srcpkgs/qtox/template
+++ b/srcpkgs/qtox/template
@@ -1,7 +1,7 @@
 # Template file for 'qtox'
 pkgname=qtox
 version=1.17.6
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DUPDATE_CHECK=OFF
  -DGIT_DESCRIBE=${version}

From 5a3ecbd485e52e37cdea09811fde861a7fcd2f34 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 077/116] retroarch: revbump for ffmpeg-6.0

---
 srcpkgs/retroarch/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroarch/template b/srcpkgs/retroarch/template
index 28016aa0129e..20a1415913be 100644
--- a/srcpkgs/retroarch/template
+++ b/srcpkgs/retroarch/template
@@ -1,7 +1,7 @@
 # Template file for 'retroarch'
 pkgname=retroarch
 version=1.15.0
-revision=1
+revision=2
 build_style=configure
 configure_args="--prefix=/usr --sysconfdir=/etc --enable-networking
  --enable-udev --disable-builtinflac --disable-builtinglslang

From 2d8278c9eea67ce96d8d64795a5cab21ab8f12f0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 078/116] scrcpy: revbump for ffmpeg-6.0

---
 srcpkgs/scrcpy/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/scrcpy/template b/srcpkgs/scrcpy/template
index ee6e698e387f..8ada5ca4323f 100644
--- a/srcpkgs/scrcpy/template
+++ b/srcpkgs/scrcpy/template
@@ -1,7 +1,7 @@
 # Template file for 'scrcpy'
 pkgname=scrcpy
 version=2.0
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcompile_server=false
  -Dprebuilt_server=/usr/share/scrcpy/scrcpy-server-v${version}"

From 4881b755457d1784a047f7fc18a32ac9f1a7a5d0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 079/116] spek-alternative: revbump for ffmpeg4-4.4.3

---
 srcpkgs/spek-alternative/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/spek-alternative/template b/srcpkgs/spek-alternative/template
index d65086b8f008..05246f1b8d0c 100644
--- a/srcpkgs/spek-alternative/template
+++ b/srcpkgs/spek-alternative/template
@@ -1,11 +1,11 @@
 # Template file for 'spek-alternative'
 pkgname=spek-alternative
 version=0.8.2.3
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake gettext-devel intltool libtool pkg-config wxWidgets-common"
-makedepends="ffmpeg-devel wxWidgets-gtk3-devel"
-depends="ffmpeg"
+makedepends="ffmpeg4-devel wxWidgets-gtk3-devel"
+depends="ffmpeg4"
 short_desc="Acoustic spectrum analyser"
 maintainer="Kartik Singh <kartik.ynwa@gmail.com>"
 license="GPL-3.0-or-later"

From d09a69c97093a0bcdc2c38e964b9efd4de1df377 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 080/116] ssr: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ssr/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/ssr/template b/srcpkgs/ssr/template
index b055b9ec0774..3448ca110eb0 100644
--- a/srcpkgs/ssr/template
+++ b/srcpkgs/ssr/template
@@ -1,11 +1,11 @@
 # Template file for 'ssr'
 pkgname=ssr
 version=0.4.4
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_QT5=ON"
 hostmakedepends="pkg-config"
-makedepends="alsa-lib-devel ffmpeg-devel glu-devel jack-devel pulseaudio-devel
+makedepends="alsa-lib-devel ffmpeg4-devel glu-devel jack-devel pulseaudio-devel
  qt5-tools-devel qt5-x11extras-devel libXinerama-devel v4l-utils-devel"
 depends="desktop-file-utils hicolor-icon-theme"
 short_desc="Simple Screen Recorder for programs and games"

From 3ebd9c115e872debb3775c983465fefb940eaf58 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 081/116] sumo: revbump for ffmpeg-6.0

---
 srcpkgs/sumo/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/sumo/template b/srcpkgs/sumo/template
index 0f9b9ec815f5..a3fe134aa5ac 100644
--- a/srcpkgs/sumo/template
+++ b/srcpkgs/sumo/template
@@ -1,7 +1,7 @@
 # Template file for 'sumo'
 pkgname=sumo
 version=1.12.0
-revision=5
+revision=6
 build_style=cmake
 hostmakedepends="libgdal-tools pkg-config swig python3-setuptools"
 makedepends="python3-devel ffmpeg-devel fox-devel gl2ps-devel libgdal-devel

From ff27117abe260b3d5757a645b09b97598bccfd81 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 082/116] synfig: revbump for ffmpeg-6.0 and mlt7

---
 srcpkgs/synfig/patches/ffmpeg6.patch | 71 ++++++++++++++++++++++++++++
 srcpkgs/synfig/template              |  4 +-
 2 files changed, 73 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/synfig/patches/ffmpeg6.patch

diff --git a/srcpkgs/synfig/patches/ffmpeg6.patch b/srcpkgs/synfig/patches/ffmpeg6.patch
new file mode 100644
index 000000000000..10780b42782f
--- /dev/null
+++ b/srcpkgs/synfig/patches/ffmpeg6.patch
@@ -0,0 +1,71 @@
+--- a/src/modules/mod_libavcodec/trgt_av.cpp	2022-10-25 09:14:12.000000000 -0400
++++ b/src/modules/mod_libavcodec/trgt_av.cpp	2023-05-05 21:34:17.899194559 -0400
+@@ -38,6 +41,7 @@
+ extern "C"
+ {
+ #ifdef HAVE_LIBAVFORMAT_AVFORMAT_H
++#	include <libavcodec/avcodec.h>
+ #	include <libavformat/avformat.h>
+ #elif defined(HAVE_AVFORMAT_H)
+ #	include <avformat.h>
+@@ -155,11 +156,11 @@
+     }
+ 
+ 	bool open_video_stream() {
+-		if (avcodec_open2(video_context, NULL, NULL) < 0) {
++		if (avcodec_open2(video_context, nullptr, nullptr) < 0) {
+ 			synfig::error("Target_LibAVCodec: could not open video codec");
+ 			// seems the calling of avcodec_free_context after error will cause crash
+ 			// so just forget about this context
+-			video_context = NULL;
++			video_context = nullptr;
+ 			close();
+ 			return false;
+         }
+@@ -234,15 +235,21 @@
+ 		close();
+ 
+ 		if (!av_registered) {
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 			av_register_all();
++#endif
+ 			av_registered = true;
+ 		}
+ 
+ 		// guess format
+-		AVOutputFormat *format = av_guess_format(NULL, filename.c_str(), NULL);
++#if LIBAVCODEC_VERSION_MAJOR < 59 // FFMPEG < 5.0
++		AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#else
++		const AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#endif
+ 		if (!format) {
+ 			synfig::warning("Target_LibAVCodec: unable to guess the output format, defaulting to MPEG");
+-			format = av_guess_format("mpeg", NULL, NULL);
++			format = av_guess_format("mpeg", nullptr, nullptr);
+ 		}
+ 		if (!format) {
+ 			synfig::error("Target_LibAVCodec: unable to find 'mpeg' output format");
+@@ -254,6 +261,7 @@
+ 		context = avformat_alloc_context();
+ 		assert(context);
+ 		context->oformat = format;
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 		if (filename.size() + 1 > sizeof(context->filename)) {
+ 			synfig::error(
+ 				"Target_LibAVCodec: filename too long, max length is %d, filename is '%s'",
+@@ -263,6 +271,14 @@
+ 			return false;
+ 		}
+ 		memcpy(context->filename, filename.c_str(), filename.size() + 1);
++#else
++		context->url = av_strndup(filename.c_str(), filename.size());
++		if (!context->url) {
++			synfig::error("Target_LibAVCodec: cannot allocate space for filename");
++			close();
++			return false;
++		}
++#endif
+ 
+ 		packet = av_packet_alloc();
+ 		assert(packet);
diff --git a/srcpkgs/synfig/template b/srcpkgs/synfig/template
index 5f5f5bb3f4b2..6e0d713150ae 100644
--- a/srcpkgs/synfig/template
+++ b/srcpkgs/synfig/template
@@ -6,7 +6,7 @@ revision=2
 build_style=gnu-configure
 configure_args="--with-boost-libdir=${XBPS_CROSS_BASE}/usr/lib"
 hostmakedepends="boost-build ImageMagick pkg-config intltool"
-makedepends="ETL gettext-devel libxml++-devel mlt-devel libmagick-devel
+makedepends="ETL gettext-devel libxml++-devel mlt7-devel libmagick-devel
  libmng-devel boost-build boost-devel libopenexr-devel ffmpeg-devel"
 depends="ImageMagick"
 short_desc="CLI 2D vector and timeline-based animation software"
@@ -20,7 +20,7 @@ CXXFLAGS="-std=c++11 -DHAVE_LOCALE_H=1"
 
 synfig-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision}
-	 libopenexr-devel libxml++-devel mlt-devel"
+	 libopenexr-devel libxml++-devel mlt7-devel"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/bin/synfig-config

From 9744cbaa1c95c670b4151bee65b74d6d79976f51 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 5 May 2023 12:57:57 -0400
Subject: [PATCH 083/116] synfigstudio: revbump for synfig mlt7

---
 srcpkgs/synfigstudio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/synfigstudio/template b/srcpkgs/synfigstudio/template
index 91349169ed2b..af1c5a296ef0 100644
--- a/srcpkgs/synfigstudio/template
+++ b/srcpkgs/synfigstudio/template
@@ -2,7 +2,7 @@
 # Should be kept in sync with 'synfig' and 'ETL'
 pkgname=synfigstudio
 version=1.4.4
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--disable-update-mimedb"
 hostmakedepends="pkg-config intltool gettext synfig"

From d35501226462e6d83f306167cdfa983859675527 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 084/116] tg_owt: revbump for ffmpeg-6.0

---
 srcpkgs/tg_owt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tg_owt/template b/srcpkgs/tg_owt/template
index 97d195ddb34a..551614b24956 100644
--- a/srcpkgs/tg_owt/template
+++ b/srcpkgs/tg_owt/template
@@ -1,7 +1,7 @@
 # Template file for 'tg_owt'
 pkgname=tg_owt
 version=0.0.0.20230107
-revision=1
+revision=2
 _commit=5098730b9eb6173f0b52068fe2555b7c1015123a
 _libyuv_commit=00950840d1c9bcbb3eb6ebc5aac5793e71166c8b
 _abseil_commit=8c0b94e793a66495e0b1f34a5eb26bd7dc672db0

From 06cfe727bf101f16ddd7e7398fb2bcd5b23feb57 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 085/116] timg: revbump for ffmpeg-6.0

---
 srcpkgs/timg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/timg/template b/srcpkgs/timg/template
index 2a2ab763d2fd..8fb4327535ef 100644
--- a/srcpkgs/timg/template
+++ b/srcpkgs/timg/template
@@ -1,7 +1,7 @@
 # Template file for 'timg'
 pkgname=timg
 version=1.4.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_OPENSLIDE_SUPPORT=off -Wno-dev"
 hostmakedepends="pkg-config git"

From 7d00810d8e4bf16144f8b2e1b0ea479e8f75617e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 086/116] tvheadend: revbump for ffmpeg4-4.4.3

---
 srcpkgs/tvheadend/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/tvheadend/template b/srcpkgs/tvheadend/template
index e6b16d7ccf3b..46b52b6fb7f9 100644
--- a/srcpkgs/tvheadend/template
+++ b/srcpkgs/tvheadend/template
@@ -1,14 +1,14 @@
 # Template file for 'tvheadend'
 pkgname=tvheadend
 version=4.2.8
-revision=6
+revision=7
 build_style=gnu-configure
 configure_args="--enable-dvbscan --disable-ffmpeg_static
 --disable-hdhomerun_static --disable-bintray_cache --disable-libx264_static
 --disable-libx265_static --disable-libvpx_static --disable-libtheora_static
 --disable-libvorbis_static --disable-libfdkaac_static"
 hostmakedepends="gettext pkg-config python git which"
-makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg-devel"
+makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg4-devel"
 short_desc="TV streaming server"
 maintainer="lemmi <lemmi@nerd2nerd.org>"
 license="GPL-3.0-only"

From bc770206538eacf9e427cd4bf36efa7822ec54e9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 087/116] unpaper: update to 7.0.0.

---
 srcpkgs/unpaper/template | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/srcpkgs/unpaper/template b/srcpkgs/unpaper/template
index 38ed47a58401..1ff910e722af 100644
--- a/srcpkgs/unpaper/template
+++ b/srcpkgs/unpaper/template
@@ -1,13 +1,13 @@
 # Template file for 'unpaper'
 pkgname=unpaper
-version=6.1
-revision=3
-build_style=gnu-configure
+version=7.0.0
+revision=1
+build_style=meson
+hostmakedepends="pkg-config meson libxslt"
+makedepends="ffmpeg-devel python3-Sphinx"
+short_desc="Post-processing tool for scanned sheets of paper"
 maintainer="Orphaned <orphan@voidlinux.org>"
-hostmakedepends="pkg-config libxslt"
-makedepends="ffmpeg-devel"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://www.flameeyes.eu/projects/unpaper"
-short_desc="A post-processing tool for scanned sheets of paper"
 distfiles="https://www.flameeyes.eu/files/${pkgname}-${version}.tar.xz"
-checksum=237c84f5da544b3f7709827f9f12c37c346cdf029b1128fb4633f9bafa5cb930
+checksum=2575fbbf26c22719d1cb882b59602c9900c7f747118ac130883f63419be46a80

From 1ed9c913bda5335eb35ac1853def72064642d4a2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 088/116] vba-m: revbump for ffmpeg-6.0

---
 srcpkgs/vba-m/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vba-m/template b/srcpkgs/vba-m/template
index ba153e0b58ca..aa6093645e97 100644
--- a/srcpkgs/vba-m/template
+++ b/srcpkgs/vba-m/template
@@ -2,7 +2,7 @@
 pkgname=vba-m
 reverts=1292_2
 version=2.1.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_GTK=TRUE -DENABLE_FFMPEG=TRUE -DENABLE_LINK=TRUE -DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="gettext pkg-config unzip zip yasm wxWidgets-gtk3-devel"

From c795edaa67a3a99ab4bdcd30205e86e9ca0b1ffe Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 089/116] vice: revbump for ffmpeg4-4.4.3

---
 srcpkgs/vice/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/vice/template b/srcpkgs/vice/template
index 0924767cfcfb..5981e45149d0 100644
--- a/srcpkgs/vice/template
+++ b/srcpkgs/vice/template
@@ -1,7 +1,7 @@
 # Template file for 'vice'
 pkgname=vice
 version=3.5
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="
 	$(vopt_enable sdl2 sdlui2)
@@ -28,7 +28,7 @@ makedepends="
 	$(vopt_if gtk3 gtk+3-devel)
 	$(vopt_if gtk3 pulseaudio-devel)
 	$(vopt_if gtk3 pango-devel)
-	$(vopt_if ffmpeg ffmpeg-devel)"
+	$(vopt_if ffmpeg ffmpeg4-devel)"
 short_desc="Emulator for C64, C128, CBM-II, PET, VIC20, Plus4 and C16"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"

From 23cda831e762a4e124b7008312c491d14d402996 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 090/116] waypipe: revbump for ffmpeg-6.0

---
 srcpkgs/waypipe/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waypipe/template b/srcpkgs/waypipe/template
index 5c4161900060..1a46fe27f7d8 100644
--- a/srcpkgs/waypipe/template
+++ b/srcpkgs/waypipe/template
@@ -1,7 +1,7 @@
 # Template file for 'waypipe'
 pkgname=waypipe
 version=0.8.4
-revision=1
+revision=2
 build_style=meson
 # lto is off because it causes linking errors in armv6l and armv7l (due to NEON)
 configure_args="-Dwerror=false -Dwith_dmabuf=enabled -Dwith_lz4=enabled

From ea6391358eb8ba321f74c4ffdb7e89c7867275aa Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 091/116] wf-recorder: revbump for ffmpeg-6.0

---
 srcpkgs/wf-recorder/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/wf-recorder/template b/srcpkgs/wf-recorder/template
index e278eb001600..5d014a5f28af 100644
--- a/srcpkgs/wf-recorder/template
+++ b/srcpkgs/wf-recorder/template
@@ -1,7 +1,7 @@
 # Template file for 'wf-recorder'
 pkgname=wf-recorder
 version=0.3.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config scdoc wayland-devel"
 makedepends="wayland-protocols wayland-devel ffmpeg-devel x264-devel

From 985e031f1084782100582df8a9e8a1f36b5f9be6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 092/116] xpra: revbump for ffmpeg-6.0

---
 srcpkgs/xpra/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xpra/template b/srcpkgs/xpra/template
index ee8ce4ec78a9..c02482ad4b39 100644
--- a/srcpkgs/xpra/template
+++ b/srcpkgs/xpra/template
@@ -1,7 +1,7 @@
 # Template file for 'xpra'
 pkgname=xpra
 version=4.4.5
-revision=1
+revision=2
 build_style=python3-module
 make_build_args="--without-cuda_kernels --without-cuda_rebuild"
 make_install_args="$(vopt_with docs) ${make_build_args}"

From 9a4851314b949a8f0624181978c220aa3d837153 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:07:40 -0400
Subject: [PATCH 093/116] nv-codec-headers: update to 12.0.16.0

---
 srcpkgs/nv-codec-headers/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/nv-codec-headers/template b/srcpkgs/nv-codec-headers/template
index 3d422a61e489..251e057f826f 100644
--- a/srcpkgs/nv-codec-headers/template
+++ b/srcpkgs/nv-codec-headers/template
@@ -1,6 +1,6 @@
 # Template file for 'nv-codec-headers'
 pkgname=nv-codec-headers
-version=11.1.5.1
+version=12.0.16.0
 revision=1
 build_style=gnu-makefile
 short_desc="FFmpeg version of headers required to interface with Nvidias codec APIs"
@@ -8,7 +8,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="MIT"
 homepage="http://git.videolan.org/?p=ffmpeg/nv-codec-headers.git"
 distfiles="https://github.com/FFmpeg/nv-codec-headers/archive/n${version}.tar.gz"
-checksum=d095fbd56aa93772471a323be0ebe65504a0f43f06c76a30b6d25da77b06ae9c
+checksum=2a1533b65f55f9da52956faf0627ed3b74868ac0c7f269990edd21369113b48f
 
 post_install() {
 	sed -n '4,25p' include/ffnvcodec/nvEncodeAPI.h > LICENSE

From 2752df3b1e81f0a7eedaaf359c93b57197fe53e3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:08:40 -0400
Subject: [PATCH 094/116] openimagedenoise: revbump for ffmpeg-6.0

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index db5ccdb055cc..cb90045afb63 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,7 +1,7 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
 version=1.4.3
-revision=1
+revision=2
 archs="x86_64*"
 build_style=cmake
 hostmakedepends="ispc python3"

From 50856ca88d0e7591d35c3085f60900234fd39cc6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:31:45 -0400
Subject: [PATCH 095/116] shotcut: revbump for ffmpeg-6.0

---
 srcpkgs/shotcut/template | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/srcpkgs/shotcut/template b/srcpkgs/shotcut/template
index 99ebf2e8a5af..c416c906ff73 100644
--- a/srcpkgs/shotcut/template
+++ b/srcpkgs/shotcut/template
@@ -1,20 +1,20 @@
 # Template file for 'shotcut'
 pkgname=shotcut
-version=22.12.21
-revision=1
+version=23.05.14
+revision=2
 build_style=cmake
 configure_args="-DSHOTCUT_VERSION=${version}"
-hostmakedepends="pkg-config qt5-tools-devel"
-makedepends="mlt7-devel qt5-declarative-devel qt5-multimedia-devel
- qt5-quickcontrols2-devel qt5-websockets-devel qt5-plugin-mysql qt5-plugin-odbc
- qt5-plugin-pgsql qt5-plugin-sqlite qt5-plugin-tds"
-depends="ffmpeg frei0r-plugins qt5-graphicaleffects qt5-quickcontrols"
+hostmakedepends="pkg-config qt6-tools-devel"
+makedepends="mlt7-devel qt6-declarative-devel qt6-multimedia-devel
+ qt6-websockets-devel qt6-plugin-mysql qt6-plugin-odbc
+ qt6-plugin-pgsql qt6-plugin-sqlite"
+depends="ffmpeg frei0r-plugins qt6-declarative"
 short_desc="Free, open source, cross-platform video editor"
 maintainer="John <me@johnnynator.dev>"
 license="GPL-3.0-or-later"
 homepage="https://www.shotcut.org"
 changelog="https://github.com/mltframework/shotcut/releases"
 distfiles="https://github.com/mltframework/shotcut/archive/v${version}.tar.gz"
-checksum=1b9a4f87b16a9751f9cb41588f22af4c00f085105d82cf21d095d9f3c280bc86
+checksum=94632bd69cc8f3b2cba0668b9e8d051493efa5a9c9554c02822c346fe64c1ce0
 
 CXXFLAGS="-DHAVE_LOCALE_H=1 -DSHOTCUT_NOUPGRADE"

From b5a29dbe434ec821b8f56e2e21f9f3d501a7396f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:30 -0400
Subject: [PATCH 096/116] shiboken2: revbump for qt5-5.15.8

---
 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch | 1 +
 srcpkgs/shiboken2/template                                 | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
 create mode 120000 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
new file mode 120000
index 000000000000..efcf3249bd88
--- /dev/null
+++ b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1 @@
+../../python3-pyside2/patches/importlib-machinery-bypass.patch
\ No newline at end of file
diff --git a/srcpkgs/shiboken2/template b/srcpkgs/shiboken2/template
index 084ecc3ba1e1..2a21998997eb 100644
--- a/srcpkgs/shiboken2/template
+++ b/srcpkgs/shiboken2/template
@@ -1,7 +1,7 @@
 # Template file for 'shiboken2'
 pkgname=shiboken2
 version=5.15.7
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/shiboken2"
 build_style=cmake

From bcf2b036698592c94445a7c0b321d9735d79c413 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:53 -0400
Subject: [PATCH 097/116] python3-pyside2: update to 5.15.8

---
 .../patches/importlib-machinery-bypass.patch      | 15 +++++++++++++++
 srcpkgs/python3-pyside2/template                  |  9 +++++----
 2 files changed, 20 insertions(+), 4 deletions(-)
 create mode 100644 srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
new file mode 100644
index 000000000000..64c429584776
--- /dev/null
+++ b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1,15 @@
+Using this prevents an error around line 220 below it.
+"AttributeError: module 'importlib' has no attribute 'machinery'"
+The old backup logic is in place and compiles without issues.
+--- a/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:09:34.688912402 -0400
++++ b/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:10:03.395529582 -0400
+@@ -170,9 +170,6 @@
+
+     # 'zipstring_sequence' comes from signature.cpp
+     zipbytes = base64.b64decode(''.join(zipstring_sequence))
+-    if sys.version_info[0] >= 3:
+-        vzip = zipfile.ZipFile(io.BytesIO(zipbytes))
+-        return sys.meta_path, EmbeddableZipImporter(vzip)
+
+     # Old version for Python 2.7, only.
+     import os
diff --git a/srcpkgs/python3-pyside2/template b/srcpkgs/python3-pyside2/template
index 50e6ff260d3b..b50e62bd215d 100644
--- a/srcpkgs/python3-pyside2/template
+++ b/srcpkgs/python3-pyside2/template
@@ -1,11 +1,12 @@
 # Template file for 'python3-pyside2'
 pkgname=python3-pyside2
-version=5.15.5
-revision=2
+version=5.15.8
+revision=1
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/pyside2"
 build_style=cmake
-configure_args="-DPYTHON_EXECUTABLE=/usr/bin/python"
+configure_args="-DPYTHON_EXECUTABLE=/usr/bin/python -DCMAKE_BUILD_TYPE=None
+ -DBUILD_TESTS=OFF"
 hostmakedepends="cmake python3 shiboken2"
 makedepends="python3-devel libshiboken2-devel qt5-devel
  qt5-multimedia-devel qt5-tools-devel qt5-plugin-mysql qt5-plugin-odbc
@@ -23,7 +24,7 @@ maintainer="yopito <pierre.bourgin@free.fr>"
 license="LGPL-3.0-or-later"
 homepage="https://wiki.qt.io/Qt_for_Python"
 distfiles="https://download.qt.io/official_releases/QtForPython/pyside2/PySide2-${version}-src/${_pkgname}.tar.xz"
-checksum=3920a4fb353300260c9bc46ff70f1fb975c5e7efa22e9d51222588928ce19b33
+checksum=23436302c8deb5b4cbc769b205d09604e38ba83b40708efccb7bd8c9af6f6b5d
 
 build_options="webengine"
 desc_option_webengine="Build Qt5 WebEngine bindings"

From 2a96e2a392146e0eb964fb21d861542934ddba85 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:35 -0400
Subject: [PATCH 098/116] konqueror: revbump for ffmpeg-6.0

---
 srcpkgs/konqueror/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/konqueror/template b/srcpkgs/konqueror/template
index d8d0e73a78ab..c5bdba601d3c 100644
--- a/srcpkgs/konqueror/template
+++ b/srcpkgs/konqueror/template
@@ -1,11 +1,11 @@
 # Template file for 'konqueror'
 pkgname=konqueror
 version=23.04.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DDESKTOPTOJSON_EXECUTABLE=/usr/bin/desktoptojson"
 hostmakedepends="extra-cmake-modules python3 qt5-host-tools qt5-qmake kdoctools
-kcoreaddons kconfig gettext"
+ kcoreaddons kconfig gettext"
 makedepends="qt5-devel qt5-webengine-devel qt5-declarative-devel
  qt5-webchannel-devel qt5-location-devel kcmutils-devel kdelibs4support-devel
  karchive-devel khtml-devel kdesu-devel kactivities5-devel"

From 3f168ac56b038cd93d9f3b97257c3dcda3efcd07 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:58 -0400
Subject: [PATCH 099/116] qt5-speech: revbump for qt5-5.15.8

---
 srcpkgs/qt5-speech/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-speech/template b/srcpkgs/qt5-speech/template
index 3ecd10d50650..2d7d4d4d2453 100644
--- a/srcpkgs/qt5-speech/template
+++ b/srcpkgs/qt5-speech/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-speech'
 pkgname=qt5-speech
 version=5.15.7
-revision=2
+revision=3
 _commit=d32f4a479d38a11f547598004b975f4356424a16
 build_style=qmake
 configure_args="-- -flite -flite-alsa -speechd"

From c767afad64857af597e3a2b60c838dcdf77d4bfb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 18:38:50 -0400
Subject: [PATCH 100/116] qt5-styleplugins: revbump for qt5-5.15.8

---
 srcpkgs/qt5-styleplugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-styleplugins/template b/srcpkgs/qt5-styleplugins/template
index 96ed97d12cd2..30d93660a2a4 100644
--- a/srcpkgs/qt5-styleplugins/template
+++ b/srcpkgs/qt5-styleplugins/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-styleplugins'
 pkgname=qt5-styleplugins
 version=5.0.0
-revision=20
+revision=21
 _gitrev=335dbece103e2cbf6c7cf819ab6672c2956b17b3
 build_style=qmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From c1aac6254ec530baa6343d00e39da9247fc18541 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 30 Apr 2023 20:22:26 -0400
Subject: [PATCH 101/116] gst-plugins-ugly1: revbump for ffmpeg-6.0

---
 srcpkgs/gst-plugins-ugly1/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-plugins-ugly1/template b/srcpkgs/gst-plugins-ugly1/template
index e254fd40f869..85ae64bc7a0a 100644
--- a/srcpkgs/gst-plugins-ugly1/template
+++ b/srcpkgs/gst-plugins-ugly1/template
@@ -1,6 +1,6 @@
 # Template file for 'gst-plugins-ugly1'
 pkgname=gst-plugins-ugly1
-version=1.20.3
+version=1.22.2
 revision=1
 build_style=meson
 configure_args="-Damrnb=disabled -Damrwbdec=disabled -Dsidplay=disabled"
@@ -15,4 +15,4 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname/1/}/${pkgname/1/}-${version}.tar.xz"
-checksum=8caa20789a09c304b49cf563d33cca9421b1875b84fcc187e4a385fa01d6aefd
+checksum=8f30f44db0bd063709bf6fbe55138e3a98af0abcb61c360f35582bbe10e80691

From df980b4b44f96a0e456279af047e7508512f9541 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 30 Apr 2023 20:22:26 -0400
Subject: [PATCH 102/116] gst-rtsp-server: revbump for ffmpeg-6.0

---
 srcpkgs/gst-rtsp-server/template | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index 8ceea8d34b4b..980fd72cdd4c 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
-version=1.20.3
-revision=3
+version=1.22.2
+revision=2
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="glib-devel gst-plugins-bad1-devel gobject-introspection
@@ -10,5 +10,5 @@ short_desc="GStreamer multimedia graph framework - rtsp server"
 maintainer="1is7ac3 <isaac.qa13@gmail.com>"
 license="LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
-distfiles="https://gstreamer.freedesktop.org/src/gst-rtsp-server/gst-rtsp-server-${version}.tar.xz"
-checksum=ee402718be9b127f0e5e66ca4c1b4f42e4926ec93ba307b7ccca5dc6cc9794ca
+distfiles="${homepage}/src/${pkgname}/${pkgname}-${version}.tar.xz"
+checksum=2be4aecfb88710100ea7115ed0216403e8094344ebf146094271b8d4d73828bf

From ca82bfa9e3c99e3dbeff6868b98e2aaefd087b26 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 30 Apr 2023 20:22:26 -0400
Subject: [PATCH 103/116] gst-libav: revbump for ffmpeg-6.0

---
 srcpkgs/gst-libav/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index f082bd211c65..04c39bff1489 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,6 +1,6 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
-version=1.20.3
+version=1.22.2
 revision=2
 build_style=meson
 hostmakedepends="pkg-config yasm"
@@ -11,7 +11,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.0-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname}/${pkgname}-${version}.tar.xz"
-checksum=3fedd10560fcdfaa1b6462cbf79a38c4e7b57d7f390359393fc0cef6dbf27dfe
+checksum=fcaaf9878fe8f3bc82317ef13a1558824cb68df1f8968c6797f556c5e33bcffd
 
 case "$XBPS_TARGET_MACHINE" in
 	*-musl) # Required by musl for M_SQRT1_2

From b1ec495c4bfe3a6c30528197bdf650a99a2cbfe4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 7 May 2023 20:14:14 -0400
Subject: [PATCH 104/116] mlt7: revbump for ffmpeg-6.0

---
 srcpkgs/gst-libav/template             | 2 +-
 srcpkgs/gst-omx/template               | 4 ++--
 srcpkgs/gst-plugins-base1/template     | 4 ++--
 srcpkgs/gst-plugins-good1/template     | 4 ++--
 srcpkgs/gst1-editing-services/template | 4 ++--
 srcpkgs/gst1-python3/template          | 6 +++---
 srcpkgs/gstreamer-vaapi/template       | 4 ++--
 srcpkgs/gstreamer1/template            | 4 ++--
 srcpkgs/mlt7/template                  | 2 +-
 9 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index 04c39bff1489..8c72fc3e97ee 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.22.2
-revision=2
+revision=1
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"
diff --git a/srcpkgs/gst-omx/template b/srcpkgs/gst-omx/template
index 893535c463da..5ad54cc7b9d8 100644
--- a/srcpkgs/gst-omx/template
+++ b/srcpkgs/gst-omx/template
@@ -1,6 +1,6 @@
 # Template file for 'gst-omx'
 pkgname=gst-omx
-version=1.20.3
+version=1.22.2
 revision=1
 build_style=meson
 configure_args="-Dexamples=disabled -Dtarget=generic"
@@ -11,4 +11,4 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.1-only"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname}/${pkgname}-${version}.tar.xz"
-checksum=8db48040bb41f09edf8d17ff6d16c54888d7777ba4501c2c69f0083350ea9a15
+checksum=1b0c57f2cc4ddeec5e7f0c436e502f06665c4e93c73261855b94e04fc94337b2
diff --git a/srcpkgs/gst-plugins-base1/template b/srcpkgs/gst-plugins-base1/template
index 29e8f76bd1fe..2f20ea819849 100644
--- a/srcpkgs/gst-plugins-base1/template
+++ b/srcpkgs/gst-plugins-base1/template
@@ -1,6 +1,6 @@
 # Template file for 'gst-plugins-base1'
 pkgname=gst-plugins-base1
-version=1.20.3
+version=1.22.2
 revision=1
 build_style=meson
 build_helper="gir"
@@ -22,7 +22,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname/1/}/${pkgname/1/}-${version}.tar.xz"
-checksum=7e30b3dd81a70380ff7554f998471d6996ff76bbe6fc5447096f851e24473c9f
+checksum=eb65120c4ee79b7a153c3c1972d5c0158c2151877cc51ec7725bba5749679d49
 
 build_options="cdparanoia gir sndio wayland"
 build_options_default="cdparanoia gir wayland"
diff --git a/srcpkgs/gst-plugins-good1/template b/srcpkgs/gst-plugins-good1/template
index 1f5e620ce1fd..5d0fe1bfe284 100644
--- a/srcpkgs/gst-plugins-good1/template
+++ b/srcpkgs/gst-plugins-good1/template
@@ -1,6 +1,6 @@
 # Template file for 'gst-plugins-good1'
 pkgname=gst-plugins-good1
-version=1.20.3
+version=1.22.2
 revision=1
 build_style=meson
 configure_args="-Ddv=disabled -Ddv1394=disabled -Dshout2=disabled -Dqt5=enabled
@@ -22,7 +22,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname/1/}/${pkgname/1/}-${version}.tar.xz"
-checksum=f8f3c206bf5cdabc00953920b47b3575af0ef15e9f871c0b6966f6d0aa5868b7
+checksum=7c8cc59425f2b232f60ca7d13e56edd615da4f711e73dd01a7cffa46e6bc0cdd
 
 build_options="gtk3 wayland"
 build_options_default="gtk3 wayland"
diff --git a/srcpkgs/gst1-editing-services/template b/srcpkgs/gst1-editing-services/template
index 673b46970f24..102440f7f253 100644
--- a/srcpkgs/gst1-editing-services/template
+++ b/srcpkgs/gst1-editing-services/template
@@ -1,6 +1,6 @@
 # Template file for 'gst1-editing-services'
 pkgname=gst1-editing-services
-version=1.20.3
+version=1.22.2
 revision=1
 build_style=meson
 build_helper="gir"
@@ -12,7 +12,7 @@ maintainer="Toyam Cox <Vaelatern@gmail.com>"
 license="LGPL-2.0-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname/gst1/gst}/${pkgname/gst1/gst}-${version}.tar.xz"
-checksum=5fd896de69fbe24421eb6b0ff8d2f8b4c3cba3f3025ceacd302172f39a8abaa2
+checksum=453b1464fc3857de269a7cb0ebd966afe02171d97bef672a0b8a0a6d43e0cebf
 
 do_check() {
 	: # Tests fail in older versions as well
diff --git a/srcpkgs/gst1-python3/template b/srcpkgs/gst1-python3/template
index 3f564ac64b93..789e40f036ea 100644
--- a/srcpkgs/gst1-python3/template
+++ b/srcpkgs/gst1-python3/template
@@ -1,7 +1,7 @@
 # Template file for 'gst1-python3'
 pkgname=gst1-python3
-version=1.20.3
-revision=2
+version=1.22.2
+revision=1
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="libglib-devel python3-devel python3-gobject-devel gst-plugins-base1-devel"
@@ -11,4 +11,4 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/gst-python/gst-python-${version}.tar.xz"
-checksum=db348120eae955b8cc4de3560a7ea06e36d6e1ddbaa99a7ad96b59846601cfdc
+checksum=bef2b3d82ce4be46b775b1bb56305c1003ee01b535a53a82f9fe8924972153ad
diff --git a/srcpkgs/gstreamer-vaapi/template b/srcpkgs/gstreamer-vaapi/template
index 3cc4e057559a..0a5ee8b1ca3f 100644
--- a/srcpkgs/gstreamer-vaapi/template
+++ b/srcpkgs/gstreamer-vaapi/template
@@ -1,6 +1,6 @@
 # Template file for 'gstreamer-vaapi'
 pkgname=gstreamer-vaapi
-version=1.20.3
+version=1.22.2
 revision=1
 build_style=meson
 hostmakedepends="pkg-config"
@@ -11,7 +11,7 @@ license="LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
 changelog="https://raw.githubusercontent.com/GStreamer/gstreamer-vaapi/master/ChangeLog"
 distfiles="${homepage}/src/gstreamer-vaapi/gstreamer-vaapi-${version}.tar.xz"
-checksum=6ee99eb316abdde9ad37002915bd8c3867918f6fdc74b7cf2ac4c1ae0d690b45
+checksum=d2e642f9745f97d9f73a7f5085e7659a9a31fe209b774e6e45dae041b435df06
 
 pre_check() {
 	# Seems to need certain hardware to pass
diff --git a/srcpkgs/gstreamer1/template b/srcpkgs/gstreamer1/template
index ae8a49cb20e8..571148f2ff33 100644
--- a/srcpkgs/gstreamer1/template
+++ b/srcpkgs/gstreamer1/template
@@ -1,6 +1,6 @@
 # Template file for 'gstreamer1'
 pkgname=gstreamer1
-version=1.20.3
+version=1.22.2
 revision=1
 build_style=meson
 build_helper="gir"
@@ -16,7 +16,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.0-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/gstreamer/gstreamer-${version}.tar.xz"
-checksum=607daf64bbbd5fb18af9d17e21c0d22c4d702fffe83b23cb22d1b1af2ca23a2a
+checksum=b2afe73603921c608ba48969dbb7d743776744bfe5d8059ece241137b7f88e21
 
 pre_check() {
 	# gst_gstdatetime is known to fail according to LFS
diff --git a/srcpkgs/mlt7/template b/srcpkgs/mlt7/template
index 9fb7f60d692e..cca0eb68cfc3 100644
--- a/srcpkgs/mlt7/template
+++ b/srcpkgs/mlt7/template
@@ -1,7 +1,7 @@
 # Template file for 'mlt7'
 pkgname=mlt7
 version=7.14.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSWIG_PYTHON=ON"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which

From 1597ac5f9f4204791d6ef1a4f5018f7d20b60cb9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 7 May 2023 20:15:03 -0400
Subject: [PATCH 105/116] qt6-webengine: revbump for ffmpeg-6.0

---
 srcpkgs/qt6-webengine/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-webengine/template b/srcpkgs/qt6-webengine/template
index 4e22cb6e8863..f948dc919a15 100644
--- a/srcpkgs/qt6-webengine/template
+++ b/srcpkgs/qt6-webengine/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-webengine'
 pkgname=qt6-webengine
 version=6.5.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="
  -DQT_FEATURE_webengine_system_ffmpeg=ON

From ada4a3d7586c116d5f6d932a2e1ff10231a38a82 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 7 May 2023 20:15:29 -0400
Subject: [PATCH 106/116] tracker-miners: revbump for ffmpeg-6.0

---
 srcpkgs/tracker-miners/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tracker-miners/template b/srcpkgs/tracker-miners/template
index 8c005d697fa4..a6e5aa577702 100644
--- a/srcpkgs/tracker-miners/template
+++ b/srcpkgs/tracker-miners/template
@@ -1,7 +1,7 @@
 # Template file for 'tracker-miners'
 pkgname=tracker-miners
 version=3.5.0
-revision=3
+revision=4
 build_style=meson
 build_helper=qemu
 # missing libgrss for miner_rss

From 370f8b1bbdb7d75886c704a45817613e2778204f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 7 May 2023 20:20:58 -0400
Subject: [PATCH 107/116] mpd: revbump for ffmpeg-6.0

---
 srcpkgs/mpd/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpd/template b/srcpkgs/mpd/template
index 9dbd4c935acc..9f058b62df2f 100644
--- a/srcpkgs/mpd/template
+++ b/srcpkgs/mpd/template
@@ -1,7 +1,7 @@
 # Template file for 'mpd'
 pkgname=mpd
 version=0.23.13
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dopus=enabled -Dmikmod=enabled -Dneighbor=true
  -Dsoundcloud=enabled -Dpipe=true -Dtwolame=enabled -Dbzip2=enabled

From 38742ed16aa5da3d06f41c41138c40548d309976 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 11 May 2023 14:05:14 -0400
Subject: [PATCH 108/116] openmw: revbump for ffmpeg-6.0

---
 srcpkgs/openmw/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openmw/template b/srcpkgs/openmw/template
index e3771c7aaf1a..3cbf20b06577 100644
--- a/srcpkgs/openmw/template
+++ b/srcpkgs/openmw/template
@@ -1,7 +1,7 @@
 # Template file for 'openmw'
 pkgname=openmw
 version=0.47.0
-revision=5
+revision=6
 build_style=cmake
 _recast_commit=e75adf86f91eb3082220085e42dda62679f9a3ea
 _bullet_tag=3.17

From 8c3fbd6ce7799a6ddf646922bec2de6995bd1fe3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 21 May 2023 12:44:11 -0400
Subject: [PATCH 109/116] electron24: revbump for ffmpeg-6.0

---
 srcpkgs/electron24/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron24/template b/srcpkgs/electron24/template
index bdaa56adc8a6..ff3d5e3ef381 100644
--- a/srcpkgs/electron24/template
+++ b/srcpkgs/electron24/template
@@ -1,7 +1,7 @@
 # Template file for 'electron24'
 pkgname=electron24
 version=24.3.0
-revision=1
+revision=2
 _nodever=18.14.0
 _chromiumver=112.0.5615.165
 archs="x86_64* aarch64*"

From f669d29f983dc003754c1508a73d6e9821216b36 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Jun 2023 08:20:22 -0400
Subject: [PATCH 110/116] gtk4: revbump for ffmpeg-6.0

---
 srcpkgs/gtk4/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gtk4/template b/srcpkgs/gtk4/template
index b318b7bae1dd..e3bde4a50e54 100644
--- a/srcpkgs/gtk4/template
+++ b/srcpkgs/gtk4/template
@@ -1,7 +1,7 @@
 # Template file for 'gtk4'
 pkgname=gtk4
 version=4.10.4
-revision=1
+revision=2
 build_style=meson
 build_helper="gir"
 configure_args="-Dman-pages=true -Dgtk_doc=true -Dbuild-tests=false

From 39f1bd6eb6b52c8cef2c2eb79a9e4604639c12d5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:25:50 -0400
Subject: [PATCH 111/116] electron19: revbump for ffmpeg-6.0

---
 srcpkgs/electron19/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron19/template b/srcpkgs/electron19/template
index 32ce301e730c..ab7f308f5e8a 100644
--- a/srcpkgs/electron19/template
+++ b/srcpkgs/electron19/template
@@ -1,7 +1,7 @@
 # Template file for 'electron19'
 pkgname=electron19
 version=19.0.8
-revision=3
+revision=4
 _nodever=16.14.2
 _chromiumver=102.0.5005.125
 archs="x86_64* aarch64* ppc64le*"

From 7d6ca920adbdec8dbb26760547755e9f39916713 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:28:26 -0400
Subject: [PATCH 112/116] siril: revbump for ffmpeg-6.0

---
 srcpkgs/siril/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/siril/template b/srcpkgs/siril/template
index 84332f79d060..62750dd24754 100644
--- a/srcpkgs/siril/template
+++ b/srcpkgs/siril/template
@@ -1,7 +1,7 @@
 # Template file for 'siril'
 pkgname=siril
 version=0.9.12
-revision=10
+revision=11
 build_style=gnu-configure
 hostmakedepends="pkg-config intltool autoconf automake gettext-devel"
 makedepends="fftw-devel libconfig-devel libopencv-devel libffms2-devel

From f87972bb006e5228486f7efea3df5bb8cc407953 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:29:08 -0400
Subject: [PATCH 113/116] telegram-desktop: revbump for ffmpeg-6.0

---
 srcpkgs/telegram-desktop/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/telegram-desktop/template b/srcpkgs/telegram-desktop/template
index f114b2341dc5..9db9f80c1a53 100644
--- a/srcpkgs/telegram-desktop/template
+++ b/srcpkgs/telegram-desktop/template
@@ -1,7 +1,7 @@
 # Template file for 'telegram-desktop'
 pkgname=telegram-desktop
 version=4.8.1
-revision=3
+revision=4
 build_style=cmake
 build_helper="qemu"
 configure_args="-DTDESKTOP_API_ID=209235

From 664e953f467ebaee123e508ae84a594f9cce533f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 10 Jun 2023 00:40:39 -0400
Subject: [PATCH 114/116] freecad: revbump for qt5-webengine-5.15.13

---
 srcpkgs/freecad/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/freecad/template b/srcpkgs/freecad/template
index a4a3f5f76b29..8608d1670c87 100644
--- a/srcpkgs/freecad/template
+++ b/srcpkgs/freecad/template
@@ -1,7 +1,7 @@
 # Template file for 'freecad'
 pkgname=freecad
 version=0.20.2
-revision=5
+revision=6
 build_style=cmake
 
 _inst_prefix=/usr/lib/${pkgname}

From e912dcc249b3f8a35decc5ae0a7c8fdbb61db39a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 10 Jun 2023 00:57:09 -0400
Subject: [PATCH 115/116] qt6-multimedia: revbump for ffmpeg-6.0

---
 srcpkgs/qt6-multimedia/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-multimedia/template b/srcpkgs/qt6-multimedia/template
index a6832fdd69bf..c9ffac914ab8 100644
--- a/srcpkgs/qt6-multimedia/template
+++ b/srcpkgs/qt6-multimedia/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-multimedia'
 pkgname=qt6-multimedia
 version=6.5.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DQT_FEATURE_gstreamer=ON"
 hostmakedepends="perl qt6-declarative-host-tools pkg-config qt6-shadertools"

From 500e545fe5299eec5670e88571ee037ccfc0dd5c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 17 Jun 2023 14:53:06 -0400
Subject: [PATCH 116/116] kdenlive: revbump for ffmpeg-6.0

---
 etc/xbps.d/repos-remote.conf | 12 ++++++++----
 srcpkgs/kdenlive/template    |  2 +-
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/etc/xbps.d/repos-remote.conf b/etc/xbps.d/repos-remote.conf
index e171ed53c2d4..98d403079d50 100644
--- a/etc/xbps.d/repos-remote.conf
+++ b/etc/xbps.d/repos-remote.conf
@@ -1,5 +1,9 @@
 # voidlinux remote repositories (glibc)
-repository=https://repo-default.voidlinux.org/current/bootstrap
-repository=https://repo-default.voidlinux.org/current
-repository=https://repo-default.voidlinux.org/current/nonfree
-repository=https://repo-default.voidlinux.org/current/debug
+#repository=https://repo-default.voidlinux.org/current/bootstrap
+#repository=https://repo-default.voidlinux.org/current
+#repository=https://repo-default.voidlinux.org/current/nonfree
+#repository=https://repo-default.voidlinux.org/current/debug
+repository=https://mirrors.servercentral.com/voidlinux/current/bootstrap
+repository=https://mirrors.servercentral.com/voidlinux/current
+repository=https://mirrors.servercentral.com/voidlinux/current/nonfree
+repository=https://mirrors.servercentral.com/voidlinux/current/debug
diff --git a/srcpkgs/kdenlive/template b/srcpkgs/kdenlive/template
index 429126ef3c3b..0c5f7bf698fb 100644
--- a/srcpkgs/kdenlive/template
+++ b/srcpkgs/kdenlive/template
@@ -1,7 +1,7 @@
 # Template file for 'kdenlive'
 pkgname=kdenlive
 version=23.04.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="
  extra-cmake-modules kconfig kcoreaddons kdoctools pkg-config python3

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (10 preceding siblings ...)
  2023-06-17 19:17 ` zlice
@ 2023-06-17 19:28 ` zlice
  2023-06-19 20:19 ` zlice
                   ` (85 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2023-06-17 19:28 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 3480 bytes --]

There is an updated pull request by zlice against master on the void-packages repository

https://github.com/zlice/void-packages ffmpeg6-split
https://github.com/void-linux/void-packages/pull/43761

ffmpeg6 split
[ci skip]


#### Testing the changes

- I tested the changes in this PR: **YES**

main testing has been vaapi in Firefox Nightly and enc/dec in Shotcut on Intel A770

#### New package

- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**

#### Local build testing

- I built this PR locally for my native architecture, **x86_64**

#### Discussion

Continuation of https://github.com/void-linux/void-packages/pull/36315

`libavresample` is deprecated, but marked as a dependency when trying to build other packages and install `ffmpeg`(6). I think the right way to handle this is make a meta package and the add to removals?


##### Commit naming / misc

~~Commits are 'dirty' right now, running with [gstreamer 1.22.1 updates](https://github.com/void-linux/void-packages/pull/42861) and [Intel OpenCL](https://github.com/void-linux/void-packages/pull/43084). This will also make [intel packages pr](https://github.com/void-linux/void-packages/pull/41132) obsolete.~~ (see Requirements below)

Maintainer for previous ffmpeg(4) was orphaned, I can put my name in there if that matters, though I don't exactly see myself keeping up on ffmpeg.

This updates QT5 which looks like it is usually hosted by Johnny. Not sure if there's any reason to stay there or these sources are fine.

##### STILL FFMPEG4

These are a mix of emulators, games and/or older packages.

- attract (multiple patches in master)
- audacity (https://github.com/audacity/audacity/issues/2305 and https://sourceforge.net/p/portmedia/wiki/portsmf/ is 'beta')
- ccextractor (master patches? no release)
- vice
- kodi
- mlt (only dep left is flowblade)
- ~~synfig (mlt)~~ (work with mlt7, bump synfigstudio)
- tvheadend
- ssr
- spek-alternative
- ppsspp
- olive
- moc
- mediastreamer
- libextractor
- idjc
- hedgewars
- ~~ffmpegthumbnailer~~ (patches for moviedecoder.xxx files)
- ~~ffmpegthumbs~~ (latest compiles)
- deadbeef
- omxplayer
- qtav (fork has ffmpeg 5 patch - https://github.com/cmguo/QtAV)
- `vlc` (vlc4 will support ffmpeg5, there's a patch to build 3.x with ffmpeg5 but it will lack vaapi)
- `osg` (OpenSceneGraph plus `xine-lib`)


##### HAVE NOT BUILT YET

- omxplayer (rpi only? ffmpeg4)
- kodi (big, but ffmpeg4)


##### UPDATED (for ffmpeg6)

- ~~blender: update to 3.5.1~~ ~~will be revbump with~~ https://github.com/void-linux/void-packages/pull/43992
- unpaper: update to 7.0.0.
- guvcview: update to 2.0.8.
- qt5: update to 5.15.8
- qt5-webengine: update to 5.18.13
- shiboken2: revbump for qt5.15.8 (patch)
- python3-pyside2: update to 5.15.8 (patch)


##### Requirements

- [gstreamer 1.22.2](https://github.com/void-linux/void-packages/pull/42861) - a few packages use ffmpeg-devel and require a revbump

- [Intel Packages](https://github.com/void-linux/void-packages/pull/41132) - ffmpeg4 uses different libraries than 6 (libmfx / Intel-MediaSDK vs only oneVPL that Intel is moving to), both are included here

- [shotcut 23.05.14](https://github.com/void-linux/void-packages/pull/44260)

A patch file from https://github.com/void-linux/void-packages/pull/43761.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ffmpeg6-split-43761.patch --]
[-- Type: text/x-diff, Size: 788425 bytes --]

From fd64bfe0f7c92696f57fc9da3eb00bfbdc02ad17 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:55:46 -0400
Subject: [PATCH 001/116] ffmpeg: update to 6.0.

---
 common/shlibs                                 | 26 +++++---
 srcpkgs/ffmpeg/files/altivec.patch            | 60 -------------------
 .../patches/armv5tel-floating-point.patch     | 18 ------
 .../workaround-mesa-readeon-vaapi-bug.patch   | 28 ---------
 srcpkgs/ffmpeg/template                       | 38 +++++-------
 5 files changed, 32 insertions(+), 138 deletions(-)
 delete mode 100644 srcpkgs/ffmpeg/files/altivec.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch

diff --git a/common/shlibs b/common/shlibs
index 494e99b89550..892e119802cb 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -387,15 +387,23 @@ libid3tag.so.0 libid3tag-0.15.1b_1
 libgif.so.7 giflib-5.1.0_1
 libImlib2.so.1 imlib2-1.4.2_1
 libmp3lame.so.0 lame-3.98.2_1
-libavdevice.so.58 libavdevice-4.0_1
-libavformat.so.58 libavformat-4.0_1
-libswscale.so.5 libswscale-4.0_1
-libswresample.so.3 libswresample-4.0_1
-libavresample.so.4 libavresample-4.0_1
-libpostproc.so.55 libpostproc-4.0_1
-libavcodec.so.58 libavcodec-4.0_1
-libavutil.so.56 libavutil-4.0_1
-libavfilter.so.7 libavfilter-4.0_1
+libavdevice.so.60 libavdevice-6.0_1
+libavformat.so.60 libavformat-6.0_1
+libswscale.so.7 libswscale-6.0_1
+libswresample.so.4 libswresample-6.0_1
+libpostproc.so.57 libpostproc-6.0_1
+libavcodec.so.60 libavcodec-6.0_1
+libavutil.so.58 libavutil-6.0_1
+libavfilter.so.9 libavfilter-6.0_1
+libavdevice.so.58 libavdevice4-4.0_1
+libavformat.so.58 libavformat4-4.0_1
+libswscale.so.5 libswscale4-4.0_1
+libswresample.so.3 libswresample4-4.0_1
+libavresample.so.4 libavresample4-4.0_1
+libpostproc.so.55 libpostproc4-4.0_1
+libavcodec.so.58 libavcodec4-4.0_1
+libavutil.so.56 libavutil4-4.0_1
+libavfilter.so.7 libavfilter4-4.0_1
 libSDL-1.2.so.0 SDL-1.2.14_1
 libSDL_image-1.2.so.0 SDL_image-1.2.10_1
 libx264.so.157 x264-20190507.2245_1
diff --git a/srcpkgs/ffmpeg/files/altivec.patch b/srcpkgs/ffmpeg/files/altivec.patch
deleted file mode 100644
index 9c5720046332..000000000000
--- a/srcpkgs/ffmpeg/files/altivec.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-revert some altivec specific change on all ppc* except ppc64le*
-
-q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
-conditionally, for ppc* but not ppc64le* (the new code is valid for
-POWER8 VSX which LE targets as a baseline but not BE)"
-
-
-This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
----
- libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
- 1 file changed, 20 insertions(+), 4 deletions(-)
-
-diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
-index 536545293d..c1e2852adb 100644
---- a/libswscale/ppc/yuv2rgb_altivec.c
-+++ b/libswscale/ppc/yuv2rgb_altivec.c
-@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-     vector signed short R1, G1, B1;                                           \
-     vector unsigned char R, G, B;                                             \
-                                                                               \
-+    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
-+    vector unsigned char align_perm;                                          \
-+                                                                              \
-     vector signed short lCY       = c->CY;                                    \
-     vector signed short lOY       = c->OY;                                    \
-     vector signed short lCRV      = c->CRV;                                   \
-@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
-                                                                               \
-         for (j = 0; j < w / 16; j++) {                                        \
--            y0 = vec_xl(0, y1i);                                              \
-+            y1ivP = (const vector unsigned char *) y1i;                       \
-+            y2ivP = (const vector unsigned char *) y2i;                       \
-+            uivP  = (const vector unsigned char *) ui;                        \
-+            vivP  = (const vector unsigned char *) vi;                        \
-+                                                                              \
-+            align_perm = vec_lvsl(0, y1i);                                    \
-+            y0 = (vector unsigned char)                                       \
-+                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
-                                                                               \
--            y1 = vec_xl(0, y2i);                                              \
-+            align_perm = vec_lvsl(0, y2i);                                    \
-+            y1 = (vector unsigned char)                                       \
-+                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
-                                                                               \
--            u = (vector signed char) vec_xl(0, ui);                           \
-+            align_perm = vec_lvsl(0, ui);                                     \
-+            u = (vector signed char)                                          \
-+                    vec_perm(uivP[0], uivP[1], align_perm);                   \
-                                                                               \
--            v = (vector signed char) vec_xl(0, vi);                           \
-+            align_perm = vec_lvsl(0, vi);                                     \
-+            v = (vector signed char)                                          \
-+                    vec_perm(vivP[0], vivP[1], align_perm);                   \
-                                                                               \
-             u = (vector signed char)                                          \
-                     vec_sub(u,                                                \
--- 
-2.27.0
-
diff --git a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
deleted file mode 100644
index 9a55178c74f0..000000000000
--- a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
-+++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
-@@ -39,6 +39,15 @@
- #endif
- #include <fenv.h>
- 
-+#if (FE_ALL_EXCEPT == 0)
-+/* E.g. ARM soft float does not define these */
-+#define FE_INVALID    0
-+#define FE_DIVBYZERO  0
-+#define FE_OVERFLOW   0
-+#define FE_UNDERFLOW  0
-+#define FE_INEXACT    0
-+#endif
-+
- #if CONFIG_LIBFONTCONFIG
- #include <fontconfig/fontconfig.h>
- #endif
diff --git a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
deleted file mode 100644
index 00e3f68a415b..000000000000
--- a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
-From: Rainer Hochecker <fernetmenta@online.de>
-Date: Sat, 26 Jan 2019 19:48:35 +0100
-Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
-
-This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
-It was hit frequently when watching h264 channels received via DVB-X.
-Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
----
- libavcodec/vaapi_h264.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
-index 5854587a255..f12fdc457a4 100644
---- a/libavcodec/vaapi_h264.c
-+++ b/libavcodec/vaapi_h264.c
-@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
-     H264SliceContext *sl = &h->slice_ctx[0];
-     int ret;
- 
-+    if (pic->nb_slices == 0) {
-+        ret = AVERROR_INVALIDDATA;
-+        goto finish;
-+    }
-+
-     ret = ff_vaapi_decode_issue(avctx, pic);
-     if (ret < 0)
-         goto finish;
diff --git a/srcpkgs/ffmpeg/template b/srcpkgs/ffmpeg/template
index df4179d1963a..f742082bb520 100644
--- a/srcpkgs/ffmpeg/template
+++ b/srcpkgs/ffmpeg/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpeg'
 # audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
 pkgname=ffmpeg
-version=4.4.4
+version=6.0
 revision=1
 short_desc="Decoding, encoding and streaming software"
 maintainer="Orphaned <orphan@voidlinux.org>"
@@ -9,7 +9,7 @@ license="GPL-3.0-or-later"
 homepage="https://www.ffmpeg.org"
 changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
 distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
-checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+checksum=57be87c22d9b49c112b6d24bc67d42508660e6b718b3db89c44e47e289137082
 
 hostmakedepends="pkg-config perl"
 makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
@@ -26,12 +26,13 @@ makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-deve
  $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
  $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
  $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
- $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers Vulkan-Tools Vulkan-ValidationLayers')
+ $(vopt_if onevpl 'onevpl onevpl-devel')
  $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
 depends="ffplay>=${version}_${revision}"
 
 build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
- dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec onevpl"
 build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
 desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
 desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
@@ -39,10 +40,8 @@ desc_option_sofa="Enable support for AES SOFA"
 desc_option_webp="Enable support for WebP"
 
 case "$XBPS_TARGET_MACHINE" in
-	i686*|x86_64*)
-		hostmakedepends+=" nasm"
-		build_options_default+=" vaapi vdpau nvenc nvdec"
-		;;
+	i686*) build_options_default+=" vaapi vdpau nvenc nvdec";;
+	x86_64*) build_options_default+=" vaapi vdpau nvenc nvdec onevpl";;
 	ppc64*) build_options_default+=" vaapi vdpau";;
 	mips*) CFLAGS="-mnan=legacy";;
 esac
@@ -117,18 +116,19 @@ do_configure() {
 		$(vopt_enable x265 libx265) \
 		$(vopt_enable v4l2 libv4l2) \
 		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
-		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		--enable-libbs2b --enable-libvidstab \
 		$(vopt_enable dav1d libdav1d) \
 		$(vopt_enable zimg libzimg) \
 		$(vopt_enable webp libwebp) \
 		$(vopt_enable sofa libmysofa) \
 		$(vopt_enable vulkan) \
+		$(vopt_enable onevpl libvpl) \
 		$(vopt_enable drm libdrm) \
 		$(vopt_enable svtav1 libsvtav1) \
 		$(vopt_enable srt libsrt) \
 		$(vopt_enable rist librist) \
-		$(vopt_if nvenc '--enable-nvenc') \
-		$(vopt_if nvdec '--enable-nvdec')
+		$(vopt_enable nvenc nvenc) \
+		$(vopt_enable nvdec nvdec)
 }
 
 do_build() {
@@ -155,10 +155,8 @@ libavdevice_package() {
 }
 
 libavresample_package() {
-	short_desc="FFmpeg audio resampling library"
-	pkg_install() {
-		vmove "usr/lib/libavresample.so.*"
-	}
+	short_desc="Package deprecated, removal needed"
+	build_style=meta
 }
 
 libavformat_package() {
@@ -212,15 +210,9 @@ ffmpeg-devel_package() {
 		libavfilter>=${version}_${revision}
 		libpostproc>=${version}_${revision}
 		libswscale>=${version}_${revision}
-		libswresample>=${version}_${revision}
-		libavresample>=${version}_${revision}"
+		libswresample>=${version}_${revision}"
 	short_desc+=" - development files"
-
-	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
-		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
-		nostrip_files="/usr/lib/libavfilter.a"
-	fi
-
+	conflicts="ffmpeg4-devel"
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig

From 16d419759bb8d3973544d460394a0b1f7246b816 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:56:22 -0400
Subject: [PATCH 002/116] New package: ffmpeg4-4.4.4.

---
 srcpkgs/ffmpeg4-devel                         |   1 +
 srcpkgs/ffmpeg4/files/altivec.patch           |  60 +++++
 .../patches/armv5tel-floating-point.patch     |  18 ++
 .../workaround-mesa-readeon-vaapi-bug.patch   |  28 +++
 srcpkgs/ffmpeg4/template                      | 238 ++++++++++++++++++
 srcpkgs/libavcodec4                           |   1 +
 srcpkgs/libavdevice4                          |   1 +
 srcpkgs/libavfilter4                          |   1 +
 srcpkgs/libavformat4                          |   1 +
 srcpkgs/libavresample4                        |   1 +
 srcpkgs/libavutil4                            |   1 +
 srcpkgs/libpostproc4                          |   1 +
 srcpkgs/libswresample4                        |   1 +
 srcpkgs/libswscale4                           |   1 +
 14 files changed, 354 insertions(+)
 create mode 120000 srcpkgs/ffmpeg4-devel
 create mode 100644 srcpkgs/ffmpeg4/files/altivec.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
 create mode 100644 srcpkgs/ffmpeg4/template
 create mode 120000 srcpkgs/libavcodec4
 create mode 120000 srcpkgs/libavdevice4
 create mode 120000 srcpkgs/libavfilter4
 create mode 120000 srcpkgs/libavformat4
 create mode 120000 srcpkgs/libavresample4
 create mode 120000 srcpkgs/libavutil4
 create mode 120000 srcpkgs/libpostproc4
 create mode 120000 srcpkgs/libswresample4
 create mode 120000 srcpkgs/libswscale4

diff --git a/srcpkgs/ffmpeg4-devel b/srcpkgs/ffmpeg4-devel
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/ffmpeg4-devel
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/ffmpeg4/files/altivec.patch b/srcpkgs/ffmpeg4/files/altivec.patch
new file mode 100644
index 000000000000..9c5720046332
--- /dev/null
+++ b/srcpkgs/ffmpeg4/files/altivec.patch
@@ -0,0 +1,60 @@
+revert some altivec specific change on all ppc* except ppc64le*
+
+q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
+conditionally, for ppc* but not ppc64le* (the new code is valid for
+POWER8 VSX which LE targets as a baseline but not BE)"
+
+
+This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
+---
+ libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
+ 1 file changed, 20 insertions(+), 4 deletions(-)
+
+diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
+index 536545293d..c1e2852adb 100644
+--- a/libswscale/ppc/yuv2rgb_altivec.c
++++ b/libswscale/ppc/yuv2rgb_altivec.c
+@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+     vector signed short R1, G1, B1;                                           \
+     vector unsigned char R, G, B;                                             \
+                                                                               \
++    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
++    vector unsigned char align_perm;                                          \
++                                                                              \
+     vector signed short lCY       = c->CY;                                    \
+     vector signed short lOY       = c->OY;                                    \
+     vector signed short lCRV      = c->CRV;                                   \
+@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
+                                                                               \
+         for (j = 0; j < w / 16; j++) {                                        \
+-            y0 = vec_xl(0, y1i);                                              \
++            y1ivP = (const vector unsigned char *) y1i;                       \
++            y2ivP = (const vector unsigned char *) y2i;                       \
++            uivP  = (const vector unsigned char *) ui;                        \
++            vivP  = (const vector unsigned char *) vi;                        \
++                                                                              \
++            align_perm = vec_lvsl(0, y1i);                                    \
++            y0 = (vector unsigned char)                                       \
++                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
+                                                                               \
+-            y1 = vec_xl(0, y2i);                                              \
++            align_perm = vec_lvsl(0, y2i);                                    \
++            y1 = (vector unsigned char)                                       \
++                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
+                                                                               \
+-            u = (vector signed char) vec_xl(0, ui);                           \
++            align_perm = vec_lvsl(0, ui);                                     \
++            u = (vector signed char)                                          \
++                    vec_perm(uivP[0], uivP[1], align_perm);                   \
+                                                                               \
+-            v = (vector signed char) vec_xl(0, vi);                           \
++            align_perm = vec_lvsl(0, vi);                                     \
++            v = (vector signed char)                                          \
++                    vec_perm(vivP[0], vivP[1], align_perm);                   \
+                                                                               \
+             u = (vector signed char)                                          \
+                     vec_sub(u,                                                \
+-- 
+2.27.0
+
diff --git a/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
new file mode 100644
index 000000000000..9a55178c74f0
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
@@ -0,0 +1,18 @@
+--- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
++++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
+@@ -39,6 +39,15 @@
+ #endif
+ #include <fenv.h>
+ 
++#if (FE_ALL_EXCEPT == 0)
++/* E.g. ARM soft float does not define these */
++#define FE_INVALID    0
++#define FE_DIVBYZERO  0
++#define FE_OVERFLOW   0
++#define FE_UNDERFLOW  0
++#define FE_INEXACT    0
++#endif
++
+ #if CONFIG_LIBFONTCONFIG
+ #include <fontconfig/fontconfig.h>
+ #endif
diff --git a/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
new file mode 100644
index 000000000000..00e3f68a415b
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
@@ -0,0 +1,28 @@
+From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
+From: Rainer Hochecker <fernetmenta@online.de>
+Date: Sat, 26 Jan 2019 19:48:35 +0100
+Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
+
+This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
+It was hit frequently when watching h264 channels received via DVB-X.
+Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
+---
+ libavcodec/vaapi_h264.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
+index 5854587a255..f12fdc457a4 100644
+--- a/libavcodec/vaapi_h264.c
++++ b/libavcodec/vaapi_h264.c
+@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
+     H264SliceContext *sl = &h->slice_ctx[0];
+     int ret;
+ 
++    if (pic->nb_slices == 0) {
++        ret = AVERROR_INVALIDDATA;
++        goto finish;
++    }
++
+     ret = ff_vaapi_decode_issue(avctx, pic);
+     if (ret < 0)
+         goto finish;
diff --git a/srcpkgs/ffmpeg4/template b/srcpkgs/ffmpeg4/template
new file mode 100644
index 000000000000..5228c7df08fb
--- /dev/null
+++ b/srcpkgs/ffmpeg4/template
@@ -0,0 +1,238 @@
+# Template file for 'ffmpeg4'
+# audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
+pkgname=ffmpeg4
+version=4.4.4
+revision=1
+short_desc="Decoding, encoding and streaming software - ffmpeg4 libraries only"
+maintainer="Orphaned <orphan@voidlinux.org>"
+license="GPL-3.0-or-later"
+homepage="https://www.ffmpeg.org"
+changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
+distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
+checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+
+hostmakedepends="pkg-config perl"
+makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
+ libXext-devel libXvMC-devel libxcb-devel lame-devel libtheora-devel
+ libvorbis-devel x264-devel xvidcore-devel jack-devel SDL2-devel
+ libcdio-paranoia-devel librtmp-devel libmodplug-devel gnutls-devel
+ speex-devel celt-devel harfbuzz-devel libass-devel opus-devel ocl-icd-devel
+ libbs2b-devel libvidstab-devel $(vopt_if pulseaudio pulseaudio-devel)
+ $(vopt_if vaapi libva-devel) $(vopt_if vdpau libvdpau-devel)
+ $(vopt_if x265 x265-devel) $(vopt_if v4l2 v4l-utils-devel)
+ $(vopt_if fdk_aac fdk-aac-devel) $(vopt_if vpx libvpx-devel)
+ $(vopt_if aom libaom-devel) $(vopt_if sndio sndio-devel)
+ $(vopt_if dav1d libdav1d-devel) $(vopt_if zimg zimg-devel)
+ $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
+ $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
+ $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if mfx 'libmfx libmfx-devel')
+ $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
+
+build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec mfx"
+build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
+
+desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
+desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
+desc_option_sofa="Enable support for AES SOFA"
+desc_option_webp="Enable support for WebP"
+
+case "$XBPS_TARGET_MACHINE" in
+	i686*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau nvenc nvdec"
+			;;
+	x86_64*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau mfx nvenc nvdec"
+			;;
+	ppc64*) build_options_default+=" vaapi vdpau";;
+	mips*) CFLAGS="-mnan=legacy";;
+esac
+
+if [ "$XBPS_TARGET_WORDSIZE" != "32" ]; then
+	build_options_default+=" svtav1"
+fi
+
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+fi
+
+_apply_patch() {
+	local args="$1" pname="$(basename $2)"
+
+	if [ ! -f ".${pname}_done" ]; then
+		patch -N $args -i $2
+		touch .${pname}_done
+	fi
+}
+
+post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64le*) ;;
+		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
+	esac
+}
+
+do_configure() {
+	# Fix gcc on x86_64-musl only
+	if [ "$XBPS_TARGET_MACHINE" = "x86_64-musl" ]; then
+		vsed -i configure -e "s;_cflags_speed='-O3';_cflags_speed='-O2';"
+	fi
+
+	if [ "$CROSS_BUILD" ]; then
+		case "$XBPS_TARGET_MACHINE" in
+			arm*) _arch="arm";;
+			aarch64*) _arch="aarch64";;
+			mips*) _arch="mips";;
+			ppc64*) _arch="ppc64";;
+			ppc*) _arch="ppc";;
+			*) _arch="${XBPS_TARGET_MACHINE%%-musl}";;
+		esac
+
+		_args+=" --enable-cross-compile
+			--sysroot=$XBPS_CROSS_BASE
+			--cross-prefix=${XBPS_CROSS_TRIPLET}-
+			--target-os=linux --arch=${_arch}"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc|ppc-musl) _args+=" --disable-altivec";;
+	esac
+
+	if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+		_args+=" --extra-libs=-latomic"
+	fi
+
+	./configure --prefix=/usr --disable-debug --enable-gpl --enable-gnutls \
+		--disable-stripping \
+		--enable-libcdio --enable-version3 --enable-runtime-cpudetect \
+		--enable-libmp3lame --enable-libvorbis --enable-libxvid \
+		--enable-libx264 $(vopt_enable vpx libvpx) --enable-libtheora \
+		--enable-shared --enable-static --enable-libxcb \
+		$(vopt_enable pulseaudio libpulse) --enable-libfreetype --enable-libmodplug \
+		--enable-libspeex --enable-libcelt --enable-libass \
+		--enable-libopus --enable-librtmp --enable-libjack \
+		$(vopt_if fdk_aac '--enable-nonfree --enable-libfdk-aac') \
+		--disable-libopencore_amrnb --disable-libopencore_amrwb \
+		--disable-libopenjpeg \
+		--enable-postproc --enable-opencl ${_args} \
+		$(vopt_enable x265 libx265) \
+		$(vopt_enable v4l2 libv4l2) \
+		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
+		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		$(vopt_enable dav1d libdav1d) \
+		$(vopt_enable zimg libzimg) \
+		$(vopt_enable webp libwebp) \
+		$(vopt_enable sofa libmysofa) \
+		$(vopt_enable vulkan) \
+		$(vopt_enable drm libdrm) \
+		$(vopt_enable svtav1 libsvtav1) \
+		$(vopt_enable srt libsrt) \
+		$(vopt_enable rist librist) \
+		$(vopt_enable mfx libmfx) \
+		$(vopt_if nvenc '--enable-nvenc') \
+		$(vopt_if nvdec '--enable-nvdec')
+}
+
+do_build() {
+	make ${makejobs}
+	make doc/ff{mpeg,play}.1
+}
+
+do_install() {
+	make DESTDIR=${DESTDIR} install install-man
+	rm -rf ${DESTDIR}/usr/bin
+}
+
+libavcodec4_package() {
+	short_desc="FFmpeg codec library"
+	pkg_install() {
+		vmove "usr/lib/libavcodec.so.*"
+	}
+}
+
+libavdevice4_package() {
+	short_desc="FFmpeg device handling library"
+	pkg_install() {
+		vmove "usr/lib/libavdevice.so.*"
+	}
+}
+
+libavresample4_package() {
+	short_desc="FFmpeg audio resampling library"
+	pkg_install() {
+		vmove "usr/lib/libavresample.so.*"
+	}
+}
+
+libavformat4_package() {
+	short_desc="FFmpeg file format library"
+	pkg_install() {
+		vmove "usr/lib/libavformat.so.*"
+	}
+}
+
+libavutil4_package() {
+	short_desc="FFmpeg utility library"
+	pkg_install() {
+		vmove "usr/lib/libavutil.so.*"
+	}
+}
+
+libavfilter4_package() {
+	short_desc="FFmpeg audio/video filter library"
+	pkg_install() {
+		vmove "usr/lib/libavfilter.so.*"
+	}
+}
+
+libpostproc4_package() {
+	short_desc="FFmpeg video postprocessing library"
+	pkg_install() {
+		vmove "usr/lib/libpostproc.so.*"
+	}
+}
+
+libswscale4_package() {
+	short_desc="FFmpeg video scaling library"
+	pkg_install() {
+		vmove "usr/lib/libswscale.so.*"
+	}
+}
+
+libswresample4_package() {
+	short_desc="FFmpeg video resampling library"
+	pkg_install() {
+		vmove "usr/lib/libswresample.so.*"
+	}
+}
+
+ffmpeg4-devel_package() {
+	depends="
+		libavcodec4>=${version}_${revision}
+		libavdevice4>=${version}_${revision}
+		libavformat4>=${version}_${revision}
+		libavutil4>=${version}_${revision}
+		libavfilter4>=${version}_${revision}
+		libpostproc4>=${version}_${revision}
+		libswscale4>=${version}_${revision}
+		libswresample4>=${version}_${revision}
+		libavresample4>=${version}_${revision}"
+	short_desc+=" - development files"
+	conflicts="ffmpeg-devel"
+	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
+		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
+		nostrip_files="/usr/lib/libavfilter.a"
+	fi
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.a"
+		vmove "usr/lib/*.so"
+		vmove usr/share/ffmpeg/examples
+		vmove usr/share/man/man3
+	}
+}
diff --git a/srcpkgs/libavcodec4 b/srcpkgs/libavcodec4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavcodec4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavdevice4 b/srcpkgs/libavdevice4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavdevice4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavfilter4 b/srcpkgs/libavfilter4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavfilter4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavformat4 b/srcpkgs/libavformat4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavformat4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavresample4 b/srcpkgs/libavresample4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavutil4 b/srcpkgs/libavutil4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavutil4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libpostproc4 b/srcpkgs/libpostproc4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libpostproc4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswresample4 b/srcpkgs/libswresample4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libswresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswscale4 b/srcpkgs/libswscale4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libswscale4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file

From c6cb02810ef41dcab2642f78032148528531ad5b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:04 -0400
Subject: [PATCH 003/116] opencv: update to 4.7.0.

---
 common/shlibs           | 104 ++++++++++++++++++++--------------------
 srcpkgs/opencv/template |   8 ++--
 2 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index 892e119802cb..ce0c518f00ef 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2134,58 +2134,58 @@ libcapstone.so.4 capstone-4.0_1
 libhavege.so.2 libhaveged-1.9.11_1
 libnih.so.1 libnih-1.0.3_1
 libnih-dbus.so.1 libnih-1.0.3_1
-libopencv_quality.so.406 libopencv-4.6.0_1
-libopencv_reg.so.406 libopencv-4.6.0_1
-libopencv_surface_matching.so.406 libopencv-4.6.0_1
-libopencv_xphoto.so.406 libopencv-4.6.0_1
-libopencv_freetype.so.406 libopencv-4.6.0_1
-libopencv_fuzzy.so.406 libopencv-4.6.0_1
-libopencv_hfs.so.406 libopencv-4.6.0_1
-libopencv_img_hash.so.406 libopencv-4.6.0_1
-libopencv_line_descriptor.so.406 libopencv-4.6.0_1
-libopencv_saliency.so.406 libopencv-4.6.0_1
-libopencv_structured_light.so.406 libopencv-4.6.0_1
-libopencv_aruco.so.406 libopencv-4.6.0_1
-libopencv_bgsegm.so.406 libopencv-4.6.0_1
-libopencv_bioinspired.so.406 libopencv-4.6.0_1
-libopencv_ccalib.so.406 libopencv-4.6.0_1
-libopencv_face.so.406 libopencv-4.6.0_1
-libopencv_tracking.so.406 libopencv-4.6.0_1
-libopencv_xfeatures2d.so.406 libopencv-4.6.0_1
-libopencv_optflow.so.406 libopencv-4.6.0_1
-libopencv_ximgproc.so.406 libopencv-4.6.0_1
-libopencv_plot.so.406 libopencv-4.6.0_1
-libopencv_text.so.406 libopencv-4.6.0_1
-libopencv_ml.so.406 libopencv-4.6.0_1
-libopencv_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn.so.406 libopencv-4.6.0_1
-libopencv_shape.so.406 libopencv-4.6.0_1
-libopencv_stitching.so.406 libopencv-4.6.0_1
-libopencv_photo.so.406 libopencv-4.6.0_1
-libopencv_video.so.406 libopencv-4.6.0_1
-libopencv_calib3d.so.406 libopencv-4.6.0_1
-libopencv_features2d.so.406 libopencv-4.6.0_1
-libopencv_flann.so.406 libopencv-4.6.0_1
-libopencv_highgui.so.406 libopencv-4.6.0_1
-libopencv_videoio.so.406 libopencv-4.6.0_1
-libopencv_imgcodecs.so.406 libopencv-4.6.0_1
-libopencv_imgproc.so.406 libopencv-4.6.0_1
-libopencv_core.so.406 libopencv-4.6.0_1
-libopencv_superres.so.406 libopencv-4.6.0_1
-libopencv_videostab.so.406 libopencv-4.6.0_1
-libopencv_gapi.so.406 libopencv-4.6.0_1
-libopencv_xobjdetect.so.406 libopencv-4.6.0_1
-libopencv_datasets.so.406 libopencv-4.6.0_1
-libopencv_dnn_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn_superres.so.406 libopencv-4.6.0_1
-libopencv_dpm.so.406 libopencv-4.6.0_1
-libopencv_phase_unwrapping.so.406 libopencv-4.6.0_1
-libopencv_stereo.so.406 libopencv-4.6.0_1
-libopencv_rapid.so.406 libopencv-4.6.0_1
-libopencv_intensity_transform.so.406 libopencv-4.6.0_1
-libopencv_alphamat.so.406 libopencv-4.6.0_1
-libopencv_barcode.so.406 libopencv-4.6.0_1
-libopencv_mcc.so.406 libopencv-4.6.0_1
+libopencv_quality.so.407 libopencv-4.7.0_1
+libopencv_reg.so.407 libopencv-4.7.0_1
+libopencv_surface_matching.so.407 libopencv-4.7.0_1
+libopencv_xphoto.so.407 libopencv-4.7.0_1
+libopencv_freetype.so.407 libopencv-4.7.0_1
+libopencv_fuzzy.so.407 libopencv-4.7.0_1
+libopencv_hfs.so.407 libopencv-4.7.0_1
+libopencv_img_hash.so.407 libopencv-4.7.0_1
+libopencv_line_descriptor.so.407 libopencv-4.7.0_1
+libopencv_saliency.so.407 libopencv-4.7.0_1
+libopencv_structured_light.so.407 libopencv-4.7.0_1
+libopencv_aruco.so.407 libopencv-4.7.0_1
+libopencv_bgsegm.so.407 libopencv-4.7.0_1
+libopencv_bioinspired.so.407 libopencv-4.7.0_1
+libopencv_ccalib.so.407 libopencv-4.7.0_1
+libopencv_face.so.407 libopencv-4.7.0_1
+libopencv_tracking.so.407 libopencv-4.7.0_1
+libopencv_xfeatures2d.so.407 libopencv-4.7.0_1
+libopencv_optflow.so.407 libopencv-4.7.0_1
+libopencv_ximgproc.so.407 libopencv-4.7.0_1
+libopencv_plot.so.407 libopencv-4.7.0_1
+libopencv_text.so.407 libopencv-4.7.0_1
+libopencv_ml.so.407 libopencv-4.7.0_1
+libopencv_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn.so.407 libopencv-4.7.0_1
+libopencv_shape.so.407 libopencv-4.7.0_1
+libopencv_stitching.so.407 libopencv-4.7.0_1
+libopencv_photo.so.407 libopencv-4.7.0_1
+libopencv_video.so.407 libopencv-4.7.0_1
+libopencv_calib3d.so.407 libopencv-4.7.0_1
+libopencv_features2d.so.407 libopencv-4.7.0_1
+libopencv_flann.so.407 libopencv-4.7.0_1
+libopencv_highgui.so.407 libopencv-4.7.0_1
+libopencv_videoio.so.407 libopencv-4.7.0_1
+libopencv_imgcodecs.so.407 libopencv-4.7.0_1
+libopencv_imgproc.so.407 libopencv-4.7.0_1
+libopencv_core.so.407 libopencv-4.7.0_1
+libopencv_superres.so.407 libopencv-4.7.0_1
+libopencv_videostab.so.407 libopencv-4.7.0_1
+libopencv_gapi.so.407 libopencv-4.7.0_1
+libopencv_xobjdetect.so.407 libopencv-4.7.0_1
+libopencv_datasets.so.407 libopencv-4.7.0_1
+libopencv_dnn_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn_superres.so.407 libopencv-4.7.0_1
+libopencv_dpm.so.407 libopencv-4.7.0_1
+libopencv_phase_unwrapping.so.407 libopencv-4.7.0_1
+libopencv_stereo.so.407 libopencv-4.7.0_1
+libopencv_rapid.so.407 libopencv-4.7.0_1
+libopencv_intensity_transform.so.407 libopencv-4.7.0_1
+libopencv_alphamat.so.407 libopencv-4.7.0_1
+libopencv_barcode.so.407 libopencv-4.7.0_1
+libopencv_mcc.so.407 libopencv-4.7.0_1
 libuniconf.so.4.6 wvstreams-4.6.1_20
 libwvbase.so.4.6 wvstreams-4.6.1_20
 libwvutils.so.4.6 wvstreams-4.6.1_20
diff --git a/srcpkgs/opencv/template b/srcpkgs/opencv/template
index 69c635b1ad2b..41f3183f1582 100644
--- a/srcpkgs/opencv/template
+++ b/srcpkgs/opencv/template
@@ -1,7 +1,7 @@
 # Template file for 'opencv'
 pkgname=opencv
-version=4.6.0
-revision=4
+version=4.7.0
+revision=1
 create_wrksrc=yes
 build_wrksrc=${pkgname}-${version}
 build_style=cmake
@@ -24,8 +24,8 @@ homepage="https://opencv.org"
 changelog="https://github.com/opencv/opencv/wiki/ChangeLog"
 distfiles="https://github.com/opencv/opencv/archive/${version}.tar.gz
  https://github.com/opencv/opencv_contrib/archive/${version}.tar.gz>contrib.tar.gz"
-checksum="1ec1cba65f9f20fe5a41fda1586e01c70ea0c9a6d7b67c9e13edf0cfe2239277
- 1777d5fd2b59029cf537e5fd6f8aa68d707075822f90bde683fcde086f85f7a7"
+checksum="8df0079cdbe179748a18d44731af62a245a45ebf5085223dc03133954c662973
+ 42df840cf9055e59d0e22c249cfb19f04743e1bdad113d31b1573d3934d62584"
 patch_args="-Np1 -d ${build_wrksrc}"
 # tests hang indenfinitely, even with test data included
 make_check=no

From bb1f2cff9f20a3171df98ae133b8fb6bc1651594 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 004/116] actiona: revbump for opencv-4.7.0

---
 srcpkgs/actiona/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/actiona/template b/srcpkgs/actiona/template
index cf5f0b7a2ae6..0d899311e6df 100644
--- a/srcpkgs/actiona/template
+++ b/srcpkgs/actiona/template
@@ -1,7 +1,7 @@
 # Template file for 'actiona'
 pkgname=actiona
 version=3.10.1
-revision=2
+revision=3
 build_style=qmake
 configure_args="PKGCONFIG_OPENCV=opencv4"
 hostmakedepends="pkg-config qt5-plugin-mysql qt5-qmake qt5-host-tools"

From 5dad514f850ed4f8d80fe382bc80d67cfde609b8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 005/116] gmic: revbump for opencv-4.7.0

---
 srcpkgs/gmic/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gmic/template b/srcpkgs/gmic/template
index 24a9c7218fdf..0bb4034d5cc8 100644
--- a/srcpkgs/gmic/template
+++ b/srcpkgs/gmic/template
@@ -1,7 +1,7 @@
 # Template file for 'gmic'
 pkgname=gmic
 version=3.1.6
-revision=3
+revision=4
 _zart_hash=34ebf6cce0bafb98abe57cec83c4a02cd1abeca0
 create_wrksrc=yes
 build_wrksrc="src"

From 13538d1d05a8c90004d67a86d7581b9203e321c2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 006/116] qimgv: revbump for opencv-4.7.0

---
 srcpkgs/qimgv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qimgv/template b/srcpkgs/qimgv/template
index 7eb30db33992..dd341dfe1bfc 100644
--- a/srcpkgs/qimgv/template
+++ b/srcpkgs/qimgv/template
@@ -1,7 +1,7 @@
 # Template file for 'qimgv'
 pkgname=qimgv
 version=1.0.2
-revision=2
+revision=3
 build_style=cmake
 configure_args="$(vopt_if video -DVIDEO_SUPPORT=ON -DVIDEO_SUPPORT=OFF)
  $(vopt_if scale -DOPENCV_SUPPORT=ON -DOPENCV_SUPPORT=OFF)

From 4724f17a08d978a1e94cb1257b8b24b1890f30e6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 007/116] retroshare: revbump for opencv-4.7.0

---
 srcpkgs/retroshare/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroshare/template b/srcpkgs/retroshare/template
index 8a0786c21a08..72023fa98b75 100644
--- a/srcpkgs/retroshare/template
+++ b/srcpkgs/retroshare/template
@@ -1,7 +1,7 @@
 # Template file for 'retroshare'
 pkgname=retroshare
 version=0.6.6
-revision=2
+revision=4
 build_style=qmake
 #XXX broadcast feature requires an ancient udp-discovery-cpp which either needs
 # to be fetched+patched (FTBFS) here or packaged :/

From d0f162a5caeb00630c9c02431c8651e19e25ca78 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 008/116] waifu2x-converter-cpp: revbump for opencv-4.7.0

---
 srcpkgs/waifu2x-converter-cpp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waifu2x-converter-cpp/template b/srcpkgs/waifu2x-converter-cpp/template
index 8c095d0d7bab..aa52d8c981a8 100644
--- a/srcpkgs/waifu2x-converter-cpp/template
+++ b/srcpkgs/waifu2x-converter-cpp/template
@@ -1,7 +1,7 @@
 # Template file for 'waifu2x-converter-cpp'
 pkgname=waifu2x-converter-cpp
 version=5.2.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DINSTALL_MODELS=ON"
 hostmakedepends="pkg-config"

From 8eadc4c48e633c5eb38899811146aa5656d962ff Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:38 -0400
Subject: [PATCH 009/116] vlc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/vlc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/vlc/template b/srcpkgs/vlc/template
index 210762b0a7e2..855ca5238662 100644
--- a/srcpkgs/vlc/template
+++ b/srcpkgs/vlc/template
@@ -1,7 +1,7 @@
 # Template file for 'vlc'
 pkgname=vlc
 version=3.0.18
-revision=3
+revision=4
 build_style=gnu-configure
 configure_args="--disable-gme --disable-libtar --enable-jack
  --enable-live555 --disable-fluidsynth --enable-dvdread
@@ -25,7 +25,7 @@ lib32disabled=yes
 hostmakedepends="automake libtool pkg-config flex gettext libgcrypt-devel
  live555-devel gettext-devel $(vopt_if lua lua52) $(vopt_if chromecast protobuf)"
 makedepends="
- avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg-devel freefont-ttf
+ avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg4-devel freefont-ttf
  gnutls-devel jack-devel liba52-devel libass-devel libbluray-devel
  libcdio-devel libdca-devel libdvbpsi-devel libdvdnav-devel libmad-devel
  libmatroska-devel libmodplug-devel libmpcdec-devel libmpeg2-devel

From 4194a7e435d0f3188f78358786b68a1bb6e8f718 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:55 -0400
Subject: [PATCH 010/116] osg: revbump for ffmpeg4-4.4.3

---
 srcpkgs/osg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/osg/template b/srcpkgs/osg/template
index a9ebbd287933..755793f7e11b 100644
--- a/srcpkgs/osg/template
+++ b/srcpkgs/osg/template
@@ -8,7 +8,7 @@ build_helper="qemu"
 configure_args="-DLIB_POSTFIX="
 hostmakedepends="pkg-config xrandr"
 makedepends="MesaLib-devel gtkglext-devel libcurl-devel giflib-devel librsvg-devel
- jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg-devel xine-lib-devel
+ jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg4-devel xine-lib-devel
  SDL2-devel gst-plugins-base1-devel
  $(vopt_if openexr libopenexr-devel)
  $(vopt_if poppler poppler-glib-devel)

From 69ebdebf2265a5e57fe275d7ed4c188f3a98a744 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:13 -0400
Subject: [PATCH 011/116] xine-lib: revbump for ffmpeg4-4.4.3

---
 srcpkgs/xine-lib/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/xine-lib/template b/srcpkgs/xine-lib/template
index f713eff49b07..ed6194c17d11 100644
--- a/srcpkgs/xine-lib/template
+++ b/srcpkgs/xine-lib/template
@@ -1,6 +1,6 @@
 # Template file for 'xine-lib'
 pkgname=xine-lib
-version=1.2.12
+version=1.2.13
 revision=1
 build_style=gnu-configure
 configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
@@ -8,7 +8,7 @@ configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
 hostmakedepends="automake gettext-devel libtool pkg-config perl"
 makedepends="
  zlib-devel alsa-lib-devel libxcb-devel libSM-devel libXext-devel libXv-devel
- libXvMC-devel liba52-devel libmad-devel ffmpeg-devel pulseaudio-devel
+ libXvMC-devel liba52-devel libmad-devel ffmpeg4-devel pulseaudio-devel
  jack-devel samba-devel libflac-devel libmodplug-devel libmpcdec-devel
  speex-devel libtheora-devel libvorbis-devel libdca-devel faad2-devel
  libcdio-devel libbluray-devel aalib-devel libcaca-devel libXinerama-devel
@@ -19,7 +19,7 @@ license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="http://www.xine-project.org"
 changelog="https://sourceforge.net/projects/xine/files/xine-lib/${version}/README.txt/view"
 distfiles="${SOURCEFORGE_SITE}/xine/${pkgname}-${version}.tar.xz"
-checksum=d606270468e1540c2a89c0d7f5fdf11e17ecc0c2698cc0bcb1065ff26abee098
+checksum=5f10d6d718a4a51c17ed1b32b031d4f9b80b061e8276535b2be31e5ac4b75e6f
 
 case "$XBPS_TARGET_MACHINE" in
 	i686-musl)

From 4896081e695e82dd385c554dafc7de5a1be77627 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 012/116] QMPlay2: revbump for ffmpeg-6.0

---
 srcpkgs/QMPlay2/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/QMPlay2/template b/srcpkgs/QMPlay2/template
index 17879a25093d..7c387a57b8bd 100644
--- a/srcpkgs/QMPlay2/template
+++ b/srcpkgs/QMPlay2/template
@@ -1,7 +1,7 @@
 # Template file for 'QMPlay2'
 pkgname=QMPlay2
 version=23.06.04
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools"
 makedepends="alsa-lib-devel ffmpeg-devel libass-devel libcdio-devel libgme-devel

From 52e216c303c775e5a7f8970404a6e57e64ce248f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 013/116] alsa-plugins: revbump for ffmpeg-6.0

---
 srcpkgs/alsa-plugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/alsa-plugins/template b/srcpkgs/alsa-plugins/template
index 0bfa6d9fd264..a5708a7d82a8 100644
--- a/srcpkgs/alsa-plugins/template
+++ b/srcpkgs/alsa-plugins/template
@@ -1,7 +1,7 @@
 # Template file for 'alsa-plugins'
 pkgname=alsa-plugins
 version=1.2.7.1
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--disable-maemo-plugin"
 hostmakedepends="pkg-config"

From 9595f6c97f7ac31a2d7ae53d402bfb38839938da Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 014/116] arcan: revbump for ffmpeg-6.0

---
 srcpkgs/arcan/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/arcan/template b/srcpkgs/arcan/template
index 7be9652eccf3..ccc7df11ceac 100644
--- a/srcpkgs/arcan/template
+++ b/srcpkgs/arcan/template
@@ -2,7 +2,7 @@
 # !! keep synced with: acfgfs aclip aloadimage
 pkgname=arcan
 version=0.6.2.1
-revision=1
+revision=2
 create_wrksrc=yes
 build_wrksrc=arcan/src
 build_style=cmake

From 6a04982b909c36732591e59b5eee2c49827333ad Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 015/116] attract: revbump for ffmpeg4-4.4.3

---
 srcpkgs/attract/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/attract/template b/srcpkgs/attract/template
index 26144e931a3c..e760bf0d18ae 100644
--- a/srcpkgs/attract/template
+++ b/srcpkgs/attract/template
@@ -1,12 +1,12 @@
 # Template file for 'attract'
 pkgname=attract
 version=2.6.2
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="VERBOSE=1"
 make_use_env=yes
 hostmakedepends="pkg-config"
-makedepends="SFML-devel ffmpeg-devel fontconfig-devel glu-devel libarchive-devel
+makedepends="SFML-devel ffmpeg4-devel fontconfig-devel glu-devel libarchive-devel
  libcurl-devel libjpeg-turbo-devel xine-lib rapidjson libXrandr-devel"
 depends="git"
 short_desc="Attract-Mode is a graphical frontend for emulators"

From 746c1163de93a1d3184aa71e8fba4b5ba2984ddc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 016/116] aubio: revbump for ffmpeg-6.0

---
 srcpkgs/aubio/patches/ffmpeg5.patch | 25 +++++++++++++++++++++++++
 srcpkgs/aubio/template              |  2 +-
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/aubio/patches/ffmpeg5.patch

diff --git a/srcpkgs/aubio/patches/ffmpeg5.patch b/srcpkgs/aubio/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..aace41a6e6d9
--- /dev/null
+++ b/srcpkgs/aubio/patches/ffmpeg5.patch
@@ -0,0 +1,25 @@
+From 8a05420e5dd8c7b8b2447f82dc919765876511b3 Mon Sep 17 00:00:00 2001
+From: Paul Brossier <piem@piem.org>
+Date: Tue, 25 Jan 2022 18:30:27 +0100
+Subject: [PATCH] [source_avcodec] define FF_API_LAVF_AVCTX for libavcodec >
+ 59, thx @berolinux (closes gh-353)
+
+---
+ src/io/source_avcodec.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/io/source_avcodec.c b/src/io/source_avcodec.c
+index e0ae93b5..1421bd9a 100644
+--- a/src/io/source_avcodec.c
++++ b/src/io/source_avcodec.c
+@@ -68,6 +68,10 @@
+ #define AUBIO_AVCODEC_MAX_BUFFER_SIZE AV_INPUT_BUFFER_MIN_SIZE
+ #endif
+ 
++#if LIBAVCODEC_VERSION_MAJOR >= 59
++#define FF_API_LAVF_AVCTX 1
++#endif
++
+ struct _aubio_source_avcodec_t {
+   uint_t hop_size;
+   uint_t samplerate;
diff --git a/srcpkgs/aubio/template b/srcpkgs/aubio/template
index ad1c4b256991..7d875cc02541 100644
--- a/srcpkgs/aubio/template
+++ b/srcpkgs/aubio/template
@@ -1,7 +1,7 @@
 # Template file for 'aubio'
 pkgname=aubio
 version=0.4.9
-revision=1
+revision=2
 build_style=waf3
 # XXX lash, pure and swig support.
 hostmakedepends="pkg-config txt2man"

From aa56e0691464a5665e49ec65d14c346578528866 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 017/116] audacious-plugins: revbump for ffmpeg-6.0

---
 .../audacious-plugins/patches/ffmpeg5.patch   | 43 +++++++++++++++++++
 srcpkgs/audacious-plugins/template            |  2 +-
 2 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/audacious-plugins/patches/ffmpeg5.patch

diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg5.patch b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..4e5e34099d71
--- /dev/null
+++ b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
@@ -0,0 +1,43 @@
+commit 298aa371c56c2f52c25a33d9bdec4918b11cebdc
+Author: tibequadorian <tibequadorian@posteo.de>
+Date:   Sat Mar 19 18:40:12 2022 +0100
+
+    audacious-plugins: rebuild against ffmpeg-5.0
+
+diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+new file mode 100644
+index 0000000000..617c11215b
+--- /dev/null
++++ b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+@@ -0,0 +1,31 @@
++From f60beb400eeb1e4778bbfd738bc4a4ccef3de539 Mon Sep 17 00:00:00 2001
++From: John Lindgren <john@jlindgren.net>
++Date: Sat, 5 Mar 2022 12:05:34 -0500
++Subject: [PATCH] Fix build with FFmpeg 5.0
++
++---
++ src/ffaudio/ffaudio-core.cc | 4 ++--
++ 1 file changed, 2 insertions(+), 2 deletions(-)
++
++diff --git a/src/ffaudio/ffaudio-core.cc b/src/ffaudio/ffaudio-core.cc
++index 16dc63e3a..a2b95fd6c 100644
++--- a/src/ffaudio/ffaudio-core.cc
+++++ b/src/ffaudio/ffaudio-core.cc
++@@ -274,7 +274,7 @@ static AVInputFormat * get_format_by_content (const char * name, VFSFile & file)
++         AVProbeData d = {name, buf, filled};
++         score = target;
++ 
++-        f = av_probe_input_format2 (& d, true, & score);
+++        f = (AVInputFormat *) av_probe_input_format2 (& d, true, & score);
++         if (f)
++             break;
++ 
++@@ -347,7 +347,7 @@ static bool find_codec (AVFormatContext * c, CodecInfo * cinfo)
++ #endif
++         if (stream && stream->codecpar && stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
++         {
++-            AVCodec * codec = avcodec_find_decoder (stream->codecpar->codec_id);
+++            AVCodec * codec = (AVCodec *) avcodec_find_decoder (stream->codecpar->codec_id);
++ 
++             if (codec)
++             {
diff --git a/srcpkgs/audacious-plugins/template b/srcpkgs/audacious-plugins/template
index 88cbc1671fc6..beebfae59ed4 100644
--- a/srcpkgs/audacious-plugins/template
+++ b/srcpkgs/audacious-plugins/template
@@ -2,7 +2,7 @@
 #Keep in sync with audacious!
 pkgname=audacious-plugins
 version=4.3.1
-revision=1
+revision=2
 build_style=meson
 configure_args="$(vopt_bool gtk3 gtk) $(vopt_bool gtk3)
  $(vopt_bool qt) $(vopt_bool qt qt6)"

From e65ad07bc075175974c79f6efb9140c4209cd3f9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 018/116] audacity: revbump for ffmpeg4-4.4.3

---
 srcpkgs/audacity/template | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/audacity/template b/srcpkgs/audacity/template
index d509c0a89407..11e20255685b 100644
--- a/srcpkgs/audacity/template
+++ b/srcpkgs/audacity/template
@@ -1,7 +1,7 @@
 # Template file for 'audacity'
 pkgname=audacity
 version=2.4.1
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--with-ffmpeg=system --with-libsndfile=system --with-expat=system
  --with-libsoxr=system --with-lame=system --with-lv2=system ac_cv_path_WX_CONFIG=wx-config-gtk3"
@@ -9,7 +9,7 @@ hostmakedepends="pkg-config cmake gettext libtool m4 which"
 makedepends="jack-devel wxWidgets-gtk3-devel gtk+3-devel
  libmad-devel soundtouch-devel libsoxr-devel
  vamp-plugin-sdk-devel lame-devel libid3tag-devel libflac-devel
- ffmpeg-devel twolame-devel serd-devel lv2 lilv-devel suil-devel"
+ ffmpeg4-devel twolame-devel serd-devel lv2 lilv-devel suil-devel"
 depends="desktop-file-utils hicolor-icon-theme"
 short_desc="Graphical cross-platform audio editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
@@ -33,5 +33,4 @@ post_install() {
 	vcopy plug-ins /usr/share/audacity
 
 	rm ${DESTDIR}/usr/share/doc/audacity/LICENSE.txt
-	vlicense LICENSE.txt LICENSE
 }

From b50d2dd063e7314136fc776f85cd65ac11171c32 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 019/116] avidemux: revbump for ffmpeg-6.0

---
 srcpkgs/avidemux/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/avidemux/template b/srcpkgs/avidemux/template
index 253a0243e225..557285982d2b 100644
--- a/srcpkgs/avidemux/template
+++ b/srcpkgs/avidemux/template
@@ -1,7 +1,7 @@
 # Template file for 'avidemux'
 pkgname=avidemux
 version=2.8.0
-revision=2
+revision=3
 # Can't be compiled for aarch64, arm* or mips*
 archs="x86_64* i686*"
 hostmakedepends="cmake pkg-config qt5-host-tools qt5-devel tar yasm"

From c87f46b4eb26708fee8d3000d30effff1b734e5b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 020/116] baresip: revbump for ffmpeg-6.0

---
 srcpkgs/baresip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/baresip/template b/srcpkgs/baresip/template
index f1bd1817048b..b21e22334316 100644
--- a/srcpkgs/baresip/template
+++ b/srcpkgs/baresip/template
@@ -1,7 +1,7 @@
 # Template file for 'baresip'
 pkgname=baresip
 version=2.10.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config glib-devel"
 makedepends="libgsm-devel libpng-devel openssl-devel libsndfile-devel

From cd73b78ad79cc8ba1efe107fc0056fd3ff3e1d43 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 021/116] blender: revbump for ffmpeg-6.0

---
 srcpkgs/blender/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index ec724bb0a6dc..0f72876d4d70 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -1,7 +1,7 @@
 # Template file for 'blender'
 pkgname=blender
 version=3.5.1
-revision=1
+revision=2
 archs="x86_64* ppc64*"
 build_style="cmake"
 pycompile_dirs="/usr/share/blender/${version%.*}/scripts"
@@ -9,8 +9,8 @@ configure_args="-DWITH_INSTALL_PORTABLE=OFF -DWITH_PYTHON_INSTALL=OFF
  -DWITH_JACK=ON -DWITH_CODEC_FFMPEG=ON -DWITH_CODEC_SNDFILE=ON -DWITH_OPENMP=ON
  -DWITH_FFTW3=ON -DWITH_MOD_OCEANSIM=ON -DWITH_CYCLES_EMBREE=OFF -DWITH_OPENCOLORIO=ON
  -DWITH_IMAGE_OPENEXR=ON -DWITH_IMAGE_OPENJPEG=ON -DWITH_OPENSUBDIV=ON
- -DWITH_OPENCOLLADA=ON -DWITH_SYSTEM_GLEW=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
- -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_LIBDECOR=ON
+ -DWITH_OPENCOLLADA=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
+ -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_WAYLAND_LIBDECOR=ON
  -DWITH_BUILDINFO=OFF -DPYTHON_VERSION=${py3_ver} -DPYTHON_LIBPATH=/usr/lib
  -DPYTHON_LIBRARY=python${py3_ver}${py3_abiver} -DPYTHON_INCLUDE_DIRS=/${py3_inc}
  -DWITH_SYSTEM_LZO=ON -DWITH_SYSTEM_EIGEN3=ON -DWITH_SYSTEM_FREETYPE=ON"

From 7be47d44fdc110fe6981d9902aa513453fb0982a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 022/116] cantata: revbump for ffmpeg-6.0

---
 srcpkgs/cantata/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cantata/template b/srcpkgs/cantata/template
index 4b417d80d5c2..8a90aaa4c07a 100644
--- a/srcpkgs/cantata/template
+++ b/srcpkgs/cantata/template
@@ -1,7 +1,7 @@
 # Template file for 'cantata'
 pkgname=cantata
 version=2.5.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools qt5-tools"
 makedepends="qt5-devel qt5-tools-devel qt5-svg-devel qt5-xmlpatterns-devel

From aa954092e5986923a2fc623f00562ea78d5a0b23 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 023/116] ccextractor: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ccextractor/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/ccextractor/template b/srcpkgs/ccextractor/template
index 9abcd82852b2..6eccad5885af 100644
--- a/srcpkgs/ccextractor/template
+++ b/srcpkgs/ccextractor/template
@@ -1,12 +1,12 @@
 # Template file for 'ccextractor'
 pkgname=ccextractor
 version=0.93
-revision=1
+revision=2
 build_wrksrc="linux"
 build_style=gnu-configure
 configure_args="--enable-ocr --enable-hardsubx"
 hostmakedepends="automake pkg-config"
-makedepends="leptonica-devel tesseract-ocr-devel ffmpeg-devel"
+makedepends="leptonica-devel tesseract-ocr-devel ffmpeg4-devel"
 short_desc="Extract subtitles from video streams"
 maintainer="newbluemoon <blaumolch@mailbox.org>"
 license="GPL-2.0-or-later"

From 962d52f3a3fb40f84bbd5d87ea12c02ab2b44a6c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 024/116] chromaprint: revbump for ffmpeg-6.0

---
 srcpkgs/chromaprint/patches/ffmpeg5.patch | 569 ++++++++++++++++++++++
 srcpkgs/chromaprint/template              |   2 +-
 2 files changed, 570 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromaprint/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromaprint/patches/ffmpeg5.patch b/srcpkgs/chromaprint/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..a9fd307a23c8
--- /dev/null
+++ b/srcpkgs/chromaprint/patches/ffmpeg5.patch
@@ -0,0 +1,569 @@
+From 8ccad6937177b1b92e40ab8f4447ea27bac009a7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= <lalinsky@gmail.com>
+Date: Fri, 4 Nov 2022 21:47:38 +0100
+Subject: [PATCH] Use FFmpeg 5.x (#120)
+
+* Use FFmpeg 5.1.2 for CI builds
+
+* Build on Ubuntu 20.04
+
+* Upgrade code to FFmpeg 5.x APIs
+
+* Only set FFmpeg include dirs if building tools
+
+* No longer needed
+
+* Use ubuntu 20.04
+---
+ .github/workflows/build.yml                   |   6 +-
+ CMakeLists.txt                                |  16 --
+ package/build.sh                              |   4 +-
+ src/audio/ffmpeg_audio_processor.h            |   2 -
+ src/audio/ffmpeg_audio_processor_avresample.h |  72 -------
+ src/audio/ffmpeg_audio_processor_swresample.h |  18 +-
+ src/audio/ffmpeg_audio_reader.h               | 197 +++++++++---------
+ tests/CMakeLists.txt                          |   6 +
+ 8 files changed, 122 insertions(+), 199 deletions(-)
+ delete mode 100644 src/audio/ffmpeg_audio_processor_avresample.h
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index f8d6a32..4da2405 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -84,9 +84,6 @@ find_package(FFmpeg)
+ if(FFMPEG_LIBRARIES)
+ 	cmake_push_check_state(RESET)
+ 	set(CMAKE_REQUIRED_LIBRARIES ${FFMPEG_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -lm)
+-	check_function_exists(av_packet_unref HAVE_AV_PACKET_UNREF)
+-	check_function_exists(av_frame_alloc HAVE_AV_FRAME_ALLOC)
+-	check_function_exists(av_frame_free HAVE_AV_FRAME_FREE)
+ 	cmake_pop_check_state()
+ endif()
+
+@@ -163,14 +160,11 @@ message(STATUS "Using ${FFT_LIB} for FFT calculations")
+ if(NOT AUDIO_PROCESSOR_LIB)
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+ 		set(AUDIO_PROCESSOR_LIB "swresample")
+-	elseif(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(AUDIO_PROCESSOR_LIB "avresample")
+ 	endif()
+ endif()
+
+ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE OFF)
+ 		set(USE_SWRESAMPLE ON)
+ 		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBSWRESAMPLE_LIBRARIES})
+ 		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBSWRESAMPLE_INCLUDE_DIRS})
+@@ -178,16 +172,6 @@ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+ 	endif()
+ 	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+-elseif(AUDIO_PROCESSOR_LIB STREQUAL "avresample")
+-	if(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE ON)
+-		set(USE_SWRESAMPLE OFF)
+-		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBAVRESAMPLE_LIBRARIES})
+-		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBAVRESAMPLE_INCLUDE_DIRS})
+-	else()
+-		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+-	endif()
+-	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+ else()
+ 	message(STATUS "Building without audio conversion support, please install FFmpeg with libswresample")
+ endif()
+diff --git a/package/build.sh b/package/build.sh
+index da631ae..b41d36e 100755
+--- a/package/build.sh
++++ b/package/build.sh
+@@ -7,8 +7,8 @@ set -eux
+
+ BASE_DIR=$(cd $(dirname $0)/.. && pwd)
+
+-FFMPEG_VERSION=4.4.1
+-FFMPEG_BUILD_TAG=v4.4.1-1
++FFMPEG_VERSION=5.1.2
++FFMPEG_BUILD_TAG=v${FFMPEG_VERSION}-1
+
+ TMP_BUILD_DIR=$BASE_DIR/$(mktemp -d build.XXXXXXXX)
+ trap 'rm -rf $TMP_BUILD_DIR' EXIT
+diff --git a/src/audio/ffmpeg_audio_processor.h b/src/audio/ffmpeg_audio_processor.h
+index 7628fc7..39f4f6d 100644
+--- a/src/audio/ffmpeg_audio_processor.h
++++ b/src/audio/ffmpeg_audio_processor.h
+@@ -10,8 +10,6 @@
+
+ #if defined(USE_SWRESAMPLE)
+ #include "audio/ffmpeg_audio_processor_swresample.h"
+-#elif defined(USE_AVRESAMPLE)
+-#include "audio/ffmpeg_audio_processor_avresample.h"
+ #else
+ #error "no audio processing library"
+ #endif
+diff --git a/src/audio/ffmpeg_audio_processor_avresample.h b/src/audio/ffmpeg_audio_processor_avresample.h
+deleted file mode 100644
+index bd85f92..0000000
+--- a/src/audio/ffmpeg_audio_processor_avresample.h
++++ /dev/null
+@@ -1,72 +0,0 @@
+-// Copyright (C) 2016  Lukas Lalinsky
+-// Distributed under the MIT license, see the LICENSE file for details.
+-
+-#ifndef CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-#define CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-
+-extern "C" {
+-#include <libavresample/avresample.h>
+-}
+-
+-namespace chromaprint {
+-
+-class FFmpegAudioProcessor {
+-public:
+-	FFmpegAudioProcessor() {
+-		m_resample_ctx = avresample_alloc_context();
+-	}
+-
+-	~FFmpegAudioProcessor() {
+-		avresample_free(&m_resample_ctx);
+-	}
+-
+-	void SetCompatibleMode() {
+-		av_opt_set_int(m_resample_ctx, "filter_size", 16, 0);
+-		av_opt_set_int(m_resample_ctx, "phase_shift", 8, 0);
+-		av_opt_set_int(m_resample_ctx, "linear_interp", 1, 0);
+-		av_opt_set_double(m_resample_ctx, "cutoff", 0.8, 0);
+-	}
+-
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "in_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_rate", sample_rate, 0);
+-	}
+-
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "out_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_rate, 0);
+-	}
+-
+-	int Init() {
+-		return avresample_open(m_resample_ctx);
+-	}
+-
+-	int Convert(uint8_t **out, int out_count, const uint8_t **in, int in_count) {
+-		return avresample_convert(m_resample_ctx, out, 0, out_count, (uint8_t **) in, 0, in_count);
+-	}
+-
+-	int Flush(uint8_t **out, int out_count) {
+-		return avresample_read(m_resample_ctx, out, out_count);
+-	}
+-
+-private:
+-	AVAudioResampleContext *m_resample_ctx = nullptr;
+-};
+-
+-}; // namespace chromaprint
+-
+-#endif
+diff --git a/src/audio/ffmpeg_audio_processor_swresample.h b/src/audio/ffmpeg_audio_processor_swresample.h
+index b86266b..b1d4bea 100644
+--- a/src/audio/ffmpeg_audio_processor_swresample.h
++++ b/src/audio/ffmpeg_audio_processor_swresample.h
+@@ -28,30 +28,28 @@ public:
+ 		av_opt_set_double(m_swr_ctx, "cutoff", 0.8, 0);
+ 	}
+
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "icl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "ich", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetInputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "in_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "isf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "in_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "isr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "in_sample_rate", sample_rate, 0);
+ 	}
+
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "ocl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "och", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetOutputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "out_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "osf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "out_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "osr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "out_sample_rate", sample_rate, 0);
+ 	}
+
+ 	int Init() {
+diff --git a/src/audio/ffmpeg_audio_reader.h b/src/audio/ffmpeg_audio_reader.h
+index 5550164..1c6b346 100644
+--- a/src/audio/ffmpeg_audio_reader.h
++++ b/src/audio/ffmpeg_audio_reader.h
+@@ -62,7 +62,7 @@ public:
+ 	bool Read(const int16_t **data, size_t *size);
+
+ 	bool IsOpen() const { return m_opened; }
+-	bool IsFinished() const { return m_finished && !m_got_frame; }
++	bool IsFinished() const { return !m_has_more_packets && !m_has_more_frames; }
+
+ 	std::string GetError() const { return m_error; }
+ 	int GetErrorCode() const { return m_error_code; }
+@@ -74,20 +74,19 @@ private:
+ 	uint8_t *m_convert_buffer[1] = { nullptr };
+ 	int m_convert_buffer_nb_samples = 0;
+
+-	AVInputFormat *m_input_fmt = nullptr;
++	const AVInputFormat *m_input_fmt = nullptr;
+ 	AVDictionary *m_input_opts = nullptr;
+
+ 	AVFormatContext *m_format_ctx = nullptr;
+ 	AVCodecContext *m_codec_ctx = nullptr;
+-	AVFrame *m_frame = nullptr;
+ 	int m_stream_index = -1;
+ 	std::string m_error;
+ 	int m_error_code = 0;
+-	bool m_finished = false;
+ 	bool m_opened = false;
+-	int m_got_frame = 0;
+-	AVPacket m_packet;
+-	AVPacket m_packet0;
++	bool m_has_more_packets = true;
++	bool m_has_more_frames = true;
++	AVPacket *m_packet = nullptr;
++	AVFrame *m_frame = nullptr;
+
+ 	int m_output_sample_rate = 0;
+ 	int m_output_channels = 0;
+@@ -98,19 +97,12 @@ private:
+
+ inline FFmpegAudioReader::FFmpegAudioReader() {
+ 	av_log_set_level(AV_LOG_QUIET);
+-
+-	av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
+ }
+
+ inline FFmpegAudioReader::~FFmpegAudioReader() {
+ 	Close();
+ 	av_dict_free(&m_input_opts);
+ 	av_freep(&m_convert_buffer[0]);
+-	av_packet_unref(&m_packet0);
+ }
+
+ inline bool FFmpegAudioReader::SetInputFormat(const char *name) {
+@@ -135,11 +127,10 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ 	Close();
+
+-    av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
++	m_packet = av_packet_alloc();
++	if (!m_packet) {
++		return false;
++	}
+
+ 	ret = avformat_open_input(&m_format_ctx, file_name.c_str(), m_input_fmt, &m_input_opts);
+ 	if (ret < 0) {
+@@ -153,26 +144,31 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		return false;
+ 	}
+
+-	AVCodec *codec;
++	const AVCodec *codec;
+ 	ret = av_find_best_stream(m_format_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &codec, 0);
+ 	if (ret < 0) {
+ 		SetError("Could not find any audio stream in the file", ret);
+ 		return false;
+ 	}
+ 	m_stream_index = ret;
++	auto stream = m_format_ctx->streams[m_stream_index];
+
+-	m_codec_ctx = m_format_ctx->streams[m_stream_index]->codec;
++	m_codec_ctx = avcodec_alloc_context3(codec);
+ 	m_codec_ctx->request_sample_fmt = AV_SAMPLE_FMT_S16;
+
++	ret = avcodec_parameters_to_context(m_codec_ctx, stream->codecpar);
++	if (ret < 0) {
++		SetError("Could not copy the stream parameters", ret);
++		return false;
++	}
++
+ 	ret = avcodec_open2(m_codec_ctx, codec, nullptr);
+ 	if (ret < 0) {
+ 		SetError("Could not open the codec", ret);
+ 		return false;
+ 	}
+
+-	if (!m_codec_ctx->channel_layout) {
+-		m_codec_ctx->channel_layout = av_get_default_channel_layout(m_codec_ctx->channels);
+-	}
++	av_dump_format(m_format_ctx, 0, "foo", 0);
+
+ 	m_frame = av_frame_alloc();
+ 	if (!m_frame) {
+@@ -183,19 +179,23 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		m_output_sample_rate = m_codec_ctx->sample_rate;
+ 	}
+
+-	if (!m_output_channels) {
+-		m_output_channels = m_codec_ctx->channels;
++	AVChannelLayout output_channel_layout;
++	if (m_output_channels) {
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
++	} else {
++		m_output_channels = m_codec_ctx->ch_layout.nb_channels;
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
+ 	}
+
+-	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
++	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->ch_layout.nb_channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
+ 		m_converter.reset(new FFmpegAudioProcessor());
+ 		m_converter->SetCompatibleMode();
+ 		m_converter->SetInputSampleFormat(m_codec_ctx->sample_fmt);
+ 		m_converter->SetInputSampleRate(m_codec_ctx->sample_rate);
+-		m_converter->SetInputChannelLayout(m_codec_ctx->channel_layout);
++		m_converter->SetInputChannelLayout(&(m_codec_ctx->ch_layout));
+ 		m_converter->SetOutputSampleFormat(AV_SAMPLE_FMT_S16);
+ 		m_converter->SetOutputSampleRate(m_output_sample_rate);
+-		m_converter->SetOutputChannelLayout(av_get_default_channel_layout(m_output_channels));
++		m_converter->SetOutputChannelLayout(&output_channel_layout);
+ 		auto ret = m_converter->Init();
+ 		if (ret != 0) {
+ 			SetError("Could not create an audio converter instance", ret);
+@@ -203,10 +203,11 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		}
+ 	}
+
++	av_channel_layout_uninit(&output_channel_layout);
++
+ 	m_opened = true;
+-	m_finished = false;
+-	m_got_frame = 0;
+-	m_nb_packets = 0;
++	m_has_more_packets = true;
++	m_has_more_frames = true;
+ 	m_decode_error = 0;
+
+ 	return true;
+@@ -214,6 +215,7 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ inline void FFmpegAudioReader::Close() {
+ 	av_frame_free(&m_frame);
++	av_packet_free(&m_packet);
+
+ 	m_stream_index = -1;
+
+@@ -252,91 +254,98 @@ inline bool FFmpegAudioReader::Read(const int16_t **data, size_t *size) {
+ 		return false;
+ 	}
+
++	*data = nullptr;
++	*size = 0;
++
+ 	int ret;
++	bool needs_packet = false;
+ 	while (true) {
+-		while (m_packet.size <= 0) {
+-			av_packet_unref(&m_packet0);
+-			av_init_packet(&m_packet);
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			ret = av_read_frame(m_format_ctx, &m_packet);
++		while (needs_packet && m_packet->size == 0) {
++			ret = av_read_frame(m_format_ctx, m_packet);
+ 			if (ret < 0) {
+ 				if (ret == AVERROR_EOF) {
+-					m_finished = true;
++					needs_packet = false;
++					m_has_more_packets = false;
+ 					break;
+-				} else {
++				}
++				SetError("Error reading from the audio source", ret);
++				return false;
++			}
++			if (m_packet->stream_index == m_stream_index) {
++				needs_packet = false;
++			} else {
++				av_packet_unref(m_packet);
++			}
++		}
++
++		if (m_packet->size != 0) {
++			ret = avcodec_send_packet(m_codec_ctx, m_packet);
++			if (ret < 0) {
++				if (ret != AVERROR(EAGAIN)) {
+ 					SetError("Error reading from the audio source", ret);
+ 					return false;
+ 				}
+-			}
+-			m_packet0 = m_packet;
+-			if (m_packet.stream_index != m_stream_index) {
+-				m_packet.data = nullptr;
+-				m_packet.size = 0;
+ 			} else {
+-				m_nb_packets++;
++				av_packet_unref(m_packet);
+ 			}
+ 		}
+
+-		ret = avcodec_decode_audio4(m_codec_ctx, m_frame, &m_got_frame, &m_packet);
++		ret = avcodec_receive_frame(m_codec_ctx, m_frame);
+ 		if (ret < 0) {
+-			if (m_decode_error) {
+-				SetError("Error decoding audio frame", m_decode_error);
+-				return false;
++			if (ret == AVERROR_EOF) {
++				m_has_more_frames = false;
++			} else if (ret == AVERROR(EAGAIN)) {
++				if (m_has_more_packets) {
++					needs_packet = true;
++					continue;
++				} else {
++					m_has_more_frames = false;
++				}
+ 			}
+-			m_decode_error = ret;
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			continue;
++			SetError("Error decoding the audio source", ret);
++			return false;
+ 		}
+
+-		break;
+-	}
+-
+-	m_decode_error = 0;
+-
+-	const int decoded = std::min(ret, m_packet.size);
+-	m_packet.data += decoded;
+-	m_packet.size -= decoded;
+-
+-	if (m_got_frame) {
+-		if (m_converter) {
+-			if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
+-				int linsize;
+-				av_freep(&m_convert_buffer[0]);
+-				m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
+-				ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
+-				if (ret < 0) {
+-					SetError("Couldn't allocate audio converter buffer", ret);
++		if (m_frame->nb_samples > 0) {
++			if (m_converter) {
++				if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
++					int linsize;
++					av_freep(&m_convert_buffer[0]);
++					m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
++					ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->ch_layout.nb_channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
++					if (ret < 0) {
++						SetError("Couldn't allocate audio converter buffer", ret);
++						return false;
++					}
++				}
++				auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
++				if (nb_samples < 0) {
++					SetError("Couldn't convert audio", ret);
+ 					return false;
+ 				}
+-			}
+-			auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			}
+-			*data = (const int16_t *) m_convert_buffer[0];
+-			*size = nb_samples;
+-		} else {
+-			*data = (const int16_t *) m_frame->data[0];
+-			*size = m_frame->nb_samples;
+-		}
+-	} else {
+-		if (m_finished && m_converter) {
+-			auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			} else if (nb_samples > 0) {
+-				m_got_frame = 1;
+ 				*data = (const int16_t *) m_convert_buffer[0];
+ 				*size = nb_samples;
++			} else {
++				*data = (const int16_t *) m_frame->data[0];
++				*size = m_frame->nb_samples;
++			}
++		} else {
++			if (m_converter) {
++				if (IsFinished()) {
++					auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
++					if (nb_samples < 0) {
++						SetError("Couldn't convert audio", ret);
++						return false;
++					} else if (nb_samples > 0) {
++						*data = (const int16_t *) m_convert_buffer[0];
++						*size = nb_samples;
++					}
++				}
+ 			}
+ 		}
+-	}
+
+-	return true;
++		return true;
++	}
+ }
+
+ inline void FFmpegAudioReader::SetError(const char *message, int errnum) {
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index a2b517b..123e643 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -38,6 +38,12 @@ set(SRCS
+
+ if(BUILD_TOOLS)
+ 	set(SRCS ${SRCS} ../src/audio/ffmpeg_audio_reader_test.cpp)
++    include_directories(
++        ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}
++        ${AUDIO_PROCESSOR_INCLUDE_DIRS}
++    )
+ 	link_libraries(fpcalc_libs)
+ endif()
+
+-- 
+2.38.1
+
+
diff --git a/srcpkgs/chromaprint/template b/srcpkgs/chromaprint/template
index 7ef7838949f3..1f7bbc70a22c 100644
--- a/srcpkgs/chromaprint/template
+++ b/srcpkgs/chromaprint/template
@@ -1,7 +1,7 @@
 # Template file for 'chromaprint'
 pkgname=chromaprint
 version=1.5.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DBUILD_TOOLS=ON"
 make_check_target="check"

From 8c63923c8158977b2e9037f38d1567b9392a0f07 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 025/116] chromium: revbump for ffmpeg-6.0

---
 .../patches/chromium-93-ffmpeg-4.4.patch      | 36 --------------
 srcpkgs/chromium/patches/ffmpeg5.patch        | 47 +++++++++++++++++++
 srcpkgs/chromium/template                     |  2 +-
 3 files changed, 48 insertions(+), 37 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch
 create mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch b/srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch
deleted file mode 100644
index f0ec736f98bc..000000000000
--- a/srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch
+++ /dev/null
@@ -1,36 +0,0 @@
-diff --git a/media/filters/ffmpeg_demuxer.cc b/media/filters/ffmpeg_demuxer.cc
-index ac4713b07268..492a9a37d096 100644
---- a/media/filters/ffmpeg_demuxer.cc
-+++ b/media/filters/ffmpeg_demuxer.cc
-@@ -427,11 +427,11 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
-   scoped_refptr<DecoderBuffer> buffer;
- 
-   if (type() == DemuxerStream::TEXT) {
--    size_t id_size = 0;
-+    int id_size = 0;
-     uint8_t* id_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
- 
--    size_t settings_size = 0;
-+    int settings_size = 0;
-     uint8_t* settings_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
- 
-@@ -443,7 +443,7 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
-     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
-                                      side_data.data(), side_data.size());
-   } else {
--    size_t side_data_size = 0;
-+    int side_data_size = 0;
-     uint8_t* side_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
- 
-@@ -504,7 +504,7 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
-                                        packet->size - data_offset);
-     }
- 
--    size_t skip_samples_size = 0;
-+    int skip_samples_size = 0;
-     const uint32_t* skip_samples_ptr =
-         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
-             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..24e2da38e34c
--- /dev/null
+++ b/srcpkgs/chromium/patches/ffmpeg5.patch
@@ -0,0 +1,47 @@
+--- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
++++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
+@@ -92,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+-  if (stream->start_time != kNoFFmpegTimestamp)
++  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -1597,7 +1585,7 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+@@ -1618,7 +1606,7 @@
+     if (stream->type() != DemuxerStream::VIDEO)
+       continue;
+ 
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+ 
+     if (!stream->IsEnabled())
diff --git a/srcpkgs/chromium/template b/srcpkgs/chromium/template
index b4a39dfd3815..c29453cd1f50 100644
--- a/srcpkgs/chromium/template
+++ b/srcpkgs/chromium/template
@@ -2,7 +2,7 @@
 pkgname=chromium
 # See https://chromiumdash.appspot.com/releases?platform=Linux for the latest version
 version=114.0.5735.106
-revision=1
+revision=2
 archs="i686* x86_64* aarch64* armv7l*"
 hostmakedepends="
  $(vopt_if clang "clang lld llvm15")

From be8e39afdd58ba0d10a9de59c9290de9b508df55 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 026/116] cmus: revbump for ffmpeg-6.0

---
 srcpkgs/cmus/patches/ffmpeg6.patch | 12 ++++++++++++
 srcpkgs/cmus/template              |  2 +-
 2 files changed, 13 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/cmus/patches/ffmpeg6.patch

diff --git a/srcpkgs/cmus/patches/ffmpeg6.patch b/srcpkgs/cmus/patches/ffmpeg6.patch
new file mode 100644
index 000000000000..ffa95ab81110
--- /dev/null
+++ b/srcpkgs/cmus/patches/ffmpeg6.patch
@@ -0,0 +1,12 @@
+--- a/ip/ffmpeg.c
++++ b/ip/ffmpeg.c
+@@ -202,9 +202,6 @@ static int ffmpeg_open(struct input_plugin_data *ip_data)
+ 			break;
+ 		}
+ 
+-		if (codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+-			cc->flags |= AV_CODEC_FLAG_TRUNCATED;
+-
+ 		if (avcodec_open2(cc, codec, NULL) < 0) {
+ 			d_print("could not open codec: %d, %s\n", cc->codec_id, avcodec_get_name(cc->codec_id));
+ 			err = -IP_ERROR_UNSUPPORTED_FILE_TYPE;
diff --git a/srcpkgs/cmus/template b/srcpkgs/cmus/template
index 0fcb424ce336..05b77d0fecae 100644
--- a/srcpkgs/cmus/template
+++ b/srcpkgs/cmus/template
@@ -1,7 +1,7 @@
 # Template file for 'cmus'
 pkgname=cmus
 version=2.10.0
-revision=1
+revision=2
 build_style=configure
 configure_args="prefix=/usr LD=$CC"
 hostmakedepends="pkg-config"

From 72a9488894d4f275daa35b382e9e9174d6e540c0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 027/116] cyanrip: revbump for ffmpeg-6.0

---
 srcpkgs/cyanrip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cyanrip/template b/srcpkgs/cyanrip/template
index 9796e3461601..5db30e020d17 100644
--- a/srcpkgs/cyanrip/template
+++ b/srcpkgs/cyanrip/template
@@ -1,7 +1,7 @@
 # Template file for 'cyanrip'
 pkgname=cyanrip
 version=0.9.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config"
 makedepends="ffmpeg-devel libcdio-devel libcdio-paranoia-devel libcurl-devel libmusicbrainz5-devel"

From 6dc22cfa6a1d0082366b286b1a4ae0bad9da201d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 028/116] deadbeef: revbump for ffmpeg4-4.4.3

---
 srcpkgs/deadbeef/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/deadbeef/template b/srcpkgs/deadbeef/template
index b664bb1b9bd9..165b3c7b9cad 100644
--- a/srcpkgs/deadbeef/template
+++ b/srcpkgs/deadbeef/template
@@ -1,14 +1,14 @@
 # Template file for 'deadbeef'
 pkgname=deadbeef
 version=1.8.8
-revision=1
+revision=2
 create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-oss --disable-lfm --disable-notify --disable-gtk2"
 hostmakedepends="automake libtool gettext gettext-devel intltool pkg-config
  yasm clang glib-devel"
 makedepends="
- alsa-lib-devel dbus-devel faad2-devel ffmpeg-devel gtk+3-devel imlib2-devel
+ alsa-lib-devel dbus-devel faad2-devel ffmpeg4-devel gtk+3-devel imlib2-devel
  jansson-devel libcddb-devel libcdio-devel libcurl-devel libflac-devel
  libmad-devel libpng-devel libsamplerate-devel libsndfile-devel libvorbis-devel
  libzip-devel mpg123-devel opusfile-devel pulseaudio-devel wavpack-devel"

From 0087f52c285eb97ac9c2df74cdbdc2e3e506d24a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 029/116] dolphin-emu: revbump for ffmpeg-6.0

---
 srcpkgs/dolphin-emu/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/dolphin-emu/template b/srcpkgs/dolphin-emu/template
index 7ea197ceb2a8..7aeb0a5b645e 100644
--- a/srcpkgs/dolphin-emu/template
+++ b/srcpkgs/dolphin-emu/template
@@ -1,7 +1,7 @@
 # Template file for 'dolphin-emu'
 pkgname=dolphin-emu
 version=5.0.16101
-revision=1
+revision=2
 _dolphin_commit=8ecfa537a242de74d2e372e30d9d79b14584b2fb
 _mgba_commit=40d4c430fc36caeb7ea32fd39624947ed487d2f2
 #Version/hash pair can be found at https://dolphin-emu.org/download/

From 07e905b6546aa105a59eee7163f2e33d40fd79e8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 030/116] droidcam-obs-plugin: revbump for ffmpeg-6.0

---
 srcpkgs/droidcam-obs-plugin/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam-obs-plugin/template b/srcpkgs/droidcam-obs-plugin/template
index fc9c9bf6b9d5..fb0480754df4 100644
--- a/srcpkgs/droidcam-obs-plugin/template
+++ b/srcpkgs/droidcam-obs-plugin/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam-obs-plugin'
 pkgname=droidcam-obs-plugin
 version=2.0.1
-revision=1
+revision=2
 build_style=gnu-makefile
 make_use_env=yes
 make_build_args="ALLOW_STATIC=no"

From 297fae5b548f7a590649916b0ad416781aed2ad6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 031/116] droidcam: revbump for ffmpeg-6.0

---
 srcpkgs/droidcam/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam/template b/srcpkgs/droidcam/template
index 1c3f1b8b1fc6..32a9220b79a4 100644
--- a/srcpkgs/droidcam/template
+++ b/srcpkgs/droidcam/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam'
 pkgname=droidcam
 version=1.8.2
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="USBMUXD=-lusbmuxd-2.0 JPEG=-lturbojpeg"
 hostmakedepends="pkg-config"

From c469bb015af37f0817b4d01a290bf8825994b272 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 032/116] ffmpegthumbnailer: revbump for ffmpeg-6.0

---
 .../ffmpegthumbnailer/patches/ffmpeg6.patch   | 202 ++++++++++++++++++
 srcpkgs/ffmpegthumbnailer/template            |   6 +-
 2 files changed, 205 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch

diff --git a/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
new file mode 100644
index 000000000000..363ff35a2841
--- /dev/null
+++ b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
@@ -0,0 +1,202 @@
+--- a/libffmpegthumbnailer/moviedecoder.cpp	2017-11-21 14:06:57.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.cpp	2023-05-05 13:14:47.946560668 -0400
+@@ -41,11 +41,6 @@
+ namespace ffmpegthumbnailer
+ {
+ 
+-struct SilenceLogLevel
+-{
+-    SilenceLogLevel() { av_log_set_level(AV_LOG_QUIET); }
+-};
+-
+ MovieDecoder::MovieDecoder(AVFormatContext* pavContext)
+ : m_VideoStream(-1)
+ , m_pFormatContext(pavContext)
+@@ -70,8 +65,6 @@
+ 
+ void MovieDecoder::initialize(const string& filename, bool preferEmbeddedMetadata)
+ {
+-    av_register_all();
+-    avcodec_register_all();
+     avformat_network_init();
+ 
+     string inputFile = filename == "-" ? "pipe:" : filename;
+@@ -97,8 +90,7 @@
+ {
+     if (m_pVideoCodecContext)
+     {
+-        avcodec_close(m_pVideoCodecContext);
+-        m_pVideoCodecContext = nullptr;
++        avcodec_free_context(&m_pVideoCodecContext);
+     }
+ 
+     if ((!m_FormatContextWasGiven) && m_pFormatContext)
+@@ -152,10 +144,10 @@
+     for (unsigned int i = 0; i < m_pFormatContext->nb_streams; ++i)
+     {
+         AVStream *stream = m_pFormatContext->streams[i];
+-        auto ctx = m_pFormatContext->streams[i]->codec;
+-        if (ctx->codec_type == AVMEDIA_TYPE_VIDEO)
++        auto par = m_pFormatContext->streams[i]->codecpar;
++        if (par->codec_type == AVMEDIA_TYPE_VIDEO)
+         {
+-            if (!preferEmbeddedMetadata || !isStillImageCodec(ctx->codec_id))
++            if (!preferEmbeddedMetadata || !isStillImageCodec(par->codec_id))
+             {
+                 videoStreams.push_back(i);
+                 continue;
+@@ -203,8 +195,7 @@
+     }
+ 
+     m_pVideoStream = m_pFormatContext->streams[m_VideoStream];
+-    m_pVideoCodecContext = m_pVideoStream->codec;
+-    m_pVideoCodec = avcodec_find_decoder(m_pVideoCodecContext->codec_id);
++    m_pVideoCodec = avcodec_find_decoder(m_pVideoStream->codecpar->codec_id);
+ 
+     if (m_pVideoCodec == nullptr)
+     {
+@@ -214,6 +205,20 @@
+         throw logic_error("Video Codec not found");
+     }
+ 
++    m_pVideoCodecContext = avcodec_alloc_context3(m_pVideoCodec);
++
++    if (m_pVideoCodecContext == nullptr)
++    {
++        destroy();
++        throw logic_error("Could not allocate video codec context");
++    }
++
++    if (avcodec_parameters_to_context(m_pVideoCodecContext, m_pVideoStream->codecpar) < 0)
++    {
++        destroy();
++        throw logic_error("Could not configure video codec context");
++    }
++
+     m_pVideoCodecContext->workaround_bugs = 1;
+ 
+     if (avcodec_open2(m_pVideoCodecContext, m_pVideoCodec, nullptr) < 0)
+@@ -386,13 +391,6 @@
+ 
+ void MovieDecoder::initializeFilterGraph(const AVRational& timeBase, const std::string& size, bool maintainAspectRatio)
+ {
+-    static const AVPixelFormat pixelFormats[] = { AV_PIX_FMT_RGB24, AV_PIX_FMT_NONE };
+-
+-    auto del = [] (AVBufferSinkParams* p) { av_freep(p); };
+-    std::unique_ptr<AVBufferSinkParams, decltype(del)> buffersinkParams(av_buffersink_params_alloc(), del);
+-
+-    avfilter_register_all();
+-
+     m_pFilterGraph = avfilter_graph_alloc();
+     assert(m_pFilterGraph);
+ 
+@@ -404,10 +402,8 @@
+ 
+     checkRc(avfilter_graph_create_filter(&m_pFilterSource, avfilter_get_by_name("buffer"), "thumb_buffer", ss.str().c_str(), nullptr, m_pFilterGraph),
+             "Failed to create filter source");
+-    buffersinkParams->pixel_fmts = pixelFormats;
+-    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, buffersinkParams.get(), m_pFilterGraph),
++    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, nullptr, m_pFilterGraph),
+             "Failed to create filter sink");
+-    buffersinkParams.release();
+ 
+     AVFilterContext* yadifFilter = nullptr;
+     if (m_pFrame->interlaced_frame != 0)
+@@ -500,15 +496,15 @@
+     }
+ 
+     checkRc(av_seek_frame(m_pFormatContext, -1, timestamp, 0), "Seeking in video failed");
+-    avcodec_flush_buffers(m_pFormatContext->streams[m_VideoStream]->codec);
++    avcodec_flush_buffers(m_pVideoCodecContext);
+ 
+     int keyFrameAttempts = 0;
+-    bool gotFrame = 0;
++    bool gotFrame;
+ 
+     do
+     {
+         int count = 0;
+-        gotFrame = 0;
++        gotFrame = false;
+ 
+         while (!gotFrame && count < 20)
+         {
+@@ -552,17 +548,33 @@
+         return false;
+     }
+ 
+-    av_frame_unref(m_pFrame);
+-
+-    int frameFinished;
++    int rc = avcodec_send_packet(m_pVideoCodecContext, m_pPacket);
++    if(rc == AVERROR(EAGAIN))
++    {
++        rc = 0;
++    }
+ 
+-    int bytesDecoded = avcodec_decode_video2(m_pVideoCodecContext, m_pFrame, &frameFinished, m_pPacket);
+-    if (bytesDecoded < 0)
++    if(rc == AVERROR_EOF)
++    {
++        return false;
++    }
++    else if(rc < 0)
+     {
+-        throw logic_error("Failed to decode video frame: bytesDecoded < 0");
++        throw logic_error("Failed to decode video frame: avcodec_send_packet() < 0");
+     }
+ 
+-    return frameFinished > 0;
++    rc = avcodec_receive_frame(m_pVideoCodecContext, m_pFrame);
++    switch(rc)
++    {
++        case 0:
++            return true;
++
++        case AVERROR(EAGAIN):
++            return false;
++
++        default:
++            throw logic_error("Failed to decode video frame: avcodec_receive_frame() < 0");
++    }
+ }
+ 
+ bool MovieDecoder::getVideoPacket()
+@@ -570,8 +582,6 @@
+     bool framesAvailable = true;
+     bool frameDecoded = false;
+ 
+-    int attempts = 0;
+-
+     if (m_pPacket)
+     {
+         av_packet_unref(m_pPacket);
+@@ -580,6 +590,7 @@
+ 
+     m_pPacket = new AVPacket();
+ 
++
+     while (framesAvailable && !frameDecoded)
+     {
+         framesAvailable = av_read_frame(m_pFormatContext, m_pPacket) >= 0;
+@@ -644,7 +655,7 @@
+ 
+ int32_t MovieDecoder::getStreamRotation()
+ {
+-    int32_t* matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
++    auto matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
+     if (matrix)
+     {
+         auto angle = lround(av_display_rotation_get(matrix));
+
+--- a/libffmpegthumbnailer/moviedecoder.h	2017-11-12 04:23:38.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.h	2023-05-05 13:26:07.095529911 -0400
+@@ -78,7 +78,7 @@
+     int                     m_VideoStream;
+     AVFormatContext*        m_pFormatContext;
+     AVCodecContext*         m_pVideoCodecContext;
+-    AVCodec*                m_pVideoCodec;
++    const AVCodec*          m_pVideoCodec;
+     AVFilterGraph*          m_pFilterGraph;
+     AVFilterContext*        m_pFilterSource;
+     AVFilterContext*        m_pFilterSink;
diff --git a/srcpkgs/ffmpegthumbnailer/template b/srcpkgs/ffmpegthumbnailer/template
index 039eea7622b3..35d546018d12 100644
--- a/srcpkgs/ffmpegthumbnailer/template
+++ b/srcpkgs/ffmpegthumbnailer/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbnailer'
 pkgname=ffmpegthumbnailer
 version=2.2.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libpng-devel libjpeg-turbo-devel ffmpeg-devel"
@@ -9,8 +9,8 @@ depends="ffmpeg"
 short_desc="Lightweight video thumbnailer"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
-homepage="https://github.com/dirkvdb/${pkgname}"
-distfiles="${homepage}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
+homepage="https://github.com/dirkvdb"
+distfiles="${homepage}/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
 checksum=1cb24059c38223f657b300c84dd80491b7040d4b69471c4fea69be862bc99b5b
 
 post_install() {

From 0f16ac67cc220339edeab79f939d30c262a51acb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 033/116] ffmpegthumbs: revbump for ffmpeg-6.0

---
 srcpkgs/ffmpegthumbs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ffmpegthumbs/template b/srcpkgs/ffmpegthumbs/template
index 5f0b9414dada..11b88193528f 100644
--- a/srcpkgs/ffmpegthumbs/template
+++ b/srcpkgs/ffmpegthumbs/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbs'
 pkgname=ffmpegthumbs
 version=22.12.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules kcoreaddons kconfig-devel
  pkg-config qt5-host-tools qt5-qmake gettext"

From f807a2223dc04af66790d52e257949d8f0cc4e25 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 034/116] ffms2: revbump for ffmpeg-6.0

---
 srcpkgs/ffms2/patches/ffmpeg5.patch | 424 ++++++++++++++++++++++++++++
 srcpkgs/ffms2/template              |   2 +-
 2 files changed, 425 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ffms2/patches/ffmpeg5.patch

diff --git a/srcpkgs/ffms2/patches/ffmpeg5.patch b/srcpkgs/ffms2/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..1479fabcafcb
--- /dev/null
+++ b/srcpkgs/ffms2/patches/ffmpeg5.patch
@@ -0,0 +1,424 @@
+From 45673149e9a2f5586855ad472e3059084eaa36b1 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:41:21 +0100
+Subject: [PATCH] Use auto for AVCodec
+
+The geniuses over at FFmpeg decided to constify this API, so old
+versions of the library will return AVCodec *, while new versions
+of the libary will return const AVCodec *, which, in C++, are not
+OK to convert between.
+
+Rather than use some macro hell in ffmscompat.h, we can work around
+this by using auto.
+
+Gross.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 2 +-
+ src/core/indexing.cpp    | 6 +++---
+ src/core/videosource.cpp | 2 +-
+ 3 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index e4ce97c..ac09666 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -469,7 +469,7 @@ void FFMS_AudioSource::OpenFile() {
+ 
+     LAVFOpenFile(SourceFile.c_str(), FormatContext, TrackNumber);
+ 
+-    AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
++    auto *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
+     if (Codec == nullptr)
+         throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+             "Audio codec not found");
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index e547c5a..59fb4e8 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -384,7 +384,7 @@ FFMS_TrackType FFMS_Indexer::GetTrackType(int Track) {
+ }
+ 
+ const char *FFMS_Indexer::GetTrackCodec(int Track) {
+-    AVCodec *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
++    auto *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
+     return codec ? codec->name : nullptr;
+ }
+ 
+@@ -402,7 +402,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             UseDTS);
+ 
+         if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            AVCodec *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (!VideoCodec) {
+                 FormatContext->streams[i]->discard = AVDISCARD_ALL;
+                 IndexMask.erase(i);
+@@ -433,7 +433,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 IndexMask.insert(i);
+             }
+         } else if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+-            AVCodec *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (AudioCodec == nullptr)
+                 throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_UNSUPPORTED,
+                     "Audio codec not found");
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index b889970..8956c22 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -171,7 +171,7 @@ FFMS_VideoSource::FFMS_VideoSource(const char *SourceFile, FFMS_Index &Index, in
+ 
+         LAVFOpenFile(SourceFile, FormatContext, VideoTrack);
+ 
+-        AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
++        auto *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
+         if (Codec == nullptr)
+             throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+                 "Video codec not found");
+-- 
+2.40.0
+
+From 96cbf38ea9381829a1314f432a2c60495dcefaad Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:12:41 +0100
+Subject: [PATCH] all: Update AVPacket API usage
+
+AVPackets must all be on the heap now, since it is no longer
+part of the libav* ABI.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 16 ++++++----
+ src/core/indexing.cpp    | 63 ++++++++++++++++++++++------------------
+ src/core/indexing.h      |  4 +--
+ src/core/utils.cpp       |  6 ----
+ src/core/utils.h         |  1 -
+ src/core/videosource.cpp | 30 ++++++++++---------
+ 6 files changed, 64 insertions(+), 56 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index 37cf9ae..e4ce97c 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -285,10 +285,15 @@ FFMS_AudioSource::AudioBlock *FFMS_AudioSource::CacheBlock(CacheIterator &pos) {
+ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     CurrentFrame = &Frames[PacketNumber];
+ 
+-    AVPacket Packet;
+-    if (!ReadPacket(&Packet))
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++    if (!ReadPacket(Packet)) {
++        av_packet_free(&Packet);
+         throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_UNKNOWN,
+             "ReadPacket unexpectedly failed to read a packet");
++    }
+ 
+     // ReadPacket may have changed the packet number
+     CurrentFrame = &Frames[PacketNumber];
+@@ -297,8 +302,9 @@ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     int NumberOfSamples = 0;
+     AudioBlock *CachedBlock = nullptr;
+     
+-    int Ret = avcodec_send_packet(CodecContext, &Packet);
+-    av_packet_unref(&Packet);
++    int Ret = avcodec_send_packet(CodecContext, Packet);
++    av_packet_unref(Packet);
++    av_packet_free(&Packet);
+ 
+     av_frame_unref(DecodeFrame);
+     Ret = avcodec_receive_frame(CodecContext, DecodeFrame);
+@@ -513,8 +519,6 @@ void FFMS_AudioSource::Seek() {
+ }
+ 
+ bool FFMS_AudioSource::ReadPacket(AVPacket *Packet) {
+-    InitNullPacket(*Packet);
+-
+     while (av_read_frame(FormatContext, Packet) >= 0) {
+         if (Packet->stream_index == TrackNumber) {
+             // Required because not all audio packets, especially in ogg, have a pts. Use the previous valid packet's pts instead.
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index 23fb95b..e547c5a 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -320,7 +320,7 @@ void FFMS_Indexer::CheckAudioProperties(int Track, AVCodecContext *Context) {
+     }
+ }
+ 
+-void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict,
++void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict,
+                                     int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct) {
+     if (VideoContext.Parser) {
+         uint8_t *OB;
+@@ -330,8 +330,8 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+         av_parser_parse2(VideoContext.Parser,
+             VideoContext.CodecContext,
+             &OB, &OBSize,
+-            pkt.data, pkt.size,
+-            pkt.pts, pkt.dts, pkt.pos);
++            pkt->data, pkt->size,
++            pkt->pts, pkt->dts, pkt->pos);
+ 
+         // H.264 (PAFF) and HEVC may have one field per packet, so we need to track
+         // when we have a full or half frame available, and mark one of them as
+@@ -351,15 +351,15 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+ 
+         *RepeatPict = VideoContext.Parser->repeat_pict;
+         *FrameType = VideoContext.Parser->pict_type;
+-        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt.flags & AV_PKT_FLAG_DISCARD));
++        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt->flags & AV_PKT_FLAG_DISCARD));
+     } else {
+-        *Invisible = !!(pkt.flags & AV_PKT_FLAG_DISCARD);
++        *Invisible = !!(pkt->flags & AV_PKT_FLAG_DISCARD);
+     }
+ 
+     if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP8)
+-        ParseVP8(pkt.data[0], Invisible, FrameType);
++        ParseVP8(pkt->data[0], Invisible, FrameType);
+     else if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP9)
+-        ParseVP9(pkt.data[0], Invisible, FrameType);
++        ParseVP9(pkt->data[0], Invisible, FrameType);
+ }
+ 
+ void FFMS_Indexer::Free() {
+@@ -458,32 +458,36 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+         }
+     }
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
+     std::vector<int64_t> LastValidTS(FormatContext->nb_streams, AV_NOPTS_VALUE);
+ 
+     int64_t filesize = avio_size(FormatContext->pb);
+     enum AVPictureStructure LastPicStruct = AV_PICTURE_STRUCTURE_UNKNOWN;
+-    while (av_read_frame(FormatContext, &Packet) >= 0) {
++    while (av_read_frame(FormatContext, Packet) >= 0) {
+         // Update progress
+         // FormatContext->pb can apparently be NULL when opening images.
+         if (IC && FormatContext->pb) {
+-            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate))
++            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate)) {
++                av_packet_free(&Packet);
+                 throw FFMS_Exception(FFMS_ERROR_CANCELLED, FFMS_ERROR_USER,
+                     "Cancelled by user");
++            }
+         }
+-        if (!IndexMask.count(Packet.stream_index)) {
+-            av_packet_unref(&Packet);
++        if (!IndexMask.count(Packet->stream_index)) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+-        int Track = Packet.stream_index;
++        int Track = Packet->stream_index;
+         FFMS_Track &TrackInfo = (*TrackIndices)[Track];
+-        bool KeyFrame = !!(Packet.flags & AV_PKT_FLAG_KEY);
++        bool KeyFrame = !!(Packet->flags & AV_PKT_FLAG_KEY);
+         ReadTS(Packet, LastValidTS[Track], (*TrackIndices)[Track].UseDTS);
+ 
+         if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            int64_t PTS = TrackInfo.UseDTS ? Packet.dts : Packet.pts;
++            int64_t PTS = TrackInfo.UseDTS ? Packet->dts : Packet->pts;
+             if (PTS == AV_NOPTS_VALUE) {
+                 // VPx alt-refs are output as packets which lack timestmps or durations, since
+                 // they are invisible. Currently, the timestamp mangling code in libavformat
+@@ -495,9 +499,11 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 // FFMS2 currently sorts packets by PTS, which will break decoding, otherwise.
+                 bool HasAltRefs = (FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP8 ||
+                                    FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP9);
+-                if (Packet.duration == 0 && !HasAltRefs)
++                if (Packet->duration == 0 && !HasAltRefs) {
++                    av_packet_free(&Packet);
+                     throw FFMS_Exception(FFMS_ERROR_INDEXING, FFMS_ERROR_PARSER,
+                         "Invalid packet pts, dts, and duration");
++                }
+ 
+                 if (TrackInfo.empty())
+                     PTS = 0;
+@@ -513,7 +519,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             ParseVideoPacket(AVContexts[Track], Packet, &RepeatPict, &FrameType, &Invisible, &LastPicStruct);
+ 
+             TrackInfo.AddVideoFrame(PTS, RepeatPict, KeyFrame,
+-                FrameType, Packet.pos, Invisible);
++                FrameType, Packet->pos, Invisible);
+         } else if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+             // For video seeking timestamps are used only if all packets have
+             // timestamps, while for audio they're used if any have timestamps,
+@@ -522,28 +528,29 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 TrackInfo.HasTS = true;
+ 
+             int64_t StartSample = AVContexts[Track].CurrentSample;
+-            uint32_t SampleCount = IndexAudioPacket(Track, &Packet, AVContexts[Track], *TrackIndices);
++            uint32_t SampleCount = IndexAudioPacket(Track, Packet, AVContexts[Track], *TrackIndices);
+             TrackInfo.SampleRate = AVContexts[Track].CodecContext->sample_rate;
+ 
+             TrackInfo.AddAudioFrame(LastValidTS[Track],
+-                StartSample, SampleCount, KeyFrame, Packet.pos, Packet.flags & AV_PKT_FLAG_DISCARD);
++                StartSample, SampleCount, KeyFrame, Packet->pos, Packet->flags & AV_PKT_FLAG_DISCARD);
+         }
+ 
+-        if (!(Packet.flags & AV_PKT_FLAG_DISCARD))
+-            TrackInfo.LastDuration = Packet.duration;
++        if (!(Packet->flags & AV_PKT_FLAG_DISCARD))
++            TrackInfo.LastDuration = Packet->duration;
+ 
+-        av_packet_unref(&Packet);
++        av_packet_unref(Packet);
+     }
++    av_packet_free(&Packet);
+ 
+     TrackIndices->Finalize(AVContexts, FormatContext->iformat->name);
+     return TrackIndices.release();
+ }
+ 
+-void FFMS_Indexer::ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS) {
+-    if (!UseDTS && Packet.pts != AV_NOPTS_VALUE)
+-        TS = Packet.pts;
++void FFMS_Indexer::ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS) {
++    if (!UseDTS && Packet->pts != AV_NOPTS_VALUE)
++        TS = Packet->pts;
+     if (TS == AV_NOPTS_VALUE)
+         UseDTS = true;
+-    if (UseDTS && Packet.dts != AV_NOPTS_VALUE)
+-        TS = Packet.dts;
++    if (UseDTS && Packet->dts != AV_NOPTS_VALUE)
++        TS = Packet->dts;
+ }
+diff --git a/src/core/indexing.h b/src/core/indexing.h
+index 3cfc3c3..5c06868 100644
+--- a/src/core/indexing.h
++++ b/src/core/indexing.h
+@@ -80,10 +80,10 @@ private:
+     int64_t Filesize;
+     uint8_t Digest[20];
+ 
+-    void ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS);
++    void ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS);
+     void CheckAudioProperties(int Track, AVCodecContext *Context);
+     uint32_t IndexAudioPacket(int Track, AVPacket *Packet, SharedAVContext &Context, FFMS_Index &TrackIndices);
+-    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
++    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
+     void Free();
+ public:
+     FFMS_Indexer(const char *Filename);
+diff --git a/src/core/utils.cpp b/src/core/utils.cpp
+index ce67533..8a2e997 100644
+--- a/src/core/utils.cpp
++++ b/src/core/utils.cpp
+@@ -62,12 +62,6 @@ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo) {
+     }
+ }
+ 
+-void InitNullPacket(AVPacket &pkt) {
+-    av_init_packet(&pkt);
+-    pkt.data = nullptr;
+-    pkt.size = 0;
+-}
+-
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames) {
+     AP.SampleFormat = static_cast<FFMS_SampleFormat>(av_get_packed_sample_fmt(CTX->sample_fmt));
+     AP.BitsPerSample = av_get_bytes_per_sample(CTX->sample_fmt) * 8;
+diff --git a/src/core/utils.h b/src/core/utils.h
+index 9819dc7..003ab79 100644
+--- a/src/core/utils.h
++++ b/src/core/utils.h
+@@ -58,7 +58,6 @@ std::unique_ptr<T> make_unique(Args&&... args) {
+ }
+ 
+ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo);
+-void InitNullPacket(AVPacket &pkt);
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames);
+ 
+ void LAVFOpenFile(const char *SourceFile, AVFormatContext *&FormatContext, int Track);
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index 06bd161..b889970 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -673,30 +673,34 @@ void FFMS_VideoSource::DecodeNextFrame(int64_t &AStartTime, int64_t &Pos) {
+     if (HasPendingDelayedFrames())
+         return;
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
+-
+-    while (ReadFrame(&Packet) >= 0) {
+-        if (Packet.stream_index != VideoTrack) {
+-            av_packet_unref(&Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++
++    while (ReadFrame(Packet) >= 0) {
++        if (Packet->stream_index != VideoTrack) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+         if (AStartTime < 0)
+-            AStartTime = Frames.UseDTS ? Packet.dts : Packet.pts;
++            AStartTime = Frames.UseDTS ? Packet->dts : Packet->pts;
+ 
+         if (Pos < 0)
+-            Pos = Packet.pos;
++            Pos = Packet->pos;
+ 
+-        bool FrameFinished = DecodePacket(&Packet);
+-        av_packet_unref(&Packet);
+-        if (FrameFinished)
++        bool FrameFinished = DecodePacket(Packet);
++        av_packet_unref(Packet);
++        if (FrameFinished) {
++            av_packet_free(&Packet);
+             return;
++        }
+     }
+ 
+     // Flush final frames
+-    InitNullPacket(Packet);
+-    DecodePacket(&Packet);
++    DecodePacket(Packet);
++    av_packet_free(&Packet);
+ }
+ 
+ bool FFMS_VideoSource::SeekTo(int n, int SeekOffset) {
+-- 
+2.40.0
+
+From bf9e03e9e08534c024e5a744a6437c4aac160201 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:20:47 +0100
+Subject: [PATCH 2/3] configure: Remove deprecated API use
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ configure.ac | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index b35ef80bc..d19714d0f 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -102,10 +102,10 @@ CFLAGS="$_CFLAGS $FFMPEG_CFLAGS"
+
+ AC_DEFUN([TEST_FFMPEG],
+          [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+-            #include <libavcodec/avcodec.h>
++            #include <libavformat/avformat.h>
+             #include <libswscale/swscale.h>
+             ]],[[
+-                avcodec_register_all();
++                avformat_network_init();
+                 swscale_version();
+             ]])], [eval $1=yes], [eval $1=no])
+         ])
+
diff --git a/srcpkgs/ffms2/template b/srcpkgs/ffms2/template
index 68e8a0c14bce..2acfadac44b3 100644
--- a/srcpkgs/ffms2/template
+++ b/srcpkgs/ffms2/template
@@ -1,7 +1,7 @@
 # Template file for 'ffms2'
 pkgname=ffms2
 version=2.40
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-shared --disable-static"
 hostmakedepends="pkg-config autoconf automake libtool"

From c5838d25f94c29e5e6f8d01b264795071047435e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 035/116] freerdp: revbump for ffmpeg-6.0

---
 .../freerdp/patches/ffmpeg6_aa2cb9aa.patch    | 42 +++++++++++++++++++
 srcpkgs/freerdp/template                      |  2 +-
 2 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch

diff --git a/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
new file mode 100644
index 000000000000..a4324da3a882
--- /dev/null
+++ b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
@@ -0,0 +1,42 @@
+From aa2cb9aa5ff5562433598ba168a466e0752bca0e Mon Sep 17 00:00:00 2001
+From: akallabeth <akallabeth@posteo.net>
+Date: Tue, 14 Feb 2023 07:48:54 +0100
+Subject: [PATCH] Fixed #8686: Update h264 to use new FFMPEG API
+
+---
+ channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c | 2 ++
+ libfreerdp/codec/h264_ffmpeg.c            | 2 ++
+ 2 files changed, 4 insertions(+)
+
+diff --git a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+index 339462d865f..beea80b7a1e 100644
+--- a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
++++ b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+@@ -239,8 +239,10 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYP
+ 		}
+ 	}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 	if (mdecoder->codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		mdecoder->codec_context->flags |= AV_CODEC_FLAG_TRUNCATED;
++#endif
+ 
+ 	return TRUE;
+ }
+diff --git a/libfreerdp/codec/h264_ffmpeg.c b/libfreerdp/codec/h264_ffmpeg.c
+index 8a23db2473c..896a333019b 100644
+--- a/libfreerdp/codec/h264_ffmpeg.c
++++ b/libfreerdp/codec/h264_ffmpeg.c
+@@ -615,10 +615,12 @@ static BOOL libavcodec_init(H264_CONTEXT* h264)
+ 			goto EXCEPTION;
+ 		}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 		if (sys->codecDecoder->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		{
+ 			sys->codecDecoderContext->flags |= AV_CODEC_FLAG_TRUNCATED;
+ 		}
++#endif
+ 
+ #ifdef WITH_VAAPI
+ 
diff --git a/srcpkgs/freerdp/template b/srcpkgs/freerdp/template
index 25e8aa9677f0..4d51c8189902 100644
--- a/srcpkgs/freerdp/template
+++ b/srcpkgs/freerdp/template
@@ -1,7 +1,7 @@
 # Template file for 'freerdp'
 pkgname=freerdp
 version=2.10.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_ALSA=ON -DWITH_CUPS=OFF -DWITH_FFMPEG=ON
  -DWITH_GSTREAMER_0_10=OFF -DWITH_GSTREAMER_1_0=OFF -DWITH_JPEG=ON

From 3212c26d8457baef7888b82d007dc73ff4eda3bf Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 036/116] gerbera: revbump for ffmpeg-6.0

---
 srcpkgs/gerbera/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gerbera/template b/srcpkgs/gerbera/template
index ae14f35c767c..2dc0ac0ce03b 100644
--- a/srcpkgs/gerbera/template
+++ b/srcpkgs/gerbera/template
@@ -1,7 +1,7 @@
 # Template file for 'gerbera'
 pkgname=gerbera
 version=1.12.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_SYSTEMD=0 -DWITH_AVCODEC=1"
 hostmakedepends="pkg-config"

From d27e72b70f07fb1af5a6bb66cfe433083966f942 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 037/116] goldendict: revbump for ffmpeg-6.0

---
 srcpkgs/goldendict/patches/ffmpeg4.patch |  21 --
 srcpkgs/goldendict/patches/ffmpeg5.patch | 232 +++++++++++++++++++++++
 srcpkgs/goldendict/template              |   2 +-
 3 files changed, 233 insertions(+), 22 deletions(-)
 delete mode 100644 srcpkgs/goldendict/patches/ffmpeg4.patch
 create mode 100644 srcpkgs/goldendict/patches/ffmpeg5.patch

diff --git a/srcpkgs/goldendict/patches/ffmpeg4.patch b/srcpkgs/goldendict/patches/ffmpeg4.patch
deleted file mode 100644
index f045fa27f54b..000000000000
--- a/srcpkgs/goldendict/patches/ffmpeg4.patch
+++ /dev/null
@@ -1,21 +0,0 @@
---- a/ffmpegaudio.cc.orig 2018-05-09 22:16:13.480659958 +0200
-+++ b/ffmpegaudio.cc      2018-05-09 22:16:50.748322790 +0200
-@@ -143,7 +143,7 @@
-     return false;
-   }
-
--  unsigned char * avioBuffer = ( unsigned char * )av_malloc( kBufferSize + FF_INPUT_BUFFER_PADDING_SIZE );
-+  unsigned char * avioBuffer = ( unsigned char * )av_malloc( kBufferSize + AV_INPUT_BUFFER_PADDING_SIZE );
-   if ( !avioBuffer )
-   {
-     errorString = QObject::tr( "av_malloc() failed." );
-@@ -380,7 +380,7 @@
-   }
-
-   if ( !Qt4x5::AtomicInt::loadAcquire( isCancelled_ ) &&
--       codecContext_->codec->capabilities & CODEC_CAP_DELAY )
-+       codecContext_->codec->capabilities & AV_CODEC_CAP_DELAY )
-   {
-     av_init_packet( &packet );
-     int gotFrame = 0;
-
diff --git a/srcpkgs/goldendict/patches/ffmpeg5.patch b/srcpkgs/goldendict/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..7cfc98ada368
--- /dev/null
+++ b/srcpkgs/goldendict/patches/ffmpeg5.patch
@@ -0,0 +1,232 @@
+From 03bbe01b79a1f07a6780cb60f23a087104c5d77b Mon Sep 17 00:00:00 2001
+From: Abs62 <ottomann@yandex.ru>
+Date: Fri, 30 Mar 2018 22:53:24 +0300
+Subject: [PATCH] Fix warnings while compile with FFMpeg 3.4.2 (issue #978)
+
+---
+ ffmpegaudio.cc | 68 +++++++++++++++++++++++++++++++++++++++++++++-----
+ 1 file changed, 62 insertions(+), 6 deletions(-)
+
+diff --git a/ffmpegaudio.cc b/ffmpegaudio.cc
+index ed1172bdd..56e8f788e 100644
+--- a/ffmpegaudio.cc
++++ b/ffmpegaudio.cc
+@@ -91,6 +91,7 @@ struct DecoderContext
+   QByteArray audioData_;
+   QDataStream audioDataStream_;
+   AVFormatContext * formatContext_;
++  AVCodec * codec_;
+   AVCodecContext * codecContext_;
+   AVIOContext * avioContext_;
+   AVStream * audioStream_;
+@@ -114,6 +115,7 @@ DecoderContext::DecoderContext( QByteArray const & audioData, QAtomicInt & isCan
+   audioData_( audioData ),
+   audioDataStream_( audioData_ ),
+   formatContext_( NULL ),
++  codec_( NULL ),
+   codecContext_( NULL ),
+   avioContext_( NULL ),
+   audioStream_( NULL ),
+@@ -143,7 +145,11 @@ bool DecoderContext::openCodec( QString & errorString )
+     return false;
+   }
+
++#if LIBAVCODEC_VERSION_MAJOR < 56 || ( LIBAVCODEC_VERSION_MAJOR == 56 && LIBAVCODEC_VERSION_MINOR < 56 )
+   unsigned char * avioBuffer = ( unsigned char * )av_malloc( kBufferSize + FF_INPUT_BUFFER_PADDING_SIZE );
++#else
++  unsigned char * avioBuffer = ( unsigned char * )av_malloc( kBufferSize + AV_INPUT_BUFFER_PADDING_SIZE );
++#endif
+   if ( !avioBuffer )
+   {
+     errorString = QObject::tr( "av_malloc() failed." );
+@@ -186,7 +192,11 @@ bool DecoderContext::openCodec( QString & errorString )
+   // Find audio stream, use the first audio stream if available
+   for ( unsigned i = 0; i < formatContext_->nb_streams; i++ )
+   {
++#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 33 )
+     if ( formatContext_->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO )
++#else
++      if ( formatContext_->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO )
++#endif
+     {
+       audioStream_ = formatContext_->streams[i];
+       break;
+@@ -198,22 +208,38 @@ bool DecoderContext::openCodec( QString & errorString )
+     return false;
+   }
+
++#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 33 )
+   codecContext_ = audioStream_->codec;
+-  AVCodec * codec = avcodec_find_decoder( codecContext_->codec_id );
+-  if ( !codec )
++  codec_ = avcodec_find_decoder( codecContext_->codec_id );
++  if ( !codec_ )
+   {
+     errorString = QObject::tr( "Codec [id: %1] not found." ).arg( codecContext_->codec_id );
+     return false;
+   }
++#else
++  codec_ = avcodec_find_decoder( audioStream_->codecpar->codec_id );
++  if ( !codec_ )
++  {
++    errorString = QObject::tr( "Codec [id: %1] not found." ).arg( audioStream_->codecpar->codec_id );
++    return false;
++  }
++  codecContext_ = avcodec_alloc_context3( codec_ );
++  if ( !codecContext_ )
++  {
++    errorString = QObject::tr( "avcodec_alloc_context3() failed." );
++    return false;
++  }
++  avcodec_parameters_to_context( codecContext_, audioStream_->codecpar );
++#endif
+
+-  ret = avcodec_open2( codecContext_, codec, NULL );
++  ret = avcodec_open2( codecContext_, codec_, NULL );
+   if ( ret < 0 )
+   {
+     errorString = QObject::tr( "avcodec_open2() failed: %1." ).arg( avErrorString( ret ) );
+     return false;
+   }
+
+-  av_log( NULL, AV_LOG_INFO, "Codec open: %s: channels: %d, rate: %d, format: %s\n", codec->long_name,
++  av_log( NULL, AV_LOG_INFO, "Codec open: %s: channels: %d, rate: %d, format: %s\n", codec_->long_name,
+           codecContext_->channels, codecContext_->sample_rate, av_get_sample_fmt_name( codecContext_->sample_fmt ) );
+   return true;
+ }
+@@ -252,10 +278,13 @@ void DecoderContext::closeCodec()
+
+   // Closing a codec context without prior avcodec_open2() will result in
+   // a crash in ffmpeg
+-  if ( audioStream_ && audioStream_->codec && audioStream_->codec->codec )
++  if ( audioStream_ && codecContext_ && codec_ )
+   {
+     audioStream_->discard = AVDISCARD_ALL;
+-    avcodec_close( audioStream_->codec );
++    avcodec_close( codecContext_ );
++#if LIBAVCODEC_VERSION_MAJOR > 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR >= 33 )
++    avcodec_free_context( &codecContext_ );
++#endif
+   }
+
+   avformat_close_input( &formatContext_ );
+@@ -356,6 +385,7 @@ bool DecoderContext::play( QString & errorString )
+     if ( packet.stream_index == audioStream_->index )
+     {
+       AVPacket pack = packet;
++#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 37 )
+       int gotFrame = 0;
+       do
+       {
+@@ -370,6 +400,19 @@ bool DecoderContext::play( QString & errorString )
+         pack.data += len;
+       }
+       while( pack.size > 0 );
++#else
++      int ret = avcodec_send_packet( codecContext_, &pack );
++      /* read all the output frames (in general there may be any number of them) */
++      while( ret >= 0 )
++      {
++        ret = avcodec_receive_frame( codecContext_, frame);
++
++        if ( Qt4x5::AtomicInt::loadAcquire( isCancelled_ ) || ret < 0 )
++          break;
++
++        playFrame( frame );
++      }
++#endif
+     }
+     // av_free_packet() must be called after each call to av_read_frame()
+ #if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 7 )
+@@ -379,6 +422,7 @@ bool DecoderContext::play( QString & errorString )
+ #endif
+   }
+
++#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 37 )
+   if ( !Qt4x5::AtomicInt::loadAcquire( isCancelled_ ) &&
+        codecContext_->codec->capabilities & CODEC_CAP_DELAY )
+   {
+@@ -391,6 +435,18 @@ bool DecoderContext::play( QString & errorString )
+       playFrame( frame );
+     }
+   }
++#else
++  /* flush the decoder */
++  av_init_packet( &packet );
++  int ret = avcodec_send_packet(codecContext_, &packet );
++  while( ret >= 0 )
++  {
++    ret = avcodec_receive_frame(codecContext_, frame);
++    if ( Qt4x5::AtomicInt::loadAcquire( isCancelled_ ) || ret < 0 )
++      break;
++    playFrame( frame );
++  }
++#endif
+
+ #if LIBAVCODEC_VERSION_MAJOR < 54
+   av_free( frame );
+32
+srcpkgs/goldendict/patches/ffmpeg5-2.patch
+Comment on this file
+@@ -0,0 +1,32 @@
+From 966f4a8b78e6324b930e5a50f2bb930bd87e565e Mon Sep 17 00:00:00 2001
+From: Abs62 <ottomann@yandex.ru>
+Date: Fri, 27 Sep 2019 17:00:52 +0300
+Subject: [PATCH] FFmpeg player: Fix some crashes on broken files
+
+---
+ ffmpegaudio.cc | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/ffmpegaudio.cc b/ffmpegaudio.cc
+index 56e8f788e..415fc79cb 100644
+--- a/ffmpegaudio.cc
++++ b/ffmpegaudio.cc
+@@ -51,7 +51,9 @@ AudioService & AudioService::instance()
+
+ AudioService::AudioService()
+ {
++#if LIBAVFORMAT_VERSION_MAJOR < 58 || ( LIBAVFORMAT_VERSION_MAJOR == 58 && LIBAVFORMAT_VERSION_MINOR < 9 )
+   av_register_all();
++#endif
+   ao_initialize();
+ }
+
+@@ -438,6 +440,8 @@ bool DecoderContext::play( QString & errorString )
+ #else
+   /* flush the decoder */
+   av_init_packet( &packet );
++  packet.data = NULL;
++  packet.size = 0;
+   int ret = avcodec_send_packet(codecContext_, &packet );
+   while( ret >= 0 )
+   {
+25
+srcpkgs/goldendict/patches/ffmpeg5-3.patch
+Comment on this file
+@@ -0,0 +1,25 @@
+From 8acb288c9e9bdb3c6bf2e803954dd3b6ac273c05 Mon Sep 17 00:00:00 2001
+From: Liao Junxuan <mikeljx@126.com>
+Date: Sun, 20 Feb 2022 12:28:05 +0800
+Subject: [PATCH] add support for ffmpeg 5.0
+
+---
+ ffmpegaudio.cc | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/ffmpegaudio.cc b/ffmpegaudio.cc
+index d550f4a77..7948d2187 100644
+--- a/ffmpegaudio.cc
++++ b/ffmpegaudio.cc
+@@ -94,7 +94,11 @@ struct DecoderContext
+   QByteArray audioData_;
+   QDataStream audioDataStream_;
+   AVFormatContext * formatContext_;
++#if LIBAVCODEC_VERSION_MAJOR < 59
+   AVCodec * codec_;
++#else
++  const AVCodec * codec_;
++#endif
+   AVCodecContext * codecContext_;
+   AVIOContext * avioContext_;
+   AVStream * audioStream_;
diff --git a/srcpkgs/goldendict/template b/srcpkgs/goldendict/template
index 4544ae710ee6..2ca4185e538a 100644
--- a/srcpkgs/goldendict/template
+++ b/srcpkgs/goldendict/template
@@ -9,7 +9,7 @@ makedepends="tiff-devel qt5-devel libvorbis-devel zlib-devel
  libXtst-devel hunspell-devel qt5-tools-devel qt5-declarative-devel
  qt5-webkit-devel lzo-devel bzip2-devel libao-devel qt5-svg-devel
  libeb-devel qt5-x11extras-devel ffmpeg-devel liblzma-devel"
-short_desc="A feature-rich dictionary lookup program"
+short_desc="Feature-rich dictionary lookup program"
 maintainer="John <me@johnnynator.dev>"
 license="GPL-3.0-or-later"
 homepage="http://goldendict.org/"

From 410ff9417abdfe5601746e1cc9640f61443195c2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 038/116] gst-libav: revbump for ffmpeg-6.0

---
 srcpkgs/gst-libav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index e9a79dc650a5..f082bd211c65 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.20.3
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"

From 3ca229f9cbb1b82d355cfedd400042f39bc0c93c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 039/116] gst-plugins-bad1: revbump for ffmpeg-6.0

---
 srcpkgs/gst-plugins-bad1/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index f55f82fd4c77..dc9d389734e1 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-plugins-bad1'
 pkgname=gst-plugins-bad1
-version=1.20.3
-revision=3
+version=1.22.2
+revision=2
 build_helper="gir"
 build_style=meson
 configure_args="-Dpackage-origin=https://voidlinux.org -Ddoc=disabled

From dba45aa016b4106a9b4b537119a73668a5b84f3d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 040/116] gst-rtsp-server: revbump for ffmpeg-6.0

---
 srcpkgs/gst-rtsp-server/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index 33cd64ceb95e..8ceea8d34b4b 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
 version=1.20.3
-revision=2
+revision=3
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="glib-devel gst-plugins-bad1-devel gobject-introspection

From ed9ee577d0e123c846f1277b048fcc3ae5588e3c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 041/116] guvcview: update to 2.0.8.

---
 srcpkgs/guvcview/patches/fix-include.patch | 10 ++++++++++
 srcpkgs/guvcview/template                  |  5 ++---
 2 files changed, 12 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/guvcview/patches/fix-include.patch

diff --git a/srcpkgs/guvcview/patches/fix-include.patch b/srcpkgs/guvcview/patches/fix-include.patch
new file mode 100644
index 000000000000..503c2af3b78c
--- /dev/null
+++ b/srcpkgs/guvcview/patches/fix-include.patch
@@ -0,0 +1,10 @@
+--- a/guvcview/guvcview.c
++++ b/guvcview/guvcview.c
+@@ -28,6 +28,7 @@
+ #include <sys/stat.h>
+ #include <sys/resource.h>
+ #include <errno.h>
++#include <locale.h>
+ 
+ #include "gview.h"
+ #include "gviewv4l2core.h"
diff --git a/srcpkgs/guvcview/template b/srcpkgs/guvcview/template
index 345cf6006f24..86a7fd619612 100644
--- a/srcpkgs/guvcview/template
+++ b/srcpkgs/guvcview/template
@@ -1,8 +1,7 @@
 # Template file for 'guvcview'
 pkgname=guvcview
-version=2.0.7
+version=2.0.8
 revision=1
-create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-static --disable-debian-menu"
 hostmakedepends="pkg-config intltool autoconf automake libtool glib-devel"
@@ -14,7 +13,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="http://guvcview.sourceforge.net/"
 distfiles="${SOURCEFORGE_SITE}/${pkgname}/${pkgname}-src-${version}.tar.bz2"
-checksum=f47d51fbd06e44eeaa1a82f4a153c927527c90d94514197a70b2956028cc8ad4
+checksum=a21f4e448286666cf27bafef5290cc953a0a1796b752e5bbe521266dc1230c81
 
 post_patch() {
 	sed '31a#include <locale.h>' -i  guvcview/guvcview.c

From 3763ee371670e1a2c5cf111cbac598e276f6bf47 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 042/116] handbrake: update to 1.6.1

---
 .../patches/fix-missing-x265-link-flag.patch    | 11 ++++++-----
 .../handbrake/patches/libhb-vpl-include.patch   | 15 +++++++++++++++
 srcpkgs/handbrake/template                      | 17 ++++++++++-------
 3 files changed, 31 insertions(+), 12 deletions(-)
 create mode 100644 srcpkgs/handbrake/patches/libhb-vpl-include.patch

diff --git a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
index 26db03867a0c..d6bb2eda627a 100644
--- a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
+++ b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
@@ -1,14 +1,15 @@
 --- a/gtk/configure.ac
 +++ b/gtk/configure.ac
 @@ -203,7 +203,7 @@
- 
+
  AM_CONDITIONAL([MINGW], [test "x$mingw_flag" = "xyes"])
- 
--HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg"
-+HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -ldl"
+
+-HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc"
++HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc -ldl"
  HB_CPPFLAGS="$HB_CPPFLAGS $HBINC"
- 
+
  PKG_CHECK_MODULES([x264], [x264], sys_x264=yes, sys_x264=no)
+
 --- a/test/module.defs
 +++ b/test/module.defs
 @@ -69,6 +69,9 @@
diff --git a/srcpkgs/handbrake/patches/libhb-vpl-include.patch b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
new file mode 100644
index 000000000000..298f9f4ab28f
--- /dev/null
+++ b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
@@ -0,0 +1,15 @@
+--- a/libhb/module.defs	2023-01-22 11:36:49.000000000 -0500
++++ b/libhb/module.defs	2023-04-03 22:37:52.395467010 -0400
+@@ -46,11 +46,7 @@
+ LIBHB.GCC.I += $(LIBHB.build/) $(CONTRIB.build/)include
+ 
+ ifeq (1,$(FEATURE.qsv))
+-    ifeq ($(HOST.system),freebsd))
+-        LIBHB.GCC.I += $(LOCALBASE)/include/vpl
+-    else
+-        LIBHB.GCC.I += $(CONTRIB.build/)include/vpl
+-    endif
++    LIBHB.GCC.I += /usr/include/vpl
+ endif
+ 
+ ifneq (,$(filter $(HOST.system),freebsd netbsd openbsd))
diff --git a/srcpkgs/handbrake/template b/srcpkgs/handbrake/template
index ca5e4571e49c..c32cb1bfa31f 100644
--- a/srcpkgs/handbrake/template
+++ b/srcpkgs/handbrake/template
@@ -1,10 +1,10 @@
 # Template file for 'handbrake'
 pkgname=handbrake
-version=1.5.1
+version=1.6.1
 revision=1
 build_style=gnu-configure
 configure_args="--force --disable-gtk-update-checks --disable-df-fetch --harden
- $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc)"
+ $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc) $(vopt_enable qsv)"
 make_build_args="-C ${XBPS_TRIPLET}"
 make_install_args="-C ${XBPS_TRIPLET}"
 hostmakedepends="automake cmake gettext-devel glib-devel intltool libtool m4 meson nasm pkg-config python3"
@@ -12,8 +12,11 @@ makedepends="bzip2-devel ffmpeg-devel gst-plugins-base1-devel gtk+3-devel
  jansson-devel lame-devel libass-devel libbluray-devel libdav1d-devel
  libdvdnav-devel libdvdread-devel libgudev-devel libnuma-devel
  libsamplerate-devel libtheora-devel libvorbis-devel libvpx-devel libxml2-devel
- opus-devel speex-devel x264-devel x265-devel zimg-devel
+ opus-devel speex-devel x264-devel x265-devel zimg-devel libsvt-av1-devel
  $(vopt_if fdk_aac fdk-aac-devel)
+ $(vopt_if qsv libva-devel)
+ $(vopt_if qsv libdrm-devel)
+ $(vopt_if qsv onevpl-devel)
  $(vopt_if nvenc nv-codec-headers)"
 depends="desktop-file-utils gst-plugins-good1 hicolor-icon-theme"
 short_desc="Multithreaded video transcoder"
@@ -21,15 +24,15 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-2.0-only"
 homepage="https://handbrake.fr/"
 distfiles="https://github.com/HandBrake/HandBrake/releases/download/${version}/HandBrake-${version}-source.tar.bz2"
-checksum=3999fe06d5309c819799a73a968a8ec3840e7840c2b64af8f5cdb7fd8c9430f0
+checksum=94ccfe03db917a91650000c510f7fd53f844da19f19ad4b4be1b8f6bc31a8d4c
 nocross=yes
 
-build_options="fdk_aac nvenc"
+build_options="fdk_aac nvenc qsv"
 
 case "$XBPS_TARGET_MACHINE" in
 	x86_64*|i686*)
 		CFLAGS="-msse"
-		build_options_default="nvenc"
+		build_options_default="nvenc qsv"
 		;;
 esac
 
@@ -37,7 +40,7 @@ pre_configure() {
 	# use system libraries, don't download them
 	rm -rf contrib/
 	for module in fdk-aac ffmpeg libbluray libdav1d libdvdnav libdvdread nvenc \
-		x265 zimg; do
+		x265 zimg svt-av1 libvpl; do
 	    vsed -i "/MODULES += contrib\/${module}/d" make/include/main.defs
 	done
 }

From a70373f366cfaefb473ff92a2e020b14edcb0c46 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 043/116] hedgewars: revbump for ffmpeg4-4.4.3

---
 srcpkgs/hedgewars/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/hedgewars/template b/srcpkgs/hedgewars/template
index 419f29b98b44..926fe4fe3e68 100644
--- a/srcpkgs/hedgewars/template
+++ b/srcpkgs/hedgewars/template
@@ -1,13 +1,13 @@
 # Template file for 'hedgewars'
 pkgname=hedgewars
 version=1.0.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DNOSERVER=1 -DDATA_INSTALL_DIR=/usr/share/${pkgname}
  -DPHYSFS_SYSTEM=1 -DMINIMAL_FLAGS=1"
 make_cmd=make
 hostmakedepends="lua51 pkg-config qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
+makedepends="ffmpeg4-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
  SDL2_mixer-devel SDL2_net-devel SDL2_ttf-devel"
 depends="libfreeglut"
 short_desc="Funny turn-based artillery game, featuring fighting Hedgehogs!"

From 42189440ee2ae946575745013b00a66dd20c53f9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 044/116] idjc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/idjc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/idjc/template b/srcpkgs/idjc/template
index df60318b3db9..36a75baf597c 100644
--- a/srcpkgs/idjc/template
+++ b/srcpkgs/idjc/template
@@ -1,11 +1,11 @@
 # Template file for 'idjc'
 pkgname=idjc
 version=0.9.1
-revision=3
+revision=4
 build_style=gnu-configure
 hostmakedepends="pkg-config git python3 automake gettext-devel libtool"
 makedepends="libvorbis-devel libogg-devel jack-devel libsamplerate-devel
- libflac-devel libsndfile-devel mpg123-devel ffmpeg-devel speex-devel
+ libflac-devel libsndfile-devel mpg123-devel ffmpeg4-devel speex-devel
  glib-devel pixman-devel lame-devel python3-gobject-devel libshout-idjc-devel
  opus-devel twolame-devel python3-mutagen python3-devel"
 depends="python3-gobject python3-mutagen desktop-file-utils shared-mime-info python3-dbus jack"

From 7b09d9e3024100afd0a60a35b8194ede23fb651b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 045/116] kfilemetadata5: revbump for ffmpeg-6.0

---
 srcpkgs/kfilemetadata5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kfilemetadata5/template b/srcpkgs/kfilemetadata5/template
index 4b91cf19f298..a3671a38ce59 100644
--- a/srcpkgs/kfilemetadata5/template
+++ b/srcpkgs/kfilemetadata5/template
@@ -1,7 +1,7 @@
 # Template file for 'kfilemetadata5'
 pkgname=kfilemetadata5
 version=5.107.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="kcoreaddons extra-cmake-modules pkg-config qt5-host-tools qt5-qmake
  gettext kcoreaddons python3"

From c6e9505bff93aa5b56f4c27c668aa11c5580320a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 046/116] kid3: revbump for ffmpeg-6.0

---
 srcpkgs/kid3/patches/ffmpeg5.patch | 17 +++++++++++++++++
 srcpkgs/kid3/template              |  2 +-
 2 files changed, 18 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/kid3/patches/ffmpeg5.patch

diff --git a/srcpkgs/kid3/patches/ffmpeg5.patch b/srcpkgs/kid3/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..135fc50e07c9
--- /dev/null
+++ b/srcpkgs/kid3/patches/ffmpeg5.patch
@@ -0,0 +1,17 @@
+# https://aur.archlinux.org/cgit/aur.git/diff/ffmpeg5.patch?h=kid3-cli&id=12410a74906612e7efc0ec8fbce739b4a0fef7e7
+diff --git a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+index e156d424..e12b9abd 100644
+--- a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
++++ b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+@@ -232,7 +232,11 @@ private:
+   friend class Format;
+   friend class Converter;
+   AVCodecContext* m_ptr;
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 0, 0)
+   AVCodec* m_impl;
++#else
++  const AVCodec* m_impl;
++#endif
+   AVFrame* m_frame;
+   bool m_opened;
+ };
diff --git a/srcpkgs/kid3/template b/srcpkgs/kid3/template
index 456206d90e16..f32f9decb0e7 100644
--- a/srcpkgs/kid3/template
+++ b/srcpkgs/kid3/template
@@ -1,7 +1,7 @@
 # Template file for 'kid3'
 pkgname=kid3
 version=3.9.1
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DWITH_APPS='CLI;$(vopt_if KDE KDE Qt)'
  -DWITH_DOCBOOKDIR=/usr/share/xsl/docbook -DWITH_FLAC=$(vopt_if flac ON OFF)

From 4baabab6405255cdb5013f34d0aa54aa1929e84b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 047/116] kodi: revbump for ffmpeg4-4.4.3

---
 srcpkgs/kodi/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/kodi/template b/srcpkgs/kodi/template
index 8057964d78a3..6cc1874be7ba 100644
--- a/srcpkgs/kodi/template
+++ b/srcpkgs/kodi/template
@@ -1,7 +1,7 @@
 # Template file for 'kodi'
 pkgname=kodi
 version=19.4
-revision=6
+revision=7
 _codename="Matrix"
 build_style=cmake
 configure_args="-DWITH_FFMPEG=/usr -DENABLE_LDGOLD=OFF
@@ -54,7 +54,7 @@ makedepends="
  libmad-devel fontconfig-devel libXinerama-devel libsamplerate-devel libmms-devel
  enca-devel boost-devel libcurl-devel libva-devel libvdpau-devel libass-devel
  libbluetooth-devel yajl-devel libplist-devel librtmp-devel tinyxml-devel
- taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg-devel
+ taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg4-devel
  giflib-devel libxslt-devel gnutls-devel libssh-devel libmicrohttpd-devel
  libcec-devel dcadec-devel flatbuffers-devel fmt-devel lcms2-devel
  libfstrcmp-devel rapidjson libcdio-paranoia spdlog libwaylandpp-devel

From a4932ae5644f02e0eecabb54dc5b1f74e9ff1db1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 048/116] kpipewire: revbump for ffmpeg-6.0

---
 srcpkgs/kpipewire/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kpipewire/template b/srcpkgs/kpipewire/template
index 05ad025944da..7aa120e6ba94 100644
--- a/srcpkgs/kpipewire/template
+++ b/srcpkgs/kpipewire/template
@@ -1,7 +1,7 @@
 # Template file for 'kpipewire'
 pkgname=kpipewire
 version=5.27.5
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules plasma-wayland-protocols gettext
  qt5-qmake qt5-host-tools pkg-config wayland-devel kcoreaddons

From 4416565a2b487616152e9e6fc8bc78c20cc6ca75 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 049/116] libextractor: revbump for ffmpeg4-4.4.3

---
 srcpkgs/libextractor/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libextractor/template b/srcpkgs/libextractor/template
index ddd4790f93e8..1fb9ca56a96a 100644
--- a/srcpkgs/libextractor/template
+++ b/srcpkgs/libextractor/template
@@ -7,7 +7,7 @@ configure_args="--disable-static"
 hostmakedepends="pkg-config"
 makedepends="zlib-devel bzip2-devel exiv2-devel tiff-devel libpng-devel
  libjpeg-turbo-devel libvorbis-devel libflac-devel giflib-devel libmpeg2-devel
- ffmpeg-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
+ ffmpeg4-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
 short_desc="Library used to extract meta data from files"
 maintainer="Martin Riese <grauehaare@gmx.de>"
 license="GPL-3.0-or-later"

From a6f57548d2f982182620b83174f0371a738aef5a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 050/116] libopenal: revbump for ffmpeg-6.0

---
 srcpkgs/libopenal/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenal/template b/srcpkgs/libopenal/template
index 77218f9e539d..3f49ed75a1fd 100644
--- a/srcpkgs/libopenal/template
+++ b/srcpkgs/libopenal/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenal'
 pkgname=libopenal
 version=1.22.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DALSOFT_EXAMPLES=OFF"
 hostmakedepends="pkg-config"

From 6d909f4b710f7d3d18b2e34e733352f33bfe1bbd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 051/116] libopenshot: revbump for ffmpeg-6.0

---
 srcpkgs/libopenshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenshot/template b/srcpkgs/libopenshot/template
index db831f69b474..81aa0d7136d9 100644
--- a/srcpkgs/libopenshot/template
+++ b/srcpkgs/libopenshot/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenshot'
 pkgname=libopenshot
 version=0.3.0
-revision=1
+revision=2
 build_style=cmake
 # Builds fail with Ruby-2.4.1
 configure_args="-DENABLE_RUBY=OFF -DUSE_SYSTEM_JSONCPP=ON"

From 31280e2a8f98ab01a63e72a4b9f62bc04037324b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 052/116] loudgain: revbump for ffmpeg-6.0

---
 srcpkgs/loudgain/patches/ffmpeg5.patch | 11 +++++++++++
 srcpkgs/loudgain/template              |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/loudgain/patches/ffmpeg5.patch

diff --git a/srcpkgs/loudgain/patches/ffmpeg5.patch b/srcpkgs/loudgain/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..16d4510ee98f
--- /dev/null
+++ b/srcpkgs/loudgain/patches/ffmpeg5.patch
@@ -0,0 +1,11 @@
+--- a/src/scan.c	2019-09-06 11:31:19.000000000 -0400
++++ b/src/scan.c	2023-03-23 11:15:40.867968521 -0400
+@@ -69,8 +69,6 @@
+ 	 * It is now useless
+ 	 * https://github.com/FFmpeg/FFmpeg/blob/70d25268c21cbee5f08304da95be1f647c630c15/doc/APIchanges#L86
+ 	 */
+-  if (avformat_version() < AV_VERSION_INT(58,9,100))
+-    av_register_all();
+ 
+ 	av_log_set_callback(scan_av_log);
+ 
diff --git a/srcpkgs/loudgain/template b/srcpkgs/loudgain/template
index da4f2d56e94c..4d6bf29efb4f 100644
--- a/srcpkgs/loudgain/template
+++ b/srcpkgs/loudgain/template
@@ -1,7 +1,7 @@
 # Template file for 'loudgain'
 pkgname=loudgain
 version=0.6.8
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libebur128-devel taglib-devel ffmpeg-devel"

From 77ba832ffbc237050ebc6e2cdf529577e4e9091f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 053/116] mediastreamer: revbump for ffmpeg4-4.4.3

---
 srcpkgs/mediastreamer/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mediastreamer/template b/srcpkgs/mediastreamer/template
index d0e97e858e29..1bde031443a5 100644
--- a/srcpkgs/mediastreamer/template
+++ b/srcpkgs/mediastreamer/template
@@ -1,11 +1,11 @@
 # Template file for 'mediastreamer'
 pkgname=mediastreamer
 version=5.2.6
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_STRICT=0 -DENABLE_UNIT_TESTS=0"
 hostmakedepends="python3"
-makedepends="bzrtp-devel ffmpeg-devel glew-devel libXv-devel libsrtp-devel
+makedepends="bzrtp-devel ffmpeg4-devel glew-devel libXv-devel libsrtp-devel
  libupnp-devel libvpx-devel mbedtls-devel opus-devel ortp-devel pulseaudio-devel
  libtheora-devel speex-devel v4l-utils-devel bcg729-devel bcmatroska2-devel libgsm-devel"
 # zxing-cpp-devel (1.2.0 probably not compatible, check again after updaing xzing)

From ba16569021e631c12608de3859250d9e218ab3cd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 054/116] mgba: revbump for ffmpeg-6.0

---
 srcpkgs/mgba/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mgba/template b/srcpkgs/mgba/template
index ae0504311eee..d31295a0cd3d 100644
--- a/srcpkgs/mgba/template
+++ b/srcpkgs/mgba/template
@@ -1,7 +1,7 @@
 # Template file for 'mgba'
 pkgname=mgba
 version=0.10.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake desktop-file-utils"
 makedepends="SDL2-devel ffmpeg-devel libedit-devel libepoxy-devel libmagick-devel

From b8bc50342c39aad2ec682a72c3036d598dad3494 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 055/116] minidlna: revbump for ffmpeg-6.0

---
 srcpkgs/minidlna/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/minidlna/template b/srcpkgs/minidlna/template
index e8081b1cbc67..9ee9714861fd 100644
--- a/srcpkgs/minidlna/template
+++ b/srcpkgs/minidlna/template
@@ -1,7 +1,7 @@
 # Template file for 'minidlna'
 pkgname=minidlna
 version=1.3.2
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="
  --sbindir=/usr/bin

From ca9dda719ec4c709d91b1c39fed31747d6f7a3df Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 056/116] mixxx: revbump for ffmpeg-6.0

---
 srcpkgs/mixxx/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mixxx/template b/srcpkgs/mixxx/template
index 619ddca0d332..4b9ea00d3fb3 100644
--- a/srcpkgs/mixxx/template
+++ b/srcpkgs/mixxx/template
@@ -1,7 +1,7 @@
 # Template file for 'mixxx'
 pkgname=mixxx
 version=2.3.3
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="extra-cmake-modules pkg-config protobuf qt5-host-tools qt5-devel"

From d3689448ee7c7b2cb8d3e37b7a943a8b5666e14b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 057/116] mlt: revbump for ffmpeg4-4.4.3

---
 srcpkgs/mlt/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mlt/template b/srcpkgs/mlt/template
index 8933eb4e7bb9..73353fedafb5 100644
--- a/srcpkgs/mlt/template
+++ b/srcpkgs/mlt/template
@@ -1,14 +1,14 @@
 # Template file for 'mlt'
 pkgname=mlt
 version=6.26.1
-revision=1
+revision=2
 build_style=configure
 configure_args="--prefix=/usr --libdir=/usr/lib$XBPS_TARGET_WORDSIZE
  --enable-gpl --enable-gpl3 --disable-swfdec --without-kde
  --swig-languages=python"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which"
 # XXX: movit vid.stab
-makedepends="alsa-lib-devel ffmpeg-devel gtk+-devel jack-devel ladspa-sdk
+makedepends="alsa-lib-devel ffmpeg4-devel gtk+-devel jack-devel ladspa-sdk
  libexif-devel libsamplerate-devel libxml2-devel sox-devel SDL_image-devel
  fftw-devel frei0r-plugins python3-devel pulseaudio-devel movit-devel
  libvidstab-devel libatomic-devel"

From 29861bc3572526793c4af06263113d08a36dd627 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 058/116] moc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/moc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/moc/template b/srcpkgs/moc/template
index c42be650a1d2..d4f0eefbad52 100644
--- a/srcpkgs/moc/template
+++ b/srcpkgs/moc/template
@@ -1,10 +1,10 @@
 # Template file for 'moc'
 pkgname=moc
 version=2.5.2
-revision=6
+revision=7
 build_style=gnu-configure
 hostmakedepends="pkg-config"
-makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg-devel
+makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg4-devel
  jack-devel alsa-lib-devel libltdl-devel libflac-devel libvorbis-devel
  libmad-devel libmpcdec-devel libmodplug-devel libid3tag-devel faad2-devel
  taglib-devel libsndfile-devel wavpack-devel speex-devel libsamplerate-devel

From 950200b5c1feb31dc547c5765fc33b85208894fb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 059/116] motion: revbump for ffmpeg-6.0

---
 srcpkgs/motion/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/motion/template b/srcpkgs/motion/template
index 3cf3c3035c5b..7dca12d851e3 100644
--- a/srcpkgs/motion/template
+++ b/srcpkgs/motion/template
@@ -1,7 +1,7 @@
 # Template file for 'motion'
 pkgname=motion
 version=4.5.1
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake pkg-config gettext-devel tar"
 makedepends="ffmpeg-devel libmicrohttpd-devel v4l-utils-devel gettext-devel"

From 6adc08cf921cf1e5562e91e15e1680a90c33ca3b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 060/116] mpv: revbump for ffmpeg-6.0

---
 srcpkgs/mpv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpv/template b/srcpkgs/mpv/template
index e163c496c6eb..d4fefbf5e3c7 100644
--- a/srcpkgs/mpv/template
+++ b/srcpkgs/mpv/template
@@ -1,7 +1,7 @@
 # Template file for 'mpv'
 pkgname=mpv
 version=0.35.1
-revision=2
+revision=3
 build_style=meson
 configure_args="-Dcdda=enabled -Ddvbin=enabled -Ddvdnav=enabled
  -Dlibmpv=true -Dcplugins=enabled

From 183097904e73843b681e8c131e5c7f3efc950121 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 061/116] musikcube: revbump for ffmpeg-6.0

---
 srcpkgs/musikcube/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/musikcube/template b/srcpkgs/musikcube/template
index 7c569303c054..a4dea460c371 100644
--- a/srcpkgs/musikcube/template
+++ b/srcpkgs/musikcube/template
@@ -1,7 +1,7 @@
 # Template file for 'musikcube'
 pkgname=musikcube
 version=3.0.0
-revision=1
+revision=2
 build_style=cmake
 make_cmd=make
 configure_args="-DNO_NCURSESW=1"

From d2f0dcdc6db172eb73dab3e3449c02e11d7b18b8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 062/116] notcurses: revbump for ffmpeg-6.0

---
 srcpkgs/notcurses/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/notcurses/template b/srcpkgs/notcurses/template
index 6dd8a091319f..3110c30c9aff 100644
--- a/srcpkgs/notcurses/template
+++ b/srcpkgs/notcurses/template
@@ -1,7 +1,7 @@
 # Template file for 'notcurses'
 pkgname=notcurses
 version=3.0.9
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DUSE_STATIC=ON $(vopt_bool man USE_PANDOC)"
 hostmakedepends="pkg-config $(vopt_if man pandoc)"

From 5bd54c528311c6739754e9e92eb798b98db41561 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 063/116] obs: revbump for ffmpeg-6.0

---
 srcpkgs/obs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/obs/template b/srcpkgs/obs/template
index 7b69c630d30d..2c8d68d71f3a 100644
--- a/srcpkgs/obs/template
+++ b/srcpkgs/obs/template
@@ -1,7 +1,7 @@
 # Template file for 'obs'
 pkgname=obs
 version=29.1.2
-revision=1
+revision=2
 archs="i686* x86_64* ppc64le* aarch64*"
 build_style=cmake
 configure_args="-DOBS_VERSION_OVERRIDE=${version} -DENABLE_JACK=ON

From 6eba96ee56a77c3df9e9202754c893f50bd4eb75 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 064/116] olive: revbump for ffmpeg4-4.4.3

---
 srcpkgs/olive/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/olive/template b/srcpkgs/olive/template
index 12a46936c990..5c2917b9c512 100644
--- a/srcpkgs/olive/template
+++ b/srcpkgs/olive/template
@@ -1,10 +1,10 @@
 # Template file for 'olive'
 pkgname=olive
 version=0.1.2
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools pkg-config"
-makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg-devel frei0r-plugins"
+makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg4-devel frei0r-plugins"
 short_desc="Non-linear video editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"

From 71228bf6e4134e003748b31cc0c4147006da02bd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 065/116] omxplayer: revbump for ffmpeg4-4.4.3

---
 srcpkgs/omxplayer/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/omxplayer/template b/srcpkgs/omxplayer/template
index e70bf7873d4d..0e9bc70e7c8e 100644
--- a/srcpkgs/omxplayer/template
+++ b/srcpkgs/omxplayer/template
@@ -1,10 +1,10 @@
 # Template file for 'omxplayer'
 pkgname=omxplayer
 version=20190102
-revision=1
+revision=2
 short_desc="Commandline OMX player for the Raspberry Pi"
 maintainer="Orphaned <orphan@voidlinux.org>"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://github.com/popcornmix/omxplayer"
 
 _commit="f06235cc9690a6d58187514452df8cf8fcdaacec"
@@ -15,7 +15,7 @@ checksum=af2d9450f8947842ea8c401fe9f71eec444013ebbdee29f2ac828c9c493c1329
 archs="armv6l* armv7l*"
 build_style=gnu-makefile
 hostmakedepends="curl pkg-config"
-makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg-devel dbus-devel"
+makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg4-devel dbus-devel"
 depends="freefont-ttf"
 
 do_build() {

From 13c6631c0f5e5f971bae22b19e4240557656409f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 066/116] openimageio: revbump for ffmpeg-6.0

---
 common/shlibs                | 2 ++
 srcpkgs/openimageio/template | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/shlibs b/common/shlibs
index ce0c518f00ef..2820e834d136 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2259,6 +2259,8 @@ libxmp.so.4 libxmp-4.3.7_1
 libKF5ThreadWeaver.so.5 threadweaver-5.26.0_1
 libOpenImageIO_Util.so.2.4 openimageio-2.4.9.0_1
 libOpenImageIO.so.2.4 openimageio-2.4.9.0_1
+libOpenImageIO_Util.so.2.4 openimageio-2.4.8.1_1
+libOpenImageIO.so.2.4 openimageio-2.4.8.1_1
 libOpenColorIO.so.2.1 opencolorio-2.1.2_1
 libpystring.so.1 pystring-1.1.3_1
 libyaml-cpp.so.0.7 yaml-cpp-0.7.0_1
diff --git a/srcpkgs/openimageio/template b/srcpkgs/openimageio/template
index c2d36b4b3539..0e9e22e9685d 100644
--- a/srcpkgs/openimageio/template
+++ b/srcpkgs/openimageio/template
@@ -1,7 +1,7 @@
 # Template file for 'openimageio'
 pkgname=openimageio
 version=2.4.9.0
-revision=4
+revision=5
 build_style=cmake
 build_helper=qemu
 configure_args="-DUSE_QT=0 -DUSE_PYTHON=0 -DOIIO_BUILD_TESTS=0

From 1ee0d8161c471a5692be6bb6e45b69e9a62bf902 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 067/116] openshot: revbump for ffmpeg-6.0

---
 srcpkgs/openshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openshot/template b/srcpkgs/openshot/template
index 322717d40abc..c074e0338773 100644
--- a/srcpkgs/openshot/template
+++ b/srcpkgs/openshot/template
@@ -1,7 +1,7 @@
 # Template file for 'openshot'
 pkgname=openshot
 version=3.0.0
-revision=1
+revision=2
 build_style=python3-module
 hostmakedepends="python3 python3-setuptools"
 makedepends="ffmpeg-devel python3-PyQt5"

From c7a6759e25aefaf38821bf92081dde79495ef27d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 068/116] opentoonz: revbump for ffmpeg-6.0

---
 srcpkgs/opentoonz/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/opentoonz/template b/srcpkgs/opentoonz/template
index ee9f7603f55f..3e81834ca0ed 100644
--- a/srcpkgs/opentoonz/template
+++ b/srcpkgs/opentoonz/template
@@ -1,7 +1,7 @@
 # Template file for 'opentoonz'
 pkgname=opentoonz
 version=1.6.0
-revision=2
+revision=3
 build_wrksrc="toonz/sources"
 build_style=cmake
 make_cmd=make

From fad508c83a45f4bfaf30e7e50cfa334bcda260dd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 069/116] pianobar: revbump for ffmpeg-6.0

---
 srcpkgs/pianobar/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pianobar/template b/srcpkgs/pianobar/template
index a9b29e91993f..81efcd122c4d 100644
--- a/srcpkgs/pianobar/template
+++ b/srcpkgs/pianobar/template
@@ -1,7 +1,7 @@
 # Template file for 'pianobar'
 pkgname=pianobar
 version=2022.04.01
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="V=1"
 hostmakedepends="pkg-config"

From 67e78de87557110085901b1adad873d7dd3f7159 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 070/116] ppsspp: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ppsspp/template | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/ppsspp/template b/srcpkgs/ppsspp/template
index 7984a733d4be..15a42fd2c993 100644
--- a/srcpkgs/ppsspp/template
+++ b/srcpkgs/ppsspp/template
@@ -1,7 +1,7 @@
 # Template file for 'ppsspp'
 pkgname=ppsspp
 version=1.14.4
-revision=1
+revision=2
 _glslang_commit=dc11adde23c455a24e13dd54de9b4ede8bdd7db8
 _SPIRV_Cross_commit=9acb9ec31f5a8ef80ea6b994bb77be787b08d3d1
 _armips_commit=6719edebaae03330ee5441d9b28280672edf00d5
@@ -13,7 +13,7 @@ configure_args="-DHEADLESS=1 -DUSE_SYSTEM_FFMPEG=1 -DUNITTEST=ON
  -DUSING_QT_UI=$(vopt_if qt ON OFF) -DUSE_SYSTEM_ZSTD=ON
  -DARMIPS_USE_STD_FILESYSTEM=ON"
 hostmakedepends="pkg-config python3 $(vopt_if qt qt5-host-tools)"
-makedepends="zlib-devel glew-devel ffmpeg-devel libzip-devel
+makedepends="zlib-devel glew-devel ffmpeg4-devel libzip-devel
  snappy-devel rapidjson libpng-devel libzstd-devel
  $(vopt_if sdl2 SDL2-devel) $(vopt_if wayland wayland-devel)
  $(vopt_if qt 'qt5-devel qt5-multimedia-devel')"
@@ -62,13 +62,12 @@ post_extract() {
 	mv ${wrksrc}/miniupnp-${_miniupnp_commit} ${wrksrc}/ext/miniupnp
 }
 
-post_patch(){
+post_patch() {
 	# disable git versioning
 	vsed -e 's|find_package(Git)|# &|' -i git-version.cmake
 }
 
 do_install() {
-	vlicense LICENSE.TXT
 	vinstall icons/icon.svg 644 usr/share/pixmaps ppsspp.svg
 	vinstall Qt/PPSSPP.desktop 644 usr/share/applications
 	vbin build/PPSSPPHeadless ppsspp-headless

From 2bdb128835e369e030c53dd1f7abbec835d585ee Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 071/116] pqiv: revbump for ffmpeg-6.0

---
 srcpkgs/pqiv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pqiv/template b/srcpkgs/pqiv/template
index 542fc27a2d32..9308d949b6a1 100644
--- a/srcpkgs/pqiv/template
+++ b/srcpkgs/pqiv/template
@@ -1,7 +1,7 @@
 # Template file for 'pqiv'
 pkgname=pqiv
 version=2.12
-revision=1
+revision=2
 build_style=gnu-makefile
 hostmakedepends="pkg-config"
 makedepends="glib-devel gtk+3-devel $(vopt_if ffmpeg ffmpeg-devel)

From 81506c89203f93e795e5fcec85835fd725820a51 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 072/116] qmmp: revbump for ffmpeg-6.0

---
 srcpkgs/qmmp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qmmp/template b/srcpkgs/qmmp/template
index 26c661ed16be..a150d7441c7a 100644
--- a/srcpkgs/qmmp/template
+++ b/srcpkgs/qmmp/template
@@ -1,7 +1,7 @@
 # Template file for 'qmmp'
 pkgname=qmmp
 version=1.6.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DUSE_HAL:BOOL=FALSE -DQMMP_DEFAULT_UI:STRING=simple"
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From 7bedda21dcae720db1bf93bc610b35a5c68afe7e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 073/116] qt5-webengine: update to 5.15.13

---
 .../chromium-media-filters-cpp14.patch        |  11 ++
 srcpkgs/qt5-webengine/patches/ffmpeg5.patch   | 179 ++++++++++++++++++
 srcpkgs/qt5-webengine/template                |  10 +-
 3 files changed, 195 insertions(+), 5 deletions(-)
 create mode 100644 srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/ffmpeg5.patch

diff --git a/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
new file mode 100644
index 000000000000..04adc540f2cb
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
@@ -0,0 +1,11 @@
+--- a/src/3rdparty/chromium/media/filters/BUILD.gn	2023-02-27 13:32:59.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/BUILD.gn	2023-04-02 17:21:39.204066384 -0400
+@@ -96,6 +96,8 @@
+     "//ui/gfx/geometry:geometry",
+   ]
+ 
++  cflags_cc = [ "-std=c++14" ]
++
+   libs = []
+ 
+   if (proprietary_codecs) {
diff --git a/srcpkgs/qt5-webengine/patches/ffmpeg5.patch b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..ac55e1634423
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
@@ -0,0 +1,179 @@
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:57.732547446 -0400
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:09.486478995 -0400
+@@ -57,6 +57,8 @@
+ 
+ namespace {
+ 
++constexpr int64_t kRelativeTsBase = static_cast<int64_t>(0x7ffeffffffffffff);
++
+ void SetAVStreamDiscard(AVStream* stream, AVDiscard discard) {
+   DCHECK(stream);
+   stream->discard = discard;
+@@ -90,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+   if (stream->start_time != kNoFFmpegTimestamp)
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (stream->first_dts != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, stream->first_dts);
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -408,11 +398,11 @@
+   scoped_refptr<DecoderBuffer> buffer;
+ 
+   if (type() == DemuxerStream::TEXT) {
+-    int id_size = 0;
++    size_t id_size = 0;
+     uint8_t* id_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
+ 
+-    int settings_size = 0;
++    size_t settings_size = 0;
+     uint8_t* settings_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
+ 
+@@ -424,7 +414,7 @@
+     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
+                                      side_data.data(), side_data.size());
+   } else {
+-    int side_data_size = 0;
++    size_t side_data_size = 0;
+     uint8_t* side_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
+ 
+@@ -485,7 +475,7 @@
+                                        packet->size - data_offset);
+     }
+ 
+-    int skip_samples_size = 0;
++    size_t skip_samples_size = 0;
+     const uint32_t* skip_samples_ptr =
+         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
+             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
+@@ -1587,6 +1577,8 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++      continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+       lowest_start_time_stream = stream.get();
+@@ -1604,6 +1596,8 @@
+     if (stream && stream->type() == DemuxerStream::VIDEO &&
+         stream->IsEnabled()) {
+       video_stream = stream.get();
++      if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++        continue;
+       if (video_stream->start_time() <= seek_time) {
+         return video_stream;
+       }
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h qtwebengine-5.15.10/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h
+--- a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-07-11 22:12:47.917192788 -0500
+@@ -29,6 +29,7 @@ extern "C" {
+ #include <libavformat/avformat.h>
+ #include <libavformat/avio.h>
+ #include <libavutil/avutil.h>
++#include <libavutil/channel_layout.h>
+ #include <libavutil/imgutils.h>
+ #include <libavutil/log.h>
+ #include <libavutil/mastering_display_metadata.h>
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/audio_file_reader.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/audio_file_reader.cc
+--- a/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -85,7 +85,7 @@ bool AudioFileReader::OpenDemuxer() {
+ }
+ 
+ bool AudioFileReader::OpenDecoder() {
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (codec) {
+     // MP3 decodes to S16P which we don't support, tell it to use S16 instead.
+     if (codec_context_->sample_fmt == AV_SAMPLE_FMT_S16P)
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -329,7 +329,7 @@ bool FFmpegAudioDecoder::ConfigureDecode
+     }
+   }
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec ||
+       avcodec_open2(codec_context_.get(), codec, &codec_options) < 0) {
+     DLOG(ERROR) << "Could not initialize audio decoder: "
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -59,7 +59,6 @@ static int64_t AVIOSeekOperation(void* o
+ }
+ 
+ void FFmpegGlue::InitializeFFmpeg() {
+-  av_register_all();
+ }
+ 
+ static void LogContainer(bool is_local_file,
+@@ -95,9 +94,6 @@ FFmpegGlue::FFmpegGlue(FFmpegURLProtocol
+   // Enable fast, but inaccurate seeks for MP3.
+   format_context_->flags |= AVFMT_FLAG_FAST_SEEK;
+ 
+-  // Ensures we can read out various metadata bits like vp8 alpha.
+-  format_context_->flags |= AVFMT_FLAG_KEEP_SIDE_DATA;
+-
+   // Ensures format parsing errors will bail out. From an audit on 11/2017, all
+   // instances were real failures. Solves bugs like http://crbug.com/710791.
+   format_context_->error_recognition |= AV_EF_EXPLODE;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -391,7 +391,7 @@ bool FFmpegVideoDecoder::ConfigureDecode
+   if (decode_nalus_)
+     codec_context_->flags2 |= AV_CODEC_FLAG2_CHUNKS;
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
+     ReleaseFFmpegResources();
+     return false;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/media_file_checker.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/media_file_checker.cc
+--- a/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -68,7 +68,7 @@ bool MediaFileChecker::Start(base::TimeD
+       auto context = AVStreamToAVCodecContext(format_context->streams[i]);
+       if (!context)
+         continue;
+-      AVCodec* codec = avcodec_find_decoder(cp->codec_id);
++      const AVCodec* codec = avcodec_find_decoder(cp->codec_id);
+       if (codec && avcodec_open2(context.get(), codec, nullptr) >= 0) {
+         auto loop = std::make_unique<FFmpegDecodingLoop>(context.get());
+         stream_contexts[i] = {std::move(context), std::move(loop)};
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc qtwebengine-5.15.10/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc
+--- a/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -203,7 +203,7 @@ int32_t H264DecoderImpl::InitDecode(cons
+   // a pointer |this|.
+   av_context_->opaque = this;
+ 
+-  AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
+   if (!codec) {
+     // This is an indication that FFmpeg has not been initialized or it has not
+     // been compiled/initialized with the correct set of codecs.
diff --git a/srcpkgs/qt5-webengine/template b/srcpkgs/qt5-webengine/template
index 85267c7cf8a3..095ab67701e4 100644
--- a/srcpkgs/qt5-webengine/template
+++ b/srcpkgs/qt5-webengine/template
@@ -1,9 +1,9 @@
 # Template file for 'qt5-webengine'
 pkgname=qt5-webengine
-version=5.15.11
-revision=3
+version=5.15.13
+revision=1
 _version="${version}-lts"
-_chromium_commit=be349eaf62e77955791d7bf29f893f1e8a37daf4
+_chromium_commit=e48df7803c7c98b0b2471c94057d32e44a301ad5
 archs="x86_64* i686* armv[67]* ppc64* aarch64*"
 create_wrksrc=yes
 build_style=qmake
@@ -32,8 +32,8 @@ license="GPL-3.0-or-later, LGPL-3.0-or-later"
 homepage="https://qt.io/"
 distfiles="https://github.com/qt/qtwebengine/archive/v${_version}.tar.gz
  https://github.com/qt/qtwebengine-chromium/archive/${_chromium_commit}.tar.gz"
-checksum="aa7466356c450c5f5870f979b93cd7e7e62da1165c328ffcab1a9928db18ad67
- 6f47ed8ab8cc062411f6f206da6353bc8263d6ed6d6290c689a05c01d91f646b"
+checksum="4b59838ed75ef788b59e1e412535a0e42dd9d311661fdeadb191b581ba815c63
+ a91686562b1d4e8b220e0bbcbab5feb64630e2de974b35ac034bf388af771a6c"
 
 no_generic_pkgconfig_link=yes
 build_options="sndio pipewire"

From 6455e1a069d9c4034895b4d5387ec5e4fe56b4d2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 074/116] qt5: update to 5.15.8

---
 ...erywhere-opensource-src-5.15.8-kf5-1.patch | 12913 ++++++++++++++++
 srcpkgs/qt5/template                          |    12 +-
 2 files changed, 12919 insertions(+), 6 deletions(-)
 create mode 100644 srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch

diff --git a/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch b/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch
new file mode 100644
index 000000000000..966c98bcd3bb
--- /dev/null
+++ b/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch
@@ -0,0 +1,12913 @@
+Submitted By:            Pierre Labastie <pierre_dot_labastie_at_neuf_dot_fr>
+Date:                    2023-01-05
+Initial Package Version: 5.15.8
+Upstream Status:         Applied (according to KDE)
+Origin:                  KDE patch set
+Description:             Patch set maintained by the KDE folks
+see https://dot.kde.org/2021/04/06/announcing-kdes-qt-5-patch-collection
+Patch generated using the procedure in
+https://wiki.linuxfromscratch.org/blfs/ticket/17476#comment:3
+
+Submodule qtbase 4ee4fc18..9cf586d6:
+diff --git a/qtbase/mkspecs/common/android/qplatformdefs.h b/qtbase/mkspecs/common/android/qplatformdefs.h
+index f75bc4093b..2bd59410d4 100644
+--- a/qtbase/mkspecs/common/android/qplatformdefs.h
++++ b/qtbase/mkspecs/common/android/qplatformdefs.h
+@@ -144,11 +144,7 @@
+ #define QT_SIGNAL_ARGS          int
+ #define QT_SIGNAL_IGNORE        SIG_IGN
+ 
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+ #define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+ 
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+diff --git a/qtbase/mkspecs/features/mac/sdk.mk b/qtbase/mkspecs/features/mac/sdk.mk
+index f30b5830b4..a32ceacb6c 100644
+--- a/qtbase/mkspecs/features/mac/sdk.mk
++++ b/qtbase/mkspecs/features/mac/sdk.mk
+@@ -1,6 +1,6 @@
+ 
+ ifeq ($(QT_MAC_SDK_NO_VERSION_CHECK),)
+-    CHECK_SDK_COMMAND = /usr/bin/xcrun --sdk $(EXPORT_QMAKE_MAC_SDK) -show-sdk-version 2>&1
++    CHECK_SDK_COMMAND = /usr/bin/xcrun --sdk $(EXPORT_QMAKE_MAC_SDK) -show-sdk-version 2>/dev/null
+     CURRENT_MAC_SDK_VERSION := $(shell DEVELOPER_DIR=$(EXPORT_QMAKE_XCODE_DEVELOPER_PATH) $(CHECK_SDK_COMMAND))
+     ifneq ($(CURRENT_MAC_SDK_VERSION),$(EXPORT_QMAKE_MAC_SDK_VERSION))
+         # We don't want to complain about out of date SDK unless the target needs to be remade.
+diff --git a/qtbase/mkspecs/linux-clang/qplatformdefs.h b/qtbase/mkspecs/linux-clang/qplatformdefs.h
+index a818d973f0..c1ab72fbc6 100644
+--- a/qtbase/mkspecs/linux-clang/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-clang/qplatformdefs.h
+@@ -79,14 +79,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-g++/qplatformdefs.h b/qtbase/mkspecs/linux-g++/qplatformdefs.h
+index 13523f0702..4d2750d9ec 100644
+--- a/qtbase/mkspecs/linux-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-g++/qplatformdefs.h
+@@ -79,14 +79,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ < 2)
+-#define QT_SOCKLEN_T            int
+-#else
+-#define QT_SOCKLEN_T            socklen_t
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-llvm/qplatformdefs.h b/qtbase/mkspecs/linux-llvm/qplatformdefs.h
+index dc750ab1ef..d3cc39b47f 100644
+--- a/qtbase/mkspecs/linux-llvm/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-llvm/qplatformdefs.h
+@@ -80,14 +80,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h b/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
+index 4c4e53da2a..83baffb3e3 100644
+--- a/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
+@@ -85,16 +85,9 @@
+ #include "../common/posix/qplatformdefs.h"
+ 
+ #undef QT_OPEN_LARGEFILE
+-#undef QT_SOCKLEN_T
+ 
+ #define QT_OPEN_LARGEFILE       0
+ 
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #ifndef SIOCGIFBRDADDR
+ #  define SIOCGIFBRDADDR 0x8919
+ #endif
+diff --git a/qtbase/mkspecs/lynxos-g++/qplatformdefs.h b/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
+index 4339ea2b23..6007af0055 100644
+--- a/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
+@@ -72,14 +72,6 @@
+ 
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp b/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
+index c3c184258f..32af3f8f29 100644
+--- a/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
++++ b/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
+@@ -10,6 +10,7 @@
+ #include "libANGLE/HandleAllocator.h"
+ 
+ #include <algorithm>
++#include <limits>
+ 
+ #include "common/debug.h"
+ 
+diff --git a/qtbase/src/3rdparty/forkfd/forkfd_linux.c b/qtbase/src/3rdparty/forkfd/forkfd_linux.c
+index ffe0e9a5e2..b1f5408d11 100644
+--- a/qtbase/src/3rdparty/forkfd/forkfd_linux.c
++++ b/qtbase/src/3rdparty/forkfd/forkfd_linux.c
+@@ -82,7 +82,8 @@ static int sys_clone(unsigned long cloneflags, int *ptid)
+     return syscall(__NR_clone, cloneflags, child_stack, stack_size, ptid, newtls, ctid);
+ #elif defined(__arc__) || defined(__arm__) || defined(__aarch64__) || defined(__mips__) || \
+     defined(__nds32__) || defined(__hppa__) || defined(__powerpc__) || defined(__i386__) || \
+-    defined(__x86_64__) || defined(__xtensa__) || defined(__alpha__) || defined(__riscv)
++    defined(__x86_64__) || defined(__xtensa__) || defined(__alpha__) || defined(__riscv) || \
++    defined(__loongarch__)
+     /* ctid and newtls are inverted on CONFIG_CLONE_BACKWARDS architectures,
+      * but since both values are 0, there's no harm. */
+     return syscall(__NR_clone, cloneflags, child_stack, ptid, ctid, newtls);
+diff --git a/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java b/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
+index 5792b5b2f5..2f74750fcf 100644
+--- a/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
++++ b/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
+@@ -116,6 +116,7 @@ public class QtNative
+     public static QtThread m_qtThread = new QtThread();
+     private static HashMap<String, Uri> m_cachedUris = new HashMap<String, Uri>();
+     private static ArrayList<String> m_knownDirs = new ArrayList<String>();
++    private static final String NoPermissionErrorMessage = "No permissions to open Uri";
+ 
+     private static final Runnable runPendingCppRunnablesRunnable = new Runnable() {
+         @Override
+@@ -193,11 +194,10 @@ public class QtNative
+                     return iterUri;
+             }
+ 
+-            // Android 6 and earlier could still manage to open the file so we can return the
+-            // parsed uri here
+-            if (Build.VERSION.SDK_INT < 24)
+-                return parsedUri;
+-            return null;
++            // if we only have transient permissions on uri all the above will fail,
++            // but we will be able to read the file anyway, so continue with uri here anyway
++            // and check for SecurityExceptions later
++            return parsedUri;
+         } catch (SecurityException e) {
+             e.printStackTrace();
+             return null;
+@@ -244,7 +244,7 @@ public class QtNative
+         int error = -1;
+ 
+         if (uri == null) {
+-            Log.e(QtTAG, "openFdForContentUrl(): No permissions to open Uri");
++            Log.e(QtTAG, "openFdForContentUrl(): " + NoPermissionErrorMessage);
+             return error;
+         }
+ 
+@@ -254,12 +254,13 @@ public class QtNative
+             return fdDesc.detachFd();
+         } catch (FileNotFoundException e) {
+             e.printStackTrace();
+-            return error;
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "openFdForContentUrl(): Invalid Uri");
+             e.printStackTrace();
+-            return error;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return error;
+     }
+ 
+     public static long getSize(Context context, String contentUrl)
+@@ -270,7 +271,7 @@ public class QtNative
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+ 
+         if (uri == null) {
+-            Log.e(QtTAG, "getSize(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return size;
+         } else if (!m_cachedUris.containsKey(contentUrl)) {
+             m_cachedUris.put(contentUrl, uri);
+@@ -288,12 +289,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "getSize(): Invalid Uri");
+             e.printStackTrace();
+-            return size;
+         }  catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "getSize(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return size;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return size;
+     }
+ 
+     public static boolean checkFileExists(Context context, String contentUrl)
+@@ -303,7 +305,7 @@ public class QtNative
+         if (uri == null)
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+         if (uri == null) {
+-            Log.e(QtTAG, "checkFileExists(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return exists;
+         } else {
+             if (!m_cachedUris.containsKey(contentUrl))
+@@ -321,12 +323,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "checkFileExists(): Invalid Uri");
+             e.printStackTrace();
+-            return exists;
+         } catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "checkFileExists(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return false;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return exists;
+     }
+ 
+     public static boolean checkIfWritable(Context context, String contentUrl)
+@@ -344,7 +347,7 @@ public class QtNative
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+         }
+         if (uri == null) {
+-            Log.e(QtTAG, "isDir(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return isDir;
+         } else {
+             if (!m_cachedUris.containsKey(contentUrl))
+@@ -374,12 +377,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "checkIfDir(): Invalid Uri");
+             e.printStackTrace();
+-            return false;
+         } catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "checkIfDir(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return false;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return false;
+     }
+     public static String[] listContentsFromTreeUri(Context context, String contentUrl)
+     {
+diff --git a/qtbase/src/concurrent/qtconcurrentreducekernel.h b/qtbase/src/concurrent/qtconcurrentreducekernel.h
+index 8f9a938952..a98dedef2e 100644
+--- a/qtbase/src/concurrent/qtconcurrentreducekernel.h
++++ b/qtbase/src/concurrent/qtconcurrentreducekernel.h
+@@ -212,11 +212,13 @@ public:
+ 
+     inline bool shouldThrottle()
+     {
++        std::lock_guard<QMutex> locker(mutex);
+         return (resultsMapSize > (ReduceQueueThrottleLimit * threadCount));
+     }
+ 
+     inline bool shouldStartThread()
+     {
++        std::lock_guard<QMutex> locker(mutex);
+         return (resultsMapSize <= (ReduceQueueStartLimit * threadCount));
+     }
+ };
+diff --git a/qtbase/src/concurrent/qtconcurrentthreadengine.cpp b/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
+index ea6ce3ac42..7f91a2ba68 100644
+--- a/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
++++ b/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
+@@ -176,6 +176,39 @@ void ThreadEngineBase::startSingleThreaded()
+     finish();
+ }
+ 
++void ThreadEngineBase::startBlocking()
++{
++    start();
++    barrier.acquire();
++    startThreads();
++
++    bool throttled = false;
++#ifndef QT_NO_EXCEPTIONS
++    try {
++#endif
++        while (threadFunction() == ThrottleThread) {
++            if (threadThrottleExit()) {
++                throttled = true;
++                break;
++            }
++        }
++#ifndef QT_NO_EXCEPTIONS
++    } catch (QException &e) {
++        handleException(e);
++    } catch (...) {
++        handleException(QUnhandledException());
++    }
++#endif
++
++    if (throttled == false) {
++        barrier.release();
++    }
++
++    barrier.wait();
++    finish();
++    exceptionStore.throwPossibleException();
++}
++
+ void ThreadEngineBase::startThread()
+ {
+     startThreadInternal();
+diff --git a/qtbase/src/concurrent/qtconcurrentthreadengine.h b/qtbase/src/concurrent/qtconcurrentthreadengine.h
+index 7c30cebdbc..a4c8548cc4 100644
+--- a/qtbase/src/concurrent/qtconcurrentthreadengine.h
++++ b/qtbase/src/concurrent/qtconcurrentthreadengine.h
+@@ -91,6 +91,7 @@ public:
+     ThreadEngineBase();
+     virtual ~ThreadEngineBase();
+     void startSingleThreaded();
++    void startBlocking();
+     void startThread();
+     bool isCanceled();
+     void waitForResume();
+@@ -143,6 +144,15 @@ public:
+         return result();
+     }
+ 
++    // Runs the user algorithm using multiple threads.
++    // This function blocks until the algorithm is finished,
++    // and then returns the result.
++    T *startBlocking()
++    {
++        ThreadEngineBase::startBlocking();
++        return result();
++    }
++
+     // Runs the user algorithm using multiple threads.
+     // Does not block, returns a future.
+     QFuture<T> startAsynchronously()
+@@ -223,6 +233,13 @@ class ThreadEngineStarter : public ThreadEngineStarterBase<T>
+ public:
+     ThreadEngineStarter(TypedThreadEngine *eng)
+         : Base(eng) { }
++
++    T startBlocking()
++    {
++        T t = *this->threadEngine->startBlocking();
++        delete this->threadEngine;
++        return t;
++    }
+ };
+ 
+ // Full template specialization where T is void.
+@@ -232,6 +249,12 @@ class ThreadEngineStarter<void> : public ThreadEngineStarterBase<void>
+ public:
+     ThreadEngineStarter(ThreadEngine<void> *_threadEngine)
+         : ThreadEngineStarterBase<void>(_threadEngine) {}
++
++    void startBlocking()
++    {
++        this->threadEngine->startBlocking();
++        delete this->threadEngine;
++    }
+ };
+ 
+ //! [qtconcurrentthreadengine-1]
+diff --git a/qtbase/src/corelib/animation/qvariantanimation.cpp b/qtbase/src/corelib/animation/qvariantanimation.cpp
+index 98b02f0202..eac1524107 100644
+--- a/qtbase/src/corelib/animation/qvariantanimation.cpp
++++ b/qtbase/src/corelib/animation/qvariantanimation.cpp
+@@ -276,7 +276,9 @@ void QVariantAnimationPrivate::setCurrentValueForProgress(const qreal progress)
+ 
+     const qreal startProgress = currentInterval.start.first;
+     const qreal endProgress = currentInterval.end.first;
+-    const qreal localProgress = (progress - startProgress) / (endProgress - startProgress);
++    const qreal localProgress =
++            qIsNull(progress - startProgress) ? 0.0 // avoid 0/0 below
++            /* else */                        : (progress - startProgress) / (endProgress - startProgress);
+ 
+     QVariant ret = q->interpolated(currentInterval.start.second,
+                                    currentInterval.end.second,
+diff --git a/qtbase/src/corelib/global/qnamespace.h b/qtbase/src/corelib/global/qnamespace.h
+index ad4150b317..bf19b1627b 100644
+--- a/qtbase/src/corelib/global/qnamespace.h
++++ b/qtbase/src/corelib/global/qnamespace.h
+@@ -1864,7 +1864,7 @@ public:
+     QT_Q_ENUM(TimerType)
+     QT_Q_ENUM(ScrollPhase)
+     QT_Q_ENUM(MouseEventSource)
+-    QT_Q_FLAG(MouseEventFlag)
++    QT_Q_FLAG(MouseEventFlags)
+     QT_Q_ENUM(ChecksumType)
+     QT_Q_ENUM(HighDpiScaleFactorRoundingPolicy)
+     QT_Q_ENUM(TabFocusBehavior)
+diff --git a/qtbase/src/corelib/global/qrandom.cpp b/qtbase/src/corelib/global/qrandom.cpp
+index 10672c1f92..25f87c7e6a 100644
+--- a/qtbase/src/corelib/global/qrandom.cpp
++++ b/qtbase/src/corelib/global/qrandom.cpp
+@@ -383,7 +383,6 @@ struct QRandomGenerator::SystemAndGlobalGenerators
+ 
+         constexpr SystemAndGlobalGenerators g = {};
+         Q_UNUSED(g);
+-        Q_STATIC_ASSERT(std::is_literal_type<SystemAndGlobalGenerators>::value);
+ #endif
+     }
+ 
+diff --git a/qtbase/src/corelib/io/qbuffer.cpp b/qtbase/src/corelib/io/qbuffer.cpp
+index 595fcd2724..032c0ddd4b 100644
+--- a/qtbase/src/corelib/io/qbuffer.cpp
++++ b/qtbase/src/corelib/io/qbuffer.cpp
+@@ -41,6 +41,8 @@
+ #include <QtCore/qmetaobject.h>
+ #include "private/qiodevice_p.h"
+ 
++#include <limits>
++
+ QT_BEGIN_NAMESPACE
+ 
+ /** QBufferPrivate **/
+@@ -366,7 +368,9 @@ qint64 QBuffer::size() const
+ bool QBuffer::seek(qint64 pos)
+ {
+     Q_D(QBuffer);
+-    if (pos > d->buf->size() && isWritable()) {
++    const auto oldBufSize = d->buf->size();
++    constexpr qint64 MaxSeekPos = (std::numeric_limits<decltype(oldBufSize)>::max)();
++    if (pos <= MaxSeekPos && pos > oldBufSize && isWritable()) {
+         if (seek(d->buf->size())) {
+             const qint64 gapSize = pos - d->buf->size();
+             if (write(QByteArray(gapSize, 0)) != gapSize) {
+@@ -377,7 +381,7 @@ bool QBuffer::seek(qint64 pos)
+             return false;
+         }
+     } else if (pos > d->buf->size() || pos < 0) {
+-        qWarning("QBuffer::seek: Invalid pos: %d", int(pos));
++        qWarning("QBuffer::seek: Invalid pos: %lld", pos);
+         return false;
+     }
+     return QIODevice::seek(pos);
+diff --git a/qtbase/src/corelib/io/qfilesystemengine_win.cpp b/qtbase/src/corelib/io/qfilesystemengine_win.cpp
+index 81d3a71986..c86ed1f9b0 100644
+--- a/qtbase/src/corelib/io/qfilesystemengine_win.cpp
++++ b/qtbase/src/corelib/io/qfilesystemengine_win.cpp
+@@ -664,14 +664,14 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry)
+     return QFileSystemEntry(ret, QFileSystemEntry::FromInternalPath());
+ }
+ 
+-#if defined(Q_CC_MINGW) && WINVER < 0x0602 //  Windows 8 onwards
++#if defined(Q_CC_MINGW) && WINVER < 0x0602 && _WIN32_WINNT < _WIN32_WINNT_WIN8 //  Windows 8 onwards
+ 
+ typedef struct _FILE_ID_INFO {
+     ULONGLONG VolumeSerialNumber;
+     FILE_ID_128 FileId;
+ } FILE_ID_INFO, *PFILE_ID_INFO;
+ 
+-#endif // if defined (Q_CC_MINGW) && WINVER < 0x0602
++#endif // if defined(Q_CC_MINGW) && WINVER < 0x0602 && _WIN32_WINNT < _WIN32_WINNT_WIN8
+ 
+ // File ID for Windows up to version 7 and FAT32 drives
+ static inline QByteArray fileId(HANDLE handle)
+diff --git a/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp b/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
+index 94d9d06bcb..27e0b13b0b 100644
+--- a/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
++++ b/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
+@@ -366,7 +366,9 @@ void QInotifyFileSystemWatcherEngine::readFromInotify()
+     // qDebug("QInotifyFileSystemWatcherEngine::readFromInotify");
+ 
+     int buffSize = 0;
+-    ioctl(inotifyFd, FIONREAD, (char *) &buffSize);
++    if (ioctl(inotifyFd, FIONREAD, (char *) &buffSize) == -1 || buffSize == 0)
++        return;
++
+     QVarLengthArray<char, 4096> buffer(buffSize);
+     buffSize = read(inotifyFd, buffer.data(), buffSize);
+     char *at = buffer.data();
+diff --git a/qtbase/src/corelib/io/qlockfile_win.cpp b/qtbase/src/corelib/io/qlockfile_win.cpp
+index 277f8d4230..38ecef5550 100644
+--- a/qtbase/src/corelib/io/qlockfile_win.cpp
++++ b/qtbase/src/corelib/io/qlockfile_win.cpp
+@@ -48,6 +48,8 @@
+ #include "QtCore/qdebug.h"
+ #include "QtCore/qthread.h"
+ 
++#include "private/qsystemlibrary_p.h"
++
+ QT_BEGIN_NAMESPACE
+ 
+ static inline bool fileExists(const wchar_t *fileName)
+@@ -150,7 +152,7 @@ QString QLockFilePrivate::processNameByPid(qint64 pid)
+ #if !defined(Q_OS_WINRT)
+     typedef DWORD (WINAPI *GetModuleFileNameExFunc)(HANDLE, HMODULE, LPTSTR, DWORD);
+ 
+-    HMODULE hPsapi = LoadLibraryA("psapi");
++    HMODULE hPsapi = QSystemLibrary::load(L"psapi");
+     if (!hPsapi)
+         return QString();
+     GetModuleFileNameExFunc qGetModuleFileNameEx = reinterpret_cast<GetModuleFileNameExFunc>(
+diff --git a/qtbase/src/corelib/io/qprocess_unix.cpp b/qtbase/src/corelib/io/qprocess_unix.cpp
+index 50390e57f5..15c8f30745 100644
+--- a/qtbase/src/corelib/io/qprocess_unix.cpp
++++ b/qtbase/src/corelib/io/qprocess_unix.cpp
+@@ -1,7 +1,7 @@
+ /****************************************************************************
+ **
+ ** Copyright (C) 2016 The Qt Company Ltd.
+-** Copyright (C) 2016 Intel Corporation.
++** Copyright (C) 2022 Intel Corporation.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtCore module of the Qt Toolkit.
+@@ -422,14 +422,15 @@ void QProcessPrivate::startProcess()
+     // Add the program name to the argument list.
+     argv[0] = nullptr;
+     if (!program.contains(QLatin1Char('/'))) {
++        // findExecutable() returns its argument if it's an absolute path,
++        // otherwise it searches $PATH; returns empty if not found (we handle
++        // that case much later)
+         const QString &exeFilePath = QStandardPaths::findExecutable(program);
+-        if (!exeFilePath.isEmpty()) {
+-            const QByteArray &tmp = QFile::encodeName(exeFilePath);
+-            argv[0] = ::strdup(tmp.constData());
+-        }
+-    }
+-    if (!argv[0])
++        const QByteArray &tmp = QFile::encodeName(exeFilePath);
++        argv[0] = ::strdup(tmp.constData());
++    } else {
+         argv[0] = ::strdup(encodedProgramName.constData());
++    }
+ 
+     // Add every argument to the list
+     for (int i = 0; i < arguments.count(); ++i)
+@@ -983,15 +984,16 @@ bool QProcessPrivate::startDetached(qint64 *pid)
+                 envp = _q_dupEnvironment(environment.d.constData()->vars, &envc);
+             }
+ 
+-            QByteArray tmp;
+             if (!program.contains(QLatin1Char('/'))) {
++                // findExecutable() returns its argument if it's an absolute path,
++                // otherwise it searches $PATH; returns empty if not found (we handle
++                // that case much later)
+                 const QString &exeFilePath = QStandardPaths::findExecutable(program);
+-                if (!exeFilePath.isEmpty())
+-                    tmp = QFile::encodeName(exeFilePath);
++                const QByteArray &tmp = QFile::encodeName(exeFilePath);
++                argv[0] = ::strdup(tmp.constData());
++            } else {
++                argv[0] = ::strdup(QFile::encodeName(program));
+             }
+-            if (tmp.isEmpty())
+-                tmp = QFile::encodeName(program);
+-            argv[0] = tmp.data();
+ 
+             if (envp)
+                 qt_safe_execve(argv[0], argv, envp);
+diff --git a/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp b/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
+index 3a79c502af..997a634e76 100644
+--- a/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
++++ b/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
+@@ -3196,9 +3196,8 @@ bool QAbstractItemModel::beginMoveColumns(const QModelIndex &sourceParent, int s
+     destinationChange.needsAdjust = destinationParent.isValid() && destinationParent.row() >= sourceLast && destinationParent.parent() == sourceParent;
+     d->changes.push(destinationChange);
+ 
+-    d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Horizontal);
+-
+     emit columnsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, QPrivateSignal());
++    d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Horizontal);
+     return true;
+ }
+ 
+@@ -3231,7 +3230,6 @@ void QAbstractItemModel::endMoveColumns()
+       adjustedSource = createIndex(adjustedSource.row(), adjustedSource.column() + numMoved, adjustedSource.internalPointer());
+ 
+     d->itemsMoved(adjustedSource, removeChange.first, removeChange.last, adjustedDestination, insertChange.first, Qt::Horizontal);
+-
+     emit columnsMoved(adjustedSource, removeChange.first, removeChange.last, adjustedDestination, insertChange.first, QPrivateSignal());
+ }
+ 
+diff --git a/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+index dc6379d9fb..c5e287ee84 100644
+--- a/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
++++ b/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+@@ -939,8 +939,9 @@ void QSortFilterProxyModelPrivate::insert_source_items(
+                 q->beginInsertColumns(proxy_parent, proxy_start, proxy_end);
+         }
+ 
+-        for (int i = 0; i < source_items.size(); ++i)
+-            proxy_to_source.insert(proxy_start + i, source_items.at(i));
++        // TODO: use the range QList::insert() overload once it is implemented (QTBUG-58633).
++        proxy_to_source.insert(proxy_start, source_items.size(), 0);
++        std::copy(source_items.cbegin(), source_items.cend(), proxy_to_source.begin() + proxy_start);
+ 
+         build_source_to_proxy_mapping(proxy_to_source, source_to_proxy);
+ 
+@@ -3123,8 +3124,9 @@ bool QSortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex &
+ 
+     if (d->filter_data.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();
+@@ -3133,9 +3135,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.hasMatch(key);
+ }
+diff --git a/qtbase/src/corelib/kernel/qcoreapplication.cpp b/qtbase/src/corelib/kernel/qcoreapplication.cpp
+index ca2864df83..132b2eae52 100644
+--- a/qtbase/src/corelib/kernel/qcoreapplication.cpp
++++ b/qtbase/src/corelib/kernel/qcoreapplication.cpp
+@@ -1157,7 +1157,7 @@ static bool doNotify(QObject *receiver, QEvent *event)
+ bool QCoreApplicationPrivate::sendThroughApplicationEventFilters(QObject *receiver, QEvent *event)
+ {
+     // We can't access the application event filters outside of the main thread (race conditions)
+-    Q_ASSERT(receiver->d_func()->threadData.loadRelaxed()->thread.loadAcquire() == mainThread());
++    Q_ASSERT(receiver->d_func()->threadData.loadAcquire()->thread.loadRelaxed() == mainThread());
+ 
+     if (extraData) {
+         // application event filters are only called for objects in the GUI thread
+diff --git a/qtbase/src/corelib/kernel/qobject.cpp b/qtbase/src/corelib/kernel/qobject.cpp
+index 1eb79138d9..36cd780ee1 100644
+--- a/qtbase/src/corelib/kernel/qobject.cpp
++++ b/qtbase/src/corelib/kernel/qobject.cpp
+@@ -1010,7 +1010,7 @@ QObject::~QObject()
+         emit destroyed(this);
+     }
+ 
+-    if (d->declarativeData) {
++    if (!d->isDeletingChildren && d->declarativeData) {
+         if (static_cast<QAbstractDeclarativeDataImpl*>(d->declarativeData)->ownedByQml1) {
+             if (QAbstractDeclarativeData::destroyed_qml1)
+                 QAbstractDeclarativeData::destroyed_qml1(d->declarativeData, this);
+@@ -1580,7 +1580,7 @@ void QObject::moveToThread(QThread *targetThread)
+ 
+     QThreadData *currentData = QThreadData::current();
+     QThreadData *targetData = targetThread ? QThreadData::get2(targetThread) : nullptr;
+-    QThreadData *thisThreadData = d->threadData.loadRelaxed();
++    QThreadData *thisThreadData = d->threadData.loadAcquire();
+     if (!thisThreadData->thread.loadAcquire() && currentData == targetData) {
+         // one exception to the rule: we allow moving objects with no thread affinity to the current thread
+         currentData = d->threadData;
+@@ -2620,7 +2620,7 @@ int QObject::receivers(const char *signal) const
+         if (!d->isSignalConnected(signal_index))
+             return receivers;
+ 
+-        if (d->declarativeData && QAbstractDeclarativeData::receivers) {
++        if (!d->isDeletingChildren && d->declarativeData && QAbstractDeclarativeData::receivers) {
+             receivers += QAbstractDeclarativeData::receivers(d->declarativeData, this,
+                                                              signal_index);
+         }
+diff --git a/qtbase/src/corelib/kernel/qobject_p.h b/qtbase/src/corelib/kernel/qobject_p.h
+index 0b827a52ca..13ffb88999 100644
+--- a/qtbase/src/corelib/kernel/qobject_p.h
++++ b/qtbase/src/corelib/kernel/qobject_p.h
+@@ -444,7 +444,7 @@ inline void QObjectPrivate::checkForIncompatibleLibraryVersion(int version) cons
+ 
+ inline bool QObjectPrivate::isDeclarativeSignalConnected(uint signal_index) const
+ {
+-    return declarativeData && QAbstractDeclarativeData::isSignalConnected
++    return !isDeletingChildren && declarativeData && QAbstractDeclarativeData::isSignalConnected
+             && QAbstractDeclarativeData::isSignalConnected(declarativeData, q_func(), signal_index);
+ }
+ 
+diff --git a/qtbase/src/corelib/kernel/qtranslator.cpp b/qtbase/src/corelib/kernel/qtranslator.cpp
+index 2812ffb7ea..bc0177c5ec 100644
+--- a/qtbase/src/corelib/kernel/qtranslator.cpp
++++ b/qtbase/src/corelib/kernel/qtranslator.cpp
+@@ -902,7 +902,7 @@ static QString getMessage(const uchar *m, const uchar *end, const char *context,
+             goto end;
+         case Tag_Translation: {
+             int len = read32(m);
+-            if (len % 1)
++            if (len & 1)
+                 return QString();
+             m += 4;
+             if (!numerus--) {
+diff --git a/qtbase/src/corelib/mimetypes/qmimedatabase.cpp b/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
+index 9de22cef33..ff868a3268 100644
+--- a/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
+@@ -389,20 +389,23 @@ QMimeType QMimeDatabasePrivate::mimeTypeForFileNameAndData(const QString &fileNa
+         // Disambiguate conflicting extensions (if magic matching found something)
+         if (candidateByData.isValid() && magicAccuracy > 0) {
+             const QString sniffedMime = candidateByData.name();
+-            // If the sniffedMime matches a glob match, use it
++            // If the sniffedMime matches a highest-weight glob match, use it
+             if (candidatesByName.m_matchingMimeTypes.contains(sniffedMime)) {
+                 *accuracyPtr = 100;
+                 return candidateByData;
+             }
+-            for (const QString &m : qAsConst(candidatesByName.m_matchingMimeTypes)) {
++            for (const QString &m : qAsConst(candidatesByName.m_allMatchingMimeTypes)) {
+                 if (inherits(m, sniffedMime)) {
+                     // We have magic + pattern pointing to this, so it's a pretty good match
+                     *accuracyPtr = 100;
+                     return mimeTypeForName(m);
+                 }
+             }
+-            *accuracyPtr = magicAccuracy;
+-            return candidateByData;
++            if (candidatesByName.m_allMatchingMimeTypes.isEmpty()) {
++                // No glob, use magic
++                *accuracyPtr = magicAccuracy;
++                return candidateByData;
++            }
+         }
+     }
+ 
+diff --git a/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp b/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
+index a81112d227..fa8f4c545d 100644
+--- a/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
+@@ -83,7 +83,10 @@ void QMimeGlobMatchResult::addMatch(const QString &mimeType, int weight, const Q
+     }
+     if (!m_matchingMimeTypes.contains(mimeType)) {
+         m_matchingMimeTypes.append(mimeType);
+-        m_allMatchingMimeTypes.append(mimeType);
++        if (replace)
++            m_allMatchingMimeTypes.prepend(mimeType); // highest-weight first
++        else
++            m_allMatchingMimeTypes.append(mimeType);
+         m_knownSuffixLength = knownSuffixLength;
+     }
+ }
+@@ -94,7 +97,7 @@ QMimeGlobPattern::PatternType QMimeGlobPattern::detectPatternType(const QString
+     if (!patternLength)
+         return OtherPattern;
+ 
+-    const bool starCount = pattern.count(QLatin1Char('*')) == 1;
++    const int starCount = pattern.count(QLatin1Char('*'));
+     const bool hasSquareBracket = pattern.indexOf(QLatin1Char('[')) != -1;
+     const bool hasQuestionMark = pattern.indexOf(QLatin1Char('?')) != -1;
+ 
+@@ -106,10 +109,10 @@ QMimeGlobPattern::PatternType QMimeGlobPattern::detectPatternType(const QString
+             // Patterns like "README*" (well this is currently the only one like that...)
+             if (pattern.at(patternLength - 1) == QLatin1Char('*'))
+                 return PrefixPattern;
+-        }
+-        // Names without any wildcards like "README"
+-        if (starCount == 0)
++        } else if (starCount == 0) {
++            // Names without any wildcards like "README"
+             return LiteralPattern;
++        }
+     }
+ 
+     if (pattern == QLatin1String("[0-9][0-9][0-9].vdr"))
+diff --git a/qtbase/src/corelib/mimetypes/qmimeprovider.cpp b/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
+index 258dddf8cb..4642d0f2d0 100644
+--- a/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
+@@ -244,15 +244,18 @@ void QMimeBinaryProvider::addFileNameMatches(const QString &fileName, QMimeGlobM
+     const QString lowerFileName = fileName.toLower();
+     // Check literals (e.g. "Makefile")
+     matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosLiteralListOffset), fileName);
+-    // Check complex globs (e.g. "callgrind.out[0-9]*")
+-    matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosGlobListOffset), fileName);
+     // Check the very common *.txt cases with the suffix tree
+-    const int reverseSuffixTreeOffset = m_cacheFile->getUint32(PosReverseSuffixTreeOffset);
+-    const int numRoots = m_cacheFile->getUint32(reverseSuffixTreeOffset);
+-    const int firstRootOffset = m_cacheFile->getUint32(reverseSuffixTreeOffset + 4);
+-    matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, lowerFileName, lowerFileName.length() - 1, false);
++    if (result.m_matchingMimeTypes.isEmpty()) {
++        const int reverseSuffixTreeOffset = m_cacheFile->getUint32(PosReverseSuffixTreeOffset);
++        const int numRoots = m_cacheFile->getUint32(reverseSuffixTreeOffset);
++        const int firstRootOffset = m_cacheFile->getUint32(reverseSuffixTreeOffset + 4);
++        matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, lowerFileName, lowerFileName.length() - 1, false);
++        if (result.m_matchingMimeTypes.isEmpty())
++            matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, fileName, fileName.length() - 1, true);
++    }
++    // Check complex globs (e.g. "callgrind.out[0-9]*" or "README*")
+     if (result.m_matchingMimeTypes.isEmpty())
+-        matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, fileName, fileName.length() - 1, true);
++        matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosGlobListOffset), fileName);
+ }
+ 
+ void QMimeBinaryProvider::matchGlobList(QMimeGlobMatchResult &result, CacheFile *cacheFile, int off, const QString &fileName)
+diff --git a/qtbase/src/corelib/serialization/qjsonparser.cpp b/qtbase/src/corelib/serialization/qjsonparser.cpp
+index 17e6f111ab..2e40b6c8fb 100644
+--- a/qtbase/src/corelib/serialization/qjsonparser.cpp
++++ b/qtbase/src/corelib/serialization/qjsonparser.cpp
+@@ -379,10 +379,30 @@ error:
+     return QCborValue();
+ }
+ 
++// We need to retain the _last_ value for any duplicate keys and we need to deref containers.
++// Therefore the manual implementation of std::unique().
++template<typename Iterator, typename Compare, typename Assign>
++static Iterator customAssigningUniqueLast(Iterator first, Iterator last,
++                                          Compare compare, Assign assign)
++{
++    first = std::adjacent_find(first, last, compare);
++    if (first == last)
++        return last;
++
++    Iterator result = first;
++    while (++first != last) {
++        if (!compare(*result, *first))
++            ++result;
++        if (result != first)
++            assign(*result, *first);
++    }
++
++    return ++result;
++}
++
+ static void sortContainer(QCborContainerPrivate *container)
+ {
+     using Forward = QJsonPrivate::KeyIterator;
+-    using Reverse = std::reverse_iterator<Forward>;
+     using Value = Forward::value_type;
+ 
+     auto compare = [container](const Value &a, const Value &b)
+@@ -420,17 +440,31 @@ static void sortContainer(QCborContainerPrivate *container)
+         }
+     };
+ 
+-    std::sort(Forward(container->elements.begin()), Forward(container->elements.end()),
+-              [&compare](const Value &a, const Value &b) { return compare(a, b) < 0; });
++    // The elements' containers are owned by the outer container, not by the elements themselves.
++    auto move = [](Forward::reference target, Forward::reference source)
++    {
++        QtCbor::Element &targetValue = target.value();
++
++        // If the target has a container, deref it before overwriting, so that we don't leak.
++        if (targetValue.flags & QtCbor::Element::IsContainer)
++            targetValue.container->deref();
++
++        // Do not move, so that we can clear the value afterwards.
++        target = source;
++
++        // Clear the source value, so that we don't store the same container twice.
++        source.value() = QtCbor::Element();
++    };
++
++    std::stable_sort(
++                Forward(container->elements.begin()), Forward(container->elements.end()),
++                [&compare](const Value &a, const Value &b) { return compare(a, b) < 0; });
+ 
+-    // We need to retain the _last_ value for any duplicate keys. Therefore the reverse dance here.
+-    auto it = std::unique(Reverse(container->elements.end()), Reverse(container->elements.begin()),
+-                          [&compare](const Value &a, const Value &b) {
+-        return compare(a, b) == 0;
+-    }).base().elementsIterator();
++    Forward result = customAssigningUniqueLast(
++                Forward(container->elements.begin()),  Forward(container->elements.end()),
++                [&compare](const Value &a, const Value &b) { return compare(a, b) == 0; }, move);
+ 
+-    // The erase from beginning is expensive but hopefully rare.
+-    container->elements.erase(container->elements.begin(), it);
++    container->elements.erase(result.elementsIterator(), container->elements.end());
+ }
+ 
+ 
+diff --git a/qtbase/src/corelib/serialization/qxmlstream.cpp b/qtbase/src/corelib/serialization/qxmlstream.cpp
+index b2f846544d..7cd457ba3a 100644
+--- a/qtbase/src/corelib/serialization/qxmlstream.cpp
++++ b/qtbase/src/corelib/serialization/qxmlstream.cpp
+@@ -980,7 +980,7 @@ inline uint QXmlStreamReaderPrivate::peekChar()
+ bool QXmlStreamReaderPrivate::scanUntil(const char *str, short tokenToInject)
+ {
+     int pos = textBuffer.size();
+-    int oldLineNumber = lineNumber;
++    const auto oldLineNumber = lineNumber;
+ 
+     uint c;
+     while ((c = getChar()) != StreamEOF) {
+diff --git a/qtbase/src/corelib/text/qstring.cpp b/qtbase/src/corelib/text/qstring.cpp
+index 3e88ab4859..8deeae47bb 100644
+--- a/qtbase/src/corelib/text/qstring.cpp
++++ b/qtbase/src/corelib/text/qstring.cpp
+@@ -12312,7 +12312,7 @@ static qsizetype qLastIndexOf(Haystack haystack0, qsizetype from,
+     const auto needle = needle0.data();
+     const auto *end = haystack;
+     haystack += from;
+-    const std::size_t sl_minus_1 = sl - 1;
++    const std::size_t sl_minus_1 = sl ? sl - 1 : 0;
+     const auto *n = needle + sl_minus_1;
+     const auto *h = haystack + sl_minus_1;
+     std::size_t hashNeedle = 0, hashHaystack = 0;
+diff --git a/qtbase/src/corelib/text/qstringiterator_p.h b/qtbase/src/corelib/text/qstringiterator_p.h
+index 219589b6e4..1d0c66cc78 100644
+--- a/qtbase/src/corelib/text/qstringiterator_p.h
++++ b/qtbase/src/corelib/text/qstringiterator_p.h
+@@ -61,6 +61,8 @@ class QStringIterator
+ {
+     QString::const_iterator i, pos, e;
+     Q_STATIC_ASSERT((std::is_same<QString::const_iterator, const QChar *>::value));
++    static bool less(const QChar *lhs, const QChar *rhs) noexcept
++    { return std::less<QString::const_iterator>{}(lhs, rhs); }
+ public:
+     explicit QStringIterator(QStringView string, qsizetype idx = 0)
+         : i(string.begin()),
+@@ -95,7 +97,8 @@ public:
+ 
+     inline void setPosition(QString::const_iterator position)
+     {
+-        Q_ASSERT_X(i <= position && position <= e, Q_FUNC_INFO, "position out of bounds");
++        Q_ASSERT_X(!less(position, i) && !less(e, position),
++                   Q_FUNC_INFO, "position out of bounds");
+         pos = position;
+     }
+ 
+@@ -103,7 +106,7 @@ public:
+ 
+     inline bool hasNext() const
+     {
+-        return pos < e;
++        return less(pos, e);
+     }
+ 
+     inline void advance()
+@@ -120,16 +123,20 @@ public:
+     {
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+-        if (Q_UNLIKELY((pos++)->isHighSurrogate()))
++        if (Q_UNLIKELY((pos++)->isHighSurrogate())) {
++            Q_ASSERT(hasNext() && pos->isLowSurrogate());
+             ++pos;
++        }
+     }
+ 
+     inline uint peekNextUnchecked() const
+     {
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+-        if (Q_UNLIKELY(pos->isHighSurrogate()))
++        if (Q_UNLIKELY(pos->isHighSurrogate())) {
++            Q_ASSERT(less(pos + 1, e) && pos[1].isLowSurrogate());
+             return QChar::surrogateToUcs4(pos[0], pos[1]);
++        }
+ 
+         return pos->unicode();
+     }
+@@ -155,8 +162,10 @@ public:
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+         const QChar cur = *pos++;
+-        if (Q_UNLIKELY(cur.isHighSurrogate()))
++        if (Q_UNLIKELY(cur.isHighSurrogate())) {
++            Q_ASSERT(hasNext() && pos->isLowSurrogate());
+             return QChar::surrogateToUcs4(cur, *pos++);
++        }
+         return cur.unicode();
+     }
+ 
+@@ -166,7 +175,7 @@ public:
+ 
+         const QChar uc = *pos++;
+         if (Q_UNLIKELY(uc.isSurrogate())) {
+-            if (Q_LIKELY(uc.isHighSurrogate() && pos < e && pos->isLowSurrogate()))
++            if (Q_LIKELY(uc.isHighSurrogate() && hasNext() && pos->isLowSurrogate()))
+                 return QChar::surrogateToUcs4(uc, *pos++);
+             return invalidAs;
+         }
+@@ -178,7 +187,7 @@ public:
+ 
+     inline bool hasPrevious() const
+     {
+-        return pos > i;
++        return less(i, pos);
+     }
+ 
+     inline void recede()
+@@ -196,16 +205,20 @@ public:
+     {
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+-        if (Q_UNLIKELY((--pos)->isLowSurrogate()))
++        if (Q_UNLIKELY((--pos)->isLowSurrogate())) {
++            Q_ASSERT(hasPrevious() && pos[-1].isHighSurrogate());
+             --pos;
++        }
+     }
+ 
+     inline uint peekPreviousUnchecked() const
+     {
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+-        if (Q_UNLIKELY(pos[-1].isLowSurrogate()))
++        if (Q_UNLIKELY(pos[-1].isLowSurrogate())) {
++            Q_ASSERT(less(i + 1, pos) && pos[-2].isHighSurrogate());
+             return QChar::surrogateToUcs4(pos[-2], pos[-1]);
++        }
+         return pos[-1].unicode();
+     }
+ 
+@@ -230,8 +243,10 @@ public:
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+         const QChar cur = *--pos;
+-        if (Q_UNLIKELY(cur.isLowSurrogate()))
++        if (Q_UNLIKELY(cur.isLowSurrogate())) {
++            Q_ASSERT(hasPrevious() && pos[-1].isHighSurrogate());
+             return QChar::surrogateToUcs4(*--pos, cur);
++        }
+         return cur.unicode();
+     }
+ 
+@@ -241,7 +256,7 @@ public:
+ 
+         const QChar uc = *--pos;
+         if (Q_UNLIKELY(uc.isSurrogate())) {
+-            if (Q_LIKELY(uc.isLowSurrogate() && pos > i && pos[-1].isHighSurrogate()))
++            if (Q_LIKELY(uc.isLowSurrogate() && hasPrevious() && pos[-1].isHighSurrogate()))
+                 return QChar::surrogateToUcs4(*--pos, uc);
+             return invalidAs;
+         }
+diff --git a/qtbase/src/corelib/thread/qfutex_p.h b/qtbase/src/corelib/thread/qfutex_p.h
+index f287b752d7..e294537787 100644
+--- a/qtbase/src/corelib/thread/qfutex_p.h
++++ b/qtbase/src/corelib/thread/qfutex_p.h
+@@ -52,6 +52,7 @@
+ //
+ 
+ #include <qglobal.h>
++#include <QtCore/qtsan_impl.h>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -106,16 +107,13 @@ namespace QtLinuxFutex {
+     inline int _q_futex(int *addr, int op, int val, quintptr val2 = 0,
+                         int *addr2 = nullptr, int val3 = 0) noexcept
+     {
+-        // A futex call ensures total ordering on the futex words
+-        // (in either success or failure of the call). Instruct TSAN accordingly,
+-        // as TSAN does not understand the futex(2) syscall.
+-        _q_tsan_release(addr, addr2);
++        QtTsan::futexRelease(addr, addr2);
+ 
+         // we use __NR_futex because some libcs (like Android's bionic) don't
+         // provide SYS_futex etc.
+         int result = syscall(__NR_futex, addr, op | FUTEX_PRIVATE_FLAG, val, val2, addr2, val3);
+ 
+-        _q_tsan_acquire(addr, addr2);
++        QtTsan::futexAcquire(addr, addr2);
+ 
+         return result;
+     }
+diff --git a/qtbase/src/corelib/thread/qmutex.cpp b/qtbase/src/corelib/thread/qmutex.cpp
+index 310d1cb14f..7097122d8e 100644
+--- a/qtbase/src/corelib/thread/qmutex.cpp
++++ b/qtbase/src/corelib/thread/qmutex.cpp
+@@ -152,6 +152,7 @@ public:
+ 
+ /*!
+     \enum QMutex::RecursionMode
++    \obsolete Use QRecursiveMutex to create a recursive mutex.
+ 
+     \value Recursive  In this mode, a thread can lock the same mutex
+                       multiple times and the mutex won't be unlocked
+@@ -173,6 +174,7 @@ public:
+ 
+ /*!
+     Constructs a new mutex. The mutex is created in an unlocked state.
++    \obsolete Use QRecursiveMutex to create a recursive mutex.
+ 
+     If \a mode is QMutex::Recursive, a thread can lock the same mutex
+     multiple times and the mutex won't be unlocked until a
+@@ -197,7 +199,7 @@ QMutex::QMutex(RecursionMode mode)
+ QMutex::~QMutex()
+ {
+     QMutexData *d = d_ptr.loadRelaxed();
+-    if (isRecursive()) {
++    if (QBasicMutex::isRecursive()) {
+         delete static_cast<QRecursiveMutexPrivate *>(d);
+     } else if (d) {
+ #ifndef QT_LINUX_FUTEX
+diff --git a/qtbase/src/corelib/thread/qmutex.h b/qtbase/src/corelib/thread/qmutex.h
+index 73c9e00663..1bae573a03 100644
+--- a/qtbase/src/corelib/thread/qmutex.h
++++ b/qtbase/src/corelib/thread/qmutex.h
+@@ -42,6 +42,7 @@
+ 
+ #include <QtCore/qglobal.h>
+ #include <QtCore/qatomic.h>
++#include <QtCore/qtsan_impl.h>
+ #include <new>
+ 
+ #if __has_include(<chrono>)
+@@ -77,19 +78,37 @@ public:
+ 
+     // BasicLockable concept
+     inline void lock() QT_MUTEX_LOCK_NOEXCEPT {
++        QtTsan::mutexPreLock(this, 0u);
++
+         if (!fastTryLock())
+             lockInternal();
++
++        QtTsan::mutexPostLock(this, 0u, 0);
+     }
+ 
+     // BasicLockable concept
+     inline void unlock() noexcept {
+         Q_ASSERT(d_ptr.loadRelaxed()); //mutex must be locked
++
++        QtTsan::mutexPreUnlock(this, 0u);
++
+         if (!fastTryUnlock())
+             unlockInternal();
++
++        QtTsan::mutexPostUnlock(this, 0u);
+     }
+ 
+     bool tryLock() noexcept {
+-        return fastTryLock();
++        unsigned tsanFlags = QtTsan::TryLock;
++        QtTsan::mutexPreLock(this, tsanFlags);
++
++        const bool success = fastTryLock();
++
++        if (!success)
++            tsanFlags |= QtTsan::TryLockFailed;
++        QtTsan::mutexPostLock(this, tsanFlags, 0);
++
++        return success;
+     }
+ 
+     // Lockable concept
+@@ -134,8 +153,16 @@ public:
+ #else
+     QMutex() { d_ptr.storeRelaxed(nullptr); }
+ #endif
++#if QT_DEPRECATED_SINCE(5,15)
+     enum RecursionMode { NonRecursive, Recursive };
++    QT_DEPRECATED_VERSION_X(5, 15, "Use QRecursiveMutex instead of a recursive QMutex")
+     explicit QMutex(RecursionMode mode);
++
++    QT_DEPRECATED_VERSION_X(5, 15, "Use QRecursiveMutex instead of a recursive QMutex")
++    bool isRecursive() const noexcept
++    { return QBasicMutex::isRecursive(); }
++#endif
++
+     ~QMutex();
+ 
+     // BasicLockable concept
+@@ -166,9 +193,6 @@ public:
+     }
+ #endif
+ 
+-    bool isRecursive() const noexcept
+-    { return QBasicMutex::isRecursive(); }
+-
+ private:
+     Q_DISABLE_COPY(QMutex)
+     friend class QMutexLocker;
+diff --git a/qtbase/src/corelib/thread/qreadwritelock.cpp b/qtbase/src/corelib/thread/qreadwritelock.cpp
+index 8c28507d5a..9dd8503116 100644
+--- a/qtbase/src/corelib/thread/qreadwritelock.cpp
++++ b/qtbase/src/corelib/thread/qreadwritelock.cpp
+@@ -155,7 +155,7 @@ QReadWriteLock::QReadWriteLock(RecursionMode recursionMode)
+ */
+ QReadWriteLock::~QReadWriteLock()
+ {
+-    auto d = d_ptr.loadRelaxed();
++    auto d = d_ptr.loadAcquire();
+     if (isUncontendedLocked(d)) {
+         qWarning("QReadWriteLock: destroying locked QReadWriteLock");
+         return;
+@@ -445,7 +445,7 @@ void QReadWriteLock::unlock()
+ /*! \internal  Helper for QWaitCondition::wait */
+ QReadWriteLock::StateForWaitCondition QReadWriteLock::stateForWaitCondition() const
+ {
+-    QReadWriteLockPrivate *d = d_ptr.loadRelaxed();
++    QReadWriteLockPrivate *d = d_ptr.loadAcquire();
+     switch (quintptr(d) & StateMask) {
+     case StateLockedForRead: return LockedForRead;
+     case StateLockedForWrite: return LockedForWrite;
+@@ -453,6 +453,7 @@ QReadWriteLock::StateForWaitCondition QReadWriteLock::stateForWaitCondition() co
+ 
+     if (!d)
+         return Unlocked;
++    const auto lock = qt_scoped_lock(d->mutex);
+     if (d->writerCount > 1)
+         return RecursivelyLocked;
+     else if (d->writerCount == 1)
+diff --git a/qtbase/src/corelib/thread/qsemaphore.cpp b/qtbase/src/corelib/thread/qsemaphore.cpp
+index 1d01fc1b28..3ecdee3747 100644
+--- a/qtbase/src/corelib/thread/qsemaphore.cpp
++++ b/qtbase/src/corelib/thread/qsemaphore.cpp
+@@ -354,7 +354,12 @@ void QSemaphore::release(int n)
+         quintptr nn = unsigned(n);
+         if (futexHasWaiterCount)
+             nn |= quint64(nn) << 32;    // token count replicated in high word
+-        quintptr prevValue = u.fetchAndAddRelease(nn);
++        quintptr prevValue = u.loadRelaxed();
++        quintptr newValue;
++        do { // loop just to ensure the operations are done atomically
++            newValue = prevValue + nn;
++            newValue &= (futexNeedsWakeAllBit - 1);
++        } while (!u.testAndSetRelease(prevValue, newValue, prevValue));
+         if (futexNeedsWake(prevValue)) {
+ #ifdef FUTEX_OP
+             if (futexHasWaiterCount) {
+@@ -376,7 +381,6 @@ void QSemaphore::release(int n)
+                 quint32 oparg = 0;
+                 quint32 cmp = FUTEX_OP_CMP_NE;
+                 quint32 cmparg = 0;
+-                u.fetchAndAndRelease(futexNeedsWakeAllBit - 1);
+                 futexWakeOp(*futexLow32(&u), n, INT_MAX, *futexHigh32(&u), FUTEX_OP(op, oparg, cmp, cmparg));
+                 return;
+             }
+@@ -388,7 +392,6 @@ 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(futexNeedsWakeAllBit - 1);
+             if (futexHasWaiterCount) {
+                 futexWakeAll(*futexLow32(&u));
+                 futexWakeAll(*futexHigh32(&u));
+diff --git a/qtbase/src/corelib/thread/qthread_p.h b/qtbase/src/corelib/thread/qthread_p.h
+index b2d1628e6e..f32f6f0460 100644
+--- a/qtbase/src/corelib/thread/qthread_p.h
++++ b/qtbase/src/corelib/thread/qthread_p.h
+@@ -174,7 +174,7 @@ public:
+     int returnCode;
+ 
+     uint stackSize;
+-    QThread::Priority priority;
++    std::underlying_type<QThread::Priority>::type priority;
+ 
+     static QThread *threadForId(int id);
+ 
+@@ -213,6 +213,13 @@ public:
+             QCoreApplication::instance()->postEvent(q_ptr, new QEvent(QEvent::Quit));
+         }
+     }
++
++#ifndef Q_OS_INTEGRITY
++private:
++    // Used in QThread(Private)::start to avoid racy access to QObject::objectName,
++    // unset afterwards. On INTEGRITY we set the thread name before starting it.
++    QString objectName;
++#endif
+ };
+ 
+ #else // QT_CONFIG(thread)
+diff --git a/qtbase/src/corelib/thread/qthread_unix.cpp b/qtbase/src/corelib/thread/qthread_unix.cpp
+index 56a8e0a038..610117a640 100644
+--- a/qtbase/src/corelib/thread/qthread_unix.cpp
++++ b/qtbase/src/corelib/thread/qthread_unix.cpp
+@@ -169,8 +169,7 @@ static void set_thread_data(QThreadData *data)
+ 
+ static void clear_thread_data()
+ {
+-    currentThreadData = nullptr;
+-    pthread_setspecific(current_thread_data_key, nullptr);
++    set_thread_data(nullptr);
+ }
+ 
+ template <typename T>
+@@ -296,7 +295,7 @@ void *QThreadPrivate::start(void *arg)
+             QMutexLocker locker(&thr->d_func()->mutex);
+ 
+             // do we need to reset the thread priority?
+-            if (int(thr->d_func()->priority) & ThreadPriorityResetFlag) {
++            if (thr->d_func()->priority & ThreadPriorityResetFlag) {
+                 thr->d_func()->setPriority(QThread::Priority(thr->d_func()->priority & ~ThreadPriorityResetFlag));
+             }
+ 
+@@ -316,10 +315,10 @@ void *QThreadPrivate::start(void *arg)
+             // Sets the name of the current thread. We can only do this
+             // when the thread is starting, as we don't have a cross
+             // platform way of setting the name of an arbitrary thread.
+-            if (Q_LIKELY(thr->objectName().isEmpty()))
++            if (Q_LIKELY(thr->d_func()->objectName.isEmpty()))
+                 setCurrentThreadName(thr->metaObject()->className());
+             else
+-                setCurrentThreadName(thr->objectName().toLocal8Bit());
++                setCurrentThreadName(std::exchange(thr->d_func()->objectName, {}).toLocal8Bit());
+         }
+ #endif
+ 
+@@ -671,7 +670,7 @@ void QThread::start(Priority priority)
+                 // could not set scheduling hints, fallback to inheriting them
+                 // we'll try again from inside the thread
+                 pthread_attr_setinheritsched(&attr, PTHREAD_INHERIT_SCHED);
+-                d->priority = Priority(priority | ThreadPriorityResetFlag);
++                d->priority = static_cast<std::underlying_type<QThread::Priority>::type>(priority) | ThreadPriorityResetFlag;
+             }
+             break;
+         }
+@@ -702,7 +701,10 @@ void QThread::start(Priority priority)
+         pthread_attr_setthreadname(&attr, metaObject()->className());
+     else
+         pthread_attr_setthreadname(&attr, objectName().toLocal8Bit());
++#else
++    d->objectName = objectName();
+ #endif
++
+     pthread_t threadId;
+     int code = pthread_create(&threadId, &attr, QThreadPrivate::start, this);
+     if (code == EPERM) {
+diff --git a/qtbase/src/corelib/thread/qthread_win.cpp b/qtbase/src/corelib/thread/qthread_win.cpp
+index bc70e3178a..4e76972498 100644
+--- a/qtbase/src/corelib/thread/qthread_win.cpp
++++ b/qtbase/src/corelib/thread/qthread_win.cpp
+@@ -394,10 +394,9 @@ unsigned int __stdcall QT_ENSURE_STACK_ALIGNED_FOR_SSE QThreadPrivate::start(voi
+ 
+ #if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) && !defined(Q_OS_WINRT)
+     // sets the name of the current thread.
+-    QByteArray objectName = thr->objectName().toLocal8Bit();
+-    qt_set_thread_name(HANDLE(-1),
+-                       objectName.isEmpty() ?
+-                       thr->metaObject()->className() : objectName.constData());
++    qt_set_thread_name(HANDLE(-1), thr->d_func()->objectName.isEmpty()
++                        ? thr->metaObject()->className()
++                        : std::exchange(thr->d_func()->objectName, {}).toLocal8Bit().constData());
+ #endif
+ 
+     emit thr->started(QThread::QPrivateSignal());
+@@ -503,6 +502,7 @@ void QThread::start(Priority priority)
+     if (d->running)
+         return;
+ 
++    d->objectName = objectName();
+     d->running = true;
+     d->finished = false;
+     d->exited = false;
+@@ -548,7 +548,7 @@ void QThread::start(Priority priority)
+ 
+     int prio;
+     d->priority = priority;
+-    switch (d->priority) {
++    switch (priority) {
+     case IdlePriority:
+         prio = THREAD_PRIORITY_IDLE;
+         break;
+@@ -686,7 +686,7 @@ void QThreadPrivate::setPriority(QThread::Priority threadPriority)
+ 
+     int prio;
+     priority = threadPriority;
+-    switch (priority) {
++    switch (threadPriority) {
+     case QThread::IdlePriority:
+         prio = THREAD_PRIORITY_IDLE;
+         break;
+diff --git a/qtbase/src/corelib/thread/qtsan_impl.h b/qtbase/src/corelib/thread/qtsan_impl.h
+new file mode 100644
+index 0000000000..580a738b91
+--- /dev/null
++++ b/qtbase/src/corelib/thread/qtsan_impl.h
+@@ -0,0 +1,115 @@
++/****************************************************************************
++**
++** Copyright (C) 2017 Intel Corporation.
++** Copyright (C) 2022 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
++** 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 QTSAN_IMPL_H
++#define QTSAN_IMPL_H
++
++#include <QtCore/qglobal.h>
++
++#if (__has_feature(thread_sanitizer) || defined(__SANITIZE_THREAD__)) && __has_include(<sanitizer/tsan_interface.h>)
++#  define QT_BUILDING_UNDER_TSAN
++#  include <sanitizer/tsan_interface.h>
++#endif
++
++QT_BEGIN_NAMESPACE
++
++namespace QtTsan {
++#ifdef QT_BUILDING_UNDER_TSAN
++inline void futexAcquire(void *addr, void *addr2 = nullptr)
++{
++    // A futex call ensures total ordering on the futex words
++    // (in either success or failure of the call). Instruct TSAN accordingly,
++    // as TSAN does not understand the futex(2) syscall (or equivalent).
++    ::__tsan_acquire(addr);
++    if (addr2)
++        ::__tsan_acquire(addr2);
++}
++
++inline void futexRelease(void *addr, void *addr2 = nullptr)
++{
++    if (addr2)
++        ::__tsan_release(addr2);
++    ::__tsan_release(addr);
++}
++
++inline void mutexPreLock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_pre_lock(addr, flags);
++}
++
++inline void mutexPostLock(void *addr, unsigned flags, int recursion)
++{
++    ::__tsan_mutex_post_lock(addr, flags, recursion);
++}
++
++inline void mutexPreUnlock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_pre_unlock(addr, flags);
++}
++
++inline void mutexPostUnlock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_post_unlock(addr, flags);
++}
++
++enum : unsigned {
++    MutexWriteReentrant = ::__tsan_mutex_write_reentrant,
++    TryLock = ::__tsan_mutex_try_lock,
++    TryLockFailed = ::__tsan_mutex_try_lock_failed,
++};
++#else
++inline void futexAcquire(void *, void * = nullptr) {}
++inline void futexRelease(void *, void * = nullptr) {}
++
++enum : unsigned {
++    MutexWriteReentrant,
++    TryLock,
++    TryLockFailed,
++};
++inline void mutexPreLock(void *, unsigned) {}
++inline void mutexPostLock(void *, unsigned, int) {}
++inline void mutexPreUnlock(void *, unsigned) {}
++inline void mutexPostUnlock(void *, unsigned) {}
++#endif // QT_BUILDING_UNDER_TSAN
++} // namespace QtTsan
++
++QT_END_NAMESPACE
++
++#endif // QTSAN_IMPL_H
+diff --git a/qtbase/src/corelib/thread/qwaitcondition_unix.cpp b/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
+index 88b058f410..0f1da4dc9b 100644
+--- a/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
++++ b/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
+@@ -213,7 +213,7 @@ bool QWaitCondition::wait(QMutex *mutex, QDeadlineTimer deadline)
+ {
+     if (! mutex)
+         return false;
+-    if (mutex->isRecursive()) {
++    if (static_cast<QBasicMutex *>(mutex)->isRecursive()) {
+         qWarning("QWaitCondition: cannot wait on recursive mutexes");
+         return false;
+     }
+diff --git a/qtbase/src/corelib/time/qdatetime.cpp b/qtbase/src/corelib/time/qdatetime.cpp
+index ec12569e3f..2c0b098079 100644
+--- a/qtbase/src/corelib/time/qdatetime.cpp
++++ b/qtbase/src/corelib/time/qdatetime.cpp
+@@ -43,6 +43,7 @@
+ #if QT_CONFIG(datetimeparser)
+ #include "private/qdatetimeparser_p.h"
+ #endif
++#include <private/qnumeric_p.h>
+ 
+ #include "qdatastream.h"
+ #include "qset.h"
+@@ -1429,9 +1430,11 @@ QDate QDate::addDays(qint64 ndays) const
+     if (isNull())
+         return QDate();
+ 
+-    // Due to limits on minJd() and maxJd() we know that any overflow
+-    // will be invalid and caught by fromJulianDay().
+-    return fromJulianDay(jd + ndays);
++    qint64 r;
++    if (Q_UNLIKELY(add_overflow(jd, ndays, &r)))
++        return QDate();
++    else
++        return fromJulianDay(r);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/corelib/time/qtimezone.cpp b/qtbase/src/corelib/time/qtimezone.cpp
+index 0309e43e52..3d451696a1 100644
+--- a/qtbase/src/corelib/time/qtimezone.cpp
++++ b/qtbase/src/corelib/time/qtimezone.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2013 John Layt <jlayt@kde.org>
++** Copyright (C) 2020 John Layt <jlayt@kde.org>
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtCore module of the Qt Toolkit.
+@@ -975,9 +975,15 @@ QList<QByteArray> QTimeZone::windowsIdToIanaIds(const QByteArray &windowsId,
+ }
+ 
+ #ifndef QT_NO_DATASTREAM
++// Invalid, as an IANA ID: too long, starts with - and has other invalid characters in it
++static inline QString invalidId() { return QStringLiteral("-No Time Zone Specified!"); }
++
+ QDataStream &operator<<(QDataStream &ds, const QTimeZone &tz)
+ {
+-    tz.d->serialize(ds);
++    if (tz.isValid())
++        tz.d->serialize(ds);
++    else
++        ds << invalidId();
+     return ds;
+ }
+ 
+@@ -985,7 +991,9 @@ QDataStream &operator>>(QDataStream &ds, QTimeZone &tz)
+ {
+     QString ianaId;
+     ds >> ianaId;
+-    if (ianaId == QLatin1String("OffsetFromUtc")) {
++    if (ianaId == invalidId()) {
++        tz = QTimeZone();
++    } else if (ianaId == QLatin1String("OffsetFromUtc")) {
+         int utcOffset;
+         QString name;
+         QString abbreviation;
+diff --git a/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp b/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
+index b1611d7ddb..a7a6a72ccf 100644
+--- a/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
++++ b/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
+@@ -42,6 +42,7 @@
+ #include "qtimezone.h"
+ #include "qtimezoneprivate_p.h"
+ #include "private/qlocale_tools_p.h"
++#include "private/qlocking_p.h"
+ 
+ #include <QtCore/QDataStream>
+ #include <QtCore/QDateTime>
+@@ -62,6 +63,10 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++#if QT_CONFIG(icu)
++static QBasicMutex s_icu_mutex;
++#endif
++
+ /*
+     Private
+ 
+@@ -670,6 +675,9 @@ QTzTimeZonePrivate::~QTzTimeZonePrivate()
+ 
+ QTzTimeZonePrivate *QTzTimeZonePrivate::clone() const
+ {
++#if QT_CONFIG(icu)
++    const auto lock = qt_scoped_lock(s_icu_mutex);
++#endif
+     return new QTzTimeZonePrivate(*this);
+ }
+ 
+@@ -913,12 +921,14 @@ QString QTzTimeZonePrivate::displayName(qint64 atMSecsSinceEpoch,
+                                         const QLocale &locale) const
+ {
+ #if QT_CONFIG(icu)
++    auto lock = qt_unique_lock(s_icu_mutex);
+     if (!m_icu)
+         m_icu = new QIcuTimeZonePrivate(m_id);
+     // TODO small risk may not match if tran times differ due to outdated files
+     // TODO Some valid TZ names are not valid ICU names, use translation table?
+     if (m_icu->isValid())
+         return m_icu->displayName(atMSecsSinceEpoch, nameType, locale);
++    lock.unlock();
+ #else
+     Q_UNUSED(nameType)
+     Q_UNUSED(locale)
+@@ -932,12 +942,14 @@ QString QTzTimeZonePrivate::displayName(QTimeZone::TimeType timeType,
+                                         const QLocale &locale) const
+ {
+ #if QT_CONFIG(icu)
++    auto lock = qt_unique_lock(s_icu_mutex);
+     if (!m_icu)
+         m_icu = new QIcuTimeZonePrivate(m_id);
+     // TODO small risk may not match if tran times differ due to outdated files
+     // TODO Some valid TZ names are not valid ICU names, use translation table?
+     if (m_icu->isValid())
+         return m_icu->displayName(timeType, nameType, locale);
++    lock.unlock();
+ #else
+     Q_UNUSED(timeType)
+     Q_UNUSED(nameType)
+diff --git a/qtbase/src/corelib/tools/qarraydata.h b/qtbase/src/corelib/tools/qarraydata.h
+index dcd95924c1..d01739e7e6 100644
+--- a/qtbase/src/corelib/tools/qarraydata.h
++++ b/qtbase/src/corelib/tools/qarraydata.h
+@@ -42,6 +42,7 @@
+ 
+ #include <QtCore/qrefcount.h>
+ #include <string.h>
++#include <cstdint>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -58,14 +59,14 @@ struct Q_CORE_EXPORT QArrayData
+     {
+         Q_ASSERT(size == 0
+                 || offset < 0 || size_t(offset) >= sizeof(QArrayData));
+-        return reinterpret_cast<char *>(this) + offset;
++        return reinterpret_cast<void *> (reinterpret_cast<uintptr_t>(this) + offset);
+     }
+ 
+     const void *data() const
+     {
+         Q_ASSERT(size == 0
+                 || offset < 0 || size_t(offset) >= sizeof(QArrayData));
+-        return reinterpret_cast<const char *>(this) + offset;
++        return reinterpret_cast<void *> (reinterpret_cast<uintptr_t>(this) + offset);
+     }
+ 
+     // This refers to array data mutability, not "header data" represented by
+diff --git a/qtbase/src/corelib/tools/qfreelist_p.h b/qtbase/src/corelib/tools/qfreelist_p.h
+index 5ba23b344b..9974102136 100644
+--- a/qtbase/src/corelib/tools/qfreelist_p.h
++++ b/qtbase/src/corelib/tools/qfreelist_p.h
+@@ -161,7 +161,7 @@ class QFreeList
+                 return i;
+             x -= size;
+         }
+-        Q_ASSERT(false);
++        Q_UNREACHABLE();
+         return -1;
+     }
+ 
+diff --git a/qtbase/src/corelib/tools/qversionnumber.h b/qtbase/src/corelib/tools/qversionnumber.h
+index d43b86ba51..2843f2b043 100644
+--- a/qtbase/src/corelib/tools/qversionnumber.h
++++ b/qtbase/src/corelib/tools/qversionnumber.h
+@@ -273,10 +273,10 @@ public:
+ 
+     Q_REQUIRED_RESULT Q_CORE_EXPORT QString toString() const;
+ #if QT_STRINGVIEW_LEVEL < 2
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(const QString &string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(const QString &string, int *suffixIndex = nullptr);
+ #endif
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QLatin1String string, int *suffixIndex = nullptr);
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QStringView string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(QLatin1String string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(QStringView string, int *suffixIndex = nullptr);
+ 
+ private:
+ #ifndef QT_NO_DATASTREAM
+diff --git a/qtbase/src/dbus/qdbusintegrator.cpp b/qtbase/src/dbus/qdbusintegrator.cpp
+index 5b66ce971b..28a3b0ffea 100644
+--- a/qtbase/src/dbus/qdbusintegrator.cpp
++++ b/qtbase/src/dbus/qdbusintegrator.cpp
+@@ -1135,7 +1135,13 @@ void QDBusConnectionPrivate::closeConnection()
+         }
+     }
+ 
+-    qDeleteAll(pendingCalls);
++    for (auto it = pendingCalls.begin(); it != pendingCalls.end(); ++it) {
++        auto call = *it;
++        if (!call->ref.deref()) {
++            delete call;
++        }
++    }
++    pendingCalls.clear();
+ 
+     // Disconnect all signals from signal hooks and from the object tree to
+     // avoid QObject::destroyed being sent to dbus daemon thread which has
+@@ -2584,6 +2590,11 @@ QDBusConnectionPrivate::findMetaObject(const QString &service, const QString &pa
+         if (mo)
+             return mo;
+     }
++    if (path.isEmpty()) {
++        error = QDBusError(QDBusError::InvalidObjectPath, QLatin1String("Object path cannot be empty"));
++        lastError = error;
++        return nullptr;
++    }
+ 
+     // introspect the target object
+     QDBusMessage msg = QDBusMessage::createMethodCall(service, path,
+diff --git a/qtbase/src/dbus/qdbusmetaobject.cpp b/qtbase/src/dbus/qdbusmetaobject.cpp
+index 5265568f42..7e9f0f1acc 100644
+--- a/qtbase/src/dbus/qdbusmetaobject.cpp
++++ b/qtbase/src/dbus/qdbusmetaobject.cpp
+@@ -210,6 +210,9 @@ QDBusMetaObjectGenerator::findType(const QByteArray &signature,
+         } else if (signature == "a{ss}") {
+             result.name = "QMap<QString,QString>";
+             type = qMetaTypeId<QMap<QString, QString> >();
++        } else if (signature == "aay") {
++            result.name = "QByteArrayList";
++            type = qMetaTypeId<QByteArrayList>();
+         } else {
+             result.name = "{D-Bus type \"" + signature + "\"}";
+             type = registerComplexDBusType(result.name);
+diff --git a/qtbase/src/gui/accessible/qaccessible.cpp b/qtbase/src/gui/accessible/qaccessible.cpp
+index d705bfccb5..0caf3c808c 100644
+--- a/qtbase/src/gui/accessible/qaccessible.cpp
++++ b/qtbase/src/gui/accessible/qaccessible.cpp
+@@ -54,6 +54,7 @@
+ #include <QtCore/qdebug.h>
+ #include <QtCore/qloggingcategory.h>
+ #include <QtCore/qmetaobject.h>
++#include <QtCore/private/qmetaobject_p.h>
+ #include <QtCore/qhash.h>
+ #include <private/qfactoryloader_p.h>
+ 
+@@ -681,6 +682,25 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
+     // Create a QAccessibleInterface for the object class. Start by the most
+     // derived class and walk up the class hierarchy.
+     const QMetaObject *mo = object->metaObject();
++    const auto *objectPriv = QObjectPrivate::get(object);
++    /*
++     We do not want to cache each and every QML metaobject (Button_QMLTYPE_124,
++     Button_QMLTYPE_125, etc.). Those dynamic metaobjects shouldn't have an
++     accessible interface in any case. Instead, we start the whole checking
++     with the first non-dynamic meta-object. To avoid potential regressions
++     in other areas of Qt that also use dynamic metaobjects, we only do this
++     for objects that are QML-related (approximated by checking whether they
++     have ddata set).
++    */
++    const bool qmlRelated = !objectPriv->isDeletingChildren &&
++                            objectPriv->declarativeData;
++    while (qmlRelated && mo) {
++        auto mop = QMetaObjectPrivate::get(mo);
++        if (!mop || !(mop->flags & DynamicMetaObject))
++            break;
++
++        mo = mo->superClass();
++    };
+     while (mo) {
+         const QString cn = QLatin1String(mo->className());
+ 
+@@ -696,14 +716,15 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
+         // Find a QAccessiblePlugin (factory) for the class name. If there's
+         // no entry in the cache try to create it using the plugin loader.
+         if (!qAccessiblePlugins()->contains(cn)) {
++            QAccessiblePlugin *factory = nullptr; // 0 means "no plugin found". This is cached as well.
+             const int index = loader()->indexOf(cn);
+-            if (index != -1) {
+-                QAccessiblePlugin *factory = qobject_cast<QAccessiblePlugin *>(loader()->instance(index));
+-                qAccessiblePlugins()->insert(cn, factory);
+-            }
++            if (index != -1)
++                factory = qobject_cast<QAccessiblePlugin *>(loader()->instance(index));
++            qAccessiblePlugins()->insert(cn, factory);
+         }
+ 
+         // At this point the cache should contain a valid factory pointer or 0:
++        Q_ASSERT(qAccessiblePlugins()->contains(cn));
+         QAccessiblePlugin *factory = qAccessiblePlugins()->value(cn);
+         if (factory) {
+             QAccessibleInterface *result = factory->create(cn, object);
+diff --git a/qtbase/src/gui/configure.json b/qtbase/src/gui/configure.json
+index 1f08795c57..12c95742d2 100644
+--- a/qtbase/src/gui/configure.json
++++ b/qtbase/src/gui/configure.json
+@@ -834,7 +834,8 @@
+                     "// embedded devices, are not intended to be used together with X. EGL support",
+                     "// has to be disabled in plugins like xcb in this case since the native display,",
+                     "// window and pixmap types will be different than what an X-based platform",
+-                    "// plugin would expect."
++                    "// plugin would expect.",
++                    "#define USE_X11"
+                 ],
+                 "include": [ "EGL/egl.h", "X11/Xlib.h" ],
+                 "main": [
+diff --git a/qtbase/src/gui/image/qbmphandler.cpp b/qtbase/src/gui/image/qbmphandler.cpp
+index 96f1e8cb1d..0e73bbbdb0 100644
+--- a/qtbase/src/gui/image/qbmphandler.cpp
++++ b/qtbase/src/gui/image/qbmphandler.cpp
+@@ -150,16 +150,42 @@ static QDataStream &operator<<(QDataStream &s, const BMP_INFOHDR &bi)
+     return s;
+ }
+ 
+-static int calc_shift(uint mask)
++static uint calc_shift(uint mask)
+ {
+-    int result = 0;
+-    while (mask && !(mask & 1)) {
++    uint result = 0;
++    while ((mask >= 0x100) || (!(mask & 1) && mask)) {
+         result++;
+         mask >>= 1;
+     }
+     return result;
+ }
+ 
++static uint calc_scale(uint low_mask)
++{
++    uint result = 8;
++    while (low_mask && result) {
++        result--;
++        low_mask >>= 1;
++    }
++    return result;
++}
++
++static inline uint apply_scale(uint value, uint scale)
++{
++    if (!(scale & 0x07)) // return immediately if scale == 8 or 0
++        return value;
++
++    uint filled = 8 - scale;
++    uint result = value << scale;
++
++    do {
++        result |= result >> filled;
++        filled <<= 1;
++    } while (filled < 8);
++
++    return result;
++}
++
+ static bool read_dib_fileheader(QDataStream &s, BMP_FILEHDR &bf)
+ {
+     // read BMP file header
+@@ -222,14 +248,14 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+     uint green_mask = 0;
+     uint blue_mask = 0;
+     uint alpha_mask = 0;
+-    int red_shift = 0;
+-    int green_shift = 0;
+-    int blue_shift = 0;
+-    int alpha_shift = 0;
+-    int red_scale = 0;
+-    int green_scale = 0;
+-    int blue_scale = 0;
+-    int alpha_scale = 0;
++    uint red_shift = 0;
++    uint green_shift = 0;
++    uint blue_shift = 0;
++    uint alpha_shift = 0;
++    uint red_scale = 0;
++    uint green_scale = 0;
++    uint blue_scale = 0;
++    uint alpha_scale = 0;
+ 
+     if (!d->isSequential())
+         d->seek(startpos + BMP_FILEHDR_SIZE + bi.biSize); // goto start of colormap or masks
+@@ -308,19 +334,19 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+         red_shift = calc_shift(red_mask);
+         if (((red_mask >> red_shift) + 1) == 0)
+             return false;
+-        red_scale = 256 / ((red_mask >> red_shift) + 1);
++        red_scale = calc_scale(red_mask >> red_shift);
+         green_shift = calc_shift(green_mask);
+         if (((green_mask >> green_shift) + 1) == 0)
+             return false;
+-        green_scale = 256 / ((green_mask >> green_shift) + 1);
++        green_scale = calc_scale(green_mask >> green_shift);
+         blue_shift = calc_shift(blue_mask);
+         if (((blue_mask >> blue_shift) + 1) == 0)
+             return false;
+-        blue_scale = 256 / ((blue_mask >> blue_shift) + 1);
++        blue_scale = calc_scale(blue_mask >> blue_shift);
+         alpha_shift = calc_shift(alpha_mask);
+         if (((alpha_mask >> alpha_shift) + 1) == 0)
+             return false;
+-        alpha_scale = 256 / ((alpha_mask >> alpha_shift) + 1);
++        alpha_scale = calc_scale(alpha_mask >> alpha_shift);
+     } else if (comp == BMP_RGB && (nbits == 24 || nbits == 32)) {
+         blue_mask = 0x000000ff;
+         green_mask = 0x0000ff00;
+@@ -328,17 +354,15 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+         blue_shift = 0;
+         green_shift = 8;
+         red_shift = 16;
+-        blue_scale = green_scale = red_scale = 1;
++        blue_scale = green_scale = red_scale = 0;
+     } else if (comp == BMP_RGB && nbits == 16) {
+         blue_mask = 0x001f;
+         green_mask = 0x03e0;
+         red_mask = 0x7c00;
+         blue_shift = 0;
+-        green_shift = 2;
+-        red_shift = 7;
+-        red_scale = 1;
+-        green_scale = 1;
+-        blue_scale = 8;
++        green_shift = 5;
++        red_shift = 10;
++        blue_scale = green_scale = red_scale = 3;
+     }
+ 
+ #if 0
+@@ -544,10 +568,10 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+                     c |= *(uchar*)(b+2)<<16;
+                 if (nbits > 24)
+                     c |= *(uchar*)(b+3)<<24;
+-                *p++ = qRgba(((c & red_mask) >> red_shift) * red_scale,
+-                                        ((c & green_mask) >> green_shift) * green_scale,
+-                                        ((c & blue_mask) >> blue_shift) * blue_scale,
+-                                        transp ? ((c & alpha_mask) >> alpha_shift) * alpha_scale : 0xff);
++                *p++ = qRgba(apply_scale((c & red_mask) >> red_shift, red_scale),
++                             apply_scale((c & green_mask) >> green_shift, green_scale),
++                             apply_scale((c & blue_mask) >> blue_shift, blue_scale),
++                             transp ? apply_scale((c & alpha_mask) >> alpha_shift, alpha_scale) : 0xff);
+                 b += nbits/8;
+             }
+         }
+diff --git a/qtbase/src/gui/image/qimage.cpp b/qtbase/src/gui/image/qimage.cpp
+index 7152ac1607..0df772564c 100644
+--- a/qtbase/src/gui/image/qimage.cpp
++++ b/qtbase/src/gui/image/qimage.cpp
+@@ -4694,6 +4694,8 @@ QImage QImage::smoothScaled(int w, int h) const {
+ static QImage rotated90(const QImage &image)
+ {
+     QImage out(image.height(), image.width(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+@@ -4722,6 +4724,8 @@ static QImage rotated180(const QImage &image)
+         return image.mirrored(true, true);
+ 
+     QImage out(image.width(), image.height(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+@@ -4734,6 +4738,8 @@ static QImage rotated180(const QImage &image)
+ static QImage rotated270(const QImage &image)
+ {
+     QImage out(image.height(), image.width(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+diff --git a/qtbase/src/gui/kernel/qcursor.cpp b/qtbase/src/gui/kernel/qcursor.cpp
+index d6ccaff8ed..455088241c 100644
+--- a/qtbase/src/gui/kernel/qcursor.cpp
++++ b/qtbase/src/gui/kernel/qcursor.cpp
+@@ -251,7 +251,8 @@ void QCursor::setPos(QScreen *screen, int x, int y)
+ {
+     if (screen) {
+         if (QPlatformCursor *cursor = screen->handle()->cursor()) {
+-            const QPoint devicePos = QHighDpi::toNativePixels(QPoint(x, y), screen);
++            const QPoint pos(x, y);
++            const QPoint devicePos = QHighDpi::toNativePixels(pos, screen->virtualSiblingAt(pos));
+             // Need to check, since some X servers generate null mouse move
+             // events, causing looping in applications which call setPos() on
+             // every mouse move event.
+diff --git a/qtbase/src/gui/kernel/qhighdpiscaling.cpp b/qtbase/src/gui/kernel/qhighdpiscaling.cpp
+index 9bbf2773a9..3ac4a4d8b6 100644
+--- a/qtbase/src/gui/kernel/qhighdpiscaling.cpp
++++ b/qtbase/src/gui/kernel/qhighdpiscaling.cpp
+@@ -580,9 +580,8 @@ void QHighDpiScaling::setScreenFactor(QScreen *screen, qreal factor)
+     else
+         qNamedScreenScaleFactors()->insert(name, factor);
+ 
+-    // hack to force re-evaluation of screen geometry
+     if (screen->handle())
+-        screen->d_func()->setPlatformScreen(screen->handle()); // updates geometries based on scale factor
++        screen->d_func()->updateLogicalDpi();
+ }
+ 
+ QPoint QHighDpiScaling::mapPositionToNative(const QPoint &pos, const QPlatformScreen *platformScreen)
+diff --git a/qtbase/src/gui/kernel/qkeysequence.cpp b/qtbase/src/gui/kernel/qkeysequence.cpp
+index a75b8ef920..4f2d294739 100644
+--- a/qtbase/src/gui/kernel/qkeysequence.cpp
++++ b/qtbase/src/gui/kernel/qkeysequence.cpp
+@@ -701,6 +701,10 @@ static const struct {
+     { Qt::Key_TouchpadToggle,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad Toggle") },
+     { Qt::Key_TouchpadOn,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad On") },
+     { Qt::Key_TouchpadOff,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad Off") },
++    { Qt::Key_Shift,  QT_TRANSLATE_NOOP("QShortcut", "Shift") },
++    { Qt::Key_Control,  QT_TRANSLATE_NOOP("QShortcut", "Control") },
++    { Qt::Key_Alt,  QT_TRANSLATE_NOOP("QShortcut", "Alt") },
++    { Qt::Key_Meta,  QT_TRANSLATE_NOOP("QShortcut", "Meta") },
+ 
+ };
+ static Q_CONSTEXPR int numKeyNames = sizeof keyname / sizeof *keyname;
+diff --git a/qtbase/src/gui/kernel/qplatformservices.cpp b/qtbase/src/gui/kernel/qplatformservices.cpp
+index fdc6a6c4aa..ac47f98c5d 100644
+--- a/qtbase/src/gui/kernel/qplatformservices.cpp
++++ b/qtbase/src/gui/kernel/qplatformservices.cpp
+@@ -55,6 +55,19 @@ QT_BEGIN_NAMESPACE
+     \brief The QPlatformServices provides the backend for desktop-related functionality.
+ */
+ 
++/*!
++    \enum QPlatformServices::Capability
++
++    Capabilities are used to determine a specific platform service's availability.
++
++    \value ColorPickingFromScreen The platform natively supports color picking from screen.
++    This capability indicates that the platform supports "opaque" color picking, where the
++    platform implements a complete user experience for color picking and outputs a color.
++    This is in contrast to the application implementing the color picking user experience
++    (taking care of showing a cross hair, instructing the platform integration to obtain
++    the color at a given pixel, etc.). The related service function is pickColor().
++ */
++
+ QPlatformServices::QPlatformServices()
+ { }
+ 
+@@ -85,5 +98,16 @@ QByteArray QPlatformServices::desktopEnvironment() const
+     return QByteArray("UNKNOWN");
+ }
+ 
++QPlatformServiceColorPicker *QPlatformServices::colorPicker(QWindow *parent)
++{
++    Q_UNUSED(parent);
++    return nullptr;
++}
++
++bool QPlatformServices::hasCapability(Capability capability) const
++{
++    Q_UNUSED(capability)
++    return false;
++}
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/gui/kernel/qplatformservices.h b/qtbase/src/gui/kernel/qplatformservices.h
+index 5de96cfa7d..a8b2a4ce71 100644
+--- a/qtbase/src/gui/kernel/qplatformservices.h
++++ b/qtbase/src/gui/kernel/qplatformservices.h
+@@ -50,16 +50,32 @@
+ //
+ 
+ #include <QtGui/qtguiglobal.h>
++#include <QtCore/qobject.h>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+ class QUrl;
++class QWindow;
++
++class Q_GUI_EXPORT QPlatformServiceColorPicker : public QObject
++{
++    Q_OBJECT
++public:
++    using QObject::QObject;
++    virtual void pickColor() = 0;
++Q_SIGNALS:
++    void colorPicked(const QColor &color);
++};
+ 
+ class Q_GUI_EXPORT QPlatformServices
+ {
+ public:
+     Q_DISABLE_COPY_MOVE(QPlatformServices)
+ 
++    enum Capability {
++        ColorPicking,
++    };
++
+     QPlatformServices();
+     virtual ~QPlatformServices() { }
+ 
+@@ -67,6 +83,10 @@ public:
+     virtual bool openDocument(const QUrl &url);
+ 
+     virtual QByteArray desktopEnvironment() const;
++
++    virtual bool hasCapability(Capability capability) const;
++
++    virtual QPlatformServiceColorPicker *colorPicker(QWindow *parent = nullptr);
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/gui/kernel/qplatformtheme.cpp b/qtbase/src/gui/kernel/qplatformtheme.cpp
+index 71521c0339..2325873245 100644
+--- a/qtbase/src/gui/kernel/qplatformtheme.cpp
++++ b/qtbase/src/gui/kernel/qplatformtheme.cpp
+@@ -163,6 +163,8 @@ QT_BEGIN_NAMESPACE
+ 
+     \value ShowShortcutsInContextMenus (bool) Whether to display shortcut key sequences in context menus.
+ 
++    \value ButtonPressKeys (QList<Qt::Key>) A list of keys that can be used to press buttons via keyboard input.
++
+     \sa themeHint(), QStyle::pixelMetric()
+ */
+ 
+@@ -563,6 +565,8 @@ QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint)
+         }
+     case MouseQuickSelectionThreshold:
+         return QVariant(10);
++    case ButtonPressKeys:
++        return QVariant::fromValue(QList<Qt::Key>({ Qt::Key_Space, Qt::Key_Select }));
+     }
+     return QVariant();
+ }
+diff --git a/qtbase/src/gui/kernel/qplatformtheme.h b/qtbase/src/gui/kernel/qplatformtheme.h
+index 3185fc4541..7e6c9d5740 100644
+--- a/qtbase/src/gui/kernel/qplatformtheme.h
++++ b/qtbase/src/gui/kernel/qplatformtheme.h
+@@ -120,7 +120,8 @@ public:
+         TouchDoubleTapDistance,
+         ShowShortcutsInContextMenus,
+         IconFallbackSearchPaths,
+-        MouseQuickSelectionThreshold
++        MouseQuickSelectionThreshold,
++        ButtonPressKeys
+     };
+ 
+     enum DialogType {
+diff --git a/qtbase/src/gui/kernel/qscreen.cpp b/qtbase/src/gui/kernel/qscreen.cpp
+index 8e0eb35116..5d172a58dd 100644
+--- a/qtbase/src/gui/kernel/qscreen.cpp
++++ b/qtbase/src/gui/kernel/qscreen.cpp
+@@ -77,6 +77,12 @@ QScreen::QScreen(QPlatformScreen *screen)
+     d->setPlatformScreen(screen);
+ }
+ 
++void QScreenPrivate::updateLogicalDpi()
++{
++    logicalDpi = QPlatformScreen::overrideDpi(platformScreen->logicalDpi());
++    updateGeometriesWithSignals(); // updates geometries based on scale factor
++}
++
+ void QScreenPrivate::updateGeometriesWithSignals()
+ {
+     const QRect oldGeometry = geometry;
+diff --git a/qtbase/src/gui/kernel/qscreen_p.h b/qtbase/src/gui/kernel/qscreen_p.h
+index 7da542c25e..e50fc3190b 100644
+--- a/qtbase/src/gui/kernel/qscreen_p.h
++++ b/qtbase/src/gui/kernel/qscreen_p.h
+@@ -70,6 +70,7 @@ public:
+         geometry = platformScreen->deviceIndependentGeometry();
+         availableGeometry = QHighDpi::fromNative(platformScreen->availableGeometry(), QHighDpiScaling::factor(platformScreen), geometry.topLeft());
+     }
++    void updateLogicalDpi();
+ 
+     void updatePrimaryOrientation();
+     void updateGeometriesWithSignals();
+diff --git a/qtbase/src/gui/painting/qblendfunctions_p.h b/qtbase/src/gui/painting/qblendfunctions_p.h
+index 080da98ec4..6997d62b3c 100644
+--- a/qtbase/src/gui/painting/qblendfunctions_p.h
++++ b/qtbase/src/gui/painting/qblendfunctions_p.h
+@@ -246,25 +246,32 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+                                   int dudx, int dvdx, int dudy, int dvdy, int u0, int v0,
+                                   Blender blender)
+ {
+-    int fromY = qMax(qRound(topY), clip.top());
+-    int toY = qMin(qRound(bottomY), clip.top() + clip.height());
++    qint64 fromY = qMax(qRound(topY), clip.top());
++    qint64 toY = qMin(qRound(bottomY), clip.top() + clip.height());
+     if (fromY >= toY)
+         return;
+ 
+     qreal leftSlope = (bottomLeft.x - topLeft.x) / (bottomLeft.y - topLeft.y);
+     qreal rightSlope = (bottomRight.x - topRight.x) / (bottomRight.y - topRight.y);
+-    int dx_l = int(leftSlope * 0x10000);
+-    int dx_r = int(rightSlope * 0x10000);
+-    int x_l = int((topLeft.x + (qreal(0.5) + fromY - topLeft.y) * leftSlope + qreal(0.5)) * 0x10000);
+-    int x_r = int((topRight.x + (qreal(0.5) + fromY - topRight.y) * rightSlope + qreal(0.5)) * 0x10000);
+-
+-    int fromX, toX, x1, x2, u, v, i, ii;
++    qint64 dx_l = qint64(leftSlope * 0x10000);
++    qint64 dx_r = qint64(rightSlope * 0x10000);
++    qint64 x_l = qint64((topLeft.x + (qreal(0.5) + fromY - topLeft.y) * leftSlope + qreal(0.5)) * 0x10000);
++    qint64 x_r = qint64((topRight.x + (qreal(0.5) + fromY - topRight.y) * rightSlope + qreal(0.5)) * 0x10000);
++
++    qint64 sourceRectTop = qint64(sourceRect.top());
++    qint64 sourceRectLeft = qint64(sourceRect.left());
++    qint64 sourceRectWidth = qint64(sourceRect.width());
++    qint64 sourceRectHeight = qint64(sourceRect.height());
++    qint64 clipLeft = qint64(clip.left());
++    qint64 clipWidth = qint64(clip.width());
++
++    qint64 fromX, toX, x1, x2, u, v, i, ii;
+     DestT *line;
+-    for (int y = fromY; y < toY; ++y) {
++    for (qint64 y = fromY; y < toY; ++y) {
+         line = reinterpret_cast<DestT *>(reinterpret_cast<uchar *>(destPixels) + y * dbpl);
+ 
+-        fromX = qMax(x_l >> 16, clip.left());
+-        toX = qMin(x_r >> 16, clip.left() + clip.width());
++        fromX = qMax(x_l >> 16, clipLeft);
++        toX = qMin(x_r >> 16, clipLeft + clipWidth);
+         if (fromX < toX) {
+             // Because of rounding, we can get source coordinates outside the source image.
+             // Clamp these coordinates to the source rect to avoid segmentation fault and
+@@ -275,10 +282,10 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             u = x1 * dudx + y * dudy + u0;
+             v = x1 * dvdx + y * dvdy + v0;
+             for (; x1 < toX; ++x1) {
+-                int uu = u >> 16;
+-                int vv = v >> 16;
+-                if (uu >= sourceRect.left() && uu < sourceRect.left() + sourceRect.width()
+-                    && vv >= sourceRect.top() && vv < sourceRect.top() + sourceRect.height()) {
++                qint64 uu = u >> 16;
++                qint64 vv = v >> 16;
++                if (uu >= sourceRectLeft && uu < sourceRectLeft + sourceRectWidth
++                    && vv >= sourceRectTop && vv < sourceRectTop + sourceRectHeight) {
+                     break;
+                 }
+                 u += dudx;
+@@ -290,10 +297,10 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             u = (x2 - 1) * dudx + y * dudy + u0;
+             v = (x2 - 1) * dvdx + y * dvdy + v0;
+             for (; x2 > x1; --x2) {
+-                int uu = u >> 16;
+-                int vv = v >> 16;
+-                if (uu >= sourceRect.left() && uu < sourceRect.left() + sourceRect.width()
+-                    && vv >= sourceRect.top() && vv < sourceRect.top() + sourceRect.height()) {
++                qint64 uu = u >> 16;
++                qint64 vv = v >> 16;
++                if (uu >= sourceRectLeft && uu < sourceRectLeft + sourceRectWidth
++                    && vv >= sourceRectTop && vv < sourceRectTop + sourceRectHeight) {
+                     break;
+                 }
+                 u -= dudx;
+@@ -308,8 +315,8 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             // Beginning of the scan line, with per-pixel checks.
+             i = x1 - fromX;
+             while (i) {
+-                int uu = qBound(sourceRect.left(), u >> 16, sourceRect.left() + sourceRect.width() - 1);
+-                int vv = qBound(sourceRect.top(), v >> 16, sourceRect.top() + sourceRect.height() - 1);
++                qint64 uu = qBound(sourceRectLeft, u >> 16, sourceRectLeft + sourceRectWidth - 1);
++                qint64 vv = qBound(sourceRectTop, v >> 16, sourceRectTop + sourceRectHeight - 1);
+                 blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + vv * sbpl)[uu]);
+                 u += dudx;
+                 v += dvdx;
+@@ -348,8 +355,8 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             // End of the scan line, with per-pixel checks.
+             i = toX - x2;
+             while (i) {
+-                int uu = qBound(sourceRect.left(), u >> 16, sourceRect.left() + sourceRect.width() - 1);
+-                int vv = qBound(sourceRect.top(), v >> 16, sourceRect.top() + sourceRect.height() - 1);
++                qint64 uu = qBound(sourceRectLeft, u >> 16, sourceRectLeft + sourceRectWidth - 1);
++                qint64 vv = qBound(sourceRectTop, v >> 16, sourceRectTop + sourceRectHeight - 1);
+                 blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + vv * sbpl)[uu]);
+                 u += dudx;
+                 v += dvdx;
+diff --git a/qtbase/src/gui/painting/qcolortrclut_p.h b/qtbase/src/gui/painting/qcolortrclut_p.h
+index 76a6a60803..24fd522e6c 100644
+--- a/qtbase/src/gui/painting/qcolortrclut_p.h
++++ b/qtbase/src/gui/painting/qcolortrclut_p.h
+@@ -118,6 +118,7 @@ public:
+         return QRgba64::fromRgba64(r, g, b, qAlpha(rgb32) * 257);
+ #endif
+     }
++    QRgba64 toLinear64(QRgba64) const = delete;
+ 
+     QRgb toLinear(QRgb rgb32) const
+     {
+diff --git a/qtbase/src/gui/painting/qdrawhelper.cpp b/qtbase/src/gui/painting/qdrawhelper.cpp
+index a61793508a..5ba2d277b7 100644
+--- a/qtbase/src/gui/painting/qdrawhelper.cpp
++++ b/qtbase/src/gui/painting/qdrawhelper.cpp
+@@ -6091,7 +6091,7 @@ static inline void alphargbblend_argb32(quint32 *dst, uint coverage, const QRgba
+ static inline void rgbBlendPixel(QRgba64 &dst, int coverage, QRgba64 slinear, const QColorTrcLut *colorProfile)
+ {
+     // Do a gammacorrected RGB alphablend...
+-    const QRgba64 dlinear = colorProfile ? colorProfile->toLinear64(dst) : dst;
++    const QRgba64 dlinear = colorProfile ? colorProfile->toLinear(dst) : dst;
+ 
+     QRgba64 blend = rgbBlend(dlinear, slinear, coverage);
+ 
+diff --git a/qtbase/src/gui/painting/qpaintengine_raster.cpp b/qtbase/src/gui/painting/qpaintengine_raster.cpp
+index 283923de52..f08eb9cbee 100644
+--- a/qtbase/src/gui/painting/qpaintengine_raster.cpp
++++ b/qtbase/src/gui/painting/qpaintengine_raster.cpp
+@@ -560,31 +560,6 @@ void QRasterPaintEngine::updateMatrix(const QTransform &matrix)
+     QRasterPaintEngineState *s = state();
+     // FALCON: get rid of this line, see drawImage call below.
+     s->matrix = matrix;
+-    QTransform::TransformationType txop = s->matrix.type();
+-
+-    switch (txop) {
+-
+-    case QTransform::TxNone:
+-        s->flags.int_xform = true;
+-        break;
+-
+-    case QTransform::TxTranslate:
+-        s->flags.int_xform = qreal(int(s->matrix.dx())) == s->matrix.dx()
+-                            && qreal(int(s->matrix.dy())) == s->matrix.dy();
+-        break;
+-
+-    case QTransform::TxScale:
+-        s->flags.int_xform = qreal(int(s->matrix.dx())) == s->matrix.dx()
+-                            && qreal(int(s->matrix.dy())) == s->matrix.dy()
+-                            && qreal(int(s->matrix.m11())) == s->matrix.m11()
+-                            && qreal(int(s->matrix.m22())) == s->matrix.m22();
+-        break;
+-
+-    default: // shear / perspective...
+-        s->flags.int_xform = false;
+-        break;
+-    }
+-
+     s->flags.tx_noshear = qt_scaleForTransform(s->matrix, &s->txscale);
+ 
+     ensureOutlineMapper();
+@@ -617,7 +592,6 @@ QRasterPaintEngineState::QRasterPaintEngineState()
+     flags.bilinear = false;
+     flags.legacy_rounding = false;
+     flags.fast_text = true;
+-    flags.int_xform = true;
+     flags.tx_noshear = true;
+     flags.fast_images = true;
+ 
+@@ -1793,7 +1767,7 @@ void QRasterPaintEngine::fill(const QVectorPath &path, const QBrush &brush)
+     QRectF cpRect = path.controlPointRect();
+     const QRectF pathDeviceRect = s->matrix.mapRect(cpRect);
+     // Skip paths that by conservative estimates are completely outside the paint device.
+-    if (!pathDeviceRect.intersects(QRectF(d->deviceRect)))
++    if (!pathDeviceRect.intersects(QRectF(d->deviceRect)) || !pathDeviceRect.isValid())
+         return;
+ 
+     ProcessSpans blend = d->getBrushFunc(pathDeviceRect, &s->brushData);
+diff --git a/qtbase/src/gui/painting/qpaintengine_raster_p.h b/qtbase/src/gui/painting/qpaintengine_raster_p.h
+index 089aadc3f7..bf7363d5aa 100644
+--- a/qtbase/src/gui/painting/qpaintengine_raster_p.h
++++ b/qtbase/src/gui/painting/qpaintengine_raster_p.h
+@@ -111,7 +111,6 @@ public:
+         uint bilinear : 1;
+         uint legacy_rounding : 1;
+         uint fast_text : 1;
+-        uint int_xform : 1;
+         uint tx_noshear : 1;
+         uint fast_images : 1;
+     };
+diff --git a/qtbase/src/gui/painting/qpainterpath.cpp b/qtbase/src/gui/painting/qpainterpath.cpp
+index f9544a3241..d80fafeaf1 100644
+--- a/qtbase/src/gui/painting/qpainterpath.cpp
++++ b/qtbase/src/gui/painting/qpainterpath.cpp
+@@ -1253,7 +1253,7 @@ void QPainterPath::addText(const QPointF &point, const QFont &f, const QString &
+ 
+         if (si.analysis.flags < QScriptAnalysis::TabOrObject) {
+             QGlyphLayout glyphs = eng->shapedGlyphs(&si);
+-            QFontEngine *fe = f.d->engineForScript(si.analysis.script);
++            QFontEngine *fe = eng->fontEngine(si);
+             Q_ASSERT(fe);
+             fe->addOutlineToPath(x, y, glyphs, this,
+                                  si.analysis.bidiLevel % 2
+diff --git a/qtbase/src/gui/painting/qpathclipper_p.h b/qtbase/src/gui/painting/qpathclipper_p.h
+index 9444a87b71..18f64c5e8c 100644
+--- a/qtbase/src/gui/painting/qpathclipper_p.h
++++ b/qtbase/src/gui/painting/qpathclipper_p.h
+@@ -156,7 +156,7 @@ public:
+     int vertex(Direction direction) const;
+ 
+ private:
+-    int m_next[2][2];
++    int m_next[2][2] = { { -1, -1 }, { -1, -1 } };
+ };
+ 
+ class QPathSegments
+@@ -296,10 +296,6 @@ inline QPathEdge::QPathEdge(int a, int b)
+     , angle(0)
+     , invAngle(0)
+ {
+-    m_next[0][0] = -1;
+-    m_next[1][0] = -1;
+-    m_next[0][0] = -1;
+-    m_next[1][0] = -1;
+ }
+ 
+ inline int QPathEdge::next(Traversal traversal, Direction direction) const
+diff --git a/qtbase/src/gui/painting/qpdf.cpp b/qtbase/src/gui/painting/qpdf.cpp
+index 3066744f1b..2c8d3c3b53 100644
+--- a/qtbase/src/gui/painting/qpdf.cpp
++++ b/qtbase/src/gui/painting/qpdf.cpp
+@@ -2760,6 +2760,8 @@ int QPdfEnginePrivate::addBrushPattern(const QTransform &m, bool *specifyColor,
+         return gradientBrush(brush, matrix, gStateObject);
+     }
+ 
++    matrix = brush.transform() * matrix;
++
+     if ((!brush.isOpaque() && brush.style() < Qt::LinearGradientPattern) || opacity != 1.0)
+         *gStateObject = addConstantAlphaObject(qRound(brush.color().alpha() * opacity),
+                                                qRound(pen.color().alpha() * opacity));
+diff --git a/qtbase/src/gui/painting/qstroker.cpp b/qtbase/src/gui/painting/qstroker.cpp
+index cb5d395e80..3b6357a893 100644
+--- a/qtbase/src/gui/painting/qstroker.cpp
++++ b/qtbase/src/gui/painting/qstroker.cpp
+@@ -1182,6 +1182,7 @@ void QDashStroker::processCurrentSubpath()
+         // Check if the entire line should be clipped away or simplified
+         bool clipIt = clipping && !lineIntersectsRect(prev, e, clip_tl, clip_br);
+         bool skipDashing = elen * invSumLength > repetitionLimit();
++        int maxDashes = dashCount;
+         if (skipDashing || clipIt) {
+             // Cut away full dash sequences.
+             elen -= std::floor(elen * invSumLength) * sumLength;
+@@ -1196,7 +1197,7 @@ void QDashStroker::processCurrentSubpath()
+                     pos = estop; // move pos to next path element
+                     done = true;
+                 } else { // Dash is on this line
+-                    pos = dpos + estart;
++                    pos = --maxDashes > 0 ? dpos + estart : estop;
+                     done = pos >= estop;
+                     if (++idash >= dashCount)
+                         idash = 0;
+diff --git a/qtbase/src/gui/painting/qt_attribution.json b/qtbase/src/gui/painting/qt_attribution.json
+index 7b16e8c211..0e87d30aa2 100644
+--- a/qtbase/src/gui/painting/qt_attribution.json
++++ b/qtbase/src/gui/painting/qt_attribution.json
+@@ -10,7 +10,7 @@
+         "Homepage": "http://www.freetype.org",
+         "License": "Freetype Project License or GNU General Public License v2.0 only",
+         "LicenseId": "FTL or GPL-2.0",
+-        "LicenseFile": "../../3rdparty/freetype/docs/LICENSE.TXT",
++        "LicenseFile": "../../3rdparty/freetype/LICENSE.TXT",
+         "Copyright": "Copyright 2000-2016 by David Turner, Robert Wilhelm, and Werner Lemberg."
+     },
+     {
+diff --git a/qtbase/src/gui/rhi/qshader_p_p.h b/qtbase/src/gui/rhi/qshader_p_p.h
+index ec9d25971f..4a5a7a6d51 100644
+--- a/qtbase/src/gui/rhi/qshader_p_p.h
++++ b/qtbase/src/gui/rhi/qshader_p_p.h
+@@ -68,13 +68,13 @@ struct Q_GUI_EXPORT QShaderPrivate
+     {
+     }
+ 
+-    QShaderPrivate(const QShaderPrivate *other)
++    QShaderPrivate(const QShaderPrivate &other)
+         : ref(1),
+-          qsbVersion(other->qsbVersion),
+-          stage(other->stage),
+-          desc(other->desc),
+-          shaders(other->shaders),
+-          bindings(other->bindings)
++          qsbVersion(other.qsbVersion),
++          stage(other.stage),
++          desc(other.desc),
++          shaders(other.shaders),
++          bindings(other.bindings)
+     {
+     }
+ 
+diff --git a/qtbase/src/gui/rhi/qshaderdescription_p_p.h b/qtbase/src/gui/rhi/qshaderdescription_p_p.h
+index ec2b0b6b4c..3da33a8a2b 100644
+--- a/qtbase/src/gui/rhi/qshaderdescription_p_p.h
++++ b/qtbase/src/gui/rhi/qshaderdescription_p_p.h
+@@ -63,16 +63,16 @@ struct Q_GUI_EXPORT QShaderDescriptionPrivate
+         localSize[0] = localSize[1] = localSize[2] = 0;
+     }
+ 
+-    QShaderDescriptionPrivate(const QShaderDescriptionPrivate *other)
++    QShaderDescriptionPrivate(const QShaderDescriptionPrivate &other)
+         : ref(1),
+-          inVars(other->inVars),
+-          outVars(other->outVars),
+-          uniformBlocks(other->uniformBlocks),
+-          pushConstantBlocks(other->pushConstantBlocks),
+-          storageBlocks(other->storageBlocks),
+-          combinedImageSamplers(other->combinedImageSamplers),
+-          storageImages(other->storageImages),
+-          localSize(other->localSize)
++          inVars(other.inVars),
++          outVars(other.outVars),
++          uniformBlocks(other.uniformBlocks),
++          pushConstantBlocks(other.pushConstantBlocks),
++          storageBlocks(other.storageBlocks),
++          combinedImageSamplers(other.combinedImageSamplers),
++          storageImages(other.storageImages),
++          localSize(other.localSize)
+     {
+     }
+ 
+diff --git a/qtbase/src/gui/text/qfontdatabase.cpp b/qtbase/src/gui/text/qfontdatabase.cpp
+index a657a8c516..4fc0100958 100644
+--- a/qtbase/src/gui/text/qfontdatabase.cpp
++++ b/qtbase/src/gui/text/qfontdatabase.cpp
+@@ -983,7 +983,7 @@ QFontEngine *loadSingleEngine(int script,
+         if (style->key.stretch != 0 && request.stretch != 0
+             && (request.styleName.isEmpty() || request.styleName != style->styleName)) {
+             def.stretch = (request.stretch * 100 + style->key.stretch / 2) / style->key.stretch;
+-        } else {
++        } else if (request.stretch == QFont::AnyStretch) {
+             def.stretch = 100;
+         }
+ 
+diff --git a/qtbase/src/gui/text/qtextdocumentlayout.cpp b/qtbase/src/gui/text/qtextdocumentlayout.cpp
+index f3e6ea2100..72267e9380 100644
+--- a/qtbase/src/gui/text/qtextdocumentlayout.cpp
++++ b/qtbase/src/gui/text/qtextdocumentlayout.cpp
+@@ -2123,7 +2123,7 @@ void QTextDocumentLayoutPrivate::drawListItem(const QPointF &offset, QPainter *p
+ {
+     Q_Q(const QTextDocumentLayout);
+     const QTextBlockFormat blockFormat = bl.blockFormat();
+-    const QTextCharFormat charFormat = QTextCursor(bl).charFormat();
++    const QTextCharFormat charFormat = bl.charFormat();
+     QFont font(charFormat.font());
+     if (q->paintDevice())
+         font = QFont(font, q->paintDevice());
+diff --git a/qtbase/src/gui/text/qtextengine.cpp b/qtbase/src/gui/text/qtextengine.cpp
+index ce4abac472..a6c66e5d2d 100644
+--- a/qtbase/src/gui/text/qtextengine.cpp
++++ b/qtbase/src/gui/text/qtextengine.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2021 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtGui module of the Qt Toolkit.
+@@ -1565,6 +1565,12 @@ void QTextEngine::shapeText(int item) const
+         // Overwrite with 0 token to indicate failure
+         QGlyphLayout g = availableGlyphs(&si);
+         g.glyphs[0] = 0;
++        g.attributes[0].clusterStart = true;
++
++        ushort *log_clusters = logClusters(&si);
++        for (int i = 0; i < itemLength; ++i)
++            log_clusters[i] = 0;
++
+         return;
+     }
+ 
+diff --git a/qtbase/src/gui/util/qdesktopservices.cpp b/qtbase/src/gui/util/qdesktopservices.cpp
+index fbb63a9408..4d5fafaaa7 100644
+--- a/qtbase/src/gui/util/qdesktopservices.cpp
++++ b/qtbase/src/gui/util/qdesktopservices.cpp
+@@ -54,6 +54,8 @@
+ #include <qpa/qplatformintegration.h>
+ #include <qdir.h>
+ 
++#include <QtCore/private/qlocking_p.h>
++
+ QT_BEGIN_NAMESPACE
+ 
+ class QOpenUrlHandlerRegistry : public QObject
+@@ -81,6 +83,7 @@ Q_GLOBAL_STATIC(QOpenUrlHandlerRegistry, handlerRegistry)
+ 
+ void QOpenUrlHandlerRegistry::handlerDestroyed(QObject *handler)
+ {
++    const auto lock = qt_scoped_lock(mutex);
+     HandlerHash::Iterator it = handlers.begin();
+     while (it != handlers.end()) {
+         if (it->receiver == handler) {
+@@ -294,7 +297,8 @@ void QDesktopServices::setUrlHandler(const QString &scheme, QObject *receiver, c
+     h.name = method;
+     registry->handlers.insert(scheme.toLower(), h);
+     QObject::connect(receiver, SIGNAL(destroyed(QObject*)),
+-                     registry, SLOT(handlerDestroyed(QObject*)));
++                     registry, SLOT(handlerDestroyed(QObject*)),
++                     Qt::DirectConnection);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/gui/util/qpkmhandler.cpp b/qtbase/src/gui/util/qpkmhandler.cpp
+index e0c3b75efe..3414f9d8ba 100644
+--- a/qtbase/src/gui/util/qpkmhandler.cpp
++++ b/qtbase/src/gui/util/qpkmhandler.cpp
+@@ -57,7 +57,7 @@ struct PkmType
+     quint32 bytesPerBlock;
+ };
+ 
+-static PkmType typeMap[5] = {
++static constexpr PkmType typeMap[5] = {
+     { 0x8D64,  8 },   // GL_ETC1_RGB8_OES
+     { 0x9274,  8 },   // GL_COMPRESSED_RGB8_ETC2
+     { 0, 0 },         // unused (obsolete)
+diff --git a/qtbase/src/network/access/qnetworkreplyfileimpl.cpp b/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
+index b6be93147a..6e69b4c4d3 100644
+--- a/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
++++ b/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
+@@ -89,9 +89,10 @@ QNetworkReplyFileImpl::QNetworkReplyFileImpl(QNetworkAccessManager *manager, con
+         // we handle only local files
+         QString msg = QCoreApplication::translate("QNetworkAccessFileBackend", "Request for opening non-local file %1").arg(url.toString());
+         setError(QNetworkReply::ProtocolInvalidOperationError, msg);
++        setFinished(true); // We're finished, will emit finished() after ctor is done.
+         QMetaObject::invokeMethod(this, "errorOccurred", Qt::QueuedConnection,
+             Q_ARG(QNetworkReply::NetworkError, QNetworkReply::ProtocolInvalidOperationError));
+-        fileOpenFinished(false);
++        QMetaObject::invokeMethod(this, [this](){ fileOpenFinished(false); }, Qt::QueuedConnection);
+         return;
+     }
+ #endif
+diff --git a/qtbase/src/network/access/qnetworkreplyimpl.cpp b/qtbase/src/network/access/qnetworkreplyimpl.cpp
+index bcdf6ee2f1..3b6deb82bd 100644
+--- a/qtbase/src/network/access/qnetworkreplyimpl.cpp
++++ b/qtbase/src/network/access/qnetworkreplyimpl.cpp
+@@ -680,7 +680,7 @@ void QNetworkReplyImplPrivate::appendDownstreamData(QIODevice *data)
+     // read until EOF from data
+     if (Q_UNLIKELY(copyDevice)) {
+         qCritical("QNetworkReplyImpl: copy from QIODevice already in progress -- "
+-                  "backend probly needs to be fixed");
++                  "backend probably needs to be fixed");
+         return;
+     }
+ 
+diff --git a/qtbase/src/network/kernel/qauthenticator.cpp b/qtbase/src/network/kernel/qauthenticator.cpp
+index d9fe7bc47b..ccd04b294a 100644
+--- a/qtbase/src/network/kernel/qauthenticator.cpp
++++ b/qtbase/src/network/kernel/qauthenticator.cpp
+@@ -50,6 +50,7 @@
+ #include <qstring.h>
+ #include <qdatetime.h>
+ #include <qrandom.h>
++#include "private/qsystemlibrary_p.h"
+ 
+ #ifdef Q_OS_WIN
+ #include <qmutex.h>
+@@ -1563,7 +1564,7 @@ static bool q_SSPI_library_load()
+ 
+     // Initialize security interface
+     if (pSecurityFunctionTable == nullptr) {
+-        securityDLLHandle = LoadLibrary(L"secur32.dll");
++        securityDLLHandle = QSystemLibrary::load(L"secur32");
+         if (securityDLLHandle != nullptr) {
+             INIT_SECURITY_INTERFACE pInitSecurityInterface =
+                 reinterpret_cast<INIT_SECURITY_INTERFACE>(
+diff --git a/qtbase/src/network/kernel/qhostinfo_unix.cpp b/qtbase/src/network/kernel/qhostinfo_unix.cpp
+index 9b0a2ee669..73679c9ef1 100644
+--- a/qtbase/src/network/kernel/qhostinfo_unix.cpp
++++ b/qtbase/src/network/kernel/qhostinfo_unix.cpp
+@@ -122,7 +122,6 @@ static QFunctionPointer resolveSymbol(QLibrary &lib, const char *sym)
+ 
+ LibResolv::LibResolv()
+ {
+-    QLibrary lib;
+ #ifdef LIBRESOLV_SO
+     lib.setFileName(QStringLiteral(LIBRESOLV_SO));
+     if (!lib.load())
+diff --git a/qtbase/src/network/socket/qsocks5socketengine.cpp b/qtbase/src/network/socket/qsocks5socketengine.cpp
+index 3a046fd116..97fadca0b3 100644
+--- a/qtbase/src/network/socket/qsocks5socketengine.cpp
++++ b/qtbase/src/network/socket/qsocks5socketengine.cpp
+@@ -1296,7 +1296,7 @@ void QSocks5SocketEnginePrivate::_q_udpSocketReadNotification()
+         int pos = 0;
+         const char *buf = inBuf.constData();
+         if (inBuf.size() < 4) {
+-            QSOCKS5_D_DEBUG << "bugus udp data, discarding";
++            QSOCKS5_D_DEBUG << "bogus udp data, discarding";
+             return;
+         }
+         QSocks5RevivedDatagram datagram;
+diff --git a/qtbase/src/network/ssl/qsslcontext_openssl.cpp b/qtbase/src/network/ssl/qsslcontext_openssl.cpp
+index c9f202f573..c992da9d8e 100644
+--- a/qtbase/src/network/ssl/qsslcontext_openssl.cpp
++++ b/qtbase/src/network/ssl/qsslcontext_openssl.cpp
+@@ -409,7 +409,7 @@ init_context:
+         break;
+     case QSsl::DtlsV1_0OrLater:
+         minVersion = DTLS1_VERSION;
+-        maxVersion = DTLS_MAX_VERSION;
++        maxVersion = 0;
+         break;
+     case QSsl::DtlsV1_2:
+         minVersion = DTLS1_2_VERSION;
+@@ -417,7 +417,7 @@ init_context:
+         break;
+     case QSsl::DtlsV1_2OrLater:
+         minVersion = DTLS1_2_VERSION;
+-        maxVersion = DTLS_MAX_VERSION;
++        maxVersion = 0;
+         break;
+     case QSsl::TlsV1_3OrLater:
+ #ifdef TLS1_3_VERSION
+@@ -455,7 +455,7 @@ init_context:
+     }
+ 
+     // Enable bug workarounds.
+-    long options = QSslSocketBackendPrivate::setupOpenSslOptions(configuration.protocol(), configuration.d->sslOptions);
++    qssloptions options = QSslSocketBackendPrivate::setupOpenSslOptions(configuration.protocol(), configuration.d->sslOptions);
+     q_SSL_CTX_set_options(sslContext->ctx, options);
+ 
+     // Tell OpenSSL to release memory early
+diff --git a/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp b/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
+index aaf8741130..b58935372c 100644
+--- a/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
++++ b/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
+@@ -59,57 +59,6 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-#ifdef OPENSSL_NO_DEPRECATED_3_0
+-
+-static int q_DH_check(DH *dh, int *status)
+-{
+-    // DH_check was first deprecated in OpenSSL 3.0.0, as low-level
+-    // API; the EVP_PKEY family of functions was advised as an alternative.
+-    // As of now EVP_PKEY_params_check ends up calling ... DH_check,
+-    // which is good enough.
+-
+-    Q_ASSERT(dh);
+-    Q_ASSERT(status);
+-
+-    EVP_PKEY *key = q_EVP_PKEY_new();
+-    if (!key) {
+-        qCWarning(lcSsl, "EVP_PKEY_new failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-    const auto keyDeleter = qScopeGuard([key](){
+-        q_EVP_PKEY_free(key);
+-    });
+-    if (!q_EVP_PKEY_set1_DH(key, dh)) {
+-        qCWarning(lcSsl, "EVP_PKEY_set1_DH failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-
+-    EVP_PKEY_CTX *keyCtx = q_EVP_PKEY_CTX_new(key, nullptr);
+-    if (!keyCtx) {
+-        qCWarning(lcSsl, "EVP_PKEY_CTX_new failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-    const auto ctxDeleter = qScopeGuard([keyCtx]{
+-        q_EVP_PKEY_CTX_free(keyCtx);
+-    });
+-
+-    const int result = q_EVP_PKEY_param_check(keyCtx);
+-    QSslSocketBackendPrivate::logAndClearErrorQueue();
+-    // Note: unlike DH_check, we cannot obtain the 'status',
+-    // if the 'result' is 0 (actually the result is 1 only
+-    // if this 'status' was 0). We could probably check the
+-    // errors from the error queue, but it's not needed anyway
+-    // - see the 'isSafeDH' below, how it returns immediately
+-    // on 0.
+-    Q_UNUSED(status)
+-
+-    return result;
+-}
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+-
+ static bool isSafeDH(DH *dh)
+ {
+     int status = 0;
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl.cpp b/qtbase/src/network/ssl/qsslsocket_openssl.cpp
+index 37fad2a68f..8f6858c867 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl.cpp
++++ b/qtbase/src/network/ssl/qsslsocket_openssl.cpp
+@@ -550,9 +550,9 @@ static void q_loadCiphersForConnection(SSL *connection, QList<QSslCipher> &ciphe
+ // Defined in qsslsocket.cpp
+ void q_setDefaultDtlsCiphers(const QList<QSslCipher> &ciphers);
+ 
+-long QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions)
++qssloptions QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions)
+ {
+-    long options;
++    qssloptions options;
+     if (protocol == QSsl::TlsV1SslV3)
+         options = SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3;
+     else if (protocol == QSsl::SecureProtocols)
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_p.h b/qtbase/src/network/ssl/qsslsocket_openssl_p.h
+index 4103de23e8..5547589256 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_p.h
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_p.h
+@@ -107,6 +107,12 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++typedef uint64_t qssloptions;
++#else
++typedef unsigned long qssloptions;
++#endif
++
+ struct QSslErrorEntry {
+     int code;
+     int depth;
+@@ -171,7 +177,7 @@ public:
+     QVector<QSslError> ocspErrors;
+     QByteArray ocspResponseDer;
+ 
+-    Q_AUTOTEST_EXPORT static long setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions);
++    Q_AUTOTEST_EXPORT static qssloptions setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions);
+     static QSslCipher QSslCipher_from_SSL_CIPHER(const SSL_CIPHER *cipher);
+     static QList<QSslCertificate> STACKOFX509_to_QSslCertificates(STACK_OF(X509) *x509);
+     static QList<QSslError> verify(const QList<QSslCertificate> &certificateChain, const QString &hostName);
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp b/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
+index e53fb279f0..459ccd0b19 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
+@@ -148,7 +148,6 @@ DEFINEFUNC(int, EVP_PKEY_up_ref, EVP_PKEY *a, a, return 0, return)
+ DEFINEFUNC2(EVP_PKEY_CTX *, EVP_PKEY_CTX_new, EVP_PKEY *pkey, pkey, ENGINE *e, e, return nullptr, return)
+ DEFINEFUNC(int, EVP_PKEY_param_check, EVP_PKEY_CTX *ctx, ctx, return 0, return)
+ DEFINEFUNC(void, EVP_PKEY_CTX_free, EVP_PKEY_CTX *ctx, ctx, return, return)
+-DEFINEFUNC(int, EVP_PKEY_base_id, EVP_PKEY *a, a, return NID_undef, return)
+ DEFINEFUNC(int, RSA_bits, RSA *a, a, return 0, return)
+ DEFINEFUNC(int, DSA_bits, DSA *a, a, return 0, return)
+ DEFINEFUNC(int, OPENSSL_sk_num, OPENSSL_STACK *a, a, return -1, return)
+@@ -158,7 +157,7 @@ DEFINEFUNC2(void, OPENSSL_sk_push, OPENSSL_STACK *a, a, void *b, b, return, DUMM
+ DEFINEFUNC(void, OPENSSL_sk_free, OPENSSL_STACK *a, a, return, DUMMYARG)
+ DEFINEFUNC2(void *, OPENSSL_sk_value, OPENSSL_STACK *a, a, int b, b, return nullptr, return)
+ DEFINEFUNC(int, SSL_session_reused, SSL *a, a, return 0, return)
+-DEFINEFUNC2(unsigned long, SSL_CTX_set_options, SSL_CTX *ctx, ctx, unsigned long op, op, return 0, return)
++DEFINEFUNC2(qssloptions, SSL_CTX_set_options, SSL_CTX *ctx, ctx, qssloptions op, op, return 0, return)
+ DEFINEFUNC(int, SSL_CTX_get_security_level, const SSL_CTX *ctx, ctx, return -1, return)
+ DEFINEFUNC2(void, SSL_CTX_set_security_level, SSL_CTX *ctx, ctx, int level, level, return, return)
+ #ifdef TLS1_3_VERSION
+@@ -371,7 +370,15 @@ DEFINEFUNC(const SSL_CIPHER *, SSL_get_current_cipher, SSL *a, a, return nullptr
+ DEFINEFUNC(int, SSL_version, const SSL *a, a, return 0, return)
+ DEFINEFUNC2(int, SSL_get_error, SSL *a, a, int b, b, return -1, return)
+ DEFINEFUNC(STACK_OF(X509) *, SSL_get_peer_cert_chain, SSL *a, a, return nullptr, return)
++
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++DEFINEFUNC(X509 *, SSL_get1_peer_certificate, SSL *a, a, return nullptr, return)
++DEFINEFUNC(int, EVP_PKEY_get_base_id, const EVP_PKEY *pkey, pkey, return -1, return)
++#else
+ DEFINEFUNC(X509 *, SSL_get_peer_certificate, SSL *a, a, return nullptr, return)
++DEFINEFUNC(int, EVP_PKEY_base_id, EVP_PKEY *a, a, return NID_undef, return)
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+ DEFINEFUNC(long, SSL_get_verify_result, const SSL *a, a, return -1, return)
+ DEFINEFUNC(SSL *, SSL_new, SSL_CTX *a, a, return nullptr, return)
+ DEFINEFUNC(SSL_CTX *, SSL_get_SSL_CTX, SSL *a, a, return nullptr, return)
+@@ -492,9 +499,7 @@ DEFINEFUNC(DH *, DH_new, DUMMYARG, DUMMYARG, return nullptr, return)
+ DEFINEFUNC(void, DH_free, DH *dh, dh, return, DUMMYARG)
+ DEFINEFUNC3(DH *, d2i_DHparams, DH**a, a, const unsigned char **pp, pp, long length, length, return nullptr, return)
+ DEFINEFUNC2(int, i2d_DHparams, DH *a, a, unsigned char **p, p, return -1, return)
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+ DEFINEFUNC2(int, DH_check, DH *dh, dh, int *codes, codes, return 0, return)
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+ DEFINEFUNC3(BIGNUM *, BN_bin2bn, const unsigned char *s, s, int len, len, BIGNUM *ret, ret, return nullptr, return)
+ 
+ #ifndef OPENSSL_NO_EC
+@@ -868,7 +873,6 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(EVP_PKEY_CTX_new)
+     RESOLVEFUNC(EVP_PKEY_param_check)
+     RESOLVEFUNC(EVP_PKEY_CTX_free)
+-    RESOLVEFUNC(EVP_PKEY_base_id)
+     RESOLVEFUNC(RSA_bits)
+     RESOLVEFUNC(OPENSSL_sk_new_null)
+     RESOLVEFUNC(OPENSSL_sk_push)
+@@ -1107,7 +1111,15 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(SSL_version)
+     RESOLVEFUNC(SSL_get_error)
+     RESOLVEFUNC(SSL_get_peer_cert_chain)
++
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++    RESOLVEFUNC(SSL_get1_peer_certificate)
++    RESOLVEFUNC(EVP_PKEY_get_base_id)
++#else
+     RESOLVEFUNC(SSL_get_peer_certificate)
++    RESOLVEFUNC(EVP_PKEY_base_id)
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+     RESOLVEFUNC(SSL_get_verify_result)
+     RESOLVEFUNC(SSL_new)
+     RESOLVEFUNC(SSL_get_SSL_CTX)
+@@ -1206,9 +1218,7 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(DH_free)
+     RESOLVEFUNC(d2i_DHparams)
+     RESOLVEFUNC(i2d_DHparams)
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+     RESOLVEFUNC(DH_check)
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+     RESOLVEFUNC(BN_bin2bn)
+ 
+ #ifndef OPENSSL_NO_EC
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h b/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
+index 95e8897a3b..27aeffa18a 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
+@@ -237,7 +237,6 @@ Q_AUTOTEST_EXPORT int q_EVP_PKEY_up_ref(EVP_PKEY *a);
+ EVP_PKEY_CTX *q_EVP_PKEY_CTX_new(EVP_PKEY *pkey, ENGINE *e);
+ void q_EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx);
+ int q_EVP_PKEY_param_check(EVP_PKEY_CTX *ctx);
+-int q_EVP_PKEY_base_id(EVP_PKEY *a);
+ int q_RSA_bits(RSA *a);
+ Q_AUTOTEST_EXPORT int q_OPENSSL_sk_num(OPENSSL_STACK *a);
+ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_pop_free(OPENSSL_STACK *a, void (*b)(void *));
+@@ -246,7 +245,7 @@ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_push(OPENSSL_STACK *st, void *data);
+ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_free(OPENSSL_STACK *a);
+ Q_AUTOTEST_EXPORT void * q_OPENSSL_sk_value(OPENSSL_STACK *a, int b);
+ int q_SSL_session_reused(SSL *a);
+-unsigned long q_SSL_CTX_set_options(SSL_CTX *ctx, unsigned long op);
++qssloptions q_SSL_CTX_set_options(SSL_CTX *ctx, qssloptions op);
+ int q_OPENSSL_init_ssl(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings);
+ size_t q_SSL_get_client_random(SSL *a, unsigned char *out, size_t outlen);
+ size_t q_SSL_SESSION_get_master_key(const SSL_SESSION *session, unsigned char *out, size_t outlen);
+@@ -510,7 +509,6 @@ const SSL_CIPHER *q_SSL_get_current_cipher(SSL *a);
+ int q_SSL_version(const SSL *a);
+ int q_SSL_get_error(SSL *a, int b);
+ STACK_OF(X509) *q_SSL_get_peer_cert_chain(SSL *a);
+-X509 *q_SSL_get_peer_certificate(SSL *a);
+ long q_SSL_get_verify_result(const SSL *a);
+ SSL *q_SSL_new(SSL_CTX *a);
+ SSL_CTX *q_SSL_get_SSL_CTX(SSL *a);
+@@ -582,10 +580,7 @@ DH *q_DH_new();
+ void q_DH_free(DH *dh);
+ DH *q_d2i_DHparams(DH **a, const unsigned char **pp, long length);
+ int q_i2d_DHparams(DH *a, unsigned char **p);
+-
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+ int q_DH_check(DH *dh, int *codes);
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+ 
+ BIGNUM *q_BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret);
+ #define q_SSL_CTX_set_tmp_dh(ctx, dh) q_SSL_CTX_ctrl((ctx), SSL_CTRL_SET_TMP_DH, 0, (char *)dh)
+@@ -754,6 +749,17 @@ void q_CRYPTO_free(void *str, const char *file, int line);
+ int q_SSL_CTX_get_security_level(const SSL_CTX *ctx);
+ void q_SSL_CTX_set_security_level(SSL_CTX *ctx, int level);
+ 
++// Here we have the ones that make difference between OpenSSL pre/post v3:
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++X509 *q_SSL_get1_peer_certificate(SSL *a);
++#define q_SSL_get_peer_certificate q_SSL_get1_peer_certificate
++int q_EVP_PKEY_get_base_id(const EVP_PKEY *pkey);
++#define q_EVP_PKEY_base_id q_EVP_PKEY_get_base_id
++#else
++X509 *q_SSL_get_peer_certificate(SSL *a);
++int q_EVP_PKEY_base_id(EVP_PKEY *a);
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+ QT_END_NAMESPACE
+ 
+ #endif
+diff --git a/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h b/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
+index bf37d07fd8..dbd42fb799 100644
+--- a/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
++++ b/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
+@@ -61,7 +61,11 @@
+ # if !defined(Q_OS_INTEGRITY)
+ #  define WIN_INTERFACE_CUSTOM   // NV
+ # endif // Q_OS_INTEGRITY
+-#endif  // QT_EGL_NO_X11
++#else // QT_EGL_NO_X11
++// If one has an eglplatform.h with https://github.com/KhronosGroup/EGL-Registry/pull/130
++// that needs USE_X11 to be defined.
++# define USE_X11
++#endif
+ 
+ #ifdef QT_EGL_WAYLAND
+ # define WAYLAND // NV
+diff --git a/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+index 159b490ce0..00aa80cd58 100644
+--- a/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
++++ b/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+@@ -567,6 +567,8 @@ void QFontconfigDatabase::populateFontDatabase()
+         fonts = FcFontList(nullptr, pattern, os);
+         FcObjectSetDestroy(os);
+         FcPatternDestroy(pattern);
++        if (!fonts)
++            return;
+     }
+ 
+     for (int i = 0; i < fonts->nfont; i++)
+diff --git a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
+index b713c19447..7cb9a8c79a 100644
+--- a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
++++ b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
+@@ -95,6 +95,7 @@ static constexpr const auto KeyTbl = qMakeArray(
+         Xkb2Qt<XKB_KEY_Clear,                   Qt::Key_Delete>,
+         Xkb2Qt<XKB_KEY_Pause,                   Qt::Key_Pause>,
+         Xkb2Qt<XKB_KEY_Print,                   Qt::Key_Print>,
++        Xkb2Qt<XKB_KEY_Sys_Req,                 Qt::Key_SysReq>,
+         Xkb2Qt<0x1005FF60,                      Qt::Key_SysReq>,         // hardcoded Sun SysReq
+         Xkb2Qt<0x1007ff00,                      Qt::Key_SysReq>,         // hardcoded X386 SysReq
+ 
+@@ -471,7 +472,7 @@ QVector<xkb_keysym_t> QXkbCommon::toKeysym(QKeyEvent *event)
+     } else if (event->modifiers() & Qt::KeypadModifier) {
+         if (qtKey >= Qt::Key_0 && qtKey <= Qt::Key_9)
+             keysyms.append(XKB_KEY_KP_0 + (qtKey - Qt::Key_0));
+-    } else if (isLatin(qtKey) && event->text().isUpper()) {
++    } else if (isLatin1(qtKey) && event->text().isUpper()) {
+         keysyms.append(qtKey);
+     }
+ 
+@@ -523,7 +524,7 @@ int QXkbCommon::keysymToQtKey(xkb_keysym_t keysym, Qt::KeyboardModifiers modifie
+         // With standard shortcuts we should prefer a latin character, this is
+         // for checks like "some qkeyevent == QKeySequence::Copy" to work even
+         // when using for example 'russian' keyboard layout.
+-        if (!QXkbCommon::isLatin(keysym)) {
++        if (!QXkbCommon::isLatin1(keysym)) {
+             xkb_keysym_t latinKeysym = QXkbCommon::lookupLatinKeysym(state, code);
+             if (latinKeysym != XKB_KEY_NoSymbol)
+                 keysym = latinKeysym;
+@@ -546,7 +547,7 @@ static int keysymToQtKey_internal(xkb_keysym_t keysym, Qt::KeyboardModifiers mod
+     } else if (keysym >= XKB_KEY_KP_0 && keysym <= XKB_KEY_KP_9) {
+         // numeric keypad keys
+         qtKey = Qt::Key_0 + (keysym - XKB_KEY_KP_0);
+-    } else if (QXkbCommon::isLatin(keysym)) {
++    } else if (QXkbCommon::isLatin1(keysym)) {
+         qtKey = QXkbCommon::qxkbcommon_xkb_keysym_to_upper(keysym);
+     } else {
+         // check if we have a direct mapping
+@@ -678,7 +679,7 @@ QList<int> QXkbCommon::possibleKeys(xkb_state *state, const QKeyEvent *event,
+         Qt::KeyboardModifiers neededMods = ModsTbl[i];
+         if ((modifiers & neededMods) == neededMods) {
+             if (i == 8) {
+-                if (isLatin(baseQtKey))
++                if (isLatin1(baseQtKey))
+                     continue;
+                 // add a latin key as a fall back key
+                 sym = lookupLatinKeysym(state, keycode);
+@@ -733,7 +734,7 @@ void QXkbCommon::verifyHasLatinLayout(xkb_keymap *keymap)
+     for (xkb_layout_index_t layout = 0; layout < layoutCount; ++layout) {
+         for (xkb_keycode_t code = minKeycode; code < maxKeycode; ++code) {
+             xkb_keymap_key_get_syms_by_level(keymap, code, layout, 0, &keysyms);
+-            if (keysyms && isLatin(keysyms[0]))
++            if (keysyms && isLatin1(keysyms[0]))
+                 nrLatinKeys++;
+             if (nrLatinKeys > 10) // arbitrarily chosen threshold
+                 return;
+@@ -766,7 +767,7 @@ xkb_keysym_t QXkbCommon::lookupLatinKeysym(xkb_state *state, xkb_keycode_t keyco
+         xkb_level_index_t level = xkb_state_key_get_level(state, keycode, layout);
+         if (xkb_keymap_key_get_syms_by_level(keymap, keycode, layout, level, &syms) != 1)
+             continue;
+-        if (isLatin(syms[0])) {
++        if (isLatin1(syms[0])) {
+             sym = syms[0];
+             break;
+         }
+diff --git a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
+index 561eae03db..8389bd8f5a 100644
+--- a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
++++ b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
+@@ -94,8 +94,8 @@ public:
+     static void verifyHasLatinLayout(xkb_keymap *keymap);
+     static xkb_keysym_t lookupLatinKeysym(xkb_state *state, xkb_keycode_t keycode);
+ 
+-    static bool isLatin(xkb_keysym_t sym) {
+-        return ((sym >= 'a' && sym <= 'z') || (sym >= 'A' && sym <= 'Z'));
++    static bool isLatin1(xkb_keysym_t sym) {
++        return sym <= 0xff;
+     }
+     static bool isKeypad(xkb_keysym_t sym) {
+         return sym >= XKB_KEY_KP_Space && sym <= XKB_KEY_KP_9;
+diff --git a/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp b/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
+index 8cd7f9b368..406f84663f 100644
+--- a/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
++++ b/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
+@@ -318,7 +318,7 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources,
+ 
+     if (current < 0 && crtc_mode.clock != 0) {
+         modes << crtc_mode;
+-        current = mode.size() - 1;
++        current = modes.size() - 1;
+     }
+ 
+     if (configuration == OutputConfigCurrent)
+diff --git a/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp b/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
+index 9153fd20bb..255ea5e33e 100644
+--- a/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
++++ b/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
+@@ -194,6 +194,9 @@ QString AtSpiAdaptor::introspect(const QString &path) const
+                 "      <arg direction=\"out\" type=\"(so)\"/>\n"
+                 "      <annotation value=\"QSpiObjectReference\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n"
+                 "    </method>\n"
++                "    <method name=\"GetAccessibleId\">\n"
++                "      <arg direction=\"out\" type=\"s\"/>\n"
++                "    </method>\n"
+                 "  </interface>\n"
+                 );
+ 
+@@ -913,8 +916,17 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+     }
+     case QAccessible::NameChanged: {
+         if (sendObject || sendObject_property_change || sendObject_property_change_accessible_name) {
+-            QString path = pathForInterface(event->accessibleInterface());
+-            QVariantList args = packDBusSignalArguments(QLatin1String("accessible-name"), 0, 0, variantForPath(path));
++            QAccessibleInterface *iface = event->accessibleInterface();
++            if (!iface) {
++                qCDebug(lcAccessibilityAtspi,
++                        "NameChanged event from invalid accessible.");
++                return;
++            }
++
++            QString path = pathForInterface(iface);
++            QVariantList args = packDBusSignalArguments(
++                QLatin1String("accessible-name"), 0, 0,
++                QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Name))));
+             sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                            QLatin1String("PropertyChange"), args);
+         }
+@@ -922,8 +934,17 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+     }
+     case QAccessible::DescriptionChanged: {
+         if (sendObject || sendObject_property_change || sendObject_property_change_accessible_description) {
+-            QString path = pathForInterface(event->accessibleInterface());
+-            QVariantList args = packDBusSignalArguments(QLatin1String("accessible-description"), 0, 0, variantForPath(path));
++            QAccessibleInterface *iface = event->accessibleInterface();
++            if (!iface) {
++                qCDebug(lcAccessibilityAtspi,
++                        "DescriptionChanged event from invalid accessible.");
++                return;
++            }
++
++            QString path = pathForInterface(iface);
++            QVariantList args = packDBusSignalArguments(
++                QLatin1String("accessible-description"), 0, 0,
++                QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Description))));
+             sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                            QLatin1String("PropertyChange"), args);
+         }
+@@ -1038,7 +1059,9 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+                 // Combo Box with AT-SPI likes to be special
+                 // It requires a name-change to update caches and then selection-changed
+                 QString path = pathForInterface(iface);
+-                QVariantList args1 = packDBusSignalArguments(QLatin1String("accessible-name"), 0, 0, variantForPath(path));
++                QVariantList args1 = packDBusSignalArguments(
++                    QLatin1String("accessible-name"), 0, 0,
++                    QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Name))));
+                 sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                                QLatin1String("PropertyChange"), args1);
+                 QVariantList args2 = packDBusSignalArguments(QString(), 0, 0, QVariant::fromValue(QDBusVariant(QVariant(0))));
+@@ -1358,6 +1381,26 @@ void AtSpiAdaptor::registerApplication()
+     delete registry;
+ }
+ 
++namespace {
++QString accessibleIdForAccessible(QAccessibleInterface *accessible)
++{
++    QString result;
++    while (accessible) {
++        if (!result.isEmpty())
++            result.prepend(QLatin1Char('.'));
++        if (auto obj = accessible->object()) {
++            const QString name = obj->objectName();
++            if (!name.isEmpty())
++                result.prepend(name);
++            else
++                result.prepend(QString::fromUtf8(obj->metaObject()->className()));
++        }
++        accessible = accessible->parent();
++    }
++    return result;
++}
++} // namespace
++
+ // Accessible
+ bool AtSpiAdaptor::accessibleInterface(QAccessibleInterface *interface, const QString &function, const QDBusMessage &message, const QDBusConnection &connection)
+ {
+@@ -1441,6 +1484,9 @@ bool AtSpiAdaptor::accessibleInterface(QAccessibleInterface *interface, const QS
+             children << ref;
+         }
+         connection.send(message.createReply(QVariant::fromValue(children)));
++    } else if (function == QLatin1String("GetAccessibleId")) {
++        sendReply(connection, message,
++                  QVariant::fromValue(QDBusVariant(accessibleIdForAccessible(interface))));
+     } else {
+         qCDebug(lcAccessibilityAtspi) << "WARNING: AtSpiAdaptor::accessibleInterface does not implement " << function << message.path();
+         return false;
+diff --git a/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp b/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
+index 45ddc8e496..cc734abc63 100644
+--- a/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
++++ b/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
+@@ -69,6 +69,21 @@ QT_BEGIN_NAMESPACE
+ DBusConnection::DBusConnection(QObject *parent)
+     : QObject(parent), m_a11yConnection(QString()), m_enabled(false)
+ {
++    // If the bus is explicitly set via env var it overrides everything else.
++    QByteArray addressEnv = qgetenv("AT_SPI_BUS_ADDRESS");
++    if (!addressEnv.isEmpty()) {
++        // Only connect on next loop run, connections to our enabled signal are
++        // only established after the ctor returns.
++        QMetaObject::invokeMethod(
++                this,
++                [this, addressEnv] {
++                    m_enabled = true;
++                    connectA11yBus(QString::fromLocal8Bit(addressEnv));
++                },
++                Qt::QueuedConnection);
++        return;
++    }
++
+     // Start monitoring if "org.a11y.Bus" is registered as DBus service.
+     QDBusConnection c = QDBusConnection::sessionBus();
+     if (!c.isConnected()) {
+diff --git a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
+index 1a3cab275d..2abe039126 100644
+--- a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
++++ b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
+@@ -51,6 +51,9 @@
+ #include <QtCore/QStandardPaths>
+ #include <QtCore/QUrl>
+ 
++#include <QtGui/QGuiApplication>
++#include <QtGui/QWindow>
++
+ #if QT_CONFIG(dbus)
+ // These QtCore includes are needed for xdg-desktop-portal support
+ #include <QtCore/private/qcore_unix_p.h>
+@@ -58,6 +61,8 @@
+ #include <QtCore/QFileInfo>
+ #include <QtCore/QUrlQuery>
+ 
++#include <QtGui/QColor>
++
+ #include <QtDBus/QDBusConnection>
+ #include <QtDBus/QDBusMessage>
+ #include <QtDBus/QDBusPendingCall>
+@@ -142,6 +147,8 @@ static inline bool detectWebBrowser(const QByteArray &desktop,
+     }
+ 
+     if (desktop == QByteArray("KDE")) {
++        if (checkExecutable(QStringLiteral("kde-open5"), browser))
++            return true;
+         // Konqueror launcher
+         if (checkExecutable(QStringLiteral("kfmclient"), browser)) {
+             browser->append(QLatin1String(" exec"));
+@@ -296,8 +303,135 @@ static inline QDBusMessage xdgDesktopPortalSendEmail(const QUrl &url)
+ 
+     return QDBusConnection::sessionBus().call(message);
+ }
++
++namespace {
++struct XDGDesktopColor
++{
++    double r = 0;
++    double g = 0;
++    double b = 0;
++
++    QColor toQColor() const
++    {
++        constexpr auto rgbMax = 255;
++        return { static_cast<int>(r * rgbMax), static_cast<int>(g * rgbMax),
++                 static_cast<int>(b * rgbMax) };
++    }
++};
++
++const QDBusArgument &operator>>(const QDBusArgument &argument, XDGDesktopColor &myStruct)
++{
++    argument.beginStructure();
++    argument >> myStruct.r >> myStruct.g >> myStruct.b;
++    argument.endStructure();
++    return argument;
++}
++
++class XdgDesktopPortalColorPicker : public QPlatformServiceColorPicker
++{
++    Q_OBJECT
++public:
++    XdgDesktopPortalColorPicker(const QString &parentWindowId, QWindow *parent)
++        : QPlatformServiceColorPicker(parent), m_parentWindowId(parentWindowId)
++    {
++    }
++
++    void pickColor() override
++    {
++        // DBus signature:
++        // PickColor (IN   s      parent_window,
++        //            IN   a{sv}  options
++        //            OUT  o      handle)
++        // Options:
++        // handle_token (s) -  A string that will be used as the last element of the @handle.
++
++        QDBusMessage message = QDBusMessage::createMethodCall(
++                QStringLiteral("org.freedesktop.portal.Desktop"), QStringLiteral("/org/freedesktop/portal/desktop"),
++                QStringLiteral("org.freedesktop.portal.Screenshot"), QStringLiteral("PickColor"));
++        message << m_parentWindowId << QVariantMap();
++
++        QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
++        auto watcher = new QDBusPendingCallWatcher(pendingCall, this);
++        connect(watcher, &QDBusPendingCallWatcher::finished, this,
++                [this](QDBusPendingCallWatcher *watcher) {
++                    watcher->deleteLater();
++                    QDBusPendingReply<QDBusObjectPath> reply = *watcher;
++                    if (reply.isError()) {
++                        qWarning("DBus call to pick color failed: %s",
++                                 qPrintable(reply.error().message()));
++                        Q_EMIT colorPicked({});
++                    } else {
++                        QDBusConnection::sessionBus().connect(
++                                QStringLiteral("org.freedesktop.portal.Desktop"), reply.value().path(),
++                                QStringLiteral("org.freedesktop.portal.Request"), QStringLiteral("Response"), this,
++                                // clang-format off
++                                SLOT(gotColorResponse(uint,QVariantMap))
++                                // clang-format on
++                        );
++                    }
++                });
++    }
++
++private Q_SLOTS:
++    void gotColorResponse(uint result, const QVariantMap &map)
++    {
++        if (result != 0)
++            return;
++        XDGDesktopColor color{};
++        map.value(QStringLiteral("color")).value<QDBusArgument>() >> color;
++        Q_EMIT colorPicked(color.toQColor());
++        deleteLater();
++    }
++
++private:
++    const QString m_parentWindowId;
++};
++} // namespace
++
+ #endif // QT_CONFIG(dbus)
+ 
++QGenericUnixServices::QGenericUnixServices()
++{
++#if QT_CONFIG(dbus)
++    if (qEnvironmentVariableIntValue("QT_NO_XDG_DESKTOP_PORTAL") > 0) {
++        return;
++    }
++    QDBusMessage message = QDBusMessage::createMethodCall(
++            QStringLiteral("org.freedesktop.portal.Desktop"), QStringLiteral("/org/freedesktop/portal/desktop"),
++            QStringLiteral("org.freedesktop.DBus.Properties"), QStringLiteral("Get"));
++    message << QStringLiteral("org.freedesktop.portal.Screenshot")
++            << QStringLiteral("version");
++
++    QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
++    auto watcher = new QDBusPendingCallWatcher(pendingCall);
++    QObject::connect(watcher, &QDBusPendingCallWatcher::finished, watcher,
++                     [this](QDBusPendingCallWatcher *watcher) {
++                         watcher->deleteLater();
++                         QDBusPendingReply<QVariant> reply = *watcher;
++                         if (!reply.isError() && reply.value().toUInt() >= 2)
++                             m_hasScreenshotPortalWithColorPicking = true;
++                     });
++
++#endif
++}
++
++QPlatformServiceColorPicker *QGenericUnixServices::colorPicker(QWindow *parent)
++{
++#if QT_CONFIG(dbus)
++    // Make double sure that we are in a wayland environment. In particular check
++    // WAYLAND_DISPLAY so also XWayland apps benefit from portal-based color picking.
++    // Outside wayland we'll rather rely on other means than the XDG desktop portal.
++    if (!qEnvironmentVariableIsEmpty("WAYLAND_DISPLAY")
++        || QGuiApplication::platformName().startsWith(QLatin1String("wayland"))) {
++        return new XdgDesktopPortalColorPicker(portalWindowIdentifier(parent), parent);
++    }
++    return nullptr;
++#else
++    Q_UNUSED(parent);
++    return nullptr;
++#endif
++}
++
+ QByteArray QGenericUnixServices::desktopEnvironment() const
+ {
+     static const QByteArray result = detectDesktopEnvironment();
+@@ -352,6 +486,8 @@ bool QGenericUnixServices::openDocument(const QUrl &url)
+ }
+ 
+ #else
++QGenericUnixServices::QGenericUnixServices() = default;
++
+ QByteArray QGenericUnixServices::desktopEnvironment() const
+ {
+     return QByteArrayLiteral("UNKNOWN");
+@@ -371,6 +507,30 @@ bool QGenericUnixServices::openDocument(const QUrl &url)
+     return false;
+ }
+ 
++QPlatformServiceColorPicker *QGenericUnixServices::colorPicker(QWindow *parent)
++{
++    Q_UNUSED(parent);
++    return nullptr;
++}
++
+ #endif // QT_NO_MULTIPROCESS
+ 
++QString QGenericUnixServices::portalWindowIdentifier(QWindow *window)
++{
++    if (QGuiApplication::platformName() == QLatin1String("xcb"))
++        return QStringLiteral("x11:") + QString::number(window->winId(), 16);
++    return QString();
++}
++
++bool QGenericUnixServices::hasCapability(Capability capability) const
++{
++    switch (capability) {
++    case Capability::ColorPicking:
++        return m_hasScreenshotPortalWithColorPicking;
++    }
++    return false;
++}
++
+ QT_END_NAMESPACE
++
++#include "qgenericunixservices.moc"
+diff --git a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
+index 8ac3de6f03..30924e64bd 100644
+--- a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
++++ b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
+@@ -59,16 +59,21 @@ QT_BEGIN_NAMESPACE
+ class QGenericUnixServices : public QPlatformServices
+ {
+ public:
+-    QGenericUnixServices() {}
++    QGenericUnixServices();
+ 
+     QByteArray desktopEnvironment() const override;
+ 
++    bool hasCapability(Capability capability) const override;
+     bool openUrl(const QUrl &url) override;
+     bool openDocument(const QUrl &url) override;
++    QPlatformServiceColorPicker *colorPicker(QWindow *parent = nullptr) override;
++
++    virtual QString portalWindowIdentifier(QWindow *window);
+ 
+ private:
+     QString m_webBrowser;
+     QString m_documentLauncher;
++    bool m_hasScreenshotPortalWithColorPicking = false;
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
+index 09470bccc6..cc7c7d4d8a 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
+@@ -69,6 +69,7 @@ const QString MenuBarPath = QLatin1String("/MenuBar");
+ */
+ QDBusMenuConnection::QDBusMenuConnection(QObject *parent, const QString &serviceName)
+     : QObject(parent)
++    , m_serviceName(serviceName)
+     , m_connection(serviceName.isNull() ? QDBusConnection::sessionBus()
+                                         : QDBusConnection::connectToBus(QDBusConnection::SessionBus, serviceName))
+     , m_dbusWatcher(new QDBusServiceWatcher(StatusNotifierWatcherService, m_connection, QDBusServiceWatcher::WatchForRegistration, this))
+@@ -83,6 +84,12 @@ QDBusMenuConnection::QDBusMenuConnection(QObject *parent, const QString &service
+ #endif
+ }
+ 
++QDBusMenuConnection::~QDBusMenuConnection()
++{
++  if (!m_serviceName.isEmpty() && m_connection.isConnected())
++      QDBusConnection::disconnectFromBus(m_serviceName);
++}
++
+ void QDBusMenuConnection::dbusError(const QDBusError &error)
+ {
+     qWarning() << "QDBusTrayIcon encountered a D-Bus error:" << error;
+@@ -105,13 +112,7 @@ void QDBusMenuConnection::unregisterTrayIconMenu(QDBusTrayIcon *item)
+ 
+ bool QDBusMenuConnection::registerTrayIcon(QDBusTrayIcon *item)
+ {
+-    bool success = connection().registerService(item->instanceId());
+-    if (!success) {
+-        qWarning() << "failed to register service" << item->instanceId();
+-        return false;
+-    }
+-
+-    success = connection().registerObject(StatusNotifierItemPath, item);
++    bool success = connection().registerObject(StatusNotifierItemPath, item);
+     if (!success) {
+         unregisterTrayIcon(item);
+         qWarning() << "failed to register" << item->instanceId() << StatusNotifierItemPath;
+@@ -126,21 +127,18 @@ bool QDBusMenuConnection::registerTrayIcon(QDBusTrayIcon *item)
+ 
+ bool QDBusMenuConnection::registerTrayIconWithWatcher(QDBusTrayIcon *item)
+ {
++    Q_UNUSED(item);
+     QDBusMessage registerMethod = QDBusMessage::createMethodCall(
+                 StatusNotifierWatcherService, StatusNotifierWatcherPath, StatusNotifierWatcherService,
+                 QLatin1String("RegisterStatusNotifierItem"));
+-    registerMethod.setArguments(QVariantList() << item->instanceId());
++    registerMethod.setArguments(QVariantList() << m_connection.baseService());
+     return m_connection.callWithCallback(registerMethod, this, SIGNAL(trayIconRegistered()), SLOT(dbusError(QDBusError)));
+ }
+ 
+-bool QDBusMenuConnection::unregisterTrayIcon(QDBusTrayIcon *item)
++void QDBusMenuConnection::unregisterTrayIcon(QDBusTrayIcon *item)
+ {
+     unregisterTrayIconMenu(item);
+     connection().unregisterObject(StatusNotifierItemPath);
+-    bool success = connection().unregisterService(item->instanceId());
+-    if (!success)
+-        qWarning() << "failed to unregister service" << item->instanceId();
+-    return success;
+ }
+ #endif // QT_NO_SYSTEMTRAYICON
+ 
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
+index f484795fbb..97bdfabb85 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
++++ b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
+@@ -70,6 +70,7 @@ class QDBusMenuConnection : public QObject
+ 
+ public:
+     QDBusMenuConnection(QObject *parent = nullptr, const QString &serviceName = QString());
++    ~QDBusMenuConnection();
+     QDBusConnection connection() const { return m_connection; }
+     QDBusServiceWatcher *dbusWatcher() const { return m_dbusWatcher; }
+     bool isStatusNotifierHostRegistered() const { return m_statusNotifierHostRegistered; }
+@@ -78,7 +79,7 @@ public:
+     void unregisterTrayIconMenu(QDBusTrayIcon *item);
+     bool registerTrayIcon(QDBusTrayIcon *item);
+     bool registerTrayIconWithWatcher(QDBusTrayIcon *item);
+-    bool unregisterTrayIcon(QDBusTrayIcon *item);
++    void unregisterTrayIcon(QDBusTrayIcon *item);
+ #endif // QT_NO_SYSTEMTRAYICON
+ 
+ Q_SIGNALS:
+@@ -90,6 +91,7 @@ private Q_SLOTS:
+     void dbusError(const QDBusError &error);
+ 
+ private:
++    QString m_serviceName;
+     QDBusConnection m_connection;
+     QDBusServiceWatcher *m_dbusWatcher;
+     bool m_statusNotifierHostRegistered;
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp b/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
+index bede70975a..76bfec5e5a 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
+@@ -71,8 +71,12 @@ Q_LOGGING_CATEGORY(qLcTray, "qt.qpa.tray")
+ static QString iconTempPath()
+ {
+     QString tempPath = QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation);
+-    if (!tempPath.isEmpty())
++    if (!tempPath.isEmpty()) {
++        QString flatpakId = qEnvironmentVariable("FLATPAK_ID");
++        if (!flatpakId.isEmpty() && QFileInfo::exists(QLatin1String("/.flatpak-info")))
++            tempPath += QLatin1String("/app/") + flatpakId;
+         return tempPath;
++    }
+ 
+     tempPath = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation);
+ 
+diff --git a/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+index cb1b39db64..6e01af052c 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+@@ -755,6 +755,9 @@ QVariant QGnomeTheme::themeHint(QPlatformTheme::ThemeHint hint) const
+         return QVariant(QChar(0x2022));
+     case QPlatformTheme::UiEffects:
+         return QVariant(int(HoverEffect));
++    case QPlatformTheme::ButtonPressKeys:
++        return QVariant::fromValue(
++                QList<Qt::Key>({ Qt::Key_Space, Qt::Key_Return, Qt::Key_Enter, Qt::Key_Select }));
+     default:
+         break;
+     }
+diff --git a/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp b/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
+index 98e05195ee..1e92f43dec 100644
+--- a/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
++++ b/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
+@@ -343,8 +343,7 @@ void QEglFSCursor::paintOnScreen()
+     // screens are siblings of each other. When not enabled, the sibling list
+     // only contains m_screen itself.
+     for (QPlatformScreen *screen : m_screen->virtualSiblings()) {
+-        if (screen->geometry().contains(cr.topLeft().toPoint() + m_cursor.hotSpot)
+-            && QOpenGLContext::currentContext()->screen() == screen->screen())
++        if (screen->geometry().contains(cr.topLeft().toPoint() + m_cursor.hotSpot))
+         {
+             cr.translate(-screen->geometry().topLeft());
+             const QSize screenSize = screen->geometry().size();
+@@ -468,11 +467,12 @@ void QEglFSCursor::draw(const QRectF &r)
+ {
+     StateSaver stateSaver;
+ 
+-    QEglFSCursorData &gfx = static_cast<QEglFSContext*>(QOpenGLContext::currentContext()->handle())->cursorData;
+-    if (!gfx.program) {
+-        // one time initialization
++    // one time initialization
++    if (!QOpenGLFunctions::d_ptr)
+         initializeOpenGLFunctions();
+ 
++    QEglFSCursorData &gfx = static_cast<QEglFSContext*>(QOpenGLContext::currentContext()->handle())->cursorData;
++    if (!gfx.program) {
+         createShaderPrograms();
+ 
+         if (!gfx.atlasTexture) {
+diff --git a/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp b/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
+index 645a0ae2e9..3e0e406f1a 100644
+--- a/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
++++ b/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
+@@ -179,7 +179,7 @@ void QEglFSKmsEventReader::create(QEglFSKmsDevice *device)
+ 
+     m_device = device;
+ 
+-    qCDebug(qLcEglfsKmsDebug, "Initalizing event reader for device %p fd %d",
++    qCDebug(qLcEglfsKmsDebug, "Initializing event reader for device %p fd %d",
+             m_device, m_device->fd());
+ 
+     m_thread = new QEglFSKmsEventReaderThread(m_device->fd());
+diff --git a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
+index 141fb68a23..d4294d425a 100644
+--- a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
++++ b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
+@@ -122,11 +122,13 @@ QOffscreenIntegration::QOffscreenIntegration()
+ #endif
+     m_services.reset(new QPlatformServices);
+ 
+-    QWindowSystemInterface::handleScreenAdded(new QOffscreenScreen);
++    m_screen = new QOffscreenScreen;
++    QWindowSystemInterface::handleScreenAdded(m_screen);
+ }
+ 
+ QOffscreenIntegration::~QOffscreenIntegration()
+ {
++    QWindowSystemInterface::handleScreenRemoved(m_screen);
+ }
+ 
+ void QOffscreenIntegration::initialize()
+diff --git a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
+index 0ea90f6c2f..fe00fde07c 100644
+--- a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
++++ b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
+@@ -84,6 +84,7 @@ protected:
+ #endif
+     QScopedPointer<QPlatformInputContext> m_inputContext;
+     QScopedPointer<QPlatformServices> m_services;
++    QPlatformScreen *m_screen;
+     mutable QScopedPointer<QPlatformNativeInterface> m_nativeInterface;
+ };
+ 
+diff --git a/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp b/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
+index 6fa5a8a2b3..1f49f0aefd 100644
+--- a/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
++++ b/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
+@@ -48,6 +48,7 @@
+ #include <qpa/qplatformnativeinterface.h>
+ #include <QtPlatformHeaders/qwglnativecontext.h>
+ 
++#include <private/qsystemlibrary_p.h>
+ #include <algorithm>
+ 
+ #include <wingdi.h>
+@@ -162,19 +163,25 @@ QFunctionPointer QWindowsOpengl32DLL::resolve(const char *name)
+ 
+ bool QWindowsOpengl32DLL::init(bool softwareRendering)
+ {
+-    const QByteArray opengl32 = QByteArrayLiteral("opengl32.dll");
+-    const QByteArray swopengl = QByteArrayLiteral("opengl32sw.dll");
++    const QByteArray opengl32 = QByteArrayLiteral("opengl32");
++    const QByteArray swopengl = QByteArrayLiteral("opengl32sw");
++    bool useSystemLib = false;
+ 
+     QByteArray openglDll = qgetenv("QT_OPENGL_DLL");
+-    if (openglDll.isEmpty())
++    if (openglDll.isEmpty()) {
+         openglDll = softwareRendering ? swopengl : opengl32;
++        useSystemLib = !softwareRendering;
++    }
+ 
+     openglDll = openglDll.toLower();
+     m_nonOpengl32 = openglDll != opengl32;
+ 
+     qCDebug(lcQpaGl) << "Qt: Using WGL and OpenGL from" << openglDll;
+ 
+-    m_lib = ::LoadLibraryA(openglDll.constData());
++    if (useSystemLib)
++        m_lib = QSystemLibrary::load((wchar_t*)(QString::fromLatin1(openglDll).utf16()));
++    else
++        m_lib = LoadLibraryA(openglDll.constData());
+     if (!m_lib) {
+         qErrnoWarning(::GetLastError(), "Failed to load %s", openglDll.constData());
+         return false;
+@@ -184,7 +191,7 @@ bool QWindowsOpengl32DLL::init(bool softwareRendering)
+         // Load opengl32.dll always. GDI functions like ChoosePixelFormat do
+         // GetModuleHandle for opengl32.dll and behave differently (and call back into
+         // opengl32) when the module is present. This is fine for dummy contexts and windows.
+-        ::LoadLibraryA("opengl32.dll");
++        QSystemLibrary::load(L"opengl32");
+     }
+ 
+     wglCreateContext = reinterpret_cast<HGLRC (WINAPI *)(HDC)>(resolve("wglCreateContext"));
+diff --git a/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp b/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
+index d7d186e804..9eb4011bf2 100644
+--- a/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
++++ b/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
+@@ -49,6 +49,7 @@
+ #include <QtCore/qstandardpaths.h>
+ #include <QtCore/qlibraryinfo.h>
+ #include <QtCore/qhash.h>
++#include <private/qsystemlibrary_p.h>
+ 
+ #ifndef QT_NO_OPENGL
+ #include <private/qopengl_p.h>
+@@ -396,7 +397,7 @@ bool QWindowsOpenGLTester::testDesktopGL()
+ 
+     // Test #1: Load opengl32.dll and try to resolve an OpenGL 2 function.
+     // This will typically fail on systems that do not have a real OpenGL driver.
+-    lib = LoadLibraryA("opengl32.dll");
++    lib = QSystemLibrary::load(L"opengl32");
+     if (lib) {
+         CreateContext = reinterpret_cast<CreateContextType>(
+             reinterpret_cast<QFunctionPointer>(::GetProcAddress(lib, "wglCreateContext")));
+diff --git a/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp b/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
+index 1afa00cfc9..118af6ce73 100644
+--- a/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
++++ b/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
+@@ -41,6 +41,7 @@
+ 
+ #include <QRect>
+ #include <QList>
++#include <QMap>
+ #include <QDebug>
+ 
+ #include <qmath.h>
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp b/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
+index 9e2a37a6a1..e6e175a118 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
+@@ -488,12 +488,12 @@ void QXcbConnection::printXcbError(const char *message, xcb_generic_error_t *err
+     uint clamped_error_code = qMin<uint>(error->error_code, (sizeof(xcb_errors) / sizeof(xcb_errors[0])) - 1);
+     uint clamped_major_code = qMin<uint>(error->major_code, (sizeof(xcb_protocol_request_codes) / sizeof(xcb_protocol_request_codes[0])) - 1);
+ 
+-    qCWarning(lcQpaXcb, "%s: %d (%s), sequence: %d, resource id: %d, major code: %d (%s), minor code: %d",
+-             message,
+-             int(error->error_code), xcb_errors[clamped_error_code],
+-             int(error->sequence), int(error->resource_id),
+-             int(error->major_code), xcb_protocol_request_codes[clamped_major_code],
+-             int(error->minor_code));
++    qCDebug(lcQpaXcb, "%s: %d (%s), sequence: %d, resource id: %d, major code: %d (%s), minor code: %d",
++            message,
++            int(error->error_code), xcb_errors[clamped_error_code],
++            int(error->sequence), int(error->resource_id),
++            int(error->major_code), xcb_protocol_request_codes[clamped_major_code],
++            int(error->minor_code));
+ }
+ 
+ static Qt::MouseButtons translateMouseButtons(int s)
+@@ -702,6 +702,8 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
+             QXcbVirtualDesktop *virtualDesktop = virtualDesktopForRootWindow(propertyNotify->window);
+             if (virtualDesktop)
+                 virtualDesktop->updateWorkArea();
++        } else if (propertyNotify->atom == atom(QXcbAtom::_NET_SUPPORTED)) {
++            m_wmSupport->updateNetWMAtoms();
+         } else {
+             HANDLE_PLATFORM_WINDOW_EVENT(xcb_property_notify_event_t, window, handlePropertyNotifyEvent);
+         }
+@@ -750,7 +752,7 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
+                 case XCB_XKB_NEW_KEYBOARD_NOTIFY: {
+                     xcb_xkb_new_keyboard_notify_event_t *ev = &xkb_event->new_keyboard_notify;
+                     if (ev->changed & XCB_XKB_NKN_DETAIL_KEYCODES)
+-                        m_keyboard->updateKeymap(ev);
++                        m_keyboard->updateKeymap();
+                     break;
+                 }
+                 default:
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp b/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
+index 76869ced60..02d2eebb56 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
+@@ -274,8 +274,7 @@ QPlatformWindow *QXcbIntegration::createForeignWindow(QWindow *window, WId nativ
+ #ifndef QT_NO_OPENGL
+ QPlatformOpenGLContext *QXcbIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
+ {
+-    QXcbScreen *screen = static_cast<QXcbScreen *>(context->screen()->handle());
+-    QXcbGlIntegration *glIntegration = screen->connection()->glIntegration();
++    QXcbGlIntegration *glIntegration = defaultConnection()->glIntegration();
+     if (!glIntegration) {
+         qWarning("QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled");
+         return nullptr;
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+index efecd7e2d1..e8286381a2 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+@@ -365,17 +365,6 @@ void QXcbKeyboard::updateKeymap(xcb_mapping_notify_event_t *event)
+     updateKeymap();
+ }
+ 
+-void QXcbKeyboard::updateKeymap(xcb_xkb_new_keyboard_notify_event_t *event)
+-{
+-    if (!event)
+-        return;
+-
+-    if (event->deviceID != event->oldDeviceID)
+-        m_config = false;
+-
+-    updateKeymap();
+-}
+-
+ void QXcbKeyboard::updateKeymap()
+ {
+     KeysymModifierMap keysymMods;
+@@ -383,6 +372,8 @@ void QXcbKeyboard::updateKeymap()
+         keysymMods = keysymsToModifiers();
+     updateModifiers(keysymMods);
+ 
++    m_config = true;
++
+     if (!m_xkbContext) {
+         m_xkbContext.reset(xkb_context_new(XKB_CONTEXT_NO_DEFAULT_INCLUDES));
+         if (!m_xkbContext) {
+@@ -398,13 +389,8 @@ void QXcbKeyboard::updateKeymap()
+     if (connection()->hasXKB()) {
+         m_xkbKeymap.reset(xkb_x11_keymap_new_from_device(m_xkbContext.get(), xcb_connection(),
+                                                          core_device_id, XKB_KEYMAP_COMPILE_NO_FLAGS));
+-        if (m_xkbKeymap) {
+-            if (m_config)
+-                m_xkbState.reset(xkb_state_new(m_xkbKeymap.get()));
+-            else
+-                m_xkbState.reset(xkb_x11_state_new_from_device(m_xkbKeymap.get(), xcb_connection(), core_device_id));
+-
+-        }
++        if (m_xkbKeymap)
++            m_xkbState.reset(xkb_x11_state_new_from_device(m_xkbKeymap.get(), xcb_connection(), core_device_id));
+     } else {
+         m_xkbKeymap.reset(keymapFromCore(keysymMods));
+         if (m_xkbKeymap)
+@@ -425,8 +411,6 @@ void QXcbKeyboard::updateKeymap()
+     updateXKBMods();
+ 
+     QXkbCommon::verifyHasLatinLayout(m_xkbKeymap.get());
+-
+-    m_config = true;
+ }
+ 
+ QList<int> QXcbKeyboard::possibleKeys(const QKeyEvent *event) const
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
+index b652c85fe3..0ee08aeff2 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
++++ b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
+@@ -69,7 +69,6 @@ public:
+ 
+     Qt::KeyboardModifiers translateModifiers(int s) const;
+     void updateKeymap(xcb_mapping_notify_event_t *event);
+-    void updateKeymap(xcb_xkb_new_keyboard_notify_event_t *event);
+     void updateKeymap();
+     QList<int> possibleKeys(const QKeyEvent *event) const;
+ 
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp b/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
+index ffda7b6a57..863e961f4c 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
+@@ -564,11 +564,6 @@ void QXcbWindow::setGeometry(const QRect &rect)
+ {
+     QPlatformWindow::setGeometry(rect);
+ 
+-    if (shouldDeferTask(Task::SetGeometry)) {
+-        m_deferredGeometry = rect;
+-        return;
+-    }
+-
+     propagateSizeHints();
+ 
+     QXcbScreen *currentScreen = xcbScreen();
+@@ -693,9 +688,6 @@ void QXcbWindow::setVisible(bool visible)
+ 
+ void QXcbWindow::show()
+ {
+-    if (shouldDeferTask(Task::Map))
+-        return;
+-
+     if (window()->isTopLevel()) {
+ 
+         // update WM_NORMAL_HINTS
+@@ -706,7 +698,7 @@ void QXcbWindow::show()
+         if (isTransient(window())) {
+             const QWindow *tp = window()->transientParent();
+             if (tp && tp->handle())
+-                transientXcbParent = static_cast<const QXcbWindow *>(tp->handle())->winId();
++                transientXcbParent = tp->handle()->winId();
+             // Default to client leader if there is no transient parent, else modal dialogs can
+             // be hidden by their parents.
+             if (!transientXcbParent)
+@@ -746,10 +738,6 @@ void QXcbWindow::show()
+ 
+ void QXcbWindow::hide()
+ {
+-    if (shouldDeferTask(Task::Unmap))
+-        return;
+-
+-    m_wmStateValid = false;
+     xcb_unmap_window(xcb_connection(), m_window);
+ 
+     // send synthetic UnmapNotify event according to icccm 4.1.4
+@@ -909,9 +897,6 @@ QXcbWindow::NetWmStates QXcbWindow::netWmStates()
+ 
+ void QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
+ {
+-    if (shouldDeferTask(Task::SetWindowFlags))
+-        return;
+-
+     Qt::WindowType type = static_cast<Qt::WindowType>(int(flags & Qt::WindowType_Mask));
+ 
+     if (type == Qt::ToolTip)
+@@ -941,8 +926,6 @@ void QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
+ 
+     setTransparentForMouseEvents(flags & Qt::WindowTransparentForInput);
+     updateDoesNotAcceptFocus(flags & Qt::WindowDoesNotAcceptFocus);
+-
+-    m_isWmManagedWindow = !(flags & Qt::X11BypassWindowManagerHint);
+ }
+ 
+ void QXcbWindow::setMotifWmHints(Qt::WindowFlags flags)
+@@ -1142,9 +1125,6 @@ void QXcbWindow::setWindowState(Qt::WindowStates state)
+     if (state == m_windowState)
+         return;
+ 
+-    if (shouldDeferTask(Task::SetWindowState))
+-        return;
+-
+     // unset old state
+     if (m_windowState & Qt::WindowMinimized)
+         xcb_map_window(xcb_connection(), m_window);
+@@ -1350,6 +1330,12 @@ void QXcbWindow::setWindowIcon(const QIcon &icon)
+     }
+ 
+     if (!icon_data.isEmpty()) {
++        // Ignore icon exceeding maximum xcb request length
++        if (icon_data.size() > xcb_get_maximum_request_length(xcb_connection())) {
++            qWarning("Ignoring window icon: Size %llu exceeds maximum xcb request length %u.",
++                     icon_data.size(), xcb_get_maximum_request_length(xcb_connection()));
++            return;
++        }
+         xcb_change_property(xcb_connection(),
+                             XCB_PROP_MODE_REPLACE,
+                             m_window,
+@@ -1639,7 +1625,7 @@ void QXcbWindow::setWmWindowType(QXcbWindowFunctions::WmWindowTypes types, Qt::W
+         break;
+     }
+ 
+-    if ((flags & Qt::FramelessWindowHint) && !(type & QXcbWindowFunctions::KdeOverride)) {
++    if ((flags & Qt::FramelessWindowHint) && !(types & QXcbWindowFunctions::KdeOverride)) {
+         // override netwm type - quick and easy for KDE noborder
+         atoms.append(atom(QXcbAtom::_KDE_NET_WM_WINDOW_TYPE_OVERRIDE));
+     }
+@@ -1894,10 +1880,6 @@ void QXcbWindow::handleUnmapNotifyEvent(const xcb_unmap_notify_event_t *event)
+     if (event->window == m_window) {
+         m_mapped = false;
+         QWindowSystemInterface::handleExposeEvent(window(), QRegion());
+-        if (!m_isWmManagedWindow || parent()) {
+-            m_wmStateValid = true;
+-            handleDeferredTasks();
+-        }
+     }
+ }
+ 
+@@ -2212,98 +2194,30 @@ void QXcbWindow::handleLeaveNotifyEvent(const xcb_leave_notify_event_t *event)
+     handleLeaveNotifyEvent(event->root_x, event->root_y, event->mode, event->detail, event->time);
+ }
+ 
+-bool QXcbWindow::shouldDeferTask(Task task)
+-{
+-    if (m_wmStateValid)
+-        return false;
+-
+-    m_deferredTasks.append(task);
+-    return true;
+-}
+-
+-void QXcbWindow::handleDeferredTasks()
+-{
+-    Q_ASSERT(m_wmStateValid == true);
+-    if (m_deferredTasks.isEmpty())
+-        return;
+-
+-    bool map = false;
+-    bool unmap = false;
+-
+-    QVector<Task> tasks;
+-    for (auto taskIt = m_deferredTasks.rbegin(); taskIt != m_deferredTasks.rend(); ++taskIt) {
+-        if (!tasks.contains(*taskIt))
+-            tasks.prepend(*taskIt);
+-    }
+-
+-    for (Task task : tasks) {
+-        switch (task) {
+-        case Task::Map:
+-            map = true;
+-            unmap = false;
+-            break;
+-        case Task::Unmap:
+-            unmap = true;
+-            map = false;
+-            break;
+-        case Task::SetGeometry:
+-            setGeometry(m_deferredGeometry);
+-            break;
+-        case Task::SetWindowFlags:
+-            setWindowFlags(window()->flags());
+-            break;
+-        case Task::SetWindowState:
+-            setWindowState(window()->windowState());
+-            break;
+-        }
+-    }
+-    m_deferredTasks.clear();
+-
+-    if (map) {
+-        Q_ASSERT(unmap == false);
+-        show();
+-    }
+-    if (unmap) {
+-        Q_ASSERT(map == false);
+-        hide();
+-    }
+-}
+-
+ void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *event)
+ {
+     connection()->setTime(event->time);
+ 
+-    const bool wmStateChanged = event->atom == atom(QXcbAtom::WM_STATE);
+-    const bool netWmStateChanged = event->atom == atom(QXcbAtom::_NET_WM_STATE);
+-    if (netWmStateChanged || wmStateChanged) {
+-        if (wmStateChanged && !m_wmStateValid && m_isWmManagedWindow) {
+-            // ICCCM 4.1.4
+-            // Clients that want to re-use a client window (e.g. by mapping it again)
+-            // after withdrawing it must wait for the withdrawal to be complete before
+-            // proceeding. The preferred method for doing this is for clients to wait for
+-            // a window manager to update or remove the WM_STATE property.
+-            m_wmStateValid = true;
+-            handleDeferredTasks();
+-        }
+-        if (event->state == XCB_PROPERTY_DELETE)
++    const bool propertyDeleted = event->state == XCB_PROPERTY_DELETE;
++
++    if (event->atom == atom(QXcbAtom::_NET_WM_STATE) || event->atom == atom(QXcbAtom::WM_STATE)) {
++        if (propertyDeleted)
+             return;
+ 
+-        if (wmStateChanged) {
++        Qt::WindowStates newState = Qt::WindowNoState;
++
++        if (event->atom == atom(QXcbAtom::WM_STATE)) { // WM_STATE: Quick check for 'Minimize'.
+             auto reply = Q_XCB_REPLY(xcb_get_property, xcb_connection(),
+                                      0, m_window, atom(QXcbAtom::WM_STATE),
+                                      XCB_ATOM_ANY, 0, 1024);
+             if (reply && reply->format == 32 && reply->type == atom(QXcbAtom::WM_STATE)) {
+-                auto data = static_cast<const quint32 *>(xcb_get_property_value(reply.get()));
+-                if (reply->length != 0) {
+-                    const bool changedToWithdrawn = data[0] == XCB_ICCCM_WM_STATE_WITHDRAWN;
+-                    const bool changedToIconic = data[0] == XCB_ICCCM_WM_STATE_ICONIC;
+-                    m_minimized = changedToIconic || (changedToWithdrawn && m_minimized);
+-                }
++                const quint32 *data = (const quint32 *)xcb_get_property_value(reply.get());
++                if (reply->length != 0)
++                    m_minimized = (data[0] == XCB_ICCCM_WM_STATE_ICONIC
++                                   || (data[0] == XCB_ICCCM_WM_STATE_WITHDRAWN && m_minimized));
+             }
+         }
+ 
+-        // _NET_WM_STATE handling
+-        Qt::WindowStates newState = Qt::WindowNoState;
+         const NetWmStates states = netWmStates();
+         // _NET_WM_STATE_HIDDEN should be set by the Window Manager to indicate that a window would
+         // not be visible on the screen if its desktop/viewport were active and its coordinates were
+@@ -2325,6 +2239,7 @@ void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *ev
+             if ((m_windowState & Qt::WindowMinimized) && connection()->mouseGrabber() == this)
+                 connection()->setMouseGrabber(nullptr);
+         }
++        return;
+     } else if (event->atom == atom(QXcbAtom::_NET_FRAME_EXTENTS)) {
+         m_dirtyFrameMargins = true;
+     }
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbwindow.h b/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
+index 55af9279b1..6f5c1f5ed9 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
++++ b/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
+@@ -74,14 +74,6 @@ public:
+ 
+     Q_DECLARE_FLAGS(NetWmStates, NetWmState)
+ 
+-    enum Task {
+-        Map,
+-        Unmap,
+-        SetGeometry,
+-        SetWindowFlags,
+-        SetWindowState
+-    };
+-
+     QXcbWindow(QWindow *window);
+     ~QXcbWindow();
+ 
+@@ -151,9 +143,6 @@ public:
+ 
+     QXcbWindow *toWindow() override;
+ 
+-    bool shouldDeferTask(Task task);
+-    void handleDeferredTasks();
+-
+     void handleMouseEvent(xcb_timestamp_t time, const QPoint &local, const QPoint &global,
+                           Qt::KeyboardModifiers modifiers, QEvent::Type type, Qt::MouseEventSource source);
+ 
+@@ -292,11 +281,6 @@ protected:
+     int m_swapInterval = -1;
+ 
+     qreal m_sizeHintsScaleFactor = 1.0;
+-
+-    bool m_wmStateValid = true;
+-    QVector<Task> m_deferredTasks;
+-    bool m_isWmManagedWindow = true;
+-    QRect m_deferredGeometry;
+ };
+ 
+ class QXcbForeignWindow : public QXcbWindow
+diff --git a/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp b/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
+index d9d117faeb..640b49daa0 100644
+--- a/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
++++ b/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
+@@ -85,6 +85,7 @@ QGtk3MenuItem::QGtk3MenuItem()
+       m_checkable(false),
+       m_checked(false),
+       m_enabled(true),
++      m_exclusive(false),
+       m_underline(false),
+       m_invalid(true),
+       m_menu(nullptr),
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
+index 0048bbc1e6..396e7f6d1c 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
+@@ -102,15 +102,12 @@ const QDBusArgument &operator >>(const QDBusArgument &arg, QXdgDesktopPortalFile
+ class QXdgDesktopPortalFileDialogPrivate
+ {
+ public:
+-    QXdgDesktopPortalFileDialogPrivate(QPlatformFileDialogHelper *nativeFileDialog)
++    QXdgDesktopPortalFileDialogPrivate(QPlatformFileDialogHelper *nativeFileDialog, uint fileChooserPortalVersion)
+         : nativeFileDialog(nativeFileDialog)
++        , fileChooserPortalVersion(fileChooserPortalVersion)
+     { }
+ 
+-    WId winId = 0;
+-    bool directoryMode = false;
+-    bool modal = false;
+-    bool multipleFiles = false;
+-    bool saveFile = false;
++    QEventLoop loop;
+     QString acceptLabel;
+     QString directory;
+     QString title;
+@@ -121,19 +118,27 @@ public:
+     QString selectedMimeTypeFilter;
+     QString selectedNameFilter;
+     QStringList selectedFiles;
+-    QPlatformFileDialogHelper *nativeFileDialog = nullptr;
++    std::unique_ptr<QPlatformFileDialogHelper> nativeFileDialog;
++    uint fileChooserPortalVersion = 0;
++    bool failedToOpen = false;
++    bool directoryMode = false;
++    bool multipleFiles = false;
++    bool saveFile = false;
+ };
+ 
+-QXdgDesktopPortalFileDialog::QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog)
++QXdgDesktopPortalFileDialog::QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog, uint fileChooserPortalVersion)
+     : QPlatformFileDialogHelper()
+-    , d_ptr(new QXdgDesktopPortalFileDialogPrivate(nativeFileDialog))
++    , d_ptr(new QXdgDesktopPortalFileDialogPrivate(nativeFileDialog, fileChooserPortalVersion))
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+     if (d->nativeFileDialog) {
+-        connect(d->nativeFileDialog, SIGNAL(accept()), this, SIGNAL(accept()));
+-        connect(d->nativeFileDialog, SIGNAL(reject()), this, SIGNAL(reject()));
++        connect(d->nativeFileDialog.get(), SIGNAL(accept()), this, SIGNAL(accept()));
++        connect(d->nativeFileDialog.get(), SIGNAL(reject()), this, SIGNAL(reject()));
+     }
++
++    d->loop.connect(this, SIGNAL(accept()), SLOT(quit()));
++    d->loop.connect(this, SIGNAL(reject()), SLOT(quit()));
+ }
+ 
+ QXdgDesktopPortalFileDialog::~QXdgDesktopPortalFileDialog()
+@@ -177,7 +182,7 @@ void QXdgDesktopPortalFileDialog::initializeDialog()
+     setDirectory(options()->initialDirectory());
+ }
+ 
+-void QXdgDesktopPortalFileDialog::openPortal()
++void QXdgDesktopPortalFileDialog::openPortal(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent)
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+@@ -185,13 +190,13 @@ void QXdgDesktopPortalFileDialog::openPortal()
+                                                           QLatin1String("/org/freedesktop/portal/desktop"),
+                                                           QLatin1String("org.freedesktop.portal.FileChooser"),
+                                                           d->saveFile ? QLatin1String("SaveFile") : QLatin1String("OpenFile"));
+-    QString parentWindowId = QLatin1String("x11:") + QString::number(d->winId, 16);
++    QString parentWindowId = QLatin1String("x11:") + QString::number(parent ? parent->winId() : 0, 16);
+ 
+     QVariantMap options;
+     if (!d->acceptLabel.isEmpty())
+         options.insert(QLatin1String("accept_label"), d->acceptLabel);
+ 
+-    options.insert(QLatin1String("modal"), d->modal);
++    options.insert(QLatin1String("modal"), windowModality != Qt::NonModal);
+     options.insert(QLatin1String("multiple"), d->multipleFiles);
+     options.insert(QLatin1String("directory"), d->directoryMode);
+ 
+@@ -290,10 +295,18 @@ void QXdgDesktopPortalFileDialog::openPortal()
+ 
+     QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
+     QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingCall);
+-    connect(watcher, &QDBusPendingCallWatcher::finished, this, [this] (QDBusPendingCallWatcher *watcher) {
++    connect(watcher, &QDBusPendingCallWatcher::finished, this, [=] (QDBusPendingCallWatcher *watcher) {
+         QDBusPendingReply<QDBusObjectPath> reply = *watcher;
+-        if (reply.isError()) {
+-            Q_EMIT reject();
++        // Any error means the dialog is not shown and we need to fallback
++        d->failedToOpen = reply.isError();
++        if (d->failedToOpen) {
++            if (d->nativeFileDialog) {
++                d->nativeFileDialog->show(windowFlags, windowModality, parent);
++                if (d->loop.isRunning())
++                    d->nativeFileDialog->exec();
++            } else {
++                Q_EMIT reject();
++            }
+         } else {
+             QDBusConnection::sessionBus().connect(nullptr,
+                                                   reply.value().path(),
+@@ -302,6 +315,7 @@ void QXdgDesktopPortalFileDialog::openPortal()
+                                                   this,
+                                                   SLOT(gotResponse(uint,QVariantMap)));
+         }
++        watcher->deleteLater();
+     });
+ }
+ 
+@@ -326,7 +340,7 @@ QUrl QXdgDesktopPortalFileDialog::directory() const
+ {
+     Q_D(const QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog())
+         return d->nativeFileDialog->directory();
+ 
+     return d->directory;
+@@ -348,7 +362,7 @@ QList<QUrl> QXdgDesktopPortalFileDialog::selectedFiles() const
+ {
+     Q_D(const QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog())
+         return d->nativeFileDialog->selectedFiles();
+ 
+     QList<QUrl> files;
+@@ -403,16 +417,13 @@ void QXdgDesktopPortalFileDialog::exec()
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly)) {
++    if (d->nativeFileDialog && useNativeFileDialog()) {
+         d->nativeFileDialog->exec();
+         return;
+     }
+ 
+     // HACK we have to avoid returning until we emit that the dialog was accepted or rejected
+-    QEventLoop loop;
+-    loop.connect(this, SIGNAL(accept()), SLOT(quit()));
+-    loop.connect(this, SIGNAL(reject()), SLOT(quit()));
+-    loop.exec();
++    d->loop.exec();
+ }
+ 
+ void QXdgDesktopPortalFileDialog::hide()
+@@ -429,13 +440,10 @@ bool QXdgDesktopPortalFileDialog::show(Qt::WindowFlags windowFlags, Qt::WindowMo
+ 
+     initializeDialog();
+ 
+-    d->modal = windowModality != Qt::NonModal;
+-    d->winId = parent ? parent->winId() : 0;
+-
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog(OpenFallback))
+         return d->nativeFileDialog->show(windowFlags, windowModality, parent);
+ 
+-    openPortal();
++    openPortal(windowFlags, windowModality, parent);
+ 
+     return true;
+ }
+@@ -465,4 +473,21 @@ void QXdgDesktopPortalFileDialog::gotResponse(uint response, const QVariantMap &
+     }
+ }
+ 
++bool QXdgDesktopPortalFileDialog::useNativeFileDialog(QXdgDesktopPortalFileDialog::FallbackType fallbackType) const
++{
++    Q_D(const QXdgDesktopPortalFileDialog);
++
++    if (d->failedToOpen && fallbackType != OpenFallback)
++        return true;
++
++    if (d->fileChooserPortalVersion < 3) {
++        if (options()->fileMode() == QFileDialogOptions::Directory)
++            return true;
++        else if (options()->fileMode() == QFileDialogOptions::DirectoryOnly)
++            return true;
++    }
++
++    return false;
++}
++
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
+index 4f4de96ecf..65e22a5cf2 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
+@@ -51,6 +51,11 @@ class QXdgDesktopPortalFileDialog : public QPlatformFileDialogHelper
+     Q_OBJECT
+     Q_DECLARE_PRIVATE(QXdgDesktopPortalFileDialog)
+ public:
++    enum FallbackType {
++        GenericFallback,
++        OpenFallback
++    };
++
+     enum ConditionType : uint {
+         GlobalPattern = 0,
+         MimeType = 1
+@@ -69,7 +74,7 @@ public:
+     };
+     typedef QVector<Filter> FilterList;
+ 
+-    QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog = nullptr);
++    QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog = nullptr, uint fileChooserPortalVersion = 0);
+     ~QXdgDesktopPortalFileDialog();
+ 
+     bool defaultNameFilterDisables() const override;
+@@ -92,7 +97,8 @@ private Q_SLOTS:
+ 
+ private:
+     void initializeDialog();
+-    void openPortal();
++    void openPortal(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent);
++    bool useNativeFileDialog(FallbackType fallbackType = GenericFallback) const;
+ 
+     QScopedPointer<QXdgDesktopPortalFileDialogPrivate> d_ptr;
+ };
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
+index fb324afbd8..b809503122 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
+@@ -111,6 +111,7 @@ QXdgDesktopPortalTheme::QXdgDesktopPortalTheme()
+         if (reply.isValid()) {
+             d->fileChooserPortalVersion = reply.value().toUInt();
+         }
++        watcher->deleteLater();
+     });
+ }
+ 
+@@ -152,11 +153,12 @@ QPlatformDialogHelper* QXdgDesktopPortalTheme::createPlatformDialogHelper(Dialog
+ {
+     Q_D(const QXdgDesktopPortalTheme);
+ 
+-    if (type == FileDialog) {
++    if (type == FileDialog && d->fileChooserPortalVersion) {
+         // Older versions of FileChooser portal don't support opening directories, therefore we fallback
+         // to native file dialog opened inside the sandbox to open a directory.
+-        if (d->fileChooserPortalVersion < 3 && d->baseTheme->usePlatformNativeDialog(type))
+-            return new QXdgDesktopPortalFileDialog(static_cast<QPlatformFileDialogHelper*>(d->baseTheme->createPlatformDialogHelper(type)));
++        if (d->baseTheme->usePlatformNativeDialog(type))
++            return new QXdgDesktopPortalFileDialog(static_cast<QPlatformFileDialogHelper*>(d->baseTheme->createPlatformDialogHelper(type)),
++                                                   d->fileChooserPortalVersion);
+ 
+         return new QXdgDesktopPortalFileDialog;
+     }
+diff --git a/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp b/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
+index 43d5e119ad..1f9cbc4565 100644
+--- a/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
++++ b/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
+@@ -89,8 +89,10 @@ void QCupsPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &v
+         break;
+     case PPK_Duplex: {
+         QPrint::DuplexMode mode = QPrint::DuplexMode(value.toInt());
+-        if (mode != d->duplex && d->m_printDevice.supportedDuplexModes().contains(mode))
++        if (d->m_printDevice.supportedDuplexModes().contains(mode)) {
+             d->duplex = mode;
++            d->duplexRequestedExplicitly = true;
++        }
+         break;
+     }
+     case PPK_PrinterName:
+@@ -277,9 +279,12 @@ void QCupsPrintEnginePrivate::changePrinter(const QString &newPrinter)
+     m_printDevice.swap(printDevice);
+     printerName = m_printDevice.id();
+ 
+-    // Check if new printer supports current settings, otherwise us defaults
+-    if (duplex != QPrint::DuplexAuto && !m_printDevice.supportedDuplexModes().contains(duplex))
++    // in case a duplex value was explicitly set, check if new printer supports current value,
++    // otherwise use device default
++    if (!duplexRequestedExplicitly || !m_printDevice.supportedDuplexModes().contains(duplex)) {
+         duplex = m_printDevice.defaultDuplexMode();
++        duplexRequestedExplicitly = false;
++    }
+     QPrint::ColorMode colorMode = grayscale ? QPrint::GrayScale : QPrint::Color;
+     if (!m_printDevice.supportedColorModes().contains(colorMode))
+         grayscale = m_printDevice.defaultColorMode() == QPrint::GrayScale;
+diff --git a/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h b/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
+index c021b0c643..8f81fe478d 100644
+--- a/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
++++ b/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
+@@ -100,6 +100,7 @@ private:
+     QStringList cupsOptions;
+     QString cupsTempFile;
+     QPrint::DuplexMode duplex;
++    bool duplexRequestedExplicitly = false;
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp b/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
+index 67e7154fa6..40876152e5 100644
+--- a/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
++++ b/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
+@@ -817,7 +817,7 @@ bool QIBaseResultPrivate::writeArray(int column, const QList<QVariant> &list)
+     ba.resize(int(bufLen));
+ 
+     if (list.size() > arraySize) {
+-        error = QLatin1String("Array size missmatch: size of %1 is %2, size of provided list is %3");
++        error = QLatin1String("Array size mismatch: size of %1 is %2, size of provided list is %3");
+         error = error.arg(QLatin1String(sqlname)).arg(arraySize).arg(list.size());
+         q->setLastError(QSqlError(error, QLatin1String(""), QSqlError::StatementError));
+         return false;
+diff --git a/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp b/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
+index 7ca055eea2..6bc9d46755 100644
+--- a/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
++++ b/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
+@@ -223,7 +223,7 @@ public:
+     struct QMyField
+     {
+         char *outField = nullptr;
+-        MYSQL_FIELD *myField = nullptr;
++        const MYSQL_FIELD *myField = nullptr;
+         QMetaType::Type type = QMetaType::UnknownType;
+         my_bool nullIndicator = false;
+         ulong bufLength = 0ul;
+@@ -361,7 +361,7 @@ static bool qIsInteger(int t)
+ void QMYSQLResultPrivate::bindBlobs()
+ {
+     int i;
+-    MYSQL_FIELD *fieldInfo;
++    const MYSQL_FIELD *fieldInfo;
+     MYSQL_BIND *bind;
+ 
+     for(i = 0; i < fields.count(); ++i) {
+@@ -379,7 +379,6 @@ void QMYSQLResultPrivate::bindBlobs()
+ bool QMYSQLResultPrivate::bindInValues()
+ {
+     MYSQL_BIND *bind;
+-    char *field;
+     int i = 0;
+ 
+     if (!meta)
+@@ -392,35 +391,34 @@ bool QMYSQLResultPrivate::bindInValues()
+     inBinds = new MYSQL_BIND[fields.size()];
+     memset(inBinds, 0, fields.size() * sizeof(MYSQL_BIND));
+ 
+-    MYSQL_FIELD *fieldInfo;
++    const MYSQL_FIELD *fieldInfo;
+ 
+     while((fieldInfo = mysql_fetch_field(meta))) {
++        bind = &inBinds[i];
++
+         QMyField &f = fields[i];
+         f.myField = fieldInfo;
+-
++        bind->buffer_length = f.bufLength = fieldInfo->length + 1;
++        bind->buffer_type = fieldInfo->type;
+         f.type = qDecodeMYSQLType(fieldInfo->type, fieldInfo->flags);
+         if (qIsBlob(fieldInfo->type)) {
+             // the size of a blob-field is available as soon as we call
+             // mysql_stmt_store_result()
+             // after mysql_stmt_exec() in QMYSQLResult::exec()
+-            fieldInfo->length = 0;
++            bind->buffer_length = f.bufLength = 0;
+             hasBlobs = true;
+         } else if (qIsInteger(f.type)) {
+-            fieldInfo->length = 8;
++            bind->buffer_length = f.bufLength = 8;
+         } else {
+-            fieldInfo->type = MYSQL_TYPE_STRING;
++            bind->buffer_type = MYSQL_TYPE_STRING;
+         }
+-        bind = &inBinds[i];
+-        field = new char[fieldInfo->length + 1];
+-        memset(field, 0, fieldInfo->length + 1);
+ 
+-        bind->buffer_type = fieldInfo->type;
+-        bind->buffer = field;
+-        bind->buffer_length = f.bufLength = fieldInfo->length + 1;
+         bind->is_null = &f.nullIndicator;
+         bind->length = &f.bufLength;
+         bind->is_unsigned = fieldInfo->flags & UNSIGNED_FLAG ? 1 : 0;
+-        f.outField=field;
++
++        char *field = new char[bind->buffer_length + 1]{};
++        bind->buffer = f.outField = field;
+ 
+         ++i;
+     }
+@@ -1369,20 +1367,20 @@ bool QMYSQLDriver::open(const QString& db,
+     }
+ 
+ #if MYSQL_VERSION_ID >= 50007
+-    if (mysql_get_client_version() >= 50503 && mysql_get_server_version(d->mysql) >= 50503) {
+-        // force the communication to be utf8mb4 (only utf8mb4 supports 4-byte characters)
+-        mysql_set_character_set(d->mysql, "utf8mb4");
++    // force the communication to be utf8mb4 (only utf8mb4 supports 4-byte characters)
++    if (mysql_set_character_set(d->mysql, "utf8mb4")) {
++        // this failed, try forcing it to utf (BMP only)
++        if (mysql_set_character_set(d->mysql, "utf8"))
++            qWarning() << "MySQL: Unable to set the client character set to utf8.";
+ #if QT_CONFIG(textcodec)
+-        d->tc = QTextCodec::codecForName("UTF-8");
++        else
++            d->tc = codec(d->mysql);
+ #endif
+-    } else
+-    {
+-        // force the communication to be utf8
+-        mysql_set_character_set(d->mysql, "utf8");
++    }
+ #if QT_CONFIG(textcodec)
+-        d->tc = codec(d->mysql);
++    else
++        d->tc = QTextCodec::codecForName("UTF-8");
+ #endif
+-    }
+ #endif  // MYSQL_VERSION_ID >= 50007
+ 
+     d->preparedQuerysEnabled = checkPreparedQueries(d->mysql);
+diff --git a/qtbase/src/printsupport/dialogs/images/print-24.png b/qtbase/src/printsupport/dialogs/images/printer-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/print-24.png
+rename to src/printsupport/dialogs/images/printer-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/print-32.png b/qtbase/src/printsupport/dialogs/images/printer-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/print-32.png
+rename to src/printsupport/dialogs/images/printer-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-sided-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-facing-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-sided-24.png
+rename to src/printsupport/dialogs/images/view-pages-facing-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-sided-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-facing-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-sided-32.png
+rename to src/printsupport/dialogs/images/view-pages-facing-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-multi-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-overview-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-multi-24.png
+rename to src/printsupport/dialogs/images/view-pages-overview-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-multi-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-overview-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-multi-32.png
+rename to src/printsupport/dialogs/images/view-pages-overview-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-one-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-single-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-one-24.png
+rename to src/printsupport/dialogs/images/view-pages-single-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-one-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-single-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-one-32.png
+rename to src/printsupport/dialogs/images/view-pages-single-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-page-24.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-page-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-page-24.png
+rename to src/printsupport/dialogs/images/zoom-fit-page-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-page-32.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-page-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-page-32.png
+rename to src/printsupport/dialogs/images/zoom-fit-page-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-width-24.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-width-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-width-24.png
+rename to src/printsupport/dialogs/images/zoom-fit-width-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-width-32.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-width-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-width-32.png
+rename to src/printsupport/dialogs/images/zoom-fit-width-32.png
+diff --git a/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp b/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
+index 78e5b8d1ef..2a28516719 100644
+--- a/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
++++ b/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
+@@ -532,6 +532,7 @@ void QPageSetupWidget::updateWidget()
+ void QPageSetupWidget::setupPrinter() const
+ {
+     m_printer->setPageLayout(m_pageLayout);
++    m_printer->setPageOrientation(m_pageLayout.orientation());
+ #if QT_CONFIG(cups)
+     QCUPSSupport::PagesPerSheet pagesPerSheet = qvariant_cast<QCUPSSupport::PagesPerSheet>(m_ui.pagesPerSheetCombo->currentData()
+ );
+diff --git a/qtbase/src/printsupport/dialogs/qprintdialog.qrc b/qtbase/src/printsupport/dialogs/qprintdialog.qrc
+index 5a579baa55..10b8e1d341 100644
+--- a/qtbase/src/printsupport/dialogs/qprintdialog.qrc
++++ b/qtbase/src/printsupport/dialogs/qprintdialog.qrc
+@@ -1,9 +1,9 @@
+ <!DOCTYPE RCC><RCC version="1.0">
+ <qresource prefix="/qt-project.org/dialogs/qprintpreviewdialog">
+-<file>images/fit-page-24.png</file>
+-<file>images/fit-page-32.png</file>
+-<file>images/fit-width-24.png</file>
+-<file>images/fit-width-32.png</file>
++<file>images/zoom-fit-page-24.png</file>
++<file>images/zoom-fit-page-32.png</file>
++<file>images/zoom-fit-width-24.png</file>
++<file>images/zoom-fit-width-32.png</file>
+ <file>images/go-first-24.png</file>
+ <file>images/go-first-32.png</file>
+ <file>images/go-last-24.png</file>
+@@ -18,14 +18,14 @@
+ <file>images/layout-portrait-32.png</file>
+ <file>images/page-setup-24.png</file>
+ <file>images/page-setup-32.png</file>
+-<file>images/print-24.png</file>
+-<file>images/print-32.png</file>
+-<file>images/view-page-multi-24.png</file>
+-<file>images/view-page-multi-32.png</file>
+-<file>images/view-page-one-24.png</file>
+-<file>images/view-page-one-32.png</file>
+-<file>images/view-page-sided-24.png</file>
+-<file>images/view-page-sided-32.png</file>
++<file>images/printer-24.png</file>
++<file>images/printer-32.png</file>
++<file>images/view-pages-overview-24.png</file>
++<file>images/view-pages-overview-32.png</file>
++<file>images/view-pages-single-24.png</file>
++<file>images/view-pages-single-32.png</file>
++<file>images/view-pages-facing-24.png</file>
++<file>images/view-pages-facing-32.png</file>
+ <file>images/zoom-in-24.png</file>
+ <file>images/zoom-in-32.png</file>
+ <file>images/zoom-out-24.png</file>
+diff --git a/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp b/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
+index c5b845f4ec..5a5ba1d0a8 100644
+--- a/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
++++ b/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
+@@ -702,13 +702,14 @@ void QPrintDialogPrivate::selectPrinter(const QPrinter::OutputFormat outputForma
+         else
+             options.grayscale->setChecked(true);
+ 
+-        // keep duplex value explicitly set by user, if any, and selected printer supports it;
+-        // use device default otherwise
++        // duplex priorities to be as follows:
++        // 1) a user-selected duplex value in the dialog has highest prority
++        // 2) duplex value set in the QPrinter
+         QPrint::DuplexMode duplex;
+         if (explicitDuplexMode != QPrint::DuplexAuto && supportedDuplexMode.contains(explicitDuplexMode))
+             duplex = explicitDuplexMode;
+         else
+-            duplex = top->d->m_currentPrintDevice.defaultDuplexMode();
++            duplex = static_cast<QPrint::DuplexMode>(p->duplex());
+         switch (duplex) {
+         case QPrint::DuplexNone:
+             options.noDuplex->setChecked(true); break;
+@@ -1242,10 +1243,10 @@ void QUnixPrintWidgetPrivate::_q_printerChanged(int index)
+             QString filename = widget.filename->text();
+             widget.filename->setText(filename);
+             widget.lOutput->setEnabled(true);
+-            if (optionsPane)
+-                optionsPane->selectPrinter(QPrinter::PdfFormat);
+             printer->setOutputFormat(QPrinter::PdfFormat);
+             m_currentPrintDevice = QPrintDevice();
++            if (optionsPane)
++                optionsPane->selectPrinter(QPrinter::PdfFormat);
+             return;
+         }
+     }
+diff --git a/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp b/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
+index 39575d5f57..23b7e89538 100644
+--- a/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
++++ b/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
+@@ -352,7 +352,7 @@ void QPrintPreviewDialogPrivate::init(QPrinter *_printer)
+ static inline void qt_setupActionIcon(QAction *action, QLatin1String name)
+ {
+     QLatin1String imagePrefix(":/qt-project.org/dialogs/qprintpreviewdialog/images/");
+-    QIcon icon;
++    QIcon icon = QIcon::fromTheme(name);
+     icon.addFile(imagePrefix + name + QLatin1String("-24.png"), QSize(24, 24));
+     icon.addFile(imagePrefix + name + QLatin1String("-32.png"), QSize(32, 32));
+     action->setIcon(icon);
+@@ -383,8 +383,8 @@ void QPrintPreviewDialogPrivate::setupActions()
+     fitPageAction->setObjectName(QLatin1String("fitPageAction"));
+     fitWidthAction->setCheckable(true);
+     fitPageAction->setCheckable(true);
+-    qt_setupActionIcon(fitWidthAction, QLatin1String("fit-width"));
+-    qt_setupActionIcon(fitPageAction, QLatin1String("fit-page"));
++    qt_setupActionIcon(fitWidthAction, QLatin1String("zoom-fit-width"));
++    qt_setupActionIcon(fitPageAction, QLatin1String("zoom-fit-page"));
+     QObject::connect(fitGroup, SIGNAL(triggered(QAction*)), q, SLOT(_q_fit(QAction*)));
+ 
+     // Zoom
+@@ -410,9 +410,9 @@ void QPrintPreviewDialogPrivate::setupActions()
+     singleModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show single page"));
+     facingModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show facing pages"));
+     overviewModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show overview of all pages"));
+-    qt_setupActionIcon(singleModeAction, QLatin1String("view-page-one"));
+-    qt_setupActionIcon(facingModeAction, QLatin1String("view-page-sided"));
+-    qt_setupActionIcon(overviewModeAction, QLatin1String("view-page-multi"));
++    qt_setupActionIcon(singleModeAction, QLatin1String("view-pages-single"));
++    qt_setupActionIcon(facingModeAction, QLatin1String("view-pages-facing"));
++    qt_setupActionIcon(overviewModeAction, QLatin1String("view-pages-overview"));
+     singleModeAction->setObjectName(QLatin1String("singleModeAction"));
+     facingModeAction->setObjectName(QLatin1String("facingModeAction"));
+     overviewModeAction->setObjectName(QLatin1String("overviewModeAction"));
+@@ -426,7 +426,7 @@ void QPrintPreviewDialogPrivate::setupActions()
+     printerGroup = new QActionGroup(q);
+     printAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Print"));
+     pageSetupAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Page setup"));
+-    qt_setupActionIcon(printAction, QLatin1String("print"));
++    qt_setupActionIcon(printAction, QLatin1String("printer"));
+     qt_setupActionIcon(pageSetupAction, QLatin1String("page-setup"));
+     QObject::connect(printAction, SIGNAL(triggered(bool)), q, SLOT(_q_print()));
+     QObject::connect(pageSetupAction, SIGNAL(triggered(bool)), q, SLOT(_q_pageSetup()));
+diff --git a/qtbase/src/sql/kernel/qsqlquery.cpp b/qtbase/src/sql/kernel/qsqlquery.cpp
+index 32c6166c79..60afef10c3 100644
+--- a/qtbase/src/sql/kernel/qsqlquery.cpp
++++ b/qtbase/src/sql/kernel/qsqlquery.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2022 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtSql module of the Qt Toolkit.
+@@ -377,6 +377,10 @@ bool QSqlQuery::exec(const QString& query)
+     QElapsedTimer t;
+     t.start();
+ #endif
++    if (!driver()) {
++        qWarning("QSqlQuery::exec: called before driver has been set up");
++        return false;
++    }
+     if (d->ref.loadRelaxed() != 1) {
+         bool fo = isForwardOnly();
+         *this = QSqlQuery(driver()->createResult());
+diff --git a/qtbase/src/testlib/qabstractitemmodeltester.cpp b/qtbase/src/testlib/qabstractitemmodeltester.cpp
+index 8efb9c53d4..ce062f66d7 100644
+--- a/qtbase/src/testlib/qabstractitemmodeltester.cpp
++++ b/qtbase/src/testlib/qabstractitemmodeltester.cpp
+@@ -454,7 +454,7 @@ void QAbstractItemModelTesterPrivate::parent()
+ 
+     // Common error test #2, make sure that a second level index has a parent
+     // that is the first level index.
+-    if (model->rowCount(topIndex) > 0) {
++    if (model->rowCount(topIndex) > 0 && model->columnCount(topIndex) > 0) {
+         QModelIndex childIndex = model->index(0, 0, topIndex);
+         MODELTESTER_VERIFY(childIndex.isValid());
+         MODELTESTER_COMPARE(model->parent(childIndex), topIndex);
+diff --git a/qtbase/src/testlib/qasciikey.cpp b/qtbase/src/testlib/qasciikey.cpp
+index 9a308da2bc..93498b256f 100644
+--- a/qtbase/src/testlib/qasciikey.cpp
++++ b/qtbase/src/testlib/qasciikey.cpp
+@@ -498,6 +498,11 @@ char QTest::keyToAscii(Qt::Key key)
+     case Qt::Key_LaunchE : return 0; // = 0x10b0,
+     case Qt::Key_LaunchF : return 0; // = 0x10b1,
+ 
++    // Keypad navigation keys
++    case Qt::Key_Select : return 0; // = 0x01010000
++    case Qt::Key_Yes : return 0; // = 0x01010001
++    case Qt::Key_No : return 0; // = 0x01010002
++
+     default: QTEST_ASSERT(false); return 0;
+     }
+ }
+diff --git a/qtbase/src/testlib/qtestresult.cpp b/qtbase/src/testlib/qtestresult.cpp
+index 88028aac6e..2e89930776 100644
+--- a/qtbase/src/testlib/qtestresult.cpp
++++ b/qtbase/src/testlib/qtestresult.cpp
+@@ -251,7 +251,8 @@ bool QTestResult::verify(bool statement, const char *statementStr,
+ {
+     QTEST_ASSERT(statementStr);
+ 
+-    char msg[1024] = {'\0'};
++    char msg[1024];
++    msg[0] = '\0';
+ 
+     if (QTestLog::verboseLevel() >= 2) {
+         qsnprintf(msg, 1024, "QVERIFY(%s)", statementStr);
+@@ -309,7 +310,8 @@ static bool compareHelper(bool success, const char *failureMsg,
+                           bool hasValues = true)
+ {
+     const size_t maxMsgLen = 1024;
+-    char msg[maxMsgLen] = {'\0'};
++    char msg[maxMsgLen];
++    msg[0] = '\0';
+ 
+     QTEST_ASSERT(expected);
+     QTEST_ASSERT(actual);
+diff --git a/qtbase/src/widgets/dialogs/qcolordialog.cpp b/qtbase/src/widgets/dialogs/qcolordialog.cpp
+index 4247731275..cb325be85c 100644
+--- a/qtbase/src/widgets/dialogs/qcolordialog.cpp
++++ b/qtbase/src/widgets/dialogs/qcolordialog.cpp
+@@ -78,7 +78,10 @@
+ #include "qwindow.h"
+ 
+ #include "private/qdialog_p.h"
++#include "private/qguiapplication_p.h"
+ 
++#include <qpa/qplatformservices.h>
++#include <qpa/qplatformintegration.h>
+ #include <algorithm>
+ 
+ QT_BEGIN_NAMESPACE
+@@ -1611,6 +1614,20 @@ void QColorDialogPrivate::_q_newStandard(int r, int c)
+ void QColorDialogPrivate::_q_pickScreenColor()
+ {
+     Q_Q(QColorDialog);
++
++    auto *platformServices = QGuiApplicationPrivate::platformIntegration()->services();
++    if (platformServices->hasCapability(QPlatformServices::Capability::ColorPicking)) {
++        if (auto *colorPicker = platformServices->colorPicker(q->windowHandle())) {
++            q->connect(colorPicker, &QPlatformServiceColorPicker::colorPicked, q,
++                       [q, colorPicker](const QColor &color) {
++                           colorPicker->deleteLater();
++                           q->setCurrentColor(color);
++                       });
++            colorPicker->pickColor();
++            return;
++        }
++    }
++
+     if (!colorPickingEventFilter)
+         colorPickingEventFilter = new QColorPickingEventFilter(this, q);
+     q->installEventFilter(colorPickingEventFilter);
+diff --git a/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp b/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
+index e120817edc..8ea36b5427 100644
+--- a/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
++++ b/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
+@@ -400,12 +400,7 @@ bool QAbstractItemDelegate::helpEvent(QHelpEvent *event,
+         const QString tooltip = index.isValid() ?
+               d->textForRole(Qt::ToolTipRole, index.data(Qt::ToolTipRole), option.locale, precision) :
+               QString();
+-        QRect rect;
+-        if (index.isValid()) {
+-            const QRect r = view->visualRect(index);
+-            rect = QRect(view->mapToGlobal(r.topLeft()), r.size());
+-        }
+-        QToolTip::showText(he->globalPos(), tooltip, view, rect);
++        QToolTip::showText(he->globalPos(), tooltip, view->viewport(), option.rect);
+         event->setAccepted(!tooltip.isEmpty());
+         break;
+         }
+diff --git a/qtbase/src/widgets/itemviews/qlistview.cpp b/qtbase/src/widgets/itemviews/qlistview.cpp
+index 2b34476642..eebfaa030e 100644
+--- a/qtbase/src/widgets/itemviews/qlistview.cpp
++++ b/qtbase/src/widgets/itemviews/qlistview.cpp
+@@ -3386,6 +3386,7 @@ void QIconModeViewBase::updateContentsSize()
+ */
+ void QListView::currentChanged(const QModelIndex &current, const QModelIndex &previous)
+ {
++    QAbstractItemView::currentChanged(current, previous);
+ #ifndef QT_NO_ACCESSIBILITY
+     if (QAccessible::isActive()) {
+         if (current.isValid()) {
+@@ -3396,7 +3397,6 @@ void QListView::currentChanged(const QModelIndex &current, const QModelIndex &pr
+         }
+     }
+ #endif
+-    QAbstractItemView::currentChanged(current, previous);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/widgets/itemviews/qtableview.cpp b/qtbase/src/widgets/itemviews/qtableview.cpp
+index 934ac581b2..f79bb24249 100644
+--- a/qtbase/src/widgets/itemviews/qtableview.cpp
++++ b/qtbase/src/widgets/itemviews/qtableview.cpp
+@@ -1013,6 +1013,7 @@ void QTableViewPrivate::drawCell(QPainter *painter, const QStyleOptionViewItem &
+ int QTableViewPrivate::widthHintForIndex(const QModelIndex &index, int hint, const QStyleOptionViewItem &option) const
+ {
+     Q_Q(const QTableView);
++    const int oldHint = hint;
+     QWidget *editor = editorForIndex(index).widget.data();
+     if (editor && persistent.contains(editor)) {
+         hint = qMax(hint, editor->sizeHint().width());
+@@ -1021,6 +1022,17 @@ int QTableViewPrivate::widthHintForIndex(const QModelIndex &index, int hint, con
+         hint = qBound(min, hint, max);
+     }
+     hint = qMax(hint, q->itemDelegate(index)->sizeHint(option, index).width());
++
++    if (hasSpans()) {
++        auto span = spans.spanAt(index.column(), index.row());
++        if (span && span->m_left == index.column() && span->m_top == index.row()) {
++            // spans are screwed up when sections are moved
++            const auto left = logicalColumn(span->m_left);
++            for (int i = 1; i <= span->width(); ++i)
++               hint -= q->columnWidth(visualColumn(left + i));
++        }
++        hint = std::max(hint, oldHint);
++    }
+     return hint;
+ }
+ 
+@@ -1053,6 +1065,11 @@ int QTableViewPrivate::heightHintForIndex(const QModelIndex &index, int hint, QS
+         option.rect.setHeight(height);
+         option.rect.setX(q->columnViewportPosition(index.column()));
+         option.rect.setWidth(q->columnWidth(index.column()));
++        if (hasSpans()) {
++            auto span = spans.spanAt(index.column(), index.row());
++            if (span && span->m_left == index.column() && span->m_top == index.row())
++                option.rect.setWidth(std::max(option.rect.width(), visualSpanRect(*span).width()));
++        }
+         // 1px less space when grid is shown (see drawCell)
+         if (showGrid)
+             option.rect.setWidth(option.rect.width() - 1);
+diff --git a/qtbase/src/widgets/kernel/qaction.h b/qtbase/src/widgets/kernel/qaction.h
+index 258a1ea0a0..737c1e8285 100644
+--- a/qtbase/src/widgets/kernel/qaction.h
++++ b/qtbase/src/widgets/kernel/qaction.h
+@@ -81,7 +81,7 @@ class Q_WIDGETS_EXPORT QAction : public QObject
+     Q_PROPERTY(MenuRole menuRole READ menuRole WRITE setMenuRole NOTIFY changed)
+     Q_PROPERTY(bool iconVisibleInMenu READ isIconVisibleInMenu WRITE setIconVisibleInMenu NOTIFY changed)
+     Q_PROPERTY(bool shortcutVisibleInContextMenu READ isShortcutVisibleInContextMenu WRITE setShortcutVisibleInContextMenu NOTIFY changed)
+-    Q_PROPERTY(Priority priority READ priority WRITE setPriority)
++    Q_PROPERTY(Priority priority READ priority WRITE setPriority NOTIFY changed)
+ 
+ public:
+     // note this is copied into qplatformmenu.h, which must stay in sync
+diff --git a/qtbase/src/widgets/kernel/qwidget.cpp b/qtbase/src/widgets/kernel/qwidget.cpp
+index 9eba1e001e..26f6d27e18 100644
+--- a/qtbase/src/widgets/kernel/qwidget.cpp
++++ b/qtbase/src/widgets/kernel/qwidget.cpp
+@@ -5296,7 +5296,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
+         QWidgetEffectSourcePrivate *sourced = static_cast<QWidgetEffectSourcePrivate *>
+                                                          (source->d_func());
+         if (!sourced->context) {
+-            const QRegion effectRgn(rgn.boundingRect());
++            const QRegion effectRgn((flags & UseEffectRegionBounds) ? rgn.boundingRect() : rgn);
+             QWidgetPaintContext context(pdev, effectRgn, offset, flags, sharedPainter, repaintManager);
+             sourced->context = &context;
+             if (!sharedPainter) {
+@@ -5328,6 +5328,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
+         }
+     }
+ #endif // QT_CONFIG(graphicseffect)
++    flags = flags & ~UseEffectRegionBounds;
+ 
+     const bool alsoOnScreen = flags & DrawPaintOnScreen;
+     const bool recursive = flags & DrawRecursive;
+diff --git a/qtbase/src/widgets/kernel/qwidget_p.h b/qtbase/src/widgets/kernel/qwidget_p.h
+index eef6b8fa2c..c432f4b5d5 100644
+--- a/qtbase/src/widgets/kernel/qwidget_p.h
++++ b/qtbase/src/widgets/kernel/qwidget_p.h
+@@ -229,7 +229,8 @@ public:
+         DontSubtractOpaqueChildren = 0x10,
+         DontDrawOpaqueChildren = 0x20,
+         DontDrawNativeChildren = 0x40,
+-        DontSetCompositionMode = 0x80
++        DontSetCompositionMode = 0x80,
++        UseEffectRegionBounds = 0x100
+     };
+     Q_DECLARE_FLAGS(DrawWidgetFlags, DrawWidgetFlag)
+     Q_FLAG(DrawWidgetFlags)
+diff --git a/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp b/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
+index 02880b34da..0d44e1326d 100644
+--- a/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
++++ b/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
+@@ -1018,7 +1018,8 @@ void QWidgetRepaintManager::paintAndFlush()
+ 
+     // Paint the rest with composition.
+     if (repaintAllWidgets || !dirtyCopy.isEmpty()) {
+-        QWidgetPrivate::DrawWidgetFlags flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive;
++        QWidgetPrivate::DrawWidgetFlags flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive
++                | QWidgetPrivate::UseEffectRegionBounds;
+         tlw->d_func()->drawWidget(store->paintDevice(), dirtyCopy, QPoint(), flags, nullptr, this);
+     }
+ 
+diff --git a/qtbase/src/widgets/styles/qfusionstyle.cpp b/qtbase/src/widgets/styles/qfusionstyle.cpp
+index f4345d97c4..962912c838 100644
+--- a/qtbase/src/widgets/styles/qfusionstyle.cpp
++++ b/qtbase/src/widgets/styles/qfusionstyle.cpp
+@@ -1772,14 +1772,6 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio
+             proxy()->drawControl(CE_PushButtonLabel, &subopt, painter, widget);
+         }
+         break;
+-    case CE_PushButtonLabel:
+-        if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
+-            QStyleOptionButton b(*button);
+-            // no PM_ButtonShiftHorizontal and PM_ButtonShiftVertical for fusion style
+-            b.state &= ~(State_On | State_Sunken);
+-            QCommonStyle::drawControl(element, &b, painter, widget);
+-        }
+-        break;
+     case CE_MenuBarEmptyArea:
+         painter->save();
+     {
+diff --git a/qtbase/src/widgets/util/qcompleter.cpp b/qtbase/src/widgets/util/qcompleter.cpp
+index 18b24063d8..ef7207a8a3 100644
+--- a/qtbase/src/widgets/util/qcompleter.cpp
++++ b/qtbase/src/widgets/util/qcompleter.cpp
+@@ -1120,6 +1120,8 @@ void QCompleter::setModel(QAbstractItemModel *model)
+ {
+     Q_D(QCompleter);
+     QAbstractItemModel *oldModel = d->proxy->sourceModel();
++    if (oldModel == model)
++        return;
+ #if QT_CONFIG(filesystemmodel)
+     if (qobject_cast<const QFileSystemModel *>(oldModel))
+         setCompletionRole(Qt::EditRole); // QTBUG-54642, clear FileNameRole set by QFileSystemModel
+diff --git a/qtbase/src/widgets/widgets/qabstractbutton.cpp b/qtbase/src/widgets/widgets/qabstractbutton.cpp
+index a128b23950..dc40bf62fb 100644
+--- a/qtbase/src/widgets/widgets/qabstractbutton.cpp
++++ b/qtbase/src/widgets/widgets/qabstractbutton.cpp
+@@ -56,6 +56,7 @@
+ #ifndef QT_NO_ACCESSIBILITY
+ #include "qaccessible.h"
+ #endif
++#include <qpa/qplatformtheme.h>
+ 
+ #include <algorithm>
+ 
+@@ -1076,19 +1077,19 @@ void QAbstractButton::keyPressEvent(QKeyEvent *e)
+ {
+     Q_D(QAbstractButton);
+     bool next = true;
+-    switch (e->key()) {
+-    case Qt::Key_Enter:
+-    case Qt::Key_Return:
+-        e->ignore();
+-        break;
+-    case Qt::Key_Select:
+-    case Qt::Key_Space:
+-        if (!e->isAutoRepeat()) {
+-            setDown(true);
+-            repaint();
+-            d->emitPressed();
+-        }
+-        break;
++
++    const auto key = static_cast<Qt::Key>(e->key());
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(key) && !e->isAutoRepeat()) {
++        setDown(true);
++        repaint();
++        d->emitPressed();
++        return;
++    }
++
++    switch (key) {
+     case Qt::Key_Up:
+         next = false;
+         Q_FALLTHROUGH();
+@@ -1153,15 +1154,15 @@ void QAbstractButton::keyReleaseEvent(QKeyEvent *e)
+     if (!e->isAutoRepeat())
+         d->repeatTimer.stop();
+ 
+-    switch (e->key()) {
+-    case Qt::Key_Select:
+-    case Qt::Key_Space:
+-        if (!e->isAutoRepeat() && d->down)
+-            d->click();
+-        break;
+-    default:
+-        e->ignore();
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(static_cast<Qt::Key>(e->key())) && !e->isAutoRepeat() && d->down) {
++        d->click();
++        return;
+     }
++
++    e->ignore();
+ }
+ 
+ /*!\reimp
+diff --git a/qtbase/src/widgets/widgets/qcombobox.cpp b/qtbase/src/widgets/widgets/qcombobox.cpp
+index 7a496c27e0..0a3d96647b 100644
+--- a/qtbase/src/widgets/widgets/qcombobox.cpp
++++ b/qtbase/src/widgets/widgets/qcombobox.cpp
+@@ -3352,7 +3352,23 @@ void QComboBox::keyPressEvent(QKeyEvent *e)
+ 
+     Move move = NoMove;
+     int newIndex = currentIndex();
+-    switch (e->key()) {
++
++    bool pressLikeButton = !d->lineEdit;
++#ifdef QT_KEYPAD_NAVIGATION
++    pressLikeButton |= QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus();
++#endif
++    auto key = static_cast<Qt::Key>(e->key());
++    if (pressLikeButton) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(key)) {
++            showPopup();
++            return;
++        }
++    }
++
++    switch (key) {
+     case Qt::Key_Up:
+         if (e->modifiers() & Qt::ControlModifier)
+             break; // pass to line edit for auto completion
+@@ -3394,26 +3410,11 @@ void QComboBox::keyPressEvent(QKeyEvent *e)
+             return;
+         }
+         break;
+-    case Qt::Key_Space:
+-        if (!d->lineEdit) {
+-            showPopup();
+-            return;
+-        }
+-        break;
+-    case Qt::Key_Enter:
+-    case Qt::Key_Return:
+     case Qt::Key_Escape:
+         if (!d->lineEdit)
+             e->ignore();
+         break;
+ #ifdef QT_KEYPAD_NAVIGATION
+-    case Qt::Key_Select:
+-        if (QApplicationPrivate::keypadNavigationEnabled()
+-                && (!hasEditFocus() || !d->lineEdit)) {
+-            showPopup();
+-            return;
+-        }
+-        break;
+     case Qt::Key_Left:
+     case Qt::Key_Right:
+         if (QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus())
+diff --git a/qtbase/src/widgets/widgets/qdatetimeedit_p.h b/qtbase/src/widgets/widgets/qdatetimeedit_p.h
+index d36b6f8f9a..e0df5b5158 100644
+--- a/qtbase/src/widgets/widgets/qdatetimeedit_p.h
++++ b/qtbase/src/widgets/widgets/qdatetimeedit_p.h
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2018 The Qt Company Ltd.
++** Copyright (C) 2021 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtWidgets module of the Qt Toolkit.
+diff --git a/qtbase/src/widgets/widgets/qgroupbox.cpp b/qtbase/src/widgets/widgets/qgroupbox.cpp
+index 02a0bed325..3f3eccc370 100644
+--- a/qtbase/src/widgets/widgets/qgroupbox.cpp
++++ b/qtbase/src/widgets/widgets/qgroupbox.cpp
+@@ -54,6 +54,8 @@
+ #include "qaccessible.h"
+ #endif
+ #include <private/qwidget_p.h>
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
+ 
+ #include "qdebug.h"
+ 
+@@ -360,7 +362,10 @@ bool QGroupBox::event(QEvent *e)
+         return true;
+     case QEvent::KeyPress: {
+         QKeyEvent *k = static_cast<QKeyEvent*>(e);
+-        if (!k->isAutoRepeat() && (k->key() == Qt::Key_Select || k->key() == Qt::Key_Space)) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (!k->isAutoRepeat() && buttonPressKeys.contains(static_cast<Qt::Key>(k->key()))) {
+             d->pressedControl = QStyle::SC_GroupBoxCheckBox;
+             update(style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxCheckBox, this));
+             return true;
+@@ -369,7 +374,10 @@ bool QGroupBox::event(QEvent *e)
+     }
+     case QEvent::KeyRelease: {
+         QKeyEvent *k = static_cast<QKeyEvent*>(e);
+-        if (!k->isAutoRepeat() && (k->key() == Qt::Key_Select || k->key() == Qt::Key_Space)) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (!k->isAutoRepeat() && buttonPressKeys.contains(static_cast<Qt::Key>(k->key()))) {
+             bool toggle = (d->pressedControl == QStyle::SC_GroupBoxLabel
+                            || d->pressedControl == QStyle::SC_GroupBoxCheckBox);
+             d->pressedControl = QStyle::SC_None;
+diff --git a/qtbase/src/widgets/widgets/qlabel.cpp b/qtbase/src/widgets/widgets/qlabel.cpp
+index 30ff80cbb0..cf2605c17c 100644
+--- a/qtbase/src/widgets/widgets/qlabel.cpp
++++ b/qtbase/src/widgets/widgets/qlabel.cpp
+@@ -421,9 +421,6 @@ void QLabel::setPixmap(const QPixmap &pixmap)
+         d->pixmap = new QPixmap(pixmap);
+     }
+ 
+-    if (d->pixmap->depth() == 1 && !d->pixmap->mask())
+-        d->pixmap->setMask(*((QBitmap *)d->pixmap));
+-
+     d->updateLabel();
+ }
+ 
+diff --git a/qtbase/src/widgets/widgets/qtoolbararealayout.cpp b/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
+index 493c094cc1..d5f4b59017 100644
+--- a/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
++++ b/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
+@@ -1367,7 +1367,7 @@ bool QToolBarAreaLayout::restoreState(QDataStream &stream, const QList<QToolBar*
+                 item.widgetItem = new QWidgetItemV2(toolBar);
+                 toolBar->setOrientation(floating ? ((shown & 2) ? Qt::Vertical : Qt::Horizontal) : dock.o);
+                 toolBar->setVisible(shown & 1);
+-                toolBar->d_func()->setWindowState(floating, true, rect);
++                toolBar->d_func()->setWindowState(floating, false, rect);
+ 
+                 item.preferredSize = item.size;
+                 line.toolBarItems.append(item);
+diff --git a/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp b/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
+index 212c0a2e13..3c77b1ba0b 100644
+--- a/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
++++ b/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
+@@ -126,8 +126,7 @@ public:
+ 
+ void tst_QtConcurrentIterateKernel::instantiate()
+ {
+-    auto future = startThreadEngine(new PrintFor(0, 40)).startAsynchronously();
+-    future.waitForFinished();
++    startThreadEngine(new PrintFor(0, 40)).startBlocking();
+     QCOMPARE(iterations.loadRelaxed(), 40);
+ }
+ 
+@@ -166,10 +165,8 @@ void tst_QtConcurrentIterateKernel::stresstest()
+     const int times = 50;
+     for (int i = 0; i < times; ++i) {
+         counter.storeRelaxed(0);
+-        // ThreadEngine will delete f when it finishes
+-        auto f = new CountFor(0, iterations);
+-        auto future = f->startAsynchronously();
+-        future.waitForFinished();
++        CountFor f(0, iterations);
++        f.startBlocking();
+         QCOMPARE(counter.loadRelaxed(), iterations);
+     }
+ }
+@@ -177,11 +174,8 @@ void tst_QtConcurrentIterateKernel::stresstest()
+ void tst_QtConcurrentIterateKernel::noIterations()
+ {
+     const int times = 20000;
+-    for (int i = 0; i < times; ++i) {
+-        auto future = startThreadEngine(new IterateKernel<TestIterator, void>(0, 0))
+-                              .startAsynchronously();
+-        future.waitForFinished();
+-    }
++    for (int i = 0; i < times; ++i)
++        startThreadEngine(new IterateKernel<TestIterator, void>(0, 0)).startBlocking();
+ }
+ 
+ QMutex threadsMutex;
+@@ -236,10 +230,8 @@ void tst_QtConcurrentIterateKernel::throttling()
+ 
+     threads.clear();
+ 
+-    // ThreadEngine will delete f when it finishes
+-    auto f = new ThrottleFor(0, totalIterations);
+-    auto future = f->startAsynchronously();
+-    future.waitForFinished();
++    ThrottleFor f(0, totalIterations);
++    f.startBlocking();
+ 
+     QCOMPARE(iterations.loadRelaxed(), totalIterations);
+ 
+diff --git a/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp b/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
+index ac7be7acdd..81bc64c8d9 100644
+--- a/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
++++ b/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
+@@ -65,9 +65,16 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::runDirectly()
+ {
+-    PrintUser *engine = new PrintUser();
+-    QFuture<void> f = engine->startAsynchronously();
+-    f.waitForFinished();
++    {
++        PrintUser engine;
++        engine.startSingleThreaded();
++        engine.startBlocking();
++    }
++    {
++        PrintUser *engine = new PrintUser();
++        QFuture<void> f = engine->startAsynchronously();
++        f.waitForFinished();
++    }
+ }
+ 
+ class StringResultUser : public ThreadEngine<QString>
+@@ -99,10 +106,8 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::result()
+ {
+-    // ThreadEngine will delete 'engine' when it finishes
+-    auto engine = new StringResultUser();
+-    auto future = engine->startAsynchronously();
+-    QCOMPARE(future.result(), QString("Foo"));
++    StringResultUser engine;
++    QCOMPARE(*engine.startBlocking(), QString("Foo"));
+ }
+ 
+ class VoidResultUser : public ThreadEngine<void>
+@@ -128,9 +133,17 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::runThroughStarter()
+ {
+-    ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
+-    QFuture<QString> f = starter.startAsynchronously();
+-    QCOMPARE(f.result(), QString("Foo"));
++    {
++        ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
++        QFuture<QString>  f = starter.startAsynchronously();
++        QCOMPARE(f.result(), QString("Foo"));
++    }
++
++    {
++        ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
++        QString str = starter.startBlocking();
++        QCOMPARE(str, QString("Foo"));
++    }
+ }
+ 
+ class CancelUser : public ThreadEngine<void>
+@@ -213,6 +226,12 @@ void tst_QtConcurrentThreadEngine::throttle()
+         f.waitForFinished();
+         QCOMPARE(count.loadRelaxed(), 0);
+     }
++
++    for (int i = 0; i < repeats; ++i) {
++        ThrottleAlwaysUser t;
++        t.startBlocking();
++        QCOMPARE(count.loadRelaxed(), 0);
++    }
+ }
+ 
+ QSet<QThread *> threads;
+@@ -249,17 +268,35 @@ void tst_QtConcurrentThreadEngine::threadCount()
+ {
+     const int repeats = 10;
+     for (int i = 0; i < repeats; ++i) {
++        ThreadCountUser t;
++        t.startBlocking();
++        int count = threads.count();
++        int count_expected = QThreadPool::globalInstance()->maxThreadCount() + 1; // +1 for the main thread.
++        if (count != count_expected)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, count_expected);
++
+         (new ThreadCountUser())->startAsynchronously().waitForFinished();
+-        const auto count = threads.count();
+-        const auto maxThreadCount = QThreadPool::globalInstance()->maxThreadCount();
+-        QVERIFY(count <= maxThreadCount);
+-        QVERIFY(!threads.contains(QThread::currentThread()));
++        count = threads.count();
++        count_expected = QThreadPool::globalInstance()->maxThreadCount();
++        if (count != count_expected)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, count_expected);
+     }
+ 
+     // Set the finish flag immediately, this should give us one thread only.
+     for (int i = 0; i < repeats; ++i) {
++        ThreadCountUser t(true /*finishImmediately*/);
++        t.startBlocking();
++        int count = threads.count();
++        if (count != 1)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, 1);
++
+         (new ThreadCountUser(true /*finishImmediately*/))->startAsynchronously().waitForFinished();
+-        const auto count = threads.count();
++        count = threads.count();
++        if (count != 1)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
+         QCOMPARE(count, 1);
+         QVERIFY(!threads.contains(QThread::currentThread()));
+     }
+@@ -400,6 +437,7 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::exceptions()
+ {
++    // Asynchronous mode:
+     {
+         bool caught = false;
+         try  {
+@@ -412,6 +450,32 @@ void tst_QtConcurrentThreadEngine::exceptions()
+         QVERIFY2(caught, "did not get exception");
+     }
+ 
++    // Blocking mode:
++    // test throwing the exception from a worker thread.
++    {
++        bool caught = false;
++        try  {
++            QtConcurrentExceptionThrower e(QThread::currentThread());
++            e.startBlocking();
++        } catch (const QException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // test throwing the exception from the main thread (different code path)
++    {
++        bool caught = false;
++        try  {
++            QtConcurrentExceptionThrower e(0);
++            e.startBlocking();
++        } catch (const QException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // Asynchronous mode:
+     {
+         bool caught = false;
+         try  {
+@@ -423,6 +487,31 @@ void tst_QtConcurrentThreadEngine::exceptions()
+         }
+         QVERIFY2(caught, "did not get exception");
+     }
++
++    // Blocking mode:
++    // test throwing the exception from a worker thread.
++    {
++        bool caught = false;
++        try  {
++            UnrelatedExceptionThrower e(QThread::currentThread());
++            e.startBlocking();
++        } catch (const QUnhandledException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // test throwing the exception from the main thread (different code path)
++    {
++        bool caught = false;
++        try  {
++            UnrelatedExceptionThrower e(0);
++            e.startBlocking();
++        } catch (const QUnhandledException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
+ }
+ 
+ #endif
+diff --git a/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp b/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
+index 4968742110..f4c3fb711d 100644
+--- a/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
++++ b/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
+@@ -42,6 +42,7 @@ private slots:
+     void writeBlock_data();
+     void writeBlock();
+     void seek();
++    void invalidSeeks();
+     void seekTest_data();
+     void seekTest();
+     void read_rawdata();
+@@ -286,6 +287,29 @@ void tst_QBuffer::seek()
+     QCOMPARE(buffer.size(), pos);
+ }
+ 
++void tst_QBuffer::invalidSeeks()
++{
++    if constexpr (sizeof(qsizetype) == sizeof(qint64)) {
++        // sizeof(qsizetype) == sizeof(qint64), so +1 would overflow
++        QSKIP("This is a 32-bit-only test.");
++    } else {
++        QBuffer buffer;
++        buffer.open(QIODevice::WriteOnly);
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++        constexpr qint64 MaxQByteArrayCapacity = (std::numeric_limits<qsizetype>::max)();
++        // this should fail fast, not after trying to allocate nearly 2 GiB of data,
++        // potentially crashing in the process:
++        QVERIFY(!buffer.seek(2 * MaxQByteArrayCapacity - 1));
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++        // ditto:
++        QVERIFY(!buffer.seek(MaxQByteArrayCapacity + 1));
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++    }
++}
++
+ void tst_QBuffer::seekTest_data()
+ {
+     writeBlock_data();
+diff --git a/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp b/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
+index da5327594c..4a04e0f7c6 100644
+--- a/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
++++ b/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
+@@ -561,7 +561,8 @@ protected:
+     qint64 readData(char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf->size() - offset));
+-        memcpy(data, buf->constData() + offset, maxSize);
++        if (maxSize > 0)
++            memcpy(data, buf->constData() + offset, maxSize);
+         offset += maxSize;
+         return maxSize;
+     }
+@@ -604,13 +605,15 @@ protected:
+     qint64 readData(char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf.size() - pos()));
+-        memcpy(data, buf.constData() + pos(), maxSize);
++        if (maxSize > 0)
++            memcpy(data, buf.constData() + pos(), maxSize);
+         return maxSize;
+     }
+     qint64 writeData(const char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf.size() - pos()));
+-        memcpy(buf.data() + pos(), data, maxSize);
++        if (maxSize > 0)
++            memcpy(buf.data() + pos(), data, maxSize);
+         return maxSize;
+     }
+ 
+diff --git a/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+index db60bead64..f345a44414 100644
+--- a/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
++++ b/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+@@ -1,7 +1,8 @@
+ /****************************************************************************
+ **
+ ** Copyright (C) 2021 The Qt Company Ltd.
+-** Copyright (C) 2020 Intel Corporation.
++** Copyright (C) 2020 The Qt Company Ltd.
++** Copyright (C) 2022 Intel Corporation.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the test suite of the Qt Toolkit.
+@@ -150,6 +151,8 @@ private slots:
+     void startStopStartStopBuffers();
+     void processEventsInAReadyReadSlot_data();
+     void processEventsInAReadyReadSlot();
++    void startFromCurrentWorkingDir_data();
++    void startFromCurrentWorkingDir();
+ 
+     // keep these at the end, since they use lots of processes and sometimes
+     // caused obscure failures to occur in tests that followed them (esp. on the Mac)
+@@ -2731,5 +2734,94 @@ void tst_QProcess::finishProcessBeforeReadingDone_deprecated()
+ 
+ #endif
+ 
++enum class ChdirMode {
++    None = 0,
++    InParent,
++    InChild
++};
++Q_DECLARE_METATYPE(ChdirMode)
++
++void tst_QProcess::startFromCurrentWorkingDir_data()
++{
++    qRegisterMetaType<ChdirMode>();
++    QTest::addColumn<QString>("programPrefix");
++    QTest::addColumn<ChdirMode>("chdirMode");
++    QTest::addColumn<bool>("success");
++
++    constexpr bool IsWindows = true
++#ifdef Q_OS_UNIX
++            && false
++#endif
++            ;
++
++    // baseline: trying to execute the directory, this can't possibly succeed!
++    QTest::newRow("plain-same-cwd") << QString() << ChdirMode::None << false;
++
++    // cross-platform behavior: neither OS searches the setWorkingDirectory()
++    // dir without "./"
++    QTest::newRow("plain-child-chdir") << QString() << ChdirMode::InChild << false;
++
++    // cross-platform behavior: both OSes search the parent's CWD with "./"
++    QTest::newRow("prefixed-parent-chdir") << "./" << ChdirMode::InParent << true;
++
++    // opposite behaviors: Windows searches the parent's CWD and Unix searches
++    // the child's with "./"
++    QTest::newRow("prefixed-child-chdir") << "./" << ChdirMode::InChild << !IsWindows;
++
++    // Windows searches the parent's CWD without "./"
++    QTest::newRow("plain-parent-chdir") << QString() << ChdirMode::InParent << IsWindows;
++}
++
++void tst_QProcess::startFromCurrentWorkingDir()
++{
++    QFETCH(QString, programPrefix);
++    QFETCH(ChdirMode, chdirMode);
++    QFETCH(bool, success);
++
++    QProcess process;
++    qRegisterMetaType<QProcess::ProcessError>();
++    QSignalSpy errorSpy(&process, &QProcess::errorOccurred);
++    QVERIFY(errorSpy.isValid());
++
++    // both the dir name and the executable name
++    const QString target = QStringLiteral("testProcessNormal");
++    process.setProgram(programPrefix + target);
++
++#ifdef Q_OS_UNIX
++    // Reset PATH, to be sure it doesn't contain . or the empty path.
++    // We can't do this on Windows because DLLs are searched in PATH
++    // and Windows always searches "." anyway.
++    auto restoreEnv = qScopeGuard([old = qgetenv("PATH")] {
++        qputenv("PATH", old);
++    });
++    qputenv("PATH", "/");
++#endif
++
++    switch (chdirMode) {
++    case ChdirMode::InParent: {
++        auto restoreCwd = qScopeGuard([old = QDir::currentPath()] {
++            QDir::setCurrent(old);
++        });
++        QVERIFY(QDir::setCurrent(target));
++        process.start();
++        break;
++    }
++    case ChdirMode::InChild:
++        process.setWorkingDirectory(target);
++        Q_FALLTHROUGH();
++    case ChdirMode::None:
++        process.start();
++        break;
++    }
++
++    QCOMPARE(process.waitForStarted(), success);
++    QCOMPARE(errorSpy.count(), int(!success));
++    if (success) {
++        QVERIFY(process.waitForFinished());
++    } else {
++        QCOMPARE(process.error(), QProcess::FailedToStart);
++    }
++}
++
+ QTEST_MAIN(tst_QProcess)
+ #include "tst_qprocess.moc"
+diff --git a/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp b/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp
+index e1ea7a4552..90972caa57 100644
+--- a/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp
++++ b/qtbase/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"
+diff --git a/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+index 9bd66c0835..ed4a0bae5d 100644
+--- a/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
++++ b/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+@@ -158,6 +158,7 @@ private slots:
+     void nullReceiver();
+     void functorReferencesConnection();
+     void disconnectDisconnects();
++    void declarativeData();
+ };
+ 
+ struct QObjectCreatedOnShutdown
+@@ -7679,5 +7680,81 @@ void tst_QObject::disconnectDisconnects()
+ Q_STATIC_ASSERT(QtPrivate::HasQ_OBJECT_Macro<tst_QObject>::Value);
+ Q_STATIC_ASSERT(!QtPrivate::HasQ_OBJECT_Macro<SiblingDeleter>::Value);
+ 
++#ifdef QT_BUILD_INTERNAL
++/*
++    Since QObjectPrivate stores the declarativeData pointer in a union with the pointer
++    to the currently destroyed child, calls to the QtDeclarative handlers need to be
++    correctly guarded. QTBUG-105286
++*/
++namespace QtDeclarative {
++static QAbstractDeclarativeData *theData;
++
++static void destroyed(QAbstractDeclarativeData *data, QObject *)
++{
++    QCOMPARE(data, theData);
++}
++static void signalEmitted(QAbstractDeclarativeData *data, QObject *, int, void **)
++{
++    QCOMPARE(data, theData);
++}
++// we can't use QCOMPARE in the next two functions, as they don't return void
++static int receivers(QAbstractDeclarativeData *data, const QObject *, int)
++{
++    QTest::qCompare(data, theData, "data", "theData", __FILE__, __LINE__);
++    return 0;
++}
++static bool isSignalConnected(QAbstractDeclarativeData *data, const QObject *, int)
++{
++    QTest::qCompare(data, theData, "data", "theData", __FILE__, __LINE__);
++    return true;
++}
++
++class Object : public QObject
++{
++    Q_OBJECT
++public:
++    using QObject::QObject;
++    ~Object()
++    {
++        if (Object *p = static_cast<Object *>(parent()))
++            p->emitSignal();
++    }
++
++    void emitSignal()
++    {
++        emit theSignal();
++    }
++
++signals:
++    void theSignal();
++};
++
++}
++#endif
++
++void tst_QObject::declarativeData()
++{
++#ifdef QT_BUILD_INTERNAL
++    QScopedValueRollback destroyed(QAbstractDeclarativeData::destroyed,
++                                   QtDeclarative::destroyed);
++    QScopedValueRollback signalEmitted(QAbstractDeclarativeData::signalEmitted,
++                                       QtDeclarative::signalEmitted);
++    QScopedValueRollback receivers(QAbstractDeclarativeData::receivers,
++                                   QtDeclarative::receivers);
++    QScopedValueRollback isSignalConnected(QAbstractDeclarativeData::isSignalConnected,
++                                           QtDeclarative::isSignalConnected);
++
++    QtDeclarative::Object p;
++    QObjectPrivate *priv = QObjectPrivate::get(&p);
++    priv->declarativeData = QtDeclarative::theData = new QAbstractDeclarativeData;
++
++    connect(&p, &QtDeclarative::Object::theSignal, &p, []{
++    });
++
++    QtDeclarative::Object *child = new QtDeclarative::Object;
++    child->setParent(&p);
++#endif
++}
++
+ QTEST_MAIN(tst_QObject)
+ #include "tst_qobject.moc"
+diff --git a/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp b/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
+index 0ea422ecbc..1a3256534b 100644
+--- a/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
++++ b/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
+@@ -70,15 +70,15 @@ static inline QString testSuiteWarning()
+ 
+     QString result;
+     QTextStream str(&result);
+-    str << "\nCannot find the shared-mime-info test suite\nstarting from: "
++    str << "\nCannot find the shared-mime-info test suite\nin the parent of: "
+         << QDir::toNativeSeparators(QDir::currentPath()) << "\n"
+            "cd " << QDir::toNativeSeparators(QStringLiteral("tests/auto/corelib/mimetypes/qmimedatabase")) << "\n"
+-           "wget http://cgit.freedesktop.org/xdg/shared-mime-info/snapshot/Release-1-10.zip\n"
+-           "unzip Release-1-10.zip\n";
++           "wget https://gitlab.freedesktop.org/xdg/shared-mime-info/-/archive/2.1/shared-mime-info-2.1.zip\n"
++           "unzip shared-mime-info-2.1.zip\n";
+ #ifdef Q_OS_WIN
+-    str << "mkdir testfiles\nxcopy /s Release-1-10 s-m-i\n";
++    str << "mkdir testfiles\nxcopy /s shared-mime-info-2.1 s-m-i\n";
+ #else
+-    str << "ln -s Release-1-10 s-m-i\n";
++    str << "ln -s shared-mime-info-2.1 s-m-i\n";
+ #endif
+     return result;
+ }
+@@ -154,7 +154,7 @@ void tst_QMimeDatabase::initTestCase()
+     QVERIFY2(copyResourceFile(xmlFileName, xmlTargetFileName, &errorMessage), qPrintable(errorMessage));
+ #endif
+ 
+-    m_testSuite = QFINDTESTDATA("s-m-i/tests");
++    m_testSuite = QFINDTESTDATA("s-m-i/tests/mime-detection");
+     if (m_testSuite.isEmpty())
+         qWarning("%s", qPrintable(testSuiteWarning()));
+ 
+@@ -611,7 +611,7 @@ void tst_QMimeDatabase::allMimeTypes()
+     QVERIFY(!lst.isEmpty());
+ 
+     // Hardcoding this is the only way to check both providers find the same number of mimetypes.
+-    QCOMPARE(lst.count(), 779);
++    QCOMPARE(lst.count(), 811);
+ 
+     foreach (const QMimeType &mime, lst) {
+         const QString name = mime.name();
+@@ -631,10 +631,9 @@ void tst_QMimeDatabase::suffixes_data()
+ 
+     QTest::newRow("mimetype with a single pattern") << "application/pdf" << "*.pdf" << "pdf";
+     QTest::newRow("mimetype with multiple patterns") << "application/x-kpresenter" << "*.kpr;*.kpt" << "kpr";
+-    QTest::newRow("jpeg") << "image/jpeg" << "*.jpe;*.jpg;*.jpeg" << "jpeg";
+-    //if (KMimeType::sharedMimeInfoVersion() > KDE_MAKE_VERSION(0, 60, 0)) {
+-        QTest::newRow("mimetype with many patterns") << "application/vnd.wordperfect" << "*.wp;*.wp4;*.wp5;*.wp6;*.wpd;*.wpp" << "wp";
+-    //}
++    // The preferred suffix for image/jpeg is *.jpg, as per https://bugs.kde.org/show_bug.cgi?id=176737
++    QTest::newRow("jpeg") << "image/jpeg" << "*.jpe;*.jpg;*.jpeg" << "jpg";
++    QTest::newRow("mimetype with many patterns") << "application/vnd.wordperfect" << "*.wp;*.wp4;*.wp5;*.wp6;*.wpd;*.wpp" << "wp";
+     QTest::newRow("oasis text mimetype") << "application/vnd.oasis.opendocument.text" << "*.odt" << "odt";
+     QTest::newRow("oasis presentation mimetype") << "application/vnd.oasis.opendocument.presentation" << "*.odp" << "odp";
+     QTest::newRow("mimetype with multiple patterns") << "text/plain" << "*.asc;*.txt;*,v" << "txt";
+diff --git a/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp b/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
+index 3e58dd03cc..c8f82ef5d5 100644
+--- a/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
++++ b/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
+@@ -176,6 +176,8 @@ private Q_SLOTS:
+     void fromToVariantConversions_data();
+     void fromToVariantConversions();
+ 
++    void noLeakOnNameClash();
++
+ private:
+     QString testDataDir;
+ };
+@@ -3685,5 +3687,23 @@ void tst_QtJson::fromToVariantConversions()
+     }
+ }
+ 
++void tst_QtJson::noLeakOnNameClash()
++{
++    QJsonDocument doc = QJsonDocument::fromJson("{\"\":{\"\":0},\"\":0}");
++    QVERIFY(!doc.isNull());
++    const QJsonObject obj = doc.object();
++
++    // Removed the duplicate key.
++    QCOMPARE(obj.length(), 1);
++
++    // Retained the last of the duplicates.
++    const QJsonValue val = obj.begin().value();
++    QVERIFY(val.isDouble());
++    QCOMPARE(val.toDouble(), 0.0);
++
++    // It should not leak.
++    // In particular it should not forget to deref the container for the inner object.
++}
++
+ QTEST_MAIN(tst_QtJson)
+ #include "tst_qtjson.moc"
+diff --git a/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp b/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
+index a59b58d57f..241c3e84ac 100644
+--- a/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
++++ b/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
+@@ -63,6 +63,7 @@ private slots:
+     void isValidId_data();
+     void isValidId();
+     void malformed();
++    void serialize();
+     // Backend tests
+     void utcTest();
+     void icuTest();
+@@ -947,6 +948,33 @@ void tst_QTimeZone::malformed()
+         barf.offsetFromUtc(now);
+ }
+ 
++void tst_QTimeZone::serialize()
++{
++    int parts = 0;
++#ifndef QT_NO_DEBUG_STREAM
++    qDebug() << QTimeZone(); // to verify no crash
++    parts++;
++#endif
++#ifndef QT_NO_DATASTREAM
++    QByteArray blob;
++    {
++        QDataStream stream(&blob, QIODevice::WriteOnly);
++        stream << QTimeZone("Europe/Oslo") << QTimeZone(420) << QTimeZone() << qint64(-1);
++    }
++    QDataStream stream(&blob, QIODevice::ReadOnly);
++    QTimeZone invalid, offset, oslo;
++    qint64 minusone;
++    stream >> oslo >> offset >> invalid >> minusone;
++    QCOMPARE(oslo, QTimeZone("Europe/Oslo"));
++    QCOMPARE(offset, QTimeZone(420));
++    QVERIFY(!invalid.isValid());
++    QCOMPARE(minusone, qint64(-1));
++    parts++;
++#endif
++    if (!parts)
++        QSKIP("No serialization enabled");
++}
++
+ void tst_QTimeZone::utcTest()
+ {
+ #ifdef QT_BUILD_INTERNAL
+diff --git a/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp b/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
+index 05480c6dd2..70f4c75756 100644
+--- a/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
++++ b/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
+@@ -324,6 +324,13 @@ void tst_QDBusInterface::notValid()
+ 
+     QVERIFY(!interface.isValid());
+     QVERIFY(!QMetaObject::invokeMethod(&interface, "ListNames", Qt::DirectConnection));
++
++    // With a connection, but empty/null service and path specified
++    QDBusConnection con = QDBusConnection::sessionBus();
++    QVERIFY(con.isConnected());
++    QDBusInterface iface({}, {}, {}, con);
++    QVERIFY(!iface.isValid());
++    QVERIFY(!QMetaObject::invokeMethod(&interface, "ListNames", Qt::DirectConnection));
+ }
+ 
+ void tst_QDBusInterface::notValidDerived()
+diff --git a/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp b/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
+index 874468c954..04ceb4ab65 100644
+--- a/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
++++ b/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
+@@ -507,6 +507,10 @@ void tst_QKeySequence::toStringFromKeycode_data()
+     QTest::newRow("Ctrl+Alt+Num+Del") << QKeySequence(Qt::ControlModifier | Qt::AltModifier | Qt::KeypadModifier | Qt::Key_Delete) << "Ctrl+Alt+Num+Del";
+     QTest::newRow("Ctrl+Ins") << QKeySequence(Qt::ControlModifier | Qt::Key_Insert) << "Ctrl+Ins";
+     QTest::newRow("Ctrl+Num+Ins(1)") << QKeySequence(Qt::Key_Insert | Qt::KeypadModifier | Qt::ControlModifier) << "Ctrl+Num+Ins";
++    QTest::newRow("Ctrl") << QKeySequence(Qt::Key_Control) << "Control";
++    QTest::newRow("Alt") << QKeySequence(Qt::Key_Alt) << "Alt";
++    QTest::newRow("Shift") << QKeySequence(Qt::Key_Shift) << "Shift";
++    QTest::newRow("Meta") << QKeySequence(Qt::Key_Meta) << "Meta";
+ }
+ 
+ void tst_QKeySequence::toStringFromKeycode()
+diff --git a/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp b/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+index 15e0ecadaa..b4eca74283 100644
+--- a/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
++++ b/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+@@ -81,6 +81,8 @@ private slots:
+     void registerOpenTypePreferredNamesSystem();
+     void registerOpenTypePreferredNamesApplication();
+ 
++    void stretchRespected();
++
+ private:
+     QString m_ledFont;
+     QString m_testFont;
+@@ -355,6 +357,28 @@ static QString testString()
+     return QStringLiteral("foo bar");
+ }
+ 
++void tst_QFontDatabase::stretchRespected()
++{
++    int italicId = QFontDatabase::addApplicationFont(m_testFontItalic);
++    QVERIFY(italicId != -1);
++
++    QVERIFY(!QFontDatabase::applicationFontFamilies(italicId).isEmpty());
++
++    QString italicFontName = QFontDatabase::applicationFontFamilies(italicId).first();
++
++    QFont italicFont = QFontDatabase().font(italicFontName,
++                                            QString::fromLatin1("Italic"), 14);
++    QVERIFY(italicFont.italic());
++
++    QFont italicStretchedFont = italicFont;
++    italicStretchedFont.setStretch( 400 );
++
++    QVERIFY(QFontMetricsF(italicFont).horizontalAdvance(QStringLiteral("foobar")) <
++            QFontMetricsF(italicStretchedFont).horizontalAdvance(QStringLiteral("foobar")));
++
++    QFontDatabase::removeApplicationFont(italicId);
++}
++
+ void tst_QFontDatabase::condensedFontWidthNoFontMerging()
+ {
+     int regularFontId = QFontDatabase::addApplicationFont(m_testFont);
+diff --git a/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+index 3d4a094c43..b423e11a99 100644
+--- a/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
++++ b/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+@@ -281,6 +281,7 @@ private Q_SLOTS:
+     void ioGetFromFileSpecial();
+     void ioGetFromFile_data();
+     void ioGetFromFile();
++    void ioGetFromFileUrl();
+     void ioGetFromFtp_data();
+     void ioGetFromFtp();
+     void ioGetFromFtpWithReuse();
+@@ -3300,6 +3301,18 @@ void tst_QNetworkReply::ioGetFromFile()
+     QCOMPARE(reader.data, data);
+ }
+ 
++void tst_QNetworkReply::ioGetFromFileUrl()
++{
++    // This immediately fails on non-windows platforms:
++    QNetworkRequest request(QUrl("file://unc-server/some/path"));
++    QNetworkReplyPtr reply(manager.get(request));
++    QSignalSpy finishedSpy(reply.get(), &QNetworkReply::finished);
++    // QTBUG-105618: This would, on non-Windows platforms, never happen because the signal
++    // was emitted before the constructor finished, leaving no chance at all to connect to the
++    // signal
++    QVERIFY(finishedSpy.wait());
++}
++
+ void tst_QNetworkReply::ioGetFromFtp_data()
+ {
+     QTest::addColumn<QString>("fileName");
+diff --git a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
+index 069fa6b341..4cc4d9a5ea 100644
+--- a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
++++ b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
+@@ -1,75 +1,34 @@
+-Certificate:
+-    Data:
+-        Version: 3 (0x2)
+-        Serial Number: 0 (0x0)
+-        Signature Algorithm: sha1WithRSAEncryption
+-        Issuer: C=NO, ST=Oslo, L=Nydalen, O=Nokia Corporation and/or its subsidiary(-ies), OU=Development, CN=fluke.troll.no/emailAddress=ahanssen@trolltech.com
+-        Validity
+-            Not Before: Dec  4 01:10:32 2007 GMT
+-            Not After : Apr 21 01:10:32 2035 GMT
+-        Subject: C=NO, ST=Oslo, O=Nokia Corporation and/or its subsidiary(-ies), OU=Development, CN=fluke.troll.no
+-        Subject Public Key Info:
+-            Public Key Algorithm: rsaEncryption
+-            RSA Public Key: (1024 bit)
+-                Modulus (1024 bit):
+-                    00:a7:c8:a0:4a:c4:19:05:1b:66:ba:32:e2:d2:f1:
+-                    1c:6f:17:82:e4:39:2e:01:51:90:db:04:34:32:11:
+-                    21:c2:0d:6f:59:d8:53:90:54:3f:83:8f:a9:d3:b3:
+-                    d5:ee:1a:9b:80:ae:c3:25:c9:5e:a5:af:4b:60:05:
+-                    aa:a0:d1:91:01:1f:ca:04:83:e3:58:1c:99:32:45:
+-                    84:70:72:58:03:98:4a:63:8b:41:f5:08:49:d2:91:
+-                    02:60:6b:e4:64:fe:dd:a0:aa:74:08:e9:34:4c:91:
+-                    5f:12:3d:37:4d:54:2c:ad:7f:5b:98:60:36:02:8c:
+-                    3b:f6:45:f3:27:6a:9b:94:9d
+-                Exponent: 65537 (0x10001)
+-        X509v3 extensions:
+-            X509v3 Basic Constraints: 
+-                CA:FALSE
+-            Netscape Comment: 
+-                OpenSSL Generated Certificate
+-            X509v3 Subject Key Identifier: 
+-                21:85:04:3D:23:01:66:E5:F7:9F:1A:84:24:8A:AF:0A:79:F4:E5:AC
+-            X509v3 Authority Key Identifier: 
+-                DirName:/C=NO/ST=Oslo/L=Nydalen/O=Nokia Corporation and/or its subsidiary(-ies)/OU=Development/CN=fluke.troll.no/emailAddress=ahanssen@trolltech.com
+-                serial:8E:A8:B4:E8:91:B7:54:2E
+-
+-    Signature Algorithm: sha1WithRSAEncryption
+-        6d:57:5f:d1:05:43:f0:62:05:ec:2a:71:a5:dc:19:08:f2:c4:
+-        a6:bd:bb:25:d9:ca:89:01:0e:e4:cf:1f:c1:8c:c8:24:18:35:
+-        53:59:7b:c0:43:b4:32:e6:98:b2:a6:ef:15:05:0b:48:5f:e1:
+-        a0:0c:97:a9:a1:77:d8:35:18:30:bc:a9:8f:d3:b7:54:c7:f1:
+-        a9:9e:5d:e6:19:bf:f6:3c:5b:2b:d8:e4:3e:62:18:88:8b:d3:
+-        24:e1:40:9b:0c:e6:29:16:62:ab:ea:05:24:70:36:aa:55:93:
+-        ef:02:81:1b:23:10:a2:04:eb:56:95:75:fc:f8:94:b1:5d:42:
+-        c5:3f:36:44:85:5d:3a:2e:90:46:8a:a2:b9:6f:87:ae:0c:15:
+-        40:19:31:90:fc:3b:25:bb:ae:f1:66:13:0d:85:90:d9:49:34:
+-        8f:f2:5d:f9:7a:db:4d:5d:27:f6:76:9d:35:8c:06:a6:4c:a3:
+-        b1:b2:b6:6f:1d:d7:a3:00:fd:72:eb:9e:ea:44:a1:af:21:34:
+-        7d:c7:42:e2:49:91:19:8b:c0:ad:ba:82:80:a8:71:70:f4:35:
+-        31:91:63:84:20:95:e9:60:af:64:8b:cc:ff:3d:8a:76:74:3d:
+-        c8:55:6d:e4:8e:c3:2b:1c:e8:42:18:ae:9f:e6:6b:9c:34:06:
+-        ec:6a:f2:c3
+ -----BEGIN CERTIFICATE-----
+-MIIEEzCCAvugAwIBAgIBADANBgkqhkiG9w0BAQUFADCBnDELMAkGA1UEBhMCTk8x
+-DTALBgNVBAgTBE9zbG8xEDAOBgNVBAcTB055ZGFsZW4xFjAUBgNVBAoTDVRyb2xs
+-dGVjaCBBU0ExFDASBgNVBAsTC0RldmVsb3BtZW50MRcwFQYDVQQDEw5mbHVrZS50
+-cm9sbC5ubzElMCMGCSqGSIb3DQEJARYWYWhhbnNzZW5AdHJvbGx0ZWNoLmNvbTAe
+-Fw0wNzEyMDQwMTEwMzJaFw0zNTA0MjEwMTEwMzJaMGMxCzAJBgNVBAYTAk5PMQ0w
+-CwYDVQQIEwRPc2xvMRYwFAYDVQQKEw1Ucm9sbHRlY2ggQVNBMRQwEgYDVQQLEwtE
+-ZXZlbG9wbWVudDEXMBUGA1UEAxMOZmx1a2UudHJvbGwubm8wgZ8wDQYJKoZIhvcN
+-AQEBBQADgY0AMIGJAoGBAKfIoErEGQUbZroy4tLxHG8XguQ5LgFRkNsENDIRIcIN
+-b1nYU5BUP4OPqdOz1e4am4CuwyXJXqWvS2AFqqDRkQEfygSD41gcmTJFhHByWAOY
+-SmOLQfUISdKRAmBr5GT+3aCqdAjpNEyRXxI9N01ULK1/W5hgNgKMO/ZF8ydqm5Sd
+-AgMBAAGjggEaMIIBFjAJBgNVHRMEAjAAMCwGCWCGSAGG+EIBDQQfFh1PcGVuU1NM
+-IEdlbmVyYXRlZCBDZXJ0aWZpY2F0ZTAdBgNVHQ4EFgQUIYUEPSMBZuX3nxqEJIqv
+-Cnn05awwgbsGA1UdIwSBszCBsKGBoqSBnzCBnDELMAkGA1UEBhMCTk8xDTALBgNV
+-BAgTBE9zbG8xEDAOBgNVBAcTB055ZGFsZW4xFjAUBgNVBAoTDVRyb2xsdGVjaCBB
+-U0ExFDASBgNVBAsTC0RldmVsb3BtZW50MRcwFQYDVQQDEw5mbHVrZS50cm9sbC5u
+-bzElMCMGCSqGSIb3DQEJARYWYWhhbnNzZW5AdHJvbGx0ZWNoLmNvbYIJAI6otOiR
+-t1QuMA0GCSqGSIb3DQEBBQUAA4IBAQBtV1/RBUPwYgXsKnGl3BkI8sSmvbsl2cqJ
+-AQ7kzx/BjMgkGDVTWXvAQ7Qy5piypu8VBQtIX+GgDJepoXfYNRgwvKmP07dUx/Gp
+-nl3mGb/2PFsr2OQ+YhiIi9Mk4UCbDOYpFmKr6gUkcDaqVZPvAoEbIxCiBOtWlXX8
+-+JSxXULFPzZEhV06LpBGiqK5b4euDBVAGTGQ/Dslu67xZhMNhZDZSTSP8l35ettN
+-XSf2dp01jAamTKOxsrZvHdejAP1y657qRKGvITR9x0LiSZEZi8CtuoKAqHFw9DUx
+-kWOEIJXpYK9ki8z/PYp2dD3IVW3kjsMrHOhCGK6f5mucNAbsavLD
++MIIF6zCCA9OgAwIBAgIUfo9amJtJGWqWE6f+SkAO85zkGr4wDQYJKoZIhvcNAQEL
++BQAwgYMxCzAJBgNVBAYTAk5PMQ0wCwYDVQQIDARPc2xvMQ0wCwYDVQQHDARPc2xv
++MRcwFQYDVQQKDA5UaGUgUXQgQ29tcGFueTEMMAoGA1UECwwDUiZEMRIwEAYDVQQD
++DAlIMiBUZXN0ZXIxGzAZBgkqhkiG9w0BCQEWDG1pbmltaUBxdC5pbzAgFw0yMDEw
++MjYxMjAxMzFaGA8yMTIwMTAwMjEyMDEzMVowgYMxCzAJBgNVBAYTAk5PMQ0wCwYD
++VQQIDARPc2xvMQ0wCwYDVQQHDARPc2xvMRcwFQYDVQQKDA5UaGUgUXQgQ29tcGFu
++eTEMMAoGA1UECwwDUiZEMRIwEAYDVQQDDAlIMiBUZXN0ZXIxGzAZBgkqhkiG9w0B
++CQEWDG1pbmltaUBxdC5pbzCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIB
++AOiUp5+E4blouKH7q+rVNR8NoYX2XkBW+q+rpy1zu5ssRSzbqxAjDx9dkht7Qlnf
++VlDT00JvpOWdeuPon5915edQRsY4Unl6mKH29ra3OtUa1/yCJXsGVJTKCj7k4Bxb
++5mZzb/fTlZntMLdTIBMfUbw62FKir1WjKIcJ9fCoG8JaGeKVO4Rh5p0ezd4UUUId
++r1BXl5Nqdqy2vTMsEDnjOsD3egkv8I2SKN4O6n/C3wWYpMOWYZkGoZiKz7rJs/i/
++ez7bsV7JlwdzTlhpJzkcOSVFBP6JlEOxTNNxZ1wtKy7PtZGmsSSATq2e6+bw38Ae
++Op0XnzzqcGjtDDofBmT7OFzZWjS9VZS6+DOOe2QHWle1nCHcHyH4ku6IRlsr9xkR
++NAIlOfnvHHxqJUenoeaZ4oQDjCBKS1KXygJO/tL7BLTQVn/xK1EmPvKNnjzWk4tR
++PnibUhhs5635qpOU/YPqFBh1JjVruZbsWcDAhRcew0uxONXOa9E+4lttQ9ySYa1A
++LvWqJuAX7gu2BsBMLyqfm811YnA7CIFMyO+HlqmkLFfv5L/xIRAXR7l26YGO0VwX
++CGjMfz4NVPMMke4nB7qa9NkpXQBQKMms3Qzd5JW0Hy9Ruj5O8GPcFZmV0twjd1uJ
++PD/cAjkWLaXjdNsJ16QWc2nghQRS6HYqKRX6j+CXOxupAgMBAAGjUzBRMB0GA1Ud
++DgQWBBRSCOU58j9NJZkMamt623qyCrhN3TAfBgNVHSMEGDAWgBRSCOU58j9NJZkM
++amt623qyCrhN3TAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4ICAQCq
++q4jxsWeNDv5Nq14hJtF9HB+ZL64zcZtRjJP1YgNs0QppKICmjPOL2nIMGmI/jKrs
++0eGAL/9XXNVHPxm1OPOncvimMMmU6emZfpMdEtTfKP43+Pg9HgKRjLoQp406vGeQ
++8ki/mbBhrItVPgEm3tu2AFA02XTYi+YxCI9kRZLGkM3FbgtOuTLPl0Z9y+kiPc9F
++uCSC03anBEqv+vDSI8+wODymQ/IJ3Jyz1lxIRDfp4qAekmy0jU2c91VOHHEmOmqq
++kqygGFRdwbe99m9yP63r6q0b5K3X2UnJ6bns0hmTwThYwpVPXLU8jdaTddbMukN2
++/Ef96Tsw8nWOEOPMySHOTIPgwyZRp26b0kA9EmhLwOP401SxXVQCmSRmtwNagmtg
++jJKmZoYBN+//D45ibK8z6Q0oOm9P+Whf/uUXehcRxBxyV3xz7k0wKGQbHj/ddwcy
++IUoIN4lrAlib+lK170kTKN352PDmrpo2gmIzPEsfurKAIMSelDl6H+kih16BtZ8y
++Nz6fh9Soqrg3OSAware8pxV7k51crBMoPLN78KoRV8MFCK4K7Fddq4rRISq6hiXq
++r1nsjoEPuKM9huprmZVZe9t5YcDa2I+wb3IiE3uwpZbAdaLDyQ5n6F/qpsiIkZXn
++gtcF7oqpG5oYrwCcZ53y/ezUgUg7PlSz2XwAGvQtgg==
+ -----END CERTIFICATE-----
+diff --git a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
+index 9d1664d609..337ce541a6 100644
+--- a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
++++ b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
+@@ -1,15 +1,52 @@
+------BEGIN RSA PRIVATE KEY-----
+-MIICXAIBAAKBgQCnyKBKxBkFG2a6MuLS8RxvF4LkOS4BUZDbBDQyESHCDW9Z2FOQ
+-VD+Dj6nTs9XuGpuArsMlyV6lr0tgBaqg0ZEBH8oEg+NYHJkyRYRwclgDmEpji0H1
+-CEnSkQJga+Rk/t2gqnQI6TRMkV8SPTdNVCytf1uYYDYCjDv2RfMnapuUnQIDAQAB
+-AoGANFzLkanTeSGNFM0uttBipFT9F4a00dqHz6JnO7zXAT26I5r8sU1pqQBb6uLz
+-/+Qz5Zwk8RUAQcsMRgJetuPQUb0JZjF6Duv24hNazqXBCu7AZzUenjafwmKC/8ri
+-KpX3fTwqzfzi//FKGgbXQ80yykSSliDL3kn/drATxsLCgQECQQDXhEFWLJ0vVZ1s
+-1Ekf+3NITE+DR16X+LQ4W6vyEHAjTbaNWtcTKdAWLA2l6N4WAAPYSi6awm+zMxx4
+-VomVTsjdAkEAx0z+e7natLeFcrrq8pbU+wa6SAP1VfhQWKitxL1e7u/QO90NCpxE
+-oQYKzMkmmpOOFjQwEMAy1dvFMbm4LHlewQJAC/ksDBaUcQHHqjktCtrUb8rVjAyW
+-A8lscckeB2fEYyG5J6dJVaY4ClNOOs5yMDS2Afk1F6H/xKvtQ/5CzInA/QJATDub
+-K+BPU8jO9q+gpuIi3VIZdupssVGmCgObVCHLakG4uO04y9IyPhV9lA9tALtoIf4c
+-VIvv5fWGXBrZ48kZAQJBAJmVCdzQxd9LZI5vxijUCj5EI4e+x5DRqVUvyP8KCZrC
+-AiNyoDP85T+hBZaSXK3aYGpVwelyj3bvo1GrTNwNWLw=
+------END RSA PRIVATE KEY-----
++-----BEGIN PRIVATE KEY-----
++MIIJQgIBADANBgkqhkiG9w0BAQEFAASCCSwwggkoAgEAAoICAQDolKefhOG5aLih
+++6vq1TUfDaGF9l5AVvqvq6ctc7ubLEUs26sQIw8fXZIbe0JZ31ZQ09NCb6TlnXrj
++6J+fdeXnUEbGOFJ5epih9va2tzrVGtf8giV7BlSUygo+5OAcW+Zmc2/305WZ7TC3
++UyATH1G8OthSoq9VoyiHCfXwqBvCWhnilTuEYeadHs3eFFFCHa9QV5eTanastr0z
++LBA54zrA93oJL/CNkijeDup/wt8FmKTDlmGZBqGYis+6ybP4v3s+27FeyZcHc05Y
++aSc5HDklRQT+iZRDsUzTcWdcLSsuz7WRprEkgE6tnuvm8N/AHjqdF5886nBo7Qw6
++HwZk+zhc2Vo0vVWUuvgzjntkB1pXtZwh3B8h+JLuiEZbK/cZETQCJTn57xx8aiVH
++p6HmmeKEA4wgSktSl8oCTv7S+wS00FZ/8StRJj7yjZ481pOLUT54m1IYbOet+aqT
++lP2D6hQYdSY1a7mW7FnAwIUXHsNLsTjVzmvRPuJbbUPckmGtQC71qibgF+4LtgbA
++TC8qn5vNdWJwOwiBTMjvh5appCxX7+S/8SEQF0e5dumBjtFcFwhozH8+DVTzDJHu
++Jwe6mvTZKV0AUCjJrN0M3eSVtB8vUbo+TvBj3BWZldLcI3dbiTw/3AI5Fi2l43Tb
++CdekFnNp4IUEUuh2KikV+o/glzsbqQIDAQABAoICAFw1q6tr5I48vY7DF+rXsuLn
++5ZUWE1IQ6fzB4lr72nJv/9EEGnMgYzt9PpMUsD6vdCpBgS2C0+6RHArFzJtNA+RM
++iHLIG7K7702veyr/xBx/MwiSlMeMv/XpkFxVI6E6skMGG2s3AMXxKvJTy5CpRx+I
++eQFyLG+Ya1X2lgJes/q+/CpAHkOjCOpcLySQC5NZ74q734V7nSdmn+Zs3tYEh+O/
++eiuwTP/j5b38Te5vVTqDxTciJPmljmXLCwa0N100lWlbcpvw8qbqiTI2Jm3XCbUE
++AzHjW9vmrF3cRS1fXxKFGShw3SRqlkbxjfeWoi8qDPUBS4m8LOr8qG9Wo5Nfon0z
++zLP4bci3zHDvVcaaZrrsUBs/yZbg+Dgka1DmX7ekmeccr2yTdKDFgPupYUyxVbTl
++a9ZLJysjFD7rgBv1ZclHonLp6Vbm+ZoTqvteo4ikAy6L9RtBWJ23XEK34PkP/+c5
++2vWZaOrnjSeBHbFce8cdJSxqWpP+eSCI5I9XbDrYFIsQ/gqKgtzDKy2ihJ2Y8STL
++yO4hyFPFjxc+Gg4/P2PpmT5CY2ty44M0BWs+JGW96CJPrrplf2lmQUQJj5LZY66X
++Z/4C9L7ZYtKZ+bs5SvU46yWugAvQZX22Xm9xLXWyVXRdx3bj+3M3fDnF9di/zdbh
++CgLx7oWPNrXc7FCajnn9AoIBAQD5FMYwRpw9NWT9WDxQwx+cSI4Icbd88ByTW63S
++LzeRwZA0J9/SfwO+aBRupzc9GkGXCiZcGMw3AGsCtig8yFlw8E5KnzN7KlftDMnM
++9NUxxzlR8VwKyLnZfG7sDTl057ZlUujnqhmt/F8F7dIy7FVO1dE/8nngA+FYTCOG
++UZdGjwyBDlDM0JJdUWGY3xslutcpCDN5mzSTKjy9drMvImAshRawxRF6WBpn7vr2
++nC6vciqfx1Mzx1vyk0Jm0ilaydDdLMADjt/iL4Nkr0BEs4k+UzQiKDwp8gu7abQ1
++eBfxd9Iar4htQa2I1Ewl6P01G/q+ZYwgHhJ9RVn4AxQXefILAoIBAQDvCouORdQX
++C8wsyp7MwXlF/3NQeNN5/+B2mhbxrBOf7PmMCXLnkRWcjwJtzypWFqJ0sqai/2+0
++bqbMcjX5maT8stT2shl3zXe/Ejt2e3TBYpc1tyuses8Kb5BMU8hu6tTd3G2CMXpD
++dT6DVemJZCTtwj9aBNIxSizvlgMolJnCpzhPnlfHSI6E+g3m/LTTo3HwbjMSw/Uq
++irgjOpI2wSBB6LZPSgjvfcYPRyWUk16L4A5uSX0cADnovDFLa5/h0wJvN/OoCSQg
++rLCXG5E18EyL5Wc58BCY1ZvxmjG3lQtgPxYu2Jwc36R/y/JKlxW5suER5ZNpbbD4
++uOyTt2VxMQ2bAoIBAQC5+MzRFqdo/AjfL5Y5JrbfVTzXCTDa09xCGd16ZU60QTWN
+++4ed/r+o1sUKqUcRFB2MzEM/2DQBjQpZB/CbEWvWa1XJWXxypXbowveZU+QqOnmN
++uQvj8WLyA3o+PNF9e9QvauwCrHpn8VpxbtPWuaYoKnUFreFZZQxHhPGxRBIS2JOZ
++eDrT8ZaWnkCkh1AZp5smQ71LOprSlmKrg4jd1GjCVMxQR5N5KXbtyv0OTCZ/UFqK
++2aRBsMPyJgkaBChkZPLRcKwc+/wlQRx1fHQb14DNTApMxoXFO7eOwqmOkpAt9iyl
++SBIwoS0UUI5ab88+bBmXNvKcuFdNuQ4nowTJUn9pAoIBADMNkILBXSvS5DeIyuO2
++Sp1tkoZUV+5NfPY3sMDK3KIibaW/+t+EOBZo4L7tKQCb8vRzl21mmsfxfgRaPDbj
++3r3tv9g0b4YLxxBy52pFscj/soXRai17SS7UZwA2QK+XzgDYbDcLNC6mIsTQG4Gx
++dsWk3/zs3KuUSQaehmwrWK+fIUK38c1pLK8v7LoxrLkqxlHwZ04RthHw8KTthH7X
++Pnl1J0LF8CSeOyfWLSuPUfkT0GEzptnNHpEbaHfQM6R6eaGhVJPF6AZme4y6YYgg
++m2ihhSt1n0XVEWpHYWjxFy3mK2mz75unFC4LM+NEY2p2zuUQoCw7NjnY3QYrfCnx
++rRMCggEAXeXsMSLFjjyuoL7iKbAxo52HD/P0fBoy58LyRcwfNVr0lvYan4pYEx+o
++KijIh9K16PqXZXKMA9v003B+ulmF8bJ7SddCZ5NGvnFhUTDe4DdTKgp2RuwQ3Bsc
++3skPIDbhVETyOLCtys34USHrq8U/0DlGY3eLRfxw9GnbKxSBGa/KEu/qQLPNUo50
++7xHZDg7GKeC3kqNJeqKM9rkp0VzIGkEnaD9127LeNDmERDfftxJzFoC/THvUBLfU
++6Sus2ZYwRE8VFvKC30Q45t/c54X3IuhYvAuiCuTmyfE4ruyzyOwKzhUkeeLq1APX
++g0veFbyfzlJ0q8qzD/iffqqIa2ZSmQ==
++-----END PRIVATE KEY-----
+diff --git a/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp b/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
+index 7ba3715e13..752aa122f6 100644
+--- a/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
++++ b/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
+@@ -179,6 +179,7 @@ void tst_QAccessibilityLinux::initTestCase()
+     QVERIFY(!address.isEmpty());
+ 
+     m_window = new AccessibleTestWindow();
++    m_window->setObjectName("mainWindow"_L1);
+     m_window->show();
+ 
+     QVERIFY(QTest::qWaitForWindowExposed(m_window));
+@@ -236,8 +237,11 @@ bool hasState(QDBusInterface *interface, AtspiStateType state)
+ void tst_QAccessibilityLinux::testLabel()
+ {
+     QLabel *l = new QLabel(m_window);
++    l->setObjectName("theObjectName"_L1);
+     l->setText("Hello A11y");
+     m_window->addWidget(l);
++    auto a11yEmpty = new QLabel(m_window);
++    m_window->addWidget(l);
+ 
+     // Application
+     QCOMPARE(getParent(mainWindow), QLatin1String(ATSPI_DBUS_PATH_ROOT));
+@@ -249,6 +253,8 @@ void tst_QAccessibilityLinux::testLabel()
+     QCOMPARE(getChildren(labelInterface).count(), 0);
+     QCOMPARE(labelInterface->call(QDBus::Block, "GetRoleName").arguments().first().toString(), QLatin1String("label"));
+     QCOMPARE(labelInterface->call(QDBus::Block, "GetRole").arguments().first().toUInt(), 29u);
++    QCOMPARE(labelInterface->call(QDBus::Block, "GetAccessibleId").arguments().first().toString(),
++             QLatin1String("mainWindow.theObjectName"));
+     QCOMPARE(getParent(labelInterface), mainWindow->path());
+     QVERIFY(!hasState(labelInterface, ATSPI_STATE_EDITABLE));
+     QVERIFY(hasState(labelInterface, ATSPI_STATE_READ_ONLY));
+@@ -256,7 +262,12 @@ void tst_QAccessibilityLinux::testLabel()
+     l->setText("New text");
+     QCOMPARE(labelInterface->property("Name").toString(), l->text());
+ 
++    auto *a11yEmptyInterface = getInterface(children.at(1), "org.a11y.atspi.Accessible");
++    QCOMPARE(a11yEmptyInterface->call(QDBus::Block, "GetAccessibleId").arguments().first().toString(),
++             QLatin1String("mainWindow.QLabel"));
++
+     m_window->clearChildren();
++    delete a11yEmptyInterface;
+     delete labelInterface;
+ }
+ 
+diff --git a/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+index 76df61c892..6d6d65b791 100644
+--- a/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
++++ b/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2022 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the test suite of the Qt Toolkit.
+@@ -68,6 +68,8 @@ private slots:
+     void query_exec();
+     void execErrorRecovery_data() { generic_data(); }
+     void execErrorRecovery();
++    void prematureExec_data() { generic_data(); }
++    void prematureExec();
+     void first_data() { generic_data(); }
+     void first();
+     void next_data() { generic_data(); }
+@@ -2770,6 +2772,35 @@ void tst_QSqlQuery::execErrorRecovery()
+     QVERIFY_SQL( q, exec() );
+ }
+ 
++void tst_QSqlQuery::prematureExec()
++{
++    QFETCH(QString, dbName);
++    // We only want the engine name, for addDatabase():
++    int cut = dbName.indexOf(QChar('@'));
++    if (cut < 0)
++        QSKIP("Failed to parse database type out of name");
++    dbName.truncate(cut);
++    cut = dbName.indexOf(QChar('_'));
++    if (cut >= 0)
++        dbName = dbName.mid(cut + 1);
++
++    auto db = QSqlDatabase::addDatabase(dbName);
++    QSqlQuery q(db);
++
++    QTest::ignoreMessage(QtWarningMsg,
++                         "QSqlDatabasePrivate::removeDatabase: connection "
++                         "'qt_sql_default_connection' is still in use, all "
++                         "queries will cease to work.");
++    QTest::ignoreMessage(QtWarningMsg,
++                         "QSqlDatabasePrivate::addDatabase: duplicate connection name "
++                         "'qt_sql_default_connection', old connection removed.");
++    auto otherDb = QSqlDatabase::addDatabase(dbName);
++
++    QTest::ignoreMessage(QtWarningMsg, "QSqlQuery::exec: called before driver has been set up");
++    // QTBUG-100037: shouldn't crash !
++    QVERIFY(!q.exec("select stuff from TheVoid"));
++}
++
+ void tst_QSqlQuery::lastInsertId()
+ {
+     QFETCH( QString, dbName );
+diff --git a/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp b/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
+index 4aa3f8d60b..d2050a61aa 100644
+--- a/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
++++ b/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
+@@ -115,6 +115,10 @@ void tst_QAbstractItemModelTester::standardItemModelZeroColumns()
+     // QTBUG-92886
+     model.insertRows(0, 5);
+     model.removeRows(1, 2);
++
++    const QModelIndex parentIndex = model.index(0, 0);
++    model.insertRows(0, 5, parentIndex);
++    model.removeRows(1, 2, parentIndex);
+ }
+ 
+ void tst_QAbstractItemModelTester::testInsertThroughProxy()
+diff --git a/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json b/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
+index 12a4a22a19..ce518e78fb 100644
+--- a/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
++++ b/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
+@@ -668,50 +668,6 @@
+         "inputFile": "task192552.h",
+         "outputRevision": 67
+     },
+-    {
+-        "classes": [
+-            {
+-                "className": "InlineSlotsWithThrowDeclaration",
+-                "object": true,
+-                "qualifiedClassName": "InlineSlotsWithThrowDeclaration",
+-                "slots": [
+-                    {
+-                        "access": "public",
+-                        "name": "a",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "b",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "c",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "d",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "e",
+-                        "returnType": "void"
+-                    }
+-                ],
+-                "superClasses": [
+-                    {
+-                        "access": "public",
+-                        "name": "QObject"
+-                    }
+-                ]
+-            }
+-        ],
+-        "inputFile": "task189996.h",
+-        "outputRevision": 67
+-    },
+     {
+         "classes": [
+             {
+diff --git a/qtbase/tests/auto/tools/moc/moc.pro b/qtbase/tests/auto/tools/moc/moc.pro
+index c324b3a8cd..4aceb78dc0 100644
+--- a/qtbase/tests/auto/tools/moc/moc.pro
++++ b/qtbase/tests/auto/tools/moc/moc.pro
+@@ -15,7 +15,7 @@ cross_compile: DEFINES += MOC_CROSS_COMPILED
+ HEADERS += using-namespaces.h no-keywords.h task87883.h c-comments.h backslash-newlines.h oldstyle-casts.h \
+            slots-with-void-template.h qinvokable.h namespaced-flags.h trigraphs.h \
+            escapes-in-string-literals.h cstyle-enums.h qprivateslots.h gadgetwithnoenums.h \
+-           dir-in-include-path.h single_function_keyword.h task192552.h task189996.h \
++           dir-in-include-path.h single_function_keyword.h task192552.h \
+            task234909.h task240368.h pure-virtual-signals.h cxx11-enums.h \
+            cxx11-final-classes.h \
+            cxx11-explicit-override-control.h \
+diff --git a/qtbase/tests/auto/tools/moc/task189996.h b/qtbase/tests/auto/tools/moc/task189996.h
+deleted file mode 100644
+index f94a051b3a..0000000000
+--- a/qtbase/tests/auto/tools/moc/task189996.h
++++ /dev/null
+@@ -1,47 +0,0 @@
+-/****************************************************************************
+-**
+-** Copyright (C) 2016 The Qt Company Ltd.
+-** Contact: https://www.qt.io/licensing/
+-**
+-** This file is part of the test suite of the Qt Toolkit.
+-**
+-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+-** 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 General Public License Usage
+-** Alternatively, this file may be used under the terms of the GNU
+-** General Public License version 3 as published by the Free Software
+-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+-** 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-3.0.html.
+-**
+-** $QT_END_LICENSE$
+-**
+-****************************************************************************/
+-// inline functions can have throw declarations
+-
+-#ifndef TASK189996_H
+-#define TASK189996_H
+-
+-#include <QObject>
+-
+-class InlineSlotsWithThrowDeclaration : public QObject
+-{
+-    Q_OBJECT
+-
+-public slots:
+-    void a() throw() { }
+-    void b() const throw() { }
+-    void c() throw();
+-    void d() throw(int) { }
+-    void e() const throw(int,double) { }
+-};
+-
+-#endif
+diff --git a/qtbase/tests/auto/tools/moc/tst_moc.cpp b/qtbase/tests/auto/tools/moc/tst_moc.cpp
+index c716aead21..15dd9e41e5 100644
+--- a/qtbase/tests/auto/tools/moc/tst_moc.cpp
++++ b/qtbase/tests/auto/tools/moc/tst_moc.cpp
+@@ -631,7 +631,6 @@ public:
+ private slots:
+     void initTestCase();
+ 
+-    void slotWithException() throw(MyStruct);
+     void dontStripNamespaces();
+     void oldStyleCasts();
+     void warnOnExtraSignalSlotQualifiaction();
+@@ -673,7 +672,6 @@ private slots:
+     void templateGtGt();
+     void qprivateslots();
+     void qprivateproperties();
+-    void inlineSlotsWithThrowDeclaration();
+     void warnOnPropertyWithoutREAD();
+     void constructors();
+     void typenameWithUnsigned();
+@@ -784,12 +782,6 @@ void tst_Moc::initTestCase()
+ #endif
+ }
+ 
+-void tst_Moc::slotWithException() throw(MyStruct)
+-{
+-    // be happy
+-    QVERIFY(true);
+-}
+-
+ void tst_Moc::dontStripNamespaces()
+ {
+     Sender sender;
+@@ -824,7 +816,7 @@ void tst_Moc::oldStyleCasts()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-Wold-style-cast" << "-I" << "."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -894,7 +886,7 @@ void tst_Moc::inputFileNameWithDotsButNoExtension()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-I" << ".."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -1174,7 +1166,7 @@ void tst_Moc::ignoreOptionClashes()
+     QStringList gccArgs;
+     gccArgs << "-c" << "-x" << "c++" << "-I" << ".."
+          << "-I" << qtIncludePath << "-I" << includeDir << "-o" << "/dev/null"
+-         << "-fPIC" << "-std=c++11" <<  "-";
++         << "-fPIC" << "-std=c++1z" <<  "-";
+     proc.start("gcc", gccArgs);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -1593,21 +1585,6 @@ void tst_Moc::qprivateproperties()
+ 
+ }
+ 
+-#include "task189996.h"
+-
+-void InlineSlotsWithThrowDeclaration::c() throw() {}
+-
+-void tst_Moc::inlineSlotsWithThrowDeclaration()
+-{
+-    InlineSlotsWithThrowDeclaration tst;
+-    const QMetaObject *mobj = tst.metaObject();
+-    QVERIFY(mobj->indexOfSlot("a()") != -1);
+-    QVERIFY(mobj->indexOfSlot("b()") != -1);
+-    QVERIFY(mobj->indexOfSlot("c()") != -1);
+-    QVERIFY(mobj->indexOfSlot("d()") != -1);
+-    QVERIFY(mobj->indexOfSlot("e()") != -1);
+-}
+-
+ void tst_Moc::warnOnPropertyWithoutREAD()
+ {
+ #ifdef MOC_CROSS_COMPILED
+@@ -1869,7 +1846,7 @@ void tst_Moc::notifyError()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-I" << "."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+diff --git a/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+index c355ee9665..88c09de8e0 100644
+--- a/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
++++ b/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+@@ -251,6 +251,7 @@ private slots:
+     void testResetCachedSizeHint();
+     void statusTips();
+     void testRemovingColumnsViaLayoutChanged();
++    void testModelMovingColumns();
+ 
+ protected:
+     void setupTestData(bool use_reset_model = false);
+@@ -360,6 +361,12 @@ public:
+         endRemoveColumns();
+     }
+ 
++    void moveColumn(int from, int to)
++    {
++        beginMoveColumns(QModelIndex(), from, from, QModelIndex(), to);
++        endMoveColumns();
++    }
++
+     void cleanup()
+     {
+         emit layoutAboutToBeChanged();
+@@ -3627,5 +3634,18 @@ void tst_QHeaderView::testRemovingColumnsViaLayoutChanged()
+     // The main point of this test is that the section-size restoring code didn't go out of bounds.
+ }
+ 
++void tst_QHeaderView::testModelMovingColumns()
++{
++    QtTestModel model(10, 10);
++    QHeaderView hv(Qt::Horizontal);
++    hv.setModel(&model);
++    hv.resizeSections(QHeaderView::ResizeToContents);
++    hv.show();
++
++    QPersistentModelIndex index3 = model.index(0, 3);
++    model.moveColumn(3, 1);
++    QCOMPARE(index3.column(), 1);
++}
++
+ QTEST_MAIN(tst_QHeaderView)
+ #include "tst_qheaderview.moc"
+diff --git a/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+index 761357b252..06bb706074 100644
+--- a/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
++++ b/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+@@ -397,6 +397,7 @@ private slots:
+     void checkHeaderMinSize();
+ 
+     void resizeToContents();
++    void resizeToContentsSpans();
+ 
+     void tabFocus();
+     void bigModel();
+@@ -3721,6 +3722,70 @@ void tst_QTableView::resizeToContents()
+ 
+ }
+ 
++
++class SpanModel : public QAbstractTableModel
++{
++public:
++    SpanModel(bool sectionsMoved)
++        : _sectionsMoved(sectionsMoved)
++    {}
++    int columnCount(const QModelIndex & = {}) const override { return 2; }
++    int rowCount(const QModelIndex & = {}) const override { return 1; }
++    QVariant data(const QModelIndex &idx, int role = Qt::DisplayRole) const override
++    {
++        if (role != Qt::DisplayRole)
++            return QVariant();
++        const int col = _sectionsMoved ? 1 - idx.column() : idx.column();
++        if (col == 0)
++            return "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.";
++        return QVariant();
++    }
++private:
++    bool _sectionsMoved;
++};
++
++
++void tst_QTableView::resizeToContentsSpans()
++{
++    SpanModel model1(false);
++    SpanModel model2(true);
++    QTableView view1, view2, view3;
++    view1.setModel(&model1);
++    view2.setModel(&model2);
++    view2.horizontalHeader()->moveSection(0, 1);
++    view3.setModel(&model1);
++
++    view1.setSpan(0, 0, 1, 2);
++    view2.setSpan(0, 1, 1, 2);
++    view1.show();
++    view2.show();
++    view3.show();
++    QVERIFY(QTest::qWaitForWindowExposed(&view1));
++    QVERIFY(QTest::qWaitForWindowExposed(&view2));
++    QVERIFY(QTest::qWaitForWindowExposed(&view3));
++    view1.setColumnWidth(0, 100);
++    view1.setColumnWidth(1, 100);
++    view2.setColumnWidth(0, 100);
++    view2.setColumnWidth(1, 100);
++    view3.setColumnWidth(0, 200);
++
++    view1.resizeRowToContents(0);
++    view2.resizeRowToContents(0);
++    view3.resizeRowToContents(0);
++    QCOMPARE(view1.rowHeight(0), view3.rowHeight(0));
++    QCOMPARE(view2.rowHeight(0), view3.rowHeight(0));
++
++    view3.resizeColumnToContents(0);
++    view3.resizeRowToContents(0);
++    // height should be only 1 text line for easy testing
++    view1.setRowHeight(0, view3.verticalHeader()->sectionSize(0));
++    view2.setRowHeight(0, view3.verticalHeader()->sectionSize(0));
++    view1.resizeColumnToContents(0);
++    view2.resizeColumnToContents(1);
++    QCOMPARE(view1.columnWidth(0), view3.columnWidth(0) - view1.columnWidth(1));
++    QCOMPARE(view2.columnWidth(0), view3.columnWidth(0) - view2.columnWidth(1));
++}
++
+ QT_BEGIN_NAMESPACE
+ extern bool Q_WIDGETS_EXPORT qt_tab_all_widgets(); // qapplication.cpp
+ QT_END_NAMESPACE
+diff --git a/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+index a3b8ef78d8..4955cebd5d 100644
+--- a/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
++++ b/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+@@ -1498,7 +1498,7 @@ void tst_QApplication::desktopSettingsAware()
+     environment += QLatin1String("QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM=1");
+     testProcess.setEnvironment(environment);
+ #endif
+-    testProcess.start("desktopsettingsaware_helper");
++    testProcess.start("./desktopsettingsaware_helper");
+     QVERIFY2(testProcess.waitForStarted(),
+              qPrintable(QString::fromLatin1("Cannot start 'desktopsettingsaware_helper': %1").arg(testProcess.errorString())));
+     QVERIFY(testProcess.waitForFinished(10000));
+@@ -2452,7 +2452,7 @@ void tst_QApplication::qtbug_12673()
+ #if QT_CONFIG(process)
+     QProcess testProcess;
+     QStringList arguments;
+-    testProcess.start("modal_helper", arguments);
++    testProcess.start("./modal_helper", arguments);
+     QVERIFY2(testProcess.waitForStarted(),
+              qPrintable(QString::fromLatin1("Cannot start 'modal_helper': %1").arg(testProcess.errorString())));
+     QVERIFY(testProcess.waitForFinished(20000));
+diff --git a/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp b/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
+index eb108a40de..dca5528c1b 100644
+--- a/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
+@@ -41,6 +41,7 @@
+ 
+ #include <private/qguiapplication_p.h>
+ #include <qpa/qplatformintegration.h>
++#include <qpa/qplatformtheme.h>
+ 
+ class tst_QAbstractButton : public QObject
+ {
+@@ -76,6 +77,8 @@ private slots:
+     void keyNavigation();
+ #endif
+ 
++    void buttonPressKeys();
++
+ protected slots:
+     void onClicked();
+     void onToggled( bool on );
+@@ -269,7 +272,13 @@ void tst_QAbstractButton::setAutoRepeat()
+         QCOMPARE(press_count, click_count);
+         QVERIFY(click_count > 1);
+         break;
+-    case 4:
++    case 4: {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(Qt::Key_Enter)) {
++            QSKIP("platform theme has Key_Enter in ButtonPressKeys");
++        }
+         // check that pressing ENTER has no effect when autorepeat is false
+         testWidget->setDown( false );
+         testWidget->setAutoRepeat( false );
+@@ -286,7 +295,14 @@ void tst_QAbstractButton::setAutoRepeat()
+ 
+         QVERIFY( click_count == 0 );
+         break;
+-    case 5:
++    }
++    case 5: {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(Qt::Key_Enter)) {
++            QSKIP("platform theme has Key_Enter in ButtonPressKeys");
++        }
+         // check that pressing ENTER has no effect when autorepeat is true
+         testWidget->setDown( false );
+         testWidget->setAutoRepeat( true );
+@@ -304,6 +320,7 @@ void tst_QAbstractButton::setAutoRepeat()
+ 
+         QVERIFY( click_count == 0 );
+         break;
++    }
+     case 6:
+         // verify autorepeat is off by default.
+         MyButton tmp( 0);
+@@ -651,5 +668,16 @@ void tst_QAbstractButton::keyNavigation()
+ }
+ #endif
+ 
++void tst_QAbstractButton::buttonPressKeys()
++{
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(testWidget, buttonPressKeys[i]);
++        QCOMPARE(click_count, i + 1);
++    }
++}
++
+ QTEST_MAIN(tst_QAbstractButton)
+ #include "tst_qabstractbutton.moc"
+diff --git a/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+index 32437050f5..46b5af6d63 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+@@ -168,6 +168,7 @@ private slots:
+     void checkMenuItemPosWhenStyleSheetIsSet();
+     void checkEmbeddedLineEditWhenStyleSheetIsSet();
+     void propagateStyleChanges();
++    void buttonPressKeys();
+ 
+ private:
+     PlatformInputContext m_platformInputContext;
+@@ -1682,6 +1683,16 @@ void tst_QComboBox::setModel()
+     QCOMPARE(box.rootModelIndex(), rootModelIndex);
+     box.setModel(box.model());
+     QCOMPARE(box.rootModelIndex(), rootModelIndex);
++
++    // check that setting the same model as the completer's doesn't crash
++    QCompleter *completer = new QCompleter(&box);
++    box.setEditable(true);
++    box.setCompleter(completer);
++    auto *listModel = new QStringListModel({ "one", "two" }, completer);
++    completer->setModel(listModel);
++    QCOMPARE(listModel->rowCount(), 2); // make sure it wasn't deleted
++    box.setModel(listModel);
++    QCOMPARE(listModel->rowCount(), 2); // make sure it wasn't deleted
+ }
+ 
+ void tst_QComboBox::setCustomModelAndView()
+@@ -3632,5 +3643,24 @@ void tst_QComboBox::propagateStyleChanges()
+     QVERIFY(frameStyle.inquired);
+ }
+ 
++void tst_QComboBox::buttonPressKeys()
++{
++    QComboBox comboBox;
++    comboBox.setEditable(false);
++    comboBox.addItem(QString::number(1));
++    comboBox.addItem(QString::number(2));
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(&comboBox, buttonPressKeys[i]);
++        // On some platforms, a window will not be immediately visible,
++        // but take some event-loop iterations to complete.
++        // Using QTRY_VERIFY to deal with that.
++        QTRY_VERIFY(comboBox.view()->isVisible());
++        comboBox.hidePopup();
++    }
++}
++
+ QTEST_MAIN(tst_QComboBox)
+ #include "tst_qcombobox.moc"
+diff --git a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
+index be3cfcd104..c228fdfcca 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
++++ b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qcommandlinkbutton
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qcommandlinkbutton.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
+index 0044d33c66..4cf06296e4 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
+@@ -40,6 +40,9 @@
+ #include <QGridLayout>
+ #include <QPainter>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ class tst_QCommandLinkButton : public QObject
+ {
+     Q_OBJECT
+@@ -223,6 +226,13 @@ void tst_QCommandLinkButton::setAutoRepeat()
+     // check that pressing ENTER has no effect
+     resetCounters();
+     testWidget->setDown( false );
++    // Skip after reset if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
+     testWidget->setAutoRepeat( false );
+     QTest::keyPress( testWidget, Qt::Key_Enter );
+ 
+@@ -255,6 +265,14 @@ void tst_QCommandLinkButton::pressed()
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+ 
++    // Skip if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
++
+     QTest::keyPress( testWidget,Qt::Key_Enter );
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+diff --git a/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro b/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
+index 4a5e76ff65..a235fa1fac 100644
+--- a/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
++++ b/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qgroupbox
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qgroupbox.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp b/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
+index 4fb5d262ca..d8d7562b73 100644
+--- a/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
+@@ -35,6 +35,9 @@
+ #include <QRadioButton>
+ #include <QDialog>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ #include "qgroupbox.h"
+ 
+ class tst_QGroupBox : public QObject
+@@ -69,6 +72,7 @@ private slots:
+     void propagateFocus();
+     void task_QTBUG_19170_ignoreMouseReleaseEvent();
+     void task_QTBUG_15519_propagateMouseEvents();
++    void buttonPressKeys();
+ 
+ private:
+     bool checked;
+@@ -610,6 +614,20 @@ void tst_QGroupBox::task_QTBUG_15519_propagateMouseEvents()
+     QCOMPARE(parent.mouseMoved, true);
+ }
+ 
++void tst_QGroupBox::buttonPressKeys()
++{
++    QGroupBox groupBox;
++    groupBox.setCheckable(true);
++    QSignalSpy clickedSpy(&groupBox, &QGroupBox::clicked);
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(&groupBox, buttonPressKeys[i]);
++        QCOMPARE(clickedSpy.length(), i + 1);
++    }
++}
++
+ void tst_QGroupBox::sendMouseMoveEvent(QWidget *widget, const QPoint &localPos)
+ {
+     // Send a MouseMove event without actually moving the pointer
+diff --git a/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro b/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
+index 353ad06ca2..e55f6148f2 100644
+--- a/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
++++ b/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qpushbutton
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qpushbutton.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp b/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
+index e818514a79..4043e9326a 100644
+--- a/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
+@@ -41,6 +41,9 @@
+ #include <QStyleFactory>
+ #include <QTabWidget>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ class tst_QPushButton : public QObject
+ {
+ Q_OBJECT
+@@ -212,6 +215,13 @@ void tst_QPushButton::autoRepeat()
+     // check that pressing ENTER has no effect
+     resetCounters();
+     testWidget->setDown( false );
++    // Skip after reset if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
+     testWidget->setAutoRepeat( false );
+     QTest::keyPress( testWidget, Qt::Key_Enter );
+ 
+@@ -247,6 +257,14 @@ void tst_QPushButton::pressed()
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+ 
++    // Skip if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
++
+     QTest::keyPress( testWidget,Qt::Key_Enter );
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+diff --git a/qtbase/tests/manual/rhi/cubemap_render/buildshader.bat b/qtbase/tests/manual/rhi/cubemap_render/buildshader.bat
+old mode 100755
+new mode 100644
+Submodule qtconnectivity e957d481..056294c0:
+diff --git a/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp b/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
+index e2635fae..a8b8e3b9 100644
+--- a/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
++++ b/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
+@@ -563,9 +563,11 @@ void HciManager::handleHciAclPacket(const quint8 *data, int size)
+ 
+ void HciManager::handleLeMetaEvent(const quint8 *data)
+ {
+-    // Spec v4.2, Vol 2, part E, 7.7.65ff
++    // Spec v5.3, Vol 4, part E, 7.7.65.*
+     switch (*data) {
+-    case 0x1: {
++    case 0x1: // HCI_LE_Connection_Complete
++    case 0xA: // HCI_LE_Enhanced_Connection_Complete
++    {
+         const quint16 handle = bt_get_le16(data + 2);
+         emit connectionComplete(handle);
+         break;
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp b/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
+index 6a93143b..4a18cfc7 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
+@@ -320,7 +320,10 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_finishSdpScan(QBluetoothServiceD
+             for (const QBluetoothUuid &id : serviceClassUuids) {
+                 if (id.minimumSize() == 16) {
+                     serviceInfo.setServiceUuid(id);
+-                    serviceInfo.setServiceName(QBluetoothServiceDiscoveryAgent::tr("Custom Service"));
++                    if (serviceInfo.serviceName().isEmpty()) {
++                        serviceInfo.setServiceName(
++                                    QBluetoothServiceDiscoveryAgent::tr("Custom Service"));
++                    }
+                     QBluetoothServiceInfo::Sequence modSeq =
+                             serviceInfo.attribute(QBluetoothServiceInfo::ServiceClassIds).value<QBluetoothServiceInfo::Sequence>();
+                     modSeq.removeOne(QVariant::fromValue(id));
+@@ -334,8 +337,10 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_finishSdpScan(QBluetoothServiceD
+                 qCDebug(QT_BT_BLUEZ) << "Discovered services" << discoveredDevices.at(0).address().toString()
+                                      << serviceInfo.serviceName() << serviceInfo.serviceUuid()
+                                      << ">>>" << serviceInfo.serviceClassUuids();
+-
+-                emit q->serviceDiscovered(serviceInfo);
++                // Use queued connection to allow us finish the service looping; the application
++                // might call stop() when it has detected the service-of-interest.
++                QMetaObject::invokeMethod(q, "serviceDiscovered", Qt::QueuedConnection,
++                                          Q_ARG(QBluetoothServiceInfo, serviceInfo));
+             }
+         }
+     }
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp b/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
+index e4d85447..aadd4755 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
+@@ -593,7 +593,7 @@ void QBluetoothSocket::setSocketState(QBluetoothSocket::SocketState state)
+ bool QBluetoothSocket::canReadLine() const
+ {
+     Q_D(const QBluetoothSocketBase);
+-    return d->canReadLine();
++    return d->canReadLine() || QIODevice::canReadLine();
+ }
+ 
+ /*!
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp b/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
+index 084aa958..d6aa17a7 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
+@@ -284,6 +284,10 @@ void QBluetoothSocketPrivateBluezDBus::connectToService(
+         return;
+     }
+ 
++    if (service.socketProtocol() != QBluetoothServiceInfo::Protocol::UnknownProtocol)
++        socketType = service.socketProtocol();
++    qCDebug(QT_BT_BLUEZ) << "Socket protocol used:" << socketType;
++
+     connectToService(service.device().address(), targetService, openMode);
+ }
+ 
+diff --git a/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp b/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
+index 05bc1a0f..a7b5ef1f 100644
+--- a/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
++++ b/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
+@@ -142,7 +142,7 @@ void tst_QBluetoothSocket::initTestCase()
+     qDebug() << "Starting discovery";
+ 
+     sda->setUuidFilter(QBluetoothUuid(QString(TEST_SERVICE_UUID)));
+-    sda->start(QBluetoothServiceDiscoveryAgent::MinimalDiscovery);
++    sda->start(QBluetoothServiceDiscoveryAgent::FullDiscovery);
+ 
+     for (int connectTime = MaxConnectTime; !done_discovery && connectTime > 0; connectTime -= 1000)
+         QTest::qWait(1000);
+Submodule qtdeclarative f5701f0d..8defe7bf:
+diff --git a/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h b/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
+index b65b994d6c..15a8cd6878 100644
+--- a/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
++++ b/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
+@@ -86,7 +86,7 @@ public:
+         if (QTypeInfo<T>::isComplex) {
+             for (int i = 0; i < count; ++i)
+                 new (data + i) T(vector.at(i));
+-        } else {
++        } else if (count) {
+             memcpy(data, static_cast<const void*>(vector.constData()), count * sizeof(T));
+         }
+     }
+diff --git a/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp b/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
+index e57cdd8278..94613598af 100644
+--- a/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
++++ b/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
+@@ -1145,8 +1145,7 @@ void Heap::QObjectWrapper::markObjects(Heap::Base *that, QV4::MarkStack *markSta
+ void QObjectWrapper::destroyObject(bool lastCall)
+ {
+     Heap::QObjectWrapper *h = d();
+-    if (!h->internalClass)
+-        return; // destroyObject already got called
++    Q_ASSERT(h->internalClass);
+ 
+     if (h->object()) {
+         QQmlData *ddata = QQmlData::get(h->object(), false);
+@@ -1176,7 +1175,7 @@ void QObjectWrapper::destroyObject(bool lastCall)
+         }
+     }
+ 
+-    h->~Data();
++    h->destroy();
+ }
+ 
+ 
+diff --git a/qtdeclarative/src/qml/memory/qv4mm.cpp b/qtdeclarative/src/qml/memory/qv4mm.cpp
+index 06caf04e5a..da149a67c4 100644
+--- a/qtdeclarative/src/qml/memory/qv4mm.cpp
++++ b/qtdeclarative/src/qml/memory/qv4mm.cpp
+@@ -981,7 +981,7 @@ void MemoryManager::sweep(bool lastSweep, ClassDestroyStatsCallback classCountPt
+ 
+     if (MultiplyWrappedQObjectMap *multiplyWrappedQObjects = engine->m_multiplyWrappedQObjects) {
+         for (MultiplyWrappedQObjectMap::Iterator it = multiplyWrappedQObjects->begin(); it != multiplyWrappedQObjects->end();) {
+-            if (!it.value().isNullOrUndefined())
++            if (it.value().isNullOrUndefined())
+                 it = multiplyWrappedQObjects->erase(it);
+             else
+                 ++it;
+diff --git a/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp b/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
+index 2079a8ed04..a577cb2351 100644
+--- a/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
++++ b/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
+@@ -389,6 +389,12 @@ void QQmlDelegateModelPrivate::connectToAbstractItemModel()
+                       q,  QQmlDelegateModel, SLOT(_q_rowsRemoved(QModelIndex,int,int)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
+                       q,  QQmlDelegateModel, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsInserted(QModelIndex,int,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsInserted(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsRemoved(QModelIndex,int,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsRemoved(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsMoved(QModelIndex,int,int,QModelIndex,int)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
+                       q, QQmlDelegateModel, SLOT(_q_dataChanged(QModelIndex,QModelIndex,QVector<int>)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
+@@ -413,6 +419,12 @@ void QQmlDelegateModelPrivate::disconnectFromAbstractItemModel()
+                         q, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int)));
+     QObject::disconnect(aim, SIGNAL(rowsRemoved(QModelIndex,int,int)),
+                         q, SLOT(_q_rowsRemoved(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsInserted(QModelIndex,int,int)), q,
++                        SLOT(_q_columnsInserted(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsRemoved(QModelIndex,int,int)), q,
++                        SLOT(_q_columnsRemoved(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)), q,
++                        SLOT(_q_columnsMoved(QModelIndex,int,int,QModelIndex,int)));
+     QObject::disconnect(aim, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
+                         q, SLOT(_q_dataChanged(QModelIndex,QModelIndex,QVector<int>)));
+     QObject::disconnect(aim, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
+@@ -1973,6 +1985,38 @@ void QQmlDelegateModel::_q_rowsMoved(
+     }
+ }
+ 
++void QQmlDelegateModel::_q_columnsInserted(const QModelIndex &parent, int begin, int end)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if (parent == d->m_adaptorModel.rootIndex && begin == 0) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
++void QQmlDelegateModel::_q_columnsRemoved(const QModelIndex &parent, int begin, int end)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if (parent == d->m_adaptorModel.rootIndex && begin == 0) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
++void QQmlDelegateModel::_q_columnsMoved(const QModelIndex &parent, int start, int end,
++                                        const QModelIndex &destination, int column)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if ((parent == d->m_adaptorModel.rootIndex && start == 0)
++        || (destination == d->m_adaptorModel.rootIndex && column == 0)) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
+ void QQmlDelegateModel::_q_dataChanged(const QModelIndex &begin, const QModelIndex &end, const QVector<int> &roles)
+ {
+     Q_D(QQmlDelegateModel);
+diff --git a/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h b/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
+index 8aab4badca..d140bfbaaf 100644
+--- a/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
++++ b/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
+@@ -152,6 +152,9 @@ private Q_SLOTS:
+     void _q_itemsMoved(int from, int to, int count);
+     void _q_modelReset();
+     void _q_rowsInserted(const QModelIndex &,int,int);
++    void _q_columnsInserted(const QModelIndex &, int, int);
++    void _q_columnsRemoved(const QModelIndex &, int, int);
++    void _q_columnsMoved(const QModelIndex &, int, int, const QModelIndex &, int);
+     void _q_rowsAboutToBeRemoved(const QModelIndex &parent, int begin, int end);
+     void _q_rowsRemoved(const QModelIndex &,int,int);
+     void _q_rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int);
+diff --git a/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp b/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
+index 85719fdc80..78e2ab302c 100644
+--- a/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
++++ b/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
+@@ -46,6 +46,7 @@
+ #include "QtQuick/private/qquicktextinput_p.h"
+ #include "QtQuick/private/qquickaccessibleattached_p.h"
+ #include "QtQuick/qquicktextdocument.h"
++#include "QtQuick/qquickrendercontrol.h"
+ QT_BEGIN_NAMESPACE
+ 
+ #if QT_CONFIG(accessibility)
+@@ -57,7 +58,19 @@ QAccessibleQuickItem::QAccessibleQuickItem(QQuickItem *item)
+ 
+ QWindow *QAccessibleQuickItem::window() const
+ {
+-    return item()->window();
++    QQuickWindow *window = item()->window();
++
++    // For QQuickWidget the above window will be the offscreen QQuickWindow,
++    // which is not a part of the accessibility tree. Detect this case and
++    // return the window for the QQuickWidget instead.
++    if (window && !window->handle()) {
++        if (QQuickRenderControl *renderControl = QQuickWindowPrivate::get(window)->renderControl) {
++            if (QWindow *renderWindow = renderControl->renderWindow(nullptr))
++                return renderWindow;
++        }
++    }
++
++    return window;
+ }
+ 
+ int QAccessibleQuickItem::childCount() const
+@@ -113,19 +126,15 @@ QAccessibleInterface *QAccessibleQuickItem::childAt(int x, int y) const
+ QAccessibleInterface *QAccessibleQuickItem::parent() const
+ {
+     QQuickItem *parent = item()->parentItem();
+-    QQuickWindow *window = item()->window();
+-    QQuickItem *ci = window ? window->contentItem() : nullptr;
++    QQuickWindow *itemWindow = item()->window();
++    QQuickItem *ci = itemWindow ? itemWindow->contentItem() : nullptr;
+     while (parent && !QQuickItemPrivate::get(parent)->isAccessible && parent != ci)
+         parent = parent->parentItem();
+ 
+     if (parent) {
+         if (parent == ci) {
+-            // Jump out to the scene widget if the parent is the root item.
+-            // There are two root items, QQuickWindow::rootItem and
+-            // QQuickView::declarativeRoot. The former is the true root item,
+-            // but is not a part of the accessibility tree. Check if we hit
+-            // it here and return an interface for the scene instead.
+-            return QAccessible::queryAccessibleInterface(window);
++            // Jump out to the window if the parent is the root item
++            return QAccessible::queryAccessibleInterface(window());
+         } else {
+             while (parent && !parent->d_func()->isAccessible)
+                 parent = parent->parentItem();
+@@ -188,7 +197,7 @@ QAccessible::State QAccessibleQuickItem::state() const
+     QRect viewRect_ = viewRect();
+     QRect itemRect = rect();
+ 
+-    if (viewRect_.isNull() || itemRect.isNull() || !item()->window() || !item()->window()->isVisible() ||!item()->isVisible() || qFuzzyIsNull(item()->opacity()))
++    if (viewRect_.isNull() || itemRect.isNull() || !window() || !window()->isVisible() ||!item()->isVisible() || qFuzzyIsNull(item()->opacity()))
+         state.invisible = true;
+     if (!viewRect_.intersects(itemRect))
+         state.offscreen = true;
+@@ -201,6 +210,10 @@ QAccessible::State QAccessibleQuickItem::state() const
+     if (role() == QAccessible::EditableText)
+         if (auto ti = qobject_cast<QQuickTextInput *>(item()))
+             state.passwordEdit = ti->echoMode() != QQuickTextInput::Normal;
++    if (!item()->isEnabled()) {
++        state.focusable = false;
++        state.disabled = true;
++    }
+     return state;
+ }
+ 
+diff --git a/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h b/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
+index 39ffcaf39c..8baa01330c 100644
+--- a/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
++++ b/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
+@@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE
+ 
+ #if QT_CONFIG(accessibility)
+ 
+-class QAccessibleQuickWindow : public QAccessibleObject
++class Q_QUICK_EXPORT QAccessibleQuickWindow : public QAccessibleObject
+ {
+ public:
+     QAccessibleQuickWindow(QQuickWindow *object);
+diff --git a/qtdeclarative/src/quick/items/qquickdrag.cpp b/qtdeclarative/src/quick/items/qquickdrag.cpp
+index 8321fcfeed..383078b3b9 100644
+--- a/qtdeclarative/src/quick/items/qquickdrag.cpp
++++ b/qtdeclarative/src/quick/items/qquickdrag.cpp
+@@ -481,7 +481,9 @@ void QQuickDragAttached::setKeys(const QStringList &keys)
+     \qmlattachedproperty stringlist QtQuick::Drag::mimeData
+     \since 5.2
+ 
+-    This property holds a map of mimeData that is used during startDrag.
++    This property holds a map from mime type to data that is used during startDrag.
++    The mime data needs to be a \c string, or an \c ArrayBuffer with the data encoded
++    according to the mime type.
+ */
+ 
+ QVariantMap QQuickDragAttached::mimeData() const
+@@ -766,8 +768,12 @@ Qt::DropAction QQuickDragAttachedPrivate::startDrag(Qt::DropActions supportedAct
+     QDrag *drag = new QDrag(source ? source : q);
+     QMimeData *mimeData = new QMimeData();
+ 
+-    for (auto it = externalMimeData.cbegin(), end = externalMimeData.cend(); it != end; ++it)
+-        mimeData->setData(it.key(), it.value().toString().toUtf8());
++    for (auto it = externalMimeData.cbegin(), end = externalMimeData.cend(); it != end; ++it) {
++        if (static_cast<QMetaType::Type>(it.value().type()) == QMetaType::QByteArray)
++            mimeData->setData(it.key(), it.value().toByteArray());
++        else
++            mimeData->setData(it.key(), it.value().toString().toUtf8());
++    }
+ 
+     drag->setMimeData(mimeData);
+     if (pixmapLoader.isReady()) {
+diff --git a/qtdeclarative/src/quick/items/qquickitem.cpp b/qtdeclarative/src/quick/items/qquickitem.cpp
+index 75f1457816..dec0ae19ae 100644
+--- a/qtdeclarative/src/quick/items/qquickitem.cpp
++++ b/qtdeclarative/src/quick/items/qquickitem.cpp
+@@ -59,6 +59,7 @@
+ #include <QtCore/private/qnumeric_p.h>
+ #include <QtGui/qpa/qplatformtheme.h>
+ #include <QtCore/qloggingcategory.h>
++#include <QtCore/private/qduplicatetracker_p.h>
+ 
+ #include <private/qqmlglobal_p.h>
+ #include <private/qqmlengine_p.h>
+@@ -2326,6 +2327,7 @@ QQuickItem::QQuickItem(QQuickItemPrivate &dd, QQuickItem *parent)
+ QQuickItem::~QQuickItem()
+ {
+     Q_D(QQuickItem);
++    d->inDestructor = true;
+ 
+     if (d->windowRefCount > 1)
+         d->windowRefCount = 1; // Make sure window is set to null in next call to derefWindow().
+@@ -2526,6 +2528,7 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo
+     QQuickItem *current = item;
+     qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: startItem:" << startItem;
+     qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: firstFromItem:" << firstFromItem;
++    QDuplicateTracker<QQuickItem *> cycleDetector;
+     do {
+         qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: current:" << current;
+         qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: from:" << from;
+@@ -2592,7 +2595,10 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo
+         // traversed all of the chain (by compare the [current] item with [startItem])
+         // Since the [startItem] might be promoted to its parent if it is invisible,
+         // we still have to check [current] item with original start item
+-        if ((current == startItem || current == originalStartItem) && from == firstFromItem) {
++        // We might also run into a cycle before we reach firstFromItem again
++        // but note that we have to ignore current if we are meant to skip it
++        if (((current == startItem || current == originalStartItem) && from == firstFromItem) ||
++                (!skip && cycleDetector.hasSeen(current))) {
+             // wrapped around, avoid endless loops
+             if (item == contentItem) {
+                 qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: looped, return contentItem";
+@@ -2689,9 +2695,8 @@ void QQuickItem::setParentItem(QQuickItem *parentItem)
+ 
+         const bool wasVisible = isVisible();
+         op->removeChild(this);
+-        if (wasVisible) {
++        if (wasVisible && !op->inDestructor)
+             emit oldParentItem->visibleChildrenChanged();
+-        }
+     } else if (d->window) {
+         QQuickWindowPrivate::get(d->window)->parentlessItems.remove(this);
+     }
+@@ -2768,8 +2773,9 @@ void QQuickItem::setParentItem(QQuickItem *parentItem)
+ 
+     d->itemChange(ItemParentHasChanged, d->parentItem);
+ 
+-    emit parentChanged(d->parentItem);
+-    if (isVisible() && d->parentItem)
++    if (!d->inDestructor)
++        emit parentChanged(d->parentItem);
++    if (isVisible() && d->parentItem && !QQuickItemPrivate::get(d->parentItem)->inDestructor)
+         emit d->parentItem->visibleChildrenChanged();
+ }
+ 
+@@ -2965,7 +2971,8 @@ void QQuickItemPrivate::removeChild(QQuickItem *child)
+ 
+     itemChange(QQuickItem::ItemChildRemovedChange, child);
+ 
+-    emit q->childrenChanged();
++    if (!inDestructor)
++        emit q->childrenChanged();
+ }
+ 
+ void QQuickItemPrivate::refWindow(QQuickWindow *c)
+@@ -3194,6 +3201,7 @@ QQuickItemPrivate::QQuickItemPrivate()
+     , touchEnabled(false)
+ #endif
+     , hasCursorHandler(false)
++    , inDestructor(false)
+     , dirtyAttributes(0)
+     , nextDirtyItem(nullptr)
+     , prevDirtyItem(nullptr)
+@@ -5120,6 +5128,13 @@ void QQuickItem::componentComplete()
+         d->addToDirtyList();
+         QQuickWindowPrivate::get(d->window)->dirtyItem(this);
+     }
++
++#if QT_CONFIG(accessibility)
++    if (d->isAccessible && d->effectiveVisible) {
++        QAccessibleEvent ev(this, QAccessible::ObjectShow);
++        QAccessible::updateAccessibility(&ev);
++    }
++#endif
+ }
+ 
+ QQuickStateGroup *QQuickItemPrivate::_states()
+@@ -6106,9 +6121,11 @@ bool QQuickItemPrivate::setEffectiveVisibleRecur(bool newEffectiveVisible)
+         QAccessible::updateAccessibility(&ev);
+     }
+ #endif
+-    emit q->visibleChanged();
+-    if (childVisibilityChanged)
+-        emit q->visibleChildrenChanged();
++    if (!inDestructor) {
++        emit q->visibleChanged();
++        if (childVisibilityChanged)
++            emit q->visibleChildrenChanged();
++    }
+ 
+     return true;    // effective visibility DID change
+ }
+@@ -6157,6 +6174,15 @@ void QQuickItemPrivate::setEffectiveEnableRecur(QQuickItem *scope, bool newEffec
+     }
+ 
+     itemChange(QQuickItem::ItemEnabledHasChanged, effectiveEnable);
++#if QT_CONFIG(accessibility)
++    if (isAccessible) {
++        QAccessible::State changedState;
++        changedState.disabled = true;
++        changedState.focusable = true;
++        QAccessibleStateChangeEvent ev(q, changedState);
++        QAccessible::updateAccessibility(&ev);
++    }
++#endif
+     emit q->enabledChanged();
+ }
+ 
+diff --git a/qtdeclarative/src/quick/items/qquickitem_p.h b/qtdeclarative/src/quick/items/qquickitem_p.h
+index 841d91bb40..ade8fb61f2 100644
+--- a/qtdeclarative/src/quick/items/qquickitem_p.h
++++ b/qtdeclarative/src/quick/items/qquickitem_p.h
+@@ -472,6 +472,7 @@ public:
+     bool replayingPressEvent:1;
+     bool touchEnabled:1;
+     bool hasCursorHandler:1;
++    quint32 inDestructor:1; // has entered ~QQuickItem
+ 
+     enum DirtyType {
+         TransformOrigin         = 0x00000001,
+diff --git a/qtdeclarative/src/quick/items/qquickitemview.cpp b/qtdeclarative/src/quick/items/qquickitemview.cpp
+index 010a0152e1..f8ad168a17 100644
+--- a/qtdeclarative/src/quick/items/qquickitemview.cpp
++++ b/qtdeclarative/src/quick/items/qquickitemview.cpp
+@@ -1785,7 +1785,7 @@ void QQuickItemViewPrivate::refill(qreal from, qreal to)
+ 
+     do {
+         bufferPause.stop();
+-        if (currentChanges.hasPendingChanges() || bufferedChanges.hasPendingChanges()) {
++        if (currentChanges.hasPendingChanges() || bufferedChanges.hasPendingChanges() || currentChanges.active) {
+             currentChanges.reset();
+             bufferedChanges.reset();
+             releaseVisibleItems(reusableFlag);
+diff --git a/qtdeclarative/src/quick/items/qquickmousearea_p_p.h b/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
+index fba383e268..0d63618622 100644
+--- a/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
++++ b/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
+@@ -61,7 +61,6 @@ QT_BEGIN_NAMESPACE
+ 
+ class QQuickMouseEvent;
+ class QQuickMouseArea;
+-class QQuickPointerMask;
+ class QQuickMouseAreaPrivate : public QQuickItemPrivate
+ {
+     Q_DECLARE_PUBLIC(QQuickMouseArea)
+@@ -100,7 +99,6 @@ public:
+ #if QT_CONFIG(quick_draganddrop)
+     QQuickDrag *drag;
+ #endif
+-    QPointer<QQuickPointerMask> mask;
+     QPointF startScene;
+     QPointF targetStartPos;
+     QPointF lastPos;
+diff --git a/qtdeclarative/src/quick/items/qquicktext.cpp b/qtdeclarative/src/quick/items/qquicktext.cpp
+index 6230186933..e823ca1095 100644
+--- a/qtdeclarative/src/quick/items/qquicktext.cpp
++++ b/qtdeclarative/src/quick/items/qquicktext.cpp
+@@ -2168,7 +2168,7 @@ void QQuickText::resetMaximumLineCount()
+     <img src="" align="top,middle,bottom" width="" height=""> - inline images
+     <ol type="">, <ul type=""> and <li> - ordered and unordered lists
+     <pre></pre> - preformatted
+-    &gt; &lt; &amp;
++    &gt; &lt; &amp; &quot; &nbsp; &apos;
+     \endcode
+ 
+     \c Text.StyledText parser is strict, requiring tags to be correctly nested.
+diff --git a/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp b/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
+index eb4db0f85e..2325a2665b 100644
+--- a/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
++++ b/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
+@@ -446,7 +446,7 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+         const char *textureRecord = allocatorData;
+         for (int i = 0; i < textureCount; ++i, textureRecord += Qtdf::TextureRecordSize) {
+-            if (textureRecord + Qtdf::TextureRecordSize > qtdfTableEnd) {
++            if (qtdfTableEnd - textureRecord < Qtdf::TextureRecordSize) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+@@ -462,7 +462,7 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+         const char *glyphRecord = textureRecord;
+         for (quint32 i = 0; i < glyphCount; ++i, glyphRecord += Qtdf::GlyphRecordSize) {
+-            if (glyphRecord + Qtdf::GlyphRecordSize > qtdfTableEnd) {
++            if (qtdfTableEnd - glyphRecord < Qtdf:: GlyphRecordSize) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+@@ -512,8 +512,8 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+             int width = texInfo->allocatedArea.width();
+             int height = texInfo->allocatedArea.height();
+-            qint64 size = width * height;
+-            if (reinterpret_cast<const char *>(textureData + size) > qtdfTableEnd) {
++            qint64 size = qint64(width) * height;
++            if (qtdfTableEnd - reinterpret_cast<const char *>(textureData) < size) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+diff --git a/qtdeclarative/src/quick/util/qquickstyledtext.cpp b/qtdeclarative/src/quick/util/qquickstyledtext.cpp
+index d531fc9205..a25af90414 100644
+--- a/qtdeclarative/src/quick/util/qquickstyledtext.cpp
++++ b/qtdeclarative/src/quick/util/qquickstyledtext.cpp
+@@ -564,6 +564,8 @@ void QQuickStyledTextPrivate::parseEntity(const QChar *&ch, const QString &textI
+                 textOut += QChar(60);
+             else if (entity == QLatin1String("amp"))
+                 textOut += QChar(38);
++            else if (entity == QLatin1String("apos"))
++                textOut += QChar(39);
+             else if (entity == QLatin1String("quot"))
+                 textOut += QChar(34);
+             else if (entity == QLatin1String("nbsp"))
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp
+new file mode 100644
+index 0000000000..8a1c901880
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp
+@@ -0,0 +1,110 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include "qaccessiblequickwidget_p.h"
++
++#include "qquickwidget_p.h"
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleQuickWidget::QAccessibleQuickWidget(QQuickWidget* widget)
++: QAccessibleWidget(widget)
++, m_accessibleWindow(QQuickWidgetPrivate::get(widget)->offscreenWindow)
++{
++    // NOTE: m_accessibleWindow is a QAccessibleQuickWindow, and not a
++    // QAccessibleQuickWidgetOffscreenWindow (defined below). This means
++    // it will return the Quick item child interfaces, which is what's needed here
++    // (unlike QAccessibleQuickWidgetOffscreenWindow, which will report 0 children).
++}
++
++QAccessibleInterface *QAccessibleQuickWidget::child(int index) const
++{
++    return m_accessibleWindow.child(index);
++}
++
++int QAccessibleQuickWidget::childCount() const
++{
++    return m_accessibleWindow.childCount();
++}
++
++int QAccessibleQuickWidget::indexOfChild(const QAccessibleInterface *iface) const
++{
++    return m_accessibleWindow.indexOfChild(iface);
++}
++
++QAccessibleInterface *QAccessibleQuickWidget::childAt(int x, int y) const
++{
++    return m_accessibleWindow.childAt(x, y);
++}
++
++QAccessibleQuickWidgetOffscreenWindow::QAccessibleQuickWidgetOffscreenWindow(QQuickWindow *window)
++:QAccessibleQuickWindow(window)
++{
++
++}
++
++QAccessibleInterface *QAccessibleQuickWidgetOffscreenWindow::child(int index) const
++{
++    Q_UNUSED(index);
++    return nullptr;
++}
++
++int QAccessibleQuickWidgetOffscreenWindow::childCount() const
++{
++    return 0;
++}
++
++int QAccessibleQuickWidgetOffscreenWindow::indexOfChild(const QAccessibleInterface *iface) const
++{
++    Q_UNUSED(iface);
++    return -1;
++}
++
++QAccessibleInterface *QAccessibleQuickWidgetOffscreenWindow::QAccessibleQuickWidgetOffscreenWindow::childAt(int x, int y) const
++{
++    Q_UNUSED(x);
++    Q_UNUSED(y);
++    return nullptr;
++}
++
++#endif // accessibility
++
++QT_END_NAMESPACE
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h
+new file mode 100644
+index 0000000000..7c2ab930e0
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h
+@@ -0,0 +1,95 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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 QACCESSIBLEQUICKWIDGET_H
++#define QACCESSIBLEQUICKWIDGET_H
++
++//
++//  W A R N I N G
++//  -------------
++//
++// This file is not part of the Qt API.  It exists purely as an
++// implementation detail.  This header file may change from version to
++// version without notice, or even be removed.
++//
++// We mean it.
++//
++
++#include "qquickwidget.h"
++#include <QtWidgets/qaccessiblewidget.h>
++
++#include <private/qaccessiblequickview_p.h>
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++// These classes implement the QQuickWiget accessibility switcharoo,
++// where the child items of the QQuickWidgetOffscreenWindow are reported
++// as child accessible interfaces of the QAccessibleQuickWidget.
++class QAccessibleQuickWidget: public QAccessibleWidget
++{
++public:
++    QAccessibleQuickWidget(QQuickWidget* widget);
++
++    QAccessibleInterface *child(int index) const override;
++    int childCount() const override;
++    int indexOfChild(const QAccessibleInterface *iface) const override;
++    QAccessibleInterface *childAt(int x, int y) const override;
++
++private:
++    QAccessibleQuickWindow m_accessibleWindow;
++    Q_DISABLE_COPY(QAccessibleQuickWidget)
++};
++
++class QAccessibleQuickWidgetOffscreenWindow: public QAccessibleQuickWindow
++{
++public:
++    QAccessibleQuickWidgetOffscreenWindow(QQuickWindow *window);
++    QAccessibleInterface *child(int index) const override;
++    int childCount() const override;
++    int indexOfChild(const QAccessibleInterface *iface) const override;
++    QAccessibleInterface *childAt(int x, int y) const override;
++};
++
++#endif // accessibility
++
++QT_END_NAMESPACE
++
++#endif
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp
+new file mode 100644
+index 0000000000..7ba88a1769
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp
+@@ -0,0 +1,60 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include "qaccessiblequickwidgetfactory_p.h"
++#include "qaccessiblequickwidget_p.h"
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleInterface *qAccessibleQuickWidgetFactory(const QString &classname, QObject *object)
++{
++    if (classname == QLatin1String("QQuickWidget")) {
++        return new QAccessibleQuickWidget(qobject_cast<QQuickWidget *>(object));
++    } else if (classname == QLatin1String("QQuickWidgetOffscreenWindow")) {
++        return new QAccessibleQuickWidgetOffscreenWindow(qobject_cast<QQuickWindow *>(object));
++    }
++    return 0;
++}
++
++#endif // accessibility
++
++QT_END_NAMESPACE
++
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h
+new file mode 100644
+index 0000000000..8c63b09f81
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h
+@@ -0,0 +1,66 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include <QtGui/qaccessible.h>
++
++#ifndef QACCESSIBLEQUICKWIDGETFACTORY_H
++#define QACCESSIBLEQUICKWIDGETFACTORY_H
++
++//
++//  W A R N I N G
++//  -------------
++//
++// This file is not part of the Qt API.  It exists purely as an
++// implementation detail.  This header file may change from version to
++// version without notice, or even be removed.
++//
++// We mean it.
++//
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleInterface *qAccessibleQuickWidgetFactory(const QString &classname, QObject *object);
++
++#endif
++
++QT_END_NAMESPACE
++
++#endif
+diff --git a/qtdeclarative/src/quickwidgets/qquickwidget.cpp b/qtdeclarative/src/quickwidgets/qquickwidget.cpp
+index 39780f8de3..9c97b43518 100644
+--- a/qtdeclarative/src/quickwidgets/qquickwidget.cpp
++++ b/qtdeclarative/src/quickwidgets/qquickwidget.cpp
+@@ -39,6 +39,7 @@
+ 
+ #include "qquickwidget.h"
+ #include "qquickwidget_p.h"
++#include "qaccessiblequickwidgetfactory_p.h"
+ 
+ #include "private/qquickwindow_p.h"
+ #include "private/qquickitem_p.h"
+@@ -75,9 +76,16 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++QQuickWidgetOffscreenWindow::QQuickWidgetOffscreenWindow(QQuickWindowPrivate &dd, QQuickRenderControl *control)
++:QQuickWindow(dd, control)
++{
++    setTitle(QString::fromLatin1("Offscreen"));
++    setObjectName(QString::fromLatin1("QQuickOffScreenWindow"));
++}
++
+ // override setVisble to prevent accidental offscreen window being created
+ // by base class.
+-class QQuickOffcreenWindowPrivate: public QQuickWindowPrivate {
++class QQuickWidgetOffscreenWindowPrivate: public QQuickWindowPrivate {
+ public:
+     void setVisible(bool visible) override {
+         Q_Q(QWindow);
+@@ -105,9 +113,8 @@ void QQuickWidgetPrivate::init(QQmlEngine* e)
+     Q_Q(QQuickWidget);
+ 
+     renderControl = new QQuickWidgetRenderControl(q);
+-    offscreenWindow = new QQuickWindow(*new QQuickOffcreenWindowPrivate(),renderControl);
+-    offscreenWindow->setTitle(QString::fromLatin1("Offscreen"));
+-    offscreenWindow->setObjectName(QString::fromLatin1("QQuickOffScreenWindow"));
++    offscreenWindow = new QQuickWidgetOffscreenWindow(*new QQuickWidgetOffscreenWindowPrivate(), renderControl);
++    offscreenWindow->setScreen(q->screen());
+     // Do not call create() on offscreenWindow.
+ 
+     // Check if the Software Adaptation is being used
+@@ -138,6 +145,10 @@ void QQuickWidgetPrivate::init(QQmlEngine* e)
+     QWidget::connect(offscreenWindow, &QQuickWindow::focusObjectChanged, q, &QQuickWidget::propagateFocusObjectChanged);
+     QObject::connect(renderControl, SIGNAL(renderRequested()), q, SLOT(triggerUpdate()));
+     QObject::connect(renderControl, SIGNAL(sceneChanged()), q, SLOT(triggerUpdate()));
++
++#if QT_CONFIG(accessibility)
++    QAccessible::installFactory(&qAccessibleQuickWidgetFactory);
++#endif
+ }
+ 
+ void QQuickWidgetPrivate::ensureEngine() const
+@@ -901,9 +912,7 @@ void QQuickWidgetPrivate::createContext()
+ 
+         context = new QOpenGLContext;
+         context->setFormat(offscreenWindow->requestedFormat());
+-        const QWindow *win = q->window()->windowHandle();
+-        if (win && win->screen())
+-            context->setScreen(win->screen());
++        context->setScreen(q->screen());
+         QOpenGLContext *shareContext = qt_gl_global_share_context();
+         if (!shareContext)
+             shareContext = QWidgetPrivate::get(q->window())->shareContext();
+@@ -1520,19 +1529,16 @@ bool QQuickWidget::event(QEvent *e)
+         d->handleWindowChange();
+         break;
+ 
+-    case QEvent::ScreenChangeInternal:
+-        if (QWindow *window = this->window()->windowHandle()) {
+-            QScreen *newScreen = window->screen();
+-
+-            if (d->offscreenWindow)
+-                d->offscreenWindow->setScreen(newScreen);
+-            if (d->offscreenSurface)
+-                d->offscreenSurface->setScreen(newScreen);
++    case QEvent::ScreenChangeInternal: {
++        QScreen *newScreen = screen();
++        if (d->offscreenWindow)
++            d->offscreenWindow->setScreen(newScreen);
++        if (d->offscreenSurface)
++            d->offscreenSurface->setScreen(newScreen);
+ #if QT_CONFIG(opengl)
+-            if (d->context)
+-                d->context->setScreen(newScreen);
++        if (d->context)
++            d->context->setScreen(newScreen);
+ #endif
+-        }
+ 
+         if (d->useSoftwareRenderer
+ #if QT_CONFIG(opengl)
+@@ -1545,7 +1551,7 @@ bool QQuickWidget::event(QEvent *e)
+             d->render(true);
+         }
+         break;
+-
++    }
+     case QEvent::Show:
+     case QEvent::Move:
+         d->updatePosition();
+diff --git a/qtdeclarative/src/quickwidgets/qquickwidget_p.h b/qtdeclarative/src/quickwidgets/qquickwidget_p.h
+index 881f7f9220..1a946bcc71 100644
+--- a/qtdeclarative/src/quickwidgets/qquickwidget_p.h
++++ b/qtdeclarative/src/quickwidgets/qquickwidget_p.h
+@@ -148,6 +148,14 @@ public:
+     bool forceFullUpdate;
+ };
+ 
++class QQuickWidgetOffscreenWindow: public QQuickWindow
++{
++    Q_OBJECT
++
++public:
++    QQuickWidgetOffscreenWindow(QQuickWindowPrivate &dd, QQuickRenderControl *control);
++};
++
+ QT_END_NAMESPACE
+ 
+ #endif // QQuickWidget_P_H
+diff --git a/qtdeclarative/src/quickwidgets/quickwidgets.pro b/qtdeclarative/src/quickwidgets/quickwidgets.pro
+index 2438e577ae..85d156b8a3 100644
+--- a/qtdeclarative/src/quickwidgets/quickwidgets.pro
++++ b/qtdeclarative/src/quickwidgets/quickwidgets.pro
+@@ -7,9 +7,13 @@ DEFINES   += QT_NO_URL_CAST_FROM_STRING QT_NO_INTEGER_EVENT_COORDINATES QT_NO_FO
+ HEADERS += \
+     qquickwidget.h \
+     qquickwidget_p.h \
+-    qtquickwidgetsglobal.h
++    qtquickwidgetsglobal.h \
++    qaccessiblequickwidget_p.h \
++    qaccessiblequickwidgetfactory_p.h
+ 
+ SOURCES += \
+-    qquickwidget.cpp
++    qquickwidget.cpp \
++    qaccessiblequickwidget.cpp \
++    qaccessiblequickwidgetfactory.cpp
+ 
+ load(qt_module)
+diff --git a/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+index 3b7d74df63..b75bf820d5 100644
+--- a/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
++++ b/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+@@ -102,6 +102,7 @@ private slots:
+     void valueConversion_RegularExpression();
+     void castWithMultipleInheritance();
+     void collectGarbage();
++    void collectGarbageNestedWrappersTwoEngines();
+     void gcWithNestedDataStructure();
+     void stacktrace();
+     void numberParsing_data();
+@@ -1809,6 +1810,44 @@ void tst_QJSEngine::collectGarbage()
+     QVERIFY(ptr.isNull());
+ }
+ 
++class TestObjectContainer : public QObject
++{
++    Q_OBJECT
++    Q_PROPERTY(QObject *dummy MEMBER m_dummy CONSTANT)
++
++public:
++    TestObjectContainer() : m_dummy(new QObject(this)) {}
++
++private:
++    QObject *m_dummy;
++};
++
++void tst_QJSEngine::collectGarbageNestedWrappersTwoEngines()
++{
++    QJSEngine engine1;
++    QJSEngine engine2;
++
++    TestObjectContainer container;
++    QQmlEngine::setObjectOwnership(&container, QQmlEngine::CppOwnership);
++
++    engine1.globalObject().setProperty("foobar", engine1.newQObject(&container));
++    engine2.globalObject().setProperty("foobar", engine2.newQObject(&container));
++
++    engine1.evaluate("foobar.dummy.baz = 42");
++    engine2.evaluate("foobar.dummy.baz = 43");
++
++    QCOMPARE(engine1.evaluate("foobar.dummy.baz").toInt(), 42);
++    QCOMPARE(engine2.evaluate("foobar.dummy.baz").toInt(), 43);
++
++    engine1.collectGarbage();
++    engine2.collectGarbage();
++
++    // The GC should not collect dummy object wrappers neither in engine1 nor engine2, we
++    // verify that by checking whether the baz property still has its previous value.
++    QCOMPARE(engine1.evaluate("foobar.dummy.baz").toInt(), 42);
++    QCOMPARE(engine2.evaluate("foobar.dummy.baz").toInt(), 43);
++}
++
+ void tst_QJSEngine::gcWithNestedDataStructure()
+ {
+     // The GC must be able to traverse deeply nested objects, otherwise this
+diff --git a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml
+new file mode 100644
+index 0000000000..206133bb39
+--- /dev/null
++++ b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml
+@@ -0,0 +1,11 @@
++import QtQuick 2.8
++
++ListView {
++    id: root
++    width: 200
++    height: 200
++
++    delegate: Text {
++        text: display
++    }
++}
+diff --git a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
+index 35f1e2c94d..1722447830 100644
+--- a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
++++ b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
+@@ -27,6 +27,8 @@
+ ****************************************************************************/
+ 
+ #include <QtTest/qtest.h>
++#include <QtCore/QConcatenateTablesProxyModel>
++#include <QtGui/QStandardItemModel>
+ #include <QtQml/qqmlcomponent.h>
+ #include <QtQmlModels/private/qqmldelegatemodel_p.h>
+ #include <QtQuick/qquickview.h>
+@@ -47,6 +49,7 @@ private slots:
+     void filterOnGroup_removeWhenCompleted();
+     void qtbug_86017();
+     void contextAccessedByHandler();
++    void redrawUponColumnChange();
+ };
+ 
+ class AbstractItemModel : public QAbstractItemModel
+@@ -186,6 +189,30 @@ void tst_QQmlDelegateModel::contextAccessedByHandler()
+     QVERIFY(root->property("works").toBool());
+ }
+ 
++void tst_QQmlDelegateModel::redrawUponColumnChange()
++{
++    QStandardItemModel m1;
++    m1.appendRow({
++            new QStandardItem("Banana"),
++            new QStandardItem("Coconut"),
++    });
++
++    QQuickView view(testFileUrl("redrawUponColumnChange.qml"));
++    QCOMPARE(view.status(), QQuickView::Ready);
++    view.show();
++    QQuickItem *root = view.rootObject();
++    root->setProperty("model", QVariant::fromValue<QObject *>(&m1));
++
++    QObject *item = root->property("currentItem").value<QObject *>();
++    QVERIFY(item);
++    QCOMPARE(item->property("text").toString(), "Banana");
++
++    QVERIFY(root);
++    m1.removeColumn(0);
++
++    QCOMPARE(item->property("text").toString(), "Coconut");
++}
++
+ QTEST_MAIN(tst_QQmlDelegateModel)
+ 
+ #include "tst_qqmldelegatemodel.moc"
+diff --git a/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp b/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
+index 5d635aa63b..824fd89e5b 100644
+--- a/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
++++ b/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
+@@ -76,10 +76,10 @@ void tst_qv4mm::multiWrappedQObjects()
+         QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 1);
+         QCOMPARE(engine2.memoryManager->m_pendingFreedObjectWrapperValue.size(), 0);
+ 
+-        // Moves the additional WeakValue from m_multiplyWrappedQObjects to
+-        // m_pendingFreedObjectWrapperValue. It's still alive after all.
++        // The additional WeakValue from m_multiplyWrappedQObjects hasn't been moved
++        // to m_pendingFreedObjectWrapperValue yet. It's still alive after all.
+         engine1.memoryManager->runGC();
+-        QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 2);
++        QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 1);
+ 
+         // engine2 doesn't own the object as engine1 was the first to wrap it above.
+         // Therefore, no effect here.
+diff --git a/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml b/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml
+new file mode 100644
+index 0000000000..889e480f3b
+--- /dev/null
++++ b/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml
+@@ -0,0 +1,13 @@
++import QtQuick 2.6
++
++Item {
++    visible: true
++    Item {
++        visible: false
++        Item {
++            objectName: "hiddenChild"
++            activeFocusOnTab: true
++            focus: true
++        }
++    }
++}
+diff --git a/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp b/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+index c8f251dbe1..c8ef36ee68 100644
+--- a/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
++++ b/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+@@ -67,6 +67,7 @@ private slots:
+     void activeFocusOnTab10();
+     void activeFocusOnTab_infiniteLoop_data();
+     void activeFocusOnTab_infiniteLoop();
++    void activeFocusOnTab_infiniteLoopControls();
+ 
+     void nextItemInFocusChain();
+     void nextItemInFocusChain2();
+@@ -1057,6 +1058,17 @@ void tst_QQuickItem::activeFocusOnTab_infiniteLoop()
+     QCOMPARE(item, window->rootObject());
+ }
+ 
++
++void tst_QQuickItem::activeFocusOnTab_infiniteLoopControls()
++{
++    auto source = testFileUrl("activeFocusOnTab_infiniteLoop3.qml");
++    QScopedPointer<QQuickView>window(new QQuickView());
++    window->setSource(source);
++    window->show();
++    QVERIFY(window->errors().isEmpty());
++    QTest::keyClick(window.get(), Qt::Key_Tab); // should not hang
++}
++
+ void tst_QQuickItem::nextItemInFocusChain()
+ {
+     if (!qt_tab_all_widgets())
+Submodule qtdoc c0c7bf07...79d6ef69:
+Submodule qtimageformats 2dcf2899..abe44c0f:
+diff --git a/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp b/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
+index dde783c..1bf9074 100644
+--- a/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
+@@ -462,8 +462,12 @@ static bool parseIconEntryInfo(ICNSEntry &icon)
+     if (isIconCompressed(icon))
+         return true;
+     // Icon depth:
+-    if (!depth.isEmpty())
+-        icon.depth = ICNSEntry::Depth(depth.toUInt());
++    if (!depth.isEmpty()) {
++        const uint depthUInt = depth.toUInt();
++        if (depthUInt > 32)
++            return false;
++        icon.depth = ICNSEntry::Depth(depthUInt);
++    }
+     // Try mono if depth not found
+     if (icon.depth == ICNSEntry::DepthUnknown)
+         icon.depth = ICNSEntry::DepthMono;
+@@ -515,6 +519,9 @@ static bool parseIconEntryInfo(ICNSEntry &icon)
+         }
+         icon.height = icon.width;
+     }
++    // Sanity check
++    if (icon.width == 0 || icon.width > 4096)
++        return false;
+     return true;
+ }
+ 
+@@ -685,7 +692,7 @@ bool QICNSHandler::canRead() const
+ bool QICNSHandler::read(QImage *outImage)
+ {
+     QImage img;
+-    if (!ensureScanned()) {
++    if (!ensureScanned() || m_currentIconIndex >= m_icons.size()) {
+         qWarning("QICNSHandler::read(): The device wasn't parsed properly!");
+         return false;
+     }
+@@ -892,7 +899,7 @@ bool QICNSHandler::scanDevice()
+             return false;
+ 
+         const qint64 blockDataOffset = device()->pos();
+-        if (!isBlockHeaderValid(blockHeader)) {
++        if (!isBlockHeaderValid(blockHeader, ICNSBlockHeaderSize + filelength - blockDataOffset)) {
+             qWarning("QICNSHandler::scanDevice(): Failed, bad header at pos %s. OSType \"%s\", length %u",
+                      QByteArray::number(blockDataOffset).constData(),
+                      nameFromOSType(blockHeader.ostype).constData(), blockHeader.length);
+@@ -927,11 +934,14 @@ bool QICNSHandler::scanDevice()
+         case ICNSBlockHeader::TypeOdrp:
+             // Icns container seems to have an embedded icon variant container
+             // Let's start a scan for entries
+-            while (device()->pos() < nextBlockOffset) {
++            while (!stream.atEnd() && device()->pos() < nextBlockOffset) {
+                 ICNSBlockHeader icon;
+                 stream >> icon;
++                if (stream.status() != QDataStream::Ok)
++                    return false;
+                 // Check for incorrect variant entry header and stop scan
+-                if (!isBlockHeaderValid(icon, blockDataLength))
++                quint64 remaining = blockDataLength - (device()->pos() - blockDataOffset);
++                if (!isBlockHeaderValid(icon, ICNSBlockHeaderSize + remaining))
+                     break;
+                 if (!addEntry(icon, device()->pos(), blockHeader.ostype))
+                     return false;
+@@ -1003,7 +1013,7 @@ bool QICNSHandler::scanDevice()
+             break;
+         }
+     }
+-    return true;
++    return (m_icons.size() > 0);
+ }
+ 
+ const ICNSEntry &QICNSHandler::getIconMask(const ICNSEntry &icon) const
+diff --git a/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp b/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
+index 5082023..cb34374 100644
+--- a/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
++++ b/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
+@@ -43,6 +43,7 @@
+ #include "qimage.h"
+ #include "qvariant.h"
+ #include "qcolor.h"
++#include "qimagereader.h"
+ 
+ #include <jasper/jasper.h>
+ #include <math.h> // for pow
+@@ -333,16 +334,46 @@ private:
+ Jpeg2000JasperReader::Jpeg2000JasperReader(QIODevice *iod, SubFormat format)
+     : jasperOk(true), ioDevice(iod), format(format), hasAlpha(false)
+ {
++#if JAS_VERSION_MAJOR < 3
+     if (jas_init()) {
+         jasperOk = false;
+         qDebug("Jasper Library initialization failed");
+     }
++#else
++    jas_conf_clear();
++#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
++    jas_conf_set_max_mem_usage(QImageReader::allocationLimit() * 1024 * 1024);
++#else
++    // 128MB seems to be enough.
++    jas_conf_set_max_mem_usage(128 * 1024 * 1024);
++#endif
++    if (jas_init_library()) {
++        jasperOk = false;
++        qDebug("Jasper library initialization failed");
++    }
++    if (jas_init_thread()) {
++        jas_cleanup_library();
++        jasperOk = false;
++        qDebug("Jasper thread initialization failed");
++    }
++#endif
+ }
+ 
+ Jpeg2000JasperReader::~Jpeg2000JasperReader()
+ {
++#if JAS_VERSION_MAJOR < 3
+     if (jasperOk)
+         jas_cleanup();
++#else
++    if (jasperOk) {
++        if (jas_cleanup_thread()) {
++            qDebug("Jasper thread cleanup failed");
++        }
++        if (jas_cleanup_library()) {
++            qDebug("Jasper library cleanup failed");
++        }
++    }
++#endif
+ }
+ 
+ /*! \internal
+@@ -857,7 +888,7 @@ bool Jpeg2000JasperReader::write(const QImage &image, int quality)
+     }
+ 
+     // Open an empty jasper stream that grows automatically
+-    jas_stream_t * memory_stream = jas_stream_memopen(0, -1);
++    jas_stream_t * memory_stream = jas_stream_memopen(0, 0);
+ 
+     // Jasper wants a non-const string.
+     char *str = qstrdup(jasperFormatString.toLatin1().constData());
+diff --git a/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp b/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
+index 1386750..ac8956c 100644
+--- a/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
+@@ -361,6 +361,8 @@ bool QTiffHandler::read(QImage *image)
+     }
+ 
+     TIFF *const tiff = d->tiff;
++    if (TIFFIsTiled(tiff) && TIFFTileSize64(tiff) > uint64_t(image->sizeInBytes())) // Corrupt image
++        return false;
+     const quint32 width = d->size.width();
+     const quint32 height = d->size.height();
+ 
+diff --git a/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp b/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
+index 82d38cb..d02eb05 100644
+--- a/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
+@@ -45,6 +45,7 @@
+ #include <qdebug.h>
+ #include <qpainter.h>
+ #include <qvariant.h>
++#include <QtEndian>
+ 
+ static const int riffHeaderSize = 12; // RIFF_HEADER_SIZE from webp/format_constants.h
+ 
+@@ -102,21 +103,23 @@ bool QWebpHandler::ensureScanned() const
+ 
+     m_scanState = ScanError;
+ 
+-    if (device()->isSequential()) {
+-        qWarning() << "Sequential devices are not supported";
++    QWebpHandler *that = const_cast<QWebpHandler *>(this);
++    const int headerBytesNeeded = sizeof(WebPBitstreamFeatures);
++    QByteArray header = device()->peek(headerBytesNeeded);
++    if (header.size() < headerBytesNeeded)
+         return false;
+-    }
+ 
+-    qint64 oldPos = device()->pos();
+-    device()->seek(0);
+-
+-    QWebpHandler *that = const_cast<QWebpHandler *>(this);
+-    QByteArray header = device()->peek(sizeof(WebPBitstreamFeatures));
++    // We do no random access during decoding, just a readAll() of the whole image file. So if
++    // if it is all available already, we can accept a sequential device. The riff header contains
++    // the file size minus 8 bytes header
++    qint64 byteSize = qFromLittleEndian<quint32>(header.constData() + 4);
++    if (device()->isSequential() && device()->bytesAvailable() < byteSize + 8) {
++        qWarning() << "QWebpHandler: Insufficient data available in sequential device";
++        return false;
++    }
+     if (WebPGetFeatures((const uint8_t*)header.constData(), header.size(), &(that->m_features)) == VP8_STATUS_OK) {
+         if (m_features.has_animation) {
+             // For animation, we have to read and scan whole file to determine loop count and images count
+-            device()->seek(oldPos);
+-
+             if (that->ensureDemuxer()) {
+                 that->m_loop = WebPDemuxGetI(m_demuxer, WEBP_FF_LOOP_COUNT);
+                 that->m_frameCount = WebPDemuxGetI(m_demuxer, WEBP_FF_FRAME_COUNT);
+@@ -126,17 +129,13 @@ bool QWebpHandler::ensureScanned() const
+                 if (that->m_features.has_alpha)
+                     that->m_composited->fill(Qt::transparent);
+ 
+-                // We do not reset device position since we have read in all data
+                 m_scanState = ScanSuccess;
+-                return true;
+             }
+         } else {
+             m_scanState = ScanSuccess;
+         }
+     }
+ 
+-    device()->seek(oldPos);
+-
+     return m_scanState == ScanSuccess;
+ }
+ 
+@@ -159,7 +158,7 @@ bool QWebpHandler::ensureDemuxer()
+ 
+ bool QWebpHandler::read(QImage *image)
+ {
+-    if (!ensureScanned() || device()->isSequential() || !ensureDemuxer())
++    if (!ensureScanned() || !ensureDemuxer())
+         return false;
+ 
+     QRect prevFrameRect;
+Submodule qtlocation 98a5c511..f991e28c:
+diff --git a/qtlocation/src/location/configure.json b/qtlocation/src/location/configure.json
+index 6d01a9a3..d1e623a1 100644
+--- a/qtlocation/src/location/configure.json
++++ b/qtlocation/src/location/configure.json
+@@ -9,7 +9,7 @@
+             "label": "Qt.labs.location experimental QML plugin",
+             "purpose": "Provides experimental QtLocation QML types",
+             "section": "Location",
+-            "condition": "config.opengl",
++            "condition": "features.opengl",
+             "output": [ "privateFeature" ]
+         },
+         "geoservices_osm": {
+diff --git a/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp b/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
+index a978573d..11e1466f 100644
+--- a/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
++++ b/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
+@@ -158,7 +158,7 @@ void QGeoMapObjectQSGSupport::updateMapObjects(QSGNode *root, QQuickWindow *wind
+     if (!root)
+         return;
+ 
+-    if (m_mapObjectsRootNode && m_mapObjectsRootNode->parent())
++    if (m_mapObjectsRootNode && !m_mapObjectsRootNode->parent())
+         root->appendChildNode(m_mapObjectsRootNode.get());
+ 
+     if (!m_mapObjectsRootNode) {
+diff --git a/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
+index 5a40467e..d123c6a8 100644
+--- a/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
+@@ -59,8 +59,10 @@ QT_BEGIN_NAMESPACE
+ static const QString kPrefixEsri(QStringLiteral("esri."));
+ static const QString kParamUserAgent(kPrefixEsri + QStringLiteral("useragent"));
+ 
+-static const QString kUrlGeocode(QStringLiteral("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates"));
+-static const QString kUrlReverseGeocode(QStringLiteral("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode"));
++static const QString kUrlGeocode(QStringLiteral("https://geocode.arcgis.com/arcgis/rest/services/"
++                                                "World/GeocodeServer/findAddressCandidates"));
++static const QString kUrlReverseGeocode(QStringLiteral(
++        "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode"));
+ 
+ static QString addressToQuery(const QGeoAddress &address)
+ {
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
+index 17492d94..96c12b1b 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
+@@ -46,7 +46,8 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-// JSON reference: http://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
++// JSON reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
+ 
+ static const QString kErrorMessage(QStringLiteral("Error %1: %2."));
+ static const QString kErrorJson(QStringLiteral("Error: invalide JSON document."));
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
+index 8cadfb29..92b6bb13 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
+@@ -44,7 +44,8 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-// JSON reference: http://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
++// JSON reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
+ 
+ GeoRouteReplyEsri::GeoRouteReplyEsri(QNetworkReply *reply, const QGeoRouteRequest &request,
+                                      QObject *parent) :
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
+index 0e6bc2c7..ed613f4b 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
+@@ -48,7 +48,8 @@ static const QString kPrefixEsri(QStringLiteral("esri."));
+ static const QString kParamUserAgent(kPrefixEsri + QStringLiteral("useragent"));
+ static const QString kParamToken(kPrefixEsri + QStringLiteral("token"));
+ 
+-static const QString kUrlRouting(QStringLiteral("http://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve"));
++static const QString kUrlRouting(QStringLiteral(
++        "https://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve"));
+ 
+ GeoRoutingManagerEngineEsri::GeoRoutingManagerEngineEsri(const QVariantMap &parameters,
+                                                          QGeoServiceProvider::Error *error,
+@@ -70,7 +71,8 @@ GeoRoutingManagerEngineEsri::~GeoRoutingManagerEngineEsri()
+ {
+ }
+ 
+-// REST reference: http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
++// REST reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
+ 
+ QGeoRouteReply *GeoRoutingManagerEngineEsri::calculateRoute(const QGeoRouteRequest &request)
+ {
+@@ -125,7 +127,7 @@ void GeoRoutingManagerEngineEsri::replyError(QGeoRouteReply::Error errorCode, co
+ QString GeoRoutingManagerEngineEsri::preferedDirectionLangage()
+ {
+     // list of supported langages is defined in:
+-    // http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
++    // https://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
+     const QStringList supportedLanguages = {
+         "ar", // Generate directions in Arabic
+         "cs", // Generate directions in Czech
+diff --git a/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
+index 5d15835d..24148f95 100644
+--- a/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
+@@ -230,7 +230,8 @@ QGeoMap *GeoTiledMappingManagerEngineEsri::createMap()
+ // ${y} = Y
+ // ${token} = Token
+ 
+-// template = 'http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{{z}}/{{y}}/{{x}}.png'
++// template =
++// 'https://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{{z}}/{{y}}/{{x}}.png'
+ 
+ bool GeoTiledMappingManagerEngineEsri::initializeMapSources(QGeoServiceProvider::Error *error,
+                                                             QString *errorString,
+diff --git a/qtlocation/src/plugins/geoservices/esri/maps.json b/qtlocation/src/plugins/geoservices/esri/maps.json
+index 8167ae7d..862e087d 100644
+--- a/qtlocation/src/plugins/geoservices/esri/maps.json
++++ b/qtlocation/src/plugins/geoservices/esri/maps.json
+@@ -6,8 +6,8 @@
+             "description": "ArcGIS Online World Street Map",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=3b93337983e9436f8db950e38a8629af'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=3b93337983e9436f8db950e38a8629af'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -16,8 +16,8 @@
+             "": "ArcGIS Online World Imagery",
+             "mobile": true,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -26,8 +26,8 @@
+             "description": "ArcGIS Online World Terrain Base",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=c61ad8ab017d49e1a82f580ee1298931'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=c61ad8ab017d49e1a82f580ee1298931'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -36,8 +36,8 @@
+             "description": "ArcGIS Online World Topography",
+             "mobile": true,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=30e5fe3149c34df1ba922e6f5bbf808f'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=30e5fe3149c34df1ba922e6f5bbf808f'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -46,8 +46,8 @@
+             "description": "This map presents land cover and detailed topographic maps for the United States.",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=99cd5fbd98934028802b4f797c4b1732'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=99cd5fbd98934028802b4f797c4b1732'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -56,8 +56,8 @@
+             "description": "National Geographic World Map",
+             "mobile": false,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=b9b1b422198944fbbd5250b3241691b6'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=b9b1b422198944fbbd5250b3241691b6'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -66,8 +66,8 @@
+             "description": "Thematic content providing a neutral background with minimal colors",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=ed712cb1db3e4bae9e85329040fb9a49'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=ed712cb1db3e4bae9e85329040fb9a49'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -76,8 +76,8 @@
+             "description": "Natural Earth physical map for the world",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=c4ec722a1cd34cf0a23904aadf8923a0'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=c4ec722a1cd34cf0a23904aadf8923a0'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -86,8 +86,8 @@
+             "description": "Portrays surface elevation as shaded relief",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=9c5370d0b54f4de1b48a3792d7377ff2'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=9c5370d0b54f4de1b48a3792d7377ff2'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -96,8 +96,8 @@
+             "description": "This map is designed to be used as a basemap by marine GIS professionals and as a reference map by anyone interested in ocean data",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=1e126e7520f9466c9ca28b8f28b5e500'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=1e126e7520f9466c9ca28b8f28b5e500'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -106,8 +106,8 @@
+             "description": "Thematic content providing a neutral background with minimal colors",
+             "mobile": false,
+             "night": true,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=a284a9b99b3446a3910d4144a50990f6'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=a284a9b99b3446a3910d4144a50990f6'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -116,8 +116,8 @@
+             "description": "DeLorme’s topographic basemap is a seamless global data set that portrays transportation, hydrography, jurisdiction boundaries, and major geographic features",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/Specialty/DeLorme_World_Base_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=b165c3df453e4be6b5ac4fdb241effbe'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/Specialty/DeLorme_World_Base_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=b165c3df453e4be6b5ac4fdb241effbe'>Esri</a> contributors"
+         }
+     ]
+ }
+diff --git a/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
+index 3858ddf5..af66f28e 100644
+--- a/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
+@@ -63,8 +63,10 @@ static const QString kCountriesKey(QStringLiteral("detailedCountries"));
+ static const QString kLocalizedNamesKey(QStringLiteral("localizedNames"));
+ static const QString kMaxLocationsKey(QStringLiteral("maxLocations"));
+ 
+-static const QUrl kUrlGeocodeServer("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer?f=pjson");
+-static const QUrl kUrlFindAddressCandidates("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates");
++static const QUrl kUrlGeocodeServer(
++        "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer?f=pjson");
++static const QUrl kUrlFindAddressCandidates("https://geocode.arcgis.com/arcgis/rest/services/World/"
++                                            "GeocodeServer/findAddressCandidates");
+ 
+ PlaceManagerEngineEsri::PlaceManagerEngineEsri(const QVariantMap &parameters, QGeoServiceProvider::Error *error,
+                                                QString *errorString) :
+Submodule qtmultimedia f0344079..0d7cc33a:
+diff --git a/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp b/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
+index 2b5325132..b68b4af1b 100644
+--- a/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
++++ b/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
+@@ -402,6 +402,8 @@ int QPulseAudioInput::bytesReady() const
+ 
+ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ {
++    Q_ASSERT(data != nullptr || len == 0);
++
+     m_bytesAvailable = checkBytesReady();
+ 
+     setError(QAudio::NoError);
+@@ -411,7 +413,8 @@ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ 
+     if (!m_pullMode && !m_tempBuffer.isEmpty()) {
+         readBytes = qMin(static_cast<int>(len), m_tempBuffer.size());
+-        memcpy(data, m_tempBuffer.constData(), readBytes);
++        if (readBytes)
++            memcpy(data, m_tempBuffer.constData(), readBytes);
+         m_totalTimeValue += readBytes;
+ 
+         if (readBytes < m_tempBuffer.size()) {
+@@ -502,9 +505,10 @@ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ 
+ void QPulseAudioInput::applyVolume(const void *src, void *dest, int len)
+ {
++    Q_ASSERT((src && dest) || len == 0);
+     if (m_volume < 1.f)
+         QAudioHelperInternal::qMultiplySamples(m_volume, m_format, src, dest, len);
+-    else
++    else if (len)
+         memcpy(dest, src, len);
+ }
+ 
+Submodule qtpim 02efef5e...f9a8f0fc (commits not present)
+Submodule qtquick3d b85cf622..47defc8b:
+diff --git a/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro b/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
+index ca5c499e..174a075b 100644
+--- a/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
++++ b/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
+@@ -10,7 +10,7 @@ QT_FOR_CONFIG += assetimporters-private
+ include($$OUT_PWD/../qtassetimporters-config.pri)
+ 
+ qtConfig(system-assimp):!if(cross_compile:host_build) {
+-    QMAKE_USE_PRIVATE += assimp
++    QMAKE_USE_PRIVATE += quick3d-assimp
+ } else {
+     include(../../../3rdparty/assimp/assimp.pri)
+ }
+Submodule qtquickcontrols2 3a657dc0..56ce8233:
+diff --git a/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp b/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
+index e5fe734f7..e36922775 100644
+--- a/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
++++ b/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
+@@ -38,6 +38,7 @@
+ #include "qwidgetplatformmenuitem_p.h"
+ 
+ #include <QtGui/qwindow.h>
++#include <QtGui/private/qhighdpiscaling_p.h>
+ #include <QtWidgets/qmenu.h>
+ #include <QtWidgets/qaction.h>
+ 
+@@ -145,7 +146,7 @@ void QWidgetPlatformMenu::showPopup(const QWindow *window, const QRect &targetRe
+ 
+     QPoint targetPos = targetRect.bottomLeft();
+     if (window)
+-        targetPos = window->mapToGlobal(targetPos);
++        targetPos = window->mapToGlobal(QHighDpi::fromNativeLocalPosition(targetPos, window));
+ 
+     const QWidgetPlatformMenuItem *widgetItem = qobject_cast<const QWidgetPlatformMenuItem *>(item);
+     m_menu->popup(targetPos, widgetItem ? widgetItem->action() : nullptr);
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
+index 950e4e099..b81fbea0b 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
+@@ -387,6 +387,17 @@ void QQuickAbstractButtonPrivate::itemImplicitHeightChanged(QQuickItem *item)
+         emit q->implicitIndicatorHeightChanged();
+ }
+ 
++void QQuickAbstractButtonPrivate::itemDestroyed(QQuickItem *item)
++{
++    Q_Q(QQuickAbstractButton);
++    QQuickControlPrivate::itemDestroyed(item);
++    if (item == indicator) {
++        indicator = nullptr;
++        emit q->implicitIndicatorWidthChanged();
++        emit q->implicitIndicatorHeightChanged();
++    }
++}
++
+ QQuickAbstractButton *QQuickAbstractButtonPrivate::findCheckedButton() const
+ {
+     Q_Q(const QQuickAbstractButton);
+@@ -1176,6 +1187,12 @@ QAccessible::Role QQuickAbstractButton::accessibleRole() const
+     }
+     return QAccessible::Button;
+ }
++
++void QQuickAbstractButton::accessiblePressAction()
++{
++    Q_D(QQuickAbstractButton);
++    d->trigger();
++}
+ #endif
+ 
+ QT_END_NAMESPACE
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
+index 0fa48980e..ab66220d0 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
+@@ -209,6 +209,7 @@ protected:
+ #if QT_CONFIG(accessibility)
+     void accessibilityActiveChanged(bool active) override;
+     QAccessible::Role accessibleRole() const override;
++    Q_INVOKABLE void accessiblePressAction();
+ #endif
+ 
+ private:
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
+index 9291c1a87..b729720f2 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
+@@ -109,6 +109,7 @@ public:
+ 
+     void itemImplicitWidthChanged(QQuickItem *item) override;
+     void itemImplicitHeightChanged(QQuickItem *item) override;
++    void itemDestroyed(QQuickItem *item) override;
+ 
+     // copied from qabstractbutton.cpp
+     static const int AUTO_REPEAT_DELAY = 300;
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp b/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
+index 2041e7741..8610cdfae 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
+@@ -145,7 +145,7 @@ int QQuickActionPrivate::ShortcutEntry::shortcutId() const
+ 
+ void QQuickActionPrivate::ShortcutEntry::grab(const QKeySequence &shortcut, bool enabled)
+ {
+-    if (shortcut.isEmpty())
++    if (shortcut.isEmpty() || m_shortcutId)
+         return;
+ 
+     Qt::ShortcutContext context = Qt::WindowShortcut; // TODO
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp b/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
+index f38c2b09c..6eed2a024 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
+@@ -225,6 +225,7 @@ void QQuickContainerPrivate::cleanup()
+     QObject::disconnect(contentModel, &QQmlObjectModel::countChanged, q, &QQuickContainer::countChanged);
+     QObject::disconnect(contentModel, &QQmlObjectModel::childrenChanged, q, &QQuickContainer::contentChildrenChanged);
+     delete contentModel;
++    contentModel = nullptr;
+ }
+ 
+ QQuickItem *QQuickContainerPrivate::itemAt(int index) const
+@@ -436,7 +437,7 @@ void QQuickContainerPrivate::contentChildren_clear(QQmlListProperty<QQuickItem>
+ void QQuickContainerPrivate::updateContentWidth()
+ {
+     Q_Q(QQuickContainer);
+-    if (hasContentWidth || qFuzzyCompare(contentWidth, implicitContentWidth))
++    if (hasContentWidth || qFuzzyCompare(contentWidth, implicitContentWidth) || !contentModel)
+         return;
+ 
+     contentWidth = implicitContentWidth;
+@@ -446,7 +447,7 @@ void QQuickContainerPrivate::updateContentWidth()
+ void QQuickContainerPrivate::updateContentHeight()
+ {
+     Q_Q(QQuickContainer);
+-    if (hasContentHeight || qFuzzyCompare(contentHeight, implicitContentHeight))
++    if (hasContentHeight || qFuzzyCompare(contentHeight, implicitContentHeight) || !contentModel)
+         return;
+ 
+     contentHeight = implicitContentHeight;
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp b/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
+index bbbd0e622..1f4b47343 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
+@@ -845,6 +845,13 @@ void QQuickControlPrivate::executeBackground(bool complete)
+         quickCompleteDeferred(q, backgroundName(), background);
+ }
+ 
++/*
++    \internal
++
++    Hides an item that was replaced by a newer one, rather than
++    deleting it, as the item is typically created in QML and hence
++    we don't own it.
++*/
+ void QQuickControlPrivate::hideOldItem(QQuickItem *item)
+ {
+     if (!item)
+@@ -863,6 +870,29 @@ void QQuickControlPrivate::hideOldItem(QQuickItem *item)
+ #endif
+ }
+ 
++/*
++    \internal
++
++    Named "unhide" because it's used for cases where an item
++    that was previously hidden by \l hideOldItem() wants to be
++    shown by a control again, such as a ScrollBar in ScrollView.
++*/
++void QQuickControlPrivate::unhideOldItem(QQuickControl *control, QQuickItem *item)
++{
++    Q_ASSERT(item);
++    qCDebug(lcItemManagement) << "unhiding old item" << item;
++
++    item->setVisible(true);
++    item->setParentItem(control);
++
++#if QT_CONFIG(accessibility)
++    // Add the item back in to the accessibility tree.
++    QQuickAccessibleAttached *accessible = accessibleAttached(item);
++    if (accessible)
++        accessible->setIgnored(false);
++#endif
++}
++
+ void QQuickControlPrivate::updateBaselineOffset()
+ {
+     Q_Q(QQuickControl);
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h b/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
+index 8e979079e..a6e624c91 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
+@@ -173,6 +173,7 @@ public:
+     virtual void executeBackground(bool complete = false);
+ 
+     static void hideOldItem(QQuickItem *item);
++    static void unhideOldItem(QQuickControl *control, QQuickItem *item);
+ 
+     void updateBaselineOffset();
+ 
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp b/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
+index e6db14eb5..6197d1547 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
+@@ -237,7 +237,7 @@ static QRectF alignedRect(Qt::LayoutDirection direction, Qt::Alignment alignment
+ void QQuickDialogButtonBoxPrivate::resizeContent()
+ {
+     Q_Q(QQuickDialogButtonBox);
+-    if (!contentItem)
++    if (!contentItem || !contentModel)
+         return;
+ 
+     QRectF geometry = q->boundingRect().adjusted(q->leftPadding(), q->topPadding(), -q->rightPadding(), -q->bottomPadding());
+@@ -322,6 +322,9 @@ void QQuickDialogButtonBoxPrivate::updateLayout()
+ qreal QQuickDialogButtonBoxPrivate::getContentWidth() const
+ {
+     Q_Q(const QQuickDialogButtonBox);
++    if (!contentModel)
++        return 0;
++
+     const int count = contentModel->count();
+     const qreal totalSpacing = qMax(0, count - 1) * spacing;
+     qreal totalWidth = totalSpacing;
+@@ -341,6 +344,9 @@ qreal QQuickDialogButtonBoxPrivate::getContentWidth() const
+ qreal QQuickDialogButtonBoxPrivate::getContentHeight() const
+ {
+     Q_Q(const QQuickDialogButtonBox);
++    if (!contentModel)
++        return 0;
++
+     const int count = contentModel->count();
+     qreal maxHeight = 0;
+     for (int i = 0; i < count; ++i) {
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp b/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
+index 91bd59184..0ce518f84 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
+@@ -399,8 +399,11 @@ void QQuickOverlay::itemChange(ItemChange change, const ItemChangeData &data)
+     Q_D(QQuickOverlay);
+     QQuickItem::itemChange(change, data);
+ 
+-    if (change == ItemChildAddedChange || change == ItemChildRemovedChange)
++    if (change == ItemChildAddedChange || change == ItemChildRemovedChange) {
+         setVisible(!d->allDrawers.isEmpty() || !childItems().isEmpty());
++        if (data.item->parent() == d->mouseGrabberPopup)
++            d->setMouseGrabberPopup(nullptr);
++    }
+ }
+ 
+ void QQuickOverlay::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp b/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
+index 4e2f509db..1c4b308cd 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
+@@ -797,6 +797,14 @@ void QQuickScrollBarAttachedPrivate::initHorizontal()
+     if (parent && parent == flickable->parentItem())
+         horizontal->stackAfter(flickable);
+ 
++    // If a scroll bar was previously hidden (due to e.g. setting a new contentItem
++    // on a ScrollView), we need to make sure that we un-hide it.
++    // We don't bother checking if the item is actually the old one, because
++    // if it's not, all of the things the function does (setting parent, visibility, etc.)
++    // should be no-ops anyway.
++    if (auto control = qobject_cast<QQuickControl*>(q_ptr->parent()))
++        QQuickControlPrivate::unhideOldItem(control, horizontal);
++
+     layoutHorizontal();
+     horizontal->setSize(area->property("widthRatio").toReal());
+     horizontal->setPosition(area->property("xPosition").toReal());
+@@ -818,6 +826,9 @@ void QQuickScrollBarAttachedPrivate::initVertical()
+     if (parent && parent == flickable->parentItem())
+         vertical->stackAfter(flickable);
+ 
++    if (auto control = qobject_cast<QQuickControl*>(q_ptr->parent()))
++        QQuickControlPrivate::unhideOldItem(control, vertical);
++
+     layoutVertical();
+     vertical->setSize(area->property("heightRatio").toReal());
+     vertical->setPosition(area->property("yPosition").toReal());
+diff --git a/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml b/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
+index 0e8b08352..cd4931184 100644
+--- a/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
++++ b/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
+@@ -576,4 +576,51 @@ TestCase {
+         verify(newHorizontalScrollBar.visible)
+         verify(!oldHorizontalScrollBar.visible)
+     }
++
++    Component {
++        id: bindingToContentItemAndStandaloneFlickable
++
++        Item {
++            width: 200
++            height: 200
++
++            property alias scrollView: scrollView
++
++            ScrollView {
++                id: scrollView
++                anchors.fill: parent
++                contentItem: listView
++
++                property Item someBinding: contentItem
++            }
++            ListView {
++                id: listView
++                model: 10
++                delegate: ItemDelegate {
++                    text: modelData
++                    width: listView.width
++                }
++            }
++        }
++    }
++
++    // Tests that scroll bars show up for a ScrollView where
++    // - its contentItem is declared as a standalone, separate item
++    // - there is a binding to contentItem (which causes a default Flickable to be created)
++    function test_bindingToContentItemAndStandaloneFlickable() {
++        let root = createTemporaryObject(bindingToContentItemAndStandaloneFlickable, testCase)
++        verify(root)
++
++        let control = root.scrollView
++        let verticalScrollBar = control.ScrollBar.vertical
++        let horizontalScrollBar = control.ScrollBar.horizontal
++        compare(verticalScrollBar.parent, control)
++        compare(horizontalScrollBar.parent, control)
++        verify(verticalScrollBar.visible)
++        verify(horizontalScrollBar.visible)
++
++        mouseDrag(verticalScrollBar, verticalScrollBar.width / 2, verticalScrollBar.height / 2, 0, 50)
++        verify(verticalScrollBar.active)
++        verify(horizontalScrollBar.active)
++    }
+ }
+diff --git a/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml b/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
+index b3fab41ca..10b6baa02 100644
+--- a/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
++++ b/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
+@@ -608,4 +608,27 @@ TestCase {
+         mouseClick(control.indicator)
+         verify(control.activeFocus)
+     }
++
++    Component {
++        id: deletionOrder1
++        Item {
++            Image { id: innerImage }
++            Switch { indicator: innerImage }
++        }
++    }
++
++    Component {
++        id: deletionOrder2
++        Item {
++            Switch { indicator: innerImage }
++            Image { id: innerImage }
++        }
++    }
++
++    function test_deletionOrder() {
++        var control1 = createTemporaryObject(deletionOrder1, testCase)
++        verify(control1)
++        var control2 = createTemporaryObject(deletionOrder2, testCase)
++        verify(control2)
++    }
+ }
+diff --git a/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml b/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml
+new file mode 100644
+index 000000000..9e4598b9f
+--- /dev/null
++++ b/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml
+@@ -0,0 +1,78 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the test suite of the Qt Toolkit.
++**
++** $QT_BEGIN_LICENSE:BSD$
++** Commercial License Usage
++** Licensees holding valid commercial Qt licenses may use this file in
++** accordance with the commercial license agreement provided with the
++** Software or, alternatively, in accordance with the terms contained in
++** a written agreement between you and The Qt Company. For licensing terms
++** and conditions see https://www.qt.io/terms-conditions. For further
++** information use the contact form at https://www.qt.io/contact-us.
++**
++** BSD License Usage
++** Alternatively, you may use this file under the terms of the BSD license
++** as follows:
++**
++** "Redistribution and use in source and binary forms, with or without
++** modification, are permitted provided that the following conditions are
++** met:
++**   * Redistributions of source code must retain the above copyright
++**     notice, this list of conditions and the following disclaimer.
++**   * Redistributions in binary form must reproduce the above copyright
++**     notice, this list of conditions and the following disclaimer in
++**     the documentation and/or other materials provided with the
++**     distribution.
++**   * Neither the name of The Qt Company Ltd nor the names of its
++**     contributors may be used to endorse or promote products derived
++**     from this software without specific prior written permission.
++**
++**
++** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
++** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
++** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
++** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
++** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
++** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
++** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
++** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
++** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
++** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
++** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
++**
++** $QT_END_LICENSE$
++**
++****************************************************************************/
++
++import QtQuick 2.15
++import QtQuick.Controls 2.15
++
++ApplicationWindow {
++    id: window
++    width: 400
++    height: 400
++    title: "releaseAfterExitTransition"
++
++    property alias popup: popup
++    property alias modalPopup: modalPopup
++
++    Popup {
++        id: popup
++        y: parent.height - height
++        width: 50
++        height: 50
++    }
++
++    Popup {
++        id: modalPopup
++        modal: true
++        y: parent.height - height
++        width: 50
++        height: 50
++        exit:  Transition { PauseAnimation { duration: 100 } }
++    }
++}
+diff --git a/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp b/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
+index 54952d128..3d50e2dd4 100644
+--- a/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
++++ b/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
+@@ -100,6 +100,7 @@ private slots:
+     void invisibleToolTipOpen();
+     void centerInOverlayWithinStackViewItem();
+     void destroyDuringExitTransition();
++    void releaseAfterExitTransition();
+ };
+ 
+ void tst_QQuickPopup::initTestCase()
+@@ -1575,6 +1576,34 @@ void tst_QQuickPopup::destroyDuringExitTransition()
+     QVERIFY(!button->isDown());
+ }
+ 
++void tst_QQuickPopup::releaseAfterExitTransition()
++{
++    QQuickApplicationHelper helper(this, "releaseAfterExitTransition.qml");
++    QVERIFY2(helper.ready, helper.failureMessage());
++
++    QQuickWindow *window = helper.window;
++    window->show();
++    QVERIFY(QTest::qWaitForWindowActive(window));
++
++    QQuickOverlay *overlay = QQuickOverlay::overlay(window);
++    QQuickPopup *modalPopup = window->property("modalPopup").value<QQuickPopup *>();
++    QQuickPopup *popup = window->property("popup").value<QQuickPopup *>();
++
++    modalPopup->open();
++    QTRY_VERIFY(modalPopup->isOpened());
++
++    QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++    // wait until the transition is finished and the overlay hides itself
++    QTRY_VERIFY(!overlay->isVisible());
++    QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++
++    popup->open();
++    QTRY_VERIFY(popup->isOpened());
++    QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++    QTRY_VERIFY(!popup->isOpened());
++}
++
++
+ QTEST_QUICKCONTROLS_MAIN(tst_QQuickPopup)
+ 
+ #include "tst_qquickpopup.moc"
+Submodule qtscript 5be95f96...4d8e4bd2 (commits not present)
+Submodule qtspeech 17fc9fde..255845e2:
+diff --git a/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp b/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
+index 6eb74b8..bcc7dd1 100644
+--- a/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
++++ b/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
+@@ -357,7 +357,9 @@ QVector<QLocale> QTextToSpeechEngineSpeechd::availableLocales() const
+ 
+ QVector<QVoice> QTextToSpeechEngineSpeechd::availableVoices() const
+ {
+-    return m_voices.values(m_currentLocale.name()).toVector();
++    QList<QVoice> resultList = m_voices.values(m_currentLocale.name());
++    std::reverse(resultList.begin(), resultList.end());
++    return resultList.toVector();
+ }
+ 
+ // We have no way of knowing our own client_id since speech-dispatcher seems to be incomplete
+Submodule qtsvg 0c05780e..a7a0f249:
+diff --git a/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp b/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
+index 561e77e..12e0574 100644
+--- a/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
++++ b/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
+@@ -191,6 +191,8 @@ bool QSvgIOHandler::read(QImage *image)
+             }
+         }
+         if (!finalSize.isEmpty()) {
++            if (qMax(finalSize.width(), finalSize.height()) > 0xffff)
++                return false; // Assume corrupted file
+             image->fill(d->backColor.rgba());
+             QPainter p(image);
+             d->r.render(&p, bounds);
+diff --git a/qtsvg/src/svg/qsvghandler.cpp b/qtsvg/src/svg/qsvghandler.cpp
+index a5f877f..8dda563 100644
+--- a/qtsvg/src/svg/qsvghandler.cpp
++++ b/qtsvg/src/svg/qsvghandler.cpp
+@@ -1393,9 +1393,10 @@ static void parseFont(QSvgNode *node,
+         case FontSizeNone:
+             break;
+         case FontSizeValue: {
+-            QSvgHandler::LengthType dummy; // should always be pixel size
+-            fontStyle->setSize(qMin(parseLength(attributes.fontSize, dummy, handler),
+-                                    qreal(0xffff)));
++            QSvgHandler::LengthType type;
++            qreal fs = parseLength(attributes.fontSize, type, handler);
++            fs = convertToPixels(fs, true, type);
++            fontStyle->setSize(qMin(fs, qreal(0xffff)));
+         }
+             break;
+         default:
+@@ -2513,6 +2514,8 @@ static bool parseAnimateTransformNode(QSvgNode *parent,
+             ++s;
+         }
+     }
++    if (vals.count() % 3 != 0)
++        return false;
+ 
+     bool ok = true;
+     int begin = parseClockValue(beginStr, &ok);
+@@ -2576,6 +2579,8 @@ static QSvgNode *createCircleNode(QSvgNode *parent,
+     qreal ncx = toDouble(cx);
+     qreal ncy = toDouble(cy);
+     qreal nr  = toDouble(r);
++    if (nr < 0.0)
++        return nullptr;
+ 
+     QRectF rect(ncx-nr, ncy-nr, nr*2, nr*2);
+     QSvgNode *circle = new QSvgCircle(parent, rect);
+@@ -3046,15 +3051,16 @@ static QSvgStyleProperty *createRadialGradientNode(QSvgNode *node,
+ 
+     qreal ncx = 0.5;
+     qreal ncy = 0.5;
+-    qreal nr  = 0.5;
+     if (!cx.isEmpty())
+         ncx = toDouble(cx);
+     if (!cy.isEmpty())
+         ncy = toDouble(cy);
++
++    qreal nr = 0.0;
+     if (!r.isEmpty())
+         nr = toDouble(r);
+-    if (nr < 0.5)
+-        nr = 0.5;
++    if (nr <= 0.0)
++        return nullptr;
+ 
+     qreal nfx = ncx;
+     if (!fx.isEmpty())
+@@ -3350,7 +3356,9 @@ static QSvgNode *createTextNode(QSvgNode *parent,
+     //### editable and rotate not handled
+     QSvgHandler::LengthType type;
+     qreal nx = parseLength(x, type, handler);
++    nx = convertToPixels(nx, true, type);
+     qreal ny = parseLength(y, type, handler);
++    ny = convertToPixels(ny, true, type);
+ 
+     QSvgNode *text = new QSvgText(parent, QPointF(nx, ny));
+     return text;
+@@ -3691,9 +3699,7 @@ void QSvgHandler::parse()
+         case QXmlStreamReader::EndElement:
+             endElement(xml->name());
+             ++remainingUnfinishedElements;
+-            // if we are using somebody else's qxmlstreamreader
+-            // we should not read until the end of the stream
+-            done = !m_ownsReader && (xml->name() == QLatin1String("svg"));
++            done = (xml->name() == QLatin1String("svg"));
+             break;
+         case QXmlStreamReader::Characters:
+             characters(xml->text());
+diff --git a/qtsvg/src/svg/qsvgstructure.cpp b/qtsvg/src/svg/qsvgstructure.cpp
+index b89608b..89c9e4e 100644
+--- a/qtsvg/src/svg/qsvgstructure.cpp
++++ b/qtsvg/src/svg/qsvgstructure.cpp
+@@ -255,9 +255,13 @@ inline static bool isSupportedSvgFeature(const QString &str)
+     };
+ 
+     if (str.length() <= MAX_WORD_LENGTH && str.length() >= MIN_WORD_LENGTH) {
++        const char16_t unicode44 = str.at(44).unicode();
++        const char16_t unicode45 = str.at(45).unicode();
++        if (unicode44 >= sizeof(asso_values) || unicode45 >= sizeof(asso_values))
++            return false;
+         const int key = str.length()
+-                        + asso_values[str.at(45).unicode()]
+-                        + asso_values[str.at(44).unicode()];
++                        + asso_values[unicode45]
++                        + asso_values[unicode44];
+         if (key <= MAX_HASH_VALUE && key >= 0)
+             return str == QLatin1String(wordlist[key]);
+     }
+diff --git a/qtsvg/src/svg/qsvgtinydocument.cpp b/qtsvg/src/svg/qsvgtinydocument.cpp
+index 63d0797..19e7154 100644
+--- a/qtsvg/src/svg/qsvgtinydocument.cpp
++++ b/qtsvg/src/svg/qsvgtinydocument.cpp
+@@ -433,8 +433,16 @@ void QSvgTinyDocument::draw(QPainter *p, QSvgExtraStates &)
+     draw(p);
+ }
+ 
++static bool isValidMatrix(const QTransform &transform)
++{
++    qreal determinant = transform.determinant();
++    return qIsFinite(determinant);
++}
++
+ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect, const QRectF &sourceRect)
+ {
++    QTransform oldTransform = p->worldTransform();
++
+     QRectF target = targetRect;
+     if (target.isEmpty()) {
+         QPaintDevice *dev = p->device();
+@@ -487,6 +495,9 @@ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect,
+         }
+ #endif
+     }
++
++    if (!isValidMatrix(p->worldTransform()))
++        p->setWorldTransform(oldTransform);
+ }
+ 
+ QRectF QSvgTinyDocument::boundsOnElement(const QString &id) const
+diff --git a/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp b/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
+index 36c76ec..db71e02 100644
+--- a/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
++++ b/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
+@@ -86,6 +86,8 @@ private slots:
+     void oss_fuzz_23731();
+     void oss_fuzz_24131();
+     void oss_fuzz_24738();
++    void illegalAnimateTransform_data();
++    void illegalAnimateTransform();
+ 
+ #ifndef QT_NO_COMPRESS
+     void testGzLoading();
+@@ -1646,5 +1648,22 @@ void tst_QSvgRenderer::oss_fuzz_24738()
+     QSvgRenderer().load(QByteArray("<svg><path d=\"a 2 1e-212.....\">"));
+ }
+ 
++void tst_QSvgRenderer::illegalAnimateTransform_data()
++{
++    QTest::addColumn<QByteArray>("svg");
++
++    QTest::newRow("case1") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" values=\"8,0,5,0\">");
++    QTest::newRow("case2") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" values=\"1,2\">");
++    QTest::newRow("case3") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" from=\".. 5 2\" to=\"f\">");
++    QTest::newRow("case4") << QByteArray("<svg><animateTransform type=\"scale\" begin=\"1\" dur=\"2\" by=\"--,..\">");
++}
++
++void tst_QSvgRenderer::illegalAnimateTransform()
++{
++    QFETCH(QByteArray, svg);
++    QSvgRenderer renderer;
++    QVERIFY(!renderer.load(svg)); // also shouldn't assert
++}
++
+ QTEST_MAIN(tst_QSvgRenderer)
+ #include "tst_qsvgrenderer.moc"
+Submodule qttools 6914f7c8..090e526e:
+diff --git a/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp b/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
+index feab1e2d5..cbfb82507 100644
+--- a/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
++++ b/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
+@@ -445,7 +445,9 @@ bool HelpGeneratorPrivate::insertFiles(const QStringList &files, const QString &
+     if (filterSetId < 0)
+         return false;
+     ++filterSetId;
+-    for (int attId : qAsConst(filterAtts)) {
++    QList<int> attValues = filterAtts.values();
++    std::sort(attValues.begin(), attValues.end());
++    for (int attId : qAsConst(attValues)) {
+         m_query->prepare(QLatin1String("INSERT INTO FileAttributeSetTable "
+             "VALUES(?, ?)"));
+         m_query->bindValue(0, filterSetId);
+Submodule qtwayland dfb0129c..2904e1b3:
+diff --git a/qtwayland/src/client/configure.json b/qtwayland/src/client/configure.json
+index 2f424580..29222357 100644
+--- a/qtwayland/src/client/configure.json
++++ b/qtwayland/src/client/configure.json
+@@ -149,8 +149,7 @@
+                     "#endif"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "vulkan-server-buffer": {
+             "label": "Vulkan Buffer Sharing",
+@@ -168,7 +167,8 @@
+                     "exportAllocInfo.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR;",
+                     "return 0;"
+                 ]
+-            }
++            },
++            "use": "wayland-client"
+         },
+         "egl_1_5-wayland": {
+             "label": "EGL 1.5 with Wayland Platform",
+@@ -183,7 +183,7 @@
+                     "eglGetPlatformDisplay(EGL_PLATFORM_WAYLAND_EXT, (struct wl_display *)(nullptr), nullptr);"
+                 ]
+             },
+-            "use": "egl"
++            "use": "egl wayland-client"
+         }
+     },
+ 
+diff --git a/qtwayland/src/client/global/qwaylandclientextension.cpp b/qtwayland/src/client/global/qwaylandclientextension.cpp
+index 125b1e19..edccfe63 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension.cpp
++++ b/qtwayland/src/client/global/qwaylandclientextension.cpp
+@@ -74,7 +74,10 @@ void QWaylandClientExtensionPrivate::handleRegistryGlobal(void *data, ::wl_regis
+ void QWaylandClientExtension::addRegistryListener()
+ {
+     Q_D(QWaylandClientExtension);
+-    d->waylandIntegration->display()->addRegistryListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++    if (!d->registered) {
++        d->waylandIntegration->display()->addRegistryListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++        d->registered = true;
++    }
+ }
+ 
+ QWaylandClientExtension::QWaylandClientExtension(const int ver)
+@@ -88,6 +91,13 @@ QWaylandClientExtension::QWaylandClientExtension(const int ver)
+     QMetaObject::invokeMethod(this, "addRegistryListener", Qt::QueuedConnection);
+ }
+ 
++QWaylandClientExtension::~QWaylandClientExtension()
++{
++    Q_D(QWaylandClientExtension);
++    if (d->registered && !QCoreApplication::closingDown())
++        d->waylandIntegration->display()->removeListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++}
++
+ QtWaylandClient::QWaylandIntegration *QWaylandClientExtension::integration() const
+ {
+     Q_D(const QWaylandClientExtension);
+diff --git a/qtwayland/src/client/global/qwaylandclientextension.h b/qtwayland/src/client/global/qwaylandclientextension.h
+index 98272e57..5bd28398 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension.h
++++ b/qtwayland/src/client/global/qwaylandclientextension.h
+@@ -63,6 +63,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandClientExtension : public QObject
+     Q_PROPERTY(bool active READ isActive NOTIFY activeChanged)
+ public:
+     QWaylandClientExtension(const int version);
++    ~QWaylandClientExtension();
+ 
+     QtWaylandClient::QWaylandIntegration *integration() const;
+     int version() const;
+diff --git a/qtwayland/src/client/global/qwaylandclientextension_p.h b/qtwayland/src/client/global/qwaylandclientextension_p.h
+index 69cc46a0..9091efbe 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension_p.h
++++ b/qtwayland/src/client/global/qwaylandclientextension_p.h
+@@ -68,6 +68,7 @@ public:
+     QtWaylandClient::QWaylandIntegration *waylandIntegration = nullptr;
+     int version = -1;
+     bool active = false;
++    bool registered = false;
+ };
+ 
+ class Q_WAYLAND_CLIENT_EXPORT QWaylandClientExtensionTemplatePrivate : public QWaylandClientExtensionPrivate
+diff --git a/qtwayland/src/client/qwaylanddatadevice.cpp b/qtwayland/src/client/qwaylanddatadevice.cpp
+index 7e2e3308..e3e60ed5 100644
+--- a/qtwayland/src/client/qwaylanddatadevice.cpp
++++ b/qtwayland/src/client/qwaylanddatadevice.cpp
+@@ -72,6 +72,8 @@ QWaylandDataDevice::QWaylandDataDevice(QWaylandDataDeviceManager *manager, QWayl
+ 
+ QWaylandDataDevice::~QWaylandDataDevice()
+ {
++    if (wl_data_device_get_version(object()) >= WL_DATA_DEVICE_RELEASE_SINCE_VERSION)
++        release();
+ }
+ 
+ QWaylandDataOffer *QWaylandDataDevice::selectionOffer() const
+@@ -110,7 +112,7 @@ QWaylandDataOffer *QWaylandDataDevice::dragOffer() const
+     return m_dragOffer.data();
+ }
+ 
+-bool QWaylandDataDevice::startDrag(QMimeData *mimeData, QWaylandWindow *icon)
++bool QWaylandDataDevice::startDrag(QMimeData *mimeData, Qt::DropActions supportedActions, QWaylandWindow *icon)
+ {
+     auto *seat = m_display->currentInputDevice();
+     auto *origin = seat->pointerFocus();
+@@ -123,7 +125,28 @@ bool QWaylandDataDevice::startDrag(QMimeData *mimeData, QWaylandWindow *icon)
+     }
+ 
+     m_dragSource.reset(new QWaylandDataSource(m_display->dndSelectionHandler(), mimeData));
++
++    if (wl_data_device_get_version(object()) >= 3)
++        m_dragSource->set_actions(dropActionsToWl(supportedActions));
++
+     connect(m_dragSource.data(), &QWaylandDataSource::cancelled, this, &QWaylandDataDevice::dragSourceCancelled);
++    connect(m_dragSource.data(), &QWaylandDataSource::dndResponseUpdated, this, [this](bool accepted, Qt::DropAction action) {
++            auto drag = static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag());
++            // in old versions drop action is not set, so we guess
++            if (wl_data_source_get_version(m_dragSource->object()) < 3) {
++                drag->setResponse(accepted);
++            } else {
++                QPlatformDropQtResponse response(accepted, action);
++                drag->setResponse(response);
++            }
++    });
++    connect(m_dragSource.data(), &QWaylandDataSource::dndDropped, this, [](bool accepted, Qt::DropAction action) {
++        QPlatformDropQtResponse response(accepted, action);
++        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setDropResponse(response);
++    });
++    connect(m_dragSource.data(), &QWaylandDataSource::finished, this, []() {
++        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag();
++    });
+ 
+     start_drag(m_dragSource->object(), origin->wlSurface(), icon->wlSurface(), m_display->currentInputDevice()->serial());
+     return true;
+@@ -152,7 +175,7 @@ void QWaylandDataDevice::data_device_drop()
+         supportedActions = drag->supportedActions();
+     } else if (m_dragOffer) {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     } else {
+         return;
+     }
+@@ -162,7 +185,11 @@ void QWaylandDataDevice::data_device_drop()
+                                                                           QGuiApplication::keyboardModifiers());
+ 
+     if (drag) {
+-        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag(response);
++        auto drag =  static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag());
++        drag->setDropResponse(response);
++        drag->finishDrag();
++    } else if (m_dragOffer) {
++        m_dragOffer->finish();
+     }
+ }
+ 
+@@ -186,7 +213,7 @@ void QWaylandDataDevice::data_device_enter(uint32_t serial, wl_surface *surface,
+         supportedActions = drag->supportedActions();
+     } else if (m_dragOffer) {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     }
+ 
+     const QPlatformDragQtResponse &response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
+@@ -197,11 +224,7 @@ void QWaylandDataDevice::data_device_enter(uint32_t serial, wl_surface *surface,
+         static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setResponse(response);
+     }
+ 
+-    if (response.isAccepted()) {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, m_dragOffer->firstFormat().toUtf8().constData());
+-    } else {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, nullptr);
+-    }
++    sendResponse(supportedActions, response);
+ }
+ 
+ void QWaylandDataDevice::data_device_leave()
+@@ -235,10 +258,10 @@ void QWaylandDataDevice::data_device_motion(uint32_t time, wl_fixed_t x, wl_fixe
+         supportedActions = drag->supportedActions();
+     } else {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     }
+ 
+-    QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
++    const QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
+                                                                           QGuiApplication::mouseButtons(),
+                                                                           QGuiApplication::keyboardModifiers());
+ 
+@@ -246,11 +269,7 @@ void QWaylandDataDevice::data_device_motion(uint32_t time, wl_fixed_t x, wl_fixe
+         static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setResponse(response);
+     }
+ 
+-    if (response.isAccepted()) {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, m_dragOffer->firstFormat().toUtf8().constData());
+-    } else {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, nullptr);
+-    }
++    sendResponse(supportedActions, response);
+ }
+ #endif // QT_CONFIG(draganddrop)
+ 
+@@ -277,14 +296,10 @@ void QWaylandDataDevice::selectionSourceCancelled()
+ #if QT_CONFIG(draganddrop)
+ void QWaylandDataDevice::dragSourceCancelled()
+ {
++    static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag();
+     m_dragSource.reset();
+ }
+ 
+-void QWaylandDataDevice::dragSourceTargetChanged(const QString &mimeType)
+-{
+-    static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->updateTarget(mimeType);
+-}
+-
+ QPoint QWaylandDataDevice::calculateDragPosition(int x, int y, QWindow *wnd) const
+ {
+     QPoint pnt(wl_fixed_to_int(x), wl_fixed_to_int(y));
+@@ -297,6 +312,33 @@ QPoint QWaylandDataDevice::calculateDragPosition(int x, int y, QWindow *wnd) con
+     }
+     return pnt;
+ }
++
++void QWaylandDataDevice::sendResponse(Qt::DropActions supportedActions, const QPlatformDragQtResponse &response)
++{
++    if (response.isAccepted()) {
++        if (wl_data_device_get_version(object()) >= 3)
++            m_dragOffer->set_actions(dropActionsToWl(supportedActions), dropActionsToWl(response.acceptedAction()));
++
++        m_dragOffer->accept(m_enterSerial, m_dragOffer->firstFormat());
++    } else {
++        m_dragOffer->accept(m_enterSerial, QString());
++    }
++}
++
++int QWaylandDataDevice::dropActionsToWl(Qt::DropActions actions)
++{
++
++    int wlActions = WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE;
++    if (actions & Qt::CopyAction)
++        wlActions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY;
++    if (actions & (Qt::MoveAction | Qt::TargetMoveAction))
++        wlActions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE;
++
++    // wayland does not support LinkAction at the time of writing
++    return wlActions;
++}
++
++
+ #endif // QT_CONFIG(draganddrop)
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddatadevice_p.h b/qtwayland/src/client/qwaylanddatadevice_p.h
+index 16c3ad28..801dcc2c 100644
+--- a/qtwayland/src/client/qwaylanddatadevice_p.h
++++ b/qtwayland/src/client/qwaylanddatadevice_p.h
+@@ -64,6 +64,7 @@ QT_REQUIRE_CONFIG(wayland_datadevice);
+ QT_BEGIN_NAMESPACE
+ 
+ class QMimeData;
++class QPlatformDragQtResponse;
+ class QWindow;
+ 
+ namespace QtWaylandClient {
+@@ -89,7 +90,7 @@ public:
+ 
+ #if QT_CONFIG(draganddrop)
+     QWaylandDataOffer *dragOffer() const;
+-    bool startDrag(QMimeData *mimeData, QWaylandWindow *icon);
++    bool startDrag(QMimeData *mimeData, Qt::DropActions supportedActions, QWaylandWindow *icon);
+     void cancelDrag();
+ #endif
+ 
+@@ -109,13 +110,16 @@ private Q_SLOTS:
+ 
+ #if QT_CONFIG(draganddrop)
+     void dragSourceCancelled();
+-    void dragSourceTargetChanged(const QString &mimeType);
+ #endif
+ 
+ private:
+ #if QT_CONFIG(draganddrop)
+     QPoint calculateDragPosition(int x, int y, QWindow *wnd) const;
+ #endif
++    void sendResponse(Qt::DropActions supportedActions, const QPlatformDragQtResponse &response);
++
++    static int dropActionsToWl(Qt::DropActions dropActions);
++
+ 
+     QWaylandDisplay *m_display = nullptr;
+     QWaylandInputDevice *m_inputDevice = nullptr;
+diff --git a/qtwayland/src/client/qwaylanddatadevicemanager.cpp b/qtwayland/src/client/qwaylanddatadevicemanager.cpp
+index 35d67307..6dc4f77f 100644
+--- a/qtwayland/src/client/qwaylanddatadevicemanager.cpp
++++ b/qtwayland/src/client/qwaylanddatadevicemanager.cpp
+@@ -50,8 +50,8 @@ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
+-QWaylandDataDeviceManager::QWaylandDataDeviceManager(QWaylandDisplay *display, uint32_t id)
+-    : wl_data_device_manager(display->wl_registry(), id, 1)
++QWaylandDataDeviceManager::QWaylandDataDeviceManager(QWaylandDisplay *display, int version, uint32_t id)
++    : wl_data_device_manager(display->wl_registry(), id, qMin(version, 3))
+     , m_display(display)
+ {
+     // Create transfer devices for all input devices.
+diff --git a/qtwayland/src/client/qwaylanddatadevicemanager_p.h b/qtwayland/src/client/qwaylanddatadevicemanager_p.h
+index bd05c0fb..510d9be4 100644
+--- a/qtwayland/src/client/qwaylanddatadevicemanager_p.h
++++ b/qtwayland/src/client/qwaylanddatadevicemanager_p.h
+@@ -68,7 +68,7 @@ class QWaylandInputDevice;
+ class Q_WAYLAND_CLIENT_EXPORT QWaylandDataDeviceManager : public QtWayland::wl_data_device_manager
+ {
+ public:
+-    QWaylandDataDeviceManager(QWaylandDisplay *display, uint32_t id);
++    QWaylandDataDeviceManager(QWaylandDisplay *display, int version, uint32_t id);
+     ~QWaylandDataDeviceManager() override;
+ 
+     QWaylandDataDevice *getDataDevice(QWaylandInputDevice *inputDevice);
+diff --git a/qtwayland/src/client/qwaylanddataoffer.cpp b/qtwayland/src/client/qwaylanddataoffer.cpp
+index 2297e8a1..fe0ea8c9 100644
+--- a/qtwayland/src/client/qwaylanddataoffer.cpp
++++ b/qtwayland/src/client/qwaylanddataoffer.cpp
+@@ -82,6 +82,15 @@ QMimeData *QWaylandDataOffer::mimeData()
+     return m_mimeData.data();
+ }
+ 
++Qt::DropActions QWaylandDataOffer::supportedActions() const
++{
++    if (wl_data_offer_get_version(const_cast<::wl_data_offer*>(object())) < 3) {
++        return Qt::MoveAction | Qt::CopyAction;
++    }
++
++    return m_supportedActions;
++}
++
+ void QWaylandDataOffer::startReceiving(const QString &mimeType, int fd)
+ {
+     receive(mimeType, fd);
+@@ -93,6 +102,22 @@ void QWaylandDataOffer::data_offer_offer(const QString &mime_type)
+     m_mimeData->appendFormat(mime_type);
+ }
+ 
++void QWaylandDataOffer::data_offer_action(uint32_t dnd_action)
++{
++    Q_UNUSED(dnd_action);
++    // This is the compositor telling the drag target what action it should perform
++    // It does not map nicely into Qt final drop semantics, other than pretending there is only one supported action?
++}
++
++void QWaylandDataOffer::data_offer_source_actions(uint32_t source_actions)
++{
++    m_supportedActions = Qt::DropActions();
++    if (source_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
++        m_supportedActions |= Qt::MoveAction;
++    if (source_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
++        m_supportedActions |= Qt::CopyAction;
++}
++
+ QWaylandMimeData::QWaylandMimeData(QWaylandAbstractDataOffer *dataOffer)
+     : m_dataOffer(dataOffer)
+ {
+@@ -163,17 +188,18 @@ QVariant QWaylandMimeData::retrieveData_sys(const QString &mimeType, QVariant::T
+ 
+ int QWaylandMimeData::readData(int fd, QByteArray &data) const
+ {
+-    fd_set readset;
+-    FD_ZERO(&readset);
+-    FD_SET(fd, &readset);
+-    struct timeval timeout;
++    struct pollfd readset;
++    readset.fd = fd;
++    readset.events = POLLIN;
++    struct timespec timeout;
+     timeout.tv_sec = 1;
+-    timeout.tv_usec = 0;
++    timeout.tv_nsec = 0;
++
+ 
+     Q_FOREVER {
+-        int ready = select(FD_SETSIZE, &readset, nullptr, nullptr, &timeout);
++        int ready = qt_safe_poll(&readset, 1, &timeout);
+         if (ready < 0) {
+-            qWarning() << "QWaylandDataOffer: select() failed";
++            qWarning() << "QWaylandDataOffer: qt_safe_poll() failed";
+             return -1;
+         } else if (ready == 0) {
+             qWarning("QWaylandDataOffer: timeout reading from pipe");
+diff --git a/qtwayland/src/client/qwaylanddataoffer_p.h b/qtwayland/src/client/qwaylanddataoffer_p.h
+index 9cf1483c..6f667398 100644
+--- a/qtwayland/src/client/qwaylanddataoffer_p.h
++++ b/qtwayland/src/client/qwaylanddataoffer_p.h
+@@ -82,6 +82,7 @@ public:
+     explicit QWaylandDataOffer(QWaylandDisplay *display, struct ::wl_data_offer *offer);
+     ~QWaylandDataOffer() override;
+     QMimeData *mimeData() override;
++    Qt::DropActions supportedActions() const;
+ 
+     QString firstFormat() const;
+ 
+@@ -89,10 +90,13 @@ public:
+ 
+ protected:
+     void data_offer_offer(const QString &mime_type) override;
++    void data_offer_source_actions(uint32_t source_actions) override;
++    void data_offer_action(uint32_t dnd_action) override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+     QScopedPointer<QWaylandMimeData> m_mimeData;
++    Qt::DropActions m_supportedActions;
+ };
+ 
+ 
+diff --git a/qtwayland/src/client/qwaylanddatasource.cpp b/qtwayland/src/client/qwaylanddatasource.cpp
+index f45122fb..5599cbd4 100644
+--- a/qtwayland/src/client/qwaylanddatasource.cpp
++++ b/qtwayland/src/client/qwaylanddatasource.cpp
+@@ -101,7 +101,32 @@ void QWaylandDataSource::data_source_send(const QString &mime_type, int32_t fd)
+ 
+ void QWaylandDataSource::data_source_target(const QString &mime_type)
+ {
+-    Q_EMIT targetChanged(mime_type);
++    m_accepted = !mime_type.isEmpty();
++    Q_EMIT dndResponseUpdated(m_accepted, m_dropAction);
++}
++
++void QWaylandDataSource::data_source_action(uint32_t action)
++{
++    Qt::DropAction qtAction = Qt::IgnoreAction;
++
++    if (action == WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
++        qtAction = Qt::MoveAction;
++    else if (action == WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
++        qtAction = Qt::CopyAction;
++
++    m_dropAction = qtAction;
++    Q_EMIT dndResponseUpdated(m_accepted, m_dropAction);
++}
++
++void QWaylandDataSource::data_source_dnd_finished()
++{
++    Q_EMIT finished();
++}
++
++void QWaylandDataSource::data_source_dnd_drop_performed()
++{
++
++    Q_EMIT dndDropped(m_accepted, m_dropAction);
+ }
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddatasource_p.h b/qtwayland/src/client/qwaylanddatasource_p.h
+index 25afff79..96f07bc3 100644
+--- a/qtwayland/src/client/qwaylanddatasource_p.h
++++ b/qtwayland/src/client/qwaylanddatasource_p.h
+@@ -77,17 +77,25 @@ public:
+     QMimeData *mimeData() const;
+ 
+ Q_SIGNALS:
+-    void targetChanged(const QString &mime_type);
+     void cancelled();
++    void finished();
++
++    void dndResponseUpdated(bool accepted, Qt::DropAction action);
++    void dndDropped(bool accepted, Qt::DropAction action);
+ 
+ protected:
+     void data_source_cancelled() override;
+     void data_source_send(const QString &mime_type, int32_t fd) override;
+     void data_source_target(const QString &mime_type) override;
++    void data_source_dnd_drop_performed() override;
++    void data_source_dnd_finished() override;
++    void data_source_action(uint32_t action) override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+     QMimeData *m_mime_data = nullptr;
++    bool m_accepted = false;
++    Qt::DropAction m_dropAction = Qt::IgnoreAction;
+ };
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddisplay.cpp b/qtwayland/src/client/qwaylanddisplay.cpp
+index f10c1f79..c01e238b 100644
+--- a/qtwayland/src/client/qwaylanddisplay.cpp
++++ b/qtwayland/src/client/qwaylanddisplay.cpp
+@@ -85,10 +85,203 @@
+ 
+ #include <errno.h>
+ 
++#include <tuple> // for std::tie
++
++static void checkWaylandError(struct wl_display *display)
++{
++    int ecode = wl_display_get_error(display);
++    if ((ecode == EPIPE || ecode == ECONNRESET)) {
++        // special case this to provide a nicer error
++        qWarning("The Wayland connection broke. Did the Wayland compositor die?");
++    } else {
++        qWarning("The Wayland connection experienced a fatal error: %s", strerror(ecode));
++    }
++    _exit(1);
++}
++
+ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
++class EventThread : public QThread
++{
++    Q_OBJECT
++public:
++    enum OperatingMode {
++        EmitToDispatch, // Emit the signal, allow dispatching in a differnt thread.
++        SelfDispatch, // Dispatch the events inside this thread.
++    };
++
++    EventThread(struct wl_display * wl, struct wl_event_queue * ev_queue,
++                OperatingMode mode)
++        : m_fd(wl_display_get_fd(wl))
++        , m_pipefd{ -1, -1 }
++        , m_wldisplay(wl)
++        , m_wlevqueue(ev_queue)
++        , m_mode(mode)
++        , m_reading(true)
++        , m_quitting(false)
++    {
++        setObjectName(QStringLiteral("WaylandEventThread"));
++    }
++
++    void readAndDispatchEvents()
++    {
++        /*
++         * Dispatch pending events and flush the requests at least once. If the event thread
++         * is not reading, try to call _prepare_read() to allow the event thread to poll().
++         * If that fails, re-try dispatch & flush again until _prepare_read() is successful.
++         *
++         * This allow any call to readAndDispatchEvents() to start event thread's polling,
++         * not only the one issued from event thread's waitForReading(), which means functions
++         * called from dispatch_pending() can safely spin an event loop.
++         */
++        for (;;) {
++            if (dispatchQueuePending() < 0) {
++                checkWaylandError(m_wldisplay);
++                return;
++            }
++
++            wl_display_flush(m_wldisplay);
++
++            // We have to check if event thread is reading every time we dispatch
++            // something, as that may recursively call this function.
++            if (m_reading.loadAcquire())
++                break;
++
++            if (prepareReadQueue() == 0) {
++                QMutexLocker l(&m_mutex);
++                m_reading.storeRelease(true);
++                m_cond.wakeOne();
++                break;
++            }
++        }
++    }
++
++    void stop()
++    {
++        // We have to both write to the pipe and set the flag, as the thread may be
++        // either in the poll() or waiting for _prepare_read().
++        if (m_pipefd[1] != -1 && write(m_pipefd[1], "\0", 1) == -1)
++            qWarning("Failed to write to the pipe: %s.", strerror(errno));
++
++        {
++            QMutexLocker l(&m_mutex);
++            m_quitting = true;
++            m_cond.wakeOne();
++        }
++
++        wait();
++    }
++
++Q_SIGNALS:
++    void needReadAndDispatch();
++
++protected:
++    void run() override
++    {
++        // we use this pipe to make the loop exit otherwise if we simply used a flag on the loop condition, if stop() gets
++        // called while poll() is blocking the thread will never quit since there are no wayland messages coming anymore.
++        struct Pipe
++        {
++            Pipe(int *fds)
++                : fds(fds)
++            {
++                if (qt_safe_pipe(fds) != 0)
++                    qWarning("Pipe creation failed. Quitting may hang.");
++            }
++            ~Pipe()
++            {
++                if (fds[0] != -1) {
++                    close(fds[0]);
++                    close(fds[1]);
++                }
++            }
++
++            int *fds;
++        } pipe(m_pipefd);
++
++        // Make the main thread call wl_prepare_read(), dispatch the pending messages and flush the
++        // outbound ones. Wait until it's done before proceeding, unless we're told to quit.
++        while (waitForReading()) {
++            pollfd fds[2] = { { m_fd, POLLIN, 0 }, { m_pipefd[0], POLLIN, 0 } };
++            poll(fds, 2, -1);
++
++            if (fds[1].revents & POLLIN) {
++                // we don't really care to read the byte that was written here since we're closing down
++                wl_display_cancel_read(m_wldisplay);
++                break;
++            }
++
++            if (fds[0].revents & POLLIN)
++                wl_display_read_events(m_wldisplay);
++                // The polll was succesfull and the event thread did the wl_display_read_events(). On the next iteration of the loop
++                // the event sent to the main thread will cause it to dispatch the messages just read, unless the loop exits in which
++                // case we don't care anymore about them.
++            else
++                wl_display_cancel_read(m_wldisplay);
++        }
++    }
++
++private:
++    bool waitForReading()
++    {
++        Q_ASSERT(QThread::currentThread() == this);
++
++        m_reading.storeRelease(false);
++
++        if (m_mode == SelfDispatch) {
++            readAndDispatchEvents();
++        } else {
++            Q_EMIT needReadAndDispatch();
++
++            QMutexLocker lock(&m_mutex);
++            // m_reading might be set from our emit or some other invocation of
++            // readAndDispatchEvents().
++            while (!m_reading.loadRelaxed() && !m_quitting)
++                m_cond.wait(&m_mutex);
++        }
++
++        return !m_quitting;
++    }
++
++    int dispatchQueuePending()
++    {
++        if (m_wlevqueue)
++            return wl_display_dispatch_queue_pending(m_wldisplay, m_wlevqueue);
++        else
++            return wl_display_dispatch_pending(m_wldisplay);
++    }
++
++    int prepareReadQueue()
++    {
++        if (m_wlevqueue)
++            return wl_display_prepare_read_queue(m_wldisplay, m_wlevqueue);
++        else
++            return wl_display_prepare_read(m_wldisplay);
++    }
++
++    int m_fd;
++    int m_pipefd[2];
++    wl_display *m_wldisplay;
++    wl_event_queue *m_wlevqueue;
++    OperatingMode m_mode;
++
++    /* Concurrency note when operating in EmitToDispatch mode:
++     * m_reading is set to false inside event thread's waitForReading(), and is
++     * set to true inside main thread's readAndDispatchEvents().
++     * The lock is not taken when setting m_reading to false, as the main thread
++     * is not actively waiting for it to turn false. However, the lock is taken
++     * inside readAndDispatchEvents() before setting m_reading to true,
++     * as the event thread is actively waiting for it under the wait condition.
++     */
++
++    QAtomicInteger<bool> m_reading;
++    bool m_quitting;
++    QMutex m_mutex;
++    QWaitCondition m_cond;
++};
++
+ Q_LOGGING_CATEGORY(lcQpaWayland, "qt.qpa.wayland"); // for general (uncategorized) Wayland platform logging
+ 
+ struct wl_surface *QWaylandDisplay::createSurface(void *handle)
+@@ -158,17 +351,16 @@ QWaylandDisplay::QWaylandDisplay(QWaylandIntegration *waylandIntegration)
+     if (!mXkbContext)
+         qCWarning(lcQpaWayland, "failed to create xkb context");
+ #endif
+-
+-    forceRoundTrip();
+-
+-    if (!mWaitingScreens.isEmpty()) {
+-        // Give wl_output.done and zxdg_output_v1.done events a chance to arrive
+-        forceRoundTrip();
+-    }
+ }
+ 
+ QWaylandDisplay::~QWaylandDisplay(void)
+ {
++    if (m_eventThread)
++        m_eventThread->stop();
++
++    if (m_frameEventQueueThread)
++        m_frameEventQueueThread->stop();
++
+     if (mSyncCallback)
+         wl_callback_destroy(mSyncCallback);
+ 
+@@ -187,6 +379,21 @@ QWaylandDisplay::~QWaylandDisplay(void)
+ #endif
+     if (mDisplay)
+         wl_display_disconnect(mDisplay);
++
++    if (m_frameEventQueue)
++        wl_event_queue_destroy(m_frameEventQueue);
++}
++
++// Steps which is called just after constructor. This separates registry_global() out of the constructor
++// so that factory functions in integration can be overridden.
++void QWaylandDisplay::initialize()
++{
++    forceRoundTrip();
++
++    if (!mWaitingScreens.isEmpty()) {
++        // Give wl_output.done and zxdg_output_v1.done events a chance to arrive
++        forceRoundTrip();
++    }
+ }
+ 
+ void QWaylandDisplay::ensureScreen()
+@@ -203,98 +410,37 @@ void QWaylandDisplay::ensureScreen()
+ 
+ void QWaylandDisplay::checkError() const
+ {
+-    int ecode = wl_display_get_error(mDisplay);
+-    if ((ecode == EPIPE || ecode == ECONNRESET)) {
+-        // special case this to provide a nicer error
+-        qWarning("The Wayland connection broke. Did the Wayland compositor die?");
+-    } else {
+-        qWarning("The Wayland connection experienced a fatal error: %s", strerror(ecode));
+-    }
+-    _exit(1);
++    checkWaylandError(mDisplay);
+ }
+ 
++// Called in main thread, either from queued signal or directly.
+ void QWaylandDisplay::flushRequests()
+ {
+-    if (wl_display_prepare_read(mDisplay) == 0) {
+-        wl_display_read_events(mDisplay);
+-    }
+-
+-    if (wl_display_dispatch_pending(mDisplay) < 0)
+-        checkError();
+-
+-    {
+-        QReadLocker locker(&m_frameQueueLock);
+-        for (const FrameQueue &q : mExternalQueues) {
+-            QMutexLocker locker(q.mutex);
+-            while (wl_display_prepare_read_queue(mDisplay, q.queue) != 0)
+-                wl_display_dispatch_queue_pending(mDisplay, q.queue);
+-            wl_display_read_events(mDisplay);
+-            wl_display_dispatch_queue_pending(mDisplay, q.queue);
+-        }
+-    }
+-
+-    wl_display_flush(mDisplay);
+-}
+-
+-void QWaylandDisplay::blockingReadEvents()
+-{
+-    if (wl_display_dispatch(mDisplay) < 0)
+-        checkError();
+-}
+-
+-void QWaylandDisplay::destroyFrameQueue(const QWaylandDisplay::FrameQueue &q)
+-{
+-    QWriteLocker locker(&m_frameQueueLock);
+-    auto it = std::find_if(mExternalQueues.begin(),
+-                           mExternalQueues.end(),
+-                           [&q] (const QWaylandDisplay::FrameQueue &other){ return other.queue == q.queue; });
+-    Q_ASSERT(it != mExternalQueues.end());
+-    mExternalQueues.erase(it);
+-    if (q.queue != nullptr)
+-        wl_event_queue_destroy(q.queue);
+-    delete q.mutex;
++    m_eventThread->readAndDispatchEvents();
+ }
+ 
+-QWaylandDisplay::FrameQueue QWaylandDisplay::createFrameQueue()
++// We have to wait until we have an eventDispatcher before creating the eventThread,
++// otherwise forceRoundTrip() may block inside _events_read() because eventThread is
++// polling.
++void QWaylandDisplay::initEventThread()
+ {
+-    QWriteLocker locker(&m_frameQueueLock);
+-    FrameQueue q{createEventQueue()};
+-    mExternalQueues.append(q);
+-    return q;
+-}
++    m_eventThread.reset(
++            new EventThread(mDisplay, /* default queue */ nullptr, EventThread::EmitToDispatch));
++    connect(m_eventThread.get(), &EventThread::needReadAndDispatch, this,
++            &QWaylandDisplay::flushRequests, Qt::QueuedConnection);
++    m_eventThread->start();
+ 
+-wl_event_queue *QWaylandDisplay::createEventQueue()
+-{
+-    return wl_display_create_queue(mDisplay);
++    // wl_display_disconnect() free this.
++    m_frameEventQueue = wl_display_create_queue(mDisplay);
++    m_frameEventQueueThread.reset(
++            new EventThread(mDisplay, m_frameEventQueue, EventThread::SelfDispatch));
++    m_frameEventQueueThread->start();
+ }
+ 
+-void QWaylandDisplay::dispatchQueueWhile(wl_event_queue *queue, std::function<bool ()> condition, int timeout)
++void QWaylandDisplay::blockingReadEvents()
+ {
+-    if (!condition())
+-        return;
+-
+-    QElapsedTimer timer;
+-    timer.start();
+-    struct pollfd pFd = qt_make_pollfd(wl_display_get_fd(mDisplay), POLLIN);
+-    while (timeout == -1 || timer.elapsed() < timeout) {
+-        while (wl_display_prepare_read_queue(mDisplay, queue) != 0)
+-            wl_display_dispatch_queue_pending(mDisplay, queue);
+-
+-        wl_display_flush(mDisplay);
+-
+-        const int remaining = qMax(timeout - timer.elapsed(), 0ll);
+-        const int pollTimeout = timeout == -1 ? -1 : remaining;
+-        if (qt_poll_msecs(&pFd, 1, pollTimeout) > 0)
+-            wl_display_read_events(mDisplay);
+-        else
+-            wl_display_cancel_read(mDisplay);
+-
+-        if (wl_display_dispatch_queue_pending(mDisplay, queue) < 0)
+-            checkError();
+-
+-        if (!condition())
+-            break;
+-    }
++    if (wl_display_dispatch(mDisplay) < 0)
++        checkWaylandError(mDisplay);
+ }
+ 
+ QWaylandScreen *QWaylandDisplay::screenForOutput(struct wl_output *output) const
+@@ -345,7 +491,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+     if (interface == QStringLiteral("wl_output")) {
+         mWaitingScreens << new QWaylandScreen(this, version, id);
+     } else if (interface == QStringLiteral("wl_compositor")) {
+-        mCompositorVersion = qMin((int)version, 3);
++        mCompositorVersion = qMin((int)version, 4);
+         mCompositor.init(registry, id, mCompositorVersion);
+     } else if (interface == QStringLiteral("wl_shm")) {
+         mShm.reset(new QWaylandShm(this, version, id));
+@@ -354,7 +500,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+         mInputDevices.append(inputDevice);
+ #if QT_CONFIG(wayland_datadevice)
+     } else if (interface == QStringLiteral("wl_data_device_manager")) {
+-        mDndSelectionHandler.reset(new QWaylandDataDeviceManager(this, id));
++        mDndSelectionHandler.reset(new QWaylandDataDeviceManager(this, version, id));
+ #endif
+     } else if (interface == QStringLiteral("qt_surface_extension")) {
+         mWindowExtension.reset(new QtWayland::qt_surface_extension(registry, id, 1));
+@@ -369,6 +515,8 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+ #if QT_CONFIG(wayland_client_primary_selection)
+     } else if (interface == QStringLiteral("zwp_primary_selection_device_manager_v1")) {
+         mPrimarySelectionManager.reset(new QWaylandPrimarySelectionDeviceManagerV1(this, id, 1));
++        for (QWaylandInputDevice *inputDevice : qAsConst(mInputDevices))
++            inputDevice->setPrimarySelectionDevice(mPrimarySelectionManager->createDevice(inputDevice));
+ #endif
+     } else if (interface == QStringLiteral("zwp_text_input_manager_v2") && !mClientSideInputContextRequested) {
+         mTextInputManager.reset(new QtWayland::zwp_text_input_manager_v2(registry, id, 1));
+@@ -427,6 +575,13 @@ void QWaylandDisplay::registry_global_remove(uint32_t id)
+                     inputDevice->setTextInput(nullptr);
+                 mWaylandIntegration->reconfigureInputContext();
+             }
++#if QT_CONFIG(wayland_client_primary_selection)
++            if (global.interface == QStringLiteral("zwp_primary_selection_device_manager_v1")) {
++                mPrimarySelectionManager.reset();
++                for (QWaylandInputDevice *inputDevice : qAsConst(mInputDevices))
++                    inputDevice->setPrimarySelectionDevice(nullptr);
++            }
++#endif
+             mGlobals.removeAt(i);
+             break;
+         }
+@@ -452,9 +607,10 @@ void QWaylandDisplay::addRegistryListener(RegistryListener listener, void *data)
+ 
+ void QWaylandDisplay::removeListener(RegistryListener listener, void *data)
+ {
+-    std::remove_if(mRegistryListeners.begin(), mRegistryListeners.end(), [=](Listener l){
++    auto iter = std::remove_if(mRegistryListeners.begin(), mRegistryListeners.end(), [=](Listener l){
+         return (l.listener == listener && l.data == data);
+     });
++    mRegistryListeners.erase(iter, mRegistryListeners.end());
+ }
+ 
+ uint32_t QWaylandDisplay::currentTimeMillisec()
+@@ -467,50 +623,9 @@ uint32_t QWaylandDisplay::currentTimeMillisec()
+     return 0;
+ }
+ 
+-static void
+-sync_callback(void *data, struct wl_callback *callback, uint32_t serial)
+-{
+-    Q_UNUSED(serial)
+-    bool *done = static_cast<bool *>(data);
+-
+-    *done = true;
+-
+-    // If the wl_callback done event is received after the condition check in the while loop in
+-    // forceRoundTrip(), but before the call to processEvents, the call to processEvents may block
+-    // forever if no more events are posted (eventhough the callback is handled in response to the
+-    // aboutToBlock signal). Hence, we wake up the event dispatcher so forceRoundTrip may return.
+-    // (QTBUG-64696)
+-    if (auto *dispatcher = QThread::currentThread()->eventDispatcher())
+-        dispatcher->wakeUp();
+-
+-    wl_callback_destroy(callback);
+-}
+-
+-static const struct wl_callback_listener sync_listener = {
+-    sync_callback
+-};
+-
+ void QWaylandDisplay::forceRoundTrip()
+ {
+-    // wl_display_roundtrip() works on the main queue only,
+-    // but we use a separate one, so basically reimplement it here
+-    int ret = 0;
+-    bool done = false;
+-    wl_callback *callback = wl_display_sync(mDisplay);
+-    wl_callback_add_listener(callback, &sync_listener, &done);
+-    flushRequests();
+-    if (QThread::currentThread()->eventDispatcher()) {
+-        while (!done && ret >= 0) {
+-            QThread::currentThread()->eventDispatcher()->processEvents(QEventLoop::WaitForMoreEvents);
+-            ret = wl_display_dispatch_pending(mDisplay);
+-        }
+-    } else {
+-        while (!done && ret >= 0)
+-            ret = wl_display_dispatch(mDisplay);
+-    }
+-
+-    if (ret == -1 && !done)
+-        wl_callback_destroy(callback);
++     wl_display_roundtrip(mDisplay);
+ }
+ 
+ bool QWaylandDisplay::supportsWindowDecoration() const
+@@ -574,14 +689,10 @@ void QWaylandDisplay::handleKeyboardFocusChanged(QWaylandInputDevice *inputDevic
+     if (mLastKeyboardFocus == keyboardFocus)
+         return;
+ 
+-    if (mWaylandIntegration->mShellIntegration) {
+-        mWaylandIntegration->mShellIntegration->handleKeyboardFocusChanged(keyboardFocus, mLastKeyboardFocus);
+-    } else {
+-        if (keyboardFocus)
+-            handleWindowActivated(keyboardFocus);
+-        if (mLastKeyboardFocus)
+-            handleWindowDeactivated(mLastKeyboardFocus);
+-    }
++    if (keyboardFocus)
++        handleWindowActivated(keyboardFocus);
++    if (mLastKeyboardFocus)
++        handleWindowDeactivated(mLastKeyboardFocus);
+ 
+     mLastKeyboardFocus = keyboardFocus;
+ }
+@@ -600,6 +711,19 @@ void QWaylandDisplay::handleWaylandSync()
+     QWindow *activeWindow = mActiveWindows.empty() ? nullptr : mActiveWindows.last()->window();
+     if (activeWindow != QGuiApplication::focusWindow())
+         QWindowSystemInterface::handleWindowActivated(activeWindow);
++
++    if (!activeWindow) {
++        if (lastInputDevice()) {
++#if QT_CONFIG(clipboard)
++            if (auto *dataDevice = lastInputDevice()->dataDevice())
++                dataDevice->invalidateSelectionOffer();
++#endif
++#if QT_CONFIG(wayland_client_primary_selection)
++            if (auto *device = lastInputDevice()->primarySelectionDevice())
++                device->invalidateSelectionOffer();
++#endif
++        }
++    }
+ }
+ 
+ const wl_callback_listener QWaylandDisplay::syncCallbackListener = {
+@@ -626,6 +750,13 @@ QWaylandInputDevice *QWaylandDisplay::defaultInputDevice() const
+     return mInputDevices.isEmpty() ? 0 : mInputDevices.first();
+ }
+ 
++bool QWaylandDisplay::isKeyboardAvailable() const
++{
++    return std::any_of(
++            mInputDevices.constBegin(), mInputDevices.constEnd(),
++            [this](const QWaylandInputDevice *device) { return device->keyboard() != nullptr; });
++}
++
+ #if QT_CONFIG(cursor)
+ 
+ QWaylandCursor *QWaylandDisplay::waylandCursor()
+@@ -652,4 +783,6 @@ QWaylandCursorTheme *QWaylandDisplay::loadCursorTheme(const QString &name, int p
+ 
+ } // namespace QtWaylandClient
+ 
++#include "qwaylanddisplay.moc"
++
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/client/qwaylanddisplay_p.h b/qtwayland/src/client/qwaylanddisplay_p.h
+index 3b092bc8..42bc661d 100644
+--- a/qtwayland/src/client/qwaylanddisplay_p.h
++++ b/qtwayland/src/client/qwaylanddisplay_p.h
+@@ -109,6 +109,7 @@ class QWaylandSurface;
+ class QWaylandShellIntegration;
+ class QWaylandCursor;
+ class QWaylandCursorTheme;
++class EventThread;
+ 
+ typedef void (*RegistryListener)(void *data,
+                                  struct wl_registry *registry,
+@@ -120,15 +121,11 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandDisplay : public QObject, public QtWayland
+     Q_OBJECT
+ 
+ public:
+-    struct FrameQueue {
+-        FrameQueue(wl_event_queue *q = nullptr) : queue(q), mutex(new QMutex) {}
+-        wl_event_queue *queue;
+-        QMutex *mutex;
+-    };
+-
+     QWaylandDisplay(QWaylandIntegration *waylandIntegration);
+     ~QWaylandDisplay(void) override;
+ 
++    void initialize();
++
+ #if QT_CONFIG(xkbcommon)
+     struct xkb_context *xkbContext() const { return mXkbContext.get(); }
+ #endif
+@@ -210,11 +207,11 @@ public:
+     void handleKeyboardFocusChanged(QWaylandInputDevice *inputDevice);
+     void handleWindowDestroyed(QWaylandWindow *window);
+ 
+-    wl_event_queue *createEventQueue();
+-    FrameQueue createFrameQueue();
+-    void destroyFrameQueue(const FrameQueue &q);
+-    void dispatchQueueWhile(wl_event_queue *queue, std::function<bool()> condition, int timeout = -1);
++    wl_event_queue *frameEventQueue() { return m_frameEventQueue; };
++
++    bool isKeyboardAvailable() const;
+ 
++    void initEventThread();
+ public slots:
+     void blockingReadEvents();
+     void flushRequests();
+@@ -237,6 +234,9 @@ private:
+     };
+ 
+     struct wl_display *mDisplay = nullptr;
++    QScopedPointer<EventThread> m_eventThread;
++    wl_event_queue *m_frameEventQueue = nullptr;
++    QScopedPointer<EventThread> m_frameEventQueueThread;
+     QtWayland::wl_compositor mCompositor;
+     QScopedPointer<QWaylandShm> mShm;
+     QList<QWaylandScreen *> mWaitingScreens;
+@@ -273,11 +273,9 @@ private:
+     QWaylandInputDevice *mLastInputDevice = nullptr;
+     QPointer<QWaylandWindow> mLastInputWindow;
+     QPointer<QWaylandWindow> mLastKeyboardFocus;
+-    QVector<QWaylandWindow *> mActiveWindows;
+-    QVector<FrameQueue> mExternalQueues;
++    QList<QWaylandWindow *> mActiveWindows;
+     struct wl_callback *mSyncCallback = nullptr;
+     static const wl_callback_listener syncCallbackListener;
+-    QReadWriteLock m_frameQueueLock;
+ 
+     bool mClientSideInputContextRequested = !QPlatformInputContextFactory::requested().isNull();
+ 
+diff --git a/qtwayland/src/client/qwaylanddnd.cpp b/qtwayland/src/client/qwaylanddnd.cpp
+index 6535aa16..7c53f5fa 100644
+--- a/qtwayland/src/client/qwaylanddnd.cpp
++++ b/qtwayland/src/client/qwaylanddnd.cpp
+@@ -66,7 +66,7 @@ void QWaylandDrag::startDrag()
+ {
+     QBasicDrag::startDrag();
+     QWaylandWindow *icon = static_cast<QWaylandWindow *>(shapedPixmapWindow()->handle());
+-    if (m_display->currentInputDevice()->dataDevice()->startDrag(drag()->mimeData(), icon)) {
++    if (m_display->currentInputDevice()->dataDevice()->startDrag(drag()->mimeData(), drag()->supportedActions(), icon)) {
+         icon->addAttachOffset(-drag()->hotSpot());
+     } else {
+         // Cancelling immediately does not work, since the event loop for QDrag::exec is started
+@@ -80,6 +80,9 @@ void QWaylandDrag::cancel()
+     QBasicDrag::cancel();
+ 
+     m_display->currentInputDevice()->dataDevice()->cancelDrag();
++
++    if (drag())
++        drag()->deleteLater();
+ }
+ 
+ void QWaylandDrag::move(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods)
+@@ -103,33 +106,41 @@ void QWaylandDrag::endDrag()
+     m_display->currentInputDevice()->handleEndDrag();
+ }
+ 
+-void QWaylandDrag::updateTarget(const QString &mimeType)
++void QWaylandDrag::setResponse(bool accepted)
+ {
+-    setCanDrop(!mimeType.isEmpty());
+-
+-    if (canDrop()) {
+-        updateCursor(defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers()));
+-    } else {
+-        updateCursor(Qt::IgnoreAction);
+-    }
++    // This method is used for old DataDevices where the drag action is not communicated
++    Qt::DropAction action = defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers());
++    setResponse(QPlatformDropQtResponse(accepted, action));
+ }
+ 
+-void QWaylandDrag::setResponse(const QPlatformDragQtResponse &response)
++void QWaylandDrag::setResponse(const QPlatformDropQtResponse &response)
+ {
+     setCanDrop(response.isAccepted());
+ 
+     if (canDrop()) {
+-        updateCursor(defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers()));
++        updateCursor(response.acceptedAction());
+     } else {
+         updateCursor(Qt::IgnoreAction);
+     }
+ }
+ 
+-void QWaylandDrag::finishDrag(const QPlatformDropQtResponse &response)
++void QWaylandDrag::setDropResponse(const QPlatformDropQtResponse &response)
+ {
+     setExecutedDropAction(response.acceptedAction());
++}
++
++void QWaylandDrag::finishDrag()
++{
+     QKeyEvent event(QEvent::KeyPress, Qt::Key_Escape, Qt::NoModifier);
+     eventFilter(shapedPixmapWindow(), &event);
++
++    if (drag())
++        drag()->deleteLater();
++}
++
++bool QWaylandDrag::ownsDragObject() const
++{
++    return true;
+ }
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddnd_p.h b/qtwayland/src/client/qwaylanddnd_p.h
+index 474fe2ab..46f629ac 100644
+--- a/qtwayland/src/client/qwaylanddnd_p.h
++++ b/qtwayland/src/client/qwaylanddnd_p.h
+@@ -71,9 +71,10 @@ public:
+     QWaylandDrag(QWaylandDisplay *display);
+     ~QWaylandDrag() override;
+ 
+-    void updateTarget(const QString &mimeType);
+-    void setResponse(const QPlatformDragQtResponse &response);
+-    void finishDrag(const QPlatformDropQtResponse &response);
++    void setResponse(bool accepted);
++    void setResponse(const QPlatformDropQtResponse &response);
++    void setDropResponse(const QPlatformDropQtResponse &response);
++    void finishDrag();
+ 
+ protected:
+     void startDrag() override;
+@@ -82,6 +83,7 @@ protected:
+     void drop(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods) override;
+     void endDrag() override;
+ 
++    bool ownsDragObject() const override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+diff --git a/qtwayland/src/client/qwaylandinputdevice.cpp b/qtwayland/src/client/qwaylandinputdevice.cpp
+index 613fe862..4b90de84 100644
+--- a/qtwayland/src/client/qwaylandinputdevice.cpp
++++ b/qtwayland/src/client/qwaylandinputdevice.cpp
+@@ -685,6 +685,11 @@ public:
+ 
+ void QWaylandInputDevice::Pointer::pointer_leave(uint32_t time, struct wl_surface *surface)
+ {
++    invalidateFocus();
++    mButtons = Qt::NoButton;
++
++    mParent->mTime = time;
++
+     // The event may arrive after destroying the window, indicated by
+     // a null surface.
+     if (!surface)
+@@ -696,11 +701,6 @@ void QWaylandInputDevice::Pointer::pointer_leave(uint32_t time, struct wl_surfac
+ 
+     if (!QWaylandWindow::mouseGrab())
+         setFrameEvent(new LeaveEvent(window, mSurfacePos, mGlobalPos));
+-
+-    invalidateFocus();
+-    mButtons = Qt::NoButton;
+-
+-    mParent->mTime = time;
+ }
+ 
+ class MotionEvent : public QWaylandPointerEvent
+@@ -1300,14 +1300,6 @@ void QWaylandInputDevice::Keyboard::handleFocusDestroyed()
+ void QWaylandInputDevice::Keyboard::handleFocusLost()
+ {
+     mFocus = nullptr;
+-#if QT_CONFIG(clipboard)
+-    if (auto *dataDevice = mParent->dataDevice())
+-        dataDevice->invalidateSelectionOffer();
+-#endif
+-#if QT_CONFIG(wayland_client_primary_selection)
+-    if (auto *device = mParent->primarySelectionDevice())
+-        device->invalidateSelectionOffer();
+-#endif
+     mParent->mQDisplay->handleKeyboardFocusChanged(mParent);
+     mRepeatTimer.stop();
+ }
+@@ -1396,6 +1388,7 @@ void QWaylandInputDevice::Touch::touch_cancel()
+     if (touchExt)
+         touchExt->touchCanceled();
+ 
++    mFocus = nullptr;
+     QWindowSystemInterface::handleTouchCancelEvent(nullptr, mParent->mTouchDevice);
+ }
+ 
+diff --git a/qtwayland/src/client/qwaylandintegration.cpp b/qtwayland/src/client/qwaylandintegration.cpp
+index c53ccb78..54861600 100644
+--- a/qtwayland/src/client/qwaylandintegration.cpp
++++ b/qtwayland/src/client/qwaylandintegration.cpp
+@@ -125,6 +125,9 @@ QWaylandIntegration::QWaylandIntegration()
+ #endif
+ 
+     reconfigureInputContext();
++
++    QWaylandWindow::fixedToplevelPositions =
++            !qEnvironmentVariableIsSet("QT_WAYLAND_DISABLE_FIXED_POSITIONS");
+ }
+ 
+ QWaylandIntegration::~QWaylandIntegration()
+@@ -192,14 +195,18 @@ QAbstractEventDispatcher *QWaylandIntegration::createEventDispatcher() const
+ 
+ void QWaylandIntegration::initialize()
+ {
++    mDisplay->initEventThread();
++
++    // Call after eventDispatcher is fully connected, for QWaylandDisplay::forceRoundTrip()
++    mDisplay->initialize();
++
++    // But the aboutToBlock() and awake() should be connected after initializePlatform().
++    // Otherwise the connected flushRequests() may consumes up all events before processEvents starts to wait,
++    // so that processEvents(QEventLoop::WaitForMoreEvents) may be blocked in the forceRoundTrip().
+     QAbstractEventDispatcher *dispatcher = QGuiApplicationPrivate::eventDispatcher;
+     QObject::connect(dispatcher, SIGNAL(aboutToBlock()), mDisplay.data(), SLOT(flushRequests()));
+     QObject::connect(dispatcher, SIGNAL(awake()), mDisplay.data(), SLOT(flushRequests()));
+ 
+-    int fd = wl_display_get_fd(mDisplay->wl_display());
+-    QSocketNotifier *sn = new QSocketNotifier(fd, QSocketNotifier::Read, mDisplay.data());
+-    QObject::connect(sn, SIGNAL(activated(QSocketDescriptor)), mDisplay.data(), SLOT(flushRequests()));
+-
+     // Qt does not support running with no screens
+     mDisplay->ensureScreen();
+ }
+@@ -262,6 +269,14 @@ QWaylandDisplay *QWaylandIntegration::display() const
+     return mDisplay.data();
+ }
+ 
++Qt::KeyboardModifiers QWaylandIntegration::queryKeyboardModifiers() const
++{
++    if (auto *seat = mDisplay->currentInputDevice()) {
++        return seat->modifiers();
++    }
++    return Qt::NoModifier;
++}
++
+ QList<int> QWaylandIntegration::possibleKeys(const QKeyEvent *event) const
+ {
+     if (auto *seat = mDisplay->currentInputDevice())
+@@ -479,7 +494,7 @@ void QWaylandIntegration::reconfigureInputContext()
+     }
+ #endif
+ 
+-    qCDebug(lcQpaWayland) << "using input method:" << inputContext()->metaObject()->className();
++    qCDebug(lcQpaWayland) << "using input method:" << (inputContext() ? inputContext()->metaObject()->className() : "<none>");
+ }
+ 
+ QWaylandShellIntegration *QWaylandIntegration::createShellIntegration(const QString &integrationName)
+diff --git a/qtwayland/src/client/qwaylandintegration_p.h b/qtwayland/src/client/qwaylandintegration_p.h
+index ff70ae25..73b80658 100644
+--- a/qtwayland/src/client/qwaylandintegration_p.h
++++ b/qtwayland/src/client/qwaylandintegration_p.h
+@@ -107,6 +107,8 @@ public:
+ 
+     QWaylandDisplay *display() const;
+ 
++    Qt::KeyboardModifiers queryKeyboardModifiers() const override;
++
+     QList<int> possibleKeys(const QKeyEvent *event) const override;
+ 
+     QStringList themeNames() const override;
+diff --git a/qtwayland/src/client/qwaylandprimaryselectionv1.cpp b/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
+index 832f9678..ea508771 100644
+--- a/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
++++ b/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
+@@ -54,11 +54,6 @@ QWaylandPrimarySelectionDeviceManagerV1::QWaylandPrimarySelectionDeviceManagerV1
+     : zwp_primary_selection_device_manager_v1(display->wl_registry(), id, qMin(version, uint(1)))
+     , m_display(display)
+ {
+-    // Create devices for all seats.
+-    // This only works if we get the global before all devices
+-    const auto seats = m_display->inputDevices();
+-    for (auto *seat : seats)
+-        seat->setPrimarySelectionDevice(createDevice(seat));
+ }
+ 
+ QWaylandPrimarySelectionDeviceV1 *QWaylandPrimarySelectionDeviceManagerV1::createDevice(QWaylandInputDevice *seat)
+diff --git a/qtwayland/src/client/qwaylandscreen.cpp b/qtwayland/src/client/qwaylandscreen.cpp
+index 6cb337de..5537dafd 100644
+--- a/qtwayland/src/client/qwaylandscreen.cpp
++++ b/qtwayland/src/client/qwaylandscreen.cpp
+@@ -60,7 +60,7 @@ QWaylandXdgOutputManagerV1::QWaylandXdgOutputManagerV1(QWaylandDisplay* display,
+ }
+ 
+ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uint32_t id)
+-    : QtWayland::wl_output(waylandDisplay->wl_registry(), id, qMin(version, 2))
++    : QtWayland::wl_output(waylandDisplay->wl_registry(), id, qMin(version, 3))
+     , m_outputId(id)
+     , mWaylandDisplay(waylandDisplay)
+     , mOutputName(QStringLiteral("Screen%1").arg(id))
+@@ -72,7 +72,7 @@ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uin
+         qCWarning(lcQpaWayland) << "wl_output done event not supported by compositor,"
+                                 << "QScreen may not work correctly";
+         mWaylandDisplay->forceRoundTrip(); // Give the compositor a chance to send geometry etc.
+-        mOutputDone = true; // Fake the done event
++        mProcessedEvents |= OutputDoneEvent; // Fake the done event
+         maybeInitialize();
+     }
+ }
+@@ -81,16 +81,29 @@ QWaylandScreen::~QWaylandScreen()
+ {
+     if (zxdg_output_v1::isInitialized())
+         zxdg_output_v1::destroy();
++    if (wl_output::isInitialized() && wl_output_get_version(wl_output::object()) >= WL_OUTPUT_RELEASE_SINCE_VERSION)
++        wl_output::release();
++}
++
++uint QWaylandScreen::requiredEvents() const
++{
++    uint ret = OutputDoneEvent;
++
++    if (mWaylandDisplay->xdgOutputManager()) {
++        ret |= XdgOutputNameEvent;
++
++        if (mWaylandDisplay->xdgOutputManager()->version() < 3)
++            ret |= XdgOutputDoneEvent;
++    }
++    return ret;
+ }
+ 
+ void QWaylandScreen::maybeInitialize()
+ {
+     Q_ASSERT(!mInitialized);
+ 
+-    if (!mOutputDone)
+-        return;
+-
+-    if (mWaylandDisplay->xdgOutputManager() && !mXdgOutputDone)
++    const uint requiredEvents = this->requiredEvents();
++    if ((mProcessedEvents & requiredEvents) != requiredEvents)
+         return;
+ 
+     mInitialized = true;
+@@ -276,9 +289,8 @@ void QWaylandScreen::output_scale(int32_t factor)
+ 
+ void QWaylandScreen::output_done()
+ {
+-    mOutputDone = true;
+-    if (zxdg_output_v1::isInitialized() && mWaylandDisplay->xdgOutputManager()->version() >= 3)
+-        mXdgOutputDone = true;
++    mProcessedEvents |= OutputDoneEvent;
++
+     if (mInitialized) {
+         updateOutputProperties();
+         if (zxdg_output_v1::isInitialized())
+@@ -339,7 +351,7 @@ void QWaylandScreen::zxdg_output_v1_done()
+     if (Q_UNLIKELY(mWaylandDisplay->xdgOutputManager()->version() >= 3))
+         qWarning(lcQpaWayland) << "zxdg_output_v1.done received on version 3 or newer, this is most likely a bug in the compositor";
+ 
+-    mXdgOutputDone = true;
++    mProcessedEvents |= XdgOutputDoneEvent;
+     if (mInitialized)
+         updateXdgOutputProperties();
+     else
+@@ -348,7 +360,11 @@ void QWaylandScreen::zxdg_output_v1_done()
+ 
+ void QWaylandScreen::zxdg_output_v1_name(const QString &name)
+ {
++    if (Q_UNLIKELY(mInitialized))
++        qWarning(lcQpaWayland) << "zxdg_output_v1.name received after output has been initialized, this is most likely a bug in the compositor";
++
+     mOutputName = name;
++    mProcessedEvents |= XdgOutputNameEvent;
+ }
+ 
+ void QWaylandScreen::updateXdgOutputProperties()
+diff --git a/qtwayland/src/client/qwaylandscreen_p.h b/qtwayland/src/client/qwaylandscreen_p.h
+index df1c94f2..050cfdc0 100644
+--- a/qtwayland/src/client/qwaylandscreen_p.h
++++ b/qtwayland/src/client/qwaylandscreen_p.h
+@@ -116,6 +116,13 @@ public:
+     static QWaylandScreen *fromWlOutput(::wl_output *output);
+ 
+ private:
++    enum Event : uint {
++        XdgOutputDoneEvent = 0x1,
++        OutputDoneEvent = 0x2,
++        XdgOutputNameEvent = 0x4,
++    };
++    uint requiredEvents() const;
++
+     void output_mode(uint32_t flags, int width, int height, int refresh) override;
+     void output_geometry(int32_t x, int32_t y,
+                          int32_t width, int32_t height,
+@@ -148,8 +155,7 @@ private:
+     QSize mPhysicalSize;
+     QString mOutputName;
+     Qt::ScreenOrientation m_orientation = Qt::PrimaryOrientation;
+-    bool mOutputDone = false;
+-    bool mXdgOutputDone = false;
++    uint mProcessedEvents = 0;
+     bool mInitialized = false;
+ 
+ #if QT_CONFIG(cursor)
+diff --git a/qtwayland/src/client/qwaylandshmbackingstore.cpp b/qtwayland/src/client/qwaylandshmbackingstore.cpp
+index dc7ff670..41cffdf7 100644
+--- a/qtwayland/src/client/qwaylandshmbackingstore.cpp
++++ b/qtwayland/src/client/qwaylandshmbackingstore.cpp
+@@ -52,6 +52,7 @@
+ 
+ #include <QtWaylandClient/private/wayland-wayland-client-protocol.h>
+ 
++#include <fcntl.h>
+ #include <unistd.h>
+ #include <sys/mman.h>
+ 
+@@ -61,6 +62,9 @@
+ #  ifndef MFD_CLOEXEC
+ #    define MFD_CLOEXEC     0x0001U
+ #  endif
++#  ifndef MFD_ALLOW_SEALING
++#    define MFD_ALLOW_SEALING 0x0002U
++#  endif
+ #endif
+ 
+ QT_BEGIN_NAMESPACE
+@@ -74,8 +78,10 @@ QWaylandShmBuffer::QWaylandShmBuffer(QWaylandDisplay *display,
+     int alloc = stride * size.height();
+     int fd = -1;
+ 
+-#ifdef SYS_memfd_create
+-    fd = syscall(SYS_memfd_create, "wayland-shm", MFD_CLOEXEC);
++#if defined(SYS_memfd_create) && defined(F_SEAL_SEAL)
++    fd = syscall(SYS_memfd_create, "wayland-shm", MFD_CLOEXEC | MFD_ALLOW_SEALING);
++    if (fd >= 0)
++        fcntl(fd, F_ADD_SEALS, F_SEAL_SHRINK | F_SEAL_SEAL);
+ #endif
+ 
+     QScopedPointer<QFile> filePointer;
+diff --git a/qtwayland/src/client/qwaylandwindow.cpp b/qtwayland/src/client/qwaylandwindow.cpp
+index cb82857a..fb2c59dc 100644
+--- a/qtwayland/src/client/qwaylandwindow.cpp
++++ b/qtwayland/src/client/qwaylandwindow.cpp
+@@ -76,7 +76,6 @@ QWaylandWindow *QWaylandWindow::mMouseGrab = nullptr;
+ QWaylandWindow::QWaylandWindow(QWindow *window, QWaylandDisplay *display)
+     : QPlatformWindow(window)
+     , mDisplay(display)
+-    , mFrameQueue(mDisplay->createFrameQueue())
+     , mResizeAfterSwap(qEnvironmentVariableIsSet("QT_WAYLAND_RESIZE_AFTER_SWAP"))
+ {
+     {
+@@ -95,9 +94,6 @@ QWaylandWindow::QWaylandWindow(QWindow *window, QWaylandDisplay *display)
+ 
+ QWaylandWindow::~QWaylandWindow()
+ {
+-    mDisplay->destroyFrameQueue(mFrameQueue);
+-    mDisplay->handleWindowDestroyed(this);
+-
+     delete mWindowDecoration;
+ 
+     if (mSurface)
+@@ -243,6 +239,7 @@ bool QWaylandWindow::shouldCreateSubSurface() const
+ 
+ void QWaylandWindow::reset()
+ {
++    closeChildPopups();
+     delete mShellSurface;
+     mShellSurface = nullptr;
+     delete mSubSurfaceWindow;
+@@ -255,17 +252,22 @@ void QWaylandWindow::reset()
+         mSurface.reset();
+     }
+ 
+-    if (mFrameCallback) {
+-        wl_callback_destroy(mFrameCallback);
+-        mFrameCallback = nullptr;
+-    }
++    {
++        QMutexLocker lock(&mFrameSyncMutex);
++        if (mFrameCallback) {
++            wl_callback_destroy(mFrameCallback);
++            mFrameCallback = nullptr;
++        }
+ 
+-    mFrameCallbackElapsedTimer.invalidate();
+-    mWaitingForFrameCallback = false;
++        mFrameCallbackElapsedTimer.invalidate();
++        mWaitingForFrameCallback = false;
++    }
+     mFrameCallbackTimedOut = false;
+ 
+     mMask = QRegion();
+     mQueuedBuffer = nullptr;
++
++    mDisplay->handleWindowDestroyed(this);
+ }
+ 
+ QWaylandWindow *QWaylandWindow::fromWlSurface(::wl_surface *surface)
+@@ -351,19 +353,25 @@ void QWaylandWindow::setGeometry_helper(const QRect &rect)
+     }
+ }
+ 
+-void QWaylandWindow::setGeometry(const QRect &rect)
++void QWaylandWindow::setGeometry(const QRect &r)
+ {
++    auto rect = r;
++    if (fixedToplevelPositions && !QPlatformWindow::parent() && window()->type() != Qt::Popup
++        && window()->type() != Qt::ToolTip) {
++        rect.moveTo(screen()->geometry().topLeft());
++    }
+     setGeometry_helper(rect);
+ 
+     if (window()->isVisible() && rect.isValid()) {
+         if (mWindowDecoration)
+             mWindowDecoration->update();
+ 
+-        if (mResizeAfterSwap && windowType() == Egl && mSentInitialResize)
++        if (mResizeAfterSwap && windowType() == Egl && mSentInitialResize) {
++            QMutexLocker lock(&mResizeLock);
+             mResizeDirty = true;
+-        else
++        } else {
+             QWindowSystemInterface::handleGeometryChange(window(), geometry());
+-
++        }
+         mSentInitialResize = true;
+     }
+     QRect exposeGeometry(QPoint(), geometry().size());
+@@ -374,7 +382,7 @@ void QWaylandWindow::setGeometry(const QRect &rect)
+         mShellSurface->setWindowGeometry(windowContentGeometry());
+ 
+     if (isOpaque() && mMask.isEmpty())
+-        setOpaqueArea(rect);
++        setOpaqueArea(QRect(QPoint(0, 0), rect.size()));
+ }
+ 
+ void QWaylandWindow::resizeFromApplyConfigure(const QSize &sizeWithMargins, const QPoint &offset)
+@@ -399,21 +407,6 @@ void QWaylandWindow::sendExposeEvent(const QRect &rect)
+     mLastExposeGeometry = rect;
+ }
+ 
+-
+-static QVector<QPointer<QWaylandWindow>> activePopups;
+-
+-void QWaylandWindow::closePopups(QWaylandWindow *parent)
+-{
+-    while (!activePopups.isEmpty()) {
+-        auto popup = activePopups.takeLast();
+-        if (popup.isNull())
+-            continue;
+-        if (popup.data() == parent)
+-            return;
+-        popup->reset();
+-    }
+-}
+-
+ QPlatformScreen *QWaylandWindow::calculateScreenFromSurfaceEvents() const
+ {
+     QReadLocker lock(&mSurfaceLock);
+@@ -433,10 +426,7 @@ void QWaylandWindow::setVisible(bool visible)
+     lastVisible = visible;
+ 
+     if (visible) {
+-        if (window()->type() == Qt::Popup || window()->type() == Qt::ToolTip)
+-            activePopups << this;
+         initWindow();
+-        mDisplay->flushRequests();
+ 
+         setGeometry(windowGeometry());
+         // Don't flush the events here, or else the newly visible window may start drawing, but since
+@@ -444,7 +434,6 @@ void QWaylandWindow::setVisible(bool visible)
+         // QWaylandShmBackingStore::beginPaint().
+     } else {
+         sendExposeEvent(QRect());
+-        closePopups(this);
+         reset();
+     }
+ }
+@@ -556,12 +545,12 @@ void QWaylandWindow::sendRecursiveExposeEvent()
+ 
+ void QWaylandWindow::attach(QWaylandBuffer *buffer, int x, int y)
+ {
+-    Q_ASSERT(!buffer->committed());
+     QReadLocker locker(&mSurfaceLock);
+     if (mSurface == nullptr)
+         return;
+ 
+     if (buffer) {
++        Q_ASSERT(!buffer->committed());
+         handleUpdate();
+         buffer->setBusy();
+ 
+@@ -583,7 +572,11 @@ void QWaylandWindow::damage(const QRect &rect)
+     if (mSurface == nullptr)
+         return;
+ 
+-    mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    const int s = scale();
++    if (mDisplay->compositorVersion() >= 4)
++        mSurface->damage_buffer(s * rect.x(), s * rect.y(), s * rect.width(), s * rect.height());
++    else
++        mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
+ }
+ 
+ void QWaylandWindow::safeCommit(QWaylandBuffer *buffer, const QRegion &damage)
+@@ -619,8 +612,14 @@ void QWaylandWindow::commit(QWaylandBuffer *buffer, const QRegion &damage)
+         return;
+ 
+     attachOffset(buffer);
+-    for (const QRect &rect: damage)
+-        mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    if (mDisplay->compositorVersion() >= 4) {
++        const int s = scale();
++        for (const QRect &rect: damage)
++            mSurface->damage_buffer(s * rect.x(), s * rect.y(), s * rect.width(), s * rect.height());
++    } else {
++        for (const QRect &rect: damage)
++            mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    }
+     Q_ASSERT(!buffer->committed());
+     buffer->setCommitted();
+     mSurface->commit();
+@@ -635,42 +634,53 @@ void QWaylandWindow::commit()
+ 
+ const wl_callback_listener QWaylandWindow::callbackListener = {
+     [](void *data, wl_callback *callback, uint32_t time) {
+-        Q_UNUSED(callback);
+         Q_UNUSED(time);
+         auto *window = static_cast<QWaylandWindow*>(data);
+-        window->handleFrameCallback();
++        window->handleFrameCallback(callback);
+     }
+ };
+ 
+-void QWaylandWindow::handleFrameCallback()
++void QWaylandWindow::handleFrameCallback(wl_callback* callback)
+ {
++    QMutexLocker locker(&mFrameSyncMutex);
++    if (!mFrameCallback) {
++        // This means the callback is already unset by QWaylandWindow::reset.
++        // The wl_callback object will be destroyed there too.
++        return;
++    }
++    Q_ASSERT(callback == mFrameCallback);
++    wl_callback_destroy(callback);
++    mFrameCallback = nullptr;
++
+     mWaitingForFrameCallback = false;
+     mFrameCallbackElapsedTimer.invalidate();
+ 
+     // The rest can wait until we can run it on the correct thread
+-    if (!mWaitingForUpdateDelivery) {
+-        auto doHandleExpose = [this]() {
+-            bool wasExposed = isExposed();
+-            mFrameCallbackTimedOut = false;
+-            if (!wasExposed && isExposed()) // Did setting mFrameCallbackTimedOut make the window exposed?
+-                sendExposeEvent(QRect(QPoint(), geometry().size()));
+-            if (wasExposed && hasPendingUpdateRequest())
+-                deliverUpdateRequest();
+-
+-            mWaitingForUpdateDelivery = false;
+-        };
++    auto doHandleExpose = [this]() {
++        mWaitingForUpdateDelivery.storeRelease(false);
++        bool wasExposed = isExposed();
++        mFrameCallbackTimedOut = false;
++        if (!wasExposed && isExposed()) // Did setting mFrameCallbackTimedOut make the window exposed?
++            sendExposeEvent(QRect(QPoint(), geometry().size()));
++        if (wasExposed && hasPendingUpdateRequest())
++            deliverUpdateRequest();
++    };
+ 
++    if (mWaitingForUpdateDelivery.testAndSetAcquire(false, true)) {
+         // Queued connection, to make sure we don't call handleUpdate() from inside waitForFrameSync()
+         // in the single-threaded case.
+-        mWaitingForUpdateDelivery = true;
+         QMetaObject::invokeMethod(this, doHandleExpose, Qt::QueuedConnection);
+     }
++
++    mFrameSyncWait.notify_all();
+ }
+ 
+ bool QWaylandWindow::waitForFrameSync(int timeout)
+ {
+-    QMutexLocker locker(mFrameQueue.mutex);
+-    mDisplay->dispatchQueueWhile(mFrameQueue.queue, [&]() { return mWaitingForFrameCallback; }, timeout);
++    QMutexLocker locker(&mFrameSyncMutex);
++
++    QDeadlineTimer deadline(timeout);
++    while (mWaitingForFrameCallback && mFrameSyncWait.wait(&mFrameSyncMutex, deadline)) { }
+ 
+     if (mWaitingForFrameCallback) {
+         qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
+@@ -868,6 +878,17 @@ bool QWaylandWindow::createDecoration()
+             subsurf->set_position(pos.x() + m.left(), pos.y() + m.top());
+         }
+         sendExposeEvent(QRect(QPoint(), geometry().size()));
++
++        // This is a special case where the buffer is recreated, but since
++        // the content rect remains the same, the widgets remain the same
++        // size and are not redrawn, leaving the new buffer empty. As a simple
++        // work-around, we trigger a full extra update whenever the client-side
++        // window decorations are toggled while the window is showing.
++        // Note: createDecoration() is sometimes called from the render thread
++        // of Qt Quick. This is essentially wrong and could potentially cause problems,
++        // but until the underlying issue has been fixed, we have to use invokeMethod()
++        // here to avoid asserts.
++        QMetaObject::invokeMethod(window(), &QWindow::requestUpdate);
+     }
+ 
+     return mWindowDecoration;
+@@ -1023,6 +1044,13 @@ void QWaylandWindow::handleScreensChanged()
+ 
+     QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->QPlatformScreen::screen());
+     mLastReportedScreen = newScreen;
++    if (fixedToplevelPositions && !QPlatformWindow::parent() && window()->type() != Qt::Popup
++        && window()->type() != Qt::ToolTip
++        && geometry().topLeft() != newScreen->geometry().topLeft()) {
++        auto geometry = this->geometry();
++        geometry.moveTo(newScreen->geometry().topLeft());
++        setGeometry(geometry);
++    }
+ 
+     int scale = newScreen->isPlaceholder() ? 1 : static_cast<QWaylandScreen *>(newScreen)->scale();
+     if (scale != mScale) {
+@@ -1094,10 +1122,18 @@ bool QWaylandWindow::setMouseGrabEnabled(bool grab)
+     return true;
+ }
+ 
++Qt::WindowStates QWaylandWindow::windowStates() const
++{
++    return mLastReportedWindowStates;
++}
++
+ void QWaylandWindow::handleWindowStatesChanged(Qt::WindowStates states)
+ {
+     createDecoration();
+-    QWindowSystemInterface::handleWindowStateChanged(window(), states, mLastReportedWindowStates);
++    Qt::WindowStates statesWithoutActive = states & ~Qt::WindowActive;
++    Qt::WindowStates lastStatesWithoutActive = mLastReportedWindowStates & ~Qt::WindowActive;
++    QWindowSystemInterface::handleWindowStateChanged(window(), statesWithoutActive,
++                                                     lastStatesWithoutActive);
+     mLastReportedWindowStates = states;
+ }
+ 
+@@ -1139,19 +1175,24 @@ void QWaylandWindow::timerEvent(QTimerEvent *event)
+     if (event->timerId() != mFrameCallbackCheckIntervalTimerId)
+         return;
+ 
+-    bool callbackTimerExpired = mFrameCallbackElapsedTimer.hasExpired(mFrameCallbackTimeout);
+-    if (!mFrameCallbackElapsedTimer.isValid() || callbackTimerExpired ) {
+-        killTimer(mFrameCallbackCheckIntervalTimerId);
+-        mFrameCallbackCheckIntervalTimerId = -1;
+-    }
+-    if (mFrameCallbackElapsedTimer.isValid() && callbackTimerExpired) {
+-        mFrameCallbackElapsedTimer.invalidate();
++    {
++        QMutexLocker lock(&mFrameSyncMutex);
+ 
+-        qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
+-        mFrameCallbackTimedOut = true;
+-        mWaitingForUpdate = false;
+-        sendExposeEvent(QRect());
++        bool callbackTimerExpired = mFrameCallbackElapsedTimer.hasExpired(mFrameCallbackTimeout);
++        if (!mFrameCallbackElapsedTimer.isValid() || callbackTimerExpired ) {
++            killTimer(mFrameCallbackCheckIntervalTimerId);
++            mFrameCallbackCheckIntervalTimerId = -1;
++        }
++        if (!mFrameCallbackElapsedTimer.isValid() || !callbackTimerExpired) {
++            return;
++        }
++        mFrameCallbackElapsedTimer.invalidate();
+     }
++
++    qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
++    mFrameCallbackTimedOut = true;
++    mWaitingForUpdate = false;
++    sendExposeEvent(QRect());
+ }
+ 
+ void QWaylandWindow::requestUpdate()
+@@ -1160,8 +1201,11 @@ void QWaylandWindow::requestUpdate()
+     Q_ASSERT(hasPendingUpdateRequest()); // should be set by QPA
+ 
+     // If we have a frame callback all is good and will be taken care of there
+-    if (mWaitingForFrameCallback)
+-        return;
++    {
++        QMutexLocker locker(&mFrameSyncMutex);
++        if (mWaitingForFrameCallback)
++            return;
++    }
+ 
+     // If we've already called deliverUpdateRequest(), but haven't seen any attach+commit/swap yet
+     // This is a somewhat redundant behavior and might indicate a bug in the calling code, so log
+@@ -1174,7 +1218,12 @@ void QWaylandWindow::requestUpdate()
+     // so use invokeMethod to delay the delivery a bit.
+     QMetaObject::invokeMethod(this, [this] {
+         // Things might have changed in the meantime
+-        if (hasPendingUpdateRequest() && !mWaitingForFrameCallback)
++        {
++            QMutexLocker locker(&mFrameSyncMutex);
++            if (mWaitingForFrameCallback)
++                return;
++        }
++        if (hasPendingUpdateRequest())
+             deliverUpdateRequest();
+     }, Qt::QueuedConnection);
+ }
+@@ -1185,19 +1234,18 @@ void QWaylandWindow::requestUpdate()
+ void QWaylandWindow::handleUpdate()
+ {
+     qCDebug(lcWaylandBackingstore) << "handleUpdate" << QThread::currentThread();
++
+     // TODO: Should sync subsurfaces avoid requesting frame callbacks?
+     QReadLocker lock(&mSurfaceLock);
+     if (!mSurface)
+         return;
+ 
+-    if (mFrameCallback) {
+-        wl_callback_destroy(mFrameCallback);
+-        mFrameCallback = nullptr;
+-    }
++    QMutexLocker locker(&mFrameSyncMutex);
++    if (mWaitingForFrameCallback)
++        return;
+ 
+-    QMutexLocker locker(mFrameQueue.mutex);
+     struct ::wl_surface *wrappedSurface = reinterpret_cast<struct ::wl_surface *>(wl_proxy_create_wrapper(mSurface->object()));
+-    wl_proxy_set_queue(reinterpret_cast<wl_proxy *>(wrappedSurface), mFrameQueue.queue);
++    wl_proxy_set_queue(reinterpret_cast<wl_proxy *>(wrappedSurface), mDisplay->frameEventQueue());
+     mFrameCallback = wl_surface_frame(wrappedSurface);
+     wl_proxy_wrapper_destroy(wrappedSurface);
+     wl_callback_add_listener(mFrameCallback, &QWaylandWindow::callbackListener, this);
+@@ -1207,6 +1255,8 @@ void QWaylandWindow::handleUpdate()
+     // Start a timer for handling the case when the compositor stops sending frame callbacks.
+     if (mFrameCallbackTimeout > 0) {
+         QMetaObject::invokeMethod(this, [this] {
++            QMutexLocker locker(&mFrameSyncMutex);
++
+             if (mWaitingForFrameCallback) {
+                 if (mFrameCallbackCheckIntervalTimerId < 0)
+                     mFrameCallbackCheckIntervalTimerId = startTimer(mFrameCallbackTimeout);
+@@ -1267,6 +1317,20 @@ void QWaylandWindow::setOpaqueArea(const QRegion &opaqueArea)
+     wl_region_destroy(region);
+ }
+ 
++void QWaylandWindow::addChildPopup(QWaylandWindow *surface) {
++    mChildPopups.append(surface);
++}
++
++void QWaylandWindow::removeChildPopup(QWaylandWindow *surface) {
++    mChildPopups.removeAll(surface);
++}
++
++void QWaylandWindow::closeChildPopups() {
++    while (!mChildPopups.isEmpty()) {
++        auto popup = mChildPopups.takeLast();
++        popup->reset();
++    }
++}
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/client/qwaylandwindow_p.h b/qtwayland/src/client/qwaylandwindow_p.h
+index 01337cff..2f219d8c 100644
+--- a/qtwayland/src/client/qwaylandwindow_p.h
++++ b/qtwayland/src/client/qwaylandwindow_p.h
+@@ -98,6 +98,9 @@ public:
+     QWaylandWindow(QWindow *window, QWaylandDisplay *display);
+     ~QWaylandWindow() override;
+ 
++    // Keep Toplevels position on the top left corner of their screen
++    static inline bool fixedToplevelPositions = true;
++
+     virtual WindowType windowType() const = 0;
+     virtual void ensureSize();
+     WId winId() const override;
+@@ -148,6 +151,7 @@ public:
+     void setWindowState(Qt::WindowStates states) override;
+     void setWindowFlags(Qt::WindowFlags flags) override;
+     void handleWindowStatesChanged(Qt::WindowStates states);
++    Qt::WindowStates windowStates() const;
+ 
+     void raise() override;
+     void lower() override;
+@@ -206,6 +210,10 @@ public:
+     void handleUpdate();
+     void deliverUpdateRequest() override;
+ 
++    void addChildPopup(QWaylandWindow* child);
++    void removeChildPopup(QWaylandWindow* child);
++    void closeChildPopups();
++
+ public slots:
+     void applyConfigure();
+ 
+@@ -215,7 +223,11 @@ signals:
+ 
+ protected:
+     QWaylandDisplay *mDisplay = nullptr;
++
++    // mSurface can be written by the main thread. Other threads should claim a read lock for access
++    mutable QReadWriteLock mSurfaceLock;
+     QScopedPointer<QWaylandSurface> mSurface;
++
+     QWaylandShellSurface *mShellSurface = nullptr;
+     QWaylandSubSurface *mSubSurfaceWindow = nullptr;
+     QVector<QWaylandSubSurface *> mChildren;
+@@ -225,13 +237,14 @@ protected:
+     Qt::MouseButtons mMousePressedInContentArea = Qt::NoButton;
+ 
+     WId mWindowId;
+-    bool mWaitingForFrameCallback = false;
+     bool mFrameCallbackTimedOut = false; // Whether the frame callback has timed out
+-    bool mWaitingForUpdateDelivery = false;
+     int mFrameCallbackCheckIntervalTimerId = -1;
+-    QElapsedTimer mFrameCallbackElapsedTimer;
+-    struct ::wl_callback *mFrameCallback = nullptr;
+-    QWaylandDisplay::FrameQueue mFrameQueue;
++    QAtomicInt mWaitingForUpdateDelivery = false;
++
++    bool mWaitingForFrameCallback = false; // Protected by mFrameSyncMutex
++    QElapsedTimer mFrameCallbackElapsedTimer; // Protected by mFrameSyncMutex
++    struct ::wl_callback *mFrameCallback = nullptr; // Protected by mFrameSyncMutex
++    QMutex mFrameSyncMutex;
+     QWaitCondition mFrameSyncWait;
+ 
+     // True when we have called deliverRequestUpdate, but the client has not yet attached a new buffer
+@@ -261,6 +274,8 @@ protected:
+     QWaylandBuffer *mQueuedBuffer = nullptr;
+     QRegion mQueuedBufferDamage;
+ 
++    QList<QPointer<QWaylandWindow>> mChildPopups;
++
+ private:
+     void setGeometry_helper(const QRect &rect);
+     void initWindow();
+@@ -283,12 +298,10 @@ private:
+     QRect mLastExposeGeometry;
+ 
+     static const wl_callback_listener callbackListener;
+-    void handleFrameCallback();
++    void handleFrameCallback(struct ::wl_callback* callback);
+ 
+     static QWaylandWindow *mMouseGrab;
+ 
+-    mutable QReadWriteLock mSurfaceLock;
+-
+     friend class QWaylandSubSurface;
+ };
+ 
+diff --git a/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h b/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
+index ccad0048..4cc9b3b8 100644
+--- a/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
++++ b/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
+@@ -73,11 +73,10 @@ public:
+         return true;
+     }
+     virtual QWaylandShellSurface *createShellSurface(QWaylandWindow *window) = 0;
++    // kept for binary compat with layer-shell-qt
+     virtual void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) {
+-        if (newFocus)
+-            m_display->handleWindowActivated(newFocus);
+-        if (oldFocus)
+-            m_display->handleWindowDeactivated(oldFocus);
++        Q_UNUSED(newFocus);
++        Q_UNUSED(oldFocus);
+     }
+     virtual void *nativeResourceForWindow(const QByteArray &resource, QWindow *window) {
+         Q_UNUSED(resource);
+diff --git a/qtwayland/src/compositor/configure.json b/qtwayland/src/compositor/configure.json
+index bcfd5215..da95d07b 100644
+--- a/qtwayland/src/compositor/configure.json
++++ b/qtwayland/src/compositor/configure.json
+@@ -7,6 +7,31 @@
+     "testDir": "../../config.tests",
+ 
+     "libraries": {
++        "wayland-client": {
++            "label": "Wayland client library",
++            "headers": "wayland-version.h",
++            "test": {
++                "main": [
++                    "#if WAYLAND_VERSION_MAJOR < 1",
++                    "# error Wayland 1.8.0 or higher required",
++                    "#endif",
++                    "#if WAYLAND_VERSION_MAJOR == 1",
++                    "# if WAYLAND_VERSION_MINOR < 8",
++                    "#  error Wayland 1.8.0 or higher required",
++                    "# endif",
++                    "# if WAYLAND_VERSION_MINOR == 8",
++                    "#  if WAYLAND_VERSION_MICRO < 0",
++                    "#   error Wayland 1.8.0 or higher required",
++                    "#  endif",
++                    "# endif",
++                    "#endif"
++                 ]
++            },
++            "sources": [
++                { "type": "pkgConfig", "args": "wayland-client" },
++                "-lwayland-client"
++            ]
++        },
+         "wayland-server": {
+             "label": "wayland-server",
+             "headers": "wayland-version.h",
+@@ -151,8 +176,7 @@
+                     "#endif"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "dmabuf-client-buffer": {
+             "label": "Linux Client dma-buf Buffer Sharing",
+@@ -176,8 +200,7 @@
+                     "return 0;"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "vulkan-server-buffer": {
+             "label": "Vulkan Buffer Sharing",
+@@ -195,7 +218,8 @@
+                     "exportAllocInfo.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR;",
+                     "return 0;"
+                 ]
+-            }
++            },
++            "use": "wayland-client"
+         }
+     },
+ 
+diff --git a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
+index 7889f575..64140672 100644
+--- a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
++++ b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
+@@ -40,6 +40,7 @@
+ #include "qwaylandeglwindow.h"
+ 
+ #include <QtWaylandClient/private/qwaylandscreen_p.h>
++#include <QtWaylandClient/private/qwaylandsurface_p.h>
+ #include "qwaylandglcontext.h"
+ 
+ #include <QtEglSupport/private/qeglconvenience_p.h>
+@@ -124,6 +125,7 @@ void QWaylandEglWindow::updateSurface(bool create)
+         }
+         mOffset = QPoint();
+     } else {
++        QReadLocker locker(&mSurfaceLock);
+         if (m_waylandEglWindow) {
+             int current_width, current_height;
+             static bool disableResizeCheck = qgetenv("QT_WAYLAND_DISABLE_RESIZECHECK").toInt();
+@@ -131,14 +133,16 @@ void QWaylandEglWindow::updateSurface(bool create)
+             if (!disableResizeCheck) {
+                 wl_egl_window_get_attached_size(m_waylandEglWindow, &current_width, &current_height);
+             }
+-            if (disableResizeCheck || (current_width != sizeWithMargins.width() || current_height != sizeWithMargins.height())) {
++            if (disableResizeCheck || (current_width != sizeWithMargins.width() || current_height != sizeWithMargins.height()) || m_requestedSize != sizeWithMargins) {
+                 wl_egl_window_resize(m_waylandEglWindow, sizeWithMargins.width(), sizeWithMargins.height(), mOffset.x(), mOffset.y());
++                m_requestedSize = sizeWithMargins;
+                 mOffset = QPoint();
+ 
+                 m_resize = true;
+             }
+-        } else if (create && wlSurface()) {
+-            m_waylandEglWindow = wl_egl_window_create(wlSurface(), sizeWithMargins.width(), sizeWithMargins.height());
++        } else if (create && mSurface) {
++            m_waylandEglWindow = wl_egl_window_create(mSurface->object(), sizeWithMargins.width(), sizeWithMargins.height());
++            m_requestedSize = sizeWithMargins;
+         }
+ 
+         if (!m_eglSurface && m_waylandEglWindow && create) {
+diff --git a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
+index 5b1f4d56..0079dfef 100644
+--- a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
++++ b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
+@@ -88,6 +88,7 @@ private:
+     mutable QOpenGLFramebufferObject *m_contentFBO = nullptr;
+ 
+     QSurfaceFormat m_format;
++    QSize m_requestedSize;
+ };
+ 
+ }
+diff --git a/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h b/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
+index 56a710c3..c6a8b6c6 100644
+--- a/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
++++ b/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
+@@ -41,6 +41,8 @@
+ #include <QtCore/QTextStream>
+ #include <QtGui/QOpenGLTexture>
+ 
++#include <array>
++
+ #include <EGL/egl.h>
+ #include <EGL/eglext.h>
+ 
+diff --git a/qtwayland/src/plugins/decorations/bradient/main.cpp b/qtwayland/src/plugins/decorations/bradient/main.cpp
+index e75fda3c..fa885143 100644
+--- a/qtwayland/src/plugins/decorations/bradient/main.cpp
++++ b/qtwayland/src/plugins/decorations/bradient/main.cpp
+@@ -164,13 +164,10 @@ void QWaylandBradientDecoration::paint(QPaintDevice *device)
+     // Window icon
+     QIcon icon = waylandWindow()->windowIcon();
+     if (!icon.isNull()) {
+-        QPixmap pixmap = icon.pixmap(QSize(128, 128));
+-        QPixmap scaled = pixmap.scaled(22, 22, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+-
+         QRectF iconRect(0, 0, 22, 22);
+-        p.drawPixmap(iconRect.adjusted(margins().left() + BUTTON_SPACING, 4,
+-                                       margins().left() + BUTTON_SPACING, 4),
+-                     scaled, iconRect);
++        iconRect.adjust(margins().left() + BUTTON_SPACING, 4,
++                        margins().left() + BUTTON_SPACING, 4),
++        icon.paint(&p, iconRect.toRect());
+     }
+ 
+     // Window title
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
+index 85d25e3c..60bdd491 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
+@@ -47,18 +47,21 @@ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
+-QWaylandXdgPopupV5::QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow *window)
++QWaylandXdgPopupV5::QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow* parent, QWaylandWindow *window)
+     : QWaylandShellSurface(window)
+     , QtWayland::xdg_popup_v5(popup)
++    , m_parent(parent)
+     , m_window(window)
+ {
+     if (window->display()->windowExtension())
+         m_extendedWindow = new QWaylandExtendedSurface(window);
++    m_parent->addChildPopup(m_window);
+ }
+ 
+ QWaylandXdgPopupV5::~QWaylandXdgPopupV5()
+ {
+     xdg_popup_destroy(object());
++    m_parent->removeChildPopup(m_window);
+     delete m_extendedWindow;
+ }
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
+index 7494f6a6..d85f130b 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
+@@ -70,7 +70,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgPopupV5 : public QWaylandShellSurface
+ {
+     Q_OBJECT
+ public:
+-    QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow *window);
++    QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow* parent, QWaylandWindow *window);
+     ~QWaylandXdgPopupV5() override;
+ 
+ protected:
+@@ -78,6 +78,7 @@ protected:
+ 
+ private:
+     QWaylandExtendedSurface *m_extendedWindow = nullptr;
++    QWaylandWindow *m_parent = nullptr;
+     QWaylandWindow *m_window = nullptr;
+ };
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
+index 7e242c4a..def8452a 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
+@@ -84,7 +84,7 @@ QWaylandXdgPopupV5 *QWaylandXdgShellV5::createXdgPopup(QWaylandWindow *window, Q
+     int x = position.x() + parentWindow->frameMargins().left();
+     int y = position.y() + parentWindow->frameMargins().top();
+ 
+-    auto popup = new QWaylandXdgPopupV5(get_xdg_popup(window->wlSurface(), parentSurface, seat, m_popupSerial, x, y), window);
++    auto popup = new QWaylandXdgPopupV5(get_xdg_popup(window->wlSurface(), parentSurface, seat, m_popupSerial, x, y), parentWindow, window);
+     m_popups.append(window);
+     QObject::connect(popup, &QWaylandXdgPopupV5::destroyed, [this, window](){
+         m_popups.removeOne(window);
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
+index 4e25949f..cfc60939 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
+@@ -85,13 +85,6 @@ QWaylandShellSurface *QWaylandXdgShellV5Integration::createShellSurface(QWayland
+     return m_xdgShell->createXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellV5Integration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) {
+-    if (newFocus && qobject_cast<QWaylandXdgPopupV5 *>(newFocus->shellSurface()))
+-        m_display->handleWindowActivated(newFocus);
+-    if (oldFocus && qobject_cast<QWaylandXdgPopupV5 *>(oldFocus->shellSurface()))
+-        m_display->handleWindowDeactivated(oldFocus);
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
+index ce6bdb9e..aed88670 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
+@@ -67,7 +67,6 @@ public:
+     QWaylandXdgShellV5Integration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShellV5> m_xdgShell;
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
+index 8c371661..151c78e3 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
+@@ -174,6 +174,7 @@ QWaylandXdgSurfaceV6::Popup::Popup(QWaylandXdgSurfaceV6 *xdgSurface, QWaylandXdg
+     , m_xdgSurface(xdgSurface)
+     , m_parent(parent)
+ {
++    m_parent->window()->addChildPopup(m_xdgSurface->window());
+ }
+ 
+ QWaylandXdgSurfaceV6::Popup::~Popup()
+@@ -181,6 +182,8 @@ QWaylandXdgSurfaceV6::Popup::~Popup()
+     if (isInitialized())
+         destroy();
+ 
++    m_parent->window()->removeChildPopup(m_xdgSurface->window());
++
+     if (m_grabbing) {
+         auto *shell = m_xdgSurface->m_shell;
+         Q_ASSERT(shell->m_topmostGrabbingPopup == this);
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
+index 03164316..e8da8ba1 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
+@@ -68,20 +68,6 @@ QWaylandShellSurface *QWaylandXdgShellV6Integration::createShellSurface(QWayland
+     return m_xdgShell->getXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellV6Integration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus)
+-{
+-    if (newFocus) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurfaceV6 *>(newFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowActivated(newFocus);
+-    }
+-    if (oldFocus && qobject_cast<QWaylandXdgSurfaceV6 *>(oldFocus->shellSurface())) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurfaceV6 *>(oldFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowDeactivated(oldFocus);
+-    }
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
+index 261f8cbb..c1bcd5c6 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
+@@ -65,7 +65,6 @@ public:
+     QWaylandXdgShellV6Integration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShellV6> m_xdgShell;
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
+index f3e3c330..fa6d5808 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
+@@ -67,11 +67,6 @@ QWaylandXdgSurface::Toplevel::Toplevel(QWaylandXdgSurface *xdgSurface)
+ 
+ QWaylandXdgSurface::Toplevel::~Toplevel()
+ {
+-    if (m_applied.states & Qt::WindowActive) {
+-        QWaylandWindow *window = m_xdgSurface->window();
+-        window->display()->handleWindowDeactivated(window);
+-    }
+-
+     // The protocol spec requires that the decoration object is deleted before xdg_toplevel.
+     delete m_decoration;
+     m_decoration = nullptr;
+@@ -85,16 +80,15 @@ void QWaylandXdgSurface::Toplevel::applyConfigure()
+     if (!(m_applied.states & (Qt::WindowMaximized|Qt::WindowFullScreen)))
+         m_normalSize = m_xdgSurface->m_window->windowFrameGeometry().size();
+ 
+-    if ((m_pending.states & Qt::WindowActive) && !(m_applied.states & Qt::WindowActive))
++    if ((m_pending.states & Qt::WindowActive) && !(m_applied.states & Qt::WindowActive)
++        && !m_xdgSurface->m_window->display()->isKeyboardAvailable())
+         m_xdgSurface->m_window->display()->handleWindowActivated(m_xdgSurface->m_window);
+ 
+-    if (!(m_pending.states & Qt::WindowActive) && (m_applied.states & Qt::WindowActive))
++    if (!(m_pending.states & Qt::WindowActive) && (m_applied.states & Qt::WindowActive)
++        && !m_xdgSurface->m_window->display()->isKeyboardAvailable())
+         m_xdgSurface->m_window->display()->handleWindowDeactivated(m_xdgSurface->m_window);
+ 
+-    // TODO: none of the other plugins send WindowActive either, but is it on purpose?
+-    Qt::WindowStates statesWithoutActive = m_pending.states & ~Qt::WindowActive;
+-
+-    m_xdgSurface->m_window->handleWindowStatesChanged(statesWithoutActive);
++    m_xdgSurface->m_window->handleWindowStatesChanged(m_pending.states);
+ 
+     if (m_pending.size.isEmpty()) {
+         // An empty size in the configure means it's up to the client to choose the size
+@@ -105,8 +99,6 @@ void QWaylandXdgSurface::Toplevel::applyConfigure()
+         m_xdgSurface->m_window->resizeFromApplyConfigure(m_pending.size);
+     }
+ 
+-    m_xdgSurface->setSizeHints();
+-
+     m_applied = m_pending;
+     qCDebug(lcQpaWayland) << "Applied pending xdg_toplevel configure event:" << m_applied.size << m_applied.states;
+ }
+@@ -203,12 +195,17 @@ QtWayland::xdg_toplevel::resize_edge QWaylandXdgSurface::Toplevel::convertToResi
+                 | ((edges & Qt::RightEdge) ? resize_edge_right : 0));
+ }
+ 
+-QWaylandXdgSurface::Popup::Popup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parent,
++QWaylandXdgSurface::Popup::Popup(QWaylandXdgSurface *xdgSurface, QWaylandWindow *parent,
+                                  QtWayland::xdg_positioner *positioner)
+-    : xdg_popup(xdgSurface->get_popup(parent->object(), positioner->object()))
+-    , m_xdgSurface(xdgSurface)
++    : m_xdgSurface(xdgSurface)
++    , m_parentXdgSurface(qobject_cast<QWaylandXdgSurface *>(parent->shellSurface()))
+     , m_parent(parent)
+ {
++
++    init(xdgSurface->get_popup(m_parentXdgSurface ? m_parentXdgSurface->object() : nullptr, positioner->object()));
++    if (m_parent) {
++        m_parent->addChildPopup(m_xdgSurface->window());
++    }
+ }
+ 
+ QWaylandXdgSurface::Popup::~Popup()
+@@ -216,10 +213,24 @@ QWaylandXdgSurface::Popup::~Popup()
+     if (isInitialized())
+         destroy();
+ 
++    if (m_parent) {
++        m_parent->removeChildPopup(m_xdgSurface->window());
++    }
++
+     if (m_grabbing) {
+         auto *shell = m_xdgSurface->m_shell;
+         Q_ASSERT(shell->m_topmostGrabbingPopup == this);
+-        shell->m_topmostGrabbingPopup = m_parent->m_popup;
++        shell->m_topmostGrabbingPopup = m_parentXdgSurface ? m_parentXdgSurface->m_popup : nullptr;
++        m_grabbing = false;
++
++        // Synthesize Qt enter/leave events for popup
++        QWindow *leave = nullptr;
++        if (m_xdgSurface && m_xdgSurface->window())
++            leave = m_xdgSurface->window()->window();
++        QWindowSystemInterface::handleLeaveEvent(leave);
++
++        if (QWindow *enter = QGuiApplication::topLevelAt(QCursor::pos()))
++            QWindowSystemInterface::handleEnterEvent(enter, enter->mapFromGlobal(QCursor::pos()), QCursor::pos());
+     }
+ }
+ 
+@@ -257,6 +268,7 @@ QWaylandXdgSurface::QWaylandXdgSurface(QWaylandXdgShell *shell, ::xdg_surface *s
+                 m_toplevel->set_parent(parentXdgSurface->m_toplevel->object());
+         }
+     }
++    setSizeHints();
+ }
+ 
+ QWaylandXdgSurface::~QWaylandXdgSurface()
+@@ -400,8 +412,6 @@ void QWaylandXdgSurface::setPopup(QWaylandWindow *parent)
+ {
+     Q_ASSERT(!m_toplevel && !m_popup);
+ 
+-    auto parentXdgSurface = static_cast<QWaylandXdgSurface *>(parent->shellSurface());
+-
+     auto positioner = new QtWayland::xdg_positioner(m_shell->create_positioner());
+     // set_popup expects a position relative to the parent
+     QPoint transientPos = m_window->geometry().topLeft(); // this is absolute
+@@ -414,8 +424,9 @@ void QWaylandXdgSurface::setPopup(QWaylandWindow *parent)
+     positioner->set_anchor(QtWayland::xdg_positioner::anchor_top_left);
+     positioner->set_gravity(QtWayland::xdg_positioner::gravity_bottom_right);
+     positioner->set_size(m_window->geometry().width(), m_window->geometry().height());
+-    m_popup = new Popup(this, parentXdgSurface, positioner);
++    m_popup = new Popup(this, parent, positioner);
+     positioner->destroy();
++
+     delete positioner;
+ }
+ 
+@@ -437,6 +448,23 @@ void QWaylandXdgSurface::setGrabPopup(QWaylandWindow *parent, QWaylandInputDevic
+     }
+     setPopup(parent);
+     m_popup->grab(device, serial);
++
++    // Synthesize Qt enter/leave events for popup
++    if (!parent)
++        return;
++    QWindow *current = QGuiApplication::topLevelAt(QCursor::pos());
++    QWindow *leave = parent->window();
++    if (current != leave)
++        return;
++
++    QWindowSystemInterface::handleLeaveEvent(leave);
++
++    QWindow *enter = nullptr;
++    if (m_popup && m_popup->m_xdgSurface && m_popup->m_xdgSurface->window())
++        enter = m_popup->m_xdgSurface->window()->window();
++
++    if (enter)
++        QWindowSystemInterface::handleEnterEvent(enter, enter->mapFromGlobal(QCursor::pos()), QCursor::pos());
+ }
+ 
+ void QWaylandXdgSurface::xdg_surface_configure(uint32_t serial)
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
+index 96785205..4b518f0a 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
+@@ -131,14 +131,15 @@ private:
+ 
+     class Popup : public QtWayland::xdg_popup {
+     public:
+-        Popup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parent, QtWayland::xdg_positioner *positioner);
++        Popup(QWaylandXdgSurface *xdgSurface, QWaylandWindow *parent, QtWayland::xdg_positioner *positioner);
+         ~Popup() override;
+ 
+         void grab(QWaylandInputDevice *seat, uint serial);
+         void xdg_popup_popup_done() override;
+ 
+         QWaylandXdgSurface *m_xdgSurface = nullptr;
+-        QWaylandXdgSurface *m_parent = nullptr;
++        QWaylandXdgSurface *m_parentXdgSurface = nullptr;
++        QWaylandWindow *m_parent = nullptr;
+         bool m_grabbing = false;
+     };
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
+index 8769d971..da0dd6a7 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
+@@ -69,20 +69,6 @@ QWaylandShellSurface *QWaylandXdgShellIntegration::createShellSurface(QWaylandWi
+     return m_xdgShell->getXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellIntegration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus)
+-{
+-    if (newFocus) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurface *>(newFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowActivated(newFocus);
+-    }
+-    if (oldFocus && qobject_cast<QWaylandXdgSurface *>(oldFocus->shellSurface())) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurface *>(oldFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowDeactivated(oldFocus);
+-    }
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
+index b6caa6c9..2f929f98 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
+@@ -65,7 +65,6 @@ public:
+     QWaylandXdgShellIntegration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShell> m_xdgShell;
+diff --git a/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp b/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
+index 526d0ef4..f50ccf30 100644
+--- a/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
++++ b/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
+@@ -39,7 +39,10 @@
+ 
+ #include "qwaylandinputmethodeventbuilder_p.h"
+ 
++#include <QBrush>
++#include <QGuiApplication>
+ #include <QInputMethod>
++#include <QPalette>
+ #include <QTextCharFormat>
+ 
+ #ifdef QT_BUILD_WAYLANDCOMPOSITOR_LIB
+@@ -81,32 +84,38 @@ void QWaylandInputMethodEventBuilder::addPreeditStyling(uint32_t index, uint32_t
+     QTextCharFormat format;
+ 
+     switch (style) {
+-    case 0:
+-    case 1:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_NONE:
++        break;
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_DEFAULT:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_UNDERLINE:
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-    case 2:
+-    case 3:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_ACTIVE:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_INACTIVE:
+         format.setFontWeight(QFont::Bold);
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-    case 4:
+-        format.setFontUnderline(true);
+-        format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+-        m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_HIGHLIGHT:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_SELECTION:
++        {
++            format.setFontUnderline(true);
++            format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
++            QPalette palette = qApp->palette();
++            format.setBackground(QBrush(palette.color(QPalette::Active, QPalette::Highlight)));
++            format.setForeground(QBrush(palette.color(QPalette::Active, QPalette::HighlightedText)));
++            m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
++        }
+         break;
+-    case 5:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_INCORRECT:
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::WaveUnderline);
+         format.setUnderlineColor(QColor(Qt::red));
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-//    case QtWayland::wl_text_input::preedit_style_selection:
+-//    case QtWayland::wl_text_input::preedit_style_none:
+     default:
+         break;
+     }
+@@ -153,7 +162,7 @@ QInputMethodEvent QWaylandInputMethodEventBuilder::buildPreedit(const QString &t
+ 
+     if (m_preeditCursor < 0) {
+         attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, 0, QVariant()));
+-    } else if (m_preeditCursor > 0) {
++    } else {
+         attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, indexFromWayland(text, m_preeditCursor), 1, QVariant()));
+     }
+ 
+diff --git a/qtwayland/src/shared/qwaylandmimehelper.cpp b/qtwayland/src/shared/qwaylandmimehelper.cpp
+index a5fdd34d..e2fe1928 100644
+--- a/qtwayland/src/shared/qwaylandmimehelper.cpp
++++ b/qtwayland/src/shared/qwaylandmimehelper.cpp
+@@ -60,7 +60,7 @@ QByteArray QWaylandMimeHelper::getByteArray(QMimeData *mimeData, const QString &
+             buf.open(QIODevice::ReadWrite);
+             QByteArray fmt = "BMP";
+             if (mimeType.startsWith(QLatin1String("image/"))) {
+-                QByteArray imgFmt = mimeType.mid(6).toUpper().toLatin1();
++                QByteArray imgFmt = mimeType.mid(6).toLower().toLatin1();
+                 if (QImageWriter::supportedImageFormats().contains(imgFmt))
+                     fmt = imgFmt;
+             }
+@@ -74,7 +74,7 @@ QByteArray QWaylandMimeHelper::getByteArray(QMimeData *mimeData, const QString &
+         QList<QUrl> urls = mimeData->urls();
+         for (int i = 0; i < urls.count(); ++i) {
+             content.append(urls.at(i).toEncoded());
+-            content.append('\n');
++            content.append("\r\n");
+         }
+     } else {
+         content = mimeData->data(mimeType);
+diff --git a/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp b/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
+index 1568b3b9..067410d0 100644
+--- a/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
++++ b/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
+@@ -35,7 +35,7 @@
+ 
+ using namespace MockCompositor;
+ 
+-constexpr int dataDeviceVersion = 1;
++constexpr int dataDeviceVersion = 3;
+ 
+ class DataDeviceCompositor : public DefaultCompositor {
+ public:
+diff --git a/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp b/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
+index 9312c2e5..2ea382f1 100644
+--- a/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
++++ b/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
+@@ -73,6 +73,7 @@ private slots:
+     void multiTouch();
+     void multiTouchUpAndMotionFrame();
+     void tapAndMoveInSameFrame();
++    void cancelTouch();
+ };
+ 
+ void tst_seatv5::bindsToSeat()
+@@ -646,5 +647,34 @@ void tst_seatv5::tapAndMoveInSameFrame()
+     QTRY_COMPARE(window.m_events.last().touchPoints.first().state(), Qt::TouchPointState::TouchPointReleased);
+ }
+ 
++void tst_seatv5::cancelTouch()
++{
++    TouchWindow window;
++    QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
++
++    exec([=] {
++        auto *t = touch();
++        auto *c = client();
++        t->sendDown(xdgToplevel()->surface(), {32, 32}, 1);
++        t->sendFrame(c);
++        t->sendCancel(c);
++        t->sendFrame(c);
++    });
++
++    QTRY_VERIFY(!window.m_events.empty());
++    {
++        auto e = window.m_events.takeFirst();
++        QCOMPARE(e.type, QEvent::TouchBegin);
++        QCOMPARE(e.touchPointStates, Qt::TouchPointPressed);
++        QCOMPARE(e.touchPoints.length(), 1);
++        QCOMPARE(e.touchPoints.first().pos(), QPointF(32-window.frameMargins().left(), 32-window.frameMargins().top()));
++    }
++    {
++        auto e = window.m_events.takeFirst();
++        QCOMPARE(e.type, QEvent::TouchCancel);
++        QCOMPARE(e.touchPoints.length(), 0);
++    }
++}
++
+ QCOMPOSITOR_TEST_MAIN(tst_seatv5)
+ #include "tst_seatv5.moc"
+diff --git a/qtwayland/tests/auto/client/shared/corecompositor.cpp b/qtwayland/tests/auto/client/shared/corecompositor.cpp
+index 5c6c83ba..fa9b7662 100644
+--- a/qtwayland/tests/auto/client/shared/corecompositor.cpp
++++ b/qtwayland/tests/auto/client/shared/corecompositor.cpp
+@@ -27,6 +27,7 @@
+ ****************************************************************************/
+ 
+ #include "corecompositor.h"
++#include <thread>
+ 
+ namespace MockCompositor {
+ 
+diff --git a/qtwayland/tests/auto/client/shared/coreprotocol.cpp b/qtwayland/tests/auto/client/shared/coreprotocol.cpp
+index 0d988521..d1a2e7cb 100644
+--- a/qtwayland/tests/auto/client/shared/coreprotocol.cpp
++++ b/qtwayland/tests/auto/client/shared/coreprotocol.cpp
+@@ -451,6 +451,13 @@ void Touch::sendFrame(wl_client *client)
+         send_frame(r->handle);
+ }
+ 
++void Touch::sendCancel(wl_client *client)
++{
++    const auto touchResources = resourceMap().values(client);
++    for (auto *r : touchResources)
++        send_cancel(r->handle);
++}
++
+ uint Keyboard::sendEnter(Surface *surface)
+ {
+     auto serial = m_seat->m_compositor->nextSerial();
+diff --git a/qtwayland/tests/auto/client/shared/coreprotocol.h b/qtwayland/tests/auto/client/shared/coreprotocol.h
+index a1af137a..210d8ddb 100644
+--- a/qtwayland/tests/auto/client/shared/coreprotocol.h
++++ b/qtwayland/tests/auto/client/shared/coreprotocol.h
+@@ -158,7 +158,7 @@ class WlCompositor : public Global, public QtWaylandServer::wl_compositor
+ {
+     Q_OBJECT
+ public:
+-    explicit WlCompositor(CoreCompositor *compositor, int version = 3)
++    explicit WlCompositor(CoreCompositor *compositor, int version = 4)
+         : QtWaylandServer::wl_compositor(compositor->m_display, version)
+         , m_compositor(compositor)
+     {}
+@@ -364,6 +364,7 @@ public:
+     uint sendUp(wl_client *client, int id);
+     void sendMotion(wl_client *client, const QPointF &position, int id);
+     void sendFrame(wl_client *client);
++    void sendCancel(wl_client *client);
+ 
+     Seat *m_seat = nullptr;
+ };
+diff --git a/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp b/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
+index a415cbf5..b1d3d07d 100644
+--- a/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
++++ b/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
+@@ -342,7 +342,7 @@ Compositor::Compositor(MockCompositor *mockCompositor)
+         exit(EXIT_FAILURE);
+     }
+ 
+-    wl_global_create(m_display, &wl_compositor_interface, 1, this, bindCompositor);
++    wl_global_create(m_display, &wl_compositor_interface, 4, this, bindCompositor);
+ 
+     m_data_device_manager.reset(new DataDeviceManager(this, m_display));
+ 
+diff --git a/qtwayland/tests/auto/client/shared_old/mocksurface.cpp b/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
+index e9df5f90..c3246e4a 100644
+--- a/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
++++ b/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
+@@ -125,6 +125,16 @@ void Surface::surface_damage(Resource *resource,
+     Q_UNUSED(height);
+ }
+ 
++void Surface::surface_damage_buffer(Resource *resource,
++                                    int32_t x, int32_t y, int32_t width, int32_t height)
++{
++    Q_UNUSED(resource);
++    Q_UNUSED(x);
++    Q_UNUSED(y);
++    Q_UNUSED(width);
++    Q_UNUSED(height);
++}
++
+ void Surface::surface_frame(Resource *resource,
+                             uint32_t callback)
+ {
+diff --git a/qtwayland/tests/auto/client/shared_old/mocksurface.h b/qtwayland/tests/auto/client/shared_old/mocksurface.h
+index 949dc23d..d176837e 100644
+--- a/qtwayland/tests/auto/client/shared_old/mocksurface.h
++++ b/qtwayland/tests/auto/client/shared_old/mocksurface.h
+@@ -65,6 +65,8 @@ protected:
+                         struct wl_resource *buffer, int x, int y) override;
+     void surface_damage(Resource *resource,
+                         int32_t x, int32_t y, int32_t width, int32_t height) override;
++    void surface_damage_buffer(Resource *resource,
++                               int32_t x, int32_t y, int32_t width, int32_t height) override;
+     void surface_frame(Resource *resource,
+                        uint32_t callback) override;
+     void surface_commit(Resource *resource) override;
+diff --git a/qtwayland/tests/auto/client/surface/tst_surface.cpp b/qtwayland/tests/auto/client/surface/tst_surface.cpp
+index 95e4e609..60c672ce 100644
+--- a/qtwayland/tests/auto/client/surface/tst_surface.cpp
++++ b/qtwayland/tests/auto/client/surface/tst_surface.cpp
+@@ -129,6 +129,10 @@ void tst_surface::waitForFrameCallbackGl()
+     // Make sure we follow frame callbacks for some frames
+     for (int i = 0; i < 5; ++i) {
+         xdgPingAndWaitForPong(); // Make sure things have happened on the client
++        if (!qEnvironmentVariableIntValue("QT_WAYLAND_DISABLE_WINDOWDECORATION") && i == 0) {
++            QCOMPARE(bufferSpy.count(), 1);
++            bufferSpy.removeFirst();
++        }
+         exec([&] {
+             QVERIFY(bufferSpy.empty()); // Make sure no extra buffers have arrived
+             QVERIFY(!xdgToplevel()->surface()->m_waitingFrameCallbacks.empty());
+diff --git a/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp b/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
+index 2277bbb8..747875b4 100644
+--- a/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
++++ b/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
+@@ -31,6 +31,7 @@
+ #include <QtGui/QOpenGLWindow>
+ #include <QtGui/qpa/qplatformnativeinterface.h>
+ #include <QtWaylandClient/private/wayland-wayland-client-protocol.h>
++#include <QtWaylandClient/private/qwaylandwindow_p.h>
+ 
+ using namespace MockCompositor;
+ 
+@@ -45,6 +46,7 @@ private slots:
+     void configureStates();
+     void popup();
+     void tooltipOnPopup();
++    void tooltipAndSiblingPopup();
+     void switchPopups();
+     void hidePopupParent();
+     void pongs();
+@@ -138,6 +140,7 @@ void tst_xdgshell::configureSize()
+ 
+ void tst_xdgshell::configureStates()
+ {
++    QVERIFY(qputenv("QT_WAYLAND_FRAME_CALLBACK_TIMEOUT", "0"));
+     QRasterWindow window;
+     window.resize(64, 48);
+     window.show();
+@@ -154,9 +157,12 @@ void tst_xdgshell::configureStates()
+     // Toplevel windows don't know their position on xdg-shell
+ //    QCOMPARE(window.frameGeometry().topLeft(), QPoint()); // TODO: this doesn't currently work when window decorations are enabled
+ 
+-//    QEXPECT_FAIL("", "configure has already been acked, we shouldn't have to wait for isActive", Continue);
+-//    QVERIFY(window.isActive());
+-    QTRY_VERIFY(window.isActive()); // Just make sure it eventually get's set correctly
++    // window.windowstate() is driven by keyboard focus, however for decorations we want to follow
++    // XDGShell this is internal to QtWayland so it is queried directly
++    auto waylandWindow = static_cast<QtWaylandClient::QWaylandWindow *>(window.handle());
++    Q_ASSERT(waylandWindow);
++    QTRY_VERIFY(waylandWindow->windowStates().testFlag(
++            Qt::WindowActive)); // Just make sure it eventually get's set correctly
+ 
+     const QSize screenSize(640, 480);
+     const uint maximizedSerial = exec([=] {
+@@ -186,6 +192,7 @@ void tst_xdgshell::configureStates()
+     QCOMPARE(window.windowStates(), Qt::WindowNoState);
+     QCOMPARE(window.frameGeometry().size(), windowedSize);
+ //    QCOMPARE(window.frameGeometry().topLeft(), QPoint()); // TODO: this doesn't currently work when window decorations are enabled
++    QVERIFY(qunsetenv("QT_WAYLAND_FRAME_CALLBACK_TIMEOUT"));
+ }
+ 
+ void tst_xdgshell::popup()
+@@ -340,6 +347,92 @@ void tst_xdgshell::tooltipOnPopup()
+     QCOMPOSITOR_TRY_COMPARE(xdgPopup(0), nullptr);
+ }
+ 
++void tst_xdgshell::tooltipAndSiblingPopup()
++{
++    class ToolTip : public QRasterWindow {
++    public:
++        explicit ToolTip(QWindow *parent) {
++            setTransientParent(parent);
++            setFlags(Qt::ToolTip);
++            resize(100, 100);
++            show();
++        }
++        void mousePressEvent(QMouseEvent *event) override {
++            QRasterWindow::mousePressEvent(event);
++            m_popup = new QRasterWindow;
++            m_popup->setTransientParent(transientParent());
++            m_popup->setFlags(Qt::Popup);
++            m_popup->resize(100, 100);
++            m_popup->show();
++        }
++
++        QRasterWindow *m_popup = nullptr;
++    };
++
++    class Window : public QRasterWindow {
++    public:
++        void mousePressEvent(QMouseEvent *event) override {
++            QRasterWindow::mousePressEvent(event);
++            m_tooltip = new ToolTip(this);
++        }
++        ToolTip *m_tooltip = nullptr;
++    };
++
++    Window window;
++    window.resize(200, 200);
++    window.show();
++
++    QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
++    exec([=] { xdgToplevel()->sendCompleteConfigure(); });
++    QCOMPOSITOR_TRY_VERIFY(xdgToplevel()->m_xdgSurface->m_committedConfigureSerial);
++
++    exec([=] {
++        auto *surface = xdgToplevel()->surface();
++        auto *p = pointer();
++        auto *c = client();
++        p->sendEnter(surface, {100, 100});
++        p->sendFrame(c);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_pressed);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_released);
++        p->sendFrame(c);
++        p->sendLeave(surface);
++        p->sendFrame(c);
++    });
++
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup());
++    exec([=] { xdgPopup()->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup()->m_xdgSurface->m_committedConfigureSerial);
++    QCOMPOSITOR_TRY_VERIFY(!xdgPopup()->m_grabbed);
++
++    exec([=] {
++        auto *surface = xdgPopup()->surface();
++        auto *p = pointer();
++        auto *c = client();
++        p->sendEnter(surface, {100, 100});
++        p->sendFrame(c);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_pressed);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_released);
++        p->sendFrame(c);
++    });
++
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1));
++    exec([=] { xdgPopup(1)->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1)->m_xdgSurface->m_committedConfigureSerial);
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1)->m_grabbed);
++
++    // Close the middle tooltip (it should not close the sibling popup)
++    window.m_tooltip->close();
++
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(1), nullptr);
++    // Verify the remaining xdg surface is a grab popup..
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(0));
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(0)->m_grabbed);
++
++    window.m_tooltip->m_popup->close();
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(1), nullptr);
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(0), nullptr);
++}
++
+ // QTBUG-65680
+ void tst_xdgshell::switchPopups()
+ {
+@@ -505,7 +598,7 @@ void tst_xdgshell::minMaxSize()
+     window.show();
+     QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
+ 
+-    exec([=] { xdgToplevel()->sendCompleteConfigure(); });
++    // we don't roundtrip with our configuration the initial commit should be correct
+ 
+     QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.minSize, QSize(100, 100));
+     QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.maxSize, QSize(1000, 1000));
+Submodule qtwebchannel 618422ee..f8949655:
+diff --git a/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp b/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
+index 536eb5c..898d769 100644
+--- a/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
++++ b/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
+@@ -186,8 +186,6 @@ Q_DECLARE_TYPEINFO(OverloadResolutionCandidate, Q_MOVABLE_TYPE);
+ QMetaObjectPublisher::QMetaObjectPublisher(QWebChannel *webChannel)
+     : QObject(webChannel)
+     , webChannel(webChannel)
+-    , signalHandler(this)
+-    , clientIsIdle(false)
+     , blockUpdates(false)
+     , propertyUpdatesInitialized(false)
+ {
+@@ -301,17 +299,17 @@ QJsonObject QMetaObjectPublisher::classInfoForObject(const QObject *object, QWeb
+     return data;
+ }
+ 
+-void QMetaObjectPublisher::setClientIsIdle(bool isIdle)
++void QMetaObjectPublisher::setClientIsIdle(bool isIdle, QWebChannelAbstractTransport *transport)
+ {
+-    if (clientIsIdle == isIdle) {
+-        return;
+-    }
+-    clientIsIdle = isIdle;
+-    if (!isIdle && timer.isActive()) {
+-        timer.stop();
+-    } else if (isIdle && !timer.isActive()) {
+-        timer.start(PROPERTY_UPDATE_INTERVAL, this);
+-    }
++    transportState[transport].clientIsIdle = isIdle;
++    if (isIdle)
++        sendEnqueuedPropertyUpdates(transport);
++}
++
++bool QMetaObjectPublisher::isClientIdle(QWebChannelAbstractTransport *transport)
++{
++    auto found = transportState.find(transport);
++    return found != transportState.end() && found.value().clientIsIdle;
+ }
+ 
+ QJsonObject QMetaObjectPublisher::initializeClient(QWebChannelAbstractTransport *transport)
+@@ -333,6 +331,7 @@ QJsonObject QMetaObjectPublisher::initializeClient(QWebChannelAbstractTransport
+ 
+ void QMetaObjectPublisher::initializePropertyUpdates(const QObject *const object, const QJsonObject &objectInfo)
+ {
++    auto *signalHandler = signalHandlerFor(object);
+     foreach (const QJsonValue &propertyInfoVar, objectInfo[KEY_PROPERTIES].toArray()) {
+         const QJsonArray &propertyInfo = propertyInfoVar.toArray();
+         if (propertyInfo.size() < 2) {
+@@ -353,19 +352,19 @@ void QMetaObjectPublisher::initializePropertyUpdates(const QObject *const object
+ 
+         // Only connect for a property update once
+         if (connectedProperties.isEmpty()) {
+-            signalHandler.connectTo(object, signalIndex);
++            signalHandler->connectTo(object, signalIndex);
+         }
+ 
+         connectedProperties.insert(propertyIndex);
+     }
+ 
+     // also always connect to destroyed signal
+-    signalHandler.connectTo(object, s_destroyedSignalIndex);
++    signalHandler->connectTo(object, s_destroyedSignalIndex);
+ }
+ 
+ void QMetaObjectPublisher::sendPendingPropertyUpdates()
+ {
+-    if (blockUpdates || !clientIsIdle || pendingPropertyUpdates.isEmpty()) {
++    if (blockUpdates) {
+         return;
+     }
+ 
+@@ -415,18 +414,19 @@ void QMetaObjectPublisher::sendPendingPropertyUpdates()
+ 
+     // data does not contain specific updates
+     if (!data.isEmpty()) {
+-        setClientIsIdle(false);
+-
+         message[KEY_DATA] = data;
+-        broadcastMessage(message);
++        enqueueBroadcastMessage(message);
+     }
+ 
+     // send every property update which is not supposed to be broadcasted
+     const QHash<QWebChannelAbstractTransport*, QJsonArray>::const_iterator suend = specificUpdates.constEnd();
+     for (QHash<QWebChannelAbstractTransport*, QJsonArray>::const_iterator it = specificUpdates.constBegin(); it != suend; ++it) {
+         message[KEY_DATA] = it.value();
+-        it.key()->sendMessage(message);
++        enqueueMessage(message, it.key());
+     }
++
++    for (auto state = transportState.begin(); state != transportState.end(); ++state)
++        sendEnqueuedPropertyUpdates(state.key());
+ }
+ 
+ QVariant QMetaObjectPublisher::invokeMethod(QObject *const object, const QMetaMethod &method,
+@@ -572,7 +572,7 @@ void QMetaObjectPublisher::signalEmitted(const QObject *object, const int signal
+         }
+     } else {
+         pendingPropertyUpdates[object][signalIndex] = arguments;
+-        if (clientIsIdle && !blockUpdates && !timer.isActive()) {
++        if (!blockUpdates && !timer.isActive()) {
+             timer.start(PROPERTY_UPDATE_INTERVAL, this);
+         }
+     }
+@@ -590,7 +590,7 @@ void QMetaObjectPublisher::objectDestroyed(const QObject *object)
+     // only remove from handler when we initialized the property updates
+     // cf: https://bugreports.qt.io/browse/QTBUG-60250
+     if (propertyUpdatesInitialized) {
+-        signalHandler.remove(object);
++        signalHandlerFor(object)->remove(object);
+         signalToPropertyMap.remove(object);
+     }
+     pendingPropertyUpdates.remove(object);
+@@ -852,6 +852,52 @@ void QMetaObjectPublisher::broadcastMessage(const QJsonObject &message) const
+     }
+ }
+ 
++void QMetaObjectPublisher::enqueueBroadcastMessage(const QJsonObject &message)
++{
++    if (webChannel->d_func()->transports.isEmpty()) {
++        qWarning("QWebChannel is not connected to any transports, cannot send message: %s",
++                 QJsonDocument(message).toJson().constData());
++        return;
++    }
++
++    for (auto *transport : webChannel->d_func()->transports) {
++        auto &state = transportState[transport];
++        state.queuedMessages.append(message);
++    }
++}
++
++void QMetaObjectPublisher::enqueueMessage(const QJsonObject &message,
++                                          QWebChannelAbstractTransport *transport)
++{
++    auto &state = transportState[transport];
++    state.queuedMessages.append(message);
++}
++
++void QMetaObjectPublisher::sendEnqueuedPropertyUpdates(QWebChannelAbstractTransport *transport)
++{
++    auto found = transportState.find(transport);
++    if (found != transportState.end() && found.value().clientIsIdle
++        && !found.value().queuedMessages.isEmpty()) {
++
++        // If the client is connected with an in-process transport, it can
++        // happen that a message triggers a subsequent property change. In
++        // that case, we need to ensure that the queued messages have already
++        // been cleared; otherwise the recursive call will send everythig again.
++        // Case in point: The qmlwebchannel tests fail if we don't clear the
++        // queued messages before sending them out.
++        // For that same reason set the client to "busy" (aka non-idle) just
++        // right before sending out the messages; otherwise a potential
++        // "Idle" type message will not correctly restore the Idle state.
++        const auto messages = std::move(found.value().queuedMessages);
++        Q_ASSERT(found.value().queuedMessages.isEmpty());
++        found.value().clientIsIdle = false;
++
++        for (const auto &message : messages) {
++            transport->sendMessage(message);
++        }
++    }
++}
++
+ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannelAbstractTransport *transport)
+ {
+     if (!webChannel->d_func()->transports.contains(transport)) {
+@@ -866,7 +912,7 @@ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannel
+ 
+     const MessageType type = toType(message.value(KEY_TYPE));
+     if (type == TypeIdle) {
+-        setClientIsIdle(true);
++        setClientIsIdle(true, transport);
+     } else if (type == TypeInit) {
+         if (!message.contains(KEY_ID)) {
+             qWarning("JSON message object is missing the id property: %s",
+@@ -913,9 +959,9 @@ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannel
+                 return;
+             transport->sendMessage(createResponse(message.value(KEY_ID), wrapResult(result, transport)));
+         } else if (type == TypeConnectToSignal) {
+-            signalHandler.connectTo(object, message.value(KEY_SIGNAL).toInt(-1));
++            signalHandlerFor(object)->connectTo(object, message.value(KEY_SIGNAL).toInt(-1));
+         } else if (type == TypeDisconnectFromSignal) {
+-            signalHandler.disconnectFrom(object, message.value(KEY_SIGNAL).toInt(-1));
++            signalHandlerFor(object)->disconnectFrom(object, message.value(KEY_SIGNAL).toInt(-1));
+         } else if (type == TypeSetProperty) {
+             setProperty(object, message.value(KEY_PROPERTY).toInt(-1),
+                         message.value(KEY_VALUE));
+@@ -931,6 +977,7 @@ void QMetaObjectPublisher::setBlockUpdates(bool block)
+     blockUpdates = block;
+ 
+     if (!blockUpdates) {
++        timer.start(PROPERTY_UPDATE_INTERVAL, this);
+         sendPendingPropertyUpdates();
+     } else if (timer.isActive()) {
+         timer.stop();
+@@ -948,4 +995,15 @@ void QMetaObjectPublisher::timerEvent(QTimerEvent *event)
+     }
+ }
+ 
++SignalHandler<QMetaObjectPublisher> *QMetaObjectPublisher::signalHandlerFor(const QObject *object)
++{
++    auto thread = object->thread();
++    auto it = signalHandlers.find(thread);
++    if (it == signalHandlers.end()) {
++        it = signalHandlers.emplace(thread, this).first;
++        it->second.moveToThread(thread);
++    }
++    return &it->second;
++}
++
+ QT_END_NAMESPACE
+diff --git a/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h b/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
+index bbd9875..4713ef1 100644
+--- a/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
++++ b/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
+@@ -59,6 +59,9 @@
+ #include <QBasicTimer>
+ #include <QPointer>
+ #include <QJsonObject>
++#include <QQueue>
++
++#include <unordered_map>
+ 
+ #include "qwebchannelglobal.h"
+ 
+@@ -109,17 +112,36 @@ public:
+      */
+     void broadcastMessage(const QJsonObject &message) const;
+ 
++    /**
++     * Enqueue the given @p message to all known transports.
++     */
++    void enqueueBroadcastMessage(const QJsonObject &message);
++
++    /**
++     * Enqueue the given @p message to @p transport.
++     */
++    void enqueueMessage(const QJsonObject &message, QWebChannelAbstractTransport *transport);
++
++    /**
++     * If client for given @p transport is idle, send queued messaged to @p transport and then mark
++     * the client as not idle.
++     */
++    void sendEnqueuedPropertyUpdates(QWebChannelAbstractTransport *transport);
++
+     /**
+      * Serialize the QMetaObject of @p object and return it in JSON form.
+      */
+     QJsonObject classInfoForObject(const QObject *object, QWebChannelAbstractTransport *transport);
+ 
+     /**
+-     * Set the client to idle or busy, based on the value of @p isIdle.
+-     *
+-     * When the value changed, start/stop the property update timer accordingly.
++     * Set the client to idle or busy for a single @p transport, based on the value of @p isIdle.
++     */
++    void setClientIsIdle(bool isIdle, QWebChannelAbstractTransport *transport);
++
++    /**
++     * Check that client is idle for @p transport.
+      */
+-    void setClientIsIdle(bool isIdle);
++    bool isClientIdle(QWebChannelAbstractTransport *transport);
+ 
+     /**
+      * Initialize clients by sending them the class information of the registered objects.
+@@ -272,10 +294,18 @@ private:
+     friend class TestWebChannel;
+ 
+     QWebChannel *webChannel;
+-    SignalHandler<QMetaObjectPublisher> signalHandler;
++    std::unordered_map<const QThread*, SignalHandler<QMetaObjectPublisher>> signalHandlers;
++    SignalHandler<QMetaObjectPublisher> *signalHandlerFor(const QObject *object);
+ 
+-    // true when the client is idle, false otherwise
+-    bool clientIsIdle;
++    struct TransportState
++    {
++        TransportState() : clientIsIdle(false) { }
++        // true when the client is idle, false otherwise
++        bool clientIsIdle;
++        // messages to send
++        QQueue<QJsonObject> queuedMessages;
++    };
++    QHash<QWebChannelAbstractTransport *, TransportState> transportState;
+ 
+     // true when no property updates should be sent, false otherwise
+     bool blockUpdates;
+diff --git a/qtwebchannel/src/webchannel/signalhandler_p.h b/qtwebchannel/src/webchannel/signalhandler_p.h
+index 27afadb..d77373c 100644
+--- a/qtwebchannel/src/webchannel/signalhandler_p.h
++++ b/qtwebchannel/src/webchannel/signalhandler_p.h
+@@ -56,6 +56,7 @@
+ #include <QVector>
+ #include <QMetaMethod>
+ #include <QDebug>
++#include <QThread>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -71,6 +72,7 @@ static const int s_destroyedSignalIndex = QObject::staticMetaObject.indexOfMetho
+ template<class Receiver>
+ class SignalHandler : public QObject
+ {
++    Q_DISABLE_COPY(SignalHandler)
+ public:
+     SignalHandler(Receiver *receiver, QObject *parent = 0);
+ 
+@@ -268,6 +270,7 @@ int SignalHandler<Receiver>::qt_metacall(QMetaObject::Call call, int methodId, v
+     if (call == QMetaObject::InvokeMetaMethod) {
+         const QObject *object = sender();
+         Q_ASSERT(object);
++        Q_ASSERT(QThread::currentThread() == object->thread());
+         Q_ASSERT(senderSignalIndex() == methodId);
+         Q_ASSERT(m_connectionsCounter.contains(object));
+         Q_ASSERT(m_connectionsCounter.value(object).contains(methodId));
+diff --git a/qtwebchannel/tests/auto/qml/testwebchannel.cpp b/qtwebchannel/tests/auto/qml/testwebchannel.cpp
+index 9891687..3ca81c2 100644
+--- a/qtwebchannel/tests/auto/qml/testwebchannel.cpp
++++ b/qtwebchannel/tests/auto/qml/testwebchannel.cpp
+@@ -46,7 +46,11 @@ TestWebChannel::~TestWebChannel()
+ 
+ bool TestWebChannel::clientIsIdle() const
+ {
+-    return QWebChannel::d_func()->publisher->clientIsIdle;
++    for (auto *transport : QWebChannel::d_func()->transports) {
++        if (QWebChannel::d_func()->publisher->isClientIdle(transport))
++            return true;
++    }
++    return false;
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp b/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
+index 181da9e..37f989a 100644
+--- a/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
++++ b/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
+@@ -785,7 +785,7 @@ void TestWebChannel::testTransportWrapObjectProperties()
+     DummyTransport *dummyTransport = new DummyTransport(this);
+     channel.connectTo(dummyTransport);
+     channel.d_func()->publisher->initializeClient(dummyTransport);
+-    channel.d_func()->publisher->setClientIsIdle(true);
++    channel.d_func()->publisher->setClientIsIdle(true, dummyTransport);
+ 
+     QCOMPARE(channel.d_func()->publisher->transportedWrappedObjects.size(), 0);
+ 
+@@ -943,8 +943,6 @@ void TestWebChannel::testInfiniteRecursion()
+ 
+ void TestWebChannel::testAsyncObject()
+ {
+-    QSKIP("This test is broken. See QTBUG-80729");
+-
+     QWebChannel channel;
+     channel.connectTo(m_dummyTransport);
+ 
+@@ -990,6 +988,50 @@ void TestWebChannel::testAsyncObject()
+     thread.wait();
+ }
+ 
++void TestWebChannel::testPropertyMultipleTransports()
++{
++    DummyTransport transport1;
++    DummyTransport transport2;
++
++    QWebChannel channel;
++    QMetaObjectPublisher *publisher = channel.d_func()->publisher;
++
++    TestObject testObj;
++    testObj.setObjectName("testObject");
++    channel.registerObject(testObj.objectName(), &testObj);
++    channel.connectTo(&transport1);
++    channel.connectTo(&transport2);
++
++    testObj.setProp("Hello");
++
++    publisher->initializeClient(&transport1);
++    publisher->initializeClient(&transport2);
++    publisher->setClientIsIdle(true, &transport1);
++    QCOMPARE(publisher->isClientIdle(&transport1), true);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++    QVERIFY(transport1.messagesSent().isEmpty());
++    QVERIFY(transport2.messagesSent().isEmpty());
++
++    testObj.setProp("World");
++    QTRY_COMPARE_WITH_TIMEOUT(transport1.messagesSent().size(), 1u, 2000);
++    QCOMPARE(transport2.messagesSent().size(), 0u);
++    publisher->setClientIsIdle(true, &transport2);
++    QTRY_COMPARE_WITH_TIMEOUT(transport2.messagesSent().size(), 1u, 2000);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++
++    testObj.setProp("!!!");
++    publisher->setClientIsIdle(true, &transport2);
++    QCOMPARE(publisher->isClientIdle(&transport2), true);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QTRY_COMPARE_WITH_TIMEOUT(transport2.messagesSent().size(), 2u, 2000);
++    QCOMPARE(transport1.messagesSent().size(), 1u);
++    publisher->setClientIsIdle(true, &transport1);
++    QTRY_COMPARE_WITH_TIMEOUT(transport1.messagesSent().size(), 2u, 2000);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++}
++
+ class FunctionWrapper : public QObject
+ {
+     Q_OBJECT
+@@ -1082,7 +1124,7 @@ void TestWebChannel::benchInitializeClients()
+ 
+         publisher->propertyUpdatesInitialized = false;
+         publisher->signalToPropertyMap.clear();
+-        publisher->signalHandler.clear();
++        publisher->signalHandlers.clear();
+     }
+ }
+ 
+@@ -1107,7 +1149,7 @@ void TestWebChannel::benchPropertyUpdates()
+             obj->change();
+         }
+ 
+-        channel.d_func()->publisher->clientIsIdle = true;
++        channel.d_func()->publisher->setClientIsIdle(true, m_dummyTransport);
+         channel.d_func()->publisher->sendPendingPropertyUpdates();
+     }
+ }
+diff --git a/qtwebchannel/tests/auto/webchannel/tst_webchannel.h b/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
+index eae21f4..dd4e690 100644
+--- a/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
++++ b/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
+@@ -348,6 +348,7 @@ private slots:
+     void testJsonToVariant();
+     void testInfiniteRecursion();
+     void testAsyncObject();
++    void testPropertyMultipleTransports();
+     void testDeletionDuringMethodInvocation_data();
+     void testDeletionDuringMethodInvocation();
+ 
+Submodule qtwebengine f328054d...38e0df6c (commits not present)
+Submodule qtwebsockets 65850954..63fb8da1:
+diff --git a/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp b/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
+index 2affdd5..95f1194 100644
+--- a/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
++++ b/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
+@@ -273,6 +273,7 @@ void QWebSocketDataProcessor::clear()
+     if (!m_pConverterState)
+         m_pConverterState = new QTextCodec::ConverterState(QTextCodec::ConvertInvalidToNull |
+                                                            QTextCodec::IgnoreHeader);
++    frame.clear();
+ }
+ 
+ /*!
+diff --git a/qtwebsockets/src/websockets/qwebsocketprotocol.cpp b/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
+index df87a93..d0465f1 100644
+--- a/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
++++ b/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
+@@ -210,7 +210,7 @@ void QWebSocketProtocol::mask(char *payload, quint64 size, quint32 maskingKey)
+                             quint8((maskingKey & 0x0000FF00u) >> 8),
+                             quint8((maskingKey & 0x000000FFu))
+                           };
+-    int i = 0;
++    quint64 i = 0;
+     while (size-- > 0)
+         *payload++ ^= mask[i++ % 4];
+ }
diff --git a/srcpkgs/qt5/template b/srcpkgs/qt5/template
index a79d25e69da8..6dddce7f3e46 100644
--- a/srcpkgs/qt5/template
+++ b/srcpkgs/qt5/template
@@ -2,11 +2,11 @@
 #
 # revbump libqtxdg after bumping patch version
 pkgname=qt5
-version=5.15.7+20221119
+version=5.15.8
+revision=1
+build_style=meta
 # commit f8c9fb304bc3e53b3aa07f962cd74e9160decccc
 # base repo: https://invent.kde.org/qt/qt/qt5
-revision=5
-build_style=meta
 hostmakedepends="cmake clang flex perl glib-devel pkg-config
  python re2c ruby which"
 makedepends="SDL2-devel Vulkan-Headers alsa-lib-devel double-conversion-devel
@@ -29,8 +29,9 @@ homepage="https://qt.io/"
 # tarball is generated with `git archive-all qt5-$version.tar.gz`
 # to keep the size smaller qtwebengine, qtwebview, qtdocgallery, qtactiveqt and qtpim
 # can be marked with the export-ignore attribute
-distfiles="https://void.johnnynator.dev/distfiles/qt5-${version}.tar.gz"
-checksum=9d57af471c78029a362276b7c99108ea009f511bb9ba6ff6cb884f6ddd255e9f
+#distfiles="https://void.johnnynator.dev/distfiles/qt5-${version}.tar.gz"
+distfiles="https://download.qt.io/archive/qt/5.15/${version}/single/qt-everywhere-opensource-src-${version}.tar.xz"
+checksum=776a9302c336671f9406a53bd30b8e36f825742b2ec44a57c08217bff0fa86b9
 python_version=2 #unverified
 replaces="qt5-doc<5.6.0 qt5-quick1<5.6.0 qt5-quick1-devel<5.6.0 qt5-webkit<5.6.0 qt5-webkit-devel<5.6.0
  qt5-enginio<5.7.1 qt5-enginio-devel<5.7.1 qt5-plugin-gtk<5.7.1 qt5-canvas3d<5.13.0"
@@ -250,7 +251,6 @@ do_configure() {
 	# opts+=" -v"
 	opts+=" -skip qtwebengine"
 	opts+=" -skip qtwebview"
-	opts+=" -skip qtdocgallery"
 	opts+=" -skip qtpim"
 	opts+=" -skip qtsystems"
 	opts+=" -skip qtspeech"

From fcd34b55acd8cf79e4264a7975beefc860c6a9c9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 075/116] qtav: revbump for ffmpeg4-4.4.3

---
 srcpkgs/qtav/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtav/template b/srcpkgs/qtav/template
index 34c30b2c0c78..2d00ad104355 100644
--- a/srcpkgs/qtav/template
+++ b/srcpkgs/qtav/template
@@ -1,10 +1,10 @@
 # Template file for 'qtav'
 pkgname=qtav
 version=1.13.0
-revision=1
+revision=2
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel libass-devel libopenal-devel
+makedepends="ffmpeg4-devel libass-devel libopenal-devel
  libva-glx-devel libXv-devel pulseaudio-devel
  qt5-declarative-devel qt5-svg-devel
  qt5-quickcontrols"

From b4dc3065639ad230b626a38b31bb5d4547a505e4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 076/116] qtox: revbump for ffmpeg-6.0

---
 srcpkgs/qtox/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qtox/template b/srcpkgs/qtox/template
index 16019d7eaec9..5cea0b11b697 100644
--- a/srcpkgs/qtox/template
+++ b/srcpkgs/qtox/template
@@ -1,7 +1,7 @@
 # Template file for 'qtox'
 pkgname=qtox
 version=1.17.6
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DUPDATE_CHECK=OFF
  -DGIT_DESCRIBE=${version}

From 5a3ecbd485e52e37cdea09811fde861a7fcd2f34 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 077/116] retroarch: revbump for ffmpeg-6.0

---
 srcpkgs/retroarch/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroarch/template b/srcpkgs/retroarch/template
index 28016aa0129e..20a1415913be 100644
--- a/srcpkgs/retroarch/template
+++ b/srcpkgs/retroarch/template
@@ -1,7 +1,7 @@
 # Template file for 'retroarch'
 pkgname=retroarch
 version=1.15.0
-revision=1
+revision=2
 build_style=configure
 configure_args="--prefix=/usr --sysconfdir=/etc --enable-networking
  --enable-udev --disable-builtinflac --disable-builtinglslang

From 2d8278c9eea67ce96d8d64795a5cab21ab8f12f0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 078/116] scrcpy: revbump for ffmpeg-6.0

---
 srcpkgs/scrcpy/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/scrcpy/template b/srcpkgs/scrcpy/template
index ee6e698e387f..8ada5ca4323f 100644
--- a/srcpkgs/scrcpy/template
+++ b/srcpkgs/scrcpy/template
@@ -1,7 +1,7 @@
 # Template file for 'scrcpy'
 pkgname=scrcpy
 version=2.0
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcompile_server=false
  -Dprebuilt_server=/usr/share/scrcpy/scrcpy-server-v${version}"

From 4881b755457d1784a047f7fc18a32ac9f1a7a5d0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 079/116] spek-alternative: revbump for ffmpeg4-4.4.3

---
 srcpkgs/spek-alternative/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/spek-alternative/template b/srcpkgs/spek-alternative/template
index d65086b8f008..05246f1b8d0c 100644
--- a/srcpkgs/spek-alternative/template
+++ b/srcpkgs/spek-alternative/template
@@ -1,11 +1,11 @@
 # Template file for 'spek-alternative'
 pkgname=spek-alternative
 version=0.8.2.3
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake gettext-devel intltool libtool pkg-config wxWidgets-common"
-makedepends="ffmpeg-devel wxWidgets-gtk3-devel"
-depends="ffmpeg"
+makedepends="ffmpeg4-devel wxWidgets-gtk3-devel"
+depends="ffmpeg4"
 short_desc="Acoustic spectrum analyser"
 maintainer="Kartik Singh <kartik.ynwa@gmail.com>"
 license="GPL-3.0-or-later"

From d09a69c97093a0bcdc2c38e964b9efd4de1df377 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 080/116] ssr: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ssr/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/ssr/template b/srcpkgs/ssr/template
index b055b9ec0774..3448ca110eb0 100644
--- a/srcpkgs/ssr/template
+++ b/srcpkgs/ssr/template
@@ -1,11 +1,11 @@
 # Template file for 'ssr'
 pkgname=ssr
 version=0.4.4
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_QT5=ON"
 hostmakedepends="pkg-config"
-makedepends="alsa-lib-devel ffmpeg-devel glu-devel jack-devel pulseaudio-devel
+makedepends="alsa-lib-devel ffmpeg4-devel glu-devel jack-devel pulseaudio-devel
  qt5-tools-devel qt5-x11extras-devel libXinerama-devel v4l-utils-devel"
 depends="desktop-file-utils hicolor-icon-theme"
 short_desc="Simple Screen Recorder for programs and games"

From 3ebd9c115e872debb3775c983465fefb940eaf58 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 081/116] sumo: revbump for ffmpeg-6.0

---
 srcpkgs/sumo/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/sumo/template b/srcpkgs/sumo/template
index 0f9b9ec815f5..a3fe134aa5ac 100644
--- a/srcpkgs/sumo/template
+++ b/srcpkgs/sumo/template
@@ -1,7 +1,7 @@
 # Template file for 'sumo'
 pkgname=sumo
 version=1.12.0
-revision=5
+revision=6
 build_style=cmake
 hostmakedepends="libgdal-tools pkg-config swig python3-setuptools"
 makedepends="python3-devel ffmpeg-devel fox-devel gl2ps-devel libgdal-devel

From ff27117abe260b3d5757a645b09b97598bccfd81 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 082/116] synfig: revbump for ffmpeg-6.0 and mlt7

---
 srcpkgs/synfig/patches/ffmpeg6.patch | 71 ++++++++++++++++++++++++++++
 srcpkgs/synfig/template              |  4 +-
 2 files changed, 73 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/synfig/patches/ffmpeg6.patch

diff --git a/srcpkgs/synfig/patches/ffmpeg6.patch b/srcpkgs/synfig/patches/ffmpeg6.patch
new file mode 100644
index 000000000000..10780b42782f
--- /dev/null
+++ b/srcpkgs/synfig/patches/ffmpeg6.patch
@@ -0,0 +1,71 @@
+--- a/src/modules/mod_libavcodec/trgt_av.cpp	2022-10-25 09:14:12.000000000 -0400
++++ b/src/modules/mod_libavcodec/trgt_av.cpp	2023-05-05 21:34:17.899194559 -0400
+@@ -38,6 +41,7 @@
+ extern "C"
+ {
+ #ifdef HAVE_LIBAVFORMAT_AVFORMAT_H
++#	include <libavcodec/avcodec.h>
+ #	include <libavformat/avformat.h>
+ #elif defined(HAVE_AVFORMAT_H)
+ #	include <avformat.h>
+@@ -155,11 +156,11 @@
+     }
+ 
+ 	bool open_video_stream() {
+-		if (avcodec_open2(video_context, NULL, NULL) < 0) {
++		if (avcodec_open2(video_context, nullptr, nullptr) < 0) {
+ 			synfig::error("Target_LibAVCodec: could not open video codec");
+ 			// seems the calling of avcodec_free_context after error will cause crash
+ 			// so just forget about this context
+-			video_context = NULL;
++			video_context = nullptr;
+ 			close();
+ 			return false;
+         }
+@@ -234,15 +235,21 @@
+ 		close();
+ 
+ 		if (!av_registered) {
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 			av_register_all();
++#endif
+ 			av_registered = true;
+ 		}
+ 
+ 		// guess format
+-		AVOutputFormat *format = av_guess_format(NULL, filename.c_str(), NULL);
++#if LIBAVCODEC_VERSION_MAJOR < 59 // FFMPEG < 5.0
++		AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#else
++		const AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#endif
+ 		if (!format) {
+ 			synfig::warning("Target_LibAVCodec: unable to guess the output format, defaulting to MPEG");
+-			format = av_guess_format("mpeg", NULL, NULL);
++			format = av_guess_format("mpeg", nullptr, nullptr);
+ 		}
+ 		if (!format) {
+ 			synfig::error("Target_LibAVCodec: unable to find 'mpeg' output format");
+@@ -254,6 +261,7 @@
+ 		context = avformat_alloc_context();
+ 		assert(context);
+ 		context->oformat = format;
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 		if (filename.size() + 1 > sizeof(context->filename)) {
+ 			synfig::error(
+ 				"Target_LibAVCodec: filename too long, max length is %d, filename is '%s'",
+@@ -263,6 +271,14 @@
+ 			return false;
+ 		}
+ 		memcpy(context->filename, filename.c_str(), filename.size() + 1);
++#else
++		context->url = av_strndup(filename.c_str(), filename.size());
++		if (!context->url) {
++			synfig::error("Target_LibAVCodec: cannot allocate space for filename");
++			close();
++			return false;
++		}
++#endif
+ 
+ 		packet = av_packet_alloc();
+ 		assert(packet);
diff --git a/srcpkgs/synfig/template b/srcpkgs/synfig/template
index 5f5f5bb3f4b2..6e0d713150ae 100644
--- a/srcpkgs/synfig/template
+++ b/srcpkgs/synfig/template
@@ -6,7 +6,7 @@ revision=2
 build_style=gnu-configure
 configure_args="--with-boost-libdir=${XBPS_CROSS_BASE}/usr/lib"
 hostmakedepends="boost-build ImageMagick pkg-config intltool"
-makedepends="ETL gettext-devel libxml++-devel mlt-devel libmagick-devel
+makedepends="ETL gettext-devel libxml++-devel mlt7-devel libmagick-devel
  libmng-devel boost-build boost-devel libopenexr-devel ffmpeg-devel"
 depends="ImageMagick"
 short_desc="CLI 2D vector and timeline-based animation software"
@@ -20,7 +20,7 @@ CXXFLAGS="-std=c++11 -DHAVE_LOCALE_H=1"
 
 synfig-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision}
-	 libopenexr-devel libxml++-devel mlt-devel"
+	 libopenexr-devel libxml++-devel mlt7-devel"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/bin/synfig-config

From 9744cbaa1c95c670b4151bee65b74d6d79976f51 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 5 May 2023 12:57:57 -0400
Subject: [PATCH 083/116] synfigstudio: revbump for synfig mlt7

---
 srcpkgs/synfigstudio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/synfigstudio/template b/srcpkgs/synfigstudio/template
index 91349169ed2b..af1c5a296ef0 100644
--- a/srcpkgs/synfigstudio/template
+++ b/srcpkgs/synfigstudio/template
@@ -2,7 +2,7 @@
 # Should be kept in sync with 'synfig' and 'ETL'
 pkgname=synfigstudio
 version=1.4.4
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--disable-update-mimedb"
 hostmakedepends="pkg-config intltool gettext synfig"

From d35501226462e6d83f306167cdfa983859675527 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 084/116] tg_owt: revbump for ffmpeg-6.0

---
 srcpkgs/tg_owt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tg_owt/template b/srcpkgs/tg_owt/template
index 97d195ddb34a..551614b24956 100644
--- a/srcpkgs/tg_owt/template
+++ b/srcpkgs/tg_owt/template
@@ -1,7 +1,7 @@
 # Template file for 'tg_owt'
 pkgname=tg_owt
 version=0.0.0.20230107
-revision=1
+revision=2
 _commit=5098730b9eb6173f0b52068fe2555b7c1015123a
 _libyuv_commit=00950840d1c9bcbb3eb6ebc5aac5793e71166c8b
 _abseil_commit=8c0b94e793a66495e0b1f34a5eb26bd7dc672db0

From 06cfe727bf101f16ddd7e7398fb2bcd5b23feb57 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 085/116] timg: revbump for ffmpeg-6.0

---
 srcpkgs/timg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/timg/template b/srcpkgs/timg/template
index 2a2ab763d2fd..8fb4327535ef 100644
--- a/srcpkgs/timg/template
+++ b/srcpkgs/timg/template
@@ -1,7 +1,7 @@
 # Template file for 'timg'
 pkgname=timg
 version=1.4.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_OPENSLIDE_SUPPORT=off -Wno-dev"
 hostmakedepends="pkg-config git"

From 7d00810d8e4bf16144f8b2e1b0ea479e8f75617e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 086/116] tvheadend: revbump for ffmpeg4-4.4.3

---
 srcpkgs/tvheadend/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/tvheadend/template b/srcpkgs/tvheadend/template
index e6b16d7ccf3b..46b52b6fb7f9 100644
--- a/srcpkgs/tvheadend/template
+++ b/srcpkgs/tvheadend/template
@@ -1,14 +1,14 @@
 # Template file for 'tvheadend'
 pkgname=tvheadend
 version=4.2.8
-revision=6
+revision=7
 build_style=gnu-configure
 configure_args="--enable-dvbscan --disable-ffmpeg_static
 --disable-hdhomerun_static --disable-bintray_cache --disable-libx264_static
 --disable-libx265_static --disable-libvpx_static --disable-libtheora_static
 --disable-libvorbis_static --disable-libfdkaac_static"
 hostmakedepends="gettext pkg-config python git which"
-makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg-devel"
+makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg4-devel"
 short_desc="TV streaming server"
 maintainer="lemmi <lemmi@nerd2nerd.org>"
 license="GPL-3.0-only"

From bc770206538eacf9e427cd4bf36efa7822ec54e9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 087/116] unpaper: update to 7.0.0.

---
 srcpkgs/unpaper/template | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/srcpkgs/unpaper/template b/srcpkgs/unpaper/template
index 38ed47a58401..1ff910e722af 100644
--- a/srcpkgs/unpaper/template
+++ b/srcpkgs/unpaper/template
@@ -1,13 +1,13 @@
 # Template file for 'unpaper'
 pkgname=unpaper
-version=6.1
-revision=3
-build_style=gnu-configure
+version=7.0.0
+revision=1
+build_style=meson
+hostmakedepends="pkg-config meson libxslt"
+makedepends="ffmpeg-devel python3-Sphinx"
+short_desc="Post-processing tool for scanned sheets of paper"
 maintainer="Orphaned <orphan@voidlinux.org>"
-hostmakedepends="pkg-config libxslt"
-makedepends="ffmpeg-devel"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://www.flameeyes.eu/projects/unpaper"
-short_desc="A post-processing tool for scanned sheets of paper"
 distfiles="https://www.flameeyes.eu/files/${pkgname}-${version}.tar.xz"
-checksum=237c84f5da544b3f7709827f9f12c37c346cdf029b1128fb4633f9bafa5cb930
+checksum=2575fbbf26c22719d1cb882b59602c9900c7f747118ac130883f63419be46a80

From 1ed9c913bda5335eb35ac1853def72064642d4a2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 088/116] vba-m: revbump for ffmpeg-6.0

---
 srcpkgs/vba-m/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vba-m/template b/srcpkgs/vba-m/template
index ba153e0b58ca..aa6093645e97 100644
--- a/srcpkgs/vba-m/template
+++ b/srcpkgs/vba-m/template
@@ -2,7 +2,7 @@
 pkgname=vba-m
 reverts=1292_2
 version=2.1.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_GTK=TRUE -DENABLE_FFMPEG=TRUE -DENABLE_LINK=TRUE -DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="gettext pkg-config unzip zip yasm wxWidgets-gtk3-devel"

From c795edaa67a3a99ab4bdcd30205e86e9ca0b1ffe Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 089/116] vice: revbump for ffmpeg4-4.4.3

---
 srcpkgs/vice/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/vice/template b/srcpkgs/vice/template
index 0924767cfcfb..5981e45149d0 100644
--- a/srcpkgs/vice/template
+++ b/srcpkgs/vice/template
@@ -1,7 +1,7 @@
 # Template file for 'vice'
 pkgname=vice
 version=3.5
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="
 	$(vopt_enable sdl2 sdlui2)
@@ -28,7 +28,7 @@ makedepends="
 	$(vopt_if gtk3 gtk+3-devel)
 	$(vopt_if gtk3 pulseaudio-devel)
 	$(vopt_if gtk3 pango-devel)
-	$(vopt_if ffmpeg ffmpeg-devel)"
+	$(vopt_if ffmpeg ffmpeg4-devel)"
 short_desc="Emulator for C64, C128, CBM-II, PET, VIC20, Plus4 and C16"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"

From 23cda831e762a4e124b7008312c491d14d402996 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 090/116] waypipe: revbump for ffmpeg-6.0

---
 srcpkgs/waypipe/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waypipe/template b/srcpkgs/waypipe/template
index 5c4161900060..1a46fe27f7d8 100644
--- a/srcpkgs/waypipe/template
+++ b/srcpkgs/waypipe/template
@@ -1,7 +1,7 @@
 # Template file for 'waypipe'
 pkgname=waypipe
 version=0.8.4
-revision=1
+revision=2
 build_style=meson
 # lto is off because it causes linking errors in armv6l and armv7l (due to NEON)
 configure_args="-Dwerror=false -Dwith_dmabuf=enabled -Dwith_lz4=enabled

From ea6391358eb8ba321f74c4ffdb7e89c7867275aa Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 091/116] wf-recorder: revbump for ffmpeg-6.0

---
 srcpkgs/wf-recorder/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/wf-recorder/template b/srcpkgs/wf-recorder/template
index e278eb001600..5d014a5f28af 100644
--- a/srcpkgs/wf-recorder/template
+++ b/srcpkgs/wf-recorder/template
@@ -1,7 +1,7 @@
 # Template file for 'wf-recorder'
 pkgname=wf-recorder
 version=0.3.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config scdoc wayland-devel"
 makedepends="wayland-protocols wayland-devel ffmpeg-devel x264-devel

From 985e031f1084782100582df8a9e8a1f36b5f9be6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 092/116] xpra: revbump for ffmpeg-6.0

---
 srcpkgs/xpra/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xpra/template b/srcpkgs/xpra/template
index ee8ce4ec78a9..c02482ad4b39 100644
--- a/srcpkgs/xpra/template
+++ b/srcpkgs/xpra/template
@@ -1,7 +1,7 @@
 # Template file for 'xpra'
 pkgname=xpra
 version=4.4.5
-revision=1
+revision=2
 build_style=python3-module
 make_build_args="--without-cuda_kernels --without-cuda_rebuild"
 make_install_args="$(vopt_with docs) ${make_build_args}"

From 9a4851314b949a8f0624181978c220aa3d837153 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:07:40 -0400
Subject: [PATCH 093/116] nv-codec-headers: update to 12.0.16.0

---
 srcpkgs/nv-codec-headers/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/nv-codec-headers/template b/srcpkgs/nv-codec-headers/template
index 3d422a61e489..251e057f826f 100644
--- a/srcpkgs/nv-codec-headers/template
+++ b/srcpkgs/nv-codec-headers/template
@@ -1,6 +1,6 @@
 # Template file for 'nv-codec-headers'
 pkgname=nv-codec-headers
-version=11.1.5.1
+version=12.0.16.0
 revision=1
 build_style=gnu-makefile
 short_desc="FFmpeg version of headers required to interface with Nvidias codec APIs"
@@ -8,7 +8,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="MIT"
 homepage="http://git.videolan.org/?p=ffmpeg/nv-codec-headers.git"
 distfiles="https://github.com/FFmpeg/nv-codec-headers/archive/n${version}.tar.gz"
-checksum=d095fbd56aa93772471a323be0ebe65504a0f43f06c76a30b6d25da77b06ae9c
+checksum=2a1533b65f55f9da52956faf0627ed3b74868ac0c7f269990edd21369113b48f
 
 post_install() {
 	sed -n '4,25p' include/ffnvcodec/nvEncodeAPI.h > LICENSE

From 2752df3b1e81f0a7eedaaf359c93b57197fe53e3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:08:40 -0400
Subject: [PATCH 094/116] openimagedenoise: revbump for ffmpeg-6.0

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index db5ccdb055cc..cb90045afb63 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,7 +1,7 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
 version=1.4.3
-revision=1
+revision=2
 archs="x86_64*"
 build_style=cmake
 hostmakedepends="ispc python3"

From 50856ca88d0e7591d35c3085f60900234fd39cc6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:31:45 -0400
Subject: [PATCH 095/116] shotcut: revbump for ffmpeg-6.0

---
 srcpkgs/shotcut/template | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/srcpkgs/shotcut/template b/srcpkgs/shotcut/template
index 99ebf2e8a5af..c416c906ff73 100644
--- a/srcpkgs/shotcut/template
+++ b/srcpkgs/shotcut/template
@@ -1,20 +1,20 @@
 # Template file for 'shotcut'
 pkgname=shotcut
-version=22.12.21
-revision=1
+version=23.05.14
+revision=2
 build_style=cmake
 configure_args="-DSHOTCUT_VERSION=${version}"
-hostmakedepends="pkg-config qt5-tools-devel"
-makedepends="mlt7-devel qt5-declarative-devel qt5-multimedia-devel
- qt5-quickcontrols2-devel qt5-websockets-devel qt5-plugin-mysql qt5-plugin-odbc
- qt5-plugin-pgsql qt5-plugin-sqlite qt5-plugin-tds"
-depends="ffmpeg frei0r-plugins qt5-graphicaleffects qt5-quickcontrols"
+hostmakedepends="pkg-config qt6-tools-devel"
+makedepends="mlt7-devel qt6-declarative-devel qt6-multimedia-devel
+ qt6-websockets-devel qt6-plugin-mysql qt6-plugin-odbc
+ qt6-plugin-pgsql qt6-plugin-sqlite"
+depends="ffmpeg frei0r-plugins qt6-declarative"
 short_desc="Free, open source, cross-platform video editor"
 maintainer="John <me@johnnynator.dev>"
 license="GPL-3.0-or-later"
 homepage="https://www.shotcut.org"
 changelog="https://github.com/mltframework/shotcut/releases"
 distfiles="https://github.com/mltframework/shotcut/archive/v${version}.tar.gz"
-checksum=1b9a4f87b16a9751f9cb41588f22af4c00f085105d82cf21d095d9f3c280bc86
+checksum=94632bd69cc8f3b2cba0668b9e8d051493efa5a9c9554c02822c346fe64c1ce0
 
 CXXFLAGS="-DHAVE_LOCALE_H=1 -DSHOTCUT_NOUPGRADE"

From b5a29dbe434ec821b8f56e2e21f9f3d501a7396f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:30 -0400
Subject: [PATCH 096/116] shiboken2: revbump for qt5-5.15.8

---
 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch | 1 +
 srcpkgs/shiboken2/template                                 | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
 create mode 120000 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
new file mode 120000
index 000000000000..efcf3249bd88
--- /dev/null
+++ b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1 @@
+../../python3-pyside2/patches/importlib-machinery-bypass.patch
\ No newline at end of file
diff --git a/srcpkgs/shiboken2/template b/srcpkgs/shiboken2/template
index 084ecc3ba1e1..2a21998997eb 100644
--- a/srcpkgs/shiboken2/template
+++ b/srcpkgs/shiboken2/template
@@ -1,7 +1,7 @@
 # Template file for 'shiboken2'
 pkgname=shiboken2
 version=5.15.7
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/shiboken2"
 build_style=cmake

From bcf2b036698592c94445a7c0b321d9735d79c413 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:53 -0400
Subject: [PATCH 097/116] python3-pyside2: update to 5.15.8

---
 .../patches/importlib-machinery-bypass.patch      | 15 +++++++++++++++
 srcpkgs/python3-pyside2/template                  |  9 +++++----
 2 files changed, 20 insertions(+), 4 deletions(-)
 create mode 100644 srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
new file mode 100644
index 000000000000..64c429584776
--- /dev/null
+++ b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1,15 @@
+Using this prevents an error around line 220 below it.
+"AttributeError: module 'importlib' has no attribute 'machinery'"
+The old backup logic is in place and compiles without issues.
+--- a/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:09:34.688912402 -0400
++++ b/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:10:03.395529582 -0400
+@@ -170,9 +170,6 @@
+
+     # 'zipstring_sequence' comes from signature.cpp
+     zipbytes = base64.b64decode(''.join(zipstring_sequence))
+-    if sys.version_info[0] >= 3:
+-        vzip = zipfile.ZipFile(io.BytesIO(zipbytes))
+-        return sys.meta_path, EmbeddableZipImporter(vzip)
+
+     # Old version for Python 2.7, only.
+     import os
diff --git a/srcpkgs/python3-pyside2/template b/srcpkgs/python3-pyside2/template
index 50e6ff260d3b..b50e62bd215d 100644
--- a/srcpkgs/python3-pyside2/template
+++ b/srcpkgs/python3-pyside2/template
@@ -1,11 +1,12 @@
 # Template file for 'python3-pyside2'
 pkgname=python3-pyside2
-version=5.15.5
-revision=2
+version=5.15.8
+revision=1
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/pyside2"
 build_style=cmake
-configure_args="-DPYTHON_EXECUTABLE=/usr/bin/python"
+configure_args="-DPYTHON_EXECUTABLE=/usr/bin/python -DCMAKE_BUILD_TYPE=None
+ -DBUILD_TESTS=OFF"
 hostmakedepends="cmake python3 shiboken2"
 makedepends="python3-devel libshiboken2-devel qt5-devel
  qt5-multimedia-devel qt5-tools-devel qt5-plugin-mysql qt5-plugin-odbc
@@ -23,7 +24,7 @@ maintainer="yopito <pierre.bourgin@free.fr>"
 license="LGPL-3.0-or-later"
 homepage="https://wiki.qt.io/Qt_for_Python"
 distfiles="https://download.qt.io/official_releases/QtForPython/pyside2/PySide2-${version}-src/${_pkgname}.tar.xz"
-checksum=3920a4fb353300260c9bc46ff70f1fb975c5e7efa22e9d51222588928ce19b33
+checksum=23436302c8deb5b4cbc769b205d09604e38ba83b40708efccb7bd8c9af6f6b5d
 
 build_options="webengine"
 desc_option_webengine="Build Qt5 WebEngine bindings"

From 2a96e2a392146e0eb964fb21d861542934ddba85 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:35 -0400
Subject: [PATCH 098/116] konqueror: revbump for ffmpeg-6.0

---
 srcpkgs/konqueror/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/konqueror/template b/srcpkgs/konqueror/template
index d8d0e73a78ab..c5bdba601d3c 100644
--- a/srcpkgs/konqueror/template
+++ b/srcpkgs/konqueror/template
@@ -1,11 +1,11 @@
 # Template file for 'konqueror'
 pkgname=konqueror
 version=23.04.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DDESKTOPTOJSON_EXECUTABLE=/usr/bin/desktoptojson"
 hostmakedepends="extra-cmake-modules python3 qt5-host-tools qt5-qmake kdoctools
-kcoreaddons kconfig gettext"
+ kcoreaddons kconfig gettext"
 makedepends="qt5-devel qt5-webengine-devel qt5-declarative-devel
  qt5-webchannel-devel qt5-location-devel kcmutils-devel kdelibs4support-devel
  karchive-devel khtml-devel kdesu-devel kactivities5-devel"

From 3f168ac56b038cd93d9f3b97257c3dcda3efcd07 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:58 -0400
Subject: [PATCH 099/116] qt5-speech: revbump for qt5-5.15.8

---
 srcpkgs/qt5-speech/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-speech/template b/srcpkgs/qt5-speech/template
index 3ecd10d50650..2d7d4d4d2453 100644
--- a/srcpkgs/qt5-speech/template
+++ b/srcpkgs/qt5-speech/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-speech'
 pkgname=qt5-speech
 version=5.15.7
-revision=2
+revision=3
 _commit=d32f4a479d38a11f547598004b975f4356424a16
 build_style=qmake
 configure_args="-- -flite -flite-alsa -speechd"

From c767afad64857af597e3a2b60c838dcdf77d4bfb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 18:38:50 -0400
Subject: [PATCH 100/116] qt5-styleplugins: revbump for qt5-5.15.8

---
 srcpkgs/qt5-styleplugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-styleplugins/template b/srcpkgs/qt5-styleplugins/template
index 96ed97d12cd2..30d93660a2a4 100644
--- a/srcpkgs/qt5-styleplugins/template
+++ b/srcpkgs/qt5-styleplugins/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-styleplugins'
 pkgname=qt5-styleplugins
 version=5.0.0
-revision=20
+revision=21
 _gitrev=335dbece103e2cbf6c7cf819ab6672c2956b17b3
 build_style=qmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From c1aac6254ec530baa6343d00e39da9247fc18541 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 30 Apr 2023 20:22:26 -0400
Subject: [PATCH 101/116] gst-plugins-ugly1: revbump for ffmpeg-6.0

---
 srcpkgs/gst-plugins-ugly1/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-plugins-ugly1/template b/srcpkgs/gst-plugins-ugly1/template
index e254fd40f869..85ae64bc7a0a 100644
--- a/srcpkgs/gst-plugins-ugly1/template
+++ b/srcpkgs/gst-plugins-ugly1/template
@@ -1,6 +1,6 @@
 # Template file for 'gst-plugins-ugly1'
 pkgname=gst-plugins-ugly1
-version=1.20.3
+version=1.22.2
 revision=1
 build_style=meson
 configure_args="-Damrnb=disabled -Damrwbdec=disabled -Dsidplay=disabled"
@@ -15,4 +15,4 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname/1/}/${pkgname/1/}-${version}.tar.xz"
-checksum=8caa20789a09c304b49cf563d33cca9421b1875b84fcc187e4a385fa01d6aefd
+checksum=8f30f44db0bd063709bf6fbe55138e3a98af0abcb61c360f35582bbe10e80691

From df980b4b44f96a0e456279af047e7508512f9541 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 30 Apr 2023 20:22:26 -0400
Subject: [PATCH 102/116] gst-rtsp-server: revbump for ffmpeg-6.0

---
 srcpkgs/gst-rtsp-server/template | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index 8ceea8d34b4b..980fd72cdd4c 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
-version=1.20.3
-revision=3
+version=1.22.2
+revision=2
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="glib-devel gst-plugins-bad1-devel gobject-introspection
@@ -10,5 +10,5 @@ short_desc="GStreamer multimedia graph framework - rtsp server"
 maintainer="1is7ac3 <isaac.qa13@gmail.com>"
 license="LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
-distfiles="https://gstreamer.freedesktop.org/src/gst-rtsp-server/gst-rtsp-server-${version}.tar.xz"
-checksum=ee402718be9b127f0e5e66ca4c1b4f42e4926ec93ba307b7ccca5dc6cc9794ca
+distfiles="${homepage}/src/${pkgname}/${pkgname}-${version}.tar.xz"
+checksum=2be4aecfb88710100ea7115ed0216403e8094344ebf146094271b8d4d73828bf

From ca82bfa9e3c99e3dbeff6868b98e2aaefd087b26 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 30 Apr 2023 20:22:26 -0400
Subject: [PATCH 103/116] gst-libav: revbump for ffmpeg-6.0

---
 srcpkgs/gst-libav/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index f082bd211c65..04c39bff1489 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,6 +1,6 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
-version=1.20.3
+version=1.22.2
 revision=2
 build_style=meson
 hostmakedepends="pkg-config yasm"
@@ -11,7 +11,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.0-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname}/${pkgname}-${version}.tar.xz"
-checksum=3fedd10560fcdfaa1b6462cbf79a38c4e7b57d7f390359393fc0cef6dbf27dfe
+checksum=fcaaf9878fe8f3bc82317ef13a1558824cb68df1f8968c6797f556c5e33bcffd
 
 case "$XBPS_TARGET_MACHINE" in
 	*-musl) # Required by musl for M_SQRT1_2

From b1ec495c4bfe3a6c30528197bdf650a99a2cbfe4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 7 May 2023 20:14:14 -0400
Subject: [PATCH 104/116] mlt7: revbump for ffmpeg-6.0

---
 srcpkgs/gst-libav/template             | 2 +-
 srcpkgs/gst-omx/template               | 4 ++--
 srcpkgs/gst-plugins-base1/template     | 4 ++--
 srcpkgs/gst-plugins-good1/template     | 4 ++--
 srcpkgs/gst1-editing-services/template | 4 ++--
 srcpkgs/gst1-python3/template          | 6 +++---
 srcpkgs/gstreamer-vaapi/template       | 4 ++--
 srcpkgs/gstreamer1/template            | 4 ++--
 srcpkgs/mlt7/template                  | 2 +-
 9 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index 04c39bff1489..8c72fc3e97ee 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.22.2
-revision=2
+revision=1
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"
diff --git a/srcpkgs/gst-omx/template b/srcpkgs/gst-omx/template
index 893535c463da..5ad54cc7b9d8 100644
--- a/srcpkgs/gst-omx/template
+++ b/srcpkgs/gst-omx/template
@@ -1,6 +1,6 @@
 # Template file for 'gst-omx'
 pkgname=gst-omx
-version=1.20.3
+version=1.22.2
 revision=1
 build_style=meson
 configure_args="-Dexamples=disabled -Dtarget=generic"
@@ -11,4 +11,4 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.1-only"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname}/${pkgname}-${version}.tar.xz"
-checksum=8db48040bb41f09edf8d17ff6d16c54888d7777ba4501c2c69f0083350ea9a15
+checksum=1b0c57f2cc4ddeec5e7f0c436e502f06665c4e93c73261855b94e04fc94337b2
diff --git a/srcpkgs/gst-plugins-base1/template b/srcpkgs/gst-plugins-base1/template
index 29e8f76bd1fe..2f20ea819849 100644
--- a/srcpkgs/gst-plugins-base1/template
+++ b/srcpkgs/gst-plugins-base1/template
@@ -1,6 +1,6 @@
 # Template file for 'gst-plugins-base1'
 pkgname=gst-plugins-base1
-version=1.20.3
+version=1.22.2
 revision=1
 build_style=meson
 build_helper="gir"
@@ -22,7 +22,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname/1/}/${pkgname/1/}-${version}.tar.xz"
-checksum=7e30b3dd81a70380ff7554f998471d6996ff76bbe6fc5447096f851e24473c9f
+checksum=eb65120c4ee79b7a153c3c1972d5c0158c2151877cc51ec7725bba5749679d49
 
 build_options="cdparanoia gir sndio wayland"
 build_options_default="cdparanoia gir wayland"
diff --git a/srcpkgs/gst-plugins-good1/template b/srcpkgs/gst-plugins-good1/template
index 1f5e620ce1fd..5d0fe1bfe284 100644
--- a/srcpkgs/gst-plugins-good1/template
+++ b/srcpkgs/gst-plugins-good1/template
@@ -1,6 +1,6 @@
 # Template file for 'gst-plugins-good1'
 pkgname=gst-plugins-good1
-version=1.20.3
+version=1.22.2
 revision=1
 build_style=meson
 configure_args="-Ddv=disabled -Ddv1394=disabled -Dshout2=disabled -Dqt5=enabled
@@ -22,7 +22,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname/1/}/${pkgname/1/}-${version}.tar.xz"
-checksum=f8f3c206bf5cdabc00953920b47b3575af0ef15e9f871c0b6966f6d0aa5868b7
+checksum=7c8cc59425f2b232f60ca7d13e56edd615da4f711e73dd01a7cffa46e6bc0cdd
 
 build_options="gtk3 wayland"
 build_options_default="gtk3 wayland"
diff --git a/srcpkgs/gst1-editing-services/template b/srcpkgs/gst1-editing-services/template
index 673b46970f24..102440f7f253 100644
--- a/srcpkgs/gst1-editing-services/template
+++ b/srcpkgs/gst1-editing-services/template
@@ -1,6 +1,6 @@
 # Template file for 'gst1-editing-services'
 pkgname=gst1-editing-services
-version=1.20.3
+version=1.22.2
 revision=1
 build_style=meson
 build_helper="gir"
@@ -12,7 +12,7 @@ maintainer="Toyam Cox <Vaelatern@gmail.com>"
 license="LGPL-2.0-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname/gst1/gst}/${pkgname/gst1/gst}-${version}.tar.xz"
-checksum=5fd896de69fbe24421eb6b0ff8d2f8b4c3cba3f3025ceacd302172f39a8abaa2
+checksum=453b1464fc3857de269a7cb0ebd966afe02171d97bef672a0b8a0a6d43e0cebf
 
 do_check() {
 	: # Tests fail in older versions as well
diff --git a/srcpkgs/gst1-python3/template b/srcpkgs/gst1-python3/template
index 3f564ac64b93..789e40f036ea 100644
--- a/srcpkgs/gst1-python3/template
+++ b/srcpkgs/gst1-python3/template
@@ -1,7 +1,7 @@
 # Template file for 'gst1-python3'
 pkgname=gst1-python3
-version=1.20.3
-revision=2
+version=1.22.2
+revision=1
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="libglib-devel python3-devel python3-gobject-devel gst-plugins-base1-devel"
@@ -11,4 +11,4 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/gst-python/gst-python-${version}.tar.xz"
-checksum=db348120eae955b8cc4de3560a7ea06e36d6e1ddbaa99a7ad96b59846601cfdc
+checksum=bef2b3d82ce4be46b775b1bb56305c1003ee01b535a53a82f9fe8924972153ad
diff --git a/srcpkgs/gstreamer-vaapi/template b/srcpkgs/gstreamer-vaapi/template
index 3cc4e057559a..0a5ee8b1ca3f 100644
--- a/srcpkgs/gstreamer-vaapi/template
+++ b/srcpkgs/gstreamer-vaapi/template
@@ -1,6 +1,6 @@
 # Template file for 'gstreamer-vaapi'
 pkgname=gstreamer-vaapi
-version=1.20.3
+version=1.22.2
 revision=1
 build_style=meson
 hostmakedepends="pkg-config"
@@ -11,7 +11,7 @@ license="LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
 changelog="https://raw.githubusercontent.com/GStreamer/gstreamer-vaapi/master/ChangeLog"
 distfiles="${homepage}/src/gstreamer-vaapi/gstreamer-vaapi-${version}.tar.xz"
-checksum=6ee99eb316abdde9ad37002915bd8c3867918f6fdc74b7cf2ac4c1ae0d690b45
+checksum=d2e642f9745f97d9f73a7f5085e7659a9a31fe209b774e6e45dae041b435df06
 
 pre_check() {
 	# Seems to need certain hardware to pass
diff --git a/srcpkgs/gstreamer1/template b/srcpkgs/gstreamer1/template
index ae8a49cb20e8..571148f2ff33 100644
--- a/srcpkgs/gstreamer1/template
+++ b/srcpkgs/gstreamer1/template
@@ -1,6 +1,6 @@
 # Template file for 'gstreamer1'
 pkgname=gstreamer1
-version=1.20.3
+version=1.22.2
 revision=1
 build_style=meson
 build_helper="gir"
@@ -16,7 +16,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.0-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/gstreamer/gstreamer-${version}.tar.xz"
-checksum=607daf64bbbd5fb18af9d17e21c0d22c4d702fffe83b23cb22d1b1af2ca23a2a
+checksum=b2afe73603921c608ba48969dbb7d743776744bfe5d8059ece241137b7f88e21
 
 pre_check() {
 	# gst_gstdatetime is known to fail according to LFS
diff --git a/srcpkgs/mlt7/template b/srcpkgs/mlt7/template
index 9fb7f60d692e..cca0eb68cfc3 100644
--- a/srcpkgs/mlt7/template
+++ b/srcpkgs/mlt7/template
@@ -1,7 +1,7 @@
 # Template file for 'mlt7'
 pkgname=mlt7
 version=7.14.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSWIG_PYTHON=ON"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which

From 1597ac5f9f4204791d6ef1a4f5018f7d20b60cb9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 7 May 2023 20:15:03 -0400
Subject: [PATCH 105/116] qt6-webengine: revbump for ffmpeg-6.0

---
 srcpkgs/qt6-webengine/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-webengine/template b/srcpkgs/qt6-webengine/template
index 4e22cb6e8863..f948dc919a15 100644
--- a/srcpkgs/qt6-webengine/template
+++ b/srcpkgs/qt6-webengine/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-webengine'
 pkgname=qt6-webengine
 version=6.5.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="
  -DQT_FEATURE_webengine_system_ffmpeg=ON

From ada4a3d7586c116d5f6d932a2e1ff10231a38a82 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 7 May 2023 20:15:29 -0400
Subject: [PATCH 106/116] tracker-miners: revbump for ffmpeg-6.0

---
 srcpkgs/tracker-miners/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tracker-miners/template b/srcpkgs/tracker-miners/template
index 8c005d697fa4..a6e5aa577702 100644
--- a/srcpkgs/tracker-miners/template
+++ b/srcpkgs/tracker-miners/template
@@ -1,7 +1,7 @@
 # Template file for 'tracker-miners'
 pkgname=tracker-miners
 version=3.5.0
-revision=3
+revision=4
 build_style=meson
 build_helper=qemu
 # missing libgrss for miner_rss

From 370f8b1bbdb7d75886c704a45817613e2778204f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 7 May 2023 20:20:58 -0400
Subject: [PATCH 107/116] mpd: revbump for ffmpeg-6.0

---
 srcpkgs/mpd/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpd/template b/srcpkgs/mpd/template
index 9dbd4c935acc..9f058b62df2f 100644
--- a/srcpkgs/mpd/template
+++ b/srcpkgs/mpd/template
@@ -1,7 +1,7 @@
 # Template file for 'mpd'
 pkgname=mpd
 version=0.23.13
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dopus=enabled -Dmikmod=enabled -Dneighbor=true
  -Dsoundcloud=enabled -Dpipe=true -Dtwolame=enabled -Dbzip2=enabled

From 38742ed16aa5da3d06f41c41138c40548d309976 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 11 May 2023 14:05:14 -0400
Subject: [PATCH 108/116] openmw: revbump for ffmpeg-6.0

---
 srcpkgs/openmw/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openmw/template b/srcpkgs/openmw/template
index e3771c7aaf1a..3cbf20b06577 100644
--- a/srcpkgs/openmw/template
+++ b/srcpkgs/openmw/template
@@ -1,7 +1,7 @@
 # Template file for 'openmw'
 pkgname=openmw
 version=0.47.0
-revision=5
+revision=6
 build_style=cmake
 _recast_commit=e75adf86f91eb3082220085e42dda62679f9a3ea
 _bullet_tag=3.17

From 8c3fbd6ce7799a6ddf646922bec2de6995bd1fe3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 21 May 2023 12:44:11 -0400
Subject: [PATCH 109/116] electron24: revbump for ffmpeg-6.0

---
 srcpkgs/electron24/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron24/template b/srcpkgs/electron24/template
index bdaa56adc8a6..ff3d5e3ef381 100644
--- a/srcpkgs/electron24/template
+++ b/srcpkgs/electron24/template
@@ -1,7 +1,7 @@
 # Template file for 'electron24'
 pkgname=electron24
 version=24.3.0
-revision=1
+revision=2
 _nodever=18.14.0
 _chromiumver=112.0.5615.165
 archs="x86_64* aarch64*"

From f669d29f983dc003754c1508a73d6e9821216b36 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Jun 2023 08:20:22 -0400
Subject: [PATCH 110/116] gtk4: revbump for ffmpeg-6.0

---
 srcpkgs/gtk4/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gtk4/template b/srcpkgs/gtk4/template
index b318b7bae1dd..e3bde4a50e54 100644
--- a/srcpkgs/gtk4/template
+++ b/srcpkgs/gtk4/template
@@ -1,7 +1,7 @@
 # Template file for 'gtk4'
 pkgname=gtk4
 version=4.10.4
-revision=1
+revision=2
 build_style=meson
 build_helper="gir"
 configure_args="-Dman-pages=true -Dgtk_doc=true -Dbuild-tests=false

From 39f1bd6eb6b52c8cef2c2eb79a9e4604639c12d5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:25:50 -0400
Subject: [PATCH 111/116] electron19: revbump for ffmpeg-6.0

---
 srcpkgs/electron19/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron19/template b/srcpkgs/electron19/template
index 32ce301e730c..ab7f308f5e8a 100644
--- a/srcpkgs/electron19/template
+++ b/srcpkgs/electron19/template
@@ -1,7 +1,7 @@
 # Template file for 'electron19'
 pkgname=electron19
 version=19.0.8
-revision=3
+revision=4
 _nodever=16.14.2
 _chromiumver=102.0.5005.125
 archs="x86_64* aarch64* ppc64le*"

From 7d6ca920adbdec8dbb26760547755e9f39916713 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:28:26 -0400
Subject: [PATCH 112/116] siril: revbump for ffmpeg-6.0

---
 srcpkgs/siril/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/siril/template b/srcpkgs/siril/template
index 84332f79d060..62750dd24754 100644
--- a/srcpkgs/siril/template
+++ b/srcpkgs/siril/template
@@ -1,7 +1,7 @@
 # Template file for 'siril'
 pkgname=siril
 version=0.9.12
-revision=10
+revision=11
 build_style=gnu-configure
 hostmakedepends="pkg-config intltool autoconf automake gettext-devel"
 makedepends="fftw-devel libconfig-devel libopencv-devel libffms2-devel

From f87972bb006e5228486f7efea3df5bb8cc407953 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:29:08 -0400
Subject: [PATCH 113/116] telegram-desktop: revbump for ffmpeg-6.0

---
 srcpkgs/telegram-desktop/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/telegram-desktop/template b/srcpkgs/telegram-desktop/template
index f114b2341dc5..9db9f80c1a53 100644
--- a/srcpkgs/telegram-desktop/template
+++ b/srcpkgs/telegram-desktop/template
@@ -1,7 +1,7 @@
 # Template file for 'telegram-desktop'
 pkgname=telegram-desktop
 version=4.8.1
-revision=3
+revision=4
 build_style=cmake
 build_helper="qemu"
 configure_args="-DTDESKTOP_API_ID=209235

From 664e953f467ebaee123e508ae84a594f9cce533f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 10 Jun 2023 00:40:39 -0400
Subject: [PATCH 114/116] freecad: revbump for qt5-webengine-5.15.13

---
 srcpkgs/freecad/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/freecad/template b/srcpkgs/freecad/template
index a4a3f5f76b29..8608d1670c87 100644
--- a/srcpkgs/freecad/template
+++ b/srcpkgs/freecad/template
@@ -1,7 +1,7 @@
 # Template file for 'freecad'
 pkgname=freecad
 version=0.20.2
-revision=5
+revision=6
 build_style=cmake
 
 _inst_prefix=/usr/lib/${pkgname}

From e912dcc249b3f8a35decc5ae0a7c8fdbb61db39a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 10 Jun 2023 00:57:09 -0400
Subject: [PATCH 115/116] qt6-multimedia: revbump for ffmpeg-6.0

---
 srcpkgs/qt6-multimedia/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-multimedia/template b/srcpkgs/qt6-multimedia/template
index a6832fdd69bf..c9ffac914ab8 100644
--- a/srcpkgs/qt6-multimedia/template
+++ b/srcpkgs/qt6-multimedia/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-multimedia'
 pkgname=qt6-multimedia
 version=6.5.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DQT_FEATURE_gstreamer=ON"
 hostmakedepends="perl qt6-declarative-host-tools pkg-config qt6-shadertools"

From 8240d536c49d2480508d33a680738fe3903ff7e2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 17 Jun 2023 15:28:21 -0400
Subject: [PATCH 116/116] kdenlive: revbump for ffmpeg-6.0

---
 srcpkgs/kdenlive/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kdenlive/template b/srcpkgs/kdenlive/template
index 429126ef3c3b..0c5f7bf698fb 100644
--- a/srcpkgs/kdenlive/template
+++ b/srcpkgs/kdenlive/template
@@ -1,7 +1,7 @@
 # Template file for 'kdenlive'
 pkgname=kdenlive
 version=23.04.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="
  extra-cmake-modules kconfig kcoreaddons kdoctools pkg-config python3

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (11 preceding siblings ...)
  2023-06-17 19:28 ` zlice
@ 2023-06-19 20:19 ` zlice
  2023-06-22 14:28 ` zlice
                   ` (84 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2023-06-19 20:19 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 3480 bytes --]

There is an updated pull request by zlice against master on the void-packages repository

https://github.com/zlice/void-packages ffmpeg6-split
https://github.com/void-linux/void-packages/pull/43761

ffmpeg6 split
[ci skip]


#### Testing the changes

- I tested the changes in this PR: **YES**

main testing has been vaapi in Firefox Nightly and enc/dec in Shotcut on Intel A770

#### New package

- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**

#### Local build testing

- I built this PR locally for my native architecture, **x86_64**

#### Discussion

Continuation of https://github.com/void-linux/void-packages/pull/36315

`libavresample` is deprecated, but marked as a dependency when trying to build other packages and install `ffmpeg`(6). I think the right way to handle this is make a meta package and the add to removals?


##### Commit naming / misc

~~Commits are 'dirty' right now, running with [gstreamer 1.22.1 updates](https://github.com/void-linux/void-packages/pull/42861) and [Intel OpenCL](https://github.com/void-linux/void-packages/pull/43084). This will also make [intel packages pr](https://github.com/void-linux/void-packages/pull/41132) obsolete.~~ (see Requirements below)

Maintainer for previous ffmpeg(4) was orphaned, I can put my name in there if that matters, though I don't exactly see myself keeping up on ffmpeg.

This updates QT5 which looks like it is usually hosted by Johnny. Not sure if there's any reason to stay there or these sources are fine.

##### STILL FFMPEG4

These are a mix of emulators, games and/or older packages.

- attract (multiple patches in master)
- audacity (https://github.com/audacity/audacity/issues/2305 and https://sourceforge.net/p/portmedia/wiki/portsmf/ is 'beta')
- ccextractor (master patches? no release)
- vice
- kodi
- mlt (only dep left is flowblade)
- ~~synfig (mlt)~~ (work with mlt7, bump synfigstudio)
- tvheadend
- ssr
- spek-alternative
- ppsspp
- olive
- moc
- mediastreamer
- libextractor
- idjc
- hedgewars
- ~~ffmpegthumbnailer~~ (patches for moviedecoder.xxx files)
- ~~ffmpegthumbs~~ (latest compiles)
- deadbeef
- omxplayer
- qtav (fork has ffmpeg 5 patch - https://github.com/cmguo/QtAV)
- `vlc` (vlc4 will support ffmpeg5, there's a patch to build 3.x with ffmpeg5 but it will lack vaapi)
- `osg` (OpenSceneGraph plus `xine-lib`)


##### HAVE NOT BUILT YET

- omxplayer (rpi only? ffmpeg4)
- kodi (big, but ffmpeg4)


##### UPDATED (for ffmpeg6)

- ~~blender: update to 3.5.1~~ ~~will be revbump with~~ https://github.com/void-linux/void-packages/pull/43992
- unpaper: update to 7.0.0.
- guvcview: update to 2.0.8.
- qt5: update to 5.15.8
- qt5-webengine: update to 5.18.13
- shiboken2: revbump for qt5.15.8 (patch)
- python3-pyside2: update to 5.15.8 (patch)


##### Requirements

- [gstreamer 1.22.2](https://github.com/void-linux/void-packages/pull/42861) - a few packages use ffmpeg-devel and require a revbump

- [Intel Packages](https://github.com/void-linux/void-packages/pull/41132) - ffmpeg4 uses different libraries than 6 (libmfx / Intel-MediaSDK vs only oneVPL that Intel is moving to), both are included here

- [shotcut 23.05.14](https://github.com/void-linux/void-packages/pull/44260)

A patch file from https://github.com/void-linux/void-packages/pull/43761.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ffmpeg6-split-43761.patch --]
[-- Type: text/x-diff, Size: 787348 bytes --]

From b7d9a2ee2da1176723d745c930629a8faed6ff9e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:55:46 -0400
Subject: [PATCH 001/116] ffmpeg: update to 6.0.

---
 common/shlibs                                 | 26 +++++---
 srcpkgs/ffmpeg/files/altivec.patch            | 60 -------------------
 .../patches/armv5tel-floating-point.patch     | 18 ------
 .../workaround-mesa-readeon-vaapi-bug.patch   | 28 ---------
 srcpkgs/ffmpeg/template                       | 38 +++++-------
 5 files changed, 32 insertions(+), 138 deletions(-)
 delete mode 100644 srcpkgs/ffmpeg/files/altivec.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch

diff --git a/common/shlibs b/common/shlibs
index c293ac460c08..05c292a04aa2 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -387,15 +387,23 @@ libid3tag.so.0 libid3tag-0.15.1b_1
 libgif.so.7 giflib-5.1.0_1
 libImlib2.so.1 imlib2-1.4.2_1
 libmp3lame.so.0 lame-3.98.2_1
-libavdevice.so.58 libavdevice-4.0_1
-libavformat.so.58 libavformat-4.0_1
-libswscale.so.5 libswscale-4.0_1
-libswresample.so.3 libswresample-4.0_1
-libavresample.so.4 libavresample-4.0_1
-libpostproc.so.55 libpostproc-4.0_1
-libavcodec.so.58 libavcodec-4.0_1
-libavutil.so.56 libavutil-4.0_1
-libavfilter.so.7 libavfilter-4.0_1
+libavdevice.so.60 libavdevice-6.0_1
+libavformat.so.60 libavformat-6.0_1
+libswscale.so.7 libswscale-6.0_1
+libswresample.so.4 libswresample-6.0_1
+libpostproc.so.57 libpostproc-6.0_1
+libavcodec.so.60 libavcodec-6.0_1
+libavutil.so.58 libavutil-6.0_1
+libavfilter.so.9 libavfilter-6.0_1
+libavdevice.so.58 libavdevice4-4.0_1
+libavformat.so.58 libavformat4-4.0_1
+libswscale.so.5 libswscale4-4.0_1
+libswresample.so.3 libswresample4-4.0_1
+libavresample.so.4 libavresample4-4.0_1
+libpostproc.so.55 libpostproc4-4.0_1
+libavcodec.so.58 libavcodec4-4.0_1
+libavutil.so.56 libavutil4-4.0_1
+libavfilter.so.7 libavfilter4-4.0_1
 libSDL-1.2.so.0 SDL-1.2.14_1
 libSDL_image-1.2.so.0 SDL_image-1.2.10_1
 libx264.so.157 x264-20190507.2245_1
diff --git a/srcpkgs/ffmpeg/files/altivec.patch b/srcpkgs/ffmpeg/files/altivec.patch
deleted file mode 100644
index 9c5720046332..000000000000
--- a/srcpkgs/ffmpeg/files/altivec.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-revert some altivec specific change on all ppc* except ppc64le*
-
-q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
-conditionally, for ppc* but not ppc64le* (the new code is valid for
-POWER8 VSX which LE targets as a baseline but not BE)"
-
-
-This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
----
- libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
- 1 file changed, 20 insertions(+), 4 deletions(-)
-
-diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
-index 536545293d..c1e2852adb 100644
---- a/libswscale/ppc/yuv2rgb_altivec.c
-+++ b/libswscale/ppc/yuv2rgb_altivec.c
-@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-     vector signed short R1, G1, B1;                                           \
-     vector unsigned char R, G, B;                                             \
-                                                                               \
-+    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
-+    vector unsigned char align_perm;                                          \
-+                                                                              \
-     vector signed short lCY       = c->CY;                                    \
-     vector signed short lOY       = c->OY;                                    \
-     vector signed short lCRV      = c->CRV;                                   \
-@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
-                                                                               \
-         for (j = 0; j < w / 16; j++) {                                        \
--            y0 = vec_xl(0, y1i);                                              \
-+            y1ivP = (const vector unsigned char *) y1i;                       \
-+            y2ivP = (const vector unsigned char *) y2i;                       \
-+            uivP  = (const vector unsigned char *) ui;                        \
-+            vivP  = (const vector unsigned char *) vi;                        \
-+                                                                              \
-+            align_perm = vec_lvsl(0, y1i);                                    \
-+            y0 = (vector unsigned char)                                       \
-+                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
-                                                                               \
--            y1 = vec_xl(0, y2i);                                              \
-+            align_perm = vec_lvsl(0, y2i);                                    \
-+            y1 = (vector unsigned char)                                       \
-+                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
-                                                                               \
--            u = (vector signed char) vec_xl(0, ui);                           \
-+            align_perm = vec_lvsl(0, ui);                                     \
-+            u = (vector signed char)                                          \
-+                    vec_perm(uivP[0], uivP[1], align_perm);                   \
-                                                                               \
--            v = (vector signed char) vec_xl(0, vi);                           \
-+            align_perm = vec_lvsl(0, vi);                                     \
-+            v = (vector signed char)                                          \
-+                    vec_perm(vivP[0], vivP[1], align_perm);                   \
-                                                                               \
-             u = (vector signed char)                                          \
-                     vec_sub(u,                                                \
--- 
-2.27.0
-
diff --git a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
deleted file mode 100644
index 9a55178c74f0..000000000000
--- a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
-+++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
-@@ -39,6 +39,15 @@
- #endif
- #include <fenv.h>
- 
-+#if (FE_ALL_EXCEPT == 0)
-+/* E.g. ARM soft float does not define these */
-+#define FE_INVALID    0
-+#define FE_DIVBYZERO  0
-+#define FE_OVERFLOW   0
-+#define FE_UNDERFLOW  0
-+#define FE_INEXACT    0
-+#endif
-+
- #if CONFIG_LIBFONTCONFIG
- #include <fontconfig/fontconfig.h>
- #endif
diff --git a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
deleted file mode 100644
index 00e3f68a415b..000000000000
--- a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
-From: Rainer Hochecker <fernetmenta@online.de>
-Date: Sat, 26 Jan 2019 19:48:35 +0100
-Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
-
-This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
-It was hit frequently when watching h264 channels received via DVB-X.
-Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
----
- libavcodec/vaapi_h264.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
-index 5854587a255..f12fdc457a4 100644
---- a/libavcodec/vaapi_h264.c
-+++ b/libavcodec/vaapi_h264.c
-@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
-     H264SliceContext *sl = &h->slice_ctx[0];
-     int ret;
- 
-+    if (pic->nb_slices == 0) {
-+        ret = AVERROR_INVALIDDATA;
-+        goto finish;
-+    }
-+
-     ret = ff_vaapi_decode_issue(avctx, pic);
-     if (ret < 0)
-         goto finish;
diff --git a/srcpkgs/ffmpeg/template b/srcpkgs/ffmpeg/template
index df4179d1963a..f742082bb520 100644
--- a/srcpkgs/ffmpeg/template
+++ b/srcpkgs/ffmpeg/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpeg'
 # audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
 pkgname=ffmpeg
-version=4.4.4
+version=6.0
 revision=1
 short_desc="Decoding, encoding and streaming software"
 maintainer="Orphaned <orphan@voidlinux.org>"
@@ -9,7 +9,7 @@ license="GPL-3.0-or-later"
 homepage="https://www.ffmpeg.org"
 changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
 distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
-checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+checksum=57be87c22d9b49c112b6d24bc67d42508660e6b718b3db89c44e47e289137082
 
 hostmakedepends="pkg-config perl"
 makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
@@ -26,12 +26,13 @@ makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-deve
  $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
  $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
  $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
- $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers Vulkan-Tools Vulkan-ValidationLayers')
+ $(vopt_if onevpl 'onevpl onevpl-devel')
  $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
 depends="ffplay>=${version}_${revision}"
 
 build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
- dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec onevpl"
 build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
 desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
 desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
@@ -39,10 +40,8 @@ desc_option_sofa="Enable support for AES SOFA"
 desc_option_webp="Enable support for WebP"
 
 case "$XBPS_TARGET_MACHINE" in
-	i686*|x86_64*)
-		hostmakedepends+=" nasm"
-		build_options_default+=" vaapi vdpau nvenc nvdec"
-		;;
+	i686*) build_options_default+=" vaapi vdpau nvenc nvdec";;
+	x86_64*) build_options_default+=" vaapi vdpau nvenc nvdec onevpl";;
 	ppc64*) build_options_default+=" vaapi vdpau";;
 	mips*) CFLAGS="-mnan=legacy";;
 esac
@@ -117,18 +116,19 @@ do_configure() {
 		$(vopt_enable x265 libx265) \
 		$(vopt_enable v4l2 libv4l2) \
 		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
-		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		--enable-libbs2b --enable-libvidstab \
 		$(vopt_enable dav1d libdav1d) \
 		$(vopt_enable zimg libzimg) \
 		$(vopt_enable webp libwebp) \
 		$(vopt_enable sofa libmysofa) \
 		$(vopt_enable vulkan) \
+		$(vopt_enable onevpl libvpl) \
 		$(vopt_enable drm libdrm) \
 		$(vopt_enable svtav1 libsvtav1) \
 		$(vopt_enable srt libsrt) \
 		$(vopt_enable rist librist) \
-		$(vopt_if nvenc '--enable-nvenc') \
-		$(vopt_if nvdec '--enable-nvdec')
+		$(vopt_enable nvenc nvenc) \
+		$(vopt_enable nvdec nvdec)
 }
 
 do_build() {
@@ -155,10 +155,8 @@ libavdevice_package() {
 }
 
 libavresample_package() {
-	short_desc="FFmpeg audio resampling library"
-	pkg_install() {
-		vmove "usr/lib/libavresample.so.*"
-	}
+	short_desc="Package deprecated, removal needed"
+	build_style=meta
 }
 
 libavformat_package() {
@@ -212,15 +210,9 @@ ffmpeg-devel_package() {
 		libavfilter>=${version}_${revision}
 		libpostproc>=${version}_${revision}
 		libswscale>=${version}_${revision}
-		libswresample>=${version}_${revision}
-		libavresample>=${version}_${revision}"
+		libswresample>=${version}_${revision}"
 	short_desc+=" - development files"
-
-	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
-		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
-		nostrip_files="/usr/lib/libavfilter.a"
-	fi
-
+	conflicts="ffmpeg4-devel"
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig

From 3c76675123699b26a24c751d8eb0c757718ab471 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:56:22 -0400
Subject: [PATCH 002/116] New package: ffmpeg4-4.4.4.

---
 srcpkgs/ffmpeg4-devel                         |   1 +
 srcpkgs/ffmpeg4/files/altivec.patch           |  60 +++++
 .../patches/armv5tel-floating-point.patch     |  18 ++
 .../workaround-mesa-readeon-vaapi-bug.patch   |  28 +++
 srcpkgs/ffmpeg4/template                      | 238 ++++++++++++++++++
 srcpkgs/libavcodec4                           |   1 +
 srcpkgs/libavdevice4                          |   1 +
 srcpkgs/libavfilter4                          |   1 +
 srcpkgs/libavformat4                          |   1 +
 srcpkgs/libavresample4                        |   1 +
 srcpkgs/libavutil4                            |   1 +
 srcpkgs/libpostproc4                          |   1 +
 srcpkgs/libswresample4                        |   1 +
 srcpkgs/libswscale4                           |   1 +
 14 files changed, 354 insertions(+)
 create mode 120000 srcpkgs/ffmpeg4-devel
 create mode 100644 srcpkgs/ffmpeg4/files/altivec.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
 create mode 100644 srcpkgs/ffmpeg4/template
 create mode 120000 srcpkgs/libavcodec4
 create mode 120000 srcpkgs/libavdevice4
 create mode 120000 srcpkgs/libavfilter4
 create mode 120000 srcpkgs/libavformat4
 create mode 120000 srcpkgs/libavresample4
 create mode 120000 srcpkgs/libavutil4
 create mode 120000 srcpkgs/libpostproc4
 create mode 120000 srcpkgs/libswresample4
 create mode 120000 srcpkgs/libswscale4

diff --git a/srcpkgs/ffmpeg4-devel b/srcpkgs/ffmpeg4-devel
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/ffmpeg4-devel
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/ffmpeg4/files/altivec.patch b/srcpkgs/ffmpeg4/files/altivec.patch
new file mode 100644
index 000000000000..9c5720046332
--- /dev/null
+++ b/srcpkgs/ffmpeg4/files/altivec.patch
@@ -0,0 +1,60 @@
+revert some altivec specific change on all ppc* except ppc64le*
+
+q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
+conditionally, for ppc* but not ppc64le* (the new code is valid for
+POWER8 VSX which LE targets as a baseline but not BE)"
+
+
+This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
+---
+ libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
+ 1 file changed, 20 insertions(+), 4 deletions(-)
+
+diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
+index 536545293d..c1e2852adb 100644
+--- a/libswscale/ppc/yuv2rgb_altivec.c
++++ b/libswscale/ppc/yuv2rgb_altivec.c
+@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+     vector signed short R1, G1, B1;                                           \
+     vector unsigned char R, G, B;                                             \
+                                                                               \
++    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
++    vector unsigned char align_perm;                                          \
++                                                                              \
+     vector signed short lCY       = c->CY;                                    \
+     vector signed short lOY       = c->OY;                                    \
+     vector signed short lCRV      = c->CRV;                                   \
+@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
+                                                                               \
+         for (j = 0; j < w / 16; j++) {                                        \
+-            y0 = vec_xl(0, y1i);                                              \
++            y1ivP = (const vector unsigned char *) y1i;                       \
++            y2ivP = (const vector unsigned char *) y2i;                       \
++            uivP  = (const vector unsigned char *) ui;                        \
++            vivP  = (const vector unsigned char *) vi;                        \
++                                                                              \
++            align_perm = vec_lvsl(0, y1i);                                    \
++            y0 = (vector unsigned char)                                       \
++                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
+                                                                               \
+-            y1 = vec_xl(0, y2i);                                              \
++            align_perm = vec_lvsl(0, y2i);                                    \
++            y1 = (vector unsigned char)                                       \
++                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
+                                                                               \
+-            u = (vector signed char) vec_xl(0, ui);                           \
++            align_perm = vec_lvsl(0, ui);                                     \
++            u = (vector signed char)                                          \
++                    vec_perm(uivP[0], uivP[1], align_perm);                   \
+                                                                               \
+-            v = (vector signed char) vec_xl(0, vi);                           \
++            align_perm = vec_lvsl(0, vi);                                     \
++            v = (vector signed char)                                          \
++                    vec_perm(vivP[0], vivP[1], align_perm);                   \
+                                                                               \
+             u = (vector signed char)                                          \
+                     vec_sub(u,                                                \
+-- 
+2.27.0
+
diff --git a/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
new file mode 100644
index 000000000000..9a55178c74f0
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
@@ -0,0 +1,18 @@
+--- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
++++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
+@@ -39,6 +39,15 @@
+ #endif
+ #include <fenv.h>
+ 
++#if (FE_ALL_EXCEPT == 0)
++/* E.g. ARM soft float does not define these */
++#define FE_INVALID    0
++#define FE_DIVBYZERO  0
++#define FE_OVERFLOW   0
++#define FE_UNDERFLOW  0
++#define FE_INEXACT    0
++#endif
++
+ #if CONFIG_LIBFONTCONFIG
+ #include <fontconfig/fontconfig.h>
+ #endif
diff --git a/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
new file mode 100644
index 000000000000..00e3f68a415b
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
@@ -0,0 +1,28 @@
+From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
+From: Rainer Hochecker <fernetmenta@online.de>
+Date: Sat, 26 Jan 2019 19:48:35 +0100
+Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
+
+This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
+It was hit frequently when watching h264 channels received via DVB-X.
+Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
+---
+ libavcodec/vaapi_h264.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
+index 5854587a255..f12fdc457a4 100644
+--- a/libavcodec/vaapi_h264.c
++++ b/libavcodec/vaapi_h264.c
+@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
+     H264SliceContext *sl = &h->slice_ctx[0];
+     int ret;
+ 
++    if (pic->nb_slices == 0) {
++        ret = AVERROR_INVALIDDATA;
++        goto finish;
++    }
++
+     ret = ff_vaapi_decode_issue(avctx, pic);
+     if (ret < 0)
+         goto finish;
diff --git a/srcpkgs/ffmpeg4/template b/srcpkgs/ffmpeg4/template
new file mode 100644
index 000000000000..5228c7df08fb
--- /dev/null
+++ b/srcpkgs/ffmpeg4/template
@@ -0,0 +1,238 @@
+# Template file for 'ffmpeg4'
+# audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
+pkgname=ffmpeg4
+version=4.4.4
+revision=1
+short_desc="Decoding, encoding and streaming software - ffmpeg4 libraries only"
+maintainer="Orphaned <orphan@voidlinux.org>"
+license="GPL-3.0-or-later"
+homepage="https://www.ffmpeg.org"
+changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
+distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
+checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+
+hostmakedepends="pkg-config perl"
+makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
+ libXext-devel libXvMC-devel libxcb-devel lame-devel libtheora-devel
+ libvorbis-devel x264-devel xvidcore-devel jack-devel SDL2-devel
+ libcdio-paranoia-devel librtmp-devel libmodplug-devel gnutls-devel
+ speex-devel celt-devel harfbuzz-devel libass-devel opus-devel ocl-icd-devel
+ libbs2b-devel libvidstab-devel $(vopt_if pulseaudio pulseaudio-devel)
+ $(vopt_if vaapi libva-devel) $(vopt_if vdpau libvdpau-devel)
+ $(vopt_if x265 x265-devel) $(vopt_if v4l2 v4l-utils-devel)
+ $(vopt_if fdk_aac fdk-aac-devel) $(vopt_if vpx libvpx-devel)
+ $(vopt_if aom libaom-devel) $(vopt_if sndio sndio-devel)
+ $(vopt_if dav1d libdav1d-devel) $(vopt_if zimg zimg-devel)
+ $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
+ $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
+ $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if mfx 'libmfx libmfx-devel')
+ $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
+
+build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec mfx"
+build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
+
+desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
+desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
+desc_option_sofa="Enable support for AES SOFA"
+desc_option_webp="Enable support for WebP"
+
+case "$XBPS_TARGET_MACHINE" in
+	i686*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau nvenc nvdec"
+			;;
+	x86_64*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau mfx nvenc nvdec"
+			;;
+	ppc64*) build_options_default+=" vaapi vdpau";;
+	mips*) CFLAGS="-mnan=legacy";;
+esac
+
+if [ "$XBPS_TARGET_WORDSIZE" != "32" ]; then
+	build_options_default+=" svtav1"
+fi
+
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+fi
+
+_apply_patch() {
+	local args="$1" pname="$(basename $2)"
+
+	if [ ! -f ".${pname}_done" ]; then
+		patch -N $args -i $2
+		touch .${pname}_done
+	fi
+}
+
+post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64le*) ;;
+		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
+	esac
+}
+
+do_configure() {
+	# Fix gcc on x86_64-musl only
+	if [ "$XBPS_TARGET_MACHINE" = "x86_64-musl" ]; then
+		vsed -i configure -e "s;_cflags_speed='-O3';_cflags_speed='-O2';"
+	fi
+
+	if [ "$CROSS_BUILD" ]; then
+		case "$XBPS_TARGET_MACHINE" in
+			arm*) _arch="arm";;
+			aarch64*) _arch="aarch64";;
+			mips*) _arch="mips";;
+			ppc64*) _arch="ppc64";;
+			ppc*) _arch="ppc";;
+			*) _arch="${XBPS_TARGET_MACHINE%%-musl}";;
+		esac
+
+		_args+=" --enable-cross-compile
+			--sysroot=$XBPS_CROSS_BASE
+			--cross-prefix=${XBPS_CROSS_TRIPLET}-
+			--target-os=linux --arch=${_arch}"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc|ppc-musl) _args+=" --disable-altivec";;
+	esac
+
+	if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+		_args+=" --extra-libs=-latomic"
+	fi
+
+	./configure --prefix=/usr --disable-debug --enable-gpl --enable-gnutls \
+		--disable-stripping \
+		--enable-libcdio --enable-version3 --enable-runtime-cpudetect \
+		--enable-libmp3lame --enable-libvorbis --enable-libxvid \
+		--enable-libx264 $(vopt_enable vpx libvpx) --enable-libtheora \
+		--enable-shared --enable-static --enable-libxcb \
+		$(vopt_enable pulseaudio libpulse) --enable-libfreetype --enable-libmodplug \
+		--enable-libspeex --enable-libcelt --enable-libass \
+		--enable-libopus --enable-librtmp --enable-libjack \
+		$(vopt_if fdk_aac '--enable-nonfree --enable-libfdk-aac') \
+		--disable-libopencore_amrnb --disable-libopencore_amrwb \
+		--disable-libopenjpeg \
+		--enable-postproc --enable-opencl ${_args} \
+		$(vopt_enable x265 libx265) \
+		$(vopt_enable v4l2 libv4l2) \
+		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
+		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		$(vopt_enable dav1d libdav1d) \
+		$(vopt_enable zimg libzimg) \
+		$(vopt_enable webp libwebp) \
+		$(vopt_enable sofa libmysofa) \
+		$(vopt_enable vulkan) \
+		$(vopt_enable drm libdrm) \
+		$(vopt_enable svtav1 libsvtav1) \
+		$(vopt_enable srt libsrt) \
+		$(vopt_enable rist librist) \
+		$(vopt_enable mfx libmfx) \
+		$(vopt_if nvenc '--enable-nvenc') \
+		$(vopt_if nvdec '--enable-nvdec')
+}
+
+do_build() {
+	make ${makejobs}
+	make doc/ff{mpeg,play}.1
+}
+
+do_install() {
+	make DESTDIR=${DESTDIR} install install-man
+	rm -rf ${DESTDIR}/usr/bin
+}
+
+libavcodec4_package() {
+	short_desc="FFmpeg codec library"
+	pkg_install() {
+		vmove "usr/lib/libavcodec.so.*"
+	}
+}
+
+libavdevice4_package() {
+	short_desc="FFmpeg device handling library"
+	pkg_install() {
+		vmove "usr/lib/libavdevice.so.*"
+	}
+}
+
+libavresample4_package() {
+	short_desc="FFmpeg audio resampling library"
+	pkg_install() {
+		vmove "usr/lib/libavresample.so.*"
+	}
+}
+
+libavformat4_package() {
+	short_desc="FFmpeg file format library"
+	pkg_install() {
+		vmove "usr/lib/libavformat.so.*"
+	}
+}
+
+libavutil4_package() {
+	short_desc="FFmpeg utility library"
+	pkg_install() {
+		vmove "usr/lib/libavutil.so.*"
+	}
+}
+
+libavfilter4_package() {
+	short_desc="FFmpeg audio/video filter library"
+	pkg_install() {
+		vmove "usr/lib/libavfilter.so.*"
+	}
+}
+
+libpostproc4_package() {
+	short_desc="FFmpeg video postprocessing library"
+	pkg_install() {
+		vmove "usr/lib/libpostproc.so.*"
+	}
+}
+
+libswscale4_package() {
+	short_desc="FFmpeg video scaling library"
+	pkg_install() {
+		vmove "usr/lib/libswscale.so.*"
+	}
+}
+
+libswresample4_package() {
+	short_desc="FFmpeg video resampling library"
+	pkg_install() {
+		vmove "usr/lib/libswresample.so.*"
+	}
+}
+
+ffmpeg4-devel_package() {
+	depends="
+		libavcodec4>=${version}_${revision}
+		libavdevice4>=${version}_${revision}
+		libavformat4>=${version}_${revision}
+		libavutil4>=${version}_${revision}
+		libavfilter4>=${version}_${revision}
+		libpostproc4>=${version}_${revision}
+		libswscale4>=${version}_${revision}
+		libswresample4>=${version}_${revision}
+		libavresample4>=${version}_${revision}"
+	short_desc+=" - development files"
+	conflicts="ffmpeg-devel"
+	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
+		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
+		nostrip_files="/usr/lib/libavfilter.a"
+	fi
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.a"
+		vmove "usr/lib/*.so"
+		vmove usr/share/ffmpeg/examples
+		vmove usr/share/man/man3
+	}
+}
diff --git a/srcpkgs/libavcodec4 b/srcpkgs/libavcodec4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavcodec4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavdevice4 b/srcpkgs/libavdevice4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavdevice4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavfilter4 b/srcpkgs/libavfilter4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavfilter4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavformat4 b/srcpkgs/libavformat4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavformat4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavresample4 b/srcpkgs/libavresample4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavutil4 b/srcpkgs/libavutil4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavutil4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libpostproc4 b/srcpkgs/libpostproc4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libpostproc4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswresample4 b/srcpkgs/libswresample4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libswresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswscale4 b/srcpkgs/libswscale4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libswscale4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file

From 17f98c048b4b76c97767f90de45a3fc20c331e40 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:04 -0400
Subject: [PATCH 003/116] opencv: update to 4.7.0.

---
 common/shlibs           | 104 ++++++++++++++++++++--------------------
 srcpkgs/opencv/template |   8 ++--
 2 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index 05c292a04aa2..2ee342f2a204 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2134,58 +2134,58 @@ libcapstone.so.4 capstone-4.0_1
 libhavege.so.2 libhaveged-1.9.11_1
 libnih.so.1 libnih-1.0.3_1
 libnih-dbus.so.1 libnih-1.0.3_1
-libopencv_quality.so.406 libopencv-4.6.0_1
-libopencv_reg.so.406 libopencv-4.6.0_1
-libopencv_surface_matching.so.406 libopencv-4.6.0_1
-libopencv_xphoto.so.406 libopencv-4.6.0_1
-libopencv_freetype.so.406 libopencv-4.6.0_1
-libopencv_fuzzy.so.406 libopencv-4.6.0_1
-libopencv_hfs.so.406 libopencv-4.6.0_1
-libopencv_img_hash.so.406 libopencv-4.6.0_1
-libopencv_line_descriptor.so.406 libopencv-4.6.0_1
-libopencv_saliency.so.406 libopencv-4.6.0_1
-libopencv_structured_light.so.406 libopencv-4.6.0_1
-libopencv_aruco.so.406 libopencv-4.6.0_1
-libopencv_bgsegm.so.406 libopencv-4.6.0_1
-libopencv_bioinspired.so.406 libopencv-4.6.0_1
-libopencv_ccalib.so.406 libopencv-4.6.0_1
-libopencv_face.so.406 libopencv-4.6.0_1
-libopencv_tracking.so.406 libopencv-4.6.0_1
-libopencv_xfeatures2d.so.406 libopencv-4.6.0_1
-libopencv_optflow.so.406 libopencv-4.6.0_1
-libopencv_ximgproc.so.406 libopencv-4.6.0_1
-libopencv_plot.so.406 libopencv-4.6.0_1
-libopencv_text.so.406 libopencv-4.6.0_1
-libopencv_ml.so.406 libopencv-4.6.0_1
-libopencv_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn.so.406 libopencv-4.6.0_1
-libopencv_shape.so.406 libopencv-4.6.0_1
-libopencv_stitching.so.406 libopencv-4.6.0_1
-libopencv_photo.so.406 libopencv-4.6.0_1
-libopencv_video.so.406 libopencv-4.6.0_1
-libopencv_calib3d.so.406 libopencv-4.6.0_1
-libopencv_features2d.so.406 libopencv-4.6.0_1
-libopencv_flann.so.406 libopencv-4.6.0_1
-libopencv_highgui.so.406 libopencv-4.6.0_1
-libopencv_videoio.so.406 libopencv-4.6.0_1
-libopencv_imgcodecs.so.406 libopencv-4.6.0_1
-libopencv_imgproc.so.406 libopencv-4.6.0_1
-libopencv_core.so.406 libopencv-4.6.0_1
-libopencv_superres.so.406 libopencv-4.6.0_1
-libopencv_videostab.so.406 libopencv-4.6.0_1
-libopencv_gapi.so.406 libopencv-4.6.0_1
-libopencv_xobjdetect.so.406 libopencv-4.6.0_1
-libopencv_datasets.so.406 libopencv-4.6.0_1
-libopencv_dnn_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn_superres.so.406 libopencv-4.6.0_1
-libopencv_dpm.so.406 libopencv-4.6.0_1
-libopencv_phase_unwrapping.so.406 libopencv-4.6.0_1
-libopencv_stereo.so.406 libopencv-4.6.0_1
-libopencv_rapid.so.406 libopencv-4.6.0_1
-libopencv_intensity_transform.so.406 libopencv-4.6.0_1
-libopencv_alphamat.so.406 libopencv-4.6.0_1
-libopencv_barcode.so.406 libopencv-4.6.0_1
-libopencv_mcc.so.406 libopencv-4.6.0_1
+libopencv_quality.so.407 libopencv-4.7.0_1
+libopencv_reg.so.407 libopencv-4.7.0_1
+libopencv_surface_matching.so.407 libopencv-4.7.0_1
+libopencv_xphoto.so.407 libopencv-4.7.0_1
+libopencv_freetype.so.407 libopencv-4.7.0_1
+libopencv_fuzzy.so.407 libopencv-4.7.0_1
+libopencv_hfs.so.407 libopencv-4.7.0_1
+libopencv_img_hash.so.407 libopencv-4.7.0_1
+libopencv_line_descriptor.so.407 libopencv-4.7.0_1
+libopencv_saliency.so.407 libopencv-4.7.0_1
+libopencv_structured_light.so.407 libopencv-4.7.0_1
+libopencv_aruco.so.407 libopencv-4.7.0_1
+libopencv_bgsegm.so.407 libopencv-4.7.0_1
+libopencv_bioinspired.so.407 libopencv-4.7.0_1
+libopencv_ccalib.so.407 libopencv-4.7.0_1
+libopencv_face.so.407 libopencv-4.7.0_1
+libopencv_tracking.so.407 libopencv-4.7.0_1
+libopencv_xfeatures2d.so.407 libopencv-4.7.0_1
+libopencv_optflow.so.407 libopencv-4.7.0_1
+libopencv_ximgproc.so.407 libopencv-4.7.0_1
+libopencv_plot.so.407 libopencv-4.7.0_1
+libopencv_text.so.407 libopencv-4.7.0_1
+libopencv_ml.so.407 libopencv-4.7.0_1
+libopencv_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn.so.407 libopencv-4.7.0_1
+libopencv_shape.so.407 libopencv-4.7.0_1
+libopencv_stitching.so.407 libopencv-4.7.0_1
+libopencv_photo.so.407 libopencv-4.7.0_1
+libopencv_video.so.407 libopencv-4.7.0_1
+libopencv_calib3d.so.407 libopencv-4.7.0_1
+libopencv_features2d.so.407 libopencv-4.7.0_1
+libopencv_flann.so.407 libopencv-4.7.0_1
+libopencv_highgui.so.407 libopencv-4.7.0_1
+libopencv_videoio.so.407 libopencv-4.7.0_1
+libopencv_imgcodecs.so.407 libopencv-4.7.0_1
+libopencv_imgproc.so.407 libopencv-4.7.0_1
+libopencv_core.so.407 libopencv-4.7.0_1
+libopencv_superres.so.407 libopencv-4.7.0_1
+libopencv_videostab.so.407 libopencv-4.7.0_1
+libopencv_gapi.so.407 libopencv-4.7.0_1
+libopencv_xobjdetect.so.407 libopencv-4.7.0_1
+libopencv_datasets.so.407 libopencv-4.7.0_1
+libopencv_dnn_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn_superres.so.407 libopencv-4.7.0_1
+libopencv_dpm.so.407 libopencv-4.7.0_1
+libopencv_phase_unwrapping.so.407 libopencv-4.7.0_1
+libopencv_stereo.so.407 libopencv-4.7.0_1
+libopencv_rapid.so.407 libopencv-4.7.0_1
+libopencv_intensity_transform.so.407 libopencv-4.7.0_1
+libopencv_alphamat.so.407 libopencv-4.7.0_1
+libopencv_barcode.so.407 libopencv-4.7.0_1
+libopencv_mcc.so.407 libopencv-4.7.0_1
 libuniconf.so.4.6 wvstreams-4.6.1_20
 libwvbase.so.4.6 wvstreams-4.6.1_20
 libwvutils.so.4.6 wvstreams-4.6.1_20
diff --git a/srcpkgs/opencv/template b/srcpkgs/opencv/template
index 69c635b1ad2b..41f3183f1582 100644
--- a/srcpkgs/opencv/template
+++ b/srcpkgs/opencv/template
@@ -1,7 +1,7 @@
 # Template file for 'opencv'
 pkgname=opencv
-version=4.6.0
-revision=4
+version=4.7.0
+revision=1
 create_wrksrc=yes
 build_wrksrc=${pkgname}-${version}
 build_style=cmake
@@ -24,8 +24,8 @@ homepage="https://opencv.org"
 changelog="https://github.com/opencv/opencv/wiki/ChangeLog"
 distfiles="https://github.com/opencv/opencv/archive/${version}.tar.gz
  https://github.com/opencv/opencv_contrib/archive/${version}.tar.gz>contrib.tar.gz"
-checksum="1ec1cba65f9f20fe5a41fda1586e01c70ea0c9a6d7b67c9e13edf0cfe2239277
- 1777d5fd2b59029cf537e5fd6f8aa68d707075822f90bde683fcde086f85f7a7"
+checksum="8df0079cdbe179748a18d44731af62a245a45ebf5085223dc03133954c662973
+ 42df840cf9055e59d0e22c249cfb19f04743e1bdad113d31b1573d3934d62584"
 patch_args="-Np1 -d ${build_wrksrc}"
 # tests hang indenfinitely, even with test data included
 make_check=no

From ca5106e7e0d20a1ac66bacf2ff66f81302735abd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 004/116] actiona: revbump for opencv-4.7.0

---
 srcpkgs/actiona/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/actiona/template b/srcpkgs/actiona/template
index cf5f0b7a2ae6..0d899311e6df 100644
--- a/srcpkgs/actiona/template
+++ b/srcpkgs/actiona/template
@@ -1,7 +1,7 @@
 # Template file for 'actiona'
 pkgname=actiona
 version=3.10.1
-revision=2
+revision=3
 build_style=qmake
 configure_args="PKGCONFIG_OPENCV=opencv4"
 hostmakedepends="pkg-config qt5-plugin-mysql qt5-qmake qt5-host-tools"

From e03833911069848231ae2314b879dc7a2b1839f0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 005/116] gmic: revbump for opencv-4.7.0

---
 srcpkgs/gmic/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gmic/template b/srcpkgs/gmic/template
index 24a9c7218fdf..0bb4034d5cc8 100644
--- a/srcpkgs/gmic/template
+++ b/srcpkgs/gmic/template
@@ -1,7 +1,7 @@
 # Template file for 'gmic'
 pkgname=gmic
 version=3.1.6
-revision=3
+revision=4
 _zart_hash=34ebf6cce0bafb98abe57cec83c4a02cd1abeca0
 create_wrksrc=yes
 build_wrksrc="src"

From f83175143a02a50e5ccf7cc0f8fe168fda96b822 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 006/116] qimgv: revbump for opencv-4.7.0

---
 srcpkgs/qimgv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qimgv/template b/srcpkgs/qimgv/template
index 7eb30db33992..dd341dfe1bfc 100644
--- a/srcpkgs/qimgv/template
+++ b/srcpkgs/qimgv/template
@@ -1,7 +1,7 @@
 # Template file for 'qimgv'
 pkgname=qimgv
 version=1.0.2
-revision=2
+revision=3
 build_style=cmake
 configure_args="$(vopt_if video -DVIDEO_SUPPORT=ON -DVIDEO_SUPPORT=OFF)
  $(vopt_if scale -DOPENCV_SUPPORT=ON -DOPENCV_SUPPORT=OFF)

From 223e5dbf96984bf5e1b7935d9c4ff3e3b7982080 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 007/116] retroshare: revbump for opencv-4.7.0

---
 srcpkgs/retroshare/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroshare/template b/srcpkgs/retroshare/template
index 8a0786c21a08..72023fa98b75 100644
--- a/srcpkgs/retroshare/template
+++ b/srcpkgs/retroshare/template
@@ -1,7 +1,7 @@
 # Template file for 'retroshare'
 pkgname=retroshare
 version=0.6.6
-revision=2
+revision=4
 build_style=qmake
 #XXX broadcast feature requires an ancient udp-discovery-cpp which either needs
 # to be fetched+patched (FTBFS) here or packaged :/

From 7a5761a972cd84f38ec29abbee68dbcc22b6e23a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 008/116] waifu2x-converter-cpp: revbump for opencv-4.7.0

---
 srcpkgs/waifu2x-converter-cpp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waifu2x-converter-cpp/template b/srcpkgs/waifu2x-converter-cpp/template
index 8c095d0d7bab..aa52d8c981a8 100644
--- a/srcpkgs/waifu2x-converter-cpp/template
+++ b/srcpkgs/waifu2x-converter-cpp/template
@@ -1,7 +1,7 @@
 # Template file for 'waifu2x-converter-cpp'
 pkgname=waifu2x-converter-cpp
 version=5.2.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DINSTALL_MODELS=ON"
 hostmakedepends="pkg-config"

From ab9eda35712282ef3479095a8fd927a6fe849674 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:38 -0400
Subject: [PATCH 009/116] vlc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/vlc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/vlc/template b/srcpkgs/vlc/template
index 210762b0a7e2..855ca5238662 100644
--- a/srcpkgs/vlc/template
+++ b/srcpkgs/vlc/template
@@ -1,7 +1,7 @@
 # Template file for 'vlc'
 pkgname=vlc
 version=3.0.18
-revision=3
+revision=4
 build_style=gnu-configure
 configure_args="--disable-gme --disable-libtar --enable-jack
  --enable-live555 --disable-fluidsynth --enable-dvdread
@@ -25,7 +25,7 @@ lib32disabled=yes
 hostmakedepends="automake libtool pkg-config flex gettext libgcrypt-devel
  live555-devel gettext-devel $(vopt_if lua lua52) $(vopt_if chromecast protobuf)"
 makedepends="
- avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg-devel freefont-ttf
+ avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg4-devel freefont-ttf
  gnutls-devel jack-devel liba52-devel libass-devel libbluray-devel
  libcdio-devel libdca-devel libdvbpsi-devel libdvdnav-devel libmad-devel
  libmatroska-devel libmodplug-devel libmpcdec-devel libmpeg2-devel

From e166384f2f6f2d5253caf7854f9e1c6d1730e8d5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:55 -0400
Subject: [PATCH 010/116] osg: revbump for ffmpeg4-4.4.3

---
 srcpkgs/osg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/osg/template b/srcpkgs/osg/template
index a9ebbd287933..755793f7e11b 100644
--- a/srcpkgs/osg/template
+++ b/srcpkgs/osg/template
@@ -8,7 +8,7 @@ build_helper="qemu"
 configure_args="-DLIB_POSTFIX="
 hostmakedepends="pkg-config xrandr"
 makedepends="MesaLib-devel gtkglext-devel libcurl-devel giflib-devel librsvg-devel
- jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg-devel xine-lib-devel
+ jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg4-devel xine-lib-devel
  SDL2-devel gst-plugins-base1-devel
  $(vopt_if openexr libopenexr-devel)
  $(vopt_if poppler poppler-glib-devel)

From 94348ebb4e8a03be625cce8f7437107e91555dce Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:13 -0400
Subject: [PATCH 011/116] xine-lib: revbump for ffmpeg4-4.4.3

---
 srcpkgs/xine-lib/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/xine-lib/template b/srcpkgs/xine-lib/template
index f713eff49b07..ed6194c17d11 100644
--- a/srcpkgs/xine-lib/template
+++ b/srcpkgs/xine-lib/template
@@ -1,6 +1,6 @@
 # Template file for 'xine-lib'
 pkgname=xine-lib
-version=1.2.12
+version=1.2.13
 revision=1
 build_style=gnu-configure
 configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
@@ -8,7 +8,7 @@ configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
 hostmakedepends="automake gettext-devel libtool pkg-config perl"
 makedepends="
  zlib-devel alsa-lib-devel libxcb-devel libSM-devel libXext-devel libXv-devel
- libXvMC-devel liba52-devel libmad-devel ffmpeg-devel pulseaudio-devel
+ libXvMC-devel liba52-devel libmad-devel ffmpeg4-devel pulseaudio-devel
  jack-devel samba-devel libflac-devel libmodplug-devel libmpcdec-devel
  speex-devel libtheora-devel libvorbis-devel libdca-devel faad2-devel
  libcdio-devel libbluray-devel aalib-devel libcaca-devel libXinerama-devel
@@ -19,7 +19,7 @@ license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="http://www.xine-project.org"
 changelog="https://sourceforge.net/projects/xine/files/xine-lib/${version}/README.txt/view"
 distfiles="${SOURCEFORGE_SITE}/xine/${pkgname}-${version}.tar.xz"
-checksum=d606270468e1540c2a89c0d7f5fdf11e17ecc0c2698cc0bcb1065ff26abee098
+checksum=5f10d6d718a4a51c17ed1b32b031d4f9b80b061e8276535b2be31e5ac4b75e6f
 
 case "$XBPS_TARGET_MACHINE" in
 	i686-musl)

From 2a72758637edc952c647f96cc0f431603aa28d6b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 012/116] QMPlay2: revbump for ffmpeg-6.0

---
 srcpkgs/QMPlay2/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/QMPlay2/template b/srcpkgs/QMPlay2/template
index 850df9d418b9..8d2ce7a76156 100644
--- a/srcpkgs/QMPlay2/template
+++ b/srcpkgs/QMPlay2/template
@@ -1,7 +1,7 @@
 # Template file for 'QMPlay2'
 pkgname=QMPlay2
 version=23.06.17
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools"
 makedepends="alsa-lib-devel ffmpeg-devel libass-devel libcdio-devel libgme-devel

From 9c21f2b96a0ca1b812683bf6265fa9552ea3a3e2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 013/116] alsa-plugins: revbump for ffmpeg-6.0

---
 srcpkgs/alsa-plugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/alsa-plugins/template b/srcpkgs/alsa-plugins/template
index 0bfa6d9fd264..a5708a7d82a8 100644
--- a/srcpkgs/alsa-plugins/template
+++ b/srcpkgs/alsa-plugins/template
@@ -1,7 +1,7 @@
 # Template file for 'alsa-plugins'
 pkgname=alsa-plugins
 version=1.2.7.1
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--disable-maemo-plugin"
 hostmakedepends="pkg-config"

From 5d353e453e31c9d1a977965c62ffe51aa907c09f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 014/116] arcan: revbump for ffmpeg-6.0

---
 srcpkgs/arcan/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/arcan/template b/srcpkgs/arcan/template
index 7be9652eccf3..ccc7df11ceac 100644
--- a/srcpkgs/arcan/template
+++ b/srcpkgs/arcan/template
@@ -2,7 +2,7 @@
 # !! keep synced with: acfgfs aclip aloadimage
 pkgname=arcan
 version=0.6.2.1
-revision=1
+revision=2
 create_wrksrc=yes
 build_wrksrc=arcan/src
 build_style=cmake

From ce13398359d3503911f6854193e9d3f26c1d5eb2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 015/116] attract: revbump for ffmpeg4-4.4.3

---
 srcpkgs/attract/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/attract/template b/srcpkgs/attract/template
index 26144e931a3c..e760bf0d18ae 100644
--- a/srcpkgs/attract/template
+++ b/srcpkgs/attract/template
@@ -1,12 +1,12 @@
 # Template file for 'attract'
 pkgname=attract
 version=2.6.2
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="VERBOSE=1"
 make_use_env=yes
 hostmakedepends="pkg-config"
-makedepends="SFML-devel ffmpeg-devel fontconfig-devel glu-devel libarchive-devel
+makedepends="SFML-devel ffmpeg4-devel fontconfig-devel glu-devel libarchive-devel
  libcurl-devel libjpeg-turbo-devel xine-lib rapidjson libXrandr-devel"
 depends="git"
 short_desc="Attract-Mode is a graphical frontend for emulators"

From b99746b0d30e0c0c2a0256269845c17a9c189fcb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 016/116] aubio: revbump for ffmpeg-6.0

---
 srcpkgs/aubio/patches/ffmpeg5.patch | 25 +++++++++++++++++++++++++
 srcpkgs/aubio/template              |  2 +-
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/aubio/patches/ffmpeg5.patch

diff --git a/srcpkgs/aubio/patches/ffmpeg5.patch b/srcpkgs/aubio/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..aace41a6e6d9
--- /dev/null
+++ b/srcpkgs/aubio/patches/ffmpeg5.patch
@@ -0,0 +1,25 @@
+From 8a05420e5dd8c7b8b2447f82dc919765876511b3 Mon Sep 17 00:00:00 2001
+From: Paul Brossier <piem@piem.org>
+Date: Tue, 25 Jan 2022 18:30:27 +0100
+Subject: [PATCH] [source_avcodec] define FF_API_LAVF_AVCTX for libavcodec >
+ 59, thx @berolinux (closes gh-353)
+
+---
+ src/io/source_avcodec.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/io/source_avcodec.c b/src/io/source_avcodec.c
+index e0ae93b5..1421bd9a 100644
+--- a/src/io/source_avcodec.c
++++ b/src/io/source_avcodec.c
+@@ -68,6 +68,10 @@
+ #define AUBIO_AVCODEC_MAX_BUFFER_SIZE AV_INPUT_BUFFER_MIN_SIZE
+ #endif
+ 
++#if LIBAVCODEC_VERSION_MAJOR >= 59
++#define FF_API_LAVF_AVCTX 1
++#endif
++
+ struct _aubio_source_avcodec_t {
+   uint_t hop_size;
+   uint_t samplerate;
diff --git a/srcpkgs/aubio/template b/srcpkgs/aubio/template
index ad1c4b256991..7d875cc02541 100644
--- a/srcpkgs/aubio/template
+++ b/srcpkgs/aubio/template
@@ -1,7 +1,7 @@
 # Template file for 'aubio'
 pkgname=aubio
 version=0.4.9
-revision=1
+revision=2
 build_style=waf3
 # XXX lash, pure and swig support.
 hostmakedepends="pkg-config txt2man"

From e379c9125110b15bee0bfbe76c7d810fbd7b7d33 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 017/116] audacious-plugins: revbump for ffmpeg-6.0

---
 .../audacious-plugins/patches/ffmpeg5.patch   | 43 +++++++++++++++++++
 srcpkgs/audacious-plugins/template            |  2 +-
 2 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/audacious-plugins/patches/ffmpeg5.patch

diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg5.patch b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..4e5e34099d71
--- /dev/null
+++ b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
@@ -0,0 +1,43 @@
+commit 298aa371c56c2f52c25a33d9bdec4918b11cebdc
+Author: tibequadorian <tibequadorian@posteo.de>
+Date:   Sat Mar 19 18:40:12 2022 +0100
+
+    audacious-plugins: rebuild against ffmpeg-5.0
+
+diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+new file mode 100644
+index 0000000000..617c11215b
+--- /dev/null
++++ b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+@@ -0,0 +1,31 @@
++From f60beb400eeb1e4778bbfd738bc4a4ccef3de539 Mon Sep 17 00:00:00 2001
++From: John Lindgren <john@jlindgren.net>
++Date: Sat, 5 Mar 2022 12:05:34 -0500
++Subject: [PATCH] Fix build with FFmpeg 5.0
++
++---
++ src/ffaudio/ffaudio-core.cc | 4 ++--
++ 1 file changed, 2 insertions(+), 2 deletions(-)
++
++diff --git a/src/ffaudio/ffaudio-core.cc b/src/ffaudio/ffaudio-core.cc
++index 16dc63e3a..a2b95fd6c 100644
++--- a/src/ffaudio/ffaudio-core.cc
+++++ b/src/ffaudio/ffaudio-core.cc
++@@ -274,7 +274,7 @@ static AVInputFormat * get_format_by_content (const char * name, VFSFile & file)
++         AVProbeData d = {name, buf, filled};
++         score = target;
++ 
++-        f = av_probe_input_format2 (& d, true, & score);
+++        f = (AVInputFormat *) av_probe_input_format2 (& d, true, & score);
++         if (f)
++             break;
++ 
++@@ -347,7 +347,7 @@ static bool find_codec (AVFormatContext * c, CodecInfo * cinfo)
++ #endif
++         if (stream && stream->codecpar && stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
++         {
++-            AVCodec * codec = avcodec_find_decoder (stream->codecpar->codec_id);
+++            AVCodec * codec = (AVCodec *) avcodec_find_decoder (stream->codecpar->codec_id);
++ 
++             if (codec)
++             {
diff --git a/srcpkgs/audacious-plugins/template b/srcpkgs/audacious-plugins/template
index 88cbc1671fc6..beebfae59ed4 100644
--- a/srcpkgs/audacious-plugins/template
+++ b/srcpkgs/audacious-plugins/template
@@ -2,7 +2,7 @@
 #Keep in sync with audacious!
 pkgname=audacious-plugins
 version=4.3.1
-revision=1
+revision=2
 build_style=meson
 configure_args="$(vopt_bool gtk3 gtk) $(vopt_bool gtk3)
  $(vopt_bool qt) $(vopt_bool qt qt6)"

From 20bf8551296b698cca34cc9f16f8cb193bbda327 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 018/116] audacity: revbump for ffmpeg4-4.4.3

---
 srcpkgs/audacity/template | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/audacity/template b/srcpkgs/audacity/template
index d509c0a89407..11e20255685b 100644
--- a/srcpkgs/audacity/template
+++ b/srcpkgs/audacity/template
@@ -1,7 +1,7 @@
 # Template file for 'audacity'
 pkgname=audacity
 version=2.4.1
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--with-ffmpeg=system --with-libsndfile=system --with-expat=system
  --with-libsoxr=system --with-lame=system --with-lv2=system ac_cv_path_WX_CONFIG=wx-config-gtk3"
@@ -9,7 +9,7 @@ hostmakedepends="pkg-config cmake gettext libtool m4 which"
 makedepends="jack-devel wxWidgets-gtk3-devel gtk+3-devel
  libmad-devel soundtouch-devel libsoxr-devel
  vamp-plugin-sdk-devel lame-devel libid3tag-devel libflac-devel
- ffmpeg-devel twolame-devel serd-devel lv2 lilv-devel suil-devel"
+ ffmpeg4-devel twolame-devel serd-devel lv2 lilv-devel suil-devel"
 depends="desktop-file-utils hicolor-icon-theme"
 short_desc="Graphical cross-platform audio editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
@@ -33,5 +33,4 @@ post_install() {
 	vcopy plug-ins /usr/share/audacity
 
 	rm ${DESTDIR}/usr/share/doc/audacity/LICENSE.txt
-	vlicense LICENSE.txt LICENSE
 }

From 101537cbbf73c8b13d8fd381a16c11441373fb39 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 019/116] avidemux: revbump for ffmpeg-6.0

---
 srcpkgs/avidemux/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/avidemux/template b/srcpkgs/avidemux/template
index 253a0243e225..557285982d2b 100644
--- a/srcpkgs/avidemux/template
+++ b/srcpkgs/avidemux/template
@@ -1,7 +1,7 @@
 # Template file for 'avidemux'
 pkgname=avidemux
 version=2.8.0
-revision=2
+revision=3
 # Can't be compiled for aarch64, arm* or mips*
 archs="x86_64* i686*"
 hostmakedepends="cmake pkg-config qt5-host-tools qt5-devel tar yasm"

From d9514205f2fe95847a229cde08741764d1c447f1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 020/116] baresip: revbump for ffmpeg-6.0

---
 srcpkgs/baresip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/baresip/template b/srcpkgs/baresip/template
index f1bd1817048b..b21e22334316 100644
--- a/srcpkgs/baresip/template
+++ b/srcpkgs/baresip/template
@@ -1,7 +1,7 @@
 # Template file for 'baresip'
 pkgname=baresip
 version=2.10.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config glib-devel"
 makedepends="libgsm-devel libpng-devel openssl-devel libsndfile-devel

From af8f4f9c369e9545d41fbd91b2d294e61c8181ce Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 021/116] blender: revbump for ffmpeg-6.0

---
 srcpkgs/blender/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index ec724bb0a6dc..0f72876d4d70 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -1,7 +1,7 @@
 # Template file for 'blender'
 pkgname=blender
 version=3.5.1
-revision=1
+revision=2
 archs="x86_64* ppc64*"
 build_style="cmake"
 pycompile_dirs="/usr/share/blender/${version%.*}/scripts"
@@ -9,8 +9,8 @@ configure_args="-DWITH_INSTALL_PORTABLE=OFF -DWITH_PYTHON_INSTALL=OFF
  -DWITH_JACK=ON -DWITH_CODEC_FFMPEG=ON -DWITH_CODEC_SNDFILE=ON -DWITH_OPENMP=ON
  -DWITH_FFTW3=ON -DWITH_MOD_OCEANSIM=ON -DWITH_CYCLES_EMBREE=OFF -DWITH_OPENCOLORIO=ON
  -DWITH_IMAGE_OPENEXR=ON -DWITH_IMAGE_OPENJPEG=ON -DWITH_OPENSUBDIV=ON
- -DWITH_OPENCOLLADA=ON -DWITH_SYSTEM_GLEW=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
- -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_LIBDECOR=ON
+ -DWITH_OPENCOLLADA=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
+ -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_WAYLAND_LIBDECOR=ON
  -DWITH_BUILDINFO=OFF -DPYTHON_VERSION=${py3_ver} -DPYTHON_LIBPATH=/usr/lib
  -DPYTHON_LIBRARY=python${py3_ver}${py3_abiver} -DPYTHON_INCLUDE_DIRS=/${py3_inc}
  -DWITH_SYSTEM_LZO=ON -DWITH_SYSTEM_EIGEN3=ON -DWITH_SYSTEM_FREETYPE=ON"

From 49973869ee1e2264200e62c829d60019556e38d4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 022/116] cantata: revbump for ffmpeg-6.0

---
 srcpkgs/cantata/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cantata/template b/srcpkgs/cantata/template
index 4b417d80d5c2..8a90aaa4c07a 100644
--- a/srcpkgs/cantata/template
+++ b/srcpkgs/cantata/template
@@ -1,7 +1,7 @@
 # Template file for 'cantata'
 pkgname=cantata
 version=2.5.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools qt5-tools"
 makedepends="qt5-devel qt5-tools-devel qt5-svg-devel qt5-xmlpatterns-devel

From 56f33f1e24f960604055f6e0c75681e914c41403 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 023/116] ccextractor: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ccextractor/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/ccextractor/template b/srcpkgs/ccextractor/template
index 9abcd82852b2..6eccad5885af 100644
--- a/srcpkgs/ccextractor/template
+++ b/srcpkgs/ccextractor/template
@@ -1,12 +1,12 @@
 # Template file for 'ccextractor'
 pkgname=ccextractor
 version=0.93
-revision=1
+revision=2
 build_wrksrc="linux"
 build_style=gnu-configure
 configure_args="--enable-ocr --enable-hardsubx"
 hostmakedepends="automake pkg-config"
-makedepends="leptonica-devel tesseract-ocr-devel ffmpeg-devel"
+makedepends="leptonica-devel tesseract-ocr-devel ffmpeg4-devel"
 short_desc="Extract subtitles from video streams"
 maintainer="newbluemoon <blaumolch@mailbox.org>"
 license="GPL-2.0-or-later"

From c4bb3e25937ce7aec621c4dcf01cab7fd47816d5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 024/116] chromaprint: revbump for ffmpeg-6.0

---
 srcpkgs/chromaprint/patches/ffmpeg5.patch | 569 ++++++++++++++++++++++
 srcpkgs/chromaprint/template              |   2 +-
 2 files changed, 570 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromaprint/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromaprint/patches/ffmpeg5.patch b/srcpkgs/chromaprint/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..a9fd307a23c8
--- /dev/null
+++ b/srcpkgs/chromaprint/patches/ffmpeg5.patch
@@ -0,0 +1,569 @@
+From 8ccad6937177b1b92e40ab8f4447ea27bac009a7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= <lalinsky@gmail.com>
+Date: Fri, 4 Nov 2022 21:47:38 +0100
+Subject: [PATCH] Use FFmpeg 5.x (#120)
+
+* Use FFmpeg 5.1.2 for CI builds
+
+* Build on Ubuntu 20.04
+
+* Upgrade code to FFmpeg 5.x APIs
+
+* Only set FFmpeg include dirs if building tools
+
+* No longer needed
+
+* Use ubuntu 20.04
+---
+ .github/workflows/build.yml                   |   6 +-
+ CMakeLists.txt                                |  16 --
+ package/build.sh                              |   4 +-
+ src/audio/ffmpeg_audio_processor.h            |   2 -
+ src/audio/ffmpeg_audio_processor_avresample.h |  72 -------
+ src/audio/ffmpeg_audio_processor_swresample.h |  18 +-
+ src/audio/ffmpeg_audio_reader.h               | 197 +++++++++---------
+ tests/CMakeLists.txt                          |   6 +
+ 8 files changed, 122 insertions(+), 199 deletions(-)
+ delete mode 100644 src/audio/ffmpeg_audio_processor_avresample.h
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index f8d6a32..4da2405 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -84,9 +84,6 @@ find_package(FFmpeg)
+ if(FFMPEG_LIBRARIES)
+ 	cmake_push_check_state(RESET)
+ 	set(CMAKE_REQUIRED_LIBRARIES ${FFMPEG_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -lm)
+-	check_function_exists(av_packet_unref HAVE_AV_PACKET_UNREF)
+-	check_function_exists(av_frame_alloc HAVE_AV_FRAME_ALLOC)
+-	check_function_exists(av_frame_free HAVE_AV_FRAME_FREE)
+ 	cmake_pop_check_state()
+ endif()
+
+@@ -163,14 +160,11 @@ message(STATUS "Using ${FFT_LIB} for FFT calculations")
+ if(NOT AUDIO_PROCESSOR_LIB)
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+ 		set(AUDIO_PROCESSOR_LIB "swresample")
+-	elseif(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(AUDIO_PROCESSOR_LIB "avresample")
+ 	endif()
+ endif()
+
+ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE OFF)
+ 		set(USE_SWRESAMPLE ON)
+ 		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBSWRESAMPLE_LIBRARIES})
+ 		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBSWRESAMPLE_INCLUDE_DIRS})
+@@ -178,16 +172,6 @@ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+ 	endif()
+ 	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+-elseif(AUDIO_PROCESSOR_LIB STREQUAL "avresample")
+-	if(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE ON)
+-		set(USE_SWRESAMPLE OFF)
+-		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBAVRESAMPLE_LIBRARIES})
+-		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBAVRESAMPLE_INCLUDE_DIRS})
+-	else()
+-		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+-	endif()
+-	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+ else()
+ 	message(STATUS "Building without audio conversion support, please install FFmpeg with libswresample")
+ endif()
+diff --git a/package/build.sh b/package/build.sh
+index da631ae..b41d36e 100755
+--- a/package/build.sh
++++ b/package/build.sh
+@@ -7,8 +7,8 @@ set -eux
+
+ BASE_DIR=$(cd $(dirname $0)/.. && pwd)
+
+-FFMPEG_VERSION=4.4.1
+-FFMPEG_BUILD_TAG=v4.4.1-1
++FFMPEG_VERSION=5.1.2
++FFMPEG_BUILD_TAG=v${FFMPEG_VERSION}-1
+
+ TMP_BUILD_DIR=$BASE_DIR/$(mktemp -d build.XXXXXXXX)
+ trap 'rm -rf $TMP_BUILD_DIR' EXIT
+diff --git a/src/audio/ffmpeg_audio_processor.h b/src/audio/ffmpeg_audio_processor.h
+index 7628fc7..39f4f6d 100644
+--- a/src/audio/ffmpeg_audio_processor.h
++++ b/src/audio/ffmpeg_audio_processor.h
+@@ -10,8 +10,6 @@
+
+ #if defined(USE_SWRESAMPLE)
+ #include "audio/ffmpeg_audio_processor_swresample.h"
+-#elif defined(USE_AVRESAMPLE)
+-#include "audio/ffmpeg_audio_processor_avresample.h"
+ #else
+ #error "no audio processing library"
+ #endif
+diff --git a/src/audio/ffmpeg_audio_processor_avresample.h b/src/audio/ffmpeg_audio_processor_avresample.h
+deleted file mode 100644
+index bd85f92..0000000
+--- a/src/audio/ffmpeg_audio_processor_avresample.h
++++ /dev/null
+@@ -1,72 +0,0 @@
+-// Copyright (C) 2016  Lukas Lalinsky
+-// Distributed under the MIT license, see the LICENSE file for details.
+-
+-#ifndef CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-#define CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-
+-extern "C" {
+-#include <libavresample/avresample.h>
+-}
+-
+-namespace chromaprint {
+-
+-class FFmpegAudioProcessor {
+-public:
+-	FFmpegAudioProcessor() {
+-		m_resample_ctx = avresample_alloc_context();
+-	}
+-
+-	~FFmpegAudioProcessor() {
+-		avresample_free(&m_resample_ctx);
+-	}
+-
+-	void SetCompatibleMode() {
+-		av_opt_set_int(m_resample_ctx, "filter_size", 16, 0);
+-		av_opt_set_int(m_resample_ctx, "phase_shift", 8, 0);
+-		av_opt_set_int(m_resample_ctx, "linear_interp", 1, 0);
+-		av_opt_set_double(m_resample_ctx, "cutoff", 0.8, 0);
+-	}
+-
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "in_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_rate", sample_rate, 0);
+-	}
+-
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "out_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_rate, 0);
+-	}
+-
+-	int Init() {
+-		return avresample_open(m_resample_ctx);
+-	}
+-
+-	int Convert(uint8_t **out, int out_count, const uint8_t **in, int in_count) {
+-		return avresample_convert(m_resample_ctx, out, 0, out_count, (uint8_t **) in, 0, in_count);
+-	}
+-
+-	int Flush(uint8_t **out, int out_count) {
+-		return avresample_read(m_resample_ctx, out, out_count);
+-	}
+-
+-private:
+-	AVAudioResampleContext *m_resample_ctx = nullptr;
+-};
+-
+-}; // namespace chromaprint
+-
+-#endif
+diff --git a/src/audio/ffmpeg_audio_processor_swresample.h b/src/audio/ffmpeg_audio_processor_swresample.h
+index b86266b..b1d4bea 100644
+--- a/src/audio/ffmpeg_audio_processor_swresample.h
++++ b/src/audio/ffmpeg_audio_processor_swresample.h
+@@ -28,30 +28,28 @@ public:
+ 		av_opt_set_double(m_swr_ctx, "cutoff", 0.8, 0);
+ 	}
+
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "icl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "ich", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetInputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "in_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "isf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "in_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "isr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "in_sample_rate", sample_rate, 0);
+ 	}
+
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "ocl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "och", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetOutputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "out_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "osf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "out_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "osr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "out_sample_rate", sample_rate, 0);
+ 	}
+
+ 	int Init() {
+diff --git a/src/audio/ffmpeg_audio_reader.h b/src/audio/ffmpeg_audio_reader.h
+index 5550164..1c6b346 100644
+--- a/src/audio/ffmpeg_audio_reader.h
++++ b/src/audio/ffmpeg_audio_reader.h
+@@ -62,7 +62,7 @@ public:
+ 	bool Read(const int16_t **data, size_t *size);
+
+ 	bool IsOpen() const { return m_opened; }
+-	bool IsFinished() const { return m_finished && !m_got_frame; }
++	bool IsFinished() const { return !m_has_more_packets && !m_has_more_frames; }
+
+ 	std::string GetError() const { return m_error; }
+ 	int GetErrorCode() const { return m_error_code; }
+@@ -74,20 +74,19 @@ private:
+ 	uint8_t *m_convert_buffer[1] = { nullptr };
+ 	int m_convert_buffer_nb_samples = 0;
+
+-	AVInputFormat *m_input_fmt = nullptr;
++	const AVInputFormat *m_input_fmt = nullptr;
+ 	AVDictionary *m_input_opts = nullptr;
+
+ 	AVFormatContext *m_format_ctx = nullptr;
+ 	AVCodecContext *m_codec_ctx = nullptr;
+-	AVFrame *m_frame = nullptr;
+ 	int m_stream_index = -1;
+ 	std::string m_error;
+ 	int m_error_code = 0;
+-	bool m_finished = false;
+ 	bool m_opened = false;
+-	int m_got_frame = 0;
+-	AVPacket m_packet;
+-	AVPacket m_packet0;
++	bool m_has_more_packets = true;
++	bool m_has_more_frames = true;
++	AVPacket *m_packet = nullptr;
++	AVFrame *m_frame = nullptr;
+
+ 	int m_output_sample_rate = 0;
+ 	int m_output_channels = 0;
+@@ -98,19 +97,12 @@ private:
+
+ inline FFmpegAudioReader::FFmpegAudioReader() {
+ 	av_log_set_level(AV_LOG_QUIET);
+-
+-	av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
+ }
+
+ inline FFmpegAudioReader::~FFmpegAudioReader() {
+ 	Close();
+ 	av_dict_free(&m_input_opts);
+ 	av_freep(&m_convert_buffer[0]);
+-	av_packet_unref(&m_packet0);
+ }
+
+ inline bool FFmpegAudioReader::SetInputFormat(const char *name) {
+@@ -135,11 +127,10 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ 	Close();
+
+-    av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
++	m_packet = av_packet_alloc();
++	if (!m_packet) {
++		return false;
++	}
+
+ 	ret = avformat_open_input(&m_format_ctx, file_name.c_str(), m_input_fmt, &m_input_opts);
+ 	if (ret < 0) {
+@@ -153,26 +144,31 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		return false;
+ 	}
+
+-	AVCodec *codec;
++	const AVCodec *codec;
+ 	ret = av_find_best_stream(m_format_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &codec, 0);
+ 	if (ret < 0) {
+ 		SetError("Could not find any audio stream in the file", ret);
+ 		return false;
+ 	}
+ 	m_stream_index = ret;
++	auto stream = m_format_ctx->streams[m_stream_index];
+
+-	m_codec_ctx = m_format_ctx->streams[m_stream_index]->codec;
++	m_codec_ctx = avcodec_alloc_context3(codec);
+ 	m_codec_ctx->request_sample_fmt = AV_SAMPLE_FMT_S16;
+
++	ret = avcodec_parameters_to_context(m_codec_ctx, stream->codecpar);
++	if (ret < 0) {
++		SetError("Could not copy the stream parameters", ret);
++		return false;
++	}
++
+ 	ret = avcodec_open2(m_codec_ctx, codec, nullptr);
+ 	if (ret < 0) {
+ 		SetError("Could not open the codec", ret);
+ 		return false;
+ 	}
+
+-	if (!m_codec_ctx->channel_layout) {
+-		m_codec_ctx->channel_layout = av_get_default_channel_layout(m_codec_ctx->channels);
+-	}
++	av_dump_format(m_format_ctx, 0, "foo", 0);
+
+ 	m_frame = av_frame_alloc();
+ 	if (!m_frame) {
+@@ -183,19 +179,23 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		m_output_sample_rate = m_codec_ctx->sample_rate;
+ 	}
+
+-	if (!m_output_channels) {
+-		m_output_channels = m_codec_ctx->channels;
++	AVChannelLayout output_channel_layout;
++	if (m_output_channels) {
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
++	} else {
++		m_output_channels = m_codec_ctx->ch_layout.nb_channels;
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
+ 	}
+
+-	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
++	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->ch_layout.nb_channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
+ 		m_converter.reset(new FFmpegAudioProcessor());
+ 		m_converter->SetCompatibleMode();
+ 		m_converter->SetInputSampleFormat(m_codec_ctx->sample_fmt);
+ 		m_converter->SetInputSampleRate(m_codec_ctx->sample_rate);
+-		m_converter->SetInputChannelLayout(m_codec_ctx->channel_layout);
++		m_converter->SetInputChannelLayout(&(m_codec_ctx->ch_layout));
+ 		m_converter->SetOutputSampleFormat(AV_SAMPLE_FMT_S16);
+ 		m_converter->SetOutputSampleRate(m_output_sample_rate);
+-		m_converter->SetOutputChannelLayout(av_get_default_channel_layout(m_output_channels));
++		m_converter->SetOutputChannelLayout(&output_channel_layout);
+ 		auto ret = m_converter->Init();
+ 		if (ret != 0) {
+ 			SetError("Could not create an audio converter instance", ret);
+@@ -203,10 +203,11 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		}
+ 	}
+
++	av_channel_layout_uninit(&output_channel_layout);
++
+ 	m_opened = true;
+-	m_finished = false;
+-	m_got_frame = 0;
+-	m_nb_packets = 0;
++	m_has_more_packets = true;
++	m_has_more_frames = true;
+ 	m_decode_error = 0;
+
+ 	return true;
+@@ -214,6 +215,7 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ inline void FFmpegAudioReader::Close() {
+ 	av_frame_free(&m_frame);
++	av_packet_free(&m_packet);
+
+ 	m_stream_index = -1;
+
+@@ -252,91 +254,98 @@ inline bool FFmpegAudioReader::Read(const int16_t **data, size_t *size) {
+ 		return false;
+ 	}
+
++	*data = nullptr;
++	*size = 0;
++
+ 	int ret;
++	bool needs_packet = false;
+ 	while (true) {
+-		while (m_packet.size <= 0) {
+-			av_packet_unref(&m_packet0);
+-			av_init_packet(&m_packet);
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			ret = av_read_frame(m_format_ctx, &m_packet);
++		while (needs_packet && m_packet->size == 0) {
++			ret = av_read_frame(m_format_ctx, m_packet);
+ 			if (ret < 0) {
+ 				if (ret == AVERROR_EOF) {
+-					m_finished = true;
++					needs_packet = false;
++					m_has_more_packets = false;
+ 					break;
+-				} else {
++				}
++				SetError("Error reading from the audio source", ret);
++				return false;
++			}
++			if (m_packet->stream_index == m_stream_index) {
++				needs_packet = false;
++			} else {
++				av_packet_unref(m_packet);
++			}
++		}
++
++		if (m_packet->size != 0) {
++			ret = avcodec_send_packet(m_codec_ctx, m_packet);
++			if (ret < 0) {
++				if (ret != AVERROR(EAGAIN)) {
+ 					SetError("Error reading from the audio source", ret);
+ 					return false;
+ 				}
+-			}
+-			m_packet0 = m_packet;
+-			if (m_packet.stream_index != m_stream_index) {
+-				m_packet.data = nullptr;
+-				m_packet.size = 0;
+ 			} else {
+-				m_nb_packets++;
++				av_packet_unref(m_packet);
+ 			}
+ 		}
+
+-		ret = avcodec_decode_audio4(m_codec_ctx, m_frame, &m_got_frame, &m_packet);
++		ret = avcodec_receive_frame(m_codec_ctx, m_frame);
+ 		if (ret < 0) {
+-			if (m_decode_error) {
+-				SetError("Error decoding audio frame", m_decode_error);
+-				return false;
++			if (ret == AVERROR_EOF) {
++				m_has_more_frames = false;
++			} else if (ret == AVERROR(EAGAIN)) {
++				if (m_has_more_packets) {
++					needs_packet = true;
++					continue;
++				} else {
++					m_has_more_frames = false;
++				}
+ 			}
+-			m_decode_error = ret;
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			continue;
++			SetError("Error decoding the audio source", ret);
++			return false;
+ 		}
+
+-		break;
+-	}
+-
+-	m_decode_error = 0;
+-
+-	const int decoded = std::min(ret, m_packet.size);
+-	m_packet.data += decoded;
+-	m_packet.size -= decoded;
+-
+-	if (m_got_frame) {
+-		if (m_converter) {
+-			if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
+-				int linsize;
+-				av_freep(&m_convert_buffer[0]);
+-				m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
+-				ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
+-				if (ret < 0) {
+-					SetError("Couldn't allocate audio converter buffer", ret);
++		if (m_frame->nb_samples > 0) {
++			if (m_converter) {
++				if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
++					int linsize;
++					av_freep(&m_convert_buffer[0]);
++					m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
++					ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->ch_layout.nb_channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
++					if (ret < 0) {
++						SetError("Couldn't allocate audio converter buffer", ret);
++						return false;
++					}
++				}
++				auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
++				if (nb_samples < 0) {
++					SetError("Couldn't convert audio", ret);
+ 					return false;
+ 				}
+-			}
+-			auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			}
+-			*data = (const int16_t *) m_convert_buffer[0];
+-			*size = nb_samples;
+-		} else {
+-			*data = (const int16_t *) m_frame->data[0];
+-			*size = m_frame->nb_samples;
+-		}
+-	} else {
+-		if (m_finished && m_converter) {
+-			auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			} else if (nb_samples > 0) {
+-				m_got_frame = 1;
+ 				*data = (const int16_t *) m_convert_buffer[0];
+ 				*size = nb_samples;
++			} else {
++				*data = (const int16_t *) m_frame->data[0];
++				*size = m_frame->nb_samples;
++			}
++		} else {
++			if (m_converter) {
++				if (IsFinished()) {
++					auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
++					if (nb_samples < 0) {
++						SetError("Couldn't convert audio", ret);
++						return false;
++					} else if (nb_samples > 0) {
++						*data = (const int16_t *) m_convert_buffer[0];
++						*size = nb_samples;
++					}
++				}
+ 			}
+ 		}
+-	}
+
+-	return true;
++		return true;
++	}
+ }
+
+ inline void FFmpegAudioReader::SetError(const char *message, int errnum) {
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index a2b517b..123e643 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -38,6 +38,12 @@ set(SRCS
+
+ if(BUILD_TOOLS)
+ 	set(SRCS ${SRCS} ../src/audio/ffmpeg_audio_reader_test.cpp)
++    include_directories(
++        ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}
++        ${AUDIO_PROCESSOR_INCLUDE_DIRS}
++    )
+ 	link_libraries(fpcalc_libs)
+ endif()
+
+-- 
+2.38.1
+
+
diff --git a/srcpkgs/chromaprint/template b/srcpkgs/chromaprint/template
index 7ef7838949f3..1f7bbc70a22c 100644
--- a/srcpkgs/chromaprint/template
+++ b/srcpkgs/chromaprint/template
@@ -1,7 +1,7 @@
 # Template file for 'chromaprint'
 pkgname=chromaprint
 version=1.5.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DBUILD_TOOLS=ON"
 make_check_target="check"

From 00137693906e0962a89d4db1cbebbaee272dd2eb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 025/116] chromium: revbump for ffmpeg-6.0

---
 .../patches/chromium-93-ffmpeg-4.4.patch      | 36 --------------
 srcpkgs/chromium/patches/ffmpeg5.patch        | 47 +++++++++++++++++++
 srcpkgs/chromium/template                     |  2 +-
 3 files changed, 48 insertions(+), 37 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch
 create mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch b/srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch
deleted file mode 100644
index f0ec736f98bc..000000000000
--- a/srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch
+++ /dev/null
@@ -1,36 +0,0 @@
-diff --git a/media/filters/ffmpeg_demuxer.cc b/media/filters/ffmpeg_demuxer.cc
-index ac4713b07268..492a9a37d096 100644
---- a/media/filters/ffmpeg_demuxer.cc
-+++ b/media/filters/ffmpeg_demuxer.cc
-@@ -427,11 +427,11 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
-   scoped_refptr<DecoderBuffer> buffer;
- 
-   if (type() == DemuxerStream::TEXT) {
--    size_t id_size = 0;
-+    int id_size = 0;
-     uint8_t* id_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
- 
--    size_t settings_size = 0;
-+    int settings_size = 0;
-     uint8_t* settings_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
- 
-@@ -443,7 +443,7 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
-     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
-                                      side_data.data(), side_data.size());
-   } else {
--    size_t side_data_size = 0;
-+    int side_data_size = 0;
-     uint8_t* side_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
- 
-@@ -504,7 +504,7 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
-                                        packet->size - data_offset);
-     }
- 
--    size_t skip_samples_size = 0;
-+    int skip_samples_size = 0;
-     const uint32_t* skip_samples_ptr =
-         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
-             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..24e2da38e34c
--- /dev/null
+++ b/srcpkgs/chromium/patches/ffmpeg5.patch
@@ -0,0 +1,47 @@
+--- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
++++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
+@@ -92,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+-  if (stream->start_time != kNoFFmpegTimestamp)
++  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -1597,7 +1585,7 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+@@ -1618,7 +1606,7 @@
+     if (stream->type() != DemuxerStream::VIDEO)
+       continue;
+ 
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+ 
+     if (!stream->IsEnabled())
diff --git a/srcpkgs/chromium/template b/srcpkgs/chromium/template
index b4a39dfd3815..c29453cd1f50 100644
--- a/srcpkgs/chromium/template
+++ b/srcpkgs/chromium/template
@@ -2,7 +2,7 @@
 pkgname=chromium
 # See https://chromiumdash.appspot.com/releases?platform=Linux for the latest version
 version=114.0.5735.106
-revision=1
+revision=2
 archs="i686* x86_64* aarch64* armv7l*"
 hostmakedepends="
  $(vopt_if clang "clang lld llvm15")

From 30a52ce69952e204be33096d1fd531bce7112d31 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 026/116] cmus: revbump for ffmpeg-6.0

---
 srcpkgs/cmus/patches/ffmpeg6.patch | 12 ++++++++++++
 srcpkgs/cmus/template              |  2 +-
 2 files changed, 13 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/cmus/patches/ffmpeg6.patch

diff --git a/srcpkgs/cmus/patches/ffmpeg6.patch b/srcpkgs/cmus/patches/ffmpeg6.patch
new file mode 100644
index 000000000000..ffa95ab81110
--- /dev/null
+++ b/srcpkgs/cmus/patches/ffmpeg6.patch
@@ -0,0 +1,12 @@
+--- a/ip/ffmpeg.c
++++ b/ip/ffmpeg.c
+@@ -202,9 +202,6 @@ static int ffmpeg_open(struct input_plugin_data *ip_data)
+ 			break;
+ 		}
+ 
+-		if (codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+-			cc->flags |= AV_CODEC_FLAG_TRUNCATED;
+-
+ 		if (avcodec_open2(cc, codec, NULL) < 0) {
+ 			d_print("could not open codec: %d, %s\n", cc->codec_id, avcodec_get_name(cc->codec_id));
+ 			err = -IP_ERROR_UNSUPPORTED_FILE_TYPE;
diff --git a/srcpkgs/cmus/template b/srcpkgs/cmus/template
index 0fcb424ce336..05b77d0fecae 100644
--- a/srcpkgs/cmus/template
+++ b/srcpkgs/cmus/template
@@ -1,7 +1,7 @@
 # Template file for 'cmus'
 pkgname=cmus
 version=2.10.0
-revision=1
+revision=2
 build_style=configure
 configure_args="prefix=/usr LD=$CC"
 hostmakedepends="pkg-config"

From 48311defef9b9d40393011f77bc8860057ce4fbb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 027/116] cyanrip: revbump for ffmpeg-6.0

---
 srcpkgs/cyanrip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cyanrip/template b/srcpkgs/cyanrip/template
index 9796e3461601..5db30e020d17 100644
--- a/srcpkgs/cyanrip/template
+++ b/srcpkgs/cyanrip/template
@@ -1,7 +1,7 @@
 # Template file for 'cyanrip'
 pkgname=cyanrip
 version=0.9.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config"
 makedepends="ffmpeg-devel libcdio-devel libcdio-paranoia-devel libcurl-devel libmusicbrainz5-devel"

From c2e5a0285fc41bd48e9b9695af98935c65e15124 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 028/116] deadbeef: revbump for ffmpeg4-4.4.3

---
 srcpkgs/deadbeef/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/deadbeef/template b/srcpkgs/deadbeef/template
index b664bb1b9bd9..165b3c7b9cad 100644
--- a/srcpkgs/deadbeef/template
+++ b/srcpkgs/deadbeef/template
@@ -1,14 +1,14 @@
 # Template file for 'deadbeef'
 pkgname=deadbeef
 version=1.8.8
-revision=1
+revision=2
 create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-oss --disable-lfm --disable-notify --disable-gtk2"
 hostmakedepends="automake libtool gettext gettext-devel intltool pkg-config
  yasm clang glib-devel"
 makedepends="
- alsa-lib-devel dbus-devel faad2-devel ffmpeg-devel gtk+3-devel imlib2-devel
+ alsa-lib-devel dbus-devel faad2-devel ffmpeg4-devel gtk+3-devel imlib2-devel
  jansson-devel libcddb-devel libcdio-devel libcurl-devel libflac-devel
  libmad-devel libpng-devel libsamplerate-devel libsndfile-devel libvorbis-devel
  libzip-devel mpg123-devel opusfile-devel pulseaudio-devel wavpack-devel"

From af87f924c34f022b8974a73961303c95fcecb89d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 029/116] dolphin-emu: revbump for ffmpeg-6.0

---
 srcpkgs/dolphin-emu/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/dolphin-emu/template b/srcpkgs/dolphin-emu/template
index 7ea197ceb2a8..7aeb0a5b645e 100644
--- a/srcpkgs/dolphin-emu/template
+++ b/srcpkgs/dolphin-emu/template
@@ -1,7 +1,7 @@
 # Template file for 'dolphin-emu'
 pkgname=dolphin-emu
 version=5.0.16101
-revision=1
+revision=2
 _dolphin_commit=8ecfa537a242de74d2e372e30d9d79b14584b2fb
 _mgba_commit=40d4c430fc36caeb7ea32fd39624947ed487d2f2
 #Version/hash pair can be found at https://dolphin-emu.org/download/

From 2bc6e90ed30f82c28a8a935774f142892677f564 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 030/116] droidcam-obs-plugin: revbump for ffmpeg-6.0

---
 srcpkgs/droidcam-obs-plugin/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam-obs-plugin/template b/srcpkgs/droidcam-obs-plugin/template
index fc9c9bf6b9d5..fb0480754df4 100644
--- a/srcpkgs/droidcam-obs-plugin/template
+++ b/srcpkgs/droidcam-obs-plugin/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam-obs-plugin'
 pkgname=droidcam-obs-plugin
 version=2.0.1
-revision=1
+revision=2
 build_style=gnu-makefile
 make_use_env=yes
 make_build_args="ALLOW_STATIC=no"

From 0031f314e2d04c3ef22b7e7fe3a7f6425f1e342d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 031/116] droidcam: revbump for ffmpeg-6.0

---
 srcpkgs/droidcam/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam/template b/srcpkgs/droidcam/template
index 1c3f1b8b1fc6..32a9220b79a4 100644
--- a/srcpkgs/droidcam/template
+++ b/srcpkgs/droidcam/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam'
 pkgname=droidcam
 version=1.8.2
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="USBMUXD=-lusbmuxd-2.0 JPEG=-lturbojpeg"
 hostmakedepends="pkg-config"

From 023cb36afa8ebec9f3d9bfa1a7b2bf82a0bd6e0c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 032/116] ffmpegthumbnailer: revbump for ffmpeg-6.0

---
 .../ffmpegthumbnailer/patches/ffmpeg6.patch   | 202 ++++++++++++++++++
 srcpkgs/ffmpegthumbnailer/template            |   6 +-
 2 files changed, 205 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch

diff --git a/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
new file mode 100644
index 000000000000..363ff35a2841
--- /dev/null
+++ b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
@@ -0,0 +1,202 @@
+--- a/libffmpegthumbnailer/moviedecoder.cpp	2017-11-21 14:06:57.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.cpp	2023-05-05 13:14:47.946560668 -0400
+@@ -41,11 +41,6 @@
+ namespace ffmpegthumbnailer
+ {
+ 
+-struct SilenceLogLevel
+-{
+-    SilenceLogLevel() { av_log_set_level(AV_LOG_QUIET); }
+-};
+-
+ MovieDecoder::MovieDecoder(AVFormatContext* pavContext)
+ : m_VideoStream(-1)
+ , m_pFormatContext(pavContext)
+@@ -70,8 +65,6 @@
+ 
+ void MovieDecoder::initialize(const string& filename, bool preferEmbeddedMetadata)
+ {
+-    av_register_all();
+-    avcodec_register_all();
+     avformat_network_init();
+ 
+     string inputFile = filename == "-" ? "pipe:" : filename;
+@@ -97,8 +90,7 @@
+ {
+     if (m_pVideoCodecContext)
+     {
+-        avcodec_close(m_pVideoCodecContext);
+-        m_pVideoCodecContext = nullptr;
++        avcodec_free_context(&m_pVideoCodecContext);
+     }
+ 
+     if ((!m_FormatContextWasGiven) && m_pFormatContext)
+@@ -152,10 +144,10 @@
+     for (unsigned int i = 0; i < m_pFormatContext->nb_streams; ++i)
+     {
+         AVStream *stream = m_pFormatContext->streams[i];
+-        auto ctx = m_pFormatContext->streams[i]->codec;
+-        if (ctx->codec_type == AVMEDIA_TYPE_VIDEO)
++        auto par = m_pFormatContext->streams[i]->codecpar;
++        if (par->codec_type == AVMEDIA_TYPE_VIDEO)
+         {
+-            if (!preferEmbeddedMetadata || !isStillImageCodec(ctx->codec_id))
++            if (!preferEmbeddedMetadata || !isStillImageCodec(par->codec_id))
+             {
+                 videoStreams.push_back(i);
+                 continue;
+@@ -203,8 +195,7 @@
+     }
+ 
+     m_pVideoStream = m_pFormatContext->streams[m_VideoStream];
+-    m_pVideoCodecContext = m_pVideoStream->codec;
+-    m_pVideoCodec = avcodec_find_decoder(m_pVideoCodecContext->codec_id);
++    m_pVideoCodec = avcodec_find_decoder(m_pVideoStream->codecpar->codec_id);
+ 
+     if (m_pVideoCodec == nullptr)
+     {
+@@ -214,6 +205,20 @@
+         throw logic_error("Video Codec not found");
+     }
+ 
++    m_pVideoCodecContext = avcodec_alloc_context3(m_pVideoCodec);
++
++    if (m_pVideoCodecContext == nullptr)
++    {
++        destroy();
++        throw logic_error("Could not allocate video codec context");
++    }
++
++    if (avcodec_parameters_to_context(m_pVideoCodecContext, m_pVideoStream->codecpar) < 0)
++    {
++        destroy();
++        throw logic_error("Could not configure video codec context");
++    }
++
+     m_pVideoCodecContext->workaround_bugs = 1;
+ 
+     if (avcodec_open2(m_pVideoCodecContext, m_pVideoCodec, nullptr) < 0)
+@@ -386,13 +391,6 @@
+ 
+ void MovieDecoder::initializeFilterGraph(const AVRational& timeBase, const std::string& size, bool maintainAspectRatio)
+ {
+-    static const AVPixelFormat pixelFormats[] = { AV_PIX_FMT_RGB24, AV_PIX_FMT_NONE };
+-
+-    auto del = [] (AVBufferSinkParams* p) { av_freep(p); };
+-    std::unique_ptr<AVBufferSinkParams, decltype(del)> buffersinkParams(av_buffersink_params_alloc(), del);
+-
+-    avfilter_register_all();
+-
+     m_pFilterGraph = avfilter_graph_alloc();
+     assert(m_pFilterGraph);
+ 
+@@ -404,10 +402,8 @@
+ 
+     checkRc(avfilter_graph_create_filter(&m_pFilterSource, avfilter_get_by_name("buffer"), "thumb_buffer", ss.str().c_str(), nullptr, m_pFilterGraph),
+             "Failed to create filter source");
+-    buffersinkParams->pixel_fmts = pixelFormats;
+-    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, buffersinkParams.get(), m_pFilterGraph),
++    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, nullptr, m_pFilterGraph),
+             "Failed to create filter sink");
+-    buffersinkParams.release();
+ 
+     AVFilterContext* yadifFilter = nullptr;
+     if (m_pFrame->interlaced_frame != 0)
+@@ -500,15 +496,15 @@
+     }
+ 
+     checkRc(av_seek_frame(m_pFormatContext, -1, timestamp, 0), "Seeking in video failed");
+-    avcodec_flush_buffers(m_pFormatContext->streams[m_VideoStream]->codec);
++    avcodec_flush_buffers(m_pVideoCodecContext);
+ 
+     int keyFrameAttempts = 0;
+-    bool gotFrame = 0;
++    bool gotFrame;
+ 
+     do
+     {
+         int count = 0;
+-        gotFrame = 0;
++        gotFrame = false;
+ 
+         while (!gotFrame && count < 20)
+         {
+@@ -552,17 +548,33 @@
+         return false;
+     }
+ 
+-    av_frame_unref(m_pFrame);
+-
+-    int frameFinished;
++    int rc = avcodec_send_packet(m_pVideoCodecContext, m_pPacket);
++    if(rc == AVERROR(EAGAIN))
++    {
++        rc = 0;
++    }
+ 
+-    int bytesDecoded = avcodec_decode_video2(m_pVideoCodecContext, m_pFrame, &frameFinished, m_pPacket);
+-    if (bytesDecoded < 0)
++    if(rc == AVERROR_EOF)
++    {
++        return false;
++    }
++    else if(rc < 0)
+     {
+-        throw logic_error("Failed to decode video frame: bytesDecoded < 0");
++        throw logic_error("Failed to decode video frame: avcodec_send_packet() < 0");
+     }
+ 
+-    return frameFinished > 0;
++    rc = avcodec_receive_frame(m_pVideoCodecContext, m_pFrame);
++    switch(rc)
++    {
++        case 0:
++            return true;
++
++        case AVERROR(EAGAIN):
++            return false;
++
++        default:
++            throw logic_error("Failed to decode video frame: avcodec_receive_frame() < 0");
++    }
+ }
+ 
+ bool MovieDecoder::getVideoPacket()
+@@ -570,8 +582,6 @@
+     bool framesAvailable = true;
+     bool frameDecoded = false;
+ 
+-    int attempts = 0;
+-
+     if (m_pPacket)
+     {
+         av_packet_unref(m_pPacket);
+@@ -580,6 +590,7 @@
+ 
+     m_pPacket = new AVPacket();
+ 
++
+     while (framesAvailable && !frameDecoded)
+     {
+         framesAvailable = av_read_frame(m_pFormatContext, m_pPacket) >= 0;
+@@ -644,7 +655,7 @@
+ 
+ int32_t MovieDecoder::getStreamRotation()
+ {
+-    int32_t* matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
++    auto matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
+     if (matrix)
+     {
+         auto angle = lround(av_display_rotation_get(matrix));
+
+--- a/libffmpegthumbnailer/moviedecoder.h	2017-11-12 04:23:38.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.h	2023-05-05 13:26:07.095529911 -0400
+@@ -78,7 +78,7 @@
+     int                     m_VideoStream;
+     AVFormatContext*        m_pFormatContext;
+     AVCodecContext*         m_pVideoCodecContext;
+-    AVCodec*                m_pVideoCodec;
++    const AVCodec*          m_pVideoCodec;
+     AVFilterGraph*          m_pFilterGraph;
+     AVFilterContext*        m_pFilterSource;
+     AVFilterContext*        m_pFilterSink;
diff --git a/srcpkgs/ffmpegthumbnailer/template b/srcpkgs/ffmpegthumbnailer/template
index 039eea7622b3..35d546018d12 100644
--- a/srcpkgs/ffmpegthumbnailer/template
+++ b/srcpkgs/ffmpegthumbnailer/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbnailer'
 pkgname=ffmpegthumbnailer
 version=2.2.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libpng-devel libjpeg-turbo-devel ffmpeg-devel"
@@ -9,8 +9,8 @@ depends="ffmpeg"
 short_desc="Lightweight video thumbnailer"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
-homepage="https://github.com/dirkvdb/${pkgname}"
-distfiles="${homepage}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
+homepage="https://github.com/dirkvdb"
+distfiles="${homepage}/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
 checksum=1cb24059c38223f657b300c84dd80491b7040d4b69471c4fea69be862bc99b5b
 
 post_install() {

From 0edd3f1d29c19669c8dcbba940149b5c3e823508 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 033/116] ffmpegthumbs: revbump for ffmpeg-6.0

---
 srcpkgs/ffmpegthumbs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ffmpegthumbs/template b/srcpkgs/ffmpegthumbs/template
index 5f0b9414dada..11b88193528f 100644
--- a/srcpkgs/ffmpegthumbs/template
+++ b/srcpkgs/ffmpegthumbs/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbs'
 pkgname=ffmpegthumbs
 version=22.12.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules kcoreaddons kconfig-devel
  pkg-config qt5-host-tools qt5-qmake gettext"

From 0f1c89cce65a726c9bc80022da46e37660c1e67d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 034/116] ffms2: revbump for ffmpeg-6.0

---
 srcpkgs/ffms2/patches/ffmpeg5.patch | 424 ++++++++++++++++++++++++++++
 srcpkgs/ffms2/template              |   2 +-
 2 files changed, 425 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ffms2/patches/ffmpeg5.patch

diff --git a/srcpkgs/ffms2/patches/ffmpeg5.patch b/srcpkgs/ffms2/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..1479fabcafcb
--- /dev/null
+++ b/srcpkgs/ffms2/patches/ffmpeg5.patch
@@ -0,0 +1,424 @@
+From 45673149e9a2f5586855ad472e3059084eaa36b1 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:41:21 +0100
+Subject: [PATCH] Use auto for AVCodec
+
+The geniuses over at FFmpeg decided to constify this API, so old
+versions of the library will return AVCodec *, while new versions
+of the libary will return const AVCodec *, which, in C++, are not
+OK to convert between.
+
+Rather than use some macro hell in ffmscompat.h, we can work around
+this by using auto.
+
+Gross.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 2 +-
+ src/core/indexing.cpp    | 6 +++---
+ src/core/videosource.cpp | 2 +-
+ 3 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index e4ce97c..ac09666 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -469,7 +469,7 @@ void FFMS_AudioSource::OpenFile() {
+ 
+     LAVFOpenFile(SourceFile.c_str(), FormatContext, TrackNumber);
+ 
+-    AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
++    auto *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
+     if (Codec == nullptr)
+         throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+             "Audio codec not found");
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index e547c5a..59fb4e8 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -384,7 +384,7 @@ FFMS_TrackType FFMS_Indexer::GetTrackType(int Track) {
+ }
+ 
+ const char *FFMS_Indexer::GetTrackCodec(int Track) {
+-    AVCodec *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
++    auto *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
+     return codec ? codec->name : nullptr;
+ }
+ 
+@@ -402,7 +402,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             UseDTS);
+ 
+         if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            AVCodec *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (!VideoCodec) {
+                 FormatContext->streams[i]->discard = AVDISCARD_ALL;
+                 IndexMask.erase(i);
+@@ -433,7 +433,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 IndexMask.insert(i);
+             }
+         } else if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+-            AVCodec *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (AudioCodec == nullptr)
+                 throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_UNSUPPORTED,
+                     "Audio codec not found");
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index b889970..8956c22 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -171,7 +171,7 @@ FFMS_VideoSource::FFMS_VideoSource(const char *SourceFile, FFMS_Index &Index, in
+ 
+         LAVFOpenFile(SourceFile, FormatContext, VideoTrack);
+ 
+-        AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
++        auto *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
+         if (Codec == nullptr)
+             throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+                 "Video codec not found");
+-- 
+2.40.0
+
+From 96cbf38ea9381829a1314f432a2c60495dcefaad Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:12:41 +0100
+Subject: [PATCH] all: Update AVPacket API usage
+
+AVPackets must all be on the heap now, since it is no longer
+part of the libav* ABI.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 16 ++++++----
+ src/core/indexing.cpp    | 63 ++++++++++++++++++++++------------------
+ src/core/indexing.h      |  4 +--
+ src/core/utils.cpp       |  6 ----
+ src/core/utils.h         |  1 -
+ src/core/videosource.cpp | 30 ++++++++++---------
+ 6 files changed, 64 insertions(+), 56 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index 37cf9ae..e4ce97c 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -285,10 +285,15 @@ FFMS_AudioSource::AudioBlock *FFMS_AudioSource::CacheBlock(CacheIterator &pos) {
+ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     CurrentFrame = &Frames[PacketNumber];
+ 
+-    AVPacket Packet;
+-    if (!ReadPacket(&Packet))
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++    if (!ReadPacket(Packet)) {
++        av_packet_free(&Packet);
+         throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_UNKNOWN,
+             "ReadPacket unexpectedly failed to read a packet");
++    }
+ 
+     // ReadPacket may have changed the packet number
+     CurrentFrame = &Frames[PacketNumber];
+@@ -297,8 +302,9 @@ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     int NumberOfSamples = 0;
+     AudioBlock *CachedBlock = nullptr;
+     
+-    int Ret = avcodec_send_packet(CodecContext, &Packet);
+-    av_packet_unref(&Packet);
++    int Ret = avcodec_send_packet(CodecContext, Packet);
++    av_packet_unref(Packet);
++    av_packet_free(&Packet);
+ 
+     av_frame_unref(DecodeFrame);
+     Ret = avcodec_receive_frame(CodecContext, DecodeFrame);
+@@ -513,8 +519,6 @@ void FFMS_AudioSource::Seek() {
+ }
+ 
+ bool FFMS_AudioSource::ReadPacket(AVPacket *Packet) {
+-    InitNullPacket(*Packet);
+-
+     while (av_read_frame(FormatContext, Packet) >= 0) {
+         if (Packet->stream_index == TrackNumber) {
+             // Required because not all audio packets, especially in ogg, have a pts. Use the previous valid packet's pts instead.
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index 23fb95b..e547c5a 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -320,7 +320,7 @@ void FFMS_Indexer::CheckAudioProperties(int Track, AVCodecContext *Context) {
+     }
+ }
+ 
+-void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict,
++void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict,
+                                     int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct) {
+     if (VideoContext.Parser) {
+         uint8_t *OB;
+@@ -330,8 +330,8 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+         av_parser_parse2(VideoContext.Parser,
+             VideoContext.CodecContext,
+             &OB, &OBSize,
+-            pkt.data, pkt.size,
+-            pkt.pts, pkt.dts, pkt.pos);
++            pkt->data, pkt->size,
++            pkt->pts, pkt->dts, pkt->pos);
+ 
+         // H.264 (PAFF) and HEVC may have one field per packet, so we need to track
+         // when we have a full or half frame available, and mark one of them as
+@@ -351,15 +351,15 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+ 
+         *RepeatPict = VideoContext.Parser->repeat_pict;
+         *FrameType = VideoContext.Parser->pict_type;
+-        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt.flags & AV_PKT_FLAG_DISCARD));
++        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt->flags & AV_PKT_FLAG_DISCARD));
+     } else {
+-        *Invisible = !!(pkt.flags & AV_PKT_FLAG_DISCARD);
++        *Invisible = !!(pkt->flags & AV_PKT_FLAG_DISCARD);
+     }
+ 
+     if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP8)
+-        ParseVP8(pkt.data[0], Invisible, FrameType);
++        ParseVP8(pkt->data[0], Invisible, FrameType);
+     else if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP9)
+-        ParseVP9(pkt.data[0], Invisible, FrameType);
++        ParseVP9(pkt->data[0], Invisible, FrameType);
+ }
+ 
+ void FFMS_Indexer::Free() {
+@@ -458,32 +458,36 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+         }
+     }
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
+     std::vector<int64_t> LastValidTS(FormatContext->nb_streams, AV_NOPTS_VALUE);
+ 
+     int64_t filesize = avio_size(FormatContext->pb);
+     enum AVPictureStructure LastPicStruct = AV_PICTURE_STRUCTURE_UNKNOWN;
+-    while (av_read_frame(FormatContext, &Packet) >= 0) {
++    while (av_read_frame(FormatContext, Packet) >= 0) {
+         // Update progress
+         // FormatContext->pb can apparently be NULL when opening images.
+         if (IC && FormatContext->pb) {
+-            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate))
++            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate)) {
++                av_packet_free(&Packet);
+                 throw FFMS_Exception(FFMS_ERROR_CANCELLED, FFMS_ERROR_USER,
+                     "Cancelled by user");
++            }
+         }
+-        if (!IndexMask.count(Packet.stream_index)) {
+-            av_packet_unref(&Packet);
++        if (!IndexMask.count(Packet->stream_index)) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+-        int Track = Packet.stream_index;
++        int Track = Packet->stream_index;
+         FFMS_Track &TrackInfo = (*TrackIndices)[Track];
+-        bool KeyFrame = !!(Packet.flags & AV_PKT_FLAG_KEY);
++        bool KeyFrame = !!(Packet->flags & AV_PKT_FLAG_KEY);
+         ReadTS(Packet, LastValidTS[Track], (*TrackIndices)[Track].UseDTS);
+ 
+         if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            int64_t PTS = TrackInfo.UseDTS ? Packet.dts : Packet.pts;
++            int64_t PTS = TrackInfo.UseDTS ? Packet->dts : Packet->pts;
+             if (PTS == AV_NOPTS_VALUE) {
+                 // VPx alt-refs are output as packets which lack timestmps or durations, since
+                 // they are invisible. Currently, the timestamp mangling code in libavformat
+@@ -495,9 +499,11 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 // FFMS2 currently sorts packets by PTS, which will break decoding, otherwise.
+                 bool HasAltRefs = (FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP8 ||
+                                    FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP9);
+-                if (Packet.duration == 0 && !HasAltRefs)
++                if (Packet->duration == 0 && !HasAltRefs) {
++                    av_packet_free(&Packet);
+                     throw FFMS_Exception(FFMS_ERROR_INDEXING, FFMS_ERROR_PARSER,
+                         "Invalid packet pts, dts, and duration");
++                }
+ 
+                 if (TrackInfo.empty())
+                     PTS = 0;
+@@ -513,7 +519,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             ParseVideoPacket(AVContexts[Track], Packet, &RepeatPict, &FrameType, &Invisible, &LastPicStruct);
+ 
+             TrackInfo.AddVideoFrame(PTS, RepeatPict, KeyFrame,
+-                FrameType, Packet.pos, Invisible);
++                FrameType, Packet->pos, Invisible);
+         } else if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+             // For video seeking timestamps are used only if all packets have
+             // timestamps, while for audio they're used if any have timestamps,
+@@ -522,28 +528,29 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 TrackInfo.HasTS = true;
+ 
+             int64_t StartSample = AVContexts[Track].CurrentSample;
+-            uint32_t SampleCount = IndexAudioPacket(Track, &Packet, AVContexts[Track], *TrackIndices);
++            uint32_t SampleCount = IndexAudioPacket(Track, Packet, AVContexts[Track], *TrackIndices);
+             TrackInfo.SampleRate = AVContexts[Track].CodecContext->sample_rate;
+ 
+             TrackInfo.AddAudioFrame(LastValidTS[Track],
+-                StartSample, SampleCount, KeyFrame, Packet.pos, Packet.flags & AV_PKT_FLAG_DISCARD);
++                StartSample, SampleCount, KeyFrame, Packet->pos, Packet->flags & AV_PKT_FLAG_DISCARD);
+         }
+ 
+-        if (!(Packet.flags & AV_PKT_FLAG_DISCARD))
+-            TrackInfo.LastDuration = Packet.duration;
++        if (!(Packet->flags & AV_PKT_FLAG_DISCARD))
++            TrackInfo.LastDuration = Packet->duration;
+ 
+-        av_packet_unref(&Packet);
++        av_packet_unref(Packet);
+     }
++    av_packet_free(&Packet);
+ 
+     TrackIndices->Finalize(AVContexts, FormatContext->iformat->name);
+     return TrackIndices.release();
+ }
+ 
+-void FFMS_Indexer::ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS) {
+-    if (!UseDTS && Packet.pts != AV_NOPTS_VALUE)
+-        TS = Packet.pts;
++void FFMS_Indexer::ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS) {
++    if (!UseDTS && Packet->pts != AV_NOPTS_VALUE)
++        TS = Packet->pts;
+     if (TS == AV_NOPTS_VALUE)
+         UseDTS = true;
+-    if (UseDTS && Packet.dts != AV_NOPTS_VALUE)
+-        TS = Packet.dts;
++    if (UseDTS && Packet->dts != AV_NOPTS_VALUE)
++        TS = Packet->dts;
+ }
+diff --git a/src/core/indexing.h b/src/core/indexing.h
+index 3cfc3c3..5c06868 100644
+--- a/src/core/indexing.h
++++ b/src/core/indexing.h
+@@ -80,10 +80,10 @@ private:
+     int64_t Filesize;
+     uint8_t Digest[20];
+ 
+-    void ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS);
++    void ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS);
+     void CheckAudioProperties(int Track, AVCodecContext *Context);
+     uint32_t IndexAudioPacket(int Track, AVPacket *Packet, SharedAVContext &Context, FFMS_Index &TrackIndices);
+-    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
++    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
+     void Free();
+ public:
+     FFMS_Indexer(const char *Filename);
+diff --git a/src/core/utils.cpp b/src/core/utils.cpp
+index ce67533..8a2e997 100644
+--- a/src/core/utils.cpp
++++ b/src/core/utils.cpp
+@@ -62,12 +62,6 @@ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo) {
+     }
+ }
+ 
+-void InitNullPacket(AVPacket &pkt) {
+-    av_init_packet(&pkt);
+-    pkt.data = nullptr;
+-    pkt.size = 0;
+-}
+-
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames) {
+     AP.SampleFormat = static_cast<FFMS_SampleFormat>(av_get_packed_sample_fmt(CTX->sample_fmt));
+     AP.BitsPerSample = av_get_bytes_per_sample(CTX->sample_fmt) * 8;
+diff --git a/src/core/utils.h b/src/core/utils.h
+index 9819dc7..003ab79 100644
+--- a/src/core/utils.h
++++ b/src/core/utils.h
+@@ -58,7 +58,6 @@ std::unique_ptr<T> make_unique(Args&&... args) {
+ }
+ 
+ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo);
+-void InitNullPacket(AVPacket &pkt);
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames);
+ 
+ void LAVFOpenFile(const char *SourceFile, AVFormatContext *&FormatContext, int Track);
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index 06bd161..b889970 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -673,30 +673,34 @@ void FFMS_VideoSource::DecodeNextFrame(int64_t &AStartTime, int64_t &Pos) {
+     if (HasPendingDelayedFrames())
+         return;
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
+-
+-    while (ReadFrame(&Packet) >= 0) {
+-        if (Packet.stream_index != VideoTrack) {
+-            av_packet_unref(&Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++
++    while (ReadFrame(Packet) >= 0) {
++        if (Packet->stream_index != VideoTrack) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+         if (AStartTime < 0)
+-            AStartTime = Frames.UseDTS ? Packet.dts : Packet.pts;
++            AStartTime = Frames.UseDTS ? Packet->dts : Packet->pts;
+ 
+         if (Pos < 0)
+-            Pos = Packet.pos;
++            Pos = Packet->pos;
+ 
+-        bool FrameFinished = DecodePacket(&Packet);
+-        av_packet_unref(&Packet);
+-        if (FrameFinished)
++        bool FrameFinished = DecodePacket(Packet);
++        av_packet_unref(Packet);
++        if (FrameFinished) {
++            av_packet_free(&Packet);
+             return;
++        }
+     }
+ 
+     // Flush final frames
+-    InitNullPacket(Packet);
+-    DecodePacket(&Packet);
++    DecodePacket(Packet);
++    av_packet_free(&Packet);
+ }
+ 
+ bool FFMS_VideoSource::SeekTo(int n, int SeekOffset) {
+-- 
+2.40.0
+
+From bf9e03e9e08534c024e5a744a6437c4aac160201 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:20:47 +0100
+Subject: [PATCH 2/3] configure: Remove deprecated API use
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ configure.ac | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index b35ef80bc..d19714d0f 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -102,10 +102,10 @@ CFLAGS="$_CFLAGS $FFMPEG_CFLAGS"
+
+ AC_DEFUN([TEST_FFMPEG],
+          [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+-            #include <libavcodec/avcodec.h>
++            #include <libavformat/avformat.h>
+             #include <libswscale/swscale.h>
+             ]],[[
+-                avcodec_register_all();
++                avformat_network_init();
+                 swscale_version();
+             ]])], [eval $1=yes], [eval $1=no])
+         ])
+
diff --git a/srcpkgs/ffms2/template b/srcpkgs/ffms2/template
index 68e8a0c14bce..2acfadac44b3 100644
--- a/srcpkgs/ffms2/template
+++ b/srcpkgs/ffms2/template
@@ -1,7 +1,7 @@
 # Template file for 'ffms2'
 pkgname=ffms2
 version=2.40
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-shared --disable-static"
 hostmakedepends="pkg-config autoconf automake libtool"

From 023092add73b3c271fc434b316b91820ee0a9312 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 035/116] freerdp: revbump for ffmpeg-6.0

---
 .../freerdp/patches/ffmpeg6_aa2cb9aa.patch    | 42 +++++++++++++++++++
 srcpkgs/freerdp/template                      |  2 +-
 2 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch

diff --git a/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
new file mode 100644
index 000000000000..a4324da3a882
--- /dev/null
+++ b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
@@ -0,0 +1,42 @@
+From aa2cb9aa5ff5562433598ba168a466e0752bca0e Mon Sep 17 00:00:00 2001
+From: akallabeth <akallabeth@posteo.net>
+Date: Tue, 14 Feb 2023 07:48:54 +0100
+Subject: [PATCH] Fixed #8686: Update h264 to use new FFMPEG API
+
+---
+ channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c | 2 ++
+ libfreerdp/codec/h264_ffmpeg.c            | 2 ++
+ 2 files changed, 4 insertions(+)
+
+diff --git a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+index 339462d865f..beea80b7a1e 100644
+--- a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
++++ b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+@@ -239,8 +239,10 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYP
+ 		}
+ 	}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 	if (mdecoder->codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		mdecoder->codec_context->flags |= AV_CODEC_FLAG_TRUNCATED;
++#endif
+ 
+ 	return TRUE;
+ }
+diff --git a/libfreerdp/codec/h264_ffmpeg.c b/libfreerdp/codec/h264_ffmpeg.c
+index 8a23db2473c..896a333019b 100644
+--- a/libfreerdp/codec/h264_ffmpeg.c
++++ b/libfreerdp/codec/h264_ffmpeg.c
+@@ -615,10 +615,12 @@ static BOOL libavcodec_init(H264_CONTEXT* h264)
+ 			goto EXCEPTION;
+ 		}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 		if (sys->codecDecoder->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		{
+ 			sys->codecDecoderContext->flags |= AV_CODEC_FLAG_TRUNCATED;
+ 		}
++#endif
+ 
+ #ifdef WITH_VAAPI
+ 
diff --git a/srcpkgs/freerdp/template b/srcpkgs/freerdp/template
index 25e8aa9677f0..4d51c8189902 100644
--- a/srcpkgs/freerdp/template
+++ b/srcpkgs/freerdp/template
@@ -1,7 +1,7 @@
 # Template file for 'freerdp'
 pkgname=freerdp
 version=2.10.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_ALSA=ON -DWITH_CUPS=OFF -DWITH_FFMPEG=ON
  -DWITH_GSTREAMER_0_10=OFF -DWITH_GSTREAMER_1_0=OFF -DWITH_JPEG=ON

From 75bfac8c48021ab9466203fc773816f02f1549b5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 036/116] gerbera: revbump for ffmpeg-6.0

---
 srcpkgs/gerbera/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gerbera/template b/srcpkgs/gerbera/template
index ae14f35c767c..2dc0ac0ce03b 100644
--- a/srcpkgs/gerbera/template
+++ b/srcpkgs/gerbera/template
@@ -1,7 +1,7 @@
 # Template file for 'gerbera'
 pkgname=gerbera
 version=1.12.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_SYSTEMD=0 -DWITH_AVCODEC=1"
 hostmakedepends="pkg-config"

From 6b952b975b720ff11e8e3b160858449a75792640 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 037/116] goldendict: revbump for ffmpeg-6.0

---
 srcpkgs/goldendict/patches/ffmpeg4.patch |  21 --
 srcpkgs/goldendict/patches/ffmpeg5.patch | 232 +++++++++++++++++++++++
 srcpkgs/goldendict/template              |   2 +-
 3 files changed, 233 insertions(+), 22 deletions(-)
 delete mode 100644 srcpkgs/goldendict/patches/ffmpeg4.patch
 create mode 100644 srcpkgs/goldendict/patches/ffmpeg5.patch

diff --git a/srcpkgs/goldendict/patches/ffmpeg4.patch b/srcpkgs/goldendict/patches/ffmpeg4.patch
deleted file mode 100644
index f045fa27f54b..000000000000
--- a/srcpkgs/goldendict/patches/ffmpeg4.patch
+++ /dev/null
@@ -1,21 +0,0 @@
---- a/ffmpegaudio.cc.orig 2018-05-09 22:16:13.480659958 +0200
-+++ b/ffmpegaudio.cc      2018-05-09 22:16:50.748322790 +0200
-@@ -143,7 +143,7 @@
-     return false;
-   }
-
--  unsigned char * avioBuffer = ( unsigned char * )av_malloc( kBufferSize + FF_INPUT_BUFFER_PADDING_SIZE );
-+  unsigned char * avioBuffer = ( unsigned char * )av_malloc( kBufferSize + AV_INPUT_BUFFER_PADDING_SIZE );
-   if ( !avioBuffer )
-   {
-     errorString = QObject::tr( "av_malloc() failed." );
-@@ -380,7 +380,7 @@
-   }
-
-   if ( !Qt4x5::AtomicInt::loadAcquire( isCancelled_ ) &&
--       codecContext_->codec->capabilities & CODEC_CAP_DELAY )
-+       codecContext_->codec->capabilities & AV_CODEC_CAP_DELAY )
-   {
-     av_init_packet( &packet );
-     int gotFrame = 0;
-
diff --git a/srcpkgs/goldendict/patches/ffmpeg5.patch b/srcpkgs/goldendict/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..7cfc98ada368
--- /dev/null
+++ b/srcpkgs/goldendict/patches/ffmpeg5.patch
@@ -0,0 +1,232 @@
+From 03bbe01b79a1f07a6780cb60f23a087104c5d77b Mon Sep 17 00:00:00 2001
+From: Abs62 <ottomann@yandex.ru>
+Date: Fri, 30 Mar 2018 22:53:24 +0300
+Subject: [PATCH] Fix warnings while compile with FFMpeg 3.4.2 (issue #978)
+
+---
+ ffmpegaudio.cc | 68 +++++++++++++++++++++++++++++++++++++++++++++-----
+ 1 file changed, 62 insertions(+), 6 deletions(-)
+
+diff --git a/ffmpegaudio.cc b/ffmpegaudio.cc
+index ed1172bdd..56e8f788e 100644
+--- a/ffmpegaudio.cc
++++ b/ffmpegaudio.cc
+@@ -91,6 +91,7 @@ struct DecoderContext
+   QByteArray audioData_;
+   QDataStream audioDataStream_;
+   AVFormatContext * formatContext_;
++  AVCodec * codec_;
+   AVCodecContext * codecContext_;
+   AVIOContext * avioContext_;
+   AVStream * audioStream_;
+@@ -114,6 +115,7 @@ DecoderContext::DecoderContext( QByteArray const & audioData, QAtomicInt & isCan
+   audioData_( audioData ),
+   audioDataStream_( audioData_ ),
+   formatContext_( NULL ),
++  codec_( NULL ),
+   codecContext_( NULL ),
+   avioContext_( NULL ),
+   audioStream_( NULL ),
+@@ -143,7 +145,11 @@ bool DecoderContext::openCodec( QString & errorString )
+     return false;
+   }
+
++#if LIBAVCODEC_VERSION_MAJOR < 56 || ( LIBAVCODEC_VERSION_MAJOR == 56 && LIBAVCODEC_VERSION_MINOR < 56 )
+   unsigned char * avioBuffer = ( unsigned char * )av_malloc( kBufferSize + FF_INPUT_BUFFER_PADDING_SIZE );
++#else
++  unsigned char * avioBuffer = ( unsigned char * )av_malloc( kBufferSize + AV_INPUT_BUFFER_PADDING_SIZE );
++#endif
+   if ( !avioBuffer )
+   {
+     errorString = QObject::tr( "av_malloc() failed." );
+@@ -186,7 +192,11 @@ bool DecoderContext::openCodec( QString & errorString )
+   // Find audio stream, use the first audio stream if available
+   for ( unsigned i = 0; i < formatContext_->nb_streams; i++ )
+   {
++#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 33 )
+     if ( formatContext_->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO )
++#else
++      if ( formatContext_->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO )
++#endif
+     {
+       audioStream_ = formatContext_->streams[i];
+       break;
+@@ -198,22 +208,38 @@ bool DecoderContext::openCodec( QString & errorString )
+     return false;
+   }
+
++#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 33 )
+   codecContext_ = audioStream_->codec;
+-  AVCodec * codec = avcodec_find_decoder( codecContext_->codec_id );
+-  if ( !codec )
++  codec_ = avcodec_find_decoder( codecContext_->codec_id );
++  if ( !codec_ )
+   {
+     errorString = QObject::tr( "Codec [id: %1] not found." ).arg( codecContext_->codec_id );
+     return false;
+   }
++#else
++  codec_ = avcodec_find_decoder( audioStream_->codecpar->codec_id );
++  if ( !codec_ )
++  {
++    errorString = QObject::tr( "Codec [id: %1] not found." ).arg( audioStream_->codecpar->codec_id );
++    return false;
++  }
++  codecContext_ = avcodec_alloc_context3( codec_ );
++  if ( !codecContext_ )
++  {
++    errorString = QObject::tr( "avcodec_alloc_context3() failed." );
++    return false;
++  }
++  avcodec_parameters_to_context( codecContext_, audioStream_->codecpar );
++#endif
+
+-  ret = avcodec_open2( codecContext_, codec, NULL );
++  ret = avcodec_open2( codecContext_, codec_, NULL );
+   if ( ret < 0 )
+   {
+     errorString = QObject::tr( "avcodec_open2() failed: %1." ).arg( avErrorString( ret ) );
+     return false;
+   }
+
+-  av_log( NULL, AV_LOG_INFO, "Codec open: %s: channels: %d, rate: %d, format: %s\n", codec->long_name,
++  av_log( NULL, AV_LOG_INFO, "Codec open: %s: channels: %d, rate: %d, format: %s\n", codec_->long_name,
+           codecContext_->channels, codecContext_->sample_rate, av_get_sample_fmt_name( codecContext_->sample_fmt ) );
+   return true;
+ }
+@@ -252,10 +278,13 @@ void DecoderContext::closeCodec()
+
+   // Closing a codec context without prior avcodec_open2() will result in
+   // a crash in ffmpeg
+-  if ( audioStream_ && audioStream_->codec && audioStream_->codec->codec )
++  if ( audioStream_ && codecContext_ && codec_ )
+   {
+     audioStream_->discard = AVDISCARD_ALL;
+-    avcodec_close( audioStream_->codec );
++    avcodec_close( codecContext_ );
++#if LIBAVCODEC_VERSION_MAJOR > 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR >= 33 )
++    avcodec_free_context( &codecContext_ );
++#endif
+   }
+
+   avformat_close_input( &formatContext_ );
+@@ -356,6 +385,7 @@ bool DecoderContext::play( QString & errorString )
+     if ( packet.stream_index == audioStream_->index )
+     {
+       AVPacket pack = packet;
++#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 37 )
+       int gotFrame = 0;
+       do
+       {
+@@ -370,6 +400,19 @@ bool DecoderContext::play( QString & errorString )
+         pack.data += len;
+       }
+       while( pack.size > 0 );
++#else
++      int ret = avcodec_send_packet( codecContext_, &pack );
++      /* read all the output frames (in general there may be any number of them) */
++      while( ret >= 0 )
++      {
++        ret = avcodec_receive_frame( codecContext_, frame);
++
++        if ( Qt4x5::AtomicInt::loadAcquire( isCancelled_ ) || ret < 0 )
++          break;
++
++        playFrame( frame );
++      }
++#endif
+     }
+     // av_free_packet() must be called after each call to av_read_frame()
+ #if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 7 )
+@@ -379,6 +422,7 @@ bool DecoderContext::play( QString & errorString )
+ #endif
+   }
+
++#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 37 )
+   if ( !Qt4x5::AtomicInt::loadAcquire( isCancelled_ ) &&
+        codecContext_->codec->capabilities & CODEC_CAP_DELAY )
+   {
+@@ -391,6 +435,18 @@ bool DecoderContext::play( QString & errorString )
+       playFrame( frame );
+     }
+   }
++#else
++  /* flush the decoder */
++  av_init_packet( &packet );
++  int ret = avcodec_send_packet(codecContext_, &packet );
++  while( ret >= 0 )
++  {
++    ret = avcodec_receive_frame(codecContext_, frame);
++    if ( Qt4x5::AtomicInt::loadAcquire( isCancelled_ ) || ret < 0 )
++      break;
++    playFrame( frame );
++  }
++#endif
+
+ #if LIBAVCODEC_VERSION_MAJOR < 54
+   av_free( frame );
+32
+srcpkgs/goldendict/patches/ffmpeg5-2.patch
+Comment on this file
+@@ -0,0 +1,32 @@
+From 966f4a8b78e6324b930e5a50f2bb930bd87e565e Mon Sep 17 00:00:00 2001
+From: Abs62 <ottomann@yandex.ru>
+Date: Fri, 27 Sep 2019 17:00:52 +0300
+Subject: [PATCH] FFmpeg player: Fix some crashes on broken files
+
+---
+ ffmpegaudio.cc | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/ffmpegaudio.cc b/ffmpegaudio.cc
+index 56e8f788e..415fc79cb 100644
+--- a/ffmpegaudio.cc
++++ b/ffmpegaudio.cc
+@@ -51,7 +51,9 @@ AudioService & AudioService::instance()
+
+ AudioService::AudioService()
+ {
++#if LIBAVFORMAT_VERSION_MAJOR < 58 || ( LIBAVFORMAT_VERSION_MAJOR == 58 && LIBAVFORMAT_VERSION_MINOR < 9 )
+   av_register_all();
++#endif
+   ao_initialize();
+ }
+
+@@ -438,6 +440,8 @@ bool DecoderContext::play( QString & errorString )
+ #else
+   /* flush the decoder */
+   av_init_packet( &packet );
++  packet.data = NULL;
++  packet.size = 0;
+   int ret = avcodec_send_packet(codecContext_, &packet );
+   while( ret >= 0 )
+   {
+25
+srcpkgs/goldendict/patches/ffmpeg5-3.patch
+Comment on this file
+@@ -0,0 +1,25 @@
+From 8acb288c9e9bdb3c6bf2e803954dd3b6ac273c05 Mon Sep 17 00:00:00 2001
+From: Liao Junxuan <mikeljx@126.com>
+Date: Sun, 20 Feb 2022 12:28:05 +0800
+Subject: [PATCH] add support for ffmpeg 5.0
+
+---
+ ffmpegaudio.cc | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/ffmpegaudio.cc b/ffmpegaudio.cc
+index d550f4a77..7948d2187 100644
+--- a/ffmpegaudio.cc
++++ b/ffmpegaudio.cc
+@@ -94,7 +94,11 @@ struct DecoderContext
+   QByteArray audioData_;
+   QDataStream audioDataStream_;
+   AVFormatContext * formatContext_;
++#if LIBAVCODEC_VERSION_MAJOR < 59
+   AVCodec * codec_;
++#else
++  const AVCodec * codec_;
++#endif
+   AVCodecContext * codecContext_;
+   AVIOContext * avioContext_;
+   AVStream * audioStream_;
diff --git a/srcpkgs/goldendict/template b/srcpkgs/goldendict/template
index 4544ae710ee6..2ca4185e538a 100644
--- a/srcpkgs/goldendict/template
+++ b/srcpkgs/goldendict/template
@@ -9,7 +9,7 @@ makedepends="tiff-devel qt5-devel libvorbis-devel zlib-devel
  libXtst-devel hunspell-devel qt5-tools-devel qt5-declarative-devel
  qt5-webkit-devel lzo-devel bzip2-devel libao-devel qt5-svg-devel
  libeb-devel qt5-x11extras-devel ffmpeg-devel liblzma-devel"
-short_desc="A feature-rich dictionary lookup program"
+short_desc="Feature-rich dictionary lookup program"
 maintainer="John <me@johnnynator.dev>"
 license="GPL-3.0-or-later"
 homepage="http://goldendict.org/"

From abc4e8e81ed1e3133fe310d8dc6c2305b294d32d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 038/116] gst-libav: revbump for ffmpeg-6.0

---
 srcpkgs/gst-libav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index e9a79dc650a5..f082bd211c65 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.20.3
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"

From d23539968d946cb9f81c5d2748b91054fabf99f0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 039/116] gst-plugins-bad1: revbump for ffmpeg-6.0

---
 srcpkgs/gst-plugins-bad1/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index f55f82fd4c77..dc9d389734e1 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-plugins-bad1'
 pkgname=gst-plugins-bad1
-version=1.20.3
-revision=3
+version=1.22.2
+revision=2
 build_helper="gir"
 build_style=meson
 configure_args="-Dpackage-origin=https://voidlinux.org -Ddoc=disabled

From 69bf0d38bb2b845d6cd2d5ebd09531ce0fedebf9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 040/116] gst-rtsp-server: revbump for ffmpeg-6.0

---
 srcpkgs/gst-rtsp-server/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index 33cd64ceb95e..8ceea8d34b4b 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
 version=1.20.3
-revision=2
+revision=3
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="glib-devel gst-plugins-bad1-devel gobject-introspection

From 9690b0105ec0d55cc4b5abe8343e691c90fe20db Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 041/116] guvcview: update to 2.0.8.

---
 srcpkgs/guvcview/patches/fix-include.patch | 10 ++++++++++
 srcpkgs/guvcview/template                  |  5 ++---
 2 files changed, 12 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/guvcview/patches/fix-include.patch

diff --git a/srcpkgs/guvcview/patches/fix-include.patch b/srcpkgs/guvcview/patches/fix-include.patch
new file mode 100644
index 000000000000..503c2af3b78c
--- /dev/null
+++ b/srcpkgs/guvcview/patches/fix-include.patch
@@ -0,0 +1,10 @@
+--- a/guvcview/guvcview.c
++++ b/guvcview/guvcview.c
+@@ -28,6 +28,7 @@
+ #include <sys/stat.h>
+ #include <sys/resource.h>
+ #include <errno.h>
++#include <locale.h>
+ 
+ #include "gview.h"
+ #include "gviewv4l2core.h"
diff --git a/srcpkgs/guvcview/template b/srcpkgs/guvcview/template
index 345cf6006f24..86a7fd619612 100644
--- a/srcpkgs/guvcview/template
+++ b/srcpkgs/guvcview/template
@@ -1,8 +1,7 @@
 # Template file for 'guvcview'
 pkgname=guvcview
-version=2.0.7
+version=2.0.8
 revision=1
-create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-static --disable-debian-menu"
 hostmakedepends="pkg-config intltool autoconf automake libtool glib-devel"
@@ -14,7 +13,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="http://guvcview.sourceforge.net/"
 distfiles="${SOURCEFORGE_SITE}/${pkgname}/${pkgname}-src-${version}.tar.bz2"
-checksum=f47d51fbd06e44eeaa1a82f4a153c927527c90d94514197a70b2956028cc8ad4
+checksum=a21f4e448286666cf27bafef5290cc953a0a1796b752e5bbe521266dc1230c81
 
 post_patch() {
 	sed '31a#include <locale.h>' -i  guvcview/guvcview.c

From db85e5fa4a84a698acc1166e6aa76ee32451579a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 042/116] handbrake: update to 1.6.1

---
 .../patches/fix-missing-x265-link-flag.patch    | 11 ++++++-----
 .../handbrake/patches/libhb-vpl-include.patch   | 15 +++++++++++++++
 srcpkgs/handbrake/template                      | 17 ++++++++++-------
 3 files changed, 31 insertions(+), 12 deletions(-)
 create mode 100644 srcpkgs/handbrake/patches/libhb-vpl-include.patch

diff --git a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
index 26db03867a0c..d6bb2eda627a 100644
--- a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
+++ b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
@@ -1,14 +1,15 @@
 --- a/gtk/configure.ac
 +++ b/gtk/configure.ac
 @@ -203,7 +203,7 @@
- 
+
  AM_CONDITIONAL([MINGW], [test "x$mingw_flag" = "xyes"])
- 
--HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg"
-+HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -ldl"
+
+-HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc"
++HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc -ldl"
  HB_CPPFLAGS="$HB_CPPFLAGS $HBINC"
- 
+
  PKG_CHECK_MODULES([x264], [x264], sys_x264=yes, sys_x264=no)
+
 --- a/test/module.defs
 +++ b/test/module.defs
 @@ -69,6 +69,9 @@
diff --git a/srcpkgs/handbrake/patches/libhb-vpl-include.patch b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
new file mode 100644
index 000000000000..298f9f4ab28f
--- /dev/null
+++ b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
@@ -0,0 +1,15 @@
+--- a/libhb/module.defs	2023-01-22 11:36:49.000000000 -0500
++++ b/libhb/module.defs	2023-04-03 22:37:52.395467010 -0400
+@@ -46,11 +46,7 @@
+ LIBHB.GCC.I += $(LIBHB.build/) $(CONTRIB.build/)include
+ 
+ ifeq (1,$(FEATURE.qsv))
+-    ifeq ($(HOST.system),freebsd))
+-        LIBHB.GCC.I += $(LOCALBASE)/include/vpl
+-    else
+-        LIBHB.GCC.I += $(CONTRIB.build/)include/vpl
+-    endif
++    LIBHB.GCC.I += /usr/include/vpl
+ endif
+ 
+ ifneq (,$(filter $(HOST.system),freebsd netbsd openbsd))
diff --git a/srcpkgs/handbrake/template b/srcpkgs/handbrake/template
index ca5e4571e49c..c32cb1bfa31f 100644
--- a/srcpkgs/handbrake/template
+++ b/srcpkgs/handbrake/template
@@ -1,10 +1,10 @@
 # Template file for 'handbrake'
 pkgname=handbrake
-version=1.5.1
+version=1.6.1
 revision=1
 build_style=gnu-configure
 configure_args="--force --disable-gtk-update-checks --disable-df-fetch --harden
- $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc)"
+ $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc) $(vopt_enable qsv)"
 make_build_args="-C ${XBPS_TRIPLET}"
 make_install_args="-C ${XBPS_TRIPLET}"
 hostmakedepends="automake cmake gettext-devel glib-devel intltool libtool m4 meson nasm pkg-config python3"
@@ -12,8 +12,11 @@ makedepends="bzip2-devel ffmpeg-devel gst-plugins-base1-devel gtk+3-devel
  jansson-devel lame-devel libass-devel libbluray-devel libdav1d-devel
  libdvdnav-devel libdvdread-devel libgudev-devel libnuma-devel
  libsamplerate-devel libtheora-devel libvorbis-devel libvpx-devel libxml2-devel
- opus-devel speex-devel x264-devel x265-devel zimg-devel
+ opus-devel speex-devel x264-devel x265-devel zimg-devel libsvt-av1-devel
  $(vopt_if fdk_aac fdk-aac-devel)
+ $(vopt_if qsv libva-devel)
+ $(vopt_if qsv libdrm-devel)
+ $(vopt_if qsv onevpl-devel)
  $(vopt_if nvenc nv-codec-headers)"
 depends="desktop-file-utils gst-plugins-good1 hicolor-icon-theme"
 short_desc="Multithreaded video transcoder"
@@ -21,15 +24,15 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-2.0-only"
 homepage="https://handbrake.fr/"
 distfiles="https://github.com/HandBrake/HandBrake/releases/download/${version}/HandBrake-${version}-source.tar.bz2"
-checksum=3999fe06d5309c819799a73a968a8ec3840e7840c2b64af8f5cdb7fd8c9430f0
+checksum=94ccfe03db917a91650000c510f7fd53f844da19f19ad4b4be1b8f6bc31a8d4c
 nocross=yes
 
-build_options="fdk_aac nvenc"
+build_options="fdk_aac nvenc qsv"
 
 case "$XBPS_TARGET_MACHINE" in
 	x86_64*|i686*)
 		CFLAGS="-msse"
-		build_options_default="nvenc"
+		build_options_default="nvenc qsv"
 		;;
 esac
 
@@ -37,7 +40,7 @@ pre_configure() {
 	# use system libraries, don't download them
 	rm -rf contrib/
 	for module in fdk-aac ffmpeg libbluray libdav1d libdvdnav libdvdread nvenc \
-		x265 zimg; do
+		x265 zimg svt-av1 libvpl; do
 	    vsed -i "/MODULES += contrib\/${module}/d" make/include/main.defs
 	done
 }

From f0956c063dc11dfbe69870bf860baafe63504e82 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 043/116] hedgewars: revbump for ffmpeg4-4.4.3

---
 srcpkgs/hedgewars/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/hedgewars/template b/srcpkgs/hedgewars/template
index 419f29b98b44..926fe4fe3e68 100644
--- a/srcpkgs/hedgewars/template
+++ b/srcpkgs/hedgewars/template
@@ -1,13 +1,13 @@
 # Template file for 'hedgewars'
 pkgname=hedgewars
 version=1.0.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DNOSERVER=1 -DDATA_INSTALL_DIR=/usr/share/${pkgname}
  -DPHYSFS_SYSTEM=1 -DMINIMAL_FLAGS=1"
 make_cmd=make
 hostmakedepends="lua51 pkg-config qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
+makedepends="ffmpeg4-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
  SDL2_mixer-devel SDL2_net-devel SDL2_ttf-devel"
 depends="libfreeglut"
 short_desc="Funny turn-based artillery game, featuring fighting Hedgehogs!"

From 192bbc5ffbf8340bee0995e27ebd1c89416d75a5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 044/116] idjc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/idjc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/idjc/template b/srcpkgs/idjc/template
index df60318b3db9..36a75baf597c 100644
--- a/srcpkgs/idjc/template
+++ b/srcpkgs/idjc/template
@@ -1,11 +1,11 @@
 # Template file for 'idjc'
 pkgname=idjc
 version=0.9.1
-revision=3
+revision=4
 build_style=gnu-configure
 hostmakedepends="pkg-config git python3 automake gettext-devel libtool"
 makedepends="libvorbis-devel libogg-devel jack-devel libsamplerate-devel
- libflac-devel libsndfile-devel mpg123-devel ffmpeg-devel speex-devel
+ libflac-devel libsndfile-devel mpg123-devel ffmpeg4-devel speex-devel
  glib-devel pixman-devel lame-devel python3-gobject-devel libshout-idjc-devel
  opus-devel twolame-devel python3-mutagen python3-devel"
 depends="python3-gobject python3-mutagen desktop-file-utils shared-mime-info python3-dbus jack"

From fb6e134ea2638ed8330d54db100ec59dd2364957 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 045/116] kfilemetadata5: revbump for ffmpeg-6.0

---
 srcpkgs/kfilemetadata5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kfilemetadata5/template b/srcpkgs/kfilemetadata5/template
index 4b91cf19f298..a3671a38ce59 100644
--- a/srcpkgs/kfilemetadata5/template
+++ b/srcpkgs/kfilemetadata5/template
@@ -1,7 +1,7 @@
 # Template file for 'kfilemetadata5'
 pkgname=kfilemetadata5
 version=5.107.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="kcoreaddons extra-cmake-modules pkg-config qt5-host-tools qt5-qmake
  gettext kcoreaddons python3"

From 4d2f9d9be113a12ee913c64d7e3d39a4ccdcfdff Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 046/116] kid3: revbump for ffmpeg-6.0

---
 srcpkgs/kid3/patches/ffmpeg5.patch | 17 +++++++++++++++++
 srcpkgs/kid3/template              |  2 +-
 2 files changed, 18 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/kid3/patches/ffmpeg5.patch

diff --git a/srcpkgs/kid3/patches/ffmpeg5.patch b/srcpkgs/kid3/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..135fc50e07c9
--- /dev/null
+++ b/srcpkgs/kid3/patches/ffmpeg5.patch
@@ -0,0 +1,17 @@
+# https://aur.archlinux.org/cgit/aur.git/diff/ffmpeg5.patch?h=kid3-cli&id=12410a74906612e7efc0ec8fbce739b4a0fef7e7
+diff --git a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+index e156d424..e12b9abd 100644
+--- a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
++++ b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+@@ -232,7 +232,11 @@ private:
+   friend class Format;
+   friend class Converter;
+   AVCodecContext* m_ptr;
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 0, 0)
+   AVCodec* m_impl;
++#else
++  const AVCodec* m_impl;
++#endif
+   AVFrame* m_frame;
+   bool m_opened;
+ };
diff --git a/srcpkgs/kid3/template b/srcpkgs/kid3/template
index 456206d90e16..f32f9decb0e7 100644
--- a/srcpkgs/kid3/template
+++ b/srcpkgs/kid3/template
@@ -1,7 +1,7 @@
 # Template file for 'kid3'
 pkgname=kid3
 version=3.9.1
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DWITH_APPS='CLI;$(vopt_if KDE KDE Qt)'
  -DWITH_DOCBOOKDIR=/usr/share/xsl/docbook -DWITH_FLAC=$(vopt_if flac ON OFF)

From eb345147b77bb06fdef782f2079dc9c2ce03e75a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 047/116] kodi: revbump for ffmpeg4-4.4.3

---
 srcpkgs/kodi/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/kodi/template b/srcpkgs/kodi/template
index 8057964d78a3..6cc1874be7ba 100644
--- a/srcpkgs/kodi/template
+++ b/srcpkgs/kodi/template
@@ -1,7 +1,7 @@
 # Template file for 'kodi'
 pkgname=kodi
 version=19.4
-revision=6
+revision=7
 _codename="Matrix"
 build_style=cmake
 configure_args="-DWITH_FFMPEG=/usr -DENABLE_LDGOLD=OFF
@@ -54,7 +54,7 @@ makedepends="
  libmad-devel fontconfig-devel libXinerama-devel libsamplerate-devel libmms-devel
  enca-devel boost-devel libcurl-devel libva-devel libvdpau-devel libass-devel
  libbluetooth-devel yajl-devel libplist-devel librtmp-devel tinyxml-devel
- taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg-devel
+ taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg4-devel
  giflib-devel libxslt-devel gnutls-devel libssh-devel libmicrohttpd-devel
  libcec-devel dcadec-devel flatbuffers-devel fmt-devel lcms2-devel
  libfstrcmp-devel rapidjson libcdio-paranoia spdlog libwaylandpp-devel

From 811a21807cbf0f633327128747ff2a6386c47323 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 048/116] kpipewire: revbump for ffmpeg-6.0

---
 srcpkgs/kpipewire/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kpipewire/template b/srcpkgs/kpipewire/template
index 05ad025944da..7aa120e6ba94 100644
--- a/srcpkgs/kpipewire/template
+++ b/srcpkgs/kpipewire/template
@@ -1,7 +1,7 @@
 # Template file for 'kpipewire'
 pkgname=kpipewire
 version=5.27.5
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules plasma-wayland-protocols gettext
  qt5-qmake qt5-host-tools pkg-config wayland-devel kcoreaddons

From 836908a04575a2625fbfe5e86d85e6f95674ee23 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 049/116] libextractor: revbump for ffmpeg4-4.4.3

---
 srcpkgs/libextractor/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libextractor/template b/srcpkgs/libextractor/template
index ddd4790f93e8..1fb9ca56a96a 100644
--- a/srcpkgs/libextractor/template
+++ b/srcpkgs/libextractor/template
@@ -7,7 +7,7 @@ configure_args="--disable-static"
 hostmakedepends="pkg-config"
 makedepends="zlib-devel bzip2-devel exiv2-devel tiff-devel libpng-devel
  libjpeg-turbo-devel libvorbis-devel libflac-devel giflib-devel libmpeg2-devel
- ffmpeg-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
+ ffmpeg4-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
 short_desc="Library used to extract meta data from files"
 maintainer="Martin Riese <grauehaare@gmx.de>"
 license="GPL-3.0-or-later"

From 399db461117a8f8b377b8a05dc36f34a8704a78d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 050/116] libopenal: revbump for ffmpeg-6.0

---
 srcpkgs/libopenal/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenal/template b/srcpkgs/libopenal/template
index 77218f9e539d..3f49ed75a1fd 100644
--- a/srcpkgs/libopenal/template
+++ b/srcpkgs/libopenal/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenal'
 pkgname=libopenal
 version=1.22.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DALSOFT_EXAMPLES=OFF"
 hostmakedepends="pkg-config"

From 03b10f3fb18f76d6e6d2d67c52ec3b0aba1909c9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 051/116] libopenshot: revbump for ffmpeg-6.0

---
 srcpkgs/libopenshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenshot/template b/srcpkgs/libopenshot/template
index db831f69b474..81aa0d7136d9 100644
--- a/srcpkgs/libopenshot/template
+++ b/srcpkgs/libopenshot/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenshot'
 pkgname=libopenshot
 version=0.3.0
-revision=1
+revision=2
 build_style=cmake
 # Builds fail with Ruby-2.4.1
 configure_args="-DENABLE_RUBY=OFF -DUSE_SYSTEM_JSONCPP=ON"

From ad5d62f5be81cc4f3d635bfcf7bb5d18bd5b8b97 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 052/116] loudgain: revbump for ffmpeg-6.0

---
 srcpkgs/loudgain/patches/ffmpeg5.patch | 11 +++++++++++
 srcpkgs/loudgain/template              |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/loudgain/patches/ffmpeg5.patch

diff --git a/srcpkgs/loudgain/patches/ffmpeg5.patch b/srcpkgs/loudgain/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..16d4510ee98f
--- /dev/null
+++ b/srcpkgs/loudgain/patches/ffmpeg5.patch
@@ -0,0 +1,11 @@
+--- a/src/scan.c	2019-09-06 11:31:19.000000000 -0400
++++ b/src/scan.c	2023-03-23 11:15:40.867968521 -0400
+@@ -69,8 +69,6 @@
+ 	 * It is now useless
+ 	 * https://github.com/FFmpeg/FFmpeg/blob/70d25268c21cbee5f08304da95be1f647c630c15/doc/APIchanges#L86
+ 	 */
+-  if (avformat_version() < AV_VERSION_INT(58,9,100))
+-    av_register_all();
+ 
+ 	av_log_set_callback(scan_av_log);
+ 
diff --git a/srcpkgs/loudgain/template b/srcpkgs/loudgain/template
index da4f2d56e94c..4d6bf29efb4f 100644
--- a/srcpkgs/loudgain/template
+++ b/srcpkgs/loudgain/template
@@ -1,7 +1,7 @@
 # Template file for 'loudgain'
 pkgname=loudgain
 version=0.6.8
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libebur128-devel taglib-devel ffmpeg-devel"

From ffbc60482d8bf1ec602214eccc8fdd6e5dff094f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 053/116] mediastreamer: revbump for ffmpeg4-4.4.3

---
 srcpkgs/mediastreamer/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mediastreamer/template b/srcpkgs/mediastreamer/template
index d0e97e858e29..1bde031443a5 100644
--- a/srcpkgs/mediastreamer/template
+++ b/srcpkgs/mediastreamer/template
@@ -1,11 +1,11 @@
 # Template file for 'mediastreamer'
 pkgname=mediastreamer
 version=5.2.6
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_STRICT=0 -DENABLE_UNIT_TESTS=0"
 hostmakedepends="python3"
-makedepends="bzrtp-devel ffmpeg-devel glew-devel libXv-devel libsrtp-devel
+makedepends="bzrtp-devel ffmpeg4-devel glew-devel libXv-devel libsrtp-devel
  libupnp-devel libvpx-devel mbedtls-devel opus-devel ortp-devel pulseaudio-devel
  libtheora-devel speex-devel v4l-utils-devel bcg729-devel bcmatroska2-devel libgsm-devel"
 # zxing-cpp-devel (1.2.0 probably not compatible, check again after updaing xzing)

From 298dad8b57cfbf6fd9def58e0930490402a1788c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 054/116] mgba: revbump for ffmpeg-6.0

---
 srcpkgs/mgba/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mgba/template b/srcpkgs/mgba/template
index ae0504311eee..d31295a0cd3d 100644
--- a/srcpkgs/mgba/template
+++ b/srcpkgs/mgba/template
@@ -1,7 +1,7 @@
 # Template file for 'mgba'
 pkgname=mgba
 version=0.10.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake desktop-file-utils"
 makedepends="SDL2-devel ffmpeg-devel libedit-devel libepoxy-devel libmagick-devel

From 84526f7e1f9b8e262d0c072a441f93a5529a497c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 055/116] minidlna: revbump for ffmpeg-6.0

---
 srcpkgs/minidlna/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/minidlna/template b/srcpkgs/minidlna/template
index e8081b1cbc67..9ee9714861fd 100644
--- a/srcpkgs/minidlna/template
+++ b/srcpkgs/minidlna/template
@@ -1,7 +1,7 @@
 # Template file for 'minidlna'
 pkgname=minidlna
 version=1.3.2
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="
  --sbindir=/usr/bin

From 233339100d985fb2b49a229817de3964d41c6d5f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 056/116] mixxx: revbump for ffmpeg-6.0

---
 srcpkgs/mixxx/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mixxx/template b/srcpkgs/mixxx/template
index 619ddca0d332..4b9ea00d3fb3 100644
--- a/srcpkgs/mixxx/template
+++ b/srcpkgs/mixxx/template
@@ -1,7 +1,7 @@
 # Template file for 'mixxx'
 pkgname=mixxx
 version=2.3.3
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="extra-cmake-modules pkg-config protobuf qt5-host-tools qt5-devel"

From 30c79259d2dc775d968089d0ce4ff7c1304b63f7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 057/116] mlt: revbump for ffmpeg4-4.4.3

---
 srcpkgs/mlt/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mlt/template b/srcpkgs/mlt/template
index 8933eb4e7bb9..73353fedafb5 100644
--- a/srcpkgs/mlt/template
+++ b/srcpkgs/mlt/template
@@ -1,14 +1,14 @@
 # Template file for 'mlt'
 pkgname=mlt
 version=6.26.1
-revision=1
+revision=2
 build_style=configure
 configure_args="--prefix=/usr --libdir=/usr/lib$XBPS_TARGET_WORDSIZE
  --enable-gpl --enable-gpl3 --disable-swfdec --without-kde
  --swig-languages=python"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which"
 # XXX: movit vid.stab
-makedepends="alsa-lib-devel ffmpeg-devel gtk+-devel jack-devel ladspa-sdk
+makedepends="alsa-lib-devel ffmpeg4-devel gtk+-devel jack-devel ladspa-sdk
  libexif-devel libsamplerate-devel libxml2-devel sox-devel SDL_image-devel
  fftw-devel frei0r-plugins python3-devel pulseaudio-devel movit-devel
  libvidstab-devel libatomic-devel"

From b726394dfcdedccdccca753c1d4c9e40a47474f5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 058/116] moc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/moc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/moc/template b/srcpkgs/moc/template
index c42be650a1d2..d4f0eefbad52 100644
--- a/srcpkgs/moc/template
+++ b/srcpkgs/moc/template
@@ -1,10 +1,10 @@
 # Template file for 'moc'
 pkgname=moc
 version=2.5.2
-revision=6
+revision=7
 build_style=gnu-configure
 hostmakedepends="pkg-config"
-makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg-devel
+makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg4-devel
  jack-devel alsa-lib-devel libltdl-devel libflac-devel libvorbis-devel
  libmad-devel libmpcdec-devel libmodplug-devel libid3tag-devel faad2-devel
  taglib-devel libsndfile-devel wavpack-devel speex-devel libsamplerate-devel

From b7f0423c6ca0ff3805210e080172bfd44c5960f1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 059/116] motion: revbump for ffmpeg-6.0

---
 srcpkgs/motion/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/motion/template b/srcpkgs/motion/template
index 3cf3c3035c5b..7dca12d851e3 100644
--- a/srcpkgs/motion/template
+++ b/srcpkgs/motion/template
@@ -1,7 +1,7 @@
 # Template file for 'motion'
 pkgname=motion
 version=4.5.1
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake pkg-config gettext-devel tar"
 makedepends="ffmpeg-devel libmicrohttpd-devel v4l-utils-devel gettext-devel"

From c1afd8c2749abba28cc9cb35f753c63e0971706a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 060/116] mpv: revbump for ffmpeg-6.0

---
 srcpkgs/mpv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpv/template b/srcpkgs/mpv/template
index e163c496c6eb..d4fefbf5e3c7 100644
--- a/srcpkgs/mpv/template
+++ b/srcpkgs/mpv/template
@@ -1,7 +1,7 @@
 # Template file for 'mpv'
 pkgname=mpv
 version=0.35.1
-revision=2
+revision=3
 build_style=meson
 configure_args="-Dcdda=enabled -Ddvbin=enabled -Ddvdnav=enabled
  -Dlibmpv=true -Dcplugins=enabled

From edada4618ef0ba751d5d99e184e031b808452764 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 061/116] musikcube: revbump for ffmpeg-6.0

---
 srcpkgs/musikcube/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/musikcube/template b/srcpkgs/musikcube/template
index 7c569303c054..a4dea460c371 100644
--- a/srcpkgs/musikcube/template
+++ b/srcpkgs/musikcube/template
@@ -1,7 +1,7 @@
 # Template file for 'musikcube'
 pkgname=musikcube
 version=3.0.0
-revision=1
+revision=2
 build_style=cmake
 make_cmd=make
 configure_args="-DNO_NCURSESW=1"

From 3a1950a9269bc0fa2e4f857310083938113d893e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 062/116] notcurses: revbump for ffmpeg-6.0

---
 srcpkgs/notcurses/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/notcurses/template b/srcpkgs/notcurses/template
index 6dd8a091319f..3110c30c9aff 100644
--- a/srcpkgs/notcurses/template
+++ b/srcpkgs/notcurses/template
@@ -1,7 +1,7 @@
 # Template file for 'notcurses'
 pkgname=notcurses
 version=3.0.9
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DUSE_STATIC=ON $(vopt_bool man USE_PANDOC)"
 hostmakedepends="pkg-config $(vopt_if man pandoc)"

From 482e9501cefe908206f4df05928e1067cc9b5421 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 063/116] obs: revbump for ffmpeg-6.0

---
 srcpkgs/obs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/obs/template b/srcpkgs/obs/template
index 7b69c630d30d..2c8d68d71f3a 100644
--- a/srcpkgs/obs/template
+++ b/srcpkgs/obs/template
@@ -1,7 +1,7 @@
 # Template file for 'obs'
 pkgname=obs
 version=29.1.2
-revision=1
+revision=2
 archs="i686* x86_64* ppc64le* aarch64*"
 build_style=cmake
 configure_args="-DOBS_VERSION_OVERRIDE=${version} -DENABLE_JACK=ON

From e931084f4252e3c8cf85a6c3a212a18773da8346 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 064/116] olive: revbump for ffmpeg4-4.4.3

---
 srcpkgs/olive/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/olive/template b/srcpkgs/olive/template
index 12a46936c990..5c2917b9c512 100644
--- a/srcpkgs/olive/template
+++ b/srcpkgs/olive/template
@@ -1,10 +1,10 @@
 # Template file for 'olive'
 pkgname=olive
 version=0.1.2
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools pkg-config"
-makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg-devel frei0r-plugins"
+makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg4-devel frei0r-plugins"
 short_desc="Non-linear video editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"

From a1c6158b70ccdcbf8f456240acb119d179474cc8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 065/116] omxplayer: revbump for ffmpeg4-4.4.3

---
 srcpkgs/omxplayer/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/omxplayer/template b/srcpkgs/omxplayer/template
index e70bf7873d4d..0e9bc70e7c8e 100644
--- a/srcpkgs/omxplayer/template
+++ b/srcpkgs/omxplayer/template
@@ -1,10 +1,10 @@
 # Template file for 'omxplayer'
 pkgname=omxplayer
 version=20190102
-revision=1
+revision=2
 short_desc="Commandline OMX player for the Raspberry Pi"
 maintainer="Orphaned <orphan@voidlinux.org>"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://github.com/popcornmix/omxplayer"
 
 _commit="f06235cc9690a6d58187514452df8cf8fcdaacec"
@@ -15,7 +15,7 @@ checksum=af2d9450f8947842ea8c401fe9f71eec444013ebbdee29f2ac828c9c493c1329
 archs="armv6l* armv7l*"
 build_style=gnu-makefile
 hostmakedepends="curl pkg-config"
-makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg-devel dbus-devel"
+makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg4-devel dbus-devel"
 depends="freefont-ttf"
 
 do_build() {

From 872143be180885526692e8bd9e94b9549173ee9f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 066/116] openimageio: revbump for ffmpeg-6.0

---
 common/shlibs                | 2 ++
 srcpkgs/openimageio/template | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/shlibs b/common/shlibs
index 2ee342f2a204..a53eb9fdd7e6 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2259,6 +2259,8 @@ libxmp.so.4 libxmp-4.3.7_1
 libKF5ThreadWeaver.so.5 threadweaver-5.26.0_1
 libOpenImageIO_Util.so.2.4 openimageio-2.4.9.0_1
 libOpenImageIO.so.2.4 openimageio-2.4.9.0_1
+libOpenImageIO_Util.so.2.4 openimageio-2.4.8.1_1
+libOpenImageIO.so.2.4 openimageio-2.4.8.1_1
 libOpenColorIO.so.2.1 opencolorio-2.1.2_1
 libpystring.so.1 pystring-1.1.3_1
 libyaml-cpp.so.0.7 yaml-cpp-0.7.0_1
diff --git a/srcpkgs/openimageio/template b/srcpkgs/openimageio/template
index c2d36b4b3539..0e9e22e9685d 100644
--- a/srcpkgs/openimageio/template
+++ b/srcpkgs/openimageio/template
@@ -1,7 +1,7 @@
 # Template file for 'openimageio'
 pkgname=openimageio
 version=2.4.9.0
-revision=4
+revision=5
 build_style=cmake
 build_helper=qemu
 configure_args="-DUSE_QT=0 -DUSE_PYTHON=0 -DOIIO_BUILD_TESTS=0

From d4559d9a687ef1396902b0501757336d706c6d17 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 067/116] openshot: revbump for ffmpeg-6.0

---
 srcpkgs/openshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openshot/template b/srcpkgs/openshot/template
index 322717d40abc..c074e0338773 100644
--- a/srcpkgs/openshot/template
+++ b/srcpkgs/openshot/template
@@ -1,7 +1,7 @@
 # Template file for 'openshot'
 pkgname=openshot
 version=3.0.0
-revision=1
+revision=2
 build_style=python3-module
 hostmakedepends="python3 python3-setuptools"
 makedepends="ffmpeg-devel python3-PyQt5"

From e58e757a97f1a1c438bfd600ad8e08e1c76e040b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 068/116] opentoonz: revbump for ffmpeg-6.0

---
 srcpkgs/opentoonz/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/opentoonz/template b/srcpkgs/opentoonz/template
index ee9f7603f55f..3e81834ca0ed 100644
--- a/srcpkgs/opentoonz/template
+++ b/srcpkgs/opentoonz/template
@@ -1,7 +1,7 @@
 # Template file for 'opentoonz'
 pkgname=opentoonz
 version=1.6.0
-revision=2
+revision=3
 build_wrksrc="toonz/sources"
 build_style=cmake
 make_cmd=make

From 570fcb92ec8505b677d9aeafec1c22fdcadf7f72 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 069/116] pianobar: revbump for ffmpeg-6.0

---
 srcpkgs/pianobar/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pianobar/template b/srcpkgs/pianobar/template
index a9b29e91993f..81efcd122c4d 100644
--- a/srcpkgs/pianobar/template
+++ b/srcpkgs/pianobar/template
@@ -1,7 +1,7 @@
 # Template file for 'pianobar'
 pkgname=pianobar
 version=2022.04.01
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="V=1"
 hostmakedepends="pkg-config"

From a1b2c917acefd5903d2ead7cbaaefc16c0334699 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 070/116] ppsspp: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ppsspp/template | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/ppsspp/template b/srcpkgs/ppsspp/template
index 7984a733d4be..15a42fd2c993 100644
--- a/srcpkgs/ppsspp/template
+++ b/srcpkgs/ppsspp/template
@@ -1,7 +1,7 @@
 # Template file for 'ppsspp'
 pkgname=ppsspp
 version=1.14.4
-revision=1
+revision=2
 _glslang_commit=dc11adde23c455a24e13dd54de9b4ede8bdd7db8
 _SPIRV_Cross_commit=9acb9ec31f5a8ef80ea6b994bb77be787b08d3d1
 _armips_commit=6719edebaae03330ee5441d9b28280672edf00d5
@@ -13,7 +13,7 @@ configure_args="-DHEADLESS=1 -DUSE_SYSTEM_FFMPEG=1 -DUNITTEST=ON
  -DUSING_QT_UI=$(vopt_if qt ON OFF) -DUSE_SYSTEM_ZSTD=ON
  -DARMIPS_USE_STD_FILESYSTEM=ON"
 hostmakedepends="pkg-config python3 $(vopt_if qt qt5-host-tools)"
-makedepends="zlib-devel glew-devel ffmpeg-devel libzip-devel
+makedepends="zlib-devel glew-devel ffmpeg4-devel libzip-devel
  snappy-devel rapidjson libpng-devel libzstd-devel
  $(vopt_if sdl2 SDL2-devel) $(vopt_if wayland wayland-devel)
  $(vopt_if qt 'qt5-devel qt5-multimedia-devel')"
@@ -62,13 +62,12 @@ post_extract() {
 	mv ${wrksrc}/miniupnp-${_miniupnp_commit} ${wrksrc}/ext/miniupnp
 }
 
-post_patch(){
+post_patch() {
 	# disable git versioning
 	vsed -e 's|find_package(Git)|# &|' -i git-version.cmake
 }
 
 do_install() {
-	vlicense LICENSE.TXT
 	vinstall icons/icon.svg 644 usr/share/pixmaps ppsspp.svg
 	vinstall Qt/PPSSPP.desktop 644 usr/share/applications
 	vbin build/PPSSPPHeadless ppsspp-headless

From c5406196407ba10aeaefa889e1fe664335fb523f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 071/116] pqiv: revbump for ffmpeg-6.0

---
 srcpkgs/pqiv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pqiv/template b/srcpkgs/pqiv/template
index 542fc27a2d32..9308d949b6a1 100644
--- a/srcpkgs/pqiv/template
+++ b/srcpkgs/pqiv/template
@@ -1,7 +1,7 @@
 # Template file for 'pqiv'
 pkgname=pqiv
 version=2.12
-revision=1
+revision=2
 build_style=gnu-makefile
 hostmakedepends="pkg-config"
 makedepends="glib-devel gtk+3-devel $(vopt_if ffmpeg ffmpeg-devel)

From 612bef2be713fb301b2dec3300e50ad09e0cc1e5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 072/116] qmmp: revbump for ffmpeg-6.0

---
 srcpkgs/qmmp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qmmp/template b/srcpkgs/qmmp/template
index 26c661ed16be..a150d7441c7a 100644
--- a/srcpkgs/qmmp/template
+++ b/srcpkgs/qmmp/template
@@ -1,7 +1,7 @@
 # Template file for 'qmmp'
 pkgname=qmmp
 version=1.6.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DUSE_HAL:BOOL=FALSE -DQMMP_DEFAULT_UI:STRING=simple"
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From f83dc9ac66f33d7561889396539611bf5bd40489 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 073/116] qt5-webengine: update to 5.15.13

---
 .../chromium-media-filters-cpp14.patch        |  11 ++
 srcpkgs/qt5-webengine/patches/ffmpeg5.patch   | 179 ++++++++++++++++++
 srcpkgs/qt5-webengine/template                |  10 +-
 3 files changed, 195 insertions(+), 5 deletions(-)
 create mode 100644 srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/ffmpeg5.patch

diff --git a/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
new file mode 100644
index 000000000000..04adc540f2cb
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
@@ -0,0 +1,11 @@
+--- a/src/3rdparty/chromium/media/filters/BUILD.gn	2023-02-27 13:32:59.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/BUILD.gn	2023-04-02 17:21:39.204066384 -0400
+@@ -96,6 +96,8 @@
+     "//ui/gfx/geometry:geometry",
+   ]
+ 
++  cflags_cc = [ "-std=c++14" ]
++
+   libs = []
+ 
+   if (proprietary_codecs) {
diff --git a/srcpkgs/qt5-webengine/patches/ffmpeg5.patch b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..ac55e1634423
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
@@ -0,0 +1,179 @@
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:57.732547446 -0400
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:09.486478995 -0400
+@@ -57,6 +57,8 @@
+ 
+ namespace {
+ 
++constexpr int64_t kRelativeTsBase = static_cast<int64_t>(0x7ffeffffffffffff);
++
+ void SetAVStreamDiscard(AVStream* stream, AVDiscard discard) {
+   DCHECK(stream);
+   stream->discard = discard;
+@@ -90,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+   if (stream->start_time != kNoFFmpegTimestamp)
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (stream->first_dts != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, stream->first_dts);
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -408,11 +398,11 @@
+   scoped_refptr<DecoderBuffer> buffer;
+ 
+   if (type() == DemuxerStream::TEXT) {
+-    int id_size = 0;
++    size_t id_size = 0;
+     uint8_t* id_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
+ 
+-    int settings_size = 0;
++    size_t settings_size = 0;
+     uint8_t* settings_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
+ 
+@@ -424,7 +414,7 @@
+     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
+                                      side_data.data(), side_data.size());
+   } else {
+-    int side_data_size = 0;
++    size_t side_data_size = 0;
+     uint8_t* side_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
+ 
+@@ -485,7 +475,7 @@
+                                        packet->size - data_offset);
+     }
+ 
+-    int skip_samples_size = 0;
++    size_t skip_samples_size = 0;
+     const uint32_t* skip_samples_ptr =
+         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
+             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
+@@ -1587,6 +1577,8 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++      continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+       lowest_start_time_stream = stream.get();
+@@ -1604,6 +1596,8 @@
+     if (stream && stream->type() == DemuxerStream::VIDEO &&
+         stream->IsEnabled()) {
+       video_stream = stream.get();
++      if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++        continue;
+       if (video_stream->start_time() <= seek_time) {
+         return video_stream;
+       }
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h qtwebengine-5.15.10/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h
+--- a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-07-11 22:12:47.917192788 -0500
+@@ -29,6 +29,7 @@ extern "C" {
+ #include <libavformat/avformat.h>
+ #include <libavformat/avio.h>
+ #include <libavutil/avutil.h>
++#include <libavutil/channel_layout.h>
+ #include <libavutil/imgutils.h>
+ #include <libavutil/log.h>
+ #include <libavutil/mastering_display_metadata.h>
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/audio_file_reader.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/audio_file_reader.cc
+--- a/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -85,7 +85,7 @@ bool AudioFileReader::OpenDemuxer() {
+ }
+ 
+ bool AudioFileReader::OpenDecoder() {
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (codec) {
+     // MP3 decodes to S16P which we don't support, tell it to use S16 instead.
+     if (codec_context_->sample_fmt == AV_SAMPLE_FMT_S16P)
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -329,7 +329,7 @@ bool FFmpegAudioDecoder::ConfigureDecode
+     }
+   }
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec ||
+       avcodec_open2(codec_context_.get(), codec, &codec_options) < 0) {
+     DLOG(ERROR) << "Could not initialize audio decoder: "
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -59,7 +59,6 @@ static int64_t AVIOSeekOperation(void* o
+ }
+ 
+ void FFmpegGlue::InitializeFFmpeg() {
+-  av_register_all();
+ }
+ 
+ static void LogContainer(bool is_local_file,
+@@ -95,9 +94,6 @@ FFmpegGlue::FFmpegGlue(FFmpegURLProtocol
+   // Enable fast, but inaccurate seeks for MP3.
+   format_context_->flags |= AVFMT_FLAG_FAST_SEEK;
+ 
+-  // Ensures we can read out various metadata bits like vp8 alpha.
+-  format_context_->flags |= AVFMT_FLAG_KEEP_SIDE_DATA;
+-
+   // Ensures format parsing errors will bail out. From an audit on 11/2017, all
+   // instances were real failures. Solves bugs like http://crbug.com/710791.
+   format_context_->error_recognition |= AV_EF_EXPLODE;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -391,7 +391,7 @@ bool FFmpegVideoDecoder::ConfigureDecode
+   if (decode_nalus_)
+     codec_context_->flags2 |= AV_CODEC_FLAG2_CHUNKS;
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
+     ReleaseFFmpegResources();
+     return false;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/media_file_checker.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/media_file_checker.cc
+--- a/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -68,7 +68,7 @@ bool MediaFileChecker::Start(base::TimeD
+       auto context = AVStreamToAVCodecContext(format_context->streams[i]);
+       if (!context)
+         continue;
+-      AVCodec* codec = avcodec_find_decoder(cp->codec_id);
++      const AVCodec* codec = avcodec_find_decoder(cp->codec_id);
+       if (codec && avcodec_open2(context.get(), codec, nullptr) >= 0) {
+         auto loop = std::make_unique<FFmpegDecodingLoop>(context.get());
+         stream_contexts[i] = {std::move(context), std::move(loop)};
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc qtwebengine-5.15.10/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc
+--- a/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -203,7 +203,7 @@ int32_t H264DecoderImpl::InitDecode(cons
+   // a pointer |this|.
+   av_context_->opaque = this;
+ 
+-  AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
+   if (!codec) {
+     // This is an indication that FFmpeg has not been initialized or it has not
+     // been compiled/initialized with the correct set of codecs.
diff --git a/srcpkgs/qt5-webengine/template b/srcpkgs/qt5-webengine/template
index 85267c7cf8a3..095ab67701e4 100644
--- a/srcpkgs/qt5-webengine/template
+++ b/srcpkgs/qt5-webengine/template
@@ -1,9 +1,9 @@
 # Template file for 'qt5-webengine'
 pkgname=qt5-webengine
-version=5.15.11
-revision=3
+version=5.15.13
+revision=1
 _version="${version}-lts"
-_chromium_commit=be349eaf62e77955791d7bf29f893f1e8a37daf4
+_chromium_commit=e48df7803c7c98b0b2471c94057d32e44a301ad5
 archs="x86_64* i686* armv[67]* ppc64* aarch64*"
 create_wrksrc=yes
 build_style=qmake
@@ -32,8 +32,8 @@ license="GPL-3.0-or-later, LGPL-3.0-or-later"
 homepage="https://qt.io/"
 distfiles="https://github.com/qt/qtwebengine/archive/v${_version}.tar.gz
  https://github.com/qt/qtwebengine-chromium/archive/${_chromium_commit}.tar.gz"
-checksum="aa7466356c450c5f5870f979b93cd7e7e62da1165c328ffcab1a9928db18ad67
- 6f47ed8ab8cc062411f6f206da6353bc8263d6ed6d6290c689a05c01d91f646b"
+checksum="4b59838ed75ef788b59e1e412535a0e42dd9d311661fdeadb191b581ba815c63
+ a91686562b1d4e8b220e0bbcbab5feb64630e2de974b35ac034bf388af771a6c"
 
 no_generic_pkgconfig_link=yes
 build_options="sndio pipewire"

From 66b1ba076a9418bacf03ff5a767c297ca2f04dad Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 074/116] qt5: update to 5.15.8

---
 ...erywhere-opensource-src-5.15.8-kf5-1.patch | 12913 ++++++++++++++++
 srcpkgs/qt5/template                          |    12 +-
 2 files changed, 12919 insertions(+), 6 deletions(-)
 create mode 100644 srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch

diff --git a/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch b/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch
new file mode 100644
index 000000000000..966c98bcd3bb
--- /dev/null
+++ b/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch
@@ -0,0 +1,12913 @@
+Submitted By:            Pierre Labastie <pierre_dot_labastie_at_neuf_dot_fr>
+Date:                    2023-01-05
+Initial Package Version: 5.15.8
+Upstream Status:         Applied (according to KDE)
+Origin:                  KDE patch set
+Description:             Patch set maintained by the KDE folks
+see https://dot.kde.org/2021/04/06/announcing-kdes-qt-5-patch-collection
+Patch generated using the procedure in
+https://wiki.linuxfromscratch.org/blfs/ticket/17476#comment:3
+
+Submodule qtbase 4ee4fc18..9cf586d6:
+diff --git a/qtbase/mkspecs/common/android/qplatformdefs.h b/qtbase/mkspecs/common/android/qplatformdefs.h
+index f75bc4093b..2bd59410d4 100644
+--- a/qtbase/mkspecs/common/android/qplatformdefs.h
++++ b/qtbase/mkspecs/common/android/qplatformdefs.h
+@@ -144,11 +144,7 @@
+ #define QT_SIGNAL_ARGS          int
+ #define QT_SIGNAL_IGNORE        SIG_IGN
+ 
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+ #define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+ 
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+diff --git a/qtbase/mkspecs/features/mac/sdk.mk b/qtbase/mkspecs/features/mac/sdk.mk
+index f30b5830b4..a32ceacb6c 100644
+--- a/qtbase/mkspecs/features/mac/sdk.mk
++++ b/qtbase/mkspecs/features/mac/sdk.mk
+@@ -1,6 +1,6 @@
+ 
+ ifeq ($(QT_MAC_SDK_NO_VERSION_CHECK),)
+-    CHECK_SDK_COMMAND = /usr/bin/xcrun --sdk $(EXPORT_QMAKE_MAC_SDK) -show-sdk-version 2>&1
++    CHECK_SDK_COMMAND = /usr/bin/xcrun --sdk $(EXPORT_QMAKE_MAC_SDK) -show-sdk-version 2>/dev/null
+     CURRENT_MAC_SDK_VERSION := $(shell DEVELOPER_DIR=$(EXPORT_QMAKE_XCODE_DEVELOPER_PATH) $(CHECK_SDK_COMMAND))
+     ifneq ($(CURRENT_MAC_SDK_VERSION),$(EXPORT_QMAKE_MAC_SDK_VERSION))
+         # We don't want to complain about out of date SDK unless the target needs to be remade.
+diff --git a/qtbase/mkspecs/linux-clang/qplatformdefs.h b/qtbase/mkspecs/linux-clang/qplatformdefs.h
+index a818d973f0..c1ab72fbc6 100644
+--- a/qtbase/mkspecs/linux-clang/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-clang/qplatformdefs.h
+@@ -79,14 +79,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-g++/qplatformdefs.h b/qtbase/mkspecs/linux-g++/qplatformdefs.h
+index 13523f0702..4d2750d9ec 100644
+--- a/qtbase/mkspecs/linux-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-g++/qplatformdefs.h
+@@ -79,14 +79,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ < 2)
+-#define QT_SOCKLEN_T            int
+-#else
+-#define QT_SOCKLEN_T            socklen_t
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-llvm/qplatformdefs.h b/qtbase/mkspecs/linux-llvm/qplatformdefs.h
+index dc750ab1ef..d3cc39b47f 100644
+--- a/qtbase/mkspecs/linux-llvm/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-llvm/qplatformdefs.h
+@@ -80,14 +80,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h b/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
+index 4c4e53da2a..83baffb3e3 100644
+--- a/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
+@@ -85,16 +85,9 @@
+ #include "../common/posix/qplatformdefs.h"
+ 
+ #undef QT_OPEN_LARGEFILE
+-#undef QT_SOCKLEN_T
+ 
+ #define QT_OPEN_LARGEFILE       0
+ 
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #ifndef SIOCGIFBRDADDR
+ #  define SIOCGIFBRDADDR 0x8919
+ #endif
+diff --git a/qtbase/mkspecs/lynxos-g++/qplatformdefs.h b/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
+index 4339ea2b23..6007af0055 100644
+--- a/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
+@@ -72,14 +72,6 @@
+ 
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp b/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
+index c3c184258f..32af3f8f29 100644
+--- a/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
++++ b/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
+@@ -10,6 +10,7 @@
+ #include "libANGLE/HandleAllocator.h"
+ 
+ #include <algorithm>
++#include <limits>
+ 
+ #include "common/debug.h"
+ 
+diff --git a/qtbase/src/3rdparty/forkfd/forkfd_linux.c b/qtbase/src/3rdparty/forkfd/forkfd_linux.c
+index ffe0e9a5e2..b1f5408d11 100644
+--- a/qtbase/src/3rdparty/forkfd/forkfd_linux.c
++++ b/qtbase/src/3rdparty/forkfd/forkfd_linux.c
+@@ -82,7 +82,8 @@ static int sys_clone(unsigned long cloneflags, int *ptid)
+     return syscall(__NR_clone, cloneflags, child_stack, stack_size, ptid, newtls, ctid);
+ #elif defined(__arc__) || defined(__arm__) || defined(__aarch64__) || defined(__mips__) || \
+     defined(__nds32__) || defined(__hppa__) || defined(__powerpc__) || defined(__i386__) || \
+-    defined(__x86_64__) || defined(__xtensa__) || defined(__alpha__) || defined(__riscv)
++    defined(__x86_64__) || defined(__xtensa__) || defined(__alpha__) || defined(__riscv) || \
++    defined(__loongarch__)
+     /* ctid and newtls are inverted on CONFIG_CLONE_BACKWARDS architectures,
+      * but since both values are 0, there's no harm. */
+     return syscall(__NR_clone, cloneflags, child_stack, ptid, ctid, newtls);
+diff --git a/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java b/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
+index 5792b5b2f5..2f74750fcf 100644
+--- a/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
++++ b/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
+@@ -116,6 +116,7 @@ public class QtNative
+     public static QtThread m_qtThread = new QtThread();
+     private static HashMap<String, Uri> m_cachedUris = new HashMap<String, Uri>();
+     private static ArrayList<String> m_knownDirs = new ArrayList<String>();
++    private static final String NoPermissionErrorMessage = "No permissions to open Uri";
+ 
+     private static final Runnable runPendingCppRunnablesRunnable = new Runnable() {
+         @Override
+@@ -193,11 +194,10 @@ public class QtNative
+                     return iterUri;
+             }
+ 
+-            // Android 6 and earlier could still manage to open the file so we can return the
+-            // parsed uri here
+-            if (Build.VERSION.SDK_INT < 24)
+-                return parsedUri;
+-            return null;
++            // if we only have transient permissions on uri all the above will fail,
++            // but we will be able to read the file anyway, so continue with uri here anyway
++            // and check for SecurityExceptions later
++            return parsedUri;
+         } catch (SecurityException e) {
+             e.printStackTrace();
+             return null;
+@@ -244,7 +244,7 @@ public class QtNative
+         int error = -1;
+ 
+         if (uri == null) {
+-            Log.e(QtTAG, "openFdForContentUrl(): No permissions to open Uri");
++            Log.e(QtTAG, "openFdForContentUrl(): " + NoPermissionErrorMessage);
+             return error;
+         }
+ 
+@@ -254,12 +254,13 @@ public class QtNative
+             return fdDesc.detachFd();
+         } catch (FileNotFoundException e) {
+             e.printStackTrace();
+-            return error;
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "openFdForContentUrl(): Invalid Uri");
+             e.printStackTrace();
+-            return error;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return error;
+     }
+ 
+     public static long getSize(Context context, String contentUrl)
+@@ -270,7 +271,7 @@ public class QtNative
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+ 
+         if (uri == null) {
+-            Log.e(QtTAG, "getSize(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return size;
+         } else if (!m_cachedUris.containsKey(contentUrl)) {
+             m_cachedUris.put(contentUrl, uri);
+@@ -288,12 +289,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "getSize(): Invalid Uri");
+             e.printStackTrace();
+-            return size;
+         }  catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "getSize(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return size;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return size;
+     }
+ 
+     public static boolean checkFileExists(Context context, String contentUrl)
+@@ -303,7 +305,7 @@ public class QtNative
+         if (uri == null)
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+         if (uri == null) {
+-            Log.e(QtTAG, "checkFileExists(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return exists;
+         } else {
+             if (!m_cachedUris.containsKey(contentUrl))
+@@ -321,12 +323,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "checkFileExists(): Invalid Uri");
+             e.printStackTrace();
+-            return exists;
+         } catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "checkFileExists(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return false;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return exists;
+     }
+ 
+     public static boolean checkIfWritable(Context context, String contentUrl)
+@@ -344,7 +347,7 @@ public class QtNative
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+         }
+         if (uri == null) {
+-            Log.e(QtTAG, "isDir(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return isDir;
+         } else {
+             if (!m_cachedUris.containsKey(contentUrl))
+@@ -374,12 +377,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "checkIfDir(): Invalid Uri");
+             e.printStackTrace();
+-            return false;
+         } catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "checkIfDir(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return false;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return false;
+     }
+     public static String[] listContentsFromTreeUri(Context context, String contentUrl)
+     {
+diff --git a/qtbase/src/concurrent/qtconcurrentreducekernel.h b/qtbase/src/concurrent/qtconcurrentreducekernel.h
+index 8f9a938952..a98dedef2e 100644
+--- a/qtbase/src/concurrent/qtconcurrentreducekernel.h
++++ b/qtbase/src/concurrent/qtconcurrentreducekernel.h
+@@ -212,11 +212,13 @@ public:
+ 
+     inline bool shouldThrottle()
+     {
++        std::lock_guard<QMutex> locker(mutex);
+         return (resultsMapSize > (ReduceQueueThrottleLimit * threadCount));
+     }
+ 
+     inline bool shouldStartThread()
+     {
++        std::lock_guard<QMutex> locker(mutex);
+         return (resultsMapSize <= (ReduceQueueStartLimit * threadCount));
+     }
+ };
+diff --git a/qtbase/src/concurrent/qtconcurrentthreadengine.cpp b/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
+index ea6ce3ac42..7f91a2ba68 100644
+--- a/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
++++ b/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
+@@ -176,6 +176,39 @@ void ThreadEngineBase::startSingleThreaded()
+     finish();
+ }
+ 
++void ThreadEngineBase::startBlocking()
++{
++    start();
++    barrier.acquire();
++    startThreads();
++
++    bool throttled = false;
++#ifndef QT_NO_EXCEPTIONS
++    try {
++#endif
++        while (threadFunction() == ThrottleThread) {
++            if (threadThrottleExit()) {
++                throttled = true;
++                break;
++            }
++        }
++#ifndef QT_NO_EXCEPTIONS
++    } catch (QException &e) {
++        handleException(e);
++    } catch (...) {
++        handleException(QUnhandledException());
++    }
++#endif
++
++    if (throttled == false) {
++        barrier.release();
++    }
++
++    barrier.wait();
++    finish();
++    exceptionStore.throwPossibleException();
++}
++
+ void ThreadEngineBase::startThread()
+ {
+     startThreadInternal();
+diff --git a/qtbase/src/concurrent/qtconcurrentthreadengine.h b/qtbase/src/concurrent/qtconcurrentthreadengine.h
+index 7c30cebdbc..a4c8548cc4 100644
+--- a/qtbase/src/concurrent/qtconcurrentthreadengine.h
++++ b/qtbase/src/concurrent/qtconcurrentthreadengine.h
+@@ -91,6 +91,7 @@ public:
+     ThreadEngineBase();
+     virtual ~ThreadEngineBase();
+     void startSingleThreaded();
++    void startBlocking();
+     void startThread();
+     bool isCanceled();
+     void waitForResume();
+@@ -143,6 +144,15 @@ public:
+         return result();
+     }
+ 
++    // Runs the user algorithm using multiple threads.
++    // This function blocks until the algorithm is finished,
++    // and then returns the result.
++    T *startBlocking()
++    {
++        ThreadEngineBase::startBlocking();
++        return result();
++    }
++
+     // Runs the user algorithm using multiple threads.
+     // Does not block, returns a future.
+     QFuture<T> startAsynchronously()
+@@ -223,6 +233,13 @@ class ThreadEngineStarter : public ThreadEngineStarterBase<T>
+ public:
+     ThreadEngineStarter(TypedThreadEngine *eng)
+         : Base(eng) { }
++
++    T startBlocking()
++    {
++        T t = *this->threadEngine->startBlocking();
++        delete this->threadEngine;
++        return t;
++    }
+ };
+ 
+ // Full template specialization where T is void.
+@@ -232,6 +249,12 @@ class ThreadEngineStarter<void> : public ThreadEngineStarterBase<void>
+ public:
+     ThreadEngineStarter(ThreadEngine<void> *_threadEngine)
+         : ThreadEngineStarterBase<void>(_threadEngine) {}
++
++    void startBlocking()
++    {
++        this->threadEngine->startBlocking();
++        delete this->threadEngine;
++    }
+ };
+ 
+ //! [qtconcurrentthreadengine-1]
+diff --git a/qtbase/src/corelib/animation/qvariantanimation.cpp b/qtbase/src/corelib/animation/qvariantanimation.cpp
+index 98b02f0202..eac1524107 100644
+--- a/qtbase/src/corelib/animation/qvariantanimation.cpp
++++ b/qtbase/src/corelib/animation/qvariantanimation.cpp
+@@ -276,7 +276,9 @@ void QVariantAnimationPrivate::setCurrentValueForProgress(const qreal progress)
+ 
+     const qreal startProgress = currentInterval.start.first;
+     const qreal endProgress = currentInterval.end.first;
+-    const qreal localProgress = (progress - startProgress) / (endProgress - startProgress);
++    const qreal localProgress =
++            qIsNull(progress - startProgress) ? 0.0 // avoid 0/0 below
++            /* else */                        : (progress - startProgress) / (endProgress - startProgress);
+ 
+     QVariant ret = q->interpolated(currentInterval.start.second,
+                                    currentInterval.end.second,
+diff --git a/qtbase/src/corelib/global/qnamespace.h b/qtbase/src/corelib/global/qnamespace.h
+index ad4150b317..bf19b1627b 100644
+--- a/qtbase/src/corelib/global/qnamespace.h
++++ b/qtbase/src/corelib/global/qnamespace.h
+@@ -1864,7 +1864,7 @@ public:
+     QT_Q_ENUM(TimerType)
+     QT_Q_ENUM(ScrollPhase)
+     QT_Q_ENUM(MouseEventSource)
+-    QT_Q_FLAG(MouseEventFlag)
++    QT_Q_FLAG(MouseEventFlags)
+     QT_Q_ENUM(ChecksumType)
+     QT_Q_ENUM(HighDpiScaleFactorRoundingPolicy)
+     QT_Q_ENUM(TabFocusBehavior)
+diff --git a/qtbase/src/corelib/global/qrandom.cpp b/qtbase/src/corelib/global/qrandom.cpp
+index 10672c1f92..25f87c7e6a 100644
+--- a/qtbase/src/corelib/global/qrandom.cpp
++++ b/qtbase/src/corelib/global/qrandom.cpp
+@@ -383,7 +383,6 @@ struct QRandomGenerator::SystemAndGlobalGenerators
+ 
+         constexpr SystemAndGlobalGenerators g = {};
+         Q_UNUSED(g);
+-        Q_STATIC_ASSERT(std::is_literal_type<SystemAndGlobalGenerators>::value);
+ #endif
+     }
+ 
+diff --git a/qtbase/src/corelib/io/qbuffer.cpp b/qtbase/src/corelib/io/qbuffer.cpp
+index 595fcd2724..032c0ddd4b 100644
+--- a/qtbase/src/corelib/io/qbuffer.cpp
++++ b/qtbase/src/corelib/io/qbuffer.cpp
+@@ -41,6 +41,8 @@
+ #include <QtCore/qmetaobject.h>
+ #include "private/qiodevice_p.h"
+ 
++#include <limits>
++
+ QT_BEGIN_NAMESPACE
+ 
+ /** QBufferPrivate **/
+@@ -366,7 +368,9 @@ qint64 QBuffer::size() const
+ bool QBuffer::seek(qint64 pos)
+ {
+     Q_D(QBuffer);
+-    if (pos > d->buf->size() && isWritable()) {
++    const auto oldBufSize = d->buf->size();
++    constexpr qint64 MaxSeekPos = (std::numeric_limits<decltype(oldBufSize)>::max)();
++    if (pos <= MaxSeekPos && pos > oldBufSize && isWritable()) {
+         if (seek(d->buf->size())) {
+             const qint64 gapSize = pos - d->buf->size();
+             if (write(QByteArray(gapSize, 0)) != gapSize) {
+@@ -377,7 +381,7 @@ bool QBuffer::seek(qint64 pos)
+             return false;
+         }
+     } else if (pos > d->buf->size() || pos < 0) {
+-        qWarning("QBuffer::seek: Invalid pos: %d", int(pos));
++        qWarning("QBuffer::seek: Invalid pos: %lld", pos);
+         return false;
+     }
+     return QIODevice::seek(pos);
+diff --git a/qtbase/src/corelib/io/qfilesystemengine_win.cpp b/qtbase/src/corelib/io/qfilesystemengine_win.cpp
+index 81d3a71986..c86ed1f9b0 100644
+--- a/qtbase/src/corelib/io/qfilesystemengine_win.cpp
++++ b/qtbase/src/corelib/io/qfilesystemengine_win.cpp
+@@ -664,14 +664,14 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry)
+     return QFileSystemEntry(ret, QFileSystemEntry::FromInternalPath());
+ }
+ 
+-#if defined(Q_CC_MINGW) && WINVER < 0x0602 //  Windows 8 onwards
++#if defined(Q_CC_MINGW) && WINVER < 0x0602 && _WIN32_WINNT < _WIN32_WINNT_WIN8 //  Windows 8 onwards
+ 
+ typedef struct _FILE_ID_INFO {
+     ULONGLONG VolumeSerialNumber;
+     FILE_ID_128 FileId;
+ } FILE_ID_INFO, *PFILE_ID_INFO;
+ 
+-#endif // if defined (Q_CC_MINGW) && WINVER < 0x0602
++#endif // if defined(Q_CC_MINGW) && WINVER < 0x0602 && _WIN32_WINNT < _WIN32_WINNT_WIN8
+ 
+ // File ID for Windows up to version 7 and FAT32 drives
+ static inline QByteArray fileId(HANDLE handle)
+diff --git a/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp b/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
+index 94d9d06bcb..27e0b13b0b 100644
+--- a/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
++++ b/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
+@@ -366,7 +366,9 @@ void QInotifyFileSystemWatcherEngine::readFromInotify()
+     // qDebug("QInotifyFileSystemWatcherEngine::readFromInotify");
+ 
+     int buffSize = 0;
+-    ioctl(inotifyFd, FIONREAD, (char *) &buffSize);
++    if (ioctl(inotifyFd, FIONREAD, (char *) &buffSize) == -1 || buffSize == 0)
++        return;
++
+     QVarLengthArray<char, 4096> buffer(buffSize);
+     buffSize = read(inotifyFd, buffer.data(), buffSize);
+     char *at = buffer.data();
+diff --git a/qtbase/src/corelib/io/qlockfile_win.cpp b/qtbase/src/corelib/io/qlockfile_win.cpp
+index 277f8d4230..38ecef5550 100644
+--- a/qtbase/src/corelib/io/qlockfile_win.cpp
++++ b/qtbase/src/corelib/io/qlockfile_win.cpp
+@@ -48,6 +48,8 @@
+ #include "QtCore/qdebug.h"
+ #include "QtCore/qthread.h"
+ 
++#include "private/qsystemlibrary_p.h"
++
+ QT_BEGIN_NAMESPACE
+ 
+ static inline bool fileExists(const wchar_t *fileName)
+@@ -150,7 +152,7 @@ QString QLockFilePrivate::processNameByPid(qint64 pid)
+ #if !defined(Q_OS_WINRT)
+     typedef DWORD (WINAPI *GetModuleFileNameExFunc)(HANDLE, HMODULE, LPTSTR, DWORD);
+ 
+-    HMODULE hPsapi = LoadLibraryA("psapi");
++    HMODULE hPsapi = QSystemLibrary::load(L"psapi");
+     if (!hPsapi)
+         return QString();
+     GetModuleFileNameExFunc qGetModuleFileNameEx = reinterpret_cast<GetModuleFileNameExFunc>(
+diff --git a/qtbase/src/corelib/io/qprocess_unix.cpp b/qtbase/src/corelib/io/qprocess_unix.cpp
+index 50390e57f5..15c8f30745 100644
+--- a/qtbase/src/corelib/io/qprocess_unix.cpp
++++ b/qtbase/src/corelib/io/qprocess_unix.cpp
+@@ -1,7 +1,7 @@
+ /****************************************************************************
+ **
+ ** Copyright (C) 2016 The Qt Company Ltd.
+-** Copyright (C) 2016 Intel Corporation.
++** Copyright (C) 2022 Intel Corporation.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtCore module of the Qt Toolkit.
+@@ -422,14 +422,15 @@ void QProcessPrivate::startProcess()
+     // Add the program name to the argument list.
+     argv[0] = nullptr;
+     if (!program.contains(QLatin1Char('/'))) {
++        // findExecutable() returns its argument if it's an absolute path,
++        // otherwise it searches $PATH; returns empty if not found (we handle
++        // that case much later)
+         const QString &exeFilePath = QStandardPaths::findExecutable(program);
+-        if (!exeFilePath.isEmpty()) {
+-            const QByteArray &tmp = QFile::encodeName(exeFilePath);
+-            argv[0] = ::strdup(tmp.constData());
+-        }
+-    }
+-    if (!argv[0])
++        const QByteArray &tmp = QFile::encodeName(exeFilePath);
++        argv[0] = ::strdup(tmp.constData());
++    } else {
+         argv[0] = ::strdup(encodedProgramName.constData());
++    }
+ 
+     // Add every argument to the list
+     for (int i = 0; i < arguments.count(); ++i)
+@@ -983,15 +984,16 @@ bool QProcessPrivate::startDetached(qint64 *pid)
+                 envp = _q_dupEnvironment(environment.d.constData()->vars, &envc);
+             }
+ 
+-            QByteArray tmp;
+             if (!program.contains(QLatin1Char('/'))) {
++                // findExecutable() returns its argument if it's an absolute path,
++                // otherwise it searches $PATH; returns empty if not found (we handle
++                // that case much later)
+                 const QString &exeFilePath = QStandardPaths::findExecutable(program);
+-                if (!exeFilePath.isEmpty())
+-                    tmp = QFile::encodeName(exeFilePath);
++                const QByteArray &tmp = QFile::encodeName(exeFilePath);
++                argv[0] = ::strdup(tmp.constData());
++            } else {
++                argv[0] = ::strdup(QFile::encodeName(program));
+             }
+-            if (tmp.isEmpty())
+-                tmp = QFile::encodeName(program);
+-            argv[0] = tmp.data();
+ 
+             if (envp)
+                 qt_safe_execve(argv[0], argv, envp);
+diff --git a/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp b/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
+index 3a79c502af..997a634e76 100644
+--- a/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
++++ b/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
+@@ -3196,9 +3196,8 @@ bool QAbstractItemModel::beginMoveColumns(const QModelIndex &sourceParent, int s
+     destinationChange.needsAdjust = destinationParent.isValid() && destinationParent.row() >= sourceLast && destinationParent.parent() == sourceParent;
+     d->changes.push(destinationChange);
+ 
+-    d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Horizontal);
+-
+     emit columnsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, QPrivateSignal());
++    d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Horizontal);
+     return true;
+ }
+ 
+@@ -3231,7 +3230,6 @@ void QAbstractItemModel::endMoveColumns()
+       adjustedSource = createIndex(adjustedSource.row(), adjustedSource.column() + numMoved, adjustedSource.internalPointer());
+ 
+     d->itemsMoved(adjustedSource, removeChange.first, removeChange.last, adjustedDestination, insertChange.first, Qt::Horizontal);
+-
+     emit columnsMoved(adjustedSource, removeChange.first, removeChange.last, adjustedDestination, insertChange.first, QPrivateSignal());
+ }
+ 
+diff --git a/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+index dc6379d9fb..c5e287ee84 100644
+--- a/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
++++ b/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+@@ -939,8 +939,9 @@ void QSortFilterProxyModelPrivate::insert_source_items(
+                 q->beginInsertColumns(proxy_parent, proxy_start, proxy_end);
+         }
+ 
+-        for (int i = 0; i < source_items.size(); ++i)
+-            proxy_to_source.insert(proxy_start + i, source_items.at(i));
++        // TODO: use the range QList::insert() overload once it is implemented (QTBUG-58633).
++        proxy_to_source.insert(proxy_start, source_items.size(), 0);
++        std::copy(source_items.cbegin(), source_items.cend(), proxy_to_source.begin() + proxy_start);
+ 
+         build_source_to_proxy_mapping(proxy_to_source, source_to_proxy);
+ 
+@@ -3123,8 +3124,9 @@ bool QSortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex &
+ 
+     if (d->filter_data.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();
+@@ -3133,9 +3135,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.hasMatch(key);
+ }
+diff --git a/qtbase/src/corelib/kernel/qcoreapplication.cpp b/qtbase/src/corelib/kernel/qcoreapplication.cpp
+index ca2864df83..132b2eae52 100644
+--- a/qtbase/src/corelib/kernel/qcoreapplication.cpp
++++ b/qtbase/src/corelib/kernel/qcoreapplication.cpp
+@@ -1157,7 +1157,7 @@ static bool doNotify(QObject *receiver, QEvent *event)
+ bool QCoreApplicationPrivate::sendThroughApplicationEventFilters(QObject *receiver, QEvent *event)
+ {
+     // We can't access the application event filters outside of the main thread (race conditions)
+-    Q_ASSERT(receiver->d_func()->threadData.loadRelaxed()->thread.loadAcquire() == mainThread());
++    Q_ASSERT(receiver->d_func()->threadData.loadAcquire()->thread.loadRelaxed() == mainThread());
+ 
+     if (extraData) {
+         // application event filters are only called for objects in the GUI thread
+diff --git a/qtbase/src/corelib/kernel/qobject.cpp b/qtbase/src/corelib/kernel/qobject.cpp
+index 1eb79138d9..36cd780ee1 100644
+--- a/qtbase/src/corelib/kernel/qobject.cpp
++++ b/qtbase/src/corelib/kernel/qobject.cpp
+@@ -1010,7 +1010,7 @@ QObject::~QObject()
+         emit destroyed(this);
+     }
+ 
+-    if (d->declarativeData) {
++    if (!d->isDeletingChildren && d->declarativeData) {
+         if (static_cast<QAbstractDeclarativeDataImpl*>(d->declarativeData)->ownedByQml1) {
+             if (QAbstractDeclarativeData::destroyed_qml1)
+                 QAbstractDeclarativeData::destroyed_qml1(d->declarativeData, this);
+@@ -1580,7 +1580,7 @@ void QObject::moveToThread(QThread *targetThread)
+ 
+     QThreadData *currentData = QThreadData::current();
+     QThreadData *targetData = targetThread ? QThreadData::get2(targetThread) : nullptr;
+-    QThreadData *thisThreadData = d->threadData.loadRelaxed();
++    QThreadData *thisThreadData = d->threadData.loadAcquire();
+     if (!thisThreadData->thread.loadAcquire() && currentData == targetData) {
+         // one exception to the rule: we allow moving objects with no thread affinity to the current thread
+         currentData = d->threadData;
+@@ -2620,7 +2620,7 @@ int QObject::receivers(const char *signal) const
+         if (!d->isSignalConnected(signal_index))
+             return receivers;
+ 
+-        if (d->declarativeData && QAbstractDeclarativeData::receivers) {
++        if (!d->isDeletingChildren && d->declarativeData && QAbstractDeclarativeData::receivers) {
+             receivers += QAbstractDeclarativeData::receivers(d->declarativeData, this,
+                                                              signal_index);
+         }
+diff --git a/qtbase/src/corelib/kernel/qobject_p.h b/qtbase/src/corelib/kernel/qobject_p.h
+index 0b827a52ca..13ffb88999 100644
+--- a/qtbase/src/corelib/kernel/qobject_p.h
++++ b/qtbase/src/corelib/kernel/qobject_p.h
+@@ -444,7 +444,7 @@ inline void QObjectPrivate::checkForIncompatibleLibraryVersion(int version) cons
+ 
+ inline bool QObjectPrivate::isDeclarativeSignalConnected(uint signal_index) const
+ {
+-    return declarativeData && QAbstractDeclarativeData::isSignalConnected
++    return !isDeletingChildren && declarativeData && QAbstractDeclarativeData::isSignalConnected
+             && QAbstractDeclarativeData::isSignalConnected(declarativeData, q_func(), signal_index);
+ }
+ 
+diff --git a/qtbase/src/corelib/kernel/qtranslator.cpp b/qtbase/src/corelib/kernel/qtranslator.cpp
+index 2812ffb7ea..bc0177c5ec 100644
+--- a/qtbase/src/corelib/kernel/qtranslator.cpp
++++ b/qtbase/src/corelib/kernel/qtranslator.cpp
+@@ -902,7 +902,7 @@ static QString getMessage(const uchar *m, const uchar *end, const char *context,
+             goto end;
+         case Tag_Translation: {
+             int len = read32(m);
+-            if (len % 1)
++            if (len & 1)
+                 return QString();
+             m += 4;
+             if (!numerus--) {
+diff --git a/qtbase/src/corelib/mimetypes/qmimedatabase.cpp b/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
+index 9de22cef33..ff868a3268 100644
+--- a/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
+@@ -389,20 +389,23 @@ QMimeType QMimeDatabasePrivate::mimeTypeForFileNameAndData(const QString &fileNa
+         // Disambiguate conflicting extensions (if magic matching found something)
+         if (candidateByData.isValid() && magicAccuracy > 0) {
+             const QString sniffedMime = candidateByData.name();
+-            // If the sniffedMime matches a glob match, use it
++            // If the sniffedMime matches a highest-weight glob match, use it
+             if (candidatesByName.m_matchingMimeTypes.contains(sniffedMime)) {
+                 *accuracyPtr = 100;
+                 return candidateByData;
+             }
+-            for (const QString &m : qAsConst(candidatesByName.m_matchingMimeTypes)) {
++            for (const QString &m : qAsConst(candidatesByName.m_allMatchingMimeTypes)) {
+                 if (inherits(m, sniffedMime)) {
+                     // We have magic + pattern pointing to this, so it's a pretty good match
+                     *accuracyPtr = 100;
+                     return mimeTypeForName(m);
+                 }
+             }
+-            *accuracyPtr = magicAccuracy;
+-            return candidateByData;
++            if (candidatesByName.m_allMatchingMimeTypes.isEmpty()) {
++                // No glob, use magic
++                *accuracyPtr = magicAccuracy;
++                return candidateByData;
++            }
+         }
+     }
+ 
+diff --git a/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp b/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
+index a81112d227..fa8f4c545d 100644
+--- a/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
+@@ -83,7 +83,10 @@ void QMimeGlobMatchResult::addMatch(const QString &mimeType, int weight, const Q
+     }
+     if (!m_matchingMimeTypes.contains(mimeType)) {
+         m_matchingMimeTypes.append(mimeType);
+-        m_allMatchingMimeTypes.append(mimeType);
++        if (replace)
++            m_allMatchingMimeTypes.prepend(mimeType); // highest-weight first
++        else
++            m_allMatchingMimeTypes.append(mimeType);
+         m_knownSuffixLength = knownSuffixLength;
+     }
+ }
+@@ -94,7 +97,7 @@ QMimeGlobPattern::PatternType QMimeGlobPattern::detectPatternType(const QString
+     if (!patternLength)
+         return OtherPattern;
+ 
+-    const bool starCount = pattern.count(QLatin1Char('*')) == 1;
++    const int starCount = pattern.count(QLatin1Char('*'));
+     const bool hasSquareBracket = pattern.indexOf(QLatin1Char('[')) != -1;
+     const bool hasQuestionMark = pattern.indexOf(QLatin1Char('?')) != -1;
+ 
+@@ -106,10 +109,10 @@ QMimeGlobPattern::PatternType QMimeGlobPattern::detectPatternType(const QString
+             // Patterns like "README*" (well this is currently the only one like that...)
+             if (pattern.at(patternLength - 1) == QLatin1Char('*'))
+                 return PrefixPattern;
+-        }
+-        // Names without any wildcards like "README"
+-        if (starCount == 0)
++        } else if (starCount == 0) {
++            // Names without any wildcards like "README"
+             return LiteralPattern;
++        }
+     }
+ 
+     if (pattern == QLatin1String("[0-9][0-9][0-9].vdr"))
+diff --git a/qtbase/src/corelib/mimetypes/qmimeprovider.cpp b/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
+index 258dddf8cb..4642d0f2d0 100644
+--- a/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
+@@ -244,15 +244,18 @@ void QMimeBinaryProvider::addFileNameMatches(const QString &fileName, QMimeGlobM
+     const QString lowerFileName = fileName.toLower();
+     // Check literals (e.g. "Makefile")
+     matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosLiteralListOffset), fileName);
+-    // Check complex globs (e.g. "callgrind.out[0-9]*")
+-    matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosGlobListOffset), fileName);
+     // Check the very common *.txt cases with the suffix tree
+-    const int reverseSuffixTreeOffset = m_cacheFile->getUint32(PosReverseSuffixTreeOffset);
+-    const int numRoots = m_cacheFile->getUint32(reverseSuffixTreeOffset);
+-    const int firstRootOffset = m_cacheFile->getUint32(reverseSuffixTreeOffset + 4);
+-    matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, lowerFileName, lowerFileName.length() - 1, false);
++    if (result.m_matchingMimeTypes.isEmpty()) {
++        const int reverseSuffixTreeOffset = m_cacheFile->getUint32(PosReverseSuffixTreeOffset);
++        const int numRoots = m_cacheFile->getUint32(reverseSuffixTreeOffset);
++        const int firstRootOffset = m_cacheFile->getUint32(reverseSuffixTreeOffset + 4);
++        matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, lowerFileName, lowerFileName.length() - 1, false);
++        if (result.m_matchingMimeTypes.isEmpty())
++            matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, fileName, fileName.length() - 1, true);
++    }
++    // Check complex globs (e.g. "callgrind.out[0-9]*" or "README*")
+     if (result.m_matchingMimeTypes.isEmpty())
+-        matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, fileName, fileName.length() - 1, true);
++        matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosGlobListOffset), fileName);
+ }
+ 
+ void QMimeBinaryProvider::matchGlobList(QMimeGlobMatchResult &result, CacheFile *cacheFile, int off, const QString &fileName)
+diff --git a/qtbase/src/corelib/serialization/qjsonparser.cpp b/qtbase/src/corelib/serialization/qjsonparser.cpp
+index 17e6f111ab..2e40b6c8fb 100644
+--- a/qtbase/src/corelib/serialization/qjsonparser.cpp
++++ b/qtbase/src/corelib/serialization/qjsonparser.cpp
+@@ -379,10 +379,30 @@ error:
+     return QCborValue();
+ }
+ 
++// We need to retain the _last_ value for any duplicate keys and we need to deref containers.
++// Therefore the manual implementation of std::unique().
++template<typename Iterator, typename Compare, typename Assign>
++static Iterator customAssigningUniqueLast(Iterator first, Iterator last,
++                                          Compare compare, Assign assign)
++{
++    first = std::adjacent_find(first, last, compare);
++    if (first == last)
++        return last;
++
++    Iterator result = first;
++    while (++first != last) {
++        if (!compare(*result, *first))
++            ++result;
++        if (result != first)
++            assign(*result, *first);
++    }
++
++    return ++result;
++}
++
+ static void sortContainer(QCborContainerPrivate *container)
+ {
+     using Forward = QJsonPrivate::KeyIterator;
+-    using Reverse = std::reverse_iterator<Forward>;
+     using Value = Forward::value_type;
+ 
+     auto compare = [container](const Value &a, const Value &b)
+@@ -420,17 +440,31 @@ static void sortContainer(QCborContainerPrivate *container)
+         }
+     };
+ 
+-    std::sort(Forward(container->elements.begin()), Forward(container->elements.end()),
+-              [&compare](const Value &a, const Value &b) { return compare(a, b) < 0; });
++    // The elements' containers are owned by the outer container, not by the elements themselves.
++    auto move = [](Forward::reference target, Forward::reference source)
++    {
++        QtCbor::Element &targetValue = target.value();
++
++        // If the target has a container, deref it before overwriting, so that we don't leak.
++        if (targetValue.flags & QtCbor::Element::IsContainer)
++            targetValue.container->deref();
++
++        // Do not move, so that we can clear the value afterwards.
++        target = source;
++
++        // Clear the source value, so that we don't store the same container twice.
++        source.value() = QtCbor::Element();
++    };
++
++    std::stable_sort(
++                Forward(container->elements.begin()), Forward(container->elements.end()),
++                [&compare](const Value &a, const Value &b) { return compare(a, b) < 0; });
+ 
+-    // We need to retain the _last_ value for any duplicate keys. Therefore the reverse dance here.
+-    auto it = std::unique(Reverse(container->elements.end()), Reverse(container->elements.begin()),
+-                          [&compare](const Value &a, const Value &b) {
+-        return compare(a, b) == 0;
+-    }).base().elementsIterator();
++    Forward result = customAssigningUniqueLast(
++                Forward(container->elements.begin()),  Forward(container->elements.end()),
++                [&compare](const Value &a, const Value &b) { return compare(a, b) == 0; }, move);
+ 
+-    // The erase from beginning is expensive but hopefully rare.
+-    container->elements.erase(container->elements.begin(), it);
++    container->elements.erase(result.elementsIterator(), container->elements.end());
+ }
+ 
+ 
+diff --git a/qtbase/src/corelib/serialization/qxmlstream.cpp b/qtbase/src/corelib/serialization/qxmlstream.cpp
+index b2f846544d..7cd457ba3a 100644
+--- a/qtbase/src/corelib/serialization/qxmlstream.cpp
++++ b/qtbase/src/corelib/serialization/qxmlstream.cpp
+@@ -980,7 +980,7 @@ inline uint QXmlStreamReaderPrivate::peekChar()
+ bool QXmlStreamReaderPrivate::scanUntil(const char *str, short tokenToInject)
+ {
+     int pos = textBuffer.size();
+-    int oldLineNumber = lineNumber;
++    const auto oldLineNumber = lineNumber;
+ 
+     uint c;
+     while ((c = getChar()) != StreamEOF) {
+diff --git a/qtbase/src/corelib/text/qstring.cpp b/qtbase/src/corelib/text/qstring.cpp
+index 3e88ab4859..8deeae47bb 100644
+--- a/qtbase/src/corelib/text/qstring.cpp
++++ b/qtbase/src/corelib/text/qstring.cpp
+@@ -12312,7 +12312,7 @@ static qsizetype qLastIndexOf(Haystack haystack0, qsizetype from,
+     const auto needle = needle0.data();
+     const auto *end = haystack;
+     haystack += from;
+-    const std::size_t sl_minus_1 = sl - 1;
++    const std::size_t sl_minus_1 = sl ? sl - 1 : 0;
+     const auto *n = needle + sl_minus_1;
+     const auto *h = haystack + sl_minus_1;
+     std::size_t hashNeedle = 0, hashHaystack = 0;
+diff --git a/qtbase/src/corelib/text/qstringiterator_p.h b/qtbase/src/corelib/text/qstringiterator_p.h
+index 219589b6e4..1d0c66cc78 100644
+--- a/qtbase/src/corelib/text/qstringiterator_p.h
++++ b/qtbase/src/corelib/text/qstringiterator_p.h
+@@ -61,6 +61,8 @@ class QStringIterator
+ {
+     QString::const_iterator i, pos, e;
+     Q_STATIC_ASSERT((std::is_same<QString::const_iterator, const QChar *>::value));
++    static bool less(const QChar *lhs, const QChar *rhs) noexcept
++    { return std::less<QString::const_iterator>{}(lhs, rhs); }
+ public:
+     explicit QStringIterator(QStringView string, qsizetype idx = 0)
+         : i(string.begin()),
+@@ -95,7 +97,8 @@ public:
+ 
+     inline void setPosition(QString::const_iterator position)
+     {
+-        Q_ASSERT_X(i <= position && position <= e, Q_FUNC_INFO, "position out of bounds");
++        Q_ASSERT_X(!less(position, i) && !less(e, position),
++                   Q_FUNC_INFO, "position out of bounds");
+         pos = position;
+     }
+ 
+@@ -103,7 +106,7 @@ public:
+ 
+     inline bool hasNext() const
+     {
+-        return pos < e;
++        return less(pos, e);
+     }
+ 
+     inline void advance()
+@@ -120,16 +123,20 @@ public:
+     {
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+-        if (Q_UNLIKELY((pos++)->isHighSurrogate()))
++        if (Q_UNLIKELY((pos++)->isHighSurrogate())) {
++            Q_ASSERT(hasNext() && pos->isLowSurrogate());
+             ++pos;
++        }
+     }
+ 
+     inline uint peekNextUnchecked() const
+     {
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+-        if (Q_UNLIKELY(pos->isHighSurrogate()))
++        if (Q_UNLIKELY(pos->isHighSurrogate())) {
++            Q_ASSERT(less(pos + 1, e) && pos[1].isLowSurrogate());
+             return QChar::surrogateToUcs4(pos[0], pos[1]);
++        }
+ 
+         return pos->unicode();
+     }
+@@ -155,8 +162,10 @@ public:
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+         const QChar cur = *pos++;
+-        if (Q_UNLIKELY(cur.isHighSurrogate()))
++        if (Q_UNLIKELY(cur.isHighSurrogate())) {
++            Q_ASSERT(hasNext() && pos->isLowSurrogate());
+             return QChar::surrogateToUcs4(cur, *pos++);
++        }
+         return cur.unicode();
+     }
+ 
+@@ -166,7 +175,7 @@ public:
+ 
+         const QChar uc = *pos++;
+         if (Q_UNLIKELY(uc.isSurrogate())) {
+-            if (Q_LIKELY(uc.isHighSurrogate() && pos < e && pos->isLowSurrogate()))
++            if (Q_LIKELY(uc.isHighSurrogate() && hasNext() && pos->isLowSurrogate()))
+                 return QChar::surrogateToUcs4(uc, *pos++);
+             return invalidAs;
+         }
+@@ -178,7 +187,7 @@ public:
+ 
+     inline bool hasPrevious() const
+     {
+-        return pos > i;
++        return less(i, pos);
+     }
+ 
+     inline void recede()
+@@ -196,16 +205,20 @@ public:
+     {
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+-        if (Q_UNLIKELY((--pos)->isLowSurrogate()))
++        if (Q_UNLIKELY((--pos)->isLowSurrogate())) {
++            Q_ASSERT(hasPrevious() && pos[-1].isHighSurrogate());
+             --pos;
++        }
+     }
+ 
+     inline uint peekPreviousUnchecked() const
+     {
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+-        if (Q_UNLIKELY(pos[-1].isLowSurrogate()))
++        if (Q_UNLIKELY(pos[-1].isLowSurrogate())) {
++            Q_ASSERT(less(i + 1, pos) && pos[-2].isHighSurrogate());
+             return QChar::surrogateToUcs4(pos[-2], pos[-1]);
++        }
+         return pos[-1].unicode();
+     }
+ 
+@@ -230,8 +243,10 @@ public:
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+         const QChar cur = *--pos;
+-        if (Q_UNLIKELY(cur.isLowSurrogate()))
++        if (Q_UNLIKELY(cur.isLowSurrogate())) {
++            Q_ASSERT(hasPrevious() && pos[-1].isHighSurrogate());
+             return QChar::surrogateToUcs4(*--pos, cur);
++        }
+         return cur.unicode();
+     }
+ 
+@@ -241,7 +256,7 @@ public:
+ 
+         const QChar uc = *--pos;
+         if (Q_UNLIKELY(uc.isSurrogate())) {
+-            if (Q_LIKELY(uc.isLowSurrogate() && pos > i && pos[-1].isHighSurrogate()))
++            if (Q_LIKELY(uc.isLowSurrogate() && hasPrevious() && pos[-1].isHighSurrogate()))
+                 return QChar::surrogateToUcs4(*--pos, uc);
+             return invalidAs;
+         }
+diff --git a/qtbase/src/corelib/thread/qfutex_p.h b/qtbase/src/corelib/thread/qfutex_p.h
+index f287b752d7..e294537787 100644
+--- a/qtbase/src/corelib/thread/qfutex_p.h
++++ b/qtbase/src/corelib/thread/qfutex_p.h
+@@ -52,6 +52,7 @@
+ //
+ 
+ #include <qglobal.h>
++#include <QtCore/qtsan_impl.h>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -106,16 +107,13 @@ namespace QtLinuxFutex {
+     inline int _q_futex(int *addr, int op, int val, quintptr val2 = 0,
+                         int *addr2 = nullptr, int val3 = 0) noexcept
+     {
+-        // A futex call ensures total ordering on the futex words
+-        // (in either success or failure of the call). Instruct TSAN accordingly,
+-        // as TSAN does not understand the futex(2) syscall.
+-        _q_tsan_release(addr, addr2);
++        QtTsan::futexRelease(addr, addr2);
+ 
+         // we use __NR_futex because some libcs (like Android's bionic) don't
+         // provide SYS_futex etc.
+         int result = syscall(__NR_futex, addr, op | FUTEX_PRIVATE_FLAG, val, val2, addr2, val3);
+ 
+-        _q_tsan_acquire(addr, addr2);
++        QtTsan::futexAcquire(addr, addr2);
+ 
+         return result;
+     }
+diff --git a/qtbase/src/corelib/thread/qmutex.cpp b/qtbase/src/corelib/thread/qmutex.cpp
+index 310d1cb14f..7097122d8e 100644
+--- a/qtbase/src/corelib/thread/qmutex.cpp
++++ b/qtbase/src/corelib/thread/qmutex.cpp
+@@ -152,6 +152,7 @@ public:
+ 
+ /*!
+     \enum QMutex::RecursionMode
++    \obsolete Use QRecursiveMutex to create a recursive mutex.
+ 
+     \value Recursive  In this mode, a thread can lock the same mutex
+                       multiple times and the mutex won't be unlocked
+@@ -173,6 +174,7 @@ public:
+ 
+ /*!
+     Constructs a new mutex. The mutex is created in an unlocked state.
++    \obsolete Use QRecursiveMutex to create a recursive mutex.
+ 
+     If \a mode is QMutex::Recursive, a thread can lock the same mutex
+     multiple times and the mutex won't be unlocked until a
+@@ -197,7 +199,7 @@ QMutex::QMutex(RecursionMode mode)
+ QMutex::~QMutex()
+ {
+     QMutexData *d = d_ptr.loadRelaxed();
+-    if (isRecursive()) {
++    if (QBasicMutex::isRecursive()) {
+         delete static_cast<QRecursiveMutexPrivate *>(d);
+     } else if (d) {
+ #ifndef QT_LINUX_FUTEX
+diff --git a/qtbase/src/corelib/thread/qmutex.h b/qtbase/src/corelib/thread/qmutex.h
+index 73c9e00663..1bae573a03 100644
+--- a/qtbase/src/corelib/thread/qmutex.h
++++ b/qtbase/src/corelib/thread/qmutex.h
+@@ -42,6 +42,7 @@
+ 
+ #include <QtCore/qglobal.h>
+ #include <QtCore/qatomic.h>
++#include <QtCore/qtsan_impl.h>
+ #include <new>
+ 
+ #if __has_include(<chrono>)
+@@ -77,19 +78,37 @@ public:
+ 
+     // BasicLockable concept
+     inline void lock() QT_MUTEX_LOCK_NOEXCEPT {
++        QtTsan::mutexPreLock(this, 0u);
++
+         if (!fastTryLock())
+             lockInternal();
++
++        QtTsan::mutexPostLock(this, 0u, 0);
+     }
+ 
+     // BasicLockable concept
+     inline void unlock() noexcept {
+         Q_ASSERT(d_ptr.loadRelaxed()); //mutex must be locked
++
++        QtTsan::mutexPreUnlock(this, 0u);
++
+         if (!fastTryUnlock())
+             unlockInternal();
++
++        QtTsan::mutexPostUnlock(this, 0u);
+     }
+ 
+     bool tryLock() noexcept {
+-        return fastTryLock();
++        unsigned tsanFlags = QtTsan::TryLock;
++        QtTsan::mutexPreLock(this, tsanFlags);
++
++        const bool success = fastTryLock();
++
++        if (!success)
++            tsanFlags |= QtTsan::TryLockFailed;
++        QtTsan::mutexPostLock(this, tsanFlags, 0);
++
++        return success;
+     }
+ 
+     // Lockable concept
+@@ -134,8 +153,16 @@ public:
+ #else
+     QMutex() { d_ptr.storeRelaxed(nullptr); }
+ #endif
++#if QT_DEPRECATED_SINCE(5,15)
+     enum RecursionMode { NonRecursive, Recursive };
++    QT_DEPRECATED_VERSION_X(5, 15, "Use QRecursiveMutex instead of a recursive QMutex")
+     explicit QMutex(RecursionMode mode);
++
++    QT_DEPRECATED_VERSION_X(5, 15, "Use QRecursiveMutex instead of a recursive QMutex")
++    bool isRecursive() const noexcept
++    { return QBasicMutex::isRecursive(); }
++#endif
++
+     ~QMutex();
+ 
+     // BasicLockable concept
+@@ -166,9 +193,6 @@ public:
+     }
+ #endif
+ 
+-    bool isRecursive() const noexcept
+-    { return QBasicMutex::isRecursive(); }
+-
+ private:
+     Q_DISABLE_COPY(QMutex)
+     friend class QMutexLocker;
+diff --git a/qtbase/src/corelib/thread/qreadwritelock.cpp b/qtbase/src/corelib/thread/qreadwritelock.cpp
+index 8c28507d5a..9dd8503116 100644
+--- a/qtbase/src/corelib/thread/qreadwritelock.cpp
++++ b/qtbase/src/corelib/thread/qreadwritelock.cpp
+@@ -155,7 +155,7 @@ QReadWriteLock::QReadWriteLock(RecursionMode recursionMode)
+ */
+ QReadWriteLock::~QReadWriteLock()
+ {
+-    auto d = d_ptr.loadRelaxed();
++    auto d = d_ptr.loadAcquire();
+     if (isUncontendedLocked(d)) {
+         qWarning("QReadWriteLock: destroying locked QReadWriteLock");
+         return;
+@@ -445,7 +445,7 @@ void QReadWriteLock::unlock()
+ /*! \internal  Helper for QWaitCondition::wait */
+ QReadWriteLock::StateForWaitCondition QReadWriteLock::stateForWaitCondition() const
+ {
+-    QReadWriteLockPrivate *d = d_ptr.loadRelaxed();
++    QReadWriteLockPrivate *d = d_ptr.loadAcquire();
+     switch (quintptr(d) & StateMask) {
+     case StateLockedForRead: return LockedForRead;
+     case StateLockedForWrite: return LockedForWrite;
+@@ -453,6 +453,7 @@ QReadWriteLock::StateForWaitCondition QReadWriteLock::stateForWaitCondition() co
+ 
+     if (!d)
+         return Unlocked;
++    const auto lock = qt_scoped_lock(d->mutex);
+     if (d->writerCount > 1)
+         return RecursivelyLocked;
+     else if (d->writerCount == 1)
+diff --git a/qtbase/src/corelib/thread/qsemaphore.cpp b/qtbase/src/corelib/thread/qsemaphore.cpp
+index 1d01fc1b28..3ecdee3747 100644
+--- a/qtbase/src/corelib/thread/qsemaphore.cpp
++++ b/qtbase/src/corelib/thread/qsemaphore.cpp
+@@ -354,7 +354,12 @@ void QSemaphore::release(int n)
+         quintptr nn = unsigned(n);
+         if (futexHasWaiterCount)
+             nn |= quint64(nn) << 32;    // token count replicated in high word
+-        quintptr prevValue = u.fetchAndAddRelease(nn);
++        quintptr prevValue = u.loadRelaxed();
++        quintptr newValue;
++        do { // loop just to ensure the operations are done atomically
++            newValue = prevValue + nn;
++            newValue &= (futexNeedsWakeAllBit - 1);
++        } while (!u.testAndSetRelease(prevValue, newValue, prevValue));
+         if (futexNeedsWake(prevValue)) {
+ #ifdef FUTEX_OP
+             if (futexHasWaiterCount) {
+@@ -376,7 +381,6 @@ void QSemaphore::release(int n)
+                 quint32 oparg = 0;
+                 quint32 cmp = FUTEX_OP_CMP_NE;
+                 quint32 cmparg = 0;
+-                u.fetchAndAndRelease(futexNeedsWakeAllBit - 1);
+                 futexWakeOp(*futexLow32(&u), n, INT_MAX, *futexHigh32(&u), FUTEX_OP(op, oparg, cmp, cmparg));
+                 return;
+             }
+@@ -388,7 +392,6 @@ 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(futexNeedsWakeAllBit - 1);
+             if (futexHasWaiterCount) {
+                 futexWakeAll(*futexLow32(&u));
+                 futexWakeAll(*futexHigh32(&u));
+diff --git a/qtbase/src/corelib/thread/qthread_p.h b/qtbase/src/corelib/thread/qthread_p.h
+index b2d1628e6e..f32f6f0460 100644
+--- a/qtbase/src/corelib/thread/qthread_p.h
++++ b/qtbase/src/corelib/thread/qthread_p.h
+@@ -174,7 +174,7 @@ public:
+     int returnCode;
+ 
+     uint stackSize;
+-    QThread::Priority priority;
++    std::underlying_type<QThread::Priority>::type priority;
+ 
+     static QThread *threadForId(int id);
+ 
+@@ -213,6 +213,13 @@ public:
+             QCoreApplication::instance()->postEvent(q_ptr, new QEvent(QEvent::Quit));
+         }
+     }
++
++#ifndef Q_OS_INTEGRITY
++private:
++    // Used in QThread(Private)::start to avoid racy access to QObject::objectName,
++    // unset afterwards. On INTEGRITY we set the thread name before starting it.
++    QString objectName;
++#endif
+ };
+ 
+ #else // QT_CONFIG(thread)
+diff --git a/qtbase/src/corelib/thread/qthread_unix.cpp b/qtbase/src/corelib/thread/qthread_unix.cpp
+index 56a8e0a038..610117a640 100644
+--- a/qtbase/src/corelib/thread/qthread_unix.cpp
++++ b/qtbase/src/corelib/thread/qthread_unix.cpp
+@@ -169,8 +169,7 @@ static void set_thread_data(QThreadData *data)
+ 
+ static void clear_thread_data()
+ {
+-    currentThreadData = nullptr;
+-    pthread_setspecific(current_thread_data_key, nullptr);
++    set_thread_data(nullptr);
+ }
+ 
+ template <typename T>
+@@ -296,7 +295,7 @@ void *QThreadPrivate::start(void *arg)
+             QMutexLocker locker(&thr->d_func()->mutex);
+ 
+             // do we need to reset the thread priority?
+-            if (int(thr->d_func()->priority) & ThreadPriorityResetFlag) {
++            if (thr->d_func()->priority & ThreadPriorityResetFlag) {
+                 thr->d_func()->setPriority(QThread::Priority(thr->d_func()->priority & ~ThreadPriorityResetFlag));
+             }
+ 
+@@ -316,10 +315,10 @@ void *QThreadPrivate::start(void *arg)
+             // Sets the name of the current thread. We can only do this
+             // when the thread is starting, as we don't have a cross
+             // platform way of setting the name of an arbitrary thread.
+-            if (Q_LIKELY(thr->objectName().isEmpty()))
++            if (Q_LIKELY(thr->d_func()->objectName.isEmpty()))
+                 setCurrentThreadName(thr->metaObject()->className());
+             else
+-                setCurrentThreadName(thr->objectName().toLocal8Bit());
++                setCurrentThreadName(std::exchange(thr->d_func()->objectName, {}).toLocal8Bit());
+         }
+ #endif
+ 
+@@ -671,7 +670,7 @@ void QThread::start(Priority priority)
+                 // could not set scheduling hints, fallback to inheriting them
+                 // we'll try again from inside the thread
+                 pthread_attr_setinheritsched(&attr, PTHREAD_INHERIT_SCHED);
+-                d->priority = Priority(priority | ThreadPriorityResetFlag);
++                d->priority = static_cast<std::underlying_type<QThread::Priority>::type>(priority) | ThreadPriorityResetFlag;
+             }
+             break;
+         }
+@@ -702,7 +701,10 @@ void QThread::start(Priority priority)
+         pthread_attr_setthreadname(&attr, metaObject()->className());
+     else
+         pthread_attr_setthreadname(&attr, objectName().toLocal8Bit());
++#else
++    d->objectName = objectName();
+ #endif
++
+     pthread_t threadId;
+     int code = pthread_create(&threadId, &attr, QThreadPrivate::start, this);
+     if (code == EPERM) {
+diff --git a/qtbase/src/corelib/thread/qthread_win.cpp b/qtbase/src/corelib/thread/qthread_win.cpp
+index bc70e3178a..4e76972498 100644
+--- a/qtbase/src/corelib/thread/qthread_win.cpp
++++ b/qtbase/src/corelib/thread/qthread_win.cpp
+@@ -394,10 +394,9 @@ unsigned int __stdcall QT_ENSURE_STACK_ALIGNED_FOR_SSE QThreadPrivate::start(voi
+ 
+ #if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) && !defined(Q_OS_WINRT)
+     // sets the name of the current thread.
+-    QByteArray objectName = thr->objectName().toLocal8Bit();
+-    qt_set_thread_name(HANDLE(-1),
+-                       objectName.isEmpty() ?
+-                       thr->metaObject()->className() : objectName.constData());
++    qt_set_thread_name(HANDLE(-1), thr->d_func()->objectName.isEmpty()
++                        ? thr->metaObject()->className()
++                        : std::exchange(thr->d_func()->objectName, {}).toLocal8Bit().constData());
+ #endif
+ 
+     emit thr->started(QThread::QPrivateSignal());
+@@ -503,6 +502,7 @@ void QThread::start(Priority priority)
+     if (d->running)
+         return;
+ 
++    d->objectName = objectName();
+     d->running = true;
+     d->finished = false;
+     d->exited = false;
+@@ -548,7 +548,7 @@ void QThread::start(Priority priority)
+ 
+     int prio;
+     d->priority = priority;
+-    switch (d->priority) {
++    switch (priority) {
+     case IdlePriority:
+         prio = THREAD_PRIORITY_IDLE;
+         break;
+@@ -686,7 +686,7 @@ void QThreadPrivate::setPriority(QThread::Priority threadPriority)
+ 
+     int prio;
+     priority = threadPriority;
+-    switch (priority) {
++    switch (threadPriority) {
+     case QThread::IdlePriority:
+         prio = THREAD_PRIORITY_IDLE;
+         break;
+diff --git a/qtbase/src/corelib/thread/qtsan_impl.h b/qtbase/src/corelib/thread/qtsan_impl.h
+new file mode 100644
+index 0000000000..580a738b91
+--- /dev/null
++++ b/qtbase/src/corelib/thread/qtsan_impl.h
+@@ -0,0 +1,115 @@
++/****************************************************************************
++**
++** Copyright (C) 2017 Intel Corporation.
++** Copyright (C) 2022 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
++** 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 QTSAN_IMPL_H
++#define QTSAN_IMPL_H
++
++#include <QtCore/qglobal.h>
++
++#if (__has_feature(thread_sanitizer) || defined(__SANITIZE_THREAD__)) && __has_include(<sanitizer/tsan_interface.h>)
++#  define QT_BUILDING_UNDER_TSAN
++#  include <sanitizer/tsan_interface.h>
++#endif
++
++QT_BEGIN_NAMESPACE
++
++namespace QtTsan {
++#ifdef QT_BUILDING_UNDER_TSAN
++inline void futexAcquire(void *addr, void *addr2 = nullptr)
++{
++    // A futex call ensures total ordering on the futex words
++    // (in either success or failure of the call). Instruct TSAN accordingly,
++    // as TSAN does not understand the futex(2) syscall (or equivalent).
++    ::__tsan_acquire(addr);
++    if (addr2)
++        ::__tsan_acquire(addr2);
++}
++
++inline void futexRelease(void *addr, void *addr2 = nullptr)
++{
++    if (addr2)
++        ::__tsan_release(addr2);
++    ::__tsan_release(addr);
++}
++
++inline void mutexPreLock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_pre_lock(addr, flags);
++}
++
++inline void mutexPostLock(void *addr, unsigned flags, int recursion)
++{
++    ::__tsan_mutex_post_lock(addr, flags, recursion);
++}
++
++inline void mutexPreUnlock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_pre_unlock(addr, flags);
++}
++
++inline void mutexPostUnlock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_post_unlock(addr, flags);
++}
++
++enum : unsigned {
++    MutexWriteReentrant = ::__tsan_mutex_write_reentrant,
++    TryLock = ::__tsan_mutex_try_lock,
++    TryLockFailed = ::__tsan_mutex_try_lock_failed,
++};
++#else
++inline void futexAcquire(void *, void * = nullptr) {}
++inline void futexRelease(void *, void * = nullptr) {}
++
++enum : unsigned {
++    MutexWriteReentrant,
++    TryLock,
++    TryLockFailed,
++};
++inline void mutexPreLock(void *, unsigned) {}
++inline void mutexPostLock(void *, unsigned, int) {}
++inline void mutexPreUnlock(void *, unsigned) {}
++inline void mutexPostUnlock(void *, unsigned) {}
++#endif // QT_BUILDING_UNDER_TSAN
++} // namespace QtTsan
++
++QT_END_NAMESPACE
++
++#endif // QTSAN_IMPL_H
+diff --git a/qtbase/src/corelib/thread/qwaitcondition_unix.cpp b/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
+index 88b058f410..0f1da4dc9b 100644
+--- a/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
++++ b/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
+@@ -213,7 +213,7 @@ bool QWaitCondition::wait(QMutex *mutex, QDeadlineTimer deadline)
+ {
+     if (! mutex)
+         return false;
+-    if (mutex->isRecursive()) {
++    if (static_cast<QBasicMutex *>(mutex)->isRecursive()) {
+         qWarning("QWaitCondition: cannot wait on recursive mutexes");
+         return false;
+     }
+diff --git a/qtbase/src/corelib/time/qdatetime.cpp b/qtbase/src/corelib/time/qdatetime.cpp
+index ec12569e3f..2c0b098079 100644
+--- a/qtbase/src/corelib/time/qdatetime.cpp
++++ b/qtbase/src/corelib/time/qdatetime.cpp
+@@ -43,6 +43,7 @@
+ #if QT_CONFIG(datetimeparser)
+ #include "private/qdatetimeparser_p.h"
+ #endif
++#include <private/qnumeric_p.h>
+ 
+ #include "qdatastream.h"
+ #include "qset.h"
+@@ -1429,9 +1430,11 @@ QDate QDate::addDays(qint64 ndays) const
+     if (isNull())
+         return QDate();
+ 
+-    // Due to limits on minJd() and maxJd() we know that any overflow
+-    // will be invalid and caught by fromJulianDay().
+-    return fromJulianDay(jd + ndays);
++    qint64 r;
++    if (Q_UNLIKELY(add_overflow(jd, ndays, &r)))
++        return QDate();
++    else
++        return fromJulianDay(r);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/corelib/time/qtimezone.cpp b/qtbase/src/corelib/time/qtimezone.cpp
+index 0309e43e52..3d451696a1 100644
+--- a/qtbase/src/corelib/time/qtimezone.cpp
++++ b/qtbase/src/corelib/time/qtimezone.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2013 John Layt <jlayt@kde.org>
++** Copyright (C) 2020 John Layt <jlayt@kde.org>
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtCore module of the Qt Toolkit.
+@@ -975,9 +975,15 @@ QList<QByteArray> QTimeZone::windowsIdToIanaIds(const QByteArray &windowsId,
+ }
+ 
+ #ifndef QT_NO_DATASTREAM
++// Invalid, as an IANA ID: too long, starts with - and has other invalid characters in it
++static inline QString invalidId() { return QStringLiteral("-No Time Zone Specified!"); }
++
+ QDataStream &operator<<(QDataStream &ds, const QTimeZone &tz)
+ {
+-    tz.d->serialize(ds);
++    if (tz.isValid())
++        tz.d->serialize(ds);
++    else
++        ds << invalidId();
+     return ds;
+ }
+ 
+@@ -985,7 +991,9 @@ QDataStream &operator>>(QDataStream &ds, QTimeZone &tz)
+ {
+     QString ianaId;
+     ds >> ianaId;
+-    if (ianaId == QLatin1String("OffsetFromUtc")) {
++    if (ianaId == invalidId()) {
++        tz = QTimeZone();
++    } else if (ianaId == QLatin1String("OffsetFromUtc")) {
+         int utcOffset;
+         QString name;
+         QString abbreviation;
+diff --git a/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp b/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
+index b1611d7ddb..a7a6a72ccf 100644
+--- a/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
++++ b/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
+@@ -42,6 +42,7 @@
+ #include "qtimezone.h"
+ #include "qtimezoneprivate_p.h"
+ #include "private/qlocale_tools_p.h"
++#include "private/qlocking_p.h"
+ 
+ #include <QtCore/QDataStream>
+ #include <QtCore/QDateTime>
+@@ -62,6 +63,10 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++#if QT_CONFIG(icu)
++static QBasicMutex s_icu_mutex;
++#endif
++
+ /*
+     Private
+ 
+@@ -670,6 +675,9 @@ QTzTimeZonePrivate::~QTzTimeZonePrivate()
+ 
+ QTzTimeZonePrivate *QTzTimeZonePrivate::clone() const
+ {
++#if QT_CONFIG(icu)
++    const auto lock = qt_scoped_lock(s_icu_mutex);
++#endif
+     return new QTzTimeZonePrivate(*this);
+ }
+ 
+@@ -913,12 +921,14 @@ QString QTzTimeZonePrivate::displayName(qint64 atMSecsSinceEpoch,
+                                         const QLocale &locale) const
+ {
+ #if QT_CONFIG(icu)
++    auto lock = qt_unique_lock(s_icu_mutex);
+     if (!m_icu)
+         m_icu = new QIcuTimeZonePrivate(m_id);
+     // TODO small risk may not match if tran times differ due to outdated files
+     // TODO Some valid TZ names are not valid ICU names, use translation table?
+     if (m_icu->isValid())
+         return m_icu->displayName(atMSecsSinceEpoch, nameType, locale);
++    lock.unlock();
+ #else
+     Q_UNUSED(nameType)
+     Q_UNUSED(locale)
+@@ -932,12 +942,14 @@ QString QTzTimeZonePrivate::displayName(QTimeZone::TimeType timeType,
+                                         const QLocale &locale) const
+ {
+ #if QT_CONFIG(icu)
++    auto lock = qt_unique_lock(s_icu_mutex);
+     if (!m_icu)
+         m_icu = new QIcuTimeZonePrivate(m_id);
+     // TODO small risk may not match if tran times differ due to outdated files
+     // TODO Some valid TZ names are not valid ICU names, use translation table?
+     if (m_icu->isValid())
+         return m_icu->displayName(timeType, nameType, locale);
++    lock.unlock();
+ #else
+     Q_UNUSED(timeType)
+     Q_UNUSED(nameType)
+diff --git a/qtbase/src/corelib/tools/qarraydata.h b/qtbase/src/corelib/tools/qarraydata.h
+index dcd95924c1..d01739e7e6 100644
+--- a/qtbase/src/corelib/tools/qarraydata.h
++++ b/qtbase/src/corelib/tools/qarraydata.h
+@@ -42,6 +42,7 @@
+ 
+ #include <QtCore/qrefcount.h>
+ #include <string.h>
++#include <cstdint>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -58,14 +59,14 @@ struct Q_CORE_EXPORT QArrayData
+     {
+         Q_ASSERT(size == 0
+                 || offset < 0 || size_t(offset) >= sizeof(QArrayData));
+-        return reinterpret_cast<char *>(this) + offset;
++        return reinterpret_cast<void *> (reinterpret_cast<uintptr_t>(this) + offset);
+     }
+ 
+     const void *data() const
+     {
+         Q_ASSERT(size == 0
+                 || offset < 0 || size_t(offset) >= sizeof(QArrayData));
+-        return reinterpret_cast<const char *>(this) + offset;
++        return reinterpret_cast<void *> (reinterpret_cast<uintptr_t>(this) + offset);
+     }
+ 
+     // This refers to array data mutability, not "header data" represented by
+diff --git a/qtbase/src/corelib/tools/qfreelist_p.h b/qtbase/src/corelib/tools/qfreelist_p.h
+index 5ba23b344b..9974102136 100644
+--- a/qtbase/src/corelib/tools/qfreelist_p.h
++++ b/qtbase/src/corelib/tools/qfreelist_p.h
+@@ -161,7 +161,7 @@ class QFreeList
+                 return i;
+             x -= size;
+         }
+-        Q_ASSERT(false);
++        Q_UNREACHABLE();
+         return -1;
+     }
+ 
+diff --git a/qtbase/src/corelib/tools/qversionnumber.h b/qtbase/src/corelib/tools/qversionnumber.h
+index d43b86ba51..2843f2b043 100644
+--- a/qtbase/src/corelib/tools/qversionnumber.h
++++ b/qtbase/src/corelib/tools/qversionnumber.h
+@@ -273,10 +273,10 @@ public:
+ 
+     Q_REQUIRED_RESULT Q_CORE_EXPORT QString toString() const;
+ #if QT_STRINGVIEW_LEVEL < 2
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(const QString &string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(const QString &string, int *suffixIndex = nullptr);
+ #endif
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QLatin1String string, int *suffixIndex = nullptr);
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QStringView string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(QLatin1String string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(QStringView string, int *suffixIndex = nullptr);
+ 
+ private:
+ #ifndef QT_NO_DATASTREAM
+diff --git a/qtbase/src/dbus/qdbusintegrator.cpp b/qtbase/src/dbus/qdbusintegrator.cpp
+index 5b66ce971b..28a3b0ffea 100644
+--- a/qtbase/src/dbus/qdbusintegrator.cpp
++++ b/qtbase/src/dbus/qdbusintegrator.cpp
+@@ -1135,7 +1135,13 @@ void QDBusConnectionPrivate::closeConnection()
+         }
+     }
+ 
+-    qDeleteAll(pendingCalls);
++    for (auto it = pendingCalls.begin(); it != pendingCalls.end(); ++it) {
++        auto call = *it;
++        if (!call->ref.deref()) {
++            delete call;
++        }
++    }
++    pendingCalls.clear();
+ 
+     // Disconnect all signals from signal hooks and from the object tree to
+     // avoid QObject::destroyed being sent to dbus daemon thread which has
+@@ -2584,6 +2590,11 @@ QDBusConnectionPrivate::findMetaObject(const QString &service, const QString &pa
+         if (mo)
+             return mo;
+     }
++    if (path.isEmpty()) {
++        error = QDBusError(QDBusError::InvalidObjectPath, QLatin1String("Object path cannot be empty"));
++        lastError = error;
++        return nullptr;
++    }
+ 
+     // introspect the target object
+     QDBusMessage msg = QDBusMessage::createMethodCall(service, path,
+diff --git a/qtbase/src/dbus/qdbusmetaobject.cpp b/qtbase/src/dbus/qdbusmetaobject.cpp
+index 5265568f42..7e9f0f1acc 100644
+--- a/qtbase/src/dbus/qdbusmetaobject.cpp
++++ b/qtbase/src/dbus/qdbusmetaobject.cpp
+@@ -210,6 +210,9 @@ QDBusMetaObjectGenerator::findType(const QByteArray &signature,
+         } else if (signature == "a{ss}") {
+             result.name = "QMap<QString,QString>";
+             type = qMetaTypeId<QMap<QString, QString> >();
++        } else if (signature == "aay") {
++            result.name = "QByteArrayList";
++            type = qMetaTypeId<QByteArrayList>();
+         } else {
+             result.name = "{D-Bus type \"" + signature + "\"}";
+             type = registerComplexDBusType(result.name);
+diff --git a/qtbase/src/gui/accessible/qaccessible.cpp b/qtbase/src/gui/accessible/qaccessible.cpp
+index d705bfccb5..0caf3c808c 100644
+--- a/qtbase/src/gui/accessible/qaccessible.cpp
++++ b/qtbase/src/gui/accessible/qaccessible.cpp
+@@ -54,6 +54,7 @@
+ #include <QtCore/qdebug.h>
+ #include <QtCore/qloggingcategory.h>
+ #include <QtCore/qmetaobject.h>
++#include <QtCore/private/qmetaobject_p.h>
+ #include <QtCore/qhash.h>
+ #include <private/qfactoryloader_p.h>
+ 
+@@ -681,6 +682,25 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
+     // Create a QAccessibleInterface for the object class. Start by the most
+     // derived class and walk up the class hierarchy.
+     const QMetaObject *mo = object->metaObject();
++    const auto *objectPriv = QObjectPrivate::get(object);
++    /*
++     We do not want to cache each and every QML metaobject (Button_QMLTYPE_124,
++     Button_QMLTYPE_125, etc.). Those dynamic metaobjects shouldn't have an
++     accessible interface in any case. Instead, we start the whole checking
++     with the first non-dynamic meta-object. To avoid potential regressions
++     in other areas of Qt that also use dynamic metaobjects, we only do this
++     for objects that are QML-related (approximated by checking whether they
++     have ddata set).
++    */
++    const bool qmlRelated = !objectPriv->isDeletingChildren &&
++                            objectPriv->declarativeData;
++    while (qmlRelated && mo) {
++        auto mop = QMetaObjectPrivate::get(mo);
++        if (!mop || !(mop->flags & DynamicMetaObject))
++            break;
++
++        mo = mo->superClass();
++    };
+     while (mo) {
+         const QString cn = QLatin1String(mo->className());
+ 
+@@ -696,14 +716,15 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
+         // Find a QAccessiblePlugin (factory) for the class name. If there's
+         // no entry in the cache try to create it using the plugin loader.
+         if (!qAccessiblePlugins()->contains(cn)) {
++            QAccessiblePlugin *factory = nullptr; // 0 means "no plugin found". This is cached as well.
+             const int index = loader()->indexOf(cn);
+-            if (index != -1) {
+-                QAccessiblePlugin *factory = qobject_cast<QAccessiblePlugin *>(loader()->instance(index));
+-                qAccessiblePlugins()->insert(cn, factory);
+-            }
++            if (index != -1)
++                factory = qobject_cast<QAccessiblePlugin *>(loader()->instance(index));
++            qAccessiblePlugins()->insert(cn, factory);
+         }
+ 
+         // At this point the cache should contain a valid factory pointer or 0:
++        Q_ASSERT(qAccessiblePlugins()->contains(cn));
+         QAccessiblePlugin *factory = qAccessiblePlugins()->value(cn);
+         if (factory) {
+             QAccessibleInterface *result = factory->create(cn, object);
+diff --git a/qtbase/src/gui/configure.json b/qtbase/src/gui/configure.json
+index 1f08795c57..12c95742d2 100644
+--- a/qtbase/src/gui/configure.json
++++ b/qtbase/src/gui/configure.json
+@@ -834,7 +834,8 @@
+                     "// embedded devices, are not intended to be used together with X. EGL support",
+                     "// has to be disabled in plugins like xcb in this case since the native display,",
+                     "// window and pixmap types will be different than what an X-based platform",
+-                    "// plugin would expect."
++                    "// plugin would expect.",
++                    "#define USE_X11"
+                 ],
+                 "include": [ "EGL/egl.h", "X11/Xlib.h" ],
+                 "main": [
+diff --git a/qtbase/src/gui/image/qbmphandler.cpp b/qtbase/src/gui/image/qbmphandler.cpp
+index 96f1e8cb1d..0e73bbbdb0 100644
+--- a/qtbase/src/gui/image/qbmphandler.cpp
++++ b/qtbase/src/gui/image/qbmphandler.cpp
+@@ -150,16 +150,42 @@ static QDataStream &operator<<(QDataStream &s, const BMP_INFOHDR &bi)
+     return s;
+ }
+ 
+-static int calc_shift(uint mask)
++static uint calc_shift(uint mask)
+ {
+-    int result = 0;
+-    while (mask && !(mask & 1)) {
++    uint result = 0;
++    while ((mask >= 0x100) || (!(mask & 1) && mask)) {
+         result++;
+         mask >>= 1;
+     }
+     return result;
+ }
+ 
++static uint calc_scale(uint low_mask)
++{
++    uint result = 8;
++    while (low_mask && result) {
++        result--;
++        low_mask >>= 1;
++    }
++    return result;
++}
++
++static inline uint apply_scale(uint value, uint scale)
++{
++    if (!(scale & 0x07)) // return immediately if scale == 8 or 0
++        return value;
++
++    uint filled = 8 - scale;
++    uint result = value << scale;
++
++    do {
++        result |= result >> filled;
++        filled <<= 1;
++    } while (filled < 8);
++
++    return result;
++}
++
+ static bool read_dib_fileheader(QDataStream &s, BMP_FILEHDR &bf)
+ {
+     // read BMP file header
+@@ -222,14 +248,14 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+     uint green_mask = 0;
+     uint blue_mask = 0;
+     uint alpha_mask = 0;
+-    int red_shift = 0;
+-    int green_shift = 0;
+-    int blue_shift = 0;
+-    int alpha_shift = 0;
+-    int red_scale = 0;
+-    int green_scale = 0;
+-    int blue_scale = 0;
+-    int alpha_scale = 0;
++    uint red_shift = 0;
++    uint green_shift = 0;
++    uint blue_shift = 0;
++    uint alpha_shift = 0;
++    uint red_scale = 0;
++    uint green_scale = 0;
++    uint blue_scale = 0;
++    uint alpha_scale = 0;
+ 
+     if (!d->isSequential())
+         d->seek(startpos + BMP_FILEHDR_SIZE + bi.biSize); // goto start of colormap or masks
+@@ -308,19 +334,19 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+         red_shift = calc_shift(red_mask);
+         if (((red_mask >> red_shift) + 1) == 0)
+             return false;
+-        red_scale = 256 / ((red_mask >> red_shift) + 1);
++        red_scale = calc_scale(red_mask >> red_shift);
+         green_shift = calc_shift(green_mask);
+         if (((green_mask >> green_shift) + 1) == 0)
+             return false;
+-        green_scale = 256 / ((green_mask >> green_shift) + 1);
++        green_scale = calc_scale(green_mask >> green_shift);
+         blue_shift = calc_shift(blue_mask);
+         if (((blue_mask >> blue_shift) + 1) == 0)
+             return false;
+-        blue_scale = 256 / ((blue_mask >> blue_shift) + 1);
++        blue_scale = calc_scale(blue_mask >> blue_shift);
+         alpha_shift = calc_shift(alpha_mask);
+         if (((alpha_mask >> alpha_shift) + 1) == 0)
+             return false;
+-        alpha_scale = 256 / ((alpha_mask >> alpha_shift) + 1);
++        alpha_scale = calc_scale(alpha_mask >> alpha_shift);
+     } else if (comp == BMP_RGB && (nbits == 24 || nbits == 32)) {
+         blue_mask = 0x000000ff;
+         green_mask = 0x0000ff00;
+@@ -328,17 +354,15 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+         blue_shift = 0;
+         green_shift = 8;
+         red_shift = 16;
+-        blue_scale = green_scale = red_scale = 1;
++        blue_scale = green_scale = red_scale = 0;
+     } else if (comp == BMP_RGB && nbits == 16) {
+         blue_mask = 0x001f;
+         green_mask = 0x03e0;
+         red_mask = 0x7c00;
+         blue_shift = 0;
+-        green_shift = 2;
+-        red_shift = 7;
+-        red_scale = 1;
+-        green_scale = 1;
+-        blue_scale = 8;
++        green_shift = 5;
++        red_shift = 10;
++        blue_scale = green_scale = red_scale = 3;
+     }
+ 
+ #if 0
+@@ -544,10 +568,10 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+                     c |= *(uchar*)(b+2)<<16;
+                 if (nbits > 24)
+                     c |= *(uchar*)(b+3)<<24;
+-                *p++ = qRgba(((c & red_mask) >> red_shift) * red_scale,
+-                                        ((c & green_mask) >> green_shift) * green_scale,
+-                                        ((c & blue_mask) >> blue_shift) * blue_scale,
+-                                        transp ? ((c & alpha_mask) >> alpha_shift) * alpha_scale : 0xff);
++                *p++ = qRgba(apply_scale((c & red_mask) >> red_shift, red_scale),
++                             apply_scale((c & green_mask) >> green_shift, green_scale),
++                             apply_scale((c & blue_mask) >> blue_shift, blue_scale),
++                             transp ? apply_scale((c & alpha_mask) >> alpha_shift, alpha_scale) : 0xff);
+                 b += nbits/8;
+             }
+         }
+diff --git a/qtbase/src/gui/image/qimage.cpp b/qtbase/src/gui/image/qimage.cpp
+index 7152ac1607..0df772564c 100644
+--- a/qtbase/src/gui/image/qimage.cpp
++++ b/qtbase/src/gui/image/qimage.cpp
+@@ -4694,6 +4694,8 @@ QImage QImage::smoothScaled(int w, int h) const {
+ static QImage rotated90(const QImage &image)
+ {
+     QImage out(image.height(), image.width(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+@@ -4722,6 +4724,8 @@ static QImage rotated180(const QImage &image)
+         return image.mirrored(true, true);
+ 
+     QImage out(image.width(), image.height(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+@@ -4734,6 +4738,8 @@ static QImage rotated180(const QImage &image)
+ static QImage rotated270(const QImage &image)
+ {
+     QImage out(image.height(), image.width(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+diff --git a/qtbase/src/gui/kernel/qcursor.cpp b/qtbase/src/gui/kernel/qcursor.cpp
+index d6ccaff8ed..455088241c 100644
+--- a/qtbase/src/gui/kernel/qcursor.cpp
++++ b/qtbase/src/gui/kernel/qcursor.cpp
+@@ -251,7 +251,8 @@ void QCursor::setPos(QScreen *screen, int x, int y)
+ {
+     if (screen) {
+         if (QPlatformCursor *cursor = screen->handle()->cursor()) {
+-            const QPoint devicePos = QHighDpi::toNativePixels(QPoint(x, y), screen);
++            const QPoint pos(x, y);
++            const QPoint devicePos = QHighDpi::toNativePixels(pos, screen->virtualSiblingAt(pos));
+             // Need to check, since some X servers generate null mouse move
+             // events, causing looping in applications which call setPos() on
+             // every mouse move event.
+diff --git a/qtbase/src/gui/kernel/qhighdpiscaling.cpp b/qtbase/src/gui/kernel/qhighdpiscaling.cpp
+index 9bbf2773a9..3ac4a4d8b6 100644
+--- a/qtbase/src/gui/kernel/qhighdpiscaling.cpp
++++ b/qtbase/src/gui/kernel/qhighdpiscaling.cpp
+@@ -580,9 +580,8 @@ void QHighDpiScaling::setScreenFactor(QScreen *screen, qreal factor)
+     else
+         qNamedScreenScaleFactors()->insert(name, factor);
+ 
+-    // hack to force re-evaluation of screen geometry
+     if (screen->handle())
+-        screen->d_func()->setPlatformScreen(screen->handle()); // updates geometries based on scale factor
++        screen->d_func()->updateLogicalDpi();
+ }
+ 
+ QPoint QHighDpiScaling::mapPositionToNative(const QPoint &pos, const QPlatformScreen *platformScreen)
+diff --git a/qtbase/src/gui/kernel/qkeysequence.cpp b/qtbase/src/gui/kernel/qkeysequence.cpp
+index a75b8ef920..4f2d294739 100644
+--- a/qtbase/src/gui/kernel/qkeysequence.cpp
++++ b/qtbase/src/gui/kernel/qkeysequence.cpp
+@@ -701,6 +701,10 @@ static const struct {
+     { Qt::Key_TouchpadToggle,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad Toggle") },
+     { Qt::Key_TouchpadOn,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad On") },
+     { Qt::Key_TouchpadOff,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad Off") },
++    { Qt::Key_Shift,  QT_TRANSLATE_NOOP("QShortcut", "Shift") },
++    { Qt::Key_Control,  QT_TRANSLATE_NOOP("QShortcut", "Control") },
++    { Qt::Key_Alt,  QT_TRANSLATE_NOOP("QShortcut", "Alt") },
++    { Qt::Key_Meta,  QT_TRANSLATE_NOOP("QShortcut", "Meta") },
+ 
+ };
+ static Q_CONSTEXPR int numKeyNames = sizeof keyname / sizeof *keyname;
+diff --git a/qtbase/src/gui/kernel/qplatformservices.cpp b/qtbase/src/gui/kernel/qplatformservices.cpp
+index fdc6a6c4aa..ac47f98c5d 100644
+--- a/qtbase/src/gui/kernel/qplatformservices.cpp
++++ b/qtbase/src/gui/kernel/qplatformservices.cpp
+@@ -55,6 +55,19 @@ QT_BEGIN_NAMESPACE
+     \brief The QPlatformServices provides the backend for desktop-related functionality.
+ */
+ 
++/*!
++    \enum QPlatformServices::Capability
++
++    Capabilities are used to determine a specific platform service's availability.
++
++    \value ColorPickingFromScreen The platform natively supports color picking from screen.
++    This capability indicates that the platform supports "opaque" color picking, where the
++    platform implements a complete user experience for color picking and outputs a color.
++    This is in contrast to the application implementing the color picking user experience
++    (taking care of showing a cross hair, instructing the platform integration to obtain
++    the color at a given pixel, etc.). The related service function is pickColor().
++ */
++
+ QPlatformServices::QPlatformServices()
+ { }
+ 
+@@ -85,5 +98,16 @@ QByteArray QPlatformServices::desktopEnvironment() const
+     return QByteArray("UNKNOWN");
+ }
+ 
++QPlatformServiceColorPicker *QPlatformServices::colorPicker(QWindow *parent)
++{
++    Q_UNUSED(parent);
++    return nullptr;
++}
++
++bool QPlatformServices::hasCapability(Capability capability) const
++{
++    Q_UNUSED(capability)
++    return false;
++}
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/gui/kernel/qplatformservices.h b/qtbase/src/gui/kernel/qplatformservices.h
+index 5de96cfa7d..a8b2a4ce71 100644
+--- a/qtbase/src/gui/kernel/qplatformservices.h
++++ b/qtbase/src/gui/kernel/qplatformservices.h
+@@ -50,16 +50,32 @@
+ //
+ 
+ #include <QtGui/qtguiglobal.h>
++#include <QtCore/qobject.h>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+ class QUrl;
++class QWindow;
++
++class Q_GUI_EXPORT QPlatformServiceColorPicker : public QObject
++{
++    Q_OBJECT
++public:
++    using QObject::QObject;
++    virtual void pickColor() = 0;
++Q_SIGNALS:
++    void colorPicked(const QColor &color);
++};
+ 
+ class Q_GUI_EXPORT QPlatformServices
+ {
+ public:
+     Q_DISABLE_COPY_MOVE(QPlatformServices)
+ 
++    enum Capability {
++        ColorPicking,
++    };
++
+     QPlatformServices();
+     virtual ~QPlatformServices() { }
+ 
+@@ -67,6 +83,10 @@ public:
+     virtual bool openDocument(const QUrl &url);
+ 
+     virtual QByteArray desktopEnvironment() const;
++
++    virtual bool hasCapability(Capability capability) const;
++
++    virtual QPlatformServiceColorPicker *colorPicker(QWindow *parent = nullptr);
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/gui/kernel/qplatformtheme.cpp b/qtbase/src/gui/kernel/qplatformtheme.cpp
+index 71521c0339..2325873245 100644
+--- a/qtbase/src/gui/kernel/qplatformtheme.cpp
++++ b/qtbase/src/gui/kernel/qplatformtheme.cpp
+@@ -163,6 +163,8 @@ QT_BEGIN_NAMESPACE
+ 
+     \value ShowShortcutsInContextMenus (bool) Whether to display shortcut key sequences in context menus.
+ 
++    \value ButtonPressKeys (QList<Qt::Key>) A list of keys that can be used to press buttons via keyboard input.
++
+     \sa themeHint(), QStyle::pixelMetric()
+ */
+ 
+@@ -563,6 +565,8 @@ QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint)
+         }
+     case MouseQuickSelectionThreshold:
+         return QVariant(10);
++    case ButtonPressKeys:
++        return QVariant::fromValue(QList<Qt::Key>({ Qt::Key_Space, Qt::Key_Select }));
+     }
+     return QVariant();
+ }
+diff --git a/qtbase/src/gui/kernel/qplatformtheme.h b/qtbase/src/gui/kernel/qplatformtheme.h
+index 3185fc4541..7e6c9d5740 100644
+--- a/qtbase/src/gui/kernel/qplatformtheme.h
++++ b/qtbase/src/gui/kernel/qplatformtheme.h
+@@ -120,7 +120,8 @@ public:
+         TouchDoubleTapDistance,
+         ShowShortcutsInContextMenus,
+         IconFallbackSearchPaths,
+-        MouseQuickSelectionThreshold
++        MouseQuickSelectionThreshold,
++        ButtonPressKeys
+     };
+ 
+     enum DialogType {
+diff --git a/qtbase/src/gui/kernel/qscreen.cpp b/qtbase/src/gui/kernel/qscreen.cpp
+index 8e0eb35116..5d172a58dd 100644
+--- a/qtbase/src/gui/kernel/qscreen.cpp
++++ b/qtbase/src/gui/kernel/qscreen.cpp
+@@ -77,6 +77,12 @@ QScreen::QScreen(QPlatformScreen *screen)
+     d->setPlatformScreen(screen);
+ }
+ 
++void QScreenPrivate::updateLogicalDpi()
++{
++    logicalDpi = QPlatformScreen::overrideDpi(platformScreen->logicalDpi());
++    updateGeometriesWithSignals(); // updates geometries based on scale factor
++}
++
+ void QScreenPrivate::updateGeometriesWithSignals()
+ {
+     const QRect oldGeometry = geometry;
+diff --git a/qtbase/src/gui/kernel/qscreen_p.h b/qtbase/src/gui/kernel/qscreen_p.h
+index 7da542c25e..e50fc3190b 100644
+--- a/qtbase/src/gui/kernel/qscreen_p.h
++++ b/qtbase/src/gui/kernel/qscreen_p.h
+@@ -70,6 +70,7 @@ public:
+         geometry = platformScreen->deviceIndependentGeometry();
+         availableGeometry = QHighDpi::fromNative(platformScreen->availableGeometry(), QHighDpiScaling::factor(platformScreen), geometry.topLeft());
+     }
++    void updateLogicalDpi();
+ 
+     void updatePrimaryOrientation();
+     void updateGeometriesWithSignals();
+diff --git a/qtbase/src/gui/painting/qblendfunctions_p.h b/qtbase/src/gui/painting/qblendfunctions_p.h
+index 080da98ec4..6997d62b3c 100644
+--- a/qtbase/src/gui/painting/qblendfunctions_p.h
++++ b/qtbase/src/gui/painting/qblendfunctions_p.h
+@@ -246,25 +246,32 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+                                   int dudx, int dvdx, int dudy, int dvdy, int u0, int v0,
+                                   Blender blender)
+ {
+-    int fromY = qMax(qRound(topY), clip.top());
+-    int toY = qMin(qRound(bottomY), clip.top() + clip.height());
++    qint64 fromY = qMax(qRound(topY), clip.top());
++    qint64 toY = qMin(qRound(bottomY), clip.top() + clip.height());
+     if (fromY >= toY)
+         return;
+ 
+     qreal leftSlope = (bottomLeft.x - topLeft.x) / (bottomLeft.y - topLeft.y);
+     qreal rightSlope = (bottomRight.x - topRight.x) / (bottomRight.y - topRight.y);
+-    int dx_l = int(leftSlope * 0x10000);
+-    int dx_r = int(rightSlope * 0x10000);
+-    int x_l = int((topLeft.x + (qreal(0.5) + fromY - topLeft.y) * leftSlope + qreal(0.5)) * 0x10000);
+-    int x_r = int((topRight.x + (qreal(0.5) + fromY - topRight.y) * rightSlope + qreal(0.5)) * 0x10000);
+-
+-    int fromX, toX, x1, x2, u, v, i, ii;
++    qint64 dx_l = qint64(leftSlope * 0x10000);
++    qint64 dx_r = qint64(rightSlope * 0x10000);
++    qint64 x_l = qint64((topLeft.x + (qreal(0.5) + fromY - topLeft.y) * leftSlope + qreal(0.5)) * 0x10000);
++    qint64 x_r = qint64((topRight.x + (qreal(0.5) + fromY - topRight.y) * rightSlope + qreal(0.5)) * 0x10000);
++
++    qint64 sourceRectTop = qint64(sourceRect.top());
++    qint64 sourceRectLeft = qint64(sourceRect.left());
++    qint64 sourceRectWidth = qint64(sourceRect.width());
++    qint64 sourceRectHeight = qint64(sourceRect.height());
++    qint64 clipLeft = qint64(clip.left());
++    qint64 clipWidth = qint64(clip.width());
++
++    qint64 fromX, toX, x1, x2, u, v, i, ii;
+     DestT *line;
+-    for (int y = fromY; y < toY; ++y) {
++    for (qint64 y = fromY; y < toY; ++y) {
+         line = reinterpret_cast<DestT *>(reinterpret_cast<uchar *>(destPixels) + y * dbpl);
+ 
+-        fromX = qMax(x_l >> 16, clip.left());
+-        toX = qMin(x_r >> 16, clip.left() + clip.width());
++        fromX = qMax(x_l >> 16, clipLeft);
++        toX = qMin(x_r >> 16, clipLeft + clipWidth);
+         if (fromX < toX) {
+             // Because of rounding, we can get source coordinates outside the source image.
+             // Clamp these coordinates to the source rect to avoid segmentation fault and
+@@ -275,10 +282,10 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             u = x1 * dudx + y * dudy + u0;
+             v = x1 * dvdx + y * dvdy + v0;
+             for (; x1 < toX; ++x1) {
+-                int uu = u >> 16;
+-                int vv = v >> 16;
+-                if (uu >= sourceRect.left() && uu < sourceRect.left() + sourceRect.width()
+-                    && vv >= sourceRect.top() && vv < sourceRect.top() + sourceRect.height()) {
++                qint64 uu = u >> 16;
++                qint64 vv = v >> 16;
++                if (uu >= sourceRectLeft && uu < sourceRectLeft + sourceRectWidth
++                    && vv >= sourceRectTop && vv < sourceRectTop + sourceRectHeight) {
+                     break;
+                 }
+                 u += dudx;
+@@ -290,10 +297,10 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             u = (x2 - 1) * dudx + y * dudy + u0;
+             v = (x2 - 1) * dvdx + y * dvdy + v0;
+             for (; x2 > x1; --x2) {
+-                int uu = u >> 16;
+-                int vv = v >> 16;
+-                if (uu >= sourceRect.left() && uu < sourceRect.left() + sourceRect.width()
+-                    && vv >= sourceRect.top() && vv < sourceRect.top() + sourceRect.height()) {
++                qint64 uu = u >> 16;
++                qint64 vv = v >> 16;
++                if (uu >= sourceRectLeft && uu < sourceRectLeft + sourceRectWidth
++                    && vv >= sourceRectTop && vv < sourceRectTop + sourceRectHeight) {
+                     break;
+                 }
+                 u -= dudx;
+@@ -308,8 +315,8 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             // Beginning of the scan line, with per-pixel checks.
+             i = x1 - fromX;
+             while (i) {
+-                int uu = qBound(sourceRect.left(), u >> 16, sourceRect.left() + sourceRect.width() - 1);
+-                int vv = qBound(sourceRect.top(), v >> 16, sourceRect.top() + sourceRect.height() - 1);
++                qint64 uu = qBound(sourceRectLeft, u >> 16, sourceRectLeft + sourceRectWidth - 1);
++                qint64 vv = qBound(sourceRectTop, v >> 16, sourceRectTop + sourceRectHeight - 1);
+                 blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + vv * sbpl)[uu]);
+                 u += dudx;
+                 v += dvdx;
+@@ -348,8 +355,8 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             // End of the scan line, with per-pixel checks.
+             i = toX - x2;
+             while (i) {
+-                int uu = qBound(sourceRect.left(), u >> 16, sourceRect.left() + sourceRect.width() - 1);
+-                int vv = qBound(sourceRect.top(), v >> 16, sourceRect.top() + sourceRect.height() - 1);
++                qint64 uu = qBound(sourceRectLeft, u >> 16, sourceRectLeft + sourceRectWidth - 1);
++                qint64 vv = qBound(sourceRectTop, v >> 16, sourceRectTop + sourceRectHeight - 1);
+                 blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + vv * sbpl)[uu]);
+                 u += dudx;
+                 v += dvdx;
+diff --git a/qtbase/src/gui/painting/qcolortrclut_p.h b/qtbase/src/gui/painting/qcolortrclut_p.h
+index 76a6a60803..24fd522e6c 100644
+--- a/qtbase/src/gui/painting/qcolortrclut_p.h
++++ b/qtbase/src/gui/painting/qcolortrclut_p.h
+@@ -118,6 +118,7 @@ public:
+         return QRgba64::fromRgba64(r, g, b, qAlpha(rgb32) * 257);
+ #endif
+     }
++    QRgba64 toLinear64(QRgba64) const = delete;
+ 
+     QRgb toLinear(QRgb rgb32) const
+     {
+diff --git a/qtbase/src/gui/painting/qdrawhelper.cpp b/qtbase/src/gui/painting/qdrawhelper.cpp
+index a61793508a..5ba2d277b7 100644
+--- a/qtbase/src/gui/painting/qdrawhelper.cpp
++++ b/qtbase/src/gui/painting/qdrawhelper.cpp
+@@ -6091,7 +6091,7 @@ static inline void alphargbblend_argb32(quint32 *dst, uint coverage, const QRgba
+ static inline void rgbBlendPixel(QRgba64 &dst, int coverage, QRgba64 slinear, const QColorTrcLut *colorProfile)
+ {
+     // Do a gammacorrected RGB alphablend...
+-    const QRgba64 dlinear = colorProfile ? colorProfile->toLinear64(dst) : dst;
++    const QRgba64 dlinear = colorProfile ? colorProfile->toLinear(dst) : dst;
+ 
+     QRgba64 blend = rgbBlend(dlinear, slinear, coverage);
+ 
+diff --git a/qtbase/src/gui/painting/qpaintengine_raster.cpp b/qtbase/src/gui/painting/qpaintengine_raster.cpp
+index 283923de52..f08eb9cbee 100644
+--- a/qtbase/src/gui/painting/qpaintengine_raster.cpp
++++ b/qtbase/src/gui/painting/qpaintengine_raster.cpp
+@@ -560,31 +560,6 @@ void QRasterPaintEngine::updateMatrix(const QTransform &matrix)
+     QRasterPaintEngineState *s = state();
+     // FALCON: get rid of this line, see drawImage call below.
+     s->matrix = matrix;
+-    QTransform::TransformationType txop = s->matrix.type();
+-
+-    switch (txop) {
+-
+-    case QTransform::TxNone:
+-        s->flags.int_xform = true;
+-        break;
+-
+-    case QTransform::TxTranslate:
+-        s->flags.int_xform = qreal(int(s->matrix.dx())) == s->matrix.dx()
+-                            && qreal(int(s->matrix.dy())) == s->matrix.dy();
+-        break;
+-
+-    case QTransform::TxScale:
+-        s->flags.int_xform = qreal(int(s->matrix.dx())) == s->matrix.dx()
+-                            && qreal(int(s->matrix.dy())) == s->matrix.dy()
+-                            && qreal(int(s->matrix.m11())) == s->matrix.m11()
+-                            && qreal(int(s->matrix.m22())) == s->matrix.m22();
+-        break;
+-
+-    default: // shear / perspective...
+-        s->flags.int_xform = false;
+-        break;
+-    }
+-
+     s->flags.tx_noshear = qt_scaleForTransform(s->matrix, &s->txscale);
+ 
+     ensureOutlineMapper();
+@@ -617,7 +592,6 @@ QRasterPaintEngineState::QRasterPaintEngineState()
+     flags.bilinear = false;
+     flags.legacy_rounding = false;
+     flags.fast_text = true;
+-    flags.int_xform = true;
+     flags.tx_noshear = true;
+     flags.fast_images = true;
+ 
+@@ -1793,7 +1767,7 @@ void QRasterPaintEngine::fill(const QVectorPath &path, const QBrush &brush)
+     QRectF cpRect = path.controlPointRect();
+     const QRectF pathDeviceRect = s->matrix.mapRect(cpRect);
+     // Skip paths that by conservative estimates are completely outside the paint device.
+-    if (!pathDeviceRect.intersects(QRectF(d->deviceRect)))
++    if (!pathDeviceRect.intersects(QRectF(d->deviceRect)) || !pathDeviceRect.isValid())
+         return;
+ 
+     ProcessSpans blend = d->getBrushFunc(pathDeviceRect, &s->brushData);
+diff --git a/qtbase/src/gui/painting/qpaintengine_raster_p.h b/qtbase/src/gui/painting/qpaintengine_raster_p.h
+index 089aadc3f7..bf7363d5aa 100644
+--- a/qtbase/src/gui/painting/qpaintengine_raster_p.h
++++ b/qtbase/src/gui/painting/qpaintengine_raster_p.h
+@@ -111,7 +111,6 @@ public:
+         uint bilinear : 1;
+         uint legacy_rounding : 1;
+         uint fast_text : 1;
+-        uint int_xform : 1;
+         uint tx_noshear : 1;
+         uint fast_images : 1;
+     };
+diff --git a/qtbase/src/gui/painting/qpainterpath.cpp b/qtbase/src/gui/painting/qpainterpath.cpp
+index f9544a3241..d80fafeaf1 100644
+--- a/qtbase/src/gui/painting/qpainterpath.cpp
++++ b/qtbase/src/gui/painting/qpainterpath.cpp
+@@ -1253,7 +1253,7 @@ void QPainterPath::addText(const QPointF &point, const QFont &f, const QString &
+ 
+         if (si.analysis.flags < QScriptAnalysis::TabOrObject) {
+             QGlyphLayout glyphs = eng->shapedGlyphs(&si);
+-            QFontEngine *fe = f.d->engineForScript(si.analysis.script);
++            QFontEngine *fe = eng->fontEngine(si);
+             Q_ASSERT(fe);
+             fe->addOutlineToPath(x, y, glyphs, this,
+                                  si.analysis.bidiLevel % 2
+diff --git a/qtbase/src/gui/painting/qpathclipper_p.h b/qtbase/src/gui/painting/qpathclipper_p.h
+index 9444a87b71..18f64c5e8c 100644
+--- a/qtbase/src/gui/painting/qpathclipper_p.h
++++ b/qtbase/src/gui/painting/qpathclipper_p.h
+@@ -156,7 +156,7 @@ public:
+     int vertex(Direction direction) const;
+ 
+ private:
+-    int m_next[2][2];
++    int m_next[2][2] = { { -1, -1 }, { -1, -1 } };
+ };
+ 
+ class QPathSegments
+@@ -296,10 +296,6 @@ inline QPathEdge::QPathEdge(int a, int b)
+     , angle(0)
+     , invAngle(0)
+ {
+-    m_next[0][0] = -1;
+-    m_next[1][0] = -1;
+-    m_next[0][0] = -1;
+-    m_next[1][0] = -1;
+ }
+ 
+ inline int QPathEdge::next(Traversal traversal, Direction direction) const
+diff --git a/qtbase/src/gui/painting/qpdf.cpp b/qtbase/src/gui/painting/qpdf.cpp
+index 3066744f1b..2c8d3c3b53 100644
+--- a/qtbase/src/gui/painting/qpdf.cpp
++++ b/qtbase/src/gui/painting/qpdf.cpp
+@@ -2760,6 +2760,8 @@ int QPdfEnginePrivate::addBrushPattern(const QTransform &m, bool *specifyColor,
+         return gradientBrush(brush, matrix, gStateObject);
+     }
+ 
++    matrix = brush.transform() * matrix;
++
+     if ((!brush.isOpaque() && brush.style() < Qt::LinearGradientPattern) || opacity != 1.0)
+         *gStateObject = addConstantAlphaObject(qRound(brush.color().alpha() * opacity),
+                                                qRound(pen.color().alpha() * opacity));
+diff --git a/qtbase/src/gui/painting/qstroker.cpp b/qtbase/src/gui/painting/qstroker.cpp
+index cb5d395e80..3b6357a893 100644
+--- a/qtbase/src/gui/painting/qstroker.cpp
++++ b/qtbase/src/gui/painting/qstroker.cpp
+@@ -1182,6 +1182,7 @@ void QDashStroker::processCurrentSubpath()
+         // Check if the entire line should be clipped away or simplified
+         bool clipIt = clipping && !lineIntersectsRect(prev, e, clip_tl, clip_br);
+         bool skipDashing = elen * invSumLength > repetitionLimit();
++        int maxDashes = dashCount;
+         if (skipDashing || clipIt) {
+             // Cut away full dash sequences.
+             elen -= std::floor(elen * invSumLength) * sumLength;
+@@ -1196,7 +1197,7 @@ void QDashStroker::processCurrentSubpath()
+                     pos = estop; // move pos to next path element
+                     done = true;
+                 } else { // Dash is on this line
+-                    pos = dpos + estart;
++                    pos = --maxDashes > 0 ? dpos + estart : estop;
+                     done = pos >= estop;
+                     if (++idash >= dashCount)
+                         idash = 0;
+diff --git a/qtbase/src/gui/painting/qt_attribution.json b/qtbase/src/gui/painting/qt_attribution.json
+index 7b16e8c211..0e87d30aa2 100644
+--- a/qtbase/src/gui/painting/qt_attribution.json
++++ b/qtbase/src/gui/painting/qt_attribution.json
+@@ -10,7 +10,7 @@
+         "Homepage": "http://www.freetype.org",
+         "License": "Freetype Project License or GNU General Public License v2.0 only",
+         "LicenseId": "FTL or GPL-2.0",
+-        "LicenseFile": "../../3rdparty/freetype/docs/LICENSE.TXT",
++        "LicenseFile": "../../3rdparty/freetype/LICENSE.TXT",
+         "Copyright": "Copyright 2000-2016 by David Turner, Robert Wilhelm, and Werner Lemberg."
+     },
+     {
+diff --git a/qtbase/src/gui/rhi/qshader_p_p.h b/qtbase/src/gui/rhi/qshader_p_p.h
+index ec9d25971f..4a5a7a6d51 100644
+--- a/qtbase/src/gui/rhi/qshader_p_p.h
++++ b/qtbase/src/gui/rhi/qshader_p_p.h
+@@ -68,13 +68,13 @@ struct Q_GUI_EXPORT QShaderPrivate
+     {
+     }
+ 
+-    QShaderPrivate(const QShaderPrivate *other)
++    QShaderPrivate(const QShaderPrivate &other)
+         : ref(1),
+-          qsbVersion(other->qsbVersion),
+-          stage(other->stage),
+-          desc(other->desc),
+-          shaders(other->shaders),
+-          bindings(other->bindings)
++          qsbVersion(other.qsbVersion),
++          stage(other.stage),
++          desc(other.desc),
++          shaders(other.shaders),
++          bindings(other.bindings)
+     {
+     }
+ 
+diff --git a/qtbase/src/gui/rhi/qshaderdescription_p_p.h b/qtbase/src/gui/rhi/qshaderdescription_p_p.h
+index ec2b0b6b4c..3da33a8a2b 100644
+--- a/qtbase/src/gui/rhi/qshaderdescription_p_p.h
++++ b/qtbase/src/gui/rhi/qshaderdescription_p_p.h
+@@ -63,16 +63,16 @@ struct Q_GUI_EXPORT QShaderDescriptionPrivate
+         localSize[0] = localSize[1] = localSize[2] = 0;
+     }
+ 
+-    QShaderDescriptionPrivate(const QShaderDescriptionPrivate *other)
++    QShaderDescriptionPrivate(const QShaderDescriptionPrivate &other)
+         : ref(1),
+-          inVars(other->inVars),
+-          outVars(other->outVars),
+-          uniformBlocks(other->uniformBlocks),
+-          pushConstantBlocks(other->pushConstantBlocks),
+-          storageBlocks(other->storageBlocks),
+-          combinedImageSamplers(other->combinedImageSamplers),
+-          storageImages(other->storageImages),
+-          localSize(other->localSize)
++          inVars(other.inVars),
++          outVars(other.outVars),
++          uniformBlocks(other.uniformBlocks),
++          pushConstantBlocks(other.pushConstantBlocks),
++          storageBlocks(other.storageBlocks),
++          combinedImageSamplers(other.combinedImageSamplers),
++          storageImages(other.storageImages),
++          localSize(other.localSize)
+     {
+     }
+ 
+diff --git a/qtbase/src/gui/text/qfontdatabase.cpp b/qtbase/src/gui/text/qfontdatabase.cpp
+index a657a8c516..4fc0100958 100644
+--- a/qtbase/src/gui/text/qfontdatabase.cpp
++++ b/qtbase/src/gui/text/qfontdatabase.cpp
+@@ -983,7 +983,7 @@ QFontEngine *loadSingleEngine(int script,
+         if (style->key.stretch != 0 && request.stretch != 0
+             && (request.styleName.isEmpty() || request.styleName != style->styleName)) {
+             def.stretch = (request.stretch * 100 + style->key.stretch / 2) / style->key.stretch;
+-        } else {
++        } else if (request.stretch == QFont::AnyStretch) {
+             def.stretch = 100;
+         }
+ 
+diff --git a/qtbase/src/gui/text/qtextdocumentlayout.cpp b/qtbase/src/gui/text/qtextdocumentlayout.cpp
+index f3e6ea2100..72267e9380 100644
+--- a/qtbase/src/gui/text/qtextdocumentlayout.cpp
++++ b/qtbase/src/gui/text/qtextdocumentlayout.cpp
+@@ -2123,7 +2123,7 @@ void QTextDocumentLayoutPrivate::drawListItem(const QPointF &offset, QPainter *p
+ {
+     Q_Q(const QTextDocumentLayout);
+     const QTextBlockFormat blockFormat = bl.blockFormat();
+-    const QTextCharFormat charFormat = QTextCursor(bl).charFormat();
++    const QTextCharFormat charFormat = bl.charFormat();
+     QFont font(charFormat.font());
+     if (q->paintDevice())
+         font = QFont(font, q->paintDevice());
+diff --git a/qtbase/src/gui/text/qtextengine.cpp b/qtbase/src/gui/text/qtextengine.cpp
+index ce4abac472..a6c66e5d2d 100644
+--- a/qtbase/src/gui/text/qtextengine.cpp
++++ b/qtbase/src/gui/text/qtextengine.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2021 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtGui module of the Qt Toolkit.
+@@ -1565,6 +1565,12 @@ void QTextEngine::shapeText(int item) const
+         // Overwrite with 0 token to indicate failure
+         QGlyphLayout g = availableGlyphs(&si);
+         g.glyphs[0] = 0;
++        g.attributes[0].clusterStart = true;
++
++        ushort *log_clusters = logClusters(&si);
++        for (int i = 0; i < itemLength; ++i)
++            log_clusters[i] = 0;
++
+         return;
+     }
+ 
+diff --git a/qtbase/src/gui/util/qdesktopservices.cpp b/qtbase/src/gui/util/qdesktopservices.cpp
+index fbb63a9408..4d5fafaaa7 100644
+--- a/qtbase/src/gui/util/qdesktopservices.cpp
++++ b/qtbase/src/gui/util/qdesktopservices.cpp
+@@ -54,6 +54,8 @@
+ #include <qpa/qplatformintegration.h>
+ #include <qdir.h>
+ 
++#include <QtCore/private/qlocking_p.h>
++
+ QT_BEGIN_NAMESPACE
+ 
+ class QOpenUrlHandlerRegistry : public QObject
+@@ -81,6 +83,7 @@ Q_GLOBAL_STATIC(QOpenUrlHandlerRegistry, handlerRegistry)
+ 
+ void QOpenUrlHandlerRegistry::handlerDestroyed(QObject *handler)
+ {
++    const auto lock = qt_scoped_lock(mutex);
+     HandlerHash::Iterator it = handlers.begin();
+     while (it != handlers.end()) {
+         if (it->receiver == handler) {
+@@ -294,7 +297,8 @@ void QDesktopServices::setUrlHandler(const QString &scheme, QObject *receiver, c
+     h.name = method;
+     registry->handlers.insert(scheme.toLower(), h);
+     QObject::connect(receiver, SIGNAL(destroyed(QObject*)),
+-                     registry, SLOT(handlerDestroyed(QObject*)));
++                     registry, SLOT(handlerDestroyed(QObject*)),
++                     Qt::DirectConnection);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/gui/util/qpkmhandler.cpp b/qtbase/src/gui/util/qpkmhandler.cpp
+index e0c3b75efe..3414f9d8ba 100644
+--- a/qtbase/src/gui/util/qpkmhandler.cpp
++++ b/qtbase/src/gui/util/qpkmhandler.cpp
+@@ -57,7 +57,7 @@ struct PkmType
+     quint32 bytesPerBlock;
+ };
+ 
+-static PkmType typeMap[5] = {
++static constexpr PkmType typeMap[5] = {
+     { 0x8D64,  8 },   // GL_ETC1_RGB8_OES
+     { 0x9274,  8 },   // GL_COMPRESSED_RGB8_ETC2
+     { 0, 0 },         // unused (obsolete)
+diff --git a/qtbase/src/network/access/qnetworkreplyfileimpl.cpp b/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
+index b6be93147a..6e69b4c4d3 100644
+--- a/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
++++ b/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
+@@ -89,9 +89,10 @@ QNetworkReplyFileImpl::QNetworkReplyFileImpl(QNetworkAccessManager *manager, con
+         // we handle only local files
+         QString msg = QCoreApplication::translate("QNetworkAccessFileBackend", "Request for opening non-local file %1").arg(url.toString());
+         setError(QNetworkReply::ProtocolInvalidOperationError, msg);
++        setFinished(true); // We're finished, will emit finished() after ctor is done.
+         QMetaObject::invokeMethod(this, "errorOccurred", Qt::QueuedConnection,
+             Q_ARG(QNetworkReply::NetworkError, QNetworkReply::ProtocolInvalidOperationError));
+-        fileOpenFinished(false);
++        QMetaObject::invokeMethod(this, [this](){ fileOpenFinished(false); }, Qt::QueuedConnection);
+         return;
+     }
+ #endif
+diff --git a/qtbase/src/network/access/qnetworkreplyimpl.cpp b/qtbase/src/network/access/qnetworkreplyimpl.cpp
+index bcdf6ee2f1..3b6deb82bd 100644
+--- a/qtbase/src/network/access/qnetworkreplyimpl.cpp
++++ b/qtbase/src/network/access/qnetworkreplyimpl.cpp
+@@ -680,7 +680,7 @@ void QNetworkReplyImplPrivate::appendDownstreamData(QIODevice *data)
+     // read until EOF from data
+     if (Q_UNLIKELY(copyDevice)) {
+         qCritical("QNetworkReplyImpl: copy from QIODevice already in progress -- "
+-                  "backend probly needs to be fixed");
++                  "backend probably needs to be fixed");
+         return;
+     }
+ 
+diff --git a/qtbase/src/network/kernel/qauthenticator.cpp b/qtbase/src/network/kernel/qauthenticator.cpp
+index d9fe7bc47b..ccd04b294a 100644
+--- a/qtbase/src/network/kernel/qauthenticator.cpp
++++ b/qtbase/src/network/kernel/qauthenticator.cpp
+@@ -50,6 +50,7 @@
+ #include <qstring.h>
+ #include <qdatetime.h>
+ #include <qrandom.h>
++#include "private/qsystemlibrary_p.h"
+ 
+ #ifdef Q_OS_WIN
+ #include <qmutex.h>
+@@ -1563,7 +1564,7 @@ static bool q_SSPI_library_load()
+ 
+     // Initialize security interface
+     if (pSecurityFunctionTable == nullptr) {
+-        securityDLLHandle = LoadLibrary(L"secur32.dll");
++        securityDLLHandle = QSystemLibrary::load(L"secur32");
+         if (securityDLLHandle != nullptr) {
+             INIT_SECURITY_INTERFACE pInitSecurityInterface =
+                 reinterpret_cast<INIT_SECURITY_INTERFACE>(
+diff --git a/qtbase/src/network/kernel/qhostinfo_unix.cpp b/qtbase/src/network/kernel/qhostinfo_unix.cpp
+index 9b0a2ee669..73679c9ef1 100644
+--- a/qtbase/src/network/kernel/qhostinfo_unix.cpp
++++ b/qtbase/src/network/kernel/qhostinfo_unix.cpp
+@@ -122,7 +122,6 @@ static QFunctionPointer resolveSymbol(QLibrary &lib, const char *sym)
+ 
+ LibResolv::LibResolv()
+ {
+-    QLibrary lib;
+ #ifdef LIBRESOLV_SO
+     lib.setFileName(QStringLiteral(LIBRESOLV_SO));
+     if (!lib.load())
+diff --git a/qtbase/src/network/socket/qsocks5socketengine.cpp b/qtbase/src/network/socket/qsocks5socketengine.cpp
+index 3a046fd116..97fadca0b3 100644
+--- a/qtbase/src/network/socket/qsocks5socketengine.cpp
++++ b/qtbase/src/network/socket/qsocks5socketengine.cpp
+@@ -1296,7 +1296,7 @@ void QSocks5SocketEnginePrivate::_q_udpSocketReadNotification()
+         int pos = 0;
+         const char *buf = inBuf.constData();
+         if (inBuf.size() < 4) {
+-            QSOCKS5_D_DEBUG << "bugus udp data, discarding";
++            QSOCKS5_D_DEBUG << "bogus udp data, discarding";
+             return;
+         }
+         QSocks5RevivedDatagram datagram;
+diff --git a/qtbase/src/network/ssl/qsslcontext_openssl.cpp b/qtbase/src/network/ssl/qsslcontext_openssl.cpp
+index c9f202f573..c992da9d8e 100644
+--- a/qtbase/src/network/ssl/qsslcontext_openssl.cpp
++++ b/qtbase/src/network/ssl/qsslcontext_openssl.cpp
+@@ -409,7 +409,7 @@ init_context:
+         break;
+     case QSsl::DtlsV1_0OrLater:
+         minVersion = DTLS1_VERSION;
+-        maxVersion = DTLS_MAX_VERSION;
++        maxVersion = 0;
+         break;
+     case QSsl::DtlsV1_2:
+         minVersion = DTLS1_2_VERSION;
+@@ -417,7 +417,7 @@ init_context:
+         break;
+     case QSsl::DtlsV1_2OrLater:
+         minVersion = DTLS1_2_VERSION;
+-        maxVersion = DTLS_MAX_VERSION;
++        maxVersion = 0;
+         break;
+     case QSsl::TlsV1_3OrLater:
+ #ifdef TLS1_3_VERSION
+@@ -455,7 +455,7 @@ init_context:
+     }
+ 
+     // Enable bug workarounds.
+-    long options = QSslSocketBackendPrivate::setupOpenSslOptions(configuration.protocol(), configuration.d->sslOptions);
++    qssloptions options = QSslSocketBackendPrivate::setupOpenSslOptions(configuration.protocol(), configuration.d->sslOptions);
+     q_SSL_CTX_set_options(sslContext->ctx, options);
+ 
+     // Tell OpenSSL to release memory early
+diff --git a/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp b/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
+index aaf8741130..b58935372c 100644
+--- a/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
++++ b/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
+@@ -59,57 +59,6 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-#ifdef OPENSSL_NO_DEPRECATED_3_0
+-
+-static int q_DH_check(DH *dh, int *status)
+-{
+-    // DH_check was first deprecated in OpenSSL 3.0.0, as low-level
+-    // API; the EVP_PKEY family of functions was advised as an alternative.
+-    // As of now EVP_PKEY_params_check ends up calling ... DH_check,
+-    // which is good enough.
+-
+-    Q_ASSERT(dh);
+-    Q_ASSERT(status);
+-
+-    EVP_PKEY *key = q_EVP_PKEY_new();
+-    if (!key) {
+-        qCWarning(lcSsl, "EVP_PKEY_new failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-    const auto keyDeleter = qScopeGuard([key](){
+-        q_EVP_PKEY_free(key);
+-    });
+-    if (!q_EVP_PKEY_set1_DH(key, dh)) {
+-        qCWarning(lcSsl, "EVP_PKEY_set1_DH failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-
+-    EVP_PKEY_CTX *keyCtx = q_EVP_PKEY_CTX_new(key, nullptr);
+-    if (!keyCtx) {
+-        qCWarning(lcSsl, "EVP_PKEY_CTX_new failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-    const auto ctxDeleter = qScopeGuard([keyCtx]{
+-        q_EVP_PKEY_CTX_free(keyCtx);
+-    });
+-
+-    const int result = q_EVP_PKEY_param_check(keyCtx);
+-    QSslSocketBackendPrivate::logAndClearErrorQueue();
+-    // Note: unlike DH_check, we cannot obtain the 'status',
+-    // if the 'result' is 0 (actually the result is 1 only
+-    // if this 'status' was 0). We could probably check the
+-    // errors from the error queue, but it's not needed anyway
+-    // - see the 'isSafeDH' below, how it returns immediately
+-    // on 0.
+-    Q_UNUSED(status)
+-
+-    return result;
+-}
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+-
+ static bool isSafeDH(DH *dh)
+ {
+     int status = 0;
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl.cpp b/qtbase/src/network/ssl/qsslsocket_openssl.cpp
+index 37fad2a68f..8f6858c867 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl.cpp
++++ b/qtbase/src/network/ssl/qsslsocket_openssl.cpp
+@@ -550,9 +550,9 @@ static void q_loadCiphersForConnection(SSL *connection, QList<QSslCipher> &ciphe
+ // Defined in qsslsocket.cpp
+ void q_setDefaultDtlsCiphers(const QList<QSslCipher> &ciphers);
+ 
+-long QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions)
++qssloptions QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions)
+ {
+-    long options;
++    qssloptions options;
+     if (protocol == QSsl::TlsV1SslV3)
+         options = SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3;
+     else if (protocol == QSsl::SecureProtocols)
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_p.h b/qtbase/src/network/ssl/qsslsocket_openssl_p.h
+index 4103de23e8..5547589256 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_p.h
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_p.h
+@@ -107,6 +107,12 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++typedef uint64_t qssloptions;
++#else
++typedef unsigned long qssloptions;
++#endif
++
+ struct QSslErrorEntry {
+     int code;
+     int depth;
+@@ -171,7 +177,7 @@ public:
+     QVector<QSslError> ocspErrors;
+     QByteArray ocspResponseDer;
+ 
+-    Q_AUTOTEST_EXPORT static long setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions);
++    Q_AUTOTEST_EXPORT static qssloptions setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions);
+     static QSslCipher QSslCipher_from_SSL_CIPHER(const SSL_CIPHER *cipher);
+     static QList<QSslCertificate> STACKOFX509_to_QSslCertificates(STACK_OF(X509) *x509);
+     static QList<QSslError> verify(const QList<QSslCertificate> &certificateChain, const QString &hostName);
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp b/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
+index e53fb279f0..459ccd0b19 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
+@@ -148,7 +148,6 @@ DEFINEFUNC(int, EVP_PKEY_up_ref, EVP_PKEY *a, a, return 0, return)
+ DEFINEFUNC2(EVP_PKEY_CTX *, EVP_PKEY_CTX_new, EVP_PKEY *pkey, pkey, ENGINE *e, e, return nullptr, return)
+ DEFINEFUNC(int, EVP_PKEY_param_check, EVP_PKEY_CTX *ctx, ctx, return 0, return)
+ DEFINEFUNC(void, EVP_PKEY_CTX_free, EVP_PKEY_CTX *ctx, ctx, return, return)
+-DEFINEFUNC(int, EVP_PKEY_base_id, EVP_PKEY *a, a, return NID_undef, return)
+ DEFINEFUNC(int, RSA_bits, RSA *a, a, return 0, return)
+ DEFINEFUNC(int, DSA_bits, DSA *a, a, return 0, return)
+ DEFINEFUNC(int, OPENSSL_sk_num, OPENSSL_STACK *a, a, return -1, return)
+@@ -158,7 +157,7 @@ DEFINEFUNC2(void, OPENSSL_sk_push, OPENSSL_STACK *a, a, void *b, b, return, DUMM
+ DEFINEFUNC(void, OPENSSL_sk_free, OPENSSL_STACK *a, a, return, DUMMYARG)
+ DEFINEFUNC2(void *, OPENSSL_sk_value, OPENSSL_STACK *a, a, int b, b, return nullptr, return)
+ DEFINEFUNC(int, SSL_session_reused, SSL *a, a, return 0, return)
+-DEFINEFUNC2(unsigned long, SSL_CTX_set_options, SSL_CTX *ctx, ctx, unsigned long op, op, return 0, return)
++DEFINEFUNC2(qssloptions, SSL_CTX_set_options, SSL_CTX *ctx, ctx, qssloptions op, op, return 0, return)
+ DEFINEFUNC(int, SSL_CTX_get_security_level, const SSL_CTX *ctx, ctx, return -1, return)
+ DEFINEFUNC2(void, SSL_CTX_set_security_level, SSL_CTX *ctx, ctx, int level, level, return, return)
+ #ifdef TLS1_3_VERSION
+@@ -371,7 +370,15 @@ DEFINEFUNC(const SSL_CIPHER *, SSL_get_current_cipher, SSL *a, a, return nullptr
+ DEFINEFUNC(int, SSL_version, const SSL *a, a, return 0, return)
+ DEFINEFUNC2(int, SSL_get_error, SSL *a, a, int b, b, return -1, return)
+ DEFINEFUNC(STACK_OF(X509) *, SSL_get_peer_cert_chain, SSL *a, a, return nullptr, return)
++
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++DEFINEFUNC(X509 *, SSL_get1_peer_certificate, SSL *a, a, return nullptr, return)
++DEFINEFUNC(int, EVP_PKEY_get_base_id, const EVP_PKEY *pkey, pkey, return -1, return)
++#else
+ DEFINEFUNC(X509 *, SSL_get_peer_certificate, SSL *a, a, return nullptr, return)
++DEFINEFUNC(int, EVP_PKEY_base_id, EVP_PKEY *a, a, return NID_undef, return)
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+ DEFINEFUNC(long, SSL_get_verify_result, const SSL *a, a, return -1, return)
+ DEFINEFUNC(SSL *, SSL_new, SSL_CTX *a, a, return nullptr, return)
+ DEFINEFUNC(SSL_CTX *, SSL_get_SSL_CTX, SSL *a, a, return nullptr, return)
+@@ -492,9 +499,7 @@ DEFINEFUNC(DH *, DH_new, DUMMYARG, DUMMYARG, return nullptr, return)
+ DEFINEFUNC(void, DH_free, DH *dh, dh, return, DUMMYARG)
+ DEFINEFUNC3(DH *, d2i_DHparams, DH**a, a, const unsigned char **pp, pp, long length, length, return nullptr, return)
+ DEFINEFUNC2(int, i2d_DHparams, DH *a, a, unsigned char **p, p, return -1, return)
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+ DEFINEFUNC2(int, DH_check, DH *dh, dh, int *codes, codes, return 0, return)
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+ DEFINEFUNC3(BIGNUM *, BN_bin2bn, const unsigned char *s, s, int len, len, BIGNUM *ret, ret, return nullptr, return)
+ 
+ #ifndef OPENSSL_NO_EC
+@@ -868,7 +873,6 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(EVP_PKEY_CTX_new)
+     RESOLVEFUNC(EVP_PKEY_param_check)
+     RESOLVEFUNC(EVP_PKEY_CTX_free)
+-    RESOLVEFUNC(EVP_PKEY_base_id)
+     RESOLVEFUNC(RSA_bits)
+     RESOLVEFUNC(OPENSSL_sk_new_null)
+     RESOLVEFUNC(OPENSSL_sk_push)
+@@ -1107,7 +1111,15 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(SSL_version)
+     RESOLVEFUNC(SSL_get_error)
+     RESOLVEFUNC(SSL_get_peer_cert_chain)
++
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++    RESOLVEFUNC(SSL_get1_peer_certificate)
++    RESOLVEFUNC(EVP_PKEY_get_base_id)
++#else
+     RESOLVEFUNC(SSL_get_peer_certificate)
++    RESOLVEFUNC(EVP_PKEY_base_id)
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+     RESOLVEFUNC(SSL_get_verify_result)
+     RESOLVEFUNC(SSL_new)
+     RESOLVEFUNC(SSL_get_SSL_CTX)
+@@ -1206,9 +1218,7 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(DH_free)
+     RESOLVEFUNC(d2i_DHparams)
+     RESOLVEFUNC(i2d_DHparams)
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+     RESOLVEFUNC(DH_check)
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+     RESOLVEFUNC(BN_bin2bn)
+ 
+ #ifndef OPENSSL_NO_EC
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h b/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
+index 95e8897a3b..27aeffa18a 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
+@@ -237,7 +237,6 @@ Q_AUTOTEST_EXPORT int q_EVP_PKEY_up_ref(EVP_PKEY *a);
+ EVP_PKEY_CTX *q_EVP_PKEY_CTX_new(EVP_PKEY *pkey, ENGINE *e);
+ void q_EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx);
+ int q_EVP_PKEY_param_check(EVP_PKEY_CTX *ctx);
+-int q_EVP_PKEY_base_id(EVP_PKEY *a);
+ int q_RSA_bits(RSA *a);
+ Q_AUTOTEST_EXPORT int q_OPENSSL_sk_num(OPENSSL_STACK *a);
+ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_pop_free(OPENSSL_STACK *a, void (*b)(void *));
+@@ -246,7 +245,7 @@ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_push(OPENSSL_STACK *st, void *data);
+ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_free(OPENSSL_STACK *a);
+ Q_AUTOTEST_EXPORT void * q_OPENSSL_sk_value(OPENSSL_STACK *a, int b);
+ int q_SSL_session_reused(SSL *a);
+-unsigned long q_SSL_CTX_set_options(SSL_CTX *ctx, unsigned long op);
++qssloptions q_SSL_CTX_set_options(SSL_CTX *ctx, qssloptions op);
+ int q_OPENSSL_init_ssl(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings);
+ size_t q_SSL_get_client_random(SSL *a, unsigned char *out, size_t outlen);
+ size_t q_SSL_SESSION_get_master_key(const SSL_SESSION *session, unsigned char *out, size_t outlen);
+@@ -510,7 +509,6 @@ const SSL_CIPHER *q_SSL_get_current_cipher(SSL *a);
+ int q_SSL_version(const SSL *a);
+ int q_SSL_get_error(SSL *a, int b);
+ STACK_OF(X509) *q_SSL_get_peer_cert_chain(SSL *a);
+-X509 *q_SSL_get_peer_certificate(SSL *a);
+ long q_SSL_get_verify_result(const SSL *a);
+ SSL *q_SSL_new(SSL_CTX *a);
+ SSL_CTX *q_SSL_get_SSL_CTX(SSL *a);
+@@ -582,10 +580,7 @@ DH *q_DH_new();
+ void q_DH_free(DH *dh);
+ DH *q_d2i_DHparams(DH **a, const unsigned char **pp, long length);
+ int q_i2d_DHparams(DH *a, unsigned char **p);
+-
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+ int q_DH_check(DH *dh, int *codes);
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+ 
+ BIGNUM *q_BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret);
+ #define q_SSL_CTX_set_tmp_dh(ctx, dh) q_SSL_CTX_ctrl((ctx), SSL_CTRL_SET_TMP_DH, 0, (char *)dh)
+@@ -754,6 +749,17 @@ void q_CRYPTO_free(void *str, const char *file, int line);
+ int q_SSL_CTX_get_security_level(const SSL_CTX *ctx);
+ void q_SSL_CTX_set_security_level(SSL_CTX *ctx, int level);
+ 
++// Here we have the ones that make difference between OpenSSL pre/post v3:
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++X509 *q_SSL_get1_peer_certificate(SSL *a);
++#define q_SSL_get_peer_certificate q_SSL_get1_peer_certificate
++int q_EVP_PKEY_get_base_id(const EVP_PKEY *pkey);
++#define q_EVP_PKEY_base_id q_EVP_PKEY_get_base_id
++#else
++X509 *q_SSL_get_peer_certificate(SSL *a);
++int q_EVP_PKEY_base_id(EVP_PKEY *a);
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+ QT_END_NAMESPACE
+ 
+ #endif
+diff --git a/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h b/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
+index bf37d07fd8..dbd42fb799 100644
+--- a/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
++++ b/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
+@@ -61,7 +61,11 @@
+ # if !defined(Q_OS_INTEGRITY)
+ #  define WIN_INTERFACE_CUSTOM   // NV
+ # endif // Q_OS_INTEGRITY
+-#endif  // QT_EGL_NO_X11
++#else // QT_EGL_NO_X11
++// If one has an eglplatform.h with https://github.com/KhronosGroup/EGL-Registry/pull/130
++// that needs USE_X11 to be defined.
++# define USE_X11
++#endif
+ 
+ #ifdef QT_EGL_WAYLAND
+ # define WAYLAND // NV
+diff --git a/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+index 159b490ce0..00aa80cd58 100644
+--- a/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
++++ b/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+@@ -567,6 +567,8 @@ void QFontconfigDatabase::populateFontDatabase()
+         fonts = FcFontList(nullptr, pattern, os);
+         FcObjectSetDestroy(os);
+         FcPatternDestroy(pattern);
++        if (!fonts)
++            return;
+     }
+ 
+     for (int i = 0; i < fonts->nfont; i++)
+diff --git a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
+index b713c19447..7cb9a8c79a 100644
+--- a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
++++ b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
+@@ -95,6 +95,7 @@ static constexpr const auto KeyTbl = qMakeArray(
+         Xkb2Qt<XKB_KEY_Clear,                   Qt::Key_Delete>,
+         Xkb2Qt<XKB_KEY_Pause,                   Qt::Key_Pause>,
+         Xkb2Qt<XKB_KEY_Print,                   Qt::Key_Print>,
++        Xkb2Qt<XKB_KEY_Sys_Req,                 Qt::Key_SysReq>,
+         Xkb2Qt<0x1005FF60,                      Qt::Key_SysReq>,         // hardcoded Sun SysReq
+         Xkb2Qt<0x1007ff00,                      Qt::Key_SysReq>,         // hardcoded X386 SysReq
+ 
+@@ -471,7 +472,7 @@ QVector<xkb_keysym_t> QXkbCommon::toKeysym(QKeyEvent *event)
+     } else if (event->modifiers() & Qt::KeypadModifier) {
+         if (qtKey >= Qt::Key_0 && qtKey <= Qt::Key_9)
+             keysyms.append(XKB_KEY_KP_0 + (qtKey - Qt::Key_0));
+-    } else if (isLatin(qtKey) && event->text().isUpper()) {
++    } else if (isLatin1(qtKey) && event->text().isUpper()) {
+         keysyms.append(qtKey);
+     }
+ 
+@@ -523,7 +524,7 @@ int QXkbCommon::keysymToQtKey(xkb_keysym_t keysym, Qt::KeyboardModifiers modifie
+         // With standard shortcuts we should prefer a latin character, this is
+         // for checks like "some qkeyevent == QKeySequence::Copy" to work even
+         // when using for example 'russian' keyboard layout.
+-        if (!QXkbCommon::isLatin(keysym)) {
++        if (!QXkbCommon::isLatin1(keysym)) {
+             xkb_keysym_t latinKeysym = QXkbCommon::lookupLatinKeysym(state, code);
+             if (latinKeysym != XKB_KEY_NoSymbol)
+                 keysym = latinKeysym;
+@@ -546,7 +547,7 @@ static int keysymToQtKey_internal(xkb_keysym_t keysym, Qt::KeyboardModifiers mod
+     } else if (keysym >= XKB_KEY_KP_0 && keysym <= XKB_KEY_KP_9) {
+         // numeric keypad keys
+         qtKey = Qt::Key_0 + (keysym - XKB_KEY_KP_0);
+-    } else if (QXkbCommon::isLatin(keysym)) {
++    } else if (QXkbCommon::isLatin1(keysym)) {
+         qtKey = QXkbCommon::qxkbcommon_xkb_keysym_to_upper(keysym);
+     } else {
+         // check if we have a direct mapping
+@@ -678,7 +679,7 @@ QList<int> QXkbCommon::possibleKeys(xkb_state *state, const QKeyEvent *event,
+         Qt::KeyboardModifiers neededMods = ModsTbl[i];
+         if ((modifiers & neededMods) == neededMods) {
+             if (i == 8) {
+-                if (isLatin(baseQtKey))
++                if (isLatin1(baseQtKey))
+                     continue;
+                 // add a latin key as a fall back key
+                 sym = lookupLatinKeysym(state, keycode);
+@@ -733,7 +734,7 @@ void QXkbCommon::verifyHasLatinLayout(xkb_keymap *keymap)
+     for (xkb_layout_index_t layout = 0; layout < layoutCount; ++layout) {
+         for (xkb_keycode_t code = minKeycode; code < maxKeycode; ++code) {
+             xkb_keymap_key_get_syms_by_level(keymap, code, layout, 0, &keysyms);
+-            if (keysyms && isLatin(keysyms[0]))
++            if (keysyms && isLatin1(keysyms[0]))
+                 nrLatinKeys++;
+             if (nrLatinKeys > 10) // arbitrarily chosen threshold
+                 return;
+@@ -766,7 +767,7 @@ xkb_keysym_t QXkbCommon::lookupLatinKeysym(xkb_state *state, xkb_keycode_t keyco
+         xkb_level_index_t level = xkb_state_key_get_level(state, keycode, layout);
+         if (xkb_keymap_key_get_syms_by_level(keymap, keycode, layout, level, &syms) != 1)
+             continue;
+-        if (isLatin(syms[0])) {
++        if (isLatin1(syms[0])) {
+             sym = syms[0];
+             break;
+         }
+diff --git a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
+index 561eae03db..8389bd8f5a 100644
+--- a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
++++ b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
+@@ -94,8 +94,8 @@ public:
+     static void verifyHasLatinLayout(xkb_keymap *keymap);
+     static xkb_keysym_t lookupLatinKeysym(xkb_state *state, xkb_keycode_t keycode);
+ 
+-    static bool isLatin(xkb_keysym_t sym) {
+-        return ((sym >= 'a' && sym <= 'z') || (sym >= 'A' && sym <= 'Z'));
++    static bool isLatin1(xkb_keysym_t sym) {
++        return sym <= 0xff;
+     }
+     static bool isKeypad(xkb_keysym_t sym) {
+         return sym >= XKB_KEY_KP_Space && sym <= XKB_KEY_KP_9;
+diff --git a/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp b/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
+index 8cd7f9b368..406f84663f 100644
+--- a/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
++++ b/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
+@@ -318,7 +318,7 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources,
+ 
+     if (current < 0 && crtc_mode.clock != 0) {
+         modes << crtc_mode;
+-        current = mode.size() - 1;
++        current = modes.size() - 1;
+     }
+ 
+     if (configuration == OutputConfigCurrent)
+diff --git a/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp b/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
+index 9153fd20bb..255ea5e33e 100644
+--- a/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
++++ b/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
+@@ -194,6 +194,9 @@ QString AtSpiAdaptor::introspect(const QString &path) const
+                 "      <arg direction=\"out\" type=\"(so)\"/>\n"
+                 "      <annotation value=\"QSpiObjectReference\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n"
+                 "    </method>\n"
++                "    <method name=\"GetAccessibleId\">\n"
++                "      <arg direction=\"out\" type=\"s\"/>\n"
++                "    </method>\n"
+                 "  </interface>\n"
+                 );
+ 
+@@ -913,8 +916,17 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+     }
+     case QAccessible::NameChanged: {
+         if (sendObject || sendObject_property_change || sendObject_property_change_accessible_name) {
+-            QString path = pathForInterface(event->accessibleInterface());
+-            QVariantList args = packDBusSignalArguments(QLatin1String("accessible-name"), 0, 0, variantForPath(path));
++            QAccessibleInterface *iface = event->accessibleInterface();
++            if (!iface) {
++                qCDebug(lcAccessibilityAtspi,
++                        "NameChanged event from invalid accessible.");
++                return;
++            }
++
++            QString path = pathForInterface(iface);
++            QVariantList args = packDBusSignalArguments(
++                QLatin1String("accessible-name"), 0, 0,
++                QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Name))));
+             sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                            QLatin1String("PropertyChange"), args);
+         }
+@@ -922,8 +934,17 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+     }
+     case QAccessible::DescriptionChanged: {
+         if (sendObject || sendObject_property_change || sendObject_property_change_accessible_description) {
+-            QString path = pathForInterface(event->accessibleInterface());
+-            QVariantList args = packDBusSignalArguments(QLatin1String("accessible-description"), 0, 0, variantForPath(path));
++            QAccessibleInterface *iface = event->accessibleInterface();
++            if (!iface) {
++                qCDebug(lcAccessibilityAtspi,
++                        "DescriptionChanged event from invalid accessible.");
++                return;
++            }
++
++            QString path = pathForInterface(iface);
++            QVariantList args = packDBusSignalArguments(
++                QLatin1String("accessible-description"), 0, 0,
++                QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Description))));
+             sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                            QLatin1String("PropertyChange"), args);
+         }
+@@ -1038,7 +1059,9 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+                 // Combo Box with AT-SPI likes to be special
+                 // It requires a name-change to update caches and then selection-changed
+                 QString path = pathForInterface(iface);
+-                QVariantList args1 = packDBusSignalArguments(QLatin1String("accessible-name"), 0, 0, variantForPath(path));
++                QVariantList args1 = packDBusSignalArguments(
++                    QLatin1String("accessible-name"), 0, 0,
++                    QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Name))));
+                 sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                                QLatin1String("PropertyChange"), args1);
+                 QVariantList args2 = packDBusSignalArguments(QString(), 0, 0, QVariant::fromValue(QDBusVariant(QVariant(0))));
+@@ -1358,6 +1381,26 @@ void AtSpiAdaptor::registerApplication()
+     delete registry;
+ }
+ 
++namespace {
++QString accessibleIdForAccessible(QAccessibleInterface *accessible)
++{
++    QString result;
++    while (accessible) {
++        if (!result.isEmpty())
++            result.prepend(QLatin1Char('.'));
++        if (auto obj = accessible->object()) {
++            const QString name = obj->objectName();
++            if (!name.isEmpty())
++                result.prepend(name);
++            else
++                result.prepend(QString::fromUtf8(obj->metaObject()->className()));
++        }
++        accessible = accessible->parent();
++    }
++    return result;
++}
++} // namespace
++
+ // Accessible
+ bool AtSpiAdaptor::accessibleInterface(QAccessibleInterface *interface, const QString &function, const QDBusMessage &message, const QDBusConnection &connection)
+ {
+@@ -1441,6 +1484,9 @@ bool AtSpiAdaptor::accessibleInterface(QAccessibleInterface *interface, const QS
+             children << ref;
+         }
+         connection.send(message.createReply(QVariant::fromValue(children)));
++    } else if (function == QLatin1String("GetAccessibleId")) {
++        sendReply(connection, message,
++                  QVariant::fromValue(QDBusVariant(accessibleIdForAccessible(interface))));
+     } else {
+         qCDebug(lcAccessibilityAtspi) << "WARNING: AtSpiAdaptor::accessibleInterface does not implement " << function << message.path();
+         return false;
+diff --git a/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp b/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
+index 45ddc8e496..cc734abc63 100644
+--- a/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
++++ b/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
+@@ -69,6 +69,21 @@ QT_BEGIN_NAMESPACE
+ DBusConnection::DBusConnection(QObject *parent)
+     : QObject(parent), m_a11yConnection(QString()), m_enabled(false)
+ {
++    // If the bus is explicitly set via env var it overrides everything else.
++    QByteArray addressEnv = qgetenv("AT_SPI_BUS_ADDRESS");
++    if (!addressEnv.isEmpty()) {
++        // Only connect on next loop run, connections to our enabled signal are
++        // only established after the ctor returns.
++        QMetaObject::invokeMethod(
++                this,
++                [this, addressEnv] {
++                    m_enabled = true;
++                    connectA11yBus(QString::fromLocal8Bit(addressEnv));
++                },
++                Qt::QueuedConnection);
++        return;
++    }
++
+     // Start monitoring if "org.a11y.Bus" is registered as DBus service.
+     QDBusConnection c = QDBusConnection::sessionBus();
+     if (!c.isConnected()) {
+diff --git a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
+index 1a3cab275d..2abe039126 100644
+--- a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
++++ b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
+@@ -51,6 +51,9 @@
+ #include <QtCore/QStandardPaths>
+ #include <QtCore/QUrl>
+ 
++#include <QtGui/QGuiApplication>
++#include <QtGui/QWindow>
++
+ #if QT_CONFIG(dbus)
+ // These QtCore includes are needed for xdg-desktop-portal support
+ #include <QtCore/private/qcore_unix_p.h>
+@@ -58,6 +61,8 @@
+ #include <QtCore/QFileInfo>
+ #include <QtCore/QUrlQuery>
+ 
++#include <QtGui/QColor>
++
+ #include <QtDBus/QDBusConnection>
+ #include <QtDBus/QDBusMessage>
+ #include <QtDBus/QDBusPendingCall>
+@@ -142,6 +147,8 @@ static inline bool detectWebBrowser(const QByteArray &desktop,
+     }
+ 
+     if (desktop == QByteArray("KDE")) {
++        if (checkExecutable(QStringLiteral("kde-open5"), browser))
++            return true;
+         // Konqueror launcher
+         if (checkExecutable(QStringLiteral("kfmclient"), browser)) {
+             browser->append(QLatin1String(" exec"));
+@@ -296,8 +303,135 @@ static inline QDBusMessage xdgDesktopPortalSendEmail(const QUrl &url)
+ 
+     return QDBusConnection::sessionBus().call(message);
+ }
++
++namespace {
++struct XDGDesktopColor
++{
++    double r = 0;
++    double g = 0;
++    double b = 0;
++
++    QColor toQColor() const
++    {
++        constexpr auto rgbMax = 255;
++        return { static_cast<int>(r * rgbMax), static_cast<int>(g * rgbMax),
++                 static_cast<int>(b * rgbMax) };
++    }
++};
++
++const QDBusArgument &operator>>(const QDBusArgument &argument, XDGDesktopColor &myStruct)
++{
++    argument.beginStructure();
++    argument >> myStruct.r >> myStruct.g >> myStruct.b;
++    argument.endStructure();
++    return argument;
++}
++
++class XdgDesktopPortalColorPicker : public QPlatformServiceColorPicker
++{
++    Q_OBJECT
++public:
++    XdgDesktopPortalColorPicker(const QString &parentWindowId, QWindow *parent)
++        : QPlatformServiceColorPicker(parent), m_parentWindowId(parentWindowId)
++    {
++    }
++
++    void pickColor() override
++    {
++        // DBus signature:
++        // PickColor (IN   s      parent_window,
++        //            IN   a{sv}  options
++        //            OUT  o      handle)
++        // Options:
++        // handle_token (s) -  A string that will be used as the last element of the @handle.
++
++        QDBusMessage message = QDBusMessage::createMethodCall(
++                QStringLiteral("org.freedesktop.portal.Desktop"), QStringLiteral("/org/freedesktop/portal/desktop"),
++                QStringLiteral("org.freedesktop.portal.Screenshot"), QStringLiteral("PickColor"));
++        message << m_parentWindowId << QVariantMap();
++
++        QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
++        auto watcher = new QDBusPendingCallWatcher(pendingCall, this);
++        connect(watcher, &QDBusPendingCallWatcher::finished, this,
++                [this](QDBusPendingCallWatcher *watcher) {
++                    watcher->deleteLater();
++                    QDBusPendingReply<QDBusObjectPath> reply = *watcher;
++                    if (reply.isError()) {
++                        qWarning("DBus call to pick color failed: %s",
++                                 qPrintable(reply.error().message()));
++                        Q_EMIT colorPicked({});
++                    } else {
++                        QDBusConnection::sessionBus().connect(
++                                QStringLiteral("org.freedesktop.portal.Desktop"), reply.value().path(),
++                                QStringLiteral("org.freedesktop.portal.Request"), QStringLiteral("Response"), this,
++                                // clang-format off
++                                SLOT(gotColorResponse(uint,QVariantMap))
++                                // clang-format on
++                        );
++                    }
++                });
++    }
++
++private Q_SLOTS:
++    void gotColorResponse(uint result, const QVariantMap &map)
++    {
++        if (result != 0)
++            return;
++        XDGDesktopColor color{};
++        map.value(QStringLiteral("color")).value<QDBusArgument>() >> color;
++        Q_EMIT colorPicked(color.toQColor());
++        deleteLater();
++    }
++
++private:
++    const QString m_parentWindowId;
++};
++} // namespace
++
+ #endif // QT_CONFIG(dbus)
+ 
++QGenericUnixServices::QGenericUnixServices()
++{
++#if QT_CONFIG(dbus)
++    if (qEnvironmentVariableIntValue("QT_NO_XDG_DESKTOP_PORTAL") > 0) {
++        return;
++    }
++    QDBusMessage message = QDBusMessage::createMethodCall(
++            QStringLiteral("org.freedesktop.portal.Desktop"), QStringLiteral("/org/freedesktop/portal/desktop"),
++            QStringLiteral("org.freedesktop.DBus.Properties"), QStringLiteral("Get"));
++    message << QStringLiteral("org.freedesktop.portal.Screenshot")
++            << QStringLiteral("version");
++
++    QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
++    auto watcher = new QDBusPendingCallWatcher(pendingCall);
++    QObject::connect(watcher, &QDBusPendingCallWatcher::finished, watcher,
++                     [this](QDBusPendingCallWatcher *watcher) {
++                         watcher->deleteLater();
++                         QDBusPendingReply<QVariant> reply = *watcher;
++                         if (!reply.isError() && reply.value().toUInt() >= 2)
++                             m_hasScreenshotPortalWithColorPicking = true;
++                     });
++
++#endif
++}
++
++QPlatformServiceColorPicker *QGenericUnixServices::colorPicker(QWindow *parent)
++{
++#if QT_CONFIG(dbus)
++    // Make double sure that we are in a wayland environment. In particular check
++    // WAYLAND_DISPLAY so also XWayland apps benefit from portal-based color picking.
++    // Outside wayland we'll rather rely on other means than the XDG desktop portal.
++    if (!qEnvironmentVariableIsEmpty("WAYLAND_DISPLAY")
++        || QGuiApplication::platformName().startsWith(QLatin1String("wayland"))) {
++        return new XdgDesktopPortalColorPicker(portalWindowIdentifier(parent), parent);
++    }
++    return nullptr;
++#else
++    Q_UNUSED(parent);
++    return nullptr;
++#endif
++}
++
+ QByteArray QGenericUnixServices::desktopEnvironment() const
+ {
+     static const QByteArray result = detectDesktopEnvironment();
+@@ -352,6 +486,8 @@ bool QGenericUnixServices::openDocument(const QUrl &url)
+ }
+ 
+ #else
++QGenericUnixServices::QGenericUnixServices() = default;
++
+ QByteArray QGenericUnixServices::desktopEnvironment() const
+ {
+     return QByteArrayLiteral("UNKNOWN");
+@@ -371,6 +507,30 @@ bool QGenericUnixServices::openDocument(const QUrl &url)
+     return false;
+ }
+ 
++QPlatformServiceColorPicker *QGenericUnixServices::colorPicker(QWindow *parent)
++{
++    Q_UNUSED(parent);
++    return nullptr;
++}
++
+ #endif // QT_NO_MULTIPROCESS
+ 
++QString QGenericUnixServices::portalWindowIdentifier(QWindow *window)
++{
++    if (QGuiApplication::platformName() == QLatin1String("xcb"))
++        return QStringLiteral("x11:") + QString::number(window->winId(), 16);
++    return QString();
++}
++
++bool QGenericUnixServices::hasCapability(Capability capability) const
++{
++    switch (capability) {
++    case Capability::ColorPicking:
++        return m_hasScreenshotPortalWithColorPicking;
++    }
++    return false;
++}
++
+ QT_END_NAMESPACE
++
++#include "qgenericunixservices.moc"
+diff --git a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
+index 8ac3de6f03..30924e64bd 100644
+--- a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
++++ b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
+@@ -59,16 +59,21 @@ QT_BEGIN_NAMESPACE
+ class QGenericUnixServices : public QPlatformServices
+ {
+ public:
+-    QGenericUnixServices() {}
++    QGenericUnixServices();
+ 
+     QByteArray desktopEnvironment() const override;
+ 
++    bool hasCapability(Capability capability) const override;
+     bool openUrl(const QUrl &url) override;
+     bool openDocument(const QUrl &url) override;
++    QPlatformServiceColorPicker *colorPicker(QWindow *parent = nullptr) override;
++
++    virtual QString portalWindowIdentifier(QWindow *window);
+ 
+ private:
+     QString m_webBrowser;
+     QString m_documentLauncher;
++    bool m_hasScreenshotPortalWithColorPicking = false;
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
+index 09470bccc6..cc7c7d4d8a 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
+@@ -69,6 +69,7 @@ const QString MenuBarPath = QLatin1String("/MenuBar");
+ */
+ QDBusMenuConnection::QDBusMenuConnection(QObject *parent, const QString &serviceName)
+     : QObject(parent)
++    , m_serviceName(serviceName)
+     , m_connection(serviceName.isNull() ? QDBusConnection::sessionBus()
+                                         : QDBusConnection::connectToBus(QDBusConnection::SessionBus, serviceName))
+     , m_dbusWatcher(new QDBusServiceWatcher(StatusNotifierWatcherService, m_connection, QDBusServiceWatcher::WatchForRegistration, this))
+@@ -83,6 +84,12 @@ QDBusMenuConnection::QDBusMenuConnection(QObject *parent, const QString &service
+ #endif
+ }
+ 
++QDBusMenuConnection::~QDBusMenuConnection()
++{
++  if (!m_serviceName.isEmpty() && m_connection.isConnected())
++      QDBusConnection::disconnectFromBus(m_serviceName);
++}
++
+ void QDBusMenuConnection::dbusError(const QDBusError &error)
+ {
+     qWarning() << "QDBusTrayIcon encountered a D-Bus error:" << error;
+@@ -105,13 +112,7 @@ void QDBusMenuConnection::unregisterTrayIconMenu(QDBusTrayIcon *item)
+ 
+ bool QDBusMenuConnection::registerTrayIcon(QDBusTrayIcon *item)
+ {
+-    bool success = connection().registerService(item->instanceId());
+-    if (!success) {
+-        qWarning() << "failed to register service" << item->instanceId();
+-        return false;
+-    }
+-
+-    success = connection().registerObject(StatusNotifierItemPath, item);
++    bool success = connection().registerObject(StatusNotifierItemPath, item);
+     if (!success) {
+         unregisterTrayIcon(item);
+         qWarning() << "failed to register" << item->instanceId() << StatusNotifierItemPath;
+@@ -126,21 +127,18 @@ bool QDBusMenuConnection::registerTrayIcon(QDBusTrayIcon *item)
+ 
+ bool QDBusMenuConnection::registerTrayIconWithWatcher(QDBusTrayIcon *item)
+ {
++    Q_UNUSED(item);
+     QDBusMessage registerMethod = QDBusMessage::createMethodCall(
+                 StatusNotifierWatcherService, StatusNotifierWatcherPath, StatusNotifierWatcherService,
+                 QLatin1String("RegisterStatusNotifierItem"));
+-    registerMethod.setArguments(QVariantList() << item->instanceId());
++    registerMethod.setArguments(QVariantList() << m_connection.baseService());
+     return m_connection.callWithCallback(registerMethod, this, SIGNAL(trayIconRegistered()), SLOT(dbusError(QDBusError)));
+ }
+ 
+-bool QDBusMenuConnection::unregisterTrayIcon(QDBusTrayIcon *item)
++void QDBusMenuConnection::unregisterTrayIcon(QDBusTrayIcon *item)
+ {
+     unregisterTrayIconMenu(item);
+     connection().unregisterObject(StatusNotifierItemPath);
+-    bool success = connection().unregisterService(item->instanceId());
+-    if (!success)
+-        qWarning() << "failed to unregister service" << item->instanceId();
+-    return success;
+ }
+ #endif // QT_NO_SYSTEMTRAYICON
+ 
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
+index f484795fbb..97bdfabb85 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
++++ b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
+@@ -70,6 +70,7 @@ class QDBusMenuConnection : public QObject
+ 
+ public:
+     QDBusMenuConnection(QObject *parent = nullptr, const QString &serviceName = QString());
++    ~QDBusMenuConnection();
+     QDBusConnection connection() const { return m_connection; }
+     QDBusServiceWatcher *dbusWatcher() const { return m_dbusWatcher; }
+     bool isStatusNotifierHostRegistered() const { return m_statusNotifierHostRegistered; }
+@@ -78,7 +79,7 @@ public:
+     void unregisterTrayIconMenu(QDBusTrayIcon *item);
+     bool registerTrayIcon(QDBusTrayIcon *item);
+     bool registerTrayIconWithWatcher(QDBusTrayIcon *item);
+-    bool unregisterTrayIcon(QDBusTrayIcon *item);
++    void unregisterTrayIcon(QDBusTrayIcon *item);
+ #endif // QT_NO_SYSTEMTRAYICON
+ 
+ Q_SIGNALS:
+@@ -90,6 +91,7 @@ private Q_SLOTS:
+     void dbusError(const QDBusError &error);
+ 
+ private:
++    QString m_serviceName;
+     QDBusConnection m_connection;
+     QDBusServiceWatcher *m_dbusWatcher;
+     bool m_statusNotifierHostRegistered;
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp b/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
+index bede70975a..76bfec5e5a 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
+@@ -71,8 +71,12 @@ Q_LOGGING_CATEGORY(qLcTray, "qt.qpa.tray")
+ static QString iconTempPath()
+ {
+     QString tempPath = QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation);
+-    if (!tempPath.isEmpty())
++    if (!tempPath.isEmpty()) {
++        QString flatpakId = qEnvironmentVariable("FLATPAK_ID");
++        if (!flatpakId.isEmpty() && QFileInfo::exists(QLatin1String("/.flatpak-info")))
++            tempPath += QLatin1String("/app/") + flatpakId;
+         return tempPath;
++    }
+ 
+     tempPath = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation);
+ 
+diff --git a/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+index cb1b39db64..6e01af052c 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+@@ -755,6 +755,9 @@ QVariant QGnomeTheme::themeHint(QPlatformTheme::ThemeHint hint) const
+         return QVariant(QChar(0x2022));
+     case QPlatformTheme::UiEffects:
+         return QVariant(int(HoverEffect));
++    case QPlatformTheme::ButtonPressKeys:
++        return QVariant::fromValue(
++                QList<Qt::Key>({ Qt::Key_Space, Qt::Key_Return, Qt::Key_Enter, Qt::Key_Select }));
+     default:
+         break;
+     }
+diff --git a/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp b/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
+index 98e05195ee..1e92f43dec 100644
+--- a/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
++++ b/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
+@@ -343,8 +343,7 @@ void QEglFSCursor::paintOnScreen()
+     // screens are siblings of each other. When not enabled, the sibling list
+     // only contains m_screen itself.
+     for (QPlatformScreen *screen : m_screen->virtualSiblings()) {
+-        if (screen->geometry().contains(cr.topLeft().toPoint() + m_cursor.hotSpot)
+-            && QOpenGLContext::currentContext()->screen() == screen->screen())
++        if (screen->geometry().contains(cr.topLeft().toPoint() + m_cursor.hotSpot))
+         {
+             cr.translate(-screen->geometry().topLeft());
+             const QSize screenSize = screen->geometry().size();
+@@ -468,11 +467,12 @@ void QEglFSCursor::draw(const QRectF &r)
+ {
+     StateSaver stateSaver;
+ 
+-    QEglFSCursorData &gfx = static_cast<QEglFSContext*>(QOpenGLContext::currentContext()->handle())->cursorData;
+-    if (!gfx.program) {
+-        // one time initialization
++    // one time initialization
++    if (!QOpenGLFunctions::d_ptr)
+         initializeOpenGLFunctions();
+ 
++    QEglFSCursorData &gfx = static_cast<QEglFSContext*>(QOpenGLContext::currentContext()->handle())->cursorData;
++    if (!gfx.program) {
+         createShaderPrograms();
+ 
+         if (!gfx.atlasTexture) {
+diff --git a/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp b/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
+index 645a0ae2e9..3e0e406f1a 100644
+--- a/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
++++ b/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
+@@ -179,7 +179,7 @@ void QEglFSKmsEventReader::create(QEglFSKmsDevice *device)
+ 
+     m_device = device;
+ 
+-    qCDebug(qLcEglfsKmsDebug, "Initalizing event reader for device %p fd %d",
++    qCDebug(qLcEglfsKmsDebug, "Initializing event reader for device %p fd %d",
+             m_device, m_device->fd());
+ 
+     m_thread = new QEglFSKmsEventReaderThread(m_device->fd());
+diff --git a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
+index 141fb68a23..d4294d425a 100644
+--- a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
++++ b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
+@@ -122,11 +122,13 @@ QOffscreenIntegration::QOffscreenIntegration()
+ #endif
+     m_services.reset(new QPlatformServices);
+ 
+-    QWindowSystemInterface::handleScreenAdded(new QOffscreenScreen);
++    m_screen = new QOffscreenScreen;
++    QWindowSystemInterface::handleScreenAdded(m_screen);
+ }
+ 
+ QOffscreenIntegration::~QOffscreenIntegration()
+ {
++    QWindowSystemInterface::handleScreenRemoved(m_screen);
+ }
+ 
+ void QOffscreenIntegration::initialize()
+diff --git a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
+index 0ea90f6c2f..fe00fde07c 100644
+--- a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
++++ b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
+@@ -84,6 +84,7 @@ protected:
+ #endif
+     QScopedPointer<QPlatformInputContext> m_inputContext;
+     QScopedPointer<QPlatformServices> m_services;
++    QPlatformScreen *m_screen;
+     mutable QScopedPointer<QPlatformNativeInterface> m_nativeInterface;
+ };
+ 
+diff --git a/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp b/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
+index 6fa5a8a2b3..1f49f0aefd 100644
+--- a/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
++++ b/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
+@@ -48,6 +48,7 @@
+ #include <qpa/qplatformnativeinterface.h>
+ #include <QtPlatformHeaders/qwglnativecontext.h>
+ 
++#include <private/qsystemlibrary_p.h>
+ #include <algorithm>
+ 
+ #include <wingdi.h>
+@@ -162,19 +163,25 @@ QFunctionPointer QWindowsOpengl32DLL::resolve(const char *name)
+ 
+ bool QWindowsOpengl32DLL::init(bool softwareRendering)
+ {
+-    const QByteArray opengl32 = QByteArrayLiteral("opengl32.dll");
+-    const QByteArray swopengl = QByteArrayLiteral("opengl32sw.dll");
++    const QByteArray opengl32 = QByteArrayLiteral("opengl32");
++    const QByteArray swopengl = QByteArrayLiteral("opengl32sw");
++    bool useSystemLib = false;
+ 
+     QByteArray openglDll = qgetenv("QT_OPENGL_DLL");
+-    if (openglDll.isEmpty())
++    if (openglDll.isEmpty()) {
+         openglDll = softwareRendering ? swopengl : opengl32;
++        useSystemLib = !softwareRendering;
++    }
+ 
+     openglDll = openglDll.toLower();
+     m_nonOpengl32 = openglDll != opengl32;
+ 
+     qCDebug(lcQpaGl) << "Qt: Using WGL and OpenGL from" << openglDll;
+ 
+-    m_lib = ::LoadLibraryA(openglDll.constData());
++    if (useSystemLib)
++        m_lib = QSystemLibrary::load((wchar_t*)(QString::fromLatin1(openglDll).utf16()));
++    else
++        m_lib = LoadLibraryA(openglDll.constData());
+     if (!m_lib) {
+         qErrnoWarning(::GetLastError(), "Failed to load %s", openglDll.constData());
+         return false;
+@@ -184,7 +191,7 @@ bool QWindowsOpengl32DLL::init(bool softwareRendering)
+         // Load opengl32.dll always. GDI functions like ChoosePixelFormat do
+         // GetModuleHandle for opengl32.dll and behave differently (and call back into
+         // opengl32) when the module is present. This is fine for dummy contexts and windows.
+-        ::LoadLibraryA("opengl32.dll");
++        QSystemLibrary::load(L"opengl32");
+     }
+ 
+     wglCreateContext = reinterpret_cast<HGLRC (WINAPI *)(HDC)>(resolve("wglCreateContext"));
+diff --git a/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp b/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
+index d7d186e804..9eb4011bf2 100644
+--- a/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
++++ b/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
+@@ -49,6 +49,7 @@
+ #include <QtCore/qstandardpaths.h>
+ #include <QtCore/qlibraryinfo.h>
+ #include <QtCore/qhash.h>
++#include <private/qsystemlibrary_p.h>
+ 
+ #ifndef QT_NO_OPENGL
+ #include <private/qopengl_p.h>
+@@ -396,7 +397,7 @@ bool QWindowsOpenGLTester::testDesktopGL()
+ 
+     // Test #1: Load opengl32.dll and try to resolve an OpenGL 2 function.
+     // This will typically fail on systems that do not have a real OpenGL driver.
+-    lib = LoadLibraryA("opengl32.dll");
++    lib = QSystemLibrary::load(L"opengl32");
+     if (lib) {
+         CreateContext = reinterpret_cast<CreateContextType>(
+             reinterpret_cast<QFunctionPointer>(::GetProcAddress(lib, "wglCreateContext")));
+diff --git a/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp b/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
+index 1afa00cfc9..118af6ce73 100644
+--- a/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
++++ b/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
+@@ -41,6 +41,7 @@
+ 
+ #include <QRect>
+ #include <QList>
++#include <QMap>
+ #include <QDebug>
+ 
+ #include <qmath.h>
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp b/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
+index 9e2a37a6a1..e6e175a118 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
+@@ -488,12 +488,12 @@ void QXcbConnection::printXcbError(const char *message, xcb_generic_error_t *err
+     uint clamped_error_code = qMin<uint>(error->error_code, (sizeof(xcb_errors) / sizeof(xcb_errors[0])) - 1);
+     uint clamped_major_code = qMin<uint>(error->major_code, (sizeof(xcb_protocol_request_codes) / sizeof(xcb_protocol_request_codes[0])) - 1);
+ 
+-    qCWarning(lcQpaXcb, "%s: %d (%s), sequence: %d, resource id: %d, major code: %d (%s), minor code: %d",
+-             message,
+-             int(error->error_code), xcb_errors[clamped_error_code],
+-             int(error->sequence), int(error->resource_id),
+-             int(error->major_code), xcb_protocol_request_codes[clamped_major_code],
+-             int(error->minor_code));
++    qCDebug(lcQpaXcb, "%s: %d (%s), sequence: %d, resource id: %d, major code: %d (%s), minor code: %d",
++            message,
++            int(error->error_code), xcb_errors[clamped_error_code],
++            int(error->sequence), int(error->resource_id),
++            int(error->major_code), xcb_protocol_request_codes[clamped_major_code],
++            int(error->minor_code));
+ }
+ 
+ static Qt::MouseButtons translateMouseButtons(int s)
+@@ -702,6 +702,8 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
+             QXcbVirtualDesktop *virtualDesktop = virtualDesktopForRootWindow(propertyNotify->window);
+             if (virtualDesktop)
+                 virtualDesktop->updateWorkArea();
++        } else if (propertyNotify->atom == atom(QXcbAtom::_NET_SUPPORTED)) {
++            m_wmSupport->updateNetWMAtoms();
+         } else {
+             HANDLE_PLATFORM_WINDOW_EVENT(xcb_property_notify_event_t, window, handlePropertyNotifyEvent);
+         }
+@@ -750,7 +752,7 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
+                 case XCB_XKB_NEW_KEYBOARD_NOTIFY: {
+                     xcb_xkb_new_keyboard_notify_event_t *ev = &xkb_event->new_keyboard_notify;
+                     if (ev->changed & XCB_XKB_NKN_DETAIL_KEYCODES)
+-                        m_keyboard->updateKeymap(ev);
++                        m_keyboard->updateKeymap();
+                     break;
+                 }
+                 default:
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp b/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
+index 76869ced60..02d2eebb56 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
+@@ -274,8 +274,7 @@ QPlatformWindow *QXcbIntegration::createForeignWindow(QWindow *window, WId nativ
+ #ifndef QT_NO_OPENGL
+ QPlatformOpenGLContext *QXcbIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
+ {
+-    QXcbScreen *screen = static_cast<QXcbScreen *>(context->screen()->handle());
+-    QXcbGlIntegration *glIntegration = screen->connection()->glIntegration();
++    QXcbGlIntegration *glIntegration = defaultConnection()->glIntegration();
+     if (!glIntegration) {
+         qWarning("QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled");
+         return nullptr;
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+index efecd7e2d1..e8286381a2 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+@@ -365,17 +365,6 @@ void QXcbKeyboard::updateKeymap(xcb_mapping_notify_event_t *event)
+     updateKeymap();
+ }
+ 
+-void QXcbKeyboard::updateKeymap(xcb_xkb_new_keyboard_notify_event_t *event)
+-{
+-    if (!event)
+-        return;
+-
+-    if (event->deviceID != event->oldDeviceID)
+-        m_config = false;
+-
+-    updateKeymap();
+-}
+-
+ void QXcbKeyboard::updateKeymap()
+ {
+     KeysymModifierMap keysymMods;
+@@ -383,6 +372,8 @@ void QXcbKeyboard::updateKeymap()
+         keysymMods = keysymsToModifiers();
+     updateModifiers(keysymMods);
+ 
++    m_config = true;
++
+     if (!m_xkbContext) {
+         m_xkbContext.reset(xkb_context_new(XKB_CONTEXT_NO_DEFAULT_INCLUDES));
+         if (!m_xkbContext) {
+@@ -398,13 +389,8 @@ void QXcbKeyboard::updateKeymap()
+     if (connection()->hasXKB()) {
+         m_xkbKeymap.reset(xkb_x11_keymap_new_from_device(m_xkbContext.get(), xcb_connection(),
+                                                          core_device_id, XKB_KEYMAP_COMPILE_NO_FLAGS));
+-        if (m_xkbKeymap) {
+-            if (m_config)
+-                m_xkbState.reset(xkb_state_new(m_xkbKeymap.get()));
+-            else
+-                m_xkbState.reset(xkb_x11_state_new_from_device(m_xkbKeymap.get(), xcb_connection(), core_device_id));
+-
+-        }
++        if (m_xkbKeymap)
++            m_xkbState.reset(xkb_x11_state_new_from_device(m_xkbKeymap.get(), xcb_connection(), core_device_id));
+     } else {
+         m_xkbKeymap.reset(keymapFromCore(keysymMods));
+         if (m_xkbKeymap)
+@@ -425,8 +411,6 @@ void QXcbKeyboard::updateKeymap()
+     updateXKBMods();
+ 
+     QXkbCommon::verifyHasLatinLayout(m_xkbKeymap.get());
+-
+-    m_config = true;
+ }
+ 
+ QList<int> QXcbKeyboard::possibleKeys(const QKeyEvent *event) const
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
+index b652c85fe3..0ee08aeff2 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
++++ b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
+@@ -69,7 +69,6 @@ public:
+ 
+     Qt::KeyboardModifiers translateModifiers(int s) const;
+     void updateKeymap(xcb_mapping_notify_event_t *event);
+-    void updateKeymap(xcb_xkb_new_keyboard_notify_event_t *event);
+     void updateKeymap();
+     QList<int> possibleKeys(const QKeyEvent *event) const;
+ 
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp b/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
+index ffda7b6a57..863e961f4c 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
+@@ -564,11 +564,6 @@ void QXcbWindow::setGeometry(const QRect &rect)
+ {
+     QPlatformWindow::setGeometry(rect);
+ 
+-    if (shouldDeferTask(Task::SetGeometry)) {
+-        m_deferredGeometry = rect;
+-        return;
+-    }
+-
+     propagateSizeHints();
+ 
+     QXcbScreen *currentScreen = xcbScreen();
+@@ -693,9 +688,6 @@ void QXcbWindow::setVisible(bool visible)
+ 
+ void QXcbWindow::show()
+ {
+-    if (shouldDeferTask(Task::Map))
+-        return;
+-
+     if (window()->isTopLevel()) {
+ 
+         // update WM_NORMAL_HINTS
+@@ -706,7 +698,7 @@ void QXcbWindow::show()
+         if (isTransient(window())) {
+             const QWindow *tp = window()->transientParent();
+             if (tp && tp->handle())
+-                transientXcbParent = static_cast<const QXcbWindow *>(tp->handle())->winId();
++                transientXcbParent = tp->handle()->winId();
+             // Default to client leader if there is no transient parent, else modal dialogs can
+             // be hidden by their parents.
+             if (!transientXcbParent)
+@@ -746,10 +738,6 @@ void QXcbWindow::show()
+ 
+ void QXcbWindow::hide()
+ {
+-    if (shouldDeferTask(Task::Unmap))
+-        return;
+-
+-    m_wmStateValid = false;
+     xcb_unmap_window(xcb_connection(), m_window);
+ 
+     // send synthetic UnmapNotify event according to icccm 4.1.4
+@@ -909,9 +897,6 @@ QXcbWindow::NetWmStates QXcbWindow::netWmStates()
+ 
+ void QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
+ {
+-    if (shouldDeferTask(Task::SetWindowFlags))
+-        return;
+-
+     Qt::WindowType type = static_cast<Qt::WindowType>(int(flags & Qt::WindowType_Mask));
+ 
+     if (type == Qt::ToolTip)
+@@ -941,8 +926,6 @@ void QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
+ 
+     setTransparentForMouseEvents(flags & Qt::WindowTransparentForInput);
+     updateDoesNotAcceptFocus(flags & Qt::WindowDoesNotAcceptFocus);
+-
+-    m_isWmManagedWindow = !(flags & Qt::X11BypassWindowManagerHint);
+ }
+ 
+ void QXcbWindow::setMotifWmHints(Qt::WindowFlags flags)
+@@ -1142,9 +1125,6 @@ void QXcbWindow::setWindowState(Qt::WindowStates state)
+     if (state == m_windowState)
+         return;
+ 
+-    if (shouldDeferTask(Task::SetWindowState))
+-        return;
+-
+     // unset old state
+     if (m_windowState & Qt::WindowMinimized)
+         xcb_map_window(xcb_connection(), m_window);
+@@ -1350,6 +1330,12 @@ void QXcbWindow::setWindowIcon(const QIcon &icon)
+     }
+ 
+     if (!icon_data.isEmpty()) {
++        // Ignore icon exceeding maximum xcb request length
++        if (icon_data.size() > xcb_get_maximum_request_length(xcb_connection())) {
++            qWarning("Ignoring window icon: Size %llu exceeds maximum xcb request length %u.",
++                     icon_data.size(), xcb_get_maximum_request_length(xcb_connection()));
++            return;
++        }
+         xcb_change_property(xcb_connection(),
+                             XCB_PROP_MODE_REPLACE,
+                             m_window,
+@@ -1639,7 +1625,7 @@ void QXcbWindow::setWmWindowType(QXcbWindowFunctions::WmWindowTypes types, Qt::W
+         break;
+     }
+ 
+-    if ((flags & Qt::FramelessWindowHint) && !(type & QXcbWindowFunctions::KdeOverride)) {
++    if ((flags & Qt::FramelessWindowHint) && !(types & QXcbWindowFunctions::KdeOverride)) {
+         // override netwm type - quick and easy for KDE noborder
+         atoms.append(atom(QXcbAtom::_KDE_NET_WM_WINDOW_TYPE_OVERRIDE));
+     }
+@@ -1894,10 +1880,6 @@ void QXcbWindow::handleUnmapNotifyEvent(const xcb_unmap_notify_event_t *event)
+     if (event->window == m_window) {
+         m_mapped = false;
+         QWindowSystemInterface::handleExposeEvent(window(), QRegion());
+-        if (!m_isWmManagedWindow || parent()) {
+-            m_wmStateValid = true;
+-            handleDeferredTasks();
+-        }
+     }
+ }
+ 
+@@ -2212,98 +2194,30 @@ void QXcbWindow::handleLeaveNotifyEvent(const xcb_leave_notify_event_t *event)
+     handleLeaveNotifyEvent(event->root_x, event->root_y, event->mode, event->detail, event->time);
+ }
+ 
+-bool QXcbWindow::shouldDeferTask(Task task)
+-{
+-    if (m_wmStateValid)
+-        return false;
+-
+-    m_deferredTasks.append(task);
+-    return true;
+-}
+-
+-void QXcbWindow::handleDeferredTasks()
+-{
+-    Q_ASSERT(m_wmStateValid == true);
+-    if (m_deferredTasks.isEmpty())
+-        return;
+-
+-    bool map = false;
+-    bool unmap = false;
+-
+-    QVector<Task> tasks;
+-    for (auto taskIt = m_deferredTasks.rbegin(); taskIt != m_deferredTasks.rend(); ++taskIt) {
+-        if (!tasks.contains(*taskIt))
+-            tasks.prepend(*taskIt);
+-    }
+-
+-    for (Task task : tasks) {
+-        switch (task) {
+-        case Task::Map:
+-            map = true;
+-            unmap = false;
+-            break;
+-        case Task::Unmap:
+-            unmap = true;
+-            map = false;
+-            break;
+-        case Task::SetGeometry:
+-            setGeometry(m_deferredGeometry);
+-            break;
+-        case Task::SetWindowFlags:
+-            setWindowFlags(window()->flags());
+-            break;
+-        case Task::SetWindowState:
+-            setWindowState(window()->windowState());
+-            break;
+-        }
+-    }
+-    m_deferredTasks.clear();
+-
+-    if (map) {
+-        Q_ASSERT(unmap == false);
+-        show();
+-    }
+-    if (unmap) {
+-        Q_ASSERT(map == false);
+-        hide();
+-    }
+-}
+-
+ void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *event)
+ {
+     connection()->setTime(event->time);
+ 
+-    const bool wmStateChanged = event->atom == atom(QXcbAtom::WM_STATE);
+-    const bool netWmStateChanged = event->atom == atom(QXcbAtom::_NET_WM_STATE);
+-    if (netWmStateChanged || wmStateChanged) {
+-        if (wmStateChanged && !m_wmStateValid && m_isWmManagedWindow) {
+-            // ICCCM 4.1.4
+-            // Clients that want to re-use a client window (e.g. by mapping it again)
+-            // after withdrawing it must wait for the withdrawal to be complete before
+-            // proceeding. The preferred method for doing this is for clients to wait for
+-            // a window manager to update or remove the WM_STATE property.
+-            m_wmStateValid = true;
+-            handleDeferredTasks();
+-        }
+-        if (event->state == XCB_PROPERTY_DELETE)
++    const bool propertyDeleted = event->state == XCB_PROPERTY_DELETE;
++
++    if (event->atom == atom(QXcbAtom::_NET_WM_STATE) || event->atom == atom(QXcbAtom::WM_STATE)) {
++        if (propertyDeleted)
+             return;
+ 
+-        if (wmStateChanged) {
++        Qt::WindowStates newState = Qt::WindowNoState;
++
++        if (event->atom == atom(QXcbAtom::WM_STATE)) { // WM_STATE: Quick check for 'Minimize'.
+             auto reply = Q_XCB_REPLY(xcb_get_property, xcb_connection(),
+                                      0, m_window, atom(QXcbAtom::WM_STATE),
+                                      XCB_ATOM_ANY, 0, 1024);
+             if (reply && reply->format == 32 && reply->type == atom(QXcbAtom::WM_STATE)) {
+-                auto data = static_cast<const quint32 *>(xcb_get_property_value(reply.get()));
+-                if (reply->length != 0) {
+-                    const bool changedToWithdrawn = data[0] == XCB_ICCCM_WM_STATE_WITHDRAWN;
+-                    const bool changedToIconic = data[0] == XCB_ICCCM_WM_STATE_ICONIC;
+-                    m_minimized = changedToIconic || (changedToWithdrawn && m_minimized);
+-                }
++                const quint32 *data = (const quint32 *)xcb_get_property_value(reply.get());
++                if (reply->length != 0)
++                    m_minimized = (data[0] == XCB_ICCCM_WM_STATE_ICONIC
++                                   || (data[0] == XCB_ICCCM_WM_STATE_WITHDRAWN && m_minimized));
+             }
+         }
+ 
+-        // _NET_WM_STATE handling
+-        Qt::WindowStates newState = Qt::WindowNoState;
+         const NetWmStates states = netWmStates();
+         // _NET_WM_STATE_HIDDEN should be set by the Window Manager to indicate that a window would
+         // not be visible on the screen if its desktop/viewport were active and its coordinates were
+@@ -2325,6 +2239,7 @@ void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *ev
+             if ((m_windowState & Qt::WindowMinimized) && connection()->mouseGrabber() == this)
+                 connection()->setMouseGrabber(nullptr);
+         }
++        return;
+     } else if (event->atom == atom(QXcbAtom::_NET_FRAME_EXTENTS)) {
+         m_dirtyFrameMargins = true;
+     }
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbwindow.h b/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
+index 55af9279b1..6f5c1f5ed9 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
++++ b/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
+@@ -74,14 +74,6 @@ public:
+ 
+     Q_DECLARE_FLAGS(NetWmStates, NetWmState)
+ 
+-    enum Task {
+-        Map,
+-        Unmap,
+-        SetGeometry,
+-        SetWindowFlags,
+-        SetWindowState
+-    };
+-
+     QXcbWindow(QWindow *window);
+     ~QXcbWindow();
+ 
+@@ -151,9 +143,6 @@ public:
+ 
+     QXcbWindow *toWindow() override;
+ 
+-    bool shouldDeferTask(Task task);
+-    void handleDeferredTasks();
+-
+     void handleMouseEvent(xcb_timestamp_t time, const QPoint &local, const QPoint &global,
+                           Qt::KeyboardModifiers modifiers, QEvent::Type type, Qt::MouseEventSource source);
+ 
+@@ -292,11 +281,6 @@ protected:
+     int m_swapInterval = -1;
+ 
+     qreal m_sizeHintsScaleFactor = 1.0;
+-
+-    bool m_wmStateValid = true;
+-    QVector<Task> m_deferredTasks;
+-    bool m_isWmManagedWindow = true;
+-    QRect m_deferredGeometry;
+ };
+ 
+ class QXcbForeignWindow : public QXcbWindow
+diff --git a/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp b/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
+index d9d117faeb..640b49daa0 100644
+--- a/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
++++ b/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
+@@ -85,6 +85,7 @@ QGtk3MenuItem::QGtk3MenuItem()
+       m_checkable(false),
+       m_checked(false),
+       m_enabled(true),
++      m_exclusive(false),
+       m_underline(false),
+       m_invalid(true),
+       m_menu(nullptr),
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
+index 0048bbc1e6..396e7f6d1c 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
+@@ -102,15 +102,12 @@ const QDBusArgument &operator >>(const QDBusArgument &arg, QXdgDesktopPortalFile
+ class QXdgDesktopPortalFileDialogPrivate
+ {
+ public:
+-    QXdgDesktopPortalFileDialogPrivate(QPlatformFileDialogHelper *nativeFileDialog)
++    QXdgDesktopPortalFileDialogPrivate(QPlatformFileDialogHelper *nativeFileDialog, uint fileChooserPortalVersion)
+         : nativeFileDialog(nativeFileDialog)
++        , fileChooserPortalVersion(fileChooserPortalVersion)
+     { }
+ 
+-    WId winId = 0;
+-    bool directoryMode = false;
+-    bool modal = false;
+-    bool multipleFiles = false;
+-    bool saveFile = false;
++    QEventLoop loop;
+     QString acceptLabel;
+     QString directory;
+     QString title;
+@@ -121,19 +118,27 @@ public:
+     QString selectedMimeTypeFilter;
+     QString selectedNameFilter;
+     QStringList selectedFiles;
+-    QPlatformFileDialogHelper *nativeFileDialog = nullptr;
++    std::unique_ptr<QPlatformFileDialogHelper> nativeFileDialog;
++    uint fileChooserPortalVersion = 0;
++    bool failedToOpen = false;
++    bool directoryMode = false;
++    bool multipleFiles = false;
++    bool saveFile = false;
+ };
+ 
+-QXdgDesktopPortalFileDialog::QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog)
++QXdgDesktopPortalFileDialog::QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog, uint fileChooserPortalVersion)
+     : QPlatformFileDialogHelper()
+-    , d_ptr(new QXdgDesktopPortalFileDialogPrivate(nativeFileDialog))
++    , d_ptr(new QXdgDesktopPortalFileDialogPrivate(nativeFileDialog, fileChooserPortalVersion))
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+     if (d->nativeFileDialog) {
+-        connect(d->nativeFileDialog, SIGNAL(accept()), this, SIGNAL(accept()));
+-        connect(d->nativeFileDialog, SIGNAL(reject()), this, SIGNAL(reject()));
++        connect(d->nativeFileDialog.get(), SIGNAL(accept()), this, SIGNAL(accept()));
++        connect(d->nativeFileDialog.get(), SIGNAL(reject()), this, SIGNAL(reject()));
+     }
++
++    d->loop.connect(this, SIGNAL(accept()), SLOT(quit()));
++    d->loop.connect(this, SIGNAL(reject()), SLOT(quit()));
+ }
+ 
+ QXdgDesktopPortalFileDialog::~QXdgDesktopPortalFileDialog()
+@@ -177,7 +182,7 @@ void QXdgDesktopPortalFileDialog::initializeDialog()
+     setDirectory(options()->initialDirectory());
+ }
+ 
+-void QXdgDesktopPortalFileDialog::openPortal()
++void QXdgDesktopPortalFileDialog::openPortal(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent)
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+@@ -185,13 +190,13 @@ void QXdgDesktopPortalFileDialog::openPortal()
+                                                           QLatin1String("/org/freedesktop/portal/desktop"),
+                                                           QLatin1String("org.freedesktop.portal.FileChooser"),
+                                                           d->saveFile ? QLatin1String("SaveFile") : QLatin1String("OpenFile"));
+-    QString parentWindowId = QLatin1String("x11:") + QString::number(d->winId, 16);
++    QString parentWindowId = QLatin1String("x11:") + QString::number(parent ? parent->winId() : 0, 16);
+ 
+     QVariantMap options;
+     if (!d->acceptLabel.isEmpty())
+         options.insert(QLatin1String("accept_label"), d->acceptLabel);
+ 
+-    options.insert(QLatin1String("modal"), d->modal);
++    options.insert(QLatin1String("modal"), windowModality != Qt::NonModal);
+     options.insert(QLatin1String("multiple"), d->multipleFiles);
+     options.insert(QLatin1String("directory"), d->directoryMode);
+ 
+@@ -290,10 +295,18 @@ void QXdgDesktopPortalFileDialog::openPortal()
+ 
+     QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
+     QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingCall);
+-    connect(watcher, &QDBusPendingCallWatcher::finished, this, [this] (QDBusPendingCallWatcher *watcher) {
++    connect(watcher, &QDBusPendingCallWatcher::finished, this, [=] (QDBusPendingCallWatcher *watcher) {
+         QDBusPendingReply<QDBusObjectPath> reply = *watcher;
+-        if (reply.isError()) {
+-            Q_EMIT reject();
++        // Any error means the dialog is not shown and we need to fallback
++        d->failedToOpen = reply.isError();
++        if (d->failedToOpen) {
++            if (d->nativeFileDialog) {
++                d->nativeFileDialog->show(windowFlags, windowModality, parent);
++                if (d->loop.isRunning())
++                    d->nativeFileDialog->exec();
++            } else {
++                Q_EMIT reject();
++            }
+         } else {
+             QDBusConnection::sessionBus().connect(nullptr,
+                                                   reply.value().path(),
+@@ -302,6 +315,7 @@ void QXdgDesktopPortalFileDialog::openPortal()
+                                                   this,
+                                                   SLOT(gotResponse(uint,QVariantMap)));
+         }
++        watcher->deleteLater();
+     });
+ }
+ 
+@@ -326,7 +340,7 @@ QUrl QXdgDesktopPortalFileDialog::directory() const
+ {
+     Q_D(const QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog())
+         return d->nativeFileDialog->directory();
+ 
+     return d->directory;
+@@ -348,7 +362,7 @@ QList<QUrl> QXdgDesktopPortalFileDialog::selectedFiles() const
+ {
+     Q_D(const QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog())
+         return d->nativeFileDialog->selectedFiles();
+ 
+     QList<QUrl> files;
+@@ -403,16 +417,13 @@ void QXdgDesktopPortalFileDialog::exec()
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly)) {
++    if (d->nativeFileDialog && useNativeFileDialog()) {
+         d->nativeFileDialog->exec();
+         return;
+     }
+ 
+     // HACK we have to avoid returning until we emit that the dialog was accepted or rejected
+-    QEventLoop loop;
+-    loop.connect(this, SIGNAL(accept()), SLOT(quit()));
+-    loop.connect(this, SIGNAL(reject()), SLOT(quit()));
+-    loop.exec();
++    d->loop.exec();
+ }
+ 
+ void QXdgDesktopPortalFileDialog::hide()
+@@ -429,13 +440,10 @@ bool QXdgDesktopPortalFileDialog::show(Qt::WindowFlags windowFlags, Qt::WindowMo
+ 
+     initializeDialog();
+ 
+-    d->modal = windowModality != Qt::NonModal;
+-    d->winId = parent ? parent->winId() : 0;
+-
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog(OpenFallback))
+         return d->nativeFileDialog->show(windowFlags, windowModality, parent);
+ 
+-    openPortal();
++    openPortal(windowFlags, windowModality, parent);
+ 
+     return true;
+ }
+@@ -465,4 +473,21 @@ void QXdgDesktopPortalFileDialog::gotResponse(uint response, const QVariantMap &
+     }
+ }
+ 
++bool QXdgDesktopPortalFileDialog::useNativeFileDialog(QXdgDesktopPortalFileDialog::FallbackType fallbackType) const
++{
++    Q_D(const QXdgDesktopPortalFileDialog);
++
++    if (d->failedToOpen && fallbackType != OpenFallback)
++        return true;
++
++    if (d->fileChooserPortalVersion < 3) {
++        if (options()->fileMode() == QFileDialogOptions::Directory)
++            return true;
++        else if (options()->fileMode() == QFileDialogOptions::DirectoryOnly)
++            return true;
++    }
++
++    return false;
++}
++
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
+index 4f4de96ecf..65e22a5cf2 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
+@@ -51,6 +51,11 @@ class QXdgDesktopPortalFileDialog : public QPlatformFileDialogHelper
+     Q_OBJECT
+     Q_DECLARE_PRIVATE(QXdgDesktopPortalFileDialog)
+ public:
++    enum FallbackType {
++        GenericFallback,
++        OpenFallback
++    };
++
+     enum ConditionType : uint {
+         GlobalPattern = 0,
+         MimeType = 1
+@@ -69,7 +74,7 @@ public:
+     };
+     typedef QVector<Filter> FilterList;
+ 
+-    QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog = nullptr);
++    QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog = nullptr, uint fileChooserPortalVersion = 0);
+     ~QXdgDesktopPortalFileDialog();
+ 
+     bool defaultNameFilterDisables() const override;
+@@ -92,7 +97,8 @@ private Q_SLOTS:
+ 
+ private:
+     void initializeDialog();
+-    void openPortal();
++    void openPortal(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent);
++    bool useNativeFileDialog(FallbackType fallbackType = GenericFallback) const;
+ 
+     QScopedPointer<QXdgDesktopPortalFileDialogPrivate> d_ptr;
+ };
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
+index fb324afbd8..b809503122 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
+@@ -111,6 +111,7 @@ QXdgDesktopPortalTheme::QXdgDesktopPortalTheme()
+         if (reply.isValid()) {
+             d->fileChooserPortalVersion = reply.value().toUInt();
+         }
++        watcher->deleteLater();
+     });
+ }
+ 
+@@ -152,11 +153,12 @@ QPlatformDialogHelper* QXdgDesktopPortalTheme::createPlatformDialogHelper(Dialog
+ {
+     Q_D(const QXdgDesktopPortalTheme);
+ 
+-    if (type == FileDialog) {
++    if (type == FileDialog && d->fileChooserPortalVersion) {
+         // Older versions of FileChooser portal don't support opening directories, therefore we fallback
+         // to native file dialog opened inside the sandbox to open a directory.
+-        if (d->fileChooserPortalVersion < 3 && d->baseTheme->usePlatformNativeDialog(type))
+-            return new QXdgDesktopPortalFileDialog(static_cast<QPlatformFileDialogHelper*>(d->baseTheme->createPlatformDialogHelper(type)));
++        if (d->baseTheme->usePlatformNativeDialog(type))
++            return new QXdgDesktopPortalFileDialog(static_cast<QPlatformFileDialogHelper*>(d->baseTheme->createPlatformDialogHelper(type)),
++                                                   d->fileChooserPortalVersion);
+ 
+         return new QXdgDesktopPortalFileDialog;
+     }
+diff --git a/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp b/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
+index 43d5e119ad..1f9cbc4565 100644
+--- a/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
++++ b/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
+@@ -89,8 +89,10 @@ void QCupsPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &v
+         break;
+     case PPK_Duplex: {
+         QPrint::DuplexMode mode = QPrint::DuplexMode(value.toInt());
+-        if (mode != d->duplex && d->m_printDevice.supportedDuplexModes().contains(mode))
++        if (d->m_printDevice.supportedDuplexModes().contains(mode)) {
+             d->duplex = mode;
++            d->duplexRequestedExplicitly = true;
++        }
+         break;
+     }
+     case PPK_PrinterName:
+@@ -277,9 +279,12 @@ void QCupsPrintEnginePrivate::changePrinter(const QString &newPrinter)
+     m_printDevice.swap(printDevice);
+     printerName = m_printDevice.id();
+ 
+-    // Check if new printer supports current settings, otherwise us defaults
+-    if (duplex != QPrint::DuplexAuto && !m_printDevice.supportedDuplexModes().contains(duplex))
++    // in case a duplex value was explicitly set, check if new printer supports current value,
++    // otherwise use device default
++    if (!duplexRequestedExplicitly || !m_printDevice.supportedDuplexModes().contains(duplex)) {
+         duplex = m_printDevice.defaultDuplexMode();
++        duplexRequestedExplicitly = false;
++    }
+     QPrint::ColorMode colorMode = grayscale ? QPrint::GrayScale : QPrint::Color;
+     if (!m_printDevice.supportedColorModes().contains(colorMode))
+         grayscale = m_printDevice.defaultColorMode() == QPrint::GrayScale;
+diff --git a/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h b/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
+index c021b0c643..8f81fe478d 100644
+--- a/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
++++ b/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
+@@ -100,6 +100,7 @@ private:
+     QStringList cupsOptions;
+     QString cupsTempFile;
+     QPrint::DuplexMode duplex;
++    bool duplexRequestedExplicitly = false;
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp b/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
+index 67e7154fa6..40876152e5 100644
+--- a/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
++++ b/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
+@@ -817,7 +817,7 @@ bool QIBaseResultPrivate::writeArray(int column, const QList<QVariant> &list)
+     ba.resize(int(bufLen));
+ 
+     if (list.size() > arraySize) {
+-        error = QLatin1String("Array size missmatch: size of %1 is %2, size of provided list is %3");
++        error = QLatin1String("Array size mismatch: size of %1 is %2, size of provided list is %3");
+         error = error.arg(QLatin1String(sqlname)).arg(arraySize).arg(list.size());
+         q->setLastError(QSqlError(error, QLatin1String(""), QSqlError::StatementError));
+         return false;
+diff --git a/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp b/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
+index 7ca055eea2..6bc9d46755 100644
+--- a/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
++++ b/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
+@@ -223,7 +223,7 @@ public:
+     struct QMyField
+     {
+         char *outField = nullptr;
+-        MYSQL_FIELD *myField = nullptr;
++        const MYSQL_FIELD *myField = nullptr;
+         QMetaType::Type type = QMetaType::UnknownType;
+         my_bool nullIndicator = false;
+         ulong bufLength = 0ul;
+@@ -361,7 +361,7 @@ static bool qIsInteger(int t)
+ void QMYSQLResultPrivate::bindBlobs()
+ {
+     int i;
+-    MYSQL_FIELD *fieldInfo;
++    const MYSQL_FIELD *fieldInfo;
+     MYSQL_BIND *bind;
+ 
+     for(i = 0; i < fields.count(); ++i) {
+@@ -379,7 +379,6 @@ void QMYSQLResultPrivate::bindBlobs()
+ bool QMYSQLResultPrivate::bindInValues()
+ {
+     MYSQL_BIND *bind;
+-    char *field;
+     int i = 0;
+ 
+     if (!meta)
+@@ -392,35 +391,34 @@ bool QMYSQLResultPrivate::bindInValues()
+     inBinds = new MYSQL_BIND[fields.size()];
+     memset(inBinds, 0, fields.size() * sizeof(MYSQL_BIND));
+ 
+-    MYSQL_FIELD *fieldInfo;
++    const MYSQL_FIELD *fieldInfo;
+ 
+     while((fieldInfo = mysql_fetch_field(meta))) {
++        bind = &inBinds[i];
++
+         QMyField &f = fields[i];
+         f.myField = fieldInfo;
+-
++        bind->buffer_length = f.bufLength = fieldInfo->length + 1;
++        bind->buffer_type = fieldInfo->type;
+         f.type = qDecodeMYSQLType(fieldInfo->type, fieldInfo->flags);
+         if (qIsBlob(fieldInfo->type)) {
+             // the size of a blob-field is available as soon as we call
+             // mysql_stmt_store_result()
+             // after mysql_stmt_exec() in QMYSQLResult::exec()
+-            fieldInfo->length = 0;
++            bind->buffer_length = f.bufLength = 0;
+             hasBlobs = true;
+         } else if (qIsInteger(f.type)) {
+-            fieldInfo->length = 8;
++            bind->buffer_length = f.bufLength = 8;
+         } else {
+-            fieldInfo->type = MYSQL_TYPE_STRING;
++            bind->buffer_type = MYSQL_TYPE_STRING;
+         }
+-        bind = &inBinds[i];
+-        field = new char[fieldInfo->length + 1];
+-        memset(field, 0, fieldInfo->length + 1);
+ 
+-        bind->buffer_type = fieldInfo->type;
+-        bind->buffer = field;
+-        bind->buffer_length = f.bufLength = fieldInfo->length + 1;
+         bind->is_null = &f.nullIndicator;
+         bind->length = &f.bufLength;
+         bind->is_unsigned = fieldInfo->flags & UNSIGNED_FLAG ? 1 : 0;
+-        f.outField=field;
++
++        char *field = new char[bind->buffer_length + 1]{};
++        bind->buffer = f.outField = field;
+ 
+         ++i;
+     }
+@@ -1369,20 +1367,20 @@ bool QMYSQLDriver::open(const QString& db,
+     }
+ 
+ #if MYSQL_VERSION_ID >= 50007
+-    if (mysql_get_client_version() >= 50503 && mysql_get_server_version(d->mysql) >= 50503) {
+-        // force the communication to be utf8mb4 (only utf8mb4 supports 4-byte characters)
+-        mysql_set_character_set(d->mysql, "utf8mb4");
++    // force the communication to be utf8mb4 (only utf8mb4 supports 4-byte characters)
++    if (mysql_set_character_set(d->mysql, "utf8mb4")) {
++        // this failed, try forcing it to utf (BMP only)
++        if (mysql_set_character_set(d->mysql, "utf8"))
++            qWarning() << "MySQL: Unable to set the client character set to utf8.";
+ #if QT_CONFIG(textcodec)
+-        d->tc = QTextCodec::codecForName("UTF-8");
++        else
++            d->tc = codec(d->mysql);
+ #endif
+-    } else
+-    {
+-        // force the communication to be utf8
+-        mysql_set_character_set(d->mysql, "utf8");
++    }
+ #if QT_CONFIG(textcodec)
+-        d->tc = codec(d->mysql);
++    else
++        d->tc = QTextCodec::codecForName("UTF-8");
+ #endif
+-    }
+ #endif  // MYSQL_VERSION_ID >= 50007
+ 
+     d->preparedQuerysEnabled = checkPreparedQueries(d->mysql);
+diff --git a/qtbase/src/printsupport/dialogs/images/print-24.png b/qtbase/src/printsupport/dialogs/images/printer-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/print-24.png
+rename to src/printsupport/dialogs/images/printer-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/print-32.png b/qtbase/src/printsupport/dialogs/images/printer-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/print-32.png
+rename to src/printsupport/dialogs/images/printer-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-sided-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-facing-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-sided-24.png
+rename to src/printsupport/dialogs/images/view-pages-facing-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-sided-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-facing-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-sided-32.png
+rename to src/printsupport/dialogs/images/view-pages-facing-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-multi-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-overview-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-multi-24.png
+rename to src/printsupport/dialogs/images/view-pages-overview-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-multi-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-overview-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-multi-32.png
+rename to src/printsupport/dialogs/images/view-pages-overview-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-one-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-single-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-one-24.png
+rename to src/printsupport/dialogs/images/view-pages-single-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-one-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-single-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-one-32.png
+rename to src/printsupport/dialogs/images/view-pages-single-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-page-24.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-page-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-page-24.png
+rename to src/printsupport/dialogs/images/zoom-fit-page-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-page-32.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-page-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-page-32.png
+rename to src/printsupport/dialogs/images/zoom-fit-page-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-width-24.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-width-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-width-24.png
+rename to src/printsupport/dialogs/images/zoom-fit-width-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-width-32.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-width-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-width-32.png
+rename to src/printsupport/dialogs/images/zoom-fit-width-32.png
+diff --git a/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp b/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
+index 78e5b8d1ef..2a28516719 100644
+--- a/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
++++ b/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
+@@ -532,6 +532,7 @@ void QPageSetupWidget::updateWidget()
+ void QPageSetupWidget::setupPrinter() const
+ {
+     m_printer->setPageLayout(m_pageLayout);
++    m_printer->setPageOrientation(m_pageLayout.orientation());
+ #if QT_CONFIG(cups)
+     QCUPSSupport::PagesPerSheet pagesPerSheet = qvariant_cast<QCUPSSupport::PagesPerSheet>(m_ui.pagesPerSheetCombo->currentData()
+ );
+diff --git a/qtbase/src/printsupport/dialogs/qprintdialog.qrc b/qtbase/src/printsupport/dialogs/qprintdialog.qrc
+index 5a579baa55..10b8e1d341 100644
+--- a/qtbase/src/printsupport/dialogs/qprintdialog.qrc
++++ b/qtbase/src/printsupport/dialogs/qprintdialog.qrc
+@@ -1,9 +1,9 @@
+ <!DOCTYPE RCC><RCC version="1.0">
+ <qresource prefix="/qt-project.org/dialogs/qprintpreviewdialog">
+-<file>images/fit-page-24.png</file>
+-<file>images/fit-page-32.png</file>
+-<file>images/fit-width-24.png</file>
+-<file>images/fit-width-32.png</file>
++<file>images/zoom-fit-page-24.png</file>
++<file>images/zoom-fit-page-32.png</file>
++<file>images/zoom-fit-width-24.png</file>
++<file>images/zoom-fit-width-32.png</file>
+ <file>images/go-first-24.png</file>
+ <file>images/go-first-32.png</file>
+ <file>images/go-last-24.png</file>
+@@ -18,14 +18,14 @@
+ <file>images/layout-portrait-32.png</file>
+ <file>images/page-setup-24.png</file>
+ <file>images/page-setup-32.png</file>
+-<file>images/print-24.png</file>
+-<file>images/print-32.png</file>
+-<file>images/view-page-multi-24.png</file>
+-<file>images/view-page-multi-32.png</file>
+-<file>images/view-page-one-24.png</file>
+-<file>images/view-page-one-32.png</file>
+-<file>images/view-page-sided-24.png</file>
+-<file>images/view-page-sided-32.png</file>
++<file>images/printer-24.png</file>
++<file>images/printer-32.png</file>
++<file>images/view-pages-overview-24.png</file>
++<file>images/view-pages-overview-32.png</file>
++<file>images/view-pages-single-24.png</file>
++<file>images/view-pages-single-32.png</file>
++<file>images/view-pages-facing-24.png</file>
++<file>images/view-pages-facing-32.png</file>
+ <file>images/zoom-in-24.png</file>
+ <file>images/zoom-in-32.png</file>
+ <file>images/zoom-out-24.png</file>
+diff --git a/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp b/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
+index c5b845f4ec..5a5ba1d0a8 100644
+--- a/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
++++ b/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
+@@ -702,13 +702,14 @@ void QPrintDialogPrivate::selectPrinter(const QPrinter::OutputFormat outputForma
+         else
+             options.grayscale->setChecked(true);
+ 
+-        // keep duplex value explicitly set by user, if any, and selected printer supports it;
+-        // use device default otherwise
++        // duplex priorities to be as follows:
++        // 1) a user-selected duplex value in the dialog has highest prority
++        // 2) duplex value set in the QPrinter
+         QPrint::DuplexMode duplex;
+         if (explicitDuplexMode != QPrint::DuplexAuto && supportedDuplexMode.contains(explicitDuplexMode))
+             duplex = explicitDuplexMode;
+         else
+-            duplex = top->d->m_currentPrintDevice.defaultDuplexMode();
++            duplex = static_cast<QPrint::DuplexMode>(p->duplex());
+         switch (duplex) {
+         case QPrint::DuplexNone:
+             options.noDuplex->setChecked(true); break;
+@@ -1242,10 +1243,10 @@ void QUnixPrintWidgetPrivate::_q_printerChanged(int index)
+             QString filename = widget.filename->text();
+             widget.filename->setText(filename);
+             widget.lOutput->setEnabled(true);
+-            if (optionsPane)
+-                optionsPane->selectPrinter(QPrinter::PdfFormat);
+             printer->setOutputFormat(QPrinter::PdfFormat);
+             m_currentPrintDevice = QPrintDevice();
++            if (optionsPane)
++                optionsPane->selectPrinter(QPrinter::PdfFormat);
+             return;
+         }
+     }
+diff --git a/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp b/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
+index 39575d5f57..23b7e89538 100644
+--- a/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
++++ b/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
+@@ -352,7 +352,7 @@ void QPrintPreviewDialogPrivate::init(QPrinter *_printer)
+ static inline void qt_setupActionIcon(QAction *action, QLatin1String name)
+ {
+     QLatin1String imagePrefix(":/qt-project.org/dialogs/qprintpreviewdialog/images/");
+-    QIcon icon;
++    QIcon icon = QIcon::fromTheme(name);
+     icon.addFile(imagePrefix + name + QLatin1String("-24.png"), QSize(24, 24));
+     icon.addFile(imagePrefix + name + QLatin1String("-32.png"), QSize(32, 32));
+     action->setIcon(icon);
+@@ -383,8 +383,8 @@ void QPrintPreviewDialogPrivate::setupActions()
+     fitPageAction->setObjectName(QLatin1String("fitPageAction"));
+     fitWidthAction->setCheckable(true);
+     fitPageAction->setCheckable(true);
+-    qt_setupActionIcon(fitWidthAction, QLatin1String("fit-width"));
+-    qt_setupActionIcon(fitPageAction, QLatin1String("fit-page"));
++    qt_setupActionIcon(fitWidthAction, QLatin1String("zoom-fit-width"));
++    qt_setupActionIcon(fitPageAction, QLatin1String("zoom-fit-page"));
+     QObject::connect(fitGroup, SIGNAL(triggered(QAction*)), q, SLOT(_q_fit(QAction*)));
+ 
+     // Zoom
+@@ -410,9 +410,9 @@ void QPrintPreviewDialogPrivate::setupActions()
+     singleModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show single page"));
+     facingModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show facing pages"));
+     overviewModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show overview of all pages"));
+-    qt_setupActionIcon(singleModeAction, QLatin1String("view-page-one"));
+-    qt_setupActionIcon(facingModeAction, QLatin1String("view-page-sided"));
+-    qt_setupActionIcon(overviewModeAction, QLatin1String("view-page-multi"));
++    qt_setupActionIcon(singleModeAction, QLatin1String("view-pages-single"));
++    qt_setupActionIcon(facingModeAction, QLatin1String("view-pages-facing"));
++    qt_setupActionIcon(overviewModeAction, QLatin1String("view-pages-overview"));
+     singleModeAction->setObjectName(QLatin1String("singleModeAction"));
+     facingModeAction->setObjectName(QLatin1String("facingModeAction"));
+     overviewModeAction->setObjectName(QLatin1String("overviewModeAction"));
+@@ -426,7 +426,7 @@ void QPrintPreviewDialogPrivate::setupActions()
+     printerGroup = new QActionGroup(q);
+     printAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Print"));
+     pageSetupAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Page setup"));
+-    qt_setupActionIcon(printAction, QLatin1String("print"));
++    qt_setupActionIcon(printAction, QLatin1String("printer"));
+     qt_setupActionIcon(pageSetupAction, QLatin1String("page-setup"));
+     QObject::connect(printAction, SIGNAL(triggered(bool)), q, SLOT(_q_print()));
+     QObject::connect(pageSetupAction, SIGNAL(triggered(bool)), q, SLOT(_q_pageSetup()));
+diff --git a/qtbase/src/sql/kernel/qsqlquery.cpp b/qtbase/src/sql/kernel/qsqlquery.cpp
+index 32c6166c79..60afef10c3 100644
+--- a/qtbase/src/sql/kernel/qsqlquery.cpp
++++ b/qtbase/src/sql/kernel/qsqlquery.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2022 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtSql module of the Qt Toolkit.
+@@ -377,6 +377,10 @@ bool QSqlQuery::exec(const QString& query)
+     QElapsedTimer t;
+     t.start();
+ #endif
++    if (!driver()) {
++        qWarning("QSqlQuery::exec: called before driver has been set up");
++        return false;
++    }
+     if (d->ref.loadRelaxed() != 1) {
+         bool fo = isForwardOnly();
+         *this = QSqlQuery(driver()->createResult());
+diff --git a/qtbase/src/testlib/qabstractitemmodeltester.cpp b/qtbase/src/testlib/qabstractitemmodeltester.cpp
+index 8efb9c53d4..ce062f66d7 100644
+--- a/qtbase/src/testlib/qabstractitemmodeltester.cpp
++++ b/qtbase/src/testlib/qabstractitemmodeltester.cpp
+@@ -454,7 +454,7 @@ void QAbstractItemModelTesterPrivate::parent()
+ 
+     // Common error test #2, make sure that a second level index has a parent
+     // that is the first level index.
+-    if (model->rowCount(topIndex) > 0) {
++    if (model->rowCount(topIndex) > 0 && model->columnCount(topIndex) > 0) {
+         QModelIndex childIndex = model->index(0, 0, topIndex);
+         MODELTESTER_VERIFY(childIndex.isValid());
+         MODELTESTER_COMPARE(model->parent(childIndex), topIndex);
+diff --git a/qtbase/src/testlib/qasciikey.cpp b/qtbase/src/testlib/qasciikey.cpp
+index 9a308da2bc..93498b256f 100644
+--- a/qtbase/src/testlib/qasciikey.cpp
++++ b/qtbase/src/testlib/qasciikey.cpp
+@@ -498,6 +498,11 @@ char QTest::keyToAscii(Qt::Key key)
+     case Qt::Key_LaunchE : return 0; // = 0x10b0,
+     case Qt::Key_LaunchF : return 0; // = 0x10b1,
+ 
++    // Keypad navigation keys
++    case Qt::Key_Select : return 0; // = 0x01010000
++    case Qt::Key_Yes : return 0; // = 0x01010001
++    case Qt::Key_No : return 0; // = 0x01010002
++
+     default: QTEST_ASSERT(false); return 0;
+     }
+ }
+diff --git a/qtbase/src/testlib/qtestresult.cpp b/qtbase/src/testlib/qtestresult.cpp
+index 88028aac6e..2e89930776 100644
+--- a/qtbase/src/testlib/qtestresult.cpp
++++ b/qtbase/src/testlib/qtestresult.cpp
+@@ -251,7 +251,8 @@ bool QTestResult::verify(bool statement, const char *statementStr,
+ {
+     QTEST_ASSERT(statementStr);
+ 
+-    char msg[1024] = {'\0'};
++    char msg[1024];
++    msg[0] = '\0';
+ 
+     if (QTestLog::verboseLevel() >= 2) {
+         qsnprintf(msg, 1024, "QVERIFY(%s)", statementStr);
+@@ -309,7 +310,8 @@ static bool compareHelper(bool success, const char *failureMsg,
+                           bool hasValues = true)
+ {
+     const size_t maxMsgLen = 1024;
+-    char msg[maxMsgLen] = {'\0'};
++    char msg[maxMsgLen];
++    msg[0] = '\0';
+ 
+     QTEST_ASSERT(expected);
+     QTEST_ASSERT(actual);
+diff --git a/qtbase/src/widgets/dialogs/qcolordialog.cpp b/qtbase/src/widgets/dialogs/qcolordialog.cpp
+index 4247731275..cb325be85c 100644
+--- a/qtbase/src/widgets/dialogs/qcolordialog.cpp
++++ b/qtbase/src/widgets/dialogs/qcolordialog.cpp
+@@ -78,7 +78,10 @@
+ #include "qwindow.h"
+ 
+ #include "private/qdialog_p.h"
++#include "private/qguiapplication_p.h"
+ 
++#include <qpa/qplatformservices.h>
++#include <qpa/qplatformintegration.h>
+ #include <algorithm>
+ 
+ QT_BEGIN_NAMESPACE
+@@ -1611,6 +1614,20 @@ void QColorDialogPrivate::_q_newStandard(int r, int c)
+ void QColorDialogPrivate::_q_pickScreenColor()
+ {
+     Q_Q(QColorDialog);
++
++    auto *platformServices = QGuiApplicationPrivate::platformIntegration()->services();
++    if (platformServices->hasCapability(QPlatformServices::Capability::ColorPicking)) {
++        if (auto *colorPicker = platformServices->colorPicker(q->windowHandle())) {
++            q->connect(colorPicker, &QPlatformServiceColorPicker::colorPicked, q,
++                       [q, colorPicker](const QColor &color) {
++                           colorPicker->deleteLater();
++                           q->setCurrentColor(color);
++                       });
++            colorPicker->pickColor();
++            return;
++        }
++    }
++
+     if (!colorPickingEventFilter)
+         colorPickingEventFilter = new QColorPickingEventFilter(this, q);
+     q->installEventFilter(colorPickingEventFilter);
+diff --git a/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp b/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
+index e120817edc..8ea36b5427 100644
+--- a/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
++++ b/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
+@@ -400,12 +400,7 @@ bool QAbstractItemDelegate::helpEvent(QHelpEvent *event,
+         const QString tooltip = index.isValid() ?
+               d->textForRole(Qt::ToolTipRole, index.data(Qt::ToolTipRole), option.locale, precision) :
+               QString();
+-        QRect rect;
+-        if (index.isValid()) {
+-            const QRect r = view->visualRect(index);
+-            rect = QRect(view->mapToGlobal(r.topLeft()), r.size());
+-        }
+-        QToolTip::showText(he->globalPos(), tooltip, view, rect);
++        QToolTip::showText(he->globalPos(), tooltip, view->viewport(), option.rect);
+         event->setAccepted(!tooltip.isEmpty());
+         break;
+         }
+diff --git a/qtbase/src/widgets/itemviews/qlistview.cpp b/qtbase/src/widgets/itemviews/qlistview.cpp
+index 2b34476642..eebfaa030e 100644
+--- a/qtbase/src/widgets/itemviews/qlistview.cpp
++++ b/qtbase/src/widgets/itemviews/qlistview.cpp
+@@ -3386,6 +3386,7 @@ void QIconModeViewBase::updateContentsSize()
+ */
+ void QListView::currentChanged(const QModelIndex &current, const QModelIndex &previous)
+ {
++    QAbstractItemView::currentChanged(current, previous);
+ #ifndef QT_NO_ACCESSIBILITY
+     if (QAccessible::isActive()) {
+         if (current.isValid()) {
+@@ -3396,7 +3397,6 @@ void QListView::currentChanged(const QModelIndex &current, const QModelIndex &pr
+         }
+     }
+ #endif
+-    QAbstractItemView::currentChanged(current, previous);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/widgets/itemviews/qtableview.cpp b/qtbase/src/widgets/itemviews/qtableview.cpp
+index 934ac581b2..f79bb24249 100644
+--- a/qtbase/src/widgets/itemviews/qtableview.cpp
++++ b/qtbase/src/widgets/itemviews/qtableview.cpp
+@@ -1013,6 +1013,7 @@ void QTableViewPrivate::drawCell(QPainter *painter, const QStyleOptionViewItem &
+ int QTableViewPrivate::widthHintForIndex(const QModelIndex &index, int hint, const QStyleOptionViewItem &option) const
+ {
+     Q_Q(const QTableView);
++    const int oldHint = hint;
+     QWidget *editor = editorForIndex(index).widget.data();
+     if (editor && persistent.contains(editor)) {
+         hint = qMax(hint, editor->sizeHint().width());
+@@ -1021,6 +1022,17 @@ int QTableViewPrivate::widthHintForIndex(const QModelIndex &index, int hint, con
+         hint = qBound(min, hint, max);
+     }
+     hint = qMax(hint, q->itemDelegate(index)->sizeHint(option, index).width());
++
++    if (hasSpans()) {
++        auto span = spans.spanAt(index.column(), index.row());
++        if (span && span->m_left == index.column() && span->m_top == index.row()) {
++            // spans are screwed up when sections are moved
++            const auto left = logicalColumn(span->m_left);
++            for (int i = 1; i <= span->width(); ++i)
++               hint -= q->columnWidth(visualColumn(left + i));
++        }
++        hint = std::max(hint, oldHint);
++    }
+     return hint;
+ }
+ 
+@@ -1053,6 +1065,11 @@ int QTableViewPrivate::heightHintForIndex(const QModelIndex &index, int hint, QS
+         option.rect.setHeight(height);
+         option.rect.setX(q->columnViewportPosition(index.column()));
+         option.rect.setWidth(q->columnWidth(index.column()));
++        if (hasSpans()) {
++            auto span = spans.spanAt(index.column(), index.row());
++            if (span && span->m_left == index.column() && span->m_top == index.row())
++                option.rect.setWidth(std::max(option.rect.width(), visualSpanRect(*span).width()));
++        }
+         // 1px less space when grid is shown (see drawCell)
+         if (showGrid)
+             option.rect.setWidth(option.rect.width() - 1);
+diff --git a/qtbase/src/widgets/kernel/qaction.h b/qtbase/src/widgets/kernel/qaction.h
+index 258a1ea0a0..737c1e8285 100644
+--- a/qtbase/src/widgets/kernel/qaction.h
++++ b/qtbase/src/widgets/kernel/qaction.h
+@@ -81,7 +81,7 @@ class Q_WIDGETS_EXPORT QAction : public QObject
+     Q_PROPERTY(MenuRole menuRole READ menuRole WRITE setMenuRole NOTIFY changed)
+     Q_PROPERTY(bool iconVisibleInMenu READ isIconVisibleInMenu WRITE setIconVisibleInMenu NOTIFY changed)
+     Q_PROPERTY(bool shortcutVisibleInContextMenu READ isShortcutVisibleInContextMenu WRITE setShortcutVisibleInContextMenu NOTIFY changed)
+-    Q_PROPERTY(Priority priority READ priority WRITE setPriority)
++    Q_PROPERTY(Priority priority READ priority WRITE setPriority NOTIFY changed)
+ 
+ public:
+     // note this is copied into qplatformmenu.h, which must stay in sync
+diff --git a/qtbase/src/widgets/kernel/qwidget.cpp b/qtbase/src/widgets/kernel/qwidget.cpp
+index 9eba1e001e..26f6d27e18 100644
+--- a/qtbase/src/widgets/kernel/qwidget.cpp
++++ b/qtbase/src/widgets/kernel/qwidget.cpp
+@@ -5296,7 +5296,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
+         QWidgetEffectSourcePrivate *sourced = static_cast<QWidgetEffectSourcePrivate *>
+                                                          (source->d_func());
+         if (!sourced->context) {
+-            const QRegion effectRgn(rgn.boundingRect());
++            const QRegion effectRgn((flags & UseEffectRegionBounds) ? rgn.boundingRect() : rgn);
+             QWidgetPaintContext context(pdev, effectRgn, offset, flags, sharedPainter, repaintManager);
+             sourced->context = &context;
+             if (!sharedPainter) {
+@@ -5328,6 +5328,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
+         }
+     }
+ #endif // QT_CONFIG(graphicseffect)
++    flags = flags & ~UseEffectRegionBounds;
+ 
+     const bool alsoOnScreen = flags & DrawPaintOnScreen;
+     const bool recursive = flags & DrawRecursive;
+diff --git a/qtbase/src/widgets/kernel/qwidget_p.h b/qtbase/src/widgets/kernel/qwidget_p.h
+index eef6b8fa2c..c432f4b5d5 100644
+--- a/qtbase/src/widgets/kernel/qwidget_p.h
++++ b/qtbase/src/widgets/kernel/qwidget_p.h
+@@ -229,7 +229,8 @@ public:
+         DontSubtractOpaqueChildren = 0x10,
+         DontDrawOpaqueChildren = 0x20,
+         DontDrawNativeChildren = 0x40,
+-        DontSetCompositionMode = 0x80
++        DontSetCompositionMode = 0x80,
++        UseEffectRegionBounds = 0x100
+     };
+     Q_DECLARE_FLAGS(DrawWidgetFlags, DrawWidgetFlag)
+     Q_FLAG(DrawWidgetFlags)
+diff --git a/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp b/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
+index 02880b34da..0d44e1326d 100644
+--- a/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
++++ b/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
+@@ -1018,7 +1018,8 @@ void QWidgetRepaintManager::paintAndFlush()
+ 
+     // Paint the rest with composition.
+     if (repaintAllWidgets || !dirtyCopy.isEmpty()) {
+-        QWidgetPrivate::DrawWidgetFlags flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive;
++        QWidgetPrivate::DrawWidgetFlags flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive
++                | QWidgetPrivate::UseEffectRegionBounds;
+         tlw->d_func()->drawWidget(store->paintDevice(), dirtyCopy, QPoint(), flags, nullptr, this);
+     }
+ 
+diff --git a/qtbase/src/widgets/styles/qfusionstyle.cpp b/qtbase/src/widgets/styles/qfusionstyle.cpp
+index f4345d97c4..962912c838 100644
+--- a/qtbase/src/widgets/styles/qfusionstyle.cpp
++++ b/qtbase/src/widgets/styles/qfusionstyle.cpp
+@@ -1772,14 +1772,6 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio
+             proxy()->drawControl(CE_PushButtonLabel, &subopt, painter, widget);
+         }
+         break;
+-    case CE_PushButtonLabel:
+-        if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
+-            QStyleOptionButton b(*button);
+-            // no PM_ButtonShiftHorizontal and PM_ButtonShiftVertical for fusion style
+-            b.state &= ~(State_On | State_Sunken);
+-            QCommonStyle::drawControl(element, &b, painter, widget);
+-        }
+-        break;
+     case CE_MenuBarEmptyArea:
+         painter->save();
+     {
+diff --git a/qtbase/src/widgets/util/qcompleter.cpp b/qtbase/src/widgets/util/qcompleter.cpp
+index 18b24063d8..ef7207a8a3 100644
+--- a/qtbase/src/widgets/util/qcompleter.cpp
++++ b/qtbase/src/widgets/util/qcompleter.cpp
+@@ -1120,6 +1120,8 @@ void QCompleter::setModel(QAbstractItemModel *model)
+ {
+     Q_D(QCompleter);
+     QAbstractItemModel *oldModel = d->proxy->sourceModel();
++    if (oldModel == model)
++        return;
+ #if QT_CONFIG(filesystemmodel)
+     if (qobject_cast<const QFileSystemModel *>(oldModel))
+         setCompletionRole(Qt::EditRole); // QTBUG-54642, clear FileNameRole set by QFileSystemModel
+diff --git a/qtbase/src/widgets/widgets/qabstractbutton.cpp b/qtbase/src/widgets/widgets/qabstractbutton.cpp
+index a128b23950..dc40bf62fb 100644
+--- a/qtbase/src/widgets/widgets/qabstractbutton.cpp
++++ b/qtbase/src/widgets/widgets/qabstractbutton.cpp
+@@ -56,6 +56,7 @@
+ #ifndef QT_NO_ACCESSIBILITY
+ #include "qaccessible.h"
+ #endif
++#include <qpa/qplatformtheme.h>
+ 
+ #include <algorithm>
+ 
+@@ -1076,19 +1077,19 @@ void QAbstractButton::keyPressEvent(QKeyEvent *e)
+ {
+     Q_D(QAbstractButton);
+     bool next = true;
+-    switch (e->key()) {
+-    case Qt::Key_Enter:
+-    case Qt::Key_Return:
+-        e->ignore();
+-        break;
+-    case Qt::Key_Select:
+-    case Qt::Key_Space:
+-        if (!e->isAutoRepeat()) {
+-            setDown(true);
+-            repaint();
+-            d->emitPressed();
+-        }
+-        break;
++
++    const auto key = static_cast<Qt::Key>(e->key());
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(key) && !e->isAutoRepeat()) {
++        setDown(true);
++        repaint();
++        d->emitPressed();
++        return;
++    }
++
++    switch (key) {
+     case Qt::Key_Up:
+         next = false;
+         Q_FALLTHROUGH();
+@@ -1153,15 +1154,15 @@ void QAbstractButton::keyReleaseEvent(QKeyEvent *e)
+     if (!e->isAutoRepeat())
+         d->repeatTimer.stop();
+ 
+-    switch (e->key()) {
+-    case Qt::Key_Select:
+-    case Qt::Key_Space:
+-        if (!e->isAutoRepeat() && d->down)
+-            d->click();
+-        break;
+-    default:
+-        e->ignore();
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(static_cast<Qt::Key>(e->key())) && !e->isAutoRepeat() && d->down) {
++        d->click();
++        return;
+     }
++
++    e->ignore();
+ }
+ 
+ /*!\reimp
+diff --git a/qtbase/src/widgets/widgets/qcombobox.cpp b/qtbase/src/widgets/widgets/qcombobox.cpp
+index 7a496c27e0..0a3d96647b 100644
+--- a/qtbase/src/widgets/widgets/qcombobox.cpp
++++ b/qtbase/src/widgets/widgets/qcombobox.cpp
+@@ -3352,7 +3352,23 @@ void QComboBox::keyPressEvent(QKeyEvent *e)
+ 
+     Move move = NoMove;
+     int newIndex = currentIndex();
+-    switch (e->key()) {
++
++    bool pressLikeButton = !d->lineEdit;
++#ifdef QT_KEYPAD_NAVIGATION
++    pressLikeButton |= QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus();
++#endif
++    auto key = static_cast<Qt::Key>(e->key());
++    if (pressLikeButton) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(key)) {
++            showPopup();
++            return;
++        }
++    }
++
++    switch (key) {
+     case Qt::Key_Up:
+         if (e->modifiers() & Qt::ControlModifier)
+             break; // pass to line edit for auto completion
+@@ -3394,26 +3410,11 @@ void QComboBox::keyPressEvent(QKeyEvent *e)
+             return;
+         }
+         break;
+-    case Qt::Key_Space:
+-        if (!d->lineEdit) {
+-            showPopup();
+-            return;
+-        }
+-        break;
+-    case Qt::Key_Enter:
+-    case Qt::Key_Return:
+     case Qt::Key_Escape:
+         if (!d->lineEdit)
+             e->ignore();
+         break;
+ #ifdef QT_KEYPAD_NAVIGATION
+-    case Qt::Key_Select:
+-        if (QApplicationPrivate::keypadNavigationEnabled()
+-                && (!hasEditFocus() || !d->lineEdit)) {
+-            showPopup();
+-            return;
+-        }
+-        break;
+     case Qt::Key_Left:
+     case Qt::Key_Right:
+         if (QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus())
+diff --git a/qtbase/src/widgets/widgets/qdatetimeedit_p.h b/qtbase/src/widgets/widgets/qdatetimeedit_p.h
+index d36b6f8f9a..e0df5b5158 100644
+--- a/qtbase/src/widgets/widgets/qdatetimeedit_p.h
++++ b/qtbase/src/widgets/widgets/qdatetimeedit_p.h
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2018 The Qt Company Ltd.
++** Copyright (C) 2021 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtWidgets module of the Qt Toolkit.
+diff --git a/qtbase/src/widgets/widgets/qgroupbox.cpp b/qtbase/src/widgets/widgets/qgroupbox.cpp
+index 02a0bed325..3f3eccc370 100644
+--- a/qtbase/src/widgets/widgets/qgroupbox.cpp
++++ b/qtbase/src/widgets/widgets/qgroupbox.cpp
+@@ -54,6 +54,8 @@
+ #include "qaccessible.h"
+ #endif
+ #include <private/qwidget_p.h>
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
+ 
+ #include "qdebug.h"
+ 
+@@ -360,7 +362,10 @@ bool QGroupBox::event(QEvent *e)
+         return true;
+     case QEvent::KeyPress: {
+         QKeyEvent *k = static_cast<QKeyEvent*>(e);
+-        if (!k->isAutoRepeat() && (k->key() == Qt::Key_Select || k->key() == Qt::Key_Space)) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (!k->isAutoRepeat() && buttonPressKeys.contains(static_cast<Qt::Key>(k->key()))) {
+             d->pressedControl = QStyle::SC_GroupBoxCheckBox;
+             update(style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxCheckBox, this));
+             return true;
+@@ -369,7 +374,10 @@ bool QGroupBox::event(QEvent *e)
+     }
+     case QEvent::KeyRelease: {
+         QKeyEvent *k = static_cast<QKeyEvent*>(e);
+-        if (!k->isAutoRepeat() && (k->key() == Qt::Key_Select || k->key() == Qt::Key_Space)) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (!k->isAutoRepeat() && buttonPressKeys.contains(static_cast<Qt::Key>(k->key()))) {
+             bool toggle = (d->pressedControl == QStyle::SC_GroupBoxLabel
+                            || d->pressedControl == QStyle::SC_GroupBoxCheckBox);
+             d->pressedControl = QStyle::SC_None;
+diff --git a/qtbase/src/widgets/widgets/qlabel.cpp b/qtbase/src/widgets/widgets/qlabel.cpp
+index 30ff80cbb0..cf2605c17c 100644
+--- a/qtbase/src/widgets/widgets/qlabel.cpp
++++ b/qtbase/src/widgets/widgets/qlabel.cpp
+@@ -421,9 +421,6 @@ void QLabel::setPixmap(const QPixmap &pixmap)
+         d->pixmap = new QPixmap(pixmap);
+     }
+ 
+-    if (d->pixmap->depth() == 1 && !d->pixmap->mask())
+-        d->pixmap->setMask(*((QBitmap *)d->pixmap));
+-
+     d->updateLabel();
+ }
+ 
+diff --git a/qtbase/src/widgets/widgets/qtoolbararealayout.cpp b/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
+index 493c094cc1..d5f4b59017 100644
+--- a/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
++++ b/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
+@@ -1367,7 +1367,7 @@ bool QToolBarAreaLayout::restoreState(QDataStream &stream, const QList<QToolBar*
+                 item.widgetItem = new QWidgetItemV2(toolBar);
+                 toolBar->setOrientation(floating ? ((shown & 2) ? Qt::Vertical : Qt::Horizontal) : dock.o);
+                 toolBar->setVisible(shown & 1);
+-                toolBar->d_func()->setWindowState(floating, true, rect);
++                toolBar->d_func()->setWindowState(floating, false, rect);
+ 
+                 item.preferredSize = item.size;
+                 line.toolBarItems.append(item);
+diff --git a/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp b/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
+index 212c0a2e13..3c77b1ba0b 100644
+--- a/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
++++ b/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
+@@ -126,8 +126,7 @@ public:
+ 
+ void tst_QtConcurrentIterateKernel::instantiate()
+ {
+-    auto future = startThreadEngine(new PrintFor(0, 40)).startAsynchronously();
+-    future.waitForFinished();
++    startThreadEngine(new PrintFor(0, 40)).startBlocking();
+     QCOMPARE(iterations.loadRelaxed(), 40);
+ }
+ 
+@@ -166,10 +165,8 @@ void tst_QtConcurrentIterateKernel::stresstest()
+     const int times = 50;
+     for (int i = 0; i < times; ++i) {
+         counter.storeRelaxed(0);
+-        // ThreadEngine will delete f when it finishes
+-        auto f = new CountFor(0, iterations);
+-        auto future = f->startAsynchronously();
+-        future.waitForFinished();
++        CountFor f(0, iterations);
++        f.startBlocking();
+         QCOMPARE(counter.loadRelaxed(), iterations);
+     }
+ }
+@@ -177,11 +174,8 @@ void tst_QtConcurrentIterateKernel::stresstest()
+ void tst_QtConcurrentIterateKernel::noIterations()
+ {
+     const int times = 20000;
+-    for (int i = 0; i < times; ++i) {
+-        auto future = startThreadEngine(new IterateKernel<TestIterator, void>(0, 0))
+-                              .startAsynchronously();
+-        future.waitForFinished();
+-    }
++    for (int i = 0; i < times; ++i)
++        startThreadEngine(new IterateKernel<TestIterator, void>(0, 0)).startBlocking();
+ }
+ 
+ QMutex threadsMutex;
+@@ -236,10 +230,8 @@ void tst_QtConcurrentIterateKernel::throttling()
+ 
+     threads.clear();
+ 
+-    // ThreadEngine will delete f when it finishes
+-    auto f = new ThrottleFor(0, totalIterations);
+-    auto future = f->startAsynchronously();
+-    future.waitForFinished();
++    ThrottleFor f(0, totalIterations);
++    f.startBlocking();
+ 
+     QCOMPARE(iterations.loadRelaxed(), totalIterations);
+ 
+diff --git a/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp b/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
+index ac7be7acdd..81bc64c8d9 100644
+--- a/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
++++ b/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
+@@ -65,9 +65,16 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::runDirectly()
+ {
+-    PrintUser *engine = new PrintUser();
+-    QFuture<void> f = engine->startAsynchronously();
+-    f.waitForFinished();
++    {
++        PrintUser engine;
++        engine.startSingleThreaded();
++        engine.startBlocking();
++    }
++    {
++        PrintUser *engine = new PrintUser();
++        QFuture<void> f = engine->startAsynchronously();
++        f.waitForFinished();
++    }
+ }
+ 
+ class StringResultUser : public ThreadEngine<QString>
+@@ -99,10 +106,8 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::result()
+ {
+-    // ThreadEngine will delete 'engine' when it finishes
+-    auto engine = new StringResultUser();
+-    auto future = engine->startAsynchronously();
+-    QCOMPARE(future.result(), QString("Foo"));
++    StringResultUser engine;
++    QCOMPARE(*engine.startBlocking(), QString("Foo"));
+ }
+ 
+ class VoidResultUser : public ThreadEngine<void>
+@@ -128,9 +133,17 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::runThroughStarter()
+ {
+-    ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
+-    QFuture<QString> f = starter.startAsynchronously();
+-    QCOMPARE(f.result(), QString("Foo"));
++    {
++        ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
++        QFuture<QString>  f = starter.startAsynchronously();
++        QCOMPARE(f.result(), QString("Foo"));
++    }
++
++    {
++        ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
++        QString str = starter.startBlocking();
++        QCOMPARE(str, QString("Foo"));
++    }
+ }
+ 
+ class CancelUser : public ThreadEngine<void>
+@@ -213,6 +226,12 @@ void tst_QtConcurrentThreadEngine::throttle()
+         f.waitForFinished();
+         QCOMPARE(count.loadRelaxed(), 0);
+     }
++
++    for (int i = 0; i < repeats; ++i) {
++        ThrottleAlwaysUser t;
++        t.startBlocking();
++        QCOMPARE(count.loadRelaxed(), 0);
++    }
+ }
+ 
+ QSet<QThread *> threads;
+@@ -249,17 +268,35 @@ void tst_QtConcurrentThreadEngine::threadCount()
+ {
+     const int repeats = 10;
+     for (int i = 0; i < repeats; ++i) {
++        ThreadCountUser t;
++        t.startBlocking();
++        int count = threads.count();
++        int count_expected = QThreadPool::globalInstance()->maxThreadCount() + 1; // +1 for the main thread.
++        if (count != count_expected)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, count_expected);
++
+         (new ThreadCountUser())->startAsynchronously().waitForFinished();
+-        const auto count = threads.count();
+-        const auto maxThreadCount = QThreadPool::globalInstance()->maxThreadCount();
+-        QVERIFY(count <= maxThreadCount);
+-        QVERIFY(!threads.contains(QThread::currentThread()));
++        count = threads.count();
++        count_expected = QThreadPool::globalInstance()->maxThreadCount();
++        if (count != count_expected)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, count_expected);
+     }
+ 
+     // Set the finish flag immediately, this should give us one thread only.
+     for (int i = 0; i < repeats; ++i) {
++        ThreadCountUser t(true /*finishImmediately*/);
++        t.startBlocking();
++        int count = threads.count();
++        if (count != 1)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, 1);
++
+         (new ThreadCountUser(true /*finishImmediately*/))->startAsynchronously().waitForFinished();
+-        const auto count = threads.count();
++        count = threads.count();
++        if (count != 1)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
+         QCOMPARE(count, 1);
+         QVERIFY(!threads.contains(QThread::currentThread()));
+     }
+@@ -400,6 +437,7 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::exceptions()
+ {
++    // Asynchronous mode:
+     {
+         bool caught = false;
+         try  {
+@@ -412,6 +450,32 @@ void tst_QtConcurrentThreadEngine::exceptions()
+         QVERIFY2(caught, "did not get exception");
+     }
+ 
++    // Blocking mode:
++    // test throwing the exception from a worker thread.
++    {
++        bool caught = false;
++        try  {
++            QtConcurrentExceptionThrower e(QThread::currentThread());
++            e.startBlocking();
++        } catch (const QException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // test throwing the exception from the main thread (different code path)
++    {
++        bool caught = false;
++        try  {
++            QtConcurrentExceptionThrower e(0);
++            e.startBlocking();
++        } catch (const QException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // Asynchronous mode:
+     {
+         bool caught = false;
+         try  {
+@@ -423,6 +487,31 @@ void tst_QtConcurrentThreadEngine::exceptions()
+         }
+         QVERIFY2(caught, "did not get exception");
+     }
++
++    // Blocking mode:
++    // test throwing the exception from a worker thread.
++    {
++        bool caught = false;
++        try  {
++            UnrelatedExceptionThrower e(QThread::currentThread());
++            e.startBlocking();
++        } catch (const QUnhandledException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // test throwing the exception from the main thread (different code path)
++    {
++        bool caught = false;
++        try  {
++            UnrelatedExceptionThrower e(0);
++            e.startBlocking();
++        } catch (const QUnhandledException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
+ }
+ 
+ #endif
+diff --git a/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp b/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
+index 4968742110..f4c3fb711d 100644
+--- a/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
++++ b/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
+@@ -42,6 +42,7 @@ private slots:
+     void writeBlock_data();
+     void writeBlock();
+     void seek();
++    void invalidSeeks();
+     void seekTest_data();
+     void seekTest();
+     void read_rawdata();
+@@ -286,6 +287,29 @@ void tst_QBuffer::seek()
+     QCOMPARE(buffer.size(), pos);
+ }
+ 
++void tst_QBuffer::invalidSeeks()
++{
++    if constexpr (sizeof(qsizetype) == sizeof(qint64)) {
++        // sizeof(qsizetype) == sizeof(qint64), so +1 would overflow
++        QSKIP("This is a 32-bit-only test.");
++    } else {
++        QBuffer buffer;
++        buffer.open(QIODevice::WriteOnly);
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++        constexpr qint64 MaxQByteArrayCapacity = (std::numeric_limits<qsizetype>::max)();
++        // this should fail fast, not after trying to allocate nearly 2 GiB of data,
++        // potentially crashing in the process:
++        QVERIFY(!buffer.seek(2 * MaxQByteArrayCapacity - 1));
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++        // ditto:
++        QVERIFY(!buffer.seek(MaxQByteArrayCapacity + 1));
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++    }
++}
++
+ void tst_QBuffer::seekTest_data()
+ {
+     writeBlock_data();
+diff --git a/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp b/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
+index da5327594c..4a04e0f7c6 100644
+--- a/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
++++ b/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
+@@ -561,7 +561,8 @@ protected:
+     qint64 readData(char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf->size() - offset));
+-        memcpy(data, buf->constData() + offset, maxSize);
++        if (maxSize > 0)
++            memcpy(data, buf->constData() + offset, maxSize);
+         offset += maxSize;
+         return maxSize;
+     }
+@@ -604,13 +605,15 @@ protected:
+     qint64 readData(char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf.size() - pos()));
+-        memcpy(data, buf.constData() + pos(), maxSize);
++        if (maxSize > 0)
++            memcpy(data, buf.constData() + pos(), maxSize);
+         return maxSize;
+     }
+     qint64 writeData(const char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf.size() - pos()));
+-        memcpy(buf.data() + pos(), data, maxSize);
++        if (maxSize > 0)
++            memcpy(buf.data() + pos(), data, maxSize);
+         return maxSize;
+     }
+ 
+diff --git a/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+index db60bead64..f345a44414 100644
+--- a/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
++++ b/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+@@ -1,7 +1,8 @@
+ /****************************************************************************
+ **
+ ** Copyright (C) 2021 The Qt Company Ltd.
+-** Copyright (C) 2020 Intel Corporation.
++** Copyright (C) 2020 The Qt Company Ltd.
++** Copyright (C) 2022 Intel Corporation.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the test suite of the Qt Toolkit.
+@@ -150,6 +151,8 @@ private slots:
+     void startStopStartStopBuffers();
+     void processEventsInAReadyReadSlot_data();
+     void processEventsInAReadyReadSlot();
++    void startFromCurrentWorkingDir_data();
++    void startFromCurrentWorkingDir();
+ 
+     // keep these at the end, since they use lots of processes and sometimes
+     // caused obscure failures to occur in tests that followed them (esp. on the Mac)
+@@ -2731,5 +2734,94 @@ void tst_QProcess::finishProcessBeforeReadingDone_deprecated()
+ 
+ #endif
+ 
++enum class ChdirMode {
++    None = 0,
++    InParent,
++    InChild
++};
++Q_DECLARE_METATYPE(ChdirMode)
++
++void tst_QProcess::startFromCurrentWorkingDir_data()
++{
++    qRegisterMetaType<ChdirMode>();
++    QTest::addColumn<QString>("programPrefix");
++    QTest::addColumn<ChdirMode>("chdirMode");
++    QTest::addColumn<bool>("success");
++
++    constexpr bool IsWindows = true
++#ifdef Q_OS_UNIX
++            && false
++#endif
++            ;
++
++    // baseline: trying to execute the directory, this can't possibly succeed!
++    QTest::newRow("plain-same-cwd") << QString() << ChdirMode::None << false;
++
++    // cross-platform behavior: neither OS searches the setWorkingDirectory()
++    // dir without "./"
++    QTest::newRow("plain-child-chdir") << QString() << ChdirMode::InChild << false;
++
++    // cross-platform behavior: both OSes search the parent's CWD with "./"
++    QTest::newRow("prefixed-parent-chdir") << "./" << ChdirMode::InParent << true;
++
++    // opposite behaviors: Windows searches the parent's CWD and Unix searches
++    // the child's with "./"
++    QTest::newRow("prefixed-child-chdir") << "./" << ChdirMode::InChild << !IsWindows;
++
++    // Windows searches the parent's CWD without "./"
++    QTest::newRow("plain-parent-chdir") << QString() << ChdirMode::InParent << IsWindows;
++}
++
++void tst_QProcess::startFromCurrentWorkingDir()
++{
++    QFETCH(QString, programPrefix);
++    QFETCH(ChdirMode, chdirMode);
++    QFETCH(bool, success);
++
++    QProcess process;
++    qRegisterMetaType<QProcess::ProcessError>();
++    QSignalSpy errorSpy(&process, &QProcess::errorOccurred);
++    QVERIFY(errorSpy.isValid());
++
++    // both the dir name and the executable name
++    const QString target = QStringLiteral("testProcessNormal");
++    process.setProgram(programPrefix + target);
++
++#ifdef Q_OS_UNIX
++    // Reset PATH, to be sure it doesn't contain . or the empty path.
++    // We can't do this on Windows because DLLs are searched in PATH
++    // and Windows always searches "." anyway.
++    auto restoreEnv = qScopeGuard([old = qgetenv("PATH")] {
++        qputenv("PATH", old);
++    });
++    qputenv("PATH", "/");
++#endif
++
++    switch (chdirMode) {
++    case ChdirMode::InParent: {
++        auto restoreCwd = qScopeGuard([old = QDir::currentPath()] {
++            QDir::setCurrent(old);
++        });
++        QVERIFY(QDir::setCurrent(target));
++        process.start();
++        break;
++    }
++    case ChdirMode::InChild:
++        process.setWorkingDirectory(target);
++        Q_FALLTHROUGH();
++    case ChdirMode::None:
++        process.start();
++        break;
++    }
++
++    QCOMPARE(process.waitForStarted(), success);
++    QCOMPARE(errorSpy.count(), int(!success));
++    if (success) {
++        QVERIFY(process.waitForFinished());
++    } else {
++        QCOMPARE(process.error(), QProcess::FailedToStart);
++    }
++}
++
+ QTEST_MAIN(tst_QProcess)
+ #include "tst_qprocess.moc"
+diff --git a/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp b/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp
+index e1ea7a4552..90972caa57 100644
+--- a/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp
++++ b/qtbase/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"
+diff --git a/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+index 9bd66c0835..ed4a0bae5d 100644
+--- a/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
++++ b/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+@@ -158,6 +158,7 @@ private slots:
+     void nullReceiver();
+     void functorReferencesConnection();
+     void disconnectDisconnects();
++    void declarativeData();
+ };
+ 
+ struct QObjectCreatedOnShutdown
+@@ -7679,5 +7680,81 @@ void tst_QObject::disconnectDisconnects()
+ Q_STATIC_ASSERT(QtPrivate::HasQ_OBJECT_Macro<tst_QObject>::Value);
+ Q_STATIC_ASSERT(!QtPrivate::HasQ_OBJECT_Macro<SiblingDeleter>::Value);
+ 
++#ifdef QT_BUILD_INTERNAL
++/*
++    Since QObjectPrivate stores the declarativeData pointer in a union with the pointer
++    to the currently destroyed child, calls to the QtDeclarative handlers need to be
++    correctly guarded. QTBUG-105286
++*/
++namespace QtDeclarative {
++static QAbstractDeclarativeData *theData;
++
++static void destroyed(QAbstractDeclarativeData *data, QObject *)
++{
++    QCOMPARE(data, theData);
++}
++static void signalEmitted(QAbstractDeclarativeData *data, QObject *, int, void **)
++{
++    QCOMPARE(data, theData);
++}
++// we can't use QCOMPARE in the next two functions, as they don't return void
++static int receivers(QAbstractDeclarativeData *data, const QObject *, int)
++{
++    QTest::qCompare(data, theData, "data", "theData", __FILE__, __LINE__);
++    return 0;
++}
++static bool isSignalConnected(QAbstractDeclarativeData *data, const QObject *, int)
++{
++    QTest::qCompare(data, theData, "data", "theData", __FILE__, __LINE__);
++    return true;
++}
++
++class Object : public QObject
++{
++    Q_OBJECT
++public:
++    using QObject::QObject;
++    ~Object()
++    {
++        if (Object *p = static_cast<Object *>(parent()))
++            p->emitSignal();
++    }
++
++    void emitSignal()
++    {
++        emit theSignal();
++    }
++
++signals:
++    void theSignal();
++};
++
++}
++#endif
++
++void tst_QObject::declarativeData()
++{
++#ifdef QT_BUILD_INTERNAL
++    QScopedValueRollback destroyed(QAbstractDeclarativeData::destroyed,
++                                   QtDeclarative::destroyed);
++    QScopedValueRollback signalEmitted(QAbstractDeclarativeData::signalEmitted,
++                                       QtDeclarative::signalEmitted);
++    QScopedValueRollback receivers(QAbstractDeclarativeData::receivers,
++                                   QtDeclarative::receivers);
++    QScopedValueRollback isSignalConnected(QAbstractDeclarativeData::isSignalConnected,
++                                           QtDeclarative::isSignalConnected);
++
++    QtDeclarative::Object p;
++    QObjectPrivate *priv = QObjectPrivate::get(&p);
++    priv->declarativeData = QtDeclarative::theData = new QAbstractDeclarativeData;
++
++    connect(&p, &QtDeclarative::Object::theSignal, &p, []{
++    });
++
++    QtDeclarative::Object *child = new QtDeclarative::Object;
++    child->setParent(&p);
++#endif
++}
++
+ QTEST_MAIN(tst_QObject)
+ #include "tst_qobject.moc"
+diff --git a/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp b/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
+index 0ea422ecbc..1a3256534b 100644
+--- a/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
++++ b/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
+@@ -70,15 +70,15 @@ static inline QString testSuiteWarning()
+ 
+     QString result;
+     QTextStream str(&result);
+-    str << "\nCannot find the shared-mime-info test suite\nstarting from: "
++    str << "\nCannot find the shared-mime-info test suite\nin the parent of: "
+         << QDir::toNativeSeparators(QDir::currentPath()) << "\n"
+            "cd " << QDir::toNativeSeparators(QStringLiteral("tests/auto/corelib/mimetypes/qmimedatabase")) << "\n"
+-           "wget http://cgit.freedesktop.org/xdg/shared-mime-info/snapshot/Release-1-10.zip\n"
+-           "unzip Release-1-10.zip\n";
++           "wget https://gitlab.freedesktop.org/xdg/shared-mime-info/-/archive/2.1/shared-mime-info-2.1.zip\n"
++           "unzip shared-mime-info-2.1.zip\n";
+ #ifdef Q_OS_WIN
+-    str << "mkdir testfiles\nxcopy /s Release-1-10 s-m-i\n";
++    str << "mkdir testfiles\nxcopy /s shared-mime-info-2.1 s-m-i\n";
+ #else
+-    str << "ln -s Release-1-10 s-m-i\n";
++    str << "ln -s shared-mime-info-2.1 s-m-i\n";
+ #endif
+     return result;
+ }
+@@ -154,7 +154,7 @@ void tst_QMimeDatabase::initTestCase()
+     QVERIFY2(copyResourceFile(xmlFileName, xmlTargetFileName, &errorMessage), qPrintable(errorMessage));
+ #endif
+ 
+-    m_testSuite = QFINDTESTDATA("s-m-i/tests");
++    m_testSuite = QFINDTESTDATA("s-m-i/tests/mime-detection");
+     if (m_testSuite.isEmpty())
+         qWarning("%s", qPrintable(testSuiteWarning()));
+ 
+@@ -611,7 +611,7 @@ void tst_QMimeDatabase::allMimeTypes()
+     QVERIFY(!lst.isEmpty());
+ 
+     // Hardcoding this is the only way to check both providers find the same number of mimetypes.
+-    QCOMPARE(lst.count(), 779);
++    QCOMPARE(lst.count(), 811);
+ 
+     foreach (const QMimeType &mime, lst) {
+         const QString name = mime.name();
+@@ -631,10 +631,9 @@ void tst_QMimeDatabase::suffixes_data()
+ 
+     QTest::newRow("mimetype with a single pattern") << "application/pdf" << "*.pdf" << "pdf";
+     QTest::newRow("mimetype with multiple patterns") << "application/x-kpresenter" << "*.kpr;*.kpt" << "kpr";
+-    QTest::newRow("jpeg") << "image/jpeg" << "*.jpe;*.jpg;*.jpeg" << "jpeg";
+-    //if (KMimeType::sharedMimeInfoVersion() > KDE_MAKE_VERSION(0, 60, 0)) {
+-        QTest::newRow("mimetype with many patterns") << "application/vnd.wordperfect" << "*.wp;*.wp4;*.wp5;*.wp6;*.wpd;*.wpp" << "wp";
+-    //}
++    // The preferred suffix for image/jpeg is *.jpg, as per https://bugs.kde.org/show_bug.cgi?id=176737
++    QTest::newRow("jpeg") << "image/jpeg" << "*.jpe;*.jpg;*.jpeg" << "jpg";
++    QTest::newRow("mimetype with many patterns") << "application/vnd.wordperfect" << "*.wp;*.wp4;*.wp5;*.wp6;*.wpd;*.wpp" << "wp";
+     QTest::newRow("oasis text mimetype") << "application/vnd.oasis.opendocument.text" << "*.odt" << "odt";
+     QTest::newRow("oasis presentation mimetype") << "application/vnd.oasis.opendocument.presentation" << "*.odp" << "odp";
+     QTest::newRow("mimetype with multiple patterns") << "text/plain" << "*.asc;*.txt;*,v" << "txt";
+diff --git a/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp b/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
+index 3e58dd03cc..c8f82ef5d5 100644
+--- a/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
++++ b/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
+@@ -176,6 +176,8 @@ private Q_SLOTS:
+     void fromToVariantConversions_data();
+     void fromToVariantConversions();
+ 
++    void noLeakOnNameClash();
++
+ private:
+     QString testDataDir;
+ };
+@@ -3685,5 +3687,23 @@ void tst_QtJson::fromToVariantConversions()
+     }
+ }
+ 
++void tst_QtJson::noLeakOnNameClash()
++{
++    QJsonDocument doc = QJsonDocument::fromJson("{\"\":{\"\":0},\"\":0}");
++    QVERIFY(!doc.isNull());
++    const QJsonObject obj = doc.object();
++
++    // Removed the duplicate key.
++    QCOMPARE(obj.length(), 1);
++
++    // Retained the last of the duplicates.
++    const QJsonValue val = obj.begin().value();
++    QVERIFY(val.isDouble());
++    QCOMPARE(val.toDouble(), 0.0);
++
++    // It should not leak.
++    // In particular it should not forget to deref the container for the inner object.
++}
++
+ QTEST_MAIN(tst_QtJson)
+ #include "tst_qtjson.moc"
+diff --git a/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp b/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
+index a59b58d57f..241c3e84ac 100644
+--- a/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
++++ b/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
+@@ -63,6 +63,7 @@ private slots:
+     void isValidId_data();
+     void isValidId();
+     void malformed();
++    void serialize();
+     // Backend tests
+     void utcTest();
+     void icuTest();
+@@ -947,6 +948,33 @@ void tst_QTimeZone::malformed()
+         barf.offsetFromUtc(now);
+ }
+ 
++void tst_QTimeZone::serialize()
++{
++    int parts = 0;
++#ifndef QT_NO_DEBUG_STREAM
++    qDebug() << QTimeZone(); // to verify no crash
++    parts++;
++#endif
++#ifndef QT_NO_DATASTREAM
++    QByteArray blob;
++    {
++        QDataStream stream(&blob, QIODevice::WriteOnly);
++        stream << QTimeZone("Europe/Oslo") << QTimeZone(420) << QTimeZone() << qint64(-1);
++    }
++    QDataStream stream(&blob, QIODevice::ReadOnly);
++    QTimeZone invalid, offset, oslo;
++    qint64 minusone;
++    stream >> oslo >> offset >> invalid >> minusone;
++    QCOMPARE(oslo, QTimeZone("Europe/Oslo"));
++    QCOMPARE(offset, QTimeZone(420));
++    QVERIFY(!invalid.isValid());
++    QCOMPARE(minusone, qint64(-1));
++    parts++;
++#endif
++    if (!parts)
++        QSKIP("No serialization enabled");
++}
++
+ void tst_QTimeZone::utcTest()
+ {
+ #ifdef QT_BUILD_INTERNAL
+diff --git a/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp b/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
+index 05480c6dd2..70f4c75756 100644
+--- a/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
++++ b/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
+@@ -324,6 +324,13 @@ void tst_QDBusInterface::notValid()
+ 
+     QVERIFY(!interface.isValid());
+     QVERIFY(!QMetaObject::invokeMethod(&interface, "ListNames", Qt::DirectConnection));
++
++    // With a connection, but empty/null service and path specified
++    QDBusConnection con = QDBusConnection::sessionBus();
++    QVERIFY(con.isConnected());
++    QDBusInterface iface({}, {}, {}, con);
++    QVERIFY(!iface.isValid());
++    QVERIFY(!QMetaObject::invokeMethod(&interface, "ListNames", Qt::DirectConnection));
+ }
+ 
+ void tst_QDBusInterface::notValidDerived()
+diff --git a/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp b/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
+index 874468c954..04ceb4ab65 100644
+--- a/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
++++ b/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
+@@ -507,6 +507,10 @@ void tst_QKeySequence::toStringFromKeycode_data()
+     QTest::newRow("Ctrl+Alt+Num+Del") << QKeySequence(Qt::ControlModifier | Qt::AltModifier | Qt::KeypadModifier | Qt::Key_Delete) << "Ctrl+Alt+Num+Del";
+     QTest::newRow("Ctrl+Ins") << QKeySequence(Qt::ControlModifier | Qt::Key_Insert) << "Ctrl+Ins";
+     QTest::newRow("Ctrl+Num+Ins(1)") << QKeySequence(Qt::Key_Insert | Qt::KeypadModifier | Qt::ControlModifier) << "Ctrl+Num+Ins";
++    QTest::newRow("Ctrl") << QKeySequence(Qt::Key_Control) << "Control";
++    QTest::newRow("Alt") << QKeySequence(Qt::Key_Alt) << "Alt";
++    QTest::newRow("Shift") << QKeySequence(Qt::Key_Shift) << "Shift";
++    QTest::newRow("Meta") << QKeySequence(Qt::Key_Meta) << "Meta";
+ }
+ 
+ void tst_QKeySequence::toStringFromKeycode()
+diff --git a/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp b/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+index 15e0ecadaa..b4eca74283 100644
+--- a/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
++++ b/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+@@ -81,6 +81,8 @@ private slots:
+     void registerOpenTypePreferredNamesSystem();
+     void registerOpenTypePreferredNamesApplication();
+ 
++    void stretchRespected();
++
+ private:
+     QString m_ledFont;
+     QString m_testFont;
+@@ -355,6 +357,28 @@ static QString testString()
+     return QStringLiteral("foo bar");
+ }
+ 
++void tst_QFontDatabase::stretchRespected()
++{
++    int italicId = QFontDatabase::addApplicationFont(m_testFontItalic);
++    QVERIFY(italicId != -1);
++
++    QVERIFY(!QFontDatabase::applicationFontFamilies(italicId).isEmpty());
++
++    QString italicFontName = QFontDatabase::applicationFontFamilies(italicId).first();
++
++    QFont italicFont = QFontDatabase().font(italicFontName,
++                                            QString::fromLatin1("Italic"), 14);
++    QVERIFY(italicFont.italic());
++
++    QFont italicStretchedFont = italicFont;
++    italicStretchedFont.setStretch( 400 );
++
++    QVERIFY(QFontMetricsF(italicFont).horizontalAdvance(QStringLiteral("foobar")) <
++            QFontMetricsF(italicStretchedFont).horizontalAdvance(QStringLiteral("foobar")));
++
++    QFontDatabase::removeApplicationFont(italicId);
++}
++
+ void tst_QFontDatabase::condensedFontWidthNoFontMerging()
+ {
+     int regularFontId = QFontDatabase::addApplicationFont(m_testFont);
+diff --git a/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+index 3d4a094c43..b423e11a99 100644
+--- a/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
++++ b/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+@@ -281,6 +281,7 @@ private Q_SLOTS:
+     void ioGetFromFileSpecial();
+     void ioGetFromFile_data();
+     void ioGetFromFile();
++    void ioGetFromFileUrl();
+     void ioGetFromFtp_data();
+     void ioGetFromFtp();
+     void ioGetFromFtpWithReuse();
+@@ -3300,6 +3301,18 @@ void tst_QNetworkReply::ioGetFromFile()
+     QCOMPARE(reader.data, data);
+ }
+ 
++void tst_QNetworkReply::ioGetFromFileUrl()
++{
++    // This immediately fails on non-windows platforms:
++    QNetworkRequest request(QUrl("file://unc-server/some/path"));
++    QNetworkReplyPtr reply(manager.get(request));
++    QSignalSpy finishedSpy(reply.get(), &QNetworkReply::finished);
++    // QTBUG-105618: This would, on non-Windows platforms, never happen because the signal
++    // was emitted before the constructor finished, leaving no chance at all to connect to the
++    // signal
++    QVERIFY(finishedSpy.wait());
++}
++
+ void tst_QNetworkReply::ioGetFromFtp_data()
+ {
+     QTest::addColumn<QString>("fileName");
+diff --git a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
+index 069fa6b341..4cc4d9a5ea 100644
+--- a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
++++ b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
+@@ -1,75 +1,34 @@
+-Certificate:
+-    Data:
+-        Version: 3 (0x2)
+-        Serial Number: 0 (0x0)
+-        Signature Algorithm: sha1WithRSAEncryption
+-        Issuer: C=NO, ST=Oslo, L=Nydalen, O=Nokia Corporation and/or its subsidiary(-ies), OU=Development, CN=fluke.troll.no/emailAddress=ahanssen@trolltech.com
+-        Validity
+-            Not Before: Dec  4 01:10:32 2007 GMT
+-            Not After : Apr 21 01:10:32 2035 GMT
+-        Subject: C=NO, ST=Oslo, O=Nokia Corporation and/or its subsidiary(-ies), OU=Development, CN=fluke.troll.no
+-        Subject Public Key Info:
+-            Public Key Algorithm: rsaEncryption
+-            RSA Public Key: (1024 bit)
+-                Modulus (1024 bit):
+-                    00:a7:c8:a0:4a:c4:19:05:1b:66:ba:32:e2:d2:f1:
+-                    1c:6f:17:82:e4:39:2e:01:51:90:db:04:34:32:11:
+-                    21:c2:0d:6f:59:d8:53:90:54:3f:83:8f:a9:d3:b3:
+-                    d5:ee:1a:9b:80:ae:c3:25:c9:5e:a5:af:4b:60:05:
+-                    aa:a0:d1:91:01:1f:ca:04:83:e3:58:1c:99:32:45:
+-                    84:70:72:58:03:98:4a:63:8b:41:f5:08:49:d2:91:
+-                    02:60:6b:e4:64:fe:dd:a0:aa:74:08:e9:34:4c:91:
+-                    5f:12:3d:37:4d:54:2c:ad:7f:5b:98:60:36:02:8c:
+-                    3b:f6:45:f3:27:6a:9b:94:9d
+-                Exponent: 65537 (0x10001)
+-        X509v3 extensions:
+-            X509v3 Basic Constraints: 
+-                CA:FALSE
+-            Netscape Comment: 
+-                OpenSSL Generated Certificate
+-            X509v3 Subject Key Identifier: 
+-                21:85:04:3D:23:01:66:E5:F7:9F:1A:84:24:8A:AF:0A:79:F4:E5:AC
+-            X509v3 Authority Key Identifier: 
+-                DirName:/C=NO/ST=Oslo/L=Nydalen/O=Nokia Corporation and/or its subsidiary(-ies)/OU=Development/CN=fluke.troll.no/emailAddress=ahanssen@trolltech.com
+-                serial:8E:A8:B4:E8:91:B7:54:2E
+-
+-    Signature Algorithm: sha1WithRSAEncryption
+-        6d:57:5f:d1:05:43:f0:62:05:ec:2a:71:a5:dc:19:08:f2:c4:
+-        a6:bd:bb:25:d9:ca:89:01:0e:e4:cf:1f:c1:8c:c8:24:18:35:
+-        53:59:7b:c0:43:b4:32:e6:98:b2:a6:ef:15:05:0b:48:5f:e1:
+-        a0:0c:97:a9:a1:77:d8:35:18:30:bc:a9:8f:d3:b7:54:c7:f1:
+-        a9:9e:5d:e6:19:bf:f6:3c:5b:2b:d8:e4:3e:62:18:88:8b:d3:
+-        24:e1:40:9b:0c:e6:29:16:62:ab:ea:05:24:70:36:aa:55:93:
+-        ef:02:81:1b:23:10:a2:04:eb:56:95:75:fc:f8:94:b1:5d:42:
+-        c5:3f:36:44:85:5d:3a:2e:90:46:8a:a2:b9:6f:87:ae:0c:15:
+-        40:19:31:90:fc:3b:25:bb:ae:f1:66:13:0d:85:90:d9:49:34:
+-        8f:f2:5d:f9:7a:db:4d:5d:27:f6:76:9d:35:8c:06:a6:4c:a3:
+-        b1:b2:b6:6f:1d:d7:a3:00:fd:72:eb:9e:ea:44:a1:af:21:34:
+-        7d:c7:42:e2:49:91:19:8b:c0:ad:ba:82:80:a8:71:70:f4:35:
+-        31:91:63:84:20:95:e9:60:af:64:8b:cc:ff:3d:8a:76:74:3d:
+-        c8:55:6d:e4:8e:c3:2b:1c:e8:42:18:ae:9f:e6:6b:9c:34:06:
+-        ec:6a:f2:c3
+ -----BEGIN CERTIFICATE-----
+-MIIEEzCCAvugAwIBAgIBADANBgkqhkiG9w0BAQUFADCBnDELMAkGA1UEBhMCTk8x
+-DTALBgNVBAgTBE9zbG8xEDAOBgNVBAcTB055ZGFsZW4xFjAUBgNVBAoTDVRyb2xs
+-dGVjaCBBU0ExFDASBgNVBAsTC0RldmVsb3BtZW50MRcwFQYDVQQDEw5mbHVrZS50
+-cm9sbC5ubzElMCMGCSqGSIb3DQEJARYWYWhhbnNzZW5AdHJvbGx0ZWNoLmNvbTAe
+-Fw0wNzEyMDQwMTEwMzJaFw0zNTA0MjEwMTEwMzJaMGMxCzAJBgNVBAYTAk5PMQ0w
+-CwYDVQQIEwRPc2xvMRYwFAYDVQQKEw1Ucm9sbHRlY2ggQVNBMRQwEgYDVQQLEwtE
+-ZXZlbG9wbWVudDEXMBUGA1UEAxMOZmx1a2UudHJvbGwubm8wgZ8wDQYJKoZIhvcN
+-AQEBBQADgY0AMIGJAoGBAKfIoErEGQUbZroy4tLxHG8XguQ5LgFRkNsENDIRIcIN
+-b1nYU5BUP4OPqdOz1e4am4CuwyXJXqWvS2AFqqDRkQEfygSD41gcmTJFhHByWAOY
+-SmOLQfUISdKRAmBr5GT+3aCqdAjpNEyRXxI9N01ULK1/W5hgNgKMO/ZF8ydqm5Sd
+-AgMBAAGjggEaMIIBFjAJBgNVHRMEAjAAMCwGCWCGSAGG+EIBDQQfFh1PcGVuU1NM
+-IEdlbmVyYXRlZCBDZXJ0aWZpY2F0ZTAdBgNVHQ4EFgQUIYUEPSMBZuX3nxqEJIqv
+-Cnn05awwgbsGA1UdIwSBszCBsKGBoqSBnzCBnDELMAkGA1UEBhMCTk8xDTALBgNV
+-BAgTBE9zbG8xEDAOBgNVBAcTB055ZGFsZW4xFjAUBgNVBAoTDVRyb2xsdGVjaCBB
+-U0ExFDASBgNVBAsTC0RldmVsb3BtZW50MRcwFQYDVQQDEw5mbHVrZS50cm9sbC5u
+-bzElMCMGCSqGSIb3DQEJARYWYWhhbnNzZW5AdHJvbGx0ZWNoLmNvbYIJAI6otOiR
+-t1QuMA0GCSqGSIb3DQEBBQUAA4IBAQBtV1/RBUPwYgXsKnGl3BkI8sSmvbsl2cqJ
+-AQ7kzx/BjMgkGDVTWXvAQ7Qy5piypu8VBQtIX+GgDJepoXfYNRgwvKmP07dUx/Gp
+-nl3mGb/2PFsr2OQ+YhiIi9Mk4UCbDOYpFmKr6gUkcDaqVZPvAoEbIxCiBOtWlXX8
+-+JSxXULFPzZEhV06LpBGiqK5b4euDBVAGTGQ/Dslu67xZhMNhZDZSTSP8l35ettN
+-XSf2dp01jAamTKOxsrZvHdejAP1y657qRKGvITR9x0LiSZEZi8CtuoKAqHFw9DUx
+-kWOEIJXpYK9ki8z/PYp2dD3IVW3kjsMrHOhCGK6f5mucNAbsavLD
++MIIF6zCCA9OgAwIBAgIUfo9amJtJGWqWE6f+SkAO85zkGr4wDQYJKoZIhvcNAQEL
++BQAwgYMxCzAJBgNVBAYTAk5PMQ0wCwYDVQQIDARPc2xvMQ0wCwYDVQQHDARPc2xv
++MRcwFQYDVQQKDA5UaGUgUXQgQ29tcGFueTEMMAoGA1UECwwDUiZEMRIwEAYDVQQD
++DAlIMiBUZXN0ZXIxGzAZBgkqhkiG9w0BCQEWDG1pbmltaUBxdC5pbzAgFw0yMDEw
++MjYxMjAxMzFaGA8yMTIwMTAwMjEyMDEzMVowgYMxCzAJBgNVBAYTAk5PMQ0wCwYD
++VQQIDARPc2xvMQ0wCwYDVQQHDARPc2xvMRcwFQYDVQQKDA5UaGUgUXQgQ29tcGFu
++eTEMMAoGA1UECwwDUiZEMRIwEAYDVQQDDAlIMiBUZXN0ZXIxGzAZBgkqhkiG9w0B
++CQEWDG1pbmltaUBxdC5pbzCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIB
++AOiUp5+E4blouKH7q+rVNR8NoYX2XkBW+q+rpy1zu5ssRSzbqxAjDx9dkht7Qlnf
++VlDT00JvpOWdeuPon5915edQRsY4Unl6mKH29ra3OtUa1/yCJXsGVJTKCj7k4Bxb
++5mZzb/fTlZntMLdTIBMfUbw62FKir1WjKIcJ9fCoG8JaGeKVO4Rh5p0ezd4UUUId
++r1BXl5Nqdqy2vTMsEDnjOsD3egkv8I2SKN4O6n/C3wWYpMOWYZkGoZiKz7rJs/i/
++ez7bsV7JlwdzTlhpJzkcOSVFBP6JlEOxTNNxZ1wtKy7PtZGmsSSATq2e6+bw38Ae
++Op0XnzzqcGjtDDofBmT7OFzZWjS9VZS6+DOOe2QHWle1nCHcHyH4ku6IRlsr9xkR
++NAIlOfnvHHxqJUenoeaZ4oQDjCBKS1KXygJO/tL7BLTQVn/xK1EmPvKNnjzWk4tR
++PnibUhhs5635qpOU/YPqFBh1JjVruZbsWcDAhRcew0uxONXOa9E+4lttQ9ySYa1A
++LvWqJuAX7gu2BsBMLyqfm811YnA7CIFMyO+HlqmkLFfv5L/xIRAXR7l26YGO0VwX
++CGjMfz4NVPMMke4nB7qa9NkpXQBQKMms3Qzd5JW0Hy9Ruj5O8GPcFZmV0twjd1uJ
++PD/cAjkWLaXjdNsJ16QWc2nghQRS6HYqKRX6j+CXOxupAgMBAAGjUzBRMB0GA1Ud
++DgQWBBRSCOU58j9NJZkMamt623qyCrhN3TAfBgNVHSMEGDAWgBRSCOU58j9NJZkM
++amt623qyCrhN3TAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4ICAQCq
++q4jxsWeNDv5Nq14hJtF9HB+ZL64zcZtRjJP1YgNs0QppKICmjPOL2nIMGmI/jKrs
++0eGAL/9XXNVHPxm1OPOncvimMMmU6emZfpMdEtTfKP43+Pg9HgKRjLoQp406vGeQ
++8ki/mbBhrItVPgEm3tu2AFA02XTYi+YxCI9kRZLGkM3FbgtOuTLPl0Z9y+kiPc9F
++uCSC03anBEqv+vDSI8+wODymQ/IJ3Jyz1lxIRDfp4qAekmy0jU2c91VOHHEmOmqq
++kqygGFRdwbe99m9yP63r6q0b5K3X2UnJ6bns0hmTwThYwpVPXLU8jdaTddbMukN2
++/Ef96Tsw8nWOEOPMySHOTIPgwyZRp26b0kA9EmhLwOP401SxXVQCmSRmtwNagmtg
++jJKmZoYBN+//D45ibK8z6Q0oOm9P+Whf/uUXehcRxBxyV3xz7k0wKGQbHj/ddwcy
++IUoIN4lrAlib+lK170kTKN352PDmrpo2gmIzPEsfurKAIMSelDl6H+kih16BtZ8y
++Nz6fh9Soqrg3OSAware8pxV7k51crBMoPLN78KoRV8MFCK4K7Fddq4rRISq6hiXq
++r1nsjoEPuKM9huprmZVZe9t5YcDa2I+wb3IiE3uwpZbAdaLDyQ5n6F/qpsiIkZXn
++gtcF7oqpG5oYrwCcZ53y/ezUgUg7PlSz2XwAGvQtgg==
+ -----END CERTIFICATE-----
+diff --git a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
+index 9d1664d609..337ce541a6 100644
+--- a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
++++ b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
+@@ -1,15 +1,52 @@
+------BEGIN RSA PRIVATE KEY-----
+-MIICXAIBAAKBgQCnyKBKxBkFG2a6MuLS8RxvF4LkOS4BUZDbBDQyESHCDW9Z2FOQ
+-VD+Dj6nTs9XuGpuArsMlyV6lr0tgBaqg0ZEBH8oEg+NYHJkyRYRwclgDmEpji0H1
+-CEnSkQJga+Rk/t2gqnQI6TRMkV8SPTdNVCytf1uYYDYCjDv2RfMnapuUnQIDAQAB
+-AoGANFzLkanTeSGNFM0uttBipFT9F4a00dqHz6JnO7zXAT26I5r8sU1pqQBb6uLz
+-/+Qz5Zwk8RUAQcsMRgJetuPQUb0JZjF6Duv24hNazqXBCu7AZzUenjafwmKC/8ri
+-KpX3fTwqzfzi//FKGgbXQ80yykSSliDL3kn/drATxsLCgQECQQDXhEFWLJ0vVZ1s
+-1Ekf+3NITE+DR16X+LQ4W6vyEHAjTbaNWtcTKdAWLA2l6N4WAAPYSi6awm+zMxx4
+-VomVTsjdAkEAx0z+e7natLeFcrrq8pbU+wa6SAP1VfhQWKitxL1e7u/QO90NCpxE
+-oQYKzMkmmpOOFjQwEMAy1dvFMbm4LHlewQJAC/ksDBaUcQHHqjktCtrUb8rVjAyW
+-A8lscckeB2fEYyG5J6dJVaY4ClNOOs5yMDS2Afk1F6H/xKvtQ/5CzInA/QJATDub
+-K+BPU8jO9q+gpuIi3VIZdupssVGmCgObVCHLakG4uO04y9IyPhV9lA9tALtoIf4c
+-VIvv5fWGXBrZ48kZAQJBAJmVCdzQxd9LZI5vxijUCj5EI4e+x5DRqVUvyP8KCZrC
+-AiNyoDP85T+hBZaSXK3aYGpVwelyj3bvo1GrTNwNWLw=
+------END RSA PRIVATE KEY-----
++-----BEGIN PRIVATE KEY-----
++MIIJQgIBADANBgkqhkiG9w0BAQEFAASCCSwwggkoAgEAAoICAQDolKefhOG5aLih
+++6vq1TUfDaGF9l5AVvqvq6ctc7ubLEUs26sQIw8fXZIbe0JZ31ZQ09NCb6TlnXrj
++6J+fdeXnUEbGOFJ5epih9va2tzrVGtf8giV7BlSUygo+5OAcW+Zmc2/305WZ7TC3
++UyATH1G8OthSoq9VoyiHCfXwqBvCWhnilTuEYeadHs3eFFFCHa9QV5eTanastr0z
++LBA54zrA93oJL/CNkijeDup/wt8FmKTDlmGZBqGYis+6ybP4v3s+27FeyZcHc05Y
++aSc5HDklRQT+iZRDsUzTcWdcLSsuz7WRprEkgE6tnuvm8N/AHjqdF5886nBo7Qw6
++HwZk+zhc2Vo0vVWUuvgzjntkB1pXtZwh3B8h+JLuiEZbK/cZETQCJTn57xx8aiVH
++p6HmmeKEA4wgSktSl8oCTv7S+wS00FZ/8StRJj7yjZ481pOLUT54m1IYbOet+aqT
++lP2D6hQYdSY1a7mW7FnAwIUXHsNLsTjVzmvRPuJbbUPckmGtQC71qibgF+4LtgbA
++TC8qn5vNdWJwOwiBTMjvh5appCxX7+S/8SEQF0e5dumBjtFcFwhozH8+DVTzDJHu
++Jwe6mvTZKV0AUCjJrN0M3eSVtB8vUbo+TvBj3BWZldLcI3dbiTw/3AI5Fi2l43Tb
++CdekFnNp4IUEUuh2KikV+o/glzsbqQIDAQABAoICAFw1q6tr5I48vY7DF+rXsuLn
++5ZUWE1IQ6fzB4lr72nJv/9EEGnMgYzt9PpMUsD6vdCpBgS2C0+6RHArFzJtNA+RM
++iHLIG7K7702veyr/xBx/MwiSlMeMv/XpkFxVI6E6skMGG2s3AMXxKvJTy5CpRx+I
++eQFyLG+Ya1X2lgJes/q+/CpAHkOjCOpcLySQC5NZ74q734V7nSdmn+Zs3tYEh+O/
++eiuwTP/j5b38Te5vVTqDxTciJPmljmXLCwa0N100lWlbcpvw8qbqiTI2Jm3XCbUE
++AzHjW9vmrF3cRS1fXxKFGShw3SRqlkbxjfeWoi8qDPUBS4m8LOr8qG9Wo5Nfon0z
++zLP4bci3zHDvVcaaZrrsUBs/yZbg+Dgka1DmX7ekmeccr2yTdKDFgPupYUyxVbTl
++a9ZLJysjFD7rgBv1ZclHonLp6Vbm+ZoTqvteo4ikAy6L9RtBWJ23XEK34PkP/+c5
++2vWZaOrnjSeBHbFce8cdJSxqWpP+eSCI5I9XbDrYFIsQ/gqKgtzDKy2ihJ2Y8STL
++yO4hyFPFjxc+Gg4/P2PpmT5CY2ty44M0BWs+JGW96CJPrrplf2lmQUQJj5LZY66X
++Z/4C9L7ZYtKZ+bs5SvU46yWugAvQZX22Xm9xLXWyVXRdx3bj+3M3fDnF9di/zdbh
++CgLx7oWPNrXc7FCajnn9AoIBAQD5FMYwRpw9NWT9WDxQwx+cSI4Icbd88ByTW63S
++LzeRwZA0J9/SfwO+aBRupzc9GkGXCiZcGMw3AGsCtig8yFlw8E5KnzN7KlftDMnM
++9NUxxzlR8VwKyLnZfG7sDTl057ZlUujnqhmt/F8F7dIy7FVO1dE/8nngA+FYTCOG
++UZdGjwyBDlDM0JJdUWGY3xslutcpCDN5mzSTKjy9drMvImAshRawxRF6WBpn7vr2
++nC6vciqfx1Mzx1vyk0Jm0ilaydDdLMADjt/iL4Nkr0BEs4k+UzQiKDwp8gu7abQ1
++eBfxd9Iar4htQa2I1Ewl6P01G/q+ZYwgHhJ9RVn4AxQXefILAoIBAQDvCouORdQX
++C8wsyp7MwXlF/3NQeNN5/+B2mhbxrBOf7PmMCXLnkRWcjwJtzypWFqJ0sqai/2+0
++bqbMcjX5maT8stT2shl3zXe/Ejt2e3TBYpc1tyuses8Kb5BMU8hu6tTd3G2CMXpD
++dT6DVemJZCTtwj9aBNIxSizvlgMolJnCpzhPnlfHSI6E+g3m/LTTo3HwbjMSw/Uq
++irgjOpI2wSBB6LZPSgjvfcYPRyWUk16L4A5uSX0cADnovDFLa5/h0wJvN/OoCSQg
++rLCXG5E18EyL5Wc58BCY1ZvxmjG3lQtgPxYu2Jwc36R/y/JKlxW5suER5ZNpbbD4
++uOyTt2VxMQ2bAoIBAQC5+MzRFqdo/AjfL5Y5JrbfVTzXCTDa09xCGd16ZU60QTWN
+++4ed/r+o1sUKqUcRFB2MzEM/2DQBjQpZB/CbEWvWa1XJWXxypXbowveZU+QqOnmN
++uQvj8WLyA3o+PNF9e9QvauwCrHpn8VpxbtPWuaYoKnUFreFZZQxHhPGxRBIS2JOZ
++eDrT8ZaWnkCkh1AZp5smQ71LOprSlmKrg4jd1GjCVMxQR5N5KXbtyv0OTCZ/UFqK
++2aRBsMPyJgkaBChkZPLRcKwc+/wlQRx1fHQb14DNTApMxoXFO7eOwqmOkpAt9iyl
++SBIwoS0UUI5ab88+bBmXNvKcuFdNuQ4nowTJUn9pAoIBADMNkILBXSvS5DeIyuO2
++Sp1tkoZUV+5NfPY3sMDK3KIibaW/+t+EOBZo4L7tKQCb8vRzl21mmsfxfgRaPDbj
++3r3tv9g0b4YLxxBy52pFscj/soXRai17SS7UZwA2QK+XzgDYbDcLNC6mIsTQG4Gx
++dsWk3/zs3KuUSQaehmwrWK+fIUK38c1pLK8v7LoxrLkqxlHwZ04RthHw8KTthH7X
++Pnl1J0LF8CSeOyfWLSuPUfkT0GEzptnNHpEbaHfQM6R6eaGhVJPF6AZme4y6YYgg
++m2ihhSt1n0XVEWpHYWjxFy3mK2mz75unFC4LM+NEY2p2zuUQoCw7NjnY3QYrfCnx
++rRMCggEAXeXsMSLFjjyuoL7iKbAxo52HD/P0fBoy58LyRcwfNVr0lvYan4pYEx+o
++KijIh9K16PqXZXKMA9v003B+ulmF8bJ7SddCZ5NGvnFhUTDe4DdTKgp2RuwQ3Bsc
++3skPIDbhVETyOLCtys34USHrq8U/0DlGY3eLRfxw9GnbKxSBGa/KEu/qQLPNUo50
++7xHZDg7GKeC3kqNJeqKM9rkp0VzIGkEnaD9127LeNDmERDfftxJzFoC/THvUBLfU
++6Sus2ZYwRE8VFvKC30Q45t/c54X3IuhYvAuiCuTmyfE4ruyzyOwKzhUkeeLq1APX
++g0veFbyfzlJ0q8qzD/iffqqIa2ZSmQ==
++-----END PRIVATE KEY-----
+diff --git a/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp b/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
+index 7ba3715e13..752aa122f6 100644
+--- a/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
++++ b/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
+@@ -179,6 +179,7 @@ void tst_QAccessibilityLinux::initTestCase()
+     QVERIFY(!address.isEmpty());
+ 
+     m_window = new AccessibleTestWindow();
++    m_window->setObjectName("mainWindow"_L1);
+     m_window->show();
+ 
+     QVERIFY(QTest::qWaitForWindowExposed(m_window));
+@@ -236,8 +237,11 @@ bool hasState(QDBusInterface *interface, AtspiStateType state)
+ void tst_QAccessibilityLinux::testLabel()
+ {
+     QLabel *l = new QLabel(m_window);
++    l->setObjectName("theObjectName"_L1);
+     l->setText("Hello A11y");
+     m_window->addWidget(l);
++    auto a11yEmpty = new QLabel(m_window);
++    m_window->addWidget(l);
+ 
+     // Application
+     QCOMPARE(getParent(mainWindow), QLatin1String(ATSPI_DBUS_PATH_ROOT));
+@@ -249,6 +253,8 @@ void tst_QAccessibilityLinux::testLabel()
+     QCOMPARE(getChildren(labelInterface).count(), 0);
+     QCOMPARE(labelInterface->call(QDBus::Block, "GetRoleName").arguments().first().toString(), QLatin1String("label"));
+     QCOMPARE(labelInterface->call(QDBus::Block, "GetRole").arguments().first().toUInt(), 29u);
++    QCOMPARE(labelInterface->call(QDBus::Block, "GetAccessibleId").arguments().first().toString(),
++             QLatin1String("mainWindow.theObjectName"));
+     QCOMPARE(getParent(labelInterface), mainWindow->path());
+     QVERIFY(!hasState(labelInterface, ATSPI_STATE_EDITABLE));
+     QVERIFY(hasState(labelInterface, ATSPI_STATE_READ_ONLY));
+@@ -256,7 +262,12 @@ void tst_QAccessibilityLinux::testLabel()
+     l->setText("New text");
+     QCOMPARE(labelInterface->property("Name").toString(), l->text());
+ 
++    auto *a11yEmptyInterface = getInterface(children.at(1), "org.a11y.atspi.Accessible");
++    QCOMPARE(a11yEmptyInterface->call(QDBus::Block, "GetAccessibleId").arguments().first().toString(),
++             QLatin1String("mainWindow.QLabel"));
++
+     m_window->clearChildren();
++    delete a11yEmptyInterface;
+     delete labelInterface;
+ }
+ 
+diff --git a/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+index 76df61c892..6d6d65b791 100644
+--- a/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
++++ b/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2022 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the test suite of the Qt Toolkit.
+@@ -68,6 +68,8 @@ private slots:
+     void query_exec();
+     void execErrorRecovery_data() { generic_data(); }
+     void execErrorRecovery();
++    void prematureExec_data() { generic_data(); }
++    void prematureExec();
+     void first_data() { generic_data(); }
+     void first();
+     void next_data() { generic_data(); }
+@@ -2770,6 +2772,35 @@ void tst_QSqlQuery::execErrorRecovery()
+     QVERIFY_SQL( q, exec() );
+ }
+ 
++void tst_QSqlQuery::prematureExec()
++{
++    QFETCH(QString, dbName);
++    // We only want the engine name, for addDatabase():
++    int cut = dbName.indexOf(QChar('@'));
++    if (cut < 0)
++        QSKIP("Failed to parse database type out of name");
++    dbName.truncate(cut);
++    cut = dbName.indexOf(QChar('_'));
++    if (cut >= 0)
++        dbName = dbName.mid(cut + 1);
++
++    auto db = QSqlDatabase::addDatabase(dbName);
++    QSqlQuery q(db);
++
++    QTest::ignoreMessage(QtWarningMsg,
++                         "QSqlDatabasePrivate::removeDatabase: connection "
++                         "'qt_sql_default_connection' is still in use, all "
++                         "queries will cease to work.");
++    QTest::ignoreMessage(QtWarningMsg,
++                         "QSqlDatabasePrivate::addDatabase: duplicate connection name "
++                         "'qt_sql_default_connection', old connection removed.");
++    auto otherDb = QSqlDatabase::addDatabase(dbName);
++
++    QTest::ignoreMessage(QtWarningMsg, "QSqlQuery::exec: called before driver has been set up");
++    // QTBUG-100037: shouldn't crash !
++    QVERIFY(!q.exec("select stuff from TheVoid"));
++}
++
+ void tst_QSqlQuery::lastInsertId()
+ {
+     QFETCH( QString, dbName );
+diff --git a/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp b/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
+index 4aa3f8d60b..d2050a61aa 100644
+--- a/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
++++ b/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
+@@ -115,6 +115,10 @@ void tst_QAbstractItemModelTester::standardItemModelZeroColumns()
+     // QTBUG-92886
+     model.insertRows(0, 5);
+     model.removeRows(1, 2);
++
++    const QModelIndex parentIndex = model.index(0, 0);
++    model.insertRows(0, 5, parentIndex);
++    model.removeRows(1, 2, parentIndex);
+ }
+ 
+ void tst_QAbstractItemModelTester::testInsertThroughProxy()
+diff --git a/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json b/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
+index 12a4a22a19..ce518e78fb 100644
+--- a/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
++++ b/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
+@@ -668,50 +668,6 @@
+         "inputFile": "task192552.h",
+         "outputRevision": 67
+     },
+-    {
+-        "classes": [
+-            {
+-                "className": "InlineSlotsWithThrowDeclaration",
+-                "object": true,
+-                "qualifiedClassName": "InlineSlotsWithThrowDeclaration",
+-                "slots": [
+-                    {
+-                        "access": "public",
+-                        "name": "a",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "b",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "c",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "d",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "e",
+-                        "returnType": "void"
+-                    }
+-                ],
+-                "superClasses": [
+-                    {
+-                        "access": "public",
+-                        "name": "QObject"
+-                    }
+-                ]
+-            }
+-        ],
+-        "inputFile": "task189996.h",
+-        "outputRevision": 67
+-    },
+     {
+         "classes": [
+             {
+diff --git a/qtbase/tests/auto/tools/moc/moc.pro b/qtbase/tests/auto/tools/moc/moc.pro
+index c324b3a8cd..4aceb78dc0 100644
+--- a/qtbase/tests/auto/tools/moc/moc.pro
++++ b/qtbase/tests/auto/tools/moc/moc.pro
+@@ -15,7 +15,7 @@ cross_compile: DEFINES += MOC_CROSS_COMPILED
+ HEADERS += using-namespaces.h no-keywords.h task87883.h c-comments.h backslash-newlines.h oldstyle-casts.h \
+            slots-with-void-template.h qinvokable.h namespaced-flags.h trigraphs.h \
+            escapes-in-string-literals.h cstyle-enums.h qprivateslots.h gadgetwithnoenums.h \
+-           dir-in-include-path.h single_function_keyword.h task192552.h task189996.h \
++           dir-in-include-path.h single_function_keyword.h task192552.h \
+            task234909.h task240368.h pure-virtual-signals.h cxx11-enums.h \
+            cxx11-final-classes.h \
+            cxx11-explicit-override-control.h \
+diff --git a/qtbase/tests/auto/tools/moc/task189996.h b/qtbase/tests/auto/tools/moc/task189996.h
+deleted file mode 100644
+index f94a051b3a..0000000000
+--- a/qtbase/tests/auto/tools/moc/task189996.h
++++ /dev/null
+@@ -1,47 +0,0 @@
+-/****************************************************************************
+-**
+-** Copyright (C) 2016 The Qt Company Ltd.
+-** Contact: https://www.qt.io/licensing/
+-**
+-** This file is part of the test suite of the Qt Toolkit.
+-**
+-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+-** 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 General Public License Usage
+-** Alternatively, this file may be used under the terms of the GNU
+-** General Public License version 3 as published by the Free Software
+-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+-** 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-3.0.html.
+-**
+-** $QT_END_LICENSE$
+-**
+-****************************************************************************/
+-// inline functions can have throw declarations
+-
+-#ifndef TASK189996_H
+-#define TASK189996_H
+-
+-#include <QObject>
+-
+-class InlineSlotsWithThrowDeclaration : public QObject
+-{
+-    Q_OBJECT
+-
+-public slots:
+-    void a() throw() { }
+-    void b() const throw() { }
+-    void c() throw();
+-    void d() throw(int) { }
+-    void e() const throw(int,double) { }
+-};
+-
+-#endif
+diff --git a/qtbase/tests/auto/tools/moc/tst_moc.cpp b/qtbase/tests/auto/tools/moc/tst_moc.cpp
+index c716aead21..15dd9e41e5 100644
+--- a/qtbase/tests/auto/tools/moc/tst_moc.cpp
++++ b/qtbase/tests/auto/tools/moc/tst_moc.cpp
+@@ -631,7 +631,6 @@ public:
+ private slots:
+     void initTestCase();
+ 
+-    void slotWithException() throw(MyStruct);
+     void dontStripNamespaces();
+     void oldStyleCasts();
+     void warnOnExtraSignalSlotQualifiaction();
+@@ -673,7 +672,6 @@ private slots:
+     void templateGtGt();
+     void qprivateslots();
+     void qprivateproperties();
+-    void inlineSlotsWithThrowDeclaration();
+     void warnOnPropertyWithoutREAD();
+     void constructors();
+     void typenameWithUnsigned();
+@@ -784,12 +782,6 @@ void tst_Moc::initTestCase()
+ #endif
+ }
+ 
+-void tst_Moc::slotWithException() throw(MyStruct)
+-{
+-    // be happy
+-    QVERIFY(true);
+-}
+-
+ void tst_Moc::dontStripNamespaces()
+ {
+     Sender sender;
+@@ -824,7 +816,7 @@ void tst_Moc::oldStyleCasts()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-Wold-style-cast" << "-I" << "."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -894,7 +886,7 @@ void tst_Moc::inputFileNameWithDotsButNoExtension()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-I" << ".."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -1174,7 +1166,7 @@ void tst_Moc::ignoreOptionClashes()
+     QStringList gccArgs;
+     gccArgs << "-c" << "-x" << "c++" << "-I" << ".."
+          << "-I" << qtIncludePath << "-I" << includeDir << "-o" << "/dev/null"
+-         << "-fPIC" << "-std=c++11" <<  "-";
++         << "-fPIC" << "-std=c++1z" <<  "-";
+     proc.start("gcc", gccArgs);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -1593,21 +1585,6 @@ void tst_Moc::qprivateproperties()
+ 
+ }
+ 
+-#include "task189996.h"
+-
+-void InlineSlotsWithThrowDeclaration::c() throw() {}
+-
+-void tst_Moc::inlineSlotsWithThrowDeclaration()
+-{
+-    InlineSlotsWithThrowDeclaration tst;
+-    const QMetaObject *mobj = tst.metaObject();
+-    QVERIFY(mobj->indexOfSlot("a()") != -1);
+-    QVERIFY(mobj->indexOfSlot("b()") != -1);
+-    QVERIFY(mobj->indexOfSlot("c()") != -1);
+-    QVERIFY(mobj->indexOfSlot("d()") != -1);
+-    QVERIFY(mobj->indexOfSlot("e()") != -1);
+-}
+-
+ void tst_Moc::warnOnPropertyWithoutREAD()
+ {
+ #ifdef MOC_CROSS_COMPILED
+@@ -1869,7 +1846,7 @@ void tst_Moc::notifyError()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-I" << "."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+diff --git a/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+index c355ee9665..88c09de8e0 100644
+--- a/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
++++ b/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+@@ -251,6 +251,7 @@ private slots:
+     void testResetCachedSizeHint();
+     void statusTips();
+     void testRemovingColumnsViaLayoutChanged();
++    void testModelMovingColumns();
+ 
+ protected:
+     void setupTestData(bool use_reset_model = false);
+@@ -360,6 +361,12 @@ public:
+         endRemoveColumns();
+     }
+ 
++    void moveColumn(int from, int to)
++    {
++        beginMoveColumns(QModelIndex(), from, from, QModelIndex(), to);
++        endMoveColumns();
++    }
++
+     void cleanup()
+     {
+         emit layoutAboutToBeChanged();
+@@ -3627,5 +3634,18 @@ void tst_QHeaderView::testRemovingColumnsViaLayoutChanged()
+     // The main point of this test is that the section-size restoring code didn't go out of bounds.
+ }
+ 
++void tst_QHeaderView::testModelMovingColumns()
++{
++    QtTestModel model(10, 10);
++    QHeaderView hv(Qt::Horizontal);
++    hv.setModel(&model);
++    hv.resizeSections(QHeaderView::ResizeToContents);
++    hv.show();
++
++    QPersistentModelIndex index3 = model.index(0, 3);
++    model.moveColumn(3, 1);
++    QCOMPARE(index3.column(), 1);
++}
++
+ QTEST_MAIN(tst_QHeaderView)
+ #include "tst_qheaderview.moc"
+diff --git a/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+index 761357b252..06bb706074 100644
+--- a/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
++++ b/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+@@ -397,6 +397,7 @@ private slots:
+     void checkHeaderMinSize();
+ 
+     void resizeToContents();
++    void resizeToContentsSpans();
+ 
+     void tabFocus();
+     void bigModel();
+@@ -3721,6 +3722,70 @@ void tst_QTableView::resizeToContents()
+ 
+ }
+ 
++
++class SpanModel : public QAbstractTableModel
++{
++public:
++    SpanModel(bool sectionsMoved)
++        : _sectionsMoved(sectionsMoved)
++    {}
++    int columnCount(const QModelIndex & = {}) const override { return 2; }
++    int rowCount(const QModelIndex & = {}) const override { return 1; }
++    QVariant data(const QModelIndex &idx, int role = Qt::DisplayRole) const override
++    {
++        if (role != Qt::DisplayRole)
++            return QVariant();
++        const int col = _sectionsMoved ? 1 - idx.column() : idx.column();
++        if (col == 0)
++            return "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.";
++        return QVariant();
++    }
++private:
++    bool _sectionsMoved;
++};
++
++
++void tst_QTableView::resizeToContentsSpans()
++{
++    SpanModel model1(false);
++    SpanModel model2(true);
++    QTableView view1, view2, view3;
++    view1.setModel(&model1);
++    view2.setModel(&model2);
++    view2.horizontalHeader()->moveSection(0, 1);
++    view3.setModel(&model1);
++
++    view1.setSpan(0, 0, 1, 2);
++    view2.setSpan(0, 1, 1, 2);
++    view1.show();
++    view2.show();
++    view3.show();
++    QVERIFY(QTest::qWaitForWindowExposed(&view1));
++    QVERIFY(QTest::qWaitForWindowExposed(&view2));
++    QVERIFY(QTest::qWaitForWindowExposed(&view3));
++    view1.setColumnWidth(0, 100);
++    view1.setColumnWidth(1, 100);
++    view2.setColumnWidth(0, 100);
++    view2.setColumnWidth(1, 100);
++    view3.setColumnWidth(0, 200);
++
++    view1.resizeRowToContents(0);
++    view2.resizeRowToContents(0);
++    view3.resizeRowToContents(0);
++    QCOMPARE(view1.rowHeight(0), view3.rowHeight(0));
++    QCOMPARE(view2.rowHeight(0), view3.rowHeight(0));
++
++    view3.resizeColumnToContents(0);
++    view3.resizeRowToContents(0);
++    // height should be only 1 text line for easy testing
++    view1.setRowHeight(0, view3.verticalHeader()->sectionSize(0));
++    view2.setRowHeight(0, view3.verticalHeader()->sectionSize(0));
++    view1.resizeColumnToContents(0);
++    view2.resizeColumnToContents(1);
++    QCOMPARE(view1.columnWidth(0), view3.columnWidth(0) - view1.columnWidth(1));
++    QCOMPARE(view2.columnWidth(0), view3.columnWidth(0) - view2.columnWidth(1));
++}
++
+ QT_BEGIN_NAMESPACE
+ extern bool Q_WIDGETS_EXPORT qt_tab_all_widgets(); // qapplication.cpp
+ QT_END_NAMESPACE
+diff --git a/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+index a3b8ef78d8..4955cebd5d 100644
+--- a/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
++++ b/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+@@ -1498,7 +1498,7 @@ void tst_QApplication::desktopSettingsAware()
+     environment += QLatin1String("QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM=1");
+     testProcess.setEnvironment(environment);
+ #endif
+-    testProcess.start("desktopsettingsaware_helper");
++    testProcess.start("./desktopsettingsaware_helper");
+     QVERIFY2(testProcess.waitForStarted(),
+              qPrintable(QString::fromLatin1("Cannot start 'desktopsettingsaware_helper': %1").arg(testProcess.errorString())));
+     QVERIFY(testProcess.waitForFinished(10000));
+@@ -2452,7 +2452,7 @@ void tst_QApplication::qtbug_12673()
+ #if QT_CONFIG(process)
+     QProcess testProcess;
+     QStringList arguments;
+-    testProcess.start("modal_helper", arguments);
++    testProcess.start("./modal_helper", arguments);
+     QVERIFY2(testProcess.waitForStarted(),
+              qPrintable(QString::fromLatin1("Cannot start 'modal_helper': %1").arg(testProcess.errorString())));
+     QVERIFY(testProcess.waitForFinished(20000));
+diff --git a/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp b/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
+index eb108a40de..dca5528c1b 100644
+--- a/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
+@@ -41,6 +41,7 @@
+ 
+ #include <private/qguiapplication_p.h>
+ #include <qpa/qplatformintegration.h>
++#include <qpa/qplatformtheme.h>
+ 
+ class tst_QAbstractButton : public QObject
+ {
+@@ -76,6 +77,8 @@ private slots:
+     void keyNavigation();
+ #endif
+ 
++    void buttonPressKeys();
++
+ protected slots:
+     void onClicked();
+     void onToggled( bool on );
+@@ -269,7 +272,13 @@ void tst_QAbstractButton::setAutoRepeat()
+         QCOMPARE(press_count, click_count);
+         QVERIFY(click_count > 1);
+         break;
+-    case 4:
++    case 4: {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(Qt::Key_Enter)) {
++            QSKIP("platform theme has Key_Enter in ButtonPressKeys");
++        }
+         // check that pressing ENTER has no effect when autorepeat is false
+         testWidget->setDown( false );
+         testWidget->setAutoRepeat( false );
+@@ -286,7 +295,14 @@ void tst_QAbstractButton::setAutoRepeat()
+ 
+         QVERIFY( click_count == 0 );
+         break;
+-    case 5:
++    }
++    case 5: {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(Qt::Key_Enter)) {
++            QSKIP("platform theme has Key_Enter in ButtonPressKeys");
++        }
+         // check that pressing ENTER has no effect when autorepeat is true
+         testWidget->setDown( false );
+         testWidget->setAutoRepeat( true );
+@@ -304,6 +320,7 @@ void tst_QAbstractButton::setAutoRepeat()
+ 
+         QVERIFY( click_count == 0 );
+         break;
++    }
+     case 6:
+         // verify autorepeat is off by default.
+         MyButton tmp( 0);
+@@ -651,5 +668,16 @@ void tst_QAbstractButton::keyNavigation()
+ }
+ #endif
+ 
++void tst_QAbstractButton::buttonPressKeys()
++{
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(testWidget, buttonPressKeys[i]);
++        QCOMPARE(click_count, i + 1);
++    }
++}
++
+ QTEST_MAIN(tst_QAbstractButton)
+ #include "tst_qabstractbutton.moc"
+diff --git a/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+index 32437050f5..46b5af6d63 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+@@ -168,6 +168,7 @@ private slots:
+     void checkMenuItemPosWhenStyleSheetIsSet();
+     void checkEmbeddedLineEditWhenStyleSheetIsSet();
+     void propagateStyleChanges();
++    void buttonPressKeys();
+ 
+ private:
+     PlatformInputContext m_platformInputContext;
+@@ -1682,6 +1683,16 @@ void tst_QComboBox::setModel()
+     QCOMPARE(box.rootModelIndex(), rootModelIndex);
+     box.setModel(box.model());
+     QCOMPARE(box.rootModelIndex(), rootModelIndex);
++
++    // check that setting the same model as the completer's doesn't crash
++    QCompleter *completer = new QCompleter(&box);
++    box.setEditable(true);
++    box.setCompleter(completer);
++    auto *listModel = new QStringListModel({ "one", "two" }, completer);
++    completer->setModel(listModel);
++    QCOMPARE(listModel->rowCount(), 2); // make sure it wasn't deleted
++    box.setModel(listModel);
++    QCOMPARE(listModel->rowCount(), 2); // make sure it wasn't deleted
+ }
+ 
+ void tst_QComboBox::setCustomModelAndView()
+@@ -3632,5 +3643,24 @@ void tst_QComboBox::propagateStyleChanges()
+     QVERIFY(frameStyle.inquired);
+ }
+ 
++void tst_QComboBox::buttonPressKeys()
++{
++    QComboBox comboBox;
++    comboBox.setEditable(false);
++    comboBox.addItem(QString::number(1));
++    comboBox.addItem(QString::number(2));
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(&comboBox, buttonPressKeys[i]);
++        // On some platforms, a window will not be immediately visible,
++        // but take some event-loop iterations to complete.
++        // Using QTRY_VERIFY to deal with that.
++        QTRY_VERIFY(comboBox.view()->isVisible());
++        comboBox.hidePopup();
++    }
++}
++
+ QTEST_MAIN(tst_QComboBox)
+ #include "tst_qcombobox.moc"
+diff --git a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
+index be3cfcd104..c228fdfcca 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
++++ b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qcommandlinkbutton
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qcommandlinkbutton.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
+index 0044d33c66..4cf06296e4 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
+@@ -40,6 +40,9 @@
+ #include <QGridLayout>
+ #include <QPainter>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ class tst_QCommandLinkButton : public QObject
+ {
+     Q_OBJECT
+@@ -223,6 +226,13 @@ void tst_QCommandLinkButton::setAutoRepeat()
+     // check that pressing ENTER has no effect
+     resetCounters();
+     testWidget->setDown( false );
++    // Skip after reset if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
+     testWidget->setAutoRepeat( false );
+     QTest::keyPress( testWidget, Qt::Key_Enter );
+ 
+@@ -255,6 +265,14 @@ void tst_QCommandLinkButton::pressed()
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+ 
++    // Skip if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
++
+     QTest::keyPress( testWidget,Qt::Key_Enter );
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+diff --git a/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro b/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
+index 4a5e76ff65..a235fa1fac 100644
+--- a/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
++++ b/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qgroupbox
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qgroupbox.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp b/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
+index 4fb5d262ca..d8d7562b73 100644
+--- a/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
+@@ -35,6 +35,9 @@
+ #include <QRadioButton>
+ #include <QDialog>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ #include "qgroupbox.h"
+ 
+ class tst_QGroupBox : public QObject
+@@ -69,6 +72,7 @@ private slots:
+     void propagateFocus();
+     void task_QTBUG_19170_ignoreMouseReleaseEvent();
+     void task_QTBUG_15519_propagateMouseEvents();
++    void buttonPressKeys();
+ 
+ private:
+     bool checked;
+@@ -610,6 +614,20 @@ void tst_QGroupBox::task_QTBUG_15519_propagateMouseEvents()
+     QCOMPARE(parent.mouseMoved, true);
+ }
+ 
++void tst_QGroupBox::buttonPressKeys()
++{
++    QGroupBox groupBox;
++    groupBox.setCheckable(true);
++    QSignalSpy clickedSpy(&groupBox, &QGroupBox::clicked);
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(&groupBox, buttonPressKeys[i]);
++        QCOMPARE(clickedSpy.length(), i + 1);
++    }
++}
++
+ void tst_QGroupBox::sendMouseMoveEvent(QWidget *widget, const QPoint &localPos)
+ {
+     // Send a MouseMove event without actually moving the pointer
+diff --git a/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro b/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
+index 353ad06ca2..e55f6148f2 100644
+--- a/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
++++ b/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qpushbutton
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qpushbutton.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp b/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
+index e818514a79..4043e9326a 100644
+--- a/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
+@@ -41,6 +41,9 @@
+ #include <QStyleFactory>
+ #include <QTabWidget>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ class tst_QPushButton : public QObject
+ {
+ Q_OBJECT
+@@ -212,6 +215,13 @@ void tst_QPushButton::autoRepeat()
+     // check that pressing ENTER has no effect
+     resetCounters();
+     testWidget->setDown( false );
++    // Skip after reset if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
+     testWidget->setAutoRepeat( false );
+     QTest::keyPress( testWidget, Qt::Key_Enter );
+ 
+@@ -247,6 +257,14 @@ void tst_QPushButton::pressed()
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+ 
++    // Skip if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
++
+     QTest::keyPress( testWidget,Qt::Key_Enter );
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+diff --git a/qtbase/tests/manual/rhi/cubemap_render/buildshader.bat b/qtbase/tests/manual/rhi/cubemap_render/buildshader.bat
+old mode 100755
+new mode 100644
+Submodule qtconnectivity e957d481..056294c0:
+diff --git a/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp b/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
+index e2635fae..a8b8e3b9 100644
+--- a/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
++++ b/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
+@@ -563,9 +563,11 @@ void HciManager::handleHciAclPacket(const quint8 *data, int size)
+ 
+ void HciManager::handleLeMetaEvent(const quint8 *data)
+ {
+-    // Spec v4.2, Vol 2, part E, 7.7.65ff
++    // Spec v5.3, Vol 4, part E, 7.7.65.*
+     switch (*data) {
+-    case 0x1: {
++    case 0x1: // HCI_LE_Connection_Complete
++    case 0xA: // HCI_LE_Enhanced_Connection_Complete
++    {
+         const quint16 handle = bt_get_le16(data + 2);
+         emit connectionComplete(handle);
+         break;
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp b/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
+index 6a93143b..4a18cfc7 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
+@@ -320,7 +320,10 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_finishSdpScan(QBluetoothServiceD
+             for (const QBluetoothUuid &id : serviceClassUuids) {
+                 if (id.minimumSize() == 16) {
+                     serviceInfo.setServiceUuid(id);
+-                    serviceInfo.setServiceName(QBluetoothServiceDiscoveryAgent::tr("Custom Service"));
++                    if (serviceInfo.serviceName().isEmpty()) {
++                        serviceInfo.setServiceName(
++                                    QBluetoothServiceDiscoveryAgent::tr("Custom Service"));
++                    }
+                     QBluetoothServiceInfo::Sequence modSeq =
+                             serviceInfo.attribute(QBluetoothServiceInfo::ServiceClassIds).value<QBluetoothServiceInfo::Sequence>();
+                     modSeq.removeOne(QVariant::fromValue(id));
+@@ -334,8 +337,10 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_finishSdpScan(QBluetoothServiceD
+                 qCDebug(QT_BT_BLUEZ) << "Discovered services" << discoveredDevices.at(0).address().toString()
+                                      << serviceInfo.serviceName() << serviceInfo.serviceUuid()
+                                      << ">>>" << serviceInfo.serviceClassUuids();
+-
+-                emit q->serviceDiscovered(serviceInfo);
++                // Use queued connection to allow us finish the service looping; the application
++                // might call stop() when it has detected the service-of-interest.
++                QMetaObject::invokeMethod(q, "serviceDiscovered", Qt::QueuedConnection,
++                                          Q_ARG(QBluetoothServiceInfo, serviceInfo));
+             }
+         }
+     }
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp b/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
+index e4d85447..aadd4755 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
+@@ -593,7 +593,7 @@ void QBluetoothSocket::setSocketState(QBluetoothSocket::SocketState state)
+ bool QBluetoothSocket::canReadLine() const
+ {
+     Q_D(const QBluetoothSocketBase);
+-    return d->canReadLine();
++    return d->canReadLine() || QIODevice::canReadLine();
+ }
+ 
+ /*!
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp b/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
+index 084aa958..d6aa17a7 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
+@@ -284,6 +284,10 @@ void QBluetoothSocketPrivateBluezDBus::connectToService(
+         return;
+     }
+ 
++    if (service.socketProtocol() != QBluetoothServiceInfo::Protocol::UnknownProtocol)
++        socketType = service.socketProtocol();
++    qCDebug(QT_BT_BLUEZ) << "Socket protocol used:" << socketType;
++
+     connectToService(service.device().address(), targetService, openMode);
+ }
+ 
+diff --git a/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp b/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
+index 05bc1a0f..a7b5ef1f 100644
+--- a/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
++++ b/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
+@@ -142,7 +142,7 @@ void tst_QBluetoothSocket::initTestCase()
+     qDebug() << "Starting discovery";
+ 
+     sda->setUuidFilter(QBluetoothUuid(QString(TEST_SERVICE_UUID)));
+-    sda->start(QBluetoothServiceDiscoveryAgent::MinimalDiscovery);
++    sda->start(QBluetoothServiceDiscoveryAgent::FullDiscovery);
+ 
+     for (int connectTime = MaxConnectTime; !done_discovery && connectTime > 0; connectTime -= 1000)
+         QTest::qWait(1000);
+Submodule qtdeclarative f5701f0d..8defe7bf:
+diff --git a/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h b/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
+index b65b994d6c..15a8cd6878 100644
+--- a/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
++++ b/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
+@@ -86,7 +86,7 @@ public:
+         if (QTypeInfo<T>::isComplex) {
+             for (int i = 0; i < count; ++i)
+                 new (data + i) T(vector.at(i));
+-        } else {
++        } else if (count) {
+             memcpy(data, static_cast<const void*>(vector.constData()), count * sizeof(T));
+         }
+     }
+diff --git a/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp b/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
+index e57cdd8278..94613598af 100644
+--- a/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
++++ b/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
+@@ -1145,8 +1145,7 @@ void Heap::QObjectWrapper::markObjects(Heap::Base *that, QV4::MarkStack *markSta
+ void QObjectWrapper::destroyObject(bool lastCall)
+ {
+     Heap::QObjectWrapper *h = d();
+-    if (!h->internalClass)
+-        return; // destroyObject already got called
++    Q_ASSERT(h->internalClass);
+ 
+     if (h->object()) {
+         QQmlData *ddata = QQmlData::get(h->object(), false);
+@@ -1176,7 +1175,7 @@ void QObjectWrapper::destroyObject(bool lastCall)
+         }
+     }
+ 
+-    h->~Data();
++    h->destroy();
+ }
+ 
+ 
+diff --git a/qtdeclarative/src/qml/memory/qv4mm.cpp b/qtdeclarative/src/qml/memory/qv4mm.cpp
+index 06caf04e5a..da149a67c4 100644
+--- a/qtdeclarative/src/qml/memory/qv4mm.cpp
++++ b/qtdeclarative/src/qml/memory/qv4mm.cpp
+@@ -981,7 +981,7 @@ void MemoryManager::sweep(bool lastSweep, ClassDestroyStatsCallback classCountPt
+ 
+     if (MultiplyWrappedQObjectMap *multiplyWrappedQObjects = engine->m_multiplyWrappedQObjects) {
+         for (MultiplyWrappedQObjectMap::Iterator it = multiplyWrappedQObjects->begin(); it != multiplyWrappedQObjects->end();) {
+-            if (!it.value().isNullOrUndefined())
++            if (it.value().isNullOrUndefined())
+                 it = multiplyWrappedQObjects->erase(it);
+             else
+                 ++it;
+diff --git a/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp b/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
+index 2079a8ed04..a577cb2351 100644
+--- a/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
++++ b/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
+@@ -389,6 +389,12 @@ void QQmlDelegateModelPrivate::connectToAbstractItemModel()
+                       q,  QQmlDelegateModel, SLOT(_q_rowsRemoved(QModelIndex,int,int)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
+                       q,  QQmlDelegateModel, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsInserted(QModelIndex,int,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsInserted(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsRemoved(QModelIndex,int,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsRemoved(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsMoved(QModelIndex,int,int,QModelIndex,int)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
+                       q, QQmlDelegateModel, SLOT(_q_dataChanged(QModelIndex,QModelIndex,QVector<int>)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
+@@ -413,6 +419,12 @@ void QQmlDelegateModelPrivate::disconnectFromAbstractItemModel()
+                         q, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int)));
+     QObject::disconnect(aim, SIGNAL(rowsRemoved(QModelIndex,int,int)),
+                         q, SLOT(_q_rowsRemoved(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsInserted(QModelIndex,int,int)), q,
++                        SLOT(_q_columnsInserted(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsRemoved(QModelIndex,int,int)), q,
++                        SLOT(_q_columnsRemoved(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)), q,
++                        SLOT(_q_columnsMoved(QModelIndex,int,int,QModelIndex,int)));
+     QObject::disconnect(aim, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
+                         q, SLOT(_q_dataChanged(QModelIndex,QModelIndex,QVector<int>)));
+     QObject::disconnect(aim, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
+@@ -1973,6 +1985,38 @@ void QQmlDelegateModel::_q_rowsMoved(
+     }
+ }
+ 
++void QQmlDelegateModel::_q_columnsInserted(const QModelIndex &parent, int begin, int end)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if (parent == d->m_adaptorModel.rootIndex && begin == 0) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
++void QQmlDelegateModel::_q_columnsRemoved(const QModelIndex &parent, int begin, int end)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if (parent == d->m_adaptorModel.rootIndex && begin == 0) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
++void QQmlDelegateModel::_q_columnsMoved(const QModelIndex &parent, int start, int end,
++                                        const QModelIndex &destination, int column)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if ((parent == d->m_adaptorModel.rootIndex && start == 0)
++        || (destination == d->m_adaptorModel.rootIndex && column == 0)) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
+ void QQmlDelegateModel::_q_dataChanged(const QModelIndex &begin, const QModelIndex &end, const QVector<int> &roles)
+ {
+     Q_D(QQmlDelegateModel);
+diff --git a/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h b/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
+index 8aab4badca..d140bfbaaf 100644
+--- a/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
++++ b/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
+@@ -152,6 +152,9 @@ private Q_SLOTS:
+     void _q_itemsMoved(int from, int to, int count);
+     void _q_modelReset();
+     void _q_rowsInserted(const QModelIndex &,int,int);
++    void _q_columnsInserted(const QModelIndex &, int, int);
++    void _q_columnsRemoved(const QModelIndex &, int, int);
++    void _q_columnsMoved(const QModelIndex &, int, int, const QModelIndex &, int);
+     void _q_rowsAboutToBeRemoved(const QModelIndex &parent, int begin, int end);
+     void _q_rowsRemoved(const QModelIndex &,int,int);
+     void _q_rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int);
+diff --git a/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp b/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
+index 85719fdc80..78e2ab302c 100644
+--- a/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
++++ b/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
+@@ -46,6 +46,7 @@
+ #include "QtQuick/private/qquicktextinput_p.h"
+ #include "QtQuick/private/qquickaccessibleattached_p.h"
+ #include "QtQuick/qquicktextdocument.h"
++#include "QtQuick/qquickrendercontrol.h"
+ QT_BEGIN_NAMESPACE
+ 
+ #if QT_CONFIG(accessibility)
+@@ -57,7 +58,19 @@ QAccessibleQuickItem::QAccessibleQuickItem(QQuickItem *item)
+ 
+ QWindow *QAccessibleQuickItem::window() const
+ {
+-    return item()->window();
++    QQuickWindow *window = item()->window();
++
++    // For QQuickWidget the above window will be the offscreen QQuickWindow,
++    // which is not a part of the accessibility tree. Detect this case and
++    // return the window for the QQuickWidget instead.
++    if (window && !window->handle()) {
++        if (QQuickRenderControl *renderControl = QQuickWindowPrivate::get(window)->renderControl) {
++            if (QWindow *renderWindow = renderControl->renderWindow(nullptr))
++                return renderWindow;
++        }
++    }
++
++    return window;
+ }
+ 
+ int QAccessibleQuickItem::childCount() const
+@@ -113,19 +126,15 @@ QAccessibleInterface *QAccessibleQuickItem::childAt(int x, int y) const
+ QAccessibleInterface *QAccessibleQuickItem::parent() const
+ {
+     QQuickItem *parent = item()->parentItem();
+-    QQuickWindow *window = item()->window();
+-    QQuickItem *ci = window ? window->contentItem() : nullptr;
++    QQuickWindow *itemWindow = item()->window();
++    QQuickItem *ci = itemWindow ? itemWindow->contentItem() : nullptr;
+     while (parent && !QQuickItemPrivate::get(parent)->isAccessible && parent != ci)
+         parent = parent->parentItem();
+ 
+     if (parent) {
+         if (parent == ci) {
+-            // Jump out to the scene widget if the parent is the root item.
+-            // There are two root items, QQuickWindow::rootItem and
+-            // QQuickView::declarativeRoot. The former is the true root item,
+-            // but is not a part of the accessibility tree. Check if we hit
+-            // it here and return an interface for the scene instead.
+-            return QAccessible::queryAccessibleInterface(window);
++            // Jump out to the window if the parent is the root item
++            return QAccessible::queryAccessibleInterface(window());
+         } else {
+             while (parent && !parent->d_func()->isAccessible)
+                 parent = parent->parentItem();
+@@ -188,7 +197,7 @@ QAccessible::State QAccessibleQuickItem::state() const
+     QRect viewRect_ = viewRect();
+     QRect itemRect = rect();
+ 
+-    if (viewRect_.isNull() || itemRect.isNull() || !item()->window() || !item()->window()->isVisible() ||!item()->isVisible() || qFuzzyIsNull(item()->opacity()))
++    if (viewRect_.isNull() || itemRect.isNull() || !window() || !window()->isVisible() ||!item()->isVisible() || qFuzzyIsNull(item()->opacity()))
+         state.invisible = true;
+     if (!viewRect_.intersects(itemRect))
+         state.offscreen = true;
+@@ -201,6 +210,10 @@ QAccessible::State QAccessibleQuickItem::state() const
+     if (role() == QAccessible::EditableText)
+         if (auto ti = qobject_cast<QQuickTextInput *>(item()))
+             state.passwordEdit = ti->echoMode() != QQuickTextInput::Normal;
++    if (!item()->isEnabled()) {
++        state.focusable = false;
++        state.disabled = true;
++    }
+     return state;
+ }
+ 
+diff --git a/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h b/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
+index 39ffcaf39c..8baa01330c 100644
+--- a/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
++++ b/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
+@@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE
+ 
+ #if QT_CONFIG(accessibility)
+ 
+-class QAccessibleQuickWindow : public QAccessibleObject
++class Q_QUICK_EXPORT QAccessibleQuickWindow : public QAccessibleObject
+ {
+ public:
+     QAccessibleQuickWindow(QQuickWindow *object);
+diff --git a/qtdeclarative/src/quick/items/qquickdrag.cpp b/qtdeclarative/src/quick/items/qquickdrag.cpp
+index 8321fcfeed..383078b3b9 100644
+--- a/qtdeclarative/src/quick/items/qquickdrag.cpp
++++ b/qtdeclarative/src/quick/items/qquickdrag.cpp
+@@ -481,7 +481,9 @@ void QQuickDragAttached::setKeys(const QStringList &keys)
+     \qmlattachedproperty stringlist QtQuick::Drag::mimeData
+     \since 5.2
+ 
+-    This property holds a map of mimeData that is used during startDrag.
++    This property holds a map from mime type to data that is used during startDrag.
++    The mime data needs to be a \c string, or an \c ArrayBuffer with the data encoded
++    according to the mime type.
+ */
+ 
+ QVariantMap QQuickDragAttached::mimeData() const
+@@ -766,8 +768,12 @@ Qt::DropAction QQuickDragAttachedPrivate::startDrag(Qt::DropActions supportedAct
+     QDrag *drag = new QDrag(source ? source : q);
+     QMimeData *mimeData = new QMimeData();
+ 
+-    for (auto it = externalMimeData.cbegin(), end = externalMimeData.cend(); it != end; ++it)
+-        mimeData->setData(it.key(), it.value().toString().toUtf8());
++    for (auto it = externalMimeData.cbegin(), end = externalMimeData.cend(); it != end; ++it) {
++        if (static_cast<QMetaType::Type>(it.value().type()) == QMetaType::QByteArray)
++            mimeData->setData(it.key(), it.value().toByteArray());
++        else
++            mimeData->setData(it.key(), it.value().toString().toUtf8());
++    }
+ 
+     drag->setMimeData(mimeData);
+     if (pixmapLoader.isReady()) {
+diff --git a/qtdeclarative/src/quick/items/qquickitem.cpp b/qtdeclarative/src/quick/items/qquickitem.cpp
+index 75f1457816..dec0ae19ae 100644
+--- a/qtdeclarative/src/quick/items/qquickitem.cpp
++++ b/qtdeclarative/src/quick/items/qquickitem.cpp
+@@ -59,6 +59,7 @@
+ #include <QtCore/private/qnumeric_p.h>
+ #include <QtGui/qpa/qplatformtheme.h>
+ #include <QtCore/qloggingcategory.h>
++#include <QtCore/private/qduplicatetracker_p.h>
+ 
+ #include <private/qqmlglobal_p.h>
+ #include <private/qqmlengine_p.h>
+@@ -2326,6 +2327,7 @@ QQuickItem::QQuickItem(QQuickItemPrivate &dd, QQuickItem *parent)
+ QQuickItem::~QQuickItem()
+ {
+     Q_D(QQuickItem);
++    d->inDestructor = true;
+ 
+     if (d->windowRefCount > 1)
+         d->windowRefCount = 1; // Make sure window is set to null in next call to derefWindow().
+@@ -2526,6 +2528,7 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo
+     QQuickItem *current = item;
+     qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: startItem:" << startItem;
+     qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: firstFromItem:" << firstFromItem;
++    QDuplicateTracker<QQuickItem *> cycleDetector;
+     do {
+         qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: current:" << current;
+         qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: from:" << from;
+@@ -2592,7 +2595,10 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo
+         // traversed all of the chain (by compare the [current] item with [startItem])
+         // Since the [startItem] might be promoted to its parent if it is invisible,
+         // we still have to check [current] item with original start item
+-        if ((current == startItem || current == originalStartItem) && from == firstFromItem) {
++        // We might also run into a cycle before we reach firstFromItem again
++        // but note that we have to ignore current if we are meant to skip it
++        if (((current == startItem || current == originalStartItem) && from == firstFromItem) ||
++                (!skip && cycleDetector.hasSeen(current))) {
+             // wrapped around, avoid endless loops
+             if (item == contentItem) {
+                 qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: looped, return contentItem";
+@@ -2689,9 +2695,8 @@ void QQuickItem::setParentItem(QQuickItem *parentItem)
+ 
+         const bool wasVisible = isVisible();
+         op->removeChild(this);
+-        if (wasVisible) {
++        if (wasVisible && !op->inDestructor)
+             emit oldParentItem->visibleChildrenChanged();
+-        }
+     } else if (d->window) {
+         QQuickWindowPrivate::get(d->window)->parentlessItems.remove(this);
+     }
+@@ -2768,8 +2773,9 @@ void QQuickItem::setParentItem(QQuickItem *parentItem)
+ 
+     d->itemChange(ItemParentHasChanged, d->parentItem);
+ 
+-    emit parentChanged(d->parentItem);
+-    if (isVisible() && d->parentItem)
++    if (!d->inDestructor)
++        emit parentChanged(d->parentItem);
++    if (isVisible() && d->parentItem && !QQuickItemPrivate::get(d->parentItem)->inDestructor)
+         emit d->parentItem->visibleChildrenChanged();
+ }
+ 
+@@ -2965,7 +2971,8 @@ void QQuickItemPrivate::removeChild(QQuickItem *child)
+ 
+     itemChange(QQuickItem::ItemChildRemovedChange, child);
+ 
+-    emit q->childrenChanged();
++    if (!inDestructor)
++        emit q->childrenChanged();
+ }
+ 
+ void QQuickItemPrivate::refWindow(QQuickWindow *c)
+@@ -3194,6 +3201,7 @@ QQuickItemPrivate::QQuickItemPrivate()
+     , touchEnabled(false)
+ #endif
+     , hasCursorHandler(false)
++    , inDestructor(false)
+     , dirtyAttributes(0)
+     , nextDirtyItem(nullptr)
+     , prevDirtyItem(nullptr)
+@@ -5120,6 +5128,13 @@ void QQuickItem::componentComplete()
+         d->addToDirtyList();
+         QQuickWindowPrivate::get(d->window)->dirtyItem(this);
+     }
++
++#if QT_CONFIG(accessibility)
++    if (d->isAccessible && d->effectiveVisible) {
++        QAccessibleEvent ev(this, QAccessible::ObjectShow);
++        QAccessible::updateAccessibility(&ev);
++    }
++#endif
+ }
+ 
+ QQuickStateGroup *QQuickItemPrivate::_states()
+@@ -6106,9 +6121,11 @@ bool QQuickItemPrivate::setEffectiveVisibleRecur(bool newEffectiveVisible)
+         QAccessible::updateAccessibility(&ev);
+     }
+ #endif
+-    emit q->visibleChanged();
+-    if (childVisibilityChanged)
+-        emit q->visibleChildrenChanged();
++    if (!inDestructor) {
++        emit q->visibleChanged();
++        if (childVisibilityChanged)
++            emit q->visibleChildrenChanged();
++    }
+ 
+     return true;    // effective visibility DID change
+ }
+@@ -6157,6 +6174,15 @@ void QQuickItemPrivate::setEffectiveEnableRecur(QQuickItem *scope, bool newEffec
+     }
+ 
+     itemChange(QQuickItem::ItemEnabledHasChanged, effectiveEnable);
++#if QT_CONFIG(accessibility)
++    if (isAccessible) {
++        QAccessible::State changedState;
++        changedState.disabled = true;
++        changedState.focusable = true;
++        QAccessibleStateChangeEvent ev(q, changedState);
++        QAccessible::updateAccessibility(&ev);
++    }
++#endif
+     emit q->enabledChanged();
+ }
+ 
+diff --git a/qtdeclarative/src/quick/items/qquickitem_p.h b/qtdeclarative/src/quick/items/qquickitem_p.h
+index 841d91bb40..ade8fb61f2 100644
+--- a/qtdeclarative/src/quick/items/qquickitem_p.h
++++ b/qtdeclarative/src/quick/items/qquickitem_p.h
+@@ -472,6 +472,7 @@ public:
+     bool replayingPressEvent:1;
+     bool touchEnabled:1;
+     bool hasCursorHandler:1;
++    quint32 inDestructor:1; // has entered ~QQuickItem
+ 
+     enum DirtyType {
+         TransformOrigin         = 0x00000001,
+diff --git a/qtdeclarative/src/quick/items/qquickitemview.cpp b/qtdeclarative/src/quick/items/qquickitemview.cpp
+index 010a0152e1..f8ad168a17 100644
+--- a/qtdeclarative/src/quick/items/qquickitemview.cpp
++++ b/qtdeclarative/src/quick/items/qquickitemview.cpp
+@@ -1785,7 +1785,7 @@ void QQuickItemViewPrivate::refill(qreal from, qreal to)
+ 
+     do {
+         bufferPause.stop();
+-        if (currentChanges.hasPendingChanges() || bufferedChanges.hasPendingChanges()) {
++        if (currentChanges.hasPendingChanges() || bufferedChanges.hasPendingChanges() || currentChanges.active) {
+             currentChanges.reset();
+             bufferedChanges.reset();
+             releaseVisibleItems(reusableFlag);
+diff --git a/qtdeclarative/src/quick/items/qquickmousearea_p_p.h b/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
+index fba383e268..0d63618622 100644
+--- a/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
++++ b/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
+@@ -61,7 +61,6 @@ QT_BEGIN_NAMESPACE
+ 
+ class QQuickMouseEvent;
+ class QQuickMouseArea;
+-class QQuickPointerMask;
+ class QQuickMouseAreaPrivate : public QQuickItemPrivate
+ {
+     Q_DECLARE_PUBLIC(QQuickMouseArea)
+@@ -100,7 +99,6 @@ public:
+ #if QT_CONFIG(quick_draganddrop)
+     QQuickDrag *drag;
+ #endif
+-    QPointer<QQuickPointerMask> mask;
+     QPointF startScene;
+     QPointF targetStartPos;
+     QPointF lastPos;
+diff --git a/qtdeclarative/src/quick/items/qquicktext.cpp b/qtdeclarative/src/quick/items/qquicktext.cpp
+index 6230186933..e823ca1095 100644
+--- a/qtdeclarative/src/quick/items/qquicktext.cpp
++++ b/qtdeclarative/src/quick/items/qquicktext.cpp
+@@ -2168,7 +2168,7 @@ void QQuickText::resetMaximumLineCount()
+     <img src="" align="top,middle,bottom" width="" height=""> - inline images
+     <ol type="">, <ul type=""> and <li> - ordered and unordered lists
+     <pre></pre> - preformatted
+-    &gt; &lt; &amp;
++    &gt; &lt; &amp; &quot; &nbsp; &apos;
+     \endcode
+ 
+     \c Text.StyledText parser is strict, requiring tags to be correctly nested.
+diff --git a/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp b/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
+index eb4db0f85e..2325a2665b 100644
+--- a/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
++++ b/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
+@@ -446,7 +446,7 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+         const char *textureRecord = allocatorData;
+         for (int i = 0; i < textureCount; ++i, textureRecord += Qtdf::TextureRecordSize) {
+-            if (textureRecord + Qtdf::TextureRecordSize > qtdfTableEnd) {
++            if (qtdfTableEnd - textureRecord < Qtdf::TextureRecordSize) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+@@ -462,7 +462,7 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+         const char *glyphRecord = textureRecord;
+         for (quint32 i = 0; i < glyphCount; ++i, glyphRecord += Qtdf::GlyphRecordSize) {
+-            if (glyphRecord + Qtdf::GlyphRecordSize > qtdfTableEnd) {
++            if (qtdfTableEnd - glyphRecord < Qtdf:: GlyphRecordSize) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+@@ -512,8 +512,8 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+             int width = texInfo->allocatedArea.width();
+             int height = texInfo->allocatedArea.height();
+-            qint64 size = width * height;
+-            if (reinterpret_cast<const char *>(textureData + size) > qtdfTableEnd) {
++            qint64 size = qint64(width) * height;
++            if (qtdfTableEnd - reinterpret_cast<const char *>(textureData) < size) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+diff --git a/qtdeclarative/src/quick/util/qquickstyledtext.cpp b/qtdeclarative/src/quick/util/qquickstyledtext.cpp
+index d531fc9205..a25af90414 100644
+--- a/qtdeclarative/src/quick/util/qquickstyledtext.cpp
++++ b/qtdeclarative/src/quick/util/qquickstyledtext.cpp
+@@ -564,6 +564,8 @@ void QQuickStyledTextPrivate::parseEntity(const QChar *&ch, const QString &textI
+                 textOut += QChar(60);
+             else if (entity == QLatin1String("amp"))
+                 textOut += QChar(38);
++            else if (entity == QLatin1String("apos"))
++                textOut += QChar(39);
+             else if (entity == QLatin1String("quot"))
+                 textOut += QChar(34);
+             else if (entity == QLatin1String("nbsp"))
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp
+new file mode 100644
+index 0000000000..8a1c901880
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp
+@@ -0,0 +1,110 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include "qaccessiblequickwidget_p.h"
++
++#include "qquickwidget_p.h"
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleQuickWidget::QAccessibleQuickWidget(QQuickWidget* widget)
++: QAccessibleWidget(widget)
++, m_accessibleWindow(QQuickWidgetPrivate::get(widget)->offscreenWindow)
++{
++    // NOTE: m_accessibleWindow is a QAccessibleQuickWindow, and not a
++    // QAccessibleQuickWidgetOffscreenWindow (defined below). This means
++    // it will return the Quick item child interfaces, which is what's needed here
++    // (unlike QAccessibleQuickWidgetOffscreenWindow, which will report 0 children).
++}
++
++QAccessibleInterface *QAccessibleQuickWidget::child(int index) const
++{
++    return m_accessibleWindow.child(index);
++}
++
++int QAccessibleQuickWidget::childCount() const
++{
++    return m_accessibleWindow.childCount();
++}
++
++int QAccessibleQuickWidget::indexOfChild(const QAccessibleInterface *iface) const
++{
++    return m_accessibleWindow.indexOfChild(iface);
++}
++
++QAccessibleInterface *QAccessibleQuickWidget::childAt(int x, int y) const
++{
++    return m_accessibleWindow.childAt(x, y);
++}
++
++QAccessibleQuickWidgetOffscreenWindow::QAccessibleQuickWidgetOffscreenWindow(QQuickWindow *window)
++:QAccessibleQuickWindow(window)
++{
++
++}
++
++QAccessibleInterface *QAccessibleQuickWidgetOffscreenWindow::child(int index) const
++{
++    Q_UNUSED(index);
++    return nullptr;
++}
++
++int QAccessibleQuickWidgetOffscreenWindow::childCount() const
++{
++    return 0;
++}
++
++int QAccessibleQuickWidgetOffscreenWindow::indexOfChild(const QAccessibleInterface *iface) const
++{
++    Q_UNUSED(iface);
++    return -1;
++}
++
++QAccessibleInterface *QAccessibleQuickWidgetOffscreenWindow::QAccessibleQuickWidgetOffscreenWindow::childAt(int x, int y) const
++{
++    Q_UNUSED(x);
++    Q_UNUSED(y);
++    return nullptr;
++}
++
++#endif // accessibility
++
++QT_END_NAMESPACE
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h
+new file mode 100644
+index 0000000000..7c2ab930e0
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h
+@@ -0,0 +1,95 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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 QACCESSIBLEQUICKWIDGET_H
++#define QACCESSIBLEQUICKWIDGET_H
++
++//
++//  W A R N I N G
++//  -------------
++//
++// This file is not part of the Qt API.  It exists purely as an
++// implementation detail.  This header file may change from version to
++// version without notice, or even be removed.
++//
++// We mean it.
++//
++
++#include "qquickwidget.h"
++#include <QtWidgets/qaccessiblewidget.h>
++
++#include <private/qaccessiblequickview_p.h>
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++// These classes implement the QQuickWiget accessibility switcharoo,
++// where the child items of the QQuickWidgetOffscreenWindow are reported
++// as child accessible interfaces of the QAccessibleQuickWidget.
++class QAccessibleQuickWidget: public QAccessibleWidget
++{
++public:
++    QAccessibleQuickWidget(QQuickWidget* widget);
++
++    QAccessibleInterface *child(int index) const override;
++    int childCount() const override;
++    int indexOfChild(const QAccessibleInterface *iface) const override;
++    QAccessibleInterface *childAt(int x, int y) const override;
++
++private:
++    QAccessibleQuickWindow m_accessibleWindow;
++    Q_DISABLE_COPY(QAccessibleQuickWidget)
++};
++
++class QAccessibleQuickWidgetOffscreenWindow: public QAccessibleQuickWindow
++{
++public:
++    QAccessibleQuickWidgetOffscreenWindow(QQuickWindow *window);
++    QAccessibleInterface *child(int index) const override;
++    int childCount() const override;
++    int indexOfChild(const QAccessibleInterface *iface) const override;
++    QAccessibleInterface *childAt(int x, int y) const override;
++};
++
++#endif // accessibility
++
++QT_END_NAMESPACE
++
++#endif
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp
+new file mode 100644
+index 0000000000..7ba88a1769
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp
+@@ -0,0 +1,60 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include "qaccessiblequickwidgetfactory_p.h"
++#include "qaccessiblequickwidget_p.h"
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleInterface *qAccessibleQuickWidgetFactory(const QString &classname, QObject *object)
++{
++    if (classname == QLatin1String("QQuickWidget")) {
++        return new QAccessibleQuickWidget(qobject_cast<QQuickWidget *>(object));
++    } else if (classname == QLatin1String("QQuickWidgetOffscreenWindow")) {
++        return new QAccessibleQuickWidgetOffscreenWindow(qobject_cast<QQuickWindow *>(object));
++    }
++    return 0;
++}
++
++#endif // accessibility
++
++QT_END_NAMESPACE
++
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h
+new file mode 100644
+index 0000000000..8c63b09f81
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h
+@@ -0,0 +1,66 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include <QtGui/qaccessible.h>
++
++#ifndef QACCESSIBLEQUICKWIDGETFACTORY_H
++#define QACCESSIBLEQUICKWIDGETFACTORY_H
++
++//
++//  W A R N I N G
++//  -------------
++//
++// This file is not part of the Qt API.  It exists purely as an
++// implementation detail.  This header file may change from version to
++// version without notice, or even be removed.
++//
++// We mean it.
++//
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleInterface *qAccessibleQuickWidgetFactory(const QString &classname, QObject *object);
++
++#endif
++
++QT_END_NAMESPACE
++
++#endif
+diff --git a/qtdeclarative/src/quickwidgets/qquickwidget.cpp b/qtdeclarative/src/quickwidgets/qquickwidget.cpp
+index 39780f8de3..9c97b43518 100644
+--- a/qtdeclarative/src/quickwidgets/qquickwidget.cpp
++++ b/qtdeclarative/src/quickwidgets/qquickwidget.cpp
+@@ -39,6 +39,7 @@
+ 
+ #include "qquickwidget.h"
+ #include "qquickwidget_p.h"
++#include "qaccessiblequickwidgetfactory_p.h"
+ 
+ #include "private/qquickwindow_p.h"
+ #include "private/qquickitem_p.h"
+@@ -75,9 +76,16 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++QQuickWidgetOffscreenWindow::QQuickWidgetOffscreenWindow(QQuickWindowPrivate &dd, QQuickRenderControl *control)
++:QQuickWindow(dd, control)
++{
++    setTitle(QString::fromLatin1("Offscreen"));
++    setObjectName(QString::fromLatin1("QQuickOffScreenWindow"));
++}
++
+ // override setVisble to prevent accidental offscreen window being created
+ // by base class.
+-class QQuickOffcreenWindowPrivate: public QQuickWindowPrivate {
++class QQuickWidgetOffscreenWindowPrivate: public QQuickWindowPrivate {
+ public:
+     void setVisible(bool visible) override {
+         Q_Q(QWindow);
+@@ -105,9 +113,8 @@ void QQuickWidgetPrivate::init(QQmlEngine* e)
+     Q_Q(QQuickWidget);
+ 
+     renderControl = new QQuickWidgetRenderControl(q);
+-    offscreenWindow = new QQuickWindow(*new QQuickOffcreenWindowPrivate(),renderControl);
+-    offscreenWindow->setTitle(QString::fromLatin1("Offscreen"));
+-    offscreenWindow->setObjectName(QString::fromLatin1("QQuickOffScreenWindow"));
++    offscreenWindow = new QQuickWidgetOffscreenWindow(*new QQuickWidgetOffscreenWindowPrivate(), renderControl);
++    offscreenWindow->setScreen(q->screen());
+     // Do not call create() on offscreenWindow.
+ 
+     // Check if the Software Adaptation is being used
+@@ -138,6 +145,10 @@ void QQuickWidgetPrivate::init(QQmlEngine* e)
+     QWidget::connect(offscreenWindow, &QQuickWindow::focusObjectChanged, q, &QQuickWidget::propagateFocusObjectChanged);
+     QObject::connect(renderControl, SIGNAL(renderRequested()), q, SLOT(triggerUpdate()));
+     QObject::connect(renderControl, SIGNAL(sceneChanged()), q, SLOT(triggerUpdate()));
++
++#if QT_CONFIG(accessibility)
++    QAccessible::installFactory(&qAccessibleQuickWidgetFactory);
++#endif
+ }
+ 
+ void QQuickWidgetPrivate::ensureEngine() const
+@@ -901,9 +912,7 @@ void QQuickWidgetPrivate::createContext()
+ 
+         context = new QOpenGLContext;
+         context->setFormat(offscreenWindow->requestedFormat());
+-        const QWindow *win = q->window()->windowHandle();
+-        if (win && win->screen())
+-            context->setScreen(win->screen());
++        context->setScreen(q->screen());
+         QOpenGLContext *shareContext = qt_gl_global_share_context();
+         if (!shareContext)
+             shareContext = QWidgetPrivate::get(q->window())->shareContext();
+@@ -1520,19 +1529,16 @@ bool QQuickWidget::event(QEvent *e)
+         d->handleWindowChange();
+         break;
+ 
+-    case QEvent::ScreenChangeInternal:
+-        if (QWindow *window = this->window()->windowHandle()) {
+-            QScreen *newScreen = window->screen();
+-
+-            if (d->offscreenWindow)
+-                d->offscreenWindow->setScreen(newScreen);
+-            if (d->offscreenSurface)
+-                d->offscreenSurface->setScreen(newScreen);
++    case QEvent::ScreenChangeInternal: {
++        QScreen *newScreen = screen();
++        if (d->offscreenWindow)
++            d->offscreenWindow->setScreen(newScreen);
++        if (d->offscreenSurface)
++            d->offscreenSurface->setScreen(newScreen);
+ #if QT_CONFIG(opengl)
+-            if (d->context)
+-                d->context->setScreen(newScreen);
++        if (d->context)
++            d->context->setScreen(newScreen);
+ #endif
+-        }
+ 
+         if (d->useSoftwareRenderer
+ #if QT_CONFIG(opengl)
+@@ -1545,7 +1551,7 @@ bool QQuickWidget::event(QEvent *e)
+             d->render(true);
+         }
+         break;
+-
++    }
+     case QEvent::Show:
+     case QEvent::Move:
+         d->updatePosition();
+diff --git a/qtdeclarative/src/quickwidgets/qquickwidget_p.h b/qtdeclarative/src/quickwidgets/qquickwidget_p.h
+index 881f7f9220..1a946bcc71 100644
+--- a/qtdeclarative/src/quickwidgets/qquickwidget_p.h
++++ b/qtdeclarative/src/quickwidgets/qquickwidget_p.h
+@@ -148,6 +148,14 @@ public:
+     bool forceFullUpdate;
+ };
+ 
++class QQuickWidgetOffscreenWindow: public QQuickWindow
++{
++    Q_OBJECT
++
++public:
++    QQuickWidgetOffscreenWindow(QQuickWindowPrivate &dd, QQuickRenderControl *control);
++};
++
+ QT_END_NAMESPACE
+ 
+ #endif // QQuickWidget_P_H
+diff --git a/qtdeclarative/src/quickwidgets/quickwidgets.pro b/qtdeclarative/src/quickwidgets/quickwidgets.pro
+index 2438e577ae..85d156b8a3 100644
+--- a/qtdeclarative/src/quickwidgets/quickwidgets.pro
++++ b/qtdeclarative/src/quickwidgets/quickwidgets.pro
+@@ -7,9 +7,13 @@ DEFINES   += QT_NO_URL_CAST_FROM_STRING QT_NO_INTEGER_EVENT_COORDINATES QT_NO_FO
+ HEADERS += \
+     qquickwidget.h \
+     qquickwidget_p.h \
+-    qtquickwidgetsglobal.h
++    qtquickwidgetsglobal.h \
++    qaccessiblequickwidget_p.h \
++    qaccessiblequickwidgetfactory_p.h
+ 
+ SOURCES += \
+-    qquickwidget.cpp
++    qquickwidget.cpp \
++    qaccessiblequickwidget.cpp \
++    qaccessiblequickwidgetfactory.cpp
+ 
+ load(qt_module)
+diff --git a/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+index 3b7d74df63..b75bf820d5 100644
+--- a/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
++++ b/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+@@ -102,6 +102,7 @@ private slots:
+     void valueConversion_RegularExpression();
+     void castWithMultipleInheritance();
+     void collectGarbage();
++    void collectGarbageNestedWrappersTwoEngines();
+     void gcWithNestedDataStructure();
+     void stacktrace();
+     void numberParsing_data();
+@@ -1809,6 +1810,44 @@ void tst_QJSEngine::collectGarbage()
+     QVERIFY(ptr.isNull());
+ }
+ 
++class TestObjectContainer : public QObject
++{
++    Q_OBJECT
++    Q_PROPERTY(QObject *dummy MEMBER m_dummy CONSTANT)
++
++public:
++    TestObjectContainer() : m_dummy(new QObject(this)) {}
++
++private:
++    QObject *m_dummy;
++};
++
++void tst_QJSEngine::collectGarbageNestedWrappersTwoEngines()
++{
++    QJSEngine engine1;
++    QJSEngine engine2;
++
++    TestObjectContainer container;
++    QQmlEngine::setObjectOwnership(&container, QQmlEngine::CppOwnership);
++
++    engine1.globalObject().setProperty("foobar", engine1.newQObject(&container));
++    engine2.globalObject().setProperty("foobar", engine2.newQObject(&container));
++
++    engine1.evaluate("foobar.dummy.baz = 42");
++    engine2.evaluate("foobar.dummy.baz = 43");
++
++    QCOMPARE(engine1.evaluate("foobar.dummy.baz").toInt(), 42);
++    QCOMPARE(engine2.evaluate("foobar.dummy.baz").toInt(), 43);
++
++    engine1.collectGarbage();
++    engine2.collectGarbage();
++
++    // The GC should not collect dummy object wrappers neither in engine1 nor engine2, we
++    // verify that by checking whether the baz property still has its previous value.
++    QCOMPARE(engine1.evaluate("foobar.dummy.baz").toInt(), 42);
++    QCOMPARE(engine2.evaluate("foobar.dummy.baz").toInt(), 43);
++}
++
+ void tst_QJSEngine::gcWithNestedDataStructure()
+ {
+     // The GC must be able to traverse deeply nested objects, otherwise this
+diff --git a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml
+new file mode 100644
+index 0000000000..206133bb39
+--- /dev/null
++++ b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml
+@@ -0,0 +1,11 @@
++import QtQuick 2.8
++
++ListView {
++    id: root
++    width: 200
++    height: 200
++
++    delegate: Text {
++        text: display
++    }
++}
+diff --git a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
+index 35f1e2c94d..1722447830 100644
+--- a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
++++ b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
+@@ -27,6 +27,8 @@
+ ****************************************************************************/
+ 
+ #include <QtTest/qtest.h>
++#include <QtCore/QConcatenateTablesProxyModel>
++#include <QtGui/QStandardItemModel>
+ #include <QtQml/qqmlcomponent.h>
+ #include <QtQmlModels/private/qqmldelegatemodel_p.h>
+ #include <QtQuick/qquickview.h>
+@@ -47,6 +49,7 @@ private slots:
+     void filterOnGroup_removeWhenCompleted();
+     void qtbug_86017();
+     void contextAccessedByHandler();
++    void redrawUponColumnChange();
+ };
+ 
+ class AbstractItemModel : public QAbstractItemModel
+@@ -186,6 +189,30 @@ void tst_QQmlDelegateModel::contextAccessedByHandler()
+     QVERIFY(root->property("works").toBool());
+ }
+ 
++void tst_QQmlDelegateModel::redrawUponColumnChange()
++{
++    QStandardItemModel m1;
++    m1.appendRow({
++            new QStandardItem("Banana"),
++            new QStandardItem("Coconut"),
++    });
++
++    QQuickView view(testFileUrl("redrawUponColumnChange.qml"));
++    QCOMPARE(view.status(), QQuickView::Ready);
++    view.show();
++    QQuickItem *root = view.rootObject();
++    root->setProperty("model", QVariant::fromValue<QObject *>(&m1));
++
++    QObject *item = root->property("currentItem").value<QObject *>();
++    QVERIFY(item);
++    QCOMPARE(item->property("text").toString(), "Banana");
++
++    QVERIFY(root);
++    m1.removeColumn(0);
++
++    QCOMPARE(item->property("text").toString(), "Coconut");
++}
++
+ QTEST_MAIN(tst_QQmlDelegateModel)
+ 
+ #include "tst_qqmldelegatemodel.moc"
+diff --git a/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp b/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
+index 5d635aa63b..824fd89e5b 100644
+--- a/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
++++ b/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
+@@ -76,10 +76,10 @@ void tst_qv4mm::multiWrappedQObjects()
+         QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 1);
+         QCOMPARE(engine2.memoryManager->m_pendingFreedObjectWrapperValue.size(), 0);
+ 
+-        // Moves the additional WeakValue from m_multiplyWrappedQObjects to
+-        // m_pendingFreedObjectWrapperValue. It's still alive after all.
++        // The additional WeakValue from m_multiplyWrappedQObjects hasn't been moved
++        // to m_pendingFreedObjectWrapperValue yet. It's still alive after all.
+         engine1.memoryManager->runGC();
+-        QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 2);
++        QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 1);
+ 
+         // engine2 doesn't own the object as engine1 was the first to wrap it above.
+         // Therefore, no effect here.
+diff --git a/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml b/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml
+new file mode 100644
+index 0000000000..889e480f3b
+--- /dev/null
++++ b/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml
+@@ -0,0 +1,13 @@
++import QtQuick 2.6
++
++Item {
++    visible: true
++    Item {
++        visible: false
++        Item {
++            objectName: "hiddenChild"
++            activeFocusOnTab: true
++            focus: true
++        }
++    }
++}
+diff --git a/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp b/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+index c8f251dbe1..c8ef36ee68 100644
+--- a/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
++++ b/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+@@ -67,6 +67,7 @@ private slots:
+     void activeFocusOnTab10();
+     void activeFocusOnTab_infiniteLoop_data();
+     void activeFocusOnTab_infiniteLoop();
++    void activeFocusOnTab_infiniteLoopControls();
+ 
+     void nextItemInFocusChain();
+     void nextItemInFocusChain2();
+@@ -1057,6 +1058,17 @@ void tst_QQuickItem::activeFocusOnTab_infiniteLoop()
+     QCOMPARE(item, window->rootObject());
+ }
+ 
++
++void tst_QQuickItem::activeFocusOnTab_infiniteLoopControls()
++{
++    auto source = testFileUrl("activeFocusOnTab_infiniteLoop3.qml");
++    QScopedPointer<QQuickView>window(new QQuickView());
++    window->setSource(source);
++    window->show();
++    QVERIFY(window->errors().isEmpty());
++    QTest::keyClick(window.get(), Qt::Key_Tab); // should not hang
++}
++
+ void tst_QQuickItem::nextItemInFocusChain()
+ {
+     if (!qt_tab_all_widgets())
+Submodule qtdoc c0c7bf07...79d6ef69:
+Submodule qtimageformats 2dcf2899..abe44c0f:
+diff --git a/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp b/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
+index dde783c..1bf9074 100644
+--- a/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
+@@ -462,8 +462,12 @@ static bool parseIconEntryInfo(ICNSEntry &icon)
+     if (isIconCompressed(icon))
+         return true;
+     // Icon depth:
+-    if (!depth.isEmpty())
+-        icon.depth = ICNSEntry::Depth(depth.toUInt());
++    if (!depth.isEmpty()) {
++        const uint depthUInt = depth.toUInt();
++        if (depthUInt > 32)
++            return false;
++        icon.depth = ICNSEntry::Depth(depthUInt);
++    }
+     // Try mono if depth not found
+     if (icon.depth == ICNSEntry::DepthUnknown)
+         icon.depth = ICNSEntry::DepthMono;
+@@ -515,6 +519,9 @@ static bool parseIconEntryInfo(ICNSEntry &icon)
+         }
+         icon.height = icon.width;
+     }
++    // Sanity check
++    if (icon.width == 0 || icon.width > 4096)
++        return false;
+     return true;
+ }
+ 
+@@ -685,7 +692,7 @@ bool QICNSHandler::canRead() const
+ bool QICNSHandler::read(QImage *outImage)
+ {
+     QImage img;
+-    if (!ensureScanned()) {
++    if (!ensureScanned() || m_currentIconIndex >= m_icons.size()) {
+         qWarning("QICNSHandler::read(): The device wasn't parsed properly!");
+         return false;
+     }
+@@ -892,7 +899,7 @@ bool QICNSHandler::scanDevice()
+             return false;
+ 
+         const qint64 blockDataOffset = device()->pos();
+-        if (!isBlockHeaderValid(blockHeader)) {
++        if (!isBlockHeaderValid(blockHeader, ICNSBlockHeaderSize + filelength - blockDataOffset)) {
+             qWarning("QICNSHandler::scanDevice(): Failed, bad header at pos %s. OSType \"%s\", length %u",
+                      QByteArray::number(blockDataOffset).constData(),
+                      nameFromOSType(blockHeader.ostype).constData(), blockHeader.length);
+@@ -927,11 +934,14 @@ bool QICNSHandler::scanDevice()
+         case ICNSBlockHeader::TypeOdrp:
+             // Icns container seems to have an embedded icon variant container
+             // Let's start a scan for entries
+-            while (device()->pos() < nextBlockOffset) {
++            while (!stream.atEnd() && device()->pos() < nextBlockOffset) {
+                 ICNSBlockHeader icon;
+                 stream >> icon;
++                if (stream.status() != QDataStream::Ok)
++                    return false;
+                 // Check for incorrect variant entry header and stop scan
+-                if (!isBlockHeaderValid(icon, blockDataLength))
++                quint64 remaining = blockDataLength - (device()->pos() - blockDataOffset);
++                if (!isBlockHeaderValid(icon, ICNSBlockHeaderSize + remaining))
+                     break;
+                 if (!addEntry(icon, device()->pos(), blockHeader.ostype))
+                     return false;
+@@ -1003,7 +1013,7 @@ bool QICNSHandler::scanDevice()
+             break;
+         }
+     }
+-    return true;
++    return (m_icons.size() > 0);
+ }
+ 
+ const ICNSEntry &QICNSHandler::getIconMask(const ICNSEntry &icon) const
+diff --git a/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp b/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
+index 5082023..cb34374 100644
+--- a/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
++++ b/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
+@@ -43,6 +43,7 @@
+ #include "qimage.h"
+ #include "qvariant.h"
+ #include "qcolor.h"
++#include "qimagereader.h"
+ 
+ #include <jasper/jasper.h>
+ #include <math.h> // for pow
+@@ -333,16 +334,46 @@ private:
+ Jpeg2000JasperReader::Jpeg2000JasperReader(QIODevice *iod, SubFormat format)
+     : jasperOk(true), ioDevice(iod), format(format), hasAlpha(false)
+ {
++#if JAS_VERSION_MAJOR < 3
+     if (jas_init()) {
+         jasperOk = false;
+         qDebug("Jasper Library initialization failed");
+     }
++#else
++    jas_conf_clear();
++#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
++    jas_conf_set_max_mem_usage(QImageReader::allocationLimit() * 1024 * 1024);
++#else
++    // 128MB seems to be enough.
++    jas_conf_set_max_mem_usage(128 * 1024 * 1024);
++#endif
++    if (jas_init_library()) {
++        jasperOk = false;
++        qDebug("Jasper library initialization failed");
++    }
++    if (jas_init_thread()) {
++        jas_cleanup_library();
++        jasperOk = false;
++        qDebug("Jasper thread initialization failed");
++    }
++#endif
+ }
+ 
+ Jpeg2000JasperReader::~Jpeg2000JasperReader()
+ {
++#if JAS_VERSION_MAJOR < 3
+     if (jasperOk)
+         jas_cleanup();
++#else
++    if (jasperOk) {
++        if (jas_cleanup_thread()) {
++            qDebug("Jasper thread cleanup failed");
++        }
++        if (jas_cleanup_library()) {
++            qDebug("Jasper library cleanup failed");
++        }
++    }
++#endif
+ }
+ 
+ /*! \internal
+@@ -857,7 +888,7 @@ bool Jpeg2000JasperReader::write(const QImage &image, int quality)
+     }
+ 
+     // Open an empty jasper stream that grows automatically
+-    jas_stream_t * memory_stream = jas_stream_memopen(0, -1);
++    jas_stream_t * memory_stream = jas_stream_memopen(0, 0);
+ 
+     // Jasper wants a non-const string.
+     char *str = qstrdup(jasperFormatString.toLatin1().constData());
+diff --git a/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp b/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
+index 1386750..ac8956c 100644
+--- a/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
+@@ -361,6 +361,8 @@ bool QTiffHandler::read(QImage *image)
+     }
+ 
+     TIFF *const tiff = d->tiff;
++    if (TIFFIsTiled(tiff) && TIFFTileSize64(tiff) > uint64_t(image->sizeInBytes())) // Corrupt image
++        return false;
+     const quint32 width = d->size.width();
+     const quint32 height = d->size.height();
+ 
+diff --git a/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp b/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
+index 82d38cb..d02eb05 100644
+--- a/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
+@@ -45,6 +45,7 @@
+ #include <qdebug.h>
+ #include <qpainter.h>
+ #include <qvariant.h>
++#include <QtEndian>
+ 
+ static const int riffHeaderSize = 12; // RIFF_HEADER_SIZE from webp/format_constants.h
+ 
+@@ -102,21 +103,23 @@ bool QWebpHandler::ensureScanned() const
+ 
+     m_scanState = ScanError;
+ 
+-    if (device()->isSequential()) {
+-        qWarning() << "Sequential devices are not supported";
++    QWebpHandler *that = const_cast<QWebpHandler *>(this);
++    const int headerBytesNeeded = sizeof(WebPBitstreamFeatures);
++    QByteArray header = device()->peek(headerBytesNeeded);
++    if (header.size() < headerBytesNeeded)
+         return false;
+-    }
+ 
+-    qint64 oldPos = device()->pos();
+-    device()->seek(0);
+-
+-    QWebpHandler *that = const_cast<QWebpHandler *>(this);
+-    QByteArray header = device()->peek(sizeof(WebPBitstreamFeatures));
++    // We do no random access during decoding, just a readAll() of the whole image file. So if
++    // if it is all available already, we can accept a sequential device. The riff header contains
++    // the file size minus 8 bytes header
++    qint64 byteSize = qFromLittleEndian<quint32>(header.constData() + 4);
++    if (device()->isSequential() && device()->bytesAvailable() < byteSize + 8) {
++        qWarning() << "QWebpHandler: Insufficient data available in sequential device";
++        return false;
++    }
+     if (WebPGetFeatures((const uint8_t*)header.constData(), header.size(), &(that->m_features)) == VP8_STATUS_OK) {
+         if (m_features.has_animation) {
+             // For animation, we have to read and scan whole file to determine loop count and images count
+-            device()->seek(oldPos);
+-
+             if (that->ensureDemuxer()) {
+                 that->m_loop = WebPDemuxGetI(m_demuxer, WEBP_FF_LOOP_COUNT);
+                 that->m_frameCount = WebPDemuxGetI(m_demuxer, WEBP_FF_FRAME_COUNT);
+@@ -126,17 +129,13 @@ bool QWebpHandler::ensureScanned() const
+                 if (that->m_features.has_alpha)
+                     that->m_composited->fill(Qt::transparent);
+ 
+-                // We do not reset device position since we have read in all data
+                 m_scanState = ScanSuccess;
+-                return true;
+             }
+         } else {
+             m_scanState = ScanSuccess;
+         }
+     }
+ 
+-    device()->seek(oldPos);
+-
+     return m_scanState == ScanSuccess;
+ }
+ 
+@@ -159,7 +158,7 @@ bool QWebpHandler::ensureDemuxer()
+ 
+ bool QWebpHandler::read(QImage *image)
+ {
+-    if (!ensureScanned() || device()->isSequential() || !ensureDemuxer())
++    if (!ensureScanned() || !ensureDemuxer())
+         return false;
+ 
+     QRect prevFrameRect;
+Submodule qtlocation 98a5c511..f991e28c:
+diff --git a/qtlocation/src/location/configure.json b/qtlocation/src/location/configure.json
+index 6d01a9a3..d1e623a1 100644
+--- a/qtlocation/src/location/configure.json
++++ b/qtlocation/src/location/configure.json
+@@ -9,7 +9,7 @@
+             "label": "Qt.labs.location experimental QML plugin",
+             "purpose": "Provides experimental QtLocation QML types",
+             "section": "Location",
+-            "condition": "config.opengl",
++            "condition": "features.opengl",
+             "output": [ "privateFeature" ]
+         },
+         "geoservices_osm": {
+diff --git a/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp b/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
+index a978573d..11e1466f 100644
+--- a/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
++++ b/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
+@@ -158,7 +158,7 @@ void QGeoMapObjectQSGSupport::updateMapObjects(QSGNode *root, QQuickWindow *wind
+     if (!root)
+         return;
+ 
+-    if (m_mapObjectsRootNode && m_mapObjectsRootNode->parent())
++    if (m_mapObjectsRootNode && !m_mapObjectsRootNode->parent())
+         root->appendChildNode(m_mapObjectsRootNode.get());
+ 
+     if (!m_mapObjectsRootNode) {
+diff --git a/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
+index 5a40467e..d123c6a8 100644
+--- a/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
+@@ -59,8 +59,10 @@ QT_BEGIN_NAMESPACE
+ static const QString kPrefixEsri(QStringLiteral("esri."));
+ static const QString kParamUserAgent(kPrefixEsri + QStringLiteral("useragent"));
+ 
+-static const QString kUrlGeocode(QStringLiteral("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates"));
+-static const QString kUrlReverseGeocode(QStringLiteral("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode"));
++static const QString kUrlGeocode(QStringLiteral("https://geocode.arcgis.com/arcgis/rest/services/"
++                                                "World/GeocodeServer/findAddressCandidates"));
++static const QString kUrlReverseGeocode(QStringLiteral(
++        "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode"));
+ 
+ static QString addressToQuery(const QGeoAddress &address)
+ {
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
+index 17492d94..96c12b1b 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
+@@ -46,7 +46,8 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-// JSON reference: http://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
++// JSON reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
+ 
+ static const QString kErrorMessage(QStringLiteral("Error %1: %2."));
+ static const QString kErrorJson(QStringLiteral("Error: invalide JSON document."));
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
+index 8cadfb29..92b6bb13 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
+@@ -44,7 +44,8 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-// JSON reference: http://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
++// JSON reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
+ 
+ GeoRouteReplyEsri::GeoRouteReplyEsri(QNetworkReply *reply, const QGeoRouteRequest &request,
+                                      QObject *parent) :
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
+index 0e6bc2c7..ed613f4b 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
+@@ -48,7 +48,8 @@ static const QString kPrefixEsri(QStringLiteral("esri."));
+ static const QString kParamUserAgent(kPrefixEsri + QStringLiteral("useragent"));
+ static const QString kParamToken(kPrefixEsri + QStringLiteral("token"));
+ 
+-static const QString kUrlRouting(QStringLiteral("http://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve"));
++static const QString kUrlRouting(QStringLiteral(
++        "https://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve"));
+ 
+ GeoRoutingManagerEngineEsri::GeoRoutingManagerEngineEsri(const QVariantMap &parameters,
+                                                          QGeoServiceProvider::Error *error,
+@@ -70,7 +71,8 @@ GeoRoutingManagerEngineEsri::~GeoRoutingManagerEngineEsri()
+ {
+ }
+ 
+-// REST reference: http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
++// REST reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
+ 
+ QGeoRouteReply *GeoRoutingManagerEngineEsri::calculateRoute(const QGeoRouteRequest &request)
+ {
+@@ -125,7 +127,7 @@ void GeoRoutingManagerEngineEsri::replyError(QGeoRouteReply::Error errorCode, co
+ QString GeoRoutingManagerEngineEsri::preferedDirectionLangage()
+ {
+     // list of supported langages is defined in:
+-    // http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
++    // https://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
+     const QStringList supportedLanguages = {
+         "ar", // Generate directions in Arabic
+         "cs", // Generate directions in Czech
+diff --git a/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
+index 5d15835d..24148f95 100644
+--- a/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
+@@ -230,7 +230,8 @@ QGeoMap *GeoTiledMappingManagerEngineEsri::createMap()
+ // ${y} = Y
+ // ${token} = Token
+ 
+-// template = 'http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{{z}}/{{y}}/{{x}}.png'
++// template =
++// 'https://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{{z}}/{{y}}/{{x}}.png'
+ 
+ bool GeoTiledMappingManagerEngineEsri::initializeMapSources(QGeoServiceProvider::Error *error,
+                                                             QString *errorString,
+diff --git a/qtlocation/src/plugins/geoservices/esri/maps.json b/qtlocation/src/plugins/geoservices/esri/maps.json
+index 8167ae7d..862e087d 100644
+--- a/qtlocation/src/plugins/geoservices/esri/maps.json
++++ b/qtlocation/src/plugins/geoservices/esri/maps.json
+@@ -6,8 +6,8 @@
+             "description": "ArcGIS Online World Street Map",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=3b93337983e9436f8db950e38a8629af'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=3b93337983e9436f8db950e38a8629af'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -16,8 +16,8 @@
+             "": "ArcGIS Online World Imagery",
+             "mobile": true,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -26,8 +26,8 @@
+             "description": "ArcGIS Online World Terrain Base",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=c61ad8ab017d49e1a82f580ee1298931'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=c61ad8ab017d49e1a82f580ee1298931'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -36,8 +36,8 @@
+             "description": "ArcGIS Online World Topography",
+             "mobile": true,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=30e5fe3149c34df1ba922e6f5bbf808f'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=30e5fe3149c34df1ba922e6f5bbf808f'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -46,8 +46,8 @@
+             "description": "This map presents land cover and detailed topographic maps for the United States.",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=99cd5fbd98934028802b4f797c4b1732'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=99cd5fbd98934028802b4f797c4b1732'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -56,8 +56,8 @@
+             "description": "National Geographic World Map",
+             "mobile": false,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=b9b1b422198944fbbd5250b3241691b6'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=b9b1b422198944fbbd5250b3241691b6'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -66,8 +66,8 @@
+             "description": "Thematic content providing a neutral background with minimal colors",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=ed712cb1db3e4bae9e85329040fb9a49'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=ed712cb1db3e4bae9e85329040fb9a49'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -76,8 +76,8 @@
+             "description": "Natural Earth physical map for the world",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=c4ec722a1cd34cf0a23904aadf8923a0'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=c4ec722a1cd34cf0a23904aadf8923a0'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -86,8 +86,8 @@
+             "description": "Portrays surface elevation as shaded relief",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=9c5370d0b54f4de1b48a3792d7377ff2'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=9c5370d0b54f4de1b48a3792d7377ff2'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -96,8 +96,8 @@
+             "description": "This map is designed to be used as a basemap by marine GIS professionals and as a reference map by anyone interested in ocean data",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=1e126e7520f9466c9ca28b8f28b5e500'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=1e126e7520f9466c9ca28b8f28b5e500'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -106,8 +106,8 @@
+             "description": "Thematic content providing a neutral background with minimal colors",
+             "mobile": false,
+             "night": true,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=a284a9b99b3446a3910d4144a50990f6'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=a284a9b99b3446a3910d4144a50990f6'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -116,8 +116,8 @@
+             "description": "DeLorme’s topographic basemap is a seamless global data set that portrays transportation, hydrography, jurisdiction boundaries, and major geographic features",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/Specialty/DeLorme_World_Base_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=b165c3df453e4be6b5ac4fdb241effbe'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/Specialty/DeLorme_World_Base_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=b165c3df453e4be6b5ac4fdb241effbe'>Esri</a> contributors"
+         }
+     ]
+ }
+diff --git a/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
+index 3858ddf5..af66f28e 100644
+--- a/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
+@@ -63,8 +63,10 @@ static const QString kCountriesKey(QStringLiteral("detailedCountries"));
+ static const QString kLocalizedNamesKey(QStringLiteral("localizedNames"));
+ static const QString kMaxLocationsKey(QStringLiteral("maxLocations"));
+ 
+-static const QUrl kUrlGeocodeServer("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer?f=pjson");
+-static const QUrl kUrlFindAddressCandidates("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates");
++static const QUrl kUrlGeocodeServer(
++        "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer?f=pjson");
++static const QUrl kUrlFindAddressCandidates("https://geocode.arcgis.com/arcgis/rest/services/World/"
++                                            "GeocodeServer/findAddressCandidates");
+ 
+ PlaceManagerEngineEsri::PlaceManagerEngineEsri(const QVariantMap &parameters, QGeoServiceProvider::Error *error,
+                                                QString *errorString) :
+Submodule qtmultimedia f0344079..0d7cc33a:
+diff --git a/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp b/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
+index 2b5325132..b68b4af1b 100644
+--- a/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
++++ b/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
+@@ -402,6 +402,8 @@ int QPulseAudioInput::bytesReady() const
+ 
+ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ {
++    Q_ASSERT(data != nullptr || len == 0);
++
+     m_bytesAvailable = checkBytesReady();
+ 
+     setError(QAudio::NoError);
+@@ -411,7 +413,8 @@ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ 
+     if (!m_pullMode && !m_tempBuffer.isEmpty()) {
+         readBytes = qMin(static_cast<int>(len), m_tempBuffer.size());
+-        memcpy(data, m_tempBuffer.constData(), readBytes);
++        if (readBytes)
++            memcpy(data, m_tempBuffer.constData(), readBytes);
+         m_totalTimeValue += readBytes;
+ 
+         if (readBytes < m_tempBuffer.size()) {
+@@ -502,9 +505,10 @@ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ 
+ void QPulseAudioInput::applyVolume(const void *src, void *dest, int len)
+ {
++    Q_ASSERT((src && dest) || len == 0);
+     if (m_volume < 1.f)
+         QAudioHelperInternal::qMultiplySamples(m_volume, m_format, src, dest, len);
+-    else
++    else if (len)
+         memcpy(dest, src, len);
+ }
+ 
+Submodule qtpim 02efef5e...f9a8f0fc (commits not present)
+Submodule qtquick3d b85cf622..47defc8b:
+diff --git a/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro b/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
+index ca5c499e..174a075b 100644
+--- a/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
++++ b/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
+@@ -10,7 +10,7 @@ QT_FOR_CONFIG += assetimporters-private
+ include($$OUT_PWD/../qtassetimporters-config.pri)
+ 
+ qtConfig(system-assimp):!if(cross_compile:host_build) {
+-    QMAKE_USE_PRIVATE += assimp
++    QMAKE_USE_PRIVATE += quick3d-assimp
+ } else {
+     include(../../../3rdparty/assimp/assimp.pri)
+ }
+Submodule qtquickcontrols2 3a657dc0..56ce8233:
+diff --git a/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp b/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
+index e5fe734f7..e36922775 100644
+--- a/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
++++ b/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
+@@ -38,6 +38,7 @@
+ #include "qwidgetplatformmenuitem_p.h"
+ 
+ #include <QtGui/qwindow.h>
++#include <QtGui/private/qhighdpiscaling_p.h>
+ #include <QtWidgets/qmenu.h>
+ #include <QtWidgets/qaction.h>
+ 
+@@ -145,7 +146,7 @@ void QWidgetPlatformMenu::showPopup(const QWindow *window, const QRect &targetRe
+ 
+     QPoint targetPos = targetRect.bottomLeft();
+     if (window)
+-        targetPos = window->mapToGlobal(targetPos);
++        targetPos = window->mapToGlobal(QHighDpi::fromNativeLocalPosition(targetPos, window));
+ 
+     const QWidgetPlatformMenuItem *widgetItem = qobject_cast<const QWidgetPlatformMenuItem *>(item);
+     m_menu->popup(targetPos, widgetItem ? widgetItem->action() : nullptr);
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
+index 950e4e099..b81fbea0b 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
+@@ -387,6 +387,17 @@ void QQuickAbstractButtonPrivate::itemImplicitHeightChanged(QQuickItem *item)
+         emit q->implicitIndicatorHeightChanged();
+ }
+ 
++void QQuickAbstractButtonPrivate::itemDestroyed(QQuickItem *item)
++{
++    Q_Q(QQuickAbstractButton);
++    QQuickControlPrivate::itemDestroyed(item);
++    if (item == indicator) {
++        indicator = nullptr;
++        emit q->implicitIndicatorWidthChanged();
++        emit q->implicitIndicatorHeightChanged();
++    }
++}
++
+ QQuickAbstractButton *QQuickAbstractButtonPrivate::findCheckedButton() const
+ {
+     Q_Q(const QQuickAbstractButton);
+@@ -1176,6 +1187,12 @@ QAccessible::Role QQuickAbstractButton::accessibleRole() const
+     }
+     return QAccessible::Button;
+ }
++
++void QQuickAbstractButton::accessiblePressAction()
++{
++    Q_D(QQuickAbstractButton);
++    d->trigger();
++}
+ #endif
+ 
+ QT_END_NAMESPACE
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
+index 0fa48980e..ab66220d0 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
+@@ -209,6 +209,7 @@ protected:
+ #if QT_CONFIG(accessibility)
+     void accessibilityActiveChanged(bool active) override;
+     QAccessible::Role accessibleRole() const override;
++    Q_INVOKABLE void accessiblePressAction();
+ #endif
+ 
+ private:
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
+index 9291c1a87..b729720f2 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
+@@ -109,6 +109,7 @@ public:
+ 
+     void itemImplicitWidthChanged(QQuickItem *item) override;
+     void itemImplicitHeightChanged(QQuickItem *item) override;
++    void itemDestroyed(QQuickItem *item) override;
+ 
+     // copied from qabstractbutton.cpp
+     static const int AUTO_REPEAT_DELAY = 300;
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp b/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
+index 2041e7741..8610cdfae 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
+@@ -145,7 +145,7 @@ int QQuickActionPrivate::ShortcutEntry::shortcutId() const
+ 
+ void QQuickActionPrivate::ShortcutEntry::grab(const QKeySequence &shortcut, bool enabled)
+ {
+-    if (shortcut.isEmpty())
++    if (shortcut.isEmpty() || m_shortcutId)
+         return;
+ 
+     Qt::ShortcutContext context = Qt::WindowShortcut; // TODO
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp b/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
+index f38c2b09c..6eed2a024 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
+@@ -225,6 +225,7 @@ void QQuickContainerPrivate::cleanup()
+     QObject::disconnect(contentModel, &QQmlObjectModel::countChanged, q, &QQuickContainer::countChanged);
+     QObject::disconnect(contentModel, &QQmlObjectModel::childrenChanged, q, &QQuickContainer::contentChildrenChanged);
+     delete contentModel;
++    contentModel = nullptr;
+ }
+ 
+ QQuickItem *QQuickContainerPrivate::itemAt(int index) const
+@@ -436,7 +437,7 @@ void QQuickContainerPrivate::contentChildren_clear(QQmlListProperty<QQuickItem>
+ void QQuickContainerPrivate::updateContentWidth()
+ {
+     Q_Q(QQuickContainer);
+-    if (hasContentWidth || qFuzzyCompare(contentWidth, implicitContentWidth))
++    if (hasContentWidth || qFuzzyCompare(contentWidth, implicitContentWidth) || !contentModel)
+         return;
+ 
+     contentWidth = implicitContentWidth;
+@@ -446,7 +447,7 @@ void QQuickContainerPrivate::updateContentWidth()
+ void QQuickContainerPrivate::updateContentHeight()
+ {
+     Q_Q(QQuickContainer);
+-    if (hasContentHeight || qFuzzyCompare(contentHeight, implicitContentHeight))
++    if (hasContentHeight || qFuzzyCompare(contentHeight, implicitContentHeight) || !contentModel)
+         return;
+ 
+     contentHeight = implicitContentHeight;
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp b/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
+index bbbd0e622..1f4b47343 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
+@@ -845,6 +845,13 @@ void QQuickControlPrivate::executeBackground(bool complete)
+         quickCompleteDeferred(q, backgroundName(), background);
+ }
+ 
++/*
++    \internal
++
++    Hides an item that was replaced by a newer one, rather than
++    deleting it, as the item is typically created in QML and hence
++    we don't own it.
++*/
+ void QQuickControlPrivate::hideOldItem(QQuickItem *item)
+ {
+     if (!item)
+@@ -863,6 +870,29 @@ void QQuickControlPrivate::hideOldItem(QQuickItem *item)
+ #endif
+ }
+ 
++/*
++    \internal
++
++    Named "unhide" because it's used for cases where an item
++    that was previously hidden by \l hideOldItem() wants to be
++    shown by a control again, such as a ScrollBar in ScrollView.
++*/
++void QQuickControlPrivate::unhideOldItem(QQuickControl *control, QQuickItem *item)
++{
++    Q_ASSERT(item);
++    qCDebug(lcItemManagement) << "unhiding old item" << item;
++
++    item->setVisible(true);
++    item->setParentItem(control);
++
++#if QT_CONFIG(accessibility)
++    // Add the item back in to the accessibility tree.
++    QQuickAccessibleAttached *accessible = accessibleAttached(item);
++    if (accessible)
++        accessible->setIgnored(false);
++#endif
++}
++
+ void QQuickControlPrivate::updateBaselineOffset()
+ {
+     Q_Q(QQuickControl);
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h b/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
+index 8e979079e..a6e624c91 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
+@@ -173,6 +173,7 @@ public:
+     virtual void executeBackground(bool complete = false);
+ 
+     static void hideOldItem(QQuickItem *item);
++    static void unhideOldItem(QQuickControl *control, QQuickItem *item);
+ 
+     void updateBaselineOffset();
+ 
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp b/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
+index e6db14eb5..6197d1547 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
+@@ -237,7 +237,7 @@ static QRectF alignedRect(Qt::LayoutDirection direction, Qt::Alignment alignment
+ void QQuickDialogButtonBoxPrivate::resizeContent()
+ {
+     Q_Q(QQuickDialogButtonBox);
+-    if (!contentItem)
++    if (!contentItem || !contentModel)
+         return;
+ 
+     QRectF geometry = q->boundingRect().adjusted(q->leftPadding(), q->topPadding(), -q->rightPadding(), -q->bottomPadding());
+@@ -322,6 +322,9 @@ void QQuickDialogButtonBoxPrivate::updateLayout()
+ qreal QQuickDialogButtonBoxPrivate::getContentWidth() const
+ {
+     Q_Q(const QQuickDialogButtonBox);
++    if (!contentModel)
++        return 0;
++
+     const int count = contentModel->count();
+     const qreal totalSpacing = qMax(0, count - 1) * spacing;
+     qreal totalWidth = totalSpacing;
+@@ -341,6 +344,9 @@ qreal QQuickDialogButtonBoxPrivate::getContentWidth() const
+ qreal QQuickDialogButtonBoxPrivate::getContentHeight() const
+ {
+     Q_Q(const QQuickDialogButtonBox);
++    if (!contentModel)
++        return 0;
++
+     const int count = contentModel->count();
+     qreal maxHeight = 0;
+     for (int i = 0; i < count; ++i) {
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp b/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
+index 91bd59184..0ce518f84 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
+@@ -399,8 +399,11 @@ void QQuickOverlay::itemChange(ItemChange change, const ItemChangeData &data)
+     Q_D(QQuickOverlay);
+     QQuickItem::itemChange(change, data);
+ 
+-    if (change == ItemChildAddedChange || change == ItemChildRemovedChange)
++    if (change == ItemChildAddedChange || change == ItemChildRemovedChange) {
+         setVisible(!d->allDrawers.isEmpty() || !childItems().isEmpty());
++        if (data.item->parent() == d->mouseGrabberPopup)
++            d->setMouseGrabberPopup(nullptr);
++    }
+ }
+ 
+ void QQuickOverlay::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp b/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
+index 4e2f509db..1c4b308cd 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
+@@ -797,6 +797,14 @@ void QQuickScrollBarAttachedPrivate::initHorizontal()
+     if (parent && parent == flickable->parentItem())
+         horizontal->stackAfter(flickable);
+ 
++    // If a scroll bar was previously hidden (due to e.g. setting a new contentItem
++    // on a ScrollView), we need to make sure that we un-hide it.
++    // We don't bother checking if the item is actually the old one, because
++    // if it's not, all of the things the function does (setting parent, visibility, etc.)
++    // should be no-ops anyway.
++    if (auto control = qobject_cast<QQuickControl*>(q_ptr->parent()))
++        QQuickControlPrivate::unhideOldItem(control, horizontal);
++
+     layoutHorizontal();
+     horizontal->setSize(area->property("widthRatio").toReal());
+     horizontal->setPosition(area->property("xPosition").toReal());
+@@ -818,6 +826,9 @@ void QQuickScrollBarAttachedPrivate::initVertical()
+     if (parent && parent == flickable->parentItem())
+         vertical->stackAfter(flickable);
+ 
++    if (auto control = qobject_cast<QQuickControl*>(q_ptr->parent()))
++        QQuickControlPrivate::unhideOldItem(control, vertical);
++
+     layoutVertical();
+     vertical->setSize(area->property("heightRatio").toReal());
+     vertical->setPosition(area->property("yPosition").toReal());
+diff --git a/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml b/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
+index 0e8b08352..cd4931184 100644
+--- a/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
++++ b/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
+@@ -576,4 +576,51 @@ TestCase {
+         verify(newHorizontalScrollBar.visible)
+         verify(!oldHorizontalScrollBar.visible)
+     }
++
++    Component {
++        id: bindingToContentItemAndStandaloneFlickable
++
++        Item {
++            width: 200
++            height: 200
++
++            property alias scrollView: scrollView
++
++            ScrollView {
++                id: scrollView
++                anchors.fill: parent
++                contentItem: listView
++
++                property Item someBinding: contentItem
++            }
++            ListView {
++                id: listView
++                model: 10
++                delegate: ItemDelegate {
++                    text: modelData
++                    width: listView.width
++                }
++            }
++        }
++    }
++
++    // Tests that scroll bars show up for a ScrollView where
++    // - its contentItem is declared as a standalone, separate item
++    // - there is a binding to contentItem (which causes a default Flickable to be created)
++    function test_bindingToContentItemAndStandaloneFlickable() {
++        let root = createTemporaryObject(bindingToContentItemAndStandaloneFlickable, testCase)
++        verify(root)
++
++        let control = root.scrollView
++        let verticalScrollBar = control.ScrollBar.vertical
++        let horizontalScrollBar = control.ScrollBar.horizontal
++        compare(verticalScrollBar.parent, control)
++        compare(horizontalScrollBar.parent, control)
++        verify(verticalScrollBar.visible)
++        verify(horizontalScrollBar.visible)
++
++        mouseDrag(verticalScrollBar, verticalScrollBar.width / 2, verticalScrollBar.height / 2, 0, 50)
++        verify(verticalScrollBar.active)
++        verify(horizontalScrollBar.active)
++    }
+ }
+diff --git a/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml b/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
+index b3fab41ca..10b6baa02 100644
+--- a/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
++++ b/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
+@@ -608,4 +608,27 @@ TestCase {
+         mouseClick(control.indicator)
+         verify(control.activeFocus)
+     }
++
++    Component {
++        id: deletionOrder1
++        Item {
++            Image { id: innerImage }
++            Switch { indicator: innerImage }
++        }
++    }
++
++    Component {
++        id: deletionOrder2
++        Item {
++            Switch { indicator: innerImage }
++            Image { id: innerImage }
++        }
++    }
++
++    function test_deletionOrder() {
++        var control1 = createTemporaryObject(deletionOrder1, testCase)
++        verify(control1)
++        var control2 = createTemporaryObject(deletionOrder2, testCase)
++        verify(control2)
++    }
+ }
+diff --git a/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml b/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml
+new file mode 100644
+index 000000000..9e4598b9f
+--- /dev/null
++++ b/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml
+@@ -0,0 +1,78 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the test suite of the Qt Toolkit.
++**
++** $QT_BEGIN_LICENSE:BSD$
++** Commercial License Usage
++** Licensees holding valid commercial Qt licenses may use this file in
++** accordance with the commercial license agreement provided with the
++** Software or, alternatively, in accordance with the terms contained in
++** a written agreement between you and The Qt Company. For licensing terms
++** and conditions see https://www.qt.io/terms-conditions. For further
++** information use the contact form at https://www.qt.io/contact-us.
++**
++** BSD License Usage
++** Alternatively, you may use this file under the terms of the BSD license
++** as follows:
++**
++** "Redistribution and use in source and binary forms, with or without
++** modification, are permitted provided that the following conditions are
++** met:
++**   * Redistributions of source code must retain the above copyright
++**     notice, this list of conditions and the following disclaimer.
++**   * Redistributions in binary form must reproduce the above copyright
++**     notice, this list of conditions and the following disclaimer in
++**     the documentation and/or other materials provided with the
++**     distribution.
++**   * Neither the name of The Qt Company Ltd nor the names of its
++**     contributors may be used to endorse or promote products derived
++**     from this software without specific prior written permission.
++**
++**
++** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
++** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
++** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
++** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
++** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
++** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
++** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
++** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
++** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
++** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
++** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
++**
++** $QT_END_LICENSE$
++**
++****************************************************************************/
++
++import QtQuick 2.15
++import QtQuick.Controls 2.15
++
++ApplicationWindow {
++    id: window
++    width: 400
++    height: 400
++    title: "releaseAfterExitTransition"
++
++    property alias popup: popup
++    property alias modalPopup: modalPopup
++
++    Popup {
++        id: popup
++        y: parent.height - height
++        width: 50
++        height: 50
++    }
++
++    Popup {
++        id: modalPopup
++        modal: true
++        y: parent.height - height
++        width: 50
++        height: 50
++        exit:  Transition { PauseAnimation { duration: 100 } }
++    }
++}
+diff --git a/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp b/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
+index 54952d128..3d50e2dd4 100644
+--- a/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
++++ b/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
+@@ -100,6 +100,7 @@ private slots:
+     void invisibleToolTipOpen();
+     void centerInOverlayWithinStackViewItem();
+     void destroyDuringExitTransition();
++    void releaseAfterExitTransition();
+ };
+ 
+ void tst_QQuickPopup::initTestCase()
+@@ -1575,6 +1576,34 @@ void tst_QQuickPopup::destroyDuringExitTransition()
+     QVERIFY(!button->isDown());
+ }
+ 
++void tst_QQuickPopup::releaseAfterExitTransition()
++{
++    QQuickApplicationHelper helper(this, "releaseAfterExitTransition.qml");
++    QVERIFY2(helper.ready, helper.failureMessage());
++
++    QQuickWindow *window = helper.window;
++    window->show();
++    QVERIFY(QTest::qWaitForWindowActive(window));
++
++    QQuickOverlay *overlay = QQuickOverlay::overlay(window);
++    QQuickPopup *modalPopup = window->property("modalPopup").value<QQuickPopup *>();
++    QQuickPopup *popup = window->property("popup").value<QQuickPopup *>();
++
++    modalPopup->open();
++    QTRY_VERIFY(modalPopup->isOpened());
++
++    QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++    // wait until the transition is finished and the overlay hides itself
++    QTRY_VERIFY(!overlay->isVisible());
++    QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++
++    popup->open();
++    QTRY_VERIFY(popup->isOpened());
++    QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++    QTRY_VERIFY(!popup->isOpened());
++}
++
++
+ QTEST_QUICKCONTROLS_MAIN(tst_QQuickPopup)
+ 
+ #include "tst_qquickpopup.moc"
+Submodule qtscript 5be95f96...4d8e4bd2 (commits not present)
+Submodule qtspeech 17fc9fde..255845e2:
+diff --git a/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp b/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
+index 6eb74b8..bcc7dd1 100644
+--- a/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
++++ b/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
+@@ -357,7 +357,9 @@ QVector<QLocale> QTextToSpeechEngineSpeechd::availableLocales() const
+ 
+ QVector<QVoice> QTextToSpeechEngineSpeechd::availableVoices() const
+ {
+-    return m_voices.values(m_currentLocale.name()).toVector();
++    QList<QVoice> resultList = m_voices.values(m_currentLocale.name());
++    std::reverse(resultList.begin(), resultList.end());
++    return resultList.toVector();
+ }
+ 
+ // We have no way of knowing our own client_id since speech-dispatcher seems to be incomplete
+Submodule qtsvg 0c05780e..a7a0f249:
+diff --git a/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp b/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
+index 561e77e..12e0574 100644
+--- a/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
++++ b/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
+@@ -191,6 +191,8 @@ bool QSvgIOHandler::read(QImage *image)
+             }
+         }
+         if (!finalSize.isEmpty()) {
++            if (qMax(finalSize.width(), finalSize.height()) > 0xffff)
++                return false; // Assume corrupted file
+             image->fill(d->backColor.rgba());
+             QPainter p(image);
+             d->r.render(&p, bounds);
+diff --git a/qtsvg/src/svg/qsvghandler.cpp b/qtsvg/src/svg/qsvghandler.cpp
+index a5f877f..8dda563 100644
+--- a/qtsvg/src/svg/qsvghandler.cpp
++++ b/qtsvg/src/svg/qsvghandler.cpp
+@@ -1393,9 +1393,10 @@ static void parseFont(QSvgNode *node,
+         case FontSizeNone:
+             break;
+         case FontSizeValue: {
+-            QSvgHandler::LengthType dummy; // should always be pixel size
+-            fontStyle->setSize(qMin(parseLength(attributes.fontSize, dummy, handler),
+-                                    qreal(0xffff)));
++            QSvgHandler::LengthType type;
++            qreal fs = parseLength(attributes.fontSize, type, handler);
++            fs = convertToPixels(fs, true, type);
++            fontStyle->setSize(qMin(fs, qreal(0xffff)));
+         }
+             break;
+         default:
+@@ -2513,6 +2514,8 @@ static bool parseAnimateTransformNode(QSvgNode *parent,
+             ++s;
+         }
+     }
++    if (vals.count() % 3 != 0)
++        return false;
+ 
+     bool ok = true;
+     int begin = parseClockValue(beginStr, &ok);
+@@ -2576,6 +2579,8 @@ static QSvgNode *createCircleNode(QSvgNode *parent,
+     qreal ncx = toDouble(cx);
+     qreal ncy = toDouble(cy);
+     qreal nr  = toDouble(r);
++    if (nr < 0.0)
++        return nullptr;
+ 
+     QRectF rect(ncx-nr, ncy-nr, nr*2, nr*2);
+     QSvgNode *circle = new QSvgCircle(parent, rect);
+@@ -3046,15 +3051,16 @@ static QSvgStyleProperty *createRadialGradientNode(QSvgNode *node,
+ 
+     qreal ncx = 0.5;
+     qreal ncy = 0.5;
+-    qreal nr  = 0.5;
+     if (!cx.isEmpty())
+         ncx = toDouble(cx);
+     if (!cy.isEmpty())
+         ncy = toDouble(cy);
++
++    qreal nr = 0.0;
+     if (!r.isEmpty())
+         nr = toDouble(r);
+-    if (nr < 0.5)
+-        nr = 0.5;
++    if (nr <= 0.0)
++        return nullptr;
+ 
+     qreal nfx = ncx;
+     if (!fx.isEmpty())
+@@ -3350,7 +3356,9 @@ static QSvgNode *createTextNode(QSvgNode *parent,
+     //### editable and rotate not handled
+     QSvgHandler::LengthType type;
+     qreal nx = parseLength(x, type, handler);
++    nx = convertToPixels(nx, true, type);
+     qreal ny = parseLength(y, type, handler);
++    ny = convertToPixels(ny, true, type);
+ 
+     QSvgNode *text = new QSvgText(parent, QPointF(nx, ny));
+     return text;
+@@ -3691,9 +3699,7 @@ void QSvgHandler::parse()
+         case QXmlStreamReader::EndElement:
+             endElement(xml->name());
+             ++remainingUnfinishedElements;
+-            // if we are using somebody else's qxmlstreamreader
+-            // we should not read until the end of the stream
+-            done = !m_ownsReader && (xml->name() == QLatin1String("svg"));
++            done = (xml->name() == QLatin1String("svg"));
+             break;
+         case QXmlStreamReader::Characters:
+             characters(xml->text());
+diff --git a/qtsvg/src/svg/qsvgstructure.cpp b/qtsvg/src/svg/qsvgstructure.cpp
+index b89608b..89c9e4e 100644
+--- a/qtsvg/src/svg/qsvgstructure.cpp
++++ b/qtsvg/src/svg/qsvgstructure.cpp
+@@ -255,9 +255,13 @@ inline static bool isSupportedSvgFeature(const QString &str)
+     };
+ 
+     if (str.length() <= MAX_WORD_LENGTH && str.length() >= MIN_WORD_LENGTH) {
++        const char16_t unicode44 = str.at(44).unicode();
++        const char16_t unicode45 = str.at(45).unicode();
++        if (unicode44 >= sizeof(asso_values) || unicode45 >= sizeof(asso_values))
++            return false;
+         const int key = str.length()
+-                        + asso_values[str.at(45).unicode()]
+-                        + asso_values[str.at(44).unicode()];
++                        + asso_values[unicode45]
++                        + asso_values[unicode44];
+         if (key <= MAX_HASH_VALUE && key >= 0)
+             return str == QLatin1String(wordlist[key]);
+     }
+diff --git a/qtsvg/src/svg/qsvgtinydocument.cpp b/qtsvg/src/svg/qsvgtinydocument.cpp
+index 63d0797..19e7154 100644
+--- a/qtsvg/src/svg/qsvgtinydocument.cpp
++++ b/qtsvg/src/svg/qsvgtinydocument.cpp
+@@ -433,8 +433,16 @@ void QSvgTinyDocument::draw(QPainter *p, QSvgExtraStates &)
+     draw(p);
+ }
+ 
++static bool isValidMatrix(const QTransform &transform)
++{
++    qreal determinant = transform.determinant();
++    return qIsFinite(determinant);
++}
++
+ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect, const QRectF &sourceRect)
+ {
++    QTransform oldTransform = p->worldTransform();
++
+     QRectF target = targetRect;
+     if (target.isEmpty()) {
+         QPaintDevice *dev = p->device();
+@@ -487,6 +495,9 @@ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect,
+         }
+ #endif
+     }
++
++    if (!isValidMatrix(p->worldTransform()))
++        p->setWorldTransform(oldTransform);
+ }
+ 
+ QRectF QSvgTinyDocument::boundsOnElement(const QString &id) const
+diff --git a/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp b/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
+index 36c76ec..db71e02 100644
+--- a/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
++++ b/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
+@@ -86,6 +86,8 @@ private slots:
+     void oss_fuzz_23731();
+     void oss_fuzz_24131();
+     void oss_fuzz_24738();
++    void illegalAnimateTransform_data();
++    void illegalAnimateTransform();
+ 
+ #ifndef QT_NO_COMPRESS
+     void testGzLoading();
+@@ -1646,5 +1648,22 @@ void tst_QSvgRenderer::oss_fuzz_24738()
+     QSvgRenderer().load(QByteArray("<svg><path d=\"a 2 1e-212.....\">"));
+ }
+ 
++void tst_QSvgRenderer::illegalAnimateTransform_data()
++{
++    QTest::addColumn<QByteArray>("svg");
++
++    QTest::newRow("case1") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" values=\"8,0,5,0\">");
++    QTest::newRow("case2") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" values=\"1,2\">");
++    QTest::newRow("case3") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" from=\".. 5 2\" to=\"f\">");
++    QTest::newRow("case4") << QByteArray("<svg><animateTransform type=\"scale\" begin=\"1\" dur=\"2\" by=\"--,..\">");
++}
++
++void tst_QSvgRenderer::illegalAnimateTransform()
++{
++    QFETCH(QByteArray, svg);
++    QSvgRenderer renderer;
++    QVERIFY(!renderer.load(svg)); // also shouldn't assert
++}
++
+ QTEST_MAIN(tst_QSvgRenderer)
+ #include "tst_qsvgrenderer.moc"
+Submodule qttools 6914f7c8..090e526e:
+diff --git a/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp b/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
+index feab1e2d5..cbfb82507 100644
+--- a/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
++++ b/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
+@@ -445,7 +445,9 @@ bool HelpGeneratorPrivate::insertFiles(const QStringList &files, const QString &
+     if (filterSetId < 0)
+         return false;
+     ++filterSetId;
+-    for (int attId : qAsConst(filterAtts)) {
++    QList<int> attValues = filterAtts.values();
++    std::sort(attValues.begin(), attValues.end());
++    for (int attId : qAsConst(attValues)) {
+         m_query->prepare(QLatin1String("INSERT INTO FileAttributeSetTable "
+             "VALUES(?, ?)"));
+         m_query->bindValue(0, filterSetId);
+Submodule qtwayland dfb0129c..2904e1b3:
+diff --git a/qtwayland/src/client/configure.json b/qtwayland/src/client/configure.json
+index 2f424580..29222357 100644
+--- a/qtwayland/src/client/configure.json
++++ b/qtwayland/src/client/configure.json
+@@ -149,8 +149,7 @@
+                     "#endif"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "vulkan-server-buffer": {
+             "label": "Vulkan Buffer Sharing",
+@@ -168,7 +167,8 @@
+                     "exportAllocInfo.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR;",
+                     "return 0;"
+                 ]
+-            }
++            },
++            "use": "wayland-client"
+         },
+         "egl_1_5-wayland": {
+             "label": "EGL 1.5 with Wayland Platform",
+@@ -183,7 +183,7 @@
+                     "eglGetPlatformDisplay(EGL_PLATFORM_WAYLAND_EXT, (struct wl_display *)(nullptr), nullptr);"
+                 ]
+             },
+-            "use": "egl"
++            "use": "egl wayland-client"
+         }
+     },
+ 
+diff --git a/qtwayland/src/client/global/qwaylandclientextension.cpp b/qtwayland/src/client/global/qwaylandclientextension.cpp
+index 125b1e19..edccfe63 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension.cpp
++++ b/qtwayland/src/client/global/qwaylandclientextension.cpp
+@@ -74,7 +74,10 @@ void QWaylandClientExtensionPrivate::handleRegistryGlobal(void *data, ::wl_regis
+ void QWaylandClientExtension::addRegistryListener()
+ {
+     Q_D(QWaylandClientExtension);
+-    d->waylandIntegration->display()->addRegistryListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++    if (!d->registered) {
++        d->waylandIntegration->display()->addRegistryListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++        d->registered = true;
++    }
+ }
+ 
+ QWaylandClientExtension::QWaylandClientExtension(const int ver)
+@@ -88,6 +91,13 @@ QWaylandClientExtension::QWaylandClientExtension(const int ver)
+     QMetaObject::invokeMethod(this, "addRegistryListener", Qt::QueuedConnection);
+ }
+ 
++QWaylandClientExtension::~QWaylandClientExtension()
++{
++    Q_D(QWaylandClientExtension);
++    if (d->registered && !QCoreApplication::closingDown())
++        d->waylandIntegration->display()->removeListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++}
++
+ QtWaylandClient::QWaylandIntegration *QWaylandClientExtension::integration() const
+ {
+     Q_D(const QWaylandClientExtension);
+diff --git a/qtwayland/src/client/global/qwaylandclientextension.h b/qtwayland/src/client/global/qwaylandclientextension.h
+index 98272e57..5bd28398 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension.h
++++ b/qtwayland/src/client/global/qwaylandclientextension.h
+@@ -63,6 +63,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandClientExtension : public QObject
+     Q_PROPERTY(bool active READ isActive NOTIFY activeChanged)
+ public:
+     QWaylandClientExtension(const int version);
++    ~QWaylandClientExtension();
+ 
+     QtWaylandClient::QWaylandIntegration *integration() const;
+     int version() const;
+diff --git a/qtwayland/src/client/global/qwaylandclientextension_p.h b/qtwayland/src/client/global/qwaylandclientextension_p.h
+index 69cc46a0..9091efbe 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension_p.h
++++ b/qtwayland/src/client/global/qwaylandclientextension_p.h
+@@ -68,6 +68,7 @@ public:
+     QtWaylandClient::QWaylandIntegration *waylandIntegration = nullptr;
+     int version = -1;
+     bool active = false;
++    bool registered = false;
+ };
+ 
+ class Q_WAYLAND_CLIENT_EXPORT QWaylandClientExtensionTemplatePrivate : public QWaylandClientExtensionPrivate
+diff --git a/qtwayland/src/client/qwaylanddatadevice.cpp b/qtwayland/src/client/qwaylanddatadevice.cpp
+index 7e2e3308..e3e60ed5 100644
+--- a/qtwayland/src/client/qwaylanddatadevice.cpp
++++ b/qtwayland/src/client/qwaylanddatadevice.cpp
+@@ -72,6 +72,8 @@ QWaylandDataDevice::QWaylandDataDevice(QWaylandDataDeviceManager *manager, QWayl
+ 
+ QWaylandDataDevice::~QWaylandDataDevice()
+ {
++    if (wl_data_device_get_version(object()) >= WL_DATA_DEVICE_RELEASE_SINCE_VERSION)
++        release();
+ }
+ 
+ QWaylandDataOffer *QWaylandDataDevice::selectionOffer() const
+@@ -110,7 +112,7 @@ QWaylandDataOffer *QWaylandDataDevice::dragOffer() const
+     return m_dragOffer.data();
+ }
+ 
+-bool QWaylandDataDevice::startDrag(QMimeData *mimeData, QWaylandWindow *icon)
++bool QWaylandDataDevice::startDrag(QMimeData *mimeData, Qt::DropActions supportedActions, QWaylandWindow *icon)
+ {
+     auto *seat = m_display->currentInputDevice();
+     auto *origin = seat->pointerFocus();
+@@ -123,7 +125,28 @@ bool QWaylandDataDevice::startDrag(QMimeData *mimeData, QWaylandWindow *icon)
+     }
+ 
+     m_dragSource.reset(new QWaylandDataSource(m_display->dndSelectionHandler(), mimeData));
++
++    if (wl_data_device_get_version(object()) >= 3)
++        m_dragSource->set_actions(dropActionsToWl(supportedActions));
++
+     connect(m_dragSource.data(), &QWaylandDataSource::cancelled, this, &QWaylandDataDevice::dragSourceCancelled);
++    connect(m_dragSource.data(), &QWaylandDataSource::dndResponseUpdated, this, [this](bool accepted, Qt::DropAction action) {
++            auto drag = static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag());
++            // in old versions drop action is not set, so we guess
++            if (wl_data_source_get_version(m_dragSource->object()) < 3) {
++                drag->setResponse(accepted);
++            } else {
++                QPlatformDropQtResponse response(accepted, action);
++                drag->setResponse(response);
++            }
++    });
++    connect(m_dragSource.data(), &QWaylandDataSource::dndDropped, this, [](bool accepted, Qt::DropAction action) {
++        QPlatformDropQtResponse response(accepted, action);
++        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setDropResponse(response);
++    });
++    connect(m_dragSource.data(), &QWaylandDataSource::finished, this, []() {
++        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag();
++    });
+ 
+     start_drag(m_dragSource->object(), origin->wlSurface(), icon->wlSurface(), m_display->currentInputDevice()->serial());
+     return true;
+@@ -152,7 +175,7 @@ void QWaylandDataDevice::data_device_drop()
+         supportedActions = drag->supportedActions();
+     } else if (m_dragOffer) {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     } else {
+         return;
+     }
+@@ -162,7 +185,11 @@ void QWaylandDataDevice::data_device_drop()
+                                                                           QGuiApplication::keyboardModifiers());
+ 
+     if (drag) {
+-        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag(response);
++        auto drag =  static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag());
++        drag->setDropResponse(response);
++        drag->finishDrag();
++    } else if (m_dragOffer) {
++        m_dragOffer->finish();
+     }
+ }
+ 
+@@ -186,7 +213,7 @@ void QWaylandDataDevice::data_device_enter(uint32_t serial, wl_surface *surface,
+         supportedActions = drag->supportedActions();
+     } else if (m_dragOffer) {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     }
+ 
+     const QPlatformDragQtResponse &response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
+@@ -197,11 +224,7 @@ void QWaylandDataDevice::data_device_enter(uint32_t serial, wl_surface *surface,
+         static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setResponse(response);
+     }
+ 
+-    if (response.isAccepted()) {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, m_dragOffer->firstFormat().toUtf8().constData());
+-    } else {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, nullptr);
+-    }
++    sendResponse(supportedActions, response);
+ }
+ 
+ void QWaylandDataDevice::data_device_leave()
+@@ -235,10 +258,10 @@ void QWaylandDataDevice::data_device_motion(uint32_t time, wl_fixed_t x, wl_fixe
+         supportedActions = drag->supportedActions();
+     } else {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     }
+ 
+-    QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
++    const QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
+                                                                           QGuiApplication::mouseButtons(),
+                                                                           QGuiApplication::keyboardModifiers());
+ 
+@@ -246,11 +269,7 @@ void QWaylandDataDevice::data_device_motion(uint32_t time, wl_fixed_t x, wl_fixe
+         static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setResponse(response);
+     }
+ 
+-    if (response.isAccepted()) {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, m_dragOffer->firstFormat().toUtf8().constData());
+-    } else {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, nullptr);
+-    }
++    sendResponse(supportedActions, response);
+ }
+ #endif // QT_CONFIG(draganddrop)
+ 
+@@ -277,14 +296,10 @@ void QWaylandDataDevice::selectionSourceCancelled()
+ #if QT_CONFIG(draganddrop)
+ void QWaylandDataDevice::dragSourceCancelled()
+ {
++    static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag();
+     m_dragSource.reset();
+ }
+ 
+-void QWaylandDataDevice::dragSourceTargetChanged(const QString &mimeType)
+-{
+-    static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->updateTarget(mimeType);
+-}
+-
+ QPoint QWaylandDataDevice::calculateDragPosition(int x, int y, QWindow *wnd) const
+ {
+     QPoint pnt(wl_fixed_to_int(x), wl_fixed_to_int(y));
+@@ -297,6 +312,33 @@ QPoint QWaylandDataDevice::calculateDragPosition(int x, int y, QWindow *wnd) con
+     }
+     return pnt;
+ }
++
++void QWaylandDataDevice::sendResponse(Qt::DropActions supportedActions, const QPlatformDragQtResponse &response)
++{
++    if (response.isAccepted()) {
++        if (wl_data_device_get_version(object()) >= 3)
++            m_dragOffer->set_actions(dropActionsToWl(supportedActions), dropActionsToWl(response.acceptedAction()));
++
++        m_dragOffer->accept(m_enterSerial, m_dragOffer->firstFormat());
++    } else {
++        m_dragOffer->accept(m_enterSerial, QString());
++    }
++}
++
++int QWaylandDataDevice::dropActionsToWl(Qt::DropActions actions)
++{
++
++    int wlActions = WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE;
++    if (actions & Qt::CopyAction)
++        wlActions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY;
++    if (actions & (Qt::MoveAction | Qt::TargetMoveAction))
++        wlActions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE;
++
++    // wayland does not support LinkAction at the time of writing
++    return wlActions;
++}
++
++
+ #endif // QT_CONFIG(draganddrop)
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddatadevice_p.h b/qtwayland/src/client/qwaylanddatadevice_p.h
+index 16c3ad28..801dcc2c 100644
+--- a/qtwayland/src/client/qwaylanddatadevice_p.h
++++ b/qtwayland/src/client/qwaylanddatadevice_p.h
+@@ -64,6 +64,7 @@ QT_REQUIRE_CONFIG(wayland_datadevice);
+ QT_BEGIN_NAMESPACE
+ 
+ class QMimeData;
++class QPlatformDragQtResponse;
+ class QWindow;
+ 
+ namespace QtWaylandClient {
+@@ -89,7 +90,7 @@ public:
+ 
+ #if QT_CONFIG(draganddrop)
+     QWaylandDataOffer *dragOffer() const;
+-    bool startDrag(QMimeData *mimeData, QWaylandWindow *icon);
++    bool startDrag(QMimeData *mimeData, Qt::DropActions supportedActions, QWaylandWindow *icon);
+     void cancelDrag();
+ #endif
+ 
+@@ -109,13 +110,16 @@ private Q_SLOTS:
+ 
+ #if QT_CONFIG(draganddrop)
+     void dragSourceCancelled();
+-    void dragSourceTargetChanged(const QString &mimeType);
+ #endif
+ 
+ private:
+ #if QT_CONFIG(draganddrop)
+     QPoint calculateDragPosition(int x, int y, QWindow *wnd) const;
+ #endif
++    void sendResponse(Qt::DropActions supportedActions, const QPlatformDragQtResponse &response);
++
++    static int dropActionsToWl(Qt::DropActions dropActions);
++
+ 
+     QWaylandDisplay *m_display = nullptr;
+     QWaylandInputDevice *m_inputDevice = nullptr;
+diff --git a/qtwayland/src/client/qwaylanddatadevicemanager.cpp b/qtwayland/src/client/qwaylanddatadevicemanager.cpp
+index 35d67307..6dc4f77f 100644
+--- a/qtwayland/src/client/qwaylanddatadevicemanager.cpp
++++ b/qtwayland/src/client/qwaylanddatadevicemanager.cpp
+@@ -50,8 +50,8 @@ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
+-QWaylandDataDeviceManager::QWaylandDataDeviceManager(QWaylandDisplay *display, uint32_t id)
+-    : wl_data_device_manager(display->wl_registry(), id, 1)
++QWaylandDataDeviceManager::QWaylandDataDeviceManager(QWaylandDisplay *display, int version, uint32_t id)
++    : wl_data_device_manager(display->wl_registry(), id, qMin(version, 3))
+     , m_display(display)
+ {
+     // Create transfer devices for all input devices.
+diff --git a/qtwayland/src/client/qwaylanddatadevicemanager_p.h b/qtwayland/src/client/qwaylanddatadevicemanager_p.h
+index bd05c0fb..510d9be4 100644
+--- a/qtwayland/src/client/qwaylanddatadevicemanager_p.h
++++ b/qtwayland/src/client/qwaylanddatadevicemanager_p.h
+@@ -68,7 +68,7 @@ class QWaylandInputDevice;
+ class Q_WAYLAND_CLIENT_EXPORT QWaylandDataDeviceManager : public QtWayland::wl_data_device_manager
+ {
+ public:
+-    QWaylandDataDeviceManager(QWaylandDisplay *display, uint32_t id);
++    QWaylandDataDeviceManager(QWaylandDisplay *display, int version, uint32_t id);
+     ~QWaylandDataDeviceManager() override;
+ 
+     QWaylandDataDevice *getDataDevice(QWaylandInputDevice *inputDevice);
+diff --git a/qtwayland/src/client/qwaylanddataoffer.cpp b/qtwayland/src/client/qwaylanddataoffer.cpp
+index 2297e8a1..fe0ea8c9 100644
+--- a/qtwayland/src/client/qwaylanddataoffer.cpp
++++ b/qtwayland/src/client/qwaylanddataoffer.cpp
+@@ -82,6 +82,15 @@ QMimeData *QWaylandDataOffer::mimeData()
+     return m_mimeData.data();
+ }
+ 
++Qt::DropActions QWaylandDataOffer::supportedActions() const
++{
++    if (wl_data_offer_get_version(const_cast<::wl_data_offer*>(object())) < 3) {
++        return Qt::MoveAction | Qt::CopyAction;
++    }
++
++    return m_supportedActions;
++}
++
+ void QWaylandDataOffer::startReceiving(const QString &mimeType, int fd)
+ {
+     receive(mimeType, fd);
+@@ -93,6 +102,22 @@ void QWaylandDataOffer::data_offer_offer(const QString &mime_type)
+     m_mimeData->appendFormat(mime_type);
+ }
+ 
++void QWaylandDataOffer::data_offer_action(uint32_t dnd_action)
++{
++    Q_UNUSED(dnd_action);
++    // This is the compositor telling the drag target what action it should perform
++    // It does not map nicely into Qt final drop semantics, other than pretending there is only one supported action?
++}
++
++void QWaylandDataOffer::data_offer_source_actions(uint32_t source_actions)
++{
++    m_supportedActions = Qt::DropActions();
++    if (source_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
++        m_supportedActions |= Qt::MoveAction;
++    if (source_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
++        m_supportedActions |= Qt::CopyAction;
++}
++
+ QWaylandMimeData::QWaylandMimeData(QWaylandAbstractDataOffer *dataOffer)
+     : m_dataOffer(dataOffer)
+ {
+@@ -163,17 +188,18 @@ QVariant QWaylandMimeData::retrieveData_sys(const QString &mimeType, QVariant::T
+ 
+ int QWaylandMimeData::readData(int fd, QByteArray &data) const
+ {
+-    fd_set readset;
+-    FD_ZERO(&readset);
+-    FD_SET(fd, &readset);
+-    struct timeval timeout;
++    struct pollfd readset;
++    readset.fd = fd;
++    readset.events = POLLIN;
++    struct timespec timeout;
+     timeout.tv_sec = 1;
+-    timeout.tv_usec = 0;
++    timeout.tv_nsec = 0;
++
+ 
+     Q_FOREVER {
+-        int ready = select(FD_SETSIZE, &readset, nullptr, nullptr, &timeout);
++        int ready = qt_safe_poll(&readset, 1, &timeout);
+         if (ready < 0) {
+-            qWarning() << "QWaylandDataOffer: select() failed";
++            qWarning() << "QWaylandDataOffer: qt_safe_poll() failed";
+             return -1;
+         } else if (ready == 0) {
+             qWarning("QWaylandDataOffer: timeout reading from pipe");
+diff --git a/qtwayland/src/client/qwaylanddataoffer_p.h b/qtwayland/src/client/qwaylanddataoffer_p.h
+index 9cf1483c..6f667398 100644
+--- a/qtwayland/src/client/qwaylanddataoffer_p.h
++++ b/qtwayland/src/client/qwaylanddataoffer_p.h
+@@ -82,6 +82,7 @@ public:
+     explicit QWaylandDataOffer(QWaylandDisplay *display, struct ::wl_data_offer *offer);
+     ~QWaylandDataOffer() override;
+     QMimeData *mimeData() override;
++    Qt::DropActions supportedActions() const;
+ 
+     QString firstFormat() const;
+ 
+@@ -89,10 +90,13 @@ public:
+ 
+ protected:
+     void data_offer_offer(const QString &mime_type) override;
++    void data_offer_source_actions(uint32_t source_actions) override;
++    void data_offer_action(uint32_t dnd_action) override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+     QScopedPointer<QWaylandMimeData> m_mimeData;
++    Qt::DropActions m_supportedActions;
+ };
+ 
+ 
+diff --git a/qtwayland/src/client/qwaylanddatasource.cpp b/qtwayland/src/client/qwaylanddatasource.cpp
+index f45122fb..5599cbd4 100644
+--- a/qtwayland/src/client/qwaylanddatasource.cpp
++++ b/qtwayland/src/client/qwaylanddatasource.cpp
+@@ -101,7 +101,32 @@ void QWaylandDataSource::data_source_send(const QString &mime_type, int32_t fd)
+ 
+ void QWaylandDataSource::data_source_target(const QString &mime_type)
+ {
+-    Q_EMIT targetChanged(mime_type);
++    m_accepted = !mime_type.isEmpty();
++    Q_EMIT dndResponseUpdated(m_accepted, m_dropAction);
++}
++
++void QWaylandDataSource::data_source_action(uint32_t action)
++{
++    Qt::DropAction qtAction = Qt::IgnoreAction;
++
++    if (action == WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
++        qtAction = Qt::MoveAction;
++    else if (action == WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
++        qtAction = Qt::CopyAction;
++
++    m_dropAction = qtAction;
++    Q_EMIT dndResponseUpdated(m_accepted, m_dropAction);
++}
++
++void QWaylandDataSource::data_source_dnd_finished()
++{
++    Q_EMIT finished();
++}
++
++void QWaylandDataSource::data_source_dnd_drop_performed()
++{
++
++    Q_EMIT dndDropped(m_accepted, m_dropAction);
+ }
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddatasource_p.h b/qtwayland/src/client/qwaylanddatasource_p.h
+index 25afff79..96f07bc3 100644
+--- a/qtwayland/src/client/qwaylanddatasource_p.h
++++ b/qtwayland/src/client/qwaylanddatasource_p.h
+@@ -77,17 +77,25 @@ public:
+     QMimeData *mimeData() const;
+ 
+ Q_SIGNALS:
+-    void targetChanged(const QString &mime_type);
+     void cancelled();
++    void finished();
++
++    void dndResponseUpdated(bool accepted, Qt::DropAction action);
++    void dndDropped(bool accepted, Qt::DropAction action);
+ 
+ protected:
+     void data_source_cancelled() override;
+     void data_source_send(const QString &mime_type, int32_t fd) override;
+     void data_source_target(const QString &mime_type) override;
++    void data_source_dnd_drop_performed() override;
++    void data_source_dnd_finished() override;
++    void data_source_action(uint32_t action) override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+     QMimeData *m_mime_data = nullptr;
++    bool m_accepted = false;
++    Qt::DropAction m_dropAction = Qt::IgnoreAction;
+ };
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddisplay.cpp b/qtwayland/src/client/qwaylanddisplay.cpp
+index f10c1f79..c01e238b 100644
+--- a/qtwayland/src/client/qwaylanddisplay.cpp
++++ b/qtwayland/src/client/qwaylanddisplay.cpp
+@@ -85,10 +85,203 @@
+ 
+ #include <errno.h>
+ 
++#include <tuple> // for std::tie
++
++static void checkWaylandError(struct wl_display *display)
++{
++    int ecode = wl_display_get_error(display);
++    if ((ecode == EPIPE || ecode == ECONNRESET)) {
++        // special case this to provide a nicer error
++        qWarning("The Wayland connection broke. Did the Wayland compositor die?");
++    } else {
++        qWarning("The Wayland connection experienced a fatal error: %s", strerror(ecode));
++    }
++    _exit(1);
++}
++
+ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
++class EventThread : public QThread
++{
++    Q_OBJECT
++public:
++    enum OperatingMode {
++        EmitToDispatch, // Emit the signal, allow dispatching in a differnt thread.
++        SelfDispatch, // Dispatch the events inside this thread.
++    };
++
++    EventThread(struct wl_display * wl, struct wl_event_queue * ev_queue,
++                OperatingMode mode)
++        : m_fd(wl_display_get_fd(wl))
++        , m_pipefd{ -1, -1 }
++        , m_wldisplay(wl)
++        , m_wlevqueue(ev_queue)
++        , m_mode(mode)
++        , m_reading(true)
++        , m_quitting(false)
++    {
++        setObjectName(QStringLiteral("WaylandEventThread"));
++    }
++
++    void readAndDispatchEvents()
++    {
++        /*
++         * Dispatch pending events and flush the requests at least once. If the event thread
++         * is not reading, try to call _prepare_read() to allow the event thread to poll().
++         * If that fails, re-try dispatch & flush again until _prepare_read() is successful.
++         *
++         * This allow any call to readAndDispatchEvents() to start event thread's polling,
++         * not only the one issued from event thread's waitForReading(), which means functions
++         * called from dispatch_pending() can safely spin an event loop.
++         */
++        for (;;) {
++            if (dispatchQueuePending() < 0) {
++                checkWaylandError(m_wldisplay);
++                return;
++            }
++
++            wl_display_flush(m_wldisplay);
++
++            // We have to check if event thread is reading every time we dispatch
++            // something, as that may recursively call this function.
++            if (m_reading.loadAcquire())
++                break;
++
++            if (prepareReadQueue() == 0) {
++                QMutexLocker l(&m_mutex);
++                m_reading.storeRelease(true);
++                m_cond.wakeOne();
++                break;
++            }
++        }
++    }
++
++    void stop()
++    {
++        // We have to both write to the pipe and set the flag, as the thread may be
++        // either in the poll() or waiting for _prepare_read().
++        if (m_pipefd[1] != -1 && write(m_pipefd[1], "\0", 1) == -1)
++            qWarning("Failed to write to the pipe: %s.", strerror(errno));
++
++        {
++            QMutexLocker l(&m_mutex);
++            m_quitting = true;
++            m_cond.wakeOne();
++        }
++
++        wait();
++    }
++
++Q_SIGNALS:
++    void needReadAndDispatch();
++
++protected:
++    void run() override
++    {
++        // we use this pipe to make the loop exit otherwise if we simply used a flag on the loop condition, if stop() gets
++        // called while poll() is blocking the thread will never quit since there are no wayland messages coming anymore.
++        struct Pipe
++        {
++            Pipe(int *fds)
++                : fds(fds)
++            {
++                if (qt_safe_pipe(fds) != 0)
++                    qWarning("Pipe creation failed. Quitting may hang.");
++            }
++            ~Pipe()
++            {
++                if (fds[0] != -1) {
++                    close(fds[0]);
++                    close(fds[1]);
++                }
++            }
++
++            int *fds;
++        } pipe(m_pipefd);
++
++        // Make the main thread call wl_prepare_read(), dispatch the pending messages and flush the
++        // outbound ones. Wait until it's done before proceeding, unless we're told to quit.
++        while (waitForReading()) {
++            pollfd fds[2] = { { m_fd, POLLIN, 0 }, { m_pipefd[0], POLLIN, 0 } };
++            poll(fds, 2, -1);
++
++            if (fds[1].revents & POLLIN) {
++                // we don't really care to read the byte that was written here since we're closing down
++                wl_display_cancel_read(m_wldisplay);
++                break;
++            }
++
++            if (fds[0].revents & POLLIN)
++                wl_display_read_events(m_wldisplay);
++                // The polll was succesfull and the event thread did the wl_display_read_events(). On the next iteration of the loop
++                // the event sent to the main thread will cause it to dispatch the messages just read, unless the loop exits in which
++                // case we don't care anymore about them.
++            else
++                wl_display_cancel_read(m_wldisplay);
++        }
++    }
++
++private:
++    bool waitForReading()
++    {
++        Q_ASSERT(QThread::currentThread() == this);
++
++        m_reading.storeRelease(false);
++
++        if (m_mode == SelfDispatch) {
++            readAndDispatchEvents();
++        } else {
++            Q_EMIT needReadAndDispatch();
++
++            QMutexLocker lock(&m_mutex);
++            // m_reading might be set from our emit or some other invocation of
++            // readAndDispatchEvents().
++            while (!m_reading.loadRelaxed() && !m_quitting)
++                m_cond.wait(&m_mutex);
++        }
++
++        return !m_quitting;
++    }
++
++    int dispatchQueuePending()
++    {
++        if (m_wlevqueue)
++            return wl_display_dispatch_queue_pending(m_wldisplay, m_wlevqueue);
++        else
++            return wl_display_dispatch_pending(m_wldisplay);
++    }
++
++    int prepareReadQueue()
++    {
++        if (m_wlevqueue)
++            return wl_display_prepare_read_queue(m_wldisplay, m_wlevqueue);
++        else
++            return wl_display_prepare_read(m_wldisplay);
++    }
++
++    int m_fd;
++    int m_pipefd[2];
++    wl_display *m_wldisplay;
++    wl_event_queue *m_wlevqueue;
++    OperatingMode m_mode;
++
++    /* Concurrency note when operating in EmitToDispatch mode:
++     * m_reading is set to false inside event thread's waitForReading(), and is
++     * set to true inside main thread's readAndDispatchEvents().
++     * The lock is not taken when setting m_reading to false, as the main thread
++     * is not actively waiting for it to turn false. However, the lock is taken
++     * inside readAndDispatchEvents() before setting m_reading to true,
++     * as the event thread is actively waiting for it under the wait condition.
++     */
++
++    QAtomicInteger<bool> m_reading;
++    bool m_quitting;
++    QMutex m_mutex;
++    QWaitCondition m_cond;
++};
++
+ Q_LOGGING_CATEGORY(lcQpaWayland, "qt.qpa.wayland"); // for general (uncategorized) Wayland platform logging
+ 
+ struct wl_surface *QWaylandDisplay::createSurface(void *handle)
+@@ -158,17 +351,16 @@ QWaylandDisplay::QWaylandDisplay(QWaylandIntegration *waylandIntegration)
+     if (!mXkbContext)
+         qCWarning(lcQpaWayland, "failed to create xkb context");
+ #endif
+-
+-    forceRoundTrip();
+-
+-    if (!mWaitingScreens.isEmpty()) {
+-        // Give wl_output.done and zxdg_output_v1.done events a chance to arrive
+-        forceRoundTrip();
+-    }
+ }
+ 
+ QWaylandDisplay::~QWaylandDisplay(void)
+ {
++    if (m_eventThread)
++        m_eventThread->stop();
++
++    if (m_frameEventQueueThread)
++        m_frameEventQueueThread->stop();
++
+     if (mSyncCallback)
+         wl_callback_destroy(mSyncCallback);
+ 
+@@ -187,6 +379,21 @@ QWaylandDisplay::~QWaylandDisplay(void)
+ #endif
+     if (mDisplay)
+         wl_display_disconnect(mDisplay);
++
++    if (m_frameEventQueue)
++        wl_event_queue_destroy(m_frameEventQueue);
++}
++
++// Steps which is called just after constructor. This separates registry_global() out of the constructor
++// so that factory functions in integration can be overridden.
++void QWaylandDisplay::initialize()
++{
++    forceRoundTrip();
++
++    if (!mWaitingScreens.isEmpty()) {
++        // Give wl_output.done and zxdg_output_v1.done events a chance to arrive
++        forceRoundTrip();
++    }
+ }
+ 
+ void QWaylandDisplay::ensureScreen()
+@@ -203,98 +410,37 @@ void QWaylandDisplay::ensureScreen()
+ 
+ void QWaylandDisplay::checkError() const
+ {
+-    int ecode = wl_display_get_error(mDisplay);
+-    if ((ecode == EPIPE || ecode == ECONNRESET)) {
+-        // special case this to provide a nicer error
+-        qWarning("The Wayland connection broke. Did the Wayland compositor die?");
+-    } else {
+-        qWarning("The Wayland connection experienced a fatal error: %s", strerror(ecode));
+-    }
+-    _exit(1);
++    checkWaylandError(mDisplay);
+ }
+ 
++// Called in main thread, either from queued signal or directly.
+ void QWaylandDisplay::flushRequests()
+ {
+-    if (wl_display_prepare_read(mDisplay) == 0) {
+-        wl_display_read_events(mDisplay);
+-    }
+-
+-    if (wl_display_dispatch_pending(mDisplay) < 0)
+-        checkError();
+-
+-    {
+-        QReadLocker locker(&m_frameQueueLock);
+-        for (const FrameQueue &q : mExternalQueues) {
+-            QMutexLocker locker(q.mutex);
+-            while (wl_display_prepare_read_queue(mDisplay, q.queue) != 0)
+-                wl_display_dispatch_queue_pending(mDisplay, q.queue);
+-            wl_display_read_events(mDisplay);
+-            wl_display_dispatch_queue_pending(mDisplay, q.queue);
+-        }
+-    }
+-
+-    wl_display_flush(mDisplay);
+-}
+-
+-void QWaylandDisplay::blockingReadEvents()
+-{
+-    if (wl_display_dispatch(mDisplay) < 0)
+-        checkError();
+-}
+-
+-void QWaylandDisplay::destroyFrameQueue(const QWaylandDisplay::FrameQueue &q)
+-{
+-    QWriteLocker locker(&m_frameQueueLock);
+-    auto it = std::find_if(mExternalQueues.begin(),
+-                           mExternalQueues.end(),
+-                           [&q] (const QWaylandDisplay::FrameQueue &other){ return other.queue == q.queue; });
+-    Q_ASSERT(it != mExternalQueues.end());
+-    mExternalQueues.erase(it);
+-    if (q.queue != nullptr)
+-        wl_event_queue_destroy(q.queue);
+-    delete q.mutex;
++    m_eventThread->readAndDispatchEvents();
+ }
+ 
+-QWaylandDisplay::FrameQueue QWaylandDisplay::createFrameQueue()
++// We have to wait until we have an eventDispatcher before creating the eventThread,
++// otherwise forceRoundTrip() may block inside _events_read() because eventThread is
++// polling.
++void QWaylandDisplay::initEventThread()
+ {
+-    QWriteLocker locker(&m_frameQueueLock);
+-    FrameQueue q{createEventQueue()};
+-    mExternalQueues.append(q);
+-    return q;
+-}
++    m_eventThread.reset(
++            new EventThread(mDisplay, /* default queue */ nullptr, EventThread::EmitToDispatch));
++    connect(m_eventThread.get(), &EventThread::needReadAndDispatch, this,
++            &QWaylandDisplay::flushRequests, Qt::QueuedConnection);
++    m_eventThread->start();
+ 
+-wl_event_queue *QWaylandDisplay::createEventQueue()
+-{
+-    return wl_display_create_queue(mDisplay);
++    // wl_display_disconnect() free this.
++    m_frameEventQueue = wl_display_create_queue(mDisplay);
++    m_frameEventQueueThread.reset(
++            new EventThread(mDisplay, m_frameEventQueue, EventThread::SelfDispatch));
++    m_frameEventQueueThread->start();
+ }
+ 
+-void QWaylandDisplay::dispatchQueueWhile(wl_event_queue *queue, std::function<bool ()> condition, int timeout)
++void QWaylandDisplay::blockingReadEvents()
+ {
+-    if (!condition())
+-        return;
+-
+-    QElapsedTimer timer;
+-    timer.start();
+-    struct pollfd pFd = qt_make_pollfd(wl_display_get_fd(mDisplay), POLLIN);
+-    while (timeout == -1 || timer.elapsed() < timeout) {
+-        while (wl_display_prepare_read_queue(mDisplay, queue) != 0)
+-            wl_display_dispatch_queue_pending(mDisplay, queue);
+-
+-        wl_display_flush(mDisplay);
+-
+-        const int remaining = qMax(timeout - timer.elapsed(), 0ll);
+-        const int pollTimeout = timeout == -1 ? -1 : remaining;
+-        if (qt_poll_msecs(&pFd, 1, pollTimeout) > 0)
+-            wl_display_read_events(mDisplay);
+-        else
+-            wl_display_cancel_read(mDisplay);
+-
+-        if (wl_display_dispatch_queue_pending(mDisplay, queue) < 0)
+-            checkError();
+-
+-        if (!condition())
+-            break;
+-    }
++    if (wl_display_dispatch(mDisplay) < 0)
++        checkWaylandError(mDisplay);
+ }
+ 
+ QWaylandScreen *QWaylandDisplay::screenForOutput(struct wl_output *output) const
+@@ -345,7 +491,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+     if (interface == QStringLiteral("wl_output")) {
+         mWaitingScreens << new QWaylandScreen(this, version, id);
+     } else if (interface == QStringLiteral("wl_compositor")) {
+-        mCompositorVersion = qMin((int)version, 3);
++        mCompositorVersion = qMin((int)version, 4);
+         mCompositor.init(registry, id, mCompositorVersion);
+     } else if (interface == QStringLiteral("wl_shm")) {
+         mShm.reset(new QWaylandShm(this, version, id));
+@@ -354,7 +500,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+         mInputDevices.append(inputDevice);
+ #if QT_CONFIG(wayland_datadevice)
+     } else if (interface == QStringLiteral("wl_data_device_manager")) {
+-        mDndSelectionHandler.reset(new QWaylandDataDeviceManager(this, id));
++        mDndSelectionHandler.reset(new QWaylandDataDeviceManager(this, version, id));
+ #endif
+     } else if (interface == QStringLiteral("qt_surface_extension")) {
+         mWindowExtension.reset(new QtWayland::qt_surface_extension(registry, id, 1));
+@@ -369,6 +515,8 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+ #if QT_CONFIG(wayland_client_primary_selection)
+     } else if (interface == QStringLiteral("zwp_primary_selection_device_manager_v1")) {
+         mPrimarySelectionManager.reset(new QWaylandPrimarySelectionDeviceManagerV1(this, id, 1));
++        for (QWaylandInputDevice *inputDevice : qAsConst(mInputDevices))
++            inputDevice->setPrimarySelectionDevice(mPrimarySelectionManager->createDevice(inputDevice));
+ #endif
+     } else if (interface == QStringLiteral("zwp_text_input_manager_v2") && !mClientSideInputContextRequested) {
+         mTextInputManager.reset(new QtWayland::zwp_text_input_manager_v2(registry, id, 1));
+@@ -427,6 +575,13 @@ void QWaylandDisplay::registry_global_remove(uint32_t id)
+                     inputDevice->setTextInput(nullptr);
+                 mWaylandIntegration->reconfigureInputContext();
+             }
++#if QT_CONFIG(wayland_client_primary_selection)
++            if (global.interface == QStringLiteral("zwp_primary_selection_device_manager_v1")) {
++                mPrimarySelectionManager.reset();
++                for (QWaylandInputDevice *inputDevice : qAsConst(mInputDevices))
++                    inputDevice->setPrimarySelectionDevice(nullptr);
++            }
++#endif
+             mGlobals.removeAt(i);
+             break;
+         }
+@@ -452,9 +607,10 @@ void QWaylandDisplay::addRegistryListener(RegistryListener listener, void *data)
+ 
+ void QWaylandDisplay::removeListener(RegistryListener listener, void *data)
+ {
+-    std::remove_if(mRegistryListeners.begin(), mRegistryListeners.end(), [=](Listener l){
++    auto iter = std::remove_if(mRegistryListeners.begin(), mRegistryListeners.end(), [=](Listener l){
+         return (l.listener == listener && l.data == data);
+     });
++    mRegistryListeners.erase(iter, mRegistryListeners.end());
+ }
+ 
+ uint32_t QWaylandDisplay::currentTimeMillisec()
+@@ -467,50 +623,9 @@ uint32_t QWaylandDisplay::currentTimeMillisec()
+     return 0;
+ }
+ 
+-static void
+-sync_callback(void *data, struct wl_callback *callback, uint32_t serial)
+-{
+-    Q_UNUSED(serial)
+-    bool *done = static_cast<bool *>(data);
+-
+-    *done = true;
+-
+-    // If the wl_callback done event is received after the condition check in the while loop in
+-    // forceRoundTrip(), but before the call to processEvents, the call to processEvents may block
+-    // forever if no more events are posted (eventhough the callback is handled in response to the
+-    // aboutToBlock signal). Hence, we wake up the event dispatcher so forceRoundTrip may return.
+-    // (QTBUG-64696)
+-    if (auto *dispatcher = QThread::currentThread()->eventDispatcher())
+-        dispatcher->wakeUp();
+-
+-    wl_callback_destroy(callback);
+-}
+-
+-static const struct wl_callback_listener sync_listener = {
+-    sync_callback
+-};
+-
+ void QWaylandDisplay::forceRoundTrip()
+ {
+-    // wl_display_roundtrip() works on the main queue only,
+-    // but we use a separate one, so basically reimplement it here
+-    int ret = 0;
+-    bool done = false;
+-    wl_callback *callback = wl_display_sync(mDisplay);
+-    wl_callback_add_listener(callback, &sync_listener, &done);
+-    flushRequests();
+-    if (QThread::currentThread()->eventDispatcher()) {
+-        while (!done && ret >= 0) {
+-            QThread::currentThread()->eventDispatcher()->processEvents(QEventLoop::WaitForMoreEvents);
+-            ret = wl_display_dispatch_pending(mDisplay);
+-        }
+-    } else {
+-        while (!done && ret >= 0)
+-            ret = wl_display_dispatch(mDisplay);
+-    }
+-
+-    if (ret == -1 && !done)
+-        wl_callback_destroy(callback);
++     wl_display_roundtrip(mDisplay);
+ }
+ 
+ bool QWaylandDisplay::supportsWindowDecoration() const
+@@ -574,14 +689,10 @@ void QWaylandDisplay::handleKeyboardFocusChanged(QWaylandInputDevice *inputDevic
+     if (mLastKeyboardFocus == keyboardFocus)
+         return;
+ 
+-    if (mWaylandIntegration->mShellIntegration) {
+-        mWaylandIntegration->mShellIntegration->handleKeyboardFocusChanged(keyboardFocus, mLastKeyboardFocus);
+-    } else {
+-        if (keyboardFocus)
+-            handleWindowActivated(keyboardFocus);
+-        if (mLastKeyboardFocus)
+-            handleWindowDeactivated(mLastKeyboardFocus);
+-    }
++    if (keyboardFocus)
++        handleWindowActivated(keyboardFocus);
++    if (mLastKeyboardFocus)
++        handleWindowDeactivated(mLastKeyboardFocus);
+ 
+     mLastKeyboardFocus = keyboardFocus;
+ }
+@@ -600,6 +711,19 @@ void QWaylandDisplay::handleWaylandSync()
+     QWindow *activeWindow = mActiveWindows.empty() ? nullptr : mActiveWindows.last()->window();
+     if (activeWindow != QGuiApplication::focusWindow())
+         QWindowSystemInterface::handleWindowActivated(activeWindow);
++
++    if (!activeWindow) {
++        if (lastInputDevice()) {
++#if QT_CONFIG(clipboard)
++            if (auto *dataDevice = lastInputDevice()->dataDevice())
++                dataDevice->invalidateSelectionOffer();
++#endif
++#if QT_CONFIG(wayland_client_primary_selection)
++            if (auto *device = lastInputDevice()->primarySelectionDevice())
++                device->invalidateSelectionOffer();
++#endif
++        }
++    }
+ }
+ 
+ const wl_callback_listener QWaylandDisplay::syncCallbackListener = {
+@@ -626,6 +750,13 @@ QWaylandInputDevice *QWaylandDisplay::defaultInputDevice() const
+     return mInputDevices.isEmpty() ? 0 : mInputDevices.first();
+ }
+ 
++bool QWaylandDisplay::isKeyboardAvailable() const
++{
++    return std::any_of(
++            mInputDevices.constBegin(), mInputDevices.constEnd(),
++            [this](const QWaylandInputDevice *device) { return device->keyboard() != nullptr; });
++}
++
+ #if QT_CONFIG(cursor)
+ 
+ QWaylandCursor *QWaylandDisplay::waylandCursor()
+@@ -652,4 +783,6 @@ QWaylandCursorTheme *QWaylandDisplay::loadCursorTheme(const QString &name, int p
+ 
+ } // namespace QtWaylandClient
+ 
++#include "qwaylanddisplay.moc"
++
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/client/qwaylanddisplay_p.h b/qtwayland/src/client/qwaylanddisplay_p.h
+index 3b092bc8..42bc661d 100644
+--- a/qtwayland/src/client/qwaylanddisplay_p.h
++++ b/qtwayland/src/client/qwaylanddisplay_p.h
+@@ -109,6 +109,7 @@ class QWaylandSurface;
+ class QWaylandShellIntegration;
+ class QWaylandCursor;
+ class QWaylandCursorTheme;
++class EventThread;
+ 
+ typedef void (*RegistryListener)(void *data,
+                                  struct wl_registry *registry,
+@@ -120,15 +121,11 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandDisplay : public QObject, public QtWayland
+     Q_OBJECT
+ 
+ public:
+-    struct FrameQueue {
+-        FrameQueue(wl_event_queue *q = nullptr) : queue(q), mutex(new QMutex) {}
+-        wl_event_queue *queue;
+-        QMutex *mutex;
+-    };
+-
+     QWaylandDisplay(QWaylandIntegration *waylandIntegration);
+     ~QWaylandDisplay(void) override;
+ 
++    void initialize();
++
+ #if QT_CONFIG(xkbcommon)
+     struct xkb_context *xkbContext() const { return mXkbContext.get(); }
+ #endif
+@@ -210,11 +207,11 @@ public:
+     void handleKeyboardFocusChanged(QWaylandInputDevice *inputDevice);
+     void handleWindowDestroyed(QWaylandWindow *window);
+ 
+-    wl_event_queue *createEventQueue();
+-    FrameQueue createFrameQueue();
+-    void destroyFrameQueue(const FrameQueue &q);
+-    void dispatchQueueWhile(wl_event_queue *queue, std::function<bool()> condition, int timeout = -1);
++    wl_event_queue *frameEventQueue() { return m_frameEventQueue; };
++
++    bool isKeyboardAvailable() const;
+ 
++    void initEventThread();
+ public slots:
+     void blockingReadEvents();
+     void flushRequests();
+@@ -237,6 +234,9 @@ private:
+     };
+ 
+     struct wl_display *mDisplay = nullptr;
++    QScopedPointer<EventThread> m_eventThread;
++    wl_event_queue *m_frameEventQueue = nullptr;
++    QScopedPointer<EventThread> m_frameEventQueueThread;
+     QtWayland::wl_compositor mCompositor;
+     QScopedPointer<QWaylandShm> mShm;
+     QList<QWaylandScreen *> mWaitingScreens;
+@@ -273,11 +273,9 @@ private:
+     QWaylandInputDevice *mLastInputDevice = nullptr;
+     QPointer<QWaylandWindow> mLastInputWindow;
+     QPointer<QWaylandWindow> mLastKeyboardFocus;
+-    QVector<QWaylandWindow *> mActiveWindows;
+-    QVector<FrameQueue> mExternalQueues;
++    QList<QWaylandWindow *> mActiveWindows;
+     struct wl_callback *mSyncCallback = nullptr;
+     static const wl_callback_listener syncCallbackListener;
+-    QReadWriteLock m_frameQueueLock;
+ 
+     bool mClientSideInputContextRequested = !QPlatformInputContextFactory::requested().isNull();
+ 
+diff --git a/qtwayland/src/client/qwaylanddnd.cpp b/qtwayland/src/client/qwaylanddnd.cpp
+index 6535aa16..7c53f5fa 100644
+--- a/qtwayland/src/client/qwaylanddnd.cpp
++++ b/qtwayland/src/client/qwaylanddnd.cpp
+@@ -66,7 +66,7 @@ void QWaylandDrag::startDrag()
+ {
+     QBasicDrag::startDrag();
+     QWaylandWindow *icon = static_cast<QWaylandWindow *>(shapedPixmapWindow()->handle());
+-    if (m_display->currentInputDevice()->dataDevice()->startDrag(drag()->mimeData(), icon)) {
++    if (m_display->currentInputDevice()->dataDevice()->startDrag(drag()->mimeData(), drag()->supportedActions(), icon)) {
+         icon->addAttachOffset(-drag()->hotSpot());
+     } else {
+         // Cancelling immediately does not work, since the event loop for QDrag::exec is started
+@@ -80,6 +80,9 @@ void QWaylandDrag::cancel()
+     QBasicDrag::cancel();
+ 
+     m_display->currentInputDevice()->dataDevice()->cancelDrag();
++
++    if (drag())
++        drag()->deleteLater();
+ }
+ 
+ void QWaylandDrag::move(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods)
+@@ -103,33 +106,41 @@ void QWaylandDrag::endDrag()
+     m_display->currentInputDevice()->handleEndDrag();
+ }
+ 
+-void QWaylandDrag::updateTarget(const QString &mimeType)
++void QWaylandDrag::setResponse(bool accepted)
+ {
+-    setCanDrop(!mimeType.isEmpty());
+-
+-    if (canDrop()) {
+-        updateCursor(defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers()));
+-    } else {
+-        updateCursor(Qt::IgnoreAction);
+-    }
++    // This method is used for old DataDevices where the drag action is not communicated
++    Qt::DropAction action = defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers());
++    setResponse(QPlatformDropQtResponse(accepted, action));
+ }
+ 
+-void QWaylandDrag::setResponse(const QPlatformDragQtResponse &response)
++void QWaylandDrag::setResponse(const QPlatformDropQtResponse &response)
+ {
+     setCanDrop(response.isAccepted());
+ 
+     if (canDrop()) {
+-        updateCursor(defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers()));
++        updateCursor(response.acceptedAction());
+     } else {
+         updateCursor(Qt::IgnoreAction);
+     }
+ }
+ 
+-void QWaylandDrag::finishDrag(const QPlatformDropQtResponse &response)
++void QWaylandDrag::setDropResponse(const QPlatformDropQtResponse &response)
+ {
+     setExecutedDropAction(response.acceptedAction());
++}
++
++void QWaylandDrag::finishDrag()
++{
+     QKeyEvent event(QEvent::KeyPress, Qt::Key_Escape, Qt::NoModifier);
+     eventFilter(shapedPixmapWindow(), &event);
++
++    if (drag())
++        drag()->deleteLater();
++}
++
++bool QWaylandDrag::ownsDragObject() const
++{
++    return true;
+ }
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddnd_p.h b/qtwayland/src/client/qwaylanddnd_p.h
+index 474fe2ab..46f629ac 100644
+--- a/qtwayland/src/client/qwaylanddnd_p.h
++++ b/qtwayland/src/client/qwaylanddnd_p.h
+@@ -71,9 +71,10 @@ public:
+     QWaylandDrag(QWaylandDisplay *display);
+     ~QWaylandDrag() override;
+ 
+-    void updateTarget(const QString &mimeType);
+-    void setResponse(const QPlatformDragQtResponse &response);
+-    void finishDrag(const QPlatformDropQtResponse &response);
++    void setResponse(bool accepted);
++    void setResponse(const QPlatformDropQtResponse &response);
++    void setDropResponse(const QPlatformDropQtResponse &response);
++    void finishDrag();
+ 
+ protected:
+     void startDrag() override;
+@@ -82,6 +83,7 @@ protected:
+     void drop(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods) override;
+     void endDrag() override;
+ 
++    bool ownsDragObject() const override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+diff --git a/qtwayland/src/client/qwaylandinputdevice.cpp b/qtwayland/src/client/qwaylandinputdevice.cpp
+index 613fe862..4b90de84 100644
+--- a/qtwayland/src/client/qwaylandinputdevice.cpp
++++ b/qtwayland/src/client/qwaylandinputdevice.cpp
+@@ -685,6 +685,11 @@ public:
+ 
+ void QWaylandInputDevice::Pointer::pointer_leave(uint32_t time, struct wl_surface *surface)
+ {
++    invalidateFocus();
++    mButtons = Qt::NoButton;
++
++    mParent->mTime = time;
++
+     // The event may arrive after destroying the window, indicated by
+     // a null surface.
+     if (!surface)
+@@ -696,11 +701,6 @@ void QWaylandInputDevice::Pointer::pointer_leave(uint32_t time, struct wl_surfac
+ 
+     if (!QWaylandWindow::mouseGrab())
+         setFrameEvent(new LeaveEvent(window, mSurfacePos, mGlobalPos));
+-
+-    invalidateFocus();
+-    mButtons = Qt::NoButton;
+-
+-    mParent->mTime = time;
+ }
+ 
+ class MotionEvent : public QWaylandPointerEvent
+@@ -1300,14 +1300,6 @@ void QWaylandInputDevice::Keyboard::handleFocusDestroyed()
+ void QWaylandInputDevice::Keyboard::handleFocusLost()
+ {
+     mFocus = nullptr;
+-#if QT_CONFIG(clipboard)
+-    if (auto *dataDevice = mParent->dataDevice())
+-        dataDevice->invalidateSelectionOffer();
+-#endif
+-#if QT_CONFIG(wayland_client_primary_selection)
+-    if (auto *device = mParent->primarySelectionDevice())
+-        device->invalidateSelectionOffer();
+-#endif
+     mParent->mQDisplay->handleKeyboardFocusChanged(mParent);
+     mRepeatTimer.stop();
+ }
+@@ -1396,6 +1388,7 @@ void QWaylandInputDevice::Touch::touch_cancel()
+     if (touchExt)
+         touchExt->touchCanceled();
+ 
++    mFocus = nullptr;
+     QWindowSystemInterface::handleTouchCancelEvent(nullptr, mParent->mTouchDevice);
+ }
+ 
+diff --git a/qtwayland/src/client/qwaylandintegration.cpp b/qtwayland/src/client/qwaylandintegration.cpp
+index c53ccb78..54861600 100644
+--- a/qtwayland/src/client/qwaylandintegration.cpp
++++ b/qtwayland/src/client/qwaylandintegration.cpp
+@@ -125,6 +125,9 @@ QWaylandIntegration::QWaylandIntegration()
+ #endif
+ 
+     reconfigureInputContext();
++
++    QWaylandWindow::fixedToplevelPositions =
++            !qEnvironmentVariableIsSet("QT_WAYLAND_DISABLE_FIXED_POSITIONS");
+ }
+ 
+ QWaylandIntegration::~QWaylandIntegration()
+@@ -192,14 +195,18 @@ QAbstractEventDispatcher *QWaylandIntegration::createEventDispatcher() const
+ 
+ void QWaylandIntegration::initialize()
+ {
++    mDisplay->initEventThread();
++
++    // Call after eventDispatcher is fully connected, for QWaylandDisplay::forceRoundTrip()
++    mDisplay->initialize();
++
++    // But the aboutToBlock() and awake() should be connected after initializePlatform().
++    // Otherwise the connected flushRequests() may consumes up all events before processEvents starts to wait,
++    // so that processEvents(QEventLoop::WaitForMoreEvents) may be blocked in the forceRoundTrip().
+     QAbstractEventDispatcher *dispatcher = QGuiApplicationPrivate::eventDispatcher;
+     QObject::connect(dispatcher, SIGNAL(aboutToBlock()), mDisplay.data(), SLOT(flushRequests()));
+     QObject::connect(dispatcher, SIGNAL(awake()), mDisplay.data(), SLOT(flushRequests()));
+ 
+-    int fd = wl_display_get_fd(mDisplay->wl_display());
+-    QSocketNotifier *sn = new QSocketNotifier(fd, QSocketNotifier::Read, mDisplay.data());
+-    QObject::connect(sn, SIGNAL(activated(QSocketDescriptor)), mDisplay.data(), SLOT(flushRequests()));
+-
+     // Qt does not support running with no screens
+     mDisplay->ensureScreen();
+ }
+@@ -262,6 +269,14 @@ QWaylandDisplay *QWaylandIntegration::display() const
+     return mDisplay.data();
+ }
+ 
++Qt::KeyboardModifiers QWaylandIntegration::queryKeyboardModifiers() const
++{
++    if (auto *seat = mDisplay->currentInputDevice()) {
++        return seat->modifiers();
++    }
++    return Qt::NoModifier;
++}
++
+ QList<int> QWaylandIntegration::possibleKeys(const QKeyEvent *event) const
+ {
+     if (auto *seat = mDisplay->currentInputDevice())
+@@ -479,7 +494,7 @@ void QWaylandIntegration::reconfigureInputContext()
+     }
+ #endif
+ 
+-    qCDebug(lcQpaWayland) << "using input method:" << inputContext()->metaObject()->className();
++    qCDebug(lcQpaWayland) << "using input method:" << (inputContext() ? inputContext()->metaObject()->className() : "<none>");
+ }
+ 
+ QWaylandShellIntegration *QWaylandIntegration::createShellIntegration(const QString &integrationName)
+diff --git a/qtwayland/src/client/qwaylandintegration_p.h b/qtwayland/src/client/qwaylandintegration_p.h
+index ff70ae25..73b80658 100644
+--- a/qtwayland/src/client/qwaylandintegration_p.h
++++ b/qtwayland/src/client/qwaylandintegration_p.h
+@@ -107,6 +107,8 @@ public:
+ 
+     QWaylandDisplay *display() const;
+ 
++    Qt::KeyboardModifiers queryKeyboardModifiers() const override;
++
+     QList<int> possibleKeys(const QKeyEvent *event) const override;
+ 
+     QStringList themeNames() const override;
+diff --git a/qtwayland/src/client/qwaylandprimaryselectionv1.cpp b/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
+index 832f9678..ea508771 100644
+--- a/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
++++ b/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
+@@ -54,11 +54,6 @@ QWaylandPrimarySelectionDeviceManagerV1::QWaylandPrimarySelectionDeviceManagerV1
+     : zwp_primary_selection_device_manager_v1(display->wl_registry(), id, qMin(version, uint(1)))
+     , m_display(display)
+ {
+-    // Create devices for all seats.
+-    // This only works if we get the global before all devices
+-    const auto seats = m_display->inputDevices();
+-    for (auto *seat : seats)
+-        seat->setPrimarySelectionDevice(createDevice(seat));
+ }
+ 
+ QWaylandPrimarySelectionDeviceV1 *QWaylandPrimarySelectionDeviceManagerV1::createDevice(QWaylandInputDevice *seat)
+diff --git a/qtwayland/src/client/qwaylandscreen.cpp b/qtwayland/src/client/qwaylandscreen.cpp
+index 6cb337de..5537dafd 100644
+--- a/qtwayland/src/client/qwaylandscreen.cpp
++++ b/qtwayland/src/client/qwaylandscreen.cpp
+@@ -60,7 +60,7 @@ QWaylandXdgOutputManagerV1::QWaylandXdgOutputManagerV1(QWaylandDisplay* display,
+ }
+ 
+ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uint32_t id)
+-    : QtWayland::wl_output(waylandDisplay->wl_registry(), id, qMin(version, 2))
++    : QtWayland::wl_output(waylandDisplay->wl_registry(), id, qMin(version, 3))
+     , m_outputId(id)
+     , mWaylandDisplay(waylandDisplay)
+     , mOutputName(QStringLiteral("Screen%1").arg(id))
+@@ -72,7 +72,7 @@ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uin
+         qCWarning(lcQpaWayland) << "wl_output done event not supported by compositor,"
+                                 << "QScreen may not work correctly";
+         mWaylandDisplay->forceRoundTrip(); // Give the compositor a chance to send geometry etc.
+-        mOutputDone = true; // Fake the done event
++        mProcessedEvents |= OutputDoneEvent; // Fake the done event
+         maybeInitialize();
+     }
+ }
+@@ -81,16 +81,29 @@ QWaylandScreen::~QWaylandScreen()
+ {
+     if (zxdg_output_v1::isInitialized())
+         zxdg_output_v1::destroy();
++    if (wl_output::isInitialized() && wl_output_get_version(wl_output::object()) >= WL_OUTPUT_RELEASE_SINCE_VERSION)
++        wl_output::release();
++}
++
++uint QWaylandScreen::requiredEvents() const
++{
++    uint ret = OutputDoneEvent;
++
++    if (mWaylandDisplay->xdgOutputManager()) {
++        ret |= XdgOutputNameEvent;
++
++        if (mWaylandDisplay->xdgOutputManager()->version() < 3)
++            ret |= XdgOutputDoneEvent;
++    }
++    return ret;
+ }
+ 
+ void QWaylandScreen::maybeInitialize()
+ {
+     Q_ASSERT(!mInitialized);
+ 
+-    if (!mOutputDone)
+-        return;
+-
+-    if (mWaylandDisplay->xdgOutputManager() && !mXdgOutputDone)
++    const uint requiredEvents = this->requiredEvents();
++    if ((mProcessedEvents & requiredEvents) != requiredEvents)
+         return;
+ 
+     mInitialized = true;
+@@ -276,9 +289,8 @@ void QWaylandScreen::output_scale(int32_t factor)
+ 
+ void QWaylandScreen::output_done()
+ {
+-    mOutputDone = true;
+-    if (zxdg_output_v1::isInitialized() && mWaylandDisplay->xdgOutputManager()->version() >= 3)
+-        mXdgOutputDone = true;
++    mProcessedEvents |= OutputDoneEvent;
++
+     if (mInitialized) {
+         updateOutputProperties();
+         if (zxdg_output_v1::isInitialized())
+@@ -339,7 +351,7 @@ void QWaylandScreen::zxdg_output_v1_done()
+     if (Q_UNLIKELY(mWaylandDisplay->xdgOutputManager()->version() >= 3))
+         qWarning(lcQpaWayland) << "zxdg_output_v1.done received on version 3 or newer, this is most likely a bug in the compositor";
+ 
+-    mXdgOutputDone = true;
++    mProcessedEvents |= XdgOutputDoneEvent;
+     if (mInitialized)
+         updateXdgOutputProperties();
+     else
+@@ -348,7 +360,11 @@ void QWaylandScreen::zxdg_output_v1_done()
+ 
+ void QWaylandScreen::zxdg_output_v1_name(const QString &name)
+ {
++    if (Q_UNLIKELY(mInitialized))
++        qWarning(lcQpaWayland) << "zxdg_output_v1.name received after output has been initialized, this is most likely a bug in the compositor";
++
+     mOutputName = name;
++    mProcessedEvents |= XdgOutputNameEvent;
+ }
+ 
+ void QWaylandScreen::updateXdgOutputProperties()
+diff --git a/qtwayland/src/client/qwaylandscreen_p.h b/qtwayland/src/client/qwaylandscreen_p.h
+index df1c94f2..050cfdc0 100644
+--- a/qtwayland/src/client/qwaylandscreen_p.h
++++ b/qtwayland/src/client/qwaylandscreen_p.h
+@@ -116,6 +116,13 @@ public:
+     static QWaylandScreen *fromWlOutput(::wl_output *output);
+ 
+ private:
++    enum Event : uint {
++        XdgOutputDoneEvent = 0x1,
++        OutputDoneEvent = 0x2,
++        XdgOutputNameEvent = 0x4,
++    };
++    uint requiredEvents() const;
++
+     void output_mode(uint32_t flags, int width, int height, int refresh) override;
+     void output_geometry(int32_t x, int32_t y,
+                          int32_t width, int32_t height,
+@@ -148,8 +155,7 @@ private:
+     QSize mPhysicalSize;
+     QString mOutputName;
+     Qt::ScreenOrientation m_orientation = Qt::PrimaryOrientation;
+-    bool mOutputDone = false;
+-    bool mXdgOutputDone = false;
++    uint mProcessedEvents = 0;
+     bool mInitialized = false;
+ 
+ #if QT_CONFIG(cursor)
+diff --git a/qtwayland/src/client/qwaylandshmbackingstore.cpp b/qtwayland/src/client/qwaylandshmbackingstore.cpp
+index dc7ff670..41cffdf7 100644
+--- a/qtwayland/src/client/qwaylandshmbackingstore.cpp
++++ b/qtwayland/src/client/qwaylandshmbackingstore.cpp
+@@ -52,6 +52,7 @@
+ 
+ #include <QtWaylandClient/private/wayland-wayland-client-protocol.h>
+ 
++#include <fcntl.h>
+ #include <unistd.h>
+ #include <sys/mman.h>
+ 
+@@ -61,6 +62,9 @@
+ #  ifndef MFD_CLOEXEC
+ #    define MFD_CLOEXEC     0x0001U
+ #  endif
++#  ifndef MFD_ALLOW_SEALING
++#    define MFD_ALLOW_SEALING 0x0002U
++#  endif
+ #endif
+ 
+ QT_BEGIN_NAMESPACE
+@@ -74,8 +78,10 @@ QWaylandShmBuffer::QWaylandShmBuffer(QWaylandDisplay *display,
+     int alloc = stride * size.height();
+     int fd = -1;
+ 
+-#ifdef SYS_memfd_create
+-    fd = syscall(SYS_memfd_create, "wayland-shm", MFD_CLOEXEC);
++#if defined(SYS_memfd_create) && defined(F_SEAL_SEAL)
++    fd = syscall(SYS_memfd_create, "wayland-shm", MFD_CLOEXEC | MFD_ALLOW_SEALING);
++    if (fd >= 0)
++        fcntl(fd, F_ADD_SEALS, F_SEAL_SHRINK | F_SEAL_SEAL);
+ #endif
+ 
+     QScopedPointer<QFile> filePointer;
+diff --git a/qtwayland/src/client/qwaylandwindow.cpp b/qtwayland/src/client/qwaylandwindow.cpp
+index cb82857a..fb2c59dc 100644
+--- a/qtwayland/src/client/qwaylandwindow.cpp
++++ b/qtwayland/src/client/qwaylandwindow.cpp
+@@ -76,7 +76,6 @@ QWaylandWindow *QWaylandWindow::mMouseGrab = nullptr;
+ QWaylandWindow::QWaylandWindow(QWindow *window, QWaylandDisplay *display)
+     : QPlatformWindow(window)
+     , mDisplay(display)
+-    , mFrameQueue(mDisplay->createFrameQueue())
+     , mResizeAfterSwap(qEnvironmentVariableIsSet("QT_WAYLAND_RESIZE_AFTER_SWAP"))
+ {
+     {
+@@ -95,9 +94,6 @@ QWaylandWindow::QWaylandWindow(QWindow *window, QWaylandDisplay *display)
+ 
+ QWaylandWindow::~QWaylandWindow()
+ {
+-    mDisplay->destroyFrameQueue(mFrameQueue);
+-    mDisplay->handleWindowDestroyed(this);
+-
+     delete mWindowDecoration;
+ 
+     if (mSurface)
+@@ -243,6 +239,7 @@ bool QWaylandWindow::shouldCreateSubSurface() const
+ 
+ void QWaylandWindow::reset()
+ {
++    closeChildPopups();
+     delete mShellSurface;
+     mShellSurface = nullptr;
+     delete mSubSurfaceWindow;
+@@ -255,17 +252,22 @@ void QWaylandWindow::reset()
+         mSurface.reset();
+     }
+ 
+-    if (mFrameCallback) {
+-        wl_callback_destroy(mFrameCallback);
+-        mFrameCallback = nullptr;
+-    }
++    {
++        QMutexLocker lock(&mFrameSyncMutex);
++        if (mFrameCallback) {
++            wl_callback_destroy(mFrameCallback);
++            mFrameCallback = nullptr;
++        }
+ 
+-    mFrameCallbackElapsedTimer.invalidate();
+-    mWaitingForFrameCallback = false;
++        mFrameCallbackElapsedTimer.invalidate();
++        mWaitingForFrameCallback = false;
++    }
+     mFrameCallbackTimedOut = false;
+ 
+     mMask = QRegion();
+     mQueuedBuffer = nullptr;
++
++    mDisplay->handleWindowDestroyed(this);
+ }
+ 
+ QWaylandWindow *QWaylandWindow::fromWlSurface(::wl_surface *surface)
+@@ -351,19 +353,25 @@ void QWaylandWindow::setGeometry_helper(const QRect &rect)
+     }
+ }
+ 
+-void QWaylandWindow::setGeometry(const QRect &rect)
++void QWaylandWindow::setGeometry(const QRect &r)
+ {
++    auto rect = r;
++    if (fixedToplevelPositions && !QPlatformWindow::parent() && window()->type() != Qt::Popup
++        && window()->type() != Qt::ToolTip) {
++        rect.moveTo(screen()->geometry().topLeft());
++    }
+     setGeometry_helper(rect);
+ 
+     if (window()->isVisible() && rect.isValid()) {
+         if (mWindowDecoration)
+             mWindowDecoration->update();
+ 
+-        if (mResizeAfterSwap && windowType() == Egl && mSentInitialResize)
++        if (mResizeAfterSwap && windowType() == Egl && mSentInitialResize) {
++            QMutexLocker lock(&mResizeLock);
+             mResizeDirty = true;
+-        else
++        } else {
+             QWindowSystemInterface::handleGeometryChange(window(), geometry());
+-
++        }
+         mSentInitialResize = true;
+     }
+     QRect exposeGeometry(QPoint(), geometry().size());
+@@ -374,7 +382,7 @@ void QWaylandWindow::setGeometry(const QRect &rect)
+         mShellSurface->setWindowGeometry(windowContentGeometry());
+ 
+     if (isOpaque() && mMask.isEmpty())
+-        setOpaqueArea(rect);
++        setOpaqueArea(QRect(QPoint(0, 0), rect.size()));
+ }
+ 
+ void QWaylandWindow::resizeFromApplyConfigure(const QSize &sizeWithMargins, const QPoint &offset)
+@@ -399,21 +407,6 @@ void QWaylandWindow::sendExposeEvent(const QRect &rect)
+     mLastExposeGeometry = rect;
+ }
+ 
+-
+-static QVector<QPointer<QWaylandWindow>> activePopups;
+-
+-void QWaylandWindow::closePopups(QWaylandWindow *parent)
+-{
+-    while (!activePopups.isEmpty()) {
+-        auto popup = activePopups.takeLast();
+-        if (popup.isNull())
+-            continue;
+-        if (popup.data() == parent)
+-            return;
+-        popup->reset();
+-    }
+-}
+-
+ QPlatformScreen *QWaylandWindow::calculateScreenFromSurfaceEvents() const
+ {
+     QReadLocker lock(&mSurfaceLock);
+@@ -433,10 +426,7 @@ void QWaylandWindow::setVisible(bool visible)
+     lastVisible = visible;
+ 
+     if (visible) {
+-        if (window()->type() == Qt::Popup || window()->type() == Qt::ToolTip)
+-            activePopups << this;
+         initWindow();
+-        mDisplay->flushRequests();
+ 
+         setGeometry(windowGeometry());
+         // Don't flush the events here, or else the newly visible window may start drawing, but since
+@@ -444,7 +434,6 @@ void QWaylandWindow::setVisible(bool visible)
+         // QWaylandShmBackingStore::beginPaint().
+     } else {
+         sendExposeEvent(QRect());
+-        closePopups(this);
+         reset();
+     }
+ }
+@@ -556,12 +545,12 @@ void QWaylandWindow::sendRecursiveExposeEvent()
+ 
+ void QWaylandWindow::attach(QWaylandBuffer *buffer, int x, int y)
+ {
+-    Q_ASSERT(!buffer->committed());
+     QReadLocker locker(&mSurfaceLock);
+     if (mSurface == nullptr)
+         return;
+ 
+     if (buffer) {
++        Q_ASSERT(!buffer->committed());
+         handleUpdate();
+         buffer->setBusy();
+ 
+@@ -583,7 +572,11 @@ void QWaylandWindow::damage(const QRect &rect)
+     if (mSurface == nullptr)
+         return;
+ 
+-    mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    const int s = scale();
++    if (mDisplay->compositorVersion() >= 4)
++        mSurface->damage_buffer(s * rect.x(), s * rect.y(), s * rect.width(), s * rect.height());
++    else
++        mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
+ }
+ 
+ void QWaylandWindow::safeCommit(QWaylandBuffer *buffer, const QRegion &damage)
+@@ -619,8 +612,14 @@ void QWaylandWindow::commit(QWaylandBuffer *buffer, const QRegion &damage)
+         return;
+ 
+     attachOffset(buffer);
+-    for (const QRect &rect: damage)
+-        mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    if (mDisplay->compositorVersion() >= 4) {
++        const int s = scale();
++        for (const QRect &rect: damage)
++            mSurface->damage_buffer(s * rect.x(), s * rect.y(), s * rect.width(), s * rect.height());
++    } else {
++        for (const QRect &rect: damage)
++            mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    }
+     Q_ASSERT(!buffer->committed());
+     buffer->setCommitted();
+     mSurface->commit();
+@@ -635,42 +634,53 @@ void QWaylandWindow::commit()
+ 
+ const wl_callback_listener QWaylandWindow::callbackListener = {
+     [](void *data, wl_callback *callback, uint32_t time) {
+-        Q_UNUSED(callback);
+         Q_UNUSED(time);
+         auto *window = static_cast<QWaylandWindow*>(data);
+-        window->handleFrameCallback();
++        window->handleFrameCallback(callback);
+     }
+ };
+ 
+-void QWaylandWindow::handleFrameCallback()
++void QWaylandWindow::handleFrameCallback(wl_callback* callback)
+ {
++    QMutexLocker locker(&mFrameSyncMutex);
++    if (!mFrameCallback) {
++        // This means the callback is already unset by QWaylandWindow::reset.
++        // The wl_callback object will be destroyed there too.
++        return;
++    }
++    Q_ASSERT(callback == mFrameCallback);
++    wl_callback_destroy(callback);
++    mFrameCallback = nullptr;
++
+     mWaitingForFrameCallback = false;
+     mFrameCallbackElapsedTimer.invalidate();
+ 
+     // The rest can wait until we can run it on the correct thread
+-    if (!mWaitingForUpdateDelivery) {
+-        auto doHandleExpose = [this]() {
+-            bool wasExposed = isExposed();
+-            mFrameCallbackTimedOut = false;
+-            if (!wasExposed && isExposed()) // Did setting mFrameCallbackTimedOut make the window exposed?
+-                sendExposeEvent(QRect(QPoint(), geometry().size()));
+-            if (wasExposed && hasPendingUpdateRequest())
+-                deliverUpdateRequest();
+-
+-            mWaitingForUpdateDelivery = false;
+-        };
++    auto doHandleExpose = [this]() {
++        mWaitingForUpdateDelivery.storeRelease(false);
++        bool wasExposed = isExposed();
++        mFrameCallbackTimedOut = false;
++        if (!wasExposed && isExposed()) // Did setting mFrameCallbackTimedOut make the window exposed?
++            sendExposeEvent(QRect(QPoint(), geometry().size()));
++        if (wasExposed && hasPendingUpdateRequest())
++            deliverUpdateRequest();
++    };
+ 
++    if (mWaitingForUpdateDelivery.testAndSetAcquire(false, true)) {
+         // Queued connection, to make sure we don't call handleUpdate() from inside waitForFrameSync()
+         // in the single-threaded case.
+-        mWaitingForUpdateDelivery = true;
+         QMetaObject::invokeMethod(this, doHandleExpose, Qt::QueuedConnection);
+     }
++
++    mFrameSyncWait.notify_all();
+ }
+ 
+ bool QWaylandWindow::waitForFrameSync(int timeout)
+ {
+-    QMutexLocker locker(mFrameQueue.mutex);
+-    mDisplay->dispatchQueueWhile(mFrameQueue.queue, [&]() { return mWaitingForFrameCallback; }, timeout);
++    QMutexLocker locker(&mFrameSyncMutex);
++
++    QDeadlineTimer deadline(timeout);
++    while (mWaitingForFrameCallback && mFrameSyncWait.wait(&mFrameSyncMutex, deadline)) { }
+ 
+     if (mWaitingForFrameCallback) {
+         qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
+@@ -868,6 +878,17 @@ bool QWaylandWindow::createDecoration()
+             subsurf->set_position(pos.x() + m.left(), pos.y() + m.top());
+         }
+         sendExposeEvent(QRect(QPoint(), geometry().size()));
++
++        // This is a special case where the buffer is recreated, but since
++        // the content rect remains the same, the widgets remain the same
++        // size and are not redrawn, leaving the new buffer empty. As a simple
++        // work-around, we trigger a full extra update whenever the client-side
++        // window decorations are toggled while the window is showing.
++        // Note: createDecoration() is sometimes called from the render thread
++        // of Qt Quick. This is essentially wrong and could potentially cause problems,
++        // but until the underlying issue has been fixed, we have to use invokeMethod()
++        // here to avoid asserts.
++        QMetaObject::invokeMethod(window(), &QWindow::requestUpdate);
+     }
+ 
+     return mWindowDecoration;
+@@ -1023,6 +1044,13 @@ void QWaylandWindow::handleScreensChanged()
+ 
+     QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->QPlatformScreen::screen());
+     mLastReportedScreen = newScreen;
++    if (fixedToplevelPositions && !QPlatformWindow::parent() && window()->type() != Qt::Popup
++        && window()->type() != Qt::ToolTip
++        && geometry().topLeft() != newScreen->geometry().topLeft()) {
++        auto geometry = this->geometry();
++        geometry.moveTo(newScreen->geometry().topLeft());
++        setGeometry(geometry);
++    }
+ 
+     int scale = newScreen->isPlaceholder() ? 1 : static_cast<QWaylandScreen *>(newScreen)->scale();
+     if (scale != mScale) {
+@@ -1094,10 +1122,18 @@ bool QWaylandWindow::setMouseGrabEnabled(bool grab)
+     return true;
+ }
+ 
++Qt::WindowStates QWaylandWindow::windowStates() const
++{
++    return mLastReportedWindowStates;
++}
++
+ void QWaylandWindow::handleWindowStatesChanged(Qt::WindowStates states)
+ {
+     createDecoration();
+-    QWindowSystemInterface::handleWindowStateChanged(window(), states, mLastReportedWindowStates);
++    Qt::WindowStates statesWithoutActive = states & ~Qt::WindowActive;
++    Qt::WindowStates lastStatesWithoutActive = mLastReportedWindowStates & ~Qt::WindowActive;
++    QWindowSystemInterface::handleWindowStateChanged(window(), statesWithoutActive,
++                                                     lastStatesWithoutActive);
+     mLastReportedWindowStates = states;
+ }
+ 
+@@ -1139,19 +1175,24 @@ void QWaylandWindow::timerEvent(QTimerEvent *event)
+     if (event->timerId() != mFrameCallbackCheckIntervalTimerId)
+         return;
+ 
+-    bool callbackTimerExpired = mFrameCallbackElapsedTimer.hasExpired(mFrameCallbackTimeout);
+-    if (!mFrameCallbackElapsedTimer.isValid() || callbackTimerExpired ) {
+-        killTimer(mFrameCallbackCheckIntervalTimerId);
+-        mFrameCallbackCheckIntervalTimerId = -1;
+-    }
+-    if (mFrameCallbackElapsedTimer.isValid() && callbackTimerExpired) {
+-        mFrameCallbackElapsedTimer.invalidate();
++    {
++        QMutexLocker lock(&mFrameSyncMutex);
+ 
+-        qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
+-        mFrameCallbackTimedOut = true;
+-        mWaitingForUpdate = false;
+-        sendExposeEvent(QRect());
++        bool callbackTimerExpired = mFrameCallbackElapsedTimer.hasExpired(mFrameCallbackTimeout);
++        if (!mFrameCallbackElapsedTimer.isValid() || callbackTimerExpired ) {
++            killTimer(mFrameCallbackCheckIntervalTimerId);
++            mFrameCallbackCheckIntervalTimerId = -1;
++        }
++        if (!mFrameCallbackElapsedTimer.isValid() || !callbackTimerExpired) {
++            return;
++        }
++        mFrameCallbackElapsedTimer.invalidate();
+     }
++
++    qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
++    mFrameCallbackTimedOut = true;
++    mWaitingForUpdate = false;
++    sendExposeEvent(QRect());
+ }
+ 
+ void QWaylandWindow::requestUpdate()
+@@ -1160,8 +1201,11 @@ void QWaylandWindow::requestUpdate()
+     Q_ASSERT(hasPendingUpdateRequest()); // should be set by QPA
+ 
+     // If we have a frame callback all is good and will be taken care of there
+-    if (mWaitingForFrameCallback)
+-        return;
++    {
++        QMutexLocker locker(&mFrameSyncMutex);
++        if (mWaitingForFrameCallback)
++            return;
++    }
+ 
+     // If we've already called deliverUpdateRequest(), but haven't seen any attach+commit/swap yet
+     // This is a somewhat redundant behavior and might indicate a bug in the calling code, so log
+@@ -1174,7 +1218,12 @@ void QWaylandWindow::requestUpdate()
+     // so use invokeMethod to delay the delivery a bit.
+     QMetaObject::invokeMethod(this, [this] {
+         // Things might have changed in the meantime
+-        if (hasPendingUpdateRequest() && !mWaitingForFrameCallback)
++        {
++            QMutexLocker locker(&mFrameSyncMutex);
++            if (mWaitingForFrameCallback)
++                return;
++        }
++        if (hasPendingUpdateRequest())
+             deliverUpdateRequest();
+     }, Qt::QueuedConnection);
+ }
+@@ -1185,19 +1234,18 @@ void QWaylandWindow::requestUpdate()
+ void QWaylandWindow::handleUpdate()
+ {
+     qCDebug(lcWaylandBackingstore) << "handleUpdate" << QThread::currentThread();
++
+     // TODO: Should sync subsurfaces avoid requesting frame callbacks?
+     QReadLocker lock(&mSurfaceLock);
+     if (!mSurface)
+         return;
+ 
+-    if (mFrameCallback) {
+-        wl_callback_destroy(mFrameCallback);
+-        mFrameCallback = nullptr;
+-    }
++    QMutexLocker locker(&mFrameSyncMutex);
++    if (mWaitingForFrameCallback)
++        return;
+ 
+-    QMutexLocker locker(mFrameQueue.mutex);
+     struct ::wl_surface *wrappedSurface = reinterpret_cast<struct ::wl_surface *>(wl_proxy_create_wrapper(mSurface->object()));
+-    wl_proxy_set_queue(reinterpret_cast<wl_proxy *>(wrappedSurface), mFrameQueue.queue);
++    wl_proxy_set_queue(reinterpret_cast<wl_proxy *>(wrappedSurface), mDisplay->frameEventQueue());
+     mFrameCallback = wl_surface_frame(wrappedSurface);
+     wl_proxy_wrapper_destroy(wrappedSurface);
+     wl_callback_add_listener(mFrameCallback, &QWaylandWindow::callbackListener, this);
+@@ -1207,6 +1255,8 @@ void QWaylandWindow::handleUpdate()
+     // Start a timer for handling the case when the compositor stops sending frame callbacks.
+     if (mFrameCallbackTimeout > 0) {
+         QMetaObject::invokeMethod(this, [this] {
++            QMutexLocker locker(&mFrameSyncMutex);
++
+             if (mWaitingForFrameCallback) {
+                 if (mFrameCallbackCheckIntervalTimerId < 0)
+                     mFrameCallbackCheckIntervalTimerId = startTimer(mFrameCallbackTimeout);
+@@ -1267,6 +1317,20 @@ void QWaylandWindow::setOpaqueArea(const QRegion &opaqueArea)
+     wl_region_destroy(region);
+ }
+ 
++void QWaylandWindow::addChildPopup(QWaylandWindow *surface) {
++    mChildPopups.append(surface);
++}
++
++void QWaylandWindow::removeChildPopup(QWaylandWindow *surface) {
++    mChildPopups.removeAll(surface);
++}
++
++void QWaylandWindow::closeChildPopups() {
++    while (!mChildPopups.isEmpty()) {
++        auto popup = mChildPopups.takeLast();
++        popup->reset();
++    }
++}
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/client/qwaylandwindow_p.h b/qtwayland/src/client/qwaylandwindow_p.h
+index 01337cff..2f219d8c 100644
+--- a/qtwayland/src/client/qwaylandwindow_p.h
++++ b/qtwayland/src/client/qwaylandwindow_p.h
+@@ -98,6 +98,9 @@ public:
+     QWaylandWindow(QWindow *window, QWaylandDisplay *display);
+     ~QWaylandWindow() override;
+ 
++    // Keep Toplevels position on the top left corner of their screen
++    static inline bool fixedToplevelPositions = true;
++
+     virtual WindowType windowType() const = 0;
+     virtual void ensureSize();
+     WId winId() const override;
+@@ -148,6 +151,7 @@ public:
+     void setWindowState(Qt::WindowStates states) override;
+     void setWindowFlags(Qt::WindowFlags flags) override;
+     void handleWindowStatesChanged(Qt::WindowStates states);
++    Qt::WindowStates windowStates() const;
+ 
+     void raise() override;
+     void lower() override;
+@@ -206,6 +210,10 @@ public:
+     void handleUpdate();
+     void deliverUpdateRequest() override;
+ 
++    void addChildPopup(QWaylandWindow* child);
++    void removeChildPopup(QWaylandWindow* child);
++    void closeChildPopups();
++
+ public slots:
+     void applyConfigure();
+ 
+@@ -215,7 +223,11 @@ signals:
+ 
+ protected:
+     QWaylandDisplay *mDisplay = nullptr;
++
++    // mSurface can be written by the main thread. Other threads should claim a read lock for access
++    mutable QReadWriteLock mSurfaceLock;
+     QScopedPointer<QWaylandSurface> mSurface;
++
+     QWaylandShellSurface *mShellSurface = nullptr;
+     QWaylandSubSurface *mSubSurfaceWindow = nullptr;
+     QVector<QWaylandSubSurface *> mChildren;
+@@ -225,13 +237,14 @@ protected:
+     Qt::MouseButtons mMousePressedInContentArea = Qt::NoButton;
+ 
+     WId mWindowId;
+-    bool mWaitingForFrameCallback = false;
+     bool mFrameCallbackTimedOut = false; // Whether the frame callback has timed out
+-    bool mWaitingForUpdateDelivery = false;
+     int mFrameCallbackCheckIntervalTimerId = -1;
+-    QElapsedTimer mFrameCallbackElapsedTimer;
+-    struct ::wl_callback *mFrameCallback = nullptr;
+-    QWaylandDisplay::FrameQueue mFrameQueue;
++    QAtomicInt mWaitingForUpdateDelivery = false;
++
++    bool mWaitingForFrameCallback = false; // Protected by mFrameSyncMutex
++    QElapsedTimer mFrameCallbackElapsedTimer; // Protected by mFrameSyncMutex
++    struct ::wl_callback *mFrameCallback = nullptr; // Protected by mFrameSyncMutex
++    QMutex mFrameSyncMutex;
+     QWaitCondition mFrameSyncWait;
+ 
+     // True when we have called deliverRequestUpdate, but the client has not yet attached a new buffer
+@@ -261,6 +274,8 @@ protected:
+     QWaylandBuffer *mQueuedBuffer = nullptr;
+     QRegion mQueuedBufferDamage;
+ 
++    QList<QPointer<QWaylandWindow>> mChildPopups;
++
+ private:
+     void setGeometry_helper(const QRect &rect);
+     void initWindow();
+@@ -283,12 +298,10 @@ private:
+     QRect mLastExposeGeometry;
+ 
+     static const wl_callback_listener callbackListener;
+-    void handleFrameCallback();
++    void handleFrameCallback(struct ::wl_callback* callback);
+ 
+     static QWaylandWindow *mMouseGrab;
+ 
+-    mutable QReadWriteLock mSurfaceLock;
+-
+     friend class QWaylandSubSurface;
+ };
+ 
+diff --git a/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h b/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
+index ccad0048..4cc9b3b8 100644
+--- a/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
++++ b/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
+@@ -73,11 +73,10 @@ public:
+         return true;
+     }
+     virtual QWaylandShellSurface *createShellSurface(QWaylandWindow *window) = 0;
++    // kept for binary compat with layer-shell-qt
+     virtual void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) {
+-        if (newFocus)
+-            m_display->handleWindowActivated(newFocus);
+-        if (oldFocus)
+-            m_display->handleWindowDeactivated(oldFocus);
++        Q_UNUSED(newFocus);
++        Q_UNUSED(oldFocus);
+     }
+     virtual void *nativeResourceForWindow(const QByteArray &resource, QWindow *window) {
+         Q_UNUSED(resource);
+diff --git a/qtwayland/src/compositor/configure.json b/qtwayland/src/compositor/configure.json
+index bcfd5215..da95d07b 100644
+--- a/qtwayland/src/compositor/configure.json
++++ b/qtwayland/src/compositor/configure.json
+@@ -7,6 +7,31 @@
+     "testDir": "../../config.tests",
+ 
+     "libraries": {
++        "wayland-client": {
++            "label": "Wayland client library",
++            "headers": "wayland-version.h",
++            "test": {
++                "main": [
++                    "#if WAYLAND_VERSION_MAJOR < 1",
++                    "# error Wayland 1.8.0 or higher required",
++                    "#endif",
++                    "#if WAYLAND_VERSION_MAJOR == 1",
++                    "# if WAYLAND_VERSION_MINOR < 8",
++                    "#  error Wayland 1.8.0 or higher required",
++                    "# endif",
++                    "# if WAYLAND_VERSION_MINOR == 8",
++                    "#  if WAYLAND_VERSION_MICRO < 0",
++                    "#   error Wayland 1.8.0 or higher required",
++                    "#  endif",
++                    "# endif",
++                    "#endif"
++                 ]
++            },
++            "sources": [
++                { "type": "pkgConfig", "args": "wayland-client" },
++                "-lwayland-client"
++            ]
++        },
+         "wayland-server": {
+             "label": "wayland-server",
+             "headers": "wayland-version.h",
+@@ -151,8 +176,7 @@
+                     "#endif"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "dmabuf-client-buffer": {
+             "label": "Linux Client dma-buf Buffer Sharing",
+@@ -176,8 +200,7 @@
+                     "return 0;"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "vulkan-server-buffer": {
+             "label": "Vulkan Buffer Sharing",
+@@ -195,7 +218,8 @@
+                     "exportAllocInfo.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR;",
+                     "return 0;"
+                 ]
+-            }
++            },
++            "use": "wayland-client"
+         }
+     },
+ 
+diff --git a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
+index 7889f575..64140672 100644
+--- a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
++++ b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
+@@ -40,6 +40,7 @@
+ #include "qwaylandeglwindow.h"
+ 
+ #include <QtWaylandClient/private/qwaylandscreen_p.h>
++#include <QtWaylandClient/private/qwaylandsurface_p.h>
+ #include "qwaylandglcontext.h"
+ 
+ #include <QtEglSupport/private/qeglconvenience_p.h>
+@@ -124,6 +125,7 @@ void QWaylandEglWindow::updateSurface(bool create)
+         }
+         mOffset = QPoint();
+     } else {
++        QReadLocker locker(&mSurfaceLock);
+         if (m_waylandEglWindow) {
+             int current_width, current_height;
+             static bool disableResizeCheck = qgetenv("QT_WAYLAND_DISABLE_RESIZECHECK").toInt();
+@@ -131,14 +133,16 @@ void QWaylandEglWindow::updateSurface(bool create)
+             if (!disableResizeCheck) {
+                 wl_egl_window_get_attached_size(m_waylandEglWindow, &current_width, &current_height);
+             }
+-            if (disableResizeCheck || (current_width != sizeWithMargins.width() || current_height != sizeWithMargins.height())) {
++            if (disableResizeCheck || (current_width != sizeWithMargins.width() || current_height != sizeWithMargins.height()) || m_requestedSize != sizeWithMargins) {
+                 wl_egl_window_resize(m_waylandEglWindow, sizeWithMargins.width(), sizeWithMargins.height(), mOffset.x(), mOffset.y());
++                m_requestedSize = sizeWithMargins;
+                 mOffset = QPoint();
+ 
+                 m_resize = true;
+             }
+-        } else if (create && wlSurface()) {
+-            m_waylandEglWindow = wl_egl_window_create(wlSurface(), sizeWithMargins.width(), sizeWithMargins.height());
++        } else if (create && mSurface) {
++            m_waylandEglWindow = wl_egl_window_create(mSurface->object(), sizeWithMargins.width(), sizeWithMargins.height());
++            m_requestedSize = sizeWithMargins;
+         }
+ 
+         if (!m_eglSurface && m_waylandEglWindow && create) {
+diff --git a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
+index 5b1f4d56..0079dfef 100644
+--- a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
++++ b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
+@@ -88,6 +88,7 @@ private:
+     mutable QOpenGLFramebufferObject *m_contentFBO = nullptr;
+ 
+     QSurfaceFormat m_format;
++    QSize m_requestedSize;
+ };
+ 
+ }
+diff --git a/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h b/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
+index 56a710c3..c6a8b6c6 100644
+--- a/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
++++ b/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
+@@ -41,6 +41,8 @@
+ #include <QtCore/QTextStream>
+ #include <QtGui/QOpenGLTexture>
+ 
++#include <array>
++
+ #include <EGL/egl.h>
+ #include <EGL/eglext.h>
+ 
+diff --git a/qtwayland/src/plugins/decorations/bradient/main.cpp b/qtwayland/src/plugins/decorations/bradient/main.cpp
+index e75fda3c..fa885143 100644
+--- a/qtwayland/src/plugins/decorations/bradient/main.cpp
++++ b/qtwayland/src/plugins/decorations/bradient/main.cpp
+@@ -164,13 +164,10 @@ void QWaylandBradientDecoration::paint(QPaintDevice *device)
+     // Window icon
+     QIcon icon = waylandWindow()->windowIcon();
+     if (!icon.isNull()) {
+-        QPixmap pixmap = icon.pixmap(QSize(128, 128));
+-        QPixmap scaled = pixmap.scaled(22, 22, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+-
+         QRectF iconRect(0, 0, 22, 22);
+-        p.drawPixmap(iconRect.adjusted(margins().left() + BUTTON_SPACING, 4,
+-                                       margins().left() + BUTTON_SPACING, 4),
+-                     scaled, iconRect);
++        iconRect.adjust(margins().left() + BUTTON_SPACING, 4,
++                        margins().left() + BUTTON_SPACING, 4),
++        icon.paint(&p, iconRect.toRect());
+     }
+ 
+     // Window title
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
+index 85d25e3c..60bdd491 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
+@@ -47,18 +47,21 @@ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
+-QWaylandXdgPopupV5::QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow *window)
++QWaylandXdgPopupV5::QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow* parent, QWaylandWindow *window)
+     : QWaylandShellSurface(window)
+     , QtWayland::xdg_popup_v5(popup)
++    , m_parent(parent)
+     , m_window(window)
+ {
+     if (window->display()->windowExtension())
+         m_extendedWindow = new QWaylandExtendedSurface(window);
++    m_parent->addChildPopup(m_window);
+ }
+ 
+ QWaylandXdgPopupV5::~QWaylandXdgPopupV5()
+ {
+     xdg_popup_destroy(object());
++    m_parent->removeChildPopup(m_window);
+     delete m_extendedWindow;
+ }
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
+index 7494f6a6..d85f130b 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
+@@ -70,7 +70,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgPopupV5 : public QWaylandShellSurface
+ {
+     Q_OBJECT
+ public:
+-    QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow *window);
++    QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow* parent, QWaylandWindow *window);
+     ~QWaylandXdgPopupV5() override;
+ 
+ protected:
+@@ -78,6 +78,7 @@ protected:
+ 
+ private:
+     QWaylandExtendedSurface *m_extendedWindow = nullptr;
++    QWaylandWindow *m_parent = nullptr;
+     QWaylandWindow *m_window = nullptr;
+ };
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
+index 7e242c4a..def8452a 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
+@@ -84,7 +84,7 @@ QWaylandXdgPopupV5 *QWaylandXdgShellV5::createXdgPopup(QWaylandWindow *window, Q
+     int x = position.x() + parentWindow->frameMargins().left();
+     int y = position.y() + parentWindow->frameMargins().top();
+ 
+-    auto popup = new QWaylandXdgPopupV5(get_xdg_popup(window->wlSurface(), parentSurface, seat, m_popupSerial, x, y), window);
++    auto popup = new QWaylandXdgPopupV5(get_xdg_popup(window->wlSurface(), parentSurface, seat, m_popupSerial, x, y), parentWindow, window);
+     m_popups.append(window);
+     QObject::connect(popup, &QWaylandXdgPopupV5::destroyed, [this, window](){
+         m_popups.removeOne(window);
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
+index 4e25949f..cfc60939 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
+@@ -85,13 +85,6 @@ QWaylandShellSurface *QWaylandXdgShellV5Integration::createShellSurface(QWayland
+     return m_xdgShell->createXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellV5Integration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) {
+-    if (newFocus && qobject_cast<QWaylandXdgPopupV5 *>(newFocus->shellSurface()))
+-        m_display->handleWindowActivated(newFocus);
+-    if (oldFocus && qobject_cast<QWaylandXdgPopupV5 *>(oldFocus->shellSurface()))
+-        m_display->handleWindowDeactivated(oldFocus);
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
+index ce6bdb9e..aed88670 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
+@@ -67,7 +67,6 @@ public:
+     QWaylandXdgShellV5Integration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShellV5> m_xdgShell;
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
+index 8c371661..151c78e3 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
+@@ -174,6 +174,7 @@ QWaylandXdgSurfaceV6::Popup::Popup(QWaylandXdgSurfaceV6 *xdgSurface, QWaylandXdg
+     , m_xdgSurface(xdgSurface)
+     , m_parent(parent)
+ {
++    m_parent->window()->addChildPopup(m_xdgSurface->window());
+ }
+ 
+ QWaylandXdgSurfaceV6::Popup::~Popup()
+@@ -181,6 +182,8 @@ QWaylandXdgSurfaceV6::Popup::~Popup()
+     if (isInitialized())
+         destroy();
+ 
++    m_parent->window()->removeChildPopup(m_xdgSurface->window());
++
+     if (m_grabbing) {
+         auto *shell = m_xdgSurface->m_shell;
+         Q_ASSERT(shell->m_topmostGrabbingPopup == this);
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
+index 03164316..e8da8ba1 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
+@@ -68,20 +68,6 @@ QWaylandShellSurface *QWaylandXdgShellV6Integration::createShellSurface(QWayland
+     return m_xdgShell->getXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellV6Integration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus)
+-{
+-    if (newFocus) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurfaceV6 *>(newFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowActivated(newFocus);
+-    }
+-    if (oldFocus && qobject_cast<QWaylandXdgSurfaceV6 *>(oldFocus->shellSurface())) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurfaceV6 *>(oldFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowDeactivated(oldFocus);
+-    }
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
+index 261f8cbb..c1bcd5c6 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
+@@ -65,7 +65,6 @@ public:
+     QWaylandXdgShellV6Integration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShellV6> m_xdgShell;
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
+index f3e3c330..fa6d5808 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
+@@ -67,11 +67,6 @@ QWaylandXdgSurface::Toplevel::Toplevel(QWaylandXdgSurface *xdgSurface)
+ 
+ QWaylandXdgSurface::Toplevel::~Toplevel()
+ {
+-    if (m_applied.states & Qt::WindowActive) {
+-        QWaylandWindow *window = m_xdgSurface->window();
+-        window->display()->handleWindowDeactivated(window);
+-    }
+-
+     // The protocol spec requires that the decoration object is deleted before xdg_toplevel.
+     delete m_decoration;
+     m_decoration = nullptr;
+@@ -85,16 +80,15 @@ void QWaylandXdgSurface::Toplevel::applyConfigure()
+     if (!(m_applied.states & (Qt::WindowMaximized|Qt::WindowFullScreen)))
+         m_normalSize = m_xdgSurface->m_window->windowFrameGeometry().size();
+ 
+-    if ((m_pending.states & Qt::WindowActive) && !(m_applied.states & Qt::WindowActive))
++    if ((m_pending.states & Qt::WindowActive) && !(m_applied.states & Qt::WindowActive)
++        && !m_xdgSurface->m_window->display()->isKeyboardAvailable())
+         m_xdgSurface->m_window->display()->handleWindowActivated(m_xdgSurface->m_window);
+ 
+-    if (!(m_pending.states & Qt::WindowActive) && (m_applied.states & Qt::WindowActive))
++    if (!(m_pending.states & Qt::WindowActive) && (m_applied.states & Qt::WindowActive)
++        && !m_xdgSurface->m_window->display()->isKeyboardAvailable())
+         m_xdgSurface->m_window->display()->handleWindowDeactivated(m_xdgSurface->m_window);
+ 
+-    // TODO: none of the other plugins send WindowActive either, but is it on purpose?
+-    Qt::WindowStates statesWithoutActive = m_pending.states & ~Qt::WindowActive;
+-
+-    m_xdgSurface->m_window->handleWindowStatesChanged(statesWithoutActive);
++    m_xdgSurface->m_window->handleWindowStatesChanged(m_pending.states);
+ 
+     if (m_pending.size.isEmpty()) {
+         // An empty size in the configure means it's up to the client to choose the size
+@@ -105,8 +99,6 @@ void QWaylandXdgSurface::Toplevel::applyConfigure()
+         m_xdgSurface->m_window->resizeFromApplyConfigure(m_pending.size);
+     }
+ 
+-    m_xdgSurface->setSizeHints();
+-
+     m_applied = m_pending;
+     qCDebug(lcQpaWayland) << "Applied pending xdg_toplevel configure event:" << m_applied.size << m_applied.states;
+ }
+@@ -203,12 +195,17 @@ QtWayland::xdg_toplevel::resize_edge QWaylandXdgSurface::Toplevel::convertToResi
+                 | ((edges & Qt::RightEdge) ? resize_edge_right : 0));
+ }
+ 
+-QWaylandXdgSurface::Popup::Popup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parent,
++QWaylandXdgSurface::Popup::Popup(QWaylandXdgSurface *xdgSurface, QWaylandWindow *parent,
+                                  QtWayland::xdg_positioner *positioner)
+-    : xdg_popup(xdgSurface->get_popup(parent->object(), positioner->object()))
+-    , m_xdgSurface(xdgSurface)
++    : m_xdgSurface(xdgSurface)
++    , m_parentXdgSurface(qobject_cast<QWaylandXdgSurface *>(parent->shellSurface()))
+     , m_parent(parent)
+ {
++
++    init(xdgSurface->get_popup(m_parentXdgSurface ? m_parentXdgSurface->object() : nullptr, positioner->object()));
++    if (m_parent) {
++        m_parent->addChildPopup(m_xdgSurface->window());
++    }
+ }
+ 
+ QWaylandXdgSurface::Popup::~Popup()
+@@ -216,10 +213,24 @@ QWaylandXdgSurface::Popup::~Popup()
+     if (isInitialized())
+         destroy();
+ 
++    if (m_parent) {
++        m_parent->removeChildPopup(m_xdgSurface->window());
++    }
++
+     if (m_grabbing) {
+         auto *shell = m_xdgSurface->m_shell;
+         Q_ASSERT(shell->m_topmostGrabbingPopup == this);
+-        shell->m_topmostGrabbingPopup = m_parent->m_popup;
++        shell->m_topmostGrabbingPopup = m_parentXdgSurface ? m_parentXdgSurface->m_popup : nullptr;
++        m_grabbing = false;
++
++        // Synthesize Qt enter/leave events for popup
++        QWindow *leave = nullptr;
++        if (m_xdgSurface && m_xdgSurface->window())
++            leave = m_xdgSurface->window()->window();
++        QWindowSystemInterface::handleLeaveEvent(leave);
++
++        if (QWindow *enter = QGuiApplication::topLevelAt(QCursor::pos()))
++            QWindowSystemInterface::handleEnterEvent(enter, enter->mapFromGlobal(QCursor::pos()), QCursor::pos());
+     }
+ }
+ 
+@@ -257,6 +268,7 @@ QWaylandXdgSurface::QWaylandXdgSurface(QWaylandXdgShell *shell, ::xdg_surface *s
+                 m_toplevel->set_parent(parentXdgSurface->m_toplevel->object());
+         }
+     }
++    setSizeHints();
+ }
+ 
+ QWaylandXdgSurface::~QWaylandXdgSurface()
+@@ -400,8 +412,6 @@ void QWaylandXdgSurface::setPopup(QWaylandWindow *parent)
+ {
+     Q_ASSERT(!m_toplevel && !m_popup);
+ 
+-    auto parentXdgSurface = static_cast<QWaylandXdgSurface *>(parent->shellSurface());
+-
+     auto positioner = new QtWayland::xdg_positioner(m_shell->create_positioner());
+     // set_popup expects a position relative to the parent
+     QPoint transientPos = m_window->geometry().topLeft(); // this is absolute
+@@ -414,8 +424,9 @@ void QWaylandXdgSurface::setPopup(QWaylandWindow *parent)
+     positioner->set_anchor(QtWayland::xdg_positioner::anchor_top_left);
+     positioner->set_gravity(QtWayland::xdg_positioner::gravity_bottom_right);
+     positioner->set_size(m_window->geometry().width(), m_window->geometry().height());
+-    m_popup = new Popup(this, parentXdgSurface, positioner);
++    m_popup = new Popup(this, parent, positioner);
+     positioner->destroy();
++
+     delete positioner;
+ }
+ 
+@@ -437,6 +448,23 @@ void QWaylandXdgSurface::setGrabPopup(QWaylandWindow *parent, QWaylandInputDevic
+     }
+     setPopup(parent);
+     m_popup->grab(device, serial);
++
++    // Synthesize Qt enter/leave events for popup
++    if (!parent)
++        return;
++    QWindow *current = QGuiApplication::topLevelAt(QCursor::pos());
++    QWindow *leave = parent->window();
++    if (current != leave)
++        return;
++
++    QWindowSystemInterface::handleLeaveEvent(leave);
++
++    QWindow *enter = nullptr;
++    if (m_popup && m_popup->m_xdgSurface && m_popup->m_xdgSurface->window())
++        enter = m_popup->m_xdgSurface->window()->window();
++
++    if (enter)
++        QWindowSystemInterface::handleEnterEvent(enter, enter->mapFromGlobal(QCursor::pos()), QCursor::pos());
+ }
+ 
+ void QWaylandXdgSurface::xdg_surface_configure(uint32_t serial)
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
+index 96785205..4b518f0a 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
+@@ -131,14 +131,15 @@ private:
+ 
+     class Popup : public QtWayland::xdg_popup {
+     public:
+-        Popup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parent, QtWayland::xdg_positioner *positioner);
++        Popup(QWaylandXdgSurface *xdgSurface, QWaylandWindow *parent, QtWayland::xdg_positioner *positioner);
+         ~Popup() override;
+ 
+         void grab(QWaylandInputDevice *seat, uint serial);
+         void xdg_popup_popup_done() override;
+ 
+         QWaylandXdgSurface *m_xdgSurface = nullptr;
+-        QWaylandXdgSurface *m_parent = nullptr;
++        QWaylandXdgSurface *m_parentXdgSurface = nullptr;
++        QWaylandWindow *m_parent = nullptr;
+         bool m_grabbing = false;
+     };
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
+index 8769d971..da0dd6a7 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
+@@ -69,20 +69,6 @@ QWaylandShellSurface *QWaylandXdgShellIntegration::createShellSurface(QWaylandWi
+     return m_xdgShell->getXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellIntegration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus)
+-{
+-    if (newFocus) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurface *>(newFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowActivated(newFocus);
+-    }
+-    if (oldFocus && qobject_cast<QWaylandXdgSurface *>(oldFocus->shellSurface())) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurface *>(oldFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowDeactivated(oldFocus);
+-    }
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
+index b6caa6c9..2f929f98 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
+@@ -65,7 +65,6 @@ public:
+     QWaylandXdgShellIntegration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShell> m_xdgShell;
+diff --git a/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp b/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
+index 526d0ef4..f50ccf30 100644
+--- a/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
++++ b/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
+@@ -39,7 +39,10 @@
+ 
+ #include "qwaylandinputmethodeventbuilder_p.h"
+ 
++#include <QBrush>
++#include <QGuiApplication>
+ #include <QInputMethod>
++#include <QPalette>
+ #include <QTextCharFormat>
+ 
+ #ifdef QT_BUILD_WAYLANDCOMPOSITOR_LIB
+@@ -81,32 +84,38 @@ void QWaylandInputMethodEventBuilder::addPreeditStyling(uint32_t index, uint32_t
+     QTextCharFormat format;
+ 
+     switch (style) {
+-    case 0:
+-    case 1:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_NONE:
++        break;
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_DEFAULT:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_UNDERLINE:
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-    case 2:
+-    case 3:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_ACTIVE:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_INACTIVE:
+         format.setFontWeight(QFont::Bold);
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-    case 4:
+-        format.setFontUnderline(true);
+-        format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+-        m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_HIGHLIGHT:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_SELECTION:
++        {
++            format.setFontUnderline(true);
++            format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
++            QPalette palette = qApp->palette();
++            format.setBackground(QBrush(palette.color(QPalette::Active, QPalette::Highlight)));
++            format.setForeground(QBrush(palette.color(QPalette::Active, QPalette::HighlightedText)));
++            m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
++        }
+         break;
+-    case 5:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_INCORRECT:
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::WaveUnderline);
+         format.setUnderlineColor(QColor(Qt::red));
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-//    case QtWayland::wl_text_input::preedit_style_selection:
+-//    case QtWayland::wl_text_input::preedit_style_none:
+     default:
+         break;
+     }
+@@ -153,7 +162,7 @@ QInputMethodEvent QWaylandInputMethodEventBuilder::buildPreedit(const QString &t
+ 
+     if (m_preeditCursor < 0) {
+         attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, 0, QVariant()));
+-    } else if (m_preeditCursor > 0) {
++    } else {
+         attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, indexFromWayland(text, m_preeditCursor), 1, QVariant()));
+     }
+ 
+diff --git a/qtwayland/src/shared/qwaylandmimehelper.cpp b/qtwayland/src/shared/qwaylandmimehelper.cpp
+index a5fdd34d..e2fe1928 100644
+--- a/qtwayland/src/shared/qwaylandmimehelper.cpp
++++ b/qtwayland/src/shared/qwaylandmimehelper.cpp
+@@ -60,7 +60,7 @@ QByteArray QWaylandMimeHelper::getByteArray(QMimeData *mimeData, const QString &
+             buf.open(QIODevice::ReadWrite);
+             QByteArray fmt = "BMP";
+             if (mimeType.startsWith(QLatin1String("image/"))) {
+-                QByteArray imgFmt = mimeType.mid(6).toUpper().toLatin1();
++                QByteArray imgFmt = mimeType.mid(6).toLower().toLatin1();
+                 if (QImageWriter::supportedImageFormats().contains(imgFmt))
+                     fmt = imgFmt;
+             }
+@@ -74,7 +74,7 @@ QByteArray QWaylandMimeHelper::getByteArray(QMimeData *mimeData, const QString &
+         QList<QUrl> urls = mimeData->urls();
+         for (int i = 0; i < urls.count(); ++i) {
+             content.append(urls.at(i).toEncoded());
+-            content.append('\n');
++            content.append("\r\n");
+         }
+     } else {
+         content = mimeData->data(mimeType);
+diff --git a/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp b/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
+index 1568b3b9..067410d0 100644
+--- a/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
++++ b/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
+@@ -35,7 +35,7 @@
+ 
+ using namespace MockCompositor;
+ 
+-constexpr int dataDeviceVersion = 1;
++constexpr int dataDeviceVersion = 3;
+ 
+ class DataDeviceCompositor : public DefaultCompositor {
+ public:
+diff --git a/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp b/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
+index 9312c2e5..2ea382f1 100644
+--- a/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
++++ b/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
+@@ -73,6 +73,7 @@ private slots:
+     void multiTouch();
+     void multiTouchUpAndMotionFrame();
+     void tapAndMoveInSameFrame();
++    void cancelTouch();
+ };
+ 
+ void tst_seatv5::bindsToSeat()
+@@ -646,5 +647,34 @@ void tst_seatv5::tapAndMoveInSameFrame()
+     QTRY_COMPARE(window.m_events.last().touchPoints.first().state(), Qt::TouchPointState::TouchPointReleased);
+ }
+ 
++void tst_seatv5::cancelTouch()
++{
++    TouchWindow window;
++    QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
++
++    exec([=] {
++        auto *t = touch();
++        auto *c = client();
++        t->sendDown(xdgToplevel()->surface(), {32, 32}, 1);
++        t->sendFrame(c);
++        t->sendCancel(c);
++        t->sendFrame(c);
++    });
++
++    QTRY_VERIFY(!window.m_events.empty());
++    {
++        auto e = window.m_events.takeFirst();
++        QCOMPARE(e.type, QEvent::TouchBegin);
++        QCOMPARE(e.touchPointStates, Qt::TouchPointPressed);
++        QCOMPARE(e.touchPoints.length(), 1);
++        QCOMPARE(e.touchPoints.first().pos(), QPointF(32-window.frameMargins().left(), 32-window.frameMargins().top()));
++    }
++    {
++        auto e = window.m_events.takeFirst();
++        QCOMPARE(e.type, QEvent::TouchCancel);
++        QCOMPARE(e.touchPoints.length(), 0);
++    }
++}
++
+ QCOMPOSITOR_TEST_MAIN(tst_seatv5)
+ #include "tst_seatv5.moc"
+diff --git a/qtwayland/tests/auto/client/shared/corecompositor.cpp b/qtwayland/tests/auto/client/shared/corecompositor.cpp
+index 5c6c83ba..fa9b7662 100644
+--- a/qtwayland/tests/auto/client/shared/corecompositor.cpp
++++ b/qtwayland/tests/auto/client/shared/corecompositor.cpp
+@@ -27,6 +27,7 @@
+ ****************************************************************************/
+ 
+ #include "corecompositor.h"
++#include <thread>
+ 
+ namespace MockCompositor {
+ 
+diff --git a/qtwayland/tests/auto/client/shared/coreprotocol.cpp b/qtwayland/tests/auto/client/shared/coreprotocol.cpp
+index 0d988521..d1a2e7cb 100644
+--- a/qtwayland/tests/auto/client/shared/coreprotocol.cpp
++++ b/qtwayland/tests/auto/client/shared/coreprotocol.cpp
+@@ -451,6 +451,13 @@ void Touch::sendFrame(wl_client *client)
+         send_frame(r->handle);
+ }
+ 
++void Touch::sendCancel(wl_client *client)
++{
++    const auto touchResources = resourceMap().values(client);
++    for (auto *r : touchResources)
++        send_cancel(r->handle);
++}
++
+ uint Keyboard::sendEnter(Surface *surface)
+ {
+     auto serial = m_seat->m_compositor->nextSerial();
+diff --git a/qtwayland/tests/auto/client/shared/coreprotocol.h b/qtwayland/tests/auto/client/shared/coreprotocol.h
+index a1af137a..210d8ddb 100644
+--- a/qtwayland/tests/auto/client/shared/coreprotocol.h
++++ b/qtwayland/tests/auto/client/shared/coreprotocol.h
+@@ -158,7 +158,7 @@ class WlCompositor : public Global, public QtWaylandServer::wl_compositor
+ {
+     Q_OBJECT
+ public:
+-    explicit WlCompositor(CoreCompositor *compositor, int version = 3)
++    explicit WlCompositor(CoreCompositor *compositor, int version = 4)
+         : QtWaylandServer::wl_compositor(compositor->m_display, version)
+         , m_compositor(compositor)
+     {}
+@@ -364,6 +364,7 @@ public:
+     uint sendUp(wl_client *client, int id);
+     void sendMotion(wl_client *client, const QPointF &position, int id);
+     void sendFrame(wl_client *client);
++    void sendCancel(wl_client *client);
+ 
+     Seat *m_seat = nullptr;
+ };
+diff --git a/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp b/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
+index a415cbf5..b1d3d07d 100644
+--- a/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
++++ b/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
+@@ -342,7 +342,7 @@ Compositor::Compositor(MockCompositor *mockCompositor)
+         exit(EXIT_FAILURE);
+     }
+ 
+-    wl_global_create(m_display, &wl_compositor_interface, 1, this, bindCompositor);
++    wl_global_create(m_display, &wl_compositor_interface, 4, this, bindCompositor);
+ 
+     m_data_device_manager.reset(new DataDeviceManager(this, m_display));
+ 
+diff --git a/qtwayland/tests/auto/client/shared_old/mocksurface.cpp b/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
+index e9df5f90..c3246e4a 100644
+--- a/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
++++ b/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
+@@ -125,6 +125,16 @@ void Surface::surface_damage(Resource *resource,
+     Q_UNUSED(height);
+ }
+ 
++void Surface::surface_damage_buffer(Resource *resource,
++                                    int32_t x, int32_t y, int32_t width, int32_t height)
++{
++    Q_UNUSED(resource);
++    Q_UNUSED(x);
++    Q_UNUSED(y);
++    Q_UNUSED(width);
++    Q_UNUSED(height);
++}
++
+ void Surface::surface_frame(Resource *resource,
+                             uint32_t callback)
+ {
+diff --git a/qtwayland/tests/auto/client/shared_old/mocksurface.h b/qtwayland/tests/auto/client/shared_old/mocksurface.h
+index 949dc23d..d176837e 100644
+--- a/qtwayland/tests/auto/client/shared_old/mocksurface.h
++++ b/qtwayland/tests/auto/client/shared_old/mocksurface.h
+@@ -65,6 +65,8 @@ protected:
+                         struct wl_resource *buffer, int x, int y) override;
+     void surface_damage(Resource *resource,
+                         int32_t x, int32_t y, int32_t width, int32_t height) override;
++    void surface_damage_buffer(Resource *resource,
++                               int32_t x, int32_t y, int32_t width, int32_t height) override;
+     void surface_frame(Resource *resource,
+                        uint32_t callback) override;
+     void surface_commit(Resource *resource) override;
+diff --git a/qtwayland/tests/auto/client/surface/tst_surface.cpp b/qtwayland/tests/auto/client/surface/tst_surface.cpp
+index 95e4e609..60c672ce 100644
+--- a/qtwayland/tests/auto/client/surface/tst_surface.cpp
++++ b/qtwayland/tests/auto/client/surface/tst_surface.cpp
+@@ -129,6 +129,10 @@ void tst_surface::waitForFrameCallbackGl()
+     // Make sure we follow frame callbacks for some frames
+     for (int i = 0; i < 5; ++i) {
+         xdgPingAndWaitForPong(); // Make sure things have happened on the client
++        if (!qEnvironmentVariableIntValue("QT_WAYLAND_DISABLE_WINDOWDECORATION") && i == 0) {
++            QCOMPARE(bufferSpy.count(), 1);
++            bufferSpy.removeFirst();
++        }
+         exec([&] {
+             QVERIFY(bufferSpy.empty()); // Make sure no extra buffers have arrived
+             QVERIFY(!xdgToplevel()->surface()->m_waitingFrameCallbacks.empty());
+diff --git a/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp b/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
+index 2277bbb8..747875b4 100644
+--- a/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
++++ b/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
+@@ -31,6 +31,7 @@
+ #include <QtGui/QOpenGLWindow>
+ #include <QtGui/qpa/qplatformnativeinterface.h>
+ #include <QtWaylandClient/private/wayland-wayland-client-protocol.h>
++#include <QtWaylandClient/private/qwaylandwindow_p.h>
+ 
+ using namespace MockCompositor;
+ 
+@@ -45,6 +46,7 @@ private slots:
+     void configureStates();
+     void popup();
+     void tooltipOnPopup();
++    void tooltipAndSiblingPopup();
+     void switchPopups();
+     void hidePopupParent();
+     void pongs();
+@@ -138,6 +140,7 @@ void tst_xdgshell::configureSize()
+ 
+ void tst_xdgshell::configureStates()
+ {
++    QVERIFY(qputenv("QT_WAYLAND_FRAME_CALLBACK_TIMEOUT", "0"));
+     QRasterWindow window;
+     window.resize(64, 48);
+     window.show();
+@@ -154,9 +157,12 @@ void tst_xdgshell::configureStates()
+     // Toplevel windows don't know their position on xdg-shell
+ //    QCOMPARE(window.frameGeometry().topLeft(), QPoint()); // TODO: this doesn't currently work when window decorations are enabled
+ 
+-//    QEXPECT_FAIL("", "configure has already been acked, we shouldn't have to wait for isActive", Continue);
+-//    QVERIFY(window.isActive());
+-    QTRY_VERIFY(window.isActive()); // Just make sure it eventually get's set correctly
++    // window.windowstate() is driven by keyboard focus, however for decorations we want to follow
++    // XDGShell this is internal to QtWayland so it is queried directly
++    auto waylandWindow = static_cast<QtWaylandClient::QWaylandWindow *>(window.handle());
++    Q_ASSERT(waylandWindow);
++    QTRY_VERIFY(waylandWindow->windowStates().testFlag(
++            Qt::WindowActive)); // Just make sure it eventually get's set correctly
+ 
+     const QSize screenSize(640, 480);
+     const uint maximizedSerial = exec([=] {
+@@ -186,6 +192,7 @@ void tst_xdgshell::configureStates()
+     QCOMPARE(window.windowStates(), Qt::WindowNoState);
+     QCOMPARE(window.frameGeometry().size(), windowedSize);
+ //    QCOMPARE(window.frameGeometry().topLeft(), QPoint()); // TODO: this doesn't currently work when window decorations are enabled
++    QVERIFY(qunsetenv("QT_WAYLAND_FRAME_CALLBACK_TIMEOUT"));
+ }
+ 
+ void tst_xdgshell::popup()
+@@ -340,6 +347,92 @@ void tst_xdgshell::tooltipOnPopup()
+     QCOMPOSITOR_TRY_COMPARE(xdgPopup(0), nullptr);
+ }
+ 
++void tst_xdgshell::tooltipAndSiblingPopup()
++{
++    class ToolTip : public QRasterWindow {
++    public:
++        explicit ToolTip(QWindow *parent) {
++            setTransientParent(parent);
++            setFlags(Qt::ToolTip);
++            resize(100, 100);
++            show();
++        }
++        void mousePressEvent(QMouseEvent *event) override {
++            QRasterWindow::mousePressEvent(event);
++            m_popup = new QRasterWindow;
++            m_popup->setTransientParent(transientParent());
++            m_popup->setFlags(Qt::Popup);
++            m_popup->resize(100, 100);
++            m_popup->show();
++        }
++
++        QRasterWindow *m_popup = nullptr;
++    };
++
++    class Window : public QRasterWindow {
++    public:
++        void mousePressEvent(QMouseEvent *event) override {
++            QRasterWindow::mousePressEvent(event);
++            m_tooltip = new ToolTip(this);
++        }
++        ToolTip *m_tooltip = nullptr;
++    };
++
++    Window window;
++    window.resize(200, 200);
++    window.show();
++
++    QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
++    exec([=] { xdgToplevel()->sendCompleteConfigure(); });
++    QCOMPOSITOR_TRY_VERIFY(xdgToplevel()->m_xdgSurface->m_committedConfigureSerial);
++
++    exec([=] {
++        auto *surface = xdgToplevel()->surface();
++        auto *p = pointer();
++        auto *c = client();
++        p->sendEnter(surface, {100, 100});
++        p->sendFrame(c);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_pressed);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_released);
++        p->sendFrame(c);
++        p->sendLeave(surface);
++        p->sendFrame(c);
++    });
++
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup());
++    exec([=] { xdgPopup()->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup()->m_xdgSurface->m_committedConfigureSerial);
++    QCOMPOSITOR_TRY_VERIFY(!xdgPopup()->m_grabbed);
++
++    exec([=] {
++        auto *surface = xdgPopup()->surface();
++        auto *p = pointer();
++        auto *c = client();
++        p->sendEnter(surface, {100, 100});
++        p->sendFrame(c);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_pressed);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_released);
++        p->sendFrame(c);
++    });
++
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1));
++    exec([=] { xdgPopup(1)->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1)->m_xdgSurface->m_committedConfigureSerial);
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1)->m_grabbed);
++
++    // Close the middle tooltip (it should not close the sibling popup)
++    window.m_tooltip->close();
++
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(1), nullptr);
++    // Verify the remaining xdg surface is a grab popup..
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(0));
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(0)->m_grabbed);
++
++    window.m_tooltip->m_popup->close();
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(1), nullptr);
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(0), nullptr);
++}
++
+ // QTBUG-65680
+ void tst_xdgshell::switchPopups()
+ {
+@@ -505,7 +598,7 @@ void tst_xdgshell::minMaxSize()
+     window.show();
+     QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
+ 
+-    exec([=] { xdgToplevel()->sendCompleteConfigure(); });
++    // we don't roundtrip with our configuration the initial commit should be correct
+ 
+     QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.minSize, QSize(100, 100));
+     QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.maxSize, QSize(1000, 1000));
+Submodule qtwebchannel 618422ee..f8949655:
+diff --git a/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp b/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
+index 536eb5c..898d769 100644
+--- a/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
++++ b/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
+@@ -186,8 +186,6 @@ Q_DECLARE_TYPEINFO(OverloadResolutionCandidate, Q_MOVABLE_TYPE);
+ QMetaObjectPublisher::QMetaObjectPublisher(QWebChannel *webChannel)
+     : QObject(webChannel)
+     , webChannel(webChannel)
+-    , signalHandler(this)
+-    , clientIsIdle(false)
+     , blockUpdates(false)
+     , propertyUpdatesInitialized(false)
+ {
+@@ -301,17 +299,17 @@ QJsonObject QMetaObjectPublisher::classInfoForObject(const QObject *object, QWeb
+     return data;
+ }
+ 
+-void QMetaObjectPublisher::setClientIsIdle(bool isIdle)
++void QMetaObjectPublisher::setClientIsIdle(bool isIdle, QWebChannelAbstractTransport *transport)
+ {
+-    if (clientIsIdle == isIdle) {
+-        return;
+-    }
+-    clientIsIdle = isIdle;
+-    if (!isIdle && timer.isActive()) {
+-        timer.stop();
+-    } else if (isIdle && !timer.isActive()) {
+-        timer.start(PROPERTY_UPDATE_INTERVAL, this);
+-    }
++    transportState[transport].clientIsIdle = isIdle;
++    if (isIdle)
++        sendEnqueuedPropertyUpdates(transport);
++}
++
++bool QMetaObjectPublisher::isClientIdle(QWebChannelAbstractTransport *transport)
++{
++    auto found = transportState.find(transport);
++    return found != transportState.end() && found.value().clientIsIdle;
+ }
+ 
+ QJsonObject QMetaObjectPublisher::initializeClient(QWebChannelAbstractTransport *transport)
+@@ -333,6 +331,7 @@ QJsonObject QMetaObjectPublisher::initializeClient(QWebChannelAbstractTransport
+ 
+ void QMetaObjectPublisher::initializePropertyUpdates(const QObject *const object, const QJsonObject &objectInfo)
+ {
++    auto *signalHandler = signalHandlerFor(object);
+     foreach (const QJsonValue &propertyInfoVar, objectInfo[KEY_PROPERTIES].toArray()) {
+         const QJsonArray &propertyInfo = propertyInfoVar.toArray();
+         if (propertyInfo.size() < 2) {
+@@ -353,19 +352,19 @@ void QMetaObjectPublisher::initializePropertyUpdates(const QObject *const object
+ 
+         // Only connect for a property update once
+         if (connectedProperties.isEmpty()) {
+-            signalHandler.connectTo(object, signalIndex);
++            signalHandler->connectTo(object, signalIndex);
+         }
+ 
+         connectedProperties.insert(propertyIndex);
+     }
+ 
+     // also always connect to destroyed signal
+-    signalHandler.connectTo(object, s_destroyedSignalIndex);
++    signalHandler->connectTo(object, s_destroyedSignalIndex);
+ }
+ 
+ void QMetaObjectPublisher::sendPendingPropertyUpdates()
+ {
+-    if (blockUpdates || !clientIsIdle || pendingPropertyUpdates.isEmpty()) {
++    if (blockUpdates) {
+         return;
+     }
+ 
+@@ -415,18 +414,19 @@ void QMetaObjectPublisher::sendPendingPropertyUpdates()
+ 
+     // data does not contain specific updates
+     if (!data.isEmpty()) {
+-        setClientIsIdle(false);
+-
+         message[KEY_DATA] = data;
+-        broadcastMessage(message);
++        enqueueBroadcastMessage(message);
+     }
+ 
+     // send every property update which is not supposed to be broadcasted
+     const QHash<QWebChannelAbstractTransport*, QJsonArray>::const_iterator suend = specificUpdates.constEnd();
+     for (QHash<QWebChannelAbstractTransport*, QJsonArray>::const_iterator it = specificUpdates.constBegin(); it != suend; ++it) {
+         message[KEY_DATA] = it.value();
+-        it.key()->sendMessage(message);
++        enqueueMessage(message, it.key());
+     }
++
++    for (auto state = transportState.begin(); state != transportState.end(); ++state)
++        sendEnqueuedPropertyUpdates(state.key());
+ }
+ 
+ QVariant QMetaObjectPublisher::invokeMethod(QObject *const object, const QMetaMethod &method,
+@@ -572,7 +572,7 @@ void QMetaObjectPublisher::signalEmitted(const QObject *object, const int signal
+         }
+     } else {
+         pendingPropertyUpdates[object][signalIndex] = arguments;
+-        if (clientIsIdle && !blockUpdates && !timer.isActive()) {
++        if (!blockUpdates && !timer.isActive()) {
+             timer.start(PROPERTY_UPDATE_INTERVAL, this);
+         }
+     }
+@@ -590,7 +590,7 @@ void QMetaObjectPublisher::objectDestroyed(const QObject *object)
+     // only remove from handler when we initialized the property updates
+     // cf: https://bugreports.qt.io/browse/QTBUG-60250
+     if (propertyUpdatesInitialized) {
+-        signalHandler.remove(object);
++        signalHandlerFor(object)->remove(object);
+         signalToPropertyMap.remove(object);
+     }
+     pendingPropertyUpdates.remove(object);
+@@ -852,6 +852,52 @@ void QMetaObjectPublisher::broadcastMessage(const QJsonObject &message) const
+     }
+ }
+ 
++void QMetaObjectPublisher::enqueueBroadcastMessage(const QJsonObject &message)
++{
++    if (webChannel->d_func()->transports.isEmpty()) {
++        qWarning("QWebChannel is not connected to any transports, cannot send message: %s",
++                 QJsonDocument(message).toJson().constData());
++        return;
++    }
++
++    for (auto *transport : webChannel->d_func()->transports) {
++        auto &state = transportState[transport];
++        state.queuedMessages.append(message);
++    }
++}
++
++void QMetaObjectPublisher::enqueueMessage(const QJsonObject &message,
++                                          QWebChannelAbstractTransport *transport)
++{
++    auto &state = transportState[transport];
++    state.queuedMessages.append(message);
++}
++
++void QMetaObjectPublisher::sendEnqueuedPropertyUpdates(QWebChannelAbstractTransport *transport)
++{
++    auto found = transportState.find(transport);
++    if (found != transportState.end() && found.value().clientIsIdle
++        && !found.value().queuedMessages.isEmpty()) {
++
++        // If the client is connected with an in-process transport, it can
++        // happen that a message triggers a subsequent property change. In
++        // that case, we need to ensure that the queued messages have already
++        // been cleared; otherwise the recursive call will send everythig again.
++        // Case in point: The qmlwebchannel tests fail if we don't clear the
++        // queued messages before sending them out.
++        // For that same reason set the client to "busy" (aka non-idle) just
++        // right before sending out the messages; otherwise a potential
++        // "Idle" type message will not correctly restore the Idle state.
++        const auto messages = std::move(found.value().queuedMessages);
++        Q_ASSERT(found.value().queuedMessages.isEmpty());
++        found.value().clientIsIdle = false;
++
++        for (const auto &message : messages) {
++            transport->sendMessage(message);
++        }
++    }
++}
++
+ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannelAbstractTransport *transport)
+ {
+     if (!webChannel->d_func()->transports.contains(transport)) {
+@@ -866,7 +912,7 @@ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannel
+ 
+     const MessageType type = toType(message.value(KEY_TYPE));
+     if (type == TypeIdle) {
+-        setClientIsIdle(true);
++        setClientIsIdle(true, transport);
+     } else if (type == TypeInit) {
+         if (!message.contains(KEY_ID)) {
+             qWarning("JSON message object is missing the id property: %s",
+@@ -913,9 +959,9 @@ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannel
+                 return;
+             transport->sendMessage(createResponse(message.value(KEY_ID), wrapResult(result, transport)));
+         } else if (type == TypeConnectToSignal) {
+-            signalHandler.connectTo(object, message.value(KEY_SIGNAL).toInt(-1));
++            signalHandlerFor(object)->connectTo(object, message.value(KEY_SIGNAL).toInt(-1));
+         } else if (type == TypeDisconnectFromSignal) {
+-            signalHandler.disconnectFrom(object, message.value(KEY_SIGNAL).toInt(-1));
++            signalHandlerFor(object)->disconnectFrom(object, message.value(KEY_SIGNAL).toInt(-1));
+         } else if (type == TypeSetProperty) {
+             setProperty(object, message.value(KEY_PROPERTY).toInt(-1),
+                         message.value(KEY_VALUE));
+@@ -931,6 +977,7 @@ void QMetaObjectPublisher::setBlockUpdates(bool block)
+     blockUpdates = block;
+ 
+     if (!blockUpdates) {
++        timer.start(PROPERTY_UPDATE_INTERVAL, this);
+         sendPendingPropertyUpdates();
+     } else if (timer.isActive()) {
+         timer.stop();
+@@ -948,4 +995,15 @@ void QMetaObjectPublisher::timerEvent(QTimerEvent *event)
+     }
+ }
+ 
++SignalHandler<QMetaObjectPublisher> *QMetaObjectPublisher::signalHandlerFor(const QObject *object)
++{
++    auto thread = object->thread();
++    auto it = signalHandlers.find(thread);
++    if (it == signalHandlers.end()) {
++        it = signalHandlers.emplace(thread, this).first;
++        it->second.moveToThread(thread);
++    }
++    return &it->second;
++}
++
+ QT_END_NAMESPACE
+diff --git a/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h b/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
+index bbd9875..4713ef1 100644
+--- a/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
++++ b/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
+@@ -59,6 +59,9 @@
+ #include <QBasicTimer>
+ #include <QPointer>
+ #include <QJsonObject>
++#include <QQueue>
++
++#include <unordered_map>
+ 
+ #include "qwebchannelglobal.h"
+ 
+@@ -109,17 +112,36 @@ public:
+      */
+     void broadcastMessage(const QJsonObject &message) const;
+ 
++    /**
++     * Enqueue the given @p message to all known transports.
++     */
++    void enqueueBroadcastMessage(const QJsonObject &message);
++
++    /**
++     * Enqueue the given @p message to @p transport.
++     */
++    void enqueueMessage(const QJsonObject &message, QWebChannelAbstractTransport *transport);
++
++    /**
++     * If client for given @p transport is idle, send queued messaged to @p transport and then mark
++     * the client as not idle.
++     */
++    void sendEnqueuedPropertyUpdates(QWebChannelAbstractTransport *transport);
++
+     /**
+      * Serialize the QMetaObject of @p object and return it in JSON form.
+      */
+     QJsonObject classInfoForObject(const QObject *object, QWebChannelAbstractTransport *transport);
+ 
+     /**
+-     * Set the client to idle or busy, based on the value of @p isIdle.
+-     *
+-     * When the value changed, start/stop the property update timer accordingly.
++     * Set the client to idle or busy for a single @p transport, based on the value of @p isIdle.
++     */
++    void setClientIsIdle(bool isIdle, QWebChannelAbstractTransport *transport);
++
++    /**
++     * Check that client is idle for @p transport.
+      */
+-    void setClientIsIdle(bool isIdle);
++    bool isClientIdle(QWebChannelAbstractTransport *transport);
+ 
+     /**
+      * Initialize clients by sending them the class information of the registered objects.
+@@ -272,10 +294,18 @@ private:
+     friend class TestWebChannel;
+ 
+     QWebChannel *webChannel;
+-    SignalHandler<QMetaObjectPublisher> signalHandler;
++    std::unordered_map<const QThread*, SignalHandler<QMetaObjectPublisher>> signalHandlers;
++    SignalHandler<QMetaObjectPublisher> *signalHandlerFor(const QObject *object);
+ 
+-    // true when the client is idle, false otherwise
+-    bool clientIsIdle;
++    struct TransportState
++    {
++        TransportState() : clientIsIdle(false) { }
++        // true when the client is idle, false otherwise
++        bool clientIsIdle;
++        // messages to send
++        QQueue<QJsonObject> queuedMessages;
++    };
++    QHash<QWebChannelAbstractTransport *, TransportState> transportState;
+ 
+     // true when no property updates should be sent, false otherwise
+     bool blockUpdates;
+diff --git a/qtwebchannel/src/webchannel/signalhandler_p.h b/qtwebchannel/src/webchannel/signalhandler_p.h
+index 27afadb..d77373c 100644
+--- a/qtwebchannel/src/webchannel/signalhandler_p.h
++++ b/qtwebchannel/src/webchannel/signalhandler_p.h
+@@ -56,6 +56,7 @@
+ #include <QVector>
+ #include <QMetaMethod>
+ #include <QDebug>
++#include <QThread>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -71,6 +72,7 @@ static const int s_destroyedSignalIndex = QObject::staticMetaObject.indexOfMetho
+ template<class Receiver>
+ class SignalHandler : public QObject
+ {
++    Q_DISABLE_COPY(SignalHandler)
+ public:
+     SignalHandler(Receiver *receiver, QObject *parent = 0);
+ 
+@@ -268,6 +270,7 @@ int SignalHandler<Receiver>::qt_metacall(QMetaObject::Call call, int methodId, v
+     if (call == QMetaObject::InvokeMetaMethod) {
+         const QObject *object = sender();
+         Q_ASSERT(object);
++        Q_ASSERT(QThread::currentThread() == object->thread());
+         Q_ASSERT(senderSignalIndex() == methodId);
+         Q_ASSERT(m_connectionsCounter.contains(object));
+         Q_ASSERT(m_connectionsCounter.value(object).contains(methodId));
+diff --git a/qtwebchannel/tests/auto/qml/testwebchannel.cpp b/qtwebchannel/tests/auto/qml/testwebchannel.cpp
+index 9891687..3ca81c2 100644
+--- a/qtwebchannel/tests/auto/qml/testwebchannel.cpp
++++ b/qtwebchannel/tests/auto/qml/testwebchannel.cpp
+@@ -46,7 +46,11 @@ TestWebChannel::~TestWebChannel()
+ 
+ bool TestWebChannel::clientIsIdle() const
+ {
+-    return QWebChannel::d_func()->publisher->clientIsIdle;
++    for (auto *transport : QWebChannel::d_func()->transports) {
++        if (QWebChannel::d_func()->publisher->isClientIdle(transport))
++            return true;
++    }
++    return false;
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp b/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
+index 181da9e..37f989a 100644
+--- a/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
++++ b/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
+@@ -785,7 +785,7 @@ void TestWebChannel::testTransportWrapObjectProperties()
+     DummyTransport *dummyTransport = new DummyTransport(this);
+     channel.connectTo(dummyTransport);
+     channel.d_func()->publisher->initializeClient(dummyTransport);
+-    channel.d_func()->publisher->setClientIsIdle(true);
++    channel.d_func()->publisher->setClientIsIdle(true, dummyTransport);
+ 
+     QCOMPARE(channel.d_func()->publisher->transportedWrappedObjects.size(), 0);
+ 
+@@ -943,8 +943,6 @@ void TestWebChannel::testInfiniteRecursion()
+ 
+ void TestWebChannel::testAsyncObject()
+ {
+-    QSKIP("This test is broken. See QTBUG-80729");
+-
+     QWebChannel channel;
+     channel.connectTo(m_dummyTransport);
+ 
+@@ -990,6 +988,50 @@ void TestWebChannel::testAsyncObject()
+     thread.wait();
+ }
+ 
++void TestWebChannel::testPropertyMultipleTransports()
++{
++    DummyTransport transport1;
++    DummyTransport transport2;
++
++    QWebChannel channel;
++    QMetaObjectPublisher *publisher = channel.d_func()->publisher;
++
++    TestObject testObj;
++    testObj.setObjectName("testObject");
++    channel.registerObject(testObj.objectName(), &testObj);
++    channel.connectTo(&transport1);
++    channel.connectTo(&transport2);
++
++    testObj.setProp("Hello");
++
++    publisher->initializeClient(&transport1);
++    publisher->initializeClient(&transport2);
++    publisher->setClientIsIdle(true, &transport1);
++    QCOMPARE(publisher->isClientIdle(&transport1), true);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++    QVERIFY(transport1.messagesSent().isEmpty());
++    QVERIFY(transport2.messagesSent().isEmpty());
++
++    testObj.setProp("World");
++    QTRY_COMPARE_WITH_TIMEOUT(transport1.messagesSent().size(), 1u, 2000);
++    QCOMPARE(transport2.messagesSent().size(), 0u);
++    publisher->setClientIsIdle(true, &transport2);
++    QTRY_COMPARE_WITH_TIMEOUT(transport2.messagesSent().size(), 1u, 2000);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++
++    testObj.setProp("!!!");
++    publisher->setClientIsIdle(true, &transport2);
++    QCOMPARE(publisher->isClientIdle(&transport2), true);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QTRY_COMPARE_WITH_TIMEOUT(transport2.messagesSent().size(), 2u, 2000);
++    QCOMPARE(transport1.messagesSent().size(), 1u);
++    publisher->setClientIsIdle(true, &transport1);
++    QTRY_COMPARE_WITH_TIMEOUT(transport1.messagesSent().size(), 2u, 2000);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++}
++
+ class FunctionWrapper : public QObject
+ {
+     Q_OBJECT
+@@ -1082,7 +1124,7 @@ void TestWebChannel::benchInitializeClients()
+ 
+         publisher->propertyUpdatesInitialized = false;
+         publisher->signalToPropertyMap.clear();
+-        publisher->signalHandler.clear();
++        publisher->signalHandlers.clear();
+     }
+ }
+ 
+@@ -1107,7 +1149,7 @@ void TestWebChannel::benchPropertyUpdates()
+             obj->change();
+         }
+ 
+-        channel.d_func()->publisher->clientIsIdle = true;
++        channel.d_func()->publisher->setClientIsIdle(true, m_dummyTransport);
+         channel.d_func()->publisher->sendPendingPropertyUpdates();
+     }
+ }
+diff --git a/qtwebchannel/tests/auto/webchannel/tst_webchannel.h b/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
+index eae21f4..dd4e690 100644
+--- a/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
++++ b/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
+@@ -348,6 +348,7 @@ private slots:
+     void testJsonToVariant();
+     void testInfiniteRecursion();
+     void testAsyncObject();
++    void testPropertyMultipleTransports();
+     void testDeletionDuringMethodInvocation_data();
+     void testDeletionDuringMethodInvocation();
+ 
+Submodule qtwebengine f328054d...38e0df6c (commits not present)
+Submodule qtwebsockets 65850954..63fb8da1:
+diff --git a/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp b/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
+index 2affdd5..95f1194 100644
+--- a/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
++++ b/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
+@@ -273,6 +273,7 @@ void QWebSocketDataProcessor::clear()
+     if (!m_pConverterState)
+         m_pConverterState = new QTextCodec::ConverterState(QTextCodec::ConvertInvalidToNull |
+                                                            QTextCodec::IgnoreHeader);
++    frame.clear();
+ }
+ 
+ /*!
+diff --git a/qtwebsockets/src/websockets/qwebsocketprotocol.cpp b/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
+index df87a93..d0465f1 100644
+--- a/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
++++ b/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
+@@ -210,7 +210,7 @@ void QWebSocketProtocol::mask(char *payload, quint64 size, quint32 maskingKey)
+                             quint8((maskingKey & 0x0000FF00u) >> 8),
+                             quint8((maskingKey & 0x000000FFu))
+                           };
+-    int i = 0;
++    quint64 i = 0;
+     while (size-- > 0)
+         *payload++ ^= mask[i++ % 4];
+ }
diff --git a/srcpkgs/qt5/template b/srcpkgs/qt5/template
index a79d25e69da8..6dddce7f3e46 100644
--- a/srcpkgs/qt5/template
+++ b/srcpkgs/qt5/template
@@ -2,11 +2,11 @@
 #
 # revbump libqtxdg after bumping patch version
 pkgname=qt5
-version=5.15.7+20221119
+version=5.15.8
+revision=1
+build_style=meta
 # commit f8c9fb304bc3e53b3aa07f962cd74e9160decccc
 # base repo: https://invent.kde.org/qt/qt/qt5
-revision=5
-build_style=meta
 hostmakedepends="cmake clang flex perl glib-devel pkg-config
  python re2c ruby which"
 makedepends="SDL2-devel Vulkan-Headers alsa-lib-devel double-conversion-devel
@@ -29,8 +29,9 @@ homepage="https://qt.io/"
 # tarball is generated with `git archive-all qt5-$version.tar.gz`
 # to keep the size smaller qtwebengine, qtwebview, qtdocgallery, qtactiveqt and qtpim
 # can be marked with the export-ignore attribute
-distfiles="https://void.johnnynator.dev/distfiles/qt5-${version}.tar.gz"
-checksum=9d57af471c78029a362276b7c99108ea009f511bb9ba6ff6cb884f6ddd255e9f
+#distfiles="https://void.johnnynator.dev/distfiles/qt5-${version}.tar.gz"
+distfiles="https://download.qt.io/archive/qt/5.15/${version}/single/qt-everywhere-opensource-src-${version}.tar.xz"
+checksum=776a9302c336671f9406a53bd30b8e36f825742b2ec44a57c08217bff0fa86b9
 python_version=2 #unverified
 replaces="qt5-doc<5.6.0 qt5-quick1<5.6.0 qt5-quick1-devel<5.6.0 qt5-webkit<5.6.0 qt5-webkit-devel<5.6.0
  qt5-enginio<5.7.1 qt5-enginio-devel<5.7.1 qt5-plugin-gtk<5.7.1 qt5-canvas3d<5.13.0"
@@ -250,7 +251,6 @@ do_configure() {
 	# opts+=" -v"
 	opts+=" -skip qtwebengine"
 	opts+=" -skip qtwebview"
-	opts+=" -skip qtdocgallery"
 	opts+=" -skip qtpim"
 	opts+=" -skip qtsystems"
 	opts+=" -skip qtspeech"

From aa3bf6758e6e52ab23b3d0964e7daac9fb007c81 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 075/116] qtav: revbump for ffmpeg4-4.4.3

---
 srcpkgs/qtav/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtav/template b/srcpkgs/qtav/template
index 34c30b2c0c78..2d00ad104355 100644
--- a/srcpkgs/qtav/template
+++ b/srcpkgs/qtav/template
@@ -1,10 +1,10 @@
 # Template file for 'qtav'
 pkgname=qtav
 version=1.13.0
-revision=1
+revision=2
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel libass-devel libopenal-devel
+makedepends="ffmpeg4-devel libass-devel libopenal-devel
  libva-glx-devel libXv-devel pulseaudio-devel
  qt5-declarative-devel qt5-svg-devel
  qt5-quickcontrols"

From e4f5f52e605a8354e10485185f77551337b6f4ef Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 076/116] qtox: revbump for ffmpeg-6.0

---
 srcpkgs/qtox/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qtox/template b/srcpkgs/qtox/template
index 16019d7eaec9..5cea0b11b697 100644
--- a/srcpkgs/qtox/template
+++ b/srcpkgs/qtox/template
@@ -1,7 +1,7 @@
 # Template file for 'qtox'
 pkgname=qtox
 version=1.17.6
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DUPDATE_CHECK=OFF
  -DGIT_DESCRIBE=${version}

From ef6f3c6f2aba286f275d5667f14fed1ee95f2d78 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 077/116] retroarch: revbump for ffmpeg-6.0

---
 srcpkgs/retroarch/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroarch/template b/srcpkgs/retroarch/template
index 28016aa0129e..20a1415913be 100644
--- a/srcpkgs/retroarch/template
+++ b/srcpkgs/retroarch/template
@@ -1,7 +1,7 @@
 # Template file for 'retroarch'
 pkgname=retroarch
 version=1.15.0
-revision=1
+revision=2
 build_style=configure
 configure_args="--prefix=/usr --sysconfdir=/etc --enable-networking
  --enable-udev --disable-builtinflac --disable-builtinglslang

From 88209d19bb877066af01ee66c5a43d80f6e7f7f8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 078/116] scrcpy: revbump for ffmpeg-6.0

---
 srcpkgs/scrcpy/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/scrcpy/template b/srcpkgs/scrcpy/template
index ee6e698e387f..8ada5ca4323f 100644
--- a/srcpkgs/scrcpy/template
+++ b/srcpkgs/scrcpy/template
@@ -1,7 +1,7 @@
 # Template file for 'scrcpy'
 pkgname=scrcpy
 version=2.0
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcompile_server=false
  -Dprebuilt_server=/usr/share/scrcpy/scrcpy-server-v${version}"

From 0cd95219b1ffd70a8ef3091bbad9606f5a1d5fe5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 079/116] spek-alternative: revbump for ffmpeg4-4.4.3

---
 srcpkgs/spek-alternative/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/spek-alternative/template b/srcpkgs/spek-alternative/template
index d65086b8f008..05246f1b8d0c 100644
--- a/srcpkgs/spek-alternative/template
+++ b/srcpkgs/spek-alternative/template
@@ -1,11 +1,11 @@
 # Template file for 'spek-alternative'
 pkgname=spek-alternative
 version=0.8.2.3
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake gettext-devel intltool libtool pkg-config wxWidgets-common"
-makedepends="ffmpeg-devel wxWidgets-gtk3-devel"
-depends="ffmpeg"
+makedepends="ffmpeg4-devel wxWidgets-gtk3-devel"
+depends="ffmpeg4"
 short_desc="Acoustic spectrum analyser"
 maintainer="Kartik Singh <kartik.ynwa@gmail.com>"
 license="GPL-3.0-or-later"

From e3fe3528c1d0731081b0212157f6a5289471b350 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 080/116] ssr: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ssr/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/ssr/template b/srcpkgs/ssr/template
index b055b9ec0774..3448ca110eb0 100644
--- a/srcpkgs/ssr/template
+++ b/srcpkgs/ssr/template
@@ -1,11 +1,11 @@
 # Template file for 'ssr'
 pkgname=ssr
 version=0.4.4
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_QT5=ON"
 hostmakedepends="pkg-config"
-makedepends="alsa-lib-devel ffmpeg-devel glu-devel jack-devel pulseaudio-devel
+makedepends="alsa-lib-devel ffmpeg4-devel glu-devel jack-devel pulseaudio-devel
  qt5-tools-devel qt5-x11extras-devel libXinerama-devel v4l-utils-devel"
 depends="desktop-file-utils hicolor-icon-theme"
 short_desc="Simple Screen Recorder for programs and games"

From 3f2b6216df4692dbfb54a6a2f3215a8434398001 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 081/116] sumo: revbump for ffmpeg-6.0

---
 srcpkgs/sumo/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/sumo/template b/srcpkgs/sumo/template
index 0f9b9ec815f5..a3fe134aa5ac 100644
--- a/srcpkgs/sumo/template
+++ b/srcpkgs/sumo/template
@@ -1,7 +1,7 @@
 # Template file for 'sumo'
 pkgname=sumo
 version=1.12.0
-revision=5
+revision=6
 build_style=cmake
 hostmakedepends="libgdal-tools pkg-config swig python3-setuptools"
 makedepends="python3-devel ffmpeg-devel fox-devel gl2ps-devel libgdal-devel

From b8842eb3e4abdae8312f42c09b0f775687edce05 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 082/116] synfig: revbump for ffmpeg-6.0 and mlt7

---
 srcpkgs/synfig/patches/ffmpeg6.patch | 71 ++++++++++++++++++++++++++++
 srcpkgs/synfig/template              |  4 +-
 2 files changed, 73 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/synfig/patches/ffmpeg6.patch

diff --git a/srcpkgs/synfig/patches/ffmpeg6.patch b/srcpkgs/synfig/patches/ffmpeg6.patch
new file mode 100644
index 000000000000..10780b42782f
--- /dev/null
+++ b/srcpkgs/synfig/patches/ffmpeg6.patch
@@ -0,0 +1,71 @@
+--- a/src/modules/mod_libavcodec/trgt_av.cpp	2022-10-25 09:14:12.000000000 -0400
++++ b/src/modules/mod_libavcodec/trgt_av.cpp	2023-05-05 21:34:17.899194559 -0400
+@@ -38,6 +41,7 @@
+ extern "C"
+ {
+ #ifdef HAVE_LIBAVFORMAT_AVFORMAT_H
++#	include <libavcodec/avcodec.h>
+ #	include <libavformat/avformat.h>
+ #elif defined(HAVE_AVFORMAT_H)
+ #	include <avformat.h>
+@@ -155,11 +156,11 @@
+     }
+ 
+ 	bool open_video_stream() {
+-		if (avcodec_open2(video_context, NULL, NULL) < 0) {
++		if (avcodec_open2(video_context, nullptr, nullptr) < 0) {
+ 			synfig::error("Target_LibAVCodec: could not open video codec");
+ 			// seems the calling of avcodec_free_context after error will cause crash
+ 			// so just forget about this context
+-			video_context = NULL;
++			video_context = nullptr;
+ 			close();
+ 			return false;
+         }
+@@ -234,15 +235,21 @@
+ 		close();
+ 
+ 		if (!av_registered) {
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 			av_register_all();
++#endif
+ 			av_registered = true;
+ 		}
+ 
+ 		// guess format
+-		AVOutputFormat *format = av_guess_format(NULL, filename.c_str(), NULL);
++#if LIBAVCODEC_VERSION_MAJOR < 59 // FFMPEG < 5.0
++		AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#else
++		const AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#endif
+ 		if (!format) {
+ 			synfig::warning("Target_LibAVCodec: unable to guess the output format, defaulting to MPEG");
+-			format = av_guess_format("mpeg", NULL, NULL);
++			format = av_guess_format("mpeg", nullptr, nullptr);
+ 		}
+ 		if (!format) {
+ 			synfig::error("Target_LibAVCodec: unable to find 'mpeg' output format");
+@@ -254,6 +261,7 @@
+ 		context = avformat_alloc_context();
+ 		assert(context);
+ 		context->oformat = format;
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 		if (filename.size() + 1 > sizeof(context->filename)) {
+ 			synfig::error(
+ 				"Target_LibAVCodec: filename too long, max length is %d, filename is '%s'",
+@@ -263,6 +271,14 @@
+ 			return false;
+ 		}
+ 		memcpy(context->filename, filename.c_str(), filename.size() + 1);
++#else
++		context->url = av_strndup(filename.c_str(), filename.size());
++		if (!context->url) {
++			synfig::error("Target_LibAVCodec: cannot allocate space for filename");
++			close();
++			return false;
++		}
++#endif
+ 
+ 		packet = av_packet_alloc();
+ 		assert(packet);
diff --git a/srcpkgs/synfig/template b/srcpkgs/synfig/template
index 5f5f5bb3f4b2..6e0d713150ae 100644
--- a/srcpkgs/synfig/template
+++ b/srcpkgs/synfig/template
@@ -6,7 +6,7 @@ revision=2
 build_style=gnu-configure
 configure_args="--with-boost-libdir=${XBPS_CROSS_BASE}/usr/lib"
 hostmakedepends="boost-build ImageMagick pkg-config intltool"
-makedepends="ETL gettext-devel libxml++-devel mlt-devel libmagick-devel
+makedepends="ETL gettext-devel libxml++-devel mlt7-devel libmagick-devel
  libmng-devel boost-build boost-devel libopenexr-devel ffmpeg-devel"
 depends="ImageMagick"
 short_desc="CLI 2D vector and timeline-based animation software"
@@ -20,7 +20,7 @@ CXXFLAGS="-std=c++11 -DHAVE_LOCALE_H=1"
 
 synfig-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision}
-	 libopenexr-devel libxml++-devel mlt-devel"
+	 libopenexr-devel libxml++-devel mlt7-devel"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/bin/synfig-config

From e46e067fbc3ef03511c11133e2df10019983436a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 5 May 2023 12:57:57 -0400
Subject: [PATCH 083/116] synfigstudio: revbump for synfig mlt7

---
 srcpkgs/synfigstudio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/synfigstudio/template b/srcpkgs/synfigstudio/template
index 91349169ed2b..af1c5a296ef0 100644
--- a/srcpkgs/synfigstudio/template
+++ b/srcpkgs/synfigstudio/template
@@ -2,7 +2,7 @@
 # Should be kept in sync with 'synfig' and 'ETL'
 pkgname=synfigstudio
 version=1.4.4
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--disable-update-mimedb"
 hostmakedepends="pkg-config intltool gettext synfig"

From bf0dbcfc2d902d5f81c404e6d30db80bbbff0919 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 084/116] tg_owt: revbump for ffmpeg-6.0

---
 srcpkgs/tg_owt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tg_owt/template b/srcpkgs/tg_owt/template
index 97d195ddb34a..551614b24956 100644
--- a/srcpkgs/tg_owt/template
+++ b/srcpkgs/tg_owt/template
@@ -1,7 +1,7 @@
 # Template file for 'tg_owt'
 pkgname=tg_owt
 version=0.0.0.20230107
-revision=1
+revision=2
 _commit=5098730b9eb6173f0b52068fe2555b7c1015123a
 _libyuv_commit=00950840d1c9bcbb3eb6ebc5aac5793e71166c8b
 _abseil_commit=8c0b94e793a66495e0b1f34a5eb26bd7dc672db0

From 87f051c7c08da798c7678ab3267994a07923745c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 085/116] timg: revbump for ffmpeg-6.0

---
 srcpkgs/timg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/timg/template b/srcpkgs/timg/template
index 2a2ab763d2fd..8fb4327535ef 100644
--- a/srcpkgs/timg/template
+++ b/srcpkgs/timg/template
@@ -1,7 +1,7 @@
 # Template file for 'timg'
 pkgname=timg
 version=1.4.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_OPENSLIDE_SUPPORT=off -Wno-dev"
 hostmakedepends="pkg-config git"

From 25e14d3a1a3359a2ca25c1bdeed196360693c96e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 086/116] tvheadend: revbump for ffmpeg4-4.4.3

---
 srcpkgs/tvheadend/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/tvheadend/template b/srcpkgs/tvheadend/template
index e6b16d7ccf3b..46b52b6fb7f9 100644
--- a/srcpkgs/tvheadend/template
+++ b/srcpkgs/tvheadend/template
@@ -1,14 +1,14 @@
 # Template file for 'tvheadend'
 pkgname=tvheadend
 version=4.2.8
-revision=6
+revision=7
 build_style=gnu-configure
 configure_args="--enable-dvbscan --disable-ffmpeg_static
 --disable-hdhomerun_static --disable-bintray_cache --disable-libx264_static
 --disable-libx265_static --disable-libvpx_static --disable-libtheora_static
 --disable-libvorbis_static --disable-libfdkaac_static"
 hostmakedepends="gettext pkg-config python git which"
-makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg-devel"
+makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg4-devel"
 short_desc="TV streaming server"
 maintainer="lemmi <lemmi@nerd2nerd.org>"
 license="GPL-3.0-only"

From 1338d0bfabe0871c1ddc4d21182ad96a7fdfbde3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 087/116] unpaper: update to 7.0.0.

---
 srcpkgs/unpaper/template | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/srcpkgs/unpaper/template b/srcpkgs/unpaper/template
index 38ed47a58401..1ff910e722af 100644
--- a/srcpkgs/unpaper/template
+++ b/srcpkgs/unpaper/template
@@ -1,13 +1,13 @@
 # Template file for 'unpaper'
 pkgname=unpaper
-version=6.1
-revision=3
-build_style=gnu-configure
+version=7.0.0
+revision=1
+build_style=meson
+hostmakedepends="pkg-config meson libxslt"
+makedepends="ffmpeg-devel python3-Sphinx"
+short_desc="Post-processing tool for scanned sheets of paper"
 maintainer="Orphaned <orphan@voidlinux.org>"
-hostmakedepends="pkg-config libxslt"
-makedepends="ffmpeg-devel"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://www.flameeyes.eu/projects/unpaper"
-short_desc="A post-processing tool for scanned sheets of paper"
 distfiles="https://www.flameeyes.eu/files/${pkgname}-${version}.tar.xz"
-checksum=237c84f5da544b3f7709827f9f12c37c346cdf029b1128fb4633f9bafa5cb930
+checksum=2575fbbf26c22719d1cb882b59602c9900c7f747118ac130883f63419be46a80

From ac3f422baeba1f747d1ac4235700e6ecf96f1844 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 088/116] vba-m: revbump for ffmpeg-6.0

---
 srcpkgs/vba-m/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vba-m/template b/srcpkgs/vba-m/template
index ba153e0b58ca..aa6093645e97 100644
--- a/srcpkgs/vba-m/template
+++ b/srcpkgs/vba-m/template
@@ -2,7 +2,7 @@
 pkgname=vba-m
 reverts=1292_2
 version=2.1.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_GTK=TRUE -DENABLE_FFMPEG=TRUE -DENABLE_LINK=TRUE -DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="gettext pkg-config unzip zip yasm wxWidgets-gtk3-devel"

From 78335f8b0f48b7104ff4ec74e5362df845c5a1d3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 089/116] vice: revbump for ffmpeg4-4.4.3

---
 srcpkgs/vice/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/vice/template b/srcpkgs/vice/template
index 0924767cfcfb..5981e45149d0 100644
--- a/srcpkgs/vice/template
+++ b/srcpkgs/vice/template
@@ -1,7 +1,7 @@
 # Template file for 'vice'
 pkgname=vice
 version=3.5
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="
 	$(vopt_enable sdl2 sdlui2)
@@ -28,7 +28,7 @@ makedepends="
 	$(vopt_if gtk3 gtk+3-devel)
 	$(vopt_if gtk3 pulseaudio-devel)
 	$(vopt_if gtk3 pango-devel)
-	$(vopt_if ffmpeg ffmpeg-devel)"
+	$(vopt_if ffmpeg ffmpeg4-devel)"
 short_desc="Emulator for C64, C128, CBM-II, PET, VIC20, Plus4 and C16"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"

From 262c34bb05f6f96a7588ef0d0b196541895c1b53 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 090/116] waypipe: revbump for ffmpeg-6.0

---
 srcpkgs/waypipe/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waypipe/template b/srcpkgs/waypipe/template
index 5c4161900060..1a46fe27f7d8 100644
--- a/srcpkgs/waypipe/template
+++ b/srcpkgs/waypipe/template
@@ -1,7 +1,7 @@
 # Template file for 'waypipe'
 pkgname=waypipe
 version=0.8.4
-revision=1
+revision=2
 build_style=meson
 # lto is off because it causes linking errors in armv6l and armv7l (due to NEON)
 configure_args="-Dwerror=false -Dwith_dmabuf=enabled -Dwith_lz4=enabled

From 573d8b9069fdc3e4220b03e3db15702532f063fe Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 091/116] wf-recorder: revbump for ffmpeg-6.0

---
 srcpkgs/wf-recorder/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/wf-recorder/template b/srcpkgs/wf-recorder/template
index e278eb001600..5d014a5f28af 100644
--- a/srcpkgs/wf-recorder/template
+++ b/srcpkgs/wf-recorder/template
@@ -1,7 +1,7 @@
 # Template file for 'wf-recorder'
 pkgname=wf-recorder
 version=0.3.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config scdoc wayland-devel"
 makedepends="wayland-protocols wayland-devel ffmpeg-devel x264-devel

From b1e634bcd82931265e837631c1c78e310ce43f86 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 092/116] xpra: revbump for ffmpeg-6.0

---
 srcpkgs/xpra/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xpra/template b/srcpkgs/xpra/template
index ee8ce4ec78a9..c02482ad4b39 100644
--- a/srcpkgs/xpra/template
+++ b/srcpkgs/xpra/template
@@ -1,7 +1,7 @@
 # Template file for 'xpra'
 pkgname=xpra
 version=4.4.5
-revision=1
+revision=2
 build_style=python3-module
 make_build_args="--without-cuda_kernels --without-cuda_rebuild"
 make_install_args="$(vopt_with docs) ${make_build_args}"

From 577beb9b106f1598fb08554ec62db2b9fbfea099 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:07:40 -0400
Subject: [PATCH 093/116] nv-codec-headers: update to 12.0.16.0

---
 srcpkgs/nv-codec-headers/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/nv-codec-headers/template b/srcpkgs/nv-codec-headers/template
index 3d422a61e489..251e057f826f 100644
--- a/srcpkgs/nv-codec-headers/template
+++ b/srcpkgs/nv-codec-headers/template
@@ -1,6 +1,6 @@
 # Template file for 'nv-codec-headers'
 pkgname=nv-codec-headers
-version=11.1.5.1
+version=12.0.16.0
 revision=1
 build_style=gnu-makefile
 short_desc="FFmpeg version of headers required to interface with Nvidias codec APIs"
@@ -8,7 +8,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="MIT"
 homepage="http://git.videolan.org/?p=ffmpeg/nv-codec-headers.git"
 distfiles="https://github.com/FFmpeg/nv-codec-headers/archive/n${version}.tar.gz"
-checksum=d095fbd56aa93772471a323be0ebe65504a0f43f06c76a30b6d25da77b06ae9c
+checksum=2a1533b65f55f9da52956faf0627ed3b74868ac0c7f269990edd21369113b48f
 
 post_install() {
 	sed -n '4,25p' include/ffnvcodec/nvEncodeAPI.h > LICENSE

From 2f2c789f86a801b97ad723a2ffc4878edafd339f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:08:40 -0400
Subject: [PATCH 094/116] openimagedenoise: revbump for ffmpeg-6.0

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index db5ccdb055cc..cb90045afb63 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,7 +1,7 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
 version=1.4.3
-revision=1
+revision=2
 archs="x86_64*"
 build_style=cmake
 hostmakedepends="ispc python3"

From 65eed46f305d2056abdf4336b30a8a031d9072f2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:31:45 -0400
Subject: [PATCH 095/116] shotcut: revbump for ffmpeg-6.0

---
 srcpkgs/shotcut/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/shotcut/template b/srcpkgs/shotcut/template
index 7d2af7b0470b..c416c906ff73 100644
--- a/srcpkgs/shotcut/template
+++ b/srcpkgs/shotcut/template
@@ -1,7 +1,7 @@
 # Template file for 'shotcut'
 pkgname=shotcut
 version=23.05.14
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSHOTCUT_VERSION=${version}"
 hostmakedepends="pkg-config qt6-tools-devel"

From 919d09eaa49363bb7c896dfab7f55c358c9b0eb7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:30 -0400
Subject: [PATCH 096/116] shiboken2: revbump for qt5-5.15.8

---
 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch | 1 +
 srcpkgs/shiboken2/template                                 | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
 create mode 120000 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
new file mode 120000
index 000000000000..efcf3249bd88
--- /dev/null
+++ b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1 @@
+../../python3-pyside2/patches/importlib-machinery-bypass.patch
\ No newline at end of file
diff --git a/srcpkgs/shiboken2/template b/srcpkgs/shiboken2/template
index 084ecc3ba1e1..2a21998997eb 100644
--- a/srcpkgs/shiboken2/template
+++ b/srcpkgs/shiboken2/template
@@ -1,7 +1,7 @@
 # Template file for 'shiboken2'
 pkgname=shiboken2
 version=5.15.7
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/shiboken2"
 build_style=cmake

From 36070e87e24800952a08c9ca294d6775930993ce Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:53 -0400
Subject: [PATCH 097/116] python3-pyside2: update to 5.15.8

---
 .../patches/importlib-machinery-bypass.patch      | 15 +++++++++++++++
 srcpkgs/python3-pyside2/template                  |  9 +++++----
 2 files changed, 20 insertions(+), 4 deletions(-)
 create mode 100644 srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
new file mode 100644
index 000000000000..64c429584776
--- /dev/null
+++ b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1,15 @@
+Using this prevents an error around line 220 below it.
+"AttributeError: module 'importlib' has no attribute 'machinery'"
+The old backup logic is in place and compiles without issues.
+--- a/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:09:34.688912402 -0400
++++ b/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:10:03.395529582 -0400
+@@ -170,9 +170,6 @@
+
+     # 'zipstring_sequence' comes from signature.cpp
+     zipbytes = base64.b64decode(''.join(zipstring_sequence))
+-    if sys.version_info[0] >= 3:
+-        vzip = zipfile.ZipFile(io.BytesIO(zipbytes))
+-        return sys.meta_path, EmbeddableZipImporter(vzip)
+
+     # Old version for Python 2.7, only.
+     import os
diff --git a/srcpkgs/python3-pyside2/template b/srcpkgs/python3-pyside2/template
index 50e6ff260d3b..b50e62bd215d 100644
--- a/srcpkgs/python3-pyside2/template
+++ b/srcpkgs/python3-pyside2/template
@@ -1,11 +1,12 @@
 # Template file for 'python3-pyside2'
 pkgname=python3-pyside2
-version=5.15.5
-revision=2
+version=5.15.8
+revision=1
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/pyside2"
 build_style=cmake
-configure_args="-DPYTHON_EXECUTABLE=/usr/bin/python"
+configure_args="-DPYTHON_EXECUTABLE=/usr/bin/python -DCMAKE_BUILD_TYPE=None
+ -DBUILD_TESTS=OFF"
 hostmakedepends="cmake python3 shiboken2"
 makedepends="python3-devel libshiboken2-devel qt5-devel
  qt5-multimedia-devel qt5-tools-devel qt5-plugin-mysql qt5-plugin-odbc
@@ -23,7 +24,7 @@ maintainer="yopito <pierre.bourgin@free.fr>"
 license="LGPL-3.0-or-later"
 homepage="https://wiki.qt.io/Qt_for_Python"
 distfiles="https://download.qt.io/official_releases/QtForPython/pyside2/PySide2-${version}-src/${_pkgname}.tar.xz"
-checksum=3920a4fb353300260c9bc46ff70f1fb975c5e7efa22e9d51222588928ce19b33
+checksum=23436302c8deb5b4cbc769b205d09604e38ba83b40708efccb7bd8c9af6f6b5d
 
 build_options="webengine"
 desc_option_webengine="Build Qt5 WebEngine bindings"

From fd9089af587f75e5572a35961240b51f73cdce33 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:35 -0400
Subject: [PATCH 098/116] konqueror: revbump for ffmpeg-6.0

---
 srcpkgs/konqueror/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/konqueror/template b/srcpkgs/konqueror/template
index d8d0e73a78ab..c5bdba601d3c 100644
--- a/srcpkgs/konqueror/template
+++ b/srcpkgs/konqueror/template
@@ -1,11 +1,11 @@
 # Template file for 'konqueror'
 pkgname=konqueror
 version=23.04.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DDESKTOPTOJSON_EXECUTABLE=/usr/bin/desktoptojson"
 hostmakedepends="extra-cmake-modules python3 qt5-host-tools qt5-qmake kdoctools
-kcoreaddons kconfig gettext"
+ kcoreaddons kconfig gettext"
 makedepends="qt5-devel qt5-webengine-devel qt5-declarative-devel
  qt5-webchannel-devel qt5-location-devel kcmutils-devel kdelibs4support-devel
  karchive-devel khtml-devel kdesu-devel kactivities5-devel"

From a72984caf4b2f408f5ff45a1ab67f40a13949d09 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:58 -0400
Subject: [PATCH 099/116] qt5-speech: revbump for qt5-5.15.8

---
 srcpkgs/qt5-speech/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-speech/template b/srcpkgs/qt5-speech/template
index 3ecd10d50650..2d7d4d4d2453 100644
--- a/srcpkgs/qt5-speech/template
+++ b/srcpkgs/qt5-speech/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-speech'
 pkgname=qt5-speech
 version=5.15.7
-revision=2
+revision=3
 _commit=d32f4a479d38a11f547598004b975f4356424a16
 build_style=qmake
 configure_args="-- -flite -flite-alsa -speechd"

From 23969223557b859f1269e5f3e5a1d6687074c034 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 18:38:50 -0400
Subject: [PATCH 100/116] qt5-styleplugins: revbump for qt5-5.15.8

---
 srcpkgs/qt5-styleplugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-styleplugins/template b/srcpkgs/qt5-styleplugins/template
index 96ed97d12cd2..30d93660a2a4 100644
--- a/srcpkgs/qt5-styleplugins/template
+++ b/srcpkgs/qt5-styleplugins/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-styleplugins'
 pkgname=qt5-styleplugins
 version=5.0.0
-revision=20
+revision=21
 _gitrev=335dbece103e2cbf6c7cf819ab6672c2956b17b3
 build_style=qmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From 99e4b2beb3fc55ce5608353f1414e68e31118357 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 30 Apr 2023 20:22:26 -0400
Subject: [PATCH 101/116] gst-plugins-ugly1: revbump for ffmpeg-6.0

---
 srcpkgs/gst-plugins-ugly1/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-plugins-ugly1/template b/srcpkgs/gst-plugins-ugly1/template
index e254fd40f869..85ae64bc7a0a 100644
--- a/srcpkgs/gst-plugins-ugly1/template
+++ b/srcpkgs/gst-plugins-ugly1/template
@@ -1,6 +1,6 @@
 # Template file for 'gst-plugins-ugly1'
 pkgname=gst-plugins-ugly1
-version=1.20.3
+version=1.22.2
 revision=1
 build_style=meson
 configure_args="-Damrnb=disabled -Damrwbdec=disabled -Dsidplay=disabled"
@@ -15,4 +15,4 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname/1/}/${pkgname/1/}-${version}.tar.xz"
-checksum=8caa20789a09c304b49cf563d33cca9421b1875b84fcc187e4a385fa01d6aefd
+checksum=8f30f44db0bd063709bf6fbe55138e3a98af0abcb61c360f35582bbe10e80691

From 7791d93c8951dc28073c219c9fc0a009d6637f34 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 30 Apr 2023 20:22:26 -0400
Subject: [PATCH 102/116] gst-rtsp-server: revbump for ffmpeg-6.0

---
 srcpkgs/gst-rtsp-server/template | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index 8ceea8d34b4b..980fd72cdd4c 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
-version=1.20.3
-revision=3
+version=1.22.2
+revision=2
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="glib-devel gst-plugins-bad1-devel gobject-introspection
@@ -10,5 +10,5 @@ short_desc="GStreamer multimedia graph framework - rtsp server"
 maintainer="1is7ac3 <isaac.qa13@gmail.com>"
 license="LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
-distfiles="https://gstreamer.freedesktop.org/src/gst-rtsp-server/gst-rtsp-server-${version}.tar.xz"
-checksum=ee402718be9b127f0e5e66ca4c1b4f42e4926ec93ba307b7ccca5dc6cc9794ca
+distfiles="${homepage}/src/${pkgname}/${pkgname}-${version}.tar.xz"
+checksum=2be4aecfb88710100ea7115ed0216403e8094344ebf146094271b8d4d73828bf

From 2e2e214a5418438e6db4ecdff930187afc966063 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 30 Apr 2023 20:22:26 -0400
Subject: [PATCH 103/116] gst-libav: revbump for ffmpeg-6.0

---
 srcpkgs/gst-libav/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index f082bd211c65..04c39bff1489 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,6 +1,6 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
-version=1.20.3
+version=1.22.2
 revision=2
 build_style=meson
 hostmakedepends="pkg-config yasm"
@@ -11,7 +11,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.0-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname}/${pkgname}-${version}.tar.xz"
-checksum=3fedd10560fcdfaa1b6462cbf79a38c4e7b57d7f390359393fc0cef6dbf27dfe
+checksum=fcaaf9878fe8f3bc82317ef13a1558824cb68df1f8968c6797f556c5e33bcffd
 
 case "$XBPS_TARGET_MACHINE" in
 	*-musl) # Required by musl for M_SQRT1_2

From 0742b0d1fce1e875280dc91c681474b559551f62 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 7 May 2023 20:14:14 -0400
Subject: [PATCH 104/116] mlt7: revbump for ffmpeg-6.0

---
 srcpkgs/gst-libav/template             | 2 +-
 srcpkgs/gst-omx/template               | 4 ++--
 srcpkgs/gst-plugins-base1/template     | 4 ++--
 srcpkgs/gst-plugins-good1/template     | 4 ++--
 srcpkgs/gst1-editing-services/template | 4 ++--
 srcpkgs/gst1-python3/template          | 6 +++---
 srcpkgs/gstreamer-vaapi/template       | 4 ++--
 srcpkgs/gstreamer1/template            | 4 ++--
 srcpkgs/mlt7/template                  | 2 +-
 9 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index 04c39bff1489..8c72fc3e97ee 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.22.2
-revision=2
+revision=1
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"
diff --git a/srcpkgs/gst-omx/template b/srcpkgs/gst-omx/template
index 893535c463da..5ad54cc7b9d8 100644
--- a/srcpkgs/gst-omx/template
+++ b/srcpkgs/gst-omx/template
@@ -1,6 +1,6 @@
 # Template file for 'gst-omx'
 pkgname=gst-omx
-version=1.20.3
+version=1.22.2
 revision=1
 build_style=meson
 configure_args="-Dexamples=disabled -Dtarget=generic"
@@ -11,4 +11,4 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.1-only"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname}/${pkgname}-${version}.tar.xz"
-checksum=8db48040bb41f09edf8d17ff6d16c54888d7777ba4501c2c69f0083350ea9a15
+checksum=1b0c57f2cc4ddeec5e7f0c436e502f06665c4e93c73261855b94e04fc94337b2
diff --git a/srcpkgs/gst-plugins-base1/template b/srcpkgs/gst-plugins-base1/template
index 29e8f76bd1fe..2f20ea819849 100644
--- a/srcpkgs/gst-plugins-base1/template
+++ b/srcpkgs/gst-plugins-base1/template
@@ -1,6 +1,6 @@
 # Template file for 'gst-plugins-base1'
 pkgname=gst-plugins-base1
-version=1.20.3
+version=1.22.2
 revision=1
 build_style=meson
 build_helper="gir"
@@ -22,7 +22,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname/1/}/${pkgname/1/}-${version}.tar.xz"
-checksum=7e30b3dd81a70380ff7554f998471d6996ff76bbe6fc5447096f851e24473c9f
+checksum=eb65120c4ee79b7a153c3c1972d5c0158c2151877cc51ec7725bba5749679d49
 
 build_options="cdparanoia gir sndio wayland"
 build_options_default="cdparanoia gir wayland"
diff --git a/srcpkgs/gst-plugins-good1/template b/srcpkgs/gst-plugins-good1/template
index 1f5e620ce1fd..5d0fe1bfe284 100644
--- a/srcpkgs/gst-plugins-good1/template
+++ b/srcpkgs/gst-plugins-good1/template
@@ -1,6 +1,6 @@
 # Template file for 'gst-plugins-good1'
 pkgname=gst-plugins-good1
-version=1.20.3
+version=1.22.2
 revision=1
 build_style=meson
 configure_args="-Ddv=disabled -Ddv1394=disabled -Dshout2=disabled -Dqt5=enabled
@@ -22,7 +22,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname/1/}/${pkgname/1/}-${version}.tar.xz"
-checksum=f8f3c206bf5cdabc00953920b47b3575af0ef15e9f871c0b6966f6d0aa5868b7
+checksum=7c8cc59425f2b232f60ca7d13e56edd615da4f711e73dd01a7cffa46e6bc0cdd
 
 build_options="gtk3 wayland"
 build_options_default="gtk3 wayland"
diff --git a/srcpkgs/gst1-editing-services/template b/srcpkgs/gst1-editing-services/template
index 673b46970f24..102440f7f253 100644
--- a/srcpkgs/gst1-editing-services/template
+++ b/srcpkgs/gst1-editing-services/template
@@ -1,6 +1,6 @@
 # Template file for 'gst1-editing-services'
 pkgname=gst1-editing-services
-version=1.20.3
+version=1.22.2
 revision=1
 build_style=meson
 build_helper="gir"
@@ -12,7 +12,7 @@ maintainer="Toyam Cox <Vaelatern@gmail.com>"
 license="LGPL-2.0-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/${pkgname/gst1/gst}/${pkgname/gst1/gst}-${version}.tar.xz"
-checksum=5fd896de69fbe24421eb6b0ff8d2f8b4c3cba3f3025ceacd302172f39a8abaa2
+checksum=453b1464fc3857de269a7cb0ebd966afe02171d97bef672a0b8a0a6d43e0cebf
 
 do_check() {
 	: # Tests fail in older versions as well
diff --git a/srcpkgs/gst1-python3/template b/srcpkgs/gst1-python3/template
index 3f564ac64b93..789e40f036ea 100644
--- a/srcpkgs/gst1-python3/template
+++ b/srcpkgs/gst1-python3/template
@@ -1,7 +1,7 @@
 # Template file for 'gst1-python3'
 pkgname=gst1-python3
-version=1.20.3
-revision=2
+version=1.22.2
+revision=1
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="libglib-devel python3-devel python3-gobject-devel gst-plugins-base1-devel"
@@ -11,4 +11,4 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/gst-python/gst-python-${version}.tar.xz"
-checksum=db348120eae955b8cc4de3560a7ea06e36d6e1ddbaa99a7ad96b59846601cfdc
+checksum=bef2b3d82ce4be46b775b1bb56305c1003ee01b535a53a82f9fe8924972153ad
diff --git a/srcpkgs/gstreamer-vaapi/template b/srcpkgs/gstreamer-vaapi/template
index 3cc4e057559a..0a5ee8b1ca3f 100644
--- a/srcpkgs/gstreamer-vaapi/template
+++ b/srcpkgs/gstreamer-vaapi/template
@@ -1,6 +1,6 @@
 # Template file for 'gstreamer-vaapi'
 pkgname=gstreamer-vaapi
-version=1.20.3
+version=1.22.2
 revision=1
 build_style=meson
 hostmakedepends="pkg-config"
@@ -11,7 +11,7 @@ license="LGPL-2.1-or-later"
 homepage="https://gstreamer.freedesktop.org"
 changelog="https://raw.githubusercontent.com/GStreamer/gstreamer-vaapi/master/ChangeLog"
 distfiles="${homepage}/src/gstreamer-vaapi/gstreamer-vaapi-${version}.tar.xz"
-checksum=6ee99eb316abdde9ad37002915bd8c3867918f6fdc74b7cf2ac4c1ae0d690b45
+checksum=d2e642f9745f97d9f73a7f5085e7659a9a31fe209b774e6e45dae041b435df06
 
 pre_check() {
 	# Seems to need certain hardware to pass
diff --git a/srcpkgs/gstreamer1/template b/srcpkgs/gstreamer1/template
index ae8a49cb20e8..571148f2ff33 100644
--- a/srcpkgs/gstreamer1/template
+++ b/srcpkgs/gstreamer1/template
@@ -1,6 +1,6 @@
 # Template file for 'gstreamer1'
 pkgname=gstreamer1
-version=1.20.3
+version=1.22.2
 revision=1
 build_style=meson
 build_helper="gir"
@@ -16,7 +16,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="LGPL-2.0-or-later"
 homepage="https://gstreamer.freedesktop.org"
 distfiles="${homepage}/src/gstreamer/gstreamer-${version}.tar.xz"
-checksum=607daf64bbbd5fb18af9d17e21c0d22c4d702fffe83b23cb22d1b1af2ca23a2a
+checksum=b2afe73603921c608ba48969dbb7d743776744bfe5d8059ece241137b7f88e21
 
 pre_check() {
 	# gst_gstdatetime is known to fail according to LFS
diff --git a/srcpkgs/mlt7/template b/srcpkgs/mlt7/template
index 9fb7f60d692e..cca0eb68cfc3 100644
--- a/srcpkgs/mlt7/template
+++ b/srcpkgs/mlt7/template
@@ -1,7 +1,7 @@
 # Template file for 'mlt7'
 pkgname=mlt7
 version=7.14.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSWIG_PYTHON=ON"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which

From ec93af999069c0b027b51fe6e104361ef4d87bf5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 7 May 2023 20:15:03 -0400
Subject: [PATCH 105/116] qt6-webengine: revbump for ffmpeg-6.0

---
 srcpkgs/qt6-webengine/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-webengine/template b/srcpkgs/qt6-webengine/template
index 4e22cb6e8863..f948dc919a15 100644
--- a/srcpkgs/qt6-webengine/template
+++ b/srcpkgs/qt6-webengine/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-webengine'
 pkgname=qt6-webengine
 version=6.5.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="
  -DQT_FEATURE_webengine_system_ffmpeg=ON

From f5c0d9277f16b700542fc3d65e2664455b441f2f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 7 May 2023 20:15:29 -0400
Subject: [PATCH 106/116] tracker-miners: revbump for ffmpeg-6.0

---
 srcpkgs/tracker-miners/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tracker-miners/template b/srcpkgs/tracker-miners/template
index 8c005d697fa4..a6e5aa577702 100644
--- a/srcpkgs/tracker-miners/template
+++ b/srcpkgs/tracker-miners/template
@@ -1,7 +1,7 @@
 # Template file for 'tracker-miners'
 pkgname=tracker-miners
 version=3.5.0
-revision=3
+revision=4
 build_style=meson
 build_helper=qemu
 # missing libgrss for miner_rss

From ea406f110dc15a101bf124701157e09d3e5485b6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 7 May 2023 20:20:58 -0400
Subject: [PATCH 107/116] mpd: revbump for ffmpeg-6.0

---
 srcpkgs/mpd/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpd/template b/srcpkgs/mpd/template
index 9dbd4c935acc..9f058b62df2f 100644
--- a/srcpkgs/mpd/template
+++ b/srcpkgs/mpd/template
@@ -1,7 +1,7 @@
 # Template file for 'mpd'
 pkgname=mpd
 version=0.23.13
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dopus=enabled -Dmikmod=enabled -Dneighbor=true
  -Dsoundcloud=enabled -Dpipe=true -Dtwolame=enabled -Dbzip2=enabled

From a7e91e43f2705109259911ebef0bb5847646e2c8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 11 May 2023 14:05:14 -0400
Subject: [PATCH 108/116] openmw: revbump for ffmpeg-6.0

---
 srcpkgs/openmw/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openmw/template b/srcpkgs/openmw/template
index e3771c7aaf1a..3cbf20b06577 100644
--- a/srcpkgs/openmw/template
+++ b/srcpkgs/openmw/template
@@ -1,7 +1,7 @@
 # Template file for 'openmw'
 pkgname=openmw
 version=0.47.0
-revision=5
+revision=6
 build_style=cmake
 _recast_commit=e75adf86f91eb3082220085e42dda62679f9a3ea
 _bullet_tag=3.17

From 08d39e5a1511f055b9eb9094a505b6918c6aa178 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 21 May 2023 12:44:11 -0400
Subject: [PATCH 109/116] electron24: revbump for ffmpeg-6.0

---
 srcpkgs/electron24/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron24/template b/srcpkgs/electron24/template
index bdaa56adc8a6..ff3d5e3ef381 100644
--- a/srcpkgs/electron24/template
+++ b/srcpkgs/electron24/template
@@ -1,7 +1,7 @@
 # Template file for 'electron24'
 pkgname=electron24
 version=24.3.0
-revision=1
+revision=2
 _nodever=18.14.0
 _chromiumver=112.0.5615.165
 archs="x86_64* aarch64*"

From b35d162646d8a4c600358b92b34ef0df561f66cf Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Jun 2023 08:20:22 -0400
Subject: [PATCH 110/116] gtk4: revbump for ffmpeg-6.0

---
 srcpkgs/gtk4/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gtk4/template b/srcpkgs/gtk4/template
index b318b7bae1dd..e3bde4a50e54 100644
--- a/srcpkgs/gtk4/template
+++ b/srcpkgs/gtk4/template
@@ -1,7 +1,7 @@
 # Template file for 'gtk4'
 pkgname=gtk4
 version=4.10.4
-revision=1
+revision=2
 build_style=meson
 build_helper="gir"
 configure_args="-Dman-pages=true -Dgtk_doc=true -Dbuild-tests=false

From c51dd16997036069b7e54a6ee15a2815930f2ecd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:25:50 -0400
Subject: [PATCH 111/116] electron19: revbump for ffmpeg-6.0

---
 srcpkgs/electron19/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron19/template b/srcpkgs/electron19/template
index 32ce301e730c..ab7f308f5e8a 100644
--- a/srcpkgs/electron19/template
+++ b/srcpkgs/electron19/template
@@ -1,7 +1,7 @@
 # Template file for 'electron19'
 pkgname=electron19
 version=19.0.8
-revision=3
+revision=4
 _nodever=16.14.2
 _chromiumver=102.0.5005.125
 archs="x86_64* aarch64* ppc64le*"

From d96b0f48a7ce4ccbb9413486fe45ac27926d39ce Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:28:26 -0400
Subject: [PATCH 112/116] siril: revbump for ffmpeg-6.0

---
 srcpkgs/siril/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/siril/template b/srcpkgs/siril/template
index 84332f79d060..62750dd24754 100644
--- a/srcpkgs/siril/template
+++ b/srcpkgs/siril/template
@@ -1,7 +1,7 @@
 # Template file for 'siril'
 pkgname=siril
 version=0.9.12
-revision=10
+revision=11
 build_style=gnu-configure
 hostmakedepends="pkg-config intltool autoconf automake gettext-devel"
 makedepends="fftw-devel libconfig-devel libopencv-devel libffms2-devel

From bbd643852de807fd1b5da7d6158bcb6a1173a35b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:29:08 -0400
Subject: [PATCH 113/116] telegram-desktop: revbump for ffmpeg-6.0

---
 srcpkgs/telegram-desktop/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/telegram-desktop/template b/srcpkgs/telegram-desktop/template
index f114b2341dc5..9db9f80c1a53 100644
--- a/srcpkgs/telegram-desktop/template
+++ b/srcpkgs/telegram-desktop/template
@@ -1,7 +1,7 @@
 # Template file for 'telegram-desktop'
 pkgname=telegram-desktop
 version=4.8.1
-revision=3
+revision=4
 build_style=cmake
 build_helper="qemu"
 configure_args="-DTDESKTOP_API_ID=209235

From ac6d86285d3c1d8b751dda658a3d2fb763bcdc56 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 10 Jun 2023 00:40:39 -0400
Subject: [PATCH 114/116] freecad: revbump for qt5-webengine-5.15.13

---
 srcpkgs/freecad/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/freecad/template b/srcpkgs/freecad/template
index a4a3f5f76b29..8608d1670c87 100644
--- a/srcpkgs/freecad/template
+++ b/srcpkgs/freecad/template
@@ -1,7 +1,7 @@
 # Template file for 'freecad'
 pkgname=freecad
 version=0.20.2
-revision=5
+revision=6
 build_style=cmake
 
 _inst_prefix=/usr/lib/${pkgname}

From 92331a94ef2c9cfa6da95494d4b3902b9828d50b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 10 Jun 2023 00:57:09 -0400
Subject: [PATCH 115/116] qt6-multimedia: revbump for ffmpeg-6.0

---
 srcpkgs/qt6-multimedia/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-multimedia/template b/srcpkgs/qt6-multimedia/template
index a6832fdd69bf..c9ffac914ab8 100644
--- a/srcpkgs/qt6-multimedia/template
+++ b/srcpkgs/qt6-multimedia/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-multimedia'
 pkgname=qt6-multimedia
 version=6.5.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DQT_FEATURE_gstreamer=ON"
 hostmakedepends="perl qt6-declarative-host-tools pkg-config qt6-shadertools"

From f7a8fe79fa3d791d55f1c6dfd08611c895adb31d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 17 Jun 2023 15:28:21 -0400
Subject: [PATCH 116/116] kdenlive: revbump for ffmpeg-6.0

---
 srcpkgs/kdenlive/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kdenlive/template b/srcpkgs/kdenlive/template
index 429126ef3c3b..0c5f7bf698fb 100644
--- a/srcpkgs/kdenlive/template
+++ b/srcpkgs/kdenlive/template
@@ -1,7 +1,7 @@
 # Template file for 'kdenlive'
 pkgname=kdenlive
 version=23.04.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="
  extra-cmake-modules kconfig kcoreaddons kdoctools pkg-config python3

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (12 preceding siblings ...)
  2023-06-19 20:19 ` zlice
@ 2023-06-22 14:28 ` zlice
  2023-06-23 20:37 ` [PR PATCH] [Updated] " zlice
                   ` (83 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2023-06-22 14:28 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 628 bytes --]

New comment by zlice on void-packages repository

https://github.com/void-linux/void-packages/pull/43761#issuecomment-1536296485

Comment:
xlint questions

```
============ qt5 ===============
qt5:35: verify python_version and remove "#unverified"
qt5:529: use <pkgname>-doc subpackage for documentation
```

what counts as 'verified' for python?

does doc pkg need changed? looks like a separate package (still on 5.15.2 and out of sync with current qt5 5.15.7)

edit: per irc i was told docs is nothing to worry about rn. the python2 vs 3 thing i guess i can't verify because i don't use any qt scripts for that


^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (13 preceding siblings ...)
  2023-06-22 14:28 ` zlice
@ 2023-06-23 20:37 ` zlice
  2023-07-04 13:30 ` zlice
                   ` (82 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2023-06-23 20:37 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 3488 bytes --]

There is an updated pull request by zlice against master on the void-packages repository

https://github.com/zlice/void-packages ffmpeg6-split
https://github.com/void-linux/void-packages/pull/43761

ffmpeg6 split
[ci skip]


#### Testing the changes

- I tested the changes in this PR: **YES**

main testing has been vaapi in Firefox Nightly and enc/dec in Shotcut on Intel A770

#### New package

- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**

#### Local build testing

- I built this PR locally for my native architecture, **x86_64**

#### Discussion

Continuation of https://github.com/void-linux/void-packages/pull/36315

`libavresample` is deprecated, but marked as a dependency when trying to build other packages and install `ffmpeg`(6). I think the right way to handle this is make a meta package and the add to removals?


##### Commit naming / misc

~~Commits are 'dirty' right now, running with [gstreamer 1.22.1 updates](https://github.com/void-linux/void-packages/pull/42861) and [Intel OpenCL](https://github.com/void-linux/void-packages/pull/43084). This will also make [intel packages pr](https://github.com/void-linux/void-packages/pull/41132) obsolete.~~ (see Requirements below)

Maintainer for previous ffmpeg(4) was orphaned, I can put my name in there if that matters, though I don't exactly see myself keeping up on ffmpeg.

This updates QT5 which looks like it is usually hosted by Johnny. Not sure if there's any reason to stay there or these sources are fine.

##### STILL FFMPEG4

These are a mix of emulators, games and/or older packages.

- attract (multiple patches in master)
- audacity (https://github.com/audacity/audacity/issues/2305 and https://sourceforge.net/p/portmedia/wiki/portsmf/ is 'beta')
- ccextractor (master patches? no release)
- vice
- kodi
- mlt (only dep left is flowblade)
- ~~synfig (mlt)~~ (work with mlt7, bump synfigstudio)
- tvheadend
- ssr
- spek-alternative
- ppsspp
- olive
- moc
- mediastreamer
- libextractor
- idjc
- hedgewars
- ~~ffmpegthumbnailer~~ (patches for moviedecoder.xxx files)
- ~~ffmpegthumbs~~ (latest compiles)
- deadbeef
- omxplayer
- qtav (fork has ffmpeg 5 patch - https://github.com/cmguo/QtAV)
- `vlc` (vlc4 will support ffmpeg5, there's a patch to build 3.x with ffmpeg5 but it will lack vaapi)
- `osg` (OpenSceneGraph plus `xine-lib`)


##### HAVE NOT BUILT YET

- omxplayer (rpi only? ffmpeg4)
- kodi (big, but ffmpeg4)


##### UPDATED (for ffmpeg6)

- ~~blender: update to 3.5.1~~ ~~will be revbump with~~ https://github.com/void-linux/void-packages/pull/43992
- unpaper: update to 7.0.0.
- guvcview: update to 2.0.8.
- qt5: update to 5.15.8
- qt5-webengine: update to 5.18.13
- shiboken2: revbump for qt5.15.8 (patch)
- python3-pyside2: update to 5.15.8 (patch)


##### Requirements

- ~~[gstreamer 1.22.2](https://github.com/void-linux/void-packages/pull/42861)~~ - a few packages use ffmpeg-devel and require a revbump

- [Intel Packages](https://github.com/void-linux/void-packages/pull/41132) - ffmpeg4 uses different libraries than 6 (libmfx / Intel-MediaSDK vs only oneVPL that Intel is moving to), both are included here

- ~~[shotcut 23.05.14](https://github.com/void-linux/void-packages/pull/44260)~~

A patch file from https://github.com/void-linux/void-packages/pull/43761.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ffmpeg6-split-43761.patch --]
[-- Type: text/x-diff, Size: 778018 bytes --]

From 65ce790c193681cb1ce01ae4030bc6ca9217adc8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:55:46 -0400
Subject: [PATCH 001/113] ffmpeg: update to 6.0.

---
 common/shlibs                                 | 26 +++++---
 srcpkgs/ffmpeg/files/altivec.patch            | 60 -------------------
 .../patches/armv5tel-floating-point.patch     | 18 ------
 .../workaround-mesa-readeon-vaapi-bug.patch   | 28 ---------
 srcpkgs/ffmpeg/template                       | 38 +++++-------
 5 files changed, 32 insertions(+), 138 deletions(-)
 delete mode 100644 srcpkgs/ffmpeg/files/altivec.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch

diff --git a/common/shlibs b/common/shlibs
index 7bc98cc1b474..dc3f03487173 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -387,15 +387,23 @@ libid3tag.so.0 libid3tag-0.15.1b_1
 libgif.so.7 giflib-5.1.0_1
 libImlib2.so.1 imlib2-1.4.2_1
 libmp3lame.so.0 lame-3.98.2_1
-libavdevice.so.58 libavdevice-4.0_1
-libavformat.so.58 libavformat-4.0_1
-libswscale.so.5 libswscale-4.0_1
-libswresample.so.3 libswresample-4.0_1
-libavresample.so.4 libavresample-4.0_1
-libpostproc.so.55 libpostproc-4.0_1
-libavcodec.so.58 libavcodec-4.0_1
-libavutil.so.56 libavutil-4.0_1
-libavfilter.so.7 libavfilter-4.0_1
+libavdevice.so.60 libavdevice-6.0_1
+libavformat.so.60 libavformat-6.0_1
+libswscale.so.7 libswscale-6.0_1
+libswresample.so.4 libswresample-6.0_1
+libpostproc.so.57 libpostproc-6.0_1
+libavcodec.so.60 libavcodec-6.0_1
+libavutil.so.58 libavutil-6.0_1
+libavfilter.so.9 libavfilter-6.0_1
+libavdevice.so.58 libavdevice4-4.0_1
+libavformat.so.58 libavformat4-4.0_1
+libswscale.so.5 libswscale4-4.0_1
+libswresample.so.3 libswresample4-4.0_1
+libavresample.so.4 libavresample4-4.0_1
+libpostproc.so.55 libpostproc4-4.0_1
+libavcodec.so.58 libavcodec4-4.0_1
+libavutil.so.56 libavutil4-4.0_1
+libavfilter.so.7 libavfilter4-4.0_1
 libSDL-1.2.so.0 SDL-1.2.14_1
 libSDL_image-1.2.so.0 SDL_image-1.2.10_1
 libx264.so.157 x264-20190507.2245_1
diff --git a/srcpkgs/ffmpeg/files/altivec.patch b/srcpkgs/ffmpeg/files/altivec.patch
deleted file mode 100644
index 9c5720046332..000000000000
--- a/srcpkgs/ffmpeg/files/altivec.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-revert some altivec specific change on all ppc* except ppc64le*
-
-q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
-conditionally, for ppc* but not ppc64le* (the new code is valid for
-POWER8 VSX which LE targets as a baseline but not BE)"
-
-
-This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
----
- libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
- 1 file changed, 20 insertions(+), 4 deletions(-)
-
-diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
-index 536545293d..c1e2852adb 100644
---- a/libswscale/ppc/yuv2rgb_altivec.c
-+++ b/libswscale/ppc/yuv2rgb_altivec.c
-@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-     vector signed short R1, G1, B1;                                           \
-     vector unsigned char R, G, B;                                             \
-                                                                               \
-+    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
-+    vector unsigned char align_perm;                                          \
-+                                                                              \
-     vector signed short lCY       = c->CY;                                    \
-     vector signed short lOY       = c->OY;                                    \
-     vector signed short lCRV      = c->CRV;                                   \
-@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
-                                                                               \
-         for (j = 0; j < w / 16; j++) {                                        \
--            y0 = vec_xl(0, y1i);                                              \
-+            y1ivP = (const vector unsigned char *) y1i;                       \
-+            y2ivP = (const vector unsigned char *) y2i;                       \
-+            uivP  = (const vector unsigned char *) ui;                        \
-+            vivP  = (const vector unsigned char *) vi;                        \
-+                                                                              \
-+            align_perm = vec_lvsl(0, y1i);                                    \
-+            y0 = (vector unsigned char)                                       \
-+                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
-                                                                               \
--            y1 = vec_xl(0, y2i);                                              \
-+            align_perm = vec_lvsl(0, y2i);                                    \
-+            y1 = (vector unsigned char)                                       \
-+                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
-                                                                               \
--            u = (vector signed char) vec_xl(0, ui);                           \
-+            align_perm = vec_lvsl(0, ui);                                     \
-+            u = (vector signed char)                                          \
-+                    vec_perm(uivP[0], uivP[1], align_perm);                   \
-                                                                               \
--            v = (vector signed char) vec_xl(0, vi);                           \
-+            align_perm = vec_lvsl(0, vi);                                     \
-+            v = (vector signed char)                                          \
-+                    vec_perm(vivP[0], vivP[1], align_perm);                   \
-                                                                               \
-             u = (vector signed char)                                          \
-                     vec_sub(u,                                                \
--- 
-2.27.0
-
diff --git a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
deleted file mode 100644
index 9a55178c74f0..000000000000
--- a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
-+++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
-@@ -39,6 +39,15 @@
- #endif
- #include <fenv.h>
- 
-+#if (FE_ALL_EXCEPT == 0)
-+/* E.g. ARM soft float does not define these */
-+#define FE_INVALID    0
-+#define FE_DIVBYZERO  0
-+#define FE_OVERFLOW   0
-+#define FE_UNDERFLOW  0
-+#define FE_INEXACT    0
-+#endif
-+
- #if CONFIG_LIBFONTCONFIG
- #include <fontconfig/fontconfig.h>
- #endif
diff --git a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
deleted file mode 100644
index 00e3f68a415b..000000000000
--- a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
-From: Rainer Hochecker <fernetmenta@online.de>
-Date: Sat, 26 Jan 2019 19:48:35 +0100
-Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
-
-This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
-It was hit frequently when watching h264 channels received via DVB-X.
-Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
----
- libavcodec/vaapi_h264.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
-index 5854587a255..f12fdc457a4 100644
---- a/libavcodec/vaapi_h264.c
-+++ b/libavcodec/vaapi_h264.c
-@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
-     H264SliceContext *sl = &h->slice_ctx[0];
-     int ret;
- 
-+    if (pic->nb_slices == 0) {
-+        ret = AVERROR_INVALIDDATA;
-+        goto finish;
-+    }
-+
-     ret = ff_vaapi_decode_issue(avctx, pic);
-     if (ret < 0)
-         goto finish;
diff --git a/srcpkgs/ffmpeg/template b/srcpkgs/ffmpeg/template
index df4179d1963a..f742082bb520 100644
--- a/srcpkgs/ffmpeg/template
+++ b/srcpkgs/ffmpeg/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpeg'
 # audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
 pkgname=ffmpeg
-version=4.4.4
+version=6.0
 revision=1
 short_desc="Decoding, encoding and streaming software"
 maintainer="Orphaned <orphan@voidlinux.org>"
@@ -9,7 +9,7 @@ license="GPL-3.0-or-later"
 homepage="https://www.ffmpeg.org"
 changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
 distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
-checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+checksum=57be87c22d9b49c112b6d24bc67d42508660e6b718b3db89c44e47e289137082
 
 hostmakedepends="pkg-config perl"
 makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
@@ -26,12 +26,13 @@ makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-deve
  $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
  $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
  $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
- $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers Vulkan-Tools Vulkan-ValidationLayers')
+ $(vopt_if onevpl 'onevpl onevpl-devel')
  $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
 depends="ffplay>=${version}_${revision}"
 
 build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
- dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec onevpl"
 build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
 desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
 desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
@@ -39,10 +40,8 @@ desc_option_sofa="Enable support for AES SOFA"
 desc_option_webp="Enable support for WebP"
 
 case "$XBPS_TARGET_MACHINE" in
-	i686*|x86_64*)
-		hostmakedepends+=" nasm"
-		build_options_default+=" vaapi vdpau nvenc nvdec"
-		;;
+	i686*) build_options_default+=" vaapi vdpau nvenc nvdec";;
+	x86_64*) build_options_default+=" vaapi vdpau nvenc nvdec onevpl";;
 	ppc64*) build_options_default+=" vaapi vdpau";;
 	mips*) CFLAGS="-mnan=legacy";;
 esac
@@ -117,18 +116,19 @@ do_configure() {
 		$(vopt_enable x265 libx265) \
 		$(vopt_enable v4l2 libv4l2) \
 		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
-		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		--enable-libbs2b --enable-libvidstab \
 		$(vopt_enable dav1d libdav1d) \
 		$(vopt_enable zimg libzimg) \
 		$(vopt_enable webp libwebp) \
 		$(vopt_enable sofa libmysofa) \
 		$(vopt_enable vulkan) \
+		$(vopt_enable onevpl libvpl) \
 		$(vopt_enable drm libdrm) \
 		$(vopt_enable svtav1 libsvtav1) \
 		$(vopt_enable srt libsrt) \
 		$(vopt_enable rist librist) \
-		$(vopt_if nvenc '--enable-nvenc') \
-		$(vopt_if nvdec '--enable-nvdec')
+		$(vopt_enable nvenc nvenc) \
+		$(vopt_enable nvdec nvdec)
 }
 
 do_build() {
@@ -155,10 +155,8 @@ libavdevice_package() {
 }
 
 libavresample_package() {
-	short_desc="FFmpeg audio resampling library"
-	pkg_install() {
-		vmove "usr/lib/libavresample.so.*"
-	}
+	short_desc="Package deprecated, removal needed"
+	build_style=meta
 }
 
 libavformat_package() {
@@ -212,15 +210,9 @@ ffmpeg-devel_package() {
 		libavfilter>=${version}_${revision}
 		libpostproc>=${version}_${revision}
 		libswscale>=${version}_${revision}
-		libswresample>=${version}_${revision}
-		libavresample>=${version}_${revision}"
+		libswresample>=${version}_${revision}"
 	short_desc+=" - development files"
-
-	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
-		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
-		nostrip_files="/usr/lib/libavfilter.a"
-	fi
-
+	conflicts="ffmpeg4-devel"
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig

From b8f6643cf3d4461bd5a06bb182b27dd7531ed484 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:56:22 -0400
Subject: [PATCH 002/113] New package: ffmpeg4-4.4.4.

---
 srcpkgs/ffmpeg4-devel                         |   1 +
 srcpkgs/ffmpeg4/files/altivec.patch           |  60 +++++
 .../patches/armv5tel-floating-point.patch     |  18 ++
 .../workaround-mesa-readeon-vaapi-bug.patch   |  28 +++
 srcpkgs/ffmpeg4/template                      | 238 ++++++++++++++++++
 srcpkgs/libavcodec4                           |   1 +
 srcpkgs/libavdevice4                          |   1 +
 srcpkgs/libavfilter4                          |   1 +
 srcpkgs/libavformat4                          |   1 +
 srcpkgs/libavresample4                        |   1 +
 srcpkgs/libavutil4                            |   1 +
 srcpkgs/libpostproc4                          |   1 +
 srcpkgs/libswresample4                        |   1 +
 srcpkgs/libswscale4                           |   1 +
 14 files changed, 354 insertions(+)
 create mode 120000 srcpkgs/ffmpeg4-devel
 create mode 100644 srcpkgs/ffmpeg4/files/altivec.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
 create mode 100644 srcpkgs/ffmpeg4/template
 create mode 120000 srcpkgs/libavcodec4
 create mode 120000 srcpkgs/libavdevice4
 create mode 120000 srcpkgs/libavfilter4
 create mode 120000 srcpkgs/libavformat4
 create mode 120000 srcpkgs/libavresample4
 create mode 120000 srcpkgs/libavutil4
 create mode 120000 srcpkgs/libpostproc4
 create mode 120000 srcpkgs/libswresample4
 create mode 120000 srcpkgs/libswscale4

diff --git a/srcpkgs/ffmpeg4-devel b/srcpkgs/ffmpeg4-devel
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/ffmpeg4-devel
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/ffmpeg4/files/altivec.patch b/srcpkgs/ffmpeg4/files/altivec.patch
new file mode 100644
index 000000000000..9c5720046332
--- /dev/null
+++ b/srcpkgs/ffmpeg4/files/altivec.patch
@@ -0,0 +1,60 @@
+revert some altivec specific change on all ppc* except ppc64le*
+
+q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
+conditionally, for ppc* but not ppc64le* (the new code is valid for
+POWER8 VSX which LE targets as a baseline but not BE)"
+
+
+This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
+---
+ libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
+ 1 file changed, 20 insertions(+), 4 deletions(-)
+
+diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
+index 536545293d..c1e2852adb 100644
+--- a/libswscale/ppc/yuv2rgb_altivec.c
++++ b/libswscale/ppc/yuv2rgb_altivec.c
+@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+     vector signed short R1, G1, B1;                                           \
+     vector unsigned char R, G, B;                                             \
+                                                                               \
++    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
++    vector unsigned char align_perm;                                          \
++                                                                              \
+     vector signed short lCY       = c->CY;                                    \
+     vector signed short lOY       = c->OY;                                    \
+     vector signed short lCRV      = c->CRV;                                   \
+@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
+                                                                               \
+         for (j = 0; j < w / 16; j++) {                                        \
+-            y0 = vec_xl(0, y1i);                                              \
++            y1ivP = (const vector unsigned char *) y1i;                       \
++            y2ivP = (const vector unsigned char *) y2i;                       \
++            uivP  = (const vector unsigned char *) ui;                        \
++            vivP  = (const vector unsigned char *) vi;                        \
++                                                                              \
++            align_perm = vec_lvsl(0, y1i);                                    \
++            y0 = (vector unsigned char)                                       \
++                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
+                                                                               \
+-            y1 = vec_xl(0, y2i);                                              \
++            align_perm = vec_lvsl(0, y2i);                                    \
++            y1 = (vector unsigned char)                                       \
++                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
+                                                                               \
+-            u = (vector signed char) vec_xl(0, ui);                           \
++            align_perm = vec_lvsl(0, ui);                                     \
++            u = (vector signed char)                                          \
++                    vec_perm(uivP[0], uivP[1], align_perm);                   \
+                                                                               \
+-            v = (vector signed char) vec_xl(0, vi);                           \
++            align_perm = vec_lvsl(0, vi);                                     \
++            v = (vector signed char)                                          \
++                    vec_perm(vivP[0], vivP[1], align_perm);                   \
+                                                                               \
+             u = (vector signed char)                                          \
+                     vec_sub(u,                                                \
+-- 
+2.27.0
+
diff --git a/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
new file mode 100644
index 000000000000..9a55178c74f0
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
@@ -0,0 +1,18 @@
+--- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
++++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
+@@ -39,6 +39,15 @@
+ #endif
+ #include <fenv.h>
+ 
++#if (FE_ALL_EXCEPT == 0)
++/* E.g. ARM soft float does not define these */
++#define FE_INVALID    0
++#define FE_DIVBYZERO  0
++#define FE_OVERFLOW   0
++#define FE_UNDERFLOW  0
++#define FE_INEXACT    0
++#endif
++
+ #if CONFIG_LIBFONTCONFIG
+ #include <fontconfig/fontconfig.h>
+ #endif
diff --git a/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
new file mode 100644
index 000000000000..00e3f68a415b
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
@@ -0,0 +1,28 @@
+From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
+From: Rainer Hochecker <fernetmenta@online.de>
+Date: Sat, 26 Jan 2019 19:48:35 +0100
+Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
+
+This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
+It was hit frequently when watching h264 channels received via DVB-X.
+Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
+---
+ libavcodec/vaapi_h264.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
+index 5854587a255..f12fdc457a4 100644
+--- a/libavcodec/vaapi_h264.c
++++ b/libavcodec/vaapi_h264.c
+@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
+     H264SliceContext *sl = &h->slice_ctx[0];
+     int ret;
+ 
++    if (pic->nb_slices == 0) {
++        ret = AVERROR_INVALIDDATA;
++        goto finish;
++    }
++
+     ret = ff_vaapi_decode_issue(avctx, pic);
+     if (ret < 0)
+         goto finish;
diff --git a/srcpkgs/ffmpeg4/template b/srcpkgs/ffmpeg4/template
new file mode 100644
index 000000000000..5228c7df08fb
--- /dev/null
+++ b/srcpkgs/ffmpeg4/template
@@ -0,0 +1,238 @@
+# Template file for 'ffmpeg4'
+# audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
+pkgname=ffmpeg4
+version=4.4.4
+revision=1
+short_desc="Decoding, encoding and streaming software - ffmpeg4 libraries only"
+maintainer="Orphaned <orphan@voidlinux.org>"
+license="GPL-3.0-or-later"
+homepage="https://www.ffmpeg.org"
+changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
+distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
+checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+
+hostmakedepends="pkg-config perl"
+makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
+ libXext-devel libXvMC-devel libxcb-devel lame-devel libtheora-devel
+ libvorbis-devel x264-devel xvidcore-devel jack-devel SDL2-devel
+ libcdio-paranoia-devel librtmp-devel libmodplug-devel gnutls-devel
+ speex-devel celt-devel harfbuzz-devel libass-devel opus-devel ocl-icd-devel
+ libbs2b-devel libvidstab-devel $(vopt_if pulseaudio pulseaudio-devel)
+ $(vopt_if vaapi libva-devel) $(vopt_if vdpau libvdpau-devel)
+ $(vopt_if x265 x265-devel) $(vopt_if v4l2 v4l-utils-devel)
+ $(vopt_if fdk_aac fdk-aac-devel) $(vopt_if vpx libvpx-devel)
+ $(vopt_if aom libaom-devel) $(vopt_if sndio sndio-devel)
+ $(vopt_if dav1d libdav1d-devel) $(vopt_if zimg zimg-devel)
+ $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
+ $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
+ $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if mfx 'libmfx libmfx-devel')
+ $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
+
+build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec mfx"
+build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
+
+desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
+desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
+desc_option_sofa="Enable support for AES SOFA"
+desc_option_webp="Enable support for WebP"
+
+case "$XBPS_TARGET_MACHINE" in
+	i686*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau nvenc nvdec"
+			;;
+	x86_64*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau mfx nvenc nvdec"
+			;;
+	ppc64*) build_options_default+=" vaapi vdpau";;
+	mips*) CFLAGS="-mnan=legacy";;
+esac
+
+if [ "$XBPS_TARGET_WORDSIZE" != "32" ]; then
+	build_options_default+=" svtav1"
+fi
+
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+fi
+
+_apply_patch() {
+	local args="$1" pname="$(basename $2)"
+
+	if [ ! -f ".${pname}_done" ]; then
+		patch -N $args -i $2
+		touch .${pname}_done
+	fi
+}
+
+post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64le*) ;;
+		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
+	esac
+}
+
+do_configure() {
+	# Fix gcc on x86_64-musl only
+	if [ "$XBPS_TARGET_MACHINE" = "x86_64-musl" ]; then
+		vsed -i configure -e "s;_cflags_speed='-O3';_cflags_speed='-O2';"
+	fi
+
+	if [ "$CROSS_BUILD" ]; then
+		case "$XBPS_TARGET_MACHINE" in
+			arm*) _arch="arm";;
+			aarch64*) _arch="aarch64";;
+			mips*) _arch="mips";;
+			ppc64*) _arch="ppc64";;
+			ppc*) _arch="ppc";;
+			*) _arch="${XBPS_TARGET_MACHINE%%-musl}";;
+		esac
+
+		_args+=" --enable-cross-compile
+			--sysroot=$XBPS_CROSS_BASE
+			--cross-prefix=${XBPS_CROSS_TRIPLET}-
+			--target-os=linux --arch=${_arch}"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc|ppc-musl) _args+=" --disable-altivec";;
+	esac
+
+	if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+		_args+=" --extra-libs=-latomic"
+	fi
+
+	./configure --prefix=/usr --disable-debug --enable-gpl --enable-gnutls \
+		--disable-stripping \
+		--enable-libcdio --enable-version3 --enable-runtime-cpudetect \
+		--enable-libmp3lame --enable-libvorbis --enable-libxvid \
+		--enable-libx264 $(vopt_enable vpx libvpx) --enable-libtheora \
+		--enable-shared --enable-static --enable-libxcb \
+		$(vopt_enable pulseaudio libpulse) --enable-libfreetype --enable-libmodplug \
+		--enable-libspeex --enable-libcelt --enable-libass \
+		--enable-libopus --enable-librtmp --enable-libjack \
+		$(vopt_if fdk_aac '--enable-nonfree --enable-libfdk-aac') \
+		--disable-libopencore_amrnb --disable-libopencore_amrwb \
+		--disable-libopenjpeg \
+		--enable-postproc --enable-opencl ${_args} \
+		$(vopt_enable x265 libx265) \
+		$(vopt_enable v4l2 libv4l2) \
+		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
+		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		$(vopt_enable dav1d libdav1d) \
+		$(vopt_enable zimg libzimg) \
+		$(vopt_enable webp libwebp) \
+		$(vopt_enable sofa libmysofa) \
+		$(vopt_enable vulkan) \
+		$(vopt_enable drm libdrm) \
+		$(vopt_enable svtav1 libsvtav1) \
+		$(vopt_enable srt libsrt) \
+		$(vopt_enable rist librist) \
+		$(vopt_enable mfx libmfx) \
+		$(vopt_if nvenc '--enable-nvenc') \
+		$(vopt_if nvdec '--enable-nvdec')
+}
+
+do_build() {
+	make ${makejobs}
+	make doc/ff{mpeg,play}.1
+}
+
+do_install() {
+	make DESTDIR=${DESTDIR} install install-man
+	rm -rf ${DESTDIR}/usr/bin
+}
+
+libavcodec4_package() {
+	short_desc="FFmpeg codec library"
+	pkg_install() {
+		vmove "usr/lib/libavcodec.so.*"
+	}
+}
+
+libavdevice4_package() {
+	short_desc="FFmpeg device handling library"
+	pkg_install() {
+		vmove "usr/lib/libavdevice.so.*"
+	}
+}
+
+libavresample4_package() {
+	short_desc="FFmpeg audio resampling library"
+	pkg_install() {
+		vmove "usr/lib/libavresample.so.*"
+	}
+}
+
+libavformat4_package() {
+	short_desc="FFmpeg file format library"
+	pkg_install() {
+		vmove "usr/lib/libavformat.so.*"
+	}
+}
+
+libavutil4_package() {
+	short_desc="FFmpeg utility library"
+	pkg_install() {
+		vmove "usr/lib/libavutil.so.*"
+	}
+}
+
+libavfilter4_package() {
+	short_desc="FFmpeg audio/video filter library"
+	pkg_install() {
+		vmove "usr/lib/libavfilter.so.*"
+	}
+}
+
+libpostproc4_package() {
+	short_desc="FFmpeg video postprocessing library"
+	pkg_install() {
+		vmove "usr/lib/libpostproc.so.*"
+	}
+}
+
+libswscale4_package() {
+	short_desc="FFmpeg video scaling library"
+	pkg_install() {
+		vmove "usr/lib/libswscale.so.*"
+	}
+}
+
+libswresample4_package() {
+	short_desc="FFmpeg video resampling library"
+	pkg_install() {
+		vmove "usr/lib/libswresample.so.*"
+	}
+}
+
+ffmpeg4-devel_package() {
+	depends="
+		libavcodec4>=${version}_${revision}
+		libavdevice4>=${version}_${revision}
+		libavformat4>=${version}_${revision}
+		libavutil4>=${version}_${revision}
+		libavfilter4>=${version}_${revision}
+		libpostproc4>=${version}_${revision}
+		libswscale4>=${version}_${revision}
+		libswresample4>=${version}_${revision}
+		libavresample4>=${version}_${revision}"
+	short_desc+=" - development files"
+	conflicts="ffmpeg-devel"
+	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
+		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
+		nostrip_files="/usr/lib/libavfilter.a"
+	fi
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.a"
+		vmove "usr/lib/*.so"
+		vmove usr/share/ffmpeg/examples
+		vmove usr/share/man/man3
+	}
+}
diff --git a/srcpkgs/libavcodec4 b/srcpkgs/libavcodec4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavcodec4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavdevice4 b/srcpkgs/libavdevice4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavdevice4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavfilter4 b/srcpkgs/libavfilter4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavfilter4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavformat4 b/srcpkgs/libavformat4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavformat4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavresample4 b/srcpkgs/libavresample4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavutil4 b/srcpkgs/libavutil4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavutil4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libpostproc4 b/srcpkgs/libpostproc4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libpostproc4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswresample4 b/srcpkgs/libswresample4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libswresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswscale4 b/srcpkgs/libswscale4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libswscale4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file

From 9322e3a14e336e7a503841fd882c8b88e12e761c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:04 -0400
Subject: [PATCH 003/113] opencv: update to 4.7.0.

---
 common/shlibs           | 104 ++++++++++++++++++++--------------------
 srcpkgs/opencv/template |   8 ++--
 2 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index dc3f03487173..eccef60021c4 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2135,58 +2135,58 @@ libcapstone.so.4 capstone-4.0_1
 libhavege.so.2 libhaveged-1.9.11_1
 libnih.so.1 libnih-1.0.3_1
 libnih-dbus.so.1 libnih-1.0.3_1
-libopencv_quality.so.406 libopencv-4.6.0_1
-libopencv_reg.so.406 libopencv-4.6.0_1
-libopencv_surface_matching.so.406 libopencv-4.6.0_1
-libopencv_xphoto.so.406 libopencv-4.6.0_1
-libopencv_freetype.so.406 libopencv-4.6.0_1
-libopencv_fuzzy.so.406 libopencv-4.6.0_1
-libopencv_hfs.so.406 libopencv-4.6.0_1
-libopencv_img_hash.so.406 libopencv-4.6.0_1
-libopencv_line_descriptor.so.406 libopencv-4.6.0_1
-libopencv_saliency.so.406 libopencv-4.6.0_1
-libopencv_structured_light.so.406 libopencv-4.6.0_1
-libopencv_aruco.so.406 libopencv-4.6.0_1
-libopencv_bgsegm.so.406 libopencv-4.6.0_1
-libopencv_bioinspired.so.406 libopencv-4.6.0_1
-libopencv_ccalib.so.406 libopencv-4.6.0_1
-libopencv_face.so.406 libopencv-4.6.0_1
-libopencv_tracking.so.406 libopencv-4.6.0_1
-libopencv_xfeatures2d.so.406 libopencv-4.6.0_1
-libopencv_optflow.so.406 libopencv-4.6.0_1
-libopencv_ximgproc.so.406 libopencv-4.6.0_1
-libopencv_plot.so.406 libopencv-4.6.0_1
-libopencv_text.so.406 libopencv-4.6.0_1
-libopencv_ml.so.406 libopencv-4.6.0_1
-libopencv_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn.so.406 libopencv-4.6.0_1
-libopencv_shape.so.406 libopencv-4.6.0_1
-libopencv_stitching.so.406 libopencv-4.6.0_1
-libopencv_photo.so.406 libopencv-4.6.0_1
-libopencv_video.so.406 libopencv-4.6.0_1
-libopencv_calib3d.so.406 libopencv-4.6.0_1
-libopencv_features2d.so.406 libopencv-4.6.0_1
-libopencv_flann.so.406 libopencv-4.6.0_1
-libopencv_highgui.so.406 libopencv-4.6.0_1
-libopencv_videoio.so.406 libopencv-4.6.0_1
-libopencv_imgcodecs.so.406 libopencv-4.6.0_1
-libopencv_imgproc.so.406 libopencv-4.6.0_1
-libopencv_core.so.406 libopencv-4.6.0_1
-libopencv_superres.so.406 libopencv-4.6.0_1
-libopencv_videostab.so.406 libopencv-4.6.0_1
-libopencv_gapi.so.406 libopencv-4.6.0_1
-libopencv_xobjdetect.so.406 libopencv-4.6.0_1
-libopencv_datasets.so.406 libopencv-4.6.0_1
-libopencv_dnn_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn_superres.so.406 libopencv-4.6.0_1
-libopencv_dpm.so.406 libopencv-4.6.0_1
-libopencv_phase_unwrapping.so.406 libopencv-4.6.0_1
-libopencv_stereo.so.406 libopencv-4.6.0_1
-libopencv_rapid.so.406 libopencv-4.6.0_1
-libopencv_intensity_transform.so.406 libopencv-4.6.0_1
-libopencv_alphamat.so.406 libopencv-4.6.0_1
-libopencv_barcode.so.406 libopencv-4.6.0_1
-libopencv_mcc.so.406 libopencv-4.6.0_1
+libopencv_quality.so.407 libopencv-4.7.0_1
+libopencv_reg.so.407 libopencv-4.7.0_1
+libopencv_surface_matching.so.407 libopencv-4.7.0_1
+libopencv_xphoto.so.407 libopencv-4.7.0_1
+libopencv_freetype.so.407 libopencv-4.7.0_1
+libopencv_fuzzy.so.407 libopencv-4.7.0_1
+libopencv_hfs.so.407 libopencv-4.7.0_1
+libopencv_img_hash.so.407 libopencv-4.7.0_1
+libopencv_line_descriptor.so.407 libopencv-4.7.0_1
+libopencv_saliency.so.407 libopencv-4.7.0_1
+libopencv_structured_light.so.407 libopencv-4.7.0_1
+libopencv_aruco.so.407 libopencv-4.7.0_1
+libopencv_bgsegm.so.407 libopencv-4.7.0_1
+libopencv_bioinspired.so.407 libopencv-4.7.0_1
+libopencv_ccalib.so.407 libopencv-4.7.0_1
+libopencv_face.so.407 libopencv-4.7.0_1
+libopencv_tracking.so.407 libopencv-4.7.0_1
+libopencv_xfeatures2d.so.407 libopencv-4.7.0_1
+libopencv_optflow.so.407 libopencv-4.7.0_1
+libopencv_ximgproc.so.407 libopencv-4.7.0_1
+libopencv_plot.so.407 libopencv-4.7.0_1
+libopencv_text.so.407 libopencv-4.7.0_1
+libopencv_ml.so.407 libopencv-4.7.0_1
+libopencv_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn.so.407 libopencv-4.7.0_1
+libopencv_shape.so.407 libopencv-4.7.0_1
+libopencv_stitching.so.407 libopencv-4.7.0_1
+libopencv_photo.so.407 libopencv-4.7.0_1
+libopencv_video.so.407 libopencv-4.7.0_1
+libopencv_calib3d.so.407 libopencv-4.7.0_1
+libopencv_features2d.so.407 libopencv-4.7.0_1
+libopencv_flann.so.407 libopencv-4.7.0_1
+libopencv_highgui.so.407 libopencv-4.7.0_1
+libopencv_videoio.so.407 libopencv-4.7.0_1
+libopencv_imgcodecs.so.407 libopencv-4.7.0_1
+libopencv_imgproc.so.407 libopencv-4.7.0_1
+libopencv_core.so.407 libopencv-4.7.0_1
+libopencv_superres.so.407 libopencv-4.7.0_1
+libopencv_videostab.so.407 libopencv-4.7.0_1
+libopencv_gapi.so.407 libopencv-4.7.0_1
+libopencv_xobjdetect.so.407 libopencv-4.7.0_1
+libopencv_datasets.so.407 libopencv-4.7.0_1
+libopencv_dnn_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn_superres.so.407 libopencv-4.7.0_1
+libopencv_dpm.so.407 libopencv-4.7.0_1
+libopencv_phase_unwrapping.so.407 libopencv-4.7.0_1
+libopencv_stereo.so.407 libopencv-4.7.0_1
+libopencv_rapid.so.407 libopencv-4.7.0_1
+libopencv_intensity_transform.so.407 libopencv-4.7.0_1
+libopencv_alphamat.so.407 libopencv-4.7.0_1
+libopencv_barcode.so.407 libopencv-4.7.0_1
+libopencv_mcc.so.407 libopencv-4.7.0_1
 libuniconf.so.4.6 wvstreams-4.6.1_20
 libwvbase.so.4.6 wvstreams-4.6.1_20
 libwvutils.so.4.6 wvstreams-4.6.1_20
diff --git a/srcpkgs/opencv/template b/srcpkgs/opencv/template
index 69c635b1ad2b..41f3183f1582 100644
--- a/srcpkgs/opencv/template
+++ b/srcpkgs/opencv/template
@@ -1,7 +1,7 @@
 # Template file for 'opencv'
 pkgname=opencv
-version=4.6.0
-revision=4
+version=4.7.0
+revision=1
 create_wrksrc=yes
 build_wrksrc=${pkgname}-${version}
 build_style=cmake
@@ -24,8 +24,8 @@ homepage="https://opencv.org"
 changelog="https://github.com/opencv/opencv/wiki/ChangeLog"
 distfiles="https://github.com/opencv/opencv/archive/${version}.tar.gz
  https://github.com/opencv/opencv_contrib/archive/${version}.tar.gz>contrib.tar.gz"
-checksum="1ec1cba65f9f20fe5a41fda1586e01c70ea0c9a6d7b67c9e13edf0cfe2239277
- 1777d5fd2b59029cf537e5fd6f8aa68d707075822f90bde683fcde086f85f7a7"
+checksum="8df0079cdbe179748a18d44731af62a245a45ebf5085223dc03133954c662973
+ 42df840cf9055e59d0e22c249cfb19f04743e1bdad113d31b1573d3934d62584"
 patch_args="-Np1 -d ${build_wrksrc}"
 # tests hang indenfinitely, even with test data included
 make_check=no

From 5d5b71488e1ad44ba40c9d71485961060dd96f95 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 004/113] actiona: revbump for opencv-4.7.0

---
 srcpkgs/actiona/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/actiona/template b/srcpkgs/actiona/template
index cf5f0b7a2ae6..0d899311e6df 100644
--- a/srcpkgs/actiona/template
+++ b/srcpkgs/actiona/template
@@ -1,7 +1,7 @@
 # Template file for 'actiona'
 pkgname=actiona
 version=3.10.1
-revision=2
+revision=3
 build_style=qmake
 configure_args="PKGCONFIG_OPENCV=opencv4"
 hostmakedepends="pkg-config qt5-plugin-mysql qt5-qmake qt5-host-tools"

From 2f3c074e2c49683f94c4c4848344ee2f306be3ca Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 005/113] gmic: revbump for opencv-4.7.0

---
 srcpkgs/gmic/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gmic/template b/srcpkgs/gmic/template
index 24a9c7218fdf..0bb4034d5cc8 100644
--- a/srcpkgs/gmic/template
+++ b/srcpkgs/gmic/template
@@ -1,7 +1,7 @@
 # Template file for 'gmic'
 pkgname=gmic
 version=3.1.6
-revision=3
+revision=4
 _zart_hash=34ebf6cce0bafb98abe57cec83c4a02cd1abeca0
 create_wrksrc=yes
 build_wrksrc="src"

From 7db44c99d9a831f945db997e92a49eda7e2bfe45 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 006/113] qimgv: revbump for opencv-4.7.0

---
 srcpkgs/qimgv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qimgv/template b/srcpkgs/qimgv/template
index 7eb30db33992..dd341dfe1bfc 100644
--- a/srcpkgs/qimgv/template
+++ b/srcpkgs/qimgv/template
@@ -1,7 +1,7 @@
 # Template file for 'qimgv'
 pkgname=qimgv
 version=1.0.2
-revision=2
+revision=3
 build_style=cmake
 configure_args="$(vopt_if video -DVIDEO_SUPPORT=ON -DVIDEO_SUPPORT=OFF)
  $(vopt_if scale -DOPENCV_SUPPORT=ON -DOPENCV_SUPPORT=OFF)

From d8f88835d68083e63a383b864338e0f2524d9d2a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 007/113] retroshare: revbump for opencv-4.7.0

---
 srcpkgs/retroshare/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroshare/template b/srcpkgs/retroshare/template
index 8a0786c21a08..72023fa98b75 100644
--- a/srcpkgs/retroshare/template
+++ b/srcpkgs/retroshare/template
@@ -1,7 +1,7 @@
 # Template file for 'retroshare'
 pkgname=retroshare
 version=0.6.6
-revision=2
+revision=4
 build_style=qmake
 #XXX broadcast feature requires an ancient udp-discovery-cpp which either needs
 # to be fetched+patched (FTBFS) here or packaged :/

From 2e2de35020e2865858048bc451db05061db25daf Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 008/113] waifu2x-converter-cpp: revbump for opencv-4.7.0

---
 srcpkgs/waifu2x-converter-cpp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waifu2x-converter-cpp/template b/srcpkgs/waifu2x-converter-cpp/template
index 8c095d0d7bab..aa52d8c981a8 100644
--- a/srcpkgs/waifu2x-converter-cpp/template
+++ b/srcpkgs/waifu2x-converter-cpp/template
@@ -1,7 +1,7 @@
 # Template file for 'waifu2x-converter-cpp'
 pkgname=waifu2x-converter-cpp
 version=5.2.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DINSTALL_MODELS=ON"
 hostmakedepends="pkg-config"

From 51c5a2deb198c789c19a2434e9d4723be69aedc3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:38 -0400
Subject: [PATCH 009/113] vlc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/vlc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/vlc/template b/srcpkgs/vlc/template
index 210762b0a7e2..855ca5238662 100644
--- a/srcpkgs/vlc/template
+++ b/srcpkgs/vlc/template
@@ -1,7 +1,7 @@
 # Template file for 'vlc'
 pkgname=vlc
 version=3.0.18
-revision=3
+revision=4
 build_style=gnu-configure
 configure_args="--disable-gme --disable-libtar --enable-jack
  --enable-live555 --disable-fluidsynth --enable-dvdread
@@ -25,7 +25,7 @@ lib32disabled=yes
 hostmakedepends="automake libtool pkg-config flex gettext libgcrypt-devel
  live555-devel gettext-devel $(vopt_if lua lua52) $(vopt_if chromecast protobuf)"
 makedepends="
- avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg-devel freefont-ttf
+ avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg4-devel freefont-ttf
  gnutls-devel jack-devel liba52-devel libass-devel libbluray-devel
  libcdio-devel libdca-devel libdvbpsi-devel libdvdnav-devel libmad-devel
  libmatroska-devel libmodplug-devel libmpcdec-devel libmpeg2-devel

From d08fc9668b239a765e40a47cdc7644efe58b4b16 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:55 -0400
Subject: [PATCH 010/113] osg: revbump for ffmpeg4-4.4.3

---
 srcpkgs/osg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/osg/template b/srcpkgs/osg/template
index a9ebbd287933..755793f7e11b 100644
--- a/srcpkgs/osg/template
+++ b/srcpkgs/osg/template
@@ -8,7 +8,7 @@ build_helper="qemu"
 configure_args="-DLIB_POSTFIX="
 hostmakedepends="pkg-config xrandr"
 makedepends="MesaLib-devel gtkglext-devel libcurl-devel giflib-devel librsvg-devel
- jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg-devel xine-lib-devel
+ jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg4-devel xine-lib-devel
  SDL2-devel gst-plugins-base1-devel
  $(vopt_if openexr libopenexr-devel)
  $(vopt_if poppler poppler-glib-devel)

From 6c8e481cabd51abe46c6defb4324ff966ad71af2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:13 -0400
Subject: [PATCH 011/113] xine-lib: revbump for ffmpeg4-4.4.3

---
 srcpkgs/xine-lib/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/xine-lib/template b/srcpkgs/xine-lib/template
index f713eff49b07..ed6194c17d11 100644
--- a/srcpkgs/xine-lib/template
+++ b/srcpkgs/xine-lib/template
@@ -1,6 +1,6 @@
 # Template file for 'xine-lib'
 pkgname=xine-lib
-version=1.2.12
+version=1.2.13
 revision=1
 build_style=gnu-configure
 configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
@@ -8,7 +8,7 @@ configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
 hostmakedepends="automake gettext-devel libtool pkg-config perl"
 makedepends="
  zlib-devel alsa-lib-devel libxcb-devel libSM-devel libXext-devel libXv-devel
- libXvMC-devel liba52-devel libmad-devel ffmpeg-devel pulseaudio-devel
+ libXvMC-devel liba52-devel libmad-devel ffmpeg4-devel pulseaudio-devel
  jack-devel samba-devel libflac-devel libmodplug-devel libmpcdec-devel
  speex-devel libtheora-devel libvorbis-devel libdca-devel faad2-devel
  libcdio-devel libbluray-devel aalib-devel libcaca-devel libXinerama-devel
@@ -19,7 +19,7 @@ license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="http://www.xine-project.org"
 changelog="https://sourceforge.net/projects/xine/files/xine-lib/${version}/README.txt/view"
 distfiles="${SOURCEFORGE_SITE}/xine/${pkgname}-${version}.tar.xz"
-checksum=d606270468e1540c2a89c0d7f5fdf11e17ecc0c2698cc0bcb1065ff26abee098
+checksum=5f10d6d718a4a51c17ed1b32b031d4f9b80b061e8276535b2be31e5ac4b75e6f
 
 case "$XBPS_TARGET_MACHINE" in
 	i686-musl)

From 5ec2050bf465c2f79a4b1a3bc0ba4d2403ecee8c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 012/113] QMPlay2: revbump for ffmpeg-6.0

---
 srcpkgs/QMPlay2/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/QMPlay2/template b/srcpkgs/QMPlay2/template
index 850df9d418b9..8d2ce7a76156 100644
--- a/srcpkgs/QMPlay2/template
+++ b/srcpkgs/QMPlay2/template
@@ -1,7 +1,7 @@
 # Template file for 'QMPlay2'
 pkgname=QMPlay2
 version=23.06.17
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools"
 makedepends="alsa-lib-devel ffmpeg-devel libass-devel libcdio-devel libgme-devel

From 59ad32e5a66df812b359ed5050a678b72ed0030a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 013/113] alsa-plugins: revbump for ffmpeg-6.0

---
 srcpkgs/alsa-plugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/alsa-plugins/template b/srcpkgs/alsa-plugins/template
index 0bfa6d9fd264..a5708a7d82a8 100644
--- a/srcpkgs/alsa-plugins/template
+++ b/srcpkgs/alsa-plugins/template
@@ -1,7 +1,7 @@
 # Template file for 'alsa-plugins'
 pkgname=alsa-plugins
 version=1.2.7.1
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--disable-maemo-plugin"
 hostmakedepends="pkg-config"

From fd8cfef1e07928358e3426fdff5f0459e270cf4b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 014/113] arcan: revbump for ffmpeg-6.0

---
 srcpkgs/arcan/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/arcan/template b/srcpkgs/arcan/template
index 7be9652eccf3..ccc7df11ceac 100644
--- a/srcpkgs/arcan/template
+++ b/srcpkgs/arcan/template
@@ -2,7 +2,7 @@
 # !! keep synced with: acfgfs aclip aloadimage
 pkgname=arcan
 version=0.6.2.1
-revision=1
+revision=2
 create_wrksrc=yes
 build_wrksrc=arcan/src
 build_style=cmake

From 25f25776ac03d781c18f6ebe4c4b18f81812c3f0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 015/113] attract: revbump for ffmpeg4-4.4.3

---
 srcpkgs/attract/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/attract/template b/srcpkgs/attract/template
index 26144e931a3c..e760bf0d18ae 100644
--- a/srcpkgs/attract/template
+++ b/srcpkgs/attract/template
@@ -1,12 +1,12 @@
 # Template file for 'attract'
 pkgname=attract
 version=2.6.2
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="VERBOSE=1"
 make_use_env=yes
 hostmakedepends="pkg-config"
-makedepends="SFML-devel ffmpeg-devel fontconfig-devel glu-devel libarchive-devel
+makedepends="SFML-devel ffmpeg4-devel fontconfig-devel glu-devel libarchive-devel
  libcurl-devel libjpeg-turbo-devel xine-lib rapidjson libXrandr-devel"
 depends="git"
 short_desc="Attract-Mode is a graphical frontend for emulators"

From f37fecf29b8b69ad2b22c682fe243e1b02c43270 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 016/113] aubio: revbump for ffmpeg-6.0

---
 srcpkgs/aubio/patches/ffmpeg5.patch | 25 +++++++++++++++++++++++++
 srcpkgs/aubio/template              |  2 +-
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/aubio/patches/ffmpeg5.patch

diff --git a/srcpkgs/aubio/patches/ffmpeg5.patch b/srcpkgs/aubio/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..aace41a6e6d9
--- /dev/null
+++ b/srcpkgs/aubio/patches/ffmpeg5.patch
@@ -0,0 +1,25 @@
+From 8a05420e5dd8c7b8b2447f82dc919765876511b3 Mon Sep 17 00:00:00 2001
+From: Paul Brossier <piem@piem.org>
+Date: Tue, 25 Jan 2022 18:30:27 +0100
+Subject: [PATCH] [source_avcodec] define FF_API_LAVF_AVCTX for libavcodec >
+ 59, thx @berolinux (closes gh-353)
+
+---
+ src/io/source_avcodec.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/io/source_avcodec.c b/src/io/source_avcodec.c
+index e0ae93b5..1421bd9a 100644
+--- a/src/io/source_avcodec.c
++++ b/src/io/source_avcodec.c
+@@ -68,6 +68,10 @@
+ #define AUBIO_AVCODEC_MAX_BUFFER_SIZE AV_INPUT_BUFFER_MIN_SIZE
+ #endif
+ 
++#if LIBAVCODEC_VERSION_MAJOR >= 59
++#define FF_API_LAVF_AVCTX 1
++#endif
++
+ struct _aubio_source_avcodec_t {
+   uint_t hop_size;
+   uint_t samplerate;
diff --git a/srcpkgs/aubio/template b/srcpkgs/aubio/template
index ad1c4b256991..7d875cc02541 100644
--- a/srcpkgs/aubio/template
+++ b/srcpkgs/aubio/template
@@ -1,7 +1,7 @@
 # Template file for 'aubio'
 pkgname=aubio
 version=0.4.9
-revision=1
+revision=2
 build_style=waf3
 # XXX lash, pure and swig support.
 hostmakedepends="pkg-config txt2man"

From ddb0c6df3f90ba9f5d8eb2dd3e57a2408e14faa2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 017/113] audacious-plugins: revbump for ffmpeg-6.0

---
 .../audacious-plugins/patches/ffmpeg5.patch   | 43 +++++++++++++++++++
 srcpkgs/audacious-plugins/template            |  2 +-
 2 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/audacious-plugins/patches/ffmpeg5.patch

diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg5.patch b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..4e5e34099d71
--- /dev/null
+++ b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
@@ -0,0 +1,43 @@
+commit 298aa371c56c2f52c25a33d9bdec4918b11cebdc
+Author: tibequadorian <tibequadorian@posteo.de>
+Date:   Sat Mar 19 18:40:12 2022 +0100
+
+    audacious-plugins: rebuild against ffmpeg-5.0
+
+diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+new file mode 100644
+index 0000000000..617c11215b
+--- /dev/null
++++ b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+@@ -0,0 +1,31 @@
++From f60beb400eeb1e4778bbfd738bc4a4ccef3de539 Mon Sep 17 00:00:00 2001
++From: John Lindgren <john@jlindgren.net>
++Date: Sat, 5 Mar 2022 12:05:34 -0500
++Subject: [PATCH] Fix build with FFmpeg 5.0
++
++---
++ src/ffaudio/ffaudio-core.cc | 4 ++--
++ 1 file changed, 2 insertions(+), 2 deletions(-)
++
++diff --git a/src/ffaudio/ffaudio-core.cc b/src/ffaudio/ffaudio-core.cc
++index 16dc63e3a..a2b95fd6c 100644
++--- a/src/ffaudio/ffaudio-core.cc
+++++ b/src/ffaudio/ffaudio-core.cc
++@@ -274,7 +274,7 @@ static AVInputFormat * get_format_by_content (const char * name, VFSFile & file)
++         AVProbeData d = {name, buf, filled};
++         score = target;
++ 
++-        f = av_probe_input_format2 (& d, true, & score);
+++        f = (AVInputFormat *) av_probe_input_format2 (& d, true, & score);
++         if (f)
++             break;
++ 
++@@ -347,7 +347,7 @@ static bool find_codec (AVFormatContext * c, CodecInfo * cinfo)
++ #endif
++         if (stream && stream->codecpar && stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
++         {
++-            AVCodec * codec = avcodec_find_decoder (stream->codecpar->codec_id);
+++            AVCodec * codec = (AVCodec *) avcodec_find_decoder (stream->codecpar->codec_id);
++ 
++             if (codec)
++             {
diff --git a/srcpkgs/audacious-plugins/template b/srcpkgs/audacious-plugins/template
index 88cbc1671fc6..beebfae59ed4 100644
--- a/srcpkgs/audacious-plugins/template
+++ b/srcpkgs/audacious-plugins/template
@@ -2,7 +2,7 @@
 #Keep in sync with audacious!
 pkgname=audacious-plugins
 version=4.3.1
-revision=1
+revision=2
 build_style=meson
 configure_args="$(vopt_bool gtk3 gtk) $(vopt_bool gtk3)
  $(vopt_bool qt) $(vopt_bool qt qt6)"

From e2b3ae3dfeb390d9d6d69fd4235c33e8571def73 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 018/113] audacity: revbump for ffmpeg4-4.4.3

---
 srcpkgs/audacity/template | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/audacity/template b/srcpkgs/audacity/template
index d509c0a89407..11e20255685b 100644
--- a/srcpkgs/audacity/template
+++ b/srcpkgs/audacity/template
@@ -1,7 +1,7 @@
 # Template file for 'audacity'
 pkgname=audacity
 version=2.4.1
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--with-ffmpeg=system --with-libsndfile=system --with-expat=system
  --with-libsoxr=system --with-lame=system --with-lv2=system ac_cv_path_WX_CONFIG=wx-config-gtk3"
@@ -9,7 +9,7 @@ hostmakedepends="pkg-config cmake gettext libtool m4 which"
 makedepends="jack-devel wxWidgets-gtk3-devel gtk+3-devel
  libmad-devel soundtouch-devel libsoxr-devel
  vamp-plugin-sdk-devel lame-devel libid3tag-devel libflac-devel
- ffmpeg-devel twolame-devel serd-devel lv2 lilv-devel suil-devel"
+ ffmpeg4-devel twolame-devel serd-devel lv2 lilv-devel suil-devel"
 depends="desktop-file-utils hicolor-icon-theme"
 short_desc="Graphical cross-platform audio editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
@@ -33,5 +33,4 @@ post_install() {
 	vcopy plug-ins /usr/share/audacity
 
 	rm ${DESTDIR}/usr/share/doc/audacity/LICENSE.txt
-	vlicense LICENSE.txt LICENSE
 }

From 147175e20bb75a3cef6d17a0207788f1a0fc72d3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 019/113] avidemux: revbump for ffmpeg-6.0

---
 srcpkgs/avidemux/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/avidemux/template b/srcpkgs/avidemux/template
index 253a0243e225..557285982d2b 100644
--- a/srcpkgs/avidemux/template
+++ b/srcpkgs/avidemux/template
@@ -1,7 +1,7 @@
 # Template file for 'avidemux'
 pkgname=avidemux
 version=2.8.0
-revision=2
+revision=3
 # Can't be compiled for aarch64, arm* or mips*
 archs="x86_64* i686*"
 hostmakedepends="cmake pkg-config qt5-host-tools qt5-devel tar yasm"

From 2a7225b42eab8c5ab1d01041c7fcdfa40c2521eb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 020/113] baresip: revbump for ffmpeg-6.0

---
 srcpkgs/baresip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/baresip/template b/srcpkgs/baresip/template
index f1bd1817048b..b21e22334316 100644
--- a/srcpkgs/baresip/template
+++ b/srcpkgs/baresip/template
@@ -1,7 +1,7 @@
 # Template file for 'baresip'
 pkgname=baresip
 version=2.10.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config glib-devel"
 makedepends="libgsm-devel libpng-devel openssl-devel libsndfile-devel

From 9903f6a91b51a087aa53cfc3bd6abecbe5a7cc7e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 021/113] blender: revbump for ffmpeg-6.0

---
 srcpkgs/blender/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index ec724bb0a6dc..0f72876d4d70 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -1,7 +1,7 @@
 # Template file for 'blender'
 pkgname=blender
 version=3.5.1
-revision=1
+revision=2
 archs="x86_64* ppc64*"
 build_style="cmake"
 pycompile_dirs="/usr/share/blender/${version%.*}/scripts"
@@ -9,8 +9,8 @@ configure_args="-DWITH_INSTALL_PORTABLE=OFF -DWITH_PYTHON_INSTALL=OFF
  -DWITH_JACK=ON -DWITH_CODEC_FFMPEG=ON -DWITH_CODEC_SNDFILE=ON -DWITH_OPENMP=ON
  -DWITH_FFTW3=ON -DWITH_MOD_OCEANSIM=ON -DWITH_CYCLES_EMBREE=OFF -DWITH_OPENCOLORIO=ON
  -DWITH_IMAGE_OPENEXR=ON -DWITH_IMAGE_OPENJPEG=ON -DWITH_OPENSUBDIV=ON
- -DWITH_OPENCOLLADA=ON -DWITH_SYSTEM_GLEW=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
- -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_LIBDECOR=ON
+ -DWITH_OPENCOLLADA=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
+ -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_WAYLAND_LIBDECOR=ON
  -DWITH_BUILDINFO=OFF -DPYTHON_VERSION=${py3_ver} -DPYTHON_LIBPATH=/usr/lib
  -DPYTHON_LIBRARY=python${py3_ver}${py3_abiver} -DPYTHON_INCLUDE_DIRS=/${py3_inc}
  -DWITH_SYSTEM_LZO=ON -DWITH_SYSTEM_EIGEN3=ON -DWITH_SYSTEM_FREETYPE=ON"

From 5692c6278f879598c178f0ae4d5aa9b5988c8bbd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 022/113] cantata: revbump for ffmpeg-6.0

---
 srcpkgs/cantata/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cantata/template b/srcpkgs/cantata/template
index 4b417d80d5c2..8a90aaa4c07a 100644
--- a/srcpkgs/cantata/template
+++ b/srcpkgs/cantata/template
@@ -1,7 +1,7 @@
 # Template file for 'cantata'
 pkgname=cantata
 version=2.5.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools qt5-tools"
 makedepends="qt5-devel qt5-tools-devel qt5-svg-devel qt5-xmlpatterns-devel

From f79f828255b06246bdb7684b843c26bce36d63ff Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 023/113] ccextractor: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ccextractor/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/ccextractor/template b/srcpkgs/ccextractor/template
index 9abcd82852b2..6eccad5885af 100644
--- a/srcpkgs/ccextractor/template
+++ b/srcpkgs/ccextractor/template
@@ -1,12 +1,12 @@
 # Template file for 'ccextractor'
 pkgname=ccextractor
 version=0.93
-revision=1
+revision=2
 build_wrksrc="linux"
 build_style=gnu-configure
 configure_args="--enable-ocr --enable-hardsubx"
 hostmakedepends="automake pkg-config"
-makedepends="leptonica-devel tesseract-ocr-devel ffmpeg-devel"
+makedepends="leptonica-devel tesseract-ocr-devel ffmpeg4-devel"
 short_desc="Extract subtitles from video streams"
 maintainer="newbluemoon <blaumolch@mailbox.org>"
 license="GPL-2.0-or-later"

From 888207b859b21519e007fa45a6aad7d7e31ab7d9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 024/113] chromaprint: revbump for ffmpeg-6.0

---
 srcpkgs/chromaprint/patches/ffmpeg5.patch | 569 ++++++++++++++++++++++
 srcpkgs/chromaprint/template              |   2 +-
 2 files changed, 570 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromaprint/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromaprint/patches/ffmpeg5.patch b/srcpkgs/chromaprint/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..a9fd307a23c8
--- /dev/null
+++ b/srcpkgs/chromaprint/patches/ffmpeg5.patch
@@ -0,0 +1,569 @@
+From 8ccad6937177b1b92e40ab8f4447ea27bac009a7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= <lalinsky@gmail.com>
+Date: Fri, 4 Nov 2022 21:47:38 +0100
+Subject: [PATCH] Use FFmpeg 5.x (#120)
+
+* Use FFmpeg 5.1.2 for CI builds
+
+* Build on Ubuntu 20.04
+
+* Upgrade code to FFmpeg 5.x APIs
+
+* Only set FFmpeg include dirs if building tools
+
+* No longer needed
+
+* Use ubuntu 20.04
+---
+ .github/workflows/build.yml                   |   6 +-
+ CMakeLists.txt                                |  16 --
+ package/build.sh                              |   4 +-
+ src/audio/ffmpeg_audio_processor.h            |   2 -
+ src/audio/ffmpeg_audio_processor_avresample.h |  72 -------
+ src/audio/ffmpeg_audio_processor_swresample.h |  18 +-
+ src/audio/ffmpeg_audio_reader.h               | 197 +++++++++---------
+ tests/CMakeLists.txt                          |   6 +
+ 8 files changed, 122 insertions(+), 199 deletions(-)
+ delete mode 100644 src/audio/ffmpeg_audio_processor_avresample.h
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index f8d6a32..4da2405 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -84,9 +84,6 @@ find_package(FFmpeg)
+ if(FFMPEG_LIBRARIES)
+ 	cmake_push_check_state(RESET)
+ 	set(CMAKE_REQUIRED_LIBRARIES ${FFMPEG_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -lm)
+-	check_function_exists(av_packet_unref HAVE_AV_PACKET_UNREF)
+-	check_function_exists(av_frame_alloc HAVE_AV_FRAME_ALLOC)
+-	check_function_exists(av_frame_free HAVE_AV_FRAME_FREE)
+ 	cmake_pop_check_state()
+ endif()
+
+@@ -163,14 +160,11 @@ message(STATUS "Using ${FFT_LIB} for FFT calculations")
+ if(NOT AUDIO_PROCESSOR_LIB)
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+ 		set(AUDIO_PROCESSOR_LIB "swresample")
+-	elseif(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(AUDIO_PROCESSOR_LIB "avresample")
+ 	endif()
+ endif()
+
+ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE OFF)
+ 		set(USE_SWRESAMPLE ON)
+ 		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBSWRESAMPLE_LIBRARIES})
+ 		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBSWRESAMPLE_INCLUDE_DIRS})
+@@ -178,16 +172,6 @@ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+ 	endif()
+ 	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+-elseif(AUDIO_PROCESSOR_LIB STREQUAL "avresample")
+-	if(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE ON)
+-		set(USE_SWRESAMPLE OFF)
+-		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBAVRESAMPLE_LIBRARIES})
+-		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBAVRESAMPLE_INCLUDE_DIRS})
+-	else()
+-		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+-	endif()
+-	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+ else()
+ 	message(STATUS "Building without audio conversion support, please install FFmpeg with libswresample")
+ endif()
+diff --git a/package/build.sh b/package/build.sh
+index da631ae..b41d36e 100755
+--- a/package/build.sh
++++ b/package/build.sh
+@@ -7,8 +7,8 @@ set -eux
+
+ BASE_DIR=$(cd $(dirname $0)/.. && pwd)
+
+-FFMPEG_VERSION=4.4.1
+-FFMPEG_BUILD_TAG=v4.4.1-1
++FFMPEG_VERSION=5.1.2
++FFMPEG_BUILD_TAG=v${FFMPEG_VERSION}-1
+
+ TMP_BUILD_DIR=$BASE_DIR/$(mktemp -d build.XXXXXXXX)
+ trap 'rm -rf $TMP_BUILD_DIR' EXIT
+diff --git a/src/audio/ffmpeg_audio_processor.h b/src/audio/ffmpeg_audio_processor.h
+index 7628fc7..39f4f6d 100644
+--- a/src/audio/ffmpeg_audio_processor.h
++++ b/src/audio/ffmpeg_audio_processor.h
+@@ -10,8 +10,6 @@
+
+ #if defined(USE_SWRESAMPLE)
+ #include "audio/ffmpeg_audio_processor_swresample.h"
+-#elif defined(USE_AVRESAMPLE)
+-#include "audio/ffmpeg_audio_processor_avresample.h"
+ #else
+ #error "no audio processing library"
+ #endif
+diff --git a/src/audio/ffmpeg_audio_processor_avresample.h b/src/audio/ffmpeg_audio_processor_avresample.h
+deleted file mode 100644
+index bd85f92..0000000
+--- a/src/audio/ffmpeg_audio_processor_avresample.h
++++ /dev/null
+@@ -1,72 +0,0 @@
+-// Copyright (C) 2016  Lukas Lalinsky
+-// Distributed under the MIT license, see the LICENSE file for details.
+-
+-#ifndef CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-#define CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-
+-extern "C" {
+-#include <libavresample/avresample.h>
+-}
+-
+-namespace chromaprint {
+-
+-class FFmpegAudioProcessor {
+-public:
+-	FFmpegAudioProcessor() {
+-		m_resample_ctx = avresample_alloc_context();
+-	}
+-
+-	~FFmpegAudioProcessor() {
+-		avresample_free(&m_resample_ctx);
+-	}
+-
+-	void SetCompatibleMode() {
+-		av_opt_set_int(m_resample_ctx, "filter_size", 16, 0);
+-		av_opt_set_int(m_resample_ctx, "phase_shift", 8, 0);
+-		av_opt_set_int(m_resample_ctx, "linear_interp", 1, 0);
+-		av_opt_set_double(m_resample_ctx, "cutoff", 0.8, 0);
+-	}
+-
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "in_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_rate", sample_rate, 0);
+-	}
+-
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "out_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_rate, 0);
+-	}
+-
+-	int Init() {
+-		return avresample_open(m_resample_ctx);
+-	}
+-
+-	int Convert(uint8_t **out, int out_count, const uint8_t **in, int in_count) {
+-		return avresample_convert(m_resample_ctx, out, 0, out_count, (uint8_t **) in, 0, in_count);
+-	}
+-
+-	int Flush(uint8_t **out, int out_count) {
+-		return avresample_read(m_resample_ctx, out, out_count);
+-	}
+-
+-private:
+-	AVAudioResampleContext *m_resample_ctx = nullptr;
+-};
+-
+-}; // namespace chromaprint
+-
+-#endif
+diff --git a/src/audio/ffmpeg_audio_processor_swresample.h b/src/audio/ffmpeg_audio_processor_swresample.h
+index b86266b..b1d4bea 100644
+--- a/src/audio/ffmpeg_audio_processor_swresample.h
++++ b/src/audio/ffmpeg_audio_processor_swresample.h
+@@ -28,30 +28,28 @@ public:
+ 		av_opt_set_double(m_swr_ctx, "cutoff", 0.8, 0);
+ 	}
+
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "icl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "ich", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetInputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "in_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "isf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "in_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "isr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "in_sample_rate", sample_rate, 0);
+ 	}
+
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "ocl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "och", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetOutputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "out_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "osf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "out_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "osr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "out_sample_rate", sample_rate, 0);
+ 	}
+
+ 	int Init() {
+diff --git a/src/audio/ffmpeg_audio_reader.h b/src/audio/ffmpeg_audio_reader.h
+index 5550164..1c6b346 100644
+--- a/src/audio/ffmpeg_audio_reader.h
++++ b/src/audio/ffmpeg_audio_reader.h
+@@ -62,7 +62,7 @@ public:
+ 	bool Read(const int16_t **data, size_t *size);
+
+ 	bool IsOpen() const { return m_opened; }
+-	bool IsFinished() const { return m_finished && !m_got_frame; }
++	bool IsFinished() const { return !m_has_more_packets && !m_has_more_frames; }
+
+ 	std::string GetError() const { return m_error; }
+ 	int GetErrorCode() const { return m_error_code; }
+@@ -74,20 +74,19 @@ private:
+ 	uint8_t *m_convert_buffer[1] = { nullptr };
+ 	int m_convert_buffer_nb_samples = 0;
+
+-	AVInputFormat *m_input_fmt = nullptr;
++	const AVInputFormat *m_input_fmt = nullptr;
+ 	AVDictionary *m_input_opts = nullptr;
+
+ 	AVFormatContext *m_format_ctx = nullptr;
+ 	AVCodecContext *m_codec_ctx = nullptr;
+-	AVFrame *m_frame = nullptr;
+ 	int m_stream_index = -1;
+ 	std::string m_error;
+ 	int m_error_code = 0;
+-	bool m_finished = false;
+ 	bool m_opened = false;
+-	int m_got_frame = 0;
+-	AVPacket m_packet;
+-	AVPacket m_packet0;
++	bool m_has_more_packets = true;
++	bool m_has_more_frames = true;
++	AVPacket *m_packet = nullptr;
++	AVFrame *m_frame = nullptr;
+
+ 	int m_output_sample_rate = 0;
+ 	int m_output_channels = 0;
+@@ -98,19 +97,12 @@ private:
+
+ inline FFmpegAudioReader::FFmpegAudioReader() {
+ 	av_log_set_level(AV_LOG_QUIET);
+-
+-	av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
+ }
+
+ inline FFmpegAudioReader::~FFmpegAudioReader() {
+ 	Close();
+ 	av_dict_free(&m_input_opts);
+ 	av_freep(&m_convert_buffer[0]);
+-	av_packet_unref(&m_packet0);
+ }
+
+ inline bool FFmpegAudioReader::SetInputFormat(const char *name) {
+@@ -135,11 +127,10 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ 	Close();
+
+-    av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
++	m_packet = av_packet_alloc();
++	if (!m_packet) {
++		return false;
++	}
+
+ 	ret = avformat_open_input(&m_format_ctx, file_name.c_str(), m_input_fmt, &m_input_opts);
+ 	if (ret < 0) {
+@@ -153,26 +144,31 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		return false;
+ 	}
+
+-	AVCodec *codec;
++	const AVCodec *codec;
+ 	ret = av_find_best_stream(m_format_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &codec, 0);
+ 	if (ret < 0) {
+ 		SetError("Could not find any audio stream in the file", ret);
+ 		return false;
+ 	}
+ 	m_stream_index = ret;
++	auto stream = m_format_ctx->streams[m_stream_index];
+
+-	m_codec_ctx = m_format_ctx->streams[m_stream_index]->codec;
++	m_codec_ctx = avcodec_alloc_context3(codec);
+ 	m_codec_ctx->request_sample_fmt = AV_SAMPLE_FMT_S16;
+
++	ret = avcodec_parameters_to_context(m_codec_ctx, stream->codecpar);
++	if (ret < 0) {
++		SetError("Could not copy the stream parameters", ret);
++		return false;
++	}
++
+ 	ret = avcodec_open2(m_codec_ctx, codec, nullptr);
+ 	if (ret < 0) {
+ 		SetError("Could not open the codec", ret);
+ 		return false;
+ 	}
+
+-	if (!m_codec_ctx->channel_layout) {
+-		m_codec_ctx->channel_layout = av_get_default_channel_layout(m_codec_ctx->channels);
+-	}
++	av_dump_format(m_format_ctx, 0, "foo", 0);
+
+ 	m_frame = av_frame_alloc();
+ 	if (!m_frame) {
+@@ -183,19 +179,23 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		m_output_sample_rate = m_codec_ctx->sample_rate;
+ 	}
+
+-	if (!m_output_channels) {
+-		m_output_channels = m_codec_ctx->channels;
++	AVChannelLayout output_channel_layout;
++	if (m_output_channels) {
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
++	} else {
++		m_output_channels = m_codec_ctx->ch_layout.nb_channels;
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
+ 	}
+
+-	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
++	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->ch_layout.nb_channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
+ 		m_converter.reset(new FFmpegAudioProcessor());
+ 		m_converter->SetCompatibleMode();
+ 		m_converter->SetInputSampleFormat(m_codec_ctx->sample_fmt);
+ 		m_converter->SetInputSampleRate(m_codec_ctx->sample_rate);
+-		m_converter->SetInputChannelLayout(m_codec_ctx->channel_layout);
++		m_converter->SetInputChannelLayout(&(m_codec_ctx->ch_layout));
+ 		m_converter->SetOutputSampleFormat(AV_SAMPLE_FMT_S16);
+ 		m_converter->SetOutputSampleRate(m_output_sample_rate);
+-		m_converter->SetOutputChannelLayout(av_get_default_channel_layout(m_output_channels));
++		m_converter->SetOutputChannelLayout(&output_channel_layout);
+ 		auto ret = m_converter->Init();
+ 		if (ret != 0) {
+ 			SetError("Could not create an audio converter instance", ret);
+@@ -203,10 +203,11 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		}
+ 	}
+
++	av_channel_layout_uninit(&output_channel_layout);
++
+ 	m_opened = true;
+-	m_finished = false;
+-	m_got_frame = 0;
+-	m_nb_packets = 0;
++	m_has_more_packets = true;
++	m_has_more_frames = true;
+ 	m_decode_error = 0;
+
+ 	return true;
+@@ -214,6 +215,7 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ inline void FFmpegAudioReader::Close() {
+ 	av_frame_free(&m_frame);
++	av_packet_free(&m_packet);
+
+ 	m_stream_index = -1;
+
+@@ -252,91 +254,98 @@ inline bool FFmpegAudioReader::Read(const int16_t **data, size_t *size) {
+ 		return false;
+ 	}
+
++	*data = nullptr;
++	*size = 0;
++
+ 	int ret;
++	bool needs_packet = false;
+ 	while (true) {
+-		while (m_packet.size <= 0) {
+-			av_packet_unref(&m_packet0);
+-			av_init_packet(&m_packet);
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			ret = av_read_frame(m_format_ctx, &m_packet);
++		while (needs_packet && m_packet->size == 0) {
++			ret = av_read_frame(m_format_ctx, m_packet);
+ 			if (ret < 0) {
+ 				if (ret == AVERROR_EOF) {
+-					m_finished = true;
++					needs_packet = false;
++					m_has_more_packets = false;
+ 					break;
+-				} else {
++				}
++				SetError("Error reading from the audio source", ret);
++				return false;
++			}
++			if (m_packet->stream_index == m_stream_index) {
++				needs_packet = false;
++			} else {
++				av_packet_unref(m_packet);
++			}
++		}
++
++		if (m_packet->size != 0) {
++			ret = avcodec_send_packet(m_codec_ctx, m_packet);
++			if (ret < 0) {
++				if (ret != AVERROR(EAGAIN)) {
+ 					SetError("Error reading from the audio source", ret);
+ 					return false;
+ 				}
+-			}
+-			m_packet0 = m_packet;
+-			if (m_packet.stream_index != m_stream_index) {
+-				m_packet.data = nullptr;
+-				m_packet.size = 0;
+ 			} else {
+-				m_nb_packets++;
++				av_packet_unref(m_packet);
+ 			}
+ 		}
+
+-		ret = avcodec_decode_audio4(m_codec_ctx, m_frame, &m_got_frame, &m_packet);
++		ret = avcodec_receive_frame(m_codec_ctx, m_frame);
+ 		if (ret < 0) {
+-			if (m_decode_error) {
+-				SetError("Error decoding audio frame", m_decode_error);
+-				return false;
++			if (ret == AVERROR_EOF) {
++				m_has_more_frames = false;
++			} else if (ret == AVERROR(EAGAIN)) {
++				if (m_has_more_packets) {
++					needs_packet = true;
++					continue;
++				} else {
++					m_has_more_frames = false;
++				}
+ 			}
+-			m_decode_error = ret;
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			continue;
++			SetError("Error decoding the audio source", ret);
++			return false;
+ 		}
+
+-		break;
+-	}
+-
+-	m_decode_error = 0;
+-
+-	const int decoded = std::min(ret, m_packet.size);
+-	m_packet.data += decoded;
+-	m_packet.size -= decoded;
+-
+-	if (m_got_frame) {
+-		if (m_converter) {
+-			if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
+-				int linsize;
+-				av_freep(&m_convert_buffer[0]);
+-				m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
+-				ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
+-				if (ret < 0) {
+-					SetError("Couldn't allocate audio converter buffer", ret);
++		if (m_frame->nb_samples > 0) {
++			if (m_converter) {
++				if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
++					int linsize;
++					av_freep(&m_convert_buffer[0]);
++					m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
++					ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->ch_layout.nb_channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
++					if (ret < 0) {
++						SetError("Couldn't allocate audio converter buffer", ret);
++						return false;
++					}
++				}
++				auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
++				if (nb_samples < 0) {
++					SetError("Couldn't convert audio", ret);
+ 					return false;
+ 				}
+-			}
+-			auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			}
+-			*data = (const int16_t *) m_convert_buffer[0];
+-			*size = nb_samples;
+-		} else {
+-			*data = (const int16_t *) m_frame->data[0];
+-			*size = m_frame->nb_samples;
+-		}
+-	} else {
+-		if (m_finished && m_converter) {
+-			auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			} else if (nb_samples > 0) {
+-				m_got_frame = 1;
+ 				*data = (const int16_t *) m_convert_buffer[0];
+ 				*size = nb_samples;
++			} else {
++				*data = (const int16_t *) m_frame->data[0];
++				*size = m_frame->nb_samples;
++			}
++		} else {
++			if (m_converter) {
++				if (IsFinished()) {
++					auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
++					if (nb_samples < 0) {
++						SetError("Couldn't convert audio", ret);
++						return false;
++					} else if (nb_samples > 0) {
++						*data = (const int16_t *) m_convert_buffer[0];
++						*size = nb_samples;
++					}
++				}
+ 			}
+ 		}
+-	}
+
+-	return true;
++		return true;
++	}
+ }
+
+ inline void FFmpegAudioReader::SetError(const char *message, int errnum) {
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index a2b517b..123e643 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -38,6 +38,12 @@ set(SRCS
+
+ if(BUILD_TOOLS)
+ 	set(SRCS ${SRCS} ../src/audio/ffmpeg_audio_reader_test.cpp)
++    include_directories(
++        ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}
++        ${AUDIO_PROCESSOR_INCLUDE_DIRS}
++    )
+ 	link_libraries(fpcalc_libs)
+ endif()
+
+-- 
+2.38.1
+
+
diff --git a/srcpkgs/chromaprint/template b/srcpkgs/chromaprint/template
index 7ef7838949f3..1f7bbc70a22c 100644
--- a/srcpkgs/chromaprint/template
+++ b/srcpkgs/chromaprint/template
@@ -1,7 +1,7 @@
 # Template file for 'chromaprint'
 pkgname=chromaprint
 version=1.5.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DBUILD_TOOLS=ON"
 make_check_target="check"

From e1bb1f1d3bc782dbbe24af66220a00fc08c59553 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 025/113] chromium: revbump for ffmpeg-6.0

---
 .../patches/chromium-93-ffmpeg-4.4.patch      | 36 --------------
 srcpkgs/chromium/patches/ffmpeg5.patch        | 47 +++++++++++++++++++
 srcpkgs/chromium/template                     |  2 +-
 3 files changed, 48 insertions(+), 37 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch
 create mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch b/srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch
deleted file mode 100644
index f0ec736f98bc..000000000000
--- a/srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch
+++ /dev/null
@@ -1,36 +0,0 @@
-diff --git a/media/filters/ffmpeg_demuxer.cc b/media/filters/ffmpeg_demuxer.cc
-index ac4713b07268..492a9a37d096 100644
---- a/media/filters/ffmpeg_demuxer.cc
-+++ b/media/filters/ffmpeg_demuxer.cc
-@@ -427,11 +427,11 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
-   scoped_refptr<DecoderBuffer> buffer;
- 
-   if (type() == DemuxerStream::TEXT) {
--    size_t id_size = 0;
-+    int id_size = 0;
-     uint8_t* id_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
- 
--    size_t settings_size = 0;
-+    int settings_size = 0;
-     uint8_t* settings_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
- 
-@@ -443,7 +443,7 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
-     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
-                                      side_data.data(), side_data.size());
-   } else {
--    size_t side_data_size = 0;
-+    int side_data_size = 0;
-     uint8_t* side_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
- 
-@@ -504,7 +504,7 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
-                                        packet->size - data_offset);
-     }
- 
--    size_t skip_samples_size = 0;
-+    int skip_samples_size = 0;
-     const uint32_t* skip_samples_ptr =
-         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
-             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..24e2da38e34c
--- /dev/null
+++ b/srcpkgs/chromium/patches/ffmpeg5.patch
@@ -0,0 +1,47 @@
+--- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
++++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
+@@ -92,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+-  if (stream->start_time != kNoFFmpegTimestamp)
++  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -1597,7 +1585,7 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+@@ -1618,7 +1606,7 @@
+     if (stream->type() != DemuxerStream::VIDEO)
+       continue;
+ 
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+ 
+     if (!stream->IsEnabled())
diff --git a/srcpkgs/chromium/template b/srcpkgs/chromium/template
index b4a39dfd3815..c29453cd1f50 100644
--- a/srcpkgs/chromium/template
+++ b/srcpkgs/chromium/template
@@ -2,7 +2,7 @@
 pkgname=chromium
 # See https://chromiumdash.appspot.com/releases?platform=Linux for the latest version
 version=114.0.5735.106
-revision=1
+revision=2
 archs="i686* x86_64* aarch64* armv7l*"
 hostmakedepends="
  $(vopt_if clang "clang lld llvm15")

From 56ab3041d1c1a46771276af4dac21622f9c2753e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 026/113] cmus: revbump for ffmpeg-6.0

---
 srcpkgs/cmus/patches/ffmpeg6.patch | 12 ++++++++++++
 srcpkgs/cmus/template              |  2 +-
 2 files changed, 13 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/cmus/patches/ffmpeg6.patch

diff --git a/srcpkgs/cmus/patches/ffmpeg6.patch b/srcpkgs/cmus/patches/ffmpeg6.patch
new file mode 100644
index 000000000000..ffa95ab81110
--- /dev/null
+++ b/srcpkgs/cmus/patches/ffmpeg6.patch
@@ -0,0 +1,12 @@
+--- a/ip/ffmpeg.c
++++ b/ip/ffmpeg.c
+@@ -202,9 +202,6 @@ static int ffmpeg_open(struct input_plugin_data *ip_data)
+ 			break;
+ 		}
+ 
+-		if (codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+-			cc->flags |= AV_CODEC_FLAG_TRUNCATED;
+-
+ 		if (avcodec_open2(cc, codec, NULL) < 0) {
+ 			d_print("could not open codec: %d, %s\n", cc->codec_id, avcodec_get_name(cc->codec_id));
+ 			err = -IP_ERROR_UNSUPPORTED_FILE_TYPE;
diff --git a/srcpkgs/cmus/template b/srcpkgs/cmus/template
index 0fcb424ce336..05b77d0fecae 100644
--- a/srcpkgs/cmus/template
+++ b/srcpkgs/cmus/template
@@ -1,7 +1,7 @@
 # Template file for 'cmus'
 pkgname=cmus
 version=2.10.0
-revision=1
+revision=2
 build_style=configure
 configure_args="prefix=/usr LD=$CC"
 hostmakedepends="pkg-config"

From 56231070a5646bc47d3b0918485060fc826035fd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 027/113] cyanrip: revbump for ffmpeg-6.0

---
 srcpkgs/cyanrip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cyanrip/template b/srcpkgs/cyanrip/template
index 9796e3461601..5db30e020d17 100644
--- a/srcpkgs/cyanrip/template
+++ b/srcpkgs/cyanrip/template
@@ -1,7 +1,7 @@
 # Template file for 'cyanrip'
 pkgname=cyanrip
 version=0.9.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config"
 makedepends="ffmpeg-devel libcdio-devel libcdio-paranoia-devel libcurl-devel libmusicbrainz5-devel"

From 11e454be0010ef07f6386036500f0b08c782105c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 028/113] deadbeef: revbump for ffmpeg4-4.4.3

---
 srcpkgs/deadbeef/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/deadbeef/template b/srcpkgs/deadbeef/template
index b664bb1b9bd9..165b3c7b9cad 100644
--- a/srcpkgs/deadbeef/template
+++ b/srcpkgs/deadbeef/template
@@ -1,14 +1,14 @@
 # Template file for 'deadbeef'
 pkgname=deadbeef
 version=1.8.8
-revision=1
+revision=2
 create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-oss --disable-lfm --disable-notify --disable-gtk2"
 hostmakedepends="automake libtool gettext gettext-devel intltool pkg-config
  yasm clang glib-devel"
 makedepends="
- alsa-lib-devel dbus-devel faad2-devel ffmpeg-devel gtk+3-devel imlib2-devel
+ alsa-lib-devel dbus-devel faad2-devel ffmpeg4-devel gtk+3-devel imlib2-devel
  jansson-devel libcddb-devel libcdio-devel libcurl-devel libflac-devel
  libmad-devel libpng-devel libsamplerate-devel libsndfile-devel libvorbis-devel
  libzip-devel mpg123-devel opusfile-devel pulseaudio-devel wavpack-devel"

From 6c6965b51a84e6e30eb02ebbe9240aa847da8445 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 029/113] dolphin-emu: revbump for ffmpeg-6.0

---
 srcpkgs/dolphin-emu/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/dolphin-emu/template b/srcpkgs/dolphin-emu/template
index 7ea197ceb2a8..7aeb0a5b645e 100644
--- a/srcpkgs/dolphin-emu/template
+++ b/srcpkgs/dolphin-emu/template
@@ -1,7 +1,7 @@
 # Template file for 'dolphin-emu'
 pkgname=dolphin-emu
 version=5.0.16101
-revision=1
+revision=2
 _dolphin_commit=8ecfa537a242de74d2e372e30d9d79b14584b2fb
 _mgba_commit=40d4c430fc36caeb7ea32fd39624947ed487d2f2
 #Version/hash pair can be found at https://dolphin-emu.org/download/

From 268da7de7bbf117f1779d7dea15a83a0db50302d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 030/113] droidcam-obs-plugin: revbump for ffmpeg-6.0

---
 srcpkgs/droidcam-obs-plugin/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam-obs-plugin/template b/srcpkgs/droidcam-obs-plugin/template
index fc9c9bf6b9d5..fb0480754df4 100644
--- a/srcpkgs/droidcam-obs-plugin/template
+++ b/srcpkgs/droidcam-obs-plugin/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam-obs-plugin'
 pkgname=droidcam-obs-plugin
 version=2.0.1
-revision=1
+revision=2
 build_style=gnu-makefile
 make_use_env=yes
 make_build_args="ALLOW_STATIC=no"

From b9821c20a3f0c3073a2ebc8c0edae379ff7ebf41 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 031/113] droidcam: revbump for ffmpeg-6.0

---
 srcpkgs/droidcam/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam/template b/srcpkgs/droidcam/template
index 1c3f1b8b1fc6..32a9220b79a4 100644
--- a/srcpkgs/droidcam/template
+++ b/srcpkgs/droidcam/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam'
 pkgname=droidcam
 version=1.8.2
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="USBMUXD=-lusbmuxd-2.0 JPEG=-lturbojpeg"
 hostmakedepends="pkg-config"

From 29ac464ef7b6f67c71ae2a996566033d7433d8ee Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 032/113] ffmpegthumbnailer: revbump for ffmpeg-6.0

---
 .../ffmpegthumbnailer/patches/ffmpeg6.patch   | 202 ++++++++++++++++++
 srcpkgs/ffmpegthumbnailer/template            |   6 +-
 2 files changed, 205 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch

diff --git a/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
new file mode 100644
index 000000000000..363ff35a2841
--- /dev/null
+++ b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
@@ -0,0 +1,202 @@
+--- a/libffmpegthumbnailer/moviedecoder.cpp	2017-11-21 14:06:57.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.cpp	2023-05-05 13:14:47.946560668 -0400
+@@ -41,11 +41,6 @@
+ namespace ffmpegthumbnailer
+ {
+ 
+-struct SilenceLogLevel
+-{
+-    SilenceLogLevel() { av_log_set_level(AV_LOG_QUIET); }
+-};
+-
+ MovieDecoder::MovieDecoder(AVFormatContext* pavContext)
+ : m_VideoStream(-1)
+ , m_pFormatContext(pavContext)
+@@ -70,8 +65,6 @@
+ 
+ void MovieDecoder::initialize(const string& filename, bool preferEmbeddedMetadata)
+ {
+-    av_register_all();
+-    avcodec_register_all();
+     avformat_network_init();
+ 
+     string inputFile = filename == "-" ? "pipe:" : filename;
+@@ -97,8 +90,7 @@
+ {
+     if (m_pVideoCodecContext)
+     {
+-        avcodec_close(m_pVideoCodecContext);
+-        m_pVideoCodecContext = nullptr;
++        avcodec_free_context(&m_pVideoCodecContext);
+     }
+ 
+     if ((!m_FormatContextWasGiven) && m_pFormatContext)
+@@ -152,10 +144,10 @@
+     for (unsigned int i = 0; i < m_pFormatContext->nb_streams; ++i)
+     {
+         AVStream *stream = m_pFormatContext->streams[i];
+-        auto ctx = m_pFormatContext->streams[i]->codec;
+-        if (ctx->codec_type == AVMEDIA_TYPE_VIDEO)
++        auto par = m_pFormatContext->streams[i]->codecpar;
++        if (par->codec_type == AVMEDIA_TYPE_VIDEO)
+         {
+-            if (!preferEmbeddedMetadata || !isStillImageCodec(ctx->codec_id))
++            if (!preferEmbeddedMetadata || !isStillImageCodec(par->codec_id))
+             {
+                 videoStreams.push_back(i);
+                 continue;
+@@ -203,8 +195,7 @@
+     }
+ 
+     m_pVideoStream = m_pFormatContext->streams[m_VideoStream];
+-    m_pVideoCodecContext = m_pVideoStream->codec;
+-    m_pVideoCodec = avcodec_find_decoder(m_pVideoCodecContext->codec_id);
++    m_pVideoCodec = avcodec_find_decoder(m_pVideoStream->codecpar->codec_id);
+ 
+     if (m_pVideoCodec == nullptr)
+     {
+@@ -214,6 +205,20 @@
+         throw logic_error("Video Codec not found");
+     }
+ 
++    m_pVideoCodecContext = avcodec_alloc_context3(m_pVideoCodec);
++
++    if (m_pVideoCodecContext == nullptr)
++    {
++        destroy();
++        throw logic_error("Could not allocate video codec context");
++    }
++
++    if (avcodec_parameters_to_context(m_pVideoCodecContext, m_pVideoStream->codecpar) < 0)
++    {
++        destroy();
++        throw logic_error("Could not configure video codec context");
++    }
++
+     m_pVideoCodecContext->workaround_bugs = 1;
+ 
+     if (avcodec_open2(m_pVideoCodecContext, m_pVideoCodec, nullptr) < 0)
+@@ -386,13 +391,6 @@
+ 
+ void MovieDecoder::initializeFilterGraph(const AVRational& timeBase, const std::string& size, bool maintainAspectRatio)
+ {
+-    static const AVPixelFormat pixelFormats[] = { AV_PIX_FMT_RGB24, AV_PIX_FMT_NONE };
+-
+-    auto del = [] (AVBufferSinkParams* p) { av_freep(p); };
+-    std::unique_ptr<AVBufferSinkParams, decltype(del)> buffersinkParams(av_buffersink_params_alloc(), del);
+-
+-    avfilter_register_all();
+-
+     m_pFilterGraph = avfilter_graph_alloc();
+     assert(m_pFilterGraph);
+ 
+@@ -404,10 +402,8 @@
+ 
+     checkRc(avfilter_graph_create_filter(&m_pFilterSource, avfilter_get_by_name("buffer"), "thumb_buffer", ss.str().c_str(), nullptr, m_pFilterGraph),
+             "Failed to create filter source");
+-    buffersinkParams->pixel_fmts = pixelFormats;
+-    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, buffersinkParams.get(), m_pFilterGraph),
++    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, nullptr, m_pFilterGraph),
+             "Failed to create filter sink");
+-    buffersinkParams.release();
+ 
+     AVFilterContext* yadifFilter = nullptr;
+     if (m_pFrame->interlaced_frame != 0)
+@@ -500,15 +496,15 @@
+     }
+ 
+     checkRc(av_seek_frame(m_pFormatContext, -1, timestamp, 0), "Seeking in video failed");
+-    avcodec_flush_buffers(m_pFormatContext->streams[m_VideoStream]->codec);
++    avcodec_flush_buffers(m_pVideoCodecContext);
+ 
+     int keyFrameAttempts = 0;
+-    bool gotFrame = 0;
++    bool gotFrame;
+ 
+     do
+     {
+         int count = 0;
+-        gotFrame = 0;
++        gotFrame = false;
+ 
+         while (!gotFrame && count < 20)
+         {
+@@ -552,17 +548,33 @@
+         return false;
+     }
+ 
+-    av_frame_unref(m_pFrame);
+-
+-    int frameFinished;
++    int rc = avcodec_send_packet(m_pVideoCodecContext, m_pPacket);
++    if(rc == AVERROR(EAGAIN))
++    {
++        rc = 0;
++    }
+ 
+-    int bytesDecoded = avcodec_decode_video2(m_pVideoCodecContext, m_pFrame, &frameFinished, m_pPacket);
+-    if (bytesDecoded < 0)
++    if(rc == AVERROR_EOF)
++    {
++        return false;
++    }
++    else if(rc < 0)
+     {
+-        throw logic_error("Failed to decode video frame: bytesDecoded < 0");
++        throw logic_error("Failed to decode video frame: avcodec_send_packet() < 0");
+     }
+ 
+-    return frameFinished > 0;
++    rc = avcodec_receive_frame(m_pVideoCodecContext, m_pFrame);
++    switch(rc)
++    {
++        case 0:
++            return true;
++
++        case AVERROR(EAGAIN):
++            return false;
++
++        default:
++            throw logic_error("Failed to decode video frame: avcodec_receive_frame() < 0");
++    }
+ }
+ 
+ bool MovieDecoder::getVideoPacket()
+@@ -570,8 +582,6 @@
+     bool framesAvailable = true;
+     bool frameDecoded = false;
+ 
+-    int attempts = 0;
+-
+     if (m_pPacket)
+     {
+         av_packet_unref(m_pPacket);
+@@ -580,6 +590,7 @@
+ 
+     m_pPacket = new AVPacket();
+ 
++
+     while (framesAvailable && !frameDecoded)
+     {
+         framesAvailable = av_read_frame(m_pFormatContext, m_pPacket) >= 0;
+@@ -644,7 +655,7 @@
+ 
+ int32_t MovieDecoder::getStreamRotation()
+ {
+-    int32_t* matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
++    auto matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
+     if (matrix)
+     {
+         auto angle = lround(av_display_rotation_get(matrix));
+
+--- a/libffmpegthumbnailer/moviedecoder.h	2017-11-12 04:23:38.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.h	2023-05-05 13:26:07.095529911 -0400
+@@ -78,7 +78,7 @@
+     int                     m_VideoStream;
+     AVFormatContext*        m_pFormatContext;
+     AVCodecContext*         m_pVideoCodecContext;
+-    AVCodec*                m_pVideoCodec;
++    const AVCodec*          m_pVideoCodec;
+     AVFilterGraph*          m_pFilterGraph;
+     AVFilterContext*        m_pFilterSource;
+     AVFilterContext*        m_pFilterSink;
diff --git a/srcpkgs/ffmpegthumbnailer/template b/srcpkgs/ffmpegthumbnailer/template
index 039eea7622b3..35d546018d12 100644
--- a/srcpkgs/ffmpegthumbnailer/template
+++ b/srcpkgs/ffmpegthumbnailer/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbnailer'
 pkgname=ffmpegthumbnailer
 version=2.2.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libpng-devel libjpeg-turbo-devel ffmpeg-devel"
@@ -9,8 +9,8 @@ depends="ffmpeg"
 short_desc="Lightweight video thumbnailer"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
-homepage="https://github.com/dirkvdb/${pkgname}"
-distfiles="${homepage}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
+homepage="https://github.com/dirkvdb"
+distfiles="${homepage}/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
 checksum=1cb24059c38223f657b300c84dd80491b7040d4b69471c4fea69be862bc99b5b
 
 post_install() {

From e2e3278cde9a8f987c804e5fc26cdf76cd03f78d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 033/113] ffmpegthumbs: revbump for ffmpeg-6.0

---
 srcpkgs/ffmpegthumbs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ffmpegthumbs/template b/srcpkgs/ffmpegthumbs/template
index 5f0b9414dada..11b88193528f 100644
--- a/srcpkgs/ffmpegthumbs/template
+++ b/srcpkgs/ffmpegthumbs/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbs'
 pkgname=ffmpegthumbs
 version=22.12.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules kcoreaddons kconfig-devel
  pkg-config qt5-host-tools qt5-qmake gettext"

From 16e84e3acfd1564f503fceac627a864eb278f776 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 034/113] ffms2: revbump for ffmpeg-6.0

---
 srcpkgs/ffms2/patches/ffmpeg5.patch | 424 ++++++++++++++++++++++++++++
 srcpkgs/ffms2/template              |   2 +-
 2 files changed, 425 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ffms2/patches/ffmpeg5.patch

diff --git a/srcpkgs/ffms2/patches/ffmpeg5.patch b/srcpkgs/ffms2/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..1479fabcafcb
--- /dev/null
+++ b/srcpkgs/ffms2/patches/ffmpeg5.patch
@@ -0,0 +1,424 @@
+From 45673149e9a2f5586855ad472e3059084eaa36b1 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:41:21 +0100
+Subject: [PATCH] Use auto for AVCodec
+
+The geniuses over at FFmpeg decided to constify this API, so old
+versions of the library will return AVCodec *, while new versions
+of the libary will return const AVCodec *, which, in C++, are not
+OK to convert between.
+
+Rather than use some macro hell in ffmscompat.h, we can work around
+this by using auto.
+
+Gross.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 2 +-
+ src/core/indexing.cpp    | 6 +++---
+ src/core/videosource.cpp | 2 +-
+ 3 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index e4ce97c..ac09666 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -469,7 +469,7 @@ void FFMS_AudioSource::OpenFile() {
+ 
+     LAVFOpenFile(SourceFile.c_str(), FormatContext, TrackNumber);
+ 
+-    AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
++    auto *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
+     if (Codec == nullptr)
+         throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+             "Audio codec not found");
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index e547c5a..59fb4e8 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -384,7 +384,7 @@ FFMS_TrackType FFMS_Indexer::GetTrackType(int Track) {
+ }
+ 
+ const char *FFMS_Indexer::GetTrackCodec(int Track) {
+-    AVCodec *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
++    auto *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
+     return codec ? codec->name : nullptr;
+ }
+ 
+@@ -402,7 +402,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             UseDTS);
+ 
+         if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            AVCodec *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (!VideoCodec) {
+                 FormatContext->streams[i]->discard = AVDISCARD_ALL;
+                 IndexMask.erase(i);
+@@ -433,7 +433,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 IndexMask.insert(i);
+             }
+         } else if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+-            AVCodec *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (AudioCodec == nullptr)
+                 throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_UNSUPPORTED,
+                     "Audio codec not found");
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index b889970..8956c22 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -171,7 +171,7 @@ FFMS_VideoSource::FFMS_VideoSource(const char *SourceFile, FFMS_Index &Index, in
+ 
+         LAVFOpenFile(SourceFile, FormatContext, VideoTrack);
+ 
+-        AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
++        auto *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
+         if (Codec == nullptr)
+             throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+                 "Video codec not found");
+-- 
+2.40.0
+
+From 96cbf38ea9381829a1314f432a2c60495dcefaad Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:12:41 +0100
+Subject: [PATCH] all: Update AVPacket API usage
+
+AVPackets must all be on the heap now, since it is no longer
+part of the libav* ABI.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 16 ++++++----
+ src/core/indexing.cpp    | 63 ++++++++++++++++++++++------------------
+ src/core/indexing.h      |  4 +--
+ src/core/utils.cpp       |  6 ----
+ src/core/utils.h         |  1 -
+ src/core/videosource.cpp | 30 ++++++++++---------
+ 6 files changed, 64 insertions(+), 56 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index 37cf9ae..e4ce97c 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -285,10 +285,15 @@ FFMS_AudioSource::AudioBlock *FFMS_AudioSource::CacheBlock(CacheIterator &pos) {
+ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     CurrentFrame = &Frames[PacketNumber];
+ 
+-    AVPacket Packet;
+-    if (!ReadPacket(&Packet))
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++    if (!ReadPacket(Packet)) {
++        av_packet_free(&Packet);
+         throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_UNKNOWN,
+             "ReadPacket unexpectedly failed to read a packet");
++    }
+ 
+     // ReadPacket may have changed the packet number
+     CurrentFrame = &Frames[PacketNumber];
+@@ -297,8 +302,9 @@ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     int NumberOfSamples = 0;
+     AudioBlock *CachedBlock = nullptr;
+     
+-    int Ret = avcodec_send_packet(CodecContext, &Packet);
+-    av_packet_unref(&Packet);
++    int Ret = avcodec_send_packet(CodecContext, Packet);
++    av_packet_unref(Packet);
++    av_packet_free(&Packet);
+ 
+     av_frame_unref(DecodeFrame);
+     Ret = avcodec_receive_frame(CodecContext, DecodeFrame);
+@@ -513,8 +519,6 @@ void FFMS_AudioSource::Seek() {
+ }
+ 
+ bool FFMS_AudioSource::ReadPacket(AVPacket *Packet) {
+-    InitNullPacket(*Packet);
+-
+     while (av_read_frame(FormatContext, Packet) >= 0) {
+         if (Packet->stream_index == TrackNumber) {
+             // Required because not all audio packets, especially in ogg, have a pts. Use the previous valid packet's pts instead.
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index 23fb95b..e547c5a 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -320,7 +320,7 @@ void FFMS_Indexer::CheckAudioProperties(int Track, AVCodecContext *Context) {
+     }
+ }
+ 
+-void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict,
++void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict,
+                                     int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct) {
+     if (VideoContext.Parser) {
+         uint8_t *OB;
+@@ -330,8 +330,8 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+         av_parser_parse2(VideoContext.Parser,
+             VideoContext.CodecContext,
+             &OB, &OBSize,
+-            pkt.data, pkt.size,
+-            pkt.pts, pkt.dts, pkt.pos);
++            pkt->data, pkt->size,
++            pkt->pts, pkt->dts, pkt->pos);
+ 
+         // H.264 (PAFF) and HEVC may have one field per packet, so we need to track
+         // when we have a full or half frame available, and mark one of them as
+@@ -351,15 +351,15 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+ 
+         *RepeatPict = VideoContext.Parser->repeat_pict;
+         *FrameType = VideoContext.Parser->pict_type;
+-        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt.flags & AV_PKT_FLAG_DISCARD));
++        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt->flags & AV_PKT_FLAG_DISCARD));
+     } else {
+-        *Invisible = !!(pkt.flags & AV_PKT_FLAG_DISCARD);
++        *Invisible = !!(pkt->flags & AV_PKT_FLAG_DISCARD);
+     }
+ 
+     if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP8)
+-        ParseVP8(pkt.data[0], Invisible, FrameType);
++        ParseVP8(pkt->data[0], Invisible, FrameType);
+     else if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP9)
+-        ParseVP9(pkt.data[0], Invisible, FrameType);
++        ParseVP9(pkt->data[0], Invisible, FrameType);
+ }
+ 
+ void FFMS_Indexer::Free() {
+@@ -458,32 +458,36 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+         }
+     }
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
+     std::vector<int64_t> LastValidTS(FormatContext->nb_streams, AV_NOPTS_VALUE);
+ 
+     int64_t filesize = avio_size(FormatContext->pb);
+     enum AVPictureStructure LastPicStruct = AV_PICTURE_STRUCTURE_UNKNOWN;
+-    while (av_read_frame(FormatContext, &Packet) >= 0) {
++    while (av_read_frame(FormatContext, Packet) >= 0) {
+         // Update progress
+         // FormatContext->pb can apparently be NULL when opening images.
+         if (IC && FormatContext->pb) {
+-            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate))
++            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate)) {
++                av_packet_free(&Packet);
+                 throw FFMS_Exception(FFMS_ERROR_CANCELLED, FFMS_ERROR_USER,
+                     "Cancelled by user");
++            }
+         }
+-        if (!IndexMask.count(Packet.stream_index)) {
+-            av_packet_unref(&Packet);
++        if (!IndexMask.count(Packet->stream_index)) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+-        int Track = Packet.stream_index;
++        int Track = Packet->stream_index;
+         FFMS_Track &TrackInfo = (*TrackIndices)[Track];
+-        bool KeyFrame = !!(Packet.flags & AV_PKT_FLAG_KEY);
++        bool KeyFrame = !!(Packet->flags & AV_PKT_FLAG_KEY);
+         ReadTS(Packet, LastValidTS[Track], (*TrackIndices)[Track].UseDTS);
+ 
+         if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            int64_t PTS = TrackInfo.UseDTS ? Packet.dts : Packet.pts;
++            int64_t PTS = TrackInfo.UseDTS ? Packet->dts : Packet->pts;
+             if (PTS == AV_NOPTS_VALUE) {
+                 // VPx alt-refs are output as packets which lack timestmps or durations, since
+                 // they are invisible. Currently, the timestamp mangling code in libavformat
+@@ -495,9 +499,11 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 // FFMS2 currently sorts packets by PTS, which will break decoding, otherwise.
+                 bool HasAltRefs = (FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP8 ||
+                                    FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP9);
+-                if (Packet.duration == 0 && !HasAltRefs)
++                if (Packet->duration == 0 && !HasAltRefs) {
++                    av_packet_free(&Packet);
+                     throw FFMS_Exception(FFMS_ERROR_INDEXING, FFMS_ERROR_PARSER,
+                         "Invalid packet pts, dts, and duration");
++                }
+ 
+                 if (TrackInfo.empty())
+                     PTS = 0;
+@@ -513,7 +519,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             ParseVideoPacket(AVContexts[Track], Packet, &RepeatPict, &FrameType, &Invisible, &LastPicStruct);
+ 
+             TrackInfo.AddVideoFrame(PTS, RepeatPict, KeyFrame,
+-                FrameType, Packet.pos, Invisible);
++                FrameType, Packet->pos, Invisible);
+         } else if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+             // For video seeking timestamps are used only if all packets have
+             // timestamps, while for audio they're used if any have timestamps,
+@@ -522,28 +528,29 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 TrackInfo.HasTS = true;
+ 
+             int64_t StartSample = AVContexts[Track].CurrentSample;
+-            uint32_t SampleCount = IndexAudioPacket(Track, &Packet, AVContexts[Track], *TrackIndices);
++            uint32_t SampleCount = IndexAudioPacket(Track, Packet, AVContexts[Track], *TrackIndices);
+             TrackInfo.SampleRate = AVContexts[Track].CodecContext->sample_rate;
+ 
+             TrackInfo.AddAudioFrame(LastValidTS[Track],
+-                StartSample, SampleCount, KeyFrame, Packet.pos, Packet.flags & AV_PKT_FLAG_DISCARD);
++                StartSample, SampleCount, KeyFrame, Packet->pos, Packet->flags & AV_PKT_FLAG_DISCARD);
+         }
+ 
+-        if (!(Packet.flags & AV_PKT_FLAG_DISCARD))
+-            TrackInfo.LastDuration = Packet.duration;
++        if (!(Packet->flags & AV_PKT_FLAG_DISCARD))
++            TrackInfo.LastDuration = Packet->duration;
+ 
+-        av_packet_unref(&Packet);
++        av_packet_unref(Packet);
+     }
++    av_packet_free(&Packet);
+ 
+     TrackIndices->Finalize(AVContexts, FormatContext->iformat->name);
+     return TrackIndices.release();
+ }
+ 
+-void FFMS_Indexer::ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS) {
+-    if (!UseDTS && Packet.pts != AV_NOPTS_VALUE)
+-        TS = Packet.pts;
++void FFMS_Indexer::ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS) {
++    if (!UseDTS && Packet->pts != AV_NOPTS_VALUE)
++        TS = Packet->pts;
+     if (TS == AV_NOPTS_VALUE)
+         UseDTS = true;
+-    if (UseDTS && Packet.dts != AV_NOPTS_VALUE)
+-        TS = Packet.dts;
++    if (UseDTS && Packet->dts != AV_NOPTS_VALUE)
++        TS = Packet->dts;
+ }
+diff --git a/src/core/indexing.h b/src/core/indexing.h
+index 3cfc3c3..5c06868 100644
+--- a/src/core/indexing.h
++++ b/src/core/indexing.h
+@@ -80,10 +80,10 @@ private:
+     int64_t Filesize;
+     uint8_t Digest[20];
+ 
+-    void ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS);
++    void ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS);
+     void CheckAudioProperties(int Track, AVCodecContext *Context);
+     uint32_t IndexAudioPacket(int Track, AVPacket *Packet, SharedAVContext &Context, FFMS_Index &TrackIndices);
+-    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
++    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
+     void Free();
+ public:
+     FFMS_Indexer(const char *Filename);
+diff --git a/src/core/utils.cpp b/src/core/utils.cpp
+index ce67533..8a2e997 100644
+--- a/src/core/utils.cpp
++++ b/src/core/utils.cpp
+@@ -62,12 +62,6 @@ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo) {
+     }
+ }
+ 
+-void InitNullPacket(AVPacket &pkt) {
+-    av_init_packet(&pkt);
+-    pkt.data = nullptr;
+-    pkt.size = 0;
+-}
+-
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames) {
+     AP.SampleFormat = static_cast<FFMS_SampleFormat>(av_get_packed_sample_fmt(CTX->sample_fmt));
+     AP.BitsPerSample = av_get_bytes_per_sample(CTX->sample_fmt) * 8;
+diff --git a/src/core/utils.h b/src/core/utils.h
+index 9819dc7..003ab79 100644
+--- a/src/core/utils.h
++++ b/src/core/utils.h
+@@ -58,7 +58,6 @@ std::unique_ptr<T> make_unique(Args&&... args) {
+ }
+ 
+ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo);
+-void InitNullPacket(AVPacket &pkt);
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames);
+ 
+ void LAVFOpenFile(const char *SourceFile, AVFormatContext *&FormatContext, int Track);
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index 06bd161..b889970 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -673,30 +673,34 @@ void FFMS_VideoSource::DecodeNextFrame(int64_t &AStartTime, int64_t &Pos) {
+     if (HasPendingDelayedFrames())
+         return;
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
+-
+-    while (ReadFrame(&Packet) >= 0) {
+-        if (Packet.stream_index != VideoTrack) {
+-            av_packet_unref(&Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++
++    while (ReadFrame(Packet) >= 0) {
++        if (Packet->stream_index != VideoTrack) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+         if (AStartTime < 0)
+-            AStartTime = Frames.UseDTS ? Packet.dts : Packet.pts;
++            AStartTime = Frames.UseDTS ? Packet->dts : Packet->pts;
+ 
+         if (Pos < 0)
+-            Pos = Packet.pos;
++            Pos = Packet->pos;
+ 
+-        bool FrameFinished = DecodePacket(&Packet);
+-        av_packet_unref(&Packet);
+-        if (FrameFinished)
++        bool FrameFinished = DecodePacket(Packet);
++        av_packet_unref(Packet);
++        if (FrameFinished) {
++            av_packet_free(&Packet);
+             return;
++        }
+     }
+ 
+     // Flush final frames
+-    InitNullPacket(Packet);
+-    DecodePacket(&Packet);
++    DecodePacket(Packet);
++    av_packet_free(&Packet);
+ }
+ 
+ bool FFMS_VideoSource::SeekTo(int n, int SeekOffset) {
+-- 
+2.40.0
+
+From bf9e03e9e08534c024e5a744a6437c4aac160201 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:20:47 +0100
+Subject: [PATCH 2/3] configure: Remove deprecated API use
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ configure.ac | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index b35ef80bc..d19714d0f 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -102,10 +102,10 @@ CFLAGS="$_CFLAGS $FFMPEG_CFLAGS"
+
+ AC_DEFUN([TEST_FFMPEG],
+          [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+-            #include <libavcodec/avcodec.h>
++            #include <libavformat/avformat.h>
+             #include <libswscale/swscale.h>
+             ]],[[
+-                avcodec_register_all();
++                avformat_network_init();
+                 swscale_version();
+             ]])], [eval $1=yes], [eval $1=no])
+         ])
+
diff --git a/srcpkgs/ffms2/template b/srcpkgs/ffms2/template
index 68e8a0c14bce..2acfadac44b3 100644
--- a/srcpkgs/ffms2/template
+++ b/srcpkgs/ffms2/template
@@ -1,7 +1,7 @@
 # Template file for 'ffms2'
 pkgname=ffms2
 version=2.40
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-shared --disable-static"
 hostmakedepends="pkg-config autoconf automake libtool"

From 4f1868b300a79a3ab51068262cabdc4c57e25f92 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 035/113] freerdp: revbump for ffmpeg-6.0

---
 .../freerdp/patches/ffmpeg6_aa2cb9aa.patch    | 42 +++++++++++++++++++
 srcpkgs/freerdp/template                      |  2 +-
 2 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch

diff --git a/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
new file mode 100644
index 000000000000..a4324da3a882
--- /dev/null
+++ b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
@@ -0,0 +1,42 @@
+From aa2cb9aa5ff5562433598ba168a466e0752bca0e Mon Sep 17 00:00:00 2001
+From: akallabeth <akallabeth@posteo.net>
+Date: Tue, 14 Feb 2023 07:48:54 +0100
+Subject: [PATCH] Fixed #8686: Update h264 to use new FFMPEG API
+
+---
+ channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c | 2 ++
+ libfreerdp/codec/h264_ffmpeg.c            | 2 ++
+ 2 files changed, 4 insertions(+)
+
+diff --git a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+index 339462d865f..beea80b7a1e 100644
+--- a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
++++ b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+@@ -239,8 +239,10 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYP
+ 		}
+ 	}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 	if (mdecoder->codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		mdecoder->codec_context->flags |= AV_CODEC_FLAG_TRUNCATED;
++#endif
+ 
+ 	return TRUE;
+ }
+diff --git a/libfreerdp/codec/h264_ffmpeg.c b/libfreerdp/codec/h264_ffmpeg.c
+index 8a23db2473c..896a333019b 100644
+--- a/libfreerdp/codec/h264_ffmpeg.c
++++ b/libfreerdp/codec/h264_ffmpeg.c
+@@ -615,10 +615,12 @@ static BOOL libavcodec_init(H264_CONTEXT* h264)
+ 			goto EXCEPTION;
+ 		}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 		if (sys->codecDecoder->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		{
+ 			sys->codecDecoderContext->flags |= AV_CODEC_FLAG_TRUNCATED;
+ 		}
++#endif
+ 
+ #ifdef WITH_VAAPI
+ 
diff --git a/srcpkgs/freerdp/template b/srcpkgs/freerdp/template
index 25e8aa9677f0..4d51c8189902 100644
--- a/srcpkgs/freerdp/template
+++ b/srcpkgs/freerdp/template
@@ -1,7 +1,7 @@
 # Template file for 'freerdp'
 pkgname=freerdp
 version=2.10.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_ALSA=ON -DWITH_CUPS=OFF -DWITH_FFMPEG=ON
  -DWITH_GSTREAMER_0_10=OFF -DWITH_GSTREAMER_1_0=OFF -DWITH_JPEG=ON

From 2dd67e67682782b1cfa0f3393715655c7de292b9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 036/113] gerbera: revbump for ffmpeg-6.0

---
 srcpkgs/gerbera/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gerbera/template b/srcpkgs/gerbera/template
index ae14f35c767c..2dc0ac0ce03b 100644
--- a/srcpkgs/gerbera/template
+++ b/srcpkgs/gerbera/template
@@ -1,7 +1,7 @@
 # Template file for 'gerbera'
 pkgname=gerbera
 version=1.12.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_SYSTEMD=0 -DWITH_AVCODEC=1"
 hostmakedepends="pkg-config"

From 8818d067fecc7e69ae7dc3577c5d1f2ef6a7a896 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 037/113] goldendict: revbump for ffmpeg-6.0

---
 srcpkgs/goldendict/patches/ffmpeg4.patch |  21 --
 srcpkgs/goldendict/patches/ffmpeg5.patch | 232 +++++++++++++++++++++++
 srcpkgs/goldendict/template              |   2 +-
 3 files changed, 233 insertions(+), 22 deletions(-)
 delete mode 100644 srcpkgs/goldendict/patches/ffmpeg4.patch
 create mode 100644 srcpkgs/goldendict/patches/ffmpeg5.patch

diff --git a/srcpkgs/goldendict/patches/ffmpeg4.patch b/srcpkgs/goldendict/patches/ffmpeg4.patch
deleted file mode 100644
index f045fa27f54b..000000000000
--- a/srcpkgs/goldendict/patches/ffmpeg4.patch
+++ /dev/null
@@ -1,21 +0,0 @@
---- a/ffmpegaudio.cc.orig 2018-05-09 22:16:13.480659958 +0200
-+++ b/ffmpegaudio.cc      2018-05-09 22:16:50.748322790 +0200
-@@ -143,7 +143,7 @@
-     return false;
-   }
-
--  unsigned char * avioBuffer = ( unsigned char * )av_malloc( kBufferSize + FF_INPUT_BUFFER_PADDING_SIZE );
-+  unsigned char * avioBuffer = ( unsigned char * )av_malloc( kBufferSize + AV_INPUT_BUFFER_PADDING_SIZE );
-   if ( !avioBuffer )
-   {
-     errorString = QObject::tr( "av_malloc() failed." );
-@@ -380,7 +380,7 @@
-   }
-
-   if ( !Qt4x5::AtomicInt::loadAcquire( isCancelled_ ) &&
--       codecContext_->codec->capabilities & CODEC_CAP_DELAY )
-+       codecContext_->codec->capabilities & AV_CODEC_CAP_DELAY )
-   {
-     av_init_packet( &packet );
-     int gotFrame = 0;
-
diff --git a/srcpkgs/goldendict/patches/ffmpeg5.patch b/srcpkgs/goldendict/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..7cfc98ada368
--- /dev/null
+++ b/srcpkgs/goldendict/patches/ffmpeg5.patch
@@ -0,0 +1,232 @@
+From 03bbe01b79a1f07a6780cb60f23a087104c5d77b Mon Sep 17 00:00:00 2001
+From: Abs62 <ottomann@yandex.ru>
+Date: Fri, 30 Mar 2018 22:53:24 +0300
+Subject: [PATCH] Fix warnings while compile with FFMpeg 3.4.2 (issue #978)
+
+---
+ ffmpegaudio.cc | 68 +++++++++++++++++++++++++++++++++++++++++++++-----
+ 1 file changed, 62 insertions(+), 6 deletions(-)
+
+diff --git a/ffmpegaudio.cc b/ffmpegaudio.cc
+index ed1172bdd..56e8f788e 100644
+--- a/ffmpegaudio.cc
++++ b/ffmpegaudio.cc
+@@ -91,6 +91,7 @@ struct DecoderContext
+   QByteArray audioData_;
+   QDataStream audioDataStream_;
+   AVFormatContext * formatContext_;
++  AVCodec * codec_;
+   AVCodecContext * codecContext_;
+   AVIOContext * avioContext_;
+   AVStream * audioStream_;
+@@ -114,6 +115,7 @@ DecoderContext::DecoderContext( QByteArray const & audioData, QAtomicInt & isCan
+   audioData_( audioData ),
+   audioDataStream_( audioData_ ),
+   formatContext_( NULL ),
++  codec_( NULL ),
+   codecContext_( NULL ),
+   avioContext_( NULL ),
+   audioStream_( NULL ),
+@@ -143,7 +145,11 @@ bool DecoderContext::openCodec( QString & errorString )
+     return false;
+   }
+
++#if LIBAVCODEC_VERSION_MAJOR < 56 || ( LIBAVCODEC_VERSION_MAJOR == 56 && LIBAVCODEC_VERSION_MINOR < 56 )
+   unsigned char * avioBuffer = ( unsigned char * )av_malloc( kBufferSize + FF_INPUT_BUFFER_PADDING_SIZE );
++#else
++  unsigned char * avioBuffer = ( unsigned char * )av_malloc( kBufferSize + AV_INPUT_BUFFER_PADDING_SIZE );
++#endif
+   if ( !avioBuffer )
+   {
+     errorString = QObject::tr( "av_malloc() failed." );
+@@ -186,7 +192,11 @@ bool DecoderContext::openCodec( QString & errorString )
+   // Find audio stream, use the first audio stream if available
+   for ( unsigned i = 0; i < formatContext_->nb_streams; i++ )
+   {
++#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 33 )
+     if ( formatContext_->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO )
++#else
++      if ( formatContext_->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO )
++#endif
+     {
+       audioStream_ = formatContext_->streams[i];
+       break;
+@@ -198,22 +208,38 @@ bool DecoderContext::openCodec( QString & errorString )
+     return false;
+   }
+
++#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 33 )
+   codecContext_ = audioStream_->codec;
+-  AVCodec * codec = avcodec_find_decoder( codecContext_->codec_id );
+-  if ( !codec )
++  codec_ = avcodec_find_decoder( codecContext_->codec_id );
++  if ( !codec_ )
+   {
+     errorString = QObject::tr( "Codec [id: %1] not found." ).arg( codecContext_->codec_id );
+     return false;
+   }
++#else
++  codec_ = avcodec_find_decoder( audioStream_->codecpar->codec_id );
++  if ( !codec_ )
++  {
++    errorString = QObject::tr( "Codec [id: %1] not found." ).arg( audioStream_->codecpar->codec_id );
++    return false;
++  }
++  codecContext_ = avcodec_alloc_context3( codec_ );
++  if ( !codecContext_ )
++  {
++    errorString = QObject::tr( "avcodec_alloc_context3() failed." );
++    return false;
++  }
++  avcodec_parameters_to_context( codecContext_, audioStream_->codecpar );
++#endif
+
+-  ret = avcodec_open2( codecContext_, codec, NULL );
++  ret = avcodec_open2( codecContext_, codec_, NULL );
+   if ( ret < 0 )
+   {
+     errorString = QObject::tr( "avcodec_open2() failed: %1." ).arg( avErrorString( ret ) );
+     return false;
+   }
+
+-  av_log( NULL, AV_LOG_INFO, "Codec open: %s: channels: %d, rate: %d, format: %s\n", codec->long_name,
++  av_log( NULL, AV_LOG_INFO, "Codec open: %s: channels: %d, rate: %d, format: %s\n", codec_->long_name,
+           codecContext_->channels, codecContext_->sample_rate, av_get_sample_fmt_name( codecContext_->sample_fmt ) );
+   return true;
+ }
+@@ -252,10 +278,13 @@ void DecoderContext::closeCodec()
+
+   // Closing a codec context without prior avcodec_open2() will result in
+   // a crash in ffmpeg
+-  if ( audioStream_ && audioStream_->codec && audioStream_->codec->codec )
++  if ( audioStream_ && codecContext_ && codec_ )
+   {
+     audioStream_->discard = AVDISCARD_ALL;
+-    avcodec_close( audioStream_->codec );
++    avcodec_close( codecContext_ );
++#if LIBAVCODEC_VERSION_MAJOR > 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR >= 33 )
++    avcodec_free_context( &codecContext_ );
++#endif
+   }
+
+   avformat_close_input( &formatContext_ );
+@@ -356,6 +385,7 @@ bool DecoderContext::play( QString & errorString )
+     if ( packet.stream_index == audioStream_->index )
+     {
+       AVPacket pack = packet;
++#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 37 )
+       int gotFrame = 0;
+       do
+       {
+@@ -370,6 +400,19 @@ bool DecoderContext::play( QString & errorString )
+         pack.data += len;
+       }
+       while( pack.size > 0 );
++#else
++      int ret = avcodec_send_packet( codecContext_, &pack );
++      /* read all the output frames (in general there may be any number of them) */
++      while( ret >= 0 )
++      {
++        ret = avcodec_receive_frame( codecContext_, frame);
++
++        if ( Qt4x5::AtomicInt::loadAcquire( isCancelled_ ) || ret < 0 )
++          break;
++
++        playFrame( frame );
++      }
++#endif
+     }
+     // av_free_packet() must be called after each call to av_read_frame()
+ #if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 7 )
+@@ -379,6 +422,7 @@ bool DecoderContext::play( QString & errorString )
+ #endif
+   }
+
++#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 37 )
+   if ( !Qt4x5::AtomicInt::loadAcquire( isCancelled_ ) &&
+        codecContext_->codec->capabilities & CODEC_CAP_DELAY )
+   {
+@@ -391,6 +435,18 @@ bool DecoderContext::play( QString & errorString )
+       playFrame( frame );
+     }
+   }
++#else
++  /* flush the decoder */
++  av_init_packet( &packet );
++  int ret = avcodec_send_packet(codecContext_, &packet );
++  while( ret >= 0 )
++  {
++    ret = avcodec_receive_frame(codecContext_, frame);
++    if ( Qt4x5::AtomicInt::loadAcquire( isCancelled_ ) || ret < 0 )
++      break;
++    playFrame( frame );
++  }
++#endif
+
+ #if LIBAVCODEC_VERSION_MAJOR < 54
+   av_free( frame );
+32
+srcpkgs/goldendict/patches/ffmpeg5-2.patch
+Comment on this file
+@@ -0,0 +1,32 @@
+From 966f4a8b78e6324b930e5a50f2bb930bd87e565e Mon Sep 17 00:00:00 2001
+From: Abs62 <ottomann@yandex.ru>
+Date: Fri, 27 Sep 2019 17:00:52 +0300
+Subject: [PATCH] FFmpeg player: Fix some crashes on broken files
+
+---
+ ffmpegaudio.cc | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/ffmpegaudio.cc b/ffmpegaudio.cc
+index 56e8f788e..415fc79cb 100644
+--- a/ffmpegaudio.cc
++++ b/ffmpegaudio.cc
+@@ -51,7 +51,9 @@ AudioService & AudioService::instance()
+
+ AudioService::AudioService()
+ {
++#if LIBAVFORMAT_VERSION_MAJOR < 58 || ( LIBAVFORMAT_VERSION_MAJOR == 58 && LIBAVFORMAT_VERSION_MINOR < 9 )
+   av_register_all();
++#endif
+   ao_initialize();
+ }
+
+@@ -438,6 +440,8 @@ bool DecoderContext::play( QString & errorString )
+ #else
+   /* flush the decoder */
+   av_init_packet( &packet );
++  packet.data = NULL;
++  packet.size = 0;
+   int ret = avcodec_send_packet(codecContext_, &packet );
+   while( ret >= 0 )
+   {
+25
+srcpkgs/goldendict/patches/ffmpeg5-3.patch
+Comment on this file
+@@ -0,0 +1,25 @@
+From 8acb288c9e9bdb3c6bf2e803954dd3b6ac273c05 Mon Sep 17 00:00:00 2001
+From: Liao Junxuan <mikeljx@126.com>
+Date: Sun, 20 Feb 2022 12:28:05 +0800
+Subject: [PATCH] add support for ffmpeg 5.0
+
+---
+ ffmpegaudio.cc | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/ffmpegaudio.cc b/ffmpegaudio.cc
+index d550f4a77..7948d2187 100644
+--- a/ffmpegaudio.cc
++++ b/ffmpegaudio.cc
+@@ -94,7 +94,11 @@ struct DecoderContext
+   QByteArray audioData_;
+   QDataStream audioDataStream_;
+   AVFormatContext * formatContext_;
++#if LIBAVCODEC_VERSION_MAJOR < 59
+   AVCodec * codec_;
++#else
++  const AVCodec * codec_;
++#endif
+   AVCodecContext * codecContext_;
+   AVIOContext * avioContext_;
+   AVStream * audioStream_;
diff --git a/srcpkgs/goldendict/template b/srcpkgs/goldendict/template
index 4544ae710ee6..2ca4185e538a 100644
--- a/srcpkgs/goldendict/template
+++ b/srcpkgs/goldendict/template
@@ -9,7 +9,7 @@ makedepends="tiff-devel qt5-devel libvorbis-devel zlib-devel
  libXtst-devel hunspell-devel qt5-tools-devel qt5-declarative-devel
  qt5-webkit-devel lzo-devel bzip2-devel libao-devel qt5-svg-devel
  libeb-devel qt5-x11extras-devel ffmpeg-devel liblzma-devel"
-short_desc="A feature-rich dictionary lookup program"
+short_desc="Feature-rich dictionary lookup program"
 maintainer="John <me@johnnynator.dev>"
 license="GPL-3.0-or-later"
 homepage="http://goldendict.org/"

From 730465a5cb6c98c9726534783f97d3792145140e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 038/113] gst-libav: revbump for ffmpeg-6.0

---
 srcpkgs/gst-libav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index 8c72fc3e97ee..04c39bff1489 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.22.2
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"

From 848bfacf82f49b24a4eb2a66ed65f79f71643259 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 039/113] gst-plugins-bad1: revbump for ffmpeg-6.0

---
 srcpkgs/gst-plugins-bad1/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index 77bf79981c20..5c158724a6c7 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-plugins-bad1'
 pkgname=gst-plugins-bad1
 version=1.22.2
-revision=1
+revision=2
 build_helper="gir"
 build_style=meson
 configure_args="-Dpackage-origin=https://voidlinux.org -Ddoc=disabled

From 96d07d2e3281b93c05f6378819d285dbc1ccdd56 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 040/113] gst-rtsp-server: revbump for ffmpeg-6.0

---
 srcpkgs/gst-rtsp-server/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index 2f0c0c45ff82..980fd72cdd4c 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
 version=1.22.2
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="glib-devel gst-plugins-bad1-devel gobject-introspection

From 4f664422cddce4d2d003b309eb4eb617f1a1e0b5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 041/113] guvcview: update to 2.0.8.

---
 srcpkgs/guvcview/patches/fix-include.patch | 10 ++++++++++
 srcpkgs/guvcview/template                  |  5 ++---
 2 files changed, 12 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/guvcview/patches/fix-include.patch

diff --git a/srcpkgs/guvcview/patches/fix-include.patch b/srcpkgs/guvcview/patches/fix-include.patch
new file mode 100644
index 000000000000..503c2af3b78c
--- /dev/null
+++ b/srcpkgs/guvcview/patches/fix-include.patch
@@ -0,0 +1,10 @@
+--- a/guvcview/guvcview.c
++++ b/guvcview/guvcview.c
+@@ -28,6 +28,7 @@
+ #include <sys/stat.h>
+ #include <sys/resource.h>
+ #include <errno.h>
++#include <locale.h>
+ 
+ #include "gview.h"
+ #include "gviewv4l2core.h"
diff --git a/srcpkgs/guvcview/template b/srcpkgs/guvcview/template
index 345cf6006f24..86a7fd619612 100644
--- a/srcpkgs/guvcview/template
+++ b/srcpkgs/guvcview/template
@@ -1,8 +1,7 @@
 # Template file for 'guvcview'
 pkgname=guvcview
-version=2.0.7
+version=2.0.8
 revision=1
-create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-static --disable-debian-menu"
 hostmakedepends="pkg-config intltool autoconf automake libtool glib-devel"
@@ -14,7 +13,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="http://guvcview.sourceforge.net/"
 distfiles="${SOURCEFORGE_SITE}/${pkgname}/${pkgname}-src-${version}.tar.bz2"
-checksum=f47d51fbd06e44eeaa1a82f4a153c927527c90d94514197a70b2956028cc8ad4
+checksum=a21f4e448286666cf27bafef5290cc953a0a1796b752e5bbe521266dc1230c81
 
 post_patch() {
 	sed '31a#include <locale.h>' -i  guvcview/guvcview.c

From 10dd2ee260c02656678509bb25eeb58541b321cd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 042/113] handbrake: update to 1.6.1

---
 .../patches/fix-missing-x265-link-flag.patch    | 11 ++++++-----
 .../handbrake/patches/libhb-vpl-include.patch   | 15 +++++++++++++++
 srcpkgs/handbrake/template                      | 17 ++++++++++-------
 3 files changed, 31 insertions(+), 12 deletions(-)
 create mode 100644 srcpkgs/handbrake/patches/libhb-vpl-include.patch

diff --git a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
index 26db03867a0c..d6bb2eda627a 100644
--- a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
+++ b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
@@ -1,14 +1,15 @@
 --- a/gtk/configure.ac
 +++ b/gtk/configure.ac
 @@ -203,7 +203,7 @@
- 
+
  AM_CONDITIONAL([MINGW], [test "x$mingw_flag" = "xyes"])
- 
--HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg"
-+HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -ldl"
+
+-HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc"
++HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc -ldl"
  HB_CPPFLAGS="$HB_CPPFLAGS $HBINC"
- 
+
  PKG_CHECK_MODULES([x264], [x264], sys_x264=yes, sys_x264=no)
+
 --- a/test/module.defs
 +++ b/test/module.defs
 @@ -69,6 +69,9 @@
diff --git a/srcpkgs/handbrake/patches/libhb-vpl-include.patch b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
new file mode 100644
index 000000000000..298f9f4ab28f
--- /dev/null
+++ b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
@@ -0,0 +1,15 @@
+--- a/libhb/module.defs	2023-01-22 11:36:49.000000000 -0500
++++ b/libhb/module.defs	2023-04-03 22:37:52.395467010 -0400
+@@ -46,11 +46,7 @@
+ LIBHB.GCC.I += $(LIBHB.build/) $(CONTRIB.build/)include
+ 
+ ifeq (1,$(FEATURE.qsv))
+-    ifeq ($(HOST.system),freebsd))
+-        LIBHB.GCC.I += $(LOCALBASE)/include/vpl
+-    else
+-        LIBHB.GCC.I += $(CONTRIB.build/)include/vpl
+-    endif
++    LIBHB.GCC.I += /usr/include/vpl
+ endif
+ 
+ ifneq (,$(filter $(HOST.system),freebsd netbsd openbsd))
diff --git a/srcpkgs/handbrake/template b/srcpkgs/handbrake/template
index ca5e4571e49c..c32cb1bfa31f 100644
--- a/srcpkgs/handbrake/template
+++ b/srcpkgs/handbrake/template
@@ -1,10 +1,10 @@
 # Template file for 'handbrake'
 pkgname=handbrake
-version=1.5.1
+version=1.6.1
 revision=1
 build_style=gnu-configure
 configure_args="--force --disable-gtk-update-checks --disable-df-fetch --harden
- $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc)"
+ $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc) $(vopt_enable qsv)"
 make_build_args="-C ${XBPS_TRIPLET}"
 make_install_args="-C ${XBPS_TRIPLET}"
 hostmakedepends="automake cmake gettext-devel glib-devel intltool libtool m4 meson nasm pkg-config python3"
@@ -12,8 +12,11 @@ makedepends="bzip2-devel ffmpeg-devel gst-plugins-base1-devel gtk+3-devel
  jansson-devel lame-devel libass-devel libbluray-devel libdav1d-devel
  libdvdnav-devel libdvdread-devel libgudev-devel libnuma-devel
  libsamplerate-devel libtheora-devel libvorbis-devel libvpx-devel libxml2-devel
- opus-devel speex-devel x264-devel x265-devel zimg-devel
+ opus-devel speex-devel x264-devel x265-devel zimg-devel libsvt-av1-devel
  $(vopt_if fdk_aac fdk-aac-devel)
+ $(vopt_if qsv libva-devel)
+ $(vopt_if qsv libdrm-devel)
+ $(vopt_if qsv onevpl-devel)
  $(vopt_if nvenc nv-codec-headers)"
 depends="desktop-file-utils gst-plugins-good1 hicolor-icon-theme"
 short_desc="Multithreaded video transcoder"
@@ -21,15 +24,15 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-2.0-only"
 homepage="https://handbrake.fr/"
 distfiles="https://github.com/HandBrake/HandBrake/releases/download/${version}/HandBrake-${version}-source.tar.bz2"
-checksum=3999fe06d5309c819799a73a968a8ec3840e7840c2b64af8f5cdb7fd8c9430f0
+checksum=94ccfe03db917a91650000c510f7fd53f844da19f19ad4b4be1b8f6bc31a8d4c
 nocross=yes
 
-build_options="fdk_aac nvenc"
+build_options="fdk_aac nvenc qsv"
 
 case "$XBPS_TARGET_MACHINE" in
 	x86_64*|i686*)
 		CFLAGS="-msse"
-		build_options_default="nvenc"
+		build_options_default="nvenc qsv"
 		;;
 esac
 
@@ -37,7 +40,7 @@ pre_configure() {
 	# use system libraries, don't download them
 	rm -rf contrib/
 	for module in fdk-aac ffmpeg libbluray libdav1d libdvdnav libdvdread nvenc \
-		x265 zimg; do
+		x265 zimg svt-av1 libvpl; do
 	    vsed -i "/MODULES += contrib\/${module}/d" make/include/main.defs
 	done
 }

From b8acf74c5ed61aa21c79ea20bfd067f3462a6182 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 043/113] hedgewars: revbump for ffmpeg4-4.4.3

---
 srcpkgs/hedgewars/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/hedgewars/template b/srcpkgs/hedgewars/template
index 419f29b98b44..926fe4fe3e68 100644
--- a/srcpkgs/hedgewars/template
+++ b/srcpkgs/hedgewars/template
@@ -1,13 +1,13 @@
 # Template file for 'hedgewars'
 pkgname=hedgewars
 version=1.0.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DNOSERVER=1 -DDATA_INSTALL_DIR=/usr/share/${pkgname}
  -DPHYSFS_SYSTEM=1 -DMINIMAL_FLAGS=1"
 make_cmd=make
 hostmakedepends="lua51 pkg-config qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
+makedepends="ffmpeg4-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
  SDL2_mixer-devel SDL2_net-devel SDL2_ttf-devel"
 depends="libfreeglut"
 short_desc="Funny turn-based artillery game, featuring fighting Hedgehogs!"

From 686238c4282fc33f9dd75b0539991b95af11aa5a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 044/113] idjc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/idjc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/idjc/template b/srcpkgs/idjc/template
index df60318b3db9..36a75baf597c 100644
--- a/srcpkgs/idjc/template
+++ b/srcpkgs/idjc/template
@@ -1,11 +1,11 @@
 # Template file for 'idjc'
 pkgname=idjc
 version=0.9.1
-revision=3
+revision=4
 build_style=gnu-configure
 hostmakedepends="pkg-config git python3 automake gettext-devel libtool"
 makedepends="libvorbis-devel libogg-devel jack-devel libsamplerate-devel
- libflac-devel libsndfile-devel mpg123-devel ffmpeg-devel speex-devel
+ libflac-devel libsndfile-devel mpg123-devel ffmpeg4-devel speex-devel
  glib-devel pixman-devel lame-devel python3-gobject-devel libshout-idjc-devel
  opus-devel twolame-devel python3-mutagen python3-devel"
 depends="python3-gobject python3-mutagen desktop-file-utils shared-mime-info python3-dbus jack"

From 18bccb7f98be1e726d155cf307de34660ea488b2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 045/113] kfilemetadata5: revbump for ffmpeg-6.0

---
 srcpkgs/kfilemetadata5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kfilemetadata5/template b/srcpkgs/kfilemetadata5/template
index 4b91cf19f298..a3671a38ce59 100644
--- a/srcpkgs/kfilemetadata5/template
+++ b/srcpkgs/kfilemetadata5/template
@@ -1,7 +1,7 @@
 # Template file for 'kfilemetadata5'
 pkgname=kfilemetadata5
 version=5.107.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="kcoreaddons extra-cmake-modules pkg-config qt5-host-tools qt5-qmake
  gettext kcoreaddons python3"

From 0348fda61088a0020813611886722e1b5182d0db Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 046/113] kid3: revbump for ffmpeg-6.0

---
 srcpkgs/kid3/patches/ffmpeg5.patch | 17 +++++++++++++++++
 srcpkgs/kid3/template              |  2 +-
 2 files changed, 18 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/kid3/patches/ffmpeg5.patch

diff --git a/srcpkgs/kid3/patches/ffmpeg5.patch b/srcpkgs/kid3/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..135fc50e07c9
--- /dev/null
+++ b/srcpkgs/kid3/patches/ffmpeg5.patch
@@ -0,0 +1,17 @@
+# https://aur.archlinux.org/cgit/aur.git/diff/ffmpeg5.patch?h=kid3-cli&id=12410a74906612e7efc0ec8fbce739b4a0fef7e7
+diff --git a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+index e156d424..e12b9abd 100644
+--- a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
++++ b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+@@ -232,7 +232,11 @@ private:
+   friend class Format;
+   friend class Converter;
+   AVCodecContext* m_ptr;
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 0, 0)
+   AVCodec* m_impl;
++#else
++  const AVCodec* m_impl;
++#endif
+   AVFrame* m_frame;
+   bool m_opened;
+ };
diff --git a/srcpkgs/kid3/template b/srcpkgs/kid3/template
index 456206d90e16..f32f9decb0e7 100644
--- a/srcpkgs/kid3/template
+++ b/srcpkgs/kid3/template
@@ -1,7 +1,7 @@
 # Template file for 'kid3'
 pkgname=kid3
 version=3.9.1
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DWITH_APPS='CLI;$(vopt_if KDE KDE Qt)'
  -DWITH_DOCBOOKDIR=/usr/share/xsl/docbook -DWITH_FLAC=$(vopt_if flac ON OFF)

From 95e679899d06ed49062286a1411860a3e2d5b5ca Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 047/113] kodi: revbump for ffmpeg4-4.4.3

---
 srcpkgs/kodi/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/kodi/template b/srcpkgs/kodi/template
index 8057964d78a3..6cc1874be7ba 100644
--- a/srcpkgs/kodi/template
+++ b/srcpkgs/kodi/template
@@ -1,7 +1,7 @@
 # Template file for 'kodi'
 pkgname=kodi
 version=19.4
-revision=6
+revision=7
 _codename="Matrix"
 build_style=cmake
 configure_args="-DWITH_FFMPEG=/usr -DENABLE_LDGOLD=OFF
@@ -54,7 +54,7 @@ makedepends="
  libmad-devel fontconfig-devel libXinerama-devel libsamplerate-devel libmms-devel
  enca-devel boost-devel libcurl-devel libva-devel libvdpau-devel libass-devel
  libbluetooth-devel yajl-devel libplist-devel librtmp-devel tinyxml-devel
- taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg-devel
+ taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg4-devel
  giflib-devel libxslt-devel gnutls-devel libssh-devel libmicrohttpd-devel
  libcec-devel dcadec-devel flatbuffers-devel fmt-devel lcms2-devel
  libfstrcmp-devel rapidjson libcdio-paranoia spdlog libwaylandpp-devel

From f0271ff23363544b99a6d932fe65791df0850245 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 048/113] kpipewire: revbump for ffmpeg-6.0

---
 srcpkgs/kpipewire/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kpipewire/template b/srcpkgs/kpipewire/template
index 05ad025944da..7aa120e6ba94 100644
--- a/srcpkgs/kpipewire/template
+++ b/srcpkgs/kpipewire/template
@@ -1,7 +1,7 @@
 # Template file for 'kpipewire'
 pkgname=kpipewire
 version=5.27.5
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules plasma-wayland-protocols gettext
  qt5-qmake qt5-host-tools pkg-config wayland-devel kcoreaddons

From 69bf9b5b973e4864a968b9161fab688d0f53baa8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 049/113] libextractor: revbump for ffmpeg4-4.4.3

---
 srcpkgs/libextractor/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libextractor/template b/srcpkgs/libextractor/template
index ddd4790f93e8..1fb9ca56a96a 100644
--- a/srcpkgs/libextractor/template
+++ b/srcpkgs/libextractor/template
@@ -7,7 +7,7 @@ configure_args="--disable-static"
 hostmakedepends="pkg-config"
 makedepends="zlib-devel bzip2-devel exiv2-devel tiff-devel libpng-devel
  libjpeg-turbo-devel libvorbis-devel libflac-devel giflib-devel libmpeg2-devel
- ffmpeg-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
+ ffmpeg4-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
 short_desc="Library used to extract meta data from files"
 maintainer="Martin Riese <grauehaare@gmx.de>"
 license="GPL-3.0-or-later"

From 618c9a37db1548c167ec41b20c9f35ded0b36644 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 050/113] libopenal: revbump for ffmpeg-6.0

---
 srcpkgs/libopenal/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenal/template b/srcpkgs/libopenal/template
index 77218f9e539d..3f49ed75a1fd 100644
--- a/srcpkgs/libopenal/template
+++ b/srcpkgs/libopenal/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenal'
 pkgname=libopenal
 version=1.22.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DALSOFT_EXAMPLES=OFF"
 hostmakedepends="pkg-config"

From fd55ea40178a356793f1faddd5701e37482cc20d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 051/113] libopenshot: revbump for ffmpeg-6.0

---
 srcpkgs/libopenshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenshot/template b/srcpkgs/libopenshot/template
index db831f69b474..81aa0d7136d9 100644
--- a/srcpkgs/libopenshot/template
+++ b/srcpkgs/libopenshot/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenshot'
 pkgname=libopenshot
 version=0.3.0
-revision=1
+revision=2
 build_style=cmake
 # Builds fail with Ruby-2.4.1
 configure_args="-DENABLE_RUBY=OFF -DUSE_SYSTEM_JSONCPP=ON"

From d412c9acfed9b8d9106ae23f9d666f8d803df27e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 052/113] loudgain: revbump for ffmpeg-6.0

---
 srcpkgs/loudgain/patches/ffmpeg5.patch | 11 +++++++++++
 srcpkgs/loudgain/template              |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/loudgain/patches/ffmpeg5.patch

diff --git a/srcpkgs/loudgain/patches/ffmpeg5.patch b/srcpkgs/loudgain/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..16d4510ee98f
--- /dev/null
+++ b/srcpkgs/loudgain/patches/ffmpeg5.patch
@@ -0,0 +1,11 @@
+--- a/src/scan.c	2019-09-06 11:31:19.000000000 -0400
++++ b/src/scan.c	2023-03-23 11:15:40.867968521 -0400
+@@ -69,8 +69,6 @@
+ 	 * It is now useless
+ 	 * https://github.com/FFmpeg/FFmpeg/blob/70d25268c21cbee5f08304da95be1f647c630c15/doc/APIchanges#L86
+ 	 */
+-  if (avformat_version() < AV_VERSION_INT(58,9,100))
+-    av_register_all();
+ 
+ 	av_log_set_callback(scan_av_log);
+ 
diff --git a/srcpkgs/loudgain/template b/srcpkgs/loudgain/template
index da4f2d56e94c..4d6bf29efb4f 100644
--- a/srcpkgs/loudgain/template
+++ b/srcpkgs/loudgain/template
@@ -1,7 +1,7 @@
 # Template file for 'loudgain'
 pkgname=loudgain
 version=0.6.8
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libebur128-devel taglib-devel ffmpeg-devel"

From 67c98beb45476fb4956e8dcc8d80c8d4fd6fc03d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 053/113] mediastreamer: revbump for ffmpeg4-4.4.3

---
 srcpkgs/mediastreamer/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mediastreamer/template b/srcpkgs/mediastreamer/template
index d0e97e858e29..1bde031443a5 100644
--- a/srcpkgs/mediastreamer/template
+++ b/srcpkgs/mediastreamer/template
@@ -1,11 +1,11 @@
 # Template file for 'mediastreamer'
 pkgname=mediastreamer
 version=5.2.6
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_STRICT=0 -DENABLE_UNIT_TESTS=0"
 hostmakedepends="python3"
-makedepends="bzrtp-devel ffmpeg-devel glew-devel libXv-devel libsrtp-devel
+makedepends="bzrtp-devel ffmpeg4-devel glew-devel libXv-devel libsrtp-devel
  libupnp-devel libvpx-devel mbedtls-devel opus-devel ortp-devel pulseaudio-devel
  libtheora-devel speex-devel v4l-utils-devel bcg729-devel bcmatroska2-devel libgsm-devel"
 # zxing-cpp-devel (1.2.0 probably not compatible, check again after updaing xzing)

From cae017b208c7b60bfd55f8f4391ac28b0d4b7b10 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 054/113] mgba: revbump for ffmpeg-6.0

---
 srcpkgs/mgba/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mgba/template b/srcpkgs/mgba/template
index ae0504311eee..d31295a0cd3d 100644
--- a/srcpkgs/mgba/template
+++ b/srcpkgs/mgba/template
@@ -1,7 +1,7 @@
 # Template file for 'mgba'
 pkgname=mgba
 version=0.10.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake desktop-file-utils"
 makedepends="SDL2-devel ffmpeg-devel libedit-devel libepoxy-devel libmagick-devel

From f789051378bb9d6dbc78cec8badf6ad92a49ffc5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 055/113] minidlna: revbump for ffmpeg-6.0

---
 srcpkgs/minidlna/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/minidlna/template b/srcpkgs/minidlna/template
index e8081b1cbc67..9ee9714861fd 100644
--- a/srcpkgs/minidlna/template
+++ b/srcpkgs/minidlna/template
@@ -1,7 +1,7 @@
 # Template file for 'minidlna'
 pkgname=minidlna
 version=1.3.2
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="
  --sbindir=/usr/bin

From d76f4b703e752af72a18a30e60f536d8d38d28d4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 056/113] mixxx: revbump for ffmpeg-6.0

---
 srcpkgs/mixxx/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mixxx/template b/srcpkgs/mixxx/template
index 619ddca0d332..4b9ea00d3fb3 100644
--- a/srcpkgs/mixxx/template
+++ b/srcpkgs/mixxx/template
@@ -1,7 +1,7 @@
 # Template file for 'mixxx'
 pkgname=mixxx
 version=2.3.3
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="extra-cmake-modules pkg-config protobuf qt5-host-tools qt5-devel"

From 491ddecd93cc8e686d72ef577beacfe0edafa6a7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 057/113] mlt: revbump for ffmpeg4-4.4.3

---
 srcpkgs/mlt/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mlt/template b/srcpkgs/mlt/template
index 8933eb4e7bb9..73353fedafb5 100644
--- a/srcpkgs/mlt/template
+++ b/srcpkgs/mlt/template
@@ -1,14 +1,14 @@
 # Template file for 'mlt'
 pkgname=mlt
 version=6.26.1
-revision=1
+revision=2
 build_style=configure
 configure_args="--prefix=/usr --libdir=/usr/lib$XBPS_TARGET_WORDSIZE
  --enable-gpl --enable-gpl3 --disable-swfdec --without-kde
  --swig-languages=python"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which"
 # XXX: movit vid.stab
-makedepends="alsa-lib-devel ffmpeg-devel gtk+-devel jack-devel ladspa-sdk
+makedepends="alsa-lib-devel ffmpeg4-devel gtk+-devel jack-devel ladspa-sdk
  libexif-devel libsamplerate-devel libxml2-devel sox-devel SDL_image-devel
  fftw-devel frei0r-plugins python3-devel pulseaudio-devel movit-devel
  libvidstab-devel libatomic-devel"

From 1e64a11348da2b5cea251fce432504ab32fa6371 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 058/113] moc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/moc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/moc/template b/srcpkgs/moc/template
index c42be650a1d2..d4f0eefbad52 100644
--- a/srcpkgs/moc/template
+++ b/srcpkgs/moc/template
@@ -1,10 +1,10 @@
 # Template file for 'moc'
 pkgname=moc
 version=2.5.2
-revision=6
+revision=7
 build_style=gnu-configure
 hostmakedepends="pkg-config"
-makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg-devel
+makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg4-devel
  jack-devel alsa-lib-devel libltdl-devel libflac-devel libvorbis-devel
  libmad-devel libmpcdec-devel libmodplug-devel libid3tag-devel faad2-devel
  taglib-devel libsndfile-devel wavpack-devel speex-devel libsamplerate-devel

From 9007b373e2c75e11bf5361cb906c650ba1a9c3d8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 059/113] motion: revbump for ffmpeg-6.0

---
 srcpkgs/motion/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/motion/template b/srcpkgs/motion/template
index 3cf3c3035c5b..7dca12d851e3 100644
--- a/srcpkgs/motion/template
+++ b/srcpkgs/motion/template
@@ -1,7 +1,7 @@
 # Template file for 'motion'
 pkgname=motion
 version=4.5.1
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake pkg-config gettext-devel tar"
 makedepends="ffmpeg-devel libmicrohttpd-devel v4l-utils-devel gettext-devel"

From e3a11c91cf1f923642173c4193a3ecaf36ea5128 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 060/113] mpv: revbump for ffmpeg-6.0

---
 srcpkgs/mpv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpv/template b/srcpkgs/mpv/template
index e163c496c6eb..d4fefbf5e3c7 100644
--- a/srcpkgs/mpv/template
+++ b/srcpkgs/mpv/template
@@ -1,7 +1,7 @@
 # Template file for 'mpv'
 pkgname=mpv
 version=0.35.1
-revision=2
+revision=3
 build_style=meson
 configure_args="-Dcdda=enabled -Ddvbin=enabled -Ddvdnav=enabled
  -Dlibmpv=true -Dcplugins=enabled

From e627f97d725b23a687612cc7bde628d4b325fd85 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 061/113] musikcube: revbump for ffmpeg-6.0

---
 srcpkgs/musikcube/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/musikcube/template b/srcpkgs/musikcube/template
index 7c569303c054..a4dea460c371 100644
--- a/srcpkgs/musikcube/template
+++ b/srcpkgs/musikcube/template
@@ -1,7 +1,7 @@
 # Template file for 'musikcube'
 pkgname=musikcube
 version=3.0.0
-revision=1
+revision=2
 build_style=cmake
 make_cmd=make
 configure_args="-DNO_NCURSESW=1"

From 6b5bb6d21b70126a6d4c53e14474d595002362b6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 062/113] notcurses: revbump for ffmpeg-6.0

---
 srcpkgs/notcurses/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/notcurses/template b/srcpkgs/notcurses/template
index 6dd8a091319f..3110c30c9aff 100644
--- a/srcpkgs/notcurses/template
+++ b/srcpkgs/notcurses/template
@@ -1,7 +1,7 @@
 # Template file for 'notcurses'
 pkgname=notcurses
 version=3.0.9
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DUSE_STATIC=ON $(vopt_bool man USE_PANDOC)"
 hostmakedepends="pkg-config $(vopt_if man pandoc)"

From 9992642ffa997051e51514499d286b4b42f7e5df Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 063/113] obs: revbump for ffmpeg-6.0

---
 srcpkgs/obs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/obs/template b/srcpkgs/obs/template
index 7b69c630d30d..2c8d68d71f3a 100644
--- a/srcpkgs/obs/template
+++ b/srcpkgs/obs/template
@@ -1,7 +1,7 @@
 # Template file for 'obs'
 pkgname=obs
 version=29.1.2
-revision=1
+revision=2
 archs="i686* x86_64* ppc64le* aarch64*"
 build_style=cmake
 configure_args="-DOBS_VERSION_OVERRIDE=${version} -DENABLE_JACK=ON

From 98bb725f228071c6114bc154e8b1ad58c0f056f8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 064/113] olive: revbump for ffmpeg4-4.4.3

---
 srcpkgs/olive/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/olive/template b/srcpkgs/olive/template
index 12a46936c990..5c2917b9c512 100644
--- a/srcpkgs/olive/template
+++ b/srcpkgs/olive/template
@@ -1,10 +1,10 @@
 # Template file for 'olive'
 pkgname=olive
 version=0.1.2
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools pkg-config"
-makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg-devel frei0r-plugins"
+makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg4-devel frei0r-plugins"
 short_desc="Non-linear video editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"

From 8c17e660456bf5995aa21a55594024334273b450 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 065/113] omxplayer: revbump for ffmpeg4-4.4.3

---
 srcpkgs/omxplayer/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/omxplayer/template b/srcpkgs/omxplayer/template
index e70bf7873d4d..0e9bc70e7c8e 100644
--- a/srcpkgs/omxplayer/template
+++ b/srcpkgs/omxplayer/template
@@ -1,10 +1,10 @@
 # Template file for 'omxplayer'
 pkgname=omxplayer
 version=20190102
-revision=1
+revision=2
 short_desc="Commandline OMX player for the Raspberry Pi"
 maintainer="Orphaned <orphan@voidlinux.org>"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://github.com/popcornmix/omxplayer"
 
 _commit="f06235cc9690a6d58187514452df8cf8fcdaacec"
@@ -15,7 +15,7 @@ checksum=af2d9450f8947842ea8c401fe9f71eec444013ebbdee29f2ac828c9c493c1329
 archs="armv6l* armv7l*"
 build_style=gnu-makefile
 hostmakedepends="curl pkg-config"
-makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg-devel dbus-devel"
+makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg4-devel dbus-devel"
 depends="freefont-ttf"
 
 do_build() {

From 370f47e30dfc9cf44f0167d48ba0b64c08d4feb1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 066/113] openimageio: revbump for ffmpeg-6.0

---
 common/shlibs                | 2 ++
 srcpkgs/openimageio/template | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/shlibs b/common/shlibs
index eccef60021c4..ebde5fe166ab 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2260,6 +2260,8 @@ libxmp.so.4 libxmp-4.3.7_1
 libKF5ThreadWeaver.so.5 threadweaver-5.26.0_1
 libOpenImageIO_Util.so.2.4 openimageio-2.4.9.0_1
 libOpenImageIO.so.2.4 openimageio-2.4.9.0_1
+libOpenImageIO_Util.so.2.4 openimageio-2.4.8.1_1
+libOpenImageIO.so.2.4 openimageio-2.4.8.1_1
 libOpenColorIO.so.2.1 opencolorio-2.1.2_1
 libpystring.so.1 pystring-1.1.3_1
 libyaml-cpp.so.0.7 yaml-cpp-0.7.0_1
diff --git a/srcpkgs/openimageio/template b/srcpkgs/openimageio/template
index c2d36b4b3539..0e9e22e9685d 100644
--- a/srcpkgs/openimageio/template
+++ b/srcpkgs/openimageio/template
@@ -1,7 +1,7 @@
 # Template file for 'openimageio'
 pkgname=openimageio
 version=2.4.9.0
-revision=4
+revision=5
 build_style=cmake
 build_helper=qemu
 configure_args="-DUSE_QT=0 -DUSE_PYTHON=0 -DOIIO_BUILD_TESTS=0

From a39d0ac508b12caf6ab52275ee0ef1a6fcaf894d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 067/113] openshot: revbump for ffmpeg-6.0

---
 srcpkgs/openshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openshot/template b/srcpkgs/openshot/template
index 322717d40abc..c074e0338773 100644
--- a/srcpkgs/openshot/template
+++ b/srcpkgs/openshot/template
@@ -1,7 +1,7 @@
 # Template file for 'openshot'
 pkgname=openshot
 version=3.0.0
-revision=1
+revision=2
 build_style=python3-module
 hostmakedepends="python3 python3-setuptools"
 makedepends="ffmpeg-devel python3-PyQt5"

From f778e5bce9b41fbc35e2e00ada0cf19f8837f9d9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 068/113] opentoonz: revbump for ffmpeg-6.0

---
 srcpkgs/opentoonz/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/opentoonz/template b/srcpkgs/opentoonz/template
index ee9f7603f55f..3e81834ca0ed 100644
--- a/srcpkgs/opentoonz/template
+++ b/srcpkgs/opentoonz/template
@@ -1,7 +1,7 @@
 # Template file for 'opentoonz'
 pkgname=opentoonz
 version=1.6.0
-revision=2
+revision=3
 build_wrksrc="toonz/sources"
 build_style=cmake
 make_cmd=make

From b79140df5a6f8616c2f28fe02e0930b0a3304a5b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 069/113] pianobar: revbump for ffmpeg-6.0

---
 srcpkgs/pianobar/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pianobar/template b/srcpkgs/pianobar/template
index a9b29e91993f..81efcd122c4d 100644
--- a/srcpkgs/pianobar/template
+++ b/srcpkgs/pianobar/template
@@ -1,7 +1,7 @@
 # Template file for 'pianobar'
 pkgname=pianobar
 version=2022.04.01
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="V=1"
 hostmakedepends="pkg-config"

From 4d76c5fe9815118b1393f46989bb4e9a8a0a1b76 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 070/113] ppsspp: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ppsspp/template | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/ppsspp/template b/srcpkgs/ppsspp/template
index 7984a733d4be..15a42fd2c993 100644
--- a/srcpkgs/ppsspp/template
+++ b/srcpkgs/ppsspp/template
@@ -1,7 +1,7 @@
 # Template file for 'ppsspp'
 pkgname=ppsspp
 version=1.14.4
-revision=1
+revision=2
 _glslang_commit=dc11adde23c455a24e13dd54de9b4ede8bdd7db8
 _SPIRV_Cross_commit=9acb9ec31f5a8ef80ea6b994bb77be787b08d3d1
 _armips_commit=6719edebaae03330ee5441d9b28280672edf00d5
@@ -13,7 +13,7 @@ configure_args="-DHEADLESS=1 -DUSE_SYSTEM_FFMPEG=1 -DUNITTEST=ON
  -DUSING_QT_UI=$(vopt_if qt ON OFF) -DUSE_SYSTEM_ZSTD=ON
  -DARMIPS_USE_STD_FILESYSTEM=ON"
 hostmakedepends="pkg-config python3 $(vopt_if qt qt5-host-tools)"
-makedepends="zlib-devel glew-devel ffmpeg-devel libzip-devel
+makedepends="zlib-devel glew-devel ffmpeg4-devel libzip-devel
  snappy-devel rapidjson libpng-devel libzstd-devel
  $(vopt_if sdl2 SDL2-devel) $(vopt_if wayland wayland-devel)
  $(vopt_if qt 'qt5-devel qt5-multimedia-devel')"
@@ -62,13 +62,12 @@ post_extract() {
 	mv ${wrksrc}/miniupnp-${_miniupnp_commit} ${wrksrc}/ext/miniupnp
 }
 
-post_patch(){
+post_patch() {
 	# disable git versioning
 	vsed -e 's|find_package(Git)|# &|' -i git-version.cmake
 }
 
 do_install() {
-	vlicense LICENSE.TXT
 	vinstall icons/icon.svg 644 usr/share/pixmaps ppsspp.svg
 	vinstall Qt/PPSSPP.desktop 644 usr/share/applications
 	vbin build/PPSSPPHeadless ppsspp-headless

From bcfca6acf8ae20c98b482f82a7aebf0dcc425562 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 071/113] pqiv: revbump for ffmpeg-6.0

---
 srcpkgs/pqiv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pqiv/template b/srcpkgs/pqiv/template
index 542fc27a2d32..9308d949b6a1 100644
--- a/srcpkgs/pqiv/template
+++ b/srcpkgs/pqiv/template
@@ -1,7 +1,7 @@
 # Template file for 'pqiv'
 pkgname=pqiv
 version=2.12
-revision=1
+revision=2
 build_style=gnu-makefile
 hostmakedepends="pkg-config"
 makedepends="glib-devel gtk+3-devel $(vopt_if ffmpeg ffmpeg-devel)

From 5bd907a6d78bba5b45a80e38cabd5142ebd93a50 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 072/113] qmmp: revbump for ffmpeg-6.0

---
 srcpkgs/qmmp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qmmp/template b/srcpkgs/qmmp/template
index 26c661ed16be..a150d7441c7a 100644
--- a/srcpkgs/qmmp/template
+++ b/srcpkgs/qmmp/template
@@ -1,7 +1,7 @@
 # Template file for 'qmmp'
 pkgname=qmmp
 version=1.6.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DUSE_HAL:BOOL=FALSE -DQMMP_DEFAULT_UI:STRING=simple"
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From baf50a1d443411885e096b656ebb7efa07d90b31 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 073/113] qt5-webengine: update to 5.15.13

---
 .../chromium-media-filters-cpp14.patch        |  11 ++
 srcpkgs/qt5-webengine/patches/ffmpeg5.patch   | 179 ++++++++++++++++++
 srcpkgs/qt5-webengine/template                |  10 +-
 3 files changed, 195 insertions(+), 5 deletions(-)
 create mode 100644 srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/ffmpeg5.patch

diff --git a/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
new file mode 100644
index 000000000000..04adc540f2cb
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
@@ -0,0 +1,11 @@
+--- a/src/3rdparty/chromium/media/filters/BUILD.gn	2023-02-27 13:32:59.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/BUILD.gn	2023-04-02 17:21:39.204066384 -0400
+@@ -96,6 +96,8 @@
+     "//ui/gfx/geometry:geometry",
+   ]
+ 
++  cflags_cc = [ "-std=c++14" ]
++
+   libs = []
+ 
+   if (proprietary_codecs) {
diff --git a/srcpkgs/qt5-webengine/patches/ffmpeg5.patch b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..ac55e1634423
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
@@ -0,0 +1,179 @@
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:57.732547446 -0400
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:09.486478995 -0400
+@@ -57,6 +57,8 @@
+ 
+ namespace {
+ 
++constexpr int64_t kRelativeTsBase = static_cast<int64_t>(0x7ffeffffffffffff);
++
+ void SetAVStreamDiscard(AVStream* stream, AVDiscard discard) {
+   DCHECK(stream);
+   stream->discard = discard;
+@@ -90,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+   if (stream->start_time != kNoFFmpegTimestamp)
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (stream->first_dts != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, stream->first_dts);
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -408,11 +398,11 @@
+   scoped_refptr<DecoderBuffer> buffer;
+ 
+   if (type() == DemuxerStream::TEXT) {
+-    int id_size = 0;
++    size_t id_size = 0;
+     uint8_t* id_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
+ 
+-    int settings_size = 0;
++    size_t settings_size = 0;
+     uint8_t* settings_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
+ 
+@@ -424,7 +414,7 @@
+     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
+                                      side_data.data(), side_data.size());
+   } else {
+-    int side_data_size = 0;
++    size_t side_data_size = 0;
+     uint8_t* side_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
+ 
+@@ -485,7 +475,7 @@
+                                        packet->size - data_offset);
+     }
+ 
+-    int skip_samples_size = 0;
++    size_t skip_samples_size = 0;
+     const uint32_t* skip_samples_ptr =
+         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
+             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
+@@ -1587,6 +1577,8 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++      continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+       lowest_start_time_stream = stream.get();
+@@ -1604,6 +1596,8 @@
+     if (stream && stream->type() == DemuxerStream::VIDEO &&
+         stream->IsEnabled()) {
+       video_stream = stream.get();
++      if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++        continue;
+       if (video_stream->start_time() <= seek_time) {
+         return video_stream;
+       }
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h qtwebengine-5.15.10/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h
+--- a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-07-11 22:12:47.917192788 -0500
+@@ -29,6 +29,7 @@ extern "C" {
+ #include <libavformat/avformat.h>
+ #include <libavformat/avio.h>
+ #include <libavutil/avutil.h>
++#include <libavutil/channel_layout.h>
+ #include <libavutil/imgutils.h>
+ #include <libavutil/log.h>
+ #include <libavutil/mastering_display_metadata.h>
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/audio_file_reader.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/audio_file_reader.cc
+--- a/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -85,7 +85,7 @@ bool AudioFileReader::OpenDemuxer() {
+ }
+ 
+ bool AudioFileReader::OpenDecoder() {
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (codec) {
+     // MP3 decodes to S16P which we don't support, tell it to use S16 instead.
+     if (codec_context_->sample_fmt == AV_SAMPLE_FMT_S16P)
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -329,7 +329,7 @@ bool FFmpegAudioDecoder::ConfigureDecode
+     }
+   }
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec ||
+       avcodec_open2(codec_context_.get(), codec, &codec_options) < 0) {
+     DLOG(ERROR) << "Could not initialize audio decoder: "
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -59,7 +59,6 @@ static int64_t AVIOSeekOperation(void* o
+ }
+ 
+ void FFmpegGlue::InitializeFFmpeg() {
+-  av_register_all();
+ }
+ 
+ static void LogContainer(bool is_local_file,
+@@ -95,9 +94,6 @@ FFmpegGlue::FFmpegGlue(FFmpegURLProtocol
+   // Enable fast, but inaccurate seeks for MP3.
+   format_context_->flags |= AVFMT_FLAG_FAST_SEEK;
+ 
+-  // Ensures we can read out various metadata bits like vp8 alpha.
+-  format_context_->flags |= AVFMT_FLAG_KEEP_SIDE_DATA;
+-
+   // Ensures format parsing errors will bail out. From an audit on 11/2017, all
+   // instances were real failures. Solves bugs like http://crbug.com/710791.
+   format_context_->error_recognition |= AV_EF_EXPLODE;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -391,7 +391,7 @@ bool FFmpegVideoDecoder::ConfigureDecode
+   if (decode_nalus_)
+     codec_context_->flags2 |= AV_CODEC_FLAG2_CHUNKS;
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
+     ReleaseFFmpegResources();
+     return false;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/media_file_checker.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/media_file_checker.cc
+--- a/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -68,7 +68,7 @@ bool MediaFileChecker::Start(base::TimeD
+       auto context = AVStreamToAVCodecContext(format_context->streams[i]);
+       if (!context)
+         continue;
+-      AVCodec* codec = avcodec_find_decoder(cp->codec_id);
++      const AVCodec* codec = avcodec_find_decoder(cp->codec_id);
+       if (codec && avcodec_open2(context.get(), codec, nullptr) >= 0) {
+         auto loop = std::make_unique<FFmpegDecodingLoop>(context.get());
+         stream_contexts[i] = {std::move(context), std::move(loop)};
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc qtwebengine-5.15.10/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc
+--- a/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -203,7 +203,7 @@ int32_t H264DecoderImpl::InitDecode(cons
+   // a pointer |this|.
+   av_context_->opaque = this;
+ 
+-  AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
+   if (!codec) {
+     // This is an indication that FFmpeg has not been initialized or it has not
+     // been compiled/initialized with the correct set of codecs.
diff --git a/srcpkgs/qt5-webengine/template b/srcpkgs/qt5-webengine/template
index 85267c7cf8a3..095ab67701e4 100644
--- a/srcpkgs/qt5-webengine/template
+++ b/srcpkgs/qt5-webengine/template
@@ -1,9 +1,9 @@
 # Template file for 'qt5-webengine'
 pkgname=qt5-webengine
-version=5.15.11
-revision=3
+version=5.15.13
+revision=1
 _version="${version}-lts"
-_chromium_commit=be349eaf62e77955791d7bf29f893f1e8a37daf4
+_chromium_commit=e48df7803c7c98b0b2471c94057d32e44a301ad5
 archs="x86_64* i686* armv[67]* ppc64* aarch64*"
 create_wrksrc=yes
 build_style=qmake
@@ -32,8 +32,8 @@ license="GPL-3.0-or-later, LGPL-3.0-or-later"
 homepage="https://qt.io/"
 distfiles="https://github.com/qt/qtwebengine/archive/v${_version}.tar.gz
  https://github.com/qt/qtwebengine-chromium/archive/${_chromium_commit}.tar.gz"
-checksum="aa7466356c450c5f5870f979b93cd7e7e62da1165c328ffcab1a9928db18ad67
- 6f47ed8ab8cc062411f6f206da6353bc8263d6ed6d6290c689a05c01d91f646b"
+checksum="4b59838ed75ef788b59e1e412535a0e42dd9d311661fdeadb191b581ba815c63
+ a91686562b1d4e8b220e0bbcbab5feb64630e2de974b35ac034bf388af771a6c"
 
 no_generic_pkgconfig_link=yes
 build_options="sndio pipewire"

From 9d9e3af04183668f2aa36db66a094ee59f24ccde Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 074/113] qt5: update to 5.15.8

---
 ...erywhere-opensource-src-5.15.8-kf5-1.patch | 12913 ++++++++++++++++
 srcpkgs/qt5/template                          |    12 +-
 2 files changed, 12919 insertions(+), 6 deletions(-)
 create mode 100644 srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch

diff --git a/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch b/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch
new file mode 100644
index 000000000000..966c98bcd3bb
--- /dev/null
+++ b/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch
@@ -0,0 +1,12913 @@
+Submitted By:            Pierre Labastie <pierre_dot_labastie_at_neuf_dot_fr>
+Date:                    2023-01-05
+Initial Package Version: 5.15.8
+Upstream Status:         Applied (according to KDE)
+Origin:                  KDE patch set
+Description:             Patch set maintained by the KDE folks
+see https://dot.kde.org/2021/04/06/announcing-kdes-qt-5-patch-collection
+Patch generated using the procedure in
+https://wiki.linuxfromscratch.org/blfs/ticket/17476#comment:3
+
+Submodule qtbase 4ee4fc18..9cf586d6:
+diff --git a/qtbase/mkspecs/common/android/qplatformdefs.h b/qtbase/mkspecs/common/android/qplatformdefs.h
+index f75bc4093b..2bd59410d4 100644
+--- a/qtbase/mkspecs/common/android/qplatformdefs.h
++++ b/qtbase/mkspecs/common/android/qplatformdefs.h
+@@ -144,11 +144,7 @@
+ #define QT_SIGNAL_ARGS          int
+ #define QT_SIGNAL_IGNORE        SIG_IGN
+ 
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+ #define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+ 
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+diff --git a/qtbase/mkspecs/features/mac/sdk.mk b/qtbase/mkspecs/features/mac/sdk.mk
+index f30b5830b4..a32ceacb6c 100644
+--- a/qtbase/mkspecs/features/mac/sdk.mk
++++ b/qtbase/mkspecs/features/mac/sdk.mk
+@@ -1,6 +1,6 @@
+ 
+ ifeq ($(QT_MAC_SDK_NO_VERSION_CHECK),)
+-    CHECK_SDK_COMMAND = /usr/bin/xcrun --sdk $(EXPORT_QMAKE_MAC_SDK) -show-sdk-version 2>&1
++    CHECK_SDK_COMMAND = /usr/bin/xcrun --sdk $(EXPORT_QMAKE_MAC_SDK) -show-sdk-version 2>/dev/null
+     CURRENT_MAC_SDK_VERSION := $(shell DEVELOPER_DIR=$(EXPORT_QMAKE_XCODE_DEVELOPER_PATH) $(CHECK_SDK_COMMAND))
+     ifneq ($(CURRENT_MAC_SDK_VERSION),$(EXPORT_QMAKE_MAC_SDK_VERSION))
+         # We don't want to complain about out of date SDK unless the target needs to be remade.
+diff --git a/qtbase/mkspecs/linux-clang/qplatformdefs.h b/qtbase/mkspecs/linux-clang/qplatformdefs.h
+index a818d973f0..c1ab72fbc6 100644
+--- a/qtbase/mkspecs/linux-clang/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-clang/qplatformdefs.h
+@@ -79,14 +79,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-g++/qplatformdefs.h b/qtbase/mkspecs/linux-g++/qplatformdefs.h
+index 13523f0702..4d2750d9ec 100644
+--- a/qtbase/mkspecs/linux-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-g++/qplatformdefs.h
+@@ -79,14 +79,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ < 2)
+-#define QT_SOCKLEN_T            int
+-#else
+-#define QT_SOCKLEN_T            socklen_t
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-llvm/qplatformdefs.h b/qtbase/mkspecs/linux-llvm/qplatformdefs.h
+index dc750ab1ef..d3cc39b47f 100644
+--- a/qtbase/mkspecs/linux-llvm/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-llvm/qplatformdefs.h
+@@ -80,14 +80,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h b/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
+index 4c4e53da2a..83baffb3e3 100644
+--- a/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
+@@ -85,16 +85,9 @@
+ #include "../common/posix/qplatformdefs.h"
+ 
+ #undef QT_OPEN_LARGEFILE
+-#undef QT_SOCKLEN_T
+ 
+ #define QT_OPEN_LARGEFILE       0
+ 
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #ifndef SIOCGIFBRDADDR
+ #  define SIOCGIFBRDADDR 0x8919
+ #endif
+diff --git a/qtbase/mkspecs/lynxos-g++/qplatformdefs.h b/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
+index 4339ea2b23..6007af0055 100644
+--- a/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
+@@ -72,14 +72,6 @@
+ 
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp b/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
+index c3c184258f..32af3f8f29 100644
+--- a/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
++++ b/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
+@@ -10,6 +10,7 @@
+ #include "libANGLE/HandleAllocator.h"
+ 
+ #include <algorithm>
++#include <limits>
+ 
+ #include "common/debug.h"
+ 
+diff --git a/qtbase/src/3rdparty/forkfd/forkfd_linux.c b/qtbase/src/3rdparty/forkfd/forkfd_linux.c
+index ffe0e9a5e2..b1f5408d11 100644
+--- a/qtbase/src/3rdparty/forkfd/forkfd_linux.c
++++ b/qtbase/src/3rdparty/forkfd/forkfd_linux.c
+@@ -82,7 +82,8 @@ static int sys_clone(unsigned long cloneflags, int *ptid)
+     return syscall(__NR_clone, cloneflags, child_stack, stack_size, ptid, newtls, ctid);
+ #elif defined(__arc__) || defined(__arm__) || defined(__aarch64__) || defined(__mips__) || \
+     defined(__nds32__) || defined(__hppa__) || defined(__powerpc__) || defined(__i386__) || \
+-    defined(__x86_64__) || defined(__xtensa__) || defined(__alpha__) || defined(__riscv)
++    defined(__x86_64__) || defined(__xtensa__) || defined(__alpha__) || defined(__riscv) || \
++    defined(__loongarch__)
+     /* ctid and newtls are inverted on CONFIG_CLONE_BACKWARDS architectures,
+      * but since both values are 0, there's no harm. */
+     return syscall(__NR_clone, cloneflags, child_stack, ptid, ctid, newtls);
+diff --git a/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java b/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
+index 5792b5b2f5..2f74750fcf 100644
+--- a/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
++++ b/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
+@@ -116,6 +116,7 @@ public class QtNative
+     public static QtThread m_qtThread = new QtThread();
+     private static HashMap<String, Uri> m_cachedUris = new HashMap<String, Uri>();
+     private static ArrayList<String> m_knownDirs = new ArrayList<String>();
++    private static final String NoPermissionErrorMessage = "No permissions to open Uri";
+ 
+     private static final Runnable runPendingCppRunnablesRunnable = new Runnable() {
+         @Override
+@@ -193,11 +194,10 @@ public class QtNative
+                     return iterUri;
+             }
+ 
+-            // Android 6 and earlier could still manage to open the file so we can return the
+-            // parsed uri here
+-            if (Build.VERSION.SDK_INT < 24)
+-                return parsedUri;
+-            return null;
++            // if we only have transient permissions on uri all the above will fail,
++            // but we will be able to read the file anyway, so continue with uri here anyway
++            // and check for SecurityExceptions later
++            return parsedUri;
+         } catch (SecurityException e) {
+             e.printStackTrace();
+             return null;
+@@ -244,7 +244,7 @@ public class QtNative
+         int error = -1;
+ 
+         if (uri == null) {
+-            Log.e(QtTAG, "openFdForContentUrl(): No permissions to open Uri");
++            Log.e(QtTAG, "openFdForContentUrl(): " + NoPermissionErrorMessage);
+             return error;
+         }
+ 
+@@ -254,12 +254,13 @@ public class QtNative
+             return fdDesc.detachFd();
+         } catch (FileNotFoundException e) {
+             e.printStackTrace();
+-            return error;
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "openFdForContentUrl(): Invalid Uri");
+             e.printStackTrace();
+-            return error;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return error;
+     }
+ 
+     public static long getSize(Context context, String contentUrl)
+@@ -270,7 +271,7 @@ public class QtNative
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+ 
+         if (uri == null) {
+-            Log.e(QtTAG, "getSize(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return size;
+         } else if (!m_cachedUris.containsKey(contentUrl)) {
+             m_cachedUris.put(contentUrl, uri);
+@@ -288,12 +289,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "getSize(): Invalid Uri");
+             e.printStackTrace();
+-            return size;
+         }  catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "getSize(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return size;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return size;
+     }
+ 
+     public static boolean checkFileExists(Context context, String contentUrl)
+@@ -303,7 +305,7 @@ public class QtNative
+         if (uri == null)
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+         if (uri == null) {
+-            Log.e(QtTAG, "checkFileExists(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return exists;
+         } else {
+             if (!m_cachedUris.containsKey(contentUrl))
+@@ -321,12 +323,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "checkFileExists(): Invalid Uri");
+             e.printStackTrace();
+-            return exists;
+         } catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "checkFileExists(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return false;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return exists;
+     }
+ 
+     public static boolean checkIfWritable(Context context, String contentUrl)
+@@ -344,7 +347,7 @@ public class QtNative
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+         }
+         if (uri == null) {
+-            Log.e(QtTAG, "isDir(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return isDir;
+         } else {
+             if (!m_cachedUris.containsKey(contentUrl))
+@@ -374,12 +377,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "checkIfDir(): Invalid Uri");
+             e.printStackTrace();
+-            return false;
+         } catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "checkIfDir(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return false;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return false;
+     }
+     public static String[] listContentsFromTreeUri(Context context, String contentUrl)
+     {
+diff --git a/qtbase/src/concurrent/qtconcurrentreducekernel.h b/qtbase/src/concurrent/qtconcurrentreducekernel.h
+index 8f9a938952..a98dedef2e 100644
+--- a/qtbase/src/concurrent/qtconcurrentreducekernel.h
++++ b/qtbase/src/concurrent/qtconcurrentreducekernel.h
+@@ -212,11 +212,13 @@ public:
+ 
+     inline bool shouldThrottle()
+     {
++        std::lock_guard<QMutex> locker(mutex);
+         return (resultsMapSize > (ReduceQueueThrottleLimit * threadCount));
+     }
+ 
+     inline bool shouldStartThread()
+     {
++        std::lock_guard<QMutex> locker(mutex);
+         return (resultsMapSize <= (ReduceQueueStartLimit * threadCount));
+     }
+ };
+diff --git a/qtbase/src/concurrent/qtconcurrentthreadengine.cpp b/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
+index ea6ce3ac42..7f91a2ba68 100644
+--- a/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
++++ b/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
+@@ -176,6 +176,39 @@ void ThreadEngineBase::startSingleThreaded()
+     finish();
+ }
+ 
++void ThreadEngineBase::startBlocking()
++{
++    start();
++    barrier.acquire();
++    startThreads();
++
++    bool throttled = false;
++#ifndef QT_NO_EXCEPTIONS
++    try {
++#endif
++        while (threadFunction() == ThrottleThread) {
++            if (threadThrottleExit()) {
++                throttled = true;
++                break;
++            }
++        }
++#ifndef QT_NO_EXCEPTIONS
++    } catch (QException &e) {
++        handleException(e);
++    } catch (...) {
++        handleException(QUnhandledException());
++    }
++#endif
++
++    if (throttled == false) {
++        barrier.release();
++    }
++
++    barrier.wait();
++    finish();
++    exceptionStore.throwPossibleException();
++}
++
+ void ThreadEngineBase::startThread()
+ {
+     startThreadInternal();
+diff --git a/qtbase/src/concurrent/qtconcurrentthreadengine.h b/qtbase/src/concurrent/qtconcurrentthreadengine.h
+index 7c30cebdbc..a4c8548cc4 100644
+--- a/qtbase/src/concurrent/qtconcurrentthreadengine.h
++++ b/qtbase/src/concurrent/qtconcurrentthreadengine.h
+@@ -91,6 +91,7 @@ public:
+     ThreadEngineBase();
+     virtual ~ThreadEngineBase();
+     void startSingleThreaded();
++    void startBlocking();
+     void startThread();
+     bool isCanceled();
+     void waitForResume();
+@@ -143,6 +144,15 @@ public:
+         return result();
+     }
+ 
++    // Runs the user algorithm using multiple threads.
++    // This function blocks until the algorithm is finished,
++    // and then returns the result.
++    T *startBlocking()
++    {
++        ThreadEngineBase::startBlocking();
++        return result();
++    }
++
+     // Runs the user algorithm using multiple threads.
+     // Does not block, returns a future.
+     QFuture<T> startAsynchronously()
+@@ -223,6 +233,13 @@ class ThreadEngineStarter : public ThreadEngineStarterBase<T>
+ public:
+     ThreadEngineStarter(TypedThreadEngine *eng)
+         : Base(eng) { }
++
++    T startBlocking()
++    {
++        T t = *this->threadEngine->startBlocking();
++        delete this->threadEngine;
++        return t;
++    }
+ };
+ 
+ // Full template specialization where T is void.
+@@ -232,6 +249,12 @@ class ThreadEngineStarter<void> : public ThreadEngineStarterBase<void>
+ public:
+     ThreadEngineStarter(ThreadEngine<void> *_threadEngine)
+         : ThreadEngineStarterBase<void>(_threadEngine) {}
++
++    void startBlocking()
++    {
++        this->threadEngine->startBlocking();
++        delete this->threadEngine;
++    }
+ };
+ 
+ //! [qtconcurrentthreadengine-1]
+diff --git a/qtbase/src/corelib/animation/qvariantanimation.cpp b/qtbase/src/corelib/animation/qvariantanimation.cpp
+index 98b02f0202..eac1524107 100644
+--- a/qtbase/src/corelib/animation/qvariantanimation.cpp
++++ b/qtbase/src/corelib/animation/qvariantanimation.cpp
+@@ -276,7 +276,9 @@ void QVariantAnimationPrivate::setCurrentValueForProgress(const qreal progress)
+ 
+     const qreal startProgress = currentInterval.start.first;
+     const qreal endProgress = currentInterval.end.first;
+-    const qreal localProgress = (progress - startProgress) / (endProgress - startProgress);
++    const qreal localProgress =
++            qIsNull(progress - startProgress) ? 0.0 // avoid 0/0 below
++            /* else */                        : (progress - startProgress) / (endProgress - startProgress);
+ 
+     QVariant ret = q->interpolated(currentInterval.start.second,
+                                    currentInterval.end.second,
+diff --git a/qtbase/src/corelib/global/qnamespace.h b/qtbase/src/corelib/global/qnamespace.h
+index ad4150b317..bf19b1627b 100644
+--- a/qtbase/src/corelib/global/qnamespace.h
++++ b/qtbase/src/corelib/global/qnamespace.h
+@@ -1864,7 +1864,7 @@ public:
+     QT_Q_ENUM(TimerType)
+     QT_Q_ENUM(ScrollPhase)
+     QT_Q_ENUM(MouseEventSource)
+-    QT_Q_FLAG(MouseEventFlag)
++    QT_Q_FLAG(MouseEventFlags)
+     QT_Q_ENUM(ChecksumType)
+     QT_Q_ENUM(HighDpiScaleFactorRoundingPolicy)
+     QT_Q_ENUM(TabFocusBehavior)
+diff --git a/qtbase/src/corelib/global/qrandom.cpp b/qtbase/src/corelib/global/qrandom.cpp
+index 10672c1f92..25f87c7e6a 100644
+--- a/qtbase/src/corelib/global/qrandom.cpp
++++ b/qtbase/src/corelib/global/qrandom.cpp
+@@ -383,7 +383,6 @@ struct QRandomGenerator::SystemAndGlobalGenerators
+ 
+         constexpr SystemAndGlobalGenerators g = {};
+         Q_UNUSED(g);
+-        Q_STATIC_ASSERT(std::is_literal_type<SystemAndGlobalGenerators>::value);
+ #endif
+     }
+ 
+diff --git a/qtbase/src/corelib/io/qbuffer.cpp b/qtbase/src/corelib/io/qbuffer.cpp
+index 595fcd2724..032c0ddd4b 100644
+--- a/qtbase/src/corelib/io/qbuffer.cpp
++++ b/qtbase/src/corelib/io/qbuffer.cpp
+@@ -41,6 +41,8 @@
+ #include <QtCore/qmetaobject.h>
+ #include "private/qiodevice_p.h"
+ 
++#include <limits>
++
+ QT_BEGIN_NAMESPACE
+ 
+ /** QBufferPrivate **/
+@@ -366,7 +368,9 @@ qint64 QBuffer::size() const
+ bool QBuffer::seek(qint64 pos)
+ {
+     Q_D(QBuffer);
+-    if (pos > d->buf->size() && isWritable()) {
++    const auto oldBufSize = d->buf->size();
++    constexpr qint64 MaxSeekPos = (std::numeric_limits<decltype(oldBufSize)>::max)();
++    if (pos <= MaxSeekPos && pos > oldBufSize && isWritable()) {
+         if (seek(d->buf->size())) {
+             const qint64 gapSize = pos - d->buf->size();
+             if (write(QByteArray(gapSize, 0)) != gapSize) {
+@@ -377,7 +381,7 @@ bool QBuffer::seek(qint64 pos)
+             return false;
+         }
+     } else if (pos > d->buf->size() || pos < 0) {
+-        qWarning("QBuffer::seek: Invalid pos: %d", int(pos));
++        qWarning("QBuffer::seek: Invalid pos: %lld", pos);
+         return false;
+     }
+     return QIODevice::seek(pos);
+diff --git a/qtbase/src/corelib/io/qfilesystemengine_win.cpp b/qtbase/src/corelib/io/qfilesystemengine_win.cpp
+index 81d3a71986..c86ed1f9b0 100644
+--- a/qtbase/src/corelib/io/qfilesystemengine_win.cpp
++++ b/qtbase/src/corelib/io/qfilesystemengine_win.cpp
+@@ -664,14 +664,14 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry)
+     return QFileSystemEntry(ret, QFileSystemEntry::FromInternalPath());
+ }
+ 
+-#if defined(Q_CC_MINGW) && WINVER < 0x0602 //  Windows 8 onwards
++#if defined(Q_CC_MINGW) && WINVER < 0x0602 && _WIN32_WINNT < _WIN32_WINNT_WIN8 //  Windows 8 onwards
+ 
+ typedef struct _FILE_ID_INFO {
+     ULONGLONG VolumeSerialNumber;
+     FILE_ID_128 FileId;
+ } FILE_ID_INFO, *PFILE_ID_INFO;
+ 
+-#endif // if defined (Q_CC_MINGW) && WINVER < 0x0602
++#endif // if defined(Q_CC_MINGW) && WINVER < 0x0602 && _WIN32_WINNT < _WIN32_WINNT_WIN8
+ 
+ // File ID for Windows up to version 7 and FAT32 drives
+ static inline QByteArray fileId(HANDLE handle)
+diff --git a/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp b/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
+index 94d9d06bcb..27e0b13b0b 100644
+--- a/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
++++ b/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
+@@ -366,7 +366,9 @@ void QInotifyFileSystemWatcherEngine::readFromInotify()
+     // qDebug("QInotifyFileSystemWatcherEngine::readFromInotify");
+ 
+     int buffSize = 0;
+-    ioctl(inotifyFd, FIONREAD, (char *) &buffSize);
++    if (ioctl(inotifyFd, FIONREAD, (char *) &buffSize) == -1 || buffSize == 0)
++        return;
++
+     QVarLengthArray<char, 4096> buffer(buffSize);
+     buffSize = read(inotifyFd, buffer.data(), buffSize);
+     char *at = buffer.data();
+diff --git a/qtbase/src/corelib/io/qlockfile_win.cpp b/qtbase/src/corelib/io/qlockfile_win.cpp
+index 277f8d4230..38ecef5550 100644
+--- a/qtbase/src/corelib/io/qlockfile_win.cpp
++++ b/qtbase/src/corelib/io/qlockfile_win.cpp
+@@ -48,6 +48,8 @@
+ #include "QtCore/qdebug.h"
+ #include "QtCore/qthread.h"
+ 
++#include "private/qsystemlibrary_p.h"
++
+ QT_BEGIN_NAMESPACE
+ 
+ static inline bool fileExists(const wchar_t *fileName)
+@@ -150,7 +152,7 @@ QString QLockFilePrivate::processNameByPid(qint64 pid)
+ #if !defined(Q_OS_WINRT)
+     typedef DWORD (WINAPI *GetModuleFileNameExFunc)(HANDLE, HMODULE, LPTSTR, DWORD);
+ 
+-    HMODULE hPsapi = LoadLibraryA("psapi");
++    HMODULE hPsapi = QSystemLibrary::load(L"psapi");
+     if (!hPsapi)
+         return QString();
+     GetModuleFileNameExFunc qGetModuleFileNameEx = reinterpret_cast<GetModuleFileNameExFunc>(
+diff --git a/qtbase/src/corelib/io/qprocess_unix.cpp b/qtbase/src/corelib/io/qprocess_unix.cpp
+index 50390e57f5..15c8f30745 100644
+--- a/qtbase/src/corelib/io/qprocess_unix.cpp
++++ b/qtbase/src/corelib/io/qprocess_unix.cpp
+@@ -1,7 +1,7 @@
+ /****************************************************************************
+ **
+ ** Copyright (C) 2016 The Qt Company Ltd.
+-** Copyright (C) 2016 Intel Corporation.
++** Copyright (C) 2022 Intel Corporation.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtCore module of the Qt Toolkit.
+@@ -422,14 +422,15 @@ void QProcessPrivate::startProcess()
+     // Add the program name to the argument list.
+     argv[0] = nullptr;
+     if (!program.contains(QLatin1Char('/'))) {
++        // findExecutable() returns its argument if it's an absolute path,
++        // otherwise it searches $PATH; returns empty if not found (we handle
++        // that case much later)
+         const QString &exeFilePath = QStandardPaths::findExecutable(program);
+-        if (!exeFilePath.isEmpty()) {
+-            const QByteArray &tmp = QFile::encodeName(exeFilePath);
+-            argv[0] = ::strdup(tmp.constData());
+-        }
+-    }
+-    if (!argv[0])
++        const QByteArray &tmp = QFile::encodeName(exeFilePath);
++        argv[0] = ::strdup(tmp.constData());
++    } else {
+         argv[0] = ::strdup(encodedProgramName.constData());
++    }
+ 
+     // Add every argument to the list
+     for (int i = 0; i < arguments.count(); ++i)
+@@ -983,15 +984,16 @@ bool QProcessPrivate::startDetached(qint64 *pid)
+                 envp = _q_dupEnvironment(environment.d.constData()->vars, &envc);
+             }
+ 
+-            QByteArray tmp;
+             if (!program.contains(QLatin1Char('/'))) {
++                // findExecutable() returns its argument if it's an absolute path,
++                // otherwise it searches $PATH; returns empty if not found (we handle
++                // that case much later)
+                 const QString &exeFilePath = QStandardPaths::findExecutable(program);
+-                if (!exeFilePath.isEmpty())
+-                    tmp = QFile::encodeName(exeFilePath);
++                const QByteArray &tmp = QFile::encodeName(exeFilePath);
++                argv[0] = ::strdup(tmp.constData());
++            } else {
++                argv[0] = ::strdup(QFile::encodeName(program));
+             }
+-            if (tmp.isEmpty())
+-                tmp = QFile::encodeName(program);
+-            argv[0] = tmp.data();
+ 
+             if (envp)
+                 qt_safe_execve(argv[0], argv, envp);
+diff --git a/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp b/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
+index 3a79c502af..997a634e76 100644
+--- a/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
++++ b/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
+@@ -3196,9 +3196,8 @@ bool QAbstractItemModel::beginMoveColumns(const QModelIndex &sourceParent, int s
+     destinationChange.needsAdjust = destinationParent.isValid() && destinationParent.row() >= sourceLast && destinationParent.parent() == sourceParent;
+     d->changes.push(destinationChange);
+ 
+-    d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Horizontal);
+-
+     emit columnsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, QPrivateSignal());
++    d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Horizontal);
+     return true;
+ }
+ 
+@@ -3231,7 +3230,6 @@ void QAbstractItemModel::endMoveColumns()
+       adjustedSource = createIndex(adjustedSource.row(), adjustedSource.column() + numMoved, adjustedSource.internalPointer());
+ 
+     d->itemsMoved(adjustedSource, removeChange.first, removeChange.last, adjustedDestination, insertChange.first, Qt::Horizontal);
+-
+     emit columnsMoved(adjustedSource, removeChange.first, removeChange.last, adjustedDestination, insertChange.first, QPrivateSignal());
+ }
+ 
+diff --git a/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+index dc6379d9fb..c5e287ee84 100644
+--- a/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
++++ b/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+@@ -939,8 +939,9 @@ void QSortFilterProxyModelPrivate::insert_source_items(
+                 q->beginInsertColumns(proxy_parent, proxy_start, proxy_end);
+         }
+ 
+-        for (int i = 0; i < source_items.size(); ++i)
+-            proxy_to_source.insert(proxy_start + i, source_items.at(i));
++        // TODO: use the range QList::insert() overload once it is implemented (QTBUG-58633).
++        proxy_to_source.insert(proxy_start, source_items.size(), 0);
++        std::copy(source_items.cbegin(), source_items.cend(), proxy_to_source.begin() + proxy_start);
+ 
+         build_source_to_proxy_mapping(proxy_to_source, source_to_proxy);
+ 
+@@ -3123,8 +3124,9 @@ bool QSortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex &
+ 
+     if (d->filter_data.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();
+@@ -3133,9 +3135,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.hasMatch(key);
+ }
+diff --git a/qtbase/src/corelib/kernel/qcoreapplication.cpp b/qtbase/src/corelib/kernel/qcoreapplication.cpp
+index ca2864df83..132b2eae52 100644
+--- a/qtbase/src/corelib/kernel/qcoreapplication.cpp
++++ b/qtbase/src/corelib/kernel/qcoreapplication.cpp
+@@ -1157,7 +1157,7 @@ static bool doNotify(QObject *receiver, QEvent *event)
+ bool QCoreApplicationPrivate::sendThroughApplicationEventFilters(QObject *receiver, QEvent *event)
+ {
+     // We can't access the application event filters outside of the main thread (race conditions)
+-    Q_ASSERT(receiver->d_func()->threadData.loadRelaxed()->thread.loadAcquire() == mainThread());
++    Q_ASSERT(receiver->d_func()->threadData.loadAcquire()->thread.loadRelaxed() == mainThread());
+ 
+     if (extraData) {
+         // application event filters are only called for objects in the GUI thread
+diff --git a/qtbase/src/corelib/kernel/qobject.cpp b/qtbase/src/corelib/kernel/qobject.cpp
+index 1eb79138d9..36cd780ee1 100644
+--- a/qtbase/src/corelib/kernel/qobject.cpp
++++ b/qtbase/src/corelib/kernel/qobject.cpp
+@@ -1010,7 +1010,7 @@ QObject::~QObject()
+         emit destroyed(this);
+     }
+ 
+-    if (d->declarativeData) {
++    if (!d->isDeletingChildren && d->declarativeData) {
+         if (static_cast<QAbstractDeclarativeDataImpl*>(d->declarativeData)->ownedByQml1) {
+             if (QAbstractDeclarativeData::destroyed_qml1)
+                 QAbstractDeclarativeData::destroyed_qml1(d->declarativeData, this);
+@@ -1580,7 +1580,7 @@ void QObject::moveToThread(QThread *targetThread)
+ 
+     QThreadData *currentData = QThreadData::current();
+     QThreadData *targetData = targetThread ? QThreadData::get2(targetThread) : nullptr;
+-    QThreadData *thisThreadData = d->threadData.loadRelaxed();
++    QThreadData *thisThreadData = d->threadData.loadAcquire();
+     if (!thisThreadData->thread.loadAcquire() && currentData == targetData) {
+         // one exception to the rule: we allow moving objects with no thread affinity to the current thread
+         currentData = d->threadData;
+@@ -2620,7 +2620,7 @@ int QObject::receivers(const char *signal) const
+         if (!d->isSignalConnected(signal_index))
+             return receivers;
+ 
+-        if (d->declarativeData && QAbstractDeclarativeData::receivers) {
++        if (!d->isDeletingChildren && d->declarativeData && QAbstractDeclarativeData::receivers) {
+             receivers += QAbstractDeclarativeData::receivers(d->declarativeData, this,
+                                                              signal_index);
+         }
+diff --git a/qtbase/src/corelib/kernel/qobject_p.h b/qtbase/src/corelib/kernel/qobject_p.h
+index 0b827a52ca..13ffb88999 100644
+--- a/qtbase/src/corelib/kernel/qobject_p.h
++++ b/qtbase/src/corelib/kernel/qobject_p.h
+@@ -444,7 +444,7 @@ inline void QObjectPrivate::checkForIncompatibleLibraryVersion(int version) cons
+ 
+ inline bool QObjectPrivate::isDeclarativeSignalConnected(uint signal_index) const
+ {
+-    return declarativeData && QAbstractDeclarativeData::isSignalConnected
++    return !isDeletingChildren && declarativeData && QAbstractDeclarativeData::isSignalConnected
+             && QAbstractDeclarativeData::isSignalConnected(declarativeData, q_func(), signal_index);
+ }
+ 
+diff --git a/qtbase/src/corelib/kernel/qtranslator.cpp b/qtbase/src/corelib/kernel/qtranslator.cpp
+index 2812ffb7ea..bc0177c5ec 100644
+--- a/qtbase/src/corelib/kernel/qtranslator.cpp
++++ b/qtbase/src/corelib/kernel/qtranslator.cpp
+@@ -902,7 +902,7 @@ static QString getMessage(const uchar *m, const uchar *end, const char *context,
+             goto end;
+         case Tag_Translation: {
+             int len = read32(m);
+-            if (len % 1)
++            if (len & 1)
+                 return QString();
+             m += 4;
+             if (!numerus--) {
+diff --git a/qtbase/src/corelib/mimetypes/qmimedatabase.cpp b/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
+index 9de22cef33..ff868a3268 100644
+--- a/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
+@@ -389,20 +389,23 @@ QMimeType QMimeDatabasePrivate::mimeTypeForFileNameAndData(const QString &fileNa
+         // Disambiguate conflicting extensions (if magic matching found something)
+         if (candidateByData.isValid() && magicAccuracy > 0) {
+             const QString sniffedMime = candidateByData.name();
+-            // If the sniffedMime matches a glob match, use it
++            // If the sniffedMime matches a highest-weight glob match, use it
+             if (candidatesByName.m_matchingMimeTypes.contains(sniffedMime)) {
+                 *accuracyPtr = 100;
+                 return candidateByData;
+             }
+-            for (const QString &m : qAsConst(candidatesByName.m_matchingMimeTypes)) {
++            for (const QString &m : qAsConst(candidatesByName.m_allMatchingMimeTypes)) {
+                 if (inherits(m, sniffedMime)) {
+                     // We have magic + pattern pointing to this, so it's a pretty good match
+                     *accuracyPtr = 100;
+                     return mimeTypeForName(m);
+                 }
+             }
+-            *accuracyPtr = magicAccuracy;
+-            return candidateByData;
++            if (candidatesByName.m_allMatchingMimeTypes.isEmpty()) {
++                // No glob, use magic
++                *accuracyPtr = magicAccuracy;
++                return candidateByData;
++            }
+         }
+     }
+ 
+diff --git a/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp b/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
+index a81112d227..fa8f4c545d 100644
+--- a/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
+@@ -83,7 +83,10 @@ void QMimeGlobMatchResult::addMatch(const QString &mimeType, int weight, const Q
+     }
+     if (!m_matchingMimeTypes.contains(mimeType)) {
+         m_matchingMimeTypes.append(mimeType);
+-        m_allMatchingMimeTypes.append(mimeType);
++        if (replace)
++            m_allMatchingMimeTypes.prepend(mimeType); // highest-weight first
++        else
++            m_allMatchingMimeTypes.append(mimeType);
+         m_knownSuffixLength = knownSuffixLength;
+     }
+ }
+@@ -94,7 +97,7 @@ QMimeGlobPattern::PatternType QMimeGlobPattern::detectPatternType(const QString
+     if (!patternLength)
+         return OtherPattern;
+ 
+-    const bool starCount = pattern.count(QLatin1Char('*')) == 1;
++    const int starCount = pattern.count(QLatin1Char('*'));
+     const bool hasSquareBracket = pattern.indexOf(QLatin1Char('[')) != -1;
+     const bool hasQuestionMark = pattern.indexOf(QLatin1Char('?')) != -1;
+ 
+@@ -106,10 +109,10 @@ QMimeGlobPattern::PatternType QMimeGlobPattern::detectPatternType(const QString
+             // Patterns like "README*" (well this is currently the only one like that...)
+             if (pattern.at(patternLength - 1) == QLatin1Char('*'))
+                 return PrefixPattern;
+-        }
+-        // Names without any wildcards like "README"
+-        if (starCount == 0)
++        } else if (starCount == 0) {
++            // Names without any wildcards like "README"
+             return LiteralPattern;
++        }
+     }
+ 
+     if (pattern == QLatin1String("[0-9][0-9][0-9].vdr"))
+diff --git a/qtbase/src/corelib/mimetypes/qmimeprovider.cpp b/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
+index 258dddf8cb..4642d0f2d0 100644
+--- a/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
+@@ -244,15 +244,18 @@ void QMimeBinaryProvider::addFileNameMatches(const QString &fileName, QMimeGlobM
+     const QString lowerFileName = fileName.toLower();
+     // Check literals (e.g. "Makefile")
+     matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosLiteralListOffset), fileName);
+-    // Check complex globs (e.g. "callgrind.out[0-9]*")
+-    matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosGlobListOffset), fileName);
+     // Check the very common *.txt cases with the suffix tree
+-    const int reverseSuffixTreeOffset = m_cacheFile->getUint32(PosReverseSuffixTreeOffset);
+-    const int numRoots = m_cacheFile->getUint32(reverseSuffixTreeOffset);
+-    const int firstRootOffset = m_cacheFile->getUint32(reverseSuffixTreeOffset + 4);
+-    matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, lowerFileName, lowerFileName.length() - 1, false);
++    if (result.m_matchingMimeTypes.isEmpty()) {
++        const int reverseSuffixTreeOffset = m_cacheFile->getUint32(PosReverseSuffixTreeOffset);
++        const int numRoots = m_cacheFile->getUint32(reverseSuffixTreeOffset);
++        const int firstRootOffset = m_cacheFile->getUint32(reverseSuffixTreeOffset + 4);
++        matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, lowerFileName, lowerFileName.length() - 1, false);
++        if (result.m_matchingMimeTypes.isEmpty())
++            matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, fileName, fileName.length() - 1, true);
++    }
++    // Check complex globs (e.g. "callgrind.out[0-9]*" or "README*")
+     if (result.m_matchingMimeTypes.isEmpty())
+-        matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, fileName, fileName.length() - 1, true);
++        matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosGlobListOffset), fileName);
+ }
+ 
+ void QMimeBinaryProvider::matchGlobList(QMimeGlobMatchResult &result, CacheFile *cacheFile, int off, const QString &fileName)
+diff --git a/qtbase/src/corelib/serialization/qjsonparser.cpp b/qtbase/src/corelib/serialization/qjsonparser.cpp
+index 17e6f111ab..2e40b6c8fb 100644
+--- a/qtbase/src/corelib/serialization/qjsonparser.cpp
++++ b/qtbase/src/corelib/serialization/qjsonparser.cpp
+@@ -379,10 +379,30 @@ error:
+     return QCborValue();
+ }
+ 
++// We need to retain the _last_ value for any duplicate keys and we need to deref containers.
++// Therefore the manual implementation of std::unique().
++template<typename Iterator, typename Compare, typename Assign>
++static Iterator customAssigningUniqueLast(Iterator first, Iterator last,
++                                          Compare compare, Assign assign)
++{
++    first = std::adjacent_find(first, last, compare);
++    if (first == last)
++        return last;
++
++    Iterator result = first;
++    while (++first != last) {
++        if (!compare(*result, *first))
++            ++result;
++        if (result != first)
++            assign(*result, *first);
++    }
++
++    return ++result;
++}
++
+ static void sortContainer(QCborContainerPrivate *container)
+ {
+     using Forward = QJsonPrivate::KeyIterator;
+-    using Reverse = std::reverse_iterator<Forward>;
+     using Value = Forward::value_type;
+ 
+     auto compare = [container](const Value &a, const Value &b)
+@@ -420,17 +440,31 @@ static void sortContainer(QCborContainerPrivate *container)
+         }
+     };
+ 
+-    std::sort(Forward(container->elements.begin()), Forward(container->elements.end()),
+-              [&compare](const Value &a, const Value &b) { return compare(a, b) < 0; });
++    // The elements' containers are owned by the outer container, not by the elements themselves.
++    auto move = [](Forward::reference target, Forward::reference source)
++    {
++        QtCbor::Element &targetValue = target.value();
++
++        // If the target has a container, deref it before overwriting, so that we don't leak.
++        if (targetValue.flags & QtCbor::Element::IsContainer)
++            targetValue.container->deref();
++
++        // Do not move, so that we can clear the value afterwards.
++        target = source;
++
++        // Clear the source value, so that we don't store the same container twice.
++        source.value() = QtCbor::Element();
++    };
++
++    std::stable_sort(
++                Forward(container->elements.begin()), Forward(container->elements.end()),
++                [&compare](const Value &a, const Value &b) { return compare(a, b) < 0; });
+ 
+-    // We need to retain the _last_ value for any duplicate keys. Therefore the reverse dance here.
+-    auto it = std::unique(Reverse(container->elements.end()), Reverse(container->elements.begin()),
+-                          [&compare](const Value &a, const Value &b) {
+-        return compare(a, b) == 0;
+-    }).base().elementsIterator();
++    Forward result = customAssigningUniqueLast(
++                Forward(container->elements.begin()),  Forward(container->elements.end()),
++                [&compare](const Value &a, const Value &b) { return compare(a, b) == 0; }, move);
+ 
+-    // The erase from beginning is expensive but hopefully rare.
+-    container->elements.erase(container->elements.begin(), it);
++    container->elements.erase(result.elementsIterator(), container->elements.end());
+ }
+ 
+ 
+diff --git a/qtbase/src/corelib/serialization/qxmlstream.cpp b/qtbase/src/corelib/serialization/qxmlstream.cpp
+index b2f846544d..7cd457ba3a 100644
+--- a/qtbase/src/corelib/serialization/qxmlstream.cpp
++++ b/qtbase/src/corelib/serialization/qxmlstream.cpp
+@@ -980,7 +980,7 @@ inline uint QXmlStreamReaderPrivate::peekChar()
+ bool QXmlStreamReaderPrivate::scanUntil(const char *str, short tokenToInject)
+ {
+     int pos = textBuffer.size();
+-    int oldLineNumber = lineNumber;
++    const auto oldLineNumber = lineNumber;
+ 
+     uint c;
+     while ((c = getChar()) != StreamEOF) {
+diff --git a/qtbase/src/corelib/text/qstring.cpp b/qtbase/src/corelib/text/qstring.cpp
+index 3e88ab4859..8deeae47bb 100644
+--- a/qtbase/src/corelib/text/qstring.cpp
++++ b/qtbase/src/corelib/text/qstring.cpp
+@@ -12312,7 +12312,7 @@ static qsizetype qLastIndexOf(Haystack haystack0, qsizetype from,
+     const auto needle = needle0.data();
+     const auto *end = haystack;
+     haystack += from;
+-    const std::size_t sl_minus_1 = sl - 1;
++    const std::size_t sl_minus_1 = sl ? sl - 1 : 0;
+     const auto *n = needle + sl_minus_1;
+     const auto *h = haystack + sl_minus_1;
+     std::size_t hashNeedle = 0, hashHaystack = 0;
+diff --git a/qtbase/src/corelib/text/qstringiterator_p.h b/qtbase/src/corelib/text/qstringiterator_p.h
+index 219589b6e4..1d0c66cc78 100644
+--- a/qtbase/src/corelib/text/qstringiterator_p.h
++++ b/qtbase/src/corelib/text/qstringiterator_p.h
+@@ -61,6 +61,8 @@ class QStringIterator
+ {
+     QString::const_iterator i, pos, e;
+     Q_STATIC_ASSERT((std::is_same<QString::const_iterator, const QChar *>::value));
++    static bool less(const QChar *lhs, const QChar *rhs) noexcept
++    { return std::less<QString::const_iterator>{}(lhs, rhs); }
+ public:
+     explicit QStringIterator(QStringView string, qsizetype idx = 0)
+         : i(string.begin()),
+@@ -95,7 +97,8 @@ public:
+ 
+     inline void setPosition(QString::const_iterator position)
+     {
+-        Q_ASSERT_X(i <= position && position <= e, Q_FUNC_INFO, "position out of bounds");
++        Q_ASSERT_X(!less(position, i) && !less(e, position),
++                   Q_FUNC_INFO, "position out of bounds");
+         pos = position;
+     }
+ 
+@@ -103,7 +106,7 @@ public:
+ 
+     inline bool hasNext() const
+     {
+-        return pos < e;
++        return less(pos, e);
+     }
+ 
+     inline void advance()
+@@ -120,16 +123,20 @@ public:
+     {
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+-        if (Q_UNLIKELY((pos++)->isHighSurrogate()))
++        if (Q_UNLIKELY((pos++)->isHighSurrogate())) {
++            Q_ASSERT(hasNext() && pos->isLowSurrogate());
+             ++pos;
++        }
+     }
+ 
+     inline uint peekNextUnchecked() const
+     {
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+-        if (Q_UNLIKELY(pos->isHighSurrogate()))
++        if (Q_UNLIKELY(pos->isHighSurrogate())) {
++            Q_ASSERT(less(pos + 1, e) && pos[1].isLowSurrogate());
+             return QChar::surrogateToUcs4(pos[0], pos[1]);
++        }
+ 
+         return pos->unicode();
+     }
+@@ -155,8 +162,10 @@ public:
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+         const QChar cur = *pos++;
+-        if (Q_UNLIKELY(cur.isHighSurrogate()))
++        if (Q_UNLIKELY(cur.isHighSurrogate())) {
++            Q_ASSERT(hasNext() && pos->isLowSurrogate());
+             return QChar::surrogateToUcs4(cur, *pos++);
++        }
+         return cur.unicode();
+     }
+ 
+@@ -166,7 +175,7 @@ public:
+ 
+         const QChar uc = *pos++;
+         if (Q_UNLIKELY(uc.isSurrogate())) {
+-            if (Q_LIKELY(uc.isHighSurrogate() && pos < e && pos->isLowSurrogate()))
++            if (Q_LIKELY(uc.isHighSurrogate() && hasNext() && pos->isLowSurrogate()))
+                 return QChar::surrogateToUcs4(uc, *pos++);
+             return invalidAs;
+         }
+@@ -178,7 +187,7 @@ public:
+ 
+     inline bool hasPrevious() const
+     {
+-        return pos > i;
++        return less(i, pos);
+     }
+ 
+     inline void recede()
+@@ -196,16 +205,20 @@ public:
+     {
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+-        if (Q_UNLIKELY((--pos)->isLowSurrogate()))
++        if (Q_UNLIKELY((--pos)->isLowSurrogate())) {
++            Q_ASSERT(hasPrevious() && pos[-1].isHighSurrogate());
+             --pos;
++        }
+     }
+ 
+     inline uint peekPreviousUnchecked() const
+     {
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+-        if (Q_UNLIKELY(pos[-1].isLowSurrogate()))
++        if (Q_UNLIKELY(pos[-1].isLowSurrogate())) {
++            Q_ASSERT(less(i + 1, pos) && pos[-2].isHighSurrogate());
+             return QChar::surrogateToUcs4(pos[-2], pos[-1]);
++        }
+         return pos[-1].unicode();
+     }
+ 
+@@ -230,8 +243,10 @@ public:
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+         const QChar cur = *--pos;
+-        if (Q_UNLIKELY(cur.isLowSurrogate()))
++        if (Q_UNLIKELY(cur.isLowSurrogate())) {
++            Q_ASSERT(hasPrevious() && pos[-1].isHighSurrogate());
+             return QChar::surrogateToUcs4(*--pos, cur);
++        }
+         return cur.unicode();
+     }
+ 
+@@ -241,7 +256,7 @@ public:
+ 
+         const QChar uc = *--pos;
+         if (Q_UNLIKELY(uc.isSurrogate())) {
+-            if (Q_LIKELY(uc.isLowSurrogate() && pos > i && pos[-1].isHighSurrogate()))
++            if (Q_LIKELY(uc.isLowSurrogate() && hasPrevious() && pos[-1].isHighSurrogate()))
+                 return QChar::surrogateToUcs4(*--pos, uc);
+             return invalidAs;
+         }
+diff --git a/qtbase/src/corelib/thread/qfutex_p.h b/qtbase/src/corelib/thread/qfutex_p.h
+index f287b752d7..e294537787 100644
+--- a/qtbase/src/corelib/thread/qfutex_p.h
++++ b/qtbase/src/corelib/thread/qfutex_p.h
+@@ -52,6 +52,7 @@
+ //
+ 
+ #include <qglobal.h>
++#include <QtCore/qtsan_impl.h>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -106,16 +107,13 @@ namespace QtLinuxFutex {
+     inline int _q_futex(int *addr, int op, int val, quintptr val2 = 0,
+                         int *addr2 = nullptr, int val3 = 0) noexcept
+     {
+-        // A futex call ensures total ordering on the futex words
+-        // (in either success or failure of the call). Instruct TSAN accordingly,
+-        // as TSAN does not understand the futex(2) syscall.
+-        _q_tsan_release(addr, addr2);
++        QtTsan::futexRelease(addr, addr2);
+ 
+         // we use __NR_futex because some libcs (like Android's bionic) don't
+         // provide SYS_futex etc.
+         int result = syscall(__NR_futex, addr, op | FUTEX_PRIVATE_FLAG, val, val2, addr2, val3);
+ 
+-        _q_tsan_acquire(addr, addr2);
++        QtTsan::futexAcquire(addr, addr2);
+ 
+         return result;
+     }
+diff --git a/qtbase/src/corelib/thread/qmutex.cpp b/qtbase/src/corelib/thread/qmutex.cpp
+index 310d1cb14f..7097122d8e 100644
+--- a/qtbase/src/corelib/thread/qmutex.cpp
++++ b/qtbase/src/corelib/thread/qmutex.cpp
+@@ -152,6 +152,7 @@ public:
+ 
+ /*!
+     \enum QMutex::RecursionMode
++    \obsolete Use QRecursiveMutex to create a recursive mutex.
+ 
+     \value Recursive  In this mode, a thread can lock the same mutex
+                       multiple times and the mutex won't be unlocked
+@@ -173,6 +174,7 @@ public:
+ 
+ /*!
+     Constructs a new mutex. The mutex is created in an unlocked state.
++    \obsolete Use QRecursiveMutex to create a recursive mutex.
+ 
+     If \a mode is QMutex::Recursive, a thread can lock the same mutex
+     multiple times and the mutex won't be unlocked until a
+@@ -197,7 +199,7 @@ QMutex::QMutex(RecursionMode mode)
+ QMutex::~QMutex()
+ {
+     QMutexData *d = d_ptr.loadRelaxed();
+-    if (isRecursive()) {
++    if (QBasicMutex::isRecursive()) {
+         delete static_cast<QRecursiveMutexPrivate *>(d);
+     } else if (d) {
+ #ifndef QT_LINUX_FUTEX
+diff --git a/qtbase/src/corelib/thread/qmutex.h b/qtbase/src/corelib/thread/qmutex.h
+index 73c9e00663..1bae573a03 100644
+--- a/qtbase/src/corelib/thread/qmutex.h
++++ b/qtbase/src/corelib/thread/qmutex.h
+@@ -42,6 +42,7 @@
+ 
+ #include <QtCore/qglobal.h>
+ #include <QtCore/qatomic.h>
++#include <QtCore/qtsan_impl.h>
+ #include <new>
+ 
+ #if __has_include(<chrono>)
+@@ -77,19 +78,37 @@ public:
+ 
+     // BasicLockable concept
+     inline void lock() QT_MUTEX_LOCK_NOEXCEPT {
++        QtTsan::mutexPreLock(this, 0u);
++
+         if (!fastTryLock())
+             lockInternal();
++
++        QtTsan::mutexPostLock(this, 0u, 0);
+     }
+ 
+     // BasicLockable concept
+     inline void unlock() noexcept {
+         Q_ASSERT(d_ptr.loadRelaxed()); //mutex must be locked
++
++        QtTsan::mutexPreUnlock(this, 0u);
++
+         if (!fastTryUnlock())
+             unlockInternal();
++
++        QtTsan::mutexPostUnlock(this, 0u);
+     }
+ 
+     bool tryLock() noexcept {
+-        return fastTryLock();
++        unsigned tsanFlags = QtTsan::TryLock;
++        QtTsan::mutexPreLock(this, tsanFlags);
++
++        const bool success = fastTryLock();
++
++        if (!success)
++            tsanFlags |= QtTsan::TryLockFailed;
++        QtTsan::mutexPostLock(this, tsanFlags, 0);
++
++        return success;
+     }
+ 
+     // Lockable concept
+@@ -134,8 +153,16 @@ public:
+ #else
+     QMutex() { d_ptr.storeRelaxed(nullptr); }
+ #endif
++#if QT_DEPRECATED_SINCE(5,15)
+     enum RecursionMode { NonRecursive, Recursive };
++    QT_DEPRECATED_VERSION_X(5, 15, "Use QRecursiveMutex instead of a recursive QMutex")
+     explicit QMutex(RecursionMode mode);
++
++    QT_DEPRECATED_VERSION_X(5, 15, "Use QRecursiveMutex instead of a recursive QMutex")
++    bool isRecursive() const noexcept
++    { return QBasicMutex::isRecursive(); }
++#endif
++
+     ~QMutex();
+ 
+     // BasicLockable concept
+@@ -166,9 +193,6 @@ public:
+     }
+ #endif
+ 
+-    bool isRecursive() const noexcept
+-    { return QBasicMutex::isRecursive(); }
+-
+ private:
+     Q_DISABLE_COPY(QMutex)
+     friend class QMutexLocker;
+diff --git a/qtbase/src/corelib/thread/qreadwritelock.cpp b/qtbase/src/corelib/thread/qreadwritelock.cpp
+index 8c28507d5a..9dd8503116 100644
+--- a/qtbase/src/corelib/thread/qreadwritelock.cpp
++++ b/qtbase/src/corelib/thread/qreadwritelock.cpp
+@@ -155,7 +155,7 @@ QReadWriteLock::QReadWriteLock(RecursionMode recursionMode)
+ */
+ QReadWriteLock::~QReadWriteLock()
+ {
+-    auto d = d_ptr.loadRelaxed();
++    auto d = d_ptr.loadAcquire();
+     if (isUncontendedLocked(d)) {
+         qWarning("QReadWriteLock: destroying locked QReadWriteLock");
+         return;
+@@ -445,7 +445,7 @@ void QReadWriteLock::unlock()
+ /*! \internal  Helper for QWaitCondition::wait */
+ QReadWriteLock::StateForWaitCondition QReadWriteLock::stateForWaitCondition() const
+ {
+-    QReadWriteLockPrivate *d = d_ptr.loadRelaxed();
++    QReadWriteLockPrivate *d = d_ptr.loadAcquire();
+     switch (quintptr(d) & StateMask) {
+     case StateLockedForRead: return LockedForRead;
+     case StateLockedForWrite: return LockedForWrite;
+@@ -453,6 +453,7 @@ QReadWriteLock::StateForWaitCondition QReadWriteLock::stateForWaitCondition() co
+ 
+     if (!d)
+         return Unlocked;
++    const auto lock = qt_scoped_lock(d->mutex);
+     if (d->writerCount > 1)
+         return RecursivelyLocked;
+     else if (d->writerCount == 1)
+diff --git a/qtbase/src/corelib/thread/qsemaphore.cpp b/qtbase/src/corelib/thread/qsemaphore.cpp
+index 1d01fc1b28..3ecdee3747 100644
+--- a/qtbase/src/corelib/thread/qsemaphore.cpp
++++ b/qtbase/src/corelib/thread/qsemaphore.cpp
+@@ -354,7 +354,12 @@ void QSemaphore::release(int n)
+         quintptr nn = unsigned(n);
+         if (futexHasWaiterCount)
+             nn |= quint64(nn) << 32;    // token count replicated in high word
+-        quintptr prevValue = u.fetchAndAddRelease(nn);
++        quintptr prevValue = u.loadRelaxed();
++        quintptr newValue;
++        do { // loop just to ensure the operations are done atomically
++            newValue = prevValue + nn;
++            newValue &= (futexNeedsWakeAllBit - 1);
++        } while (!u.testAndSetRelease(prevValue, newValue, prevValue));
+         if (futexNeedsWake(prevValue)) {
+ #ifdef FUTEX_OP
+             if (futexHasWaiterCount) {
+@@ -376,7 +381,6 @@ void QSemaphore::release(int n)
+                 quint32 oparg = 0;
+                 quint32 cmp = FUTEX_OP_CMP_NE;
+                 quint32 cmparg = 0;
+-                u.fetchAndAndRelease(futexNeedsWakeAllBit - 1);
+                 futexWakeOp(*futexLow32(&u), n, INT_MAX, *futexHigh32(&u), FUTEX_OP(op, oparg, cmp, cmparg));
+                 return;
+             }
+@@ -388,7 +392,6 @@ 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(futexNeedsWakeAllBit - 1);
+             if (futexHasWaiterCount) {
+                 futexWakeAll(*futexLow32(&u));
+                 futexWakeAll(*futexHigh32(&u));
+diff --git a/qtbase/src/corelib/thread/qthread_p.h b/qtbase/src/corelib/thread/qthread_p.h
+index b2d1628e6e..f32f6f0460 100644
+--- a/qtbase/src/corelib/thread/qthread_p.h
++++ b/qtbase/src/corelib/thread/qthread_p.h
+@@ -174,7 +174,7 @@ public:
+     int returnCode;
+ 
+     uint stackSize;
+-    QThread::Priority priority;
++    std::underlying_type<QThread::Priority>::type priority;
+ 
+     static QThread *threadForId(int id);
+ 
+@@ -213,6 +213,13 @@ public:
+             QCoreApplication::instance()->postEvent(q_ptr, new QEvent(QEvent::Quit));
+         }
+     }
++
++#ifndef Q_OS_INTEGRITY
++private:
++    // Used in QThread(Private)::start to avoid racy access to QObject::objectName,
++    // unset afterwards. On INTEGRITY we set the thread name before starting it.
++    QString objectName;
++#endif
+ };
+ 
+ #else // QT_CONFIG(thread)
+diff --git a/qtbase/src/corelib/thread/qthread_unix.cpp b/qtbase/src/corelib/thread/qthread_unix.cpp
+index 56a8e0a038..610117a640 100644
+--- a/qtbase/src/corelib/thread/qthread_unix.cpp
++++ b/qtbase/src/corelib/thread/qthread_unix.cpp
+@@ -169,8 +169,7 @@ static void set_thread_data(QThreadData *data)
+ 
+ static void clear_thread_data()
+ {
+-    currentThreadData = nullptr;
+-    pthread_setspecific(current_thread_data_key, nullptr);
++    set_thread_data(nullptr);
+ }
+ 
+ template <typename T>
+@@ -296,7 +295,7 @@ void *QThreadPrivate::start(void *arg)
+             QMutexLocker locker(&thr->d_func()->mutex);
+ 
+             // do we need to reset the thread priority?
+-            if (int(thr->d_func()->priority) & ThreadPriorityResetFlag) {
++            if (thr->d_func()->priority & ThreadPriorityResetFlag) {
+                 thr->d_func()->setPriority(QThread::Priority(thr->d_func()->priority & ~ThreadPriorityResetFlag));
+             }
+ 
+@@ -316,10 +315,10 @@ void *QThreadPrivate::start(void *arg)
+             // Sets the name of the current thread. We can only do this
+             // when the thread is starting, as we don't have a cross
+             // platform way of setting the name of an arbitrary thread.
+-            if (Q_LIKELY(thr->objectName().isEmpty()))
++            if (Q_LIKELY(thr->d_func()->objectName.isEmpty()))
+                 setCurrentThreadName(thr->metaObject()->className());
+             else
+-                setCurrentThreadName(thr->objectName().toLocal8Bit());
++                setCurrentThreadName(std::exchange(thr->d_func()->objectName, {}).toLocal8Bit());
+         }
+ #endif
+ 
+@@ -671,7 +670,7 @@ void QThread::start(Priority priority)
+                 // could not set scheduling hints, fallback to inheriting them
+                 // we'll try again from inside the thread
+                 pthread_attr_setinheritsched(&attr, PTHREAD_INHERIT_SCHED);
+-                d->priority = Priority(priority | ThreadPriorityResetFlag);
++                d->priority = static_cast<std::underlying_type<QThread::Priority>::type>(priority) | ThreadPriorityResetFlag;
+             }
+             break;
+         }
+@@ -702,7 +701,10 @@ void QThread::start(Priority priority)
+         pthread_attr_setthreadname(&attr, metaObject()->className());
+     else
+         pthread_attr_setthreadname(&attr, objectName().toLocal8Bit());
++#else
++    d->objectName = objectName();
+ #endif
++
+     pthread_t threadId;
+     int code = pthread_create(&threadId, &attr, QThreadPrivate::start, this);
+     if (code == EPERM) {
+diff --git a/qtbase/src/corelib/thread/qthread_win.cpp b/qtbase/src/corelib/thread/qthread_win.cpp
+index bc70e3178a..4e76972498 100644
+--- a/qtbase/src/corelib/thread/qthread_win.cpp
++++ b/qtbase/src/corelib/thread/qthread_win.cpp
+@@ -394,10 +394,9 @@ unsigned int __stdcall QT_ENSURE_STACK_ALIGNED_FOR_SSE QThreadPrivate::start(voi
+ 
+ #if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) && !defined(Q_OS_WINRT)
+     // sets the name of the current thread.
+-    QByteArray objectName = thr->objectName().toLocal8Bit();
+-    qt_set_thread_name(HANDLE(-1),
+-                       objectName.isEmpty() ?
+-                       thr->metaObject()->className() : objectName.constData());
++    qt_set_thread_name(HANDLE(-1), thr->d_func()->objectName.isEmpty()
++                        ? thr->metaObject()->className()
++                        : std::exchange(thr->d_func()->objectName, {}).toLocal8Bit().constData());
+ #endif
+ 
+     emit thr->started(QThread::QPrivateSignal());
+@@ -503,6 +502,7 @@ void QThread::start(Priority priority)
+     if (d->running)
+         return;
+ 
++    d->objectName = objectName();
+     d->running = true;
+     d->finished = false;
+     d->exited = false;
+@@ -548,7 +548,7 @@ void QThread::start(Priority priority)
+ 
+     int prio;
+     d->priority = priority;
+-    switch (d->priority) {
++    switch (priority) {
+     case IdlePriority:
+         prio = THREAD_PRIORITY_IDLE;
+         break;
+@@ -686,7 +686,7 @@ void QThreadPrivate::setPriority(QThread::Priority threadPriority)
+ 
+     int prio;
+     priority = threadPriority;
+-    switch (priority) {
++    switch (threadPriority) {
+     case QThread::IdlePriority:
+         prio = THREAD_PRIORITY_IDLE;
+         break;
+diff --git a/qtbase/src/corelib/thread/qtsan_impl.h b/qtbase/src/corelib/thread/qtsan_impl.h
+new file mode 100644
+index 0000000000..580a738b91
+--- /dev/null
++++ b/qtbase/src/corelib/thread/qtsan_impl.h
+@@ -0,0 +1,115 @@
++/****************************************************************************
++**
++** Copyright (C) 2017 Intel Corporation.
++** Copyright (C) 2022 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
++** 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 QTSAN_IMPL_H
++#define QTSAN_IMPL_H
++
++#include <QtCore/qglobal.h>
++
++#if (__has_feature(thread_sanitizer) || defined(__SANITIZE_THREAD__)) && __has_include(<sanitizer/tsan_interface.h>)
++#  define QT_BUILDING_UNDER_TSAN
++#  include <sanitizer/tsan_interface.h>
++#endif
++
++QT_BEGIN_NAMESPACE
++
++namespace QtTsan {
++#ifdef QT_BUILDING_UNDER_TSAN
++inline void futexAcquire(void *addr, void *addr2 = nullptr)
++{
++    // A futex call ensures total ordering on the futex words
++    // (in either success or failure of the call). Instruct TSAN accordingly,
++    // as TSAN does not understand the futex(2) syscall (or equivalent).
++    ::__tsan_acquire(addr);
++    if (addr2)
++        ::__tsan_acquire(addr2);
++}
++
++inline void futexRelease(void *addr, void *addr2 = nullptr)
++{
++    if (addr2)
++        ::__tsan_release(addr2);
++    ::__tsan_release(addr);
++}
++
++inline void mutexPreLock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_pre_lock(addr, flags);
++}
++
++inline void mutexPostLock(void *addr, unsigned flags, int recursion)
++{
++    ::__tsan_mutex_post_lock(addr, flags, recursion);
++}
++
++inline void mutexPreUnlock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_pre_unlock(addr, flags);
++}
++
++inline void mutexPostUnlock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_post_unlock(addr, flags);
++}
++
++enum : unsigned {
++    MutexWriteReentrant = ::__tsan_mutex_write_reentrant,
++    TryLock = ::__tsan_mutex_try_lock,
++    TryLockFailed = ::__tsan_mutex_try_lock_failed,
++};
++#else
++inline void futexAcquire(void *, void * = nullptr) {}
++inline void futexRelease(void *, void * = nullptr) {}
++
++enum : unsigned {
++    MutexWriteReentrant,
++    TryLock,
++    TryLockFailed,
++};
++inline void mutexPreLock(void *, unsigned) {}
++inline void mutexPostLock(void *, unsigned, int) {}
++inline void mutexPreUnlock(void *, unsigned) {}
++inline void mutexPostUnlock(void *, unsigned) {}
++#endif // QT_BUILDING_UNDER_TSAN
++} // namespace QtTsan
++
++QT_END_NAMESPACE
++
++#endif // QTSAN_IMPL_H
+diff --git a/qtbase/src/corelib/thread/qwaitcondition_unix.cpp b/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
+index 88b058f410..0f1da4dc9b 100644
+--- a/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
++++ b/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
+@@ -213,7 +213,7 @@ bool QWaitCondition::wait(QMutex *mutex, QDeadlineTimer deadline)
+ {
+     if (! mutex)
+         return false;
+-    if (mutex->isRecursive()) {
++    if (static_cast<QBasicMutex *>(mutex)->isRecursive()) {
+         qWarning("QWaitCondition: cannot wait on recursive mutexes");
+         return false;
+     }
+diff --git a/qtbase/src/corelib/time/qdatetime.cpp b/qtbase/src/corelib/time/qdatetime.cpp
+index ec12569e3f..2c0b098079 100644
+--- a/qtbase/src/corelib/time/qdatetime.cpp
++++ b/qtbase/src/corelib/time/qdatetime.cpp
+@@ -43,6 +43,7 @@
+ #if QT_CONFIG(datetimeparser)
+ #include "private/qdatetimeparser_p.h"
+ #endif
++#include <private/qnumeric_p.h>
+ 
+ #include "qdatastream.h"
+ #include "qset.h"
+@@ -1429,9 +1430,11 @@ QDate QDate::addDays(qint64 ndays) const
+     if (isNull())
+         return QDate();
+ 
+-    // Due to limits on minJd() and maxJd() we know that any overflow
+-    // will be invalid and caught by fromJulianDay().
+-    return fromJulianDay(jd + ndays);
++    qint64 r;
++    if (Q_UNLIKELY(add_overflow(jd, ndays, &r)))
++        return QDate();
++    else
++        return fromJulianDay(r);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/corelib/time/qtimezone.cpp b/qtbase/src/corelib/time/qtimezone.cpp
+index 0309e43e52..3d451696a1 100644
+--- a/qtbase/src/corelib/time/qtimezone.cpp
++++ b/qtbase/src/corelib/time/qtimezone.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2013 John Layt <jlayt@kde.org>
++** Copyright (C) 2020 John Layt <jlayt@kde.org>
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtCore module of the Qt Toolkit.
+@@ -975,9 +975,15 @@ QList<QByteArray> QTimeZone::windowsIdToIanaIds(const QByteArray &windowsId,
+ }
+ 
+ #ifndef QT_NO_DATASTREAM
++// Invalid, as an IANA ID: too long, starts with - and has other invalid characters in it
++static inline QString invalidId() { return QStringLiteral("-No Time Zone Specified!"); }
++
+ QDataStream &operator<<(QDataStream &ds, const QTimeZone &tz)
+ {
+-    tz.d->serialize(ds);
++    if (tz.isValid())
++        tz.d->serialize(ds);
++    else
++        ds << invalidId();
+     return ds;
+ }
+ 
+@@ -985,7 +991,9 @@ QDataStream &operator>>(QDataStream &ds, QTimeZone &tz)
+ {
+     QString ianaId;
+     ds >> ianaId;
+-    if (ianaId == QLatin1String("OffsetFromUtc")) {
++    if (ianaId == invalidId()) {
++        tz = QTimeZone();
++    } else if (ianaId == QLatin1String("OffsetFromUtc")) {
+         int utcOffset;
+         QString name;
+         QString abbreviation;
+diff --git a/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp b/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
+index b1611d7ddb..a7a6a72ccf 100644
+--- a/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
++++ b/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
+@@ -42,6 +42,7 @@
+ #include "qtimezone.h"
+ #include "qtimezoneprivate_p.h"
+ #include "private/qlocale_tools_p.h"
++#include "private/qlocking_p.h"
+ 
+ #include <QtCore/QDataStream>
+ #include <QtCore/QDateTime>
+@@ -62,6 +63,10 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++#if QT_CONFIG(icu)
++static QBasicMutex s_icu_mutex;
++#endif
++
+ /*
+     Private
+ 
+@@ -670,6 +675,9 @@ QTzTimeZonePrivate::~QTzTimeZonePrivate()
+ 
+ QTzTimeZonePrivate *QTzTimeZonePrivate::clone() const
+ {
++#if QT_CONFIG(icu)
++    const auto lock = qt_scoped_lock(s_icu_mutex);
++#endif
+     return new QTzTimeZonePrivate(*this);
+ }
+ 
+@@ -913,12 +921,14 @@ QString QTzTimeZonePrivate::displayName(qint64 atMSecsSinceEpoch,
+                                         const QLocale &locale) const
+ {
+ #if QT_CONFIG(icu)
++    auto lock = qt_unique_lock(s_icu_mutex);
+     if (!m_icu)
+         m_icu = new QIcuTimeZonePrivate(m_id);
+     // TODO small risk may not match if tran times differ due to outdated files
+     // TODO Some valid TZ names are not valid ICU names, use translation table?
+     if (m_icu->isValid())
+         return m_icu->displayName(atMSecsSinceEpoch, nameType, locale);
++    lock.unlock();
+ #else
+     Q_UNUSED(nameType)
+     Q_UNUSED(locale)
+@@ -932,12 +942,14 @@ QString QTzTimeZonePrivate::displayName(QTimeZone::TimeType timeType,
+                                         const QLocale &locale) const
+ {
+ #if QT_CONFIG(icu)
++    auto lock = qt_unique_lock(s_icu_mutex);
+     if (!m_icu)
+         m_icu = new QIcuTimeZonePrivate(m_id);
+     // TODO small risk may not match if tran times differ due to outdated files
+     // TODO Some valid TZ names are not valid ICU names, use translation table?
+     if (m_icu->isValid())
+         return m_icu->displayName(timeType, nameType, locale);
++    lock.unlock();
+ #else
+     Q_UNUSED(timeType)
+     Q_UNUSED(nameType)
+diff --git a/qtbase/src/corelib/tools/qarraydata.h b/qtbase/src/corelib/tools/qarraydata.h
+index dcd95924c1..d01739e7e6 100644
+--- a/qtbase/src/corelib/tools/qarraydata.h
++++ b/qtbase/src/corelib/tools/qarraydata.h
+@@ -42,6 +42,7 @@
+ 
+ #include <QtCore/qrefcount.h>
+ #include <string.h>
++#include <cstdint>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -58,14 +59,14 @@ struct Q_CORE_EXPORT QArrayData
+     {
+         Q_ASSERT(size == 0
+                 || offset < 0 || size_t(offset) >= sizeof(QArrayData));
+-        return reinterpret_cast<char *>(this) + offset;
++        return reinterpret_cast<void *> (reinterpret_cast<uintptr_t>(this) + offset);
+     }
+ 
+     const void *data() const
+     {
+         Q_ASSERT(size == 0
+                 || offset < 0 || size_t(offset) >= sizeof(QArrayData));
+-        return reinterpret_cast<const char *>(this) + offset;
++        return reinterpret_cast<void *> (reinterpret_cast<uintptr_t>(this) + offset);
+     }
+ 
+     // This refers to array data mutability, not "header data" represented by
+diff --git a/qtbase/src/corelib/tools/qfreelist_p.h b/qtbase/src/corelib/tools/qfreelist_p.h
+index 5ba23b344b..9974102136 100644
+--- a/qtbase/src/corelib/tools/qfreelist_p.h
++++ b/qtbase/src/corelib/tools/qfreelist_p.h
+@@ -161,7 +161,7 @@ class QFreeList
+                 return i;
+             x -= size;
+         }
+-        Q_ASSERT(false);
++        Q_UNREACHABLE();
+         return -1;
+     }
+ 
+diff --git a/qtbase/src/corelib/tools/qversionnumber.h b/qtbase/src/corelib/tools/qversionnumber.h
+index d43b86ba51..2843f2b043 100644
+--- a/qtbase/src/corelib/tools/qversionnumber.h
++++ b/qtbase/src/corelib/tools/qversionnumber.h
+@@ -273,10 +273,10 @@ public:
+ 
+     Q_REQUIRED_RESULT Q_CORE_EXPORT QString toString() const;
+ #if QT_STRINGVIEW_LEVEL < 2
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(const QString &string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(const QString &string, int *suffixIndex = nullptr);
+ #endif
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QLatin1String string, int *suffixIndex = nullptr);
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QStringView string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(QLatin1String string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(QStringView string, int *suffixIndex = nullptr);
+ 
+ private:
+ #ifndef QT_NO_DATASTREAM
+diff --git a/qtbase/src/dbus/qdbusintegrator.cpp b/qtbase/src/dbus/qdbusintegrator.cpp
+index 5b66ce971b..28a3b0ffea 100644
+--- a/qtbase/src/dbus/qdbusintegrator.cpp
++++ b/qtbase/src/dbus/qdbusintegrator.cpp
+@@ -1135,7 +1135,13 @@ void QDBusConnectionPrivate::closeConnection()
+         }
+     }
+ 
+-    qDeleteAll(pendingCalls);
++    for (auto it = pendingCalls.begin(); it != pendingCalls.end(); ++it) {
++        auto call = *it;
++        if (!call->ref.deref()) {
++            delete call;
++        }
++    }
++    pendingCalls.clear();
+ 
+     // Disconnect all signals from signal hooks and from the object tree to
+     // avoid QObject::destroyed being sent to dbus daemon thread which has
+@@ -2584,6 +2590,11 @@ QDBusConnectionPrivate::findMetaObject(const QString &service, const QString &pa
+         if (mo)
+             return mo;
+     }
++    if (path.isEmpty()) {
++        error = QDBusError(QDBusError::InvalidObjectPath, QLatin1String("Object path cannot be empty"));
++        lastError = error;
++        return nullptr;
++    }
+ 
+     // introspect the target object
+     QDBusMessage msg = QDBusMessage::createMethodCall(service, path,
+diff --git a/qtbase/src/dbus/qdbusmetaobject.cpp b/qtbase/src/dbus/qdbusmetaobject.cpp
+index 5265568f42..7e9f0f1acc 100644
+--- a/qtbase/src/dbus/qdbusmetaobject.cpp
++++ b/qtbase/src/dbus/qdbusmetaobject.cpp
+@@ -210,6 +210,9 @@ QDBusMetaObjectGenerator::findType(const QByteArray &signature,
+         } else if (signature == "a{ss}") {
+             result.name = "QMap<QString,QString>";
+             type = qMetaTypeId<QMap<QString, QString> >();
++        } else if (signature == "aay") {
++            result.name = "QByteArrayList";
++            type = qMetaTypeId<QByteArrayList>();
+         } else {
+             result.name = "{D-Bus type \"" + signature + "\"}";
+             type = registerComplexDBusType(result.name);
+diff --git a/qtbase/src/gui/accessible/qaccessible.cpp b/qtbase/src/gui/accessible/qaccessible.cpp
+index d705bfccb5..0caf3c808c 100644
+--- a/qtbase/src/gui/accessible/qaccessible.cpp
++++ b/qtbase/src/gui/accessible/qaccessible.cpp
+@@ -54,6 +54,7 @@
+ #include <QtCore/qdebug.h>
+ #include <QtCore/qloggingcategory.h>
+ #include <QtCore/qmetaobject.h>
++#include <QtCore/private/qmetaobject_p.h>
+ #include <QtCore/qhash.h>
+ #include <private/qfactoryloader_p.h>
+ 
+@@ -681,6 +682,25 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
+     // Create a QAccessibleInterface for the object class. Start by the most
+     // derived class and walk up the class hierarchy.
+     const QMetaObject *mo = object->metaObject();
++    const auto *objectPriv = QObjectPrivate::get(object);
++    /*
++     We do not want to cache each and every QML metaobject (Button_QMLTYPE_124,
++     Button_QMLTYPE_125, etc.). Those dynamic metaobjects shouldn't have an
++     accessible interface in any case. Instead, we start the whole checking
++     with the first non-dynamic meta-object. To avoid potential regressions
++     in other areas of Qt that also use dynamic metaobjects, we only do this
++     for objects that are QML-related (approximated by checking whether they
++     have ddata set).
++    */
++    const bool qmlRelated = !objectPriv->isDeletingChildren &&
++                            objectPriv->declarativeData;
++    while (qmlRelated && mo) {
++        auto mop = QMetaObjectPrivate::get(mo);
++        if (!mop || !(mop->flags & DynamicMetaObject))
++            break;
++
++        mo = mo->superClass();
++    };
+     while (mo) {
+         const QString cn = QLatin1String(mo->className());
+ 
+@@ -696,14 +716,15 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
+         // Find a QAccessiblePlugin (factory) for the class name. If there's
+         // no entry in the cache try to create it using the plugin loader.
+         if (!qAccessiblePlugins()->contains(cn)) {
++            QAccessiblePlugin *factory = nullptr; // 0 means "no plugin found". This is cached as well.
+             const int index = loader()->indexOf(cn);
+-            if (index != -1) {
+-                QAccessiblePlugin *factory = qobject_cast<QAccessiblePlugin *>(loader()->instance(index));
+-                qAccessiblePlugins()->insert(cn, factory);
+-            }
++            if (index != -1)
++                factory = qobject_cast<QAccessiblePlugin *>(loader()->instance(index));
++            qAccessiblePlugins()->insert(cn, factory);
+         }
+ 
+         // At this point the cache should contain a valid factory pointer or 0:
++        Q_ASSERT(qAccessiblePlugins()->contains(cn));
+         QAccessiblePlugin *factory = qAccessiblePlugins()->value(cn);
+         if (factory) {
+             QAccessibleInterface *result = factory->create(cn, object);
+diff --git a/qtbase/src/gui/configure.json b/qtbase/src/gui/configure.json
+index 1f08795c57..12c95742d2 100644
+--- a/qtbase/src/gui/configure.json
++++ b/qtbase/src/gui/configure.json
+@@ -834,7 +834,8 @@
+                     "// embedded devices, are not intended to be used together with X. EGL support",
+                     "// has to be disabled in plugins like xcb in this case since the native display,",
+                     "// window and pixmap types will be different than what an X-based platform",
+-                    "// plugin would expect."
++                    "// plugin would expect.",
++                    "#define USE_X11"
+                 ],
+                 "include": [ "EGL/egl.h", "X11/Xlib.h" ],
+                 "main": [
+diff --git a/qtbase/src/gui/image/qbmphandler.cpp b/qtbase/src/gui/image/qbmphandler.cpp
+index 96f1e8cb1d..0e73bbbdb0 100644
+--- a/qtbase/src/gui/image/qbmphandler.cpp
++++ b/qtbase/src/gui/image/qbmphandler.cpp
+@@ -150,16 +150,42 @@ static QDataStream &operator<<(QDataStream &s, const BMP_INFOHDR &bi)
+     return s;
+ }
+ 
+-static int calc_shift(uint mask)
++static uint calc_shift(uint mask)
+ {
+-    int result = 0;
+-    while (mask && !(mask & 1)) {
++    uint result = 0;
++    while ((mask >= 0x100) || (!(mask & 1) && mask)) {
+         result++;
+         mask >>= 1;
+     }
+     return result;
+ }
+ 
++static uint calc_scale(uint low_mask)
++{
++    uint result = 8;
++    while (low_mask && result) {
++        result--;
++        low_mask >>= 1;
++    }
++    return result;
++}
++
++static inline uint apply_scale(uint value, uint scale)
++{
++    if (!(scale & 0x07)) // return immediately if scale == 8 or 0
++        return value;
++
++    uint filled = 8 - scale;
++    uint result = value << scale;
++
++    do {
++        result |= result >> filled;
++        filled <<= 1;
++    } while (filled < 8);
++
++    return result;
++}
++
+ static bool read_dib_fileheader(QDataStream &s, BMP_FILEHDR &bf)
+ {
+     // read BMP file header
+@@ -222,14 +248,14 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+     uint green_mask = 0;
+     uint blue_mask = 0;
+     uint alpha_mask = 0;
+-    int red_shift = 0;
+-    int green_shift = 0;
+-    int blue_shift = 0;
+-    int alpha_shift = 0;
+-    int red_scale = 0;
+-    int green_scale = 0;
+-    int blue_scale = 0;
+-    int alpha_scale = 0;
++    uint red_shift = 0;
++    uint green_shift = 0;
++    uint blue_shift = 0;
++    uint alpha_shift = 0;
++    uint red_scale = 0;
++    uint green_scale = 0;
++    uint blue_scale = 0;
++    uint alpha_scale = 0;
+ 
+     if (!d->isSequential())
+         d->seek(startpos + BMP_FILEHDR_SIZE + bi.biSize); // goto start of colormap or masks
+@@ -308,19 +334,19 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+         red_shift = calc_shift(red_mask);
+         if (((red_mask >> red_shift) + 1) == 0)
+             return false;
+-        red_scale = 256 / ((red_mask >> red_shift) + 1);
++        red_scale = calc_scale(red_mask >> red_shift);
+         green_shift = calc_shift(green_mask);
+         if (((green_mask >> green_shift) + 1) == 0)
+             return false;
+-        green_scale = 256 / ((green_mask >> green_shift) + 1);
++        green_scale = calc_scale(green_mask >> green_shift);
+         blue_shift = calc_shift(blue_mask);
+         if (((blue_mask >> blue_shift) + 1) == 0)
+             return false;
+-        blue_scale = 256 / ((blue_mask >> blue_shift) + 1);
++        blue_scale = calc_scale(blue_mask >> blue_shift);
+         alpha_shift = calc_shift(alpha_mask);
+         if (((alpha_mask >> alpha_shift) + 1) == 0)
+             return false;
+-        alpha_scale = 256 / ((alpha_mask >> alpha_shift) + 1);
++        alpha_scale = calc_scale(alpha_mask >> alpha_shift);
+     } else if (comp == BMP_RGB && (nbits == 24 || nbits == 32)) {
+         blue_mask = 0x000000ff;
+         green_mask = 0x0000ff00;
+@@ -328,17 +354,15 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+         blue_shift = 0;
+         green_shift = 8;
+         red_shift = 16;
+-        blue_scale = green_scale = red_scale = 1;
++        blue_scale = green_scale = red_scale = 0;
+     } else if (comp == BMP_RGB && nbits == 16) {
+         blue_mask = 0x001f;
+         green_mask = 0x03e0;
+         red_mask = 0x7c00;
+         blue_shift = 0;
+-        green_shift = 2;
+-        red_shift = 7;
+-        red_scale = 1;
+-        green_scale = 1;
+-        blue_scale = 8;
++        green_shift = 5;
++        red_shift = 10;
++        blue_scale = green_scale = red_scale = 3;
+     }
+ 
+ #if 0
+@@ -544,10 +568,10 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+                     c |= *(uchar*)(b+2)<<16;
+                 if (nbits > 24)
+                     c |= *(uchar*)(b+3)<<24;
+-                *p++ = qRgba(((c & red_mask) >> red_shift) * red_scale,
+-                                        ((c & green_mask) >> green_shift) * green_scale,
+-                                        ((c & blue_mask) >> blue_shift) * blue_scale,
+-                                        transp ? ((c & alpha_mask) >> alpha_shift) * alpha_scale : 0xff);
++                *p++ = qRgba(apply_scale((c & red_mask) >> red_shift, red_scale),
++                             apply_scale((c & green_mask) >> green_shift, green_scale),
++                             apply_scale((c & blue_mask) >> blue_shift, blue_scale),
++                             transp ? apply_scale((c & alpha_mask) >> alpha_shift, alpha_scale) : 0xff);
+                 b += nbits/8;
+             }
+         }
+diff --git a/qtbase/src/gui/image/qimage.cpp b/qtbase/src/gui/image/qimage.cpp
+index 7152ac1607..0df772564c 100644
+--- a/qtbase/src/gui/image/qimage.cpp
++++ b/qtbase/src/gui/image/qimage.cpp
+@@ -4694,6 +4694,8 @@ QImage QImage::smoothScaled(int w, int h) const {
+ static QImage rotated90(const QImage &image)
+ {
+     QImage out(image.height(), image.width(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+@@ -4722,6 +4724,8 @@ static QImage rotated180(const QImage &image)
+         return image.mirrored(true, true);
+ 
+     QImage out(image.width(), image.height(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+@@ -4734,6 +4738,8 @@ static QImage rotated180(const QImage &image)
+ static QImage rotated270(const QImage &image)
+ {
+     QImage out(image.height(), image.width(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+diff --git a/qtbase/src/gui/kernel/qcursor.cpp b/qtbase/src/gui/kernel/qcursor.cpp
+index d6ccaff8ed..455088241c 100644
+--- a/qtbase/src/gui/kernel/qcursor.cpp
++++ b/qtbase/src/gui/kernel/qcursor.cpp
+@@ -251,7 +251,8 @@ void QCursor::setPos(QScreen *screen, int x, int y)
+ {
+     if (screen) {
+         if (QPlatformCursor *cursor = screen->handle()->cursor()) {
+-            const QPoint devicePos = QHighDpi::toNativePixels(QPoint(x, y), screen);
++            const QPoint pos(x, y);
++            const QPoint devicePos = QHighDpi::toNativePixels(pos, screen->virtualSiblingAt(pos));
+             // Need to check, since some X servers generate null mouse move
+             // events, causing looping in applications which call setPos() on
+             // every mouse move event.
+diff --git a/qtbase/src/gui/kernel/qhighdpiscaling.cpp b/qtbase/src/gui/kernel/qhighdpiscaling.cpp
+index 9bbf2773a9..3ac4a4d8b6 100644
+--- a/qtbase/src/gui/kernel/qhighdpiscaling.cpp
++++ b/qtbase/src/gui/kernel/qhighdpiscaling.cpp
+@@ -580,9 +580,8 @@ void QHighDpiScaling::setScreenFactor(QScreen *screen, qreal factor)
+     else
+         qNamedScreenScaleFactors()->insert(name, factor);
+ 
+-    // hack to force re-evaluation of screen geometry
+     if (screen->handle())
+-        screen->d_func()->setPlatformScreen(screen->handle()); // updates geometries based on scale factor
++        screen->d_func()->updateLogicalDpi();
+ }
+ 
+ QPoint QHighDpiScaling::mapPositionToNative(const QPoint &pos, const QPlatformScreen *platformScreen)
+diff --git a/qtbase/src/gui/kernel/qkeysequence.cpp b/qtbase/src/gui/kernel/qkeysequence.cpp
+index a75b8ef920..4f2d294739 100644
+--- a/qtbase/src/gui/kernel/qkeysequence.cpp
++++ b/qtbase/src/gui/kernel/qkeysequence.cpp
+@@ -701,6 +701,10 @@ static const struct {
+     { Qt::Key_TouchpadToggle,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad Toggle") },
+     { Qt::Key_TouchpadOn,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad On") },
+     { Qt::Key_TouchpadOff,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad Off") },
++    { Qt::Key_Shift,  QT_TRANSLATE_NOOP("QShortcut", "Shift") },
++    { Qt::Key_Control,  QT_TRANSLATE_NOOP("QShortcut", "Control") },
++    { Qt::Key_Alt,  QT_TRANSLATE_NOOP("QShortcut", "Alt") },
++    { Qt::Key_Meta,  QT_TRANSLATE_NOOP("QShortcut", "Meta") },
+ 
+ };
+ static Q_CONSTEXPR int numKeyNames = sizeof keyname / sizeof *keyname;
+diff --git a/qtbase/src/gui/kernel/qplatformservices.cpp b/qtbase/src/gui/kernel/qplatformservices.cpp
+index fdc6a6c4aa..ac47f98c5d 100644
+--- a/qtbase/src/gui/kernel/qplatformservices.cpp
++++ b/qtbase/src/gui/kernel/qplatformservices.cpp
+@@ -55,6 +55,19 @@ QT_BEGIN_NAMESPACE
+     \brief The QPlatformServices provides the backend for desktop-related functionality.
+ */
+ 
++/*!
++    \enum QPlatformServices::Capability
++
++    Capabilities are used to determine a specific platform service's availability.
++
++    \value ColorPickingFromScreen The platform natively supports color picking from screen.
++    This capability indicates that the platform supports "opaque" color picking, where the
++    platform implements a complete user experience for color picking and outputs a color.
++    This is in contrast to the application implementing the color picking user experience
++    (taking care of showing a cross hair, instructing the platform integration to obtain
++    the color at a given pixel, etc.). The related service function is pickColor().
++ */
++
+ QPlatformServices::QPlatformServices()
+ { }
+ 
+@@ -85,5 +98,16 @@ QByteArray QPlatformServices::desktopEnvironment() const
+     return QByteArray("UNKNOWN");
+ }
+ 
++QPlatformServiceColorPicker *QPlatformServices::colorPicker(QWindow *parent)
++{
++    Q_UNUSED(parent);
++    return nullptr;
++}
++
++bool QPlatformServices::hasCapability(Capability capability) const
++{
++    Q_UNUSED(capability)
++    return false;
++}
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/gui/kernel/qplatformservices.h b/qtbase/src/gui/kernel/qplatformservices.h
+index 5de96cfa7d..a8b2a4ce71 100644
+--- a/qtbase/src/gui/kernel/qplatformservices.h
++++ b/qtbase/src/gui/kernel/qplatformservices.h
+@@ -50,16 +50,32 @@
+ //
+ 
+ #include <QtGui/qtguiglobal.h>
++#include <QtCore/qobject.h>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+ class QUrl;
++class QWindow;
++
++class Q_GUI_EXPORT QPlatformServiceColorPicker : public QObject
++{
++    Q_OBJECT
++public:
++    using QObject::QObject;
++    virtual void pickColor() = 0;
++Q_SIGNALS:
++    void colorPicked(const QColor &color);
++};
+ 
+ class Q_GUI_EXPORT QPlatformServices
+ {
+ public:
+     Q_DISABLE_COPY_MOVE(QPlatformServices)
+ 
++    enum Capability {
++        ColorPicking,
++    };
++
+     QPlatformServices();
+     virtual ~QPlatformServices() { }
+ 
+@@ -67,6 +83,10 @@ public:
+     virtual bool openDocument(const QUrl &url);
+ 
+     virtual QByteArray desktopEnvironment() const;
++
++    virtual bool hasCapability(Capability capability) const;
++
++    virtual QPlatformServiceColorPicker *colorPicker(QWindow *parent = nullptr);
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/gui/kernel/qplatformtheme.cpp b/qtbase/src/gui/kernel/qplatformtheme.cpp
+index 71521c0339..2325873245 100644
+--- a/qtbase/src/gui/kernel/qplatformtheme.cpp
++++ b/qtbase/src/gui/kernel/qplatformtheme.cpp
+@@ -163,6 +163,8 @@ QT_BEGIN_NAMESPACE
+ 
+     \value ShowShortcutsInContextMenus (bool) Whether to display shortcut key sequences in context menus.
+ 
++    \value ButtonPressKeys (QList<Qt::Key>) A list of keys that can be used to press buttons via keyboard input.
++
+     \sa themeHint(), QStyle::pixelMetric()
+ */
+ 
+@@ -563,6 +565,8 @@ QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint)
+         }
+     case MouseQuickSelectionThreshold:
+         return QVariant(10);
++    case ButtonPressKeys:
++        return QVariant::fromValue(QList<Qt::Key>({ Qt::Key_Space, Qt::Key_Select }));
+     }
+     return QVariant();
+ }
+diff --git a/qtbase/src/gui/kernel/qplatformtheme.h b/qtbase/src/gui/kernel/qplatformtheme.h
+index 3185fc4541..7e6c9d5740 100644
+--- a/qtbase/src/gui/kernel/qplatformtheme.h
++++ b/qtbase/src/gui/kernel/qplatformtheme.h
+@@ -120,7 +120,8 @@ public:
+         TouchDoubleTapDistance,
+         ShowShortcutsInContextMenus,
+         IconFallbackSearchPaths,
+-        MouseQuickSelectionThreshold
++        MouseQuickSelectionThreshold,
++        ButtonPressKeys
+     };
+ 
+     enum DialogType {
+diff --git a/qtbase/src/gui/kernel/qscreen.cpp b/qtbase/src/gui/kernel/qscreen.cpp
+index 8e0eb35116..5d172a58dd 100644
+--- a/qtbase/src/gui/kernel/qscreen.cpp
++++ b/qtbase/src/gui/kernel/qscreen.cpp
+@@ -77,6 +77,12 @@ QScreen::QScreen(QPlatformScreen *screen)
+     d->setPlatformScreen(screen);
+ }
+ 
++void QScreenPrivate::updateLogicalDpi()
++{
++    logicalDpi = QPlatformScreen::overrideDpi(platformScreen->logicalDpi());
++    updateGeometriesWithSignals(); // updates geometries based on scale factor
++}
++
+ void QScreenPrivate::updateGeometriesWithSignals()
+ {
+     const QRect oldGeometry = geometry;
+diff --git a/qtbase/src/gui/kernel/qscreen_p.h b/qtbase/src/gui/kernel/qscreen_p.h
+index 7da542c25e..e50fc3190b 100644
+--- a/qtbase/src/gui/kernel/qscreen_p.h
++++ b/qtbase/src/gui/kernel/qscreen_p.h
+@@ -70,6 +70,7 @@ public:
+         geometry = platformScreen->deviceIndependentGeometry();
+         availableGeometry = QHighDpi::fromNative(platformScreen->availableGeometry(), QHighDpiScaling::factor(platformScreen), geometry.topLeft());
+     }
++    void updateLogicalDpi();
+ 
+     void updatePrimaryOrientation();
+     void updateGeometriesWithSignals();
+diff --git a/qtbase/src/gui/painting/qblendfunctions_p.h b/qtbase/src/gui/painting/qblendfunctions_p.h
+index 080da98ec4..6997d62b3c 100644
+--- a/qtbase/src/gui/painting/qblendfunctions_p.h
++++ b/qtbase/src/gui/painting/qblendfunctions_p.h
+@@ -246,25 +246,32 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+                                   int dudx, int dvdx, int dudy, int dvdy, int u0, int v0,
+                                   Blender blender)
+ {
+-    int fromY = qMax(qRound(topY), clip.top());
+-    int toY = qMin(qRound(bottomY), clip.top() + clip.height());
++    qint64 fromY = qMax(qRound(topY), clip.top());
++    qint64 toY = qMin(qRound(bottomY), clip.top() + clip.height());
+     if (fromY >= toY)
+         return;
+ 
+     qreal leftSlope = (bottomLeft.x - topLeft.x) / (bottomLeft.y - topLeft.y);
+     qreal rightSlope = (bottomRight.x - topRight.x) / (bottomRight.y - topRight.y);
+-    int dx_l = int(leftSlope * 0x10000);
+-    int dx_r = int(rightSlope * 0x10000);
+-    int x_l = int((topLeft.x + (qreal(0.5) + fromY - topLeft.y) * leftSlope + qreal(0.5)) * 0x10000);
+-    int x_r = int((topRight.x + (qreal(0.5) + fromY - topRight.y) * rightSlope + qreal(0.5)) * 0x10000);
+-
+-    int fromX, toX, x1, x2, u, v, i, ii;
++    qint64 dx_l = qint64(leftSlope * 0x10000);
++    qint64 dx_r = qint64(rightSlope * 0x10000);
++    qint64 x_l = qint64((topLeft.x + (qreal(0.5) + fromY - topLeft.y) * leftSlope + qreal(0.5)) * 0x10000);
++    qint64 x_r = qint64((topRight.x + (qreal(0.5) + fromY - topRight.y) * rightSlope + qreal(0.5)) * 0x10000);
++
++    qint64 sourceRectTop = qint64(sourceRect.top());
++    qint64 sourceRectLeft = qint64(sourceRect.left());
++    qint64 sourceRectWidth = qint64(sourceRect.width());
++    qint64 sourceRectHeight = qint64(sourceRect.height());
++    qint64 clipLeft = qint64(clip.left());
++    qint64 clipWidth = qint64(clip.width());
++
++    qint64 fromX, toX, x1, x2, u, v, i, ii;
+     DestT *line;
+-    for (int y = fromY; y < toY; ++y) {
++    for (qint64 y = fromY; y < toY; ++y) {
+         line = reinterpret_cast<DestT *>(reinterpret_cast<uchar *>(destPixels) + y * dbpl);
+ 
+-        fromX = qMax(x_l >> 16, clip.left());
+-        toX = qMin(x_r >> 16, clip.left() + clip.width());
++        fromX = qMax(x_l >> 16, clipLeft);
++        toX = qMin(x_r >> 16, clipLeft + clipWidth);
+         if (fromX < toX) {
+             // Because of rounding, we can get source coordinates outside the source image.
+             // Clamp these coordinates to the source rect to avoid segmentation fault and
+@@ -275,10 +282,10 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             u = x1 * dudx + y * dudy + u0;
+             v = x1 * dvdx + y * dvdy + v0;
+             for (; x1 < toX; ++x1) {
+-                int uu = u >> 16;
+-                int vv = v >> 16;
+-                if (uu >= sourceRect.left() && uu < sourceRect.left() + sourceRect.width()
+-                    && vv >= sourceRect.top() && vv < sourceRect.top() + sourceRect.height()) {
++                qint64 uu = u >> 16;
++                qint64 vv = v >> 16;
++                if (uu >= sourceRectLeft && uu < sourceRectLeft + sourceRectWidth
++                    && vv >= sourceRectTop && vv < sourceRectTop + sourceRectHeight) {
+                     break;
+                 }
+                 u += dudx;
+@@ -290,10 +297,10 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             u = (x2 - 1) * dudx + y * dudy + u0;
+             v = (x2 - 1) * dvdx + y * dvdy + v0;
+             for (; x2 > x1; --x2) {
+-                int uu = u >> 16;
+-                int vv = v >> 16;
+-                if (uu >= sourceRect.left() && uu < sourceRect.left() + sourceRect.width()
+-                    && vv >= sourceRect.top() && vv < sourceRect.top() + sourceRect.height()) {
++                qint64 uu = u >> 16;
++                qint64 vv = v >> 16;
++                if (uu >= sourceRectLeft && uu < sourceRectLeft + sourceRectWidth
++                    && vv >= sourceRectTop && vv < sourceRectTop + sourceRectHeight) {
+                     break;
+                 }
+                 u -= dudx;
+@@ -308,8 +315,8 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             // Beginning of the scan line, with per-pixel checks.
+             i = x1 - fromX;
+             while (i) {
+-                int uu = qBound(sourceRect.left(), u >> 16, sourceRect.left() + sourceRect.width() - 1);
+-                int vv = qBound(sourceRect.top(), v >> 16, sourceRect.top() + sourceRect.height() - 1);
++                qint64 uu = qBound(sourceRectLeft, u >> 16, sourceRectLeft + sourceRectWidth - 1);
++                qint64 vv = qBound(sourceRectTop, v >> 16, sourceRectTop + sourceRectHeight - 1);
+                 blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + vv * sbpl)[uu]);
+                 u += dudx;
+                 v += dvdx;
+@@ -348,8 +355,8 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             // End of the scan line, with per-pixel checks.
+             i = toX - x2;
+             while (i) {
+-                int uu = qBound(sourceRect.left(), u >> 16, sourceRect.left() + sourceRect.width() - 1);
+-                int vv = qBound(sourceRect.top(), v >> 16, sourceRect.top() + sourceRect.height() - 1);
++                qint64 uu = qBound(sourceRectLeft, u >> 16, sourceRectLeft + sourceRectWidth - 1);
++                qint64 vv = qBound(sourceRectTop, v >> 16, sourceRectTop + sourceRectHeight - 1);
+                 blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + vv * sbpl)[uu]);
+                 u += dudx;
+                 v += dvdx;
+diff --git a/qtbase/src/gui/painting/qcolortrclut_p.h b/qtbase/src/gui/painting/qcolortrclut_p.h
+index 76a6a60803..24fd522e6c 100644
+--- a/qtbase/src/gui/painting/qcolortrclut_p.h
++++ b/qtbase/src/gui/painting/qcolortrclut_p.h
+@@ -118,6 +118,7 @@ public:
+         return QRgba64::fromRgba64(r, g, b, qAlpha(rgb32) * 257);
+ #endif
+     }
++    QRgba64 toLinear64(QRgba64) const = delete;
+ 
+     QRgb toLinear(QRgb rgb32) const
+     {
+diff --git a/qtbase/src/gui/painting/qdrawhelper.cpp b/qtbase/src/gui/painting/qdrawhelper.cpp
+index a61793508a..5ba2d277b7 100644
+--- a/qtbase/src/gui/painting/qdrawhelper.cpp
++++ b/qtbase/src/gui/painting/qdrawhelper.cpp
+@@ -6091,7 +6091,7 @@ static inline void alphargbblend_argb32(quint32 *dst, uint coverage, const QRgba
+ static inline void rgbBlendPixel(QRgba64 &dst, int coverage, QRgba64 slinear, const QColorTrcLut *colorProfile)
+ {
+     // Do a gammacorrected RGB alphablend...
+-    const QRgba64 dlinear = colorProfile ? colorProfile->toLinear64(dst) : dst;
++    const QRgba64 dlinear = colorProfile ? colorProfile->toLinear(dst) : dst;
+ 
+     QRgba64 blend = rgbBlend(dlinear, slinear, coverage);
+ 
+diff --git a/qtbase/src/gui/painting/qpaintengine_raster.cpp b/qtbase/src/gui/painting/qpaintengine_raster.cpp
+index 283923de52..f08eb9cbee 100644
+--- a/qtbase/src/gui/painting/qpaintengine_raster.cpp
++++ b/qtbase/src/gui/painting/qpaintengine_raster.cpp
+@@ -560,31 +560,6 @@ void QRasterPaintEngine::updateMatrix(const QTransform &matrix)
+     QRasterPaintEngineState *s = state();
+     // FALCON: get rid of this line, see drawImage call below.
+     s->matrix = matrix;
+-    QTransform::TransformationType txop = s->matrix.type();
+-
+-    switch (txop) {
+-
+-    case QTransform::TxNone:
+-        s->flags.int_xform = true;
+-        break;
+-
+-    case QTransform::TxTranslate:
+-        s->flags.int_xform = qreal(int(s->matrix.dx())) == s->matrix.dx()
+-                            && qreal(int(s->matrix.dy())) == s->matrix.dy();
+-        break;
+-
+-    case QTransform::TxScale:
+-        s->flags.int_xform = qreal(int(s->matrix.dx())) == s->matrix.dx()
+-                            && qreal(int(s->matrix.dy())) == s->matrix.dy()
+-                            && qreal(int(s->matrix.m11())) == s->matrix.m11()
+-                            && qreal(int(s->matrix.m22())) == s->matrix.m22();
+-        break;
+-
+-    default: // shear / perspective...
+-        s->flags.int_xform = false;
+-        break;
+-    }
+-
+     s->flags.tx_noshear = qt_scaleForTransform(s->matrix, &s->txscale);
+ 
+     ensureOutlineMapper();
+@@ -617,7 +592,6 @@ QRasterPaintEngineState::QRasterPaintEngineState()
+     flags.bilinear = false;
+     flags.legacy_rounding = false;
+     flags.fast_text = true;
+-    flags.int_xform = true;
+     flags.tx_noshear = true;
+     flags.fast_images = true;
+ 
+@@ -1793,7 +1767,7 @@ void QRasterPaintEngine::fill(const QVectorPath &path, const QBrush &brush)
+     QRectF cpRect = path.controlPointRect();
+     const QRectF pathDeviceRect = s->matrix.mapRect(cpRect);
+     // Skip paths that by conservative estimates are completely outside the paint device.
+-    if (!pathDeviceRect.intersects(QRectF(d->deviceRect)))
++    if (!pathDeviceRect.intersects(QRectF(d->deviceRect)) || !pathDeviceRect.isValid())
+         return;
+ 
+     ProcessSpans blend = d->getBrushFunc(pathDeviceRect, &s->brushData);
+diff --git a/qtbase/src/gui/painting/qpaintengine_raster_p.h b/qtbase/src/gui/painting/qpaintengine_raster_p.h
+index 089aadc3f7..bf7363d5aa 100644
+--- a/qtbase/src/gui/painting/qpaintengine_raster_p.h
++++ b/qtbase/src/gui/painting/qpaintengine_raster_p.h
+@@ -111,7 +111,6 @@ public:
+         uint bilinear : 1;
+         uint legacy_rounding : 1;
+         uint fast_text : 1;
+-        uint int_xform : 1;
+         uint tx_noshear : 1;
+         uint fast_images : 1;
+     };
+diff --git a/qtbase/src/gui/painting/qpainterpath.cpp b/qtbase/src/gui/painting/qpainterpath.cpp
+index f9544a3241..d80fafeaf1 100644
+--- a/qtbase/src/gui/painting/qpainterpath.cpp
++++ b/qtbase/src/gui/painting/qpainterpath.cpp
+@@ -1253,7 +1253,7 @@ void QPainterPath::addText(const QPointF &point, const QFont &f, const QString &
+ 
+         if (si.analysis.flags < QScriptAnalysis::TabOrObject) {
+             QGlyphLayout glyphs = eng->shapedGlyphs(&si);
+-            QFontEngine *fe = f.d->engineForScript(si.analysis.script);
++            QFontEngine *fe = eng->fontEngine(si);
+             Q_ASSERT(fe);
+             fe->addOutlineToPath(x, y, glyphs, this,
+                                  si.analysis.bidiLevel % 2
+diff --git a/qtbase/src/gui/painting/qpathclipper_p.h b/qtbase/src/gui/painting/qpathclipper_p.h
+index 9444a87b71..18f64c5e8c 100644
+--- a/qtbase/src/gui/painting/qpathclipper_p.h
++++ b/qtbase/src/gui/painting/qpathclipper_p.h
+@@ -156,7 +156,7 @@ public:
+     int vertex(Direction direction) const;
+ 
+ private:
+-    int m_next[2][2];
++    int m_next[2][2] = { { -1, -1 }, { -1, -1 } };
+ };
+ 
+ class QPathSegments
+@@ -296,10 +296,6 @@ inline QPathEdge::QPathEdge(int a, int b)
+     , angle(0)
+     , invAngle(0)
+ {
+-    m_next[0][0] = -1;
+-    m_next[1][0] = -1;
+-    m_next[0][0] = -1;
+-    m_next[1][0] = -1;
+ }
+ 
+ inline int QPathEdge::next(Traversal traversal, Direction direction) const
+diff --git a/qtbase/src/gui/painting/qpdf.cpp b/qtbase/src/gui/painting/qpdf.cpp
+index 3066744f1b..2c8d3c3b53 100644
+--- a/qtbase/src/gui/painting/qpdf.cpp
++++ b/qtbase/src/gui/painting/qpdf.cpp
+@@ -2760,6 +2760,8 @@ int QPdfEnginePrivate::addBrushPattern(const QTransform &m, bool *specifyColor,
+         return gradientBrush(brush, matrix, gStateObject);
+     }
+ 
++    matrix = brush.transform() * matrix;
++
+     if ((!brush.isOpaque() && brush.style() < Qt::LinearGradientPattern) || opacity != 1.0)
+         *gStateObject = addConstantAlphaObject(qRound(brush.color().alpha() * opacity),
+                                                qRound(pen.color().alpha() * opacity));
+diff --git a/qtbase/src/gui/painting/qstroker.cpp b/qtbase/src/gui/painting/qstroker.cpp
+index cb5d395e80..3b6357a893 100644
+--- a/qtbase/src/gui/painting/qstroker.cpp
++++ b/qtbase/src/gui/painting/qstroker.cpp
+@@ -1182,6 +1182,7 @@ void QDashStroker::processCurrentSubpath()
+         // Check if the entire line should be clipped away or simplified
+         bool clipIt = clipping && !lineIntersectsRect(prev, e, clip_tl, clip_br);
+         bool skipDashing = elen * invSumLength > repetitionLimit();
++        int maxDashes = dashCount;
+         if (skipDashing || clipIt) {
+             // Cut away full dash sequences.
+             elen -= std::floor(elen * invSumLength) * sumLength;
+@@ -1196,7 +1197,7 @@ void QDashStroker::processCurrentSubpath()
+                     pos = estop; // move pos to next path element
+                     done = true;
+                 } else { // Dash is on this line
+-                    pos = dpos + estart;
++                    pos = --maxDashes > 0 ? dpos + estart : estop;
+                     done = pos >= estop;
+                     if (++idash >= dashCount)
+                         idash = 0;
+diff --git a/qtbase/src/gui/painting/qt_attribution.json b/qtbase/src/gui/painting/qt_attribution.json
+index 7b16e8c211..0e87d30aa2 100644
+--- a/qtbase/src/gui/painting/qt_attribution.json
++++ b/qtbase/src/gui/painting/qt_attribution.json
+@@ -10,7 +10,7 @@
+         "Homepage": "http://www.freetype.org",
+         "License": "Freetype Project License or GNU General Public License v2.0 only",
+         "LicenseId": "FTL or GPL-2.0",
+-        "LicenseFile": "../../3rdparty/freetype/docs/LICENSE.TXT",
++        "LicenseFile": "../../3rdparty/freetype/LICENSE.TXT",
+         "Copyright": "Copyright 2000-2016 by David Turner, Robert Wilhelm, and Werner Lemberg."
+     },
+     {
+diff --git a/qtbase/src/gui/rhi/qshader_p_p.h b/qtbase/src/gui/rhi/qshader_p_p.h
+index ec9d25971f..4a5a7a6d51 100644
+--- a/qtbase/src/gui/rhi/qshader_p_p.h
++++ b/qtbase/src/gui/rhi/qshader_p_p.h
+@@ -68,13 +68,13 @@ struct Q_GUI_EXPORT QShaderPrivate
+     {
+     }
+ 
+-    QShaderPrivate(const QShaderPrivate *other)
++    QShaderPrivate(const QShaderPrivate &other)
+         : ref(1),
+-          qsbVersion(other->qsbVersion),
+-          stage(other->stage),
+-          desc(other->desc),
+-          shaders(other->shaders),
+-          bindings(other->bindings)
++          qsbVersion(other.qsbVersion),
++          stage(other.stage),
++          desc(other.desc),
++          shaders(other.shaders),
++          bindings(other.bindings)
+     {
+     }
+ 
+diff --git a/qtbase/src/gui/rhi/qshaderdescription_p_p.h b/qtbase/src/gui/rhi/qshaderdescription_p_p.h
+index ec2b0b6b4c..3da33a8a2b 100644
+--- a/qtbase/src/gui/rhi/qshaderdescription_p_p.h
++++ b/qtbase/src/gui/rhi/qshaderdescription_p_p.h
+@@ -63,16 +63,16 @@ struct Q_GUI_EXPORT QShaderDescriptionPrivate
+         localSize[0] = localSize[1] = localSize[2] = 0;
+     }
+ 
+-    QShaderDescriptionPrivate(const QShaderDescriptionPrivate *other)
++    QShaderDescriptionPrivate(const QShaderDescriptionPrivate &other)
+         : ref(1),
+-          inVars(other->inVars),
+-          outVars(other->outVars),
+-          uniformBlocks(other->uniformBlocks),
+-          pushConstantBlocks(other->pushConstantBlocks),
+-          storageBlocks(other->storageBlocks),
+-          combinedImageSamplers(other->combinedImageSamplers),
+-          storageImages(other->storageImages),
+-          localSize(other->localSize)
++          inVars(other.inVars),
++          outVars(other.outVars),
++          uniformBlocks(other.uniformBlocks),
++          pushConstantBlocks(other.pushConstantBlocks),
++          storageBlocks(other.storageBlocks),
++          combinedImageSamplers(other.combinedImageSamplers),
++          storageImages(other.storageImages),
++          localSize(other.localSize)
+     {
+     }
+ 
+diff --git a/qtbase/src/gui/text/qfontdatabase.cpp b/qtbase/src/gui/text/qfontdatabase.cpp
+index a657a8c516..4fc0100958 100644
+--- a/qtbase/src/gui/text/qfontdatabase.cpp
++++ b/qtbase/src/gui/text/qfontdatabase.cpp
+@@ -983,7 +983,7 @@ QFontEngine *loadSingleEngine(int script,
+         if (style->key.stretch != 0 && request.stretch != 0
+             && (request.styleName.isEmpty() || request.styleName != style->styleName)) {
+             def.stretch = (request.stretch * 100 + style->key.stretch / 2) / style->key.stretch;
+-        } else {
++        } else if (request.stretch == QFont::AnyStretch) {
+             def.stretch = 100;
+         }
+ 
+diff --git a/qtbase/src/gui/text/qtextdocumentlayout.cpp b/qtbase/src/gui/text/qtextdocumentlayout.cpp
+index f3e6ea2100..72267e9380 100644
+--- a/qtbase/src/gui/text/qtextdocumentlayout.cpp
++++ b/qtbase/src/gui/text/qtextdocumentlayout.cpp
+@@ -2123,7 +2123,7 @@ void QTextDocumentLayoutPrivate::drawListItem(const QPointF &offset, QPainter *p
+ {
+     Q_Q(const QTextDocumentLayout);
+     const QTextBlockFormat blockFormat = bl.blockFormat();
+-    const QTextCharFormat charFormat = QTextCursor(bl).charFormat();
++    const QTextCharFormat charFormat = bl.charFormat();
+     QFont font(charFormat.font());
+     if (q->paintDevice())
+         font = QFont(font, q->paintDevice());
+diff --git a/qtbase/src/gui/text/qtextengine.cpp b/qtbase/src/gui/text/qtextengine.cpp
+index ce4abac472..a6c66e5d2d 100644
+--- a/qtbase/src/gui/text/qtextengine.cpp
++++ b/qtbase/src/gui/text/qtextengine.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2021 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtGui module of the Qt Toolkit.
+@@ -1565,6 +1565,12 @@ void QTextEngine::shapeText(int item) const
+         // Overwrite with 0 token to indicate failure
+         QGlyphLayout g = availableGlyphs(&si);
+         g.glyphs[0] = 0;
++        g.attributes[0].clusterStart = true;
++
++        ushort *log_clusters = logClusters(&si);
++        for (int i = 0; i < itemLength; ++i)
++            log_clusters[i] = 0;
++
+         return;
+     }
+ 
+diff --git a/qtbase/src/gui/util/qdesktopservices.cpp b/qtbase/src/gui/util/qdesktopservices.cpp
+index fbb63a9408..4d5fafaaa7 100644
+--- a/qtbase/src/gui/util/qdesktopservices.cpp
++++ b/qtbase/src/gui/util/qdesktopservices.cpp
+@@ -54,6 +54,8 @@
+ #include <qpa/qplatformintegration.h>
+ #include <qdir.h>
+ 
++#include <QtCore/private/qlocking_p.h>
++
+ QT_BEGIN_NAMESPACE
+ 
+ class QOpenUrlHandlerRegistry : public QObject
+@@ -81,6 +83,7 @@ Q_GLOBAL_STATIC(QOpenUrlHandlerRegistry, handlerRegistry)
+ 
+ void QOpenUrlHandlerRegistry::handlerDestroyed(QObject *handler)
+ {
++    const auto lock = qt_scoped_lock(mutex);
+     HandlerHash::Iterator it = handlers.begin();
+     while (it != handlers.end()) {
+         if (it->receiver == handler) {
+@@ -294,7 +297,8 @@ void QDesktopServices::setUrlHandler(const QString &scheme, QObject *receiver, c
+     h.name = method;
+     registry->handlers.insert(scheme.toLower(), h);
+     QObject::connect(receiver, SIGNAL(destroyed(QObject*)),
+-                     registry, SLOT(handlerDestroyed(QObject*)));
++                     registry, SLOT(handlerDestroyed(QObject*)),
++                     Qt::DirectConnection);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/gui/util/qpkmhandler.cpp b/qtbase/src/gui/util/qpkmhandler.cpp
+index e0c3b75efe..3414f9d8ba 100644
+--- a/qtbase/src/gui/util/qpkmhandler.cpp
++++ b/qtbase/src/gui/util/qpkmhandler.cpp
+@@ -57,7 +57,7 @@ struct PkmType
+     quint32 bytesPerBlock;
+ };
+ 
+-static PkmType typeMap[5] = {
++static constexpr PkmType typeMap[5] = {
+     { 0x8D64,  8 },   // GL_ETC1_RGB8_OES
+     { 0x9274,  8 },   // GL_COMPRESSED_RGB8_ETC2
+     { 0, 0 },         // unused (obsolete)
+diff --git a/qtbase/src/network/access/qnetworkreplyfileimpl.cpp b/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
+index b6be93147a..6e69b4c4d3 100644
+--- a/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
++++ b/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
+@@ -89,9 +89,10 @@ QNetworkReplyFileImpl::QNetworkReplyFileImpl(QNetworkAccessManager *manager, con
+         // we handle only local files
+         QString msg = QCoreApplication::translate("QNetworkAccessFileBackend", "Request for opening non-local file %1").arg(url.toString());
+         setError(QNetworkReply::ProtocolInvalidOperationError, msg);
++        setFinished(true); // We're finished, will emit finished() after ctor is done.
+         QMetaObject::invokeMethod(this, "errorOccurred", Qt::QueuedConnection,
+             Q_ARG(QNetworkReply::NetworkError, QNetworkReply::ProtocolInvalidOperationError));
+-        fileOpenFinished(false);
++        QMetaObject::invokeMethod(this, [this](){ fileOpenFinished(false); }, Qt::QueuedConnection);
+         return;
+     }
+ #endif
+diff --git a/qtbase/src/network/access/qnetworkreplyimpl.cpp b/qtbase/src/network/access/qnetworkreplyimpl.cpp
+index bcdf6ee2f1..3b6deb82bd 100644
+--- a/qtbase/src/network/access/qnetworkreplyimpl.cpp
++++ b/qtbase/src/network/access/qnetworkreplyimpl.cpp
+@@ -680,7 +680,7 @@ void QNetworkReplyImplPrivate::appendDownstreamData(QIODevice *data)
+     // read until EOF from data
+     if (Q_UNLIKELY(copyDevice)) {
+         qCritical("QNetworkReplyImpl: copy from QIODevice already in progress -- "
+-                  "backend probly needs to be fixed");
++                  "backend probably needs to be fixed");
+         return;
+     }
+ 
+diff --git a/qtbase/src/network/kernel/qauthenticator.cpp b/qtbase/src/network/kernel/qauthenticator.cpp
+index d9fe7bc47b..ccd04b294a 100644
+--- a/qtbase/src/network/kernel/qauthenticator.cpp
++++ b/qtbase/src/network/kernel/qauthenticator.cpp
+@@ -50,6 +50,7 @@
+ #include <qstring.h>
+ #include <qdatetime.h>
+ #include <qrandom.h>
++#include "private/qsystemlibrary_p.h"
+ 
+ #ifdef Q_OS_WIN
+ #include <qmutex.h>
+@@ -1563,7 +1564,7 @@ static bool q_SSPI_library_load()
+ 
+     // Initialize security interface
+     if (pSecurityFunctionTable == nullptr) {
+-        securityDLLHandle = LoadLibrary(L"secur32.dll");
++        securityDLLHandle = QSystemLibrary::load(L"secur32");
+         if (securityDLLHandle != nullptr) {
+             INIT_SECURITY_INTERFACE pInitSecurityInterface =
+                 reinterpret_cast<INIT_SECURITY_INTERFACE>(
+diff --git a/qtbase/src/network/kernel/qhostinfo_unix.cpp b/qtbase/src/network/kernel/qhostinfo_unix.cpp
+index 9b0a2ee669..73679c9ef1 100644
+--- a/qtbase/src/network/kernel/qhostinfo_unix.cpp
++++ b/qtbase/src/network/kernel/qhostinfo_unix.cpp
+@@ -122,7 +122,6 @@ static QFunctionPointer resolveSymbol(QLibrary &lib, const char *sym)
+ 
+ LibResolv::LibResolv()
+ {
+-    QLibrary lib;
+ #ifdef LIBRESOLV_SO
+     lib.setFileName(QStringLiteral(LIBRESOLV_SO));
+     if (!lib.load())
+diff --git a/qtbase/src/network/socket/qsocks5socketengine.cpp b/qtbase/src/network/socket/qsocks5socketengine.cpp
+index 3a046fd116..97fadca0b3 100644
+--- a/qtbase/src/network/socket/qsocks5socketengine.cpp
++++ b/qtbase/src/network/socket/qsocks5socketengine.cpp
+@@ -1296,7 +1296,7 @@ void QSocks5SocketEnginePrivate::_q_udpSocketReadNotification()
+         int pos = 0;
+         const char *buf = inBuf.constData();
+         if (inBuf.size() < 4) {
+-            QSOCKS5_D_DEBUG << "bugus udp data, discarding";
++            QSOCKS5_D_DEBUG << "bogus udp data, discarding";
+             return;
+         }
+         QSocks5RevivedDatagram datagram;
+diff --git a/qtbase/src/network/ssl/qsslcontext_openssl.cpp b/qtbase/src/network/ssl/qsslcontext_openssl.cpp
+index c9f202f573..c992da9d8e 100644
+--- a/qtbase/src/network/ssl/qsslcontext_openssl.cpp
++++ b/qtbase/src/network/ssl/qsslcontext_openssl.cpp
+@@ -409,7 +409,7 @@ init_context:
+         break;
+     case QSsl::DtlsV1_0OrLater:
+         minVersion = DTLS1_VERSION;
+-        maxVersion = DTLS_MAX_VERSION;
++        maxVersion = 0;
+         break;
+     case QSsl::DtlsV1_2:
+         minVersion = DTLS1_2_VERSION;
+@@ -417,7 +417,7 @@ init_context:
+         break;
+     case QSsl::DtlsV1_2OrLater:
+         minVersion = DTLS1_2_VERSION;
+-        maxVersion = DTLS_MAX_VERSION;
++        maxVersion = 0;
+         break;
+     case QSsl::TlsV1_3OrLater:
+ #ifdef TLS1_3_VERSION
+@@ -455,7 +455,7 @@ init_context:
+     }
+ 
+     // Enable bug workarounds.
+-    long options = QSslSocketBackendPrivate::setupOpenSslOptions(configuration.protocol(), configuration.d->sslOptions);
++    qssloptions options = QSslSocketBackendPrivate::setupOpenSslOptions(configuration.protocol(), configuration.d->sslOptions);
+     q_SSL_CTX_set_options(sslContext->ctx, options);
+ 
+     // Tell OpenSSL to release memory early
+diff --git a/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp b/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
+index aaf8741130..b58935372c 100644
+--- a/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
++++ b/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
+@@ -59,57 +59,6 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-#ifdef OPENSSL_NO_DEPRECATED_3_0
+-
+-static int q_DH_check(DH *dh, int *status)
+-{
+-    // DH_check was first deprecated in OpenSSL 3.0.0, as low-level
+-    // API; the EVP_PKEY family of functions was advised as an alternative.
+-    // As of now EVP_PKEY_params_check ends up calling ... DH_check,
+-    // which is good enough.
+-
+-    Q_ASSERT(dh);
+-    Q_ASSERT(status);
+-
+-    EVP_PKEY *key = q_EVP_PKEY_new();
+-    if (!key) {
+-        qCWarning(lcSsl, "EVP_PKEY_new failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-    const auto keyDeleter = qScopeGuard([key](){
+-        q_EVP_PKEY_free(key);
+-    });
+-    if (!q_EVP_PKEY_set1_DH(key, dh)) {
+-        qCWarning(lcSsl, "EVP_PKEY_set1_DH failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-
+-    EVP_PKEY_CTX *keyCtx = q_EVP_PKEY_CTX_new(key, nullptr);
+-    if (!keyCtx) {
+-        qCWarning(lcSsl, "EVP_PKEY_CTX_new failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-    const auto ctxDeleter = qScopeGuard([keyCtx]{
+-        q_EVP_PKEY_CTX_free(keyCtx);
+-    });
+-
+-    const int result = q_EVP_PKEY_param_check(keyCtx);
+-    QSslSocketBackendPrivate::logAndClearErrorQueue();
+-    // Note: unlike DH_check, we cannot obtain the 'status',
+-    // if the 'result' is 0 (actually the result is 1 only
+-    // if this 'status' was 0). We could probably check the
+-    // errors from the error queue, but it's not needed anyway
+-    // - see the 'isSafeDH' below, how it returns immediately
+-    // on 0.
+-    Q_UNUSED(status)
+-
+-    return result;
+-}
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+-
+ static bool isSafeDH(DH *dh)
+ {
+     int status = 0;
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl.cpp b/qtbase/src/network/ssl/qsslsocket_openssl.cpp
+index 37fad2a68f..8f6858c867 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl.cpp
++++ b/qtbase/src/network/ssl/qsslsocket_openssl.cpp
+@@ -550,9 +550,9 @@ static void q_loadCiphersForConnection(SSL *connection, QList<QSslCipher> &ciphe
+ // Defined in qsslsocket.cpp
+ void q_setDefaultDtlsCiphers(const QList<QSslCipher> &ciphers);
+ 
+-long QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions)
++qssloptions QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions)
+ {
+-    long options;
++    qssloptions options;
+     if (protocol == QSsl::TlsV1SslV3)
+         options = SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3;
+     else if (protocol == QSsl::SecureProtocols)
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_p.h b/qtbase/src/network/ssl/qsslsocket_openssl_p.h
+index 4103de23e8..5547589256 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_p.h
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_p.h
+@@ -107,6 +107,12 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++typedef uint64_t qssloptions;
++#else
++typedef unsigned long qssloptions;
++#endif
++
+ struct QSslErrorEntry {
+     int code;
+     int depth;
+@@ -171,7 +177,7 @@ public:
+     QVector<QSslError> ocspErrors;
+     QByteArray ocspResponseDer;
+ 
+-    Q_AUTOTEST_EXPORT static long setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions);
++    Q_AUTOTEST_EXPORT static qssloptions setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions);
+     static QSslCipher QSslCipher_from_SSL_CIPHER(const SSL_CIPHER *cipher);
+     static QList<QSslCertificate> STACKOFX509_to_QSslCertificates(STACK_OF(X509) *x509);
+     static QList<QSslError> verify(const QList<QSslCertificate> &certificateChain, const QString &hostName);
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp b/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
+index e53fb279f0..459ccd0b19 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
+@@ -148,7 +148,6 @@ DEFINEFUNC(int, EVP_PKEY_up_ref, EVP_PKEY *a, a, return 0, return)
+ DEFINEFUNC2(EVP_PKEY_CTX *, EVP_PKEY_CTX_new, EVP_PKEY *pkey, pkey, ENGINE *e, e, return nullptr, return)
+ DEFINEFUNC(int, EVP_PKEY_param_check, EVP_PKEY_CTX *ctx, ctx, return 0, return)
+ DEFINEFUNC(void, EVP_PKEY_CTX_free, EVP_PKEY_CTX *ctx, ctx, return, return)
+-DEFINEFUNC(int, EVP_PKEY_base_id, EVP_PKEY *a, a, return NID_undef, return)
+ DEFINEFUNC(int, RSA_bits, RSA *a, a, return 0, return)
+ DEFINEFUNC(int, DSA_bits, DSA *a, a, return 0, return)
+ DEFINEFUNC(int, OPENSSL_sk_num, OPENSSL_STACK *a, a, return -1, return)
+@@ -158,7 +157,7 @@ DEFINEFUNC2(void, OPENSSL_sk_push, OPENSSL_STACK *a, a, void *b, b, return, DUMM
+ DEFINEFUNC(void, OPENSSL_sk_free, OPENSSL_STACK *a, a, return, DUMMYARG)
+ DEFINEFUNC2(void *, OPENSSL_sk_value, OPENSSL_STACK *a, a, int b, b, return nullptr, return)
+ DEFINEFUNC(int, SSL_session_reused, SSL *a, a, return 0, return)
+-DEFINEFUNC2(unsigned long, SSL_CTX_set_options, SSL_CTX *ctx, ctx, unsigned long op, op, return 0, return)
++DEFINEFUNC2(qssloptions, SSL_CTX_set_options, SSL_CTX *ctx, ctx, qssloptions op, op, return 0, return)
+ DEFINEFUNC(int, SSL_CTX_get_security_level, const SSL_CTX *ctx, ctx, return -1, return)
+ DEFINEFUNC2(void, SSL_CTX_set_security_level, SSL_CTX *ctx, ctx, int level, level, return, return)
+ #ifdef TLS1_3_VERSION
+@@ -371,7 +370,15 @@ DEFINEFUNC(const SSL_CIPHER *, SSL_get_current_cipher, SSL *a, a, return nullptr
+ DEFINEFUNC(int, SSL_version, const SSL *a, a, return 0, return)
+ DEFINEFUNC2(int, SSL_get_error, SSL *a, a, int b, b, return -1, return)
+ DEFINEFUNC(STACK_OF(X509) *, SSL_get_peer_cert_chain, SSL *a, a, return nullptr, return)
++
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++DEFINEFUNC(X509 *, SSL_get1_peer_certificate, SSL *a, a, return nullptr, return)
++DEFINEFUNC(int, EVP_PKEY_get_base_id, const EVP_PKEY *pkey, pkey, return -1, return)
++#else
+ DEFINEFUNC(X509 *, SSL_get_peer_certificate, SSL *a, a, return nullptr, return)
++DEFINEFUNC(int, EVP_PKEY_base_id, EVP_PKEY *a, a, return NID_undef, return)
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+ DEFINEFUNC(long, SSL_get_verify_result, const SSL *a, a, return -1, return)
+ DEFINEFUNC(SSL *, SSL_new, SSL_CTX *a, a, return nullptr, return)
+ DEFINEFUNC(SSL_CTX *, SSL_get_SSL_CTX, SSL *a, a, return nullptr, return)
+@@ -492,9 +499,7 @@ DEFINEFUNC(DH *, DH_new, DUMMYARG, DUMMYARG, return nullptr, return)
+ DEFINEFUNC(void, DH_free, DH *dh, dh, return, DUMMYARG)
+ DEFINEFUNC3(DH *, d2i_DHparams, DH**a, a, const unsigned char **pp, pp, long length, length, return nullptr, return)
+ DEFINEFUNC2(int, i2d_DHparams, DH *a, a, unsigned char **p, p, return -1, return)
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+ DEFINEFUNC2(int, DH_check, DH *dh, dh, int *codes, codes, return 0, return)
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+ DEFINEFUNC3(BIGNUM *, BN_bin2bn, const unsigned char *s, s, int len, len, BIGNUM *ret, ret, return nullptr, return)
+ 
+ #ifndef OPENSSL_NO_EC
+@@ -868,7 +873,6 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(EVP_PKEY_CTX_new)
+     RESOLVEFUNC(EVP_PKEY_param_check)
+     RESOLVEFUNC(EVP_PKEY_CTX_free)
+-    RESOLVEFUNC(EVP_PKEY_base_id)
+     RESOLVEFUNC(RSA_bits)
+     RESOLVEFUNC(OPENSSL_sk_new_null)
+     RESOLVEFUNC(OPENSSL_sk_push)
+@@ -1107,7 +1111,15 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(SSL_version)
+     RESOLVEFUNC(SSL_get_error)
+     RESOLVEFUNC(SSL_get_peer_cert_chain)
++
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++    RESOLVEFUNC(SSL_get1_peer_certificate)
++    RESOLVEFUNC(EVP_PKEY_get_base_id)
++#else
+     RESOLVEFUNC(SSL_get_peer_certificate)
++    RESOLVEFUNC(EVP_PKEY_base_id)
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+     RESOLVEFUNC(SSL_get_verify_result)
+     RESOLVEFUNC(SSL_new)
+     RESOLVEFUNC(SSL_get_SSL_CTX)
+@@ -1206,9 +1218,7 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(DH_free)
+     RESOLVEFUNC(d2i_DHparams)
+     RESOLVEFUNC(i2d_DHparams)
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+     RESOLVEFUNC(DH_check)
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+     RESOLVEFUNC(BN_bin2bn)
+ 
+ #ifndef OPENSSL_NO_EC
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h b/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
+index 95e8897a3b..27aeffa18a 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
+@@ -237,7 +237,6 @@ Q_AUTOTEST_EXPORT int q_EVP_PKEY_up_ref(EVP_PKEY *a);
+ EVP_PKEY_CTX *q_EVP_PKEY_CTX_new(EVP_PKEY *pkey, ENGINE *e);
+ void q_EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx);
+ int q_EVP_PKEY_param_check(EVP_PKEY_CTX *ctx);
+-int q_EVP_PKEY_base_id(EVP_PKEY *a);
+ int q_RSA_bits(RSA *a);
+ Q_AUTOTEST_EXPORT int q_OPENSSL_sk_num(OPENSSL_STACK *a);
+ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_pop_free(OPENSSL_STACK *a, void (*b)(void *));
+@@ -246,7 +245,7 @@ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_push(OPENSSL_STACK *st, void *data);
+ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_free(OPENSSL_STACK *a);
+ Q_AUTOTEST_EXPORT void * q_OPENSSL_sk_value(OPENSSL_STACK *a, int b);
+ int q_SSL_session_reused(SSL *a);
+-unsigned long q_SSL_CTX_set_options(SSL_CTX *ctx, unsigned long op);
++qssloptions q_SSL_CTX_set_options(SSL_CTX *ctx, qssloptions op);
+ int q_OPENSSL_init_ssl(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings);
+ size_t q_SSL_get_client_random(SSL *a, unsigned char *out, size_t outlen);
+ size_t q_SSL_SESSION_get_master_key(const SSL_SESSION *session, unsigned char *out, size_t outlen);
+@@ -510,7 +509,6 @@ const SSL_CIPHER *q_SSL_get_current_cipher(SSL *a);
+ int q_SSL_version(const SSL *a);
+ int q_SSL_get_error(SSL *a, int b);
+ STACK_OF(X509) *q_SSL_get_peer_cert_chain(SSL *a);
+-X509 *q_SSL_get_peer_certificate(SSL *a);
+ long q_SSL_get_verify_result(const SSL *a);
+ SSL *q_SSL_new(SSL_CTX *a);
+ SSL_CTX *q_SSL_get_SSL_CTX(SSL *a);
+@@ -582,10 +580,7 @@ DH *q_DH_new();
+ void q_DH_free(DH *dh);
+ DH *q_d2i_DHparams(DH **a, const unsigned char **pp, long length);
+ int q_i2d_DHparams(DH *a, unsigned char **p);
+-
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+ int q_DH_check(DH *dh, int *codes);
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+ 
+ BIGNUM *q_BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret);
+ #define q_SSL_CTX_set_tmp_dh(ctx, dh) q_SSL_CTX_ctrl((ctx), SSL_CTRL_SET_TMP_DH, 0, (char *)dh)
+@@ -754,6 +749,17 @@ void q_CRYPTO_free(void *str, const char *file, int line);
+ int q_SSL_CTX_get_security_level(const SSL_CTX *ctx);
+ void q_SSL_CTX_set_security_level(SSL_CTX *ctx, int level);
+ 
++// Here we have the ones that make difference between OpenSSL pre/post v3:
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++X509 *q_SSL_get1_peer_certificate(SSL *a);
++#define q_SSL_get_peer_certificate q_SSL_get1_peer_certificate
++int q_EVP_PKEY_get_base_id(const EVP_PKEY *pkey);
++#define q_EVP_PKEY_base_id q_EVP_PKEY_get_base_id
++#else
++X509 *q_SSL_get_peer_certificate(SSL *a);
++int q_EVP_PKEY_base_id(EVP_PKEY *a);
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+ QT_END_NAMESPACE
+ 
+ #endif
+diff --git a/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h b/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
+index bf37d07fd8..dbd42fb799 100644
+--- a/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
++++ b/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
+@@ -61,7 +61,11 @@
+ # if !defined(Q_OS_INTEGRITY)
+ #  define WIN_INTERFACE_CUSTOM   // NV
+ # endif // Q_OS_INTEGRITY
+-#endif  // QT_EGL_NO_X11
++#else // QT_EGL_NO_X11
++// If one has an eglplatform.h with https://github.com/KhronosGroup/EGL-Registry/pull/130
++// that needs USE_X11 to be defined.
++# define USE_X11
++#endif
+ 
+ #ifdef QT_EGL_WAYLAND
+ # define WAYLAND // NV
+diff --git a/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+index 159b490ce0..00aa80cd58 100644
+--- a/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
++++ b/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+@@ -567,6 +567,8 @@ void QFontconfigDatabase::populateFontDatabase()
+         fonts = FcFontList(nullptr, pattern, os);
+         FcObjectSetDestroy(os);
+         FcPatternDestroy(pattern);
++        if (!fonts)
++            return;
+     }
+ 
+     for (int i = 0; i < fonts->nfont; i++)
+diff --git a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
+index b713c19447..7cb9a8c79a 100644
+--- a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
++++ b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
+@@ -95,6 +95,7 @@ static constexpr const auto KeyTbl = qMakeArray(
+         Xkb2Qt<XKB_KEY_Clear,                   Qt::Key_Delete>,
+         Xkb2Qt<XKB_KEY_Pause,                   Qt::Key_Pause>,
+         Xkb2Qt<XKB_KEY_Print,                   Qt::Key_Print>,
++        Xkb2Qt<XKB_KEY_Sys_Req,                 Qt::Key_SysReq>,
+         Xkb2Qt<0x1005FF60,                      Qt::Key_SysReq>,         // hardcoded Sun SysReq
+         Xkb2Qt<0x1007ff00,                      Qt::Key_SysReq>,         // hardcoded X386 SysReq
+ 
+@@ -471,7 +472,7 @@ QVector<xkb_keysym_t> QXkbCommon::toKeysym(QKeyEvent *event)
+     } else if (event->modifiers() & Qt::KeypadModifier) {
+         if (qtKey >= Qt::Key_0 && qtKey <= Qt::Key_9)
+             keysyms.append(XKB_KEY_KP_0 + (qtKey - Qt::Key_0));
+-    } else if (isLatin(qtKey) && event->text().isUpper()) {
++    } else if (isLatin1(qtKey) && event->text().isUpper()) {
+         keysyms.append(qtKey);
+     }
+ 
+@@ -523,7 +524,7 @@ int QXkbCommon::keysymToQtKey(xkb_keysym_t keysym, Qt::KeyboardModifiers modifie
+         // With standard shortcuts we should prefer a latin character, this is
+         // for checks like "some qkeyevent == QKeySequence::Copy" to work even
+         // when using for example 'russian' keyboard layout.
+-        if (!QXkbCommon::isLatin(keysym)) {
++        if (!QXkbCommon::isLatin1(keysym)) {
+             xkb_keysym_t latinKeysym = QXkbCommon::lookupLatinKeysym(state, code);
+             if (latinKeysym != XKB_KEY_NoSymbol)
+                 keysym = latinKeysym;
+@@ -546,7 +547,7 @@ static int keysymToQtKey_internal(xkb_keysym_t keysym, Qt::KeyboardModifiers mod
+     } else if (keysym >= XKB_KEY_KP_0 && keysym <= XKB_KEY_KP_9) {
+         // numeric keypad keys
+         qtKey = Qt::Key_0 + (keysym - XKB_KEY_KP_0);
+-    } else if (QXkbCommon::isLatin(keysym)) {
++    } else if (QXkbCommon::isLatin1(keysym)) {
+         qtKey = QXkbCommon::qxkbcommon_xkb_keysym_to_upper(keysym);
+     } else {
+         // check if we have a direct mapping
+@@ -678,7 +679,7 @@ QList<int> QXkbCommon::possibleKeys(xkb_state *state, const QKeyEvent *event,
+         Qt::KeyboardModifiers neededMods = ModsTbl[i];
+         if ((modifiers & neededMods) == neededMods) {
+             if (i == 8) {
+-                if (isLatin(baseQtKey))
++                if (isLatin1(baseQtKey))
+                     continue;
+                 // add a latin key as a fall back key
+                 sym = lookupLatinKeysym(state, keycode);
+@@ -733,7 +734,7 @@ void QXkbCommon::verifyHasLatinLayout(xkb_keymap *keymap)
+     for (xkb_layout_index_t layout = 0; layout < layoutCount; ++layout) {
+         for (xkb_keycode_t code = minKeycode; code < maxKeycode; ++code) {
+             xkb_keymap_key_get_syms_by_level(keymap, code, layout, 0, &keysyms);
+-            if (keysyms && isLatin(keysyms[0]))
++            if (keysyms && isLatin1(keysyms[0]))
+                 nrLatinKeys++;
+             if (nrLatinKeys > 10) // arbitrarily chosen threshold
+                 return;
+@@ -766,7 +767,7 @@ xkb_keysym_t QXkbCommon::lookupLatinKeysym(xkb_state *state, xkb_keycode_t keyco
+         xkb_level_index_t level = xkb_state_key_get_level(state, keycode, layout);
+         if (xkb_keymap_key_get_syms_by_level(keymap, keycode, layout, level, &syms) != 1)
+             continue;
+-        if (isLatin(syms[0])) {
++        if (isLatin1(syms[0])) {
+             sym = syms[0];
+             break;
+         }
+diff --git a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
+index 561eae03db..8389bd8f5a 100644
+--- a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
++++ b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
+@@ -94,8 +94,8 @@ public:
+     static void verifyHasLatinLayout(xkb_keymap *keymap);
+     static xkb_keysym_t lookupLatinKeysym(xkb_state *state, xkb_keycode_t keycode);
+ 
+-    static bool isLatin(xkb_keysym_t sym) {
+-        return ((sym >= 'a' && sym <= 'z') || (sym >= 'A' && sym <= 'Z'));
++    static bool isLatin1(xkb_keysym_t sym) {
++        return sym <= 0xff;
+     }
+     static bool isKeypad(xkb_keysym_t sym) {
+         return sym >= XKB_KEY_KP_Space && sym <= XKB_KEY_KP_9;
+diff --git a/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp b/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
+index 8cd7f9b368..406f84663f 100644
+--- a/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
++++ b/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
+@@ -318,7 +318,7 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources,
+ 
+     if (current < 0 && crtc_mode.clock != 0) {
+         modes << crtc_mode;
+-        current = mode.size() - 1;
++        current = modes.size() - 1;
+     }
+ 
+     if (configuration == OutputConfigCurrent)
+diff --git a/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp b/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
+index 9153fd20bb..255ea5e33e 100644
+--- a/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
++++ b/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
+@@ -194,6 +194,9 @@ QString AtSpiAdaptor::introspect(const QString &path) const
+                 "      <arg direction=\"out\" type=\"(so)\"/>\n"
+                 "      <annotation value=\"QSpiObjectReference\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n"
+                 "    </method>\n"
++                "    <method name=\"GetAccessibleId\">\n"
++                "      <arg direction=\"out\" type=\"s\"/>\n"
++                "    </method>\n"
+                 "  </interface>\n"
+                 );
+ 
+@@ -913,8 +916,17 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+     }
+     case QAccessible::NameChanged: {
+         if (sendObject || sendObject_property_change || sendObject_property_change_accessible_name) {
+-            QString path = pathForInterface(event->accessibleInterface());
+-            QVariantList args = packDBusSignalArguments(QLatin1String("accessible-name"), 0, 0, variantForPath(path));
++            QAccessibleInterface *iface = event->accessibleInterface();
++            if (!iface) {
++                qCDebug(lcAccessibilityAtspi,
++                        "NameChanged event from invalid accessible.");
++                return;
++            }
++
++            QString path = pathForInterface(iface);
++            QVariantList args = packDBusSignalArguments(
++                QLatin1String("accessible-name"), 0, 0,
++                QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Name))));
+             sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                            QLatin1String("PropertyChange"), args);
+         }
+@@ -922,8 +934,17 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+     }
+     case QAccessible::DescriptionChanged: {
+         if (sendObject || sendObject_property_change || sendObject_property_change_accessible_description) {
+-            QString path = pathForInterface(event->accessibleInterface());
+-            QVariantList args = packDBusSignalArguments(QLatin1String("accessible-description"), 0, 0, variantForPath(path));
++            QAccessibleInterface *iface = event->accessibleInterface();
++            if (!iface) {
++                qCDebug(lcAccessibilityAtspi,
++                        "DescriptionChanged event from invalid accessible.");
++                return;
++            }
++
++            QString path = pathForInterface(iface);
++            QVariantList args = packDBusSignalArguments(
++                QLatin1String("accessible-description"), 0, 0,
++                QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Description))));
+             sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                            QLatin1String("PropertyChange"), args);
+         }
+@@ -1038,7 +1059,9 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+                 // Combo Box with AT-SPI likes to be special
+                 // It requires a name-change to update caches and then selection-changed
+                 QString path = pathForInterface(iface);
+-                QVariantList args1 = packDBusSignalArguments(QLatin1String("accessible-name"), 0, 0, variantForPath(path));
++                QVariantList args1 = packDBusSignalArguments(
++                    QLatin1String("accessible-name"), 0, 0,
++                    QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Name))));
+                 sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                                QLatin1String("PropertyChange"), args1);
+                 QVariantList args2 = packDBusSignalArguments(QString(), 0, 0, QVariant::fromValue(QDBusVariant(QVariant(0))));
+@@ -1358,6 +1381,26 @@ void AtSpiAdaptor::registerApplication()
+     delete registry;
+ }
+ 
++namespace {
++QString accessibleIdForAccessible(QAccessibleInterface *accessible)
++{
++    QString result;
++    while (accessible) {
++        if (!result.isEmpty())
++            result.prepend(QLatin1Char('.'));
++        if (auto obj = accessible->object()) {
++            const QString name = obj->objectName();
++            if (!name.isEmpty())
++                result.prepend(name);
++            else
++                result.prepend(QString::fromUtf8(obj->metaObject()->className()));
++        }
++        accessible = accessible->parent();
++    }
++    return result;
++}
++} // namespace
++
+ // Accessible
+ bool AtSpiAdaptor::accessibleInterface(QAccessibleInterface *interface, const QString &function, const QDBusMessage &message, const QDBusConnection &connection)
+ {
+@@ -1441,6 +1484,9 @@ bool AtSpiAdaptor::accessibleInterface(QAccessibleInterface *interface, const QS
+             children << ref;
+         }
+         connection.send(message.createReply(QVariant::fromValue(children)));
++    } else if (function == QLatin1String("GetAccessibleId")) {
++        sendReply(connection, message,
++                  QVariant::fromValue(QDBusVariant(accessibleIdForAccessible(interface))));
+     } else {
+         qCDebug(lcAccessibilityAtspi) << "WARNING: AtSpiAdaptor::accessibleInterface does not implement " << function << message.path();
+         return false;
+diff --git a/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp b/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
+index 45ddc8e496..cc734abc63 100644
+--- a/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
++++ b/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
+@@ -69,6 +69,21 @@ QT_BEGIN_NAMESPACE
+ DBusConnection::DBusConnection(QObject *parent)
+     : QObject(parent), m_a11yConnection(QString()), m_enabled(false)
+ {
++    // If the bus is explicitly set via env var it overrides everything else.
++    QByteArray addressEnv = qgetenv("AT_SPI_BUS_ADDRESS");
++    if (!addressEnv.isEmpty()) {
++        // Only connect on next loop run, connections to our enabled signal are
++        // only established after the ctor returns.
++        QMetaObject::invokeMethod(
++                this,
++                [this, addressEnv] {
++                    m_enabled = true;
++                    connectA11yBus(QString::fromLocal8Bit(addressEnv));
++                },
++                Qt::QueuedConnection);
++        return;
++    }
++
+     // Start monitoring if "org.a11y.Bus" is registered as DBus service.
+     QDBusConnection c = QDBusConnection::sessionBus();
+     if (!c.isConnected()) {
+diff --git a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
+index 1a3cab275d..2abe039126 100644
+--- a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
++++ b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
+@@ -51,6 +51,9 @@
+ #include <QtCore/QStandardPaths>
+ #include <QtCore/QUrl>
+ 
++#include <QtGui/QGuiApplication>
++#include <QtGui/QWindow>
++
+ #if QT_CONFIG(dbus)
+ // These QtCore includes are needed for xdg-desktop-portal support
+ #include <QtCore/private/qcore_unix_p.h>
+@@ -58,6 +61,8 @@
+ #include <QtCore/QFileInfo>
+ #include <QtCore/QUrlQuery>
+ 
++#include <QtGui/QColor>
++
+ #include <QtDBus/QDBusConnection>
+ #include <QtDBus/QDBusMessage>
+ #include <QtDBus/QDBusPendingCall>
+@@ -142,6 +147,8 @@ static inline bool detectWebBrowser(const QByteArray &desktop,
+     }
+ 
+     if (desktop == QByteArray("KDE")) {
++        if (checkExecutable(QStringLiteral("kde-open5"), browser))
++            return true;
+         // Konqueror launcher
+         if (checkExecutable(QStringLiteral("kfmclient"), browser)) {
+             browser->append(QLatin1String(" exec"));
+@@ -296,8 +303,135 @@ static inline QDBusMessage xdgDesktopPortalSendEmail(const QUrl &url)
+ 
+     return QDBusConnection::sessionBus().call(message);
+ }
++
++namespace {
++struct XDGDesktopColor
++{
++    double r = 0;
++    double g = 0;
++    double b = 0;
++
++    QColor toQColor() const
++    {
++        constexpr auto rgbMax = 255;
++        return { static_cast<int>(r * rgbMax), static_cast<int>(g * rgbMax),
++                 static_cast<int>(b * rgbMax) };
++    }
++};
++
++const QDBusArgument &operator>>(const QDBusArgument &argument, XDGDesktopColor &myStruct)
++{
++    argument.beginStructure();
++    argument >> myStruct.r >> myStruct.g >> myStruct.b;
++    argument.endStructure();
++    return argument;
++}
++
++class XdgDesktopPortalColorPicker : public QPlatformServiceColorPicker
++{
++    Q_OBJECT
++public:
++    XdgDesktopPortalColorPicker(const QString &parentWindowId, QWindow *parent)
++        : QPlatformServiceColorPicker(parent), m_parentWindowId(parentWindowId)
++    {
++    }
++
++    void pickColor() override
++    {
++        // DBus signature:
++        // PickColor (IN   s      parent_window,
++        //            IN   a{sv}  options
++        //            OUT  o      handle)
++        // Options:
++        // handle_token (s) -  A string that will be used as the last element of the @handle.
++
++        QDBusMessage message = QDBusMessage::createMethodCall(
++                QStringLiteral("org.freedesktop.portal.Desktop"), QStringLiteral("/org/freedesktop/portal/desktop"),
++                QStringLiteral("org.freedesktop.portal.Screenshot"), QStringLiteral("PickColor"));
++        message << m_parentWindowId << QVariantMap();
++
++        QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
++        auto watcher = new QDBusPendingCallWatcher(pendingCall, this);
++        connect(watcher, &QDBusPendingCallWatcher::finished, this,
++                [this](QDBusPendingCallWatcher *watcher) {
++                    watcher->deleteLater();
++                    QDBusPendingReply<QDBusObjectPath> reply = *watcher;
++                    if (reply.isError()) {
++                        qWarning("DBus call to pick color failed: %s",
++                                 qPrintable(reply.error().message()));
++                        Q_EMIT colorPicked({});
++                    } else {
++                        QDBusConnection::sessionBus().connect(
++                                QStringLiteral("org.freedesktop.portal.Desktop"), reply.value().path(),
++                                QStringLiteral("org.freedesktop.portal.Request"), QStringLiteral("Response"), this,
++                                // clang-format off
++                                SLOT(gotColorResponse(uint,QVariantMap))
++                                // clang-format on
++                        );
++                    }
++                });
++    }
++
++private Q_SLOTS:
++    void gotColorResponse(uint result, const QVariantMap &map)
++    {
++        if (result != 0)
++            return;
++        XDGDesktopColor color{};
++        map.value(QStringLiteral("color")).value<QDBusArgument>() >> color;
++        Q_EMIT colorPicked(color.toQColor());
++        deleteLater();
++    }
++
++private:
++    const QString m_parentWindowId;
++};
++} // namespace
++
+ #endif // QT_CONFIG(dbus)
+ 
++QGenericUnixServices::QGenericUnixServices()
++{
++#if QT_CONFIG(dbus)
++    if (qEnvironmentVariableIntValue("QT_NO_XDG_DESKTOP_PORTAL") > 0) {
++        return;
++    }
++    QDBusMessage message = QDBusMessage::createMethodCall(
++            QStringLiteral("org.freedesktop.portal.Desktop"), QStringLiteral("/org/freedesktop/portal/desktop"),
++            QStringLiteral("org.freedesktop.DBus.Properties"), QStringLiteral("Get"));
++    message << QStringLiteral("org.freedesktop.portal.Screenshot")
++            << QStringLiteral("version");
++
++    QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
++    auto watcher = new QDBusPendingCallWatcher(pendingCall);
++    QObject::connect(watcher, &QDBusPendingCallWatcher::finished, watcher,
++                     [this](QDBusPendingCallWatcher *watcher) {
++                         watcher->deleteLater();
++                         QDBusPendingReply<QVariant> reply = *watcher;
++                         if (!reply.isError() && reply.value().toUInt() >= 2)
++                             m_hasScreenshotPortalWithColorPicking = true;
++                     });
++
++#endif
++}
++
++QPlatformServiceColorPicker *QGenericUnixServices::colorPicker(QWindow *parent)
++{
++#if QT_CONFIG(dbus)
++    // Make double sure that we are in a wayland environment. In particular check
++    // WAYLAND_DISPLAY so also XWayland apps benefit from portal-based color picking.
++    // Outside wayland we'll rather rely on other means than the XDG desktop portal.
++    if (!qEnvironmentVariableIsEmpty("WAYLAND_DISPLAY")
++        || QGuiApplication::platformName().startsWith(QLatin1String("wayland"))) {
++        return new XdgDesktopPortalColorPicker(portalWindowIdentifier(parent), parent);
++    }
++    return nullptr;
++#else
++    Q_UNUSED(parent);
++    return nullptr;
++#endif
++}
++
+ QByteArray QGenericUnixServices::desktopEnvironment() const
+ {
+     static const QByteArray result = detectDesktopEnvironment();
+@@ -352,6 +486,8 @@ bool QGenericUnixServices::openDocument(const QUrl &url)
+ }
+ 
+ #else
++QGenericUnixServices::QGenericUnixServices() = default;
++
+ QByteArray QGenericUnixServices::desktopEnvironment() const
+ {
+     return QByteArrayLiteral("UNKNOWN");
+@@ -371,6 +507,30 @@ bool QGenericUnixServices::openDocument(const QUrl &url)
+     return false;
+ }
+ 
++QPlatformServiceColorPicker *QGenericUnixServices::colorPicker(QWindow *parent)
++{
++    Q_UNUSED(parent);
++    return nullptr;
++}
++
+ #endif // QT_NO_MULTIPROCESS
+ 
++QString QGenericUnixServices::portalWindowIdentifier(QWindow *window)
++{
++    if (QGuiApplication::platformName() == QLatin1String("xcb"))
++        return QStringLiteral("x11:") + QString::number(window->winId(), 16);
++    return QString();
++}
++
++bool QGenericUnixServices::hasCapability(Capability capability) const
++{
++    switch (capability) {
++    case Capability::ColorPicking:
++        return m_hasScreenshotPortalWithColorPicking;
++    }
++    return false;
++}
++
+ QT_END_NAMESPACE
++
++#include "qgenericunixservices.moc"
+diff --git a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
+index 8ac3de6f03..30924e64bd 100644
+--- a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
++++ b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
+@@ -59,16 +59,21 @@ QT_BEGIN_NAMESPACE
+ class QGenericUnixServices : public QPlatformServices
+ {
+ public:
+-    QGenericUnixServices() {}
++    QGenericUnixServices();
+ 
+     QByteArray desktopEnvironment() const override;
+ 
++    bool hasCapability(Capability capability) const override;
+     bool openUrl(const QUrl &url) override;
+     bool openDocument(const QUrl &url) override;
++    QPlatformServiceColorPicker *colorPicker(QWindow *parent = nullptr) override;
++
++    virtual QString portalWindowIdentifier(QWindow *window);
+ 
+ private:
+     QString m_webBrowser;
+     QString m_documentLauncher;
++    bool m_hasScreenshotPortalWithColorPicking = false;
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
+index 09470bccc6..cc7c7d4d8a 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
+@@ -69,6 +69,7 @@ const QString MenuBarPath = QLatin1String("/MenuBar");
+ */
+ QDBusMenuConnection::QDBusMenuConnection(QObject *parent, const QString &serviceName)
+     : QObject(parent)
++    , m_serviceName(serviceName)
+     , m_connection(serviceName.isNull() ? QDBusConnection::sessionBus()
+                                         : QDBusConnection::connectToBus(QDBusConnection::SessionBus, serviceName))
+     , m_dbusWatcher(new QDBusServiceWatcher(StatusNotifierWatcherService, m_connection, QDBusServiceWatcher::WatchForRegistration, this))
+@@ -83,6 +84,12 @@ QDBusMenuConnection::QDBusMenuConnection(QObject *parent, const QString &service
+ #endif
+ }
+ 
++QDBusMenuConnection::~QDBusMenuConnection()
++{
++  if (!m_serviceName.isEmpty() && m_connection.isConnected())
++      QDBusConnection::disconnectFromBus(m_serviceName);
++}
++
+ void QDBusMenuConnection::dbusError(const QDBusError &error)
+ {
+     qWarning() << "QDBusTrayIcon encountered a D-Bus error:" << error;
+@@ -105,13 +112,7 @@ void QDBusMenuConnection::unregisterTrayIconMenu(QDBusTrayIcon *item)
+ 
+ bool QDBusMenuConnection::registerTrayIcon(QDBusTrayIcon *item)
+ {
+-    bool success = connection().registerService(item->instanceId());
+-    if (!success) {
+-        qWarning() << "failed to register service" << item->instanceId();
+-        return false;
+-    }
+-
+-    success = connection().registerObject(StatusNotifierItemPath, item);
++    bool success = connection().registerObject(StatusNotifierItemPath, item);
+     if (!success) {
+         unregisterTrayIcon(item);
+         qWarning() << "failed to register" << item->instanceId() << StatusNotifierItemPath;
+@@ -126,21 +127,18 @@ bool QDBusMenuConnection::registerTrayIcon(QDBusTrayIcon *item)
+ 
+ bool QDBusMenuConnection::registerTrayIconWithWatcher(QDBusTrayIcon *item)
+ {
++    Q_UNUSED(item);
+     QDBusMessage registerMethod = QDBusMessage::createMethodCall(
+                 StatusNotifierWatcherService, StatusNotifierWatcherPath, StatusNotifierWatcherService,
+                 QLatin1String("RegisterStatusNotifierItem"));
+-    registerMethod.setArguments(QVariantList() << item->instanceId());
++    registerMethod.setArguments(QVariantList() << m_connection.baseService());
+     return m_connection.callWithCallback(registerMethod, this, SIGNAL(trayIconRegistered()), SLOT(dbusError(QDBusError)));
+ }
+ 
+-bool QDBusMenuConnection::unregisterTrayIcon(QDBusTrayIcon *item)
++void QDBusMenuConnection::unregisterTrayIcon(QDBusTrayIcon *item)
+ {
+     unregisterTrayIconMenu(item);
+     connection().unregisterObject(StatusNotifierItemPath);
+-    bool success = connection().unregisterService(item->instanceId());
+-    if (!success)
+-        qWarning() << "failed to unregister service" << item->instanceId();
+-    return success;
+ }
+ #endif // QT_NO_SYSTEMTRAYICON
+ 
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
+index f484795fbb..97bdfabb85 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
++++ b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
+@@ -70,6 +70,7 @@ class QDBusMenuConnection : public QObject
+ 
+ public:
+     QDBusMenuConnection(QObject *parent = nullptr, const QString &serviceName = QString());
++    ~QDBusMenuConnection();
+     QDBusConnection connection() const { return m_connection; }
+     QDBusServiceWatcher *dbusWatcher() const { return m_dbusWatcher; }
+     bool isStatusNotifierHostRegistered() const { return m_statusNotifierHostRegistered; }
+@@ -78,7 +79,7 @@ public:
+     void unregisterTrayIconMenu(QDBusTrayIcon *item);
+     bool registerTrayIcon(QDBusTrayIcon *item);
+     bool registerTrayIconWithWatcher(QDBusTrayIcon *item);
+-    bool unregisterTrayIcon(QDBusTrayIcon *item);
++    void unregisterTrayIcon(QDBusTrayIcon *item);
+ #endif // QT_NO_SYSTEMTRAYICON
+ 
+ Q_SIGNALS:
+@@ -90,6 +91,7 @@ private Q_SLOTS:
+     void dbusError(const QDBusError &error);
+ 
+ private:
++    QString m_serviceName;
+     QDBusConnection m_connection;
+     QDBusServiceWatcher *m_dbusWatcher;
+     bool m_statusNotifierHostRegistered;
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp b/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
+index bede70975a..76bfec5e5a 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
+@@ -71,8 +71,12 @@ Q_LOGGING_CATEGORY(qLcTray, "qt.qpa.tray")
+ static QString iconTempPath()
+ {
+     QString tempPath = QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation);
+-    if (!tempPath.isEmpty())
++    if (!tempPath.isEmpty()) {
++        QString flatpakId = qEnvironmentVariable("FLATPAK_ID");
++        if (!flatpakId.isEmpty() && QFileInfo::exists(QLatin1String("/.flatpak-info")))
++            tempPath += QLatin1String("/app/") + flatpakId;
+         return tempPath;
++    }
+ 
+     tempPath = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation);
+ 
+diff --git a/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+index cb1b39db64..6e01af052c 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+@@ -755,6 +755,9 @@ QVariant QGnomeTheme::themeHint(QPlatformTheme::ThemeHint hint) const
+         return QVariant(QChar(0x2022));
+     case QPlatformTheme::UiEffects:
+         return QVariant(int(HoverEffect));
++    case QPlatformTheme::ButtonPressKeys:
++        return QVariant::fromValue(
++                QList<Qt::Key>({ Qt::Key_Space, Qt::Key_Return, Qt::Key_Enter, Qt::Key_Select }));
+     default:
+         break;
+     }
+diff --git a/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp b/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
+index 98e05195ee..1e92f43dec 100644
+--- a/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
++++ b/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
+@@ -343,8 +343,7 @@ void QEglFSCursor::paintOnScreen()
+     // screens are siblings of each other. When not enabled, the sibling list
+     // only contains m_screen itself.
+     for (QPlatformScreen *screen : m_screen->virtualSiblings()) {
+-        if (screen->geometry().contains(cr.topLeft().toPoint() + m_cursor.hotSpot)
+-            && QOpenGLContext::currentContext()->screen() == screen->screen())
++        if (screen->geometry().contains(cr.topLeft().toPoint() + m_cursor.hotSpot))
+         {
+             cr.translate(-screen->geometry().topLeft());
+             const QSize screenSize = screen->geometry().size();
+@@ -468,11 +467,12 @@ void QEglFSCursor::draw(const QRectF &r)
+ {
+     StateSaver stateSaver;
+ 
+-    QEglFSCursorData &gfx = static_cast<QEglFSContext*>(QOpenGLContext::currentContext()->handle())->cursorData;
+-    if (!gfx.program) {
+-        // one time initialization
++    // one time initialization
++    if (!QOpenGLFunctions::d_ptr)
+         initializeOpenGLFunctions();
+ 
++    QEglFSCursorData &gfx = static_cast<QEglFSContext*>(QOpenGLContext::currentContext()->handle())->cursorData;
++    if (!gfx.program) {
+         createShaderPrograms();
+ 
+         if (!gfx.atlasTexture) {
+diff --git a/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp b/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
+index 645a0ae2e9..3e0e406f1a 100644
+--- a/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
++++ b/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
+@@ -179,7 +179,7 @@ void QEglFSKmsEventReader::create(QEglFSKmsDevice *device)
+ 
+     m_device = device;
+ 
+-    qCDebug(qLcEglfsKmsDebug, "Initalizing event reader for device %p fd %d",
++    qCDebug(qLcEglfsKmsDebug, "Initializing event reader for device %p fd %d",
+             m_device, m_device->fd());
+ 
+     m_thread = new QEglFSKmsEventReaderThread(m_device->fd());
+diff --git a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
+index 141fb68a23..d4294d425a 100644
+--- a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
++++ b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
+@@ -122,11 +122,13 @@ QOffscreenIntegration::QOffscreenIntegration()
+ #endif
+     m_services.reset(new QPlatformServices);
+ 
+-    QWindowSystemInterface::handleScreenAdded(new QOffscreenScreen);
++    m_screen = new QOffscreenScreen;
++    QWindowSystemInterface::handleScreenAdded(m_screen);
+ }
+ 
+ QOffscreenIntegration::~QOffscreenIntegration()
+ {
++    QWindowSystemInterface::handleScreenRemoved(m_screen);
+ }
+ 
+ void QOffscreenIntegration::initialize()
+diff --git a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
+index 0ea90f6c2f..fe00fde07c 100644
+--- a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
++++ b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
+@@ -84,6 +84,7 @@ protected:
+ #endif
+     QScopedPointer<QPlatformInputContext> m_inputContext;
+     QScopedPointer<QPlatformServices> m_services;
++    QPlatformScreen *m_screen;
+     mutable QScopedPointer<QPlatformNativeInterface> m_nativeInterface;
+ };
+ 
+diff --git a/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp b/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
+index 6fa5a8a2b3..1f49f0aefd 100644
+--- a/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
++++ b/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
+@@ -48,6 +48,7 @@
+ #include <qpa/qplatformnativeinterface.h>
+ #include <QtPlatformHeaders/qwglnativecontext.h>
+ 
++#include <private/qsystemlibrary_p.h>
+ #include <algorithm>
+ 
+ #include <wingdi.h>
+@@ -162,19 +163,25 @@ QFunctionPointer QWindowsOpengl32DLL::resolve(const char *name)
+ 
+ bool QWindowsOpengl32DLL::init(bool softwareRendering)
+ {
+-    const QByteArray opengl32 = QByteArrayLiteral("opengl32.dll");
+-    const QByteArray swopengl = QByteArrayLiteral("opengl32sw.dll");
++    const QByteArray opengl32 = QByteArrayLiteral("opengl32");
++    const QByteArray swopengl = QByteArrayLiteral("opengl32sw");
++    bool useSystemLib = false;
+ 
+     QByteArray openglDll = qgetenv("QT_OPENGL_DLL");
+-    if (openglDll.isEmpty())
++    if (openglDll.isEmpty()) {
+         openglDll = softwareRendering ? swopengl : opengl32;
++        useSystemLib = !softwareRendering;
++    }
+ 
+     openglDll = openglDll.toLower();
+     m_nonOpengl32 = openglDll != opengl32;
+ 
+     qCDebug(lcQpaGl) << "Qt: Using WGL and OpenGL from" << openglDll;
+ 
+-    m_lib = ::LoadLibraryA(openglDll.constData());
++    if (useSystemLib)
++        m_lib = QSystemLibrary::load((wchar_t*)(QString::fromLatin1(openglDll).utf16()));
++    else
++        m_lib = LoadLibraryA(openglDll.constData());
+     if (!m_lib) {
+         qErrnoWarning(::GetLastError(), "Failed to load %s", openglDll.constData());
+         return false;
+@@ -184,7 +191,7 @@ bool QWindowsOpengl32DLL::init(bool softwareRendering)
+         // Load opengl32.dll always. GDI functions like ChoosePixelFormat do
+         // GetModuleHandle for opengl32.dll and behave differently (and call back into
+         // opengl32) when the module is present. This is fine for dummy contexts and windows.
+-        ::LoadLibraryA("opengl32.dll");
++        QSystemLibrary::load(L"opengl32");
+     }
+ 
+     wglCreateContext = reinterpret_cast<HGLRC (WINAPI *)(HDC)>(resolve("wglCreateContext"));
+diff --git a/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp b/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
+index d7d186e804..9eb4011bf2 100644
+--- a/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
++++ b/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
+@@ -49,6 +49,7 @@
+ #include <QtCore/qstandardpaths.h>
+ #include <QtCore/qlibraryinfo.h>
+ #include <QtCore/qhash.h>
++#include <private/qsystemlibrary_p.h>
+ 
+ #ifndef QT_NO_OPENGL
+ #include <private/qopengl_p.h>
+@@ -396,7 +397,7 @@ bool QWindowsOpenGLTester::testDesktopGL()
+ 
+     // Test #1: Load opengl32.dll and try to resolve an OpenGL 2 function.
+     // This will typically fail on systems that do not have a real OpenGL driver.
+-    lib = LoadLibraryA("opengl32.dll");
++    lib = QSystemLibrary::load(L"opengl32");
+     if (lib) {
+         CreateContext = reinterpret_cast<CreateContextType>(
+             reinterpret_cast<QFunctionPointer>(::GetProcAddress(lib, "wglCreateContext")));
+diff --git a/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp b/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
+index 1afa00cfc9..118af6ce73 100644
+--- a/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
++++ b/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
+@@ -41,6 +41,7 @@
+ 
+ #include <QRect>
+ #include <QList>
++#include <QMap>
+ #include <QDebug>
+ 
+ #include <qmath.h>
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp b/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
+index 9e2a37a6a1..e6e175a118 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
+@@ -488,12 +488,12 @@ void QXcbConnection::printXcbError(const char *message, xcb_generic_error_t *err
+     uint clamped_error_code = qMin<uint>(error->error_code, (sizeof(xcb_errors) / sizeof(xcb_errors[0])) - 1);
+     uint clamped_major_code = qMin<uint>(error->major_code, (sizeof(xcb_protocol_request_codes) / sizeof(xcb_protocol_request_codes[0])) - 1);
+ 
+-    qCWarning(lcQpaXcb, "%s: %d (%s), sequence: %d, resource id: %d, major code: %d (%s), minor code: %d",
+-             message,
+-             int(error->error_code), xcb_errors[clamped_error_code],
+-             int(error->sequence), int(error->resource_id),
+-             int(error->major_code), xcb_protocol_request_codes[clamped_major_code],
+-             int(error->minor_code));
++    qCDebug(lcQpaXcb, "%s: %d (%s), sequence: %d, resource id: %d, major code: %d (%s), minor code: %d",
++            message,
++            int(error->error_code), xcb_errors[clamped_error_code],
++            int(error->sequence), int(error->resource_id),
++            int(error->major_code), xcb_protocol_request_codes[clamped_major_code],
++            int(error->minor_code));
+ }
+ 
+ static Qt::MouseButtons translateMouseButtons(int s)
+@@ -702,6 +702,8 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
+             QXcbVirtualDesktop *virtualDesktop = virtualDesktopForRootWindow(propertyNotify->window);
+             if (virtualDesktop)
+                 virtualDesktop->updateWorkArea();
++        } else if (propertyNotify->atom == atom(QXcbAtom::_NET_SUPPORTED)) {
++            m_wmSupport->updateNetWMAtoms();
+         } else {
+             HANDLE_PLATFORM_WINDOW_EVENT(xcb_property_notify_event_t, window, handlePropertyNotifyEvent);
+         }
+@@ -750,7 +752,7 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
+                 case XCB_XKB_NEW_KEYBOARD_NOTIFY: {
+                     xcb_xkb_new_keyboard_notify_event_t *ev = &xkb_event->new_keyboard_notify;
+                     if (ev->changed & XCB_XKB_NKN_DETAIL_KEYCODES)
+-                        m_keyboard->updateKeymap(ev);
++                        m_keyboard->updateKeymap();
+                     break;
+                 }
+                 default:
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp b/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
+index 76869ced60..02d2eebb56 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
+@@ -274,8 +274,7 @@ QPlatformWindow *QXcbIntegration::createForeignWindow(QWindow *window, WId nativ
+ #ifndef QT_NO_OPENGL
+ QPlatformOpenGLContext *QXcbIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
+ {
+-    QXcbScreen *screen = static_cast<QXcbScreen *>(context->screen()->handle());
+-    QXcbGlIntegration *glIntegration = screen->connection()->glIntegration();
++    QXcbGlIntegration *glIntegration = defaultConnection()->glIntegration();
+     if (!glIntegration) {
+         qWarning("QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled");
+         return nullptr;
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+index efecd7e2d1..e8286381a2 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+@@ -365,17 +365,6 @@ void QXcbKeyboard::updateKeymap(xcb_mapping_notify_event_t *event)
+     updateKeymap();
+ }
+ 
+-void QXcbKeyboard::updateKeymap(xcb_xkb_new_keyboard_notify_event_t *event)
+-{
+-    if (!event)
+-        return;
+-
+-    if (event->deviceID != event->oldDeviceID)
+-        m_config = false;
+-
+-    updateKeymap();
+-}
+-
+ void QXcbKeyboard::updateKeymap()
+ {
+     KeysymModifierMap keysymMods;
+@@ -383,6 +372,8 @@ void QXcbKeyboard::updateKeymap()
+         keysymMods = keysymsToModifiers();
+     updateModifiers(keysymMods);
+ 
++    m_config = true;
++
+     if (!m_xkbContext) {
+         m_xkbContext.reset(xkb_context_new(XKB_CONTEXT_NO_DEFAULT_INCLUDES));
+         if (!m_xkbContext) {
+@@ -398,13 +389,8 @@ void QXcbKeyboard::updateKeymap()
+     if (connection()->hasXKB()) {
+         m_xkbKeymap.reset(xkb_x11_keymap_new_from_device(m_xkbContext.get(), xcb_connection(),
+                                                          core_device_id, XKB_KEYMAP_COMPILE_NO_FLAGS));
+-        if (m_xkbKeymap) {
+-            if (m_config)
+-                m_xkbState.reset(xkb_state_new(m_xkbKeymap.get()));
+-            else
+-                m_xkbState.reset(xkb_x11_state_new_from_device(m_xkbKeymap.get(), xcb_connection(), core_device_id));
+-
+-        }
++        if (m_xkbKeymap)
++            m_xkbState.reset(xkb_x11_state_new_from_device(m_xkbKeymap.get(), xcb_connection(), core_device_id));
+     } else {
+         m_xkbKeymap.reset(keymapFromCore(keysymMods));
+         if (m_xkbKeymap)
+@@ -425,8 +411,6 @@ void QXcbKeyboard::updateKeymap()
+     updateXKBMods();
+ 
+     QXkbCommon::verifyHasLatinLayout(m_xkbKeymap.get());
+-
+-    m_config = true;
+ }
+ 
+ QList<int> QXcbKeyboard::possibleKeys(const QKeyEvent *event) const
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
+index b652c85fe3..0ee08aeff2 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
++++ b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
+@@ -69,7 +69,6 @@ public:
+ 
+     Qt::KeyboardModifiers translateModifiers(int s) const;
+     void updateKeymap(xcb_mapping_notify_event_t *event);
+-    void updateKeymap(xcb_xkb_new_keyboard_notify_event_t *event);
+     void updateKeymap();
+     QList<int> possibleKeys(const QKeyEvent *event) const;
+ 
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp b/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
+index ffda7b6a57..863e961f4c 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
+@@ -564,11 +564,6 @@ void QXcbWindow::setGeometry(const QRect &rect)
+ {
+     QPlatformWindow::setGeometry(rect);
+ 
+-    if (shouldDeferTask(Task::SetGeometry)) {
+-        m_deferredGeometry = rect;
+-        return;
+-    }
+-
+     propagateSizeHints();
+ 
+     QXcbScreen *currentScreen = xcbScreen();
+@@ -693,9 +688,6 @@ void QXcbWindow::setVisible(bool visible)
+ 
+ void QXcbWindow::show()
+ {
+-    if (shouldDeferTask(Task::Map))
+-        return;
+-
+     if (window()->isTopLevel()) {
+ 
+         // update WM_NORMAL_HINTS
+@@ -706,7 +698,7 @@ void QXcbWindow::show()
+         if (isTransient(window())) {
+             const QWindow *tp = window()->transientParent();
+             if (tp && tp->handle())
+-                transientXcbParent = static_cast<const QXcbWindow *>(tp->handle())->winId();
++                transientXcbParent = tp->handle()->winId();
+             // Default to client leader if there is no transient parent, else modal dialogs can
+             // be hidden by their parents.
+             if (!transientXcbParent)
+@@ -746,10 +738,6 @@ void QXcbWindow::show()
+ 
+ void QXcbWindow::hide()
+ {
+-    if (shouldDeferTask(Task::Unmap))
+-        return;
+-
+-    m_wmStateValid = false;
+     xcb_unmap_window(xcb_connection(), m_window);
+ 
+     // send synthetic UnmapNotify event according to icccm 4.1.4
+@@ -909,9 +897,6 @@ QXcbWindow::NetWmStates QXcbWindow::netWmStates()
+ 
+ void QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
+ {
+-    if (shouldDeferTask(Task::SetWindowFlags))
+-        return;
+-
+     Qt::WindowType type = static_cast<Qt::WindowType>(int(flags & Qt::WindowType_Mask));
+ 
+     if (type == Qt::ToolTip)
+@@ -941,8 +926,6 @@ void QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
+ 
+     setTransparentForMouseEvents(flags & Qt::WindowTransparentForInput);
+     updateDoesNotAcceptFocus(flags & Qt::WindowDoesNotAcceptFocus);
+-
+-    m_isWmManagedWindow = !(flags & Qt::X11BypassWindowManagerHint);
+ }
+ 
+ void QXcbWindow::setMotifWmHints(Qt::WindowFlags flags)
+@@ -1142,9 +1125,6 @@ void QXcbWindow::setWindowState(Qt::WindowStates state)
+     if (state == m_windowState)
+         return;
+ 
+-    if (shouldDeferTask(Task::SetWindowState))
+-        return;
+-
+     // unset old state
+     if (m_windowState & Qt::WindowMinimized)
+         xcb_map_window(xcb_connection(), m_window);
+@@ -1350,6 +1330,12 @@ void QXcbWindow::setWindowIcon(const QIcon &icon)
+     }
+ 
+     if (!icon_data.isEmpty()) {
++        // Ignore icon exceeding maximum xcb request length
++        if (icon_data.size() > xcb_get_maximum_request_length(xcb_connection())) {
++            qWarning("Ignoring window icon: Size %llu exceeds maximum xcb request length %u.",
++                     icon_data.size(), xcb_get_maximum_request_length(xcb_connection()));
++            return;
++        }
+         xcb_change_property(xcb_connection(),
+                             XCB_PROP_MODE_REPLACE,
+                             m_window,
+@@ -1639,7 +1625,7 @@ void QXcbWindow::setWmWindowType(QXcbWindowFunctions::WmWindowTypes types, Qt::W
+         break;
+     }
+ 
+-    if ((flags & Qt::FramelessWindowHint) && !(type & QXcbWindowFunctions::KdeOverride)) {
++    if ((flags & Qt::FramelessWindowHint) && !(types & QXcbWindowFunctions::KdeOverride)) {
+         // override netwm type - quick and easy for KDE noborder
+         atoms.append(atom(QXcbAtom::_KDE_NET_WM_WINDOW_TYPE_OVERRIDE));
+     }
+@@ -1894,10 +1880,6 @@ void QXcbWindow::handleUnmapNotifyEvent(const xcb_unmap_notify_event_t *event)
+     if (event->window == m_window) {
+         m_mapped = false;
+         QWindowSystemInterface::handleExposeEvent(window(), QRegion());
+-        if (!m_isWmManagedWindow || parent()) {
+-            m_wmStateValid = true;
+-            handleDeferredTasks();
+-        }
+     }
+ }
+ 
+@@ -2212,98 +2194,30 @@ void QXcbWindow::handleLeaveNotifyEvent(const xcb_leave_notify_event_t *event)
+     handleLeaveNotifyEvent(event->root_x, event->root_y, event->mode, event->detail, event->time);
+ }
+ 
+-bool QXcbWindow::shouldDeferTask(Task task)
+-{
+-    if (m_wmStateValid)
+-        return false;
+-
+-    m_deferredTasks.append(task);
+-    return true;
+-}
+-
+-void QXcbWindow::handleDeferredTasks()
+-{
+-    Q_ASSERT(m_wmStateValid == true);
+-    if (m_deferredTasks.isEmpty())
+-        return;
+-
+-    bool map = false;
+-    bool unmap = false;
+-
+-    QVector<Task> tasks;
+-    for (auto taskIt = m_deferredTasks.rbegin(); taskIt != m_deferredTasks.rend(); ++taskIt) {
+-        if (!tasks.contains(*taskIt))
+-            tasks.prepend(*taskIt);
+-    }
+-
+-    for (Task task : tasks) {
+-        switch (task) {
+-        case Task::Map:
+-            map = true;
+-            unmap = false;
+-            break;
+-        case Task::Unmap:
+-            unmap = true;
+-            map = false;
+-            break;
+-        case Task::SetGeometry:
+-            setGeometry(m_deferredGeometry);
+-            break;
+-        case Task::SetWindowFlags:
+-            setWindowFlags(window()->flags());
+-            break;
+-        case Task::SetWindowState:
+-            setWindowState(window()->windowState());
+-            break;
+-        }
+-    }
+-    m_deferredTasks.clear();
+-
+-    if (map) {
+-        Q_ASSERT(unmap == false);
+-        show();
+-    }
+-    if (unmap) {
+-        Q_ASSERT(map == false);
+-        hide();
+-    }
+-}
+-
+ void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *event)
+ {
+     connection()->setTime(event->time);
+ 
+-    const bool wmStateChanged = event->atom == atom(QXcbAtom::WM_STATE);
+-    const bool netWmStateChanged = event->atom == atom(QXcbAtom::_NET_WM_STATE);
+-    if (netWmStateChanged || wmStateChanged) {
+-        if (wmStateChanged && !m_wmStateValid && m_isWmManagedWindow) {
+-            // ICCCM 4.1.4
+-            // Clients that want to re-use a client window (e.g. by mapping it again)
+-            // after withdrawing it must wait for the withdrawal to be complete before
+-            // proceeding. The preferred method for doing this is for clients to wait for
+-            // a window manager to update or remove the WM_STATE property.
+-            m_wmStateValid = true;
+-            handleDeferredTasks();
+-        }
+-        if (event->state == XCB_PROPERTY_DELETE)
++    const bool propertyDeleted = event->state == XCB_PROPERTY_DELETE;
++
++    if (event->atom == atom(QXcbAtom::_NET_WM_STATE) || event->atom == atom(QXcbAtom::WM_STATE)) {
++        if (propertyDeleted)
+             return;
+ 
+-        if (wmStateChanged) {
++        Qt::WindowStates newState = Qt::WindowNoState;
++
++        if (event->atom == atom(QXcbAtom::WM_STATE)) { // WM_STATE: Quick check for 'Minimize'.
+             auto reply = Q_XCB_REPLY(xcb_get_property, xcb_connection(),
+                                      0, m_window, atom(QXcbAtom::WM_STATE),
+                                      XCB_ATOM_ANY, 0, 1024);
+             if (reply && reply->format == 32 && reply->type == atom(QXcbAtom::WM_STATE)) {
+-                auto data = static_cast<const quint32 *>(xcb_get_property_value(reply.get()));
+-                if (reply->length != 0) {
+-                    const bool changedToWithdrawn = data[0] == XCB_ICCCM_WM_STATE_WITHDRAWN;
+-                    const bool changedToIconic = data[0] == XCB_ICCCM_WM_STATE_ICONIC;
+-                    m_minimized = changedToIconic || (changedToWithdrawn && m_minimized);
+-                }
++                const quint32 *data = (const quint32 *)xcb_get_property_value(reply.get());
++                if (reply->length != 0)
++                    m_minimized = (data[0] == XCB_ICCCM_WM_STATE_ICONIC
++                                   || (data[0] == XCB_ICCCM_WM_STATE_WITHDRAWN && m_minimized));
+             }
+         }
+ 
+-        // _NET_WM_STATE handling
+-        Qt::WindowStates newState = Qt::WindowNoState;
+         const NetWmStates states = netWmStates();
+         // _NET_WM_STATE_HIDDEN should be set by the Window Manager to indicate that a window would
+         // not be visible on the screen if its desktop/viewport were active and its coordinates were
+@@ -2325,6 +2239,7 @@ void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *ev
+             if ((m_windowState & Qt::WindowMinimized) && connection()->mouseGrabber() == this)
+                 connection()->setMouseGrabber(nullptr);
+         }
++        return;
+     } else if (event->atom == atom(QXcbAtom::_NET_FRAME_EXTENTS)) {
+         m_dirtyFrameMargins = true;
+     }
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbwindow.h b/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
+index 55af9279b1..6f5c1f5ed9 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
++++ b/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
+@@ -74,14 +74,6 @@ public:
+ 
+     Q_DECLARE_FLAGS(NetWmStates, NetWmState)
+ 
+-    enum Task {
+-        Map,
+-        Unmap,
+-        SetGeometry,
+-        SetWindowFlags,
+-        SetWindowState
+-    };
+-
+     QXcbWindow(QWindow *window);
+     ~QXcbWindow();
+ 
+@@ -151,9 +143,6 @@ public:
+ 
+     QXcbWindow *toWindow() override;
+ 
+-    bool shouldDeferTask(Task task);
+-    void handleDeferredTasks();
+-
+     void handleMouseEvent(xcb_timestamp_t time, const QPoint &local, const QPoint &global,
+                           Qt::KeyboardModifiers modifiers, QEvent::Type type, Qt::MouseEventSource source);
+ 
+@@ -292,11 +281,6 @@ protected:
+     int m_swapInterval = -1;
+ 
+     qreal m_sizeHintsScaleFactor = 1.0;
+-
+-    bool m_wmStateValid = true;
+-    QVector<Task> m_deferredTasks;
+-    bool m_isWmManagedWindow = true;
+-    QRect m_deferredGeometry;
+ };
+ 
+ class QXcbForeignWindow : public QXcbWindow
+diff --git a/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp b/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
+index d9d117faeb..640b49daa0 100644
+--- a/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
++++ b/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
+@@ -85,6 +85,7 @@ QGtk3MenuItem::QGtk3MenuItem()
+       m_checkable(false),
+       m_checked(false),
+       m_enabled(true),
++      m_exclusive(false),
+       m_underline(false),
+       m_invalid(true),
+       m_menu(nullptr),
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
+index 0048bbc1e6..396e7f6d1c 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
+@@ -102,15 +102,12 @@ const QDBusArgument &operator >>(const QDBusArgument &arg, QXdgDesktopPortalFile
+ class QXdgDesktopPortalFileDialogPrivate
+ {
+ public:
+-    QXdgDesktopPortalFileDialogPrivate(QPlatformFileDialogHelper *nativeFileDialog)
++    QXdgDesktopPortalFileDialogPrivate(QPlatformFileDialogHelper *nativeFileDialog, uint fileChooserPortalVersion)
+         : nativeFileDialog(nativeFileDialog)
++        , fileChooserPortalVersion(fileChooserPortalVersion)
+     { }
+ 
+-    WId winId = 0;
+-    bool directoryMode = false;
+-    bool modal = false;
+-    bool multipleFiles = false;
+-    bool saveFile = false;
++    QEventLoop loop;
+     QString acceptLabel;
+     QString directory;
+     QString title;
+@@ -121,19 +118,27 @@ public:
+     QString selectedMimeTypeFilter;
+     QString selectedNameFilter;
+     QStringList selectedFiles;
+-    QPlatformFileDialogHelper *nativeFileDialog = nullptr;
++    std::unique_ptr<QPlatformFileDialogHelper> nativeFileDialog;
++    uint fileChooserPortalVersion = 0;
++    bool failedToOpen = false;
++    bool directoryMode = false;
++    bool multipleFiles = false;
++    bool saveFile = false;
+ };
+ 
+-QXdgDesktopPortalFileDialog::QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog)
++QXdgDesktopPortalFileDialog::QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog, uint fileChooserPortalVersion)
+     : QPlatformFileDialogHelper()
+-    , d_ptr(new QXdgDesktopPortalFileDialogPrivate(nativeFileDialog))
++    , d_ptr(new QXdgDesktopPortalFileDialogPrivate(nativeFileDialog, fileChooserPortalVersion))
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+     if (d->nativeFileDialog) {
+-        connect(d->nativeFileDialog, SIGNAL(accept()), this, SIGNAL(accept()));
+-        connect(d->nativeFileDialog, SIGNAL(reject()), this, SIGNAL(reject()));
++        connect(d->nativeFileDialog.get(), SIGNAL(accept()), this, SIGNAL(accept()));
++        connect(d->nativeFileDialog.get(), SIGNAL(reject()), this, SIGNAL(reject()));
+     }
++
++    d->loop.connect(this, SIGNAL(accept()), SLOT(quit()));
++    d->loop.connect(this, SIGNAL(reject()), SLOT(quit()));
+ }
+ 
+ QXdgDesktopPortalFileDialog::~QXdgDesktopPortalFileDialog()
+@@ -177,7 +182,7 @@ void QXdgDesktopPortalFileDialog::initializeDialog()
+     setDirectory(options()->initialDirectory());
+ }
+ 
+-void QXdgDesktopPortalFileDialog::openPortal()
++void QXdgDesktopPortalFileDialog::openPortal(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent)
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+@@ -185,13 +190,13 @@ void QXdgDesktopPortalFileDialog::openPortal()
+                                                           QLatin1String("/org/freedesktop/portal/desktop"),
+                                                           QLatin1String("org.freedesktop.portal.FileChooser"),
+                                                           d->saveFile ? QLatin1String("SaveFile") : QLatin1String("OpenFile"));
+-    QString parentWindowId = QLatin1String("x11:") + QString::number(d->winId, 16);
++    QString parentWindowId = QLatin1String("x11:") + QString::number(parent ? parent->winId() : 0, 16);
+ 
+     QVariantMap options;
+     if (!d->acceptLabel.isEmpty())
+         options.insert(QLatin1String("accept_label"), d->acceptLabel);
+ 
+-    options.insert(QLatin1String("modal"), d->modal);
++    options.insert(QLatin1String("modal"), windowModality != Qt::NonModal);
+     options.insert(QLatin1String("multiple"), d->multipleFiles);
+     options.insert(QLatin1String("directory"), d->directoryMode);
+ 
+@@ -290,10 +295,18 @@ void QXdgDesktopPortalFileDialog::openPortal()
+ 
+     QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
+     QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingCall);
+-    connect(watcher, &QDBusPendingCallWatcher::finished, this, [this] (QDBusPendingCallWatcher *watcher) {
++    connect(watcher, &QDBusPendingCallWatcher::finished, this, [=] (QDBusPendingCallWatcher *watcher) {
+         QDBusPendingReply<QDBusObjectPath> reply = *watcher;
+-        if (reply.isError()) {
+-            Q_EMIT reject();
++        // Any error means the dialog is not shown and we need to fallback
++        d->failedToOpen = reply.isError();
++        if (d->failedToOpen) {
++            if (d->nativeFileDialog) {
++                d->nativeFileDialog->show(windowFlags, windowModality, parent);
++                if (d->loop.isRunning())
++                    d->nativeFileDialog->exec();
++            } else {
++                Q_EMIT reject();
++            }
+         } else {
+             QDBusConnection::sessionBus().connect(nullptr,
+                                                   reply.value().path(),
+@@ -302,6 +315,7 @@ void QXdgDesktopPortalFileDialog::openPortal()
+                                                   this,
+                                                   SLOT(gotResponse(uint,QVariantMap)));
+         }
++        watcher->deleteLater();
+     });
+ }
+ 
+@@ -326,7 +340,7 @@ QUrl QXdgDesktopPortalFileDialog::directory() const
+ {
+     Q_D(const QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog())
+         return d->nativeFileDialog->directory();
+ 
+     return d->directory;
+@@ -348,7 +362,7 @@ QList<QUrl> QXdgDesktopPortalFileDialog::selectedFiles() const
+ {
+     Q_D(const QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog())
+         return d->nativeFileDialog->selectedFiles();
+ 
+     QList<QUrl> files;
+@@ -403,16 +417,13 @@ void QXdgDesktopPortalFileDialog::exec()
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly)) {
++    if (d->nativeFileDialog && useNativeFileDialog()) {
+         d->nativeFileDialog->exec();
+         return;
+     }
+ 
+     // HACK we have to avoid returning until we emit that the dialog was accepted or rejected
+-    QEventLoop loop;
+-    loop.connect(this, SIGNAL(accept()), SLOT(quit()));
+-    loop.connect(this, SIGNAL(reject()), SLOT(quit()));
+-    loop.exec();
++    d->loop.exec();
+ }
+ 
+ void QXdgDesktopPortalFileDialog::hide()
+@@ -429,13 +440,10 @@ bool QXdgDesktopPortalFileDialog::show(Qt::WindowFlags windowFlags, Qt::WindowMo
+ 
+     initializeDialog();
+ 
+-    d->modal = windowModality != Qt::NonModal;
+-    d->winId = parent ? parent->winId() : 0;
+-
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog(OpenFallback))
+         return d->nativeFileDialog->show(windowFlags, windowModality, parent);
+ 
+-    openPortal();
++    openPortal(windowFlags, windowModality, parent);
+ 
+     return true;
+ }
+@@ -465,4 +473,21 @@ void QXdgDesktopPortalFileDialog::gotResponse(uint response, const QVariantMap &
+     }
+ }
+ 
++bool QXdgDesktopPortalFileDialog::useNativeFileDialog(QXdgDesktopPortalFileDialog::FallbackType fallbackType) const
++{
++    Q_D(const QXdgDesktopPortalFileDialog);
++
++    if (d->failedToOpen && fallbackType != OpenFallback)
++        return true;
++
++    if (d->fileChooserPortalVersion < 3) {
++        if (options()->fileMode() == QFileDialogOptions::Directory)
++            return true;
++        else if (options()->fileMode() == QFileDialogOptions::DirectoryOnly)
++            return true;
++    }
++
++    return false;
++}
++
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
+index 4f4de96ecf..65e22a5cf2 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
+@@ -51,6 +51,11 @@ class QXdgDesktopPortalFileDialog : public QPlatformFileDialogHelper
+     Q_OBJECT
+     Q_DECLARE_PRIVATE(QXdgDesktopPortalFileDialog)
+ public:
++    enum FallbackType {
++        GenericFallback,
++        OpenFallback
++    };
++
+     enum ConditionType : uint {
+         GlobalPattern = 0,
+         MimeType = 1
+@@ -69,7 +74,7 @@ public:
+     };
+     typedef QVector<Filter> FilterList;
+ 
+-    QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog = nullptr);
++    QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog = nullptr, uint fileChooserPortalVersion = 0);
+     ~QXdgDesktopPortalFileDialog();
+ 
+     bool defaultNameFilterDisables() const override;
+@@ -92,7 +97,8 @@ private Q_SLOTS:
+ 
+ private:
+     void initializeDialog();
+-    void openPortal();
++    void openPortal(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent);
++    bool useNativeFileDialog(FallbackType fallbackType = GenericFallback) const;
+ 
+     QScopedPointer<QXdgDesktopPortalFileDialogPrivate> d_ptr;
+ };
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
+index fb324afbd8..b809503122 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
+@@ -111,6 +111,7 @@ QXdgDesktopPortalTheme::QXdgDesktopPortalTheme()
+         if (reply.isValid()) {
+             d->fileChooserPortalVersion = reply.value().toUInt();
+         }
++        watcher->deleteLater();
+     });
+ }
+ 
+@@ -152,11 +153,12 @@ QPlatformDialogHelper* QXdgDesktopPortalTheme::createPlatformDialogHelper(Dialog
+ {
+     Q_D(const QXdgDesktopPortalTheme);
+ 
+-    if (type == FileDialog) {
++    if (type == FileDialog && d->fileChooserPortalVersion) {
+         // Older versions of FileChooser portal don't support opening directories, therefore we fallback
+         // to native file dialog opened inside the sandbox to open a directory.
+-        if (d->fileChooserPortalVersion < 3 && d->baseTheme->usePlatformNativeDialog(type))
+-            return new QXdgDesktopPortalFileDialog(static_cast<QPlatformFileDialogHelper*>(d->baseTheme->createPlatformDialogHelper(type)));
++        if (d->baseTheme->usePlatformNativeDialog(type))
++            return new QXdgDesktopPortalFileDialog(static_cast<QPlatformFileDialogHelper*>(d->baseTheme->createPlatformDialogHelper(type)),
++                                                   d->fileChooserPortalVersion);
+ 
+         return new QXdgDesktopPortalFileDialog;
+     }
+diff --git a/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp b/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
+index 43d5e119ad..1f9cbc4565 100644
+--- a/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
++++ b/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
+@@ -89,8 +89,10 @@ void QCupsPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &v
+         break;
+     case PPK_Duplex: {
+         QPrint::DuplexMode mode = QPrint::DuplexMode(value.toInt());
+-        if (mode != d->duplex && d->m_printDevice.supportedDuplexModes().contains(mode))
++        if (d->m_printDevice.supportedDuplexModes().contains(mode)) {
+             d->duplex = mode;
++            d->duplexRequestedExplicitly = true;
++        }
+         break;
+     }
+     case PPK_PrinterName:
+@@ -277,9 +279,12 @@ void QCupsPrintEnginePrivate::changePrinter(const QString &newPrinter)
+     m_printDevice.swap(printDevice);
+     printerName = m_printDevice.id();
+ 
+-    // Check if new printer supports current settings, otherwise us defaults
+-    if (duplex != QPrint::DuplexAuto && !m_printDevice.supportedDuplexModes().contains(duplex))
++    // in case a duplex value was explicitly set, check if new printer supports current value,
++    // otherwise use device default
++    if (!duplexRequestedExplicitly || !m_printDevice.supportedDuplexModes().contains(duplex)) {
+         duplex = m_printDevice.defaultDuplexMode();
++        duplexRequestedExplicitly = false;
++    }
+     QPrint::ColorMode colorMode = grayscale ? QPrint::GrayScale : QPrint::Color;
+     if (!m_printDevice.supportedColorModes().contains(colorMode))
+         grayscale = m_printDevice.defaultColorMode() == QPrint::GrayScale;
+diff --git a/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h b/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
+index c021b0c643..8f81fe478d 100644
+--- a/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
++++ b/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
+@@ -100,6 +100,7 @@ private:
+     QStringList cupsOptions;
+     QString cupsTempFile;
+     QPrint::DuplexMode duplex;
++    bool duplexRequestedExplicitly = false;
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp b/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
+index 67e7154fa6..40876152e5 100644
+--- a/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
++++ b/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
+@@ -817,7 +817,7 @@ bool QIBaseResultPrivate::writeArray(int column, const QList<QVariant> &list)
+     ba.resize(int(bufLen));
+ 
+     if (list.size() > arraySize) {
+-        error = QLatin1String("Array size missmatch: size of %1 is %2, size of provided list is %3");
++        error = QLatin1String("Array size mismatch: size of %1 is %2, size of provided list is %3");
+         error = error.arg(QLatin1String(sqlname)).arg(arraySize).arg(list.size());
+         q->setLastError(QSqlError(error, QLatin1String(""), QSqlError::StatementError));
+         return false;
+diff --git a/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp b/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
+index 7ca055eea2..6bc9d46755 100644
+--- a/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
++++ b/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
+@@ -223,7 +223,7 @@ public:
+     struct QMyField
+     {
+         char *outField = nullptr;
+-        MYSQL_FIELD *myField = nullptr;
++        const MYSQL_FIELD *myField = nullptr;
+         QMetaType::Type type = QMetaType::UnknownType;
+         my_bool nullIndicator = false;
+         ulong bufLength = 0ul;
+@@ -361,7 +361,7 @@ static bool qIsInteger(int t)
+ void QMYSQLResultPrivate::bindBlobs()
+ {
+     int i;
+-    MYSQL_FIELD *fieldInfo;
++    const MYSQL_FIELD *fieldInfo;
+     MYSQL_BIND *bind;
+ 
+     for(i = 0; i < fields.count(); ++i) {
+@@ -379,7 +379,6 @@ void QMYSQLResultPrivate::bindBlobs()
+ bool QMYSQLResultPrivate::bindInValues()
+ {
+     MYSQL_BIND *bind;
+-    char *field;
+     int i = 0;
+ 
+     if (!meta)
+@@ -392,35 +391,34 @@ bool QMYSQLResultPrivate::bindInValues()
+     inBinds = new MYSQL_BIND[fields.size()];
+     memset(inBinds, 0, fields.size() * sizeof(MYSQL_BIND));
+ 
+-    MYSQL_FIELD *fieldInfo;
++    const MYSQL_FIELD *fieldInfo;
+ 
+     while((fieldInfo = mysql_fetch_field(meta))) {
++        bind = &inBinds[i];
++
+         QMyField &f = fields[i];
+         f.myField = fieldInfo;
+-
++        bind->buffer_length = f.bufLength = fieldInfo->length + 1;
++        bind->buffer_type = fieldInfo->type;
+         f.type = qDecodeMYSQLType(fieldInfo->type, fieldInfo->flags);
+         if (qIsBlob(fieldInfo->type)) {
+             // the size of a blob-field is available as soon as we call
+             // mysql_stmt_store_result()
+             // after mysql_stmt_exec() in QMYSQLResult::exec()
+-            fieldInfo->length = 0;
++            bind->buffer_length = f.bufLength = 0;
+             hasBlobs = true;
+         } else if (qIsInteger(f.type)) {
+-            fieldInfo->length = 8;
++            bind->buffer_length = f.bufLength = 8;
+         } else {
+-            fieldInfo->type = MYSQL_TYPE_STRING;
++            bind->buffer_type = MYSQL_TYPE_STRING;
+         }
+-        bind = &inBinds[i];
+-        field = new char[fieldInfo->length + 1];
+-        memset(field, 0, fieldInfo->length + 1);
+ 
+-        bind->buffer_type = fieldInfo->type;
+-        bind->buffer = field;
+-        bind->buffer_length = f.bufLength = fieldInfo->length + 1;
+         bind->is_null = &f.nullIndicator;
+         bind->length = &f.bufLength;
+         bind->is_unsigned = fieldInfo->flags & UNSIGNED_FLAG ? 1 : 0;
+-        f.outField=field;
++
++        char *field = new char[bind->buffer_length + 1]{};
++        bind->buffer = f.outField = field;
+ 
+         ++i;
+     }
+@@ -1369,20 +1367,20 @@ bool QMYSQLDriver::open(const QString& db,
+     }
+ 
+ #if MYSQL_VERSION_ID >= 50007
+-    if (mysql_get_client_version() >= 50503 && mysql_get_server_version(d->mysql) >= 50503) {
+-        // force the communication to be utf8mb4 (only utf8mb4 supports 4-byte characters)
+-        mysql_set_character_set(d->mysql, "utf8mb4");
++    // force the communication to be utf8mb4 (only utf8mb4 supports 4-byte characters)
++    if (mysql_set_character_set(d->mysql, "utf8mb4")) {
++        // this failed, try forcing it to utf (BMP only)
++        if (mysql_set_character_set(d->mysql, "utf8"))
++            qWarning() << "MySQL: Unable to set the client character set to utf8.";
+ #if QT_CONFIG(textcodec)
+-        d->tc = QTextCodec::codecForName("UTF-8");
++        else
++            d->tc = codec(d->mysql);
+ #endif
+-    } else
+-    {
+-        // force the communication to be utf8
+-        mysql_set_character_set(d->mysql, "utf8");
++    }
+ #if QT_CONFIG(textcodec)
+-        d->tc = codec(d->mysql);
++    else
++        d->tc = QTextCodec::codecForName("UTF-8");
+ #endif
+-    }
+ #endif  // MYSQL_VERSION_ID >= 50007
+ 
+     d->preparedQuerysEnabled = checkPreparedQueries(d->mysql);
+diff --git a/qtbase/src/printsupport/dialogs/images/print-24.png b/qtbase/src/printsupport/dialogs/images/printer-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/print-24.png
+rename to src/printsupport/dialogs/images/printer-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/print-32.png b/qtbase/src/printsupport/dialogs/images/printer-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/print-32.png
+rename to src/printsupport/dialogs/images/printer-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-sided-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-facing-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-sided-24.png
+rename to src/printsupport/dialogs/images/view-pages-facing-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-sided-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-facing-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-sided-32.png
+rename to src/printsupport/dialogs/images/view-pages-facing-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-multi-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-overview-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-multi-24.png
+rename to src/printsupport/dialogs/images/view-pages-overview-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-multi-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-overview-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-multi-32.png
+rename to src/printsupport/dialogs/images/view-pages-overview-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-one-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-single-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-one-24.png
+rename to src/printsupport/dialogs/images/view-pages-single-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-one-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-single-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-one-32.png
+rename to src/printsupport/dialogs/images/view-pages-single-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-page-24.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-page-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-page-24.png
+rename to src/printsupport/dialogs/images/zoom-fit-page-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-page-32.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-page-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-page-32.png
+rename to src/printsupport/dialogs/images/zoom-fit-page-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-width-24.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-width-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-width-24.png
+rename to src/printsupport/dialogs/images/zoom-fit-width-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-width-32.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-width-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-width-32.png
+rename to src/printsupport/dialogs/images/zoom-fit-width-32.png
+diff --git a/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp b/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
+index 78e5b8d1ef..2a28516719 100644
+--- a/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
++++ b/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
+@@ -532,6 +532,7 @@ void QPageSetupWidget::updateWidget()
+ void QPageSetupWidget::setupPrinter() const
+ {
+     m_printer->setPageLayout(m_pageLayout);
++    m_printer->setPageOrientation(m_pageLayout.orientation());
+ #if QT_CONFIG(cups)
+     QCUPSSupport::PagesPerSheet pagesPerSheet = qvariant_cast<QCUPSSupport::PagesPerSheet>(m_ui.pagesPerSheetCombo->currentData()
+ );
+diff --git a/qtbase/src/printsupport/dialogs/qprintdialog.qrc b/qtbase/src/printsupport/dialogs/qprintdialog.qrc
+index 5a579baa55..10b8e1d341 100644
+--- a/qtbase/src/printsupport/dialogs/qprintdialog.qrc
++++ b/qtbase/src/printsupport/dialogs/qprintdialog.qrc
+@@ -1,9 +1,9 @@
+ <!DOCTYPE RCC><RCC version="1.0">
+ <qresource prefix="/qt-project.org/dialogs/qprintpreviewdialog">
+-<file>images/fit-page-24.png</file>
+-<file>images/fit-page-32.png</file>
+-<file>images/fit-width-24.png</file>
+-<file>images/fit-width-32.png</file>
++<file>images/zoom-fit-page-24.png</file>
++<file>images/zoom-fit-page-32.png</file>
++<file>images/zoom-fit-width-24.png</file>
++<file>images/zoom-fit-width-32.png</file>
+ <file>images/go-first-24.png</file>
+ <file>images/go-first-32.png</file>
+ <file>images/go-last-24.png</file>
+@@ -18,14 +18,14 @@
+ <file>images/layout-portrait-32.png</file>
+ <file>images/page-setup-24.png</file>
+ <file>images/page-setup-32.png</file>
+-<file>images/print-24.png</file>
+-<file>images/print-32.png</file>
+-<file>images/view-page-multi-24.png</file>
+-<file>images/view-page-multi-32.png</file>
+-<file>images/view-page-one-24.png</file>
+-<file>images/view-page-one-32.png</file>
+-<file>images/view-page-sided-24.png</file>
+-<file>images/view-page-sided-32.png</file>
++<file>images/printer-24.png</file>
++<file>images/printer-32.png</file>
++<file>images/view-pages-overview-24.png</file>
++<file>images/view-pages-overview-32.png</file>
++<file>images/view-pages-single-24.png</file>
++<file>images/view-pages-single-32.png</file>
++<file>images/view-pages-facing-24.png</file>
++<file>images/view-pages-facing-32.png</file>
+ <file>images/zoom-in-24.png</file>
+ <file>images/zoom-in-32.png</file>
+ <file>images/zoom-out-24.png</file>
+diff --git a/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp b/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
+index c5b845f4ec..5a5ba1d0a8 100644
+--- a/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
++++ b/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
+@@ -702,13 +702,14 @@ void QPrintDialogPrivate::selectPrinter(const QPrinter::OutputFormat outputForma
+         else
+             options.grayscale->setChecked(true);
+ 
+-        // keep duplex value explicitly set by user, if any, and selected printer supports it;
+-        // use device default otherwise
++        // duplex priorities to be as follows:
++        // 1) a user-selected duplex value in the dialog has highest prority
++        // 2) duplex value set in the QPrinter
+         QPrint::DuplexMode duplex;
+         if (explicitDuplexMode != QPrint::DuplexAuto && supportedDuplexMode.contains(explicitDuplexMode))
+             duplex = explicitDuplexMode;
+         else
+-            duplex = top->d->m_currentPrintDevice.defaultDuplexMode();
++            duplex = static_cast<QPrint::DuplexMode>(p->duplex());
+         switch (duplex) {
+         case QPrint::DuplexNone:
+             options.noDuplex->setChecked(true); break;
+@@ -1242,10 +1243,10 @@ void QUnixPrintWidgetPrivate::_q_printerChanged(int index)
+             QString filename = widget.filename->text();
+             widget.filename->setText(filename);
+             widget.lOutput->setEnabled(true);
+-            if (optionsPane)
+-                optionsPane->selectPrinter(QPrinter::PdfFormat);
+             printer->setOutputFormat(QPrinter::PdfFormat);
+             m_currentPrintDevice = QPrintDevice();
++            if (optionsPane)
++                optionsPane->selectPrinter(QPrinter::PdfFormat);
+             return;
+         }
+     }
+diff --git a/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp b/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
+index 39575d5f57..23b7e89538 100644
+--- a/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
++++ b/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
+@@ -352,7 +352,7 @@ void QPrintPreviewDialogPrivate::init(QPrinter *_printer)
+ static inline void qt_setupActionIcon(QAction *action, QLatin1String name)
+ {
+     QLatin1String imagePrefix(":/qt-project.org/dialogs/qprintpreviewdialog/images/");
+-    QIcon icon;
++    QIcon icon = QIcon::fromTheme(name);
+     icon.addFile(imagePrefix + name + QLatin1String("-24.png"), QSize(24, 24));
+     icon.addFile(imagePrefix + name + QLatin1String("-32.png"), QSize(32, 32));
+     action->setIcon(icon);
+@@ -383,8 +383,8 @@ void QPrintPreviewDialogPrivate::setupActions()
+     fitPageAction->setObjectName(QLatin1String("fitPageAction"));
+     fitWidthAction->setCheckable(true);
+     fitPageAction->setCheckable(true);
+-    qt_setupActionIcon(fitWidthAction, QLatin1String("fit-width"));
+-    qt_setupActionIcon(fitPageAction, QLatin1String("fit-page"));
++    qt_setupActionIcon(fitWidthAction, QLatin1String("zoom-fit-width"));
++    qt_setupActionIcon(fitPageAction, QLatin1String("zoom-fit-page"));
+     QObject::connect(fitGroup, SIGNAL(triggered(QAction*)), q, SLOT(_q_fit(QAction*)));
+ 
+     // Zoom
+@@ -410,9 +410,9 @@ void QPrintPreviewDialogPrivate::setupActions()
+     singleModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show single page"));
+     facingModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show facing pages"));
+     overviewModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show overview of all pages"));
+-    qt_setupActionIcon(singleModeAction, QLatin1String("view-page-one"));
+-    qt_setupActionIcon(facingModeAction, QLatin1String("view-page-sided"));
+-    qt_setupActionIcon(overviewModeAction, QLatin1String("view-page-multi"));
++    qt_setupActionIcon(singleModeAction, QLatin1String("view-pages-single"));
++    qt_setupActionIcon(facingModeAction, QLatin1String("view-pages-facing"));
++    qt_setupActionIcon(overviewModeAction, QLatin1String("view-pages-overview"));
+     singleModeAction->setObjectName(QLatin1String("singleModeAction"));
+     facingModeAction->setObjectName(QLatin1String("facingModeAction"));
+     overviewModeAction->setObjectName(QLatin1String("overviewModeAction"));
+@@ -426,7 +426,7 @@ void QPrintPreviewDialogPrivate::setupActions()
+     printerGroup = new QActionGroup(q);
+     printAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Print"));
+     pageSetupAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Page setup"));
+-    qt_setupActionIcon(printAction, QLatin1String("print"));
++    qt_setupActionIcon(printAction, QLatin1String("printer"));
+     qt_setupActionIcon(pageSetupAction, QLatin1String("page-setup"));
+     QObject::connect(printAction, SIGNAL(triggered(bool)), q, SLOT(_q_print()));
+     QObject::connect(pageSetupAction, SIGNAL(triggered(bool)), q, SLOT(_q_pageSetup()));
+diff --git a/qtbase/src/sql/kernel/qsqlquery.cpp b/qtbase/src/sql/kernel/qsqlquery.cpp
+index 32c6166c79..60afef10c3 100644
+--- a/qtbase/src/sql/kernel/qsqlquery.cpp
++++ b/qtbase/src/sql/kernel/qsqlquery.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2022 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtSql module of the Qt Toolkit.
+@@ -377,6 +377,10 @@ bool QSqlQuery::exec(const QString& query)
+     QElapsedTimer t;
+     t.start();
+ #endif
++    if (!driver()) {
++        qWarning("QSqlQuery::exec: called before driver has been set up");
++        return false;
++    }
+     if (d->ref.loadRelaxed() != 1) {
+         bool fo = isForwardOnly();
+         *this = QSqlQuery(driver()->createResult());
+diff --git a/qtbase/src/testlib/qabstractitemmodeltester.cpp b/qtbase/src/testlib/qabstractitemmodeltester.cpp
+index 8efb9c53d4..ce062f66d7 100644
+--- a/qtbase/src/testlib/qabstractitemmodeltester.cpp
++++ b/qtbase/src/testlib/qabstractitemmodeltester.cpp
+@@ -454,7 +454,7 @@ void QAbstractItemModelTesterPrivate::parent()
+ 
+     // Common error test #2, make sure that a second level index has a parent
+     // that is the first level index.
+-    if (model->rowCount(topIndex) > 0) {
++    if (model->rowCount(topIndex) > 0 && model->columnCount(topIndex) > 0) {
+         QModelIndex childIndex = model->index(0, 0, topIndex);
+         MODELTESTER_VERIFY(childIndex.isValid());
+         MODELTESTER_COMPARE(model->parent(childIndex), topIndex);
+diff --git a/qtbase/src/testlib/qasciikey.cpp b/qtbase/src/testlib/qasciikey.cpp
+index 9a308da2bc..93498b256f 100644
+--- a/qtbase/src/testlib/qasciikey.cpp
++++ b/qtbase/src/testlib/qasciikey.cpp
+@@ -498,6 +498,11 @@ char QTest::keyToAscii(Qt::Key key)
+     case Qt::Key_LaunchE : return 0; // = 0x10b0,
+     case Qt::Key_LaunchF : return 0; // = 0x10b1,
+ 
++    // Keypad navigation keys
++    case Qt::Key_Select : return 0; // = 0x01010000
++    case Qt::Key_Yes : return 0; // = 0x01010001
++    case Qt::Key_No : return 0; // = 0x01010002
++
+     default: QTEST_ASSERT(false); return 0;
+     }
+ }
+diff --git a/qtbase/src/testlib/qtestresult.cpp b/qtbase/src/testlib/qtestresult.cpp
+index 88028aac6e..2e89930776 100644
+--- a/qtbase/src/testlib/qtestresult.cpp
++++ b/qtbase/src/testlib/qtestresult.cpp
+@@ -251,7 +251,8 @@ bool QTestResult::verify(bool statement, const char *statementStr,
+ {
+     QTEST_ASSERT(statementStr);
+ 
+-    char msg[1024] = {'\0'};
++    char msg[1024];
++    msg[0] = '\0';
+ 
+     if (QTestLog::verboseLevel() >= 2) {
+         qsnprintf(msg, 1024, "QVERIFY(%s)", statementStr);
+@@ -309,7 +310,8 @@ static bool compareHelper(bool success, const char *failureMsg,
+                           bool hasValues = true)
+ {
+     const size_t maxMsgLen = 1024;
+-    char msg[maxMsgLen] = {'\0'};
++    char msg[maxMsgLen];
++    msg[0] = '\0';
+ 
+     QTEST_ASSERT(expected);
+     QTEST_ASSERT(actual);
+diff --git a/qtbase/src/widgets/dialogs/qcolordialog.cpp b/qtbase/src/widgets/dialogs/qcolordialog.cpp
+index 4247731275..cb325be85c 100644
+--- a/qtbase/src/widgets/dialogs/qcolordialog.cpp
++++ b/qtbase/src/widgets/dialogs/qcolordialog.cpp
+@@ -78,7 +78,10 @@
+ #include "qwindow.h"
+ 
+ #include "private/qdialog_p.h"
++#include "private/qguiapplication_p.h"
+ 
++#include <qpa/qplatformservices.h>
++#include <qpa/qplatformintegration.h>
+ #include <algorithm>
+ 
+ QT_BEGIN_NAMESPACE
+@@ -1611,6 +1614,20 @@ void QColorDialogPrivate::_q_newStandard(int r, int c)
+ void QColorDialogPrivate::_q_pickScreenColor()
+ {
+     Q_Q(QColorDialog);
++
++    auto *platformServices = QGuiApplicationPrivate::platformIntegration()->services();
++    if (platformServices->hasCapability(QPlatformServices::Capability::ColorPicking)) {
++        if (auto *colorPicker = platformServices->colorPicker(q->windowHandle())) {
++            q->connect(colorPicker, &QPlatformServiceColorPicker::colorPicked, q,
++                       [q, colorPicker](const QColor &color) {
++                           colorPicker->deleteLater();
++                           q->setCurrentColor(color);
++                       });
++            colorPicker->pickColor();
++            return;
++        }
++    }
++
+     if (!colorPickingEventFilter)
+         colorPickingEventFilter = new QColorPickingEventFilter(this, q);
+     q->installEventFilter(colorPickingEventFilter);
+diff --git a/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp b/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
+index e120817edc..8ea36b5427 100644
+--- a/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
++++ b/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
+@@ -400,12 +400,7 @@ bool QAbstractItemDelegate::helpEvent(QHelpEvent *event,
+         const QString tooltip = index.isValid() ?
+               d->textForRole(Qt::ToolTipRole, index.data(Qt::ToolTipRole), option.locale, precision) :
+               QString();
+-        QRect rect;
+-        if (index.isValid()) {
+-            const QRect r = view->visualRect(index);
+-            rect = QRect(view->mapToGlobal(r.topLeft()), r.size());
+-        }
+-        QToolTip::showText(he->globalPos(), tooltip, view, rect);
++        QToolTip::showText(he->globalPos(), tooltip, view->viewport(), option.rect);
+         event->setAccepted(!tooltip.isEmpty());
+         break;
+         }
+diff --git a/qtbase/src/widgets/itemviews/qlistview.cpp b/qtbase/src/widgets/itemviews/qlistview.cpp
+index 2b34476642..eebfaa030e 100644
+--- a/qtbase/src/widgets/itemviews/qlistview.cpp
++++ b/qtbase/src/widgets/itemviews/qlistview.cpp
+@@ -3386,6 +3386,7 @@ void QIconModeViewBase::updateContentsSize()
+ */
+ void QListView::currentChanged(const QModelIndex &current, const QModelIndex &previous)
+ {
++    QAbstractItemView::currentChanged(current, previous);
+ #ifndef QT_NO_ACCESSIBILITY
+     if (QAccessible::isActive()) {
+         if (current.isValid()) {
+@@ -3396,7 +3397,6 @@ void QListView::currentChanged(const QModelIndex &current, const QModelIndex &pr
+         }
+     }
+ #endif
+-    QAbstractItemView::currentChanged(current, previous);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/widgets/itemviews/qtableview.cpp b/qtbase/src/widgets/itemviews/qtableview.cpp
+index 934ac581b2..f79bb24249 100644
+--- a/qtbase/src/widgets/itemviews/qtableview.cpp
++++ b/qtbase/src/widgets/itemviews/qtableview.cpp
+@@ -1013,6 +1013,7 @@ void QTableViewPrivate::drawCell(QPainter *painter, const QStyleOptionViewItem &
+ int QTableViewPrivate::widthHintForIndex(const QModelIndex &index, int hint, const QStyleOptionViewItem &option) const
+ {
+     Q_Q(const QTableView);
++    const int oldHint = hint;
+     QWidget *editor = editorForIndex(index).widget.data();
+     if (editor && persistent.contains(editor)) {
+         hint = qMax(hint, editor->sizeHint().width());
+@@ -1021,6 +1022,17 @@ int QTableViewPrivate::widthHintForIndex(const QModelIndex &index, int hint, con
+         hint = qBound(min, hint, max);
+     }
+     hint = qMax(hint, q->itemDelegate(index)->sizeHint(option, index).width());
++
++    if (hasSpans()) {
++        auto span = spans.spanAt(index.column(), index.row());
++        if (span && span->m_left == index.column() && span->m_top == index.row()) {
++            // spans are screwed up when sections are moved
++            const auto left = logicalColumn(span->m_left);
++            for (int i = 1; i <= span->width(); ++i)
++               hint -= q->columnWidth(visualColumn(left + i));
++        }
++        hint = std::max(hint, oldHint);
++    }
+     return hint;
+ }
+ 
+@@ -1053,6 +1065,11 @@ int QTableViewPrivate::heightHintForIndex(const QModelIndex &index, int hint, QS
+         option.rect.setHeight(height);
+         option.rect.setX(q->columnViewportPosition(index.column()));
+         option.rect.setWidth(q->columnWidth(index.column()));
++        if (hasSpans()) {
++            auto span = spans.spanAt(index.column(), index.row());
++            if (span && span->m_left == index.column() && span->m_top == index.row())
++                option.rect.setWidth(std::max(option.rect.width(), visualSpanRect(*span).width()));
++        }
+         // 1px less space when grid is shown (see drawCell)
+         if (showGrid)
+             option.rect.setWidth(option.rect.width() - 1);
+diff --git a/qtbase/src/widgets/kernel/qaction.h b/qtbase/src/widgets/kernel/qaction.h
+index 258a1ea0a0..737c1e8285 100644
+--- a/qtbase/src/widgets/kernel/qaction.h
++++ b/qtbase/src/widgets/kernel/qaction.h
+@@ -81,7 +81,7 @@ class Q_WIDGETS_EXPORT QAction : public QObject
+     Q_PROPERTY(MenuRole menuRole READ menuRole WRITE setMenuRole NOTIFY changed)
+     Q_PROPERTY(bool iconVisibleInMenu READ isIconVisibleInMenu WRITE setIconVisibleInMenu NOTIFY changed)
+     Q_PROPERTY(bool shortcutVisibleInContextMenu READ isShortcutVisibleInContextMenu WRITE setShortcutVisibleInContextMenu NOTIFY changed)
+-    Q_PROPERTY(Priority priority READ priority WRITE setPriority)
++    Q_PROPERTY(Priority priority READ priority WRITE setPriority NOTIFY changed)
+ 
+ public:
+     // note this is copied into qplatformmenu.h, which must stay in sync
+diff --git a/qtbase/src/widgets/kernel/qwidget.cpp b/qtbase/src/widgets/kernel/qwidget.cpp
+index 9eba1e001e..26f6d27e18 100644
+--- a/qtbase/src/widgets/kernel/qwidget.cpp
++++ b/qtbase/src/widgets/kernel/qwidget.cpp
+@@ -5296,7 +5296,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
+         QWidgetEffectSourcePrivate *sourced = static_cast<QWidgetEffectSourcePrivate *>
+                                                          (source->d_func());
+         if (!sourced->context) {
+-            const QRegion effectRgn(rgn.boundingRect());
++            const QRegion effectRgn((flags & UseEffectRegionBounds) ? rgn.boundingRect() : rgn);
+             QWidgetPaintContext context(pdev, effectRgn, offset, flags, sharedPainter, repaintManager);
+             sourced->context = &context;
+             if (!sharedPainter) {
+@@ -5328,6 +5328,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
+         }
+     }
+ #endif // QT_CONFIG(graphicseffect)
++    flags = flags & ~UseEffectRegionBounds;
+ 
+     const bool alsoOnScreen = flags & DrawPaintOnScreen;
+     const bool recursive = flags & DrawRecursive;
+diff --git a/qtbase/src/widgets/kernel/qwidget_p.h b/qtbase/src/widgets/kernel/qwidget_p.h
+index eef6b8fa2c..c432f4b5d5 100644
+--- a/qtbase/src/widgets/kernel/qwidget_p.h
++++ b/qtbase/src/widgets/kernel/qwidget_p.h
+@@ -229,7 +229,8 @@ public:
+         DontSubtractOpaqueChildren = 0x10,
+         DontDrawOpaqueChildren = 0x20,
+         DontDrawNativeChildren = 0x40,
+-        DontSetCompositionMode = 0x80
++        DontSetCompositionMode = 0x80,
++        UseEffectRegionBounds = 0x100
+     };
+     Q_DECLARE_FLAGS(DrawWidgetFlags, DrawWidgetFlag)
+     Q_FLAG(DrawWidgetFlags)
+diff --git a/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp b/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
+index 02880b34da..0d44e1326d 100644
+--- a/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
++++ b/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
+@@ -1018,7 +1018,8 @@ void QWidgetRepaintManager::paintAndFlush()
+ 
+     // Paint the rest with composition.
+     if (repaintAllWidgets || !dirtyCopy.isEmpty()) {
+-        QWidgetPrivate::DrawWidgetFlags flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive;
++        QWidgetPrivate::DrawWidgetFlags flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive
++                | QWidgetPrivate::UseEffectRegionBounds;
+         tlw->d_func()->drawWidget(store->paintDevice(), dirtyCopy, QPoint(), flags, nullptr, this);
+     }
+ 
+diff --git a/qtbase/src/widgets/styles/qfusionstyle.cpp b/qtbase/src/widgets/styles/qfusionstyle.cpp
+index f4345d97c4..962912c838 100644
+--- a/qtbase/src/widgets/styles/qfusionstyle.cpp
++++ b/qtbase/src/widgets/styles/qfusionstyle.cpp
+@@ -1772,14 +1772,6 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio
+             proxy()->drawControl(CE_PushButtonLabel, &subopt, painter, widget);
+         }
+         break;
+-    case CE_PushButtonLabel:
+-        if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
+-            QStyleOptionButton b(*button);
+-            // no PM_ButtonShiftHorizontal and PM_ButtonShiftVertical for fusion style
+-            b.state &= ~(State_On | State_Sunken);
+-            QCommonStyle::drawControl(element, &b, painter, widget);
+-        }
+-        break;
+     case CE_MenuBarEmptyArea:
+         painter->save();
+     {
+diff --git a/qtbase/src/widgets/util/qcompleter.cpp b/qtbase/src/widgets/util/qcompleter.cpp
+index 18b24063d8..ef7207a8a3 100644
+--- a/qtbase/src/widgets/util/qcompleter.cpp
++++ b/qtbase/src/widgets/util/qcompleter.cpp
+@@ -1120,6 +1120,8 @@ void QCompleter::setModel(QAbstractItemModel *model)
+ {
+     Q_D(QCompleter);
+     QAbstractItemModel *oldModel = d->proxy->sourceModel();
++    if (oldModel == model)
++        return;
+ #if QT_CONFIG(filesystemmodel)
+     if (qobject_cast<const QFileSystemModel *>(oldModel))
+         setCompletionRole(Qt::EditRole); // QTBUG-54642, clear FileNameRole set by QFileSystemModel
+diff --git a/qtbase/src/widgets/widgets/qabstractbutton.cpp b/qtbase/src/widgets/widgets/qabstractbutton.cpp
+index a128b23950..dc40bf62fb 100644
+--- a/qtbase/src/widgets/widgets/qabstractbutton.cpp
++++ b/qtbase/src/widgets/widgets/qabstractbutton.cpp
+@@ -56,6 +56,7 @@
+ #ifndef QT_NO_ACCESSIBILITY
+ #include "qaccessible.h"
+ #endif
++#include <qpa/qplatformtheme.h>
+ 
+ #include <algorithm>
+ 
+@@ -1076,19 +1077,19 @@ void QAbstractButton::keyPressEvent(QKeyEvent *e)
+ {
+     Q_D(QAbstractButton);
+     bool next = true;
+-    switch (e->key()) {
+-    case Qt::Key_Enter:
+-    case Qt::Key_Return:
+-        e->ignore();
+-        break;
+-    case Qt::Key_Select:
+-    case Qt::Key_Space:
+-        if (!e->isAutoRepeat()) {
+-            setDown(true);
+-            repaint();
+-            d->emitPressed();
+-        }
+-        break;
++
++    const auto key = static_cast<Qt::Key>(e->key());
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(key) && !e->isAutoRepeat()) {
++        setDown(true);
++        repaint();
++        d->emitPressed();
++        return;
++    }
++
++    switch (key) {
+     case Qt::Key_Up:
+         next = false;
+         Q_FALLTHROUGH();
+@@ -1153,15 +1154,15 @@ void QAbstractButton::keyReleaseEvent(QKeyEvent *e)
+     if (!e->isAutoRepeat())
+         d->repeatTimer.stop();
+ 
+-    switch (e->key()) {
+-    case Qt::Key_Select:
+-    case Qt::Key_Space:
+-        if (!e->isAutoRepeat() && d->down)
+-            d->click();
+-        break;
+-    default:
+-        e->ignore();
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(static_cast<Qt::Key>(e->key())) && !e->isAutoRepeat() && d->down) {
++        d->click();
++        return;
+     }
++
++    e->ignore();
+ }
+ 
+ /*!\reimp
+diff --git a/qtbase/src/widgets/widgets/qcombobox.cpp b/qtbase/src/widgets/widgets/qcombobox.cpp
+index 7a496c27e0..0a3d96647b 100644
+--- a/qtbase/src/widgets/widgets/qcombobox.cpp
++++ b/qtbase/src/widgets/widgets/qcombobox.cpp
+@@ -3352,7 +3352,23 @@ void QComboBox::keyPressEvent(QKeyEvent *e)
+ 
+     Move move = NoMove;
+     int newIndex = currentIndex();
+-    switch (e->key()) {
++
++    bool pressLikeButton = !d->lineEdit;
++#ifdef QT_KEYPAD_NAVIGATION
++    pressLikeButton |= QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus();
++#endif
++    auto key = static_cast<Qt::Key>(e->key());
++    if (pressLikeButton) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(key)) {
++            showPopup();
++            return;
++        }
++    }
++
++    switch (key) {
+     case Qt::Key_Up:
+         if (e->modifiers() & Qt::ControlModifier)
+             break; // pass to line edit for auto completion
+@@ -3394,26 +3410,11 @@ void QComboBox::keyPressEvent(QKeyEvent *e)
+             return;
+         }
+         break;
+-    case Qt::Key_Space:
+-        if (!d->lineEdit) {
+-            showPopup();
+-            return;
+-        }
+-        break;
+-    case Qt::Key_Enter:
+-    case Qt::Key_Return:
+     case Qt::Key_Escape:
+         if (!d->lineEdit)
+             e->ignore();
+         break;
+ #ifdef QT_KEYPAD_NAVIGATION
+-    case Qt::Key_Select:
+-        if (QApplicationPrivate::keypadNavigationEnabled()
+-                && (!hasEditFocus() || !d->lineEdit)) {
+-            showPopup();
+-            return;
+-        }
+-        break;
+     case Qt::Key_Left:
+     case Qt::Key_Right:
+         if (QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus())
+diff --git a/qtbase/src/widgets/widgets/qdatetimeedit_p.h b/qtbase/src/widgets/widgets/qdatetimeedit_p.h
+index d36b6f8f9a..e0df5b5158 100644
+--- a/qtbase/src/widgets/widgets/qdatetimeedit_p.h
++++ b/qtbase/src/widgets/widgets/qdatetimeedit_p.h
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2018 The Qt Company Ltd.
++** Copyright (C) 2021 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtWidgets module of the Qt Toolkit.
+diff --git a/qtbase/src/widgets/widgets/qgroupbox.cpp b/qtbase/src/widgets/widgets/qgroupbox.cpp
+index 02a0bed325..3f3eccc370 100644
+--- a/qtbase/src/widgets/widgets/qgroupbox.cpp
++++ b/qtbase/src/widgets/widgets/qgroupbox.cpp
+@@ -54,6 +54,8 @@
+ #include "qaccessible.h"
+ #endif
+ #include <private/qwidget_p.h>
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
+ 
+ #include "qdebug.h"
+ 
+@@ -360,7 +362,10 @@ bool QGroupBox::event(QEvent *e)
+         return true;
+     case QEvent::KeyPress: {
+         QKeyEvent *k = static_cast<QKeyEvent*>(e);
+-        if (!k->isAutoRepeat() && (k->key() == Qt::Key_Select || k->key() == Qt::Key_Space)) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (!k->isAutoRepeat() && buttonPressKeys.contains(static_cast<Qt::Key>(k->key()))) {
+             d->pressedControl = QStyle::SC_GroupBoxCheckBox;
+             update(style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxCheckBox, this));
+             return true;
+@@ -369,7 +374,10 @@ bool QGroupBox::event(QEvent *e)
+     }
+     case QEvent::KeyRelease: {
+         QKeyEvent *k = static_cast<QKeyEvent*>(e);
+-        if (!k->isAutoRepeat() && (k->key() == Qt::Key_Select || k->key() == Qt::Key_Space)) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (!k->isAutoRepeat() && buttonPressKeys.contains(static_cast<Qt::Key>(k->key()))) {
+             bool toggle = (d->pressedControl == QStyle::SC_GroupBoxLabel
+                            || d->pressedControl == QStyle::SC_GroupBoxCheckBox);
+             d->pressedControl = QStyle::SC_None;
+diff --git a/qtbase/src/widgets/widgets/qlabel.cpp b/qtbase/src/widgets/widgets/qlabel.cpp
+index 30ff80cbb0..cf2605c17c 100644
+--- a/qtbase/src/widgets/widgets/qlabel.cpp
++++ b/qtbase/src/widgets/widgets/qlabel.cpp
+@@ -421,9 +421,6 @@ void QLabel::setPixmap(const QPixmap &pixmap)
+         d->pixmap = new QPixmap(pixmap);
+     }
+ 
+-    if (d->pixmap->depth() == 1 && !d->pixmap->mask())
+-        d->pixmap->setMask(*((QBitmap *)d->pixmap));
+-
+     d->updateLabel();
+ }
+ 
+diff --git a/qtbase/src/widgets/widgets/qtoolbararealayout.cpp b/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
+index 493c094cc1..d5f4b59017 100644
+--- a/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
++++ b/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
+@@ -1367,7 +1367,7 @@ bool QToolBarAreaLayout::restoreState(QDataStream &stream, const QList<QToolBar*
+                 item.widgetItem = new QWidgetItemV2(toolBar);
+                 toolBar->setOrientation(floating ? ((shown & 2) ? Qt::Vertical : Qt::Horizontal) : dock.o);
+                 toolBar->setVisible(shown & 1);
+-                toolBar->d_func()->setWindowState(floating, true, rect);
++                toolBar->d_func()->setWindowState(floating, false, rect);
+ 
+                 item.preferredSize = item.size;
+                 line.toolBarItems.append(item);
+diff --git a/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp b/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
+index 212c0a2e13..3c77b1ba0b 100644
+--- a/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
++++ b/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
+@@ -126,8 +126,7 @@ public:
+ 
+ void tst_QtConcurrentIterateKernel::instantiate()
+ {
+-    auto future = startThreadEngine(new PrintFor(0, 40)).startAsynchronously();
+-    future.waitForFinished();
++    startThreadEngine(new PrintFor(0, 40)).startBlocking();
+     QCOMPARE(iterations.loadRelaxed(), 40);
+ }
+ 
+@@ -166,10 +165,8 @@ void tst_QtConcurrentIterateKernel::stresstest()
+     const int times = 50;
+     for (int i = 0; i < times; ++i) {
+         counter.storeRelaxed(0);
+-        // ThreadEngine will delete f when it finishes
+-        auto f = new CountFor(0, iterations);
+-        auto future = f->startAsynchronously();
+-        future.waitForFinished();
++        CountFor f(0, iterations);
++        f.startBlocking();
+         QCOMPARE(counter.loadRelaxed(), iterations);
+     }
+ }
+@@ -177,11 +174,8 @@ void tst_QtConcurrentIterateKernel::stresstest()
+ void tst_QtConcurrentIterateKernel::noIterations()
+ {
+     const int times = 20000;
+-    for (int i = 0; i < times; ++i) {
+-        auto future = startThreadEngine(new IterateKernel<TestIterator, void>(0, 0))
+-                              .startAsynchronously();
+-        future.waitForFinished();
+-    }
++    for (int i = 0; i < times; ++i)
++        startThreadEngine(new IterateKernel<TestIterator, void>(0, 0)).startBlocking();
+ }
+ 
+ QMutex threadsMutex;
+@@ -236,10 +230,8 @@ void tst_QtConcurrentIterateKernel::throttling()
+ 
+     threads.clear();
+ 
+-    // ThreadEngine will delete f when it finishes
+-    auto f = new ThrottleFor(0, totalIterations);
+-    auto future = f->startAsynchronously();
+-    future.waitForFinished();
++    ThrottleFor f(0, totalIterations);
++    f.startBlocking();
+ 
+     QCOMPARE(iterations.loadRelaxed(), totalIterations);
+ 
+diff --git a/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp b/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
+index ac7be7acdd..81bc64c8d9 100644
+--- a/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
++++ b/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
+@@ -65,9 +65,16 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::runDirectly()
+ {
+-    PrintUser *engine = new PrintUser();
+-    QFuture<void> f = engine->startAsynchronously();
+-    f.waitForFinished();
++    {
++        PrintUser engine;
++        engine.startSingleThreaded();
++        engine.startBlocking();
++    }
++    {
++        PrintUser *engine = new PrintUser();
++        QFuture<void> f = engine->startAsynchronously();
++        f.waitForFinished();
++    }
+ }
+ 
+ class StringResultUser : public ThreadEngine<QString>
+@@ -99,10 +106,8 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::result()
+ {
+-    // ThreadEngine will delete 'engine' when it finishes
+-    auto engine = new StringResultUser();
+-    auto future = engine->startAsynchronously();
+-    QCOMPARE(future.result(), QString("Foo"));
++    StringResultUser engine;
++    QCOMPARE(*engine.startBlocking(), QString("Foo"));
+ }
+ 
+ class VoidResultUser : public ThreadEngine<void>
+@@ -128,9 +133,17 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::runThroughStarter()
+ {
+-    ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
+-    QFuture<QString> f = starter.startAsynchronously();
+-    QCOMPARE(f.result(), QString("Foo"));
++    {
++        ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
++        QFuture<QString>  f = starter.startAsynchronously();
++        QCOMPARE(f.result(), QString("Foo"));
++    }
++
++    {
++        ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
++        QString str = starter.startBlocking();
++        QCOMPARE(str, QString("Foo"));
++    }
+ }
+ 
+ class CancelUser : public ThreadEngine<void>
+@@ -213,6 +226,12 @@ void tst_QtConcurrentThreadEngine::throttle()
+         f.waitForFinished();
+         QCOMPARE(count.loadRelaxed(), 0);
+     }
++
++    for (int i = 0; i < repeats; ++i) {
++        ThrottleAlwaysUser t;
++        t.startBlocking();
++        QCOMPARE(count.loadRelaxed(), 0);
++    }
+ }
+ 
+ QSet<QThread *> threads;
+@@ -249,17 +268,35 @@ void tst_QtConcurrentThreadEngine::threadCount()
+ {
+     const int repeats = 10;
+     for (int i = 0; i < repeats; ++i) {
++        ThreadCountUser t;
++        t.startBlocking();
++        int count = threads.count();
++        int count_expected = QThreadPool::globalInstance()->maxThreadCount() + 1; // +1 for the main thread.
++        if (count != count_expected)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, count_expected);
++
+         (new ThreadCountUser())->startAsynchronously().waitForFinished();
+-        const auto count = threads.count();
+-        const auto maxThreadCount = QThreadPool::globalInstance()->maxThreadCount();
+-        QVERIFY(count <= maxThreadCount);
+-        QVERIFY(!threads.contains(QThread::currentThread()));
++        count = threads.count();
++        count_expected = QThreadPool::globalInstance()->maxThreadCount();
++        if (count != count_expected)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, count_expected);
+     }
+ 
+     // Set the finish flag immediately, this should give us one thread only.
+     for (int i = 0; i < repeats; ++i) {
++        ThreadCountUser t(true /*finishImmediately*/);
++        t.startBlocking();
++        int count = threads.count();
++        if (count != 1)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, 1);
++
+         (new ThreadCountUser(true /*finishImmediately*/))->startAsynchronously().waitForFinished();
+-        const auto count = threads.count();
++        count = threads.count();
++        if (count != 1)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
+         QCOMPARE(count, 1);
+         QVERIFY(!threads.contains(QThread::currentThread()));
+     }
+@@ -400,6 +437,7 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::exceptions()
+ {
++    // Asynchronous mode:
+     {
+         bool caught = false;
+         try  {
+@@ -412,6 +450,32 @@ void tst_QtConcurrentThreadEngine::exceptions()
+         QVERIFY2(caught, "did not get exception");
+     }
+ 
++    // Blocking mode:
++    // test throwing the exception from a worker thread.
++    {
++        bool caught = false;
++        try  {
++            QtConcurrentExceptionThrower e(QThread::currentThread());
++            e.startBlocking();
++        } catch (const QException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // test throwing the exception from the main thread (different code path)
++    {
++        bool caught = false;
++        try  {
++            QtConcurrentExceptionThrower e(0);
++            e.startBlocking();
++        } catch (const QException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // Asynchronous mode:
+     {
+         bool caught = false;
+         try  {
+@@ -423,6 +487,31 @@ void tst_QtConcurrentThreadEngine::exceptions()
+         }
+         QVERIFY2(caught, "did not get exception");
+     }
++
++    // Blocking mode:
++    // test throwing the exception from a worker thread.
++    {
++        bool caught = false;
++        try  {
++            UnrelatedExceptionThrower e(QThread::currentThread());
++            e.startBlocking();
++        } catch (const QUnhandledException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // test throwing the exception from the main thread (different code path)
++    {
++        bool caught = false;
++        try  {
++            UnrelatedExceptionThrower e(0);
++            e.startBlocking();
++        } catch (const QUnhandledException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
+ }
+ 
+ #endif
+diff --git a/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp b/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
+index 4968742110..f4c3fb711d 100644
+--- a/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
++++ b/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
+@@ -42,6 +42,7 @@ private slots:
+     void writeBlock_data();
+     void writeBlock();
+     void seek();
++    void invalidSeeks();
+     void seekTest_data();
+     void seekTest();
+     void read_rawdata();
+@@ -286,6 +287,29 @@ void tst_QBuffer::seek()
+     QCOMPARE(buffer.size(), pos);
+ }
+ 
++void tst_QBuffer::invalidSeeks()
++{
++    if constexpr (sizeof(qsizetype) == sizeof(qint64)) {
++        // sizeof(qsizetype) == sizeof(qint64), so +1 would overflow
++        QSKIP("This is a 32-bit-only test.");
++    } else {
++        QBuffer buffer;
++        buffer.open(QIODevice::WriteOnly);
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++        constexpr qint64 MaxQByteArrayCapacity = (std::numeric_limits<qsizetype>::max)();
++        // this should fail fast, not after trying to allocate nearly 2 GiB of data,
++        // potentially crashing in the process:
++        QVERIFY(!buffer.seek(2 * MaxQByteArrayCapacity - 1));
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++        // ditto:
++        QVERIFY(!buffer.seek(MaxQByteArrayCapacity + 1));
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++    }
++}
++
+ void tst_QBuffer::seekTest_data()
+ {
+     writeBlock_data();
+diff --git a/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp b/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
+index da5327594c..4a04e0f7c6 100644
+--- a/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
++++ b/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
+@@ -561,7 +561,8 @@ protected:
+     qint64 readData(char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf->size() - offset));
+-        memcpy(data, buf->constData() + offset, maxSize);
++        if (maxSize > 0)
++            memcpy(data, buf->constData() + offset, maxSize);
+         offset += maxSize;
+         return maxSize;
+     }
+@@ -604,13 +605,15 @@ protected:
+     qint64 readData(char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf.size() - pos()));
+-        memcpy(data, buf.constData() + pos(), maxSize);
++        if (maxSize > 0)
++            memcpy(data, buf.constData() + pos(), maxSize);
+         return maxSize;
+     }
+     qint64 writeData(const char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf.size() - pos()));
+-        memcpy(buf.data() + pos(), data, maxSize);
++        if (maxSize > 0)
++            memcpy(buf.data() + pos(), data, maxSize);
+         return maxSize;
+     }
+ 
+diff --git a/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+index db60bead64..f345a44414 100644
+--- a/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
++++ b/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+@@ -1,7 +1,8 @@
+ /****************************************************************************
+ **
+ ** Copyright (C) 2021 The Qt Company Ltd.
+-** Copyright (C) 2020 Intel Corporation.
++** Copyright (C) 2020 The Qt Company Ltd.
++** Copyright (C) 2022 Intel Corporation.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the test suite of the Qt Toolkit.
+@@ -150,6 +151,8 @@ private slots:
+     void startStopStartStopBuffers();
+     void processEventsInAReadyReadSlot_data();
+     void processEventsInAReadyReadSlot();
++    void startFromCurrentWorkingDir_data();
++    void startFromCurrentWorkingDir();
+ 
+     // keep these at the end, since they use lots of processes and sometimes
+     // caused obscure failures to occur in tests that followed them (esp. on the Mac)
+@@ -2731,5 +2734,94 @@ void tst_QProcess::finishProcessBeforeReadingDone_deprecated()
+ 
+ #endif
+ 
++enum class ChdirMode {
++    None = 0,
++    InParent,
++    InChild
++};
++Q_DECLARE_METATYPE(ChdirMode)
++
++void tst_QProcess::startFromCurrentWorkingDir_data()
++{
++    qRegisterMetaType<ChdirMode>();
++    QTest::addColumn<QString>("programPrefix");
++    QTest::addColumn<ChdirMode>("chdirMode");
++    QTest::addColumn<bool>("success");
++
++    constexpr bool IsWindows = true
++#ifdef Q_OS_UNIX
++            && false
++#endif
++            ;
++
++    // baseline: trying to execute the directory, this can't possibly succeed!
++    QTest::newRow("plain-same-cwd") << QString() << ChdirMode::None << false;
++
++    // cross-platform behavior: neither OS searches the setWorkingDirectory()
++    // dir without "./"
++    QTest::newRow("plain-child-chdir") << QString() << ChdirMode::InChild << false;
++
++    // cross-platform behavior: both OSes search the parent's CWD with "./"
++    QTest::newRow("prefixed-parent-chdir") << "./" << ChdirMode::InParent << true;
++
++    // opposite behaviors: Windows searches the parent's CWD and Unix searches
++    // the child's with "./"
++    QTest::newRow("prefixed-child-chdir") << "./" << ChdirMode::InChild << !IsWindows;
++
++    // Windows searches the parent's CWD without "./"
++    QTest::newRow("plain-parent-chdir") << QString() << ChdirMode::InParent << IsWindows;
++}
++
++void tst_QProcess::startFromCurrentWorkingDir()
++{
++    QFETCH(QString, programPrefix);
++    QFETCH(ChdirMode, chdirMode);
++    QFETCH(bool, success);
++
++    QProcess process;
++    qRegisterMetaType<QProcess::ProcessError>();
++    QSignalSpy errorSpy(&process, &QProcess::errorOccurred);
++    QVERIFY(errorSpy.isValid());
++
++    // both the dir name and the executable name
++    const QString target = QStringLiteral("testProcessNormal");
++    process.setProgram(programPrefix + target);
++
++#ifdef Q_OS_UNIX
++    // Reset PATH, to be sure it doesn't contain . or the empty path.
++    // We can't do this on Windows because DLLs are searched in PATH
++    // and Windows always searches "." anyway.
++    auto restoreEnv = qScopeGuard([old = qgetenv("PATH")] {
++        qputenv("PATH", old);
++    });
++    qputenv("PATH", "/");
++#endif
++
++    switch (chdirMode) {
++    case ChdirMode::InParent: {
++        auto restoreCwd = qScopeGuard([old = QDir::currentPath()] {
++            QDir::setCurrent(old);
++        });
++        QVERIFY(QDir::setCurrent(target));
++        process.start();
++        break;
++    }
++    case ChdirMode::InChild:
++        process.setWorkingDirectory(target);
++        Q_FALLTHROUGH();
++    case ChdirMode::None:
++        process.start();
++        break;
++    }
++
++    QCOMPARE(process.waitForStarted(), success);
++    QCOMPARE(errorSpy.count(), int(!success));
++    if (success) {
++        QVERIFY(process.waitForFinished());
++    } else {
++        QCOMPARE(process.error(), QProcess::FailedToStart);
++    }
++}
++
+ QTEST_MAIN(tst_QProcess)
+ #include "tst_qprocess.moc"
+diff --git a/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp b/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp
+index e1ea7a4552..90972caa57 100644
+--- a/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp
++++ b/qtbase/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"
+diff --git a/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+index 9bd66c0835..ed4a0bae5d 100644
+--- a/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
++++ b/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+@@ -158,6 +158,7 @@ private slots:
+     void nullReceiver();
+     void functorReferencesConnection();
+     void disconnectDisconnects();
++    void declarativeData();
+ };
+ 
+ struct QObjectCreatedOnShutdown
+@@ -7679,5 +7680,81 @@ void tst_QObject::disconnectDisconnects()
+ Q_STATIC_ASSERT(QtPrivate::HasQ_OBJECT_Macro<tst_QObject>::Value);
+ Q_STATIC_ASSERT(!QtPrivate::HasQ_OBJECT_Macro<SiblingDeleter>::Value);
+ 
++#ifdef QT_BUILD_INTERNAL
++/*
++    Since QObjectPrivate stores the declarativeData pointer in a union with the pointer
++    to the currently destroyed child, calls to the QtDeclarative handlers need to be
++    correctly guarded. QTBUG-105286
++*/
++namespace QtDeclarative {
++static QAbstractDeclarativeData *theData;
++
++static void destroyed(QAbstractDeclarativeData *data, QObject *)
++{
++    QCOMPARE(data, theData);
++}
++static void signalEmitted(QAbstractDeclarativeData *data, QObject *, int, void **)
++{
++    QCOMPARE(data, theData);
++}
++// we can't use QCOMPARE in the next two functions, as they don't return void
++static int receivers(QAbstractDeclarativeData *data, const QObject *, int)
++{
++    QTest::qCompare(data, theData, "data", "theData", __FILE__, __LINE__);
++    return 0;
++}
++static bool isSignalConnected(QAbstractDeclarativeData *data, const QObject *, int)
++{
++    QTest::qCompare(data, theData, "data", "theData", __FILE__, __LINE__);
++    return true;
++}
++
++class Object : public QObject
++{
++    Q_OBJECT
++public:
++    using QObject::QObject;
++    ~Object()
++    {
++        if (Object *p = static_cast<Object *>(parent()))
++            p->emitSignal();
++    }
++
++    void emitSignal()
++    {
++        emit theSignal();
++    }
++
++signals:
++    void theSignal();
++};
++
++}
++#endif
++
++void tst_QObject::declarativeData()
++{
++#ifdef QT_BUILD_INTERNAL
++    QScopedValueRollback destroyed(QAbstractDeclarativeData::destroyed,
++                                   QtDeclarative::destroyed);
++    QScopedValueRollback signalEmitted(QAbstractDeclarativeData::signalEmitted,
++                                       QtDeclarative::signalEmitted);
++    QScopedValueRollback receivers(QAbstractDeclarativeData::receivers,
++                                   QtDeclarative::receivers);
++    QScopedValueRollback isSignalConnected(QAbstractDeclarativeData::isSignalConnected,
++                                           QtDeclarative::isSignalConnected);
++
++    QtDeclarative::Object p;
++    QObjectPrivate *priv = QObjectPrivate::get(&p);
++    priv->declarativeData = QtDeclarative::theData = new QAbstractDeclarativeData;
++
++    connect(&p, &QtDeclarative::Object::theSignal, &p, []{
++    });
++
++    QtDeclarative::Object *child = new QtDeclarative::Object;
++    child->setParent(&p);
++#endif
++}
++
+ QTEST_MAIN(tst_QObject)
+ #include "tst_qobject.moc"
+diff --git a/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp b/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
+index 0ea422ecbc..1a3256534b 100644
+--- a/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
++++ b/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
+@@ -70,15 +70,15 @@ static inline QString testSuiteWarning()
+ 
+     QString result;
+     QTextStream str(&result);
+-    str << "\nCannot find the shared-mime-info test suite\nstarting from: "
++    str << "\nCannot find the shared-mime-info test suite\nin the parent of: "
+         << QDir::toNativeSeparators(QDir::currentPath()) << "\n"
+            "cd " << QDir::toNativeSeparators(QStringLiteral("tests/auto/corelib/mimetypes/qmimedatabase")) << "\n"
+-           "wget http://cgit.freedesktop.org/xdg/shared-mime-info/snapshot/Release-1-10.zip\n"
+-           "unzip Release-1-10.zip\n";
++           "wget https://gitlab.freedesktop.org/xdg/shared-mime-info/-/archive/2.1/shared-mime-info-2.1.zip\n"
++           "unzip shared-mime-info-2.1.zip\n";
+ #ifdef Q_OS_WIN
+-    str << "mkdir testfiles\nxcopy /s Release-1-10 s-m-i\n";
++    str << "mkdir testfiles\nxcopy /s shared-mime-info-2.1 s-m-i\n";
+ #else
+-    str << "ln -s Release-1-10 s-m-i\n";
++    str << "ln -s shared-mime-info-2.1 s-m-i\n";
+ #endif
+     return result;
+ }
+@@ -154,7 +154,7 @@ void tst_QMimeDatabase::initTestCase()
+     QVERIFY2(copyResourceFile(xmlFileName, xmlTargetFileName, &errorMessage), qPrintable(errorMessage));
+ #endif
+ 
+-    m_testSuite = QFINDTESTDATA("s-m-i/tests");
++    m_testSuite = QFINDTESTDATA("s-m-i/tests/mime-detection");
+     if (m_testSuite.isEmpty())
+         qWarning("%s", qPrintable(testSuiteWarning()));
+ 
+@@ -611,7 +611,7 @@ void tst_QMimeDatabase::allMimeTypes()
+     QVERIFY(!lst.isEmpty());
+ 
+     // Hardcoding this is the only way to check both providers find the same number of mimetypes.
+-    QCOMPARE(lst.count(), 779);
++    QCOMPARE(lst.count(), 811);
+ 
+     foreach (const QMimeType &mime, lst) {
+         const QString name = mime.name();
+@@ -631,10 +631,9 @@ void tst_QMimeDatabase::suffixes_data()
+ 
+     QTest::newRow("mimetype with a single pattern") << "application/pdf" << "*.pdf" << "pdf";
+     QTest::newRow("mimetype with multiple patterns") << "application/x-kpresenter" << "*.kpr;*.kpt" << "kpr";
+-    QTest::newRow("jpeg") << "image/jpeg" << "*.jpe;*.jpg;*.jpeg" << "jpeg";
+-    //if (KMimeType::sharedMimeInfoVersion() > KDE_MAKE_VERSION(0, 60, 0)) {
+-        QTest::newRow("mimetype with many patterns") << "application/vnd.wordperfect" << "*.wp;*.wp4;*.wp5;*.wp6;*.wpd;*.wpp" << "wp";
+-    //}
++    // The preferred suffix for image/jpeg is *.jpg, as per https://bugs.kde.org/show_bug.cgi?id=176737
++    QTest::newRow("jpeg") << "image/jpeg" << "*.jpe;*.jpg;*.jpeg" << "jpg";
++    QTest::newRow("mimetype with many patterns") << "application/vnd.wordperfect" << "*.wp;*.wp4;*.wp5;*.wp6;*.wpd;*.wpp" << "wp";
+     QTest::newRow("oasis text mimetype") << "application/vnd.oasis.opendocument.text" << "*.odt" << "odt";
+     QTest::newRow("oasis presentation mimetype") << "application/vnd.oasis.opendocument.presentation" << "*.odp" << "odp";
+     QTest::newRow("mimetype with multiple patterns") << "text/plain" << "*.asc;*.txt;*,v" << "txt";
+diff --git a/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp b/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
+index 3e58dd03cc..c8f82ef5d5 100644
+--- a/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
++++ b/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
+@@ -176,6 +176,8 @@ private Q_SLOTS:
+     void fromToVariantConversions_data();
+     void fromToVariantConversions();
+ 
++    void noLeakOnNameClash();
++
+ private:
+     QString testDataDir;
+ };
+@@ -3685,5 +3687,23 @@ void tst_QtJson::fromToVariantConversions()
+     }
+ }
+ 
++void tst_QtJson::noLeakOnNameClash()
++{
++    QJsonDocument doc = QJsonDocument::fromJson("{\"\":{\"\":0},\"\":0}");
++    QVERIFY(!doc.isNull());
++    const QJsonObject obj = doc.object();
++
++    // Removed the duplicate key.
++    QCOMPARE(obj.length(), 1);
++
++    // Retained the last of the duplicates.
++    const QJsonValue val = obj.begin().value();
++    QVERIFY(val.isDouble());
++    QCOMPARE(val.toDouble(), 0.0);
++
++    // It should not leak.
++    // In particular it should not forget to deref the container for the inner object.
++}
++
+ QTEST_MAIN(tst_QtJson)
+ #include "tst_qtjson.moc"
+diff --git a/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp b/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
+index a59b58d57f..241c3e84ac 100644
+--- a/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
++++ b/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
+@@ -63,6 +63,7 @@ private slots:
+     void isValidId_data();
+     void isValidId();
+     void malformed();
++    void serialize();
+     // Backend tests
+     void utcTest();
+     void icuTest();
+@@ -947,6 +948,33 @@ void tst_QTimeZone::malformed()
+         barf.offsetFromUtc(now);
+ }
+ 
++void tst_QTimeZone::serialize()
++{
++    int parts = 0;
++#ifndef QT_NO_DEBUG_STREAM
++    qDebug() << QTimeZone(); // to verify no crash
++    parts++;
++#endif
++#ifndef QT_NO_DATASTREAM
++    QByteArray blob;
++    {
++        QDataStream stream(&blob, QIODevice::WriteOnly);
++        stream << QTimeZone("Europe/Oslo") << QTimeZone(420) << QTimeZone() << qint64(-1);
++    }
++    QDataStream stream(&blob, QIODevice::ReadOnly);
++    QTimeZone invalid, offset, oslo;
++    qint64 minusone;
++    stream >> oslo >> offset >> invalid >> minusone;
++    QCOMPARE(oslo, QTimeZone("Europe/Oslo"));
++    QCOMPARE(offset, QTimeZone(420));
++    QVERIFY(!invalid.isValid());
++    QCOMPARE(minusone, qint64(-1));
++    parts++;
++#endif
++    if (!parts)
++        QSKIP("No serialization enabled");
++}
++
+ void tst_QTimeZone::utcTest()
+ {
+ #ifdef QT_BUILD_INTERNAL
+diff --git a/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp b/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
+index 05480c6dd2..70f4c75756 100644
+--- a/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
++++ b/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
+@@ -324,6 +324,13 @@ void tst_QDBusInterface::notValid()
+ 
+     QVERIFY(!interface.isValid());
+     QVERIFY(!QMetaObject::invokeMethod(&interface, "ListNames", Qt::DirectConnection));
++
++    // With a connection, but empty/null service and path specified
++    QDBusConnection con = QDBusConnection::sessionBus();
++    QVERIFY(con.isConnected());
++    QDBusInterface iface({}, {}, {}, con);
++    QVERIFY(!iface.isValid());
++    QVERIFY(!QMetaObject::invokeMethod(&interface, "ListNames", Qt::DirectConnection));
+ }
+ 
+ void tst_QDBusInterface::notValidDerived()
+diff --git a/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp b/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
+index 874468c954..04ceb4ab65 100644
+--- a/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
++++ b/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
+@@ -507,6 +507,10 @@ void tst_QKeySequence::toStringFromKeycode_data()
+     QTest::newRow("Ctrl+Alt+Num+Del") << QKeySequence(Qt::ControlModifier | Qt::AltModifier | Qt::KeypadModifier | Qt::Key_Delete) << "Ctrl+Alt+Num+Del";
+     QTest::newRow("Ctrl+Ins") << QKeySequence(Qt::ControlModifier | Qt::Key_Insert) << "Ctrl+Ins";
+     QTest::newRow("Ctrl+Num+Ins(1)") << QKeySequence(Qt::Key_Insert | Qt::KeypadModifier | Qt::ControlModifier) << "Ctrl+Num+Ins";
++    QTest::newRow("Ctrl") << QKeySequence(Qt::Key_Control) << "Control";
++    QTest::newRow("Alt") << QKeySequence(Qt::Key_Alt) << "Alt";
++    QTest::newRow("Shift") << QKeySequence(Qt::Key_Shift) << "Shift";
++    QTest::newRow("Meta") << QKeySequence(Qt::Key_Meta) << "Meta";
+ }
+ 
+ void tst_QKeySequence::toStringFromKeycode()
+diff --git a/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp b/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+index 15e0ecadaa..b4eca74283 100644
+--- a/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
++++ b/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+@@ -81,6 +81,8 @@ private slots:
+     void registerOpenTypePreferredNamesSystem();
+     void registerOpenTypePreferredNamesApplication();
+ 
++    void stretchRespected();
++
+ private:
+     QString m_ledFont;
+     QString m_testFont;
+@@ -355,6 +357,28 @@ static QString testString()
+     return QStringLiteral("foo bar");
+ }
+ 
++void tst_QFontDatabase::stretchRespected()
++{
++    int italicId = QFontDatabase::addApplicationFont(m_testFontItalic);
++    QVERIFY(italicId != -1);
++
++    QVERIFY(!QFontDatabase::applicationFontFamilies(italicId).isEmpty());
++
++    QString italicFontName = QFontDatabase::applicationFontFamilies(italicId).first();
++
++    QFont italicFont = QFontDatabase().font(italicFontName,
++                                            QString::fromLatin1("Italic"), 14);
++    QVERIFY(italicFont.italic());
++
++    QFont italicStretchedFont = italicFont;
++    italicStretchedFont.setStretch( 400 );
++
++    QVERIFY(QFontMetricsF(italicFont).horizontalAdvance(QStringLiteral("foobar")) <
++            QFontMetricsF(italicStretchedFont).horizontalAdvance(QStringLiteral("foobar")));
++
++    QFontDatabase::removeApplicationFont(italicId);
++}
++
+ void tst_QFontDatabase::condensedFontWidthNoFontMerging()
+ {
+     int regularFontId = QFontDatabase::addApplicationFont(m_testFont);
+diff --git a/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+index 3d4a094c43..b423e11a99 100644
+--- a/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
++++ b/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+@@ -281,6 +281,7 @@ private Q_SLOTS:
+     void ioGetFromFileSpecial();
+     void ioGetFromFile_data();
+     void ioGetFromFile();
++    void ioGetFromFileUrl();
+     void ioGetFromFtp_data();
+     void ioGetFromFtp();
+     void ioGetFromFtpWithReuse();
+@@ -3300,6 +3301,18 @@ void tst_QNetworkReply::ioGetFromFile()
+     QCOMPARE(reader.data, data);
+ }
+ 
++void tst_QNetworkReply::ioGetFromFileUrl()
++{
++    // This immediately fails on non-windows platforms:
++    QNetworkRequest request(QUrl("file://unc-server/some/path"));
++    QNetworkReplyPtr reply(manager.get(request));
++    QSignalSpy finishedSpy(reply.get(), &QNetworkReply::finished);
++    // QTBUG-105618: This would, on non-Windows platforms, never happen because the signal
++    // was emitted before the constructor finished, leaving no chance at all to connect to the
++    // signal
++    QVERIFY(finishedSpy.wait());
++}
++
+ void tst_QNetworkReply::ioGetFromFtp_data()
+ {
+     QTest::addColumn<QString>("fileName");
+diff --git a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
+index 069fa6b341..4cc4d9a5ea 100644
+--- a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
++++ b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
+@@ -1,75 +1,34 @@
+-Certificate:
+-    Data:
+-        Version: 3 (0x2)
+-        Serial Number: 0 (0x0)
+-        Signature Algorithm: sha1WithRSAEncryption
+-        Issuer: C=NO, ST=Oslo, L=Nydalen, O=Nokia Corporation and/or its subsidiary(-ies), OU=Development, CN=fluke.troll.no/emailAddress=ahanssen@trolltech.com
+-        Validity
+-            Not Before: Dec  4 01:10:32 2007 GMT
+-            Not After : Apr 21 01:10:32 2035 GMT
+-        Subject: C=NO, ST=Oslo, O=Nokia Corporation and/or its subsidiary(-ies), OU=Development, CN=fluke.troll.no
+-        Subject Public Key Info:
+-            Public Key Algorithm: rsaEncryption
+-            RSA Public Key: (1024 bit)
+-                Modulus (1024 bit):
+-                    00:a7:c8:a0:4a:c4:19:05:1b:66:ba:32:e2:d2:f1:
+-                    1c:6f:17:82:e4:39:2e:01:51:90:db:04:34:32:11:
+-                    21:c2:0d:6f:59:d8:53:90:54:3f:83:8f:a9:d3:b3:
+-                    d5:ee:1a:9b:80:ae:c3:25:c9:5e:a5:af:4b:60:05:
+-                    aa:a0:d1:91:01:1f:ca:04:83:e3:58:1c:99:32:45:
+-                    84:70:72:58:03:98:4a:63:8b:41:f5:08:49:d2:91:
+-                    02:60:6b:e4:64:fe:dd:a0:aa:74:08:e9:34:4c:91:
+-                    5f:12:3d:37:4d:54:2c:ad:7f:5b:98:60:36:02:8c:
+-                    3b:f6:45:f3:27:6a:9b:94:9d
+-                Exponent: 65537 (0x10001)
+-        X509v3 extensions:
+-            X509v3 Basic Constraints: 
+-                CA:FALSE
+-            Netscape Comment: 
+-                OpenSSL Generated Certificate
+-            X509v3 Subject Key Identifier: 
+-                21:85:04:3D:23:01:66:E5:F7:9F:1A:84:24:8A:AF:0A:79:F4:E5:AC
+-            X509v3 Authority Key Identifier: 
+-                DirName:/C=NO/ST=Oslo/L=Nydalen/O=Nokia Corporation and/or its subsidiary(-ies)/OU=Development/CN=fluke.troll.no/emailAddress=ahanssen@trolltech.com
+-                serial:8E:A8:B4:E8:91:B7:54:2E
+-
+-    Signature Algorithm: sha1WithRSAEncryption
+-        6d:57:5f:d1:05:43:f0:62:05:ec:2a:71:a5:dc:19:08:f2:c4:
+-        a6:bd:bb:25:d9:ca:89:01:0e:e4:cf:1f:c1:8c:c8:24:18:35:
+-        53:59:7b:c0:43:b4:32:e6:98:b2:a6:ef:15:05:0b:48:5f:e1:
+-        a0:0c:97:a9:a1:77:d8:35:18:30:bc:a9:8f:d3:b7:54:c7:f1:
+-        a9:9e:5d:e6:19:bf:f6:3c:5b:2b:d8:e4:3e:62:18:88:8b:d3:
+-        24:e1:40:9b:0c:e6:29:16:62:ab:ea:05:24:70:36:aa:55:93:
+-        ef:02:81:1b:23:10:a2:04:eb:56:95:75:fc:f8:94:b1:5d:42:
+-        c5:3f:36:44:85:5d:3a:2e:90:46:8a:a2:b9:6f:87:ae:0c:15:
+-        40:19:31:90:fc:3b:25:bb:ae:f1:66:13:0d:85:90:d9:49:34:
+-        8f:f2:5d:f9:7a:db:4d:5d:27:f6:76:9d:35:8c:06:a6:4c:a3:
+-        b1:b2:b6:6f:1d:d7:a3:00:fd:72:eb:9e:ea:44:a1:af:21:34:
+-        7d:c7:42:e2:49:91:19:8b:c0:ad:ba:82:80:a8:71:70:f4:35:
+-        31:91:63:84:20:95:e9:60:af:64:8b:cc:ff:3d:8a:76:74:3d:
+-        c8:55:6d:e4:8e:c3:2b:1c:e8:42:18:ae:9f:e6:6b:9c:34:06:
+-        ec:6a:f2:c3
+ -----BEGIN CERTIFICATE-----
+-MIIEEzCCAvugAwIBAgIBADANBgkqhkiG9w0BAQUFADCBnDELMAkGA1UEBhMCTk8x
+-DTALBgNVBAgTBE9zbG8xEDAOBgNVBAcTB055ZGFsZW4xFjAUBgNVBAoTDVRyb2xs
+-dGVjaCBBU0ExFDASBgNVBAsTC0RldmVsb3BtZW50MRcwFQYDVQQDEw5mbHVrZS50
+-cm9sbC5ubzElMCMGCSqGSIb3DQEJARYWYWhhbnNzZW5AdHJvbGx0ZWNoLmNvbTAe
+-Fw0wNzEyMDQwMTEwMzJaFw0zNTA0MjEwMTEwMzJaMGMxCzAJBgNVBAYTAk5PMQ0w
+-CwYDVQQIEwRPc2xvMRYwFAYDVQQKEw1Ucm9sbHRlY2ggQVNBMRQwEgYDVQQLEwtE
+-ZXZlbG9wbWVudDEXMBUGA1UEAxMOZmx1a2UudHJvbGwubm8wgZ8wDQYJKoZIhvcN
+-AQEBBQADgY0AMIGJAoGBAKfIoErEGQUbZroy4tLxHG8XguQ5LgFRkNsENDIRIcIN
+-b1nYU5BUP4OPqdOz1e4am4CuwyXJXqWvS2AFqqDRkQEfygSD41gcmTJFhHByWAOY
+-SmOLQfUISdKRAmBr5GT+3aCqdAjpNEyRXxI9N01ULK1/W5hgNgKMO/ZF8ydqm5Sd
+-AgMBAAGjggEaMIIBFjAJBgNVHRMEAjAAMCwGCWCGSAGG+EIBDQQfFh1PcGVuU1NM
+-IEdlbmVyYXRlZCBDZXJ0aWZpY2F0ZTAdBgNVHQ4EFgQUIYUEPSMBZuX3nxqEJIqv
+-Cnn05awwgbsGA1UdIwSBszCBsKGBoqSBnzCBnDELMAkGA1UEBhMCTk8xDTALBgNV
+-BAgTBE9zbG8xEDAOBgNVBAcTB055ZGFsZW4xFjAUBgNVBAoTDVRyb2xsdGVjaCBB
+-U0ExFDASBgNVBAsTC0RldmVsb3BtZW50MRcwFQYDVQQDEw5mbHVrZS50cm9sbC5u
+-bzElMCMGCSqGSIb3DQEJARYWYWhhbnNzZW5AdHJvbGx0ZWNoLmNvbYIJAI6otOiR
+-t1QuMA0GCSqGSIb3DQEBBQUAA4IBAQBtV1/RBUPwYgXsKnGl3BkI8sSmvbsl2cqJ
+-AQ7kzx/BjMgkGDVTWXvAQ7Qy5piypu8VBQtIX+GgDJepoXfYNRgwvKmP07dUx/Gp
+-nl3mGb/2PFsr2OQ+YhiIi9Mk4UCbDOYpFmKr6gUkcDaqVZPvAoEbIxCiBOtWlXX8
+-+JSxXULFPzZEhV06LpBGiqK5b4euDBVAGTGQ/Dslu67xZhMNhZDZSTSP8l35ettN
+-XSf2dp01jAamTKOxsrZvHdejAP1y657qRKGvITR9x0LiSZEZi8CtuoKAqHFw9DUx
+-kWOEIJXpYK9ki8z/PYp2dD3IVW3kjsMrHOhCGK6f5mucNAbsavLD
++MIIF6zCCA9OgAwIBAgIUfo9amJtJGWqWE6f+SkAO85zkGr4wDQYJKoZIhvcNAQEL
++BQAwgYMxCzAJBgNVBAYTAk5PMQ0wCwYDVQQIDARPc2xvMQ0wCwYDVQQHDARPc2xv
++MRcwFQYDVQQKDA5UaGUgUXQgQ29tcGFueTEMMAoGA1UECwwDUiZEMRIwEAYDVQQD
++DAlIMiBUZXN0ZXIxGzAZBgkqhkiG9w0BCQEWDG1pbmltaUBxdC5pbzAgFw0yMDEw
++MjYxMjAxMzFaGA8yMTIwMTAwMjEyMDEzMVowgYMxCzAJBgNVBAYTAk5PMQ0wCwYD
++VQQIDARPc2xvMQ0wCwYDVQQHDARPc2xvMRcwFQYDVQQKDA5UaGUgUXQgQ29tcGFu
++eTEMMAoGA1UECwwDUiZEMRIwEAYDVQQDDAlIMiBUZXN0ZXIxGzAZBgkqhkiG9w0B
++CQEWDG1pbmltaUBxdC5pbzCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIB
++AOiUp5+E4blouKH7q+rVNR8NoYX2XkBW+q+rpy1zu5ssRSzbqxAjDx9dkht7Qlnf
++VlDT00JvpOWdeuPon5915edQRsY4Unl6mKH29ra3OtUa1/yCJXsGVJTKCj7k4Bxb
++5mZzb/fTlZntMLdTIBMfUbw62FKir1WjKIcJ9fCoG8JaGeKVO4Rh5p0ezd4UUUId
++r1BXl5Nqdqy2vTMsEDnjOsD3egkv8I2SKN4O6n/C3wWYpMOWYZkGoZiKz7rJs/i/
++ez7bsV7JlwdzTlhpJzkcOSVFBP6JlEOxTNNxZ1wtKy7PtZGmsSSATq2e6+bw38Ae
++Op0XnzzqcGjtDDofBmT7OFzZWjS9VZS6+DOOe2QHWle1nCHcHyH4ku6IRlsr9xkR
++NAIlOfnvHHxqJUenoeaZ4oQDjCBKS1KXygJO/tL7BLTQVn/xK1EmPvKNnjzWk4tR
++PnibUhhs5635qpOU/YPqFBh1JjVruZbsWcDAhRcew0uxONXOa9E+4lttQ9ySYa1A
++LvWqJuAX7gu2BsBMLyqfm811YnA7CIFMyO+HlqmkLFfv5L/xIRAXR7l26YGO0VwX
++CGjMfz4NVPMMke4nB7qa9NkpXQBQKMms3Qzd5JW0Hy9Ruj5O8GPcFZmV0twjd1uJ
++PD/cAjkWLaXjdNsJ16QWc2nghQRS6HYqKRX6j+CXOxupAgMBAAGjUzBRMB0GA1Ud
++DgQWBBRSCOU58j9NJZkMamt623qyCrhN3TAfBgNVHSMEGDAWgBRSCOU58j9NJZkM
++amt623qyCrhN3TAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4ICAQCq
++q4jxsWeNDv5Nq14hJtF9HB+ZL64zcZtRjJP1YgNs0QppKICmjPOL2nIMGmI/jKrs
++0eGAL/9XXNVHPxm1OPOncvimMMmU6emZfpMdEtTfKP43+Pg9HgKRjLoQp406vGeQ
++8ki/mbBhrItVPgEm3tu2AFA02XTYi+YxCI9kRZLGkM3FbgtOuTLPl0Z9y+kiPc9F
++uCSC03anBEqv+vDSI8+wODymQ/IJ3Jyz1lxIRDfp4qAekmy0jU2c91VOHHEmOmqq
++kqygGFRdwbe99m9yP63r6q0b5K3X2UnJ6bns0hmTwThYwpVPXLU8jdaTddbMukN2
++/Ef96Tsw8nWOEOPMySHOTIPgwyZRp26b0kA9EmhLwOP401SxXVQCmSRmtwNagmtg
++jJKmZoYBN+//D45ibK8z6Q0oOm9P+Whf/uUXehcRxBxyV3xz7k0wKGQbHj/ddwcy
++IUoIN4lrAlib+lK170kTKN352PDmrpo2gmIzPEsfurKAIMSelDl6H+kih16BtZ8y
++Nz6fh9Soqrg3OSAware8pxV7k51crBMoPLN78KoRV8MFCK4K7Fddq4rRISq6hiXq
++r1nsjoEPuKM9huprmZVZe9t5YcDa2I+wb3IiE3uwpZbAdaLDyQ5n6F/qpsiIkZXn
++gtcF7oqpG5oYrwCcZ53y/ezUgUg7PlSz2XwAGvQtgg==
+ -----END CERTIFICATE-----
+diff --git a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
+index 9d1664d609..337ce541a6 100644
+--- a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
++++ b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
+@@ -1,15 +1,52 @@
+------BEGIN RSA PRIVATE KEY-----
+-MIICXAIBAAKBgQCnyKBKxBkFG2a6MuLS8RxvF4LkOS4BUZDbBDQyESHCDW9Z2FOQ
+-VD+Dj6nTs9XuGpuArsMlyV6lr0tgBaqg0ZEBH8oEg+NYHJkyRYRwclgDmEpji0H1
+-CEnSkQJga+Rk/t2gqnQI6TRMkV8SPTdNVCytf1uYYDYCjDv2RfMnapuUnQIDAQAB
+-AoGANFzLkanTeSGNFM0uttBipFT9F4a00dqHz6JnO7zXAT26I5r8sU1pqQBb6uLz
+-/+Qz5Zwk8RUAQcsMRgJetuPQUb0JZjF6Duv24hNazqXBCu7AZzUenjafwmKC/8ri
+-KpX3fTwqzfzi//FKGgbXQ80yykSSliDL3kn/drATxsLCgQECQQDXhEFWLJ0vVZ1s
+-1Ekf+3NITE+DR16X+LQ4W6vyEHAjTbaNWtcTKdAWLA2l6N4WAAPYSi6awm+zMxx4
+-VomVTsjdAkEAx0z+e7natLeFcrrq8pbU+wa6SAP1VfhQWKitxL1e7u/QO90NCpxE
+-oQYKzMkmmpOOFjQwEMAy1dvFMbm4LHlewQJAC/ksDBaUcQHHqjktCtrUb8rVjAyW
+-A8lscckeB2fEYyG5J6dJVaY4ClNOOs5yMDS2Afk1F6H/xKvtQ/5CzInA/QJATDub
+-K+BPU8jO9q+gpuIi3VIZdupssVGmCgObVCHLakG4uO04y9IyPhV9lA9tALtoIf4c
+-VIvv5fWGXBrZ48kZAQJBAJmVCdzQxd9LZI5vxijUCj5EI4e+x5DRqVUvyP8KCZrC
+-AiNyoDP85T+hBZaSXK3aYGpVwelyj3bvo1GrTNwNWLw=
+------END RSA PRIVATE KEY-----
++-----BEGIN PRIVATE KEY-----
++MIIJQgIBADANBgkqhkiG9w0BAQEFAASCCSwwggkoAgEAAoICAQDolKefhOG5aLih
+++6vq1TUfDaGF9l5AVvqvq6ctc7ubLEUs26sQIw8fXZIbe0JZ31ZQ09NCb6TlnXrj
++6J+fdeXnUEbGOFJ5epih9va2tzrVGtf8giV7BlSUygo+5OAcW+Zmc2/305WZ7TC3
++UyATH1G8OthSoq9VoyiHCfXwqBvCWhnilTuEYeadHs3eFFFCHa9QV5eTanastr0z
++LBA54zrA93oJL/CNkijeDup/wt8FmKTDlmGZBqGYis+6ybP4v3s+27FeyZcHc05Y
++aSc5HDklRQT+iZRDsUzTcWdcLSsuz7WRprEkgE6tnuvm8N/AHjqdF5886nBo7Qw6
++HwZk+zhc2Vo0vVWUuvgzjntkB1pXtZwh3B8h+JLuiEZbK/cZETQCJTn57xx8aiVH
++p6HmmeKEA4wgSktSl8oCTv7S+wS00FZ/8StRJj7yjZ481pOLUT54m1IYbOet+aqT
++lP2D6hQYdSY1a7mW7FnAwIUXHsNLsTjVzmvRPuJbbUPckmGtQC71qibgF+4LtgbA
++TC8qn5vNdWJwOwiBTMjvh5appCxX7+S/8SEQF0e5dumBjtFcFwhozH8+DVTzDJHu
++Jwe6mvTZKV0AUCjJrN0M3eSVtB8vUbo+TvBj3BWZldLcI3dbiTw/3AI5Fi2l43Tb
++CdekFnNp4IUEUuh2KikV+o/glzsbqQIDAQABAoICAFw1q6tr5I48vY7DF+rXsuLn
++5ZUWE1IQ6fzB4lr72nJv/9EEGnMgYzt9PpMUsD6vdCpBgS2C0+6RHArFzJtNA+RM
++iHLIG7K7702veyr/xBx/MwiSlMeMv/XpkFxVI6E6skMGG2s3AMXxKvJTy5CpRx+I
++eQFyLG+Ya1X2lgJes/q+/CpAHkOjCOpcLySQC5NZ74q734V7nSdmn+Zs3tYEh+O/
++eiuwTP/j5b38Te5vVTqDxTciJPmljmXLCwa0N100lWlbcpvw8qbqiTI2Jm3XCbUE
++AzHjW9vmrF3cRS1fXxKFGShw3SRqlkbxjfeWoi8qDPUBS4m8LOr8qG9Wo5Nfon0z
++zLP4bci3zHDvVcaaZrrsUBs/yZbg+Dgka1DmX7ekmeccr2yTdKDFgPupYUyxVbTl
++a9ZLJysjFD7rgBv1ZclHonLp6Vbm+ZoTqvteo4ikAy6L9RtBWJ23XEK34PkP/+c5
++2vWZaOrnjSeBHbFce8cdJSxqWpP+eSCI5I9XbDrYFIsQ/gqKgtzDKy2ihJ2Y8STL
++yO4hyFPFjxc+Gg4/P2PpmT5CY2ty44M0BWs+JGW96CJPrrplf2lmQUQJj5LZY66X
++Z/4C9L7ZYtKZ+bs5SvU46yWugAvQZX22Xm9xLXWyVXRdx3bj+3M3fDnF9di/zdbh
++CgLx7oWPNrXc7FCajnn9AoIBAQD5FMYwRpw9NWT9WDxQwx+cSI4Icbd88ByTW63S
++LzeRwZA0J9/SfwO+aBRupzc9GkGXCiZcGMw3AGsCtig8yFlw8E5KnzN7KlftDMnM
++9NUxxzlR8VwKyLnZfG7sDTl057ZlUujnqhmt/F8F7dIy7FVO1dE/8nngA+FYTCOG
++UZdGjwyBDlDM0JJdUWGY3xslutcpCDN5mzSTKjy9drMvImAshRawxRF6WBpn7vr2
++nC6vciqfx1Mzx1vyk0Jm0ilaydDdLMADjt/iL4Nkr0BEs4k+UzQiKDwp8gu7abQ1
++eBfxd9Iar4htQa2I1Ewl6P01G/q+ZYwgHhJ9RVn4AxQXefILAoIBAQDvCouORdQX
++C8wsyp7MwXlF/3NQeNN5/+B2mhbxrBOf7PmMCXLnkRWcjwJtzypWFqJ0sqai/2+0
++bqbMcjX5maT8stT2shl3zXe/Ejt2e3TBYpc1tyuses8Kb5BMU8hu6tTd3G2CMXpD
++dT6DVemJZCTtwj9aBNIxSizvlgMolJnCpzhPnlfHSI6E+g3m/LTTo3HwbjMSw/Uq
++irgjOpI2wSBB6LZPSgjvfcYPRyWUk16L4A5uSX0cADnovDFLa5/h0wJvN/OoCSQg
++rLCXG5E18EyL5Wc58BCY1ZvxmjG3lQtgPxYu2Jwc36R/y/JKlxW5suER5ZNpbbD4
++uOyTt2VxMQ2bAoIBAQC5+MzRFqdo/AjfL5Y5JrbfVTzXCTDa09xCGd16ZU60QTWN
+++4ed/r+o1sUKqUcRFB2MzEM/2DQBjQpZB/CbEWvWa1XJWXxypXbowveZU+QqOnmN
++uQvj8WLyA3o+PNF9e9QvauwCrHpn8VpxbtPWuaYoKnUFreFZZQxHhPGxRBIS2JOZ
++eDrT8ZaWnkCkh1AZp5smQ71LOprSlmKrg4jd1GjCVMxQR5N5KXbtyv0OTCZ/UFqK
++2aRBsMPyJgkaBChkZPLRcKwc+/wlQRx1fHQb14DNTApMxoXFO7eOwqmOkpAt9iyl
++SBIwoS0UUI5ab88+bBmXNvKcuFdNuQ4nowTJUn9pAoIBADMNkILBXSvS5DeIyuO2
++Sp1tkoZUV+5NfPY3sMDK3KIibaW/+t+EOBZo4L7tKQCb8vRzl21mmsfxfgRaPDbj
++3r3tv9g0b4YLxxBy52pFscj/soXRai17SS7UZwA2QK+XzgDYbDcLNC6mIsTQG4Gx
++dsWk3/zs3KuUSQaehmwrWK+fIUK38c1pLK8v7LoxrLkqxlHwZ04RthHw8KTthH7X
++Pnl1J0LF8CSeOyfWLSuPUfkT0GEzptnNHpEbaHfQM6R6eaGhVJPF6AZme4y6YYgg
++m2ihhSt1n0XVEWpHYWjxFy3mK2mz75unFC4LM+NEY2p2zuUQoCw7NjnY3QYrfCnx
++rRMCggEAXeXsMSLFjjyuoL7iKbAxo52HD/P0fBoy58LyRcwfNVr0lvYan4pYEx+o
++KijIh9K16PqXZXKMA9v003B+ulmF8bJ7SddCZ5NGvnFhUTDe4DdTKgp2RuwQ3Bsc
++3skPIDbhVETyOLCtys34USHrq8U/0DlGY3eLRfxw9GnbKxSBGa/KEu/qQLPNUo50
++7xHZDg7GKeC3kqNJeqKM9rkp0VzIGkEnaD9127LeNDmERDfftxJzFoC/THvUBLfU
++6Sus2ZYwRE8VFvKC30Q45t/c54X3IuhYvAuiCuTmyfE4ruyzyOwKzhUkeeLq1APX
++g0veFbyfzlJ0q8qzD/iffqqIa2ZSmQ==
++-----END PRIVATE KEY-----
+diff --git a/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp b/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
+index 7ba3715e13..752aa122f6 100644
+--- a/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
++++ b/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
+@@ -179,6 +179,7 @@ void tst_QAccessibilityLinux::initTestCase()
+     QVERIFY(!address.isEmpty());
+ 
+     m_window = new AccessibleTestWindow();
++    m_window->setObjectName("mainWindow"_L1);
+     m_window->show();
+ 
+     QVERIFY(QTest::qWaitForWindowExposed(m_window));
+@@ -236,8 +237,11 @@ bool hasState(QDBusInterface *interface, AtspiStateType state)
+ void tst_QAccessibilityLinux::testLabel()
+ {
+     QLabel *l = new QLabel(m_window);
++    l->setObjectName("theObjectName"_L1);
+     l->setText("Hello A11y");
+     m_window->addWidget(l);
++    auto a11yEmpty = new QLabel(m_window);
++    m_window->addWidget(l);
+ 
+     // Application
+     QCOMPARE(getParent(mainWindow), QLatin1String(ATSPI_DBUS_PATH_ROOT));
+@@ -249,6 +253,8 @@ void tst_QAccessibilityLinux::testLabel()
+     QCOMPARE(getChildren(labelInterface).count(), 0);
+     QCOMPARE(labelInterface->call(QDBus::Block, "GetRoleName").arguments().first().toString(), QLatin1String("label"));
+     QCOMPARE(labelInterface->call(QDBus::Block, "GetRole").arguments().first().toUInt(), 29u);
++    QCOMPARE(labelInterface->call(QDBus::Block, "GetAccessibleId").arguments().first().toString(),
++             QLatin1String("mainWindow.theObjectName"));
+     QCOMPARE(getParent(labelInterface), mainWindow->path());
+     QVERIFY(!hasState(labelInterface, ATSPI_STATE_EDITABLE));
+     QVERIFY(hasState(labelInterface, ATSPI_STATE_READ_ONLY));
+@@ -256,7 +262,12 @@ void tst_QAccessibilityLinux::testLabel()
+     l->setText("New text");
+     QCOMPARE(labelInterface->property("Name").toString(), l->text());
+ 
++    auto *a11yEmptyInterface = getInterface(children.at(1), "org.a11y.atspi.Accessible");
++    QCOMPARE(a11yEmptyInterface->call(QDBus::Block, "GetAccessibleId").arguments().first().toString(),
++             QLatin1String("mainWindow.QLabel"));
++
+     m_window->clearChildren();
++    delete a11yEmptyInterface;
+     delete labelInterface;
+ }
+ 
+diff --git a/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+index 76df61c892..6d6d65b791 100644
+--- a/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
++++ b/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2022 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the test suite of the Qt Toolkit.
+@@ -68,6 +68,8 @@ private slots:
+     void query_exec();
+     void execErrorRecovery_data() { generic_data(); }
+     void execErrorRecovery();
++    void prematureExec_data() { generic_data(); }
++    void prematureExec();
+     void first_data() { generic_data(); }
+     void first();
+     void next_data() { generic_data(); }
+@@ -2770,6 +2772,35 @@ void tst_QSqlQuery::execErrorRecovery()
+     QVERIFY_SQL( q, exec() );
+ }
+ 
++void tst_QSqlQuery::prematureExec()
++{
++    QFETCH(QString, dbName);
++    // We only want the engine name, for addDatabase():
++    int cut = dbName.indexOf(QChar('@'));
++    if (cut < 0)
++        QSKIP("Failed to parse database type out of name");
++    dbName.truncate(cut);
++    cut = dbName.indexOf(QChar('_'));
++    if (cut >= 0)
++        dbName = dbName.mid(cut + 1);
++
++    auto db = QSqlDatabase::addDatabase(dbName);
++    QSqlQuery q(db);
++
++    QTest::ignoreMessage(QtWarningMsg,
++                         "QSqlDatabasePrivate::removeDatabase: connection "
++                         "'qt_sql_default_connection' is still in use, all "
++                         "queries will cease to work.");
++    QTest::ignoreMessage(QtWarningMsg,
++                         "QSqlDatabasePrivate::addDatabase: duplicate connection name "
++                         "'qt_sql_default_connection', old connection removed.");
++    auto otherDb = QSqlDatabase::addDatabase(dbName);
++
++    QTest::ignoreMessage(QtWarningMsg, "QSqlQuery::exec: called before driver has been set up");
++    // QTBUG-100037: shouldn't crash !
++    QVERIFY(!q.exec("select stuff from TheVoid"));
++}
++
+ void tst_QSqlQuery::lastInsertId()
+ {
+     QFETCH( QString, dbName );
+diff --git a/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp b/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
+index 4aa3f8d60b..d2050a61aa 100644
+--- a/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
++++ b/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
+@@ -115,6 +115,10 @@ void tst_QAbstractItemModelTester::standardItemModelZeroColumns()
+     // QTBUG-92886
+     model.insertRows(0, 5);
+     model.removeRows(1, 2);
++
++    const QModelIndex parentIndex = model.index(0, 0);
++    model.insertRows(0, 5, parentIndex);
++    model.removeRows(1, 2, parentIndex);
+ }
+ 
+ void tst_QAbstractItemModelTester::testInsertThroughProxy()
+diff --git a/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json b/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
+index 12a4a22a19..ce518e78fb 100644
+--- a/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
++++ b/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
+@@ -668,50 +668,6 @@
+         "inputFile": "task192552.h",
+         "outputRevision": 67
+     },
+-    {
+-        "classes": [
+-            {
+-                "className": "InlineSlotsWithThrowDeclaration",
+-                "object": true,
+-                "qualifiedClassName": "InlineSlotsWithThrowDeclaration",
+-                "slots": [
+-                    {
+-                        "access": "public",
+-                        "name": "a",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "b",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "c",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "d",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "e",
+-                        "returnType": "void"
+-                    }
+-                ],
+-                "superClasses": [
+-                    {
+-                        "access": "public",
+-                        "name": "QObject"
+-                    }
+-                ]
+-            }
+-        ],
+-        "inputFile": "task189996.h",
+-        "outputRevision": 67
+-    },
+     {
+         "classes": [
+             {
+diff --git a/qtbase/tests/auto/tools/moc/moc.pro b/qtbase/tests/auto/tools/moc/moc.pro
+index c324b3a8cd..4aceb78dc0 100644
+--- a/qtbase/tests/auto/tools/moc/moc.pro
++++ b/qtbase/tests/auto/tools/moc/moc.pro
+@@ -15,7 +15,7 @@ cross_compile: DEFINES += MOC_CROSS_COMPILED
+ HEADERS += using-namespaces.h no-keywords.h task87883.h c-comments.h backslash-newlines.h oldstyle-casts.h \
+            slots-with-void-template.h qinvokable.h namespaced-flags.h trigraphs.h \
+            escapes-in-string-literals.h cstyle-enums.h qprivateslots.h gadgetwithnoenums.h \
+-           dir-in-include-path.h single_function_keyword.h task192552.h task189996.h \
++           dir-in-include-path.h single_function_keyword.h task192552.h \
+            task234909.h task240368.h pure-virtual-signals.h cxx11-enums.h \
+            cxx11-final-classes.h \
+            cxx11-explicit-override-control.h \
+diff --git a/qtbase/tests/auto/tools/moc/task189996.h b/qtbase/tests/auto/tools/moc/task189996.h
+deleted file mode 100644
+index f94a051b3a..0000000000
+--- a/qtbase/tests/auto/tools/moc/task189996.h
++++ /dev/null
+@@ -1,47 +0,0 @@
+-/****************************************************************************
+-**
+-** Copyright (C) 2016 The Qt Company Ltd.
+-** Contact: https://www.qt.io/licensing/
+-**
+-** This file is part of the test suite of the Qt Toolkit.
+-**
+-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+-** 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 General Public License Usage
+-** Alternatively, this file may be used under the terms of the GNU
+-** General Public License version 3 as published by the Free Software
+-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+-** 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-3.0.html.
+-**
+-** $QT_END_LICENSE$
+-**
+-****************************************************************************/
+-// inline functions can have throw declarations
+-
+-#ifndef TASK189996_H
+-#define TASK189996_H
+-
+-#include <QObject>
+-
+-class InlineSlotsWithThrowDeclaration : public QObject
+-{
+-    Q_OBJECT
+-
+-public slots:
+-    void a() throw() { }
+-    void b() const throw() { }
+-    void c() throw();
+-    void d() throw(int) { }
+-    void e() const throw(int,double) { }
+-};
+-
+-#endif
+diff --git a/qtbase/tests/auto/tools/moc/tst_moc.cpp b/qtbase/tests/auto/tools/moc/tst_moc.cpp
+index c716aead21..15dd9e41e5 100644
+--- a/qtbase/tests/auto/tools/moc/tst_moc.cpp
++++ b/qtbase/tests/auto/tools/moc/tst_moc.cpp
+@@ -631,7 +631,6 @@ public:
+ private slots:
+     void initTestCase();
+ 
+-    void slotWithException() throw(MyStruct);
+     void dontStripNamespaces();
+     void oldStyleCasts();
+     void warnOnExtraSignalSlotQualifiaction();
+@@ -673,7 +672,6 @@ private slots:
+     void templateGtGt();
+     void qprivateslots();
+     void qprivateproperties();
+-    void inlineSlotsWithThrowDeclaration();
+     void warnOnPropertyWithoutREAD();
+     void constructors();
+     void typenameWithUnsigned();
+@@ -784,12 +782,6 @@ void tst_Moc::initTestCase()
+ #endif
+ }
+ 
+-void tst_Moc::slotWithException() throw(MyStruct)
+-{
+-    // be happy
+-    QVERIFY(true);
+-}
+-
+ void tst_Moc::dontStripNamespaces()
+ {
+     Sender sender;
+@@ -824,7 +816,7 @@ void tst_Moc::oldStyleCasts()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-Wold-style-cast" << "-I" << "."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -894,7 +886,7 @@ void tst_Moc::inputFileNameWithDotsButNoExtension()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-I" << ".."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -1174,7 +1166,7 @@ void tst_Moc::ignoreOptionClashes()
+     QStringList gccArgs;
+     gccArgs << "-c" << "-x" << "c++" << "-I" << ".."
+          << "-I" << qtIncludePath << "-I" << includeDir << "-o" << "/dev/null"
+-         << "-fPIC" << "-std=c++11" <<  "-";
++         << "-fPIC" << "-std=c++1z" <<  "-";
+     proc.start("gcc", gccArgs);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -1593,21 +1585,6 @@ void tst_Moc::qprivateproperties()
+ 
+ }
+ 
+-#include "task189996.h"
+-
+-void InlineSlotsWithThrowDeclaration::c() throw() {}
+-
+-void tst_Moc::inlineSlotsWithThrowDeclaration()
+-{
+-    InlineSlotsWithThrowDeclaration tst;
+-    const QMetaObject *mobj = tst.metaObject();
+-    QVERIFY(mobj->indexOfSlot("a()") != -1);
+-    QVERIFY(mobj->indexOfSlot("b()") != -1);
+-    QVERIFY(mobj->indexOfSlot("c()") != -1);
+-    QVERIFY(mobj->indexOfSlot("d()") != -1);
+-    QVERIFY(mobj->indexOfSlot("e()") != -1);
+-}
+-
+ void tst_Moc::warnOnPropertyWithoutREAD()
+ {
+ #ifdef MOC_CROSS_COMPILED
+@@ -1869,7 +1846,7 @@ void tst_Moc::notifyError()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-I" << "."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+diff --git a/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+index c355ee9665..88c09de8e0 100644
+--- a/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
++++ b/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+@@ -251,6 +251,7 @@ private slots:
+     void testResetCachedSizeHint();
+     void statusTips();
+     void testRemovingColumnsViaLayoutChanged();
++    void testModelMovingColumns();
+ 
+ protected:
+     void setupTestData(bool use_reset_model = false);
+@@ -360,6 +361,12 @@ public:
+         endRemoveColumns();
+     }
+ 
++    void moveColumn(int from, int to)
++    {
++        beginMoveColumns(QModelIndex(), from, from, QModelIndex(), to);
++        endMoveColumns();
++    }
++
+     void cleanup()
+     {
+         emit layoutAboutToBeChanged();
+@@ -3627,5 +3634,18 @@ void tst_QHeaderView::testRemovingColumnsViaLayoutChanged()
+     // The main point of this test is that the section-size restoring code didn't go out of bounds.
+ }
+ 
++void tst_QHeaderView::testModelMovingColumns()
++{
++    QtTestModel model(10, 10);
++    QHeaderView hv(Qt::Horizontal);
++    hv.setModel(&model);
++    hv.resizeSections(QHeaderView::ResizeToContents);
++    hv.show();
++
++    QPersistentModelIndex index3 = model.index(0, 3);
++    model.moveColumn(3, 1);
++    QCOMPARE(index3.column(), 1);
++}
++
+ QTEST_MAIN(tst_QHeaderView)
+ #include "tst_qheaderview.moc"
+diff --git a/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+index 761357b252..06bb706074 100644
+--- a/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
++++ b/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+@@ -397,6 +397,7 @@ private slots:
+     void checkHeaderMinSize();
+ 
+     void resizeToContents();
++    void resizeToContentsSpans();
+ 
+     void tabFocus();
+     void bigModel();
+@@ -3721,6 +3722,70 @@ void tst_QTableView::resizeToContents()
+ 
+ }
+ 
++
++class SpanModel : public QAbstractTableModel
++{
++public:
++    SpanModel(bool sectionsMoved)
++        : _sectionsMoved(sectionsMoved)
++    {}
++    int columnCount(const QModelIndex & = {}) const override { return 2; }
++    int rowCount(const QModelIndex & = {}) const override { return 1; }
++    QVariant data(const QModelIndex &idx, int role = Qt::DisplayRole) const override
++    {
++        if (role != Qt::DisplayRole)
++            return QVariant();
++        const int col = _sectionsMoved ? 1 - idx.column() : idx.column();
++        if (col == 0)
++            return "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.";
++        return QVariant();
++    }
++private:
++    bool _sectionsMoved;
++};
++
++
++void tst_QTableView::resizeToContentsSpans()
++{
++    SpanModel model1(false);
++    SpanModel model2(true);
++    QTableView view1, view2, view3;
++    view1.setModel(&model1);
++    view2.setModel(&model2);
++    view2.horizontalHeader()->moveSection(0, 1);
++    view3.setModel(&model1);
++
++    view1.setSpan(0, 0, 1, 2);
++    view2.setSpan(0, 1, 1, 2);
++    view1.show();
++    view2.show();
++    view3.show();
++    QVERIFY(QTest::qWaitForWindowExposed(&view1));
++    QVERIFY(QTest::qWaitForWindowExposed(&view2));
++    QVERIFY(QTest::qWaitForWindowExposed(&view3));
++    view1.setColumnWidth(0, 100);
++    view1.setColumnWidth(1, 100);
++    view2.setColumnWidth(0, 100);
++    view2.setColumnWidth(1, 100);
++    view3.setColumnWidth(0, 200);
++
++    view1.resizeRowToContents(0);
++    view2.resizeRowToContents(0);
++    view3.resizeRowToContents(0);
++    QCOMPARE(view1.rowHeight(0), view3.rowHeight(0));
++    QCOMPARE(view2.rowHeight(0), view3.rowHeight(0));
++
++    view3.resizeColumnToContents(0);
++    view3.resizeRowToContents(0);
++    // height should be only 1 text line for easy testing
++    view1.setRowHeight(0, view3.verticalHeader()->sectionSize(0));
++    view2.setRowHeight(0, view3.verticalHeader()->sectionSize(0));
++    view1.resizeColumnToContents(0);
++    view2.resizeColumnToContents(1);
++    QCOMPARE(view1.columnWidth(0), view3.columnWidth(0) - view1.columnWidth(1));
++    QCOMPARE(view2.columnWidth(0), view3.columnWidth(0) - view2.columnWidth(1));
++}
++
+ QT_BEGIN_NAMESPACE
+ extern bool Q_WIDGETS_EXPORT qt_tab_all_widgets(); // qapplication.cpp
+ QT_END_NAMESPACE
+diff --git a/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+index a3b8ef78d8..4955cebd5d 100644
+--- a/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
++++ b/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+@@ -1498,7 +1498,7 @@ void tst_QApplication::desktopSettingsAware()
+     environment += QLatin1String("QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM=1");
+     testProcess.setEnvironment(environment);
+ #endif
+-    testProcess.start("desktopsettingsaware_helper");
++    testProcess.start("./desktopsettingsaware_helper");
+     QVERIFY2(testProcess.waitForStarted(),
+              qPrintable(QString::fromLatin1("Cannot start 'desktopsettingsaware_helper': %1").arg(testProcess.errorString())));
+     QVERIFY(testProcess.waitForFinished(10000));
+@@ -2452,7 +2452,7 @@ void tst_QApplication::qtbug_12673()
+ #if QT_CONFIG(process)
+     QProcess testProcess;
+     QStringList arguments;
+-    testProcess.start("modal_helper", arguments);
++    testProcess.start("./modal_helper", arguments);
+     QVERIFY2(testProcess.waitForStarted(),
+              qPrintable(QString::fromLatin1("Cannot start 'modal_helper': %1").arg(testProcess.errorString())));
+     QVERIFY(testProcess.waitForFinished(20000));
+diff --git a/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp b/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
+index eb108a40de..dca5528c1b 100644
+--- a/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
+@@ -41,6 +41,7 @@
+ 
+ #include <private/qguiapplication_p.h>
+ #include <qpa/qplatformintegration.h>
++#include <qpa/qplatformtheme.h>
+ 
+ class tst_QAbstractButton : public QObject
+ {
+@@ -76,6 +77,8 @@ private slots:
+     void keyNavigation();
+ #endif
+ 
++    void buttonPressKeys();
++
+ protected slots:
+     void onClicked();
+     void onToggled( bool on );
+@@ -269,7 +272,13 @@ void tst_QAbstractButton::setAutoRepeat()
+         QCOMPARE(press_count, click_count);
+         QVERIFY(click_count > 1);
+         break;
+-    case 4:
++    case 4: {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(Qt::Key_Enter)) {
++            QSKIP("platform theme has Key_Enter in ButtonPressKeys");
++        }
+         // check that pressing ENTER has no effect when autorepeat is false
+         testWidget->setDown( false );
+         testWidget->setAutoRepeat( false );
+@@ -286,7 +295,14 @@ void tst_QAbstractButton::setAutoRepeat()
+ 
+         QVERIFY( click_count == 0 );
+         break;
+-    case 5:
++    }
++    case 5: {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(Qt::Key_Enter)) {
++            QSKIP("platform theme has Key_Enter in ButtonPressKeys");
++        }
+         // check that pressing ENTER has no effect when autorepeat is true
+         testWidget->setDown( false );
+         testWidget->setAutoRepeat( true );
+@@ -304,6 +320,7 @@ void tst_QAbstractButton::setAutoRepeat()
+ 
+         QVERIFY( click_count == 0 );
+         break;
++    }
+     case 6:
+         // verify autorepeat is off by default.
+         MyButton tmp( 0);
+@@ -651,5 +668,16 @@ void tst_QAbstractButton::keyNavigation()
+ }
+ #endif
+ 
++void tst_QAbstractButton::buttonPressKeys()
++{
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(testWidget, buttonPressKeys[i]);
++        QCOMPARE(click_count, i + 1);
++    }
++}
++
+ QTEST_MAIN(tst_QAbstractButton)
+ #include "tst_qabstractbutton.moc"
+diff --git a/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+index 32437050f5..46b5af6d63 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+@@ -168,6 +168,7 @@ private slots:
+     void checkMenuItemPosWhenStyleSheetIsSet();
+     void checkEmbeddedLineEditWhenStyleSheetIsSet();
+     void propagateStyleChanges();
++    void buttonPressKeys();
+ 
+ private:
+     PlatformInputContext m_platformInputContext;
+@@ -1682,6 +1683,16 @@ void tst_QComboBox::setModel()
+     QCOMPARE(box.rootModelIndex(), rootModelIndex);
+     box.setModel(box.model());
+     QCOMPARE(box.rootModelIndex(), rootModelIndex);
++
++    // check that setting the same model as the completer's doesn't crash
++    QCompleter *completer = new QCompleter(&box);
++    box.setEditable(true);
++    box.setCompleter(completer);
++    auto *listModel = new QStringListModel({ "one", "two" }, completer);
++    completer->setModel(listModel);
++    QCOMPARE(listModel->rowCount(), 2); // make sure it wasn't deleted
++    box.setModel(listModel);
++    QCOMPARE(listModel->rowCount(), 2); // make sure it wasn't deleted
+ }
+ 
+ void tst_QComboBox::setCustomModelAndView()
+@@ -3632,5 +3643,24 @@ void tst_QComboBox::propagateStyleChanges()
+     QVERIFY(frameStyle.inquired);
+ }
+ 
++void tst_QComboBox::buttonPressKeys()
++{
++    QComboBox comboBox;
++    comboBox.setEditable(false);
++    comboBox.addItem(QString::number(1));
++    comboBox.addItem(QString::number(2));
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(&comboBox, buttonPressKeys[i]);
++        // On some platforms, a window will not be immediately visible,
++        // but take some event-loop iterations to complete.
++        // Using QTRY_VERIFY to deal with that.
++        QTRY_VERIFY(comboBox.view()->isVisible());
++        comboBox.hidePopup();
++    }
++}
++
+ QTEST_MAIN(tst_QComboBox)
+ #include "tst_qcombobox.moc"
+diff --git a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
+index be3cfcd104..c228fdfcca 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
++++ b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qcommandlinkbutton
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qcommandlinkbutton.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
+index 0044d33c66..4cf06296e4 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
+@@ -40,6 +40,9 @@
+ #include <QGridLayout>
+ #include <QPainter>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ class tst_QCommandLinkButton : public QObject
+ {
+     Q_OBJECT
+@@ -223,6 +226,13 @@ void tst_QCommandLinkButton::setAutoRepeat()
+     // check that pressing ENTER has no effect
+     resetCounters();
+     testWidget->setDown( false );
++    // Skip after reset if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
+     testWidget->setAutoRepeat( false );
+     QTest::keyPress( testWidget, Qt::Key_Enter );
+ 
+@@ -255,6 +265,14 @@ void tst_QCommandLinkButton::pressed()
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+ 
++    // Skip if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
++
+     QTest::keyPress( testWidget,Qt::Key_Enter );
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+diff --git a/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro b/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
+index 4a5e76ff65..a235fa1fac 100644
+--- a/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
++++ b/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qgroupbox
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qgroupbox.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp b/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
+index 4fb5d262ca..d8d7562b73 100644
+--- a/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
+@@ -35,6 +35,9 @@
+ #include <QRadioButton>
+ #include <QDialog>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ #include "qgroupbox.h"
+ 
+ class tst_QGroupBox : public QObject
+@@ -69,6 +72,7 @@ private slots:
+     void propagateFocus();
+     void task_QTBUG_19170_ignoreMouseReleaseEvent();
+     void task_QTBUG_15519_propagateMouseEvents();
++    void buttonPressKeys();
+ 
+ private:
+     bool checked;
+@@ -610,6 +614,20 @@ void tst_QGroupBox::task_QTBUG_15519_propagateMouseEvents()
+     QCOMPARE(parent.mouseMoved, true);
+ }
+ 
++void tst_QGroupBox::buttonPressKeys()
++{
++    QGroupBox groupBox;
++    groupBox.setCheckable(true);
++    QSignalSpy clickedSpy(&groupBox, &QGroupBox::clicked);
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(&groupBox, buttonPressKeys[i]);
++        QCOMPARE(clickedSpy.length(), i + 1);
++    }
++}
++
+ void tst_QGroupBox::sendMouseMoveEvent(QWidget *widget, const QPoint &localPos)
+ {
+     // Send a MouseMove event without actually moving the pointer
+diff --git a/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro b/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
+index 353ad06ca2..e55f6148f2 100644
+--- a/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
++++ b/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qpushbutton
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qpushbutton.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp b/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
+index e818514a79..4043e9326a 100644
+--- a/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
+@@ -41,6 +41,9 @@
+ #include <QStyleFactory>
+ #include <QTabWidget>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ class tst_QPushButton : public QObject
+ {
+ Q_OBJECT
+@@ -212,6 +215,13 @@ void tst_QPushButton::autoRepeat()
+     // check that pressing ENTER has no effect
+     resetCounters();
+     testWidget->setDown( false );
++    // Skip after reset if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
+     testWidget->setAutoRepeat( false );
+     QTest::keyPress( testWidget, Qt::Key_Enter );
+ 
+@@ -247,6 +257,14 @@ void tst_QPushButton::pressed()
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+ 
++    // Skip if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
++
+     QTest::keyPress( testWidget,Qt::Key_Enter );
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+diff --git a/qtbase/tests/manual/rhi/cubemap_render/buildshader.bat b/qtbase/tests/manual/rhi/cubemap_render/buildshader.bat
+old mode 100755
+new mode 100644
+Submodule qtconnectivity e957d481..056294c0:
+diff --git a/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp b/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
+index e2635fae..a8b8e3b9 100644
+--- a/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
++++ b/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
+@@ -563,9 +563,11 @@ void HciManager::handleHciAclPacket(const quint8 *data, int size)
+ 
+ void HciManager::handleLeMetaEvent(const quint8 *data)
+ {
+-    // Spec v4.2, Vol 2, part E, 7.7.65ff
++    // Spec v5.3, Vol 4, part E, 7.7.65.*
+     switch (*data) {
+-    case 0x1: {
++    case 0x1: // HCI_LE_Connection_Complete
++    case 0xA: // HCI_LE_Enhanced_Connection_Complete
++    {
+         const quint16 handle = bt_get_le16(data + 2);
+         emit connectionComplete(handle);
+         break;
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp b/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
+index 6a93143b..4a18cfc7 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
+@@ -320,7 +320,10 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_finishSdpScan(QBluetoothServiceD
+             for (const QBluetoothUuid &id : serviceClassUuids) {
+                 if (id.minimumSize() == 16) {
+                     serviceInfo.setServiceUuid(id);
+-                    serviceInfo.setServiceName(QBluetoothServiceDiscoveryAgent::tr("Custom Service"));
++                    if (serviceInfo.serviceName().isEmpty()) {
++                        serviceInfo.setServiceName(
++                                    QBluetoothServiceDiscoveryAgent::tr("Custom Service"));
++                    }
+                     QBluetoothServiceInfo::Sequence modSeq =
+                             serviceInfo.attribute(QBluetoothServiceInfo::ServiceClassIds).value<QBluetoothServiceInfo::Sequence>();
+                     modSeq.removeOne(QVariant::fromValue(id));
+@@ -334,8 +337,10 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_finishSdpScan(QBluetoothServiceD
+                 qCDebug(QT_BT_BLUEZ) << "Discovered services" << discoveredDevices.at(0).address().toString()
+                                      << serviceInfo.serviceName() << serviceInfo.serviceUuid()
+                                      << ">>>" << serviceInfo.serviceClassUuids();
+-
+-                emit q->serviceDiscovered(serviceInfo);
++                // Use queued connection to allow us finish the service looping; the application
++                // might call stop() when it has detected the service-of-interest.
++                QMetaObject::invokeMethod(q, "serviceDiscovered", Qt::QueuedConnection,
++                                          Q_ARG(QBluetoothServiceInfo, serviceInfo));
+             }
+         }
+     }
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp b/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
+index e4d85447..aadd4755 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
+@@ -593,7 +593,7 @@ void QBluetoothSocket::setSocketState(QBluetoothSocket::SocketState state)
+ bool QBluetoothSocket::canReadLine() const
+ {
+     Q_D(const QBluetoothSocketBase);
+-    return d->canReadLine();
++    return d->canReadLine() || QIODevice::canReadLine();
+ }
+ 
+ /*!
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp b/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
+index 084aa958..d6aa17a7 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
+@@ -284,6 +284,10 @@ void QBluetoothSocketPrivateBluezDBus::connectToService(
+         return;
+     }
+ 
++    if (service.socketProtocol() != QBluetoothServiceInfo::Protocol::UnknownProtocol)
++        socketType = service.socketProtocol();
++    qCDebug(QT_BT_BLUEZ) << "Socket protocol used:" << socketType;
++
+     connectToService(service.device().address(), targetService, openMode);
+ }
+ 
+diff --git a/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp b/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
+index 05bc1a0f..a7b5ef1f 100644
+--- a/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
++++ b/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
+@@ -142,7 +142,7 @@ void tst_QBluetoothSocket::initTestCase()
+     qDebug() << "Starting discovery";
+ 
+     sda->setUuidFilter(QBluetoothUuid(QString(TEST_SERVICE_UUID)));
+-    sda->start(QBluetoothServiceDiscoveryAgent::MinimalDiscovery);
++    sda->start(QBluetoothServiceDiscoveryAgent::FullDiscovery);
+ 
+     for (int connectTime = MaxConnectTime; !done_discovery && connectTime > 0; connectTime -= 1000)
+         QTest::qWait(1000);
+Submodule qtdeclarative f5701f0d..8defe7bf:
+diff --git a/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h b/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
+index b65b994d6c..15a8cd6878 100644
+--- a/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
++++ b/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
+@@ -86,7 +86,7 @@ public:
+         if (QTypeInfo<T>::isComplex) {
+             for (int i = 0; i < count; ++i)
+                 new (data + i) T(vector.at(i));
+-        } else {
++        } else if (count) {
+             memcpy(data, static_cast<const void*>(vector.constData()), count * sizeof(T));
+         }
+     }
+diff --git a/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp b/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
+index e57cdd8278..94613598af 100644
+--- a/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
++++ b/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
+@@ -1145,8 +1145,7 @@ void Heap::QObjectWrapper::markObjects(Heap::Base *that, QV4::MarkStack *markSta
+ void QObjectWrapper::destroyObject(bool lastCall)
+ {
+     Heap::QObjectWrapper *h = d();
+-    if (!h->internalClass)
+-        return; // destroyObject already got called
++    Q_ASSERT(h->internalClass);
+ 
+     if (h->object()) {
+         QQmlData *ddata = QQmlData::get(h->object(), false);
+@@ -1176,7 +1175,7 @@ void QObjectWrapper::destroyObject(bool lastCall)
+         }
+     }
+ 
+-    h->~Data();
++    h->destroy();
+ }
+ 
+ 
+diff --git a/qtdeclarative/src/qml/memory/qv4mm.cpp b/qtdeclarative/src/qml/memory/qv4mm.cpp
+index 06caf04e5a..da149a67c4 100644
+--- a/qtdeclarative/src/qml/memory/qv4mm.cpp
++++ b/qtdeclarative/src/qml/memory/qv4mm.cpp
+@@ -981,7 +981,7 @@ void MemoryManager::sweep(bool lastSweep, ClassDestroyStatsCallback classCountPt
+ 
+     if (MultiplyWrappedQObjectMap *multiplyWrappedQObjects = engine->m_multiplyWrappedQObjects) {
+         for (MultiplyWrappedQObjectMap::Iterator it = multiplyWrappedQObjects->begin(); it != multiplyWrappedQObjects->end();) {
+-            if (!it.value().isNullOrUndefined())
++            if (it.value().isNullOrUndefined())
+                 it = multiplyWrappedQObjects->erase(it);
+             else
+                 ++it;
+diff --git a/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp b/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
+index 2079a8ed04..a577cb2351 100644
+--- a/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
++++ b/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
+@@ -389,6 +389,12 @@ void QQmlDelegateModelPrivate::connectToAbstractItemModel()
+                       q,  QQmlDelegateModel, SLOT(_q_rowsRemoved(QModelIndex,int,int)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
+                       q,  QQmlDelegateModel, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsInserted(QModelIndex,int,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsInserted(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsRemoved(QModelIndex,int,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsRemoved(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsMoved(QModelIndex,int,int,QModelIndex,int)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
+                       q, QQmlDelegateModel, SLOT(_q_dataChanged(QModelIndex,QModelIndex,QVector<int>)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
+@@ -413,6 +419,12 @@ void QQmlDelegateModelPrivate::disconnectFromAbstractItemModel()
+                         q, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int)));
+     QObject::disconnect(aim, SIGNAL(rowsRemoved(QModelIndex,int,int)),
+                         q, SLOT(_q_rowsRemoved(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsInserted(QModelIndex,int,int)), q,
++                        SLOT(_q_columnsInserted(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsRemoved(QModelIndex,int,int)), q,
++                        SLOT(_q_columnsRemoved(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)), q,
++                        SLOT(_q_columnsMoved(QModelIndex,int,int,QModelIndex,int)));
+     QObject::disconnect(aim, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
+                         q, SLOT(_q_dataChanged(QModelIndex,QModelIndex,QVector<int>)));
+     QObject::disconnect(aim, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
+@@ -1973,6 +1985,38 @@ void QQmlDelegateModel::_q_rowsMoved(
+     }
+ }
+ 
++void QQmlDelegateModel::_q_columnsInserted(const QModelIndex &parent, int begin, int end)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if (parent == d->m_adaptorModel.rootIndex && begin == 0) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
++void QQmlDelegateModel::_q_columnsRemoved(const QModelIndex &parent, int begin, int end)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if (parent == d->m_adaptorModel.rootIndex && begin == 0) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
++void QQmlDelegateModel::_q_columnsMoved(const QModelIndex &parent, int start, int end,
++                                        const QModelIndex &destination, int column)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if ((parent == d->m_adaptorModel.rootIndex && start == 0)
++        || (destination == d->m_adaptorModel.rootIndex && column == 0)) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
+ void QQmlDelegateModel::_q_dataChanged(const QModelIndex &begin, const QModelIndex &end, const QVector<int> &roles)
+ {
+     Q_D(QQmlDelegateModel);
+diff --git a/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h b/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
+index 8aab4badca..d140bfbaaf 100644
+--- a/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
++++ b/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
+@@ -152,6 +152,9 @@ private Q_SLOTS:
+     void _q_itemsMoved(int from, int to, int count);
+     void _q_modelReset();
+     void _q_rowsInserted(const QModelIndex &,int,int);
++    void _q_columnsInserted(const QModelIndex &, int, int);
++    void _q_columnsRemoved(const QModelIndex &, int, int);
++    void _q_columnsMoved(const QModelIndex &, int, int, const QModelIndex &, int);
+     void _q_rowsAboutToBeRemoved(const QModelIndex &parent, int begin, int end);
+     void _q_rowsRemoved(const QModelIndex &,int,int);
+     void _q_rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int);
+diff --git a/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp b/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
+index 85719fdc80..78e2ab302c 100644
+--- a/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
++++ b/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
+@@ -46,6 +46,7 @@
+ #include "QtQuick/private/qquicktextinput_p.h"
+ #include "QtQuick/private/qquickaccessibleattached_p.h"
+ #include "QtQuick/qquicktextdocument.h"
++#include "QtQuick/qquickrendercontrol.h"
+ QT_BEGIN_NAMESPACE
+ 
+ #if QT_CONFIG(accessibility)
+@@ -57,7 +58,19 @@ QAccessibleQuickItem::QAccessibleQuickItem(QQuickItem *item)
+ 
+ QWindow *QAccessibleQuickItem::window() const
+ {
+-    return item()->window();
++    QQuickWindow *window = item()->window();
++
++    // For QQuickWidget the above window will be the offscreen QQuickWindow,
++    // which is not a part of the accessibility tree. Detect this case and
++    // return the window for the QQuickWidget instead.
++    if (window && !window->handle()) {
++        if (QQuickRenderControl *renderControl = QQuickWindowPrivate::get(window)->renderControl) {
++            if (QWindow *renderWindow = renderControl->renderWindow(nullptr))
++                return renderWindow;
++        }
++    }
++
++    return window;
+ }
+ 
+ int QAccessibleQuickItem::childCount() const
+@@ -113,19 +126,15 @@ QAccessibleInterface *QAccessibleQuickItem::childAt(int x, int y) const
+ QAccessibleInterface *QAccessibleQuickItem::parent() const
+ {
+     QQuickItem *parent = item()->parentItem();
+-    QQuickWindow *window = item()->window();
+-    QQuickItem *ci = window ? window->contentItem() : nullptr;
++    QQuickWindow *itemWindow = item()->window();
++    QQuickItem *ci = itemWindow ? itemWindow->contentItem() : nullptr;
+     while (parent && !QQuickItemPrivate::get(parent)->isAccessible && parent != ci)
+         parent = parent->parentItem();
+ 
+     if (parent) {
+         if (parent == ci) {
+-            // Jump out to the scene widget if the parent is the root item.
+-            // There are two root items, QQuickWindow::rootItem and
+-            // QQuickView::declarativeRoot. The former is the true root item,
+-            // but is not a part of the accessibility tree. Check if we hit
+-            // it here and return an interface for the scene instead.
+-            return QAccessible::queryAccessibleInterface(window);
++            // Jump out to the window if the parent is the root item
++            return QAccessible::queryAccessibleInterface(window());
+         } else {
+             while (parent && !parent->d_func()->isAccessible)
+                 parent = parent->parentItem();
+@@ -188,7 +197,7 @@ QAccessible::State QAccessibleQuickItem::state() const
+     QRect viewRect_ = viewRect();
+     QRect itemRect = rect();
+ 
+-    if (viewRect_.isNull() || itemRect.isNull() || !item()->window() || !item()->window()->isVisible() ||!item()->isVisible() || qFuzzyIsNull(item()->opacity()))
++    if (viewRect_.isNull() || itemRect.isNull() || !window() || !window()->isVisible() ||!item()->isVisible() || qFuzzyIsNull(item()->opacity()))
+         state.invisible = true;
+     if (!viewRect_.intersects(itemRect))
+         state.offscreen = true;
+@@ -201,6 +210,10 @@ QAccessible::State QAccessibleQuickItem::state() const
+     if (role() == QAccessible::EditableText)
+         if (auto ti = qobject_cast<QQuickTextInput *>(item()))
+             state.passwordEdit = ti->echoMode() != QQuickTextInput::Normal;
++    if (!item()->isEnabled()) {
++        state.focusable = false;
++        state.disabled = true;
++    }
+     return state;
+ }
+ 
+diff --git a/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h b/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
+index 39ffcaf39c..8baa01330c 100644
+--- a/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
++++ b/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
+@@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE
+ 
+ #if QT_CONFIG(accessibility)
+ 
+-class QAccessibleQuickWindow : public QAccessibleObject
++class Q_QUICK_EXPORT QAccessibleQuickWindow : public QAccessibleObject
+ {
+ public:
+     QAccessibleQuickWindow(QQuickWindow *object);
+diff --git a/qtdeclarative/src/quick/items/qquickdrag.cpp b/qtdeclarative/src/quick/items/qquickdrag.cpp
+index 8321fcfeed..383078b3b9 100644
+--- a/qtdeclarative/src/quick/items/qquickdrag.cpp
++++ b/qtdeclarative/src/quick/items/qquickdrag.cpp
+@@ -481,7 +481,9 @@ void QQuickDragAttached::setKeys(const QStringList &keys)
+     \qmlattachedproperty stringlist QtQuick::Drag::mimeData
+     \since 5.2
+ 
+-    This property holds a map of mimeData that is used during startDrag.
++    This property holds a map from mime type to data that is used during startDrag.
++    The mime data needs to be a \c string, or an \c ArrayBuffer with the data encoded
++    according to the mime type.
+ */
+ 
+ QVariantMap QQuickDragAttached::mimeData() const
+@@ -766,8 +768,12 @@ Qt::DropAction QQuickDragAttachedPrivate::startDrag(Qt::DropActions supportedAct
+     QDrag *drag = new QDrag(source ? source : q);
+     QMimeData *mimeData = new QMimeData();
+ 
+-    for (auto it = externalMimeData.cbegin(), end = externalMimeData.cend(); it != end; ++it)
+-        mimeData->setData(it.key(), it.value().toString().toUtf8());
++    for (auto it = externalMimeData.cbegin(), end = externalMimeData.cend(); it != end; ++it) {
++        if (static_cast<QMetaType::Type>(it.value().type()) == QMetaType::QByteArray)
++            mimeData->setData(it.key(), it.value().toByteArray());
++        else
++            mimeData->setData(it.key(), it.value().toString().toUtf8());
++    }
+ 
+     drag->setMimeData(mimeData);
+     if (pixmapLoader.isReady()) {
+diff --git a/qtdeclarative/src/quick/items/qquickitem.cpp b/qtdeclarative/src/quick/items/qquickitem.cpp
+index 75f1457816..dec0ae19ae 100644
+--- a/qtdeclarative/src/quick/items/qquickitem.cpp
++++ b/qtdeclarative/src/quick/items/qquickitem.cpp
+@@ -59,6 +59,7 @@
+ #include <QtCore/private/qnumeric_p.h>
+ #include <QtGui/qpa/qplatformtheme.h>
+ #include <QtCore/qloggingcategory.h>
++#include <QtCore/private/qduplicatetracker_p.h>
+ 
+ #include <private/qqmlglobal_p.h>
+ #include <private/qqmlengine_p.h>
+@@ -2326,6 +2327,7 @@ QQuickItem::QQuickItem(QQuickItemPrivate &dd, QQuickItem *parent)
+ QQuickItem::~QQuickItem()
+ {
+     Q_D(QQuickItem);
++    d->inDestructor = true;
+ 
+     if (d->windowRefCount > 1)
+         d->windowRefCount = 1; // Make sure window is set to null in next call to derefWindow().
+@@ -2526,6 +2528,7 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo
+     QQuickItem *current = item;
+     qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: startItem:" << startItem;
+     qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: firstFromItem:" << firstFromItem;
++    QDuplicateTracker<QQuickItem *> cycleDetector;
+     do {
+         qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: current:" << current;
+         qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: from:" << from;
+@@ -2592,7 +2595,10 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo
+         // traversed all of the chain (by compare the [current] item with [startItem])
+         // Since the [startItem] might be promoted to its parent if it is invisible,
+         // we still have to check [current] item with original start item
+-        if ((current == startItem || current == originalStartItem) && from == firstFromItem) {
++        // We might also run into a cycle before we reach firstFromItem again
++        // but note that we have to ignore current if we are meant to skip it
++        if (((current == startItem || current == originalStartItem) && from == firstFromItem) ||
++                (!skip && cycleDetector.hasSeen(current))) {
+             // wrapped around, avoid endless loops
+             if (item == contentItem) {
+                 qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: looped, return contentItem";
+@@ -2689,9 +2695,8 @@ void QQuickItem::setParentItem(QQuickItem *parentItem)
+ 
+         const bool wasVisible = isVisible();
+         op->removeChild(this);
+-        if (wasVisible) {
++        if (wasVisible && !op->inDestructor)
+             emit oldParentItem->visibleChildrenChanged();
+-        }
+     } else if (d->window) {
+         QQuickWindowPrivate::get(d->window)->parentlessItems.remove(this);
+     }
+@@ -2768,8 +2773,9 @@ void QQuickItem::setParentItem(QQuickItem *parentItem)
+ 
+     d->itemChange(ItemParentHasChanged, d->parentItem);
+ 
+-    emit parentChanged(d->parentItem);
+-    if (isVisible() && d->parentItem)
++    if (!d->inDestructor)
++        emit parentChanged(d->parentItem);
++    if (isVisible() && d->parentItem && !QQuickItemPrivate::get(d->parentItem)->inDestructor)
+         emit d->parentItem->visibleChildrenChanged();
+ }
+ 
+@@ -2965,7 +2971,8 @@ void QQuickItemPrivate::removeChild(QQuickItem *child)
+ 
+     itemChange(QQuickItem::ItemChildRemovedChange, child);
+ 
+-    emit q->childrenChanged();
++    if (!inDestructor)
++        emit q->childrenChanged();
+ }
+ 
+ void QQuickItemPrivate::refWindow(QQuickWindow *c)
+@@ -3194,6 +3201,7 @@ QQuickItemPrivate::QQuickItemPrivate()
+     , touchEnabled(false)
+ #endif
+     , hasCursorHandler(false)
++    , inDestructor(false)
+     , dirtyAttributes(0)
+     , nextDirtyItem(nullptr)
+     , prevDirtyItem(nullptr)
+@@ -5120,6 +5128,13 @@ void QQuickItem::componentComplete()
+         d->addToDirtyList();
+         QQuickWindowPrivate::get(d->window)->dirtyItem(this);
+     }
++
++#if QT_CONFIG(accessibility)
++    if (d->isAccessible && d->effectiveVisible) {
++        QAccessibleEvent ev(this, QAccessible::ObjectShow);
++        QAccessible::updateAccessibility(&ev);
++    }
++#endif
+ }
+ 
+ QQuickStateGroup *QQuickItemPrivate::_states()
+@@ -6106,9 +6121,11 @@ bool QQuickItemPrivate::setEffectiveVisibleRecur(bool newEffectiveVisible)
+         QAccessible::updateAccessibility(&ev);
+     }
+ #endif
+-    emit q->visibleChanged();
+-    if (childVisibilityChanged)
+-        emit q->visibleChildrenChanged();
++    if (!inDestructor) {
++        emit q->visibleChanged();
++        if (childVisibilityChanged)
++            emit q->visibleChildrenChanged();
++    }
+ 
+     return true;    // effective visibility DID change
+ }
+@@ -6157,6 +6174,15 @@ void QQuickItemPrivate::setEffectiveEnableRecur(QQuickItem *scope, bool newEffec
+     }
+ 
+     itemChange(QQuickItem::ItemEnabledHasChanged, effectiveEnable);
++#if QT_CONFIG(accessibility)
++    if (isAccessible) {
++        QAccessible::State changedState;
++        changedState.disabled = true;
++        changedState.focusable = true;
++        QAccessibleStateChangeEvent ev(q, changedState);
++        QAccessible::updateAccessibility(&ev);
++    }
++#endif
+     emit q->enabledChanged();
+ }
+ 
+diff --git a/qtdeclarative/src/quick/items/qquickitem_p.h b/qtdeclarative/src/quick/items/qquickitem_p.h
+index 841d91bb40..ade8fb61f2 100644
+--- a/qtdeclarative/src/quick/items/qquickitem_p.h
++++ b/qtdeclarative/src/quick/items/qquickitem_p.h
+@@ -472,6 +472,7 @@ public:
+     bool replayingPressEvent:1;
+     bool touchEnabled:1;
+     bool hasCursorHandler:1;
++    quint32 inDestructor:1; // has entered ~QQuickItem
+ 
+     enum DirtyType {
+         TransformOrigin         = 0x00000001,
+diff --git a/qtdeclarative/src/quick/items/qquickitemview.cpp b/qtdeclarative/src/quick/items/qquickitemview.cpp
+index 010a0152e1..f8ad168a17 100644
+--- a/qtdeclarative/src/quick/items/qquickitemview.cpp
++++ b/qtdeclarative/src/quick/items/qquickitemview.cpp
+@@ -1785,7 +1785,7 @@ void QQuickItemViewPrivate::refill(qreal from, qreal to)
+ 
+     do {
+         bufferPause.stop();
+-        if (currentChanges.hasPendingChanges() || bufferedChanges.hasPendingChanges()) {
++        if (currentChanges.hasPendingChanges() || bufferedChanges.hasPendingChanges() || currentChanges.active) {
+             currentChanges.reset();
+             bufferedChanges.reset();
+             releaseVisibleItems(reusableFlag);
+diff --git a/qtdeclarative/src/quick/items/qquickmousearea_p_p.h b/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
+index fba383e268..0d63618622 100644
+--- a/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
++++ b/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
+@@ -61,7 +61,6 @@ QT_BEGIN_NAMESPACE
+ 
+ class QQuickMouseEvent;
+ class QQuickMouseArea;
+-class QQuickPointerMask;
+ class QQuickMouseAreaPrivate : public QQuickItemPrivate
+ {
+     Q_DECLARE_PUBLIC(QQuickMouseArea)
+@@ -100,7 +99,6 @@ public:
+ #if QT_CONFIG(quick_draganddrop)
+     QQuickDrag *drag;
+ #endif
+-    QPointer<QQuickPointerMask> mask;
+     QPointF startScene;
+     QPointF targetStartPos;
+     QPointF lastPos;
+diff --git a/qtdeclarative/src/quick/items/qquicktext.cpp b/qtdeclarative/src/quick/items/qquicktext.cpp
+index 6230186933..e823ca1095 100644
+--- a/qtdeclarative/src/quick/items/qquicktext.cpp
++++ b/qtdeclarative/src/quick/items/qquicktext.cpp
+@@ -2168,7 +2168,7 @@ void QQuickText::resetMaximumLineCount()
+     <img src="" align="top,middle,bottom" width="" height=""> - inline images
+     <ol type="">, <ul type=""> and <li> - ordered and unordered lists
+     <pre></pre> - preformatted
+-    &gt; &lt; &amp;
++    &gt; &lt; &amp; &quot; &nbsp; &apos;
+     \endcode
+ 
+     \c Text.StyledText parser is strict, requiring tags to be correctly nested.
+diff --git a/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp b/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
+index eb4db0f85e..2325a2665b 100644
+--- a/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
++++ b/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
+@@ -446,7 +446,7 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+         const char *textureRecord = allocatorData;
+         for (int i = 0; i < textureCount; ++i, textureRecord += Qtdf::TextureRecordSize) {
+-            if (textureRecord + Qtdf::TextureRecordSize > qtdfTableEnd) {
++            if (qtdfTableEnd - textureRecord < Qtdf::TextureRecordSize) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+@@ -462,7 +462,7 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+         const char *glyphRecord = textureRecord;
+         for (quint32 i = 0; i < glyphCount; ++i, glyphRecord += Qtdf::GlyphRecordSize) {
+-            if (glyphRecord + Qtdf::GlyphRecordSize > qtdfTableEnd) {
++            if (qtdfTableEnd - glyphRecord < Qtdf:: GlyphRecordSize) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+@@ -512,8 +512,8 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+             int width = texInfo->allocatedArea.width();
+             int height = texInfo->allocatedArea.height();
+-            qint64 size = width * height;
+-            if (reinterpret_cast<const char *>(textureData + size) > qtdfTableEnd) {
++            qint64 size = qint64(width) * height;
++            if (qtdfTableEnd - reinterpret_cast<const char *>(textureData) < size) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+diff --git a/qtdeclarative/src/quick/util/qquickstyledtext.cpp b/qtdeclarative/src/quick/util/qquickstyledtext.cpp
+index d531fc9205..a25af90414 100644
+--- a/qtdeclarative/src/quick/util/qquickstyledtext.cpp
++++ b/qtdeclarative/src/quick/util/qquickstyledtext.cpp
+@@ -564,6 +564,8 @@ void QQuickStyledTextPrivate::parseEntity(const QChar *&ch, const QString &textI
+                 textOut += QChar(60);
+             else if (entity == QLatin1String("amp"))
+                 textOut += QChar(38);
++            else if (entity == QLatin1String("apos"))
++                textOut += QChar(39);
+             else if (entity == QLatin1String("quot"))
+                 textOut += QChar(34);
+             else if (entity == QLatin1String("nbsp"))
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp
+new file mode 100644
+index 0000000000..8a1c901880
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp
+@@ -0,0 +1,110 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include "qaccessiblequickwidget_p.h"
++
++#include "qquickwidget_p.h"
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleQuickWidget::QAccessibleQuickWidget(QQuickWidget* widget)
++: QAccessibleWidget(widget)
++, m_accessibleWindow(QQuickWidgetPrivate::get(widget)->offscreenWindow)
++{
++    // NOTE: m_accessibleWindow is a QAccessibleQuickWindow, and not a
++    // QAccessibleQuickWidgetOffscreenWindow (defined below). This means
++    // it will return the Quick item child interfaces, which is what's needed here
++    // (unlike QAccessibleQuickWidgetOffscreenWindow, which will report 0 children).
++}
++
++QAccessibleInterface *QAccessibleQuickWidget::child(int index) const
++{
++    return m_accessibleWindow.child(index);
++}
++
++int QAccessibleQuickWidget::childCount() const
++{
++    return m_accessibleWindow.childCount();
++}
++
++int QAccessibleQuickWidget::indexOfChild(const QAccessibleInterface *iface) const
++{
++    return m_accessibleWindow.indexOfChild(iface);
++}
++
++QAccessibleInterface *QAccessibleQuickWidget::childAt(int x, int y) const
++{
++    return m_accessibleWindow.childAt(x, y);
++}
++
++QAccessibleQuickWidgetOffscreenWindow::QAccessibleQuickWidgetOffscreenWindow(QQuickWindow *window)
++:QAccessibleQuickWindow(window)
++{
++
++}
++
++QAccessibleInterface *QAccessibleQuickWidgetOffscreenWindow::child(int index) const
++{
++    Q_UNUSED(index);
++    return nullptr;
++}
++
++int QAccessibleQuickWidgetOffscreenWindow::childCount() const
++{
++    return 0;
++}
++
++int QAccessibleQuickWidgetOffscreenWindow::indexOfChild(const QAccessibleInterface *iface) const
++{
++    Q_UNUSED(iface);
++    return -1;
++}
++
++QAccessibleInterface *QAccessibleQuickWidgetOffscreenWindow::QAccessibleQuickWidgetOffscreenWindow::childAt(int x, int y) const
++{
++    Q_UNUSED(x);
++    Q_UNUSED(y);
++    return nullptr;
++}
++
++#endif // accessibility
++
++QT_END_NAMESPACE
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h
+new file mode 100644
+index 0000000000..7c2ab930e0
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h
+@@ -0,0 +1,95 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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 QACCESSIBLEQUICKWIDGET_H
++#define QACCESSIBLEQUICKWIDGET_H
++
++//
++//  W A R N I N G
++//  -------------
++//
++// This file is not part of the Qt API.  It exists purely as an
++// implementation detail.  This header file may change from version to
++// version without notice, or even be removed.
++//
++// We mean it.
++//
++
++#include "qquickwidget.h"
++#include <QtWidgets/qaccessiblewidget.h>
++
++#include <private/qaccessiblequickview_p.h>
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++// These classes implement the QQuickWiget accessibility switcharoo,
++// where the child items of the QQuickWidgetOffscreenWindow are reported
++// as child accessible interfaces of the QAccessibleQuickWidget.
++class QAccessibleQuickWidget: public QAccessibleWidget
++{
++public:
++    QAccessibleQuickWidget(QQuickWidget* widget);
++
++    QAccessibleInterface *child(int index) const override;
++    int childCount() const override;
++    int indexOfChild(const QAccessibleInterface *iface) const override;
++    QAccessibleInterface *childAt(int x, int y) const override;
++
++private:
++    QAccessibleQuickWindow m_accessibleWindow;
++    Q_DISABLE_COPY(QAccessibleQuickWidget)
++};
++
++class QAccessibleQuickWidgetOffscreenWindow: public QAccessibleQuickWindow
++{
++public:
++    QAccessibleQuickWidgetOffscreenWindow(QQuickWindow *window);
++    QAccessibleInterface *child(int index) const override;
++    int childCount() const override;
++    int indexOfChild(const QAccessibleInterface *iface) const override;
++    QAccessibleInterface *childAt(int x, int y) const override;
++};
++
++#endif // accessibility
++
++QT_END_NAMESPACE
++
++#endif
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp
+new file mode 100644
+index 0000000000..7ba88a1769
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp
+@@ -0,0 +1,60 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include "qaccessiblequickwidgetfactory_p.h"
++#include "qaccessiblequickwidget_p.h"
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleInterface *qAccessibleQuickWidgetFactory(const QString &classname, QObject *object)
++{
++    if (classname == QLatin1String("QQuickWidget")) {
++        return new QAccessibleQuickWidget(qobject_cast<QQuickWidget *>(object));
++    } else if (classname == QLatin1String("QQuickWidgetOffscreenWindow")) {
++        return new QAccessibleQuickWidgetOffscreenWindow(qobject_cast<QQuickWindow *>(object));
++    }
++    return 0;
++}
++
++#endif // accessibility
++
++QT_END_NAMESPACE
++
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h
+new file mode 100644
+index 0000000000..8c63b09f81
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h
+@@ -0,0 +1,66 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include <QtGui/qaccessible.h>
++
++#ifndef QACCESSIBLEQUICKWIDGETFACTORY_H
++#define QACCESSIBLEQUICKWIDGETFACTORY_H
++
++//
++//  W A R N I N G
++//  -------------
++//
++// This file is not part of the Qt API.  It exists purely as an
++// implementation detail.  This header file may change from version to
++// version without notice, or even be removed.
++//
++// We mean it.
++//
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleInterface *qAccessibleQuickWidgetFactory(const QString &classname, QObject *object);
++
++#endif
++
++QT_END_NAMESPACE
++
++#endif
+diff --git a/qtdeclarative/src/quickwidgets/qquickwidget.cpp b/qtdeclarative/src/quickwidgets/qquickwidget.cpp
+index 39780f8de3..9c97b43518 100644
+--- a/qtdeclarative/src/quickwidgets/qquickwidget.cpp
++++ b/qtdeclarative/src/quickwidgets/qquickwidget.cpp
+@@ -39,6 +39,7 @@
+ 
+ #include "qquickwidget.h"
+ #include "qquickwidget_p.h"
++#include "qaccessiblequickwidgetfactory_p.h"
+ 
+ #include "private/qquickwindow_p.h"
+ #include "private/qquickitem_p.h"
+@@ -75,9 +76,16 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++QQuickWidgetOffscreenWindow::QQuickWidgetOffscreenWindow(QQuickWindowPrivate &dd, QQuickRenderControl *control)
++:QQuickWindow(dd, control)
++{
++    setTitle(QString::fromLatin1("Offscreen"));
++    setObjectName(QString::fromLatin1("QQuickOffScreenWindow"));
++}
++
+ // override setVisble to prevent accidental offscreen window being created
+ // by base class.
+-class QQuickOffcreenWindowPrivate: public QQuickWindowPrivate {
++class QQuickWidgetOffscreenWindowPrivate: public QQuickWindowPrivate {
+ public:
+     void setVisible(bool visible) override {
+         Q_Q(QWindow);
+@@ -105,9 +113,8 @@ void QQuickWidgetPrivate::init(QQmlEngine* e)
+     Q_Q(QQuickWidget);
+ 
+     renderControl = new QQuickWidgetRenderControl(q);
+-    offscreenWindow = new QQuickWindow(*new QQuickOffcreenWindowPrivate(),renderControl);
+-    offscreenWindow->setTitle(QString::fromLatin1("Offscreen"));
+-    offscreenWindow->setObjectName(QString::fromLatin1("QQuickOffScreenWindow"));
++    offscreenWindow = new QQuickWidgetOffscreenWindow(*new QQuickWidgetOffscreenWindowPrivate(), renderControl);
++    offscreenWindow->setScreen(q->screen());
+     // Do not call create() on offscreenWindow.
+ 
+     // Check if the Software Adaptation is being used
+@@ -138,6 +145,10 @@ void QQuickWidgetPrivate::init(QQmlEngine* e)
+     QWidget::connect(offscreenWindow, &QQuickWindow::focusObjectChanged, q, &QQuickWidget::propagateFocusObjectChanged);
+     QObject::connect(renderControl, SIGNAL(renderRequested()), q, SLOT(triggerUpdate()));
+     QObject::connect(renderControl, SIGNAL(sceneChanged()), q, SLOT(triggerUpdate()));
++
++#if QT_CONFIG(accessibility)
++    QAccessible::installFactory(&qAccessibleQuickWidgetFactory);
++#endif
+ }
+ 
+ void QQuickWidgetPrivate::ensureEngine() const
+@@ -901,9 +912,7 @@ void QQuickWidgetPrivate::createContext()
+ 
+         context = new QOpenGLContext;
+         context->setFormat(offscreenWindow->requestedFormat());
+-        const QWindow *win = q->window()->windowHandle();
+-        if (win && win->screen())
+-            context->setScreen(win->screen());
++        context->setScreen(q->screen());
+         QOpenGLContext *shareContext = qt_gl_global_share_context();
+         if (!shareContext)
+             shareContext = QWidgetPrivate::get(q->window())->shareContext();
+@@ -1520,19 +1529,16 @@ bool QQuickWidget::event(QEvent *e)
+         d->handleWindowChange();
+         break;
+ 
+-    case QEvent::ScreenChangeInternal:
+-        if (QWindow *window = this->window()->windowHandle()) {
+-            QScreen *newScreen = window->screen();
+-
+-            if (d->offscreenWindow)
+-                d->offscreenWindow->setScreen(newScreen);
+-            if (d->offscreenSurface)
+-                d->offscreenSurface->setScreen(newScreen);
++    case QEvent::ScreenChangeInternal: {
++        QScreen *newScreen = screen();
++        if (d->offscreenWindow)
++            d->offscreenWindow->setScreen(newScreen);
++        if (d->offscreenSurface)
++            d->offscreenSurface->setScreen(newScreen);
+ #if QT_CONFIG(opengl)
+-            if (d->context)
+-                d->context->setScreen(newScreen);
++        if (d->context)
++            d->context->setScreen(newScreen);
+ #endif
+-        }
+ 
+         if (d->useSoftwareRenderer
+ #if QT_CONFIG(opengl)
+@@ -1545,7 +1551,7 @@ bool QQuickWidget::event(QEvent *e)
+             d->render(true);
+         }
+         break;
+-
++    }
+     case QEvent::Show:
+     case QEvent::Move:
+         d->updatePosition();
+diff --git a/qtdeclarative/src/quickwidgets/qquickwidget_p.h b/qtdeclarative/src/quickwidgets/qquickwidget_p.h
+index 881f7f9220..1a946bcc71 100644
+--- a/qtdeclarative/src/quickwidgets/qquickwidget_p.h
++++ b/qtdeclarative/src/quickwidgets/qquickwidget_p.h
+@@ -148,6 +148,14 @@ public:
+     bool forceFullUpdate;
+ };
+ 
++class QQuickWidgetOffscreenWindow: public QQuickWindow
++{
++    Q_OBJECT
++
++public:
++    QQuickWidgetOffscreenWindow(QQuickWindowPrivate &dd, QQuickRenderControl *control);
++};
++
+ QT_END_NAMESPACE
+ 
+ #endif // QQuickWidget_P_H
+diff --git a/qtdeclarative/src/quickwidgets/quickwidgets.pro b/qtdeclarative/src/quickwidgets/quickwidgets.pro
+index 2438e577ae..85d156b8a3 100644
+--- a/qtdeclarative/src/quickwidgets/quickwidgets.pro
++++ b/qtdeclarative/src/quickwidgets/quickwidgets.pro
+@@ -7,9 +7,13 @@ DEFINES   += QT_NO_URL_CAST_FROM_STRING QT_NO_INTEGER_EVENT_COORDINATES QT_NO_FO
+ HEADERS += \
+     qquickwidget.h \
+     qquickwidget_p.h \
+-    qtquickwidgetsglobal.h
++    qtquickwidgetsglobal.h \
++    qaccessiblequickwidget_p.h \
++    qaccessiblequickwidgetfactory_p.h
+ 
+ SOURCES += \
+-    qquickwidget.cpp
++    qquickwidget.cpp \
++    qaccessiblequickwidget.cpp \
++    qaccessiblequickwidgetfactory.cpp
+ 
+ load(qt_module)
+diff --git a/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+index 3b7d74df63..b75bf820d5 100644
+--- a/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
++++ b/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+@@ -102,6 +102,7 @@ private slots:
+     void valueConversion_RegularExpression();
+     void castWithMultipleInheritance();
+     void collectGarbage();
++    void collectGarbageNestedWrappersTwoEngines();
+     void gcWithNestedDataStructure();
+     void stacktrace();
+     void numberParsing_data();
+@@ -1809,6 +1810,44 @@ void tst_QJSEngine::collectGarbage()
+     QVERIFY(ptr.isNull());
+ }
+ 
++class TestObjectContainer : public QObject
++{
++    Q_OBJECT
++    Q_PROPERTY(QObject *dummy MEMBER m_dummy CONSTANT)
++
++public:
++    TestObjectContainer() : m_dummy(new QObject(this)) {}
++
++private:
++    QObject *m_dummy;
++};
++
++void tst_QJSEngine::collectGarbageNestedWrappersTwoEngines()
++{
++    QJSEngine engine1;
++    QJSEngine engine2;
++
++    TestObjectContainer container;
++    QQmlEngine::setObjectOwnership(&container, QQmlEngine::CppOwnership);
++
++    engine1.globalObject().setProperty("foobar", engine1.newQObject(&container));
++    engine2.globalObject().setProperty("foobar", engine2.newQObject(&container));
++
++    engine1.evaluate("foobar.dummy.baz = 42");
++    engine2.evaluate("foobar.dummy.baz = 43");
++
++    QCOMPARE(engine1.evaluate("foobar.dummy.baz").toInt(), 42);
++    QCOMPARE(engine2.evaluate("foobar.dummy.baz").toInt(), 43);
++
++    engine1.collectGarbage();
++    engine2.collectGarbage();
++
++    // The GC should not collect dummy object wrappers neither in engine1 nor engine2, we
++    // verify that by checking whether the baz property still has its previous value.
++    QCOMPARE(engine1.evaluate("foobar.dummy.baz").toInt(), 42);
++    QCOMPARE(engine2.evaluate("foobar.dummy.baz").toInt(), 43);
++}
++
+ void tst_QJSEngine::gcWithNestedDataStructure()
+ {
+     // The GC must be able to traverse deeply nested objects, otherwise this
+diff --git a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml
+new file mode 100644
+index 0000000000..206133bb39
+--- /dev/null
++++ b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml
+@@ -0,0 +1,11 @@
++import QtQuick 2.8
++
++ListView {
++    id: root
++    width: 200
++    height: 200
++
++    delegate: Text {
++        text: display
++    }
++}
+diff --git a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
+index 35f1e2c94d..1722447830 100644
+--- a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
++++ b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
+@@ -27,6 +27,8 @@
+ ****************************************************************************/
+ 
+ #include <QtTest/qtest.h>
++#include <QtCore/QConcatenateTablesProxyModel>
++#include <QtGui/QStandardItemModel>
+ #include <QtQml/qqmlcomponent.h>
+ #include <QtQmlModels/private/qqmldelegatemodel_p.h>
+ #include <QtQuick/qquickview.h>
+@@ -47,6 +49,7 @@ private slots:
+     void filterOnGroup_removeWhenCompleted();
+     void qtbug_86017();
+     void contextAccessedByHandler();
++    void redrawUponColumnChange();
+ };
+ 
+ class AbstractItemModel : public QAbstractItemModel
+@@ -186,6 +189,30 @@ void tst_QQmlDelegateModel::contextAccessedByHandler()
+     QVERIFY(root->property("works").toBool());
+ }
+ 
++void tst_QQmlDelegateModel::redrawUponColumnChange()
++{
++    QStandardItemModel m1;
++    m1.appendRow({
++            new QStandardItem("Banana"),
++            new QStandardItem("Coconut"),
++    });
++
++    QQuickView view(testFileUrl("redrawUponColumnChange.qml"));
++    QCOMPARE(view.status(), QQuickView::Ready);
++    view.show();
++    QQuickItem *root = view.rootObject();
++    root->setProperty("model", QVariant::fromValue<QObject *>(&m1));
++
++    QObject *item = root->property("currentItem").value<QObject *>();
++    QVERIFY(item);
++    QCOMPARE(item->property("text").toString(), "Banana");
++
++    QVERIFY(root);
++    m1.removeColumn(0);
++
++    QCOMPARE(item->property("text").toString(), "Coconut");
++}
++
+ QTEST_MAIN(tst_QQmlDelegateModel)
+ 
+ #include "tst_qqmldelegatemodel.moc"
+diff --git a/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp b/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
+index 5d635aa63b..824fd89e5b 100644
+--- a/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
++++ b/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
+@@ -76,10 +76,10 @@ void tst_qv4mm::multiWrappedQObjects()
+         QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 1);
+         QCOMPARE(engine2.memoryManager->m_pendingFreedObjectWrapperValue.size(), 0);
+ 
+-        // Moves the additional WeakValue from m_multiplyWrappedQObjects to
+-        // m_pendingFreedObjectWrapperValue. It's still alive after all.
++        // The additional WeakValue from m_multiplyWrappedQObjects hasn't been moved
++        // to m_pendingFreedObjectWrapperValue yet. It's still alive after all.
+         engine1.memoryManager->runGC();
+-        QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 2);
++        QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 1);
+ 
+         // engine2 doesn't own the object as engine1 was the first to wrap it above.
+         // Therefore, no effect here.
+diff --git a/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml b/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml
+new file mode 100644
+index 0000000000..889e480f3b
+--- /dev/null
++++ b/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml
+@@ -0,0 +1,13 @@
++import QtQuick 2.6
++
++Item {
++    visible: true
++    Item {
++        visible: false
++        Item {
++            objectName: "hiddenChild"
++            activeFocusOnTab: true
++            focus: true
++        }
++    }
++}
+diff --git a/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp b/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+index c8f251dbe1..c8ef36ee68 100644
+--- a/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
++++ b/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+@@ -67,6 +67,7 @@ private slots:
+     void activeFocusOnTab10();
+     void activeFocusOnTab_infiniteLoop_data();
+     void activeFocusOnTab_infiniteLoop();
++    void activeFocusOnTab_infiniteLoopControls();
+ 
+     void nextItemInFocusChain();
+     void nextItemInFocusChain2();
+@@ -1057,6 +1058,17 @@ void tst_QQuickItem::activeFocusOnTab_infiniteLoop()
+     QCOMPARE(item, window->rootObject());
+ }
+ 
++
++void tst_QQuickItem::activeFocusOnTab_infiniteLoopControls()
++{
++    auto source = testFileUrl("activeFocusOnTab_infiniteLoop3.qml");
++    QScopedPointer<QQuickView>window(new QQuickView());
++    window->setSource(source);
++    window->show();
++    QVERIFY(window->errors().isEmpty());
++    QTest::keyClick(window.get(), Qt::Key_Tab); // should not hang
++}
++
+ void tst_QQuickItem::nextItemInFocusChain()
+ {
+     if (!qt_tab_all_widgets())
+Submodule qtdoc c0c7bf07...79d6ef69:
+Submodule qtimageformats 2dcf2899..abe44c0f:
+diff --git a/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp b/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
+index dde783c..1bf9074 100644
+--- a/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
+@@ -462,8 +462,12 @@ static bool parseIconEntryInfo(ICNSEntry &icon)
+     if (isIconCompressed(icon))
+         return true;
+     // Icon depth:
+-    if (!depth.isEmpty())
+-        icon.depth = ICNSEntry::Depth(depth.toUInt());
++    if (!depth.isEmpty()) {
++        const uint depthUInt = depth.toUInt();
++        if (depthUInt > 32)
++            return false;
++        icon.depth = ICNSEntry::Depth(depthUInt);
++    }
+     // Try mono if depth not found
+     if (icon.depth == ICNSEntry::DepthUnknown)
+         icon.depth = ICNSEntry::DepthMono;
+@@ -515,6 +519,9 @@ static bool parseIconEntryInfo(ICNSEntry &icon)
+         }
+         icon.height = icon.width;
+     }
++    // Sanity check
++    if (icon.width == 0 || icon.width > 4096)
++        return false;
+     return true;
+ }
+ 
+@@ -685,7 +692,7 @@ bool QICNSHandler::canRead() const
+ bool QICNSHandler::read(QImage *outImage)
+ {
+     QImage img;
+-    if (!ensureScanned()) {
++    if (!ensureScanned() || m_currentIconIndex >= m_icons.size()) {
+         qWarning("QICNSHandler::read(): The device wasn't parsed properly!");
+         return false;
+     }
+@@ -892,7 +899,7 @@ bool QICNSHandler::scanDevice()
+             return false;
+ 
+         const qint64 blockDataOffset = device()->pos();
+-        if (!isBlockHeaderValid(blockHeader)) {
++        if (!isBlockHeaderValid(blockHeader, ICNSBlockHeaderSize + filelength - blockDataOffset)) {
+             qWarning("QICNSHandler::scanDevice(): Failed, bad header at pos %s. OSType \"%s\", length %u",
+                      QByteArray::number(blockDataOffset).constData(),
+                      nameFromOSType(blockHeader.ostype).constData(), blockHeader.length);
+@@ -927,11 +934,14 @@ bool QICNSHandler::scanDevice()
+         case ICNSBlockHeader::TypeOdrp:
+             // Icns container seems to have an embedded icon variant container
+             // Let's start a scan for entries
+-            while (device()->pos() < nextBlockOffset) {
++            while (!stream.atEnd() && device()->pos() < nextBlockOffset) {
+                 ICNSBlockHeader icon;
+                 stream >> icon;
++                if (stream.status() != QDataStream::Ok)
++                    return false;
+                 // Check for incorrect variant entry header and stop scan
+-                if (!isBlockHeaderValid(icon, blockDataLength))
++                quint64 remaining = blockDataLength - (device()->pos() - blockDataOffset);
++                if (!isBlockHeaderValid(icon, ICNSBlockHeaderSize + remaining))
+                     break;
+                 if (!addEntry(icon, device()->pos(), blockHeader.ostype))
+                     return false;
+@@ -1003,7 +1013,7 @@ bool QICNSHandler::scanDevice()
+             break;
+         }
+     }
+-    return true;
++    return (m_icons.size() > 0);
+ }
+ 
+ const ICNSEntry &QICNSHandler::getIconMask(const ICNSEntry &icon) const
+diff --git a/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp b/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
+index 5082023..cb34374 100644
+--- a/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
++++ b/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
+@@ -43,6 +43,7 @@
+ #include "qimage.h"
+ #include "qvariant.h"
+ #include "qcolor.h"
++#include "qimagereader.h"
+ 
+ #include <jasper/jasper.h>
+ #include <math.h> // for pow
+@@ -333,16 +334,46 @@ private:
+ Jpeg2000JasperReader::Jpeg2000JasperReader(QIODevice *iod, SubFormat format)
+     : jasperOk(true), ioDevice(iod), format(format), hasAlpha(false)
+ {
++#if JAS_VERSION_MAJOR < 3
+     if (jas_init()) {
+         jasperOk = false;
+         qDebug("Jasper Library initialization failed");
+     }
++#else
++    jas_conf_clear();
++#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
++    jas_conf_set_max_mem_usage(QImageReader::allocationLimit() * 1024 * 1024);
++#else
++    // 128MB seems to be enough.
++    jas_conf_set_max_mem_usage(128 * 1024 * 1024);
++#endif
++    if (jas_init_library()) {
++        jasperOk = false;
++        qDebug("Jasper library initialization failed");
++    }
++    if (jas_init_thread()) {
++        jas_cleanup_library();
++        jasperOk = false;
++        qDebug("Jasper thread initialization failed");
++    }
++#endif
+ }
+ 
+ Jpeg2000JasperReader::~Jpeg2000JasperReader()
+ {
++#if JAS_VERSION_MAJOR < 3
+     if (jasperOk)
+         jas_cleanup();
++#else
++    if (jasperOk) {
++        if (jas_cleanup_thread()) {
++            qDebug("Jasper thread cleanup failed");
++        }
++        if (jas_cleanup_library()) {
++            qDebug("Jasper library cleanup failed");
++        }
++    }
++#endif
+ }
+ 
+ /*! \internal
+@@ -857,7 +888,7 @@ bool Jpeg2000JasperReader::write(const QImage &image, int quality)
+     }
+ 
+     // Open an empty jasper stream that grows automatically
+-    jas_stream_t * memory_stream = jas_stream_memopen(0, -1);
++    jas_stream_t * memory_stream = jas_stream_memopen(0, 0);
+ 
+     // Jasper wants a non-const string.
+     char *str = qstrdup(jasperFormatString.toLatin1().constData());
+diff --git a/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp b/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
+index 1386750..ac8956c 100644
+--- a/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
+@@ -361,6 +361,8 @@ bool QTiffHandler::read(QImage *image)
+     }
+ 
+     TIFF *const tiff = d->tiff;
++    if (TIFFIsTiled(tiff) && TIFFTileSize64(tiff) > uint64_t(image->sizeInBytes())) // Corrupt image
++        return false;
+     const quint32 width = d->size.width();
+     const quint32 height = d->size.height();
+ 
+diff --git a/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp b/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
+index 82d38cb..d02eb05 100644
+--- a/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
+@@ -45,6 +45,7 @@
+ #include <qdebug.h>
+ #include <qpainter.h>
+ #include <qvariant.h>
++#include <QtEndian>
+ 
+ static const int riffHeaderSize = 12; // RIFF_HEADER_SIZE from webp/format_constants.h
+ 
+@@ -102,21 +103,23 @@ bool QWebpHandler::ensureScanned() const
+ 
+     m_scanState = ScanError;
+ 
+-    if (device()->isSequential()) {
+-        qWarning() << "Sequential devices are not supported";
++    QWebpHandler *that = const_cast<QWebpHandler *>(this);
++    const int headerBytesNeeded = sizeof(WebPBitstreamFeatures);
++    QByteArray header = device()->peek(headerBytesNeeded);
++    if (header.size() < headerBytesNeeded)
+         return false;
+-    }
+ 
+-    qint64 oldPos = device()->pos();
+-    device()->seek(0);
+-
+-    QWebpHandler *that = const_cast<QWebpHandler *>(this);
+-    QByteArray header = device()->peek(sizeof(WebPBitstreamFeatures));
++    // We do no random access during decoding, just a readAll() of the whole image file. So if
++    // if it is all available already, we can accept a sequential device. The riff header contains
++    // the file size minus 8 bytes header
++    qint64 byteSize = qFromLittleEndian<quint32>(header.constData() + 4);
++    if (device()->isSequential() && device()->bytesAvailable() < byteSize + 8) {
++        qWarning() << "QWebpHandler: Insufficient data available in sequential device";
++        return false;
++    }
+     if (WebPGetFeatures((const uint8_t*)header.constData(), header.size(), &(that->m_features)) == VP8_STATUS_OK) {
+         if (m_features.has_animation) {
+             // For animation, we have to read and scan whole file to determine loop count and images count
+-            device()->seek(oldPos);
+-
+             if (that->ensureDemuxer()) {
+                 that->m_loop = WebPDemuxGetI(m_demuxer, WEBP_FF_LOOP_COUNT);
+                 that->m_frameCount = WebPDemuxGetI(m_demuxer, WEBP_FF_FRAME_COUNT);
+@@ -126,17 +129,13 @@ bool QWebpHandler::ensureScanned() const
+                 if (that->m_features.has_alpha)
+                     that->m_composited->fill(Qt::transparent);
+ 
+-                // We do not reset device position since we have read in all data
+                 m_scanState = ScanSuccess;
+-                return true;
+             }
+         } else {
+             m_scanState = ScanSuccess;
+         }
+     }
+ 
+-    device()->seek(oldPos);
+-
+     return m_scanState == ScanSuccess;
+ }
+ 
+@@ -159,7 +158,7 @@ bool QWebpHandler::ensureDemuxer()
+ 
+ bool QWebpHandler::read(QImage *image)
+ {
+-    if (!ensureScanned() || device()->isSequential() || !ensureDemuxer())
++    if (!ensureScanned() || !ensureDemuxer())
+         return false;
+ 
+     QRect prevFrameRect;
+Submodule qtlocation 98a5c511..f991e28c:
+diff --git a/qtlocation/src/location/configure.json b/qtlocation/src/location/configure.json
+index 6d01a9a3..d1e623a1 100644
+--- a/qtlocation/src/location/configure.json
++++ b/qtlocation/src/location/configure.json
+@@ -9,7 +9,7 @@
+             "label": "Qt.labs.location experimental QML plugin",
+             "purpose": "Provides experimental QtLocation QML types",
+             "section": "Location",
+-            "condition": "config.opengl",
++            "condition": "features.opengl",
+             "output": [ "privateFeature" ]
+         },
+         "geoservices_osm": {
+diff --git a/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp b/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
+index a978573d..11e1466f 100644
+--- a/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
++++ b/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
+@@ -158,7 +158,7 @@ void QGeoMapObjectQSGSupport::updateMapObjects(QSGNode *root, QQuickWindow *wind
+     if (!root)
+         return;
+ 
+-    if (m_mapObjectsRootNode && m_mapObjectsRootNode->parent())
++    if (m_mapObjectsRootNode && !m_mapObjectsRootNode->parent())
+         root->appendChildNode(m_mapObjectsRootNode.get());
+ 
+     if (!m_mapObjectsRootNode) {
+diff --git a/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
+index 5a40467e..d123c6a8 100644
+--- a/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
+@@ -59,8 +59,10 @@ QT_BEGIN_NAMESPACE
+ static const QString kPrefixEsri(QStringLiteral("esri."));
+ static const QString kParamUserAgent(kPrefixEsri + QStringLiteral("useragent"));
+ 
+-static const QString kUrlGeocode(QStringLiteral("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates"));
+-static const QString kUrlReverseGeocode(QStringLiteral("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode"));
++static const QString kUrlGeocode(QStringLiteral("https://geocode.arcgis.com/arcgis/rest/services/"
++                                                "World/GeocodeServer/findAddressCandidates"));
++static const QString kUrlReverseGeocode(QStringLiteral(
++        "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode"));
+ 
+ static QString addressToQuery(const QGeoAddress &address)
+ {
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
+index 17492d94..96c12b1b 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
+@@ -46,7 +46,8 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-// JSON reference: http://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
++// JSON reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
+ 
+ static const QString kErrorMessage(QStringLiteral("Error %1: %2."));
+ static const QString kErrorJson(QStringLiteral("Error: invalide JSON document."));
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
+index 8cadfb29..92b6bb13 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
+@@ -44,7 +44,8 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-// JSON reference: http://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
++// JSON reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
+ 
+ GeoRouteReplyEsri::GeoRouteReplyEsri(QNetworkReply *reply, const QGeoRouteRequest &request,
+                                      QObject *parent) :
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
+index 0e6bc2c7..ed613f4b 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
+@@ -48,7 +48,8 @@ static const QString kPrefixEsri(QStringLiteral("esri."));
+ static const QString kParamUserAgent(kPrefixEsri + QStringLiteral("useragent"));
+ static const QString kParamToken(kPrefixEsri + QStringLiteral("token"));
+ 
+-static const QString kUrlRouting(QStringLiteral("http://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve"));
++static const QString kUrlRouting(QStringLiteral(
++        "https://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve"));
+ 
+ GeoRoutingManagerEngineEsri::GeoRoutingManagerEngineEsri(const QVariantMap &parameters,
+                                                          QGeoServiceProvider::Error *error,
+@@ -70,7 +71,8 @@ GeoRoutingManagerEngineEsri::~GeoRoutingManagerEngineEsri()
+ {
+ }
+ 
+-// REST reference: http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
++// REST reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
+ 
+ QGeoRouteReply *GeoRoutingManagerEngineEsri::calculateRoute(const QGeoRouteRequest &request)
+ {
+@@ -125,7 +127,7 @@ void GeoRoutingManagerEngineEsri::replyError(QGeoRouteReply::Error errorCode, co
+ QString GeoRoutingManagerEngineEsri::preferedDirectionLangage()
+ {
+     // list of supported langages is defined in:
+-    // http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
++    // https://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
+     const QStringList supportedLanguages = {
+         "ar", // Generate directions in Arabic
+         "cs", // Generate directions in Czech
+diff --git a/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
+index 5d15835d..24148f95 100644
+--- a/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
+@@ -230,7 +230,8 @@ QGeoMap *GeoTiledMappingManagerEngineEsri::createMap()
+ // ${y} = Y
+ // ${token} = Token
+ 
+-// template = 'http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{{z}}/{{y}}/{{x}}.png'
++// template =
++// 'https://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{{z}}/{{y}}/{{x}}.png'
+ 
+ bool GeoTiledMappingManagerEngineEsri::initializeMapSources(QGeoServiceProvider::Error *error,
+                                                             QString *errorString,
+diff --git a/qtlocation/src/plugins/geoservices/esri/maps.json b/qtlocation/src/plugins/geoservices/esri/maps.json
+index 8167ae7d..862e087d 100644
+--- a/qtlocation/src/plugins/geoservices/esri/maps.json
++++ b/qtlocation/src/plugins/geoservices/esri/maps.json
+@@ -6,8 +6,8 @@
+             "description": "ArcGIS Online World Street Map",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=3b93337983e9436f8db950e38a8629af'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=3b93337983e9436f8db950e38a8629af'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -16,8 +16,8 @@
+             "": "ArcGIS Online World Imagery",
+             "mobile": true,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -26,8 +26,8 @@
+             "description": "ArcGIS Online World Terrain Base",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=c61ad8ab017d49e1a82f580ee1298931'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=c61ad8ab017d49e1a82f580ee1298931'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -36,8 +36,8 @@
+             "description": "ArcGIS Online World Topography",
+             "mobile": true,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=30e5fe3149c34df1ba922e6f5bbf808f'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=30e5fe3149c34df1ba922e6f5bbf808f'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -46,8 +46,8 @@
+             "description": "This map presents land cover and detailed topographic maps for the United States.",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=99cd5fbd98934028802b4f797c4b1732'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=99cd5fbd98934028802b4f797c4b1732'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -56,8 +56,8 @@
+             "description": "National Geographic World Map",
+             "mobile": false,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=b9b1b422198944fbbd5250b3241691b6'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=b9b1b422198944fbbd5250b3241691b6'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -66,8 +66,8 @@
+             "description": "Thematic content providing a neutral background with minimal colors",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=ed712cb1db3e4bae9e85329040fb9a49'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=ed712cb1db3e4bae9e85329040fb9a49'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -76,8 +76,8 @@
+             "description": "Natural Earth physical map for the world",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=c4ec722a1cd34cf0a23904aadf8923a0'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=c4ec722a1cd34cf0a23904aadf8923a0'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -86,8 +86,8 @@
+             "description": "Portrays surface elevation as shaded relief",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=9c5370d0b54f4de1b48a3792d7377ff2'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=9c5370d0b54f4de1b48a3792d7377ff2'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -96,8 +96,8 @@
+             "description": "This map is designed to be used as a basemap by marine GIS professionals and as a reference map by anyone interested in ocean data",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=1e126e7520f9466c9ca28b8f28b5e500'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=1e126e7520f9466c9ca28b8f28b5e500'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -106,8 +106,8 @@
+             "description": "Thematic content providing a neutral background with minimal colors",
+             "mobile": false,
+             "night": true,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=a284a9b99b3446a3910d4144a50990f6'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=a284a9b99b3446a3910d4144a50990f6'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -116,8 +116,8 @@
+             "description": "DeLorme’s topographic basemap is a seamless global data set that portrays transportation, hydrography, jurisdiction boundaries, and major geographic features",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/Specialty/DeLorme_World_Base_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=b165c3df453e4be6b5ac4fdb241effbe'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/Specialty/DeLorme_World_Base_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=b165c3df453e4be6b5ac4fdb241effbe'>Esri</a> contributors"
+         }
+     ]
+ }
+diff --git a/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
+index 3858ddf5..af66f28e 100644
+--- a/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
+@@ -63,8 +63,10 @@ static const QString kCountriesKey(QStringLiteral("detailedCountries"));
+ static const QString kLocalizedNamesKey(QStringLiteral("localizedNames"));
+ static const QString kMaxLocationsKey(QStringLiteral("maxLocations"));
+ 
+-static const QUrl kUrlGeocodeServer("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer?f=pjson");
+-static const QUrl kUrlFindAddressCandidates("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates");
++static const QUrl kUrlGeocodeServer(
++        "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer?f=pjson");
++static const QUrl kUrlFindAddressCandidates("https://geocode.arcgis.com/arcgis/rest/services/World/"
++                                            "GeocodeServer/findAddressCandidates");
+ 
+ PlaceManagerEngineEsri::PlaceManagerEngineEsri(const QVariantMap &parameters, QGeoServiceProvider::Error *error,
+                                                QString *errorString) :
+Submodule qtmultimedia f0344079..0d7cc33a:
+diff --git a/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp b/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
+index 2b5325132..b68b4af1b 100644
+--- a/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
++++ b/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
+@@ -402,6 +402,8 @@ int QPulseAudioInput::bytesReady() const
+ 
+ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ {
++    Q_ASSERT(data != nullptr || len == 0);
++
+     m_bytesAvailable = checkBytesReady();
+ 
+     setError(QAudio::NoError);
+@@ -411,7 +413,8 @@ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ 
+     if (!m_pullMode && !m_tempBuffer.isEmpty()) {
+         readBytes = qMin(static_cast<int>(len), m_tempBuffer.size());
+-        memcpy(data, m_tempBuffer.constData(), readBytes);
++        if (readBytes)
++            memcpy(data, m_tempBuffer.constData(), readBytes);
+         m_totalTimeValue += readBytes;
+ 
+         if (readBytes < m_tempBuffer.size()) {
+@@ -502,9 +505,10 @@ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ 
+ void QPulseAudioInput::applyVolume(const void *src, void *dest, int len)
+ {
++    Q_ASSERT((src && dest) || len == 0);
+     if (m_volume < 1.f)
+         QAudioHelperInternal::qMultiplySamples(m_volume, m_format, src, dest, len);
+-    else
++    else if (len)
+         memcpy(dest, src, len);
+ }
+ 
+Submodule qtpim 02efef5e...f9a8f0fc (commits not present)
+Submodule qtquick3d b85cf622..47defc8b:
+diff --git a/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro b/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
+index ca5c499e..174a075b 100644
+--- a/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
++++ b/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
+@@ -10,7 +10,7 @@ QT_FOR_CONFIG += assetimporters-private
+ include($$OUT_PWD/../qtassetimporters-config.pri)
+ 
+ qtConfig(system-assimp):!if(cross_compile:host_build) {
+-    QMAKE_USE_PRIVATE += assimp
++    QMAKE_USE_PRIVATE += quick3d-assimp
+ } else {
+     include(../../../3rdparty/assimp/assimp.pri)
+ }
+Submodule qtquickcontrols2 3a657dc0..56ce8233:
+diff --git a/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp b/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
+index e5fe734f7..e36922775 100644
+--- a/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
++++ b/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
+@@ -38,6 +38,7 @@
+ #include "qwidgetplatformmenuitem_p.h"
+ 
+ #include <QtGui/qwindow.h>
++#include <QtGui/private/qhighdpiscaling_p.h>
+ #include <QtWidgets/qmenu.h>
+ #include <QtWidgets/qaction.h>
+ 
+@@ -145,7 +146,7 @@ void QWidgetPlatformMenu::showPopup(const QWindow *window, const QRect &targetRe
+ 
+     QPoint targetPos = targetRect.bottomLeft();
+     if (window)
+-        targetPos = window->mapToGlobal(targetPos);
++        targetPos = window->mapToGlobal(QHighDpi::fromNativeLocalPosition(targetPos, window));
+ 
+     const QWidgetPlatformMenuItem *widgetItem = qobject_cast<const QWidgetPlatformMenuItem *>(item);
+     m_menu->popup(targetPos, widgetItem ? widgetItem->action() : nullptr);
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
+index 950e4e099..b81fbea0b 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
+@@ -387,6 +387,17 @@ void QQuickAbstractButtonPrivate::itemImplicitHeightChanged(QQuickItem *item)
+         emit q->implicitIndicatorHeightChanged();
+ }
+ 
++void QQuickAbstractButtonPrivate::itemDestroyed(QQuickItem *item)
++{
++    Q_Q(QQuickAbstractButton);
++    QQuickControlPrivate::itemDestroyed(item);
++    if (item == indicator) {
++        indicator = nullptr;
++        emit q->implicitIndicatorWidthChanged();
++        emit q->implicitIndicatorHeightChanged();
++    }
++}
++
+ QQuickAbstractButton *QQuickAbstractButtonPrivate::findCheckedButton() const
+ {
+     Q_Q(const QQuickAbstractButton);
+@@ -1176,6 +1187,12 @@ QAccessible::Role QQuickAbstractButton::accessibleRole() const
+     }
+     return QAccessible::Button;
+ }
++
++void QQuickAbstractButton::accessiblePressAction()
++{
++    Q_D(QQuickAbstractButton);
++    d->trigger();
++}
+ #endif
+ 
+ QT_END_NAMESPACE
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
+index 0fa48980e..ab66220d0 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
+@@ -209,6 +209,7 @@ protected:
+ #if QT_CONFIG(accessibility)
+     void accessibilityActiveChanged(bool active) override;
+     QAccessible::Role accessibleRole() const override;
++    Q_INVOKABLE void accessiblePressAction();
+ #endif
+ 
+ private:
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
+index 9291c1a87..b729720f2 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
+@@ -109,6 +109,7 @@ public:
+ 
+     void itemImplicitWidthChanged(QQuickItem *item) override;
+     void itemImplicitHeightChanged(QQuickItem *item) override;
++    void itemDestroyed(QQuickItem *item) override;
+ 
+     // copied from qabstractbutton.cpp
+     static const int AUTO_REPEAT_DELAY = 300;
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp b/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
+index 2041e7741..8610cdfae 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
+@@ -145,7 +145,7 @@ int QQuickActionPrivate::ShortcutEntry::shortcutId() const
+ 
+ void QQuickActionPrivate::ShortcutEntry::grab(const QKeySequence &shortcut, bool enabled)
+ {
+-    if (shortcut.isEmpty())
++    if (shortcut.isEmpty() || m_shortcutId)
+         return;
+ 
+     Qt::ShortcutContext context = Qt::WindowShortcut; // TODO
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp b/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
+index f38c2b09c..6eed2a024 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
+@@ -225,6 +225,7 @@ void QQuickContainerPrivate::cleanup()
+     QObject::disconnect(contentModel, &QQmlObjectModel::countChanged, q, &QQuickContainer::countChanged);
+     QObject::disconnect(contentModel, &QQmlObjectModel::childrenChanged, q, &QQuickContainer::contentChildrenChanged);
+     delete contentModel;
++    contentModel = nullptr;
+ }
+ 
+ QQuickItem *QQuickContainerPrivate::itemAt(int index) const
+@@ -436,7 +437,7 @@ void QQuickContainerPrivate::contentChildren_clear(QQmlListProperty<QQuickItem>
+ void QQuickContainerPrivate::updateContentWidth()
+ {
+     Q_Q(QQuickContainer);
+-    if (hasContentWidth || qFuzzyCompare(contentWidth, implicitContentWidth))
++    if (hasContentWidth || qFuzzyCompare(contentWidth, implicitContentWidth) || !contentModel)
+         return;
+ 
+     contentWidth = implicitContentWidth;
+@@ -446,7 +447,7 @@ void QQuickContainerPrivate::updateContentWidth()
+ void QQuickContainerPrivate::updateContentHeight()
+ {
+     Q_Q(QQuickContainer);
+-    if (hasContentHeight || qFuzzyCompare(contentHeight, implicitContentHeight))
++    if (hasContentHeight || qFuzzyCompare(contentHeight, implicitContentHeight) || !contentModel)
+         return;
+ 
+     contentHeight = implicitContentHeight;
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp b/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
+index bbbd0e622..1f4b47343 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
+@@ -845,6 +845,13 @@ void QQuickControlPrivate::executeBackground(bool complete)
+         quickCompleteDeferred(q, backgroundName(), background);
+ }
+ 
++/*
++    \internal
++
++    Hides an item that was replaced by a newer one, rather than
++    deleting it, as the item is typically created in QML and hence
++    we don't own it.
++*/
+ void QQuickControlPrivate::hideOldItem(QQuickItem *item)
+ {
+     if (!item)
+@@ -863,6 +870,29 @@ void QQuickControlPrivate::hideOldItem(QQuickItem *item)
+ #endif
+ }
+ 
++/*
++    \internal
++
++    Named "unhide" because it's used for cases where an item
++    that was previously hidden by \l hideOldItem() wants to be
++    shown by a control again, such as a ScrollBar in ScrollView.
++*/
++void QQuickControlPrivate::unhideOldItem(QQuickControl *control, QQuickItem *item)
++{
++    Q_ASSERT(item);
++    qCDebug(lcItemManagement) << "unhiding old item" << item;
++
++    item->setVisible(true);
++    item->setParentItem(control);
++
++#if QT_CONFIG(accessibility)
++    // Add the item back in to the accessibility tree.
++    QQuickAccessibleAttached *accessible = accessibleAttached(item);
++    if (accessible)
++        accessible->setIgnored(false);
++#endif
++}
++
+ void QQuickControlPrivate::updateBaselineOffset()
+ {
+     Q_Q(QQuickControl);
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h b/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
+index 8e979079e..a6e624c91 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
+@@ -173,6 +173,7 @@ public:
+     virtual void executeBackground(bool complete = false);
+ 
+     static void hideOldItem(QQuickItem *item);
++    static void unhideOldItem(QQuickControl *control, QQuickItem *item);
+ 
+     void updateBaselineOffset();
+ 
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp b/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
+index e6db14eb5..6197d1547 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
+@@ -237,7 +237,7 @@ static QRectF alignedRect(Qt::LayoutDirection direction, Qt::Alignment alignment
+ void QQuickDialogButtonBoxPrivate::resizeContent()
+ {
+     Q_Q(QQuickDialogButtonBox);
+-    if (!contentItem)
++    if (!contentItem || !contentModel)
+         return;
+ 
+     QRectF geometry = q->boundingRect().adjusted(q->leftPadding(), q->topPadding(), -q->rightPadding(), -q->bottomPadding());
+@@ -322,6 +322,9 @@ void QQuickDialogButtonBoxPrivate::updateLayout()
+ qreal QQuickDialogButtonBoxPrivate::getContentWidth() const
+ {
+     Q_Q(const QQuickDialogButtonBox);
++    if (!contentModel)
++        return 0;
++
+     const int count = contentModel->count();
+     const qreal totalSpacing = qMax(0, count - 1) * spacing;
+     qreal totalWidth = totalSpacing;
+@@ -341,6 +344,9 @@ qreal QQuickDialogButtonBoxPrivate::getContentWidth() const
+ qreal QQuickDialogButtonBoxPrivate::getContentHeight() const
+ {
+     Q_Q(const QQuickDialogButtonBox);
++    if (!contentModel)
++        return 0;
++
+     const int count = contentModel->count();
+     qreal maxHeight = 0;
+     for (int i = 0; i < count; ++i) {
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp b/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
+index 91bd59184..0ce518f84 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
+@@ -399,8 +399,11 @@ void QQuickOverlay::itemChange(ItemChange change, const ItemChangeData &data)
+     Q_D(QQuickOverlay);
+     QQuickItem::itemChange(change, data);
+ 
+-    if (change == ItemChildAddedChange || change == ItemChildRemovedChange)
++    if (change == ItemChildAddedChange || change == ItemChildRemovedChange) {
+         setVisible(!d->allDrawers.isEmpty() || !childItems().isEmpty());
++        if (data.item->parent() == d->mouseGrabberPopup)
++            d->setMouseGrabberPopup(nullptr);
++    }
+ }
+ 
+ void QQuickOverlay::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp b/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
+index 4e2f509db..1c4b308cd 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
+@@ -797,6 +797,14 @@ void QQuickScrollBarAttachedPrivate::initHorizontal()
+     if (parent && parent == flickable->parentItem())
+         horizontal->stackAfter(flickable);
+ 
++    // If a scroll bar was previously hidden (due to e.g. setting a new contentItem
++    // on a ScrollView), we need to make sure that we un-hide it.
++    // We don't bother checking if the item is actually the old one, because
++    // if it's not, all of the things the function does (setting parent, visibility, etc.)
++    // should be no-ops anyway.
++    if (auto control = qobject_cast<QQuickControl*>(q_ptr->parent()))
++        QQuickControlPrivate::unhideOldItem(control, horizontal);
++
+     layoutHorizontal();
+     horizontal->setSize(area->property("widthRatio").toReal());
+     horizontal->setPosition(area->property("xPosition").toReal());
+@@ -818,6 +826,9 @@ void QQuickScrollBarAttachedPrivate::initVertical()
+     if (parent && parent == flickable->parentItem())
+         vertical->stackAfter(flickable);
+ 
++    if (auto control = qobject_cast<QQuickControl*>(q_ptr->parent()))
++        QQuickControlPrivate::unhideOldItem(control, vertical);
++
+     layoutVertical();
+     vertical->setSize(area->property("heightRatio").toReal());
+     vertical->setPosition(area->property("yPosition").toReal());
+diff --git a/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml b/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
+index 0e8b08352..cd4931184 100644
+--- a/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
++++ b/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
+@@ -576,4 +576,51 @@ TestCase {
+         verify(newHorizontalScrollBar.visible)
+         verify(!oldHorizontalScrollBar.visible)
+     }
++
++    Component {
++        id: bindingToContentItemAndStandaloneFlickable
++
++        Item {
++            width: 200
++            height: 200
++
++            property alias scrollView: scrollView
++
++            ScrollView {
++                id: scrollView
++                anchors.fill: parent
++                contentItem: listView
++
++                property Item someBinding: contentItem
++            }
++            ListView {
++                id: listView
++                model: 10
++                delegate: ItemDelegate {
++                    text: modelData
++                    width: listView.width
++                }
++            }
++        }
++    }
++
++    // Tests that scroll bars show up for a ScrollView where
++    // - its contentItem is declared as a standalone, separate item
++    // - there is a binding to contentItem (which causes a default Flickable to be created)
++    function test_bindingToContentItemAndStandaloneFlickable() {
++        let root = createTemporaryObject(bindingToContentItemAndStandaloneFlickable, testCase)
++        verify(root)
++
++        let control = root.scrollView
++        let verticalScrollBar = control.ScrollBar.vertical
++        let horizontalScrollBar = control.ScrollBar.horizontal
++        compare(verticalScrollBar.parent, control)
++        compare(horizontalScrollBar.parent, control)
++        verify(verticalScrollBar.visible)
++        verify(horizontalScrollBar.visible)
++
++        mouseDrag(verticalScrollBar, verticalScrollBar.width / 2, verticalScrollBar.height / 2, 0, 50)
++        verify(verticalScrollBar.active)
++        verify(horizontalScrollBar.active)
++    }
+ }
+diff --git a/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml b/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
+index b3fab41ca..10b6baa02 100644
+--- a/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
++++ b/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
+@@ -608,4 +608,27 @@ TestCase {
+         mouseClick(control.indicator)
+         verify(control.activeFocus)
+     }
++
++    Component {
++        id: deletionOrder1
++        Item {
++            Image { id: innerImage }
++            Switch { indicator: innerImage }
++        }
++    }
++
++    Component {
++        id: deletionOrder2
++        Item {
++            Switch { indicator: innerImage }
++            Image { id: innerImage }
++        }
++    }
++
++    function test_deletionOrder() {
++        var control1 = createTemporaryObject(deletionOrder1, testCase)
++        verify(control1)
++        var control2 = createTemporaryObject(deletionOrder2, testCase)
++        verify(control2)
++    }
+ }
+diff --git a/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml b/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml
+new file mode 100644
+index 000000000..9e4598b9f
+--- /dev/null
++++ b/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml
+@@ -0,0 +1,78 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the test suite of the Qt Toolkit.
++**
++** $QT_BEGIN_LICENSE:BSD$
++** Commercial License Usage
++** Licensees holding valid commercial Qt licenses may use this file in
++** accordance with the commercial license agreement provided with the
++** Software or, alternatively, in accordance with the terms contained in
++** a written agreement between you and The Qt Company. For licensing terms
++** and conditions see https://www.qt.io/terms-conditions. For further
++** information use the contact form at https://www.qt.io/contact-us.
++**
++** BSD License Usage
++** Alternatively, you may use this file under the terms of the BSD license
++** as follows:
++**
++** "Redistribution and use in source and binary forms, with or without
++** modification, are permitted provided that the following conditions are
++** met:
++**   * Redistributions of source code must retain the above copyright
++**     notice, this list of conditions and the following disclaimer.
++**   * Redistributions in binary form must reproduce the above copyright
++**     notice, this list of conditions and the following disclaimer in
++**     the documentation and/or other materials provided with the
++**     distribution.
++**   * Neither the name of The Qt Company Ltd nor the names of its
++**     contributors may be used to endorse or promote products derived
++**     from this software without specific prior written permission.
++**
++**
++** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
++** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
++** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
++** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
++** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
++** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
++** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
++** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
++** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
++** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
++** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
++**
++** $QT_END_LICENSE$
++**
++****************************************************************************/
++
++import QtQuick 2.15
++import QtQuick.Controls 2.15
++
++ApplicationWindow {
++    id: window
++    width: 400
++    height: 400
++    title: "releaseAfterExitTransition"
++
++    property alias popup: popup
++    property alias modalPopup: modalPopup
++
++    Popup {
++        id: popup
++        y: parent.height - height
++        width: 50
++        height: 50
++    }
++
++    Popup {
++        id: modalPopup
++        modal: true
++        y: parent.height - height
++        width: 50
++        height: 50
++        exit:  Transition { PauseAnimation { duration: 100 } }
++    }
++}
+diff --git a/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp b/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
+index 54952d128..3d50e2dd4 100644
+--- a/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
++++ b/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
+@@ -100,6 +100,7 @@ private slots:
+     void invisibleToolTipOpen();
+     void centerInOverlayWithinStackViewItem();
+     void destroyDuringExitTransition();
++    void releaseAfterExitTransition();
+ };
+ 
+ void tst_QQuickPopup::initTestCase()
+@@ -1575,6 +1576,34 @@ void tst_QQuickPopup::destroyDuringExitTransition()
+     QVERIFY(!button->isDown());
+ }
+ 
++void tst_QQuickPopup::releaseAfterExitTransition()
++{
++    QQuickApplicationHelper helper(this, "releaseAfterExitTransition.qml");
++    QVERIFY2(helper.ready, helper.failureMessage());
++
++    QQuickWindow *window = helper.window;
++    window->show();
++    QVERIFY(QTest::qWaitForWindowActive(window));
++
++    QQuickOverlay *overlay = QQuickOverlay::overlay(window);
++    QQuickPopup *modalPopup = window->property("modalPopup").value<QQuickPopup *>();
++    QQuickPopup *popup = window->property("popup").value<QQuickPopup *>();
++
++    modalPopup->open();
++    QTRY_VERIFY(modalPopup->isOpened());
++
++    QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++    // wait until the transition is finished and the overlay hides itself
++    QTRY_VERIFY(!overlay->isVisible());
++    QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++
++    popup->open();
++    QTRY_VERIFY(popup->isOpened());
++    QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++    QTRY_VERIFY(!popup->isOpened());
++}
++
++
+ QTEST_QUICKCONTROLS_MAIN(tst_QQuickPopup)
+ 
+ #include "tst_qquickpopup.moc"
+Submodule qtscript 5be95f96...4d8e4bd2 (commits not present)
+Submodule qtspeech 17fc9fde..255845e2:
+diff --git a/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp b/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
+index 6eb74b8..bcc7dd1 100644
+--- a/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
++++ b/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
+@@ -357,7 +357,9 @@ QVector<QLocale> QTextToSpeechEngineSpeechd::availableLocales() const
+ 
+ QVector<QVoice> QTextToSpeechEngineSpeechd::availableVoices() const
+ {
+-    return m_voices.values(m_currentLocale.name()).toVector();
++    QList<QVoice> resultList = m_voices.values(m_currentLocale.name());
++    std::reverse(resultList.begin(), resultList.end());
++    return resultList.toVector();
+ }
+ 
+ // We have no way of knowing our own client_id since speech-dispatcher seems to be incomplete
+Submodule qtsvg 0c05780e..a7a0f249:
+diff --git a/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp b/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
+index 561e77e..12e0574 100644
+--- a/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
++++ b/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
+@@ -191,6 +191,8 @@ bool QSvgIOHandler::read(QImage *image)
+             }
+         }
+         if (!finalSize.isEmpty()) {
++            if (qMax(finalSize.width(), finalSize.height()) > 0xffff)
++                return false; // Assume corrupted file
+             image->fill(d->backColor.rgba());
+             QPainter p(image);
+             d->r.render(&p, bounds);
+diff --git a/qtsvg/src/svg/qsvghandler.cpp b/qtsvg/src/svg/qsvghandler.cpp
+index a5f877f..8dda563 100644
+--- a/qtsvg/src/svg/qsvghandler.cpp
++++ b/qtsvg/src/svg/qsvghandler.cpp
+@@ -1393,9 +1393,10 @@ static void parseFont(QSvgNode *node,
+         case FontSizeNone:
+             break;
+         case FontSizeValue: {
+-            QSvgHandler::LengthType dummy; // should always be pixel size
+-            fontStyle->setSize(qMin(parseLength(attributes.fontSize, dummy, handler),
+-                                    qreal(0xffff)));
++            QSvgHandler::LengthType type;
++            qreal fs = parseLength(attributes.fontSize, type, handler);
++            fs = convertToPixels(fs, true, type);
++            fontStyle->setSize(qMin(fs, qreal(0xffff)));
+         }
+             break;
+         default:
+@@ -2513,6 +2514,8 @@ static bool parseAnimateTransformNode(QSvgNode *parent,
+             ++s;
+         }
+     }
++    if (vals.count() % 3 != 0)
++        return false;
+ 
+     bool ok = true;
+     int begin = parseClockValue(beginStr, &ok);
+@@ -2576,6 +2579,8 @@ static QSvgNode *createCircleNode(QSvgNode *parent,
+     qreal ncx = toDouble(cx);
+     qreal ncy = toDouble(cy);
+     qreal nr  = toDouble(r);
++    if (nr < 0.0)
++        return nullptr;
+ 
+     QRectF rect(ncx-nr, ncy-nr, nr*2, nr*2);
+     QSvgNode *circle = new QSvgCircle(parent, rect);
+@@ -3046,15 +3051,16 @@ static QSvgStyleProperty *createRadialGradientNode(QSvgNode *node,
+ 
+     qreal ncx = 0.5;
+     qreal ncy = 0.5;
+-    qreal nr  = 0.5;
+     if (!cx.isEmpty())
+         ncx = toDouble(cx);
+     if (!cy.isEmpty())
+         ncy = toDouble(cy);
++
++    qreal nr = 0.0;
+     if (!r.isEmpty())
+         nr = toDouble(r);
+-    if (nr < 0.5)
+-        nr = 0.5;
++    if (nr <= 0.0)
++        return nullptr;
+ 
+     qreal nfx = ncx;
+     if (!fx.isEmpty())
+@@ -3350,7 +3356,9 @@ static QSvgNode *createTextNode(QSvgNode *parent,
+     //### editable and rotate not handled
+     QSvgHandler::LengthType type;
+     qreal nx = parseLength(x, type, handler);
++    nx = convertToPixels(nx, true, type);
+     qreal ny = parseLength(y, type, handler);
++    ny = convertToPixels(ny, true, type);
+ 
+     QSvgNode *text = new QSvgText(parent, QPointF(nx, ny));
+     return text;
+@@ -3691,9 +3699,7 @@ void QSvgHandler::parse()
+         case QXmlStreamReader::EndElement:
+             endElement(xml->name());
+             ++remainingUnfinishedElements;
+-            // if we are using somebody else's qxmlstreamreader
+-            // we should not read until the end of the stream
+-            done = !m_ownsReader && (xml->name() == QLatin1String("svg"));
++            done = (xml->name() == QLatin1String("svg"));
+             break;
+         case QXmlStreamReader::Characters:
+             characters(xml->text());
+diff --git a/qtsvg/src/svg/qsvgstructure.cpp b/qtsvg/src/svg/qsvgstructure.cpp
+index b89608b..89c9e4e 100644
+--- a/qtsvg/src/svg/qsvgstructure.cpp
++++ b/qtsvg/src/svg/qsvgstructure.cpp
+@@ -255,9 +255,13 @@ inline static bool isSupportedSvgFeature(const QString &str)
+     };
+ 
+     if (str.length() <= MAX_WORD_LENGTH && str.length() >= MIN_WORD_LENGTH) {
++        const char16_t unicode44 = str.at(44).unicode();
++        const char16_t unicode45 = str.at(45).unicode();
++        if (unicode44 >= sizeof(asso_values) || unicode45 >= sizeof(asso_values))
++            return false;
+         const int key = str.length()
+-                        + asso_values[str.at(45).unicode()]
+-                        + asso_values[str.at(44).unicode()];
++                        + asso_values[unicode45]
++                        + asso_values[unicode44];
+         if (key <= MAX_HASH_VALUE && key >= 0)
+             return str == QLatin1String(wordlist[key]);
+     }
+diff --git a/qtsvg/src/svg/qsvgtinydocument.cpp b/qtsvg/src/svg/qsvgtinydocument.cpp
+index 63d0797..19e7154 100644
+--- a/qtsvg/src/svg/qsvgtinydocument.cpp
++++ b/qtsvg/src/svg/qsvgtinydocument.cpp
+@@ -433,8 +433,16 @@ void QSvgTinyDocument::draw(QPainter *p, QSvgExtraStates &)
+     draw(p);
+ }
+ 
++static bool isValidMatrix(const QTransform &transform)
++{
++    qreal determinant = transform.determinant();
++    return qIsFinite(determinant);
++}
++
+ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect, const QRectF &sourceRect)
+ {
++    QTransform oldTransform = p->worldTransform();
++
+     QRectF target = targetRect;
+     if (target.isEmpty()) {
+         QPaintDevice *dev = p->device();
+@@ -487,6 +495,9 @@ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect,
+         }
+ #endif
+     }
++
++    if (!isValidMatrix(p->worldTransform()))
++        p->setWorldTransform(oldTransform);
+ }
+ 
+ QRectF QSvgTinyDocument::boundsOnElement(const QString &id) const
+diff --git a/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp b/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
+index 36c76ec..db71e02 100644
+--- a/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
++++ b/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
+@@ -86,6 +86,8 @@ private slots:
+     void oss_fuzz_23731();
+     void oss_fuzz_24131();
+     void oss_fuzz_24738();
++    void illegalAnimateTransform_data();
++    void illegalAnimateTransform();
+ 
+ #ifndef QT_NO_COMPRESS
+     void testGzLoading();
+@@ -1646,5 +1648,22 @@ void tst_QSvgRenderer::oss_fuzz_24738()
+     QSvgRenderer().load(QByteArray("<svg><path d=\"a 2 1e-212.....\">"));
+ }
+ 
++void tst_QSvgRenderer::illegalAnimateTransform_data()
++{
++    QTest::addColumn<QByteArray>("svg");
++
++    QTest::newRow("case1") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" values=\"8,0,5,0\">");
++    QTest::newRow("case2") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" values=\"1,2\">");
++    QTest::newRow("case3") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" from=\".. 5 2\" to=\"f\">");
++    QTest::newRow("case4") << QByteArray("<svg><animateTransform type=\"scale\" begin=\"1\" dur=\"2\" by=\"--,..\">");
++}
++
++void tst_QSvgRenderer::illegalAnimateTransform()
++{
++    QFETCH(QByteArray, svg);
++    QSvgRenderer renderer;
++    QVERIFY(!renderer.load(svg)); // also shouldn't assert
++}
++
+ QTEST_MAIN(tst_QSvgRenderer)
+ #include "tst_qsvgrenderer.moc"
+Submodule qttools 6914f7c8..090e526e:
+diff --git a/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp b/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
+index feab1e2d5..cbfb82507 100644
+--- a/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
++++ b/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
+@@ -445,7 +445,9 @@ bool HelpGeneratorPrivate::insertFiles(const QStringList &files, const QString &
+     if (filterSetId < 0)
+         return false;
+     ++filterSetId;
+-    for (int attId : qAsConst(filterAtts)) {
++    QList<int> attValues = filterAtts.values();
++    std::sort(attValues.begin(), attValues.end());
++    for (int attId : qAsConst(attValues)) {
+         m_query->prepare(QLatin1String("INSERT INTO FileAttributeSetTable "
+             "VALUES(?, ?)"));
+         m_query->bindValue(0, filterSetId);
+Submodule qtwayland dfb0129c..2904e1b3:
+diff --git a/qtwayland/src/client/configure.json b/qtwayland/src/client/configure.json
+index 2f424580..29222357 100644
+--- a/qtwayland/src/client/configure.json
++++ b/qtwayland/src/client/configure.json
+@@ -149,8 +149,7 @@
+                     "#endif"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "vulkan-server-buffer": {
+             "label": "Vulkan Buffer Sharing",
+@@ -168,7 +167,8 @@
+                     "exportAllocInfo.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR;",
+                     "return 0;"
+                 ]
+-            }
++            },
++            "use": "wayland-client"
+         },
+         "egl_1_5-wayland": {
+             "label": "EGL 1.5 with Wayland Platform",
+@@ -183,7 +183,7 @@
+                     "eglGetPlatformDisplay(EGL_PLATFORM_WAYLAND_EXT, (struct wl_display *)(nullptr), nullptr);"
+                 ]
+             },
+-            "use": "egl"
++            "use": "egl wayland-client"
+         }
+     },
+ 
+diff --git a/qtwayland/src/client/global/qwaylandclientextension.cpp b/qtwayland/src/client/global/qwaylandclientextension.cpp
+index 125b1e19..edccfe63 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension.cpp
++++ b/qtwayland/src/client/global/qwaylandclientextension.cpp
+@@ -74,7 +74,10 @@ void QWaylandClientExtensionPrivate::handleRegistryGlobal(void *data, ::wl_regis
+ void QWaylandClientExtension::addRegistryListener()
+ {
+     Q_D(QWaylandClientExtension);
+-    d->waylandIntegration->display()->addRegistryListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++    if (!d->registered) {
++        d->waylandIntegration->display()->addRegistryListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++        d->registered = true;
++    }
+ }
+ 
+ QWaylandClientExtension::QWaylandClientExtension(const int ver)
+@@ -88,6 +91,13 @@ QWaylandClientExtension::QWaylandClientExtension(const int ver)
+     QMetaObject::invokeMethod(this, "addRegistryListener", Qt::QueuedConnection);
+ }
+ 
++QWaylandClientExtension::~QWaylandClientExtension()
++{
++    Q_D(QWaylandClientExtension);
++    if (d->registered && !QCoreApplication::closingDown())
++        d->waylandIntegration->display()->removeListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++}
++
+ QtWaylandClient::QWaylandIntegration *QWaylandClientExtension::integration() const
+ {
+     Q_D(const QWaylandClientExtension);
+diff --git a/qtwayland/src/client/global/qwaylandclientextension.h b/qtwayland/src/client/global/qwaylandclientextension.h
+index 98272e57..5bd28398 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension.h
++++ b/qtwayland/src/client/global/qwaylandclientextension.h
+@@ -63,6 +63,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandClientExtension : public QObject
+     Q_PROPERTY(bool active READ isActive NOTIFY activeChanged)
+ public:
+     QWaylandClientExtension(const int version);
++    ~QWaylandClientExtension();
+ 
+     QtWaylandClient::QWaylandIntegration *integration() const;
+     int version() const;
+diff --git a/qtwayland/src/client/global/qwaylandclientextension_p.h b/qtwayland/src/client/global/qwaylandclientextension_p.h
+index 69cc46a0..9091efbe 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension_p.h
++++ b/qtwayland/src/client/global/qwaylandclientextension_p.h
+@@ -68,6 +68,7 @@ public:
+     QtWaylandClient::QWaylandIntegration *waylandIntegration = nullptr;
+     int version = -1;
+     bool active = false;
++    bool registered = false;
+ };
+ 
+ class Q_WAYLAND_CLIENT_EXPORT QWaylandClientExtensionTemplatePrivate : public QWaylandClientExtensionPrivate
+diff --git a/qtwayland/src/client/qwaylanddatadevice.cpp b/qtwayland/src/client/qwaylanddatadevice.cpp
+index 7e2e3308..e3e60ed5 100644
+--- a/qtwayland/src/client/qwaylanddatadevice.cpp
++++ b/qtwayland/src/client/qwaylanddatadevice.cpp
+@@ -72,6 +72,8 @@ QWaylandDataDevice::QWaylandDataDevice(QWaylandDataDeviceManager *manager, QWayl
+ 
+ QWaylandDataDevice::~QWaylandDataDevice()
+ {
++    if (wl_data_device_get_version(object()) >= WL_DATA_DEVICE_RELEASE_SINCE_VERSION)
++        release();
+ }
+ 
+ QWaylandDataOffer *QWaylandDataDevice::selectionOffer() const
+@@ -110,7 +112,7 @@ QWaylandDataOffer *QWaylandDataDevice::dragOffer() const
+     return m_dragOffer.data();
+ }
+ 
+-bool QWaylandDataDevice::startDrag(QMimeData *mimeData, QWaylandWindow *icon)
++bool QWaylandDataDevice::startDrag(QMimeData *mimeData, Qt::DropActions supportedActions, QWaylandWindow *icon)
+ {
+     auto *seat = m_display->currentInputDevice();
+     auto *origin = seat->pointerFocus();
+@@ -123,7 +125,28 @@ bool QWaylandDataDevice::startDrag(QMimeData *mimeData, QWaylandWindow *icon)
+     }
+ 
+     m_dragSource.reset(new QWaylandDataSource(m_display->dndSelectionHandler(), mimeData));
++
++    if (wl_data_device_get_version(object()) >= 3)
++        m_dragSource->set_actions(dropActionsToWl(supportedActions));
++
+     connect(m_dragSource.data(), &QWaylandDataSource::cancelled, this, &QWaylandDataDevice::dragSourceCancelled);
++    connect(m_dragSource.data(), &QWaylandDataSource::dndResponseUpdated, this, [this](bool accepted, Qt::DropAction action) {
++            auto drag = static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag());
++            // in old versions drop action is not set, so we guess
++            if (wl_data_source_get_version(m_dragSource->object()) < 3) {
++                drag->setResponse(accepted);
++            } else {
++                QPlatformDropQtResponse response(accepted, action);
++                drag->setResponse(response);
++            }
++    });
++    connect(m_dragSource.data(), &QWaylandDataSource::dndDropped, this, [](bool accepted, Qt::DropAction action) {
++        QPlatformDropQtResponse response(accepted, action);
++        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setDropResponse(response);
++    });
++    connect(m_dragSource.data(), &QWaylandDataSource::finished, this, []() {
++        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag();
++    });
+ 
+     start_drag(m_dragSource->object(), origin->wlSurface(), icon->wlSurface(), m_display->currentInputDevice()->serial());
+     return true;
+@@ -152,7 +175,7 @@ void QWaylandDataDevice::data_device_drop()
+         supportedActions = drag->supportedActions();
+     } else if (m_dragOffer) {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     } else {
+         return;
+     }
+@@ -162,7 +185,11 @@ void QWaylandDataDevice::data_device_drop()
+                                                                           QGuiApplication::keyboardModifiers());
+ 
+     if (drag) {
+-        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag(response);
++        auto drag =  static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag());
++        drag->setDropResponse(response);
++        drag->finishDrag();
++    } else if (m_dragOffer) {
++        m_dragOffer->finish();
+     }
+ }
+ 
+@@ -186,7 +213,7 @@ void QWaylandDataDevice::data_device_enter(uint32_t serial, wl_surface *surface,
+         supportedActions = drag->supportedActions();
+     } else if (m_dragOffer) {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     }
+ 
+     const QPlatformDragQtResponse &response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
+@@ -197,11 +224,7 @@ void QWaylandDataDevice::data_device_enter(uint32_t serial, wl_surface *surface,
+         static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setResponse(response);
+     }
+ 
+-    if (response.isAccepted()) {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, m_dragOffer->firstFormat().toUtf8().constData());
+-    } else {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, nullptr);
+-    }
++    sendResponse(supportedActions, response);
+ }
+ 
+ void QWaylandDataDevice::data_device_leave()
+@@ -235,10 +258,10 @@ void QWaylandDataDevice::data_device_motion(uint32_t time, wl_fixed_t x, wl_fixe
+         supportedActions = drag->supportedActions();
+     } else {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     }
+ 
+-    QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
++    const QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
+                                                                           QGuiApplication::mouseButtons(),
+                                                                           QGuiApplication::keyboardModifiers());
+ 
+@@ -246,11 +269,7 @@ void QWaylandDataDevice::data_device_motion(uint32_t time, wl_fixed_t x, wl_fixe
+         static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setResponse(response);
+     }
+ 
+-    if (response.isAccepted()) {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, m_dragOffer->firstFormat().toUtf8().constData());
+-    } else {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, nullptr);
+-    }
++    sendResponse(supportedActions, response);
+ }
+ #endif // QT_CONFIG(draganddrop)
+ 
+@@ -277,14 +296,10 @@ void QWaylandDataDevice::selectionSourceCancelled()
+ #if QT_CONFIG(draganddrop)
+ void QWaylandDataDevice::dragSourceCancelled()
+ {
++    static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag();
+     m_dragSource.reset();
+ }
+ 
+-void QWaylandDataDevice::dragSourceTargetChanged(const QString &mimeType)
+-{
+-    static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->updateTarget(mimeType);
+-}
+-
+ QPoint QWaylandDataDevice::calculateDragPosition(int x, int y, QWindow *wnd) const
+ {
+     QPoint pnt(wl_fixed_to_int(x), wl_fixed_to_int(y));
+@@ -297,6 +312,33 @@ QPoint QWaylandDataDevice::calculateDragPosition(int x, int y, QWindow *wnd) con
+     }
+     return pnt;
+ }
++
++void QWaylandDataDevice::sendResponse(Qt::DropActions supportedActions, const QPlatformDragQtResponse &response)
++{
++    if (response.isAccepted()) {
++        if (wl_data_device_get_version(object()) >= 3)
++            m_dragOffer->set_actions(dropActionsToWl(supportedActions), dropActionsToWl(response.acceptedAction()));
++
++        m_dragOffer->accept(m_enterSerial, m_dragOffer->firstFormat());
++    } else {
++        m_dragOffer->accept(m_enterSerial, QString());
++    }
++}
++
++int QWaylandDataDevice::dropActionsToWl(Qt::DropActions actions)
++{
++
++    int wlActions = WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE;
++    if (actions & Qt::CopyAction)
++        wlActions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY;
++    if (actions & (Qt::MoveAction | Qt::TargetMoveAction))
++        wlActions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE;
++
++    // wayland does not support LinkAction at the time of writing
++    return wlActions;
++}
++
++
+ #endif // QT_CONFIG(draganddrop)
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddatadevice_p.h b/qtwayland/src/client/qwaylanddatadevice_p.h
+index 16c3ad28..801dcc2c 100644
+--- a/qtwayland/src/client/qwaylanddatadevice_p.h
++++ b/qtwayland/src/client/qwaylanddatadevice_p.h
+@@ -64,6 +64,7 @@ QT_REQUIRE_CONFIG(wayland_datadevice);
+ QT_BEGIN_NAMESPACE
+ 
+ class QMimeData;
++class QPlatformDragQtResponse;
+ class QWindow;
+ 
+ namespace QtWaylandClient {
+@@ -89,7 +90,7 @@ public:
+ 
+ #if QT_CONFIG(draganddrop)
+     QWaylandDataOffer *dragOffer() const;
+-    bool startDrag(QMimeData *mimeData, QWaylandWindow *icon);
++    bool startDrag(QMimeData *mimeData, Qt::DropActions supportedActions, QWaylandWindow *icon);
+     void cancelDrag();
+ #endif
+ 
+@@ -109,13 +110,16 @@ private Q_SLOTS:
+ 
+ #if QT_CONFIG(draganddrop)
+     void dragSourceCancelled();
+-    void dragSourceTargetChanged(const QString &mimeType);
+ #endif
+ 
+ private:
+ #if QT_CONFIG(draganddrop)
+     QPoint calculateDragPosition(int x, int y, QWindow *wnd) const;
+ #endif
++    void sendResponse(Qt::DropActions supportedActions, const QPlatformDragQtResponse &response);
++
++    static int dropActionsToWl(Qt::DropActions dropActions);
++
+ 
+     QWaylandDisplay *m_display = nullptr;
+     QWaylandInputDevice *m_inputDevice = nullptr;
+diff --git a/qtwayland/src/client/qwaylanddatadevicemanager.cpp b/qtwayland/src/client/qwaylanddatadevicemanager.cpp
+index 35d67307..6dc4f77f 100644
+--- a/qtwayland/src/client/qwaylanddatadevicemanager.cpp
++++ b/qtwayland/src/client/qwaylanddatadevicemanager.cpp
+@@ -50,8 +50,8 @@ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
+-QWaylandDataDeviceManager::QWaylandDataDeviceManager(QWaylandDisplay *display, uint32_t id)
+-    : wl_data_device_manager(display->wl_registry(), id, 1)
++QWaylandDataDeviceManager::QWaylandDataDeviceManager(QWaylandDisplay *display, int version, uint32_t id)
++    : wl_data_device_manager(display->wl_registry(), id, qMin(version, 3))
+     , m_display(display)
+ {
+     // Create transfer devices for all input devices.
+diff --git a/qtwayland/src/client/qwaylanddatadevicemanager_p.h b/qtwayland/src/client/qwaylanddatadevicemanager_p.h
+index bd05c0fb..510d9be4 100644
+--- a/qtwayland/src/client/qwaylanddatadevicemanager_p.h
++++ b/qtwayland/src/client/qwaylanddatadevicemanager_p.h
+@@ -68,7 +68,7 @@ class QWaylandInputDevice;
+ class Q_WAYLAND_CLIENT_EXPORT QWaylandDataDeviceManager : public QtWayland::wl_data_device_manager
+ {
+ public:
+-    QWaylandDataDeviceManager(QWaylandDisplay *display, uint32_t id);
++    QWaylandDataDeviceManager(QWaylandDisplay *display, int version, uint32_t id);
+     ~QWaylandDataDeviceManager() override;
+ 
+     QWaylandDataDevice *getDataDevice(QWaylandInputDevice *inputDevice);
+diff --git a/qtwayland/src/client/qwaylanddataoffer.cpp b/qtwayland/src/client/qwaylanddataoffer.cpp
+index 2297e8a1..fe0ea8c9 100644
+--- a/qtwayland/src/client/qwaylanddataoffer.cpp
++++ b/qtwayland/src/client/qwaylanddataoffer.cpp
+@@ -82,6 +82,15 @@ QMimeData *QWaylandDataOffer::mimeData()
+     return m_mimeData.data();
+ }
+ 
++Qt::DropActions QWaylandDataOffer::supportedActions() const
++{
++    if (wl_data_offer_get_version(const_cast<::wl_data_offer*>(object())) < 3) {
++        return Qt::MoveAction | Qt::CopyAction;
++    }
++
++    return m_supportedActions;
++}
++
+ void QWaylandDataOffer::startReceiving(const QString &mimeType, int fd)
+ {
+     receive(mimeType, fd);
+@@ -93,6 +102,22 @@ void QWaylandDataOffer::data_offer_offer(const QString &mime_type)
+     m_mimeData->appendFormat(mime_type);
+ }
+ 
++void QWaylandDataOffer::data_offer_action(uint32_t dnd_action)
++{
++    Q_UNUSED(dnd_action);
++    // This is the compositor telling the drag target what action it should perform
++    // It does not map nicely into Qt final drop semantics, other than pretending there is only one supported action?
++}
++
++void QWaylandDataOffer::data_offer_source_actions(uint32_t source_actions)
++{
++    m_supportedActions = Qt::DropActions();
++    if (source_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
++        m_supportedActions |= Qt::MoveAction;
++    if (source_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
++        m_supportedActions |= Qt::CopyAction;
++}
++
+ QWaylandMimeData::QWaylandMimeData(QWaylandAbstractDataOffer *dataOffer)
+     : m_dataOffer(dataOffer)
+ {
+@@ -163,17 +188,18 @@ QVariant QWaylandMimeData::retrieveData_sys(const QString &mimeType, QVariant::T
+ 
+ int QWaylandMimeData::readData(int fd, QByteArray &data) const
+ {
+-    fd_set readset;
+-    FD_ZERO(&readset);
+-    FD_SET(fd, &readset);
+-    struct timeval timeout;
++    struct pollfd readset;
++    readset.fd = fd;
++    readset.events = POLLIN;
++    struct timespec timeout;
+     timeout.tv_sec = 1;
+-    timeout.tv_usec = 0;
++    timeout.tv_nsec = 0;
++
+ 
+     Q_FOREVER {
+-        int ready = select(FD_SETSIZE, &readset, nullptr, nullptr, &timeout);
++        int ready = qt_safe_poll(&readset, 1, &timeout);
+         if (ready < 0) {
+-            qWarning() << "QWaylandDataOffer: select() failed";
++            qWarning() << "QWaylandDataOffer: qt_safe_poll() failed";
+             return -1;
+         } else if (ready == 0) {
+             qWarning("QWaylandDataOffer: timeout reading from pipe");
+diff --git a/qtwayland/src/client/qwaylanddataoffer_p.h b/qtwayland/src/client/qwaylanddataoffer_p.h
+index 9cf1483c..6f667398 100644
+--- a/qtwayland/src/client/qwaylanddataoffer_p.h
++++ b/qtwayland/src/client/qwaylanddataoffer_p.h
+@@ -82,6 +82,7 @@ public:
+     explicit QWaylandDataOffer(QWaylandDisplay *display, struct ::wl_data_offer *offer);
+     ~QWaylandDataOffer() override;
+     QMimeData *mimeData() override;
++    Qt::DropActions supportedActions() const;
+ 
+     QString firstFormat() const;
+ 
+@@ -89,10 +90,13 @@ public:
+ 
+ protected:
+     void data_offer_offer(const QString &mime_type) override;
++    void data_offer_source_actions(uint32_t source_actions) override;
++    void data_offer_action(uint32_t dnd_action) override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+     QScopedPointer<QWaylandMimeData> m_mimeData;
++    Qt::DropActions m_supportedActions;
+ };
+ 
+ 
+diff --git a/qtwayland/src/client/qwaylanddatasource.cpp b/qtwayland/src/client/qwaylanddatasource.cpp
+index f45122fb..5599cbd4 100644
+--- a/qtwayland/src/client/qwaylanddatasource.cpp
++++ b/qtwayland/src/client/qwaylanddatasource.cpp
+@@ -101,7 +101,32 @@ void QWaylandDataSource::data_source_send(const QString &mime_type, int32_t fd)
+ 
+ void QWaylandDataSource::data_source_target(const QString &mime_type)
+ {
+-    Q_EMIT targetChanged(mime_type);
++    m_accepted = !mime_type.isEmpty();
++    Q_EMIT dndResponseUpdated(m_accepted, m_dropAction);
++}
++
++void QWaylandDataSource::data_source_action(uint32_t action)
++{
++    Qt::DropAction qtAction = Qt::IgnoreAction;
++
++    if (action == WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
++        qtAction = Qt::MoveAction;
++    else if (action == WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
++        qtAction = Qt::CopyAction;
++
++    m_dropAction = qtAction;
++    Q_EMIT dndResponseUpdated(m_accepted, m_dropAction);
++}
++
++void QWaylandDataSource::data_source_dnd_finished()
++{
++    Q_EMIT finished();
++}
++
++void QWaylandDataSource::data_source_dnd_drop_performed()
++{
++
++    Q_EMIT dndDropped(m_accepted, m_dropAction);
+ }
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddatasource_p.h b/qtwayland/src/client/qwaylanddatasource_p.h
+index 25afff79..96f07bc3 100644
+--- a/qtwayland/src/client/qwaylanddatasource_p.h
++++ b/qtwayland/src/client/qwaylanddatasource_p.h
+@@ -77,17 +77,25 @@ public:
+     QMimeData *mimeData() const;
+ 
+ Q_SIGNALS:
+-    void targetChanged(const QString &mime_type);
+     void cancelled();
++    void finished();
++
++    void dndResponseUpdated(bool accepted, Qt::DropAction action);
++    void dndDropped(bool accepted, Qt::DropAction action);
+ 
+ protected:
+     void data_source_cancelled() override;
+     void data_source_send(const QString &mime_type, int32_t fd) override;
+     void data_source_target(const QString &mime_type) override;
++    void data_source_dnd_drop_performed() override;
++    void data_source_dnd_finished() override;
++    void data_source_action(uint32_t action) override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+     QMimeData *m_mime_data = nullptr;
++    bool m_accepted = false;
++    Qt::DropAction m_dropAction = Qt::IgnoreAction;
+ };
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddisplay.cpp b/qtwayland/src/client/qwaylanddisplay.cpp
+index f10c1f79..c01e238b 100644
+--- a/qtwayland/src/client/qwaylanddisplay.cpp
++++ b/qtwayland/src/client/qwaylanddisplay.cpp
+@@ -85,10 +85,203 @@
+ 
+ #include <errno.h>
+ 
++#include <tuple> // for std::tie
++
++static void checkWaylandError(struct wl_display *display)
++{
++    int ecode = wl_display_get_error(display);
++    if ((ecode == EPIPE || ecode == ECONNRESET)) {
++        // special case this to provide a nicer error
++        qWarning("The Wayland connection broke. Did the Wayland compositor die?");
++    } else {
++        qWarning("The Wayland connection experienced a fatal error: %s", strerror(ecode));
++    }
++    _exit(1);
++}
++
+ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
++class EventThread : public QThread
++{
++    Q_OBJECT
++public:
++    enum OperatingMode {
++        EmitToDispatch, // Emit the signal, allow dispatching in a differnt thread.
++        SelfDispatch, // Dispatch the events inside this thread.
++    };
++
++    EventThread(struct wl_display * wl, struct wl_event_queue * ev_queue,
++                OperatingMode mode)
++        : m_fd(wl_display_get_fd(wl))
++        , m_pipefd{ -1, -1 }
++        , m_wldisplay(wl)
++        , m_wlevqueue(ev_queue)
++        , m_mode(mode)
++        , m_reading(true)
++        , m_quitting(false)
++    {
++        setObjectName(QStringLiteral("WaylandEventThread"));
++    }
++
++    void readAndDispatchEvents()
++    {
++        /*
++         * Dispatch pending events and flush the requests at least once. If the event thread
++         * is not reading, try to call _prepare_read() to allow the event thread to poll().
++         * If that fails, re-try dispatch & flush again until _prepare_read() is successful.
++         *
++         * This allow any call to readAndDispatchEvents() to start event thread's polling,
++         * not only the one issued from event thread's waitForReading(), which means functions
++         * called from dispatch_pending() can safely spin an event loop.
++         */
++        for (;;) {
++            if (dispatchQueuePending() < 0) {
++                checkWaylandError(m_wldisplay);
++                return;
++            }
++
++            wl_display_flush(m_wldisplay);
++
++            // We have to check if event thread is reading every time we dispatch
++            // something, as that may recursively call this function.
++            if (m_reading.loadAcquire())
++                break;
++
++            if (prepareReadQueue() == 0) {
++                QMutexLocker l(&m_mutex);
++                m_reading.storeRelease(true);
++                m_cond.wakeOne();
++                break;
++            }
++        }
++    }
++
++    void stop()
++    {
++        // We have to both write to the pipe and set the flag, as the thread may be
++        // either in the poll() or waiting for _prepare_read().
++        if (m_pipefd[1] != -1 && write(m_pipefd[1], "\0", 1) == -1)
++            qWarning("Failed to write to the pipe: %s.", strerror(errno));
++
++        {
++            QMutexLocker l(&m_mutex);
++            m_quitting = true;
++            m_cond.wakeOne();
++        }
++
++        wait();
++    }
++
++Q_SIGNALS:
++    void needReadAndDispatch();
++
++protected:
++    void run() override
++    {
++        // we use this pipe to make the loop exit otherwise if we simply used a flag on the loop condition, if stop() gets
++        // called while poll() is blocking the thread will never quit since there are no wayland messages coming anymore.
++        struct Pipe
++        {
++            Pipe(int *fds)
++                : fds(fds)
++            {
++                if (qt_safe_pipe(fds) != 0)
++                    qWarning("Pipe creation failed. Quitting may hang.");
++            }
++            ~Pipe()
++            {
++                if (fds[0] != -1) {
++                    close(fds[0]);
++                    close(fds[1]);
++                }
++            }
++
++            int *fds;
++        } pipe(m_pipefd);
++
++        // Make the main thread call wl_prepare_read(), dispatch the pending messages and flush the
++        // outbound ones. Wait until it's done before proceeding, unless we're told to quit.
++        while (waitForReading()) {
++            pollfd fds[2] = { { m_fd, POLLIN, 0 }, { m_pipefd[0], POLLIN, 0 } };
++            poll(fds, 2, -1);
++
++            if (fds[1].revents & POLLIN) {
++                // we don't really care to read the byte that was written here since we're closing down
++                wl_display_cancel_read(m_wldisplay);
++                break;
++            }
++
++            if (fds[0].revents & POLLIN)
++                wl_display_read_events(m_wldisplay);
++                // The polll was succesfull and the event thread did the wl_display_read_events(). On the next iteration of the loop
++                // the event sent to the main thread will cause it to dispatch the messages just read, unless the loop exits in which
++                // case we don't care anymore about them.
++            else
++                wl_display_cancel_read(m_wldisplay);
++        }
++    }
++
++private:
++    bool waitForReading()
++    {
++        Q_ASSERT(QThread::currentThread() == this);
++
++        m_reading.storeRelease(false);
++
++        if (m_mode == SelfDispatch) {
++            readAndDispatchEvents();
++        } else {
++            Q_EMIT needReadAndDispatch();
++
++            QMutexLocker lock(&m_mutex);
++            // m_reading might be set from our emit or some other invocation of
++            // readAndDispatchEvents().
++            while (!m_reading.loadRelaxed() && !m_quitting)
++                m_cond.wait(&m_mutex);
++        }
++
++        return !m_quitting;
++    }
++
++    int dispatchQueuePending()
++    {
++        if (m_wlevqueue)
++            return wl_display_dispatch_queue_pending(m_wldisplay, m_wlevqueue);
++        else
++            return wl_display_dispatch_pending(m_wldisplay);
++    }
++
++    int prepareReadQueue()
++    {
++        if (m_wlevqueue)
++            return wl_display_prepare_read_queue(m_wldisplay, m_wlevqueue);
++        else
++            return wl_display_prepare_read(m_wldisplay);
++    }
++
++    int m_fd;
++    int m_pipefd[2];
++    wl_display *m_wldisplay;
++    wl_event_queue *m_wlevqueue;
++    OperatingMode m_mode;
++
++    /* Concurrency note when operating in EmitToDispatch mode:
++     * m_reading is set to false inside event thread's waitForReading(), and is
++     * set to true inside main thread's readAndDispatchEvents().
++     * The lock is not taken when setting m_reading to false, as the main thread
++     * is not actively waiting for it to turn false. However, the lock is taken
++     * inside readAndDispatchEvents() before setting m_reading to true,
++     * as the event thread is actively waiting for it under the wait condition.
++     */
++
++    QAtomicInteger<bool> m_reading;
++    bool m_quitting;
++    QMutex m_mutex;
++    QWaitCondition m_cond;
++};
++
+ Q_LOGGING_CATEGORY(lcQpaWayland, "qt.qpa.wayland"); // for general (uncategorized) Wayland platform logging
+ 
+ struct wl_surface *QWaylandDisplay::createSurface(void *handle)
+@@ -158,17 +351,16 @@ QWaylandDisplay::QWaylandDisplay(QWaylandIntegration *waylandIntegration)
+     if (!mXkbContext)
+         qCWarning(lcQpaWayland, "failed to create xkb context");
+ #endif
+-
+-    forceRoundTrip();
+-
+-    if (!mWaitingScreens.isEmpty()) {
+-        // Give wl_output.done and zxdg_output_v1.done events a chance to arrive
+-        forceRoundTrip();
+-    }
+ }
+ 
+ QWaylandDisplay::~QWaylandDisplay(void)
+ {
++    if (m_eventThread)
++        m_eventThread->stop();
++
++    if (m_frameEventQueueThread)
++        m_frameEventQueueThread->stop();
++
+     if (mSyncCallback)
+         wl_callback_destroy(mSyncCallback);
+ 
+@@ -187,6 +379,21 @@ QWaylandDisplay::~QWaylandDisplay(void)
+ #endif
+     if (mDisplay)
+         wl_display_disconnect(mDisplay);
++
++    if (m_frameEventQueue)
++        wl_event_queue_destroy(m_frameEventQueue);
++}
++
++// Steps which is called just after constructor. This separates registry_global() out of the constructor
++// so that factory functions in integration can be overridden.
++void QWaylandDisplay::initialize()
++{
++    forceRoundTrip();
++
++    if (!mWaitingScreens.isEmpty()) {
++        // Give wl_output.done and zxdg_output_v1.done events a chance to arrive
++        forceRoundTrip();
++    }
+ }
+ 
+ void QWaylandDisplay::ensureScreen()
+@@ -203,98 +410,37 @@ void QWaylandDisplay::ensureScreen()
+ 
+ void QWaylandDisplay::checkError() const
+ {
+-    int ecode = wl_display_get_error(mDisplay);
+-    if ((ecode == EPIPE || ecode == ECONNRESET)) {
+-        // special case this to provide a nicer error
+-        qWarning("The Wayland connection broke. Did the Wayland compositor die?");
+-    } else {
+-        qWarning("The Wayland connection experienced a fatal error: %s", strerror(ecode));
+-    }
+-    _exit(1);
++    checkWaylandError(mDisplay);
+ }
+ 
++// Called in main thread, either from queued signal or directly.
+ void QWaylandDisplay::flushRequests()
+ {
+-    if (wl_display_prepare_read(mDisplay) == 0) {
+-        wl_display_read_events(mDisplay);
+-    }
+-
+-    if (wl_display_dispatch_pending(mDisplay) < 0)
+-        checkError();
+-
+-    {
+-        QReadLocker locker(&m_frameQueueLock);
+-        for (const FrameQueue &q : mExternalQueues) {
+-            QMutexLocker locker(q.mutex);
+-            while (wl_display_prepare_read_queue(mDisplay, q.queue) != 0)
+-                wl_display_dispatch_queue_pending(mDisplay, q.queue);
+-            wl_display_read_events(mDisplay);
+-            wl_display_dispatch_queue_pending(mDisplay, q.queue);
+-        }
+-    }
+-
+-    wl_display_flush(mDisplay);
+-}
+-
+-void QWaylandDisplay::blockingReadEvents()
+-{
+-    if (wl_display_dispatch(mDisplay) < 0)
+-        checkError();
+-}
+-
+-void QWaylandDisplay::destroyFrameQueue(const QWaylandDisplay::FrameQueue &q)
+-{
+-    QWriteLocker locker(&m_frameQueueLock);
+-    auto it = std::find_if(mExternalQueues.begin(),
+-                           mExternalQueues.end(),
+-                           [&q] (const QWaylandDisplay::FrameQueue &other){ return other.queue == q.queue; });
+-    Q_ASSERT(it != mExternalQueues.end());
+-    mExternalQueues.erase(it);
+-    if (q.queue != nullptr)
+-        wl_event_queue_destroy(q.queue);
+-    delete q.mutex;
++    m_eventThread->readAndDispatchEvents();
+ }
+ 
+-QWaylandDisplay::FrameQueue QWaylandDisplay::createFrameQueue()
++// We have to wait until we have an eventDispatcher before creating the eventThread,
++// otherwise forceRoundTrip() may block inside _events_read() because eventThread is
++// polling.
++void QWaylandDisplay::initEventThread()
+ {
+-    QWriteLocker locker(&m_frameQueueLock);
+-    FrameQueue q{createEventQueue()};
+-    mExternalQueues.append(q);
+-    return q;
+-}
++    m_eventThread.reset(
++            new EventThread(mDisplay, /* default queue */ nullptr, EventThread::EmitToDispatch));
++    connect(m_eventThread.get(), &EventThread::needReadAndDispatch, this,
++            &QWaylandDisplay::flushRequests, Qt::QueuedConnection);
++    m_eventThread->start();
+ 
+-wl_event_queue *QWaylandDisplay::createEventQueue()
+-{
+-    return wl_display_create_queue(mDisplay);
++    // wl_display_disconnect() free this.
++    m_frameEventQueue = wl_display_create_queue(mDisplay);
++    m_frameEventQueueThread.reset(
++            new EventThread(mDisplay, m_frameEventQueue, EventThread::SelfDispatch));
++    m_frameEventQueueThread->start();
+ }
+ 
+-void QWaylandDisplay::dispatchQueueWhile(wl_event_queue *queue, std::function<bool ()> condition, int timeout)
++void QWaylandDisplay::blockingReadEvents()
+ {
+-    if (!condition())
+-        return;
+-
+-    QElapsedTimer timer;
+-    timer.start();
+-    struct pollfd pFd = qt_make_pollfd(wl_display_get_fd(mDisplay), POLLIN);
+-    while (timeout == -1 || timer.elapsed() < timeout) {
+-        while (wl_display_prepare_read_queue(mDisplay, queue) != 0)
+-            wl_display_dispatch_queue_pending(mDisplay, queue);
+-
+-        wl_display_flush(mDisplay);
+-
+-        const int remaining = qMax(timeout - timer.elapsed(), 0ll);
+-        const int pollTimeout = timeout == -1 ? -1 : remaining;
+-        if (qt_poll_msecs(&pFd, 1, pollTimeout) > 0)
+-            wl_display_read_events(mDisplay);
+-        else
+-            wl_display_cancel_read(mDisplay);
+-
+-        if (wl_display_dispatch_queue_pending(mDisplay, queue) < 0)
+-            checkError();
+-
+-        if (!condition())
+-            break;
+-    }
++    if (wl_display_dispatch(mDisplay) < 0)
++        checkWaylandError(mDisplay);
+ }
+ 
+ QWaylandScreen *QWaylandDisplay::screenForOutput(struct wl_output *output) const
+@@ -345,7 +491,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+     if (interface == QStringLiteral("wl_output")) {
+         mWaitingScreens << new QWaylandScreen(this, version, id);
+     } else if (interface == QStringLiteral("wl_compositor")) {
+-        mCompositorVersion = qMin((int)version, 3);
++        mCompositorVersion = qMin((int)version, 4);
+         mCompositor.init(registry, id, mCompositorVersion);
+     } else if (interface == QStringLiteral("wl_shm")) {
+         mShm.reset(new QWaylandShm(this, version, id));
+@@ -354,7 +500,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+         mInputDevices.append(inputDevice);
+ #if QT_CONFIG(wayland_datadevice)
+     } else if (interface == QStringLiteral("wl_data_device_manager")) {
+-        mDndSelectionHandler.reset(new QWaylandDataDeviceManager(this, id));
++        mDndSelectionHandler.reset(new QWaylandDataDeviceManager(this, version, id));
+ #endif
+     } else if (interface == QStringLiteral("qt_surface_extension")) {
+         mWindowExtension.reset(new QtWayland::qt_surface_extension(registry, id, 1));
+@@ -369,6 +515,8 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+ #if QT_CONFIG(wayland_client_primary_selection)
+     } else if (interface == QStringLiteral("zwp_primary_selection_device_manager_v1")) {
+         mPrimarySelectionManager.reset(new QWaylandPrimarySelectionDeviceManagerV1(this, id, 1));
++        for (QWaylandInputDevice *inputDevice : qAsConst(mInputDevices))
++            inputDevice->setPrimarySelectionDevice(mPrimarySelectionManager->createDevice(inputDevice));
+ #endif
+     } else if (interface == QStringLiteral("zwp_text_input_manager_v2") && !mClientSideInputContextRequested) {
+         mTextInputManager.reset(new QtWayland::zwp_text_input_manager_v2(registry, id, 1));
+@@ -427,6 +575,13 @@ void QWaylandDisplay::registry_global_remove(uint32_t id)
+                     inputDevice->setTextInput(nullptr);
+                 mWaylandIntegration->reconfigureInputContext();
+             }
++#if QT_CONFIG(wayland_client_primary_selection)
++            if (global.interface == QStringLiteral("zwp_primary_selection_device_manager_v1")) {
++                mPrimarySelectionManager.reset();
++                for (QWaylandInputDevice *inputDevice : qAsConst(mInputDevices))
++                    inputDevice->setPrimarySelectionDevice(nullptr);
++            }
++#endif
+             mGlobals.removeAt(i);
+             break;
+         }
+@@ -452,9 +607,10 @@ void QWaylandDisplay::addRegistryListener(RegistryListener listener, void *data)
+ 
+ void QWaylandDisplay::removeListener(RegistryListener listener, void *data)
+ {
+-    std::remove_if(mRegistryListeners.begin(), mRegistryListeners.end(), [=](Listener l){
++    auto iter = std::remove_if(mRegistryListeners.begin(), mRegistryListeners.end(), [=](Listener l){
+         return (l.listener == listener && l.data == data);
+     });
++    mRegistryListeners.erase(iter, mRegistryListeners.end());
+ }
+ 
+ uint32_t QWaylandDisplay::currentTimeMillisec()
+@@ -467,50 +623,9 @@ uint32_t QWaylandDisplay::currentTimeMillisec()
+     return 0;
+ }
+ 
+-static void
+-sync_callback(void *data, struct wl_callback *callback, uint32_t serial)
+-{
+-    Q_UNUSED(serial)
+-    bool *done = static_cast<bool *>(data);
+-
+-    *done = true;
+-
+-    // If the wl_callback done event is received after the condition check in the while loop in
+-    // forceRoundTrip(), but before the call to processEvents, the call to processEvents may block
+-    // forever if no more events are posted (eventhough the callback is handled in response to the
+-    // aboutToBlock signal). Hence, we wake up the event dispatcher so forceRoundTrip may return.
+-    // (QTBUG-64696)
+-    if (auto *dispatcher = QThread::currentThread()->eventDispatcher())
+-        dispatcher->wakeUp();
+-
+-    wl_callback_destroy(callback);
+-}
+-
+-static const struct wl_callback_listener sync_listener = {
+-    sync_callback
+-};
+-
+ void QWaylandDisplay::forceRoundTrip()
+ {
+-    // wl_display_roundtrip() works on the main queue only,
+-    // but we use a separate one, so basically reimplement it here
+-    int ret = 0;
+-    bool done = false;
+-    wl_callback *callback = wl_display_sync(mDisplay);
+-    wl_callback_add_listener(callback, &sync_listener, &done);
+-    flushRequests();
+-    if (QThread::currentThread()->eventDispatcher()) {
+-        while (!done && ret >= 0) {
+-            QThread::currentThread()->eventDispatcher()->processEvents(QEventLoop::WaitForMoreEvents);
+-            ret = wl_display_dispatch_pending(mDisplay);
+-        }
+-    } else {
+-        while (!done && ret >= 0)
+-            ret = wl_display_dispatch(mDisplay);
+-    }
+-
+-    if (ret == -1 && !done)
+-        wl_callback_destroy(callback);
++     wl_display_roundtrip(mDisplay);
+ }
+ 
+ bool QWaylandDisplay::supportsWindowDecoration() const
+@@ -574,14 +689,10 @@ void QWaylandDisplay::handleKeyboardFocusChanged(QWaylandInputDevice *inputDevic
+     if (mLastKeyboardFocus == keyboardFocus)
+         return;
+ 
+-    if (mWaylandIntegration->mShellIntegration) {
+-        mWaylandIntegration->mShellIntegration->handleKeyboardFocusChanged(keyboardFocus, mLastKeyboardFocus);
+-    } else {
+-        if (keyboardFocus)
+-            handleWindowActivated(keyboardFocus);
+-        if (mLastKeyboardFocus)
+-            handleWindowDeactivated(mLastKeyboardFocus);
+-    }
++    if (keyboardFocus)
++        handleWindowActivated(keyboardFocus);
++    if (mLastKeyboardFocus)
++        handleWindowDeactivated(mLastKeyboardFocus);
+ 
+     mLastKeyboardFocus = keyboardFocus;
+ }
+@@ -600,6 +711,19 @@ void QWaylandDisplay::handleWaylandSync()
+     QWindow *activeWindow = mActiveWindows.empty() ? nullptr : mActiveWindows.last()->window();
+     if (activeWindow != QGuiApplication::focusWindow())
+         QWindowSystemInterface::handleWindowActivated(activeWindow);
++
++    if (!activeWindow) {
++        if (lastInputDevice()) {
++#if QT_CONFIG(clipboard)
++            if (auto *dataDevice = lastInputDevice()->dataDevice())
++                dataDevice->invalidateSelectionOffer();
++#endif
++#if QT_CONFIG(wayland_client_primary_selection)
++            if (auto *device = lastInputDevice()->primarySelectionDevice())
++                device->invalidateSelectionOffer();
++#endif
++        }
++    }
+ }
+ 
+ const wl_callback_listener QWaylandDisplay::syncCallbackListener = {
+@@ -626,6 +750,13 @@ QWaylandInputDevice *QWaylandDisplay::defaultInputDevice() const
+     return mInputDevices.isEmpty() ? 0 : mInputDevices.first();
+ }
+ 
++bool QWaylandDisplay::isKeyboardAvailable() const
++{
++    return std::any_of(
++            mInputDevices.constBegin(), mInputDevices.constEnd(),
++            [this](const QWaylandInputDevice *device) { return device->keyboard() != nullptr; });
++}
++
+ #if QT_CONFIG(cursor)
+ 
+ QWaylandCursor *QWaylandDisplay::waylandCursor()
+@@ -652,4 +783,6 @@ QWaylandCursorTheme *QWaylandDisplay::loadCursorTheme(const QString &name, int p
+ 
+ } // namespace QtWaylandClient
+ 
++#include "qwaylanddisplay.moc"
++
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/client/qwaylanddisplay_p.h b/qtwayland/src/client/qwaylanddisplay_p.h
+index 3b092bc8..42bc661d 100644
+--- a/qtwayland/src/client/qwaylanddisplay_p.h
++++ b/qtwayland/src/client/qwaylanddisplay_p.h
+@@ -109,6 +109,7 @@ class QWaylandSurface;
+ class QWaylandShellIntegration;
+ class QWaylandCursor;
+ class QWaylandCursorTheme;
++class EventThread;
+ 
+ typedef void (*RegistryListener)(void *data,
+                                  struct wl_registry *registry,
+@@ -120,15 +121,11 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandDisplay : public QObject, public QtWayland
+     Q_OBJECT
+ 
+ public:
+-    struct FrameQueue {
+-        FrameQueue(wl_event_queue *q = nullptr) : queue(q), mutex(new QMutex) {}
+-        wl_event_queue *queue;
+-        QMutex *mutex;
+-    };
+-
+     QWaylandDisplay(QWaylandIntegration *waylandIntegration);
+     ~QWaylandDisplay(void) override;
+ 
++    void initialize();
++
+ #if QT_CONFIG(xkbcommon)
+     struct xkb_context *xkbContext() const { return mXkbContext.get(); }
+ #endif
+@@ -210,11 +207,11 @@ public:
+     void handleKeyboardFocusChanged(QWaylandInputDevice *inputDevice);
+     void handleWindowDestroyed(QWaylandWindow *window);
+ 
+-    wl_event_queue *createEventQueue();
+-    FrameQueue createFrameQueue();
+-    void destroyFrameQueue(const FrameQueue &q);
+-    void dispatchQueueWhile(wl_event_queue *queue, std::function<bool()> condition, int timeout = -1);
++    wl_event_queue *frameEventQueue() { return m_frameEventQueue; };
++
++    bool isKeyboardAvailable() const;
+ 
++    void initEventThread();
+ public slots:
+     void blockingReadEvents();
+     void flushRequests();
+@@ -237,6 +234,9 @@ private:
+     };
+ 
+     struct wl_display *mDisplay = nullptr;
++    QScopedPointer<EventThread> m_eventThread;
++    wl_event_queue *m_frameEventQueue = nullptr;
++    QScopedPointer<EventThread> m_frameEventQueueThread;
+     QtWayland::wl_compositor mCompositor;
+     QScopedPointer<QWaylandShm> mShm;
+     QList<QWaylandScreen *> mWaitingScreens;
+@@ -273,11 +273,9 @@ private:
+     QWaylandInputDevice *mLastInputDevice = nullptr;
+     QPointer<QWaylandWindow> mLastInputWindow;
+     QPointer<QWaylandWindow> mLastKeyboardFocus;
+-    QVector<QWaylandWindow *> mActiveWindows;
+-    QVector<FrameQueue> mExternalQueues;
++    QList<QWaylandWindow *> mActiveWindows;
+     struct wl_callback *mSyncCallback = nullptr;
+     static const wl_callback_listener syncCallbackListener;
+-    QReadWriteLock m_frameQueueLock;
+ 
+     bool mClientSideInputContextRequested = !QPlatformInputContextFactory::requested().isNull();
+ 
+diff --git a/qtwayland/src/client/qwaylanddnd.cpp b/qtwayland/src/client/qwaylanddnd.cpp
+index 6535aa16..7c53f5fa 100644
+--- a/qtwayland/src/client/qwaylanddnd.cpp
++++ b/qtwayland/src/client/qwaylanddnd.cpp
+@@ -66,7 +66,7 @@ void QWaylandDrag::startDrag()
+ {
+     QBasicDrag::startDrag();
+     QWaylandWindow *icon = static_cast<QWaylandWindow *>(shapedPixmapWindow()->handle());
+-    if (m_display->currentInputDevice()->dataDevice()->startDrag(drag()->mimeData(), icon)) {
++    if (m_display->currentInputDevice()->dataDevice()->startDrag(drag()->mimeData(), drag()->supportedActions(), icon)) {
+         icon->addAttachOffset(-drag()->hotSpot());
+     } else {
+         // Cancelling immediately does not work, since the event loop for QDrag::exec is started
+@@ -80,6 +80,9 @@ void QWaylandDrag::cancel()
+     QBasicDrag::cancel();
+ 
+     m_display->currentInputDevice()->dataDevice()->cancelDrag();
++
++    if (drag())
++        drag()->deleteLater();
+ }
+ 
+ void QWaylandDrag::move(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods)
+@@ -103,33 +106,41 @@ void QWaylandDrag::endDrag()
+     m_display->currentInputDevice()->handleEndDrag();
+ }
+ 
+-void QWaylandDrag::updateTarget(const QString &mimeType)
++void QWaylandDrag::setResponse(bool accepted)
+ {
+-    setCanDrop(!mimeType.isEmpty());
+-
+-    if (canDrop()) {
+-        updateCursor(defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers()));
+-    } else {
+-        updateCursor(Qt::IgnoreAction);
+-    }
++    // This method is used for old DataDevices where the drag action is not communicated
++    Qt::DropAction action = defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers());
++    setResponse(QPlatformDropQtResponse(accepted, action));
+ }
+ 
+-void QWaylandDrag::setResponse(const QPlatformDragQtResponse &response)
++void QWaylandDrag::setResponse(const QPlatformDropQtResponse &response)
+ {
+     setCanDrop(response.isAccepted());
+ 
+     if (canDrop()) {
+-        updateCursor(defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers()));
++        updateCursor(response.acceptedAction());
+     } else {
+         updateCursor(Qt::IgnoreAction);
+     }
+ }
+ 
+-void QWaylandDrag::finishDrag(const QPlatformDropQtResponse &response)
++void QWaylandDrag::setDropResponse(const QPlatformDropQtResponse &response)
+ {
+     setExecutedDropAction(response.acceptedAction());
++}
++
++void QWaylandDrag::finishDrag()
++{
+     QKeyEvent event(QEvent::KeyPress, Qt::Key_Escape, Qt::NoModifier);
+     eventFilter(shapedPixmapWindow(), &event);
++
++    if (drag())
++        drag()->deleteLater();
++}
++
++bool QWaylandDrag::ownsDragObject() const
++{
++    return true;
+ }
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddnd_p.h b/qtwayland/src/client/qwaylanddnd_p.h
+index 474fe2ab..46f629ac 100644
+--- a/qtwayland/src/client/qwaylanddnd_p.h
++++ b/qtwayland/src/client/qwaylanddnd_p.h
+@@ -71,9 +71,10 @@ public:
+     QWaylandDrag(QWaylandDisplay *display);
+     ~QWaylandDrag() override;
+ 
+-    void updateTarget(const QString &mimeType);
+-    void setResponse(const QPlatformDragQtResponse &response);
+-    void finishDrag(const QPlatformDropQtResponse &response);
++    void setResponse(bool accepted);
++    void setResponse(const QPlatformDropQtResponse &response);
++    void setDropResponse(const QPlatformDropQtResponse &response);
++    void finishDrag();
+ 
+ protected:
+     void startDrag() override;
+@@ -82,6 +83,7 @@ protected:
+     void drop(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods) override;
+     void endDrag() override;
+ 
++    bool ownsDragObject() const override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+diff --git a/qtwayland/src/client/qwaylandinputdevice.cpp b/qtwayland/src/client/qwaylandinputdevice.cpp
+index 613fe862..4b90de84 100644
+--- a/qtwayland/src/client/qwaylandinputdevice.cpp
++++ b/qtwayland/src/client/qwaylandinputdevice.cpp
+@@ -685,6 +685,11 @@ public:
+ 
+ void QWaylandInputDevice::Pointer::pointer_leave(uint32_t time, struct wl_surface *surface)
+ {
++    invalidateFocus();
++    mButtons = Qt::NoButton;
++
++    mParent->mTime = time;
++
+     // The event may arrive after destroying the window, indicated by
+     // a null surface.
+     if (!surface)
+@@ -696,11 +701,6 @@ void QWaylandInputDevice::Pointer::pointer_leave(uint32_t time, struct wl_surfac
+ 
+     if (!QWaylandWindow::mouseGrab())
+         setFrameEvent(new LeaveEvent(window, mSurfacePos, mGlobalPos));
+-
+-    invalidateFocus();
+-    mButtons = Qt::NoButton;
+-
+-    mParent->mTime = time;
+ }
+ 
+ class MotionEvent : public QWaylandPointerEvent
+@@ -1300,14 +1300,6 @@ void QWaylandInputDevice::Keyboard::handleFocusDestroyed()
+ void QWaylandInputDevice::Keyboard::handleFocusLost()
+ {
+     mFocus = nullptr;
+-#if QT_CONFIG(clipboard)
+-    if (auto *dataDevice = mParent->dataDevice())
+-        dataDevice->invalidateSelectionOffer();
+-#endif
+-#if QT_CONFIG(wayland_client_primary_selection)
+-    if (auto *device = mParent->primarySelectionDevice())
+-        device->invalidateSelectionOffer();
+-#endif
+     mParent->mQDisplay->handleKeyboardFocusChanged(mParent);
+     mRepeatTimer.stop();
+ }
+@@ -1396,6 +1388,7 @@ void QWaylandInputDevice::Touch::touch_cancel()
+     if (touchExt)
+         touchExt->touchCanceled();
+ 
++    mFocus = nullptr;
+     QWindowSystemInterface::handleTouchCancelEvent(nullptr, mParent->mTouchDevice);
+ }
+ 
+diff --git a/qtwayland/src/client/qwaylandintegration.cpp b/qtwayland/src/client/qwaylandintegration.cpp
+index c53ccb78..54861600 100644
+--- a/qtwayland/src/client/qwaylandintegration.cpp
++++ b/qtwayland/src/client/qwaylandintegration.cpp
+@@ -125,6 +125,9 @@ QWaylandIntegration::QWaylandIntegration()
+ #endif
+ 
+     reconfigureInputContext();
++
++    QWaylandWindow::fixedToplevelPositions =
++            !qEnvironmentVariableIsSet("QT_WAYLAND_DISABLE_FIXED_POSITIONS");
+ }
+ 
+ QWaylandIntegration::~QWaylandIntegration()
+@@ -192,14 +195,18 @@ QAbstractEventDispatcher *QWaylandIntegration::createEventDispatcher() const
+ 
+ void QWaylandIntegration::initialize()
+ {
++    mDisplay->initEventThread();
++
++    // Call after eventDispatcher is fully connected, for QWaylandDisplay::forceRoundTrip()
++    mDisplay->initialize();
++
++    // But the aboutToBlock() and awake() should be connected after initializePlatform().
++    // Otherwise the connected flushRequests() may consumes up all events before processEvents starts to wait,
++    // so that processEvents(QEventLoop::WaitForMoreEvents) may be blocked in the forceRoundTrip().
+     QAbstractEventDispatcher *dispatcher = QGuiApplicationPrivate::eventDispatcher;
+     QObject::connect(dispatcher, SIGNAL(aboutToBlock()), mDisplay.data(), SLOT(flushRequests()));
+     QObject::connect(dispatcher, SIGNAL(awake()), mDisplay.data(), SLOT(flushRequests()));
+ 
+-    int fd = wl_display_get_fd(mDisplay->wl_display());
+-    QSocketNotifier *sn = new QSocketNotifier(fd, QSocketNotifier::Read, mDisplay.data());
+-    QObject::connect(sn, SIGNAL(activated(QSocketDescriptor)), mDisplay.data(), SLOT(flushRequests()));
+-
+     // Qt does not support running with no screens
+     mDisplay->ensureScreen();
+ }
+@@ -262,6 +269,14 @@ QWaylandDisplay *QWaylandIntegration::display() const
+     return mDisplay.data();
+ }
+ 
++Qt::KeyboardModifiers QWaylandIntegration::queryKeyboardModifiers() const
++{
++    if (auto *seat = mDisplay->currentInputDevice()) {
++        return seat->modifiers();
++    }
++    return Qt::NoModifier;
++}
++
+ QList<int> QWaylandIntegration::possibleKeys(const QKeyEvent *event) const
+ {
+     if (auto *seat = mDisplay->currentInputDevice())
+@@ -479,7 +494,7 @@ void QWaylandIntegration::reconfigureInputContext()
+     }
+ #endif
+ 
+-    qCDebug(lcQpaWayland) << "using input method:" << inputContext()->metaObject()->className();
++    qCDebug(lcQpaWayland) << "using input method:" << (inputContext() ? inputContext()->metaObject()->className() : "<none>");
+ }
+ 
+ QWaylandShellIntegration *QWaylandIntegration::createShellIntegration(const QString &integrationName)
+diff --git a/qtwayland/src/client/qwaylandintegration_p.h b/qtwayland/src/client/qwaylandintegration_p.h
+index ff70ae25..73b80658 100644
+--- a/qtwayland/src/client/qwaylandintegration_p.h
++++ b/qtwayland/src/client/qwaylandintegration_p.h
+@@ -107,6 +107,8 @@ public:
+ 
+     QWaylandDisplay *display() const;
+ 
++    Qt::KeyboardModifiers queryKeyboardModifiers() const override;
++
+     QList<int> possibleKeys(const QKeyEvent *event) const override;
+ 
+     QStringList themeNames() const override;
+diff --git a/qtwayland/src/client/qwaylandprimaryselectionv1.cpp b/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
+index 832f9678..ea508771 100644
+--- a/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
++++ b/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
+@@ -54,11 +54,6 @@ QWaylandPrimarySelectionDeviceManagerV1::QWaylandPrimarySelectionDeviceManagerV1
+     : zwp_primary_selection_device_manager_v1(display->wl_registry(), id, qMin(version, uint(1)))
+     , m_display(display)
+ {
+-    // Create devices for all seats.
+-    // This only works if we get the global before all devices
+-    const auto seats = m_display->inputDevices();
+-    for (auto *seat : seats)
+-        seat->setPrimarySelectionDevice(createDevice(seat));
+ }
+ 
+ QWaylandPrimarySelectionDeviceV1 *QWaylandPrimarySelectionDeviceManagerV1::createDevice(QWaylandInputDevice *seat)
+diff --git a/qtwayland/src/client/qwaylandscreen.cpp b/qtwayland/src/client/qwaylandscreen.cpp
+index 6cb337de..5537dafd 100644
+--- a/qtwayland/src/client/qwaylandscreen.cpp
++++ b/qtwayland/src/client/qwaylandscreen.cpp
+@@ -60,7 +60,7 @@ QWaylandXdgOutputManagerV1::QWaylandXdgOutputManagerV1(QWaylandDisplay* display,
+ }
+ 
+ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uint32_t id)
+-    : QtWayland::wl_output(waylandDisplay->wl_registry(), id, qMin(version, 2))
++    : QtWayland::wl_output(waylandDisplay->wl_registry(), id, qMin(version, 3))
+     , m_outputId(id)
+     , mWaylandDisplay(waylandDisplay)
+     , mOutputName(QStringLiteral("Screen%1").arg(id))
+@@ -72,7 +72,7 @@ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uin
+         qCWarning(lcQpaWayland) << "wl_output done event not supported by compositor,"
+                                 << "QScreen may not work correctly";
+         mWaylandDisplay->forceRoundTrip(); // Give the compositor a chance to send geometry etc.
+-        mOutputDone = true; // Fake the done event
++        mProcessedEvents |= OutputDoneEvent; // Fake the done event
+         maybeInitialize();
+     }
+ }
+@@ -81,16 +81,29 @@ QWaylandScreen::~QWaylandScreen()
+ {
+     if (zxdg_output_v1::isInitialized())
+         zxdg_output_v1::destroy();
++    if (wl_output::isInitialized() && wl_output_get_version(wl_output::object()) >= WL_OUTPUT_RELEASE_SINCE_VERSION)
++        wl_output::release();
++}
++
++uint QWaylandScreen::requiredEvents() const
++{
++    uint ret = OutputDoneEvent;
++
++    if (mWaylandDisplay->xdgOutputManager()) {
++        ret |= XdgOutputNameEvent;
++
++        if (mWaylandDisplay->xdgOutputManager()->version() < 3)
++            ret |= XdgOutputDoneEvent;
++    }
++    return ret;
+ }
+ 
+ void QWaylandScreen::maybeInitialize()
+ {
+     Q_ASSERT(!mInitialized);
+ 
+-    if (!mOutputDone)
+-        return;
+-
+-    if (mWaylandDisplay->xdgOutputManager() && !mXdgOutputDone)
++    const uint requiredEvents = this->requiredEvents();
++    if ((mProcessedEvents & requiredEvents) != requiredEvents)
+         return;
+ 
+     mInitialized = true;
+@@ -276,9 +289,8 @@ void QWaylandScreen::output_scale(int32_t factor)
+ 
+ void QWaylandScreen::output_done()
+ {
+-    mOutputDone = true;
+-    if (zxdg_output_v1::isInitialized() && mWaylandDisplay->xdgOutputManager()->version() >= 3)
+-        mXdgOutputDone = true;
++    mProcessedEvents |= OutputDoneEvent;
++
+     if (mInitialized) {
+         updateOutputProperties();
+         if (zxdg_output_v1::isInitialized())
+@@ -339,7 +351,7 @@ void QWaylandScreen::zxdg_output_v1_done()
+     if (Q_UNLIKELY(mWaylandDisplay->xdgOutputManager()->version() >= 3))
+         qWarning(lcQpaWayland) << "zxdg_output_v1.done received on version 3 or newer, this is most likely a bug in the compositor";
+ 
+-    mXdgOutputDone = true;
++    mProcessedEvents |= XdgOutputDoneEvent;
+     if (mInitialized)
+         updateXdgOutputProperties();
+     else
+@@ -348,7 +360,11 @@ void QWaylandScreen::zxdg_output_v1_done()
+ 
+ void QWaylandScreen::zxdg_output_v1_name(const QString &name)
+ {
++    if (Q_UNLIKELY(mInitialized))
++        qWarning(lcQpaWayland) << "zxdg_output_v1.name received after output has been initialized, this is most likely a bug in the compositor";
++
+     mOutputName = name;
++    mProcessedEvents |= XdgOutputNameEvent;
+ }
+ 
+ void QWaylandScreen::updateXdgOutputProperties()
+diff --git a/qtwayland/src/client/qwaylandscreen_p.h b/qtwayland/src/client/qwaylandscreen_p.h
+index df1c94f2..050cfdc0 100644
+--- a/qtwayland/src/client/qwaylandscreen_p.h
++++ b/qtwayland/src/client/qwaylandscreen_p.h
+@@ -116,6 +116,13 @@ public:
+     static QWaylandScreen *fromWlOutput(::wl_output *output);
+ 
+ private:
++    enum Event : uint {
++        XdgOutputDoneEvent = 0x1,
++        OutputDoneEvent = 0x2,
++        XdgOutputNameEvent = 0x4,
++    };
++    uint requiredEvents() const;
++
+     void output_mode(uint32_t flags, int width, int height, int refresh) override;
+     void output_geometry(int32_t x, int32_t y,
+                          int32_t width, int32_t height,
+@@ -148,8 +155,7 @@ private:
+     QSize mPhysicalSize;
+     QString mOutputName;
+     Qt::ScreenOrientation m_orientation = Qt::PrimaryOrientation;
+-    bool mOutputDone = false;
+-    bool mXdgOutputDone = false;
++    uint mProcessedEvents = 0;
+     bool mInitialized = false;
+ 
+ #if QT_CONFIG(cursor)
+diff --git a/qtwayland/src/client/qwaylandshmbackingstore.cpp b/qtwayland/src/client/qwaylandshmbackingstore.cpp
+index dc7ff670..41cffdf7 100644
+--- a/qtwayland/src/client/qwaylandshmbackingstore.cpp
++++ b/qtwayland/src/client/qwaylandshmbackingstore.cpp
+@@ -52,6 +52,7 @@
+ 
+ #include <QtWaylandClient/private/wayland-wayland-client-protocol.h>
+ 
++#include <fcntl.h>
+ #include <unistd.h>
+ #include <sys/mman.h>
+ 
+@@ -61,6 +62,9 @@
+ #  ifndef MFD_CLOEXEC
+ #    define MFD_CLOEXEC     0x0001U
+ #  endif
++#  ifndef MFD_ALLOW_SEALING
++#    define MFD_ALLOW_SEALING 0x0002U
++#  endif
+ #endif
+ 
+ QT_BEGIN_NAMESPACE
+@@ -74,8 +78,10 @@ QWaylandShmBuffer::QWaylandShmBuffer(QWaylandDisplay *display,
+     int alloc = stride * size.height();
+     int fd = -1;
+ 
+-#ifdef SYS_memfd_create
+-    fd = syscall(SYS_memfd_create, "wayland-shm", MFD_CLOEXEC);
++#if defined(SYS_memfd_create) && defined(F_SEAL_SEAL)
++    fd = syscall(SYS_memfd_create, "wayland-shm", MFD_CLOEXEC | MFD_ALLOW_SEALING);
++    if (fd >= 0)
++        fcntl(fd, F_ADD_SEALS, F_SEAL_SHRINK | F_SEAL_SEAL);
+ #endif
+ 
+     QScopedPointer<QFile> filePointer;
+diff --git a/qtwayland/src/client/qwaylandwindow.cpp b/qtwayland/src/client/qwaylandwindow.cpp
+index cb82857a..fb2c59dc 100644
+--- a/qtwayland/src/client/qwaylandwindow.cpp
++++ b/qtwayland/src/client/qwaylandwindow.cpp
+@@ -76,7 +76,6 @@ QWaylandWindow *QWaylandWindow::mMouseGrab = nullptr;
+ QWaylandWindow::QWaylandWindow(QWindow *window, QWaylandDisplay *display)
+     : QPlatformWindow(window)
+     , mDisplay(display)
+-    , mFrameQueue(mDisplay->createFrameQueue())
+     , mResizeAfterSwap(qEnvironmentVariableIsSet("QT_WAYLAND_RESIZE_AFTER_SWAP"))
+ {
+     {
+@@ -95,9 +94,6 @@ QWaylandWindow::QWaylandWindow(QWindow *window, QWaylandDisplay *display)
+ 
+ QWaylandWindow::~QWaylandWindow()
+ {
+-    mDisplay->destroyFrameQueue(mFrameQueue);
+-    mDisplay->handleWindowDestroyed(this);
+-
+     delete mWindowDecoration;
+ 
+     if (mSurface)
+@@ -243,6 +239,7 @@ bool QWaylandWindow::shouldCreateSubSurface() const
+ 
+ void QWaylandWindow::reset()
+ {
++    closeChildPopups();
+     delete mShellSurface;
+     mShellSurface = nullptr;
+     delete mSubSurfaceWindow;
+@@ -255,17 +252,22 @@ void QWaylandWindow::reset()
+         mSurface.reset();
+     }
+ 
+-    if (mFrameCallback) {
+-        wl_callback_destroy(mFrameCallback);
+-        mFrameCallback = nullptr;
+-    }
++    {
++        QMutexLocker lock(&mFrameSyncMutex);
++        if (mFrameCallback) {
++            wl_callback_destroy(mFrameCallback);
++            mFrameCallback = nullptr;
++        }
+ 
+-    mFrameCallbackElapsedTimer.invalidate();
+-    mWaitingForFrameCallback = false;
++        mFrameCallbackElapsedTimer.invalidate();
++        mWaitingForFrameCallback = false;
++    }
+     mFrameCallbackTimedOut = false;
+ 
+     mMask = QRegion();
+     mQueuedBuffer = nullptr;
++
++    mDisplay->handleWindowDestroyed(this);
+ }
+ 
+ QWaylandWindow *QWaylandWindow::fromWlSurface(::wl_surface *surface)
+@@ -351,19 +353,25 @@ void QWaylandWindow::setGeometry_helper(const QRect &rect)
+     }
+ }
+ 
+-void QWaylandWindow::setGeometry(const QRect &rect)
++void QWaylandWindow::setGeometry(const QRect &r)
+ {
++    auto rect = r;
++    if (fixedToplevelPositions && !QPlatformWindow::parent() && window()->type() != Qt::Popup
++        && window()->type() != Qt::ToolTip) {
++        rect.moveTo(screen()->geometry().topLeft());
++    }
+     setGeometry_helper(rect);
+ 
+     if (window()->isVisible() && rect.isValid()) {
+         if (mWindowDecoration)
+             mWindowDecoration->update();
+ 
+-        if (mResizeAfterSwap && windowType() == Egl && mSentInitialResize)
++        if (mResizeAfterSwap && windowType() == Egl && mSentInitialResize) {
++            QMutexLocker lock(&mResizeLock);
+             mResizeDirty = true;
+-        else
++        } else {
+             QWindowSystemInterface::handleGeometryChange(window(), geometry());
+-
++        }
+         mSentInitialResize = true;
+     }
+     QRect exposeGeometry(QPoint(), geometry().size());
+@@ -374,7 +382,7 @@ void QWaylandWindow::setGeometry(const QRect &rect)
+         mShellSurface->setWindowGeometry(windowContentGeometry());
+ 
+     if (isOpaque() && mMask.isEmpty())
+-        setOpaqueArea(rect);
++        setOpaqueArea(QRect(QPoint(0, 0), rect.size()));
+ }
+ 
+ void QWaylandWindow::resizeFromApplyConfigure(const QSize &sizeWithMargins, const QPoint &offset)
+@@ -399,21 +407,6 @@ void QWaylandWindow::sendExposeEvent(const QRect &rect)
+     mLastExposeGeometry = rect;
+ }
+ 
+-
+-static QVector<QPointer<QWaylandWindow>> activePopups;
+-
+-void QWaylandWindow::closePopups(QWaylandWindow *parent)
+-{
+-    while (!activePopups.isEmpty()) {
+-        auto popup = activePopups.takeLast();
+-        if (popup.isNull())
+-            continue;
+-        if (popup.data() == parent)
+-            return;
+-        popup->reset();
+-    }
+-}
+-
+ QPlatformScreen *QWaylandWindow::calculateScreenFromSurfaceEvents() const
+ {
+     QReadLocker lock(&mSurfaceLock);
+@@ -433,10 +426,7 @@ void QWaylandWindow::setVisible(bool visible)
+     lastVisible = visible;
+ 
+     if (visible) {
+-        if (window()->type() == Qt::Popup || window()->type() == Qt::ToolTip)
+-            activePopups << this;
+         initWindow();
+-        mDisplay->flushRequests();
+ 
+         setGeometry(windowGeometry());
+         // Don't flush the events here, or else the newly visible window may start drawing, but since
+@@ -444,7 +434,6 @@ void QWaylandWindow::setVisible(bool visible)
+         // QWaylandShmBackingStore::beginPaint().
+     } else {
+         sendExposeEvent(QRect());
+-        closePopups(this);
+         reset();
+     }
+ }
+@@ -556,12 +545,12 @@ void QWaylandWindow::sendRecursiveExposeEvent()
+ 
+ void QWaylandWindow::attach(QWaylandBuffer *buffer, int x, int y)
+ {
+-    Q_ASSERT(!buffer->committed());
+     QReadLocker locker(&mSurfaceLock);
+     if (mSurface == nullptr)
+         return;
+ 
+     if (buffer) {
++        Q_ASSERT(!buffer->committed());
+         handleUpdate();
+         buffer->setBusy();
+ 
+@@ -583,7 +572,11 @@ void QWaylandWindow::damage(const QRect &rect)
+     if (mSurface == nullptr)
+         return;
+ 
+-    mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    const int s = scale();
++    if (mDisplay->compositorVersion() >= 4)
++        mSurface->damage_buffer(s * rect.x(), s * rect.y(), s * rect.width(), s * rect.height());
++    else
++        mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
+ }
+ 
+ void QWaylandWindow::safeCommit(QWaylandBuffer *buffer, const QRegion &damage)
+@@ -619,8 +612,14 @@ void QWaylandWindow::commit(QWaylandBuffer *buffer, const QRegion &damage)
+         return;
+ 
+     attachOffset(buffer);
+-    for (const QRect &rect: damage)
+-        mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    if (mDisplay->compositorVersion() >= 4) {
++        const int s = scale();
++        for (const QRect &rect: damage)
++            mSurface->damage_buffer(s * rect.x(), s * rect.y(), s * rect.width(), s * rect.height());
++    } else {
++        for (const QRect &rect: damage)
++            mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    }
+     Q_ASSERT(!buffer->committed());
+     buffer->setCommitted();
+     mSurface->commit();
+@@ -635,42 +634,53 @@ void QWaylandWindow::commit()
+ 
+ const wl_callback_listener QWaylandWindow::callbackListener = {
+     [](void *data, wl_callback *callback, uint32_t time) {
+-        Q_UNUSED(callback);
+         Q_UNUSED(time);
+         auto *window = static_cast<QWaylandWindow*>(data);
+-        window->handleFrameCallback();
++        window->handleFrameCallback(callback);
+     }
+ };
+ 
+-void QWaylandWindow::handleFrameCallback()
++void QWaylandWindow::handleFrameCallback(wl_callback* callback)
+ {
++    QMutexLocker locker(&mFrameSyncMutex);
++    if (!mFrameCallback) {
++        // This means the callback is already unset by QWaylandWindow::reset.
++        // The wl_callback object will be destroyed there too.
++        return;
++    }
++    Q_ASSERT(callback == mFrameCallback);
++    wl_callback_destroy(callback);
++    mFrameCallback = nullptr;
++
+     mWaitingForFrameCallback = false;
+     mFrameCallbackElapsedTimer.invalidate();
+ 
+     // The rest can wait until we can run it on the correct thread
+-    if (!mWaitingForUpdateDelivery) {
+-        auto doHandleExpose = [this]() {
+-            bool wasExposed = isExposed();
+-            mFrameCallbackTimedOut = false;
+-            if (!wasExposed && isExposed()) // Did setting mFrameCallbackTimedOut make the window exposed?
+-                sendExposeEvent(QRect(QPoint(), geometry().size()));
+-            if (wasExposed && hasPendingUpdateRequest())
+-                deliverUpdateRequest();
+-
+-            mWaitingForUpdateDelivery = false;
+-        };
++    auto doHandleExpose = [this]() {
++        mWaitingForUpdateDelivery.storeRelease(false);
++        bool wasExposed = isExposed();
++        mFrameCallbackTimedOut = false;
++        if (!wasExposed && isExposed()) // Did setting mFrameCallbackTimedOut make the window exposed?
++            sendExposeEvent(QRect(QPoint(), geometry().size()));
++        if (wasExposed && hasPendingUpdateRequest())
++            deliverUpdateRequest();
++    };
+ 
++    if (mWaitingForUpdateDelivery.testAndSetAcquire(false, true)) {
+         // Queued connection, to make sure we don't call handleUpdate() from inside waitForFrameSync()
+         // in the single-threaded case.
+-        mWaitingForUpdateDelivery = true;
+         QMetaObject::invokeMethod(this, doHandleExpose, Qt::QueuedConnection);
+     }
++
++    mFrameSyncWait.notify_all();
+ }
+ 
+ bool QWaylandWindow::waitForFrameSync(int timeout)
+ {
+-    QMutexLocker locker(mFrameQueue.mutex);
+-    mDisplay->dispatchQueueWhile(mFrameQueue.queue, [&]() { return mWaitingForFrameCallback; }, timeout);
++    QMutexLocker locker(&mFrameSyncMutex);
++
++    QDeadlineTimer deadline(timeout);
++    while (mWaitingForFrameCallback && mFrameSyncWait.wait(&mFrameSyncMutex, deadline)) { }
+ 
+     if (mWaitingForFrameCallback) {
+         qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
+@@ -868,6 +878,17 @@ bool QWaylandWindow::createDecoration()
+             subsurf->set_position(pos.x() + m.left(), pos.y() + m.top());
+         }
+         sendExposeEvent(QRect(QPoint(), geometry().size()));
++
++        // This is a special case where the buffer is recreated, but since
++        // the content rect remains the same, the widgets remain the same
++        // size and are not redrawn, leaving the new buffer empty. As a simple
++        // work-around, we trigger a full extra update whenever the client-side
++        // window decorations are toggled while the window is showing.
++        // Note: createDecoration() is sometimes called from the render thread
++        // of Qt Quick. This is essentially wrong and could potentially cause problems,
++        // but until the underlying issue has been fixed, we have to use invokeMethod()
++        // here to avoid asserts.
++        QMetaObject::invokeMethod(window(), &QWindow::requestUpdate);
+     }
+ 
+     return mWindowDecoration;
+@@ -1023,6 +1044,13 @@ void QWaylandWindow::handleScreensChanged()
+ 
+     QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->QPlatformScreen::screen());
+     mLastReportedScreen = newScreen;
++    if (fixedToplevelPositions && !QPlatformWindow::parent() && window()->type() != Qt::Popup
++        && window()->type() != Qt::ToolTip
++        && geometry().topLeft() != newScreen->geometry().topLeft()) {
++        auto geometry = this->geometry();
++        geometry.moveTo(newScreen->geometry().topLeft());
++        setGeometry(geometry);
++    }
+ 
+     int scale = newScreen->isPlaceholder() ? 1 : static_cast<QWaylandScreen *>(newScreen)->scale();
+     if (scale != mScale) {
+@@ -1094,10 +1122,18 @@ bool QWaylandWindow::setMouseGrabEnabled(bool grab)
+     return true;
+ }
+ 
++Qt::WindowStates QWaylandWindow::windowStates() const
++{
++    return mLastReportedWindowStates;
++}
++
+ void QWaylandWindow::handleWindowStatesChanged(Qt::WindowStates states)
+ {
+     createDecoration();
+-    QWindowSystemInterface::handleWindowStateChanged(window(), states, mLastReportedWindowStates);
++    Qt::WindowStates statesWithoutActive = states & ~Qt::WindowActive;
++    Qt::WindowStates lastStatesWithoutActive = mLastReportedWindowStates & ~Qt::WindowActive;
++    QWindowSystemInterface::handleWindowStateChanged(window(), statesWithoutActive,
++                                                     lastStatesWithoutActive);
+     mLastReportedWindowStates = states;
+ }
+ 
+@@ -1139,19 +1175,24 @@ void QWaylandWindow::timerEvent(QTimerEvent *event)
+     if (event->timerId() != mFrameCallbackCheckIntervalTimerId)
+         return;
+ 
+-    bool callbackTimerExpired = mFrameCallbackElapsedTimer.hasExpired(mFrameCallbackTimeout);
+-    if (!mFrameCallbackElapsedTimer.isValid() || callbackTimerExpired ) {
+-        killTimer(mFrameCallbackCheckIntervalTimerId);
+-        mFrameCallbackCheckIntervalTimerId = -1;
+-    }
+-    if (mFrameCallbackElapsedTimer.isValid() && callbackTimerExpired) {
+-        mFrameCallbackElapsedTimer.invalidate();
++    {
++        QMutexLocker lock(&mFrameSyncMutex);
+ 
+-        qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
+-        mFrameCallbackTimedOut = true;
+-        mWaitingForUpdate = false;
+-        sendExposeEvent(QRect());
++        bool callbackTimerExpired = mFrameCallbackElapsedTimer.hasExpired(mFrameCallbackTimeout);
++        if (!mFrameCallbackElapsedTimer.isValid() || callbackTimerExpired ) {
++            killTimer(mFrameCallbackCheckIntervalTimerId);
++            mFrameCallbackCheckIntervalTimerId = -1;
++        }
++        if (!mFrameCallbackElapsedTimer.isValid() || !callbackTimerExpired) {
++            return;
++        }
++        mFrameCallbackElapsedTimer.invalidate();
+     }
++
++    qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
++    mFrameCallbackTimedOut = true;
++    mWaitingForUpdate = false;
++    sendExposeEvent(QRect());
+ }
+ 
+ void QWaylandWindow::requestUpdate()
+@@ -1160,8 +1201,11 @@ void QWaylandWindow::requestUpdate()
+     Q_ASSERT(hasPendingUpdateRequest()); // should be set by QPA
+ 
+     // If we have a frame callback all is good and will be taken care of there
+-    if (mWaitingForFrameCallback)
+-        return;
++    {
++        QMutexLocker locker(&mFrameSyncMutex);
++        if (mWaitingForFrameCallback)
++            return;
++    }
+ 
+     // If we've already called deliverUpdateRequest(), but haven't seen any attach+commit/swap yet
+     // This is a somewhat redundant behavior and might indicate a bug in the calling code, so log
+@@ -1174,7 +1218,12 @@ void QWaylandWindow::requestUpdate()
+     // so use invokeMethod to delay the delivery a bit.
+     QMetaObject::invokeMethod(this, [this] {
+         // Things might have changed in the meantime
+-        if (hasPendingUpdateRequest() && !mWaitingForFrameCallback)
++        {
++            QMutexLocker locker(&mFrameSyncMutex);
++            if (mWaitingForFrameCallback)
++                return;
++        }
++        if (hasPendingUpdateRequest())
+             deliverUpdateRequest();
+     }, Qt::QueuedConnection);
+ }
+@@ -1185,19 +1234,18 @@ void QWaylandWindow::requestUpdate()
+ void QWaylandWindow::handleUpdate()
+ {
+     qCDebug(lcWaylandBackingstore) << "handleUpdate" << QThread::currentThread();
++
+     // TODO: Should sync subsurfaces avoid requesting frame callbacks?
+     QReadLocker lock(&mSurfaceLock);
+     if (!mSurface)
+         return;
+ 
+-    if (mFrameCallback) {
+-        wl_callback_destroy(mFrameCallback);
+-        mFrameCallback = nullptr;
+-    }
++    QMutexLocker locker(&mFrameSyncMutex);
++    if (mWaitingForFrameCallback)
++        return;
+ 
+-    QMutexLocker locker(mFrameQueue.mutex);
+     struct ::wl_surface *wrappedSurface = reinterpret_cast<struct ::wl_surface *>(wl_proxy_create_wrapper(mSurface->object()));
+-    wl_proxy_set_queue(reinterpret_cast<wl_proxy *>(wrappedSurface), mFrameQueue.queue);
++    wl_proxy_set_queue(reinterpret_cast<wl_proxy *>(wrappedSurface), mDisplay->frameEventQueue());
+     mFrameCallback = wl_surface_frame(wrappedSurface);
+     wl_proxy_wrapper_destroy(wrappedSurface);
+     wl_callback_add_listener(mFrameCallback, &QWaylandWindow::callbackListener, this);
+@@ -1207,6 +1255,8 @@ void QWaylandWindow::handleUpdate()
+     // Start a timer for handling the case when the compositor stops sending frame callbacks.
+     if (mFrameCallbackTimeout > 0) {
+         QMetaObject::invokeMethod(this, [this] {
++            QMutexLocker locker(&mFrameSyncMutex);
++
+             if (mWaitingForFrameCallback) {
+                 if (mFrameCallbackCheckIntervalTimerId < 0)
+                     mFrameCallbackCheckIntervalTimerId = startTimer(mFrameCallbackTimeout);
+@@ -1267,6 +1317,20 @@ void QWaylandWindow::setOpaqueArea(const QRegion &opaqueArea)
+     wl_region_destroy(region);
+ }
+ 
++void QWaylandWindow::addChildPopup(QWaylandWindow *surface) {
++    mChildPopups.append(surface);
++}
++
++void QWaylandWindow::removeChildPopup(QWaylandWindow *surface) {
++    mChildPopups.removeAll(surface);
++}
++
++void QWaylandWindow::closeChildPopups() {
++    while (!mChildPopups.isEmpty()) {
++        auto popup = mChildPopups.takeLast();
++        popup->reset();
++    }
++}
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/client/qwaylandwindow_p.h b/qtwayland/src/client/qwaylandwindow_p.h
+index 01337cff..2f219d8c 100644
+--- a/qtwayland/src/client/qwaylandwindow_p.h
++++ b/qtwayland/src/client/qwaylandwindow_p.h
+@@ -98,6 +98,9 @@ public:
+     QWaylandWindow(QWindow *window, QWaylandDisplay *display);
+     ~QWaylandWindow() override;
+ 
++    // Keep Toplevels position on the top left corner of their screen
++    static inline bool fixedToplevelPositions = true;
++
+     virtual WindowType windowType() const = 0;
+     virtual void ensureSize();
+     WId winId() const override;
+@@ -148,6 +151,7 @@ public:
+     void setWindowState(Qt::WindowStates states) override;
+     void setWindowFlags(Qt::WindowFlags flags) override;
+     void handleWindowStatesChanged(Qt::WindowStates states);
++    Qt::WindowStates windowStates() const;
+ 
+     void raise() override;
+     void lower() override;
+@@ -206,6 +210,10 @@ public:
+     void handleUpdate();
+     void deliverUpdateRequest() override;
+ 
++    void addChildPopup(QWaylandWindow* child);
++    void removeChildPopup(QWaylandWindow* child);
++    void closeChildPopups();
++
+ public slots:
+     void applyConfigure();
+ 
+@@ -215,7 +223,11 @@ signals:
+ 
+ protected:
+     QWaylandDisplay *mDisplay = nullptr;
++
++    // mSurface can be written by the main thread. Other threads should claim a read lock for access
++    mutable QReadWriteLock mSurfaceLock;
+     QScopedPointer<QWaylandSurface> mSurface;
++
+     QWaylandShellSurface *mShellSurface = nullptr;
+     QWaylandSubSurface *mSubSurfaceWindow = nullptr;
+     QVector<QWaylandSubSurface *> mChildren;
+@@ -225,13 +237,14 @@ protected:
+     Qt::MouseButtons mMousePressedInContentArea = Qt::NoButton;
+ 
+     WId mWindowId;
+-    bool mWaitingForFrameCallback = false;
+     bool mFrameCallbackTimedOut = false; // Whether the frame callback has timed out
+-    bool mWaitingForUpdateDelivery = false;
+     int mFrameCallbackCheckIntervalTimerId = -1;
+-    QElapsedTimer mFrameCallbackElapsedTimer;
+-    struct ::wl_callback *mFrameCallback = nullptr;
+-    QWaylandDisplay::FrameQueue mFrameQueue;
++    QAtomicInt mWaitingForUpdateDelivery = false;
++
++    bool mWaitingForFrameCallback = false; // Protected by mFrameSyncMutex
++    QElapsedTimer mFrameCallbackElapsedTimer; // Protected by mFrameSyncMutex
++    struct ::wl_callback *mFrameCallback = nullptr; // Protected by mFrameSyncMutex
++    QMutex mFrameSyncMutex;
+     QWaitCondition mFrameSyncWait;
+ 
+     // True when we have called deliverRequestUpdate, but the client has not yet attached a new buffer
+@@ -261,6 +274,8 @@ protected:
+     QWaylandBuffer *mQueuedBuffer = nullptr;
+     QRegion mQueuedBufferDamage;
+ 
++    QList<QPointer<QWaylandWindow>> mChildPopups;
++
+ private:
+     void setGeometry_helper(const QRect &rect);
+     void initWindow();
+@@ -283,12 +298,10 @@ private:
+     QRect mLastExposeGeometry;
+ 
+     static const wl_callback_listener callbackListener;
+-    void handleFrameCallback();
++    void handleFrameCallback(struct ::wl_callback* callback);
+ 
+     static QWaylandWindow *mMouseGrab;
+ 
+-    mutable QReadWriteLock mSurfaceLock;
+-
+     friend class QWaylandSubSurface;
+ };
+ 
+diff --git a/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h b/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
+index ccad0048..4cc9b3b8 100644
+--- a/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
++++ b/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
+@@ -73,11 +73,10 @@ public:
+         return true;
+     }
+     virtual QWaylandShellSurface *createShellSurface(QWaylandWindow *window) = 0;
++    // kept for binary compat with layer-shell-qt
+     virtual void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) {
+-        if (newFocus)
+-            m_display->handleWindowActivated(newFocus);
+-        if (oldFocus)
+-            m_display->handleWindowDeactivated(oldFocus);
++        Q_UNUSED(newFocus);
++        Q_UNUSED(oldFocus);
+     }
+     virtual void *nativeResourceForWindow(const QByteArray &resource, QWindow *window) {
+         Q_UNUSED(resource);
+diff --git a/qtwayland/src/compositor/configure.json b/qtwayland/src/compositor/configure.json
+index bcfd5215..da95d07b 100644
+--- a/qtwayland/src/compositor/configure.json
++++ b/qtwayland/src/compositor/configure.json
+@@ -7,6 +7,31 @@
+     "testDir": "../../config.tests",
+ 
+     "libraries": {
++        "wayland-client": {
++            "label": "Wayland client library",
++            "headers": "wayland-version.h",
++            "test": {
++                "main": [
++                    "#if WAYLAND_VERSION_MAJOR < 1",
++                    "# error Wayland 1.8.0 or higher required",
++                    "#endif",
++                    "#if WAYLAND_VERSION_MAJOR == 1",
++                    "# if WAYLAND_VERSION_MINOR < 8",
++                    "#  error Wayland 1.8.0 or higher required",
++                    "# endif",
++                    "# if WAYLAND_VERSION_MINOR == 8",
++                    "#  if WAYLAND_VERSION_MICRO < 0",
++                    "#   error Wayland 1.8.0 or higher required",
++                    "#  endif",
++                    "# endif",
++                    "#endif"
++                 ]
++            },
++            "sources": [
++                { "type": "pkgConfig", "args": "wayland-client" },
++                "-lwayland-client"
++            ]
++        },
+         "wayland-server": {
+             "label": "wayland-server",
+             "headers": "wayland-version.h",
+@@ -151,8 +176,7 @@
+                     "#endif"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "dmabuf-client-buffer": {
+             "label": "Linux Client dma-buf Buffer Sharing",
+@@ -176,8 +200,7 @@
+                     "return 0;"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "vulkan-server-buffer": {
+             "label": "Vulkan Buffer Sharing",
+@@ -195,7 +218,8 @@
+                     "exportAllocInfo.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR;",
+                     "return 0;"
+                 ]
+-            }
++            },
++            "use": "wayland-client"
+         }
+     },
+ 
+diff --git a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
+index 7889f575..64140672 100644
+--- a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
++++ b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
+@@ -40,6 +40,7 @@
+ #include "qwaylandeglwindow.h"
+ 
+ #include <QtWaylandClient/private/qwaylandscreen_p.h>
++#include <QtWaylandClient/private/qwaylandsurface_p.h>
+ #include "qwaylandglcontext.h"
+ 
+ #include <QtEglSupport/private/qeglconvenience_p.h>
+@@ -124,6 +125,7 @@ void QWaylandEglWindow::updateSurface(bool create)
+         }
+         mOffset = QPoint();
+     } else {
++        QReadLocker locker(&mSurfaceLock);
+         if (m_waylandEglWindow) {
+             int current_width, current_height;
+             static bool disableResizeCheck = qgetenv("QT_WAYLAND_DISABLE_RESIZECHECK").toInt();
+@@ -131,14 +133,16 @@ void QWaylandEglWindow::updateSurface(bool create)
+             if (!disableResizeCheck) {
+                 wl_egl_window_get_attached_size(m_waylandEglWindow, &current_width, &current_height);
+             }
+-            if (disableResizeCheck || (current_width != sizeWithMargins.width() || current_height != sizeWithMargins.height())) {
++            if (disableResizeCheck || (current_width != sizeWithMargins.width() || current_height != sizeWithMargins.height()) || m_requestedSize != sizeWithMargins) {
+                 wl_egl_window_resize(m_waylandEglWindow, sizeWithMargins.width(), sizeWithMargins.height(), mOffset.x(), mOffset.y());
++                m_requestedSize = sizeWithMargins;
+                 mOffset = QPoint();
+ 
+                 m_resize = true;
+             }
+-        } else if (create && wlSurface()) {
+-            m_waylandEglWindow = wl_egl_window_create(wlSurface(), sizeWithMargins.width(), sizeWithMargins.height());
++        } else if (create && mSurface) {
++            m_waylandEglWindow = wl_egl_window_create(mSurface->object(), sizeWithMargins.width(), sizeWithMargins.height());
++            m_requestedSize = sizeWithMargins;
+         }
+ 
+         if (!m_eglSurface && m_waylandEglWindow && create) {
+diff --git a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
+index 5b1f4d56..0079dfef 100644
+--- a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
++++ b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
+@@ -88,6 +88,7 @@ private:
+     mutable QOpenGLFramebufferObject *m_contentFBO = nullptr;
+ 
+     QSurfaceFormat m_format;
++    QSize m_requestedSize;
+ };
+ 
+ }
+diff --git a/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h b/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
+index 56a710c3..c6a8b6c6 100644
+--- a/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
++++ b/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
+@@ -41,6 +41,8 @@
+ #include <QtCore/QTextStream>
+ #include <QtGui/QOpenGLTexture>
+ 
++#include <array>
++
+ #include <EGL/egl.h>
+ #include <EGL/eglext.h>
+ 
+diff --git a/qtwayland/src/plugins/decorations/bradient/main.cpp b/qtwayland/src/plugins/decorations/bradient/main.cpp
+index e75fda3c..fa885143 100644
+--- a/qtwayland/src/plugins/decorations/bradient/main.cpp
++++ b/qtwayland/src/plugins/decorations/bradient/main.cpp
+@@ -164,13 +164,10 @@ void QWaylandBradientDecoration::paint(QPaintDevice *device)
+     // Window icon
+     QIcon icon = waylandWindow()->windowIcon();
+     if (!icon.isNull()) {
+-        QPixmap pixmap = icon.pixmap(QSize(128, 128));
+-        QPixmap scaled = pixmap.scaled(22, 22, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+-
+         QRectF iconRect(0, 0, 22, 22);
+-        p.drawPixmap(iconRect.adjusted(margins().left() + BUTTON_SPACING, 4,
+-                                       margins().left() + BUTTON_SPACING, 4),
+-                     scaled, iconRect);
++        iconRect.adjust(margins().left() + BUTTON_SPACING, 4,
++                        margins().left() + BUTTON_SPACING, 4),
++        icon.paint(&p, iconRect.toRect());
+     }
+ 
+     // Window title
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
+index 85d25e3c..60bdd491 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
+@@ -47,18 +47,21 @@ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
+-QWaylandXdgPopupV5::QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow *window)
++QWaylandXdgPopupV5::QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow* parent, QWaylandWindow *window)
+     : QWaylandShellSurface(window)
+     , QtWayland::xdg_popup_v5(popup)
++    , m_parent(parent)
+     , m_window(window)
+ {
+     if (window->display()->windowExtension())
+         m_extendedWindow = new QWaylandExtendedSurface(window);
++    m_parent->addChildPopup(m_window);
+ }
+ 
+ QWaylandXdgPopupV5::~QWaylandXdgPopupV5()
+ {
+     xdg_popup_destroy(object());
++    m_parent->removeChildPopup(m_window);
+     delete m_extendedWindow;
+ }
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
+index 7494f6a6..d85f130b 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
+@@ -70,7 +70,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgPopupV5 : public QWaylandShellSurface
+ {
+     Q_OBJECT
+ public:
+-    QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow *window);
++    QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow* parent, QWaylandWindow *window);
+     ~QWaylandXdgPopupV5() override;
+ 
+ protected:
+@@ -78,6 +78,7 @@ protected:
+ 
+ private:
+     QWaylandExtendedSurface *m_extendedWindow = nullptr;
++    QWaylandWindow *m_parent = nullptr;
+     QWaylandWindow *m_window = nullptr;
+ };
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
+index 7e242c4a..def8452a 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
+@@ -84,7 +84,7 @@ QWaylandXdgPopupV5 *QWaylandXdgShellV5::createXdgPopup(QWaylandWindow *window, Q
+     int x = position.x() + parentWindow->frameMargins().left();
+     int y = position.y() + parentWindow->frameMargins().top();
+ 
+-    auto popup = new QWaylandXdgPopupV5(get_xdg_popup(window->wlSurface(), parentSurface, seat, m_popupSerial, x, y), window);
++    auto popup = new QWaylandXdgPopupV5(get_xdg_popup(window->wlSurface(), parentSurface, seat, m_popupSerial, x, y), parentWindow, window);
+     m_popups.append(window);
+     QObject::connect(popup, &QWaylandXdgPopupV5::destroyed, [this, window](){
+         m_popups.removeOne(window);
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
+index 4e25949f..cfc60939 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
+@@ -85,13 +85,6 @@ QWaylandShellSurface *QWaylandXdgShellV5Integration::createShellSurface(QWayland
+     return m_xdgShell->createXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellV5Integration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) {
+-    if (newFocus && qobject_cast<QWaylandXdgPopupV5 *>(newFocus->shellSurface()))
+-        m_display->handleWindowActivated(newFocus);
+-    if (oldFocus && qobject_cast<QWaylandXdgPopupV5 *>(oldFocus->shellSurface()))
+-        m_display->handleWindowDeactivated(oldFocus);
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
+index ce6bdb9e..aed88670 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
+@@ -67,7 +67,6 @@ public:
+     QWaylandXdgShellV5Integration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShellV5> m_xdgShell;
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
+index 8c371661..151c78e3 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
+@@ -174,6 +174,7 @@ QWaylandXdgSurfaceV6::Popup::Popup(QWaylandXdgSurfaceV6 *xdgSurface, QWaylandXdg
+     , m_xdgSurface(xdgSurface)
+     , m_parent(parent)
+ {
++    m_parent->window()->addChildPopup(m_xdgSurface->window());
+ }
+ 
+ QWaylandXdgSurfaceV6::Popup::~Popup()
+@@ -181,6 +182,8 @@ QWaylandXdgSurfaceV6::Popup::~Popup()
+     if (isInitialized())
+         destroy();
+ 
++    m_parent->window()->removeChildPopup(m_xdgSurface->window());
++
+     if (m_grabbing) {
+         auto *shell = m_xdgSurface->m_shell;
+         Q_ASSERT(shell->m_topmostGrabbingPopup == this);
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
+index 03164316..e8da8ba1 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
+@@ -68,20 +68,6 @@ QWaylandShellSurface *QWaylandXdgShellV6Integration::createShellSurface(QWayland
+     return m_xdgShell->getXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellV6Integration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus)
+-{
+-    if (newFocus) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurfaceV6 *>(newFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowActivated(newFocus);
+-    }
+-    if (oldFocus && qobject_cast<QWaylandXdgSurfaceV6 *>(oldFocus->shellSurface())) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurfaceV6 *>(oldFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowDeactivated(oldFocus);
+-    }
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
+index 261f8cbb..c1bcd5c6 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
+@@ -65,7 +65,6 @@ public:
+     QWaylandXdgShellV6Integration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShellV6> m_xdgShell;
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
+index f3e3c330..fa6d5808 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
+@@ -67,11 +67,6 @@ QWaylandXdgSurface::Toplevel::Toplevel(QWaylandXdgSurface *xdgSurface)
+ 
+ QWaylandXdgSurface::Toplevel::~Toplevel()
+ {
+-    if (m_applied.states & Qt::WindowActive) {
+-        QWaylandWindow *window = m_xdgSurface->window();
+-        window->display()->handleWindowDeactivated(window);
+-    }
+-
+     // The protocol spec requires that the decoration object is deleted before xdg_toplevel.
+     delete m_decoration;
+     m_decoration = nullptr;
+@@ -85,16 +80,15 @@ void QWaylandXdgSurface::Toplevel::applyConfigure()
+     if (!(m_applied.states & (Qt::WindowMaximized|Qt::WindowFullScreen)))
+         m_normalSize = m_xdgSurface->m_window->windowFrameGeometry().size();
+ 
+-    if ((m_pending.states & Qt::WindowActive) && !(m_applied.states & Qt::WindowActive))
++    if ((m_pending.states & Qt::WindowActive) && !(m_applied.states & Qt::WindowActive)
++        && !m_xdgSurface->m_window->display()->isKeyboardAvailable())
+         m_xdgSurface->m_window->display()->handleWindowActivated(m_xdgSurface->m_window);
+ 
+-    if (!(m_pending.states & Qt::WindowActive) && (m_applied.states & Qt::WindowActive))
++    if (!(m_pending.states & Qt::WindowActive) && (m_applied.states & Qt::WindowActive)
++        && !m_xdgSurface->m_window->display()->isKeyboardAvailable())
+         m_xdgSurface->m_window->display()->handleWindowDeactivated(m_xdgSurface->m_window);
+ 
+-    // TODO: none of the other plugins send WindowActive either, but is it on purpose?
+-    Qt::WindowStates statesWithoutActive = m_pending.states & ~Qt::WindowActive;
+-
+-    m_xdgSurface->m_window->handleWindowStatesChanged(statesWithoutActive);
++    m_xdgSurface->m_window->handleWindowStatesChanged(m_pending.states);
+ 
+     if (m_pending.size.isEmpty()) {
+         // An empty size in the configure means it's up to the client to choose the size
+@@ -105,8 +99,6 @@ void QWaylandXdgSurface::Toplevel::applyConfigure()
+         m_xdgSurface->m_window->resizeFromApplyConfigure(m_pending.size);
+     }
+ 
+-    m_xdgSurface->setSizeHints();
+-
+     m_applied = m_pending;
+     qCDebug(lcQpaWayland) << "Applied pending xdg_toplevel configure event:" << m_applied.size << m_applied.states;
+ }
+@@ -203,12 +195,17 @@ QtWayland::xdg_toplevel::resize_edge QWaylandXdgSurface::Toplevel::convertToResi
+                 | ((edges & Qt::RightEdge) ? resize_edge_right : 0));
+ }
+ 
+-QWaylandXdgSurface::Popup::Popup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parent,
++QWaylandXdgSurface::Popup::Popup(QWaylandXdgSurface *xdgSurface, QWaylandWindow *parent,
+                                  QtWayland::xdg_positioner *positioner)
+-    : xdg_popup(xdgSurface->get_popup(parent->object(), positioner->object()))
+-    , m_xdgSurface(xdgSurface)
++    : m_xdgSurface(xdgSurface)
++    , m_parentXdgSurface(qobject_cast<QWaylandXdgSurface *>(parent->shellSurface()))
+     , m_parent(parent)
+ {
++
++    init(xdgSurface->get_popup(m_parentXdgSurface ? m_parentXdgSurface->object() : nullptr, positioner->object()));
++    if (m_parent) {
++        m_parent->addChildPopup(m_xdgSurface->window());
++    }
+ }
+ 
+ QWaylandXdgSurface::Popup::~Popup()
+@@ -216,10 +213,24 @@ QWaylandXdgSurface::Popup::~Popup()
+     if (isInitialized())
+         destroy();
+ 
++    if (m_parent) {
++        m_parent->removeChildPopup(m_xdgSurface->window());
++    }
++
+     if (m_grabbing) {
+         auto *shell = m_xdgSurface->m_shell;
+         Q_ASSERT(shell->m_topmostGrabbingPopup == this);
+-        shell->m_topmostGrabbingPopup = m_parent->m_popup;
++        shell->m_topmostGrabbingPopup = m_parentXdgSurface ? m_parentXdgSurface->m_popup : nullptr;
++        m_grabbing = false;
++
++        // Synthesize Qt enter/leave events for popup
++        QWindow *leave = nullptr;
++        if (m_xdgSurface && m_xdgSurface->window())
++            leave = m_xdgSurface->window()->window();
++        QWindowSystemInterface::handleLeaveEvent(leave);
++
++        if (QWindow *enter = QGuiApplication::topLevelAt(QCursor::pos()))
++            QWindowSystemInterface::handleEnterEvent(enter, enter->mapFromGlobal(QCursor::pos()), QCursor::pos());
+     }
+ }
+ 
+@@ -257,6 +268,7 @@ QWaylandXdgSurface::QWaylandXdgSurface(QWaylandXdgShell *shell, ::xdg_surface *s
+                 m_toplevel->set_parent(parentXdgSurface->m_toplevel->object());
+         }
+     }
++    setSizeHints();
+ }
+ 
+ QWaylandXdgSurface::~QWaylandXdgSurface()
+@@ -400,8 +412,6 @@ void QWaylandXdgSurface::setPopup(QWaylandWindow *parent)
+ {
+     Q_ASSERT(!m_toplevel && !m_popup);
+ 
+-    auto parentXdgSurface = static_cast<QWaylandXdgSurface *>(parent->shellSurface());
+-
+     auto positioner = new QtWayland::xdg_positioner(m_shell->create_positioner());
+     // set_popup expects a position relative to the parent
+     QPoint transientPos = m_window->geometry().topLeft(); // this is absolute
+@@ -414,8 +424,9 @@ void QWaylandXdgSurface::setPopup(QWaylandWindow *parent)
+     positioner->set_anchor(QtWayland::xdg_positioner::anchor_top_left);
+     positioner->set_gravity(QtWayland::xdg_positioner::gravity_bottom_right);
+     positioner->set_size(m_window->geometry().width(), m_window->geometry().height());
+-    m_popup = new Popup(this, parentXdgSurface, positioner);
++    m_popup = new Popup(this, parent, positioner);
+     positioner->destroy();
++
+     delete positioner;
+ }
+ 
+@@ -437,6 +448,23 @@ void QWaylandXdgSurface::setGrabPopup(QWaylandWindow *parent, QWaylandInputDevic
+     }
+     setPopup(parent);
+     m_popup->grab(device, serial);
++
++    // Synthesize Qt enter/leave events for popup
++    if (!parent)
++        return;
++    QWindow *current = QGuiApplication::topLevelAt(QCursor::pos());
++    QWindow *leave = parent->window();
++    if (current != leave)
++        return;
++
++    QWindowSystemInterface::handleLeaveEvent(leave);
++
++    QWindow *enter = nullptr;
++    if (m_popup && m_popup->m_xdgSurface && m_popup->m_xdgSurface->window())
++        enter = m_popup->m_xdgSurface->window()->window();
++
++    if (enter)
++        QWindowSystemInterface::handleEnterEvent(enter, enter->mapFromGlobal(QCursor::pos()), QCursor::pos());
+ }
+ 
+ void QWaylandXdgSurface::xdg_surface_configure(uint32_t serial)
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
+index 96785205..4b518f0a 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
+@@ -131,14 +131,15 @@ private:
+ 
+     class Popup : public QtWayland::xdg_popup {
+     public:
+-        Popup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parent, QtWayland::xdg_positioner *positioner);
++        Popup(QWaylandXdgSurface *xdgSurface, QWaylandWindow *parent, QtWayland::xdg_positioner *positioner);
+         ~Popup() override;
+ 
+         void grab(QWaylandInputDevice *seat, uint serial);
+         void xdg_popup_popup_done() override;
+ 
+         QWaylandXdgSurface *m_xdgSurface = nullptr;
+-        QWaylandXdgSurface *m_parent = nullptr;
++        QWaylandXdgSurface *m_parentXdgSurface = nullptr;
++        QWaylandWindow *m_parent = nullptr;
+         bool m_grabbing = false;
+     };
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
+index 8769d971..da0dd6a7 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
+@@ -69,20 +69,6 @@ QWaylandShellSurface *QWaylandXdgShellIntegration::createShellSurface(QWaylandWi
+     return m_xdgShell->getXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellIntegration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus)
+-{
+-    if (newFocus) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurface *>(newFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowActivated(newFocus);
+-    }
+-    if (oldFocus && qobject_cast<QWaylandXdgSurface *>(oldFocus->shellSurface())) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurface *>(oldFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowDeactivated(oldFocus);
+-    }
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
+index b6caa6c9..2f929f98 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
+@@ -65,7 +65,6 @@ public:
+     QWaylandXdgShellIntegration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShell> m_xdgShell;
+diff --git a/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp b/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
+index 526d0ef4..f50ccf30 100644
+--- a/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
++++ b/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
+@@ -39,7 +39,10 @@
+ 
+ #include "qwaylandinputmethodeventbuilder_p.h"
+ 
++#include <QBrush>
++#include <QGuiApplication>
+ #include <QInputMethod>
++#include <QPalette>
+ #include <QTextCharFormat>
+ 
+ #ifdef QT_BUILD_WAYLANDCOMPOSITOR_LIB
+@@ -81,32 +84,38 @@ void QWaylandInputMethodEventBuilder::addPreeditStyling(uint32_t index, uint32_t
+     QTextCharFormat format;
+ 
+     switch (style) {
+-    case 0:
+-    case 1:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_NONE:
++        break;
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_DEFAULT:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_UNDERLINE:
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-    case 2:
+-    case 3:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_ACTIVE:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_INACTIVE:
+         format.setFontWeight(QFont::Bold);
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-    case 4:
+-        format.setFontUnderline(true);
+-        format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+-        m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_HIGHLIGHT:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_SELECTION:
++        {
++            format.setFontUnderline(true);
++            format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
++            QPalette palette = qApp->palette();
++            format.setBackground(QBrush(palette.color(QPalette::Active, QPalette::Highlight)));
++            format.setForeground(QBrush(palette.color(QPalette::Active, QPalette::HighlightedText)));
++            m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
++        }
+         break;
+-    case 5:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_INCORRECT:
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::WaveUnderline);
+         format.setUnderlineColor(QColor(Qt::red));
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-//    case QtWayland::wl_text_input::preedit_style_selection:
+-//    case QtWayland::wl_text_input::preedit_style_none:
+     default:
+         break;
+     }
+@@ -153,7 +162,7 @@ QInputMethodEvent QWaylandInputMethodEventBuilder::buildPreedit(const QString &t
+ 
+     if (m_preeditCursor < 0) {
+         attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, 0, QVariant()));
+-    } else if (m_preeditCursor > 0) {
++    } else {
+         attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, indexFromWayland(text, m_preeditCursor), 1, QVariant()));
+     }
+ 
+diff --git a/qtwayland/src/shared/qwaylandmimehelper.cpp b/qtwayland/src/shared/qwaylandmimehelper.cpp
+index a5fdd34d..e2fe1928 100644
+--- a/qtwayland/src/shared/qwaylandmimehelper.cpp
++++ b/qtwayland/src/shared/qwaylandmimehelper.cpp
+@@ -60,7 +60,7 @@ QByteArray QWaylandMimeHelper::getByteArray(QMimeData *mimeData, const QString &
+             buf.open(QIODevice::ReadWrite);
+             QByteArray fmt = "BMP";
+             if (mimeType.startsWith(QLatin1String("image/"))) {
+-                QByteArray imgFmt = mimeType.mid(6).toUpper().toLatin1();
++                QByteArray imgFmt = mimeType.mid(6).toLower().toLatin1();
+                 if (QImageWriter::supportedImageFormats().contains(imgFmt))
+                     fmt = imgFmt;
+             }
+@@ -74,7 +74,7 @@ QByteArray QWaylandMimeHelper::getByteArray(QMimeData *mimeData, const QString &
+         QList<QUrl> urls = mimeData->urls();
+         for (int i = 0; i < urls.count(); ++i) {
+             content.append(urls.at(i).toEncoded());
+-            content.append('\n');
++            content.append("\r\n");
+         }
+     } else {
+         content = mimeData->data(mimeType);
+diff --git a/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp b/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
+index 1568b3b9..067410d0 100644
+--- a/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
++++ b/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
+@@ -35,7 +35,7 @@
+ 
+ using namespace MockCompositor;
+ 
+-constexpr int dataDeviceVersion = 1;
++constexpr int dataDeviceVersion = 3;
+ 
+ class DataDeviceCompositor : public DefaultCompositor {
+ public:
+diff --git a/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp b/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
+index 9312c2e5..2ea382f1 100644
+--- a/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
++++ b/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
+@@ -73,6 +73,7 @@ private slots:
+     void multiTouch();
+     void multiTouchUpAndMotionFrame();
+     void tapAndMoveInSameFrame();
++    void cancelTouch();
+ };
+ 
+ void tst_seatv5::bindsToSeat()
+@@ -646,5 +647,34 @@ void tst_seatv5::tapAndMoveInSameFrame()
+     QTRY_COMPARE(window.m_events.last().touchPoints.first().state(), Qt::TouchPointState::TouchPointReleased);
+ }
+ 
++void tst_seatv5::cancelTouch()
++{
++    TouchWindow window;
++    QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
++
++    exec([=] {
++        auto *t = touch();
++        auto *c = client();
++        t->sendDown(xdgToplevel()->surface(), {32, 32}, 1);
++        t->sendFrame(c);
++        t->sendCancel(c);
++        t->sendFrame(c);
++    });
++
++    QTRY_VERIFY(!window.m_events.empty());
++    {
++        auto e = window.m_events.takeFirst();
++        QCOMPARE(e.type, QEvent::TouchBegin);
++        QCOMPARE(e.touchPointStates, Qt::TouchPointPressed);
++        QCOMPARE(e.touchPoints.length(), 1);
++        QCOMPARE(e.touchPoints.first().pos(), QPointF(32-window.frameMargins().left(), 32-window.frameMargins().top()));
++    }
++    {
++        auto e = window.m_events.takeFirst();
++        QCOMPARE(e.type, QEvent::TouchCancel);
++        QCOMPARE(e.touchPoints.length(), 0);
++    }
++}
++
+ QCOMPOSITOR_TEST_MAIN(tst_seatv5)
+ #include "tst_seatv5.moc"
+diff --git a/qtwayland/tests/auto/client/shared/corecompositor.cpp b/qtwayland/tests/auto/client/shared/corecompositor.cpp
+index 5c6c83ba..fa9b7662 100644
+--- a/qtwayland/tests/auto/client/shared/corecompositor.cpp
++++ b/qtwayland/tests/auto/client/shared/corecompositor.cpp
+@@ -27,6 +27,7 @@
+ ****************************************************************************/
+ 
+ #include "corecompositor.h"
++#include <thread>
+ 
+ namespace MockCompositor {
+ 
+diff --git a/qtwayland/tests/auto/client/shared/coreprotocol.cpp b/qtwayland/tests/auto/client/shared/coreprotocol.cpp
+index 0d988521..d1a2e7cb 100644
+--- a/qtwayland/tests/auto/client/shared/coreprotocol.cpp
++++ b/qtwayland/tests/auto/client/shared/coreprotocol.cpp
+@@ -451,6 +451,13 @@ void Touch::sendFrame(wl_client *client)
+         send_frame(r->handle);
+ }
+ 
++void Touch::sendCancel(wl_client *client)
++{
++    const auto touchResources = resourceMap().values(client);
++    for (auto *r : touchResources)
++        send_cancel(r->handle);
++}
++
+ uint Keyboard::sendEnter(Surface *surface)
+ {
+     auto serial = m_seat->m_compositor->nextSerial();
+diff --git a/qtwayland/tests/auto/client/shared/coreprotocol.h b/qtwayland/tests/auto/client/shared/coreprotocol.h
+index a1af137a..210d8ddb 100644
+--- a/qtwayland/tests/auto/client/shared/coreprotocol.h
++++ b/qtwayland/tests/auto/client/shared/coreprotocol.h
+@@ -158,7 +158,7 @@ class WlCompositor : public Global, public QtWaylandServer::wl_compositor
+ {
+     Q_OBJECT
+ public:
+-    explicit WlCompositor(CoreCompositor *compositor, int version = 3)
++    explicit WlCompositor(CoreCompositor *compositor, int version = 4)
+         : QtWaylandServer::wl_compositor(compositor->m_display, version)
+         , m_compositor(compositor)
+     {}
+@@ -364,6 +364,7 @@ public:
+     uint sendUp(wl_client *client, int id);
+     void sendMotion(wl_client *client, const QPointF &position, int id);
+     void sendFrame(wl_client *client);
++    void sendCancel(wl_client *client);
+ 
+     Seat *m_seat = nullptr;
+ };
+diff --git a/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp b/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
+index a415cbf5..b1d3d07d 100644
+--- a/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
++++ b/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
+@@ -342,7 +342,7 @@ Compositor::Compositor(MockCompositor *mockCompositor)
+         exit(EXIT_FAILURE);
+     }
+ 
+-    wl_global_create(m_display, &wl_compositor_interface, 1, this, bindCompositor);
++    wl_global_create(m_display, &wl_compositor_interface, 4, this, bindCompositor);
+ 
+     m_data_device_manager.reset(new DataDeviceManager(this, m_display));
+ 
+diff --git a/qtwayland/tests/auto/client/shared_old/mocksurface.cpp b/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
+index e9df5f90..c3246e4a 100644
+--- a/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
++++ b/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
+@@ -125,6 +125,16 @@ void Surface::surface_damage(Resource *resource,
+     Q_UNUSED(height);
+ }
+ 
++void Surface::surface_damage_buffer(Resource *resource,
++                                    int32_t x, int32_t y, int32_t width, int32_t height)
++{
++    Q_UNUSED(resource);
++    Q_UNUSED(x);
++    Q_UNUSED(y);
++    Q_UNUSED(width);
++    Q_UNUSED(height);
++}
++
+ void Surface::surface_frame(Resource *resource,
+                             uint32_t callback)
+ {
+diff --git a/qtwayland/tests/auto/client/shared_old/mocksurface.h b/qtwayland/tests/auto/client/shared_old/mocksurface.h
+index 949dc23d..d176837e 100644
+--- a/qtwayland/tests/auto/client/shared_old/mocksurface.h
++++ b/qtwayland/tests/auto/client/shared_old/mocksurface.h
+@@ -65,6 +65,8 @@ protected:
+                         struct wl_resource *buffer, int x, int y) override;
+     void surface_damage(Resource *resource,
+                         int32_t x, int32_t y, int32_t width, int32_t height) override;
++    void surface_damage_buffer(Resource *resource,
++                               int32_t x, int32_t y, int32_t width, int32_t height) override;
+     void surface_frame(Resource *resource,
+                        uint32_t callback) override;
+     void surface_commit(Resource *resource) override;
+diff --git a/qtwayland/tests/auto/client/surface/tst_surface.cpp b/qtwayland/tests/auto/client/surface/tst_surface.cpp
+index 95e4e609..60c672ce 100644
+--- a/qtwayland/tests/auto/client/surface/tst_surface.cpp
++++ b/qtwayland/tests/auto/client/surface/tst_surface.cpp
+@@ -129,6 +129,10 @@ void tst_surface::waitForFrameCallbackGl()
+     // Make sure we follow frame callbacks for some frames
+     for (int i = 0; i < 5; ++i) {
+         xdgPingAndWaitForPong(); // Make sure things have happened on the client
++        if (!qEnvironmentVariableIntValue("QT_WAYLAND_DISABLE_WINDOWDECORATION") && i == 0) {
++            QCOMPARE(bufferSpy.count(), 1);
++            bufferSpy.removeFirst();
++        }
+         exec([&] {
+             QVERIFY(bufferSpy.empty()); // Make sure no extra buffers have arrived
+             QVERIFY(!xdgToplevel()->surface()->m_waitingFrameCallbacks.empty());
+diff --git a/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp b/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
+index 2277bbb8..747875b4 100644
+--- a/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
++++ b/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
+@@ -31,6 +31,7 @@
+ #include <QtGui/QOpenGLWindow>
+ #include <QtGui/qpa/qplatformnativeinterface.h>
+ #include <QtWaylandClient/private/wayland-wayland-client-protocol.h>
++#include <QtWaylandClient/private/qwaylandwindow_p.h>
+ 
+ using namespace MockCompositor;
+ 
+@@ -45,6 +46,7 @@ private slots:
+     void configureStates();
+     void popup();
+     void tooltipOnPopup();
++    void tooltipAndSiblingPopup();
+     void switchPopups();
+     void hidePopupParent();
+     void pongs();
+@@ -138,6 +140,7 @@ void tst_xdgshell::configureSize()
+ 
+ void tst_xdgshell::configureStates()
+ {
++    QVERIFY(qputenv("QT_WAYLAND_FRAME_CALLBACK_TIMEOUT", "0"));
+     QRasterWindow window;
+     window.resize(64, 48);
+     window.show();
+@@ -154,9 +157,12 @@ void tst_xdgshell::configureStates()
+     // Toplevel windows don't know their position on xdg-shell
+ //    QCOMPARE(window.frameGeometry().topLeft(), QPoint()); // TODO: this doesn't currently work when window decorations are enabled
+ 
+-//    QEXPECT_FAIL("", "configure has already been acked, we shouldn't have to wait for isActive", Continue);
+-//    QVERIFY(window.isActive());
+-    QTRY_VERIFY(window.isActive()); // Just make sure it eventually get's set correctly
++    // window.windowstate() is driven by keyboard focus, however for decorations we want to follow
++    // XDGShell this is internal to QtWayland so it is queried directly
++    auto waylandWindow = static_cast<QtWaylandClient::QWaylandWindow *>(window.handle());
++    Q_ASSERT(waylandWindow);
++    QTRY_VERIFY(waylandWindow->windowStates().testFlag(
++            Qt::WindowActive)); // Just make sure it eventually get's set correctly
+ 
+     const QSize screenSize(640, 480);
+     const uint maximizedSerial = exec([=] {
+@@ -186,6 +192,7 @@ void tst_xdgshell::configureStates()
+     QCOMPARE(window.windowStates(), Qt::WindowNoState);
+     QCOMPARE(window.frameGeometry().size(), windowedSize);
+ //    QCOMPARE(window.frameGeometry().topLeft(), QPoint()); // TODO: this doesn't currently work when window decorations are enabled
++    QVERIFY(qunsetenv("QT_WAYLAND_FRAME_CALLBACK_TIMEOUT"));
+ }
+ 
+ void tst_xdgshell::popup()
+@@ -340,6 +347,92 @@ void tst_xdgshell::tooltipOnPopup()
+     QCOMPOSITOR_TRY_COMPARE(xdgPopup(0), nullptr);
+ }
+ 
++void tst_xdgshell::tooltipAndSiblingPopup()
++{
++    class ToolTip : public QRasterWindow {
++    public:
++        explicit ToolTip(QWindow *parent) {
++            setTransientParent(parent);
++            setFlags(Qt::ToolTip);
++            resize(100, 100);
++            show();
++        }
++        void mousePressEvent(QMouseEvent *event) override {
++            QRasterWindow::mousePressEvent(event);
++            m_popup = new QRasterWindow;
++            m_popup->setTransientParent(transientParent());
++            m_popup->setFlags(Qt::Popup);
++            m_popup->resize(100, 100);
++            m_popup->show();
++        }
++
++        QRasterWindow *m_popup = nullptr;
++    };
++
++    class Window : public QRasterWindow {
++    public:
++        void mousePressEvent(QMouseEvent *event) override {
++            QRasterWindow::mousePressEvent(event);
++            m_tooltip = new ToolTip(this);
++        }
++        ToolTip *m_tooltip = nullptr;
++    };
++
++    Window window;
++    window.resize(200, 200);
++    window.show();
++
++    QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
++    exec([=] { xdgToplevel()->sendCompleteConfigure(); });
++    QCOMPOSITOR_TRY_VERIFY(xdgToplevel()->m_xdgSurface->m_committedConfigureSerial);
++
++    exec([=] {
++        auto *surface = xdgToplevel()->surface();
++        auto *p = pointer();
++        auto *c = client();
++        p->sendEnter(surface, {100, 100});
++        p->sendFrame(c);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_pressed);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_released);
++        p->sendFrame(c);
++        p->sendLeave(surface);
++        p->sendFrame(c);
++    });
++
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup());
++    exec([=] { xdgPopup()->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup()->m_xdgSurface->m_committedConfigureSerial);
++    QCOMPOSITOR_TRY_VERIFY(!xdgPopup()->m_grabbed);
++
++    exec([=] {
++        auto *surface = xdgPopup()->surface();
++        auto *p = pointer();
++        auto *c = client();
++        p->sendEnter(surface, {100, 100});
++        p->sendFrame(c);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_pressed);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_released);
++        p->sendFrame(c);
++    });
++
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1));
++    exec([=] { xdgPopup(1)->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1)->m_xdgSurface->m_committedConfigureSerial);
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1)->m_grabbed);
++
++    // Close the middle tooltip (it should not close the sibling popup)
++    window.m_tooltip->close();
++
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(1), nullptr);
++    // Verify the remaining xdg surface is a grab popup..
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(0));
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(0)->m_grabbed);
++
++    window.m_tooltip->m_popup->close();
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(1), nullptr);
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(0), nullptr);
++}
++
+ // QTBUG-65680
+ void tst_xdgshell::switchPopups()
+ {
+@@ -505,7 +598,7 @@ void tst_xdgshell::minMaxSize()
+     window.show();
+     QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
+ 
+-    exec([=] { xdgToplevel()->sendCompleteConfigure(); });
++    // we don't roundtrip with our configuration the initial commit should be correct
+ 
+     QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.minSize, QSize(100, 100));
+     QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.maxSize, QSize(1000, 1000));
+Submodule qtwebchannel 618422ee..f8949655:
+diff --git a/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp b/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
+index 536eb5c..898d769 100644
+--- a/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
++++ b/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
+@@ -186,8 +186,6 @@ Q_DECLARE_TYPEINFO(OverloadResolutionCandidate, Q_MOVABLE_TYPE);
+ QMetaObjectPublisher::QMetaObjectPublisher(QWebChannel *webChannel)
+     : QObject(webChannel)
+     , webChannel(webChannel)
+-    , signalHandler(this)
+-    , clientIsIdle(false)
+     , blockUpdates(false)
+     , propertyUpdatesInitialized(false)
+ {
+@@ -301,17 +299,17 @@ QJsonObject QMetaObjectPublisher::classInfoForObject(const QObject *object, QWeb
+     return data;
+ }
+ 
+-void QMetaObjectPublisher::setClientIsIdle(bool isIdle)
++void QMetaObjectPublisher::setClientIsIdle(bool isIdle, QWebChannelAbstractTransport *transport)
+ {
+-    if (clientIsIdle == isIdle) {
+-        return;
+-    }
+-    clientIsIdle = isIdle;
+-    if (!isIdle && timer.isActive()) {
+-        timer.stop();
+-    } else if (isIdle && !timer.isActive()) {
+-        timer.start(PROPERTY_UPDATE_INTERVAL, this);
+-    }
++    transportState[transport].clientIsIdle = isIdle;
++    if (isIdle)
++        sendEnqueuedPropertyUpdates(transport);
++}
++
++bool QMetaObjectPublisher::isClientIdle(QWebChannelAbstractTransport *transport)
++{
++    auto found = transportState.find(transport);
++    return found != transportState.end() && found.value().clientIsIdle;
+ }
+ 
+ QJsonObject QMetaObjectPublisher::initializeClient(QWebChannelAbstractTransport *transport)
+@@ -333,6 +331,7 @@ QJsonObject QMetaObjectPublisher::initializeClient(QWebChannelAbstractTransport
+ 
+ void QMetaObjectPublisher::initializePropertyUpdates(const QObject *const object, const QJsonObject &objectInfo)
+ {
++    auto *signalHandler = signalHandlerFor(object);
+     foreach (const QJsonValue &propertyInfoVar, objectInfo[KEY_PROPERTIES].toArray()) {
+         const QJsonArray &propertyInfo = propertyInfoVar.toArray();
+         if (propertyInfo.size() < 2) {
+@@ -353,19 +352,19 @@ void QMetaObjectPublisher::initializePropertyUpdates(const QObject *const object
+ 
+         // Only connect for a property update once
+         if (connectedProperties.isEmpty()) {
+-            signalHandler.connectTo(object, signalIndex);
++            signalHandler->connectTo(object, signalIndex);
+         }
+ 
+         connectedProperties.insert(propertyIndex);
+     }
+ 
+     // also always connect to destroyed signal
+-    signalHandler.connectTo(object, s_destroyedSignalIndex);
++    signalHandler->connectTo(object, s_destroyedSignalIndex);
+ }
+ 
+ void QMetaObjectPublisher::sendPendingPropertyUpdates()
+ {
+-    if (blockUpdates || !clientIsIdle || pendingPropertyUpdates.isEmpty()) {
++    if (blockUpdates) {
+         return;
+     }
+ 
+@@ -415,18 +414,19 @@ void QMetaObjectPublisher::sendPendingPropertyUpdates()
+ 
+     // data does not contain specific updates
+     if (!data.isEmpty()) {
+-        setClientIsIdle(false);
+-
+         message[KEY_DATA] = data;
+-        broadcastMessage(message);
++        enqueueBroadcastMessage(message);
+     }
+ 
+     // send every property update which is not supposed to be broadcasted
+     const QHash<QWebChannelAbstractTransport*, QJsonArray>::const_iterator suend = specificUpdates.constEnd();
+     for (QHash<QWebChannelAbstractTransport*, QJsonArray>::const_iterator it = specificUpdates.constBegin(); it != suend; ++it) {
+         message[KEY_DATA] = it.value();
+-        it.key()->sendMessage(message);
++        enqueueMessage(message, it.key());
+     }
++
++    for (auto state = transportState.begin(); state != transportState.end(); ++state)
++        sendEnqueuedPropertyUpdates(state.key());
+ }
+ 
+ QVariant QMetaObjectPublisher::invokeMethod(QObject *const object, const QMetaMethod &method,
+@@ -572,7 +572,7 @@ void QMetaObjectPublisher::signalEmitted(const QObject *object, const int signal
+         }
+     } else {
+         pendingPropertyUpdates[object][signalIndex] = arguments;
+-        if (clientIsIdle && !blockUpdates && !timer.isActive()) {
++        if (!blockUpdates && !timer.isActive()) {
+             timer.start(PROPERTY_UPDATE_INTERVAL, this);
+         }
+     }
+@@ -590,7 +590,7 @@ void QMetaObjectPublisher::objectDestroyed(const QObject *object)
+     // only remove from handler when we initialized the property updates
+     // cf: https://bugreports.qt.io/browse/QTBUG-60250
+     if (propertyUpdatesInitialized) {
+-        signalHandler.remove(object);
++        signalHandlerFor(object)->remove(object);
+         signalToPropertyMap.remove(object);
+     }
+     pendingPropertyUpdates.remove(object);
+@@ -852,6 +852,52 @@ void QMetaObjectPublisher::broadcastMessage(const QJsonObject &message) const
+     }
+ }
+ 
++void QMetaObjectPublisher::enqueueBroadcastMessage(const QJsonObject &message)
++{
++    if (webChannel->d_func()->transports.isEmpty()) {
++        qWarning("QWebChannel is not connected to any transports, cannot send message: %s",
++                 QJsonDocument(message).toJson().constData());
++        return;
++    }
++
++    for (auto *transport : webChannel->d_func()->transports) {
++        auto &state = transportState[transport];
++        state.queuedMessages.append(message);
++    }
++}
++
++void QMetaObjectPublisher::enqueueMessage(const QJsonObject &message,
++                                          QWebChannelAbstractTransport *transport)
++{
++    auto &state = transportState[transport];
++    state.queuedMessages.append(message);
++}
++
++void QMetaObjectPublisher::sendEnqueuedPropertyUpdates(QWebChannelAbstractTransport *transport)
++{
++    auto found = transportState.find(transport);
++    if (found != transportState.end() && found.value().clientIsIdle
++        && !found.value().queuedMessages.isEmpty()) {
++
++        // If the client is connected with an in-process transport, it can
++        // happen that a message triggers a subsequent property change. In
++        // that case, we need to ensure that the queued messages have already
++        // been cleared; otherwise the recursive call will send everythig again.
++        // Case in point: The qmlwebchannel tests fail if we don't clear the
++        // queued messages before sending them out.
++        // For that same reason set the client to "busy" (aka non-idle) just
++        // right before sending out the messages; otherwise a potential
++        // "Idle" type message will not correctly restore the Idle state.
++        const auto messages = std::move(found.value().queuedMessages);
++        Q_ASSERT(found.value().queuedMessages.isEmpty());
++        found.value().clientIsIdle = false;
++
++        for (const auto &message : messages) {
++            transport->sendMessage(message);
++        }
++    }
++}
++
+ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannelAbstractTransport *transport)
+ {
+     if (!webChannel->d_func()->transports.contains(transport)) {
+@@ -866,7 +912,7 @@ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannel
+ 
+     const MessageType type = toType(message.value(KEY_TYPE));
+     if (type == TypeIdle) {
+-        setClientIsIdle(true);
++        setClientIsIdle(true, transport);
+     } else if (type == TypeInit) {
+         if (!message.contains(KEY_ID)) {
+             qWarning("JSON message object is missing the id property: %s",
+@@ -913,9 +959,9 @@ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannel
+                 return;
+             transport->sendMessage(createResponse(message.value(KEY_ID), wrapResult(result, transport)));
+         } else if (type == TypeConnectToSignal) {
+-            signalHandler.connectTo(object, message.value(KEY_SIGNAL).toInt(-1));
++            signalHandlerFor(object)->connectTo(object, message.value(KEY_SIGNAL).toInt(-1));
+         } else if (type == TypeDisconnectFromSignal) {
+-            signalHandler.disconnectFrom(object, message.value(KEY_SIGNAL).toInt(-1));
++            signalHandlerFor(object)->disconnectFrom(object, message.value(KEY_SIGNAL).toInt(-1));
+         } else if (type == TypeSetProperty) {
+             setProperty(object, message.value(KEY_PROPERTY).toInt(-1),
+                         message.value(KEY_VALUE));
+@@ -931,6 +977,7 @@ void QMetaObjectPublisher::setBlockUpdates(bool block)
+     blockUpdates = block;
+ 
+     if (!blockUpdates) {
++        timer.start(PROPERTY_UPDATE_INTERVAL, this);
+         sendPendingPropertyUpdates();
+     } else if (timer.isActive()) {
+         timer.stop();
+@@ -948,4 +995,15 @@ void QMetaObjectPublisher::timerEvent(QTimerEvent *event)
+     }
+ }
+ 
++SignalHandler<QMetaObjectPublisher> *QMetaObjectPublisher::signalHandlerFor(const QObject *object)
++{
++    auto thread = object->thread();
++    auto it = signalHandlers.find(thread);
++    if (it == signalHandlers.end()) {
++        it = signalHandlers.emplace(thread, this).first;
++        it->second.moveToThread(thread);
++    }
++    return &it->second;
++}
++
+ QT_END_NAMESPACE
+diff --git a/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h b/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
+index bbd9875..4713ef1 100644
+--- a/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
++++ b/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
+@@ -59,6 +59,9 @@
+ #include <QBasicTimer>
+ #include <QPointer>
+ #include <QJsonObject>
++#include <QQueue>
++
++#include <unordered_map>
+ 
+ #include "qwebchannelglobal.h"
+ 
+@@ -109,17 +112,36 @@ public:
+      */
+     void broadcastMessage(const QJsonObject &message) const;
+ 
++    /**
++     * Enqueue the given @p message to all known transports.
++     */
++    void enqueueBroadcastMessage(const QJsonObject &message);
++
++    /**
++     * Enqueue the given @p message to @p transport.
++     */
++    void enqueueMessage(const QJsonObject &message, QWebChannelAbstractTransport *transport);
++
++    /**
++     * If client for given @p transport is idle, send queued messaged to @p transport and then mark
++     * the client as not idle.
++     */
++    void sendEnqueuedPropertyUpdates(QWebChannelAbstractTransport *transport);
++
+     /**
+      * Serialize the QMetaObject of @p object and return it in JSON form.
+      */
+     QJsonObject classInfoForObject(const QObject *object, QWebChannelAbstractTransport *transport);
+ 
+     /**
+-     * Set the client to idle or busy, based on the value of @p isIdle.
+-     *
+-     * When the value changed, start/stop the property update timer accordingly.
++     * Set the client to idle or busy for a single @p transport, based on the value of @p isIdle.
++     */
++    void setClientIsIdle(bool isIdle, QWebChannelAbstractTransport *transport);
++
++    /**
++     * Check that client is idle for @p transport.
+      */
+-    void setClientIsIdle(bool isIdle);
++    bool isClientIdle(QWebChannelAbstractTransport *transport);
+ 
+     /**
+      * Initialize clients by sending them the class information of the registered objects.
+@@ -272,10 +294,18 @@ private:
+     friend class TestWebChannel;
+ 
+     QWebChannel *webChannel;
+-    SignalHandler<QMetaObjectPublisher> signalHandler;
++    std::unordered_map<const QThread*, SignalHandler<QMetaObjectPublisher>> signalHandlers;
++    SignalHandler<QMetaObjectPublisher> *signalHandlerFor(const QObject *object);
+ 
+-    // true when the client is idle, false otherwise
+-    bool clientIsIdle;
++    struct TransportState
++    {
++        TransportState() : clientIsIdle(false) { }
++        // true when the client is idle, false otherwise
++        bool clientIsIdle;
++        // messages to send
++        QQueue<QJsonObject> queuedMessages;
++    };
++    QHash<QWebChannelAbstractTransport *, TransportState> transportState;
+ 
+     // true when no property updates should be sent, false otherwise
+     bool blockUpdates;
+diff --git a/qtwebchannel/src/webchannel/signalhandler_p.h b/qtwebchannel/src/webchannel/signalhandler_p.h
+index 27afadb..d77373c 100644
+--- a/qtwebchannel/src/webchannel/signalhandler_p.h
++++ b/qtwebchannel/src/webchannel/signalhandler_p.h
+@@ -56,6 +56,7 @@
+ #include <QVector>
+ #include <QMetaMethod>
+ #include <QDebug>
++#include <QThread>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -71,6 +72,7 @@ static const int s_destroyedSignalIndex = QObject::staticMetaObject.indexOfMetho
+ template<class Receiver>
+ class SignalHandler : public QObject
+ {
++    Q_DISABLE_COPY(SignalHandler)
+ public:
+     SignalHandler(Receiver *receiver, QObject *parent = 0);
+ 
+@@ -268,6 +270,7 @@ int SignalHandler<Receiver>::qt_metacall(QMetaObject::Call call, int methodId, v
+     if (call == QMetaObject::InvokeMetaMethod) {
+         const QObject *object = sender();
+         Q_ASSERT(object);
++        Q_ASSERT(QThread::currentThread() == object->thread());
+         Q_ASSERT(senderSignalIndex() == methodId);
+         Q_ASSERT(m_connectionsCounter.contains(object));
+         Q_ASSERT(m_connectionsCounter.value(object).contains(methodId));
+diff --git a/qtwebchannel/tests/auto/qml/testwebchannel.cpp b/qtwebchannel/tests/auto/qml/testwebchannel.cpp
+index 9891687..3ca81c2 100644
+--- a/qtwebchannel/tests/auto/qml/testwebchannel.cpp
++++ b/qtwebchannel/tests/auto/qml/testwebchannel.cpp
+@@ -46,7 +46,11 @@ TestWebChannel::~TestWebChannel()
+ 
+ bool TestWebChannel::clientIsIdle() const
+ {
+-    return QWebChannel::d_func()->publisher->clientIsIdle;
++    for (auto *transport : QWebChannel::d_func()->transports) {
++        if (QWebChannel::d_func()->publisher->isClientIdle(transport))
++            return true;
++    }
++    return false;
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp b/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
+index 181da9e..37f989a 100644
+--- a/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
++++ b/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
+@@ -785,7 +785,7 @@ void TestWebChannel::testTransportWrapObjectProperties()
+     DummyTransport *dummyTransport = new DummyTransport(this);
+     channel.connectTo(dummyTransport);
+     channel.d_func()->publisher->initializeClient(dummyTransport);
+-    channel.d_func()->publisher->setClientIsIdle(true);
++    channel.d_func()->publisher->setClientIsIdle(true, dummyTransport);
+ 
+     QCOMPARE(channel.d_func()->publisher->transportedWrappedObjects.size(), 0);
+ 
+@@ -943,8 +943,6 @@ void TestWebChannel::testInfiniteRecursion()
+ 
+ void TestWebChannel::testAsyncObject()
+ {
+-    QSKIP("This test is broken. See QTBUG-80729");
+-
+     QWebChannel channel;
+     channel.connectTo(m_dummyTransport);
+ 
+@@ -990,6 +988,50 @@ void TestWebChannel::testAsyncObject()
+     thread.wait();
+ }
+ 
++void TestWebChannel::testPropertyMultipleTransports()
++{
++    DummyTransport transport1;
++    DummyTransport transport2;
++
++    QWebChannel channel;
++    QMetaObjectPublisher *publisher = channel.d_func()->publisher;
++
++    TestObject testObj;
++    testObj.setObjectName("testObject");
++    channel.registerObject(testObj.objectName(), &testObj);
++    channel.connectTo(&transport1);
++    channel.connectTo(&transport2);
++
++    testObj.setProp("Hello");
++
++    publisher->initializeClient(&transport1);
++    publisher->initializeClient(&transport2);
++    publisher->setClientIsIdle(true, &transport1);
++    QCOMPARE(publisher->isClientIdle(&transport1), true);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++    QVERIFY(transport1.messagesSent().isEmpty());
++    QVERIFY(transport2.messagesSent().isEmpty());
++
++    testObj.setProp("World");
++    QTRY_COMPARE_WITH_TIMEOUT(transport1.messagesSent().size(), 1u, 2000);
++    QCOMPARE(transport2.messagesSent().size(), 0u);
++    publisher->setClientIsIdle(true, &transport2);
++    QTRY_COMPARE_WITH_TIMEOUT(transport2.messagesSent().size(), 1u, 2000);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++
++    testObj.setProp("!!!");
++    publisher->setClientIsIdle(true, &transport2);
++    QCOMPARE(publisher->isClientIdle(&transport2), true);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QTRY_COMPARE_WITH_TIMEOUT(transport2.messagesSent().size(), 2u, 2000);
++    QCOMPARE(transport1.messagesSent().size(), 1u);
++    publisher->setClientIsIdle(true, &transport1);
++    QTRY_COMPARE_WITH_TIMEOUT(transport1.messagesSent().size(), 2u, 2000);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++}
++
+ class FunctionWrapper : public QObject
+ {
+     Q_OBJECT
+@@ -1082,7 +1124,7 @@ void TestWebChannel::benchInitializeClients()
+ 
+         publisher->propertyUpdatesInitialized = false;
+         publisher->signalToPropertyMap.clear();
+-        publisher->signalHandler.clear();
++        publisher->signalHandlers.clear();
+     }
+ }
+ 
+@@ -1107,7 +1149,7 @@ void TestWebChannel::benchPropertyUpdates()
+             obj->change();
+         }
+ 
+-        channel.d_func()->publisher->clientIsIdle = true;
++        channel.d_func()->publisher->setClientIsIdle(true, m_dummyTransport);
+         channel.d_func()->publisher->sendPendingPropertyUpdates();
+     }
+ }
+diff --git a/qtwebchannel/tests/auto/webchannel/tst_webchannel.h b/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
+index eae21f4..dd4e690 100644
+--- a/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
++++ b/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
+@@ -348,6 +348,7 @@ private slots:
+     void testJsonToVariant();
+     void testInfiniteRecursion();
+     void testAsyncObject();
++    void testPropertyMultipleTransports();
+     void testDeletionDuringMethodInvocation_data();
+     void testDeletionDuringMethodInvocation();
+ 
+Submodule qtwebengine f328054d...38e0df6c (commits not present)
+Submodule qtwebsockets 65850954..63fb8da1:
+diff --git a/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp b/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
+index 2affdd5..95f1194 100644
+--- a/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
++++ b/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
+@@ -273,6 +273,7 @@ void QWebSocketDataProcessor::clear()
+     if (!m_pConverterState)
+         m_pConverterState = new QTextCodec::ConverterState(QTextCodec::ConvertInvalidToNull |
+                                                            QTextCodec::IgnoreHeader);
++    frame.clear();
+ }
+ 
+ /*!
+diff --git a/qtwebsockets/src/websockets/qwebsocketprotocol.cpp b/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
+index df87a93..d0465f1 100644
+--- a/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
++++ b/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
+@@ -210,7 +210,7 @@ void QWebSocketProtocol::mask(char *payload, quint64 size, quint32 maskingKey)
+                             quint8((maskingKey & 0x0000FF00u) >> 8),
+                             quint8((maskingKey & 0x000000FFu))
+                           };
+-    int i = 0;
++    quint64 i = 0;
+     while (size-- > 0)
+         *payload++ ^= mask[i++ % 4];
+ }
diff --git a/srcpkgs/qt5/template b/srcpkgs/qt5/template
index a79d25e69da8..6dddce7f3e46 100644
--- a/srcpkgs/qt5/template
+++ b/srcpkgs/qt5/template
@@ -2,11 +2,11 @@
 #
 # revbump libqtxdg after bumping patch version
 pkgname=qt5
-version=5.15.7+20221119
+version=5.15.8
+revision=1
+build_style=meta
 # commit f8c9fb304bc3e53b3aa07f962cd74e9160decccc
 # base repo: https://invent.kde.org/qt/qt/qt5
-revision=5
-build_style=meta
 hostmakedepends="cmake clang flex perl glib-devel pkg-config
  python re2c ruby which"
 makedepends="SDL2-devel Vulkan-Headers alsa-lib-devel double-conversion-devel
@@ -29,8 +29,9 @@ homepage="https://qt.io/"
 # tarball is generated with `git archive-all qt5-$version.tar.gz`
 # to keep the size smaller qtwebengine, qtwebview, qtdocgallery, qtactiveqt and qtpim
 # can be marked with the export-ignore attribute
-distfiles="https://void.johnnynator.dev/distfiles/qt5-${version}.tar.gz"
-checksum=9d57af471c78029a362276b7c99108ea009f511bb9ba6ff6cb884f6ddd255e9f
+#distfiles="https://void.johnnynator.dev/distfiles/qt5-${version}.tar.gz"
+distfiles="https://download.qt.io/archive/qt/5.15/${version}/single/qt-everywhere-opensource-src-${version}.tar.xz"
+checksum=776a9302c336671f9406a53bd30b8e36f825742b2ec44a57c08217bff0fa86b9
 python_version=2 #unverified
 replaces="qt5-doc<5.6.0 qt5-quick1<5.6.0 qt5-quick1-devel<5.6.0 qt5-webkit<5.6.0 qt5-webkit-devel<5.6.0
  qt5-enginio<5.7.1 qt5-enginio-devel<5.7.1 qt5-plugin-gtk<5.7.1 qt5-canvas3d<5.13.0"
@@ -250,7 +251,6 @@ do_configure() {
 	# opts+=" -v"
 	opts+=" -skip qtwebengine"
 	opts+=" -skip qtwebview"
-	opts+=" -skip qtdocgallery"
 	opts+=" -skip qtpim"
 	opts+=" -skip qtsystems"
 	opts+=" -skip qtspeech"

From 9ad9a12e762086e72cfbd8318d02310a781e539b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 075/113] qtav: revbump for ffmpeg4-4.4.3

---
 srcpkgs/qtav/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtav/template b/srcpkgs/qtav/template
index 34c30b2c0c78..2d00ad104355 100644
--- a/srcpkgs/qtav/template
+++ b/srcpkgs/qtav/template
@@ -1,10 +1,10 @@
 # Template file for 'qtav'
 pkgname=qtav
 version=1.13.0
-revision=1
+revision=2
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel libass-devel libopenal-devel
+makedepends="ffmpeg4-devel libass-devel libopenal-devel
  libva-glx-devel libXv-devel pulseaudio-devel
  qt5-declarative-devel qt5-svg-devel
  qt5-quickcontrols"

From e5763047aeaf3dff03123a218c29e5903f24d4f9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 076/113] qtox: revbump for ffmpeg-6.0

---
 srcpkgs/qtox/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qtox/template b/srcpkgs/qtox/template
index 16019d7eaec9..5cea0b11b697 100644
--- a/srcpkgs/qtox/template
+++ b/srcpkgs/qtox/template
@@ -1,7 +1,7 @@
 # Template file for 'qtox'
 pkgname=qtox
 version=1.17.6
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DUPDATE_CHECK=OFF
  -DGIT_DESCRIBE=${version}

From e5364bdb7661c697abb10caffc42871770d000c3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 077/113] retroarch: revbump for ffmpeg-6.0

---
 srcpkgs/retroarch/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroarch/template b/srcpkgs/retroarch/template
index 28016aa0129e..20a1415913be 100644
--- a/srcpkgs/retroarch/template
+++ b/srcpkgs/retroarch/template
@@ -1,7 +1,7 @@
 # Template file for 'retroarch'
 pkgname=retroarch
 version=1.15.0
-revision=1
+revision=2
 build_style=configure
 configure_args="--prefix=/usr --sysconfdir=/etc --enable-networking
  --enable-udev --disable-builtinflac --disable-builtinglslang

From 2910d0d2dc58c5983e88925fc3f1a19116b6e122 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 078/113] scrcpy: revbump for ffmpeg-6.0

---
 srcpkgs/scrcpy/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/scrcpy/template b/srcpkgs/scrcpy/template
index ee6e698e387f..8ada5ca4323f 100644
--- a/srcpkgs/scrcpy/template
+++ b/srcpkgs/scrcpy/template
@@ -1,7 +1,7 @@
 # Template file for 'scrcpy'
 pkgname=scrcpy
 version=2.0
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcompile_server=false
  -Dprebuilt_server=/usr/share/scrcpy/scrcpy-server-v${version}"

From 8d081d184dd64917da35d8a21f50a3f35504be49 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 079/113] spek-alternative: revbump for ffmpeg4-4.4.3

---
 srcpkgs/spek-alternative/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/spek-alternative/template b/srcpkgs/spek-alternative/template
index d65086b8f008..05246f1b8d0c 100644
--- a/srcpkgs/spek-alternative/template
+++ b/srcpkgs/spek-alternative/template
@@ -1,11 +1,11 @@
 # Template file for 'spek-alternative'
 pkgname=spek-alternative
 version=0.8.2.3
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake gettext-devel intltool libtool pkg-config wxWidgets-common"
-makedepends="ffmpeg-devel wxWidgets-gtk3-devel"
-depends="ffmpeg"
+makedepends="ffmpeg4-devel wxWidgets-gtk3-devel"
+depends="ffmpeg4"
 short_desc="Acoustic spectrum analyser"
 maintainer="Kartik Singh <kartik.ynwa@gmail.com>"
 license="GPL-3.0-or-later"

From 08a70ff706844114913a51da983c3369afe41347 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 080/113] ssr: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ssr/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/ssr/template b/srcpkgs/ssr/template
index b055b9ec0774..3448ca110eb0 100644
--- a/srcpkgs/ssr/template
+++ b/srcpkgs/ssr/template
@@ -1,11 +1,11 @@
 # Template file for 'ssr'
 pkgname=ssr
 version=0.4.4
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_QT5=ON"
 hostmakedepends="pkg-config"
-makedepends="alsa-lib-devel ffmpeg-devel glu-devel jack-devel pulseaudio-devel
+makedepends="alsa-lib-devel ffmpeg4-devel glu-devel jack-devel pulseaudio-devel
  qt5-tools-devel qt5-x11extras-devel libXinerama-devel v4l-utils-devel"
 depends="desktop-file-utils hicolor-icon-theme"
 short_desc="Simple Screen Recorder for programs and games"

From accfbe5300ca37e0e63e59ef6f37a119e837a35d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 081/113] sumo: revbump for ffmpeg-6.0

---
 srcpkgs/sumo/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/sumo/template b/srcpkgs/sumo/template
index 0f9b9ec815f5..a3fe134aa5ac 100644
--- a/srcpkgs/sumo/template
+++ b/srcpkgs/sumo/template
@@ -1,7 +1,7 @@
 # Template file for 'sumo'
 pkgname=sumo
 version=1.12.0
-revision=5
+revision=6
 build_style=cmake
 hostmakedepends="libgdal-tools pkg-config swig python3-setuptools"
 makedepends="python3-devel ffmpeg-devel fox-devel gl2ps-devel libgdal-devel

From f9169cb4ba348f2bbb40ed23b114b6744b74e096 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 082/113] synfig: revbump for ffmpeg-6.0 and mlt7

---
 srcpkgs/synfig/patches/ffmpeg6.patch | 71 ++++++++++++++++++++++++++++
 srcpkgs/synfig/template              |  4 +-
 2 files changed, 73 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/synfig/patches/ffmpeg6.patch

diff --git a/srcpkgs/synfig/patches/ffmpeg6.patch b/srcpkgs/synfig/patches/ffmpeg6.patch
new file mode 100644
index 000000000000..10780b42782f
--- /dev/null
+++ b/srcpkgs/synfig/patches/ffmpeg6.patch
@@ -0,0 +1,71 @@
+--- a/src/modules/mod_libavcodec/trgt_av.cpp	2022-10-25 09:14:12.000000000 -0400
++++ b/src/modules/mod_libavcodec/trgt_av.cpp	2023-05-05 21:34:17.899194559 -0400
+@@ -38,6 +41,7 @@
+ extern "C"
+ {
+ #ifdef HAVE_LIBAVFORMAT_AVFORMAT_H
++#	include <libavcodec/avcodec.h>
+ #	include <libavformat/avformat.h>
+ #elif defined(HAVE_AVFORMAT_H)
+ #	include <avformat.h>
+@@ -155,11 +156,11 @@
+     }
+ 
+ 	bool open_video_stream() {
+-		if (avcodec_open2(video_context, NULL, NULL) < 0) {
++		if (avcodec_open2(video_context, nullptr, nullptr) < 0) {
+ 			synfig::error("Target_LibAVCodec: could not open video codec");
+ 			// seems the calling of avcodec_free_context after error will cause crash
+ 			// so just forget about this context
+-			video_context = NULL;
++			video_context = nullptr;
+ 			close();
+ 			return false;
+         }
+@@ -234,15 +235,21 @@
+ 		close();
+ 
+ 		if (!av_registered) {
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 			av_register_all();
++#endif
+ 			av_registered = true;
+ 		}
+ 
+ 		// guess format
+-		AVOutputFormat *format = av_guess_format(NULL, filename.c_str(), NULL);
++#if LIBAVCODEC_VERSION_MAJOR < 59 // FFMPEG < 5.0
++		AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#else
++		const AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#endif
+ 		if (!format) {
+ 			synfig::warning("Target_LibAVCodec: unable to guess the output format, defaulting to MPEG");
+-			format = av_guess_format("mpeg", NULL, NULL);
++			format = av_guess_format("mpeg", nullptr, nullptr);
+ 		}
+ 		if (!format) {
+ 			synfig::error("Target_LibAVCodec: unable to find 'mpeg' output format");
+@@ -254,6 +261,7 @@
+ 		context = avformat_alloc_context();
+ 		assert(context);
+ 		context->oformat = format;
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 		if (filename.size() + 1 > sizeof(context->filename)) {
+ 			synfig::error(
+ 				"Target_LibAVCodec: filename too long, max length is %d, filename is '%s'",
+@@ -263,6 +271,14 @@
+ 			return false;
+ 		}
+ 		memcpy(context->filename, filename.c_str(), filename.size() + 1);
++#else
++		context->url = av_strndup(filename.c_str(), filename.size());
++		if (!context->url) {
++			synfig::error("Target_LibAVCodec: cannot allocate space for filename");
++			close();
++			return false;
++		}
++#endif
+ 
+ 		packet = av_packet_alloc();
+ 		assert(packet);
diff --git a/srcpkgs/synfig/template b/srcpkgs/synfig/template
index 5f5f5bb3f4b2..6e0d713150ae 100644
--- a/srcpkgs/synfig/template
+++ b/srcpkgs/synfig/template
@@ -6,7 +6,7 @@ revision=2
 build_style=gnu-configure
 configure_args="--with-boost-libdir=${XBPS_CROSS_BASE}/usr/lib"
 hostmakedepends="boost-build ImageMagick pkg-config intltool"
-makedepends="ETL gettext-devel libxml++-devel mlt-devel libmagick-devel
+makedepends="ETL gettext-devel libxml++-devel mlt7-devel libmagick-devel
  libmng-devel boost-build boost-devel libopenexr-devel ffmpeg-devel"
 depends="ImageMagick"
 short_desc="CLI 2D vector and timeline-based animation software"
@@ -20,7 +20,7 @@ CXXFLAGS="-std=c++11 -DHAVE_LOCALE_H=1"
 
 synfig-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision}
-	 libopenexr-devel libxml++-devel mlt-devel"
+	 libopenexr-devel libxml++-devel mlt7-devel"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/bin/synfig-config

From 838433f37167609cdc518dec35c969d3e672743d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 5 May 2023 12:57:57 -0400
Subject: [PATCH 083/113] synfigstudio: revbump for synfig mlt7

---
 srcpkgs/synfigstudio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/synfigstudio/template b/srcpkgs/synfigstudio/template
index 91349169ed2b..af1c5a296ef0 100644
--- a/srcpkgs/synfigstudio/template
+++ b/srcpkgs/synfigstudio/template
@@ -2,7 +2,7 @@
 # Should be kept in sync with 'synfig' and 'ETL'
 pkgname=synfigstudio
 version=1.4.4
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--disable-update-mimedb"
 hostmakedepends="pkg-config intltool gettext synfig"

From 590d43f463b8ce46436cb5e509551028601906c3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 084/113] tg_owt: revbump for ffmpeg-6.0

---
 srcpkgs/tg_owt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tg_owt/template b/srcpkgs/tg_owt/template
index 97d195ddb34a..551614b24956 100644
--- a/srcpkgs/tg_owt/template
+++ b/srcpkgs/tg_owt/template
@@ -1,7 +1,7 @@
 # Template file for 'tg_owt'
 pkgname=tg_owt
 version=0.0.0.20230107
-revision=1
+revision=2
 _commit=5098730b9eb6173f0b52068fe2555b7c1015123a
 _libyuv_commit=00950840d1c9bcbb3eb6ebc5aac5793e71166c8b
 _abseil_commit=8c0b94e793a66495e0b1f34a5eb26bd7dc672db0

From b6e8a670447713d03dbb2a54d1e054567888972b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 085/113] timg: revbump for ffmpeg-6.0

---
 srcpkgs/timg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/timg/template b/srcpkgs/timg/template
index 2a2ab763d2fd..8fb4327535ef 100644
--- a/srcpkgs/timg/template
+++ b/srcpkgs/timg/template
@@ -1,7 +1,7 @@
 # Template file for 'timg'
 pkgname=timg
 version=1.4.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_OPENSLIDE_SUPPORT=off -Wno-dev"
 hostmakedepends="pkg-config git"

From 303c9162e8f8f8177bd3eef49c326a06fdfe4172 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 086/113] tvheadend: revbump for ffmpeg4-4.4.3

---
 srcpkgs/tvheadend/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/tvheadend/template b/srcpkgs/tvheadend/template
index e6b16d7ccf3b..46b52b6fb7f9 100644
--- a/srcpkgs/tvheadend/template
+++ b/srcpkgs/tvheadend/template
@@ -1,14 +1,14 @@
 # Template file for 'tvheadend'
 pkgname=tvheadend
 version=4.2.8
-revision=6
+revision=7
 build_style=gnu-configure
 configure_args="--enable-dvbscan --disable-ffmpeg_static
 --disable-hdhomerun_static --disable-bintray_cache --disable-libx264_static
 --disable-libx265_static --disable-libvpx_static --disable-libtheora_static
 --disable-libvorbis_static --disable-libfdkaac_static"
 hostmakedepends="gettext pkg-config python git which"
-makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg-devel"
+makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg4-devel"
 short_desc="TV streaming server"
 maintainer="lemmi <lemmi@nerd2nerd.org>"
 license="GPL-3.0-only"

From 3a9cd37e9bdf586c999855c1fb2094f156751f7a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 087/113] unpaper: update to 7.0.0.

---
 srcpkgs/unpaper/template | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/srcpkgs/unpaper/template b/srcpkgs/unpaper/template
index 38ed47a58401..1ff910e722af 100644
--- a/srcpkgs/unpaper/template
+++ b/srcpkgs/unpaper/template
@@ -1,13 +1,13 @@
 # Template file for 'unpaper'
 pkgname=unpaper
-version=6.1
-revision=3
-build_style=gnu-configure
+version=7.0.0
+revision=1
+build_style=meson
+hostmakedepends="pkg-config meson libxslt"
+makedepends="ffmpeg-devel python3-Sphinx"
+short_desc="Post-processing tool for scanned sheets of paper"
 maintainer="Orphaned <orphan@voidlinux.org>"
-hostmakedepends="pkg-config libxslt"
-makedepends="ffmpeg-devel"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://www.flameeyes.eu/projects/unpaper"
-short_desc="A post-processing tool for scanned sheets of paper"
 distfiles="https://www.flameeyes.eu/files/${pkgname}-${version}.tar.xz"
-checksum=237c84f5da544b3f7709827f9f12c37c346cdf029b1128fb4633f9bafa5cb930
+checksum=2575fbbf26c22719d1cb882b59602c9900c7f747118ac130883f63419be46a80

From 69c6b238969f0b54d3c967ad90d3056e3279e6b0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 088/113] vba-m: revbump for ffmpeg-6.0

---
 srcpkgs/vba-m/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vba-m/template b/srcpkgs/vba-m/template
index ba153e0b58ca..aa6093645e97 100644
--- a/srcpkgs/vba-m/template
+++ b/srcpkgs/vba-m/template
@@ -2,7 +2,7 @@
 pkgname=vba-m
 reverts=1292_2
 version=2.1.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_GTK=TRUE -DENABLE_FFMPEG=TRUE -DENABLE_LINK=TRUE -DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="gettext pkg-config unzip zip yasm wxWidgets-gtk3-devel"

From 5c2032fd7a32b9f032e5d50d574f93b47cde87cb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 089/113] vice: revbump for ffmpeg4-4.4.3

---
 srcpkgs/vice/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/vice/template b/srcpkgs/vice/template
index 0924767cfcfb..5981e45149d0 100644
--- a/srcpkgs/vice/template
+++ b/srcpkgs/vice/template
@@ -1,7 +1,7 @@
 # Template file for 'vice'
 pkgname=vice
 version=3.5
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="
 	$(vopt_enable sdl2 sdlui2)
@@ -28,7 +28,7 @@ makedepends="
 	$(vopt_if gtk3 gtk+3-devel)
 	$(vopt_if gtk3 pulseaudio-devel)
 	$(vopt_if gtk3 pango-devel)
-	$(vopt_if ffmpeg ffmpeg-devel)"
+	$(vopt_if ffmpeg ffmpeg4-devel)"
 short_desc="Emulator for C64, C128, CBM-II, PET, VIC20, Plus4 and C16"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"

From c289530284eb201261b63468ccf8bb84ab813ca8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 090/113] waypipe: revbump for ffmpeg-6.0

---
 srcpkgs/waypipe/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waypipe/template b/srcpkgs/waypipe/template
index 5c4161900060..1a46fe27f7d8 100644
--- a/srcpkgs/waypipe/template
+++ b/srcpkgs/waypipe/template
@@ -1,7 +1,7 @@
 # Template file for 'waypipe'
 pkgname=waypipe
 version=0.8.4
-revision=1
+revision=2
 build_style=meson
 # lto is off because it causes linking errors in armv6l and armv7l (due to NEON)
 configure_args="-Dwerror=false -Dwith_dmabuf=enabled -Dwith_lz4=enabled

From a52ac146eb7f4e00a712e6110a01ead7e35f602f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 091/113] wf-recorder: revbump for ffmpeg-6.0

---
 srcpkgs/wf-recorder/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/wf-recorder/template b/srcpkgs/wf-recorder/template
index e278eb001600..5d014a5f28af 100644
--- a/srcpkgs/wf-recorder/template
+++ b/srcpkgs/wf-recorder/template
@@ -1,7 +1,7 @@
 # Template file for 'wf-recorder'
 pkgname=wf-recorder
 version=0.3.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config scdoc wayland-devel"
 makedepends="wayland-protocols wayland-devel ffmpeg-devel x264-devel

From c9caf6fcc66fc3fa424afab261676d63b5c76454 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 092/113] xpra: revbump for ffmpeg-6.0

---
 srcpkgs/xpra/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xpra/template b/srcpkgs/xpra/template
index 0a63fdb6c743..d5acc1981c5f 100644
--- a/srcpkgs/xpra/template
+++ b/srcpkgs/xpra/template
@@ -1,7 +1,7 @@
 # Template file for 'xpra'
 pkgname=xpra
 version=4.4.6
-revision=1
+revision=2
 build_style=python3-module
 make_build_args="--without-cuda_kernels --without-cuda_rebuild"
 make_install_args="$(vopt_with docs) ${make_build_args}"

From 7380e7f7195e020d770642dd77858bfaa5e19c6b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:07:40 -0400
Subject: [PATCH 093/113] nv-codec-headers: update to 12.0.16.0

---
 srcpkgs/nv-codec-headers/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/nv-codec-headers/template b/srcpkgs/nv-codec-headers/template
index 3d422a61e489..251e057f826f 100644
--- a/srcpkgs/nv-codec-headers/template
+++ b/srcpkgs/nv-codec-headers/template
@@ -1,6 +1,6 @@
 # Template file for 'nv-codec-headers'
 pkgname=nv-codec-headers
-version=11.1.5.1
+version=12.0.16.0
 revision=1
 build_style=gnu-makefile
 short_desc="FFmpeg version of headers required to interface with Nvidias codec APIs"
@@ -8,7 +8,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="MIT"
 homepage="http://git.videolan.org/?p=ffmpeg/nv-codec-headers.git"
 distfiles="https://github.com/FFmpeg/nv-codec-headers/archive/n${version}.tar.gz"
-checksum=d095fbd56aa93772471a323be0ebe65504a0f43f06c76a30b6d25da77b06ae9c
+checksum=2a1533b65f55f9da52956faf0627ed3b74868ac0c7f269990edd21369113b48f
 
 post_install() {
 	sed -n '4,25p' include/ffnvcodec/nvEncodeAPI.h > LICENSE

From 1d0d1325370bd53cb3585d8a9add498398393c82 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:08:40 -0400
Subject: [PATCH 094/113] openimagedenoise: revbump for ffmpeg-6.0

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index db5ccdb055cc..cb90045afb63 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,7 +1,7 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
 version=1.4.3
-revision=1
+revision=2
 archs="x86_64*"
 build_style=cmake
 hostmakedepends="ispc python3"

From b2a9cbe3374727f68cbde878a01adbda782fbbd8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:31:45 -0400
Subject: [PATCH 095/113] shotcut: revbump for ffmpeg-6.0

---
 srcpkgs/shotcut/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/shotcut/template b/srcpkgs/shotcut/template
index 7d2af7b0470b..c416c906ff73 100644
--- a/srcpkgs/shotcut/template
+++ b/srcpkgs/shotcut/template
@@ -1,7 +1,7 @@
 # Template file for 'shotcut'
 pkgname=shotcut
 version=23.05.14
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSHOTCUT_VERSION=${version}"
 hostmakedepends="pkg-config qt6-tools-devel"

From b3f7de17e2f9fa0f688b8742840a3ab1a67a8f8f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:30 -0400
Subject: [PATCH 096/113] shiboken2: revbump for qt5-5.15.8

---
 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch | 1 +
 srcpkgs/shiboken2/template                                 | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
 create mode 120000 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
new file mode 120000
index 000000000000..efcf3249bd88
--- /dev/null
+++ b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1 @@
+../../python3-pyside2/patches/importlib-machinery-bypass.patch
\ No newline at end of file
diff --git a/srcpkgs/shiboken2/template b/srcpkgs/shiboken2/template
index 084ecc3ba1e1..2a21998997eb 100644
--- a/srcpkgs/shiboken2/template
+++ b/srcpkgs/shiboken2/template
@@ -1,7 +1,7 @@
 # Template file for 'shiboken2'
 pkgname=shiboken2
 version=5.15.7
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/shiboken2"
 build_style=cmake

From 3e070382670b0c96b728cb833e0192abb46363cb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:53 -0400
Subject: [PATCH 097/113] python3-pyside2: update to 5.15.8

---
 .../patches/importlib-machinery-bypass.patch      | 15 +++++++++++++++
 srcpkgs/python3-pyside2/template                  |  9 +++++----
 2 files changed, 20 insertions(+), 4 deletions(-)
 create mode 100644 srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
new file mode 100644
index 000000000000..64c429584776
--- /dev/null
+++ b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1,15 @@
+Using this prevents an error around line 220 below it.
+"AttributeError: module 'importlib' has no attribute 'machinery'"
+The old backup logic is in place and compiles without issues.
+--- a/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:09:34.688912402 -0400
++++ b/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:10:03.395529582 -0400
+@@ -170,9 +170,6 @@
+
+     # 'zipstring_sequence' comes from signature.cpp
+     zipbytes = base64.b64decode(''.join(zipstring_sequence))
+-    if sys.version_info[0] >= 3:
+-        vzip = zipfile.ZipFile(io.BytesIO(zipbytes))
+-        return sys.meta_path, EmbeddableZipImporter(vzip)
+
+     # Old version for Python 2.7, only.
+     import os
diff --git a/srcpkgs/python3-pyside2/template b/srcpkgs/python3-pyside2/template
index 50e6ff260d3b..b50e62bd215d 100644
--- a/srcpkgs/python3-pyside2/template
+++ b/srcpkgs/python3-pyside2/template
@@ -1,11 +1,12 @@
 # Template file for 'python3-pyside2'
 pkgname=python3-pyside2
-version=5.15.5
-revision=2
+version=5.15.8
+revision=1
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/pyside2"
 build_style=cmake
-configure_args="-DPYTHON_EXECUTABLE=/usr/bin/python"
+configure_args="-DPYTHON_EXECUTABLE=/usr/bin/python -DCMAKE_BUILD_TYPE=None
+ -DBUILD_TESTS=OFF"
 hostmakedepends="cmake python3 shiboken2"
 makedepends="python3-devel libshiboken2-devel qt5-devel
  qt5-multimedia-devel qt5-tools-devel qt5-plugin-mysql qt5-plugin-odbc
@@ -23,7 +24,7 @@ maintainer="yopito <pierre.bourgin@free.fr>"
 license="LGPL-3.0-or-later"
 homepage="https://wiki.qt.io/Qt_for_Python"
 distfiles="https://download.qt.io/official_releases/QtForPython/pyside2/PySide2-${version}-src/${_pkgname}.tar.xz"
-checksum=3920a4fb353300260c9bc46ff70f1fb975c5e7efa22e9d51222588928ce19b33
+checksum=23436302c8deb5b4cbc769b205d09604e38ba83b40708efccb7bd8c9af6f6b5d
 
 build_options="webengine"
 desc_option_webengine="Build Qt5 WebEngine bindings"

From 9f081989916530642c132b5e906e2b78976f3740 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:35 -0400
Subject: [PATCH 098/113] konqueror: revbump for ffmpeg-6.0

---
 srcpkgs/konqueror/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/konqueror/template b/srcpkgs/konqueror/template
index d8d0e73a78ab..c5bdba601d3c 100644
--- a/srcpkgs/konqueror/template
+++ b/srcpkgs/konqueror/template
@@ -1,11 +1,11 @@
 # Template file for 'konqueror'
 pkgname=konqueror
 version=23.04.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DDESKTOPTOJSON_EXECUTABLE=/usr/bin/desktoptojson"
 hostmakedepends="extra-cmake-modules python3 qt5-host-tools qt5-qmake kdoctools
-kcoreaddons kconfig gettext"
+ kcoreaddons kconfig gettext"
 makedepends="qt5-devel qt5-webengine-devel qt5-declarative-devel
  qt5-webchannel-devel qt5-location-devel kcmutils-devel kdelibs4support-devel
  karchive-devel khtml-devel kdesu-devel kactivities5-devel"

From 8a6ded496f3439fe258c4cdd2e4571529f4bc1bf Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:58 -0400
Subject: [PATCH 099/113] qt5-speech: revbump for qt5-5.15.8

---
 srcpkgs/qt5-speech/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-speech/template b/srcpkgs/qt5-speech/template
index 3ecd10d50650..2d7d4d4d2453 100644
--- a/srcpkgs/qt5-speech/template
+++ b/srcpkgs/qt5-speech/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-speech'
 pkgname=qt5-speech
 version=5.15.7
-revision=2
+revision=3
 _commit=d32f4a479d38a11f547598004b975f4356424a16
 build_style=qmake
 configure_args="-- -flite -flite-alsa -speechd"

From 47f4ba66a98b6a71fc7d5e3d9714952267b2ba48 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 18:38:50 -0400
Subject: [PATCH 100/113] qt5-styleplugins: revbump for qt5-5.15.8

---
 srcpkgs/qt5-styleplugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-styleplugins/template b/srcpkgs/qt5-styleplugins/template
index 96ed97d12cd2..30d93660a2a4 100644
--- a/srcpkgs/qt5-styleplugins/template
+++ b/srcpkgs/qt5-styleplugins/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-styleplugins'
 pkgname=qt5-styleplugins
 version=5.0.0
-revision=20
+revision=21
 _gitrev=335dbece103e2cbf6c7cf819ab6672c2956b17b3
 build_style=qmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From 5cd48ece4797958585d7d05ccc570a68db4d2398 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 7 May 2023 20:14:14 -0400
Subject: [PATCH 101/113] mlt7: revbump for ffmpeg-6.0

---
 srcpkgs/gst-libav/template | 2 +-
 srcpkgs/mlt7/template      | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index 04c39bff1489..8c72fc3e97ee 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.22.2
-revision=2
+revision=1
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"
diff --git a/srcpkgs/mlt7/template b/srcpkgs/mlt7/template
index 9fb7f60d692e..cca0eb68cfc3 100644
--- a/srcpkgs/mlt7/template
+++ b/srcpkgs/mlt7/template
@@ -1,7 +1,7 @@
 # Template file for 'mlt7'
 pkgname=mlt7
 version=7.14.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSWIG_PYTHON=ON"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which

From f25eefe70ffefe875092eab7744844b0f5e7b121 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 7 May 2023 20:15:03 -0400
Subject: [PATCH 102/113] qt6-webengine: revbump for ffmpeg-6.0

---
 srcpkgs/qt6-webengine/template | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-webengine/template b/srcpkgs/qt6-webengine/template
index 4e22cb6e8863..43778b568d3f 100644
--- a/srcpkgs/qt6-webengine/template
+++ b/srcpkgs/qt6-webengine/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-webengine'
 pkgname=qt6-webengine
 version=6.5.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="
  -DQT_FEATURE_webengine_system_ffmpeg=ON
@@ -145,6 +145,7 @@ pre_install() {
 }
 
 post_install() {
+	vlicense LICENSES/BSD-3-Clause.txt
 	local _file
 	find "${DESTDIR}"/usr/lib/qt6/examples \
 		-path '*/lib/qt6/**/lib/qt6/*' -type f |

From 4811b45fac9001da3dd3a8b479bb05498fbe9d96 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 7 May 2023 20:15:29 -0400
Subject: [PATCH 103/113] tracker-miners: revbump for ffmpeg-6.0

---
 srcpkgs/tracker-miners/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tracker-miners/template b/srcpkgs/tracker-miners/template
index 8c005d697fa4..a6e5aa577702 100644
--- a/srcpkgs/tracker-miners/template
+++ b/srcpkgs/tracker-miners/template
@@ -1,7 +1,7 @@
 # Template file for 'tracker-miners'
 pkgname=tracker-miners
 version=3.5.0
-revision=3
+revision=4
 build_style=meson
 build_helper=qemu
 # missing libgrss for miner_rss

From 1630d8a2ebd0d3bc5293e16a344744c52e360685 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 7 May 2023 20:20:58 -0400
Subject: [PATCH 104/113] mpd: revbump for ffmpeg-6.0

---
 srcpkgs/mpd/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpd/template b/srcpkgs/mpd/template
index 9dbd4c935acc..9f058b62df2f 100644
--- a/srcpkgs/mpd/template
+++ b/srcpkgs/mpd/template
@@ -1,7 +1,7 @@
 # Template file for 'mpd'
 pkgname=mpd
 version=0.23.13
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dopus=enabled -Dmikmod=enabled -Dneighbor=true
  -Dsoundcloud=enabled -Dpipe=true -Dtwolame=enabled -Dbzip2=enabled

From 5f49e16a6afac92848bbe7474cb13871c432c3ff Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 11 May 2023 14:05:14 -0400
Subject: [PATCH 105/113] openmw: revbump for ffmpeg-6.0

---
 srcpkgs/openmw/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openmw/template b/srcpkgs/openmw/template
index e3771c7aaf1a..3cbf20b06577 100644
--- a/srcpkgs/openmw/template
+++ b/srcpkgs/openmw/template
@@ -1,7 +1,7 @@
 # Template file for 'openmw'
 pkgname=openmw
 version=0.47.0
-revision=5
+revision=6
 build_style=cmake
 _recast_commit=e75adf86f91eb3082220085e42dda62679f9a3ea
 _bullet_tag=3.17

From b2108cff01cce1d500c9d8246d4d97c9e2a61396 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 21 May 2023 12:44:11 -0400
Subject: [PATCH 106/113] electron24: revbump for ffmpeg-6.0

---
 srcpkgs/electron24/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron24/template b/srcpkgs/electron24/template
index bdaa56adc8a6..ff3d5e3ef381 100644
--- a/srcpkgs/electron24/template
+++ b/srcpkgs/electron24/template
@@ -1,7 +1,7 @@
 # Template file for 'electron24'
 pkgname=electron24
 version=24.3.0
-revision=1
+revision=2
 _nodever=18.14.0
 _chromiumver=112.0.5615.165
 archs="x86_64* aarch64*"

From 8694473102b1c5c030ecbd4de1b505fd3a807ed2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Jun 2023 08:20:22 -0400
Subject: [PATCH 107/113] gtk4: revbump for ffmpeg-6.0

---
 srcpkgs/gtk4/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gtk4/template b/srcpkgs/gtk4/template
index b318b7bae1dd..e3bde4a50e54 100644
--- a/srcpkgs/gtk4/template
+++ b/srcpkgs/gtk4/template
@@ -1,7 +1,7 @@
 # Template file for 'gtk4'
 pkgname=gtk4
 version=4.10.4
-revision=1
+revision=2
 build_style=meson
 build_helper="gir"
 configure_args="-Dman-pages=true -Dgtk_doc=true -Dbuild-tests=false

From 3ec0ad12f1d008617343cf71d2ba0cade6891d9a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:25:50 -0400
Subject: [PATCH 108/113] electron19: revbump for ffmpeg-6.0

---
 srcpkgs/electron19/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron19/template b/srcpkgs/electron19/template
index 32ce301e730c..ab7f308f5e8a 100644
--- a/srcpkgs/electron19/template
+++ b/srcpkgs/electron19/template
@@ -1,7 +1,7 @@
 # Template file for 'electron19'
 pkgname=electron19
 version=19.0.8
-revision=3
+revision=4
 _nodever=16.14.2
 _chromiumver=102.0.5005.125
 archs="x86_64* aarch64* ppc64le*"

From ab78c461ca76cb79486a81b53e809608b6c07c62 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:28:26 -0400
Subject: [PATCH 109/113] siril: revbump for ffmpeg-6.0

---
 srcpkgs/siril/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/siril/template b/srcpkgs/siril/template
index 84332f79d060..62750dd24754 100644
--- a/srcpkgs/siril/template
+++ b/srcpkgs/siril/template
@@ -1,7 +1,7 @@
 # Template file for 'siril'
 pkgname=siril
 version=0.9.12
-revision=10
+revision=11
 build_style=gnu-configure
 hostmakedepends="pkg-config intltool autoconf automake gettext-devel"
 makedepends="fftw-devel libconfig-devel libopencv-devel libffms2-devel

From 0111765e03900f469932e5cc13f69e9785504d5a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:29:08 -0400
Subject: [PATCH 110/113] telegram-desktop: revbump for ffmpeg-6.0

---
 srcpkgs/telegram-desktop/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/telegram-desktop/template b/srcpkgs/telegram-desktop/template
index f114b2341dc5..9db9f80c1a53 100644
--- a/srcpkgs/telegram-desktop/template
+++ b/srcpkgs/telegram-desktop/template
@@ -1,7 +1,7 @@
 # Template file for 'telegram-desktop'
 pkgname=telegram-desktop
 version=4.8.1
-revision=3
+revision=4
 build_style=cmake
 build_helper="qemu"
 configure_args="-DTDESKTOP_API_ID=209235

From adc3338018d23c8dfc8cac95d74252741b3e0e12 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 10 Jun 2023 00:40:39 -0400
Subject: [PATCH 111/113] freecad: revbump for qt5-webengine-5.15.13

---
 srcpkgs/freecad/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/freecad/template b/srcpkgs/freecad/template
index a4a3f5f76b29..8608d1670c87 100644
--- a/srcpkgs/freecad/template
+++ b/srcpkgs/freecad/template
@@ -1,7 +1,7 @@
 # Template file for 'freecad'
 pkgname=freecad
 version=0.20.2
-revision=5
+revision=6
 build_style=cmake
 
 _inst_prefix=/usr/lib/${pkgname}

From 7ffa8f8da1b1b5bb98304447a9a8107336bc8b2b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 10 Jun 2023 00:57:09 -0400
Subject: [PATCH 112/113] qt6-multimedia: revbump for ffmpeg-6.0

---
 srcpkgs/qt6-multimedia/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-multimedia/template b/srcpkgs/qt6-multimedia/template
index a6832fdd69bf..c9ffac914ab8 100644
--- a/srcpkgs/qt6-multimedia/template
+++ b/srcpkgs/qt6-multimedia/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-multimedia'
 pkgname=qt6-multimedia
 version=6.5.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DQT_FEATURE_gstreamer=ON"
 hostmakedepends="perl qt6-declarative-host-tools pkg-config qt6-shadertools"

From cd8cead4ed4a995df2822653e4aaea06f74a37a3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 22 Jun 2023 10:25:02 -0400
Subject: [PATCH 113/113] kdenlive: revbump for ffmpeg-6.0

---
 srcpkgs/kdenlive/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kdenlive/template b/srcpkgs/kdenlive/template
index 89c0dcfb8577..75495b3a3586 100644
--- a/srcpkgs/kdenlive/template
+++ b/srcpkgs/kdenlive/template
@@ -1,7 +1,7 @@
 # Template file for 'kdenlive'
 pkgname=kdenlive
 version=23.04.2
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="
  extra-cmake-modules kconfig kcoreaddons kdoctools pkg-config python3

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (14 preceding siblings ...)
  2023-06-23 20:37 ` [PR PATCH] [Updated] " zlice
@ 2023-07-04 13:30 ` zlice
  2023-07-04 14:18 ` zlice
                   ` (81 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2023-07-04 13:30 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 3488 bytes --]

There is an updated pull request by zlice against master on the void-packages repository

https://github.com/zlice/void-packages ffmpeg6-split
https://github.com/void-linux/void-packages/pull/43761

ffmpeg6 split
[ci skip]


#### Testing the changes

- I tested the changes in this PR: **YES**

main testing has been vaapi in Firefox Nightly and enc/dec in Shotcut on Intel A770

#### New package

- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**

#### Local build testing

- I built this PR locally for my native architecture, **x86_64**

#### Discussion

Continuation of https://github.com/void-linux/void-packages/pull/36315

`libavresample` is deprecated, but marked as a dependency when trying to build other packages and install `ffmpeg`(6). I think the right way to handle this is make a meta package and the add to removals?


##### Commit naming / misc

~~Commits are 'dirty' right now, running with [gstreamer 1.22.1 updates](https://github.com/void-linux/void-packages/pull/42861) and [Intel OpenCL](https://github.com/void-linux/void-packages/pull/43084). This will also make [intel packages pr](https://github.com/void-linux/void-packages/pull/41132) obsolete.~~ (see Requirements below)

Maintainer for previous ffmpeg(4) was orphaned, I can put my name in there if that matters, though I don't exactly see myself keeping up on ffmpeg.

This updates QT5 which looks like it is usually hosted by Johnny. Not sure if there's any reason to stay there or these sources are fine.

##### STILL FFMPEG4

These are a mix of emulators, games and/or older packages.

- attract (multiple patches in master)
- audacity (https://github.com/audacity/audacity/issues/2305 and https://sourceforge.net/p/portmedia/wiki/portsmf/ is 'beta')
- ccextractor (master patches? no release)
- vice
- kodi
- mlt (only dep left is flowblade)
- ~~synfig (mlt)~~ (work with mlt7, bump synfigstudio)
- tvheadend
- ssr
- spek-alternative
- ppsspp
- olive
- moc
- mediastreamer
- libextractor
- idjc
- hedgewars
- ~~ffmpegthumbnailer~~ (patches for moviedecoder.xxx files)
- ~~ffmpegthumbs~~ (latest compiles)
- deadbeef
- omxplayer
- qtav (fork has ffmpeg 5 patch - https://github.com/cmguo/QtAV)
- `vlc` (vlc4 will support ffmpeg5, there's a patch to build 3.x with ffmpeg5 but it will lack vaapi)
- `osg` (OpenSceneGraph plus `xine-lib`)


##### HAVE NOT BUILT YET

- omxplayer (rpi only? ffmpeg4)
- kodi (big, but ffmpeg4)


##### UPDATED (for ffmpeg6)

- ~~blender: update to 3.5.1~~ ~~will be revbump with~~ https://github.com/void-linux/void-packages/pull/43992
- unpaper: update to 7.0.0.
- guvcview: update to 2.0.8.
- qt5: update to 5.15.8
- qt5-webengine: update to 5.18.13
- shiboken2: revbump for qt5.15.8 (patch)
- python3-pyside2: update to 5.15.8 (patch)


##### Requirements

- ~~[gstreamer 1.22.2](https://github.com/void-linux/void-packages/pull/42861)~~ - a few packages use ffmpeg-devel and require a revbump

- [Intel Packages](https://github.com/void-linux/void-packages/pull/41132) - ffmpeg4 uses different libraries than 6 (libmfx / Intel-MediaSDK vs only oneVPL that Intel is moving to), both are included here

- ~~[shotcut 23.05.14](https://github.com/void-linux/void-packages/pull/44260)~~

A patch file from https://github.com/void-linux/void-packages/pull/43761.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ffmpeg6-split-43761.patch --]
[-- Type: text/x-diff, Size: 779374 bytes --]

From 859fe4a884f213f4f8e7c7bfd3e3bea413bc6802 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:55:46 -0400
Subject: [PATCH 001/113] ffmpeg: update to 6.0.

---
 common/shlibs                                 | 26 +++++---
 srcpkgs/ffmpeg/files/altivec.patch            | 60 -------------------
 .../patches/armv5tel-floating-point.patch     | 18 ------
 .../workaround-mesa-readeon-vaapi-bug.patch   | 28 ---------
 srcpkgs/ffmpeg/template                       | 41 +++++--------
 5 files changed, 33 insertions(+), 140 deletions(-)
 delete mode 100644 srcpkgs/ffmpeg/files/altivec.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch

diff --git a/common/shlibs b/common/shlibs
index 4e6a5a663fa02..a77346cce3e9a 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -387,15 +387,23 @@ libid3tag.so.0 libid3tag-0.15.1b_1
 libgif.so.7 giflib-5.1.0_1
 libImlib2.so.1 imlib2-1.4.2_1
 libmp3lame.so.0 lame-3.98.2_1
-libavdevice.so.58 libavdevice-4.0_1
-libavformat.so.58 libavformat-4.0_1
-libswscale.so.5 libswscale-4.0_1
-libswresample.so.3 libswresample-4.0_1
-libavresample.so.4 libavresample-4.0_1
-libpostproc.so.55 libpostproc-4.0_1
-libavcodec.so.58 libavcodec-4.0_1
-libavutil.so.56 libavutil-4.0_1
-libavfilter.so.7 libavfilter-4.0_1
+libavdevice.so.60 libavdevice-6.0_1
+libavformat.so.60 libavformat-6.0_1
+libswscale.so.7 libswscale-6.0_1
+libswresample.so.4 libswresample-6.0_1
+libpostproc.so.57 libpostproc-6.0_1
+libavcodec.so.60 libavcodec-6.0_1
+libavutil.so.58 libavutil-6.0_1
+libavfilter.so.9 libavfilter-6.0_1
+libavdevice.so.58 libavdevice4-4.0_1
+libavformat.so.58 libavformat4-4.0_1
+libswscale.so.5 libswscale4-4.0_1
+libswresample.so.3 libswresample4-4.0_1
+libavresample.so.4 libavresample4-4.0_1
+libpostproc.so.55 libpostproc4-4.0_1
+libavcodec.so.58 libavcodec4-4.0_1
+libavutil.so.56 libavutil4-4.0_1
+libavfilter.so.7 libavfilter4-4.0_1
 libSDL-1.2.so.0 SDL-1.2.14_1
 libSDL_image-1.2.so.0 SDL_image-1.2.10_1
 libx264.so.157 x264-20190507.2245_1
diff --git a/srcpkgs/ffmpeg/files/altivec.patch b/srcpkgs/ffmpeg/files/altivec.patch
deleted file mode 100644
index 9c57200463320..0000000000000
--- a/srcpkgs/ffmpeg/files/altivec.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-revert some altivec specific change on all ppc* except ppc64le*
-
-q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
-conditionally, for ppc* but not ppc64le* (the new code is valid for
-POWER8 VSX which LE targets as a baseline but not BE)"
-
-
-This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
----
- libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
- 1 file changed, 20 insertions(+), 4 deletions(-)
-
-diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
-index 536545293d..c1e2852adb 100644
---- a/libswscale/ppc/yuv2rgb_altivec.c
-+++ b/libswscale/ppc/yuv2rgb_altivec.c
-@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-     vector signed short R1, G1, B1;                                           \
-     vector unsigned char R, G, B;                                             \
-                                                                               \
-+    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
-+    vector unsigned char align_perm;                                          \
-+                                                                              \
-     vector signed short lCY       = c->CY;                                    \
-     vector signed short lOY       = c->OY;                                    \
-     vector signed short lCRV      = c->CRV;                                   \
-@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
-                                                                               \
-         for (j = 0; j < w / 16; j++) {                                        \
--            y0 = vec_xl(0, y1i);                                              \
-+            y1ivP = (const vector unsigned char *) y1i;                       \
-+            y2ivP = (const vector unsigned char *) y2i;                       \
-+            uivP  = (const vector unsigned char *) ui;                        \
-+            vivP  = (const vector unsigned char *) vi;                        \
-+                                                                              \
-+            align_perm = vec_lvsl(0, y1i);                                    \
-+            y0 = (vector unsigned char)                                       \
-+                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
-                                                                               \
--            y1 = vec_xl(0, y2i);                                              \
-+            align_perm = vec_lvsl(0, y2i);                                    \
-+            y1 = (vector unsigned char)                                       \
-+                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
-                                                                               \
--            u = (vector signed char) vec_xl(0, ui);                           \
-+            align_perm = vec_lvsl(0, ui);                                     \
-+            u = (vector signed char)                                          \
-+                    vec_perm(uivP[0], uivP[1], align_perm);                   \
-                                                                               \
--            v = (vector signed char) vec_xl(0, vi);                           \
-+            align_perm = vec_lvsl(0, vi);                                     \
-+            v = (vector signed char)                                          \
-+                    vec_perm(vivP[0], vivP[1], align_perm);                   \
-                                                                               \
-             u = (vector signed char)                                          \
-                     vec_sub(u,                                                \
--- 
-2.27.0
-
diff --git a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
deleted file mode 100644
index 9a55178c74f0f..0000000000000
--- a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
-+++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
-@@ -39,6 +39,15 @@
- #endif
- #include <fenv.h>
- 
-+#if (FE_ALL_EXCEPT == 0)
-+/* E.g. ARM soft float does not define these */
-+#define FE_INVALID    0
-+#define FE_DIVBYZERO  0
-+#define FE_OVERFLOW   0
-+#define FE_UNDERFLOW  0
-+#define FE_INEXACT    0
-+#endif
-+
- #if CONFIG_LIBFONTCONFIG
- #include <fontconfig/fontconfig.h>
- #endif
diff --git a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
deleted file mode 100644
index 00e3f68a415b8..0000000000000
--- a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
-From: Rainer Hochecker <fernetmenta@online.de>
-Date: Sat, 26 Jan 2019 19:48:35 +0100
-Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
-
-This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
-It was hit frequently when watching h264 channels received via DVB-X.
-Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
----
- libavcodec/vaapi_h264.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
-index 5854587a255..f12fdc457a4 100644
---- a/libavcodec/vaapi_h264.c
-+++ b/libavcodec/vaapi_h264.c
-@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
-     H264SliceContext *sl = &h->slice_ctx[0];
-     int ret;
- 
-+    if (pic->nb_slices == 0) {
-+        ret = AVERROR_INVALIDDATA;
-+        goto finish;
-+    }
-+
-     ret = ff_vaapi_decode_issue(avctx, pic);
-     if (ret < 0)
-         goto finish;
diff --git a/srcpkgs/ffmpeg/template b/srcpkgs/ffmpeg/template
index aa058aab9ca9f..a2c5d8750dd6b 100644
--- a/srcpkgs/ffmpeg/template
+++ b/srcpkgs/ffmpeg/template
@@ -1,15 +1,14 @@
 # Template file for 'ffmpeg'
 # audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
-pkgname=ffmpeg
-version=4.4.4
-revision=2
+version=6.0
+revision=1
 short_desc="Decoding, encoding and streaming software"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="https://www.ffmpeg.org"
 changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
 distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
-checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+checksum=57be87c22d9b49c112b6d24bc67d42508660e6b718b3db89c44e47e289137082
 
 hostmakedepends="pkg-config perl"
 makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
@@ -26,12 +25,13 @@ makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-deve
  $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
  $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
  $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
- $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers Vulkan-Tools Vulkan-ValidationLayers')
+ $(vopt_if onevpl 'onevpl onevpl-devel')
  $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
 depends="ffplay>=${version}_${revision}"
 
 build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
- dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec onevpl"
 build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
 desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
 desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
@@ -39,10 +39,8 @@ desc_option_sofa="Enable support for AES SOFA"
 desc_option_webp="Enable support for WebP"
 
 case "$XBPS_TARGET_MACHINE" in
-	i686*|x86_64*)
-		hostmakedepends+=" nasm"
-		build_options_default+=" vaapi vdpau nvenc nvdec"
-		;;
+	i686*) build_options_default+=" vaapi vdpau nvenc nvdec";;
+	x86_64*) build_options_default+=" vaapi vdpau nvenc nvdec onevpl";;
 	ppc64*) build_options_default+=" vaapi vdpau";;
 	mips*) CFLAGS="-mnan=legacy";;
 esac
@@ -119,18 +117,19 @@ do_configure() {
 		$(vopt_enable x265 libx265) \
 		$(vopt_enable v4l2 libv4l2) \
 		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
-		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		--enable-libbs2b --enable-libvidstab \
 		$(vopt_enable dav1d libdav1d) \
 		$(vopt_enable zimg libzimg) \
 		$(vopt_enable webp libwebp) \
 		$(vopt_enable sofa libmysofa) \
 		$(vopt_enable vulkan) \
+		$(vopt_enable onevpl libvpl) \
 		$(vopt_enable drm libdrm) \
 		$(vopt_enable svtav1 libsvtav1) \
 		$(vopt_enable srt libsrt) \
 		$(vopt_enable rist librist) \
-		$(vopt_if nvenc '--enable-nvenc') \
-		$(vopt_if nvdec '--enable-nvdec')
+		$(vopt_enable nvenc nvenc) \
+		$(vopt_enable nvdec nvdec)
 }
 
 do_build() {
@@ -157,10 +156,8 @@ libavdevice_package() {
 }
 
 libavresample_package() {
-	short_desc="FFmpeg audio resampling library"
-	pkg_install() {
-		vmove "usr/lib/libavresample.so.*"
-	}
+	short_desc="Package deprecated, removal needed"
+	build_style=meta
 }
 
 libavformat_package() {
@@ -214,15 +211,9 @@ ffmpeg-devel_package() {
 		libavfilter>=${version}_${revision}
 		libpostproc>=${version}_${revision}
 		libswscale>=${version}_${revision}
-		libswresample>=${version}_${revision}
-		libavresample>=${version}_${revision}"
+		libswresample>=${version}_${revision}"
 	short_desc+=" - development files"
-
-	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
-		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
-		nostrip_files="/usr/lib/libavfilter.a"
-	fi
-
+	conflicts="ffmpeg4-devel"
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig

From 93c2a084536016cc7236416bebeacbb0b006b562 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:56:22 -0400
Subject: [PATCH 002/113] New package: ffmpeg4-4.4.4.

---
 srcpkgs/ffmpeg4-devel                         |   1 +
 srcpkgs/ffmpeg4/files/altivec.patch           |  60 +++++
 .../patches/armv5tel-floating-point.patch     |  18 ++
 ...h-libavcodec-libsvtav1-ten_bit_format.diff |  40 +++
 .../workaround-mesa-readeon-vaapi-bug.patch   |  28 ++
 srcpkgs/ffmpeg4/template                      | 240 ++++++++++++++++++
 srcpkgs/libavcodec4                           |   1 +
 srcpkgs/libavdevice4                          |   1 +
 srcpkgs/libavfilter4                          |   1 +
 srcpkgs/libavformat4                          |   1 +
 srcpkgs/libavresample4                        |   1 +
 srcpkgs/libavutil4                            |   1 +
 srcpkgs/libpostproc4                          |   1 +
 srcpkgs/libswresample4                        |   1 +
 srcpkgs/libswscale4                           |   1 +
 15 files changed, 396 insertions(+)
 create mode 120000 srcpkgs/ffmpeg4-devel
 create mode 100644 srcpkgs/ffmpeg4/files/altivec.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 create mode 100644 srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
 create mode 100644 srcpkgs/ffmpeg4/template
 create mode 120000 srcpkgs/libavcodec4
 create mode 120000 srcpkgs/libavdevice4
 create mode 120000 srcpkgs/libavfilter4
 create mode 120000 srcpkgs/libavformat4
 create mode 120000 srcpkgs/libavresample4
 create mode 120000 srcpkgs/libavutil4
 create mode 120000 srcpkgs/libpostproc4
 create mode 120000 srcpkgs/libswresample4
 create mode 120000 srcpkgs/libswscale4

diff --git a/srcpkgs/ffmpeg4-devel b/srcpkgs/ffmpeg4-devel
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/ffmpeg4-devel
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/ffmpeg4/files/altivec.patch b/srcpkgs/ffmpeg4/files/altivec.patch
new file mode 100644
index 0000000000000..9c57200463320
--- /dev/null
+++ b/srcpkgs/ffmpeg4/files/altivec.patch
@@ -0,0 +1,60 @@
+revert some altivec specific change on all ppc* except ppc64le*
+
+q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
+conditionally, for ppc* but not ppc64le* (the new code is valid for
+POWER8 VSX which LE targets as a baseline but not BE)"
+
+
+This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
+---
+ libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
+ 1 file changed, 20 insertions(+), 4 deletions(-)
+
+diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
+index 536545293d..c1e2852adb 100644
+--- a/libswscale/ppc/yuv2rgb_altivec.c
++++ b/libswscale/ppc/yuv2rgb_altivec.c
+@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+     vector signed short R1, G1, B1;                                           \
+     vector unsigned char R, G, B;                                             \
+                                                                               \
++    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
++    vector unsigned char align_perm;                                          \
++                                                                              \
+     vector signed short lCY       = c->CY;                                    \
+     vector signed short lOY       = c->OY;                                    \
+     vector signed short lCRV      = c->CRV;                                   \
+@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
+                                                                               \
+         for (j = 0; j < w / 16; j++) {                                        \
+-            y0 = vec_xl(0, y1i);                                              \
++            y1ivP = (const vector unsigned char *) y1i;                       \
++            y2ivP = (const vector unsigned char *) y2i;                       \
++            uivP  = (const vector unsigned char *) ui;                        \
++            vivP  = (const vector unsigned char *) vi;                        \
++                                                                              \
++            align_perm = vec_lvsl(0, y1i);                                    \
++            y0 = (vector unsigned char)                                       \
++                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
+                                                                               \
+-            y1 = vec_xl(0, y2i);                                              \
++            align_perm = vec_lvsl(0, y2i);                                    \
++            y1 = (vector unsigned char)                                       \
++                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
+                                                                               \
+-            u = (vector signed char) vec_xl(0, ui);                           \
++            align_perm = vec_lvsl(0, ui);                                     \
++            u = (vector signed char)                                          \
++                    vec_perm(uivP[0], uivP[1], align_perm);                   \
+                                                                               \
+-            v = (vector signed char) vec_xl(0, vi);                           \
++            align_perm = vec_lvsl(0, vi);                                     \
++            v = (vector signed char)                                          \
++                    vec_perm(vivP[0], vivP[1], align_perm);                   \
+                                                                               \
+             u = (vector signed char)                                          \
+                     vec_sub(u,                                                \
+-- 
+2.27.0
+
diff --git a/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
new file mode 100644
index 0000000000000..9a55178c74f0f
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
@@ -0,0 +1,18 @@
+--- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
++++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
+@@ -39,6 +39,15 @@
+ #endif
+ #include <fenv.h>
+ 
++#if (FE_ALL_EXCEPT == 0)
++/* E.g. ARM soft float does not define these */
++#define FE_INVALID    0
++#define FE_DIVBYZERO  0
++#define FE_OVERFLOW   0
++#define FE_UNDERFLOW  0
++#define FE_INEXACT    0
++#endif
++
+ #if CONFIG_LIBFONTCONFIG
+ #include <fontconfig/fontconfig.h>
+ #endif
diff --git a/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
new file mode 100644
index 0000000000000..aa948f7a8a2df
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
@@ -0,0 +1,40 @@
+#==================================================================================================
+# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
+# From: Christopher Degawa <christopher.degawa@intel.com>
+# Date: Thu, 20 Oct 2022 22:55:27 -0500
+# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
+#
+# compressed_ten_bit_format has been deprecated upstream and has no effect
+# and can be removed. Plus, technically it was never used in the first place
+# since it would require the app (ffmpeg) to set it and do additional
+# processing of the input frames.
+#
+# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
+#
+# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
+#==================================================================================================
+--- a/libavcodec/libsvtav1.c
++++ b/libavcodec/libsvtav1.c
+@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
+ 
+ static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
+ {
+-    const int    pack_mode_10bit =
+-        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
+-    const size_t luma_size_8bit  =
+-        config->source_width * config->source_height * (1 << pack_mode_10bit);
+-    const size_t luma_size_10bit =
+-        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
++    const size_t luma_size = config->source_width * config->source_height *
++        (config->encoder_bit_depth > 8 ? 2 : 1);
+ 
+     EbSvtIOFormat *in_data;
+ 
+-    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
++    svt_enc->raw_size = luma_size * 3 / 2;
+ 
+     // allocate buffer for in and out
+     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
+-- 
+GitLab
+
diff --git a/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
new file mode 100644
index 0000000000000..00e3f68a415b8
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
@@ -0,0 +1,28 @@
+From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
+From: Rainer Hochecker <fernetmenta@online.de>
+Date: Sat, 26 Jan 2019 19:48:35 +0100
+Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
+
+This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
+It was hit frequently when watching h264 channels received via DVB-X.
+Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
+---
+ libavcodec/vaapi_h264.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
+index 5854587a255..f12fdc457a4 100644
+--- a/libavcodec/vaapi_h264.c
++++ b/libavcodec/vaapi_h264.c
+@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
+     H264SliceContext *sl = &h->slice_ctx[0];
+     int ret;
+ 
++    if (pic->nb_slices == 0) {
++        ret = AVERROR_INVALIDDATA;
++        goto finish;
++    }
++
+     ret = ff_vaapi_decode_issue(avctx, pic);
+     if (ret < 0)
+         goto finish;
diff --git a/srcpkgs/ffmpeg4/template b/srcpkgs/ffmpeg4/template
new file mode 100644
index 0000000000000..f2c851693d367
--- /dev/null
+++ b/srcpkgs/ffmpeg4/template
@@ -0,0 +1,240 @@
+# Template file for 'ffmpeg4'
+# audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
+pkgname=ffmpeg4
+version=4.4.4
+revision=1
+short_desc="Decoding, encoding and streaming software - ffmpeg4 libraries only"
+maintainer="Orphaned <orphan@voidlinux.org>"
+license="GPL-3.0-or-later"
+homepage="https://www.ffmpeg.org"
+changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
+distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
+checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+
+hostmakedepends="pkg-config perl"
+makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
+ libXext-devel libXvMC-devel libxcb-devel lame-devel libtheora-devel
+ libvorbis-devel x264-devel xvidcore-devel jack-devel SDL2-devel
+ libcdio-paranoia-devel librtmp-devel libmodplug-devel gnutls-devel
+ speex-devel celt-devel harfbuzz-devel libass-devel opus-devel ocl-icd-devel
+ libbs2b-devel libvidstab-devel vmaf-devel $(vopt_if pulseaudio pulseaudio-devel)
+ $(vopt_if vaapi libva-devel) $(vopt_if vdpau libvdpau-devel)
+ $(vopt_if x265 x265-devel) $(vopt_if v4l2 v4l-utils-devel)
+ $(vopt_if fdk_aac fdk-aac-devel) $(vopt_if vpx libvpx-devel)
+ $(vopt_if aom libaom-devel) $(vopt_if sndio sndio-devel)
+ $(vopt_if dav1d libdav1d-devel) $(vopt_if zimg zimg-devel)
+ $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
+ $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
+ $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if mfx 'libmfx libmfx-devel')
+ $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
+
+build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec mfx"
+build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
+
+desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
+desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
+desc_option_sofa="Enable support for AES SOFA"
+desc_option_webp="Enable support for WebP"
+
+case "$XBPS_TARGET_MACHINE" in
+	i686*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau nvenc nvdec"
+			;;
+	x86_64*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau mfx nvenc nvdec"
+			;;
+	ppc64*) build_options_default+=" vaapi vdpau";;
+	mips*) CFLAGS="-mnan=legacy";;
+esac
+
+if [ "$XBPS_TARGET_WORDSIZE" != "32" ]; then
+	build_options_default+=" svtav1"
+fi
+
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+fi
+
+_apply_patch() {
+	local args="$1" pname="$(basename $2)"
+
+	if [ ! -f ".${pname}_done" ]; then
+		patch -N $args -i $2
+		touch .${pname}_done
+	fi
+}
+
+post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64le*) ;;
+		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
+	esac
+
+	vsed -i libavfilter/vf_libvmaf.c -e 's!/usr/local/share/model/\(vmaf_v0.6.1\).pkl!/usr/share/vmaf/\1.json!'
+}
+
+do_configure() {
+	# Fix gcc on x86_64-musl only
+	if [ "$XBPS_TARGET_MACHINE" = "x86_64-musl" ]; then
+		vsed -i configure -e "s;_cflags_speed='-O3';_cflags_speed='-O2';"
+	fi
+
+	if [ "$CROSS_BUILD" ]; then
+		case "$XBPS_TARGET_MACHINE" in
+			arm*) _arch="arm";;
+			aarch64*) _arch="aarch64";;
+			mips*) _arch="mips";;
+			ppc64*) _arch="ppc64";;
+			ppc*) _arch="ppc";;
+			*) _arch="${XBPS_TARGET_MACHINE%%-musl}";;
+		esac
+
+		_args+=" --enable-cross-compile
+			--sysroot=$XBPS_CROSS_BASE
+			--cross-prefix=${XBPS_CROSS_TRIPLET}-
+			--target-os=linux --arch=${_arch}"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc|ppc-musl) _args+=" --disable-altivec";;
+	esac
+
+	if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+		_args+=" --extra-libs=-latomic"
+	fi
+
+	./configure --prefix=/usr --disable-debug --enable-gpl --enable-gnutls \
+		--disable-stripping \
+		--enable-libcdio --enable-version3 --enable-runtime-cpudetect \
+		--enable-libmp3lame --enable-libvorbis --enable-libxvid \
+		--enable-libx264 $(vopt_enable vpx libvpx) --enable-libtheora \
+		--enable-shared --enable-static --enable-libxcb \
+		$(vopt_enable pulseaudio libpulse) --enable-libfreetype --enable-libmodplug \
+		--enable-libspeex --enable-libcelt --enable-libass \
+		--enable-libopus --enable-librtmp --enable-libjack \
+		$(vopt_if fdk_aac '--enable-nonfree --enable-libfdk-aac') \
+		--disable-libopencore_amrnb --disable-libopencore_amrwb \
+		--disable-libopenjpeg \
+		--enable-postproc --enable-opencl ${_args} --enable-libvmaf ${_args} \
+		$(vopt_enable x265 libx265) \
+		$(vopt_enable v4l2 libv4l2) \
+		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
+		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		$(vopt_enable dav1d libdav1d) \
+		$(vopt_enable zimg libzimg) \
+		$(vopt_enable webp libwebp) \
+		$(vopt_enable sofa libmysofa) \
+		$(vopt_enable vulkan) \
+		$(vopt_enable drm libdrm) \
+		$(vopt_enable svtav1 libsvtav1) \
+		$(vopt_enable srt libsrt) \
+		$(vopt_enable rist librist) \
+		$(vopt_enable mfx libmfx) \
+		$(vopt_if nvenc '--enable-nvenc') \
+		$(vopt_if nvdec '--enable-nvdec')
+}
+
+do_build() {
+	make ${makejobs}
+	make doc/ff{mpeg,play}.1
+}
+
+do_install() {
+	make DESTDIR=${DESTDIR} install install-man
+	rm -rf ${DESTDIR}/usr/bin
+}
+
+libavcodec4_package() {
+	short_desc="FFmpeg codec library"
+	pkg_install() {
+		vmove "usr/lib/libavcodec.so.*"
+	}
+}
+
+libavdevice4_package() {
+	short_desc="FFmpeg device handling library"
+	pkg_install() {
+		vmove "usr/lib/libavdevice.so.*"
+	}
+}
+
+libavresample4_package() {
+	short_desc="FFmpeg audio resampling library"
+	pkg_install() {
+		vmove "usr/lib/libavresample.so.*"
+	}
+}
+
+libavformat4_package() {
+	short_desc="FFmpeg file format library"
+	pkg_install() {
+		vmove "usr/lib/libavformat.so.*"
+	}
+}
+
+libavutil4_package() {
+	short_desc="FFmpeg utility library"
+	pkg_install() {
+		vmove "usr/lib/libavutil.so.*"
+	}
+}
+
+libavfilter4_package() {
+	short_desc="FFmpeg audio/video filter library"
+	pkg_install() {
+		vmove "usr/lib/libavfilter.so.*"
+	}
+}
+
+libpostproc4_package() {
+	short_desc="FFmpeg video postprocessing library"
+	pkg_install() {
+		vmove "usr/lib/libpostproc.so.*"
+	}
+}
+
+libswscale4_package() {
+	short_desc="FFmpeg video scaling library"
+	pkg_install() {
+		vmove "usr/lib/libswscale.so.*"
+	}
+}
+
+libswresample4_package() {
+	short_desc="FFmpeg video resampling library"
+	pkg_install() {
+		vmove "usr/lib/libswresample.so.*"
+	}
+}
+
+ffmpeg4-devel_package() {
+	depends="
+		libavcodec4>=${version}_${revision}
+		libavdevice4>=${version}_${revision}
+		libavformat4>=${version}_${revision}
+		libavutil4>=${version}_${revision}
+		libavfilter4>=${version}_${revision}
+		libpostproc4>=${version}_${revision}
+		libswscale4>=${version}_${revision}
+		libswresample4>=${version}_${revision}
+		libavresample4>=${version}_${revision}"
+	short_desc+=" - development files"
+	conflicts="ffmpeg-devel"
+	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
+		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
+		nostrip_files="/usr/lib/libavfilter.a"
+	fi
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.a"
+		vmove "usr/lib/*.so"
+		vmove usr/share/ffmpeg/examples
+		vmove usr/share/man/man3
+	}
+}
diff --git a/srcpkgs/libavcodec4 b/srcpkgs/libavcodec4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavcodec4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavdevice4 b/srcpkgs/libavdevice4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavdevice4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavfilter4 b/srcpkgs/libavfilter4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavfilter4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavformat4 b/srcpkgs/libavformat4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavformat4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavresample4 b/srcpkgs/libavresample4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavutil4 b/srcpkgs/libavutil4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavutil4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libpostproc4 b/srcpkgs/libpostproc4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libpostproc4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswresample4 b/srcpkgs/libswresample4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libswresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswscale4 b/srcpkgs/libswscale4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libswscale4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file

From c21fa5cfcc99395cdf2f878fca7d4fcbd7c5274d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:04 -0400
Subject: [PATCH 003/113] opencv: update to 4.7.0.

---
 common/shlibs           | 104 ++++++++++++++++++++--------------------
 srcpkgs/opencv/template |   8 ++--
 2 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index a77346cce3e9a..ca0ee066215ea 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2136,58 +2136,58 @@ libcapstone.so.4 capstone-4.0_1
 libhavege.so.2 libhaveged-1.9.11_1
 libnih.so.1 libnih-1.0.3_1
 libnih-dbus.so.1 libnih-1.0.3_1
-libopencv_quality.so.406 libopencv-4.6.0_1
-libopencv_reg.so.406 libopencv-4.6.0_1
-libopencv_surface_matching.so.406 libopencv-4.6.0_1
-libopencv_xphoto.so.406 libopencv-4.6.0_1
-libopencv_freetype.so.406 libopencv-4.6.0_1
-libopencv_fuzzy.so.406 libopencv-4.6.0_1
-libopencv_hfs.so.406 libopencv-4.6.0_1
-libopencv_img_hash.so.406 libopencv-4.6.0_1
-libopencv_line_descriptor.so.406 libopencv-4.6.0_1
-libopencv_saliency.so.406 libopencv-4.6.0_1
-libopencv_structured_light.so.406 libopencv-4.6.0_1
-libopencv_aruco.so.406 libopencv-4.6.0_1
-libopencv_bgsegm.so.406 libopencv-4.6.0_1
-libopencv_bioinspired.so.406 libopencv-4.6.0_1
-libopencv_ccalib.so.406 libopencv-4.6.0_1
-libopencv_face.so.406 libopencv-4.6.0_1
-libopencv_tracking.so.406 libopencv-4.6.0_1
-libopencv_xfeatures2d.so.406 libopencv-4.6.0_1
-libopencv_optflow.so.406 libopencv-4.6.0_1
-libopencv_ximgproc.so.406 libopencv-4.6.0_1
-libopencv_plot.so.406 libopencv-4.6.0_1
-libopencv_text.so.406 libopencv-4.6.0_1
-libopencv_ml.so.406 libopencv-4.6.0_1
-libopencv_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn.so.406 libopencv-4.6.0_1
-libopencv_shape.so.406 libopencv-4.6.0_1
-libopencv_stitching.so.406 libopencv-4.6.0_1
-libopencv_photo.so.406 libopencv-4.6.0_1
-libopencv_video.so.406 libopencv-4.6.0_1
-libopencv_calib3d.so.406 libopencv-4.6.0_1
-libopencv_features2d.so.406 libopencv-4.6.0_1
-libopencv_flann.so.406 libopencv-4.6.0_1
-libopencv_highgui.so.406 libopencv-4.6.0_1
-libopencv_videoio.so.406 libopencv-4.6.0_1
-libopencv_imgcodecs.so.406 libopencv-4.6.0_1
-libopencv_imgproc.so.406 libopencv-4.6.0_1
-libopencv_core.so.406 libopencv-4.6.0_1
-libopencv_superres.so.406 libopencv-4.6.0_1
-libopencv_videostab.so.406 libopencv-4.6.0_1
-libopencv_gapi.so.406 libopencv-4.6.0_1
-libopencv_xobjdetect.so.406 libopencv-4.6.0_1
-libopencv_datasets.so.406 libopencv-4.6.0_1
-libopencv_dnn_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn_superres.so.406 libopencv-4.6.0_1
-libopencv_dpm.so.406 libopencv-4.6.0_1
-libopencv_phase_unwrapping.so.406 libopencv-4.6.0_1
-libopencv_stereo.so.406 libopencv-4.6.0_1
-libopencv_rapid.so.406 libopencv-4.6.0_1
-libopencv_intensity_transform.so.406 libopencv-4.6.0_1
-libopencv_alphamat.so.406 libopencv-4.6.0_1
-libopencv_barcode.so.406 libopencv-4.6.0_1
-libopencv_mcc.so.406 libopencv-4.6.0_1
+libopencv_quality.so.407 libopencv-4.7.0_1
+libopencv_reg.so.407 libopencv-4.7.0_1
+libopencv_surface_matching.so.407 libopencv-4.7.0_1
+libopencv_xphoto.so.407 libopencv-4.7.0_1
+libopencv_freetype.so.407 libopencv-4.7.0_1
+libopencv_fuzzy.so.407 libopencv-4.7.0_1
+libopencv_hfs.so.407 libopencv-4.7.0_1
+libopencv_img_hash.so.407 libopencv-4.7.0_1
+libopencv_line_descriptor.so.407 libopencv-4.7.0_1
+libopencv_saliency.so.407 libopencv-4.7.0_1
+libopencv_structured_light.so.407 libopencv-4.7.0_1
+libopencv_aruco.so.407 libopencv-4.7.0_1
+libopencv_bgsegm.so.407 libopencv-4.7.0_1
+libopencv_bioinspired.so.407 libopencv-4.7.0_1
+libopencv_ccalib.so.407 libopencv-4.7.0_1
+libopencv_face.so.407 libopencv-4.7.0_1
+libopencv_tracking.so.407 libopencv-4.7.0_1
+libopencv_xfeatures2d.so.407 libopencv-4.7.0_1
+libopencv_optflow.so.407 libopencv-4.7.0_1
+libopencv_ximgproc.so.407 libopencv-4.7.0_1
+libopencv_plot.so.407 libopencv-4.7.0_1
+libopencv_text.so.407 libopencv-4.7.0_1
+libopencv_ml.so.407 libopencv-4.7.0_1
+libopencv_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn.so.407 libopencv-4.7.0_1
+libopencv_shape.so.407 libopencv-4.7.0_1
+libopencv_stitching.so.407 libopencv-4.7.0_1
+libopencv_photo.so.407 libopencv-4.7.0_1
+libopencv_video.so.407 libopencv-4.7.0_1
+libopencv_calib3d.so.407 libopencv-4.7.0_1
+libopencv_features2d.so.407 libopencv-4.7.0_1
+libopencv_flann.so.407 libopencv-4.7.0_1
+libopencv_highgui.so.407 libopencv-4.7.0_1
+libopencv_videoio.so.407 libopencv-4.7.0_1
+libopencv_imgcodecs.so.407 libopencv-4.7.0_1
+libopencv_imgproc.so.407 libopencv-4.7.0_1
+libopencv_core.so.407 libopencv-4.7.0_1
+libopencv_superres.so.407 libopencv-4.7.0_1
+libopencv_videostab.so.407 libopencv-4.7.0_1
+libopencv_gapi.so.407 libopencv-4.7.0_1
+libopencv_xobjdetect.so.407 libopencv-4.7.0_1
+libopencv_datasets.so.407 libopencv-4.7.0_1
+libopencv_dnn_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn_superres.so.407 libopencv-4.7.0_1
+libopencv_dpm.so.407 libopencv-4.7.0_1
+libopencv_phase_unwrapping.so.407 libopencv-4.7.0_1
+libopencv_stereo.so.407 libopencv-4.7.0_1
+libopencv_rapid.so.407 libopencv-4.7.0_1
+libopencv_intensity_transform.so.407 libopencv-4.7.0_1
+libopencv_alphamat.so.407 libopencv-4.7.0_1
+libopencv_barcode.so.407 libopencv-4.7.0_1
+libopencv_mcc.so.407 libopencv-4.7.0_1
 libuniconf.so.4.6 wvstreams-4.6.1_20
 libwvbase.so.4.6 wvstreams-4.6.1_20
 libwvutils.so.4.6 wvstreams-4.6.1_20
diff --git a/srcpkgs/opencv/template b/srcpkgs/opencv/template
index 69c635b1ad2bc..41f3183f1582f 100644
--- a/srcpkgs/opencv/template
+++ b/srcpkgs/opencv/template
@@ -1,7 +1,7 @@
 # Template file for 'opencv'
 pkgname=opencv
-version=4.6.0
-revision=4
+version=4.7.0
+revision=1
 create_wrksrc=yes
 build_wrksrc=${pkgname}-${version}
 build_style=cmake
@@ -24,8 +24,8 @@ homepage="https://opencv.org"
 changelog="https://github.com/opencv/opencv/wiki/ChangeLog"
 distfiles="https://github.com/opencv/opencv/archive/${version}.tar.gz
  https://github.com/opencv/opencv_contrib/archive/${version}.tar.gz>contrib.tar.gz"
-checksum="1ec1cba65f9f20fe5a41fda1586e01c70ea0c9a6d7b67c9e13edf0cfe2239277
- 1777d5fd2b59029cf537e5fd6f8aa68d707075822f90bde683fcde086f85f7a7"
+checksum="8df0079cdbe179748a18d44731af62a245a45ebf5085223dc03133954c662973
+ 42df840cf9055e59d0e22c249cfb19f04743e1bdad113d31b1573d3934d62584"
 patch_args="-Np1 -d ${build_wrksrc}"
 # tests hang indenfinitely, even with test data included
 make_check=no

From aa7e79cf1c5b2c1b42fffb6a2a8e1b86b8dc8ffb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 004/113] actiona: revbump for opencv-4.7.0

---
 srcpkgs/actiona/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/actiona/template b/srcpkgs/actiona/template
index cf5f0b7a2ae61..0d899311e6df7 100644
--- a/srcpkgs/actiona/template
+++ b/srcpkgs/actiona/template
@@ -1,7 +1,7 @@
 # Template file for 'actiona'
 pkgname=actiona
 version=3.10.1
-revision=2
+revision=3
 build_style=qmake
 configure_args="PKGCONFIG_OPENCV=opencv4"
 hostmakedepends="pkg-config qt5-plugin-mysql qt5-qmake qt5-host-tools"

From f8e1187de23002e151d27529463a85125d0687f7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 005/113] qimgv: revbump for opencv-4.7.0

---
 srcpkgs/qimgv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qimgv/template b/srcpkgs/qimgv/template
index 7eb30db33992c..dd341dfe1bfce 100644
--- a/srcpkgs/qimgv/template
+++ b/srcpkgs/qimgv/template
@@ -1,7 +1,7 @@
 # Template file for 'qimgv'
 pkgname=qimgv
 version=1.0.2
-revision=2
+revision=3
 build_style=cmake
 configure_args="$(vopt_if video -DVIDEO_SUPPORT=ON -DVIDEO_SUPPORT=OFF)
  $(vopt_if scale -DOPENCV_SUPPORT=ON -DOPENCV_SUPPORT=OFF)

From 0bd06f376481bd204c4a0e7b6aa99451b9e5b262 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 006/113] retroshare: revbump for opencv-4.7.0

---
 srcpkgs/retroshare/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroshare/template b/srcpkgs/retroshare/template
index 8a0786c21a082..72023fa98b751 100644
--- a/srcpkgs/retroshare/template
+++ b/srcpkgs/retroshare/template
@@ -1,7 +1,7 @@
 # Template file for 'retroshare'
 pkgname=retroshare
 version=0.6.6
-revision=2
+revision=4
 build_style=qmake
 #XXX broadcast feature requires an ancient udp-discovery-cpp which either needs
 # to be fetched+patched (FTBFS) here or packaged :/

From 1709d5c7bcb63a4fde2d2fb0122e87455d89663c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 007/113] waifu2x-converter-cpp: revbump for opencv-4.7.0

---
 srcpkgs/waifu2x-converter-cpp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waifu2x-converter-cpp/template b/srcpkgs/waifu2x-converter-cpp/template
index 8c095d0d7baba..aa52d8c981a84 100644
--- a/srcpkgs/waifu2x-converter-cpp/template
+++ b/srcpkgs/waifu2x-converter-cpp/template
@@ -1,7 +1,7 @@
 # Template file for 'waifu2x-converter-cpp'
 pkgname=waifu2x-converter-cpp
 version=5.2.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DINSTALL_MODELS=ON"
 hostmakedepends="pkg-config"

From 2c99baeb300dd3e3336f8467b0d532a0649a8ed5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:38 -0400
Subject: [PATCH 008/113] vlc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/vlc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/vlc/template b/srcpkgs/vlc/template
index 210762b0a7e29..855ca52386626 100644
--- a/srcpkgs/vlc/template
+++ b/srcpkgs/vlc/template
@@ -1,7 +1,7 @@
 # Template file for 'vlc'
 pkgname=vlc
 version=3.0.18
-revision=3
+revision=4
 build_style=gnu-configure
 configure_args="--disable-gme --disable-libtar --enable-jack
  --enable-live555 --disable-fluidsynth --enable-dvdread
@@ -25,7 +25,7 @@ lib32disabled=yes
 hostmakedepends="automake libtool pkg-config flex gettext libgcrypt-devel
  live555-devel gettext-devel $(vopt_if lua lua52) $(vopt_if chromecast protobuf)"
 makedepends="
- avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg-devel freefont-ttf
+ avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg4-devel freefont-ttf
  gnutls-devel jack-devel liba52-devel libass-devel libbluray-devel
  libcdio-devel libdca-devel libdvbpsi-devel libdvdnav-devel libmad-devel
  libmatroska-devel libmodplug-devel libmpcdec-devel libmpeg2-devel

From 93478e73074399dcb0ca9018f03d9417d8404e64 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:55 -0400
Subject: [PATCH 009/113] osg: revbump for ffmpeg4-4.4.3

---
 srcpkgs/osg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/osg/template b/srcpkgs/osg/template
index a9ebbd287933b..755793f7e11bf 100644
--- a/srcpkgs/osg/template
+++ b/srcpkgs/osg/template
@@ -8,7 +8,7 @@ build_helper="qemu"
 configure_args="-DLIB_POSTFIX="
 hostmakedepends="pkg-config xrandr"
 makedepends="MesaLib-devel gtkglext-devel libcurl-devel giflib-devel librsvg-devel
- jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg-devel xine-lib-devel
+ jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg4-devel xine-lib-devel
  SDL2-devel gst-plugins-base1-devel
  $(vopt_if openexr libopenexr-devel)
  $(vopt_if poppler poppler-glib-devel)

From 6c895e979eb9240b569fc8501450e368fbc7283b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:13 -0400
Subject: [PATCH 010/113] xine-lib: revbump for ffmpeg4-4.4.3

---
 srcpkgs/xine-lib/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/xine-lib/template b/srcpkgs/xine-lib/template
index f713eff49b07c..ed6194c17d11e 100644
--- a/srcpkgs/xine-lib/template
+++ b/srcpkgs/xine-lib/template
@@ -1,6 +1,6 @@
 # Template file for 'xine-lib'
 pkgname=xine-lib
-version=1.2.12
+version=1.2.13
 revision=1
 build_style=gnu-configure
 configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
@@ -8,7 +8,7 @@ configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
 hostmakedepends="automake gettext-devel libtool pkg-config perl"
 makedepends="
  zlib-devel alsa-lib-devel libxcb-devel libSM-devel libXext-devel libXv-devel
- libXvMC-devel liba52-devel libmad-devel ffmpeg-devel pulseaudio-devel
+ libXvMC-devel liba52-devel libmad-devel ffmpeg4-devel pulseaudio-devel
  jack-devel samba-devel libflac-devel libmodplug-devel libmpcdec-devel
  speex-devel libtheora-devel libvorbis-devel libdca-devel faad2-devel
  libcdio-devel libbluray-devel aalib-devel libcaca-devel libXinerama-devel
@@ -19,7 +19,7 @@ license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="http://www.xine-project.org"
 changelog="https://sourceforge.net/projects/xine/files/xine-lib/${version}/README.txt/view"
 distfiles="${SOURCEFORGE_SITE}/xine/${pkgname}-${version}.tar.xz"
-checksum=d606270468e1540c2a89c0d7f5fdf11e17ecc0c2698cc0bcb1065ff26abee098
+checksum=5f10d6d718a4a51c17ed1b32b031d4f9b80b061e8276535b2be31e5ac4b75e6f
 
 case "$XBPS_TARGET_MACHINE" in
 	i686-musl)

From 8da2a39d7e8f30d90c85864cbf1109a477f23584 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 011/113] QMPlay2: revbump for ffmpeg-6.0

---
 srcpkgs/QMPlay2/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/QMPlay2/template b/srcpkgs/QMPlay2/template
index 850df9d418b90..8d2ce7a76156c 100644
--- a/srcpkgs/QMPlay2/template
+++ b/srcpkgs/QMPlay2/template
@@ -1,7 +1,7 @@
 # Template file for 'QMPlay2'
 pkgname=QMPlay2
 version=23.06.17
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools"
 makedepends="alsa-lib-devel ffmpeg-devel libass-devel libcdio-devel libgme-devel

From 7d283905b6f4868e8aa590b84b1d495fcfe1cdf1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 012/113] alsa-plugins: revbump for ffmpeg-6.0

---
 srcpkgs/alsa-plugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/alsa-plugins/template b/srcpkgs/alsa-plugins/template
index 0bfa6d9fd2643..a5708a7d82a8f 100644
--- a/srcpkgs/alsa-plugins/template
+++ b/srcpkgs/alsa-plugins/template
@@ -1,7 +1,7 @@
 # Template file for 'alsa-plugins'
 pkgname=alsa-plugins
 version=1.2.7.1
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--disable-maemo-plugin"
 hostmakedepends="pkg-config"

From 4143e8ba69bb63b593ddba71823d8791d98c1b34 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 013/113] arcan: revbump for ffmpeg-6.0

---
 srcpkgs/arcan/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/arcan/template b/srcpkgs/arcan/template
index 7be9652eccf3c..ccc7df11ceac6 100644
--- a/srcpkgs/arcan/template
+++ b/srcpkgs/arcan/template
@@ -2,7 +2,7 @@
 # !! keep synced with: acfgfs aclip aloadimage
 pkgname=arcan
 version=0.6.2.1
-revision=1
+revision=2
 create_wrksrc=yes
 build_wrksrc=arcan/src
 build_style=cmake

From 0ff269021a917cb99fe123b2e729e2549238767a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 014/113] attract: revbump for ffmpeg4-4.4.3

---
 srcpkgs/attract/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/attract/template b/srcpkgs/attract/template
index 26144e931a3c7..e760bf0d18aec 100644
--- a/srcpkgs/attract/template
+++ b/srcpkgs/attract/template
@@ -1,12 +1,12 @@
 # Template file for 'attract'
 pkgname=attract
 version=2.6.2
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="VERBOSE=1"
 make_use_env=yes
 hostmakedepends="pkg-config"
-makedepends="SFML-devel ffmpeg-devel fontconfig-devel glu-devel libarchive-devel
+makedepends="SFML-devel ffmpeg4-devel fontconfig-devel glu-devel libarchive-devel
  libcurl-devel libjpeg-turbo-devel xine-lib rapidjson libXrandr-devel"
 depends="git"
 short_desc="Attract-Mode is a graphical frontend for emulators"

From 26492c79a0966e80682cba1970eb12030526db60 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 015/113] aubio: revbump for ffmpeg-6.0

---
 srcpkgs/aubio/patches/ffmpeg5.patch | 25 +++++++++++++++++++++++++
 srcpkgs/aubio/template              |  2 +-
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/aubio/patches/ffmpeg5.patch

diff --git a/srcpkgs/aubio/patches/ffmpeg5.patch b/srcpkgs/aubio/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..aace41a6e6d9a
--- /dev/null
+++ b/srcpkgs/aubio/patches/ffmpeg5.patch
@@ -0,0 +1,25 @@
+From 8a05420e5dd8c7b8b2447f82dc919765876511b3 Mon Sep 17 00:00:00 2001
+From: Paul Brossier <piem@piem.org>
+Date: Tue, 25 Jan 2022 18:30:27 +0100
+Subject: [PATCH] [source_avcodec] define FF_API_LAVF_AVCTX for libavcodec >
+ 59, thx @berolinux (closes gh-353)
+
+---
+ src/io/source_avcodec.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/io/source_avcodec.c b/src/io/source_avcodec.c
+index e0ae93b5..1421bd9a 100644
+--- a/src/io/source_avcodec.c
++++ b/src/io/source_avcodec.c
+@@ -68,6 +68,10 @@
+ #define AUBIO_AVCODEC_MAX_BUFFER_SIZE AV_INPUT_BUFFER_MIN_SIZE
+ #endif
+ 
++#if LIBAVCODEC_VERSION_MAJOR >= 59
++#define FF_API_LAVF_AVCTX 1
++#endif
++
+ struct _aubio_source_avcodec_t {
+   uint_t hop_size;
+   uint_t samplerate;
diff --git a/srcpkgs/aubio/template b/srcpkgs/aubio/template
index ad1c4b2569917..7d875cc02541a 100644
--- a/srcpkgs/aubio/template
+++ b/srcpkgs/aubio/template
@@ -1,7 +1,7 @@
 # Template file for 'aubio'
 pkgname=aubio
 version=0.4.9
-revision=1
+revision=2
 build_style=waf3
 # XXX lash, pure and swig support.
 hostmakedepends="pkg-config txt2man"

From a9aca6fe5272b0025e3c1dba8a8ec251bdd3483d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 016/113] audacious-plugins: revbump for ffmpeg-6.0

---
 .../audacious-plugins/patches/ffmpeg5.patch   | 43 +++++++++++++++++++
 srcpkgs/audacious-plugins/template            |  2 +-
 2 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/audacious-plugins/patches/ffmpeg5.patch

diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg5.patch b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..4e5e34099d71c
--- /dev/null
+++ b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
@@ -0,0 +1,43 @@
+commit 298aa371c56c2f52c25a33d9bdec4918b11cebdc
+Author: tibequadorian <tibequadorian@posteo.de>
+Date:   Sat Mar 19 18:40:12 2022 +0100
+
+    audacious-plugins: rebuild against ffmpeg-5.0
+
+diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+new file mode 100644
+index 0000000000..617c11215b
+--- /dev/null
++++ b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+@@ -0,0 +1,31 @@
++From f60beb400eeb1e4778bbfd738bc4a4ccef3de539 Mon Sep 17 00:00:00 2001
++From: John Lindgren <john@jlindgren.net>
++Date: Sat, 5 Mar 2022 12:05:34 -0500
++Subject: [PATCH] Fix build with FFmpeg 5.0
++
++---
++ src/ffaudio/ffaudio-core.cc | 4 ++--
++ 1 file changed, 2 insertions(+), 2 deletions(-)
++
++diff --git a/src/ffaudio/ffaudio-core.cc b/src/ffaudio/ffaudio-core.cc
++index 16dc63e3a..a2b95fd6c 100644
++--- a/src/ffaudio/ffaudio-core.cc
+++++ b/src/ffaudio/ffaudio-core.cc
++@@ -274,7 +274,7 @@ static AVInputFormat * get_format_by_content (const char * name, VFSFile & file)
++         AVProbeData d = {name, buf, filled};
++         score = target;
++ 
++-        f = av_probe_input_format2 (& d, true, & score);
+++        f = (AVInputFormat *) av_probe_input_format2 (& d, true, & score);
++         if (f)
++             break;
++ 
++@@ -347,7 +347,7 @@ static bool find_codec (AVFormatContext * c, CodecInfo * cinfo)
++ #endif
++         if (stream && stream->codecpar && stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
++         {
++-            AVCodec * codec = avcodec_find_decoder (stream->codecpar->codec_id);
+++            AVCodec * codec = (AVCodec *) avcodec_find_decoder (stream->codecpar->codec_id);
++ 
++             if (codec)
++             {
diff --git a/srcpkgs/audacious-plugins/template b/srcpkgs/audacious-plugins/template
index 88cbc1671fc6a..beebfae59ed44 100644
--- a/srcpkgs/audacious-plugins/template
+++ b/srcpkgs/audacious-plugins/template
@@ -2,7 +2,7 @@
 #Keep in sync with audacious!
 pkgname=audacious-plugins
 version=4.3.1
-revision=1
+revision=2
 build_style=meson
 configure_args="$(vopt_bool gtk3 gtk) $(vopt_bool gtk3)
  $(vopt_bool qt) $(vopt_bool qt qt6)"

From e5b18f5feba5da262ae8d4f661116db3636660b4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 017/113] audacity: revbump for ffmpeg4-4.4.3

---
 srcpkgs/audacity/template | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/audacity/template b/srcpkgs/audacity/template
index d509c0a894077..11e20255685b0 100644
--- a/srcpkgs/audacity/template
+++ b/srcpkgs/audacity/template
@@ -1,7 +1,7 @@
 # Template file for 'audacity'
 pkgname=audacity
 version=2.4.1
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--with-ffmpeg=system --with-libsndfile=system --with-expat=system
  --with-libsoxr=system --with-lame=system --with-lv2=system ac_cv_path_WX_CONFIG=wx-config-gtk3"
@@ -9,7 +9,7 @@ hostmakedepends="pkg-config cmake gettext libtool m4 which"
 makedepends="jack-devel wxWidgets-gtk3-devel gtk+3-devel
  libmad-devel soundtouch-devel libsoxr-devel
  vamp-plugin-sdk-devel lame-devel libid3tag-devel libflac-devel
- ffmpeg-devel twolame-devel serd-devel lv2 lilv-devel suil-devel"
+ ffmpeg4-devel twolame-devel serd-devel lv2 lilv-devel suil-devel"
 depends="desktop-file-utils hicolor-icon-theme"
 short_desc="Graphical cross-platform audio editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
@@ -33,5 +33,4 @@ post_install() {
 	vcopy plug-ins /usr/share/audacity
 
 	rm ${DESTDIR}/usr/share/doc/audacity/LICENSE.txt
-	vlicense LICENSE.txt LICENSE
 }

From 86cd5bbe4a9c918d9e61ea0c5597de2ed3cd427f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 018/113] avidemux: revbump for ffmpeg-6.0

---
 srcpkgs/avidemux/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/avidemux/template b/srcpkgs/avidemux/template
index 253a0243e2259..557285982d2b8 100644
--- a/srcpkgs/avidemux/template
+++ b/srcpkgs/avidemux/template
@@ -1,7 +1,7 @@
 # Template file for 'avidemux'
 pkgname=avidemux
 version=2.8.0
-revision=2
+revision=3
 # Can't be compiled for aarch64, arm* or mips*
 archs="x86_64* i686*"
 hostmakedepends="cmake pkg-config qt5-host-tools qt5-devel tar yasm"

From 0845275459e6e787a842ab0d4ae4dfea3e35f772 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 019/113] baresip: revbump for ffmpeg-6.0

---
 srcpkgs/baresip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/baresip/template b/srcpkgs/baresip/template
index f1bd1817048b5..b21e22334316e 100644
--- a/srcpkgs/baresip/template
+++ b/srcpkgs/baresip/template
@@ -1,7 +1,7 @@
 # Template file for 'baresip'
 pkgname=baresip
 version=2.10.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config glib-devel"
 makedepends="libgsm-devel libpng-devel openssl-devel libsndfile-devel

From af8dec1a7aec2fdcd246dda59dc3f8fde02e5dcc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 020/113] blender: revbump for ffmpeg-6.0

---
 srcpkgs/blender/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index 7a710ac0df495..0f72876d4d704 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -9,8 +9,8 @@ configure_args="-DWITH_INSTALL_PORTABLE=OFF -DWITH_PYTHON_INSTALL=OFF
  -DWITH_JACK=ON -DWITH_CODEC_FFMPEG=ON -DWITH_CODEC_SNDFILE=ON -DWITH_OPENMP=ON
  -DWITH_FFTW3=ON -DWITH_MOD_OCEANSIM=ON -DWITH_CYCLES_EMBREE=OFF -DWITH_OPENCOLORIO=ON
  -DWITH_IMAGE_OPENEXR=ON -DWITH_IMAGE_OPENJPEG=ON -DWITH_OPENSUBDIV=ON
- -DWITH_OPENCOLLADA=ON -DWITH_SYSTEM_GLEW=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
- -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_LIBDECOR=ON
+ -DWITH_OPENCOLLADA=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
+ -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_WAYLAND_LIBDECOR=ON
  -DWITH_BUILDINFO=OFF -DPYTHON_VERSION=${py3_ver} -DPYTHON_LIBPATH=/usr/lib
  -DPYTHON_LIBRARY=python${py3_ver}${py3_abiver} -DPYTHON_INCLUDE_DIRS=/${py3_inc}
  -DWITH_SYSTEM_LZO=ON -DWITH_SYSTEM_EIGEN3=ON -DWITH_SYSTEM_FREETYPE=ON"

From bf7fd88759e8c50e6939285af27c1d8ff189c738 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 021/113] cantata: revbump for ffmpeg-6.0

---
 srcpkgs/cantata/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cantata/template b/srcpkgs/cantata/template
index 4b417d80d5c2d..8a90aaa4c07a2 100644
--- a/srcpkgs/cantata/template
+++ b/srcpkgs/cantata/template
@@ -1,7 +1,7 @@
 # Template file for 'cantata'
 pkgname=cantata
 version=2.5.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools qt5-tools"
 makedepends="qt5-devel qt5-tools-devel qt5-svg-devel qt5-xmlpatterns-devel

From 3c6734d7f347d2a8b1e4b50cc0e1e37de37d2c37 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 022/113] ccextractor: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ccextractor/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/ccextractor/template b/srcpkgs/ccextractor/template
index 9abcd82852b27..6eccad5885af9 100644
--- a/srcpkgs/ccextractor/template
+++ b/srcpkgs/ccextractor/template
@@ -1,12 +1,12 @@
 # Template file for 'ccextractor'
 pkgname=ccextractor
 version=0.93
-revision=1
+revision=2
 build_wrksrc="linux"
 build_style=gnu-configure
 configure_args="--enable-ocr --enable-hardsubx"
 hostmakedepends="automake pkg-config"
-makedepends="leptonica-devel tesseract-ocr-devel ffmpeg-devel"
+makedepends="leptonica-devel tesseract-ocr-devel ffmpeg4-devel"
 short_desc="Extract subtitles from video streams"
 maintainer="newbluemoon <blaumolch@mailbox.org>"
 license="GPL-2.0-or-later"

From 49a0cccbdd74562869c218c595b2f4e9884063e4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 023/113] chromaprint: revbump for ffmpeg-6.0

---
 srcpkgs/chromaprint/patches/ffmpeg5.patch | 569 ++++++++++++++++++++++
 srcpkgs/chromaprint/template              |   2 +-
 2 files changed, 570 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromaprint/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromaprint/patches/ffmpeg5.patch b/srcpkgs/chromaprint/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..a9fd307a23c8a
--- /dev/null
+++ b/srcpkgs/chromaprint/patches/ffmpeg5.patch
@@ -0,0 +1,569 @@
+From 8ccad6937177b1b92e40ab8f4447ea27bac009a7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= <lalinsky@gmail.com>
+Date: Fri, 4 Nov 2022 21:47:38 +0100
+Subject: [PATCH] Use FFmpeg 5.x (#120)
+
+* Use FFmpeg 5.1.2 for CI builds
+
+* Build on Ubuntu 20.04
+
+* Upgrade code to FFmpeg 5.x APIs
+
+* Only set FFmpeg include dirs if building tools
+
+* No longer needed
+
+* Use ubuntu 20.04
+---
+ .github/workflows/build.yml                   |   6 +-
+ CMakeLists.txt                                |  16 --
+ package/build.sh                              |   4 +-
+ src/audio/ffmpeg_audio_processor.h            |   2 -
+ src/audio/ffmpeg_audio_processor_avresample.h |  72 -------
+ src/audio/ffmpeg_audio_processor_swresample.h |  18 +-
+ src/audio/ffmpeg_audio_reader.h               | 197 +++++++++---------
+ tests/CMakeLists.txt                          |   6 +
+ 8 files changed, 122 insertions(+), 199 deletions(-)
+ delete mode 100644 src/audio/ffmpeg_audio_processor_avresample.h
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index f8d6a32..4da2405 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -84,9 +84,6 @@ find_package(FFmpeg)
+ if(FFMPEG_LIBRARIES)
+ 	cmake_push_check_state(RESET)
+ 	set(CMAKE_REQUIRED_LIBRARIES ${FFMPEG_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -lm)
+-	check_function_exists(av_packet_unref HAVE_AV_PACKET_UNREF)
+-	check_function_exists(av_frame_alloc HAVE_AV_FRAME_ALLOC)
+-	check_function_exists(av_frame_free HAVE_AV_FRAME_FREE)
+ 	cmake_pop_check_state()
+ endif()
+
+@@ -163,14 +160,11 @@ message(STATUS "Using ${FFT_LIB} for FFT calculations")
+ if(NOT AUDIO_PROCESSOR_LIB)
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+ 		set(AUDIO_PROCESSOR_LIB "swresample")
+-	elseif(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(AUDIO_PROCESSOR_LIB "avresample")
+ 	endif()
+ endif()
+
+ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE OFF)
+ 		set(USE_SWRESAMPLE ON)
+ 		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBSWRESAMPLE_LIBRARIES})
+ 		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBSWRESAMPLE_INCLUDE_DIRS})
+@@ -178,16 +172,6 @@ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+ 	endif()
+ 	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+-elseif(AUDIO_PROCESSOR_LIB STREQUAL "avresample")
+-	if(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE ON)
+-		set(USE_SWRESAMPLE OFF)
+-		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBAVRESAMPLE_LIBRARIES})
+-		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBAVRESAMPLE_INCLUDE_DIRS})
+-	else()
+-		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+-	endif()
+-	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+ else()
+ 	message(STATUS "Building without audio conversion support, please install FFmpeg with libswresample")
+ endif()
+diff --git a/package/build.sh b/package/build.sh
+index da631ae..b41d36e 100755
+--- a/package/build.sh
++++ b/package/build.sh
+@@ -7,8 +7,8 @@ set -eux
+
+ BASE_DIR=$(cd $(dirname $0)/.. && pwd)
+
+-FFMPEG_VERSION=4.4.1
+-FFMPEG_BUILD_TAG=v4.4.1-1
++FFMPEG_VERSION=5.1.2
++FFMPEG_BUILD_TAG=v${FFMPEG_VERSION}-1
+
+ TMP_BUILD_DIR=$BASE_DIR/$(mktemp -d build.XXXXXXXX)
+ trap 'rm -rf $TMP_BUILD_DIR' EXIT
+diff --git a/src/audio/ffmpeg_audio_processor.h b/src/audio/ffmpeg_audio_processor.h
+index 7628fc7..39f4f6d 100644
+--- a/src/audio/ffmpeg_audio_processor.h
++++ b/src/audio/ffmpeg_audio_processor.h
+@@ -10,8 +10,6 @@
+
+ #if defined(USE_SWRESAMPLE)
+ #include "audio/ffmpeg_audio_processor_swresample.h"
+-#elif defined(USE_AVRESAMPLE)
+-#include "audio/ffmpeg_audio_processor_avresample.h"
+ #else
+ #error "no audio processing library"
+ #endif
+diff --git a/src/audio/ffmpeg_audio_processor_avresample.h b/src/audio/ffmpeg_audio_processor_avresample.h
+deleted file mode 100644
+index bd85f92..0000000
+--- a/src/audio/ffmpeg_audio_processor_avresample.h
++++ /dev/null
+@@ -1,72 +0,0 @@
+-// Copyright (C) 2016  Lukas Lalinsky
+-// Distributed under the MIT license, see the LICENSE file for details.
+-
+-#ifndef CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-#define CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-
+-extern "C" {
+-#include <libavresample/avresample.h>
+-}
+-
+-namespace chromaprint {
+-
+-class FFmpegAudioProcessor {
+-public:
+-	FFmpegAudioProcessor() {
+-		m_resample_ctx = avresample_alloc_context();
+-	}
+-
+-	~FFmpegAudioProcessor() {
+-		avresample_free(&m_resample_ctx);
+-	}
+-
+-	void SetCompatibleMode() {
+-		av_opt_set_int(m_resample_ctx, "filter_size", 16, 0);
+-		av_opt_set_int(m_resample_ctx, "phase_shift", 8, 0);
+-		av_opt_set_int(m_resample_ctx, "linear_interp", 1, 0);
+-		av_opt_set_double(m_resample_ctx, "cutoff", 0.8, 0);
+-	}
+-
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "in_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_rate", sample_rate, 0);
+-	}
+-
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "out_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_rate, 0);
+-	}
+-
+-	int Init() {
+-		return avresample_open(m_resample_ctx);
+-	}
+-
+-	int Convert(uint8_t **out, int out_count, const uint8_t **in, int in_count) {
+-		return avresample_convert(m_resample_ctx, out, 0, out_count, (uint8_t **) in, 0, in_count);
+-	}
+-
+-	int Flush(uint8_t **out, int out_count) {
+-		return avresample_read(m_resample_ctx, out, out_count);
+-	}
+-
+-private:
+-	AVAudioResampleContext *m_resample_ctx = nullptr;
+-};
+-
+-}; // namespace chromaprint
+-
+-#endif
+diff --git a/src/audio/ffmpeg_audio_processor_swresample.h b/src/audio/ffmpeg_audio_processor_swresample.h
+index b86266b..b1d4bea 100644
+--- a/src/audio/ffmpeg_audio_processor_swresample.h
++++ b/src/audio/ffmpeg_audio_processor_swresample.h
+@@ -28,30 +28,28 @@ public:
+ 		av_opt_set_double(m_swr_ctx, "cutoff", 0.8, 0);
+ 	}
+
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "icl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "ich", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetInputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "in_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "isf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "in_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "isr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "in_sample_rate", sample_rate, 0);
+ 	}
+
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "ocl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "och", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetOutputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "out_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "osf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "out_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "osr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "out_sample_rate", sample_rate, 0);
+ 	}
+
+ 	int Init() {
+diff --git a/src/audio/ffmpeg_audio_reader.h b/src/audio/ffmpeg_audio_reader.h
+index 5550164..1c6b346 100644
+--- a/src/audio/ffmpeg_audio_reader.h
++++ b/src/audio/ffmpeg_audio_reader.h
+@@ -62,7 +62,7 @@ public:
+ 	bool Read(const int16_t **data, size_t *size);
+
+ 	bool IsOpen() const { return m_opened; }
+-	bool IsFinished() const { return m_finished && !m_got_frame; }
++	bool IsFinished() const { return !m_has_more_packets && !m_has_more_frames; }
+
+ 	std::string GetError() const { return m_error; }
+ 	int GetErrorCode() const { return m_error_code; }
+@@ -74,20 +74,19 @@ private:
+ 	uint8_t *m_convert_buffer[1] = { nullptr };
+ 	int m_convert_buffer_nb_samples = 0;
+
+-	AVInputFormat *m_input_fmt = nullptr;
++	const AVInputFormat *m_input_fmt = nullptr;
+ 	AVDictionary *m_input_opts = nullptr;
+
+ 	AVFormatContext *m_format_ctx = nullptr;
+ 	AVCodecContext *m_codec_ctx = nullptr;
+-	AVFrame *m_frame = nullptr;
+ 	int m_stream_index = -1;
+ 	std::string m_error;
+ 	int m_error_code = 0;
+-	bool m_finished = false;
+ 	bool m_opened = false;
+-	int m_got_frame = 0;
+-	AVPacket m_packet;
+-	AVPacket m_packet0;
++	bool m_has_more_packets = true;
++	bool m_has_more_frames = true;
++	AVPacket *m_packet = nullptr;
++	AVFrame *m_frame = nullptr;
+
+ 	int m_output_sample_rate = 0;
+ 	int m_output_channels = 0;
+@@ -98,19 +97,12 @@ private:
+
+ inline FFmpegAudioReader::FFmpegAudioReader() {
+ 	av_log_set_level(AV_LOG_QUIET);
+-
+-	av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
+ }
+
+ inline FFmpegAudioReader::~FFmpegAudioReader() {
+ 	Close();
+ 	av_dict_free(&m_input_opts);
+ 	av_freep(&m_convert_buffer[0]);
+-	av_packet_unref(&m_packet0);
+ }
+
+ inline bool FFmpegAudioReader::SetInputFormat(const char *name) {
+@@ -135,11 +127,10 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ 	Close();
+
+-    av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
++	m_packet = av_packet_alloc();
++	if (!m_packet) {
++		return false;
++	}
+
+ 	ret = avformat_open_input(&m_format_ctx, file_name.c_str(), m_input_fmt, &m_input_opts);
+ 	if (ret < 0) {
+@@ -153,26 +144,31 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		return false;
+ 	}
+
+-	AVCodec *codec;
++	const AVCodec *codec;
+ 	ret = av_find_best_stream(m_format_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &codec, 0);
+ 	if (ret < 0) {
+ 		SetError("Could not find any audio stream in the file", ret);
+ 		return false;
+ 	}
+ 	m_stream_index = ret;
++	auto stream = m_format_ctx->streams[m_stream_index];
+
+-	m_codec_ctx = m_format_ctx->streams[m_stream_index]->codec;
++	m_codec_ctx = avcodec_alloc_context3(codec);
+ 	m_codec_ctx->request_sample_fmt = AV_SAMPLE_FMT_S16;
+
++	ret = avcodec_parameters_to_context(m_codec_ctx, stream->codecpar);
++	if (ret < 0) {
++		SetError("Could not copy the stream parameters", ret);
++		return false;
++	}
++
+ 	ret = avcodec_open2(m_codec_ctx, codec, nullptr);
+ 	if (ret < 0) {
+ 		SetError("Could not open the codec", ret);
+ 		return false;
+ 	}
+
+-	if (!m_codec_ctx->channel_layout) {
+-		m_codec_ctx->channel_layout = av_get_default_channel_layout(m_codec_ctx->channels);
+-	}
++	av_dump_format(m_format_ctx, 0, "foo", 0);
+
+ 	m_frame = av_frame_alloc();
+ 	if (!m_frame) {
+@@ -183,19 +179,23 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		m_output_sample_rate = m_codec_ctx->sample_rate;
+ 	}
+
+-	if (!m_output_channels) {
+-		m_output_channels = m_codec_ctx->channels;
++	AVChannelLayout output_channel_layout;
++	if (m_output_channels) {
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
++	} else {
++		m_output_channels = m_codec_ctx->ch_layout.nb_channels;
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
+ 	}
+
+-	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
++	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->ch_layout.nb_channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
+ 		m_converter.reset(new FFmpegAudioProcessor());
+ 		m_converter->SetCompatibleMode();
+ 		m_converter->SetInputSampleFormat(m_codec_ctx->sample_fmt);
+ 		m_converter->SetInputSampleRate(m_codec_ctx->sample_rate);
+-		m_converter->SetInputChannelLayout(m_codec_ctx->channel_layout);
++		m_converter->SetInputChannelLayout(&(m_codec_ctx->ch_layout));
+ 		m_converter->SetOutputSampleFormat(AV_SAMPLE_FMT_S16);
+ 		m_converter->SetOutputSampleRate(m_output_sample_rate);
+-		m_converter->SetOutputChannelLayout(av_get_default_channel_layout(m_output_channels));
++		m_converter->SetOutputChannelLayout(&output_channel_layout);
+ 		auto ret = m_converter->Init();
+ 		if (ret != 0) {
+ 			SetError("Could not create an audio converter instance", ret);
+@@ -203,10 +203,11 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		}
+ 	}
+
++	av_channel_layout_uninit(&output_channel_layout);
++
+ 	m_opened = true;
+-	m_finished = false;
+-	m_got_frame = 0;
+-	m_nb_packets = 0;
++	m_has_more_packets = true;
++	m_has_more_frames = true;
+ 	m_decode_error = 0;
+
+ 	return true;
+@@ -214,6 +215,7 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ inline void FFmpegAudioReader::Close() {
+ 	av_frame_free(&m_frame);
++	av_packet_free(&m_packet);
+
+ 	m_stream_index = -1;
+
+@@ -252,91 +254,98 @@ inline bool FFmpegAudioReader::Read(const int16_t **data, size_t *size) {
+ 		return false;
+ 	}
+
++	*data = nullptr;
++	*size = 0;
++
+ 	int ret;
++	bool needs_packet = false;
+ 	while (true) {
+-		while (m_packet.size <= 0) {
+-			av_packet_unref(&m_packet0);
+-			av_init_packet(&m_packet);
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			ret = av_read_frame(m_format_ctx, &m_packet);
++		while (needs_packet && m_packet->size == 0) {
++			ret = av_read_frame(m_format_ctx, m_packet);
+ 			if (ret < 0) {
+ 				if (ret == AVERROR_EOF) {
+-					m_finished = true;
++					needs_packet = false;
++					m_has_more_packets = false;
+ 					break;
+-				} else {
++				}
++				SetError("Error reading from the audio source", ret);
++				return false;
++			}
++			if (m_packet->stream_index == m_stream_index) {
++				needs_packet = false;
++			} else {
++				av_packet_unref(m_packet);
++			}
++		}
++
++		if (m_packet->size != 0) {
++			ret = avcodec_send_packet(m_codec_ctx, m_packet);
++			if (ret < 0) {
++				if (ret != AVERROR(EAGAIN)) {
+ 					SetError("Error reading from the audio source", ret);
+ 					return false;
+ 				}
+-			}
+-			m_packet0 = m_packet;
+-			if (m_packet.stream_index != m_stream_index) {
+-				m_packet.data = nullptr;
+-				m_packet.size = 0;
+ 			} else {
+-				m_nb_packets++;
++				av_packet_unref(m_packet);
+ 			}
+ 		}
+
+-		ret = avcodec_decode_audio4(m_codec_ctx, m_frame, &m_got_frame, &m_packet);
++		ret = avcodec_receive_frame(m_codec_ctx, m_frame);
+ 		if (ret < 0) {
+-			if (m_decode_error) {
+-				SetError("Error decoding audio frame", m_decode_error);
+-				return false;
++			if (ret == AVERROR_EOF) {
++				m_has_more_frames = false;
++			} else if (ret == AVERROR(EAGAIN)) {
++				if (m_has_more_packets) {
++					needs_packet = true;
++					continue;
++				} else {
++					m_has_more_frames = false;
++				}
+ 			}
+-			m_decode_error = ret;
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			continue;
++			SetError("Error decoding the audio source", ret);
++			return false;
+ 		}
+
+-		break;
+-	}
+-
+-	m_decode_error = 0;
+-
+-	const int decoded = std::min(ret, m_packet.size);
+-	m_packet.data += decoded;
+-	m_packet.size -= decoded;
+-
+-	if (m_got_frame) {
+-		if (m_converter) {
+-			if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
+-				int linsize;
+-				av_freep(&m_convert_buffer[0]);
+-				m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
+-				ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
+-				if (ret < 0) {
+-					SetError("Couldn't allocate audio converter buffer", ret);
++		if (m_frame->nb_samples > 0) {
++			if (m_converter) {
++				if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
++					int linsize;
++					av_freep(&m_convert_buffer[0]);
++					m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
++					ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->ch_layout.nb_channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
++					if (ret < 0) {
++						SetError("Couldn't allocate audio converter buffer", ret);
++						return false;
++					}
++				}
++				auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
++				if (nb_samples < 0) {
++					SetError("Couldn't convert audio", ret);
+ 					return false;
+ 				}
+-			}
+-			auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			}
+-			*data = (const int16_t *) m_convert_buffer[0];
+-			*size = nb_samples;
+-		} else {
+-			*data = (const int16_t *) m_frame->data[0];
+-			*size = m_frame->nb_samples;
+-		}
+-	} else {
+-		if (m_finished && m_converter) {
+-			auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			} else if (nb_samples > 0) {
+-				m_got_frame = 1;
+ 				*data = (const int16_t *) m_convert_buffer[0];
+ 				*size = nb_samples;
++			} else {
++				*data = (const int16_t *) m_frame->data[0];
++				*size = m_frame->nb_samples;
++			}
++		} else {
++			if (m_converter) {
++				if (IsFinished()) {
++					auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
++					if (nb_samples < 0) {
++						SetError("Couldn't convert audio", ret);
++						return false;
++					} else if (nb_samples > 0) {
++						*data = (const int16_t *) m_convert_buffer[0];
++						*size = nb_samples;
++					}
++				}
+ 			}
+ 		}
+-	}
+
+-	return true;
++		return true;
++	}
+ }
+
+ inline void FFmpegAudioReader::SetError(const char *message, int errnum) {
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index a2b517b..123e643 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -38,6 +38,12 @@ set(SRCS
+
+ if(BUILD_TOOLS)
+ 	set(SRCS ${SRCS} ../src/audio/ffmpeg_audio_reader_test.cpp)
++    include_directories(
++        ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}
++        ${AUDIO_PROCESSOR_INCLUDE_DIRS}
++    )
+ 	link_libraries(fpcalc_libs)
+ endif()
+
+-- 
+2.38.1
+
+
diff --git a/srcpkgs/chromaprint/template b/srcpkgs/chromaprint/template
index 7ef7838949f3a..1f7bbc70a22c8 100644
--- a/srcpkgs/chromaprint/template
+++ b/srcpkgs/chromaprint/template
@@ -1,7 +1,7 @@
 # Template file for 'chromaprint'
 pkgname=chromaprint
 version=1.5.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DBUILD_TOOLS=ON"
 make_check_target="check"

From 5728b0ba0a3f20d78e3abe78a97cc6709aa5ec5a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 024/113] chromium: revbump for ffmpeg-6.0

---
 .../patches/chromium-93-ffmpeg-4.4.patch      | 36 --------------
 srcpkgs/chromium/patches/ffmpeg5.patch        | 47 +++++++++++++++++++
 srcpkgs/chromium/template                     |  2 +-
 3 files changed, 48 insertions(+), 37 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch
 create mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch b/srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch
deleted file mode 100644
index f0ec736f98bc7..0000000000000
--- a/srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch
+++ /dev/null
@@ -1,36 +0,0 @@
-diff --git a/media/filters/ffmpeg_demuxer.cc b/media/filters/ffmpeg_demuxer.cc
-index ac4713b07268..492a9a37d096 100644
---- a/media/filters/ffmpeg_demuxer.cc
-+++ b/media/filters/ffmpeg_demuxer.cc
-@@ -427,11 +427,11 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
-   scoped_refptr<DecoderBuffer> buffer;
- 
-   if (type() == DemuxerStream::TEXT) {
--    size_t id_size = 0;
-+    int id_size = 0;
-     uint8_t* id_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
- 
--    size_t settings_size = 0;
-+    int settings_size = 0;
-     uint8_t* settings_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
- 
-@@ -443,7 +443,7 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
-     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
-                                      side_data.data(), side_data.size());
-   } else {
--    size_t side_data_size = 0;
-+    int side_data_size = 0;
-     uint8_t* side_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
- 
-@@ -504,7 +504,7 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
-                                        packet->size - data_offset);
-     }
- 
--    size_t skip_samples_size = 0;
-+    int skip_samples_size = 0;
-     const uint32_t* skip_samples_ptr =
-         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
-             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..24e2da38e34ca
--- /dev/null
+++ b/srcpkgs/chromium/patches/ffmpeg5.patch
@@ -0,0 +1,47 @@
+--- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
++++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
+@@ -92,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+-  if (stream->start_time != kNoFFmpegTimestamp)
++  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -1597,7 +1585,7 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+@@ -1618,7 +1606,7 @@
+     if (stream->type() != DemuxerStream::VIDEO)
+       continue;
+ 
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+ 
+     if (!stream->IsEnabled())
diff --git a/srcpkgs/chromium/template b/srcpkgs/chromium/template
index b4a39dfd3815c..c29453cd1f509 100644
--- a/srcpkgs/chromium/template
+++ b/srcpkgs/chromium/template
@@ -2,7 +2,7 @@
 pkgname=chromium
 # See https://chromiumdash.appspot.com/releases?platform=Linux for the latest version
 version=114.0.5735.106
-revision=1
+revision=2
 archs="i686* x86_64* aarch64* armv7l*"
 hostmakedepends="
  $(vopt_if clang "clang lld llvm15")

From ad2e390a435816326bc54ba4b819de392d205007 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 025/113] cmus: revbump for ffmpeg-6.0

---
 srcpkgs/cmus/patches/ffmpeg6.patch | 12 ++++++++++++
 srcpkgs/cmus/template              |  2 +-
 2 files changed, 13 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/cmus/patches/ffmpeg6.patch

diff --git a/srcpkgs/cmus/patches/ffmpeg6.patch b/srcpkgs/cmus/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..ffa95ab811101
--- /dev/null
+++ b/srcpkgs/cmus/patches/ffmpeg6.patch
@@ -0,0 +1,12 @@
+--- a/ip/ffmpeg.c
++++ b/ip/ffmpeg.c
+@@ -202,9 +202,6 @@ static int ffmpeg_open(struct input_plugin_data *ip_data)
+ 			break;
+ 		}
+ 
+-		if (codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+-			cc->flags |= AV_CODEC_FLAG_TRUNCATED;
+-
+ 		if (avcodec_open2(cc, codec, NULL) < 0) {
+ 			d_print("could not open codec: %d, %s\n", cc->codec_id, avcodec_get_name(cc->codec_id));
+ 			err = -IP_ERROR_UNSUPPORTED_FILE_TYPE;
diff --git a/srcpkgs/cmus/template b/srcpkgs/cmus/template
index 0fcb424ce336c..05b77d0fecaea 100644
--- a/srcpkgs/cmus/template
+++ b/srcpkgs/cmus/template
@@ -1,7 +1,7 @@
 # Template file for 'cmus'
 pkgname=cmus
 version=2.10.0
-revision=1
+revision=2
 build_style=configure
 configure_args="prefix=/usr LD=$CC"
 hostmakedepends="pkg-config"

From 6375ae5dfdadeb440dc55e70db983e9a475d60be Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 026/113] cyanrip: revbump for ffmpeg-6.0

---
 srcpkgs/cyanrip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cyanrip/template b/srcpkgs/cyanrip/template
index 9796e3461601a..5db30e020d17e 100644
--- a/srcpkgs/cyanrip/template
+++ b/srcpkgs/cyanrip/template
@@ -1,7 +1,7 @@
 # Template file for 'cyanrip'
 pkgname=cyanrip
 version=0.9.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config"
 makedepends="ffmpeg-devel libcdio-devel libcdio-paranoia-devel libcurl-devel libmusicbrainz5-devel"

From b72e3913bbf2a8be5b902f87712d35ea2b4aaab0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 027/113] deadbeef: revbump for ffmpeg4-4.4.3

---
 srcpkgs/deadbeef/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/deadbeef/template b/srcpkgs/deadbeef/template
index b664bb1b9bd9f..165b3c7b9cad8 100644
--- a/srcpkgs/deadbeef/template
+++ b/srcpkgs/deadbeef/template
@@ -1,14 +1,14 @@
 # Template file for 'deadbeef'
 pkgname=deadbeef
 version=1.8.8
-revision=1
+revision=2
 create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-oss --disable-lfm --disable-notify --disable-gtk2"
 hostmakedepends="automake libtool gettext gettext-devel intltool pkg-config
  yasm clang glib-devel"
 makedepends="
- alsa-lib-devel dbus-devel faad2-devel ffmpeg-devel gtk+3-devel imlib2-devel
+ alsa-lib-devel dbus-devel faad2-devel ffmpeg4-devel gtk+3-devel imlib2-devel
  jansson-devel libcddb-devel libcdio-devel libcurl-devel libflac-devel
  libmad-devel libpng-devel libsamplerate-devel libsndfile-devel libvorbis-devel
  libzip-devel mpg123-devel opusfile-devel pulseaudio-devel wavpack-devel"

From e0f6138abd66793d9c3c82007b2531783c818b5d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 028/113] dolphin-emu: revbump for ffmpeg-6.0

---
 srcpkgs/dolphin-emu/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/dolphin-emu/template b/srcpkgs/dolphin-emu/template
index 7ea197ceb2a8e..7aeb0a5b645e0 100644
--- a/srcpkgs/dolphin-emu/template
+++ b/srcpkgs/dolphin-emu/template
@@ -1,7 +1,7 @@
 # Template file for 'dolphin-emu'
 pkgname=dolphin-emu
 version=5.0.16101
-revision=1
+revision=2
 _dolphin_commit=8ecfa537a242de74d2e372e30d9d79b14584b2fb
 _mgba_commit=40d4c430fc36caeb7ea32fd39624947ed487d2f2
 #Version/hash pair can be found at https://dolphin-emu.org/download/

From df9a4ba2008ddbe78f15ceef259ac61466bd3178 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 029/113] droidcam-obs-plugin: revbump for ffmpeg-6.0

---
 srcpkgs/droidcam-obs-plugin/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam-obs-plugin/template b/srcpkgs/droidcam-obs-plugin/template
index fc9c9bf6b9d54..fb0480754df4d 100644
--- a/srcpkgs/droidcam-obs-plugin/template
+++ b/srcpkgs/droidcam-obs-plugin/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam-obs-plugin'
 pkgname=droidcam-obs-plugin
 version=2.0.1
-revision=1
+revision=2
 build_style=gnu-makefile
 make_use_env=yes
 make_build_args="ALLOW_STATIC=no"

From f6319b9587b308d190cc01a997ff242f325cd6c5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 030/113] droidcam: revbump for ffmpeg-6.0

---
 srcpkgs/droidcam/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam/template b/srcpkgs/droidcam/template
index 1c3f1b8b1fc67..32a9220b79a4d 100644
--- a/srcpkgs/droidcam/template
+++ b/srcpkgs/droidcam/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam'
 pkgname=droidcam
 version=1.8.2
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="USBMUXD=-lusbmuxd-2.0 JPEG=-lturbojpeg"
 hostmakedepends="pkg-config"

From 83842f038c6572e245d8032a0e31550a760887d8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 031/113] ffmpegthumbnailer: revbump for ffmpeg-6.0

---
 .../ffmpegthumbnailer/patches/ffmpeg6.patch   | 202 ++++++++++++++++++
 srcpkgs/ffmpegthumbnailer/template            |   6 +-
 2 files changed, 205 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch

diff --git a/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..363ff35a28419
--- /dev/null
+++ b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
@@ -0,0 +1,202 @@
+--- a/libffmpegthumbnailer/moviedecoder.cpp	2017-11-21 14:06:57.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.cpp	2023-05-05 13:14:47.946560668 -0400
+@@ -41,11 +41,6 @@
+ namespace ffmpegthumbnailer
+ {
+ 
+-struct SilenceLogLevel
+-{
+-    SilenceLogLevel() { av_log_set_level(AV_LOG_QUIET); }
+-};
+-
+ MovieDecoder::MovieDecoder(AVFormatContext* pavContext)
+ : m_VideoStream(-1)
+ , m_pFormatContext(pavContext)
+@@ -70,8 +65,6 @@
+ 
+ void MovieDecoder::initialize(const string& filename, bool preferEmbeddedMetadata)
+ {
+-    av_register_all();
+-    avcodec_register_all();
+     avformat_network_init();
+ 
+     string inputFile = filename == "-" ? "pipe:" : filename;
+@@ -97,8 +90,7 @@
+ {
+     if (m_pVideoCodecContext)
+     {
+-        avcodec_close(m_pVideoCodecContext);
+-        m_pVideoCodecContext = nullptr;
++        avcodec_free_context(&m_pVideoCodecContext);
+     }
+ 
+     if ((!m_FormatContextWasGiven) && m_pFormatContext)
+@@ -152,10 +144,10 @@
+     for (unsigned int i = 0; i < m_pFormatContext->nb_streams; ++i)
+     {
+         AVStream *stream = m_pFormatContext->streams[i];
+-        auto ctx = m_pFormatContext->streams[i]->codec;
+-        if (ctx->codec_type == AVMEDIA_TYPE_VIDEO)
++        auto par = m_pFormatContext->streams[i]->codecpar;
++        if (par->codec_type == AVMEDIA_TYPE_VIDEO)
+         {
+-            if (!preferEmbeddedMetadata || !isStillImageCodec(ctx->codec_id))
++            if (!preferEmbeddedMetadata || !isStillImageCodec(par->codec_id))
+             {
+                 videoStreams.push_back(i);
+                 continue;
+@@ -203,8 +195,7 @@
+     }
+ 
+     m_pVideoStream = m_pFormatContext->streams[m_VideoStream];
+-    m_pVideoCodecContext = m_pVideoStream->codec;
+-    m_pVideoCodec = avcodec_find_decoder(m_pVideoCodecContext->codec_id);
++    m_pVideoCodec = avcodec_find_decoder(m_pVideoStream->codecpar->codec_id);
+ 
+     if (m_pVideoCodec == nullptr)
+     {
+@@ -214,6 +205,20 @@
+         throw logic_error("Video Codec not found");
+     }
+ 
++    m_pVideoCodecContext = avcodec_alloc_context3(m_pVideoCodec);
++
++    if (m_pVideoCodecContext == nullptr)
++    {
++        destroy();
++        throw logic_error("Could not allocate video codec context");
++    }
++
++    if (avcodec_parameters_to_context(m_pVideoCodecContext, m_pVideoStream->codecpar) < 0)
++    {
++        destroy();
++        throw logic_error("Could not configure video codec context");
++    }
++
+     m_pVideoCodecContext->workaround_bugs = 1;
+ 
+     if (avcodec_open2(m_pVideoCodecContext, m_pVideoCodec, nullptr) < 0)
+@@ -386,13 +391,6 @@
+ 
+ void MovieDecoder::initializeFilterGraph(const AVRational& timeBase, const std::string& size, bool maintainAspectRatio)
+ {
+-    static const AVPixelFormat pixelFormats[] = { AV_PIX_FMT_RGB24, AV_PIX_FMT_NONE };
+-
+-    auto del = [] (AVBufferSinkParams* p) { av_freep(p); };
+-    std::unique_ptr<AVBufferSinkParams, decltype(del)> buffersinkParams(av_buffersink_params_alloc(), del);
+-
+-    avfilter_register_all();
+-
+     m_pFilterGraph = avfilter_graph_alloc();
+     assert(m_pFilterGraph);
+ 
+@@ -404,10 +402,8 @@
+ 
+     checkRc(avfilter_graph_create_filter(&m_pFilterSource, avfilter_get_by_name("buffer"), "thumb_buffer", ss.str().c_str(), nullptr, m_pFilterGraph),
+             "Failed to create filter source");
+-    buffersinkParams->pixel_fmts = pixelFormats;
+-    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, buffersinkParams.get(), m_pFilterGraph),
++    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, nullptr, m_pFilterGraph),
+             "Failed to create filter sink");
+-    buffersinkParams.release();
+ 
+     AVFilterContext* yadifFilter = nullptr;
+     if (m_pFrame->interlaced_frame != 0)
+@@ -500,15 +496,15 @@
+     }
+ 
+     checkRc(av_seek_frame(m_pFormatContext, -1, timestamp, 0), "Seeking in video failed");
+-    avcodec_flush_buffers(m_pFormatContext->streams[m_VideoStream]->codec);
++    avcodec_flush_buffers(m_pVideoCodecContext);
+ 
+     int keyFrameAttempts = 0;
+-    bool gotFrame = 0;
++    bool gotFrame;
+ 
+     do
+     {
+         int count = 0;
+-        gotFrame = 0;
++        gotFrame = false;
+ 
+         while (!gotFrame && count < 20)
+         {
+@@ -552,17 +548,33 @@
+         return false;
+     }
+ 
+-    av_frame_unref(m_pFrame);
+-
+-    int frameFinished;
++    int rc = avcodec_send_packet(m_pVideoCodecContext, m_pPacket);
++    if(rc == AVERROR(EAGAIN))
++    {
++        rc = 0;
++    }
+ 
+-    int bytesDecoded = avcodec_decode_video2(m_pVideoCodecContext, m_pFrame, &frameFinished, m_pPacket);
+-    if (bytesDecoded < 0)
++    if(rc == AVERROR_EOF)
++    {
++        return false;
++    }
++    else if(rc < 0)
+     {
+-        throw logic_error("Failed to decode video frame: bytesDecoded < 0");
++        throw logic_error("Failed to decode video frame: avcodec_send_packet() < 0");
+     }
+ 
+-    return frameFinished > 0;
++    rc = avcodec_receive_frame(m_pVideoCodecContext, m_pFrame);
++    switch(rc)
++    {
++        case 0:
++            return true;
++
++        case AVERROR(EAGAIN):
++            return false;
++
++        default:
++            throw logic_error("Failed to decode video frame: avcodec_receive_frame() < 0");
++    }
+ }
+ 
+ bool MovieDecoder::getVideoPacket()
+@@ -570,8 +582,6 @@
+     bool framesAvailable = true;
+     bool frameDecoded = false;
+ 
+-    int attempts = 0;
+-
+     if (m_pPacket)
+     {
+         av_packet_unref(m_pPacket);
+@@ -580,6 +590,7 @@
+ 
+     m_pPacket = new AVPacket();
+ 
++
+     while (framesAvailable && !frameDecoded)
+     {
+         framesAvailable = av_read_frame(m_pFormatContext, m_pPacket) >= 0;
+@@ -644,7 +655,7 @@
+ 
+ int32_t MovieDecoder::getStreamRotation()
+ {
+-    int32_t* matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
++    auto matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
+     if (matrix)
+     {
+         auto angle = lround(av_display_rotation_get(matrix));
+
+--- a/libffmpegthumbnailer/moviedecoder.h	2017-11-12 04:23:38.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.h	2023-05-05 13:26:07.095529911 -0400
+@@ -78,7 +78,7 @@
+     int                     m_VideoStream;
+     AVFormatContext*        m_pFormatContext;
+     AVCodecContext*         m_pVideoCodecContext;
+-    AVCodec*                m_pVideoCodec;
++    const AVCodec*          m_pVideoCodec;
+     AVFilterGraph*          m_pFilterGraph;
+     AVFilterContext*        m_pFilterSource;
+     AVFilterContext*        m_pFilterSink;
diff --git a/srcpkgs/ffmpegthumbnailer/template b/srcpkgs/ffmpegthumbnailer/template
index 039eea7622b39..35d546018d12a 100644
--- a/srcpkgs/ffmpegthumbnailer/template
+++ b/srcpkgs/ffmpegthumbnailer/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbnailer'
 pkgname=ffmpegthumbnailer
 version=2.2.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libpng-devel libjpeg-turbo-devel ffmpeg-devel"
@@ -9,8 +9,8 @@ depends="ffmpeg"
 short_desc="Lightweight video thumbnailer"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
-homepage="https://github.com/dirkvdb/${pkgname}"
-distfiles="${homepage}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
+homepage="https://github.com/dirkvdb"
+distfiles="${homepage}/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
 checksum=1cb24059c38223f657b300c84dd80491b7040d4b69471c4fea69be862bc99b5b
 
 post_install() {

From 3e77b9342bcb730baf3bfa4ec591b77c62b737d0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 032/113] ffmpegthumbs: revbump for ffmpeg-6.0

---
 srcpkgs/ffmpegthumbs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ffmpegthumbs/template b/srcpkgs/ffmpegthumbs/template
index 5f0b9414dadaf..11b88193528f4 100644
--- a/srcpkgs/ffmpegthumbs/template
+++ b/srcpkgs/ffmpegthumbs/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbs'
 pkgname=ffmpegthumbs
 version=22.12.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules kcoreaddons kconfig-devel
  pkg-config qt5-host-tools qt5-qmake gettext"

From 072b18ffa8ddeda3dab5ba18f0a27167b4a441d7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 033/113] ffms2: revbump for ffmpeg-6.0

---
 srcpkgs/ffms2/patches/ffmpeg5.patch | 424 ++++++++++++++++++++++++++++
 srcpkgs/ffms2/template              |   2 +-
 2 files changed, 425 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ffms2/patches/ffmpeg5.patch

diff --git a/srcpkgs/ffms2/patches/ffmpeg5.patch b/srcpkgs/ffms2/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..1479fabcafcb4
--- /dev/null
+++ b/srcpkgs/ffms2/patches/ffmpeg5.patch
@@ -0,0 +1,424 @@
+From 45673149e9a2f5586855ad472e3059084eaa36b1 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:41:21 +0100
+Subject: [PATCH] Use auto for AVCodec
+
+The geniuses over at FFmpeg decided to constify this API, so old
+versions of the library will return AVCodec *, while new versions
+of the libary will return const AVCodec *, which, in C++, are not
+OK to convert between.
+
+Rather than use some macro hell in ffmscompat.h, we can work around
+this by using auto.
+
+Gross.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 2 +-
+ src/core/indexing.cpp    | 6 +++---
+ src/core/videosource.cpp | 2 +-
+ 3 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index e4ce97c..ac09666 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -469,7 +469,7 @@ void FFMS_AudioSource::OpenFile() {
+ 
+     LAVFOpenFile(SourceFile.c_str(), FormatContext, TrackNumber);
+ 
+-    AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
++    auto *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
+     if (Codec == nullptr)
+         throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+             "Audio codec not found");
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index e547c5a..59fb4e8 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -384,7 +384,7 @@ FFMS_TrackType FFMS_Indexer::GetTrackType(int Track) {
+ }
+ 
+ const char *FFMS_Indexer::GetTrackCodec(int Track) {
+-    AVCodec *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
++    auto *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
+     return codec ? codec->name : nullptr;
+ }
+ 
+@@ -402,7 +402,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             UseDTS);
+ 
+         if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            AVCodec *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (!VideoCodec) {
+                 FormatContext->streams[i]->discard = AVDISCARD_ALL;
+                 IndexMask.erase(i);
+@@ -433,7 +433,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 IndexMask.insert(i);
+             }
+         } else if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+-            AVCodec *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (AudioCodec == nullptr)
+                 throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_UNSUPPORTED,
+                     "Audio codec not found");
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index b889970..8956c22 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -171,7 +171,7 @@ FFMS_VideoSource::FFMS_VideoSource(const char *SourceFile, FFMS_Index &Index, in
+ 
+         LAVFOpenFile(SourceFile, FormatContext, VideoTrack);
+ 
+-        AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
++        auto *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
+         if (Codec == nullptr)
+             throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+                 "Video codec not found");
+-- 
+2.40.0
+
+From 96cbf38ea9381829a1314f432a2c60495dcefaad Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:12:41 +0100
+Subject: [PATCH] all: Update AVPacket API usage
+
+AVPackets must all be on the heap now, since it is no longer
+part of the libav* ABI.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 16 ++++++----
+ src/core/indexing.cpp    | 63 ++++++++++++++++++++++------------------
+ src/core/indexing.h      |  4 +--
+ src/core/utils.cpp       |  6 ----
+ src/core/utils.h         |  1 -
+ src/core/videosource.cpp | 30 ++++++++++---------
+ 6 files changed, 64 insertions(+), 56 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index 37cf9ae..e4ce97c 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -285,10 +285,15 @@ FFMS_AudioSource::AudioBlock *FFMS_AudioSource::CacheBlock(CacheIterator &pos) {
+ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     CurrentFrame = &Frames[PacketNumber];
+ 
+-    AVPacket Packet;
+-    if (!ReadPacket(&Packet))
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++    if (!ReadPacket(Packet)) {
++        av_packet_free(&Packet);
+         throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_UNKNOWN,
+             "ReadPacket unexpectedly failed to read a packet");
++    }
+ 
+     // ReadPacket may have changed the packet number
+     CurrentFrame = &Frames[PacketNumber];
+@@ -297,8 +302,9 @@ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     int NumberOfSamples = 0;
+     AudioBlock *CachedBlock = nullptr;
+     
+-    int Ret = avcodec_send_packet(CodecContext, &Packet);
+-    av_packet_unref(&Packet);
++    int Ret = avcodec_send_packet(CodecContext, Packet);
++    av_packet_unref(Packet);
++    av_packet_free(&Packet);
+ 
+     av_frame_unref(DecodeFrame);
+     Ret = avcodec_receive_frame(CodecContext, DecodeFrame);
+@@ -513,8 +519,6 @@ void FFMS_AudioSource::Seek() {
+ }
+ 
+ bool FFMS_AudioSource::ReadPacket(AVPacket *Packet) {
+-    InitNullPacket(*Packet);
+-
+     while (av_read_frame(FormatContext, Packet) >= 0) {
+         if (Packet->stream_index == TrackNumber) {
+             // Required because not all audio packets, especially in ogg, have a pts. Use the previous valid packet's pts instead.
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index 23fb95b..e547c5a 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -320,7 +320,7 @@ void FFMS_Indexer::CheckAudioProperties(int Track, AVCodecContext *Context) {
+     }
+ }
+ 
+-void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict,
++void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict,
+                                     int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct) {
+     if (VideoContext.Parser) {
+         uint8_t *OB;
+@@ -330,8 +330,8 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+         av_parser_parse2(VideoContext.Parser,
+             VideoContext.CodecContext,
+             &OB, &OBSize,
+-            pkt.data, pkt.size,
+-            pkt.pts, pkt.dts, pkt.pos);
++            pkt->data, pkt->size,
++            pkt->pts, pkt->dts, pkt->pos);
+ 
+         // H.264 (PAFF) and HEVC may have one field per packet, so we need to track
+         // when we have a full or half frame available, and mark one of them as
+@@ -351,15 +351,15 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+ 
+         *RepeatPict = VideoContext.Parser->repeat_pict;
+         *FrameType = VideoContext.Parser->pict_type;
+-        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt.flags & AV_PKT_FLAG_DISCARD));
++        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt->flags & AV_PKT_FLAG_DISCARD));
+     } else {
+-        *Invisible = !!(pkt.flags & AV_PKT_FLAG_DISCARD);
++        *Invisible = !!(pkt->flags & AV_PKT_FLAG_DISCARD);
+     }
+ 
+     if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP8)
+-        ParseVP8(pkt.data[0], Invisible, FrameType);
++        ParseVP8(pkt->data[0], Invisible, FrameType);
+     else if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP9)
+-        ParseVP9(pkt.data[0], Invisible, FrameType);
++        ParseVP9(pkt->data[0], Invisible, FrameType);
+ }
+ 
+ void FFMS_Indexer::Free() {
+@@ -458,32 +458,36 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+         }
+     }
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
+     std::vector<int64_t> LastValidTS(FormatContext->nb_streams, AV_NOPTS_VALUE);
+ 
+     int64_t filesize = avio_size(FormatContext->pb);
+     enum AVPictureStructure LastPicStruct = AV_PICTURE_STRUCTURE_UNKNOWN;
+-    while (av_read_frame(FormatContext, &Packet) >= 0) {
++    while (av_read_frame(FormatContext, Packet) >= 0) {
+         // Update progress
+         // FormatContext->pb can apparently be NULL when opening images.
+         if (IC && FormatContext->pb) {
+-            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate))
++            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate)) {
++                av_packet_free(&Packet);
+                 throw FFMS_Exception(FFMS_ERROR_CANCELLED, FFMS_ERROR_USER,
+                     "Cancelled by user");
++            }
+         }
+-        if (!IndexMask.count(Packet.stream_index)) {
+-            av_packet_unref(&Packet);
++        if (!IndexMask.count(Packet->stream_index)) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+-        int Track = Packet.stream_index;
++        int Track = Packet->stream_index;
+         FFMS_Track &TrackInfo = (*TrackIndices)[Track];
+-        bool KeyFrame = !!(Packet.flags & AV_PKT_FLAG_KEY);
++        bool KeyFrame = !!(Packet->flags & AV_PKT_FLAG_KEY);
+         ReadTS(Packet, LastValidTS[Track], (*TrackIndices)[Track].UseDTS);
+ 
+         if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            int64_t PTS = TrackInfo.UseDTS ? Packet.dts : Packet.pts;
++            int64_t PTS = TrackInfo.UseDTS ? Packet->dts : Packet->pts;
+             if (PTS == AV_NOPTS_VALUE) {
+                 // VPx alt-refs are output as packets which lack timestmps or durations, since
+                 // they are invisible. Currently, the timestamp mangling code in libavformat
+@@ -495,9 +499,11 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 // FFMS2 currently sorts packets by PTS, which will break decoding, otherwise.
+                 bool HasAltRefs = (FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP8 ||
+                                    FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP9);
+-                if (Packet.duration == 0 && !HasAltRefs)
++                if (Packet->duration == 0 && !HasAltRefs) {
++                    av_packet_free(&Packet);
+                     throw FFMS_Exception(FFMS_ERROR_INDEXING, FFMS_ERROR_PARSER,
+                         "Invalid packet pts, dts, and duration");
++                }
+ 
+                 if (TrackInfo.empty())
+                     PTS = 0;
+@@ -513,7 +519,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             ParseVideoPacket(AVContexts[Track], Packet, &RepeatPict, &FrameType, &Invisible, &LastPicStruct);
+ 
+             TrackInfo.AddVideoFrame(PTS, RepeatPict, KeyFrame,
+-                FrameType, Packet.pos, Invisible);
++                FrameType, Packet->pos, Invisible);
+         } else if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+             // For video seeking timestamps are used only if all packets have
+             // timestamps, while for audio they're used if any have timestamps,
+@@ -522,28 +528,29 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 TrackInfo.HasTS = true;
+ 
+             int64_t StartSample = AVContexts[Track].CurrentSample;
+-            uint32_t SampleCount = IndexAudioPacket(Track, &Packet, AVContexts[Track], *TrackIndices);
++            uint32_t SampleCount = IndexAudioPacket(Track, Packet, AVContexts[Track], *TrackIndices);
+             TrackInfo.SampleRate = AVContexts[Track].CodecContext->sample_rate;
+ 
+             TrackInfo.AddAudioFrame(LastValidTS[Track],
+-                StartSample, SampleCount, KeyFrame, Packet.pos, Packet.flags & AV_PKT_FLAG_DISCARD);
++                StartSample, SampleCount, KeyFrame, Packet->pos, Packet->flags & AV_PKT_FLAG_DISCARD);
+         }
+ 
+-        if (!(Packet.flags & AV_PKT_FLAG_DISCARD))
+-            TrackInfo.LastDuration = Packet.duration;
++        if (!(Packet->flags & AV_PKT_FLAG_DISCARD))
++            TrackInfo.LastDuration = Packet->duration;
+ 
+-        av_packet_unref(&Packet);
++        av_packet_unref(Packet);
+     }
++    av_packet_free(&Packet);
+ 
+     TrackIndices->Finalize(AVContexts, FormatContext->iformat->name);
+     return TrackIndices.release();
+ }
+ 
+-void FFMS_Indexer::ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS) {
+-    if (!UseDTS && Packet.pts != AV_NOPTS_VALUE)
+-        TS = Packet.pts;
++void FFMS_Indexer::ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS) {
++    if (!UseDTS && Packet->pts != AV_NOPTS_VALUE)
++        TS = Packet->pts;
+     if (TS == AV_NOPTS_VALUE)
+         UseDTS = true;
+-    if (UseDTS && Packet.dts != AV_NOPTS_VALUE)
+-        TS = Packet.dts;
++    if (UseDTS && Packet->dts != AV_NOPTS_VALUE)
++        TS = Packet->dts;
+ }
+diff --git a/src/core/indexing.h b/src/core/indexing.h
+index 3cfc3c3..5c06868 100644
+--- a/src/core/indexing.h
++++ b/src/core/indexing.h
+@@ -80,10 +80,10 @@ private:
+     int64_t Filesize;
+     uint8_t Digest[20];
+ 
+-    void ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS);
++    void ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS);
+     void CheckAudioProperties(int Track, AVCodecContext *Context);
+     uint32_t IndexAudioPacket(int Track, AVPacket *Packet, SharedAVContext &Context, FFMS_Index &TrackIndices);
+-    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
++    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
+     void Free();
+ public:
+     FFMS_Indexer(const char *Filename);
+diff --git a/src/core/utils.cpp b/src/core/utils.cpp
+index ce67533..8a2e997 100644
+--- a/src/core/utils.cpp
++++ b/src/core/utils.cpp
+@@ -62,12 +62,6 @@ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo) {
+     }
+ }
+ 
+-void InitNullPacket(AVPacket &pkt) {
+-    av_init_packet(&pkt);
+-    pkt.data = nullptr;
+-    pkt.size = 0;
+-}
+-
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames) {
+     AP.SampleFormat = static_cast<FFMS_SampleFormat>(av_get_packed_sample_fmt(CTX->sample_fmt));
+     AP.BitsPerSample = av_get_bytes_per_sample(CTX->sample_fmt) * 8;
+diff --git a/src/core/utils.h b/src/core/utils.h
+index 9819dc7..003ab79 100644
+--- a/src/core/utils.h
++++ b/src/core/utils.h
+@@ -58,7 +58,6 @@ std::unique_ptr<T> make_unique(Args&&... args) {
+ }
+ 
+ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo);
+-void InitNullPacket(AVPacket &pkt);
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames);
+ 
+ void LAVFOpenFile(const char *SourceFile, AVFormatContext *&FormatContext, int Track);
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index 06bd161..b889970 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -673,30 +673,34 @@ void FFMS_VideoSource::DecodeNextFrame(int64_t &AStartTime, int64_t &Pos) {
+     if (HasPendingDelayedFrames())
+         return;
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
+-
+-    while (ReadFrame(&Packet) >= 0) {
+-        if (Packet.stream_index != VideoTrack) {
+-            av_packet_unref(&Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++
++    while (ReadFrame(Packet) >= 0) {
++        if (Packet->stream_index != VideoTrack) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+         if (AStartTime < 0)
+-            AStartTime = Frames.UseDTS ? Packet.dts : Packet.pts;
++            AStartTime = Frames.UseDTS ? Packet->dts : Packet->pts;
+ 
+         if (Pos < 0)
+-            Pos = Packet.pos;
++            Pos = Packet->pos;
+ 
+-        bool FrameFinished = DecodePacket(&Packet);
+-        av_packet_unref(&Packet);
+-        if (FrameFinished)
++        bool FrameFinished = DecodePacket(Packet);
++        av_packet_unref(Packet);
++        if (FrameFinished) {
++            av_packet_free(&Packet);
+             return;
++        }
+     }
+ 
+     // Flush final frames
+-    InitNullPacket(Packet);
+-    DecodePacket(&Packet);
++    DecodePacket(Packet);
++    av_packet_free(&Packet);
+ }
+ 
+ bool FFMS_VideoSource::SeekTo(int n, int SeekOffset) {
+-- 
+2.40.0
+
+From bf9e03e9e08534c024e5a744a6437c4aac160201 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:20:47 +0100
+Subject: [PATCH 2/3] configure: Remove deprecated API use
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ configure.ac | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index b35ef80bc..d19714d0f 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -102,10 +102,10 @@ CFLAGS="$_CFLAGS $FFMPEG_CFLAGS"
+
+ AC_DEFUN([TEST_FFMPEG],
+          [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+-            #include <libavcodec/avcodec.h>
++            #include <libavformat/avformat.h>
+             #include <libswscale/swscale.h>
+             ]],[[
+-                avcodec_register_all();
++                avformat_network_init();
+                 swscale_version();
+             ]])], [eval $1=yes], [eval $1=no])
+         ])
+
diff --git a/srcpkgs/ffms2/template b/srcpkgs/ffms2/template
index 68e8a0c14bce3..2acfadac44b34 100644
--- a/srcpkgs/ffms2/template
+++ b/srcpkgs/ffms2/template
@@ -1,7 +1,7 @@
 # Template file for 'ffms2'
 pkgname=ffms2
 version=2.40
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-shared --disable-static"
 hostmakedepends="pkg-config autoconf automake libtool"

From 49aed5d04319f2d8982bed0efc1344ae1e2b4709 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 034/113] freerdp: revbump for ffmpeg-6.0

---
 .../freerdp/patches/ffmpeg6_aa2cb9aa.patch    | 42 +++++++++++++++++++
 srcpkgs/freerdp/template                      |  2 +-
 2 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch

diff --git a/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
new file mode 100644
index 0000000000000..a4324da3a8822
--- /dev/null
+++ b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
@@ -0,0 +1,42 @@
+From aa2cb9aa5ff5562433598ba168a466e0752bca0e Mon Sep 17 00:00:00 2001
+From: akallabeth <akallabeth@posteo.net>
+Date: Tue, 14 Feb 2023 07:48:54 +0100
+Subject: [PATCH] Fixed #8686: Update h264 to use new FFMPEG API
+
+---
+ channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c | 2 ++
+ libfreerdp/codec/h264_ffmpeg.c            | 2 ++
+ 2 files changed, 4 insertions(+)
+
+diff --git a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+index 339462d865f..beea80b7a1e 100644
+--- a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
++++ b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+@@ -239,8 +239,10 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYP
+ 		}
+ 	}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 	if (mdecoder->codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		mdecoder->codec_context->flags |= AV_CODEC_FLAG_TRUNCATED;
++#endif
+ 
+ 	return TRUE;
+ }
+diff --git a/libfreerdp/codec/h264_ffmpeg.c b/libfreerdp/codec/h264_ffmpeg.c
+index 8a23db2473c..896a333019b 100644
+--- a/libfreerdp/codec/h264_ffmpeg.c
++++ b/libfreerdp/codec/h264_ffmpeg.c
+@@ -615,10 +615,12 @@ static BOOL libavcodec_init(H264_CONTEXT* h264)
+ 			goto EXCEPTION;
+ 		}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 		if (sys->codecDecoder->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		{
+ 			sys->codecDecoderContext->flags |= AV_CODEC_FLAG_TRUNCATED;
+ 		}
++#endif
+ 
+ #ifdef WITH_VAAPI
+ 
diff --git a/srcpkgs/freerdp/template b/srcpkgs/freerdp/template
index 25e8aa9677f0b..4d51c8189902a 100644
--- a/srcpkgs/freerdp/template
+++ b/srcpkgs/freerdp/template
@@ -1,7 +1,7 @@
 # Template file for 'freerdp'
 pkgname=freerdp
 version=2.10.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_ALSA=ON -DWITH_CUPS=OFF -DWITH_FFMPEG=ON
  -DWITH_GSTREAMER_0_10=OFF -DWITH_GSTREAMER_1_0=OFF -DWITH_JPEG=ON

From 97d1ce1f764ed4ac732c4d53499d5cebcff64603 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 035/113] gerbera: revbump for ffmpeg-6.0

---
 srcpkgs/gerbera/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gerbera/template b/srcpkgs/gerbera/template
index ae14f35c767c0..2dc0ac0ce03b5 100644
--- a/srcpkgs/gerbera/template
+++ b/srcpkgs/gerbera/template
@@ -1,7 +1,7 @@
 # Template file for 'gerbera'
 pkgname=gerbera
 version=1.12.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_SYSTEMD=0 -DWITH_AVCODEC=1"
 hostmakedepends="pkg-config"

From f716f14c13bfc739c00effa567a28a5c18a7b0e9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 036/113] goldendict: revbump for ffmpeg-6.0

---
 srcpkgs/goldendict/patches/ffmpeg5.patch | 232 +++++++++++++++++++++++
 srcpkgs/goldendict/template              |   4 +-
 2 files changed, 234 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/goldendict/patches/ffmpeg5.patch

diff --git a/srcpkgs/goldendict/patches/ffmpeg5.patch b/srcpkgs/goldendict/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..7cfc98ada368a
--- /dev/null
+++ b/srcpkgs/goldendict/patches/ffmpeg5.patch
@@ -0,0 +1,232 @@
+From 03bbe01b79a1f07a6780cb60f23a087104c5d77b Mon Sep 17 00:00:00 2001
+From: Abs62 <ottomann@yandex.ru>
+Date: Fri, 30 Mar 2018 22:53:24 +0300
+Subject: [PATCH] Fix warnings while compile with FFMpeg 3.4.2 (issue #978)
+
+---
+ ffmpegaudio.cc | 68 +++++++++++++++++++++++++++++++++++++++++++++-----
+ 1 file changed, 62 insertions(+), 6 deletions(-)
+
+diff --git a/ffmpegaudio.cc b/ffmpegaudio.cc
+index ed1172bdd..56e8f788e 100644
+--- a/ffmpegaudio.cc
++++ b/ffmpegaudio.cc
+@@ -91,6 +91,7 @@ struct DecoderContext
+   QByteArray audioData_;
+   QDataStream audioDataStream_;
+   AVFormatContext * formatContext_;
++  AVCodec * codec_;
+   AVCodecContext * codecContext_;
+   AVIOContext * avioContext_;
+   AVStream * audioStream_;
+@@ -114,6 +115,7 @@ DecoderContext::DecoderContext( QByteArray const & audioData, QAtomicInt & isCan
+   audioData_( audioData ),
+   audioDataStream_( audioData_ ),
+   formatContext_( NULL ),
++  codec_( NULL ),
+   codecContext_( NULL ),
+   avioContext_( NULL ),
+   audioStream_( NULL ),
+@@ -143,7 +145,11 @@ bool DecoderContext::openCodec( QString & errorString )
+     return false;
+   }
+
++#if LIBAVCODEC_VERSION_MAJOR < 56 || ( LIBAVCODEC_VERSION_MAJOR == 56 && LIBAVCODEC_VERSION_MINOR < 56 )
+   unsigned char * avioBuffer = ( unsigned char * )av_malloc( kBufferSize + FF_INPUT_BUFFER_PADDING_SIZE );
++#else
++  unsigned char * avioBuffer = ( unsigned char * )av_malloc( kBufferSize + AV_INPUT_BUFFER_PADDING_SIZE );
++#endif
+   if ( !avioBuffer )
+   {
+     errorString = QObject::tr( "av_malloc() failed." );
+@@ -186,7 +192,11 @@ bool DecoderContext::openCodec( QString & errorString )
+   // Find audio stream, use the first audio stream if available
+   for ( unsigned i = 0; i < formatContext_->nb_streams; i++ )
+   {
++#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 33 )
+     if ( formatContext_->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO )
++#else
++      if ( formatContext_->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO )
++#endif
+     {
+       audioStream_ = formatContext_->streams[i];
+       break;
+@@ -198,22 +208,38 @@ bool DecoderContext::openCodec( QString & errorString )
+     return false;
+   }
+
++#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 33 )
+   codecContext_ = audioStream_->codec;
+-  AVCodec * codec = avcodec_find_decoder( codecContext_->codec_id );
+-  if ( !codec )
++  codec_ = avcodec_find_decoder( codecContext_->codec_id );
++  if ( !codec_ )
+   {
+     errorString = QObject::tr( "Codec [id: %1] not found." ).arg( codecContext_->codec_id );
+     return false;
+   }
++#else
++  codec_ = avcodec_find_decoder( audioStream_->codecpar->codec_id );
++  if ( !codec_ )
++  {
++    errorString = QObject::tr( "Codec [id: %1] not found." ).arg( audioStream_->codecpar->codec_id );
++    return false;
++  }
++  codecContext_ = avcodec_alloc_context3( codec_ );
++  if ( !codecContext_ )
++  {
++    errorString = QObject::tr( "avcodec_alloc_context3() failed." );
++    return false;
++  }
++  avcodec_parameters_to_context( codecContext_, audioStream_->codecpar );
++#endif
+
+-  ret = avcodec_open2( codecContext_, codec, NULL );
++  ret = avcodec_open2( codecContext_, codec_, NULL );
+   if ( ret < 0 )
+   {
+     errorString = QObject::tr( "avcodec_open2() failed: %1." ).arg( avErrorString( ret ) );
+     return false;
+   }
+
+-  av_log( NULL, AV_LOG_INFO, "Codec open: %s: channels: %d, rate: %d, format: %s\n", codec->long_name,
++  av_log( NULL, AV_LOG_INFO, "Codec open: %s: channels: %d, rate: %d, format: %s\n", codec_->long_name,
+           codecContext_->channels, codecContext_->sample_rate, av_get_sample_fmt_name( codecContext_->sample_fmt ) );
+   return true;
+ }
+@@ -252,10 +278,13 @@ void DecoderContext::closeCodec()
+
+   // Closing a codec context without prior avcodec_open2() will result in
+   // a crash in ffmpeg
+-  if ( audioStream_ && audioStream_->codec && audioStream_->codec->codec )
++  if ( audioStream_ && codecContext_ && codec_ )
+   {
+     audioStream_->discard = AVDISCARD_ALL;
+-    avcodec_close( audioStream_->codec );
++    avcodec_close( codecContext_ );
++#if LIBAVCODEC_VERSION_MAJOR > 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR >= 33 )
++    avcodec_free_context( &codecContext_ );
++#endif
+   }
+
+   avformat_close_input( &formatContext_ );
+@@ -356,6 +385,7 @@ bool DecoderContext::play( QString & errorString )
+     if ( packet.stream_index == audioStream_->index )
+     {
+       AVPacket pack = packet;
++#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 37 )
+       int gotFrame = 0;
+       do
+       {
+@@ -370,6 +400,19 @@ bool DecoderContext::play( QString & errorString )
+         pack.data += len;
+       }
+       while( pack.size > 0 );
++#else
++      int ret = avcodec_send_packet( codecContext_, &pack );
++      /* read all the output frames (in general there may be any number of them) */
++      while( ret >= 0 )
++      {
++        ret = avcodec_receive_frame( codecContext_, frame);
++
++        if ( Qt4x5::AtomicInt::loadAcquire( isCancelled_ ) || ret < 0 )
++          break;
++
++        playFrame( frame );
++      }
++#endif
+     }
+     // av_free_packet() must be called after each call to av_read_frame()
+ #if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 7 )
+@@ -379,6 +422,7 @@ bool DecoderContext::play( QString & errorString )
+ #endif
+   }
+
++#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 37 )
+   if ( !Qt4x5::AtomicInt::loadAcquire( isCancelled_ ) &&
+        codecContext_->codec->capabilities & CODEC_CAP_DELAY )
+   {
+@@ -391,6 +435,18 @@ bool DecoderContext::play( QString & errorString )
+       playFrame( frame );
+     }
+   }
++#else
++  /* flush the decoder */
++  av_init_packet( &packet );
++  int ret = avcodec_send_packet(codecContext_, &packet );
++  while( ret >= 0 )
++  {
++    ret = avcodec_receive_frame(codecContext_, frame);
++    if ( Qt4x5::AtomicInt::loadAcquire( isCancelled_ ) || ret < 0 )
++      break;
++    playFrame( frame );
++  }
++#endif
+
+ #if LIBAVCODEC_VERSION_MAJOR < 54
+   av_free( frame );
+32
+srcpkgs/goldendict/patches/ffmpeg5-2.patch
+Comment on this file
+@@ -0,0 +1,32 @@
+From 966f4a8b78e6324b930e5a50f2bb930bd87e565e Mon Sep 17 00:00:00 2001
+From: Abs62 <ottomann@yandex.ru>
+Date: Fri, 27 Sep 2019 17:00:52 +0300
+Subject: [PATCH] FFmpeg player: Fix some crashes on broken files
+
+---
+ ffmpegaudio.cc | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/ffmpegaudio.cc b/ffmpegaudio.cc
+index 56e8f788e..415fc79cb 100644
+--- a/ffmpegaudio.cc
++++ b/ffmpegaudio.cc
+@@ -51,7 +51,9 @@ AudioService & AudioService::instance()
+
+ AudioService::AudioService()
+ {
++#if LIBAVFORMAT_VERSION_MAJOR < 58 || ( LIBAVFORMAT_VERSION_MAJOR == 58 && LIBAVFORMAT_VERSION_MINOR < 9 )
+   av_register_all();
++#endif
+   ao_initialize();
+ }
+
+@@ -438,6 +440,8 @@ bool DecoderContext::play( QString & errorString )
+ #else
+   /* flush the decoder */
+   av_init_packet( &packet );
++  packet.data = NULL;
++  packet.size = 0;
+   int ret = avcodec_send_packet(codecContext_, &packet );
+   while( ret >= 0 )
+   {
+25
+srcpkgs/goldendict/patches/ffmpeg5-3.patch
+Comment on this file
+@@ -0,0 +1,25 @@
+From 8acb288c9e9bdb3c6bf2e803954dd3b6ac273c05 Mon Sep 17 00:00:00 2001
+From: Liao Junxuan <mikeljx@126.com>
+Date: Sun, 20 Feb 2022 12:28:05 +0800
+Subject: [PATCH] add support for ffmpeg 5.0
+
+---
+ ffmpegaudio.cc | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/ffmpegaudio.cc b/ffmpegaudio.cc
+index d550f4a77..7948d2187 100644
+--- a/ffmpegaudio.cc
++++ b/ffmpegaudio.cc
+@@ -94,7 +94,11 @@ struct DecoderContext
+   QByteArray audioData_;
+   QDataStream audioDataStream_;
+   AVFormatContext * formatContext_;
++#if LIBAVCODEC_VERSION_MAJOR < 59
+   AVCodec * codec_;
++#else
++  const AVCodec * codec_;
++#endif
+   AVCodecContext * codecContext_;
+   AVIOContext * avioContext_;
+   AVStream * audioStream_;
diff --git a/srcpkgs/goldendict/template b/srcpkgs/goldendict/template
index f4a05759f693d..97f44347b03a6 100644
--- a/srcpkgs/goldendict/template
+++ b/srcpkgs/goldendict/template
@@ -1,7 +1,7 @@
 # Template file for 'goldendict'
 pkgname=goldendict
 version=1.5.0
-revision=1
+revision=2
 build_style=qmake
 configure_args="CONFIG+=zim_support goldendict.pro"
 hostmakedepends="qt5-qmake pkg-config qt5-host-tools"
@@ -10,7 +10,7 @@ makedepends="tiff-devel qt5-devel libvorbis-devel zlib-devel
  qt5-webkit-devel lzo-devel bzip2-devel libao-devel qt5-svg-devel
  libeb-devel qt5-x11extras-devel ffmpeg-devel liblzma-devel
  qt5-multimedia-devel"
-short_desc="A feature-rich dictionary lookup program"
+short_desc="Feature-rich dictionary lookup program"
 maintainer="John <me@johnnynator.dev>"
 license="GPL-3.0-or-later"
 homepage="http://goldendict.org/"

From 32c0c2858eca09c4a26d5ed74b090176fdfc967b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 037/113] gst-libav: revbump for ffmpeg-6.0

---
 srcpkgs/gst-libav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index 8c72fc3e97eee..04c39bff14896 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.22.2
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"

From 063639023a11f795b11e7f04be34e5ad39ca3f3e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 038/113] gst-plugins-bad1: revbump for ffmpeg-6.0

---
 srcpkgs/gst-plugins-bad1/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index 77bf79981c20b..5c158724a6c7e 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-plugins-bad1'
 pkgname=gst-plugins-bad1
 version=1.22.2
-revision=1
+revision=2
 build_helper="gir"
 build_style=meson
 configure_args="-Dpackage-origin=https://voidlinux.org -Ddoc=disabled

From 496374914b86b977ccb93ded73e1796793b05f2f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 039/113] gst-rtsp-server: revbump for ffmpeg-6.0

---
 srcpkgs/gst-rtsp-server/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index 2f0c0c45ff820..980fd72cdd4c5 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
 version=1.22.2
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="glib-devel gst-plugins-bad1-devel gobject-introspection

From 2d2c78e8d34f306c55327ce0cece58dd652a8af3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 040/113] guvcview: update to 2.0.8.

---
 srcpkgs/guvcview/patches/fix-include.patch | 10 ++++++++++
 srcpkgs/guvcview/template                  |  5 ++---
 2 files changed, 12 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/guvcview/patches/fix-include.patch

diff --git a/srcpkgs/guvcview/patches/fix-include.patch b/srcpkgs/guvcview/patches/fix-include.patch
new file mode 100644
index 0000000000000..503c2af3b78c1
--- /dev/null
+++ b/srcpkgs/guvcview/patches/fix-include.patch
@@ -0,0 +1,10 @@
+--- a/guvcview/guvcview.c
++++ b/guvcview/guvcview.c
+@@ -28,6 +28,7 @@
+ #include <sys/stat.h>
+ #include <sys/resource.h>
+ #include <errno.h>
++#include <locale.h>
+ 
+ #include "gview.h"
+ #include "gviewv4l2core.h"
diff --git a/srcpkgs/guvcview/template b/srcpkgs/guvcview/template
index 345cf6006f246..86a7fd619612c 100644
--- a/srcpkgs/guvcview/template
+++ b/srcpkgs/guvcview/template
@@ -1,8 +1,7 @@
 # Template file for 'guvcview'
 pkgname=guvcview
-version=2.0.7
+version=2.0.8
 revision=1
-create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-static --disable-debian-menu"
 hostmakedepends="pkg-config intltool autoconf automake libtool glib-devel"
@@ -14,7 +13,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="http://guvcview.sourceforge.net/"
 distfiles="${SOURCEFORGE_SITE}/${pkgname}/${pkgname}-src-${version}.tar.bz2"
-checksum=f47d51fbd06e44eeaa1a82f4a153c927527c90d94514197a70b2956028cc8ad4
+checksum=a21f4e448286666cf27bafef5290cc953a0a1796b752e5bbe521266dc1230c81
 
 post_patch() {
 	sed '31a#include <locale.h>' -i  guvcview/guvcview.c

From f33391516ab0f5e4bdf756aac570e7a06e983996 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 041/113] handbrake: update to 1.6.1

---
 .../patches/fix-missing-x265-link-flag.patch    | 11 ++++++-----
 .../handbrake/patches/libhb-vpl-include.patch   | 15 +++++++++++++++
 srcpkgs/handbrake/template                      | 17 ++++++++++-------
 3 files changed, 31 insertions(+), 12 deletions(-)
 create mode 100644 srcpkgs/handbrake/patches/libhb-vpl-include.patch

diff --git a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
index 26db03867a0c8..d6bb2eda627a3 100644
--- a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
+++ b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
@@ -1,14 +1,15 @@
 --- a/gtk/configure.ac
 +++ b/gtk/configure.ac
 @@ -203,7 +203,7 @@
- 
+
  AM_CONDITIONAL([MINGW], [test "x$mingw_flag" = "xyes"])
- 
--HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg"
-+HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -ldl"
+
+-HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc"
++HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc -ldl"
  HB_CPPFLAGS="$HB_CPPFLAGS $HBINC"
- 
+
  PKG_CHECK_MODULES([x264], [x264], sys_x264=yes, sys_x264=no)
+
 --- a/test/module.defs
 +++ b/test/module.defs
 @@ -69,6 +69,9 @@
diff --git a/srcpkgs/handbrake/patches/libhb-vpl-include.patch b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
new file mode 100644
index 0000000000000..298f9f4ab28f2
--- /dev/null
+++ b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
@@ -0,0 +1,15 @@
+--- a/libhb/module.defs	2023-01-22 11:36:49.000000000 -0500
++++ b/libhb/module.defs	2023-04-03 22:37:52.395467010 -0400
+@@ -46,11 +46,7 @@
+ LIBHB.GCC.I += $(LIBHB.build/) $(CONTRIB.build/)include
+ 
+ ifeq (1,$(FEATURE.qsv))
+-    ifeq ($(HOST.system),freebsd))
+-        LIBHB.GCC.I += $(LOCALBASE)/include/vpl
+-    else
+-        LIBHB.GCC.I += $(CONTRIB.build/)include/vpl
+-    endif
++    LIBHB.GCC.I += /usr/include/vpl
+ endif
+ 
+ ifneq (,$(filter $(HOST.system),freebsd netbsd openbsd))
diff --git a/srcpkgs/handbrake/template b/srcpkgs/handbrake/template
index ca5e4571e49c3..c32cb1bfa31f4 100644
--- a/srcpkgs/handbrake/template
+++ b/srcpkgs/handbrake/template
@@ -1,10 +1,10 @@
 # Template file for 'handbrake'
 pkgname=handbrake
-version=1.5.1
+version=1.6.1
 revision=1
 build_style=gnu-configure
 configure_args="--force --disable-gtk-update-checks --disable-df-fetch --harden
- $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc)"
+ $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc) $(vopt_enable qsv)"
 make_build_args="-C ${XBPS_TRIPLET}"
 make_install_args="-C ${XBPS_TRIPLET}"
 hostmakedepends="automake cmake gettext-devel glib-devel intltool libtool m4 meson nasm pkg-config python3"
@@ -12,8 +12,11 @@ makedepends="bzip2-devel ffmpeg-devel gst-plugins-base1-devel gtk+3-devel
  jansson-devel lame-devel libass-devel libbluray-devel libdav1d-devel
  libdvdnav-devel libdvdread-devel libgudev-devel libnuma-devel
  libsamplerate-devel libtheora-devel libvorbis-devel libvpx-devel libxml2-devel
- opus-devel speex-devel x264-devel x265-devel zimg-devel
+ opus-devel speex-devel x264-devel x265-devel zimg-devel libsvt-av1-devel
  $(vopt_if fdk_aac fdk-aac-devel)
+ $(vopt_if qsv libva-devel)
+ $(vopt_if qsv libdrm-devel)
+ $(vopt_if qsv onevpl-devel)
  $(vopt_if nvenc nv-codec-headers)"
 depends="desktop-file-utils gst-plugins-good1 hicolor-icon-theme"
 short_desc="Multithreaded video transcoder"
@@ -21,15 +24,15 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-2.0-only"
 homepage="https://handbrake.fr/"
 distfiles="https://github.com/HandBrake/HandBrake/releases/download/${version}/HandBrake-${version}-source.tar.bz2"
-checksum=3999fe06d5309c819799a73a968a8ec3840e7840c2b64af8f5cdb7fd8c9430f0
+checksum=94ccfe03db917a91650000c510f7fd53f844da19f19ad4b4be1b8f6bc31a8d4c
 nocross=yes
 
-build_options="fdk_aac nvenc"
+build_options="fdk_aac nvenc qsv"
 
 case "$XBPS_TARGET_MACHINE" in
 	x86_64*|i686*)
 		CFLAGS="-msse"
-		build_options_default="nvenc"
+		build_options_default="nvenc qsv"
 		;;
 esac
 
@@ -37,7 +40,7 @@ pre_configure() {
 	# use system libraries, don't download them
 	rm -rf contrib/
 	for module in fdk-aac ffmpeg libbluray libdav1d libdvdnav libdvdread nvenc \
-		x265 zimg; do
+		x265 zimg svt-av1 libvpl; do
 	    vsed -i "/MODULES += contrib\/${module}/d" make/include/main.defs
 	done
 }

From e8ef8fe6d03ba8b5654e46f31fdc8a5d9a17d7f8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 042/113] hedgewars: revbump for ffmpeg4-4.4.3

---
 srcpkgs/hedgewars/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/hedgewars/template b/srcpkgs/hedgewars/template
index 419f29b98b44d..926fe4fe3e688 100644
--- a/srcpkgs/hedgewars/template
+++ b/srcpkgs/hedgewars/template
@@ -1,13 +1,13 @@
 # Template file for 'hedgewars'
 pkgname=hedgewars
 version=1.0.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DNOSERVER=1 -DDATA_INSTALL_DIR=/usr/share/${pkgname}
  -DPHYSFS_SYSTEM=1 -DMINIMAL_FLAGS=1"
 make_cmd=make
 hostmakedepends="lua51 pkg-config qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
+makedepends="ffmpeg4-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
  SDL2_mixer-devel SDL2_net-devel SDL2_ttf-devel"
 depends="libfreeglut"
 short_desc="Funny turn-based artillery game, featuring fighting Hedgehogs!"

From 8e904a5731e6e723bb1a871082f835dde53200a0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 043/113] idjc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/idjc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/idjc/template b/srcpkgs/idjc/template
index df60318b3db96..36a75baf597c5 100644
--- a/srcpkgs/idjc/template
+++ b/srcpkgs/idjc/template
@@ -1,11 +1,11 @@
 # Template file for 'idjc'
 pkgname=idjc
 version=0.9.1
-revision=3
+revision=4
 build_style=gnu-configure
 hostmakedepends="pkg-config git python3 automake gettext-devel libtool"
 makedepends="libvorbis-devel libogg-devel jack-devel libsamplerate-devel
- libflac-devel libsndfile-devel mpg123-devel ffmpeg-devel speex-devel
+ libflac-devel libsndfile-devel mpg123-devel ffmpeg4-devel speex-devel
  glib-devel pixman-devel lame-devel python3-gobject-devel libshout-idjc-devel
  opus-devel twolame-devel python3-mutagen python3-devel"
 depends="python3-gobject python3-mutagen desktop-file-utils shared-mime-info python3-dbus jack"

From a0e7a7603c145bf67ed7ab80e3238596022265fc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 044/113] kfilemetadata5: revbump for ffmpeg-6.0

---
 srcpkgs/kfilemetadata5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kfilemetadata5/template b/srcpkgs/kfilemetadata5/template
index 4b91cf19f298f..a3671a38ce59e 100644
--- a/srcpkgs/kfilemetadata5/template
+++ b/srcpkgs/kfilemetadata5/template
@@ -1,7 +1,7 @@
 # Template file for 'kfilemetadata5'
 pkgname=kfilemetadata5
 version=5.107.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="kcoreaddons extra-cmake-modules pkg-config qt5-host-tools qt5-qmake
  gettext kcoreaddons python3"

From 87943cd36daa38c3b850e38a67fa567efa871def Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 045/113] kid3: revbump for ffmpeg-6.0

---
 srcpkgs/kid3/patches/ffmpeg5.patch | 17 +++++++++++++++++
 srcpkgs/kid3/template              |  2 +-
 2 files changed, 18 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/kid3/patches/ffmpeg5.patch

diff --git a/srcpkgs/kid3/patches/ffmpeg5.patch b/srcpkgs/kid3/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..135fc50e07c9b
--- /dev/null
+++ b/srcpkgs/kid3/patches/ffmpeg5.patch
@@ -0,0 +1,17 @@
+# https://aur.archlinux.org/cgit/aur.git/diff/ffmpeg5.patch?h=kid3-cli&id=12410a74906612e7efc0ec8fbce739b4a0fef7e7
+diff --git a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+index e156d424..e12b9abd 100644
+--- a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
++++ b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+@@ -232,7 +232,11 @@ private:
+   friend class Format;
+   friend class Converter;
+   AVCodecContext* m_ptr;
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 0, 0)
+   AVCodec* m_impl;
++#else
++  const AVCodec* m_impl;
++#endif
+   AVFrame* m_frame;
+   bool m_opened;
+ };
diff --git a/srcpkgs/kid3/template b/srcpkgs/kid3/template
index 456206d90e16a..f32f9decb0e7f 100644
--- a/srcpkgs/kid3/template
+++ b/srcpkgs/kid3/template
@@ -1,7 +1,7 @@
 # Template file for 'kid3'
 pkgname=kid3
 version=3.9.1
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DWITH_APPS='CLI;$(vopt_if KDE KDE Qt)'
  -DWITH_DOCBOOKDIR=/usr/share/xsl/docbook -DWITH_FLAC=$(vopt_if flac ON OFF)

From da21a90cac5731f65ebae86f50028d47a0828ffc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 046/113] kodi: revbump for ffmpeg4-4.4.3

---
 srcpkgs/kodi/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/kodi/template b/srcpkgs/kodi/template
index 8057964d78a38..6cc1874be7ba6 100644
--- a/srcpkgs/kodi/template
+++ b/srcpkgs/kodi/template
@@ -1,7 +1,7 @@
 # Template file for 'kodi'
 pkgname=kodi
 version=19.4
-revision=6
+revision=7
 _codename="Matrix"
 build_style=cmake
 configure_args="-DWITH_FFMPEG=/usr -DENABLE_LDGOLD=OFF
@@ -54,7 +54,7 @@ makedepends="
  libmad-devel fontconfig-devel libXinerama-devel libsamplerate-devel libmms-devel
  enca-devel boost-devel libcurl-devel libva-devel libvdpau-devel libass-devel
  libbluetooth-devel yajl-devel libplist-devel librtmp-devel tinyxml-devel
- taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg-devel
+ taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg4-devel
  giflib-devel libxslt-devel gnutls-devel libssh-devel libmicrohttpd-devel
  libcec-devel dcadec-devel flatbuffers-devel fmt-devel lcms2-devel
  libfstrcmp-devel rapidjson libcdio-paranoia spdlog libwaylandpp-devel

From d264012702477ddd8d4a032d76ffc43296e0b179 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 047/113] kpipewire: revbump for ffmpeg-6.0

---
 srcpkgs/kpipewire/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kpipewire/template b/srcpkgs/kpipewire/template
index db4e42f0d456a..2334bf8678062 100644
--- a/srcpkgs/kpipewire/template
+++ b/srcpkgs/kpipewire/template
@@ -1,7 +1,7 @@
 # Template file for 'kpipewire'
 pkgname=kpipewire
 version=5.27.6
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules plasma-wayland-protocols gettext
  qt5-qmake qt5-host-tools pkg-config wayland-devel kcoreaddons

From e964a712ac2630036e8cb83054bd954fd6c4bd36 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 048/113] libextractor: revbump for ffmpeg4-4.4.3

---
 srcpkgs/libextractor/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libextractor/template b/srcpkgs/libextractor/template
index ddd4790f93e88..1fb9ca56a96ae 100644
--- a/srcpkgs/libextractor/template
+++ b/srcpkgs/libextractor/template
@@ -7,7 +7,7 @@ configure_args="--disable-static"
 hostmakedepends="pkg-config"
 makedepends="zlib-devel bzip2-devel exiv2-devel tiff-devel libpng-devel
  libjpeg-turbo-devel libvorbis-devel libflac-devel giflib-devel libmpeg2-devel
- ffmpeg-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
+ ffmpeg4-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
 short_desc="Library used to extract meta data from files"
 maintainer="Martin Riese <grauehaare@gmx.de>"
 license="GPL-3.0-or-later"

From bd973a050e0aa37b2c732f25781334eb0a0b1680 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 049/113] libopenal: revbump for ffmpeg-6.0

---
 srcpkgs/libopenal/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenal/template b/srcpkgs/libopenal/template
index 77218f9e539df..3f49ed75a1fdc 100644
--- a/srcpkgs/libopenal/template
+++ b/srcpkgs/libopenal/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenal'
 pkgname=libopenal
 version=1.22.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DALSOFT_EXAMPLES=OFF"
 hostmakedepends="pkg-config"

From 82205a4e5be62eeb44470f2b0b66c3216da5cfe2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 050/113] libopenshot: revbump for ffmpeg-6.0

---
 srcpkgs/libopenshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenshot/template b/srcpkgs/libopenshot/template
index db831f69b474c..81aa0d7136d92 100644
--- a/srcpkgs/libopenshot/template
+++ b/srcpkgs/libopenshot/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenshot'
 pkgname=libopenshot
 version=0.3.0
-revision=1
+revision=2
 build_style=cmake
 # Builds fail with Ruby-2.4.1
 configure_args="-DENABLE_RUBY=OFF -DUSE_SYSTEM_JSONCPP=ON"

From 37ea59aea105f03d8e280d484ddcb2c7bd8c2b26 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 051/113] loudgain: revbump for ffmpeg-6.0

---
 srcpkgs/loudgain/patches/ffmpeg5.patch | 11 +++++++++++
 srcpkgs/loudgain/template              |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/loudgain/patches/ffmpeg5.patch

diff --git a/srcpkgs/loudgain/patches/ffmpeg5.patch b/srcpkgs/loudgain/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..16d4510ee98fa
--- /dev/null
+++ b/srcpkgs/loudgain/patches/ffmpeg5.patch
@@ -0,0 +1,11 @@
+--- a/src/scan.c	2019-09-06 11:31:19.000000000 -0400
++++ b/src/scan.c	2023-03-23 11:15:40.867968521 -0400
+@@ -69,8 +69,6 @@
+ 	 * It is now useless
+ 	 * https://github.com/FFmpeg/FFmpeg/blob/70d25268c21cbee5f08304da95be1f647c630c15/doc/APIchanges#L86
+ 	 */
+-  if (avformat_version() < AV_VERSION_INT(58,9,100))
+-    av_register_all();
+ 
+ 	av_log_set_callback(scan_av_log);
+ 
diff --git a/srcpkgs/loudgain/template b/srcpkgs/loudgain/template
index da4f2d56e94c3..4d6bf29efb4fd 100644
--- a/srcpkgs/loudgain/template
+++ b/srcpkgs/loudgain/template
@@ -1,7 +1,7 @@
 # Template file for 'loudgain'
 pkgname=loudgain
 version=0.6.8
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libebur128-devel taglib-devel ffmpeg-devel"

From 8a7b5e9f77a40f88050e1103a4ba8c9cd27e72e1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 052/113] mediastreamer: revbump for ffmpeg4-4.4.3

---
 srcpkgs/mediastreamer/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mediastreamer/template b/srcpkgs/mediastreamer/template
index d0e97e858e29a..1bde031443a59 100644
--- a/srcpkgs/mediastreamer/template
+++ b/srcpkgs/mediastreamer/template
@@ -1,11 +1,11 @@
 # Template file for 'mediastreamer'
 pkgname=mediastreamer
 version=5.2.6
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_STRICT=0 -DENABLE_UNIT_TESTS=0"
 hostmakedepends="python3"
-makedepends="bzrtp-devel ffmpeg-devel glew-devel libXv-devel libsrtp-devel
+makedepends="bzrtp-devel ffmpeg4-devel glew-devel libXv-devel libsrtp-devel
  libupnp-devel libvpx-devel mbedtls-devel opus-devel ortp-devel pulseaudio-devel
  libtheora-devel speex-devel v4l-utils-devel bcg729-devel bcmatroska2-devel libgsm-devel"
 # zxing-cpp-devel (1.2.0 probably not compatible, check again after updaing xzing)

From 0f984407789861a51116bc41a9ca1b8960cebe10 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 053/113] mgba: revbump for ffmpeg-6.0

---
 srcpkgs/mgba/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mgba/template b/srcpkgs/mgba/template
index ae0504311eee0..d31295a0cd3d3 100644
--- a/srcpkgs/mgba/template
+++ b/srcpkgs/mgba/template
@@ -1,7 +1,7 @@
 # Template file for 'mgba'
 pkgname=mgba
 version=0.10.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake desktop-file-utils"
 makedepends="SDL2-devel ffmpeg-devel libedit-devel libepoxy-devel libmagick-devel

From 7550b7b4addca5a33b2fd45adaa4bdfe65bc0235 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 054/113] minidlna: revbump for ffmpeg-6.0

---
 srcpkgs/minidlna/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/minidlna/template b/srcpkgs/minidlna/template
index d551e49ed4653..5fa929f3a0c12 100644
--- a/srcpkgs/minidlna/template
+++ b/srcpkgs/minidlna/template
@@ -1,7 +1,7 @@
 # Template file for 'minidlna'
 pkgname=minidlna
 version=1.3.3
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="
  --sbindir=/usr/bin

From c5899bdc992dc2d0984ebab1f710f7dbd49881ce Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 055/113] mixxx: revbump for ffmpeg-6.0

---
 srcpkgs/mixxx/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mixxx/template b/srcpkgs/mixxx/template
index 619ddca0d3324..4b9ea00d3fb3d 100644
--- a/srcpkgs/mixxx/template
+++ b/srcpkgs/mixxx/template
@@ -1,7 +1,7 @@
 # Template file for 'mixxx'
 pkgname=mixxx
 version=2.3.3
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="extra-cmake-modules pkg-config protobuf qt5-host-tools qt5-devel"

From 1dd343288edb77fb05aada2e307ac9154fbeaa6d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 056/113] mlt: revbump for ffmpeg4-4.4.3

---
 srcpkgs/mlt/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mlt/template b/srcpkgs/mlt/template
index 8933eb4e7bb9e..73353fedafb50 100644
--- a/srcpkgs/mlt/template
+++ b/srcpkgs/mlt/template
@@ -1,14 +1,14 @@
 # Template file for 'mlt'
 pkgname=mlt
 version=6.26.1
-revision=1
+revision=2
 build_style=configure
 configure_args="--prefix=/usr --libdir=/usr/lib$XBPS_TARGET_WORDSIZE
  --enable-gpl --enable-gpl3 --disable-swfdec --without-kde
  --swig-languages=python"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which"
 # XXX: movit vid.stab
-makedepends="alsa-lib-devel ffmpeg-devel gtk+-devel jack-devel ladspa-sdk
+makedepends="alsa-lib-devel ffmpeg4-devel gtk+-devel jack-devel ladspa-sdk
  libexif-devel libsamplerate-devel libxml2-devel sox-devel SDL_image-devel
  fftw-devel frei0r-plugins python3-devel pulseaudio-devel movit-devel
  libvidstab-devel libatomic-devel"

From 0135b81482492c6d1e9e578da804c4582267477e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 057/113] moc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/moc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/moc/template b/srcpkgs/moc/template
index c42be650a1d25..d4f0eefbad52d 100644
--- a/srcpkgs/moc/template
+++ b/srcpkgs/moc/template
@@ -1,10 +1,10 @@
 # Template file for 'moc'
 pkgname=moc
 version=2.5.2
-revision=6
+revision=7
 build_style=gnu-configure
 hostmakedepends="pkg-config"
-makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg-devel
+makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg4-devel
  jack-devel alsa-lib-devel libltdl-devel libflac-devel libvorbis-devel
  libmad-devel libmpcdec-devel libmodplug-devel libid3tag-devel faad2-devel
  taglib-devel libsndfile-devel wavpack-devel speex-devel libsamplerate-devel

From 00592a9ca638e0ecad20ce4717f3ebba6c08cb20 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 058/113] motion: revbump for ffmpeg-6.0

---
 srcpkgs/motion/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/motion/template b/srcpkgs/motion/template
index 3cf3c3035c5b7..7dca12d851e33 100644
--- a/srcpkgs/motion/template
+++ b/srcpkgs/motion/template
@@ -1,7 +1,7 @@
 # Template file for 'motion'
 pkgname=motion
 version=4.5.1
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake pkg-config gettext-devel tar"
 makedepends="ffmpeg-devel libmicrohttpd-devel v4l-utils-devel gettext-devel"

From ea065854d315b9fa37ba972626e1639969bd6905 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 059/113] mpv: revbump for ffmpeg-6.0

---
 srcpkgs/mpv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpv/template b/srcpkgs/mpv/template
index e163c496c6ebb..d4fefbf5e3c7c 100644
--- a/srcpkgs/mpv/template
+++ b/srcpkgs/mpv/template
@@ -1,7 +1,7 @@
 # Template file for 'mpv'
 pkgname=mpv
 version=0.35.1
-revision=2
+revision=3
 build_style=meson
 configure_args="-Dcdda=enabled -Ddvbin=enabled -Ddvdnav=enabled
  -Dlibmpv=true -Dcplugins=enabled

From c7a7b8f5f038883d5298da8bf33c99c173b8bb3f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 060/113] musikcube: revbump for ffmpeg-6.0

---
 srcpkgs/musikcube/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/musikcube/template b/srcpkgs/musikcube/template
index 7c569303c0543..a4dea460c3717 100644
--- a/srcpkgs/musikcube/template
+++ b/srcpkgs/musikcube/template
@@ -1,7 +1,7 @@
 # Template file for 'musikcube'
 pkgname=musikcube
 version=3.0.0
-revision=1
+revision=2
 build_style=cmake
 make_cmd=make
 configure_args="-DNO_NCURSESW=1"

From 62185a30e46eb522380d8fbfeefe0a9df288822c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 061/113] notcurses: revbump for ffmpeg-6.0

---
 srcpkgs/notcurses/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/notcurses/template b/srcpkgs/notcurses/template
index 6dd8a091319f7..3110c30c9aff2 100644
--- a/srcpkgs/notcurses/template
+++ b/srcpkgs/notcurses/template
@@ -1,7 +1,7 @@
 # Template file for 'notcurses'
 pkgname=notcurses
 version=3.0.9
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DUSE_STATIC=ON $(vopt_bool man USE_PANDOC)"
 hostmakedepends="pkg-config $(vopt_if man pandoc)"

From 39a948feff41ce9e4783eac6824d4a51216f72bf Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 062/113] obs: revbump for ffmpeg-6.0

---
 srcpkgs/obs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/obs/template b/srcpkgs/obs/template
index 7b69c630d30d4..2c8d68d71f3a1 100644
--- a/srcpkgs/obs/template
+++ b/srcpkgs/obs/template
@@ -1,7 +1,7 @@
 # Template file for 'obs'
 pkgname=obs
 version=29.1.2
-revision=1
+revision=2
 archs="i686* x86_64* ppc64le* aarch64*"
 build_style=cmake
 configure_args="-DOBS_VERSION_OVERRIDE=${version} -DENABLE_JACK=ON

From 926829e3f55052a9cee3c209752064db48919dba Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 063/113] olive: revbump for ffmpeg4-4.4.3

---
 srcpkgs/olive/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/olive/template b/srcpkgs/olive/template
index 12a46936c9900..5c2917b9c5124 100644
--- a/srcpkgs/olive/template
+++ b/srcpkgs/olive/template
@@ -1,10 +1,10 @@
 # Template file for 'olive'
 pkgname=olive
 version=0.1.2
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools pkg-config"
-makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg-devel frei0r-plugins"
+makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg4-devel frei0r-plugins"
 short_desc="Non-linear video editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"

From 0ece9033559c5f2e39efd793a28420dda9d69215 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 064/113] omxplayer: revbump for ffmpeg4-4.4.3

---
 srcpkgs/omxplayer/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/omxplayer/template b/srcpkgs/omxplayer/template
index e70bf7873d4de..0e9bc70e7c8eb 100644
--- a/srcpkgs/omxplayer/template
+++ b/srcpkgs/omxplayer/template
@@ -1,10 +1,10 @@
 # Template file for 'omxplayer'
 pkgname=omxplayer
 version=20190102
-revision=1
+revision=2
 short_desc="Commandline OMX player for the Raspberry Pi"
 maintainer="Orphaned <orphan@voidlinux.org>"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://github.com/popcornmix/omxplayer"
 
 _commit="f06235cc9690a6d58187514452df8cf8fcdaacec"
@@ -15,7 +15,7 @@ checksum=af2d9450f8947842ea8c401fe9f71eec444013ebbdee29f2ac828c9c493c1329
 archs="armv6l* armv7l*"
 build_style=gnu-makefile
 hostmakedepends="curl pkg-config"
-makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg-devel dbus-devel"
+makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg4-devel dbus-devel"
 depends="freefont-ttf"
 
 do_build() {

From 87002207f8b514874cc51af323cfaaae69e68073 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 065/113] openimageio: revbump for ffmpeg-6.0

---
 common/shlibs | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/common/shlibs b/common/shlibs
index ca0ee066215ea..1ffaf3fd70576 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2260,6 +2260,8 @@ libxmp.so.4 libxmp-4.3.7_1
 libKF5ThreadWeaver.so.5 threadweaver-5.26.0_1
 libOpenImageIO_Util.so.2.4 openimageio-2.4.9.0_1
 libOpenImageIO.so.2.4 openimageio-2.4.9.0_1
+libOpenImageIO_Util.so.2.4 openimageio-2.4.8.1_1
+libOpenImageIO.so.2.4 openimageio-2.4.8.1_1
 libOpenColorIO.so.2.1 opencolorio-2.1.2_1
 libpystring.so.1 pystring-1.1.3_1
 libyaml-cpp.so.0.7 yaml-cpp-0.7.0_1

From 6f186aa6622f1734e5b83fb7809b825065f50c59 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 066/113] openshot: revbump for ffmpeg-6.0

---
 srcpkgs/openshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openshot/template b/srcpkgs/openshot/template
index 322717d40abc0..c074e0338773b 100644
--- a/srcpkgs/openshot/template
+++ b/srcpkgs/openshot/template
@@ -1,7 +1,7 @@
 # Template file for 'openshot'
 pkgname=openshot
 version=3.0.0
-revision=1
+revision=2
 build_style=python3-module
 hostmakedepends="python3 python3-setuptools"
 makedepends="ffmpeg-devel python3-PyQt5"

From b4b2efacc4639a90e6741aad5bc09ef309040fb5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 067/113] opentoonz: revbump for ffmpeg-6.0

---
 srcpkgs/opentoonz/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/opentoonz/template b/srcpkgs/opentoonz/template
index ee9f7603f55fd..3e81834ca0edd 100644
--- a/srcpkgs/opentoonz/template
+++ b/srcpkgs/opentoonz/template
@@ -1,7 +1,7 @@
 # Template file for 'opentoonz'
 pkgname=opentoonz
 version=1.6.0
-revision=2
+revision=3
 build_wrksrc="toonz/sources"
 build_style=cmake
 make_cmd=make

From c581ca7baff7b9f2c5c2f007baf88a3895592028 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 068/113] pianobar: revbump for ffmpeg-6.0

---
 srcpkgs/pianobar/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pianobar/template b/srcpkgs/pianobar/template
index e3febb821a451..1e3dc1bf9308e 100644
--- a/srcpkgs/pianobar/template
+++ b/srcpkgs/pianobar/template
@@ -1,7 +1,7 @@
 # Template file for 'pianobar'
 pkgname=pianobar
 version=2022.04.01
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="V=1"
 hostmakedepends="pkg-config"

From 73385aff3ebe6286f52548808c04413b11dac724 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 069/113] ppsspp: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ppsspp/template | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/ppsspp/template b/srcpkgs/ppsspp/template
index 7984a733d4bea..15a42fd2c993e 100644
--- a/srcpkgs/ppsspp/template
+++ b/srcpkgs/ppsspp/template
@@ -1,7 +1,7 @@
 # Template file for 'ppsspp'
 pkgname=ppsspp
 version=1.14.4
-revision=1
+revision=2
 _glslang_commit=dc11adde23c455a24e13dd54de9b4ede8bdd7db8
 _SPIRV_Cross_commit=9acb9ec31f5a8ef80ea6b994bb77be787b08d3d1
 _armips_commit=6719edebaae03330ee5441d9b28280672edf00d5
@@ -13,7 +13,7 @@ configure_args="-DHEADLESS=1 -DUSE_SYSTEM_FFMPEG=1 -DUNITTEST=ON
  -DUSING_QT_UI=$(vopt_if qt ON OFF) -DUSE_SYSTEM_ZSTD=ON
  -DARMIPS_USE_STD_FILESYSTEM=ON"
 hostmakedepends="pkg-config python3 $(vopt_if qt qt5-host-tools)"
-makedepends="zlib-devel glew-devel ffmpeg-devel libzip-devel
+makedepends="zlib-devel glew-devel ffmpeg4-devel libzip-devel
  snappy-devel rapidjson libpng-devel libzstd-devel
  $(vopt_if sdl2 SDL2-devel) $(vopt_if wayland wayland-devel)
  $(vopt_if qt 'qt5-devel qt5-multimedia-devel')"
@@ -62,13 +62,12 @@ post_extract() {
 	mv ${wrksrc}/miniupnp-${_miniupnp_commit} ${wrksrc}/ext/miniupnp
 }
 
-post_patch(){
+post_patch() {
 	# disable git versioning
 	vsed -e 's|find_package(Git)|# &|' -i git-version.cmake
 }
 
 do_install() {
-	vlicense LICENSE.TXT
 	vinstall icons/icon.svg 644 usr/share/pixmaps ppsspp.svg
 	vinstall Qt/PPSSPP.desktop 644 usr/share/applications
 	vbin build/PPSSPPHeadless ppsspp-headless

From 2872eba0f3474ef764d118c7e6fb6715fdf54138 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 070/113] pqiv: revbump for ffmpeg-6.0

---
 srcpkgs/pqiv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pqiv/template b/srcpkgs/pqiv/template
index 542fc27a2d32a..9308d949b6a1c 100644
--- a/srcpkgs/pqiv/template
+++ b/srcpkgs/pqiv/template
@@ -1,7 +1,7 @@
 # Template file for 'pqiv'
 pkgname=pqiv
 version=2.12
-revision=1
+revision=2
 build_style=gnu-makefile
 hostmakedepends="pkg-config"
 makedepends="glib-devel gtk+3-devel $(vopt_if ffmpeg ffmpeg-devel)

From 04c156bbd4e470a064c8529faf1f7ade33d82a13 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 071/113] qmmp: revbump for ffmpeg-6.0

---
 srcpkgs/qmmp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qmmp/template b/srcpkgs/qmmp/template
index 26c661ed16bea..a150d7441c7a6 100644
--- a/srcpkgs/qmmp/template
+++ b/srcpkgs/qmmp/template
@@ -1,7 +1,7 @@
 # Template file for 'qmmp'
 pkgname=qmmp
 version=1.6.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DUSE_HAL:BOOL=FALSE -DQMMP_DEFAULT_UI:STRING=simple"
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From de231a2f9d87735284381a1e2adff9b7782789f6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 072/113] qt5-webengine: update to 5.15.13

---
 .../chromium-media-filters-cpp14.patch        |  11 ++
 srcpkgs/qt5-webengine/patches/ffmpeg5.patch   | 179 ++++++++++++++++++
 srcpkgs/qt5-webengine/template                |  10 +-
 3 files changed, 195 insertions(+), 5 deletions(-)
 create mode 100644 srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/ffmpeg5.patch

diff --git a/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
new file mode 100644
index 0000000000000..04adc540f2cbc
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
@@ -0,0 +1,11 @@
+--- a/src/3rdparty/chromium/media/filters/BUILD.gn	2023-02-27 13:32:59.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/BUILD.gn	2023-04-02 17:21:39.204066384 -0400
+@@ -96,6 +96,8 @@
+     "//ui/gfx/geometry:geometry",
+   ]
+ 
++  cflags_cc = [ "-std=c++14" ]
++
+   libs = []
+ 
+   if (proprietary_codecs) {
diff --git a/srcpkgs/qt5-webengine/patches/ffmpeg5.patch b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..ac55e1634423a
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
@@ -0,0 +1,179 @@
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:57.732547446 -0400
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:09.486478995 -0400
+@@ -57,6 +57,8 @@
+ 
+ namespace {
+ 
++constexpr int64_t kRelativeTsBase = static_cast<int64_t>(0x7ffeffffffffffff);
++
+ void SetAVStreamDiscard(AVStream* stream, AVDiscard discard) {
+   DCHECK(stream);
+   stream->discard = discard;
+@@ -90,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+   if (stream->start_time != kNoFFmpegTimestamp)
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (stream->first_dts != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, stream->first_dts);
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -408,11 +398,11 @@
+   scoped_refptr<DecoderBuffer> buffer;
+ 
+   if (type() == DemuxerStream::TEXT) {
+-    int id_size = 0;
++    size_t id_size = 0;
+     uint8_t* id_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
+ 
+-    int settings_size = 0;
++    size_t settings_size = 0;
+     uint8_t* settings_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
+ 
+@@ -424,7 +414,7 @@
+     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
+                                      side_data.data(), side_data.size());
+   } else {
+-    int side_data_size = 0;
++    size_t side_data_size = 0;
+     uint8_t* side_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
+ 
+@@ -485,7 +475,7 @@
+                                        packet->size - data_offset);
+     }
+ 
+-    int skip_samples_size = 0;
++    size_t skip_samples_size = 0;
+     const uint32_t* skip_samples_ptr =
+         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
+             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
+@@ -1587,6 +1577,8 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++      continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+       lowest_start_time_stream = stream.get();
+@@ -1604,6 +1596,8 @@
+     if (stream && stream->type() == DemuxerStream::VIDEO &&
+         stream->IsEnabled()) {
+       video_stream = stream.get();
++      if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++        continue;
+       if (video_stream->start_time() <= seek_time) {
+         return video_stream;
+       }
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h qtwebengine-5.15.10/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h
+--- a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-07-11 22:12:47.917192788 -0500
+@@ -29,6 +29,7 @@ extern "C" {
+ #include <libavformat/avformat.h>
+ #include <libavformat/avio.h>
+ #include <libavutil/avutil.h>
++#include <libavutil/channel_layout.h>
+ #include <libavutil/imgutils.h>
+ #include <libavutil/log.h>
+ #include <libavutil/mastering_display_metadata.h>
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/audio_file_reader.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/audio_file_reader.cc
+--- a/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -85,7 +85,7 @@ bool AudioFileReader::OpenDemuxer() {
+ }
+ 
+ bool AudioFileReader::OpenDecoder() {
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (codec) {
+     // MP3 decodes to S16P which we don't support, tell it to use S16 instead.
+     if (codec_context_->sample_fmt == AV_SAMPLE_FMT_S16P)
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -329,7 +329,7 @@ bool FFmpegAudioDecoder::ConfigureDecode
+     }
+   }
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec ||
+       avcodec_open2(codec_context_.get(), codec, &codec_options) < 0) {
+     DLOG(ERROR) << "Could not initialize audio decoder: "
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -59,7 +59,6 @@ static int64_t AVIOSeekOperation(void* o
+ }
+ 
+ void FFmpegGlue::InitializeFFmpeg() {
+-  av_register_all();
+ }
+ 
+ static void LogContainer(bool is_local_file,
+@@ -95,9 +94,6 @@ FFmpegGlue::FFmpegGlue(FFmpegURLProtocol
+   // Enable fast, but inaccurate seeks for MP3.
+   format_context_->flags |= AVFMT_FLAG_FAST_SEEK;
+ 
+-  // Ensures we can read out various metadata bits like vp8 alpha.
+-  format_context_->flags |= AVFMT_FLAG_KEEP_SIDE_DATA;
+-
+   // Ensures format parsing errors will bail out. From an audit on 11/2017, all
+   // instances were real failures. Solves bugs like http://crbug.com/710791.
+   format_context_->error_recognition |= AV_EF_EXPLODE;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -391,7 +391,7 @@ bool FFmpegVideoDecoder::ConfigureDecode
+   if (decode_nalus_)
+     codec_context_->flags2 |= AV_CODEC_FLAG2_CHUNKS;
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
+     ReleaseFFmpegResources();
+     return false;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/media_file_checker.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/media_file_checker.cc
+--- a/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -68,7 +68,7 @@ bool MediaFileChecker::Start(base::TimeD
+       auto context = AVStreamToAVCodecContext(format_context->streams[i]);
+       if (!context)
+         continue;
+-      AVCodec* codec = avcodec_find_decoder(cp->codec_id);
++      const AVCodec* codec = avcodec_find_decoder(cp->codec_id);
+       if (codec && avcodec_open2(context.get(), codec, nullptr) >= 0) {
+         auto loop = std::make_unique<FFmpegDecodingLoop>(context.get());
+         stream_contexts[i] = {std::move(context), std::move(loop)};
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc qtwebengine-5.15.10/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc
+--- a/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -203,7 +203,7 @@ int32_t H264DecoderImpl::InitDecode(cons
+   // a pointer |this|.
+   av_context_->opaque = this;
+ 
+-  AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
+   if (!codec) {
+     // This is an indication that FFmpeg has not been initialized or it has not
+     // been compiled/initialized with the correct set of codecs.
diff --git a/srcpkgs/qt5-webengine/template b/srcpkgs/qt5-webengine/template
index 85267c7cf8a3f..095ab67701e42 100644
--- a/srcpkgs/qt5-webengine/template
+++ b/srcpkgs/qt5-webengine/template
@@ -1,9 +1,9 @@
 # Template file for 'qt5-webengine'
 pkgname=qt5-webengine
-version=5.15.11
-revision=3
+version=5.15.13
+revision=1
 _version="${version}-lts"
-_chromium_commit=be349eaf62e77955791d7bf29f893f1e8a37daf4
+_chromium_commit=e48df7803c7c98b0b2471c94057d32e44a301ad5
 archs="x86_64* i686* armv[67]* ppc64* aarch64*"
 create_wrksrc=yes
 build_style=qmake
@@ -32,8 +32,8 @@ license="GPL-3.0-or-later, LGPL-3.0-or-later"
 homepage="https://qt.io/"
 distfiles="https://github.com/qt/qtwebengine/archive/v${_version}.tar.gz
  https://github.com/qt/qtwebengine-chromium/archive/${_chromium_commit}.tar.gz"
-checksum="aa7466356c450c5f5870f979b93cd7e7e62da1165c328ffcab1a9928db18ad67
- 6f47ed8ab8cc062411f6f206da6353bc8263d6ed6d6290c689a05c01d91f646b"
+checksum="4b59838ed75ef788b59e1e412535a0e42dd9d311661fdeadb191b581ba815c63
+ a91686562b1d4e8b220e0bbcbab5feb64630e2de974b35ac034bf388af771a6c"
 
 no_generic_pkgconfig_link=yes
 build_options="sndio pipewire"

From b0ae3e027d81a0811713b8f043d7b5daf586e9b4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 073/113] qt5: update to 5.15.8

---
 ...erywhere-opensource-src-5.15.8-kf5-1.patch | 12913 ++++++++++++++++
 srcpkgs/qt5/template                          |    12 +-
 2 files changed, 12919 insertions(+), 6 deletions(-)
 create mode 100644 srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch

diff --git a/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch b/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch
new file mode 100644
index 0000000000000..966c98bcd3bb1
--- /dev/null
+++ b/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch
@@ -0,0 +1,12913 @@
+Submitted By:            Pierre Labastie <pierre_dot_labastie_at_neuf_dot_fr>
+Date:                    2023-01-05
+Initial Package Version: 5.15.8
+Upstream Status:         Applied (according to KDE)
+Origin:                  KDE patch set
+Description:             Patch set maintained by the KDE folks
+see https://dot.kde.org/2021/04/06/announcing-kdes-qt-5-patch-collection
+Patch generated using the procedure in
+https://wiki.linuxfromscratch.org/blfs/ticket/17476#comment:3
+
+Submodule qtbase 4ee4fc18..9cf586d6:
+diff --git a/qtbase/mkspecs/common/android/qplatformdefs.h b/qtbase/mkspecs/common/android/qplatformdefs.h
+index f75bc4093b..2bd59410d4 100644
+--- a/qtbase/mkspecs/common/android/qplatformdefs.h
++++ b/qtbase/mkspecs/common/android/qplatformdefs.h
+@@ -144,11 +144,7 @@
+ #define QT_SIGNAL_ARGS          int
+ #define QT_SIGNAL_IGNORE        SIG_IGN
+ 
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+ #define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+ 
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+diff --git a/qtbase/mkspecs/features/mac/sdk.mk b/qtbase/mkspecs/features/mac/sdk.mk
+index f30b5830b4..a32ceacb6c 100644
+--- a/qtbase/mkspecs/features/mac/sdk.mk
++++ b/qtbase/mkspecs/features/mac/sdk.mk
+@@ -1,6 +1,6 @@
+ 
+ ifeq ($(QT_MAC_SDK_NO_VERSION_CHECK),)
+-    CHECK_SDK_COMMAND = /usr/bin/xcrun --sdk $(EXPORT_QMAKE_MAC_SDK) -show-sdk-version 2>&1
++    CHECK_SDK_COMMAND = /usr/bin/xcrun --sdk $(EXPORT_QMAKE_MAC_SDK) -show-sdk-version 2>/dev/null
+     CURRENT_MAC_SDK_VERSION := $(shell DEVELOPER_DIR=$(EXPORT_QMAKE_XCODE_DEVELOPER_PATH) $(CHECK_SDK_COMMAND))
+     ifneq ($(CURRENT_MAC_SDK_VERSION),$(EXPORT_QMAKE_MAC_SDK_VERSION))
+         # We don't want to complain about out of date SDK unless the target needs to be remade.
+diff --git a/qtbase/mkspecs/linux-clang/qplatformdefs.h b/qtbase/mkspecs/linux-clang/qplatformdefs.h
+index a818d973f0..c1ab72fbc6 100644
+--- a/qtbase/mkspecs/linux-clang/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-clang/qplatformdefs.h
+@@ -79,14 +79,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-g++/qplatformdefs.h b/qtbase/mkspecs/linux-g++/qplatformdefs.h
+index 13523f0702..4d2750d9ec 100644
+--- a/qtbase/mkspecs/linux-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-g++/qplatformdefs.h
+@@ -79,14 +79,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ < 2)
+-#define QT_SOCKLEN_T            int
+-#else
+-#define QT_SOCKLEN_T            socklen_t
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-llvm/qplatformdefs.h b/qtbase/mkspecs/linux-llvm/qplatformdefs.h
+index dc750ab1ef..d3cc39b47f 100644
+--- a/qtbase/mkspecs/linux-llvm/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-llvm/qplatformdefs.h
+@@ -80,14 +80,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h b/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
+index 4c4e53da2a..83baffb3e3 100644
+--- a/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
+@@ -85,16 +85,9 @@
+ #include "../common/posix/qplatformdefs.h"
+ 
+ #undef QT_OPEN_LARGEFILE
+-#undef QT_SOCKLEN_T
+ 
+ #define QT_OPEN_LARGEFILE       0
+ 
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #ifndef SIOCGIFBRDADDR
+ #  define SIOCGIFBRDADDR 0x8919
+ #endif
+diff --git a/qtbase/mkspecs/lynxos-g++/qplatformdefs.h b/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
+index 4339ea2b23..6007af0055 100644
+--- a/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
+@@ -72,14 +72,6 @@
+ 
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp b/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
+index c3c184258f..32af3f8f29 100644
+--- a/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
++++ b/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
+@@ -10,6 +10,7 @@
+ #include "libANGLE/HandleAllocator.h"
+ 
+ #include <algorithm>
++#include <limits>
+ 
+ #include "common/debug.h"
+ 
+diff --git a/qtbase/src/3rdparty/forkfd/forkfd_linux.c b/qtbase/src/3rdparty/forkfd/forkfd_linux.c
+index ffe0e9a5e2..b1f5408d11 100644
+--- a/qtbase/src/3rdparty/forkfd/forkfd_linux.c
++++ b/qtbase/src/3rdparty/forkfd/forkfd_linux.c
+@@ -82,7 +82,8 @@ static int sys_clone(unsigned long cloneflags, int *ptid)
+     return syscall(__NR_clone, cloneflags, child_stack, stack_size, ptid, newtls, ctid);
+ #elif defined(__arc__) || defined(__arm__) || defined(__aarch64__) || defined(__mips__) || \
+     defined(__nds32__) || defined(__hppa__) || defined(__powerpc__) || defined(__i386__) || \
+-    defined(__x86_64__) || defined(__xtensa__) || defined(__alpha__) || defined(__riscv)
++    defined(__x86_64__) || defined(__xtensa__) || defined(__alpha__) || defined(__riscv) || \
++    defined(__loongarch__)
+     /* ctid and newtls are inverted on CONFIG_CLONE_BACKWARDS architectures,
+      * but since both values are 0, there's no harm. */
+     return syscall(__NR_clone, cloneflags, child_stack, ptid, ctid, newtls);
+diff --git a/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java b/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
+index 5792b5b2f5..2f74750fcf 100644
+--- a/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
++++ b/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
+@@ -116,6 +116,7 @@ public class QtNative
+     public static QtThread m_qtThread = new QtThread();
+     private static HashMap<String, Uri> m_cachedUris = new HashMap<String, Uri>();
+     private static ArrayList<String> m_knownDirs = new ArrayList<String>();
++    private static final String NoPermissionErrorMessage = "No permissions to open Uri";
+ 
+     private static final Runnable runPendingCppRunnablesRunnable = new Runnable() {
+         @Override
+@@ -193,11 +194,10 @@ public class QtNative
+                     return iterUri;
+             }
+ 
+-            // Android 6 and earlier could still manage to open the file so we can return the
+-            // parsed uri here
+-            if (Build.VERSION.SDK_INT < 24)
+-                return parsedUri;
+-            return null;
++            // if we only have transient permissions on uri all the above will fail,
++            // but we will be able to read the file anyway, so continue with uri here anyway
++            // and check for SecurityExceptions later
++            return parsedUri;
+         } catch (SecurityException e) {
+             e.printStackTrace();
+             return null;
+@@ -244,7 +244,7 @@ public class QtNative
+         int error = -1;
+ 
+         if (uri == null) {
+-            Log.e(QtTAG, "openFdForContentUrl(): No permissions to open Uri");
++            Log.e(QtTAG, "openFdForContentUrl(): " + NoPermissionErrorMessage);
+             return error;
+         }
+ 
+@@ -254,12 +254,13 @@ public class QtNative
+             return fdDesc.detachFd();
+         } catch (FileNotFoundException e) {
+             e.printStackTrace();
+-            return error;
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "openFdForContentUrl(): Invalid Uri");
+             e.printStackTrace();
+-            return error;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return error;
+     }
+ 
+     public static long getSize(Context context, String contentUrl)
+@@ -270,7 +271,7 @@ public class QtNative
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+ 
+         if (uri == null) {
+-            Log.e(QtTAG, "getSize(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return size;
+         } else if (!m_cachedUris.containsKey(contentUrl)) {
+             m_cachedUris.put(contentUrl, uri);
+@@ -288,12 +289,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "getSize(): Invalid Uri");
+             e.printStackTrace();
+-            return size;
+         }  catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "getSize(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return size;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return size;
+     }
+ 
+     public static boolean checkFileExists(Context context, String contentUrl)
+@@ -303,7 +305,7 @@ public class QtNative
+         if (uri == null)
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+         if (uri == null) {
+-            Log.e(QtTAG, "checkFileExists(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return exists;
+         } else {
+             if (!m_cachedUris.containsKey(contentUrl))
+@@ -321,12 +323,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "checkFileExists(): Invalid Uri");
+             e.printStackTrace();
+-            return exists;
+         } catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "checkFileExists(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return false;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return exists;
+     }
+ 
+     public static boolean checkIfWritable(Context context, String contentUrl)
+@@ -344,7 +347,7 @@ public class QtNative
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+         }
+         if (uri == null) {
+-            Log.e(QtTAG, "isDir(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return isDir;
+         } else {
+             if (!m_cachedUris.containsKey(contentUrl))
+@@ -374,12 +377,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "checkIfDir(): Invalid Uri");
+             e.printStackTrace();
+-            return false;
+         } catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "checkIfDir(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return false;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return false;
+     }
+     public static String[] listContentsFromTreeUri(Context context, String contentUrl)
+     {
+diff --git a/qtbase/src/concurrent/qtconcurrentreducekernel.h b/qtbase/src/concurrent/qtconcurrentreducekernel.h
+index 8f9a938952..a98dedef2e 100644
+--- a/qtbase/src/concurrent/qtconcurrentreducekernel.h
++++ b/qtbase/src/concurrent/qtconcurrentreducekernel.h
+@@ -212,11 +212,13 @@ public:
+ 
+     inline bool shouldThrottle()
+     {
++        std::lock_guard<QMutex> locker(mutex);
+         return (resultsMapSize > (ReduceQueueThrottleLimit * threadCount));
+     }
+ 
+     inline bool shouldStartThread()
+     {
++        std::lock_guard<QMutex> locker(mutex);
+         return (resultsMapSize <= (ReduceQueueStartLimit * threadCount));
+     }
+ };
+diff --git a/qtbase/src/concurrent/qtconcurrentthreadengine.cpp b/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
+index ea6ce3ac42..7f91a2ba68 100644
+--- a/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
++++ b/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
+@@ -176,6 +176,39 @@ void ThreadEngineBase::startSingleThreaded()
+     finish();
+ }
+ 
++void ThreadEngineBase::startBlocking()
++{
++    start();
++    barrier.acquire();
++    startThreads();
++
++    bool throttled = false;
++#ifndef QT_NO_EXCEPTIONS
++    try {
++#endif
++        while (threadFunction() == ThrottleThread) {
++            if (threadThrottleExit()) {
++                throttled = true;
++                break;
++            }
++        }
++#ifndef QT_NO_EXCEPTIONS
++    } catch (QException &e) {
++        handleException(e);
++    } catch (...) {
++        handleException(QUnhandledException());
++    }
++#endif
++
++    if (throttled == false) {
++        barrier.release();
++    }
++
++    barrier.wait();
++    finish();
++    exceptionStore.throwPossibleException();
++}
++
+ void ThreadEngineBase::startThread()
+ {
+     startThreadInternal();
+diff --git a/qtbase/src/concurrent/qtconcurrentthreadengine.h b/qtbase/src/concurrent/qtconcurrentthreadengine.h
+index 7c30cebdbc..a4c8548cc4 100644
+--- a/qtbase/src/concurrent/qtconcurrentthreadengine.h
++++ b/qtbase/src/concurrent/qtconcurrentthreadengine.h
+@@ -91,6 +91,7 @@ public:
+     ThreadEngineBase();
+     virtual ~ThreadEngineBase();
+     void startSingleThreaded();
++    void startBlocking();
+     void startThread();
+     bool isCanceled();
+     void waitForResume();
+@@ -143,6 +144,15 @@ public:
+         return result();
+     }
+ 
++    // Runs the user algorithm using multiple threads.
++    // This function blocks until the algorithm is finished,
++    // and then returns the result.
++    T *startBlocking()
++    {
++        ThreadEngineBase::startBlocking();
++        return result();
++    }
++
+     // Runs the user algorithm using multiple threads.
+     // Does not block, returns a future.
+     QFuture<T> startAsynchronously()
+@@ -223,6 +233,13 @@ class ThreadEngineStarter : public ThreadEngineStarterBase<T>
+ public:
+     ThreadEngineStarter(TypedThreadEngine *eng)
+         : Base(eng) { }
++
++    T startBlocking()
++    {
++        T t = *this->threadEngine->startBlocking();
++        delete this->threadEngine;
++        return t;
++    }
+ };
+ 
+ // Full template specialization where T is void.
+@@ -232,6 +249,12 @@ class ThreadEngineStarter<void> : public ThreadEngineStarterBase<void>
+ public:
+     ThreadEngineStarter(ThreadEngine<void> *_threadEngine)
+         : ThreadEngineStarterBase<void>(_threadEngine) {}
++
++    void startBlocking()
++    {
++        this->threadEngine->startBlocking();
++        delete this->threadEngine;
++    }
+ };
+ 
+ //! [qtconcurrentthreadengine-1]
+diff --git a/qtbase/src/corelib/animation/qvariantanimation.cpp b/qtbase/src/corelib/animation/qvariantanimation.cpp
+index 98b02f0202..eac1524107 100644
+--- a/qtbase/src/corelib/animation/qvariantanimation.cpp
++++ b/qtbase/src/corelib/animation/qvariantanimation.cpp
+@@ -276,7 +276,9 @@ void QVariantAnimationPrivate::setCurrentValueForProgress(const qreal progress)
+ 
+     const qreal startProgress = currentInterval.start.first;
+     const qreal endProgress = currentInterval.end.first;
+-    const qreal localProgress = (progress - startProgress) / (endProgress - startProgress);
++    const qreal localProgress =
++            qIsNull(progress - startProgress) ? 0.0 // avoid 0/0 below
++            /* else */                        : (progress - startProgress) / (endProgress - startProgress);
+ 
+     QVariant ret = q->interpolated(currentInterval.start.second,
+                                    currentInterval.end.second,
+diff --git a/qtbase/src/corelib/global/qnamespace.h b/qtbase/src/corelib/global/qnamespace.h
+index ad4150b317..bf19b1627b 100644
+--- a/qtbase/src/corelib/global/qnamespace.h
++++ b/qtbase/src/corelib/global/qnamespace.h
+@@ -1864,7 +1864,7 @@ public:
+     QT_Q_ENUM(TimerType)
+     QT_Q_ENUM(ScrollPhase)
+     QT_Q_ENUM(MouseEventSource)
+-    QT_Q_FLAG(MouseEventFlag)
++    QT_Q_FLAG(MouseEventFlags)
+     QT_Q_ENUM(ChecksumType)
+     QT_Q_ENUM(HighDpiScaleFactorRoundingPolicy)
+     QT_Q_ENUM(TabFocusBehavior)
+diff --git a/qtbase/src/corelib/global/qrandom.cpp b/qtbase/src/corelib/global/qrandom.cpp
+index 10672c1f92..25f87c7e6a 100644
+--- a/qtbase/src/corelib/global/qrandom.cpp
++++ b/qtbase/src/corelib/global/qrandom.cpp
+@@ -383,7 +383,6 @@ struct QRandomGenerator::SystemAndGlobalGenerators
+ 
+         constexpr SystemAndGlobalGenerators g = {};
+         Q_UNUSED(g);
+-        Q_STATIC_ASSERT(std::is_literal_type<SystemAndGlobalGenerators>::value);
+ #endif
+     }
+ 
+diff --git a/qtbase/src/corelib/io/qbuffer.cpp b/qtbase/src/corelib/io/qbuffer.cpp
+index 595fcd2724..032c0ddd4b 100644
+--- a/qtbase/src/corelib/io/qbuffer.cpp
++++ b/qtbase/src/corelib/io/qbuffer.cpp
+@@ -41,6 +41,8 @@
+ #include <QtCore/qmetaobject.h>
+ #include "private/qiodevice_p.h"
+ 
++#include <limits>
++
+ QT_BEGIN_NAMESPACE
+ 
+ /** QBufferPrivate **/
+@@ -366,7 +368,9 @@ qint64 QBuffer::size() const
+ bool QBuffer::seek(qint64 pos)
+ {
+     Q_D(QBuffer);
+-    if (pos > d->buf->size() && isWritable()) {
++    const auto oldBufSize = d->buf->size();
++    constexpr qint64 MaxSeekPos = (std::numeric_limits<decltype(oldBufSize)>::max)();
++    if (pos <= MaxSeekPos && pos > oldBufSize && isWritable()) {
+         if (seek(d->buf->size())) {
+             const qint64 gapSize = pos - d->buf->size();
+             if (write(QByteArray(gapSize, 0)) != gapSize) {
+@@ -377,7 +381,7 @@ bool QBuffer::seek(qint64 pos)
+             return false;
+         }
+     } else if (pos > d->buf->size() || pos < 0) {
+-        qWarning("QBuffer::seek: Invalid pos: %d", int(pos));
++        qWarning("QBuffer::seek: Invalid pos: %lld", pos);
+         return false;
+     }
+     return QIODevice::seek(pos);
+diff --git a/qtbase/src/corelib/io/qfilesystemengine_win.cpp b/qtbase/src/corelib/io/qfilesystemengine_win.cpp
+index 81d3a71986..c86ed1f9b0 100644
+--- a/qtbase/src/corelib/io/qfilesystemengine_win.cpp
++++ b/qtbase/src/corelib/io/qfilesystemengine_win.cpp
+@@ -664,14 +664,14 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry)
+     return QFileSystemEntry(ret, QFileSystemEntry::FromInternalPath());
+ }
+ 
+-#if defined(Q_CC_MINGW) && WINVER < 0x0602 //  Windows 8 onwards
++#if defined(Q_CC_MINGW) && WINVER < 0x0602 && _WIN32_WINNT < _WIN32_WINNT_WIN8 //  Windows 8 onwards
+ 
+ typedef struct _FILE_ID_INFO {
+     ULONGLONG VolumeSerialNumber;
+     FILE_ID_128 FileId;
+ } FILE_ID_INFO, *PFILE_ID_INFO;
+ 
+-#endif // if defined (Q_CC_MINGW) && WINVER < 0x0602
++#endif // if defined(Q_CC_MINGW) && WINVER < 0x0602 && _WIN32_WINNT < _WIN32_WINNT_WIN8
+ 
+ // File ID for Windows up to version 7 and FAT32 drives
+ static inline QByteArray fileId(HANDLE handle)
+diff --git a/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp b/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
+index 94d9d06bcb..27e0b13b0b 100644
+--- a/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
++++ b/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
+@@ -366,7 +366,9 @@ void QInotifyFileSystemWatcherEngine::readFromInotify()
+     // qDebug("QInotifyFileSystemWatcherEngine::readFromInotify");
+ 
+     int buffSize = 0;
+-    ioctl(inotifyFd, FIONREAD, (char *) &buffSize);
++    if (ioctl(inotifyFd, FIONREAD, (char *) &buffSize) == -1 || buffSize == 0)
++        return;
++
+     QVarLengthArray<char, 4096> buffer(buffSize);
+     buffSize = read(inotifyFd, buffer.data(), buffSize);
+     char *at = buffer.data();
+diff --git a/qtbase/src/corelib/io/qlockfile_win.cpp b/qtbase/src/corelib/io/qlockfile_win.cpp
+index 277f8d4230..38ecef5550 100644
+--- a/qtbase/src/corelib/io/qlockfile_win.cpp
++++ b/qtbase/src/corelib/io/qlockfile_win.cpp
+@@ -48,6 +48,8 @@
+ #include "QtCore/qdebug.h"
+ #include "QtCore/qthread.h"
+ 
++#include "private/qsystemlibrary_p.h"
++
+ QT_BEGIN_NAMESPACE
+ 
+ static inline bool fileExists(const wchar_t *fileName)
+@@ -150,7 +152,7 @@ QString QLockFilePrivate::processNameByPid(qint64 pid)
+ #if !defined(Q_OS_WINRT)
+     typedef DWORD (WINAPI *GetModuleFileNameExFunc)(HANDLE, HMODULE, LPTSTR, DWORD);
+ 
+-    HMODULE hPsapi = LoadLibraryA("psapi");
++    HMODULE hPsapi = QSystemLibrary::load(L"psapi");
+     if (!hPsapi)
+         return QString();
+     GetModuleFileNameExFunc qGetModuleFileNameEx = reinterpret_cast<GetModuleFileNameExFunc>(
+diff --git a/qtbase/src/corelib/io/qprocess_unix.cpp b/qtbase/src/corelib/io/qprocess_unix.cpp
+index 50390e57f5..15c8f30745 100644
+--- a/qtbase/src/corelib/io/qprocess_unix.cpp
++++ b/qtbase/src/corelib/io/qprocess_unix.cpp
+@@ -1,7 +1,7 @@
+ /****************************************************************************
+ **
+ ** Copyright (C) 2016 The Qt Company Ltd.
+-** Copyright (C) 2016 Intel Corporation.
++** Copyright (C) 2022 Intel Corporation.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtCore module of the Qt Toolkit.
+@@ -422,14 +422,15 @@ void QProcessPrivate::startProcess()
+     // Add the program name to the argument list.
+     argv[0] = nullptr;
+     if (!program.contains(QLatin1Char('/'))) {
++        // findExecutable() returns its argument if it's an absolute path,
++        // otherwise it searches $PATH; returns empty if not found (we handle
++        // that case much later)
+         const QString &exeFilePath = QStandardPaths::findExecutable(program);
+-        if (!exeFilePath.isEmpty()) {
+-            const QByteArray &tmp = QFile::encodeName(exeFilePath);
+-            argv[0] = ::strdup(tmp.constData());
+-        }
+-    }
+-    if (!argv[0])
++        const QByteArray &tmp = QFile::encodeName(exeFilePath);
++        argv[0] = ::strdup(tmp.constData());
++    } else {
+         argv[0] = ::strdup(encodedProgramName.constData());
++    }
+ 
+     // Add every argument to the list
+     for (int i = 0; i < arguments.count(); ++i)
+@@ -983,15 +984,16 @@ bool QProcessPrivate::startDetached(qint64 *pid)
+                 envp = _q_dupEnvironment(environment.d.constData()->vars, &envc);
+             }
+ 
+-            QByteArray tmp;
+             if (!program.contains(QLatin1Char('/'))) {
++                // findExecutable() returns its argument if it's an absolute path,
++                // otherwise it searches $PATH; returns empty if not found (we handle
++                // that case much later)
+                 const QString &exeFilePath = QStandardPaths::findExecutable(program);
+-                if (!exeFilePath.isEmpty())
+-                    tmp = QFile::encodeName(exeFilePath);
++                const QByteArray &tmp = QFile::encodeName(exeFilePath);
++                argv[0] = ::strdup(tmp.constData());
++            } else {
++                argv[0] = ::strdup(QFile::encodeName(program));
+             }
+-            if (tmp.isEmpty())
+-                tmp = QFile::encodeName(program);
+-            argv[0] = tmp.data();
+ 
+             if (envp)
+                 qt_safe_execve(argv[0], argv, envp);
+diff --git a/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp b/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
+index 3a79c502af..997a634e76 100644
+--- a/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
++++ b/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
+@@ -3196,9 +3196,8 @@ bool QAbstractItemModel::beginMoveColumns(const QModelIndex &sourceParent, int s
+     destinationChange.needsAdjust = destinationParent.isValid() && destinationParent.row() >= sourceLast && destinationParent.parent() == sourceParent;
+     d->changes.push(destinationChange);
+ 
+-    d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Horizontal);
+-
+     emit columnsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, QPrivateSignal());
++    d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Horizontal);
+     return true;
+ }
+ 
+@@ -3231,7 +3230,6 @@ void QAbstractItemModel::endMoveColumns()
+       adjustedSource = createIndex(adjustedSource.row(), adjustedSource.column() + numMoved, adjustedSource.internalPointer());
+ 
+     d->itemsMoved(adjustedSource, removeChange.first, removeChange.last, adjustedDestination, insertChange.first, Qt::Horizontal);
+-
+     emit columnsMoved(adjustedSource, removeChange.first, removeChange.last, adjustedDestination, insertChange.first, QPrivateSignal());
+ }
+ 
+diff --git a/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+index dc6379d9fb..c5e287ee84 100644
+--- a/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
++++ b/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+@@ -939,8 +939,9 @@ void QSortFilterProxyModelPrivate::insert_source_items(
+                 q->beginInsertColumns(proxy_parent, proxy_start, proxy_end);
+         }
+ 
+-        for (int i = 0; i < source_items.size(); ++i)
+-            proxy_to_source.insert(proxy_start + i, source_items.at(i));
++        // TODO: use the range QList::insert() overload once it is implemented (QTBUG-58633).
++        proxy_to_source.insert(proxy_start, source_items.size(), 0);
++        std::copy(source_items.cbegin(), source_items.cend(), proxy_to_source.begin() + proxy_start);
+ 
+         build_source_to_proxy_mapping(proxy_to_source, source_to_proxy);
+ 
+@@ -3123,8 +3124,9 @@ bool QSortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex &
+ 
+     if (d->filter_data.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();
+@@ -3133,9 +3135,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.hasMatch(key);
+ }
+diff --git a/qtbase/src/corelib/kernel/qcoreapplication.cpp b/qtbase/src/corelib/kernel/qcoreapplication.cpp
+index ca2864df83..132b2eae52 100644
+--- a/qtbase/src/corelib/kernel/qcoreapplication.cpp
++++ b/qtbase/src/corelib/kernel/qcoreapplication.cpp
+@@ -1157,7 +1157,7 @@ static bool doNotify(QObject *receiver, QEvent *event)
+ bool QCoreApplicationPrivate::sendThroughApplicationEventFilters(QObject *receiver, QEvent *event)
+ {
+     // We can't access the application event filters outside of the main thread (race conditions)
+-    Q_ASSERT(receiver->d_func()->threadData.loadRelaxed()->thread.loadAcquire() == mainThread());
++    Q_ASSERT(receiver->d_func()->threadData.loadAcquire()->thread.loadRelaxed() == mainThread());
+ 
+     if (extraData) {
+         // application event filters are only called for objects in the GUI thread
+diff --git a/qtbase/src/corelib/kernel/qobject.cpp b/qtbase/src/corelib/kernel/qobject.cpp
+index 1eb79138d9..36cd780ee1 100644
+--- a/qtbase/src/corelib/kernel/qobject.cpp
++++ b/qtbase/src/corelib/kernel/qobject.cpp
+@@ -1010,7 +1010,7 @@ QObject::~QObject()
+         emit destroyed(this);
+     }
+ 
+-    if (d->declarativeData) {
++    if (!d->isDeletingChildren && d->declarativeData) {
+         if (static_cast<QAbstractDeclarativeDataImpl*>(d->declarativeData)->ownedByQml1) {
+             if (QAbstractDeclarativeData::destroyed_qml1)
+                 QAbstractDeclarativeData::destroyed_qml1(d->declarativeData, this);
+@@ -1580,7 +1580,7 @@ void QObject::moveToThread(QThread *targetThread)
+ 
+     QThreadData *currentData = QThreadData::current();
+     QThreadData *targetData = targetThread ? QThreadData::get2(targetThread) : nullptr;
+-    QThreadData *thisThreadData = d->threadData.loadRelaxed();
++    QThreadData *thisThreadData = d->threadData.loadAcquire();
+     if (!thisThreadData->thread.loadAcquire() && currentData == targetData) {
+         // one exception to the rule: we allow moving objects with no thread affinity to the current thread
+         currentData = d->threadData;
+@@ -2620,7 +2620,7 @@ int QObject::receivers(const char *signal) const
+         if (!d->isSignalConnected(signal_index))
+             return receivers;
+ 
+-        if (d->declarativeData && QAbstractDeclarativeData::receivers) {
++        if (!d->isDeletingChildren && d->declarativeData && QAbstractDeclarativeData::receivers) {
+             receivers += QAbstractDeclarativeData::receivers(d->declarativeData, this,
+                                                              signal_index);
+         }
+diff --git a/qtbase/src/corelib/kernel/qobject_p.h b/qtbase/src/corelib/kernel/qobject_p.h
+index 0b827a52ca..13ffb88999 100644
+--- a/qtbase/src/corelib/kernel/qobject_p.h
++++ b/qtbase/src/corelib/kernel/qobject_p.h
+@@ -444,7 +444,7 @@ inline void QObjectPrivate::checkForIncompatibleLibraryVersion(int version) cons
+ 
+ inline bool QObjectPrivate::isDeclarativeSignalConnected(uint signal_index) const
+ {
+-    return declarativeData && QAbstractDeclarativeData::isSignalConnected
++    return !isDeletingChildren && declarativeData && QAbstractDeclarativeData::isSignalConnected
+             && QAbstractDeclarativeData::isSignalConnected(declarativeData, q_func(), signal_index);
+ }
+ 
+diff --git a/qtbase/src/corelib/kernel/qtranslator.cpp b/qtbase/src/corelib/kernel/qtranslator.cpp
+index 2812ffb7ea..bc0177c5ec 100644
+--- a/qtbase/src/corelib/kernel/qtranslator.cpp
++++ b/qtbase/src/corelib/kernel/qtranslator.cpp
+@@ -902,7 +902,7 @@ static QString getMessage(const uchar *m, const uchar *end, const char *context,
+             goto end;
+         case Tag_Translation: {
+             int len = read32(m);
+-            if (len % 1)
++            if (len & 1)
+                 return QString();
+             m += 4;
+             if (!numerus--) {
+diff --git a/qtbase/src/corelib/mimetypes/qmimedatabase.cpp b/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
+index 9de22cef33..ff868a3268 100644
+--- a/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
+@@ -389,20 +389,23 @@ QMimeType QMimeDatabasePrivate::mimeTypeForFileNameAndData(const QString &fileNa
+         // Disambiguate conflicting extensions (if magic matching found something)
+         if (candidateByData.isValid() && magicAccuracy > 0) {
+             const QString sniffedMime = candidateByData.name();
+-            // If the sniffedMime matches a glob match, use it
++            // If the sniffedMime matches a highest-weight glob match, use it
+             if (candidatesByName.m_matchingMimeTypes.contains(sniffedMime)) {
+                 *accuracyPtr = 100;
+                 return candidateByData;
+             }
+-            for (const QString &m : qAsConst(candidatesByName.m_matchingMimeTypes)) {
++            for (const QString &m : qAsConst(candidatesByName.m_allMatchingMimeTypes)) {
+                 if (inherits(m, sniffedMime)) {
+                     // We have magic + pattern pointing to this, so it's a pretty good match
+                     *accuracyPtr = 100;
+                     return mimeTypeForName(m);
+                 }
+             }
+-            *accuracyPtr = magicAccuracy;
+-            return candidateByData;
++            if (candidatesByName.m_allMatchingMimeTypes.isEmpty()) {
++                // No glob, use magic
++                *accuracyPtr = magicAccuracy;
++                return candidateByData;
++            }
+         }
+     }
+ 
+diff --git a/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp b/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
+index a81112d227..fa8f4c545d 100644
+--- a/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
+@@ -83,7 +83,10 @@ void QMimeGlobMatchResult::addMatch(const QString &mimeType, int weight, const Q
+     }
+     if (!m_matchingMimeTypes.contains(mimeType)) {
+         m_matchingMimeTypes.append(mimeType);
+-        m_allMatchingMimeTypes.append(mimeType);
++        if (replace)
++            m_allMatchingMimeTypes.prepend(mimeType); // highest-weight first
++        else
++            m_allMatchingMimeTypes.append(mimeType);
+         m_knownSuffixLength = knownSuffixLength;
+     }
+ }
+@@ -94,7 +97,7 @@ QMimeGlobPattern::PatternType QMimeGlobPattern::detectPatternType(const QString
+     if (!patternLength)
+         return OtherPattern;
+ 
+-    const bool starCount = pattern.count(QLatin1Char('*')) == 1;
++    const int starCount = pattern.count(QLatin1Char('*'));
+     const bool hasSquareBracket = pattern.indexOf(QLatin1Char('[')) != -1;
+     const bool hasQuestionMark = pattern.indexOf(QLatin1Char('?')) != -1;
+ 
+@@ -106,10 +109,10 @@ QMimeGlobPattern::PatternType QMimeGlobPattern::detectPatternType(const QString
+             // Patterns like "README*" (well this is currently the only one like that...)
+             if (pattern.at(patternLength - 1) == QLatin1Char('*'))
+                 return PrefixPattern;
+-        }
+-        // Names without any wildcards like "README"
+-        if (starCount == 0)
++        } else if (starCount == 0) {
++            // Names without any wildcards like "README"
+             return LiteralPattern;
++        }
+     }
+ 
+     if (pattern == QLatin1String("[0-9][0-9][0-9].vdr"))
+diff --git a/qtbase/src/corelib/mimetypes/qmimeprovider.cpp b/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
+index 258dddf8cb..4642d0f2d0 100644
+--- a/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
+@@ -244,15 +244,18 @@ void QMimeBinaryProvider::addFileNameMatches(const QString &fileName, QMimeGlobM
+     const QString lowerFileName = fileName.toLower();
+     // Check literals (e.g. "Makefile")
+     matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosLiteralListOffset), fileName);
+-    // Check complex globs (e.g. "callgrind.out[0-9]*")
+-    matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosGlobListOffset), fileName);
+     // Check the very common *.txt cases with the suffix tree
+-    const int reverseSuffixTreeOffset = m_cacheFile->getUint32(PosReverseSuffixTreeOffset);
+-    const int numRoots = m_cacheFile->getUint32(reverseSuffixTreeOffset);
+-    const int firstRootOffset = m_cacheFile->getUint32(reverseSuffixTreeOffset + 4);
+-    matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, lowerFileName, lowerFileName.length() - 1, false);
++    if (result.m_matchingMimeTypes.isEmpty()) {
++        const int reverseSuffixTreeOffset = m_cacheFile->getUint32(PosReverseSuffixTreeOffset);
++        const int numRoots = m_cacheFile->getUint32(reverseSuffixTreeOffset);
++        const int firstRootOffset = m_cacheFile->getUint32(reverseSuffixTreeOffset + 4);
++        matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, lowerFileName, lowerFileName.length() - 1, false);
++        if (result.m_matchingMimeTypes.isEmpty())
++            matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, fileName, fileName.length() - 1, true);
++    }
++    // Check complex globs (e.g. "callgrind.out[0-9]*" or "README*")
+     if (result.m_matchingMimeTypes.isEmpty())
+-        matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, fileName, fileName.length() - 1, true);
++        matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosGlobListOffset), fileName);
+ }
+ 
+ void QMimeBinaryProvider::matchGlobList(QMimeGlobMatchResult &result, CacheFile *cacheFile, int off, const QString &fileName)
+diff --git a/qtbase/src/corelib/serialization/qjsonparser.cpp b/qtbase/src/corelib/serialization/qjsonparser.cpp
+index 17e6f111ab..2e40b6c8fb 100644
+--- a/qtbase/src/corelib/serialization/qjsonparser.cpp
++++ b/qtbase/src/corelib/serialization/qjsonparser.cpp
+@@ -379,10 +379,30 @@ error:
+     return QCborValue();
+ }
+ 
++// We need to retain the _last_ value for any duplicate keys and we need to deref containers.
++// Therefore the manual implementation of std::unique().
++template<typename Iterator, typename Compare, typename Assign>
++static Iterator customAssigningUniqueLast(Iterator first, Iterator last,
++                                          Compare compare, Assign assign)
++{
++    first = std::adjacent_find(first, last, compare);
++    if (first == last)
++        return last;
++
++    Iterator result = first;
++    while (++first != last) {
++        if (!compare(*result, *first))
++            ++result;
++        if (result != first)
++            assign(*result, *first);
++    }
++
++    return ++result;
++}
++
+ static void sortContainer(QCborContainerPrivate *container)
+ {
+     using Forward = QJsonPrivate::KeyIterator;
+-    using Reverse = std::reverse_iterator<Forward>;
+     using Value = Forward::value_type;
+ 
+     auto compare = [container](const Value &a, const Value &b)
+@@ -420,17 +440,31 @@ static void sortContainer(QCborContainerPrivate *container)
+         }
+     };
+ 
+-    std::sort(Forward(container->elements.begin()), Forward(container->elements.end()),
+-              [&compare](const Value &a, const Value &b) { return compare(a, b) < 0; });
++    // The elements' containers are owned by the outer container, not by the elements themselves.
++    auto move = [](Forward::reference target, Forward::reference source)
++    {
++        QtCbor::Element &targetValue = target.value();
++
++        // If the target has a container, deref it before overwriting, so that we don't leak.
++        if (targetValue.flags & QtCbor::Element::IsContainer)
++            targetValue.container->deref();
++
++        // Do not move, so that we can clear the value afterwards.
++        target = source;
++
++        // Clear the source value, so that we don't store the same container twice.
++        source.value() = QtCbor::Element();
++    };
++
++    std::stable_sort(
++                Forward(container->elements.begin()), Forward(container->elements.end()),
++                [&compare](const Value &a, const Value &b) { return compare(a, b) < 0; });
+ 
+-    // We need to retain the _last_ value for any duplicate keys. Therefore the reverse dance here.
+-    auto it = std::unique(Reverse(container->elements.end()), Reverse(container->elements.begin()),
+-                          [&compare](const Value &a, const Value &b) {
+-        return compare(a, b) == 0;
+-    }).base().elementsIterator();
++    Forward result = customAssigningUniqueLast(
++                Forward(container->elements.begin()),  Forward(container->elements.end()),
++                [&compare](const Value &a, const Value &b) { return compare(a, b) == 0; }, move);
+ 
+-    // The erase from beginning is expensive but hopefully rare.
+-    container->elements.erase(container->elements.begin(), it);
++    container->elements.erase(result.elementsIterator(), container->elements.end());
+ }
+ 
+ 
+diff --git a/qtbase/src/corelib/serialization/qxmlstream.cpp b/qtbase/src/corelib/serialization/qxmlstream.cpp
+index b2f846544d..7cd457ba3a 100644
+--- a/qtbase/src/corelib/serialization/qxmlstream.cpp
++++ b/qtbase/src/corelib/serialization/qxmlstream.cpp
+@@ -980,7 +980,7 @@ inline uint QXmlStreamReaderPrivate::peekChar()
+ bool QXmlStreamReaderPrivate::scanUntil(const char *str, short tokenToInject)
+ {
+     int pos = textBuffer.size();
+-    int oldLineNumber = lineNumber;
++    const auto oldLineNumber = lineNumber;
+ 
+     uint c;
+     while ((c = getChar()) != StreamEOF) {
+diff --git a/qtbase/src/corelib/text/qstring.cpp b/qtbase/src/corelib/text/qstring.cpp
+index 3e88ab4859..8deeae47bb 100644
+--- a/qtbase/src/corelib/text/qstring.cpp
++++ b/qtbase/src/corelib/text/qstring.cpp
+@@ -12312,7 +12312,7 @@ static qsizetype qLastIndexOf(Haystack haystack0, qsizetype from,
+     const auto needle = needle0.data();
+     const auto *end = haystack;
+     haystack += from;
+-    const std::size_t sl_minus_1 = sl - 1;
++    const std::size_t sl_minus_1 = sl ? sl - 1 : 0;
+     const auto *n = needle + sl_minus_1;
+     const auto *h = haystack + sl_minus_1;
+     std::size_t hashNeedle = 0, hashHaystack = 0;
+diff --git a/qtbase/src/corelib/text/qstringiterator_p.h b/qtbase/src/corelib/text/qstringiterator_p.h
+index 219589b6e4..1d0c66cc78 100644
+--- a/qtbase/src/corelib/text/qstringiterator_p.h
++++ b/qtbase/src/corelib/text/qstringiterator_p.h
+@@ -61,6 +61,8 @@ class QStringIterator
+ {
+     QString::const_iterator i, pos, e;
+     Q_STATIC_ASSERT((std::is_same<QString::const_iterator, const QChar *>::value));
++    static bool less(const QChar *lhs, const QChar *rhs) noexcept
++    { return std::less<QString::const_iterator>{}(lhs, rhs); }
+ public:
+     explicit QStringIterator(QStringView string, qsizetype idx = 0)
+         : i(string.begin()),
+@@ -95,7 +97,8 @@ public:
+ 
+     inline void setPosition(QString::const_iterator position)
+     {
+-        Q_ASSERT_X(i <= position && position <= e, Q_FUNC_INFO, "position out of bounds");
++        Q_ASSERT_X(!less(position, i) && !less(e, position),
++                   Q_FUNC_INFO, "position out of bounds");
+         pos = position;
+     }
+ 
+@@ -103,7 +106,7 @@ public:
+ 
+     inline bool hasNext() const
+     {
+-        return pos < e;
++        return less(pos, e);
+     }
+ 
+     inline void advance()
+@@ -120,16 +123,20 @@ public:
+     {
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+-        if (Q_UNLIKELY((pos++)->isHighSurrogate()))
++        if (Q_UNLIKELY((pos++)->isHighSurrogate())) {
++            Q_ASSERT(hasNext() && pos->isLowSurrogate());
+             ++pos;
++        }
+     }
+ 
+     inline uint peekNextUnchecked() const
+     {
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+-        if (Q_UNLIKELY(pos->isHighSurrogate()))
++        if (Q_UNLIKELY(pos->isHighSurrogate())) {
++            Q_ASSERT(less(pos + 1, e) && pos[1].isLowSurrogate());
+             return QChar::surrogateToUcs4(pos[0], pos[1]);
++        }
+ 
+         return pos->unicode();
+     }
+@@ -155,8 +162,10 @@ public:
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+         const QChar cur = *pos++;
+-        if (Q_UNLIKELY(cur.isHighSurrogate()))
++        if (Q_UNLIKELY(cur.isHighSurrogate())) {
++            Q_ASSERT(hasNext() && pos->isLowSurrogate());
+             return QChar::surrogateToUcs4(cur, *pos++);
++        }
+         return cur.unicode();
+     }
+ 
+@@ -166,7 +175,7 @@ public:
+ 
+         const QChar uc = *pos++;
+         if (Q_UNLIKELY(uc.isSurrogate())) {
+-            if (Q_LIKELY(uc.isHighSurrogate() && pos < e && pos->isLowSurrogate()))
++            if (Q_LIKELY(uc.isHighSurrogate() && hasNext() && pos->isLowSurrogate()))
+                 return QChar::surrogateToUcs4(uc, *pos++);
+             return invalidAs;
+         }
+@@ -178,7 +187,7 @@ public:
+ 
+     inline bool hasPrevious() const
+     {
+-        return pos > i;
++        return less(i, pos);
+     }
+ 
+     inline void recede()
+@@ -196,16 +205,20 @@ public:
+     {
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+-        if (Q_UNLIKELY((--pos)->isLowSurrogate()))
++        if (Q_UNLIKELY((--pos)->isLowSurrogate())) {
++            Q_ASSERT(hasPrevious() && pos[-1].isHighSurrogate());
+             --pos;
++        }
+     }
+ 
+     inline uint peekPreviousUnchecked() const
+     {
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+-        if (Q_UNLIKELY(pos[-1].isLowSurrogate()))
++        if (Q_UNLIKELY(pos[-1].isLowSurrogate())) {
++            Q_ASSERT(less(i + 1, pos) && pos[-2].isHighSurrogate());
+             return QChar::surrogateToUcs4(pos[-2], pos[-1]);
++        }
+         return pos[-1].unicode();
+     }
+ 
+@@ -230,8 +243,10 @@ public:
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+         const QChar cur = *--pos;
+-        if (Q_UNLIKELY(cur.isLowSurrogate()))
++        if (Q_UNLIKELY(cur.isLowSurrogate())) {
++            Q_ASSERT(hasPrevious() && pos[-1].isHighSurrogate());
+             return QChar::surrogateToUcs4(*--pos, cur);
++        }
+         return cur.unicode();
+     }
+ 
+@@ -241,7 +256,7 @@ public:
+ 
+         const QChar uc = *--pos;
+         if (Q_UNLIKELY(uc.isSurrogate())) {
+-            if (Q_LIKELY(uc.isLowSurrogate() && pos > i && pos[-1].isHighSurrogate()))
++            if (Q_LIKELY(uc.isLowSurrogate() && hasPrevious() && pos[-1].isHighSurrogate()))
+                 return QChar::surrogateToUcs4(*--pos, uc);
+             return invalidAs;
+         }
+diff --git a/qtbase/src/corelib/thread/qfutex_p.h b/qtbase/src/corelib/thread/qfutex_p.h
+index f287b752d7..e294537787 100644
+--- a/qtbase/src/corelib/thread/qfutex_p.h
++++ b/qtbase/src/corelib/thread/qfutex_p.h
+@@ -52,6 +52,7 @@
+ //
+ 
+ #include <qglobal.h>
++#include <QtCore/qtsan_impl.h>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -106,16 +107,13 @@ namespace QtLinuxFutex {
+     inline int _q_futex(int *addr, int op, int val, quintptr val2 = 0,
+                         int *addr2 = nullptr, int val3 = 0) noexcept
+     {
+-        // A futex call ensures total ordering on the futex words
+-        // (in either success or failure of the call). Instruct TSAN accordingly,
+-        // as TSAN does not understand the futex(2) syscall.
+-        _q_tsan_release(addr, addr2);
++        QtTsan::futexRelease(addr, addr2);
+ 
+         // we use __NR_futex because some libcs (like Android's bionic) don't
+         // provide SYS_futex etc.
+         int result = syscall(__NR_futex, addr, op | FUTEX_PRIVATE_FLAG, val, val2, addr2, val3);
+ 
+-        _q_tsan_acquire(addr, addr2);
++        QtTsan::futexAcquire(addr, addr2);
+ 
+         return result;
+     }
+diff --git a/qtbase/src/corelib/thread/qmutex.cpp b/qtbase/src/corelib/thread/qmutex.cpp
+index 310d1cb14f..7097122d8e 100644
+--- a/qtbase/src/corelib/thread/qmutex.cpp
++++ b/qtbase/src/corelib/thread/qmutex.cpp
+@@ -152,6 +152,7 @@ public:
+ 
+ /*!
+     \enum QMutex::RecursionMode
++    \obsolete Use QRecursiveMutex to create a recursive mutex.
+ 
+     \value Recursive  In this mode, a thread can lock the same mutex
+                       multiple times and the mutex won't be unlocked
+@@ -173,6 +174,7 @@ public:
+ 
+ /*!
+     Constructs a new mutex. The mutex is created in an unlocked state.
++    \obsolete Use QRecursiveMutex to create a recursive mutex.
+ 
+     If \a mode is QMutex::Recursive, a thread can lock the same mutex
+     multiple times and the mutex won't be unlocked until a
+@@ -197,7 +199,7 @@ QMutex::QMutex(RecursionMode mode)
+ QMutex::~QMutex()
+ {
+     QMutexData *d = d_ptr.loadRelaxed();
+-    if (isRecursive()) {
++    if (QBasicMutex::isRecursive()) {
+         delete static_cast<QRecursiveMutexPrivate *>(d);
+     } else if (d) {
+ #ifndef QT_LINUX_FUTEX
+diff --git a/qtbase/src/corelib/thread/qmutex.h b/qtbase/src/corelib/thread/qmutex.h
+index 73c9e00663..1bae573a03 100644
+--- a/qtbase/src/corelib/thread/qmutex.h
++++ b/qtbase/src/corelib/thread/qmutex.h
+@@ -42,6 +42,7 @@
+ 
+ #include <QtCore/qglobal.h>
+ #include <QtCore/qatomic.h>
++#include <QtCore/qtsan_impl.h>
+ #include <new>
+ 
+ #if __has_include(<chrono>)
+@@ -77,19 +78,37 @@ public:
+ 
+     // BasicLockable concept
+     inline void lock() QT_MUTEX_LOCK_NOEXCEPT {
++        QtTsan::mutexPreLock(this, 0u);
++
+         if (!fastTryLock())
+             lockInternal();
++
++        QtTsan::mutexPostLock(this, 0u, 0);
+     }
+ 
+     // BasicLockable concept
+     inline void unlock() noexcept {
+         Q_ASSERT(d_ptr.loadRelaxed()); //mutex must be locked
++
++        QtTsan::mutexPreUnlock(this, 0u);
++
+         if (!fastTryUnlock())
+             unlockInternal();
++
++        QtTsan::mutexPostUnlock(this, 0u);
+     }
+ 
+     bool tryLock() noexcept {
+-        return fastTryLock();
++        unsigned tsanFlags = QtTsan::TryLock;
++        QtTsan::mutexPreLock(this, tsanFlags);
++
++        const bool success = fastTryLock();
++
++        if (!success)
++            tsanFlags |= QtTsan::TryLockFailed;
++        QtTsan::mutexPostLock(this, tsanFlags, 0);
++
++        return success;
+     }
+ 
+     // Lockable concept
+@@ -134,8 +153,16 @@ public:
+ #else
+     QMutex() { d_ptr.storeRelaxed(nullptr); }
+ #endif
++#if QT_DEPRECATED_SINCE(5,15)
+     enum RecursionMode { NonRecursive, Recursive };
++    QT_DEPRECATED_VERSION_X(5, 15, "Use QRecursiveMutex instead of a recursive QMutex")
+     explicit QMutex(RecursionMode mode);
++
++    QT_DEPRECATED_VERSION_X(5, 15, "Use QRecursiveMutex instead of a recursive QMutex")
++    bool isRecursive() const noexcept
++    { return QBasicMutex::isRecursive(); }
++#endif
++
+     ~QMutex();
+ 
+     // BasicLockable concept
+@@ -166,9 +193,6 @@ public:
+     }
+ #endif
+ 
+-    bool isRecursive() const noexcept
+-    { return QBasicMutex::isRecursive(); }
+-
+ private:
+     Q_DISABLE_COPY(QMutex)
+     friend class QMutexLocker;
+diff --git a/qtbase/src/corelib/thread/qreadwritelock.cpp b/qtbase/src/corelib/thread/qreadwritelock.cpp
+index 8c28507d5a..9dd8503116 100644
+--- a/qtbase/src/corelib/thread/qreadwritelock.cpp
++++ b/qtbase/src/corelib/thread/qreadwritelock.cpp
+@@ -155,7 +155,7 @@ QReadWriteLock::QReadWriteLock(RecursionMode recursionMode)
+ */
+ QReadWriteLock::~QReadWriteLock()
+ {
+-    auto d = d_ptr.loadRelaxed();
++    auto d = d_ptr.loadAcquire();
+     if (isUncontendedLocked(d)) {
+         qWarning("QReadWriteLock: destroying locked QReadWriteLock");
+         return;
+@@ -445,7 +445,7 @@ void QReadWriteLock::unlock()
+ /*! \internal  Helper for QWaitCondition::wait */
+ QReadWriteLock::StateForWaitCondition QReadWriteLock::stateForWaitCondition() const
+ {
+-    QReadWriteLockPrivate *d = d_ptr.loadRelaxed();
++    QReadWriteLockPrivate *d = d_ptr.loadAcquire();
+     switch (quintptr(d) & StateMask) {
+     case StateLockedForRead: return LockedForRead;
+     case StateLockedForWrite: return LockedForWrite;
+@@ -453,6 +453,7 @@ QReadWriteLock::StateForWaitCondition QReadWriteLock::stateForWaitCondition() co
+ 
+     if (!d)
+         return Unlocked;
++    const auto lock = qt_scoped_lock(d->mutex);
+     if (d->writerCount > 1)
+         return RecursivelyLocked;
+     else if (d->writerCount == 1)
+diff --git a/qtbase/src/corelib/thread/qsemaphore.cpp b/qtbase/src/corelib/thread/qsemaphore.cpp
+index 1d01fc1b28..3ecdee3747 100644
+--- a/qtbase/src/corelib/thread/qsemaphore.cpp
++++ b/qtbase/src/corelib/thread/qsemaphore.cpp
+@@ -354,7 +354,12 @@ void QSemaphore::release(int n)
+         quintptr nn = unsigned(n);
+         if (futexHasWaiterCount)
+             nn |= quint64(nn) << 32;    // token count replicated in high word
+-        quintptr prevValue = u.fetchAndAddRelease(nn);
++        quintptr prevValue = u.loadRelaxed();
++        quintptr newValue;
++        do { // loop just to ensure the operations are done atomically
++            newValue = prevValue + nn;
++            newValue &= (futexNeedsWakeAllBit - 1);
++        } while (!u.testAndSetRelease(prevValue, newValue, prevValue));
+         if (futexNeedsWake(prevValue)) {
+ #ifdef FUTEX_OP
+             if (futexHasWaiterCount) {
+@@ -376,7 +381,6 @@ void QSemaphore::release(int n)
+                 quint32 oparg = 0;
+                 quint32 cmp = FUTEX_OP_CMP_NE;
+                 quint32 cmparg = 0;
+-                u.fetchAndAndRelease(futexNeedsWakeAllBit - 1);
+                 futexWakeOp(*futexLow32(&u), n, INT_MAX, *futexHigh32(&u), FUTEX_OP(op, oparg, cmp, cmparg));
+                 return;
+             }
+@@ -388,7 +392,6 @@ 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(futexNeedsWakeAllBit - 1);
+             if (futexHasWaiterCount) {
+                 futexWakeAll(*futexLow32(&u));
+                 futexWakeAll(*futexHigh32(&u));
+diff --git a/qtbase/src/corelib/thread/qthread_p.h b/qtbase/src/corelib/thread/qthread_p.h
+index b2d1628e6e..f32f6f0460 100644
+--- a/qtbase/src/corelib/thread/qthread_p.h
++++ b/qtbase/src/corelib/thread/qthread_p.h
+@@ -174,7 +174,7 @@ public:
+     int returnCode;
+ 
+     uint stackSize;
+-    QThread::Priority priority;
++    std::underlying_type<QThread::Priority>::type priority;
+ 
+     static QThread *threadForId(int id);
+ 
+@@ -213,6 +213,13 @@ public:
+             QCoreApplication::instance()->postEvent(q_ptr, new QEvent(QEvent::Quit));
+         }
+     }
++
++#ifndef Q_OS_INTEGRITY
++private:
++    // Used in QThread(Private)::start to avoid racy access to QObject::objectName,
++    // unset afterwards. On INTEGRITY we set the thread name before starting it.
++    QString objectName;
++#endif
+ };
+ 
+ #else // QT_CONFIG(thread)
+diff --git a/qtbase/src/corelib/thread/qthread_unix.cpp b/qtbase/src/corelib/thread/qthread_unix.cpp
+index 56a8e0a038..610117a640 100644
+--- a/qtbase/src/corelib/thread/qthread_unix.cpp
++++ b/qtbase/src/corelib/thread/qthread_unix.cpp
+@@ -169,8 +169,7 @@ static void set_thread_data(QThreadData *data)
+ 
+ static void clear_thread_data()
+ {
+-    currentThreadData = nullptr;
+-    pthread_setspecific(current_thread_data_key, nullptr);
++    set_thread_data(nullptr);
+ }
+ 
+ template <typename T>
+@@ -296,7 +295,7 @@ void *QThreadPrivate::start(void *arg)
+             QMutexLocker locker(&thr->d_func()->mutex);
+ 
+             // do we need to reset the thread priority?
+-            if (int(thr->d_func()->priority) & ThreadPriorityResetFlag) {
++            if (thr->d_func()->priority & ThreadPriorityResetFlag) {
+                 thr->d_func()->setPriority(QThread::Priority(thr->d_func()->priority & ~ThreadPriorityResetFlag));
+             }
+ 
+@@ -316,10 +315,10 @@ void *QThreadPrivate::start(void *arg)
+             // Sets the name of the current thread. We can only do this
+             // when the thread is starting, as we don't have a cross
+             // platform way of setting the name of an arbitrary thread.
+-            if (Q_LIKELY(thr->objectName().isEmpty()))
++            if (Q_LIKELY(thr->d_func()->objectName.isEmpty()))
+                 setCurrentThreadName(thr->metaObject()->className());
+             else
+-                setCurrentThreadName(thr->objectName().toLocal8Bit());
++                setCurrentThreadName(std::exchange(thr->d_func()->objectName, {}).toLocal8Bit());
+         }
+ #endif
+ 
+@@ -671,7 +670,7 @@ void QThread::start(Priority priority)
+                 // could not set scheduling hints, fallback to inheriting them
+                 // we'll try again from inside the thread
+                 pthread_attr_setinheritsched(&attr, PTHREAD_INHERIT_SCHED);
+-                d->priority = Priority(priority | ThreadPriorityResetFlag);
++                d->priority = static_cast<std::underlying_type<QThread::Priority>::type>(priority) | ThreadPriorityResetFlag;
+             }
+             break;
+         }
+@@ -702,7 +701,10 @@ void QThread::start(Priority priority)
+         pthread_attr_setthreadname(&attr, metaObject()->className());
+     else
+         pthread_attr_setthreadname(&attr, objectName().toLocal8Bit());
++#else
++    d->objectName = objectName();
+ #endif
++
+     pthread_t threadId;
+     int code = pthread_create(&threadId, &attr, QThreadPrivate::start, this);
+     if (code == EPERM) {
+diff --git a/qtbase/src/corelib/thread/qthread_win.cpp b/qtbase/src/corelib/thread/qthread_win.cpp
+index bc70e3178a..4e76972498 100644
+--- a/qtbase/src/corelib/thread/qthread_win.cpp
++++ b/qtbase/src/corelib/thread/qthread_win.cpp
+@@ -394,10 +394,9 @@ unsigned int __stdcall QT_ENSURE_STACK_ALIGNED_FOR_SSE QThreadPrivate::start(voi
+ 
+ #if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) && !defined(Q_OS_WINRT)
+     // sets the name of the current thread.
+-    QByteArray objectName = thr->objectName().toLocal8Bit();
+-    qt_set_thread_name(HANDLE(-1),
+-                       objectName.isEmpty() ?
+-                       thr->metaObject()->className() : objectName.constData());
++    qt_set_thread_name(HANDLE(-1), thr->d_func()->objectName.isEmpty()
++                        ? thr->metaObject()->className()
++                        : std::exchange(thr->d_func()->objectName, {}).toLocal8Bit().constData());
+ #endif
+ 
+     emit thr->started(QThread::QPrivateSignal());
+@@ -503,6 +502,7 @@ void QThread::start(Priority priority)
+     if (d->running)
+         return;
+ 
++    d->objectName = objectName();
+     d->running = true;
+     d->finished = false;
+     d->exited = false;
+@@ -548,7 +548,7 @@ void QThread::start(Priority priority)
+ 
+     int prio;
+     d->priority = priority;
+-    switch (d->priority) {
++    switch (priority) {
+     case IdlePriority:
+         prio = THREAD_PRIORITY_IDLE;
+         break;
+@@ -686,7 +686,7 @@ void QThreadPrivate::setPriority(QThread::Priority threadPriority)
+ 
+     int prio;
+     priority = threadPriority;
+-    switch (priority) {
++    switch (threadPriority) {
+     case QThread::IdlePriority:
+         prio = THREAD_PRIORITY_IDLE;
+         break;
+diff --git a/qtbase/src/corelib/thread/qtsan_impl.h b/qtbase/src/corelib/thread/qtsan_impl.h
+new file mode 100644
+index 0000000000..580a738b91
+--- /dev/null
++++ b/qtbase/src/corelib/thread/qtsan_impl.h
+@@ -0,0 +1,115 @@
++/****************************************************************************
++**
++** Copyright (C) 2017 Intel Corporation.
++** Copyright (C) 2022 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
++** 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 QTSAN_IMPL_H
++#define QTSAN_IMPL_H
++
++#include <QtCore/qglobal.h>
++
++#if (__has_feature(thread_sanitizer) || defined(__SANITIZE_THREAD__)) && __has_include(<sanitizer/tsan_interface.h>)
++#  define QT_BUILDING_UNDER_TSAN
++#  include <sanitizer/tsan_interface.h>
++#endif
++
++QT_BEGIN_NAMESPACE
++
++namespace QtTsan {
++#ifdef QT_BUILDING_UNDER_TSAN
++inline void futexAcquire(void *addr, void *addr2 = nullptr)
++{
++    // A futex call ensures total ordering on the futex words
++    // (in either success or failure of the call). Instruct TSAN accordingly,
++    // as TSAN does not understand the futex(2) syscall (or equivalent).
++    ::__tsan_acquire(addr);
++    if (addr2)
++        ::__tsan_acquire(addr2);
++}
++
++inline void futexRelease(void *addr, void *addr2 = nullptr)
++{
++    if (addr2)
++        ::__tsan_release(addr2);
++    ::__tsan_release(addr);
++}
++
++inline void mutexPreLock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_pre_lock(addr, flags);
++}
++
++inline void mutexPostLock(void *addr, unsigned flags, int recursion)
++{
++    ::__tsan_mutex_post_lock(addr, flags, recursion);
++}
++
++inline void mutexPreUnlock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_pre_unlock(addr, flags);
++}
++
++inline void mutexPostUnlock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_post_unlock(addr, flags);
++}
++
++enum : unsigned {
++    MutexWriteReentrant = ::__tsan_mutex_write_reentrant,
++    TryLock = ::__tsan_mutex_try_lock,
++    TryLockFailed = ::__tsan_mutex_try_lock_failed,
++};
++#else
++inline void futexAcquire(void *, void * = nullptr) {}
++inline void futexRelease(void *, void * = nullptr) {}
++
++enum : unsigned {
++    MutexWriteReentrant,
++    TryLock,
++    TryLockFailed,
++};
++inline void mutexPreLock(void *, unsigned) {}
++inline void mutexPostLock(void *, unsigned, int) {}
++inline void mutexPreUnlock(void *, unsigned) {}
++inline void mutexPostUnlock(void *, unsigned) {}
++#endif // QT_BUILDING_UNDER_TSAN
++} // namespace QtTsan
++
++QT_END_NAMESPACE
++
++#endif // QTSAN_IMPL_H
+diff --git a/qtbase/src/corelib/thread/qwaitcondition_unix.cpp b/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
+index 88b058f410..0f1da4dc9b 100644
+--- a/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
++++ b/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
+@@ -213,7 +213,7 @@ bool QWaitCondition::wait(QMutex *mutex, QDeadlineTimer deadline)
+ {
+     if (! mutex)
+         return false;
+-    if (mutex->isRecursive()) {
++    if (static_cast<QBasicMutex *>(mutex)->isRecursive()) {
+         qWarning("QWaitCondition: cannot wait on recursive mutexes");
+         return false;
+     }
+diff --git a/qtbase/src/corelib/time/qdatetime.cpp b/qtbase/src/corelib/time/qdatetime.cpp
+index ec12569e3f..2c0b098079 100644
+--- a/qtbase/src/corelib/time/qdatetime.cpp
++++ b/qtbase/src/corelib/time/qdatetime.cpp
+@@ -43,6 +43,7 @@
+ #if QT_CONFIG(datetimeparser)
+ #include "private/qdatetimeparser_p.h"
+ #endif
++#include <private/qnumeric_p.h>
+ 
+ #include "qdatastream.h"
+ #include "qset.h"
+@@ -1429,9 +1430,11 @@ QDate QDate::addDays(qint64 ndays) const
+     if (isNull())
+         return QDate();
+ 
+-    // Due to limits on minJd() and maxJd() we know that any overflow
+-    // will be invalid and caught by fromJulianDay().
+-    return fromJulianDay(jd + ndays);
++    qint64 r;
++    if (Q_UNLIKELY(add_overflow(jd, ndays, &r)))
++        return QDate();
++    else
++        return fromJulianDay(r);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/corelib/time/qtimezone.cpp b/qtbase/src/corelib/time/qtimezone.cpp
+index 0309e43e52..3d451696a1 100644
+--- a/qtbase/src/corelib/time/qtimezone.cpp
++++ b/qtbase/src/corelib/time/qtimezone.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2013 John Layt <jlayt@kde.org>
++** Copyright (C) 2020 John Layt <jlayt@kde.org>
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtCore module of the Qt Toolkit.
+@@ -975,9 +975,15 @@ QList<QByteArray> QTimeZone::windowsIdToIanaIds(const QByteArray &windowsId,
+ }
+ 
+ #ifndef QT_NO_DATASTREAM
++// Invalid, as an IANA ID: too long, starts with - and has other invalid characters in it
++static inline QString invalidId() { return QStringLiteral("-No Time Zone Specified!"); }
++
+ QDataStream &operator<<(QDataStream &ds, const QTimeZone &tz)
+ {
+-    tz.d->serialize(ds);
++    if (tz.isValid())
++        tz.d->serialize(ds);
++    else
++        ds << invalidId();
+     return ds;
+ }
+ 
+@@ -985,7 +991,9 @@ QDataStream &operator>>(QDataStream &ds, QTimeZone &tz)
+ {
+     QString ianaId;
+     ds >> ianaId;
+-    if (ianaId == QLatin1String("OffsetFromUtc")) {
++    if (ianaId == invalidId()) {
++        tz = QTimeZone();
++    } else if (ianaId == QLatin1String("OffsetFromUtc")) {
+         int utcOffset;
+         QString name;
+         QString abbreviation;
+diff --git a/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp b/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
+index b1611d7ddb..a7a6a72ccf 100644
+--- a/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
++++ b/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
+@@ -42,6 +42,7 @@
+ #include "qtimezone.h"
+ #include "qtimezoneprivate_p.h"
+ #include "private/qlocale_tools_p.h"
++#include "private/qlocking_p.h"
+ 
+ #include <QtCore/QDataStream>
+ #include <QtCore/QDateTime>
+@@ -62,6 +63,10 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++#if QT_CONFIG(icu)
++static QBasicMutex s_icu_mutex;
++#endif
++
+ /*
+     Private
+ 
+@@ -670,6 +675,9 @@ QTzTimeZonePrivate::~QTzTimeZonePrivate()
+ 
+ QTzTimeZonePrivate *QTzTimeZonePrivate::clone() const
+ {
++#if QT_CONFIG(icu)
++    const auto lock = qt_scoped_lock(s_icu_mutex);
++#endif
+     return new QTzTimeZonePrivate(*this);
+ }
+ 
+@@ -913,12 +921,14 @@ QString QTzTimeZonePrivate::displayName(qint64 atMSecsSinceEpoch,
+                                         const QLocale &locale) const
+ {
+ #if QT_CONFIG(icu)
++    auto lock = qt_unique_lock(s_icu_mutex);
+     if (!m_icu)
+         m_icu = new QIcuTimeZonePrivate(m_id);
+     // TODO small risk may not match if tran times differ due to outdated files
+     // TODO Some valid TZ names are not valid ICU names, use translation table?
+     if (m_icu->isValid())
+         return m_icu->displayName(atMSecsSinceEpoch, nameType, locale);
++    lock.unlock();
+ #else
+     Q_UNUSED(nameType)
+     Q_UNUSED(locale)
+@@ -932,12 +942,14 @@ QString QTzTimeZonePrivate::displayName(QTimeZone::TimeType timeType,
+                                         const QLocale &locale) const
+ {
+ #if QT_CONFIG(icu)
++    auto lock = qt_unique_lock(s_icu_mutex);
+     if (!m_icu)
+         m_icu = new QIcuTimeZonePrivate(m_id);
+     // TODO small risk may not match if tran times differ due to outdated files
+     // TODO Some valid TZ names are not valid ICU names, use translation table?
+     if (m_icu->isValid())
+         return m_icu->displayName(timeType, nameType, locale);
++    lock.unlock();
+ #else
+     Q_UNUSED(timeType)
+     Q_UNUSED(nameType)
+diff --git a/qtbase/src/corelib/tools/qarraydata.h b/qtbase/src/corelib/tools/qarraydata.h
+index dcd95924c1..d01739e7e6 100644
+--- a/qtbase/src/corelib/tools/qarraydata.h
++++ b/qtbase/src/corelib/tools/qarraydata.h
+@@ -42,6 +42,7 @@
+ 
+ #include <QtCore/qrefcount.h>
+ #include <string.h>
++#include <cstdint>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -58,14 +59,14 @@ struct Q_CORE_EXPORT QArrayData
+     {
+         Q_ASSERT(size == 0
+                 || offset < 0 || size_t(offset) >= sizeof(QArrayData));
+-        return reinterpret_cast<char *>(this) + offset;
++        return reinterpret_cast<void *> (reinterpret_cast<uintptr_t>(this) + offset);
+     }
+ 
+     const void *data() const
+     {
+         Q_ASSERT(size == 0
+                 || offset < 0 || size_t(offset) >= sizeof(QArrayData));
+-        return reinterpret_cast<const char *>(this) + offset;
++        return reinterpret_cast<void *> (reinterpret_cast<uintptr_t>(this) + offset);
+     }
+ 
+     // This refers to array data mutability, not "header data" represented by
+diff --git a/qtbase/src/corelib/tools/qfreelist_p.h b/qtbase/src/corelib/tools/qfreelist_p.h
+index 5ba23b344b..9974102136 100644
+--- a/qtbase/src/corelib/tools/qfreelist_p.h
++++ b/qtbase/src/corelib/tools/qfreelist_p.h
+@@ -161,7 +161,7 @@ class QFreeList
+                 return i;
+             x -= size;
+         }
+-        Q_ASSERT(false);
++        Q_UNREACHABLE();
+         return -1;
+     }
+ 
+diff --git a/qtbase/src/corelib/tools/qversionnumber.h b/qtbase/src/corelib/tools/qversionnumber.h
+index d43b86ba51..2843f2b043 100644
+--- a/qtbase/src/corelib/tools/qversionnumber.h
++++ b/qtbase/src/corelib/tools/qversionnumber.h
+@@ -273,10 +273,10 @@ public:
+ 
+     Q_REQUIRED_RESULT Q_CORE_EXPORT QString toString() const;
+ #if QT_STRINGVIEW_LEVEL < 2
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(const QString &string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(const QString &string, int *suffixIndex = nullptr);
+ #endif
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QLatin1String string, int *suffixIndex = nullptr);
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QStringView string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(QLatin1String string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(QStringView string, int *suffixIndex = nullptr);
+ 
+ private:
+ #ifndef QT_NO_DATASTREAM
+diff --git a/qtbase/src/dbus/qdbusintegrator.cpp b/qtbase/src/dbus/qdbusintegrator.cpp
+index 5b66ce971b..28a3b0ffea 100644
+--- a/qtbase/src/dbus/qdbusintegrator.cpp
++++ b/qtbase/src/dbus/qdbusintegrator.cpp
+@@ -1135,7 +1135,13 @@ void QDBusConnectionPrivate::closeConnection()
+         }
+     }
+ 
+-    qDeleteAll(pendingCalls);
++    for (auto it = pendingCalls.begin(); it != pendingCalls.end(); ++it) {
++        auto call = *it;
++        if (!call->ref.deref()) {
++            delete call;
++        }
++    }
++    pendingCalls.clear();
+ 
+     // Disconnect all signals from signal hooks and from the object tree to
+     // avoid QObject::destroyed being sent to dbus daemon thread which has
+@@ -2584,6 +2590,11 @@ QDBusConnectionPrivate::findMetaObject(const QString &service, const QString &pa
+         if (mo)
+             return mo;
+     }
++    if (path.isEmpty()) {
++        error = QDBusError(QDBusError::InvalidObjectPath, QLatin1String("Object path cannot be empty"));
++        lastError = error;
++        return nullptr;
++    }
+ 
+     // introspect the target object
+     QDBusMessage msg = QDBusMessage::createMethodCall(service, path,
+diff --git a/qtbase/src/dbus/qdbusmetaobject.cpp b/qtbase/src/dbus/qdbusmetaobject.cpp
+index 5265568f42..7e9f0f1acc 100644
+--- a/qtbase/src/dbus/qdbusmetaobject.cpp
++++ b/qtbase/src/dbus/qdbusmetaobject.cpp
+@@ -210,6 +210,9 @@ QDBusMetaObjectGenerator::findType(const QByteArray &signature,
+         } else if (signature == "a{ss}") {
+             result.name = "QMap<QString,QString>";
+             type = qMetaTypeId<QMap<QString, QString> >();
++        } else if (signature == "aay") {
++            result.name = "QByteArrayList";
++            type = qMetaTypeId<QByteArrayList>();
+         } else {
+             result.name = "{D-Bus type \"" + signature + "\"}";
+             type = registerComplexDBusType(result.name);
+diff --git a/qtbase/src/gui/accessible/qaccessible.cpp b/qtbase/src/gui/accessible/qaccessible.cpp
+index d705bfccb5..0caf3c808c 100644
+--- a/qtbase/src/gui/accessible/qaccessible.cpp
++++ b/qtbase/src/gui/accessible/qaccessible.cpp
+@@ -54,6 +54,7 @@
+ #include <QtCore/qdebug.h>
+ #include <QtCore/qloggingcategory.h>
+ #include <QtCore/qmetaobject.h>
++#include <QtCore/private/qmetaobject_p.h>
+ #include <QtCore/qhash.h>
+ #include <private/qfactoryloader_p.h>
+ 
+@@ -681,6 +682,25 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
+     // Create a QAccessibleInterface for the object class. Start by the most
+     // derived class and walk up the class hierarchy.
+     const QMetaObject *mo = object->metaObject();
++    const auto *objectPriv = QObjectPrivate::get(object);
++    /*
++     We do not want to cache each and every QML metaobject (Button_QMLTYPE_124,
++     Button_QMLTYPE_125, etc.). Those dynamic metaobjects shouldn't have an
++     accessible interface in any case. Instead, we start the whole checking
++     with the first non-dynamic meta-object. To avoid potential regressions
++     in other areas of Qt that also use dynamic metaobjects, we only do this
++     for objects that are QML-related (approximated by checking whether they
++     have ddata set).
++    */
++    const bool qmlRelated = !objectPriv->isDeletingChildren &&
++                            objectPriv->declarativeData;
++    while (qmlRelated && mo) {
++        auto mop = QMetaObjectPrivate::get(mo);
++        if (!mop || !(mop->flags & DynamicMetaObject))
++            break;
++
++        mo = mo->superClass();
++    };
+     while (mo) {
+         const QString cn = QLatin1String(mo->className());
+ 
+@@ -696,14 +716,15 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
+         // Find a QAccessiblePlugin (factory) for the class name. If there's
+         // no entry in the cache try to create it using the plugin loader.
+         if (!qAccessiblePlugins()->contains(cn)) {
++            QAccessiblePlugin *factory = nullptr; // 0 means "no plugin found". This is cached as well.
+             const int index = loader()->indexOf(cn);
+-            if (index != -1) {
+-                QAccessiblePlugin *factory = qobject_cast<QAccessiblePlugin *>(loader()->instance(index));
+-                qAccessiblePlugins()->insert(cn, factory);
+-            }
++            if (index != -1)
++                factory = qobject_cast<QAccessiblePlugin *>(loader()->instance(index));
++            qAccessiblePlugins()->insert(cn, factory);
+         }
+ 
+         // At this point the cache should contain a valid factory pointer or 0:
++        Q_ASSERT(qAccessiblePlugins()->contains(cn));
+         QAccessiblePlugin *factory = qAccessiblePlugins()->value(cn);
+         if (factory) {
+             QAccessibleInterface *result = factory->create(cn, object);
+diff --git a/qtbase/src/gui/configure.json b/qtbase/src/gui/configure.json
+index 1f08795c57..12c95742d2 100644
+--- a/qtbase/src/gui/configure.json
++++ b/qtbase/src/gui/configure.json
+@@ -834,7 +834,8 @@
+                     "// embedded devices, are not intended to be used together with X. EGL support",
+                     "// has to be disabled in plugins like xcb in this case since the native display,",
+                     "// window and pixmap types will be different than what an X-based platform",
+-                    "// plugin would expect."
++                    "// plugin would expect.",
++                    "#define USE_X11"
+                 ],
+                 "include": [ "EGL/egl.h", "X11/Xlib.h" ],
+                 "main": [
+diff --git a/qtbase/src/gui/image/qbmphandler.cpp b/qtbase/src/gui/image/qbmphandler.cpp
+index 96f1e8cb1d..0e73bbbdb0 100644
+--- a/qtbase/src/gui/image/qbmphandler.cpp
++++ b/qtbase/src/gui/image/qbmphandler.cpp
+@@ -150,16 +150,42 @@ static QDataStream &operator<<(QDataStream &s, const BMP_INFOHDR &bi)
+     return s;
+ }
+ 
+-static int calc_shift(uint mask)
++static uint calc_shift(uint mask)
+ {
+-    int result = 0;
+-    while (mask && !(mask & 1)) {
++    uint result = 0;
++    while ((mask >= 0x100) || (!(mask & 1) && mask)) {
+         result++;
+         mask >>= 1;
+     }
+     return result;
+ }
+ 
++static uint calc_scale(uint low_mask)
++{
++    uint result = 8;
++    while (low_mask && result) {
++        result--;
++        low_mask >>= 1;
++    }
++    return result;
++}
++
++static inline uint apply_scale(uint value, uint scale)
++{
++    if (!(scale & 0x07)) // return immediately if scale == 8 or 0
++        return value;
++
++    uint filled = 8 - scale;
++    uint result = value << scale;
++
++    do {
++        result |= result >> filled;
++        filled <<= 1;
++    } while (filled < 8);
++
++    return result;
++}
++
+ static bool read_dib_fileheader(QDataStream &s, BMP_FILEHDR &bf)
+ {
+     // read BMP file header
+@@ -222,14 +248,14 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+     uint green_mask = 0;
+     uint blue_mask = 0;
+     uint alpha_mask = 0;
+-    int red_shift = 0;
+-    int green_shift = 0;
+-    int blue_shift = 0;
+-    int alpha_shift = 0;
+-    int red_scale = 0;
+-    int green_scale = 0;
+-    int blue_scale = 0;
+-    int alpha_scale = 0;
++    uint red_shift = 0;
++    uint green_shift = 0;
++    uint blue_shift = 0;
++    uint alpha_shift = 0;
++    uint red_scale = 0;
++    uint green_scale = 0;
++    uint blue_scale = 0;
++    uint alpha_scale = 0;
+ 
+     if (!d->isSequential())
+         d->seek(startpos + BMP_FILEHDR_SIZE + bi.biSize); // goto start of colormap or masks
+@@ -308,19 +334,19 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+         red_shift = calc_shift(red_mask);
+         if (((red_mask >> red_shift) + 1) == 0)
+             return false;
+-        red_scale = 256 / ((red_mask >> red_shift) + 1);
++        red_scale = calc_scale(red_mask >> red_shift);
+         green_shift = calc_shift(green_mask);
+         if (((green_mask >> green_shift) + 1) == 0)
+             return false;
+-        green_scale = 256 / ((green_mask >> green_shift) + 1);
++        green_scale = calc_scale(green_mask >> green_shift);
+         blue_shift = calc_shift(blue_mask);
+         if (((blue_mask >> blue_shift) + 1) == 0)
+             return false;
+-        blue_scale = 256 / ((blue_mask >> blue_shift) + 1);
++        blue_scale = calc_scale(blue_mask >> blue_shift);
+         alpha_shift = calc_shift(alpha_mask);
+         if (((alpha_mask >> alpha_shift) + 1) == 0)
+             return false;
+-        alpha_scale = 256 / ((alpha_mask >> alpha_shift) + 1);
++        alpha_scale = calc_scale(alpha_mask >> alpha_shift);
+     } else if (comp == BMP_RGB && (nbits == 24 || nbits == 32)) {
+         blue_mask = 0x000000ff;
+         green_mask = 0x0000ff00;
+@@ -328,17 +354,15 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+         blue_shift = 0;
+         green_shift = 8;
+         red_shift = 16;
+-        blue_scale = green_scale = red_scale = 1;
++        blue_scale = green_scale = red_scale = 0;
+     } else if (comp == BMP_RGB && nbits == 16) {
+         blue_mask = 0x001f;
+         green_mask = 0x03e0;
+         red_mask = 0x7c00;
+         blue_shift = 0;
+-        green_shift = 2;
+-        red_shift = 7;
+-        red_scale = 1;
+-        green_scale = 1;
+-        blue_scale = 8;
++        green_shift = 5;
++        red_shift = 10;
++        blue_scale = green_scale = red_scale = 3;
+     }
+ 
+ #if 0
+@@ -544,10 +568,10 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+                     c |= *(uchar*)(b+2)<<16;
+                 if (nbits > 24)
+                     c |= *(uchar*)(b+3)<<24;
+-                *p++ = qRgba(((c & red_mask) >> red_shift) * red_scale,
+-                                        ((c & green_mask) >> green_shift) * green_scale,
+-                                        ((c & blue_mask) >> blue_shift) * blue_scale,
+-                                        transp ? ((c & alpha_mask) >> alpha_shift) * alpha_scale : 0xff);
++                *p++ = qRgba(apply_scale((c & red_mask) >> red_shift, red_scale),
++                             apply_scale((c & green_mask) >> green_shift, green_scale),
++                             apply_scale((c & blue_mask) >> blue_shift, blue_scale),
++                             transp ? apply_scale((c & alpha_mask) >> alpha_shift, alpha_scale) : 0xff);
+                 b += nbits/8;
+             }
+         }
+diff --git a/qtbase/src/gui/image/qimage.cpp b/qtbase/src/gui/image/qimage.cpp
+index 7152ac1607..0df772564c 100644
+--- a/qtbase/src/gui/image/qimage.cpp
++++ b/qtbase/src/gui/image/qimage.cpp
+@@ -4694,6 +4694,8 @@ QImage QImage::smoothScaled(int w, int h) const {
+ static QImage rotated90(const QImage &image)
+ {
+     QImage out(image.height(), image.width(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+@@ -4722,6 +4724,8 @@ static QImage rotated180(const QImage &image)
+         return image.mirrored(true, true);
+ 
+     QImage out(image.width(), image.height(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+@@ -4734,6 +4738,8 @@ static QImage rotated180(const QImage &image)
+ static QImage rotated270(const QImage &image)
+ {
+     QImage out(image.height(), image.width(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+diff --git a/qtbase/src/gui/kernel/qcursor.cpp b/qtbase/src/gui/kernel/qcursor.cpp
+index d6ccaff8ed..455088241c 100644
+--- a/qtbase/src/gui/kernel/qcursor.cpp
++++ b/qtbase/src/gui/kernel/qcursor.cpp
+@@ -251,7 +251,8 @@ void QCursor::setPos(QScreen *screen, int x, int y)
+ {
+     if (screen) {
+         if (QPlatformCursor *cursor = screen->handle()->cursor()) {
+-            const QPoint devicePos = QHighDpi::toNativePixels(QPoint(x, y), screen);
++            const QPoint pos(x, y);
++            const QPoint devicePos = QHighDpi::toNativePixels(pos, screen->virtualSiblingAt(pos));
+             // Need to check, since some X servers generate null mouse move
+             // events, causing looping in applications which call setPos() on
+             // every mouse move event.
+diff --git a/qtbase/src/gui/kernel/qhighdpiscaling.cpp b/qtbase/src/gui/kernel/qhighdpiscaling.cpp
+index 9bbf2773a9..3ac4a4d8b6 100644
+--- a/qtbase/src/gui/kernel/qhighdpiscaling.cpp
++++ b/qtbase/src/gui/kernel/qhighdpiscaling.cpp
+@@ -580,9 +580,8 @@ void QHighDpiScaling::setScreenFactor(QScreen *screen, qreal factor)
+     else
+         qNamedScreenScaleFactors()->insert(name, factor);
+ 
+-    // hack to force re-evaluation of screen geometry
+     if (screen->handle())
+-        screen->d_func()->setPlatformScreen(screen->handle()); // updates geometries based on scale factor
++        screen->d_func()->updateLogicalDpi();
+ }
+ 
+ QPoint QHighDpiScaling::mapPositionToNative(const QPoint &pos, const QPlatformScreen *platformScreen)
+diff --git a/qtbase/src/gui/kernel/qkeysequence.cpp b/qtbase/src/gui/kernel/qkeysequence.cpp
+index a75b8ef920..4f2d294739 100644
+--- a/qtbase/src/gui/kernel/qkeysequence.cpp
++++ b/qtbase/src/gui/kernel/qkeysequence.cpp
+@@ -701,6 +701,10 @@ static const struct {
+     { Qt::Key_TouchpadToggle,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad Toggle") },
+     { Qt::Key_TouchpadOn,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad On") },
+     { Qt::Key_TouchpadOff,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad Off") },
++    { Qt::Key_Shift,  QT_TRANSLATE_NOOP("QShortcut", "Shift") },
++    { Qt::Key_Control,  QT_TRANSLATE_NOOP("QShortcut", "Control") },
++    { Qt::Key_Alt,  QT_TRANSLATE_NOOP("QShortcut", "Alt") },
++    { Qt::Key_Meta,  QT_TRANSLATE_NOOP("QShortcut", "Meta") },
+ 
+ };
+ static Q_CONSTEXPR int numKeyNames = sizeof keyname / sizeof *keyname;
+diff --git a/qtbase/src/gui/kernel/qplatformservices.cpp b/qtbase/src/gui/kernel/qplatformservices.cpp
+index fdc6a6c4aa..ac47f98c5d 100644
+--- a/qtbase/src/gui/kernel/qplatformservices.cpp
++++ b/qtbase/src/gui/kernel/qplatformservices.cpp
+@@ -55,6 +55,19 @@ QT_BEGIN_NAMESPACE
+     \brief The QPlatformServices provides the backend for desktop-related functionality.
+ */
+ 
++/*!
++    \enum QPlatformServices::Capability
++
++    Capabilities are used to determine a specific platform service's availability.
++
++    \value ColorPickingFromScreen The platform natively supports color picking from screen.
++    This capability indicates that the platform supports "opaque" color picking, where the
++    platform implements a complete user experience for color picking and outputs a color.
++    This is in contrast to the application implementing the color picking user experience
++    (taking care of showing a cross hair, instructing the platform integration to obtain
++    the color at a given pixel, etc.). The related service function is pickColor().
++ */
++
+ QPlatformServices::QPlatformServices()
+ { }
+ 
+@@ -85,5 +98,16 @@ QByteArray QPlatformServices::desktopEnvironment() const
+     return QByteArray("UNKNOWN");
+ }
+ 
++QPlatformServiceColorPicker *QPlatformServices::colorPicker(QWindow *parent)
++{
++    Q_UNUSED(parent);
++    return nullptr;
++}
++
++bool QPlatformServices::hasCapability(Capability capability) const
++{
++    Q_UNUSED(capability)
++    return false;
++}
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/gui/kernel/qplatformservices.h b/qtbase/src/gui/kernel/qplatformservices.h
+index 5de96cfa7d..a8b2a4ce71 100644
+--- a/qtbase/src/gui/kernel/qplatformservices.h
++++ b/qtbase/src/gui/kernel/qplatformservices.h
+@@ -50,16 +50,32 @@
+ //
+ 
+ #include <QtGui/qtguiglobal.h>
++#include <QtCore/qobject.h>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+ class QUrl;
++class QWindow;
++
++class Q_GUI_EXPORT QPlatformServiceColorPicker : public QObject
++{
++    Q_OBJECT
++public:
++    using QObject::QObject;
++    virtual void pickColor() = 0;
++Q_SIGNALS:
++    void colorPicked(const QColor &color);
++};
+ 
+ class Q_GUI_EXPORT QPlatformServices
+ {
+ public:
+     Q_DISABLE_COPY_MOVE(QPlatformServices)
+ 
++    enum Capability {
++        ColorPicking,
++    };
++
+     QPlatformServices();
+     virtual ~QPlatformServices() { }
+ 
+@@ -67,6 +83,10 @@ public:
+     virtual bool openDocument(const QUrl &url);
+ 
+     virtual QByteArray desktopEnvironment() const;
++
++    virtual bool hasCapability(Capability capability) const;
++
++    virtual QPlatformServiceColorPicker *colorPicker(QWindow *parent = nullptr);
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/gui/kernel/qplatformtheme.cpp b/qtbase/src/gui/kernel/qplatformtheme.cpp
+index 71521c0339..2325873245 100644
+--- a/qtbase/src/gui/kernel/qplatformtheme.cpp
++++ b/qtbase/src/gui/kernel/qplatformtheme.cpp
+@@ -163,6 +163,8 @@ QT_BEGIN_NAMESPACE
+ 
+     \value ShowShortcutsInContextMenus (bool) Whether to display shortcut key sequences in context menus.
+ 
++    \value ButtonPressKeys (QList<Qt::Key>) A list of keys that can be used to press buttons via keyboard input.
++
+     \sa themeHint(), QStyle::pixelMetric()
+ */
+ 
+@@ -563,6 +565,8 @@ QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint)
+         }
+     case MouseQuickSelectionThreshold:
+         return QVariant(10);
++    case ButtonPressKeys:
++        return QVariant::fromValue(QList<Qt::Key>({ Qt::Key_Space, Qt::Key_Select }));
+     }
+     return QVariant();
+ }
+diff --git a/qtbase/src/gui/kernel/qplatformtheme.h b/qtbase/src/gui/kernel/qplatformtheme.h
+index 3185fc4541..7e6c9d5740 100644
+--- a/qtbase/src/gui/kernel/qplatformtheme.h
++++ b/qtbase/src/gui/kernel/qplatformtheme.h
+@@ -120,7 +120,8 @@ public:
+         TouchDoubleTapDistance,
+         ShowShortcutsInContextMenus,
+         IconFallbackSearchPaths,
+-        MouseQuickSelectionThreshold
++        MouseQuickSelectionThreshold,
++        ButtonPressKeys
+     };
+ 
+     enum DialogType {
+diff --git a/qtbase/src/gui/kernel/qscreen.cpp b/qtbase/src/gui/kernel/qscreen.cpp
+index 8e0eb35116..5d172a58dd 100644
+--- a/qtbase/src/gui/kernel/qscreen.cpp
++++ b/qtbase/src/gui/kernel/qscreen.cpp
+@@ -77,6 +77,12 @@ QScreen::QScreen(QPlatformScreen *screen)
+     d->setPlatformScreen(screen);
+ }
+ 
++void QScreenPrivate::updateLogicalDpi()
++{
++    logicalDpi = QPlatformScreen::overrideDpi(platformScreen->logicalDpi());
++    updateGeometriesWithSignals(); // updates geometries based on scale factor
++}
++
+ void QScreenPrivate::updateGeometriesWithSignals()
+ {
+     const QRect oldGeometry = geometry;
+diff --git a/qtbase/src/gui/kernel/qscreen_p.h b/qtbase/src/gui/kernel/qscreen_p.h
+index 7da542c25e..e50fc3190b 100644
+--- a/qtbase/src/gui/kernel/qscreen_p.h
++++ b/qtbase/src/gui/kernel/qscreen_p.h
+@@ -70,6 +70,7 @@ public:
+         geometry = platformScreen->deviceIndependentGeometry();
+         availableGeometry = QHighDpi::fromNative(platformScreen->availableGeometry(), QHighDpiScaling::factor(platformScreen), geometry.topLeft());
+     }
++    void updateLogicalDpi();
+ 
+     void updatePrimaryOrientation();
+     void updateGeometriesWithSignals();
+diff --git a/qtbase/src/gui/painting/qblendfunctions_p.h b/qtbase/src/gui/painting/qblendfunctions_p.h
+index 080da98ec4..6997d62b3c 100644
+--- a/qtbase/src/gui/painting/qblendfunctions_p.h
++++ b/qtbase/src/gui/painting/qblendfunctions_p.h
+@@ -246,25 +246,32 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+                                   int dudx, int dvdx, int dudy, int dvdy, int u0, int v0,
+                                   Blender blender)
+ {
+-    int fromY = qMax(qRound(topY), clip.top());
+-    int toY = qMin(qRound(bottomY), clip.top() + clip.height());
++    qint64 fromY = qMax(qRound(topY), clip.top());
++    qint64 toY = qMin(qRound(bottomY), clip.top() + clip.height());
+     if (fromY >= toY)
+         return;
+ 
+     qreal leftSlope = (bottomLeft.x - topLeft.x) / (bottomLeft.y - topLeft.y);
+     qreal rightSlope = (bottomRight.x - topRight.x) / (bottomRight.y - topRight.y);
+-    int dx_l = int(leftSlope * 0x10000);
+-    int dx_r = int(rightSlope * 0x10000);
+-    int x_l = int((topLeft.x + (qreal(0.5) + fromY - topLeft.y) * leftSlope + qreal(0.5)) * 0x10000);
+-    int x_r = int((topRight.x + (qreal(0.5) + fromY - topRight.y) * rightSlope + qreal(0.5)) * 0x10000);
+-
+-    int fromX, toX, x1, x2, u, v, i, ii;
++    qint64 dx_l = qint64(leftSlope * 0x10000);
++    qint64 dx_r = qint64(rightSlope * 0x10000);
++    qint64 x_l = qint64((topLeft.x + (qreal(0.5) + fromY - topLeft.y) * leftSlope + qreal(0.5)) * 0x10000);
++    qint64 x_r = qint64((topRight.x + (qreal(0.5) + fromY - topRight.y) * rightSlope + qreal(0.5)) * 0x10000);
++
++    qint64 sourceRectTop = qint64(sourceRect.top());
++    qint64 sourceRectLeft = qint64(sourceRect.left());
++    qint64 sourceRectWidth = qint64(sourceRect.width());
++    qint64 sourceRectHeight = qint64(sourceRect.height());
++    qint64 clipLeft = qint64(clip.left());
++    qint64 clipWidth = qint64(clip.width());
++
++    qint64 fromX, toX, x1, x2, u, v, i, ii;
+     DestT *line;
+-    for (int y = fromY; y < toY; ++y) {
++    for (qint64 y = fromY; y < toY; ++y) {
+         line = reinterpret_cast<DestT *>(reinterpret_cast<uchar *>(destPixels) + y * dbpl);
+ 
+-        fromX = qMax(x_l >> 16, clip.left());
+-        toX = qMin(x_r >> 16, clip.left() + clip.width());
++        fromX = qMax(x_l >> 16, clipLeft);
++        toX = qMin(x_r >> 16, clipLeft + clipWidth);
+         if (fromX < toX) {
+             // Because of rounding, we can get source coordinates outside the source image.
+             // Clamp these coordinates to the source rect to avoid segmentation fault and
+@@ -275,10 +282,10 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             u = x1 * dudx + y * dudy + u0;
+             v = x1 * dvdx + y * dvdy + v0;
+             for (; x1 < toX; ++x1) {
+-                int uu = u >> 16;
+-                int vv = v >> 16;
+-                if (uu >= sourceRect.left() && uu < sourceRect.left() + sourceRect.width()
+-                    && vv >= sourceRect.top() && vv < sourceRect.top() + sourceRect.height()) {
++                qint64 uu = u >> 16;
++                qint64 vv = v >> 16;
++                if (uu >= sourceRectLeft && uu < sourceRectLeft + sourceRectWidth
++                    && vv >= sourceRectTop && vv < sourceRectTop + sourceRectHeight) {
+                     break;
+                 }
+                 u += dudx;
+@@ -290,10 +297,10 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             u = (x2 - 1) * dudx + y * dudy + u0;
+             v = (x2 - 1) * dvdx + y * dvdy + v0;
+             for (; x2 > x1; --x2) {
+-                int uu = u >> 16;
+-                int vv = v >> 16;
+-                if (uu >= sourceRect.left() && uu < sourceRect.left() + sourceRect.width()
+-                    && vv >= sourceRect.top() && vv < sourceRect.top() + sourceRect.height()) {
++                qint64 uu = u >> 16;
++                qint64 vv = v >> 16;
++                if (uu >= sourceRectLeft && uu < sourceRectLeft + sourceRectWidth
++                    && vv >= sourceRectTop && vv < sourceRectTop + sourceRectHeight) {
+                     break;
+                 }
+                 u -= dudx;
+@@ -308,8 +315,8 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             // Beginning of the scan line, with per-pixel checks.
+             i = x1 - fromX;
+             while (i) {
+-                int uu = qBound(sourceRect.left(), u >> 16, sourceRect.left() + sourceRect.width() - 1);
+-                int vv = qBound(sourceRect.top(), v >> 16, sourceRect.top() + sourceRect.height() - 1);
++                qint64 uu = qBound(sourceRectLeft, u >> 16, sourceRectLeft + sourceRectWidth - 1);
++                qint64 vv = qBound(sourceRectTop, v >> 16, sourceRectTop + sourceRectHeight - 1);
+                 blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + vv * sbpl)[uu]);
+                 u += dudx;
+                 v += dvdx;
+@@ -348,8 +355,8 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             // End of the scan line, with per-pixel checks.
+             i = toX - x2;
+             while (i) {
+-                int uu = qBound(sourceRect.left(), u >> 16, sourceRect.left() + sourceRect.width() - 1);
+-                int vv = qBound(sourceRect.top(), v >> 16, sourceRect.top() + sourceRect.height() - 1);
++                qint64 uu = qBound(sourceRectLeft, u >> 16, sourceRectLeft + sourceRectWidth - 1);
++                qint64 vv = qBound(sourceRectTop, v >> 16, sourceRectTop + sourceRectHeight - 1);
+                 blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + vv * sbpl)[uu]);
+                 u += dudx;
+                 v += dvdx;
+diff --git a/qtbase/src/gui/painting/qcolortrclut_p.h b/qtbase/src/gui/painting/qcolortrclut_p.h
+index 76a6a60803..24fd522e6c 100644
+--- a/qtbase/src/gui/painting/qcolortrclut_p.h
++++ b/qtbase/src/gui/painting/qcolortrclut_p.h
+@@ -118,6 +118,7 @@ public:
+         return QRgba64::fromRgba64(r, g, b, qAlpha(rgb32) * 257);
+ #endif
+     }
++    QRgba64 toLinear64(QRgba64) const = delete;
+ 
+     QRgb toLinear(QRgb rgb32) const
+     {
+diff --git a/qtbase/src/gui/painting/qdrawhelper.cpp b/qtbase/src/gui/painting/qdrawhelper.cpp
+index a61793508a..5ba2d277b7 100644
+--- a/qtbase/src/gui/painting/qdrawhelper.cpp
++++ b/qtbase/src/gui/painting/qdrawhelper.cpp
+@@ -6091,7 +6091,7 @@ static inline void alphargbblend_argb32(quint32 *dst, uint coverage, const QRgba
+ static inline void rgbBlendPixel(QRgba64 &dst, int coverage, QRgba64 slinear, const QColorTrcLut *colorProfile)
+ {
+     // Do a gammacorrected RGB alphablend...
+-    const QRgba64 dlinear = colorProfile ? colorProfile->toLinear64(dst) : dst;
++    const QRgba64 dlinear = colorProfile ? colorProfile->toLinear(dst) : dst;
+ 
+     QRgba64 blend = rgbBlend(dlinear, slinear, coverage);
+ 
+diff --git a/qtbase/src/gui/painting/qpaintengine_raster.cpp b/qtbase/src/gui/painting/qpaintengine_raster.cpp
+index 283923de52..f08eb9cbee 100644
+--- a/qtbase/src/gui/painting/qpaintengine_raster.cpp
++++ b/qtbase/src/gui/painting/qpaintengine_raster.cpp
+@@ -560,31 +560,6 @@ void QRasterPaintEngine::updateMatrix(const QTransform &matrix)
+     QRasterPaintEngineState *s = state();
+     // FALCON: get rid of this line, see drawImage call below.
+     s->matrix = matrix;
+-    QTransform::TransformationType txop = s->matrix.type();
+-
+-    switch (txop) {
+-
+-    case QTransform::TxNone:
+-        s->flags.int_xform = true;
+-        break;
+-
+-    case QTransform::TxTranslate:
+-        s->flags.int_xform = qreal(int(s->matrix.dx())) == s->matrix.dx()
+-                            && qreal(int(s->matrix.dy())) == s->matrix.dy();
+-        break;
+-
+-    case QTransform::TxScale:
+-        s->flags.int_xform = qreal(int(s->matrix.dx())) == s->matrix.dx()
+-                            && qreal(int(s->matrix.dy())) == s->matrix.dy()
+-                            && qreal(int(s->matrix.m11())) == s->matrix.m11()
+-                            && qreal(int(s->matrix.m22())) == s->matrix.m22();
+-        break;
+-
+-    default: // shear / perspective...
+-        s->flags.int_xform = false;
+-        break;
+-    }
+-
+     s->flags.tx_noshear = qt_scaleForTransform(s->matrix, &s->txscale);
+ 
+     ensureOutlineMapper();
+@@ -617,7 +592,6 @@ QRasterPaintEngineState::QRasterPaintEngineState()
+     flags.bilinear = false;
+     flags.legacy_rounding = false;
+     flags.fast_text = true;
+-    flags.int_xform = true;
+     flags.tx_noshear = true;
+     flags.fast_images = true;
+ 
+@@ -1793,7 +1767,7 @@ void QRasterPaintEngine::fill(const QVectorPath &path, const QBrush &brush)
+     QRectF cpRect = path.controlPointRect();
+     const QRectF pathDeviceRect = s->matrix.mapRect(cpRect);
+     // Skip paths that by conservative estimates are completely outside the paint device.
+-    if (!pathDeviceRect.intersects(QRectF(d->deviceRect)))
++    if (!pathDeviceRect.intersects(QRectF(d->deviceRect)) || !pathDeviceRect.isValid())
+         return;
+ 
+     ProcessSpans blend = d->getBrushFunc(pathDeviceRect, &s->brushData);
+diff --git a/qtbase/src/gui/painting/qpaintengine_raster_p.h b/qtbase/src/gui/painting/qpaintengine_raster_p.h
+index 089aadc3f7..bf7363d5aa 100644
+--- a/qtbase/src/gui/painting/qpaintengine_raster_p.h
++++ b/qtbase/src/gui/painting/qpaintengine_raster_p.h
+@@ -111,7 +111,6 @@ public:
+         uint bilinear : 1;
+         uint legacy_rounding : 1;
+         uint fast_text : 1;
+-        uint int_xform : 1;
+         uint tx_noshear : 1;
+         uint fast_images : 1;
+     };
+diff --git a/qtbase/src/gui/painting/qpainterpath.cpp b/qtbase/src/gui/painting/qpainterpath.cpp
+index f9544a3241..d80fafeaf1 100644
+--- a/qtbase/src/gui/painting/qpainterpath.cpp
++++ b/qtbase/src/gui/painting/qpainterpath.cpp
+@@ -1253,7 +1253,7 @@ void QPainterPath::addText(const QPointF &point, const QFont &f, const QString &
+ 
+         if (si.analysis.flags < QScriptAnalysis::TabOrObject) {
+             QGlyphLayout glyphs = eng->shapedGlyphs(&si);
+-            QFontEngine *fe = f.d->engineForScript(si.analysis.script);
++            QFontEngine *fe = eng->fontEngine(si);
+             Q_ASSERT(fe);
+             fe->addOutlineToPath(x, y, glyphs, this,
+                                  si.analysis.bidiLevel % 2
+diff --git a/qtbase/src/gui/painting/qpathclipper_p.h b/qtbase/src/gui/painting/qpathclipper_p.h
+index 9444a87b71..18f64c5e8c 100644
+--- a/qtbase/src/gui/painting/qpathclipper_p.h
++++ b/qtbase/src/gui/painting/qpathclipper_p.h
+@@ -156,7 +156,7 @@ public:
+     int vertex(Direction direction) const;
+ 
+ private:
+-    int m_next[2][2];
++    int m_next[2][2] = { { -1, -1 }, { -1, -1 } };
+ };
+ 
+ class QPathSegments
+@@ -296,10 +296,6 @@ inline QPathEdge::QPathEdge(int a, int b)
+     , angle(0)
+     , invAngle(0)
+ {
+-    m_next[0][0] = -1;
+-    m_next[1][0] = -1;
+-    m_next[0][0] = -1;
+-    m_next[1][0] = -1;
+ }
+ 
+ inline int QPathEdge::next(Traversal traversal, Direction direction) const
+diff --git a/qtbase/src/gui/painting/qpdf.cpp b/qtbase/src/gui/painting/qpdf.cpp
+index 3066744f1b..2c8d3c3b53 100644
+--- a/qtbase/src/gui/painting/qpdf.cpp
++++ b/qtbase/src/gui/painting/qpdf.cpp
+@@ -2760,6 +2760,8 @@ int QPdfEnginePrivate::addBrushPattern(const QTransform &m, bool *specifyColor,
+         return gradientBrush(brush, matrix, gStateObject);
+     }
+ 
++    matrix = brush.transform() * matrix;
++
+     if ((!brush.isOpaque() && brush.style() < Qt::LinearGradientPattern) || opacity != 1.0)
+         *gStateObject = addConstantAlphaObject(qRound(brush.color().alpha() * opacity),
+                                                qRound(pen.color().alpha() * opacity));
+diff --git a/qtbase/src/gui/painting/qstroker.cpp b/qtbase/src/gui/painting/qstroker.cpp
+index cb5d395e80..3b6357a893 100644
+--- a/qtbase/src/gui/painting/qstroker.cpp
++++ b/qtbase/src/gui/painting/qstroker.cpp
+@@ -1182,6 +1182,7 @@ void QDashStroker::processCurrentSubpath()
+         // Check if the entire line should be clipped away or simplified
+         bool clipIt = clipping && !lineIntersectsRect(prev, e, clip_tl, clip_br);
+         bool skipDashing = elen * invSumLength > repetitionLimit();
++        int maxDashes = dashCount;
+         if (skipDashing || clipIt) {
+             // Cut away full dash sequences.
+             elen -= std::floor(elen * invSumLength) * sumLength;
+@@ -1196,7 +1197,7 @@ void QDashStroker::processCurrentSubpath()
+                     pos = estop; // move pos to next path element
+                     done = true;
+                 } else { // Dash is on this line
+-                    pos = dpos + estart;
++                    pos = --maxDashes > 0 ? dpos + estart : estop;
+                     done = pos >= estop;
+                     if (++idash >= dashCount)
+                         idash = 0;
+diff --git a/qtbase/src/gui/painting/qt_attribution.json b/qtbase/src/gui/painting/qt_attribution.json
+index 7b16e8c211..0e87d30aa2 100644
+--- a/qtbase/src/gui/painting/qt_attribution.json
++++ b/qtbase/src/gui/painting/qt_attribution.json
+@@ -10,7 +10,7 @@
+         "Homepage": "http://www.freetype.org",
+         "License": "Freetype Project License or GNU General Public License v2.0 only",
+         "LicenseId": "FTL or GPL-2.0",
+-        "LicenseFile": "../../3rdparty/freetype/docs/LICENSE.TXT",
++        "LicenseFile": "../../3rdparty/freetype/LICENSE.TXT",
+         "Copyright": "Copyright 2000-2016 by David Turner, Robert Wilhelm, and Werner Lemberg."
+     },
+     {
+diff --git a/qtbase/src/gui/rhi/qshader_p_p.h b/qtbase/src/gui/rhi/qshader_p_p.h
+index ec9d25971f..4a5a7a6d51 100644
+--- a/qtbase/src/gui/rhi/qshader_p_p.h
++++ b/qtbase/src/gui/rhi/qshader_p_p.h
+@@ -68,13 +68,13 @@ struct Q_GUI_EXPORT QShaderPrivate
+     {
+     }
+ 
+-    QShaderPrivate(const QShaderPrivate *other)
++    QShaderPrivate(const QShaderPrivate &other)
+         : ref(1),
+-          qsbVersion(other->qsbVersion),
+-          stage(other->stage),
+-          desc(other->desc),
+-          shaders(other->shaders),
+-          bindings(other->bindings)
++          qsbVersion(other.qsbVersion),
++          stage(other.stage),
++          desc(other.desc),
++          shaders(other.shaders),
++          bindings(other.bindings)
+     {
+     }
+ 
+diff --git a/qtbase/src/gui/rhi/qshaderdescription_p_p.h b/qtbase/src/gui/rhi/qshaderdescription_p_p.h
+index ec2b0b6b4c..3da33a8a2b 100644
+--- a/qtbase/src/gui/rhi/qshaderdescription_p_p.h
++++ b/qtbase/src/gui/rhi/qshaderdescription_p_p.h
+@@ -63,16 +63,16 @@ struct Q_GUI_EXPORT QShaderDescriptionPrivate
+         localSize[0] = localSize[1] = localSize[2] = 0;
+     }
+ 
+-    QShaderDescriptionPrivate(const QShaderDescriptionPrivate *other)
++    QShaderDescriptionPrivate(const QShaderDescriptionPrivate &other)
+         : ref(1),
+-          inVars(other->inVars),
+-          outVars(other->outVars),
+-          uniformBlocks(other->uniformBlocks),
+-          pushConstantBlocks(other->pushConstantBlocks),
+-          storageBlocks(other->storageBlocks),
+-          combinedImageSamplers(other->combinedImageSamplers),
+-          storageImages(other->storageImages),
+-          localSize(other->localSize)
++          inVars(other.inVars),
++          outVars(other.outVars),
++          uniformBlocks(other.uniformBlocks),
++          pushConstantBlocks(other.pushConstantBlocks),
++          storageBlocks(other.storageBlocks),
++          combinedImageSamplers(other.combinedImageSamplers),
++          storageImages(other.storageImages),
++          localSize(other.localSize)
+     {
+     }
+ 
+diff --git a/qtbase/src/gui/text/qfontdatabase.cpp b/qtbase/src/gui/text/qfontdatabase.cpp
+index a657a8c516..4fc0100958 100644
+--- a/qtbase/src/gui/text/qfontdatabase.cpp
++++ b/qtbase/src/gui/text/qfontdatabase.cpp
+@@ -983,7 +983,7 @@ QFontEngine *loadSingleEngine(int script,
+         if (style->key.stretch != 0 && request.stretch != 0
+             && (request.styleName.isEmpty() || request.styleName != style->styleName)) {
+             def.stretch = (request.stretch * 100 + style->key.stretch / 2) / style->key.stretch;
+-        } else {
++        } else if (request.stretch == QFont::AnyStretch) {
+             def.stretch = 100;
+         }
+ 
+diff --git a/qtbase/src/gui/text/qtextdocumentlayout.cpp b/qtbase/src/gui/text/qtextdocumentlayout.cpp
+index f3e6ea2100..72267e9380 100644
+--- a/qtbase/src/gui/text/qtextdocumentlayout.cpp
++++ b/qtbase/src/gui/text/qtextdocumentlayout.cpp
+@@ -2123,7 +2123,7 @@ void QTextDocumentLayoutPrivate::drawListItem(const QPointF &offset, QPainter *p
+ {
+     Q_Q(const QTextDocumentLayout);
+     const QTextBlockFormat blockFormat = bl.blockFormat();
+-    const QTextCharFormat charFormat = QTextCursor(bl).charFormat();
++    const QTextCharFormat charFormat = bl.charFormat();
+     QFont font(charFormat.font());
+     if (q->paintDevice())
+         font = QFont(font, q->paintDevice());
+diff --git a/qtbase/src/gui/text/qtextengine.cpp b/qtbase/src/gui/text/qtextengine.cpp
+index ce4abac472..a6c66e5d2d 100644
+--- a/qtbase/src/gui/text/qtextengine.cpp
++++ b/qtbase/src/gui/text/qtextengine.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2021 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtGui module of the Qt Toolkit.
+@@ -1565,6 +1565,12 @@ void QTextEngine::shapeText(int item) const
+         // Overwrite with 0 token to indicate failure
+         QGlyphLayout g = availableGlyphs(&si);
+         g.glyphs[0] = 0;
++        g.attributes[0].clusterStart = true;
++
++        ushort *log_clusters = logClusters(&si);
++        for (int i = 0; i < itemLength; ++i)
++            log_clusters[i] = 0;
++
+         return;
+     }
+ 
+diff --git a/qtbase/src/gui/util/qdesktopservices.cpp b/qtbase/src/gui/util/qdesktopservices.cpp
+index fbb63a9408..4d5fafaaa7 100644
+--- a/qtbase/src/gui/util/qdesktopservices.cpp
++++ b/qtbase/src/gui/util/qdesktopservices.cpp
+@@ -54,6 +54,8 @@
+ #include <qpa/qplatformintegration.h>
+ #include <qdir.h>
+ 
++#include <QtCore/private/qlocking_p.h>
++
+ QT_BEGIN_NAMESPACE
+ 
+ class QOpenUrlHandlerRegistry : public QObject
+@@ -81,6 +83,7 @@ Q_GLOBAL_STATIC(QOpenUrlHandlerRegistry, handlerRegistry)
+ 
+ void QOpenUrlHandlerRegistry::handlerDestroyed(QObject *handler)
+ {
++    const auto lock = qt_scoped_lock(mutex);
+     HandlerHash::Iterator it = handlers.begin();
+     while (it != handlers.end()) {
+         if (it->receiver == handler) {
+@@ -294,7 +297,8 @@ void QDesktopServices::setUrlHandler(const QString &scheme, QObject *receiver, c
+     h.name = method;
+     registry->handlers.insert(scheme.toLower(), h);
+     QObject::connect(receiver, SIGNAL(destroyed(QObject*)),
+-                     registry, SLOT(handlerDestroyed(QObject*)));
++                     registry, SLOT(handlerDestroyed(QObject*)),
++                     Qt::DirectConnection);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/gui/util/qpkmhandler.cpp b/qtbase/src/gui/util/qpkmhandler.cpp
+index e0c3b75efe..3414f9d8ba 100644
+--- a/qtbase/src/gui/util/qpkmhandler.cpp
++++ b/qtbase/src/gui/util/qpkmhandler.cpp
+@@ -57,7 +57,7 @@ struct PkmType
+     quint32 bytesPerBlock;
+ };
+ 
+-static PkmType typeMap[5] = {
++static constexpr PkmType typeMap[5] = {
+     { 0x8D64,  8 },   // GL_ETC1_RGB8_OES
+     { 0x9274,  8 },   // GL_COMPRESSED_RGB8_ETC2
+     { 0, 0 },         // unused (obsolete)
+diff --git a/qtbase/src/network/access/qnetworkreplyfileimpl.cpp b/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
+index b6be93147a..6e69b4c4d3 100644
+--- a/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
++++ b/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
+@@ -89,9 +89,10 @@ QNetworkReplyFileImpl::QNetworkReplyFileImpl(QNetworkAccessManager *manager, con
+         // we handle only local files
+         QString msg = QCoreApplication::translate("QNetworkAccessFileBackend", "Request for opening non-local file %1").arg(url.toString());
+         setError(QNetworkReply::ProtocolInvalidOperationError, msg);
++        setFinished(true); // We're finished, will emit finished() after ctor is done.
+         QMetaObject::invokeMethod(this, "errorOccurred", Qt::QueuedConnection,
+             Q_ARG(QNetworkReply::NetworkError, QNetworkReply::ProtocolInvalidOperationError));
+-        fileOpenFinished(false);
++        QMetaObject::invokeMethod(this, [this](){ fileOpenFinished(false); }, Qt::QueuedConnection);
+         return;
+     }
+ #endif
+diff --git a/qtbase/src/network/access/qnetworkreplyimpl.cpp b/qtbase/src/network/access/qnetworkreplyimpl.cpp
+index bcdf6ee2f1..3b6deb82bd 100644
+--- a/qtbase/src/network/access/qnetworkreplyimpl.cpp
++++ b/qtbase/src/network/access/qnetworkreplyimpl.cpp
+@@ -680,7 +680,7 @@ void QNetworkReplyImplPrivate::appendDownstreamData(QIODevice *data)
+     // read until EOF from data
+     if (Q_UNLIKELY(copyDevice)) {
+         qCritical("QNetworkReplyImpl: copy from QIODevice already in progress -- "
+-                  "backend probly needs to be fixed");
++                  "backend probably needs to be fixed");
+         return;
+     }
+ 
+diff --git a/qtbase/src/network/kernel/qauthenticator.cpp b/qtbase/src/network/kernel/qauthenticator.cpp
+index d9fe7bc47b..ccd04b294a 100644
+--- a/qtbase/src/network/kernel/qauthenticator.cpp
++++ b/qtbase/src/network/kernel/qauthenticator.cpp
+@@ -50,6 +50,7 @@
+ #include <qstring.h>
+ #include <qdatetime.h>
+ #include <qrandom.h>
++#include "private/qsystemlibrary_p.h"
+ 
+ #ifdef Q_OS_WIN
+ #include <qmutex.h>
+@@ -1563,7 +1564,7 @@ static bool q_SSPI_library_load()
+ 
+     // Initialize security interface
+     if (pSecurityFunctionTable == nullptr) {
+-        securityDLLHandle = LoadLibrary(L"secur32.dll");
++        securityDLLHandle = QSystemLibrary::load(L"secur32");
+         if (securityDLLHandle != nullptr) {
+             INIT_SECURITY_INTERFACE pInitSecurityInterface =
+                 reinterpret_cast<INIT_SECURITY_INTERFACE>(
+diff --git a/qtbase/src/network/kernel/qhostinfo_unix.cpp b/qtbase/src/network/kernel/qhostinfo_unix.cpp
+index 9b0a2ee669..73679c9ef1 100644
+--- a/qtbase/src/network/kernel/qhostinfo_unix.cpp
++++ b/qtbase/src/network/kernel/qhostinfo_unix.cpp
+@@ -122,7 +122,6 @@ static QFunctionPointer resolveSymbol(QLibrary &lib, const char *sym)
+ 
+ LibResolv::LibResolv()
+ {
+-    QLibrary lib;
+ #ifdef LIBRESOLV_SO
+     lib.setFileName(QStringLiteral(LIBRESOLV_SO));
+     if (!lib.load())
+diff --git a/qtbase/src/network/socket/qsocks5socketengine.cpp b/qtbase/src/network/socket/qsocks5socketengine.cpp
+index 3a046fd116..97fadca0b3 100644
+--- a/qtbase/src/network/socket/qsocks5socketengine.cpp
++++ b/qtbase/src/network/socket/qsocks5socketengine.cpp
+@@ -1296,7 +1296,7 @@ void QSocks5SocketEnginePrivate::_q_udpSocketReadNotification()
+         int pos = 0;
+         const char *buf = inBuf.constData();
+         if (inBuf.size() < 4) {
+-            QSOCKS5_D_DEBUG << "bugus udp data, discarding";
++            QSOCKS5_D_DEBUG << "bogus udp data, discarding";
+             return;
+         }
+         QSocks5RevivedDatagram datagram;
+diff --git a/qtbase/src/network/ssl/qsslcontext_openssl.cpp b/qtbase/src/network/ssl/qsslcontext_openssl.cpp
+index c9f202f573..c992da9d8e 100644
+--- a/qtbase/src/network/ssl/qsslcontext_openssl.cpp
++++ b/qtbase/src/network/ssl/qsslcontext_openssl.cpp
+@@ -409,7 +409,7 @@ init_context:
+         break;
+     case QSsl::DtlsV1_0OrLater:
+         minVersion = DTLS1_VERSION;
+-        maxVersion = DTLS_MAX_VERSION;
++        maxVersion = 0;
+         break;
+     case QSsl::DtlsV1_2:
+         minVersion = DTLS1_2_VERSION;
+@@ -417,7 +417,7 @@ init_context:
+         break;
+     case QSsl::DtlsV1_2OrLater:
+         minVersion = DTLS1_2_VERSION;
+-        maxVersion = DTLS_MAX_VERSION;
++        maxVersion = 0;
+         break;
+     case QSsl::TlsV1_3OrLater:
+ #ifdef TLS1_3_VERSION
+@@ -455,7 +455,7 @@ init_context:
+     }
+ 
+     // Enable bug workarounds.
+-    long options = QSslSocketBackendPrivate::setupOpenSslOptions(configuration.protocol(), configuration.d->sslOptions);
++    qssloptions options = QSslSocketBackendPrivate::setupOpenSslOptions(configuration.protocol(), configuration.d->sslOptions);
+     q_SSL_CTX_set_options(sslContext->ctx, options);
+ 
+     // Tell OpenSSL to release memory early
+diff --git a/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp b/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
+index aaf8741130..b58935372c 100644
+--- a/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
++++ b/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
+@@ -59,57 +59,6 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-#ifdef OPENSSL_NO_DEPRECATED_3_0
+-
+-static int q_DH_check(DH *dh, int *status)
+-{
+-    // DH_check was first deprecated in OpenSSL 3.0.0, as low-level
+-    // API; the EVP_PKEY family of functions was advised as an alternative.
+-    // As of now EVP_PKEY_params_check ends up calling ... DH_check,
+-    // which is good enough.
+-
+-    Q_ASSERT(dh);
+-    Q_ASSERT(status);
+-
+-    EVP_PKEY *key = q_EVP_PKEY_new();
+-    if (!key) {
+-        qCWarning(lcSsl, "EVP_PKEY_new failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-    const auto keyDeleter = qScopeGuard([key](){
+-        q_EVP_PKEY_free(key);
+-    });
+-    if (!q_EVP_PKEY_set1_DH(key, dh)) {
+-        qCWarning(lcSsl, "EVP_PKEY_set1_DH failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-
+-    EVP_PKEY_CTX *keyCtx = q_EVP_PKEY_CTX_new(key, nullptr);
+-    if (!keyCtx) {
+-        qCWarning(lcSsl, "EVP_PKEY_CTX_new failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-    const auto ctxDeleter = qScopeGuard([keyCtx]{
+-        q_EVP_PKEY_CTX_free(keyCtx);
+-    });
+-
+-    const int result = q_EVP_PKEY_param_check(keyCtx);
+-    QSslSocketBackendPrivate::logAndClearErrorQueue();
+-    // Note: unlike DH_check, we cannot obtain the 'status',
+-    // if the 'result' is 0 (actually the result is 1 only
+-    // if this 'status' was 0). We could probably check the
+-    // errors from the error queue, but it's not needed anyway
+-    // - see the 'isSafeDH' below, how it returns immediately
+-    // on 0.
+-    Q_UNUSED(status)
+-
+-    return result;
+-}
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+-
+ static bool isSafeDH(DH *dh)
+ {
+     int status = 0;
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl.cpp b/qtbase/src/network/ssl/qsslsocket_openssl.cpp
+index 37fad2a68f..8f6858c867 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl.cpp
++++ b/qtbase/src/network/ssl/qsslsocket_openssl.cpp
+@@ -550,9 +550,9 @@ static void q_loadCiphersForConnection(SSL *connection, QList<QSslCipher> &ciphe
+ // Defined in qsslsocket.cpp
+ void q_setDefaultDtlsCiphers(const QList<QSslCipher> &ciphers);
+ 
+-long QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions)
++qssloptions QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions)
+ {
+-    long options;
++    qssloptions options;
+     if (protocol == QSsl::TlsV1SslV3)
+         options = SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3;
+     else if (protocol == QSsl::SecureProtocols)
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_p.h b/qtbase/src/network/ssl/qsslsocket_openssl_p.h
+index 4103de23e8..5547589256 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_p.h
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_p.h
+@@ -107,6 +107,12 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++typedef uint64_t qssloptions;
++#else
++typedef unsigned long qssloptions;
++#endif
++
+ struct QSslErrorEntry {
+     int code;
+     int depth;
+@@ -171,7 +177,7 @@ public:
+     QVector<QSslError> ocspErrors;
+     QByteArray ocspResponseDer;
+ 
+-    Q_AUTOTEST_EXPORT static long setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions);
++    Q_AUTOTEST_EXPORT static qssloptions setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions);
+     static QSslCipher QSslCipher_from_SSL_CIPHER(const SSL_CIPHER *cipher);
+     static QList<QSslCertificate> STACKOFX509_to_QSslCertificates(STACK_OF(X509) *x509);
+     static QList<QSslError> verify(const QList<QSslCertificate> &certificateChain, const QString &hostName);
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp b/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
+index e53fb279f0..459ccd0b19 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
+@@ -148,7 +148,6 @@ DEFINEFUNC(int, EVP_PKEY_up_ref, EVP_PKEY *a, a, return 0, return)
+ DEFINEFUNC2(EVP_PKEY_CTX *, EVP_PKEY_CTX_new, EVP_PKEY *pkey, pkey, ENGINE *e, e, return nullptr, return)
+ DEFINEFUNC(int, EVP_PKEY_param_check, EVP_PKEY_CTX *ctx, ctx, return 0, return)
+ DEFINEFUNC(void, EVP_PKEY_CTX_free, EVP_PKEY_CTX *ctx, ctx, return, return)
+-DEFINEFUNC(int, EVP_PKEY_base_id, EVP_PKEY *a, a, return NID_undef, return)
+ DEFINEFUNC(int, RSA_bits, RSA *a, a, return 0, return)
+ DEFINEFUNC(int, DSA_bits, DSA *a, a, return 0, return)
+ DEFINEFUNC(int, OPENSSL_sk_num, OPENSSL_STACK *a, a, return -1, return)
+@@ -158,7 +157,7 @@ DEFINEFUNC2(void, OPENSSL_sk_push, OPENSSL_STACK *a, a, void *b, b, return, DUMM
+ DEFINEFUNC(void, OPENSSL_sk_free, OPENSSL_STACK *a, a, return, DUMMYARG)
+ DEFINEFUNC2(void *, OPENSSL_sk_value, OPENSSL_STACK *a, a, int b, b, return nullptr, return)
+ DEFINEFUNC(int, SSL_session_reused, SSL *a, a, return 0, return)
+-DEFINEFUNC2(unsigned long, SSL_CTX_set_options, SSL_CTX *ctx, ctx, unsigned long op, op, return 0, return)
++DEFINEFUNC2(qssloptions, SSL_CTX_set_options, SSL_CTX *ctx, ctx, qssloptions op, op, return 0, return)
+ DEFINEFUNC(int, SSL_CTX_get_security_level, const SSL_CTX *ctx, ctx, return -1, return)
+ DEFINEFUNC2(void, SSL_CTX_set_security_level, SSL_CTX *ctx, ctx, int level, level, return, return)
+ #ifdef TLS1_3_VERSION
+@@ -371,7 +370,15 @@ DEFINEFUNC(const SSL_CIPHER *, SSL_get_current_cipher, SSL *a, a, return nullptr
+ DEFINEFUNC(int, SSL_version, const SSL *a, a, return 0, return)
+ DEFINEFUNC2(int, SSL_get_error, SSL *a, a, int b, b, return -1, return)
+ DEFINEFUNC(STACK_OF(X509) *, SSL_get_peer_cert_chain, SSL *a, a, return nullptr, return)
++
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++DEFINEFUNC(X509 *, SSL_get1_peer_certificate, SSL *a, a, return nullptr, return)
++DEFINEFUNC(int, EVP_PKEY_get_base_id, const EVP_PKEY *pkey, pkey, return -1, return)
++#else
+ DEFINEFUNC(X509 *, SSL_get_peer_certificate, SSL *a, a, return nullptr, return)
++DEFINEFUNC(int, EVP_PKEY_base_id, EVP_PKEY *a, a, return NID_undef, return)
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+ DEFINEFUNC(long, SSL_get_verify_result, const SSL *a, a, return -1, return)
+ DEFINEFUNC(SSL *, SSL_new, SSL_CTX *a, a, return nullptr, return)
+ DEFINEFUNC(SSL_CTX *, SSL_get_SSL_CTX, SSL *a, a, return nullptr, return)
+@@ -492,9 +499,7 @@ DEFINEFUNC(DH *, DH_new, DUMMYARG, DUMMYARG, return nullptr, return)
+ DEFINEFUNC(void, DH_free, DH *dh, dh, return, DUMMYARG)
+ DEFINEFUNC3(DH *, d2i_DHparams, DH**a, a, const unsigned char **pp, pp, long length, length, return nullptr, return)
+ DEFINEFUNC2(int, i2d_DHparams, DH *a, a, unsigned char **p, p, return -1, return)
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+ DEFINEFUNC2(int, DH_check, DH *dh, dh, int *codes, codes, return 0, return)
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+ DEFINEFUNC3(BIGNUM *, BN_bin2bn, const unsigned char *s, s, int len, len, BIGNUM *ret, ret, return nullptr, return)
+ 
+ #ifndef OPENSSL_NO_EC
+@@ -868,7 +873,6 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(EVP_PKEY_CTX_new)
+     RESOLVEFUNC(EVP_PKEY_param_check)
+     RESOLVEFUNC(EVP_PKEY_CTX_free)
+-    RESOLVEFUNC(EVP_PKEY_base_id)
+     RESOLVEFUNC(RSA_bits)
+     RESOLVEFUNC(OPENSSL_sk_new_null)
+     RESOLVEFUNC(OPENSSL_sk_push)
+@@ -1107,7 +1111,15 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(SSL_version)
+     RESOLVEFUNC(SSL_get_error)
+     RESOLVEFUNC(SSL_get_peer_cert_chain)
++
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++    RESOLVEFUNC(SSL_get1_peer_certificate)
++    RESOLVEFUNC(EVP_PKEY_get_base_id)
++#else
+     RESOLVEFUNC(SSL_get_peer_certificate)
++    RESOLVEFUNC(EVP_PKEY_base_id)
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+     RESOLVEFUNC(SSL_get_verify_result)
+     RESOLVEFUNC(SSL_new)
+     RESOLVEFUNC(SSL_get_SSL_CTX)
+@@ -1206,9 +1218,7 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(DH_free)
+     RESOLVEFUNC(d2i_DHparams)
+     RESOLVEFUNC(i2d_DHparams)
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+     RESOLVEFUNC(DH_check)
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+     RESOLVEFUNC(BN_bin2bn)
+ 
+ #ifndef OPENSSL_NO_EC
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h b/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
+index 95e8897a3b..27aeffa18a 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
+@@ -237,7 +237,6 @@ Q_AUTOTEST_EXPORT int q_EVP_PKEY_up_ref(EVP_PKEY *a);
+ EVP_PKEY_CTX *q_EVP_PKEY_CTX_new(EVP_PKEY *pkey, ENGINE *e);
+ void q_EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx);
+ int q_EVP_PKEY_param_check(EVP_PKEY_CTX *ctx);
+-int q_EVP_PKEY_base_id(EVP_PKEY *a);
+ int q_RSA_bits(RSA *a);
+ Q_AUTOTEST_EXPORT int q_OPENSSL_sk_num(OPENSSL_STACK *a);
+ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_pop_free(OPENSSL_STACK *a, void (*b)(void *));
+@@ -246,7 +245,7 @@ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_push(OPENSSL_STACK *st, void *data);
+ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_free(OPENSSL_STACK *a);
+ Q_AUTOTEST_EXPORT void * q_OPENSSL_sk_value(OPENSSL_STACK *a, int b);
+ int q_SSL_session_reused(SSL *a);
+-unsigned long q_SSL_CTX_set_options(SSL_CTX *ctx, unsigned long op);
++qssloptions q_SSL_CTX_set_options(SSL_CTX *ctx, qssloptions op);
+ int q_OPENSSL_init_ssl(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings);
+ size_t q_SSL_get_client_random(SSL *a, unsigned char *out, size_t outlen);
+ size_t q_SSL_SESSION_get_master_key(const SSL_SESSION *session, unsigned char *out, size_t outlen);
+@@ -510,7 +509,6 @@ const SSL_CIPHER *q_SSL_get_current_cipher(SSL *a);
+ int q_SSL_version(const SSL *a);
+ int q_SSL_get_error(SSL *a, int b);
+ STACK_OF(X509) *q_SSL_get_peer_cert_chain(SSL *a);
+-X509 *q_SSL_get_peer_certificate(SSL *a);
+ long q_SSL_get_verify_result(const SSL *a);
+ SSL *q_SSL_new(SSL_CTX *a);
+ SSL_CTX *q_SSL_get_SSL_CTX(SSL *a);
+@@ -582,10 +580,7 @@ DH *q_DH_new();
+ void q_DH_free(DH *dh);
+ DH *q_d2i_DHparams(DH **a, const unsigned char **pp, long length);
+ int q_i2d_DHparams(DH *a, unsigned char **p);
+-
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+ int q_DH_check(DH *dh, int *codes);
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+ 
+ BIGNUM *q_BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret);
+ #define q_SSL_CTX_set_tmp_dh(ctx, dh) q_SSL_CTX_ctrl((ctx), SSL_CTRL_SET_TMP_DH, 0, (char *)dh)
+@@ -754,6 +749,17 @@ void q_CRYPTO_free(void *str, const char *file, int line);
+ int q_SSL_CTX_get_security_level(const SSL_CTX *ctx);
+ void q_SSL_CTX_set_security_level(SSL_CTX *ctx, int level);
+ 
++// Here we have the ones that make difference between OpenSSL pre/post v3:
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++X509 *q_SSL_get1_peer_certificate(SSL *a);
++#define q_SSL_get_peer_certificate q_SSL_get1_peer_certificate
++int q_EVP_PKEY_get_base_id(const EVP_PKEY *pkey);
++#define q_EVP_PKEY_base_id q_EVP_PKEY_get_base_id
++#else
++X509 *q_SSL_get_peer_certificate(SSL *a);
++int q_EVP_PKEY_base_id(EVP_PKEY *a);
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+ QT_END_NAMESPACE
+ 
+ #endif
+diff --git a/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h b/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
+index bf37d07fd8..dbd42fb799 100644
+--- a/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
++++ b/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
+@@ -61,7 +61,11 @@
+ # if !defined(Q_OS_INTEGRITY)
+ #  define WIN_INTERFACE_CUSTOM   // NV
+ # endif // Q_OS_INTEGRITY
+-#endif  // QT_EGL_NO_X11
++#else // QT_EGL_NO_X11
++// If one has an eglplatform.h with https://github.com/KhronosGroup/EGL-Registry/pull/130
++// that needs USE_X11 to be defined.
++# define USE_X11
++#endif
+ 
+ #ifdef QT_EGL_WAYLAND
+ # define WAYLAND // NV
+diff --git a/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+index 159b490ce0..00aa80cd58 100644
+--- a/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
++++ b/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+@@ -567,6 +567,8 @@ void QFontconfigDatabase::populateFontDatabase()
+         fonts = FcFontList(nullptr, pattern, os);
+         FcObjectSetDestroy(os);
+         FcPatternDestroy(pattern);
++        if (!fonts)
++            return;
+     }
+ 
+     for (int i = 0; i < fonts->nfont; i++)
+diff --git a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
+index b713c19447..7cb9a8c79a 100644
+--- a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
++++ b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
+@@ -95,6 +95,7 @@ static constexpr const auto KeyTbl = qMakeArray(
+         Xkb2Qt<XKB_KEY_Clear,                   Qt::Key_Delete>,
+         Xkb2Qt<XKB_KEY_Pause,                   Qt::Key_Pause>,
+         Xkb2Qt<XKB_KEY_Print,                   Qt::Key_Print>,
++        Xkb2Qt<XKB_KEY_Sys_Req,                 Qt::Key_SysReq>,
+         Xkb2Qt<0x1005FF60,                      Qt::Key_SysReq>,         // hardcoded Sun SysReq
+         Xkb2Qt<0x1007ff00,                      Qt::Key_SysReq>,         // hardcoded X386 SysReq
+ 
+@@ -471,7 +472,7 @@ QVector<xkb_keysym_t> QXkbCommon::toKeysym(QKeyEvent *event)
+     } else if (event->modifiers() & Qt::KeypadModifier) {
+         if (qtKey >= Qt::Key_0 && qtKey <= Qt::Key_9)
+             keysyms.append(XKB_KEY_KP_0 + (qtKey - Qt::Key_0));
+-    } else if (isLatin(qtKey) && event->text().isUpper()) {
++    } else if (isLatin1(qtKey) && event->text().isUpper()) {
+         keysyms.append(qtKey);
+     }
+ 
+@@ -523,7 +524,7 @@ int QXkbCommon::keysymToQtKey(xkb_keysym_t keysym, Qt::KeyboardModifiers modifie
+         // With standard shortcuts we should prefer a latin character, this is
+         // for checks like "some qkeyevent == QKeySequence::Copy" to work even
+         // when using for example 'russian' keyboard layout.
+-        if (!QXkbCommon::isLatin(keysym)) {
++        if (!QXkbCommon::isLatin1(keysym)) {
+             xkb_keysym_t latinKeysym = QXkbCommon::lookupLatinKeysym(state, code);
+             if (latinKeysym != XKB_KEY_NoSymbol)
+                 keysym = latinKeysym;
+@@ -546,7 +547,7 @@ static int keysymToQtKey_internal(xkb_keysym_t keysym, Qt::KeyboardModifiers mod
+     } else if (keysym >= XKB_KEY_KP_0 && keysym <= XKB_KEY_KP_9) {
+         // numeric keypad keys
+         qtKey = Qt::Key_0 + (keysym - XKB_KEY_KP_0);
+-    } else if (QXkbCommon::isLatin(keysym)) {
++    } else if (QXkbCommon::isLatin1(keysym)) {
+         qtKey = QXkbCommon::qxkbcommon_xkb_keysym_to_upper(keysym);
+     } else {
+         // check if we have a direct mapping
+@@ -678,7 +679,7 @@ QList<int> QXkbCommon::possibleKeys(xkb_state *state, const QKeyEvent *event,
+         Qt::KeyboardModifiers neededMods = ModsTbl[i];
+         if ((modifiers & neededMods) == neededMods) {
+             if (i == 8) {
+-                if (isLatin(baseQtKey))
++                if (isLatin1(baseQtKey))
+                     continue;
+                 // add a latin key as a fall back key
+                 sym = lookupLatinKeysym(state, keycode);
+@@ -733,7 +734,7 @@ void QXkbCommon::verifyHasLatinLayout(xkb_keymap *keymap)
+     for (xkb_layout_index_t layout = 0; layout < layoutCount; ++layout) {
+         for (xkb_keycode_t code = minKeycode; code < maxKeycode; ++code) {
+             xkb_keymap_key_get_syms_by_level(keymap, code, layout, 0, &keysyms);
+-            if (keysyms && isLatin(keysyms[0]))
++            if (keysyms && isLatin1(keysyms[0]))
+                 nrLatinKeys++;
+             if (nrLatinKeys > 10) // arbitrarily chosen threshold
+                 return;
+@@ -766,7 +767,7 @@ xkb_keysym_t QXkbCommon::lookupLatinKeysym(xkb_state *state, xkb_keycode_t keyco
+         xkb_level_index_t level = xkb_state_key_get_level(state, keycode, layout);
+         if (xkb_keymap_key_get_syms_by_level(keymap, keycode, layout, level, &syms) != 1)
+             continue;
+-        if (isLatin(syms[0])) {
++        if (isLatin1(syms[0])) {
+             sym = syms[0];
+             break;
+         }
+diff --git a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
+index 561eae03db..8389bd8f5a 100644
+--- a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
++++ b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
+@@ -94,8 +94,8 @@ public:
+     static void verifyHasLatinLayout(xkb_keymap *keymap);
+     static xkb_keysym_t lookupLatinKeysym(xkb_state *state, xkb_keycode_t keycode);
+ 
+-    static bool isLatin(xkb_keysym_t sym) {
+-        return ((sym >= 'a' && sym <= 'z') || (sym >= 'A' && sym <= 'Z'));
++    static bool isLatin1(xkb_keysym_t sym) {
++        return sym <= 0xff;
+     }
+     static bool isKeypad(xkb_keysym_t sym) {
+         return sym >= XKB_KEY_KP_Space && sym <= XKB_KEY_KP_9;
+diff --git a/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp b/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
+index 8cd7f9b368..406f84663f 100644
+--- a/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
++++ b/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
+@@ -318,7 +318,7 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources,
+ 
+     if (current < 0 && crtc_mode.clock != 0) {
+         modes << crtc_mode;
+-        current = mode.size() - 1;
++        current = modes.size() - 1;
+     }
+ 
+     if (configuration == OutputConfigCurrent)
+diff --git a/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp b/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
+index 9153fd20bb..255ea5e33e 100644
+--- a/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
++++ b/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
+@@ -194,6 +194,9 @@ QString AtSpiAdaptor::introspect(const QString &path) const
+                 "      <arg direction=\"out\" type=\"(so)\"/>\n"
+                 "      <annotation value=\"QSpiObjectReference\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n"
+                 "    </method>\n"
++                "    <method name=\"GetAccessibleId\">\n"
++                "      <arg direction=\"out\" type=\"s\"/>\n"
++                "    </method>\n"
+                 "  </interface>\n"
+                 );
+ 
+@@ -913,8 +916,17 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+     }
+     case QAccessible::NameChanged: {
+         if (sendObject || sendObject_property_change || sendObject_property_change_accessible_name) {
+-            QString path = pathForInterface(event->accessibleInterface());
+-            QVariantList args = packDBusSignalArguments(QLatin1String("accessible-name"), 0, 0, variantForPath(path));
++            QAccessibleInterface *iface = event->accessibleInterface();
++            if (!iface) {
++                qCDebug(lcAccessibilityAtspi,
++                        "NameChanged event from invalid accessible.");
++                return;
++            }
++
++            QString path = pathForInterface(iface);
++            QVariantList args = packDBusSignalArguments(
++                QLatin1String("accessible-name"), 0, 0,
++                QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Name))));
+             sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                            QLatin1String("PropertyChange"), args);
+         }
+@@ -922,8 +934,17 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+     }
+     case QAccessible::DescriptionChanged: {
+         if (sendObject || sendObject_property_change || sendObject_property_change_accessible_description) {
+-            QString path = pathForInterface(event->accessibleInterface());
+-            QVariantList args = packDBusSignalArguments(QLatin1String("accessible-description"), 0, 0, variantForPath(path));
++            QAccessibleInterface *iface = event->accessibleInterface();
++            if (!iface) {
++                qCDebug(lcAccessibilityAtspi,
++                        "DescriptionChanged event from invalid accessible.");
++                return;
++            }
++
++            QString path = pathForInterface(iface);
++            QVariantList args = packDBusSignalArguments(
++                QLatin1String("accessible-description"), 0, 0,
++                QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Description))));
+             sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                            QLatin1String("PropertyChange"), args);
+         }
+@@ -1038,7 +1059,9 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+                 // Combo Box with AT-SPI likes to be special
+                 // It requires a name-change to update caches and then selection-changed
+                 QString path = pathForInterface(iface);
+-                QVariantList args1 = packDBusSignalArguments(QLatin1String("accessible-name"), 0, 0, variantForPath(path));
++                QVariantList args1 = packDBusSignalArguments(
++                    QLatin1String("accessible-name"), 0, 0,
++                    QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Name))));
+                 sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                                QLatin1String("PropertyChange"), args1);
+                 QVariantList args2 = packDBusSignalArguments(QString(), 0, 0, QVariant::fromValue(QDBusVariant(QVariant(0))));
+@@ -1358,6 +1381,26 @@ void AtSpiAdaptor::registerApplication()
+     delete registry;
+ }
+ 
++namespace {
++QString accessibleIdForAccessible(QAccessibleInterface *accessible)
++{
++    QString result;
++    while (accessible) {
++        if (!result.isEmpty())
++            result.prepend(QLatin1Char('.'));
++        if (auto obj = accessible->object()) {
++            const QString name = obj->objectName();
++            if (!name.isEmpty())
++                result.prepend(name);
++            else
++                result.prepend(QString::fromUtf8(obj->metaObject()->className()));
++        }
++        accessible = accessible->parent();
++    }
++    return result;
++}
++} // namespace
++
+ // Accessible
+ bool AtSpiAdaptor::accessibleInterface(QAccessibleInterface *interface, const QString &function, const QDBusMessage &message, const QDBusConnection &connection)
+ {
+@@ -1441,6 +1484,9 @@ bool AtSpiAdaptor::accessibleInterface(QAccessibleInterface *interface, const QS
+             children << ref;
+         }
+         connection.send(message.createReply(QVariant::fromValue(children)));
++    } else if (function == QLatin1String("GetAccessibleId")) {
++        sendReply(connection, message,
++                  QVariant::fromValue(QDBusVariant(accessibleIdForAccessible(interface))));
+     } else {
+         qCDebug(lcAccessibilityAtspi) << "WARNING: AtSpiAdaptor::accessibleInterface does not implement " << function << message.path();
+         return false;
+diff --git a/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp b/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
+index 45ddc8e496..cc734abc63 100644
+--- a/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
++++ b/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
+@@ -69,6 +69,21 @@ QT_BEGIN_NAMESPACE
+ DBusConnection::DBusConnection(QObject *parent)
+     : QObject(parent), m_a11yConnection(QString()), m_enabled(false)
+ {
++    // If the bus is explicitly set via env var it overrides everything else.
++    QByteArray addressEnv = qgetenv("AT_SPI_BUS_ADDRESS");
++    if (!addressEnv.isEmpty()) {
++        // Only connect on next loop run, connections to our enabled signal are
++        // only established after the ctor returns.
++        QMetaObject::invokeMethod(
++                this,
++                [this, addressEnv] {
++                    m_enabled = true;
++                    connectA11yBus(QString::fromLocal8Bit(addressEnv));
++                },
++                Qt::QueuedConnection);
++        return;
++    }
++
+     // Start monitoring if "org.a11y.Bus" is registered as DBus service.
+     QDBusConnection c = QDBusConnection::sessionBus();
+     if (!c.isConnected()) {
+diff --git a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
+index 1a3cab275d..2abe039126 100644
+--- a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
++++ b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
+@@ -51,6 +51,9 @@
+ #include <QtCore/QStandardPaths>
+ #include <QtCore/QUrl>
+ 
++#include <QtGui/QGuiApplication>
++#include <QtGui/QWindow>
++
+ #if QT_CONFIG(dbus)
+ // These QtCore includes are needed for xdg-desktop-portal support
+ #include <QtCore/private/qcore_unix_p.h>
+@@ -58,6 +61,8 @@
+ #include <QtCore/QFileInfo>
+ #include <QtCore/QUrlQuery>
+ 
++#include <QtGui/QColor>
++
+ #include <QtDBus/QDBusConnection>
+ #include <QtDBus/QDBusMessage>
+ #include <QtDBus/QDBusPendingCall>
+@@ -142,6 +147,8 @@ static inline bool detectWebBrowser(const QByteArray &desktop,
+     }
+ 
+     if (desktop == QByteArray("KDE")) {
++        if (checkExecutable(QStringLiteral("kde-open5"), browser))
++            return true;
+         // Konqueror launcher
+         if (checkExecutable(QStringLiteral("kfmclient"), browser)) {
+             browser->append(QLatin1String(" exec"));
+@@ -296,8 +303,135 @@ static inline QDBusMessage xdgDesktopPortalSendEmail(const QUrl &url)
+ 
+     return QDBusConnection::sessionBus().call(message);
+ }
++
++namespace {
++struct XDGDesktopColor
++{
++    double r = 0;
++    double g = 0;
++    double b = 0;
++
++    QColor toQColor() const
++    {
++        constexpr auto rgbMax = 255;
++        return { static_cast<int>(r * rgbMax), static_cast<int>(g * rgbMax),
++                 static_cast<int>(b * rgbMax) };
++    }
++};
++
++const QDBusArgument &operator>>(const QDBusArgument &argument, XDGDesktopColor &myStruct)
++{
++    argument.beginStructure();
++    argument >> myStruct.r >> myStruct.g >> myStruct.b;
++    argument.endStructure();
++    return argument;
++}
++
++class XdgDesktopPortalColorPicker : public QPlatformServiceColorPicker
++{
++    Q_OBJECT
++public:
++    XdgDesktopPortalColorPicker(const QString &parentWindowId, QWindow *parent)
++        : QPlatformServiceColorPicker(parent), m_parentWindowId(parentWindowId)
++    {
++    }
++
++    void pickColor() override
++    {
++        // DBus signature:
++        // PickColor (IN   s      parent_window,
++        //            IN   a{sv}  options
++        //            OUT  o      handle)
++        // Options:
++        // handle_token (s) -  A string that will be used as the last element of the @handle.
++
++        QDBusMessage message = QDBusMessage::createMethodCall(
++                QStringLiteral("org.freedesktop.portal.Desktop"), QStringLiteral("/org/freedesktop/portal/desktop"),
++                QStringLiteral("org.freedesktop.portal.Screenshot"), QStringLiteral("PickColor"));
++        message << m_parentWindowId << QVariantMap();
++
++        QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
++        auto watcher = new QDBusPendingCallWatcher(pendingCall, this);
++        connect(watcher, &QDBusPendingCallWatcher::finished, this,
++                [this](QDBusPendingCallWatcher *watcher) {
++                    watcher->deleteLater();
++                    QDBusPendingReply<QDBusObjectPath> reply = *watcher;
++                    if (reply.isError()) {
++                        qWarning("DBus call to pick color failed: %s",
++                                 qPrintable(reply.error().message()));
++                        Q_EMIT colorPicked({});
++                    } else {
++                        QDBusConnection::sessionBus().connect(
++                                QStringLiteral("org.freedesktop.portal.Desktop"), reply.value().path(),
++                                QStringLiteral("org.freedesktop.portal.Request"), QStringLiteral("Response"), this,
++                                // clang-format off
++                                SLOT(gotColorResponse(uint,QVariantMap))
++                                // clang-format on
++                        );
++                    }
++                });
++    }
++
++private Q_SLOTS:
++    void gotColorResponse(uint result, const QVariantMap &map)
++    {
++        if (result != 0)
++            return;
++        XDGDesktopColor color{};
++        map.value(QStringLiteral("color")).value<QDBusArgument>() >> color;
++        Q_EMIT colorPicked(color.toQColor());
++        deleteLater();
++    }
++
++private:
++    const QString m_parentWindowId;
++};
++} // namespace
++
+ #endif // QT_CONFIG(dbus)
+ 
++QGenericUnixServices::QGenericUnixServices()
++{
++#if QT_CONFIG(dbus)
++    if (qEnvironmentVariableIntValue("QT_NO_XDG_DESKTOP_PORTAL") > 0) {
++        return;
++    }
++    QDBusMessage message = QDBusMessage::createMethodCall(
++            QStringLiteral("org.freedesktop.portal.Desktop"), QStringLiteral("/org/freedesktop/portal/desktop"),
++            QStringLiteral("org.freedesktop.DBus.Properties"), QStringLiteral("Get"));
++    message << QStringLiteral("org.freedesktop.portal.Screenshot")
++            << QStringLiteral("version");
++
++    QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
++    auto watcher = new QDBusPendingCallWatcher(pendingCall);
++    QObject::connect(watcher, &QDBusPendingCallWatcher::finished, watcher,
++                     [this](QDBusPendingCallWatcher *watcher) {
++                         watcher->deleteLater();
++                         QDBusPendingReply<QVariant> reply = *watcher;
++                         if (!reply.isError() && reply.value().toUInt() >= 2)
++                             m_hasScreenshotPortalWithColorPicking = true;
++                     });
++
++#endif
++}
++
++QPlatformServiceColorPicker *QGenericUnixServices::colorPicker(QWindow *parent)
++{
++#if QT_CONFIG(dbus)
++    // Make double sure that we are in a wayland environment. In particular check
++    // WAYLAND_DISPLAY so also XWayland apps benefit from portal-based color picking.
++    // Outside wayland we'll rather rely on other means than the XDG desktop portal.
++    if (!qEnvironmentVariableIsEmpty("WAYLAND_DISPLAY")
++        || QGuiApplication::platformName().startsWith(QLatin1String("wayland"))) {
++        return new XdgDesktopPortalColorPicker(portalWindowIdentifier(parent), parent);
++    }
++    return nullptr;
++#else
++    Q_UNUSED(parent);
++    return nullptr;
++#endif
++}
++
+ QByteArray QGenericUnixServices::desktopEnvironment() const
+ {
+     static const QByteArray result = detectDesktopEnvironment();
+@@ -352,6 +486,8 @@ bool QGenericUnixServices::openDocument(const QUrl &url)
+ }
+ 
+ #else
++QGenericUnixServices::QGenericUnixServices() = default;
++
+ QByteArray QGenericUnixServices::desktopEnvironment() const
+ {
+     return QByteArrayLiteral("UNKNOWN");
+@@ -371,6 +507,30 @@ bool QGenericUnixServices::openDocument(const QUrl &url)
+     return false;
+ }
+ 
++QPlatformServiceColorPicker *QGenericUnixServices::colorPicker(QWindow *parent)
++{
++    Q_UNUSED(parent);
++    return nullptr;
++}
++
+ #endif // QT_NO_MULTIPROCESS
+ 
++QString QGenericUnixServices::portalWindowIdentifier(QWindow *window)
++{
++    if (QGuiApplication::platformName() == QLatin1String("xcb"))
++        return QStringLiteral("x11:") + QString::number(window->winId(), 16);
++    return QString();
++}
++
++bool QGenericUnixServices::hasCapability(Capability capability) const
++{
++    switch (capability) {
++    case Capability::ColorPicking:
++        return m_hasScreenshotPortalWithColorPicking;
++    }
++    return false;
++}
++
+ QT_END_NAMESPACE
++
++#include "qgenericunixservices.moc"
+diff --git a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
+index 8ac3de6f03..30924e64bd 100644
+--- a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
++++ b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
+@@ -59,16 +59,21 @@ QT_BEGIN_NAMESPACE
+ class QGenericUnixServices : public QPlatformServices
+ {
+ public:
+-    QGenericUnixServices() {}
++    QGenericUnixServices();
+ 
+     QByteArray desktopEnvironment() const override;
+ 
++    bool hasCapability(Capability capability) const override;
+     bool openUrl(const QUrl &url) override;
+     bool openDocument(const QUrl &url) override;
++    QPlatformServiceColorPicker *colorPicker(QWindow *parent = nullptr) override;
++
++    virtual QString portalWindowIdentifier(QWindow *window);
+ 
+ private:
+     QString m_webBrowser;
+     QString m_documentLauncher;
++    bool m_hasScreenshotPortalWithColorPicking = false;
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
+index 09470bccc6..cc7c7d4d8a 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
+@@ -69,6 +69,7 @@ const QString MenuBarPath = QLatin1String("/MenuBar");
+ */
+ QDBusMenuConnection::QDBusMenuConnection(QObject *parent, const QString &serviceName)
+     : QObject(parent)
++    , m_serviceName(serviceName)
+     , m_connection(serviceName.isNull() ? QDBusConnection::sessionBus()
+                                         : QDBusConnection::connectToBus(QDBusConnection::SessionBus, serviceName))
+     , m_dbusWatcher(new QDBusServiceWatcher(StatusNotifierWatcherService, m_connection, QDBusServiceWatcher::WatchForRegistration, this))
+@@ -83,6 +84,12 @@ QDBusMenuConnection::QDBusMenuConnection(QObject *parent, const QString &service
+ #endif
+ }
+ 
++QDBusMenuConnection::~QDBusMenuConnection()
++{
++  if (!m_serviceName.isEmpty() && m_connection.isConnected())
++      QDBusConnection::disconnectFromBus(m_serviceName);
++}
++
+ void QDBusMenuConnection::dbusError(const QDBusError &error)
+ {
+     qWarning() << "QDBusTrayIcon encountered a D-Bus error:" << error;
+@@ -105,13 +112,7 @@ void QDBusMenuConnection::unregisterTrayIconMenu(QDBusTrayIcon *item)
+ 
+ bool QDBusMenuConnection::registerTrayIcon(QDBusTrayIcon *item)
+ {
+-    bool success = connection().registerService(item->instanceId());
+-    if (!success) {
+-        qWarning() << "failed to register service" << item->instanceId();
+-        return false;
+-    }
+-
+-    success = connection().registerObject(StatusNotifierItemPath, item);
++    bool success = connection().registerObject(StatusNotifierItemPath, item);
+     if (!success) {
+         unregisterTrayIcon(item);
+         qWarning() << "failed to register" << item->instanceId() << StatusNotifierItemPath;
+@@ -126,21 +127,18 @@ bool QDBusMenuConnection::registerTrayIcon(QDBusTrayIcon *item)
+ 
+ bool QDBusMenuConnection::registerTrayIconWithWatcher(QDBusTrayIcon *item)
+ {
++    Q_UNUSED(item);
+     QDBusMessage registerMethod = QDBusMessage::createMethodCall(
+                 StatusNotifierWatcherService, StatusNotifierWatcherPath, StatusNotifierWatcherService,
+                 QLatin1String("RegisterStatusNotifierItem"));
+-    registerMethod.setArguments(QVariantList() << item->instanceId());
++    registerMethod.setArguments(QVariantList() << m_connection.baseService());
+     return m_connection.callWithCallback(registerMethod, this, SIGNAL(trayIconRegistered()), SLOT(dbusError(QDBusError)));
+ }
+ 
+-bool QDBusMenuConnection::unregisterTrayIcon(QDBusTrayIcon *item)
++void QDBusMenuConnection::unregisterTrayIcon(QDBusTrayIcon *item)
+ {
+     unregisterTrayIconMenu(item);
+     connection().unregisterObject(StatusNotifierItemPath);
+-    bool success = connection().unregisterService(item->instanceId());
+-    if (!success)
+-        qWarning() << "failed to unregister service" << item->instanceId();
+-    return success;
+ }
+ #endif // QT_NO_SYSTEMTRAYICON
+ 
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
+index f484795fbb..97bdfabb85 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
++++ b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
+@@ -70,6 +70,7 @@ class QDBusMenuConnection : public QObject
+ 
+ public:
+     QDBusMenuConnection(QObject *parent = nullptr, const QString &serviceName = QString());
++    ~QDBusMenuConnection();
+     QDBusConnection connection() const { return m_connection; }
+     QDBusServiceWatcher *dbusWatcher() const { return m_dbusWatcher; }
+     bool isStatusNotifierHostRegistered() const { return m_statusNotifierHostRegistered; }
+@@ -78,7 +79,7 @@ public:
+     void unregisterTrayIconMenu(QDBusTrayIcon *item);
+     bool registerTrayIcon(QDBusTrayIcon *item);
+     bool registerTrayIconWithWatcher(QDBusTrayIcon *item);
+-    bool unregisterTrayIcon(QDBusTrayIcon *item);
++    void unregisterTrayIcon(QDBusTrayIcon *item);
+ #endif // QT_NO_SYSTEMTRAYICON
+ 
+ Q_SIGNALS:
+@@ -90,6 +91,7 @@ private Q_SLOTS:
+     void dbusError(const QDBusError &error);
+ 
+ private:
++    QString m_serviceName;
+     QDBusConnection m_connection;
+     QDBusServiceWatcher *m_dbusWatcher;
+     bool m_statusNotifierHostRegistered;
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp b/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
+index bede70975a..76bfec5e5a 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
+@@ -71,8 +71,12 @@ Q_LOGGING_CATEGORY(qLcTray, "qt.qpa.tray")
+ static QString iconTempPath()
+ {
+     QString tempPath = QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation);
+-    if (!tempPath.isEmpty())
++    if (!tempPath.isEmpty()) {
++        QString flatpakId = qEnvironmentVariable("FLATPAK_ID");
++        if (!flatpakId.isEmpty() && QFileInfo::exists(QLatin1String("/.flatpak-info")))
++            tempPath += QLatin1String("/app/") + flatpakId;
+         return tempPath;
++    }
+ 
+     tempPath = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation);
+ 
+diff --git a/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+index cb1b39db64..6e01af052c 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+@@ -755,6 +755,9 @@ QVariant QGnomeTheme::themeHint(QPlatformTheme::ThemeHint hint) const
+         return QVariant(QChar(0x2022));
+     case QPlatformTheme::UiEffects:
+         return QVariant(int(HoverEffect));
++    case QPlatformTheme::ButtonPressKeys:
++        return QVariant::fromValue(
++                QList<Qt::Key>({ Qt::Key_Space, Qt::Key_Return, Qt::Key_Enter, Qt::Key_Select }));
+     default:
+         break;
+     }
+diff --git a/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp b/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
+index 98e05195ee..1e92f43dec 100644
+--- a/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
++++ b/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
+@@ -343,8 +343,7 @@ void QEglFSCursor::paintOnScreen()
+     // screens are siblings of each other. When not enabled, the sibling list
+     // only contains m_screen itself.
+     for (QPlatformScreen *screen : m_screen->virtualSiblings()) {
+-        if (screen->geometry().contains(cr.topLeft().toPoint() + m_cursor.hotSpot)
+-            && QOpenGLContext::currentContext()->screen() == screen->screen())
++        if (screen->geometry().contains(cr.topLeft().toPoint() + m_cursor.hotSpot))
+         {
+             cr.translate(-screen->geometry().topLeft());
+             const QSize screenSize = screen->geometry().size();
+@@ -468,11 +467,12 @@ void QEglFSCursor::draw(const QRectF &r)
+ {
+     StateSaver stateSaver;
+ 
+-    QEglFSCursorData &gfx = static_cast<QEglFSContext*>(QOpenGLContext::currentContext()->handle())->cursorData;
+-    if (!gfx.program) {
+-        // one time initialization
++    // one time initialization
++    if (!QOpenGLFunctions::d_ptr)
+         initializeOpenGLFunctions();
+ 
++    QEglFSCursorData &gfx = static_cast<QEglFSContext*>(QOpenGLContext::currentContext()->handle())->cursorData;
++    if (!gfx.program) {
+         createShaderPrograms();
+ 
+         if (!gfx.atlasTexture) {
+diff --git a/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp b/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
+index 645a0ae2e9..3e0e406f1a 100644
+--- a/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
++++ b/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
+@@ -179,7 +179,7 @@ void QEglFSKmsEventReader::create(QEglFSKmsDevice *device)
+ 
+     m_device = device;
+ 
+-    qCDebug(qLcEglfsKmsDebug, "Initalizing event reader for device %p fd %d",
++    qCDebug(qLcEglfsKmsDebug, "Initializing event reader for device %p fd %d",
+             m_device, m_device->fd());
+ 
+     m_thread = new QEglFSKmsEventReaderThread(m_device->fd());
+diff --git a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
+index 141fb68a23..d4294d425a 100644
+--- a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
++++ b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
+@@ -122,11 +122,13 @@ QOffscreenIntegration::QOffscreenIntegration()
+ #endif
+     m_services.reset(new QPlatformServices);
+ 
+-    QWindowSystemInterface::handleScreenAdded(new QOffscreenScreen);
++    m_screen = new QOffscreenScreen;
++    QWindowSystemInterface::handleScreenAdded(m_screen);
+ }
+ 
+ QOffscreenIntegration::~QOffscreenIntegration()
+ {
++    QWindowSystemInterface::handleScreenRemoved(m_screen);
+ }
+ 
+ void QOffscreenIntegration::initialize()
+diff --git a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
+index 0ea90f6c2f..fe00fde07c 100644
+--- a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
++++ b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
+@@ -84,6 +84,7 @@ protected:
+ #endif
+     QScopedPointer<QPlatformInputContext> m_inputContext;
+     QScopedPointer<QPlatformServices> m_services;
++    QPlatformScreen *m_screen;
+     mutable QScopedPointer<QPlatformNativeInterface> m_nativeInterface;
+ };
+ 
+diff --git a/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp b/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
+index 6fa5a8a2b3..1f49f0aefd 100644
+--- a/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
++++ b/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
+@@ -48,6 +48,7 @@
+ #include <qpa/qplatformnativeinterface.h>
+ #include <QtPlatformHeaders/qwglnativecontext.h>
+ 
++#include <private/qsystemlibrary_p.h>
+ #include <algorithm>
+ 
+ #include <wingdi.h>
+@@ -162,19 +163,25 @@ QFunctionPointer QWindowsOpengl32DLL::resolve(const char *name)
+ 
+ bool QWindowsOpengl32DLL::init(bool softwareRendering)
+ {
+-    const QByteArray opengl32 = QByteArrayLiteral("opengl32.dll");
+-    const QByteArray swopengl = QByteArrayLiteral("opengl32sw.dll");
++    const QByteArray opengl32 = QByteArrayLiteral("opengl32");
++    const QByteArray swopengl = QByteArrayLiteral("opengl32sw");
++    bool useSystemLib = false;
+ 
+     QByteArray openglDll = qgetenv("QT_OPENGL_DLL");
+-    if (openglDll.isEmpty())
++    if (openglDll.isEmpty()) {
+         openglDll = softwareRendering ? swopengl : opengl32;
++        useSystemLib = !softwareRendering;
++    }
+ 
+     openglDll = openglDll.toLower();
+     m_nonOpengl32 = openglDll != opengl32;
+ 
+     qCDebug(lcQpaGl) << "Qt: Using WGL and OpenGL from" << openglDll;
+ 
+-    m_lib = ::LoadLibraryA(openglDll.constData());
++    if (useSystemLib)
++        m_lib = QSystemLibrary::load((wchar_t*)(QString::fromLatin1(openglDll).utf16()));
++    else
++        m_lib = LoadLibraryA(openglDll.constData());
+     if (!m_lib) {
+         qErrnoWarning(::GetLastError(), "Failed to load %s", openglDll.constData());
+         return false;
+@@ -184,7 +191,7 @@ bool QWindowsOpengl32DLL::init(bool softwareRendering)
+         // Load opengl32.dll always. GDI functions like ChoosePixelFormat do
+         // GetModuleHandle for opengl32.dll and behave differently (and call back into
+         // opengl32) when the module is present. This is fine for dummy contexts and windows.
+-        ::LoadLibraryA("opengl32.dll");
++        QSystemLibrary::load(L"opengl32");
+     }
+ 
+     wglCreateContext = reinterpret_cast<HGLRC (WINAPI *)(HDC)>(resolve("wglCreateContext"));
+diff --git a/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp b/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
+index d7d186e804..9eb4011bf2 100644
+--- a/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
++++ b/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
+@@ -49,6 +49,7 @@
+ #include <QtCore/qstandardpaths.h>
+ #include <QtCore/qlibraryinfo.h>
+ #include <QtCore/qhash.h>
++#include <private/qsystemlibrary_p.h>
+ 
+ #ifndef QT_NO_OPENGL
+ #include <private/qopengl_p.h>
+@@ -396,7 +397,7 @@ bool QWindowsOpenGLTester::testDesktopGL()
+ 
+     // Test #1: Load opengl32.dll and try to resolve an OpenGL 2 function.
+     // This will typically fail on systems that do not have a real OpenGL driver.
+-    lib = LoadLibraryA("opengl32.dll");
++    lib = QSystemLibrary::load(L"opengl32");
+     if (lib) {
+         CreateContext = reinterpret_cast<CreateContextType>(
+             reinterpret_cast<QFunctionPointer>(::GetProcAddress(lib, "wglCreateContext")));
+diff --git a/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp b/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
+index 1afa00cfc9..118af6ce73 100644
+--- a/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
++++ b/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
+@@ -41,6 +41,7 @@
+ 
+ #include <QRect>
+ #include <QList>
++#include <QMap>
+ #include <QDebug>
+ 
+ #include <qmath.h>
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp b/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
+index 9e2a37a6a1..e6e175a118 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
+@@ -488,12 +488,12 @@ void QXcbConnection::printXcbError(const char *message, xcb_generic_error_t *err
+     uint clamped_error_code = qMin<uint>(error->error_code, (sizeof(xcb_errors) / sizeof(xcb_errors[0])) - 1);
+     uint clamped_major_code = qMin<uint>(error->major_code, (sizeof(xcb_protocol_request_codes) / sizeof(xcb_protocol_request_codes[0])) - 1);
+ 
+-    qCWarning(lcQpaXcb, "%s: %d (%s), sequence: %d, resource id: %d, major code: %d (%s), minor code: %d",
+-             message,
+-             int(error->error_code), xcb_errors[clamped_error_code],
+-             int(error->sequence), int(error->resource_id),
+-             int(error->major_code), xcb_protocol_request_codes[clamped_major_code],
+-             int(error->minor_code));
++    qCDebug(lcQpaXcb, "%s: %d (%s), sequence: %d, resource id: %d, major code: %d (%s), minor code: %d",
++            message,
++            int(error->error_code), xcb_errors[clamped_error_code],
++            int(error->sequence), int(error->resource_id),
++            int(error->major_code), xcb_protocol_request_codes[clamped_major_code],
++            int(error->minor_code));
+ }
+ 
+ static Qt::MouseButtons translateMouseButtons(int s)
+@@ -702,6 +702,8 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
+             QXcbVirtualDesktop *virtualDesktop = virtualDesktopForRootWindow(propertyNotify->window);
+             if (virtualDesktop)
+                 virtualDesktop->updateWorkArea();
++        } else if (propertyNotify->atom == atom(QXcbAtom::_NET_SUPPORTED)) {
++            m_wmSupport->updateNetWMAtoms();
+         } else {
+             HANDLE_PLATFORM_WINDOW_EVENT(xcb_property_notify_event_t, window, handlePropertyNotifyEvent);
+         }
+@@ -750,7 +752,7 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
+                 case XCB_XKB_NEW_KEYBOARD_NOTIFY: {
+                     xcb_xkb_new_keyboard_notify_event_t *ev = &xkb_event->new_keyboard_notify;
+                     if (ev->changed & XCB_XKB_NKN_DETAIL_KEYCODES)
+-                        m_keyboard->updateKeymap(ev);
++                        m_keyboard->updateKeymap();
+                     break;
+                 }
+                 default:
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp b/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
+index 76869ced60..02d2eebb56 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
+@@ -274,8 +274,7 @@ QPlatformWindow *QXcbIntegration::createForeignWindow(QWindow *window, WId nativ
+ #ifndef QT_NO_OPENGL
+ QPlatformOpenGLContext *QXcbIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
+ {
+-    QXcbScreen *screen = static_cast<QXcbScreen *>(context->screen()->handle());
+-    QXcbGlIntegration *glIntegration = screen->connection()->glIntegration();
++    QXcbGlIntegration *glIntegration = defaultConnection()->glIntegration();
+     if (!glIntegration) {
+         qWarning("QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled");
+         return nullptr;
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+index efecd7e2d1..e8286381a2 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+@@ -365,17 +365,6 @@ void QXcbKeyboard::updateKeymap(xcb_mapping_notify_event_t *event)
+     updateKeymap();
+ }
+ 
+-void QXcbKeyboard::updateKeymap(xcb_xkb_new_keyboard_notify_event_t *event)
+-{
+-    if (!event)
+-        return;
+-
+-    if (event->deviceID != event->oldDeviceID)
+-        m_config = false;
+-
+-    updateKeymap();
+-}
+-
+ void QXcbKeyboard::updateKeymap()
+ {
+     KeysymModifierMap keysymMods;
+@@ -383,6 +372,8 @@ void QXcbKeyboard::updateKeymap()
+         keysymMods = keysymsToModifiers();
+     updateModifiers(keysymMods);
+ 
++    m_config = true;
++
+     if (!m_xkbContext) {
+         m_xkbContext.reset(xkb_context_new(XKB_CONTEXT_NO_DEFAULT_INCLUDES));
+         if (!m_xkbContext) {
+@@ -398,13 +389,8 @@ void QXcbKeyboard::updateKeymap()
+     if (connection()->hasXKB()) {
+         m_xkbKeymap.reset(xkb_x11_keymap_new_from_device(m_xkbContext.get(), xcb_connection(),
+                                                          core_device_id, XKB_KEYMAP_COMPILE_NO_FLAGS));
+-        if (m_xkbKeymap) {
+-            if (m_config)
+-                m_xkbState.reset(xkb_state_new(m_xkbKeymap.get()));
+-            else
+-                m_xkbState.reset(xkb_x11_state_new_from_device(m_xkbKeymap.get(), xcb_connection(), core_device_id));
+-
+-        }
++        if (m_xkbKeymap)
++            m_xkbState.reset(xkb_x11_state_new_from_device(m_xkbKeymap.get(), xcb_connection(), core_device_id));
+     } else {
+         m_xkbKeymap.reset(keymapFromCore(keysymMods));
+         if (m_xkbKeymap)
+@@ -425,8 +411,6 @@ void QXcbKeyboard::updateKeymap()
+     updateXKBMods();
+ 
+     QXkbCommon::verifyHasLatinLayout(m_xkbKeymap.get());
+-
+-    m_config = true;
+ }
+ 
+ QList<int> QXcbKeyboard::possibleKeys(const QKeyEvent *event) const
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
+index b652c85fe3..0ee08aeff2 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
++++ b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
+@@ -69,7 +69,6 @@ public:
+ 
+     Qt::KeyboardModifiers translateModifiers(int s) const;
+     void updateKeymap(xcb_mapping_notify_event_t *event);
+-    void updateKeymap(xcb_xkb_new_keyboard_notify_event_t *event);
+     void updateKeymap();
+     QList<int> possibleKeys(const QKeyEvent *event) const;
+ 
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp b/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
+index ffda7b6a57..863e961f4c 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
+@@ -564,11 +564,6 @@ void QXcbWindow::setGeometry(const QRect &rect)
+ {
+     QPlatformWindow::setGeometry(rect);
+ 
+-    if (shouldDeferTask(Task::SetGeometry)) {
+-        m_deferredGeometry = rect;
+-        return;
+-    }
+-
+     propagateSizeHints();
+ 
+     QXcbScreen *currentScreen = xcbScreen();
+@@ -693,9 +688,6 @@ void QXcbWindow::setVisible(bool visible)
+ 
+ void QXcbWindow::show()
+ {
+-    if (shouldDeferTask(Task::Map))
+-        return;
+-
+     if (window()->isTopLevel()) {
+ 
+         // update WM_NORMAL_HINTS
+@@ -706,7 +698,7 @@ void QXcbWindow::show()
+         if (isTransient(window())) {
+             const QWindow *tp = window()->transientParent();
+             if (tp && tp->handle())
+-                transientXcbParent = static_cast<const QXcbWindow *>(tp->handle())->winId();
++                transientXcbParent = tp->handle()->winId();
+             // Default to client leader if there is no transient parent, else modal dialogs can
+             // be hidden by their parents.
+             if (!transientXcbParent)
+@@ -746,10 +738,6 @@ void QXcbWindow::show()
+ 
+ void QXcbWindow::hide()
+ {
+-    if (shouldDeferTask(Task::Unmap))
+-        return;
+-
+-    m_wmStateValid = false;
+     xcb_unmap_window(xcb_connection(), m_window);
+ 
+     // send synthetic UnmapNotify event according to icccm 4.1.4
+@@ -909,9 +897,6 @@ QXcbWindow::NetWmStates QXcbWindow::netWmStates()
+ 
+ void QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
+ {
+-    if (shouldDeferTask(Task::SetWindowFlags))
+-        return;
+-
+     Qt::WindowType type = static_cast<Qt::WindowType>(int(flags & Qt::WindowType_Mask));
+ 
+     if (type == Qt::ToolTip)
+@@ -941,8 +926,6 @@ void QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
+ 
+     setTransparentForMouseEvents(flags & Qt::WindowTransparentForInput);
+     updateDoesNotAcceptFocus(flags & Qt::WindowDoesNotAcceptFocus);
+-
+-    m_isWmManagedWindow = !(flags & Qt::X11BypassWindowManagerHint);
+ }
+ 
+ void QXcbWindow::setMotifWmHints(Qt::WindowFlags flags)
+@@ -1142,9 +1125,6 @@ void QXcbWindow::setWindowState(Qt::WindowStates state)
+     if (state == m_windowState)
+         return;
+ 
+-    if (shouldDeferTask(Task::SetWindowState))
+-        return;
+-
+     // unset old state
+     if (m_windowState & Qt::WindowMinimized)
+         xcb_map_window(xcb_connection(), m_window);
+@@ -1350,6 +1330,12 @@ void QXcbWindow::setWindowIcon(const QIcon &icon)
+     }
+ 
+     if (!icon_data.isEmpty()) {
++        // Ignore icon exceeding maximum xcb request length
++        if (icon_data.size() > xcb_get_maximum_request_length(xcb_connection())) {
++            qWarning("Ignoring window icon: Size %llu exceeds maximum xcb request length %u.",
++                     icon_data.size(), xcb_get_maximum_request_length(xcb_connection()));
++            return;
++        }
+         xcb_change_property(xcb_connection(),
+                             XCB_PROP_MODE_REPLACE,
+                             m_window,
+@@ -1639,7 +1625,7 @@ void QXcbWindow::setWmWindowType(QXcbWindowFunctions::WmWindowTypes types, Qt::W
+         break;
+     }
+ 
+-    if ((flags & Qt::FramelessWindowHint) && !(type & QXcbWindowFunctions::KdeOverride)) {
++    if ((flags & Qt::FramelessWindowHint) && !(types & QXcbWindowFunctions::KdeOverride)) {
+         // override netwm type - quick and easy for KDE noborder
+         atoms.append(atom(QXcbAtom::_KDE_NET_WM_WINDOW_TYPE_OVERRIDE));
+     }
+@@ -1894,10 +1880,6 @@ void QXcbWindow::handleUnmapNotifyEvent(const xcb_unmap_notify_event_t *event)
+     if (event->window == m_window) {
+         m_mapped = false;
+         QWindowSystemInterface::handleExposeEvent(window(), QRegion());
+-        if (!m_isWmManagedWindow || parent()) {
+-            m_wmStateValid = true;
+-            handleDeferredTasks();
+-        }
+     }
+ }
+ 
+@@ -2212,98 +2194,30 @@ void QXcbWindow::handleLeaveNotifyEvent(const xcb_leave_notify_event_t *event)
+     handleLeaveNotifyEvent(event->root_x, event->root_y, event->mode, event->detail, event->time);
+ }
+ 
+-bool QXcbWindow::shouldDeferTask(Task task)
+-{
+-    if (m_wmStateValid)
+-        return false;
+-
+-    m_deferredTasks.append(task);
+-    return true;
+-}
+-
+-void QXcbWindow::handleDeferredTasks()
+-{
+-    Q_ASSERT(m_wmStateValid == true);
+-    if (m_deferredTasks.isEmpty())
+-        return;
+-
+-    bool map = false;
+-    bool unmap = false;
+-
+-    QVector<Task> tasks;
+-    for (auto taskIt = m_deferredTasks.rbegin(); taskIt != m_deferredTasks.rend(); ++taskIt) {
+-        if (!tasks.contains(*taskIt))
+-            tasks.prepend(*taskIt);
+-    }
+-
+-    for (Task task : tasks) {
+-        switch (task) {
+-        case Task::Map:
+-            map = true;
+-            unmap = false;
+-            break;
+-        case Task::Unmap:
+-            unmap = true;
+-            map = false;
+-            break;
+-        case Task::SetGeometry:
+-            setGeometry(m_deferredGeometry);
+-            break;
+-        case Task::SetWindowFlags:
+-            setWindowFlags(window()->flags());
+-            break;
+-        case Task::SetWindowState:
+-            setWindowState(window()->windowState());
+-            break;
+-        }
+-    }
+-    m_deferredTasks.clear();
+-
+-    if (map) {
+-        Q_ASSERT(unmap == false);
+-        show();
+-    }
+-    if (unmap) {
+-        Q_ASSERT(map == false);
+-        hide();
+-    }
+-}
+-
+ void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *event)
+ {
+     connection()->setTime(event->time);
+ 
+-    const bool wmStateChanged = event->atom == atom(QXcbAtom::WM_STATE);
+-    const bool netWmStateChanged = event->atom == atom(QXcbAtom::_NET_WM_STATE);
+-    if (netWmStateChanged || wmStateChanged) {
+-        if (wmStateChanged && !m_wmStateValid && m_isWmManagedWindow) {
+-            // ICCCM 4.1.4
+-            // Clients that want to re-use a client window (e.g. by mapping it again)
+-            // after withdrawing it must wait for the withdrawal to be complete before
+-            // proceeding. The preferred method for doing this is for clients to wait for
+-            // a window manager to update or remove the WM_STATE property.
+-            m_wmStateValid = true;
+-            handleDeferredTasks();
+-        }
+-        if (event->state == XCB_PROPERTY_DELETE)
++    const bool propertyDeleted = event->state == XCB_PROPERTY_DELETE;
++
++    if (event->atom == atom(QXcbAtom::_NET_WM_STATE) || event->atom == atom(QXcbAtom::WM_STATE)) {
++        if (propertyDeleted)
+             return;
+ 
+-        if (wmStateChanged) {
++        Qt::WindowStates newState = Qt::WindowNoState;
++
++        if (event->atom == atom(QXcbAtom::WM_STATE)) { // WM_STATE: Quick check for 'Minimize'.
+             auto reply = Q_XCB_REPLY(xcb_get_property, xcb_connection(),
+                                      0, m_window, atom(QXcbAtom::WM_STATE),
+                                      XCB_ATOM_ANY, 0, 1024);
+             if (reply && reply->format == 32 && reply->type == atom(QXcbAtom::WM_STATE)) {
+-                auto data = static_cast<const quint32 *>(xcb_get_property_value(reply.get()));
+-                if (reply->length != 0) {
+-                    const bool changedToWithdrawn = data[0] == XCB_ICCCM_WM_STATE_WITHDRAWN;
+-                    const bool changedToIconic = data[0] == XCB_ICCCM_WM_STATE_ICONIC;
+-                    m_minimized = changedToIconic || (changedToWithdrawn && m_minimized);
+-                }
++                const quint32 *data = (const quint32 *)xcb_get_property_value(reply.get());
++                if (reply->length != 0)
++                    m_minimized = (data[0] == XCB_ICCCM_WM_STATE_ICONIC
++                                   || (data[0] == XCB_ICCCM_WM_STATE_WITHDRAWN && m_minimized));
+             }
+         }
+ 
+-        // _NET_WM_STATE handling
+-        Qt::WindowStates newState = Qt::WindowNoState;
+         const NetWmStates states = netWmStates();
+         // _NET_WM_STATE_HIDDEN should be set by the Window Manager to indicate that a window would
+         // not be visible on the screen if its desktop/viewport were active and its coordinates were
+@@ -2325,6 +2239,7 @@ void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *ev
+             if ((m_windowState & Qt::WindowMinimized) && connection()->mouseGrabber() == this)
+                 connection()->setMouseGrabber(nullptr);
+         }
++        return;
+     } else if (event->atom == atom(QXcbAtom::_NET_FRAME_EXTENTS)) {
+         m_dirtyFrameMargins = true;
+     }
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbwindow.h b/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
+index 55af9279b1..6f5c1f5ed9 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
++++ b/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
+@@ -74,14 +74,6 @@ public:
+ 
+     Q_DECLARE_FLAGS(NetWmStates, NetWmState)
+ 
+-    enum Task {
+-        Map,
+-        Unmap,
+-        SetGeometry,
+-        SetWindowFlags,
+-        SetWindowState
+-    };
+-
+     QXcbWindow(QWindow *window);
+     ~QXcbWindow();
+ 
+@@ -151,9 +143,6 @@ public:
+ 
+     QXcbWindow *toWindow() override;
+ 
+-    bool shouldDeferTask(Task task);
+-    void handleDeferredTasks();
+-
+     void handleMouseEvent(xcb_timestamp_t time, const QPoint &local, const QPoint &global,
+                           Qt::KeyboardModifiers modifiers, QEvent::Type type, Qt::MouseEventSource source);
+ 
+@@ -292,11 +281,6 @@ protected:
+     int m_swapInterval = -1;
+ 
+     qreal m_sizeHintsScaleFactor = 1.0;
+-
+-    bool m_wmStateValid = true;
+-    QVector<Task> m_deferredTasks;
+-    bool m_isWmManagedWindow = true;
+-    QRect m_deferredGeometry;
+ };
+ 
+ class QXcbForeignWindow : public QXcbWindow
+diff --git a/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp b/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
+index d9d117faeb..640b49daa0 100644
+--- a/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
++++ b/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
+@@ -85,6 +85,7 @@ QGtk3MenuItem::QGtk3MenuItem()
+       m_checkable(false),
+       m_checked(false),
+       m_enabled(true),
++      m_exclusive(false),
+       m_underline(false),
+       m_invalid(true),
+       m_menu(nullptr),
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
+index 0048bbc1e6..396e7f6d1c 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
+@@ -102,15 +102,12 @@ const QDBusArgument &operator >>(const QDBusArgument &arg, QXdgDesktopPortalFile
+ class QXdgDesktopPortalFileDialogPrivate
+ {
+ public:
+-    QXdgDesktopPortalFileDialogPrivate(QPlatformFileDialogHelper *nativeFileDialog)
++    QXdgDesktopPortalFileDialogPrivate(QPlatformFileDialogHelper *nativeFileDialog, uint fileChooserPortalVersion)
+         : nativeFileDialog(nativeFileDialog)
++        , fileChooserPortalVersion(fileChooserPortalVersion)
+     { }
+ 
+-    WId winId = 0;
+-    bool directoryMode = false;
+-    bool modal = false;
+-    bool multipleFiles = false;
+-    bool saveFile = false;
++    QEventLoop loop;
+     QString acceptLabel;
+     QString directory;
+     QString title;
+@@ -121,19 +118,27 @@ public:
+     QString selectedMimeTypeFilter;
+     QString selectedNameFilter;
+     QStringList selectedFiles;
+-    QPlatformFileDialogHelper *nativeFileDialog = nullptr;
++    std::unique_ptr<QPlatformFileDialogHelper> nativeFileDialog;
++    uint fileChooserPortalVersion = 0;
++    bool failedToOpen = false;
++    bool directoryMode = false;
++    bool multipleFiles = false;
++    bool saveFile = false;
+ };
+ 
+-QXdgDesktopPortalFileDialog::QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog)
++QXdgDesktopPortalFileDialog::QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog, uint fileChooserPortalVersion)
+     : QPlatformFileDialogHelper()
+-    , d_ptr(new QXdgDesktopPortalFileDialogPrivate(nativeFileDialog))
++    , d_ptr(new QXdgDesktopPortalFileDialogPrivate(nativeFileDialog, fileChooserPortalVersion))
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+     if (d->nativeFileDialog) {
+-        connect(d->nativeFileDialog, SIGNAL(accept()), this, SIGNAL(accept()));
+-        connect(d->nativeFileDialog, SIGNAL(reject()), this, SIGNAL(reject()));
++        connect(d->nativeFileDialog.get(), SIGNAL(accept()), this, SIGNAL(accept()));
++        connect(d->nativeFileDialog.get(), SIGNAL(reject()), this, SIGNAL(reject()));
+     }
++
++    d->loop.connect(this, SIGNAL(accept()), SLOT(quit()));
++    d->loop.connect(this, SIGNAL(reject()), SLOT(quit()));
+ }
+ 
+ QXdgDesktopPortalFileDialog::~QXdgDesktopPortalFileDialog()
+@@ -177,7 +182,7 @@ void QXdgDesktopPortalFileDialog::initializeDialog()
+     setDirectory(options()->initialDirectory());
+ }
+ 
+-void QXdgDesktopPortalFileDialog::openPortal()
++void QXdgDesktopPortalFileDialog::openPortal(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent)
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+@@ -185,13 +190,13 @@ void QXdgDesktopPortalFileDialog::openPortal()
+                                                           QLatin1String("/org/freedesktop/portal/desktop"),
+                                                           QLatin1String("org.freedesktop.portal.FileChooser"),
+                                                           d->saveFile ? QLatin1String("SaveFile") : QLatin1String("OpenFile"));
+-    QString parentWindowId = QLatin1String("x11:") + QString::number(d->winId, 16);
++    QString parentWindowId = QLatin1String("x11:") + QString::number(parent ? parent->winId() : 0, 16);
+ 
+     QVariantMap options;
+     if (!d->acceptLabel.isEmpty())
+         options.insert(QLatin1String("accept_label"), d->acceptLabel);
+ 
+-    options.insert(QLatin1String("modal"), d->modal);
++    options.insert(QLatin1String("modal"), windowModality != Qt::NonModal);
+     options.insert(QLatin1String("multiple"), d->multipleFiles);
+     options.insert(QLatin1String("directory"), d->directoryMode);
+ 
+@@ -290,10 +295,18 @@ void QXdgDesktopPortalFileDialog::openPortal()
+ 
+     QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
+     QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingCall);
+-    connect(watcher, &QDBusPendingCallWatcher::finished, this, [this] (QDBusPendingCallWatcher *watcher) {
++    connect(watcher, &QDBusPendingCallWatcher::finished, this, [=] (QDBusPendingCallWatcher *watcher) {
+         QDBusPendingReply<QDBusObjectPath> reply = *watcher;
+-        if (reply.isError()) {
+-            Q_EMIT reject();
++        // Any error means the dialog is not shown and we need to fallback
++        d->failedToOpen = reply.isError();
++        if (d->failedToOpen) {
++            if (d->nativeFileDialog) {
++                d->nativeFileDialog->show(windowFlags, windowModality, parent);
++                if (d->loop.isRunning())
++                    d->nativeFileDialog->exec();
++            } else {
++                Q_EMIT reject();
++            }
+         } else {
+             QDBusConnection::sessionBus().connect(nullptr,
+                                                   reply.value().path(),
+@@ -302,6 +315,7 @@ void QXdgDesktopPortalFileDialog::openPortal()
+                                                   this,
+                                                   SLOT(gotResponse(uint,QVariantMap)));
+         }
++        watcher->deleteLater();
+     });
+ }
+ 
+@@ -326,7 +340,7 @@ QUrl QXdgDesktopPortalFileDialog::directory() const
+ {
+     Q_D(const QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog())
+         return d->nativeFileDialog->directory();
+ 
+     return d->directory;
+@@ -348,7 +362,7 @@ QList<QUrl> QXdgDesktopPortalFileDialog::selectedFiles() const
+ {
+     Q_D(const QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog())
+         return d->nativeFileDialog->selectedFiles();
+ 
+     QList<QUrl> files;
+@@ -403,16 +417,13 @@ void QXdgDesktopPortalFileDialog::exec()
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly)) {
++    if (d->nativeFileDialog && useNativeFileDialog()) {
+         d->nativeFileDialog->exec();
+         return;
+     }
+ 
+     // HACK we have to avoid returning until we emit that the dialog was accepted or rejected
+-    QEventLoop loop;
+-    loop.connect(this, SIGNAL(accept()), SLOT(quit()));
+-    loop.connect(this, SIGNAL(reject()), SLOT(quit()));
+-    loop.exec();
++    d->loop.exec();
+ }
+ 
+ void QXdgDesktopPortalFileDialog::hide()
+@@ -429,13 +440,10 @@ bool QXdgDesktopPortalFileDialog::show(Qt::WindowFlags windowFlags, Qt::WindowMo
+ 
+     initializeDialog();
+ 
+-    d->modal = windowModality != Qt::NonModal;
+-    d->winId = parent ? parent->winId() : 0;
+-
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog(OpenFallback))
+         return d->nativeFileDialog->show(windowFlags, windowModality, parent);
+ 
+-    openPortal();
++    openPortal(windowFlags, windowModality, parent);
+ 
+     return true;
+ }
+@@ -465,4 +473,21 @@ void QXdgDesktopPortalFileDialog::gotResponse(uint response, const QVariantMap &
+     }
+ }
+ 
++bool QXdgDesktopPortalFileDialog::useNativeFileDialog(QXdgDesktopPortalFileDialog::FallbackType fallbackType) const
++{
++    Q_D(const QXdgDesktopPortalFileDialog);
++
++    if (d->failedToOpen && fallbackType != OpenFallback)
++        return true;
++
++    if (d->fileChooserPortalVersion < 3) {
++        if (options()->fileMode() == QFileDialogOptions::Directory)
++            return true;
++        else if (options()->fileMode() == QFileDialogOptions::DirectoryOnly)
++            return true;
++    }
++
++    return false;
++}
++
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
+index 4f4de96ecf..65e22a5cf2 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
+@@ -51,6 +51,11 @@ class QXdgDesktopPortalFileDialog : public QPlatformFileDialogHelper
+     Q_OBJECT
+     Q_DECLARE_PRIVATE(QXdgDesktopPortalFileDialog)
+ public:
++    enum FallbackType {
++        GenericFallback,
++        OpenFallback
++    };
++
+     enum ConditionType : uint {
+         GlobalPattern = 0,
+         MimeType = 1
+@@ -69,7 +74,7 @@ public:
+     };
+     typedef QVector<Filter> FilterList;
+ 
+-    QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog = nullptr);
++    QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog = nullptr, uint fileChooserPortalVersion = 0);
+     ~QXdgDesktopPortalFileDialog();
+ 
+     bool defaultNameFilterDisables() const override;
+@@ -92,7 +97,8 @@ private Q_SLOTS:
+ 
+ private:
+     void initializeDialog();
+-    void openPortal();
++    void openPortal(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent);
++    bool useNativeFileDialog(FallbackType fallbackType = GenericFallback) const;
+ 
+     QScopedPointer<QXdgDesktopPortalFileDialogPrivate> d_ptr;
+ };
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
+index fb324afbd8..b809503122 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
+@@ -111,6 +111,7 @@ QXdgDesktopPortalTheme::QXdgDesktopPortalTheme()
+         if (reply.isValid()) {
+             d->fileChooserPortalVersion = reply.value().toUInt();
+         }
++        watcher->deleteLater();
+     });
+ }
+ 
+@@ -152,11 +153,12 @@ QPlatformDialogHelper* QXdgDesktopPortalTheme::createPlatformDialogHelper(Dialog
+ {
+     Q_D(const QXdgDesktopPortalTheme);
+ 
+-    if (type == FileDialog) {
++    if (type == FileDialog && d->fileChooserPortalVersion) {
+         // Older versions of FileChooser portal don't support opening directories, therefore we fallback
+         // to native file dialog opened inside the sandbox to open a directory.
+-        if (d->fileChooserPortalVersion < 3 && d->baseTheme->usePlatformNativeDialog(type))
+-            return new QXdgDesktopPortalFileDialog(static_cast<QPlatformFileDialogHelper*>(d->baseTheme->createPlatformDialogHelper(type)));
++        if (d->baseTheme->usePlatformNativeDialog(type))
++            return new QXdgDesktopPortalFileDialog(static_cast<QPlatformFileDialogHelper*>(d->baseTheme->createPlatformDialogHelper(type)),
++                                                   d->fileChooserPortalVersion);
+ 
+         return new QXdgDesktopPortalFileDialog;
+     }
+diff --git a/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp b/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
+index 43d5e119ad..1f9cbc4565 100644
+--- a/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
++++ b/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
+@@ -89,8 +89,10 @@ void QCupsPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &v
+         break;
+     case PPK_Duplex: {
+         QPrint::DuplexMode mode = QPrint::DuplexMode(value.toInt());
+-        if (mode != d->duplex && d->m_printDevice.supportedDuplexModes().contains(mode))
++        if (d->m_printDevice.supportedDuplexModes().contains(mode)) {
+             d->duplex = mode;
++            d->duplexRequestedExplicitly = true;
++        }
+         break;
+     }
+     case PPK_PrinterName:
+@@ -277,9 +279,12 @@ void QCupsPrintEnginePrivate::changePrinter(const QString &newPrinter)
+     m_printDevice.swap(printDevice);
+     printerName = m_printDevice.id();
+ 
+-    // Check if new printer supports current settings, otherwise us defaults
+-    if (duplex != QPrint::DuplexAuto && !m_printDevice.supportedDuplexModes().contains(duplex))
++    // in case a duplex value was explicitly set, check if new printer supports current value,
++    // otherwise use device default
++    if (!duplexRequestedExplicitly || !m_printDevice.supportedDuplexModes().contains(duplex)) {
+         duplex = m_printDevice.defaultDuplexMode();
++        duplexRequestedExplicitly = false;
++    }
+     QPrint::ColorMode colorMode = grayscale ? QPrint::GrayScale : QPrint::Color;
+     if (!m_printDevice.supportedColorModes().contains(colorMode))
+         grayscale = m_printDevice.defaultColorMode() == QPrint::GrayScale;
+diff --git a/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h b/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
+index c021b0c643..8f81fe478d 100644
+--- a/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
++++ b/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
+@@ -100,6 +100,7 @@ private:
+     QStringList cupsOptions;
+     QString cupsTempFile;
+     QPrint::DuplexMode duplex;
++    bool duplexRequestedExplicitly = false;
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp b/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
+index 67e7154fa6..40876152e5 100644
+--- a/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
++++ b/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
+@@ -817,7 +817,7 @@ bool QIBaseResultPrivate::writeArray(int column, const QList<QVariant> &list)
+     ba.resize(int(bufLen));
+ 
+     if (list.size() > arraySize) {
+-        error = QLatin1String("Array size missmatch: size of %1 is %2, size of provided list is %3");
++        error = QLatin1String("Array size mismatch: size of %1 is %2, size of provided list is %3");
+         error = error.arg(QLatin1String(sqlname)).arg(arraySize).arg(list.size());
+         q->setLastError(QSqlError(error, QLatin1String(""), QSqlError::StatementError));
+         return false;
+diff --git a/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp b/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
+index 7ca055eea2..6bc9d46755 100644
+--- a/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
++++ b/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
+@@ -223,7 +223,7 @@ public:
+     struct QMyField
+     {
+         char *outField = nullptr;
+-        MYSQL_FIELD *myField = nullptr;
++        const MYSQL_FIELD *myField = nullptr;
+         QMetaType::Type type = QMetaType::UnknownType;
+         my_bool nullIndicator = false;
+         ulong bufLength = 0ul;
+@@ -361,7 +361,7 @@ static bool qIsInteger(int t)
+ void QMYSQLResultPrivate::bindBlobs()
+ {
+     int i;
+-    MYSQL_FIELD *fieldInfo;
++    const MYSQL_FIELD *fieldInfo;
+     MYSQL_BIND *bind;
+ 
+     for(i = 0; i < fields.count(); ++i) {
+@@ -379,7 +379,6 @@ void QMYSQLResultPrivate::bindBlobs()
+ bool QMYSQLResultPrivate::bindInValues()
+ {
+     MYSQL_BIND *bind;
+-    char *field;
+     int i = 0;
+ 
+     if (!meta)
+@@ -392,35 +391,34 @@ bool QMYSQLResultPrivate::bindInValues()
+     inBinds = new MYSQL_BIND[fields.size()];
+     memset(inBinds, 0, fields.size() * sizeof(MYSQL_BIND));
+ 
+-    MYSQL_FIELD *fieldInfo;
++    const MYSQL_FIELD *fieldInfo;
+ 
+     while((fieldInfo = mysql_fetch_field(meta))) {
++        bind = &inBinds[i];
++
+         QMyField &f = fields[i];
+         f.myField = fieldInfo;
+-
++        bind->buffer_length = f.bufLength = fieldInfo->length + 1;
++        bind->buffer_type = fieldInfo->type;
+         f.type = qDecodeMYSQLType(fieldInfo->type, fieldInfo->flags);
+         if (qIsBlob(fieldInfo->type)) {
+             // the size of a blob-field is available as soon as we call
+             // mysql_stmt_store_result()
+             // after mysql_stmt_exec() in QMYSQLResult::exec()
+-            fieldInfo->length = 0;
++            bind->buffer_length = f.bufLength = 0;
+             hasBlobs = true;
+         } else if (qIsInteger(f.type)) {
+-            fieldInfo->length = 8;
++            bind->buffer_length = f.bufLength = 8;
+         } else {
+-            fieldInfo->type = MYSQL_TYPE_STRING;
++            bind->buffer_type = MYSQL_TYPE_STRING;
+         }
+-        bind = &inBinds[i];
+-        field = new char[fieldInfo->length + 1];
+-        memset(field, 0, fieldInfo->length + 1);
+ 
+-        bind->buffer_type = fieldInfo->type;
+-        bind->buffer = field;
+-        bind->buffer_length = f.bufLength = fieldInfo->length + 1;
+         bind->is_null = &f.nullIndicator;
+         bind->length = &f.bufLength;
+         bind->is_unsigned = fieldInfo->flags & UNSIGNED_FLAG ? 1 : 0;
+-        f.outField=field;
++
++        char *field = new char[bind->buffer_length + 1]{};
++        bind->buffer = f.outField = field;
+ 
+         ++i;
+     }
+@@ -1369,20 +1367,20 @@ bool QMYSQLDriver::open(const QString& db,
+     }
+ 
+ #if MYSQL_VERSION_ID >= 50007
+-    if (mysql_get_client_version() >= 50503 && mysql_get_server_version(d->mysql) >= 50503) {
+-        // force the communication to be utf8mb4 (only utf8mb4 supports 4-byte characters)
+-        mysql_set_character_set(d->mysql, "utf8mb4");
++    // force the communication to be utf8mb4 (only utf8mb4 supports 4-byte characters)
++    if (mysql_set_character_set(d->mysql, "utf8mb4")) {
++        // this failed, try forcing it to utf (BMP only)
++        if (mysql_set_character_set(d->mysql, "utf8"))
++            qWarning() << "MySQL: Unable to set the client character set to utf8.";
+ #if QT_CONFIG(textcodec)
+-        d->tc = QTextCodec::codecForName("UTF-8");
++        else
++            d->tc = codec(d->mysql);
+ #endif
+-    } else
+-    {
+-        // force the communication to be utf8
+-        mysql_set_character_set(d->mysql, "utf8");
++    }
+ #if QT_CONFIG(textcodec)
+-        d->tc = codec(d->mysql);
++    else
++        d->tc = QTextCodec::codecForName("UTF-8");
+ #endif
+-    }
+ #endif  // MYSQL_VERSION_ID >= 50007
+ 
+     d->preparedQuerysEnabled = checkPreparedQueries(d->mysql);
+diff --git a/qtbase/src/printsupport/dialogs/images/print-24.png b/qtbase/src/printsupport/dialogs/images/printer-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/print-24.png
+rename to src/printsupport/dialogs/images/printer-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/print-32.png b/qtbase/src/printsupport/dialogs/images/printer-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/print-32.png
+rename to src/printsupport/dialogs/images/printer-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-sided-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-facing-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-sided-24.png
+rename to src/printsupport/dialogs/images/view-pages-facing-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-sided-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-facing-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-sided-32.png
+rename to src/printsupport/dialogs/images/view-pages-facing-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-multi-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-overview-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-multi-24.png
+rename to src/printsupport/dialogs/images/view-pages-overview-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-multi-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-overview-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-multi-32.png
+rename to src/printsupport/dialogs/images/view-pages-overview-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-one-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-single-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-one-24.png
+rename to src/printsupport/dialogs/images/view-pages-single-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-one-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-single-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-one-32.png
+rename to src/printsupport/dialogs/images/view-pages-single-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-page-24.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-page-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-page-24.png
+rename to src/printsupport/dialogs/images/zoom-fit-page-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-page-32.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-page-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-page-32.png
+rename to src/printsupport/dialogs/images/zoom-fit-page-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-width-24.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-width-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-width-24.png
+rename to src/printsupport/dialogs/images/zoom-fit-width-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-width-32.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-width-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-width-32.png
+rename to src/printsupport/dialogs/images/zoom-fit-width-32.png
+diff --git a/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp b/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
+index 78e5b8d1ef..2a28516719 100644
+--- a/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
++++ b/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
+@@ -532,6 +532,7 @@ void QPageSetupWidget::updateWidget()
+ void QPageSetupWidget::setupPrinter() const
+ {
+     m_printer->setPageLayout(m_pageLayout);
++    m_printer->setPageOrientation(m_pageLayout.orientation());
+ #if QT_CONFIG(cups)
+     QCUPSSupport::PagesPerSheet pagesPerSheet = qvariant_cast<QCUPSSupport::PagesPerSheet>(m_ui.pagesPerSheetCombo->currentData()
+ );
+diff --git a/qtbase/src/printsupport/dialogs/qprintdialog.qrc b/qtbase/src/printsupport/dialogs/qprintdialog.qrc
+index 5a579baa55..10b8e1d341 100644
+--- a/qtbase/src/printsupport/dialogs/qprintdialog.qrc
++++ b/qtbase/src/printsupport/dialogs/qprintdialog.qrc
+@@ -1,9 +1,9 @@
+ <!DOCTYPE RCC><RCC version="1.0">
+ <qresource prefix="/qt-project.org/dialogs/qprintpreviewdialog">
+-<file>images/fit-page-24.png</file>
+-<file>images/fit-page-32.png</file>
+-<file>images/fit-width-24.png</file>
+-<file>images/fit-width-32.png</file>
++<file>images/zoom-fit-page-24.png</file>
++<file>images/zoom-fit-page-32.png</file>
++<file>images/zoom-fit-width-24.png</file>
++<file>images/zoom-fit-width-32.png</file>
+ <file>images/go-first-24.png</file>
+ <file>images/go-first-32.png</file>
+ <file>images/go-last-24.png</file>
+@@ -18,14 +18,14 @@
+ <file>images/layout-portrait-32.png</file>
+ <file>images/page-setup-24.png</file>
+ <file>images/page-setup-32.png</file>
+-<file>images/print-24.png</file>
+-<file>images/print-32.png</file>
+-<file>images/view-page-multi-24.png</file>
+-<file>images/view-page-multi-32.png</file>
+-<file>images/view-page-one-24.png</file>
+-<file>images/view-page-one-32.png</file>
+-<file>images/view-page-sided-24.png</file>
+-<file>images/view-page-sided-32.png</file>
++<file>images/printer-24.png</file>
++<file>images/printer-32.png</file>
++<file>images/view-pages-overview-24.png</file>
++<file>images/view-pages-overview-32.png</file>
++<file>images/view-pages-single-24.png</file>
++<file>images/view-pages-single-32.png</file>
++<file>images/view-pages-facing-24.png</file>
++<file>images/view-pages-facing-32.png</file>
+ <file>images/zoom-in-24.png</file>
+ <file>images/zoom-in-32.png</file>
+ <file>images/zoom-out-24.png</file>
+diff --git a/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp b/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
+index c5b845f4ec..5a5ba1d0a8 100644
+--- a/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
++++ b/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
+@@ -702,13 +702,14 @@ void QPrintDialogPrivate::selectPrinter(const QPrinter::OutputFormat outputForma
+         else
+             options.grayscale->setChecked(true);
+ 
+-        // keep duplex value explicitly set by user, if any, and selected printer supports it;
+-        // use device default otherwise
++        // duplex priorities to be as follows:
++        // 1) a user-selected duplex value in the dialog has highest prority
++        // 2) duplex value set in the QPrinter
+         QPrint::DuplexMode duplex;
+         if (explicitDuplexMode != QPrint::DuplexAuto && supportedDuplexMode.contains(explicitDuplexMode))
+             duplex = explicitDuplexMode;
+         else
+-            duplex = top->d->m_currentPrintDevice.defaultDuplexMode();
++            duplex = static_cast<QPrint::DuplexMode>(p->duplex());
+         switch (duplex) {
+         case QPrint::DuplexNone:
+             options.noDuplex->setChecked(true); break;
+@@ -1242,10 +1243,10 @@ void QUnixPrintWidgetPrivate::_q_printerChanged(int index)
+             QString filename = widget.filename->text();
+             widget.filename->setText(filename);
+             widget.lOutput->setEnabled(true);
+-            if (optionsPane)
+-                optionsPane->selectPrinter(QPrinter::PdfFormat);
+             printer->setOutputFormat(QPrinter::PdfFormat);
+             m_currentPrintDevice = QPrintDevice();
++            if (optionsPane)
++                optionsPane->selectPrinter(QPrinter::PdfFormat);
+             return;
+         }
+     }
+diff --git a/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp b/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
+index 39575d5f57..23b7e89538 100644
+--- a/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
++++ b/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
+@@ -352,7 +352,7 @@ void QPrintPreviewDialogPrivate::init(QPrinter *_printer)
+ static inline void qt_setupActionIcon(QAction *action, QLatin1String name)
+ {
+     QLatin1String imagePrefix(":/qt-project.org/dialogs/qprintpreviewdialog/images/");
+-    QIcon icon;
++    QIcon icon = QIcon::fromTheme(name);
+     icon.addFile(imagePrefix + name + QLatin1String("-24.png"), QSize(24, 24));
+     icon.addFile(imagePrefix + name + QLatin1String("-32.png"), QSize(32, 32));
+     action->setIcon(icon);
+@@ -383,8 +383,8 @@ void QPrintPreviewDialogPrivate::setupActions()
+     fitPageAction->setObjectName(QLatin1String("fitPageAction"));
+     fitWidthAction->setCheckable(true);
+     fitPageAction->setCheckable(true);
+-    qt_setupActionIcon(fitWidthAction, QLatin1String("fit-width"));
+-    qt_setupActionIcon(fitPageAction, QLatin1String("fit-page"));
++    qt_setupActionIcon(fitWidthAction, QLatin1String("zoom-fit-width"));
++    qt_setupActionIcon(fitPageAction, QLatin1String("zoom-fit-page"));
+     QObject::connect(fitGroup, SIGNAL(triggered(QAction*)), q, SLOT(_q_fit(QAction*)));
+ 
+     // Zoom
+@@ -410,9 +410,9 @@ void QPrintPreviewDialogPrivate::setupActions()
+     singleModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show single page"));
+     facingModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show facing pages"));
+     overviewModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show overview of all pages"));
+-    qt_setupActionIcon(singleModeAction, QLatin1String("view-page-one"));
+-    qt_setupActionIcon(facingModeAction, QLatin1String("view-page-sided"));
+-    qt_setupActionIcon(overviewModeAction, QLatin1String("view-page-multi"));
++    qt_setupActionIcon(singleModeAction, QLatin1String("view-pages-single"));
++    qt_setupActionIcon(facingModeAction, QLatin1String("view-pages-facing"));
++    qt_setupActionIcon(overviewModeAction, QLatin1String("view-pages-overview"));
+     singleModeAction->setObjectName(QLatin1String("singleModeAction"));
+     facingModeAction->setObjectName(QLatin1String("facingModeAction"));
+     overviewModeAction->setObjectName(QLatin1String("overviewModeAction"));
+@@ -426,7 +426,7 @@ void QPrintPreviewDialogPrivate::setupActions()
+     printerGroup = new QActionGroup(q);
+     printAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Print"));
+     pageSetupAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Page setup"));
+-    qt_setupActionIcon(printAction, QLatin1String("print"));
++    qt_setupActionIcon(printAction, QLatin1String("printer"));
+     qt_setupActionIcon(pageSetupAction, QLatin1String("page-setup"));
+     QObject::connect(printAction, SIGNAL(triggered(bool)), q, SLOT(_q_print()));
+     QObject::connect(pageSetupAction, SIGNAL(triggered(bool)), q, SLOT(_q_pageSetup()));
+diff --git a/qtbase/src/sql/kernel/qsqlquery.cpp b/qtbase/src/sql/kernel/qsqlquery.cpp
+index 32c6166c79..60afef10c3 100644
+--- a/qtbase/src/sql/kernel/qsqlquery.cpp
++++ b/qtbase/src/sql/kernel/qsqlquery.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2022 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtSql module of the Qt Toolkit.
+@@ -377,6 +377,10 @@ bool QSqlQuery::exec(const QString& query)
+     QElapsedTimer t;
+     t.start();
+ #endif
++    if (!driver()) {
++        qWarning("QSqlQuery::exec: called before driver has been set up");
++        return false;
++    }
+     if (d->ref.loadRelaxed() != 1) {
+         bool fo = isForwardOnly();
+         *this = QSqlQuery(driver()->createResult());
+diff --git a/qtbase/src/testlib/qabstractitemmodeltester.cpp b/qtbase/src/testlib/qabstractitemmodeltester.cpp
+index 8efb9c53d4..ce062f66d7 100644
+--- a/qtbase/src/testlib/qabstractitemmodeltester.cpp
++++ b/qtbase/src/testlib/qabstractitemmodeltester.cpp
+@@ -454,7 +454,7 @@ void QAbstractItemModelTesterPrivate::parent()
+ 
+     // Common error test #2, make sure that a second level index has a parent
+     // that is the first level index.
+-    if (model->rowCount(topIndex) > 0) {
++    if (model->rowCount(topIndex) > 0 && model->columnCount(topIndex) > 0) {
+         QModelIndex childIndex = model->index(0, 0, topIndex);
+         MODELTESTER_VERIFY(childIndex.isValid());
+         MODELTESTER_COMPARE(model->parent(childIndex), topIndex);
+diff --git a/qtbase/src/testlib/qasciikey.cpp b/qtbase/src/testlib/qasciikey.cpp
+index 9a308da2bc..93498b256f 100644
+--- a/qtbase/src/testlib/qasciikey.cpp
++++ b/qtbase/src/testlib/qasciikey.cpp
+@@ -498,6 +498,11 @@ char QTest::keyToAscii(Qt::Key key)
+     case Qt::Key_LaunchE : return 0; // = 0x10b0,
+     case Qt::Key_LaunchF : return 0; // = 0x10b1,
+ 
++    // Keypad navigation keys
++    case Qt::Key_Select : return 0; // = 0x01010000
++    case Qt::Key_Yes : return 0; // = 0x01010001
++    case Qt::Key_No : return 0; // = 0x01010002
++
+     default: QTEST_ASSERT(false); return 0;
+     }
+ }
+diff --git a/qtbase/src/testlib/qtestresult.cpp b/qtbase/src/testlib/qtestresult.cpp
+index 88028aac6e..2e89930776 100644
+--- a/qtbase/src/testlib/qtestresult.cpp
++++ b/qtbase/src/testlib/qtestresult.cpp
+@@ -251,7 +251,8 @@ bool QTestResult::verify(bool statement, const char *statementStr,
+ {
+     QTEST_ASSERT(statementStr);
+ 
+-    char msg[1024] = {'\0'};
++    char msg[1024];
++    msg[0] = '\0';
+ 
+     if (QTestLog::verboseLevel() >= 2) {
+         qsnprintf(msg, 1024, "QVERIFY(%s)", statementStr);
+@@ -309,7 +310,8 @@ static bool compareHelper(bool success, const char *failureMsg,
+                           bool hasValues = true)
+ {
+     const size_t maxMsgLen = 1024;
+-    char msg[maxMsgLen] = {'\0'};
++    char msg[maxMsgLen];
++    msg[0] = '\0';
+ 
+     QTEST_ASSERT(expected);
+     QTEST_ASSERT(actual);
+diff --git a/qtbase/src/widgets/dialogs/qcolordialog.cpp b/qtbase/src/widgets/dialogs/qcolordialog.cpp
+index 4247731275..cb325be85c 100644
+--- a/qtbase/src/widgets/dialogs/qcolordialog.cpp
++++ b/qtbase/src/widgets/dialogs/qcolordialog.cpp
+@@ -78,7 +78,10 @@
+ #include "qwindow.h"
+ 
+ #include "private/qdialog_p.h"
++#include "private/qguiapplication_p.h"
+ 
++#include <qpa/qplatformservices.h>
++#include <qpa/qplatformintegration.h>
+ #include <algorithm>
+ 
+ QT_BEGIN_NAMESPACE
+@@ -1611,6 +1614,20 @@ void QColorDialogPrivate::_q_newStandard(int r, int c)
+ void QColorDialogPrivate::_q_pickScreenColor()
+ {
+     Q_Q(QColorDialog);
++
++    auto *platformServices = QGuiApplicationPrivate::platformIntegration()->services();
++    if (platformServices->hasCapability(QPlatformServices::Capability::ColorPicking)) {
++        if (auto *colorPicker = platformServices->colorPicker(q->windowHandle())) {
++            q->connect(colorPicker, &QPlatformServiceColorPicker::colorPicked, q,
++                       [q, colorPicker](const QColor &color) {
++                           colorPicker->deleteLater();
++                           q->setCurrentColor(color);
++                       });
++            colorPicker->pickColor();
++            return;
++        }
++    }
++
+     if (!colorPickingEventFilter)
+         colorPickingEventFilter = new QColorPickingEventFilter(this, q);
+     q->installEventFilter(colorPickingEventFilter);
+diff --git a/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp b/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
+index e120817edc..8ea36b5427 100644
+--- a/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
++++ b/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
+@@ -400,12 +400,7 @@ bool QAbstractItemDelegate::helpEvent(QHelpEvent *event,
+         const QString tooltip = index.isValid() ?
+               d->textForRole(Qt::ToolTipRole, index.data(Qt::ToolTipRole), option.locale, precision) :
+               QString();
+-        QRect rect;
+-        if (index.isValid()) {
+-            const QRect r = view->visualRect(index);
+-            rect = QRect(view->mapToGlobal(r.topLeft()), r.size());
+-        }
+-        QToolTip::showText(he->globalPos(), tooltip, view, rect);
++        QToolTip::showText(he->globalPos(), tooltip, view->viewport(), option.rect);
+         event->setAccepted(!tooltip.isEmpty());
+         break;
+         }
+diff --git a/qtbase/src/widgets/itemviews/qlistview.cpp b/qtbase/src/widgets/itemviews/qlistview.cpp
+index 2b34476642..eebfaa030e 100644
+--- a/qtbase/src/widgets/itemviews/qlistview.cpp
++++ b/qtbase/src/widgets/itemviews/qlistview.cpp
+@@ -3386,6 +3386,7 @@ void QIconModeViewBase::updateContentsSize()
+ */
+ void QListView::currentChanged(const QModelIndex &current, const QModelIndex &previous)
+ {
++    QAbstractItemView::currentChanged(current, previous);
+ #ifndef QT_NO_ACCESSIBILITY
+     if (QAccessible::isActive()) {
+         if (current.isValid()) {
+@@ -3396,7 +3397,6 @@ void QListView::currentChanged(const QModelIndex &current, const QModelIndex &pr
+         }
+     }
+ #endif
+-    QAbstractItemView::currentChanged(current, previous);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/widgets/itemviews/qtableview.cpp b/qtbase/src/widgets/itemviews/qtableview.cpp
+index 934ac581b2..f79bb24249 100644
+--- a/qtbase/src/widgets/itemviews/qtableview.cpp
++++ b/qtbase/src/widgets/itemviews/qtableview.cpp
+@@ -1013,6 +1013,7 @@ void QTableViewPrivate::drawCell(QPainter *painter, const QStyleOptionViewItem &
+ int QTableViewPrivate::widthHintForIndex(const QModelIndex &index, int hint, const QStyleOptionViewItem &option) const
+ {
+     Q_Q(const QTableView);
++    const int oldHint = hint;
+     QWidget *editor = editorForIndex(index).widget.data();
+     if (editor && persistent.contains(editor)) {
+         hint = qMax(hint, editor->sizeHint().width());
+@@ -1021,6 +1022,17 @@ int QTableViewPrivate::widthHintForIndex(const QModelIndex &index, int hint, con
+         hint = qBound(min, hint, max);
+     }
+     hint = qMax(hint, q->itemDelegate(index)->sizeHint(option, index).width());
++
++    if (hasSpans()) {
++        auto span = spans.spanAt(index.column(), index.row());
++        if (span && span->m_left == index.column() && span->m_top == index.row()) {
++            // spans are screwed up when sections are moved
++            const auto left = logicalColumn(span->m_left);
++            for (int i = 1; i <= span->width(); ++i)
++               hint -= q->columnWidth(visualColumn(left + i));
++        }
++        hint = std::max(hint, oldHint);
++    }
+     return hint;
+ }
+ 
+@@ -1053,6 +1065,11 @@ int QTableViewPrivate::heightHintForIndex(const QModelIndex &index, int hint, QS
+         option.rect.setHeight(height);
+         option.rect.setX(q->columnViewportPosition(index.column()));
+         option.rect.setWidth(q->columnWidth(index.column()));
++        if (hasSpans()) {
++            auto span = spans.spanAt(index.column(), index.row());
++            if (span && span->m_left == index.column() && span->m_top == index.row())
++                option.rect.setWidth(std::max(option.rect.width(), visualSpanRect(*span).width()));
++        }
+         // 1px less space when grid is shown (see drawCell)
+         if (showGrid)
+             option.rect.setWidth(option.rect.width() - 1);
+diff --git a/qtbase/src/widgets/kernel/qaction.h b/qtbase/src/widgets/kernel/qaction.h
+index 258a1ea0a0..737c1e8285 100644
+--- a/qtbase/src/widgets/kernel/qaction.h
++++ b/qtbase/src/widgets/kernel/qaction.h
+@@ -81,7 +81,7 @@ class Q_WIDGETS_EXPORT QAction : public QObject
+     Q_PROPERTY(MenuRole menuRole READ menuRole WRITE setMenuRole NOTIFY changed)
+     Q_PROPERTY(bool iconVisibleInMenu READ isIconVisibleInMenu WRITE setIconVisibleInMenu NOTIFY changed)
+     Q_PROPERTY(bool shortcutVisibleInContextMenu READ isShortcutVisibleInContextMenu WRITE setShortcutVisibleInContextMenu NOTIFY changed)
+-    Q_PROPERTY(Priority priority READ priority WRITE setPriority)
++    Q_PROPERTY(Priority priority READ priority WRITE setPriority NOTIFY changed)
+ 
+ public:
+     // note this is copied into qplatformmenu.h, which must stay in sync
+diff --git a/qtbase/src/widgets/kernel/qwidget.cpp b/qtbase/src/widgets/kernel/qwidget.cpp
+index 9eba1e001e..26f6d27e18 100644
+--- a/qtbase/src/widgets/kernel/qwidget.cpp
++++ b/qtbase/src/widgets/kernel/qwidget.cpp
+@@ -5296,7 +5296,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
+         QWidgetEffectSourcePrivate *sourced = static_cast<QWidgetEffectSourcePrivate *>
+                                                          (source->d_func());
+         if (!sourced->context) {
+-            const QRegion effectRgn(rgn.boundingRect());
++            const QRegion effectRgn((flags & UseEffectRegionBounds) ? rgn.boundingRect() : rgn);
+             QWidgetPaintContext context(pdev, effectRgn, offset, flags, sharedPainter, repaintManager);
+             sourced->context = &context;
+             if (!sharedPainter) {
+@@ -5328,6 +5328,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
+         }
+     }
+ #endif // QT_CONFIG(graphicseffect)
++    flags = flags & ~UseEffectRegionBounds;
+ 
+     const bool alsoOnScreen = flags & DrawPaintOnScreen;
+     const bool recursive = flags & DrawRecursive;
+diff --git a/qtbase/src/widgets/kernel/qwidget_p.h b/qtbase/src/widgets/kernel/qwidget_p.h
+index eef6b8fa2c..c432f4b5d5 100644
+--- a/qtbase/src/widgets/kernel/qwidget_p.h
++++ b/qtbase/src/widgets/kernel/qwidget_p.h
+@@ -229,7 +229,8 @@ public:
+         DontSubtractOpaqueChildren = 0x10,
+         DontDrawOpaqueChildren = 0x20,
+         DontDrawNativeChildren = 0x40,
+-        DontSetCompositionMode = 0x80
++        DontSetCompositionMode = 0x80,
++        UseEffectRegionBounds = 0x100
+     };
+     Q_DECLARE_FLAGS(DrawWidgetFlags, DrawWidgetFlag)
+     Q_FLAG(DrawWidgetFlags)
+diff --git a/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp b/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
+index 02880b34da..0d44e1326d 100644
+--- a/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
++++ b/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
+@@ -1018,7 +1018,8 @@ void QWidgetRepaintManager::paintAndFlush()
+ 
+     // Paint the rest with composition.
+     if (repaintAllWidgets || !dirtyCopy.isEmpty()) {
+-        QWidgetPrivate::DrawWidgetFlags flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive;
++        QWidgetPrivate::DrawWidgetFlags flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive
++                | QWidgetPrivate::UseEffectRegionBounds;
+         tlw->d_func()->drawWidget(store->paintDevice(), dirtyCopy, QPoint(), flags, nullptr, this);
+     }
+ 
+diff --git a/qtbase/src/widgets/styles/qfusionstyle.cpp b/qtbase/src/widgets/styles/qfusionstyle.cpp
+index f4345d97c4..962912c838 100644
+--- a/qtbase/src/widgets/styles/qfusionstyle.cpp
++++ b/qtbase/src/widgets/styles/qfusionstyle.cpp
+@@ -1772,14 +1772,6 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio
+             proxy()->drawControl(CE_PushButtonLabel, &subopt, painter, widget);
+         }
+         break;
+-    case CE_PushButtonLabel:
+-        if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
+-            QStyleOptionButton b(*button);
+-            // no PM_ButtonShiftHorizontal and PM_ButtonShiftVertical for fusion style
+-            b.state &= ~(State_On | State_Sunken);
+-            QCommonStyle::drawControl(element, &b, painter, widget);
+-        }
+-        break;
+     case CE_MenuBarEmptyArea:
+         painter->save();
+     {
+diff --git a/qtbase/src/widgets/util/qcompleter.cpp b/qtbase/src/widgets/util/qcompleter.cpp
+index 18b24063d8..ef7207a8a3 100644
+--- a/qtbase/src/widgets/util/qcompleter.cpp
++++ b/qtbase/src/widgets/util/qcompleter.cpp
+@@ -1120,6 +1120,8 @@ void QCompleter::setModel(QAbstractItemModel *model)
+ {
+     Q_D(QCompleter);
+     QAbstractItemModel *oldModel = d->proxy->sourceModel();
++    if (oldModel == model)
++        return;
+ #if QT_CONFIG(filesystemmodel)
+     if (qobject_cast<const QFileSystemModel *>(oldModel))
+         setCompletionRole(Qt::EditRole); // QTBUG-54642, clear FileNameRole set by QFileSystemModel
+diff --git a/qtbase/src/widgets/widgets/qabstractbutton.cpp b/qtbase/src/widgets/widgets/qabstractbutton.cpp
+index a128b23950..dc40bf62fb 100644
+--- a/qtbase/src/widgets/widgets/qabstractbutton.cpp
++++ b/qtbase/src/widgets/widgets/qabstractbutton.cpp
+@@ -56,6 +56,7 @@
+ #ifndef QT_NO_ACCESSIBILITY
+ #include "qaccessible.h"
+ #endif
++#include <qpa/qplatformtheme.h>
+ 
+ #include <algorithm>
+ 
+@@ -1076,19 +1077,19 @@ void QAbstractButton::keyPressEvent(QKeyEvent *e)
+ {
+     Q_D(QAbstractButton);
+     bool next = true;
+-    switch (e->key()) {
+-    case Qt::Key_Enter:
+-    case Qt::Key_Return:
+-        e->ignore();
+-        break;
+-    case Qt::Key_Select:
+-    case Qt::Key_Space:
+-        if (!e->isAutoRepeat()) {
+-            setDown(true);
+-            repaint();
+-            d->emitPressed();
+-        }
+-        break;
++
++    const auto key = static_cast<Qt::Key>(e->key());
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(key) && !e->isAutoRepeat()) {
++        setDown(true);
++        repaint();
++        d->emitPressed();
++        return;
++    }
++
++    switch (key) {
+     case Qt::Key_Up:
+         next = false;
+         Q_FALLTHROUGH();
+@@ -1153,15 +1154,15 @@ void QAbstractButton::keyReleaseEvent(QKeyEvent *e)
+     if (!e->isAutoRepeat())
+         d->repeatTimer.stop();
+ 
+-    switch (e->key()) {
+-    case Qt::Key_Select:
+-    case Qt::Key_Space:
+-        if (!e->isAutoRepeat() && d->down)
+-            d->click();
+-        break;
+-    default:
+-        e->ignore();
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(static_cast<Qt::Key>(e->key())) && !e->isAutoRepeat() && d->down) {
++        d->click();
++        return;
+     }
++
++    e->ignore();
+ }
+ 
+ /*!\reimp
+diff --git a/qtbase/src/widgets/widgets/qcombobox.cpp b/qtbase/src/widgets/widgets/qcombobox.cpp
+index 7a496c27e0..0a3d96647b 100644
+--- a/qtbase/src/widgets/widgets/qcombobox.cpp
++++ b/qtbase/src/widgets/widgets/qcombobox.cpp
+@@ -3352,7 +3352,23 @@ void QComboBox::keyPressEvent(QKeyEvent *e)
+ 
+     Move move = NoMove;
+     int newIndex = currentIndex();
+-    switch (e->key()) {
++
++    bool pressLikeButton = !d->lineEdit;
++#ifdef QT_KEYPAD_NAVIGATION
++    pressLikeButton |= QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus();
++#endif
++    auto key = static_cast<Qt::Key>(e->key());
++    if (pressLikeButton) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(key)) {
++            showPopup();
++            return;
++        }
++    }
++
++    switch (key) {
+     case Qt::Key_Up:
+         if (e->modifiers() & Qt::ControlModifier)
+             break; // pass to line edit for auto completion
+@@ -3394,26 +3410,11 @@ void QComboBox::keyPressEvent(QKeyEvent *e)
+             return;
+         }
+         break;
+-    case Qt::Key_Space:
+-        if (!d->lineEdit) {
+-            showPopup();
+-            return;
+-        }
+-        break;
+-    case Qt::Key_Enter:
+-    case Qt::Key_Return:
+     case Qt::Key_Escape:
+         if (!d->lineEdit)
+             e->ignore();
+         break;
+ #ifdef QT_KEYPAD_NAVIGATION
+-    case Qt::Key_Select:
+-        if (QApplicationPrivate::keypadNavigationEnabled()
+-                && (!hasEditFocus() || !d->lineEdit)) {
+-            showPopup();
+-            return;
+-        }
+-        break;
+     case Qt::Key_Left:
+     case Qt::Key_Right:
+         if (QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus())
+diff --git a/qtbase/src/widgets/widgets/qdatetimeedit_p.h b/qtbase/src/widgets/widgets/qdatetimeedit_p.h
+index d36b6f8f9a..e0df5b5158 100644
+--- a/qtbase/src/widgets/widgets/qdatetimeedit_p.h
++++ b/qtbase/src/widgets/widgets/qdatetimeedit_p.h
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2018 The Qt Company Ltd.
++** Copyright (C) 2021 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtWidgets module of the Qt Toolkit.
+diff --git a/qtbase/src/widgets/widgets/qgroupbox.cpp b/qtbase/src/widgets/widgets/qgroupbox.cpp
+index 02a0bed325..3f3eccc370 100644
+--- a/qtbase/src/widgets/widgets/qgroupbox.cpp
++++ b/qtbase/src/widgets/widgets/qgroupbox.cpp
+@@ -54,6 +54,8 @@
+ #include "qaccessible.h"
+ #endif
+ #include <private/qwidget_p.h>
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
+ 
+ #include "qdebug.h"
+ 
+@@ -360,7 +362,10 @@ bool QGroupBox::event(QEvent *e)
+         return true;
+     case QEvent::KeyPress: {
+         QKeyEvent *k = static_cast<QKeyEvent*>(e);
+-        if (!k->isAutoRepeat() && (k->key() == Qt::Key_Select || k->key() == Qt::Key_Space)) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (!k->isAutoRepeat() && buttonPressKeys.contains(static_cast<Qt::Key>(k->key()))) {
+             d->pressedControl = QStyle::SC_GroupBoxCheckBox;
+             update(style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxCheckBox, this));
+             return true;
+@@ -369,7 +374,10 @@ bool QGroupBox::event(QEvent *e)
+     }
+     case QEvent::KeyRelease: {
+         QKeyEvent *k = static_cast<QKeyEvent*>(e);
+-        if (!k->isAutoRepeat() && (k->key() == Qt::Key_Select || k->key() == Qt::Key_Space)) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (!k->isAutoRepeat() && buttonPressKeys.contains(static_cast<Qt::Key>(k->key()))) {
+             bool toggle = (d->pressedControl == QStyle::SC_GroupBoxLabel
+                            || d->pressedControl == QStyle::SC_GroupBoxCheckBox);
+             d->pressedControl = QStyle::SC_None;
+diff --git a/qtbase/src/widgets/widgets/qlabel.cpp b/qtbase/src/widgets/widgets/qlabel.cpp
+index 30ff80cbb0..cf2605c17c 100644
+--- a/qtbase/src/widgets/widgets/qlabel.cpp
++++ b/qtbase/src/widgets/widgets/qlabel.cpp
+@@ -421,9 +421,6 @@ void QLabel::setPixmap(const QPixmap &pixmap)
+         d->pixmap = new QPixmap(pixmap);
+     }
+ 
+-    if (d->pixmap->depth() == 1 && !d->pixmap->mask())
+-        d->pixmap->setMask(*((QBitmap *)d->pixmap));
+-
+     d->updateLabel();
+ }
+ 
+diff --git a/qtbase/src/widgets/widgets/qtoolbararealayout.cpp b/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
+index 493c094cc1..d5f4b59017 100644
+--- a/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
++++ b/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
+@@ -1367,7 +1367,7 @@ bool QToolBarAreaLayout::restoreState(QDataStream &stream, const QList<QToolBar*
+                 item.widgetItem = new QWidgetItemV2(toolBar);
+                 toolBar->setOrientation(floating ? ((shown & 2) ? Qt::Vertical : Qt::Horizontal) : dock.o);
+                 toolBar->setVisible(shown & 1);
+-                toolBar->d_func()->setWindowState(floating, true, rect);
++                toolBar->d_func()->setWindowState(floating, false, rect);
+ 
+                 item.preferredSize = item.size;
+                 line.toolBarItems.append(item);
+diff --git a/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp b/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
+index 212c0a2e13..3c77b1ba0b 100644
+--- a/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
++++ b/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
+@@ -126,8 +126,7 @@ public:
+ 
+ void tst_QtConcurrentIterateKernel::instantiate()
+ {
+-    auto future = startThreadEngine(new PrintFor(0, 40)).startAsynchronously();
+-    future.waitForFinished();
++    startThreadEngine(new PrintFor(0, 40)).startBlocking();
+     QCOMPARE(iterations.loadRelaxed(), 40);
+ }
+ 
+@@ -166,10 +165,8 @@ void tst_QtConcurrentIterateKernel::stresstest()
+     const int times = 50;
+     for (int i = 0; i < times; ++i) {
+         counter.storeRelaxed(0);
+-        // ThreadEngine will delete f when it finishes
+-        auto f = new CountFor(0, iterations);
+-        auto future = f->startAsynchronously();
+-        future.waitForFinished();
++        CountFor f(0, iterations);
++        f.startBlocking();
+         QCOMPARE(counter.loadRelaxed(), iterations);
+     }
+ }
+@@ -177,11 +174,8 @@ void tst_QtConcurrentIterateKernel::stresstest()
+ void tst_QtConcurrentIterateKernel::noIterations()
+ {
+     const int times = 20000;
+-    for (int i = 0; i < times; ++i) {
+-        auto future = startThreadEngine(new IterateKernel<TestIterator, void>(0, 0))
+-                              .startAsynchronously();
+-        future.waitForFinished();
+-    }
++    for (int i = 0; i < times; ++i)
++        startThreadEngine(new IterateKernel<TestIterator, void>(0, 0)).startBlocking();
+ }
+ 
+ QMutex threadsMutex;
+@@ -236,10 +230,8 @@ void tst_QtConcurrentIterateKernel::throttling()
+ 
+     threads.clear();
+ 
+-    // ThreadEngine will delete f when it finishes
+-    auto f = new ThrottleFor(0, totalIterations);
+-    auto future = f->startAsynchronously();
+-    future.waitForFinished();
++    ThrottleFor f(0, totalIterations);
++    f.startBlocking();
+ 
+     QCOMPARE(iterations.loadRelaxed(), totalIterations);
+ 
+diff --git a/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp b/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
+index ac7be7acdd..81bc64c8d9 100644
+--- a/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
++++ b/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
+@@ -65,9 +65,16 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::runDirectly()
+ {
+-    PrintUser *engine = new PrintUser();
+-    QFuture<void> f = engine->startAsynchronously();
+-    f.waitForFinished();
++    {
++        PrintUser engine;
++        engine.startSingleThreaded();
++        engine.startBlocking();
++    }
++    {
++        PrintUser *engine = new PrintUser();
++        QFuture<void> f = engine->startAsynchronously();
++        f.waitForFinished();
++    }
+ }
+ 
+ class StringResultUser : public ThreadEngine<QString>
+@@ -99,10 +106,8 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::result()
+ {
+-    // ThreadEngine will delete 'engine' when it finishes
+-    auto engine = new StringResultUser();
+-    auto future = engine->startAsynchronously();
+-    QCOMPARE(future.result(), QString("Foo"));
++    StringResultUser engine;
++    QCOMPARE(*engine.startBlocking(), QString("Foo"));
+ }
+ 
+ class VoidResultUser : public ThreadEngine<void>
+@@ -128,9 +133,17 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::runThroughStarter()
+ {
+-    ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
+-    QFuture<QString> f = starter.startAsynchronously();
+-    QCOMPARE(f.result(), QString("Foo"));
++    {
++        ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
++        QFuture<QString>  f = starter.startAsynchronously();
++        QCOMPARE(f.result(), QString("Foo"));
++    }
++
++    {
++        ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
++        QString str = starter.startBlocking();
++        QCOMPARE(str, QString("Foo"));
++    }
+ }
+ 
+ class CancelUser : public ThreadEngine<void>
+@@ -213,6 +226,12 @@ void tst_QtConcurrentThreadEngine::throttle()
+         f.waitForFinished();
+         QCOMPARE(count.loadRelaxed(), 0);
+     }
++
++    for (int i = 0; i < repeats; ++i) {
++        ThrottleAlwaysUser t;
++        t.startBlocking();
++        QCOMPARE(count.loadRelaxed(), 0);
++    }
+ }
+ 
+ QSet<QThread *> threads;
+@@ -249,17 +268,35 @@ void tst_QtConcurrentThreadEngine::threadCount()
+ {
+     const int repeats = 10;
+     for (int i = 0; i < repeats; ++i) {
++        ThreadCountUser t;
++        t.startBlocking();
++        int count = threads.count();
++        int count_expected = QThreadPool::globalInstance()->maxThreadCount() + 1; // +1 for the main thread.
++        if (count != count_expected)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, count_expected);
++
+         (new ThreadCountUser())->startAsynchronously().waitForFinished();
+-        const auto count = threads.count();
+-        const auto maxThreadCount = QThreadPool::globalInstance()->maxThreadCount();
+-        QVERIFY(count <= maxThreadCount);
+-        QVERIFY(!threads.contains(QThread::currentThread()));
++        count = threads.count();
++        count_expected = QThreadPool::globalInstance()->maxThreadCount();
++        if (count != count_expected)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, count_expected);
+     }
+ 
+     // Set the finish flag immediately, this should give us one thread only.
+     for (int i = 0; i < repeats; ++i) {
++        ThreadCountUser t(true /*finishImmediately*/);
++        t.startBlocking();
++        int count = threads.count();
++        if (count != 1)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, 1);
++
+         (new ThreadCountUser(true /*finishImmediately*/))->startAsynchronously().waitForFinished();
+-        const auto count = threads.count();
++        count = threads.count();
++        if (count != 1)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
+         QCOMPARE(count, 1);
+         QVERIFY(!threads.contains(QThread::currentThread()));
+     }
+@@ -400,6 +437,7 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::exceptions()
+ {
++    // Asynchronous mode:
+     {
+         bool caught = false;
+         try  {
+@@ -412,6 +450,32 @@ void tst_QtConcurrentThreadEngine::exceptions()
+         QVERIFY2(caught, "did not get exception");
+     }
+ 
++    // Blocking mode:
++    // test throwing the exception from a worker thread.
++    {
++        bool caught = false;
++        try  {
++            QtConcurrentExceptionThrower e(QThread::currentThread());
++            e.startBlocking();
++        } catch (const QException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // test throwing the exception from the main thread (different code path)
++    {
++        bool caught = false;
++        try  {
++            QtConcurrentExceptionThrower e(0);
++            e.startBlocking();
++        } catch (const QException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // Asynchronous mode:
+     {
+         bool caught = false;
+         try  {
+@@ -423,6 +487,31 @@ void tst_QtConcurrentThreadEngine::exceptions()
+         }
+         QVERIFY2(caught, "did not get exception");
+     }
++
++    // Blocking mode:
++    // test throwing the exception from a worker thread.
++    {
++        bool caught = false;
++        try  {
++            UnrelatedExceptionThrower e(QThread::currentThread());
++            e.startBlocking();
++        } catch (const QUnhandledException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // test throwing the exception from the main thread (different code path)
++    {
++        bool caught = false;
++        try  {
++            UnrelatedExceptionThrower e(0);
++            e.startBlocking();
++        } catch (const QUnhandledException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
+ }
+ 
+ #endif
+diff --git a/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp b/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
+index 4968742110..f4c3fb711d 100644
+--- a/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
++++ b/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
+@@ -42,6 +42,7 @@ private slots:
+     void writeBlock_data();
+     void writeBlock();
+     void seek();
++    void invalidSeeks();
+     void seekTest_data();
+     void seekTest();
+     void read_rawdata();
+@@ -286,6 +287,29 @@ void tst_QBuffer::seek()
+     QCOMPARE(buffer.size(), pos);
+ }
+ 
++void tst_QBuffer::invalidSeeks()
++{
++    if constexpr (sizeof(qsizetype) == sizeof(qint64)) {
++        // sizeof(qsizetype) == sizeof(qint64), so +1 would overflow
++        QSKIP("This is a 32-bit-only test.");
++    } else {
++        QBuffer buffer;
++        buffer.open(QIODevice::WriteOnly);
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++        constexpr qint64 MaxQByteArrayCapacity = (std::numeric_limits<qsizetype>::max)();
++        // this should fail fast, not after trying to allocate nearly 2 GiB of data,
++        // potentially crashing in the process:
++        QVERIFY(!buffer.seek(2 * MaxQByteArrayCapacity - 1));
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++        // ditto:
++        QVERIFY(!buffer.seek(MaxQByteArrayCapacity + 1));
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++    }
++}
++
+ void tst_QBuffer::seekTest_data()
+ {
+     writeBlock_data();
+diff --git a/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp b/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
+index da5327594c..4a04e0f7c6 100644
+--- a/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
++++ b/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
+@@ -561,7 +561,8 @@ protected:
+     qint64 readData(char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf->size() - offset));
+-        memcpy(data, buf->constData() + offset, maxSize);
++        if (maxSize > 0)
++            memcpy(data, buf->constData() + offset, maxSize);
+         offset += maxSize;
+         return maxSize;
+     }
+@@ -604,13 +605,15 @@ protected:
+     qint64 readData(char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf.size() - pos()));
+-        memcpy(data, buf.constData() + pos(), maxSize);
++        if (maxSize > 0)
++            memcpy(data, buf.constData() + pos(), maxSize);
+         return maxSize;
+     }
+     qint64 writeData(const char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf.size() - pos()));
+-        memcpy(buf.data() + pos(), data, maxSize);
++        if (maxSize > 0)
++            memcpy(buf.data() + pos(), data, maxSize);
+         return maxSize;
+     }
+ 
+diff --git a/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+index db60bead64..f345a44414 100644
+--- a/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
++++ b/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+@@ -1,7 +1,8 @@
+ /****************************************************************************
+ **
+ ** Copyright (C) 2021 The Qt Company Ltd.
+-** Copyright (C) 2020 Intel Corporation.
++** Copyright (C) 2020 The Qt Company Ltd.
++** Copyright (C) 2022 Intel Corporation.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the test suite of the Qt Toolkit.
+@@ -150,6 +151,8 @@ private slots:
+     void startStopStartStopBuffers();
+     void processEventsInAReadyReadSlot_data();
+     void processEventsInAReadyReadSlot();
++    void startFromCurrentWorkingDir_data();
++    void startFromCurrentWorkingDir();
+ 
+     // keep these at the end, since they use lots of processes and sometimes
+     // caused obscure failures to occur in tests that followed them (esp. on the Mac)
+@@ -2731,5 +2734,94 @@ void tst_QProcess::finishProcessBeforeReadingDone_deprecated()
+ 
+ #endif
+ 
++enum class ChdirMode {
++    None = 0,
++    InParent,
++    InChild
++};
++Q_DECLARE_METATYPE(ChdirMode)
++
++void tst_QProcess::startFromCurrentWorkingDir_data()
++{
++    qRegisterMetaType<ChdirMode>();
++    QTest::addColumn<QString>("programPrefix");
++    QTest::addColumn<ChdirMode>("chdirMode");
++    QTest::addColumn<bool>("success");
++
++    constexpr bool IsWindows = true
++#ifdef Q_OS_UNIX
++            && false
++#endif
++            ;
++
++    // baseline: trying to execute the directory, this can't possibly succeed!
++    QTest::newRow("plain-same-cwd") << QString() << ChdirMode::None << false;
++
++    // cross-platform behavior: neither OS searches the setWorkingDirectory()
++    // dir without "./"
++    QTest::newRow("plain-child-chdir") << QString() << ChdirMode::InChild << false;
++
++    // cross-platform behavior: both OSes search the parent's CWD with "./"
++    QTest::newRow("prefixed-parent-chdir") << "./" << ChdirMode::InParent << true;
++
++    // opposite behaviors: Windows searches the parent's CWD and Unix searches
++    // the child's with "./"
++    QTest::newRow("prefixed-child-chdir") << "./" << ChdirMode::InChild << !IsWindows;
++
++    // Windows searches the parent's CWD without "./"
++    QTest::newRow("plain-parent-chdir") << QString() << ChdirMode::InParent << IsWindows;
++}
++
++void tst_QProcess::startFromCurrentWorkingDir()
++{
++    QFETCH(QString, programPrefix);
++    QFETCH(ChdirMode, chdirMode);
++    QFETCH(bool, success);
++
++    QProcess process;
++    qRegisterMetaType<QProcess::ProcessError>();
++    QSignalSpy errorSpy(&process, &QProcess::errorOccurred);
++    QVERIFY(errorSpy.isValid());
++
++    // both the dir name and the executable name
++    const QString target = QStringLiteral("testProcessNormal");
++    process.setProgram(programPrefix + target);
++
++#ifdef Q_OS_UNIX
++    // Reset PATH, to be sure it doesn't contain . or the empty path.
++    // We can't do this on Windows because DLLs are searched in PATH
++    // and Windows always searches "." anyway.
++    auto restoreEnv = qScopeGuard([old = qgetenv("PATH")] {
++        qputenv("PATH", old);
++    });
++    qputenv("PATH", "/");
++#endif
++
++    switch (chdirMode) {
++    case ChdirMode::InParent: {
++        auto restoreCwd = qScopeGuard([old = QDir::currentPath()] {
++            QDir::setCurrent(old);
++        });
++        QVERIFY(QDir::setCurrent(target));
++        process.start();
++        break;
++    }
++    case ChdirMode::InChild:
++        process.setWorkingDirectory(target);
++        Q_FALLTHROUGH();
++    case ChdirMode::None:
++        process.start();
++        break;
++    }
++
++    QCOMPARE(process.waitForStarted(), success);
++    QCOMPARE(errorSpy.count(), int(!success));
++    if (success) {
++        QVERIFY(process.waitForFinished());
++    } else {
++        QCOMPARE(process.error(), QProcess::FailedToStart);
++    }
++}
++
+ QTEST_MAIN(tst_QProcess)
+ #include "tst_qprocess.moc"
+diff --git a/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp b/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp
+index e1ea7a4552..90972caa57 100644
+--- a/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp
++++ b/qtbase/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"
+diff --git a/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+index 9bd66c0835..ed4a0bae5d 100644
+--- a/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
++++ b/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+@@ -158,6 +158,7 @@ private slots:
+     void nullReceiver();
+     void functorReferencesConnection();
+     void disconnectDisconnects();
++    void declarativeData();
+ };
+ 
+ struct QObjectCreatedOnShutdown
+@@ -7679,5 +7680,81 @@ void tst_QObject::disconnectDisconnects()
+ Q_STATIC_ASSERT(QtPrivate::HasQ_OBJECT_Macro<tst_QObject>::Value);
+ Q_STATIC_ASSERT(!QtPrivate::HasQ_OBJECT_Macro<SiblingDeleter>::Value);
+ 
++#ifdef QT_BUILD_INTERNAL
++/*
++    Since QObjectPrivate stores the declarativeData pointer in a union with the pointer
++    to the currently destroyed child, calls to the QtDeclarative handlers need to be
++    correctly guarded. QTBUG-105286
++*/
++namespace QtDeclarative {
++static QAbstractDeclarativeData *theData;
++
++static void destroyed(QAbstractDeclarativeData *data, QObject *)
++{
++    QCOMPARE(data, theData);
++}
++static void signalEmitted(QAbstractDeclarativeData *data, QObject *, int, void **)
++{
++    QCOMPARE(data, theData);
++}
++// we can't use QCOMPARE in the next two functions, as they don't return void
++static int receivers(QAbstractDeclarativeData *data, const QObject *, int)
++{
++    QTest::qCompare(data, theData, "data", "theData", __FILE__, __LINE__);
++    return 0;
++}
++static bool isSignalConnected(QAbstractDeclarativeData *data, const QObject *, int)
++{
++    QTest::qCompare(data, theData, "data", "theData", __FILE__, __LINE__);
++    return true;
++}
++
++class Object : public QObject
++{
++    Q_OBJECT
++public:
++    using QObject::QObject;
++    ~Object()
++    {
++        if (Object *p = static_cast<Object *>(parent()))
++            p->emitSignal();
++    }
++
++    void emitSignal()
++    {
++        emit theSignal();
++    }
++
++signals:
++    void theSignal();
++};
++
++}
++#endif
++
++void tst_QObject::declarativeData()
++{
++#ifdef QT_BUILD_INTERNAL
++    QScopedValueRollback destroyed(QAbstractDeclarativeData::destroyed,
++                                   QtDeclarative::destroyed);
++    QScopedValueRollback signalEmitted(QAbstractDeclarativeData::signalEmitted,
++                                       QtDeclarative::signalEmitted);
++    QScopedValueRollback receivers(QAbstractDeclarativeData::receivers,
++                                   QtDeclarative::receivers);
++    QScopedValueRollback isSignalConnected(QAbstractDeclarativeData::isSignalConnected,
++                                           QtDeclarative::isSignalConnected);
++
++    QtDeclarative::Object p;
++    QObjectPrivate *priv = QObjectPrivate::get(&p);
++    priv->declarativeData = QtDeclarative::theData = new QAbstractDeclarativeData;
++
++    connect(&p, &QtDeclarative::Object::theSignal, &p, []{
++    });
++
++    QtDeclarative::Object *child = new QtDeclarative::Object;
++    child->setParent(&p);
++#endif
++}
++
+ QTEST_MAIN(tst_QObject)
+ #include "tst_qobject.moc"
+diff --git a/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp b/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
+index 0ea422ecbc..1a3256534b 100644
+--- a/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
++++ b/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
+@@ -70,15 +70,15 @@ static inline QString testSuiteWarning()
+ 
+     QString result;
+     QTextStream str(&result);
+-    str << "\nCannot find the shared-mime-info test suite\nstarting from: "
++    str << "\nCannot find the shared-mime-info test suite\nin the parent of: "
+         << QDir::toNativeSeparators(QDir::currentPath()) << "\n"
+            "cd " << QDir::toNativeSeparators(QStringLiteral("tests/auto/corelib/mimetypes/qmimedatabase")) << "\n"
+-           "wget http://cgit.freedesktop.org/xdg/shared-mime-info/snapshot/Release-1-10.zip\n"
+-           "unzip Release-1-10.zip\n";
++           "wget https://gitlab.freedesktop.org/xdg/shared-mime-info/-/archive/2.1/shared-mime-info-2.1.zip\n"
++           "unzip shared-mime-info-2.1.zip\n";
+ #ifdef Q_OS_WIN
+-    str << "mkdir testfiles\nxcopy /s Release-1-10 s-m-i\n";
++    str << "mkdir testfiles\nxcopy /s shared-mime-info-2.1 s-m-i\n";
+ #else
+-    str << "ln -s Release-1-10 s-m-i\n";
++    str << "ln -s shared-mime-info-2.1 s-m-i\n";
+ #endif
+     return result;
+ }
+@@ -154,7 +154,7 @@ void tst_QMimeDatabase::initTestCase()
+     QVERIFY2(copyResourceFile(xmlFileName, xmlTargetFileName, &errorMessage), qPrintable(errorMessage));
+ #endif
+ 
+-    m_testSuite = QFINDTESTDATA("s-m-i/tests");
++    m_testSuite = QFINDTESTDATA("s-m-i/tests/mime-detection");
+     if (m_testSuite.isEmpty())
+         qWarning("%s", qPrintable(testSuiteWarning()));
+ 
+@@ -611,7 +611,7 @@ void tst_QMimeDatabase::allMimeTypes()
+     QVERIFY(!lst.isEmpty());
+ 
+     // Hardcoding this is the only way to check both providers find the same number of mimetypes.
+-    QCOMPARE(lst.count(), 779);
++    QCOMPARE(lst.count(), 811);
+ 
+     foreach (const QMimeType &mime, lst) {
+         const QString name = mime.name();
+@@ -631,10 +631,9 @@ void tst_QMimeDatabase::suffixes_data()
+ 
+     QTest::newRow("mimetype with a single pattern") << "application/pdf" << "*.pdf" << "pdf";
+     QTest::newRow("mimetype with multiple patterns") << "application/x-kpresenter" << "*.kpr;*.kpt" << "kpr";
+-    QTest::newRow("jpeg") << "image/jpeg" << "*.jpe;*.jpg;*.jpeg" << "jpeg";
+-    //if (KMimeType::sharedMimeInfoVersion() > KDE_MAKE_VERSION(0, 60, 0)) {
+-        QTest::newRow("mimetype with many patterns") << "application/vnd.wordperfect" << "*.wp;*.wp4;*.wp5;*.wp6;*.wpd;*.wpp" << "wp";
+-    //}
++    // The preferred suffix for image/jpeg is *.jpg, as per https://bugs.kde.org/show_bug.cgi?id=176737
++    QTest::newRow("jpeg") << "image/jpeg" << "*.jpe;*.jpg;*.jpeg" << "jpg";
++    QTest::newRow("mimetype with many patterns") << "application/vnd.wordperfect" << "*.wp;*.wp4;*.wp5;*.wp6;*.wpd;*.wpp" << "wp";
+     QTest::newRow("oasis text mimetype") << "application/vnd.oasis.opendocument.text" << "*.odt" << "odt";
+     QTest::newRow("oasis presentation mimetype") << "application/vnd.oasis.opendocument.presentation" << "*.odp" << "odp";
+     QTest::newRow("mimetype with multiple patterns") << "text/plain" << "*.asc;*.txt;*,v" << "txt";
+diff --git a/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp b/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
+index 3e58dd03cc..c8f82ef5d5 100644
+--- a/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
++++ b/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
+@@ -176,6 +176,8 @@ private Q_SLOTS:
+     void fromToVariantConversions_data();
+     void fromToVariantConversions();
+ 
++    void noLeakOnNameClash();
++
+ private:
+     QString testDataDir;
+ };
+@@ -3685,5 +3687,23 @@ void tst_QtJson::fromToVariantConversions()
+     }
+ }
+ 
++void tst_QtJson::noLeakOnNameClash()
++{
++    QJsonDocument doc = QJsonDocument::fromJson("{\"\":{\"\":0},\"\":0}");
++    QVERIFY(!doc.isNull());
++    const QJsonObject obj = doc.object();
++
++    // Removed the duplicate key.
++    QCOMPARE(obj.length(), 1);
++
++    // Retained the last of the duplicates.
++    const QJsonValue val = obj.begin().value();
++    QVERIFY(val.isDouble());
++    QCOMPARE(val.toDouble(), 0.0);
++
++    // It should not leak.
++    // In particular it should not forget to deref the container for the inner object.
++}
++
+ QTEST_MAIN(tst_QtJson)
+ #include "tst_qtjson.moc"
+diff --git a/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp b/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
+index a59b58d57f..241c3e84ac 100644
+--- a/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
++++ b/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
+@@ -63,6 +63,7 @@ private slots:
+     void isValidId_data();
+     void isValidId();
+     void malformed();
++    void serialize();
+     // Backend tests
+     void utcTest();
+     void icuTest();
+@@ -947,6 +948,33 @@ void tst_QTimeZone::malformed()
+         barf.offsetFromUtc(now);
+ }
+ 
++void tst_QTimeZone::serialize()
++{
++    int parts = 0;
++#ifndef QT_NO_DEBUG_STREAM
++    qDebug() << QTimeZone(); // to verify no crash
++    parts++;
++#endif
++#ifndef QT_NO_DATASTREAM
++    QByteArray blob;
++    {
++        QDataStream stream(&blob, QIODevice::WriteOnly);
++        stream << QTimeZone("Europe/Oslo") << QTimeZone(420) << QTimeZone() << qint64(-1);
++    }
++    QDataStream stream(&blob, QIODevice::ReadOnly);
++    QTimeZone invalid, offset, oslo;
++    qint64 minusone;
++    stream >> oslo >> offset >> invalid >> minusone;
++    QCOMPARE(oslo, QTimeZone("Europe/Oslo"));
++    QCOMPARE(offset, QTimeZone(420));
++    QVERIFY(!invalid.isValid());
++    QCOMPARE(minusone, qint64(-1));
++    parts++;
++#endif
++    if (!parts)
++        QSKIP("No serialization enabled");
++}
++
+ void tst_QTimeZone::utcTest()
+ {
+ #ifdef QT_BUILD_INTERNAL
+diff --git a/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp b/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
+index 05480c6dd2..70f4c75756 100644
+--- a/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
++++ b/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
+@@ -324,6 +324,13 @@ void tst_QDBusInterface::notValid()
+ 
+     QVERIFY(!interface.isValid());
+     QVERIFY(!QMetaObject::invokeMethod(&interface, "ListNames", Qt::DirectConnection));
++
++    // With a connection, but empty/null service and path specified
++    QDBusConnection con = QDBusConnection::sessionBus();
++    QVERIFY(con.isConnected());
++    QDBusInterface iface({}, {}, {}, con);
++    QVERIFY(!iface.isValid());
++    QVERIFY(!QMetaObject::invokeMethod(&interface, "ListNames", Qt::DirectConnection));
+ }
+ 
+ void tst_QDBusInterface::notValidDerived()
+diff --git a/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp b/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
+index 874468c954..04ceb4ab65 100644
+--- a/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
++++ b/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
+@@ -507,6 +507,10 @@ void tst_QKeySequence::toStringFromKeycode_data()
+     QTest::newRow("Ctrl+Alt+Num+Del") << QKeySequence(Qt::ControlModifier | Qt::AltModifier | Qt::KeypadModifier | Qt::Key_Delete) << "Ctrl+Alt+Num+Del";
+     QTest::newRow("Ctrl+Ins") << QKeySequence(Qt::ControlModifier | Qt::Key_Insert) << "Ctrl+Ins";
+     QTest::newRow("Ctrl+Num+Ins(1)") << QKeySequence(Qt::Key_Insert | Qt::KeypadModifier | Qt::ControlModifier) << "Ctrl+Num+Ins";
++    QTest::newRow("Ctrl") << QKeySequence(Qt::Key_Control) << "Control";
++    QTest::newRow("Alt") << QKeySequence(Qt::Key_Alt) << "Alt";
++    QTest::newRow("Shift") << QKeySequence(Qt::Key_Shift) << "Shift";
++    QTest::newRow("Meta") << QKeySequence(Qt::Key_Meta) << "Meta";
+ }
+ 
+ void tst_QKeySequence::toStringFromKeycode()
+diff --git a/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp b/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+index 15e0ecadaa..b4eca74283 100644
+--- a/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
++++ b/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+@@ -81,6 +81,8 @@ private slots:
+     void registerOpenTypePreferredNamesSystem();
+     void registerOpenTypePreferredNamesApplication();
+ 
++    void stretchRespected();
++
+ private:
+     QString m_ledFont;
+     QString m_testFont;
+@@ -355,6 +357,28 @@ static QString testString()
+     return QStringLiteral("foo bar");
+ }
+ 
++void tst_QFontDatabase::stretchRespected()
++{
++    int italicId = QFontDatabase::addApplicationFont(m_testFontItalic);
++    QVERIFY(italicId != -1);
++
++    QVERIFY(!QFontDatabase::applicationFontFamilies(italicId).isEmpty());
++
++    QString italicFontName = QFontDatabase::applicationFontFamilies(italicId).first();
++
++    QFont italicFont = QFontDatabase().font(italicFontName,
++                                            QString::fromLatin1("Italic"), 14);
++    QVERIFY(italicFont.italic());
++
++    QFont italicStretchedFont = italicFont;
++    italicStretchedFont.setStretch( 400 );
++
++    QVERIFY(QFontMetricsF(italicFont).horizontalAdvance(QStringLiteral("foobar")) <
++            QFontMetricsF(italicStretchedFont).horizontalAdvance(QStringLiteral("foobar")));
++
++    QFontDatabase::removeApplicationFont(italicId);
++}
++
+ void tst_QFontDatabase::condensedFontWidthNoFontMerging()
+ {
+     int regularFontId = QFontDatabase::addApplicationFont(m_testFont);
+diff --git a/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+index 3d4a094c43..b423e11a99 100644
+--- a/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
++++ b/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+@@ -281,6 +281,7 @@ private Q_SLOTS:
+     void ioGetFromFileSpecial();
+     void ioGetFromFile_data();
+     void ioGetFromFile();
++    void ioGetFromFileUrl();
+     void ioGetFromFtp_data();
+     void ioGetFromFtp();
+     void ioGetFromFtpWithReuse();
+@@ -3300,6 +3301,18 @@ void tst_QNetworkReply::ioGetFromFile()
+     QCOMPARE(reader.data, data);
+ }
+ 
++void tst_QNetworkReply::ioGetFromFileUrl()
++{
++    // This immediately fails on non-windows platforms:
++    QNetworkRequest request(QUrl("file://unc-server/some/path"));
++    QNetworkReplyPtr reply(manager.get(request));
++    QSignalSpy finishedSpy(reply.get(), &QNetworkReply::finished);
++    // QTBUG-105618: This would, on non-Windows platforms, never happen because the signal
++    // was emitted before the constructor finished, leaving no chance at all to connect to the
++    // signal
++    QVERIFY(finishedSpy.wait());
++}
++
+ void tst_QNetworkReply::ioGetFromFtp_data()
+ {
+     QTest::addColumn<QString>("fileName");
+diff --git a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
+index 069fa6b341..4cc4d9a5ea 100644
+--- a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
++++ b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
+@@ -1,75 +1,34 @@
+-Certificate:
+-    Data:
+-        Version: 3 (0x2)
+-        Serial Number: 0 (0x0)
+-        Signature Algorithm: sha1WithRSAEncryption
+-        Issuer: C=NO, ST=Oslo, L=Nydalen, O=Nokia Corporation and/or its subsidiary(-ies), OU=Development, CN=fluke.troll.no/emailAddress=ahanssen@trolltech.com
+-        Validity
+-            Not Before: Dec  4 01:10:32 2007 GMT
+-            Not After : Apr 21 01:10:32 2035 GMT
+-        Subject: C=NO, ST=Oslo, O=Nokia Corporation and/or its subsidiary(-ies), OU=Development, CN=fluke.troll.no
+-        Subject Public Key Info:
+-            Public Key Algorithm: rsaEncryption
+-            RSA Public Key: (1024 bit)
+-                Modulus (1024 bit):
+-                    00:a7:c8:a0:4a:c4:19:05:1b:66:ba:32:e2:d2:f1:
+-                    1c:6f:17:82:e4:39:2e:01:51:90:db:04:34:32:11:
+-                    21:c2:0d:6f:59:d8:53:90:54:3f:83:8f:a9:d3:b3:
+-                    d5:ee:1a:9b:80:ae:c3:25:c9:5e:a5:af:4b:60:05:
+-                    aa:a0:d1:91:01:1f:ca:04:83:e3:58:1c:99:32:45:
+-                    84:70:72:58:03:98:4a:63:8b:41:f5:08:49:d2:91:
+-                    02:60:6b:e4:64:fe:dd:a0:aa:74:08:e9:34:4c:91:
+-                    5f:12:3d:37:4d:54:2c:ad:7f:5b:98:60:36:02:8c:
+-                    3b:f6:45:f3:27:6a:9b:94:9d
+-                Exponent: 65537 (0x10001)
+-        X509v3 extensions:
+-            X509v3 Basic Constraints: 
+-                CA:FALSE
+-            Netscape Comment: 
+-                OpenSSL Generated Certificate
+-            X509v3 Subject Key Identifier: 
+-                21:85:04:3D:23:01:66:E5:F7:9F:1A:84:24:8A:AF:0A:79:F4:E5:AC
+-            X509v3 Authority Key Identifier: 
+-                DirName:/C=NO/ST=Oslo/L=Nydalen/O=Nokia Corporation and/or its subsidiary(-ies)/OU=Development/CN=fluke.troll.no/emailAddress=ahanssen@trolltech.com
+-                serial:8E:A8:B4:E8:91:B7:54:2E
+-
+-    Signature Algorithm: sha1WithRSAEncryption
+-        6d:57:5f:d1:05:43:f0:62:05:ec:2a:71:a5:dc:19:08:f2:c4:
+-        a6:bd:bb:25:d9:ca:89:01:0e:e4:cf:1f:c1:8c:c8:24:18:35:
+-        53:59:7b:c0:43:b4:32:e6:98:b2:a6:ef:15:05:0b:48:5f:e1:
+-        a0:0c:97:a9:a1:77:d8:35:18:30:bc:a9:8f:d3:b7:54:c7:f1:
+-        a9:9e:5d:e6:19:bf:f6:3c:5b:2b:d8:e4:3e:62:18:88:8b:d3:
+-        24:e1:40:9b:0c:e6:29:16:62:ab:ea:05:24:70:36:aa:55:93:
+-        ef:02:81:1b:23:10:a2:04:eb:56:95:75:fc:f8:94:b1:5d:42:
+-        c5:3f:36:44:85:5d:3a:2e:90:46:8a:a2:b9:6f:87:ae:0c:15:
+-        40:19:31:90:fc:3b:25:bb:ae:f1:66:13:0d:85:90:d9:49:34:
+-        8f:f2:5d:f9:7a:db:4d:5d:27:f6:76:9d:35:8c:06:a6:4c:a3:
+-        b1:b2:b6:6f:1d:d7:a3:00:fd:72:eb:9e:ea:44:a1:af:21:34:
+-        7d:c7:42:e2:49:91:19:8b:c0:ad:ba:82:80:a8:71:70:f4:35:
+-        31:91:63:84:20:95:e9:60:af:64:8b:cc:ff:3d:8a:76:74:3d:
+-        c8:55:6d:e4:8e:c3:2b:1c:e8:42:18:ae:9f:e6:6b:9c:34:06:
+-        ec:6a:f2:c3
+ -----BEGIN CERTIFICATE-----
+-MIIEEzCCAvugAwIBAgIBADANBgkqhkiG9w0BAQUFADCBnDELMAkGA1UEBhMCTk8x
+-DTALBgNVBAgTBE9zbG8xEDAOBgNVBAcTB055ZGFsZW4xFjAUBgNVBAoTDVRyb2xs
+-dGVjaCBBU0ExFDASBgNVBAsTC0RldmVsb3BtZW50MRcwFQYDVQQDEw5mbHVrZS50
+-cm9sbC5ubzElMCMGCSqGSIb3DQEJARYWYWhhbnNzZW5AdHJvbGx0ZWNoLmNvbTAe
+-Fw0wNzEyMDQwMTEwMzJaFw0zNTA0MjEwMTEwMzJaMGMxCzAJBgNVBAYTAk5PMQ0w
+-CwYDVQQIEwRPc2xvMRYwFAYDVQQKEw1Ucm9sbHRlY2ggQVNBMRQwEgYDVQQLEwtE
+-ZXZlbG9wbWVudDEXMBUGA1UEAxMOZmx1a2UudHJvbGwubm8wgZ8wDQYJKoZIhvcN
+-AQEBBQADgY0AMIGJAoGBAKfIoErEGQUbZroy4tLxHG8XguQ5LgFRkNsENDIRIcIN
+-b1nYU5BUP4OPqdOz1e4am4CuwyXJXqWvS2AFqqDRkQEfygSD41gcmTJFhHByWAOY
+-SmOLQfUISdKRAmBr5GT+3aCqdAjpNEyRXxI9N01ULK1/W5hgNgKMO/ZF8ydqm5Sd
+-AgMBAAGjggEaMIIBFjAJBgNVHRMEAjAAMCwGCWCGSAGG+EIBDQQfFh1PcGVuU1NM
+-IEdlbmVyYXRlZCBDZXJ0aWZpY2F0ZTAdBgNVHQ4EFgQUIYUEPSMBZuX3nxqEJIqv
+-Cnn05awwgbsGA1UdIwSBszCBsKGBoqSBnzCBnDELMAkGA1UEBhMCTk8xDTALBgNV
+-BAgTBE9zbG8xEDAOBgNVBAcTB055ZGFsZW4xFjAUBgNVBAoTDVRyb2xsdGVjaCBB
+-U0ExFDASBgNVBAsTC0RldmVsb3BtZW50MRcwFQYDVQQDEw5mbHVrZS50cm9sbC5u
+-bzElMCMGCSqGSIb3DQEJARYWYWhhbnNzZW5AdHJvbGx0ZWNoLmNvbYIJAI6otOiR
+-t1QuMA0GCSqGSIb3DQEBBQUAA4IBAQBtV1/RBUPwYgXsKnGl3BkI8sSmvbsl2cqJ
+-AQ7kzx/BjMgkGDVTWXvAQ7Qy5piypu8VBQtIX+GgDJepoXfYNRgwvKmP07dUx/Gp
+-nl3mGb/2PFsr2OQ+YhiIi9Mk4UCbDOYpFmKr6gUkcDaqVZPvAoEbIxCiBOtWlXX8
+-+JSxXULFPzZEhV06LpBGiqK5b4euDBVAGTGQ/Dslu67xZhMNhZDZSTSP8l35ettN
+-XSf2dp01jAamTKOxsrZvHdejAP1y657qRKGvITR9x0LiSZEZi8CtuoKAqHFw9DUx
+-kWOEIJXpYK9ki8z/PYp2dD3IVW3kjsMrHOhCGK6f5mucNAbsavLD
++MIIF6zCCA9OgAwIBAgIUfo9amJtJGWqWE6f+SkAO85zkGr4wDQYJKoZIhvcNAQEL
++BQAwgYMxCzAJBgNVBAYTAk5PMQ0wCwYDVQQIDARPc2xvMQ0wCwYDVQQHDARPc2xv
++MRcwFQYDVQQKDA5UaGUgUXQgQ29tcGFueTEMMAoGA1UECwwDUiZEMRIwEAYDVQQD
++DAlIMiBUZXN0ZXIxGzAZBgkqhkiG9w0BCQEWDG1pbmltaUBxdC5pbzAgFw0yMDEw
++MjYxMjAxMzFaGA8yMTIwMTAwMjEyMDEzMVowgYMxCzAJBgNVBAYTAk5PMQ0wCwYD
++VQQIDARPc2xvMQ0wCwYDVQQHDARPc2xvMRcwFQYDVQQKDA5UaGUgUXQgQ29tcGFu
++eTEMMAoGA1UECwwDUiZEMRIwEAYDVQQDDAlIMiBUZXN0ZXIxGzAZBgkqhkiG9w0B
++CQEWDG1pbmltaUBxdC5pbzCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIB
++AOiUp5+E4blouKH7q+rVNR8NoYX2XkBW+q+rpy1zu5ssRSzbqxAjDx9dkht7Qlnf
++VlDT00JvpOWdeuPon5915edQRsY4Unl6mKH29ra3OtUa1/yCJXsGVJTKCj7k4Bxb
++5mZzb/fTlZntMLdTIBMfUbw62FKir1WjKIcJ9fCoG8JaGeKVO4Rh5p0ezd4UUUId
++r1BXl5Nqdqy2vTMsEDnjOsD3egkv8I2SKN4O6n/C3wWYpMOWYZkGoZiKz7rJs/i/
++ez7bsV7JlwdzTlhpJzkcOSVFBP6JlEOxTNNxZ1wtKy7PtZGmsSSATq2e6+bw38Ae
++Op0XnzzqcGjtDDofBmT7OFzZWjS9VZS6+DOOe2QHWle1nCHcHyH4ku6IRlsr9xkR
++NAIlOfnvHHxqJUenoeaZ4oQDjCBKS1KXygJO/tL7BLTQVn/xK1EmPvKNnjzWk4tR
++PnibUhhs5635qpOU/YPqFBh1JjVruZbsWcDAhRcew0uxONXOa9E+4lttQ9ySYa1A
++LvWqJuAX7gu2BsBMLyqfm811YnA7CIFMyO+HlqmkLFfv5L/xIRAXR7l26YGO0VwX
++CGjMfz4NVPMMke4nB7qa9NkpXQBQKMms3Qzd5JW0Hy9Ruj5O8GPcFZmV0twjd1uJ
++PD/cAjkWLaXjdNsJ16QWc2nghQRS6HYqKRX6j+CXOxupAgMBAAGjUzBRMB0GA1Ud
++DgQWBBRSCOU58j9NJZkMamt623qyCrhN3TAfBgNVHSMEGDAWgBRSCOU58j9NJZkM
++amt623qyCrhN3TAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4ICAQCq
++q4jxsWeNDv5Nq14hJtF9HB+ZL64zcZtRjJP1YgNs0QppKICmjPOL2nIMGmI/jKrs
++0eGAL/9XXNVHPxm1OPOncvimMMmU6emZfpMdEtTfKP43+Pg9HgKRjLoQp406vGeQ
++8ki/mbBhrItVPgEm3tu2AFA02XTYi+YxCI9kRZLGkM3FbgtOuTLPl0Z9y+kiPc9F
++uCSC03anBEqv+vDSI8+wODymQ/IJ3Jyz1lxIRDfp4qAekmy0jU2c91VOHHEmOmqq
++kqygGFRdwbe99m9yP63r6q0b5K3X2UnJ6bns0hmTwThYwpVPXLU8jdaTddbMukN2
++/Ef96Tsw8nWOEOPMySHOTIPgwyZRp26b0kA9EmhLwOP401SxXVQCmSRmtwNagmtg
++jJKmZoYBN+//D45ibK8z6Q0oOm9P+Whf/uUXehcRxBxyV3xz7k0wKGQbHj/ddwcy
++IUoIN4lrAlib+lK170kTKN352PDmrpo2gmIzPEsfurKAIMSelDl6H+kih16BtZ8y
++Nz6fh9Soqrg3OSAware8pxV7k51crBMoPLN78KoRV8MFCK4K7Fddq4rRISq6hiXq
++r1nsjoEPuKM9huprmZVZe9t5YcDa2I+wb3IiE3uwpZbAdaLDyQ5n6F/qpsiIkZXn
++gtcF7oqpG5oYrwCcZ53y/ezUgUg7PlSz2XwAGvQtgg==
+ -----END CERTIFICATE-----
+diff --git a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
+index 9d1664d609..337ce541a6 100644
+--- a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
++++ b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
+@@ -1,15 +1,52 @@
+------BEGIN RSA PRIVATE KEY-----
+-MIICXAIBAAKBgQCnyKBKxBkFG2a6MuLS8RxvF4LkOS4BUZDbBDQyESHCDW9Z2FOQ
+-VD+Dj6nTs9XuGpuArsMlyV6lr0tgBaqg0ZEBH8oEg+NYHJkyRYRwclgDmEpji0H1
+-CEnSkQJga+Rk/t2gqnQI6TRMkV8SPTdNVCytf1uYYDYCjDv2RfMnapuUnQIDAQAB
+-AoGANFzLkanTeSGNFM0uttBipFT9F4a00dqHz6JnO7zXAT26I5r8sU1pqQBb6uLz
+-/+Qz5Zwk8RUAQcsMRgJetuPQUb0JZjF6Duv24hNazqXBCu7AZzUenjafwmKC/8ri
+-KpX3fTwqzfzi//FKGgbXQ80yykSSliDL3kn/drATxsLCgQECQQDXhEFWLJ0vVZ1s
+-1Ekf+3NITE+DR16X+LQ4W6vyEHAjTbaNWtcTKdAWLA2l6N4WAAPYSi6awm+zMxx4
+-VomVTsjdAkEAx0z+e7natLeFcrrq8pbU+wa6SAP1VfhQWKitxL1e7u/QO90NCpxE
+-oQYKzMkmmpOOFjQwEMAy1dvFMbm4LHlewQJAC/ksDBaUcQHHqjktCtrUb8rVjAyW
+-A8lscckeB2fEYyG5J6dJVaY4ClNOOs5yMDS2Afk1F6H/xKvtQ/5CzInA/QJATDub
+-K+BPU8jO9q+gpuIi3VIZdupssVGmCgObVCHLakG4uO04y9IyPhV9lA9tALtoIf4c
+-VIvv5fWGXBrZ48kZAQJBAJmVCdzQxd9LZI5vxijUCj5EI4e+x5DRqVUvyP8KCZrC
+-AiNyoDP85T+hBZaSXK3aYGpVwelyj3bvo1GrTNwNWLw=
+------END RSA PRIVATE KEY-----
++-----BEGIN PRIVATE KEY-----
++MIIJQgIBADANBgkqhkiG9w0BAQEFAASCCSwwggkoAgEAAoICAQDolKefhOG5aLih
+++6vq1TUfDaGF9l5AVvqvq6ctc7ubLEUs26sQIw8fXZIbe0JZ31ZQ09NCb6TlnXrj
++6J+fdeXnUEbGOFJ5epih9va2tzrVGtf8giV7BlSUygo+5OAcW+Zmc2/305WZ7TC3
++UyATH1G8OthSoq9VoyiHCfXwqBvCWhnilTuEYeadHs3eFFFCHa9QV5eTanastr0z
++LBA54zrA93oJL/CNkijeDup/wt8FmKTDlmGZBqGYis+6ybP4v3s+27FeyZcHc05Y
++aSc5HDklRQT+iZRDsUzTcWdcLSsuz7WRprEkgE6tnuvm8N/AHjqdF5886nBo7Qw6
++HwZk+zhc2Vo0vVWUuvgzjntkB1pXtZwh3B8h+JLuiEZbK/cZETQCJTn57xx8aiVH
++p6HmmeKEA4wgSktSl8oCTv7S+wS00FZ/8StRJj7yjZ481pOLUT54m1IYbOet+aqT
++lP2D6hQYdSY1a7mW7FnAwIUXHsNLsTjVzmvRPuJbbUPckmGtQC71qibgF+4LtgbA
++TC8qn5vNdWJwOwiBTMjvh5appCxX7+S/8SEQF0e5dumBjtFcFwhozH8+DVTzDJHu
++Jwe6mvTZKV0AUCjJrN0M3eSVtB8vUbo+TvBj3BWZldLcI3dbiTw/3AI5Fi2l43Tb
++CdekFnNp4IUEUuh2KikV+o/glzsbqQIDAQABAoICAFw1q6tr5I48vY7DF+rXsuLn
++5ZUWE1IQ6fzB4lr72nJv/9EEGnMgYzt9PpMUsD6vdCpBgS2C0+6RHArFzJtNA+RM
++iHLIG7K7702veyr/xBx/MwiSlMeMv/XpkFxVI6E6skMGG2s3AMXxKvJTy5CpRx+I
++eQFyLG+Ya1X2lgJes/q+/CpAHkOjCOpcLySQC5NZ74q734V7nSdmn+Zs3tYEh+O/
++eiuwTP/j5b38Te5vVTqDxTciJPmljmXLCwa0N100lWlbcpvw8qbqiTI2Jm3XCbUE
++AzHjW9vmrF3cRS1fXxKFGShw3SRqlkbxjfeWoi8qDPUBS4m8LOr8qG9Wo5Nfon0z
++zLP4bci3zHDvVcaaZrrsUBs/yZbg+Dgka1DmX7ekmeccr2yTdKDFgPupYUyxVbTl
++a9ZLJysjFD7rgBv1ZclHonLp6Vbm+ZoTqvteo4ikAy6L9RtBWJ23XEK34PkP/+c5
++2vWZaOrnjSeBHbFce8cdJSxqWpP+eSCI5I9XbDrYFIsQ/gqKgtzDKy2ihJ2Y8STL
++yO4hyFPFjxc+Gg4/P2PpmT5CY2ty44M0BWs+JGW96CJPrrplf2lmQUQJj5LZY66X
++Z/4C9L7ZYtKZ+bs5SvU46yWugAvQZX22Xm9xLXWyVXRdx3bj+3M3fDnF9di/zdbh
++CgLx7oWPNrXc7FCajnn9AoIBAQD5FMYwRpw9NWT9WDxQwx+cSI4Icbd88ByTW63S
++LzeRwZA0J9/SfwO+aBRupzc9GkGXCiZcGMw3AGsCtig8yFlw8E5KnzN7KlftDMnM
++9NUxxzlR8VwKyLnZfG7sDTl057ZlUujnqhmt/F8F7dIy7FVO1dE/8nngA+FYTCOG
++UZdGjwyBDlDM0JJdUWGY3xslutcpCDN5mzSTKjy9drMvImAshRawxRF6WBpn7vr2
++nC6vciqfx1Mzx1vyk0Jm0ilaydDdLMADjt/iL4Nkr0BEs4k+UzQiKDwp8gu7abQ1
++eBfxd9Iar4htQa2I1Ewl6P01G/q+ZYwgHhJ9RVn4AxQXefILAoIBAQDvCouORdQX
++C8wsyp7MwXlF/3NQeNN5/+B2mhbxrBOf7PmMCXLnkRWcjwJtzypWFqJ0sqai/2+0
++bqbMcjX5maT8stT2shl3zXe/Ejt2e3TBYpc1tyuses8Kb5BMU8hu6tTd3G2CMXpD
++dT6DVemJZCTtwj9aBNIxSizvlgMolJnCpzhPnlfHSI6E+g3m/LTTo3HwbjMSw/Uq
++irgjOpI2wSBB6LZPSgjvfcYPRyWUk16L4A5uSX0cADnovDFLa5/h0wJvN/OoCSQg
++rLCXG5E18EyL5Wc58BCY1ZvxmjG3lQtgPxYu2Jwc36R/y/JKlxW5suER5ZNpbbD4
++uOyTt2VxMQ2bAoIBAQC5+MzRFqdo/AjfL5Y5JrbfVTzXCTDa09xCGd16ZU60QTWN
+++4ed/r+o1sUKqUcRFB2MzEM/2DQBjQpZB/CbEWvWa1XJWXxypXbowveZU+QqOnmN
++uQvj8WLyA3o+PNF9e9QvauwCrHpn8VpxbtPWuaYoKnUFreFZZQxHhPGxRBIS2JOZ
++eDrT8ZaWnkCkh1AZp5smQ71LOprSlmKrg4jd1GjCVMxQR5N5KXbtyv0OTCZ/UFqK
++2aRBsMPyJgkaBChkZPLRcKwc+/wlQRx1fHQb14DNTApMxoXFO7eOwqmOkpAt9iyl
++SBIwoS0UUI5ab88+bBmXNvKcuFdNuQ4nowTJUn9pAoIBADMNkILBXSvS5DeIyuO2
++Sp1tkoZUV+5NfPY3sMDK3KIibaW/+t+EOBZo4L7tKQCb8vRzl21mmsfxfgRaPDbj
++3r3tv9g0b4YLxxBy52pFscj/soXRai17SS7UZwA2QK+XzgDYbDcLNC6mIsTQG4Gx
++dsWk3/zs3KuUSQaehmwrWK+fIUK38c1pLK8v7LoxrLkqxlHwZ04RthHw8KTthH7X
++Pnl1J0LF8CSeOyfWLSuPUfkT0GEzptnNHpEbaHfQM6R6eaGhVJPF6AZme4y6YYgg
++m2ihhSt1n0XVEWpHYWjxFy3mK2mz75unFC4LM+NEY2p2zuUQoCw7NjnY3QYrfCnx
++rRMCggEAXeXsMSLFjjyuoL7iKbAxo52HD/P0fBoy58LyRcwfNVr0lvYan4pYEx+o
++KijIh9K16PqXZXKMA9v003B+ulmF8bJ7SddCZ5NGvnFhUTDe4DdTKgp2RuwQ3Bsc
++3skPIDbhVETyOLCtys34USHrq8U/0DlGY3eLRfxw9GnbKxSBGa/KEu/qQLPNUo50
++7xHZDg7GKeC3kqNJeqKM9rkp0VzIGkEnaD9127LeNDmERDfftxJzFoC/THvUBLfU
++6Sus2ZYwRE8VFvKC30Q45t/c54X3IuhYvAuiCuTmyfE4ruyzyOwKzhUkeeLq1APX
++g0veFbyfzlJ0q8qzD/iffqqIa2ZSmQ==
++-----END PRIVATE KEY-----
+diff --git a/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp b/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
+index 7ba3715e13..752aa122f6 100644
+--- a/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
++++ b/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
+@@ -179,6 +179,7 @@ void tst_QAccessibilityLinux::initTestCase()
+     QVERIFY(!address.isEmpty());
+ 
+     m_window = new AccessibleTestWindow();
++    m_window->setObjectName("mainWindow"_L1);
+     m_window->show();
+ 
+     QVERIFY(QTest::qWaitForWindowExposed(m_window));
+@@ -236,8 +237,11 @@ bool hasState(QDBusInterface *interface, AtspiStateType state)
+ void tst_QAccessibilityLinux::testLabel()
+ {
+     QLabel *l = new QLabel(m_window);
++    l->setObjectName("theObjectName"_L1);
+     l->setText("Hello A11y");
+     m_window->addWidget(l);
++    auto a11yEmpty = new QLabel(m_window);
++    m_window->addWidget(l);
+ 
+     // Application
+     QCOMPARE(getParent(mainWindow), QLatin1String(ATSPI_DBUS_PATH_ROOT));
+@@ -249,6 +253,8 @@ void tst_QAccessibilityLinux::testLabel()
+     QCOMPARE(getChildren(labelInterface).count(), 0);
+     QCOMPARE(labelInterface->call(QDBus::Block, "GetRoleName").arguments().first().toString(), QLatin1String("label"));
+     QCOMPARE(labelInterface->call(QDBus::Block, "GetRole").arguments().first().toUInt(), 29u);
++    QCOMPARE(labelInterface->call(QDBus::Block, "GetAccessibleId").arguments().first().toString(),
++             QLatin1String("mainWindow.theObjectName"));
+     QCOMPARE(getParent(labelInterface), mainWindow->path());
+     QVERIFY(!hasState(labelInterface, ATSPI_STATE_EDITABLE));
+     QVERIFY(hasState(labelInterface, ATSPI_STATE_READ_ONLY));
+@@ -256,7 +262,12 @@ void tst_QAccessibilityLinux::testLabel()
+     l->setText("New text");
+     QCOMPARE(labelInterface->property("Name").toString(), l->text());
+ 
++    auto *a11yEmptyInterface = getInterface(children.at(1), "org.a11y.atspi.Accessible");
++    QCOMPARE(a11yEmptyInterface->call(QDBus::Block, "GetAccessibleId").arguments().first().toString(),
++             QLatin1String("mainWindow.QLabel"));
++
+     m_window->clearChildren();
++    delete a11yEmptyInterface;
+     delete labelInterface;
+ }
+ 
+diff --git a/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+index 76df61c892..6d6d65b791 100644
+--- a/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
++++ b/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2022 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the test suite of the Qt Toolkit.
+@@ -68,6 +68,8 @@ private slots:
+     void query_exec();
+     void execErrorRecovery_data() { generic_data(); }
+     void execErrorRecovery();
++    void prematureExec_data() { generic_data(); }
++    void prematureExec();
+     void first_data() { generic_data(); }
+     void first();
+     void next_data() { generic_data(); }
+@@ -2770,6 +2772,35 @@ void tst_QSqlQuery::execErrorRecovery()
+     QVERIFY_SQL( q, exec() );
+ }
+ 
++void tst_QSqlQuery::prematureExec()
++{
++    QFETCH(QString, dbName);
++    // We only want the engine name, for addDatabase():
++    int cut = dbName.indexOf(QChar('@'));
++    if (cut < 0)
++        QSKIP("Failed to parse database type out of name");
++    dbName.truncate(cut);
++    cut = dbName.indexOf(QChar('_'));
++    if (cut >= 0)
++        dbName = dbName.mid(cut + 1);
++
++    auto db = QSqlDatabase::addDatabase(dbName);
++    QSqlQuery q(db);
++
++    QTest::ignoreMessage(QtWarningMsg,
++                         "QSqlDatabasePrivate::removeDatabase: connection "
++                         "'qt_sql_default_connection' is still in use, all "
++                         "queries will cease to work.");
++    QTest::ignoreMessage(QtWarningMsg,
++                         "QSqlDatabasePrivate::addDatabase: duplicate connection name "
++                         "'qt_sql_default_connection', old connection removed.");
++    auto otherDb = QSqlDatabase::addDatabase(dbName);
++
++    QTest::ignoreMessage(QtWarningMsg, "QSqlQuery::exec: called before driver has been set up");
++    // QTBUG-100037: shouldn't crash !
++    QVERIFY(!q.exec("select stuff from TheVoid"));
++}
++
+ void tst_QSqlQuery::lastInsertId()
+ {
+     QFETCH( QString, dbName );
+diff --git a/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp b/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
+index 4aa3f8d60b..d2050a61aa 100644
+--- a/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
++++ b/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
+@@ -115,6 +115,10 @@ void tst_QAbstractItemModelTester::standardItemModelZeroColumns()
+     // QTBUG-92886
+     model.insertRows(0, 5);
+     model.removeRows(1, 2);
++
++    const QModelIndex parentIndex = model.index(0, 0);
++    model.insertRows(0, 5, parentIndex);
++    model.removeRows(1, 2, parentIndex);
+ }
+ 
+ void tst_QAbstractItemModelTester::testInsertThroughProxy()
+diff --git a/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json b/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
+index 12a4a22a19..ce518e78fb 100644
+--- a/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
++++ b/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
+@@ -668,50 +668,6 @@
+         "inputFile": "task192552.h",
+         "outputRevision": 67
+     },
+-    {
+-        "classes": [
+-            {
+-                "className": "InlineSlotsWithThrowDeclaration",
+-                "object": true,
+-                "qualifiedClassName": "InlineSlotsWithThrowDeclaration",
+-                "slots": [
+-                    {
+-                        "access": "public",
+-                        "name": "a",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "b",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "c",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "d",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "e",
+-                        "returnType": "void"
+-                    }
+-                ],
+-                "superClasses": [
+-                    {
+-                        "access": "public",
+-                        "name": "QObject"
+-                    }
+-                ]
+-            }
+-        ],
+-        "inputFile": "task189996.h",
+-        "outputRevision": 67
+-    },
+     {
+         "classes": [
+             {
+diff --git a/qtbase/tests/auto/tools/moc/moc.pro b/qtbase/tests/auto/tools/moc/moc.pro
+index c324b3a8cd..4aceb78dc0 100644
+--- a/qtbase/tests/auto/tools/moc/moc.pro
++++ b/qtbase/tests/auto/tools/moc/moc.pro
+@@ -15,7 +15,7 @@ cross_compile: DEFINES += MOC_CROSS_COMPILED
+ HEADERS += using-namespaces.h no-keywords.h task87883.h c-comments.h backslash-newlines.h oldstyle-casts.h \
+            slots-with-void-template.h qinvokable.h namespaced-flags.h trigraphs.h \
+            escapes-in-string-literals.h cstyle-enums.h qprivateslots.h gadgetwithnoenums.h \
+-           dir-in-include-path.h single_function_keyword.h task192552.h task189996.h \
++           dir-in-include-path.h single_function_keyword.h task192552.h \
+            task234909.h task240368.h pure-virtual-signals.h cxx11-enums.h \
+            cxx11-final-classes.h \
+            cxx11-explicit-override-control.h \
+diff --git a/qtbase/tests/auto/tools/moc/task189996.h b/qtbase/tests/auto/tools/moc/task189996.h
+deleted file mode 100644
+index f94a051b3a..0000000000
+--- a/qtbase/tests/auto/tools/moc/task189996.h
++++ /dev/null
+@@ -1,47 +0,0 @@
+-/****************************************************************************
+-**
+-** Copyright (C) 2016 The Qt Company Ltd.
+-** Contact: https://www.qt.io/licensing/
+-**
+-** This file is part of the test suite of the Qt Toolkit.
+-**
+-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+-** 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 General Public License Usage
+-** Alternatively, this file may be used under the terms of the GNU
+-** General Public License version 3 as published by the Free Software
+-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+-** 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-3.0.html.
+-**
+-** $QT_END_LICENSE$
+-**
+-****************************************************************************/
+-// inline functions can have throw declarations
+-
+-#ifndef TASK189996_H
+-#define TASK189996_H
+-
+-#include <QObject>
+-
+-class InlineSlotsWithThrowDeclaration : public QObject
+-{
+-    Q_OBJECT
+-
+-public slots:
+-    void a() throw() { }
+-    void b() const throw() { }
+-    void c() throw();
+-    void d() throw(int) { }
+-    void e() const throw(int,double) { }
+-};
+-
+-#endif
+diff --git a/qtbase/tests/auto/tools/moc/tst_moc.cpp b/qtbase/tests/auto/tools/moc/tst_moc.cpp
+index c716aead21..15dd9e41e5 100644
+--- a/qtbase/tests/auto/tools/moc/tst_moc.cpp
++++ b/qtbase/tests/auto/tools/moc/tst_moc.cpp
+@@ -631,7 +631,6 @@ public:
+ private slots:
+     void initTestCase();
+ 
+-    void slotWithException() throw(MyStruct);
+     void dontStripNamespaces();
+     void oldStyleCasts();
+     void warnOnExtraSignalSlotQualifiaction();
+@@ -673,7 +672,6 @@ private slots:
+     void templateGtGt();
+     void qprivateslots();
+     void qprivateproperties();
+-    void inlineSlotsWithThrowDeclaration();
+     void warnOnPropertyWithoutREAD();
+     void constructors();
+     void typenameWithUnsigned();
+@@ -784,12 +782,6 @@ void tst_Moc::initTestCase()
+ #endif
+ }
+ 
+-void tst_Moc::slotWithException() throw(MyStruct)
+-{
+-    // be happy
+-    QVERIFY(true);
+-}
+-
+ void tst_Moc::dontStripNamespaces()
+ {
+     Sender sender;
+@@ -824,7 +816,7 @@ void tst_Moc::oldStyleCasts()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-Wold-style-cast" << "-I" << "."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -894,7 +886,7 @@ void tst_Moc::inputFileNameWithDotsButNoExtension()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-I" << ".."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -1174,7 +1166,7 @@ void tst_Moc::ignoreOptionClashes()
+     QStringList gccArgs;
+     gccArgs << "-c" << "-x" << "c++" << "-I" << ".."
+          << "-I" << qtIncludePath << "-I" << includeDir << "-o" << "/dev/null"
+-         << "-fPIC" << "-std=c++11" <<  "-";
++         << "-fPIC" << "-std=c++1z" <<  "-";
+     proc.start("gcc", gccArgs);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -1593,21 +1585,6 @@ void tst_Moc::qprivateproperties()
+ 
+ }
+ 
+-#include "task189996.h"
+-
+-void InlineSlotsWithThrowDeclaration::c() throw() {}
+-
+-void tst_Moc::inlineSlotsWithThrowDeclaration()
+-{
+-    InlineSlotsWithThrowDeclaration tst;
+-    const QMetaObject *mobj = tst.metaObject();
+-    QVERIFY(mobj->indexOfSlot("a()") != -1);
+-    QVERIFY(mobj->indexOfSlot("b()") != -1);
+-    QVERIFY(mobj->indexOfSlot("c()") != -1);
+-    QVERIFY(mobj->indexOfSlot("d()") != -1);
+-    QVERIFY(mobj->indexOfSlot("e()") != -1);
+-}
+-
+ void tst_Moc::warnOnPropertyWithoutREAD()
+ {
+ #ifdef MOC_CROSS_COMPILED
+@@ -1869,7 +1846,7 @@ void tst_Moc::notifyError()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-I" << "."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+diff --git a/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+index c355ee9665..88c09de8e0 100644
+--- a/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
++++ b/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+@@ -251,6 +251,7 @@ private slots:
+     void testResetCachedSizeHint();
+     void statusTips();
+     void testRemovingColumnsViaLayoutChanged();
++    void testModelMovingColumns();
+ 
+ protected:
+     void setupTestData(bool use_reset_model = false);
+@@ -360,6 +361,12 @@ public:
+         endRemoveColumns();
+     }
+ 
++    void moveColumn(int from, int to)
++    {
++        beginMoveColumns(QModelIndex(), from, from, QModelIndex(), to);
++        endMoveColumns();
++    }
++
+     void cleanup()
+     {
+         emit layoutAboutToBeChanged();
+@@ -3627,5 +3634,18 @@ void tst_QHeaderView::testRemovingColumnsViaLayoutChanged()
+     // The main point of this test is that the section-size restoring code didn't go out of bounds.
+ }
+ 
++void tst_QHeaderView::testModelMovingColumns()
++{
++    QtTestModel model(10, 10);
++    QHeaderView hv(Qt::Horizontal);
++    hv.setModel(&model);
++    hv.resizeSections(QHeaderView::ResizeToContents);
++    hv.show();
++
++    QPersistentModelIndex index3 = model.index(0, 3);
++    model.moveColumn(3, 1);
++    QCOMPARE(index3.column(), 1);
++}
++
+ QTEST_MAIN(tst_QHeaderView)
+ #include "tst_qheaderview.moc"
+diff --git a/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+index 761357b252..06bb706074 100644
+--- a/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
++++ b/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+@@ -397,6 +397,7 @@ private slots:
+     void checkHeaderMinSize();
+ 
+     void resizeToContents();
++    void resizeToContentsSpans();
+ 
+     void tabFocus();
+     void bigModel();
+@@ -3721,6 +3722,70 @@ void tst_QTableView::resizeToContents()
+ 
+ }
+ 
++
++class SpanModel : public QAbstractTableModel
++{
++public:
++    SpanModel(bool sectionsMoved)
++        : _sectionsMoved(sectionsMoved)
++    {}
++    int columnCount(const QModelIndex & = {}) const override { return 2; }
++    int rowCount(const QModelIndex & = {}) const override { return 1; }
++    QVariant data(const QModelIndex &idx, int role = Qt::DisplayRole) const override
++    {
++        if (role != Qt::DisplayRole)
++            return QVariant();
++        const int col = _sectionsMoved ? 1 - idx.column() : idx.column();
++        if (col == 0)
++            return "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.";
++        return QVariant();
++    }
++private:
++    bool _sectionsMoved;
++};
++
++
++void tst_QTableView::resizeToContentsSpans()
++{
++    SpanModel model1(false);
++    SpanModel model2(true);
++    QTableView view1, view2, view3;
++    view1.setModel(&model1);
++    view2.setModel(&model2);
++    view2.horizontalHeader()->moveSection(0, 1);
++    view3.setModel(&model1);
++
++    view1.setSpan(0, 0, 1, 2);
++    view2.setSpan(0, 1, 1, 2);
++    view1.show();
++    view2.show();
++    view3.show();
++    QVERIFY(QTest::qWaitForWindowExposed(&view1));
++    QVERIFY(QTest::qWaitForWindowExposed(&view2));
++    QVERIFY(QTest::qWaitForWindowExposed(&view3));
++    view1.setColumnWidth(0, 100);
++    view1.setColumnWidth(1, 100);
++    view2.setColumnWidth(0, 100);
++    view2.setColumnWidth(1, 100);
++    view3.setColumnWidth(0, 200);
++
++    view1.resizeRowToContents(0);
++    view2.resizeRowToContents(0);
++    view3.resizeRowToContents(0);
++    QCOMPARE(view1.rowHeight(0), view3.rowHeight(0));
++    QCOMPARE(view2.rowHeight(0), view3.rowHeight(0));
++
++    view3.resizeColumnToContents(0);
++    view3.resizeRowToContents(0);
++    // height should be only 1 text line for easy testing
++    view1.setRowHeight(0, view3.verticalHeader()->sectionSize(0));
++    view2.setRowHeight(0, view3.verticalHeader()->sectionSize(0));
++    view1.resizeColumnToContents(0);
++    view2.resizeColumnToContents(1);
++    QCOMPARE(view1.columnWidth(0), view3.columnWidth(0) - view1.columnWidth(1));
++    QCOMPARE(view2.columnWidth(0), view3.columnWidth(0) - view2.columnWidth(1));
++}
++
+ QT_BEGIN_NAMESPACE
+ extern bool Q_WIDGETS_EXPORT qt_tab_all_widgets(); // qapplication.cpp
+ QT_END_NAMESPACE
+diff --git a/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+index a3b8ef78d8..4955cebd5d 100644
+--- a/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
++++ b/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+@@ -1498,7 +1498,7 @@ void tst_QApplication::desktopSettingsAware()
+     environment += QLatin1String("QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM=1");
+     testProcess.setEnvironment(environment);
+ #endif
+-    testProcess.start("desktopsettingsaware_helper");
++    testProcess.start("./desktopsettingsaware_helper");
+     QVERIFY2(testProcess.waitForStarted(),
+              qPrintable(QString::fromLatin1("Cannot start 'desktopsettingsaware_helper': %1").arg(testProcess.errorString())));
+     QVERIFY(testProcess.waitForFinished(10000));
+@@ -2452,7 +2452,7 @@ void tst_QApplication::qtbug_12673()
+ #if QT_CONFIG(process)
+     QProcess testProcess;
+     QStringList arguments;
+-    testProcess.start("modal_helper", arguments);
++    testProcess.start("./modal_helper", arguments);
+     QVERIFY2(testProcess.waitForStarted(),
+              qPrintable(QString::fromLatin1("Cannot start 'modal_helper': %1").arg(testProcess.errorString())));
+     QVERIFY(testProcess.waitForFinished(20000));
+diff --git a/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp b/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
+index eb108a40de..dca5528c1b 100644
+--- a/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
+@@ -41,6 +41,7 @@
+ 
+ #include <private/qguiapplication_p.h>
+ #include <qpa/qplatformintegration.h>
++#include <qpa/qplatformtheme.h>
+ 
+ class tst_QAbstractButton : public QObject
+ {
+@@ -76,6 +77,8 @@ private slots:
+     void keyNavigation();
+ #endif
+ 
++    void buttonPressKeys();
++
+ protected slots:
+     void onClicked();
+     void onToggled( bool on );
+@@ -269,7 +272,13 @@ void tst_QAbstractButton::setAutoRepeat()
+         QCOMPARE(press_count, click_count);
+         QVERIFY(click_count > 1);
+         break;
+-    case 4:
++    case 4: {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(Qt::Key_Enter)) {
++            QSKIP("platform theme has Key_Enter in ButtonPressKeys");
++        }
+         // check that pressing ENTER has no effect when autorepeat is false
+         testWidget->setDown( false );
+         testWidget->setAutoRepeat( false );
+@@ -286,7 +295,14 @@ void tst_QAbstractButton::setAutoRepeat()
+ 
+         QVERIFY( click_count == 0 );
+         break;
+-    case 5:
++    }
++    case 5: {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(Qt::Key_Enter)) {
++            QSKIP("platform theme has Key_Enter in ButtonPressKeys");
++        }
+         // check that pressing ENTER has no effect when autorepeat is true
+         testWidget->setDown( false );
+         testWidget->setAutoRepeat( true );
+@@ -304,6 +320,7 @@ void tst_QAbstractButton::setAutoRepeat()
+ 
+         QVERIFY( click_count == 0 );
+         break;
++    }
+     case 6:
+         // verify autorepeat is off by default.
+         MyButton tmp( 0);
+@@ -651,5 +668,16 @@ void tst_QAbstractButton::keyNavigation()
+ }
+ #endif
+ 
++void tst_QAbstractButton::buttonPressKeys()
++{
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(testWidget, buttonPressKeys[i]);
++        QCOMPARE(click_count, i + 1);
++    }
++}
++
+ QTEST_MAIN(tst_QAbstractButton)
+ #include "tst_qabstractbutton.moc"
+diff --git a/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+index 32437050f5..46b5af6d63 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+@@ -168,6 +168,7 @@ private slots:
+     void checkMenuItemPosWhenStyleSheetIsSet();
+     void checkEmbeddedLineEditWhenStyleSheetIsSet();
+     void propagateStyleChanges();
++    void buttonPressKeys();
+ 
+ private:
+     PlatformInputContext m_platformInputContext;
+@@ -1682,6 +1683,16 @@ void tst_QComboBox::setModel()
+     QCOMPARE(box.rootModelIndex(), rootModelIndex);
+     box.setModel(box.model());
+     QCOMPARE(box.rootModelIndex(), rootModelIndex);
++
++    // check that setting the same model as the completer's doesn't crash
++    QCompleter *completer = new QCompleter(&box);
++    box.setEditable(true);
++    box.setCompleter(completer);
++    auto *listModel = new QStringListModel({ "one", "two" }, completer);
++    completer->setModel(listModel);
++    QCOMPARE(listModel->rowCount(), 2); // make sure it wasn't deleted
++    box.setModel(listModel);
++    QCOMPARE(listModel->rowCount(), 2); // make sure it wasn't deleted
+ }
+ 
+ void tst_QComboBox::setCustomModelAndView()
+@@ -3632,5 +3643,24 @@ void tst_QComboBox::propagateStyleChanges()
+     QVERIFY(frameStyle.inquired);
+ }
+ 
++void tst_QComboBox::buttonPressKeys()
++{
++    QComboBox comboBox;
++    comboBox.setEditable(false);
++    comboBox.addItem(QString::number(1));
++    comboBox.addItem(QString::number(2));
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(&comboBox, buttonPressKeys[i]);
++        // On some platforms, a window will not be immediately visible,
++        // but take some event-loop iterations to complete.
++        // Using QTRY_VERIFY to deal with that.
++        QTRY_VERIFY(comboBox.view()->isVisible());
++        comboBox.hidePopup();
++    }
++}
++
+ QTEST_MAIN(tst_QComboBox)
+ #include "tst_qcombobox.moc"
+diff --git a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
+index be3cfcd104..c228fdfcca 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
++++ b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qcommandlinkbutton
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qcommandlinkbutton.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
+index 0044d33c66..4cf06296e4 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
+@@ -40,6 +40,9 @@
+ #include <QGridLayout>
+ #include <QPainter>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ class tst_QCommandLinkButton : public QObject
+ {
+     Q_OBJECT
+@@ -223,6 +226,13 @@ void tst_QCommandLinkButton::setAutoRepeat()
+     // check that pressing ENTER has no effect
+     resetCounters();
+     testWidget->setDown( false );
++    // Skip after reset if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
+     testWidget->setAutoRepeat( false );
+     QTest::keyPress( testWidget, Qt::Key_Enter );
+ 
+@@ -255,6 +265,14 @@ void tst_QCommandLinkButton::pressed()
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+ 
++    // Skip if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
++
+     QTest::keyPress( testWidget,Qt::Key_Enter );
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+diff --git a/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro b/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
+index 4a5e76ff65..a235fa1fac 100644
+--- a/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
++++ b/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qgroupbox
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qgroupbox.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp b/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
+index 4fb5d262ca..d8d7562b73 100644
+--- a/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
+@@ -35,6 +35,9 @@
+ #include <QRadioButton>
+ #include <QDialog>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ #include "qgroupbox.h"
+ 
+ class tst_QGroupBox : public QObject
+@@ -69,6 +72,7 @@ private slots:
+     void propagateFocus();
+     void task_QTBUG_19170_ignoreMouseReleaseEvent();
+     void task_QTBUG_15519_propagateMouseEvents();
++    void buttonPressKeys();
+ 
+ private:
+     bool checked;
+@@ -610,6 +614,20 @@ void tst_QGroupBox::task_QTBUG_15519_propagateMouseEvents()
+     QCOMPARE(parent.mouseMoved, true);
+ }
+ 
++void tst_QGroupBox::buttonPressKeys()
++{
++    QGroupBox groupBox;
++    groupBox.setCheckable(true);
++    QSignalSpy clickedSpy(&groupBox, &QGroupBox::clicked);
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(&groupBox, buttonPressKeys[i]);
++        QCOMPARE(clickedSpy.length(), i + 1);
++    }
++}
++
+ void tst_QGroupBox::sendMouseMoveEvent(QWidget *widget, const QPoint &localPos)
+ {
+     // Send a MouseMove event without actually moving the pointer
+diff --git a/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro b/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
+index 353ad06ca2..e55f6148f2 100644
+--- a/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
++++ b/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qpushbutton
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qpushbutton.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp b/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
+index e818514a79..4043e9326a 100644
+--- a/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
+@@ -41,6 +41,9 @@
+ #include <QStyleFactory>
+ #include <QTabWidget>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ class tst_QPushButton : public QObject
+ {
+ Q_OBJECT
+@@ -212,6 +215,13 @@ void tst_QPushButton::autoRepeat()
+     // check that pressing ENTER has no effect
+     resetCounters();
+     testWidget->setDown( false );
++    // Skip after reset if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
+     testWidget->setAutoRepeat( false );
+     QTest::keyPress( testWidget, Qt::Key_Enter );
+ 
+@@ -247,6 +257,14 @@ void tst_QPushButton::pressed()
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+ 
++    // Skip if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
++
+     QTest::keyPress( testWidget,Qt::Key_Enter );
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+diff --git a/qtbase/tests/manual/rhi/cubemap_render/buildshader.bat b/qtbase/tests/manual/rhi/cubemap_render/buildshader.bat
+old mode 100755
+new mode 100644
+Submodule qtconnectivity e957d481..056294c0:
+diff --git a/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp b/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
+index e2635fae..a8b8e3b9 100644
+--- a/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
++++ b/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
+@@ -563,9 +563,11 @@ void HciManager::handleHciAclPacket(const quint8 *data, int size)
+ 
+ void HciManager::handleLeMetaEvent(const quint8 *data)
+ {
+-    // Spec v4.2, Vol 2, part E, 7.7.65ff
++    // Spec v5.3, Vol 4, part E, 7.7.65.*
+     switch (*data) {
+-    case 0x1: {
++    case 0x1: // HCI_LE_Connection_Complete
++    case 0xA: // HCI_LE_Enhanced_Connection_Complete
++    {
+         const quint16 handle = bt_get_le16(data + 2);
+         emit connectionComplete(handle);
+         break;
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp b/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
+index 6a93143b..4a18cfc7 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
+@@ -320,7 +320,10 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_finishSdpScan(QBluetoothServiceD
+             for (const QBluetoothUuid &id : serviceClassUuids) {
+                 if (id.minimumSize() == 16) {
+                     serviceInfo.setServiceUuid(id);
+-                    serviceInfo.setServiceName(QBluetoothServiceDiscoveryAgent::tr("Custom Service"));
++                    if (serviceInfo.serviceName().isEmpty()) {
++                        serviceInfo.setServiceName(
++                                    QBluetoothServiceDiscoveryAgent::tr("Custom Service"));
++                    }
+                     QBluetoothServiceInfo::Sequence modSeq =
+                             serviceInfo.attribute(QBluetoothServiceInfo::ServiceClassIds).value<QBluetoothServiceInfo::Sequence>();
+                     modSeq.removeOne(QVariant::fromValue(id));
+@@ -334,8 +337,10 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_finishSdpScan(QBluetoothServiceD
+                 qCDebug(QT_BT_BLUEZ) << "Discovered services" << discoveredDevices.at(0).address().toString()
+                                      << serviceInfo.serviceName() << serviceInfo.serviceUuid()
+                                      << ">>>" << serviceInfo.serviceClassUuids();
+-
+-                emit q->serviceDiscovered(serviceInfo);
++                // Use queued connection to allow us finish the service looping; the application
++                // might call stop() when it has detected the service-of-interest.
++                QMetaObject::invokeMethod(q, "serviceDiscovered", Qt::QueuedConnection,
++                                          Q_ARG(QBluetoothServiceInfo, serviceInfo));
+             }
+         }
+     }
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp b/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
+index e4d85447..aadd4755 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
+@@ -593,7 +593,7 @@ void QBluetoothSocket::setSocketState(QBluetoothSocket::SocketState state)
+ bool QBluetoothSocket::canReadLine() const
+ {
+     Q_D(const QBluetoothSocketBase);
+-    return d->canReadLine();
++    return d->canReadLine() || QIODevice::canReadLine();
+ }
+ 
+ /*!
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp b/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
+index 084aa958..d6aa17a7 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
+@@ -284,6 +284,10 @@ void QBluetoothSocketPrivateBluezDBus::connectToService(
+         return;
+     }
+ 
++    if (service.socketProtocol() != QBluetoothServiceInfo::Protocol::UnknownProtocol)
++        socketType = service.socketProtocol();
++    qCDebug(QT_BT_BLUEZ) << "Socket protocol used:" << socketType;
++
+     connectToService(service.device().address(), targetService, openMode);
+ }
+ 
+diff --git a/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp b/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
+index 05bc1a0f..a7b5ef1f 100644
+--- a/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
++++ b/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
+@@ -142,7 +142,7 @@ void tst_QBluetoothSocket::initTestCase()
+     qDebug() << "Starting discovery";
+ 
+     sda->setUuidFilter(QBluetoothUuid(QString(TEST_SERVICE_UUID)));
+-    sda->start(QBluetoothServiceDiscoveryAgent::MinimalDiscovery);
++    sda->start(QBluetoothServiceDiscoveryAgent::FullDiscovery);
+ 
+     for (int connectTime = MaxConnectTime; !done_discovery && connectTime > 0; connectTime -= 1000)
+         QTest::qWait(1000);
+Submodule qtdeclarative f5701f0d..8defe7bf:
+diff --git a/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h b/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
+index b65b994d6c..15a8cd6878 100644
+--- a/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
++++ b/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
+@@ -86,7 +86,7 @@ public:
+         if (QTypeInfo<T>::isComplex) {
+             for (int i = 0; i < count; ++i)
+                 new (data + i) T(vector.at(i));
+-        } else {
++        } else if (count) {
+             memcpy(data, static_cast<const void*>(vector.constData()), count * sizeof(T));
+         }
+     }
+diff --git a/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp b/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
+index e57cdd8278..94613598af 100644
+--- a/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
++++ b/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
+@@ -1145,8 +1145,7 @@ void Heap::QObjectWrapper::markObjects(Heap::Base *that, QV4::MarkStack *markSta
+ void QObjectWrapper::destroyObject(bool lastCall)
+ {
+     Heap::QObjectWrapper *h = d();
+-    if (!h->internalClass)
+-        return; // destroyObject already got called
++    Q_ASSERT(h->internalClass);
+ 
+     if (h->object()) {
+         QQmlData *ddata = QQmlData::get(h->object(), false);
+@@ -1176,7 +1175,7 @@ void QObjectWrapper::destroyObject(bool lastCall)
+         }
+     }
+ 
+-    h->~Data();
++    h->destroy();
+ }
+ 
+ 
+diff --git a/qtdeclarative/src/qml/memory/qv4mm.cpp b/qtdeclarative/src/qml/memory/qv4mm.cpp
+index 06caf04e5a..da149a67c4 100644
+--- a/qtdeclarative/src/qml/memory/qv4mm.cpp
++++ b/qtdeclarative/src/qml/memory/qv4mm.cpp
+@@ -981,7 +981,7 @@ void MemoryManager::sweep(bool lastSweep, ClassDestroyStatsCallback classCountPt
+ 
+     if (MultiplyWrappedQObjectMap *multiplyWrappedQObjects = engine->m_multiplyWrappedQObjects) {
+         for (MultiplyWrappedQObjectMap::Iterator it = multiplyWrappedQObjects->begin(); it != multiplyWrappedQObjects->end();) {
+-            if (!it.value().isNullOrUndefined())
++            if (it.value().isNullOrUndefined())
+                 it = multiplyWrappedQObjects->erase(it);
+             else
+                 ++it;
+diff --git a/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp b/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
+index 2079a8ed04..a577cb2351 100644
+--- a/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
++++ b/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
+@@ -389,6 +389,12 @@ void QQmlDelegateModelPrivate::connectToAbstractItemModel()
+                       q,  QQmlDelegateModel, SLOT(_q_rowsRemoved(QModelIndex,int,int)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
+                       q,  QQmlDelegateModel, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsInserted(QModelIndex,int,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsInserted(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsRemoved(QModelIndex,int,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsRemoved(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsMoved(QModelIndex,int,int,QModelIndex,int)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
+                       q, QQmlDelegateModel, SLOT(_q_dataChanged(QModelIndex,QModelIndex,QVector<int>)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
+@@ -413,6 +419,12 @@ void QQmlDelegateModelPrivate::disconnectFromAbstractItemModel()
+                         q, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int)));
+     QObject::disconnect(aim, SIGNAL(rowsRemoved(QModelIndex,int,int)),
+                         q, SLOT(_q_rowsRemoved(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsInserted(QModelIndex,int,int)), q,
++                        SLOT(_q_columnsInserted(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsRemoved(QModelIndex,int,int)), q,
++                        SLOT(_q_columnsRemoved(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)), q,
++                        SLOT(_q_columnsMoved(QModelIndex,int,int,QModelIndex,int)));
+     QObject::disconnect(aim, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
+                         q, SLOT(_q_dataChanged(QModelIndex,QModelIndex,QVector<int>)));
+     QObject::disconnect(aim, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
+@@ -1973,6 +1985,38 @@ void QQmlDelegateModel::_q_rowsMoved(
+     }
+ }
+ 
++void QQmlDelegateModel::_q_columnsInserted(const QModelIndex &parent, int begin, int end)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if (parent == d->m_adaptorModel.rootIndex && begin == 0) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
++void QQmlDelegateModel::_q_columnsRemoved(const QModelIndex &parent, int begin, int end)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if (parent == d->m_adaptorModel.rootIndex && begin == 0) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
++void QQmlDelegateModel::_q_columnsMoved(const QModelIndex &parent, int start, int end,
++                                        const QModelIndex &destination, int column)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if ((parent == d->m_adaptorModel.rootIndex && start == 0)
++        || (destination == d->m_adaptorModel.rootIndex && column == 0)) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
+ void QQmlDelegateModel::_q_dataChanged(const QModelIndex &begin, const QModelIndex &end, const QVector<int> &roles)
+ {
+     Q_D(QQmlDelegateModel);
+diff --git a/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h b/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
+index 8aab4badca..d140bfbaaf 100644
+--- a/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
++++ b/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
+@@ -152,6 +152,9 @@ private Q_SLOTS:
+     void _q_itemsMoved(int from, int to, int count);
+     void _q_modelReset();
+     void _q_rowsInserted(const QModelIndex &,int,int);
++    void _q_columnsInserted(const QModelIndex &, int, int);
++    void _q_columnsRemoved(const QModelIndex &, int, int);
++    void _q_columnsMoved(const QModelIndex &, int, int, const QModelIndex &, int);
+     void _q_rowsAboutToBeRemoved(const QModelIndex &parent, int begin, int end);
+     void _q_rowsRemoved(const QModelIndex &,int,int);
+     void _q_rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int);
+diff --git a/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp b/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
+index 85719fdc80..78e2ab302c 100644
+--- a/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
++++ b/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
+@@ -46,6 +46,7 @@
+ #include "QtQuick/private/qquicktextinput_p.h"
+ #include "QtQuick/private/qquickaccessibleattached_p.h"
+ #include "QtQuick/qquicktextdocument.h"
++#include "QtQuick/qquickrendercontrol.h"
+ QT_BEGIN_NAMESPACE
+ 
+ #if QT_CONFIG(accessibility)
+@@ -57,7 +58,19 @@ QAccessibleQuickItem::QAccessibleQuickItem(QQuickItem *item)
+ 
+ QWindow *QAccessibleQuickItem::window() const
+ {
+-    return item()->window();
++    QQuickWindow *window = item()->window();
++
++    // For QQuickWidget the above window will be the offscreen QQuickWindow,
++    // which is not a part of the accessibility tree. Detect this case and
++    // return the window for the QQuickWidget instead.
++    if (window && !window->handle()) {
++        if (QQuickRenderControl *renderControl = QQuickWindowPrivate::get(window)->renderControl) {
++            if (QWindow *renderWindow = renderControl->renderWindow(nullptr))
++                return renderWindow;
++        }
++    }
++
++    return window;
+ }
+ 
+ int QAccessibleQuickItem::childCount() const
+@@ -113,19 +126,15 @@ QAccessibleInterface *QAccessibleQuickItem::childAt(int x, int y) const
+ QAccessibleInterface *QAccessibleQuickItem::parent() const
+ {
+     QQuickItem *parent = item()->parentItem();
+-    QQuickWindow *window = item()->window();
+-    QQuickItem *ci = window ? window->contentItem() : nullptr;
++    QQuickWindow *itemWindow = item()->window();
++    QQuickItem *ci = itemWindow ? itemWindow->contentItem() : nullptr;
+     while (parent && !QQuickItemPrivate::get(parent)->isAccessible && parent != ci)
+         parent = parent->parentItem();
+ 
+     if (parent) {
+         if (parent == ci) {
+-            // Jump out to the scene widget if the parent is the root item.
+-            // There are two root items, QQuickWindow::rootItem and
+-            // QQuickView::declarativeRoot. The former is the true root item,
+-            // but is not a part of the accessibility tree. Check if we hit
+-            // it here and return an interface for the scene instead.
+-            return QAccessible::queryAccessibleInterface(window);
++            // Jump out to the window if the parent is the root item
++            return QAccessible::queryAccessibleInterface(window());
+         } else {
+             while (parent && !parent->d_func()->isAccessible)
+                 parent = parent->parentItem();
+@@ -188,7 +197,7 @@ QAccessible::State QAccessibleQuickItem::state() const
+     QRect viewRect_ = viewRect();
+     QRect itemRect = rect();
+ 
+-    if (viewRect_.isNull() || itemRect.isNull() || !item()->window() || !item()->window()->isVisible() ||!item()->isVisible() || qFuzzyIsNull(item()->opacity()))
++    if (viewRect_.isNull() || itemRect.isNull() || !window() || !window()->isVisible() ||!item()->isVisible() || qFuzzyIsNull(item()->opacity()))
+         state.invisible = true;
+     if (!viewRect_.intersects(itemRect))
+         state.offscreen = true;
+@@ -201,6 +210,10 @@ QAccessible::State QAccessibleQuickItem::state() const
+     if (role() == QAccessible::EditableText)
+         if (auto ti = qobject_cast<QQuickTextInput *>(item()))
+             state.passwordEdit = ti->echoMode() != QQuickTextInput::Normal;
++    if (!item()->isEnabled()) {
++        state.focusable = false;
++        state.disabled = true;
++    }
+     return state;
+ }
+ 
+diff --git a/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h b/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
+index 39ffcaf39c..8baa01330c 100644
+--- a/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
++++ b/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
+@@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE
+ 
+ #if QT_CONFIG(accessibility)
+ 
+-class QAccessibleQuickWindow : public QAccessibleObject
++class Q_QUICK_EXPORT QAccessibleQuickWindow : public QAccessibleObject
+ {
+ public:
+     QAccessibleQuickWindow(QQuickWindow *object);
+diff --git a/qtdeclarative/src/quick/items/qquickdrag.cpp b/qtdeclarative/src/quick/items/qquickdrag.cpp
+index 8321fcfeed..383078b3b9 100644
+--- a/qtdeclarative/src/quick/items/qquickdrag.cpp
++++ b/qtdeclarative/src/quick/items/qquickdrag.cpp
+@@ -481,7 +481,9 @@ void QQuickDragAttached::setKeys(const QStringList &keys)
+     \qmlattachedproperty stringlist QtQuick::Drag::mimeData
+     \since 5.2
+ 
+-    This property holds a map of mimeData that is used during startDrag.
++    This property holds a map from mime type to data that is used during startDrag.
++    The mime data needs to be a \c string, or an \c ArrayBuffer with the data encoded
++    according to the mime type.
+ */
+ 
+ QVariantMap QQuickDragAttached::mimeData() const
+@@ -766,8 +768,12 @@ Qt::DropAction QQuickDragAttachedPrivate::startDrag(Qt::DropActions supportedAct
+     QDrag *drag = new QDrag(source ? source : q);
+     QMimeData *mimeData = new QMimeData();
+ 
+-    for (auto it = externalMimeData.cbegin(), end = externalMimeData.cend(); it != end; ++it)
+-        mimeData->setData(it.key(), it.value().toString().toUtf8());
++    for (auto it = externalMimeData.cbegin(), end = externalMimeData.cend(); it != end; ++it) {
++        if (static_cast<QMetaType::Type>(it.value().type()) == QMetaType::QByteArray)
++            mimeData->setData(it.key(), it.value().toByteArray());
++        else
++            mimeData->setData(it.key(), it.value().toString().toUtf8());
++    }
+ 
+     drag->setMimeData(mimeData);
+     if (pixmapLoader.isReady()) {
+diff --git a/qtdeclarative/src/quick/items/qquickitem.cpp b/qtdeclarative/src/quick/items/qquickitem.cpp
+index 75f1457816..dec0ae19ae 100644
+--- a/qtdeclarative/src/quick/items/qquickitem.cpp
++++ b/qtdeclarative/src/quick/items/qquickitem.cpp
+@@ -59,6 +59,7 @@
+ #include <QtCore/private/qnumeric_p.h>
+ #include <QtGui/qpa/qplatformtheme.h>
+ #include <QtCore/qloggingcategory.h>
++#include <QtCore/private/qduplicatetracker_p.h>
+ 
+ #include <private/qqmlglobal_p.h>
+ #include <private/qqmlengine_p.h>
+@@ -2326,6 +2327,7 @@ QQuickItem::QQuickItem(QQuickItemPrivate &dd, QQuickItem *parent)
+ QQuickItem::~QQuickItem()
+ {
+     Q_D(QQuickItem);
++    d->inDestructor = true;
+ 
+     if (d->windowRefCount > 1)
+         d->windowRefCount = 1; // Make sure window is set to null in next call to derefWindow().
+@@ -2526,6 +2528,7 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo
+     QQuickItem *current = item;
+     qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: startItem:" << startItem;
+     qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: firstFromItem:" << firstFromItem;
++    QDuplicateTracker<QQuickItem *> cycleDetector;
+     do {
+         qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: current:" << current;
+         qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: from:" << from;
+@@ -2592,7 +2595,10 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo
+         // traversed all of the chain (by compare the [current] item with [startItem])
+         // Since the [startItem] might be promoted to its parent if it is invisible,
+         // we still have to check [current] item with original start item
+-        if ((current == startItem || current == originalStartItem) && from == firstFromItem) {
++        // We might also run into a cycle before we reach firstFromItem again
++        // but note that we have to ignore current if we are meant to skip it
++        if (((current == startItem || current == originalStartItem) && from == firstFromItem) ||
++                (!skip && cycleDetector.hasSeen(current))) {
+             // wrapped around, avoid endless loops
+             if (item == contentItem) {
+                 qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: looped, return contentItem";
+@@ -2689,9 +2695,8 @@ void QQuickItem::setParentItem(QQuickItem *parentItem)
+ 
+         const bool wasVisible = isVisible();
+         op->removeChild(this);
+-        if (wasVisible) {
++        if (wasVisible && !op->inDestructor)
+             emit oldParentItem->visibleChildrenChanged();
+-        }
+     } else if (d->window) {
+         QQuickWindowPrivate::get(d->window)->parentlessItems.remove(this);
+     }
+@@ -2768,8 +2773,9 @@ void QQuickItem::setParentItem(QQuickItem *parentItem)
+ 
+     d->itemChange(ItemParentHasChanged, d->parentItem);
+ 
+-    emit parentChanged(d->parentItem);
+-    if (isVisible() && d->parentItem)
++    if (!d->inDestructor)
++        emit parentChanged(d->parentItem);
++    if (isVisible() && d->parentItem && !QQuickItemPrivate::get(d->parentItem)->inDestructor)
+         emit d->parentItem->visibleChildrenChanged();
+ }
+ 
+@@ -2965,7 +2971,8 @@ void QQuickItemPrivate::removeChild(QQuickItem *child)
+ 
+     itemChange(QQuickItem::ItemChildRemovedChange, child);
+ 
+-    emit q->childrenChanged();
++    if (!inDestructor)
++        emit q->childrenChanged();
+ }
+ 
+ void QQuickItemPrivate::refWindow(QQuickWindow *c)
+@@ -3194,6 +3201,7 @@ QQuickItemPrivate::QQuickItemPrivate()
+     , touchEnabled(false)
+ #endif
+     , hasCursorHandler(false)
++    , inDestructor(false)
+     , dirtyAttributes(0)
+     , nextDirtyItem(nullptr)
+     , prevDirtyItem(nullptr)
+@@ -5120,6 +5128,13 @@ void QQuickItem::componentComplete()
+         d->addToDirtyList();
+         QQuickWindowPrivate::get(d->window)->dirtyItem(this);
+     }
++
++#if QT_CONFIG(accessibility)
++    if (d->isAccessible && d->effectiveVisible) {
++        QAccessibleEvent ev(this, QAccessible::ObjectShow);
++        QAccessible::updateAccessibility(&ev);
++    }
++#endif
+ }
+ 
+ QQuickStateGroup *QQuickItemPrivate::_states()
+@@ -6106,9 +6121,11 @@ bool QQuickItemPrivate::setEffectiveVisibleRecur(bool newEffectiveVisible)
+         QAccessible::updateAccessibility(&ev);
+     }
+ #endif
+-    emit q->visibleChanged();
+-    if (childVisibilityChanged)
+-        emit q->visibleChildrenChanged();
++    if (!inDestructor) {
++        emit q->visibleChanged();
++        if (childVisibilityChanged)
++            emit q->visibleChildrenChanged();
++    }
+ 
+     return true;    // effective visibility DID change
+ }
+@@ -6157,6 +6174,15 @@ void QQuickItemPrivate::setEffectiveEnableRecur(QQuickItem *scope, bool newEffec
+     }
+ 
+     itemChange(QQuickItem::ItemEnabledHasChanged, effectiveEnable);
++#if QT_CONFIG(accessibility)
++    if (isAccessible) {
++        QAccessible::State changedState;
++        changedState.disabled = true;
++        changedState.focusable = true;
++        QAccessibleStateChangeEvent ev(q, changedState);
++        QAccessible::updateAccessibility(&ev);
++    }
++#endif
+     emit q->enabledChanged();
+ }
+ 
+diff --git a/qtdeclarative/src/quick/items/qquickitem_p.h b/qtdeclarative/src/quick/items/qquickitem_p.h
+index 841d91bb40..ade8fb61f2 100644
+--- a/qtdeclarative/src/quick/items/qquickitem_p.h
++++ b/qtdeclarative/src/quick/items/qquickitem_p.h
+@@ -472,6 +472,7 @@ public:
+     bool replayingPressEvent:1;
+     bool touchEnabled:1;
+     bool hasCursorHandler:1;
++    quint32 inDestructor:1; // has entered ~QQuickItem
+ 
+     enum DirtyType {
+         TransformOrigin         = 0x00000001,
+diff --git a/qtdeclarative/src/quick/items/qquickitemview.cpp b/qtdeclarative/src/quick/items/qquickitemview.cpp
+index 010a0152e1..f8ad168a17 100644
+--- a/qtdeclarative/src/quick/items/qquickitemview.cpp
++++ b/qtdeclarative/src/quick/items/qquickitemview.cpp
+@@ -1785,7 +1785,7 @@ void QQuickItemViewPrivate::refill(qreal from, qreal to)
+ 
+     do {
+         bufferPause.stop();
+-        if (currentChanges.hasPendingChanges() || bufferedChanges.hasPendingChanges()) {
++        if (currentChanges.hasPendingChanges() || bufferedChanges.hasPendingChanges() || currentChanges.active) {
+             currentChanges.reset();
+             bufferedChanges.reset();
+             releaseVisibleItems(reusableFlag);
+diff --git a/qtdeclarative/src/quick/items/qquickmousearea_p_p.h b/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
+index fba383e268..0d63618622 100644
+--- a/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
++++ b/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
+@@ -61,7 +61,6 @@ QT_BEGIN_NAMESPACE
+ 
+ class QQuickMouseEvent;
+ class QQuickMouseArea;
+-class QQuickPointerMask;
+ class QQuickMouseAreaPrivate : public QQuickItemPrivate
+ {
+     Q_DECLARE_PUBLIC(QQuickMouseArea)
+@@ -100,7 +99,6 @@ public:
+ #if QT_CONFIG(quick_draganddrop)
+     QQuickDrag *drag;
+ #endif
+-    QPointer<QQuickPointerMask> mask;
+     QPointF startScene;
+     QPointF targetStartPos;
+     QPointF lastPos;
+diff --git a/qtdeclarative/src/quick/items/qquicktext.cpp b/qtdeclarative/src/quick/items/qquicktext.cpp
+index 6230186933..e823ca1095 100644
+--- a/qtdeclarative/src/quick/items/qquicktext.cpp
++++ b/qtdeclarative/src/quick/items/qquicktext.cpp
+@@ -2168,7 +2168,7 @@ void QQuickText::resetMaximumLineCount()
+     <img src="" align="top,middle,bottom" width="" height=""> - inline images
+     <ol type="">, <ul type=""> and <li> - ordered and unordered lists
+     <pre></pre> - preformatted
+-    &gt; &lt; &amp;
++    &gt; &lt; &amp; &quot; &nbsp; &apos;
+     \endcode
+ 
+     \c Text.StyledText parser is strict, requiring tags to be correctly nested.
+diff --git a/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp b/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
+index eb4db0f85e..2325a2665b 100644
+--- a/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
++++ b/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
+@@ -446,7 +446,7 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+         const char *textureRecord = allocatorData;
+         for (int i = 0; i < textureCount; ++i, textureRecord += Qtdf::TextureRecordSize) {
+-            if (textureRecord + Qtdf::TextureRecordSize > qtdfTableEnd) {
++            if (qtdfTableEnd - textureRecord < Qtdf::TextureRecordSize) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+@@ -462,7 +462,7 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+         const char *glyphRecord = textureRecord;
+         for (quint32 i = 0; i < glyphCount; ++i, glyphRecord += Qtdf::GlyphRecordSize) {
+-            if (glyphRecord + Qtdf::GlyphRecordSize > qtdfTableEnd) {
++            if (qtdfTableEnd - glyphRecord < Qtdf:: GlyphRecordSize) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+@@ -512,8 +512,8 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+             int width = texInfo->allocatedArea.width();
+             int height = texInfo->allocatedArea.height();
+-            qint64 size = width * height;
+-            if (reinterpret_cast<const char *>(textureData + size) > qtdfTableEnd) {
++            qint64 size = qint64(width) * height;
++            if (qtdfTableEnd - reinterpret_cast<const char *>(textureData) < size) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+diff --git a/qtdeclarative/src/quick/util/qquickstyledtext.cpp b/qtdeclarative/src/quick/util/qquickstyledtext.cpp
+index d531fc9205..a25af90414 100644
+--- a/qtdeclarative/src/quick/util/qquickstyledtext.cpp
++++ b/qtdeclarative/src/quick/util/qquickstyledtext.cpp
+@@ -564,6 +564,8 @@ void QQuickStyledTextPrivate::parseEntity(const QChar *&ch, const QString &textI
+                 textOut += QChar(60);
+             else if (entity == QLatin1String("amp"))
+                 textOut += QChar(38);
++            else if (entity == QLatin1String("apos"))
++                textOut += QChar(39);
+             else if (entity == QLatin1String("quot"))
+                 textOut += QChar(34);
+             else if (entity == QLatin1String("nbsp"))
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp
+new file mode 100644
+index 0000000000..8a1c901880
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp
+@@ -0,0 +1,110 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include "qaccessiblequickwidget_p.h"
++
++#include "qquickwidget_p.h"
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleQuickWidget::QAccessibleQuickWidget(QQuickWidget* widget)
++: QAccessibleWidget(widget)
++, m_accessibleWindow(QQuickWidgetPrivate::get(widget)->offscreenWindow)
++{
++    // NOTE: m_accessibleWindow is a QAccessibleQuickWindow, and not a
++    // QAccessibleQuickWidgetOffscreenWindow (defined below). This means
++    // it will return the Quick item child interfaces, which is what's needed here
++    // (unlike QAccessibleQuickWidgetOffscreenWindow, which will report 0 children).
++}
++
++QAccessibleInterface *QAccessibleQuickWidget::child(int index) const
++{
++    return m_accessibleWindow.child(index);
++}
++
++int QAccessibleQuickWidget::childCount() const
++{
++    return m_accessibleWindow.childCount();
++}
++
++int QAccessibleQuickWidget::indexOfChild(const QAccessibleInterface *iface) const
++{
++    return m_accessibleWindow.indexOfChild(iface);
++}
++
++QAccessibleInterface *QAccessibleQuickWidget::childAt(int x, int y) const
++{
++    return m_accessibleWindow.childAt(x, y);
++}
++
++QAccessibleQuickWidgetOffscreenWindow::QAccessibleQuickWidgetOffscreenWindow(QQuickWindow *window)
++:QAccessibleQuickWindow(window)
++{
++
++}
++
++QAccessibleInterface *QAccessibleQuickWidgetOffscreenWindow::child(int index) const
++{
++    Q_UNUSED(index);
++    return nullptr;
++}
++
++int QAccessibleQuickWidgetOffscreenWindow::childCount() const
++{
++    return 0;
++}
++
++int QAccessibleQuickWidgetOffscreenWindow::indexOfChild(const QAccessibleInterface *iface) const
++{
++    Q_UNUSED(iface);
++    return -1;
++}
++
++QAccessibleInterface *QAccessibleQuickWidgetOffscreenWindow::QAccessibleQuickWidgetOffscreenWindow::childAt(int x, int y) const
++{
++    Q_UNUSED(x);
++    Q_UNUSED(y);
++    return nullptr;
++}
++
++#endif // accessibility
++
++QT_END_NAMESPACE
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h
+new file mode 100644
+index 0000000000..7c2ab930e0
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h
+@@ -0,0 +1,95 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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 QACCESSIBLEQUICKWIDGET_H
++#define QACCESSIBLEQUICKWIDGET_H
++
++//
++//  W A R N I N G
++//  -------------
++//
++// This file is not part of the Qt API.  It exists purely as an
++// implementation detail.  This header file may change from version to
++// version without notice, or even be removed.
++//
++// We mean it.
++//
++
++#include "qquickwidget.h"
++#include <QtWidgets/qaccessiblewidget.h>
++
++#include <private/qaccessiblequickview_p.h>
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++// These classes implement the QQuickWiget accessibility switcharoo,
++// where the child items of the QQuickWidgetOffscreenWindow are reported
++// as child accessible interfaces of the QAccessibleQuickWidget.
++class QAccessibleQuickWidget: public QAccessibleWidget
++{
++public:
++    QAccessibleQuickWidget(QQuickWidget* widget);
++
++    QAccessibleInterface *child(int index) const override;
++    int childCount() const override;
++    int indexOfChild(const QAccessibleInterface *iface) const override;
++    QAccessibleInterface *childAt(int x, int y) const override;
++
++private:
++    QAccessibleQuickWindow m_accessibleWindow;
++    Q_DISABLE_COPY(QAccessibleQuickWidget)
++};
++
++class QAccessibleQuickWidgetOffscreenWindow: public QAccessibleQuickWindow
++{
++public:
++    QAccessibleQuickWidgetOffscreenWindow(QQuickWindow *window);
++    QAccessibleInterface *child(int index) const override;
++    int childCount() const override;
++    int indexOfChild(const QAccessibleInterface *iface) const override;
++    QAccessibleInterface *childAt(int x, int y) const override;
++};
++
++#endif // accessibility
++
++QT_END_NAMESPACE
++
++#endif
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp
+new file mode 100644
+index 0000000000..7ba88a1769
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp
+@@ -0,0 +1,60 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include "qaccessiblequickwidgetfactory_p.h"
++#include "qaccessiblequickwidget_p.h"
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleInterface *qAccessibleQuickWidgetFactory(const QString &classname, QObject *object)
++{
++    if (classname == QLatin1String("QQuickWidget")) {
++        return new QAccessibleQuickWidget(qobject_cast<QQuickWidget *>(object));
++    } else if (classname == QLatin1String("QQuickWidgetOffscreenWindow")) {
++        return new QAccessibleQuickWidgetOffscreenWindow(qobject_cast<QQuickWindow *>(object));
++    }
++    return 0;
++}
++
++#endif // accessibility
++
++QT_END_NAMESPACE
++
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h
+new file mode 100644
+index 0000000000..8c63b09f81
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h
+@@ -0,0 +1,66 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include <QtGui/qaccessible.h>
++
++#ifndef QACCESSIBLEQUICKWIDGETFACTORY_H
++#define QACCESSIBLEQUICKWIDGETFACTORY_H
++
++//
++//  W A R N I N G
++//  -------------
++//
++// This file is not part of the Qt API.  It exists purely as an
++// implementation detail.  This header file may change from version to
++// version without notice, or even be removed.
++//
++// We mean it.
++//
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleInterface *qAccessibleQuickWidgetFactory(const QString &classname, QObject *object);
++
++#endif
++
++QT_END_NAMESPACE
++
++#endif
+diff --git a/qtdeclarative/src/quickwidgets/qquickwidget.cpp b/qtdeclarative/src/quickwidgets/qquickwidget.cpp
+index 39780f8de3..9c97b43518 100644
+--- a/qtdeclarative/src/quickwidgets/qquickwidget.cpp
++++ b/qtdeclarative/src/quickwidgets/qquickwidget.cpp
+@@ -39,6 +39,7 @@
+ 
+ #include "qquickwidget.h"
+ #include "qquickwidget_p.h"
++#include "qaccessiblequickwidgetfactory_p.h"
+ 
+ #include "private/qquickwindow_p.h"
+ #include "private/qquickitem_p.h"
+@@ -75,9 +76,16 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++QQuickWidgetOffscreenWindow::QQuickWidgetOffscreenWindow(QQuickWindowPrivate &dd, QQuickRenderControl *control)
++:QQuickWindow(dd, control)
++{
++    setTitle(QString::fromLatin1("Offscreen"));
++    setObjectName(QString::fromLatin1("QQuickOffScreenWindow"));
++}
++
+ // override setVisble to prevent accidental offscreen window being created
+ // by base class.
+-class QQuickOffcreenWindowPrivate: public QQuickWindowPrivate {
++class QQuickWidgetOffscreenWindowPrivate: public QQuickWindowPrivate {
+ public:
+     void setVisible(bool visible) override {
+         Q_Q(QWindow);
+@@ -105,9 +113,8 @@ void QQuickWidgetPrivate::init(QQmlEngine* e)
+     Q_Q(QQuickWidget);
+ 
+     renderControl = new QQuickWidgetRenderControl(q);
+-    offscreenWindow = new QQuickWindow(*new QQuickOffcreenWindowPrivate(),renderControl);
+-    offscreenWindow->setTitle(QString::fromLatin1("Offscreen"));
+-    offscreenWindow->setObjectName(QString::fromLatin1("QQuickOffScreenWindow"));
++    offscreenWindow = new QQuickWidgetOffscreenWindow(*new QQuickWidgetOffscreenWindowPrivate(), renderControl);
++    offscreenWindow->setScreen(q->screen());
+     // Do not call create() on offscreenWindow.
+ 
+     // Check if the Software Adaptation is being used
+@@ -138,6 +145,10 @@ void QQuickWidgetPrivate::init(QQmlEngine* e)
+     QWidget::connect(offscreenWindow, &QQuickWindow::focusObjectChanged, q, &QQuickWidget::propagateFocusObjectChanged);
+     QObject::connect(renderControl, SIGNAL(renderRequested()), q, SLOT(triggerUpdate()));
+     QObject::connect(renderControl, SIGNAL(sceneChanged()), q, SLOT(triggerUpdate()));
++
++#if QT_CONFIG(accessibility)
++    QAccessible::installFactory(&qAccessibleQuickWidgetFactory);
++#endif
+ }
+ 
+ void QQuickWidgetPrivate::ensureEngine() const
+@@ -901,9 +912,7 @@ void QQuickWidgetPrivate::createContext()
+ 
+         context = new QOpenGLContext;
+         context->setFormat(offscreenWindow->requestedFormat());
+-        const QWindow *win = q->window()->windowHandle();
+-        if (win && win->screen())
+-            context->setScreen(win->screen());
++        context->setScreen(q->screen());
+         QOpenGLContext *shareContext = qt_gl_global_share_context();
+         if (!shareContext)
+             shareContext = QWidgetPrivate::get(q->window())->shareContext();
+@@ -1520,19 +1529,16 @@ bool QQuickWidget::event(QEvent *e)
+         d->handleWindowChange();
+         break;
+ 
+-    case QEvent::ScreenChangeInternal:
+-        if (QWindow *window = this->window()->windowHandle()) {
+-            QScreen *newScreen = window->screen();
+-
+-            if (d->offscreenWindow)
+-                d->offscreenWindow->setScreen(newScreen);
+-            if (d->offscreenSurface)
+-                d->offscreenSurface->setScreen(newScreen);
++    case QEvent::ScreenChangeInternal: {
++        QScreen *newScreen = screen();
++        if (d->offscreenWindow)
++            d->offscreenWindow->setScreen(newScreen);
++        if (d->offscreenSurface)
++            d->offscreenSurface->setScreen(newScreen);
+ #if QT_CONFIG(opengl)
+-            if (d->context)
+-                d->context->setScreen(newScreen);
++        if (d->context)
++            d->context->setScreen(newScreen);
+ #endif
+-        }
+ 
+         if (d->useSoftwareRenderer
+ #if QT_CONFIG(opengl)
+@@ -1545,7 +1551,7 @@ bool QQuickWidget::event(QEvent *e)
+             d->render(true);
+         }
+         break;
+-
++    }
+     case QEvent::Show:
+     case QEvent::Move:
+         d->updatePosition();
+diff --git a/qtdeclarative/src/quickwidgets/qquickwidget_p.h b/qtdeclarative/src/quickwidgets/qquickwidget_p.h
+index 881f7f9220..1a946bcc71 100644
+--- a/qtdeclarative/src/quickwidgets/qquickwidget_p.h
++++ b/qtdeclarative/src/quickwidgets/qquickwidget_p.h
+@@ -148,6 +148,14 @@ public:
+     bool forceFullUpdate;
+ };
+ 
++class QQuickWidgetOffscreenWindow: public QQuickWindow
++{
++    Q_OBJECT
++
++public:
++    QQuickWidgetOffscreenWindow(QQuickWindowPrivate &dd, QQuickRenderControl *control);
++};
++
+ QT_END_NAMESPACE
+ 
+ #endif // QQuickWidget_P_H
+diff --git a/qtdeclarative/src/quickwidgets/quickwidgets.pro b/qtdeclarative/src/quickwidgets/quickwidgets.pro
+index 2438e577ae..85d156b8a3 100644
+--- a/qtdeclarative/src/quickwidgets/quickwidgets.pro
++++ b/qtdeclarative/src/quickwidgets/quickwidgets.pro
+@@ -7,9 +7,13 @@ DEFINES   += QT_NO_URL_CAST_FROM_STRING QT_NO_INTEGER_EVENT_COORDINATES QT_NO_FO
+ HEADERS += \
+     qquickwidget.h \
+     qquickwidget_p.h \
+-    qtquickwidgetsglobal.h
++    qtquickwidgetsglobal.h \
++    qaccessiblequickwidget_p.h \
++    qaccessiblequickwidgetfactory_p.h
+ 
+ SOURCES += \
+-    qquickwidget.cpp
++    qquickwidget.cpp \
++    qaccessiblequickwidget.cpp \
++    qaccessiblequickwidgetfactory.cpp
+ 
+ load(qt_module)
+diff --git a/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+index 3b7d74df63..b75bf820d5 100644
+--- a/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
++++ b/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+@@ -102,6 +102,7 @@ private slots:
+     void valueConversion_RegularExpression();
+     void castWithMultipleInheritance();
+     void collectGarbage();
++    void collectGarbageNestedWrappersTwoEngines();
+     void gcWithNestedDataStructure();
+     void stacktrace();
+     void numberParsing_data();
+@@ -1809,6 +1810,44 @@ void tst_QJSEngine::collectGarbage()
+     QVERIFY(ptr.isNull());
+ }
+ 
++class TestObjectContainer : public QObject
++{
++    Q_OBJECT
++    Q_PROPERTY(QObject *dummy MEMBER m_dummy CONSTANT)
++
++public:
++    TestObjectContainer() : m_dummy(new QObject(this)) {}
++
++private:
++    QObject *m_dummy;
++};
++
++void tst_QJSEngine::collectGarbageNestedWrappersTwoEngines()
++{
++    QJSEngine engine1;
++    QJSEngine engine2;
++
++    TestObjectContainer container;
++    QQmlEngine::setObjectOwnership(&container, QQmlEngine::CppOwnership);
++
++    engine1.globalObject().setProperty("foobar", engine1.newQObject(&container));
++    engine2.globalObject().setProperty("foobar", engine2.newQObject(&container));
++
++    engine1.evaluate("foobar.dummy.baz = 42");
++    engine2.evaluate("foobar.dummy.baz = 43");
++
++    QCOMPARE(engine1.evaluate("foobar.dummy.baz").toInt(), 42);
++    QCOMPARE(engine2.evaluate("foobar.dummy.baz").toInt(), 43);
++
++    engine1.collectGarbage();
++    engine2.collectGarbage();
++
++    // The GC should not collect dummy object wrappers neither in engine1 nor engine2, we
++    // verify that by checking whether the baz property still has its previous value.
++    QCOMPARE(engine1.evaluate("foobar.dummy.baz").toInt(), 42);
++    QCOMPARE(engine2.evaluate("foobar.dummy.baz").toInt(), 43);
++}
++
+ void tst_QJSEngine::gcWithNestedDataStructure()
+ {
+     // The GC must be able to traverse deeply nested objects, otherwise this
+diff --git a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml
+new file mode 100644
+index 0000000000..206133bb39
+--- /dev/null
++++ b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml
+@@ -0,0 +1,11 @@
++import QtQuick 2.8
++
++ListView {
++    id: root
++    width: 200
++    height: 200
++
++    delegate: Text {
++        text: display
++    }
++}
+diff --git a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
+index 35f1e2c94d..1722447830 100644
+--- a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
++++ b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
+@@ -27,6 +27,8 @@
+ ****************************************************************************/
+ 
+ #include <QtTest/qtest.h>
++#include <QtCore/QConcatenateTablesProxyModel>
++#include <QtGui/QStandardItemModel>
+ #include <QtQml/qqmlcomponent.h>
+ #include <QtQmlModels/private/qqmldelegatemodel_p.h>
+ #include <QtQuick/qquickview.h>
+@@ -47,6 +49,7 @@ private slots:
+     void filterOnGroup_removeWhenCompleted();
+     void qtbug_86017();
+     void contextAccessedByHandler();
++    void redrawUponColumnChange();
+ };
+ 
+ class AbstractItemModel : public QAbstractItemModel
+@@ -186,6 +189,30 @@ void tst_QQmlDelegateModel::contextAccessedByHandler()
+     QVERIFY(root->property("works").toBool());
+ }
+ 
++void tst_QQmlDelegateModel::redrawUponColumnChange()
++{
++    QStandardItemModel m1;
++    m1.appendRow({
++            new QStandardItem("Banana"),
++            new QStandardItem("Coconut"),
++    });
++
++    QQuickView view(testFileUrl("redrawUponColumnChange.qml"));
++    QCOMPARE(view.status(), QQuickView::Ready);
++    view.show();
++    QQuickItem *root = view.rootObject();
++    root->setProperty("model", QVariant::fromValue<QObject *>(&m1));
++
++    QObject *item = root->property("currentItem").value<QObject *>();
++    QVERIFY(item);
++    QCOMPARE(item->property("text").toString(), "Banana");
++
++    QVERIFY(root);
++    m1.removeColumn(0);
++
++    QCOMPARE(item->property("text").toString(), "Coconut");
++}
++
+ QTEST_MAIN(tst_QQmlDelegateModel)
+ 
+ #include "tst_qqmldelegatemodel.moc"
+diff --git a/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp b/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
+index 5d635aa63b..824fd89e5b 100644
+--- a/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
++++ b/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
+@@ -76,10 +76,10 @@ void tst_qv4mm::multiWrappedQObjects()
+         QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 1);
+         QCOMPARE(engine2.memoryManager->m_pendingFreedObjectWrapperValue.size(), 0);
+ 
+-        // Moves the additional WeakValue from m_multiplyWrappedQObjects to
+-        // m_pendingFreedObjectWrapperValue. It's still alive after all.
++        // The additional WeakValue from m_multiplyWrappedQObjects hasn't been moved
++        // to m_pendingFreedObjectWrapperValue yet. It's still alive after all.
+         engine1.memoryManager->runGC();
+-        QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 2);
++        QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 1);
+ 
+         // engine2 doesn't own the object as engine1 was the first to wrap it above.
+         // Therefore, no effect here.
+diff --git a/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml b/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml
+new file mode 100644
+index 0000000000..889e480f3b
+--- /dev/null
++++ b/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml
+@@ -0,0 +1,13 @@
++import QtQuick 2.6
++
++Item {
++    visible: true
++    Item {
++        visible: false
++        Item {
++            objectName: "hiddenChild"
++            activeFocusOnTab: true
++            focus: true
++        }
++    }
++}
+diff --git a/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp b/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+index c8f251dbe1..c8ef36ee68 100644
+--- a/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
++++ b/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+@@ -67,6 +67,7 @@ private slots:
+     void activeFocusOnTab10();
+     void activeFocusOnTab_infiniteLoop_data();
+     void activeFocusOnTab_infiniteLoop();
++    void activeFocusOnTab_infiniteLoopControls();
+ 
+     void nextItemInFocusChain();
+     void nextItemInFocusChain2();
+@@ -1057,6 +1058,17 @@ void tst_QQuickItem::activeFocusOnTab_infiniteLoop()
+     QCOMPARE(item, window->rootObject());
+ }
+ 
++
++void tst_QQuickItem::activeFocusOnTab_infiniteLoopControls()
++{
++    auto source = testFileUrl("activeFocusOnTab_infiniteLoop3.qml");
++    QScopedPointer<QQuickView>window(new QQuickView());
++    window->setSource(source);
++    window->show();
++    QVERIFY(window->errors().isEmpty());
++    QTest::keyClick(window.get(), Qt::Key_Tab); // should not hang
++}
++
+ void tst_QQuickItem::nextItemInFocusChain()
+ {
+     if (!qt_tab_all_widgets())
+Submodule qtdoc c0c7bf07...79d6ef69:
+Submodule qtimageformats 2dcf2899..abe44c0f:
+diff --git a/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp b/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
+index dde783c..1bf9074 100644
+--- a/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
+@@ -462,8 +462,12 @@ static bool parseIconEntryInfo(ICNSEntry &icon)
+     if (isIconCompressed(icon))
+         return true;
+     // Icon depth:
+-    if (!depth.isEmpty())
+-        icon.depth = ICNSEntry::Depth(depth.toUInt());
++    if (!depth.isEmpty()) {
++        const uint depthUInt = depth.toUInt();
++        if (depthUInt > 32)
++            return false;
++        icon.depth = ICNSEntry::Depth(depthUInt);
++    }
+     // Try mono if depth not found
+     if (icon.depth == ICNSEntry::DepthUnknown)
+         icon.depth = ICNSEntry::DepthMono;
+@@ -515,6 +519,9 @@ static bool parseIconEntryInfo(ICNSEntry &icon)
+         }
+         icon.height = icon.width;
+     }
++    // Sanity check
++    if (icon.width == 0 || icon.width > 4096)
++        return false;
+     return true;
+ }
+ 
+@@ -685,7 +692,7 @@ bool QICNSHandler::canRead() const
+ bool QICNSHandler::read(QImage *outImage)
+ {
+     QImage img;
+-    if (!ensureScanned()) {
++    if (!ensureScanned() || m_currentIconIndex >= m_icons.size()) {
+         qWarning("QICNSHandler::read(): The device wasn't parsed properly!");
+         return false;
+     }
+@@ -892,7 +899,7 @@ bool QICNSHandler::scanDevice()
+             return false;
+ 
+         const qint64 blockDataOffset = device()->pos();
+-        if (!isBlockHeaderValid(blockHeader)) {
++        if (!isBlockHeaderValid(blockHeader, ICNSBlockHeaderSize + filelength - blockDataOffset)) {
+             qWarning("QICNSHandler::scanDevice(): Failed, bad header at pos %s. OSType \"%s\", length %u",
+                      QByteArray::number(blockDataOffset).constData(),
+                      nameFromOSType(blockHeader.ostype).constData(), blockHeader.length);
+@@ -927,11 +934,14 @@ bool QICNSHandler::scanDevice()
+         case ICNSBlockHeader::TypeOdrp:
+             // Icns container seems to have an embedded icon variant container
+             // Let's start a scan for entries
+-            while (device()->pos() < nextBlockOffset) {
++            while (!stream.atEnd() && device()->pos() < nextBlockOffset) {
+                 ICNSBlockHeader icon;
+                 stream >> icon;
++                if (stream.status() != QDataStream::Ok)
++                    return false;
+                 // Check for incorrect variant entry header and stop scan
+-                if (!isBlockHeaderValid(icon, blockDataLength))
++                quint64 remaining = blockDataLength - (device()->pos() - blockDataOffset);
++                if (!isBlockHeaderValid(icon, ICNSBlockHeaderSize + remaining))
+                     break;
+                 if (!addEntry(icon, device()->pos(), blockHeader.ostype))
+                     return false;
+@@ -1003,7 +1013,7 @@ bool QICNSHandler::scanDevice()
+             break;
+         }
+     }
+-    return true;
++    return (m_icons.size() > 0);
+ }
+ 
+ const ICNSEntry &QICNSHandler::getIconMask(const ICNSEntry &icon) const
+diff --git a/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp b/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
+index 5082023..cb34374 100644
+--- a/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
++++ b/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
+@@ -43,6 +43,7 @@
+ #include "qimage.h"
+ #include "qvariant.h"
+ #include "qcolor.h"
++#include "qimagereader.h"
+ 
+ #include <jasper/jasper.h>
+ #include <math.h> // for pow
+@@ -333,16 +334,46 @@ private:
+ Jpeg2000JasperReader::Jpeg2000JasperReader(QIODevice *iod, SubFormat format)
+     : jasperOk(true), ioDevice(iod), format(format), hasAlpha(false)
+ {
++#if JAS_VERSION_MAJOR < 3
+     if (jas_init()) {
+         jasperOk = false;
+         qDebug("Jasper Library initialization failed");
+     }
++#else
++    jas_conf_clear();
++#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
++    jas_conf_set_max_mem_usage(QImageReader::allocationLimit() * 1024 * 1024);
++#else
++    // 128MB seems to be enough.
++    jas_conf_set_max_mem_usage(128 * 1024 * 1024);
++#endif
++    if (jas_init_library()) {
++        jasperOk = false;
++        qDebug("Jasper library initialization failed");
++    }
++    if (jas_init_thread()) {
++        jas_cleanup_library();
++        jasperOk = false;
++        qDebug("Jasper thread initialization failed");
++    }
++#endif
+ }
+ 
+ Jpeg2000JasperReader::~Jpeg2000JasperReader()
+ {
++#if JAS_VERSION_MAJOR < 3
+     if (jasperOk)
+         jas_cleanup();
++#else
++    if (jasperOk) {
++        if (jas_cleanup_thread()) {
++            qDebug("Jasper thread cleanup failed");
++        }
++        if (jas_cleanup_library()) {
++            qDebug("Jasper library cleanup failed");
++        }
++    }
++#endif
+ }
+ 
+ /*! \internal
+@@ -857,7 +888,7 @@ bool Jpeg2000JasperReader::write(const QImage &image, int quality)
+     }
+ 
+     // Open an empty jasper stream that grows automatically
+-    jas_stream_t * memory_stream = jas_stream_memopen(0, -1);
++    jas_stream_t * memory_stream = jas_stream_memopen(0, 0);
+ 
+     // Jasper wants a non-const string.
+     char *str = qstrdup(jasperFormatString.toLatin1().constData());
+diff --git a/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp b/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
+index 1386750..ac8956c 100644
+--- a/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
+@@ -361,6 +361,8 @@ bool QTiffHandler::read(QImage *image)
+     }
+ 
+     TIFF *const tiff = d->tiff;
++    if (TIFFIsTiled(tiff) && TIFFTileSize64(tiff) > uint64_t(image->sizeInBytes())) // Corrupt image
++        return false;
+     const quint32 width = d->size.width();
+     const quint32 height = d->size.height();
+ 
+diff --git a/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp b/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
+index 82d38cb..d02eb05 100644
+--- a/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
+@@ -45,6 +45,7 @@
+ #include <qdebug.h>
+ #include <qpainter.h>
+ #include <qvariant.h>
++#include <QtEndian>
+ 
+ static const int riffHeaderSize = 12; // RIFF_HEADER_SIZE from webp/format_constants.h
+ 
+@@ -102,21 +103,23 @@ bool QWebpHandler::ensureScanned() const
+ 
+     m_scanState = ScanError;
+ 
+-    if (device()->isSequential()) {
+-        qWarning() << "Sequential devices are not supported";
++    QWebpHandler *that = const_cast<QWebpHandler *>(this);
++    const int headerBytesNeeded = sizeof(WebPBitstreamFeatures);
++    QByteArray header = device()->peek(headerBytesNeeded);
++    if (header.size() < headerBytesNeeded)
+         return false;
+-    }
+ 
+-    qint64 oldPos = device()->pos();
+-    device()->seek(0);
+-
+-    QWebpHandler *that = const_cast<QWebpHandler *>(this);
+-    QByteArray header = device()->peek(sizeof(WebPBitstreamFeatures));
++    // We do no random access during decoding, just a readAll() of the whole image file. So if
++    // if it is all available already, we can accept a sequential device. The riff header contains
++    // the file size minus 8 bytes header
++    qint64 byteSize = qFromLittleEndian<quint32>(header.constData() + 4);
++    if (device()->isSequential() && device()->bytesAvailable() < byteSize + 8) {
++        qWarning() << "QWebpHandler: Insufficient data available in sequential device";
++        return false;
++    }
+     if (WebPGetFeatures((const uint8_t*)header.constData(), header.size(), &(that->m_features)) == VP8_STATUS_OK) {
+         if (m_features.has_animation) {
+             // For animation, we have to read and scan whole file to determine loop count and images count
+-            device()->seek(oldPos);
+-
+             if (that->ensureDemuxer()) {
+                 that->m_loop = WebPDemuxGetI(m_demuxer, WEBP_FF_LOOP_COUNT);
+                 that->m_frameCount = WebPDemuxGetI(m_demuxer, WEBP_FF_FRAME_COUNT);
+@@ -126,17 +129,13 @@ bool QWebpHandler::ensureScanned() const
+                 if (that->m_features.has_alpha)
+                     that->m_composited->fill(Qt::transparent);
+ 
+-                // We do not reset device position since we have read in all data
+                 m_scanState = ScanSuccess;
+-                return true;
+             }
+         } else {
+             m_scanState = ScanSuccess;
+         }
+     }
+ 
+-    device()->seek(oldPos);
+-
+     return m_scanState == ScanSuccess;
+ }
+ 
+@@ -159,7 +158,7 @@ bool QWebpHandler::ensureDemuxer()
+ 
+ bool QWebpHandler::read(QImage *image)
+ {
+-    if (!ensureScanned() || device()->isSequential() || !ensureDemuxer())
++    if (!ensureScanned() || !ensureDemuxer())
+         return false;
+ 
+     QRect prevFrameRect;
+Submodule qtlocation 98a5c511..f991e28c:
+diff --git a/qtlocation/src/location/configure.json b/qtlocation/src/location/configure.json
+index 6d01a9a3..d1e623a1 100644
+--- a/qtlocation/src/location/configure.json
++++ b/qtlocation/src/location/configure.json
+@@ -9,7 +9,7 @@
+             "label": "Qt.labs.location experimental QML plugin",
+             "purpose": "Provides experimental QtLocation QML types",
+             "section": "Location",
+-            "condition": "config.opengl",
++            "condition": "features.opengl",
+             "output": [ "privateFeature" ]
+         },
+         "geoservices_osm": {
+diff --git a/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp b/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
+index a978573d..11e1466f 100644
+--- a/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
++++ b/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
+@@ -158,7 +158,7 @@ void QGeoMapObjectQSGSupport::updateMapObjects(QSGNode *root, QQuickWindow *wind
+     if (!root)
+         return;
+ 
+-    if (m_mapObjectsRootNode && m_mapObjectsRootNode->parent())
++    if (m_mapObjectsRootNode && !m_mapObjectsRootNode->parent())
+         root->appendChildNode(m_mapObjectsRootNode.get());
+ 
+     if (!m_mapObjectsRootNode) {
+diff --git a/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
+index 5a40467e..d123c6a8 100644
+--- a/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
+@@ -59,8 +59,10 @@ QT_BEGIN_NAMESPACE
+ static const QString kPrefixEsri(QStringLiteral("esri."));
+ static const QString kParamUserAgent(kPrefixEsri + QStringLiteral("useragent"));
+ 
+-static const QString kUrlGeocode(QStringLiteral("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates"));
+-static const QString kUrlReverseGeocode(QStringLiteral("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode"));
++static const QString kUrlGeocode(QStringLiteral("https://geocode.arcgis.com/arcgis/rest/services/"
++                                                "World/GeocodeServer/findAddressCandidates"));
++static const QString kUrlReverseGeocode(QStringLiteral(
++        "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode"));
+ 
+ static QString addressToQuery(const QGeoAddress &address)
+ {
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
+index 17492d94..96c12b1b 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
+@@ -46,7 +46,8 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-// JSON reference: http://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
++// JSON reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
+ 
+ static const QString kErrorMessage(QStringLiteral("Error %1: %2."));
+ static const QString kErrorJson(QStringLiteral("Error: invalide JSON document."));
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
+index 8cadfb29..92b6bb13 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
+@@ -44,7 +44,8 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-// JSON reference: http://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
++// JSON reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
+ 
+ GeoRouteReplyEsri::GeoRouteReplyEsri(QNetworkReply *reply, const QGeoRouteRequest &request,
+                                      QObject *parent) :
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
+index 0e6bc2c7..ed613f4b 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
+@@ -48,7 +48,8 @@ static const QString kPrefixEsri(QStringLiteral("esri."));
+ static const QString kParamUserAgent(kPrefixEsri + QStringLiteral("useragent"));
+ static const QString kParamToken(kPrefixEsri + QStringLiteral("token"));
+ 
+-static const QString kUrlRouting(QStringLiteral("http://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve"));
++static const QString kUrlRouting(QStringLiteral(
++        "https://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve"));
+ 
+ GeoRoutingManagerEngineEsri::GeoRoutingManagerEngineEsri(const QVariantMap &parameters,
+                                                          QGeoServiceProvider::Error *error,
+@@ -70,7 +71,8 @@ GeoRoutingManagerEngineEsri::~GeoRoutingManagerEngineEsri()
+ {
+ }
+ 
+-// REST reference: http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
++// REST reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
+ 
+ QGeoRouteReply *GeoRoutingManagerEngineEsri::calculateRoute(const QGeoRouteRequest &request)
+ {
+@@ -125,7 +127,7 @@ void GeoRoutingManagerEngineEsri::replyError(QGeoRouteReply::Error errorCode, co
+ QString GeoRoutingManagerEngineEsri::preferedDirectionLangage()
+ {
+     // list of supported langages is defined in:
+-    // http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
++    // https://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
+     const QStringList supportedLanguages = {
+         "ar", // Generate directions in Arabic
+         "cs", // Generate directions in Czech
+diff --git a/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
+index 5d15835d..24148f95 100644
+--- a/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
+@@ -230,7 +230,8 @@ QGeoMap *GeoTiledMappingManagerEngineEsri::createMap()
+ // ${y} = Y
+ // ${token} = Token
+ 
+-// template = 'http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{{z}}/{{y}}/{{x}}.png'
++// template =
++// 'https://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{{z}}/{{y}}/{{x}}.png'
+ 
+ bool GeoTiledMappingManagerEngineEsri::initializeMapSources(QGeoServiceProvider::Error *error,
+                                                             QString *errorString,
+diff --git a/qtlocation/src/plugins/geoservices/esri/maps.json b/qtlocation/src/plugins/geoservices/esri/maps.json
+index 8167ae7d..862e087d 100644
+--- a/qtlocation/src/plugins/geoservices/esri/maps.json
++++ b/qtlocation/src/plugins/geoservices/esri/maps.json
+@@ -6,8 +6,8 @@
+             "description": "ArcGIS Online World Street Map",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=3b93337983e9436f8db950e38a8629af'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=3b93337983e9436f8db950e38a8629af'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -16,8 +16,8 @@
+             "": "ArcGIS Online World Imagery",
+             "mobile": true,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -26,8 +26,8 @@
+             "description": "ArcGIS Online World Terrain Base",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=c61ad8ab017d49e1a82f580ee1298931'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=c61ad8ab017d49e1a82f580ee1298931'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -36,8 +36,8 @@
+             "description": "ArcGIS Online World Topography",
+             "mobile": true,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=30e5fe3149c34df1ba922e6f5bbf808f'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=30e5fe3149c34df1ba922e6f5bbf808f'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -46,8 +46,8 @@
+             "description": "This map presents land cover and detailed topographic maps for the United States.",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=99cd5fbd98934028802b4f797c4b1732'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=99cd5fbd98934028802b4f797c4b1732'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -56,8 +56,8 @@
+             "description": "National Geographic World Map",
+             "mobile": false,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=b9b1b422198944fbbd5250b3241691b6'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=b9b1b422198944fbbd5250b3241691b6'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -66,8 +66,8 @@
+             "description": "Thematic content providing a neutral background with minimal colors",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=ed712cb1db3e4bae9e85329040fb9a49'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=ed712cb1db3e4bae9e85329040fb9a49'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -76,8 +76,8 @@
+             "description": "Natural Earth physical map for the world",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=c4ec722a1cd34cf0a23904aadf8923a0'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=c4ec722a1cd34cf0a23904aadf8923a0'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -86,8 +86,8 @@
+             "description": "Portrays surface elevation as shaded relief",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=9c5370d0b54f4de1b48a3792d7377ff2'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=9c5370d0b54f4de1b48a3792d7377ff2'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -96,8 +96,8 @@
+             "description": "This map is designed to be used as a basemap by marine GIS professionals and as a reference map by anyone interested in ocean data",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=1e126e7520f9466c9ca28b8f28b5e500'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=1e126e7520f9466c9ca28b8f28b5e500'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -106,8 +106,8 @@
+             "description": "Thematic content providing a neutral background with minimal colors",
+             "mobile": false,
+             "night": true,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=a284a9b99b3446a3910d4144a50990f6'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=a284a9b99b3446a3910d4144a50990f6'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -116,8 +116,8 @@
+             "description": "DeLorme’s topographic basemap is a seamless global data set that portrays transportation, hydrography, jurisdiction boundaries, and major geographic features",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/Specialty/DeLorme_World_Base_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=b165c3df453e4be6b5ac4fdb241effbe'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/Specialty/DeLorme_World_Base_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=b165c3df453e4be6b5ac4fdb241effbe'>Esri</a> contributors"
+         }
+     ]
+ }
+diff --git a/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
+index 3858ddf5..af66f28e 100644
+--- a/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
+@@ -63,8 +63,10 @@ static const QString kCountriesKey(QStringLiteral("detailedCountries"));
+ static const QString kLocalizedNamesKey(QStringLiteral("localizedNames"));
+ static const QString kMaxLocationsKey(QStringLiteral("maxLocations"));
+ 
+-static const QUrl kUrlGeocodeServer("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer?f=pjson");
+-static const QUrl kUrlFindAddressCandidates("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates");
++static const QUrl kUrlGeocodeServer(
++        "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer?f=pjson");
++static const QUrl kUrlFindAddressCandidates("https://geocode.arcgis.com/arcgis/rest/services/World/"
++                                            "GeocodeServer/findAddressCandidates");
+ 
+ PlaceManagerEngineEsri::PlaceManagerEngineEsri(const QVariantMap &parameters, QGeoServiceProvider::Error *error,
+                                                QString *errorString) :
+Submodule qtmultimedia f0344079..0d7cc33a:
+diff --git a/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp b/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
+index 2b5325132..b68b4af1b 100644
+--- a/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
++++ b/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
+@@ -402,6 +402,8 @@ int QPulseAudioInput::bytesReady() const
+ 
+ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ {
++    Q_ASSERT(data != nullptr || len == 0);
++
+     m_bytesAvailable = checkBytesReady();
+ 
+     setError(QAudio::NoError);
+@@ -411,7 +413,8 @@ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ 
+     if (!m_pullMode && !m_tempBuffer.isEmpty()) {
+         readBytes = qMin(static_cast<int>(len), m_tempBuffer.size());
+-        memcpy(data, m_tempBuffer.constData(), readBytes);
++        if (readBytes)
++            memcpy(data, m_tempBuffer.constData(), readBytes);
+         m_totalTimeValue += readBytes;
+ 
+         if (readBytes < m_tempBuffer.size()) {
+@@ -502,9 +505,10 @@ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ 
+ void QPulseAudioInput::applyVolume(const void *src, void *dest, int len)
+ {
++    Q_ASSERT((src && dest) || len == 0);
+     if (m_volume < 1.f)
+         QAudioHelperInternal::qMultiplySamples(m_volume, m_format, src, dest, len);
+-    else
++    else if (len)
+         memcpy(dest, src, len);
+ }
+ 
+Submodule qtpim 02efef5e...f9a8f0fc (commits not present)
+Submodule qtquick3d b85cf622..47defc8b:
+diff --git a/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro b/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
+index ca5c499e..174a075b 100644
+--- a/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
++++ b/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
+@@ -10,7 +10,7 @@ QT_FOR_CONFIG += assetimporters-private
+ include($$OUT_PWD/../qtassetimporters-config.pri)
+ 
+ qtConfig(system-assimp):!if(cross_compile:host_build) {
+-    QMAKE_USE_PRIVATE += assimp
++    QMAKE_USE_PRIVATE += quick3d-assimp
+ } else {
+     include(../../../3rdparty/assimp/assimp.pri)
+ }
+Submodule qtquickcontrols2 3a657dc0..56ce8233:
+diff --git a/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp b/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
+index e5fe734f7..e36922775 100644
+--- a/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
++++ b/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
+@@ -38,6 +38,7 @@
+ #include "qwidgetplatformmenuitem_p.h"
+ 
+ #include <QtGui/qwindow.h>
++#include <QtGui/private/qhighdpiscaling_p.h>
+ #include <QtWidgets/qmenu.h>
+ #include <QtWidgets/qaction.h>
+ 
+@@ -145,7 +146,7 @@ void QWidgetPlatformMenu::showPopup(const QWindow *window, const QRect &targetRe
+ 
+     QPoint targetPos = targetRect.bottomLeft();
+     if (window)
+-        targetPos = window->mapToGlobal(targetPos);
++        targetPos = window->mapToGlobal(QHighDpi::fromNativeLocalPosition(targetPos, window));
+ 
+     const QWidgetPlatformMenuItem *widgetItem = qobject_cast<const QWidgetPlatformMenuItem *>(item);
+     m_menu->popup(targetPos, widgetItem ? widgetItem->action() : nullptr);
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
+index 950e4e099..b81fbea0b 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
+@@ -387,6 +387,17 @@ void QQuickAbstractButtonPrivate::itemImplicitHeightChanged(QQuickItem *item)
+         emit q->implicitIndicatorHeightChanged();
+ }
+ 
++void QQuickAbstractButtonPrivate::itemDestroyed(QQuickItem *item)
++{
++    Q_Q(QQuickAbstractButton);
++    QQuickControlPrivate::itemDestroyed(item);
++    if (item == indicator) {
++        indicator = nullptr;
++        emit q->implicitIndicatorWidthChanged();
++        emit q->implicitIndicatorHeightChanged();
++    }
++}
++
+ QQuickAbstractButton *QQuickAbstractButtonPrivate::findCheckedButton() const
+ {
+     Q_Q(const QQuickAbstractButton);
+@@ -1176,6 +1187,12 @@ QAccessible::Role QQuickAbstractButton::accessibleRole() const
+     }
+     return QAccessible::Button;
+ }
++
++void QQuickAbstractButton::accessiblePressAction()
++{
++    Q_D(QQuickAbstractButton);
++    d->trigger();
++}
+ #endif
+ 
+ QT_END_NAMESPACE
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
+index 0fa48980e..ab66220d0 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
+@@ -209,6 +209,7 @@ protected:
+ #if QT_CONFIG(accessibility)
+     void accessibilityActiveChanged(bool active) override;
+     QAccessible::Role accessibleRole() const override;
++    Q_INVOKABLE void accessiblePressAction();
+ #endif
+ 
+ private:
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
+index 9291c1a87..b729720f2 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
+@@ -109,6 +109,7 @@ public:
+ 
+     void itemImplicitWidthChanged(QQuickItem *item) override;
+     void itemImplicitHeightChanged(QQuickItem *item) override;
++    void itemDestroyed(QQuickItem *item) override;
+ 
+     // copied from qabstractbutton.cpp
+     static const int AUTO_REPEAT_DELAY = 300;
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp b/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
+index 2041e7741..8610cdfae 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
+@@ -145,7 +145,7 @@ int QQuickActionPrivate::ShortcutEntry::shortcutId() const
+ 
+ void QQuickActionPrivate::ShortcutEntry::grab(const QKeySequence &shortcut, bool enabled)
+ {
+-    if (shortcut.isEmpty())
++    if (shortcut.isEmpty() || m_shortcutId)
+         return;
+ 
+     Qt::ShortcutContext context = Qt::WindowShortcut; // TODO
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp b/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
+index f38c2b09c..6eed2a024 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
+@@ -225,6 +225,7 @@ void QQuickContainerPrivate::cleanup()
+     QObject::disconnect(contentModel, &QQmlObjectModel::countChanged, q, &QQuickContainer::countChanged);
+     QObject::disconnect(contentModel, &QQmlObjectModel::childrenChanged, q, &QQuickContainer::contentChildrenChanged);
+     delete contentModel;
++    contentModel = nullptr;
+ }
+ 
+ QQuickItem *QQuickContainerPrivate::itemAt(int index) const
+@@ -436,7 +437,7 @@ void QQuickContainerPrivate::contentChildren_clear(QQmlListProperty<QQuickItem>
+ void QQuickContainerPrivate::updateContentWidth()
+ {
+     Q_Q(QQuickContainer);
+-    if (hasContentWidth || qFuzzyCompare(contentWidth, implicitContentWidth))
++    if (hasContentWidth || qFuzzyCompare(contentWidth, implicitContentWidth) || !contentModel)
+         return;
+ 
+     contentWidth = implicitContentWidth;
+@@ -446,7 +447,7 @@ void QQuickContainerPrivate::updateContentWidth()
+ void QQuickContainerPrivate::updateContentHeight()
+ {
+     Q_Q(QQuickContainer);
+-    if (hasContentHeight || qFuzzyCompare(contentHeight, implicitContentHeight))
++    if (hasContentHeight || qFuzzyCompare(contentHeight, implicitContentHeight) || !contentModel)
+         return;
+ 
+     contentHeight = implicitContentHeight;
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp b/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
+index bbbd0e622..1f4b47343 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
+@@ -845,6 +845,13 @@ void QQuickControlPrivate::executeBackground(bool complete)
+         quickCompleteDeferred(q, backgroundName(), background);
+ }
+ 
++/*
++    \internal
++
++    Hides an item that was replaced by a newer one, rather than
++    deleting it, as the item is typically created in QML and hence
++    we don't own it.
++*/
+ void QQuickControlPrivate::hideOldItem(QQuickItem *item)
+ {
+     if (!item)
+@@ -863,6 +870,29 @@ void QQuickControlPrivate::hideOldItem(QQuickItem *item)
+ #endif
+ }
+ 
++/*
++    \internal
++
++    Named "unhide" because it's used for cases where an item
++    that was previously hidden by \l hideOldItem() wants to be
++    shown by a control again, such as a ScrollBar in ScrollView.
++*/
++void QQuickControlPrivate::unhideOldItem(QQuickControl *control, QQuickItem *item)
++{
++    Q_ASSERT(item);
++    qCDebug(lcItemManagement) << "unhiding old item" << item;
++
++    item->setVisible(true);
++    item->setParentItem(control);
++
++#if QT_CONFIG(accessibility)
++    // Add the item back in to the accessibility tree.
++    QQuickAccessibleAttached *accessible = accessibleAttached(item);
++    if (accessible)
++        accessible->setIgnored(false);
++#endif
++}
++
+ void QQuickControlPrivate::updateBaselineOffset()
+ {
+     Q_Q(QQuickControl);
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h b/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
+index 8e979079e..a6e624c91 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
+@@ -173,6 +173,7 @@ public:
+     virtual void executeBackground(bool complete = false);
+ 
+     static void hideOldItem(QQuickItem *item);
++    static void unhideOldItem(QQuickControl *control, QQuickItem *item);
+ 
+     void updateBaselineOffset();
+ 
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp b/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
+index e6db14eb5..6197d1547 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
+@@ -237,7 +237,7 @@ static QRectF alignedRect(Qt::LayoutDirection direction, Qt::Alignment alignment
+ void QQuickDialogButtonBoxPrivate::resizeContent()
+ {
+     Q_Q(QQuickDialogButtonBox);
+-    if (!contentItem)
++    if (!contentItem || !contentModel)
+         return;
+ 
+     QRectF geometry = q->boundingRect().adjusted(q->leftPadding(), q->topPadding(), -q->rightPadding(), -q->bottomPadding());
+@@ -322,6 +322,9 @@ void QQuickDialogButtonBoxPrivate::updateLayout()
+ qreal QQuickDialogButtonBoxPrivate::getContentWidth() const
+ {
+     Q_Q(const QQuickDialogButtonBox);
++    if (!contentModel)
++        return 0;
++
+     const int count = contentModel->count();
+     const qreal totalSpacing = qMax(0, count - 1) * spacing;
+     qreal totalWidth = totalSpacing;
+@@ -341,6 +344,9 @@ qreal QQuickDialogButtonBoxPrivate::getContentWidth() const
+ qreal QQuickDialogButtonBoxPrivate::getContentHeight() const
+ {
+     Q_Q(const QQuickDialogButtonBox);
++    if (!contentModel)
++        return 0;
++
+     const int count = contentModel->count();
+     qreal maxHeight = 0;
+     for (int i = 0; i < count; ++i) {
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp b/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
+index 91bd59184..0ce518f84 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
+@@ -399,8 +399,11 @@ void QQuickOverlay::itemChange(ItemChange change, const ItemChangeData &data)
+     Q_D(QQuickOverlay);
+     QQuickItem::itemChange(change, data);
+ 
+-    if (change == ItemChildAddedChange || change == ItemChildRemovedChange)
++    if (change == ItemChildAddedChange || change == ItemChildRemovedChange) {
+         setVisible(!d->allDrawers.isEmpty() || !childItems().isEmpty());
++        if (data.item->parent() == d->mouseGrabberPopup)
++            d->setMouseGrabberPopup(nullptr);
++    }
+ }
+ 
+ void QQuickOverlay::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp b/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
+index 4e2f509db..1c4b308cd 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
+@@ -797,6 +797,14 @@ void QQuickScrollBarAttachedPrivate::initHorizontal()
+     if (parent && parent == flickable->parentItem())
+         horizontal->stackAfter(flickable);
+ 
++    // If a scroll bar was previously hidden (due to e.g. setting a new contentItem
++    // on a ScrollView), we need to make sure that we un-hide it.
++    // We don't bother checking if the item is actually the old one, because
++    // if it's not, all of the things the function does (setting parent, visibility, etc.)
++    // should be no-ops anyway.
++    if (auto control = qobject_cast<QQuickControl*>(q_ptr->parent()))
++        QQuickControlPrivate::unhideOldItem(control, horizontal);
++
+     layoutHorizontal();
+     horizontal->setSize(area->property("widthRatio").toReal());
+     horizontal->setPosition(area->property("xPosition").toReal());
+@@ -818,6 +826,9 @@ void QQuickScrollBarAttachedPrivate::initVertical()
+     if (parent && parent == flickable->parentItem())
+         vertical->stackAfter(flickable);
+ 
++    if (auto control = qobject_cast<QQuickControl*>(q_ptr->parent()))
++        QQuickControlPrivate::unhideOldItem(control, vertical);
++
+     layoutVertical();
+     vertical->setSize(area->property("heightRatio").toReal());
+     vertical->setPosition(area->property("yPosition").toReal());
+diff --git a/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml b/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
+index 0e8b08352..cd4931184 100644
+--- a/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
++++ b/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
+@@ -576,4 +576,51 @@ TestCase {
+         verify(newHorizontalScrollBar.visible)
+         verify(!oldHorizontalScrollBar.visible)
+     }
++
++    Component {
++        id: bindingToContentItemAndStandaloneFlickable
++
++        Item {
++            width: 200
++            height: 200
++
++            property alias scrollView: scrollView
++
++            ScrollView {
++                id: scrollView
++                anchors.fill: parent
++                contentItem: listView
++
++                property Item someBinding: contentItem
++            }
++            ListView {
++                id: listView
++                model: 10
++                delegate: ItemDelegate {
++                    text: modelData
++                    width: listView.width
++                }
++            }
++        }
++    }
++
++    // Tests that scroll bars show up for a ScrollView where
++    // - its contentItem is declared as a standalone, separate item
++    // - there is a binding to contentItem (which causes a default Flickable to be created)
++    function test_bindingToContentItemAndStandaloneFlickable() {
++        let root = createTemporaryObject(bindingToContentItemAndStandaloneFlickable, testCase)
++        verify(root)
++
++        let control = root.scrollView
++        let verticalScrollBar = control.ScrollBar.vertical
++        let horizontalScrollBar = control.ScrollBar.horizontal
++        compare(verticalScrollBar.parent, control)
++        compare(horizontalScrollBar.parent, control)
++        verify(verticalScrollBar.visible)
++        verify(horizontalScrollBar.visible)
++
++        mouseDrag(verticalScrollBar, verticalScrollBar.width / 2, verticalScrollBar.height / 2, 0, 50)
++        verify(verticalScrollBar.active)
++        verify(horizontalScrollBar.active)
++    }
+ }
+diff --git a/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml b/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
+index b3fab41ca..10b6baa02 100644
+--- a/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
++++ b/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
+@@ -608,4 +608,27 @@ TestCase {
+         mouseClick(control.indicator)
+         verify(control.activeFocus)
+     }
++
++    Component {
++        id: deletionOrder1
++        Item {
++            Image { id: innerImage }
++            Switch { indicator: innerImage }
++        }
++    }
++
++    Component {
++        id: deletionOrder2
++        Item {
++            Switch { indicator: innerImage }
++            Image { id: innerImage }
++        }
++    }
++
++    function test_deletionOrder() {
++        var control1 = createTemporaryObject(deletionOrder1, testCase)
++        verify(control1)
++        var control2 = createTemporaryObject(deletionOrder2, testCase)
++        verify(control2)
++    }
+ }
+diff --git a/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml b/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml
+new file mode 100644
+index 000000000..9e4598b9f
+--- /dev/null
++++ b/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml
+@@ -0,0 +1,78 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the test suite of the Qt Toolkit.
++**
++** $QT_BEGIN_LICENSE:BSD$
++** Commercial License Usage
++** Licensees holding valid commercial Qt licenses may use this file in
++** accordance with the commercial license agreement provided with the
++** Software or, alternatively, in accordance with the terms contained in
++** a written agreement between you and The Qt Company. For licensing terms
++** and conditions see https://www.qt.io/terms-conditions. For further
++** information use the contact form at https://www.qt.io/contact-us.
++**
++** BSD License Usage
++** Alternatively, you may use this file under the terms of the BSD license
++** as follows:
++**
++** "Redistribution and use in source and binary forms, with or without
++** modification, are permitted provided that the following conditions are
++** met:
++**   * Redistributions of source code must retain the above copyright
++**     notice, this list of conditions and the following disclaimer.
++**   * Redistributions in binary form must reproduce the above copyright
++**     notice, this list of conditions and the following disclaimer in
++**     the documentation and/or other materials provided with the
++**     distribution.
++**   * Neither the name of The Qt Company Ltd nor the names of its
++**     contributors may be used to endorse or promote products derived
++**     from this software without specific prior written permission.
++**
++**
++** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
++** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
++** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
++** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
++** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
++** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
++** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
++** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
++** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
++** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
++** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
++**
++** $QT_END_LICENSE$
++**
++****************************************************************************/
++
++import QtQuick 2.15
++import QtQuick.Controls 2.15
++
++ApplicationWindow {
++    id: window
++    width: 400
++    height: 400
++    title: "releaseAfterExitTransition"
++
++    property alias popup: popup
++    property alias modalPopup: modalPopup
++
++    Popup {
++        id: popup
++        y: parent.height - height
++        width: 50
++        height: 50
++    }
++
++    Popup {
++        id: modalPopup
++        modal: true
++        y: parent.height - height
++        width: 50
++        height: 50
++        exit:  Transition { PauseAnimation { duration: 100 } }
++    }
++}
+diff --git a/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp b/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
+index 54952d128..3d50e2dd4 100644
+--- a/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
++++ b/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
+@@ -100,6 +100,7 @@ private slots:
+     void invisibleToolTipOpen();
+     void centerInOverlayWithinStackViewItem();
+     void destroyDuringExitTransition();
++    void releaseAfterExitTransition();
+ };
+ 
+ void tst_QQuickPopup::initTestCase()
+@@ -1575,6 +1576,34 @@ void tst_QQuickPopup::destroyDuringExitTransition()
+     QVERIFY(!button->isDown());
+ }
+ 
++void tst_QQuickPopup::releaseAfterExitTransition()
++{
++    QQuickApplicationHelper helper(this, "releaseAfterExitTransition.qml");
++    QVERIFY2(helper.ready, helper.failureMessage());
++
++    QQuickWindow *window = helper.window;
++    window->show();
++    QVERIFY(QTest::qWaitForWindowActive(window));
++
++    QQuickOverlay *overlay = QQuickOverlay::overlay(window);
++    QQuickPopup *modalPopup = window->property("modalPopup").value<QQuickPopup *>();
++    QQuickPopup *popup = window->property("popup").value<QQuickPopup *>();
++
++    modalPopup->open();
++    QTRY_VERIFY(modalPopup->isOpened());
++
++    QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++    // wait until the transition is finished and the overlay hides itself
++    QTRY_VERIFY(!overlay->isVisible());
++    QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++
++    popup->open();
++    QTRY_VERIFY(popup->isOpened());
++    QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++    QTRY_VERIFY(!popup->isOpened());
++}
++
++
+ QTEST_QUICKCONTROLS_MAIN(tst_QQuickPopup)
+ 
+ #include "tst_qquickpopup.moc"
+Submodule qtscript 5be95f96...4d8e4bd2 (commits not present)
+Submodule qtspeech 17fc9fde..255845e2:
+diff --git a/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp b/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
+index 6eb74b8..bcc7dd1 100644
+--- a/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
++++ b/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
+@@ -357,7 +357,9 @@ QVector<QLocale> QTextToSpeechEngineSpeechd::availableLocales() const
+ 
+ QVector<QVoice> QTextToSpeechEngineSpeechd::availableVoices() const
+ {
+-    return m_voices.values(m_currentLocale.name()).toVector();
++    QList<QVoice> resultList = m_voices.values(m_currentLocale.name());
++    std::reverse(resultList.begin(), resultList.end());
++    return resultList.toVector();
+ }
+ 
+ // We have no way of knowing our own client_id since speech-dispatcher seems to be incomplete
+Submodule qtsvg 0c05780e..a7a0f249:
+diff --git a/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp b/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
+index 561e77e..12e0574 100644
+--- a/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
++++ b/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
+@@ -191,6 +191,8 @@ bool QSvgIOHandler::read(QImage *image)
+             }
+         }
+         if (!finalSize.isEmpty()) {
++            if (qMax(finalSize.width(), finalSize.height()) > 0xffff)
++                return false; // Assume corrupted file
+             image->fill(d->backColor.rgba());
+             QPainter p(image);
+             d->r.render(&p, bounds);
+diff --git a/qtsvg/src/svg/qsvghandler.cpp b/qtsvg/src/svg/qsvghandler.cpp
+index a5f877f..8dda563 100644
+--- a/qtsvg/src/svg/qsvghandler.cpp
++++ b/qtsvg/src/svg/qsvghandler.cpp
+@@ -1393,9 +1393,10 @@ static void parseFont(QSvgNode *node,
+         case FontSizeNone:
+             break;
+         case FontSizeValue: {
+-            QSvgHandler::LengthType dummy; // should always be pixel size
+-            fontStyle->setSize(qMin(parseLength(attributes.fontSize, dummy, handler),
+-                                    qreal(0xffff)));
++            QSvgHandler::LengthType type;
++            qreal fs = parseLength(attributes.fontSize, type, handler);
++            fs = convertToPixels(fs, true, type);
++            fontStyle->setSize(qMin(fs, qreal(0xffff)));
+         }
+             break;
+         default:
+@@ -2513,6 +2514,8 @@ static bool parseAnimateTransformNode(QSvgNode *parent,
+             ++s;
+         }
+     }
++    if (vals.count() % 3 != 0)
++        return false;
+ 
+     bool ok = true;
+     int begin = parseClockValue(beginStr, &ok);
+@@ -2576,6 +2579,8 @@ static QSvgNode *createCircleNode(QSvgNode *parent,
+     qreal ncx = toDouble(cx);
+     qreal ncy = toDouble(cy);
+     qreal nr  = toDouble(r);
++    if (nr < 0.0)
++        return nullptr;
+ 
+     QRectF rect(ncx-nr, ncy-nr, nr*2, nr*2);
+     QSvgNode *circle = new QSvgCircle(parent, rect);
+@@ -3046,15 +3051,16 @@ static QSvgStyleProperty *createRadialGradientNode(QSvgNode *node,
+ 
+     qreal ncx = 0.5;
+     qreal ncy = 0.5;
+-    qreal nr  = 0.5;
+     if (!cx.isEmpty())
+         ncx = toDouble(cx);
+     if (!cy.isEmpty())
+         ncy = toDouble(cy);
++
++    qreal nr = 0.0;
+     if (!r.isEmpty())
+         nr = toDouble(r);
+-    if (nr < 0.5)
+-        nr = 0.5;
++    if (nr <= 0.0)
++        return nullptr;
+ 
+     qreal nfx = ncx;
+     if (!fx.isEmpty())
+@@ -3350,7 +3356,9 @@ static QSvgNode *createTextNode(QSvgNode *parent,
+     //### editable and rotate not handled
+     QSvgHandler::LengthType type;
+     qreal nx = parseLength(x, type, handler);
++    nx = convertToPixels(nx, true, type);
+     qreal ny = parseLength(y, type, handler);
++    ny = convertToPixels(ny, true, type);
+ 
+     QSvgNode *text = new QSvgText(parent, QPointF(nx, ny));
+     return text;
+@@ -3691,9 +3699,7 @@ void QSvgHandler::parse()
+         case QXmlStreamReader::EndElement:
+             endElement(xml->name());
+             ++remainingUnfinishedElements;
+-            // if we are using somebody else's qxmlstreamreader
+-            // we should not read until the end of the stream
+-            done = !m_ownsReader && (xml->name() == QLatin1String("svg"));
++            done = (xml->name() == QLatin1String("svg"));
+             break;
+         case QXmlStreamReader::Characters:
+             characters(xml->text());
+diff --git a/qtsvg/src/svg/qsvgstructure.cpp b/qtsvg/src/svg/qsvgstructure.cpp
+index b89608b..89c9e4e 100644
+--- a/qtsvg/src/svg/qsvgstructure.cpp
++++ b/qtsvg/src/svg/qsvgstructure.cpp
+@@ -255,9 +255,13 @@ inline static bool isSupportedSvgFeature(const QString &str)
+     };
+ 
+     if (str.length() <= MAX_WORD_LENGTH && str.length() >= MIN_WORD_LENGTH) {
++        const char16_t unicode44 = str.at(44).unicode();
++        const char16_t unicode45 = str.at(45).unicode();
++        if (unicode44 >= sizeof(asso_values) || unicode45 >= sizeof(asso_values))
++            return false;
+         const int key = str.length()
+-                        + asso_values[str.at(45).unicode()]
+-                        + asso_values[str.at(44).unicode()];
++                        + asso_values[unicode45]
++                        + asso_values[unicode44];
+         if (key <= MAX_HASH_VALUE && key >= 0)
+             return str == QLatin1String(wordlist[key]);
+     }
+diff --git a/qtsvg/src/svg/qsvgtinydocument.cpp b/qtsvg/src/svg/qsvgtinydocument.cpp
+index 63d0797..19e7154 100644
+--- a/qtsvg/src/svg/qsvgtinydocument.cpp
++++ b/qtsvg/src/svg/qsvgtinydocument.cpp
+@@ -433,8 +433,16 @@ void QSvgTinyDocument::draw(QPainter *p, QSvgExtraStates &)
+     draw(p);
+ }
+ 
++static bool isValidMatrix(const QTransform &transform)
++{
++    qreal determinant = transform.determinant();
++    return qIsFinite(determinant);
++}
++
+ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect, const QRectF &sourceRect)
+ {
++    QTransform oldTransform = p->worldTransform();
++
+     QRectF target = targetRect;
+     if (target.isEmpty()) {
+         QPaintDevice *dev = p->device();
+@@ -487,6 +495,9 @@ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect,
+         }
+ #endif
+     }
++
++    if (!isValidMatrix(p->worldTransform()))
++        p->setWorldTransform(oldTransform);
+ }
+ 
+ QRectF QSvgTinyDocument::boundsOnElement(const QString &id) const
+diff --git a/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp b/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
+index 36c76ec..db71e02 100644
+--- a/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
++++ b/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
+@@ -86,6 +86,8 @@ private slots:
+     void oss_fuzz_23731();
+     void oss_fuzz_24131();
+     void oss_fuzz_24738();
++    void illegalAnimateTransform_data();
++    void illegalAnimateTransform();
+ 
+ #ifndef QT_NO_COMPRESS
+     void testGzLoading();
+@@ -1646,5 +1648,22 @@ void tst_QSvgRenderer::oss_fuzz_24738()
+     QSvgRenderer().load(QByteArray("<svg><path d=\"a 2 1e-212.....\">"));
+ }
+ 
++void tst_QSvgRenderer::illegalAnimateTransform_data()
++{
++    QTest::addColumn<QByteArray>("svg");
++
++    QTest::newRow("case1") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" values=\"8,0,5,0\">");
++    QTest::newRow("case2") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" values=\"1,2\">");
++    QTest::newRow("case3") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" from=\".. 5 2\" to=\"f\">");
++    QTest::newRow("case4") << QByteArray("<svg><animateTransform type=\"scale\" begin=\"1\" dur=\"2\" by=\"--,..\">");
++}
++
++void tst_QSvgRenderer::illegalAnimateTransform()
++{
++    QFETCH(QByteArray, svg);
++    QSvgRenderer renderer;
++    QVERIFY(!renderer.load(svg)); // also shouldn't assert
++}
++
+ QTEST_MAIN(tst_QSvgRenderer)
+ #include "tst_qsvgrenderer.moc"
+Submodule qttools 6914f7c8..090e526e:
+diff --git a/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp b/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
+index feab1e2d5..cbfb82507 100644
+--- a/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
++++ b/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
+@@ -445,7 +445,9 @@ bool HelpGeneratorPrivate::insertFiles(const QStringList &files, const QString &
+     if (filterSetId < 0)
+         return false;
+     ++filterSetId;
+-    for (int attId : qAsConst(filterAtts)) {
++    QList<int> attValues = filterAtts.values();
++    std::sort(attValues.begin(), attValues.end());
++    for (int attId : qAsConst(attValues)) {
+         m_query->prepare(QLatin1String("INSERT INTO FileAttributeSetTable "
+             "VALUES(?, ?)"));
+         m_query->bindValue(0, filterSetId);
+Submodule qtwayland dfb0129c..2904e1b3:
+diff --git a/qtwayland/src/client/configure.json b/qtwayland/src/client/configure.json
+index 2f424580..29222357 100644
+--- a/qtwayland/src/client/configure.json
++++ b/qtwayland/src/client/configure.json
+@@ -149,8 +149,7 @@
+                     "#endif"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "vulkan-server-buffer": {
+             "label": "Vulkan Buffer Sharing",
+@@ -168,7 +167,8 @@
+                     "exportAllocInfo.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR;",
+                     "return 0;"
+                 ]
+-            }
++            },
++            "use": "wayland-client"
+         },
+         "egl_1_5-wayland": {
+             "label": "EGL 1.5 with Wayland Platform",
+@@ -183,7 +183,7 @@
+                     "eglGetPlatformDisplay(EGL_PLATFORM_WAYLAND_EXT, (struct wl_display *)(nullptr), nullptr);"
+                 ]
+             },
+-            "use": "egl"
++            "use": "egl wayland-client"
+         }
+     },
+ 
+diff --git a/qtwayland/src/client/global/qwaylandclientextension.cpp b/qtwayland/src/client/global/qwaylandclientextension.cpp
+index 125b1e19..edccfe63 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension.cpp
++++ b/qtwayland/src/client/global/qwaylandclientextension.cpp
+@@ -74,7 +74,10 @@ void QWaylandClientExtensionPrivate::handleRegistryGlobal(void *data, ::wl_regis
+ void QWaylandClientExtension::addRegistryListener()
+ {
+     Q_D(QWaylandClientExtension);
+-    d->waylandIntegration->display()->addRegistryListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++    if (!d->registered) {
++        d->waylandIntegration->display()->addRegistryListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++        d->registered = true;
++    }
+ }
+ 
+ QWaylandClientExtension::QWaylandClientExtension(const int ver)
+@@ -88,6 +91,13 @@ QWaylandClientExtension::QWaylandClientExtension(const int ver)
+     QMetaObject::invokeMethod(this, "addRegistryListener", Qt::QueuedConnection);
+ }
+ 
++QWaylandClientExtension::~QWaylandClientExtension()
++{
++    Q_D(QWaylandClientExtension);
++    if (d->registered && !QCoreApplication::closingDown())
++        d->waylandIntegration->display()->removeListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++}
++
+ QtWaylandClient::QWaylandIntegration *QWaylandClientExtension::integration() const
+ {
+     Q_D(const QWaylandClientExtension);
+diff --git a/qtwayland/src/client/global/qwaylandclientextension.h b/qtwayland/src/client/global/qwaylandclientextension.h
+index 98272e57..5bd28398 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension.h
++++ b/qtwayland/src/client/global/qwaylandclientextension.h
+@@ -63,6 +63,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandClientExtension : public QObject
+     Q_PROPERTY(bool active READ isActive NOTIFY activeChanged)
+ public:
+     QWaylandClientExtension(const int version);
++    ~QWaylandClientExtension();
+ 
+     QtWaylandClient::QWaylandIntegration *integration() const;
+     int version() const;
+diff --git a/qtwayland/src/client/global/qwaylandclientextension_p.h b/qtwayland/src/client/global/qwaylandclientextension_p.h
+index 69cc46a0..9091efbe 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension_p.h
++++ b/qtwayland/src/client/global/qwaylandclientextension_p.h
+@@ -68,6 +68,7 @@ public:
+     QtWaylandClient::QWaylandIntegration *waylandIntegration = nullptr;
+     int version = -1;
+     bool active = false;
++    bool registered = false;
+ };
+ 
+ class Q_WAYLAND_CLIENT_EXPORT QWaylandClientExtensionTemplatePrivate : public QWaylandClientExtensionPrivate
+diff --git a/qtwayland/src/client/qwaylanddatadevice.cpp b/qtwayland/src/client/qwaylanddatadevice.cpp
+index 7e2e3308..e3e60ed5 100644
+--- a/qtwayland/src/client/qwaylanddatadevice.cpp
++++ b/qtwayland/src/client/qwaylanddatadevice.cpp
+@@ -72,6 +72,8 @@ QWaylandDataDevice::QWaylandDataDevice(QWaylandDataDeviceManager *manager, QWayl
+ 
+ QWaylandDataDevice::~QWaylandDataDevice()
+ {
++    if (wl_data_device_get_version(object()) >= WL_DATA_DEVICE_RELEASE_SINCE_VERSION)
++        release();
+ }
+ 
+ QWaylandDataOffer *QWaylandDataDevice::selectionOffer() const
+@@ -110,7 +112,7 @@ QWaylandDataOffer *QWaylandDataDevice::dragOffer() const
+     return m_dragOffer.data();
+ }
+ 
+-bool QWaylandDataDevice::startDrag(QMimeData *mimeData, QWaylandWindow *icon)
++bool QWaylandDataDevice::startDrag(QMimeData *mimeData, Qt::DropActions supportedActions, QWaylandWindow *icon)
+ {
+     auto *seat = m_display->currentInputDevice();
+     auto *origin = seat->pointerFocus();
+@@ -123,7 +125,28 @@ bool QWaylandDataDevice::startDrag(QMimeData *mimeData, QWaylandWindow *icon)
+     }
+ 
+     m_dragSource.reset(new QWaylandDataSource(m_display->dndSelectionHandler(), mimeData));
++
++    if (wl_data_device_get_version(object()) >= 3)
++        m_dragSource->set_actions(dropActionsToWl(supportedActions));
++
+     connect(m_dragSource.data(), &QWaylandDataSource::cancelled, this, &QWaylandDataDevice::dragSourceCancelled);
++    connect(m_dragSource.data(), &QWaylandDataSource::dndResponseUpdated, this, [this](bool accepted, Qt::DropAction action) {
++            auto drag = static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag());
++            // in old versions drop action is not set, so we guess
++            if (wl_data_source_get_version(m_dragSource->object()) < 3) {
++                drag->setResponse(accepted);
++            } else {
++                QPlatformDropQtResponse response(accepted, action);
++                drag->setResponse(response);
++            }
++    });
++    connect(m_dragSource.data(), &QWaylandDataSource::dndDropped, this, [](bool accepted, Qt::DropAction action) {
++        QPlatformDropQtResponse response(accepted, action);
++        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setDropResponse(response);
++    });
++    connect(m_dragSource.data(), &QWaylandDataSource::finished, this, []() {
++        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag();
++    });
+ 
+     start_drag(m_dragSource->object(), origin->wlSurface(), icon->wlSurface(), m_display->currentInputDevice()->serial());
+     return true;
+@@ -152,7 +175,7 @@ void QWaylandDataDevice::data_device_drop()
+         supportedActions = drag->supportedActions();
+     } else if (m_dragOffer) {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     } else {
+         return;
+     }
+@@ -162,7 +185,11 @@ void QWaylandDataDevice::data_device_drop()
+                                                                           QGuiApplication::keyboardModifiers());
+ 
+     if (drag) {
+-        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag(response);
++        auto drag =  static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag());
++        drag->setDropResponse(response);
++        drag->finishDrag();
++    } else if (m_dragOffer) {
++        m_dragOffer->finish();
+     }
+ }
+ 
+@@ -186,7 +213,7 @@ void QWaylandDataDevice::data_device_enter(uint32_t serial, wl_surface *surface,
+         supportedActions = drag->supportedActions();
+     } else if (m_dragOffer) {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     }
+ 
+     const QPlatformDragQtResponse &response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
+@@ -197,11 +224,7 @@ void QWaylandDataDevice::data_device_enter(uint32_t serial, wl_surface *surface,
+         static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setResponse(response);
+     }
+ 
+-    if (response.isAccepted()) {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, m_dragOffer->firstFormat().toUtf8().constData());
+-    } else {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, nullptr);
+-    }
++    sendResponse(supportedActions, response);
+ }
+ 
+ void QWaylandDataDevice::data_device_leave()
+@@ -235,10 +258,10 @@ void QWaylandDataDevice::data_device_motion(uint32_t time, wl_fixed_t x, wl_fixe
+         supportedActions = drag->supportedActions();
+     } else {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     }
+ 
+-    QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
++    const QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
+                                                                           QGuiApplication::mouseButtons(),
+                                                                           QGuiApplication::keyboardModifiers());
+ 
+@@ -246,11 +269,7 @@ void QWaylandDataDevice::data_device_motion(uint32_t time, wl_fixed_t x, wl_fixe
+         static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setResponse(response);
+     }
+ 
+-    if (response.isAccepted()) {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, m_dragOffer->firstFormat().toUtf8().constData());
+-    } else {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, nullptr);
+-    }
++    sendResponse(supportedActions, response);
+ }
+ #endif // QT_CONFIG(draganddrop)
+ 
+@@ -277,14 +296,10 @@ void QWaylandDataDevice::selectionSourceCancelled()
+ #if QT_CONFIG(draganddrop)
+ void QWaylandDataDevice::dragSourceCancelled()
+ {
++    static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag();
+     m_dragSource.reset();
+ }
+ 
+-void QWaylandDataDevice::dragSourceTargetChanged(const QString &mimeType)
+-{
+-    static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->updateTarget(mimeType);
+-}
+-
+ QPoint QWaylandDataDevice::calculateDragPosition(int x, int y, QWindow *wnd) const
+ {
+     QPoint pnt(wl_fixed_to_int(x), wl_fixed_to_int(y));
+@@ -297,6 +312,33 @@ QPoint QWaylandDataDevice::calculateDragPosition(int x, int y, QWindow *wnd) con
+     }
+     return pnt;
+ }
++
++void QWaylandDataDevice::sendResponse(Qt::DropActions supportedActions, const QPlatformDragQtResponse &response)
++{
++    if (response.isAccepted()) {
++        if (wl_data_device_get_version(object()) >= 3)
++            m_dragOffer->set_actions(dropActionsToWl(supportedActions), dropActionsToWl(response.acceptedAction()));
++
++        m_dragOffer->accept(m_enterSerial, m_dragOffer->firstFormat());
++    } else {
++        m_dragOffer->accept(m_enterSerial, QString());
++    }
++}
++
++int QWaylandDataDevice::dropActionsToWl(Qt::DropActions actions)
++{
++
++    int wlActions = WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE;
++    if (actions & Qt::CopyAction)
++        wlActions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY;
++    if (actions & (Qt::MoveAction | Qt::TargetMoveAction))
++        wlActions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE;
++
++    // wayland does not support LinkAction at the time of writing
++    return wlActions;
++}
++
++
+ #endif // QT_CONFIG(draganddrop)
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddatadevice_p.h b/qtwayland/src/client/qwaylanddatadevice_p.h
+index 16c3ad28..801dcc2c 100644
+--- a/qtwayland/src/client/qwaylanddatadevice_p.h
++++ b/qtwayland/src/client/qwaylanddatadevice_p.h
+@@ -64,6 +64,7 @@ QT_REQUIRE_CONFIG(wayland_datadevice);
+ QT_BEGIN_NAMESPACE
+ 
+ class QMimeData;
++class QPlatformDragQtResponse;
+ class QWindow;
+ 
+ namespace QtWaylandClient {
+@@ -89,7 +90,7 @@ public:
+ 
+ #if QT_CONFIG(draganddrop)
+     QWaylandDataOffer *dragOffer() const;
+-    bool startDrag(QMimeData *mimeData, QWaylandWindow *icon);
++    bool startDrag(QMimeData *mimeData, Qt::DropActions supportedActions, QWaylandWindow *icon);
+     void cancelDrag();
+ #endif
+ 
+@@ -109,13 +110,16 @@ private Q_SLOTS:
+ 
+ #if QT_CONFIG(draganddrop)
+     void dragSourceCancelled();
+-    void dragSourceTargetChanged(const QString &mimeType);
+ #endif
+ 
+ private:
+ #if QT_CONFIG(draganddrop)
+     QPoint calculateDragPosition(int x, int y, QWindow *wnd) const;
+ #endif
++    void sendResponse(Qt::DropActions supportedActions, const QPlatformDragQtResponse &response);
++
++    static int dropActionsToWl(Qt::DropActions dropActions);
++
+ 
+     QWaylandDisplay *m_display = nullptr;
+     QWaylandInputDevice *m_inputDevice = nullptr;
+diff --git a/qtwayland/src/client/qwaylanddatadevicemanager.cpp b/qtwayland/src/client/qwaylanddatadevicemanager.cpp
+index 35d67307..6dc4f77f 100644
+--- a/qtwayland/src/client/qwaylanddatadevicemanager.cpp
++++ b/qtwayland/src/client/qwaylanddatadevicemanager.cpp
+@@ -50,8 +50,8 @@ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
+-QWaylandDataDeviceManager::QWaylandDataDeviceManager(QWaylandDisplay *display, uint32_t id)
+-    : wl_data_device_manager(display->wl_registry(), id, 1)
++QWaylandDataDeviceManager::QWaylandDataDeviceManager(QWaylandDisplay *display, int version, uint32_t id)
++    : wl_data_device_manager(display->wl_registry(), id, qMin(version, 3))
+     , m_display(display)
+ {
+     // Create transfer devices for all input devices.
+diff --git a/qtwayland/src/client/qwaylanddatadevicemanager_p.h b/qtwayland/src/client/qwaylanddatadevicemanager_p.h
+index bd05c0fb..510d9be4 100644
+--- a/qtwayland/src/client/qwaylanddatadevicemanager_p.h
++++ b/qtwayland/src/client/qwaylanddatadevicemanager_p.h
+@@ -68,7 +68,7 @@ class QWaylandInputDevice;
+ class Q_WAYLAND_CLIENT_EXPORT QWaylandDataDeviceManager : public QtWayland::wl_data_device_manager
+ {
+ public:
+-    QWaylandDataDeviceManager(QWaylandDisplay *display, uint32_t id);
++    QWaylandDataDeviceManager(QWaylandDisplay *display, int version, uint32_t id);
+     ~QWaylandDataDeviceManager() override;
+ 
+     QWaylandDataDevice *getDataDevice(QWaylandInputDevice *inputDevice);
+diff --git a/qtwayland/src/client/qwaylanddataoffer.cpp b/qtwayland/src/client/qwaylanddataoffer.cpp
+index 2297e8a1..fe0ea8c9 100644
+--- a/qtwayland/src/client/qwaylanddataoffer.cpp
++++ b/qtwayland/src/client/qwaylanddataoffer.cpp
+@@ -82,6 +82,15 @@ QMimeData *QWaylandDataOffer::mimeData()
+     return m_mimeData.data();
+ }
+ 
++Qt::DropActions QWaylandDataOffer::supportedActions() const
++{
++    if (wl_data_offer_get_version(const_cast<::wl_data_offer*>(object())) < 3) {
++        return Qt::MoveAction | Qt::CopyAction;
++    }
++
++    return m_supportedActions;
++}
++
+ void QWaylandDataOffer::startReceiving(const QString &mimeType, int fd)
+ {
+     receive(mimeType, fd);
+@@ -93,6 +102,22 @@ void QWaylandDataOffer::data_offer_offer(const QString &mime_type)
+     m_mimeData->appendFormat(mime_type);
+ }
+ 
++void QWaylandDataOffer::data_offer_action(uint32_t dnd_action)
++{
++    Q_UNUSED(dnd_action);
++    // This is the compositor telling the drag target what action it should perform
++    // It does not map nicely into Qt final drop semantics, other than pretending there is only one supported action?
++}
++
++void QWaylandDataOffer::data_offer_source_actions(uint32_t source_actions)
++{
++    m_supportedActions = Qt::DropActions();
++    if (source_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
++        m_supportedActions |= Qt::MoveAction;
++    if (source_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
++        m_supportedActions |= Qt::CopyAction;
++}
++
+ QWaylandMimeData::QWaylandMimeData(QWaylandAbstractDataOffer *dataOffer)
+     : m_dataOffer(dataOffer)
+ {
+@@ -163,17 +188,18 @@ QVariant QWaylandMimeData::retrieveData_sys(const QString &mimeType, QVariant::T
+ 
+ int QWaylandMimeData::readData(int fd, QByteArray &data) const
+ {
+-    fd_set readset;
+-    FD_ZERO(&readset);
+-    FD_SET(fd, &readset);
+-    struct timeval timeout;
++    struct pollfd readset;
++    readset.fd = fd;
++    readset.events = POLLIN;
++    struct timespec timeout;
+     timeout.tv_sec = 1;
+-    timeout.tv_usec = 0;
++    timeout.tv_nsec = 0;
++
+ 
+     Q_FOREVER {
+-        int ready = select(FD_SETSIZE, &readset, nullptr, nullptr, &timeout);
++        int ready = qt_safe_poll(&readset, 1, &timeout);
+         if (ready < 0) {
+-            qWarning() << "QWaylandDataOffer: select() failed";
++            qWarning() << "QWaylandDataOffer: qt_safe_poll() failed";
+             return -1;
+         } else if (ready == 0) {
+             qWarning("QWaylandDataOffer: timeout reading from pipe");
+diff --git a/qtwayland/src/client/qwaylanddataoffer_p.h b/qtwayland/src/client/qwaylanddataoffer_p.h
+index 9cf1483c..6f667398 100644
+--- a/qtwayland/src/client/qwaylanddataoffer_p.h
++++ b/qtwayland/src/client/qwaylanddataoffer_p.h
+@@ -82,6 +82,7 @@ public:
+     explicit QWaylandDataOffer(QWaylandDisplay *display, struct ::wl_data_offer *offer);
+     ~QWaylandDataOffer() override;
+     QMimeData *mimeData() override;
++    Qt::DropActions supportedActions() const;
+ 
+     QString firstFormat() const;
+ 
+@@ -89,10 +90,13 @@ public:
+ 
+ protected:
+     void data_offer_offer(const QString &mime_type) override;
++    void data_offer_source_actions(uint32_t source_actions) override;
++    void data_offer_action(uint32_t dnd_action) override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+     QScopedPointer<QWaylandMimeData> m_mimeData;
++    Qt::DropActions m_supportedActions;
+ };
+ 
+ 
+diff --git a/qtwayland/src/client/qwaylanddatasource.cpp b/qtwayland/src/client/qwaylanddatasource.cpp
+index f45122fb..5599cbd4 100644
+--- a/qtwayland/src/client/qwaylanddatasource.cpp
++++ b/qtwayland/src/client/qwaylanddatasource.cpp
+@@ -101,7 +101,32 @@ void QWaylandDataSource::data_source_send(const QString &mime_type, int32_t fd)
+ 
+ void QWaylandDataSource::data_source_target(const QString &mime_type)
+ {
+-    Q_EMIT targetChanged(mime_type);
++    m_accepted = !mime_type.isEmpty();
++    Q_EMIT dndResponseUpdated(m_accepted, m_dropAction);
++}
++
++void QWaylandDataSource::data_source_action(uint32_t action)
++{
++    Qt::DropAction qtAction = Qt::IgnoreAction;
++
++    if (action == WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
++        qtAction = Qt::MoveAction;
++    else if (action == WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
++        qtAction = Qt::CopyAction;
++
++    m_dropAction = qtAction;
++    Q_EMIT dndResponseUpdated(m_accepted, m_dropAction);
++}
++
++void QWaylandDataSource::data_source_dnd_finished()
++{
++    Q_EMIT finished();
++}
++
++void QWaylandDataSource::data_source_dnd_drop_performed()
++{
++
++    Q_EMIT dndDropped(m_accepted, m_dropAction);
+ }
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddatasource_p.h b/qtwayland/src/client/qwaylanddatasource_p.h
+index 25afff79..96f07bc3 100644
+--- a/qtwayland/src/client/qwaylanddatasource_p.h
++++ b/qtwayland/src/client/qwaylanddatasource_p.h
+@@ -77,17 +77,25 @@ public:
+     QMimeData *mimeData() const;
+ 
+ Q_SIGNALS:
+-    void targetChanged(const QString &mime_type);
+     void cancelled();
++    void finished();
++
++    void dndResponseUpdated(bool accepted, Qt::DropAction action);
++    void dndDropped(bool accepted, Qt::DropAction action);
+ 
+ protected:
+     void data_source_cancelled() override;
+     void data_source_send(const QString &mime_type, int32_t fd) override;
+     void data_source_target(const QString &mime_type) override;
++    void data_source_dnd_drop_performed() override;
++    void data_source_dnd_finished() override;
++    void data_source_action(uint32_t action) override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+     QMimeData *m_mime_data = nullptr;
++    bool m_accepted = false;
++    Qt::DropAction m_dropAction = Qt::IgnoreAction;
+ };
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddisplay.cpp b/qtwayland/src/client/qwaylanddisplay.cpp
+index f10c1f79..c01e238b 100644
+--- a/qtwayland/src/client/qwaylanddisplay.cpp
++++ b/qtwayland/src/client/qwaylanddisplay.cpp
+@@ -85,10 +85,203 @@
+ 
+ #include <errno.h>
+ 
++#include <tuple> // for std::tie
++
++static void checkWaylandError(struct wl_display *display)
++{
++    int ecode = wl_display_get_error(display);
++    if ((ecode == EPIPE || ecode == ECONNRESET)) {
++        // special case this to provide a nicer error
++        qWarning("The Wayland connection broke. Did the Wayland compositor die?");
++    } else {
++        qWarning("The Wayland connection experienced a fatal error: %s", strerror(ecode));
++    }
++    _exit(1);
++}
++
+ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
++class EventThread : public QThread
++{
++    Q_OBJECT
++public:
++    enum OperatingMode {
++        EmitToDispatch, // Emit the signal, allow dispatching in a differnt thread.
++        SelfDispatch, // Dispatch the events inside this thread.
++    };
++
++    EventThread(struct wl_display * wl, struct wl_event_queue * ev_queue,
++                OperatingMode mode)
++        : m_fd(wl_display_get_fd(wl))
++        , m_pipefd{ -1, -1 }
++        , m_wldisplay(wl)
++        , m_wlevqueue(ev_queue)
++        , m_mode(mode)
++        , m_reading(true)
++        , m_quitting(false)
++    {
++        setObjectName(QStringLiteral("WaylandEventThread"));
++    }
++
++    void readAndDispatchEvents()
++    {
++        /*
++         * Dispatch pending events and flush the requests at least once. If the event thread
++         * is not reading, try to call _prepare_read() to allow the event thread to poll().
++         * If that fails, re-try dispatch & flush again until _prepare_read() is successful.
++         *
++         * This allow any call to readAndDispatchEvents() to start event thread's polling,
++         * not only the one issued from event thread's waitForReading(), which means functions
++         * called from dispatch_pending() can safely spin an event loop.
++         */
++        for (;;) {
++            if (dispatchQueuePending() < 0) {
++                checkWaylandError(m_wldisplay);
++                return;
++            }
++
++            wl_display_flush(m_wldisplay);
++
++            // We have to check if event thread is reading every time we dispatch
++            // something, as that may recursively call this function.
++            if (m_reading.loadAcquire())
++                break;
++
++            if (prepareReadQueue() == 0) {
++                QMutexLocker l(&m_mutex);
++                m_reading.storeRelease(true);
++                m_cond.wakeOne();
++                break;
++            }
++        }
++    }
++
++    void stop()
++    {
++        // We have to both write to the pipe and set the flag, as the thread may be
++        // either in the poll() or waiting for _prepare_read().
++        if (m_pipefd[1] != -1 && write(m_pipefd[1], "\0", 1) == -1)
++            qWarning("Failed to write to the pipe: %s.", strerror(errno));
++
++        {
++            QMutexLocker l(&m_mutex);
++            m_quitting = true;
++            m_cond.wakeOne();
++        }
++
++        wait();
++    }
++
++Q_SIGNALS:
++    void needReadAndDispatch();
++
++protected:
++    void run() override
++    {
++        // we use this pipe to make the loop exit otherwise if we simply used a flag on the loop condition, if stop() gets
++        // called while poll() is blocking the thread will never quit since there are no wayland messages coming anymore.
++        struct Pipe
++        {
++            Pipe(int *fds)
++                : fds(fds)
++            {
++                if (qt_safe_pipe(fds) != 0)
++                    qWarning("Pipe creation failed. Quitting may hang.");
++            }
++            ~Pipe()
++            {
++                if (fds[0] != -1) {
++                    close(fds[0]);
++                    close(fds[1]);
++                }
++            }
++
++            int *fds;
++        } pipe(m_pipefd);
++
++        // Make the main thread call wl_prepare_read(), dispatch the pending messages and flush the
++        // outbound ones. Wait until it's done before proceeding, unless we're told to quit.
++        while (waitForReading()) {
++            pollfd fds[2] = { { m_fd, POLLIN, 0 }, { m_pipefd[0], POLLIN, 0 } };
++            poll(fds, 2, -1);
++
++            if (fds[1].revents & POLLIN) {
++                // we don't really care to read the byte that was written here since we're closing down
++                wl_display_cancel_read(m_wldisplay);
++                break;
++            }
++
++            if (fds[0].revents & POLLIN)
++                wl_display_read_events(m_wldisplay);
++                // The polll was succesfull and the event thread did the wl_display_read_events(). On the next iteration of the loop
++                // the event sent to the main thread will cause it to dispatch the messages just read, unless the loop exits in which
++                // case we don't care anymore about them.
++            else
++                wl_display_cancel_read(m_wldisplay);
++        }
++    }
++
++private:
++    bool waitForReading()
++    {
++        Q_ASSERT(QThread::currentThread() == this);
++
++        m_reading.storeRelease(false);
++
++        if (m_mode == SelfDispatch) {
++            readAndDispatchEvents();
++        } else {
++            Q_EMIT needReadAndDispatch();
++
++            QMutexLocker lock(&m_mutex);
++            // m_reading might be set from our emit or some other invocation of
++            // readAndDispatchEvents().
++            while (!m_reading.loadRelaxed() && !m_quitting)
++                m_cond.wait(&m_mutex);
++        }
++
++        return !m_quitting;
++    }
++
++    int dispatchQueuePending()
++    {
++        if (m_wlevqueue)
++            return wl_display_dispatch_queue_pending(m_wldisplay, m_wlevqueue);
++        else
++            return wl_display_dispatch_pending(m_wldisplay);
++    }
++
++    int prepareReadQueue()
++    {
++        if (m_wlevqueue)
++            return wl_display_prepare_read_queue(m_wldisplay, m_wlevqueue);
++        else
++            return wl_display_prepare_read(m_wldisplay);
++    }
++
++    int m_fd;
++    int m_pipefd[2];
++    wl_display *m_wldisplay;
++    wl_event_queue *m_wlevqueue;
++    OperatingMode m_mode;
++
++    /* Concurrency note when operating in EmitToDispatch mode:
++     * m_reading is set to false inside event thread's waitForReading(), and is
++     * set to true inside main thread's readAndDispatchEvents().
++     * The lock is not taken when setting m_reading to false, as the main thread
++     * is not actively waiting for it to turn false. However, the lock is taken
++     * inside readAndDispatchEvents() before setting m_reading to true,
++     * as the event thread is actively waiting for it under the wait condition.
++     */
++
++    QAtomicInteger<bool> m_reading;
++    bool m_quitting;
++    QMutex m_mutex;
++    QWaitCondition m_cond;
++};
++
+ Q_LOGGING_CATEGORY(lcQpaWayland, "qt.qpa.wayland"); // for general (uncategorized) Wayland platform logging
+ 
+ struct wl_surface *QWaylandDisplay::createSurface(void *handle)
+@@ -158,17 +351,16 @@ QWaylandDisplay::QWaylandDisplay(QWaylandIntegration *waylandIntegration)
+     if (!mXkbContext)
+         qCWarning(lcQpaWayland, "failed to create xkb context");
+ #endif
+-
+-    forceRoundTrip();
+-
+-    if (!mWaitingScreens.isEmpty()) {
+-        // Give wl_output.done and zxdg_output_v1.done events a chance to arrive
+-        forceRoundTrip();
+-    }
+ }
+ 
+ QWaylandDisplay::~QWaylandDisplay(void)
+ {
++    if (m_eventThread)
++        m_eventThread->stop();
++
++    if (m_frameEventQueueThread)
++        m_frameEventQueueThread->stop();
++
+     if (mSyncCallback)
+         wl_callback_destroy(mSyncCallback);
+ 
+@@ -187,6 +379,21 @@ QWaylandDisplay::~QWaylandDisplay(void)
+ #endif
+     if (mDisplay)
+         wl_display_disconnect(mDisplay);
++
++    if (m_frameEventQueue)
++        wl_event_queue_destroy(m_frameEventQueue);
++}
++
++// Steps which is called just after constructor. This separates registry_global() out of the constructor
++// so that factory functions in integration can be overridden.
++void QWaylandDisplay::initialize()
++{
++    forceRoundTrip();
++
++    if (!mWaitingScreens.isEmpty()) {
++        // Give wl_output.done and zxdg_output_v1.done events a chance to arrive
++        forceRoundTrip();
++    }
+ }
+ 
+ void QWaylandDisplay::ensureScreen()
+@@ -203,98 +410,37 @@ void QWaylandDisplay::ensureScreen()
+ 
+ void QWaylandDisplay::checkError() const
+ {
+-    int ecode = wl_display_get_error(mDisplay);
+-    if ((ecode == EPIPE || ecode == ECONNRESET)) {
+-        // special case this to provide a nicer error
+-        qWarning("The Wayland connection broke. Did the Wayland compositor die?");
+-    } else {
+-        qWarning("The Wayland connection experienced a fatal error: %s", strerror(ecode));
+-    }
+-    _exit(1);
++    checkWaylandError(mDisplay);
+ }
+ 
++// Called in main thread, either from queued signal or directly.
+ void QWaylandDisplay::flushRequests()
+ {
+-    if (wl_display_prepare_read(mDisplay) == 0) {
+-        wl_display_read_events(mDisplay);
+-    }
+-
+-    if (wl_display_dispatch_pending(mDisplay) < 0)
+-        checkError();
+-
+-    {
+-        QReadLocker locker(&m_frameQueueLock);
+-        for (const FrameQueue &q : mExternalQueues) {
+-            QMutexLocker locker(q.mutex);
+-            while (wl_display_prepare_read_queue(mDisplay, q.queue) != 0)
+-                wl_display_dispatch_queue_pending(mDisplay, q.queue);
+-            wl_display_read_events(mDisplay);
+-            wl_display_dispatch_queue_pending(mDisplay, q.queue);
+-        }
+-    }
+-
+-    wl_display_flush(mDisplay);
+-}
+-
+-void QWaylandDisplay::blockingReadEvents()
+-{
+-    if (wl_display_dispatch(mDisplay) < 0)
+-        checkError();
+-}
+-
+-void QWaylandDisplay::destroyFrameQueue(const QWaylandDisplay::FrameQueue &q)
+-{
+-    QWriteLocker locker(&m_frameQueueLock);
+-    auto it = std::find_if(mExternalQueues.begin(),
+-                           mExternalQueues.end(),
+-                           [&q] (const QWaylandDisplay::FrameQueue &other){ return other.queue == q.queue; });
+-    Q_ASSERT(it != mExternalQueues.end());
+-    mExternalQueues.erase(it);
+-    if (q.queue != nullptr)
+-        wl_event_queue_destroy(q.queue);
+-    delete q.mutex;
++    m_eventThread->readAndDispatchEvents();
+ }
+ 
+-QWaylandDisplay::FrameQueue QWaylandDisplay::createFrameQueue()
++// We have to wait until we have an eventDispatcher before creating the eventThread,
++// otherwise forceRoundTrip() may block inside _events_read() because eventThread is
++// polling.
++void QWaylandDisplay::initEventThread()
+ {
+-    QWriteLocker locker(&m_frameQueueLock);
+-    FrameQueue q{createEventQueue()};
+-    mExternalQueues.append(q);
+-    return q;
+-}
++    m_eventThread.reset(
++            new EventThread(mDisplay, /* default queue */ nullptr, EventThread::EmitToDispatch));
++    connect(m_eventThread.get(), &EventThread::needReadAndDispatch, this,
++            &QWaylandDisplay::flushRequests, Qt::QueuedConnection);
++    m_eventThread->start();
+ 
+-wl_event_queue *QWaylandDisplay::createEventQueue()
+-{
+-    return wl_display_create_queue(mDisplay);
++    // wl_display_disconnect() free this.
++    m_frameEventQueue = wl_display_create_queue(mDisplay);
++    m_frameEventQueueThread.reset(
++            new EventThread(mDisplay, m_frameEventQueue, EventThread::SelfDispatch));
++    m_frameEventQueueThread->start();
+ }
+ 
+-void QWaylandDisplay::dispatchQueueWhile(wl_event_queue *queue, std::function<bool ()> condition, int timeout)
++void QWaylandDisplay::blockingReadEvents()
+ {
+-    if (!condition())
+-        return;
+-
+-    QElapsedTimer timer;
+-    timer.start();
+-    struct pollfd pFd = qt_make_pollfd(wl_display_get_fd(mDisplay), POLLIN);
+-    while (timeout == -1 || timer.elapsed() < timeout) {
+-        while (wl_display_prepare_read_queue(mDisplay, queue) != 0)
+-            wl_display_dispatch_queue_pending(mDisplay, queue);
+-
+-        wl_display_flush(mDisplay);
+-
+-        const int remaining = qMax(timeout - timer.elapsed(), 0ll);
+-        const int pollTimeout = timeout == -1 ? -1 : remaining;
+-        if (qt_poll_msecs(&pFd, 1, pollTimeout) > 0)
+-            wl_display_read_events(mDisplay);
+-        else
+-            wl_display_cancel_read(mDisplay);
+-
+-        if (wl_display_dispatch_queue_pending(mDisplay, queue) < 0)
+-            checkError();
+-
+-        if (!condition())
+-            break;
+-    }
++    if (wl_display_dispatch(mDisplay) < 0)
++        checkWaylandError(mDisplay);
+ }
+ 
+ QWaylandScreen *QWaylandDisplay::screenForOutput(struct wl_output *output) const
+@@ -345,7 +491,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+     if (interface == QStringLiteral("wl_output")) {
+         mWaitingScreens << new QWaylandScreen(this, version, id);
+     } else if (interface == QStringLiteral("wl_compositor")) {
+-        mCompositorVersion = qMin((int)version, 3);
++        mCompositorVersion = qMin((int)version, 4);
+         mCompositor.init(registry, id, mCompositorVersion);
+     } else if (interface == QStringLiteral("wl_shm")) {
+         mShm.reset(new QWaylandShm(this, version, id));
+@@ -354,7 +500,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+         mInputDevices.append(inputDevice);
+ #if QT_CONFIG(wayland_datadevice)
+     } else if (interface == QStringLiteral("wl_data_device_manager")) {
+-        mDndSelectionHandler.reset(new QWaylandDataDeviceManager(this, id));
++        mDndSelectionHandler.reset(new QWaylandDataDeviceManager(this, version, id));
+ #endif
+     } else if (interface == QStringLiteral("qt_surface_extension")) {
+         mWindowExtension.reset(new QtWayland::qt_surface_extension(registry, id, 1));
+@@ -369,6 +515,8 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+ #if QT_CONFIG(wayland_client_primary_selection)
+     } else if (interface == QStringLiteral("zwp_primary_selection_device_manager_v1")) {
+         mPrimarySelectionManager.reset(new QWaylandPrimarySelectionDeviceManagerV1(this, id, 1));
++        for (QWaylandInputDevice *inputDevice : qAsConst(mInputDevices))
++            inputDevice->setPrimarySelectionDevice(mPrimarySelectionManager->createDevice(inputDevice));
+ #endif
+     } else if (interface == QStringLiteral("zwp_text_input_manager_v2") && !mClientSideInputContextRequested) {
+         mTextInputManager.reset(new QtWayland::zwp_text_input_manager_v2(registry, id, 1));
+@@ -427,6 +575,13 @@ void QWaylandDisplay::registry_global_remove(uint32_t id)
+                     inputDevice->setTextInput(nullptr);
+                 mWaylandIntegration->reconfigureInputContext();
+             }
++#if QT_CONFIG(wayland_client_primary_selection)
++            if (global.interface == QStringLiteral("zwp_primary_selection_device_manager_v1")) {
++                mPrimarySelectionManager.reset();
++                for (QWaylandInputDevice *inputDevice : qAsConst(mInputDevices))
++                    inputDevice->setPrimarySelectionDevice(nullptr);
++            }
++#endif
+             mGlobals.removeAt(i);
+             break;
+         }
+@@ -452,9 +607,10 @@ void QWaylandDisplay::addRegistryListener(RegistryListener listener, void *data)
+ 
+ void QWaylandDisplay::removeListener(RegistryListener listener, void *data)
+ {
+-    std::remove_if(mRegistryListeners.begin(), mRegistryListeners.end(), [=](Listener l){
++    auto iter = std::remove_if(mRegistryListeners.begin(), mRegistryListeners.end(), [=](Listener l){
+         return (l.listener == listener && l.data == data);
+     });
++    mRegistryListeners.erase(iter, mRegistryListeners.end());
+ }
+ 
+ uint32_t QWaylandDisplay::currentTimeMillisec()
+@@ -467,50 +623,9 @@ uint32_t QWaylandDisplay::currentTimeMillisec()
+     return 0;
+ }
+ 
+-static void
+-sync_callback(void *data, struct wl_callback *callback, uint32_t serial)
+-{
+-    Q_UNUSED(serial)
+-    bool *done = static_cast<bool *>(data);
+-
+-    *done = true;
+-
+-    // If the wl_callback done event is received after the condition check in the while loop in
+-    // forceRoundTrip(), but before the call to processEvents, the call to processEvents may block
+-    // forever if no more events are posted (eventhough the callback is handled in response to the
+-    // aboutToBlock signal). Hence, we wake up the event dispatcher so forceRoundTrip may return.
+-    // (QTBUG-64696)
+-    if (auto *dispatcher = QThread::currentThread()->eventDispatcher())
+-        dispatcher->wakeUp();
+-
+-    wl_callback_destroy(callback);
+-}
+-
+-static const struct wl_callback_listener sync_listener = {
+-    sync_callback
+-};
+-
+ void QWaylandDisplay::forceRoundTrip()
+ {
+-    // wl_display_roundtrip() works on the main queue only,
+-    // but we use a separate one, so basically reimplement it here
+-    int ret = 0;
+-    bool done = false;
+-    wl_callback *callback = wl_display_sync(mDisplay);
+-    wl_callback_add_listener(callback, &sync_listener, &done);
+-    flushRequests();
+-    if (QThread::currentThread()->eventDispatcher()) {
+-        while (!done && ret >= 0) {
+-            QThread::currentThread()->eventDispatcher()->processEvents(QEventLoop::WaitForMoreEvents);
+-            ret = wl_display_dispatch_pending(mDisplay);
+-        }
+-    } else {
+-        while (!done && ret >= 0)
+-            ret = wl_display_dispatch(mDisplay);
+-    }
+-
+-    if (ret == -1 && !done)
+-        wl_callback_destroy(callback);
++     wl_display_roundtrip(mDisplay);
+ }
+ 
+ bool QWaylandDisplay::supportsWindowDecoration() const
+@@ -574,14 +689,10 @@ void QWaylandDisplay::handleKeyboardFocusChanged(QWaylandInputDevice *inputDevic
+     if (mLastKeyboardFocus == keyboardFocus)
+         return;
+ 
+-    if (mWaylandIntegration->mShellIntegration) {
+-        mWaylandIntegration->mShellIntegration->handleKeyboardFocusChanged(keyboardFocus, mLastKeyboardFocus);
+-    } else {
+-        if (keyboardFocus)
+-            handleWindowActivated(keyboardFocus);
+-        if (mLastKeyboardFocus)
+-            handleWindowDeactivated(mLastKeyboardFocus);
+-    }
++    if (keyboardFocus)
++        handleWindowActivated(keyboardFocus);
++    if (mLastKeyboardFocus)
++        handleWindowDeactivated(mLastKeyboardFocus);
+ 
+     mLastKeyboardFocus = keyboardFocus;
+ }
+@@ -600,6 +711,19 @@ void QWaylandDisplay::handleWaylandSync()
+     QWindow *activeWindow = mActiveWindows.empty() ? nullptr : mActiveWindows.last()->window();
+     if (activeWindow != QGuiApplication::focusWindow())
+         QWindowSystemInterface::handleWindowActivated(activeWindow);
++
++    if (!activeWindow) {
++        if (lastInputDevice()) {
++#if QT_CONFIG(clipboard)
++            if (auto *dataDevice = lastInputDevice()->dataDevice())
++                dataDevice->invalidateSelectionOffer();
++#endif
++#if QT_CONFIG(wayland_client_primary_selection)
++            if (auto *device = lastInputDevice()->primarySelectionDevice())
++                device->invalidateSelectionOffer();
++#endif
++        }
++    }
+ }
+ 
+ const wl_callback_listener QWaylandDisplay::syncCallbackListener = {
+@@ -626,6 +750,13 @@ QWaylandInputDevice *QWaylandDisplay::defaultInputDevice() const
+     return mInputDevices.isEmpty() ? 0 : mInputDevices.first();
+ }
+ 
++bool QWaylandDisplay::isKeyboardAvailable() const
++{
++    return std::any_of(
++            mInputDevices.constBegin(), mInputDevices.constEnd(),
++            [this](const QWaylandInputDevice *device) { return device->keyboard() != nullptr; });
++}
++
+ #if QT_CONFIG(cursor)
+ 
+ QWaylandCursor *QWaylandDisplay::waylandCursor()
+@@ -652,4 +783,6 @@ QWaylandCursorTheme *QWaylandDisplay::loadCursorTheme(const QString &name, int p
+ 
+ } // namespace QtWaylandClient
+ 
++#include "qwaylanddisplay.moc"
++
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/client/qwaylanddisplay_p.h b/qtwayland/src/client/qwaylanddisplay_p.h
+index 3b092bc8..42bc661d 100644
+--- a/qtwayland/src/client/qwaylanddisplay_p.h
++++ b/qtwayland/src/client/qwaylanddisplay_p.h
+@@ -109,6 +109,7 @@ class QWaylandSurface;
+ class QWaylandShellIntegration;
+ class QWaylandCursor;
+ class QWaylandCursorTheme;
++class EventThread;
+ 
+ typedef void (*RegistryListener)(void *data,
+                                  struct wl_registry *registry,
+@@ -120,15 +121,11 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandDisplay : public QObject, public QtWayland
+     Q_OBJECT
+ 
+ public:
+-    struct FrameQueue {
+-        FrameQueue(wl_event_queue *q = nullptr) : queue(q), mutex(new QMutex) {}
+-        wl_event_queue *queue;
+-        QMutex *mutex;
+-    };
+-
+     QWaylandDisplay(QWaylandIntegration *waylandIntegration);
+     ~QWaylandDisplay(void) override;
+ 
++    void initialize();
++
+ #if QT_CONFIG(xkbcommon)
+     struct xkb_context *xkbContext() const { return mXkbContext.get(); }
+ #endif
+@@ -210,11 +207,11 @@ public:
+     void handleKeyboardFocusChanged(QWaylandInputDevice *inputDevice);
+     void handleWindowDestroyed(QWaylandWindow *window);
+ 
+-    wl_event_queue *createEventQueue();
+-    FrameQueue createFrameQueue();
+-    void destroyFrameQueue(const FrameQueue &q);
+-    void dispatchQueueWhile(wl_event_queue *queue, std::function<bool()> condition, int timeout = -1);
++    wl_event_queue *frameEventQueue() { return m_frameEventQueue; };
++
++    bool isKeyboardAvailable() const;
+ 
++    void initEventThread();
+ public slots:
+     void blockingReadEvents();
+     void flushRequests();
+@@ -237,6 +234,9 @@ private:
+     };
+ 
+     struct wl_display *mDisplay = nullptr;
++    QScopedPointer<EventThread> m_eventThread;
++    wl_event_queue *m_frameEventQueue = nullptr;
++    QScopedPointer<EventThread> m_frameEventQueueThread;
+     QtWayland::wl_compositor mCompositor;
+     QScopedPointer<QWaylandShm> mShm;
+     QList<QWaylandScreen *> mWaitingScreens;
+@@ -273,11 +273,9 @@ private:
+     QWaylandInputDevice *mLastInputDevice = nullptr;
+     QPointer<QWaylandWindow> mLastInputWindow;
+     QPointer<QWaylandWindow> mLastKeyboardFocus;
+-    QVector<QWaylandWindow *> mActiveWindows;
+-    QVector<FrameQueue> mExternalQueues;
++    QList<QWaylandWindow *> mActiveWindows;
+     struct wl_callback *mSyncCallback = nullptr;
+     static const wl_callback_listener syncCallbackListener;
+-    QReadWriteLock m_frameQueueLock;
+ 
+     bool mClientSideInputContextRequested = !QPlatformInputContextFactory::requested().isNull();
+ 
+diff --git a/qtwayland/src/client/qwaylanddnd.cpp b/qtwayland/src/client/qwaylanddnd.cpp
+index 6535aa16..7c53f5fa 100644
+--- a/qtwayland/src/client/qwaylanddnd.cpp
++++ b/qtwayland/src/client/qwaylanddnd.cpp
+@@ -66,7 +66,7 @@ void QWaylandDrag::startDrag()
+ {
+     QBasicDrag::startDrag();
+     QWaylandWindow *icon = static_cast<QWaylandWindow *>(shapedPixmapWindow()->handle());
+-    if (m_display->currentInputDevice()->dataDevice()->startDrag(drag()->mimeData(), icon)) {
++    if (m_display->currentInputDevice()->dataDevice()->startDrag(drag()->mimeData(), drag()->supportedActions(), icon)) {
+         icon->addAttachOffset(-drag()->hotSpot());
+     } else {
+         // Cancelling immediately does not work, since the event loop for QDrag::exec is started
+@@ -80,6 +80,9 @@ void QWaylandDrag::cancel()
+     QBasicDrag::cancel();
+ 
+     m_display->currentInputDevice()->dataDevice()->cancelDrag();
++
++    if (drag())
++        drag()->deleteLater();
+ }
+ 
+ void QWaylandDrag::move(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods)
+@@ -103,33 +106,41 @@ void QWaylandDrag::endDrag()
+     m_display->currentInputDevice()->handleEndDrag();
+ }
+ 
+-void QWaylandDrag::updateTarget(const QString &mimeType)
++void QWaylandDrag::setResponse(bool accepted)
+ {
+-    setCanDrop(!mimeType.isEmpty());
+-
+-    if (canDrop()) {
+-        updateCursor(defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers()));
+-    } else {
+-        updateCursor(Qt::IgnoreAction);
+-    }
++    // This method is used for old DataDevices where the drag action is not communicated
++    Qt::DropAction action = defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers());
++    setResponse(QPlatformDropQtResponse(accepted, action));
+ }
+ 
+-void QWaylandDrag::setResponse(const QPlatformDragQtResponse &response)
++void QWaylandDrag::setResponse(const QPlatformDropQtResponse &response)
+ {
+     setCanDrop(response.isAccepted());
+ 
+     if (canDrop()) {
+-        updateCursor(defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers()));
++        updateCursor(response.acceptedAction());
+     } else {
+         updateCursor(Qt::IgnoreAction);
+     }
+ }
+ 
+-void QWaylandDrag::finishDrag(const QPlatformDropQtResponse &response)
++void QWaylandDrag::setDropResponse(const QPlatformDropQtResponse &response)
+ {
+     setExecutedDropAction(response.acceptedAction());
++}
++
++void QWaylandDrag::finishDrag()
++{
+     QKeyEvent event(QEvent::KeyPress, Qt::Key_Escape, Qt::NoModifier);
+     eventFilter(shapedPixmapWindow(), &event);
++
++    if (drag())
++        drag()->deleteLater();
++}
++
++bool QWaylandDrag::ownsDragObject() const
++{
++    return true;
+ }
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddnd_p.h b/qtwayland/src/client/qwaylanddnd_p.h
+index 474fe2ab..46f629ac 100644
+--- a/qtwayland/src/client/qwaylanddnd_p.h
++++ b/qtwayland/src/client/qwaylanddnd_p.h
+@@ -71,9 +71,10 @@ public:
+     QWaylandDrag(QWaylandDisplay *display);
+     ~QWaylandDrag() override;
+ 
+-    void updateTarget(const QString &mimeType);
+-    void setResponse(const QPlatformDragQtResponse &response);
+-    void finishDrag(const QPlatformDropQtResponse &response);
++    void setResponse(bool accepted);
++    void setResponse(const QPlatformDropQtResponse &response);
++    void setDropResponse(const QPlatformDropQtResponse &response);
++    void finishDrag();
+ 
+ protected:
+     void startDrag() override;
+@@ -82,6 +83,7 @@ protected:
+     void drop(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods) override;
+     void endDrag() override;
+ 
++    bool ownsDragObject() const override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+diff --git a/qtwayland/src/client/qwaylandinputdevice.cpp b/qtwayland/src/client/qwaylandinputdevice.cpp
+index 613fe862..4b90de84 100644
+--- a/qtwayland/src/client/qwaylandinputdevice.cpp
++++ b/qtwayland/src/client/qwaylandinputdevice.cpp
+@@ -685,6 +685,11 @@ public:
+ 
+ void QWaylandInputDevice::Pointer::pointer_leave(uint32_t time, struct wl_surface *surface)
+ {
++    invalidateFocus();
++    mButtons = Qt::NoButton;
++
++    mParent->mTime = time;
++
+     // The event may arrive after destroying the window, indicated by
+     // a null surface.
+     if (!surface)
+@@ -696,11 +701,6 @@ void QWaylandInputDevice::Pointer::pointer_leave(uint32_t time, struct wl_surfac
+ 
+     if (!QWaylandWindow::mouseGrab())
+         setFrameEvent(new LeaveEvent(window, mSurfacePos, mGlobalPos));
+-
+-    invalidateFocus();
+-    mButtons = Qt::NoButton;
+-
+-    mParent->mTime = time;
+ }
+ 
+ class MotionEvent : public QWaylandPointerEvent
+@@ -1300,14 +1300,6 @@ void QWaylandInputDevice::Keyboard::handleFocusDestroyed()
+ void QWaylandInputDevice::Keyboard::handleFocusLost()
+ {
+     mFocus = nullptr;
+-#if QT_CONFIG(clipboard)
+-    if (auto *dataDevice = mParent->dataDevice())
+-        dataDevice->invalidateSelectionOffer();
+-#endif
+-#if QT_CONFIG(wayland_client_primary_selection)
+-    if (auto *device = mParent->primarySelectionDevice())
+-        device->invalidateSelectionOffer();
+-#endif
+     mParent->mQDisplay->handleKeyboardFocusChanged(mParent);
+     mRepeatTimer.stop();
+ }
+@@ -1396,6 +1388,7 @@ void QWaylandInputDevice::Touch::touch_cancel()
+     if (touchExt)
+         touchExt->touchCanceled();
+ 
++    mFocus = nullptr;
+     QWindowSystemInterface::handleTouchCancelEvent(nullptr, mParent->mTouchDevice);
+ }
+ 
+diff --git a/qtwayland/src/client/qwaylandintegration.cpp b/qtwayland/src/client/qwaylandintegration.cpp
+index c53ccb78..54861600 100644
+--- a/qtwayland/src/client/qwaylandintegration.cpp
++++ b/qtwayland/src/client/qwaylandintegration.cpp
+@@ -125,6 +125,9 @@ QWaylandIntegration::QWaylandIntegration()
+ #endif
+ 
+     reconfigureInputContext();
++
++    QWaylandWindow::fixedToplevelPositions =
++            !qEnvironmentVariableIsSet("QT_WAYLAND_DISABLE_FIXED_POSITIONS");
+ }
+ 
+ QWaylandIntegration::~QWaylandIntegration()
+@@ -192,14 +195,18 @@ QAbstractEventDispatcher *QWaylandIntegration::createEventDispatcher() const
+ 
+ void QWaylandIntegration::initialize()
+ {
++    mDisplay->initEventThread();
++
++    // Call after eventDispatcher is fully connected, for QWaylandDisplay::forceRoundTrip()
++    mDisplay->initialize();
++
++    // But the aboutToBlock() and awake() should be connected after initializePlatform().
++    // Otherwise the connected flushRequests() may consumes up all events before processEvents starts to wait,
++    // so that processEvents(QEventLoop::WaitForMoreEvents) may be blocked in the forceRoundTrip().
+     QAbstractEventDispatcher *dispatcher = QGuiApplicationPrivate::eventDispatcher;
+     QObject::connect(dispatcher, SIGNAL(aboutToBlock()), mDisplay.data(), SLOT(flushRequests()));
+     QObject::connect(dispatcher, SIGNAL(awake()), mDisplay.data(), SLOT(flushRequests()));
+ 
+-    int fd = wl_display_get_fd(mDisplay->wl_display());
+-    QSocketNotifier *sn = new QSocketNotifier(fd, QSocketNotifier::Read, mDisplay.data());
+-    QObject::connect(sn, SIGNAL(activated(QSocketDescriptor)), mDisplay.data(), SLOT(flushRequests()));
+-
+     // Qt does not support running with no screens
+     mDisplay->ensureScreen();
+ }
+@@ -262,6 +269,14 @@ QWaylandDisplay *QWaylandIntegration::display() const
+     return mDisplay.data();
+ }
+ 
++Qt::KeyboardModifiers QWaylandIntegration::queryKeyboardModifiers() const
++{
++    if (auto *seat = mDisplay->currentInputDevice()) {
++        return seat->modifiers();
++    }
++    return Qt::NoModifier;
++}
++
+ QList<int> QWaylandIntegration::possibleKeys(const QKeyEvent *event) const
+ {
+     if (auto *seat = mDisplay->currentInputDevice())
+@@ -479,7 +494,7 @@ void QWaylandIntegration::reconfigureInputContext()
+     }
+ #endif
+ 
+-    qCDebug(lcQpaWayland) << "using input method:" << inputContext()->metaObject()->className();
++    qCDebug(lcQpaWayland) << "using input method:" << (inputContext() ? inputContext()->metaObject()->className() : "<none>");
+ }
+ 
+ QWaylandShellIntegration *QWaylandIntegration::createShellIntegration(const QString &integrationName)
+diff --git a/qtwayland/src/client/qwaylandintegration_p.h b/qtwayland/src/client/qwaylandintegration_p.h
+index ff70ae25..73b80658 100644
+--- a/qtwayland/src/client/qwaylandintegration_p.h
++++ b/qtwayland/src/client/qwaylandintegration_p.h
+@@ -107,6 +107,8 @@ public:
+ 
+     QWaylandDisplay *display() const;
+ 
++    Qt::KeyboardModifiers queryKeyboardModifiers() const override;
++
+     QList<int> possibleKeys(const QKeyEvent *event) const override;
+ 
+     QStringList themeNames() const override;
+diff --git a/qtwayland/src/client/qwaylandprimaryselectionv1.cpp b/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
+index 832f9678..ea508771 100644
+--- a/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
++++ b/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
+@@ -54,11 +54,6 @@ QWaylandPrimarySelectionDeviceManagerV1::QWaylandPrimarySelectionDeviceManagerV1
+     : zwp_primary_selection_device_manager_v1(display->wl_registry(), id, qMin(version, uint(1)))
+     , m_display(display)
+ {
+-    // Create devices for all seats.
+-    // This only works if we get the global before all devices
+-    const auto seats = m_display->inputDevices();
+-    for (auto *seat : seats)
+-        seat->setPrimarySelectionDevice(createDevice(seat));
+ }
+ 
+ QWaylandPrimarySelectionDeviceV1 *QWaylandPrimarySelectionDeviceManagerV1::createDevice(QWaylandInputDevice *seat)
+diff --git a/qtwayland/src/client/qwaylandscreen.cpp b/qtwayland/src/client/qwaylandscreen.cpp
+index 6cb337de..5537dafd 100644
+--- a/qtwayland/src/client/qwaylandscreen.cpp
++++ b/qtwayland/src/client/qwaylandscreen.cpp
+@@ -60,7 +60,7 @@ QWaylandXdgOutputManagerV1::QWaylandXdgOutputManagerV1(QWaylandDisplay* display,
+ }
+ 
+ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uint32_t id)
+-    : QtWayland::wl_output(waylandDisplay->wl_registry(), id, qMin(version, 2))
++    : QtWayland::wl_output(waylandDisplay->wl_registry(), id, qMin(version, 3))
+     , m_outputId(id)
+     , mWaylandDisplay(waylandDisplay)
+     , mOutputName(QStringLiteral("Screen%1").arg(id))
+@@ -72,7 +72,7 @@ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uin
+         qCWarning(lcQpaWayland) << "wl_output done event not supported by compositor,"
+                                 << "QScreen may not work correctly";
+         mWaylandDisplay->forceRoundTrip(); // Give the compositor a chance to send geometry etc.
+-        mOutputDone = true; // Fake the done event
++        mProcessedEvents |= OutputDoneEvent; // Fake the done event
+         maybeInitialize();
+     }
+ }
+@@ -81,16 +81,29 @@ QWaylandScreen::~QWaylandScreen()
+ {
+     if (zxdg_output_v1::isInitialized())
+         zxdg_output_v1::destroy();
++    if (wl_output::isInitialized() && wl_output_get_version(wl_output::object()) >= WL_OUTPUT_RELEASE_SINCE_VERSION)
++        wl_output::release();
++}
++
++uint QWaylandScreen::requiredEvents() const
++{
++    uint ret = OutputDoneEvent;
++
++    if (mWaylandDisplay->xdgOutputManager()) {
++        ret |= XdgOutputNameEvent;
++
++        if (mWaylandDisplay->xdgOutputManager()->version() < 3)
++            ret |= XdgOutputDoneEvent;
++    }
++    return ret;
+ }
+ 
+ void QWaylandScreen::maybeInitialize()
+ {
+     Q_ASSERT(!mInitialized);
+ 
+-    if (!mOutputDone)
+-        return;
+-
+-    if (mWaylandDisplay->xdgOutputManager() && !mXdgOutputDone)
++    const uint requiredEvents = this->requiredEvents();
++    if ((mProcessedEvents & requiredEvents) != requiredEvents)
+         return;
+ 
+     mInitialized = true;
+@@ -276,9 +289,8 @@ void QWaylandScreen::output_scale(int32_t factor)
+ 
+ void QWaylandScreen::output_done()
+ {
+-    mOutputDone = true;
+-    if (zxdg_output_v1::isInitialized() && mWaylandDisplay->xdgOutputManager()->version() >= 3)
+-        mXdgOutputDone = true;
++    mProcessedEvents |= OutputDoneEvent;
++
+     if (mInitialized) {
+         updateOutputProperties();
+         if (zxdg_output_v1::isInitialized())
+@@ -339,7 +351,7 @@ void QWaylandScreen::zxdg_output_v1_done()
+     if (Q_UNLIKELY(mWaylandDisplay->xdgOutputManager()->version() >= 3))
+         qWarning(lcQpaWayland) << "zxdg_output_v1.done received on version 3 or newer, this is most likely a bug in the compositor";
+ 
+-    mXdgOutputDone = true;
++    mProcessedEvents |= XdgOutputDoneEvent;
+     if (mInitialized)
+         updateXdgOutputProperties();
+     else
+@@ -348,7 +360,11 @@ void QWaylandScreen::zxdg_output_v1_done()
+ 
+ void QWaylandScreen::zxdg_output_v1_name(const QString &name)
+ {
++    if (Q_UNLIKELY(mInitialized))
++        qWarning(lcQpaWayland) << "zxdg_output_v1.name received after output has been initialized, this is most likely a bug in the compositor";
++
+     mOutputName = name;
++    mProcessedEvents |= XdgOutputNameEvent;
+ }
+ 
+ void QWaylandScreen::updateXdgOutputProperties()
+diff --git a/qtwayland/src/client/qwaylandscreen_p.h b/qtwayland/src/client/qwaylandscreen_p.h
+index df1c94f2..050cfdc0 100644
+--- a/qtwayland/src/client/qwaylandscreen_p.h
++++ b/qtwayland/src/client/qwaylandscreen_p.h
+@@ -116,6 +116,13 @@ public:
+     static QWaylandScreen *fromWlOutput(::wl_output *output);
+ 
+ private:
++    enum Event : uint {
++        XdgOutputDoneEvent = 0x1,
++        OutputDoneEvent = 0x2,
++        XdgOutputNameEvent = 0x4,
++    };
++    uint requiredEvents() const;
++
+     void output_mode(uint32_t flags, int width, int height, int refresh) override;
+     void output_geometry(int32_t x, int32_t y,
+                          int32_t width, int32_t height,
+@@ -148,8 +155,7 @@ private:
+     QSize mPhysicalSize;
+     QString mOutputName;
+     Qt::ScreenOrientation m_orientation = Qt::PrimaryOrientation;
+-    bool mOutputDone = false;
+-    bool mXdgOutputDone = false;
++    uint mProcessedEvents = 0;
+     bool mInitialized = false;
+ 
+ #if QT_CONFIG(cursor)
+diff --git a/qtwayland/src/client/qwaylandshmbackingstore.cpp b/qtwayland/src/client/qwaylandshmbackingstore.cpp
+index dc7ff670..41cffdf7 100644
+--- a/qtwayland/src/client/qwaylandshmbackingstore.cpp
++++ b/qtwayland/src/client/qwaylandshmbackingstore.cpp
+@@ -52,6 +52,7 @@
+ 
+ #include <QtWaylandClient/private/wayland-wayland-client-protocol.h>
+ 
++#include <fcntl.h>
+ #include <unistd.h>
+ #include <sys/mman.h>
+ 
+@@ -61,6 +62,9 @@
+ #  ifndef MFD_CLOEXEC
+ #    define MFD_CLOEXEC     0x0001U
+ #  endif
++#  ifndef MFD_ALLOW_SEALING
++#    define MFD_ALLOW_SEALING 0x0002U
++#  endif
+ #endif
+ 
+ QT_BEGIN_NAMESPACE
+@@ -74,8 +78,10 @@ QWaylandShmBuffer::QWaylandShmBuffer(QWaylandDisplay *display,
+     int alloc = stride * size.height();
+     int fd = -1;
+ 
+-#ifdef SYS_memfd_create
+-    fd = syscall(SYS_memfd_create, "wayland-shm", MFD_CLOEXEC);
++#if defined(SYS_memfd_create) && defined(F_SEAL_SEAL)
++    fd = syscall(SYS_memfd_create, "wayland-shm", MFD_CLOEXEC | MFD_ALLOW_SEALING);
++    if (fd >= 0)
++        fcntl(fd, F_ADD_SEALS, F_SEAL_SHRINK | F_SEAL_SEAL);
+ #endif
+ 
+     QScopedPointer<QFile> filePointer;
+diff --git a/qtwayland/src/client/qwaylandwindow.cpp b/qtwayland/src/client/qwaylandwindow.cpp
+index cb82857a..fb2c59dc 100644
+--- a/qtwayland/src/client/qwaylandwindow.cpp
++++ b/qtwayland/src/client/qwaylandwindow.cpp
+@@ -76,7 +76,6 @@ QWaylandWindow *QWaylandWindow::mMouseGrab = nullptr;
+ QWaylandWindow::QWaylandWindow(QWindow *window, QWaylandDisplay *display)
+     : QPlatformWindow(window)
+     , mDisplay(display)
+-    , mFrameQueue(mDisplay->createFrameQueue())
+     , mResizeAfterSwap(qEnvironmentVariableIsSet("QT_WAYLAND_RESIZE_AFTER_SWAP"))
+ {
+     {
+@@ -95,9 +94,6 @@ QWaylandWindow::QWaylandWindow(QWindow *window, QWaylandDisplay *display)
+ 
+ QWaylandWindow::~QWaylandWindow()
+ {
+-    mDisplay->destroyFrameQueue(mFrameQueue);
+-    mDisplay->handleWindowDestroyed(this);
+-
+     delete mWindowDecoration;
+ 
+     if (mSurface)
+@@ -243,6 +239,7 @@ bool QWaylandWindow::shouldCreateSubSurface() const
+ 
+ void QWaylandWindow::reset()
+ {
++    closeChildPopups();
+     delete mShellSurface;
+     mShellSurface = nullptr;
+     delete mSubSurfaceWindow;
+@@ -255,17 +252,22 @@ void QWaylandWindow::reset()
+         mSurface.reset();
+     }
+ 
+-    if (mFrameCallback) {
+-        wl_callback_destroy(mFrameCallback);
+-        mFrameCallback = nullptr;
+-    }
++    {
++        QMutexLocker lock(&mFrameSyncMutex);
++        if (mFrameCallback) {
++            wl_callback_destroy(mFrameCallback);
++            mFrameCallback = nullptr;
++        }
+ 
+-    mFrameCallbackElapsedTimer.invalidate();
+-    mWaitingForFrameCallback = false;
++        mFrameCallbackElapsedTimer.invalidate();
++        mWaitingForFrameCallback = false;
++    }
+     mFrameCallbackTimedOut = false;
+ 
+     mMask = QRegion();
+     mQueuedBuffer = nullptr;
++
++    mDisplay->handleWindowDestroyed(this);
+ }
+ 
+ QWaylandWindow *QWaylandWindow::fromWlSurface(::wl_surface *surface)
+@@ -351,19 +353,25 @@ void QWaylandWindow::setGeometry_helper(const QRect &rect)
+     }
+ }
+ 
+-void QWaylandWindow::setGeometry(const QRect &rect)
++void QWaylandWindow::setGeometry(const QRect &r)
+ {
++    auto rect = r;
++    if (fixedToplevelPositions && !QPlatformWindow::parent() && window()->type() != Qt::Popup
++        && window()->type() != Qt::ToolTip) {
++        rect.moveTo(screen()->geometry().topLeft());
++    }
+     setGeometry_helper(rect);
+ 
+     if (window()->isVisible() && rect.isValid()) {
+         if (mWindowDecoration)
+             mWindowDecoration->update();
+ 
+-        if (mResizeAfterSwap && windowType() == Egl && mSentInitialResize)
++        if (mResizeAfterSwap && windowType() == Egl && mSentInitialResize) {
++            QMutexLocker lock(&mResizeLock);
+             mResizeDirty = true;
+-        else
++        } else {
+             QWindowSystemInterface::handleGeometryChange(window(), geometry());
+-
++        }
+         mSentInitialResize = true;
+     }
+     QRect exposeGeometry(QPoint(), geometry().size());
+@@ -374,7 +382,7 @@ void QWaylandWindow::setGeometry(const QRect &rect)
+         mShellSurface->setWindowGeometry(windowContentGeometry());
+ 
+     if (isOpaque() && mMask.isEmpty())
+-        setOpaqueArea(rect);
++        setOpaqueArea(QRect(QPoint(0, 0), rect.size()));
+ }
+ 
+ void QWaylandWindow::resizeFromApplyConfigure(const QSize &sizeWithMargins, const QPoint &offset)
+@@ -399,21 +407,6 @@ void QWaylandWindow::sendExposeEvent(const QRect &rect)
+     mLastExposeGeometry = rect;
+ }
+ 
+-
+-static QVector<QPointer<QWaylandWindow>> activePopups;
+-
+-void QWaylandWindow::closePopups(QWaylandWindow *parent)
+-{
+-    while (!activePopups.isEmpty()) {
+-        auto popup = activePopups.takeLast();
+-        if (popup.isNull())
+-            continue;
+-        if (popup.data() == parent)
+-            return;
+-        popup->reset();
+-    }
+-}
+-
+ QPlatformScreen *QWaylandWindow::calculateScreenFromSurfaceEvents() const
+ {
+     QReadLocker lock(&mSurfaceLock);
+@@ -433,10 +426,7 @@ void QWaylandWindow::setVisible(bool visible)
+     lastVisible = visible;
+ 
+     if (visible) {
+-        if (window()->type() == Qt::Popup || window()->type() == Qt::ToolTip)
+-            activePopups << this;
+         initWindow();
+-        mDisplay->flushRequests();
+ 
+         setGeometry(windowGeometry());
+         // Don't flush the events here, or else the newly visible window may start drawing, but since
+@@ -444,7 +434,6 @@ void QWaylandWindow::setVisible(bool visible)
+         // QWaylandShmBackingStore::beginPaint().
+     } else {
+         sendExposeEvent(QRect());
+-        closePopups(this);
+         reset();
+     }
+ }
+@@ -556,12 +545,12 @@ void QWaylandWindow::sendRecursiveExposeEvent()
+ 
+ void QWaylandWindow::attach(QWaylandBuffer *buffer, int x, int y)
+ {
+-    Q_ASSERT(!buffer->committed());
+     QReadLocker locker(&mSurfaceLock);
+     if (mSurface == nullptr)
+         return;
+ 
+     if (buffer) {
++        Q_ASSERT(!buffer->committed());
+         handleUpdate();
+         buffer->setBusy();
+ 
+@@ -583,7 +572,11 @@ void QWaylandWindow::damage(const QRect &rect)
+     if (mSurface == nullptr)
+         return;
+ 
+-    mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    const int s = scale();
++    if (mDisplay->compositorVersion() >= 4)
++        mSurface->damage_buffer(s * rect.x(), s * rect.y(), s * rect.width(), s * rect.height());
++    else
++        mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
+ }
+ 
+ void QWaylandWindow::safeCommit(QWaylandBuffer *buffer, const QRegion &damage)
+@@ -619,8 +612,14 @@ void QWaylandWindow::commit(QWaylandBuffer *buffer, const QRegion &damage)
+         return;
+ 
+     attachOffset(buffer);
+-    for (const QRect &rect: damage)
+-        mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    if (mDisplay->compositorVersion() >= 4) {
++        const int s = scale();
++        for (const QRect &rect: damage)
++            mSurface->damage_buffer(s * rect.x(), s * rect.y(), s * rect.width(), s * rect.height());
++    } else {
++        for (const QRect &rect: damage)
++            mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    }
+     Q_ASSERT(!buffer->committed());
+     buffer->setCommitted();
+     mSurface->commit();
+@@ -635,42 +634,53 @@ void QWaylandWindow::commit()
+ 
+ const wl_callback_listener QWaylandWindow::callbackListener = {
+     [](void *data, wl_callback *callback, uint32_t time) {
+-        Q_UNUSED(callback);
+         Q_UNUSED(time);
+         auto *window = static_cast<QWaylandWindow*>(data);
+-        window->handleFrameCallback();
++        window->handleFrameCallback(callback);
+     }
+ };
+ 
+-void QWaylandWindow::handleFrameCallback()
++void QWaylandWindow::handleFrameCallback(wl_callback* callback)
+ {
++    QMutexLocker locker(&mFrameSyncMutex);
++    if (!mFrameCallback) {
++        // This means the callback is already unset by QWaylandWindow::reset.
++        // The wl_callback object will be destroyed there too.
++        return;
++    }
++    Q_ASSERT(callback == mFrameCallback);
++    wl_callback_destroy(callback);
++    mFrameCallback = nullptr;
++
+     mWaitingForFrameCallback = false;
+     mFrameCallbackElapsedTimer.invalidate();
+ 
+     // The rest can wait until we can run it on the correct thread
+-    if (!mWaitingForUpdateDelivery) {
+-        auto doHandleExpose = [this]() {
+-            bool wasExposed = isExposed();
+-            mFrameCallbackTimedOut = false;
+-            if (!wasExposed && isExposed()) // Did setting mFrameCallbackTimedOut make the window exposed?
+-                sendExposeEvent(QRect(QPoint(), geometry().size()));
+-            if (wasExposed && hasPendingUpdateRequest())
+-                deliverUpdateRequest();
+-
+-            mWaitingForUpdateDelivery = false;
+-        };
++    auto doHandleExpose = [this]() {
++        mWaitingForUpdateDelivery.storeRelease(false);
++        bool wasExposed = isExposed();
++        mFrameCallbackTimedOut = false;
++        if (!wasExposed && isExposed()) // Did setting mFrameCallbackTimedOut make the window exposed?
++            sendExposeEvent(QRect(QPoint(), geometry().size()));
++        if (wasExposed && hasPendingUpdateRequest())
++            deliverUpdateRequest();
++    };
+ 
++    if (mWaitingForUpdateDelivery.testAndSetAcquire(false, true)) {
+         // Queued connection, to make sure we don't call handleUpdate() from inside waitForFrameSync()
+         // in the single-threaded case.
+-        mWaitingForUpdateDelivery = true;
+         QMetaObject::invokeMethod(this, doHandleExpose, Qt::QueuedConnection);
+     }
++
++    mFrameSyncWait.notify_all();
+ }
+ 
+ bool QWaylandWindow::waitForFrameSync(int timeout)
+ {
+-    QMutexLocker locker(mFrameQueue.mutex);
+-    mDisplay->dispatchQueueWhile(mFrameQueue.queue, [&]() { return mWaitingForFrameCallback; }, timeout);
++    QMutexLocker locker(&mFrameSyncMutex);
++
++    QDeadlineTimer deadline(timeout);
++    while (mWaitingForFrameCallback && mFrameSyncWait.wait(&mFrameSyncMutex, deadline)) { }
+ 
+     if (mWaitingForFrameCallback) {
+         qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
+@@ -868,6 +878,17 @@ bool QWaylandWindow::createDecoration()
+             subsurf->set_position(pos.x() + m.left(), pos.y() + m.top());
+         }
+         sendExposeEvent(QRect(QPoint(), geometry().size()));
++
++        // This is a special case where the buffer is recreated, but since
++        // the content rect remains the same, the widgets remain the same
++        // size and are not redrawn, leaving the new buffer empty. As a simple
++        // work-around, we trigger a full extra update whenever the client-side
++        // window decorations are toggled while the window is showing.
++        // Note: createDecoration() is sometimes called from the render thread
++        // of Qt Quick. This is essentially wrong and could potentially cause problems,
++        // but until the underlying issue has been fixed, we have to use invokeMethod()
++        // here to avoid asserts.
++        QMetaObject::invokeMethod(window(), &QWindow::requestUpdate);
+     }
+ 
+     return mWindowDecoration;
+@@ -1023,6 +1044,13 @@ void QWaylandWindow::handleScreensChanged()
+ 
+     QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->QPlatformScreen::screen());
+     mLastReportedScreen = newScreen;
++    if (fixedToplevelPositions && !QPlatformWindow::parent() && window()->type() != Qt::Popup
++        && window()->type() != Qt::ToolTip
++        && geometry().topLeft() != newScreen->geometry().topLeft()) {
++        auto geometry = this->geometry();
++        geometry.moveTo(newScreen->geometry().topLeft());
++        setGeometry(geometry);
++    }
+ 
+     int scale = newScreen->isPlaceholder() ? 1 : static_cast<QWaylandScreen *>(newScreen)->scale();
+     if (scale != mScale) {
+@@ -1094,10 +1122,18 @@ bool QWaylandWindow::setMouseGrabEnabled(bool grab)
+     return true;
+ }
+ 
++Qt::WindowStates QWaylandWindow::windowStates() const
++{
++    return mLastReportedWindowStates;
++}
++
+ void QWaylandWindow::handleWindowStatesChanged(Qt::WindowStates states)
+ {
+     createDecoration();
+-    QWindowSystemInterface::handleWindowStateChanged(window(), states, mLastReportedWindowStates);
++    Qt::WindowStates statesWithoutActive = states & ~Qt::WindowActive;
++    Qt::WindowStates lastStatesWithoutActive = mLastReportedWindowStates & ~Qt::WindowActive;
++    QWindowSystemInterface::handleWindowStateChanged(window(), statesWithoutActive,
++                                                     lastStatesWithoutActive);
+     mLastReportedWindowStates = states;
+ }
+ 
+@@ -1139,19 +1175,24 @@ void QWaylandWindow::timerEvent(QTimerEvent *event)
+     if (event->timerId() != mFrameCallbackCheckIntervalTimerId)
+         return;
+ 
+-    bool callbackTimerExpired = mFrameCallbackElapsedTimer.hasExpired(mFrameCallbackTimeout);
+-    if (!mFrameCallbackElapsedTimer.isValid() || callbackTimerExpired ) {
+-        killTimer(mFrameCallbackCheckIntervalTimerId);
+-        mFrameCallbackCheckIntervalTimerId = -1;
+-    }
+-    if (mFrameCallbackElapsedTimer.isValid() && callbackTimerExpired) {
+-        mFrameCallbackElapsedTimer.invalidate();
++    {
++        QMutexLocker lock(&mFrameSyncMutex);
+ 
+-        qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
+-        mFrameCallbackTimedOut = true;
+-        mWaitingForUpdate = false;
+-        sendExposeEvent(QRect());
++        bool callbackTimerExpired = mFrameCallbackElapsedTimer.hasExpired(mFrameCallbackTimeout);
++        if (!mFrameCallbackElapsedTimer.isValid() || callbackTimerExpired ) {
++            killTimer(mFrameCallbackCheckIntervalTimerId);
++            mFrameCallbackCheckIntervalTimerId = -1;
++        }
++        if (!mFrameCallbackElapsedTimer.isValid() || !callbackTimerExpired) {
++            return;
++        }
++        mFrameCallbackElapsedTimer.invalidate();
+     }
++
++    qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
++    mFrameCallbackTimedOut = true;
++    mWaitingForUpdate = false;
++    sendExposeEvent(QRect());
+ }
+ 
+ void QWaylandWindow::requestUpdate()
+@@ -1160,8 +1201,11 @@ void QWaylandWindow::requestUpdate()
+     Q_ASSERT(hasPendingUpdateRequest()); // should be set by QPA
+ 
+     // If we have a frame callback all is good and will be taken care of there
+-    if (mWaitingForFrameCallback)
+-        return;
++    {
++        QMutexLocker locker(&mFrameSyncMutex);
++        if (mWaitingForFrameCallback)
++            return;
++    }
+ 
+     // If we've already called deliverUpdateRequest(), but haven't seen any attach+commit/swap yet
+     // This is a somewhat redundant behavior and might indicate a bug in the calling code, so log
+@@ -1174,7 +1218,12 @@ void QWaylandWindow::requestUpdate()
+     // so use invokeMethod to delay the delivery a bit.
+     QMetaObject::invokeMethod(this, [this] {
+         // Things might have changed in the meantime
+-        if (hasPendingUpdateRequest() && !mWaitingForFrameCallback)
++        {
++            QMutexLocker locker(&mFrameSyncMutex);
++            if (mWaitingForFrameCallback)
++                return;
++        }
++        if (hasPendingUpdateRequest())
+             deliverUpdateRequest();
+     }, Qt::QueuedConnection);
+ }
+@@ -1185,19 +1234,18 @@ void QWaylandWindow::requestUpdate()
+ void QWaylandWindow::handleUpdate()
+ {
+     qCDebug(lcWaylandBackingstore) << "handleUpdate" << QThread::currentThread();
++
+     // TODO: Should sync subsurfaces avoid requesting frame callbacks?
+     QReadLocker lock(&mSurfaceLock);
+     if (!mSurface)
+         return;
+ 
+-    if (mFrameCallback) {
+-        wl_callback_destroy(mFrameCallback);
+-        mFrameCallback = nullptr;
+-    }
++    QMutexLocker locker(&mFrameSyncMutex);
++    if (mWaitingForFrameCallback)
++        return;
+ 
+-    QMutexLocker locker(mFrameQueue.mutex);
+     struct ::wl_surface *wrappedSurface = reinterpret_cast<struct ::wl_surface *>(wl_proxy_create_wrapper(mSurface->object()));
+-    wl_proxy_set_queue(reinterpret_cast<wl_proxy *>(wrappedSurface), mFrameQueue.queue);
++    wl_proxy_set_queue(reinterpret_cast<wl_proxy *>(wrappedSurface), mDisplay->frameEventQueue());
+     mFrameCallback = wl_surface_frame(wrappedSurface);
+     wl_proxy_wrapper_destroy(wrappedSurface);
+     wl_callback_add_listener(mFrameCallback, &QWaylandWindow::callbackListener, this);
+@@ -1207,6 +1255,8 @@ void QWaylandWindow::handleUpdate()
+     // Start a timer for handling the case when the compositor stops sending frame callbacks.
+     if (mFrameCallbackTimeout > 0) {
+         QMetaObject::invokeMethod(this, [this] {
++            QMutexLocker locker(&mFrameSyncMutex);
++
+             if (mWaitingForFrameCallback) {
+                 if (mFrameCallbackCheckIntervalTimerId < 0)
+                     mFrameCallbackCheckIntervalTimerId = startTimer(mFrameCallbackTimeout);
+@@ -1267,6 +1317,20 @@ void QWaylandWindow::setOpaqueArea(const QRegion &opaqueArea)
+     wl_region_destroy(region);
+ }
+ 
++void QWaylandWindow::addChildPopup(QWaylandWindow *surface) {
++    mChildPopups.append(surface);
++}
++
++void QWaylandWindow::removeChildPopup(QWaylandWindow *surface) {
++    mChildPopups.removeAll(surface);
++}
++
++void QWaylandWindow::closeChildPopups() {
++    while (!mChildPopups.isEmpty()) {
++        auto popup = mChildPopups.takeLast();
++        popup->reset();
++    }
++}
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/client/qwaylandwindow_p.h b/qtwayland/src/client/qwaylandwindow_p.h
+index 01337cff..2f219d8c 100644
+--- a/qtwayland/src/client/qwaylandwindow_p.h
++++ b/qtwayland/src/client/qwaylandwindow_p.h
+@@ -98,6 +98,9 @@ public:
+     QWaylandWindow(QWindow *window, QWaylandDisplay *display);
+     ~QWaylandWindow() override;
+ 
++    // Keep Toplevels position on the top left corner of their screen
++    static inline bool fixedToplevelPositions = true;
++
+     virtual WindowType windowType() const = 0;
+     virtual void ensureSize();
+     WId winId() const override;
+@@ -148,6 +151,7 @@ public:
+     void setWindowState(Qt::WindowStates states) override;
+     void setWindowFlags(Qt::WindowFlags flags) override;
+     void handleWindowStatesChanged(Qt::WindowStates states);
++    Qt::WindowStates windowStates() const;
+ 
+     void raise() override;
+     void lower() override;
+@@ -206,6 +210,10 @@ public:
+     void handleUpdate();
+     void deliverUpdateRequest() override;
+ 
++    void addChildPopup(QWaylandWindow* child);
++    void removeChildPopup(QWaylandWindow* child);
++    void closeChildPopups();
++
+ public slots:
+     void applyConfigure();
+ 
+@@ -215,7 +223,11 @@ signals:
+ 
+ protected:
+     QWaylandDisplay *mDisplay = nullptr;
++
++    // mSurface can be written by the main thread. Other threads should claim a read lock for access
++    mutable QReadWriteLock mSurfaceLock;
+     QScopedPointer<QWaylandSurface> mSurface;
++
+     QWaylandShellSurface *mShellSurface = nullptr;
+     QWaylandSubSurface *mSubSurfaceWindow = nullptr;
+     QVector<QWaylandSubSurface *> mChildren;
+@@ -225,13 +237,14 @@ protected:
+     Qt::MouseButtons mMousePressedInContentArea = Qt::NoButton;
+ 
+     WId mWindowId;
+-    bool mWaitingForFrameCallback = false;
+     bool mFrameCallbackTimedOut = false; // Whether the frame callback has timed out
+-    bool mWaitingForUpdateDelivery = false;
+     int mFrameCallbackCheckIntervalTimerId = -1;
+-    QElapsedTimer mFrameCallbackElapsedTimer;
+-    struct ::wl_callback *mFrameCallback = nullptr;
+-    QWaylandDisplay::FrameQueue mFrameQueue;
++    QAtomicInt mWaitingForUpdateDelivery = false;
++
++    bool mWaitingForFrameCallback = false; // Protected by mFrameSyncMutex
++    QElapsedTimer mFrameCallbackElapsedTimer; // Protected by mFrameSyncMutex
++    struct ::wl_callback *mFrameCallback = nullptr; // Protected by mFrameSyncMutex
++    QMutex mFrameSyncMutex;
+     QWaitCondition mFrameSyncWait;
+ 
+     // True when we have called deliverRequestUpdate, but the client has not yet attached a new buffer
+@@ -261,6 +274,8 @@ protected:
+     QWaylandBuffer *mQueuedBuffer = nullptr;
+     QRegion mQueuedBufferDamage;
+ 
++    QList<QPointer<QWaylandWindow>> mChildPopups;
++
+ private:
+     void setGeometry_helper(const QRect &rect);
+     void initWindow();
+@@ -283,12 +298,10 @@ private:
+     QRect mLastExposeGeometry;
+ 
+     static const wl_callback_listener callbackListener;
+-    void handleFrameCallback();
++    void handleFrameCallback(struct ::wl_callback* callback);
+ 
+     static QWaylandWindow *mMouseGrab;
+ 
+-    mutable QReadWriteLock mSurfaceLock;
+-
+     friend class QWaylandSubSurface;
+ };
+ 
+diff --git a/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h b/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
+index ccad0048..4cc9b3b8 100644
+--- a/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
++++ b/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
+@@ -73,11 +73,10 @@ public:
+         return true;
+     }
+     virtual QWaylandShellSurface *createShellSurface(QWaylandWindow *window) = 0;
++    // kept for binary compat with layer-shell-qt
+     virtual void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) {
+-        if (newFocus)
+-            m_display->handleWindowActivated(newFocus);
+-        if (oldFocus)
+-            m_display->handleWindowDeactivated(oldFocus);
++        Q_UNUSED(newFocus);
++        Q_UNUSED(oldFocus);
+     }
+     virtual void *nativeResourceForWindow(const QByteArray &resource, QWindow *window) {
+         Q_UNUSED(resource);
+diff --git a/qtwayland/src/compositor/configure.json b/qtwayland/src/compositor/configure.json
+index bcfd5215..da95d07b 100644
+--- a/qtwayland/src/compositor/configure.json
++++ b/qtwayland/src/compositor/configure.json
+@@ -7,6 +7,31 @@
+     "testDir": "../../config.tests",
+ 
+     "libraries": {
++        "wayland-client": {
++            "label": "Wayland client library",
++            "headers": "wayland-version.h",
++            "test": {
++                "main": [
++                    "#if WAYLAND_VERSION_MAJOR < 1",
++                    "# error Wayland 1.8.0 or higher required",
++                    "#endif",
++                    "#if WAYLAND_VERSION_MAJOR == 1",
++                    "# if WAYLAND_VERSION_MINOR < 8",
++                    "#  error Wayland 1.8.0 or higher required",
++                    "# endif",
++                    "# if WAYLAND_VERSION_MINOR == 8",
++                    "#  if WAYLAND_VERSION_MICRO < 0",
++                    "#   error Wayland 1.8.0 or higher required",
++                    "#  endif",
++                    "# endif",
++                    "#endif"
++                 ]
++            },
++            "sources": [
++                { "type": "pkgConfig", "args": "wayland-client" },
++                "-lwayland-client"
++            ]
++        },
+         "wayland-server": {
+             "label": "wayland-server",
+             "headers": "wayland-version.h",
+@@ -151,8 +176,7 @@
+                     "#endif"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "dmabuf-client-buffer": {
+             "label": "Linux Client dma-buf Buffer Sharing",
+@@ -176,8 +200,7 @@
+                     "return 0;"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "vulkan-server-buffer": {
+             "label": "Vulkan Buffer Sharing",
+@@ -195,7 +218,8 @@
+                     "exportAllocInfo.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR;",
+                     "return 0;"
+                 ]
+-            }
++            },
++            "use": "wayland-client"
+         }
+     },
+ 
+diff --git a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
+index 7889f575..64140672 100644
+--- a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
++++ b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
+@@ -40,6 +40,7 @@
+ #include "qwaylandeglwindow.h"
+ 
+ #include <QtWaylandClient/private/qwaylandscreen_p.h>
++#include <QtWaylandClient/private/qwaylandsurface_p.h>
+ #include "qwaylandglcontext.h"
+ 
+ #include <QtEglSupport/private/qeglconvenience_p.h>
+@@ -124,6 +125,7 @@ void QWaylandEglWindow::updateSurface(bool create)
+         }
+         mOffset = QPoint();
+     } else {
++        QReadLocker locker(&mSurfaceLock);
+         if (m_waylandEglWindow) {
+             int current_width, current_height;
+             static bool disableResizeCheck = qgetenv("QT_WAYLAND_DISABLE_RESIZECHECK").toInt();
+@@ -131,14 +133,16 @@ void QWaylandEglWindow::updateSurface(bool create)
+             if (!disableResizeCheck) {
+                 wl_egl_window_get_attached_size(m_waylandEglWindow, &current_width, &current_height);
+             }
+-            if (disableResizeCheck || (current_width != sizeWithMargins.width() || current_height != sizeWithMargins.height())) {
++            if (disableResizeCheck || (current_width != sizeWithMargins.width() || current_height != sizeWithMargins.height()) || m_requestedSize != sizeWithMargins) {
+                 wl_egl_window_resize(m_waylandEglWindow, sizeWithMargins.width(), sizeWithMargins.height(), mOffset.x(), mOffset.y());
++                m_requestedSize = sizeWithMargins;
+                 mOffset = QPoint();
+ 
+                 m_resize = true;
+             }
+-        } else if (create && wlSurface()) {
+-            m_waylandEglWindow = wl_egl_window_create(wlSurface(), sizeWithMargins.width(), sizeWithMargins.height());
++        } else if (create && mSurface) {
++            m_waylandEglWindow = wl_egl_window_create(mSurface->object(), sizeWithMargins.width(), sizeWithMargins.height());
++            m_requestedSize = sizeWithMargins;
+         }
+ 
+         if (!m_eglSurface && m_waylandEglWindow && create) {
+diff --git a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
+index 5b1f4d56..0079dfef 100644
+--- a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
++++ b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
+@@ -88,6 +88,7 @@ private:
+     mutable QOpenGLFramebufferObject *m_contentFBO = nullptr;
+ 
+     QSurfaceFormat m_format;
++    QSize m_requestedSize;
+ };
+ 
+ }
+diff --git a/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h b/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
+index 56a710c3..c6a8b6c6 100644
+--- a/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
++++ b/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
+@@ -41,6 +41,8 @@
+ #include <QtCore/QTextStream>
+ #include <QtGui/QOpenGLTexture>
+ 
++#include <array>
++
+ #include <EGL/egl.h>
+ #include <EGL/eglext.h>
+ 
+diff --git a/qtwayland/src/plugins/decorations/bradient/main.cpp b/qtwayland/src/plugins/decorations/bradient/main.cpp
+index e75fda3c..fa885143 100644
+--- a/qtwayland/src/plugins/decorations/bradient/main.cpp
++++ b/qtwayland/src/plugins/decorations/bradient/main.cpp
+@@ -164,13 +164,10 @@ void QWaylandBradientDecoration::paint(QPaintDevice *device)
+     // Window icon
+     QIcon icon = waylandWindow()->windowIcon();
+     if (!icon.isNull()) {
+-        QPixmap pixmap = icon.pixmap(QSize(128, 128));
+-        QPixmap scaled = pixmap.scaled(22, 22, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+-
+         QRectF iconRect(0, 0, 22, 22);
+-        p.drawPixmap(iconRect.adjusted(margins().left() + BUTTON_SPACING, 4,
+-                                       margins().left() + BUTTON_SPACING, 4),
+-                     scaled, iconRect);
++        iconRect.adjust(margins().left() + BUTTON_SPACING, 4,
++                        margins().left() + BUTTON_SPACING, 4),
++        icon.paint(&p, iconRect.toRect());
+     }
+ 
+     // Window title
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
+index 85d25e3c..60bdd491 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
+@@ -47,18 +47,21 @@ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
+-QWaylandXdgPopupV5::QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow *window)
++QWaylandXdgPopupV5::QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow* parent, QWaylandWindow *window)
+     : QWaylandShellSurface(window)
+     , QtWayland::xdg_popup_v5(popup)
++    , m_parent(parent)
+     , m_window(window)
+ {
+     if (window->display()->windowExtension())
+         m_extendedWindow = new QWaylandExtendedSurface(window);
++    m_parent->addChildPopup(m_window);
+ }
+ 
+ QWaylandXdgPopupV5::~QWaylandXdgPopupV5()
+ {
+     xdg_popup_destroy(object());
++    m_parent->removeChildPopup(m_window);
+     delete m_extendedWindow;
+ }
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
+index 7494f6a6..d85f130b 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
+@@ -70,7 +70,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgPopupV5 : public QWaylandShellSurface
+ {
+     Q_OBJECT
+ public:
+-    QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow *window);
++    QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow* parent, QWaylandWindow *window);
+     ~QWaylandXdgPopupV5() override;
+ 
+ protected:
+@@ -78,6 +78,7 @@ protected:
+ 
+ private:
+     QWaylandExtendedSurface *m_extendedWindow = nullptr;
++    QWaylandWindow *m_parent = nullptr;
+     QWaylandWindow *m_window = nullptr;
+ };
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
+index 7e242c4a..def8452a 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
+@@ -84,7 +84,7 @@ QWaylandXdgPopupV5 *QWaylandXdgShellV5::createXdgPopup(QWaylandWindow *window, Q
+     int x = position.x() + parentWindow->frameMargins().left();
+     int y = position.y() + parentWindow->frameMargins().top();
+ 
+-    auto popup = new QWaylandXdgPopupV5(get_xdg_popup(window->wlSurface(), parentSurface, seat, m_popupSerial, x, y), window);
++    auto popup = new QWaylandXdgPopupV5(get_xdg_popup(window->wlSurface(), parentSurface, seat, m_popupSerial, x, y), parentWindow, window);
+     m_popups.append(window);
+     QObject::connect(popup, &QWaylandXdgPopupV5::destroyed, [this, window](){
+         m_popups.removeOne(window);
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
+index 4e25949f..cfc60939 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
+@@ -85,13 +85,6 @@ QWaylandShellSurface *QWaylandXdgShellV5Integration::createShellSurface(QWayland
+     return m_xdgShell->createXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellV5Integration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) {
+-    if (newFocus && qobject_cast<QWaylandXdgPopupV5 *>(newFocus->shellSurface()))
+-        m_display->handleWindowActivated(newFocus);
+-    if (oldFocus && qobject_cast<QWaylandXdgPopupV5 *>(oldFocus->shellSurface()))
+-        m_display->handleWindowDeactivated(oldFocus);
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
+index ce6bdb9e..aed88670 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
+@@ -67,7 +67,6 @@ public:
+     QWaylandXdgShellV5Integration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShellV5> m_xdgShell;
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
+index 8c371661..151c78e3 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
+@@ -174,6 +174,7 @@ QWaylandXdgSurfaceV6::Popup::Popup(QWaylandXdgSurfaceV6 *xdgSurface, QWaylandXdg
+     , m_xdgSurface(xdgSurface)
+     , m_parent(parent)
+ {
++    m_parent->window()->addChildPopup(m_xdgSurface->window());
+ }
+ 
+ QWaylandXdgSurfaceV6::Popup::~Popup()
+@@ -181,6 +182,8 @@ QWaylandXdgSurfaceV6::Popup::~Popup()
+     if (isInitialized())
+         destroy();
+ 
++    m_parent->window()->removeChildPopup(m_xdgSurface->window());
++
+     if (m_grabbing) {
+         auto *shell = m_xdgSurface->m_shell;
+         Q_ASSERT(shell->m_topmostGrabbingPopup == this);
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
+index 03164316..e8da8ba1 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
+@@ -68,20 +68,6 @@ QWaylandShellSurface *QWaylandXdgShellV6Integration::createShellSurface(QWayland
+     return m_xdgShell->getXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellV6Integration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus)
+-{
+-    if (newFocus) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurfaceV6 *>(newFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowActivated(newFocus);
+-    }
+-    if (oldFocus && qobject_cast<QWaylandXdgSurfaceV6 *>(oldFocus->shellSurface())) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurfaceV6 *>(oldFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowDeactivated(oldFocus);
+-    }
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
+index 261f8cbb..c1bcd5c6 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
+@@ -65,7 +65,6 @@ public:
+     QWaylandXdgShellV6Integration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShellV6> m_xdgShell;
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
+index f3e3c330..fa6d5808 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
+@@ -67,11 +67,6 @@ QWaylandXdgSurface::Toplevel::Toplevel(QWaylandXdgSurface *xdgSurface)
+ 
+ QWaylandXdgSurface::Toplevel::~Toplevel()
+ {
+-    if (m_applied.states & Qt::WindowActive) {
+-        QWaylandWindow *window = m_xdgSurface->window();
+-        window->display()->handleWindowDeactivated(window);
+-    }
+-
+     // The protocol spec requires that the decoration object is deleted before xdg_toplevel.
+     delete m_decoration;
+     m_decoration = nullptr;
+@@ -85,16 +80,15 @@ void QWaylandXdgSurface::Toplevel::applyConfigure()
+     if (!(m_applied.states & (Qt::WindowMaximized|Qt::WindowFullScreen)))
+         m_normalSize = m_xdgSurface->m_window->windowFrameGeometry().size();
+ 
+-    if ((m_pending.states & Qt::WindowActive) && !(m_applied.states & Qt::WindowActive))
++    if ((m_pending.states & Qt::WindowActive) && !(m_applied.states & Qt::WindowActive)
++        && !m_xdgSurface->m_window->display()->isKeyboardAvailable())
+         m_xdgSurface->m_window->display()->handleWindowActivated(m_xdgSurface->m_window);
+ 
+-    if (!(m_pending.states & Qt::WindowActive) && (m_applied.states & Qt::WindowActive))
++    if (!(m_pending.states & Qt::WindowActive) && (m_applied.states & Qt::WindowActive)
++        && !m_xdgSurface->m_window->display()->isKeyboardAvailable())
+         m_xdgSurface->m_window->display()->handleWindowDeactivated(m_xdgSurface->m_window);
+ 
+-    // TODO: none of the other plugins send WindowActive either, but is it on purpose?
+-    Qt::WindowStates statesWithoutActive = m_pending.states & ~Qt::WindowActive;
+-
+-    m_xdgSurface->m_window->handleWindowStatesChanged(statesWithoutActive);
++    m_xdgSurface->m_window->handleWindowStatesChanged(m_pending.states);
+ 
+     if (m_pending.size.isEmpty()) {
+         // An empty size in the configure means it's up to the client to choose the size
+@@ -105,8 +99,6 @@ void QWaylandXdgSurface::Toplevel::applyConfigure()
+         m_xdgSurface->m_window->resizeFromApplyConfigure(m_pending.size);
+     }
+ 
+-    m_xdgSurface->setSizeHints();
+-
+     m_applied = m_pending;
+     qCDebug(lcQpaWayland) << "Applied pending xdg_toplevel configure event:" << m_applied.size << m_applied.states;
+ }
+@@ -203,12 +195,17 @@ QtWayland::xdg_toplevel::resize_edge QWaylandXdgSurface::Toplevel::convertToResi
+                 | ((edges & Qt::RightEdge) ? resize_edge_right : 0));
+ }
+ 
+-QWaylandXdgSurface::Popup::Popup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parent,
++QWaylandXdgSurface::Popup::Popup(QWaylandXdgSurface *xdgSurface, QWaylandWindow *parent,
+                                  QtWayland::xdg_positioner *positioner)
+-    : xdg_popup(xdgSurface->get_popup(parent->object(), positioner->object()))
+-    , m_xdgSurface(xdgSurface)
++    : m_xdgSurface(xdgSurface)
++    , m_parentXdgSurface(qobject_cast<QWaylandXdgSurface *>(parent->shellSurface()))
+     , m_parent(parent)
+ {
++
++    init(xdgSurface->get_popup(m_parentXdgSurface ? m_parentXdgSurface->object() : nullptr, positioner->object()));
++    if (m_parent) {
++        m_parent->addChildPopup(m_xdgSurface->window());
++    }
+ }
+ 
+ QWaylandXdgSurface::Popup::~Popup()
+@@ -216,10 +213,24 @@ QWaylandXdgSurface::Popup::~Popup()
+     if (isInitialized())
+         destroy();
+ 
++    if (m_parent) {
++        m_parent->removeChildPopup(m_xdgSurface->window());
++    }
++
+     if (m_grabbing) {
+         auto *shell = m_xdgSurface->m_shell;
+         Q_ASSERT(shell->m_topmostGrabbingPopup == this);
+-        shell->m_topmostGrabbingPopup = m_parent->m_popup;
++        shell->m_topmostGrabbingPopup = m_parentXdgSurface ? m_parentXdgSurface->m_popup : nullptr;
++        m_grabbing = false;
++
++        // Synthesize Qt enter/leave events for popup
++        QWindow *leave = nullptr;
++        if (m_xdgSurface && m_xdgSurface->window())
++            leave = m_xdgSurface->window()->window();
++        QWindowSystemInterface::handleLeaveEvent(leave);
++
++        if (QWindow *enter = QGuiApplication::topLevelAt(QCursor::pos()))
++            QWindowSystemInterface::handleEnterEvent(enter, enter->mapFromGlobal(QCursor::pos()), QCursor::pos());
+     }
+ }
+ 
+@@ -257,6 +268,7 @@ QWaylandXdgSurface::QWaylandXdgSurface(QWaylandXdgShell *shell, ::xdg_surface *s
+                 m_toplevel->set_parent(parentXdgSurface->m_toplevel->object());
+         }
+     }
++    setSizeHints();
+ }
+ 
+ QWaylandXdgSurface::~QWaylandXdgSurface()
+@@ -400,8 +412,6 @@ void QWaylandXdgSurface::setPopup(QWaylandWindow *parent)
+ {
+     Q_ASSERT(!m_toplevel && !m_popup);
+ 
+-    auto parentXdgSurface = static_cast<QWaylandXdgSurface *>(parent->shellSurface());
+-
+     auto positioner = new QtWayland::xdg_positioner(m_shell->create_positioner());
+     // set_popup expects a position relative to the parent
+     QPoint transientPos = m_window->geometry().topLeft(); // this is absolute
+@@ -414,8 +424,9 @@ void QWaylandXdgSurface::setPopup(QWaylandWindow *parent)
+     positioner->set_anchor(QtWayland::xdg_positioner::anchor_top_left);
+     positioner->set_gravity(QtWayland::xdg_positioner::gravity_bottom_right);
+     positioner->set_size(m_window->geometry().width(), m_window->geometry().height());
+-    m_popup = new Popup(this, parentXdgSurface, positioner);
++    m_popup = new Popup(this, parent, positioner);
+     positioner->destroy();
++
+     delete positioner;
+ }
+ 
+@@ -437,6 +448,23 @@ void QWaylandXdgSurface::setGrabPopup(QWaylandWindow *parent, QWaylandInputDevic
+     }
+     setPopup(parent);
+     m_popup->grab(device, serial);
++
++    // Synthesize Qt enter/leave events for popup
++    if (!parent)
++        return;
++    QWindow *current = QGuiApplication::topLevelAt(QCursor::pos());
++    QWindow *leave = parent->window();
++    if (current != leave)
++        return;
++
++    QWindowSystemInterface::handleLeaveEvent(leave);
++
++    QWindow *enter = nullptr;
++    if (m_popup && m_popup->m_xdgSurface && m_popup->m_xdgSurface->window())
++        enter = m_popup->m_xdgSurface->window()->window();
++
++    if (enter)
++        QWindowSystemInterface::handleEnterEvent(enter, enter->mapFromGlobal(QCursor::pos()), QCursor::pos());
+ }
+ 
+ void QWaylandXdgSurface::xdg_surface_configure(uint32_t serial)
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
+index 96785205..4b518f0a 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
+@@ -131,14 +131,15 @@ private:
+ 
+     class Popup : public QtWayland::xdg_popup {
+     public:
+-        Popup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parent, QtWayland::xdg_positioner *positioner);
++        Popup(QWaylandXdgSurface *xdgSurface, QWaylandWindow *parent, QtWayland::xdg_positioner *positioner);
+         ~Popup() override;
+ 
+         void grab(QWaylandInputDevice *seat, uint serial);
+         void xdg_popup_popup_done() override;
+ 
+         QWaylandXdgSurface *m_xdgSurface = nullptr;
+-        QWaylandXdgSurface *m_parent = nullptr;
++        QWaylandXdgSurface *m_parentXdgSurface = nullptr;
++        QWaylandWindow *m_parent = nullptr;
+         bool m_grabbing = false;
+     };
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
+index 8769d971..da0dd6a7 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
+@@ -69,20 +69,6 @@ QWaylandShellSurface *QWaylandXdgShellIntegration::createShellSurface(QWaylandWi
+     return m_xdgShell->getXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellIntegration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus)
+-{
+-    if (newFocus) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurface *>(newFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowActivated(newFocus);
+-    }
+-    if (oldFocus && qobject_cast<QWaylandXdgSurface *>(oldFocus->shellSurface())) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurface *>(oldFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowDeactivated(oldFocus);
+-    }
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
+index b6caa6c9..2f929f98 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
+@@ -65,7 +65,6 @@ public:
+     QWaylandXdgShellIntegration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShell> m_xdgShell;
+diff --git a/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp b/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
+index 526d0ef4..f50ccf30 100644
+--- a/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
++++ b/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
+@@ -39,7 +39,10 @@
+ 
+ #include "qwaylandinputmethodeventbuilder_p.h"
+ 
++#include <QBrush>
++#include <QGuiApplication>
+ #include <QInputMethod>
++#include <QPalette>
+ #include <QTextCharFormat>
+ 
+ #ifdef QT_BUILD_WAYLANDCOMPOSITOR_LIB
+@@ -81,32 +84,38 @@ void QWaylandInputMethodEventBuilder::addPreeditStyling(uint32_t index, uint32_t
+     QTextCharFormat format;
+ 
+     switch (style) {
+-    case 0:
+-    case 1:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_NONE:
++        break;
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_DEFAULT:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_UNDERLINE:
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-    case 2:
+-    case 3:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_ACTIVE:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_INACTIVE:
+         format.setFontWeight(QFont::Bold);
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-    case 4:
+-        format.setFontUnderline(true);
+-        format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+-        m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_HIGHLIGHT:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_SELECTION:
++        {
++            format.setFontUnderline(true);
++            format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
++            QPalette palette = qApp->palette();
++            format.setBackground(QBrush(palette.color(QPalette::Active, QPalette::Highlight)));
++            format.setForeground(QBrush(palette.color(QPalette::Active, QPalette::HighlightedText)));
++            m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
++        }
+         break;
+-    case 5:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_INCORRECT:
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::WaveUnderline);
+         format.setUnderlineColor(QColor(Qt::red));
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-//    case QtWayland::wl_text_input::preedit_style_selection:
+-//    case QtWayland::wl_text_input::preedit_style_none:
+     default:
+         break;
+     }
+@@ -153,7 +162,7 @@ QInputMethodEvent QWaylandInputMethodEventBuilder::buildPreedit(const QString &t
+ 
+     if (m_preeditCursor < 0) {
+         attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, 0, QVariant()));
+-    } else if (m_preeditCursor > 0) {
++    } else {
+         attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, indexFromWayland(text, m_preeditCursor), 1, QVariant()));
+     }
+ 
+diff --git a/qtwayland/src/shared/qwaylandmimehelper.cpp b/qtwayland/src/shared/qwaylandmimehelper.cpp
+index a5fdd34d..e2fe1928 100644
+--- a/qtwayland/src/shared/qwaylandmimehelper.cpp
++++ b/qtwayland/src/shared/qwaylandmimehelper.cpp
+@@ -60,7 +60,7 @@ QByteArray QWaylandMimeHelper::getByteArray(QMimeData *mimeData, const QString &
+             buf.open(QIODevice::ReadWrite);
+             QByteArray fmt = "BMP";
+             if (mimeType.startsWith(QLatin1String("image/"))) {
+-                QByteArray imgFmt = mimeType.mid(6).toUpper().toLatin1();
++                QByteArray imgFmt = mimeType.mid(6).toLower().toLatin1();
+                 if (QImageWriter::supportedImageFormats().contains(imgFmt))
+                     fmt = imgFmt;
+             }
+@@ -74,7 +74,7 @@ QByteArray QWaylandMimeHelper::getByteArray(QMimeData *mimeData, const QString &
+         QList<QUrl> urls = mimeData->urls();
+         for (int i = 0; i < urls.count(); ++i) {
+             content.append(urls.at(i).toEncoded());
+-            content.append('\n');
++            content.append("\r\n");
+         }
+     } else {
+         content = mimeData->data(mimeType);
+diff --git a/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp b/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
+index 1568b3b9..067410d0 100644
+--- a/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
++++ b/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
+@@ -35,7 +35,7 @@
+ 
+ using namespace MockCompositor;
+ 
+-constexpr int dataDeviceVersion = 1;
++constexpr int dataDeviceVersion = 3;
+ 
+ class DataDeviceCompositor : public DefaultCompositor {
+ public:
+diff --git a/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp b/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
+index 9312c2e5..2ea382f1 100644
+--- a/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
++++ b/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
+@@ -73,6 +73,7 @@ private slots:
+     void multiTouch();
+     void multiTouchUpAndMotionFrame();
+     void tapAndMoveInSameFrame();
++    void cancelTouch();
+ };
+ 
+ void tst_seatv5::bindsToSeat()
+@@ -646,5 +647,34 @@ void tst_seatv5::tapAndMoveInSameFrame()
+     QTRY_COMPARE(window.m_events.last().touchPoints.first().state(), Qt::TouchPointState::TouchPointReleased);
+ }
+ 
++void tst_seatv5::cancelTouch()
++{
++    TouchWindow window;
++    QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
++
++    exec([=] {
++        auto *t = touch();
++        auto *c = client();
++        t->sendDown(xdgToplevel()->surface(), {32, 32}, 1);
++        t->sendFrame(c);
++        t->sendCancel(c);
++        t->sendFrame(c);
++    });
++
++    QTRY_VERIFY(!window.m_events.empty());
++    {
++        auto e = window.m_events.takeFirst();
++        QCOMPARE(e.type, QEvent::TouchBegin);
++        QCOMPARE(e.touchPointStates, Qt::TouchPointPressed);
++        QCOMPARE(e.touchPoints.length(), 1);
++        QCOMPARE(e.touchPoints.first().pos(), QPointF(32-window.frameMargins().left(), 32-window.frameMargins().top()));
++    }
++    {
++        auto e = window.m_events.takeFirst();
++        QCOMPARE(e.type, QEvent::TouchCancel);
++        QCOMPARE(e.touchPoints.length(), 0);
++    }
++}
++
+ QCOMPOSITOR_TEST_MAIN(tst_seatv5)
+ #include "tst_seatv5.moc"
+diff --git a/qtwayland/tests/auto/client/shared/corecompositor.cpp b/qtwayland/tests/auto/client/shared/corecompositor.cpp
+index 5c6c83ba..fa9b7662 100644
+--- a/qtwayland/tests/auto/client/shared/corecompositor.cpp
++++ b/qtwayland/tests/auto/client/shared/corecompositor.cpp
+@@ -27,6 +27,7 @@
+ ****************************************************************************/
+ 
+ #include "corecompositor.h"
++#include <thread>
+ 
+ namespace MockCompositor {
+ 
+diff --git a/qtwayland/tests/auto/client/shared/coreprotocol.cpp b/qtwayland/tests/auto/client/shared/coreprotocol.cpp
+index 0d988521..d1a2e7cb 100644
+--- a/qtwayland/tests/auto/client/shared/coreprotocol.cpp
++++ b/qtwayland/tests/auto/client/shared/coreprotocol.cpp
+@@ -451,6 +451,13 @@ void Touch::sendFrame(wl_client *client)
+         send_frame(r->handle);
+ }
+ 
++void Touch::sendCancel(wl_client *client)
++{
++    const auto touchResources = resourceMap().values(client);
++    for (auto *r : touchResources)
++        send_cancel(r->handle);
++}
++
+ uint Keyboard::sendEnter(Surface *surface)
+ {
+     auto serial = m_seat->m_compositor->nextSerial();
+diff --git a/qtwayland/tests/auto/client/shared/coreprotocol.h b/qtwayland/tests/auto/client/shared/coreprotocol.h
+index a1af137a..210d8ddb 100644
+--- a/qtwayland/tests/auto/client/shared/coreprotocol.h
++++ b/qtwayland/tests/auto/client/shared/coreprotocol.h
+@@ -158,7 +158,7 @@ class WlCompositor : public Global, public QtWaylandServer::wl_compositor
+ {
+     Q_OBJECT
+ public:
+-    explicit WlCompositor(CoreCompositor *compositor, int version = 3)
++    explicit WlCompositor(CoreCompositor *compositor, int version = 4)
+         : QtWaylandServer::wl_compositor(compositor->m_display, version)
+         , m_compositor(compositor)
+     {}
+@@ -364,6 +364,7 @@ public:
+     uint sendUp(wl_client *client, int id);
+     void sendMotion(wl_client *client, const QPointF &position, int id);
+     void sendFrame(wl_client *client);
++    void sendCancel(wl_client *client);
+ 
+     Seat *m_seat = nullptr;
+ };
+diff --git a/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp b/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
+index a415cbf5..b1d3d07d 100644
+--- a/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
++++ b/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
+@@ -342,7 +342,7 @@ Compositor::Compositor(MockCompositor *mockCompositor)
+         exit(EXIT_FAILURE);
+     }
+ 
+-    wl_global_create(m_display, &wl_compositor_interface, 1, this, bindCompositor);
++    wl_global_create(m_display, &wl_compositor_interface, 4, this, bindCompositor);
+ 
+     m_data_device_manager.reset(new DataDeviceManager(this, m_display));
+ 
+diff --git a/qtwayland/tests/auto/client/shared_old/mocksurface.cpp b/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
+index e9df5f90..c3246e4a 100644
+--- a/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
++++ b/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
+@@ -125,6 +125,16 @@ void Surface::surface_damage(Resource *resource,
+     Q_UNUSED(height);
+ }
+ 
++void Surface::surface_damage_buffer(Resource *resource,
++                                    int32_t x, int32_t y, int32_t width, int32_t height)
++{
++    Q_UNUSED(resource);
++    Q_UNUSED(x);
++    Q_UNUSED(y);
++    Q_UNUSED(width);
++    Q_UNUSED(height);
++}
++
+ void Surface::surface_frame(Resource *resource,
+                             uint32_t callback)
+ {
+diff --git a/qtwayland/tests/auto/client/shared_old/mocksurface.h b/qtwayland/tests/auto/client/shared_old/mocksurface.h
+index 949dc23d..d176837e 100644
+--- a/qtwayland/tests/auto/client/shared_old/mocksurface.h
++++ b/qtwayland/tests/auto/client/shared_old/mocksurface.h
+@@ -65,6 +65,8 @@ protected:
+                         struct wl_resource *buffer, int x, int y) override;
+     void surface_damage(Resource *resource,
+                         int32_t x, int32_t y, int32_t width, int32_t height) override;
++    void surface_damage_buffer(Resource *resource,
++                               int32_t x, int32_t y, int32_t width, int32_t height) override;
+     void surface_frame(Resource *resource,
+                        uint32_t callback) override;
+     void surface_commit(Resource *resource) override;
+diff --git a/qtwayland/tests/auto/client/surface/tst_surface.cpp b/qtwayland/tests/auto/client/surface/tst_surface.cpp
+index 95e4e609..60c672ce 100644
+--- a/qtwayland/tests/auto/client/surface/tst_surface.cpp
++++ b/qtwayland/tests/auto/client/surface/tst_surface.cpp
+@@ -129,6 +129,10 @@ void tst_surface::waitForFrameCallbackGl()
+     // Make sure we follow frame callbacks for some frames
+     for (int i = 0; i < 5; ++i) {
+         xdgPingAndWaitForPong(); // Make sure things have happened on the client
++        if (!qEnvironmentVariableIntValue("QT_WAYLAND_DISABLE_WINDOWDECORATION") && i == 0) {
++            QCOMPARE(bufferSpy.count(), 1);
++            bufferSpy.removeFirst();
++        }
+         exec([&] {
+             QVERIFY(bufferSpy.empty()); // Make sure no extra buffers have arrived
+             QVERIFY(!xdgToplevel()->surface()->m_waitingFrameCallbacks.empty());
+diff --git a/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp b/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
+index 2277bbb8..747875b4 100644
+--- a/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
++++ b/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
+@@ -31,6 +31,7 @@
+ #include <QtGui/QOpenGLWindow>
+ #include <QtGui/qpa/qplatformnativeinterface.h>
+ #include <QtWaylandClient/private/wayland-wayland-client-protocol.h>
++#include <QtWaylandClient/private/qwaylandwindow_p.h>
+ 
+ using namespace MockCompositor;
+ 
+@@ -45,6 +46,7 @@ private slots:
+     void configureStates();
+     void popup();
+     void tooltipOnPopup();
++    void tooltipAndSiblingPopup();
+     void switchPopups();
+     void hidePopupParent();
+     void pongs();
+@@ -138,6 +140,7 @@ void tst_xdgshell::configureSize()
+ 
+ void tst_xdgshell::configureStates()
+ {
++    QVERIFY(qputenv("QT_WAYLAND_FRAME_CALLBACK_TIMEOUT", "0"));
+     QRasterWindow window;
+     window.resize(64, 48);
+     window.show();
+@@ -154,9 +157,12 @@ void tst_xdgshell::configureStates()
+     // Toplevel windows don't know their position on xdg-shell
+ //    QCOMPARE(window.frameGeometry().topLeft(), QPoint()); // TODO: this doesn't currently work when window decorations are enabled
+ 
+-//    QEXPECT_FAIL("", "configure has already been acked, we shouldn't have to wait for isActive", Continue);
+-//    QVERIFY(window.isActive());
+-    QTRY_VERIFY(window.isActive()); // Just make sure it eventually get's set correctly
++    // window.windowstate() is driven by keyboard focus, however for decorations we want to follow
++    // XDGShell this is internal to QtWayland so it is queried directly
++    auto waylandWindow = static_cast<QtWaylandClient::QWaylandWindow *>(window.handle());
++    Q_ASSERT(waylandWindow);
++    QTRY_VERIFY(waylandWindow->windowStates().testFlag(
++            Qt::WindowActive)); // Just make sure it eventually get's set correctly
+ 
+     const QSize screenSize(640, 480);
+     const uint maximizedSerial = exec([=] {
+@@ -186,6 +192,7 @@ void tst_xdgshell::configureStates()
+     QCOMPARE(window.windowStates(), Qt::WindowNoState);
+     QCOMPARE(window.frameGeometry().size(), windowedSize);
+ //    QCOMPARE(window.frameGeometry().topLeft(), QPoint()); // TODO: this doesn't currently work when window decorations are enabled
++    QVERIFY(qunsetenv("QT_WAYLAND_FRAME_CALLBACK_TIMEOUT"));
+ }
+ 
+ void tst_xdgshell::popup()
+@@ -340,6 +347,92 @@ void tst_xdgshell::tooltipOnPopup()
+     QCOMPOSITOR_TRY_COMPARE(xdgPopup(0), nullptr);
+ }
+ 
++void tst_xdgshell::tooltipAndSiblingPopup()
++{
++    class ToolTip : public QRasterWindow {
++    public:
++        explicit ToolTip(QWindow *parent) {
++            setTransientParent(parent);
++            setFlags(Qt::ToolTip);
++            resize(100, 100);
++            show();
++        }
++        void mousePressEvent(QMouseEvent *event) override {
++            QRasterWindow::mousePressEvent(event);
++            m_popup = new QRasterWindow;
++            m_popup->setTransientParent(transientParent());
++            m_popup->setFlags(Qt::Popup);
++            m_popup->resize(100, 100);
++            m_popup->show();
++        }
++
++        QRasterWindow *m_popup = nullptr;
++    };
++
++    class Window : public QRasterWindow {
++    public:
++        void mousePressEvent(QMouseEvent *event) override {
++            QRasterWindow::mousePressEvent(event);
++            m_tooltip = new ToolTip(this);
++        }
++        ToolTip *m_tooltip = nullptr;
++    };
++
++    Window window;
++    window.resize(200, 200);
++    window.show();
++
++    QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
++    exec([=] { xdgToplevel()->sendCompleteConfigure(); });
++    QCOMPOSITOR_TRY_VERIFY(xdgToplevel()->m_xdgSurface->m_committedConfigureSerial);
++
++    exec([=] {
++        auto *surface = xdgToplevel()->surface();
++        auto *p = pointer();
++        auto *c = client();
++        p->sendEnter(surface, {100, 100});
++        p->sendFrame(c);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_pressed);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_released);
++        p->sendFrame(c);
++        p->sendLeave(surface);
++        p->sendFrame(c);
++    });
++
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup());
++    exec([=] { xdgPopup()->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup()->m_xdgSurface->m_committedConfigureSerial);
++    QCOMPOSITOR_TRY_VERIFY(!xdgPopup()->m_grabbed);
++
++    exec([=] {
++        auto *surface = xdgPopup()->surface();
++        auto *p = pointer();
++        auto *c = client();
++        p->sendEnter(surface, {100, 100});
++        p->sendFrame(c);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_pressed);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_released);
++        p->sendFrame(c);
++    });
++
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1));
++    exec([=] { xdgPopup(1)->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1)->m_xdgSurface->m_committedConfigureSerial);
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1)->m_grabbed);
++
++    // Close the middle tooltip (it should not close the sibling popup)
++    window.m_tooltip->close();
++
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(1), nullptr);
++    // Verify the remaining xdg surface is a grab popup..
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(0));
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(0)->m_grabbed);
++
++    window.m_tooltip->m_popup->close();
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(1), nullptr);
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(0), nullptr);
++}
++
+ // QTBUG-65680
+ void tst_xdgshell::switchPopups()
+ {
+@@ -505,7 +598,7 @@ void tst_xdgshell::minMaxSize()
+     window.show();
+     QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
+ 
+-    exec([=] { xdgToplevel()->sendCompleteConfigure(); });
++    // we don't roundtrip with our configuration the initial commit should be correct
+ 
+     QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.minSize, QSize(100, 100));
+     QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.maxSize, QSize(1000, 1000));
+Submodule qtwebchannel 618422ee..f8949655:
+diff --git a/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp b/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
+index 536eb5c..898d769 100644
+--- a/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
++++ b/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
+@@ -186,8 +186,6 @@ Q_DECLARE_TYPEINFO(OverloadResolutionCandidate, Q_MOVABLE_TYPE);
+ QMetaObjectPublisher::QMetaObjectPublisher(QWebChannel *webChannel)
+     : QObject(webChannel)
+     , webChannel(webChannel)
+-    , signalHandler(this)
+-    , clientIsIdle(false)
+     , blockUpdates(false)
+     , propertyUpdatesInitialized(false)
+ {
+@@ -301,17 +299,17 @@ QJsonObject QMetaObjectPublisher::classInfoForObject(const QObject *object, QWeb
+     return data;
+ }
+ 
+-void QMetaObjectPublisher::setClientIsIdle(bool isIdle)
++void QMetaObjectPublisher::setClientIsIdle(bool isIdle, QWebChannelAbstractTransport *transport)
+ {
+-    if (clientIsIdle == isIdle) {
+-        return;
+-    }
+-    clientIsIdle = isIdle;
+-    if (!isIdle && timer.isActive()) {
+-        timer.stop();
+-    } else if (isIdle && !timer.isActive()) {
+-        timer.start(PROPERTY_UPDATE_INTERVAL, this);
+-    }
++    transportState[transport].clientIsIdle = isIdle;
++    if (isIdle)
++        sendEnqueuedPropertyUpdates(transport);
++}
++
++bool QMetaObjectPublisher::isClientIdle(QWebChannelAbstractTransport *transport)
++{
++    auto found = transportState.find(transport);
++    return found != transportState.end() && found.value().clientIsIdle;
+ }
+ 
+ QJsonObject QMetaObjectPublisher::initializeClient(QWebChannelAbstractTransport *transport)
+@@ -333,6 +331,7 @@ QJsonObject QMetaObjectPublisher::initializeClient(QWebChannelAbstractTransport
+ 
+ void QMetaObjectPublisher::initializePropertyUpdates(const QObject *const object, const QJsonObject &objectInfo)
+ {
++    auto *signalHandler = signalHandlerFor(object);
+     foreach (const QJsonValue &propertyInfoVar, objectInfo[KEY_PROPERTIES].toArray()) {
+         const QJsonArray &propertyInfo = propertyInfoVar.toArray();
+         if (propertyInfo.size() < 2) {
+@@ -353,19 +352,19 @@ void QMetaObjectPublisher::initializePropertyUpdates(const QObject *const object
+ 
+         // Only connect for a property update once
+         if (connectedProperties.isEmpty()) {
+-            signalHandler.connectTo(object, signalIndex);
++            signalHandler->connectTo(object, signalIndex);
+         }
+ 
+         connectedProperties.insert(propertyIndex);
+     }
+ 
+     // also always connect to destroyed signal
+-    signalHandler.connectTo(object, s_destroyedSignalIndex);
++    signalHandler->connectTo(object, s_destroyedSignalIndex);
+ }
+ 
+ void QMetaObjectPublisher::sendPendingPropertyUpdates()
+ {
+-    if (blockUpdates || !clientIsIdle || pendingPropertyUpdates.isEmpty()) {
++    if (blockUpdates) {
+         return;
+     }
+ 
+@@ -415,18 +414,19 @@ void QMetaObjectPublisher::sendPendingPropertyUpdates()
+ 
+     // data does not contain specific updates
+     if (!data.isEmpty()) {
+-        setClientIsIdle(false);
+-
+         message[KEY_DATA] = data;
+-        broadcastMessage(message);
++        enqueueBroadcastMessage(message);
+     }
+ 
+     // send every property update which is not supposed to be broadcasted
+     const QHash<QWebChannelAbstractTransport*, QJsonArray>::const_iterator suend = specificUpdates.constEnd();
+     for (QHash<QWebChannelAbstractTransport*, QJsonArray>::const_iterator it = specificUpdates.constBegin(); it != suend; ++it) {
+         message[KEY_DATA] = it.value();
+-        it.key()->sendMessage(message);
++        enqueueMessage(message, it.key());
+     }
++
++    for (auto state = transportState.begin(); state != transportState.end(); ++state)
++        sendEnqueuedPropertyUpdates(state.key());
+ }
+ 
+ QVariant QMetaObjectPublisher::invokeMethod(QObject *const object, const QMetaMethod &method,
+@@ -572,7 +572,7 @@ void QMetaObjectPublisher::signalEmitted(const QObject *object, const int signal
+         }
+     } else {
+         pendingPropertyUpdates[object][signalIndex] = arguments;
+-        if (clientIsIdle && !blockUpdates && !timer.isActive()) {
++        if (!blockUpdates && !timer.isActive()) {
+             timer.start(PROPERTY_UPDATE_INTERVAL, this);
+         }
+     }
+@@ -590,7 +590,7 @@ void QMetaObjectPublisher::objectDestroyed(const QObject *object)
+     // only remove from handler when we initialized the property updates
+     // cf: https://bugreports.qt.io/browse/QTBUG-60250
+     if (propertyUpdatesInitialized) {
+-        signalHandler.remove(object);
++        signalHandlerFor(object)->remove(object);
+         signalToPropertyMap.remove(object);
+     }
+     pendingPropertyUpdates.remove(object);
+@@ -852,6 +852,52 @@ void QMetaObjectPublisher::broadcastMessage(const QJsonObject &message) const
+     }
+ }
+ 
++void QMetaObjectPublisher::enqueueBroadcastMessage(const QJsonObject &message)
++{
++    if (webChannel->d_func()->transports.isEmpty()) {
++        qWarning("QWebChannel is not connected to any transports, cannot send message: %s",
++                 QJsonDocument(message).toJson().constData());
++        return;
++    }
++
++    for (auto *transport : webChannel->d_func()->transports) {
++        auto &state = transportState[transport];
++        state.queuedMessages.append(message);
++    }
++}
++
++void QMetaObjectPublisher::enqueueMessage(const QJsonObject &message,
++                                          QWebChannelAbstractTransport *transport)
++{
++    auto &state = transportState[transport];
++    state.queuedMessages.append(message);
++}
++
++void QMetaObjectPublisher::sendEnqueuedPropertyUpdates(QWebChannelAbstractTransport *transport)
++{
++    auto found = transportState.find(transport);
++    if (found != transportState.end() && found.value().clientIsIdle
++        && !found.value().queuedMessages.isEmpty()) {
++
++        // If the client is connected with an in-process transport, it can
++        // happen that a message triggers a subsequent property change. In
++        // that case, we need to ensure that the queued messages have already
++        // been cleared; otherwise the recursive call will send everythig again.
++        // Case in point: The qmlwebchannel tests fail if we don't clear the
++        // queued messages before sending them out.
++        // For that same reason set the client to "busy" (aka non-idle) just
++        // right before sending out the messages; otherwise a potential
++        // "Idle" type message will not correctly restore the Idle state.
++        const auto messages = std::move(found.value().queuedMessages);
++        Q_ASSERT(found.value().queuedMessages.isEmpty());
++        found.value().clientIsIdle = false;
++
++        for (const auto &message : messages) {
++            transport->sendMessage(message);
++        }
++    }
++}
++
+ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannelAbstractTransport *transport)
+ {
+     if (!webChannel->d_func()->transports.contains(transport)) {
+@@ -866,7 +912,7 @@ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannel
+ 
+     const MessageType type = toType(message.value(KEY_TYPE));
+     if (type == TypeIdle) {
+-        setClientIsIdle(true);
++        setClientIsIdle(true, transport);
+     } else if (type == TypeInit) {
+         if (!message.contains(KEY_ID)) {
+             qWarning("JSON message object is missing the id property: %s",
+@@ -913,9 +959,9 @@ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannel
+                 return;
+             transport->sendMessage(createResponse(message.value(KEY_ID), wrapResult(result, transport)));
+         } else if (type == TypeConnectToSignal) {
+-            signalHandler.connectTo(object, message.value(KEY_SIGNAL).toInt(-1));
++            signalHandlerFor(object)->connectTo(object, message.value(KEY_SIGNAL).toInt(-1));
+         } else if (type == TypeDisconnectFromSignal) {
+-            signalHandler.disconnectFrom(object, message.value(KEY_SIGNAL).toInt(-1));
++            signalHandlerFor(object)->disconnectFrom(object, message.value(KEY_SIGNAL).toInt(-1));
+         } else if (type == TypeSetProperty) {
+             setProperty(object, message.value(KEY_PROPERTY).toInt(-1),
+                         message.value(KEY_VALUE));
+@@ -931,6 +977,7 @@ void QMetaObjectPublisher::setBlockUpdates(bool block)
+     blockUpdates = block;
+ 
+     if (!blockUpdates) {
++        timer.start(PROPERTY_UPDATE_INTERVAL, this);
+         sendPendingPropertyUpdates();
+     } else if (timer.isActive()) {
+         timer.stop();
+@@ -948,4 +995,15 @@ void QMetaObjectPublisher::timerEvent(QTimerEvent *event)
+     }
+ }
+ 
++SignalHandler<QMetaObjectPublisher> *QMetaObjectPublisher::signalHandlerFor(const QObject *object)
++{
++    auto thread = object->thread();
++    auto it = signalHandlers.find(thread);
++    if (it == signalHandlers.end()) {
++        it = signalHandlers.emplace(thread, this).first;
++        it->second.moveToThread(thread);
++    }
++    return &it->second;
++}
++
+ QT_END_NAMESPACE
+diff --git a/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h b/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
+index bbd9875..4713ef1 100644
+--- a/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
++++ b/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
+@@ -59,6 +59,9 @@
+ #include <QBasicTimer>
+ #include <QPointer>
+ #include <QJsonObject>
++#include <QQueue>
++
++#include <unordered_map>
+ 
+ #include "qwebchannelglobal.h"
+ 
+@@ -109,17 +112,36 @@ public:
+      */
+     void broadcastMessage(const QJsonObject &message) const;
+ 
++    /**
++     * Enqueue the given @p message to all known transports.
++     */
++    void enqueueBroadcastMessage(const QJsonObject &message);
++
++    /**
++     * Enqueue the given @p message to @p transport.
++     */
++    void enqueueMessage(const QJsonObject &message, QWebChannelAbstractTransport *transport);
++
++    /**
++     * If client for given @p transport is idle, send queued messaged to @p transport and then mark
++     * the client as not idle.
++     */
++    void sendEnqueuedPropertyUpdates(QWebChannelAbstractTransport *transport);
++
+     /**
+      * Serialize the QMetaObject of @p object and return it in JSON form.
+      */
+     QJsonObject classInfoForObject(const QObject *object, QWebChannelAbstractTransport *transport);
+ 
+     /**
+-     * Set the client to idle or busy, based on the value of @p isIdle.
+-     *
+-     * When the value changed, start/stop the property update timer accordingly.
++     * Set the client to idle or busy for a single @p transport, based on the value of @p isIdle.
++     */
++    void setClientIsIdle(bool isIdle, QWebChannelAbstractTransport *transport);
++
++    /**
++     * Check that client is idle for @p transport.
+      */
+-    void setClientIsIdle(bool isIdle);
++    bool isClientIdle(QWebChannelAbstractTransport *transport);
+ 
+     /**
+      * Initialize clients by sending them the class information of the registered objects.
+@@ -272,10 +294,18 @@ private:
+     friend class TestWebChannel;
+ 
+     QWebChannel *webChannel;
+-    SignalHandler<QMetaObjectPublisher> signalHandler;
++    std::unordered_map<const QThread*, SignalHandler<QMetaObjectPublisher>> signalHandlers;
++    SignalHandler<QMetaObjectPublisher> *signalHandlerFor(const QObject *object);
+ 
+-    // true when the client is idle, false otherwise
+-    bool clientIsIdle;
++    struct TransportState
++    {
++        TransportState() : clientIsIdle(false) { }
++        // true when the client is idle, false otherwise
++        bool clientIsIdle;
++        // messages to send
++        QQueue<QJsonObject> queuedMessages;
++    };
++    QHash<QWebChannelAbstractTransport *, TransportState> transportState;
+ 
+     // true when no property updates should be sent, false otherwise
+     bool blockUpdates;
+diff --git a/qtwebchannel/src/webchannel/signalhandler_p.h b/qtwebchannel/src/webchannel/signalhandler_p.h
+index 27afadb..d77373c 100644
+--- a/qtwebchannel/src/webchannel/signalhandler_p.h
++++ b/qtwebchannel/src/webchannel/signalhandler_p.h
+@@ -56,6 +56,7 @@
+ #include <QVector>
+ #include <QMetaMethod>
+ #include <QDebug>
++#include <QThread>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -71,6 +72,7 @@ static const int s_destroyedSignalIndex = QObject::staticMetaObject.indexOfMetho
+ template<class Receiver>
+ class SignalHandler : public QObject
+ {
++    Q_DISABLE_COPY(SignalHandler)
+ public:
+     SignalHandler(Receiver *receiver, QObject *parent = 0);
+ 
+@@ -268,6 +270,7 @@ int SignalHandler<Receiver>::qt_metacall(QMetaObject::Call call, int methodId, v
+     if (call == QMetaObject::InvokeMetaMethod) {
+         const QObject *object = sender();
+         Q_ASSERT(object);
++        Q_ASSERT(QThread::currentThread() == object->thread());
+         Q_ASSERT(senderSignalIndex() == methodId);
+         Q_ASSERT(m_connectionsCounter.contains(object));
+         Q_ASSERT(m_connectionsCounter.value(object).contains(methodId));
+diff --git a/qtwebchannel/tests/auto/qml/testwebchannel.cpp b/qtwebchannel/tests/auto/qml/testwebchannel.cpp
+index 9891687..3ca81c2 100644
+--- a/qtwebchannel/tests/auto/qml/testwebchannel.cpp
++++ b/qtwebchannel/tests/auto/qml/testwebchannel.cpp
+@@ -46,7 +46,11 @@ TestWebChannel::~TestWebChannel()
+ 
+ bool TestWebChannel::clientIsIdle() const
+ {
+-    return QWebChannel::d_func()->publisher->clientIsIdle;
++    for (auto *transport : QWebChannel::d_func()->transports) {
++        if (QWebChannel::d_func()->publisher->isClientIdle(transport))
++            return true;
++    }
++    return false;
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp b/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
+index 181da9e..37f989a 100644
+--- a/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
++++ b/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
+@@ -785,7 +785,7 @@ void TestWebChannel::testTransportWrapObjectProperties()
+     DummyTransport *dummyTransport = new DummyTransport(this);
+     channel.connectTo(dummyTransport);
+     channel.d_func()->publisher->initializeClient(dummyTransport);
+-    channel.d_func()->publisher->setClientIsIdle(true);
++    channel.d_func()->publisher->setClientIsIdle(true, dummyTransport);
+ 
+     QCOMPARE(channel.d_func()->publisher->transportedWrappedObjects.size(), 0);
+ 
+@@ -943,8 +943,6 @@ void TestWebChannel::testInfiniteRecursion()
+ 
+ void TestWebChannel::testAsyncObject()
+ {
+-    QSKIP("This test is broken. See QTBUG-80729");
+-
+     QWebChannel channel;
+     channel.connectTo(m_dummyTransport);
+ 
+@@ -990,6 +988,50 @@ void TestWebChannel::testAsyncObject()
+     thread.wait();
+ }
+ 
++void TestWebChannel::testPropertyMultipleTransports()
++{
++    DummyTransport transport1;
++    DummyTransport transport2;
++
++    QWebChannel channel;
++    QMetaObjectPublisher *publisher = channel.d_func()->publisher;
++
++    TestObject testObj;
++    testObj.setObjectName("testObject");
++    channel.registerObject(testObj.objectName(), &testObj);
++    channel.connectTo(&transport1);
++    channel.connectTo(&transport2);
++
++    testObj.setProp("Hello");
++
++    publisher->initializeClient(&transport1);
++    publisher->initializeClient(&transport2);
++    publisher->setClientIsIdle(true, &transport1);
++    QCOMPARE(publisher->isClientIdle(&transport1), true);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++    QVERIFY(transport1.messagesSent().isEmpty());
++    QVERIFY(transport2.messagesSent().isEmpty());
++
++    testObj.setProp("World");
++    QTRY_COMPARE_WITH_TIMEOUT(transport1.messagesSent().size(), 1u, 2000);
++    QCOMPARE(transport2.messagesSent().size(), 0u);
++    publisher->setClientIsIdle(true, &transport2);
++    QTRY_COMPARE_WITH_TIMEOUT(transport2.messagesSent().size(), 1u, 2000);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++
++    testObj.setProp("!!!");
++    publisher->setClientIsIdle(true, &transport2);
++    QCOMPARE(publisher->isClientIdle(&transport2), true);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QTRY_COMPARE_WITH_TIMEOUT(transport2.messagesSent().size(), 2u, 2000);
++    QCOMPARE(transport1.messagesSent().size(), 1u);
++    publisher->setClientIsIdle(true, &transport1);
++    QTRY_COMPARE_WITH_TIMEOUT(transport1.messagesSent().size(), 2u, 2000);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++}
++
+ class FunctionWrapper : public QObject
+ {
+     Q_OBJECT
+@@ -1082,7 +1124,7 @@ void TestWebChannel::benchInitializeClients()
+ 
+         publisher->propertyUpdatesInitialized = false;
+         publisher->signalToPropertyMap.clear();
+-        publisher->signalHandler.clear();
++        publisher->signalHandlers.clear();
+     }
+ }
+ 
+@@ -1107,7 +1149,7 @@ void TestWebChannel::benchPropertyUpdates()
+             obj->change();
+         }
+ 
+-        channel.d_func()->publisher->clientIsIdle = true;
++        channel.d_func()->publisher->setClientIsIdle(true, m_dummyTransport);
+         channel.d_func()->publisher->sendPendingPropertyUpdates();
+     }
+ }
+diff --git a/qtwebchannel/tests/auto/webchannel/tst_webchannel.h b/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
+index eae21f4..dd4e690 100644
+--- a/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
++++ b/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
+@@ -348,6 +348,7 @@ private slots:
+     void testJsonToVariant();
+     void testInfiniteRecursion();
+     void testAsyncObject();
++    void testPropertyMultipleTransports();
+     void testDeletionDuringMethodInvocation_data();
+     void testDeletionDuringMethodInvocation();
+ 
+Submodule qtwebengine f328054d...38e0df6c (commits not present)
+Submodule qtwebsockets 65850954..63fb8da1:
+diff --git a/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp b/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
+index 2affdd5..95f1194 100644
+--- a/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
++++ b/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
+@@ -273,6 +273,7 @@ void QWebSocketDataProcessor::clear()
+     if (!m_pConverterState)
+         m_pConverterState = new QTextCodec::ConverterState(QTextCodec::ConvertInvalidToNull |
+                                                            QTextCodec::IgnoreHeader);
++    frame.clear();
+ }
+ 
+ /*!
+diff --git a/qtwebsockets/src/websockets/qwebsocketprotocol.cpp b/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
+index df87a93..d0465f1 100644
+--- a/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
++++ b/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
+@@ -210,7 +210,7 @@ void QWebSocketProtocol::mask(char *payload, quint64 size, quint32 maskingKey)
+                             quint8((maskingKey & 0x0000FF00u) >> 8),
+                             quint8((maskingKey & 0x000000FFu))
+                           };
+-    int i = 0;
++    quint64 i = 0;
+     while (size-- > 0)
+         *payload++ ^= mask[i++ % 4];
+ }
diff --git a/srcpkgs/qt5/template b/srcpkgs/qt5/template
index a79d25e69da81..6dddce7f3e466 100644
--- a/srcpkgs/qt5/template
+++ b/srcpkgs/qt5/template
@@ -2,11 +2,11 @@
 #
 # revbump libqtxdg after bumping patch version
 pkgname=qt5
-version=5.15.7+20221119
+version=5.15.8
+revision=1
+build_style=meta
 # commit f8c9fb304bc3e53b3aa07f962cd74e9160decccc
 # base repo: https://invent.kde.org/qt/qt/qt5
-revision=5
-build_style=meta
 hostmakedepends="cmake clang flex perl glib-devel pkg-config
  python re2c ruby which"
 makedepends="SDL2-devel Vulkan-Headers alsa-lib-devel double-conversion-devel
@@ -29,8 +29,9 @@ homepage="https://qt.io/"
 # tarball is generated with `git archive-all qt5-$version.tar.gz`
 # to keep the size smaller qtwebengine, qtwebview, qtdocgallery, qtactiveqt and qtpim
 # can be marked with the export-ignore attribute
-distfiles="https://void.johnnynator.dev/distfiles/qt5-${version}.tar.gz"
-checksum=9d57af471c78029a362276b7c99108ea009f511bb9ba6ff6cb884f6ddd255e9f
+#distfiles="https://void.johnnynator.dev/distfiles/qt5-${version}.tar.gz"
+distfiles="https://download.qt.io/archive/qt/5.15/${version}/single/qt-everywhere-opensource-src-${version}.tar.xz"
+checksum=776a9302c336671f9406a53bd30b8e36f825742b2ec44a57c08217bff0fa86b9
 python_version=2 #unverified
 replaces="qt5-doc<5.6.0 qt5-quick1<5.6.0 qt5-quick1-devel<5.6.0 qt5-webkit<5.6.0 qt5-webkit-devel<5.6.0
  qt5-enginio<5.7.1 qt5-enginio-devel<5.7.1 qt5-plugin-gtk<5.7.1 qt5-canvas3d<5.13.0"
@@ -250,7 +251,6 @@ do_configure() {
 	# opts+=" -v"
 	opts+=" -skip qtwebengine"
 	opts+=" -skip qtwebview"
-	opts+=" -skip qtdocgallery"
 	opts+=" -skip qtpim"
 	opts+=" -skip qtsystems"
 	opts+=" -skip qtspeech"

From 52ef0159c44fb82acc909197a0fe84befe353c2b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 074/113] qtav: revbump for ffmpeg4-4.4.3

---
 srcpkgs/qtav/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtav/template b/srcpkgs/qtav/template
index 34c30b2c0c78f..2d00ad104355e 100644
--- a/srcpkgs/qtav/template
+++ b/srcpkgs/qtav/template
@@ -1,10 +1,10 @@
 # Template file for 'qtav'
 pkgname=qtav
 version=1.13.0
-revision=1
+revision=2
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel libass-devel libopenal-devel
+makedepends="ffmpeg4-devel libass-devel libopenal-devel
  libva-glx-devel libXv-devel pulseaudio-devel
  qt5-declarative-devel qt5-svg-devel
  qt5-quickcontrols"

From dd15cad93fb1db8137fc28438b0c6b702cc4f312 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 075/113] qtox: revbump for ffmpeg-6.0

---
 srcpkgs/qtox/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qtox/template b/srcpkgs/qtox/template
index 16019d7eaec9e..5cea0b11b6971 100644
--- a/srcpkgs/qtox/template
+++ b/srcpkgs/qtox/template
@@ -1,7 +1,7 @@
 # Template file for 'qtox'
 pkgname=qtox
 version=1.17.6
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DUPDATE_CHECK=OFF
  -DGIT_DESCRIBE=${version}

From b269d7490ba45ddb1d66e6b29af6316f9e508446 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 076/113] retroarch: revbump for ffmpeg-6.0

---
 srcpkgs/retroarch/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroarch/template b/srcpkgs/retroarch/template
index 28016aa0129e6..20a1415913be5 100644
--- a/srcpkgs/retroarch/template
+++ b/srcpkgs/retroarch/template
@@ -1,7 +1,7 @@
 # Template file for 'retroarch'
 pkgname=retroarch
 version=1.15.0
-revision=1
+revision=2
 build_style=configure
 configure_args="--prefix=/usr --sysconfdir=/etc --enable-networking
  --enable-udev --disable-builtinflac --disable-builtinglslang

From 68bb74463f82e707e44f844a081eac15521e99d8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 077/113] scrcpy: revbump for ffmpeg-6.0

---
 srcpkgs/scrcpy/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/scrcpy/template b/srcpkgs/scrcpy/template
index 06208c389ca97..a5de935c7def7 100644
--- a/srcpkgs/scrcpy/template
+++ b/srcpkgs/scrcpy/template
@@ -1,7 +1,7 @@
 # Template file for 'scrcpy'
 pkgname=scrcpy
 version=2.1
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcompile_server=false
  -Dprebuilt_server=/usr/share/scrcpy/scrcpy-server-v${version}"

From d2eb04eaab0e5f384fd694bacce0a066d8f4f276 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 078/113] spek-alternative: revbump for ffmpeg4-4.4.3

---
 srcpkgs/spek-alternative/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/spek-alternative/template b/srcpkgs/spek-alternative/template
index d65086b8f008c..05246f1b8d0c8 100644
--- a/srcpkgs/spek-alternative/template
+++ b/srcpkgs/spek-alternative/template
@@ -1,11 +1,11 @@
 # Template file for 'spek-alternative'
 pkgname=spek-alternative
 version=0.8.2.3
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake gettext-devel intltool libtool pkg-config wxWidgets-common"
-makedepends="ffmpeg-devel wxWidgets-gtk3-devel"
-depends="ffmpeg"
+makedepends="ffmpeg4-devel wxWidgets-gtk3-devel"
+depends="ffmpeg4"
 short_desc="Acoustic spectrum analyser"
 maintainer="Kartik Singh <kartik.ynwa@gmail.com>"
 license="GPL-3.0-or-later"

From fd8b544e72a1b17dcac619f1fb91242b71f118a3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 079/113] ssr: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ssr/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/ssr/template b/srcpkgs/ssr/template
index b055b9ec0774a..3448ca110eb0c 100644
--- a/srcpkgs/ssr/template
+++ b/srcpkgs/ssr/template
@@ -1,11 +1,11 @@
 # Template file for 'ssr'
 pkgname=ssr
 version=0.4.4
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_QT5=ON"
 hostmakedepends="pkg-config"
-makedepends="alsa-lib-devel ffmpeg-devel glu-devel jack-devel pulseaudio-devel
+makedepends="alsa-lib-devel ffmpeg4-devel glu-devel jack-devel pulseaudio-devel
  qt5-tools-devel qt5-x11extras-devel libXinerama-devel v4l-utils-devel"
 depends="desktop-file-utils hicolor-icon-theme"
 short_desc="Simple Screen Recorder for programs and games"

From 31b3cf3c1b4fe7a348c1a1a04a405f9f3585bc6b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 080/113] sumo: revbump for ffmpeg-6.0

---
 srcpkgs/sumo/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/sumo/template b/srcpkgs/sumo/template
index 0f9b9ec815f56..a3fe134aa5acc 100644
--- a/srcpkgs/sumo/template
+++ b/srcpkgs/sumo/template
@@ -1,7 +1,7 @@
 # Template file for 'sumo'
 pkgname=sumo
 version=1.12.0
-revision=5
+revision=6
 build_style=cmake
 hostmakedepends="libgdal-tools pkg-config swig python3-setuptools"
 makedepends="python3-devel ffmpeg-devel fox-devel gl2ps-devel libgdal-devel

From 563aec555538d866332807c30301f5b30cd537cc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 081/113] synfig: revbump for ffmpeg-6.0 and mlt7

---
 srcpkgs/synfig/patches/ffmpeg6.patch | 71 ++++++++++++++++++++++++++++
 srcpkgs/synfig/template              |  6 +--
 2 files changed, 74 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/synfig/patches/ffmpeg6.patch

diff --git a/srcpkgs/synfig/patches/ffmpeg6.patch b/srcpkgs/synfig/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..10780b42782f4
--- /dev/null
+++ b/srcpkgs/synfig/patches/ffmpeg6.patch
@@ -0,0 +1,71 @@
+--- a/src/modules/mod_libavcodec/trgt_av.cpp	2022-10-25 09:14:12.000000000 -0400
++++ b/src/modules/mod_libavcodec/trgt_av.cpp	2023-05-05 21:34:17.899194559 -0400
+@@ -38,6 +41,7 @@
+ extern "C"
+ {
+ #ifdef HAVE_LIBAVFORMAT_AVFORMAT_H
++#	include <libavcodec/avcodec.h>
+ #	include <libavformat/avformat.h>
+ #elif defined(HAVE_AVFORMAT_H)
+ #	include <avformat.h>
+@@ -155,11 +156,11 @@
+     }
+ 
+ 	bool open_video_stream() {
+-		if (avcodec_open2(video_context, NULL, NULL) < 0) {
++		if (avcodec_open2(video_context, nullptr, nullptr) < 0) {
+ 			synfig::error("Target_LibAVCodec: could not open video codec");
+ 			// seems the calling of avcodec_free_context after error will cause crash
+ 			// so just forget about this context
+-			video_context = NULL;
++			video_context = nullptr;
+ 			close();
+ 			return false;
+         }
+@@ -234,15 +235,21 @@
+ 		close();
+ 
+ 		if (!av_registered) {
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 			av_register_all();
++#endif
+ 			av_registered = true;
+ 		}
+ 
+ 		// guess format
+-		AVOutputFormat *format = av_guess_format(NULL, filename.c_str(), NULL);
++#if LIBAVCODEC_VERSION_MAJOR < 59 // FFMPEG < 5.0
++		AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#else
++		const AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#endif
+ 		if (!format) {
+ 			synfig::warning("Target_LibAVCodec: unable to guess the output format, defaulting to MPEG");
+-			format = av_guess_format("mpeg", NULL, NULL);
++			format = av_guess_format("mpeg", nullptr, nullptr);
+ 		}
+ 		if (!format) {
+ 			synfig::error("Target_LibAVCodec: unable to find 'mpeg' output format");
+@@ -254,6 +261,7 @@
+ 		context = avformat_alloc_context();
+ 		assert(context);
+ 		context->oformat = format;
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 		if (filename.size() + 1 > sizeof(context->filename)) {
+ 			synfig::error(
+ 				"Target_LibAVCodec: filename too long, max length is %d, filename is '%s'",
+@@ -263,6 +271,14 @@
+ 			return false;
+ 		}
+ 		memcpy(context->filename, filename.c_str(), filename.size() + 1);
++#else
++		context->url = av_strndup(filename.c_str(), filename.size());
++		if (!context->url) {
++			synfig::error("Target_LibAVCodec: cannot allocate space for filename");
++			close();
++			return false;
++		}
++#endif
+ 
+ 		packet = av_packet_alloc();
+ 		assert(packet);
diff --git a/srcpkgs/synfig/template b/srcpkgs/synfig/template
index 30109541ec4fc..703cfd7ebac84 100644
--- a/srcpkgs/synfig/template
+++ b/srcpkgs/synfig/template
@@ -2,11 +2,11 @@
 # Should be kept in sync with 'synfigstudio' and 'ETL'
 pkgname=synfig
 version=1.4.4
-revision=3
+revision=4
 build_style=gnu-configure
 configure_args="--with-boost-libdir=${XBPS_CROSS_BASE}/usr/lib"
 hostmakedepends="boost-build ImageMagick pkg-config intltool"
-makedepends="ETL gettext-devel libxml++-devel mlt-devel libmagick-devel
+makedepends="ETL gettext-devel libxml++-devel mlt7-devel libmagick-devel
  libmng-devel boost-build boost-devel libopenexr-devel ffmpeg-devel"
 depends="ImageMagick"
 short_desc="CLI 2D vector and timeline-based animation software"
@@ -20,7 +20,7 @@ CXXFLAGS="-std=c++11 -DHAVE_LOCALE_H=1"
 
 synfig-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision}
-	 libopenexr-devel libxml++-devel mlt-devel"
+	 libopenexr-devel libxml++-devel mlt7-devel"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/bin/synfig-config

From 8f104c14bd12fa6814b57e1fa5b86181a26e328b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 082/113] tg_owt: revbump for ffmpeg-6.0

---
 srcpkgs/tg_owt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tg_owt/template b/srcpkgs/tg_owt/template
index 97d195ddb34a3..551614b24956c 100644
--- a/srcpkgs/tg_owt/template
+++ b/srcpkgs/tg_owt/template
@@ -1,7 +1,7 @@
 # Template file for 'tg_owt'
 pkgname=tg_owt
 version=0.0.0.20230107
-revision=1
+revision=2
 _commit=5098730b9eb6173f0b52068fe2555b7c1015123a
 _libyuv_commit=00950840d1c9bcbb3eb6ebc5aac5793e71166c8b
 _abseil_commit=8c0b94e793a66495e0b1f34a5eb26bd7dc672db0

From d90fbee0d8e648a0f8989b9bea122a18cd7d7155 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 083/113] timg: revbump for ffmpeg-6.0

---
 srcpkgs/timg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/timg/template b/srcpkgs/timg/template
index 2a2ab763d2fdd..8fb4327535ef9 100644
--- a/srcpkgs/timg/template
+++ b/srcpkgs/timg/template
@@ -1,7 +1,7 @@
 # Template file for 'timg'
 pkgname=timg
 version=1.4.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_OPENSLIDE_SUPPORT=off -Wno-dev"
 hostmakedepends="pkg-config git"

From e5933e58d81fdf1af3da92996415344d38044097 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 084/113] tvheadend: revbump for ffmpeg4-4.4.3

---
 srcpkgs/tvheadend/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/tvheadend/template b/srcpkgs/tvheadend/template
index e6b16d7ccf3bd..46b52b6fb7f94 100644
--- a/srcpkgs/tvheadend/template
+++ b/srcpkgs/tvheadend/template
@@ -1,14 +1,14 @@
 # Template file for 'tvheadend'
 pkgname=tvheadend
 version=4.2.8
-revision=6
+revision=7
 build_style=gnu-configure
 configure_args="--enable-dvbscan --disable-ffmpeg_static
 --disable-hdhomerun_static --disable-bintray_cache --disable-libx264_static
 --disable-libx265_static --disable-libvpx_static --disable-libtheora_static
 --disable-libvorbis_static --disable-libfdkaac_static"
 hostmakedepends="gettext pkg-config python git which"
-makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg-devel"
+makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg4-devel"
 short_desc="TV streaming server"
 maintainer="lemmi <lemmi@nerd2nerd.org>"
 license="GPL-3.0-only"

From bd12aed176788502899def52d285207da7ec1d0b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 085/113] unpaper: update to 7.0.0.

---
 srcpkgs/unpaper/template | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/srcpkgs/unpaper/template b/srcpkgs/unpaper/template
index 38ed47a584016..1ff910e722afc 100644
--- a/srcpkgs/unpaper/template
+++ b/srcpkgs/unpaper/template
@@ -1,13 +1,13 @@
 # Template file for 'unpaper'
 pkgname=unpaper
-version=6.1
-revision=3
-build_style=gnu-configure
+version=7.0.0
+revision=1
+build_style=meson
+hostmakedepends="pkg-config meson libxslt"
+makedepends="ffmpeg-devel python3-Sphinx"
+short_desc="Post-processing tool for scanned sheets of paper"
 maintainer="Orphaned <orphan@voidlinux.org>"
-hostmakedepends="pkg-config libxslt"
-makedepends="ffmpeg-devel"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://www.flameeyes.eu/projects/unpaper"
-short_desc="A post-processing tool for scanned sheets of paper"
 distfiles="https://www.flameeyes.eu/files/${pkgname}-${version}.tar.xz"
-checksum=237c84f5da544b3f7709827f9f12c37c346cdf029b1128fb4633f9bafa5cb930
+checksum=2575fbbf26c22719d1cb882b59602c9900c7f747118ac130883f63419be46a80

From a16ccc3aead4f216cabe70cc9b6e1a670169f056 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 086/113] vba-m: revbump for ffmpeg-6.0

---
 srcpkgs/vba-m/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vba-m/template b/srcpkgs/vba-m/template
index ba153e0b58ca4..aa6093645e974 100644
--- a/srcpkgs/vba-m/template
+++ b/srcpkgs/vba-m/template
@@ -2,7 +2,7 @@
 pkgname=vba-m
 reverts=1292_2
 version=2.1.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_GTK=TRUE -DENABLE_FFMPEG=TRUE -DENABLE_LINK=TRUE -DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="gettext pkg-config unzip zip yasm wxWidgets-gtk3-devel"

From c2ae4fc5118fcbe0b9bc7d57f40857c423338a92 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 087/113] vice: revbump for ffmpeg4-4.4.3

---
 srcpkgs/vice/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/vice/template b/srcpkgs/vice/template
index fe9d33a811947..4beab2c5f9ebd 100644
--- a/srcpkgs/vice/template
+++ b/srcpkgs/vice/template
@@ -1,7 +1,7 @@
 # Template file for 'vice'
 pkgname=vice
 version=3.7.1
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="
 	$(vopt_enable sdl2 sdlui2)
@@ -26,7 +26,7 @@ makedepends="
 	$(vopt_if gtk3 gtk+3-devel)
 	$(vopt_if gtk3 pulseaudio-devel)
 	$(vopt_if gtk3 pango-devel)
-	$(vopt_if ffmpeg ffmpeg-devel)"
+	$(vopt_if ffmpeg ffmpeg4-devel)"
 short_desc="Emulator for C64, C128, CBM-II, PET, VIC20, Plus4 and C16"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"

From d105dd5fd3b3eaba2004e733e6de66cc64af9109 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 088/113] waypipe: revbump for ffmpeg-6.0

---
 srcpkgs/waypipe/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waypipe/template b/srcpkgs/waypipe/template
index 5c4161900060a..1a46fe27f7d83 100644
--- a/srcpkgs/waypipe/template
+++ b/srcpkgs/waypipe/template
@@ -1,7 +1,7 @@
 # Template file for 'waypipe'
 pkgname=waypipe
 version=0.8.4
-revision=1
+revision=2
 build_style=meson
 # lto is off because it causes linking errors in armv6l and armv7l (due to NEON)
 configure_args="-Dwerror=false -Dwith_dmabuf=enabled -Dwith_lz4=enabled

From 151279f8084d6155932cb14f1d336a731185ac92 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 089/113] wf-recorder: revbump for ffmpeg-6.0

---
 srcpkgs/wf-recorder/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/wf-recorder/template b/srcpkgs/wf-recorder/template
index e278eb001600f..5d014a5f28afb 100644
--- a/srcpkgs/wf-recorder/template
+++ b/srcpkgs/wf-recorder/template
@@ -1,7 +1,7 @@
 # Template file for 'wf-recorder'
 pkgname=wf-recorder
 version=0.3.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config scdoc wayland-devel"
 makedepends="wayland-protocols wayland-devel ffmpeg-devel x264-devel

From f7a5c5a9dbbb4f4a410f371757c464b96366020e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 090/113] xpra: revbump for ffmpeg-6.0

---
 srcpkgs/xpra/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xpra/template b/srcpkgs/xpra/template
index 0a63fdb6c7437..d5acc1981c5f6 100644
--- a/srcpkgs/xpra/template
+++ b/srcpkgs/xpra/template
@@ -1,7 +1,7 @@
 # Template file for 'xpra'
 pkgname=xpra
 version=4.4.6
-revision=1
+revision=2
 build_style=python3-module
 make_build_args="--without-cuda_kernels --without-cuda_rebuild"
 make_install_args="$(vopt_with docs) ${make_build_args}"

From de5dbf9c0b50eae5aa6ec6cd0dda2343ad00d793 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:07:40 -0400
Subject: [PATCH 091/113] nv-codec-headers: update to 12.0.16.0

---
 srcpkgs/nv-codec-headers/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/nv-codec-headers/template b/srcpkgs/nv-codec-headers/template
index 3d422a61e4891..251e057f826fb 100644
--- a/srcpkgs/nv-codec-headers/template
+++ b/srcpkgs/nv-codec-headers/template
@@ -1,6 +1,6 @@
 # Template file for 'nv-codec-headers'
 pkgname=nv-codec-headers
-version=11.1.5.1
+version=12.0.16.0
 revision=1
 build_style=gnu-makefile
 short_desc="FFmpeg version of headers required to interface with Nvidias codec APIs"
@@ -8,7 +8,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="MIT"
 homepage="http://git.videolan.org/?p=ffmpeg/nv-codec-headers.git"
 distfiles="https://github.com/FFmpeg/nv-codec-headers/archive/n${version}.tar.gz"
-checksum=d095fbd56aa93772471a323be0ebe65504a0f43f06c76a30b6d25da77b06ae9c
+checksum=2a1533b65f55f9da52956faf0627ed3b74868ac0c7f269990edd21369113b48f
 
 post_install() {
 	sed -n '4,25p' include/ffnvcodec/nvEncodeAPI.h > LICENSE

From 1556611d06d728708ad5c3b93d163918f3c853df Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:08:40 -0400
Subject: [PATCH 092/113] openimagedenoise: revbump for ffmpeg-6.0

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index db5ccdb055cc9..cb90045afb634 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,7 +1,7 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
 version=1.4.3
-revision=1
+revision=2
 archs="x86_64*"
 build_style=cmake
 hostmakedepends="ispc python3"

From f8852d7617fcf0654653595f4e122e49acb8fd50 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:31:45 -0400
Subject: [PATCH 093/113] shotcut: revbump for ffmpeg-6.0

---
 srcpkgs/shotcut/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/shotcut/template b/srcpkgs/shotcut/template
index 7d2af7b0470b5..c416c906ff734 100644
--- a/srcpkgs/shotcut/template
+++ b/srcpkgs/shotcut/template
@@ -1,7 +1,7 @@
 # Template file for 'shotcut'
 pkgname=shotcut
 version=23.05.14
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSHOTCUT_VERSION=${version}"
 hostmakedepends="pkg-config qt6-tools-devel"

From 2dfb526423364e94ca9944c4f605e1c61faff88e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:30 -0400
Subject: [PATCH 094/113] shiboken2: revbump for qt5-5.15.8

---
 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch | 1 +
 srcpkgs/shiboken2/template                                 | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
 create mode 120000 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
new file mode 120000
index 0000000000000..efcf3249bd885
--- /dev/null
+++ b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1 @@
+../../python3-pyside2/patches/importlib-machinery-bypass.patch
\ No newline at end of file
diff --git a/srcpkgs/shiboken2/template b/srcpkgs/shiboken2/template
index 084ecc3ba1e1c..2a21998997eb1 100644
--- a/srcpkgs/shiboken2/template
+++ b/srcpkgs/shiboken2/template
@@ -1,7 +1,7 @@
 # Template file for 'shiboken2'
 pkgname=shiboken2
 version=5.15.7
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/shiboken2"
 build_style=cmake

From 0d1f7b19091988d4dd0d60ff0942bde93054826d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:53 -0400
Subject: [PATCH 095/113] python3-pyside2: update to 5.15.8

---
 .../patches/importlib-machinery-bypass.patch      | 15 +++++++++++++++
 srcpkgs/python3-pyside2/template                  |  9 +++++----
 2 files changed, 20 insertions(+), 4 deletions(-)
 create mode 100644 srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
new file mode 100644
index 0000000000000..64c429584776b
--- /dev/null
+++ b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1,15 @@
+Using this prevents an error around line 220 below it.
+"AttributeError: module 'importlib' has no attribute 'machinery'"
+The old backup logic is in place and compiles without issues.
+--- a/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:09:34.688912402 -0400
++++ b/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:10:03.395529582 -0400
+@@ -170,9 +170,6 @@
+
+     # 'zipstring_sequence' comes from signature.cpp
+     zipbytes = base64.b64decode(''.join(zipstring_sequence))
+-    if sys.version_info[0] >= 3:
+-        vzip = zipfile.ZipFile(io.BytesIO(zipbytes))
+-        return sys.meta_path, EmbeddableZipImporter(vzip)
+
+     # Old version for Python 2.7, only.
+     import os
diff --git a/srcpkgs/python3-pyside2/template b/srcpkgs/python3-pyside2/template
index 50e6ff260d3b5..b50e62bd215d4 100644
--- a/srcpkgs/python3-pyside2/template
+++ b/srcpkgs/python3-pyside2/template
@@ -1,11 +1,12 @@
 # Template file for 'python3-pyside2'
 pkgname=python3-pyside2
-version=5.15.5
-revision=2
+version=5.15.8
+revision=1
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/pyside2"
 build_style=cmake
-configure_args="-DPYTHON_EXECUTABLE=/usr/bin/python"
+configure_args="-DPYTHON_EXECUTABLE=/usr/bin/python -DCMAKE_BUILD_TYPE=None
+ -DBUILD_TESTS=OFF"
 hostmakedepends="cmake python3 shiboken2"
 makedepends="python3-devel libshiboken2-devel qt5-devel
  qt5-multimedia-devel qt5-tools-devel qt5-plugin-mysql qt5-plugin-odbc
@@ -23,7 +24,7 @@ maintainer="yopito <pierre.bourgin@free.fr>"
 license="LGPL-3.0-or-later"
 homepage="https://wiki.qt.io/Qt_for_Python"
 distfiles="https://download.qt.io/official_releases/QtForPython/pyside2/PySide2-${version}-src/${_pkgname}.tar.xz"
-checksum=3920a4fb353300260c9bc46ff70f1fb975c5e7efa22e9d51222588928ce19b33
+checksum=23436302c8deb5b4cbc769b205d09604e38ba83b40708efccb7bd8c9af6f6b5d
 
 build_options="webengine"
 desc_option_webengine="Build Qt5 WebEngine bindings"

From 4ab6c589a9b32e45b3ed8e994991fccaf7aa506e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:35 -0400
Subject: [PATCH 096/113] konqueror: revbump for ffmpeg-6.0

---
 srcpkgs/konqueror/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/konqueror/template b/srcpkgs/konqueror/template
index d8d0e73a78ab2..c5bdba601d3c3 100644
--- a/srcpkgs/konqueror/template
+++ b/srcpkgs/konqueror/template
@@ -1,11 +1,11 @@
 # Template file for 'konqueror'
 pkgname=konqueror
 version=23.04.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DDESKTOPTOJSON_EXECUTABLE=/usr/bin/desktoptojson"
 hostmakedepends="extra-cmake-modules python3 qt5-host-tools qt5-qmake kdoctools
-kcoreaddons kconfig gettext"
+ kcoreaddons kconfig gettext"
 makedepends="qt5-devel qt5-webengine-devel qt5-declarative-devel
  qt5-webchannel-devel qt5-location-devel kcmutils-devel kdelibs4support-devel
  karchive-devel khtml-devel kdesu-devel kactivities5-devel"

From 2cc3ab42db4985dfcfa8ee81132cc7655f9dc7d2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:58 -0400
Subject: [PATCH 097/113] qt5-speech: revbump for qt5-5.15.8

---
 srcpkgs/qt5-speech/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-speech/template b/srcpkgs/qt5-speech/template
index 3ecd10d50650c..2d7d4d4d24535 100644
--- a/srcpkgs/qt5-speech/template
+++ b/srcpkgs/qt5-speech/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-speech'
 pkgname=qt5-speech
 version=5.15.7
-revision=2
+revision=3
 _commit=d32f4a479d38a11f547598004b975f4356424a16
 build_style=qmake
 configure_args="-- -flite -flite-alsa -speechd"

From b40e884b4edbeb1ad3b020cc271e890d80bd0bd4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 18:38:50 -0400
Subject: [PATCH 098/113] qt5-styleplugins: revbump for qt5-5.15.8

---
 srcpkgs/qt5-styleplugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-styleplugins/template b/srcpkgs/qt5-styleplugins/template
index 96ed97d12cd24..30d93660a2a4e 100644
--- a/srcpkgs/qt5-styleplugins/template
+++ b/srcpkgs/qt5-styleplugins/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-styleplugins'
 pkgname=qt5-styleplugins
 version=5.0.0
-revision=20
+revision=21
 _gitrev=335dbece103e2cbf6c7cf819ab6672c2956b17b3
 build_style=qmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From 2bb7bdab351f238449b4ff5c345454973f2c2f77 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 7 May 2023 20:14:14 -0400
Subject: [PATCH 099/113] mlt7: revbump for ffmpeg-6.0

---
 srcpkgs/gst-libav/template | 2 +-
 srcpkgs/mlt7/template      | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index 04c39bff14896..8c72fc3e97eee 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.22.2
-revision=2
+revision=1
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"
diff --git a/srcpkgs/mlt7/template b/srcpkgs/mlt7/template
index 9fb7f60d692e1..cca0eb68cfc31 100644
--- a/srcpkgs/mlt7/template
+++ b/srcpkgs/mlt7/template
@@ -1,7 +1,7 @@
 # Template file for 'mlt7'
 pkgname=mlt7
 version=7.14.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSWIG_PYTHON=ON"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which

From f7479599731801a9df9f5c86797ed646c0ab7fc8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 7 May 2023 20:15:03 -0400
Subject: [PATCH 100/113] qt6-webengine: revbump for ffmpeg-6.0

---
 srcpkgs/qt6-webengine/template | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-webengine/template b/srcpkgs/qt6-webengine/template
index 4e22cb6e88638..43778b568d3f0 100644
--- a/srcpkgs/qt6-webengine/template
+++ b/srcpkgs/qt6-webengine/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-webengine'
 pkgname=qt6-webengine
 version=6.5.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="
  -DQT_FEATURE_webengine_system_ffmpeg=ON
@@ -145,6 +145,7 @@ pre_install() {
 }
 
 post_install() {
+	vlicense LICENSES/BSD-3-Clause.txt
 	local _file
 	find "${DESTDIR}"/usr/lib/qt6/examples \
 		-path '*/lib/qt6/**/lib/qt6/*' -type f |

From af0fc7186195f2dd54aa1d49c608af3b6933a3b2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 7 May 2023 20:15:29 -0400
Subject: [PATCH 101/113] tracker-miners: revbump for ffmpeg-6.0

---
 srcpkgs/tracker-miners/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tracker-miners/template b/srcpkgs/tracker-miners/template
index 8c005d697fa42..a6e5aa5777024 100644
--- a/srcpkgs/tracker-miners/template
+++ b/srcpkgs/tracker-miners/template
@@ -1,7 +1,7 @@
 # Template file for 'tracker-miners'
 pkgname=tracker-miners
 version=3.5.0
-revision=3
+revision=4
 build_style=meson
 build_helper=qemu
 # missing libgrss for miner_rss

From aace09b716adad8a8837ce8239ab7ae78238b148 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 7 May 2023 20:20:58 -0400
Subject: [PATCH 102/113] mpd: revbump for ffmpeg-6.0

---
 srcpkgs/mpd/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpd/template b/srcpkgs/mpd/template
index 9dbd4c935acc5..9f058b62df2f3 100644
--- a/srcpkgs/mpd/template
+++ b/srcpkgs/mpd/template
@@ -1,7 +1,7 @@
 # Template file for 'mpd'
 pkgname=mpd
 version=0.23.13
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dopus=enabled -Dmikmod=enabled -Dneighbor=true
  -Dsoundcloud=enabled -Dpipe=true -Dtwolame=enabled -Dbzip2=enabled

From 8148c06c336f3661026b351d8746b5ebdb9a31f6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 11 May 2023 14:05:14 -0400
Subject: [PATCH 103/113] openmw: revbump for ffmpeg-6.0

---
 srcpkgs/openmw/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openmw/template b/srcpkgs/openmw/template
index e3771c7aaf1a3..3cbf20b065770 100644
--- a/srcpkgs/openmw/template
+++ b/srcpkgs/openmw/template
@@ -1,7 +1,7 @@
 # Template file for 'openmw'
 pkgname=openmw
 version=0.47.0
-revision=5
+revision=6
 build_style=cmake
 _recast_commit=e75adf86f91eb3082220085e42dda62679f9a3ea
 _bullet_tag=3.17

From 3ae478f545319b0a084e5de62a04182477db8420 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 21 May 2023 12:44:11 -0400
Subject: [PATCH 104/113] electron24: revbump for ffmpeg-6.0

---
 srcpkgs/electron24/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron24/template b/srcpkgs/electron24/template
index bdaa56adc8a65..ff3d5e3ef3819 100644
--- a/srcpkgs/electron24/template
+++ b/srcpkgs/electron24/template
@@ -1,7 +1,7 @@
 # Template file for 'electron24'
 pkgname=electron24
 version=24.3.0
-revision=1
+revision=2
 _nodever=18.14.0
 _chromiumver=112.0.5615.165
 archs="x86_64* aarch64*"

From 260a0de07b8abb268c2449906020ecef53399403 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Jun 2023 08:20:22 -0400
Subject: [PATCH 105/113] gtk4: revbump for ffmpeg-6.0

---
 srcpkgs/gtk4/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gtk4/template b/srcpkgs/gtk4/template
index b318b7bae1dd9..e3bde4a50e547 100644
--- a/srcpkgs/gtk4/template
+++ b/srcpkgs/gtk4/template
@@ -1,7 +1,7 @@
 # Template file for 'gtk4'
 pkgname=gtk4
 version=4.10.4
-revision=1
+revision=2
 build_style=meson
 build_helper="gir"
 configure_args="-Dman-pages=true -Dgtk_doc=true -Dbuild-tests=false

From 2fff7795a117b701f8aed96f1b85b749f8fe34e9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:25:50 -0400
Subject: [PATCH 106/113] electron19: revbump for ffmpeg-6.0

---
 srcpkgs/electron19/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron19/template b/srcpkgs/electron19/template
index 32ce301e730cf..ab7f308f5e8a6 100644
--- a/srcpkgs/electron19/template
+++ b/srcpkgs/electron19/template
@@ -1,7 +1,7 @@
 # Template file for 'electron19'
 pkgname=electron19
 version=19.0.8
-revision=3
+revision=4
 _nodever=16.14.2
 _chromiumver=102.0.5005.125
 archs="x86_64* aarch64* ppc64le*"

From 436c3593b4de1306fedc6c9970e54fe2e76a973c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:28:26 -0400
Subject: [PATCH 107/113] siril: revbump for ffmpeg-6.0

---
 srcpkgs/siril/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/siril/template b/srcpkgs/siril/template
index 84332f79d060d..62750dd247548 100644
--- a/srcpkgs/siril/template
+++ b/srcpkgs/siril/template
@@ -1,7 +1,7 @@
 # Template file for 'siril'
 pkgname=siril
 version=0.9.12
-revision=10
+revision=11
 build_style=gnu-configure
 hostmakedepends="pkg-config intltool autoconf automake gettext-devel"
 makedepends="fftw-devel libconfig-devel libopencv-devel libffms2-devel

From 0b990327b9a78d884dfbecca83381cec88e8522e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:29:08 -0400
Subject: [PATCH 108/113] telegram-desktop: revbump for ffmpeg-6.0

---
 srcpkgs/telegram-desktop/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/telegram-desktop/template b/srcpkgs/telegram-desktop/template
index f114b2341dc5d..9db9f80c1a53f 100644
--- a/srcpkgs/telegram-desktop/template
+++ b/srcpkgs/telegram-desktop/template
@@ -1,7 +1,7 @@
 # Template file for 'telegram-desktop'
 pkgname=telegram-desktop
 version=4.8.1
-revision=3
+revision=4
 build_style=cmake
 build_helper="qemu"
 configure_args="-DTDESKTOP_API_ID=209235

From 32bddfce752f56d62ae7731a1bd32f8332e4c19a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 10 Jun 2023 00:40:39 -0400
Subject: [PATCH 109/113] freecad: revbump for qt5-webengine-5.15.13

---
 srcpkgs/freecad/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/freecad/template b/srcpkgs/freecad/template
index a4a3f5f76b29a..8608d1670c87f 100644
--- a/srcpkgs/freecad/template
+++ b/srcpkgs/freecad/template
@@ -1,7 +1,7 @@
 # Template file for 'freecad'
 pkgname=freecad
 version=0.20.2
-revision=5
+revision=6
 build_style=cmake
 
 _inst_prefix=/usr/lib/${pkgname}

From b28420ab0d07cf1839aa12c4b26f578488e6f8c3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 10 Jun 2023 00:57:09 -0400
Subject: [PATCH 110/113] qt6-multimedia: revbump for ffmpeg-6.0

---
 srcpkgs/qt6-multimedia/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-multimedia/template b/srcpkgs/qt6-multimedia/template
index a6832fdd69bfe..c9ffac914ab8f 100644
--- a/srcpkgs/qt6-multimedia/template
+++ b/srcpkgs/qt6-multimedia/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-multimedia'
 pkgname=qt6-multimedia
 version=6.5.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DQT_FEATURE_gstreamer=ON"
 hostmakedepends="perl qt6-declarative-host-tools pkg-config qt6-shadertools"

From 5227c40079c5436277e8990c49ddd4566b9c7398 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 22 Jun 2023 10:25:02 -0400
Subject: [PATCH 111/113] kdenlive: revbump for ffmpeg-6.0

---
 srcpkgs/kdenlive/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kdenlive/template b/srcpkgs/kdenlive/template
index 89c0dcfb8577f..75495b3a35869 100644
--- a/srcpkgs/kdenlive/template
+++ b/srcpkgs/kdenlive/template
@@ -1,7 +1,7 @@
 # Template file for 'kdenlive'
 pkgname=kdenlive
 version=23.04.2
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="
  extra-cmake-modules kconfig kcoreaddons kdoctools pkg-config python3

From 26ed98327822d58d4d67dd569cdf941be2ec63ce Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Jul 2023 09:18:23 -0400
Subject: [PATCH 112/113] gmic: revbump for opencv-4.7.0

---
 srcpkgs/gmic/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gmic/template b/srcpkgs/gmic/template
index 0bb4034d5cc86..808953e9b543c 100644
--- a/srcpkgs/gmic/template
+++ b/srcpkgs/gmic/template
@@ -1,7 +1,7 @@
 # Template file for 'gmic'
 pkgname=gmic
 version=3.1.6
-revision=4
+revision=5
 _zart_hash=34ebf6cce0bafb98abe57cec83c4a02cd1abeca0
 create_wrksrc=yes
 build_wrksrc="src"

From 318e0c525f9afa8d9036dbba76cafcc0a952de4c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Jul 2023 09:29:52 -0400
Subject: [PATCH 113/113] synfigstudio: revbump for synfig mlt7

---
 srcpkgs/synfigstudio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/synfigstudio/template b/srcpkgs/synfigstudio/template
index af1c5a296ef0f..09e442da9a680 100644
--- a/srcpkgs/synfigstudio/template
+++ b/srcpkgs/synfigstudio/template
@@ -2,7 +2,7 @@
 # Should be kept in sync with 'synfig' and 'ETL'
 pkgname=synfigstudio
 version=1.4.4
-revision=3
+revision=4
 build_style=gnu-configure
 configure_args="--disable-update-mimedb"
 hostmakedepends="pkg-config intltool gettext synfig"

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (15 preceding siblings ...)
  2023-07-04 13:30 ` zlice
@ 2023-07-04 14:18 ` zlice
  2023-07-04 14:19 ` zlice
                   ` (80 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2023-07-04 14:18 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 3488 bytes --]

There is an updated pull request by zlice against master on the void-packages repository

https://github.com/zlice/void-packages ffmpeg6-split
https://github.com/void-linux/void-packages/pull/43761

ffmpeg6 split
[ci skip]


#### Testing the changes

- I tested the changes in this PR: **YES**

main testing has been vaapi in Firefox Nightly and enc/dec in Shotcut on Intel A770

#### New package

- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**

#### Local build testing

- I built this PR locally for my native architecture, **x86_64**

#### Discussion

Continuation of https://github.com/void-linux/void-packages/pull/36315

`libavresample` is deprecated, but marked as a dependency when trying to build other packages and install `ffmpeg`(6). I think the right way to handle this is make a meta package and the add to removals?


##### Commit naming / misc

~~Commits are 'dirty' right now, running with [gstreamer 1.22.1 updates](https://github.com/void-linux/void-packages/pull/42861) and [Intel OpenCL](https://github.com/void-linux/void-packages/pull/43084). This will also make [intel packages pr](https://github.com/void-linux/void-packages/pull/41132) obsolete.~~ (see Requirements below)

Maintainer for previous ffmpeg(4) was orphaned, I can put my name in there if that matters, though I don't exactly see myself keeping up on ffmpeg.

This updates QT5 which looks like it is usually hosted by Johnny. Not sure if there's any reason to stay there or these sources are fine.

##### STILL FFMPEG4

These are a mix of emulators, games and/or older packages.

- attract (multiple patches in master)
- audacity (https://github.com/audacity/audacity/issues/2305 and https://sourceforge.net/p/portmedia/wiki/portsmf/ is 'beta')
- ccextractor (master patches? no release)
- vice
- kodi
- mlt (only dep left is flowblade)
- ~~synfig (mlt)~~ (work with mlt7, bump synfigstudio)
- tvheadend
- ssr
- spek-alternative
- ppsspp
- olive
- moc
- mediastreamer
- libextractor
- idjc
- hedgewars
- ~~ffmpegthumbnailer~~ (patches for moviedecoder.xxx files)
- ~~ffmpegthumbs~~ (latest compiles)
- deadbeef
- omxplayer
- qtav (fork has ffmpeg 5 patch - https://github.com/cmguo/QtAV)
- `vlc` (vlc4 will support ffmpeg5, there's a patch to build 3.x with ffmpeg5 but it will lack vaapi)
- `osg` (OpenSceneGraph plus `xine-lib`)


##### HAVE NOT BUILT YET

- omxplayer (rpi only? ffmpeg4)
- kodi (big, but ffmpeg4)


##### UPDATED (for ffmpeg6)

- ~~blender: update to 3.5.1~~ ~~will be revbump with~~ https://github.com/void-linux/void-packages/pull/43992
- unpaper: update to 7.0.0.
- guvcview: update to 2.0.8.
- qt5: update to 5.15.8
- qt5-webengine: update to 5.18.13
- shiboken2: revbump for qt5.15.8 (patch)
- python3-pyside2: update to 5.15.8 (patch)


##### Requirements

- ~~[gstreamer 1.22.2](https://github.com/void-linux/void-packages/pull/42861)~~ - a few packages use ffmpeg-devel and require a revbump

- [Intel Packages](https://github.com/void-linux/void-packages/pull/41132) - ffmpeg4 uses different libraries than 6 (libmfx / Intel-MediaSDK vs only oneVPL that Intel is moving to), both are included here

- ~~[shotcut 23.05.14](https://github.com/void-linux/void-packages/pull/44260)~~

A patch file from https://github.com/void-linux/void-packages/pull/43761.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ffmpeg6-split-43761.patch --]
[-- Type: text/x-diff, Size: 780046 bytes --]

From 489ef8091f17bb172622bbbcc8f58fcdfac1a5ba Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:55:46 -0400
Subject: [PATCH 001/113] ffmpeg: update to 6.0.

---
 common/shlibs                                 | 26 +++++---
 srcpkgs/ffmpeg/files/altivec.patch            | 60 -------------------
 .../patches/armv5tel-floating-point.patch     | 18 ------
 .../workaround-mesa-readeon-vaapi-bug.patch   | 28 ---------
 srcpkgs/ffmpeg/template                       | 41 +++++--------
 5 files changed, 33 insertions(+), 140 deletions(-)
 delete mode 100644 srcpkgs/ffmpeg/files/altivec.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch

diff --git a/common/shlibs b/common/shlibs
index 4e6a5a663fa02..a77346cce3e9a 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -387,15 +387,23 @@ libid3tag.so.0 libid3tag-0.15.1b_1
 libgif.so.7 giflib-5.1.0_1
 libImlib2.so.1 imlib2-1.4.2_1
 libmp3lame.so.0 lame-3.98.2_1
-libavdevice.so.58 libavdevice-4.0_1
-libavformat.so.58 libavformat-4.0_1
-libswscale.so.5 libswscale-4.0_1
-libswresample.so.3 libswresample-4.0_1
-libavresample.so.4 libavresample-4.0_1
-libpostproc.so.55 libpostproc-4.0_1
-libavcodec.so.58 libavcodec-4.0_1
-libavutil.so.56 libavutil-4.0_1
-libavfilter.so.7 libavfilter-4.0_1
+libavdevice.so.60 libavdevice-6.0_1
+libavformat.so.60 libavformat-6.0_1
+libswscale.so.7 libswscale-6.0_1
+libswresample.so.4 libswresample-6.0_1
+libpostproc.so.57 libpostproc-6.0_1
+libavcodec.so.60 libavcodec-6.0_1
+libavutil.so.58 libavutil-6.0_1
+libavfilter.so.9 libavfilter-6.0_1
+libavdevice.so.58 libavdevice4-4.0_1
+libavformat.so.58 libavformat4-4.0_1
+libswscale.so.5 libswscale4-4.0_1
+libswresample.so.3 libswresample4-4.0_1
+libavresample.so.4 libavresample4-4.0_1
+libpostproc.so.55 libpostproc4-4.0_1
+libavcodec.so.58 libavcodec4-4.0_1
+libavutil.so.56 libavutil4-4.0_1
+libavfilter.so.7 libavfilter4-4.0_1
 libSDL-1.2.so.0 SDL-1.2.14_1
 libSDL_image-1.2.so.0 SDL_image-1.2.10_1
 libx264.so.157 x264-20190507.2245_1
diff --git a/srcpkgs/ffmpeg/files/altivec.patch b/srcpkgs/ffmpeg/files/altivec.patch
deleted file mode 100644
index 9c57200463320..0000000000000
--- a/srcpkgs/ffmpeg/files/altivec.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-revert some altivec specific change on all ppc* except ppc64le*
-
-q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
-conditionally, for ppc* but not ppc64le* (the new code is valid for
-POWER8 VSX which LE targets as a baseline but not BE)"
-
-
-This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
----
- libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
- 1 file changed, 20 insertions(+), 4 deletions(-)
-
-diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
-index 536545293d..c1e2852adb 100644
---- a/libswscale/ppc/yuv2rgb_altivec.c
-+++ b/libswscale/ppc/yuv2rgb_altivec.c
-@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-     vector signed short R1, G1, B1;                                           \
-     vector unsigned char R, G, B;                                             \
-                                                                               \
-+    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
-+    vector unsigned char align_perm;                                          \
-+                                                                              \
-     vector signed short lCY       = c->CY;                                    \
-     vector signed short lOY       = c->OY;                                    \
-     vector signed short lCRV      = c->CRV;                                   \
-@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
-                                                                               \
-         for (j = 0; j < w / 16; j++) {                                        \
--            y0 = vec_xl(0, y1i);                                              \
-+            y1ivP = (const vector unsigned char *) y1i;                       \
-+            y2ivP = (const vector unsigned char *) y2i;                       \
-+            uivP  = (const vector unsigned char *) ui;                        \
-+            vivP  = (const vector unsigned char *) vi;                        \
-+                                                                              \
-+            align_perm = vec_lvsl(0, y1i);                                    \
-+            y0 = (vector unsigned char)                                       \
-+                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
-                                                                               \
--            y1 = vec_xl(0, y2i);                                              \
-+            align_perm = vec_lvsl(0, y2i);                                    \
-+            y1 = (vector unsigned char)                                       \
-+                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
-                                                                               \
--            u = (vector signed char) vec_xl(0, ui);                           \
-+            align_perm = vec_lvsl(0, ui);                                     \
-+            u = (vector signed char)                                          \
-+                    vec_perm(uivP[0], uivP[1], align_perm);                   \
-                                                                               \
--            v = (vector signed char) vec_xl(0, vi);                           \
-+            align_perm = vec_lvsl(0, vi);                                     \
-+            v = (vector signed char)                                          \
-+                    vec_perm(vivP[0], vivP[1], align_perm);                   \
-                                                                               \
-             u = (vector signed char)                                          \
-                     vec_sub(u,                                                \
--- 
-2.27.0
-
diff --git a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
deleted file mode 100644
index 9a55178c74f0f..0000000000000
--- a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
-+++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
-@@ -39,6 +39,15 @@
- #endif
- #include <fenv.h>
- 
-+#if (FE_ALL_EXCEPT == 0)
-+/* E.g. ARM soft float does not define these */
-+#define FE_INVALID    0
-+#define FE_DIVBYZERO  0
-+#define FE_OVERFLOW   0
-+#define FE_UNDERFLOW  0
-+#define FE_INEXACT    0
-+#endif
-+
- #if CONFIG_LIBFONTCONFIG
- #include <fontconfig/fontconfig.h>
- #endif
diff --git a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
deleted file mode 100644
index 00e3f68a415b8..0000000000000
--- a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
-From: Rainer Hochecker <fernetmenta@online.de>
-Date: Sat, 26 Jan 2019 19:48:35 +0100
-Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
-
-This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
-It was hit frequently when watching h264 channels received via DVB-X.
-Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
----
- libavcodec/vaapi_h264.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
-index 5854587a255..f12fdc457a4 100644
---- a/libavcodec/vaapi_h264.c
-+++ b/libavcodec/vaapi_h264.c
-@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
-     H264SliceContext *sl = &h->slice_ctx[0];
-     int ret;
- 
-+    if (pic->nb_slices == 0) {
-+        ret = AVERROR_INVALIDDATA;
-+        goto finish;
-+    }
-+
-     ret = ff_vaapi_decode_issue(avctx, pic);
-     if (ret < 0)
-         goto finish;
diff --git a/srcpkgs/ffmpeg/template b/srcpkgs/ffmpeg/template
index aa058aab9ca9f..a2c5d8750dd6b 100644
--- a/srcpkgs/ffmpeg/template
+++ b/srcpkgs/ffmpeg/template
@@ -1,15 +1,14 @@
 # Template file for 'ffmpeg'
 # audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
-pkgname=ffmpeg
-version=4.4.4
-revision=2
+version=6.0
+revision=1
 short_desc="Decoding, encoding and streaming software"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="https://www.ffmpeg.org"
 changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
 distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
-checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+checksum=57be87c22d9b49c112b6d24bc67d42508660e6b718b3db89c44e47e289137082
 
 hostmakedepends="pkg-config perl"
 makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
@@ -26,12 +25,13 @@ makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-deve
  $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
  $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
  $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
- $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers Vulkan-Tools Vulkan-ValidationLayers')
+ $(vopt_if onevpl 'onevpl onevpl-devel')
  $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
 depends="ffplay>=${version}_${revision}"
 
 build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
- dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec onevpl"
 build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
 desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
 desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
@@ -39,10 +39,8 @@ desc_option_sofa="Enable support for AES SOFA"
 desc_option_webp="Enable support for WebP"
 
 case "$XBPS_TARGET_MACHINE" in
-	i686*|x86_64*)
-		hostmakedepends+=" nasm"
-		build_options_default+=" vaapi vdpau nvenc nvdec"
-		;;
+	i686*) build_options_default+=" vaapi vdpau nvenc nvdec";;
+	x86_64*) build_options_default+=" vaapi vdpau nvenc nvdec onevpl";;
 	ppc64*) build_options_default+=" vaapi vdpau";;
 	mips*) CFLAGS="-mnan=legacy";;
 esac
@@ -119,18 +117,19 @@ do_configure() {
 		$(vopt_enable x265 libx265) \
 		$(vopt_enable v4l2 libv4l2) \
 		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
-		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		--enable-libbs2b --enable-libvidstab \
 		$(vopt_enable dav1d libdav1d) \
 		$(vopt_enable zimg libzimg) \
 		$(vopt_enable webp libwebp) \
 		$(vopt_enable sofa libmysofa) \
 		$(vopt_enable vulkan) \
+		$(vopt_enable onevpl libvpl) \
 		$(vopt_enable drm libdrm) \
 		$(vopt_enable svtav1 libsvtav1) \
 		$(vopt_enable srt libsrt) \
 		$(vopt_enable rist librist) \
-		$(vopt_if nvenc '--enable-nvenc') \
-		$(vopt_if nvdec '--enable-nvdec')
+		$(vopt_enable nvenc nvenc) \
+		$(vopt_enable nvdec nvdec)
 }
 
 do_build() {
@@ -157,10 +156,8 @@ libavdevice_package() {
 }
 
 libavresample_package() {
-	short_desc="FFmpeg audio resampling library"
-	pkg_install() {
-		vmove "usr/lib/libavresample.so.*"
-	}
+	short_desc="Package deprecated, removal needed"
+	build_style=meta
 }
 
 libavformat_package() {
@@ -214,15 +211,9 @@ ffmpeg-devel_package() {
 		libavfilter>=${version}_${revision}
 		libpostproc>=${version}_${revision}
 		libswscale>=${version}_${revision}
-		libswresample>=${version}_${revision}
-		libavresample>=${version}_${revision}"
+		libswresample>=${version}_${revision}"
 	short_desc+=" - development files"
-
-	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
-		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
-		nostrip_files="/usr/lib/libavfilter.a"
-	fi
-
+	conflicts="ffmpeg4-devel"
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig

From db20f06baaa6b1f7e6082dfb1a3dfb5f4bbc06d8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:56:22 -0400
Subject: [PATCH 002/113] New package: ffmpeg4-4.4.4.

---
 srcpkgs/ffmpeg4-devel                         |   1 +
 srcpkgs/ffmpeg4/files/altivec.patch           |  60 +++++
 .../patches/armv5tel-floating-point.patch     |  18 ++
 ...h-libavcodec-libsvtav1-ten_bit_format.diff |  40 +++
 .../workaround-mesa-readeon-vaapi-bug.patch   |  28 ++
 srcpkgs/ffmpeg4/template                      | 240 ++++++++++++++++++
 srcpkgs/libavcodec4                           |   1 +
 srcpkgs/libavdevice4                          |   1 +
 srcpkgs/libavfilter4                          |   1 +
 srcpkgs/libavformat4                          |   1 +
 srcpkgs/libavresample4                        |   1 +
 srcpkgs/libavutil4                            |   1 +
 srcpkgs/libpostproc4                          |   1 +
 srcpkgs/libswresample4                        |   1 +
 srcpkgs/libswscale4                           |   1 +
 15 files changed, 396 insertions(+)
 create mode 120000 srcpkgs/ffmpeg4-devel
 create mode 100644 srcpkgs/ffmpeg4/files/altivec.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 create mode 100644 srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
 create mode 100644 srcpkgs/ffmpeg4/template
 create mode 120000 srcpkgs/libavcodec4
 create mode 120000 srcpkgs/libavdevice4
 create mode 120000 srcpkgs/libavfilter4
 create mode 120000 srcpkgs/libavformat4
 create mode 120000 srcpkgs/libavresample4
 create mode 120000 srcpkgs/libavutil4
 create mode 120000 srcpkgs/libpostproc4
 create mode 120000 srcpkgs/libswresample4
 create mode 120000 srcpkgs/libswscale4

diff --git a/srcpkgs/ffmpeg4-devel b/srcpkgs/ffmpeg4-devel
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/ffmpeg4-devel
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/ffmpeg4/files/altivec.patch b/srcpkgs/ffmpeg4/files/altivec.patch
new file mode 100644
index 0000000000000..9c57200463320
--- /dev/null
+++ b/srcpkgs/ffmpeg4/files/altivec.patch
@@ -0,0 +1,60 @@
+revert some altivec specific change on all ppc* except ppc64le*
+
+q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
+conditionally, for ppc* but not ppc64le* (the new code is valid for
+POWER8 VSX which LE targets as a baseline but not BE)"
+
+
+This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
+---
+ libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
+ 1 file changed, 20 insertions(+), 4 deletions(-)
+
+diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
+index 536545293d..c1e2852adb 100644
+--- a/libswscale/ppc/yuv2rgb_altivec.c
++++ b/libswscale/ppc/yuv2rgb_altivec.c
+@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+     vector signed short R1, G1, B1;                                           \
+     vector unsigned char R, G, B;                                             \
+                                                                               \
++    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
++    vector unsigned char align_perm;                                          \
++                                                                              \
+     vector signed short lCY       = c->CY;                                    \
+     vector signed short lOY       = c->OY;                                    \
+     vector signed short lCRV      = c->CRV;                                   \
+@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
+                                                                               \
+         for (j = 0; j < w / 16; j++) {                                        \
+-            y0 = vec_xl(0, y1i);                                              \
++            y1ivP = (const vector unsigned char *) y1i;                       \
++            y2ivP = (const vector unsigned char *) y2i;                       \
++            uivP  = (const vector unsigned char *) ui;                        \
++            vivP  = (const vector unsigned char *) vi;                        \
++                                                                              \
++            align_perm = vec_lvsl(0, y1i);                                    \
++            y0 = (vector unsigned char)                                       \
++                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
+                                                                               \
+-            y1 = vec_xl(0, y2i);                                              \
++            align_perm = vec_lvsl(0, y2i);                                    \
++            y1 = (vector unsigned char)                                       \
++                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
+                                                                               \
+-            u = (vector signed char) vec_xl(0, ui);                           \
++            align_perm = vec_lvsl(0, ui);                                     \
++            u = (vector signed char)                                          \
++                    vec_perm(uivP[0], uivP[1], align_perm);                   \
+                                                                               \
+-            v = (vector signed char) vec_xl(0, vi);                           \
++            align_perm = vec_lvsl(0, vi);                                     \
++            v = (vector signed char)                                          \
++                    vec_perm(vivP[0], vivP[1], align_perm);                   \
+                                                                               \
+             u = (vector signed char)                                          \
+                     vec_sub(u,                                                \
+-- 
+2.27.0
+
diff --git a/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
new file mode 100644
index 0000000000000..9a55178c74f0f
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
@@ -0,0 +1,18 @@
+--- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
++++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
+@@ -39,6 +39,15 @@
+ #endif
+ #include <fenv.h>
+ 
++#if (FE_ALL_EXCEPT == 0)
++/* E.g. ARM soft float does not define these */
++#define FE_INVALID    0
++#define FE_DIVBYZERO  0
++#define FE_OVERFLOW   0
++#define FE_UNDERFLOW  0
++#define FE_INEXACT    0
++#endif
++
+ #if CONFIG_LIBFONTCONFIG
+ #include <fontconfig/fontconfig.h>
+ #endif
diff --git a/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
new file mode 100644
index 0000000000000..aa948f7a8a2df
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
@@ -0,0 +1,40 @@
+#==================================================================================================
+# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
+# From: Christopher Degawa <christopher.degawa@intel.com>
+# Date: Thu, 20 Oct 2022 22:55:27 -0500
+# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
+#
+# compressed_ten_bit_format has been deprecated upstream and has no effect
+# and can be removed. Plus, technically it was never used in the first place
+# since it would require the app (ffmpeg) to set it and do additional
+# processing of the input frames.
+#
+# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
+#
+# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
+#==================================================================================================
+--- a/libavcodec/libsvtav1.c
++++ b/libavcodec/libsvtav1.c
+@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
+ 
+ static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
+ {
+-    const int    pack_mode_10bit =
+-        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
+-    const size_t luma_size_8bit  =
+-        config->source_width * config->source_height * (1 << pack_mode_10bit);
+-    const size_t luma_size_10bit =
+-        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
++    const size_t luma_size = config->source_width * config->source_height *
++        (config->encoder_bit_depth > 8 ? 2 : 1);
+ 
+     EbSvtIOFormat *in_data;
+ 
+-    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
++    svt_enc->raw_size = luma_size * 3 / 2;
+ 
+     // allocate buffer for in and out
+     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
+-- 
+GitLab
+
diff --git a/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
new file mode 100644
index 0000000000000..00e3f68a415b8
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
@@ -0,0 +1,28 @@
+From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
+From: Rainer Hochecker <fernetmenta@online.de>
+Date: Sat, 26 Jan 2019 19:48:35 +0100
+Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
+
+This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
+It was hit frequently when watching h264 channels received via DVB-X.
+Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
+---
+ libavcodec/vaapi_h264.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
+index 5854587a255..f12fdc457a4 100644
+--- a/libavcodec/vaapi_h264.c
++++ b/libavcodec/vaapi_h264.c
+@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
+     H264SliceContext *sl = &h->slice_ctx[0];
+     int ret;
+ 
++    if (pic->nb_slices == 0) {
++        ret = AVERROR_INVALIDDATA;
++        goto finish;
++    }
++
+     ret = ff_vaapi_decode_issue(avctx, pic);
+     if (ret < 0)
+         goto finish;
diff --git a/srcpkgs/ffmpeg4/template b/srcpkgs/ffmpeg4/template
new file mode 100644
index 0000000000000..f2c851693d367
--- /dev/null
+++ b/srcpkgs/ffmpeg4/template
@@ -0,0 +1,240 @@
+# Template file for 'ffmpeg4'
+# audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
+pkgname=ffmpeg4
+version=4.4.4
+revision=1
+short_desc="Decoding, encoding and streaming software - ffmpeg4 libraries only"
+maintainer="Orphaned <orphan@voidlinux.org>"
+license="GPL-3.0-or-later"
+homepage="https://www.ffmpeg.org"
+changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
+distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
+checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+
+hostmakedepends="pkg-config perl"
+makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
+ libXext-devel libXvMC-devel libxcb-devel lame-devel libtheora-devel
+ libvorbis-devel x264-devel xvidcore-devel jack-devel SDL2-devel
+ libcdio-paranoia-devel librtmp-devel libmodplug-devel gnutls-devel
+ speex-devel celt-devel harfbuzz-devel libass-devel opus-devel ocl-icd-devel
+ libbs2b-devel libvidstab-devel vmaf-devel $(vopt_if pulseaudio pulseaudio-devel)
+ $(vopt_if vaapi libva-devel) $(vopt_if vdpau libvdpau-devel)
+ $(vopt_if x265 x265-devel) $(vopt_if v4l2 v4l-utils-devel)
+ $(vopt_if fdk_aac fdk-aac-devel) $(vopt_if vpx libvpx-devel)
+ $(vopt_if aom libaom-devel) $(vopt_if sndio sndio-devel)
+ $(vopt_if dav1d libdav1d-devel) $(vopt_if zimg zimg-devel)
+ $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
+ $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
+ $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if mfx 'libmfx libmfx-devel')
+ $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
+
+build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec mfx"
+build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
+
+desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
+desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
+desc_option_sofa="Enable support for AES SOFA"
+desc_option_webp="Enable support for WebP"
+
+case "$XBPS_TARGET_MACHINE" in
+	i686*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau nvenc nvdec"
+			;;
+	x86_64*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau mfx nvenc nvdec"
+			;;
+	ppc64*) build_options_default+=" vaapi vdpau";;
+	mips*) CFLAGS="-mnan=legacy";;
+esac
+
+if [ "$XBPS_TARGET_WORDSIZE" != "32" ]; then
+	build_options_default+=" svtav1"
+fi
+
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+fi
+
+_apply_patch() {
+	local args="$1" pname="$(basename $2)"
+
+	if [ ! -f ".${pname}_done" ]; then
+		patch -N $args -i $2
+		touch .${pname}_done
+	fi
+}
+
+post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64le*) ;;
+		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
+	esac
+
+	vsed -i libavfilter/vf_libvmaf.c -e 's!/usr/local/share/model/\(vmaf_v0.6.1\).pkl!/usr/share/vmaf/\1.json!'
+}
+
+do_configure() {
+	# Fix gcc on x86_64-musl only
+	if [ "$XBPS_TARGET_MACHINE" = "x86_64-musl" ]; then
+		vsed -i configure -e "s;_cflags_speed='-O3';_cflags_speed='-O2';"
+	fi
+
+	if [ "$CROSS_BUILD" ]; then
+		case "$XBPS_TARGET_MACHINE" in
+			arm*) _arch="arm";;
+			aarch64*) _arch="aarch64";;
+			mips*) _arch="mips";;
+			ppc64*) _arch="ppc64";;
+			ppc*) _arch="ppc";;
+			*) _arch="${XBPS_TARGET_MACHINE%%-musl}";;
+		esac
+
+		_args+=" --enable-cross-compile
+			--sysroot=$XBPS_CROSS_BASE
+			--cross-prefix=${XBPS_CROSS_TRIPLET}-
+			--target-os=linux --arch=${_arch}"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc|ppc-musl) _args+=" --disable-altivec";;
+	esac
+
+	if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+		_args+=" --extra-libs=-latomic"
+	fi
+
+	./configure --prefix=/usr --disable-debug --enable-gpl --enable-gnutls \
+		--disable-stripping \
+		--enable-libcdio --enable-version3 --enable-runtime-cpudetect \
+		--enable-libmp3lame --enable-libvorbis --enable-libxvid \
+		--enable-libx264 $(vopt_enable vpx libvpx) --enable-libtheora \
+		--enable-shared --enable-static --enable-libxcb \
+		$(vopt_enable pulseaudio libpulse) --enable-libfreetype --enable-libmodplug \
+		--enable-libspeex --enable-libcelt --enable-libass \
+		--enable-libopus --enable-librtmp --enable-libjack \
+		$(vopt_if fdk_aac '--enable-nonfree --enable-libfdk-aac') \
+		--disable-libopencore_amrnb --disable-libopencore_amrwb \
+		--disable-libopenjpeg \
+		--enable-postproc --enable-opencl ${_args} --enable-libvmaf ${_args} \
+		$(vopt_enable x265 libx265) \
+		$(vopt_enable v4l2 libv4l2) \
+		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
+		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		$(vopt_enable dav1d libdav1d) \
+		$(vopt_enable zimg libzimg) \
+		$(vopt_enable webp libwebp) \
+		$(vopt_enable sofa libmysofa) \
+		$(vopt_enable vulkan) \
+		$(vopt_enable drm libdrm) \
+		$(vopt_enable svtav1 libsvtav1) \
+		$(vopt_enable srt libsrt) \
+		$(vopt_enable rist librist) \
+		$(vopt_enable mfx libmfx) \
+		$(vopt_if nvenc '--enable-nvenc') \
+		$(vopt_if nvdec '--enable-nvdec')
+}
+
+do_build() {
+	make ${makejobs}
+	make doc/ff{mpeg,play}.1
+}
+
+do_install() {
+	make DESTDIR=${DESTDIR} install install-man
+	rm -rf ${DESTDIR}/usr/bin
+}
+
+libavcodec4_package() {
+	short_desc="FFmpeg codec library"
+	pkg_install() {
+		vmove "usr/lib/libavcodec.so.*"
+	}
+}
+
+libavdevice4_package() {
+	short_desc="FFmpeg device handling library"
+	pkg_install() {
+		vmove "usr/lib/libavdevice.so.*"
+	}
+}
+
+libavresample4_package() {
+	short_desc="FFmpeg audio resampling library"
+	pkg_install() {
+		vmove "usr/lib/libavresample.so.*"
+	}
+}
+
+libavformat4_package() {
+	short_desc="FFmpeg file format library"
+	pkg_install() {
+		vmove "usr/lib/libavformat.so.*"
+	}
+}
+
+libavutil4_package() {
+	short_desc="FFmpeg utility library"
+	pkg_install() {
+		vmove "usr/lib/libavutil.so.*"
+	}
+}
+
+libavfilter4_package() {
+	short_desc="FFmpeg audio/video filter library"
+	pkg_install() {
+		vmove "usr/lib/libavfilter.so.*"
+	}
+}
+
+libpostproc4_package() {
+	short_desc="FFmpeg video postprocessing library"
+	pkg_install() {
+		vmove "usr/lib/libpostproc.so.*"
+	}
+}
+
+libswscale4_package() {
+	short_desc="FFmpeg video scaling library"
+	pkg_install() {
+		vmove "usr/lib/libswscale.so.*"
+	}
+}
+
+libswresample4_package() {
+	short_desc="FFmpeg video resampling library"
+	pkg_install() {
+		vmove "usr/lib/libswresample.so.*"
+	}
+}
+
+ffmpeg4-devel_package() {
+	depends="
+		libavcodec4>=${version}_${revision}
+		libavdevice4>=${version}_${revision}
+		libavformat4>=${version}_${revision}
+		libavutil4>=${version}_${revision}
+		libavfilter4>=${version}_${revision}
+		libpostproc4>=${version}_${revision}
+		libswscale4>=${version}_${revision}
+		libswresample4>=${version}_${revision}
+		libavresample4>=${version}_${revision}"
+	short_desc+=" - development files"
+	conflicts="ffmpeg-devel"
+	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
+		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
+		nostrip_files="/usr/lib/libavfilter.a"
+	fi
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.a"
+		vmove "usr/lib/*.so"
+		vmove usr/share/ffmpeg/examples
+		vmove usr/share/man/man3
+	}
+}
diff --git a/srcpkgs/libavcodec4 b/srcpkgs/libavcodec4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavcodec4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavdevice4 b/srcpkgs/libavdevice4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavdevice4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavfilter4 b/srcpkgs/libavfilter4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavfilter4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavformat4 b/srcpkgs/libavformat4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavformat4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavresample4 b/srcpkgs/libavresample4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavutil4 b/srcpkgs/libavutil4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavutil4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libpostproc4 b/srcpkgs/libpostproc4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libpostproc4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswresample4 b/srcpkgs/libswresample4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libswresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswscale4 b/srcpkgs/libswscale4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libswscale4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file

From e75857aa8f399eefafe80bbec35898dd08f40abd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:04 -0400
Subject: [PATCH 003/113] opencv: update to 4.7.0.

---
 common/shlibs           | 104 ++++++++++++++++++++--------------------
 srcpkgs/opencv/template |   8 ++--
 2 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index a77346cce3e9a..ca0ee066215ea 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2136,58 +2136,58 @@ libcapstone.so.4 capstone-4.0_1
 libhavege.so.2 libhaveged-1.9.11_1
 libnih.so.1 libnih-1.0.3_1
 libnih-dbus.so.1 libnih-1.0.3_1
-libopencv_quality.so.406 libopencv-4.6.0_1
-libopencv_reg.so.406 libopencv-4.6.0_1
-libopencv_surface_matching.so.406 libopencv-4.6.0_1
-libopencv_xphoto.so.406 libopencv-4.6.0_1
-libopencv_freetype.so.406 libopencv-4.6.0_1
-libopencv_fuzzy.so.406 libopencv-4.6.0_1
-libopencv_hfs.so.406 libopencv-4.6.0_1
-libopencv_img_hash.so.406 libopencv-4.6.0_1
-libopencv_line_descriptor.so.406 libopencv-4.6.0_1
-libopencv_saliency.so.406 libopencv-4.6.0_1
-libopencv_structured_light.so.406 libopencv-4.6.0_1
-libopencv_aruco.so.406 libopencv-4.6.0_1
-libopencv_bgsegm.so.406 libopencv-4.6.0_1
-libopencv_bioinspired.so.406 libopencv-4.6.0_1
-libopencv_ccalib.so.406 libopencv-4.6.0_1
-libopencv_face.so.406 libopencv-4.6.0_1
-libopencv_tracking.so.406 libopencv-4.6.0_1
-libopencv_xfeatures2d.so.406 libopencv-4.6.0_1
-libopencv_optflow.so.406 libopencv-4.6.0_1
-libopencv_ximgproc.so.406 libopencv-4.6.0_1
-libopencv_plot.so.406 libopencv-4.6.0_1
-libopencv_text.so.406 libopencv-4.6.0_1
-libopencv_ml.so.406 libopencv-4.6.0_1
-libopencv_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn.so.406 libopencv-4.6.0_1
-libopencv_shape.so.406 libopencv-4.6.0_1
-libopencv_stitching.so.406 libopencv-4.6.0_1
-libopencv_photo.so.406 libopencv-4.6.0_1
-libopencv_video.so.406 libopencv-4.6.0_1
-libopencv_calib3d.so.406 libopencv-4.6.0_1
-libopencv_features2d.so.406 libopencv-4.6.0_1
-libopencv_flann.so.406 libopencv-4.6.0_1
-libopencv_highgui.so.406 libopencv-4.6.0_1
-libopencv_videoio.so.406 libopencv-4.6.0_1
-libopencv_imgcodecs.so.406 libopencv-4.6.0_1
-libopencv_imgproc.so.406 libopencv-4.6.0_1
-libopencv_core.so.406 libopencv-4.6.0_1
-libopencv_superres.so.406 libopencv-4.6.0_1
-libopencv_videostab.so.406 libopencv-4.6.0_1
-libopencv_gapi.so.406 libopencv-4.6.0_1
-libopencv_xobjdetect.so.406 libopencv-4.6.0_1
-libopencv_datasets.so.406 libopencv-4.6.0_1
-libopencv_dnn_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn_superres.so.406 libopencv-4.6.0_1
-libopencv_dpm.so.406 libopencv-4.6.0_1
-libopencv_phase_unwrapping.so.406 libopencv-4.6.0_1
-libopencv_stereo.so.406 libopencv-4.6.0_1
-libopencv_rapid.so.406 libopencv-4.6.0_1
-libopencv_intensity_transform.so.406 libopencv-4.6.0_1
-libopencv_alphamat.so.406 libopencv-4.6.0_1
-libopencv_barcode.so.406 libopencv-4.6.0_1
-libopencv_mcc.so.406 libopencv-4.6.0_1
+libopencv_quality.so.407 libopencv-4.7.0_1
+libopencv_reg.so.407 libopencv-4.7.0_1
+libopencv_surface_matching.so.407 libopencv-4.7.0_1
+libopencv_xphoto.so.407 libopencv-4.7.0_1
+libopencv_freetype.so.407 libopencv-4.7.0_1
+libopencv_fuzzy.so.407 libopencv-4.7.0_1
+libopencv_hfs.so.407 libopencv-4.7.0_1
+libopencv_img_hash.so.407 libopencv-4.7.0_1
+libopencv_line_descriptor.so.407 libopencv-4.7.0_1
+libopencv_saliency.so.407 libopencv-4.7.0_1
+libopencv_structured_light.so.407 libopencv-4.7.0_1
+libopencv_aruco.so.407 libopencv-4.7.0_1
+libopencv_bgsegm.so.407 libopencv-4.7.0_1
+libopencv_bioinspired.so.407 libopencv-4.7.0_1
+libopencv_ccalib.so.407 libopencv-4.7.0_1
+libopencv_face.so.407 libopencv-4.7.0_1
+libopencv_tracking.so.407 libopencv-4.7.0_1
+libopencv_xfeatures2d.so.407 libopencv-4.7.0_1
+libopencv_optflow.so.407 libopencv-4.7.0_1
+libopencv_ximgproc.so.407 libopencv-4.7.0_1
+libopencv_plot.so.407 libopencv-4.7.0_1
+libopencv_text.so.407 libopencv-4.7.0_1
+libopencv_ml.so.407 libopencv-4.7.0_1
+libopencv_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn.so.407 libopencv-4.7.0_1
+libopencv_shape.so.407 libopencv-4.7.0_1
+libopencv_stitching.so.407 libopencv-4.7.0_1
+libopencv_photo.so.407 libopencv-4.7.0_1
+libopencv_video.so.407 libopencv-4.7.0_1
+libopencv_calib3d.so.407 libopencv-4.7.0_1
+libopencv_features2d.so.407 libopencv-4.7.0_1
+libopencv_flann.so.407 libopencv-4.7.0_1
+libopencv_highgui.so.407 libopencv-4.7.0_1
+libopencv_videoio.so.407 libopencv-4.7.0_1
+libopencv_imgcodecs.so.407 libopencv-4.7.0_1
+libopencv_imgproc.so.407 libopencv-4.7.0_1
+libopencv_core.so.407 libopencv-4.7.0_1
+libopencv_superres.so.407 libopencv-4.7.0_1
+libopencv_videostab.so.407 libopencv-4.7.0_1
+libopencv_gapi.so.407 libopencv-4.7.0_1
+libopencv_xobjdetect.so.407 libopencv-4.7.0_1
+libopencv_datasets.so.407 libopencv-4.7.0_1
+libopencv_dnn_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn_superres.so.407 libopencv-4.7.0_1
+libopencv_dpm.so.407 libopencv-4.7.0_1
+libopencv_phase_unwrapping.so.407 libopencv-4.7.0_1
+libopencv_stereo.so.407 libopencv-4.7.0_1
+libopencv_rapid.so.407 libopencv-4.7.0_1
+libopencv_intensity_transform.so.407 libopencv-4.7.0_1
+libopencv_alphamat.so.407 libopencv-4.7.0_1
+libopencv_barcode.so.407 libopencv-4.7.0_1
+libopencv_mcc.so.407 libopencv-4.7.0_1
 libuniconf.so.4.6 wvstreams-4.6.1_20
 libwvbase.so.4.6 wvstreams-4.6.1_20
 libwvutils.so.4.6 wvstreams-4.6.1_20
diff --git a/srcpkgs/opencv/template b/srcpkgs/opencv/template
index 69c635b1ad2bc..41f3183f1582f 100644
--- a/srcpkgs/opencv/template
+++ b/srcpkgs/opencv/template
@@ -1,7 +1,7 @@
 # Template file for 'opencv'
 pkgname=opencv
-version=4.6.0
-revision=4
+version=4.7.0
+revision=1
 create_wrksrc=yes
 build_wrksrc=${pkgname}-${version}
 build_style=cmake
@@ -24,8 +24,8 @@ homepage="https://opencv.org"
 changelog="https://github.com/opencv/opencv/wiki/ChangeLog"
 distfiles="https://github.com/opencv/opencv/archive/${version}.tar.gz
  https://github.com/opencv/opencv_contrib/archive/${version}.tar.gz>contrib.tar.gz"
-checksum="1ec1cba65f9f20fe5a41fda1586e01c70ea0c9a6d7b67c9e13edf0cfe2239277
- 1777d5fd2b59029cf537e5fd6f8aa68d707075822f90bde683fcde086f85f7a7"
+checksum="8df0079cdbe179748a18d44731af62a245a45ebf5085223dc03133954c662973
+ 42df840cf9055e59d0e22c249cfb19f04743e1bdad113d31b1573d3934d62584"
 patch_args="-Np1 -d ${build_wrksrc}"
 # tests hang indenfinitely, even with test data included
 make_check=no

From 872b27ccab83f6e66524d8e6d365e407679da160 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 004/113] actiona: revbump for opencv-4.7.0

---
 srcpkgs/actiona/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/actiona/template b/srcpkgs/actiona/template
index cf5f0b7a2ae61..0d899311e6df7 100644
--- a/srcpkgs/actiona/template
+++ b/srcpkgs/actiona/template
@@ -1,7 +1,7 @@
 # Template file for 'actiona'
 pkgname=actiona
 version=3.10.1
-revision=2
+revision=3
 build_style=qmake
 configure_args="PKGCONFIG_OPENCV=opencv4"
 hostmakedepends="pkg-config qt5-plugin-mysql qt5-qmake qt5-host-tools"

From 1d72e9120877fdcfdb9ec558b59432aade245e5a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 005/113] qimgv: revbump for opencv-4.7.0

---
 srcpkgs/qimgv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qimgv/template b/srcpkgs/qimgv/template
index 7eb30db33992c..dd341dfe1bfce 100644
--- a/srcpkgs/qimgv/template
+++ b/srcpkgs/qimgv/template
@@ -1,7 +1,7 @@
 # Template file for 'qimgv'
 pkgname=qimgv
 version=1.0.2
-revision=2
+revision=3
 build_style=cmake
 configure_args="$(vopt_if video -DVIDEO_SUPPORT=ON -DVIDEO_SUPPORT=OFF)
  $(vopt_if scale -DOPENCV_SUPPORT=ON -DOPENCV_SUPPORT=OFF)

From a3ddd74e30609df762cdd4da69b413abb689ba87 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 006/113] retroshare: revbump for opencv-4.7.0

---
 srcpkgs/retroshare/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroshare/template b/srcpkgs/retroshare/template
index 8a0786c21a082..72023fa98b751 100644
--- a/srcpkgs/retroshare/template
+++ b/srcpkgs/retroshare/template
@@ -1,7 +1,7 @@
 # Template file for 'retroshare'
 pkgname=retroshare
 version=0.6.6
-revision=2
+revision=4
 build_style=qmake
 #XXX broadcast feature requires an ancient udp-discovery-cpp which either needs
 # to be fetched+patched (FTBFS) here or packaged :/

From f5cd3b08b3f16c62be3ca0b5f7ced3bc983a38f2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 007/113] waifu2x-converter-cpp: revbump for opencv-4.7.0

---
 srcpkgs/waifu2x-converter-cpp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waifu2x-converter-cpp/template b/srcpkgs/waifu2x-converter-cpp/template
index 8c095d0d7baba..aa52d8c981a84 100644
--- a/srcpkgs/waifu2x-converter-cpp/template
+++ b/srcpkgs/waifu2x-converter-cpp/template
@@ -1,7 +1,7 @@
 # Template file for 'waifu2x-converter-cpp'
 pkgname=waifu2x-converter-cpp
 version=5.2.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DINSTALL_MODELS=ON"
 hostmakedepends="pkg-config"

From f0da174a70814736f7dc4213b013fdbbb82e6d01 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:38 -0400
Subject: [PATCH 008/113] vlc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/vlc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/vlc/template b/srcpkgs/vlc/template
index 210762b0a7e29..855ca52386626 100644
--- a/srcpkgs/vlc/template
+++ b/srcpkgs/vlc/template
@@ -1,7 +1,7 @@
 # Template file for 'vlc'
 pkgname=vlc
 version=3.0.18
-revision=3
+revision=4
 build_style=gnu-configure
 configure_args="--disable-gme --disable-libtar --enable-jack
  --enable-live555 --disable-fluidsynth --enable-dvdread
@@ -25,7 +25,7 @@ lib32disabled=yes
 hostmakedepends="automake libtool pkg-config flex gettext libgcrypt-devel
  live555-devel gettext-devel $(vopt_if lua lua52) $(vopt_if chromecast protobuf)"
 makedepends="
- avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg-devel freefont-ttf
+ avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg4-devel freefont-ttf
  gnutls-devel jack-devel liba52-devel libass-devel libbluray-devel
  libcdio-devel libdca-devel libdvbpsi-devel libdvdnav-devel libmad-devel
  libmatroska-devel libmodplug-devel libmpcdec-devel libmpeg2-devel

From 7ebea9d5668edb8bc1c65505ff52422cfe4d31b4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:55 -0400
Subject: [PATCH 009/113] osg: revbump for ffmpeg4-4.4.3

---
 srcpkgs/osg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/osg/template b/srcpkgs/osg/template
index a9ebbd287933b..755793f7e11bf 100644
--- a/srcpkgs/osg/template
+++ b/srcpkgs/osg/template
@@ -8,7 +8,7 @@ build_helper="qemu"
 configure_args="-DLIB_POSTFIX="
 hostmakedepends="pkg-config xrandr"
 makedepends="MesaLib-devel gtkglext-devel libcurl-devel giflib-devel librsvg-devel
- jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg-devel xine-lib-devel
+ jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg4-devel xine-lib-devel
  SDL2-devel gst-plugins-base1-devel
  $(vopt_if openexr libopenexr-devel)
  $(vopt_if poppler poppler-glib-devel)

From 799c48913dbc1fe40841121c7f6912d61c088118 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:13 -0400
Subject: [PATCH 010/113] xine-lib: revbump for ffmpeg4-4.4.3

---
 srcpkgs/xine-lib/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/xine-lib/template b/srcpkgs/xine-lib/template
index f713eff49b07c..ed6194c17d11e 100644
--- a/srcpkgs/xine-lib/template
+++ b/srcpkgs/xine-lib/template
@@ -1,6 +1,6 @@
 # Template file for 'xine-lib'
 pkgname=xine-lib
-version=1.2.12
+version=1.2.13
 revision=1
 build_style=gnu-configure
 configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
@@ -8,7 +8,7 @@ configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
 hostmakedepends="automake gettext-devel libtool pkg-config perl"
 makedepends="
  zlib-devel alsa-lib-devel libxcb-devel libSM-devel libXext-devel libXv-devel
- libXvMC-devel liba52-devel libmad-devel ffmpeg-devel pulseaudio-devel
+ libXvMC-devel liba52-devel libmad-devel ffmpeg4-devel pulseaudio-devel
  jack-devel samba-devel libflac-devel libmodplug-devel libmpcdec-devel
  speex-devel libtheora-devel libvorbis-devel libdca-devel faad2-devel
  libcdio-devel libbluray-devel aalib-devel libcaca-devel libXinerama-devel
@@ -19,7 +19,7 @@ license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="http://www.xine-project.org"
 changelog="https://sourceforge.net/projects/xine/files/xine-lib/${version}/README.txt/view"
 distfiles="${SOURCEFORGE_SITE}/xine/${pkgname}-${version}.tar.xz"
-checksum=d606270468e1540c2a89c0d7f5fdf11e17ecc0c2698cc0bcb1065ff26abee098
+checksum=5f10d6d718a4a51c17ed1b32b031d4f9b80b061e8276535b2be31e5ac4b75e6f
 
 case "$XBPS_TARGET_MACHINE" in
 	i686-musl)

From 6a08a4dd48e7ad6a4177446f465398f928c64ecf Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 011/113] QMPlay2: revbump for ffmpeg-6.0

---
 srcpkgs/QMPlay2/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/QMPlay2/template b/srcpkgs/QMPlay2/template
index 850df9d418b90..8d2ce7a76156c 100644
--- a/srcpkgs/QMPlay2/template
+++ b/srcpkgs/QMPlay2/template
@@ -1,7 +1,7 @@
 # Template file for 'QMPlay2'
 pkgname=QMPlay2
 version=23.06.17
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools"
 makedepends="alsa-lib-devel ffmpeg-devel libass-devel libcdio-devel libgme-devel

From 2b6b3567ae402780c7e7cb58e26ccb66e72c5295 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 012/113] alsa-plugins: revbump for ffmpeg-6.0

---
 srcpkgs/alsa-plugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/alsa-plugins/template b/srcpkgs/alsa-plugins/template
index 0bfa6d9fd2643..a5708a7d82a8f 100644
--- a/srcpkgs/alsa-plugins/template
+++ b/srcpkgs/alsa-plugins/template
@@ -1,7 +1,7 @@
 # Template file for 'alsa-plugins'
 pkgname=alsa-plugins
 version=1.2.7.1
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--disable-maemo-plugin"
 hostmakedepends="pkg-config"

From f8340f2ff564bc87ac5df4e412086925af1689a7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 013/113] arcan: revbump for ffmpeg-6.0

---
 srcpkgs/arcan/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/arcan/template b/srcpkgs/arcan/template
index 7be9652eccf3c..ccc7df11ceac6 100644
--- a/srcpkgs/arcan/template
+++ b/srcpkgs/arcan/template
@@ -2,7 +2,7 @@
 # !! keep synced with: acfgfs aclip aloadimage
 pkgname=arcan
 version=0.6.2.1
-revision=1
+revision=2
 create_wrksrc=yes
 build_wrksrc=arcan/src
 build_style=cmake

From 36c05299730aa27031a0146a33a0b4144cf4ce1f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 014/113] attract: revbump for ffmpeg4-4.4.3

---
 srcpkgs/attract/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/attract/template b/srcpkgs/attract/template
index 26144e931a3c7..e760bf0d18aec 100644
--- a/srcpkgs/attract/template
+++ b/srcpkgs/attract/template
@@ -1,12 +1,12 @@
 # Template file for 'attract'
 pkgname=attract
 version=2.6.2
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="VERBOSE=1"
 make_use_env=yes
 hostmakedepends="pkg-config"
-makedepends="SFML-devel ffmpeg-devel fontconfig-devel glu-devel libarchive-devel
+makedepends="SFML-devel ffmpeg4-devel fontconfig-devel glu-devel libarchive-devel
  libcurl-devel libjpeg-turbo-devel xine-lib rapidjson libXrandr-devel"
 depends="git"
 short_desc="Attract-Mode is a graphical frontend for emulators"

From 500e6d6beae4fd96fe97ab0c5ce5b50f11f728db Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 015/113] aubio: revbump for ffmpeg-6.0

---
 srcpkgs/aubio/patches/ffmpeg5.patch | 25 +++++++++++++++++++++++++
 srcpkgs/aubio/template              |  2 +-
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/aubio/patches/ffmpeg5.patch

diff --git a/srcpkgs/aubio/patches/ffmpeg5.patch b/srcpkgs/aubio/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..aace41a6e6d9a
--- /dev/null
+++ b/srcpkgs/aubio/patches/ffmpeg5.patch
@@ -0,0 +1,25 @@
+From 8a05420e5dd8c7b8b2447f82dc919765876511b3 Mon Sep 17 00:00:00 2001
+From: Paul Brossier <piem@piem.org>
+Date: Tue, 25 Jan 2022 18:30:27 +0100
+Subject: [PATCH] [source_avcodec] define FF_API_LAVF_AVCTX for libavcodec >
+ 59, thx @berolinux (closes gh-353)
+
+---
+ src/io/source_avcodec.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/io/source_avcodec.c b/src/io/source_avcodec.c
+index e0ae93b5..1421bd9a 100644
+--- a/src/io/source_avcodec.c
++++ b/src/io/source_avcodec.c
+@@ -68,6 +68,10 @@
+ #define AUBIO_AVCODEC_MAX_BUFFER_SIZE AV_INPUT_BUFFER_MIN_SIZE
+ #endif
+ 
++#if LIBAVCODEC_VERSION_MAJOR >= 59
++#define FF_API_LAVF_AVCTX 1
++#endif
++
+ struct _aubio_source_avcodec_t {
+   uint_t hop_size;
+   uint_t samplerate;
diff --git a/srcpkgs/aubio/template b/srcpkgs/aubio/template
index ad1c4b2569917..7d875cc02541a 100644
--- a/srcpkgs/aubio/template
+++ b/srcpkgs/aubio/template
@@ -1,7 +1,7 @@
 # Template file for 'aubio'
 pkgname=aubio
 version=0.4.9
-revision=1
+revision=2
 build_style=waf3
 # XXX lash, pure and swig support.
 hostmakedepends="pkg-config txt2man"

From ed5c31130978eb0a1ca265ca07d073c46327dbb7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 016/113] audacious-plugins: revbump for ffmpeg-6.0

---
 .../audacious-plugins/patches/ffmpeg5.patch   | 43 +++++++++++++++++++
 srcpkgs/audacious-plugins/template            |  2 +-
 2 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/audacious-plugins/patches/ffmpeg5.patch

diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg5.patch b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..4e5e34099d71c
--- /dev/null
+++ b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
@@ -0,0 +1,43 @@
+commit 298aa371c56c2f52c25a33d9bdec4918b11cebdc
+Author: tibequadorian <tibequadorian@posteo.de>
+Date:   Sat Mar 19 18:40:12 2022 +0100
+
+    audacious-plugins: rebuild against ffmpeg-5.0
+
+diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+new file mode 100644
+index 0000000000..617c11215b
+--- /dev/null
++++ b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+@@ -0,0 +1,31 @@
++From f60beb400eeb1e4778bbfd738bc4a4ccef3de539 Mon Sep 17 00:00:00 2001
++From: John Lindgren <john@jlindgren.net>
++Date: Sat, 5 Mar 2022 12:05:34 -0500
++Subject: [PATCH] Fix build with FFmpeg 5.0
++
++---
++ src/ffaudio/ffaudio-core.cc | 4 ++--
++ 1 file changed, 2 insertions(+), 2 deletions(-)
++
++diff --git a/src/ffaudio/ffaudio-core.cc b/src/ffaudio/ffaudio-core.cc
++index 16dc63e3a..a2b95fd6c 100644
++--- a/src/ffaudio/ffaudio-core.cc
+++++ b/src/ffaudio/ffaudio-core.cc
++@@ -274,7 +274,7 @@ static AVInputFormat * get_format_by_content (const char * name, VFSFile & file)
++         AVProbeData d = {name, buf, filled};
++         score = target;
++ 
++-        f = av_probe_input_format2 (& d, true, & score);
+++        f = (AVInputFormat *) av_probe_input_format2 (& d, true, & score);
++         if (f)
++             break;
++ 
++@@ -347,7 +347,7 @@ static bool find_codec (AVFormatContext * c, CodecInfo * cinfo)
++ #endif
++         if (stream && stream->codecpar && stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
++         {
++-            AVCodec * codec = avcodec_find_decoder (stream->codecpar->codec_id);
+++            AVCodec * codec = (AVCodec *) avcodec_find_decoder (stream->codecpar->codec_id);
++ 
++             if (codec)
++             {
diff --git a/srcpkgs/audacious-plugins/template b/srcpkgs/audacious-plugins/template
index 88cbc1671fc6a..beebfae59ed44 100644
--- a/srcpkgs/audacious-plugins/template
+++ b/srcpkgs/audacious-plugins/template
@@ -2,7 +2,7 @@
 #Keep in sync with audacious!
 pkgname=audacious-plugins
 version=4.3.1
-revision=1
+revision=2
 build_style=meson
 configure_args="$(vopt_bool gtk3 gtk) $(vopt_bool gtk3)
  $(vopt_bool qt) $(vopt_bool qt qt6)"

From 31d7a3bb1afd1f01897079f4fe21c358de65e0ef Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 017/113] audacity: revbump for ffmpeg4-4.4.3

---
 srcpkgs/audacity/template | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/audacity/template b/srcpkgs/audacity/template
index d509c0a894077..11e20255685b0 100644
--- a/srcpkgs/audacity/template
+++ b/srcpkgs/audacity/template
@@ -1,7 +1,7 @@
 # Template file for 'audacity'
 pkgname=audacity
 version=2.4.1
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--with-ffmpeg=system --with-libsndfile=system --with-expat=system
  --with-libsoxr=system --with-lame=system --with-lv2=system ac_cv_path_WX_CONFIG=wx-config-gtk3"
@@ -9,7 +9,7 @@ hostmakedepends="pkg-config cmake gettext libtool m4 which"
 makedepends="jack-devel wxWidgets-gtk3-devel gtk+3-devel
  libmad-devel soundtouch-devel libsoxr-devel
  vamp-plugin-sdk-devel lame-devel libid3tag-devel libflac-devel
- ffmpeg-devel twolame-devel serd-devel lv2 lilv-devel suil-devel"
+ ffmpeg4-devel twolame-devel serd-devel lv2 lilv-devel suil-devel"
 depends="desktop-file-utils hicolor-icon-theme"
 short_desc="Graphical cross-platform audio editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
@@ -33,5 +33,4 @@ post_install() {
 	vcopy plug-ins /usr/share/audacity
 
 	rm ${DESTDIR}/usr/share/doc/audacity/LICENSE.txt
-	vlicense LICENSE.txt LICENSE
 }

From 10ade9d793594c3a5985bda6736712dc10ef4d0e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 018/113] avidemux: revbump for ffmpeg-6.0

---
 srcpkgs/avidemux/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/avidemux/template b/srcpkgs/avidemux/template
index 253a0243e2259..557285982d2b8 100644
--- a/srcpkgs/avidemux/template
+++ b/srcpkgs/avidemux/template
@@ -1,7 +1,7 @@
 # Template file for 'avidemux'
 pkgname=avidemux
 version=2.8.0
-revision=2
+revision=3
 # Can't be compiled for aarch64, arm* or mips*
 archs="x86_64* i686*"
 hostmakedepends="cmake pkg-config qt5-host-tools qt5-devel tar yasm"

From 05c99e65835800a528ee3107e6032ef11beade0e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 019/113] baresip: revbump for ffmpeg-6.0

---
 srcpkgs/baresip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/baresip/template b/srcpkgs/baresip/template
index f1bd1817048b5..b21e22334316e 100644
--- a/srcpkgs/baresip/template
+++ b/srcpkgs/baresip/template
@@ -1,7 +1,7 @@
 # Template file for 'baresip'
 pkgname=baresip
 version=2.10.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config glib-devel"
 makedepends="libgsm-devel libpng-devel openssl-devel libsndfile-devel

From 4cdf29f13fc694b13150b060f4d2d0a40fe972a8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 020/113] blender: revbump for ffmpeg-6.0

---
 srcpkgs/blender/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index 7a710ac0df495..0f72876d4d704 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -9,8 +9,8 @@ configure_args="-DWITH_INSTALL_PORTABLE=OFF -DWITH_PYTHON_INSTALL=OFF
  -DWITH_JACK=ON -DWITH_CODEC_FFMPEG=ON -DWITH_CODEC_SNDFILE=ON -DWITH_OPENMP=ON
  -DWITH_FFTW3=ON -DWITH_MOD_OCEANSIM=ON -DWITH_CYCLES_EMBREE=OFF -DWITH_OPENCOLORIO=ON
  -DWITH_IMAGE_OPENEXR=ON -DWITH_IMAGE_OPENJPEG=ON -DWITH_OPENSUBDIV=ON
- -DWITH_OPENCOLLADA=ON -DWITH_SYSTEM_GLEW=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
- -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_LIBDECOR=ON
+ -DWITH_OPENCOLLADA=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
+ -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_WAYLAND_LIBDECOR=ON
  -DWITH_BUILDINFO=OFF -DPYTHON_VERSION=${py3_ver} -DPYTHON_LIBPATH=/usr/lib
  -DPYTHON_LIBRARY=python${py3_ver}${py3_abiver} -DPYTHON_INCLUDE_DIRS=/${py3_inc}
  -DWITH_SYSTEM_LZO=ON -DWITH_SYSTEM_EIGEN3=ON -DWITH_SYSTEM_FREETYPE=ON"

From 940329daae3a14fc45a97c90170a496f9a32d2b7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 021/113] cantata: revbump for ffmpeg-6.0

---
 srcpkgs/cantata/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cantata/template b/srcpkgs/cantata/template
index 4b417d80d5c2d..8a90aaa4c07a2 100644
--- a/srcpkgs/cantata/template
+++ b/srcpkgs/cantata/template
@@ -1,7 +1,7 @@
 # Template file for 'cantata'
 pkgname=cantata
 version=2.5.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools qt5-tools"
 makedepends="qt5-devel qt5-tools-devel qt5-svg-devel qt5-xmlpatterns-devel

From 62a08119df80003aafbca5afc1bf1cbc98a398a8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 022/113] ccextractor: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ccextractor/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/ccextractor/template b/srcpkgs/ccextractor/template
index 9abcd82852b27..6eccad5885af9 100644
--- a/srcpkgs/ccextractor/template
+++ b/srcpkgs/ccextractor/template
@@ -1,12 +1,12 @@
 # Template file for 'ccextractor'
 pkgname=ccextractor
 version=0.93
-revision=1
+revision=2
 build_wrksrc="linux"
 build_style=gnu-configure
 configure_args="--enable-ocr --enable-hardsubx"
 hostmakedepends="automake pkg-config"
-makedepends="leptonica-devel tesseract-ocr-devel ffmpeg-devel"
+makedepends="leptonica-devel tesseract-ocr-devel ffmpeg4-devel"
 short_desc="Extract subtitles from video streams"
 maintainer="newbluemoon <blaumolch@mailbox.org>"
 license="GPL-2.0-or-later"

From bb99ad93f5d502850711fcd08e54c4a9e96750a9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 023/113] chromaprint: revbump for ffmpeg-6.0

---
 srcpkgs/chromaprint/patches/ffmpeg5.patch | 569 ++++++++++++++++++++++
 srcpkgs/chromaprint/template              |   2 +-
 2 files changed, 570 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromaprint/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromaprint/patches/ffmpeg5.patch b/srcpkgs/chromaprint/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..a9fd307a23c8a
--- /dev/null
+++ b/srcpkgs/chromaprint/patches/ffmpeg5.patch
@@ -0,0 +1,569 @@
+From 8ccad6937177b1b92e40ab8f4447ea27bac009a7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= <lalinsky@gmail.com>
+Date: Fri, 4 Nov 2022 21:47:38 +0100
+Subject: [PATCH] Use FFmpeg 5.x (#120)
+
+* Use FFmpeg 5.1.2 for CI builds
+
+* Build on Ubuntu 20.04
+
+* Upgrade code to FFmpeg 5.x APIs
+
+* Only set FFmpeg include dirs if building tools
+
+* No longer needed
+
+* Use ubuntu 20.04
+---
+ .github/workflows/build.yml                   |   6 +-
+ CMakeLists.txt                                |  16 --
+ package/build.sh                              |   4 +-
+ src/audio/ffmpeg_audio_processor.h            |   2 -
+ src/audio/ffmpeg_audio_processor_avresample.h |  72 -------
+ src/audio/ffmpeg_audio_processor_swresample.h |  18 +-
+ src/audio/ffmpeg_audio_reader.h               | 197 +++++++++---------
+ tests/CMakeLists.txt                          |   6 +
+ 8 files changed, 122 insertions(+), 199 deletions(-)
+ delete mode 100644 src/audio/ffmpeg_audio_processor_avresample.h
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index f8d6a32..4da2405 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -84,9 +84,6 @@ find_package(FFmpeg)
+ if(FFMPEG_LIBRARIES)
+ 	cmake_push_check_state(RESET)
+ 	set(CMAKE_REQUIRED_LIBRARIES ${FFMPEG_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -lm)
+-	check_function_exists(av_packet_unref HAVE_AV_PACKET_UNREF)
+-	check_function_exists(av_frame_alloc HAVE_AV_FRAME_ALLOC)
+-	check_function_exists(av_frame_free HAVE_AV_FRAME_FREE)
+ 	cmake_pop_check_state()
+ endif()
+
+@@ -163,14 +160,11 @@ message(STATUS "Using ${FFT_LIB} for FFT calculations")
+ if(NOT AUDIO_PROCESSOR_LIB)
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+ 		set(AUDIO_PROCESSOR_LIB "swresample")
+-	elseif(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(AUDIO_PROCESSOR_LIB "avresample")
+ 	endif()
+ endif()
+
+ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE OFF)
+ 		set(USE_SWRESAMPLE ON)
+ 		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBSWRESAMPLE_LIBRARIES})
+ 		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBSWRESAMPLE_INCLUDE_DIRS})
+@@ -178,16 +172,6 @@ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+ 	endif()
+ 	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+-elseif(AUDIO_PROCESSOR_LIB STREQUAL "avresample")
+-	if(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE ON)
+-		set(USE_SWRESAMPLE OFF)
+-		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBAVRESAMPLE_LIBRARIES})
+-		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBAVRESAMPLE_INCLUDE_DIRS})
+-	else()
+-		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+-	endif()
+-	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+ else()
+ 	message(STATUS "Building without audio conversion support, please install FFmpeg with libswresample")
+ endif()
+diff --git a/package/build.sh b/package/build.sh
+index da631ae..b41d36e 100755
+--- a/package/build.sh
++++ b/package/build.sh
+@@ -7,8 +7,8 @@ set -eux
+
+ BASE_DIR=$(cd $(dirname $0)/.. && pwd)
+
+-FFMPEG_VERSION=4.4.1
+-FFMPEG_BUILD_TAG=v4.4.1-1
++FFMPEG_VERSION=5.1.2
++FFMPEG_BUILD_TAG=v${FFMPEG_VERSION}-1
+
+ TMP_BUILD_DIR=$BASE_DIR/$(mktemp -d build.XXXXXXXX)
+ trap 'rm -rf $TMP_BUILD_DIR' EXIT
+diff --git a/src/audio/ffmpeg_audio_processor.h b/src/audio/ffmpeg_audio_processor.h
+index 7628fc7..39f4f6d 100644
+--- a/src/audio/ffmpeg_audio_processor.h
++++ b/src/audio/ffmpeg_audio_processor.h
+@@ -10,8 +10,6 @@
+
+ #if defined(USE_SWRESAMPLE)
+ #include "audio/ffmpeg_audio_processor_swresample.h"
+-#elif defined(USE_AVRESAMPLE)
+-#include "audio/ffmpeg_audio_processor_avresample.h"
+ #else
+ #error "no audio processing library"
+ #endif
+diff --git a/src/audio/ffmpeg_audio_processor_avresample.h b/src/audio/ffmpeg_audio_processor_avresample.h
+deleted file mode 100644
+index bd85f92..0000000
+--- a/src/audio/ffmpeg_audio_processor_avresample.h
++++ /dev/null
+@@ -1,72 +0,0 @@
+-// Copyright (C) 2016  Lukas Lalinsky
+-// Distributed under the MIT license, see the LICENSE file for details.
+-
+-#ifndef CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-#define CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-
+-extern "C" {
+-#include <libavresample/avresample.h>
+-}
+-
+-namespace chromaprint {
+-
+-class FFmpegAudioProcessor {
+-public:
+-	FFmpegAudioProcessor() {
+-		m_resample_ctx = avresample_alloc_context();
+-	}
+-
+-	~FFmpegAudioProcessor() {
+-		avresample_free(&m_resample_ctx);
+-	}
+-
+-	void SetCompatibleMode() {
+-		av_opt_set_int(m_resample_ctx, "filter_size", 16, 0);
+-		av_opt_set_int(m_resample_ctx, "phase_shift", 8, 0);
+-		av_opt_set_int(m_resample_ctx, "linear_interp", 1, 0);
+-		av_opt_set_double(m_resample_ctx, "cutoff", 0.8, 0);
+-	}
+-
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "in_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_rate", sample_rate, 0);
+-	}
+-
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "out_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_rate, 0);
+-	}
+-
+-	int Init() {
+-		return avresample_open(m_resample_ctx);
+-	}
+-
+-	int Convert(uint8_t **out, int out_count, const uint8_t **in, int in_count) {
+-		return avresample_convert(m_resample_ctx, out, 0, out_count, (uint8_t **) in, 0, in_count);
+-	}
+-
+-	int Flush(uint8_t **out, int out_count) {
+-		return avresample_read(m_resample_ctx, out, out_count);
+-	}
+-
+-private:
+-	AVAudioResampleContext *m_resample_ctx = nullptr;
+-};
+-
+-}; // namespace chromaprint
+-
+-#endif
+diff --git a/src/audio/ffmpeg_audio_processor_swresample.h b/src/audio/ffmpeg_audio_processor_swresample.h
+index b86266b..b1d4bea 100644
+--- a/src/audio/ffmpeg_audio_processor_swresample.h
++++ b/src/audio/ffmpeg_audio_processor_swresample.h
+@@ -28,30 +28,28 @@ public:
+ 		av_opt_set_double(m_swr_ctx, "cutoff", 0.8, 0);
+ 	}
+
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "icl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "ich", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetInputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "in_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "isf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "in_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "isr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "in_sample_rate", sample_rate, 0);
+ 	}
+
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "ocl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "och", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetOutputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "out_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "osf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "out_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "osr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "out_sample_rate", sample_rate, 0);
+ 	}
+
+ 	int Init() {
+diff --git a/src/audio/ffmpeg_audio_reader.h b/src/audio/ffmpeg_audio_reader.h
+index 5550164..1c6b346 100644
+--- a/src/audio/ffmpeg_audio_reader.h
++++ b/src/audio/ffmpeg_audio_reader.h
+@@ -62,7 +62,7 @@ public:
+ 	bool Read(const int16_t **data, size_t *size);
+
+ 	bool IsOpen() const { return m_opened; }
+-	bool IsFinished() const { return m_finished && !m_got_frame; }
++	bool IsFinished() const { return !m_has_more_packets && !m_has_more_frames; }
+
+ 	std::string GetError() const { return m_error; }
+ 	int GetErrorCode() const { return m_error_code; }
+@@ -74,20 +74,19 @@ private:
+ 	uint8_t *m_convert_buffer[1] = { nullptr };
+ 	int m_convert_buffer_nb_samples = 0;
+
+-	AVInputFormat *m_input_fmt = nullptr;
++	const AVInputFormat *m_input_fmt = nullptr;
+ 	AVDictionary *m_input_opts = nullptr;
+
+ 	AVFormatContext *m_format_ctx = nullptr;
+ 	AVCodecContext *m_codec_ctx = nullptr;
+-	AVFrame *m_frame = nullptr;
+ 	int m_stream_index = -1;
+ 	std::string m_error;
+ 	int m_error_code = 0;
+-	bool m_finished = false;
+ 	bool m_opened = false;
+-	int m_got_frame = 0;
+-	AVPacket m_packet;
+-	AVPacket m_packet0;
++	bool m_has_more_packets = true;
++	bool m_has_more_frames = true;
++	AVPacket *m_packet = nullptr;
++	AVFrame *m_frame = nullptr;
+
+ 	int m_output_sample_rate = 0;
+ 	int m_output_channels = 0;
+@@ -98,19 +97,12 @@ private:
+
+ inline FFmpegAudioReader::FFmpegAudioReader() {
+ 	av_log_set_level(AV_LOG_QUIET);
+-
+-	av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
+ }
+
+ inline FFmpegAudioReader::~FFmpegAudioReader() {
+ 	Close();
+ 	av_dict_free(&m_input_opts);
+ 	av_freep(&m_convert_buffer[0]);
+-	av_packet_unref(&m_packet0);
+ }
+
+ inline bool FFmpegAudioReader::SetInputFormat(const char *name) {
+@@ -135,11 +127,10 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ 	Close();
+
+-    av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
++	m_packet = av_packet_alloc();
++	if (!m_packet) {
++		return false;
++	}
+
+ 	ret = avformat_open_input(&m_format_ctx, file_name.c_str(), m_input_fmt, &m_input_opts);
+ 	if (ret < 0) {
+@@ -153,26 +144,31 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		return false;
+ 	}
+
+-	AVCodec *codec;
++	const AVCodec *codec;
+ 	ret = av_find_best_stream(m_format_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &codec, 0);
+ 	if (ret < 0) {
+ 		SetError("Could not find any audio stream in the file", ret);
+ 		return false;
+ 	}
+ 	m_stream_index = ret;
++	auto stream = m_format_ctx->streams[m_stream_index];
+
+-	m_codec_ctx = m_format_ctx->streams[m_stream_index]->codec;
++	m_codec_ctx = avcodec_alloc_context3(codec);
+ 	m_codec_ctx->request_sample_fmt = AV_SAMPLE_FMT_S16;
+
++	ret = avcodec_parameters_to_context(m_codec_ctx, stream->codecpar);
++	if (ret < 0) {
++		SetError("Could not copy the stream parameters", ret);
++		return false;
++	}
++
+ 	ret = avcodec_open2(m_codec_ctx, codec, nullptr);
+ 	if (ret < 0) {
+ 		SetError("Could not open the codec", ret);
+ 		return false;
+ 	}
+
+-	if (!m_codec_ctx->channel_layout) {
+-		m_codec_ctx->channel_layout = av_get_default_channel_layout(m_codec_ctx->channels);
+-	}
++	av_dump_format(m_format_ctx, 0, "foo", 0);
+
+ 	m_frame = av_frame_alloc();
+ 	if (!m_frame) {
+@@ -183,19 +179,23 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		m_output_sample_rate = m_codec_ctx->sample_rate;
+ 	}
+
+-	if (!m_output_channels) {
+-		m_output_channels = m_codec_ctx->channels;
++	AVChannelLayout output_channel_layout;
++	if (m_output_channels) {
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
++	} else {
++		m_output_channels = m_codec_ctx->ch_layout.nb_channels;
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
+ 	}
+
+-	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
++	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->ch_layout.nb_channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
+ 		m_converter.reset(new FFmpegAudioProcessor());
+ 		m_converter->SetCompatibleMode();
+ 		m_converter->SetInputSampleFormat(m_codec_ctx->sample_fmt);
+ 		m_converter->SetInputSampleRate(m_codec_ctx->sample_rate);
+-		m_converter->SetInputChannelLayout(m_codec_ctx->channel_layout);
++		m_converter->SetInputChannelLayout(&(m_codec_ctx->ch_layout));
+ 		m_converter->SetOutputSampleFormat(AV_SAMPLE_FMT_S16);
+ 		m_converter->SetOutputSampleRate(m_output_sample_rate);
+-		m_converter->SetOutputChannelLayout(av_get_default_channel_layout(m_output_channels));
++		m_converter->SetOutputChannelLayout(&output_channel_layout);
+ 		auto ret = m_converter->Init();
+ 		if (ret != 0) {
+ 			SetError("Could not create an audio converter instance", ret);
+@@ -203,10 +203,11 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		}
+ 	}
+
++	av_channel_layout_uninit(&output_channel_layout);
++
+ 	m_opened = true;
+-	m_finished = false;
+-	m_got_frame = 0;
+-	m_nb_packets = 0;
++	m_has_more_packets = true;
++	m_has_more_frames = true;
+ 	m_decode_error = 0;
+
+ 	return true;
+@@ -214,6 +215,7 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ inline void FFmpegAudioReader::Close() {
+ 	av_frame_free(&m_frame);
++	av_packet_free(&m_packet);
+
+ 	m_stream_index = -1;
+
+@@ -252,91 +254,98 @@ inline bool FFmpegAudioReader::Read(const int16_t **data, size_t *size) {
+ 		return false;
+ 	}
+
++	*data = nullptr;
++	*size = 0;
++
+ 	int ret;
++	bool needs_packet = false;
+ 	while (true) {
+-		while (m_packet.size <= 0) {
+-			av_packet_unref(&m_packet0);
+-			av_init_packet(&m_packet);
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			ret = av_read_frame(m_format_ctx, &m_packet);
++		while (needs_packet && m_packet->size == 0) {
++			ret = av_read_frame(m_format_ctx, m_packet);
+ 			if (ret < 0) {
+ 				if (ret == AVERROR_EOF) {
+-					m_finished = true;
++					needs_packet = false;
++					m_has_more_packets = false;
+ 					break;
+-				} else {
++				}
++				SetError("Error reading from the audio source", ret);
++				return false;
++			}
++			if (m_packet->stream_index == m_stream_index) {
++				needs_packet = false;
++			} else {
++				av_packet_unref(m_packet);
++			}
++		}
++
++		if (m_packet->size != 0) {
++			ret = avcodec_send_packet(m_codec_ctx, m_packet);
++			if (ret < 0) {
++				if (ret != AVERROR(EAGAIN)) {
+ 					SetError("Error reading from the audio source", ret);
+ 					return false;
+ 				}
+-			}
+-			m_packet0 = m_packet;
+-			if (m_packet.stream_index != m_stream_index) {
+-				m_packet.data = nullptr;
+-				m_packet.size = 0;
+ 			} else {
+-				m_nb_packets++;
++				av_packet_unref(m_packet);
+ 			}
+ 		}
+
+-		ret = avcodec_decode_audio4(m_codec_ctx, m_frame, &m_got_frame, &m_packet);
++		ret = avcodec_receive_frame(m_codec_ctx, m_frame);
+ 		if (ret < 0) {
+-			if (m_decode_error) {
+-				SetError("Error decoding audio frame", m_decode_error);
+-				return false;
++			if (ret == AVERROR_EOF) {
++				m_has_more_frames = false;
++			} else if (ret == AVERROR(EAGAIN)) {
++				if (m_has_more_packets) {
++					needs_packet = true;
++					continue;
++				} else {
++					m_has_more_frames = false;
++				}
+ 			}
+-			m_decode_error = ret;
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			continue;
++			SetError("Error decoding the audio source", ret);
++			return false;
+ 		}
+
+-		break;
+-	}
+-
+-	m_decode_error = 0;
+-
+-	const int decoded = std::min(ret, m_packet.size);
+-	m_packet.data += decoded;
+-	m_packet.size -= decoded;
+-
+-	if (m_got_frame) {
+-		if (m_converter) {
+-			if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
+-				int linsize;
+-				av_freep(&m_convert_buffer[0]);
+-				m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
+-				ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
+-				if (ret < 0) {
+-					SetError("Couldn't allocate audio converter buffer", ret);
++		if (m_frame->nb_samples > 0) {
++			if (m_converter) {
++				if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
++					int linsize;
++					av_freep(&m_convert_buffer[0]);
++					m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
++					ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->ch_layout.nb_channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
++					if (ret < 0) {
++						SetError("Couldn't allocate audio converter buffer", ret);
++						return false;
++					}
++				}
++				auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
++				if (nb_samples < 0) {
++					SetError("Couldn't convert audio", ret);
+ 					return false;
+ 				}
+-			}
+-			auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			}
+-			*data = (const int16_t *) m_convert_buffer[0];
+-			*size = nb_samples;
+-		} else {
+-			*data = (const int16_t *) m_frame->data[0];
+-			*size = m_frame->nb_samples;
+-		}
+-	} else {
+-		if (m_finished && m_converter) {
+-			auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			} else if (nb_samples > 0) {
+-				m_got_frame = 1;
+ 				*data = (const int16_t *) m_convert_buffer[0];
+ 				*size = nb_samples;
++			} else {
++				*data = (const int16_t *) m_frame->data[0];
++				*size = m_frame->nb_samples;
++			}
++		} else {
++			if (m_converter) {
++				if (IsFinished()) {
++					auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
++					if (nb_samples < 0) {
++						SetError("Couldn't convert audio", ret);
++						return false;
++					} else if (nb_samples > 0) {
++						*data = (const int16_t *) m_convert_buffer[0];
++						*size = nb_samples;
++					}
++				}
+ 			}
+ 		}
+-	}
+
+-	return true;
++		return true;
++	}
+ }
+
+ inline void FFmpegAudioReader::SetError(const char *message, int errnum) {
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index a2b517b..123e643 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -38,6 +38,12 @@ set(SRCS
+
+ if(BUILD_TOOLS)
+ 	set(SRCS ${SRCS} ../src/audio/ffmpeg_audio_reader_test.cpp)
++    include_directories(
++        ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}
++        ${AUDIO_PROCESSOR_INCLUDE_DIRS}
++    )
+ 	link_libraries(fpcalc_libs)
+ endif()
+
+-- 
+2.38.1
+
+
diff --git a/srcpkgs/chromaprint/template b/srcpkgs/chromaprint/template
index 7ef7838949f3a..1f7bbc70a22c8 100644
--- a/srcpkgs/chromaprint/template
+++ b/srcpkgs/chromaprint/template
@@ -1,7 +1,7 @@
 # Template file for 'chromaprint'
 pkgname=chromaprint
 version=1.5.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DBUILD_TOOLS=ON"
 make_check_target="check"

From 1c6da6d1d2cf6bafddd5d947c6c9d44e5ea9e728 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 024/113] chromium: revbump for ffmpeg-6.0

---
 .../patches/chromium-93-ffmpeg-4.4.patch      | 36 --------------
 srcpkgs/chromium/patches/ffmpeg5.patch        | 47 +++++++++++++++++++
 srcpkgs/chromium/template                     |  2 +-
 3 files changed, 48 insertions(+), 37 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch
 create mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch b/srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch
deleted file mode 100644
index f0ec736f98bc7..0000000000000
--- a/srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch
+++ /dev/null
@@ -1,36 +0,0 @@
-diff --git a/media/filters/ffmpeg_demuxer.cc b/media/filters/ffmpeg_demuxer.cc
-index ac4713b07268..492a9a37d096 100644
---- a/media/filters/ffmpeg_demuxer.cc
-+++ b/media/filters/ffmpeg_demuxer.cc
-@@ -427,11 +427,11 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
-   scoped_refptr<DecoderBuffer> buffer;
- 
-   if (type() == DemuxerStream::TEXT) {
--    size_t id_size = 0;
-+    int id_size = 0;
-     uint8_t* id_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
- 
--    size_t settings_size = 0;
-+    int settings_size = 0;
-     uint8_t* settings_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
- 
-@@ -443,7 +443,7 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
-     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
-                                      side_data.data(), side_data.size());
-   } else {
--    size_t side_data_size = 0;
-+    int side_data_size = 0;
-     uint8_t* side_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
- 
-@@ -504,7 +504,7 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
-                                        packet->size - data_offset);
-     }
- 
--    size_t skip_samples_size = 0;
-+    int skip_samples_size = 0;
-     const uint32_t* skip_samples_ptr =
-         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
-             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..24e2da38e34ca
--- /dev/null
+++ b/srcpkgs/chromium/patches/ffmpeg5.patch
@@ -0,0 +1,47 @@
+--- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
++++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
+@@ -92,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+-  if (stream->start_time != kNoFFmpegTimestamp)
++  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -1597,7 +1585,7 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+@@ -1618,7 +1606,7 @@
+     if (stream->type() != DemuxerStream::VIDEO)
+       continue;
+ 
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+ 
+     if (!stream->IsEnabled())
diff --git a/srcpkgs/chromium/template b/srcpkgs/chromium/template
index b4a39dfd3815c..c29453cd1f509 100644
--- a/srcpkgs/chromium/template
+++ b/srcpkgs/chromium/template
@@ -2,7 +2,7 @@
 pkgname=chromium
 # See https://chromiumdash.appspot.com/releases?platform=Linux for the latest version
 version=114.0.5735.106
-revision=1
+revision=2
 archs="i686* x86_64* aarch64* armv7l*"
 hostmakedepends="
  $(vopt_if clang "clang lld llvm15")

From a2d6b14b4272b17888d709d2ba8eabcf91529cb1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 025/113] cmus: revbump for ffmpeg-6.0

---
 srcpkgs/cmus/patches/ffmpeg6.patch | 12 ++++++++++++
 srcpkgs/cmus/template              |  2 +-
 2 files changed, 13 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/cmus/patches/ffmpeg6.patch

diff --git a/srcpkgs/cmus/patches/ffmpeg6.patch b/srcpkgs/cmus/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..ffa95ab811101
--- /dev/null
+++ b/srcpkgs/cmus/patches/ffmpeg6.patch
@@ -0,0 +1,12 @@
+--- a/ip/ffmpeg.c
++++ b/ip/ffmpeg.c
+@@ -202,9 +202,6 @@ static int ffmpeg_open(struct input_plugin_data *ip_data)
+ 			break;
+ 		}
+ 
+-		if (codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+-			cc->flags |= AV_CODEC_FLAG_TRUNCATED;
+-
+ 		if (avcodec_open2(cc, codec, NULL) < 0) {
+ 			d_print("could not open codec: %d, %s\n", cc->codec_id, avcodec_get_name(cc->codec_id));
+ 			err = -IP_ERROR_UNSUPPORTED_FILE_TYPE;
diff --git a/srcpkgs/cmus/template b/srcpkgs/cmus/template
index 0fcb424ce336c..05b77d0fecaea 100644
--- a/srcpkgs/cmus/template
+++ b/srcpkgs/cmus/template
@@ -1,7 +1,7 @@
 # Template file for 'cmus'
 pkgname=cmus
 version=2.10.0
-revision=1
+revision=2
 build_style=configure
 configure_args="prefix=/usr LD=$CC"
 hostmakedepends="pkg-config"

From b55280f16d6a828267eeb799c0e6ccc435da8490 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 026/113] cyanrip: revbump for ffmpeg-6.0

---
 srcpkgs/cyanrip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cyanrip/template b/srcpkgs/cyanrip/template
index 9796e3461601a..5db30e020d17e 100644
--- a/srcpkgs/cyanrip/template
+++ b/srcpkgs/cyanrip/template
@@ -1,7 +1,7 @@
 # Template file for 'cyanrip'
 pkgname=cyanrip
 version=0.9.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config"
 makedepends="ffmpeg-devel libcdio-devel libcdio-paranoia-devel libcurl-devel libmusicbrainz5-devel"

From 800906a10adf795f982b438446e34b3f3224026b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 027/113] deadbeef: revbump for ffmpeg4-4.4.3

---
 srcpkgs/deadbeef/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/deadbeef/template b/srcpkgs/deadbeef/template
index b664bb1b9bd9f..165b3c7b9cad8 100644
--- a/srcpkgs/deadbeef/template
+++ b/srcpkgs/deadbeef/template
@@ -1,14 +1,14 @@
 # Template file for 'deadbeef'
 pkgname=deadbeef
 version=1.8.8
-revision=1
+revision=2
 create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-oss --disable-lfm --disable-notify --disable-gtk2"
 hostmakedepends="automake libtool gettext gettext-devel intltool pkg-config
  yasm clang glib-devel"
 makedepends="
- alsa-lib-devel dbus-devel faad2-devel ffmpeg-devel gtk+3-devel imlib2-devel
+ alsa-lib-devel dbus-devel faad2-devel ffmpeg4-devel gtk+3-devel imlib2-devel
  jansson-devel libcddb-devel libcdio-devel libcurl-devel libflac-devel
  libmad-devel libpng-devel libsamplerate-devel libsndfile-devel libvorbis-devel
  libzip-devel mpg123-devel opusfile-devel pulseaudio-devel wavpack-devel"

From 8dd109c892c872c5e84531070a9e769e4701d707 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 028/113] dolphin-emu: revbump for ffmpeg-6.0

---
 srcpkgs/dolphin-emu/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/dolphin-emu/template b/srcpkgs/dolphin-emu/template
index 7ea197ceb2a8e..7aeb0a5b645e0 100644
--- a/srcpkgs/dolphin-emu/template
+++ b/srcpkgs/dolphin-emu/template
@@ -1,7 +1,7 @@
 # Template file for 'dolphin-emu'
 pkgname=dolphin-emu
 version=5.0.16101
-revision=1
+revision=2
 _dolphin_commit=8ecfa537a242de74d2e372e30d9d79b14584b2fb
 _mgba_commit=40d4c430fc36caeb7ea32fd39624947ed487d2f2
 #Version/hash pair can be found at https://dolphin-emu.org/download/

From dd30734a002ffd50973935315d955b5e39f7a58b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 029/113] droidcam-obs-plugin: revbump for ffmpeg-6.0

---
 srcpkgs/droidcam-obs-plugin/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam-obs-plugin/template b/srcpkgs/droidcam-obs-plugin/template
index fc9c9bf6b9d54..fb0480754df4d 100644
--- a/srcpkgs/droidcam-obs-plugin/template
+++ b/srcpkgs/droidcam-obs-plugin/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam-obs-plugin'
 pkgname=droidcam-obs-plugin
 version=2.0.1
-revision=1
+revision=2
 build_style=gnu-makefile
 make_use_env=yes
 make_build_args="ALLOW_STATIC=no"

From 66a4cfc1088c4ad81fd0027ea0de3189d78bf230 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 030/113] droidcam: revbump for ffmpeg-6.0

---
 srcpkgs/droidcam/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam/template b/srcpkgs/droidcam/template
index 1c3f1b8b1fc67..32a9220b79a4d 100644
--- a/srcpkgs/droidcam/template
+++ b/srcpkgs/droidcam/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam'
 pkgname=droidcam
 version=1.8.2
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="USBMUXD=-lusbmuxd-2.0 JPEG=-lturbojpeg"
 hostmakedepends="pkg-config"

From 0ca5ac90f8c2ab9c675aa9d4938db2f3b230d6bb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 031/113] ffmpegthumbnailer: revbump for ffmpeg-6.0

---
 .../ffmpegthumbnailer/patches/ffmpeg6.patch   | 202 ++++++++++++++++++
 srcpkgs/ffmpegthumbnailer/template            |   6 +-
 2 files changed, 205 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch

diff --git a/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..363ff35a28419
--- /dev/null
+++ b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
@@ -0,0 +1,202 @@
+--- a/libffmpegthumbnailer/moviedecoder.cpp	2017-11-21 14:06:57.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.cpp	2023-05-05 13:14:47.946560668 -0400
+@@ -41,11 +41,6 @@
+ namespace ffmpegthumbnailer
+ {
+ 
+-struct SilenceLogLevel
+-{
+-    SilenceLogLevel() { av_log_set_level(AV_LOG_QUIET); }
+-};
+-
+ MovieDecoder::MovieDecoder(AVFormatContext* pavContext)
+ : m_VideoStream(-1)
+ , m_pFormatContext(pavContext)
+@@ -70,8 +65,6 @@
+ 
+ void MovieDecoder::initialize(const string& filename, bool preferEmbeddedMetadata)
+ {
+-    av_register_all();
+-    avcodec_register_all();
+     avformat_network_init();
+ 
+     string inputFile = filename == "-" ? "pipe:" : filename;
+@@ -97,8 +90,7 @@
+ {
+     if (m_pVideoCodecContext)
+     {
+-        avcodec_close(m_pVideoCodecContext);
+-        m_pVideoCodecContext = nullptr;
++        avcodec_free_context(&m_pVideoCodecContext);
+     }
+ 
+     if ((!m_FormatContextWasGiven) && m_pFormatContext)
+@@ -152,10 +144,10 @@
+     for (unsigned int i = 0; i < m_pFormatContext->nb_streams; ++i)
+     {
+         AVStream *stream = m_pFormatContext->streams[i];
+-        auto ctx = m_pFormatContext->streams[i]->codec;
+-        if (ctx->codec_type == AVMEDIA_TYPE_VIDEO)
++        auto par = m_pFormatContext->streams[i]->codecpar;
++        if (par->codec_type == AVMEDIA_TYPE_VIDEO)
+         {
+-            if (!preferEmbeddedMetadata || !isStillImageCodec(ctx->codec_id))
++            if (!preferEmbeddedMetadata || !isStillImageCodec(par->codec_id))
+             {
+                 videoStreams.push_back(i);
+                 continue;
+@@ -203,8 +195,7 @@
+     }
+ 
+     m_pVideoStream = m_pFormatContext->streams[m_VideoStream];
+-    m_pVideoCodecContext = m_pVideoStream->codec;
+-    m_pVideoCodec = avcodec_find_decoder(m_pVideoCodecContext->codec_id);
++    m_pVideoCodec = avcodec_find_decoder(m_pVideoStream->codecpar->codec_id);
+ 
+     if (m_pVideoCodec == nullptr)
+     {
+@@ -214,6 +205,20 @@
+         throw logic_error("Video Codec not found");
+     }
+ 
++    m_pVideoCodecContext = avcodec_alloc_context3(m_pVideoCodec);
++
++    if (m_pVideoCodecContext == nullptr)
++    {
++        destroy();
++        throw logic_error("Could not allocate video codec context");
++    }
++
++    if (avcodec_parameters_to_context(m_pVideoCodecContext, m_pVideoStream->codecpar) < 0)
++    {
++        destroy();
++        throw logic_error("Could not configure video codec context");
++    }
++
+     m_pVideoCodecContext->workaround_bugs = 1;
+ 
+     if (avcodec_open2(m_pVideoCodecContext, m_pVideoCodec, nullptr) < 0)
+@@ -386,13 +391,6 @@
+ 
+ void MovieDecoder::initializeFilterGraph(const AVRational& timeBase, const std::string& size, bool maintainAspectRatio)
+ {
+-    static const AVPixelFormat pixelFormats[] = { AV_PIX_FMT_RGB24, AV_PIX_FMT_NONE };
+-
+-    auto del = [] (AVBufferSinkParams* p) { av_freep(p); };
+-    std::unique_ptr<AVBufferSinkParams, decltype(del)> buffersinkParams(av_buffersink_params_alloc(), del);
+-
+-    avfilter_register_all();
+-
+     m_pFilterGraph = avfilter_graph_alloc();
+     assert(m_pFilterGraph);
+ 
+@@ -404,10 +402,8 @@
+ 
+     checkRc(avfilter_graph_create_filter(&m_pFilterSource, avfilter_get_by_name("buffer"), "thumb_buffer", ss.str().c_str(), nullptr, m_pFilterGraph),
+             "Failed to create filter source");
+-    buffersinkParams->pixel_fmts = pixelFormats;
+-    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, buffersinkParams.get(), m_pFilterGraph),
++    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, nullptr, m_pFilterGraph),
+             "Failed to create filter sink");
+-    buffersinkParams.release();
+ 
+     AVFilterContext* yadifFilter = nullptr;
+     if (m_pFrame->interlaced_frame != 0)
+@@ -500,15 +496,15 @@
+     }
+ 
+     checkRc(av_seek_frame(m_pFormatContext, -1, timestamp, 0), "Seeking in video failed");
+-    avcodec_flush_buffers(m_pFormatContext->streams[m_VideoStream]->codec);
++    avcodec_flush_buffers(m_pVideoCodecContext);
+ 
+     int keyFrameAttempts = 0;
+-    bool gotFrame = 0;
++    bool gotFrame;
+ 
+     do
+     {
+         int count = 0;
+-        gotFrame = 0;
++        gotFrame = false;
+ 
+         while (!gotFrame && count < 20)
+         {
+@@ -552,17 +548,33 @@
+         return false;
+     }
+ 
+-    av_frame_unref(m_pFrame);
+-
+-    int frameFinished;
++    int rc = avcodec_send_packet(m_pVideoCodecContext, m_pPacket);
++    if(rc == AVERROR(EAGAIN))
++    {
++        rc = 0;
++    }
+ 
+-    int bytesDecoded = avcodec_decode_video2(m_pVideoCodecContext, m_pFrame, &frameFinished, m_pPacket);
+-    if (bytesDecoded < 0)
++    if(rc == AVERROR_EOF)
++    {
++        return false;
++    }
++    else if(rc < 0)
+     {
+-        throw logic_error("Failed to decode video frame: bytesDecoded < 0");
++        throw logic_error("Failed to decode video frame: avcodec_send_packet() < 0");
+     }
+ 
+-    return frameFinished > 0;
++    rc = avcodec_receive_frame(m_pVideoCodecContext, m_pFrame);
++    switch(rc)
++    {
++        case 0:
++            return true;
++
++        case AVERROR(EAGAIN):
++            return false;
++
++        default:
++            throw logic_error("Failed to decode video frame: avcodec_receive_frame() < 0");
++    }
+ }
+ 
+ bool MovieDecoder::getVideoPacket()
+@@ -570,8 +582,6 @@
+     bool framesAvailable = true;
+     bool frameDecoded = false;
+ 
+-    int attempts = 0;
+-
+     if (m_pPacket)
+     {
+         av_packet_unref(m_pPacket);
+@@ -580,6 +590,7 @@
+ 
+     m_pPacket = new AVPacket();
+ 
++
+     while (framesAvailable && !frameDecoded)
+     {
+         framesAvailable = av_read_frame(m_pFormatContext, m_pPacket) >= 0;
+@@ -644,7 +655,7 @@
+ 
+ int32_t MovieDecoder::getStreamRotation()
+ {
+-    int32_t* matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
++    auto matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
+     if (matrix)
+     {
+         auto angle = lround(av_display_rotation_get(matrix));
+
+--- a/libffmpegthumbnailer/moviedecoder.h	2017-11-12 04:23:38.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.h	2023-05-05 13:26:07.095529911 -0400
+@@ -78,7 +78,7 @@
+     int                     m_VideoStream;
+     AVFormatContext*        m_pFormatContext;
+     AVCodecContext*         m_pVideoCodecContext;
+-    AVCodec*                m_pVideoCodec;
++    const AVCodec*          m_pVideoCodec;
+     AVFilterGraph*          m_pFilterGraph;
+     AVFilterContext*        m_pFilterSource;
+     AVFilterContext*        m_pFilterSink;
diff --git a/srcpkgs/ffmpegthumbnailer/template b/srcpkgs/ffmpegthumbnailer/template
index 039eea7622b39..35d546018d12a 100644
--- a/srcpkgs/ffmpegthumbnailer/template
+++ b/srcpkgs/ffmpegthumbnailer/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbnailer'
 pkgname=ffmpegthumbnailer
 version=2.2.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libpng-devel libjpeg-turbo-devel ffmpeg-devel"
@@ -9,8 +9,8 @@ depends="ffmpeg"
 short_desc="Lightweight video thumbnailer"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
-homepage="https://github.com/dirkvdb/${pkgname}"
-distfiles="${homepage}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
+homepage="https://github.com/dirkvdb"
+distfiles="${homepage}/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
 checksum=1cb24059c38223f657b300c84dd80491b7040d4b69471c4fea69be862bc99b5b
 
 post_install() {

From 95cfc4ff7f2df5015541365b4e63bcbd81b0c633 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 032/113] ffmpegthumbs: revbump for ffmpeg-6.0

---
 srcpkgs/ffmpegthumbs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ffmpegthumbs/template b/srcpkgs/ffmpegthumbs/template
index 5f0b9414dadaf..11b88193528f4 100644
--- a/srcpkgs/ffmpegthumbs/template
+++ b/srcpkgs/ffmpegthumbs/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbs'
 pkgname=ffmpegthumbs
 version=22.12.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules kcoreaddons kconfig-devel
  pkg-config qt5-host-tools qt5-qmake gettext"

From 96cbfd395949478b017fe42072d30f7a7e2cf12f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 033/113] ffms2: revbump for ffmpeg-6.0

---
 srcpkgs/ffms2/patches/ffmpeg5.patch | 424 ++++++++++++++++++++++++++++
 srcpkgs/ffms2/template              |   2 +-
 2 files changed, 425 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ffms2/patches/ffmpeg5.patch

diff --git a/srcpkgs/ffms2/patches/ffmpeg5.patch b/srcpkgs/ffms2/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..1479fabcafcb4
--- /dev/null
+++ b/srcpkgs/ffms2/patches/ffmpeg5.patch
@@ -0,0 +1,424 @@
+From 45673149e9a2f5586855ad472e3059084eaa36b1 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:41:21 +0100
+Subject: [PATCH] Use auto for AVCodec
+
+The geniuses over at FFmpeg decided to constify this API, so old
+versions of the library will return AVCodec *, while new versions
+of the libary will return const AVCodec *, which, in C++, are not
+OK to convert between.
+
+Rather than use some macro hell in ffmscompat.h, we can work around
+this by using auto.
+
+Gross.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 2 +-
+ src/core/indexing.cpp    | 6 +++---
+ src/core/videosource.cpp | 2 +-
+ 3 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index e4ce97c..ac09666 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -469,7 +469,7 @@ void FFMS_AudioSource::OpenFile() {
+ 
+     LAVFOpenFile(SourceFile.c_str(), FormatContext, TrackNumber);
+ 
+-    AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
++    auto *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
+     if (Codec == nullptr)
+         throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+             "Audio codec not found");
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index e547c5a..59fb4e8 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -384,7 +384,7 @@ FFMS_TrackType FFMS_Indexer::GetTrackType(int Track) {
+ }
+ 
+ const char *FFMS_Indexer::GetTrackCodec(int Track) {
+-    AVCodec *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
++    auto *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
+     return codec ? codec->name : nullptr;
+ }
+ 
+@@ -402,7 +402,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             UseDTS);
+ 
+         if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            AVCodec *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (!VideoCodec) {
+                 FormatContext->streams[i]->discard = AVDISCARD_ALL;
+                 IndexMask.erase(i);
+@@ -433,7 +433,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 IndexMask.insert(i);
+             }
+         } else if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+-            AVCodec *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (AudioCodec == nullptr)
+                 throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_UNSUPPORTED,
+                     "Audio codec not found");
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index b889970..8956c22 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -171,7 +171,7 @@ FFMS_VideoSource::FFMS_VideoSource(const char *SourceFile, FFMS_Index &Index, in
+ 
+         LAVFOpenFile(SourceFile, FormatContext, VideoTrack);
+ 
+-        AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
++        auto *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
+         if (Codec == nullptr)
+             throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+                 "Video codec not found");
+-- 
+2.40.0
+
+From 96cbf38ea9381829a1314f432a2c60495dcefaad Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:12:41 +0100
+Subject: [PATCH] all: Update AVPacket API usage
+
+AVPackets must all be on the heap now, since it is no longer
+part of the libav* ABI.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 16 ++++++----
+ src/core/indexing.cpp    | 63 ++++++++++++++++++++++------------------
+ src/core/indexing.h      |  4 +--
+ src/core/utils.cpp       |  6 ----
+ src/core/utils.h         |  1 -
+ src/core/videosource.cpp | 30 ++++++++++---------
+ 6 files changed, 64 insertions(+), 56 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index 37cf9ae..e4ce97c 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -285,10 +285,15 @@ FFMS_AudioSource::AudioBlock *FFMS_AudioSource::CacheBlock(CacheIterator &pos) {
+ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     CurrentFrame = &Frames[PacketNumber];
+ 
+-    AVPacket Packet;
+-    if (!ReadPacket(&Packet))
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++    if (!ReadPacket(Packet)) {
++        av_packet_free(&Packet);
+         throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_UNKNOWN,
+             "ReadPacket unexpectedly failed to read a packet");
++    }
+ 
+     // ReadPacket may have changed the packet number
+     CurrentFrame = &Frames[PacketNumber];
+@@ -297,8 +302,9 @@ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     int NumberOfSamples = 0;
+     AudioBlock *CachedBlock = nullptr;
+     
+-    int Ret = avcodec_send_packet(CodecContext, &Packet);
+-    av_packet_unref(&Packet);
++    int Ret = avcodec_send_packet(CodecContext, Packet);
++    av_packet_unref(Packet);
++    av_packet_free(&Packet);
+ 
+     av_frame_unref(DecodeFrame);
+     Ret = avcodec_receive_frame(CodecContext, DecodeFrame);
+@@ -513,8 +519,6 @@ void FFMS_AudioSource::Seek() {
+ }
+ 
+ bool FFMS_AudioSource::ReadPacket(AVPacket *Packet) {
+-    InitNullPacket(*Packet);
+-
+     while (av_read_frame(FormatContext, Packet) >= 0) {
+         if (Packet->stream_index == TrackNumber) {
+             // Required because not all audio packets, especially in ogg, have a pts. Use the previous valid packet's pts instead.
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index 23fb95b..e547c5a 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -320,7 +320,7 @@ void FFMS_Indexer::CheckAudioProperties(int Track, AVCodecContext *Context) {
+     }
+ }
+ 
+-void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict,
++void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict,
+                                     int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct) {
+     if (VideoContext.Parser) {
+         uint8_t *OB;
+@@ -330,8 +330,8 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+         av_parser_parse2(VideoContext.Parser,
+             VideoContext.CodecContext,
+             &OB, &OBSize,
+-            pkt.data, pkt.size,
+-            pkt.pts, pkt.dts, pkt.pos);
++            pkt->data, pkt->size,
++            pkt->pts, pkt->dts, pkt->pos);
+ 
+         // H.264 (PAFF) and HEVC may have one field per packet, so we need to track
+         // when we have a full or half frame available, and mark one of them as
+@@ -351,15 +351,15 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+ 
+         *RepeatPict = VideoContext.Parser->repeat_pict;
+         *FrameType = VideoContext.Parser->pict_type;
+-        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt.flags & AV_PKT_FLAG_DISCARD));
++        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt->flags & AV_PKT_FLAG_DISCARD));
+     } else {
+-        *Invisible = !!(pkt.flags & AV_PKT_FLAG_DISCARD);
++        *Invisible = !!(pkt->flags & AV_PKT_FLAG_DISCARD);
+     }
+ 
+     if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP8)
+-        ParseVP8(pkt.data[0], Invisible, FrameType);
++        ParseVP8(pkt->data[0], Invisible, FrameType);
+     else if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP9)
+-        ParseVP9(pkt.data[0], Invisible, FrameType);
++        ParseVP9(pkt->data[0], Invisible, FrameType);
+ }
+ 
+ void FFMS_Indexer::Free() {
+@@ -458,32 +458,36 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+         }
+     }
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
+     std::vector<int64_t> LastValidTS(FormatContext->nb_streams, AV_NOPTS_VALUE);
+ 
+     int64_t filesize = avio_size(FormatContext->pb);
+     enum AVPictureStructure LastPicStruct = AV_PICTURE_STRUCTURE_UNKNOWN;
+-    while (av_read_frame(FormatContext, &Packet) >= 0) {
++    while (av_read_frame(FormatContext, Packet) >= 0) {
+         // Update progress
+         // FormatContext->pb can apparently be NULL when opening images.
+         if (IC && FormatContext->pb) {
+-            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate))
++            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate)) {
++                av_packet_free(&Packet);
+                 throw FFMS_Exception(FFMS_ERROR_CANCELLED, FFMS_ERROR_USER,
+                     "Cancelled by user");
++            }
+         }
+-        if (!IndexMask.count(Packet.stream_index)) {
+-            av_packet_unref(&Packet);
++        if (!IndexMask.count(Packet->stream_index)) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+-        int Track = Packet.stream_index;
++        int Track = Packet->stream_index;
+         FFMS_Track &TrackInfo = (*TrackIndices)[Track];
+-        bool KeyFrame = !!(Packet.flags & AV_PKT_FLAG_KEY);
++        bool KeyFrame = !!(Packet->flags & AV_PKT_FLAG_KEY);
+         ReadTS(Packet, LastValidTS[Track], (*TrackIndices)[Track].UseDTS);
+ 
+         if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            int64_t PTS = TrackInfo.UseDTS ? Packet.dts : Packet.pts;
++            int64_t PTS = TrackInfo.UseDTS ? Packet->dts : Packet->pts;
+             if (PTS == AV_NOPTS_VALUE) {
+                 // VPx alt-refs are output as packets which lack timestmps or durations, since
+                 // they are invisible. Currently, the timestamp mangling code in libavformat
+@@ -495,9 +499,11 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 // FFMS2 currently sorts packets by PTS, which will break decoding, otherwise.
+                 bool HasAltRefs = (FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP8 ||
+                                    FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP9);
+-                if (Packet.duration == 0 && !HasAltRefs)
++                if (Packet->duration == 0 && !HasAltRefs) {
++                    av_packet_free(&Packet);
+                     throw FFMS_Exception(FFMS_ERROR_INDEXING, FFMS_ERROR_PARSER,
+                         "Invalid packet pts, dts, and duration");
++                }
+ 
+                 if (TrackInfo.empty())
+                     PTS = 0;
+@@ -513,7 +519,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             ParseVideoPacket(AVContexts[Track], Packet, &RepeatPict, &FrameType, &Invisible, &LastPicStruct);
+ 
+             TrackInfo.AddVideoFrame(PTS, RepeatPict, KeyFrame,
+-                FrameType, Packet.pos, Invisible);
++                FrameType, Packet->pos, Invisible);
+         } else if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+             // For video seeking timestamps are used only if all packets have
+             // timestamps, while for audio they're used if any have timestamps,
+@@ -522,28 +528,29 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 TrackInfo.HasTS = true;
+ 
+             int64_t StartSample = AVContexts[Track].CurrentSample;
+-            uint32_t SampleCount = IndexAudioPacket(Track, &Packet, AVContexts[Track], *TrackIndices);
++            uint32_t SampleCount = IndexAudioPacket(Track, Packet, AVContexts[Track], *TrackIndices);
+             TrackInfo.SampleRate = AVContexts[Track].CodecContext->sample_rate;
+ 
+             TrackInfo.AddAudioFrame(LastValidTS[Track],
+-                StartSample, SampleCount, KeyFrame, Packet.pos, Packet.flags & AV_PKT_FLAG_DISCARD);
++                StartSample, SampleCount, KeyFrame, Packet->pos, Packet->flags & AV_PKT_FLAG_DISCARD);
+         }
+ 
+-        if (!(Packet.flags & AV_PKT_FLAG_DISCARD))
+-            TrackInfo.LastDuration = Packet.duration;
++        if (!(Packet->flags & AV_PKT_FLAG_DISCARD))
++            TrackInfo.LastDuration = Packet->duration;
+ 
+-        av_packet_unref(&Packet);
++        av_packet_unref(Packet);
+     }
++    av_packet_free(&Packet);
+ 
+     TrackIndices->Finalize(AVContexts, FormatContext->iformat->name);
+     return TrackIndices.release();
+ }
+ 
+-void FFMS_Indexer::ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS) {
+-    if (!UseDTS && Packet.pts != AV_NOPTS_VALUE)
+-        TS = Packet.pts;
++void FFMS_Indexer::ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS) {
++    if (!UseDTS && Packet->pts != AV_NOPTS_VALUE)
++        TS = Packet->pts;
+     if (TS == AV_NOPTS_VALUE)
+         UseDTS = true;
+-    if (UseDTS && Packet.dts != AV_NOPTS_VALUE)
+-        TS = Packet.dts;
++    if (UseDTS && Packet->dts != AV_NOPTS_VALUE)
++        TS = Packet->dts;
+ }
+diff --git a/src/core/indexing.h b/src/core/indexing.h
+index 3cfc3c3..5c06868 100644
+--- a/src/core/indexing.h
++++ b/src/core/indexing.h
+@@ -80,10 +80,10 @@ private:
+     int64_t Filesize;
+     uint8_t Digest[20];
+ 
+-    void ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS);
++    void ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS);
+     void CheckAudioProperties(int Track, AVCodecContext *Context);
+     uint32_t IndexAudioPacket(int Track, AVPacket *Packet, SharedAVContext &Context, FFMS_Index &TrackIndices);
+-    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
++    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
+     void Free();
+ public:
+     FFMS_Indexer(const char *Filename);
+diff --git a/src/core/utils.cpp b/src/core/utils.cpp
+index ce67533..8a2e997 100644
+--- a/src/core/utils.cpp
++++ b/src/core/utils.cpp
+@@ -62,12 +62,6 @@ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo) {
+     }
+ }
+ 
+-void InitNullPacket(AVPacket &pkt) {
+-    av_init_packet(&pkt);
+-    pkt.data = nullptr;
+-    pkt.size = 0;
+-}
+-
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames) {
+     AP.SampleFormat = static_cast<FFMS_SampleFormat>(av_get_packed_sample_fmt(CTX->sample_fmt));
+     AP.BitsPerSample = av_get_bytes_per_sample(CTX->sample_fmt) * 8;
+diff --git a/src/core/utils.h b/src/core/utils.h
+index 9819dc7..003ab79 100644
+--- a/src/core/utils.h
++++ b/src/core/utils.h
+@@ -58,7 +58,6 @@ std::unique_ptr<T> make_unique(Args&&... args) {
+ }
+ 
+ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo);
+-void InitNullPacket(AVPacket &pkt);
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames);
+ 
+ void LAVFOpenFile(const char *SourceFile, AVFormatContext *&FormatContext, int Track);
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index 06bd161..b889970 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -673,30 +673,34 @@ void FFMS_VideoSource::DecodeNextFrame(int64_t &AStartTime, int64_t &Pos) {
+     if (HasPendingDelayedFrames())
+         return;
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
+-
+-    while (ReadFrame(&Packet) >= 0) {
+-        if (Packet.stream_index != VideoTrack) {
+-            av_packet_unref(&Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++
++    while (ReadFrame(Packet) >= 0) {
++        if (Packet->stream_index != VideoTrack) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+         if (AStartTime < 0)
+-            AStartTime = Frames.UseDTS ? Packet.dts : Packet.pts;
++            AStartTime = Frames.UseDTS ? Packet->dts : Packet->pts;
+ 
+         if (Pos < 0)
+-            Pos = Packet.pos;
++            Pos = Packet->pos;
+ 
+-        bool FrameFinished = DecodePacket(&Packet);
+-        av_packet_unref(&Packet);
+-        if (FrameFinished)
++        bool FrameFinished = DecodePacket(Packet);
++        av_packet_unref(Packet);
++        if (FrameFinished) {
++            av_packet_free(&Packet);
+             return;
++        }
+     }
+ 
+     // Flush final frames
+-    InitNullPacket(Packet);
+-    DecodePacket(&Packet);
++    DecodePacket(Packet);
++    av_packet_free(&Packet);
+ }
+ 
+ bool FFMS_VideoSource::SeekTo(int n, int SeekOffset) {
+-- 
+2.40.0
+
+From bf9e03e9e08534c024e5a744a6437c4aac160201 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:20:47 +0100
+Subject: [PATCH 2/3] configure: Remove deprecated API use
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ configure.ac | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index b35ef80bc..d19714d0f 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -102,10 +102,10 @@ CFLAGS="$_CFLAGS $FFMPEG_CFLAGS"
+
+ AC_DEFUN([TEST_FFMPEG],
+          [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+-            #include <libavcodec/avcodec.h>
++            #include <libavformat/avformat.h>
+             #include <libswscale/swscale.h>
+             ]],[[
+-                avcodec_register_all();
++                avformat_network_init();
+                 swscale_version();
+             ]])], [eval $1=yes], [eval $1=no])
+         ])
+
diff --git a/srcpkgs/ffms2/template b/srcpkgs/ffms2/template
index 68e8a0c14bce3..2acfadac44b34 100644
--- a/srcpkgs/ffms2/template
+++ b/srcpkgs/ffms2/template
@@ -1,7 +1,7 @@
 # Template file for 'ffms2'
 pkgname=ffms2
 version=2.40
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-shared --disable-static"
 hostmakedepends="pkg-config autoconf automake libtool"

From e874041f3f3354e6d2ec4cd3b335adbae9a02236 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 034/113] freerdp: revbump for ffmpeg-6.0

---
 .../freerdp/patches/ffmpeg6_aa2cb9aa.patch    | 42 +++++++++++++++++++
 srcpkgs/freerdp/template                      |  2 +-
 2 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch

diff --git a/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
new file mode 100644
index 0000000000000..a4324da3a8822
--- /dev/null
+++ b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
@@ -0,0 +1,42 @@
+From aa2cb9aa5ff5562433598ba168a466e0752bca0e Mon Sep 17 00:00:00 2001
+From: akallabeth <akallabeth@posteo.net>
+Date: Tue, 14 Feb 2023 07:48:54 +0100
+Subject: [PATCH] Fixed #8686: Update h264 to use new FFMPEG API
+
+---
+ channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c | 2 ++
+ libfreerdp/codec/h264_ffmpeg.c            | 2 ++
+ 2 files changed, 4 insertions(+)
+
+diff --git a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+index 339462d865f..beea80b7a1e 100644
+--- a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
++++ b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+@@ -239,8 +239,10 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYP
+ 		}
+ 	}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 	if (mdecoder->codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		mdecoder->codec_context->flags |= AV_CODEC_FLAG_TRUNCATED;
++#endif
+ 
+ 	return TRUE;
+ }
+diff --git a/libfreerdp/codec/h264_ffmpeg.c b/libfreerdp/codec/h264_ffmpeg.c
+index 8a23db2473c..896a333019b 100644
+--- a/libfreerdp/codec/h264_ffmpeg.c
++++ b/libfreerdp/codec/h264_ffmpeg.c
+@@ -615,10 +615,12 @@ static BOOL libavcodec_init(H264_CONTEXT* h264)
+ 			goto EXCEPTION;
+ 		}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 		if (sys->codecDecoder->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		{
+ 			sys->codecDecoderContext->flags |= AV_CODEC_FLAG_TRUNCATED;
+ 		}
++#endif
+ 
+ #ifdef WITH_VAAPI
+ 
diff --git a/srcpkgs/freerdp/template b/srcpkgs/freerdp/template
index 25e8aa9677f0b..4d51c8189902a 100644
--- a/srcpkgs/freerdp/template
+++ b/srcpkgs/freerdp/template
@@ -1,7 +1,7 @@
 # Template file for 'freerdp'
 pkgname=freerdp
 version=2.10.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_ALSA=ON -DWITH_CUPS=OFF -DWITH_FFMPEG=ON
  -DWITH_GSTREAMER_0_10=OFF -DWITH_GSTREAMER_1_0=OFF -DWITH_JPEG=ON

From 8c88a89ec931b6ea742d7fada33746d1f4e29937 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 035/113] gerbera: revbump for ffmpeg-6.0

---
 srcpkgs/gerbera/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gerbera/template b/srcpkgs/gerbera/template
index ae14f35c767c0..2dc0ac0ce03b5 100644
--- a/srcpkgs/gerbera/template
+++ b/srcpkgs/gerbera/template
@@ -1,7 +1,7 @@
 # Template file for 'gerbera'
 pkgname=gerbera
 version=1.12.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_SYSTEMD=0 -DWITH_AVCODEC=1"
 hostmakedepends="pkg-config"

From 228fe1e6a1512fdc694bed33de3f6a8d90e1777a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 036/113] goldendict: revbump for ffmpeg-6.0

---
 srcpkgs/goldendict/patches/ffmpeg5.patch | 232 +++++++++++++++++++++++
 srcpkgs/goldendict/template              |   4 +-
 2 files changed, 234 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/goldendict/patches/ffmpeg5.patch

diff --git a/srcpkgs/goldendict/patches/ffmpeg5.patch b/srcpkgs/goldendict/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..7cfc98ada368a
--- /dev/null
+++ b/srcpkgs/goldendict/patches/ffmpeg5.patch
@@ -0,0 +1,232 @@
+From 03bbe01b79a1f07a6780cb60f23a087104c5d77b Mon Sep 17 00:00:00 2001
+From: Abs62 <ottomann@yandex.ru>
+Date: Fri, 30 Mar 2018 22:53:24 +0300
+Subject: [PATCH] Fix warnings while compile with FFMpeg 3.4.2 (issue #978)
+
+---
+ ffmpegaudio.cc | 68 +++++++++++++++++++++++++++++++++++++++++++++-----
+ 1 file changed, 62 insertions(+), 6 deletions(-)
+
+diff --git a/ffmpegaudio.cc b/ffmpegaudio.cc
+index ed1172bdd..56e8f788e 100644
+--- a/ffmpegaudio.cc
++++ b/ffmpegaudio.cc
+@@ -91,6 +91,7 @@ struct DecoderContext
+   QByteArray audioData_;
+   QDataStream audioDataStream_;
+   AVFormatContext * formatContext_;
++  AVCodec * codec_;
+   AVCodecContext * codecContext_;
+   AVIOContext * avioContext_;
+   AVStream * audioStream_;
+@@ -114,6 +115,7 @@ DecoderContext::DecoderContext( QByteArray const & audioData, QAtomicInt & isCan
+   audioData_( audioData ),
+   audioDataStream_( audioData_ ),
+   formatContext_( NULL ),
++  codec_( NULL ),
+   codecContext_( NULL ),
+   avioContext_( NULL ),
+   audioStream_( NULL ),
+@@ -143,7 +145,11 @@ bool DecoderContext::openCodec( QString & errorString )
+     return false;
+   }
+
++#if LIBAVCODEC_VERSION_MAJOR < 56 || ( LIBAVCODEC_VERSION_MAJOR == 56 && LIBAVCODEC_VERSION_MINOR < 56 )
+   unsigned char * avioBuffer = ( unsigned char * )av_malloc( kBufferSize + FF_INPUT_BUFFER_PADDING_SIZE );
++#else
++  unsigned char * avioBuffer = ( unsigned char * )av_malloc( kBufferSize + AV_INPUT_BUFFER_PADDING_SIZE );
++#endif
+   if ( !avioBuffer )
+   {
+     errorString = QObject::tr( "av_malloc() failed." );
+@@ -186,7 +192,11 @@ bool DecoderContext::openCodec( QString & errorString )
+   // Find audio stream, use the first audio stream if available
+   for ( unsigned i = 0; i < formatContext_->nb_streams; i++ )
+   {
++#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 33 )
+     if ( formatContext_->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO )
++#else
++      if ( formatContext_->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO )
++#endif
+     {
+       audioStream_ = formatContext_->streams[i];
+       break;
+@@ -198,22 +208,38 @@ bool DecoderContext::openCodec( QString & errorString )
+     return false;
+   }
+
++#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 33 )
+   codecContext_ = audioStream_->codec;
+-  AVCodec * codec = avcodec_find_decoder( codecContext_->codec_id );
+-  if ( !codec )
++  codec_ = avcodec_find_decoder( codecContext_->codec_id );
++  if ( !codec_ )
+   {
+     errorString = QObject::tr( "Codec [id: %1] not found." ).arg( codecContext_->codec_id );
+     return false;
+   }
++#else
++  codec_ = avcodec_find_decoder( audioStream_->codecpar->codec_id );
++  if ( !codec_ )
++  {
++    errorString = QObject::tr( "Codec [id: %1] not found." ).arg( audioStream_->codecpar->codec_id );
++    return false;
++  }
++  codecContext_ = avcodec_alloc_context3( codec_ );
++  if ( !codecContext_ )
++  {
++    errorString = QObject::tr( "avcodec_alloc_context3() failed." );
++    return false;
++  }
++  avcodec_parameters_to_context( codecContext_, audioStream_->codecpar );
++#endif
+
+-  ret = avcodec_open2( codecContext_, codec, NULL );
++  ret = avcodec_open2( codecContext_, codec_, NULL );
+   if ( ret < 0 )
+   {
+     errorString = QObject::tr( "avcodec_open2() failed: %1." ).arg( avErrorString( ret ) );
+     return false;
+   }
+
+-  av_log( NULL, AV_LOG_INFO, "Codec open: %s: channels: %d, rate: %d, format: %s\n", codec->long_name,
++  av_log( NULL, AV_LOG_INFO, "Codec open: %s: channels: %d, rate: %d, format: %s\n", codec_->long_name,
+           codecContext_->channels, codecContext_->sample_rate, av_get_sample_fmt_name( codecContext_->sample_fmt ) );
+   return true;
+ }
+@@ -252,10 +278,13 @@ void DecoderContext::closeCodec()
+
+   // Closing a codec context without prior avcodec_open2() will result in
+   // a crash in ffmpeg
+-  if ( audioStream_ && audioStream_->codec && audioStream_->codec->codec )
++  if ( audioStream_ && codecContext_ && codec_ )
+   {
+     audioStream_->discard = AVDISCARD_ALL;
+-    avcodec_close( audioStream_->codec );
++    avcodec_close( codecContext_ );
++#if LIBAVCODEC_VERSION_MAJOR > 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR >= 33 )
++    avcodec_free_context( &codecContext_ );
++#endif
+   }
+
+   avformat_close_input( &formatContext_ );
+@@ -356,6 +385,7 @@ bool DecoderContext::play( QString & errorString )
+     if ( packet.stream_index == audioStream_->index )
+     {
+       AVPacket pack = packet;
++#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 37 )
+       int gotFrame = 0;
+       do
+       {
+@@ -370,6 +400,19 @@ bool DecoderContext::play( QString & errorString )
+         pack.data += len;
+       }
+       while( pack.size > 0 );
++#else
++      int ret = avcodec_send_packet( codecContext_, &pack );
++      /* read all the output frames (in general there may be any number of them) */
++      while( ret >= 0 )
++      {
++        ret = avcodec_receive_frame( codecContext_, frame);
++
++        if ( Qt4x5::AtomicInt::loadAcquire( isCancelled_ ) || ret < 0 )
++          break;
++
++        playFrame( frame );
++      }
++#endif
+     }
+     // av_free_packet() must be called after each call to av_read_frame()
+ #if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 7 )
+@@ -379,6 +422,7 @@ bool DecoderContext::play( QString & errorString )
+ #endif
+   }
+
++#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 37 )
+   if ( !Qt4x5::AtomicInt::loadAcquire( isCancelled_ ) &&
+        codecContext_->codec->capabilities & CODEC_CAP_DELAY )
+   {
+@@ -391,6 +435,18 @@ bool DecoderContext::play( QString & errorString )
+       playFrame( frame );
+     }
+   }
++#else
++  /* flush the decoder */
++  av_init_packet( &packet );
++  int ret = avcodec_send_packet(codecContext_, &packet );
++  while( ret >= 0 )
++  {
++    ret = avcodec_receive_frame(codecContext_, frame);
++    if ( Qt4x5::AtomicInt::loadAcquire( isCancelled_ ) || ret < 0 )
++      break;
++    playFrame( frame );
++  }
++#endif
+
+ #if LIBAVCODEC_VERSION_MAJOR < 54
+   av_free( frame );
+32
+srcpkgs/goldendict/patches/ffmpeg5-2.patch
+Comment on this file
+@@ -0,0 +1,32 @@
+From 966f4a8b78e6324b930e5a50f2bb930bd87e565e Mon Sep 17 00:00:00 2001
+From: Abs62 <ottomann@yandex.ru>
+Date: Fri, 27 Sep 2019 17:00:52 +0300
+Subject: [PATCH] FFmpeg player: Fix some crashes on broken files
+
+---
+ ffmpegaudio.cc | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/ffmpegaudio.cc b/ffmpegaudio.cc
+index 56e8f788e..415fc79cb 100644
+--- a/ffmpegaudio.cc
++++ b/ffmpegaudio.cc
+@@ -51,7 +51,9 @@ AudioService & AudioService::instance()
+
+ AudioService::AudioService()
+ {
++#if LIBAVFORMAT_VERSION_MAJOR < 58 || ( LIBAVFORMAT_VERSION_MAJOR == 58 && LIBAVFORMAT_VERSION_MINOR < 9 )
+   av_register_all();
++#endif
+   ao_initialize();
+ }
+
+@@ -438,6 +440,8 @@ bool DecoderContext::play( QString & errorString )
+ #else
+   /* flush the decoder */
+   av_init_packet( &packet );
++  packet.data = NULL;
++  packet.size = 0;
+   int ret = avcodec_send_packet(codecContext_, &packet );
+   while( ret >= 0 )
+   {
+25
+srcpkgs/goldendict/patches/ffmpeg5-3.patch
+Comment on this file
+@@ -0,0 +1,25 @@
+From 8acb288c9e9bdb3c6bf2e803954dd3b6ac273c05 Mon Sep 17 00:00:00 2001
+From: Liao Junxuan <mikeljx@126.com>
+Date: Sun, 20 Feb 2022 12:28:05 +0800
+Subject: [PATCH] add support for ffmpeg 5.0
+
+---
+ ffmpegaudio.cc | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/ffmpegaudio.cc b/ffmpegaudio.cc
+index d550f4a77..7948d2187 100644
+--- a/ffmpegaudio.cc
++++ b/ffmpegaudio.cc
+@@ -94,7 +94,11 @@ struct DecoderContext
+   QByteArray audioData_;
+   QDataStream audioDataStream_;
+   AVFormatContext * formatContext_;
++#if LIBAVCODEC_VERSION_MAJOR < 59
+   AVCodec * codec_;
++#else
++  const AVCodec * codec_;
++#endif
+   AVCodecContext * codecContext_;
+   AVIOContext * avioContext_;
+   AVStream * audioStream_;
diff --git a/srcpkgs/goldendict/template b/srcpkgs/goldendict/template
index f4a05759f693d..97f44347b03a6 100644
--- a/srcpkgs/goldendict/template
+++ b/srcpkgs/goldendict/template
@@ -1,7 +1,7 @@
 # Template file for 'goldendict'
 pkgname=goldendict
 version=1.5.0
-revision=1
+revision=2
 build_style=qmake
 configure_args="CONFIG+=zim_support goldendict.pro"
 hostmakedepends="qt5-qmake pkg-config qt5-host-tools"
@@ -10,7 +10,7 @@ makedepends="tiff-devel qt5-devel libvorbis-devel zlib-devel
  qt5-webkit-devel lzo-devel bzip2-devel libao-devel qt5-svg-devel
  libeb-devel qt5-x11extras-devel ffmpeg-devel liblzma-devel
  qt5-multimedia-devel"
-short_desc="A feature-rich dictionary lookup program"
+short_desc="Feature-rich dictionary lookup program"
 maintainer="John <me@johnnynator.dev>"
 license="GPL-3.0-or-later"
 homepage="http://goldendict.org/"

From 1092cab70eb702338fcda39458af3075a84989eb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 037/113] gst-libav: revbump for ffmpeg-6.0

---
 srcpkgs/gst-libav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index 8c72fc3e97eee..04c39bff14896 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.22.2
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"

From 795f01f1db35fdd65c2f12c21eb11782b02bf1d7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 038/113] gst-plugins-bad1: revbump for ffmpeg-6.0

---
 srcpkgs/gst-plugins-bad1/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index 77bf79981c20b..5c158724a6c7e 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-plugins-bad1'
 pkgname=gst-plugins-bad1
 version=1.22.2
-revision=1
+revision=2
 build_helper="gir"
 build_style=meson
 configure_args="-Dpackage-origin=https://voidlinux.org -Ddoc=disabled

From 261cf2c0cf795d208590136485ca25ffb594fe12 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 039/113] gst-rtsp-server: revbump for ffmpeg-6.0

---
 srcpkgs/gst-rtsp-server/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index 2f0c0c45ff820..980fd72cdd4c5 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
 version=1.22.2
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="glib-devel gst-plugins-bad1-devel gobject-introspection

From 4ef9daeb5fc8471959e00ed95470411c36df2827 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 040/113] guvcview: update to 2.0.8.

---
 srcpkgs/guvcview/patches/fix-include.patch | 10 ++++++++++
 srcpkgs/guvcview/template                  |  5 ++---
 2 files changed, 12 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/guvcview/patches/fix-include.patch

diff --git a/srcpkgs/guvcview/patches/fix-include.patch b/srcpkgs/guvcview/patches/fix-include.patch
new file mode 100644
index 0000000000000..503c2af3b78c1
--- /dev/null
+++ b/srcpkgs/guvcview/patches/fix-include.patch
@@ -0,0 +1,10 @@
+--- a/guvcview/guvcview.c
++++ b/guvcview/guvcview.c
+@@ -28,6 +28,7 @@
+ #include <sys/stat.h>
+ #include <sys/resource.h>
+ #include <errno.h>
++#include <locale.h>
+ 
+ #include "gview.h"
+ #include "gviewv4l2core.h"
diff --git a/srcpkgs/guvcview/template b/srcpkgs/guvcview/template
index 345cf6006f246..86a7fd619612c 100644
--- a/srcpkgs/guvcview/template
+++ b/srcpkgs/guvcview/template
@@ -1,8 +1,7 @@
 # Template file for 'guvcview'
 pkgname=guvcview
-version=2.0.7
+version=2.0.8
 revision=1
-create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-static --disable-debian-menu"
 hostmakedepends="pkg-config intltool autoconf automake libtool glib-devel"
@@ -14,7 +13,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="http://guvcview.sourceforge.net/"
 distfiles="${SOURCEFORGE_SITE}/${pkgname}/${pkgname}-src-${version}.tar.bz2"
-checksum=f47d51fbd06e44eeaa1a82f4a153c927527c90d94514197a70b2956028cc8ad4
+checksum=a21f4e448286666cf27bafef5290cc953a0a1796b752e5bbe521266dc1230c81
 
 post_patch() {
 	sed '31a#include <locale.h>' -i  guvcview/guvcview.c

From b24f0364f0539ceeeea254a809f8c8a196a65ca8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 041/113] handbrake: update to 1.6.1

---
 .../patches/fix-missing-x265-link-flag.patch    | 11 ++++++-----
 .../handbrake/patches/libhb-vpl-include.patch   | 15 +++++++++++++++
 srcpkgs/handbrake/template                      | 17 ++++++++++-------
 3 files changed, 31 insertions(+), 12 deletions(-)
 create mode 100644 srcpkgs/handbrake/patches/libhb-vpl-include.patch

diff --git a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
index 26db03867a0c8..d6bb2eda627a3 100644
--- a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
+++ b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
@@ -1,14 +1,15 @@
 --- a/gtk/configure.ac
 +++ b/gtk/configure.ac
 @@ -203,7 +203,7 @@
- 
+
  AM_CONDITIONAL([MINGW], [test "x$mingw_flag" = "xyes"])
- 
--HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg"
-+HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -ldl"
+
+-HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc"
++HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc -ldl"
  HB_CPPFLAGS="$HB_CPPFLAGS $HBINC"
- 
+
  PKG_CHECK_MODULES([x264], [x264], sys_x264=yes, sys_x264=no)
+
 --- a/test/module.defs
 +++ b/test/module.defs
 @@ -69,6 +69,9 @@
diff --git a/srcpkgs/handbrake/patches/libhb-vpl-include.patch b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
new file mode 100644
index 0000000000000..298f9f4ab28f2
--- /dev/null
+++ b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
@@ -0,0 +1,15 @@
+--- a/libhb/module.defs	2023-01-22 11:36:49.000000000 -0500
++++ b/libhb/module.defs	2023-04-03 22:37:52.395467010 -0400
+@@ -46,11 +46,7 @@
+ LIBHB.GCC.I += $(LIBHB.build/) $(CONTRIB.build/)include
+ 
+ ifeq (1,$(FEATURE.qsv))
+-    ifeq ($(HOST.system),freebsd))
+-        LIBHB.GCC.I += $(LOCALBASE)/include/vpl
+-    else
+-        LIBHB.GCC.I += $(CONTRIB.build/)include/vpl
+-    endif
++    LIBHB.GCC.I += /usr/include/vpl
+ endif
+ 
+ ifneq (,$(filter $(HOST.system),freebsd netbsd openbsd))
diff --git a/srcpkgs/handbrake/template b/srcpkgs/handbrake/template
index ca5e4571e49c3..c32cb1bfa31f4 100644
--- a/srcpkgs/handbrake/template
+++ b/srcpkgs/handbrake/template
@@ -1,10 +1,10 @@
 # Template file for 'handbrake'
 pkgname=handbrake
-version=1.5.1
+version=1.6.1
 revision=1
 build_style=gnu-configure
 configure_args="--force --disable-gtk-update-checks --disable-df-fetch --harden
- $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc)"
+ $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc) $(vopt_enable qsv)"
 make_build_args="-C ${XBPS_TRIPLET}"
 make_install_args="-C ${XBPS_TRIPLET}"
 hostmakedepends="automake cmake gettext-devel glib-devel intltool libtool m4 meson nasm pkg-config python3"
@@ -12,8 +12,11 @@ makedepends="bzip2-devel ffmpeg-devel gst-plugins-base1-devel gtk+3-devel
  jansson-devel lame-devel libass-devel libbluray-devel libdav1d-devel
  libdvdnav-devel libdvdread-devel libgudev-devel libnuma-devel
  libsamplerate-devel libtheora-devel libvorbis-devel libvpx-devel libxml2-devel
- opus-devel speex-devel x264-devel x265-devel zimg-devel
+ opus-devel speex-devel x264-devel x265-devel zimg-devel libsvt-av1-devel
  $(vopt_if fdk_aac fdk-aac-devel)
+ $(vopt_if qsv libva-devel)
+ $(vopt_if qsv libdrm-devel)
+ $(vopt_if qsv onevpl-devel)
  $(vopt_if nvenc nv-codec-headers)"
 depends="desktop-file-utils gst-plugins-good1 hicolor-icon-theme"
 short_desc="Multithreaded video transcoder"
@@ -21,15 +24,15 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-2.0-only"
 homepage="https://handbrake.fr/"
 distfiles="https://github.com/HandBrake/HandBrake/releases/download/${version}/HandBrake-${version}-source.tar.bz2"
-checksum=3999fe06d5309c819799a73a968a8ec3840e7840c2b64af8f5cdb7fd8c9430f0
+checksum=94ccfe03db917a91650000c510f7fd53f844da19f19ad4b4be1b8f6bc31a8d4c
 nocross=yes
 
-build_options="fdk_aac nvenc"
+build_options="fdk_aac nvenc qsv"
 
 case "$XBPS_TARGET_MACHINE" in
 	x86_64*|i686*)
 		CFLAGS="-msse"
-		build_options_default="nvenc"
+		build_options_default="nvenc qsv"
 		;;
 esac
 
@@ -37,7 +40,7 @@ pre_configure() {
 	# use system libraries, don't download them
 	rm -rf contrib/
 	for module in fdk-aac ffmpeg libbluray libdav1d libdvdnav libdvdread nvenc \
-		x265 zimg; do
+		x265 zimg svt-av1 libvpl; do
 	    vsed -i "/MODULES += contrib\/${module}/d" make/include/main.defs
 	done
 }

From 8428634e81d946ec5f9459fb53d5150e9e25a9d9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 042/113] hedgewars: revbump for ffmpeg4-4.4.3

---
 srcpkgs/hedgewars/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/hedgewars/template b/srcpkgs/hedgewars/template
index 419f29b98b44d..926fe4fe3e688 100644
--- a/srcpkgs/hedgewars/template
+++ b/srcpkgs/hedgewars/template
@@ -1,13 +1,13 @@
 # Template file for 'hedgewars'
 pkgname=hedgewars
 version=1.0.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DNOSERVER=1 -DDATA_INSTALL_DIR=/usr/share/${pkgname}
  -DPHYSFS_SYSTEM=1 -DMINIMAL_FLAGS=1"
 make_cmd=make
 hostmakedepends="lua51 pkg-config qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
+makedepends="ffmpeg4-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
  SDL2_mixer-devel SDL2_net-devel SDL2_ttf-devel"
 depends="libfreeglut"
 short_desc="Funny turn-based artillery game, featuring fighting Hedgehogs!"

From 574330a056113b2bca65a69c14f230b9ba7feebb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 043/113] idjc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/idjc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/idjc/template b/srcpkgs/idjc/template
index df60318b3db96..36a75baf597c5 100644
--- a/srcpkgs/idjc/template
+++ b/srcpkgs/idjc/template
@@ -1,11 +1,11 @@
 # Template file for 'idjc'
 pkgname=idjc
 version=0.9.1
-revision=3
+revision=4
 build_style=gnu-configure
 hostmakedepends="pkg-config git python3 automake gettext-devel libtool"
 makedepends="libvorbis-devel libogg-devel jack-devel libsamplerate-devel
- libflac-devel libsndfile-devel mpg123-devel ffmpeg-devel speex-devel
+ libflac-devel libsndfile-devel mpg123-devel ffmpeg4-devel speex-devel
  glib-devel pixman-devel lame-devel python3-gobject-devel libshout-idjc-devel
  opus-devel twolame-devel python3-mutagen python3-devel"
 depends="python3-gobject python3-mutagen desktop-file-utils shared-mime-info python3-dbus jack"

From 6f9b42c7b7b39c3f7986d59aea8dc5c9f7eb8bb1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 044/113] kfilemetadata5: revbump for ffmpeg-6.0

---
 srcpkgs/kfilemetadata5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kfilemetadata5/template b/srcpkgs/kfilemetadata5/template
index 4b91cf19f298f..a3671a38ce59e 100644
--- a/srcpkgs/kfilemetadata5/template
+++ b/srcpkgs/kfilemetadata5/template
@@ -1,7 +1,7 @@
 # Template file for 'kfilemetadata5'
 pkgname=kfilemetadata5
 version=5.107.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="kcoreaddons extra-cmake-modules pkg-config qt5-host-tools qt5-qmake
  gettext kcoreaddons python3"

From d1bc4a76ed23f9f37afb4f94bf8ca326e7ed8f2c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 045/113] kid3: revbump for ffmpeg-6.0

---
 srcpkgs/kid3/patches/ffmpeg5.patch | 17 +++++++++++++++++
 srcpkgs/kid3/template              |  2 +-
 2 files changed, 18 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/kid3/patches/ffmpeg5.patch

diff --git a/srcpkgs/kid3/patches/ffmpeg5.patch b/srcpkgs/kid3/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..135fc50e07c9b
--- /dev/null
+++ b/srcpkgs/kid3/patches/ffmpeg5.patch
@@ -0,0 +1,17 @@
+# https://aur.archlinux.org/cgit/aur.git/diff/ffmpeg5.patch?h=kid3-cli&id=12410a74906612e7efc0ec8fbce739b4a0fef7e7
+diff --git a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+index e156d424..e12b9abd 100644
+--- a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
++++ b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+@@ -232,7 +232,11 @@ private:
+   friend class Format;
+   friend class Converter;
+   AVCodecContext* m_ptr;
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 0, 0)
+   AVCodec* m_impl;
++#else
++  const AVCodec* m_impl;
++#endif
+   AVFrame* m_frame;
+   bool m_opened;
+ };
diff --git a/srcpkgs/kid3/template b/srcpkgs/kid3/template
index 456206d90e16a..f32f9decb0e7f 100644
--- a/srcpkgs/kid3/template
+++ b/srcpkgs/kid3/template
@@ -1,7 +1,7 @@
 # Template file for 'kid3'
 pkgname=kid3
 version=3.9.1
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DWITH_APPS='CLI;$(vopt_if KDE KDE Qt)'
  -DWITH_DOCBOOKDIR=/usr/share/xsl/docbook -DWITH_FLAC=$(vopt_if flac ON OFF)

From 54376ca79080ef08b10ed751ee48ea8a218405ab Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 046/113] kodi: revbump for ffmpeg4-4.4.3

---
 srcpkgs/kodi/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/kodi/template b/srcpkgs/kodi/template
index 8057964d78a38..6cc1874be7ba6 100644
--- a/srcpkgs/kodi/template
+++ b/srcpkgs/kodi/template
@@ -1,7 +1,7 @@
 # Template file for 'kodi'
 pkgname=kodi
 version=19.4
-revision=6
+revision=7
 _codename="Matrix"
 build_style=cmake
 configure_args="-DWITH_FFMPEG=/usr -DENABLE_LDGOLD=OFF
@@ -54,7 +54,7 @@ makedepends="
  libmad-devel fontconfig-devel libXinerama-devel libsamplerate-devel libmms-devel
  enca-devel boost-devel libcurl-devel libva-devel libvdpau-devel libass-devel
  libbluetooth-devel yajl-devel libplist-devel librtmp-devel tinyxml-devel
- taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg-devel
+ taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg4-devel
  giflib-devel libxslt-devel gnutls-devel libssh-devel libmicrohttpd-devel
  libcec-devel dcadec-devel flatbuffers-devel fmt-devel lcms2-devel
  libfstrcmp-devel rapidjson libcdio-paranoia spdlog libwaylandpp-devel

From d832cdd6cfe80c8f42987e971083cfc6542e4a8e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 047/113] kpipewire: revbump for ffmpeg-6.0

---
 srcpkgs/kpipewire/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kpipewire/template b/srcpkgs/kpipewire/template
index db4e42f0d456a..2334bf8678062 100644
--- a/srcpkgs/kpipewire/template
+++ b/srcpkgs/kpipewire/template
@@ -1,7 +1,7 @@
 # Template file for 'kpipewire'
 pkgname=kpipewire
 version=5.27.6
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules plasma-wayland-protocols gettext
  qt5-qmake qt5-host-tools pkg-config wayland-devel kcoreaddons

From ab4875f3ded74f497d8c492553bcb394acf8230b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 048/113] libextractor: revbump for ffmpeg4-4.4.3

---
 srcpkgs/libextractor/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libextractor/template b/srcpkgs/libextractor/template
index ddd4790f93e88..1fb9ca56a96ae 100644
--- a/srcpkgs/libextractor/template
+++ b/srcpkgs/libextractor/template
@@ -7,7 +7,7 @@ configure_args="--disable-static"
 hostmakedepends="pkg-config"
 makedepends="zlib-devel bzip2-devel exiv2-devel tiff-devel libpng-devel
  libjpeg-turbo-devel libvorbis-devel libflac-devel giflib-devel libmpeg2-devel
- ffmpeg-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
+ ffmpeg4-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
 short_desc="Library used to extract meta data from files"
 maintainer="Martin Riese <grauehaare@gmx.de>"
 license="GPL-3.0-or-later"

From e7b00c31422b57759e8525d97f80385aabfa2438 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 049/113] libopenal: revbump for ffmpeg-6.0

---
 srcpkgs/libopenal/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenal/template b/srcpkgs/libopenal/template
index 77218f9e539df..3f49ed75a1fdc 100644
--- a/srcpkgs/libopenal/template
+++ b/srcpkgs/libopenal/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenal'
 pkgname=libopenal
 version=1.22.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DALSOFT_EXAMPLES=OFF"
 hostmakedepends="pkg-config"

From b5f31fba93e19c31a0c9640a8a848826cdf4ac52 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 050/113] libopenshot: revbump for ffmpeg-6.0

---
 srcpkgs/libopenshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenshot/template b/srcpkgs/libopenshot/template
index db831f69b474c..81aa0d7136d92 100644
--- a/srcpkgs/libopenshot/template
+++ b/srcpkgs/libopenshot/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenshot'
 pkgname=libopenshot
 version=0.3.0
-revision=1
+revision=2
 build_style=cmake
 # Builds fail with Ruby-2.4.1
 configure_args="-DENABLE_RUBY=OFF -DUSE_SYSTEM_JSONCPP=ON"

From bd8ae4ebbff59acc6c76f1172a474fda776f133a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 051/113] loudgain: revbump for ffmpeg-6.0

---
 srcpkgs/loudgain/patches/ffmpeg5.patch | 11 +++++++++++
 srcpkgs/loudgain/template              |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/loudgain/patches/ffmpeg5.patch

diff --git a/srcpkgs/loudgain/patches/ffmpeg5.patch b/srcpkgs/loudgain/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..16d4510ee98fa
--- /dev/null
+++ b/srcpkgs/loudgain/patches/ffmpeg5.patch
@@ -0,0 +1,11 @@
+--- a/src/scan.c	2019-09-06 11:31:19.000000000 -0400
++++ b/src/scan.c	2023-03-23 11:15:40.867968521 -0400
+@@ -69,8 +69,6 @@
+ 	 * It is now useless
+ 	 * https://github.com/FFmpeg/FFmpeg/blob/70d25268c21cbee5f08304da95be1f647c630c15/doc/APIchanges#L86
+ 	 */
+-  if (avformat_version() < AV_VERSION_INT(58,9,100))
+-    av_register_all();
+ 
+ 	av_log_set_callback(scan_av_log);
+ 
diff --git a/srcpkgs/loudgain/template b/srcpkgs/loudgain/template
index da4f2d56e94c3..4d6bf29efb4fd 100644
--- a/srcpkgs/loudgain/template
+++ b/srcpkgs/loudgain/template
@@ -1,7 +1,7 @@
 # Template file for 'loudgain'
 pkgname=loudgain
 version=0.6.8
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libebur128-devel taglib-devel ffmpeg-devel"

From 8092a3ab783ff6903af23fc4405a70ca56d8e959 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 052/113] mediastreamer: revbump for ffmpeg4-4.4.3

---
 srcpkgs/mediastreamer/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mediastreamer/template b/srcpkgs/mediastreamer/template
index d0e97e858e29a..1bde031443a59 100644
--- a/srcpkgs/mediastreamer/template
+++ b/srcpkgs/mediastreamer/template
@@ -1,11 +1,11 @@
 # Template file for 'mediastreamer'
 pkgname=mediastreamer
 version=5.2.6
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_STRICT=0 -DENABLE_UNIT_TESTS=0"
 hostmakedepends="python3"
-makedepends="bzrtp-devel ffmpeg-devel glew-devel libXv-devel libsrtp-devel
+makedepends="bzrtp-devel ffmpeg4-devel glew-devel libXv-devel libsrtp-devel
  libupnp-devel libvpx-devel mbedtls-devel opus-devel ortp-devel pulseaudio-devel
  libtheora-devel speex-devel v4l-utils-devel bcg729-devel bcmatroska2-devel libgsm-devel"
 # zxing-cpp-devel (1.2.0 probably not compatible, check again after updaing xzing)

From d217057287f5589ab99707523c9ee4a1f2072be5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 053/113] mgba: revbump for ffmpeg-6.0

---
 srcpkgs/mgba/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mgba/template b/srcpkgs/mgba/template
index ae0504311eee0..d31295a0cd3d3 100644
--- a/srcpkgs/mgba/template
+++ b/srcpkgs/mgba/template
@@ -1,7 +1,7 @@
 # Template file for 'mgba'
 pkgname=mgba
 version=0.10.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake desktop-file-utils"
 makedepends="SDL2-devel ffmpeg-devel libedit-devel libepoxy-devel libmagick-devel

From c1249f47c21e7098559b780a321aaba3ce976c4a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 054/113] minidlna: revbump for ffmpeg-6.0

---
 srcpkgs/minidlna/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/minidlna/template b/srcpkgs/minidlna/template
index d551e49ed4653..5fa929f3a0c12 100644
--- a/srcpkgs/minidlna/template
+++ b/srcpkgs/minidlna/template
@@ -1,7 +1,7 @@
 # Template file for 'minidlna'
 pkgname=minidlna
 version=1.3.3
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="
  --sbindir=/usr/bin

From 4ae4ddf71a2e14290d920e0a12d24e0802e601d2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 055/113] mixxx: revbump for ffmpeg-6.0

---
 srcpkgs/mixxx/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mixxx/template b/srcpkgs/mixxx/template
index 619ddca0d3324..4b9ea00d3fb3d 100644
--- a/srcpkgs/mixxx/template
+++ b/srcpkgs/mixxx/template
@@ -1,7 +1,7 @@
 # Template file for 'mixxx'
 pkgname=mixxx
 version=2.3.3
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="extra-cmake-modules pkg-config protobuf qt5-host-tools qt5-devel"

From a46e80408b5958bd3114b3412c985dfcc2fe0f38 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 056/113] mlt: revbump for ffmpeg4-4.4.3

---
 srcpkgs/mlt/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mlt/template b/srcpkgs/mlt/template
index 8933eb4e7bb9e..73353fedafb50 100644
--- a/srcpkgs/mlt/template
+++ b/srcpkgs/mlt/template
@@ -1,14 +1,14 @@
 # Template file for 'mlt'
 pkgname=mlt
 version=6.26.1
-revision=1
+revision=2
 build_style=configure
 configure_args="--prefix=/usr --libdir=/usr/lib$XBPS_TARGET_WORDSIZE
  --enable-gpl --enable-gpl3 --disable-swfdec --without-kde
  --swig-languages=python"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which"
 # XXX: movit vid.stab
-makedepends="alsa-lib-devel ffmpeg-devel gtk+-devel jack-devel ladspa-sdk
+makedepends="alsa-lib-devel ffmpeg4-devel gtk+-devel jack-devel ladspa-sdk
  libexif-devel libsamplerate-devel libxml2-devel sox-devel SDL_image-devel
  fftw-devel frei0r-plugins python3-devel pulseaudio-devel movit-devel
  libvidstab-devel libatomic-devel"

From 14b9c837e49a8106a232cf3462e0d652fe4f4a03 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 057/113] moc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/moc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/moc/template b/srcpkgs/moc/template
index c42be650a1d25..d4f0eefbad52d 100644
--- a/srcpkgs/moc/template
+++ b/srcpkgs/moc/template
@@ -1,10 +1,10 @@
 # Template file for 'moc'
 pkgname=moc
 version=2.5.2
-revision=6
+revision=7
 build_style=gnu-configure
 hostmakedepends="pkg-config"
-makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg-devel
+makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg4-devel
  jack-devel alsa-lib-devel libltdl-devel libflac-devel libvorbis-devel
  libmad-devel libmpcdec-devel libmodplug-devel libid3tag-devel faad2-devel
  taglib-devel libsndfile-devel wavpack-devel speex-devel libsamplerate-devel

From 813362ec0cc7059941f0967dffdf032ecb9a6cfb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 058/113] motion: revbump for ffmpeg-6.0

---
 srcpkgs/motion/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/motion/template b/srcpkgs/motion/template
index 3cf3c3035c5b7..7dca12d851e33 100644
--- a/srcpkgs/motion/template
+++ b/srcpkgs/motion/template
@@ -1,7 +1,7 @@
 # Template file for 'motion'
 pkgname=motion
 version=4.5.1
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake pkg-config gettext-devel tar"
 makedepends="ffmpeg-devel libmicrohttpd-devel v4l-utils-devel gettext-devel"

From 1fd359b67bf608bc80cdd057aba032642a72e1d9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 059/113] mpv: revbump for ffmpeg-6.0

---
 srcpkgs/mpv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpv/template b/srcpkgs/mpv/template
index e163c496c6ebb..d4fefbf5e3c7c 100644
--- a/srcpkgs/mpv/template
+++ b/srcpkgs/mpv/template
@@ -1,7 +1,7 @@
 # Template file for 'mpv'
 pkgname=mpv
 version=0.35.1
-revision=2
+revision=3
 build_style=meson
 configure_args="-Dcdda=enabled -Ddvbin=enabled -Ddvdnav=enabled
  -Dlibmpv=true -Dcplugins=enabled

From c8c593da81ceff294860fcfcb47e5f1653c156d1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 060/113] musikcube: revbump for ffmpeg-6.0

---
 srcpkgs/musikcube/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/musikcube/template b/srcpkgs/musikcube/template
index 7c569303c0543..a4dea460c3717 100644
--- a/srcpkgs/musikcube/template
+++ b/srcpkgs/musikcube/template
@@ -1,7 +1,7 @@
 # Template file for 'musikcube'
 pkgname=musikcube
 version=3.0.0
-revision=1
+revision=2
 build_style=cmake
 make_cmd=make
 configure_args="-DNO_NCURSESW=1"

From 369943f0f44af7e348d4eba2b7f4fbab8e39529d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 061/113] notcurses: revbump for ffmpeg-6.0

---
 srcpkgs/notcurses/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/notcurses/template b/srcpkgs/notcurses/template
index 6dd8a091319f7..3110c30c9aff2 100644
--- a/srcpkgs/notcurses/template
+++ b/srcpkgs/notcurses/template
@@ -1,7 +1,7 @@
 # Template file for 'notcurses'
 pkgname=notcurses
 version=3.0.9
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DUSE_STATIC=ON $(vopt_bool man USE_PANDOC)"
 hostmakedepends="pkg-config $(vopt_if man pandoc)"

From 8a30cf9e6a843e1f00ff7c9afc860496b1c7fa18 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 062/113] obs: revbump for ffmpeg-6.0

---
 srcpkgs/obs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/obs/template b/srcpkgs/obs/template
index 7b69c630d30d4..2c8d68d71f3a1 100644
--- a/srcpkgs/obs/template
+++ b/srcpkgs/obs/template
@@ -1,7 +1,7 @@
 # Template file for 'obs'
 pkgname=obs
 version=29.1.2
-revision=1
+revision=2
 archs="i686* x86_64* ppc64le* aarch64*"
 build_style=cmake
 configure_args="-DOBS_VERSION_OVERRIDE=${version} -DENABLE_JACK=ON

From 7d4540259e2d72a59f514497f5b6e0d3003b4fed Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 063/113] olive: revbump for ffmpeg4-4.4.3

---
 srcpkgs/olive/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/olive/template b/srcpkgs/olive/template
index 12a46936c9900..5c2917b9c5124 100644
--- a/srcpkgs/olive/template
+++ b/srcpkgs/olive/template
@@ -1,10 +1,10 @@
 # Template file for 'olive'
 pkgname=olive
 version=0.1.2
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools pkg-config"
-makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg-devel frei0r-plugins"
+makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg4-devel frei0r-plugins"
 short_desc="Non-linear video editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"

From 508ffbec2043a331c00669816c83074f62dd4e5c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 064/113] omxplayer: revbump for ffmpeg4-4.4.3

---
 srcpkgs/omxplayer/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/omxplayer/template b/srcpkgs/omxplayer/template
index e70bf7873d4de..0e9bc70e7c8eb 100644
--- a/srcpkgs/omxplayer/template
+++ b/srcpkgs/omxplayer/template
@@ -1,10 +1,10 @@
 # Template file for 'omxplayer'
 pkgname=omxplayer
 version=20190102
-revision=1
+revision=2
 short_desc="Commandline OMX player for the Raspberry Pi"
 maintainer="Orphaned <orphan@voidlinux.org>"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://github.com/popcornmix/omxplayer"
 
 _commit="f06235cc9690a6d58187514452df8cf8fcdaacec"
@@ -15,7 +15,7 @@ checksum=af2d9450f8947842ea8c401fe9f71eec444013ebbdee29f2ac828c9c493c1329
 archs="armv6l* armv7l*"
 build_style=gnu-makefile
 hostmakedepends="curl pkg-config"
-makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg-devel dbus-devel"
+makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg4-devel dbus-devel"
 depends="freefont-ttf"
 
 do_build() {

From 3461c2e12e0974124689ba7c2541e59738665fdb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 065/113] openimageio: revbump for ffmpeg-6.0

---
 etc/xbps.d/repos-remote.conf | 4 ++++
 srcpkgs/openimageio/template | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/etc/xbps.d/repos-remote.conf b/etc/xbps.d/repos-remote.conf
index e171ed53c2d4b..014c0074d3b33 100644
--- a/etc/xbps.d/repos-remote.conf
+++ b/etc/xbps.d/repos-remote.conf
@@ -3,3 +3,7 @@ repository=https://repo-default.voidlinux.org/current/bootstrap
 repository=https://repo-default.voidlinux.org/current
 repository=https://repo-default.voidlinux.org/current/nonfree
 repository=https://repo-default.voidlinux.org/current/debug
+#repository=https://mirrors.servercentral.com/voidlinux/current/bootstrap
+#repository=https://mirrors.servercentral.com/voidlinux/current
+#repository=https://mirrors.servercentral.com/voidlinux/current/nonfree
+#repository=https://mirrors.servercentral.com/voidlinux/current/debug
diff --git a/srcpkgs/openimageio/template b/srcpkgs/openimageio/template
index 0e9e22e9685d9..e74a8dbd683e4 100644
--- a/srcpkgs/openimageio/template
+++ b/srcpkgs/openimageio/template
@@ -1,7 +1,7 @@
 # Template file for 'openimageio'
 pkgname=openimageio
 version=2.4.9.0
-revision=5
+revision=6
 build_style=cmake
 build_helper=qemu
 configure_args="-DUSE_QT=0 -DUSE_PYTHON=0 -DOIIO_BUILD_TESTS=0

From 15f5f1ab6ff209324e3ae8ac2ba0c553ad6fa6db Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 066/113] openshot: revbump for ffmpeg-6.0

---
 srcpkgs/openshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openshot/template b/srcpkgs/openshot/template
index 322717d40abc0..c074e0338773b 100644
--- a/srcpkgs/openshot/template
+++ b/srcpkgs/openshot/template
@@ -1,7 +1,7 @@
 # Template file for 'openshot'
 pkgname=openshot
 version=3.0.0
-revision=1
+revision=2
 build_style=python3-module
 hostmakedepends="python3 python3-setuptools"
 makedepends="ffmpeg-devel python3-PyQt5"

From 53811ae9cb92b959e0b6905bc34b64d8f2d19844 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 067/113] opentoonz: revbump for ffmpeg-6.0

---
 srcpkgs/opentoonz/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/opentoonz/template b/srcpkgs/opentoonz/template
index ee9f7603f55fd..3e81834ca0edd 100644
--- a/srcpkgs/opentoonz/template
+++ b/srcpkgs/opentoonz/template
@@ -1,7 +1,7 @@
 # Template file for 'opentoonz'
 pkgname=opentoonz
 version=1.6.0
-revision=2
+revision=3
 build_wrksrc="toonz/sources"
 build_style=cmake
 make_cmd=make

From 792ab27c31ed84d52f47415855a5e1350aed6155 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 068/113] pianobar: revbump for ffmpeg-6.0

---
 srcpkgs/pianobar/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pianobar/template b/srcpkgs/pianobar/template
index e3febb821a451..1e3dc1bf9308e 100644
--- a/srcpkgs/pianobar/template
+++ b/srcpkgs/pianobar/template
@@ -1,7 +1,7 @@
 # Template file for 'pianobar'
 pkgname=pianobar
 version=2022.04.01
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="V=1"
 hostmakedepends="pkg-config"

From 423a0e1a1fac11224f11ce313b0b54ddf26d5663 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 069/113] ppsspp: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ppsspp/template | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/ppsspp/template b/srcpkgs/ppsspp/template
index 7984a733d4bea..15a42fd2c993e 100644
--- a/srcpkgs/ppsspp/template
+++ b/srcpkgs/ppsspp/template
@@ -1,7 +1,7 @@
 # Template file for 'ppsspp'
 pkgname=ppsspp
 version=1.14.4
-revision=1
+revision=2
 _glslang_commit=dc11adde23c455a24e13dd54de9b4ede8bdd7db8
 _SPIRV_Cross_commit=9acb9ec31f5a8ef80ea6b994bb77be787b08d3d1
 _armips_commit=6719edebaae03330ee5441d9b28280672edf00d5
@@ -13,7 +13,7 @@ configure_args="-DHEADLESS=1 -DUSE_SYSTEM_FFMPEG=1 -DUNITTEST=ON
  -DUSING_QT_UI=$(vopt_if qt ON OFF) -DUSE_SYSTEM_ZSTD=ON
  -DARMIPS_USE_STD_FILESYSTEM=ON"
 hostmakedepends="pkg-config python3 $(vopt_if qt qt5-host-tools)"
-makedepends="zlib-devel glew-devel ffmpeg-devel libzip-devel
+makedepends="zlib-devel glew-devel ffmpeg4-devel libzip-devel
  snappy-devel rapidjson libpng-devel libzstd-devel
  $(vopt_if sdl2 SDL2-devel) $(vopt_if wayland wayland-devel)
  $(vopt_if qt 'qt5-devel qt5-multimedia-devel')"
@@ -62,13 +62,12 @@ post_extract() {
 	mv ${wrksrc}/miniupnp-${_miniupnp_commit} ${wrksrc}/ext/miniupnp
 }
 
-post_patch(){
+post_patch() {
 	# disable git versioning
 	vsed -e 's|find_package(Git)|# &|' -i git-version.cmake
 }
 
 do_install() {
-	vlicense LICENSE.TXT
 	vinstall icons/icon.svg 644 usr/share/pixmaps ppsspp.svg
 	vinstall Qt/PPSSPP.desktop 644 usr/share/applications
 	vbin build/PPSSPPHeadless ppsspp-headless

From 3baa0f3494ed96a64340297936774b4a3dfcf18b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 070/113] pqiv: revbump for ffmpeg-6.0

---
 srcpkgs/pqiv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pqiv/template b/srcpkgs/pqiv/template
index 542fc27a2d32a..9308d949b6a1c 100644
--- a/srcpkgs/pqiv/template
+++ b/srcpkgs/pqiv/template
@@ -1,7 +1,7 @@
 # Template file for 'pqiv'
 pkgname=pqiv
 version=2.12
-revision=1
+revision=2
 build_style=gnu-makefile
 hostmakedepends="pkg-config"
 makedepends="glib-devel gtk+3-devel $(vopt_if ffmpeg ffmpeg-devel)

From adad52a863bff257365fc7df2f7d9468061bf2d0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 071/113] qmmp: revbump for ffmpeg-6.0

---
 srcpkgs/qmmp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qmmp/template b/srcpkgs/qmmp/template
index 26c661ed16bea..a150d7441c7a6 100644
--- a/srcpkgs/qmmp/template
+++ b/srcpkgs/qmmp/template
@@ -1,7 +1,7 @@
 # Template file for 'qmmp'
 pkgname=qmmp
 version=1.6.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DUSE_HAL:BOOL=FALSE -DQMMP_DEFAULT_UI:STRING=simple"
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From c03728e65928085c8a1076cac9dad7c719d9b8f0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 072/113] qt5-webengine: update to 5.15.13

---
 .../chromium-media-filters-cpp14.patch        |  11 ++
 srcpkgs/qt5-webengine/patches/ffmpeg5.patch   | 179 ++++++++++++++++++
 srcpkgs/qt5-webengine/template                |  10 +-
 3 files changed, 195 insertions(+), 5 deletions(-)
 create mode 100644 srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/ffmpeg5.patch

diff --git a/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
new file mode 100644
index 0000000000000..04adc540f2cbc
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
@@ -0,0 +1,11 @@
+--- a/src/3rdparty/chromium/media/filters/BUILD.gn	2023-02-27 13:32:59.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/BUILD.gn	2023-04-02 17:21:39.204066384 -0400
+@@ -96,6 +96,8 @@
+     "//ui/gfx/geometry:geometry",
+   ]
+ 
++  cflags_cc = [ "-std=c++14" ]
++
+   libs = []
+ 
+   if (proprietary_codecs) {
diff --git a/srcpkgs/qt5-webengine/patches/ffmpeg5.patch b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..ac55e1634423a
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
@@ -0,0 +1,179 @@
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:57.732547446 -0400
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:09.486478995 -0400
+@@ -57,6 +57,8 @@
+ 
+ namespace {
+ 
++constexpr int64_t kRelativeTsBase = static_cast<int64_t>(0x7ffeffffffffffff);
++
+ void SetAVStreamDiscard(AVStream* stream, AVDiscard discard) {
+   DCHECK(stream);
+   stream->discard = discard;
+@@ -90,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+   if (stream->start_time != kNoFFmpegTimestamp)
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (stream->first_dts != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, stream->first_dts);
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -408,11 +398,11 @@
+   scoped_refptr<DecoderBuffer> buffer;
+ 
+   if (type() == DemuxerStream::TEXT) {
+-    int id_size = 0;
++    size_t id_size = 0;
+     uint8_t* id_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
+ 
+-    int settings_size = 0;
++    size_t settings_size = 0;
+     uint8_t* settings_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
+ 
+@@ -424,7 +414,7 @@
+     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
+                                      side_data.data(), side_data.size());
+   } else {
+-    int side_data_size = 0;
++    size_t side_data_size = 0;
+     uint8_t* side_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
+ 
+@@ -485,7 +475,7 @@
+                                        packet->size - data_offset);
+     }
+ 
+-    int skip_samples_size = 0;
++    size_t skip_samples_size = 0;
+     const uint32_t* skip_samples_ptr =
+         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
+             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
+@@ -1587,6 +1577,8 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++      continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+       lowest_start_time_stream = stream.get();
+@@ -1604,6 +1596,8 @@
+     if (stream && stream->type() == DemuxerStream::VIDEO &&
+         stream->IsEnabled()) {
+       video_stream = stream.get();
++      if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++        continue;
+       if (video_stream->start_time() <= seek_time) {
+         return video_stream;
+       }
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h qtwebengine-5.15.10/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h
+--- a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-07-11 22:12:47.917192788 -0500
+@@ -29,6 +29,7 @@ extern "C" {
+ #include <libavformat/avformat.h>
+ #include <libavformat/avio.h>
+ #include <libavutil/avutil.h>
++#include <libavutil/channel_layout.h>
+ #include <libavutil/imgutils.h>
+ #include <libavutil/log.h>
+ #include <libavutil/mastering_display_metadata.h>
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/audio_file_reader.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/audio_file_reader.cc
+--- a/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -85,7 +85,7 @@ bool AudioFileReader::OpenDemuxer() {
+ }
+ 
+ bool AudioFileReader::OpenDecoder() {
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (codec) {
+     // MP3 decodes to S16P which we don't support, tell it to use S16 instead.
+     if (codec_context_->sample_fmt == AV_SAMPLE_FMT_S16P)
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -329,7 +329,7 @@ bool FFmpegAudioDecoder::ConfigureDecode
+     }
+   }
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec ||
+       avcodec_open2(codec_context_.get(), codec, &codec_options) < 0) {
+     DLOG(ERROR) << "Could not initialize audio decoder: "
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -59,7 +59,6 @@ static int64_t AVIOSeekOperation(void* o
+ }
+ 
+ void FFmpegGlue::InitializeFFmpeg() {
+-  av_register_all();
+ }
+ 
+ static void LogContainer(bool is_local_file,
+@@ -95,9 +94,6 @@ FFmpegGlue::FFmpegGlue(FFmpegURLProtocol
+   // Enable fast, but inaccurate seeks for MP3.
+   format_context_->flags |= AVFMT_FLAG_FAST_SEEK;
+ 
+-  // Ensures we can read out various metadata bits like vp8 alpha.
+-  format_context_->flags |= AVFMT_FLAG_KEEP_SIDE_DATA;
+-
+   // Ensures format parsing errors will bail out. From an audit on 11/2017, all
+   // instances were real failures. Solves bugs like http://crbug.com/710791.
+   format_context_->error_recognition |= AV_EF_EXPLODE;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -391,7 +391,7 @@ bool FFmpegVideoDecoder::ConfigureDecode
+   if (decode_nalus_)
+     codec_context_->flags2 |= AV_CODEC_FLAG2_CHUNKS;
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
+     ReleaseFFmpegResources();
+     return false;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/media_file_checker.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/media_file_checker.cc
+--- a/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -68,7 +68,7 @@ bool MediaFileChecker::Start(base::TimeD
+       auto context = AVStreamToAVCodecContext(format_context->streams[i]);
+       if (!context)
+         continue;
+-      AVCodec* codec = avcodec_find_decoder(cp->codec_id);
++      const AVCodec* codec = avcodec_find_decoder(cp->codec_id);
+       if (codec && avcodec_open2(context.get(), codec, nullptr) >= 0) {
+         auto loop = std::make_unique<FFmpegDecodingLoop>(context.get());
+         stream_contexts[i] = {std::move(context), std::move(loop)};
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc qtwebengine-5.15.10/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc
+--- a/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -203,7 +203,7 @@ int32_t H264DecoderImpl::InitDecode(cons
+   // a pointer |this|.
+   av_context_->opaque = this;
+ 
+-  AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
+   if (!codec) {
+     // This is an indication that FFmpeg has not been initialized or it has not
+     // been compiled/initialized with the correct set of codecs.
diff --git a/srcpkgs/qt5-webengine/template b/srcpkgs/qt5-webengine/template
index 85267c7cf8a3f..095ab67701e42 100644
--- a/srcpkgs/qt5-webengine/template
+++ b/srcpkgs/qt5-webengine/template
@@ -1,9 +1,9 @@
 # Template file for 'qt5-webengine'
 pkgname=qt5-webengine
-version=5.15.11
-revision=3
+version=5.15.13
+revision=1
 _version="${version}-lts"
-_chromium_commit=be349eaf62e77955791d7bf29f893f1e8a37daf4
+_chromium_commit=e48df7803c7c98b0b2471c94057d32e44a301ad5
 archs="x86_64* i686* armv[67]* ppc64* aarch64*"
 create_wrksrc=yes
 build_style=qmake
@@ -32,8 +32,8 @@ license="GPL-3.0-or-later, LGPL-3.0-or-later"
 homepage="https://qt.io/"
 distfiles="https://github.com/qt/qtwebengine/archive/v${_version}.tar.gz
  https://github.com/qt/qtwebengine-chromium/archive/${_chromium_commit}.tar.gz"
-checksum="aa7466356c450c5f5870f979b93cd7e7e62da1165c328ffcab1a9928db18ad67
- 6f47ed8ab8cc062411f6f206da6353bc8263d6ed6d6290c689a05c01d91f646b"
+checksum="4b59838ed75ef788b59e1e412535a0e42dd9d311661fdeadb191b581ba815c63
+ a91686562b1d4e8b220e0bbcbab5feb64630e2de974b35ac034bf388af771a6c"
 
 no_generic_pkgconfig_link=yes
 build_options="sndio pipewire"

From 17aae80f3a13041d956c4dc981282339cc25fea9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 073/113] qt5: update to 5.15.8

---
 ...erywhere-opensource-src-5.15.8-kf5-1.patch | 12913 ++++++++++++++++
 srcpkgs/qt5/template                          |    12 +-
 2 files changed, 12919 insertions(+), 6 deletions(-)
 create mode 100644 srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch

diff --git a/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch b/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch
new file mode 100644
index 0000000000000..966c98bcd3bb1
--- /dev/null
+++ b/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch
@@ -0,0 +1,12913 @@
+Submitted By:            Pierre Labastie <pierre_dot_labastie_at_neuf_dot_fr>
+Date:                    2023-01-05
+Initial Package Version: 5.15.8
+Upstream Status:         Applied (according to KDE)
+Origin:                  KDE patch set
+Description:             Patch set maintained by the KDE folks
+see https://dot.kde.org/2021/04/06/announcing-kdes-qt-5-patch-collection
+Patch generated using the procedure in
+https://wiki.linuxfromscratch.org/blfs/ticket/17476#comment:3
+
+Submodule qtbase 4ee4fc18..9cf586d6:
+diff --git a/qtbase/mkspecs/common/android/qplatformdefs.h b/qtbase/mkspecs/common/android/qplatformdefs.h
+index f75bc4093b..2bd59410d4 100644
+--- a/qtbase/mkspecs/common/android/qplatformdefs.h
++++ b/qtbase/mkspecs/common/android/qplatformdefs.h
+@@ -144,11 +144,7 @@
+ #define QT_SIGNAL_ARGS          int
+ #define QT_SIGNAL_IGNORE        SIG_IGN
+ 
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+ #define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+ 
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+diff --git a/qtbase/mkspecs/features/mac/sdk.mk b/qtbase/mkspecs/features/mac/sdk.mk
+index f30b5830b4..a32ceacb6c 100644
+--- a/qtbase/mkspecs/features/mac/sdk.mk
++++ b/qtbase/mkspecs/features/mac/sdk.mk
+@@ -1,6 +1,6 @@
+ 
+ ifeq ($(QT_MAC_SDK_NO_VERSION_CHECK),)
+-    CHECK_SDK_COMMAND = /usr/bin/xcrun --sdk $(EXPORT_QMAKE_MAC_SDK) -show-sdk-version 2>&1
++    CHECK_SDK_COMMAND = /usr/bin/xcrun --sdk $(EXPORT_QMAKE_MAC_SDK) -show-sdk-version 2>/dev/null
+     CURRENT_MAC_SDK_VERSION := $(shell DEVELOPER_DIR=$(EXPORT_QMAKE_XCODE_DEVELOPER_PATH) $(CHECK_SDK_COMMAND))
+     ifneq ($(CURRENT_MAC_SDK_VERSION),$(EXPORT_QMAKE_MAC_SDK_VERSION))
+         # We don't want to complain about out of date SDK unless the target needs to be remade.
+diff --git a/qtbase/mkspecs/linux-clang/qplatformdefs.h b/qtbase/mkspecs/linux-clang/qplatformdefs.h
+index a818d973f0..c1ab72fbc6 100644
+--- a/qtbase/mkspecs/linux-clang/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-clang/qplatformdefs.h
+@@ -79,14 +79,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-g++/qplatformdefs.h b/qtbase/mkspecs/linux-g++/qplatformdefs.h
+index 13523f0702..4d2750d9ec 100644
+--- a/qtbase/mkspecs/linux-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-g++/qplatformdefs.h
+@@ -79,14 +79,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ < 2)
+-#define QT_SOCKLEN_T            int
+-#else
+-#define QT_SOCKLEN_T            socklen_t
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-llvm/qplatformdefs.h b/qtbase/mkspecs/linux-llvm/qplatformdefs.h
+index dc750ab1ef..d3cc39b47f 100644
+--- a/qtbase/mkspecs/linux-llvm/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-llvm/qplatformdefs.h
+@@ -80,14 +80,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h b/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
+index 4c4e53da2a..83baffb3e3 100644
+--- a/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
+@@ -85,16 +85,9 @@
+ #include "../common/posix/qplatformdefs.h"
+ 
+ #undef QT_OPEN_LARGEFILE
+-#undef QT_SOCKLEN_T
+ 
+ #define QT_OPEN_LARGEFILE       0
+ 
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #ifndef SIOCGIFBRDADDR
+ #  define SIOCGIFBRDADDR 0x8919
+ #endif
+diff --git a/qtbase/mkspecs/lynxos-g++/qplatformdefs.h b/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
+index 4339ea2b23..6007af0055 100644
+--- a/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
+@@ -72,14 +72,6 @@
+ 
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp b/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
+index c3c184258f..32af3f8f29 100644
+--- a/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
++++ b/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
+@@ -10,6 +10,7 @@
+ #include "libANGLE/HandleAllocator.h"
+ 
+ #include <algorithm>
++#include <limits>
+ 
+ #include "common/debug.h"
+ 
+diff --git a/qtbase/src/3rdparty/forkfd/forkfd_linux.c b/qtbase/src/3rdparty/forkfd/forkfd_linux.c
+index ffe0e9a5e2..b1f5408d11 100644
+--- a/qtbase/src/3rdparty/forkfd/forkfd_linux.c
++++ b/qtbase/src/3rdparty/forkfd/forkfd_linux.c
+@@ -82,7 +82,8 @@ static int sys_clone(unsigned long cloneflags, int *ptid)
+     return syscall(__NR_clone, cloneflags, child_stack, stack_size, ptid, newtls, ctid);
+ #elif defined(__arc__) || defined(__arm__) || defined(__aarch64__) || defined(__mips__) || \
+     defined(__nds32__) || defined(__hppa__) || defined(__powerpc__) || defined(__i386__) || \
+-    defined(__x86_64__) || defined(__xtensa__) || defined(__alpha__) || defined(__riscv)
++    defined(__x86_64__) || defined(__xtensa__) || defined(__alpha__) || defined(__riscv) || \
++    defined(__loongarch__)
+     /* ctid and newtls are inverted on CONFIG_CLONE_BACKWARDS architectures,
+      * but since both values are 0, there's no harm. */
+     return syscall(__NR_clone, cloneflags, child_stack, ptid, ctid, newtls);
+diff --git a/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java b/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
+index 5792b5b2f5..2f74750fcf 100644
+--- a/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
++++ b/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
+@@ -116,6 +116,7 @@ public class QtNative
+     public static QtThread m_qtThread = new QtThread();
+     private static HashMap<String, Uri> m_cachedUris = new HashMap<String, Uri>();
+     private static ArrayList<String> m_knownDirs = new ArrayList<String>();
++    private static final String NoPermissionErrorMessage = "No permissions to open Uri";
+ 
+     private static final Runnable runPendingCppRunnablesRunnable = new Runnable() {
+         @Override
+@@ -193,11 +194,10 @@ public class QtNative
+                     return iterUri;
+             }
+ 
+-            // Android 6 and earlier could still manage to open the file so we can return the
+-            // parsed uri here
+-            if (Build.VERSION.SDK_INT < 24)
+-                return parsedUri;
+-            return null;
++            // if we only have transient permissions on uri all the above will fail,
++            // but we will be able to read the file anyway, so continue with uri here anyway
++            // and check for SecurityExceptions later
++            return parsedUri;
+         } catch (SecurityException e) {
+             e.printStackTrace();
+             return null;
+@@ -244,7 +244,7 @@ public class QtNative
+         int error = -1;
+ 
+         if (uri == null) {
+-            Log.e(QtTAG, "openFdForContentUrl(): No permissions to open Uri");
++            Log.e(QtTAG, "openFdForContentUrl(): " + NoPermissionErrorMessage);
+             return error;
+         }
+ 
+@@ -254,12 +254,13 @@ public class QtNative
+             return fdDesc.detachFd();
+         } catch (FileNotFoundException e) {
+             e.printStackTrace();
+-            return error;
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "openFdForContentUrl(): Invalid Uri");
+             e.printStackTrace();
+-            return error;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return error;
+     }
+ 
+     public static long getSize(Context context, String contentUrl)
+@@ -270,7 +271,7 @@ public class QtNative
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+ 
+         if (uri == null) {
+-            Log.e(QtTAG, "getSize(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return size;
+         } else if (!m_cachedUris.containsKey(contentUrl)) {
+             m_cachedUris.put(contentUrl, uri);
+@@ -288,12 +289,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "getSize(): Invalid Uri");
+             e.printStackTrace();
+-            return size;
+         }  catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "getSize(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return size;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return size;
+     }
+ 
+     public static boolean checkFileExists(Context context, String contentUrl)
+@@ -303,7 +305,7 @@ public class QtNative
+         if (uri == null)
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+         if (uri == null) {
+-            Log.e(QtTAG, "checkFileExists(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return exists;
+         } else {
+             if (!m_cachedUris.containsKey(contentUrl))
+@@ -321,12 +323,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "checkFileExists(): Invalid Uri");
+             e.printStackTrace();
+-            return exists;
+         } catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "checkFileExists(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return false;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return exists;
+     }
+ 
+     public static boolean checkIfWritable(Context context, String contentUrl)
+@@ -344,7 +347,7 @@ public class QtNative
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+         }
+         if (uri == null) {
+-            Log.e(QtTAG, "isDir(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return isDir;
+         } else {
+             if (!m_cachedUris.containsKey(contentUrl))
+@@ -374,12 +377,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "checkIfDir(): Invalid Uri");
+             e.printStackTrace();
+-            return false;
+         } catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "checkIfDir(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return false;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return false;
+     }
+     public static String[] listContentsFromTreeUri(Context context, String contentUrl)
+     {
+diff --git a/qtbase/src/concurrent/qtconcurrentreducekernel.h b/qtbase/src/concurrent/qtconcurrentreducekernel.h
+index 8f9a938952..a98dedef2e 100644
+--- a/qtbase/src/concurrent/qtconcurrentreducekernel.h
++++ b/qtbase/src/concurrent/qtconcurrentreducekernel.h
+@@ -212,11 +212,13 @@ public:
+ 
+     inline bool shouldThrottle()
+     {
++        std::lock_guard<QMutex> locker(mutex);
+         return (resultsMapSize > (ReduceQueueThrottleLimit * threadCount));
+     }
+ 
+     inline bool shouldStartThread()
+     {
++        std::lock_guard<QMutex> locker(mutex);
+         return (resultsMapSize <= (ReduceQueueStartLimit * threadCount));
+     }
+ };
+diff --git a/qtbase/src/concurrent/qtconcurrentthreadengine.cpp b/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
+index ea6ce3ac42..7f91a2ba68 100644
+--- a/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
++++ b/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
+@@ -176,6 +176,39 @@ void ThreadEngineBase::startSingleThreaded()
+     finish();
+ }
+ 
++void ThreadEngineBase::startBlocking()
++{
++    start();
++    barrier.acquire();
++    startThreads();
++
++    bool throttled = false;
++#ifndef QT_NO_EXCEPTIONS
++    try {
++#endif
++        while (threadFunction() == ThrottleThread) {
++            if (threadThrottleExit()) {
++                throttled = true;
++                break;
++            }
++        }
++#ifndef QT_NO_EXCEPTIONS
++    } catch (QException &e) {
++        handleException(e);
++    } catch (...) {
++        handleException(QUnhandledException());
++    }
++#endif
++
++    if (throttled == false) {
++        barrier.release();
++    }
++
++    barrier.wait();
++    finish();
++    exceptionStore.throwPossibleException();
++}
++
+ void ThreadEngineBase::startThread()
+ {
+     startThreadInternal();
+diff --git a/qtbase/src/concurrent/qtconcurrentthreadengine.h b/qtbase/src/concurrent/qtconcurrentthreadengine.h
+index 7c30cebdbc..a4c8548cc4 100644
+--- a/qtbase/src/concurrent/qtconcurrentthreadengine.h
++++ b/qtbase/src/concurrent/qtconcurrentthreadengine.h
+@@ -91,6 +91,7 @@ public:
+     ThreadEngineBase();
+     virtual ~ThreadEngineBase();
+     void startSingleThreaded();
++    void startBlocking();
+     void startThread();
+     bool isCanceled();
+     void waitForResume();
+@@ -143,6 +144,15 @@ public:
+         return result();
+     }
+ 
++    // Runs the user algorithm using multiple threads.
++    // This function blocks until the algorithm is finished,
++    // and then returns the result.
++    T *startBlocking()
++    {
++        ThreadEngineBase::startBlocking();
++        return result();
++    }
++
+     // Runs the user algorithm using multiple threads.
+     // Does not block, returns a future.
+     QFuture<T> startAsynchronously()
+@@ -223,6 +233,13 @@ class ThreadEngineStarter : public ThreadEngineStarterBase<T>
+ public:
+     ThreadEngineStarter(TypedThreadEngine *eng)
+         : Base(eng) { }
++
++    T startBlocking()
++    {
++        T t = *this->threadEngine->startBlocking();
++        delete this->threadEngine;
++        return t;
++    }
+ };
+ 
+ // Full template specialization where T is void.
+@@ -232,6 +249,12 @@ class ThreadEngineStarter<void> : public ThreadEngineStarterBase<void>
+ public:
+     ThreadEngineStarter(ThreadEngine<void> *_threadEngine)
+         : ThreadEngineStarterBase<void>(_threadEngine) {}
++
++    void startBlocking()
++    {
++        this->threadEngine->startBlocking();
++        delete this->threadEngine;
++    }
+ };
+ 
+ //! [qtconcurrentthreadengine-1]
+diff --git a/qtbase/src/corelib/animation/qvariantanimation.cpp b/qtbase/src/corelib/animation/qvariantanimation.cpp
+index 98b02f0202..eac1524107 100644
+--- a/qtbase/src/corelib/animation/qvariantanimation.cpp
++++ b/qtbase/src/corelib/animation/qvariantanimation.cpp
+@@ -276,7 +276,9 @@ void QVariantAnimationPrivate::setCurrentValueForProgress(const qreal progress)
+ 
+     const qreal startProgress = currentInterval.start.first;
+     const qreal endProgress = currentInterval.end.first;
+-    const qreal localProgress = (progress - startProgress) / (endProgress - startProgress);
++    const qreal localProgress =
++            qIsNull(progress - startProgress) ? 0.0 // avoid 0/0 below
++            /* else */                        : (progress - startProgress) / (endProgress - startProgress);
+ 
+     QVariant ret = q->interpolated(currentInterval.start.second,
+                                    currentInterval.end.second,
+diff --git a/qtbase/src/corelib/global/qnamespace.h b/qtbase/src/corelib/global/qnamespace.h
+index ad4150b317..bf19b1627b 100644
+--- a/qtbase/src/corelib/global/qnamespace.h
++++ b/qtbase/src/corelib/global/qnamespace.h
+@@ -1864,7 +1864,7 @@ public:
+     QT_Q_ENUM(TimerType)
+     QT_Q_ENUM(ScrollPhase)
+     QT_Q_ENUM(MouseEventSource)
+-    QT_Q_FLAG(MouseEventFlag)
++    QT_Q_FLAG(MouseEventFlags)
+     QT_Q_ENUM(ChecksumType)
+     QT_Q_ENUM(HighDpiScaleFactorRoundingPolicy)
+     QT_Q_ENUM(TabFocusBehavior)
+diff --git a/qtbase/src/corelib/global/qrandom.cpp b/qtbase/src/corelib/global/qrandom.cpp
+index 10672c1f92..25f87c7e6a 100644
+--- a/qtbase/src/corelib/global/qrandom.cpp
++++ b/qtbase/src/corelib/global/qrandom.cpp
+@@ -383,7 +383,6 @@ struct QRandomGenerator::SystemAndGlobalGenerators
+ 
+         constexpr SystemAndGlobalGenerators g = {};
+         Q_UNUSED(g);
+-        Q_STATIC_ASSERT(std::is_literal_type<SystemAndGlobalGenerators>::value);
+ #endif
+     }
+ 
+diff --git a/qtbase/src/corelib/io/qbuffer.cpp b/qtbase/src/corelib/io/qbuffer.cpp
+index 595fcd2724..032c0ddd4b 100644
+--- a/qtbase/src/corelib/io/qbuffer.cpp
++++ b/qtbase/src/corelib/io/qbuffer.cpp
+@@ -41,6 +41,8 @@
+ #include <QtCore/qmetaobject.h>
+ #include "private/qiodevice_p.h"
+ 
++#include <limits>
++
+ QT_BEGIN_NAMESPACE
+ 
+ /** QBufferPrivate **/
+@@ -366,7 +368,9 @@ qint64 QBuffer::size() const
+ bool QBuffer::seek(qint64 pos)
+ {
+     Q_D(QBuffer);
+-    if (pos > d->buf->size() && isWritable()) {
++    const auto oldBufSize = d->buf->size();
++    constexpr qint64 MaxSeekPos = (std::numeric_limits<decltype(oldBufSize)>::max)();
++    if (pos <= MaxSeekPos && pos > oldBufSize && isWritable()) {
+         if (seek(d->buf->size())) {
+             const qint64 gapSize = pos - d->buf->size();
+             if (write(QByteArray(gapSize, 0)) != gapSize) {
+@@ -377,7 +381,7 @@ bool QBuffer::seek(qint64 pos)
+             return false;
+         }
+     } else if (pos > d->buf->size() || pos < 0) {
+-        qWarning("QBuffer::seek: Invalid pos: %d", int(pos));
++        qWarning("QBuffer::seek: Invalid pos: %lld", pos);
+         return false;
+     }
+     return QIODevice::seek(pos);
+diff --git a/qtbase/src/corelib/io/qfilesystemengine_win.cpp b/qtbase/src/corelib/io/qfilesystemengine_win.cpp
+index 81d3a71986..c86ed1f9b0 100644
+--- a/qtbase/src/corelib/io/qfilesystemengine_win.cpp
++++ b/qtbase/src/corelib/io/qfilesystemengine_win.cpp
+@@ -664,14 +664,14 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry)
+     return QFileSystemEntry(ret, QFileSystemEntry::FromInternalPath());
+ }
+ 
+-#if defined(Q_CC_MINGW) && WINVER < 0x0602 //  Windows 8 onwards
++#if defined(Q_CC_MINGW) && WINVER < 0x0602 && _WIN32_WINNT < _WIN32_WINNT_WIN8 //  Windows 8 onwards
+ 
+ typedef struct _FILE_ID_INFO {
+     ULONGLONG VolumeSerialNumber;
+     FILE_ID_128 FileId;
+ } FILE_ID_INFO, *PFILE_ID_INFO;
+ 
+-#endif // if defined (Q_CC_MINGW) && WINVER < 0x0602
++#endif // if defined(Q_CC_MINGW) && WINVER < 0x0602 && _WIN32_WINNT < _WIN32_WINNT_WIN8
+ 
+ // File ID for Windows up to version 7 and FAT32 drives
+ static inline QByteArray fileId(HANDLE handle)
+diff --git a/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp b/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
+index 94d9d06bcb..27e0b13b0b 100644
+--- a/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
++++ b/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
+@@ -366,7 +366,9 @@ void QInotifyFileSystemWatcherEngine::readFromInotify()
+     // qDebug("QInotifyFileSystemWatcherEngine::readFromInotify");
+ 
+     int buffSize = 0;
+-    ioctl(inotifyFd, FIONREAD, (char *) &buffSize);
++    if (ioctl(inotifyFd, FIONREAD, (char *) &buffSize) == -1 || buffSize == 0)
++        return;
++
+     QVarLengthArray<char, 4096> buffer(buffSize);
+     buffSize = read(inotifyFd, buffer.data(), buffSize);
+     char *at = buffer.data();
+diff --git a/qtbase/src/corelib/io/qlockfile_win.cpp b/qtbase/src/corelib/io/qlockfile_win.cpp
+index 277f8d4230..38ecef5550 100644
+--- a/qtbase/src/corelib/io/qlockfile_win.cpp
++++ b/qtbase/src/corelib/io/qlockfile_win.cpp
+@@ -48,6 +48,8 @@
+ #include "QtCore/qdebug.h"
+ #include "QtCore/qthread.h"
+ 
++#include "private/qsystemlibrary_p.h"
++
+ QT_BEGIN_NAMESPACE
+ 
+ static inline bool fileExists(const wchar_t *fileName)
+@@ -150,7 +152,7 @@ QString QLockFilePrivate::processNameByPid(qint64 pid)
+ #if !defined(Q_OS_WINRT)
+     typedef DWORD (WINAPI *GetModuleFileNameExFunc)(HANDLE, HMODULE, LPTSTR, DWORD);
+ 
+-    HMODULE hPsapi = LoadLibraryA("psapi");
++    HMODULE hPsapi = QSystemLibrary::load(L"psapi");
+     if (!hPsapi)
+         return QString();
+     GetModuleFileNameExFunc qGetModuleFileNameEx = reinterpret_cast<GetModuleFileNameExFunc>(
+diff --git a/qtbase/src/corelib/io/qprocess_unix.cpp b/qtbase/src/corelib/io/qprocess_unix.cpp
+index 50390e57f5..15c8f30745 100644
+--- a/qtbase/src/corelib/io/qprocess_unix.cpp
++++ b/qtbase/src/corelib/io/qprocess_unix.cpp
+@@ -1,7 +1,7 @@
+ /****************************************************************************
+ **
+ ** Copyright (C) 2016 The Qt Company Ltd.
+-** Copyright (C) 2016 Intel Corporation.
++** Copyright (C) 2022 Intel Corporation.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtCore module of the Qt Toolkit.
+@@ -422,14 +422,15 @@ void QProcessPrivate::startProcess()
+     // Add the program name to the argument list.
+     argv[0] = nullptr;
+     if (!program.contains(QLatin1Char('/'))) {
++        // findExecutable() returns its argument if it's an absolute path,
++        // otherwise it searches $PATH; returns empty if not found (we handle
++        // that case much later)
+         const QString &exeFilePath = QStandardPaths::findExecutable(program);
+-        if (!exeFilePath.isEmpty()) {
+-            const QByteArray &tmp = QFile::encodeName(exeFilePath);
+-            argv[0] = ::strdup(tmp.constData());
+-        }
+-    }
+-    if (!argv[0])
++        const QByteArray &tmp = QFile::encodeName(exeFilePath);
++        argv[0] = ::strdup(tmp.constData());
++    } else {
+         argv[0] = ::strdup(encodedProgramName.constData());
++    }
+ 
+     // Add every argument to the list
+     for (int i = 0; i < arguments.count(); ++i)
+@@ -983,15 +984,16 @@ bool QProcessPrivate::startDetached(qint64 *pid)
+                 envp = _q_dupEnvironment(environment.d.constData()->vars, &envc);
+             }
+ 
+-            QByteArray tmp;
+             if (!program.contains(QLatin1Char('/'))) {
++                // findExecutable() returns its argument if it's an absolute path,
++                // otherwise it searches $PATH; returns empty if not found (we handle
++                // that case much later)
+                 const QString &exeFilePath = QStandardPaths::findExecutable(program);
+-                if (!exeFilePath.isEmpty())
+-                    tmp = QFile::encodeName(exeFilePath);
++                const QByteArray &tmp = QFile::encodeName(exeFilePath);
++                argv[0] = ::strdup(tmp.constData());
++            } else {
++                argv[0] = ::strdup(QFile::encodeName(program));
+             }
+-            if (tmp.isEmpty())
+-                tmp = QFile::encodeName(program);
+-            argv[0] = tmp.data();
+ 
+             if (envp)
+                 qt_safe_execve(argv[0], argv, envp);
+diff --git a/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp b/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
+index 3a79c502af..997a634e76 100644
+--- a/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
++++ b/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
+@@ -3196,9 +3196,8 @@ bool QAbstractItemModel::beginMoveColumns(const QModelIndex &sourceParent, int s
+     destinationChange.needsAdjust = destinationParent.isValid() && destinationParent.row() >= sourceLast && destinationParent.parent() == sourceParent;
+     d->changes.push(destinationChange);
+ 
+-    d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Horizontal);
+-
+     emit columnsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, QPrivateSignal());
++    d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Horizontal);
+     return true;
+ }
+ 
+@@ -3231,7 +3230,6 @@ void QAbstractItemModel::endMoveColumns()
+       adjustedSource = createIndex(adjustedSource.row(), adjustedSource.column() + numMoved, adjustedSource.internalPointer());
+ 
+     d->itemsMoved(adjustedSource, removeChange.first, removeChange.last, adjustedDestination, insertChange.first, Qt::Horizontal);
+-
+     emit columnsMoved(adjustedSource, removeChange.first, removeChange.last, adjustedDestination, insertChange.first, QPrivateSignal());
+ }
+ 
+diff --git a/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+index dc6379d9fb..c5e287ee84 100644
+--- a/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
++++ b/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+@@ -939,8 +939,9 @@ void QSortFilterProxyModelPrivate::insert_source_items(
+                 q->beginInsertColumns(proxy_parent, proxy_start, proxy_end);
+         }
+ 
+-        for (int i = 0; i < source_items.size(); ++i)
+-            proxy_to_source.insert(proxy_start + i, source_items.at(i));
++        // TODO: use the range QList::insert() overload once it is implemented (QTBUG-58633).
++        proxy_to_source.insert(proxy_start, source_items.size(), 0);
++        std::copy(source_items.cbegin(), source_items.cend(), proxy_to_source.begin() + proxy_start);
+ 
+         build_source_to_proxy_mapping(proxy_to_source, source_to_proxy);
+ 
+@@ -3123,8 +3124,9 @@ bool QSortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex &
+ 
+     if (d->filter_data.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();
+@@ -3133,9 +3135,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.hasMatch(key);
+ }
+diff --git a/qtbase/src/corelib/kernel/qcoreapplication.cpp b/qtbase/src/corelib/kernel/qcoreapplication.cpp
+index ca2864df83..132b2eae52 100644
+--- a/qtbase/src/corelib/kernel/qcoreapplication.cpp
++++ b/qtbase/src/corelib/kernel/qcoreapplication.cpp
+@@ -1157,7 +1157,7 @@ static bool doNotify(QObject *receiver, QEvent *event)
+ bool QCoreApplicationPrivate::sendThroughApplicationEventFilters(QObject *receiver, QEvent *event)
+ {
+     // We can't access the application event filters outside of the main thread (race conditions)
+-    Q_ASSERT(receiver->d_func()->threadData.loadRelaxed()->thread.loadAcquire() == mainThread());
++    Q_ASSERT(receiver->d_func()->threadData.loadAcquire()->thread.loadRelaxed() == mainThread());
+ 
+     if (extraData) {
+         // application event filters are only called for objects in the GUI thread
+diff --git a/qtbase/src/corelib/kernel/qobject.cpp b/qtbase/src/corelib/kernel/qobject.cpp
+index 1eb79138d9..36cd780ee1 100644
+--- a/qtbase/src/corelib/kernel/qobject.cpp
++++ b/qtbase/src/corelib/kernel/qobject.cpp
+@@ -1010,7 +1010,7 @@ QObject::~QObject()
+         emit destroyed(this);
+     }
+ 
+-    if (d->declarativeData) {
++    if (!d->isDeletingChildren && d->declarativeData) {
+         if (static_cast<QAbstractDeclarativeDataImpl*>(d->declarativeData)->ownedByQml1) {
+             if (QAbstractDeclarativeData::destroyed_qml1)
+                 QAbstractDeclarativeData::destroyed_qml1(d->declarativeData, this);
+@@ -1580,7 +1580,7 @@ void QObject::moveToThread(QThread *targetThread)
+ 
+     QThreadData *currentData = QThreadData::current();
+     QThreadData *targetData = targetThread ? QThreadData::get2(targetThread) : nullptr;
+-    QThreadData *thisThreadData = d->threadData.loadRelaxed();
++    QThreadData *thisThreadData = d->threadData.loadAcquire();
+     if (!thisThreadData->thread.loadAcquire() && currentData == targetData) {
+         // one exception to the rule: we allow moving objects with no thread affinity to the current thread
+         currentData = d->threadData;
+@@ -2620,7 +2620,7 @@ int QObject::receivers(const char *signal) const
+         if (!d->isSignalConnected(signal_index))
+             return receivers;
+ 
+-        if (d->declarativeData && QAbstractDeclarativeData::receivers) {
++        if (!d->isDeletingChildren && d->declarativeData && QAbstractDeclarativeData::receivers) {
+             receivers += QAbstractDeclarativeData::receivers(d->declarativeData, this,
+                                                              signal_index);
+         }
+diff --git a/qtbase/src/corelib/kernel/qobject_p.h b/qtbase/src/corelib/kernel/qobject_p.h
+index 0b827a52ca..13ffb88999 100644
+--- a/qtbase/src/corelib/kernel/qobject_p.h
++++ b/qtbase/src/corelib/kernel/qobject_p.h
+@@ -444,7 +444,7 @@ inline void QObjectPrivate::checkForIncompatibleLibraryVersion(int version) cons
+ 
+ inline bool QObjectPrivate::isDeclarativeSignalConnected(uint signal_index) const
+ {
+-    return declarativeData && QAbstractDeclarativeData::isSignalConnected
++    return !isDeletingChildren && declarativeData && QAbstractDeclarativeData::isSignalConnected
+             && QAbstractDeclarativeData::isSignalConnected(declarativeData, q_func(), signal_index);
+ }
+ 
+diff --git a/qtbase/src/corelib/kernel/qtranslator.cpp b/qtbase/src/corelib/kernel/qtranslator.cpp
+index 2812ffb7ea..bc0177c5ec 100644
+--- a/qtbase/src/corelib/kernel/qtranslator.cpp
++++ b/qtbase/src/corelib/kernel/qtranslator.cpp
+@@ -902,7 +902,7 @@ static QString getMessage(const uchar *m, const uchar *end, const char *context,
+             goto end;
+         case Tag_Translation: {
+             int len = read32(m);
+-            if (len % 1)
++            if (len & 1)
+                 return QString();
+             m += 4;
+             if (!numerus--) {
+diff --git a/qtbase/src/corelib/mimetypes/qmimedatabase.cpp b/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
+index 9de22cef33..ff868a3268 100644
+--- a/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
+@@ -389,20 +389,23 @@ QMimeType QMimeDatabasePrivate::mimeTypeForFileNameAndData(const QString &fileNa
+         // Disambiguate conflicting extensions (if magic matching found something)
+         if (candidateByData.isValid() && magicAccuracy > 0) {
+             const QString sniffedMime = candidateByData.name();
+-            // If the sniffedMime matches a glob match, use it
++            // If the sniffedMime matches a highest-weight glob match, use it
+             if (candidatesByName.m_matchingMimeTypes.contains(sniffedMime)) {
+                 *accuracyPtr = 100;
+                 return candidateByData;
+             }
+-            for (const QString &m : qAsConst(candidatesByName.m_matchingMimeTypes)) {
++            for (const QString &m : qAsConst(candidatesByName.m_allMatchingMimeTypes)) {
+                 if (inherits(m, sniffedMime)) {
+                     // We have magic + pattern pointing to this, so it's a pretty good match
+                     *accuracyPtr = 100;
+                     return mimeTypeForName(m);
+                 }
+             }
+-            *accuracyPtr = magicAccuracy;
+-            return candidateByData;
++            if (candidatesByName.m_allMatchingMimeTypes.isEmpty()) {
++                // No glob, use magic
++                *accuracyPtr = magicAccuracy;
++                return candidateByData;
++            }
+         }
+     }
+ 
+diff --git a/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp b/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
+index a81112d227..fa8f4c545d 100644
+--- a/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
+@@ -83,7 +83,10 @@ void QMimeGlobMatchResult::addMatch(const QString &mimeType, int weight, const Q
+     }
+     if (!m_matchingMimeTypes.contains(mimeType)) {
+         m_matchingMimeTypes.append(mimeType);
+-        m_allMatchingMimeTypes.append(mimeType);
++        if (replace)
++            m_allMatchingMimeTypes.prepend(mimeType); // highest-weight first
++        else
++            m_allMatchingMimeTypes.append(mimeType);
+         m_knownSuffixLength = knownSuffixLength;
+     }
+ }
+@@ -94,7 +97,7 @@ QMimeGlobPattern::PatternType QMimeGlobPattern::detectPatternType(const QString
+     if (!patternLength)
+         return OtherPattern;
+ 
+-    const bool starCount = pattern.count(QLatin1Char('*')) == 1;
++    const int starCount = pattern.count(QLatin1Char('*'));
+     const bool hasSquareBracket = pattern.indexOf(QLatin1Char('[')) != -1;
+     const bool hasQuestionMark = pattern.indexOf(QLatin1Char('?')) != -1;
+ 
+@@ -106,10 +109,10 @@ QMimeGlobPattern::PatternType QMimeGlobPattern::detectPatternType(const QString
+             // Patterns like "README*" (well this is currently the only one like that...)
+             if (pattern.at(patternLength - 1) == QLatin1Char('*'))
+                 return PrefixPattern;
+-        }
+-        // Names without any wildcards like "README"
+-        if (starCount == 0)
++        } else if (starCount == 0) {
++            // Names without any wildcards like "README"
+             return LiteralPattern;
++        }
+     }
+ 
+     if (pattern == QLatin1String("[0-9][0-9][0-9].vdr"))
+diff --git a/qtbase/src/corelib/mimetypes/qmimeprovider.cpp b/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
+index 258dddf8cb..4642d0f2d0 100644
+--- a/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
+@@ -244,15 +244,18 @@ void QMimeBinaryProvider::addFileNameMatches(const QString &fileName, QMimeGlobM
+     const QString lowerFileName = fileName.toLower();
+     // Check literals (e.g. "Makefile")
+     matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosLiteralListOffset), fileName);
+-    // Check complex globs (e.g. "callgrind.out[0-9]*")
+-    matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosGlobListOffset), fileName);
+     // Check the very common *.txt cases with the suffix tree
+-    const int reverseSuffixTreeOffset = m_cacheFile->getUint32(PosReverseSuffixTreeOffset);
+-    const int numRoots = m_cacheFile->getUint32(reverseSuffixTreeOffset);
+-    const int firstRootOffset = m_cacheFile->getUint32(reverseSuffixTreeOffset + 4);
+-    matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, lowerFileName, lowerFileName.length() - 1, false);
++    if (result.m_matchingMimeTypes.isEmpty()) {
++        const int reverseSuffixTreeOffset = m_cacheFile->getUint32(PosReverseSuffixTreeOffset);
++        const int numRoots = m_cacheFile->getUint32(reverseSuffixTreeOffset);
++        const int firstRootOffset = m_cacheFile->getUint32(reverseSuffixTreeOffset + 4);
++        matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, lowerFileName, lowerFileName.length() - 1, false);
++        if (result.m_matchingMimeTypes.isEmpty())
++            matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, fileName, fileName.length() - 1, true);
++    }
++    // Check complex globs (e.g. "callgrind.out[0-9]*" or "README*")
+     if (result.m_matchingMimeTypes.isEmpty())
+-        matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, fileName, fileName.length() - 1, true);
++        matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosGlobListOffset), fileName);
+ }
+ 
+ void QMimeBinaryProvider::matchGlobList(QMimeGlobMatchResult &result, CacheFile *cacheFile, int off, const QString &fileName)
+diff --git a/qtbase/src/corelib/serialization/qjsonparser.cpp b/qtbase/src/corelib/serialization/qjsonparser.cpp
+index 17e6f111ab..2e40b6c8fb 100644
+--- a/qtbase/src/corelib/serialization/qjsonparser.cpp
++++ b/qtbase/src/corelib/serialization/qjsonparser.cpp
+@@ -379,10 +379,30 @@ error:
+     return QCborValue();
+ }
+ 
++// We need to retain the _last_ value for any duplicate keys and we need to deref containers.
++// Therefore the manual implementation of std::unique().
++template<typename Iterator, typename Compare, typename Assign>
++static Iterator customAssigningUniqueLast(Iterator first, Iterator last,
++                                          Compare compare, Assign assign)
++{
++    first = std::adjacent_find(first, last, compare);
++    if (first == last)
++        return last;
++
++    Iterator result = first;
++    while (++first != last) {
++        if (!compare(*result, *first))
++            ++result;
++        if (result != first)
++            assign(*result, *first);
++    }
++
++    return ++result;
++}
++
+ static void sortContainer(QCborContainerPrivate *container)
+ {
+     using Forward = QJsonPrivate::KeyIterator;
+-    using Reverse = std::reverse_iterator<Forward>;
+     using Value = Forward::value_type;
+ 
+     auto compare = [container](const Value &a, const Value &b)
+@@ -420,17 +440,31 @@ static void sortContainer(QCborContainerPrivate *container)
+         }
+     };
+ 
+-    std::sort(Forward(container->elements.begin()), Forward(container->elements.end()),
+-              [&compare](const Value &a, const Value &b) { return compare(a, b) < 0; });
++    // The elements' containers are owned by the outer container, not by the elements themselves.
++    auto move = [](Forward::reference target, Forward::reference source)
++    {
++        QtCbor::Element &targetValue = target.value();
++
++        // If the target has a container, deref it before overwriting, so that we don't leak.
++        if (targetValue.flags & QtCbor::Element::IsContainer)
++            targetValue.container->deref();
++
++        // Do not move, so that we can clear the value afterwards.
++        target = source;
++
++        // Clear the source value, so that we don't store the same container twice.
++        source.value() = QtCbor::Element();
++    };
++
++    std::stable_sort(
++                Forward(container->elements.begin()), Forward(container->elements.end()),
++                [&compare](const Value &a, const Value &b) { return compare(a, b) < 0; });
+ 
+-    // We need to retain the _last_ value for any duplicate keys. Therefore the reverse dance here.
+-    auto it = std::unique(Reverse(container->elements.end()), Reverse(container->elements.begin()),
+-                          [&compare](const Value &a, const Value &b) {
+-        return compare(a, b) == 0;
+-    }).base().elementsIterator();
++    Forward result = customAssigningUniqueLast(
++                Forward(container->elements.begin()),  Forward(container->elements.end()),
++                [&compare](const Value &a, const Value &b) { return compare(a, b) == 0; }, move);
+ 
+-    // The erase from beginning is expensive but hopefully rare.
+-    container->elements.erase(container->elements.begin(), it);
++    container->elements.erase(result.elementsIterator(), container->elements.end());
+ }
+ 
+ 
+diff --git a/qtbase/src/corelib/serialization/qxmlstream.cpp b/qtbase/src/corelib/serialization/qxmlstream.cpp
+index b2f846544d..7cd457ba3a 100644
+--- a/qtbase/src/corelib/serialization/qxmlstream.cpp
++++ b/qtbase/src/corelib/serialization/qxmlstream.cpp
+@@ -980,7 +980,7 @@ inline uint QXmlStreamReaderPrivate::peekChar()
+ bool QXmlStreamReaderPrivate::scanUntil(const char *str, short tokenToInject)
+ {
+     int pos = textBuffer.size();
+-    int oldLineNumber = lineNumber;
++    const auto oldLineNumber = lineNumber;
+ 
+     uint c;
+     while ((c = getChar()) != StreamEOF) {
+diff --git a/qtbase/src/corelib/text/qstring.cpp b/qtbase/src/corelib/text/qstring.cpp
+index 3e88ab4859..8deeae47bb 100644
+--- a/qtbase/src/corelib/text/qstring.cpp
++++ b/qtbase/src/corelib/text/qstring.cpp
+@@ -12312,7 +12312,7 @@ static qsizetype qLastIndexOf(Haystack haystack0, qsizetype from,
+     const auto needle = needle0.data();
+     const auto *end = haystack;
+     haystack += from;
+-    const std::size_t sl_minus_1 = sl - 1;
++    const std::size_t sl_minus_1 = sl ? sl - 1 : 0;
+     const auto *n = needle + sl_minus_1;
+     const auto *h = haystack + sl_minus_1;
+     std::size_t hashNeedle = 0, hashHaystack = 0;
+diff --git a/qtbase/src/corelib/text/qstringiterator_p.h b/qtbase/src/corelib/text/qstringiterator_p.h
+index 219589b6e4..1d0c66cc78 100644
+--- a/qtbase/src/corelib/text/qstringiterator_p.h
++++ b/qtbase/src/corelib/text/qstringiterator_p.h
+@@ -61,6 +61,8 @@ class QStringIterator
+ {
+     QString::const_iterator i, pos, e;
+     Q_STATIC_ASSERT((std::is_same<QString::const_iterator, const QChar *>::value));
++    static bool less(const QChar *lhs, const QChar *rhs) noexcept
++    { return std::less<QString::const_iterator>{}(lhs, rhs); }
+ public:
+     explicit QStringIterator(QStringView string, qsizetype idx = 0)
+         : i(string.begin()),
+@@ -95,7 +97,8 @@ public:
+ 
+     inline void setPosition(QString::const_iterator position)
+     {
+-        Q_ASSERT_X(i <= position && position <= e, Q_FUNC_INFO, "position out of bounds");
++        Q_ASSERT_X(!less(position, i) && !less(e, position),
++                   Q_FUNC_INFO, "position out of bounds");
+         pos = position;
+     }
+ 
+@@ -103,7 +106,7 @@ public:
+ 
+     inline bool hasNext() const
+     {
+-        return pos < e;
++        return less(pos, e);
+     }
+ 
+     inline void advance()
+@@ -120,16 +123,20 @@ public:
+     {
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+-        if (Q_UNLIKELY((pos++)->isHighSurrogate()))
++        if (Q_UNLIKELY((pos++)->isHighSurrogate())) {
++            Q_ASSERT(hasNext() && pos->isLowSurrogate());
+             ++pos;
++        }
+     }
+ 
+     inline uint peekNextUnchecked() const
+     {
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+-        if (Q_UNLIKELY(pos->isHighSurrogate()))
++        if (Q_UNLIKELY(pos->isHighSurrogate())) {
++            Q_ASSERT(less(pos + 1, e) && pos[1].isLowSurrogate());
+             return QChar::surrogateToUcs4(pos[0], pos[1]);
++        }
+ 
+         return pos->unicode();
+     }
+@@ -155,8 +162,10 @@ public:
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+         const QChar cur = *pos++;
+-        if (Q_UNLIKELY(cur.isHighSurrogate()))
++        if (Q_UNLIKELY(cur.isHighSurrogate())) {
++            Q_ASSERT(hasNext() && pos->isLowSurrogate());
+             return QChar::surrogateToUcs4(cur, *pos++);
++        }
+         return cur.unicode();
+     }
+ 
+@@ -166,7 +175,7 @@ public:
+ 
+         const QChar uc = *pos++;
+         if (Q_UNLIKELY(uc.isSurrogate())) {
+-            if (Q_LIKELY(uc.isHighSurrogate() && pos < e && pos->isLowSurrogate()))
++            if (Q_LIKELY(uc.isHighSurrogate() && hasNext() && pos->isLowSurrogate()))
+                 return QChar::surrogateToUcs4(uc, *pos++);
+             return invalidAs;
+         }
+@@ -178,7 +187,7 @@ public:
+ 
+     inline bool hasPrevious() const
+     {
+-        return pos > i;
++        return less(i, pos);
+     }
+ 
+     inline void recede()
+@@ -196,16 +205,20 @@ public:
+     {
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+-        if (Q_UNLIKELY((--pos)->isLowSurrogate()))
++        if (Q_UNLIKELY((--pos)->isLowSurrogate())) {
++            Q_ASSERT(hasPrevious() && pos[-1].isHighSurrogate());
+             --pos;
++        }
+     }
+ 
+     inline uint peekPreviousUnchecked() const
+     {
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+-        if (Q_UNLIKELY(pos[-1].isLowSurrogate()))
++        if (Q_UNLIKELY(pos[-1].isLowSurrogate())) {
++            Q_ASSERT(less(i + 1, pos) && pos[-2].isHighSurrogate());
+             return QChar::surrogateToUcs4(pos[-2], pos[-1]);
++        }
+         return pos[-1].unicode();
+     }
+ 
+@@ -230,8 +243,10 @@ public:
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+         const QChar cur = *--pos;
+-        if (Q_UNLIKELY(cur.isLowSurrogate()))
++        if (Q_UNLIKELY(cur.isLowSurrogate())) {
++            Q_ASSERT(hasPrevious() && pos[-1].isHighSurrogate());
+             return QChar::surrogateToUcs4(*--pos, cur);
++        }
+         return cur.unicode();
+     }
+ 
+@@ -241,7 +256,7 @@ public:
+ 
+         const QChar uc = *--pos;
+         if (Q_UNLIKELY(uc.isSurrogate())) {
+-            if (Q_LIKELY(uc.isLowSurrogate() && pos > i && pos[-1].isHighSurrogate()))
++            if (Q_LIKELY(uc.isLowSurrogate() && hasPrevious() && pos[-1].isHighSurrogate()))
+                 return QChar::surrogateToUcs4(*--pos, uc);
+             return invalidAs;
+         }
+diff --git a/qtbase/src/corelib/thread/qfutex_p.h b/qtbase/src/corelib/thread/qfutex_p.h
+index f287b752d7..e294537787 100644
+--- a/qtbase/src/corelib/thread/qfutex_p.h
++++ b/qtbase/src/corelib/thread/qfutex_p.h
+@@ -52,6 +52,7 @@
+ //
+ 
+ #include <qglobal.h>
++#include <QtCore/qtsan_impl.h>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -106,16 +107,13 @@ namespace QtLinuxFutex {
+     inline int _q_futex(int *addr, int op, int val, quintptr val2 = 0,
+                         int *addr2 = nullptr, int val3 = 0) noexcept
+     {
+-        // A futex call ensures total ordering on the futex words
+-        // (in either success or failure of the call). Instruct TSAN accordingly,
+-        // as TSAN does not understand the futex(2) syscall.
+-        _q_tsan_release(addr, addr2);
++        QtTsan::futexRelease(addr, addr2);
+ 
+         // we use __NR_futex because some libcs (like Android's bionic) don't
+         // provide SYS_futex etc.
+         int result = syscall(__NR_futex, addr, op | FUTEX_PRIVATE_FLAG, val, val2, addr2, val3);
+ 
+-        _q_tsan_acquire(addr, addr2);
++        QtTsan::futexAcquire(addr, addr2);
+ 
+         return result;
+     }
+diff --git a/qtbase/src/corelib/thread/qmutex.cpp b/qtbase/src/corelib/thread/qmutex.cpp
+index 310d1cb14f..7097122d8e 100644
+--- a/qtbase/src/corelib/thread/qmutex.cpp
++++ b/qtbase/src/corelib/thread/qmutex.cpp
+@@ -152,6 +152,7 @@ public:
+ 
+ /*!
+     \enum QMutex::RecursionMode
++    \obsolete Use QRecursiveMutex to create a recursive mutex.
+ 
+     \value Recursive  In this mode, a thread can lock the same mutex
+                       multiple times and the mutex won't be unlocked
+@@ -173,6 +174,7 @@ public:
+ 
+ /*!
+     Constructs a new mutex. The mutex is created in an unlocked state.
++    \obsolete Use QRecursiveMutex to create a recursive mutex.
+ 
+     If \a mode is QMutex::Recursive, a thread can lock the same mutex
+     multiple times and the mutex won't be unlocked until a
+@@ -197,7 +199,7 @@ QMutex::QMutex(RecursionMode mode)
+ QMutex::~QMutex()
+ {
+     QMutexData *d = d_ptr.loadRelaxed();
+-    if (isRecursive()) {
++    if (QBasicMutex::isRecursive()) {
+         delete static_cast<QRecursiveMutexPrivate *>(d);
+     } else if (d) {
+ #ifndef QT_LINUX_FUTEX
+diff --git a/qtbase/src/corelib/thread/qmutex.h b/qtbase/src/corelib/thread/qmutex.h
+index 73c9e00663..1bae573a03 100644
+--- a/qtbase/src/corelib/thread/qmutex.h
++++ b/qtbase/src/corelib/thread/qmutex.h
+@@ -42,6 +42,7 @@
+ 
+ #include <QtCore/qglobal.h>
+ #include <QtCore/qatomic.h>
++#include <QtCore/qtsan_impl.h>
+ #include <new>
+ 
+ #if __has_include(<chrono>)
+@@ -77,19 +78,37 @@ public:
+ 
+     // BasicLockable concept
+     inline void lock() QT_MUTEX_LOCK_NOEXCEPT {
++        QtTsan::mutexPreLock(this, 0u);
++
+         if (!fastTryLock())
+             lockInternal();
++
++        QtTsan::mutexPostLock(this, 0u, 0);
+     }
+ 
+     // BasicLockable concept
+     inline void unlock() noexcept {
+         Q_ASSERT(d_ptr.loadRelaxed()); //mutex must be locked
++
++        QtTsan::mutexPreUnlock(this, 0u);
++
+         if (!fastTryUnlock())
+             unlockInternal();
++
++        QtTsan::mutexPostUnlock(this, 0u);
+     }
+ 
+     bool tryLock() noexcept {
+-        return fastTryLock();
++        unsigned tsanFlags = QtTsan::TryLock;
++        QtTsan::mutexPreLock(this, tsanFlags);
++
++        const bool success = fastTryLock();
++
++        if (!success)
++            tsanFlags |= QtTsan::TryLockFailed;
++        QtTsan::mutexPostLock(this, tsanFlags, 0);
++
++        return success;
+     }
+ 
+     // Lockable concept
+@@ -134,8 +153,16 @@ public:
+ #else
+     QMutex() { d_ptr.storeRelaxed(nullptr); }
+ #endif
++#if QT_DEPRECATED_SINCE(5,15)
+     enum RecursionMode { NonRecursive, Recursive };
++    QT_DEPRECATED_VERSION_X(5, 15, "Use QRecursiveMutex instead of a recursive QMutex")
+     explicit QMutex(RecursionMode mode);
++
++    QT_DEPRECATED_VERSION_X(5, 15, "Use QRecursiveMutex instead of a recursive QMutex")
++    bool isRecursive() const noexcept
++    { return QBasicMutex::isRecursive(); }
++#endif
++
+     ~QMutex();
+ 
+     // BasicLockable concept
+@@ -166,9 +193,6 @@ public:
+     }
+ #endif
+ 
+-    bool isRecursive() const noexcept
+-    { return QBasicMutex::isRecursive(); }
+-
+ private:
+     Q_DISABLE_COPY(QMutex)
+     friend class QMutexLocker;
+diff --git a/qtbase/src/corelib/thread/qreadwritelock.cpp b/qtbase/src/corelib/thread/qreadwritelock.cpp
+index 8c28507d5a..9dd8503116 100644
+--- a/qtbase/src/corelib/thread/qreadwritelock.cpp
++++ b/qtbase/src/corelib/thread/qreadwritelock.cpp
+@@ -155,7 +155,7 @@ QReadWriteLock::QReadWriteLock(RecursionMode recursionMode)
+ */
+ QReadWriteLock::~QReadWriteLock()
+ {
+-    auto d = d_ptr.loadRelaxed();
++    auto d = d_ptr.loadAcquire();
+     if (isUncontendedLocked(d)) {
+         qWarning("QReadWriteLock: destroying locked QReadWriteLock");
+         return;
+@@ -445,7 +445,7 @@ void QReadWriteLock::unlock()
+ /*! \internal  Helper for QWaitCondition::wait */
+ QReadWriteLock::StateForWaitCondition QReadWriteLock::stateForWaitCondition() const
+ {
+-    QReadWriteLockPrivate *d = d_ptr.loadRelaxed();
++    QReadWriteLockPrivate *d = d_ptr.loadAcquire();
+     switch (quintptr(d) & StateMask) {
+     case StateLockedForRead: return LockedForRead;
+     case StateLockedForWrite: return LockedForWrite;
+@@ -453,6 +453,7 @@ QReadWriteLock::StateForWaitCondition QReadWriteLock::stateForWaitCondition() co
+ 
+     if (!d)
+         return Unlocked;
++    const auto lock = qt_scoped_lock(d->mutex);
+     if (d->writerCount > 1)
+         return RecursivelyLocked;
+     else if (d->writerCount == 1)
+diff --git a/qtbase/src/corelib/thread/qsemaphore.cpp b/qtbase/src/corelib/thread/qsemaphore.cpp
+index 1d01fc1b28..3ecdee3747 100644
+--- a/qtbase/src/corelib/thread/qsemaphore.cpp
++++ b/qtbase/src/corelib/thread/qsemaphore.cpp
+@@ -354,7 +354,12 @@ void QSemaphore::release(int n)
+         quintptr nn = unsigned(n);
+         if (futexHasWaiterCount)
+             nn |= quint64(nn) << 32;    // token count replicated in high word
+-        quintptr prevValue = u.fetchAndAddRelease(nn);
++        quintptr prevValue = u.loadRelaxed();
++        quintptr newValue;
++        do { // loop just to ensure the operations are done atomically
++            newValue = prevValue + nn;
++            newValue &= (futexNeedsWakeAllBit - 1);
++        } while (!u.testAndSetRelease(prevValue, newValue, prevValue));
+         if (futexNeedsWake(prevValue)) {
+ #ifdef FUTEX_OP
+             if (futexHasWaiterCount) {
+@@ -376,7 +381,6 @@ void QSemaphore::release(int n)
+                 quint32 oparg = 0;
+                 quint32 cmp = FUTEX_OP_CMP_NE;
+                 quint32 cmparg = 0;
+-                u.fetchAndAndRelease(futexNeedsWakeAllBit - 1);
+                 futexWakeOp(*futexLow32(&u), n, INT_MAX, *futexHigh32(&u), FUTEX_OP(op, oparg, cmp, cmparg));
+                 return;
+             }
+@@ -388,7 +392,6 @@ 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(futexNeedsWakeAllBit - 1);
+             if (futexHasWaiterCount) {
+                 futexWakeAll(*futexLow32(&u));
+                 futexWakeAll(*futexHigh32(&u));
+diff --git a/qtbase/src/corelib/thread/qthread_p.h b/qtbase/src/corelib/thread/qthread_p.h
+index b2d1628e6e..f32f6f0460 100644
+--- a/qtbase/src/corelib/thread/qthread_p.h
++++ b/qtbase/src/corelib/thread/qthread_p.h
+@@ -174,7 +174,7 @@ public:
+     int returnCode;
+ 
+     uint stackSize;
+-    QThread::Priority priority;
++    std::underlying_type<QThread::Priority>::type priority;
+ 
+     static QThread *threadForId(int id);
+ 
+@@ -213,6 +213,13 @@ public:
+             QCoreApplication::instance()->postEvent(q_ptr, new QEvent(QEvent::Quit));
+         }
+     }
++
++#ifndef Q_OS_INTEGRITY
++private:
++    // Used in QThread(Private)::start to avoid racy access to QObject::objectName,
++    // unset afterwards. On INTEGRITY we set the thread name before starting it.
++    QString objectName;
++#endif
+ };
+ 
+ #else // QT_CONFIG(thread)
+diff --git a/qtbase/src/corelib/thread/qthread_unix.cpp b/qtbase/src/corelib/thread/qthread_unix.cpp
+index 56a8e0a038..610117a640 100644
+--- a/qtbase/src/corelib/thread/qthread_unix.cpp
++++ b/qtbase/src/corelib/thread/qthread_unix.cpp
+@@ -169,8 +169,7 @@ static void set_thread_data(QThreadData *data)
+ 
+ static void clear_thread_data()
+ {
+-    currentThreadData = nullptr;
+-    pthread_setspecific(current_thread_data_key, nullptr);
++    set_thread_data(nullptr);
+ }
+ 
+ template <typename T>
+@@ -296,7 +295,7 @@ void *QThreadPrivate::start(void *arg)
+             QMutexLocker locker(&thr->d_func()->mutex);
+ 
+             // do we need to reset the thread priority?
+-            if (int(thr->d_func()->priority) & ThreadPriorityResetFlag) {
++            if (thr->d_func()->priority & ThreadPriorityResetFlag) {
+                 thr->d_func()->setPriority(QThread::Priority(thr->d_func()->priority & ~ThreadPriorityResetFlag));
+             }
+ 
+@@ -316,10 +315,10 @@ void *QThreadPrivate::start(void *arg)
+             // Sets the name of the current thread. We can only do this
+             // when the thread is starting, as we don't have a cross
+             // platform way of setting the name of an arbitrary thread.
+-            if (Q_LIKELY(thr->objectName().isEmpty()))
++            if (Q_LIKELY(thr->d_func()->objectName.isEmpty()))
+                 setCurrentThreadName(thr->metaObject()->className());
+             else
+-                setCurrentThreadName(thr->objectName().toLocal8Bit());
++                setCurrentThreadName(std::exchange(thr->d_func()->objectName, {}).toLocal8Bit());
+         }
+ #endif
+ 
+@@ -671,7 +670,7 @@ void QThread::start(Priority priority)
+                 // could not set scheduling hints, fallback to inheriting them
+                 // we'll try again from inside the thread
+                 pthread_attr_setinheritsched(&attr, PTHREAD_INHERIT_SCHED);
+-                d->priority = Priority(priority | ThreadPriorityResetFlag);
++                d->priority = static_cast<std::underlying_type<QThread::Priority>::type>(priority) | ThreadPriorityResetFlag;
+             }
+             break;
+         }
+@@ -702,7 +701,10 @@ void QThread::start(Priority priority)
+         pthread_attr_setthreadname(&attr, metaObject()->className());
+     else
+         pthread_attr_setthreadname(&attr, objectName().toLocal8Bit());
++#else
++    d->objectName = objectName();
+ #endif
++
+     pthread_t threadId;
+     int code = pthread_create(&threadId, &attr, QThreadPrivate::start, this);
+     if (code == EPERM) {
+diff --git a/qtbase/src/corelib/thread/qthread_win.cpp b/qtbase/src/corelib/thread/qthread_win.cpp
+index bc70e3178a..4e76972498 100644
+--- a/qtbase/src/corelib/thread/qthread_win.cpp
++++ b/qtbase/src/corelib/thread/qthread_win.cpp
+@@ -394,10 +394,9 @@ unsigned int __stdcall QT_ENSURE_STACK_ALIGNED_FOR_SSE QThreadPrivate::start(voi
+ 
+ #if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) && !defined(Q_OS_WINRT)
+     // sets the name of the current thread.
+-    QByteArray objectName = thr->objectName().toLocal8Bit();
+-    qt_set_thread_name(HANDLE(-1),
+-                       objectName.isEmpty() ?
+-                       thr->metaObject()->className() : objectName.constData());
++    qt_set_thread_name(HANDLE(-1), thr->d_func()->objectName.isEmpty()
++                        ? thr->metaObject()->className()
++                        : std::exchange(thr->d_func()->objectName, {}).toLocal8Bit().constData());
+ #endif
+ 
+     emit thr->started(QThread::QPrivateSignal());
+@@ -503,6 +502,7 @@ void QThread::start(Priority priority)
+     if (d->running)
+         return;
+ 
++    d->objectName = objectName();
+     d->running = true;
+     d->finished = false;
+     d->exited = false;
+@@ -548,7 +548,7 @@ void QThread::start(Priority priority)
+ 
+     int prio;
+     d->priority = priority;
+-    switch (d->priority) {
++    switch (priority) {
+     case IdlePriority:
+         prio = THREAD_PRIORITY_IDLE;
+         break;
+@@ -686,7 +686,7 @@ void QThreadPrivate::setPriority(QThread::Priority threadPriority)
+ 
+     int prio;
+     priority = threadPriority;
+-    switch (priority) {
++    switch (threadPriority) {
+     case QThread::IdlePriority:
+         prio = THREAD_PRIORITY_IDLE;
+         break;
+diff --git a/qtbase/src/corelib/thread/qtsan_impl.h b/qtbase/src/corelib/thread/qtsan_impl.h
+new file mode 100644
+index 0000000000..580a738b91
+--- /dev/null
++++ b/qtbase/src/corelib/thread/qtsan_impl.h
+@@ -0,0 +1,115 @@
++/****************************************************************************
++**
++** Copyright (C) 2017 Intel Corporation.
++** Copyright (C) 2022 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
++** 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 QTSAN_IMPL_H
++#define QTSAN_IMPL_H
++
++#include <QtCore/qglobal.h>
++
++#if (__has_feature(thread_sanitizer) || defined(__SANITIZE_THREAD__)) && __has_include(<sanitizer/tsan_interface.h>)
++#  define QT_BUILDING_UNDER_TSAN
++#  include <sanitizer/tsan_interface.h>
++#endif
++
++QT_BEGIN_NAMESPACE
++
++namespace QtTsan {
++#ifdef QT_BUILDING_UNDER_TSAN
++inline void futexAcquire(void *addr, void *addr2 = nullptr)
++{
++    // A futex call ensures total ordering on the futex words
++    // (in either success or failure of the call). Instruct TSAN accordingly,
++    // as TSAN does not understand the futex(2) syscall (or equivalent).
++    ::__tsan_acquire(addr);
++    if (addr2)
++        ::__tsan_acquire(addr2);
++}
++
++inline void futexRelease(void *addr, void *addr2 = nullptr)
++{
++    if (addr2)
++        ::__tsan_release(addr2);
++    ::__tsan_release(addr);
++}
++
++inline void mutexPreLock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_pre_lock(addr, flags);
++}
++
++inline void mutexPostLock(void *addr, unsigned flags, int recursion)
++{
++    ::__tsan_mutex_post_lock(addr, flags, recursion);
++}
++
++inline void mutexPreUnlock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_pre_unlock(addr, flags);
++}
++
++inline void mutexPostUnlock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_post_unlock(addr, flags);
++}
++
++enum : unsigned {
++    MutexWriteReentrant = ::__tsan_mutex_write_reentrant,
++    TryLock = ::__tsan_mutex_try_lock,
++    TryLockFailed = ::__tsan_mutex_try_lock_failed,
++};
++#else
++inline void futexAcquire(void *, void * = nullptr) {}
++inline void futexRelease(void *, void * = nullptr) {}
++
++enum : unsigned {
++    MutexWriteReentrant,
++    TryLock,
++    TryLockFailed,
++};
++inline void mutexPreLock(void *, unsigned) {}
++inline void mutexPostLock(void *, unsigned, int) {}
++inline void mutexPreUnlock(void *, unsigned) {}
++inline void mutexPostUnlock(void *, unsigned) {}
++#endif // QT_BUILDING_UNDER_TSAN
++} // namespace QtTsan
++
++QT_END_NAMESPACE
++
++#endif // QTSAN_IMPL_H
+diff --git a/qtbase/src/corelib/thread/qwaitcondition_unix.cpp b/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
+index 88b058f410..0f1da4dc9b 100644
+--- a/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
++++ b/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
+@@ -213,7 +213,7 @@ bool QWaitCondition::wait(QMutex *mutex, QDeadlineTimer deadline)
+ {
+     if (! mutex)
+         return false;
+-    if (mutex->isRecursive()) {
++    if (static_cast<QBasicMutex *>(mutex)->isRecursive()) {
+         qWarning("QWaitCondition: cannot wait on recursive mutexes");
+         return false;
+     }
+diff --git a/qtbase/src/corelib/time/qdatetime.cpp b/qtbase/src/corelib/time/qdatetime.cpp
+index ec12569e3f..2c0b098079 100644
+--- a/qtbase/src/corelib/time/qdatetime.cpp
++++ b/qtbase/src/corelib/time/qdatetime.cpp
+@@ -43,6 +43,7 @@
+ #if QT_CONFIG(datetimeparser)
+ #include "private/qdatetimeparser_p.h"
+ #endif
++#include <private/qnumeric_p.h>
+ 
+ #include "qdatastream.h"
+ #include "qset.h"
+@@ -1429,9 +1430,11 @@ QDate QDate::addDays(qint64 ndays) const
+     if (isNull())
+         return QDate();
+ 
+-    // Due to limits on minJd() and maxJd() we know that any overflow
+-    // will be invalid and caught by fromJulianDay().
+-    return fromJulianDay(jd + ndays);
++    qint64 r;
++    if (Q_UNLIKELY(add_overflow(jd, ndays, &r)))
++        return QDate();
++    else
++        return fromJulianDay(r);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/corelib/time/qtimezone.cpp b/qtbase/src/corelib/time/qtimezone.cpp
+index 0309e43e52..3d451696a1 100644
+--- a/qtbase/src/corelib/time/qtimezone.cpp
++++ b/qtbase/src/corelib/time/qtimezone.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2013 John Layt <jlayt@kde.org>
++** Copyright (C) 2020 John Layt <jlayt@kde.org>
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtCore module of the Qt Toolkit.
+@@ -975,9 +975,15 @@ QList<QByteArray> QTimeZone::windowsIdToIanaIds(const QByteArray &windowsId,
+ }
+ 
+ #ifndef QT_NO_DATASTREAM
++// Invalid, as an IANA ID: too long, starts with - and has other invalid characters in it
++static inline QString invalidId() { return QStringLiteral("-No Time Zone Specified!"); }
++
+ QDataStream &operator<<(QDataStream &ds, const QTimeZone &tz)
+ {
+-    tz.d->serialize(ds);
++    if (tz.isValid())
++        tz.d->serialize(ds);
++    else
++        ds << invalidId();
+     return ds;
+ }
+ 
+@@ -985,7 +991,9 @@ QDataStream &operator>>(QDataStream &ds, QTimeZone &tz)
+ {
+     QString ianaId;
+     ds >> ianaId;
+-    if (ianaId == QLatin1String("OffsetFromUtc")) {
++    if (ianaId == invalidId()) {
++        tz = QTimeZone();
++    } else if (ianaId == QLatin1String("OffsetFromUtc")) {
+         int utcOffset;
+         QString name;
+         QString abbreviation;
+diff --git a/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp b/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
+index b1611d7ddb..a7a6a72ccf 100644
+--- a/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
++++ b/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
+@@ -42,6 +42,7 @@
+ #include "qtimezone.h"
+ #include "qtimezoneprivate_p.h"
+ #include "private/qlocale_tools_p.h"
++#include "private/qlocking_p.h"
+ 
+ #include <QtCore/QDataStream>
+ #include <QtCore/QDateTime>
+@@ -62,6 +63,10 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++#if QT_CONFIG(icu)
++static QBasicMutex s_icu_mutex;
++#endif
++
+ /*
+     Private
+ 
+@@ -670,6 +675,9 @@ QTzTimeZonePrivate::~QTzTimeZonePrivate()
+ 
+ QTzTimeZonePrivate *QTzTimeZonePrivate::clone() const
+ {
++#if QT_CONFIG(icu)
++    const auto lock = qt_scoped_lock(s_icu_mutex);
++#endif
+     return new QTzTimeZonePrivate(*this);
+ }
+ 
+@@ -913,12 +921,14 @@ QString QTzTimeZonePrivate::displayName(qint64 atMSecsSinceEpoch,
+                                         const QLocale &locale) const
+ {
+ #if QT_CONFIG(icu)
++    auto lock = qt_unique_lock(s_icu_mutex);
+     if (!m_icu)
+         m_icu = new QIcuTimeZonePrivate(m_id);
+     // TODO small risk may not match if tran times differ due to outdated files
+     // TODO Some valid TZ names are not valid ICU names, use translation table?
+     if (m_icu->isValid())
+         return m_icu->displayName(atMSecsSinceEpoch, nameType, locale);
++    lock.unlock();
+ #else
+     Q_UNUSED(nameType)
+     Q_UNUSED(locale)
+@@ -932,12 +942,14 @@ QString QTzTimeZonePrivate::displayName(QTimeZone::TimeType timeType,
+                                         const QLocale &locale) const
+ {
+ #if QT_CONFIG(icu)
++    auto lock = qt_unique_lock(s_icu_mutex);
+     if (!m_icu)
+         m_icu = new QIcuTimeZonePrivate(m_id);
+     // TODO small risk may not match if tran times differ due to outdated files
+     // TODO Some valid TZ names are not valid ICU names, use translation table?
+     if (m_icu->isValid())
+         return m_icu->displayName(timeType, nameType, locale);
++    lock.unlock();
+ #else
+     Q_UNUSED(timeType)
+     Q_UNUSED(nameType)
+diff --git a/qtbase/src/corelib/tools/qarraydata.h b/qtbase/src/corelib/tools/qarraydata.h
+index dcd95924c1..d01739e7e6 100644
+--- a/qtbase/src/corelib/tools/qarraydata.h
++++ b/qtbase/src/corelib/tools/qarraydata.h
+@@ -42,6 +42,7 @@
+ 
+ #include <QtCore/qrefcount.h>
+ #include <string.h>
++#include <cstdint>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -58,14 +59,14 @@ struct Q_CORE_EXPORT QArrayData
+     {
+         Q_ASSERT(size == 0
+                 || offset < 0 || size_t(offset) >= sizeof(QArrayData));
+-        return reinterpret_cast<char *>(this) + offset;
++        return reinterpret_cast<void *> (reinterpret_cast<uintptr_t>(this) + offset);
+     }
+ 
+     const void *data() const
+     {
+         Q_ASSERT(size == 0
+                 || offset < 0 || size_t(offset) >= sizeof(QArrayData));
+-        return reinterpret_cast<const char *>(this) + offset;
++        return reinterpret_cast<void *> (reinterpret_cast<uintptr_t>(this) + offset);
+     }
+ 
+     // This refers to array data mutability, not "header data" represented by
+diff --git a/qtbase/src/corelib/tools/qfreelist_p.h b/qtbase/src/corelib/tools/qfreelist_p.h
+index 5ba23b344b..9974102136 100644
+--- a/qtbase/src/corelib/tools/qfreelist_p.h
++++ b/qtbase/src/corelib/tools/qfreelist_p.h
+@@ -161,7 +161,7 @@ class QFreeList
+                 return i;
+             x -= size;
+         }
+-        Q_ASSERT(false);
++        Q_UNREACHABLE();
+         return -1;
+     }
+ 
+diff --git a/qtbase/src/corelib/tools/qversionnumber.h b/qtbase/src/corelib/tools/qversionnumber.h
+index d43b86ba51..2843f2b043 100644
+--- a/qtbase/src/corelib/tools/qversionnumber.h
++++ b/qtbase/src/corelib/tools/qversionnumber.h
+@@ -273,10 +273,10 @@ public:
+ 
+     Q_REQUIRED_RESULT Q_CORE_EXPORT QString toString() const;
+ #if QT_STRINGVIEW_LEVEL < 2
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(const QString &string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(const QString &string, int *suffixIndex = nullptr);
+ #endif
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QLatin1String string, int *suffixIndex = nullptr);
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QStringView string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(QLatin1String string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(QStringView string, int *suffixIndex = nullptr);
+ 
+ private:
+ #ifndef QT_NO_DATASTREAM
+diff --git a/qtbase/src/dbus/qdbusintegrator.cpp b/qtbase/src/dbus/qdbusintegrator.cpp
+index 5b66ce971b..28a3b0ffea 100644
+--- a/qtbase/src/dbus/qdbusintegrator.cpp
++++ b/qtbase/src/dbus/qdbusintegrator.cpp
+@@ -1135,7 +1135,13 @@ void QDBusConnectionPrivate::closeConnection()
+         }
+     }
+ 
+-    qDeleteAll(pendingCalls);
++    for (auto it = pendingCalls.begin(); it != pendingCalls.end(); ++it) {
++        auto call = *it;
++        if (!call->ref.deref()) {
++            delete call;
++        }
++    }
++    pendingCalls.clear();
+ 
+     // Disconnect all signals from signal hooks and from the object tree to
+     // avoid QObject::destroyed being sent to dbus daemon thread which has
+@@ -2584,6 +2590,11 @@ QDBusConnectionPrivate::findMetaObject(const QString &service, const QString &pa
+         if (mo)
+             return mo;
+     }
++    if (path.isEmpty()) {
++        error = QDBusError(QDBusError::InvalidObjectPath, QLatin1String("Object path cannot be empty"));
++        lastError = error;
++        return nullptr;
++    }
+ 
+     // introspect the target object
+     QDBusMessage msg = QDBusMessage::createMethodCall(service, path,
+diff --git a/qtbase/src/dbus/qdbusmetaobject.cpp b/qtbase/src/dbus/qdbusmetaobject.cpp
+index 5265568f42..7e9f0f1acc 100644
+--- a/qtbase/src/dbus/qdbusmetaobject.cpp
++++ b/qtbase/src/dbus/qdbusmetaobject.cpp
+@@ -210,6 +210,9 @@ QDBusMetaObjectGenerator::findType(const QByteArray &signature,
+         } else if (signature == "a{ss}") {
+             result.name = "QMap<QString,QString>";
+             type = qMetaTypeId<QMap<QString, QString> >();
++        } else if (signature == "aay") {
++            result.name = "QByteArrayList";
++            type = qMetaTypeId<QByteArrayList>();
+         } else {
+             result.name = "{D-Bus type \"" + signature + "\"}";
+             type = registerComplexDBusType(result.name);
+diff --git a/qtbase/src/gui/accessible/qaccessible.cpp b/qtbase/src/gui/accessible/qaccessible.cpp
+index d705bfccb5..0caf3c808c 100644
+--- a/qtbase/src/gui/accessible/qaccessible.cpp
++++ b/qtbase/src/gui/accessible/qaccessible.cpp
+@@ -54,6 +54,7 @@
+ #include <QtCore/qdebug.h>
+ #include <QtCore/qloggingcategory.h>
+ #include <QtCore/qmetaobject.h>
++#include <QtCore/private/qmetaobject_p.h>
+ #include <QtCore/qhash.h>
+ #include <private/qfactoryloader_p.h>
+ 
+@@ -681,6 +682,25 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
+     // Create a QAccessibleInterface for the object class. Start by the most
+     // derived class and walk up the class hierarchy.
+     const QMetaObject *mo = object->metaObject();
++    const auto *objectPriv = QObjectPrivate::get(object);
++    /*
++     We do not want to cache each and every QML metaobject (Button_QMLTYPE_124,
++     Button_QMLTYPE_125, etc.). Those dynamic metaobjects shouldn't have an
++     accessible interface in any case. Instead, we start the whole checking
++     with the first non-dynamic meta-object. To avoid potential regressions
++     in other areas of Qt that also use dynamic metaobjects, we only do this
++     for objects that are QML-related (approximated by checking whether they
++     have ddata set).
++    */
++    const bool qmlRelated = !objectPriv->isDeletingChildren &&
++                            objectPriv->declarativeData;
++    while (qmlRelated && mo) {
++        auto mop = QMetaObjectPrivate::get(mo);
++        if (!mop || !(mop->flags & DynamicMetaObject))
++            break;
++
++        mo = mo->superClass();
++    };
+     while (mo) {
+         const QString cn = QLatin1String(mo->className());
+ 
+@@ -696,14 +716,15 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
+         // Find a QAccessiblePlugin (factory) for the class name. If there's
+         // no entry in the cache try to create it using the plugin loader.
+         if (!qAccessiblePlugins()->contains(cn)) {
++            QAccessiblePlugin *factory = nullptr; // 0 means "no plugin found". This is cached as well.
+             const int index = loader()->indexOf(cn);
+-            if (index != -1) {
+-                QAccessiblePlugin *factory = qobject_cast<QAccessiblePlugin *>(loader()->instance(index));
+-                qAccessiblePlugins()->insert(cn, factory);
+-            }
++            if (index != -1)
++                factory = qobject_cast<QAccessiblePlugin *>(loader()->instance(index));
++            qAccessiblePlugins()->insert(cn, factory);
+         }
+ 
+         // At this point the cache should contain a valid factory pointer or 0:
++        Q_ASSERT(qAccessiblePlugins()->contains(cn));
+         QAccessiblePlugin *factory = qAccessiblePlugins()->value(cn);
+         if (factory) {
+             QAccessibleInterface *result = factory->create(cn, object);
+diff --git a/qtbase/src/gui/configure.json b/qtbase/src/gui/configure.json
+index 1f08795c57..12c95742d2 100644
+--- a/qtbase/src/gui/configure.json
++++ b/qtbase/src/gui/configure.json
+@@ -834,7 +834,8 @@
+                     "// embedded devices, are not intended to be used together with X. EGL support",
+                     "// has to be disabled in plugins like xcb in this case since the native display,",
+                     "// window and pixmap types will be different than what an X-based platform",
+-                    "// plugin would expect."
++                    "// plugin would expect.",
++                    "#define USE_X11"
+                 ],
+                 "include": [ "EGL/egl.h", "X11/Xlib.h" ],
+                 "main": [
+diff --git a/qtbase/src/gui/image/qbmphandler.cpp b/qtbase/src/gui/image/qbmphandler.cpp
+index 96f1e8cb1d..0e73bbbdb0 100644
+--- a/qtbase/src/gui/image/qbmphandler.cpp
++++ b/qtbase/src/gui/image/qbmphandler.cpp
+@@ -150,16 +150,42 @@ static QDataStream &operator<<(QDataStream &s, const BMP_INFOHDR &bi)
+     return s;
+ }
+ 
+-static int calc_shift(uint mask)
++static uint calc_shift(uint mask)
+ {
+-    int result = 0;
+-    while (mask && !(mask & 1)) {
++    uint result = 0;
++    while ((mask >= 0x100) || (!(mask & 1) && mask)) {
+         result++;
+         mask >>= 1;
+     }
+     return result;
+ }
+ 
++static uint calc_scale(uint low_mask)
++{
++    uint result = 8;
++    while (low_mask && result) {
++        result--;
++        low_mask >>= 1;
++    }
++    return result;
++}
++
++static inline uint apply_scale(uint value, uint scale)
++{
++    if (!(scale & 0x07)) // return immediately if scale == 8 or 0
++        return value;
++
++    uint filled = 8 - scale;
++    uint result = value << scale;
++
++    do {
++        result |= result >> filled;
++        filled <<= 1;
++    } while (filled < 8);
++
++    return result;
++}
++
+ static bool read_dib_fileheader(QDataStream &s, BMP_FILEHDR &bf)
+ {
+     // read BMP file header
+@@ -222,14 +248,14 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+     uint green_mask = 0;
+     uint blue_mask = 0;
+     uint alpha_mask = 0;
+-    int red_shift = 0;
+-    int green_shift = 0;
+-    int blue_shift = 0;
+-    int alpha_shift = 0;
+-    int red_scale = 0;
+-    int green_scale = 0;
+-    int blue_scale = 0;
+-    int alpha_scale = 0;
++    uint red_shift = 0;
++    uint green_shift = 0;
++    uint blue_shift = 0;
++    uint alpha_shift = 0;
++    uint red_scale = 0;
++    uint green_scale = 0;
++    uint blue_scale = 0;
++    uint alpha_scale = 0;
+ 
+     if (!d->isSequential())
+         d->seek(startpos + BMP_FILEHDR_SIZE + bi.biSize); // goto start of colormap or masks
+@@ -308,19 +334,19 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+         red_shift = calc_shift(red_mask);
+         if (((red_mask >> red_shift) + 1) == 0)
+             return false;
+-        red_scale = 256 / ((red_mask >> red_shift) + 1);
++        red_scale = calc_scale(red_mask >> red_shift);
+         green_shift = calc_shift(green_mask);
+         if (((green_mask >> green_shift) + 1) == 0)
+             return false;
+-        green_scale = 256 / ((green_mask >> green_shift) + 1);
++        green_scale = calc_scale(green_mask >> green_shift);
+         blue_shift = calc_shift(blue_mask);
+         if (((blue_mask >> blue_shift) + 1) == 0)
+             return false;
+-        blue_scale = 256 / ((blue_mask >> blue_shift) + 1);
++        blue_scale = calc_scale(blue_mask >> blue_shift);
+         alpha_shift = calc_shift(alpha_mask);
+         if (((alpha_mask >> alpha_shift) + 1) == 0)
+             return false;
+-        alpha_scale = 256 / ((alpha_mask >> alpha_shift) + 1);
++        alpha_scale = calc_scale(alpha_mask >> alpha_shift);
+     } else if (comp == BMP_RGB && (nbits == 24 || nbits == 32)) {
+         blue_mask = 0x000000ff;
+         green_mask = 0x0000ff00;
+@@ -328,17 +354,15 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+         blue_shift = 0;
+         green_shift = 8;
+         red_shift = 16;
+-        blue_scale = green_scale = red_scale = 1;
++        blue_scale = green_scale = red_scale = 0;
+     } else if (comp == BMP_RGB && nbits == 16) {
+         blue_mask = 0x001f;
+         green_mask = 0x03e0;
+         red_mask = 0x7c00;
+         blue_shift = 0;
+-        green_shift = 2;
+-        red_shift = 7;
+-        red_scale = 1;
+-        green_scale = 1;
+-        blue_scale = 8;
++        green_shift = 5;
++        red_shift = 10;
++        blue_scale = green_scale = red_scale = 3;
+     }
+ 
+ #if 0
+@@ -544,10 +568,10 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+                     c |= *(uchar*)(b+2)<<16;
+                 if (nbits > 24)
+                     c |= *(uchar*)(b+3)<<24;
+-                *p++ = qRgba(((c & red_mask) >> red_shift) * red_scale,
+-                                        ((c & green_mask) >> green_shift) * green_scale,
+-                                        ((c & blue_mask) >> blue_shift) * blue_scale,
+-                                        transp ? ((c & alpha_mask) >> alpha_shift) * alpha_scale : 0xff);
++                *p++ = qRgba(apply_scale((c & red_mask) >> red_shift, red_scale),
++                             apply_scale((c & green_mask) >> green_shift, green_scale),
++                             apply_scale((c & blue_mask) >> blue_shift, blue_scale),
++                             transp ? apply_scale((c & alpha_mask) >> alpha_shift, alpha_scale) : 0xff);
+                 b += nbits/8;
+             }
+         }
+diff --git a/qtbase/src/gui/image/qimage.cpp b/qtbase/src/gui/image/qimage.cpp
+index 7152ac1607..0df772564c 100644
+--- a/qtbase/src/gui/image/qimage.cpp
++++ b/qtbase/src/gui/image/qimage.cpp
+@@ -4694,6 +4694,8 @@ QImage QImage::smoothScaled(int w, int h) const {
+ static QImage rotated90(const QImage &image)
+ {
+     QImage out(image.height(), image.width(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+@@ -4722,6 +4724,8 @@ static QImage rotated180(const QImage &image)
+         return image.mirrored(true, true);
+ 
+     QImage out(image.width(), image.height(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+@@ -4734,6 +4738,8 @@ static QImage rotated180(const QImage &image)
+ static QImage rotated270(const QImage &image)
+ {
+     QImage out(image.height(), image.width(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+diff --git a/qtbase/src/gui/kernel/qcursor.cpp b/qtbase/src/gui/kernel/qcursor.cpp
+index d6ccaff8ed..455088241c 100644
+--- a/qtbase/src/gui/kernel/qcursor.cpp
++++ b/qtbase/src/gui/kernel/qcursor.cpp
+@@ -251,7 +251,8 @@ void QCursor::setPos(QScreen *screen, int x, int y)
+ {
+     if (screen) {
+         if (QPlatformCursor *cursor = screen->handle()->cursor()) {
+-            const QPoint devicePos = QHighDpi::toNativePixels(QPoint(x, y), screen);
++            const QPoint pos(x, y);
++            const QPoint devicePos = QHighDpi::toNativePixels(pos, screen->virtualSiblingAt(pos));
+             // Need to check, since some X servers generate null mouse move
+             // events, causing looping in applications which call setPos() on
+             // every mouse move event.
+diff --git a/qtbase/src/gui/kernel/qhighdpiscaling.cpp b/qtbase/src/gui/kernel/qhighdpiscaling.cpp
+index 9bbf2773a9..3ac4a4d8b6 100644
+--- a/qtbase/src/gui/kernel/qhighdpiscaling.cpp
++++ b/qtbase/src/gui/kernel/qhighdpiscaling.cpp
+@@ -580,9 +580,8 @@ void QHighDpiScaling::setScreenFactor(QScreen *screen, qreal factor)
+     else
+         qNamedScreenScaleFactors()->insert(name, factor);
+ 
+-    // hack to force re-evaluation of screen geometry
+     if (screen->handle())
+-        screen->d_func()->setPlatformScreen(screen->handle()); // updates geometries based on scale factor
++        screen->d_func()->updateLogicalDpi();
+ }
+ 
+ QPoint QHighDpiScaling::mapPositionToNative(const QPoint &pos, const QPlatformScreen *platformScreen)
+diff --git a/qtbase/src/gui/kernel/qkeysequence.cpp b/qtbase/src/gui/kernel/qkeysequence.cpp
+index a75b8ef920..4f2d294739 100644
+--- a/qtbase/src/gui/kernel/qkeysequence.cpp
++++ b/qtbase/src/gui/kernel/qkeysequence.cpp
+@@ -701,6 +701,10 @@ static const struct {
+     { Qt::Key_TouchpadToggle,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad Toggle") },
+     { Qt::Key_TouchpadOn,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad On") },
+     { Qt::Key_TouchpadOff,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad Off") },
++    { Qt::Key_Shift,  QT_TRANSLATE_NOOP("QShortcut", "Shift") },
++    { Qt::Key_Control,  QT_TRANSLATE_NOOP("QShortcut", "Control") },
++    { Qt::Key_Alt,  QT_TRANSLATE_NOOP("QShortcut", "Alt") },
++    { Qt::Key_Meta,  QT_TRANSLATE_NOOP("QShortcut", "Meta") },
+ 
+ };
+ static Q_CONSTEXPR int numKeyNames = sizeof keyname / sizeof *keyname;
+diff --git a/qtbase/src/gui/kernel/qplatformservices.cpp b/qtbase/src/gui/kernel/qplatformservices.cpp
+index fdc6a6c4aa..ac47f98c5d 100644
+--- a/qtbase/src/gui/kernel/qplatformservices.cpp
++++ b/qtbase/src/gui/kernel/qplatformservices.cpp
+@@ -55,6 +55,19 @@ QT_BEGIN_NAMESPACE
+     \brief The QPlatformServices provides the backend for desktop-related functionality.
+ */
+ 
++/*!
++    \enum QPlatformServices::Capability
++
++    Capabilities are used to determine a specific platform service's availability.
++
++    \value ColorPickingFromScreen The platform natively supports color picking from screen.
++    This capability indicates that the platform supports "opaque" color picking, where the
++    platform implements a complete user experience for color picking and outputs a color.
++    This is in contrast to the application implementing the color picking user experience
++    (taking care of showing a cross hair, instructing the platform integration to obtain
++    the color at a given pixel, etc.). The related service function is pickColor().
++ */
++
+ QPlatformServices::QPlatformServices()
+ { }
+ 
+@@ -85,5 +98,16 @@ QByteArray QPlatformServices::desktopEnvironment() const
+     return QByteArray("UNKNOWN");
+ }
+ 
++QPlatformServiceColorPicker *QPlatformServices::colorPicker(QWindow *parent)
++{
++    Q_UNUSED(parent);
++    return nullptr;
++}
++
++bool QPlatformServices::hasCapability(Capability capability) const
++{
++    Q_UNUSED(capability)
++    return false;
++}
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/gui/kernel/qplatformservices.h b/qtbase/src/gui/kernel/qplatformservices.h
+index 5de96cfa7d..a8b2a4ce71 100644
+--- a/qtbase/src/gui/kernel/qplatformservices.h
++++ b/qtbase/src/gui/kernel/qplatformservices.h
+@@ -50,16 +50,32 @@
+ //
+ 
+ #include <QtGui/qtguiglobal.h>
++#include <QtCore/qobject.h>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+ class QUrl;
++class QWindow;
++
++class Q_GUI_EXPORT QPlatformServiceColorPicker : public QObject
++{
++    Q_OBJECT
++public:
++    using QObject::QObject;
++    virtual void pickColor() = 0;
++Q_SIGNALS:
++    void colorPicked(const QColor &color);
++};
+ 
+ class Q_GUI_EXPORT QPlatformServices
+ {
+ public:
+     Q_DISABLE_COPY_MOVE(QPlatformServices)
+ 
++    enum Capability {
++        ColorPicking,
++    };
++
+     QPlatformServices();
+     virtual ~QPlatformServices() { }
+ 
+@@ -67,6 +83,10 @@ public:
+     virtual bool openDocument(const QUrl &url);
+ 
+     virtual QByteArray desktopEnvironment() const;
++
++    virtual bool hasCapability(Capability capability) const;
++
++    virtual QPlatformServiceColorPicker *colorPicker(QWindow *parent = nullptr);
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/gui/kernel/qplatformtheme.cpp b/qtbase/src/gui/kernel/qplatformtheme.cpp
+index 71521c0339..2325873245 100644
+--- a/qtbase/src/gui/kernel/qplatformtheme.cpp
++++ b/qtbase/src/gui/kernel/qplatformtheme.cpp
+@@ -163,6 +163,8 @@ QT_BEGIN_NAMESPACE
+ 
+     \value ShowShortcutsInContextMenus (bool) Whether to display shortcut key sequences in context menus.
+ 
++    \value ButtonPressKeys (QList<Qt::Key>) A list of keys that can be used to press buttons via keyboard input.
++
+     \sa themeHint(), QStyle::pixelMetric()
+ */
+ 
+@@ -563,6 +565,8 @@ QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint)
+         }
+     case MouseQuickSelectionThreshold:
+         return QVariant(10);
++    case ButtonPressKeys:
++        return QVariant::fromValue(QList<Qt::Key>({ Qt::Key_Space, Qt::Key_Select }));
+     }
+     return QVariant();
+ }
+diff --git a/qtbase/src/gui/kernel/qplatformtheme.h b/qtbase/src/gui/kernel/qplatformtheme.h
+index 3185fc4541..7e6c9d5740 100644
+--- a/qtbase/src/gui/kernel/qplatformtheme.h
++++ b/qtbase/src/gui/kernel/qplatformtheme.h
+@@ -120,7 +120,8 @@ public:
+         TouchDoubleTapDistance,
+         ShowShortcutsInContextMenus,
+         IconFallbackSearchPaths,
+-        MouseQuickSelectionThreshold
++        MouseQuickSelectionThreshold,
++        ButtonPressKeys
+     };
+ 
+     enum DialogType {
+diff --git a/qtbase/src/gui/kernel/qscreen.cpp b/qtbase/src/gui/kernel/qscreen.cpp
+index 8e0eb35116..5d172a58dd 100644
+--- a/qtbase/src/gui/kernel/qscreen.cpp
++++ b/qtbase/src/gui/kernel/qscreen.cpp
+@@ -77,6 +77,12 @@ QScreen::QScreen(QPlatformScreen *screen)
+     d->setPlatformScreen(screen);
+ }
+ 
++void QScreenPrivate::updateLogicalDpi()
++{
++    logicalDpi = QPlatformScreen::overrideDpi(platformScreen->logicalDpi());
++    updateGeometriesWithSignals(); // updates geometries based on scale factor
++}
++
+ void QScreenPrivate::updateGeometriesWithSignals()
+ {
+     const QRect oldGeometry = geometry;
+diff --git a/qtbase/src/gui/kernel/qscreen_p.h b/qtbase/src/gui/kernel/qscreen_p.h
+index 7da542c25e..e50fc3190b 100644
+--- a/qtbase/src/gui/kernel/qscreen_p.h
++++ b/qtbase/src/gui/kernel/qscreen_p.h
+@@ -70,6 +70,7 @@ public:
+         geometry = platformScreen->deviceIndependentGeometry();
+         availableGeometry = QHighDpi::fromNative(platformScreen->availableGeometry(), QHighDpiScaling::factor(platformScreen), geometry.topLeft());
+     }
++    void updateLogicalDpi();
+ 
+     void updatePrimaryOrientation();
+     void updateGeometriesWithSignals();
+diff --git a/qtbase/src/gui/painting/qblendfunctions_p.h b/qtbase/src/gui/painting/qblendfunctions_p.h
+index 080da98ec4..6997d62b3c 100644
+--- a/qtbase/src/gui/painting/qblendfunctions_p.h
++++ b/qtbase/src/gui/painting/qblendfunctions_p.h
+@@ -246,25 +246,32 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+                                   int dudx, int dvdx, int dudy, int dvdy, int u0, int v0,
+                                   Blender blender)
+ {
+-    int fromY = qMax(qRound(topY), clip.top());
+-    int toY = qMin(qRound(bottomY), clip.top() + clip.height());
++    qint64 fromY = qMax(qRound(topY), clip.top());
++    qint64 toY = qMin(qRound(bottomY), clip.top() + clip.height());
+     if (fromY >= toY)
+         return;
+ 
+     qreal leftSlope = (bottomLeft.x - topLeft.x) / (bottomLeft.y - topLeft.y);
+     qreal rightSlope = (bottomRight.x - topRight.x) / (bottomRight.y - topRight.y);
+-    int dx_l = int(leftSlope * 0x10000);
+-    int dx_r = int(rightSlope * 0x10000);
+-    int x_l = int((topLeft.x + (qreal(0.5) + fromY - topLeft.y) * leftSlope + qreal(0.5)) * 0x10000);
+-    int x_r = int((topRight.x + (qreal(0.5) + fromY - topRight.y) * rightSlope + qreal(0.5)) * 0x10000);
+-
+-    int fromX, toX, x1, x2, u, v, i, ii;
++    qint64 dx_l = qint64(leftSlope * 0x10000);
++    qint64 dx_r = qint64(rightSlope * 0x10000);
++    qint64 x_l = qint64((topLeft.x + (qreal(0.5) + fromY - topLeft.y) * leftSlope + qreal(0.5)) * 0x10000);
++    qint64 x_r = qint64((topRight.x + (qreal(0.5) + fromY - topRight.y) * rightSlope + qreal(0.5)) * 0x10000);
++
++    qint64 sourceRectTop = qint64(sourceRect.top());
++    qint64 sourceRectLeft = qint64(sourceRect.left());
++    qint64 sourceRectWidth = qint64(sourceRect.width());
++    qint64 sourceRectHeight = qint64(sourceRect.height());
++    qint64 clipLeft = qint64(clip.left());
++    qint64 clipWidth = qint64(clip.width());
++
++    qint64 fromX, toX, x1, x2, u, v, i, ii;
+     DestT *line;
+-    for (int y = fromY; y < toY; ++y) {
++    for (qint64 y = fromY; y < toY; ++y) {
+         line = reinterpret_cast<DestT *>(reinterpret_cast<uchar *>(destPixels) + y * dbpl);
+ 
+-        fromX = qMax(x_l >> 16, clip.left());
+-        toX = qMin(x_r >> 16, clip.left() + clip.width());
++        fromX = qMax(x_l >> 16, clipLeft);
++        toX = qMin(x_r >> 16, clipLeft + clipWidth);
+         if (fromX < toX) {
+             // Because of rounding, we can get source coordinates outside the source image.
+             // Clamp these coordinates to the source rect to avoid segmentation fault and
+@@ -275,10 +282,10 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             u = x1 * dudx + y * dudy + u0;
+             v = x1 * dvdx + y * dvdy + v0;
+             for (; x1 < toX; ++x1) {
+-                int uu = u >> 16;
+-                int vv = v >> 16;
+-                if (uu >= sourceRect.left() && uu < sourceRect.left() + sourceRect.width()
+-                    && vv >= sourceRect.top() && vv < sourceRect.top() + sourceRect.height()) {
++                qint64 uu = u >> 16;
++                qint64 vv = v >> 16;
++                if (uu >= sourceRectLeft && uu < sourceRectLeft + sourceRectWidth
++                    && vv >= sourceRectTop && vv < sourceRectTop + sourceRectHeight) {
+                     break;
+                 }
+                 u += dudx;
+@@ -290,10 +297,10 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             u = (x2 - 1) * dudx + y * dudy + u0;
+             v = (x2 - 1) * dvdx + y * dvdy + v0;
+             for (; x2 > x1; --x2) {
+-                int uu = u >> 16;
+-                int vv = v >> 16;
+-                if (uu >= sourceRect.left() && uu < sourceRect.left() + sourceRect.width()
+-                    && vv >= sourceRect.top() && vv < sourceRect.top() + sourceRect.height()) {
++                qint64 uu = u >> 16;
++                qint64 vv = v >> 16;
++                if (uu >= sourceRectLeft && uu < sourceRectLeft + sourceRectWidth
++                    && vv >= sourceRectTop && vv < sourceRectTop + sourceRectHeight) {
+                     break;
+                 }
+                 u -= dudx;
+@@ -308,8 +315,8 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             // Beginning of the scan line, with per-pixel checks.
+             i = x1 - fromX;
+             while (i) {
+-                int uu = qBound(sourceRect.left(), u >> 16, sourceRect.left() + sourceRect.width() - 1);
+-                int vv = qBound(sourceRect.top(), v >> 16, sourceRect.top() + sourceRect.height() - 1);
++                qint64 uu = qBound(sourceRectLeft, u >> 16, sourceRectLeft + sourceRectWidth - 1);
++                qint64 vv = qBound(sourceRectTop, v >> 16, sourceRectTop + sourceRectHeight - 1);
+                 blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + vv * sbpl)[uu]);
+                 u += dudx;
+                 v += dvdx;
+@@ -348,8 +355,8 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             // End of the scan line, with per-pixel checks.
+             i = toX - x2;
+             while (i) {
+-                int uu = qBound(sourceRect.left(), u >> 16, sourceRect.left() + sourceRect.width() - 1);
+-                int vv = qBound(sourceRect.top(), v >> 16, sourceRect.top() + sourceRect.height() - 1);
++                qint64 uu = qBound(sourceRectLeft, u >> 16, sourceRectLeft + sourceRectWidth - 1);
++                qint64 vv = qBound(sourceRectTop, v >> 16, sourceRectTop + sourceRectHeight - 1);
+                 blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + vv * sbpl)[uu]);
+                 u += dudx;
+                 v += dvdx;
+diff --git a/qtbase/src/gui/painting/qcolortrclut_p.h b/qtbase/src/gui/painting/qcolortrclut_p.h
+index 76a6a60803..24fd522e6c 100644
+--- a/qtbase/src/gui/painting/qcolortrclut_p.h
++++ b/qtbase/src/gui/painting/qcolortrclut_p.h
+@@ -118,6 +118,7 @@ public:
+         return QRgba64::fromRgba64(r, g, b, qAlpha(rgb32) * 257);
+ #endif
+     }
++    QRgba64 toLinear64(QRgba64) const = delete;
+ 
+     QRgb toLinear(QRgb rgb32) const
+     {
+diff --git a/qtbase/src/gui/painting/qdrawhelper.cpp b/qtbase/src/gui/painting/qdrawhelper.cpp
+index a61793508a..5ba2d277b7 100644
+--- a/qtbase/src/gui/painting/qdrawhelper.cpp
++++ b/qtbase/src/gui/painting/qdrawhelper.cpp
+@@ -6091,7 +6091,7 @@ static inline void alphargbblend_argb32(quint32 *dst, uint coverage, const QRgba
+ static inline void rgbBlendPixel(QRgba64 &dst, int coverage, QRgba64 slinear, const QColorTrcLut *colorProfile)
+ {
+     // Do a gammacorrected RGB alphablend...
+-    const QRgba64 dlinear = colorProfile ? colorProfile->toLinear64(dst) : dst;
++    const QRgba64 dlinear = colorProfile ? colorProfile->toLinear(dst) : dst;
+ 
+     QRgba64 blend = rgbBlend(dlinear, slinear, coverage);
+ 
+diff --git a/qtbase/src/gui/painting/qpaintengine_raster.cpp b/qtbase/src/gui/painting/qpaintengine_raster.cpp
+index 283923de52..f08eb9cbee 100644
+--- a/qtbase/src/gui/painting/qpaintengine_raster.cpp
++++ b/qtbase/src/gui/painting/qpaintengine_raster.cpp
+@@ -560,31 +560,6 @@ void QRasterPaintEngine::updateMatrix(const QTransform &matrix)
+     QRasterPaintEngineState *s = state();
+     // FALCON: get rid of this line, see drawImage call below.
+     s->matrix = matrix;
+-    QTransform::TransformationType txop = s->matrix.type();
+-
+-    switch (txop) {
+-
+-    case QTransform::TxNone:
+-        s->flags.int_xform = true;
+-        break;
+-
+-    case QTransform::TxTranslate:
+-        s->flags.int_xform = qreal(int(s->matrix.dx())) == s->matrix.dx()
+-                            && qreal(int(s->matrix.dy())) == s->matrix.dy();
+-        break;
+-
+-    case QTransform::TxScale:
+-        s->flags.int_xform = qreal(int(s->matrix.dx())) == s->matrix.dx()
+-                            && qreal(int(s->matrix.dy())) == s->matrix.dy()
+-                            && qreal(int(s->matrix.m11())) == s->matrix.m11()
+-                            && qreal(int(s->matrix.m22())) == s->matrix.m22();
+-        break;
+-
+-    default: // shear / perspective...
+-        s->flags.int_xform = false;
+-        break;
+-    }
+-
+     s->flags.tx_noshear = qt_scaleForTransform(s->matrix, &s->txscale);
+ 
+     ensureOutlineMapper();
+@@ -617,7 +592,6 @@ QRasterPaintEngineState::QRasterPaintEngineState()
+     flags.bilinear = false;
+     flags.legacy_rounding = false;
+     flags.fast_text = true;
+-    flags.int_xform = true;
+     flags.tx_noshear = true;
+     flags.fast_images = true;
+ 
+@@ -1793,7 +1767,7 @@ void QRasterPaintEngine::fill(const QVectorPath &path, const QBrush &brush)
+     QRectF cpRect = path.controlPointRect();
+     const QRectF pathDeviceRect = s->matrix.mapRect(cpRect);
+     // Skip paths that by conservative estimates are completely outside the paint device.
+-    if (!pathDeviceRect.intersects(QRectF(d->deviceRect)))
++    if (!pathDeviceRect.intersects(QRectF(d->deviceRect)) || !pathDeviceRect.isValid())
+         return;
+ 
+     ProcessSpans blend = d->getBrushFunc(pathDeviceRect, &s->brushData);
+diff --git a/qtbase/src/gui/painting/qpaintengine_raster_p.h b/qtbase/src/gui/painting/qpaintengine_raster_p.h
+index 089aadc3f7..bf7363d5aa 100644
+--- a/qtbase/src/gui/painting/qpaintengine_raster_p.h
++++ b/qtbase/src/gui/painting/qpaintengine_raster_p.h
+@@ -111,7 +111,6 @@ public:
+         uint bilinear : 1;
+         uint legacy_rounding : 1;
+         uint fast_text : 1;
+-        uint int_xform : 1;
+         uint tx_noshear : 1;
+         uint fast_images : 1;
+     };
+diff --git a/qtbase/src/gui/painting/qpainterpath.cpp b/qtbase/src/gui/painting/qpainterpath.cpp
+index f9544a3241..d80fafeaf1 100644
+--- a/qtbase/src/gui/painting/qpainterpath.cpp
++++ b/qtbase/src/gui/painting/qpainterpath.cpp
+@@ -1253,7 +1253,7 @@ void QPainterPath::addText(const QPointF &point, const QFont &f, const QString &
+ 
+         if (si.analysis.flags < QScriptAnalysis::TabOrObject) {
+             QGlyphLayout glyphs = eng->shapedGlyphs(&si);
+-            QFontEngine *fe = f.d->engineForScript(si.analysis.script);
++            QFontEngine *fe = eng->fontEngine(si);
+             Q_ASSERT(fe);
+             fe->addOutlineToPath(x, y, glyphs, this,
+                                  si.analysis.bidiLevel % 2
+diff --git a/qtbase/src/gui/painting/qpathclipper_p.h b/qtbase/src/gui/painting/qpathclipper_p.h
+index 9444a87b71..18f64c5e8c 100644
+--- a/qtbase/src/gui/painting/qpathclipper_p.h
++++ b/qtbase/src/gui/painting/qpathclipper_p.h
+@@ -156,7 +156,7 @@ public:
+     int vertex(Direction direction) const;
+ 
+ private:
+-    int m_next[2][2];
++    int m_next[2][2] = { { -1, -1 }, { -1, -1 } };
+ };
+ 
+ class QPathSegments
+@@ -296,10 +296,6 @@ inline QPathEdge::QPathEdge(int a, int b)
+     , angle(0)
+     , invAngle(0)
+ {
+-    m_next[0][0] = -1;
+-    m_next[1][0] = -1;
+-    m_next[0][0] = -1;
+-    m_next[1][0] = -1;
+ }
+ 
+ inline int QPathEdge::next(Traversal traversal, Direction direction) const
+diff --git a/qtbase/src/gui/painting/qpdf.cpp b/qtbase/src/gui/painting/qpdf.cpp
+index 3066744f1b..2c8d3c3b53 100644
+--- a/qtbase/src/gui/painting/qpdf.cpp
++++ b/qtbase/src/gui/painting/qpdf.cpp
+@@ -2760,6 +2760,8 @@ int QPdfEnginePrivate::addBrushPattern(const QTransform &m, bool *specifyColor,
+         return gradientBrush(brush, matrix, gStateObject);
+     }
+ 
++    matrix = brush.transform() * matrix;
++
+     if ((!brush.isOpaque() && brush.style() < Qt::LinearGradientPattern) || opacity != 1.0)
+         *gStateObject = addConstantAlphaObject(qRound(brush.color().alpha() * opacity),
+                                                qRound(pen.color().alpha() * opacity));
+diff --git a/qtbase/src/gui/painting/qstroker.cpp b/qtbase/src/gui/painting/qstroker.cpp
+index cb5d395e80..3b6357a893 100644
+--- a/qtbase/src/gui/painting/qstroker.cpp
++++ b/qtbase/src/gui/painting/qstroker.cpp
+@@ -1182,6 +1182,7 @@ void QDashStroker::processCurrentSubpath()
+         // Check if the entire line should be clipped away or simplified
+         bool clipIt = clipping && !lineIntersectsRect(prev, e, clip_tl, clip_br);
+         bool skipDashing = elen * invSumLength > repetitionLimit();
++        int maxDashes = dashCount;
+         if (skipDashing || clipIt) {
+             // Cut away full dash sequences.
+             elen -= std::floor(elen * invSumLength) * sumLength;
+@@ -1196,7 +1197,7 @@ void QDashStroker::processCurrentSubpath()
+                     pos = estop; // move pos to next path element
+                     done = true;
+                 } else { // Dash is on this line
+-                    pos = dpos + estart;
++                    pos = --maxDashes > 0 ? dpos + estart : estop;
+                     done = pos >= estop;
+                     if (++idash >= dashCount)
+                         idash = 0;
+diff --git a/qtbase/src/gui/painting/qt_attribution.json b/qtbase/src/gui/painting/qt_attribution.json
+index 7b16e8c211..0e87d30aa2 100644
+--- a/qtbase/src/gui/painting/qt_attribution.json
++++ b/qtbase/src/gui/painting/qt_attribution.json
+@@ -10,7 +10,7 @@
+         "Homepage": "http://www.freetype.org",
+         "License": "Freetype Project License or GNU General Public License v2.0 only",
+         "LicenseId": "FTL or GPL-2.0",
+-        "LicenseFile": "../../3rdparty/freetype/docs/LICENSE.TXT",
++        "LicenseFile": "../../3rdparty/freetype/LICENSE.TXT",
+         "Copyright": "Copyright 2000-2016 by David Turner, Robert Wilhelm, and Werner Lemberg."
+     },
+     {
+diff --git a/qtbase/src/gui/rhi/qshader_p_p.h b/qtbase/src/gui/rhi/qshader_p_p.h
+index ec9d25971f..4a5a7a6d51 100644
+--- a/qtbase/src/gui/rhi/qshader_p_p.h
++++ b/qtbase/src/gui/rhi/qshader_p_p.h
+@@ -68,13 +68,13 @@ struct Q_GUI_EXPORT QShaderPrivate
+     {
+     }
+ 
+-    QShaderPrivate(const QShaderPrivate *other)
++    QShaderPrivate(const QShaderPrivate &other)
+         : ref(1),
+-          qsbVersion(other->qsbVersion),
+-          stage(other->stage),
+-          desc(other->desc),
+-          shaders(other->shaders),
+-          bindings(other->bindings)
++          qsbVersion(other.qsbVersion),
++          stage(other.stage),
++          desc(other.desc),
++          shaders(other.shaders),
++          bindings(other.bindings)
+     {
+     }
+ 
+diff --git a/qtbase/src/gui/rhi/qshaderdescription_p_p.h b/qtbase/src/gui/rhi/qshaderdescription_p_p.h
+index ec2b0b6b4c..3da33a8a2b 100644
+--- a/qtbase/src/gui/rhi/qshaderdescription_p_p.h
++++ b/qtbase/src/gui/rhi/qshaderdescription_p_p.h
+@@ -63,16 +63,16 @@ struct Q_GUI_EXPORT QShaderDescriptionPrivate
+         localSize[0] = localSize[1] = localSize[2] = 0;
+     }
+ 
+-    QShaderDescriptionPrivate(const QShaderDescriptionPrivate *other)
++    QShaderDescriptionPrivate(const QShaderDescriptionPrivate &other)
+         : ref(1),
+-          inVars(other->inVars),
+-          outVars(other->outVars),
+-          uniformBlocks(other->uniformBlocks),
+-          pushConstantBlocks(other->pushConstantBlocks),
+-          storageBlocks(other->storageBlocks),
+-          combinedImageSamplers(other->combinedImageSamplers),
+-          storageImages(other->storageImages),
+-          localSize(other->localSize)
++          inVars(other.inVars),
++          outVars(other.outVars),
++          uniformBlocks(other.uniformBlocks),
++          pushConstantBlocks(other.pushConstantBlocks),
++          storageBlocks(other.storageBlocks),
++          combinedImageSamplers(other.combinedImageSamplers),
++          storageImages(other.storageImages),
++          localSize(other.localSize)
+     {
+     }
+ 
+diff --git a/qtbase/src/gui/text/qfontdatabase.cpp b/qtbase/src/gui/text/qfontdatabase.cpp
+index a657a8c516..4fc0100958 100644
+--- a/qtbase/src/gui/text/qfontdatabase.cpp
++++ b/qtbase/src/gui/text/qfontdatabase.cpp
+@@ -983,7 +983,7 @@ QFontEngine *loadSingleEngine(int script,
+         if (style->key.stretch != 0 && request.stretch != 0
+             && (request.styleName.isEmpty() || request.styleName != style->styleName)) {
+             def.stretch = (request.stretch * 100 + style->key.stretch / 2) / style->key.stretch;
+-        } else {
++        } else if (request.stretch == QFont::AnyStretch) {
+             def.stretch = 100;
+         }
+ 
+diff --git a/qtbase/src/gui/text/qtextdocumentlayout.cpp b/qtbase/src/gui/text/qtextdocumentlayout.cpp
+index f3e6ea2100..72267e9380 100644
+--- a/qtbase/src/gui/text/qtextdocumentlayout.cpp
++++ b/qtbase/src/gui/text/qtextdocumentlayout.cpp
+@@ -2123,7 +2123,7 @@ void QTextDocumentLayoutPrivate::drawListItem(const QPointF &offset, QPainter *p
+ {
+     Q_Q(const QTextDocumentLayout);
+     const QTextBlockFormat blockFormat = bl.blockFormat();
+-    const QTextCharFormat charFormat = QTextCursor(bl).charFormat();
++    const QTextCharFormat charFormat = bl.charFormat();
+     QFont font(charFormat.font());
+     if (q->paintDevice())
+         font = QFont(font, q->paintDevice());
+diff --git a/qtbase/src/gui/text/qtextengine.cpp b/qtbase/src/gui/text/qtextengine.cpp
+index ce4abac472..a6c66e5d2d 100644
+--- a/qtbase/src/gui/text/qtextengine.cpp
++++ b/qtbase/src/gui/text/qtextengine.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2021 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtGui module of the Qt Toolkit.
+@@ -1565,6 +1565,12 @@ void QTextEngine::shapeText(int item) const
+         // Overwrite with 0 token to indicate failure
+         QGlyphLayout g = availableGlyphs(&si);
+         g.glyphs[0] = 0;
++        g.attributes[0].clusterStart = true;
++
++        ushort *log_clusters = logClusters(&si);
++        for (int i = 0; i < itemLength; ++i)
++            log_clusters[i] = 0;
++
+         return;
+     }
+ 
+diff --git a/qtbase/src/gui/util/qdesktopservices.cpp b/qtbase/src/gui/util/qdesktopservices.cpp
+index fbb63a9408..4d5fafaaa7 100644
+--- a/qtbase/src/gui/util/qdesktopservices.cpp
++++ b/qtbase/src/gui/util/qdesktopservices.cpp
+@@ -54,6 +54,8 @@
+ #include <qpa/qplatformintegration.h>
+ #include <qdir.h>
+ 
++#include <QtCore/private/qlocking_p.h>
++
+ QT_BEGIN_NAMESPACE
+ 
+ class QOpenUrlHandlerRegistry : public QObject
+@@ -81,6 +83,7 @@ Q_GLOBAL_STATIC(QOpenUrlHandlerRegistry, handlerRegistry)
+ 
+ void QOpenUrlHandlerRegistry::handlerDestroyed(QObject *handler)
+ {
++    const auto lock = qt_scoped_lock(mutex);
+     HandlerHash::Iterator it = handlers.begin();
+     while (it != handlers.end()) {
+         if (it->receiver == handler) {
+@@ -294,7 +297,8 @@ void QDesktopServices::setUrlHandler(const QString &scheme, QObject *receiver, c
+     h.name = method;
+     registry->handlers.insert(scheme.toLower(), h);
+     QObject::connect(receiver, SIGNAL(destroyed(QObject*)),
+-                     registry, SLOT(handlerDestroyed(QObject*)));
++                     registry, SLOT(handlerDestroyed(QObject*)),
++                     Qt::DirectConnection);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/gui/util/qpkmhandler.cpp b/qtbase/src/gui/util/qpkmhandler.cpp
+index e0c3b75efe..3414f9d8ba 100644
+--- a/qtbase/src/gui/util/qpkmhandler.cpp
++++ b/qtbase/src/gui/util/qpkmhandler.cpp
+@@ -57,7 +57,7 @@ struct PkmType
+     quint32 bytesPerBlock;
+ };
+ 
+-static PkmType typeMap[5] = {
++static constexpr PkmType typeMap[5] = {
+     { 0x8D64,  8 },   // GL_ETC1_RGB8_OES
+     { 0x9274,  8 },   // GL_COMPRESSED_RGB8_ETC2
+     { 0, 0 },         // unused (obsolete)
+diff --git a/qtbase/src/network/access/qnetworkreplyfileimpl.cpp b/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
+index b6be93147a..6e69b4c4d3 100644
+--- a/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
++++ b/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
+@@ -89,9 +89,10 @@ QNetworkReplyFileImpl::QNetworkReplyFileImpl(QNetworkAccessManager *manager, con
+         // we handle only local files
+         QString msg = QCoreApplication::translate("QNetworkAccessFileBackend", "Request for opening non-local file %1").arg(url.toString());
+         setError(QNetworkReply::ProtocolInvalidOperationError, msg);
++        setFinished(true); // We're finished, will emit finished() after ctor is done.
+         QMetaObject::invokeMethod(this, "errorOccurred", Qt::QueuedConnection,
+             Q_ARG(QNetworkReply::NetworkError, QNetworkReply::ProtocolInvalidOperationError));
+-        fileOpenFinished(false);
++        QMetaObject::invokeMethod(this, [this](){ fileOpenFinished(false); }, Qt::QueuedConnection);
+         return;
+     }
+ #endif
+diff --git a/qtbase/src/network/access/qnetworkreplyimpl.cpp b/qtbase/src/network/access/qnetworkreplyimpl.cpp
+index bcdf6ee2f1..3b6deb82bd 100644
+--- a/qtbase/src/network/access/qnetworkreplyimpl.cpp
++++ b/qtbase/src/network/access/qnetworkreplyimpl.cpp
+@@ -680,7 +680,7 @@ void QNetworkReplyImplPrivate::appendDownstreamData(QIODevice *data)
+     // read until EOF from data
+     if (Q_UNLIKELY(copyDevice)) {
+         qCritical("QNetworkReplyImpl: copy from QIODevice already in progress -- "
+-                  "backend probly needs to be fixed");
++                  "backend probably needs to be fixed");
+         return;
+     }
+ 
+diff --git a/qtbase/src/network/kernel/qauthenticator.cpp b/qtbase/src/network/kernel/qauthenticator.cpp
+index d9fe7bc47b..ccd04b294a 100644
+--- a/qtbase/src/network/kernel/qauthenticator.cpp
++++ b/qtbase/src/network/kernel/qauthenticator.cpp
+@@ -50,6 +50,7 @@
+ #include <qstring.h>
+ #include <qdatetime.h>
+ #include <qrandom.h>
++#include "private/qsystemlibrary_p.h"
+ 
+ #ifdef Q_OS_WIN
+ #include <qmutex.h>
+@@ -1563,7 +1564,7 @@ static bool q_SSPI_library_load()
+ 
+     // Initialize security interface
+     if (pSecurityFunctionTable == nullptr) {
+-        securityDLLHandle = LoadLibrary(L"secur32.dll");
++        securityDLLHandle = QSystemLibrary::load(L"secur32");
+         if (securityDLLHandle != nullptr) {
+             INIT_SECURITY_INTERFACE pInitSecurityInterface =
+                 reinterpret_cast<INIT_SECURITY_INTERFACE>(
+diff --git a/qtbase/src/network/kernel/qhostinfo_unix.cpp b/qtbase/src/network/kernel/qhostinfo_unix.cpp
+index 9b0a2ee669..73679c9ef1 100644
+--- a/qtbase/src/network/kernel/qhostinfo_unix.cpp
++++ b/qtbase/src/network/kernel/qhostinfo_unix.cpp
+@@ -122,7 +122,6 @@ static QFunctionPointer resolveSymbol(QLibrary &lib, const char *sym)
+ 
+ LibResolv::LibResolv()
+ {
+-    QLibrary lib;
+ #ifdef LIBRESOLV_SO
+     lib.setFileName(QStringLiteral(LIBRESOLV_SO));
+     if (!lib.load())
+diff --git a/qtbase/src/network/socket/qsocks5socketengine.cpp b/qtbase/src/network/socket/qsocks5socketengine.cpp
+index 3a046fd116..97fadca0b3 100644
+--- a/qtbase/src/network/socket/qsocks5socketengine.cpp
++++ b/qtbase/src/network/socket/qsocks5socketengine.cpp
+@@ -1296,7 +1296,7 @@ void QSocks5SocketEnginePrivate::_q_udpSocketReadNotification()
+         int pos = 0;
+         const char *buf = inBuf.constData();
+         if (inBuf.size() < 4) {
+-            QSOCKS5_D_DEBUG << "bugus udp data, discarding";
++            QSOCKS5_D_DEBUG << "bogus udp data, discarding";
+             return;
+         }
+         QSocks5RevivedDatagram datagram;
+diff --git a/qtbase/src/network/ssl/qsslcontext_openssl.cpp b/qtbase/src/network/ssl/qsslcontext_openssl.cpp
+index c9f202f573..c992da9d8e 100644
+--- a/qtbase/src/network/ssl/qsslcontext_openssl.cpp
++++ b/qtbase/src/network/ssl/qsslcontext_openssl.cpp
+@@ -409,7 +409,7 @@ init_context:
+         break;
+     case QSsl::DtlsV1_0OrLater:
+         minVersion = DTLS1_VERSION;
+-        maxVersion = DTLS_MAX_VERSION;
++        maxVersion = 0;
+         break;
+     case QSsl::DtlsV1_2:
+         minVersion = DTLS1_2_VERSION;
+@@ -417,7 +417,7 @@ init_context:
+         break;
+     case QSsl::DtlsV1_2OrLater:
+         minVersion = DTLS1_2_VERSION;
+-        maxVersion = DTLS_MAX_VERSION;
++        maxVersion = 0;
+         break;
+     case QSsl::TlsV1_3OrLater:
+ #ifdef TLS1_3_VERSION
+@@ -455,7 +455,7 @@ init_context:
+     }
+ 
+     // Enable bug workarounds.
+-    long options = QSslSocketBackendPrivate::setupOpenSslOptions(configuration.protocol(), configuration.d->sslOptions);
++    qssloptions options = QSslSocketBackendPrivate::setupOpenSslOptions(configuration.protocol(), configuration.d->sslOptions);
+     q_SSL_CTX_set_options(sslContext->ctx, options);
+ 
+     // Tell OpenSSL to release memory early
+diff --git a/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp b/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
+index aaf8741130..b58935372c 100644
+--- a/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
++++ b/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
+@@ -59,57 +59,6 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-#ifdef OPENSSL_NO_DEPRECATED_3_0
+-
+-static int q_DH_check(DH *dh, int *status)
+-{
+-    // DH_check was first deprecated in OpenSSL 3.0.0, as low-level
+-    // API; the EVP_PKEY family of functions was advised as an alternative.
+-    // As of now EVP_PKEY_params_check ends up calling ... DH_check,
+-    // which is good enough.
+-
+-    Q_ASSERT(dh);
+-    Q_ASSERT(status);
+-
+-    EVP_PKEY *key = q_EVP_PKEY_new();
+-    if (!key) {
+-        qCWarning(lcSsl, "EVP_PKEY_new failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-    const auto keyDeleter = qScopeGuard([key](){
+-        q_EVP_PKEY_free(key);
+-    });
+-    if (!q_EVP_PKEY_set1_DH(key, dh)) {
+-        qCWarning(lcSsl, "EVP_PKEY_set1_DH failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-
+-    EVP_PKEY_CTX *keyCtx = q_EVP_PKEY_CTX_new(key, nullptr);
+-    if (!keyCtx) {
+-        qCWarning(lcSsl, "EVP_PKEY_CTX_new failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-    const auto ctxDeleter = qScopeGuard([keyCtx]{
+-        q_EVP_PKEY_CTX_free(keyCtx);
+-    });
+-
+-    const int result = q_EVP_PKEY_param_check(keyCtx);
+-    QSslSocketBackendPrivate::logAndClearErrorQueue();
+-    // Note: unlike DH_check, we cannot obtain the 'status',
+-    // if the 'result' is 0 (actually the result is 1 only
+-    // if this 'status' was 0). We could probably check the
+-    // errors from the error queue, but it's not needed anyway
+-    // - see the 'isSafeDH' below, how it returns immediately
+-    // on 0.
+-    Q_UNUSED(status)
+-
+-    return result;
+-}
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+-
+ static bool isSafeDH(DH *dh)
+ {
+     int status = 0;
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl.cpp b/qtbase/src/network/ssl/qsslsocket_openssl.cpp
+index 37fad2a68f..8f6858c867 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl.cpp
++++ b/qtbase/src/network/ssl/qsslsocket_openssl.cpp
+@@ -550,9 +550,9 @@ static void q_loadCiphersForConnection(SSL *connection, QList<QSslCipher> &ciphe
+ // Defined in qsslsocket.cpp
+ void q_setDefaultDtlsCiphers(const QList<QSslCipher> &ciphers);
+ 
+-long QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions)
++qssloptions QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions)
+ {
+-    long options;
++    qssloptions options;
+     if (protocol == QSsl::TlsV1SslV3)
+         options = SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3;
+     else if (protocol == QSsl::SecureProtocols)
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_p.h b/qtbase/src/network/ssl/qsslsocket_openssl_p.h
+index 4103de23e8..5547589256 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_p.h
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_p.h
+@@ -107,6 +107,12 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++typedef uint64_t qssloptions;
++#else
++typedef unsigned long qssloptions;
++#endif
++
+ struct QSslErrorEntry {
+     int code;
+     int depth;
+@@ -171,7 +177,7 @@ public:
+     QVector<QSslError> ocspErrors;
+     QByteArray ocspResponseDer;
+ 
+-    Q_AUTOTEST_EXPORT static long setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions);
++    Q_AUTOTEST_EXPORT static qssloptions setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions);
+     static QSslCipher QSslCipher_from_SSL_CIPHER(const SSL_CIPHER *cipher);
+     static QList<QSslCertificate> STACKOFX509_to_QSslCertificates(STACK_OF(X509) *x509);
+     static QList<QSslError> verify(const QList<QSslCertificate> &certificateChain, const QString &hostName);
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp b/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
+index e53fb279f0..459ccd0b19 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
+@@ -148,7 +148,6 @@ DEFINEFUNC(int, EVP_PKEY_up_ref, EVP_PKEY *a, a, return 0, return)
+ DEFINEFUNC2(EVP_PKEY_CTX *, EVP_PKEY_CTX_new, EVP_PKEY *pkey, pkey, ENGINE *e, e, return nullptr, return)
+ DEFINEFUNC(int, EVP_PKEY_param_check, EVP_PKEY_CTX *ctx, ctx, return 0, return)
+ DEFINEFUNC(void, EVP_PKEY_CTX_free, EVP_PKEY_CTX *ctx, ctx, return, return)
+-DEFINEFUNC(int, EVP_PKEY_base_id, EVP_PKEY *a, a, return NID_undef, return)
+ DEFINEFUNC(int, RSA_bits, RSA *a, a, return 0, return)
+ DEFINEFUNC(int, DSA_bits, DSA *a, a, return 0, return)
+ DEFINEFUNC(int, OPENSSL_sk_num, OPENSSL_STACK *a, a, return -1, return)
+@@ -158,7 +157,7 @@ DEFINEFUNC2(void, OPENSSL_sk_push, OPENSSL_STACK *a, a, void *b, b, return, DUMM
+ DEFINEFUNC(void, OPENSSL_sk_free, OPENSSL_STACK *a, a, return, DUMMYARG)
+ DEFINEFUNC2(void *, OPENSSL_sk_value, OPENSSL_STACK *a, a, int b, b, return nullptr, return)
+ DEFINEFUNC(int, SSL_session_reused, SSL *a, a, return 0, return)
+-DEFINEFUNC2(unsigned long, SSL_CTX_set_options, SSL_CTX *ctx, ctx, unsigned long op, op, return 0, return)
++DEFINEFUNC2(qssloptions, SSL_CTX_set_options, SSL_CTX *ctx, ctx, qssloptions op, op, return 0, return)
+ DEFINEFUNC(int, SSL_CTX_get_security_level, const SSL_CTX *ctx, ctx, return -1, return)
+ DEFINEFUNC2(void, SSL_CTX_set_security_level, SSL_CTX *ctx, ctx, int level, level, return, return)
+ #ifdef TLS1_3_VERSION
+@@ -371,7 +370,15 @@ DEFINEFUNC(const SSL_CIPHER *, SSL_get_current_cipher, SSL *a, a, return nullptr
+ DEFINEFUNC(int, SSL_version, const SSL *a, a, return 0, return)
+ DEFINEFUNC2(int, SSL_get_error, SSL *a, a, int b, b, return -1, return)
+ DEFINEFUNC(STACK_OF(X509) *, SSL_get_peer_cert_chain, SSL *a, a, return nullptr, return)
++
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++DEFINEFUNC(X509 *, SSL_get1_peer_certificate, SSL *a, a, return nullptr, return)
++DEFINEFUNC(int, EVP_PKEY_get_base_id, const EVP_PKEY *pkey, pkey, return -1, return)
++#else
+ DEFINEFUNC(X509 *, SSL_get_peer_certificate, SSL *a, a, return nullptr, return)
++DEFINEFUNC(int, EVP_PKEY_base_id, EVP_PKEY *a, a, return NID_undef, return)
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+ DEFINEFUNC(long, SSL_get_verify_result, const SSL *a, a, return -1, return)
+ DEFINEFUNC(SSL *, SSL_new, SSL_CTX *a, a, return nullptr, return)
+ DEFINEFUNC(SSL_CTX *, SSL_get_SSL_CTX, SSL *a, a, return nullptr, return)
+@@ -492,9 +499,7 @@ DEFINEFUNC(DH *, DH_new, DUMMYARG, DUMMYARG, return nullptr, return)
+ DEFINEFUNC(void, DH_free, DH *dh, dh, return, DUMMYARG)
+ DEFINEFUNC3(DH *, d2i_DHparams, DH**a, a, const unsigned char **pp, pp, long length, length, return nullptr, return)
+ DEFINEFUNC2(int, i2d_DHparams, DH *a, a, unsigned char **p, p, return -1, return)
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+ DEFINEFUNC2(int, DH_check, DH *dh, dh, int *codes, codes, return 0, return)
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+ DEFINEFUNC3(BIGNUM *, BN_bin2bn, const unsigned char *s, s, int len, len, BIGNUM *ret, ret, return nullptr, return)
+ 
+ #ifndef OPENSSL_NO_EC
+@@ -868,7 +873,6 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(EVP_PKEY_CTX_new)
+     RESOLVEFUNC(EVP_PKEY_param_check)
+     RESOLVEFUNC(EVP_PKEY_CTX_free)
+-    RESOLVEFUNC(EVP_PKEY_base_id)
+     RESOLVEFUNC(RSA_bits)
+     RESOLVEFUNC(OPENSSL_sk_new_null)
+     RESOLVEFUNC(OPENSSL_sk_push)
+@@ -1107,7 +1111,15 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(SSL_version)
+     RESOLVEFUNC(SSL_get_error)
+     RESOLVEFUNC(SSL_get_peer_cert_chain)
++
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++    RESOLVEFUNC(SSL_get1_peer_certificate)
++    RESOLVEFUNC(EVP_PKEY_get_base_id)
++#else
+     RESOLVEFUNC(SSL_get_peer_certificate)
++    RESOLVEFUNC(EVP_PKEY_base_id)
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+     RESOLVEFUNC(SSL_get_verify_result)
+     RESOLVEFUNC(SSL_new)
+     RESOLVEFUNC(SSL_get_SSL_CTX)
+@@ -1206,9 +1218,7 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(DH_free)
+     RESOLVEFUNC(d2i_DHparams)
+     RESOLVEFUNC(i2d_DHparams)
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+     RESOLVEFUNC(DH_check)
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+     RESOLVEFUNC(BN_bin2bn)
+ 
+ #ifndef OPENSSL_NO_EC
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h b/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
+index 95e8897a3b..27aeffa18a 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
+@@ -237,7 +237,6 @@ Q_AUTOTEST_EXPORT int q_EVP_PKEY_up_ref(EVP_PKEY *a);
+ EVP_PKEY_CTX *q_EVP_PKEY_CTX_new(EVP_PKEY *pkey, ENGINE *e);
+ void q_EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx);
+ int q_EVP_PKEY_param_check(EVP_PKEY_CTX *ctx);
+-int q_EVP_PKEY_base_id(EVP_PKEY *a);
+ int q_RSA_bits(RSA *a);
+ Q_AUTOTEST_EXPORT int q_OPENSSL_sk_num(OPENSSL_STACK *a);
+ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_pop_free(OPENSSL_STACK *a, void (*b)(void *));
+@@ -246,7 +245,7 @@ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_push(OPENSSL_STACK *st, void *data);
+ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_free(OPENSSL_STACK *a);
+ Q_AUTOTEST_EXPORT void * q_OPENSSL_sk_value(OPENSSL_STACK *a, int b);
+ int q_SSL_session_reused(SSL *a);
+-unsigned long q_SSL_CTX_set_options(SSL_CTX *ctx, unsigned long op);
++qssloptions q_SSL_CTX_set_options(SSL_CTX *ctx, qssloptions op);
+ int q_OPENSSL_init_ssl(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings);
+ size_t q_SSL_get_client_random(SSL *a, unsigned char *out, size_t outlen);
+ size_t q_SSL_SESSION_get_master_key(const SSL_SESSION *session, unsigned char *out, size_t outlen);
+@@ -510,7 +509,6 @@ const SSL_CIPHER *q_SSL_get_current_cipher(SSL *a);
+ int q_SSL_version(const SSL *a);
+ int q_SSL_get_error(SSL *a, int b);
+ STACK_OF(X509) *q_SSL_get_peer_cert_chain(SSL *a);
+-X509 *q_SSL_get_peer_certificate(SSL *a);
+ long q_SSL_get_verify_result(const SSL *a);
+ SSL *q_SSL_new(SSL_CTX *a);
+ SSL_CTX *q_SSL_get_SSL_CTX(SSL *a);
+@@ -582,10 +580,7 @@ DH *q_DH_new();
+ void q_DH_free(DH *dh);
+ DH *q_d2i_DHparams(DH **a, const unsigned char **pp, long length);
+ int q_i2d_DHparams(DH *a, unsigned char **p);
+-
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+ int q_DH_check(DH *dh, int *codes);
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+ 
+ BIGNUM *q_BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret);
+ #define q_SSL_CTX_set_tmp_dh(ctx, dh) q_SSL_CTX_ctrl((ctx), SSL_CTRL_SET_TMP_DH, 0, (char *)dh)
+@@ -754,6 +749,17 @@ void q_CRYPTO_free(void *str, const char *file, int line);
+ int q_SSL_CTX_get_security_level(const SSL_CTX *ctx);
+ void q_SSL_CTX_set_security_level(SSL_CTX *ctx, int level);
+ 
++// Here we have the ones that make difference between OpenSSL pre/post v3:
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++X509 *q_SSL_get1_peer_certificate(SSL *a);
++#define q_SSL_get_peer_certificate q_SSL_get1_peer_certificate
++int q_EVP_PKEY_get_base_id(const EVP_PKEY *pkey);
++#define q_EVP_PKEY_base_id q_EVP_PKEY_get_base_id
++#else
++X509 *q_SSL_get_peer_certificate(SSL *a);
++int q_EVP_PKEY_base_id(EVP_PKEY *a);
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+ QT_END_NAMESPACE
+ 
+ #endif
+diff --git a/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h b/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
+index bf37d07fd8..dbd42fb799 100644
+--- a/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
++++ b/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
+@@ -61,7 +61,11 @@
+ # if !defined(Q_OS_INTEGRITY)
+ #  define WIN_INTERFACE_CUSTOM   // NV
+ # endif // Q_OS_INTEGRITY
+-#endif  // QT_EGL_NO_X11
++#else // QT_EGL_NO_X11
++// If one has an eglplatform.h with https://github.com/KhronosGroup/EGL-Registry/pull/130
++// that needs USE_X11 to be defined.
++# define USE_X11
++#endif
+ 
+ #ifdef QT_EGL_WAYLAND
+ # define WAYLAND // NV
+diff --git a/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+index 159b490ce0..00aa80cd58 100644
+--- a/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
++++ b/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+@@ -567,6 +567,8 @@ void QFontconfigDatabase::populateFontDatabase()
+         fonts = FcFontList(nullptr, pattern, os);
+         FcObjectSetDestroy(os);
+         FcPatternDestroy(pattern);
++        if (!fonts)
++            return;
+     }
+ 
+     for (int i = 0; i < fonts->nfont; i++)
+diff --git a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
+index b713c19447..7cb9a8c79a 100644
+--- a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
++++ b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
+@@ -95,6 +95,7 @@ static constexpr const auto KeyTbl = qMakeArray(
+         Xkb2Qt<XKB_KEY_Clear,                   Qt::Key_Delete>,
+         Xkb2Qt<XKB_KEY_Pause,                   Qt::Key_Pause>,
+         Xkb2Qt<XKB_KEY_Print,                   Qt::Key_Print>,
++        Xkb2Qt<XKB_KEY_Sys_Req,                 Qt::Key_SysReq>,
+         Xkb2Qt<0x1005FF60,                      Qt::Key_SysReq>,         // hardcoded Sun SysReq
+         Xkb2Qt<0x1007ff00,                      Qt::Key_SysReq>,         // hardcoded X386 SysReq
+ 
+@@ -471,7 +472,7 @@ QVector<xkb_keysym_t> QXkbCommon::toKeysym(QKeyEvent *event)
+     } else if (event->modifiers() & Qt::KeypadModifier) {
+         if (qtKey >= Qt::Key_0 && qtKey <= Qt::Key_9)
+             keysyms.append(XKB_KEY_KP_0 + (qtKey - Qt::Key_0));
+-    } else if (isLatin(qtKey) && event->text().isUpper()) {
++    } else if (isLatin1(qtKey) && event->text().isUpper()) {
+         keysyms.append(qtKey);
+     }
+ 
+@@ -523,7 +524,7 @@ int QXkbCommon::keysymToQtKey(xkb_keysym_t keysym, Qt::KeyboardModifiers modifie
+         // With standard shortcuts we should prefer a latin character, this is
+         // for checks like "some qkeyevent == QKeySequence::Copy" to work even
+         // when using for example 'russian' keyboard layout.
+-        if (!QXkbCommon::isLatin(keysym)) {
++        if (!QXkbCommon::isLatin1(keysym)) {
+             xkb_keysym_t latinKeysym = QXkbCommon::lookupLatinKeysym(state, code);
+             if (latinKeysym != XKB_KEY_NoSymbol)
+                 keysym = latinKeysym;
+@@ -546,7 +547,7 @@ static int keysymToQtKey_internal(xkb_keysym_t keysym, Qt::KeyboardModifiers mod
+     } else if (keysym >= XKB_KEY_KP_0 && keysym <= XKB_KEY_KP_9) {
+         // numeric keypad keys
+         qtKey = Qt::Key_0 + (keysym - XKB_KEY_KP_0);
+-    } else if (QXkbCommon::isLatin(keysym)) {
++    } else if (QXkbCommon::isLatin1(keysym)) {
+         qtKey = QXkbCommon::qxkbcommon_xkb_keysym_to_upper(keysym);
+     } else {
+         // check if we have a direct mapping
+@@ -678,7 +679,7 @@ QList<int> QXkbCommon::possibleKeys(xkb_state *state, const QKeyEvent *event,
+         Qt::KeyboardModifiers neededMods = ModsTbl[i];
+         if ((modifiers & neededMods) == neededMods) {
+             if (i == 8) {
+-                if (isLatin(baseQtKey))
++                if (isLatin1(baseQtKey))
+                     continue;
+                 // add a latin key as a fall back key
+                 sym = lookupLatinKeysym(state, keycode);
+@@ -733,7 +734,7 @@ void QXkbCommon::verifyHasLatinLayout(xkb_keymap *keymap)
+     for (xkb_layout_index_t layout = 0; layout < layoutCount; ++layout) {
+         for (xkb_keycode_t code = minKeycode; code < maxKeycode; ++code) {
+             xkb_keymap_key_get_syms_by_level(keymap, code, layout, 0, &keysyms);
+-            if (keysyms && isLatin(keysyms[0]))
++            if (keysyms && isLatin1(keysyms[0]))
+                 nrLatinKeys++;
+             if (nrLatinKeys > 10) // arbitrarily chosen threshold
+                 return;
+@@ -766,7 +767,7 @@ xkb_keysym_t QXkbCommon::lookupLatinKeysym(xkb_state *state, xkb_keycode_t keyco
+         xkb_level_index_t level = xkb_state_key_get_level(state, keycode, layout);
+         if (xkb_keymap_key_get_syms_by_level(keymap, keycode, layout, level, &syms) != 1)
+             continue;
+-        if (isLatin(syms[0])) {
++        if (isLatin1(syms[0])) {
+             sym = syms[0];
+             break;
+         }
+diff --git a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
+index 561eae03db..8389bd8f5a 100644
+--- a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
++++ b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
+@@ -94,8 +94,8 @@ public:
+     static void verifyHasLatinLayout(xkb_keymap *keymap);
+     static xkb_keysym_t lookupLatinKeysym(xkb_state *state, xkb_keycode_t keycode);
+ 
+-    static bool isLatin(xkb_keysym_t sym) {
+-        return ((sym >= 'a' && sym <= 'z') || (sym >= 'A' && sym <= 'Z'));
++    static bool isLatin1(xkb_keysym_t sym) {
++        return sym <= 0xff;
+     }
+     static bool isKeypad(xkb_keysym_t sym) {
+         return sym >= XKB_KEY_KP_Space && sym <= XKB_KEY_KP_9;
+diff --git a/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp b/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
+index 8cd7f9b368..406f84663f 100644
+--- a/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
++++ b/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
+@@ -318,7 +318,7 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources,
+ 
+     if (current < 0 && crtc_mode.clock != 0) {
+         modes << crtc_mode;
+-        current = mode.size() - 1;
++        current = modes.size() - 1;
+     }
+ 
+     if (configuration == OutputConfigCurrent)
+diff --git a/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp b/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
+index 9153fd20bb..255ea5e33e 100644
+--- a/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
++++ b/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
+@@ -194,6 +194,9 @@ QString AtSpiAdaptor::introspect(const QString &path) const
+                 "      <arg direction=\"out\" type=\"(so)\"/>\n"
+                 "      <annotation value=\"QSpiObjectReference\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n"
+                 "    </method>\n"
++                "    <method name=\"GetAccessibleId\">\n"
++                "      <arg direction=\"out\" type=\"s\"/>\n"
++                "    </method>\n"
+                 "  </interface>\n"
+                 );
+ 
+@@ -913,8 +916,17 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+     }
+     case QAccessible::NameChanged: {
+         if (sendObject || sendObject_property_change || sendObject_property_change_accessible_name) {
+-            QString path = pathForInterface(event->accessibleInterface());
+-            QVariantList args = packDBusSignalArguments(QLatin1String("accessible-name"), 0, 0, variantForPath(path));
++            QAccessibleInterface *iface = event->accessibleInterface();
++            if (!iface) {
++                qCDebug(lcAccessibilityAtspi,
++                        "NameChanged event from invalid accessible.");
++                return;
++            }
++
++            QString path = pathForInterface(iface);
++            QVariantList args = packDBusSignalArguments(
++                QLatin1String("accessible-name"), 0, 0,
++                QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Name))));
+             sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                            QLatin1String("PropertyChange"), args);
+         }
+@@ -922,8 +934,17 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+     }
+     case QAccessible::DescriptionChanged: {
+         if (sendObject || sendObject_property_change || sendObject_property_change_accessible_description) {
+-            QString path = pathForInterface(event->accessibleInterface());
+-            QVariantList args = packDBusSignalArguments(QLatin1String("accessible-description"), 0, 0, variantForPath(path));
++            QAccessibleInterface *iface = event->accessibleInterface();
++            if (!iface) {
++                qCDebug(lcAccessibilityAtspi,
++                        "DescriptionChanged event from invalid accessible.");
++                return;
++            }
++
++            QString path = pathForInterface(iface);
++            QVariantList args = packDBusSignalArguments(
++                QLatin1String("accessible-description"), 0, 0,
++                QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Description))));
+             sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                            QLatin1String("PropertyChange"), args);
+         }
+@@ -1038,7 +1059,9 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+                 // Combo Box with AT-SPI likes to be special
+                 // It requires a name-change to update caches and then selection-changed
+                 QString path = pathForInterface(iface);
+-                QVariantList args1 = packDBusSignalArguments(QLatin1String("accessible-name"), 0, 0, variantForPath(path));
++                QVariantList args1 = packDBusSignalArguments(
++                    QLatin1String("accessible-name"), 0, 0,
++                    QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Name))));
+                 sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                                QLatin1String("PropertyChange"), args1);
+                 QVariantList args2 = packDBusSignalArguments(QString(), 0, 0, QVariant::fromValue(QDBusVariant(QVariant(0))));
+@@ -1358,6 +1381,26 @@ void AtSpiAdaptor::registerApplication()
+     delete registry;
+ }
+ 
++namespace {
++QString accessibleIdForAccessible(QAccessibleInterface *accessible)
++{
++    QString result;
++    while (accessible) {
++        if (!result.isEmpty())
++            result.prepend(QLatin1Char('.'));
++        if (auto obj = accessible->object()) {
++            const QString name = obj->objectName();
++            if (!name.isEmpty())
++                result.prepend(name);
++            else
++                result.prepend(QString::fromUtf8(obj->metaObject()->className()));
++        }
++        accessible = accessible->parent();
++    }
++    return result;
++}
++} // namespace
++
+ // Accessible
+ bool AtSpiAdaptor::accessibleInterface(QAccessibleInterface *interface, const QString &function, const QDBusMessage &message, const QDBusConnection &connection)
+ {
+@@ -1441,6 +1484,9 @@ bool AtSpiAdaptor::accessibleInterface(QAccessibleInterface *interface, const QS
+             children << ref;
+         }
+         connection.send(message.createReply(QVariant::fromValue(children)));
++    } else if (function == QLatin1String("GetAccessibleId")) {
++        sendReply(connection, message,
++                  QVariant::fromValue(QDBusVariant(accessibleIdForAccessible(interface))));
+     } else {
+         qCDebug(lcAccessibilityAtspi) << "WARNING: AtSpiAdaptor::accessibleInterface does not implement " << function << message.path();
+         return false;
+diff --git a/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp b/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
+index 45ddc8e496..cc734abc63 100644
+--- a/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
++++ b/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
+@@ -69,6 +69,21 @@ QT_BEGIN_NAMESPACE
+ DBusConnection::DBusConnection(QObject *parent)
+     : QObject(parent), m_a11yConnection(QString()), m_enabled(false)
+ {
++    // If the bus is explicitly set via env var it overrides everything else.
++    QByteArray addressEnv = qgetenv("AT_SPI_BUS_ADDRESS");
++    if (!addressEnv.isEmpty()) {
++        // Only connect on next loop run, connections to our enabled signal are
++        // only established after the ctor returns.
++        QMetaObject::invokeMethod(
++                this,
++                [this, addressEnv] {
++                    m_enabled = true;
++                    connectA11yBus(QString::fromLocal8Bit(addressEnv));
++                },
++                Qt::QueuedConnection);
++        return;
++    }
++
+     // Start monitoring if "org.a11y.Bus" is registered as DBus service.
+     QDBusConnection c = QDBusConnection::sessionBus();
+     if (!c.isConnected()) {
+diff --git a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
+index 1a3cab275d..2abe039126 100644
+--- a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
++++ b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
+@@ -51,6 +51,9 @@
+ #include <QtCore/QStandardPaths>
+ #include <QtCore/QUrl>
+ 
++#include <QtGui/QGuiApplication>
++#include <QtGui/QWindow>
++
+ #if QT_CONFIG(dbus)
+ // These QtCore includes are needed for xdg-desktop-portal support
+ #include <QtCore/private/qcore_unix_p.h>
+@@ -58,6 +61,8 @@
+ #include <QtCore/QFileInfo>
+ #include <QtCore/QUrlQuery>
+ 
++#include <QtGui/QColor>
++
+ #include <QtDBus/QDBusConnection>
+ #include <QtDBus/QDBusMessage>
+ #include <QtDBus/QDBusPendingCall>
+@@ -142,6 +147,8 @@ static inline bool detectWebBrowser(const QByteArray &desktop,
+     }
+ 
+     if (desktop == QByteArray("KDE")) {
++        if (checkExecutable(QStringLiteral("kde-open5"), browser))
++            return true;
+         // Konqueror launcher
+         if (checkExecutable(QStringLiteral("kfmclient"), browser)) {
+             browser->append(QLatin1String(" exec"));
+@@ -296,8 +303,135 @@ static inline QDBusMessage xdgDesktopPortalSendEmail(const QUrl &url)
+ 
+     return QDBusConnection::sessionBus().call(message);
+ }
++
++namespace {
++struct XDGDesktopColor
++{
++    double r = 0;
++    double g = 0;
++    double b = 0;
++
++    QColor toQColor() const
++    {
++        constexpr auto rgbMax = 255;
++        return { static_cast<int>(r * rgbMax), static_cast<int>(g * rgbMax),
++                 static_cast<int>(b * rgbMax) };
++    }
++};
++
++const QDBusArgument &operator>>(const QDBusArgument &argument, XDGDesktopColor &myStruct)
++{
++    argument.beginStructure();
++    argument >> myStruct.r >> myStruct.g >> myStruct.b;
++    argument.endStructure();
++    return argument;
++}
++
++class XdgDesktopPortalColorPicker : public QPlatformServiceColorPicker
++{
++    Q_OBJECT
++public:
++    XdgDesktopPortalColorPicker(const QString &parentWindowId, QWindow *parent)
++        : QPlatformServiceColorPicker(parent), m_parentWindowId(parentWindowId)
++    {
++    }
++
++    void pickColor() override
++    {
++        // DBus signature:
++        // PickColor (IN   s      parent_window,
++        //            IN   a{sv}  options
++        //            OUT  o      handle)
++        // Options:
++        // handle_token (s) -  A string that will be used as the last element of the @handle.
++
++        QDBusMessage message = QDBusMessage::createMethodCall(
++                QStringLiteral("org.freedesktop.portal.Desktop"), QStringLiteral("/org/freedesktop/portal/desktop"),
++                QStringLiteral("org.freedesktop.portal.Screenshot"), QStringLiteral("PickColor"));
++        message << m_parentWindowId << QVariantMap();
++
++        QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
++        auto watcher = new QDBusPendingCallWatcher(pendingCall, this);
++        connect(watcher, &QDBusPendingCallWatcher::finished, this,
++                [this](QDBusPendingCallWatcher *watcher) {
++                    watcher->deleteLater();
++                    QDBusPendingReply<QDBusObjectPath> reply = *watcher;
++                    if (reply.isError()) {
++                        qWarning("DBus call to pick color failed: %s",
++                                 qPrintable(reply.error().message()));
++                        Q_EMIT colorPicked({});
++                    } else {
++                        QDBusConnection::sessionBus().connect(
++                                QStringLiteral("org.freedesktop.portal.Desktop"), reply.value().path(),
++                                QStringLiteral("org.freedesktop.portal.Request"), QStringLiteral("Response"), this,
++                                // clang-format off
++                                SLOT(gotColorResponse(uint,QVariantMap))
++                                // clang-format on
++                        );
++                    }
++                });
++    }
++
++private Q_SLOTS:
++    void gotColorResponse(uint result, const QVariantMap &map)
++    {
++        if (result != 0)
++            return;
++        XDGDesktopColor color{};
++        map.value(QStringLiteral("color")).value<QDBusArgument>() >> color;
++        Q_EMIT colorPicked(color.toQColor());
++        deleteLater();
++    }
++
++private:
++    const QString m_parentWindowId;
++};
++} // namespace
++
+ #endif // QT_CONFIG(dbus)
+ 
++QGenericUnixServices::QGenericUnixServices()
++{
++#if QT_CONFIG(dbus)
++    if (qEnvironmentVariableIntValue("QT_NO_XDG_DESKTOP_PORTAL") > 0) {
++        return;
++    }
++    QDBusMessage message = QDBusMessage::createMethodCall(
++            QStringLiteral("org.freedesktop.portal.Desktop"), QStringLiteral("/org/freedesktop/portal/desktop"),
++            QStringLiteral("org.freedesktop.DBus.Properties"), QStringLiteral("Get"));
++    message << QStringLiteral("org.freedesktop.portal.Screenshot")
++            << QStringLiteral("version");
++
++    QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
++    auto watcher = new QDBusPendingCallWatcher(pendingCall);
++    QObject::connect(watcher, &QDBusPendingCallWatcher::finished, watcher,
++                     [this](QDBusPendingCallWatcher *watcher) {
++                         watcher->deleteLater();
++                         QDBusPendingReply<QVariant> reply = *watcher;
++                         if (!reply.isError() && reply.value().toUInt() >= 2)
++                             m_hasScreenshotPortalWithColorPicking = true;
++                     });
++
++#endif
++}
++
++QPlatformServiceColorPicker *QGenericUnixServices::colorPicker(QWindow *parent)
++{
++#if QT_CONFIG(dbus)
++    // Make double sure that we are in a wayland environment. In particular check
++    // WAYLAND_DISPLAY so also XWayland apps benefit from portal-based color picking.
++    // Outside wayland we'll rather rely on other means than the XDG desktop portal.
++    if (!qEnvironmentVariableIsEmpty("WAYLAND_DISPLAY")
++        || QGuiApplication::platformName().startsWith(QLatin1String("wayland"))) {
++        return new XdgDesktopPortalColorPicker(portalWindowIdentifier(parent), parent);
++    }
++    return nullptr;
++#else
++    Q_UNUSED(parent);
++    return nullptr;
++#endif
++}
++
+ QByteArray QGenericUnixServices::desktopEnvironment() const
+ {
+     static const QByteArray result = detectDesktopEnvironment();
+@@ -352,6 +486,8 @@ bool QGenericUnixServices::openDocument(const QUrl &url)
+ }
+ 
+ #else
++QGenericUnixServices::QGenericUnixServices() = default;
++
+ QByteArray QGenericUnixServices::desktopEnvironment() const
+ {
+     return QByteArrayLiteral("UNKNOWN");
+@@ -371,6 +507,30 @@ bool QGenericUnixServices::openDocument(const QUrl &url)
+     return false;
+ }
+ 
++QPlatformServiceColorPicker *QGenericUnixServices::colorPicker(QWindow *parent)
++{
++    Q_UNUSED(parent);
++    return nullptr;
++}
++
+ #endif // QT_NO_MULTIPROCESS
+ 
++QString QGenericUnixServices::portalWindowIdentifier(QWindow *window)
++{
++    if (QGuiApplication::platformName() == QLatin1String("xcb"))
++        return QStringLiteral("x11:") + QString::number(window->winId(), 16);
++    return QString();
++}
++
++bool QGenericUnixServices::hasCapability(Capability capability) const
++{
++    switch (capability) {
++    case Capability::ColorPicking:
++        return m_hasScreenshotPortalWithColorPicking;
++    }
++    return false;
++}
++
+ QT_END_NAMESPACE
++
++#include "qgenericunixservices.moc"
+diff --git a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
+index 8ac3de6f03..30924e64bd 100644
+--- a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
++++ b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
+@@ -59,16 +59,21 @@ QT_BEGIN_NAMESPACE
+ class QGenericUnixServices : public QPlatformServices
+ {
+ public:
+-    QGenericUnixServices() {}
++    QGenericUnixServices();
+ 
+     QByteArray desktopEnvironment() const override;
+ 
++    bool hasCapability(Capability capability) const override;
+     bool openUrl(const QUrl &url) override;
+     bool openDocument(const QUrl &url) override;
++    QPlatformServiceColorPicker *colorPicker(QWindow *parent = nullptr) override;
++
++    virtual QString portalWindowIdentifier(QWindow *window);
+ 
+ private:
+     QString m_webBrowser;
+     QString m_documentLauncher;
++    bool m_hasScreenshotPortalWithColorPicking = false;
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
+index 09470bccc6..cc7c7d4d8a 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
+@@ -69,6 +69,7 @@ const QString MenuBarPath = QLatin1String("/MenuBar");
+ */
+ QDBusMenuConnection::QDBusMenuConnection(QObject *parent, const QString &serviceName)
+     : QObject(parent)
++    , m_serviceName(serviceName)
+     , m_connection(serviceName.isNull() ? QDBusConnection::sessionBus()
+                                         : QDBusConnection::connectToBus(QDBusConnection::SessionBus, serviceName))
+     , m_dbusWatcher(new QDBusServiceWatcher(StatusNotifierWatcherService, m_connection, QDBusServiceWatcher::WatchForRegistration, this))
+@@ -83,6 +84,12 @@ QDBusMenuConnection::QDBusMenuConnection(QObject *parent, const QString &service
+ #endif
+ }
+ 
++QDBusMenuConnection::~QDBusMenuConnection()
++{
++  if (!m_serviceName.isEmpty() && m_connection.isConnected())
++      QDBusConnection::disconnectFromBus(m_serviceName);
++}
++
+ void QDBusMenuConnection::dbusError(const QDBusError &error)
+ {
+     qWarning() << "QDBusTrayIcon encountered a D-Bus error:" << error;
+@@ -105,13 +112,7 @@ void QDBusMenuConnection::unregisterTrayIconMenu(QDBusTrayIcon *item)
+ 
+ bool QDBusMenuConnection::registerTrayIcon(QDBusTrayIcon *item)
+ {
+-    bool success = connection().registerService(item->instanceId());
+-    if (!success) {
+-        qWarning() << "failed to register service" << item->instanceId();
+-        return false;
+-    }
+-
+-    success = connection().registerObject(StatusNotifierItemPath, item);
++    bool success = connection().registerObject(StatusNotifierItemPath, item);
+     if (!success) {
+         unregisterTrayIcon(item);
+         qWarning() << "failed to register" << item->instanceId() << StatusNotifierItemPath;
+@@ -126,21 +127,18 @@ bool QDBusMenuConnection::registerTrayIcon(QDBusTrayIcon *item)
+ 
+ bool QDBusMenuConnection::registerTrayIconWithWatcher(QDBusTrayIcon *item)
+ {
++    Q_UNUSED(item);
+     QDBusMessage registerMethod = QDBusMessage::createMethodCall(
+                 StatusNotifierWatcherService, StatusNotifierWatcherPath, StatusNotifierWatcherService,
+                 QLatin1String("RegisterStatusNotifierItem"));
+-    registerMethod.setArguments(QVariantList() << item->instanceId());
++    registerMethod.setArguments(QVariantList() << m_connection.baseService());
+     return m_connection.callWithCallback(registerMethod, this, SIGNAL(trayIconRegistered()), SLOT(dbusError(QDBusError)));
+ }
+ 
+-bool QDBusMenuConnection::unregisterTrayIcon(QDBusTrayIcon *item)
++void QDBusMenuConnection::unregisterTrayIcon(QDBusTrayIcon *item)
+ {
+     unregisterTrayIconMenu(item);
+     connection().unregisterObject(StatusNotifierItemPath);
+-    bool success = connection().unregisterService(item->instanceId());
+-    if (!success)
+-        qWarning() << "failed to unregister service" << item->instanceId();
+-    return success;
+ }
+ #endif // QT_NO_SYSTEMTRAYICON
+ 
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
+index f484795fbb..97bdfabb85 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
++++ b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
+@@ -70,6 +70,7 @@ class QDBusMenuConnection : public QObject
+ 
+ public:
+     QDBusMenuConnection(QObject *parent = nullptr, const QString &serviceName = QString());
++    ~QDBusMenuConnection();
+     QDBusConnection connection() const { return m_connection; }
+     QDBusServiceWatcher *dbusWatcher() const { return m_dbusWatcher; }
+     bool isStatusNotifierHostRegistered() const { return m_statusNotifierHostRegistered; }
+@@ -78,7 +79,7 @@ public:
+     void unregisterTrayIconMenu(QDBusTrayIcon *item);
+     bool registerTrayIcon(QDBusTrayIcon *item);
+     bool registerTrayIconWithWatcher(QDBusTrayIcon *item);
+-    bool unregisterTrayIcon(QDBusTrayIcon *item);
++    void unregisterTrayIcon(QDBusTrayIcon *item);
+ #endif // QT_NO_SYSTEMTRAYICON
+ 
+ Q_SIGNALS:
+@@ -90,6 +91,7 @@ private Q_SLOTS:
+     void dbusError(const QDBusError &error);
+ 
+ private:
++    QString m_serviceName;
+     QDBusConnection m_connection;
+     QDBusServiceWatcher *m_dbusWatcher;
+     bool m_statusNotifierHostRegistered;
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp b/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
+index bede70975a..76bfec5e5a 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
+@@ -71,8 +71,12 @@ Q_LOGGING_CATEGORY(qLcTray, "qt.qpa.tray")
+ static QString iconTempPath()
+ {
+     QString tempPath = QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation);
+-    if (!tempPath.isEmpty())
++    if (!tempPath.isEmpty()) {
++        QString flatpakId = qEnvironmentVariable("FLATPAK_ID");
++        if (!flatpakId.isEmpty() && QFileInfo::exists(QLatin1String("/.flatpak-info")))
++            tempPath += QLatin1String("/app/") + flatpakId;
+         return tempPath;
++    }
+ 
+     tempPath = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation);
+ 
+diff --git a/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+index cb1b39db64..6e01af052c 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+@@ -755,6 +755,9 @@ QVariant QGnomeTheme::themeHint(QPlatformTheme::ThemeHint hint) const
+         return QVariant(QChar(0x2022));
+     case QPlatformTheme::UiEffects:
+         return QVariant(int(HoverEffect));
++    case QPlatformTheme::ButtonPressKeys:
++        return QVariant::fromValue(
++                QList<Qt::Key>({ Qt::Key_Space, Qt::Key_Return, Qt::Key_Enter, Qt::Key_Select }));
+     default:
+         break;
+     }
+diff --git a/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp b/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
+index 98e05195ee..1e92f43dec 100644
+--- a/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
++++ b/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
+@@ -343,8 +343,7 @@ void QEglFSCursor::paintOnScreen()
+     // screens are siblings of each other. When not enabled, the sibling list
+     // only contains m_screen itself.
+     for (QPlatformScreen *screen : m_screen->virtualSiblings()) {
+-        if (screen->geometry().contains(cr.topLeft().toPoint() + m_cursor.hotSpot)
+-            && QOpenGLContext::currentContext()->screen() == screen->screen())
++        if (screen->geometry().contains(cr.topLeft().toPoint() + m_cursor.hotSpot))
+         {
+             cr.translate(-screen->geometry().topLeft());
+             const QSize screenSize = screen->geometry().size();
+@@ -468,11 +467,12 @@ void QEglFSCursor::draw(const QRectF &r)
+ {
+     StateSaver stateSaver;
+ 
+-    QEglFSCursorData &gfx = static_cast<QEglFSContext*>(QOpenGLContext::currentContext()->handle())->cursorData;
+-    if (!gfx.program) {
+-        // one time initialization
++    // one time initialization
++    if (!QOpenGLFunctions::d_ptr)
+         initializeOpenGLFunctions();
+ 
++    QEglFSCursorData &gfx = static_cast<QEglFSContext*>(QOpenGLContext::currentContext()->handle())->cursorData;
++    if (!gfx.program) {
+         createShaderPrograms();
+ 
+         if (!gfx.atlasTexture) {
+diff --git a/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp b/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
+index 645a0ae2e9..3e0e406f1a 100644
+--- a/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
++++ b/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
+@@ -179,7 +179,7 @@ void QEglFSKmsEventReader::create(QEglFSKmsDevice *device)
+ 
+     m_device = device;
+ 
+-    qCDebug(qLcEglfsKmsDebug, "Initalizing event reader for device %p fd %d",
++    qCDebug(qLcEglfsKmsDebug, "Initializing event reader for device %p fd %d",
+             m_device, m_device->fd());
+ 
+     m_thread = new QEglFSKmsEventReaderThread(m_device->fd());
+diff --git a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
+index 141fb68a23..d4294d425a 100644
+--- a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
++++ b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
+@@ -122,11 +122,13 @@ QOffscreenIntegration::QOffscreenIntegration()
+ #endif
+     m_services.reset(new QPlatformServices);
+ 
+-    QWindowSystemInterface::handleScreenAdded(new QOffscreenScreen);
++    m_screen = new QOffscreenScreen;
++    QWindowSystemInterface::handleScreenAdded(m_screen);
+ }
+ 
+ QOffscreenIntegration::~QOffscreenIntegration()
+ {
++    QWindowSystemInterface::handleScreenRemoved(m_screen);
+ }
+ 
+ void QOffscreenIntegration::initialize()
+diff --git a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
+index 0ea90f6c2f..fe00fde07c 100644
+--- a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
++++ b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
+@@ -84,6 +84,7 @@ protected:
+ #endif
+     QScopedPointer<QPlatformInputContext> m_inputContext;
+     QScopedPointer<QPlatformServices> m_services;
++    QPlatformScreen *m_screen;
+     mutable QScopedPointer<QPlatformNativeInterface> m_nativeInterface;
+ };
+ 
+diff --git a/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp b/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
+index 6fa5a8a2b3..1f49f0aefd 100644
+--- a/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
++++ b/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
+@@ -48,6 +48,7 @@
+ #include <qpa/qplatformnativeinterface.h>
+ #include <QtPlatformHeaders/qwglnativecontext.h>
+ 
++#include <private/qsystemlibrary_p.h>
+ #include <algorithm>
+ 
+ #include <wingdi.h>
+@@ -162,19 +163,25 @@ QFunctionPointer QWindowsOpengl32DLL::resolve(const char *name)
+ 
+ bool QWindowsOpengl32DLL::init(bool softwareRendering)
+ {
+-    const QByteArray opengl32 = QByteArrayLiteral("opengl32.dll");
+-    const QByteArray swopengl = QByteArrayLiteral("opengl32sw.dll");
++    const QByteArray opengl32 = QByteArrayLiteral("opengl32");
++    const QByteArray swopengl = QByteArrayLiteral("opengl32sw");
++    bool useSystemLib = false;
+ 
+     QByteArray openglDll = qgetenv("QT_OPENGL_DLL");
+-    if (openglDll.isEmpty())
++    if (openglDll.isEmpty()) {
+         openglDll = softwareRendering ? swopengl : opengl32;
++        useSystemLib = !softwareRendering;
++    }
+ 
+     openglDll = openglDll.toLower();
+     m_nonOpengl32 = openglDll != opengl32;
+ 
+     qCDebug(lcQpaGl) << "Qt: Using WGL and OpenGL from" << openglDll;
+ 
+-    m_lib = ::LoadLibraryA(openglDll.constData());
++    if (useSystemLib)
++        m_lib = QSystemLibrary::load((wchar_t*)(QString::fromLatin1(openglDll).utf16()));
++    else
++        m_lib = LoadLibraryA(openglDll.constData());
+     if (!m_lib) {
+         qErrnoWarning(::GetLastError(), "Failed to load %s", openglDll.constData());
+         return false;
+@@ -184,7 +191,7 @@ bool QWindowsOpengl32DLL::init(bool softwareRendering)
+         // Load opengl32.dll always. GDI functions like ChoosePixelFormat do
+         // GetModuleHandle for opengl32.dll and behave differently (and call back into
+         // opengl32) when the module is present. This is fine for dummy contexts and windows.
+-        ::LoadLibraryA("opengl32.dll");
++        QSystemLibrary::load(L"opengl32");
+     }
+ 
+     wglCreateContext = reinterpret_cast<HGLRC (WINAPI *)(HDC)>(resolve("wglCreateContext"));
+diff --git a/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp b/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
+index d7d186e804..9eb4011bf2 100644
+--- a/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
++++ b/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
+@@ -49,6 +49,7 @@
+ #include <QtCore/qstandardpaths.h>
+ #include <QtCore/qlibraryinfo.h>
+ #include <QtCore/qhash.h>
++#include <private/qsystemlibrary_p.h>
+ 
+ #ifndef QT_NO_OPENGL
+ #include <private/qopengl_p.h>
+@@ -396,7 +397,7 @@ bool QWindowsOpenGLTester::testDesktopGL()
+ 
+     // Test #1: Load opengl32.dll and try to resolve an OpenGL 2 function.
+     // This will typically fail on systems that do not have a real OpenGL driver.
+-    lib = LoadLibraryA("opengl32.dll");
++    lib = QSystemLibrary::load(L"opengl32");
+     if (lib) {
+         CreateContext = reinterpret_cast<CreateContextType>(
+             reinterpret_cast<QFunctionPointer>(::GetProcAddress(lib, "wglCreateContext")));
+diff --git a/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp b/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
+index 1afa00cfc9..118af6ce73 100644
+--- a/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
++++ b/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
+@@ -41,6 +41,7 @@
+ 
+ #include <QRect>
+ #include <QList>
++#include <QMap>
+ #include <QDebug>
+ 
+ #include <qmath.h>
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp b/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
+index 9e2a37a6a1..e6e175a118 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
+@@ -488,12 +488,12 @@ void QXcbConnection::printXcbError(const char *message, xcb_generic_error_t *err
+     uint clamped_error_code = qMin<uint>(error->error_code, (sizeof(xcb_errors) / sizeof(xcb_errors[0])) - 1);
+     uint clamped_major_code = qMin<uint>(error->major_code, (sizeof(xcb_protocol_request_codes) / sizeof(xcb_protocol_request_codes[0])) - 1);
+ 
+-    qCWarning(lcQpaXcb, "%s: %d (%s), sequence: %d, resource id: %d, major code: %d (%s), minor code: %d",
+-             message,
+-             int(error->error_code), xcb_errors[clamped_error_code],
+-             int(error->sequence), int(error->resource_id),
+-             int(error->major_code), xcb_protocol_request_codes[clamped_major_code],
+-             int(error->minor_code));
++    qCDebug(lcQpaXcb, "%s: %d (%s), sequence: %d, resource id: %d, major code: %d (%s), minor code: %d",
++            message,
++            int(error->error_code), xcb_errors[clamped_error_code],
++            int(error->sequence), int(error->resource_id),
++            int(error->major_code), xcb_protocol_request_codes[clamped_major_code],
++            int(error->minor_code));
+ }
+ 
+ static Qt::MouseButtons translateMouseButtons(int s)
+@@ -702,6 +702,8 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
+             QXcbVirtualDesktop *virtualDesktop = virtualDesktopForRootWindow(propertyNotify->window);
+             if (virtualDesktop)
+                 virtualDesktop->updateWorkArea();
++        } else if (propertyNotify->atom == atom(QXcbAtom::_NET_SUPPORTED)) {
++            m_wmSupport->updateNetWMAtoms();
+         } else {
+             HANDLE_PLATFORM_WINDOW_EVENT(xcb_property_notify_event_t, window, handlePropertyNotifyEvent);
+         }
+@@ -750,7 +752,7 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
+                 case XCB_XKB_NEW_KEYBOARD_NOTIFY: {
+                     xcb_xkb_new_keyboard_notify_event_t *ev = &xkb_event->new_keyboard_notify;
+                     if (ev->changed & XCB_XKB_NKN_DETAIL_KEYCODES)
+-                        m_keyboard->updateKeymap(ev);
++                        m_keyboard->updateKeymap();
+                     break;
+                 }
+                 default:
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp b/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
+index 76869ced60..02d2eebb56 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
+@@ -274,8 +274,7 @@ QPlatformWindow *QXcbIntegration::createForeignWindow(QWindow *window, WId nativ
+ #ifndef QT_NO_OPENGL
+ QPlatformOpenGLContext *QXcbIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
+ {
+-    QXcbScreen *screen = static_cast<QXcbScreen *>(context->screen()->handle());
+-    QXcbGlIntegration *glIntegration = screen->connection()->glIntegration();
++    QXcbGlIntegration *glIntegration = defaultConnection()->glIntegration();
+     if (!glIntegration) {
+         qWarning("QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled");
+         return nullptr;
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+index efecd7e2d1..e8286381a2 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+@@ -365,17 +365,6 @@ void QXcbKeyboard::updateKeymap(xcb_mapping_notify_event_t *event)
+     updateKeymap();
+ }
+ 
+-void QXcbKeyboard::updateKeymap(xcb_xkb_new_keyboard_notify_event_t *event)
+-{
+-    if (!event)
+-        return;
+-
+-    if (event->deviceID != event->oldDeviceID)
+-        m_config = false;
+-
+-    updateKeymap();
+-}
+-
+ void QXcbKeyboard::updateKeymap()
+ {
+     KeysymModifierMap keysymMods;
+@@ -383,6 +372,8 @@ void QXcbKeyboard::updateKeymap()
+         keysymMods = keysymsToModifiers();
+     updateModifiers(keysymMods);
+ 
++    m_config = true;
++
+     if (!m_xkbContext) {
+         m_xkbContext.reset(xkb_context_new(XKB_CONTEXT_NO_DEFAULT_INCLUDES));
+         if (!m_xkbContext) {
+@@ -398,13 +389,8 @@ void QXcbKeyboard::updateKeymap()
+     if (connection()->hasXKB()) {
+         m_xkbKeymap.reset(xkb_x11_keymap_new_from_device(m_xkbContext.get(), xcb_connection(),
+                                                          core_device_id, XKB_KEYMAP_COMPILE_NO_FLAGS));
+-        if (m_xkbKeymap) {
+-            if (m_config)
+-                m_xkbState.reset(xkb_state_new(m_xkbKeymap.get()));
+-            else
+-                m_xkbState.reset(xkb_x11_state_new_from_device(m_xkbKeymap.get(), xcb_connection(), core_device_id));
+-
+-        }
++        if (m_xkbKeymap)
++            m_xkbState.reset(xkb_x11_state_new_from_device(m_xkbKeymap.get(), xcb_connection(), core_device_id));
+     } else {
+         m_xkbKeymap.reset(keymapFromCore(keysymMods));
+         if (m_xkbKeymap)
+@@ -425,8 +411,6 @@ void QXcbKeyboard::updateKeymap()
+     updateXKBMods();
+ 
+     QXkbCommon::verifyHasLatinLayout(m_xkbKeymap.get());
+-
+-    m_config = true;
+ }
+ 
+ QList<int> QXcbKeyboard::possibleKeys(const QKeyEvent *event) const
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
+index b652c85fe3..0ee08aeff2 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
++++ b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
+@@ -69,7 +69,6 @@ public:
+ 
+     Qt::KeyboardModifiers translateModifiers(int s) const;
+     void updateKeymap(xcb_mapping_notify_event_t *event);
+-    void updateKeymap(xcb_xkb_new_keyboard_notify_event_t *event);
+     void updateKeymap();
+     QList<int> possibleKeys(const QKeyEvent *event) const;
+ 
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp b/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
+index ffda7b6a57..863e961f4c 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
+@@ -564,11 +564,6 @@ void QXcbWindow::setGeometry(const QRect &rect)
+ {
+     QPlatformWindow::setGeometry(rect);
+ 
+-    if (shouldDeferTask(Task::SetGeometry)) {
+-        m_deferredGeometry = rect;
+-        return;
+-    }
+-
+     propagateSizeHints();
+ 
+     QXcbScreen *currentScreen = xcbScreen();
+@@ -693,9 +688,6 @@ void QXcbWindow::setVisible(bool visible)
+ 
+ void QXcbWindow::show()
+ {
+-    if (shouldDeferTask(Task::Map))
+-        return;
+-
+     if (window()->isTopLevel()) {
+ 
+         // update WM_NORMAL_HINTS
+@@ -706,7 +698,7 @@ void QXcbWindow::show()
+         if (isTransient(window())) {
+             const QWindow *tp = window()->transientParent();
+             if (tp && tp->handle())
+-                transientXcbParent = static_cast<const QXcbWindow *>(tp->handle())->winId();
++                transientXcbParent = tp->handle()->winId();
+             // Default to client leader if there is no transient parent, else modal dialogs can
+             // be hidden by their parents.
+             if (!transientXcbParent)
+@@ -746,10 +738,6 @@ void QXcbWindow::show()
+ 
+ void QXcbWindow::hide()
+ {
+-    if (shouldDeferTask(Task::Unmap))
+-        return;
+-
+-    m_wmStateValid = false;
+     xcb_unmap_window(xcb_connection(), m_window);
+ 
+     // send synthetic UnmapNotify event according to icccm 4.1.4
+@@ -909,9 +897,6 @@ QXcbWindow::NetWmStates QXcbWindow::netWmStates()
+ 
+ void QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
+ {
+-    if (shouldDeferTask(Task::SetWindowFlags))
+-        return;
+-
+     Qt::WindowType type = static_cast<Qt::WindowType>(int(flags & Qt::WindowType_Mask));
+ 
+     if (type == Qt::ToolTip)
+@@ -941,8 +926,6 @@ void QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
+ 
+     setTransparentForMouseEvents(flags & Qt::WindowTransparentForInput);
+     updateDoesNotAcceptFocus(flags & Qt::WindowDoesNotAcceptFocus);
+-
+-    m_isWmManagedWindow = !(flags & Qt::X11BypassWindowManagerHint);
+ }
+ 
+ void QXcbWindow::setMotifWmHints(Qt::WindowFlags flags)
+@@ -1142,9 +1125,6 @@ void QXcbWindow::setWindowState(Qt::WindowStates state)
+     if (state == m_windowState)
+         return;
+ 
+-    if (shouldDeferTask(Task::SetWindowState))
+-        return;
+-
+     // unset old state
+     if (m_windowState & Qt::WindowMinimized)
+         xcb_map_window(xcb_connection(), m_window);
+@@ -1350,6 +1330,12 @@ void QXcbWindow::setWindowIcon(const QIcon &icon)
+     }
+ 
+     if (!icon_data.isEmpty()) {
++        // Ignore icon exceeding maximum xcb request length
++        if (icon_data.size() > xcb_get_maximum_request_length(xcb_connection())) {
++            qWarning("Ignoring window icon: Size %llu exceeds maximum xcb request length %u.",
++                     icon_data.size(), xcb_get_maximum_request_length(xcb_connection()));
++            return;
++        }
+         xcb_change_property(xcb_connection(),
+                             XCB_PROP_MODE_REPLACE,
+                             m_window,
+@@ -1639,7 +1625,7 @@ void QXcbWindow::setWmWindowType(QXcbWindowFunctions::WmWindowTypes types, Qt::W
+         break;
+     }
+ 
+-    if ((flags & Qt::FramelessWindowHint) && !(type & QXcbWindowFunctions::KdeOverride)) {
++    if ((flags & Qt::FramelessWindowHint) && !(types & QXcbWindowFunctions::KdeOverride)) {
+         // override netwm type - quick and easy for KDE noborder
+         atoms.append(atom(QXcbAtom::_KDE_NET_WM_WINDOW_TYPE_OVERRIDE));
+     }
+@@ -1894,10 +1880,6 @@ void QXcbWindow::handleUnmapNotifyEvent(const xcb_unmap_notify_event_t *event)
+     if (event->window == m_window) {
+         m_mapped = false;
+         QWindowSystemInterface::handleExposeEvent(window(), QRegion());
+-        if (!m_isWmManagedWindow || parent()) {
+-            m_wmStateValid = true;
+-            handleDeferredTasks();
+-        }
+     }
+ }
+ 
+@@ -2212,98 +2194,30 @@ void QXcbWindow::handleLeaveNotifyEvent(const xcb_leave_notify_event_t *event)
+     handleLeaveNotifyEvent(event->root_x, event->root_y, event->mode, event->detail, event->time);
+ }
+ 
+-bool QXcbWindow::shouldDeferTask(Task task)
+-{
+-    if (m_wmStateValid)
+-        return false;
+-
+-    m_deferredTasks.append(task);
+-    return true;
+-}
+-
+-void QXcbWindow::handleDeferredTasks()
+-{
+-    Q_ASSERT(m_wmStateValid == true);
+-    if (m_deferredTasks.isEmpty())
+-        return;
+-
+-    bool map = false;
+-    bool unmap = false;
+-
+-    QVector<Task> tasks;
+-    for (auto taskIt = m_deferredTasks.rbegin(); taskIt != m_deferredTasks.rend(); ++taskIt) {
+-        if (!tasks.contains(*taskIt))
+-            tasks.prepend(*taskIt);
+-    }
+-
+-    for (Task task : tasks) {
+-        switch (task) {
+-        case Task::Map:
+-            map = true;
+-            unmap = false;
+-            break;
+-        case Task::Unmap:
+-            unmap = true;
+-            map = false;
+-            break;
+-        case Task::SetGeometry:
+-            setGeometry(m_deferredGeometry);
+-            break;
+-        case Task::SetWindowFlags:
+-            setWindowFlags(window()->flags());
+-            break;
+-        case Task::SetWindowState:
+-            setWindowState(window()->windowState());
+-            break;
+-        }
+-    }
+-    m_deferredTasks.clear();
+-
+-    if (map) {
+-        Q_ASSERT(unmap == false);
+-        show();
+-    }
+-    if (unmap) {
+-        Q_ASSERT(map == false);
+-        hide();
+-    }
+-}
+-
+ void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *event)
+ {
+     connection()->setTime(event->time);
+ 
+-    const bool wmStateChanged = event->atom == atom(QXcbAtom::WM_STATE);
+-    const bool netWmStateChanged = event->atom == atom(QXcbAtom::_NET_WM_STATE);
+-    if (netWmStateChanged || wmStateChanged) {
+-        if (wmStateChanged && !m_wmStateValid && m_isWmManagedWindow) {
+-            // ICCCM 4.1.4
+-            // Clients that want to re-use a client window (e.g. by mapping it again)
+-            // after withdrawing it must wait for the withdrawal to be complete before
+-            // proceeding. The preferred method for doing this is for clients to wait for
+-            // a window manager to update or remove the WM_STATE property.
+-            m_wmStateValid = true;
+-            handleDeferredTasks();
+-        }
+-        if (event->state == XCB_PROPERTY_DELETE)
++    const bool propertyDeleted = event->state == XCB_PROPERTY_DELETE;
++
++    if (event->atom == atom(QXcbAtom::_NET_WM_STATE) || event->atom == atom(QXcbAtom::WM_STATE)) {
++        if (propertyDeleted)
+             return;
+ 
+-        if (wmStateChanged) {
++        Qt::WindowStates newState = Qt::WindowNoState;
++
++        if (event->atom == atom(QXcbAtom::WM_STATE)) { // WM_STATE: Quick check for 'Minimize'.
+             auto reply = Q_XCB_REPLY(xcb_get_property, xcb_connection(),
+                                      0, m_window, atom(QXcbAtom::WM_STATE),
+                                      XCB_ATOM_ANY, 0, 1024);
+             if (reply && reply->format == 32 && reply->type == atom(QXcbAtom::WM_STATE)) {
+-                auto data = static_cast<const quint32 *>(xcb_get_property_value(reply.get()));
+-                if (reply->length != 0) {
+-                    const bool changedToWithdrawn = data[0] == XCB_ICCCM_WM_STATE_WITHDRAWN;
+-                    const bool changedToIconic = data[0] == XCB_ICCCM_WM_STATE_ICONIC;
+-                    m_minimized = changedToIconic || (changedToWithdrawn && m_minimized);
+-                }
++                const quint32 *data = (const quint32 *)xcb_get_property_value(reply.get());
++                if (reply->length != 0)
++                    m_minimized = (data[0] == XCB_ICCCM_WM_STATE_ICONIC
++                                   || (data[0] == XCB_ICCCM_WM_STATE_WITHDRAWN && m_minimized));
+             }
+         }
+ 
+-        // _NET_WM_STATE handling
+-        Qt::WindowStates newState = Qt::WindowNoState;
+         const NetWmStates states = netWmStates();
+         // _NET_WM_STATE_HIDDEN should be set by the Window Manager to indicate that a window would
+         // not be visible on the screen if its desktop/viewport were active and its coordinates were
+@@ -2325,6 +2239,7 @@ void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *ev
+             if ((m_windowState & Qt::WindowMinimized) && connection()->mouseGrabber() == this)
+                 connection()->setMouseGrabber(nullptr);
+         }
++        return;
+     } else if (event->atom == atom(QXcbAtom::_NET_FRAME_EXTENTS)) {
+         m_dirtyFrameMargins = true;
+     }
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbwindow.h b/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
+index 55af9279b1..6f5c1f5ed9 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
++++ b/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
+@@ -74,14 +74,6 @@ public:
+ 
+     Q_DECLARE_FLAGS(NetWmStates, NetWmState)
+ 
+-    enum Task {
+-        Map,
+-        Unmap,
+-        SetGeometry,
+-        SetWindowFlags,
+-        SetWindowState
+-    };
+-
+     QXcbWindow(QWindow *window);
+     ~QXcbWindow();
+ 
+@@ -151,9 +143,6 @@ public:
+ 
+     QXcbWindow *toWindow() override;
+ 
+-    bool shouldDeferTask(Task task);
+-    void handleDeferredTasks();
+-
+     void handleMouseEvent(xcb_timestamp_t time, const QPoint &local, const QPoint &global,
+                           Qt::KeyboardModifiers modifiers, QEvent::Type type, Qt::MouseEventSource source);
+ 
+@@ -292,11 +281,6 @@ protected:
+     int m_swapInterval = -1;
+ 
+     qreal m_sizeHintsScaleFactor = 1.0;
+-
+-    bool m_wmStateValid = true;
+-    QVector<Task> m_deferredTasks;
+-    bool m_isWmManagedWindow = true;
+-    QRect m_deferredGeometry;
+ };
+ 
+ class QXcbForeignWindow : public QXcbWindow
+diff --git a/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp b/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
+index d9d117faeb..640b49daa0 100644
+--- a/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
++++ b/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
+@@ -85,6 +85,7 @@ QGtk3MenuItem::QGtk3MenuItem()
+       m_checkable(false),
+       m_checked(false),
+       m_enabled(true),
++      m_exclusive(false),
+       m_underline(false),
+       m_invalid(true),
+       m_menu(nullptr),
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
+index 0048bbc1e6..396e7f6d1c 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
+@@ -102,15 +102,12 @@ const QDBusArgument &operator >>(const QDBusArgument &arg, QXdgDesktopPortalFile
+ class QXdgDesktopPortalFileDialogPrivate
+ {
+ public:
+-    QXdgDesktopPortalFileDialogPrivate(QPlatformFileDialogHelper *nativeFileDialog)
++    QXdgDesktopPortalFileDialogPrivate(QPlatformFileDialogHelper *nativeFileDialog, uint fileChooserPortalVersion)
+         : nativeFileDialog(nativeFileDialog)
++        , fileChooserPortalVersion(fileChooserPortalVersion)
+     { }
+ 
+-    WId winId = 0;
+-    bool directoryMode = false;
+-    bool modal = false;
+-    bool multipleFiles = false;
+-    bool saveFile = false;
++    QEventLoop loop;
+     QString acceptLabel;
+     QString directory;
+     QString title;
+@@ -121,19 +118,27 @@ public:
+     QString selectedMimeTypeFilter;
+     QString selectedNameFilter;
+     QStringList selectedFiles;
+-    QPlatformFileDialogHelper *nativeFileDialog = nullptr;
++    std::unique_ptr<QPlatformFileDialogHelper> nativeFileDialog;
++    uint fileChooserPortalVersion = 0;
++    bool failedToOpen = false;
++    bool directoryMode = false;
++    bool multipleFiles = false;
++    bool saveFile = false;
+ };
+ 
+-QXdgDesktopPortalFileDialog::QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog)
++QXdgDesktopPortalFileDialog::QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog, uint fileChooserPortalVersion)
+     : QPlatformFileDialogHelper()
+-    , d_ptr(new QXdgDesktopPortalFileDialogPrivate(nativeFileDialog))
++    , d_ptr(new QXdgDesktopPortalFileDialogPrivate(nativeFileDialog, fileChooserPortalVersion))
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+     if (d->nativeFileDialog) {
+-        connect(d->nativeFileDialog, SIGNAL(accept()), this, SIGNAL(accept()));
+-        connect(d->nativeFileDialog, SIGNAL(reject()), this, SIGNAL(reject()));
++        connect(d->nativeFileDialog.get(), SIGNAL(accept()), this, SIGNAL(accept()));
++        connect(d->nativeFileDialog.get(), SIGNAL(reject()), this, SIGNAL(reject()));
+     }
++
++    d->loop.connect(this, SIGNAL(accept()), SLOT(quit()));
++    d->loop.connect(this, SIGNAL(reject()), SLOT(quit()));
+ }
+ 
+ QXdgDesktopPortalFileDialog::~QXdgDesktopPortalFileDialog()
+@@ -177,7 +182,7 @@ void QXdgDesktopPortalFileDialog::initializeDialog()
+     setDirectory(options()->initialDirectory());
+ }
+ 
+-void QXdgDesktopPortalFileDialog::openPortal()
++void QXdgDesktopPortalFileDialog::openPortal(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent)
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+@@ -185,13 +190,13 @@ void QXdgDesktopPortalFileDialog::openPortal()
+                                                           QLatin1String("/org/freedesktop/portal/desktop"),
+                                                           QLatin1String("org.freedesktop.portal.FileChooser"),
+                                                           d->saveFile ? QLatin1String("SaveFile") : QLatin1String("OpenFile"));
+-    QString parentWindowId = QLatin1String("x11:") + QString::number(d->winId, 16);
++    QString parentWindowId = QLatin1String("x11:") + QString::number(parent ? parent->winId() : 0, 16);
+ 
+     QVariantMap options;
+     if (!d->acceptLabel.isEmpty())
+         options.insert(QLatin1String("accept_label"), d->acceptLabel);
+ 
+-    options.insert(QLatin1String("modal"), d->modal);
++    options.insert(QLatin1String("modal"), windowModality != Qt::NonModal);
+     options.insert(QLatin1String("multiple"), d->multipleFiles);
+     options.insert(QLatin1String("directory"), d->directoryMode);
+ 
+@@ -290,10 +295,18 @@ void QXdgDesktopPortalFileDialog::openPortal()
+ 
+     QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
+     QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingCall);
+-    connect(watcher, &QDBusPendingCallWatcher::finished, this, [this] (QDBusPendingCallWatcher *watcher) {
++    connect(watcher, &QDBusPendingCallWatcher::finished, this, [=] (QDBusPendingCallWatcher *watcher) {
+         QDBusPendingReply<QDBusObjectPath> reply = *watcher;
+-        if (reply.isError()) {
+-            Q_EMIT reject();
++        // Any error means the dialog is not shown and we need to fallback
++        d->failedToOpen = reply.isError();
++        if (d->failedToOpen) {
++            if (d->nativeFileDialog) {
++                d->nativeFileDialog->show(windowFlags, windowModality, parent);
++                if (d->loop.isRunning())
++                    d->nativeFileDialog->exec();
++            } else {
++                Q_EMIT reject();
++            }
+         } else {
+             QDBusConnection::sessionBus().connect(nullptr,
+                                                   reply.value().path(),
+@@ -302,6 +315,7 @@ void QXdgDesktopPortalFileDialog::openPortal()
+                                                   this,
+                                                   SLOT(gotResponse(uint,QVariantMap)));
+         }
++        watcher->deleteLater();
+     });
+ }
+ 
+@@ -326,7 +340,7 @@ QUrl QXdgDesktopPortalFileDialog::directory() const
+ {
+     Q_D(const QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog())
+         return d->nativeFileDialog->directory();
+ 
+     return d->directory;
+@@ -348,7 +362,7 @@ QList<QUrl> QXdgDesktopPortalFileDialog::selectedFiles() const
+ {
+     Q_D(const QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog())
+         return d->nativeFileDialog->selectedFiles();
+ 
+     QList<QUrl> files;
+@@ -403,16 +417,13 @@ void QXdgDesktopPortalFileDialog::exec()
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly)) {
++    if (d->nativeFileDialog && useNativeFileDialog()) {
+         d->nativeFileDialog->exec();
+         return;
+     }
+ 
+     // HACK we have to avoid returning until we emit that the dialog was accepted or rejected
+-    QEventLoop loop;
+-    loop.connect(this, SIGNAL(accept()), SLOT(quit()));
+-    loop.connect(this, SIGNAL(reject()), SLOT(quit()));
+-    loop.exec();
++    d->loop.exec();
+ }
+ 
+ void QXdgDesktopPortalFileDialog::hide()
+@@ -429,13 +440,10 @@ bool QXdgDesktopPortalFileDialog::show(Qt::WindowFlags windowFlags, Qt::WindowMo
+ 
+     initializeDialog();
+ 
+-    d->modal = windowModality != Qt::NonModal;
+-    d->winId = parent ? parent->winId() : 0;
+-
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog(OpenFallback))
+         return d->nativeFileDialog->show(windowFlags, windowModality, parent);
+ 
+-    openPortal();
++    openPortal(windowFlags, windowModality, parent);
+ 
+     return true;
+ }
+@@ -465,4 +473,21 @@ void QXdgDesktopPortalFileDialog::gotResponse(uint response, const QVariantMap &
+     }
+ }
+ 
++bool QXdgDesktopPortalFileDialog::useNativeFileDialog(QXdgDesktopPortalFileDialog::FallbackType fallbackType) const
++{
++    Q_D(const QXdgDesktopPortalFileDialog);
++
++    if (d->failedToOpen && fallbackType != OpenFallback)
++        return true;
++
++    if (d->fileChooserPortalVersion < 3) {
++        if (options()->fileMode() == QFileDialogOptions::Directory)
++            return true;
++        else if (options()->fileMode() == QFileDialogOptions::DirectoryOnly)
++            return true;
++    }
++
++    return false;
++}
++
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
+index 4f4de96ecf..65e22a5cf2 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
+@@ -51,6 +51,11 @@ class QXdgDesktopPortalFileDialog : public QPlatformFileDialogHelper
+     Q_OBJECT
+     Q_DECLARE_PRIVATE(QXdgDesktopPortalFileDialog)
+ public:
++    enum FallbackType {
++        GenericFallback,
++        OpenFallback
++    };
++
+     enum ConditionType : uint {
+         GlobalPattern = 0,
+         MimeType = 1
+@@ -69,7 +74,7 @@ public:
+     };
+     typedef QVector<Filter> FilterList;
+ 
+-    QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog = nullptr);
++    QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog = nullptr, uint fileChooserPortalVersion = 0);
+     ~QXdgDesktopPortalFileDialog();
+ 
+     bool defaultNameFilterDisables() const override;
+@@ -92,7 +97,8 @@ private Q_SLOTS:
+ 
+ private:
+     void initializeDialog();
+-    void openPortal();
++    void openPortal(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent);
++    bool useNativeFileDialog(FallbackType fallbackType = GenericFallback) const;
+ 
+     QScopedPointer<QXdgDesktopPortalFileDialogPrivate> d_ptr;
+ };
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
+index fb324afbd8..b809503122 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
+@@ -111,6 +111,7 @@ QXdgDesktopPortalTheme::QXdgDesktopPortalTheme()
+         if (reply.isValid()) {
+             d->fileChooserPortalVersion = reply.value().toUInt();
+         }
++        watcher->deleteLater();
+     });
+ }
+ 
+@@ -152,11 +153,12 @@ QPlatformDialogHelper* QXdgDesktopPortalTheme::createPlatformDialogHelper(Dialog
+ {
+     Q_D(const QXdgDesktopPortalTheme);
+ 
+-    if (type == FileDialog) {
++    if (type == FileDialog && d->fileChooserPortalVersion) {
+         // Older versions of FileChooser portal don't support opening directories, therefore we fallback
+         // to native file dialog opened inside the sandbox to open a directory.
+-        if (d->fileChooserPortalVersion < 3 && d->baseTheme->usePlatformNativeDialog(type))
+-            return new QXdgDesktopPortalFileDialog(static_cast<QPlatformFileDialogHelper*>(d->baseTheme->createPlatformDialogHelper(type)));
++        if (d->baseTheme->usePlatformNativeDialog(type))
++            return new QXdgDesktopPortalFileDialog(static_cast<QPlatformFileDialogHelper*>(d->baseTheme->createPlatformDialogHelper(type)),
++                                                   d->fileChooserPortalVersion);
+ 
+         return new QXdgDesktopPortalFileDialog;
+     }
+diff --git a/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp b/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
+index 43d5e119ad..1f9cbc4565 100644
+--- a/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
++++ b/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
+@@ -89,8 +89,10 @@ void QCupsPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &v
+         break;
+     case PPK_Duplex: {
+         QPrint::DuplexMode mode = QPrint::DuplexMode(value.toInt());
+-        if (mode != d->duplex && d->m_printDevice.supportedDuplexModes().contains(mode))
++        if (d->m_printDevice.supportedDuplexModes().contains(mode)) {
+             d->duplex = mode;
++            d->duplexRequestedExplicitly = true;
++        }
+         break;
+     }
+     case PPK_PrinterName:
+@@ -277,9 +279,12 @@ void QCupsPrintEnginePrivate::changePrinter(const QString &newPrinter)
+     m_printDevice.swap(printDevice);
+     printerName = m_printDevice.id();
+ 
+-    // Check if new printer supports current settings, otherwise us defaults
+-    if (duplex != QPrint::DuplexAuto && !m_printDevice.supportedDuplexModes().contains(duplex))
++    // in case a duplex value was explicitly set, check if new printer supports current value,
++    // otherwise use device default
++    if (!duplexRequestedExplicitly || !m_printDevice.supportedDuplexModes().contains(duplex)) {
+         duplex = m_printDevice.defaultDuplexMode();
++        duplexRequestedExplicitly = false;
++    }
+     QPrint::ColorMode colorMode = grayscale ? QPrint::GrayScale : QPrint::Color;
+     if (!m_printDevice.supportedColorModes().contains(colorMode))
+         grayscale = m_printDevice.defaultColorMode() == QPrint::GrayScale;
+diff --git a/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h b/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
+index c021b0c643..8f81fe478d 100644
+--- a/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
++++ b/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
+@@ -100,6 +100,7 @@ private:
+     QStringList cupsOptions;
+     QString cupsTempFile;
+     QPrint::DuplexMode duplex;
++    bool duplexRequestedExplicitly = false;
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp b/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
+index 67e7154fa6..40876152e5 100644
+--- a/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
++++ b/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
+@@ -817,7 +817,7 @@ bool QIBaseResultPrivate::writeArray(int column, const QList<QVariant> &list)
+     ba.resize(int(bufLen));
+ 
+     if (list.size() > arraySize) {
+-        error = QLatin1String("Array size missmatch: size of %1 is %2, size of provided list is %3");
++        error = QLatin1String("Array size mismatch: size of %1 is %2, size of provided list is %3");
+         error = error.arg(QLatin1String(sqlname)).arg(arraySize).arg(list.size());
+         q->setLastError(QSqlError(error, QLatin1String(""), QSqlError::StatementError));
+         return false;
+diff --git a/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp b/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
+index 7ca055eea2..6bc9d46755 100644
+--- a/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
++++ b/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
+@@ -223,7 +223,7 @@ public:
+     struct QMyField
+     {
+         char *outField = nullptr;
+-        MYSQL_FIELD *myField = nullptr;
++        const MYSQL_FIELD *myField = nullptr;
+         QMetaType::Type type = QMetaType::UnknownType;
+         my_bool nullIndicator = false;
+         ulong bufLength = 0ul;
+@@ -361,7 +361,7 @@ static bool qIsInteger(int t)
+ void QMYSQLResultPrivate::bindBlobs()
+ {
+     int i;
+-    MYSQL_FIELD *fieldInfo;
++    const MYSQL_FIELD *fieldInfo;
+     MYSQL_BIND *bind;
+ 
+     for(i = 0; i < fields.count(); ++i) {
+@@ -379,7 +379,6 @@ void QMYSQLResultPrivate::bindBlobs()
+ bool QMYSQLResultPrivate::bindInValues()
+ {
+     MYSQL_BIND *bind;
+-    char *field;
+     int i = 0;
+ 
+     if (!meta)
+@@ -392,35 +391,34 @@ bool QMYSQLResultPrivate::bindInValues()
+     inBinds = new MYSQL_BIND[fields.size()];
+     memset(inBinds, 0, fields.size() * sizeof(MYSQL_BIND));
+ 
+-    MYSQL_FIELD *fieldInfo;
++    const MYSQL_FIELD *fieldInfo;
+ 
+     while((fieldInfo = mysql_fetch_field(meta))) {
++        bind = &inBinds[i];
++
+         QMyField &f = fields[i];
+         f.myField = fieldInfo;
+-
++        bind->buffer_length = f.bufLength = fieldInfo->length + 1;
++        bind->buffer_type = fieldInfo->type;
+         f.type = qDecodeMYSQLType(fieldInfo->type, fieldInfo->flags);
+         if (qIsBlob(fieldInfo->type)) {
+             // the size of a blob-field is available as soon as we call
+             // mysql_stmt_store_result()
+             // after mysql_stmt_exec() in QMYSQLResult::exec()
+-            fieldInfo->length = 0;
++            bind->buffer_length = f.bufLength = 0;
+             hasBlobs = true;
+         } else if (qIsInteger(f.type)) {
+-            fieldInfo->length = 8;
++            bind->buffer_length = f.bufLength = 8;
+         } else {
+-            fieldInfo->type = MYSQL_TYPE_STRING;
++            bind->buffer_type = MYSQL_TYPE_STRING;
+         }
+-        bind = &inBinds[i];
+-        field = new char[fieldInfo->length + 1];
+-        memset(field, 0, fieldInfo->length + 1);
+ 
+-        bind->buffer_type = fieldInfo->type;
+-        bind->buffer = field;
+-        bind->buffer_length = f.bufLength = fieldInfo->length + 1;
+         bind->is_null = &f.nullIndicator;
+         bind->length = &f.bufLength;
+         bind->is_unsigned = fieldInfo->flags & UNSIGNED_FLAG ? 1 : 0;
+-        f.outField=field;
++
++        char *field = new char[bind->buffer_length + 1]{};
++        bind->buffer = f.outField = field;
+ 
+         ++i;
+     }
+@@ -1369,20 +1367,20 @@ bool QMYSQLDriver::open(const QString& db,
+     }
+ 
+ #if MYSQL_VERSION_ID >= 50007
+-    if (mysql_get_client_version() >= 50503 && mysql_get_server_version(d->mysql) >= 50503) {
+-        // force the communication to be utf8mb4 (only utf8mb4 supports 4-byte characters)
+-        mysql_set_character_set(d->mysql, "utf8mb4");
++    // force the communication to be utf8mb4 (only utf8mb4 supports 4-byte characters)
++    if (mysql_set_character_set(d->mysql, "utf8mb4")) {
++        // this failed, try forcing it to utf (BMP only)
++        if (mysql_set_character_set(d->mysql, "utf8"))
++            qWarning() << "MySQL: Unable to set the client character set to utf8.";
+ #if QT_CONFIG(textcodec)
+-        d->tc = QTextCodec::codecForName("UTF-8");
++        else
++            d->tc = codec(d->mysql);
+ #endif
+-    } else
+-    {
+-        // force the communication to be utf8
+-        mysql_set_character_set(d->mysql, "utf8");
++    }
+ #if QT_CONFIG(textcodec)
+-        d->tc = codec(d->mysql);
++    else
++        d->tc = QTextCodec::codecForName("UTF-8");
+ #endif
+-    }
+ #endif  // MYSQL_VERSION_ID >= 50007
+ 
+     d->preparedQuerysEnabled = checkPreparedQueries(d->mysql);
+diff --git a/qtbase/src/printsupport/dialogs/images/print-24.png b/qtbase/src/printsupport/dialogs/images/printer-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/print-24.png
+rename to src/printsupport/dialogs/images/printer-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/print-32.png b/qtbase/src/printsupport/dialogs/images/printer-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/print-32.png
+rename to src/printsupport/dialogs/images/printer-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-sided-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-facing-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-sided-24.png
+rename to src/printsupport/dialogs/images/view-pages-facing-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-sided-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-facing-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-sided-32.png
+rename to src/printsupport/dialogs/images/view-pages-facing-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-multi-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-overview-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-multi-24.png
+rename to src/printsupport/dialogs/images/view-pages-overview-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-multi-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-overview-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-multi-32.png
+rename to src/printsupport/dialogs/images/view-pages-overview-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-one-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-single-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-one-24.png
+rename to src/printsupport/dialogs/images/view-pages-single-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-one-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-single-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-one-32.png
+rename to src/printsupport/dialogs/images/view-pages-single-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-page-24.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-page-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-page-24.png
+rename to src/printsupport/dialogs/images/zoom-fit-page-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-page-32.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-page-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-page-32.png
+rename to src/printsupport/dialogs/images/zoom-fit-page-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-width-24.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-width-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-width-24.png
+rename to src/printsupport/dialogs/images/zoom-fit-width-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-width-32.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-width-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-width-32.png
+rename to src/printsupport/dialogs/images/zoom-fit-width-32.png
+diff --git a/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp b/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
+index 78e5b8d1ef..2a28516719 100644
+--- a/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
++++ b/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
+@@ -532,6 +532,7 @@ void QPageSetupWidget::updateWidget()
+ void QPageSetupWidget::setupPrinter() const
+ {
+     m_printer->setPageLayout(m_pageLayout);
++    m_printer->setPageOrientation(m_pageLayout.orientation());
+ #if QT_CONFIG(cups)
+     QCUPSSupport::PagesPerSheet pagesPerSheet = qvariant_cast<QCUPSSupport::PagesPerSheet>(m_ui.pagesPerSheetCombo->currentData()
+ );
+diff --git a/qtbase/src/printsupport/dialogs/qprintdialog.qrc b/qtbase/src/printsupport/dialogs/qprintdialog.qrc
+index 5a579baa55..10b8e1d341 100644
+--- a/qtbase/src/printsupport/dialogs/qprintdialog.qrc
++++ b/qtbase/src/printsupport/dialogs/qprintdialog.qrc
+@@ -1,9 +1,9 @@
+ <!DOCTYPE RCC><RCC version="1.0">
+ <qresource prefix="/qt-project.org/dialogs/qprintpreviewdialog">
+-<file>images/fit-page-24.png</file>
+-<file>images/fit-page-32.png</file>
+-<file>images/fit-width-24.png</file>
+-<file>images/fit-width-32.png</file>
++<file>images/zoom-fit-page-24.png</file>
++<file>images/zoom-fit-page-32.png</file>
++<file>images/zoom-fit-width-24.png</file>
++<file>images/zoom-fit-width-32.png</file>
+ <file>images/go-first-24.png</file>
+ <file>images/go-first-32.png</file>
+ <file>images/go-last-24.png</file>
+@@ -18,14 +18,14 @@
+ <file>images/layout-portrait-32.png</file>
+ <file>images/page-setup-24.png</file>
+ <file>images/page-setup-32.png</file>
+-<file>images/print-24.png</file>
+-<file>images/print-32.png</file>
+-<file>images/view-page-multi-24.png</file>
+-<file>images/view-page-multi-32.png</file>
+-<file>images/view-page-one-24.png</file>
+-<file>images/view-page-one-32.png</file>
+-<file>images/view-page-sided-24.png</file>
+-<file>images/view-page-sided-32.png</file>
++<file>images/printer-24.png</file>
++<file>images/printer-32.png</file>
++<file>images/view-pages-overview-24.png</file>
++<file>images/view-pages-overview-32.png</file>
++<file>images/view-pages-single-24.png</file>
++<file>images/view-pages-single-32.png</file>
++<file>images/view-pages-facing-24.png</file>
++<file>images/view-pages-facing-32.png</file>
+ <file>images/zoom-in-24.png</file>
+ <file>images/zoom-in-32.png</file>
+ <file>images/zoom-out-24.png</file>
+diff --git a/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp b/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
+index c5b845f4ec..5a5ba1d0a8 100644
+--- a/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
++++ b/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
+@@ -702,13 +702,14 @@ void QPrintDialogPrivate::selectPrinter(const QPrinter::OutputFormat outputForma
+         else
+             options.grayscale->setChecked(true);
+ 
+-        // keep duplex value explicitly set by user, if any, and selected printer supports it;
+-        // use device default otherwise
++        // duplex priorities to be as follows:
++        // 1) a user-selected duplex value in the dialog has highest prority
++        // 2) duplex value set in the QPrinter
+         QPrint::DuplexMode duplex;
+         if (explicitDuplexMode != QPrint::DuplexAuto && supportedDuplexMode.contains(explicitDuplexMode))
+             duplex = explicitDuplexMode;
+         else
+-            duplex = top->d->m_currentPrintDevice.defaultDuplexMode();
++            duplex = static_cast<QPrint::DuplexMode>(p->duplex());
+         switch (duplex) {
+         case QPrint::DuplexNone:
+             options.noDuplex->setChecked(true); break;
+@@ -1242,10 +1243,10 @@ void QUnixPrintWidgetPrivate::_q_printerChanged(int index)
+             QString filename = widget.filename->text();
+             widget.filename->setText(filename);
+             widget.lOutput->setEnabled(true);
+-            if (optionsPane)
+-                optionsPane->selectPrinter(QPrinter::PdfFormat);
+             printer->setOutputFormat(QPrinter::PdfFormat);
+             m_currentPrintDevice = QPrintDevice();
++            if (optionsPane)
++                optionsPane->selectPrinter(QPrinter::PdfFormat);
+             return;
+         }
+     }
+diff --git a/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp b/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
+index 39575d5f57..23b7e89538 100644
+--- a/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
++++ b/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
+@@ -352,7 +352,7 @@ void QPrintPreviewDialogPrivate::init(QPrinter *_printer)
+ static inline void qt_setupActionIcon(QAction *action, QLatin1String name)
+ {
+     QLatin1String imagePrefix(":/qt-project.org/dialogs/qprintpreviewdialog/images/");
+-    QIcon icon;
++    QIcon icon = QIcon::fromTheme(name);
+     icon.addFile(imagePrefix + name + QLatin1String("-24.png"), QSize(24, 24));
+     icon.addFile(imagePrefix + name + QLatin1String("-32.png"), QSize(32, 32));
+     action->setIcon(icon);
+@@ -383,8 +383,8 @@ void QPrintPreviewDialogPrivate::setupActions()
+     fitPageAction->setObjectName(QLatin1String("fitPageAction"));
+     fitWidthAction->setCheckable(true);
+     fitPageAction->setCheckable(true);
+-    qt_setupActionIcon(fitWidthAction, QLatin1String("fit-width"));
+-    qt_setupActionIcon(fitPageAction, QLatin1String("fit-page"));
++    qt_setupActionIcon(fitWidthAction, QLatin1String("zoom-fit-width"));
++    qt_setupActionIcon(fitPageAction, QLatin1String("zoom-fit-page"));
+     QObject::connect(fitGroup, SIGNAL(triggered(QAction*)), q, SLOT(_q_fit(QAction*)));
+ 
+     // Zoom
+@@ -410,9 +410,9 @@ void QPrintPreviewDialogPrivate::setupActions()
+     singleModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show single page"));
+     facingModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show facing pages"));
+     overviewModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show overview of all pages"));
+-    qt_setupActionIcon(singleModeAction, QLatin1String("view-page-one"));
+-    qt_setupActionIcon(facingModeAction, QLatin1String("view-page-sided"));
+-    qt_setupActionIcon(overviewModeAction, QLatin1String("view-page-multi"));
++    qt_setupActionIcon(singleModeAction, QLatin1String("view-pages-single"));
++    qt_setupActionIcon(facingModeAction, QLatin1String("view-pages-facing"));
++    qt_setupActionIcon(overviewModeAction, QLatin1String("view-pages-overview"));
+     singleModeAction->setObjectName(QLatin1String("singleModeAction"));
+     facingModeAction->setObjectName(QLatin1String("facingModeAction"));
+     overviewModeAction->setObjectName(QLatin1String("overviewModeAction"));
+@@ -426,7 +426,7 @@ void QPrintPreviewDialogPrivate::setupActions()
+     printerGroup = new QActionGroup(q);
+     printAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Print"));
+     pageSetupAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Page setup"));
+-    qt_setupActionIcon(printAction, QLatin1String("print"));
++    qt_setupActionIcon(printAction, QLatin1String("printer"));
+     qt_setupActionIcon(pageSetupAction, QLatin1String("page-setup"));
+     QObject::connect(printAction, SIGNAL(triggered(bool)), q, SLOT(_q_print()));
+     QObject::connect(pageSetupAction, SIGNAL(triggered(bool)), q, SLOT(_q_pageSetup()));
+diff --git a/qtbase/src/sql/kernel/qsqlquery.cpp b/qtbase/src/sql/kernel/qsqlquery.cpp
+index 32c6166c79..60afef10c3 100644
+--- a/qtbase/src/sql/kernel/qsqlquery.cpp
++++ b/qtbase/src/sql/kernel/qsqlquery.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2022 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtSql module of the Qt Toolkit.
+@@ -377,6 +377,10 @@ bool QSqlQuery::exec(const QString& query)
+     QElapsedTimer t;
+     t.start();
+ #endif
++    if (!driver()) {
++        qWarning("QSqlQuery::exec: called before driver has been set up");
++        return false;
++    }
+     if (d->ref.loadRelaxed() != 1) {
+         bool fo = isForwardOnly();
+         *this = QSqlQuery(driver()->createResult());
+diff --git a/qtbase/src/testlib/qabstractitemmodeltester.cpp b/qtbase/src/testlib/qabstractitemmodeltester.cpp
+index 8efb9c53d4..ce062f66d7 100644
+--- a/qtbase/src/testlib/qabstractitemmodeltester.cpp
++++ b/qtbase/src/testlib/qabstractitemmodeltester.cpp
+@@ -454,7 +454,7 @@ void QAbstractItemModelTesterPrivate::parent()
+ 
+     // Common error test #2, make sure that a second level index has a parent
+     // that is the first level index.
+-    if (model->rowCount(topIndex) > 0) {
++    if (model->rowCount(topIndex) > 0 && model->columnCount(topIndex) > 0) {
+         QModelIndex childIndex = model->index(0, 0, topIndex);
+         MODELTESTER_VERIFY(childIndex.isValid());
+         MODELTESTER_COMPARE(model->parent(childIndex), topIndex);
+diff --git a/qtbase/src/testlib/qasciikey.cpp b/qtbase/src/testlib/qasciikey.cpp
+index 9a308da2bc..93498b256f 100644
+--- a/qtbase/src/testlib/qasciikey.cpp
++++ b/qtbase/src/testlib/qasciikey.cpp
+@@ -498,6 +498,11 @@ char QTest::keyToAscii(Qt::Key key)
+     case Qt::Key_LaunchE : return 0; // = 0x10b0,
+     case Qt::Key_LaunchF : return 0; // = 0x10b1,
+ 
++    // Keypad navigation keys
++    case Qt::Key_Select : return 0; // = 0x01010000
++    case Qt::Key_Yes : return 0; // = 0x01010001
++    case Qt::Key_No : return 0; // = 0x01010002
++
+     default: QTEST_ASSERT(false); return 0;
+     }
+ }
+diff --git a/qtbase/src/testlib/qtestresult.cpp b/qtbase/src/testlib/qtestresult.cpp
+index 88028aac6e..2e89930776 100644
+--- a/qtbase/src/testlib/qtestresult.cpp
++++ b/qtbase/src/testlib/qtestresult.cpp
+@@ -251,7 +251,8 @@ bool QTestResult::verify(bool statement, const char *statementStr,
+ {
+     QTEST_ASSERT(statementStr);
+ 
+-    char msg[1024] = {'\0'};
++    char msg[1024];
++    msg[0] = '\0';
+ 
+     if (QTestLog::verboseLevel() >= 2) {
+         qsnprintf(msg, 1024, "QVERIFY(%s)", statementStr);
+@@ -309,7 +310,8 @@ static bool compareHelper(bool success, const char *failureMsg,
+                           bool hasValues = true)
+ {
+     const size_t maxMsgLen = 1024;
+-    char msg[maxMsgLen] = {'\0'};
++    char msg[maxMsgLen];
++    msg[0] = '\0';
+ 
+     QTEST_ASSERT(expected);
+     QTEST_ASSERT(actual);
+diff --git a/qtbase/src/widgets/dialogs/qcolordialog.cpp b/qtbase/src/widgets/dialogs/qcolordialog.cpp
+index 4247731275..cb325be85c 100644
+--- a/qtbase/src/widgets/dialogs/qcolordialog.cpp
++++ b/qtbase/src/widgets/dialogs/qcolordialog.cpp
+@@ -78,7 +78,10 @@
+ #include "qwindow.h"
+ 
+ #include "private/qdialog_p.h"
++#include "private/qguiapplication_p.h"
+ 
++#include <qpa/qplatformservices.h>
++#include <qpa/qplatformintegration.h>
+ #include <algorithm>
+ 
+ QT_BEGIN_NAMESPACE
+@@ -1611,6 +1614,20 @@ void QColorDialogPrivate::_q_newStandard(int r, int c)
+ void QColorDialogPrivate::_q_pickScreenColor()
+ {
+     Q_Q(QColorDialog);
++
++    auto *platformServices = QGuiApplicationPrivate::platformIntegration()->services();
++    if (platformServices->hasCapability(QPlatformServices::Capability::ColorPicking)) {
++        if (auto *colorPicker = platformServices->colorPicker(q->windowHandle())) {
++            q->connect(colorPicker, &QPlatformServiceColorPicker::colorPicked, q,
++                       [q, colorPicker](const QColor &color) {
++                           colorPicker->deleteLater();
++                           q->setCurrentColor(color);
++                       });
++            colorPicker->pickColor();
++            return;
++        }
++    }
++
+     if (!colorPickingEventFilter)
+         colorPickingEventFilter = new QColorPickingEventFilter(this, q);
+     q->installEventFilter(colorPickingEventFilter);
+diff --git a/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp b/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
+index e120817edc..8ea36b5427 100644
+--- a/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
++++ b/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
+@@ -400,12 +400,7 @@ bool QAbstractItemDelegate::helpEvent(QHelpEvent *event,
+         const QString tooltip = index.isValid() ?
+               d->textForRole(Qt::ToolTipRole, index.data(Qt::ToolTipRole), option.locale, precision) :
+               QString();
+-        QRect rect;
+-        if (index.isValid()) {
+-            const QRect r = view->visualRect(index);
+-            rect = QRect(view->mapToGlobal(r.topLeft()), r.size());
+-        }
+-        QToolTip::showText(he->globalPos(), tooltip, view, rect);
++        QToolTip::showText(he->globalPos(), tooltip, view->viewport(), option.rect);
+         event->setAccepted(!tooltip.isEmpty());
+         break;
+         }
+diff --git a/qtbase/src/widgets/itemviews/qlistview.cpp b/qtbase/src/widgets/itemviews/qlistview.cpp
+index 2b34476642..eebfaa030e 100644
+--- a/qtbase/src/widgets/itemviews/qlistview.cpp
++++ b/qtbase/src/widgets/itemviews/qlistview.cpp
+@@ -3386,6 +3386,7 @@ void QIconModeViewBase::updateContentsSize()
+ */
+ void QListView::currentChanged(const QModelIndex &current, const QModelIndex &previous)
+ {
++    QAbstractItemView::currentChanged(current, previous);
+ #ifndef QT_NO_ACCESSIBILITY
+     if (QAccessible::isActive()) {
+         if (current.isValid()) {
+@@ -3396,7 +3397,6 @@ void QListView::currentChanged(const QModelIndex &current, const QModelIndex &pr
+         }
+     }
+ #endif
+-    QAbstractItemView::currentChanged(current, previous);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/widgets/itemviews/qtableview.cpp b/qtbase/src/widgets/itemviews/qtableview.cpp
+index 934ac581b2..f79bb24249 100644
+--- a/qtbase/src/widgets/itemviews/qtableview.cpp
++++ b/qtbase/src/widgets/itemviews/qtableview.cpp
+@@ -1013,6 +1013,7 @@ void QTableViewPrivate::drawCell(QPainter *painter, const QStyleOptionViewItem &
+ int QTableViewPrivate::widthHintForIndex(const QModelIndex &index, int hint, const QStyleOptionViewItem &option) const
+ {
+     Q_Q(const QTableView);
++    const int oldHint = hint;
+     QWidget *editor = editorForIndex(index).widget.data();
+     if (editor && persistent.contains(editor)) {
+         hint = qMax(hint, editor->sizeHint().width());
+@@ -1021,6 +1022,17 @@ int QTableViewPrivate::widthHintForIndex(const QModelIndex &index, int hint, con
+         hint = qBound(min, hint, max);
+     }
+     hint = qMax(hint, q->itemDelegate(index)->sizeHint(option, index).width());
++
++    if (hasSpans()) {
++        auto span = spans.spanAt(index.column(), index.row());
++        if (span && span->m_left == index.column() && span->m_top == index.row()) {
++            // spans are screwed up when sections are moved
++            const auto left = logicalColumn(span->m_left);
++            for (int i = 1; i <= span->width(); ++i)
++               hint -= q->columnWidth(visualColumn(left + i));
++        }
++        hint = std::max(hint, oldHint);
++    }
+     return hint;
+ }
+ 
+@@ -1053,6 +1065,11 @@ int QTableViewPrivate::heightHintForIndex(const QModelIndex &index, int hint, QS
+         option.rect.setHeight(height);
+         option.rect.setX(q->columnViewportPosition(index.column()));
+         option.rect.setWidth(q->columnWidth(index.column()));
++        if (hasSpans()) {
++            auto span = spans.spanAt(index.column(), index.row());
++            if (span && span->m_left == index.column() && span->m_top == index.row())
++                option.rect.setWidth(std::max(option.rect.width(), visualSpanRect(*span).width()));
++        }
+         // 1px less space when grid is shown (see drawCell)
+         if (showGrid)
+             option.rect.setWidth(option.rect.width() - 1);
+diff --git a/qtbase/src/widgets/kernel/qaction.h b/qtbase/src/widgets/kernel/qaction.h
+index 258a1ea0a0..737c1e8285 100644
+--- a/qtbase/src/widgets/kernel/qaction.h
++++ b/qtbase/src/widgets/kernel/qaction.h
+@@ -81,7 +81,7 @@ class Q_WIDGETS_EXPORT QAction : public QObject
+     Q_PROPERTY(MenuRole menuRole READ menuRole WRITE setMenuRole NOTIFY changed)
+     Q_PROPERTY(bool iconVisibleInMenu READ isIconVisibleInMenu WRITE setIconVisibleInMenu NOTIFY changed)
+     Q_PROPERTY(bool shortcutVisibleInContextMenu READ isShortcutVisibleInContextMenu WRITE setShortcutVisibleInContextMenu NOTIFY changed)
+-    Q_PROPERTY(Priority priority READ priority WRITE setPriority)
++    Q_PROPERTY(Priority priority READ priority WRITE setPriority NOTIFY changed)
+ 
+ public:
+     // note this is copied into qplatformmenu.h, which must stay in sync
+diff --git a/qtbase/src/widgets/kernel/qwidget.cpp b/qtbase/src/widgets/kernel/qwidget.cpp
+index 9eba1e001e..26f6d27e18 100644
+--- a/qtbase/src/widgets/kernel/qwidget.cpp
++++ b/qtbase/src/widgets/kernel/qwidget.cpp
+@@ -5296,7 +5296,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
+         QWidgetEffectSourcePrivate *sourced = static_cast<QWidgetEffectSourcePrivate *>
+                                                          (source->d_func());
+         if (!sourced->context) {
+-            const QRegion effectRgn(rgn.boundingRect());
++            const QRegion effectRgn((flags & UseEffectRegionBounds) ? rgn.boundingRect() : rgn);
+             QWidgetPaintContext context(pdev, effectRgn, offset, flags, sharedPainter, repaintManager);
+             sourced->context = &context;
+             if (!sharedPainter) {
+@@ -5328,6 +5328,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
+         }
+     }
+ #endif // QT_CONFIG(graphicseffect)
++    flags = flags & ~UseEffectRegionBounds;
+ 
+     const bool alsoOnScreen = flags & DrawPaintOnScreen;
+     const bool recursive = flags & DrawRecursive;
+diff --git a/qtbase/src/widgets/kernel/qwidget_p.h b/qtbase/src/widgets/kernel/qwidget_p.h
+index eef6b8fa2c..c432f4b5d5 100644
+--- a/qtbase/src/widgets/kernel/qwidget_p.h
++++ b/qtbase/src/widgets/kernel/qwidget_p.h
+@@ -229,7 +229,8 @@ public:
+         DontSubtractOpaqueChildren = 0x10,
+         DontDrawOpaqueChildren = 0x20,
+         DontDrawNativeChildren = 0x40,
+-        DontSetCompositionMode = 0x80
++        DontSetCompositionMode = 0x80,
++        UseEffectRegionBounds = 0x100
+     };
+     Q_DECLARE_FLAGS(DrawWidgetFlags, DrawWidgetFlag)
+     Q_FLAG(DrawWidgetFlags)
+diff --git a/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp b/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
+index 02880b34da..0d44e1326d 100644
+--- a/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
++++ b/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
+@@ -1018,7 +1018,8 @@ void QWidgetRepaintManager::paintAndFlush()
+ 
+     // Paint the rest with composition.
+     if (repaintAllWidgets || !dirtyCopy.isEmpty()) {
+-        QWidgetPrivate::DrawWidgetFlags flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive;
++        QWidgetPrivate::DrawWidgetFlags flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive
++                | QWidgetPrivate::UseEffectRegionBounds;
+         tlw->d_func()->drawWidget(store->paintDevice(), dirtyCopy, QPoint(), flags, nullptr, this);
+     }
+ 
+diff --git a/qtbase/src/widgets/styles/qfusionstyle.cpp b/qtbase/src/widgets/styles/qfusionstyle.cpp
+index f4345d97c4..962912c838 100644
+--- a/qtbase/src/widgets/styles/qfusionstyle.cpp
++++ b/qtbase/src/widgets/styles/qfusionstyle.cpp
+@@ -1772,14 +1772,6 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio
+             proxy()->drawControl(CE_PushButtonLabel, &subopt, painter, widget);
+         }
+         break;
+-    case CE_PushButtonLabel:
+-        if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
+-            QStyleOptionButton b(*button);
+-            // no PM_ButtonShiftHorizontal and PM_ButtonShiftVertical for fusion style
+-            b.state &= ~(State_On | State_Sunken);
+-            QCommonStyle::drawControl(element, &b, painter, widget);
+-        }
+-        break;
+     case CE_MenuBarEmptyArea:
+         painter->save();
+     {
+diff --git a/qtbase/src/widgets/util/qcompleter.cpp b/qtbase/src/widgets/util/qcompleter.cpp
+index 18b24063d8..ef7207a8a3 100644
+--- a/qtbase/src/widgets/util/qcompleter.cpp
++++ b/qtbase/src/widgets/util/qcompleter.cpp
+@@ -1120,6 +1120,8 @@ void QCompleter::setModel(QAbstractItemModel *model)
+ {
+     Q_D(QCompleter);
+     QAbstractItemModel *oldModel = d->proxy->sourceModel();
++    if (oldModel == model)
++        return;
+ #if QT_CONFIG(filesystemmodel)
+     if (qobject_cast<const QFileSystemModel *>(oldModel))
+         setCompletionRole(Qt::EditRole); // QTBUG-54642, clear FileNameRole set by QFileSystemModel
+diff --git a/qtbase/src/widgets/widgets/qabstractbutton.cpp b/qtbase/src/widgets/widgets/qabstractbutton.cpp
+index a128b23950..dc40bf62fb 100644
+--- a/qtbase/src/widgets/widgets/qabstractbutton.cpp
++++ b/qtbase/src/widgets/widgets/qabstractbutton.cpp
+@@ -56,6 +56,7 @@
+ #ifndef QT_NO_ACCESSIBILITY
+ #include "qaccessible.h"
+ #endif
++#include <qpa/qplatformtheme.h>
+ 
+ #include <algorithm>
+ 
+@@ -1076,19 +1077,19 @@ void QAbstractButton::keyPressEvent(QKeyEvent *e)
+ {
+     Q_D(QAbstractButton);
+     bool next = true;
+-    switch (e->key()) {
+-    case Qt::Key_Enter:
+-    case Qt::Key_Return:
+-        e->ignore();
+-        break;
+-    case Qt::Key_Select:
+-    case Qt::Key_Space:
+-        if (!e->isAutoRepeat()) {
+-            setDown(true);
+-            repaint();
+-            d->emitPressed();
+-        }
+-        break;
++
++    const auto key = static_cast<Qt::Key>(e->key());
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(key) && !e->isAutoRepeat()) {
++        setDown(true);
++        repaint();
++        d->emitPressed();
++        return;
++    }
++
++    switch (key) {
+     case Qt::Key_Up:
+         next = false;
+         Q_FALLTHROUGH();
+@@ -1153,15 +1154,15 @@ void QAbstractButton::keyReleaseEvent(QKeyEvent *e)
+     if (!e->isAutoRepeat())
+         d->repeatTimer.stop();
+ 
+-    switch (e->key()) {
+-    case Qt::Key_Select:
+-    case Qt::Key_Space:
+-        if (!e->isAutoRepeat() && d->down)
+-            d->click();
+-        break;
+-    default:
+-        e->ignore();
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(static_cast<Qt::Key>(e->key())) && !e->isAutoRepeat() && d->down) {
++        d->click();
++        return;
+     }
++
++    e->ignore();
+ }
+ 
+ /*!\reimp
+diff --git a/qtbase/src/widgets/widgets/qcombobox.cpp b/qtbase/src/widgets/widgets/qcombobox.cpp
+index 7a496c27e0..0a3d96647b 100644
+--- a/qtbase/src/widgets/widgets/qcombobox.cpp
++++ b/qtbase/src/widgets/widgets/qcombobox.cpp
+@@ -3352,7 +3352,23 @@ void QComboBox::keyPressEvent(QKeyEvent *e)
+ 
+     Move move = NoMove;
+     int newIndex = currentIndex();
+-    switch (e->key()) {
++
++    bool pressLikeButton = !d->lineEdit;
++#ifdef QT_KEYPAD_NAVIGATION
++    pressLikeButton |= QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus();
++#endif
++    auto key = static_cast<Qt::Key>(e->key());
++    if (pressLikeButton) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(key)) {
++            showPopup();
++            return;
++        }
++    }
++
++    switch (key) {
+     case Qt::Key_Up:
+         if (e->modifiers() & Qt::ControlModifier)
+             break; // pass to line edit for auto completion
+@@ -3394,26 +3410,11 @@ void QComboBox::keyPressEvent(QKeyEvent *e)
+             return;
+         }
+         break;
+-    case Qt::Key_Space:
+-        if (!d->lineEdit) {
+-            showPopup();
+-            return;
+-        }
+-        break;
+-    case Qt::Key_Enter:
+-    case Qt::Key_Return:
+     case Qt::Key_Escape:
+         if (!d->lineEdit)
+             e->ignore();
+         break;
+ #ifdef QT_KEYPAD_NAVIGATION
+-    case Qt::Key_Select:
+-        if (QApplicationPrivate::keypadNavigationEnabled()
+-                && (!hasEditFocus() || !d->lineEdit)) {
+-            showPopup();
+-            return;
+-        }
+-        break;
+     case Qt::Key_Left:
+     case Qt::Key_Right:
+         if (QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus())
+diff --git a/qtbase/src/widgets/widgets/qdatetimeedit_p.h b/qtbase/src/widgets/widgets/qdatetimeedit_p.h
+index d36b6f8f9a..e0df5b5158 100644
+--- a/qtbase/src/widgets/widgets/qdatetimeedit_p.h
++++ b/qtbase/src/widgets/widgets/qdatetimeedit_p.h
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2018 The Qt Company Ltd.
++** Copyright (C) 2021 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtWidgets module of the Qt Toolkit.
+diff --git a/qtbase/src/widgets/widgets/qgroupbox.cpp b/qtbase/src/widgets/widgets/qgroupbox.cpp
+index 02a0bed325..3f3eccc370 100644
+--- a/qtbase/src/widgets/widgets/qgroupbox.cpp
++++ b/qtbase/src/widgets/widgets/qgroupbox.cpp
+@@ -54,6 +54,8 @@
+ #include "qaccessible.h"
+ #endif
+ #include <private/qwidget_p.h>
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
+ 
+ #include "qdebug.h"
+ 
+@@ -360,7 +362,10 @@ bool QGroupBox::event(QEvent *e)
+         return true;
+     case QEvent::KeyPress: {
+         QKeyEvent *k = static_cast<QKeyEvent*>(e);
+-        if (!k->isAutoRepeat() && (k->key() == Qt::Key_Select || k->key() == Qt::Key_Space)) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (!k->isAutoRepeat() && buttonPressKeys.contains(static_cast<Qt::Key>(k->key()))) {
+             d->pressedControl = QStyle::SC_GroupBoxCheckBox;
+             update(style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxCheckBox, this));
+             return true;
+@@ -369,7 +374,10 @@ bool QGroupBox::event(QEvent *e)
+     }
+     case QEvent::KeyRelease: {
+         QKeyEvent *k = static_cast<QKeyEvent*>(e);
+-        if (!k->isAutoRepeat() && (k->key() == Qt::Key_Select || k->key() == Qt::Key_Space)) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (!k->isAutoRepeat() && buttonPressKeys.contains(static_cast<Qt::Key>(k->key()))) {
+             bool toggle = (d->pressedControl == QStyle::SC_GroupBoxLabel
+                            || d->pressedControl == QStyle::SC_GroupBoxCheckBox);
+             d->pressedControl = QStyle::SC_None;
+diff --git a/qtbase/src/widgets/widgets/qlabel.cpp b/qtbase/src/widgets/widgets/qlabel.cpp
+index 30ff80cbb0..cf2605c17c 100644
+--- a/qtbase/src/widgets/widgets/qlabel.cpp
++++ b/qtbase/src/widgets/widgets/qlabel.cpp
+@@ -421,9 +421,6 @@ void QLabel::setPixmap(const QPixmap &pixmap)
+         d->pixmap = new QPixmap(pixmap);
+     }
+ 
+-    if (d->pixmap->depth() == 1 && !d->pixmap->mask())
+-        d->pixmap->setMask(*((QBitmap *)d->pixmap));
+-
+     d->updateLabel();
+ }
+ 
+diff --git a/qtbase/src/widgets/widgets/qtoolbararealayout.cpp b/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
+index 493c094cc1..d5f4b59017 100644
+--- a/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
++++ b/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
+@@ -1367,7 +1367,7 @@ bool QToolBarAreaLayout::restoreState(QDataStream &stream, const QList<QToolBar*
+                 item.widgetItem = new QWidgetItemV2(toolBar);
+                 toolBar->setOrientation(floating ? ((shown & 2) ? Qt::Vertical : Qt::Horizontal) : dock.o);
+                 toolBar->setVisible(shown & 1);
+-                toolBar->d_func()->setWindowState(floating, true, rect);
++                toolBar->d_func()->setWindowState(floating, false, rect);
+ 
+                 item.preferredSize = item.size;
+                 line.toolBarItems.append(item);
+diff --git a/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp b/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
+index 212c0a2e13..3c77b1ba0b 100644
+--- a/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
++++ b/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
+@@ -126,8 +126,7 @@ public:
+ 
+ void tst_QtConcurrentIterateKernel::instantiate()
+ {
+-    auto future = startThreadEngine(new PrintFor(0, 40)).startAsynchronously();
+-    future.waitForFinished();
++    startThreadEngine(new PrintFor(0, 40)).startBlocking();
+     QCOMPARE(iterations.loadRelaxed(), 40);
+ }
+ 
+@@ -166,10 +165,8 @@ void tst_QtConcurrentIterateKernel::stresstest()
+     const int times = 50;
+     for (int i = 0; i < times; ++i) {
+         counter.storeRelaxed(0);
+-        // ThreadEngine will delete f when it finishes
+-        auto f = new CountFor(0, iterations);
+-        auto future = f->startAsynchronously();
+-        future.waitForFinished();
++        CountFor f(0, iterations);
++        f.startBlocking();
+         QCOMPARE(counter.loadRelaxed(), iterations);
+     }
+ }
+@@ -177,11 +174,8 @@ void tst_QtConcurrentIterateKernel::stresstest()
+ void tst_QtConcurrentIterateKernel::noIterations()
+ {
+     const int times = 20000;
+-    for (int i = 0; i < times; ++i) {
+-        auto future = startThreadEngine(new IterateKernel<TestIterator, void>(0, 0))
+-                              .startAsynchronously();
+-        future.waitForFinished();
+-    }
++    for (int i = 0; i < times; ++i)
++        startThreadEngine(new IterateKernel<TestIterator, void>(0, 0)).startBlocking();
+ }
+ 
+ QMutex threadsMutex;
+@@ -236,10 +230,8 @@ void tst_QtConcurrentIterateKernel::throttling()
+ 
+     threads.clear();
+ 
+-    // ThreadEngine will delete f when it finishes
+-    auto f = new ThrottleFor(0, totalIterations);
+-    auto future = f->startAsynchronously();
+-    future.waitForFinished();
++    ThrottleFor f(0, totalIterations);
++    f.startBlocking();
+ 
+     QCOMPARE(iterations.loadRelaxed(), totalIterations);
+ 
+diff --git a/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp b/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
+index ac7be7acdd..81bc64c8d9 100644
+--- a/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
++++ b/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
+@@ -65,9 +65,16 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::runDirectly()
+ {
+-    PrintUser *engine = new PrintUser();
+-    QFuture<void> f = engine->startAsynchronously();
+-    f.waitForFinished();
++    {
++        PrintUser engine;
++        engine.startSingleThreaded();
++        engine.startBlocking();
++    }
++    {
++        PrintUser *engine = new PrintUser();
++        QFuture<void> f = engine->startAsynchronously();
++        f.waitForFinished();
++    }
+ }
+ 
+ class StringResultUser : public ThreadEngine<QString>
+@@ -99,10 +106,8 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::result()
+ {
+-    // ThreadEngine will delete 'engine' when it finishes
+-    auto engine = new StringResultUser();
+-    auto future = engine->startAsynchronously();
+-    QCOMPARE(future.result(), QString("Foo"));
++    StringResultUser engine;
++    QCOMPARE(*engine.startBlocking(), QString("Foo"));
+ }
+ 
+ class VoidResultUser : public ThreadEngine<void>
+@@ -128,9 +133,17 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::runThroughStarter()
+ {
+-    ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
+-    QFuture<QString> f = starter.startAsynchronously();
+-    QCOMPARE(f.result(), QString("Foo"));
++    {
++        ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
++        QFuture<QString>  f = starter.startAsynchronously();
++        QCOMPARE(f.result(), QString("Foo"));
++    }
++
++    {
++        ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
++        QString str = starter.startBlocking();
++        QCOMPARE(str, QString("Foo"));
++    }
+ }
+ 
+ class CancelUser : public ThreadEngine<void>
+@@ -213,6 +226,12 @@ void tst_QtConcurrentThreadEngine::throttle()
+         f.waitForFinished();
+         QCOMPARE(count.loadRelaxed(), 0);
+     }
++
++    for (int i = 0; i < repeats; ++i) {
++        ThrottleAlwaysUser t;
++        t.startBlocking();
++        QCOMPARE(count.loadRelaxed(), 0);
++    }
+ }
+ 
+ QSet<QThread *> threads;
+@@ -249,17 +268,35 @@ void tst_QtConcurrentThreadEngine::threadCount()
+ {
+     const int repeats = 10;
+     for (int i = 0; i < repeats; ++i) {
++        ThreadCountUser t;
++        t.startBlocking();
++        int count = threads.count();
++        int count_expected = QThreadPool::globalInstance()->maxThreadCount() + 1; // +1 for the main thread.
++        if (count != count_expected)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, count_expected);
++
+         (new ThreadCountUser())->startAsynchronously().waitForFinished();
+-        const auto count = threads.count();
+-        const auto maxThreadCount = QThreadPool::globalInstance()->maxThreadCount();
+-        QVERIFY(count <= maxThreadCount);
+-        QVERIFY(!threads.contains(QThread::currentThread()));
++        count = threads.count();
++        count_expected = QThreadPool::globalInstance()->maxThreadCount();
++        if (count != count_expected)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, count_expected);
+     }
+ 
+     // Set the finish flag immediately, this should give us one thread only.
+     for (int i = 0; i < repeats; ++i) {
++        ThreadCountUser t(true /*finishImmediately*/);
++        t.startBlocking();
++        int count = threads.count();
++        if (count != 1)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, 1);
++
+         (new ThreadCountUser(true /*finishImmediately*/))->startAsynchronously().waitForFinished();
+-        const auto count = threads.count();
++        count = threads.count();
++        if (count != 1)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
+         QCOMPARE(count, 1);
+         QVERIFY(!threads.contains(QThread::currentThread()));
+     }
+@@ -400,6 +437,7 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::exceptions()
+ {
++    // Asynchronous mode:
+     {
+         bool caught = false;
+         try  {
+@@ -412,6 +450,32 @@ void tst_QtConcurrentThreadEngine::exceptions()
+         QVERIFY2(caught, "did not get exception");
+     }
+ 
++    // Blocking mode:
++    // test throwing the exception from a worker thread.
++    {
++        bool caught = false;
++        try  {
++            QtConcurrentExceptionThrower e(QThread::currentThread());
++            e.startBlocking();
++        } catch (const QException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // test throwing the exception from the main thread (different code path)
++    {
++        bool caught = false;
++        try  {
++            QtConcurrentExceptionThrower e(0);
++            e.startBlocking();
++        } catch (const QException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // Asynchronous mode:
+     {
+         bool caught = false;
+         try  {
+@@ -423,6 +487,31 @@ void tst_QtConcurrentThreadEngine::exceptions()
+         }
+         QVERIFY2(caught, "did not get exception");
+     }
++
++    // Blocking mode:
++    // test throwing the exception from a worker thread.
++    {
++        bool caught = false;
++        try  {
++            UnrelatedExceptionThrower e(QThread::currentThread());
++            e.startBlocking();
++        } catch (const QUnhandledException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // test throwing the exception from the main thread (different code path)
++    {
++        bool caught = false;
++        try  {
++            UnrelatedExceptionThrower e(0);
++            e.startBlocking();
++        } catch (const QUnhandledException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
+ }
+ 
+ #endif
+diff --git a/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp b/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
+index 4968742110..f4c3fb711d 100644
+--- a/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
++++ b/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
+@@ -42,6 +42,7 @@ private slots:
+     void writeBlock_data();
+     void writeBlock();
+     void seek();
++    void invalidSeeks();
+     void seekTest_data();
+     void seekTest();
+     void read_rawdata();
+@@ -286,6 +287,29 @@ void tst_QBuffer::seek()
+     QCOMPARE(buffer.size(), pos);
+ }
+ 
++void tst_QBuffer::invalidSeeks()
++{
++    if constexpr (sizeof(qsizetype) == sizeof(qint64)) {
++        // sizeof(qsizetype) == sizeof(qint64), so +1 would overflow
++        QSKIP("This is a 32-bit-only test.");
++    } else {
++        QBuffer buffer;
++        buffer.open(QIODevice::WriteOnly);
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++        constexpr qint64 MaxQByteArrayCapacity = (std::numeric_limits<qsizetype>::max)();
++        // this should fail fast, not after trying to allocate nearly 2 GiB of data,
++        // potentially crashing in the process:
++        QVERIFY(!buffer.seek(2 * MaxQByteArrayCapacity - 1));
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++        // ditto:
++        QVERIFY(!buffer.seek(MaxQByteArrayCapacity + 1));
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++    }
++}
++
+ void tst_QBuffer::seekTest_data()
+ {
+     writeBlock_data();
+diff --git a/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp b/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
+index da5327594c..4a04e0f7c6 100644
+--- a/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
++++ b/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
+@@ -561,7 +561,8 @@ protected:
+     qint64 readData(char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf->size() - offset));
+-        memcpy(data, buf->constData() + offset, maxSize);
++        if (maxSize > 0)
++            memcpy(data, buf->constData() + offset, maxSize);
+         offset += maxSize;
+         return maxSize;
+     }
+@@ -604,13 +605,15 @@ protected:
+     qint64 readData(char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf.size() - pos()));
+-        memcpy(data, buf.constData() + pos(), maxSize);
++        if (maxSize > 0)
++            memcpy(data, buf.constData() + pos(), maxSize);
+         return maxSize;
+     }
+     qint64 writeData(const char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf.size() - pos()));
+-        memcpy(buf.data() + pos(), data, maxSize);
++        if (maxSize > 0)
++            memcpy(buf.data() + pos(), data, maxSize);
+         return maxSize;
+     }
+ 
+diff --git a/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+index db60bead64..f345a44414 100644
+--- a/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
++++ b/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+@@ -1,7 +1,8 @@
+ /****************************************************************************
+ **
+ ** Copyright (C) 2021 The Qt Company Ltd.
+-** Copyright (C) 2020 Intel Corporation.
++** Copyright (C) 2020 The Qt Company Ltd.
++** Copyright (C) 2022 Intel Corporation.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the test suite of the Qt Toolkit.
+@@ -150,6 +151,8 @@ private slots:
+     void startStopStartStopBuffers();
+     void processEventsInAReadyReadSlot_data();
+     void processEventsInAReadyReadSlot();
++    void startFromCurrentWorkingDir_data();
++    void startFromCurrentWorkingDir();
+ 
+     // keep these at the end, since they use lots of processes and sometimes
+     // caused obscure failures to occur in tests that followed them (esp. on the Mac)
+@@ -2731,5 +2734,94 @@ void tst_QProcess::finishProcessBeforeReadingDone_deprecated()
+ 
+ #endif
+ 
++enum class ChdirMode {
++    None = 0,
++    InParent,
++    InChild
++};
++Q_DECLARE_METATYPE(ChdirMode)
++
++void tst_QProcess::startFromCurrentWorkingDir_data()
++{
++    qRegisterMetaType<ChdirMode>();
++    QTest::addColumn<QString>("programPrefix");
++    QTest::addColumn<ChdirMode>("chdirMode");
++    QTest::addColumn<bool>("success");
++
++    constexpr bool IsWindows = true
++#ifdef Q_OS_UNIX
++            && false
++#endif
++            ;
++
++    // baseline: trying to execute the directory, this can't possibly succeed!
++    QTest::newRow("plain-same-cwd") << QString() << ChdirMode::None << false;
++
++    // cross-platform behavior: neither OS searches the setWorkingDirectory()
++    // dir without "./"
++    QTest::newRow("plain-child-chdir") << QString() << ChdirMode::InChild << false;
++
++    // cross-platform behavior: both OSes search the parent's CWD with "./"
++    QTest::newRow("prefixed-parent-chdir") << "./" << ChdirMode::InParent << true;
++
++    // opposite behaviors: Windows searches the parent's CWD and Unix searches
++    // the child's with "./"
++    QTest::newRow("prefixed-child-chdir") << "./" << ChdirMode::InChild << !IsWindows;
++
++    // Windows searches the parent's CWD without "./"
++    QTest::newRow("plain-parent-chdir") << QString() << ChdirMode::InParent << IsWindows;
++}
++
++void tst_QProcess::startFromCurrentWorkingDir()
++{
++    QFETCH(QString, programPrefix);
++    QFETCH(ChdirMode, chdirMode);
++    QFETCH(bool, success);
++
++    QProcess process;
++    qRegisterMetaType<QProcess::ProcessError>();
++    QSignalSpy errorSpy(&process, &QProcess::errorOccurred);
++    QVERIFY(errorSpy.isValid());
++
++    // both the dir name and the executable name
++    const QString target = QStringLiteral("testProcessNormal");
++    process.setProgram(programPrefix + target);
++
++#ifdef Q_OS_UNIX
++    // Reset PATH, to be sure it doesn't contain . or the empty path.
++    // We can't do this on Windows because DLLs are searched in PATH
++    // and Windows always searches "." anyway.
++    auto restoreEnv = qScopeGuard([old = qgetenv("PATH")] {
++        qputenv("PATH", old);
++    });
++    qputenv("PATH", "/");
++#endif
++
++    switch (chdirMode) {
++    case ChdirMode::InParent: {
++        auto restoreCwd = qScopeGuard([old = QDir::currentPath()] {
++            QDir::setCurrent(old);
++        });
++        QVERIFY(QDir::setCurrent(target));
++        process.start();
++        break;
++    }
++    case ChdirMode::InChild:
++        process.setWorkingDirectory(target);
++        Q_FALLTHROUGH();
++    case ChdirMode::None:
++        process.start();
++        break;
++    }
++
++    QCOMPARE(process.waitForStarted(), success);
++    QCOMPARE(errorSpy.count(), int(!success));
++    if (success) {
++        QVERIFY(process.waitForFinished());
++    } else {
++        QCOMPARE(process.error(), QProcess::FailedToStart);
++    }
++}
++
+ QTEST_MAIN(tst_QProcess)
+ #include "tst_qprocess.moc"
+diff --git a/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp b/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp
+index e1ea7a4552..90972caa57 100644
+--- a/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp
++++ b/qtbase/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"
+diff --git a/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+index 9bd66c0835..ed4a0bae5d 100644
+--- a/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
++++ b/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+@@ -158,6 +158,7 @@ private slots:
+     void nullReceiver();
+     void functorReferencesConnection();
+     void disconnectDisconnects();
++    void declarativeData();
+ };
+ 
+ struct QObjectCreatedOnShutdown
+@@ -7679,5 +7680,81 @@ void tst_QObject::disconnectDisconnects()
+ Q_STATIC_ASSERT(QtPrivate::HasQ_OBJECT_Macro<tst_QObject>::Value);
+ Q_STATIC_ASSERT(!QtPrivate::HasQ_OBJECT_Macro<SiblingDeleter>::Value);
+ 
++#ifdef QT_BUILD_INTERNAL
++/*
++    Since QObjectPrivate stores the declarativeData pointer in a union with the pointer
++    to the currently destroyed child, calls to the QtDeclarative handlers need to be
++    correctly guarded. QTBUG-105286
++*/
++namespace QtDeclarative {
++static QAbstractDeclarativeData *theData;
++
++static void destroyed(QAbstractDeclarativeData *data, QObject *)
++{
++    QCOMPARE(data, theData);
++}
++static void signalEmitted(QAbstractDeclarativeData *data, QObject *, int, void **)
++{
++    QCOMPARE(data, theData);
++}
++// we can't use QCOMPARE in the next two functions, as they don't return void
++static int receivers(QAbstractDeclarativeData *data, const QObject *, int)
++{
++    QTest::qCompare(data, theData, "data", "theData", __FILE__, __LINE__);
++    return 0;
++}
++static bool isSignalConnected(QAbstractDeclarativeData *data, const QObject *, int)
++{
++    QTest::qCompare(data, theData, "data", "theData", __FILE__, __LINE__);
++    return true;
++}
++
++class Object : public QObject
++{
++    Q_OBJECT
++public:
++    using QObject::QObject;
++    ~Object()
++    {
++        if (Object *p = static_cast<Object *>(parent()))
++            p->emitSignal();
++    }
++
++    void emitSignal()
++    {
++        emit theSignal();
++    }
++
++signals:
++    void theSignal();
++};
++
++}
++#endif
++
++void tst_QObject::declarativeData()
++{
++#ifdef QT_BUILD_INTERNAL
++    QScopedValueRollback destroyed(QAbstractDeclarativeData::destroyed,
++                                   QtDeclarative::destroyed);
++    QScopedValueRollback signalEmitted(QAbstractDeclarativeData::signalEmitted,
++                                       QtDeclarative::signalEmitted);
++    QScopedValueRollback receivers(QAbstractDeclarativeData::receivers,
++                                   QtDeclarative::receivers);
++    QScopedValueRollback isSignalConnected(QAbstractDeclarativeData::isSignalConnected,
++                                           QtDeclarative::isSignalConnected);
++
++    QtDeclarative::Object p;
++    QObjectPrivate *priv = QObjectPrivate::get(&p);
++    priv->declarativeData = QtDeclarative::theData = new QAbstractDeclarativeData;
++
++    connect(&p, &QtDeclarative::Object::theSignal, &p, []{
++    });
++
++    QtDeclarative::Object *child = new QtDeclarative::Object;
++    child->setParent(&p);
++#endif
++}
++
+ QTEST_MAIN(tst_QObject)
+ #include "tst_qobject.moc"
+diff --git a/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp b/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
+index 0ea422ecbc..1a3256534b 100644
+--- a/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
++++ b/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
+@@ -70,15 +70,15 @@ static inline QString testSuiteWarning()
+ 
+     QString result;
+     QTextStream str(&result);
+-    str << "\nCannot find the shared-mime-info test suite\nstarting from: "
++    str << "\nCannot find the shared-mime-info test suite\nin the parent of: "
+         << QDir::toNativeSeparators(QDir::currentPath()) << "\n"
+            "cd " << QDir::toNativeSeparators(QStringLiteral("tests/auto/corelib/mimetypes/qmimedatabase")) << "\n"
+-           "wget http://cgit.freedesktop.org/xdg/shared-mime-info/snapshot/Release-1-10.zip\n"
+-           "unzip Release-1-10.zip\n";
++           "wget https://gitlab.freedesktop.org/xdg/shared-mime-info/-/archive/2.1/shared-mime-info-2.1.zip\n"
++           "unzip shared-mime-info-2.1.zip\n";
+ #ifdef Q_OS_WIN
+-    str << "mkdir testfiles\nxcopy /s Release-1-10 s-m-i\n";
++    str << "mkdir testfiles\nxcopy /s shared-mime-info-2.1 s-m-i\n";
+ #else
+-    str << "ln -s Release-1-10 s-m-i\n";
++    str << "ln -s shared-mime-info-2.1 s-m-i\n";
+ #endif
+     return result;
+ }
+@@ -154,7 +154,7 @@ void tst_QMimeDatabase::initTestCase()
+     QVERIFY2(copyResourceFile(xmlFileName, xmlTargetFileName, &errorMessage), qPrintable(errorMessage));
+ #endif
+ 
+-    m_testSuite = QFINDTESTDATA("s-m-i/tests");
++    m_testSuite = QFINDTESTDATA("s-m-i/tests/mime-detection");
+     if (m_testSuite.isEmpty())
+         qWarning("%s", qPrintable(testSuiteWarning()));
+ 
+@@ -611,7 +611,7 @@ void tst_QMimeDatabase::allMimeTypes()
+     QVERIFY(!lst.isEmpty());
+ 
+     // Hardcoding this is the only way to check both providers find the same number of mimetypes.
+-    QCOMPARE(lst.count(), 779);
++    QCOMPARE(lst.count(), 811);
+ 
+     foreach (const QMimeType &mime, lst) {
+         const QString name = mime.name();
+@@ -631,10 +631,9 @@ void tst_QMimeDatabase::suffixes_data()
+ 
+     QTest::newRow("mimetype with a single pattern") << "application/pdf" << "*.pdf" << "pdf";
+     QTest::newRow("mimetype with multiple patterns") << "application/x-kpresenter" << "*.kpr;*.kpt" << "kpr";
+-    QTest::newRow("jpeg") << "image/jpeg" << "*.jpe;*.jpg;*.jpeg" << "jpeg";
+-    //if (KMimeType::sharedMimeInfoVersion() > KDE_MAKE_VERSION(0, 60, 0)) {
+-        QTest::newRow("mimetype with many patterns") << "application/vnd.wordperfect" << "*.wp;*.wp4;*.wp5;*.wp6;*.wpd;*.wpp" << "wp";
+-    //}
++    // The preferred suffix for image/jpeg is *.jpg, as per https://bugs.kde.org/show_bug.cgi?id=176737
++    QTest::newRow("jpeg") << "image/jpeg" << "*.jpe;*.jpg;*.jpeg" << "jpg";
++    QTest::newRow("mimetype with many patterns") << "application/vnd.wordperfect" << "*.wp;*.wp4;*.wp5;*.wp6;*.wpd;*.wpp" << "wp";
+     QTest::newRow("oasis text mimetype") << "application/vnd.oasis.opendocument.text" << "*.odt" << "odt";
+     QTest::newRow("oasis presentation mimetype") << "application/vnd.oasis.opendocument.presentation" << "*.odp" << "odp";
+     QTest::newRow("mimetype with multiple patterns") << "text/plain" << "*.asc;*.txt;*,v" << "txt";
+diff --git a/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp b/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
+index 3e58dd03cc..c8f82ef5d5 100644
+--- a/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
++++ b/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
+@@ -176,6 +176,8 @@ private Q_SLOTS:
+     void fromToVariantConversions_data();
+     void fromToVariantConversions();
+ 
++    void noLeakOnNameClash();
++
+ private:
+     QString testDataDir;
+ };
+@@ -3685,5 +3687,23 @@ void tst_QtJson::fromToVariantConversions()
+     }
+ }
+ 
++void tst_QtJson::noLeakOnNameClash()
++{
++    QJsonDocument doc = QJsonDocument::fromJson("{\"\":{\"\":0},\"\":0}");
++    QVERIFY(!doc.isNull());
++    const QJsonObject obj = doc.object();
++
++    // Removed the duplicate key.
++    QCOMPARE(obj.length(), 1);
++
++    // Retained the last of the duplicates.
++    const QJsonValue val = obj.begin().value();
++    QVERIFY(val.isDouble());
++    QCOMPARE(val.toDouble(), 0.0);
++
++    // It should not leak.
++    // In particular it should not forget to deref the container for the inner object.
++}
++
+ QTEST_MAIN(tst_QtJson)
+ #include "tst_qtjson.moc"
+diff --git a/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp b/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
+index a59b58d57f..241c3e84ac 100644
+--- a/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
++++ b/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
+@@ -63,6 +63,7 @@ private slots:
+     void isValidId_data();
+     void isValidId();
+     void malformed();
++    void serialize();
+     // Backend tests
+     void utcTest();
+     void icuTest();
+@@ -947,6 +948,33 @@ void tst_QTimeZone::malformed()
+         barf.offsetFromUtc(now);
+ }
+ 
++void tst_QTimeZone::serialize()
++{
++    int parts = 0;
++#ifndef QT_NO_DEBUG_STREAM
++    qDebug() << QTimeZone(); // to verify no crash
++    parts++;
++#endif
++#ifndef QT_NO_DATASTREAM
++    QByteArray blob;
++    {
++        QDataStream stream(&blob, QIODevice::WriteOnly);
++        stream << QTimeZone("Europe/Oslo") << QTimeZone(420) << QTimeZone() << qint64(-1);
++    }
++    QDataStream stream(&blob, QIODevice::ReadOnly);
++    QTimeZone invalid, offset, oslo;
++    qint64 minusone;
++    stream >> oslo >> offset >> invalid >> minusone;
++    QCOMPARE(oslo, QTimeZone("Europe/Oslo"));
++    QCOMPARE(offset, QTimeZone(420));
++    QVERIFY(!invalid.isValid());
++    QCOMPARE(minusone, qint64(-1));
++    parts++;
++#endif
++    if (!parts)
++        QSKIP("No serialization enabled");
++}
++
+ void tst_QTimeZone::utcTest()
+ {
+ #ifdef QT_BUILD_INTERNAL
+diff --git a/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp b/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
+index 05480c6dd2..70f4c75756 100644
+--- a/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
++++ b/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
+@@ -324,6 +324,13 @@ void tst_QDBusInterface::notValid()
+ 
+     QVERIFY(!interface.isValid());
+     QVERIFY(!QMetaObject::invokeMethod(&interface, "ListNames", Qt::DirectConnection));
++
++    // With a connection, but empty/null service and path specified
++    QDBusConnection con = QDBusConnection::sessionBus();
++    QVERIFY(con.isConnected());
++    QDBusInterface iface({}, {}, {}, con);
++    QVERIFY(!iface.isValid());
++    QVERIFY(!QMetaObject::invokeMethod(&interface, "ListNames", Qt::DirectConnection));
+ }
+ 
+ void tst_QDBusInterface::notValidDerived()
+diff --git a/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp b/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
+index 874468c954..04ceb4ab65 100644
+--- a/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
++++ b/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
+@@ -507,6 +507,10 @@ void tst_QKeySequence::toStringFromKeycode_data()
+     QTest::newRow("Ctrl+Alt+Num+Del") << QKeySequence(Qt::ControlModifier | Qt::AltModifier | Qt::KeypadModifier | Qt::Key_Delete) << "Ctrl+Alt+Num+Del";
+     QTest::newRow("Ctrl+Ins") << QKeySequence(Qt::ControlModifier | Qt::Key_Insert) << "Ctrl+Ins";
+     QTest::newRow("Ctrl+Num+Ins(1)") << QKeySequence(Qt::Key_Insert | Qt::KeypadModifier | Qt::ControlModifier) << "Ctrl+Num+Ins";
++    QTest::newRow("Ctrl") << QKeySequence(Qt::Key_Control) << "Control";
++    QTest::newRow("Alt") << QKeySequence(Qt::Key_Alt) << "Alt";
++    QTest::newRow("Shift") << QKeySequence(Qt::Key_Shift) << "Shift";
++    QTest::newRow("Meta") << QKeySequence(Qt::Key_Meta) << "Meta";
+ }
+ 
+ void tst_QKeySequence::toStringFromKeycode()
+diff --git a/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp b/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+index 15e0ecadaa..b4eca74283 100644
+--- a/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
++++ b/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+@@ -81,6 +81,8 @@ private slots:
+     void registerOpenTypePreferredNamesSystem();
+     void registerOpenTypePreferredNamesApplication();
+ 
++    void stretchRespected();
++
+ private:
+     QString m_ledFont;
+     QString m_testFont;
+@@ -355,6 +357,28 @@ static QString testString()
+     return QStringLiteral("foo bar");
+ }
+ 
++void tst_QFontDatabase::stretchRespected()
++{
++    int italicId = QFontDatabase::addApplicationFont(m_testFontItalic);
++    QVERIFY(italicId != -1);
++
++    QVERIFY(!QFontDatabase::applicationFontFamilies(italicId).isEmpty());
++
++    QString italicFontName = QFontDatabase::applicationFontFamilies(italicId).first();
++
++    QFont italicFont = QFontDatabase().font(italicFontName,
++                                            QString::fromLatin1("Italic"), 14);
++    QVERIFY(italicFont.italic());
++
++    QFont italicStretchedFont = italicFont;
++    italicStretchedFont.setStretch( 400 );
++
++    QVERIFY(QFontMetricsF(italicFont).horizontalAdvance(QStringLiteral("foobar")) <
++            QFontMetricsF(italicStretchedFont).horizontalAdvance(QStringLiteral("foobar")));
++
++    QFontDatabase::removeApplicationFont(italicId);
++}
++
+ void tst_QFontDatabase::condensedFontWidthNoFontMerging()
+ {
+     int regularFontId = QFontDatabase::addApplicationFont(m_testFont);
+diff --git a/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+index 3d4a094c43..b423e11a99 100644
+--- a/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
++++ b/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+@@ -281,6 +281,7 @@ private Q_SLOTS:
+     void ioGetFromFileSpecial();
+     void ioGetFromFile_data();
+     void ioGetFromFile();
++    void ioGetFromFileUrl();
+     void ioGetFromFtp_data();
+     void ioGetFromFtp();
+     void ioGetFromFtpWithReuse();
+@@ -3300,6 +3301,18 @@ void tst_QNetworkReply::ioGetFromFile()
+     QCOMPARE(reader.data, data);
+ }
+ 
++void tst_QNetworkReply::ioGetFromFileUrl()
++{
++    // This immediately fails on non-windows platforms:
++    QNetworkRequest request(QUrl("file://unc-server/some/path"));
++    QNetworkReplyPtr reply(manager.get(request));
++    QSignalSpy finishedSpy(reply.get(), &QNetworkReply::finished);
++    // QTBUG-105618: This would, on non-Windows platforms, never happen because the signal
++    // was emitted before the constructor finished, leaving no chance at all to connect to the
++    // signal
++    QVERIFY(finishedSpy.wait());
++}
++
+ void tst_QNetworkReply::ioGetFromFtp_data()
+ {
+     QTest::addColumn<QString>("fileName");
+diff --git a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
+index 069fa6b341..4cc4d9a5ea 100644
+--- a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
++++ b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
+@@ -1,75 +1,34 @@
+-Certificate:
+-    Data:
+-        Version: 3 (0x2)
+-        Serial Number: 0 (0x0)
+-        Signature Algorithm: sha1WithRSAEncryption
+-        Issuer: C=NO, ST=Oslo, L=Nydalen, O=Nokia Corporation and/or its subsidiary(-ies), OU=Development, CN=fluke.troll.no/emailAddress=ahanssen@trolltech.com
+-        Validity
+-            Not Before: Dec  4 01:10:32 2007 GMT
+-            Not After : Apr 21 01:10:32 2035 GMT
+-        Subject: C=NO, ST=Oslo, O=Nokia Corporation and/or its subsidiary(-ies), OU=Development, CN=fluke.troll.no
+-        Subject Public Key Info:
+-            Public Key Algorithm: rsaEncryption
+-            RSA Public Key: (1024 bit)
+-                Modulus (1024 bit):
+-                    00:a7:c8:a0:4a:c4:19:05:1b:66:ba:32:e2:d2:f1:
+-                    1c:6f:17:82:e4:39:2e:01:51:90:db:04:34:32:11:
+-                    21:c2:0d:6f:59:d8:53:90:54:3f:83:8f:a9:d3:b3:
+-                    d5:ee:1a:9b:80:ae:c3:25:c9:5e:a5:af:4b:60:05:
+-                    aa:a0:d1:91:01:1f:ca:04:83:e3:58:1c:99:32:45:
+-                    84:70:72:58:03:98:4a:63:8b:41:f5:08:49:d2:91:
+-                    02:60:6b:e4:64:fe:dd:a0:aa:74:08:e9:34:4c:91:
+-                    5f:12:3d:37:4d:54:2c:ad:7f:5b:98:60:36:02:8c:
+-                    3b:f6:45:f3:27:6a:9b:94:9d
+-                Exponent: 65537 (0x10001)
+-        X509v3 extensions:
+-            X509v3 Basic Constraints: 
+-                CA:FALSE
+-            Netscape Comment: 
+-                OpenSSL Generated Certificate
+-            X509v3 Subject Key Identifier: 
+-                21:85:04:3D:23:01:66:E5:F7:9F:1A:84:24:8A:AF:0A:79:F4:E5:AC
+-            X509v3 Authority Key Identifier: 
+-                DirName:/C=NO/ST=Oslo/L=Nydalen/O=Nokia Corporation and/or its subsidiary(-ies)/OU=Development/CN=fluke.troll.no/emailAddress=ahanssen@trolltech.com
+-                serial:8E:A8:B4:E8:91:B7:54:2E
+-
+-    Signature Algorithm: sha1WithRSAEncryption
+-        6d:57:5f:d1:05:43:f0:62:05:ec:2a:71:a5:dc:19:08:f2:c4:
+-        a6:bd:bb:25:d9:ca:89:01:0e:e4:cf:1f:c1:8c:c8:24:18:35:
+-        53:59:7b:c0:43:b4:32:e6:98:b2:a6:ef:15:05:0b:48:5f:e1:
+-        a0:0c:97:a9:a1:77:d8:35:18:30:bc:a9:8f:d3:b7:54:c7:f1:
+-        a9:9e:5d:e6:19:bf:f6:3c:5b:2b:d8:e4:3e:62:18:88:8b:d3:
+-        24:e1:40:9b:0c:e6:29:16:62:ab:ea:05:24:70:36:aa:55:93:
+-        ef:02:81:1b:23:10:a2:04:eb:56:95:75:fc:f8:94:b1:5d:42:
+-        c5:3f:36:44:85:5d:3a:2e:90:46:8a:a2:b9:6f:87:ae:0c:15:
+-        40:19:31:90:fc:3b:25:bb:ae:f1:66:13:0d:85:90:d9:49:34:
+-        8f:f2:5d:f9:7a:db:4d:5d:27:f6:76:9d:35:8c:06:a6:4c:a3:
+-        b1:b2:b6:6f:1d:d7:a3:00:fd:72:eb:9e:ea:44:a1:af:21:34:
+-        7d:c7:42:e2:49:91:19:8b:c0:ad:ba:82:80:a8:71:70:f4:35:
+-        31:91:63:84:20:95:e9:60:af:64:8b:cc:ff:3d:8a:76:74:3d:
+-        c8:55:6d:e4:8e:c3:2b:1c:e8:42:18:ae:9f:e6:6b:9c:34:06:
+-        ec:6a:f2:c3
+ -----BEGIN CERTIFICATE-----
+-MIIEEzCCAvugAwIBAgIBADANBgkqhkiG9w0BAQUFADCBnDELMAkGA1UEBhMCTk8x
+-DTALBgNVBAgTBE9zbG8xEDAOBgNVBAcTB055ZGFsZW4xFjAUBgNVBAoTDVRyb2xs
+-dGVjaCBBU0ExFDASBgNVBAsTC0RldmVsb3BtZW50MRcwFQYDVQQDEw5mbHVrZS50
+-cm9sbC5ubzElMCMGCSqGSIb3DQEJARYWYWhhbnNzZW5AdHJvbGx0ZWNoLmNvbTAe
+-Fw0wNzEyMDQwMTEwMzJaFw0zNTA0MjEwMTEwMzJaMGMxCzAJBgNVBAYTAk5PMQ0w
+-CwYDVQQIEwRPc2xvMRYwFAYDVQQKEw1Ucm9sbHRlY2ggQVNBMRQwEgYDVQQLEwtE
+-ZXZlbG9wbWVudDEXMBUGA1UEAxMOZmx1a2UudHJvbGwubm8wgZ8wDQYJKoZIhvcN
+-AQEBBQADgY0AMIGJAoGBAKfIoErEGQUbZroy4tLxHG8XguQ5LgFRkNsENDIRIcIN
+-b1nYU5BUP4OPqdOz1e4am4CuwyXJXqWvS2AFqqDRkQEfygSD41gcmTJFhHByWAOY
+-SmOLQfUISdKRAmBr5GT+3aCqdAjpNEyRXxI9N01ULK1/W5hgNgKMO/ZF8ydqm5Sd
+-AgMBAAGjggEaMIIBFjAJBgNVHRMEAjAAMCwGCWCGSAGG+EIBDQQfFh1PcGVuU1NM
+-IEdlbmVyYXRlZCBDZXJ0aWZpY2F0ZTAdBgNVHQ4EFgQUIYUEPSMBZuX3nxqEJIqv
+-Cnn05awwgbsGA1UdIwSBszCBsKGBoqSBnzCBnDELMAkGA1UEBhMCTk8xDTALBgNV
+-BAgTBE9zbG8xEDAOBgNVBAcTB055ZGFsZW4xFjAUBgNVBAoTDVRyb2xsdGVjaCBB
+-U0ExFDASBgNVBAsTC0RldmVsb3BtZW50MRcwFQYDVQQDEw5mbHVrZS50cm9sbC5u
+-bzElMCMGCSqGSIb3DQEJARYWYWhhbnNzZW5AdHJvbGx0ZWNoLmNvbYIJAI6otOiR
+-t1QuMA0GCSqGSIb3DQEBBQUAA4IBAQBtV1/RBUPwYgXsKnGl3BkI8sSmvbsl2cqJ
+-AQ7kzx/BjMgkGDVTWXvAQ7Qy5piypu8VBQtIX+GgDJepoXfYNRgwvKmP07dUx/Gp
+-nl3mGb/2PFsr2OQ+YhiIi9Mk4UCbDOYpFmKr6gUkcDaqVZPvAoEbIxCiBOtWlXX8
+-+JSxXULFPzZEhV06LpBGiqK5b4euDBVAGTGQ/Dslu67xZhMNhZDZSTSP8l35ettN
+-XSf2dp01jAamTKOxsrZvHdejAP1y657qRKGvITR9x0LiSZEZi8CtuoKAqHFw9DUx
+-kWOEIJXpYK9ki8z/PYp2dD3IVW3kjsMrHOhCGK6f5mucNAbsavLD
++MIIF6zCCA9OgAwIBAgIUfo9amJtJGWqWE6f+SkAO85zkGr4wDQYJKoZIhvcNAQEL
++BQAwgYMxCzAJBgNVBAYTAk5PMQ0wCwYDVQQIDARPc2xvMQ0wCwYDVQQHDARPc2xv
++MRcwFQYDVQQKDA5UaGUgUXQgQ29tcGFueTEMMAoGA1UECwwDUiZEMRIwEAYDVQQD
++DAlIMiBUZXN0ZXIxGzAZBgkqhkiG9w0BCQEWDG1pbmltaUBxdC5pbzAgFw0yMDEw
++MjYxMjAxMzFaGA8yMTIwMTAwMjEyMDEzMVowgYMxCzAJBgNVBAYTAk5PMQ0wCwYD
++VQQIDARPc2xvMQ0wCwYDVQQHDARPc2xvMRcwFQYDVQQKDA5UaGUgUXQgQ29tcGFu
++eTEMMAoGA1UECwwDUiZEMRIwEAYDVQQDDAlIMiBUZXN0ZXIxGzAZBgkqhkiG9w0B
++CQEWDG1pbmltaUBxdC5pbzCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIB
++AOiUp5+E4blouKH7q+rVNR8NoYX2XkBW+q+rpy1zu5ssRSzbqxAjDx9dkht7Qlnf
++VlDT00JvpOWdeuPon5915edQRsY4Unl6mKH29ra3OtUa1/yCJXsGVJTKCj7k4Bxb
++5mZzb/fTlZntMLdTIBMfUbw62FKir1WjKIcJ9fCoG8JaGeKVO4Rh5p0ezd4UUUId
++r1BXl5Nqdqy2vTMsEDnjOsD3egkv8I2SKN4O6n/C3wWYpMOWYZkGoZiKz7rJs/i/
++ez7bsV7JlwdzTlhpJzkcOSVFBP6JlEOxTNNxZ1wtKy7PtZGmsSSATq2e6+bw38Ae
++Op0XnzzqcGjtDDofBmT7OFzZWjS9VZS6+DOOe2QHWle1nCHcHyH4ku6IRlsr9xkR
++NAIlOfnvHHxqJUenoeaZ4oQDjCBKS1KXygJO/tL7BLTQVn/xK1EmPvKNnjzWk4tR
++PnibUhhs5635qpOU/YPqFBh1JjVruZbsWcDAhRcew0uxONXOa9E+4lttQ9ySYa1A
++LvWqJuAX7gu2BsBMLyqfm811YnA7CIFMyO+HlqmkLFfv5L/xIRAXR7l26YGO0VwX
++CGjMfz4NVPMMke4nB7qa9NkpXQBQKMms3Qzd5JW0Hy9Ruj5O8GPcFZmV0twjd1uJ
++PD/cAjkWLaXjdNsJ16QWc2nghQRS6HYqKRX6j+CXOxupAgMBAAGjUzBRMB0GA1Ud
++DgQWBBRSCOU58j9NJZkMamt623qyCrhN3TAfBgNVHSMEGDAWgBRSCOU58j9NJZkM
++amt623qyCrhN3TAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4ICAQCq
++q4jxsWeNDv5Nq14hJtF9HB+ZL64zcZtRjJP1YgNs0QppKICmjPOL2nIMGmI/jKrs
++0eGAL/9XXNVHPxm1OPOncvimMMmU6emZfpMdEtTfKP43+Pg9HgKRjLoQp406vGeQ
++8ki/mbBhrItVPgEm3tu2AFA02XTYi+YxCI9kRZLGkM3FbgtOuTLPl0Z9y+kiPc9F
++uCSC03anBEqv+vDSI8+wODymQ/IJ3Jyz1lxIRDfp4qAekmy0jU2c91VOHHEmOmqq
++kqygGFRdwbe99m9yP63r6q0b5K3X2UnJ6bns0hmTwThYwpVPXLU8jdaTddbMukN2
++/Ef96Tsw8nWOEOPMySHOTIPgwyZRp26b0kA9EmhLwOP401SxXVQCmSRmtwNagmtg
++jJKmZoYBN+//D45ibK8z6Q0oOm9P+Whf/uUXehcRxBxyV3xz7k0wKGQbHj/ddwcy
++IUoIN4lrAlib+lK170kTKN352PDmrpo2gmIzPEsfurKAIMSelDl6H+kih16BtZ8y
++Nz6fh9Soqrg3OSAware8pxV7k51crBMoPLN78KoRV8MFCK4K7Fddq4rRISq6hiXq
++r1nsjoEPuKM9huprmZVZe9t5YcDa2I+wb3IiE3uwpZbAdaLDyQ5n6F/qpsiIkZXn
++gtcF7oqpG5oYrwCcZ53y/ezUgUg7PlSz2XwAGvQtgg==
+ -----END CERTIFICATE-----
+diff --git a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
+index 9d1664d609..337ce541a6 100644
+--- a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
++++ b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
+@@ -1,15 +1,52 @@
+------BEGIN RSA PRIVATE KEY-----
+-MIICXAIBAAKBgQCnyKBKxBkFG2a6MuLS8RxvF4LkOS4BUZDbBDQyESHCDW9Z2FOQ
+-VD+Dj6nTs9XuGpuArsMlyV6lr0tgBaqg0ZEBH8oEg+NYHJkyRYRwclgDmEpji0H1
+-CEnSkQJga+Rk/t2gqnQI6TRMkV8SPTdNVCytf1uYYDYCjDv2RfMnapuUnQIDAQAB
+-AoGANFzLkanTeSGNFM0uttBipFT9F4a00dqHz6JnO7zXAT26I5r8sU1pqQBb6uLz
+-/+Qz5Zwk8RUAQcsMRgJetuPQUb0JZjF6Duv24hNazqXBCu7AZzUenjafwmKC/8ri
+-KpX3fTwqzfzi//FKGgbXQ80yykSSliDL3kn/drATxsLCgQECQQDXhEFWLJ0vVZ1s
+-1Ekf+3NITE+DR16X+LQ4W6vyEHAjTbaNWtcTKdAWLA2l6N4WAAPYSi6awm+zMxx4
+-VomVTsjdAkEAx0z+e7natLeFcrrq8pbU+wa6SAP1VfhQWKitxL1e7u/QO90NCpxE
+-oQYKzMkmmpOOFjQwEMAy1dvFMbm4LHlewQJAC/ksDBaUcQHHqjktCtrUb8rVjAyW
+-A8lscckeB2fEYyG5J6dJVaY4ClNOOs5yMDS2Afk1F6H/xKvtQ/5CzInA/QJATDub
+-K+BPU8jO9q+gpuIi3VIZdupssVGmCgObVCHLakG4uO04y9IyPhV9lA9tALtoIf4c
+-VIvv5fWGXBrZ48kZAQJBAJmVCdzQxd9LZI5vxijUCj5EI4e+x5DRqVUvyP8KCZrC
+-AiNyoDP85T+hBZaSXK3aYGpVwelyj3bvo1GrTNwNWLw=
+------END RSA PRIVATE KEY-----
++-----BEGIN PRIVATE KEY-----
++MIIJQgIBADANBgkqhkiG9w0BAQEFAASCCSwwggkoAgEAAoICAQDolKefhOG5aLih
+++6vq1TUfDaGF9l5AVvqvq6ctc7ubLEUs26sQIw8fXZIbe0JZ31ZQ09NCb6TlnXrj
++6J+fdeXnUEbGOFJ5epih9va2tzrVGtf8giV7BlSUygo+5OAcW+Zmc2/305WZ7TC3
++UyATH1G8OthSoq9VoyiHCfXwqBvCWhnilTuEYeadHs3eFFFCHa9QV5eTanastr0z
++LBA54zrA93oJL/CNkijeDup/wt8FmKTDlmGZBqGYis+6ybP4v3s+27FeyZcHc05Y
++aSc5HDklRQT+iZRDsUzTcWdcLSsuz7WRprEkgE6tnuvm8N/AHjqdF5886nBo7Qw6
++HwZk+zhc2Vo0vVWUuvgzjntkB1pXtZwh3B8h+JLuiEZbK/cZETQCJTn57xx8aiVH
++p6HmmeKEA4wgSktSl8oCTv7S+wS00FZ/8StRJj7yjZ481pOLUT54m1IYbOet+aqT
++lP2D6hQYdSY1a7mW7FnAwIUXHsNLsTjVzmvRPuJbbUPckmGtQC71qibgF+4LtgbA
++TC8qn5vNdWJwOwiBTMjvh5appCxX7+S/8SEQF0e5dumBjtFcFwhozH8+DVTzDJHu
++Jwe6mvTZKV0AUCjJrN0M3eSVtB8vUbo+TvBj3BWZldLcI3dbiTw/3AI5Fi2l43Tb
++CdekFnNp4IUEUuh2KikV+o/glzsbqQIDAQABAoICAFw1q6tr5I48vY7DF+rXsuLn
++5ZUWE1IQ6fzB4lr72nJv/9EEGnMgYzt9PpMUsD6vdCpBgS2C0+6RHArFzJtNA+RM
++iHLIG7K7702veyr/xBx/MwiSlMeMv/XpkFxVI6E6skMGG2s3AMXxKvJTy5CpRx+I
++eQFyLG+Ya1X2lgJes/q+/CpAHkOjCOpcLySQC5NZ74q734V7nSdmn+Zs3tYEh+O/
++eiuwTP/j5b38Te5vVTqDxTciJPmljmXLCwa0N100lWlbcpvw8qbqiTI2Jm3XCbUE
++AzHjW9vmrF3cRS1fXxKFGShw3SRqlkbxjfeWoi8qDPUBS4m8LOr8qG9Wo5Nfon0z
++zLP4bci3zHDvVcaaZrrsUBs/yZbg+Dgka1DmX7ekmeccr2yTdKDFgPupYUyxVbTl
++a9ZLJysjFD7rgBv1ZclHonLp6Vbm+ZoTqvteo4ikAy6L9RtBWJ23XEK34PkP/+c5
++2vWZaOrnjSeBHbFce8cdJSxqWpP+eSCI5I9XbDrYFIsQ/gqKgtzDKy2ihJ2Y8STL
++yO4hyFPFjxc+Gg4/P2PpmT5CY2ty44M0BWs+JGW96CJPrrplf2lmQUQJj5LZY66X
++Z/4C9L7ZYtKZ+bs5SvU46yWugAvQZX22Xm9xLXWyVXRdx3bj+3M3fDnF9di/zdbh
++CgLx7oWPNrXc7FCajnn9AoIBAQD5FMYwRpw9NWT9WDxQwx+cSI4Icbd88ByTW63S
++LzeRwZA0J9/SfwO+aBRupzc9GkGXCiZcGMw3AGsCtig8yFlw8E5KnzN7KlftDMnM
++9NUxxzlR8VwKyLnZfG7sDTl057ZlUujnqhmt/F8F7dIy7FVO1dE/8nngA+FYTCOG
++UZdGjwyBDlDM0JJdUWGY3xslutcpCDN5mzSTKjy9drMvImAshRawxRF6WBpn7vr2
++nC6vciqfx1Mzx1vyk0Jm0ilaydDdLMADjt/iL4Nkr0BEs4k+UzQiKDwp8gu7abQ1
++eBfxd9Iar4htQa2I1Ewl6P01G/q+ZYwgHhJ9RVn4AxQXefILAoIBAQDvCouORdQX
++C8wsyp7MwXlF/3NQeNN5/+B2mhbxrBOf7PmMCXLnkRWcjwJtzypWFqJ0sqai/2+0
++bqbMcjX5maT8stT2shl3zXe/Ejt2e3TBYpc1tyuses8Kb5BMU8hu6tTd3G2CMXpD
++dT6DVemJZCTtwj9aBNIxSizvlgMolJnCpzhPnlfHSI6E+g3m/LTTo3HwbjMSw/Uq
++irgjOpI2wSBB6LZPSgjvfcYPRyWUk16L4A5uSX0cADnovDFLa5/h0wJvN/OoCSQg
++rLCXG5E18EyL5Wc58BCY1ZvxmjG3lQtgPxYu2Jwc36R/y/JKlxW5suER5ZNpbbD4
++uOyTt2VxMQ2bAoIBAQC5+MzRFqdo/AjfL5Y5JrbfVTzXCTDa09xCGd16ZU60QTWN
+++4ed/r+o1sUKqUcRFB2MzEM/2DQBjQpZB/CbEWvWa1XJWXxypXbowveZU+QqOnmN
++uQvj8WLyA3o+PNF9e9QvauwCrHpn8VpxbtPWuaYoKnUFreFZZQxHhPGxRBIS2JOZ
++eDrT8ZaWnkCkh1AZp5smQ71LOprSlmKrg4jd1GjCVMxQR5N5KXbtyv0OTCZ/UFqK
++2aRBsMPyJgkaBChkZPLRcKwc+/wlQRx1fHQb14DNTApMxoXFO7eOwqmOkpAt9iyl
++SBIwoS0UUI5ab88+bBmXNvKcuFdNuQ4nowTJUn9pAoIBADMNkILBXSvS5DeIyuO2
++Sp1tkoZUV+5NfPY3sMDK3KIibaW/+t+EOBZo4L7tKQCb8vRzl21mmsfxfgRaPDbj
++3r3tv9g0b4YLxxBy52pFscj/soXRai17SS7UZwA2QK+XzgDYbDcLNC6mIsTQG4Gx
++dsWk3/zs3KuUSQaehmwrWK+fIUK38c1pLK8v7LoxrLkqxlHwZ04RthHw8KTthH7X
++Pnl1J0LF8CSeOyfWLSuPUfkT0GEzptnNHpEbaHfQM6R6eaGhVJPF6AZme4y6YYgg
++m2ihhSt1n0XVEWpHYWjxFy3mK2mz75unFC4LM+NEY2p2zuUQoCw7NjnY3QYrfCnx
++rRMCggEAXeXsMSLFjjyuoL7iKbAxo52HD/P0fBoy58LyRcwfNVr0lvYan4pYEx+o
++KijIh9K16PqXZXKMA9v003B+ulmF8bJ7SddCZ5NGvnFhUTDe4DdTKgp2RuwQ3Bsc
++3skPIDbhVETyOLCtys34USHrq8U/0DlGY3eLRfxw9GnbKxSBGa/KEu/qQLPNUo50
++7xHZDg7GKeC3kqNJeqKM9rkp0VzIGkEnaD9127LeNDmERDfftxJzFoC/THvUBLfU
++6Sus2ZYwRE8VFvKC30Q45t/c54X3IuhYvAuiCuTmyfE4ruyzyOwKzhUkeeLq1APX
++g0veFbyfzlJ0q8qzD/iffqqIa2ZSmQ==
++-----END PRIVATE KEY-----
+diff --git a/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp b/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
+index 7ba3715e13..752aa122f6 100644
+--- a/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
++++ b/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
+@@ -179,6 +179,7 @@ void tst_QAccessibilityLinux::initTestCase()
+     QVERIFY(!address.isEmpty());
+ 
+     m_window = new AccessibleTestWindow();
++    m_window->setObjectName("mainWindow"_L1);
+     m_window->show();
+ 
+     QVERIFY(QTest::qWaitForWindowExposed(m_window));
+@@ -236,8 +237,11 @@ bool hasState(QDBusInterface *interface, AtspiStateType state)
+ void tst_QAccessibilityLinux::testLabel()
+ {
+     QLabel *l = new QLabel(m_window);
++    l->setObjectName("theObjectName"_L1);
+     l->setText("Hello A11y");
+     m_window->addWidget(l);
++    auto a11yEmpty = new QLabel(m_window);
++    m_window->addWidget(l);
+ 
+     // Application
+     QCOMPARE(getParent(mainWindow), QLatin1String(ATSPI_DBUS_PATH_ROOT));
+@@ -249,6 +253,8 @@ void tst_QAccessibilityLinux::testLabel()
+     QCOMPARE(getChildren(labelInterface).count(), 0);
+     QCOMPARE(labelInterface->call(QDBus::Block, "GetRoleName").arguments().first().toString(), QLatin1String("label"));
+     QCOMPARE(labelInterface->call(QDBus::Block, "GetRole").arguments().first().toUInt(), 29u);
++    QCOMPARE(labelInterface->call(QDBus::Block, "GetAccessibleId").arguments().first().toString(),
++             QLatin1String("mainWindow.theObjectName"));
+     QCOMPARE(getParent(labelInterface), mainWindow->path());
+     QVERIFY(!hasState(labelInterface, ATSPI_STATE_EDITABLE));
+     QVERIFY(hasState(labelInterface, ATSPI_STATE_READ_ONLY));
+@@ -256,7 +262,12 @@ void tst_QAccessibilityLinux::testLabel()
+     l->setText("New text");
+     QCOMPARE(labelInterface->property("Name").toString(), l->text());
+ 
++    auto *a11yEmptyInterface = getInterface(children.at(1), "org.a11y.atspi.Accessible");
++    QCOMPARE(a11yEmptyInterface->call(QDBus::Block, "GetAccessibleId").arguments().first().toString(),
++             QLatin1String("mainWindow.QLabel"));
++
+     m_window->clearChildren();
++    delete a11yEmptyInterface;
+     delete labelInterface;
+ }
+ 
+diff --git a/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+index 76df61c892..6d6d65b791 100644
+--- a/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
++++ b/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2022 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the test suite of the Qt Toolkit.
+@@ -68,6 +68,8 @@ private slots:
+     void query_exec();
+     void execErrorRecovery_data() { generic_data(); }
+     void execErrorRecovery();
++    void prematureExec_data() { generic_data(); }
++    void prematureExec();
+     void first_data() { generic_data(); }
+     void first();
+     void next_data() { generic_data(); }
+@@ -2770,6 +2772,35 @@ void tst_QSqlQuery::execErrorRecovery()
+     QVERIFY_SQL( q, exec() );
+ }
+ 
++void tst_QSqlQuery::prematureExec()
++{
++    QFETCH(QString, dbName);
++    // We only want the engine name, for addDatabase():
++    int cut = dbName.indexOf(QChar('@'));
++    if (cut < 0)
++        QSKIP("Failed to parse database type out of name");
++    dbName.truncate(cut);
++    cut = dbName.indexOf(QChar('_'));
++    if (cut >= 0)
++        dbName = dbName.mid(cut + 1);
++
++    auto db = QSqlDatabase::addDatabase(dbName);
++    QSqlQuery q(db);
++
++    QTest::ignoreMessage(QtWarningMsg,
++                         "QSqlDatabasePrivate::removeDatabase: connection "
++                         "'qt_sql_default_connection' is still in use, all "
++                         "queries will cease to work.");
++    QTest::ignoreMessage(QtWarningMsg,
++                         "QSqlDatabasePrivate::addDatabase: duplicate connection name "
++                         "'qt_sql_default_connection', old connection removed.");
++    auto otherDb = QSqlDatabase::addDatabase(dbName);
++
++    QTest::ignoreMessage(QtWarningMsg, "QSqlQuery::exec: called before driver has been set up");
++    // QTBUG-100037: shouldn't crash !
++    QVERIFY(!q.exec("select stuff from TheVoid"));
++}
++
+ void tst_QSqlQuery::lastInsertId()
+ {
+     QFETCH( QString, dbName );
+diff --git a/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp b/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
+index 4aa3f8d60b..d2050a61aa 100644
+--- a/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
++++ b/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
+@@ -115,6 +115,10 @@ void tst_QAbstractItemModelTester::standardItemModelZeroColumns()
+     // QTBUG-92886
+     model.insertRows(0, 5);
+     model.removeRows(1, 2);
++
++    const QModelIndex parentIndex = model.index(0, 0);
++    model.insertRows(0, 5, parentIndex);
++    model.removeRows(1, 2, parentIndex);
+ }
+ 
+ void tst_QAbstractItemModelTester::testInsertThroughProxy()
+diff --git a/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json b/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
+index 12a4a22a19..ce518e78fb 100644
+--- a/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
++++ b/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
+@@ -668,50 +668,6 @@
+         "inputFile": "task192552.h",
+         "outputRevision": 67
+     },
+-    {
+-        "classes": [
+-            {
+-                "className": "InlineSlotsWithThrowDeclaration",
+-                "object": true,
+-                "qualifiedClassName": "InlineSlotsWithThrowDeclaration",
+-                "slots": [
+-                    {
+-                        "access": "public",
+-                        "name": "a",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "b",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "c",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "d",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "e",
+-                        "returnType": "void"
+-                    }
+-                ],
+-                "superClasses": [
+-                    {
+-                        "access": "public",
+-                        "name": "QObject"
+-                    }
+-                ]
+-            }
+-        ],
+-        "inputFile": "task189996.h",
+-        "outputRevision": 67
+-    },
+     {
+         "classes": [
+             {
+diff --git a/qtbase/tests/auto/tools/moc/moc.pro b/qtbase/tests/auto/tools/moc/moc.pro
+index c324b3a8cd..4aceb78dc0 100644
+--- a/qtbase/tests/auto/tools/moc/moc.pro
++++ b/qtbase/tests/auto/tools/moc/moc.pro
+@@ -15,7 +15,7 @@ cross_compile: DEFINES += MOC_CROSS_COMPILED
+ HEADERS += using-namespaces.h no-keywords.h task87883.h c-comments.h backslash-newlines.h oldstyle-casts.h \
+            slots-with-void-template.h qinvokable.h namespaced-flags.h trigraphs.h \
+            escapes-in-string-literals.h cstyle-enums.h qprivateslots.h gadgetwithnoenums.h \
+-           dir-in-include-path.h single_function_keyword.h task192552.h task189996.h \
++           dir-in-include-path.h single_function_keyword.h task192552.h \
+            task234909.h task240368.h pure-virtual-signals.h cxx11-enums.h \
+            cxx11-final-classes.h \
+            cxx11-explicit-override-control.h \
+diff --git a/qtbase/tests/auto/tools/moc/task189996.h b/qtbase/tests/auto/tools/moc/task189996.h
+deleted file mode 100644
+index f94a051b3a..0000000000
+--- a/qtbase/tests/auto/tools/moc/task189996.h
++++ /dev/null
+@@ -1,47 +0,0 @@
+-/****************************************************************************
+-**
+-** Copyright (C) 2016 The Qt Company Ltd.
+-** Contact: https://www.qt.io/licensing/
+-**
+-** This file is part of the test suite of the Qt Toolkit.
+-**
+-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+-** 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 General Public License Usage
+-** Alternatively, this file may be used under the terms of the GNU
+-** General Public License version 3 as published by the Free Software
+-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+-** 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-3.0.html.
+-**
+-** $QT_END_LICENSE$
+-**
+-****************************************************************************/
+-// inline functions can have throw declarations
+-
+-#ifndef TASK189996_H
+-#define TASK189996_H
+-
+-#include <QObject>
+-
+-class InlineSlotsWithThrowDeclaration : public QObject
+-{
+-    Q_OBJECT
+-
+-public slots:
+-    void a() throw() { }
+-    void b() const throw() { }
+-    void c() throw();
+-    void d() throw(int) { }
+-    void e() const throw(int,double) { }
+-};
+-
+-#endif
+diff --git a/qtbase/tests/auto/tools/moc/tst_moc.cpp b/qtbase/tests/auto/tools/moc/tst_moc.cpp
+index c716aead21..15dd9e41e5 100644
+--- a/qtbase/tests/auto/tools/moc/tst_moc.cpp
++++ b/qtbase/tests/auto/tools/moc/tst_moc.cpp
+@@ -631,7 +631,6 @@ public:
+ private slots:
+     void initTestCase();
+ 
+-    void slotWithException() throw(MyStruct);
+     void dontStripNamespaces();
+     void oldStyleCasts();
+     void warnOnExtraSignalSlotQualifiaction();
+@@ -673,7 +672,6 @@ private slots:
+     void templateGtGt();
+     void qprivateslots();
+     void qprivateproperties();
+-    void inlineSlotsWithThrowDeclaration();
+     void warnOnPropertyWithoutREAD();
+     void constructors();
+     void typenameWithUnsigned();
+@@ -784,12 +782,6 @@ void tst_Moc::initTestCase()
+ #endif
+ }
+ 
+-void tst_Moc::slotWithException() throw(MyStruct)
+-{
+-    // be happy
+-    QVERIFY(true);
+-}
+-
+ void tst_Moc::dontStripNamespaces()
+ {
+     Sender sender;
+@@ -824,7 +816,7 @@ void tst_Moc::oldStyleCasts()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-Wold-style-cast" << "-I" << "."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -894,7 +886,7 @@ void tst_Moc::inputFileNameWithDotsButNoExtension()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-I" << ".."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -1174,7 +1166,7 @@ void tst_Moc::ignoreOptionClashes()
+     QStringList gccArgs;
+     gccArgs << "-c" << "-x" << "c++" << "-I" << ".."
+          << "-I" << qtIncludePath << "-I" << includeDir << "-o" << "/dev/null"
+-         << "-fPIC" << "-std=c++11" <<  "-";
++         << "-fPIC" << "-std=c++1z" <<  "-";
+     proc.start("gcc", gccArgs);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -1593,21 +1585,6 @@ void tst_Moc::qprivateproperties()
+ 
+ }
+ 
+-#include "task189996.h"
+-
+-void InlineSlotsWithThrowDeclaration::c() throw() {}
+-
+-void tst_Moc::inlineSlotsWithThrowDeclaration()
+-{
+-    InlineSlotsWithThrowDeclaration tst;
+-    const QMetaObject *mobj = tst.metaObject();
+-    QVERIFY(mobj->indexOfSlot("a()") != -1);
+-    QVERIFY(mobj->indexOfSlot("b()") != -1);
+-    QVERIFY(mobj->indexOfSlot("c()") != -1);
+-    QVERIFY(mobj->indexOfSlot("d()") != -1);
+-    QVERIFY(mobj->indexOfSlot("e()") != -1);
+-}
+-
+ void tst_Moc::warnOnPropertyWithoutREAD()
+ {
+ #ifdef MOC_CROSS_COMPILED
+@@ -1869,7 +1846,7 @@ void tst_Moc::notifyError()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-I" << "."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+diff --git a/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+index c355ee9665..88c09de8e0 100644
+--- a/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
++++ b/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+@@ -251,6 +251,7 @@ private slots:
+     void testResetCachedSizeHint();
+     void statusTips();
+     void testRemovingColumnsViaLayoutChanged();
++    void testModelMovingColumns();
+ 
+ protected:
+     void setupTestData(bool use_reset_model = false);
+@@ -360,6 +361,12 @@ public:
+         endRemoveColumns();
+     }
+ 
++    void moveColumn(int from, int to)
++    {
++        beginMoveColumns(QModelIndex(), from, from, QModelIndex(), to);
++        endMoveColumns();
++    }
++
+     void cleanup()
+     {
+         emit layoutAboutToBeChanged();
+@@ -3627,5 +3634,18 @@ void tst_QHeaderView::testRemovingColumnsViaLayoutChanged()
+     // The main point of this test is that the section-size restoring code didn't go out of bounds.
+ }
+ 
++void tst_QHeaderView::testModelMovingColumns()
++{
++    QtTestModel model(10, 10);
++    QHeaderView hv(Qt::Horizontal);
++    hv.setModel(&model);
++    hv.resizeSections(QHeaderView::ResizeToContents);
++    hv.show();
++
++    QPersistentModelIndex index3 = model.index(0, 3);
++    model.moveColumn(3, 1);
++    QCOMPARE(index3.column(), 1);
++}
++
+ QTEST_MAIN(tst_QHeaderView)
+ #include "tst_qheaderview.moc"
+diff --git a/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+index 761357b252..06bb706074 100644
+--- a/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
++++ b/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+@@ -397,6 +397,7 @@ private slots:
+     void checkHeaderMinSize();
+ 
+     void resizeToContents();
++    void resizeToContentsSpans();
+ 
+     void tabFocus();
+     void bigModel();
+@@ -3721,6 +3722,70 @@ void tst_QTableView::resizeToContents()
+ 
+ }
+ 
++
++class SpanModel : public QAbstractTableModel
++{
++public:
++    SpanModel(bool sectionsMoved)
++        : _sectionsMoved(sectionsMoved)
++    {}
++    int columnCount(const QModelIndex & = {}) const override { return 2; }
++    int rowCount(const QModelIndex & = {}) const override { return 1; }
++    QVariant data(const QModelIndex &idx, int role = Qt::DisplayRole) const override
++    {
++        if (role != Qt::DisplayRole)
++            return QVariant();
++        const int col = _sectionsMoved ? 1 - idx.column() : idx.column();
++        if (col == 0)
++            return "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.";
++        return QVariant();
++    }
++private:
++    bool _sectionsMoved;
++};
++
++
++void tst_QTableView::resizeToContentsSpans()
++{
++    SpanModel model1(false);
++    SpanModel model2(true);
++    QTableView view1, view2, view3;
++    view1.setModel(&model1);
++    view2.setModel(&model2);
++    view2.horizontalHeader()->moveSection(0, 1);
++    view3.setModel(&model1);
++
++    view1.setSpan(0, 0, 1, 2);
++    view2.setSpan(0, 1, 1, 2);
++    view1.show();
++    view2.show();
++    view3.show();
++    QVERIFY(QTest::qWaitForWindowExposed(&view1));
++    QVERIFY(QTest::qWaitForWindowExposed(&view2));
++    QVERIFY(QTest::qWaitForWindowExposed(&view3));
++    view1.setColumnWidth(0, 100);
++    view1.setColumnWidth(1, 100);
++    view2.setColumnWidth(0, 100);
++    view2.setColumnWidth(1, 100);
++    view3.setColumnWidth(0, 200);
++
++    view1.resizeRowToContents(0);
++    view2.resizeRowToContents(0);
++    view3.resizeRowToContents(0);
++    QCOMPARE(view1.rowHeight(0), view3.rowHeight(0));
++    QCOMPARE(view2.rowHeight(0), view3.rowHeight(0));
++
++    view3.resizeColumnToContents(0);
++    view3.resizeRowToContents(0);
++    // height should be only 1 text line for easy testing
++    view1.setRowHeight(0, view3.verticalHeader()->sectionSize(0));
++    view2.setRowHeight(0, view3.verticalHeader()->sectionSize(0));
++    view1.resizeColumnToContents(0);
++    view2.resizeColumnToContents(1);
++    QCOMPARE(view1.columnWidth(0), view3.columnWidth(0) - view1.columnWidth(1));
++    QCOMPARE(view2.columnWidth(0), view3.columnWidth(0) - view2.columnWidth(1));
++}
++
+ QT_BEGIN_NAMESPACE
+ extern bool Q_WIDGETS_EXPORT qt_tab_all_widgets(); // qapplication.cpp
+ QT_END_NAMESPACE
+diff --git a/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+index a3b8ef78d8..4955cebd5d 100644
+--- a/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
++++ b/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+@@ -1498,7 +1498,7 @@ void tst_QApplication::desktopSettingsAware()
+     environment += QLatin1String("QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM=1");
+     testProcess.setEnvironment(environment);
+ #endif
+-    testProcess.start("desktopsettingsaware_helper");
++    testProcess.start("./desktopsettingsaware_helper");
+     QVERIFY2(testProcess.waitForStarted(),
+              qPrintable(QString::fromLatin1("Cannot start 'desktopsettingsaware_helper': %1").arg(testProcess.errorString())));
+     QVERIFY(testProcess.waitForFinished(10000));
+@@ -2452,7 +2452,7 @@ void tst_QApplication::qtbug_12673()
+ #if QT_CONFIG(process)
+     QProcess testProcess;
+     QStringList arguments;
+-    testProcess.start("modal_helper", arguments);
++    testProcess.start("./modal_helper", arguments);
+     QVERIFY2(testProcess.waitForStarted(),
+              qPrintable(QString::fromLatin1("Cannot start 'modal_helper': %1").arg(testProcess.errorString())));
+     QVERIFY(testProcess.waitForFinished(20000));
+diff --git a/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp b/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
+index eb108a40de..dca5528c1b 100644
+--- a/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
+@@ -41,6 +41,7 @@
+ 
+ #include <private/qguiapplication_p.h>
+ #include <qpa/qplatformintegration.h>
++#include <qpa/qplatformtheme.h>
+ 
+ class tst_QAbstractButton : public QObject
+ {
+@@ -76,6 +77,8 @@ private slots:
+     void keyNavigation();
+ #endif
+ 
++    void buttonPressKeys();
++
+ protected slots:
+     void onClicked();
+     void onToggled( bool on );
+@@ -269,7 +272,13 @@ void tst_QAbstractButton::setAutoRepeat()
+         QCOMPARE(press_count, click_count);
+         QVERIFY(click_count > 1);
+         break;
+-    case 4:
++    case 4: {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(Qt::Key_Enter)) {
++            QSKIP("platform theme has Key_Enter in ButtonPressKeys");
++        }
+         // check that pressing ENTER has no effect when autorepeat is false
+         testWidget->setDown( false );
+         testWidget->setAutoRepeat( false );
+@@ -286,7 +295,14 @@ void tst_QAbstractButton::setAutoRepeat()
+ 
+         QVERIFY( click_count == 0 );
+         break;
+-    case 5:
++    }
++    case 5: {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(Qt::Key_Enter)) {
++            QSKIP("platform theme has Key_Enter in ButtonPressKeys");
++        }
+         // check that pressing ENTER has no effect when autorepeat is true
+         testWidget->setDown( false );
+         testWidget->setAutoRepeat( true );
+@@ -304,6 +320,7 @@ void tst_QAbstractButton::setAutoRepeat()
+ 
+         QVERIFY( click_count == 0 );
+         break;
++    }
+     case 6:
+         // verify autorepeat is off by default.
+         MyButton tmp( 0);
+@@ -651,5 +668,16 @@ void tst_QAbstractButton::keyNavigation()
+ }
+ #endif
+ 
++void tst_QAbstractButton::buttonPressKeys()
++{
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(testWidget, buttonPressKeys[i]);
++        QCOMPARE(click_count, i + 1);
++    }
++}
++
+ QTEST_MAIN(tst_QAbstractButton)
+ #include "tst_qabstractbutton.moc"
+diff --git a/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+index 32437050f5..46b5af6d63 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+@@ -168,6 +168,7 @@ private slots:
+     void checkMenuItemPosWhenStyleSheetIsSet();
+     void checkEmbeddedLineEditWhenStyleSheetIsSet();
+     void propagateStyleChanges();
++    void buttonPressKeys();
+ 
+ private:
+     PlatformInputContext m_platformInputContext;
+@@ -1682,6 +1683,16 @@ void tst_QComboBox::setModel()
+     QCOMPARE(box.rootModelIndex(), rootModelIndex);
+     box.setModel(box.model());
+     QCOMPARE(box.rootModelIndex(), rootModelIndex);
++
++    // check that setting the same model as the completer's doesn't crash
++    QCompleter *completer = new QCompleter(&box);
++    box.setEditable(true);
++    box.setCompleter(completer);
++    auto *listModel = new QStringListModel({ "one", "two" }, completer);
++    completer->setModel(listModel);
++    QCOMPARE(listModel->rowCount(), 2); // make sure it wasn't deleted
++    box.setModel(listModel);
++    QCOMPARE(listModel->rowCount(), 2); // make sure it wasn't deleted
+ }
+ 
+ void tst_QComboBox::setCustomModelAndView()
+@@ -3632,5 +3643,24 @@ void tst_QComboBox::propagateStyleChanges()
+     QVERIFY(frameStyle.inquired);
+ }
+ 
++void tst_QComboBox::buttonPressKeys()
++{
++    QComboBox comboBox;
++    comboBox.setEditable(false);
++    comboBox.addItem(QString::number(1));
++    comboBox.addItem(QString::number(2));
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(&comboBox, buttonPressKeys[i]);
++        // On some platforms, a window will not be immediately visible,
++        // but take some event-loop iterations to complete.
++        // Using QTRY_VERIFY to deal with that.
++        QTRY_VERIFY(comboBox.view()->isVisible());
++        comboBox.hidePopup();
++    }
++}
++
+ QTEST_MAIN(tst_QComboBox)
+ #include "tst_qcombobox.moc"
+diff --git a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
+index be3cfcd104..c228fdfcca 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
++++ b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qcommandlinkbutton
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qcommandlinkbutton.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
+index 0044d33c66..4cf06296e4 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
+@@ -40,6 +40,9 @@
+ #include <QGridLayout>
+ #include <QPainter>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ class tst_QCommandLinkButton : public QObject
+ {
+     Q_OBJECT
+@@ -223,6 +226,13 @@ void tst_QCommandLinkButton::setAutoRepeat()
+     // check that pressing ENTER has no effect
+     resetCounters();
+     testWidget->setDown( false );
++    // Skip after reset if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
+     testWidget->setAutoRepeat( false );
+     QTest::keyPress( testWidget, Qt::Key_Enter );
+ 
+@@ -255,6 +265,14 @@ void tst_QCommandLinkButton::pressed()
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+ 
++    // Skip if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
++
+     QTest::keyPress( testWidget,Qt::Key_Enter );
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+diff --git a/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro b/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
+index 4a5e76ff65..a235fa1fac 100644
+--- a/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
++++ b/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qgroupbox
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qgroupbox.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp b/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
+index 4fb5d262ca..d8d7562b73 100644
+--- a/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
+@@ -35,6 +35,9 @@
+ #include <QRadioButton>
+ #include <QDialog>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ #include "qgroupbox.h"
+ 
+ class tst_QGroupBox : public QObject
+@@ -69,6 +72,7 @@ private slots:
+     void propagateFocus();
+     void task_QTBUG_19170_ignoreMouseReleaseEvent();
+     void task_QTBUG_15519_propagateMouseEvents();
++    void buttonPressKeys();
+ 
+ private:
+     bool checked;
+@@ -610,6 +614,20 @@ void tst_QGroupBox::task_QTBUG_15519_propagateMouseEvents()
+     QCOMPARE(parent.mouseMoved, true);
+ }
+ 
++void tst_QGroupBox::buttonPressKeys()
++{
++    QGroupBox groupBox;
++    groupBox.setCheckable(true);
++    QSignalSpy clickedSpy(&groupBox, &QGroupBox::clicked);
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(&groupBox, buttonPressKeys[i]);
++        QCOMPARE(clickedSpy.length(), i + 1);
++    }
++}
++
+ void tst_QGroupBox::sendMouseMoveEvent(QWidget *widget, const QPoint &localPos)
+ {
+     // Send a MouseMove event without actually moving the pointer
+diff --git a/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro b/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
+index 353ad06ca2..e55f6148f2 100644
+--- a/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
++++ b/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qpushbutton
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qpushbutton.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp b/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
+index e818514a79..4043e9326a 100644
+--- a/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
+@@ -41,6 +41,9 @@
+ #include <QStyleFactory>
+ #include <QTabWidget>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ class tst_QPushButton : public QObject
+ {
+ Q_OBJECT
+@@ -212,6 +215,13 @@ void tst_QPushButton::autoRepeat()
+     // check that pressing ENTER has no effect
+     resetCounters();
+     testWidget->setDown( false );
++    // Skip after reset if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
+     testWidget->setAutoRepeat( false );
+     QTest::keyPress( testWidget, Qt::Key_Enter );
+ 
+@@ -247,6 +257,14 @@ void tst_QPushButton::pressed()
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+ 
++    // Skip if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
++
+     QTest::keyPress( testWidget,Qt::Key_Enter );
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+diff --git a/qtbase/tests/manual/rhi/cubemap_render/buildshader.bat b/qtbase/tests/manual/rhi/cubemap_render/buildshader.bat
+old mode 100755
+new mode 100644
+Submodule qtconnectivity e957d481..056294c0:
+diff --git a/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp b/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
+index e2635fae..a8b8e3b9 100644
+--- a/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
++++ b/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
+@@ -563,9 +563,11 @@ void HciManager::handleHciAclPacket(const quint8 *data, int size)
+ 
+ void HciManager::handleLeMetaEvent(const quint8 *data)
+ {
+-    // Spec v4.2, Vol 2, part E, 7.7.65ff
++    // Spec v5.3, Vol 4, part E, 7.7.65.*
+     switch (*data) {
+-    case 0x1: {
++    case 0x1: // HCI_LE_Connection_Complete
++    case 0xA: // HCI_LE_Enhanced_Connection_Complete
++    {
+         const quint16 handle = bt_get_le16(data + 2);
+         emit connectionComplete(handle);
+         break;
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp b/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
+index 6a93143b..4a18cfc7 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
+@@ -320,7 +320,10 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_finishSdpScan(QBluetoothServiceD
+             for (const QBluetoothUuid &id : serviceClassUuids) {
+                 if (id.minimumSize() == 16) {
+                     serviceInfo.setServiceUuid(id);
+-                    serviceInfo.setServiceName(QBluetoothServiceDiscoveryAgent::tr("Custom Service"));
++                    if (serviceInfo.serviceName().isEmpty()) {
++                        serviceInfo.setServiceName(
++                                    QBluetoothServiceDiscoveryAgent::tr("Custom Service"));
++                    }
+                     QBluetoothServiceInfo::Sequence modSeq =
+                             serviceInfo.attribute(QBluetoothServiceInfo::ServiceClassIds).value<QBluetoothServiceInfo::Sequence>();
+                     modSeq.removeOne(QVariant::fromValue(id));
+@@ -334,8 +337,10 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_finishSdpScan(QBluetoothServiceD
+                 qCDebug(QT_BT_BLUEZ) << "Discovered services" << discoveredDevices.at(0).address().toString()
+                                      << serviceInfo.serviceName() << serviceInfo.serviceUuid()
+                                      << ">>>" << serviceInfo.serviceClassUuids();
+-
+-                emit q->serviceDiscovered(serviceInfo);
++                // Use queued connection to allow us finish the service looping; the application
++                // might call stop() when it has detected the service-of-interest.
++                QMetaObject::invokeMethod(q, "serviceDiscovered", Qt::QueuedConnection,
++                                          Q_ARG(QBluetoothServiceInfo, serviceInfo));
+             }
+         }
+     }
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp b/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
+index e4d85447..aadd4755 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
+@@ -593,7 +593,7 @@ void QBluetoothSocket::setSocketState(QBluetoothSocket::SocketState state)
+ bool QBluetoothSocket::canReadLine() const
+ {
+     Q_D(const QBluetoothSocketBase);
+-    return d->canReadLine();
++    return d->canReadLine() || QIODevice::canReadLine();
+ }
+ 
+ /*!
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp b/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
+index 084aa958..d6aa17a7 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
+@@ -284,6 +284,10 @@ void QBluetoothSocketPrivateBluezDBus::connectToService(
+         return;
+     }
+ 
++    if (service.socketProtocol() != QBluetoothServiceInfo::Protocol::UnknownProtocol)
++        socketType = service.socketProtocol();
++    qCDebug(QT_BT_BLUEZ) << "Socket protocol used:" << socketType;
++
+     connectToService(service.device().address(), targetService, openMode);
+ }
+ 
+diff --git a/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp b/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
+index 05bc1a0f..a7b5ef1f 100644
+--- a/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
++++ b/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
+@@ -142,7 +142,7 @@ void tst_QBluetoothSocket::initTestCase()
+     qDebug() << "Starting discovery";
+ 
+     sda->setUuidFilter(QBluetoothUuid(QString(TEST_SERVICE_UUID)));
+-    sda->start(QBluetoothServiceDiscoveryAgent::MinimalDiscovery);
++    sda->start(QBluetoothServiceDiscoveryAgent::FullDiscovery);
+ 
+     for (int connectTime = MaxConnectTime; !done_discovery && connectTime > 0; connectTime -= 1000)
+         QTest::qWait(1000);
+Submodule qtdeclarative f5701f0d..8defe7bf:
+diff --git a/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h b/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
+index b65b994d6c..15a8cd6878 100644
+--- a/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
++++ b/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
+@@ -86,7 +86,7 @@ public:
+         if (QTypeInfo<T>::isComplex) {
+             for (int i = 0; i < count; ++i)
+                 new (data + i) T(vector.at(i));
+-        } else {
++        } else if (count) {
+             memcpy(data, static_cast<const void*>(vector.constData()), count * sizeof(T));
+         }
+     }
+diff --git a/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp b/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
+index e57cdd8278..94613598af 100644
+--- a/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
++++ b/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
+@@ -1145,8 +1145,7 @@ void Heap::QObjectWrapper::markObjects(Heap::Base *that, QV4::MarkStack *markSta
+ void QObjectWrapper::destroyObject(bool lastCall)
+ {
+     Heap::QObjectWrapper *h = d();
+-    if (!h->internalClass)
+-        return; // destroyObject already got called
++    Q_ASSERT(h->internalClass);
+ 
+     if (h->object()) {
+         QQmlData *ddata = QQmlData::get(h->object(), false);
+@@ -1176,7 +1175,7 @@ void QObjectWrapper::destroyObject(bool lastCall)
+         }
+     }
+ 
+-    h->~Data();
++    h->destroy();
+ }
+ 
+ 
+diff --git a/qtdeclarative/src/qml/memory/qv4mm.cpp b/qtdeclarative/src/qml/memory/qv4mm.cpp
+index 06caf04e5a..da149a67c4 100644
+--- a/qtdeclarative/src/qml/memory/qv4mm.cpp
++++ b/qtdeclarative/src/qml/memory/qv4mm.cpp
+@@ -981,7 +981,7 @@ void MemoryManager::sweep(bool lastSweep, ClassDestroyStatsCallback classCountPt
+ 
+     if (MultiplyWrappedQObjectMap *multiplyWrappedQObjects = engine->m_multiplyWrappedQObjects) {
+         for (MultiplyWrappedQObjectMap::Iterator it = multiplyWrappedQObjects->begin(); it != multiplyWrappedQObjects->end();) {
+-            if (!it.value().isNullOrUndefined())
++            if (it.value().isNullOrUndefined())
+                 it = multiplyWrappedQObjects->erase(it);
+             else
+                 ++it;
+diff --git a/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp b/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
+index 2079a8ed04..a577cb2351 100644
+--- a/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
++++ b/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
+@@ -389,6 +389,12 @@ void QQmlDelegateModelPrivate::connectToAbstractItemModel()
+                       q,  QQmlDelegateModel, SLOT(_q_rowsRemoved(QModelIndex,int,int)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
+                       q,  QQmlDelegateModel, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsInserted(QModelIndex,int,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsInserted(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsRemoved(QModelIndex,int,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsRemoved(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsMoved(QModelIndex,int,int,QModelIndex,int)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
+                       q, QQmlDelegateModel, SLOT(_q_dataChanged(QModelIndex,QModelIndex,QVector<int>)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
+@@ -413,6 +419,12 @@ void QQmlDelegateModelPrivate::disconnectFromAbstractItemModel()
+                         q, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int)));
+     QObject::disconnect(aim, SIGNAL(rowsRemoved(QModelIndex,int,int)),
+                         q, SLOT(_q_rowsRemoved(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsInserted(QModelIndex,int,int)), q,
++                        SLOT(_q_columnsInserted(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsRemoved(QModelIndex,int,int)), q,
++                        SLOT(_q_columnsRemoved(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)), q,
++                        SLOT(_q_columnsMoved(QModelIndex,int,int,QModelIndex,int)));
+     QObject::disconnect(aim, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
+                         q, SLOT(_q_dataChanged(QModelIndex,QModelIndex,QVector<int>)));
+     QObject::disconnect(aim, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
+@@ -1973,6 +1985,38 @@ void QQmlDelegateModel::_q_rowsMoved(
+     }
+ }
+ 
++void QQmlDelegateModel::_q_columnsInserted(const QModelIndex &parent, int begin, int end)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if (parent == d->m_adaptorModel.rootIndex && begin == 0) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
++void QQmlDelegateModel::_q_columnsRemoved(const QModelIndex &parent, int begin, int end)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if (parent == d->m_adaptorModel.rootIndex && begin == 0) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
++void QQmlDelegateModel::_q_columnsMoved(const QModelIndex &parent, int start, int end,
++                                        const QModelIndex &destination, int column)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if ((parent == d->m_adaptorModel.rootIndex && start == 0)
++        || (destination == d->m_adaptorModel.rootIndex && column == 0)) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
+ void QQmlDelegateModel::_q_dataChanged(const QModelIndex &begin, const QModelIndex &end, const QVector<int> &roles)
+ {
+     Q_D(QQmlDelegateModel);
+diff --git a/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h b/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
+index 8aab4badca..d140bfbaaf 100644
+--- a/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
++++ b/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
+@@ -152,6 +152,9 @@ private Q_SLOTS:
+     void _q_itemsMoved(int from, int to, int count);
+     void _q_modelReset();
+     void _q_rowsInserted(const QModelIndex &,int,int);
++    void _q_columnsInserted(const QModelIndex &, int, int);
++    void _q_columnsRemoved(const QModelIndex &, int, int);
++    void _q_columnsMoved(const QModelIndex &, int, int, const QModelIndex &, int);
+     void _q_rowsAboutToBeRemoved(const QModelIndex &parent, int begin, int end);
+     void _q_rowsRemoved(const QModelIndex &,int,int);
+     void _q_rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int);
+diff --git a/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp b/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
+index 85719fdc80..78e2ab302c 100644
+--- a/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
++++ b/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
+@@ -46,6 +46,7 @@
+ #include "QtQuick/private/qquicktextinput_p.h"
+ #include "QtQuick/private/qquickaccessibleattached_p.h"
+ #include "QtQuick/qquicktextdocument.h"
++#include "QtQuick/qquickrendercontrol.h"
+ QT_BEGIN_NAMESPACE
+ 
+ #if QT_CONFIG(accessibility)
+@@ -57,7 +58,19 @@ QAccessibleQuickItem::QAccessibleQuickItem(QQuickItem *item)
+ 
+ QWindow *QAccessibleQuickItem::window() const
+ {
+-    return item()->window();
++    QQuickWindow *window = item()->window();
++
++    // For QQuickWidget the above window will be the offscreen QQuickWindow,
++    // which is not a part of the accessibility tree. Detect this case and
++    // return the window for the QQuickWidget instead.
++    if (window && !window->handle()) {
++        if (QQuickRenderControl *renderControl = QQuickWindowPrivate::get(window)->renderControl) {
++            if (QWindow *renderWindow = renderControl->renderWindow(nullptr))
++                return renderWindow;
++        }
++    }
++
++    return window;
+ }
+ 
+ int QAccessibleQuickItem::childCount() const
+@@ -113,19 +126,15 @@ QAccessibleInterface *QAccessibleQuickItem::childAt(int x, int y) const
+ QAccessibleInterface *QAccessibleQuickItem::parent() const
+ {
+     QQuickItem *parent = item()->parentItem();
+-    QQuickWindow *window = item()->window();
+-    QQuickItem *ci = window ? window->contentItem() : nullptr;
++    QQuickWindow *itemWindow = item()->window();
++    QQuickItem *ci = itemWindow ? itemWindow->contentItem() : nullptr;
+     while (parent && !QQuickItemPrivate::get(parent)->isAccessible && parent != ci)
+         parent = parent->parentItem();
+ 
+     if (parent) {
+         if (parent == ci) {
+-            // Jump out to the scene widget if the parent is the root item.
+-            // There are two root items, QQuickWindow::rootItem and
+-            // QQuickView::declarativeRoot. The former is the true root item,
+-            // but is not a part of the accessibility tree. Check if we hit
+-            // it here and return an interface for the scene instead.
+-            return QAccessible::queryAccessibleInterface(window);
++            // Jump out to the window if the parent is the root item
++            return QAccessible::queryAccessibleInterface(window());
+         } else {
+             while (parent && !parent->d_func()->isAccessible)
+                 parent = parent->parentItem();
+@@ -188,7 +197,7 @@ QAccessible::State QAccessibleQuickItem::state() const
+     QRect viewRect_ = viewRect();
+     QRect itemRect = rect();
+ 
+-    if (viewRect_.isNull() || itemRect.isNull() || !item()->window() || !item()->window()->isVisible() ||!item()->isVisible() || qFuzzyIsNull(item()->opacity()))
++    if (viewRect_.isNull() || itemRect.isNull() || !window() || !window()->isVisible() ||!item()->isVisible() || qFuzzyIsNull(item()->opacity()))
+         state.invisible = true;
+     if (!viewRect_.intersects(itemRect))
+         state.offscreen = true;
+@@ -201,6 +210,10 @@ QAccessible::State QAccessibleQuickItem::state() const
+     if (role() == QAccessible::EditableText)
+         if (auto ti = qobject_cast<QQuickTextInput *>(item()))
+             state.passwordEdit = ti->echoMode() != QQuickTextInput::Normal;
++    if (!item()->isEnabled()) {
++        state.focusable = false;
++        state.disabled = true;
++    }
+     return state;
+ }
+ 
+diff --git a/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h b/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
+index 39ffcaf39c..8baa01330c 100644
+--- a/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
++++ b/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
+@@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE
+ 
+ #if QT_CONFIG(accessibility)
+ 
+-class QAccessibleQuickWindow : public QAccessibleObject
++class Q_QUICK_EXPORT QAccessibleQuickWindow : public QAccessibleObject
+ {
+ public:
+     QAccessibleQuickWindow(QQuickWindow *object);
+diff --git a/qtdeclarative/src/quick/items/qquickdrag.cpp b/qtdeclarative/src/quick/items/qquickdrag.cpp
+index 8321fcfeed..383078b3b9 100644
+--- a/qtdeclarative/src/quick/items/qquickdrag.cpp
++++ b/qtdeclarative/src/quick/items/qquickdrag.cpp
+@@ -481,7 +481,9 @@ void QQuickDragAttached::setKeys(const QStringList &keys)
+     \qmlattachedproperty stringlist QtQuick::Drag::mimeData
+     \since 5.2
+ 
+-    This property holds a map of mimeData that is used during startDrag.
++    This property holds a map from mime type to data that is used during startDrag.
++    The mime data needs to be a \c string, or an \c ArrayBuffer with the data encoded
++    according to the mime type.
+ */
+ 
+ QVariantMap QQuickDragAttached::mimeData() const
+@@ -766,8 +768,12 @@ Qt::DropAction QQuickDragAttachedPrivate::startDrag(Qt::DropActions supportedAct
+     QDrag *drag = new QDrag(source ? source : q);
+     QMimeData *mimeData = new QMimeData();
+ 
+-    for (auto it = externalMimeData.cbegin(), end = externalMimeData.cend(); it != end; ++it)
+-        mimeData->setData(it.key(), it.value().toString().toUtf8());
++    for (auto it = externalMimeData.cbegin(), end = externalMimeData.cend(); it != end; ++it) {
++        if (static_cast<QMetaType::Type>(it.value().type()) == QMetaType::QByteArray)
++            mimeData->setData(it.key(), it.value().toByteArray());
++        else
++            mimeData->setData(it.key(), it.value().toString().toUtf8());
++    }
+ 
+     drag->setMimeData(mimeData);
+     if (pixmapLoader.isReady()) {
+diff --git a/qtdeclarative/src/quick/items/qquickitem.cpp b/qtdeclarative/src/quick/items/qquickitem.cpp
+index 75f1457816..dec0ae19ae 100644
+--- a/qtdeclarative/src/quick/items/qquickitem.cpp
++++ b/qtdeclarative/src/quick/items/qquickitem.cpp
+@@ -59,6 +59,7 @@
+ #include <QtCore/private/qnumeric_p.h>
+ #include <QtGui/qpa/qplatformtheme.h>
+ #include <QtCore/qloggingcategory.h>
++#include <QtCore/private/qduplicatetracker_p.h>
+ 
+ #include <private/qqmlglobal_p.h>
+ #include <private/qqmlengine_p.h>
+@@ -2326,6 +2327,7 @@ QQuickItem::QQuickItem(QQuickItemPrivate &dd, QQuickItem *parent)
+ QQuickItem::~QQuickItem()
+ {
+     Q_D(QQuickItem);
++    d->inDestructor = true;
+ 
+     if (d->windowRefCount > 1)
+         d->windowRefCount = 1; // Make sure window is set to null in next call to derefWindow().
+@@ -2526,6 +2528,7 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo
+     QQuickItem *current = item;
+     qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: startItem:" << startItem;
+     qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: firstFromItem:" << firstFromItem;
++    QDuplicateTracker<QQuickItem *> cycleDetector;
+     do {
+         qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: current:" << current;
+         qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: from:" << from;
+@@ -2592,7 +2595,10 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo
+         // traversed all of the chain (by compare the [current] item with [startItem])
+         // Since the [startItem] might be promoted to its parent if it is invisible,
+         // we still have to check [current] item with original start item
+-        if ((current == startItem || current == originalStartItem) && from == firstFromItem) {
++        // We might also run into a cycle before we reach firstFromItem again
++        // but note that we have to ignore current if we are meant to skip it
++        if (((current == startItem || current == originalStartItem) && from == firstFromItem) ||
++                (!skip && cycleDetector.hasSeen(current))) {
+             // wrapped around, avoid endless loops
+             if (item == contentItem) {
+                 qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: looped, return contentItem";
+@@ -2689,9 +2695,8 @@ void QQuickItem::setParentItem(QQuickItem *parentItem)
+ 
+         const bool wasVisible = isVisible();
+         op->removeChild(this);
+-        if (wasVisible) {
++        if (wasVisible && !op->inDestructor)
+             emit oldParentItem->visibleChildrenChanged();
+-        }
+     } else if (d->window) {
+         QQuickWindowPrivate::get(d->window)->parentlessItems.remove(this);
+     }
+@@ -2768,8 +2773,9 @@ void QQuickItem::setParentItem(QQuickItem *parentItem)
+ 
+     d->itemChange(ItemParentHasChanged, d->parentItem);
+ 
+-    emit parentChanged(d->parentItem);
+-    if (isVisible() && d->parentItem)
++    if (!d->inDestructor)
++        emit parentChanged(d->parentItem);
++    if (isVisible() && d->parentItem && !QQuickItemPrivate::get(d->parentItem)->inDestructor)
+         emit d->parentItem->visibleChildrenChanged();
+ }
+ 
+@@ -2965,7 +2971,8 @@ void QQuickItemPrivate::removeChild(QQuickItem *child)
+ 
+     itemChange(QQuickItem::ItemChildRemovedChange, child);
+ 
+-    emit q->childrenChanged();
++    if (!inDestructor)
++        emit q->childrenChanged();
+ }
+ 
+ void QQuickItemPrivate::refWindow(QQuickWindow *c)
+@@ -3194,6 +3201,7 @@ QQuickItemPrivate::QQuickItemPrivate()
+     , touchEnabled(false)
+ #endif
+     , hasCursorHandler(false)
++    , inDestructor(false)
+     , dirtyAttributes(0)
+     , nextDirtyItem(nullptr)
+     , prevDirtyItem(nullptr)
+@@ -5120,6 +5128,13 @@ void QQuickItem::componentComplete()
+         d->addToDirtyList();
+         QQuickWindowPrivate::get(d->window)->dirtyItem(this);
+     }
++
++#if QT_CONFIG(accessibility)
++    if (d->isAccessible && d->effectiveVisible) {
++        QAccessibleEvent ev(this, QAccessible::ObjectShow);
++        QAccessible::updateAccessibility(&ev);
++    }
++#endif
+ }
+ 
+ QQuickStateGroup *QQuickItemPrivate::_states()
+@@ -6106,9 +6121,11 @@ bool QQuickItemPrivate::setEffectiveVisibleRecur(bool newEffectiveVisible)
+         QAccessible::updateAccessibility(&ev);
+     }
+ #endif
+-    emit q->visibleChanged();
+-    if (childVisibilityChanged)
+-        emit q->visibleChildrenChanged();
++    if (!inDestructor) {
++        emit q->visibleChanged();
++        if (childVisibilityChanged)
++            emit q->visibleChildrenChanged();
++    }
+ 
+     return true;    // effective visibility DID change
+ }
+@@ -6157,6 +6174,15 @@ void QQuickItemPrivate::setEffectiveEnableRecur(QQuickItem *scope, bool newEffec
+     }
+ 
+     itemChange(QQuickItem::ItemEnabledHasChanged, effectiveEnable);
++#if QT_CONFIG(accessibility)
++    if (isAccessible) {
++        QAccessible::State changedState;
++        changedState.disabled = true;
++        changedState.focusable = true;
++        QAccessibleStateChangeEvent ev(q, changedState);
++        QAccessible::updateAccessibility(&ev);
++    }
++#endif
+     emit q->enabledChanged();
+ }
+ 
+diff --git a/qtdeclarative/src/quick/items/qquickitem_p.h b/qtdeclarative/src/quick/items/qquickitem_p.h
+index 841d91bb40..ade8fb61f2 100644
+--- a/qtdeclarative/src/quick/items/qquickitem_p.h
++++ b/qtdeclarative/src/quick/items/qquickitem_p.h
+@@ -472,6 +472,7 @@ public:
+     bool replayingPressEvent:1;
+     bool touchEnabled:1;
+     bool hasCursorHandler:1;
++    quint32 inDestructor:1; // has entered ~QQuickItem
+ 
+     enum DirtyType {
+         TransformOrigin         = 0x00000001,
+diff --git a/qtdeclarative/src/quick/items/qquickitemview.cpp b/qtdeclarative/src/quick/items/qquickitemview.cpp
+index 010a0152e1..f8ad168a17 100644
+--- a/qtdeclarative/src/quick/items/qquickitemview.cpp
++++ b/qtdeclarative/src/quick/items/qquickitemview.cpp
+@@ -1785,7 +1785,7 @@ void QQuickItemViewPrivate::refill(qreal from, qreal to)
+ 
+     do {
+         bufferPause.stop();
+-        if (currentChanges.hasPendingChanges() || bufferedChanges.hasPendingChanges()) {
++        if (currentChanges.hasPendingChanges() || bufferedChanges.hasPendingChanges() || currentChanges.active) {
+             currentChanges.reset();
+             bufferedChanges.reset();
+             releaseVisibleItems(reusableFlag);
+diff --git a/qtdeclarative/src/quick/items/qquickmousearea_p_p.h b/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
+index fba383e268..0d63618622 100644
+--- a/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
++++ b/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
+@@ -61,7 +61,6 @@ QT_BEGIN_NAMESPACE
+ 
+ class QQuickMouseEvent;
+ class QQuickMouseArea;
+-class QQuickPointerMask;
+ class QQuickMouseAreaPrivate : public QQuickItemPrivate
+ {
+     Q_DECLARE_PUBLIC(QQuickMouseArea)
+@@ -100,7 +99,6 @@ public:
+ #if QT_CONFIG(quick_draganddrop)
+     QQuickDrag *drag;
+ #endif
+-    QPointer<QQuickPointerMask> mask;
+     QPointF startScene;
+     QPointF targetStartPos;
+     QPointF lastPos;
+diff --git a/qtdeclarative/src/quick/items/qquicktext.cpp b/qtdeclarative/src/quick/items/qquicktext.cpp
+index 6230186933..e823ca1095 100644
+--- a/qtdeclarative/src/quick/items/qquicktext.cpp
++++ b/qtdeclarative/src/quick/items/qquicktext.cpp
+@@ -2168,7 +2168,7 @@ void QQuickText::resetMaximumLineCount()
+     <img src="" align="top,middle,bottom" width="" height=""> - inline images
+     <ol type="">, <ul type=""> and <li> - ordered and unordered lists
+     <pre></pre> - preformatted
+-    &gt; &lt; &amp;
++    &gt; &lt; &amp; &quot; &nbsp; &apos;
+     \endcode
+ 
+     \c Text.StyledText parser is strict, requiring tags to be correctly nested.
+diff --git a/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp b/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
+index eb4db0f85e..2325a2665b 100644
+--- a/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
++++ b/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
+@@ -446,7 +446,7 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+         const char *textureRecord = allocatorData;
+         for (int i = 0; i < textureCount; ++i, textureRecord += Qtdf::TextureRecordSize) {
+-            if (textureRecord + Qtdf::TextureRecordSize > qtdfTableEnd) {
++            if (qtdfTableEnd - textureRecord < Qtdf::TextureRecordSize) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+@@ -462,7 +462,7 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+         const char *glyphRecord = textureRecord;
+         for (quint32 i = 0; i < glyphCount; ++i, glyphRecord += Qtdf::GlyphRecordSize) {
+-            if (glyphRecord + Qtdf::GlyphRecordSize > qtdfTableEnd) {
++            if (qtdfTableEnd - glyphRecord < Qtdf:: GlyphRecordSize) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+@@ -512,8 +512,8 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+             int width = texInfo->allocatedArea.width();
+             int height = texInfo->allocatedArea.height();
+-            qint64 size = width * height;
+-            if (reinterpret_cast<const char *>(textureData + size) > qtdfTableEnd) {
++            qint64 size = qint64(width) * height;
++            if (qtdfTableEnd - reinterpret_cast<const char *>(textureData) < size) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+diff --git a/qtdeclarative/src/quick/util/qquickstyledtext.cpp b/qtdeclarative/src/quick/util/qquickstyledtext.cpp
+index d531fc9205..a25af90414 100644
+--- a/qtdeclarative/src/quick/util/qquickstyledtext.cpp
++++ b/qtdeclarative/src/quick/util/qquickstyledtext.cpp
+@@ -564,6 +564,8 @@ void QQuickStyledTextPrivate::parseEntity(const QChar *&ch, const QString &textI
+                 textOut += QChar(60);
+             else if (entity == QLatin1String("amp"))
+                 textOut += QChar(38);
++            else if (entity == QLatin1String("apos"))
++                textOut += QChar(39);
+             else if (entity == QLatin1String("quot"))
+                 textOut += QChar(34);
+             else if (entity == QLatin1String("nbsp"))
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp
+new file mode 100644
+index 0000000000..8a1c901880
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp
+@@ -0,0 +1,110 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include "qaccessiblequickwidget_p.h"
++
++#include "qquickwidget_p.h"
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleQuickWidget::QAccessibleQuickWidget(QQuickWidget* widget)
++: QAccessibleWidget(widget)
++, m_accessibleWindow(QQuickWidgetPrivate::get(widget)->offscreenWindow)
++{
++    // NOTE: m_accessibleWindow is a QAccessibleQuickWindow, and not a
++    // QAccessibleQuickWidgetOffscreenWindow (defined below). This means
++    // it will return the Quick item child interfaces, which is what's needed here
++    // (unlike QAccessibleQuickWidgetOffscreenWindow, which will report 0 children).
++}
++
++QAccessibleInterface *QAccessibleQuickWidget::child(int index) const
++{
++    return m_accessibleWindow.child(index);
++}
++
++int QAccessibleQuickWidget::childCount() const
++{
++    return m_accessibleWindow.childCount();
++}
++
++int QAccessibleQuickWidget::indexOfChild(const QAccessibleInterface *iface) const
++{
++    return m_accessibleWindow.indexOfChild(iface);
++}
++
++QAccessibleInterface *QAccessibleQuickWidget::childAt(int x, int y) const
++{
++    return m_accessibleWindow.childAt(x, y);
++}
++
++QAccessibleQuickWidgetOffscreenWindow::QAccessibleQuickWidgetOffscreenWindow(QQuickWindow *window)
++:QAccessibleQuickWindow(window)
++{
++
++}
++
++QAccessibleInterface *QAccessibleQuickWidgetOffscreenWindow::child(int index) const
++{
++    Q_UNUSED(index);
++    return nullptr;
++}
++
++int QAccessibleQuickWidgetOffscreenWindow::childCount() const
++{
++    return 0;
++}
++
++int QAccessibleQuickWidgetOffscreenWindow::indexOfChild(const QAccessibleInterface *iface) const
++{
++    Q_UNUSED(iface);
++    return -1;
++}
++
++QAccessibleInterface *QAccessibleQuickWidgetOffscreenWindow::QAccessibleQuickWidgetOffscreenWindow::childAt(int x, int y) const
++{
++    Q_UNUSED(x);
++    Q_UNUSED(y);
++    return nullptr;
++}
++
++#endif // accessibility
++
++QT_END_NAMESPACE
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h
+new file mode 100644
+index 0000000000..7c2ab930e0
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h
+@@ -0,0 +1,95 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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 QACCESSIBLEQUICKWIDGET_H
++#define QACCESSIBLEQUICKWIDGET_H
++
++//
++//  W A R N I N G
++//  -------------
++//
++// This file is not part of the Qt API.  It exists purely as an
++// implementation detail.  This header file may change from version to
++// version without notice, or even be removed.
++//
++// We mean it.
++//
++
++#include "qquickwidget.h"
++#include <QtWidgets/qaccessiblewidget.h>
++
++#include <private/qaccessiblequickview_p.h>
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++// These classes implement the QQuickWiget accessibility switcharoo,
++// where the child items of the QQuickWidgetOffscreenWindow are reported
++// as child accessible interfaces of the QAccessibleQuickWidget.
++class QAccessibleQuickWidget: public QAccessibleWidget
++{
++public:
++    QAccessibleQuickWidget(QQuickWidget* widget);
++
++    QAccessibleInterface *child(int index) const override;
++    int childCount() const override;
++    int indexOfChild(const QAccessibleInterface *iface) const override;
++    QAccessibleInterface *childAt(int x, int y) const override;
++
++private:
++    QAccessibleQuickWindow m_accessibleWindow;
++    Q_DISABLE_COPY(QAccessibleQuickWidget)
++};
++
++class QAccessibleQuickWidgetOffscreenWindow: public QAccessibleQuickWindow
++{
++public:
++    QAccessibleQuickWidgetOffscreenWindow(QQuickWindow *window);
++    QAccessibleInterface *child(int index) const override;
++    int childCount() const override;
++    int indexOfChild(const QAccessibleInterface *iface) const override;
++    QAccessibleInterface *childAt(int x, int y) const override;
++};
++
++#endif // accessibility
++
++QT_END_NAMESPACE
++
++#endif
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp
+new file mode 100644
+index 0000000000..7ba88a1769
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp
+@@ -0,0 +1,60 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include "qaccessiblequickwidgetfactory_p.h"
++#include "qaccessiblequickwidget_p.h"
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleInterface *qAccessibleQuickWidgetFactory(const QString &classname, QObject *object)
++{
++    if (classname == QLatin1String("QQuickWidget")) {
++        return new QAccessibleQuickWidget(qobject_cast<QQuickWidget *>(object));
++    } else if (classname == QLatin1String("QQuickWidgetOffscreenWindow")) {
++        return new QAccessibleQuickWidgetOffscreenWindow(qobject_cast<QQuickWindow *>(object));
++    }
++    return 0;
++}
++
++#endif // accessibility
++
++QT_END_NAMESPACE
++
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h
+new file mode 100644
+index 0000000000..8c63b09f81
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h
+@@ -0,0 +1,66 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include <QtGui/qaccessible.h>
++
++#ifndef QACCESSIBLEQUICKWIDGETFACTORY_H
++#define QACCESSIBLEQUICKWIDGETFACTORY_H
++
++//
++//  W A R N I N G
++//  -------------
++//
++// This file is not part of the Qt API.  It exists purely as an
++// implementation detail.  This header file may change from version to
++// version without notice, or even be removed.
++//
++// We mean it.
++//
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleInterface *qAccessibleQuickWidgetFactory(const QString &classname, QObject *object);
++
++#endif
++
++QT_END_NAMESPACE
++
++#endif
+diff --git a/qtdeclarative/src/quickwidgets/qquickwidget.cpp b/qtdeclarative/src/quickwidgets/qquickwidget.cpp
+index 39780f8de3..9c97b43518 100644
+--- a/qtdeclarative/src/quickwidgets/qquickwidget.cpp
++++ b/qtdeclarative/src/quickwidgets/qquickwidget.cpp
+@@ -39,6 +39,7 @@
+ 
+ #include "qquickwidget.h"
+ #include "qquickwidget_p.h"
++#include "qaccessiblequickwidgetfactory_p.h"
+ 
+ #include "private/qquickwindow_p.h"
+ #include "private/qquickitem_p.h"
+@@ -75,9 +76,16 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++QQuickWidgetOffscreenWindow::QQuickWidgetOffscreenWindow(QQuickWindowPrivate &dd, QQuickRenderControl *control)
++:QQuickWindow(dd, control)
++{
++    setTitle(QString::fromLatin1("Offscreen"));
++    setObjectName(QString::fromLatin1("QQuickOffScreenWindow"));
++}
++
+ // override setVisble to prevent accidental offscreen window being created
+ // by base class.
+-class QQuickOffcreenWindowPrivate: public QQuickWindowPrivate {
++class QQuickWidgetOffscreenWindowPrivate: public QQuickWindowPrivate {
+ public:
+     void setVisible(bool visible) override {
+         Q_Q(QWindow);
+@@ -105,9 +113,8 @@ void QQuickWidgetPrivate::init(QQmlEngine* e)
+     Q_Q(QQuickWidget);
+ 
+     renderControl = new QQuickWidgetRenderControl(q);
+-    offscreenWindow = new QQuickWindow(*new QQuickOffcreenWindowPrivate(),renderControl);
+-    offscreenWindow->setTitle(QString::fromLatin1("Offscreen"));
+-    offscreenWindow->setObjectName(QString::fromLatin1("QQuickOffScreenWindow"));
++    offscreenWindow = new QQuickWidgetOffscreenWindow(*new QQuickWidgetOffscreenWindowPrivate(), renderControl);
++    offscreenWindow->setScreen(q->screen());
+     // Do not call create() on offscreenWindow.
+ 
+     // Check if the Software Adaptation is being used
+@@ -138,6 +145,10 @@ void QQuickWidgetPrivate::init(QQmlEngine* e)
+     QWidget::connect(offscreenWindow, &QQuickWindow::focusObjectChanged, q, &QQuickWidget::propagateFocusObjectChanged);
+     QObject::connect(renderControl, SIGNAL(renderRequested()), q, SLOT(triggerUpdate()));
+     QObject::connect(renderControl, SIGNAL(sceneChanged()), q, SLOT(triggerUpdate()));
++
++#if QT_CONFIG(accessibility)
++    QAccessible::installFactory(&qAccessibleQuickWidgetFactory);
++#endif
+ }
+ 
+ void QQuickWidgetPrivate::ensureEngine() const
+@@ -901,9 +912,7 @@ void QQuickWidgetPrivate::createContext()
+ 
+         context = new QOpenGLContext;
+         context->setFormat(offscreenWindow->requestedFormat());
+-        const QWindow *win = q->window()->windowHandle();
+-        if (win && win->screen())
+-            context->setScreen(win->screen());
++        context->setScreen(q->screen());
+         QOpenGLContext *shareContext = qt_gl_global_share_context();
+         if (!shareContext)
+             shareContext = QWidgetPrivate::get(q->window())->shareContext();
+@@ -1520,19 +1529,16 @@ bool QQuickWidget::event(QEvent *e)
+         d->handleWindowChange();
+         break;
+ 
+-    case QEvent::ScreenChangeInternal:
+-        if (QWindow *window = this->window()->windowHandle()) {
+-            QScreen *newScreen = window->screen();
+-
+-            if (d->offscreenWindow)
+-                d->offscreenWindow->setScreen(newScreen);
+-            if (d->offscreenSurface)
+-                d->offscreenSurface->setScreen(newScreen);
++    case QEvent::ScreenChangeInternal: {
++        QScreen *newScreen = screen();
++        if (d->offscreenWindow)
++            d->offscreenWindow->setScreen(newScreen);
++        if (d->offscreenSurface)
++            d->offscreenSurface->setScreen(newScreen);
+ #if QT_CONFIG(opengl)
+-            if (d->context)
+-                d->context->setScreen(newScreen);
++        if (d->context)
++            d->context->setScreen(newScreen);
+ #endif
+-        }
+ 
+         if (d->useSoftwareRenderer
+ #if QT_CONFIG(opengl)
+@@ -1545,7 +1551,7 @@ bool QQuickWidget::event(QEvent *e)
+             d->render(true);
+         }
+         break;
+-
++    }
+     case QEvent::Show:
+     case QEvent::Move:
+         d->updatePosition();
+diff --git a/qtdeclarative/src/quickwidgets/qquickwidget_p.h b/qtdeclarative/src/quickwidgets/qquickwidget_p.h
+index 881f7f9220..1a946bcc71 100644
+--- a/qtdeclarative/src/quickwidgets/qquickwidget_p.h
++++ b/qtdeclarative/src/quickwidgets/qquickwidget_p.h
+@@ -148,6 +148,14 @@ public:
+     bool forceFullUpdate;
+ };
+ 
++class QQuickWidgetOffscreenWindow: public QQuickWindow
++{
++    Q_OBJECT
++
++public:
++    QQuickWidgetOffscreenWindow(QQuickWindowPrivate &dd, QQuickRenderControl *control);
++};
++
+ QT_END_NAMESPACE
+ 
+ #endif // QQuickWidget_P_H
+diff --git a/qtdeclarative/src/quickwidgets/quickwidgets.pro b/qtdeclarative/src/quickwidgets/quickwidgets.pro
+index 2438e577ae..85d156b8a3 100644
+--- a/qtdeclarative/src/quickwidgets/quickwidgets.pro
++++ b/qtdeclarative/src/quickwidgets/quickwidgets.pro
+@@ -7,9 +7,13 @@ DEFINES   += QT_NO_URL_CAST_FROM_STRING QT_NO_INTEGER_EVENT_COORDINATES QT_NO_FO
+ HEADERS += \
+     qquickwidget.h \
+     qquickwidget_p.h \
+-    qtquickwidgetsglobal.h
++    qtquickwidgetsglobal.h \
++    qaccessiblequickwidget_p.h \
++    qaccessiblequickwidgetfactory_p.h
+ 
+ SOURCES += \
+-    qquickwidget.cpp
++    qquickwidget.cpp \
++    qaccessiblequickwidget.cpp \
++    qaccessiblequickwidgetfactory.cpp
+ 
+ load(qt_module)
+diff --git a/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+index 3b7d74df63..b75bf820d5 100644
+--- a/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
++++ b/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+@@ -102,6 +102,7 @@ private slots:
+     void valueConversion_RegularExpression();
+     void castWithMultipleInheritance();
+     void collectGarbage();
++    void collectGarbageNestedWrappersTwoEngines();
+     void gcWithNestedDataStructure();
+     void stacktrace();
+     void numberParsing_data();
+@@ -1809,6 +1810,44 @@ void tst_QJSEngine::collectGarbage()
+     QVERIFY(ptr.isNull());
+ }
+ 
++class TestObjectContainer : public QObject
++{
++    Q_OBJECT
++    Q_PROPERTY(QObject *dummy MEMBER m_dummy CONSTANT)
++
++public:
++    TestObjectContainer() : m_dummy(new QObject(this)) {}
++
++private:
++    QObject *m_dummy;
++};
++
++void tst_QJSEngine::collectGarbageNestedWrappersTwoEngines()
++{
++    QJSEngine engine1;
++    QJSEngine engine2;
++
++    TestObjectContainer container;
++    QQmlEngine::setObjectOwnership(&container, QQmlEngine::CppOwnership);
++
++    engine1.globalObject().setProperty("foobar", engine1.newQObject(&container));
++    engine2.globalObject().setProperty("foobar", engine2.newQObject(&container));
++
++    engine1.evaluate("foobar.dummy.baz = 42");
++    engine2.evaluate("foobar.dummy.baz = 43");
++
++    QCOMPARE(engine1.evaluate("foobar.dummy.baz").toInt(), 42);
++    QCOMPARE(engine2.evaluate("foobar.dummy.baz").toInt(), 43);
++
++    engine1.collectGarbage();
++    engine2.collectGarbage();
++
++    // The GC should not collect dummy object wrappers neither in engine1 nor engine2, we
++    // verify that by checking whether the baz property still has its previous value.
++    QCOMPARE(engine1.evaluate("foobar.dummy.baz").toInt(), 42);
++    QCOMPARE(engine2.evaluate("foobar.dummy.baz").toInt(), 43);
++}
++
+ void tst_QJSEngine::gcWithNestedDataStructure()
+ {
+     // The GC must be able to traverse deeply nested objects, otherwise this
+diff --git a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml
+new file mode 100644
+index 0000000000..206133bb39
+--- /dev/null
++++ b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml
+@@ -0,0 +1,11 @@
++import QtQuick 2.8
++
++ListView {
++    id: root
++    width: 200
++    height: 200
++
++    delegate: Text {
++        text: display
++    }
++}
+diff --git a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
+index 35f1e2c94d..1722447830 100644
+--- a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
++++ b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
+@@ -27,6 +27,8 @@
+ ****************************************************************************/
+ 
+ #include <QtTest/qtest.h>
++#include <QtCore/QConcatenateTablesProxyModel>
++#include <QtGui/QStandardItemModel>
+ #include <QtQml/qqmlcomponent.h>
+ #include <QtQmlModels/private/qqmldelegatemodel_p.h>
+ #include <QtQuick/qquickview.h>
+@@ -47,6 +49,7 @@ private slots:
+     void filterOnGroup_removeWhenCompleted();
+     void qtbug_86017();
+     void contextAccessedByHandler();
++    void redrawUponColumnChange();
+ };
+ 
+ class AbstractItemModel : public QAbstractItemModel
+@@ -186,6 +189,30 @@ void tst_QQmlDelegateModel::contextAccessedByHandler()
+     QVERIFY(root->property("works").toBool());
+ }
+ 
++void tst_QQmlDelegateModel::redrawUponColumnChange()
++{
++    QStandardItemModel m1;
++    m1.appendRow({
++            new QStandardItem("Banana"),
++            new QStandardItem("Coconut"),
++    });
++
++    QQuickView view(testFileUrl("redrawUponColumnChange.qml"));
++    QCOMPARE(view.status(), QQuickView::Ready);
++    view.show();
++    QQuickItem *root = view.rootObject();
++    root->setProperty("model", QVariant::fromValue<QObject *>(&m1));
++
++    QObject *item = root->property("currentItem").value<QObject *>();
++    QVERIFY(item);
++    QCOMPARE(item->property("text").toString(), "Banana");
++
++    QVERIFY(root);
++    m1.removeColumn(0);
++
++    QCOMPARE(item->property("text").toString(), "Coconut");
++}
++
+ QTEST_MAIN(tst_QQmlDelegateModel)
+ 
+ #include "tst_qqmldelegatemodel.moc"
+diff --git a/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp b/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
+index 5d635aa63b..824fd89e5b 100644
+--- a/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
++++ b/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
+@@ -76,10 +76,10 @@ void tst_qv4mm::multiWrappedQObjects()
+         QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 1);
+         QCOMPARE(engine2.memoryManager->m_pendingFreedObjectWrapperValue.size(), 0);
+ 
+-        // Moves the additional WeakValue from m_multiplyWrappedQObjects to
+-        // m_pendingFreedObjectWrapperValue. It's still alive after all.
++        // The additional WeakValue from m_multiplyWrappedQObjects hasn't been moved
++        // to m_pendingFreedObjectWrapperValue yet. It's still alive after all.
+         engine1.memoryManager->runGC();
+-        QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 2);
++        QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 1);
+ 
+         // engine2 doesn't own the object as engine1 was the first to wrap it above.
+         // Therefore, no effect here.
+diff --git a/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml b/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml
+new file mode 100644
+index 0000000000..889e480f3b
+--- /dev/null
++++ b/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml
+@@ -0,0 +1,13 @@
++import QtQuick 2.6
++
++Item {
++    visible: true
++    Item {
++        visible: false
++        Item {
++            objectName: "hiddenChild"
++            activeFocusOnTab: true
++            focus: true
++        }
++    }
++}
+diff --git a/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp b/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+index c8f251dbe1..c8ef36ee68 100644
+--- a/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
++++ b/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+@@ -67,6 +67,7 @@ private slots:
+     void activeFocusOnTab10();
+     void activeFocusOnTab_infiniteLoop_data();
+     void activeFocusOnTab_infiniteLoop();
++    void activeFocusOnTab_infiniteLoopControls();
+ 
+     void nextItemInFocusChain();
+     void nextItemInFocusChain2();
+@@ -1057,6 +1058,17 @@ void tst_QQuickItem::activeFocusOnTab_infiniteLoop()
+     QCOMPARE(item, window->rootObject());
+ }
+ 
++
++void tst_QQuickItem::activeFocusOnTab_infiniteLoopControls()
++{
++    auto source = testFileUrl("activeFocusOnTab_infiniteLoop3.qml");
++    QScopedPointer<QQuickView>window(new QQuickView());
++    window->setSource(source);
++    window->show();
++    QVERIFY(window->errors().isEmpty());
++    QTest::keyClick(window.get(), Qt::Key_Tab); // should not hang
++}
++
+ void tst_QQuickItem::nextItemInFocusChain()
+ {
+     if (!qt_tab_all_widgets())
+Submodule qtdoc c0c7bf07...79d6ef69:
+Submodule qtimageformats 2dcf2899..abe44c0f:
+diff --git a/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp b/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
+index dde783c..1bf9074 100644
+--- a/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
+@@ -462,8 +462,12 @@ static bool parseIconEntryInfo(ICNSEntry &icon)
+     if (isIconCompressed(icon))
+         return true;
+     // Icon depth:
+-    if (!depth.isEmpty())
+-        icon.depth = ICNSEntry::Depth(depth.toUInt());
++    if (!depth.isEmpty()) {
++        const uint depthUInt = depth.toUInt();
++        if (depthUInt > 32)
++            return false;
++        icon.depth = ICNSEntry::Depth(depthUInt);
++    }
+     // Try mono if depth not found
+     if (icon.depth == ICNSEntry::DepthUnknown)
+         icon.depth = ICNSEntry::DepthMono;
+@@ -515,6 +519,9 @@ static bool parseIconEntryInfo(ICNSEntry &icon)
+         }
+         icon.height = icon.width;
+     }
++    // Sanity check
++    if (icon.width == 0 || icon.width > 4096)
++        return false;
+     return true;
+ }
+ 
+@@ -685,7 +692,7 @@ bool QICNSHandler::canRead() const
+ bool QICNSHandler::read(QImage *outImage)
+ {
+     QImage img;
+-    if (!ensureScanned()) {
++    if (!ensureScanned() || m_currentIconIndex >= m_icons.size()) {
+         qWarning("QICNSHandler::read(): The device wasn't parsed properly!");
+         return false;
+     }
+@@ -892,7 +899,7 @@ bool QICNSHandler::scanDevice()
+             return false;
+ 
+         const qint64 blockDataOffset = device()->pos();
+-        if (!isBlockHeaderValid(blockHeader)) {
++        if (!isBlockHeaderValid(blockHeader, ICNSBlockHeaderSize + filelength - blockDataOffset)) {
+             qWarning("QICNSHandler::scanDevice(): Failed, bad header at pos %s. OSType \"%s\", length %u",
+                      QByteArray::number(blockDataOffset).constData(),
+                      nameFromOSType(blockHeader.ostype).constData(), blockHeader.length);
+@@ -927,11 +934,14 @@ bool QICNSHandler::scanDevice()
+         case ICNSBlockHeader::TypeOdrp:
+             // Icns container seems to have an embedded icon variant container
+             // Let's start a scan for entries
+-            while (device()->pos() < nextBlockOffset) {
++            while (!stream.atEnd() && device()->pos() < nextBlockOffset) {
+                 ICNSBlockHeader icon;
+                 stream >> icon;
++                if (stream.status() != QDataStream::Ok)
++                    return false;
+                 // Check for incorrect variant entry header and stop scan
+-                if (!isBlockHeaderValid(icon, blockDataLength))
++                quint64 remaining = blockDataLength - (device()->pos() - blockDataOffset);
++                if (!isBlockHeaderValid(icon, ICNSBlockHeaderSize + remaining))
+                     break;
+                 if (!addEntry(icon, device()->pos(), blockHeader.ostype))
+                     return false;
+@@ -1003,7 +1013,7 @@ bool QICNSHandler::scanDevice()
+             break;
+         }
+     }
+-    return true;
++    return (m_icons.size() > 0);
+ }
+ 
+ const ICNSEntry &QICNSHandler::getIconMask(const ICNSEntry &icon) const
+diff --git a/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp b/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
+index 5082023..cb34374 100644
+--- a/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
++++ b/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
+@@ -43,6 +43,7 @@
+ #include "qimage.h"
+ #include "qvariant.h"
+ #include "qcolor.h"
++#include "qimagereader.h"
+ 
+ #include <jasper/jasper.h>
+ #include <math.h> // for pow
+@@ -333,16 +334,46 @@ private:
+ Jpeg2000JasperReader::Jpeg2000JasperReader(QIODevice *iod, SubFormat format)
+     : jasperOk(true), ioDevice(iod), format(format), hasAlpha(false)
+ {
++#if JAS_VERSION_MAJOR < 3
+     if (jas_init()) {
+         jasperOk = false;
+         qDebug("Jasper Library initialization failed");
+     }
++#else
++    jas_conf_clear();
++#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
++    jas_conf_set_max_mem_usage(QImageReader::allocationLimit() * 1024 * 1024);
++#else
++    // 128MB seems to be enough.
++    jas_conf_set_max_mem_usage(128 * 1024 * 1024);
++#endif
++    if (jas_init_library()) {
++        jasperOk = false;
++        qDebug("Jasper library initialization failed");
++    }
++    if (jas_init_thread()) {
++        jas_cleanup_library();
++        jasperOk = false;
++        qDebug("Jasper thread initialization failed");
++    }
++#endif
+ }
+ 
+ Jpeg2000JasperReader::~Jpeg2000JasperReader()
+ {
++#if JAS_VERSION_MAJOR < 3
+     if (jasperOk)
+         jas_cleanup();
++#else
++    if (jasperOk) {
++        if (jas_cleanup_thread()) {
++            qDebug("Jasper thread cleanup failed");
++        }
++        if (jas_cleanup_library()) {
++            qDebug("Jasper library cleanup failed");
++        }
++    }
++#endif
+ }
+ 
+ /*! \internal
+@@ -857,7 +888,7 @@ bool Jpeg2000JasperReader::write(const QImage &image, int quality)
+     }
+ 
+     // Open an empty jasper stream that grows automatically
+-    jas_stream_t * memory_stream = jas_stream_memopen(0, -1);
++    jas_stream_t * memory_stream = jas_stream_memopen(0, 0);
+ 
+     // Jasper wants a non-const string.
+     char *str = qstrdup(jasperFormatString.toLatin1().constData());
+diff --git a/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp b/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
+index 1386750..ac8956c 100644
+--- a/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
+@@ -361,6 +361,8 @@ bool QTiffHandler::read(QImage *image)
+     }
+ 
+     TIFF *const tiff = d->tiff;
++    if (TIFFIsTiled(tiff) && TIFFTileSize64(tiff) > uint64_t(image->sizeInBytes())) // Corrupt image
++        return false;
+     const quint32 width = d->size.width();
+     const quint32 height = d->size.height();
+ 
+diff --git a/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp b/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
+index 82d38cb..d02eb05 100644
+--- a/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
+@@ -45,6 +45,7 @@
+ #include <qdebug.h>
+ #include <qpainter.h>
+ #include <qvariant.h>
++#include <QtEndian>
+ 
+ static const int riffHeaderSize = 12; // RIFF_HEADER_SIZE from webp/format_constants.h
+ 
+@@ -102,21 +103,23 @@ bool QWebpHandler::ensureScanned() const
+ 
+     m_scanState = ScanError;
+ 
+-    if (device()->isSequential()) {
+-        qWarning() << "Sequential devices are not supported";
++    QWebpHandler *that = const_cast<QWebpHandler *>(this);
++    const int headerBytesNeeded = sizeof(WebPBitstreamFeatures);
++    QByteArray header = device()->peek(headerBytesNeeded);
++    if (header.size() < headerBytesNeeded)
+         return false;
+-    }
+ 
+-    qint64 oldPos = device()->pos();
+-    device()->seek(0);
+-
+-    QWebpHandler *that = const_cast<QWebpHandler *>(this);
+-    QByteArray header = device()->peek(sizeof(WebPBitstreamFeatures));
++    // We do no random access during decoding, just a readAll() of the whole image file. So if
++    // if it is all available already, we can accept a sequential device. The riff header contains
++    // the file size minus 8 bytes header
++    qint64 byteSize = qFromLittleEndian<quint32>(header.constData() + 4);
++    if (device()->isSequential() && device()->bytesAvailable() < byteSize + 8) {
++        qWarning() << "QWebpHandler: Insufficient data available in sequential device";
++        return false;
++    }
+     if (WebPGetFeatures((const uint8_t*)header.constData(), header.size(), &(that->m_features)) == VP8_STATUS_OK) {
+         if (m_features.has_animation) {
+             // For animation, we have to read and scan whole file to determine loop count and images count
+-            device()->seek(oldPos);
+-
+             if (that->ensureDemuxer()) {
+                 that->m_loop = WebPDemuxGetI(m_demuxer, WEBP_FF_LOOP_COUNT);
+                 that->m_frameCount = WebPDemuxGetI(m_demuxer, WEBP_FF_FRAME_COUNT);
+@@ -126,17 +129,13 @@ bool QWebpHandler::ensureScanned() const
+                 if (that->m_features.has_alpha)
+                     that->m_composited->fill(Qt::transparent);
+ 
+-                // We do not reset device position since we have read in all data
+                 m_scanState = ScanSuccess;
+-                return true;
+             }
+         } else {
+             m_scanState = ScanSuccess;
+         }
+     }
+ 
+-    device()->seek(oldPos);
+-
+     return m_scanState == ScanSuccess;
+ }
+ 
+@@ -159,7 +158,7 @@ bool QWebpHandler::ensureDemuxer()
+ 
+ bool QWebpHandler::read(QImage *image)
+ {
+-    if (!ensureScanned() || device()->isSequential() || !ensureDemuxer())
++    if (!ensureScanned() || !ensureDemuxer())
+         return false;
+ 
+     QRect prevFrameRect;
+Submodule qtlocation 98a5c511..f991e28c:
+diff --git a/qtlocation/src/location/configure.json b/qtlocation/src/location/configure.json
+index 6d01a9a3..d1e623a1 100644
+--- a/qtlocation/src/location/configure.json
++++ b/qtlocation/src/location/configure.json
+@@ -9,7 +9,7 @@
+             "label": "Qt.labs.location experimental QML plugin",
+             "purpose": "Provides experimental QtLocation QML types",
+             "section": "Location",
+-            "condition": "config.opengl",
++            "condition": "features.opengl",
+             "output": [ "privateFeature" ]
+         },
+         "geoservices_osm": {
+diff --git a/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp b/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
+index a978573d..11e1466f 100644
+--- a/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
++++ b/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
+@@ -158,7 +158,7 @@ void QGeoMapObjectQSGSupport::updateMapObjects(QSGNode *root, QQuickWindow *wind
+     if (!root)
+         return;
+ 
+-    if (m_mapObjectsRootNode && m_mapObjectsRootNode->parent())
++    if (m_mapObjectsRootNode && !m_mapObjectsRootNode->parent())
+         root->appendChildNode(m_mapObjectsRootNode.get());
+ 
+     if (!m_mapObjectsRootNode) {
+diff --git a/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
+index 5a40467e..d123c6a8 100644
+--- a/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
+@@ -59,8 +59,10 @@ QT_BEGIN_NAMESPACE
+ static const QString kPrefixEsri(QStringLiteral("esri."));
+ static const QString kParamUserAgent(kPrefixEsri + QStringLiteral("useragent"));
+ 
+-static const QString kUrlGeocode(QStringLiteral("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates"));
+-static const QString kUrlReverseGeocode(QStringLiteral("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode"));
++static const QString kUrlGeocode(QStringLiteral("https://geocode.arcgis.com/arcgis/rest/services/"
++                                                "World/GeocodeServer/findAddressCandidates"));
++static const QString kUrlReverseGeocode(QStringLiteral(
++        "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode"));
+ 
+ static QString addressToQuery(const QGeoAddress &address)
+ {
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
+index 17492d94..96c12b1b 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
+@@ -46,7 +46,8 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-// JSON reference: http://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
++// JSON reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
+ 
+ static const QString kErrorMessage(QStringLiteral("Error %1: %2."));
+ static const QString kErrorJson(QStringLiteral("Error: invalide JSON document."));
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
+index 8cadfb29..92b6bb13 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
+@@ -44,7 +44,8 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-// JSON reference: http://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
++// JSON reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
+ 
+ GeoRouteReplyEsri::GeoRouteReplyEsri(QNetworkReply *reply, const QGeoRouteRequest &request,
+                                      QObject *parent) :
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
+index 0e6bc2c7..ed613f4b 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
+@@ -48,7 +48,8 @@ static const QString kPrefixEsri(QStringLiteral("esri."));
+ static const QString kParamUserAgent(kPrefixEsri + QStringLiteral("useragent"));
+ static const QString kParamToken(kPrefixEsri + QStringLiteral("token"));
+ 
+-static const QString kUrlRouting(QStringLiteral("http://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve"));
++static const QString kUrlRouting(QStringLiteral(
++        "https://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve"));
+ 
+ GeoRoutingManagerEngineEsri::GeoRoutingManagerEngineEsri(const QVariantMap &parameters,
+                                                          QGeoServiceProvider::Error *error,
+@@ -70,7 +71,8 @@ GeoRoutingManagerEngineEsri::~GeoRoutingManagerEngineEsri()
+ {
+ }
+ 
+-// REST reference: http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
++// REST reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
+ 
+ QGeoRouteReply *GeoRoutingManagerEngineEsri::calculateRoute(const QGeoRouteRequest &request)
+ {
+@@ -125,7 +127,7 @@ void GeoRoutingManagerEngineEsri::replyError(QGeoRouteReply::Error errorCode, co
+ QString GeoRoutingManagerEngineEsri::preferedDirectionLangage()
+ {
+     // list of supported langages is defined in:
+-    // http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
++    // https://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
+     const QStringList supportedLanguages = {
+         "ar", // Generate directions in Arabic
+         "cs", // Generate directions in Czech
+diff --git a/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
+index 5d15835d..24148f95 100644
+--- a/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
+@@ -230,7 +230,8 @@ QGeoMap *GeoTiledMappingManagerEngineEsri::createMap()
+ // ${y} = Y
+ // ${token} = Token
+ 
+-// template = 'http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{{z}}/{{y}}/{{x}}.png'
++// template =
++// 'https://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{{z}}/{{y}}/{{x}}.png'
+ 
+ bool GeoTiledMappingManagerEngineEsri::initializeMapSources(QGeoServiceProvider::Error *error,
+                                                             QString *errorString,
+diff --git a/qtlocation/src/plugins/geoservices/esri/maps.json b/qtlocation/src/plugins/geoservices/esri/maps.json
+index 8167ae7d..862e087d 100644
+--- a/qtlocation/src/plugins/geoservices/esri/maps.json
++++ b/qtlocation/src/plugins/geoservices/esri/maps.json
+@@ -6,8 +6,8 @@
+             "description": "ArcGIS Online World Street Map",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=3b93337983e9436f8db950e38a8629af'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=3b93337983e9436f8db950e38a8629af'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -16,8 +16,8 @@
+             "": "ArcGIS Online World Imagery",
+             "mobile": true,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -26,8 +26,8 @@
+             "description": "ArcGIS Online World Terrain Base",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=c61ad8ab017d49e1a82f580ee1298931'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=c61ad8ab017d49e1a82f580ee1298931'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -36,8 +36,8 @@
+             "description": "ArcGIS Online World Topography",
+             "mobile": true,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=30e5fe3149c34df1ba922e6f5bbf808f'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=30e5fe3149c34df1ba922e6f5bbf808f'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -46,8 +46,8 @@
+             "description": "This map presents land cover and detailed topographic maps for the United States.",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=99cd5fbd98934028802b4f797c4b1732'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=99cd5fbd98934028802b4f797c4b1732'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -56,8 +56,8 @@
+             "description": "National Geographic World Map",
+             "mobile": false,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=b9b1b422198944fbbd5250b3241691b6'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=b9b1b422198944fbbd5250b3241691b6'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -66,8 +66,8 @@
+             "description": "Thematic content providing a neutral background with minimal colors",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=ed712cb1db3e4bae9e85329040fb9a49'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=ed712cb1db3e4bae9e85329040fb9a49'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -76,8 +76,8 @@
+             "description": "Natural Earth physical map for the world",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=c4ec722a1cd34cf0a23904aadf8923a0'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=c4ec722a1cd34cf0a23904aadf8923a0'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -86,8 +86,8 @@
+             "description": "Portrays surface elevation as shaded relief",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=9c5370d0b54f4de1b48a3792d7377ff2'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=9c5370d0b54f4de1b48a3792d7377ff2'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -96,8 +96,8 @@
+             "description": "This map is designed to be used as a basemap by marine GIS professionals and as a reference map by anyone interested in ocean data",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=1e126e7520f9466c9ca28b8f28b5e500'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=1e126e7520f9466c9ca28b8f28b5e500'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -106,8 +106,8 @@
+             "description": "Thematic content providing a neutral background with minimal colors",
+             "mobile": false,
+             "night": true,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=a284a9b99b3446a3910d4144a50990f6'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=a284a9b99b3446a3910d4144a50990f6'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -116,8 +116,8 @@
+             "description": "DeLorme’s topographic basemap is a seamless global data set that portrays transportation, hydrography, jurisdiction boundaries, and major geographic features",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/Specialty/DeLorme_World_Base_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=b165c3df453e4be6b5ac4fdb241effbe'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/Specialty/DeLorme_World_Base_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=b165c3df453e4be6b5ac4fdb241effbe'>Esri</a> contributors"
+         }
+     ]
+ }
+diff --git a/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
+index 3858ddf5..af66f28e 100644
+--- a/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
+@@ -63,8 +63,10 @@ static const QString kCountriesKey(QStringLiteral("detailedCountries"));
+ static const QString kLocalizedNamesKey(QStringLiteral("localizedNames"));
+ static const QString kMaxLocationsKey(QStringLiteral("maxLocations"));
+ 
+-static const QUrl kUrlGeocodeServer("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer?f=pjson");
+-static const QUrl kUrlFindAddressCandidates("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates");
++static const QUrl kUrlGeocodeServer(
++        "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer?f=pjson");
++static const QUrl kUrlFindAddressCandidates("https://geocode.arcgis.com/arcgis/rest/services/World/"
++                                            "GeocodeServer/findAddressCandidates");
+ 
+ PlaceManagerEngineEsri::PlaceManagerEngineEsri(const QVariantMap &parameters, QGeoServiceProvider::Error *error,
+                                                QString *errorString) :
+Submodule qtmultimedia f0344079..0d7cc33a:
+diff --git a/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp b/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
+index 2b5325132..b68b4af1b 100644
+--- a/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
++++ b/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
+@@ -402,6 +402,8 @@ int QPulseAudioInput::bytesReady() const
+ 
+ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ {
++    Q_ASSERT(data != nullptr || len == 0);
++
+     m_bytesAvailable = checkBytesReady();
+ 
+     setError(QAudio::NoError);
+@@ -411,7 +413,8 @@ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ 
+     if (!m_pullMode && !m_tempBuffer.isEmpty()) {
+         readBytes = qMin(static_cast<int>(len), m_tempBuffer.size());
+-        memcpy(data, m_tempBuffer.constData(), readBytes);
++        if (readBytes)
++            memcpy(data, m_tempBuffer.constData(), readBytes);
+         m_totalTimeValue += readBytes;
+ 
+         if (readBytes < m_tempBuffer.size()) {
+@@ -502,9 +505,10 @@ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ 
+ void QPulseAudioInput::applyVolume(const void *src, void *dest, int len)
+ {
++    Q_ASSERT((src && dest) || len == 0);
+     if (m_volume < 1.f)
+         QAudioHelperInternal::qMultiplySamples(m_volume, m_format, src, dest, len);
+-    else
++    else if (len)
+         memcpy(dest, src, len);
+ }
+ 
+Submodule qtpim 02efef5e...f9a8f0fc (commits not present)
+Submodule qtquick3d b85cf622..47defc8b:
+diff --git a/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro b/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
+index ca5c499e..174a075b 100644
+--- a/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
++++ b/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
+@@ -10,7 +10,7 @@ QT_FOR_CONFIG += assetimporters-private
+ include($$OUT_PWD/../qtassetimporters-config.pri)
+ 
+ qtConfig(system-assimp):!if(cross_compile:host_build) {
+-    QMAKE_USE_PRIVATE += assimp
++    QMAKE_USE_PRIVATE += quick3d-assimp
+ } else {
+     include(../../../3rdparty/assimp/assimp.pri)
+ }
+Submodule qtquickcontrols2 3a657dc0..56ce8233:
+diff --git a/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp b/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
+index e5fe734f7..e36922775 100644
+--- a/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
++++ b/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
+@@ -38,6 +38,7 @@
+ #include "qwidgetplatformmenuitem_p.h"
+ 
+ #include <QtGui/qwindow.h>
++#include <QtGui/private/qhighdpiscaling_p.h>
+ #include <QtWidgets/qmenu.h>
+ #include <QtWidgets/qaction.h>
+ 
+@@ -145,7 +146,7 @@ void QWidgetPlatformMenu::showPopup(const QWindow *window, const QRect &targetRe
+ 
+     QPoint targetPos = targetRect.bottomLeft();
+     if (window)
+-        targetPos = window->mapToGlobal(targetPos);
++        targetPos = window->mapToGlobal(QHighDpi::fromNativeLocalPosition(targetPos, window));
+ 
+     const QWidgetPlatformMenuItem *widgetItem = qobject_cast<const QWidgetPlatformMenuItem *>(item);
+     m_menu->popup(targetPos, widgetItem ? widgetItem->action() : nullptr);
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
+index 950e4e099..b81fbea0b 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
+@@ -387,6 +387,17 @@ void QQuickAbstractButtonPrivate::itemImplicitHeightChanged(QQuickItem *item)
+         emit q->implicitIndicatorHeightChanged();
+ }
+ 
++void QQuickAbstractButtonPrivate::itemDestroyed(QQuickItem *item)
++{
++    Q_Q(QQuickAbstractButton);
++    QQuickControlPrivate::itemDestroyed(item);
++    if (item == indicator) {
++        indicator = nullptr;
++        emit q->implicitIndicatorWidthChanged();
++        emit q->implicitIndicatorHeightChanged();
++    }
++}
++
+ QQuickAbstractButton *QQuickAbstractButtonPrivate::findCheckedButton() const
+ {
+     Q_Q(const QQuickAbstractButton);
+@@ -1176,6 +1187,12 @@ QAccessible::Role QQuickAbstractButton::accessibleRole() const
+     }
+     return QAccessible::Button;
+ }
++
++void QQuickAbstractButton::accessiblePressAction()
++{
++    Q_D(QQuickAbstractButton);
++    d->trigger();
++}
+ #endif
+ 
+ QT_END_NAMESPACE
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
+index 0fa48980e..ab66220d0 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
+@@ -209,6 +209,7 @@ protected:
+ #if QT_CONFIG(accessibility)
+     void accessibilityActiveChanged(bool active) override;
+     QAccessible::Role accessibleRole() const override;
++    Q_INVOKABLE void accessiblePressAction();
+ #endif
+ 
+ private:
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
+index 9291c1a87..b729720f2 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
+@@ -109,6 +109,7 @@ public:
+ 
+     void itemImplicitWidthChanged(QQuickItem *item) override;
+     void itemImplicitHeightChanged(QQuickItem *item) override;
++    void itemDestroyed(QQuickItem *item) override;
+ 
+     // copied from qabstractbutton.cpp
+     static const int AUTO_REPEAT_DELAY = 300;
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp b/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
+index 2041e7741..8610cdfae 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
+@@ -145,7 +145,7 @@ int QQuickActionPrivate::ShortcutEntry::shortcutId() const
+ 
+ void QQuickActionPrivate::ShortcutEntry::grab(const QKeySequence &shortcut, bool enabled)
+ {
+-    if (shortcut.isEmpty())
++    if (shortcut.isEmpty() || m_shortcutId)
+         return;
+ 
+     Qt::ShortcutContext context = Qt::WindowShortcut; // TODO
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp b/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
+index f38c2b09c..6eed2a024 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
+@@ -225,6 +225,7 @@ void QQuickContainerPrivate::cleanup()
+     QObject::disconnect(contentModel, &QQmlObjectModel::countChanged, q, &QQuickContainer::countChanged);
+     QObject::disconnect(contentModel, &QQmlObjectModel::childrenChanged, q, &QQuickContainer::contentChildrenChanged);
+     delete contentModel;
++    contentModel = nullptr;
+ }
+ 
+ QQuickItem *QQuickContainerPrivate::itemAt(int index) const
+@@ -436,7 +437,7 @@ void QQuickContainerPrivate::contentChildren_clear(QQmlListProperty<QQuickItem>
+ void QQuickContainerPrivate::updateContentWidth()
+ {
+     Q_Q(QQuickContainer);
+-    if (hasContentWidth || qFuzzyCompare(contentWidth, implicitContentWidth))
++    if (hasContentWidth || qFuzzyCompare(contentWidth, implicitContentWidth) || !contentModel)
+         return;
+ 
+     contentWidth = implicitContentWidth;
+@@ -446,7 +447,7 @@ void QQuickContainerPrivate::updateContentWidth()
+ void QQuickContainerPrivate::updateContentHeight()
+ {
+     Q_Q(QQuickContainer);
+-    if (hasContentHeight || qFuzzyCompare(contentHeight, implicitContentHeight))
++    if (hasContentHeight || qFuzzyCompare(contentHeight, implicitContentHeight) || !contentModel)
+         return;
+ 
+     contentHeight = implicitContentHeight;
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp b/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
+index bbbd0e622..1f4b47343 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
+@@ -845,6 +845,13 @@ void QQuickControlPrivate::executeBackground(bool complete)
+         quickCompleteDeferred(q, backgroundName(), background);
+ }
+ 
++/*
++    \internal
++
++    Hides an item that was replaced by a newer one, rather than
++    deleting it, as the item is typically created in QML and hence
++    we don't own it.
++*/
+ void QQuickControlPrivate::hideOldItem(QQuickItem *item)
+ {
+     if (!item)
+@@ -863,6 +870,29 @@ void QQuickControlPrivate::hideOldItem(QQuickItem *item)
+ #endif
+ }
+ 
++/*
++    \internal
++
++    Named "unhide" because it's used for cases where an item
++    that was previously hidden by \l hideOldItem() wants to be
++    shown by a control again, such as a ScrollBar in ScrollView.
++*/
++void QQuickControlPrivate::unhideOldItem(QQuickControl *control, QQuickItem *item)
++{
++    Q_ASSERT(item);
++    qCDebug(lcItemManagement) << "unhiding old item" << item;
++
++    item->setVisible(true);
++    item->setParentItem(control);
++
++#if QT_CONFIG(accessibility)
++    // Add the item back in to the accessibility tree.
++    QQuickAccessibleAttached *accessible = accessibleAttached(item);
++    if (accessible)
++        accessible->setIgnored(false);
++#endif
++}
++
+ void QQuickControlPrivate::updateBaselineOffset()
+ {
+     Q_Q(QQuickControl);
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h b/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
+index 8e979079e..a6e624c91 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
+@@ -173,6 +173,7 @@ public:
+     virtual void executeBackground(bool complete = false);
+ 
+     static void hideOldItem(QQuickItem *item);
++    static void unhideOldItem(QQuickControl *control, QQuickItem *item);
+ 
+     void updateBaselineOffset();
+ 
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp b/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
+index e6db14eb5..6197d1547 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
+@@ -237,7 +237,7 @@ static QRectF alignedRect(Qt::LayoutDirection direction, Qt::Alignment alignment
+ void QQuickDialogButtonBoxPrivate::resizeContent()
+ {
+     Q_Q(QQuickDialogButtonBox);
+-    if (!contentItem)
++    if (!contentItem || !contentModel)
+         return;
+ 
+     QRectF geometry = q->boundingRect().adjusted(q->leftPadding(), q->topPadding(), -q->rightPadding(), -q->bottomPadding());
+@@ -322,6 +322,9 @@ void QQuickDialogButtonBoxPrivate::updateLayout()
+ qreal QQuickDialogButtonBoxPrivate::getContentWidth() const
+ {
+     Q_Q(const QQuickDialogButtonBox);
++    if (!contentModel)
++        return 0;
++
+     const int count = contentModel->count();
+     const qreal totalSpacing = qMax(0, count - 1) * spacing;
+     qreal totalWidth = totalSpacing;
+@@ -341,6 +344,9 @@ qreal QQuickDialogButtonBoxPrivate::getContentWidth() const
+ qreal QQuickDialogButtonBoxPrivate::getContentHeight() const
+ {
+     Q_Q(const QQuickDialogButtonBox);
++    if (!contentModel)
++        return 0;
++
+     const int count = contentModel->count();
+     qreal maxHeight = 0;
+     for (int i = 0; i < count; ++i) {
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp b/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
+index 91bd59184..0ce518f84 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
+@@ -399,8 +399,11 @@ void QQuickOverlay::itemChange(ItemChange change, const ItemChangeData &data)
+     Q_D(QQuickOverlay);
+     QQuickItem::itemChange(change, data);
+ 
+-    if (change == ItemChildAddedChange || change == ItemChildRemovedChange)
++    if (change == ItemChildAddedChange || change == ItemChildRemovedChange) {
+         setVisible(!d->allDrawers.isEmpty() || !childItems().isEmpty());
++        if (data.item->parent() == d->mouseGrabberPopup)
++            d->setMouseGrabberPopup(nullptr);
++    }
+ }
+ 
+ void QQuickOverlay::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp b/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
+index 4e2f509db..1c4b308cd 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
+@@ -797,6 +797,14 @@ void QQuickScrollBarAttachedPrivate::initHorizontal()
+     if (parent && parent == flickable->parentItem())
+         horizontal->stackAfter(flickable);
+ 
++    // If a scroll bar was previously hidden (due to e.g. setting a new contentItem
++    // on a ScrollView), we need to make sure that we un-hide it.
++    // We don't bother checking if the item is actually the old one, because
++    // if it's not, all of the things the function does (setting parent, visibility, etc.)
++    // should be no-ops anyway.
++    if (auto control = qobject_cast<QQuickControl*>(q_ptr->parent()))
++        QQuickControlPrivate::unhideOldItem(control, horizontal);
++
+     layoutHorizontal();
+     horizontal->setSize(area->property("widthRatio").toReal());
+     horizontal->setPosition(area->property("xPosition").toReal());
+@@ -818,6 +826,9 @@ void QQuickScrollBarAttachedPrivate::initVertical()
+     if (parent && parent == flickable->parentItem())
+         vertical->stackAfter(flickable);
+ 
++    if (auto control = qobject_cast<QQuickControl*>(q_ptr->parent()))
++        QQuickControlPrivate::unhideOldItem(control, vertical);
++
+     layoutVertical();
+     vertical->setSize(area->property("heightRatio").toReal());
+     vertical->setPosition(area->property("yPosition").toReal());
+diff --git a/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml b/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
+index 0e8b08352..cd4931184 100644
+--- a/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
++++ b/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
+@@ -576,4 +576,51 @@ TestCase {
+         verify(newHorizontalScrollBar.visible)
+         verify(!oldHorizontalScrollBar.visible)
+     }
++
++    Component {
++        id: bindingToContentItemAndStandaloneFlickable
++
++        Item {
++            width: 200
++            height: 200
++
++            property alias scrollView: scrollView
++
++            ScrollView {
++                id: scrollView
++                anchors.fill: parent
++                contentItem: listView
++
++                property Item someBinding: contentItem
++            }
++            ListView {
++                id: listView
++                model: 10
++                delegate: ItemDelegate {
++                    text: modelData
++                    width: listView.width
++                }
++            }
++        }
++    }
++
++    // Tests that scroll bars show up for a ScrollView where
++    // - its contentItem is declared as a standalone, separate item
++    // - there is a binding to contentItem (which causes a default Flickable to be created)
++    function test_bindingToContentItemAndStandaloneFlickable() {
++        let root = createTemporaryObject(bindingToContentItemAndStandaloneFlickable, testCase)
++        verify(root)
++
++        let control = root.scrollView
++        let verticalScrollBar = control.ScrollBar.vertical
++        let horizontalScrollBar = control.ScrollBar.horizontal
++        compare(verticalScrollBar.parent, control)
++        compare(horizontalScrollBar.parent, control)
++        verify(verticalScrollBar.visible)
++        verify(horizontalScrollBar.visible)
++
++        mouseDrag(verticalScrollBar, verticalScrollBar.width / 2, verticalScrollBar.height / 2, 0, 50)
++        verify(verticalScrollBar.active)
++        verify(horizontalScrollBar.active)
++    }
+ }
+diff --git a/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml b/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
+index b3fab41ca..10b6baa02 100644
+--- a/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
++++ b/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
+@@ -608,4 +608,27 @@ TestCase {
+         mouseClick(control.indicator)
+         verify(control.activeFocus)
+     }
++
++    Component {
++        id: deletionOrder1
++        Item {
++            Image { id: innerImage }
++            Switch { indicator: innerImage }
++        }
++    }
++
++    Component {
++        id: deletionOrder2
++        Item {
++            Switch { indicator: innerImage }
++            Image { id: innerImage }
++        }
++    }
++
++    function test_deletionOrder() {
++        var control1 = createTemporaryObject(deletionOrder1, testCase)
++        verify(control1)
++        var control2 = createTemporaryObject(deletionOrder2, testCase)
++        verify(control2)
++    }
+ }
+diff --git a/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml b/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml
+new file mode 100644
+index 000000000..9e4598b9f
+--- /dev/null
++++ b/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml
+@@ -0,0 +1,78 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the test suite of the Qt Toolkit.
++**
++** $QT_BEGIN_LICENSE:BSD$
++** Commercial License Usage
++** Licensees holding valid commercial Qt licenses may use this file in
++** accordance with the commercial license agreement provided with the
++** Software or, alternatively, in accordance with the terms contained in
++** a written agreement between you and The Qt Company. For licensing terms
++** and conditions see https://www.qt.io/terms-conditions. For further
++** information use the contact form at https://www.qt.io/contact-us.
++**
++** BSD License Usage
++** Alternatively, you may use this file under the terms of the BSD license
++** as follows:
++**
++** "Redistribution and use in source and binary forms, with or without
++** modification, are permitted provided that the following conditions are
++** met:
++**   * Redistributions of source code must retain the above copyright
++**     notice, this list of conditions and the following disclaimer.
++**   * Redistributions in binary form must reproduce the above copyright
++**     notice, this list of conditions and the following disclaimer in
++**     the documentation and/or other materials provided with the
++**     distribution.
++**   * Neither the name of The Qt Company Ltd nor the names of its
++**     contributors may be used to endorse or promote products derived
++**     from this software without specific prior written permission.
++**
++**
++** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
++** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
++** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
++** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
++** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
++** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
++** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
++** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
++** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
++** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
++** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
++**
++** $QT_END_LICENSE$
++**
++****************************************************************************/
++
++import QtQuick 2.15
++import QtQuick.Controls 2.15
++
++ApplicationWindow {
++    id: window
++    width: 400
++    height: 400
++    title: "releaseAfterExitTransition"
++
++    property alias popup: popup
++    property alias modalPopup: modalPopup
++
++    Popup {
++        id: popup
++        y: parent.height - height
++        width: 50
++        height: 50
++    }
++
++    Popup {
++        id: modalPopup
++        modal: true
++        y: parent.height - height
++        width: 50
++        height: 50
++        exit:  Transition { PauseAnimation { duration: 100 } }
++    }
++}
+diff --git a/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp b/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
+index 54952d128..3d50e2dd4 100644
+--- a/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
++++ b/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
+@@ -100,6 +100,7 @@ private slots:
+     void invisibleToolTipOpen();
+     void centerInOverlayWithinStackViewItem();
+     void destroyDuringExitTransition();
++    void releaseAfterExitTransition();
+ };
+ 
+ void tst_QQuickPopup::initTestCase()
+@@ -1575,6 +1576,34 @@ void tst_QQuickPopup::destroyDuringExitTransition()
+     QVERIFY(!button->isDown());
+ }
+ 
++void tst_QQuickPopup::releaseAfterExitTransition()
++{
++    QQuickApplicationHelper helper(this, "releaseAfterExitTransition.qml");
++    QVERIFY2(helper.ready, helper.failureMessage());
++
++    QQuickWindow *window = helper.window;
++    window->show();
++    QVERIFY(QTest::qWaitForWindowActive(window));
++
++    QQuickOverlay *overlay = QQuickOverlay::overlay(window);
++    QQuickPopup *modalPopup = window->property("modalPopup").value<QQuickPopup *>();
++    QQuickPopup *popup = window->property("popup").value<QQuickPopup *>();
++
++    modalPopup->open();
++    QTRY_VERIFY(modalPopup->isOpened());
++
++    QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++    // wait until the transition is finished and the overlay hides itself
++    QTRY_VERIFY(!overlay->isVisible());
++    QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++
++    popup->open();
++    QTRY_VERIFY(popup->isOpened());
++    QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++    QTRY_VERIFY(!popup->isOpened());
++}
++
++
+ QTEST_QUICKCONTROLS_MAIN(tst_QQuickPopup)
+ 
+ #include "tst_qquickpopup.moc"
+Submodule qtscript 5be95f96...4d8e4bd2 (commits not present)
+Submodule qtspeech 17fc9fde..255845e2:
+diff --git a/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp b/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
+index 6eb74b8..bcc7dd1 100644
+--- a/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
++++ b/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
+@@ -357,7 +357,9 @@ QVector<QLocale> QTextToSpeechEngineSpeechd::availableLocales() const
+ 
+ QVector<QVoice> QTextToSpeechEngineSpeechd::availableVoices() const
+ {
+-    return m_voices.values(m_currentLocale.name()).toVector();
++    QList<QVoice> resultList = m_voices.values(m_currentLocale.name());
++    std::reverse(resultList.begin(), resultList.end());
++    return resultList.toVector();
+ }
+ 
+ // We have no way of knowing our own client_id since speech-dispatcher seems to be incomplete
+Submodule qtsvg 0c05780e..a7a0f249:
+diff --git a/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp b/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
+index 561e77e..12e0574 100644
+--- a/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
++++ b/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
+@@ -191,6 +191,8 @@ bool QSvgIOHandler::read(QImage *image)
+             }
+         }
+         if (!finalSize.isEmpty()) {
++            if (qMax(finalSize.width(), finalSize.height()) > 0xffff)
++                return false; // Assume corrupted file
+             image->fill(d->backColor.rgba());
+             QPainter p(image);
+             d->r.render(&p, bounds);
+diff --git a/qtsvg/src/svg/qsvghandler.cpp b/qtsvg/src/svg/qsvghandler.cpp
+index a5f877f..8dda563 100644
+--- a/qtsvg/src/svg/qsvghandler.cpp
++++ b/qtsvg/src/svg/qsvghandler.cpp
+@@ -1393,9 +1393,10 @@ static void parseFont(QSvgNode *node,
+         case FontSizeNone:
+             break;
+         case FontSizeValue: {
+-            QSvgHandler::LengthType dummy; // should always be pixel size
+-            fontStyle->setSize(qMin(parseLength(attributes.fontSize, dummy, handler),
+-                                    qreal(0xffff)));
++            QSvgHandler::LengthType type;
++            qreal fs = parseLength(attributes.fontSize, type, handler);
++            fs = convertToPixels(fs, true, type);
++            fontStyle->setSize(qMin(fs, qreal(0xffff)));
+         }
+             break;
+         default:
+@@ -2513,6 +2514,8 @@ static bool parseAnimateTransformNode(QSvgNode *parent,
+             ++s;
+         }
+     }
++    if (vals.count() % 3 != 0)
++        return false;
+ 
+     bool ok = true;
+     int begin = parseClockValue(beginStr, &ok);
+@@ -2576,6 +2579,8 @@ static QSvgNode *createCircleNode(QSvgNode *parent,
+     qreal ncx = toDouble(cx);
+     qreal ncy = toDouble(cy);
+     qreal nr  = toDouble(r);
++    if (nr < 0.0)
++        return nullptr;
+ 
+     QRectF rect(ncx-nr, ncy-nr, nr*2, nr*2);
+     QSvgNode *circle = new QSvgCircle(parent, rect);
+@@ -3046,15 +3051,16 @@ static QSvgStyleProperty *createRadialGradientNode(QSvgNode *node,
+ 
+     qreal ncx = 0.5;
+     qreal ncy = 0.5;
+-    qreal nr  = 0.5;
+     if (!cx.isEmpty())
+         ncx = toDouble(cx);
+     if (!cy.isEmpty())
+         ncy = toDouble(cy);
++
++    qreal nr = 0.0;
+     if (!r.isEmpty())
+         nr = toDouble(r);
+-    if (nr < 0.5)
+-        nr = 0.5;
++    if (nr <= 0.0)
++        return nullptr;
+ 
+     qreal nfx = ncx;
+     if (!fx.isEmpty())
+@@ -3350,7 +3356,9 @@ static QSvgNode *createTextNode(QSvgNode *parent,
+     //### editable and rotate not handled
+     QSvgHandler::LengthType type;
+     qreal nx = parseLength(x, type, handler);
++    nx = convertToPixels(nx, true, type);
+     qreal ny = parseLength(y, type, handler);
++    ny = convertToPixels(ny, true, type);
+ 
+     QSvgNode *text = new QSvgText(parent, QPointF(nx, ny));
+     return text;
+@@ -3691,9 +3699,7 @@ void QSvgHandler::parse()
+         case QXmlStreamReader::EndElement:
+             endElement(xml->name());
+             ++remainingUnfinishedElements;
+-            // if we are using somebody else's qxmlstreamreader
+-            // we should not read until the end of the stream
+-            done = !m_ownsReader && (xml->name() == QLatin1String("svg"));
++            done = (xml->name() == QLatin1String("svg"));
+             break;
+         case QXmlStreamReader::Characters:
+             characters(xml->text());
+diff --git a/qtsvg/src/svg/qsvgstructure.cpp b/qtsvg/src/svg/qsvgstructure.cpp
+index b89608b..89c9e4e 100644
+--- a/qtsvg/src/svg/qsvgstructure.cpp
++++ b/qtsvg/src/svg/qsvgstructure.cpp
+@@ -255,9 +255,13 @@ inline static bool isSupportedSvgFeature(const QString &str)
+     };
+ 
+     if (str.length() <= MAX_WORD_LENGTH && str.length() >= MIN_WORD_LENGTH) {
++        const char16_t unicode44 = str.at(44).unicode();
++        const char16_t unicode45 = str.at(45).unicode();
++        if (unicode44 >= sizeof(asso_values) || unicode45 >= sizeof(asso_values))
++            return false;
+         const int key = str.length()
+-                        + asso_values[str.at(45).unicode()]
+-                        + asso_values[str.at(44).unicode()];
++                        + asso_values[unicode45]
++                        + asso_values[unicode44];
+         if (key <= MAX_HASH_VALUE && key >= 0)
+             return str == QLatin1String(wordlist[key]);
+     }
+diff --git a/qtsvg/src/svg/qsvgtinydocument.cpp b/qtsvg/src/svg/qsvgtinydocument.cpp
+index 63d0797..19e7154 100644
+--- a/qtsvg/src/svg/qsvgtinydocument.cpp
++++ b/qtsvg/src/svg/qsvgtinydocument.cpp
+@@ -433,8 +433,16 @@ void QSvgTinyDocument::draw(QPainter *p, QSvgExtraStates &)
+     draw(p);
+ }
+ 
++static bool isValidMatrix(const QTransform &transform)
++{
++    qreal determinant = transform.determinant();
++    return qIsFinite(determinant);
++}
++
+ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect, const QRectF &sourceRect)
+ {
++    QTransform oldTransform = p->worldTransform();
++
+     QRectF target = targetRect;
+     if (target.isEmpty()) {
+         QPaintDevice *dev = p->device();
+@@ -487,6 +495,9 @@ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect,
+         }
+ #endif
+     }
++
++    if (!isValidMatrix(p->worldTransform()))
++        p->setWorldTransform(oldTransform);
+ }
+ 
+ QRectF QSvgTinyDocument::boundsOnElement(const QString &id) const
+diff --git a/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp b/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
+index 36c76ec..db71e02 100644
+--- a/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
++++ b/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
+@@ -86,6 +86,8 @@ private slots:
+     void oss_fuzz_23731();
+     void oss_fuzz_24131();
+     void oss_fuzz_24738();
++    void illegalAnimateTransform_data();
++    void illegalAnimateTransform();
+ 
+ #ifndef QT_NO_COMPRESS
+     void testGzLoading();
+@@ -1646,5 +1648,22 @@ void tst_QSvgRenderer::oss_fuzz_24738()
+     QSvgRenderer().load(QByteArray("<svg><path d=\"a 2 1e-212.....\">"));
+ }
+ 
++void tst_QSvgRenderer::illegalAnimateTransform_data()
++{
++    QTest::addColumn<QByteArray>("svg");
++
++    QTest::newRow("case1") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" values=\"8,0,5,0\">");
++    QTest::newRow("case2") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" values=\"1,2\">");
++    QTest::newRow("case3") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" from=\".. 5 2\" to=\"f\">");
++    QTest::newRow("case4") << QByteArray("<svg><animateTransform type=\"scale\" begin=\"1\" dur=\"2\" by=\"--,..\">");
++}
++
++void tst_QSvgRenderer::illegalAnimateTransform()
++{
++    QFETCH(QByteArray, svg);
++    QSvgRenderer renderer;
++    QVERIFY(!renderer.load(svg)); // also shouldn't assert
++}
++
+ QTEST_MAIN(tst_QSvgRenderer)
+ #include "tst_qsvgrenderer.moc"
+Submodule qttools 6914f7c8..090e526e:
+diff --git a/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp b/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
+index feab1e2d5..cbfb82507 100644
+--- a/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
++++ b/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
+@@ -445,7 +445,9 @@ bool HelpGeneratorPrivate::insertFiles(const QStringList &files, const QString &
+     if (filterSetId < 0)
+         return false;
+     ++filterSetId;
+-    for (int attId : qAsConst(filterAtts)) {
++    QList<int> attValues = filterAtts.values();
++    std::sort(attValues.begin(), attValues.end());
++    for (int attId : qAsConst(attValues)) {
+         m_query->prepare(QLatin1String("INSERT INTO FileAttributeSetTable "
+             "VALUES(?, ?)"));
+         m_query->bindValue(0, filterSetId);
+Submodule qtwayland dfb0129c..2904e1b3:
+diff --git a/qtwayland/src/client/configure.json b/qtwayland/src/client/configure.json
+index 2f424580..29222357 100644
+--- a/qtwayland/src/client/configure.json
++++ b/qtwayland/src/client/configure.json
+@@ -149,8 +149,7 @@
+                     "#endif"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "vulkan-server-buffer": {
+             "label": "Vulkan Buffer Sharing",
+@@ -168,7 +167,8 @@
+                     "exportAllocInfo.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR;",
+                     "return 0;"
+                 ]
+-            }
++            },
++            "use": "wayland-client"
+         },
+         "egl_1_5-wayland": {
+             "label": "EGL 1.5 with Wayland Platform",
+@@ -183,7 +183,7 @@
+                     "eglGetPlatformDisplay(EGL_PLATFORM_WAYLAND_EXT, (struct wl_display *)(nullptr), nullptr);"
+                 ]
+             },
+-            "use": "egl"
++            "use": "egl wayland-client"
+         }
+     },
+ 
+diff --git a/qtwayland/src/client/global/qwaylandclientextension.cpp b/qtwayland/src/client/global/qwaylandclientextension.cpp
+index 125b1e19..edccfe63 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension.cpp
++++ b/qtwayland/src/client/global/qwaylandclientextension.cpp
+@@ -74,7 +74,10 @@ void QWaylandClientExtensionPrivate::handleRegistryGlobal(void *data, ::wl_regis
+ void QWaylandClientExtension::addRegistryListener()
+ {
+     Q_D(QWaylandClientExtension);
+-    d->waylandIntegration->display()->addRegistryListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++    if (!d->registered) {
++        d->waylandIntegration->display()->addRegistryListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++        d->registered = true;
++    }
+ }
+ 
+ QWaylandClientExtension::QWaylandClientExtension(const int ver)
+@@ -88,6 +91,13 @@ QWaylandClientExtension::QWaylandClientExtension(const int ver)
+     QMetaObject::invokeMethod(this, "addRegistryListener", Qt::QueuedConnection);
+ }
+ 
++QWaylandClientExtension::~QWaylandClientExtension()
++{
++    Q_D(QWaylandClientExtension);
++    if (d->registered && !QCoreApplication::closingDown())
++        d->waylandIntegration->display()->removeListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++}
++
+ QtWaylandClient::QWaylandIntegration *QWaylandClientExtension::integration() const
+ {
+     Q_D(const QWaylandClientExtension);
+diff --git a/qtwayland/src/client/global/qwaylandclientextension.h b/qtwayland/src/client/global/qwaylandclientextension.h
+index 98272e57..5bd28398 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension.h
++++ b/qtwayland/src/client/global/qwaylandclientextension.h
+@@ -63,6 +63,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandClientExtension : public QObject
+     Q_PROPERTY(bool active READ isActive NOTIFY activeChanged)
+ public:
+     QWaylandClientExtension(const int version);
++    ~QWaylandClientExtension();
+ 
+     QtWaylandClient::QWaylandIntegration *integration() const;
+     int version() const;
+diff --git a/qtwayland/src/client/global/qwaylandclientextension_p.h b/qtwayland/src/client/global/qwaylandclientextension_p.h
+index 69cc46a0..9091efbe 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension_p.h
++++ b/qtwayland/src/client/global/qwaylandclientextension_p.h
+@@ -68,6 +68,7 @@ public:
+     QtWaylandClient::QWaylandIntegration *waylandIntegration = nullptr;
+     int version = -1;
+     bool active = false;
++    bool registered = false;
+ };
+ 
+ class Q_WAYLAND_CLIENT_EXPORT QWaylandClientExtensionTemplatePrivate : public QWaylandClientExtensionPrivate
+diff --git a/qtwayland/src/client/qwaylanddatadevice.cpp b/qtwayland/src/client/qwaylanddatadevice.cpp
+index 7e2e3308..e3e60ed5 100644
+--- a/qtwayland/src/client/qwaylanddatadevice.cpp
++++ b/qtwayland/src/client/qwaylanddatadevice.cpp
+@@ -72,6 +72,8 @@ QWaylandDataDevice::QWaylandDataDevice(QWaylandDataDeviceManager *manager, QWayl
+ 
+ QWaylandDataDevice::~QWaylandDataDevice()
+ {
++    if (wl_data_device_get_version(object()) >= WL_DATA_DEVICE_RELEASE_SINCE_VERSION)
++        release();
+ }
+ 
+ QWaylandDataOffer *QWaylandDataDevice::selectionOffer() const
+@@ -110,7 +112,7 @@ QWaylandDataOffer *QWaylandDataDevice::dragOffer() const
+     return m_dragOffer.data();
+ }
+ 
+-bool QWaylandDataDevice::startDrag(QMimeData *mimeData, QWaylandWindow *icon)
++bool QWaylandDataDevice::startDrag(QMimeData *mimeData, Qt::DropActions supportedActions, QWaylandWindow *icon)
+ {
+     auto *seat = m_display->currentInputDevice();
+     auto *origin = seat->pointerFocus();
+@@ -123,7 +125,28 @@ bool QWaylandDataDevice::startDrag(QMimeData *mimeData, QWaylandWindow *icon)
+     }
+ 
+     m_dragSource.reset(new QWaylandDataSource(m_display->dndSelectionHandler(), mimeData));
++
++    if (wl_data_device_get_version(object()) >= 3)
++        m_dragSource->set_actions(dropActionsToWl(supportedActions));
++
+     connect(m_dragSource.data(), &QWaylandDataSource::cancelled, this, &QWaylandDataDevice::dragSourceCancelled);
++    connect(m_dragSource.data(), &QWaylandDataSource::dndResponseUpdated, this, [this](bool accepted, Qt::DropAction action) {
++            auto drag = static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag());
++            // in old versions drop action is not set, so we guess
++            if (wl_data_source_get_version(m_dragSource->object()) < 3) {
++                drag->setResponse(accepted);
++            } else {
++                QPlatformDropQtResponse response(accepted, action);
++                drag->setResponse(response);
++            }
++    });
++    connect(m_dragSource.data(), &QWaylandDataSource::dndDropped, this, [](bool accepted, Qt::DropAction action) {
++        QPlatformDropQtResponse response(accepted, action);
++        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setDropResponse(response);
++    });
++    connect(m_dragSource.data(), &QWaylandDataSource::finished, this, []() {
++        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag();
++    });
+ 
+     start_drag(m_dragSource->object(), origin->wlSurface(), icon->wlSurface(), m_display->currentInputDevice()->serial());
+     return true;
+@@ -152,7 +175,7 @@ void QWaylandDataDevice::data_device_drop()
+         supportedActions = drag->supportedActions();
+     } else if (m_dragOffer) {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     } else {
+         return;
+     }
+@@ -162,7 +185,11 @@ void QWaylandDataDevice::data_device_drop()
+                                                                           QGuiApplication::keyboardModifiers());
+ 
+     if (drag) {
+-        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag(response);
++        auto drag =  static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag());
++        drag->setDropResponse(response);
++        drag->finishDrag();
++    } else if (m_dragOffer) {
++        m_dragOffer->finish();
+     }
+ }
+ 
+@@ -186,7 +213,7 @@ void QWaylandDataDevice::data_device_enter(uint32_t serial, wl_surface *surface,
+         supportedActions = drag->supportedActions();
+     } else if (m_dragOffer) {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     }
+ 
+     const QPlatformDragQtResponse &response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
+@@ -197,11 +224,7 @@ void QWaylandDataDevice::data_device_enter(uint32_t serial, wl_surface *surface,
+         static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setResponse(response);
+     }
+ 
+-    if (response.isAccepted()) {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, m_dragOffer->firstFormat().toUtf8().constData());
+-    } else {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, nullptr);
+-    }
++    sendResponse(supportedActions, response);
+ }
+ 
+ void QWaylandDataDevice::data_device_leave()
+@@ -235,10 +258,10 @@ void QWaylandDataDevice::data_device_motion(uint32_t time, wl_fixed_t x, wl_fixe
+         supportedActions = drag->supportedActions();
+     } else {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     }
+ 
+-    QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
++    const QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
+                                                                           QGuiApplication::mouseButtons(),
+                                                                           QGuiApplication::keyboardModifiers());
+ 
+@@ -246,11 +269,7 @@ void QWaylandDataDevice::data_device_motion(uint32_t time, wl_fixed_t x, wl_fixe
+         static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setResponse(response);
+     }
+ 
+-    if (response.isAccepted()) {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, m_dragOffer->firstFormat().toUtf8().constData());
+-    } else {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, nullptr);
+-    }
++    sendResponse(supportedActions, response);
+ }
+ #endif // QT_CONFIG(draganddrop)
+ 
+@@ -277,14 +296,10 @@ void QWaylandDataDevice::selectionSourceCancelled()
+ #if QT_CONFIG(draganddrop)
+ void QWaylandDataDevice::dragSourceCancelled()
+ {
++    static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag();
+     m_dragSource.reset();
+ }
+ 
+-void QWaylandDataDevice::dragSourceTargetChanged(const QString &mimeType)
+-{
+-    static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->updateTarget(mimeType);
+-}
+-
+ QPoint QWaylandDataDevice::calculateDragPosition(int x, int y, QWindow *wnd) const
+ {
+     QPoint pnt(wl_fixed_to_int(x), wl_fixed_to_int(y));
+@@ -297,6 +312,33 @@ QPoint QWaylandDataDevice::calculateDragPosition(int x, int y, QWindow *wnd) con
+     }
+     return pnt;
+ }
++
++void QWaylandDataDevice::sendResponse(Qt::DropActions supportedActions, const QPlatformDragQtResponse &response)
++{
++    if (response.isAccepted()) {
++        if (wl_data_device_get_version(object()) >= 3)
++            m_dragOffer->set_actions(dropActionsToWl(supportedActions), dropActionsToWl(response.acceptedAction()));
++
++        m_dragOffer->accept(m_enterSerial, m_dragOffer->firstFormat());
++    } else {
++        m_dragOffer->accept(m_enterSerial, QString());
++    }
++}
++
++int QWaylandDataDevice::dropActionsToWl(Qt::DropActions actions)
++{
++
++    int wlActions = WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE;
++    if (actions & Qt::CopyAction)
++        wlActions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY;
++    if (actions & (Qt::MoveAction | Qt::TargetMoveAction))
++        wlActions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE;
++
++    // wayland does not support LinkAction at the time of writing
++    return wlActions;
++}
++
++
+ #endif // QT_CONFIG(draganddrop)
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddatadevice_p.h b/qtwayland/src/client/qwaylanddatadevice_p.h
+index 16c3ad28..801dcc2c 100644
+--- a/qtwayland/src/client/qwaylanddatadevice_p.h
++++ b/qtwayland/src/client/qwaylanddatadevice_p.h
+@@ -64,6 +64,7 @@ QT_REQUIRE_CONFIG(wayland_datadevice);
+ QT_BEGIN_NAMESPACE
+ 
+ class QMimeData;
++class QPlatformDragQtResponse;
+ class QWindow;
+ 
+ namespace QtWaylandClient {
+@@ -89,7 +90,7 @@ public:
+ 
+ #if QT_CONFIG(draganddrop)
+     QWaylandDataOffer *dragOffer() const;
+-    bool startDrag(QMimeData *mimeData, QWaylandWindow *icon);
++    bool startDrag(QMimeData *mimeData, Qt::DropActions supportedActions, QWaylandWindow *icon);
+     void cancelDrag();
+ #endif
+ 
+@@ -109,13 +110,16 @@ private Q_SLOTS:
+ 
+ #if QT_CONFIG(draganddrop)
+     void dragSourceCancelled();
+-    void dragSourceTargetChanged(const QString &mimeType);
+ #endif
+ 
+ private:
+ #if QT_CONFIG(draganddrop)
+     QPoint calculateDragPosition(int x, int y, QWindow *wnd) const;
+ #endif
++    void sendResponse(Qt::DropActions supportedActions, const QPlatformDragQtResponse &response);
++
++    static int dropActionsToWl(Qt::DropActions dropActions);
++
+ 
+     QWaylandDisplay *m_display = nullptr;
+     QWaylandInputDevice *m_inputDevice = nullptr;
+diff --git a/qtwayland/src/client/qwaylanddatadevicemanager.cpp b/qtwayland/src/client/qwaylanddatadevicemanager.cpp
+index 35d67307..6dc4f77f 100644
+--- a/qtwayland/src/client/qwaylanddatadevicemanager.cpp
++++ b/qtwayland/src/client/qwaylanddatadevicemanager.cpp
+@@ -50,8 +50,8 @@ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
+-QWaylandDataDeviceManager::QWaylandDataDeviceManager(QWaylandDisplay *display, uint32_t id)
+-    : wl_data_device_manager(display->wl_registry(), id, 1)
++QWaylandDataDeviceManager::QWaylandDataDeviceManager(QWaylandDisplay *display, int version, uint32_t id)
++    : wl_data_device_manager(display->wl_registry(), id, qMin(version, 3))
+     , m_display(display)
+ {
+     // Create transfer devices for all input devices.
+diff --git a/qtwayland/src/client/qwaylanddatadevicemanager_p.h b/qtwayland/src/client/qwaylanddatadevicemanager_p.h
+index bd05c0fb..510d9be4 100644
+--- a/qtwayland/src/client/qwaylanddatadevicemanager_p.h
++++ b/qtwayland/src/client/qwaylanddatadevicemanager_p.h
+@@ -68,7 +68,7 @@ class QWaylandInputDevice;
+ class Q_WAYLAND_CLIENT_EXPORT QWaylandDataDeviceManager : public QtWayland::wl_data_device_manager
+ {
+ public:
+-    QWaylandDataDeviceManager(QWaylandDisplay *display, uint32_t id);
++    QWaylandDataDeviceManager(QWaylandDisplay *display, int version, uint32_t id);
+     ~QWaylandDataDeviceManager() override;
+ 
+     QWaylandDataDevice *getDataDevice(QWaylandInputDevice *inputDevice);
+diff --git a/qtwayland/src/client/qwaylanddataoffer.cpp b/qtwayland/src/client/qwaylanddataoffer.cpp
+index 2297e8a1..fe0ea8c9 100644
+--- a/qtwayland/src/client/qwaylanddataoffer.cpp
++++ b/qtwayland/src/client/qwaylanddataoffer.cpp
+@@ -82,6 +82,15 @@ QMimeData *QWaylandDataOffer::mimeData()
+     return m_mimeData.data();
+ }
+ 
++Qt::DropActions QWaylandDataOffer::supportedActions() const
++{
++    if (wl_data_offer_get_version(const_cast<::wl_data_offer*>(object())) < 3) {
++        return Qt::MoveAction | Qt::CopyAction;
++    }
++
++    return m_supportedActions;
++}
++
+ void QWaylandDataOffer::startReceiving(const QString &mimeType, int fd)
+ {
+     receive(mimeType, fd);
+@@ -93,6 +102,22 @@ void QWaylandDataOffer::data_offer_offer(const QString &mime_type)
+     m_mimeData->appendFormat(mime_type);
+ }
+ 
++void QWaylandDataOffer::data_offer_action(uint32_t dnd_action)
++{
++    Q_UNUSED(dnd_action);
++    // This is the compositor telling the drag target what action it should perform
++    // It does not map nicely into Qt final drop semantics, other than pretending there is only one supported action?
++}
++
++void QWaylandDataOffer::data_offer_source_actions(uint32_t source_actions)
++{
++    m_supportedActions = Qt::DropActions();
++    if (source_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
++        m_supportedActions |= Qt::MoveAction;
++    if (source_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
++        m_supportedActions |= Qt::CopyAction;
++}
++
+ QWaylandMimeData::QWaylandMimeData(QWaylandAbstractDataOffer *dataOffer)
+     : m_dataOffer(dataOffer)
+ {
+@@ -163,17 +188,18 @@ QVariant QWaylandMimeData::retrieveData_sys(const QString &mimeType, QVariant::T
+ 
+ int QWaylandMimeData::readData(int fd, QByteArray &data) const
+ {
+-    fd_set readset;
+-    FD_ZERO(&readset);
+-    FD_SET(fd, &readset);
+-    struct timeval timeout;
++    struct pollfd readset;
++    readset.fd = fd;
++    readset.events = POLLIN;
++    struct timespec timeout;
+     timeout.tv_sec = 1;
+-    timeout.tv_usec = 0;
++    timeout.tv_nsec = 0;
++
+ 
+     Q_FOREVER {
+-        int ready = select(FD_SETSIZE, &readset, nullptr, nullptr, &timeout);
++        int ready = qt_safe_poll(&readset, 1, &timeout);
+         if (ready < 0) {
+-            qWarning() << "QWaylandDataOffer: select() failed";
++            qWarning() << "QWaylandDataOffer: qt_safe_poll() failed";
+             return -1;
+         } else if (ready == 0) {
+             qWarning("QWaylandDataOffer: timeout reading from pipe");
+diff --git a/qtwayland/src/client/qwaylanddataoffer_p.h b/qtwayland/src/client/qwaylanddataoffer_p.h
+index 9cf1483c..6f667398 100644
+--- a/qtwayland/src/client/qwaylanddataoffer_p.h
++++ b/qtwayland/src/client/qwaylanddataoffer_p.h
+@@ -82,6 +82,7 @@ public:
+     explicit QWaylandDataOffer(QWaylandDisplay *display, struct ::wl_data_offer *offer);
+     ~QWaylandDataOffer() override;
+     QMimeData *mimeData() override;
++    Qt::DropActions supportedActions() const;
+ 
+     QString firstFormat() const;
+ 
+@@ -89,10 +90,13 @@ public:
+ 
+ protected:
+     void data_offer_offer(const QString &mime_type) override;
++    void data_offer_source_actions(uint32_t source_actions) override;
++    void data_offer_action(uint32_t dnd_action) override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+     QScopedPointer<QWaylandMimeData> m_mimeData;
++    Qt::DropActions m_supportedActions;
+ };
+ 
+ 
+diff --git a/qtwayland/src/client/qwaylanddatasource.cpp b/qtwayland/src/client/qwaylanddatasource.cpp
+index f45122fb..5599cbd4 100644
+--- a/qtwayland/src/client/qwaylanddatasource.cpp
++++ b/qtwayland/src/client/qwaylanddatasource.cpp
+@@ -101,7 +101,32 @@ void QWaylandDataSource::data_source_send(const QString &mime_type, int32_t fd)
+ 
+ void QWaylandDataSource::data_source_target(const QString &mime_type)
+ {
+-    Q_EMIT targetChanged(mime_type);
++    m_accepted = !mime_type.isEmpty();
++    Q_EMIT dndResponseUpdated(m_accepted, m_dropAction);
++}
++
++void QWaylandDataSource::data_source_action(uint32_t action)
++{
++    Qt::DropAction qtAction = Qt::IgnoreAction;
++
++    if (action == WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
++        qtAction = Qt::MoveAction;
++    else if (action == WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
++        qtAction = Qt::CopyAction;
++
++    m_dropAction = qtAction;
++    Q_EMIT dndResponseUpdated(m_accepted, m_dropAction);
++}
++
++void QWaylandDataSource::data_source_dnd_finished()
++{
++    Q_EMIT finished();
++}
++
++void QWaylandDataSource::data_source_dnd_drop_performed()
++{
++
++    Q_EMIT dndDropped(m_accepted, m_dropAction);
+ }
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddatasource_p.h b/qtwayland/src/client/qwaylanddatasource_p.h
+index 25afff79..96f07bc3 100644
+--- a/qtwayland/src/client/qwaylanddatasource_p.h
++++ b/qtwayland/src/client/qwaylanddatasource_p.h
+@@ -77,17 +77,25 @@ public:
+     QMimeData *mimeData() const;
+ 
+ Q_SIGNALS:
+-    void targetChanged(const QString &mime_type);
+     void cancelled();
++    void finished();
++
++    void dndResponseUpdated(bool accepted, Qt::DropAction action);
++    void dndDropped(bool accepted, Qt::DropAction action);
+ 
+ protected:
+     void data_source_cancelled() override;
+     void data_source_send(const QString &mime_type, int32_t fd) override;
+     void data_source_target(const QString &mime_type) override;
++    void data_source_dnd_drop_performed() override;
++    void data_source_dnd_finished() override;
++    void data_source_action(uint32_t action) override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+     QMimeData *m_mime_data = nullptr;
++    bool m_accepted = false;
++    Qt::DropAction m_dropAction = Qt::IgnoreAction;
+ };
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddisplay.cpp b/qtwayland/src/client/qwaylanddisplay.cpp
+index f10c1f79..c01e238b 100644
+--- a/qtwayland/src/client/qwaylanddisplay.cpp
++++ b/qtwayland/src/client/qwaylanddisplay.cpp
+@@ -85,10 +85,203 @@
+ 
+ #include <errno.h>
+ 
++#include <tuple> // for std::tie
++
++static void checkWaylandError(struct wl_display *display)
++{
++    int ecode = wl_display_get_error(display);
++    if ((ecode == EPIPE || ecode == ECONNRESET)) {
++        // special case this to provide a nicer error
++        qWarning("The Wayland connection broke. Did the Wayland compositor die?");
++    } else {
++        qWarning("The Wayland connection experienced a fatal error: %s", strerror(ecode));
++    }
++    _exit(1);
++}
++
+ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
++class EventThread : public QThread
++{
++    Q_OBJECT
++public:
++    enum OperatingMode {
++        EmitToDispatch, // Emit the signal, allow dispatching in a differnt thread.
++        SelfDispatch, // Dispatch the events inside this thread.
++    };
++
++    EventThread(struct wl_display * wl, struct wl_event_queue * ev_queue,
++                OperatingMode mode)
++        : m_fd(wl_display_get_fd(wl))
++        , m_pipefd{ -1, -1 }
++        , m_wldisplay(wl)
++        , m_wlevqueue(ev_queue)
++        , m_mode(mode)
++        , m_reading(true)
++        , m_quitting(false)
++    {
++        setObjectName(QStringLiteral("WaylandEventThread"));
++    }
++
++    void readAndDispatchEvents()
++    {
++        /*
++         * Dispatch pending events and flush the requests at least once. If the event thread
++         * is not reading, try to call _prepare_read() to allow the event thread to poll().
++         * If that fails, re-try dispatch & flush again until _prepare_read() is successful.
++         *
++         * This allow any call to readAndDispatchEvents() to start event thread's polling,
++         * not only the one issued from event thread's waitForReading(), which means functions
++         * called from dispatch_pending() can safely spin an event loop.
++         */
++        for (;;) {
++            if (dispatchQueuePending() < 0) {
++                checkWaylandError(m_wldisplay);
++                return;
++            }
++
++            wl_display_flush(m_wldisplay);
++
++            // We have to check if event thread is reading every time we dispatch
++            // something, as that may recursively call this function.
++            if (m_reading.loadAcquire())
++                break;
++
++            if (prepareReadQueue() == 0) {
++                QMutexLocker l(&m_mutex);
++                m_reading.storeRelease(true);
++                m_cond.wakeOne();
++                break;
++            }
++        }
++    }
++
++    void stop()
++    {
++        // We have to both write to the pipe and set the flag, as the thread may be
++        // either in the poll() or waiting for _prepare_read().
++        if (m_pipefd[1] != -1 && write(m_pipefd[1], "\0", 1) == -1)
++            qWarning("Failed to write to the pipe: %s.", strerror(errno));
++
++        {
++            QMutexLocker l(&m_mutex);
++            m_quitting = true;
++            m_cond.wakeOne();
++        }
++
++        wait();
++    }
++
++Q_SIGNALS:
++    void needReadAndDispatch();
++
++protected:
++    void run() override
++    {
++        // we use this pipe to make the loop exit otherwise if we simply used a flag on the loop condition, if stop() gets
++        // called while poll() is blocking the thread will never quit since there are no wayland messages coming anymore.
++        struct Pipe
++        {
++            Pipe(int *fds)
++                : fds(fds)
++            {
++                if (qt_safe_pipe(fds) != 0)
++                    qWarning("Pipe creation failed. Quitting may hang.");
++            }
++            ~Pipe()
++            {
++                if (fds[0] != -1) {
++                    close(fds[0]);
++                    close(fds[1]);
++                }
++            }
++
++            int *fds;
++        } pipe(m_pipefd);
++
++        // Make the main thread call wl_prepare_read(), dispatch the pending messages and flush the
++        // outbound ones. Wait until it's done before proceeding, unless we're told to quit.
++        while (waitForReading()) {
++            pollfd fds[2] = { { m_fd, POLLIN, 0 }, { m_pipefd[0], POLLIN, 0 } };
++            poll(fds, 2, -1);
++
++            if (fds[1].revents & POLLIN) {
++                // we don't really care to read the byte that was written here since we're closing down
++                wl_display_cancel_read(m_wldisplay);
++                break;
++            }
++
++            if (fds[0].revents & POLLIN)
++                wl_display_read_events(m_wldisplay);
++                // The polll was succesfull and the event thread did the wl_display_read_events(). On the next iteration of the loop
++                // the event sent to the main thread will cause it to dispatch the messages just read, unless the loop exits in which
++                // case we don't care anymore about them.
++            else
++                wl_display_cancel_read(m_wldisplay);
++        }
++    }
++
++private:
++    bool waitForReading()
++    {
++        Q_ASSERT(QThread::currentThread() == this);
++
++        m_reading.storeRelease(false);
++
++        if (m_mode == SelfDispatch) {
++            readAndDispatchEvents();
++        } else {
++            Q_EMIT needReadAndDispatch();
++
++            QMutexLocker lock(&m_mutex);
++            // m_reading might be set from our emit or some other invocation of
++            // readAndDispatchEvents().
++            while (!m_reading.loadRelaxed() && !m_quitting)
++                m_cond.wait(&m_mutex);
++        }
++
++        return !m_quitting;
++    }
++
++    int dispatchQueuePending()
++    {
++        if (m_wlevqueue)
++            return wl_display_dispatch_queue_pending(m_wldisplay, m_wlevqueue);
++        else
++            return wl_display_dispatch_pending(m_wldisplay);
++    }
++
++    int prepareReadQueue()
++    {
++        if (m_wlevqueue)
++            return wl_display_prepare_read_queue(m_wldisplay, m_wlevqueue);
++        else
++            return wl_display_prepare_read(m_wldisplay);
++    }
++
++    int m_fd;
++    int m_pipefd[2];
++    wl_display *m_wldisplay;
++    wl_event_queue *m_wlevqueue;
++    OperatingMode m_mode;
++
++    /* Concurrency note when operating in EmitToDispatch mode:
++     * m_reading is set to false inside event thread's waitForReading(), and is
++     * set to true inside main thread's readAndDispatchEvents().
++     * The lock is not taken when setting m_reading to false, as the main thread
++     * is not actively waiting for it to turn false. However, the lock is taken
++     * inside readAndDispatchEvents() before setting m_reading to true,
++     * as the event thread is actively waiting for it under the wait condition.
++     */
++
++    QAtomicInteger<bool> m_reading;
++    bool m_quitting;
++    QMutex m_mutex;
++    QWaitCondition m_cond;
++};
++
+ Q_LOGGING_CATEGORY(lcQpaWayland, "qt.qpa.wayland"); // for general (uncategorized) Wayland platform logging
+ 
+ struct wl_surface *QWaylandDisplay::createSurface(void *handle)
+@@ -158,17 +351,16 @@ QWaylandDisplay::QWaylandDisplay(QWaylandIntegration *waylandIntegration)
+     if (!mXkbContext)
+         qCWarning(lcQpaWayland, "failed to create xkb context");
+ #endif
+-
+-    forceRoundTrip();
+-
+-    if (!mWaitingScreens.isEmpty()) {
+-        // Give wl_output.done and zxdg_output_v1.done events a chance to arrive
+-        forceRoundTrip();
+-    }
+ }
+ 
+ QWaylandDisplay::~QWaylandDisplay(void)
+ {
++    if (m_eventThread)
++        m_eventThread->stop();
++
++    if (m_frameEventQueueThread)
++        m_frameEventQueueThread->stop();
++
+     if (mSyncCallback)
+         wl_callback_destroy(mSyncCallback);
+ 
+@@ -187,6 +379,21 @@ QWaylandDisplay::~QWaylandDisplay(void)
+ #endif
+     if (mDisplay)
+         wl_display_disconnect(mDisplay);
++
++    if (m_frameEventQueue)
++        wl_event_queue_destroy(m_frameEventQueue);
++}
++
++// Steps which is called just after constructor. This separates registry_global() out of the constructor
++// so that factory functions in integration can be overridden.
++void QWaylandDisplay::initialize()
++{
++    forceRoundTrip();
++
++    if (!mWaitingScreens.isEmpty()) {
++        // Give wl_output.done and zxdg_output_v1.done events a chance to arrive
++        forceRoundTrip();
++    }
+ }
+ 
+ void QWaylandDisplay::ensureScreen()
+@@ -203,98 +410,37 @@ void QWaylandDisplay::ensureScreen()
+ 
+ void QWaylandDisplay::checkError() const
+ {
+-    int ecode = wl_display_get_error(mDisplay);
+-    if ((ecode == EPIPE || ecode == ECONNRESET)) {
+-        // special case this to provide a nicer error
+-        qWarning("The Wayland connection broke. Did the Wayland compositor die?");
+-    } else {
+-        qWarning("The Wayland connection experienced a fatal error: %s", strerror(ecode));
+-    }
+-    _exit(1);
++    checkWaylandError(mDisplay);
+ }
+ 
++// Called in main thread, either from queued signal or directly.
+ void QWaylandDisplay::flushRequests()
+ {
+-    if (wl_display_prepare_read(mDisplay) == 0) {
+-        wl_display_read_events(mDisplay);
+-    }
+-
+-    if (wl_display_dispatch_pending(mDisplay) < 0)
+-        checkError();
+-
+-    {
+-        QReadLocker locker(&m_frameQueueLock);
+-        for (const FrameQueue &q : mExternalQueues) {
+-            QMutexLocker locker(q.mutex);
+-            while (wl_display_prepare_read_queue(mDisplay, q.queue) != 0)
+-                wl_display_dispatch_queue_pending(mDisplay, q.queue);
+-            wl_display_read_events(mDisplay);
+-            wl_display_dispatch_queue_pending(mDisplay, q.queue);
+-        }
+-    }
+-
+-    wl_display_flush(mDisplay);
+-}
+-
+-void QWaylandDisplay::blockingReadEvents()
+-{
+-    if (wl_display_dispatch(mDisplay) < 0)
+-        checkError();
+-}
+-
+-void QWaylandDisplay::destroyFrameQueue(const QWaylandDisplay::FrameQueue &q)
+-{
+-    QWriteLocker locker(&m_frameQueueLock);
+-    auto it = std::find_if(mExternalQueues.begin(),
+-                           mExternalQueues.end(),
+-                           [&q] (const QWaylandDisplay::FrameQueue &other){ return other.queue == q.queue; });
+-    Q_ASSERT(it != mExternalQueues.end());
+-    mExternalQueues.erase(it);
+-    if (q.queue != nullptr)
+-        wl_event_queue_destroy(q.queue);
+-    delete q.mutex;
++    m_eventThread->readAndDispatchEvents();
+ }
+ 
+-QWaylandDisplay::FrameQueue QWaylandDisplay::createFrameQueue()
++// We have to wait until we have an eventDispatcher before creating the eventThread,
++// otherwise forceRoundTrip() may block inside _events_read() because eventThread is
++// polling.
++void QWaylandDisplay::initEventThread()
+ {
+-    QWriteLocker locker(&m_frameQueueLock);
+-    FrameQueue q{createEventQueue()};
+-    mExternalQueues.append(q);
+-    return q;
+-}
++    m_eventThread.reset(
++            new EventThread(mDisplay, /* default queue */ nullptr, EventThread::EmitToDispatch));
++    connect(m_eventThread.get(), &EventThread::needReadAndDispatch, this,
++            &QWaylandDisplay::flushRequests, Qt::QueuedConnection);
++    m_eventThread->start();
+ 
+-wl_event_queue *QWaylandDisplay::createEventQueue()
+-{
+-    return wl_display_create_queue(mDisplay);
++    // wl_display_disconnect() free this.
++    m_frameEventQueue = wl_display_create_queue(mDisplay);
++    m_frameEventQueueThread.reset(
++            new EventThread(mDisplay, m_frameEventQueue, EventThread::SelfDispatch));
++    m_frameEventQueueThread->start();
+ }
+ 
+-void QWaylandDisplay::dispatchQueueWhile(wl_event_queue *queue, std::function<bool ()> condition, int timeout)
++void QWaylandDisplay::blockingReadEvents()
+ {
+-    if (!condition())
+-        return;
+-
+-    QElapsedTimer timer;
+-    timer.start();
+-    struct pollfd pFd = qt_make_pollfd(wl_display_get_fd(mDisplay), POLLIN);
+-    while (timeout == -1 || timer.elapsed() < timeout) {
+-        while (wl_display_prepare_read_queue(mDisplay, queue) != 0)
+-            wl_display_dispatch_queue_pending(mDisplay, queue);
+-
+-        wl_display_flush(mDisplay);
+-
+-        const int remaining = qMax(timeout - timer.elapsed(), 0ll);
+-        const int pollTimeout = timeout == -1 ? -1 : remaining;
+-        if (qt_poll_msecs(&pFd, 1, pollTimeout) > 0)
+-            wl_display_read_events(mDisplay);
+-        else
+-            wl_display_cancel_read(mDisplay);
+-
+-        if (wl_display_dispatch_queue_pending(mDisplay, queue) < 0)
+-            checkError();
+-
+-        if (!condition())
+-            break;
+-    }
++    if (wl_display_dispatch(mDisplay) < 0)
++        checkWaylandError(mDisplay);
+ }
+ 
+ QWaylandScreen *QWaylandDisplay::screenForOutput(struct wl_output *output) const
+@@ -345,7 +491,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+     if (interface == QStringLiteral("wl_output")) {
+         mWaitingScreens << new QWaylandScreen(this, version, id);
+     } else if (interface == QStringLiteral("wl_compositor")) {
+-        mCompositorVersion = qMin((int)version, 3);
++        mCompositorVersion = qMin((int)version, 4);
+         mCompositor.init(registry, id, mCompositorVersion);
+     } else if (interface == QStringLiteral("wl_shm")) {
+         mShm.reset(new QWaylandShm(this, version, id));
+@@ -354,7 +500,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+         mInputDevices.append(inputDevice);
+ #if QT_CONFIG(wayland_datadevice)
+     } else if (interface == QStringLiteral("wl_data_device_manager")) {
+-        mDndSelectionHandler.reset(new QWaylandDataDeviceManager(this, id));
++        mDndSelectionHandler.reset(new QWaylandDataDeviceManager(this, version, id));
+ #endif
+     } else if (interface == QStringLiteral("qt_surface_extension")) {
+         mWindowExtension.reset(new QtWayland::qt_surface_extension(registry, id, 1));
+@@ -369,6 +515,8 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+ #if QT_CONFIG(wayland_client_primary_selection)
+     } else if (interface == QStringLiteral("zwp_primary_selection_device_manager_v1")) {
+         mPrimarySelectionManager.reset(new QWaylandPrimarySelectionDeviceManagerV1(this, id, 1));
++        for (QWaylandInputDevice *inputDevice : qAsConst(mInputDevices))
++            inputDevice->setPrimarySelectionDevice(mPrimarySelectionManager->createDevice(inputDevice));
+ #endif
+     } else if (interface == QStringLiteral("zwp_text_input_manager_v2") && !mClientSideInputContextRequested) {
+         mTextInputManager.reset(new QtWayland::zwp_text_input_manager_v2(registry, id, 1));
+@@ -427,6 +575,13 @@ void QWaylandDisplay::registry_global_remove(uint32_t id)
+                     inputDevice->setTextInput(nullptr);
+                 mWaylandIntegration->reconfigureInputContext();
+             }
++#if QT_CONFIG(wayland_client_primary_selection)
++            if (global.interface == QStringLiteral("zwp_primary_selection_device_manager_v1")) {
++                mPrimarySelectionManager.reset();
++                for (QWaylandInputDevice *inputDevice : qAsConst(mInputDevices))
++                    inputDevice->setPrimarySelectionDevice(nullptr);
++            }
++#endif
+             mGlobals.removeAt(i);
+             break;
+         }
+@@ -452,9 +607,10 @@ void QWaylandDisplay::addRegistryListener(RegistryListener listener, void *data)
+ 
+ void QWaylandDisplay::removeListener(RegistryListener listener, void *data)
+ {
+-    std::remove_if(mRegistryListeners.begin(), mRegistryListeners.end(), [=](Listener l){
++    auto iter = std::remove_if(mRegistryListeners.begin(), mRegistryListeners.end(), [=](Listener l){
+         return (l.listener == listener && l.data == data);
+     });
++    mRegistryListeners.erase(iter, mRegistryListeners.end());
+ }
+ 
+ uint32_t QWaylandDisplay::currentTimeMillisec()
+@@ -467,50 +623,9 @@ uint32_t QWaylandDisplay::currentTimeMillisec()
+     return 0;
+ }
+ 
+-static void
+-sync_callback(void *data, struct wl_callback *callback, uint32_t serial)
+-{
+-    Q_UNUSED(serial)
+-    bool *done = static_cast<bool *>(data);
+-
+-    *done = true;
+-
+-    // If the wl_callback done event is received after the condition check in the while loop in
+-    // forceRoundTrip(), but before the call to processEvents, the call to processEvents may block
+-    // forever if no more events are posted (eventhough the callback is handled in response to the
+-    // aboutToBlock signal). Hence, we wake up the event dispatcher so forceRoundTrip may return.
+-    // (QTBUG-64696)
+-    if (auto *dispatcher = QThread::currentThread()->eventDispatcher())
+-        dispatcher->wakeUp();
+-
+-    wl_callback_destroy(callback);
+-}
+-
+-static const struct wl_callback_listener sync_listener = {
+-    sync_callback
+-};
+-
+ void QWaylandDisplay::forceRoundTrip()
+ {
+-    // wl_display_roundtrip() works on the main queue only,
+-    // but we use a separate one, so basically reimplement it here
+-    int ret = 0;
+-    bool done = false;
+-    wl_callback *callback = wl_display_sync(mDisplay);
+-    wl_callback_add_listener(callback, &sync_listener, &done);
+-    flushRequests();
+-    if (QThread::currentThread()->eventDispatcher()) {
+-        while (!done && ret >= 0) {
+-            QThread::currentThread()->eventDispatcher()->processEvents(QEventLoop::WaitForMoreEvents);
+-            ret = wl_display_dispatch_pending(mDisplay);
+-        }
+-    } else {
+-        while (!done && ret >= 0)
+-            ret = wl_display_dispatch(mDisplay);
+-    }
+-
+-    if (ret == -1 && !done)
+-        wl_callback_destroy(callback);
++     wl_display_roundtrip(mDisplay);
+ }
+ 
+ bool QWaylandDisplay::supportsWindowDecoration() const
+@@ -574,14 +689,10 @@ void QWaylandDisplay::handleKeyboardFocusChanged(QWaylandInputDevice *inputDevic
+     if (mLastKeyboardFocus == keyboardFocus)
+         return;
+ 
+-    if (mWaylandIntegration->mShellIntegration) {
+-        mWaylandIntegration->mShellIntegration->handleKeyboardFocusChanged(keyboardFocus, mLastKeyboardFocus);
+-    } else {
+-        if (keyboardFocus)
+-            handleWindowActivated(keyboardFocus);
+-        if (mLastKeyboardFocus)
+-            handleWindowDeactivated(mLastKeyboardFocus);
+-    }
++    if (keyboardFocus)
++        handleWindowActivated(keyboardFocus);
++    if (mLastKeyboardFocus)
++        handleWindowDeactivated(mLastKeyboardFocus);
+ 
+     mLastKeyboardFocus = keyboardFocus;
+ }
+@@ -600,6 +711,19 @@ void QWaylandDisplay::handleWaylandSync()
+     QWindow *activeWindow = mActiveWindows.empty() ? nullptr : mActiveWindows.last()->window();
+     if (activeWindow != QGuiApplication::focusWindow())
+         QWindowSystemInterface::handleWindowActivated(activeWindow);
++
++    if (!activeWindow) {
++        if (lastInputDevice()) {
++#if QT_CONFIG(clipboard)
++            if (auto *dataDevice = lastInputDevice()->dataDevice())
++                dataDevice->invalidateSelectionOffer();
++#endif
++#if QT_CONFIG(wayland_client_primary_selection)
++            if (auto *device = lastInputDevice()->primarySelectionDevice())
++                device->invalidateSelectionOffer();
++#endif
++        }
++    }
+ }
+ 
+ const wl_callback_listener QWaylandDisplay::syncCallbackListener = {
+@@ -626,6 +750,13 @@ QWaylandInputDevice *QWaylandDisplay::defaultInputDevice() const
+     return mInputDevices.isEmpty() ? 0 : mInputDevices.first();
+ }
+ 
++bool QWaylandDisplay::isKeyboardAvailable() const
++{
++    return std::any_of(
++            mInputDevices.constBegin(), mInputDevices.constEnd(),
++            [this](const QWaylandInputDevice *device) { return device->keyboard() != nullptr; });
++}
++
+ #if QT_CONFIG(cursor)
+ 
+ QWaylandCursor *QWaylandDisplay::waylandCursor()
+@@ -652,4 +783,6 @@ QWaylandCursorTheme *QWaylandDisplay::loadCursorTheme(const QString &name, int p
+ 
+ } // namespace QtWaylandClient
+ 
++#include "qwaylanddisplay.moc"
++
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/client/qwaylanddisplay_p.h b/qtwayland/src/client/qwaylanddisplay_p.h
+index 3b092bc8..42bc661d 100644
+--- a/qtwayland/src/client/qwaylanddisplay_p.h
++++ b/qtwayland/src/client/qwaylanddisplay_p.h
+@@ -109,6 +109,7 @@ class QWaylandSurface;
+ class QWaylandShellIntegration;
+ class QWaylandCursor;
+ class QWaylandCursorTheme;
++class EventThread;
+ 
+ typedef void (*RegistryListener)(void *data,
+                                  struct wl_registry *registry,
+@@ -120,15 +121,11 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandDisplay : public QObject, public QtWayland
+     Q_OBJECT
+ 
+ public:
+-    struct FrameQueue {
+-        FrameQueue(wl_event_queue *q = nullptr) : queue(q), mutex(new QMutex) {}
+-        wl_event_queue *queue;
+-        QMutex *mutex;
+-    };
+-
+     QWaylandDisplay(QWaylandIntegration *waylandIntegration);
+     ~QWaylandDisplay(void) override;
+ 
++    void initialize();
++
+ #if QT_CONFIG(xkbcommon)
+     struct xkb_context *xkbContext() const { return mXkbContext.get(); }
+ #endif
+@@ -210,11 +207,11 @@ public:
+     void handleKeyboardFocusChanged(QWaylandInputDevice *inputDevice);
+     void handleWindowDestroyed(QWaylandWindow *window);
+ 
+-    wl_event_queue *createEventQueue();
+-    FrameQueue createFrameQueue();
+-    void destroyFrameQueue(const FrameQueue &q);
+-    void dispatchQueueWhile(wl_event_queue *queue, std::function<bool()> condition, int timeout = -1);
++    wl_event_queue *frameEventQueue() { return m_frameEventQueue; };
++
++    bool isKeyboardAvailable() const;
+ 
++    void initEventThread();
+ public slots:
+     void blockingReadEvents();
+     void flushRequests();
+@@ -237,6 +234,9 @@ private:
+     };
+ 
+     struct wl_display *mDisplay = nullptr;
++    QScopedPointer<EventThread> m_eventThread;
++    wl_event_queue *m_frameEventQueue = nullptr;
++    QScopedPointer<EventThread> m_frameEventQueueThread;
+     QtWayland::wl_compositor mCompositor;
+     QScopedPointer<QWaylandShm> mShm;
+     QList<QWaylandScreen *> mWaitingScreens;
+@@ -273,11 +273,9 @@ private:
+     QWaylandInputDevice *mLastInputDevice = nullptr;
+     QPointer<QWaylandWindow> mLastInputWindow;
+     QPointer<QWaylandWindow> mLastKeyboardFocus;
+-    QVector<QWaylandWindow *> mActiveWindows;
+-    QVector<FrameQueue> mExternalQueues;
++    QList<QWaylandWindow *> mActiveWindows;
+     struct wl_callback *mSyncCallback = nullptr;
+     static const wl_callback_listener syncCallbackListener;
+-    QReadWriteLock m_frameQueueLock;
+ 
+     bool mClientSideInputContextRequested = !QPlatformInputContextFactory::requested().isNull();
+ 
+diff --git a/qtwayland/src/client/qwaylanddnd.cpp b/qtwayland/src/client/qwaylanddnd.cpp
+index 6535aa16..7c53f5fa 100644
+--- a/qtwayland/src/client/qwaylanddnd.cpp
++++ b/qtwayland/src/client/qwaylanddnd.cpp
+@@ -66,7 +66,7 @@ void QWaylandDrag::startDrag()
+ {
+     QBasicDrag::startDrag();
+     QWaylandWindow *icon = static_cast<QWaylandWindow *>(shapedPixmapWindow()->handle());
+-    if (m_display->currentInputDevice()->dataDevice()->startDrag(drag()->mimeData(), icon)) {
++    if (m_display->currentInputDevice()->dataDevice()->startDrag(drag()->mimeData(), drag()->supportedActions(), icon)) {
+         icon->addAttachOffset(-drag()->hotSpot());
+     } else {
+         // Cancelling immediately does not work, since the event loop for QDrag::exec is started
+@@ -80,6 +80,9 @@ void QWaylandDrag::cancel()
+     QBasicDrag::cancel();
+ 
+     m_display->currentInputDevice()->dataDevice()->cancelDrag();
++
++    if (drag())
++        drag()->deleteLater();
+ }
+ 
+ void QWaylandDrag::move(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods)
+@@ -103,33 +106,41 @@ void QWaylandDrag::endDrag()
+     m_display->currentInputDevice()->handleEndDrag();
+ }
+ 
+-void QWaylandDrag::updateTarget(const QString &mimeType)
++void QWaylandDrag::setResponse(bool accepted)
+ {
+-    setCanDrop(!mimeType.isEmpty());
+-
+-    if (canDrop()) {
+-        updateCursor(defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers()));
+-    } else {
+-        updateCursor(Qt::IgnoreAction);
+-    }
++    // This method is used for old DataDevices where the drag action is not communicated
++    Qt::DropAction action = defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers());
++    setResponse(QPlatformDropQtResponse(accepted, action));
+ }
+ 
+-void QWaylandDrag::setResponse(const QPlatformDragQtResponse &response)
++void QWaylandDrag::setResponse(const QPlatformDropQtResponse &response)
+ {
+     setCanDrop(response.isAccepted());
+ 
+     if (canDrop()) {
+-        updateCursor(defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers()));
++        updateCursor(response.acceptedAction());
+     } else {
+         updateCursor(Qt::IgnoreAction);
+     }
+ }
+ 
+-void QWaylandDrag::finishDrag(const QPlatformDropQtResponse &response)
++void QWaylandDrag::setDropResponse(const QPlatformDropQtResponse &response)
+ {
+     setExecutedDropAction(response.acceptedAction());
++}
++
++void QWaylandDrag::finishDrag()
++{
+     QKeyEvent event(QEvent::KeyPress, Qt::Key_Escape, Qt::NoModifier);
+     eventFilter(shapedPixmapWindow(), &event);
++
++    if (drag())
++        drag()->deleteLater();
++}
++
++bool QWaylandDrag::ownsDragObject() const
++{
++    return true;
+ }
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddnd_p.h b/qtwayland/src/client/qwaylanddnd_p.h
+index 474fe2ab..46f629ac 100644
+--- a/qtwayland/src/client/qwaylanddnd_p.h
++++ b/qtwayland/src/client/qwaylanddnd_p.h
+@@ -71,9 +71,10 @@ public:
+     QWaylandDrag(QWaylandDisplay *display);
+     ~QWaylandDrag() override;
+ 
+-    void updateTarget(const QString &mimeType);
+-    void setResponse(const QPlatformDragQtResponse &response);
+-    void finishDrag(const QPlatformDropQtResponse &response);
++    void setResponse(bool accepted);
++    void setResponse(const QPlatformDropQtResponse &response);
++    void setDropResponse(const QPlatformDropQtResponse &response);
++    void finishDrag();
+ 
+ protected:
+     void startDrag() override;
+@@ -82,6 +83,7 @@ protected:
+     void drop(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods) override;
+     void endDrag() override;
+ 
++    bool ownsDragObject() const override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+diff --git a/qtwayland/src/client/qwaylandinputdevice.cpp b/qtwayland/src/client/qwaylandinputdevice.cpp
+index 613fe862..4b90de84 100644
+--- a/qtwayland/src/client/qwaylandinputdevice.cpp
++++ b/qtwayland/src/client/qwaylandinputdevice.cpp
+@@ -685,6 +685,11 @@ public:
+ 
+ void QWaylandInputDevice::Pointer::pointer_leave(uint32_t time, struct wl_surface *surface)
+ {
++    invalidateFocus();
++    mButtons = Qt::NoButton;
++
++    mParent->mTime = time;
++
+     // The event may arrive after destroying the window, indicated by
+     // a null surface.
+     if (!surface)
+@@ -696,11 +701,6 @@ void QWaylandInputDevice::Pointer::pointer_leave(uint32_t time, struct wl_surfac
+ 
+     if (!QWaylandWindow::mouseGrab())
+         setFrameEvent(new LeaveEvent(window, mSurfacePos, mGlobalPos));
+-
+-    invalidateFocus();
+-    mButtons = Qt::NoButton;
+-
+-    mParent->mTime = time;
+ }
+ 
+ class MotionEvent : public QWaylandPointerEvent
+@@ -1300,14 +1300,6 @@ void QWaylandInputDevice::Keyboard::handleFocusDestroyed()
+ void QWaylandInputDevice::Keyboard::handleFocusLost()
+ {
+     mFocus = nullptr;
+-#if QT_CONFIG(clipboard)
+-    if (auto *dataDevice = mParent->dataDevice())
+-        dataDevice->invalidateSelectionOffer();
+-#endif
+-#if QT_CONFIG(wayland_client_primary_selection)
+-    if (auto *device = mParent->primarySelectionDevice())
+-        device->invalidateSelectionOffer();
+-#endif
+     mParent->mQDisplay->handleKeyboardFocusChanged(mParent);
+     mRepeatTimer.stop();
+ }
+@@ -1396,6 +1388,7 @@ void QWaylandInputDevice::Touch::touch_cancel()
+     if (touchExt)
+         touchExt->touchCanceled();
+ 
++    mFocus = nullptr;
+     QWindowSystemInterface::handleTouchCancelEvent(nullptr, mParent->mTouchDevice);
+ }
+ 
+diff --git a/qtwayland/src/client/qwaylandintegration.cpp b/qtwayland/src/client/qwaylandintegration.cpp
+index c53ccb78..54861600 100644
+--- a/qtwayland/src/client/qwaylandintegration.cpp
++++ b/qtwayland/src/client/qwaylandintegration.cpp
+@@ -125,6 +125,9 @@ QWaylandIntegration::QWaylandIntegration()
+ #endif
+ 
+     reconfigureInputContext();
++
++    QWaylandWindow::fixedToplevelPositions =
++            !qEnvironmentVariableIsSet("QT_WAYLAND_DISABLE_FIXED_POSITIONS");
+ }
+ 
+ QWaylandIntegration::~QWaylandIntegration()
+@@ -192,14 +195,18 @@ QAbstractEventDispatcher *QWaylandIntegration::createEventDispatcher() const
+ 
+ void QWaylandIntegration::initialize()
+ {
++    mDisplay->initEventThread();
++
++    // Call after eventDispatcher is fully connected, for QWaylandDisplay::forceRoundTrip()
++    mDisplay->initialize();
++
++    // But the aboutToBlock() and awake() should be connected after initializePlatform().
++    // Otherwise the connected flushRequests() may consumes up all events before processEvents starts to wait,
++    // so that processEvents(QEventLoop::WaitForMoreEvents) may be blocked in the forceRoundTrip().
+     QAbstractEventDispatcher *dispatcher = QGuiApplicationPrivate::eventDispatcher;
+     QObject::connect(dispatcher, SIGNAL(aboutToBlock()), mDisplay.data(), SLOT(flushRequests()));
+     QObject::connect(dispatcher, SIGNAL(awake()), mDisplay.data(), SLOT(flushRequests()));
+ 
+-    int fd = wl_display_get_fd(mDisplay->wl_display());
+-    QSocketNotifier *sn = new QSocketNotifier(fd, QSocketNotifier::Read, mDisplay.data());
+-    QObject::connect(sn, SIGNAL(activated(QSocketDescriptor)), mDisplay.data(), SLOT(flushRequests()));
+-
+     // Qt does not support running with no screens
+     mDisplay->ensureScreen();
+ }
+@@ -262,6 +269,14 @@ QWaylandDisplay *QWaylandIntegration::display() const
+     return mDisplay.data();
+ }
+ 
++Qt::KeyboardModifiers QWaylandIntegration::queryKeyboardModifiers() const
++{
++    if (auto *seat = mDisplay->currentInputDevice()) {
++        return seat->modifiers();
++    }
++    return Qt::NoModifier;
++}
++
+ QList<int> QWaylandIntegration::possibleKeys(const QKeyEvent *event) const
+ {
+     if (auto *seat = mDisplay->currentInputDevice())
+@@ -479,7 +494,7 @@ void QWaylandIntegration::reconfigureInputContext()
+     }
+ #endif
+ 
+-    qCDebug(lcQpaWayland) << "using input method:" << inputContext()->metaObject()->className();
++    qCDebug(lcQpaWayland) << "using input method:" << (inputContext() ? inputContext()->metaObject()->className() : "<none>");
+ }
+ 
+ QWaylandShellIntegration *QWaylandIntegration::createShellIntegration(const QString &integrationName)
+diff --git a/qtwayland/src/client/qwaylandintegration_p.h b/qtwayland/src/client/qwaylandintegration_p.h
+index ff70ae25..73b80658 100644
+--- a/qtwayland/src/client/qwaylandintegration_p.h
++++ b/qtwayland/src/client/qwaylandintegration_p.h
+@@ -107,6 +107,8 @@ public:
+ 
+     QWaylandDisplay *display() const;
+ 
++    Qt::KeyboardModifiers queryKeyboardModifiers() const override;
++
+     QList<int> possibleKeys(const QKeyEvent *event) const override;
+ 
+     QStringList themeNames() const override;
+diff --git a/qtwayland/src/client/qwaylandprimaryselectionv1.cpp b/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
+index 832f9678..ea508771 100644
+--- a/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
++++ b/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
+@@ -54,11 +54,6 @@ QWaylandPrimarySelectionDeviceManagerV1::QWaylandPrimarySelectionDeviceManagerV1
+     : zwp_primary_selection_device_manager_v1(display->wl_registry(), id, qMin(version, uint(1)))
+     , m_display(display)
+ {
+-    // Create devices for all seats.
+-    // This only works if we get the global before all devices
+-    const auto seats = m_display->inputDevices();
+-    for (auto *seat : seats)
+-        seat->setPrimarySelectionDevice(createDevice(seat));
+ }
+ 
+ QWaylandPrimarySelectionDeviceV1 *QWaylandPrimarySelectionDeviceManagerV1::createDevice(QWaylandInputDevice *seat)
+diff --git a/qtwayland/src/client/qwaylandscreen.cpp b/qtwayland/src/client/qwaylandscreen.cpp
+index 6cb337de..5537dafd 100644
+--- a/qtwayland/src/client/qwaylandscreen.cpp
++++ b/qtwayland/src/client/qwaylandscreen.cpp
+@@ -60,7 +60,7 @@ QWaylandXdgOutputManagerV1::QWaylandXdgOutputManagerV1(QWaylandDisplay* display,
+ }
+ 
+ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uint32_t id)
+-    : QtWayland::wl_output(waylandDisplay->wl_registry(), id, qMin(version, 2))
++    : QtWayland::wl_output(waylandDisplay->wl_registry(), id, qMin(version, 3))
+     , m_outputId(id)
+     , mWaylandDisplay(waylandDisplay)
+     , mOutputName(QStringLiteral("Screen%1").arg(id))
+@@ -72,7 +72,7 @@ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uin
+         qCWarning(lcQpaWayland) << "wl_output done event not supported by compositor,"
+                                 << "QScreen may not work correctly";
+         mWaylandDisplay->forceRoundTrip(); // Give the compositor a chance to send geometry etc.
+-        mOutputDone = true; // Fake the done event
++        mProcessedEvents |= OutputDoneEvent; // Fake the done event
+         maybeInitialize();
+     }
+ }
+@@ -81,16 +81,29 @@ QWaylandScreen::~QWaylandScreen()
+ {
+     if (zxdg_output_v1::isInitialized())
+         zxdg_output_v1::destroy();
++    if (wl_output::isInitialized() && wl_output_get_version(wl_output::object()) >= WL_OUTPUT_RELEASE_SINCE_VERSION)
++        wl_output::release();
++}
++
++uint QWaylandScreen::requiredEvents() const
++{
++    uint ret = OutputDoneEvent;
++
++    if (mWaylandDisplay->xdgOutputManager()) {
++        ret |= XdgOutputNameEvent;
++
++        if (mWaylandDisplay->xdgOutputManager()->version() < 3)
++            ret |= XdgOutputDoneEvent;
++    }
++    return ret;
+ }
+ 
+ void QWaylandScreen::maybeInitialize()
+ {
+     Q_ASSERT(!mInitialized);
+ 
+-    if (!mOutputDone)
+-        return;
+-
+-    if (mWaylandDisplay->xdgOutputManager() && !mXdgOutputDone)
++    const uint requiredEvents = this->requiredEvents();
++    if ((mProcessedEvents & requiredEvents) != requiredEvents)
+         return;
+ 
+     mInitialized = true;
+@@ -276,9 +289,8 @@ void QWaylandScreen::output_scale(int32_t factor)
+ 
+ void QWaylandScreen::output_done()
+ {
+-    mOutputDone = true;
+-    if (zxdg_output_v1::isInitialized() && mWaylandDisplay->xdgOutputManager()->version() >= 3)
+-        mXdgOutputDone = true;
++    mProcessedEvents |= OutputDoneEvent;
++
+     if (mInitialized) {
+         updateOutputProperties();
+         if (zxdg_output_v1::isInitialized())
+@@ -339,7 +351,7 @@ void QWaylandScreen::zxdg_output_v1_done()
+     if (Q_UNLIKELY(mWaylandDisplay->xdgOutputManager()->version() >= 3))
+         qWarning(lcQpaWayland) << "zxdg_output_v1.done received on version 3 or newer, this is most likely a bug in the compositor";
+ 
+-    mXdgOutputDone = true;
++    mProcessedEvents |= XdgOutputDoneEvent;
+     if (mInitialized)
+         updateXdgOutputProperties();
+     else
+@@ -348,7 +360,11 @@ void QWaylandScreen::zxdg_output_v1_done()
+ 
+ void QWaylandScreen::zxdg_output_v1_name(const QString &name)
+ {
++    if (Q_UNLIKELY(mInitialized))
++        qWarning(lcQpaWayland) << "zxdg_output_v1.name received after output has been initialized, this is most likely a bug in the compositor";
++
+     mOutputName = name;
++    mProcessedEvents |= XdgOutputNameEvent;
+ }
+ 
+ void QWaylandScreen::updateXdgOutputProperties()
+diff --git a/qtwayland/src/client/qwaylandscreen_p.h b/qtwayland/src/client/qwaylandscreen_p.h
+index df1c94f2..050cfdc0 100644
+--- a/qtwayland/src/client/qwaylandscreen_p.h
++++ b/qtwayland/src/client/qwaylandscreen_p.h
+@@ -116,6 +116,13 @@ public:
+     static QWaylandScreen *fromWlOutput(::wl_output *output);
+ 
+ private:
++    enum Event : uint {
++        XdgOutputDoneEvent = 0x1,
++        OutputDoneEvent = 0x2,
++        XdgOutputNameEvent = 0x4,
++    };
++    uint requiredEvents() const;
++
+     void output_mode(uint32_t flags, int width, int height, int refresh) override;
+     void output_geometry(int32_t x, int32_t y,
+                          int32_t width, int32_t height,
+@@ -148,8 +155,7 @@ private:
+     QSize mPhysicalSize;
+     QString mOutputName;
+     Qt::ScreenOrientation m_orientation = Qt::PrimaryOrientation;
+-    bool mOutputDone = false;
+-    bool mXdgOutputDone = false;
++    uint mProcessedEvents = 0;
+     bool mInitialized = false;
+ 
+ #if QT_CONFIG(cursor)
+diff --git a/qtwayland/src/client/qwaylandshmbackingstore.cpp b/qtwayland/src/client/qwaylandshmbackingstore.cpp
+index dc7ff670..41cffdf7 100644
+--- a/qtwayland/src/client/qwaylandshmbackingstore.cpp
++++ b/qtwayland/src/client/qwaylandshmbackingstore.cpp
+@@ -52,6 +52,7 @@
+ 
+ #include <QtWaylandClient/private/wayland-wayland-client-protocol.h>
+ 
++#include <fcntl.h>
+ #include <unistd.h>
+ #include <sys/mman.h>
+ 
+@@ -61,6 +62,9 @@
+ #  ifndef MFD_CLOEXEC
+ #    define MFD_CLOEXEC     0x0001U
+ #  endif
++#  ifndef MFD_ALLOW_SEALING
++#    define MFD_ALLOW_SEALING 0x0002U
++#  endif
+ #endif
+ 
+ QT_BEGIN_NAMESPACE
+@@ -74,8 +78,10 @@ QWaylandShmBuffer::QWaylandShmBuffer(QWaylandDisplay *display,
+     int alloc = stride * size.height();
+     int fd = -1;
+ 
+-#ifdef SYS_memfd_create
+-    fd = syscall(SYS_memfd_create, "wayland-shm", MFD_CLOEXEC);
++#if defined(SYS_memfd_create) && defined(F_SEAL_SEAL)
++    fd = syscall(SYS_memfd_create, "wayland-shm", MFD_CLOEXEC | MFD_ALLOW_SEALING);
++    if (fd >= 0)
++        fcntl(fd, F_ADD_SEALS, F_SEAL_SHRINK | F_SEAL_SEAL);
+ #endif
+ 
+     QScopedPointer<QFile> filePointer;
+diff --git a/qtwayland/src/client/qwaylandwindow.cpp b/qtwayland/src/client/qwaylandwindow.cpp
+index cb82857a..fb2c59dc 100644
+--- a/qtwayland/src/client/qwaylandwindow.cpp
++++ b/qtwayland/src/client/qwaylandwindow.cpp
+@@ -76,7 +76,6 @@ QWaylandWindow *QWaylandWindow::mMouseGrab = nullptr;
+ QWaylandWindow::QWaylandWindow(QWindow *window, QWaylandDisplay *display)
+     : QPlatformWindow(window)
+     , mDisplay(display)
+-    , mFrameQueue(mDisplay->createFrameQueue())
+     , mResizeAfterSwap(qEnvironmentVariableIsSet("QT_WAYLAND_RESIZE_AFTER_SWAP"))
+ {
+     {
+@@ -95,9 +94,6 @@ QWaylandWindow::QWaylandWindow(QWindow *window, QWaylandDisplay *display)
+ 
+ QWaylandWindow::~QWaylandWindow()
+ {
+-    mDisplay->destroyFrameQueue(mFrameQueue);
+-    mDisplay->handleWindowDestroyed(this);
+-
+     delete mWindowDecoration;
+ 
+     if (mSurface)
+@@ -243,6 +239,7 @@ bool QWaylandWindow::shouldCreateSubSurface() const
+ 
+ void QWaylandWindow::reset()
+ {
++    closeChildPopups();
+     delete mShellSurface;
+     mShellSurface = nullptr;
+     delete mSubSurfaceWindow;
+@@ -255,17 +252,22 @@ void QWaylandWindow::reset()
+         mSurface.reset();
+     }
+ 
+-    if (mFrameCallback) {
+-        wl_callback_destroy(mFrameCallback);
+-        mFrameCallback = nullptr;
+-    }
++    {
++        QMutexLocker lock(&mFrameSyncMutex);
++        if (mFrameCallback) {
++            wl_callback_destroy(mFrameCallback);
++            mFrameCallback = nullptr;
++        }
+ 
+-    mFrameCallbackElapsedTimer.invalidate();
+-    mWaitingForFrameCallback = false;
++        mFrameCallbackElapsedTimer.invalidate();
++        mWaitingForFrameCallback = false;
++    }
+     mFrameCallbackTimedOut = false;
+ 
+     mMask = QRegion();
+     mQueuedBuffer = nullptr;
++
++    mDisplay->handleWindowDestroyed(this);
+ }
+ 
+ QWaylandWindow *QWaylandWindow::fromWlSurface(::wl_surface *surface)
+@@ -351,19 +353,25 @@ void QWaylandWindow::setGeometry_helper(const QRect &rect)
+     }
+ }
+ 
+-void QWaylandWindow::setGeometry(const QRect &rect)
++void QWaylandWindow::setGeometry(const QRect &r)
+ {
++    auto rect = r;
++    if (fixedToplevelPositions && !QPlatformWindow::parent() && window()->type() != Qt::Popup
++        && window()->type() != Qt::ToolTip) {
++        rect.moveTo(screen()->geometry().topLeft());
++    }
+     setGeometry_helper(rect);
+ 
+     if (window()->isVisible() && rect.isValid()) {
+         if (mWindowDecoration)
+             mWindowDecoration->update();
+ 
+-        if (mResizeAfterSwap && windowType() == Egl && mSentInitialResize)
++        if (mResizeAfterSwap && windowType() == Egl && mSentInitialResize) {
++            QMutexLocker lock(&mResizeLock);
+             mResizeDirty = true;
+-        else
++        } else {
+             QWindowSystemInterface::handleGeometryChange(window(), geometry());
+-
++        }
+         mSentInitialResize = true;
+     }
+     QRect exposeGeometry(QPoint(), geometry().size());
+@@ -374,7 +382,7 @@ void QWaylandWindow::setGeometry(const QRect &rect)
+         mShellSurface->setWindowGeometry(windowContentGeometry());
+ 
+     if (isOpaque() && mMask.isEmpty())
+-        setOpaqueArea(rect);
++        setOpaqueArea(QRect(QPoint(0, 0), rect.size()));
+ }
+ 
+ void QWaylandWindow::resizeFromApplyConfigure(const QSize &sizeWithMargins, const QPoint &offset)
+@@ -399,21 +407,6 @@ void QWaylandWindow::sendExposeEvent(const QRect &rect)
+     mLastExposeGeometry = rect;
+ }
+ 
+-
+-static QVector<QPointer<QWaylandWindow>> activePopups;
+-
+-void QWaylandWindow::closePopups(QWaylandWindow *parent)
+-{
+-    while (!activePopups.isEmpty()) {
+-        auto popup = activePopups.takeLast();
+-        if (popup.isNull())
+-            continue;
+-        if (popup.data() == parent)
+-            return;
+-        popup->reset();
+-    }
+-}
+-
+ QPlatformScreen *QWaylandWindow::calculateScreenFromSurfaceEvents() const
+ {
+     QReadLocker lock(&mSurfaceLock);
+@@ -433,10 +426,7 @@ void QWaylandWindow::setVisible(bool visible)
+     lastVisible = visible;
+ 
+     if (visible) {
+-        if (window()->type() == Qt::Popup || window()->type() == Qt::ToolTip)
+-            activePopups << this;
+         initWindow();
+-        mDisplay->flushRequests();
+ 
+         setGeometry(windowGeometry());
+         // Don't flush the events here, or else the newly visible window may start drawing, but since
+@@ -444,7 +434,6 @@ void QWaylandWindow::setVisible(bool visible)
+         // QWaylandShmBackingStore::beginPaint().
+     } else {
+         sendExposeEvent(QRect());
+-        closePopups(this);
+         reset();
+     }
+ }
+@@ -556,12 +545,12 @@ void QWaylandWindow::sendRecursiveExposeEvent()
+ 
+ void QWaylandWindow::attach(QWaylandBuffer *buffer, int x, int y)
+ {
+-    Q_ASSERT(!buffer->committed());
+     QReadLocker locker(&mSurfaceLock);
+     if (mSurface == nullptr)
+         return;
+ 
+     if (buffer) {
++        Q_ASSERT(!buffer->committed());
+         handleUpdate();
+         buffer->setBusy();
+ 
+@@ -583,7 +572,11 @@ void QWaylandWindow::damage(const QRect &rect)
+     if (mSurface == nullptr)
+         return;
+ 
+-    mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    const int s = scale();
++    if (mDisplay->compositorVersion() >= 4)
++        mSurface->damage_buffer(s * rect.x(), s * rect.y(), s * rect.width(), s * rect.height());
++    else
++        mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
+ }
+ 
+ void QWaylandWindow::safeCommit(QWaylandBuffer *buffer, const QRegion &damage)
+@@ -619,8 +612,14 @@ void QWaylandWindow::commit(QWaylandBuffer *buffer, const QRegion &damage)
+         return;
+ 
+     attachOffset(buffer);
+-    for (const QRect &rect: damage)
+-        mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    if (mDisplay->compositorVersion() >= 4) {
++        const int s = scale();
++        for (const QRect &rect: damage)
++            mSurface->damage_buffer(s * rect.x(), s * rect.y(), s * rect.width(), s * rect.height());
++    } else {
++        for (const QRect &rect: damage)
++            mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    }
+     Q_ASSERT(!buffer->committed());
+     buffer->setCommitted();
+     mSurface->commit();
+@@ -635,42 +634,53 @@ void QWaylandWindow::commit()
+ 
+ const wl_callback_listener QWaylandWindow::callbackListener = {
+     [](void *data, wl_callback *callback, uint32_t time) {
+-        Q_UNUSED(callback);
+         Q_UNUSED(time);
+         auto *window = static_cast<QWaylandWindow*>(data);
+-        window->handleFrameCallback();
++        window->handleFrameCallback(callback);
+     }
+ };
+ 
+-void QWaylandWindow::handleFrameCallback()
++void QWaylandWindow::handleFrameCallback(wl_callback* callback)
+ {
++    QMutexLocker locker(&mFrameSyncMutex);
++    if (!mFrameCallback) {
++        // This means the callback is already unset by QWaylandWindow::reset.
++        // The wl_callback object will be destroyed there too.
++        return;
++    }
++    Q_ASSERT(callback == mFrameCallback);
++    wl_callback_destroy(callback);
++    mFrameCallback = nullptr;
++
+     mWaitingForFrameCallback = false;
+     mFrameCallbackElapsedTimer.invalidate();
+ 
+     // The rest can wait until we can run it on the correct thread
+-    if (!mWaitingForUpdateDelivery) {
+-        auto doHandleExpose = [this]() {
+-            bool wasExposed = isExposed();
+-            mFrameCallbackTimedOut = false;
+-            if (!wasExposed && isExposed()) // Did setting mFrameCallbackTimedOut make the window exposed?
+-                sendExposeEvent(QRect(QPoint(), geometry().size()));
+-            if (wasExposed && hasPendingUpdateRequest())
+-                deliverUpdateRequest();
+-
+-            mWaitingForUpdateDelivery = false;
+-        };
++    auto doHandleExpose = [this]() {
++        mWaitingForUpdateDelivery.storeRelease(false);
++        bool wasExposed = isExposed();
++        mFrameCallbackTimedOut = false;
++        if (!wasExposed && isExposed()) // Did setting mFrameCallbackTimedOut make the window exposed?
++            sendExposeEvent(QRect(QPoint(), geometry().size()));
++        if (wasExposed && hasPendingUpdateRequest())
++            deliverUpdateRequest();
++    };
+ 
++    if (mWaitingForUpdateDelivery.testAndSetAcquire(false, true)) {
+         // Queued connection, to make sure we don't call handleUpdate() from inside waitForFrameSync()
+         // in the single-threaded case.
+-        mWaitingForUpdateDelivery = true;
+         QMetaObject::invokeMethod(this, doHandleExpose, Qt::QueuedConnection);
+     }
++
++    mFrameSyncWait.notify_all();
+ }
+ 
+ bool QWaylandWindow::waitForFrameSync(int timeout)
+ {
+-    QMutexLocker locker(mFrameQueue.mutex);
+-    mDisplay->dispatchQueueWhile(mFrameQueue.queue, [&]() { return mWaitingForFrameCallback; }, timeout);
++    QMutexLocker locker(&mFrameSyncMutex);
++
++    QDeadlineTimer deadline(timeout);
++    while (mWaitingForFrameCallback && mFrameSyncWait.wait(&mFrameSyncMutex, deadline)) { }
+ 
+     if (mWaitingForFrameCallback) {
+         qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
+@@ -868,6 +878,17 @@ bool QWaylandWindow::createDecoration()
+             subsurf->set_position(pos.x() + m.left(), pos.y() + m.top());
+         }
+         sendExposeEvent(QRect(QPoint(), geometry().size()));
++
++        // This is a special case where the buffer is recreated, but since
++        // the content rect remains the same, the widgets remain the same
++        // size and are not redrawn, leaving the new buffer empty. As a simple
++        // work-around, we trigger a full extra update whenever the client-side
++        // window decorations are toggled while the window is showing.
++        // Note: createDecoration() is sometimes called from the render thread
++        // of Qt Quick. This is essentially wrong and could potentially cause problems,
++        // but until the underlying issue has been fixed, we have to use invokeMethod()
++        // here to avoid asserts.
++        QMetaObject::invokeMethod(window(), &QWindow::requestUpdate);
+     }
+ 
+     return mWindowDecoration;
+@@ -1023,6 +1044,13 @@ void QWaylandWindow::handleScreensChanged()
+ 
+     QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->QPlatformScreen::screen());
+     mLastReportedScreen = newScreen;
++    if (fixedToplevelPositions && !QPlatformWindow::parent() && window()->type() != Qt::Popup
++        && window()->type() != Qt::ToolTip
++        && geometry().topLeft() != newScreen->geometry().topLeft()) {
++        auto geometry = this->geometry();
++        geometry.moveTo(newScreen->geometry().topLeft());
++        setGeometry(geometry);
++    }
+ 
+     int scale = newScreen->isPlaceholder() ? 1 : static_cast<QWaylandScreen *>(newScreen)->scale();
+     if (scale != mScale) {
+@@ -1094,10 +1122,18 @@ bool QWaylandWindow::setMouseGrabEnabled(bool grab)
+     return true;
+ }
+ 
++Qt::WindowStates QWaylandWindow::windowStates() const
++{
++    return mLastReportedWindowStates;
++}
++
+ void QWaylandWindow::handleWindowStatesChanged(Qt::WindowStates states)
+ {
+     createDecoration();
+-    QWindowSystemInterface::handleWindowStateChanged(window(), states, mLastReportedWindowStates);
++    Qt::WindowStates statesWithoutActive = states & ~Qt::WindowActive;
++    Qt::WindowStates lastStatesWithoutActive = mLastReportedWindowStates & ~Qt::WindowActive;
++    QWindowSystemInterface::handleWindowStateChanged(window(), statesWithoutActive,
++                                                     lastStatesWithoutActive);
+     mLastReportedWindowStates = states;
+ }
+ 
+@@ -1139,19 +1175,24 @@ void QWaylandWindow::timerEvent(QTimerEvent *event)
+     if (event->timerId() != mFrameCallbackCheckIntervalTimerId)
+         return;
+ 
+-    bool callbackTimerExpired = mFrameCallbackElapsedTimer.hasExpired(mFrameCallbackTimeout);
+-    if (!mFrameCallbackElapsedTimer.isValid() || callbackTimerExpired ) {
+-        killTimer(mFrameCallbackCheckIntervalTimerId);
+-        mFrameCallbackCheckIntervalTimerId = -1;
+-    }
+-    if (mFrameCallbackElapsedTimer.isValid() && callbackTimerExpired) {
+-        mFrameCallbackElapsedTimer.invalidate();
++    {
++        QMutexLocker lock(&mFrameSyncMutex);
+ 
+-        qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
+-        mFrameCallbackTimedOut = true;
+-        mWaitingForUpdate = false;
+-        sendExposeEvent(QRect());
++        bool callbackTimerExpired = mFrameCallbackElapsedTimer.hasExpired(mFrameCallbackTimeout);
++        if (!mFrameCallbackElapsedTimer.isValid() || callbackTimerExpired ) {
++            killTimer(mFrameCallbackCheckIntervalTimerId);
++            mFrameCallbackCheckIntervalTimerId = -1;
++        }
++        if (!mFrameCallbackElapsedTimer.isValid() || !callbackTimerExpired) {
++            return;
++        }
++        mFrameCallbackElapsedTimer.invalidate();
+     }
++
++    qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
++    mFrameCallbackTimedOut = true;
++    mWaitingForUpdate = false;
++    sendExposeEvent(QRect());
+ }
+ 
+ void QWaylandWindow::requestUpdate()
+@@ -1160,8 +1201,11 @@ void QWaylandWindow::requestUpdate()
+     Q_ASSERT(hasPendingUpdateRequest()); // should be set by QPA
+ 
+     // If we have a frame callback all is good and will be taken care of there
+-    if (mWaitingForFrameCallback)
+-        return;
++    {
++        QMutexLocker locker(&mFrameSyncMutex);
++        if (mWaitingForFrameCallback)
++            return;
++    }
+ 
+     // If we've already called deliverUpdateRequest(), but haven't seen any attach+commit/swap yet
+     // This is a somewhat redundant behavior and might indicate a bug in the calling code, so log
+@@ -1174,7 +1218,12 @@ void QWaylandWindow::requestUpdate()
+     // so use invokeMethod to delay the delivery a bit.
+     QMetaObject::invokeMethod(this, [this] {
+         // Things might have changed in the meantime
+-        if (hasPendingUpdateRequest() && !mWaitingForFrameCallback)
++        {
++            QMutexLocker locker(&mFrameSyncMutex);
++            if (mWaitingForFrameCallback)
++                return;
++        }
++        if (hasPendingUpdateRequest())
+             deliverUpdateRequest();
+     }, Qt::QueuedConnection);
+ }
+@@ -1185,19 +1234,18 @@ void QWaylandWindow::requestUpdate()
+ void QWaylandWindow::handleUpdate()
+ {
+     qCDebug(lcWaylandBackingstore) << "handleUpdate" << QThread::currentThread();
++
+     // TODO: Should sync subsurfaces avoid requesting frame callbacks?
+     QReadLocker lock(&mSurfaceLock);
+     if (!mSurface)
+         return;
+ 
+-    if (mFrameCallback) {
+-        wl_callback_destroy(mFrameCallback);
+-        mFrameCallback = nullptr;
+-    }
++    QMutexLocker locker(&mFrameSyncMutex);
++    if (mWaitingForFrameCallback)
++        return;
+ 
+-    QMutexLocker locker(mFrameQueue.mutex);
+     struct ::wl_surface *wrappedSurface = reinterpret_cast<struct ::wl_surface *>(wl_proxy_create_wrapper(mSurface->object()));
+-    wl_proxy_set_queue(reinterpret_cast<wl_proxy *>(wrappedSurface), mFrameQueue.queue);
++    wl_proxy_set_queue(reinterpret_cast<wl_proxy *>(wrappedSurface), mDisplay->frameEventQueue());
+     mFrameCallback = wl_surface_frame(wrappedSurface);
+     wl_proxy_wrapper_destroy(wrappedSurface);
+     wl_callback_add_listener(mFrameCallback, &QWaylandWindow::callbackListener, this);
+@@ -1207,6 +1255,8 @@ void QWaylandWindow::handleUpdate()
+     // Start a timer for handling the case when the compositor stops sending frame callbacks.
+     if (mFrameCallbackTimeout > 0) {
+         QMetaObject::invokeMethod(this, [this] {
++            QMutexLocker locker(&mFrameSyncMutex);
++
+             if (mWaitingForFrameCallback) {
+                 if (mFrameCallbackCheckIntervalTimerId < 0)
+                     mFrameCallbackCheckIntervalTimerId = startTimer(mFrameCallbackTimeout);
+@@ -1267,6 +1317,20 @@ void QWaylandWindow::setOpaqueArea(const QRegion &opaqueArea)
+     wl_region_destroy(region);
+ }
+ 
++void QWaylandWindow::addChildPopup(QWaylandWindow *surface) {
++    mChildPopups.append(surface);
++}
++
++void QWaylandWindow::removeChildPopup(QWaylandWindow *surface) {
++    mChildPopups.removeAll(surface);
++}
++
++void QWaylandWindow::closeChildPopups() {
++    while (!mChildPopups.isEmpty()) {
++        auto popup = mChildPopups.takeLast();
++        popup->reset();
++    }
++}
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/client/qwaylandwindow_p.h b/qtwayland/src/client/qwaylandwindow_p.h
+index 01337cff..2f219d8c 100644
+--- a/qtwayland/src/client/qwaylandwindow_p.h
++++ b/qtwayland/src/client/qwaylandwindow_p.h
+@@ -98,6 +98,9 @@ public:
+     QWaylandWindow(QWindow *window, QWaylandDisplay *display);
+     ~QWaylandWindow() override;
+ 
++    // Keep Toplevels position on the top left corner of their screen
++    static inline bool fixedToplevelPositions = true;
++
+     virtual WindowType windowType() const = 0;
+     virtual void ensureSize();
+     WId winId() const override;
+@@ -148,6 +151,7 @@ public:
+     void setWindowState(Qt::WindowStates states) override;
+     void setWindowFlags(Qt::WindowFlags flags) override;
+     void handleWindowStatesChanged(Qt::WindowStates states);
++    Qt::WindowStates windowStates() const;
+ 
+     void raise() override;
+     void lower() override;
+@@ -206,6 +210,10 @@ public:
+     void handleUpdate();
+     void deliverUpdateRequest() override;
+ 
++    void addChildPopup(QWaylandWindow* child);
++    void removeChildPopup(QWaylandWindow* child);
++    void closeChildPopups();
++
+ public slots:
+     void applyConfigure();
+ 
+@@ -215,7 +223,11 @@ signals:
+ 
+ protected:
+     QWaylandDisplay *mDisplay = nullptr;
++
++    // mSurface can be written by the main thread. Other threads should claim a read lock for access
++    mutable QReadWriteLock mSurfaceLock;
+     QScopedPointer<QWaylandSurface> mSurface;
++
+     QWaylandShellSurface *mShellSurface = nullptr;
+     QWaylandSubSurface *mSubSurfaceWindow = nullptr;
+     QVector<QWaylandSubSurface *> mChildren;
+@@ -225,13 +237,14 @@ protected:
+     Qt::MouseButtons mMousePressedInContentArea = Qt::NoButton;
+ 
+     WId mWindowId;
+-    bool mWaitingForFrameCallback = false;
+     bool mFrameCallbackTimedOut = false; // Whether the frame callback has timed out
+-    bool mWaitingForUpdateDelivery = false;
+     int mFrameCallbackCheckIntervalTimerId = -1;
+-    QElapsedTimer mFrameCallbackElapsedTimer;
+-    struct ::wl_callback *mFrameCallback = nullptr;
+-    QWaylandDisplay::FrameQueue mFrameQueue;
++    QAtomicInt mWaitingForUpdateDelivery = false;
++
++    bool mWaitingForFrameCallback = false; // Protected by mFrameSyncMutex
++    QElapsedTimer mFrameCallbackElapsedTimer; // Protected by mFrameSyncMutex
++    struct ::wl_callback *mFrameCallback = nullptr; // Protected by mFrameSyncMutex
++    QMutex mFrameSyncMutex;
+     QWaitCondition mFrameSyncWait;
+ 
+     // True when we have called deliverRequestUpdate, but the client has not yet attached a new buffer
+@@ -261,6 +274,8 @@ protected:
+     QWaylandBuffer *mQueuedBuffer = nullptr;
+     QRegion mQueuedBufferDamage;
+ 
++    QList<QPointer<QWaylandWindow>> mChildPopups;
++
+ private:
+     void setGeometry_helper(const QRect &rect);
+     void initWindow();
+@@ -283,12 +298,10 @@ private:
+     QRect mLastExposeGeometry;
+ 
+     static const wl_callback_listener callbackListener;
+-    void handleFrameCallback();
++    void handleFrameCallback(struct ::wl_callback* callback);
+ 
+     static QWaylandWindow *mMouseGrab;
+ 
+-    mutable QReadWriteLock mSurfaceLock;
+-
+     friend class QWaylandSubSurface;
+ };
+ 
+diff --git a/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h b/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
+index ccad0048..4cc9b3b8 100644
+--- a/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
++++ b/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
+@@ -73,11 +73,10 @@ public:
+         return true;
+     }
+     virtual QWaylandShellSurface *createShellSurface(QWaylandWindow *window) = 0;
++    // kept for binary compat with layer-shell-qt
+     virtual void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) {
+-        if (newFocus)
+-            m_display->handleWindowActivated(newFocus);
+-        if (oldFocus)
+-            m_display->handleWindowDeactivated(oldFocus);
++        Q_UNUSED(newFocus);
++        Q_UNUSED(oldFocus);
+     }
+     virtual void *nativeResourceForWindow(const QByteArray &resource, QWindow *window) {
+         Q_UNUSED(resource);
+diff --git a/qtwayland/src/compositor/configure.json b/qtwayland/src/compositor/configure.json
+index bcfd5215..da95d07b 100644
+--- a/qtwayland/src/compositor/configure.json
++++ b/qtwayland/src/compositor/configure.json
+@@ -7,6 +7,31 @@
+     "testDir": "../../config.tests",
+ 
+     "libraries": {
++        "wayland-client": {
++            "label": "Wayland client library",
++            "headers": "wayland-version.h",
++            "test": {
++                "main": [
++                    "#if WAYLAND_VERSION_MAJOR < 1",
++                    "# error Wayland 1.8.0 or higher required",
++                    "#endif",
++                    "#if WAYLAND_VERSION_MAJOR == 1",
++                    "# if WAYLAND_VERSION_MINOR < 8",
++                    "#  error Wayland 1.8.0 or higher required",
++                    "# endif",
++                    "# if WAYLAND_VERSION_MINOR == 8",
++                    "#  if WAYLAND_VERSION_MICRO < 0",
++                    "#   error Wayland 1.8.0 or higher required",
++                    "#  endif",
++                    "# endif",
++                    "#endif"
++                 ]
++            },
++            "sources": [
++                { "type": "pkgConfig", "args": "wayland-client" },
++                "-lwayland-client"
++            ]
++        },
+         "wayland-server": {
+             "label": "wayland-server",
+             "headers": "wayland-version.h",
+@@ -151,8 +176,7 @@
+                     "#endif"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "dmabuf-client-buffer": {
+             "label": "Linux Client dma-buf Buffer Sharing",
+@@ -176,8 +200,7 @@
+                     "return 0;"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "vulkan-server-buffer": {
+             "label": "Vulkan Buffer Sharing",
+@@ -195,7 +218,8 @@
+                     "exportAllocInfo.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR;",
+                     "return 0;"
+                 ]
+-            }
++            },
++            "use": "wayland-client"
+         }
+     },
+ 
+diff --git a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
+index 7889f575..64140672 100644
+--- a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
++++ b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
+@@ -40,6 +40,7 @@
+ #include "qwaylandeglwindow.h"
+ 
+ #include <QtWaylandClient/private/qwaylandscreen_p.h>
++#include <QtWaylandClient/private/qwaylandsurface_p.h>
+ #include "qwaylandglcontext.h"
+ 
+ #include <QtEglSupport/private/qeglconvenience_p.h>
+@@ -124,6 +125,7 @@ void QWaylandEglWindow::updateSurface(bool create)
+         }
+         mOffset = QPoint();
+     } else {
++        QReadLocker locker(&mSurfaceLock);
+         if (m_waylandEglWindow) {
+             int current_width, current_height;
+             static bool disableResizeCheck = qgetenv("QT_WAYLAND_DISABLE_RESIZECHECK").toInt();
+@@ -131,14 +133,16 @@ void QWaylandEglWindow::updateSurface(bool create)
+             if (!disableResizeCheck) {
+                 wl_egl_window_get_attached_size(m_waylandEglWindow, &current_width, &current_height);
+             }
+-            if (disableResizeCheck || (current_width != sizeWithMargins.width() || current_height != sizeWithMargins.height())) {
++            if (disableResizeCheck || (current_width != sizeWithMargins.width() || current_height != sizeWithMargins.height()) || m_requestedSize != sizeWithMargins) {
+                 wl_egl_window_resize(m_waylandEglWindow, sizeWithMargins.width(), sizeWithMargins.height(), mOffset.x(), mOffset.y());
++                m_requestedSize = sizeWithMargins;
+                 mOffset = QPoint();
+ 
+                 m_resize = true;
+             }
+-        } else if (create && wlSurface()) {
+-            m_waylandEglWindow = wl_egl_window_create(wlSurface(), sizeWithMargins.width(), sizeWithMargins.height());
++        } else if (create && mSurface) {
++            m_waylandEglWindow = wl_egl_window_create(mSurface->object(), sizeWithMargins.width(), sizeWithMargins.height());
++            m_requestedSize = sizeWithMargins;
+         }
+ 
+         if (!m_eglSurface && m_waylandEglWindow && create) {
+diff --git a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
+index 5b1f4d56..0079dfef 100644
+--- a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
++++ b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
+@@ -88,6 +88,7 @@ private:
+     mutable QOpenGLFramebufferObject *m_contentFBO = nullptr;
+ 
+     QSurfaceFormat m_format;
++    QSize m_requestedSize;
+ };
+ 
+ }
+diff --git a/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h b/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
+index 56a710c3..c6a8b6c6 100644
+--- a/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
++++ b/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
+@@ -41,6 +41,8 @@
+ #include <QtCore/QTextStream>
+ #include <QtGui/QOpenGLTexture>
+ 
++#include <array>
++
+ #include <EGL/egl.h>
+ #include <EGL/eglext.h>
+ 
+diff --git a/qtwayland/src/plugins/decorations/bradient/main.cpp b/qtwayland/src/plugins/decorations/bradient/main.cpp
+index e75fda3c..fa885143 100644
+--- a/qtwayland/src/plugins/decorations/bradient/main.cpp
++++ b/qtwayland/src/plugins/decorations/bradient/main.cpp
+@@ -164,13 +164,10 @@ void QWaylandBradientDecoration::paint(QPaintDevice *device)
+     // Window icon
+     QIcon icon = waylandWindow()->windowIcon();
+     if (!icon.isNull()) {
+-        QPixmap pixmap = icon.pixmap(QSize(128, 128));
+-        QPixmap scaled = pixmap.scaled(22, 22, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+-
+         QRectF iconRect(0, 0, 22, 22);
+-        p.drawPixmap(iconRect.adjusted(margins().left() + BUTTON_SPACING, 4,
+-                                       margins().left() + BUTTON_SPACING, 4),
+-                     scaled, iconRect);
++        iconRect.adjust(margins().left() + BUTTON_SPACING, 4,
++                        margins().left() + BUTTON_SPACING, 4),
++        icon.paint(&p, iconRect.toRect());
+     }
+ 
+     // Window title
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
+index 85d25e3c..60bdd491 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
+@@ -47,18 +47,21 @@ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
+-QWaylandXdgPopupV5::QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow *window)
++QWaylandXdgPopupV5::QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow* parent, QWaylandWindow *window)
+     : QWaylandShellSurface(window)
+     , QtWayland::xdg_popup_v5(popup)
++    , m_parent(parent)
+     , m_window(window)
+ {
+     if (window->display()->windowExtension())
+         m_extendedWindow = new QWaylandExtendedSurface(window);
++    m_parent->addChildPopup(m_window);
+ }
+ 
+ QWaylandXdgPopupV5::~QWaylandXdgPopupV5()
+ {
+     xdg_popup_destroy(object());
++    m_parent->removeChildPopup(m_window);
+     delete m_extendedWindow;
+ }
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
+index 7494f6a6..d85f130b 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
+@@ -70,7 +70,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgPopupV5 : public QWaylandShellSurface
+ {
+     Q_OBJECT
+ public:
+-    QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow *window);
++    QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow* parent, QWaylandWindow *window);
+     ~QWaylandXdgPopupV5() override;
+ 
+ protected:
+@@ -78,6 +78,7 @@ protected:
+ 
+ private:
+     QWaylandExtendedSurface *m_extendedWindow = nullptr;
++    QWaylandWindow *m_parent = nullptr;
+     QWaylandWindow *m_window = nullptr;
+ };
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
+index 7e242c4a..def8452a 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
+@@ -84,7 +84,7 @@ QWaylandXdgPopupV5 *QWaylandXdgShellV5::createXdgPopup(QWaylandWindow *window, Q
+     int x = position.x() + parentWindow->frameMargins().left();
+     int y = position.y() + parentWindow->frameMargins().top();
+ 
+-    auto popup = new QWaylandXdgPopupV5(get_xdg_popup(window->wlSurface(), parentSurface, seat, m_popupSerial, x, y), window);
++    auto popup = new QWaylandXdgPopupV5(get_xdg_popup(window->wlSurface(), parentSurface, seat, m_popupSerial, x, y), parentWindow, window);
+     m_popups.append(window);
+     QObject::connect(popup, &QWaylandXdgPopupV5::destroyed, [this, window](){
+         m_popups.removeOne(window);
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
+index 4e25949f..cfc60939 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
+@@ -85,13 +85,6 @@ QWaylandShellSurface *QWaylandXdgShellV5Integration::createShellSurface(QWayland
+     return m_xdgShell->createXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellV5Integration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) {
+-    if (newFocus && qobject_cast<QWaylandXdgPopupV5 *>(newFocus->shellSurface()))
+-        m_display->handleWindowActivated(newFocus);
+-    if (oldFocus && qobject_cast<QWaylandXdgPopupV5 *>(oldFocus->shellSurface()))
+-        m_display->handleWindowDeactivated(oldFocus);
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
+index ce6bdb9e..aed88670 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
+@@ -67,7 +67,6 @@ public:
+     QWaylandXdgShellV5Integration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShellV5> m_xdgShell;
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
+index 8c371661..151c78e3 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
+@@ -174,6 +174,7 @@ QWaylandXdgSurfaceV6::Popup::Popup(QWaylandXdgSurfaceV6 *xdgSurface, QWaylandXdg
+     , m_xdgSurface(xdgSurface)
+     , m_parent(parent)
+ {
++    m_parent->window()->addChildPopup(m_xdgSurface->window());
+ }
+ 
+ QWaylandXdgSurfaceV6::Popup::~Popup()
+@@ -181,6 +182,8 @@ QWaylandXdgSurfaceV6::Popup::~Popup()
+     if (isInitialized())
+         destroy();
+ 
++    m_parent->window()->removeChildPopup(m_xdgSurface->window());
++
+     if (m_grabbing) {
+         auto *shell = m_xdgSurface->m_shell;
+         Q_ASSERT(shell->m_topmostGrabbingPopup == this);
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
+index 03164316..e8da8ba1 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
+@@ -68,20 +68,6 @@ QWaylandShellSurface *QWaylandXdgShellV6Integration::createShellSurface(QWayland
+     return m_xdgShell->getXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellV6Integration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus)
+-{
+-    if (newFocus) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurfaceV6 *>(newFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowActivated(newFocus);
+-    }
+-    if (oldFocus && qobject_cast<QWaylandXdgSurfaceV6 *>(oldFocus->shellSurface())) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurfaceV6 *>(oldFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowDeactivated(oldFocus);
+-    }
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
+index 261f8cbb..c1bcd5c6 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
+@@ -65,7 +65,6 @@ public:
+     QWaylandXdgShellV6Integration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShellV6> m_xdgShell;
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
+index f3e3c330..fa6d5808 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
+@@ -67,11 +67,6 @@ QWaylandXdgSurface::Toplevel::Toplevel(QWaylandXdgSurface *xdgSurface)
+ 
+ QWaylandXdgSurface::Toplevel::~Toplevel()
+ {
+-    if (m_applied.states & Qt::WindowActive) {
+-        QWaylandWindow *window = m_xdgSurface->window();
+-        window->display()->handleWindowDeactivated(window);
+-    }
+-
+     // The protocol spec requires that the decoration object is deleted before xdg_toplevel.
+     delete m_decoration;
+     m_decoration = nullptr;
+@@ -85,16 +80,15 @@ void QWaylandXdgSurface::Toplevel::applyConfigure()
+     if (!(m_applied.states & (Qt::WindowMaximized|Qt::WindowFullScreen)))
+         m_normalSize = m_xdgSurface->m_window->windowFrameGeometry().size();
+ 
+-    if ((m_pending.states & Qt::WindowActive) && !(m_applied.states & Qt::WindowActive))
++    if ((m_pending.states & Qt::WindowActive) && !(m_applied.states & Qt::WindowActive)
++        && !m_xdgSurface->m_window->display()->isKeyboardAvailable())
+         m_xdgSurface->m_window->display()->handleWindowActivated(m_xdgSurface->m_window);
+ 
+-    if (!(m_pending.states & Qt::WindowActive) && (m_applied.states & Qt::WindowActive))
++    if (!(m_pending.states & Qt::WindowActive) && (m_applied.states & Qt::WindowActive)
++        && !m_xdgSurface->m_window->display()->isKeyboardAvailable())
+         m_xdgSurface->m_window->display()->handleWindowDeactivated(m_xdgSurface->m_window);
+ 
+-    // TODO: none of the other plugins send WindowActive either, but is it on purpose?
+-    Qt::WindowStates statesWithoutActive = m_pending.states & ~Qt::WindowActive;
+-
+-    m_xdgSurface->m_window->handleWindowStatesChanged(statesWithoutActive);
++    m_xdgSurface->m_window->handleWindowStatesChanged(m_pending.states);
+ 
+     if (m_pending.size.isEmpty()) {
+         // An empty size in the configure means it's up to the client to choose the size
+@@ -105,8 +99,6 @@ void QWaylandXdgSurface::Toplevel::applyConfigure()
+         m_xdgSurface->m_window->resizeFromApplyConfigure(m_pending.size);
+     }
+ 
+-    m_xdgSurface->setSizeHints();
+-
+     m_applied = m_pending;
+     qCDebug(lcQpaWayland) << "Applied pending xdg_toplevel configure event:" << m_applied.size << m_applied.states;
+ }
+@@ -203,12 +195,17 @@ QtWayland::xdg_toplevel::resize_edge QWaylandXdgSurface::Toplevel::convertToResi
+                 | ((edges & Qt::RightEdge) ? resize_edge_right : 0));
+ }
+ 
+-QWaylandXdgSurface::Popup::Popup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parent,
++QWaylandXdgSurface::Popup::Popup(QWaylandXdgSurface *xdgSurface, QWaylandWindow *parent,
+                                  QtWayland::xdg_positioner *positioner)
+-    : xdg_popup(xdgSurface->get_popup(parent->object(), positioner->object()))
+-    , m_xdgSurface(xdgSurface)
++    : m_xdgSurface(xdgSurface)
++    , m_parentXdgSurface(qobject_cast<QWaylandXdgSurface *>(parent->shellSurface()))
+     , m_parent(parent)
+ {
++
++    init(xdgSurface->get_popup(m_parentXdgSurface ? m_parentXdgSurface->object() : nullptr, positioner->object()));
++    if (m_parent) {
++        m_parent->addChildPopup(m_xdgSurface->window());
++    }
+ }
+ 
+ QWaylandXdgSurface::Popup::~Popup()
+@@ -216,10 +213,24 @@ QWaylandXdgSurface::Popup::~Popup()
+     if (isInitialized())
+         destroy();
+ 
++    if (m_parent) {
++        m_parent->removeChildPopup(m_xdgSurface->window());
++    }
++
+     if (m_grabbing) {
+         auto *shell = m_xdgSurface->m_shell;
+         Q_ASSERT(shell->m_topmostGrabbingPopup == this);
+-        shell->m_topmostGrabbingPopup = m_parent->m_popup;
++        shell->m_topmostGrabbingPopup = m_parentXdgSurface ? m_parentXdgSurface->m_popup : nullptr;
++        m_grabbing = false;
++
++        // Synthesize Qt enter/leave events for popup
++        QWindow *leave = nullptr;
++        if (m_xdgSurface && m_xdgSurface->window())
++            leave = m_xdgSurface->window()->window();
++        QWindowSystemInterface::handleLeaveEvent(leave);
++
++        if (QWindow *enter = QGuiApplication::topLevelAt(QCursor::pos()))
++            QWindowSystemInterface::handleEnterEvent(enter, enter->mapFromGlobal(QCursor::pos()), QCursor::pos());
+     }
+ }
+ 
+@@ -257,6 +268,7 @@ QWaylandXdgSurface::QWaylandXdgSurface(QWaylandXdgShell *shell, ::xdg_surface *s
+                 m_toplevel->set_parent(parentXdgSurface->m_toplevel->object());
+         }
+     }
++    setSizeHints();
+ }
+ 
+ QWaylandXdgSurface::~QWaylandXdgSurface()
+@@ -400,8 +412,6 @@ void QWaylandXdgSurface::setPopup(QWaylandWindow *parent)
+ {
+     Q_ASSERT(!m_toplevel && !m_popup);
+ 
+-    auto parentXdgSurface = static_cast<QWaylandXdgSurface *>(parent->shellSurface());
+-
+     auto positioner = new QtWayland::xdg_positioner(m_shell->create_positioner());
+     // set_popup expects a position relative to the parent
+     QPoint transientPos = m_window->geometry().topLeft(); // this is absolute
+@@ -414,8 +424,9 @@ void QWaylandXdgSurface::setPopup(QWaylandWindow *parent)
+     positioner->set_anchor(QtWayland::xdg_positioner::anchor_top_left);
+     positioner->set_gravity(QtWayland::xdg_positioner::gravity_bottom_right);
+     positioner->set_size(m_window->geometry().width(), m_window->geometry().height());
+-    m_popup = new Popup(this, parentXdgSurface, positioner);
++    m_popup = new Popup(this, parent, positioner);
+     positioner->destroy();
++
+     delete positioner;
+ }
+ 
+@@ -437,6 +448,23 @@ void QWaylandXdgSurface::setGrabPopup(QWaylandWindow *parent, QWaylandInputDevic
+     }
+     setPopup(parent);
+     m_popup->grab(device, serial);
++
++    // Synthesize Qt enter/leave events for popup
++    if (!parent)
++        return;
++    QWindow *current = QGuiApplication::topLevelAt(QCursor::pos());
++    QWindow *leave = parent->window();
++    if (current != leave)
++        return;
++
++    QWindowSystemInterface::handleLeaveEvent(leave);
++
++    QWindow *enter = nullptr;
++    if (m_popup && m_popup->m_xdgSurface && m_popup->m_xdgSurface->window())
++        enter = m_popup->m_xdgSurface->window()->window();
++
++    if (enter)
++        QWindowSystemInterface::handleEnterEvent(enter, enter->mapFromGlobal(QCursor::pos()), QCursor::pos());
+ }
+ 
+ void QWaylandXdgSurface::xdg_surface_configure(uint32_t serial)
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
+index 96785205..4b518f0a 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
+@@ -131,14 +131,15 @@ private:
+ 
+     class Popup : public QtWayland::xdg_popup {
+     public:
+-        Popup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parent, QtWayland::xdg_positioner *positioner);
++        Popup(QWaylandXdgSurface *xdgSurface, QWaylandWindow *parent, QtWayland::xdg_positioner *positioner);
+         ~Popup() override;
+ 
+         void grab(QWaylandInputDevice *seat, uint serial);
+         void xdg_popup_popup_done() override;
+ 
+         QWaylandXdgSurface *m_xdgSurface = nullptr;
+-        QWaylandXdgSurface *m_parent = nullptr;
++        QWaylandXdgSurface *m_parentXdgSurface = nullptr;
++        QWaylandWindow *m_parent = nullptr;
+         bool m_grabbing = false;
+     };
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
+index 8769d971..da0dd6a7 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
+@@ -69,20 +69,6 @@ QWaylandShellSurface *QWaylandXdgShellIntegration::createShellSurface(QWaylandWi
+     return m_xdgShell->getXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellIntegration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus)
+-{
+-    if (newFocus) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurface *>(newFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowActivated(newFocus);
+-    }
+-    if (oldFocus && qobject_cast<QWaylandXdgSurface *>(oldFocus->shellSurface())) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurface *>(oldFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowDeactivated(oldFocus);
+-    }
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
+index b6caa6c9..2f929f98 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
+@@ -65,7 +65,6 @@ public:
+     QWaylandXdgShellIntegration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShell> m_xdgShell;
+diff --git a/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp b/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
+index 526d0ef4..f50ccf30 100644
+--- a/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
++++ b/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
+@@ -39,7 +39,10 @@
+ 
+ #include "qwaylandinputmethodeventbuilder_p.h"
+ 
++#include <QBrush>
++#include <QGuiApplication>
+ #include <QInputMethod>
++#include <QPalette>
+ #include <QTextCharFormat>
+ 
+ #ifdef QT_BUILD_WAYLANDCOMPOSITOR_LIB
+@@ -81,32 +84,38 @@ void QWaylandInputMethodEventBuilder::addPreeditStyling(uint32_t index, uint32_t
+     QTextCharFormat format;
+ 
+     switch (style) {
+-    case 0:
+-    case 1:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_NONE:
++        break;
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_DEFAULT:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_UNDERLINE:
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-    case 2:
+-    case 3:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_ACTIVE:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_INACTIVE:
+         format.setFontWeight(QFont::Bold);
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-    case 4:
+-        format.setFontUnderline(true);
+-        format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+-        m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_HIGHLIGHT:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_SELECTION:
++        {
++            format.setFontUnderline(true);
++            format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
++            QPalette palette = qApp->palette();
++            format.setBackground(QBrush(palette.color(QPalette::Active, QPalette::Highlight)));
++            format.setForeground(QBrush(palette.color(QPalette::Active, QPalette::HighlightedText)));
++            m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
++        }
+         break;
+-    case 5:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_INCORRECT:
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::WaveUnderline);
+         format.setUnderlineColor(QColor(Qt::red));
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-//    case QtWayland::wl_text_input::preedit_style_selection:
+-//    case QtWayland::wl_text_input::preedit_style_none:
+     default:
+         break;
+     }
+@@ -153,7 +162,7 @@ QInputMethodEvent QWaylandInputMethodEventBuilder::buildPreedit(const QString &t
+ 
+     if (m_preeditCursor < 0) {
+         attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, 0, QVariant()));
+-    } else if (m_preeditCursor > 0) {
++    } else {
+         attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, indexFromWayland(text, m_preeditCursor), 1, QVariant()));
+     }
+ 
+diff --git a/qtwayland/src/shared/qwaylandmimehelper.cpp b/qtwayland/src/shared/qwaylandmimehelper.cpp
+index a5fdd34d..e2fe1928 100644
+--- a/qtwayland/src/shared/qwaylandmimehelper.cpp
++++ b/qtwayland/src/shared/qwaylandmimehelper.cpp
+@@ -60,7 +60,7 @@ QByteArray QWaylandMimeHelper::getByteArray(QMimeData *mimeData, const QString &
+             buf.open(QIODevice::ReadWrite);
+             QByteArray fmt = "BMP";
+             if (mimeType.startsWith(QLatin1String("image/"))) {
+-                QByteArray imgFmt = mimeType.mid(6).toUpper().toLatin1();
++                QByteArray imgFmt = mimeType.mid(6).toLower().toLatin1();
+                 if (QImageWriter::supportedImageFormats().contains(imgFmt))
+                     fmt = imgFmt;
+             }
+@@ -74,7 +74,7 @@ QByteArray QWaylandMimeHelper::getByteArray(QMimeData *mimeData, const QString &
+         QList<QUrl> urls = mimeData->urls();
+         for (int i = 0; i < urls.count(); ++i) {
+             content.append(urls.at(i).toEncoded());
+-            content.append('\n');
++            content.append("\r\n");
+         }
+     } else {
+         content = mimeData->data(mimeType);
+diff --git a/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp b/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
+index 1568b3b9..067410d0 100644
+--- a/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
++++ b/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
+@@ -35,7 +35,7 @@
+ 
+ using namespace MockCompositor;
+ 
+-constexpr int dataDeviceVersion = 1;
++constexpr int dataDeviceVersion = 3;
+ 
+ class DataDeviceCompositor : public DefaultCompositor {
+ public:
+diff --git a/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp b/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
+index 9312c2e5..2ea382f1 100644
+--- a/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
++++ b/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
+@@ -73,6 +73,7 @@ private slots:
+     void multiTouch();
+     void multiTouchUpAndMotionFrame();
+     void tapAndMoveInSameFrame();
++    void cancelTouch();
+ };
+ 
+ void tst_seatv5::bindsToSeat()
+@@ -646,5 +647,34 @@ void tst_seatv5::tapAndMoveInSameFrame()
+     QTRY_COMPARE(window.m_events.last().touchPoints.first().state(), Qt::TouchPointState::TouchPointReleased);
+ }
+ 
++void tst_seatv5::cancelTouch()
++{
++    TouchWindow window;
++    QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
++
++    exec([=] {
++        auto *t = touch();
++        auto *c = client();
++        t->sendDown(xdgToplevel()->surface(), {32, 32}, 1);
++        t->sendFrame(c);
++        t->sendCancel(c);
++        t->sendFrame(c);
++    });
++
++    QTRY_VERIFY(!window.m_events.empty());
++    {
++        auto e = window.m_events.takeFirst();
++        QCOMPARE(e.type, QEvent::TouchBegin);
++        QCOMPARE(e.touchPointStates, Qt::TouchPointPressed);
++        QCOMPARE(e.touchPoints.length(), 1);
++        QCOMPARE(e.touchPoints.first().pos(), QPointF(32-window.frameMargins().left(), 32-window.frameMargins().top()));
++    }
++    {
++        auto e = window.m_events.takeFirst();
++        QCOMPARE(e.type, QEvent::TouchCancel);
++        QCOMPARE(e.touchPoints.length(), 0);
++    }
++}
++
+ QCOMPOSITOR_TEST_MAIN(tst_seatv5)
+ #include "tst_seatv5.moc"
+diff --git a/qtwayland/tests/auto/client/shared/corecompositor.cpp b/qtwayland/tests/auto/client/shared/corecompositor.cpp
+index 5c6c83ba..fa9b7662 100644
+--- a/qtwayland/tests/auto/client/shared/corecompositor.cpp
++++ b/qtwayland/tests/auto/client/shared/corecompositor.cpp
+@@ -27,6 +27,7 @@
+ ****************************************************************************/
+ 
+ #include "corecompositor.h"
++#include <thread>
+ 
+ namespace MockCompositor {
+ 
+diff --git a/qtwayland/tests/auto/client/shared/coreprotocol.cpp b/qtwayland/tests/auto/client/shared/coreprotocol.cpp
+index 0d988521..d1a2e7cb 100644
+--- a/qtwayland/tests/auto/client/shared/coreprotocol.cpp
++++ b/qtwayland/tests/auto/client/shared/coreprotocol.cpp
+@@ -451,6 +451,13 @@ void Touch::sendFrame(wl_client *client)
+         send_frame(r->handle);
+ }
+ 
++void Touch::sendCancel(wl_client *client)
++{
++    const auto touchResources = resourceMap().values(client);
++    for (auto *r : touchResources)
++        send_cancel(r->handle);
++}
++
+ uint Keyboard::sendEnter(Surface *surface)
+ {
+     auto serial = m_seat->m_compositor->nextSerial();
+diff --git a/qtwayland/tests/auto/client/shared/coreprotocol.h b/qtwayland/tests/auto/client/shared/coreprotocol.h
+index a1af137a..210d8ddb 100644
+--- a/qtwayland/tests/auto/client/shared/coreprotocol.h
++++ b/qtwayland/tests/auto/client/shared/coreprotocol.h
+@@ -158,7 +158,7 @@ class WlCompositor : public Global, public QtWaylandServer::wl_compositor
+ {
+     Q_OBJECT
+ public:
+-    explicit WlCompositor(CoreCompositor *compositor, int version = 3)
++    explicit WlCompositor(CoreCompositor *compositor, int version = 4)
+         : QtWaylandServer::wl_compositor(compositor->m_display, version)
+         , m_compositor(compositor)
+     {}
+@@ -364,6 +364,7 @@ public:
+     uint sendUp(wl_client *client, int id);
+     void sendMotion(wl_client *client, const QPointF &position, int id);
+     void sendFrame(wl_client *client);
++    void sendCancel(wl_client *client);
+ 
+     Seat *m_seat = nullptr;
+ };
+diff --git a/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp b/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
+index a415cbf5..b1d3d07d 100644
+--- a/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
++++ b/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
+@@ -342,7 +342,7 @@ Compositor::Compositor(MockCompositor *mockCompositor)
+         exit(EXIT_FAILURE);
+     }
+ 
+-    wl_global_create(m_display, &wl_compositor_interface, 1, this, bindCompositor);
++    wl_global_create(m_display, &wl_compositor_interface, 4, this, bindCompositor);
+ 
+     m_data_device_manager.reset(new DataDeviceManager(this, m_display));
+ 
+diff --git a/qtwayland/tests/auto/client/shared_old/mocksurface.cpp b/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
+index e9df5f90..c3246e4a 100644
+--- a/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
++++ b/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
+@@ -125,6 +125,16 @@ void Surface::surface_damage(Resource *resource,
+     Q_UNUSED(height);
+ }
+ 
++void Surface::surface_damage_buffer(Resource *resource,
++                                    int32_t x, int32_t y, int32_t width, int32_t height)
++{
++    Q_UNUSED(resource);
++    Q_UNUSED(x);
++    Q_UNUSED(y);
++    Q_UNUSED(width);
++    Q_UNUSED(height);
++}
++
+ void Surface::surface_frame(Resource *resource,
+                             uint32_t callback)
+ {
+diff --git a/qtwayland/tests/auto/client/shared_old/mocksurface.h b/qtwayland/tests/auto/client/shared_old/mocksurface.h
+index 949dc23d..d176837e 100644
+--- a/qtwayland/tests/auto/client/shared_old/mocksurface.h
++++ b/qtwayland/tests/auto/client/shared_old/mocksurface.h
+@@ -65,6 +65,8 @@ protected:
+                         struct wl_resource *buffer, int x, int y) override;
+     void surface_damage(Resource *resource,
+                         int32_t x, int32_t y, int32_t width, int32_t height) override;
++    void surface_damage_buffer(Resource *resource,
++                               int32_t x, int32_t y, int32_t width, int32_t height) override;
+     void surface_frame(Resource *resource,
+                        uint32_t callback) override;
+     void surface_commit(Resource *resource) override;
+diff --git a/qtwayland/tests/auto/client/surface/tst_surface.cpp b/qtwayland/tests/auto/client/surface/tst_surface.cpp
+index 95e4e609..60c672ce 100644
+--- a/qtwayland/tests/auto/client/surface/tst_surface.cpp
++++ b/qtwayland/tests/auto/client/surface/tst_surface.cpp
+@@ -129,6 +129,10 @@ void tst_surface::waitForFrameCallbackGl()
+     // Make sure we follow frame callbacks for some frames
+     for (int i = 0; i < 5; ++i) {
+         xdgPingAndWaitForPong(); // Make sure things have happened on the client
++        if (!qEnvironmentVariableIntValue("QT_WAYLAND_DISABLE_WINDOWDECORATION") && i == 0) {
++            QCOMPARE(bufferSpy.count(), 1);
++            bufferSpy.removeFirst();
++        }
+         exec([&] {
+             QVERIFY(bufferSpy.empty()); // Make sure no extra buffers have arrived
+             QVERIFY(!xdgToplevel()->surface()->m_waitingFrameCallbacks.empty());
+diff --git a/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp b/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
+index 2277bbb8..747875b4 100644
+--- a/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
++++ b/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
+@@ -31,6 +31,7 @@
+ #include <QtGui/QOpenGLWindow>
+ #include <QtGui/qpa/qplatformnativeinterface.h>
+ #include <QtWaylandClient/private/wayland-wayland-client-protocol.h>
++#include <QtWaylandClient/private/qwaylandwindow_p.h>
+ 
+ using namespace MockCompositor;
+ 
+@@ -45,6 +46,7 @@ private slots:
+     void configureStates();
+     void popup();
+     void tooltipOnPopup();
++    void tooltipAndSiblingPopup();
+     void switchPopups();
+     void hidePopupParent();
+     void pongs();
+@@ -138,6 +140,7 @@ void tst_xdgshell::configureSize()
+ 
+ void tst_xdgshell::configureStates()
+ {
++    QVERIFY(qputenv("QT_WAYLAND_FRAME_CALLBACK_TIMEOUT", "0"));
+     QRasterWindow window;
+     window.resize(64, 48);
+     window.show();
+@@ -154,9 +157,12 @@ void tst_xdgshell::configureStates()
+     // Toplevel windows don't know their position on xdg-shell
+ //    QCOMPARE(window.frameGeometry().topLeft(), QPoint()); // TODO: this doesn't currently work when window decorations are enabled
+ 
+-//    QEXPECT_FAIL("", "configure has already been acked, we shouldn't have to wait for isActive", Continue);
+-//    QVERIFY(window.isActive());
+-    QTRY_VERIFY(window.isActive()); // Just make sure it eventually get's set correctly
++    // window.windowstate() is driven by keyboard focus, however for decorations we want to follow
++    // XDGShell this is internal to QtWayland so it is queried directly
++    auto waylandWindow = static_cast<QtWaylandClient::QWaylandWindow *>(window.handle());
++    Q_ASSERT(waylandWindow);
++    QTRY_VERIFY(waylandWindow->windowStates().testFlag(
++            Qt::WindowActive)); // Just make sure it eventually get's set correctly
+ 
+     const QSize screenSize(640, 480);
+     const uint maximizedSerial = exec([=] {
+@@ -186,6 +192,7 @@ void tst_xdgshell::configureStates()
+     QCOMPARE(window.windowStates(), Qt::WindowNoState);
+     QCOMPARE(window.frameGeometry().size(), windowedSize);
+ //    QCOMPARE(window.frameGeometry().topLeft(), QPoint()); // TODO: this doesn't currently work when window decorations are enabled
++    QVERIFY(qunsetenv("QT_WAYLAND_FRAME_CALLBACK_TIMEOUT"));
+ }
+ 
+ void tst_xdgshell::popup()
+@@ -340,6 +347,92 @@ void tst_xdgshell::tooltipOnPopup()
+     QCOMPOSITOR_TRY_COMPARE(xdgPopup(0), nullptr);
+ }
+ 
++void tst_xdgshell::tooltipAndSiblingPopup()
++{
++    class ToolTip : public QRasterWindow {
++    public:
++        explicit ToolTip(QWindow *parent) {
++            setTransientParent(parent);
++            setFlags(Qt::ToolTip);
++            resize(100, 100);
++            show();
++        }
++        void mousePressEvent(QMouseEvent *event) override {
++            QRasterWindow::mousePressEvent(event);
++            m_popup = new QRasterWindow;
++            m_popup->setTransientParent(transientParent());
++            m_popup->setFlags(Qt::Popup);
++            m_popup->resize(100, 100);
++            m_popup->show();
++        }
++
++        QRasterWindow *m_popup = nullptr;
++    };
++
++    class Window : public QRasterWindow {
++    public:
++        void mousePressEvent(QMouseEvent *event) override {
++            QRasterWindow::mousePressEvent(event);
++            m_tooltip = new ToolTip(this);
++        }
++        ToolTip *m_tooltip = nullptr;
++    };
++
++    Window window;
++    window.resize(200, 200);
++    window.show();
++
++    QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
++    exec([=] { xdgToplevel()->sendCompleteConfigure(); });
++    QCOMPOSITOR_TRY_VERIFY(xdgToplevel()->m_xdgSurface->m_committedConfigureSerial);
++
++    exec([=] {
++        auto *surface = xdgToplevel()->surface();
++        auto *p = pointer();
++        auto *c = client();
++        p->sendEnter(surface, {100, 100});
++        p->sendFrame(c);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_pressed);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_released);
++        p->sendFrame(c);
++        p->sendLeave(surface);
++        p->sendFrame(c);
++    });
++
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup());
++    exec([=] { xdgPopup()->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup()->m_xdgSurface->m_committedConfigureSerial);
++    QCOMPOSITOR_TRY_VERIFY(!xdgPopup()->m_grabbed);
++
++    exec([=] {
++        auto *surface = xdgPopup()->surface();
++        auto *p = pointer();
++        auto *c = client();
++        p->sendEnter(surface, {100, 100});
++        p->sendFrame(c);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_pressed);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_released);
++        p->sendFrame(c);
++    });
++
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1));
++    exec([=] { xdgPopup(1)->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1)->m_xdgSurface->m_committedConfigureSerial);
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1)->m_grabbed);
++
++    // Close the middle tooltip (it should not close the sibling popup)
++    window.m_tooltip->close();
++
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(1), nullptr);
++    // Verify the remaining xdg surface is a grab popup..
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(0));
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(0)->m_grabbed);
++
++    window.m_tooltip->m_popup->close();
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(1), nullptr);
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(0), nullptr);
++}
++
+ // QTBUG-65680
+ void tst_xdgshell::switchPopups()
+ {
+@@ -505,7 +598,7 @@ void tst_xdgshell::minMaxSize()
+     window.show();
+     QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
+ 
+-    exec([=] { xdgToplevel()->sendCompleteConfigure(); });
++    // we don't roundtrip with our configuration the initial commit should be correct
+ 
+     QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.minSize, QSize(100, 100));
+     QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.maxSize, QSize(1000, 1000));
+Submodule qtwebchannel 618422ee..f8949655:
+diff --git a/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp b/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
+index 536eb5c..898d769 100644
+--- a/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
++++ b/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
+@@ -186,8 +186,6 @@ Q_DECLARE_TYPEINFO(OverloadResolutionCandidate, Q_MOVABLE_TYPE);
+ QMetaObjectPublisher::QMetaObjectPublisher(QWebChannel *webChannel)
+     : QObject(webChannel)
+     , webChannel(webChannel)
+-    , signalHandler(this)
+-    , clientIsIdle(false)
+     , blockUpdates(false)
+     , propertyUpdatesInitialized(false)
+ {
+@@ -301,17 +299,17 @@ QJsonObject QMetaObjectPublisher::classInfoForObject(const QObject *object, QWeb
+     return data;
+ }
+ 
+-void QMetaObjectPublisher::setClientIsIdle(bool isIdle)
++void QMetaObjectPublisher::setClientIsIdle(bool isIdle, QWebChannelAbstractTransport *transport)
+ {
+-    if (clientIsIdle == isIdle) {
+-        return;
+-    }
+-    clientIsIdle = isIdle;
+-    if (!isIdle && timer.isActive()) {
+-        timer.stop();
+-    } else if (isIdle && !timer.isActive()) {
+-        timer.start(PROPERTY_UPDATE_INTERVAL, this);
+-    }
++    transportState[transport].clientIsIdle = isIdle;
++    if (isIdle)
++        sendEnqueuedPropertyUpdates(transport);
++}
++
++bool QMetaObjectPublisher::isClientIdle(QWebChannelAbstractTransport *transport)
++{
++    auto found = transportState.find(transport);
++    return found != transportState.end() && found.value().clientIsIdle;
+ }
+ 
+ QJsonObject QMetaObjectPublisher::initializeClient(QWebChannelAbstractTransport *transport)
+@@ -333,6 +331,7 @@ QJsonObject QMetaObjectPublisher::initializeClient(QWebChannelAbstractTransport
+ 
+ void QMetaObjectPublisher::initializePropertyUpdates(const QObject *const object, const QJsonObject &objectInfo)
+ {
++    auto *signalHandler = signalHandlerFor(object);
+     foreach (const QJsonValue &propertyInfoVar, objectInfo[KEY_PROPERTIES].toArray()) {
+         const QJsonArray &propertyInfo = propertyInfoVar.toArray();
+         if (propertyInfo.size() < 2) {
+@@ -353,19 +352,19 @@ void QMetaObjectPublisher::initializePropertyUpdates(const QObject *const object
+ 
+         // Only connect for a property update once
+         if (connectedProperties.isEmpty()) {
+-            signalHandler.connectTo(object, signalIndex);
++            signalHandler->connectTo(object, signalIndex);
+         }
+ 
+         connectedProperties.insert(propertyIndex);
+     }
+ 
+     // also always connect to destroyed signal
+-    signalHandler.connectTo(object, s_destroyedSignalIndex);
++    signalHandler->connectTo(object, s_destroyedSignalIndex);
+ }
+ 
+ void QMetaObjectPublisher::sendPendingPropertyUpdates()
+ {
+-    if (blockUpdates || !clientIsIdle || pendingPropertyUpdates.isEmpty()) {
++    if (blockUpdates) {
+         return;
+     }
+ 
+@@ -415,18 +414,19 @@ void QMetaObjectPublisher::sendPendingPropertyUpdates()
+ 
+     // data does not contain specific updates
+     if (!data.isEmpty()) {
+-        setClientIsIdle(false);
+-
+         message[KEY_DATA] = data;
+-        broadcastMessage(message);
++        enqueueBroadcastMessage(message);
+     }
+ 
+     // send every property update which is not supposed to be broadcasted
+     const QHash<QWebChannelAbstractTransport*, QJsonArray>::const_iterator suend = specificUpdates.constEnd();
+     for (QHash<QWebChannelAbstractTransport*, QJsonArray>::const_iterator it = specificUpdates.constBegin(); it != suend; ++it) {
+         message[KEY_DATA] = it.value();
+-        it.key()->sendMessage(message);
++        enqueueMessage(message, it.key());
+     }
++
++    for (auto state = transportState.begin(); state != transportState.end(); ++state)
++        sendEnqueuedPropertyUpdates(state.key());
+ }
+ 
+ QVariant QMetaObjectPublisher::invokeMethod(QObject *const object, const QMetaMethod &method,
+@@ -572,7 +572,7 @@ void QMetaObjectPublisher::signalEmitted(const QObject *object, const int signal
+         }
+     } else {
+         pendingPropertyUpdates[object][signalIndex] = arguments;
+-        if (clientIsIdle && !blockUpdates && !timer.isActive()) {
++        if (!blockUpdates && !timer.isActive()) {
+             timer.start(PROPERTY_UPDATE_INTERVAL, this);
+         }
+     }
+@@ -590,7 +590,7 @@ void QMetaObjectPublisher::objectDestroyed(const QObject *object)
+     // only remove from handler when we initialized the property updates
+     // cf: https://bugreports.qt.io/browse/QTBUG-60250
+     if (propertyUpdatesInitialized) {
+-        signalHandler.remove(object);
++        signalHandlerFor(object)->remove(object);
+         signalToPropertyMap.remove(object);
+     }
+     pendingPropertyUpdates.remove(object);
+@@ -852,6 +852,52 @@ void QMetaObjectPublisher::broadcastMessage(const QJsonObject &message) const
+     }
+ }
+ 
++void QMetaObjectPublisher::enqueueBroadcastMessage(const QJsonObject &message)
++{
++    if (webChannel->d_func()->transports.isEmpty()) {
++        qWarning("QWebChannel is not connected to any transports, cannot send message: %s",
++                 QJsonDocument(message).toJson().constData());
++        return;
++    }
++
++    for (auto *transport : webChannel->d_func()->transports) {
++        auto &state = transportState[transport];
++        state.queuedMessages.append(message);
++    }
++}
++
++void QMetaObjectPublisher::enqueueMessage(const QJsonObject &message,
++                                          QWebChannelAbstractTransport *transport)
++{
++    auto &state = transportState[transport];
++    state.queuedMessages.append(message);
++}
++
++void QMetaObjectPublisher::sendEnqueuedPropertyUpdates(QWebChannelAbstractTransport *transport)
++{
++    auto found = transportState.find(transport);
++    if (found != transportState.end() && found.value().clientIsIdle
++        && !found.value().queuedMessages.isEmpty()) {
++
++        // If the client is connected with an in-process transport, it can
++        // happen that a message triggers a subsequent property change. In
++        // that case, we need to ensure that the queued messages have already
++        // been cleared; otherwise the recursive call will send everythig again.
++        // Case in point: The qmlwebchannel tests fail if we don't clear the
++        // queued messages before sending them out.
++        // For that same reason set the client to "busy" (aka non-idle) just
++        // right before sending out the messages; otherwise a potential
++        // "Idle" type message will not correctly restore the Idle state.
++        const auto messages = std::move(found.value().queuedMessages);
++        Q_ASSERT(found.value().queuedMessages.isEmpty());
++        found.value().clientIsIdle = false;
++
++        for (const auto &message : messages) {
++            transport->sendMessage(message);
++        }
++    }
++}
++
+ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannelAbstractTransport *transport)
+ {
+     if (!webChannel->d_func()->transports.contains(transport)) {
+@@ -866,7 +912,7 @@ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannel
+ 
+     const MessageType type = toType(message.value(KEY_TYPE));
+     if (type == TypeIdle) {
+-        setClientIsIdle(true);
++        setClientIsIdle(true, transport);
+     } else if (type == TypeInit) {
+         if (!message.contains(KEY_ID)) {
+             qWarning("JSON message object is missing the id property: %s",
+@@ -913,9 +959,9 @@ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannel
+                 return;
+             transport->sendMessage(createResponse(message.value(KEY_ID), wrapResult(result, transport)));
+         } else if (type == TypeConnectToSignal) {
+-            signalHandler.connectTo(object, message.value(KEY_SIGNAL).toInt(-1));
++            signalHandlerFor(object)->connectTo(object, message.value(KEY_SIGNAL).toInt(-1));
+         } else if (type == TypeDisconnectFromSignal) {
+-            signalHandler.disconnectFrom(object, message.value(KEY_SIGNAL).toInt(-1));
++            signalHandlerFor(object)->disconnectFrom(object, message.value(KEY_SIGNAL).toInt(-1));
+         } else if (type == TypeSetProperty) {
+             setProperty(object, message.value(KEY_PROPERTY).toInt(-1),
+                         message.value(KEY_VALUE));
+@@ -931,6 +977,7 @@ void QMetaObjectPublisher::setBlockUpdates(bool block)
+     blockUpdates = block;
+ 
+     if (!blockUpdates) {
++        timer.start(PROPERTY_UPDATE_INTERVAL, this);
+         sendPendingPropertyUpdates();
+     } else if (timer.isActive()) {
+         timer.stop();
+@@ -948,4 +995,15 @@ void QMetaObjectPublisher::timerEvent(QTimerEvent *event)
+     }
+ }
+ 
++SignalHandler<QMetaObjectPublisher> *QMetaObjectPublisher::signalHandlerFor(const QObject *object)
++{
++    auto thread = object->thread();
++    auto it = signalHandlers.find(thread);
++    if (it == signalHandlers.end()) {
++        it = signalHandlers.emplace(thread, this).first;
++        it->second.moveToThread(thread);
++    }
++    return &it->second;
++}
++
+ QT_END_NAMESPACE
+diff --git a/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h b/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
+index bbd9875..4713ef1 100644
+--- a/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
++++ b/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
+@@ -59,6 +59,9 @@
+ #include <QBasicTimer>
+ #include <QPointer>
+ #include <QJsonObject>
++#include <QQueue>
++
++#include <unordered_map>
+ 
+ #include "qwebchannelglobal.h"
+ 
+@@ -109,17 +112,36 @@ public:
+      */
+     void broadcastMessage(const QJsonObject &message) const;
+ 
++    /**
++     * Enqueue the given @p message to all known transports.
++     */
++    void enqueueBroadcastMessage(const QJsonObject &message);
++
++    /**
++     * Enqueue the given @p message to @p transport.
++     */
++    void enqueueMessage(const QJsonObject &message, QWebChannelAbstractTransport *transport);
++
++    /**
++     * If client for given @p transport is idle, send queued messaged to @p transport and then mark
++     * the client as not idle.
++     */
++    void sendEnqueuedPropertyUpdates(QWebChannelAbstractTransport *transport);
++
+     /**
+      * Serialize the QMetaObject of @p object and return it in JSON form.
+      */
+     QJsonObject classInfoForObject(const QObject *object, QWebChannelAbstractTransport *transport);
+ 
+     /**
+-     * Set the client to idle or busy, based on the value of @p isIdle.
+-     *
+-     * When the value changed, start/stop the property update timer accordingly.
++     * Set the client to idle or busy for a single @p transport, based on the value of @p isIdle.
++     */
++    void setClientIsIdle(bool isIdle, QWebChannelAbstractTransport *transport);
++
++    /**
++     * Check that client is idle for @p transport.
+      */
+-    void setClientIsIdle(bool isIdle);
++    bool isClientIdle(QWebChannelAbstractTransport *transport);
+ 
+     /**
+      * Initialize clients by sending them the class information of the registered objects.
+@@ -272,10 +294,18 @@ private:
+     friend class TestWebChannel;
+ 
+     QWebChannel *webChannel;
+-    SignalHandler<QMetaObjectPublisher> signalHandler;
++    std::unordered_map<const QThread*, SignalHandler<QMetaObjectPublisher>> signalHandlers;
++    SignalHandler<QMetaObjectPublisher> *signalHandlerFor(const QObject *object);
+ 
+-    // true when the client is idle, false otherwise
+-    bool clientIsIdle;
++    struct TransportState
++    {
++        TransportState() : clientIsIdle(false) { }
++        // true when the client is idle, false otherwise
++        bool clientIsIdle;
++        // messages to send
++        QQueue<QJsonObject> queuedMessages;
++    };
++    QHash<QWebChannelAbstractTransport *, TransportState> transportState;
+ 
+     // true when no property updates should be sent, false otherwise
+     bool blockUpdates;
+diff --git a/qtwebchannel/src/webchannel/signalhandler_p.h b/qtwebchannel/src/webchannel/signalhandler_p.h
+index 27afadb..d77373c 100644
+--- a/qtwebchannel/src/webchannel/signalhandler_p.h
++++ b/qtwebchannel/src/webchannel/signalhandler_p.h
+@@ -56,6 +56,7 @@
+ #include <QVector>
+ #include <QMetaMethod>
+ #include <QDebug>
++#include <QThread>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -71,6 +72,7 @@ static const int s_destroyedSignalIndex = QObject::staticMetaObject.indexOfMetho
+ template<class Receiver>
+ class SignalHandler : public QObject
+ {
++    Q_DISABLE_COPY(SignalHandler)
+ public:
+     SignalHandler(Receiver *receiver, QObject *parent = 0);
+ 
+@@ -268,6 +270,7 @@ int SignalHandler<Receiver>::qt_metacall(QMetaObject::Call call, int methodId, v
+     if (call == QMetaObject::InvokeMetaMethod) {
+         const QObject *object = sender();
+         Q_ASSERT(object);
++        Q_ASSERT(QThread::currentThread() == object->thread());
+         Q_ASSERT(senderSignalIndex() == methodId);
+         Q_ASSERT(m_connectionsCounter.contains(object));
+         Q_ASSERT(m_connectionsCounter.value(object).contains(methodId));
+diff --git a/qtwebchannel/tests/auto/qml/testwebchannel.cpp b/qtwebchannel/tests/auto/qml/testwebchannel.cpp
+index 9891687..3ca81c2 100644
+--- a/qtwebchannel/tests/auto/qml/testwebchannel.cpp
++++ b/qtwebchannel/tests/auto/qml/testwebchannel.cpp
+@@ -46,7 +46,11 @@ TestWebChannel::~TestWebChannel()
+ 
+ bool TestWebChannel::clientIsIdle() const
+ {
+-    return QWebChannel::d_func()->publisher->clientIsIdle;
++    for (auto *transport : QWebChannel::d_func()->transports) {
++        if (QWebChannel::d_func()->publisher->isClientIdle(transport))
++            return true;
++    }
++    return false;
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp b/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
+index 181da9e..37f989a 100644
+--- a/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
++++ b/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
+@@ -785,7 +785,7 @@ void TestWebChannel::testTransportWrapObjectProperties()
+     DummyTransport *dummyTransport = new DummyTransport(this);
+     channel.connectTo(dummyTransport);
+     channel.d_func()->publisher->initializeClient(dummyTransport);
+-    channel.d_func()->publisher->setClientIsIdle(true);
++    channel.d_func()->publisher->setClientIsIdle(true, dummyTransport);
+ 
+     QCOMPARE(channel.d_func()->publisher->transportedWrappedObjects.size(), 0);
+ 
+@@ -943,8 +943,6 @@ void TestWebChannel::testInfiniteRecursion()
+ 
+ void TestWebChannel::testAsyncObject()
+ {
+-    QSKIP("This test is broken. See QTBUG-80729");
+-
+     QWebChannel channel;
+     channel.connectTo(m_dummyTransport);
+ 
+@@ -990,6 +988,50 @@ void TestWebChannel::testAsyncObject()
+     thread.wait();
+ }
+ 
++void TestWebChannel::testPropertyMultipleTransports()
++{
++    DummyTransport transport1;
++    DummyTransport transport2;
++
++    QWebChannel channel;
++    QMetaObjectPublisher *publisher = channel.d_func()->publisher;
++
++    TestObject testObj;
++    testObj.setObjectName("testObject");
++    channel.registerObject(testObj.objectName(), &testObj);
++    channel.connectTo(&transport1);
++    channel.connectTo(&transport2);
++
++    testObj.setProp("Hello");
++
++    publisher->initializeClient(&transport1);
++    publisher->initializeClient(&transport2);
++    publisher->setClientIsIdle(true, &transport1);
++    QCOMPARE(publisher->isClientIdle(&transport1), true);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++    QVERIFY(transport1.messagesSent().isEmpty());
++    QVERIFY(transport2.messagesSent().isEmpty());
++
++    testObj.setProp("World");
++    QTRY_COMPARE_WITH_TIMEOUT(transport1.messagesSent().size(), 1u, 2000);
++    QCOMPARE(transport2.messagesSent().size(), 0u);
++    publisher->setClientIsIdle(true, &transport2);
++    QTRY_COMPARE_WITH_TIMEOUT(transport2.messagesSent().size(), 1u, 2000);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++
++    testObj.setProp("!!!");
++    publisher->setClientIsIdle(true, &transport2);
++    QCOMPARE(publisher->isClientIdle(&transport2), true);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QTRY_COMPARE_WITH_TIMEOUT(transport2.messagesSent().size(), 2u, 2000);
++    QCOMPARE(transport1.messagesSent().size(), 1u);
++    publisher->setClientIsIdle(true, &transport1);
++    QTRY_COMPARE_WITH_TIMEOUT(transport1.messagesSent().size(), 2u, 2000);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++}
++
+ class FunctionWrapper : public QObject
+ {
+     Q_OBJECT
+@@ -1082,7 +1124,7 @@ void TestWebChannel::benchInitializeClients()
+ 
+         publisher->propertyUpdatesInitialized = false;
+         publisher->signalToPropertyMap.clear();
+-        publisher->signalHandler.clear();
++        publisher->signalHandlers.clear();
+     }
+ }
+ 
+@@ -1107,7 +1149,7 @@ void TestWebChannel::benchPropertyUpdates()
+             obj->change();
+         }
+ 
+-        channel.d_func()->publisher->clientIsIdle = true;
++        channel.d_func()->publisher->setClientIsIdle(true, m_dummyTransport);
+         channel.d_func()->publisher->sendPendingPropertyUpdates();
+     }
+ }
+diff --git a/qtwebchannel/tests/auto/webchannel/tst_webchannel.h b/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
+index eae21f4..dd4e690 100644
+--- a/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
++++ b/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
+@@ -348,6 +348,7 @@ private slots:
+     void testJsonToVariant();
+     void testInfiniteRecursion();
+     void testAsyncObject();
++    void testPropertyMultipleTransports();
+     void testDeletionDuringMethodInvocation_data();
+     void testDeletionDuringMethodInvocation();
+ 
+Submodule qtwebengine f328054d...38e0df6c (commits not present)
+Submodule qtwebsockets 65850954..63fb8da1:
+diff --git a/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp b/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
+index 2affdd5..95f1194 100644
+--- a/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
++++ b/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
+@@ -273,6 +273,7 @@ void QWebSocketDataProcessor::clear()
+     if (!m_pConverterState)
+         m_pConverterState = new QTextCodec::ConverterState(QTextCodec::ConvertInvalidToNull |
+                                                            QTextCodec::IgnoreHeader);
++    frame.clear();
+ }
+ 
+ /*!
+diff --git a/qtwebsockets/src/websockets/qwebsocketprotocol.cpp b/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
+index df87a93..d0465f1 100644
+--- a/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
++++ b/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
+@@ -210,7 +210,7 @@ void QWebSocketProtocol::mask(char *payload, quint64 size, quint32 maskingKey)
+                             quint8((maskingKey & 0x0000FF00u) >> 8),
+                             quint8((maskingKey & 0x000000FFu))
+                           };
+-    int i = 0;
++    quint64 i = 0;
+     while (size-- > 0)
+         *payload++ ^= mask[i++ % 4];
+ }
diff --git a/srcpkgs/qt5/template b/srcpkgs/qt5/template
index a79d25e69da81..6dddce7f3e466 100644
--- a/srcpkgs/qt5/template
+++ b/srcpkgs/qt5/template
@@ -2,11 +2,11 @@
 #
 # revbump libqtxdg after bumping patch version
 pkgname=qt5
-version=5.15.7+20221119
+version=5.15.8
+revision=1
+build_style=meta
 # commit f8c9fb304bc3e53b3aa07f962cd74e9160decccc
 # base repo: https://invent.kde.org/qt/qt/qt5
-revision=5
-build_style=meta
 hostmakedepends="cmake clang flex perl glib-devel pkg-config
  python re2c ruby which"
 makedepends="SDL2-devel Vulkan-Headers alsa-lib-devel double-conversion-devel
@@ -29,8 +29,9 @@ homepage="https://qt.io/"
 # tarball is generated with `git archive-all qt5-$version.tar.gz`
 # to keep the size smaller qtwebengine, qtwebview, qtdocgallery, qtactiveqt and qtpim
 # can be marked with the export-ignore attribute
-distfiles="https://void.johnnynator.dev/distfiles/qt5-${version}.tar.gz"
-checksum=9d57af471c78029a362276b7c99108ea009f511bb9ba6ff6cb884f6ddd255e9f
+#distfiles="https://void.johnnynator.dev/distfiles/qt5-${version}.tar.gz"
+distfiles="https://download.qt.io/archive/qt/5.15/${version}/single/qt-everywhere-opensource-src-${version}.tar.xz"
+checksum=776a9302c336671f9406a53bd30b8e36f825742b2ec44a57c08217bff0fa86b9
 python_version=2 #unverified
 replaces="qt5-doc<5.6.0 qt5-quick1<5.6.0 qt5-quick1-devel<5.6.0 qt5-webkit<5.6.0 qt5-webkit-devel<5.6.0
  qt5-enginio<5.7.1 qt5-enginio-devel<5.7.1 qt5-plugin-gtk<5.7.1 qt5-canvas3d<5.13.0"
@@ -250,7 +251,6 @@ do_configure() {
 	# opts+=" -v"
 	opts+=" -skip qtwebengine"
 	opts+=" -skip qtwebview"
-	opts+=" -skip qtdocgallery"
 	opts+=" -skip qtpim"
 	opts+=" -skip qtsystems"
 	opts+=" -skip qtspeech"

From c264b781ec53145b0ce5010f11a528499d6b0f54 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 074/113] qtav: revbump for ffmpeg4-4.4.3

---
 srcpkgs/qtav/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtav/template b/srcpkgs/qtav/template
index 34c30b2c0c78f..2d00ad104355e 100644
--- a/srcpkgs/qtav/template
+++ b/srcpkgs/qtav/template
@@ -1,10 +1,10 @@
 # Template file for 'qtav'
 pkgname=qtav
 version=1.13.0
-revision=1
+revision=2
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel libass-devel libopenal-devel
+makedepends="ffmpeg4-devel libass-devel libopenal-devel
  libva-glx-devel libXv-devel pulseaudio-devel
  qt5-declarative-devel qt5-svg-devel
  qt5-quickcontrols"

From 1530015948d14e940471f90671e6e75c12649953 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 075/113] qtox: revbump for ffmpeg-6.0

---
 srcpkgs/qtox/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qtox/template b/srcpkgs/qtox/template
index 16019d7eaec9e..5cea0b11b6971 100644
--- a/srcpkgs/qtox/template
+++ b/srcpkgs/qtox/template
@@ -1,7 +1,7 @@
 # Template file for 'qtox'
 pkgname=qtox
 version=1.17.6
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DUPDATE_CHECK=OFF
  -DGIT_DESCRIBE=${version}

From dffa65f5f2a9ba66b8ce17a61c1b8356034b7622 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 076/113] retroarch: revbump for ffmpeg-6.0

---
 srcpkgs/retroarch/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroarch/template b/srcpkgs/retroarch/template
index 28016aa0129e6..20a1415913be5 100644
--- a/srcpkgs/retroarch/template
+++ b/srcpkgs/retroarch/template
@@ -1,7 +1,7 @@
 # Template file for 'retroarch'
 pkgname=retroarch
 version=1.15.0
-revision=1
+revision=2
 build_style=configure
 configure_args="--prefix=/usr --sysconfdir=/etc --enable-networking
  --enable-udev --disable-builtinflac --disable-builtinglslang

From 008e985aa498b1a5010beadb9ce1cbb31c0609d0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 077/113] scrcpy: revbump for ffmpeg-6.0

---
 srcpkgs/scrcpy/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/scrcpy/template b/srcpkgs/scrcpy/template
index 06208c389ca97..a5de935c7def7 100644
--- a/srcpkgs/scrcpy/template
+++ b/srcpkgs/scrcpy/template
@@ -1,7 +1,7 @@
 # Template file for 'scrcpy'
 pkgname=scrcpy
 version=2.1
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcompile_server=false
  -Dprebuilt_server=/usr/share/scrcpy/scrcpy-server-v${version}"

From 266e02dd7a7c9a8a41efa61cddc413ab48f6621e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 078/113] spek-alternative: revbump for ffmpeg4-4.4.3

---
 srcpkgs/spek-alternative/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/spek-alternative/template b/srcpkgs/spek-alternative/template
index d65086b8f008c..05246f1b8d0c8 100644
--- a/srcpkgs/spek-alternative/template
+++ b/srcpkgs/spek-alternative/template
@@ -1,11 +1,11 @@
 # Template file for 'spek-alternative'
 pkgname=spek-alternative
 version=0.8.2.3
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake gettext-devel intltool libtool pkg-config wxWidgets-common"
-makedepends="ffmpeg-devel wxWidgets-gtk3-devel"
-depends="ffmpeg"
+makedepends="ffmpeg4-devel wxWidgets-gtk3-devel"
+depends="ffmpeg4"
 short_desc="Acoustic spectrum analyser"
 maintainer="Kartik Singh <kartik.ynwa@gmail.com>"
 license="GPL-3.0-or-later"

From 44fc655d80f57ede249a8c5d82f4a07cca385680 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 079/113] ssr: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ssr/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/ssr/template b/srcpkgs/ssr/template
index b055b9ec0774a..3448ca110eb0c 100644
--- a/srcpkgs/ssr/template
+++ b/srcpkgs/ssr/template
@@ -1,11 +1,11 @@
 # Template file for 'ssr'
 pkgname=ssr
 version=0.4.4
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_QT5=ON"
 hostmakedepends="pkg-config"
-makedepends="alsa-lib-devel ffmpeg-devel glu-devel jack-devel pulseaudio-devel
+makedepends="alsa-lib-devel ffmpeg4-devel glu-devel jack-devel pulseaudio-devel
  qt5-tools-devel qt5-x11extras-devel libXinerama-devel v4l-utils-devel"
 depends="desktop-file-utils hicolor-icon-theme"
 short_desc="Simple Screen Recorder for programs and games"

From 86129648508b009826ec9460687984823eff55af Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 080/113] sumo: revbump for ffmpeg-6.0

---
 srcpkgs/sumo/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/sumo/template b/srcpkgs/sumo/template
index 0f9b9ec815f56..a3fe134aa5acc 100644
--- a/srcpkgs/sumo/template
+++ b/srcpkgs/sumo/template
@@ -1,7 +1,7 @@
 # Template file for 'sumo'
 pkgname=sumo
 version=1.12.0
-revision=5
+revision=6
 build_style=cmake
 hostmakedepends="libgdal-tools pkg-config swig python3-setuptools"
 makedepends="python3-devel ffmpeg-devel fox-devel gl2ps-devel libgdal-devel

From 1815510dac14060d6b230d335cba5411b210ea83 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 081/113] synfig: revbump for ffmpeg-6.0 and mlt7

---
 srcpkgs/synfig/patches/ffmpeg6.patch | 71 ++++++++++++++++++++++++++++
 srcpkgs/synfig/template              |  6 +--
 2 files changed, 74 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/synfig/patches/ffmpeg6.patch

diff --git a/srcpkgs/synfig/patches/ffmpeg6.patch b/srcpkgs/synfig/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..10780b42782f4
--- /dev/null
+++ b/srcpkgs/synfig/patches/ffmpeg6.patch
@@ -0,0 +1,71 @@
+--- a/src/modules/mod_libavcodec/trgt_av.cpp	2022-10-25 09:14:12.000000000 -0400
++++ b/src/modules/mod_libavcodec/trgt_av.cpp	2023-05-05 21:34:17.899194559 -0400
+@@ -38,6 +41,7 @@
+ extern "C"
+ {
+ #ifdef HAVE_LIBAVFORMAT_AVFORMAT_H
++#	include <libavcodec/avcodec.h>
+ #	include <libavformat/avformat.h>
+ #elif defined(HAVE_AVFORMAT_H)
+ #	include <avformat.h>
+@@ -155,11 +156,11 @@
+     }
+ 
+ 	bool open_video_stream() {
+-		if (avcodec_open2(video_context, NULL, NULL) < 0) {
++		if (avcodec_open2(video_context, nullptr, nullptr) < 0) {
+ 			synfig::error("Target_LibAVCodec: could not open video codec");
+ 			// seems the calling of avcodec_free_context after error will cause crash
+ 			// so just forget about this context
+-			video_context = NULL;
++			video_context = nullptr;
+ 			close();
+ 			return false;
+         }
+@@ -234,15 +235,21 @@
+ 		close();
+ 
+ 		if (!av_registered) {
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 			av_register_all();
++#endif
+ 			av_registered = true;
+ 		}
+ 
+ 		// guess format
+-		AVOutputFormat *format = av_guess_format(NULL, filename.c_str(), NULL);
++#if LIBAVCODEC_VERSION_MAJOR < 59 // FFMPEG < 5.0
++		AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#else
++		const AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#endif
+ 		if (!format) {
+ 			synfig::warning("Target_LibAVCodec: unable to guess the output format, defaulting to MPEG");
+-			format = av_guess_format("mpeg", NULL, NULL);
++			format = av_guess_format("mpeg", nullptr, nullptr);
+ 		}
+ 		if (!format) {
+ 			synfig::error("Target_LibAVCodec: unable to find 'mpeg' output format");
+@@ -254,6 +261,7 @@
+ 		context = avformat_alloc_context();
+ 		assert(context);
+ 		context->oformat = format;
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 		if (filename.size() + 1 > sizeof(context->filename)) {
+ 			synfig::error(
+ 				"Target_LibAVCodec: filename too long, max length is %d, filename is '%s'",
+@@ -263,6 +271,14 @@
+ 			return false;
+ 		}
+ 		memcpy(context->filename, filename.c_str(), filename.size() + 1);
++#else
++		context->url = av_strndup(filename.c_str(), filename.size());
++		if (!context->url) {
++			synfig::error("Target_LibAVCodec: cannot allocate space for filename");
++			close();
++			return false;
++		}
++#endif
+ 
+ 		packet = av_packet_alloc();
+ 		assert(packet);
diff --git a/srcpkgs/synfig/template b/srcpkgs/synfig/template
index 30109541ec4fc..703cfd7ebac84 100644
--- a/srcpkgs/synfig/template
+++ b/srcpkgs/synfig/template
@@ -2,11 +2,11 @@
 # Should be kept in sync with 'synfigstudio' and 'ETL'
 pkgname=synfig
 version=1.4.4
-revision=3
+revision=4
 build_style=gnu-configure
 configure_args="--with-boost-libdir=${XBPS_CROSS_BASE}/usr/lib"
 hostmakedepends="boost-build ImageMagick pkg-config intltool"
-makedepends="ETL gettext-devel libxml++-devel mlt-devel libmagick-devel
+makedepends="ETL gettext-devel libxml++-devel mlt7-devel libmagick-devel
  libmng-devel boost-build boost-devel libopenexr-devel ffmpeg-devel"
 depends="ImageMagick"
 short_desc="CLI 2D vector and timeline-based animation software"
@@ -20,7 +20,7 @@ CXXFLAGS="-std=c++11 -DHAVE_LOCALE_H=1"
 
 synfig-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision}
-	 libopenexr-devel libxml++-devel mlt-devel"
+	 libopenexr-devel libxml++-devel mlt7-devel"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/bin/synfig-config

From b83df9106558626010341393582a066958dc012b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 082/113] tg_owt: revbump for ffmpeg-6.0

---
 srcpkgs/tg_owt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tg_owt/template b/srcpkgs/tg_owt/template
index 97d195ddb34a3..551614b24956c 100644
--- a/srcpkgs/tg_owt/template
+++ b/srcpkgs/tg_owt/template
@@ -1,7 +1,7 @@
 # Template file for 'tg_owt'
 pkgname=tg_owt
 version=0.0.0.20230107
-revision=1
+revision=2
 _commit=5098730b9eb6173f0b52068fe2555b7c1015123a
 _libyuv_commit=00950840d1c9bcbb3eb6ebc5aac5793e71166c8b
 _abseil_commit=8c0b94e793a66495e0b1f34a5eb26bd7dc672db0

From e1ae971d89a3fca391d40f692b07ed5f71f37e05 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 083/113] timg: revbump for ffmpeg-6.0

---
 srcpkgs/timg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/timg/template b/srcpkgs/timg/template
index 2a2ab763d2fdd..8fb4327535ef9 100644
--- a/srcpkgs/timg/template
+++ b/srcpkgs/timg/template
@@ -1,7 +1,7 @@
 # Template file for 'timg'
 pkgname=timg
 version=1.4.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_OPENSLIDE_SUPPORT=off -Wno-dev"
 hostmakedepends="pkg-config git"

From f85999d8cfadad170c238a0ee524d10aaa7d0e6a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 084/113] tvheadend: revbump for ffmpeg4-4.4.3

---
 srcpkgs/tvheadend/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/tvheadend/template b/srcpkgs/tvheadend/template
index e6b16d7ccf3bd..46b52b6fb7f94 100644
--- a/srcpkgs/tvheadend/template
+++ b/srcpkgs/tvheadend/template
@@ -1,14 +1,14 @@
 # Template file for 'tvheadend'
 pkgname=tvheadend
 version=4.2.8
-revision=6
+revision=7
 build_style=gnu-configure
 configure_args="--enable-dvbscan --disable-ffmpeg_static
 --disable-hdhomerun_static --disable-bintray_cache --disable-libx264_static
 --disable-libx265_static --disable-libvpx_static --disable-libtheora_static
 --disable-libvorbis_static --disable-libfdkaac_static"
 hostmakedepends="gettext pkg-config python git which"
-makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg-devel"
+makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg4-devel"
 short_desc="TV streaming server"
 maintainer="lemmi <lemmi@nerd2nerd.org>"
 license="GPL-3.0-only"

From a5472e0000c282a595f23b685b7661d882d66e3b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 085/113] unpaper: update to 7.0.0.

---
 srcpkgs/unpaper/template | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/srcpkgs/unpaper/template b/srcpkgs/unpaper/template
index 38ed47a584016..1ff910e722afc 100644
--- a/srcpkgs/unpaper/template
+++ b/srcpkgs/unpaper/template
@@ -1,13 +1,13 @@
 # Template file for 'unpaper'
 pkgname=unpaper
-version=6.1
-revision=3
-build_style=gnu-configure
+version=7.0.0
+revision=1
+build_style=meson
+hostmakedepends="pkg-config meson libxslt"
+makedepends="ffmpeg-devel python3-Sphinx"
+short_desc="Post-processing tool for scanned sheets of paper"
 maintainer="Orphaned <orphan@voidlinux.org>"
-hostmakedepends="pkg-config libxslt"
-makedepends="ffmpeg-devel"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://www.flameeyes.eu/projects/unpaper"
-short_desc="A post-processing tool for scanned sheets of paper"
 distfiles="https://www.flameeyes.eu/files/${pkgname}-${version}.tar.xz"
-checksum=237c84f5da544b3f7709827f9f12c37c346cdf029b1128fb4633f9bafa5cb930
+checksum=2575fbbf26c22719d1cb882b59602c9900c7f747118ac130883f63419be46a80

From c81fab9f0b93175de3e5318866d24fd4876a5ba6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 086/113] vba-m: revbump for ffmpeg-6.0

---
 srcpkgs/vba-m/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vba-m/template b/srcpkgs/vba-m/template
index ba153e0b58ca4..aa6093645e974 100644
--- a/srcpkgs/vba-m/template
+++ b/srcpkgs/vba-m/template
@@ -2,7 +2,7 @@
 pkgname=vba-m
 reverts=1292_2
 version=2.1.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_GTK=TRUE -DENABLE_FFMPEG=TRUE -DENABLE_LINK=TRUE -DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="gettext pkg-config unzip zip yasm wxWidgets-gtk3-devel"

From 482c0aecb61b6e8fb4d47ade6c00a01114a83d37 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 087/113] vice: revbump for ffmpeg4-4.4.3

---
 srcpkgs/vice/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/vice/template b/srcpkgs/vice/template
index fe9d33a811947..4beab2c5f9ebd 100644
--- a/srcpkgs/vice/template
+++ b/srcpkgs/vice/template
@@ -1,7 +1,7 @@
 # Template file for 'vice'
 pkgname=vice
 version=3.7.1
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="
 	$(vopt_enable sdl2 sdlui2)
@@ -26,7 +26,7 @@ makedepends="
 	$(vopt_if gtk3 gtk+3-devel)
 	$(vopt_if gtk3 pulseaudio-devel)
 	$(vopt_if gtk3 pango-devel)
-	$(vopt_if ffmpeg ffmpeg-devel)"
+	$(vopt_if ffmpeg ffmpeg4-devel)"
 short_desc="Emulator for C64, C128, CBM-II, PET, VIC20, Plus4 and C16"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"

From 402b1e98b6d483a2bb9b012e1f62d2eaf8baa365 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 088/113] waypipe: revbump for ffmpeg-6.0

---
 srcpkgs/waypipe/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waypipe/template b/srcpkgs/waypipe/template
index 5c4161900060a..1a46fe27f7d83 100644
--- a/srcpkgs/waypipe/template
+++ b/srcpkgs/waypipe/template
@@ -1,7 +1,7 @@
 # Template file for 'waypipe'
 pkgname=waypipe
 version=0.8.4
-revision=1
+revision=2
 build_style=meson
 # lto is off because it causes linking errors in armv6l and armv7l (due to NEON)
 configure_args="-Dwerror=false -Dwith_dmabuf=enabled -Dwith_lz4=enabled

From 81cda532f70c8c070d305019e3808f6cb53ae514 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 089/113] wf-recorder: revbump for ffmpeg-6.0

---
 srcpkgs/wf-recorder/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/wf-recorder/template b/srcpkgs/wf-recorder/template
index e278eb001600f..5d014a5f28afb 100644
--- a/srcpkgs/wf-recorder/template
+++ b/srcpkgs/wf-recorder/template
@@ -1,7 +1,7 @@
 # Template file for 'wf-recorder'
 pkgname=wf-recorder
 version=0.3.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config scdoc wayland-devel"
 makedepends="wayland-protocols wayland-devel ffmpeg-devel x264-devel

From cfd8be002ba2787df8172ccb57d7d4341266f2f2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 090/113] xpra: revbump for ffmpeg-6.0

---
 srcpkgs/xpra/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xpra/template b/srcpkgs/xpra/template
index 0a63fdb6c7437..d5acc1981c5f6 100644
--- a/srcpkgs/xpra/template
+++ b/srcpkgs/xpra/template
@@ -1,7 +1,7 @@
 # Template file for 'xpra'
 pkgname=xpra
 version=4.4.6
-revision=1
+revision=2
 build_style=python3-module
 make_build_args="--without-cuda_kernels --without-cuda_rebuild"
 make_install_args="$(vopt_with docs) ${make_build_args}"

From 8104e07903a648fff6e9f93a3710d6df437f5945 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:07:40 -0400
Subject: [PATCH 091/113] nv-codec-headers: update to 12.0.16.0

---
 srcpkgs/nv-codec-headers/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/nv-codec-headers/template b/srcpkgs/nv-codec-headers/template
index 3d422a61e4891..251e057f826fb 100644
--- a/srcpkgs/nv-codec-headers/template
+++ b/srcpkgs/nv-codec-headers/template
@@ -1,6 +1,6 @@
 # Template file for 'nv-codec-headers'
 pkgname=nv-codec-headers
-version=11.1.5.1
+version=12.0.16.0
 revision=1
 build_style=gnu-makefile
 short_desc="FFmpeg version of headers required to interface with Nvidias codec APIs"
@@ -8,7 +8,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="MIT"
 homepage="http://git.videolan.org/?p=ffmpeg/nv-codec-headers.git"
 distfiles="https://github.com/FFmpeg/nv-codec-headers/archive/n${version}.tar.gz"
-checksum=d095fbd56aa93772471a323be0ebe65504a0f43f06c76a30b6d25da77b06ae9c
+checksum=2a1533b65f55f9da52956faf0627ed3b74868ac0c7f269990edd21369113b48f
 
 post_install() {
 	sed -n '4,25p' include/ffnvcodec/nvEncodeAPI.h > LICENSE

From 2888f0248693a7aed55d7b62ebd1b04c5f414dd0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:08:40 -0400
Subject: [PATCH 092/113] openimagedenoise: revbump for ffmpeg-6.0

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index db5ccdb055cc9..cb90045afb634 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,7 +1,7 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
 version=1.4.3
-revision=1
+revision=2
 archs="x86_64*"
 build_style=cmake
 hostmakedepends="ispc python3"

From b48a2776ae67043ebbd78e01731fdfcbf3099a08 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:31:45 -0400
Subject: [PATCH 093/113] shotcut: revbump for ffmpeg-6.0

---
 srcpkgs/shotcut/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/shotcut/template b/srcpkgs/shotcut/template
index 7d2af7b0470b5..c416c906ff734 100644
--- a/srcpkgs/shotcut/template
+++ b/srcpkgs/shotcut/template
@@ -1,7 +1,7 @@
 # Template file for 'shotcut'
 pkgname=shotcut
 version=23.05.14
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSHOTCUT_VERSION=${version}"
 hostmakedepends="pkg-config qt6-tools-devel"

From 2e83a684b1f77669c9f159e030e1fa25d2a894b6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:30 -0400
Subject: [PATCH 094/113] shiboken2: revbump for qt5-5.15.8

---
 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch | 1 +
 srcpkgs/shiboken2/template                                 | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
 create mode 120000 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
new file mode 120000
index 0000000000000..efcf3249bd885
--- /dev/null
+++ b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1 @@
+../../python3-pyside2/patches/importlib-machinery-bypass.patch
\ No newline at end of file
diff --git a/srcpkgs/shiboken2/template b/srcpkgs/shiboken2/template
index 084ecc3ba1e1c..2a21998997eb1 100644
--- a/srcpkgs/shiboken2/template
+++ b/srcpkgs/shiboken2/template
@@ -1,7 +1,7 @@
 # Template file for 'shiboken2'
 pkgname=shiboken2
 version=5.15.7
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/shiboken2"
 build_style=cmake

From 7cacdb392231c6aa9c4e8d8c502f65abbcabc379 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:53 -0400
Subject: [PATCH 095/113] python3-pyside2: update to 5.15.8

---
 .../patches/importlib-machinery-bypass.patch      | 15 +++++++++++++++
 srcpkgs/python3-pyside2/template                  |  9 +++++----
 2 files changed, 20 insertions(+), 4 deletions(-)
 create mode 100644 srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
new file mode 100644
index 0000000000000..64c429584776b
--- /dev/null
+++ b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1,15 @@
+Using this prevents an error around line 220 below it.
+"AttributeError: module 'importlib' has no attribute 'machinery'"
+The old backup logic is in place and compiles without issues.
+--- a/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:09:34.688912402 -0400
++++ b/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:10:03.395529582 -0400
+@@ -170,9 +170,6 @@
+
+     # 'zipstring_sequence' comes from signature.cpp
+     zipbytes = base64.b64decode(''.join(zipstring_sequence))
+-    if sys.version_info[0] >= 3:
+-        vzip = zipfile.ZipFile(io.BytesIO(zipbytes))
+-        return sys.meta_path, EmbeddableZipImporter(vzip)
+
+     # Old version for Python 2.7, only.
+     import os
diff --git a/srcpkgs/python3-pyside2/template b/srcpkgs/python3-pyside2/template
index 50e6ff260d3b5..b50e62bd215d4 100644
--- a/srcpkgs/python3-pyside2/template
+++ b/srcpkgs/python3-pyside2/template
@@ -1,11 +1,12 @@
 # Template file for 'python3-pyside2'
 pkgname=python3-pyside2
-version=5.15.5
-revision=2
+version=5.15.8
+revision=1
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/pyside2"
 build_style=cmake
-configure_args="-DPYTHON_EXECUTABLE=/usr/bin/python"
+configure_args="-DPYTHON_EXECUTABLE=/usr/bin/python -DCMAKE_BUILD_TYPE=None
+ -DBUILD_TESTS=OFF"
 hostmakedepends="cmake python3 shiboken2"
 makedepends="python3-devel libshiboken2-devel qt5-devel
  qt5-multimedia-devel qt5-tools-devel qt5-plugin-mysql qt5-plugin-odbc
@@ -23,7 +24,7 @@ maintainer="yopito <pierre.bourgin@free.fr>"
 license="LGPL-3.0-or-later"
 homepage="https://wiki.qt.io/Qt_for_Python"
 distfiles="https://download.qt.io/official_releases/QtForPython/pyside2/PySide2-${version}-src/${_pkgname}.tar.xz"
-checksum=3920a4fb353300260c9bc46ff70f1fb975c5e7efa22e9d51222588928ce19b33
+checksum=23436302c8deb5b4cbc769b205d09604e38ba83b40708efccb7bd8c9af6f6b5d
 
 build_options="webengine"
 desc_option_webengine="Build Qt5 WebEngine bindings"

From 057ddba018455ab81efab2719d36b3be0b4dadd7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:35 -0400
Subject: [PATCH 096/113] konqueror: revbump for ffmpeg-6.0

---
 srcpkgs/konqueror/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/konqueror/template b/srcpkgs/konqueror/template
index d8d0e73a78ab2..c5bdba601d3c3 100644
--- a/srcpkgs/konqueror/template
+++ b/srcpkgs/konqueror/template
@@ -1,11 +1,11 @@
 # Template file for 'konqueror'
 pkgname=konqueror
 version=23.04.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DDESKTOPTOJSON_EXECUTABLE=/usr/bin/desktoptojson"
 hostmakedepends="extra-cmake-modules python3 qt5-host-tools qt5-qmake kdoctools
-kcoreaddons kconfig gettext"
+ kcoreaddons kconfig gettext"
 makedepends="qt5-devel qt5-webengine-devel qt5-declarative-devel
  qt5-webchannel-devel qt5-location-devel kcmutils-devel kdelibs4support-devel
  karchive-devel khtml-devel kdesu-devel kactivities5-devel"

From bb0fefef9c18233d3b8cb7db3921b8fa2fcd127d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:58 -0400
Subject: [PATCH 097/113] qt5-speech: revbump for qt5-5.15.8

---
 srcpkgs/qt5-speech/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-speech/template b/srcpkgs/qt5-speech/template
index 3ecd10d50650c..2d7d4d4d24535 100644
--- a/srcpkgs/qt5-speech/template
+++ b/srcpkgs/qt5-speech/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-speech'
 pkgname=qt5-speech
 version=5.15.7
-revision=2
+revision=3
 _commit=d32f4a479d38a11f547598004b975f4356424a16
 build_style=qmake
 configure_args="-- -flite -flite-alsa -speechd"

From c631089c2819718a72b185cb6156795f6a234330 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 18:38:50 -0400
Subject: [PATCH 098/113] qt5-styleplugins: revbump for qt5-5.15.8

---
 srcpkgs/qt5-styleplugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-styleplugins/template b/srcpkgs/qt5-styleplugins/template
index 96ed97d12cd24..30d93660a2a4e 100644
--- a/srcpkgs/qt5-styleplugins/template
+++ b/srcpkgs/qt5-styleplugins/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-styleplugins'
 pkgname=qt5-styleplugins
 version=5.0.0
-revision=20
+revision=21
 _gitrev=335dbece103e2cbf6c7cf819ab6672c2956b17b3
 build_style=qmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From a3bd1502f736c23be1a297cc11b8d436e6de10c8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 7 May 2023 20:14:14 -0400
Subject: [PATCH 099/113] mlt7: revbump for ffmpeg-6.0

---
 srcpkgs/gst-libav/template | 2 +-
 srcpkgs/mlt7/template      | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index 04c39bff14896..8c72fc3e97eee 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.22.2
-revision=2
+revision=1
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"
diff --git a/srcpkgs/mlt7/template b/srcpkgs/mlt7/template
index 9fb7f60d692e1..cca0eb68cfc31 100644
--- a/srcpkgs/mlt7/template
+++ b/srcpkgs/mlt7/template
@@ -1,7 +1,7 @@
 # Template file for 'mlt7'
 pkgname=mlt7
 version=7.14.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSWIG_PYTHON=ON"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which

From da6fcbd1b54e01e61bc8c2b63aae006d839df66c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 7 May 2023 20:15:03 -0400
Subject: [PATCH 100/113] qt6-webengine: revbump for ffmpeg-6.0

---
 srcpkgs/qt6-webengine/template | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-webengine/template b/srcpkgs/qt6-webengine/template
index 4e22cb6e88638..43778b568d3f0 100644
--- a/srcpkgs/qt6-webengine/template
+++ b/srcpkgs/qt6-webengine/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-webengine'
 pkgname=qt6-webengine
 version=6.5.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="
  -DQT_FEATURE_webengine_system_ffmpeg=ON
@@ -145,6 +145,7 @@ pre_install() {
 }
 
 post_install() {
+	vlicense LICENSES/BSD-3-Clause.txt
 	local _file
 	find "${DESTDIR}"/usr/lib/qt6/examples \
 		-path '*/lib/qt6/**/lib/qt6/*' -type f |

From e19b23af4c700113cfa9f1f8ac3fe70c3f7360c9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 7 May 2023 20:15:29 -0400
Subject: [PATCH 101/113] tracker-miners: revbump for ffmpeg-6.0

---
 srcpkgs/tracker-miners/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tracker-miners/template b/srcpkgs/tracker-miners/template
index 8c005d697fa42..a6e5aa5777024 100644
--- a/srcpkgs/tracker-miners/template
+++ b/srcpkgs/tracker-miners/template
@@ -1,7 +1,7 @@
 # Template file for 'tracker-miners'
 pkgname=tracker-miners
 version=3.5.0
-revision=3
+revision=4
 build_style=meson
 build_helper=qemu
 # missing libgrss for miner_rss

From ec8212ce589ac0c6f5b8dc373d55fefff4b28e67 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 7 May 2023 20:20:58 -0400
Subject: [PATCH 102/113] mpd: revbump for ffmpeg-6.0

---
 srcpkgs/mpd/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpd/template b/srcpkgs/mpd/template
index 9dbd4c935acc5..9f058b62df2f3 100644
--- a/srcpkgs/mpd/template
+++ b/srcpkgs/mpd/template
@@ -1,7 +1,7 @@
 # Template file for 'mpd'
 pkgname=mpd
 version=0.23.13
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dopus=enabled -Dmikmod=enabled -Dneighbor=true
  -Dsoundcloud=enabled -Dpipe=true -Dtwolame=enabled -Dbzip2=enabled

From 535c2c5d6efae511de342e98ce59f3682bd792e1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 11 May 2023 14:05:14 -0400
Subject: [PATCH 103/113] openmw: revbump for ffmpeg-6.0

---
 srcpkgs/openmw/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openmw/template b/srcpkgs/openmw/template
index e3771c7aaf1a3..3cbf20b065770 100644
--- a/srcpkgs/openmw/template
+++ b/srcpkgs/openmw/template
@@ -1,7 +1,7 @@
 # Template file for 'openmw'
 pkgname=openmw
 version=0.47.0
-revision=5
+revision=6
 build_style=cmake
 _recast_commit=e75adf86f91eb3082220085e42dda62679f9a3ea
 _bullet_tag=3.17

From 84df4087d42237eda578a9072f69cbfc404e48ac Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 21 May 2023 12:44:11 -0400
Subject: [PATCH 104/113] electron24: revbump for ffmpeg-6.0

---
 srcpkgs/electron24/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron24/template b/srcpkgs/electron24/template
index bdaa56adc8a65..ff3d5e3ef3819 100644
--- a/srcpkgs/electron24/template
+++ b/srcpkgs/electron24/template
@@ -1,7 +1,7 @@
 # Template file for 'electron24'
 pkgname=electron24
 version=24.3.0
-revision=1
+revision=2
 _nodever=18.14.0
 _chromiumver=112.0.5615.165
 archs="x86_64* aarch64*"

From 8ec34cdd60ba8f7e4af647b58318cc5bbbbce7c4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Jun 2023 08:20:22 -0400
Subject: [PATCH 105/113] gtk4: revbump for ffmpeg-6.0

---
 srcpkgs/gtk4/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gtk4/template b/srcpkgs/gtk4/template
index b318b7bae1dd9..e3bde4a50e547 100644
--- a/srcpkgs/gtk4/template
+++ b/srcpkgs/gtk4/template
@@ -1,7 +1,7 @@
 # Template file for 'gtk4'
 pkgname=gtk4
 version=4.10.4
-revision=1
+revision=2
 build_style=meson
 build_helper="gir"
 configure_args="-Dman-pages=true -Dgtk_doc=true -Dbuild-tests=false

From 5fcd59eee6c96164e6bd27414ef848ab58b6fc03 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:25:50 -0400
Subject: [PATCH 106/113] electron19: revbump for ffmpeg-6.0

---
 srcpkgs/electron19/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron19/template b/srcpkgs/electron19/template
index 32ce301e730cf..ab7f308f5e8a6 100644
--- a/srcpkgs/electron19/template
+++ b/srcpkgs/electron19/template
@@ -1,7 +1,7 @@
 # Template file for 'electron19'
 pkgname=electron19
 version=19.0.8
-revision=3
+revision=4
 _nodever=16.14.2
 _chromiumver=102.0.5005.125
 archs="x86_64* aarch64* ppc64le*"

From ba7293dd1a7ca023bb67882f52ab901a1e394b07 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:28:26 -0400
Subject: [PATCH 107/113] siril: revbump for ffmpeg-6.0

---
 srcpkgs/siril/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/siril/template b/srcpkgs/siril/template
index 84332f79d060d..62750dd247548 100644
--- a/srcpkgs/siril/template
+++ b/srcpkgs/siril/template
@@ -1,7 +1,7 @@
 # Template file for 'siril'
 pkgname=siril
 version=0.9.12
-revision=10
+revision=11
 build_style=gnu-configure
 hostmakedepends="pkg-config intltool autoconf automake gettext-devel"
 makedepends="fftw-devel libconfig-devel libopencv-devel libffms2-devel

From 5c1cf8bef72995d98112cd5504505266f5372d6c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:29:08 -0400
Subject: [PATCH 108/113] telegram-desktop: revbump for ffmpeg-6.0

---
 srcpkgs/telegram-desktop/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/telegram-desktop/template b/srcpkgs/telegram-desktop/template
index f114b2341dc5d..9db9f80c1a53f 100644
--- a/srcpkgs/telegram-desktop/template
+++ b/srcpkgs/telegram-desktop/template
@@ -1,7 +1,7 @@
 # Template file for 'telegram-desktop'
 pkgname=telegram-desktop
 version=4.8.1
-revision=3
+revision=4
 build_style=cmake
 build_helper="qemu"
 configure_args="-DTDESKTOP_API_ID=209235

From 2e7044279a1730c6921cb58de320c8069ef50839 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 10 Jun 2023 00:40:39 -0400
Subject: [PATCH 109/113] freecad: revbump for qt5-webengine-5.15.13

---
 srcpkgs/freecad/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/freecad/template b/srcpkgs/freecad/template
index a4a3f5f76b29a..8608d1670c87f 100644
--- a/srcpkgs/freecad/template
+++ b/srcpkgs/freecad/template
@@ -1,7 +1,7 @@
 # Template file for 'freecad'
 pkgname=freecad
 version=0.20.2
-revision=5
+revision=6
 build_style=cmake
 
 _inst_prefix=/usr/lib/${pkgname}

From 822823ce91b585c97cf07a103f0e020ffd52edae Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 10 Jun 2023 00:57:09 -0400
Subject: [PATCH 110/113] qt6-multimedia: revbump for ffmpeg-6.0

---
 srcpkgs/qt6-multimedia/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-multimedia/template b/srcpkgs/qt6-multimedia/template
index a6832fdd69bfe..c9ffac914ab8f 100644
--- a/srcpkgs/qt6-multimedia/template
+++ b/srcpkgs/qt6-multimedia/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-multimedia'
 pkgname=qt6-multimedia
 version=6.5.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DQT_FEATURE_gstreamer=ON"
 hostmakedepends="perl qt6-declarative-host-tools pkg-config qt6-shadertools"

From f632c83bfc0d6eae867b7a44b89b7634a261c95d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 22 Jun 2023 10:25:02 -0400
Subject: [PATCH 111/113] kdenlive: revbump for ffmpeg-6.0

---
 srcpkgs/kdenlive/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kdenlive/template b/srcpkgs/kdenlive/template
index 89c0dcfb8577f..75495b3a35869 100644
--- a/srcpkgs/kdenlive/template
+++ b/srcpkgs/kdenlive/template
@@ -1,7 +1,7 @@
 # Template file for 'kdenlive'
 pkgname=kdenlive
 version=23.04.2
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="
  extra-cmake-modules kconfig kcoreaddons kdoctools pkg-config python3

From 18bfd369bc26a58b5796a64de7f0870f26cc482b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Jul 2023 09:18:23 -0400
Subject: [PATCH 112/113] gmic: revbump for opencv-4.7.0

---
 srcpkgs/gmic/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gmic/template b/srcpkgs/gmic/template
index 0bb4034d5cc86..808953e9b543c 100644
--- a/srcpkgs/gmic/template
+++ b/srcpkgs/gmic/template
@@ -1,7 +1,7 @@
 # Template file for 'gmic'
 pkgname=gmic
 version=3.1.6
-revision=4
+revision=5
 _zart_hash=34ebf6cce0bafb98abe57cec83c4a02cd1abeca0
 create_wrksrc=yes
 build_wrksrc="src"

From 8b7501ddd6d73e2b5d0426913d29b1a86ef336a9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Jul 2023 09:29:52 -0400
Subject: [PATCH 113/113] synfigstudio: revbump for synfig mlt7

---
 srcpkgs/synfigstudio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/synfigstudio/template b/srcpkgs/synfigstudio/template
index af1c5a296ef0f..09e442da9a680 100644
--- a/srcpkgs/synfigstudio/template
+++ b/srcpkgs/synfigstudio/template
@@ -2,7 +2,7 @@
 # Should be kept in sync with 'synfig' and 'ETL'
 pkgname=synfigstudio
 version=1.4.4
-revision=3
+revision=4
 build_style=gnu-configure
 configure_args="--disable-update-mimedb"
 hostmakedepends="pkg-config intltool gettext synfig"

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (16 preceding siblings ...)
  2023-07-04 14:18 ` zlice
@ 2023-07-04 14:19 ` zlice
  2023-07-09 14:54 ` zlice
                   ` (79 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2023-07-04 14:19 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 3488 bytes --]

There is an updated pull request by zlice against master on the void-packages repository

https://github.com/zlice/void-packages ffmpeg6-split
https://github.com/void-linux/void-packages/pull/43761

ffmpeg6 split
[ci skip]


#### Testing the changes

- I tested the changes in this PR: **YES**

main testing has been vaapi in Firefox Nightly and enc/dec in Shotcut on Intel A770

#### New package

- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**

#### Local build testing

- I built this PR locally for my native architecture, **x86_64**

#### Discussion

Continuation of https://github.com/void-linux/void-packages/pull/36315

`libavresample` is deprecated, but marked as a dependency when trying to build other packages and install `ffmpeg`(6). I think the right way to handle this is make a meta package and the add to removals?


##### Commit naming / misc

~~Commits are 'dirty' right now, running with [gstreamer 1.22.1 updates](https://github.com/void-linux/void-packages/pull/42861) and [Intel OpenCL](https://github.com/void-linux/void-packages/pull/43084). This will also make [intel packages pr](https://github.com/void-linux/void-packages/pull/41132) obsolete.~~ (see Requirements below)

Maintainer for previous ffmpeg(4) was orphaned, I can put my name in there if that matters, though I don't exactly see myself keeping up on ffmpeg.

This updates QT5 which looks like it is usually hosted by Johnny. Not sure if there's any reason to stay there or these sources are fine.

##### STILL FFMPEG4

These are a mix of emulators, games and/or older packages.

- attract (multiple patches in master)
- audacity (https://github.com/audacity/audacity/issues/2305 and https://sourceforge.net/p/portmedia/wiki/portsmf/ is 'beta')
- ccextractor (master patches? no release)
- vice
- kodi
- mlt (only dep left is flowblade)
- ~~synfig (mlt)~~ (work with mlt7, bump synfigstudio)
- tvheadend
- ssr
- spek-alternative
- ppsspp
- olive
- moc
- mediastreamer
- libextractor
- idjc
- hedgewars
- ~~ffmpegthumbnailer~~ (patches for moviedecoder.xxx files)
- ~~ffmpegthumbs~~ (latest compiles)
- deadbeef
- omxplayer
- qtav (fork has ffmpeg 5 patch - https://github.com/cmguo/QtAV)
- `vlc` (vlc4 will support ffmpeg5, there's a patch to build 3.x with ffmpeg5 but it will lack vaapi)
- `osg` (OpenSceneGraph plus `xine-lib`)


##### HAVE NOT BUILT YET

- omxplayer (rpi only? ffmpeg4)
- kodi (big, but ffmpeg4)


##### UPDATED (for ffmpeg6)

- ~~blender: update to 3.5.1~~ ~~will be revbump with~~ https://github.com/void-linux/void-packages/pull/43992
- unpaper: update to 7.0.0.
- guvcview: update to 2.0.8.
- qt5: update to 5.15.8
- qt5-webengine: update to 5.18.13
- shiboken2: revbump for qt5.15.8 (patch)
- python3-pyside2: update to 5.15.8 (patch)


##### Requirements

- ~~[gstreamer 1.22.2](https://github.com/void-linux/void-packages/pull/42861)~~ - a few packages use ffmpeg-devel and require a revbump

- [Intel Packages](https://github.com/void-linux/void-packages/pull/41132) - ffmpeg4 uses different libraries than 6 (libmfx / Intel-MediaSDK vs only oneVPL that Intel is moving to), both are included here

- ~~[shotcut 23.05.14](https://github.com/void-linux/void-packages/pull/44260)~~

A patch file from https://github.com/void-linux/void-packages/pull/43761.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ffmpeg6-split-43761.patch --]
[-- Type: text/x-diff, Size: 778967 bytes --]

From 489ef8091f17bb172622bbbcc8f58fcdfac1a5ba Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:55:46 -0400
Subject: [PATCH 001/113] ffmpeg: update to 6.0.

---
 common/shlibs                                 | 26 +++++---
 srcpkgs/ffmpeg/files/altivec.patch            | 60 -------------------
 .../patches/armv5tel-floating-point.patch     | 18 ------
 .../workaround-mesa-readeon-vaapi-bug.patch   | 28 ---------
 srcpkgs/ffmpeg/template                       | 41 +++++--------
 5 files changed, 33 insertions(+), 140 deletions(-)
 delete mode 100644 srcpkgs/ffmpeg/files/altivec.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch

diff --git a/common/shlibs b/common/shlibs
index 4e6a5a663fa0..a77346cce3e9 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -387,15 +387,23 @@ libid3tag.so.0 libid3tag-0.15.1b_1
 libgif.so.7 giflib-5.1.0_1
 libImlib2.so.1 imlib2-1.4.2_1
 libmp3lame.so.0 lame-3.98.2_1
-libavdevice.so.58 libavdevice-4.0_1
-libavformat.so.58 libavformat-4.0_1
-libswscale.so.5 libswscale-4.0_1
-libswresample.so.3 libswresample-4.0_1
-libavresample.so.4 libavresample-4.0_1
-libpostproc.so.55 libpostproc-4.0_1
-libavcodec.so.58 libavcodec-4.0_1
-libavutil.so.56 libavutil-4.0_1
-libavfilter.so.7 libavfilter-4.0_1
+libavdevice.so.60 libavdevice-6.0_1
+libavformat.so.60 libavformat-6.0_1
+libswscale.so.7 libswscale-6.0_1
+libswresample.so.4 libswresample-6.0_1
+libpostproc.so.57 libpostproc-6.0_1
+libavcodec.so.60 libavcodec-6.0_1
+libavutil.so.58 libavutil-6.0_1
+libavfilter.so.9 libavfilter-6.0_1
+libavdevice.so.58 libavdevice4-4.0_1
+libavformat.so.58 libavformat4-4.0_1
+libswscale.so.5 libswscale4-4.0_1
+libswresample.so.3 libswresample4-4.0_1
+libavresample.so.4 libavresample4-4.0_1
+libpostproc.so.55 libpostproc4-4.0_1
+libavcodec.so.58 libavcodec4-4.0_1
+libavutil.so.56 libavutil4-4.0_1
+libavfilter.so.7 libavfilter4-4.0_1
 libSDL-1.2.so.0 SDL-1.2.14_1
 libSDL_image-1.2.so.0 SDL_image-1.2.10_1
 libx264.so.157 x264-20190507.2245_1
diff --git a/srcpkgs/ffmpeg/files/altivec.patch b/srcpkgs/ffmpeg/files/altivec.patch
deleted file mode 100644
index 9c5720046332..000000000000
--- a/srcpkgs/ffmpeg/files/altivec.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-revert some altivec specific change on all ppc* except ppc64le*
-
-q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
-conditionally, for ppc* but not ppc64le* (the new code is valid for
-POWER8 VSX which LE targets as a baseline but not BE)"
-
-
-This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
----
- libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
- 1 file changed, 20 insertions(+), 4 deletions(-)
-
-diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
-index 536545293d..c1e2852adb 100644
---- a/libswscale/ppc/yuv2rgb_altivec.c
-+++ b/libswscale/ppc/yuv2rgb_altivec.c
-@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-     vector signed short R1, G1, B1;                                           \
-     vector unsigned char R, G, B;                                             \
-                                                                               \
-+    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
-+    vector unsigned char align_perm;                                          \
-+                                                                              \
-     vector signed short lCY       = c->CY;                                    \
-     vector signed short lOY       = c->OY;                                    \
-     vector signed short lCRV      = c->CRV;                                   \
-@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
-                                                                               \
-         for (j = 0; j < w / 16; j++) {                                        \
--            y0 = vec_xl(0, y1i);                                              \
-+            y1ivP = (const vector unsigned char *) y1i;                       \
-+            y2ivP = (const vector unsigned char *) y2i;                       \
-+            uivP  = (const vector unsigned char *) ui;                        \
-+            vivP  = (const vector unsigned char *) vi;                        \
-+                                                                              \
-+            align_perm = vec_lvsl(0, y1i);                                    \
-+            y0 = (vector unsigned char)                                       \
-+                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
-                                                                               \
--            y1 = vec_xl(0, y2i);                                              \
-+            align_perm = vec_lvsl(0, y2i);                                    \
-+            y1 = (vector unsigned char)                                       \
-+                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
-                                                                               \
--            u = (vector signed char) vec_xl(0, ui);                           \
-+            align_perm = vec_lvsl(0, ui);                                     \
-+            u = (vector signed char)                                          \
-+                    vec_perm(uivP[0], uivP[1], align_perm);                   \
-                                                                               \
--            v = (vector signed char) vec_xl(0, vi);                           \
-+            align_perm = vec_lvsl(0, vi);                                     \
-+            v = (vector signed char)                                          \
-+                    vec_perm(vivP[0], vivP[1], align_perm);                   \
-                                                                               \
-             u = (vector signed char)                                          \
-                     vec_sub(u,                                                \
--- 
-2.27.0
-
diff --git a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
deleted file mode 100644
index 9a55178c74f0..000000000000
--- a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
-+++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
-@@ -39,6 +39,15 @@
- #endif
- #include <fenv.h>
- 
-+#if (FE_ALL_EXCEPT == 0)
-+/* E.g. ARM soft float does not define these */
-+#define FE_INVALID    0
-+#define FE_DIVBYZERO  0
-+#define FE_OVERFLOW   0
-+#define FE_UNDERFLOW  0
-+#define FE_INEXACT    0
-+#endif
-+
- #if CONFIG_LIBFONTCONFIG
- #include <fontconfig/fontconfig.h>
- #endif
diff --git a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
deleted file mode 100644
index 00e3f68a415b..000000000000
--- a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
-From: Rainer Hochecker <fernetmenta@online.de>
-Date: Sat, 26 Jan 2019 19:48:35 +0100
-Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
-
-This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
-It was hit frequently when watching h264 channels received via DVB-X.
-Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
----
- libavcodec/vaapi_h264.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
-index 5854587a255..f12fdc457a4 100644
---- a/libavcodec/vaapi_h264.c
-+++ b/libavcodec/vaapi_h264.c
-@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
-     H264SliceContext *sl = &h->slice_ctx[0];
-     int ret;
- 
-+    if (pic->nb_slices == 0) {
-+        ret = AVERROR_INVALIDDATA;
-+        goto finish;
-+    }
-+
-     ret = ff_vaapi_decode_issue(avctx, pic);
-     if (ret < 0)
-         goto finish;
diff --git a/srcpkgs/ffmpeg/template b/srcpkgs/ffmpeg/template
index aa058aab9ca9..a2c5d8750dd6 100644
--- a/srcpkgs/ffmpeg/template
+++ b/srcpkgs/ffmpeg/template
@@ -1,15 +1,14 @@
 # Template file for 'ffmpeg'
 # audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
-pkgname=ffmpeg
-version=4.4.4
-revision=2
+version=6.0
+revision=1
 short_desc="Decoding, encoding and streaming software"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="https://www.ffmpeg.org"
 changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
 distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
-checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+checksum=57be87c22d9b49c112b6d24bc67d42508660e6b718b3db89c44e47e289137082
 
 hostmakedepends="pkg-config perl"
 makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
@@ -26,12 +25,13 @@ makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-deve
  $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
  $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
  $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
- $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers Vulkan-Tools Vulkan-ValidationLayers')
+ $(vopt_if onevpl 'onevpl onevpl-devel')
  $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
 depends="ffplay>=${version}_${revision}"
 
 build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
- dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec onevpl"
 build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
 desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
 desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
@@ -39,10 +39,8 @@ desc_option_sofa="Enable support for AES SOFA"
 desc_option_webp="Enable support for WebP"
 
 case "$XBPS_TARGET_MACHINE" in
-	i686*|x86_64*)
-		hostmakedepends+=" nasm"
-		build_options_default+=" vaapi vdpau nvenc nvdec"
-		;;
+	i686*) build_options_default+=" vaapi vdpau nvenc nvdec";;
+	x86_64*) build_options_default+=" vaapi vdpau nvenc nvdec onevpl";;
 	ppc64*) build_options_default+=" vaapi vdpau";;
 	mips*) CFLAGS="-mnan=legacy";;
 esac
@@ -119,18 +117,19 @@ do_configure() {
 		$(vopt_enable x265 libx265) \
 		$(vopt_enable v4l2 libv4l2) \
 		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
-		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		--enable-libbs2b --enable-libvidstab \
 		$(vopt_enable dav1d libdav1d) \
 		$(vopt_enable zimg libzimg) \
 		$(vopt_enable webp libwebp) \
 		$(vopt_enable sofa libmysofa) \
 		$(vopt_enable vulkan) \
+		$(vopt_enable onevpl libvpl) \
 		$(vopt_enable drm libdrm) \
 		$(vopt_enable svtav1 libsvtav1) \
 		$(vopt_enable srt libsrt) \
 		$(vopt_enable rist librist) \
-		$(vopt_if nvenc '--enable-nvenc') \
-		$(vopt_if nvdec '--enable-nvdec')
+		$(vopt_enable nvenc nvenc) \
+		$(vopt_enable nvdec nvdec)
 }
 
 do_build() {
@@ -157,10 +156,8 @@ libavdevice_package() {
 }
 
 libavresample_package() {
-	short_desc="FFmpeg audio resampling library"
-	pkg_install() {
-		vmove "usr/lib/libavresample.so.*"
-	}
+	short_desc="Package deprecated, removal needed"
+	build_style=meta
 }
 
 libavformat_package() {
@@ -214,15 +211,9 @@ ffmpeg-devel_package() {
 		libavfilter>=${version}_${revision}
 		libpostproc>=${version}_${revision}
 		libswscale>=${version}_${revision}
-		libswresample>=${version}_${revision}
-		libavresample>=${version}_${revision}"
+		libswresample>=${version}_${revision}"
 	short_desc+=" - development files"
-
-	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
-		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
-		nostrip_files="/usr/lib/libavfilter.a"
-	fi
-
+	conflicts="ffmpeg4-devel"
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig

From db20f06baaa6b1f7e6082dfb1a3dfb5f4bbc06d8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:56:22 -0400
Subject: [PATCH 002/113] New package: ffmpeg4-4.4.4.

---
 srcpkgs/ffmpeg4-devel                         |   1 +
 srcpkgs/ffmpeg4/files/altivec.patch           |  60 +++++
 .../patches/armv5tel-floating-point.patch     |  18 ++
 ...h-libavcodec-libsvtav1-ten_bit_format.diff |  40 +++
 .../workaround-mesa-readeon-vaapi-bug.patch   |  28 ++
 srcpkgs/ffmpeg4/template                      | 240 ++++++++++++++++++
 srcpkgs/libavcodec4                           |   1 +
 srcpkgs/libavdevice4                          |   1 +
 srcpkgs/libavfilter4                          |   1 +
 srcpkgs/libavformat4                          |   1 +
 srcpkgs/libavresample4                        |   1 +
 srcpkgs/libavutil4                            |   1 +
 srcpkgs/libpostproc4                          |   1 +
 srcpkgs/libswresample4                        |   1 +
 srcpkgs/libswscale4                           |   1 +
 15 files changed, 396 insertions(+)
 create mode 120000 srcpkgs/ffmpeg4-devel
 create mode 100644 srcpkgs/ffmpeg4/files/altivec.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 create mode 100644 srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
 create mode 100644 srcpkgs/ffmpeg4/template
 create mode 120000 srcpkgs/libavcodec4
 create mode 120000 srcpkgs/libavdevice4
 create mode 120000 srcpkgs/libavfilter4
 create mode 120000 srcpkgs/libavformat4
 create mode 120000 srcpkgs/libavresample4
 create mode 120000 srcpkgs/libavutil4
 create mode 120000 srcpkgs/libpostproc4
 create mode 120000 srcpkgs/libswresample4
 create mode 120000 srcpkgs/libswscale4

diff --git a/srcpkgs/ffmpeg4-devel b/srcpkgs/ffmpeg4-devel
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/ffmpeg4-devel
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/ffmpeg4/files/altivec.patch b/srcpkgs/ffmpeg4/files/altivec.patch
new file mode 100644
index 000000000000..9c5720046332
--- /dev/null
+++ b/srcpkgs/ffmpeg4/files/altivec.patch
@@ -0,0 +1,60 @@
+revert some altivec specific change on all ppc* except ppc64le*
+
+q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
+conditionally, for ppc* but not ppc64le* (the new code is valid for
+POWER8 VSX which LE targets as a baseline but not BE)"
+
+
+This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
+---
+ libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
+ 1 file changed, 20 insertions(+), 4 deletions(-)
+
+diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
+index 536545293d..c1e2852adb 100644
+--- a/libswscale/ppc/yuv2rgb_altivec.c
++++ b/libswscale/ppc/yuv2rgb_altivec.c
+@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+     vector signed short R1, G1, B1;                                           \
+     vector unsigned char R, G, B;                                             \
+                                                                               \
++    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
++    vector unsigned char align_perm;                                          \
++                                                                              \
+     vector signed short lCY       = c->CY;                                    \
+     vector signed short lOY       = c->OY;                                    \
+     vector signed short lCRV      = c->CRV;                                   \
+@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
+                                                                               \
+         for (j = 0; j < w / 16; j++) {                                        \
+-            y0 = vec_xl(0, y1i);                                              \
++            y1ivP = (const vector unsigned char *) y1i;                       \
++            y2ivP = (const vector unsigned char *) y2i;                       \
++            uivP  = (const vector unsigned char *) ui;                        \
++            vivP  = (const vector unsigned char *) vi;                        \
++                                                                              \
++            align_perm = vec_lvsl(0, y1i);                                    \
++            y0 = (vector unsigned char)                                       \
++                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
+                                                                               \
+-            y1 = vec_xl(0, y2i);                                              \
++            align_perm = vec_lvsl(0, y2i);                                    \
++            y1 = (vector unsigned char)                                       \
++                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
+                                                                               \
+-            u = (vector signed char) vec_xl(0, ui);                           \
++            align_perm = vec_lvsl(0, ui);                                     \
++            u = (vector signed char)                                          \
++                    vec_perm(uivP[0], uivP[1], align_perm);                   \
+                                                                               \
+-            v = (vector signed char) vec_xl(0, vi);                           \
++            align_perm = vec_lvsl(0, vi);                                     \
++            v = (vector signed char)                                          \
++                    vec_perm(vivP[0], vivP[1], align_perm);                   \
+                                                                               \
+             u = (vector signed char)                                          \
+                     vec_sub(u,                                                \
+-- 
+2.27.0
+
diff --git a/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
new file mode 100644
index 000000000000..9a55178c74f0
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
@@ -0,0 +1,18 @@
+--- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
++++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
+@@ -39,6 +39,15 @@
+ #endif
+ #include <fenv.h>
+ 
++#if (FE_ALL_EXCEPT == 0)
++/* E.g. ARM soft float does not define these */
++#define FE_INVALID    0
++#define FE_DIVBYZERO  0
++#define FE_OVERFLOW   0
++#define FE_UNDERFLOW  0
++#define FE_INEXACT    0
++#endif
++
+ #if CONFIG_LIBFONTCONFIG
+ #include <fontconfig/fontconfig.h>
+ #endif
diff --git a/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
new file mode 100644
index 000000000000..aa948f7a8a2d
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
@@ -0,0 +1,40 @@
+#==================================================================================================
+# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
+# From: Christopher Degawa <christopher.degawa@intel.com>
+# Date: Thu, 20 Oct 2022 22:55:27 -0500
+# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
+#
+# compressed_ten_bit_format has been deprecated upstream and has no effect
+# and can be removed. Plus, technically it was never used in the first place
+# since it would require the app (ffmpeg) to set it and do additional
+# processing of the input frames.
+#
+# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
+#
+# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
+#==================================================================================================
+--- a/libavcodec/libsvtav1.c
++++ b/libavcodec/libsvtav1.c
+@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
+ 
+ static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
+ {
+-    const int    pack_mode_10bit =
+-        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
+-    const size_t luma_size_8bit  =
+-        config->source_width * config->source_height * (1 << pack_mode_10bit);
+-    const size_t luma_size_10bit =
+-        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
++    const size_t luma_size = config->source_width * config->source_height *
++        (config->encoder_bit_depth > 8 ? 2 : 1);
+ 
+     EbSvtIOFormat *in_data;
+ 
+-    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
++    svt_enc->raw_size = luma_size * 3 / 2;
+ 
+     // allocate buffer for in and out
+     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
+-- 
+GitLab
+
diff --git a/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
new file mode 100644
index 000000000000..00e3f68a415b
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
@@ -0,0 +1,28 @@
+From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
+From: Rainer Hochecker <fernetmenta@online.de>
+Date: Sat, 26 Jan 2019 19:48:35 +0100
+Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
+
+This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
+It was hit frequently when watching h264 channels received via DVB-X.
+Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
+---
+ libavcodec/vaapi_h264.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
+index 5854587a255..f12fdc457a4 100644
+--- a/libavcodec/vaapi_h264.c
++++ b/libavcodec/vaapi_h264.c
+@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
+     H264SliceContext *sl = &h->slice_ctx[0];
+     int ret;
+ 
++    if (pic->nb_slices == 0) {
++        ret = AVERROR_INVALIDDATA;
++        goto finish;
++    }
++
+     ret = ff_vaapi_decode_issue(avctx, pic);
+     if (ret < 0)
+         goto finish;
diff --git a/srcpkgs/ffmpeg4/template b/srcpkgs/ffmpeg4/template
new file mode 100644
index 000000000000..f2c851693d36
--- /dev/null
+++ b/srcpkgs/ffmpeg4/template
@@ -0,0 +1,240 @@
+# Template file for 'ffmpeg4'
+# audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
+pkgname=ffmpeg4
+version=4.4.4
+revision=1
+short_desc="Decoding, encoding and streaming software - ffmpeg4 libraries only"
+maintainer="Orphaned <orphan@voidlinux.org>"
+license="GPL-3.0-or-later"
+homepage="https://www.ffmpeg.org"
+changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
+distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
+checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+
+hostmakedepends="pkg-config perl"
+makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
+ libXext-devel libXvMC-devel libxcb-devel lame-devel libtheora-devel
+ libvorbis-devel x264-devel xvidcore-devel jack-devel SDL2-devel
+ libcdio-paranoia-devel librtmp-devel libmodplug-devel gnutls-devel
+ speex-devel celt-devel harfbuzz-devel libass-devel opus-devel ocl-icd-devel
+ libbs2b-devel libvidstab-devel vmaf-devel $(vopt_if pulseaudio pulseaudio-devel)
+ $(vopt_if vaapi libva-devel) $(vopt_if vdpau libvdpau-devel)
+ $(vopt_if x265 x265-devel) $(vopt_if v4l2 v4l-utils-devel)
+ $(vopt_if fdk_aac fdk-aac-devel) $(vopt_if vpx libvpx-devel)
+ $(vopt_if aom libaom-devel) $(vopt_if sndio sndio-devel)
+ $(vopt_if dav1d libdav1d-devel) $(vopt_if zimg zimg-devel)
+ $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
+ $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
+ $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if mfx 'libmfx libmfx-devel')
+ $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
+
+build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec mfx"
+build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
+
+desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
+desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
+desc_option_sofa="Enable support for AES SOFA"
+desc_option_webp="Enable support for WebP"
+
+case "$XBPS_TARGET_MACHINE" in
+	i686*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau nvenc nvdec"
+			;;
+	x86_64*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau mfx nvenc nvdec"
+			;;
+	ppc64*) build_options_default+=" vaapi vdpau";;
+	mips*) CFLAGS="-mnan=legacy";;
+esac
+
+if [ "$XBPS_TARGET_WORDSIZE" != "32" ]; then
+	build_options_default+=" svtav1"
+fi
+
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+fi
+
+_apply_patch() {
+	local args="$1" pname="$(basename $2)"
+
+	if [ ! -f ".${pname}_done" ]; then
+		patch -N $args -i $2
+		touch .${pname}_done
+	fi
+}
+
+post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64le*) ;;
+		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
+	esac
+
+	vsed -i libavfilter/vf_libvmaf.c -e 's!/usr/local/share/model/\(vmaf_v0.6.1\).pkl!/usr/share/vmaf/\1.json!'
+}
+
+do_configure() {
+	# Fix gcc on x86_64-musl only
+	if [ "$XBPS_TARGET_MACHINE" = "x86_64-musl" ]; then
+		vsed -i configure -e "s;_cflags_speed='-O3';_cflags_speed='-O2';"
+	fi
+
+	if [ "$CROSS_BUILD" ]; then
+		case "$XBPS_TARGET_MACHINE" in
+			arm*) _arch="arm";;
+			aarch64*) _arch="aarch64";;
+			mips*) _arch="mips";;
+			ppc64*) _arch="ppc64";;
+			ppc*) _arch="ppc";;
+			*) _arch="${XBPS_TARGET_MACHINE%%-musl}";;
+		esac
+
+		_args+=" --enable-cross-compile
+			--sysroot=$XBPS_CROSS_BASE
+			--cross-prefix=${XBPS_CROSS_TRIPLET}-
+			--target-os=linux --arch=${_arch}"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc|ppc-musl) _args+=" --disable-altivec";;
+	esac
+
+	if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+		_args+=" --extra-libs=-latomic"
+	fi
+
+	./configure --prefix=/usr --disable-debug --enable-gpl --enable-gnutls \
+		--disable-stripping \
+		--enable-libcdio --enable-version3 --enable-runtime-cpudetect \
+		--enable-libmp3lame --enable-libvorbis --enable-libxvid \
+		--enable-libx264 $(vopt_enable vpx libvpx) --enable-libtheora \
+		--enable-shared --enable-static --enable-libxcb \
+		$(vopt_enable pulseaudio libpulse) --enable-libfreetype --enable-libmodplug \
+		--enable-libspeex --enable-libcelt --enable-libass \
+		--enable-libopus --enable-librtmp --enable-libjack \
+		$(vopt_if fdk_aac '--enable-nonfree --enable-libfdk-aac') \
+		--disable-libopencore_amrnb --disable-libopencore_amrwb \
+		--disable-libopenjpeg \
+		--enable-postproc --enable-opencl ${_args} --enable-libvmaf ${_args} \
+		$(vopt_enable x265 libx265) \
+		$(vopt_enable v4l2 libv4l2) \
+		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
+		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		$(vopt_enable dav1d libdav1d) \
+		$(vopt_enable zimg libzimg) \
+		$(vopt_enable webp libwebp) \
+		$(vopt_enable sofa libmysofa) \
+		$(vopt_enable vulkan) \
+		$(vopt_enable drm libdrm) \
+		$(vopt_enable svtav1 libsvtav1) \
+		$(vopt_enable srt libsrt) \
+		$(vopt_enable rist librist) \
+		$(vopt_enable mfx libmfx) \
+		$(vopt_if nvenc '--enable-nvenc') \
+		$(vopt_if nvdec '--enable-nvdec')
+}
+
+do_build() {
+	make ${makejobs}
+	make doc/ff{mpeg,play}.1
+}
+
+do_install() {
+	make DESTDIR=${DESTDIR} install install-man
+	rm -rf ${DESTDIR}/usr/bin
+}
+
+libavcodec4_package() {
+	short_desc="FFmpeg codec library"
+	pkg_install() {
+		vmove "usr/lib/libavcodec.so.*"
+	}
+}
+
+libavdevice4_package() {
+	short_desc="FFmpeg device handling library"
+	pkg_install() {
+		vmove "usr/lib/libavdevice.so.*"
+	}
+}
+
+libavresample4_package() {
+	short_desc="FFmpeg audio resampling library"
+	pkg_install() {
+		vmove "usr/lib/libavresample.so.*"
+	}
+}
+
+libavformat4_package() {
+	short_desc="FFmpeg file format library"
+	pkg_install() {
+		vmove "usr/lib/libavformat.so.*"
+	}
+}
+
+libavutil4_package() {
+	short_desc="FFmpeg utility library"
+	pkg_install() {
+		vmove "usr/lib/libavutil.so.*"
+	}
+}
+
+libavfilter4_package() {
+	short_desc="FFmpeg audio/video filter library"
+	pkg_install() {
+		vmove "usr/lib/libavfilter.so.*"
+	}
+}
+
+libpostproc4_package() {
+	short_desc="FFmpeg video postprocessing library"
+	pkg_install() {
+		vmove "usr/lib/libpostproc.so.*"
+	}
+}
+
+libswscale4_package() {
+	short_desc="FFmpeg video scaling library"
+	pkg_install() {
+		vmove "usr/lib/libswscale.so.*"
+	}
+}
+
+libswresample4_package() {
+	short_desc="FFmpeg video resampling library"
+	pkg_install() {
+		vmove "usr/lib/libswresample.so.*"
+	}
+}
+
+ffmpeg4-devel_package() {
+	depends="
+		libavcodec4>=${version}_${revision}
+		libavdevice4>=${version}_${revision}
+		libavformat4>=${version}_${revision}
+		libavutil4>=${version}_${revision}
+		libavfilter4>=${version}_${revision}
+		libpostproc4>=${version}_${revision}
+		libswscale4>=${version}_${revision}
+		libswresample4>=${version}_${revision}
+		libavresample4>=${version}_${revision}"
+	short_desc+=" - development files"
+	conflicts="ffmpeg-devel"
+	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
+		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
+		nostrip_files="/usr/lib/libavfilter.a"
+	fi
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.a"
+		vmove "usr/lib/*.so"
+		vmove usr/share/ffmpeg/examples
+		vmove usr/share/man/man3
+	}
+}
diff --git a/srcpkgs/libavcodec4 b/srcpkgs/libavcodec4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavcodec4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavdevice4 b/srcpkgs/libavdevice4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavdevice4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavfilter4 b/srcpkgs/libavfilter4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavfilter4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavformat4 b/srcpkgs/libavformat4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavformat4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavresample4 b/srcpkgs/libavresample4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavutil4 b/srcpkgs/libavutil4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavutil4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libpostproc4 b/srcpkgs/libpostproc4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libpostproc4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswresample4 b/srcpkgs/libswresample4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libswresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswscale4 b/srcpkgs/libswscale4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libswscale4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file

From e75857aa8f399eefafe80bbec35898dd08f40abd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:04 -0400
Subject: [PATCH 003/113] opencv: update to 4.7.0.

---
 common/shlibs           | 104 ++++++++++++++++++++--------------------
 srcpkgs/opencv/template |   8 ++--
 2 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index a77346cce3e9..ca0ee066215e 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2136,58 +2136,58 @@ libcapstone.so.4 capstone-4.0_1
 libhavege.so.2 libhaveged-1.9.11_1
 libnih.so.1 libnih-1.0.3_1
 libnih-dbus.so.1 libnih-1.0.3_1
-libopencv_quality.so.406 libopencv-4.6.0_1
-libopencv_reg.so.406 libopencv-4.6.0_1
-libopencv_surface_matching.so.406 libopencv-4.6.0_1
-libopencv_xphoto.so.406 libopencv-4.6.0_1
-libopencv_freetype.so.406 libopencv-4.6.0_1
-libopencv_fuzzy.so.406 libopencv-4.6.0_1
-libopencv_hfs.so.406 libopencv-4.6.0_1
-libopencv_img_hash.so.406 libopencv-4.6.0_1
-libopencv_line_descriptor.so.406 libopencv-4.6.0_1
-libopencv_saliency.so.406 libopencv-4.6.0_1
-libopencv_structured_light.so.406 libopencv-4.6.0_1
-libopencv_aruco.so.406 libopencv-4.6.0_1
-libopencv_bgsegm.so.406 libopencv-4.6.0_1
-libopencv_bioinspired.so.406 libopencv-4.6.0_1
-libopencv_ccalib.so.406 libopencv-4.6.0_1
-libopencv_face.so.406 libopencv-4.6.0_1
-libopencv_tracking.so.406 libopencv-4.6.0_1
-libopencv_xfeatures2d.so.406 libopencv-4.6.0_1
-libopencv_optflow.so.406 libopencv-4.6.0_1
-libopencv_ximgproc.so.406 libopencv-4.6.0_1
-libopencv_plot.so.406 libopencv-4.6.0_1
-libopencv_text.so.406 libopencv-4.6.0_1
-libopencv_ml.so.406 libopencv-4.6.0_1
-libopencv_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn.so.406 libopencv-4.6.0_1
-libopencv_shape.so.406 libopencv-4.6.0_1
-libopencv_stitching.so.406 libopencv-4.6.0_1
-libopencv_photo.so.406 libopencv-4.6.0_1
-libopencv_video.so.406 libopencv-4.6.0_1
-libopencv_calib3d.so.406 libopencv-4.6.0_1
-libopencv_features2d.so.406 libopencv-4.6.0_1
-libopencv_flann.so.406 libopencv-4.6.0_1
-libopencv_highgui.so.406 libopencv-4.6.0_1
-libopencv_videoio.so.406 libopencv-4.6.0_1
-libopencv_imgcodecs.so.406 libopencv-4.6.0_1
-libopencv_imgproc.so.406 libopencv-4.6.0_1
-libopencv_core.so.406 libopencv-4.6.0_1
-libopencv_superres.so.406 libopencv-4.6.0_1
-libopencv_videostab.so.406 libopencv-4.6.0_1
-libopencv_gapi.so.406 libopencv-4.6.0_1
-libopencv_xobjdetect.so.406 libopencv-4.6.0_1
-libopencv_datasets.so.406 libopencv-4.6.0_1
-libopencv_dnn_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn_superres.so.406 libopencv-4.6.0_1
-libopencv_dpm.so.406 libopencv-4.6.0_1
-libopencv_phase_unwrapping.so.406 libopencv-4.6.0_1
-libopencv_stereo.so.406 libopencv-4.6.0_1
-libopencv_rapid.so.406 libopencv-4.6.0_1
-libopencv_intensity_transform.so.406 libopencv-4.6.0_1
-libopencv_alphamat.so.406 libopencv-4.6.0_1
-libopencv_barcode.so.406 libopencv-4.6.0_1
-libopencv_mcc.so.406 libopencv-4.6.0_1
+libopencv_quality.so.407 libopencv-4.7.0_1
+libopencv_reg.so.407 libopencv-4.7.0_1
+libopencv_surface_matching.so.407 libopencv-4.7.0_1
+libopencv_xphoto.so.407 libopencv-4.7.0_1
+libopencv_freetype.so.407 libopencv-4.7.0_1
+libopencv_fuzzy.so.407 libopencv-4.7.0_1
+libopencv_hfs.so.407 libopencv-4.7.0_1
+libopencv_img_hash.so.407 libopencv-4.7.0_1
+libopencv_line_descriptor.so.407 libopencv-4.7.0_1
+libopencv_saliency.so.407 libopencv-4.7.0_1
+libopencv_structured_light.so.407 libopencv-4.7.0_1
+libopencv_aruco.so.407 libopencv-4.7.0_1
+libopencv_bgsegm.so.407 libopencv-4.7.0_1
+libopencv_bioinspired.so.407 libopencv-4.7.0_1
+libopencv_ccalib.so.407 libopencv-4.7.0_1
+libopencv_face.so.407 libopencv-4.7.0_1
+libopencv_tracking.so.407 libopencv-4.7.0_1
+libopencv_xfeatures2d.so.407 libopencv-4.7.0_1
+libopencv_optflow.so.407 libopencv-4.7.0_1
+libopencv_ximgproc.so.407 libopencv-4.7.0_1
+libopencv_plot.so.407 libopencv-4.7.0_1
+libopencv_text.so.407 libopencv-4.7.0_1
+libopencv_ml.so.407 libopencv-4.7.0_1
+libopencv_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn.so.407 libopencv-4.7.0_1
+libopencv_shape.so.407 libopencv-4.7.0_1
+libopencv_stitching.so.407 libopencv-4.7.0_1
+libopencv_photo.so.407 libopencv-4.7.0_1
+libopencv_video.so.407 libopencv-4.7.0_1
+libopencv_calib3d.so.407 libopencv-4.7.0_1
+libopencv_features2d.so.407 libopencv-4.7.0_1
+libopencv_flann.so.407 libopencv-4.7.0_1
+libopencv_highgui.so.407 libopencv-4.7.0_1
+libopencv_videoio.so.407 libopencv-4.7.0_1
+libopencv_imgcodecs.so.407 libopencv-4.7.0_1
+libopencv_imgproc.so.407 libopencv-4.7.0_1
+libopencv_core.so.407 libopencv-4.7.0_1
+libopencv_superres.so.407 libopencv-4.7.0_1
+libopencv_videostab.so.407 libopencv-4.7.0_1
+libopencv_gapi.so.407 libopencv-4.7.0_1
+libopencv_xobjdetect.so.407 libopencv-4.7.0_1
+libopencv_datasets.so.407 libopencv-4.7.0_1
+libopencv_dnn_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn_superres.so.407 libopencv-4.7.0_1
+libopencv_dpm.so.407 libopencv-4.7.0_1
+libopencv_phase_unwrapping.so.407 libopencv-4.7.0_1
+libopencv_stereo.so.407 libopencv-4.7.0_1
+libopencv_rapid.so.407 libopencv-4.7.0_1
+libopencv_intensity_transform.so.407 libopencv-4.7.0_1
+libopencv_alphamat.so.407 libopencv-4.7.0_1
+libopencv_barcode.so.407 libopencv-4.7.0_1
+libopencv_mcc.so.407 libopencv-4.7.0_1
 libuniconf.so.4.6 wvstreams-4.6.1_20
 libwvbase.so.4.6 wvstreams-4.6.1_20
 libwvutils.so.4.6 wvstreams-4.6.1_20
diff --git a/srcpkgs/opencv/template b/srcpkgs/opencv/template
index 69c635b1ad2b..41f3183f1582 100644
--- a/srcpkgs/opencv/template
+++ b/srcpkgs/opencv/template
@@ -1,7 +1,7 @@
 # Template file for 'opencv'
 pkgname=opencv
-version=4.6.0
-revision=4
+version=4.7.0
+revision=1
 create_wrksrc=yes
 build_wrksrc=${pkgname}-${version}
 build_style=cmake
@@ -24,8 +24,8 @@ homepage="https://opencv.org"
 changelog="https://github.com/opencv/opencv/wiki/ChangeLog"
 distfiles="https://github.com/opencv/opencv/archive/${version}.tar.gz
  https://github.com/opencv/opencv_contrib/archive/${version}.tar.gz>contrib.tar.gz"
-checksum="1ec1cba65f9f20fe5a41fda1586e01c70ea0c9a6d7b67c9e13edf0cfe2239277
- 1777d5fd2b59029cf537e5fd6f8aa68d707075822f90bde683fcde086f85f7a7"
+checksum="8df0079cdbe179748a18d44731af62a245a45ebf5085223dc03133954c662973
+ 42df840cf9055e59d0e22c249cfb19f04743e1bdad113d31b1573d3934d62584"
 patch_args="-Np1 -d ${build_wrksrc}"
 # tests hang indenfinitely, even with test data included
 make_check=no

From 872b27ccab83f6e66524d8e6d365e407679da160 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 004/113] actiona: revbump for opencv-4.7.0

---
 srcpkgs/actiona/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/actiona/template b/srcpkgs/actiona/template
index cf5f0b7a2ae6..0d899311e6df 100644
--- a/srcpkgs/actiona/template
+++ b/srcpkgs/actiona/template
@@ -1,7 +1,7 @@
 # Template file for 'actiona'
 pkgname=actiona
 version=3.10.1
-revision=2
+revision=3
 build_style=qmake
 configure_args="PKGCONFIG_OPENCV=opencv4"
 hostmakedepends="pkg-config qt5-plugin-mysql qt5-qmake qt5-host-tools"

From 1d72e9120877fdcfdb9ec558b59432aade245e5a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 005/113] qimgv: revbump for opencv-4.7.0

---
 srcpkgs/qimgv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qimgv/template b/srcpkgs/qimgv/template
index 7eb30db33992..dd341dfe1bfc 100644
--- a/srcpkgs/qimgv/template
+++ b/srcpkgs/qimgv/template
@@ -1,7 +1,7 @@
 # Template file for 'qimgv'
 pkgname=qimgv
 version=1.0.2
-revision=2
+revision=3
 build_style=cmake
 configure_args="$(vopt_if video -DVIDEO_SUPPORT=ON -DVIDEO_SUPPORT=OFF)
  $(vopt_if scale -DOPENCV_SUPPORT=ON -DOPENCV_SUPPORT=OFF)

From a3ddd74e30609df762cdd4da69b413abb689ba87 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 006/113] retroshare: revbump for opencv-4.7.0

---
 srcpkgs/retroshare/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroshare/template b/srcpkgs/retroshare/template
index 8a0786c21a08..72023fa98b75 100644
--- a/srcpkgs/retroshare/template
+++ b/srcpkgs/retroshare/template
@@ -1,7 +1,7 @@
 # Template file for 'retroshare'
 pkgname=retroshare
 version=0.6.6
-revision=2
+revision=4
 build_style=qmake
 #XXX broadcast feature requires an ancient udp-discovery-cpp which either needs
 # to be fetched+patched (FTBFS) here or packaged :/

From f5cd3b08b3f16c62be3ca0b5f7ced3bc983a38f2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 007/113] waifu2x-converter-cpp: revbump for opencv-4.7.0

---
 srcpkgs/waifu2x-converter-cpp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waifu2x-converter-cpp/template b/srcpkgs/waifu2x-converter-cpp/template
index 8c095d0d7bab..aa52d8c981a8 100644
--- a/srcpkgs/waifu2x-converter-cpp/template
+++ b/srcpkgs/waifu2x-converter-cpp/template
@@ -1,7 +1,7 @@
 # Template file for 'waifu2x-converter-cpp'
 pkgname=waifu2x-converter-cpp
 version=5.2.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DINSTALL_MODELS=ON"
 hostmakedepends="pkg-config"

From f0da174a70814736f7dc4213b013fdbbb82e6d01 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:38 -0400
Subject: [PATCH 008/113] vlc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/vlc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/vlc/template b/srcpkgs/vlc/template
index 210762b0a7e2..855ca5238662 100644
--- a/srcpkgs/vlc/template
+++ b/srcpkgs/vlc/template
@@ -1,7 +1,7 @@
 # Template file for 'vlc'
 pkgname=vlc
 version=3.0.18
-revision=3
+revision=4
 build_style=gnu-configure
 configure_args="--disable-gme --disable-libtar --enable-jack
  --enable-live555 --disable-fluidsynth --enable-dvdread
@@ -25,7 +25,7 @@ lib32disabled=yes
 hostmakedepends="automake libtool pkg-config flex gettext libgcrypt-devel
  live555-devel gettext-devel $(vopt_if lua lua52) $(vopt_if chromecast protobuf)"
 makedepends="
- avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg-devel freefont-ttf
+ avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg4-devel freefont-ttf
  gnutls-devel jack-devel liba52-devel libass-devel libbluray-devel
  libcdio-devel libdca-devel libdvbpsi-devel libdvdnav-devel libmad-devel
  libmatroska-devel libmodplug-devel libmpcdec-devel libmpeg2-devel

From 7ebea9d5668edb8bc1c65505ff52422cfe4d31b4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:55 -0400
Subject: [PATCH 009/113] osg: revbump for ffmpeg4-4.4.3

---
 srcpkgs/osg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/osg/template b/srcpkgs/osg/template
index a9ebbd287933..755793f7e11b 100644
--- a/srcpkgs/osg/template
+++ b/srcpkgs/osg/template
@@ -8,7 +8,7 @@ build_helper="qemu"
 configure_args="-DLIB_POSTFIX="
 hostmakedepends="pkg-config xrandr"
 makedepends="MesaLib-devel gtkglext-devel libcurl-devel giflib-devel librsvg-devel
- jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg-devel xine-lib-devel
+ jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg4-devel xine-lib-devel
  SDL2-devel gst-plugins-base1-devel
  $(vopt_if openexr libopenexr-devel)
  $(vopt_if poppler poppler-glib-devel)

From 799c48913dbc1fe40841121c7f6912d61c088118 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:13 -0400
Subject: [PATCH 010/113] xine-lib: revbump for ffmpeg4-4.4.3

---
 srcpkgs/xine-lib/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/xine-lib/template b/srcpkgs/xine-lib/template
index f713eff49b07..ed6194c17d11 100644
--- a/srcpkgs/xine-lib/template
+++ b/srcpkgs/xine-lib/template
@@ -1,6 +1,6 @@
 # Template file for 'xine-lib'
 pkgname=xine-lib
-version=1.2.12
+version=1.2.13
 revision=1
 build_style=gnu-configure
 configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
@@ -8,7 +8,7 @@ configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
 hostmakedepends="automake gettext-devel libtool pkg-config perl"
 makedepends="
  zlib-devel alsa-lib-devel libxcb-devel libSM-devel libXext-devel libXv-devel
- libXvMC-devel liba52-devel libmad-devel ffmpeg-devel pulseaudio-devel
+ libXvMC-devel liba52-devel libmad-devel ffmpeg4-devel pulseaudio-devel
  jack-devel samba-devel libflac-devel libmodplug-devel libmpcdec-devel
  speex-devel libtheora-devel libvorbis-devel libdca-devel faad2-devel
  libcdio-devel libbluray-devel aalib-devel libcaca-devel libXinerama-devel
@@ -19,7 +19,7 @@ license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="http://www.xine-project.org"
 changelog="https://sourceforge.net/projects/xine/files/xine-lib/${version}/README.txt/view"
 distfiles="${SOURCEFORGE_SITE}/xine/${pkgname}-${version}.tar.xz"
-checksum=d606270468e1540c2a89c0d7f5fdf11e17ecc0c2698cc0bcb1065ff26abee098
+checksum=5f10d6d718a4a51c17ed1b32b031d4f9b80b061e8276535b2be31e5ac4b75e6f
 
 case "$XBPS_TARGET_MACHINE" in
 	i686-musl)

From 6a08a4dd48e7ad6a4177446f465398f928c64ecf Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 011/113] QMPlay2: revbump for ffmpeg-6.0

---
 srcpkgs/QMPlay2/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/QMPlay2/template b/srcpkgs/QMPlay2/template
index 850df9d418b9..8d2ce7a76156 100644
--- a/srcpkgs/QMPlay2/template
+++ b/srcpkgs/QMPlay2/template
@@ -1,7 +1,7 @@
 # Template file for 'QMPlay2'
 pkgname=QMPlay2
 version=23.06.17
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools"
 makedepends="alsa-lib-devel ffmpeg-devel libass-devel libcdio-devel libgme-devel

From 2b6b3567ae402780c7e7cb58e26ccb66e72c5295 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 012/113] alsa-plugins: revbump for ffmpeg-6.0

---
 srcpkgs/alsa-plugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/alsa-plugins/template b/srcpkgs/alsa-plugins/template
index 0bfa6d9fd264..a5708a7d82a8 100644
--- a/srcpkgs/alsa-plugins/template
+++ b/srcpkgs/alsa-plugins/template
@@ -1,7 +1,7 @@
 # Template file for 'alsa-plugins'
 pkgname=alsa-plugins
 version=1.2.7.1
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--disable-maemo-plugin"
 hostmakedepends="pkg-config"

From f8340f2ff564bc87ac5df4e412086925af1689a7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 013/113] arcan: revbump for ffmpeg-6.0

---
 srcpkgs/arcan/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/arcan/template b/srcpkgs/arcan/template
index 7be9652eccf3..ccc7df11ceac 100644
--- a/srcpkgs/arcan/template
+++ b/srcpkgs/arcan/template
@@ -2,7 +2,7 @@
 # !! keep synced with: acfgfs aclip aloadimage
 pkgname=arcan
 version=0.6.2.1
-revision=1
+revision=2
 create_wrksrc=yes
 build_wrksrc=arcan/src
 build_style=cmake

From 36c05299730aa27031a0146a33a0b4144cf4ce1f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 014/113] attract: revbump for ffmpeg4-4.4.3

---
 srcpkgs/attract/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/attract/template b/srcpkgs/attract/template
index 26144e931a3c..e760bf0d18ae 100644
--- a/srcpkgs/attract/template
+++ b/srcpkgs/attract/template
@@ -1,12 +1,12 @@
 # Template file for 'attract'
 pkgname=attract
 version=2.6.2
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="VERBOSE=1"
 make_use_env=yes
 hostmakedepends="pkg-config"
-makedepends="SFML-devel ffmpeg-devel fontconfig-devel glu-devel libarchive-devel
+makedepends="SFML-devel ffmpeg4-devel fontconfig-devel glu-devel libarchive-devel
  libcurl-devel libjpeg-turbo-devel xine-lib rapidjson libXrandr-devel"
 depends="git"
 short_desc="Attract-Mode is a graphical frontend for emulators"

From 500e6d6beae4fd96fe97ab0c5ce5b50f11f728db Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 015/113] aubio: revbump for ffmpeg-6.0

---
 srcpkgs/aubio/patches/ffmpeg5.patch | 25 +++++++++++++++++++++++++
 srcpkgs/aubio/template              |  2 +-
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/aubio/patches/ffmpeg5.patch

diff --git a/srcpkgs/aubio/patches/ffmpeg5.patch b/srcpkgs/aubio/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..aace41a6e6d9
--- /dev/null
+++ b/srcpkgs/aubio/patches/ffmpeg5.patch
@@ -0,0 +1,25 @@
+From 8a05420e5dd8c7b8b2447f82dc919765876511b3 Mon Sep 17 00:00:00 2001
+From: Paul Brossier <piem@piem.org>
+Date: Tue, 25 Jan 2022 18:30:27 +0100
+Subject: [PATCH] [source_avcodec] define FF_API_LAVF_AVCTX for libavcodec >
+ 59, thx @berolinux (closes gh-353)
+
+---
+ src/io/source_avcodec.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/io/source_avcodec.c b/src/io/source_avcodec.c
+index e0ae93b5..1421bd9a 100644
+--- a/src/io/source_avcodec.c
++++ b/src/io/source_avcodec.c
+@@ -68,6 +68,10 @@
+ #define AUBIO_AVCODEC_MAX_BUFFER_SIZE AV_INPUT_BUFFER_MIN_SIZE
+ #endif
+ 
++#if LIBAVCODEC_VERSION_MAJOR >= 59
++#define FF_API_LAVF_AVCTX 1
++#endif
++
+ struct _aubio_source_avcodec_t {
+   uint_t hop_size;
+   uint_t samplerate;
diff --git a/srcpkgs/aubio/template b/srcpkgs/aubio/template
index ad1c4b256991..7d875cc02541 100644
--- a/srcpkgs/aubio/template
+++ b/srcpkgs/aubio/template
@@ -1,7 +1,7 @@
 # Template file for 'aubio'
 pkgname=aubio
 version=0.4.9
-revision=1
+revision=2
 build_style=waf3
 # XXX lash, pure and swig support.
 hostmakedepends="pkg-config txt2man"

From ed5c31130978eb0a1ca265ca07d073c46327dbb7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 016/113] audacious-plugins: revbump for ffmpeg-6.0

---
 .../audacious-plugins/patches/ffmpeg5.patch   | 43 +++++++++++++++++++
 srcpkgs/audacious-plugins/template            |  2 +-
 2 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/audacious-plugins/patches/ffmpeg5.patch

diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg5.patch b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..4e5e34099d71
--- /dev/null
+++ b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
@@ -0,0 +1,43 @@
+commit 298aa371c56c2f52c25a33d9bdec4918b11cebdc
+Author: tibequadorian <tibequadorian@posteo.de>
+Date:   Sat Mar 19 18:40:12 2022 +0100
+
+    audacious-plugins: rebuild against ffmpeg-5.0
+
+diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+new file mode 100644
+index 0000000000..617c11215b
+--- /dev/null
++++ b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+@@ -0,0 +1,31 @@
++From f60beb400eeb1e4778bbfd738bc4a4ccef3de539 Mon Sep 17 00:00:00 2001
++From: John Lindgren <john@jlindgren.net>
++Date: Sat, 5 Mar 2022 12:05:34 -0500
++Subject: [PATCH] Fix build with FFmpeg 5.0
++
++---
++ src/ffaudio/ffaudio-core.cc | 4 ++--
++ 1 file changed, 2 insertions(+), 2 deletions(-)
++
++diff --git a/src/ffaudio/ffaudio-core.cc b/src/ffaudio/ffaudio-core.cc
++index 16dc63e3a..a2b95fd6c 100644
++--- a/src/ffaudio/ffaudio-core.cc
+++++ b/src/ffaudio/ffaudio-core.cc
++@@ -274,7 +274,7 @@ static AVInputFormat * get_format_by_content (const char * name, VFSFile & file)
++         AVProbeData d = {name, buf, filled};
++         score = target;
++ 
++-        f = av_probe_input_format2 (& d, true, & score);
+++        f = (AVInputFormat *) av_probe_input_format2 (& d, true, & score);
++         if (f)
++             break;
++ 
++@@ -347,7 +347,7 @@ static bool find_codec (AVFormatContext * c, CodecInfo * cinfo)
++ #endif
++         if (stream && stream->codecpar && stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
++         {
++-            AVCodec * codec = avcodec_find_decoder (stream->codecpar->codec_id);
+++            AVCodec * codec = (AVCodec *) avcodec_find_decoder (stream->codecpar->codec_id);
++ 
++             if (codec)
++             {
diff --git a/srcpkgs/audacious-plugins/template b/srcpkgs/audacious-plugins/template
index 88cbc1671fc6..beebfae59ed4 100644
--- a/srcpkgs/audacious-plugins/template
+++ b/srcpkgs/audacious-plugins/template
@@ -2,7 +2,7 @@
 #Keep in sync with audacious!
 pkgname=audacious-plugins
 version=4.3.1
-revision=1
+revision=2
 build_style=meson
 configure_args="$(vopt_bool gtk3 gtk) $(vopt_bool gtk3)
  $(vopt_bool qt) $(vopt_bool qt qt6)"

From 31d7a3bb1afd1f01897079f4fe21c358de65e0ef Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 017/113] audacity: revbump for ffmpeg4-4.4.3

---
 srcpkgs/audacity/template | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/audacity/template b/srcpkgs/audacity/template
index d509c0a89407..11e20255685b 100644
--- a/srcpkgs/audacity/template
+++ b/srcpkgs/audacity/template
@@ -1,7 +1,7 @@
 # Template file for 'audacity'
 pkgname=audacity
 version=2.4.1
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--with-ffmpeg=system --with-libsndfile=system --with-expat=system
  --with-libsoxr=system --with-lame=system --with-lv2=system ac_cv_path_WX_CONFIG=wx-config-gtk3"
@@ -9,7 +9,7 @@ hostmakedepends="pkg-config cmake gettext libtool m4 which"
 makedepends="jack-devel wxWidgets-gtk3-devel gtk+3-devel
  libmad-devel soundtouch-devel libsoxr-devel
  vamp-plugin-sdk-devel lame-devel libid3tag-devel libflac-devel
- ffmpeg-devel twolame-devel serd-devel lv2 lilv-devel suil-devel"
+ ffmpeg4-devel twolame-devel serd-devel lv2 lilv-devel suil-devel"
 depends="desktop-file-utils hicolor-icon-theme"
 short_desc="Graphical cross-platform audio editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
@@ -33,5 +33,4 @@ post_install() {
 	vcopy plug-ins /usr/share/audacity
 
 	rm ${DESTDIR}/usr/share/doc/audacity/LICENSE.txt
-	vlicense LICENSE.txt LICENSE
 }

From 10ade9d793594c3a5985bda6736712dc10ef4d0e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 018/113] avidemux: revbump for ffmpeg-6.0

---
 srcpkgs/avidemux/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/avidemux/template b/srcpkgs/avidemux/template
index 253a0243e225..557285982d2b 100644
--- a/srcpkgs/avidemux/template
+++ b/srcpkgs/avidemux/template
@@ -1,7 +1,7 @@
 # Template file for 'avidemux'
 pkgname=avidemux
 version=2.8.0
-revision=2
+revision=3
 # Can't be compiled for aarch64, arm* or mips*
 archs="x86_64* i686*"
 hostmakedepends="cmake pkg-config qt5-host-tools qt5-devel tar yasm"

From 05c99e65835800a528ee3107e6032ef11beade0e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 019/113] baresip: revbump for ffmpeg-6.0

---
 srcpkgs/baresip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/baresip/template b/srcpkgs/baresip/template
index f1bd1817048b..b21e22334316 100644
--- a/srcpkgs/baresip/template
+++ b/srcpkgs/baresip/template
@@ -1,7 +1,7 @@
 # Template file for 'baresip'
 pkgname=baresip
 version=2.10.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config glib-devel"
 makedepends="libgsm-devel libpng-devel openssl-devel libsndfile-devel

From 4cdf29f13fc694b13150b060f4d2d0a40fe972a8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 020/113] blender: revbump for ffmpeg-6.0

---
 srcpkgs/blender/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index 7a710ac0df49..0f72876d4d70 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -9,8 +9,8 @@ configure_args="-DWITH_INSTALL_PORTABLE=OFF -DWITH_PYTHON_INSTALL=OFF
  -DWITH_JACK=ON -DWITH_CODEC_FFMPEG=ON -DWITH_CODEC_SNDFILE=ON -DWITH_OPENMP=ON
  -DWITH_FFTW3=ON -DWITH_MOD_OCEANSIM=ON -DWITH_CYCLES_EMBREE=OFF -DWITH_OPENCOLORIO=ON
  -DWITH_IMAGE_OPENEXR=ON -DWITH_IMAGE_OPENJPEG=ON -DWITH_OPENSUBDIV=ON
- -DWITH_OPENCOLLADA=ON -DWITH_SYSTEM_GLEW=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
- -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_LIBDECOR=ON
+ -DWITH_OPENCOLLADA=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
+ -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_WAYLAND_LIBDECOR=ON
  -DWITH_BUILDINFO=OFF -DPYTHON_VERSION=${py3_ver} -DPYTHON_LIBPATH=/usr/lib
  -DPYTHON_LIBRARY=python${py3_ver}${py3_abiver} -DPYTHON_INCLUDE_DIRS=/${py3_inc}
  -DWITH_SYSTEM_LZO=ON -DWITH_SYSTEM_EIGEN3=ON -DWITH_SYSTEM_FREETYPE=ON"

From 940329daae3a14fc45a97c90170a496f9a32d2b7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 021/113] cantata: revbump for ffmpeg-6.0

---
 srcpkgs/cantata/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cantata/template b/srcpkgs/cantata/template
index 4b417d80d5c2..8a90aaa4c07a 100644
--- a/srcpkgs/cantata/template
+++ b/srcpkgs/cantata/template
@@ -1,7 +1,7 @@
 # Template file for 'cantata'
 pkgname=cantata
 version=2.5.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools qt5-tools"
 makedepends="qt5-devel qt5-tools-devel qt5-svg-devel qt5-xmlpatterns-devel

From 62a08119df80003aafbca5afc1bf1cbc98a398a8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 022/113] ccextractor: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ccextractor/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/ccextractor/template b/srcpkgs/ccextractor/template
index 9abcd82852b2..6eccad5885af 100644
--- a/srcpkgs/ccextractor/template
+++ b/srcpkgs/ccextractor/template
@@ -1,12 +1,12 @@
 # Template file for 'ccextractor'
 pkgname=ccextractor
 version=0.93
-revision=1
+revision=2
 build_wrksrc="linux"
 build_style=gnu-configure
 configure_args="--enable-ocr --enable-hardsubx"
 hostmakedepends="automake pkg-config"
-makedepends="leptonica-devel tesseract-ocr-devel ffmpeg-devel"
+makedepends="leptonica-devel tesseract-ocr-devel ffmpeg4-devel"
 short_desc="Extract subtitles from video streams"
 maintainer="newbluemoon <blaumolch@mailbox.org>"
 license="GPL-2.0-or-later"

From bb99ad93f5d502850711fcd08e54c4a9e96750a9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 023/113] chromaprint: revbump for ffmpeg-6.0

---
 srcpkgs/chromaprint/patches/ffmpeg5.patch | 569 ++++++++++++++++++++++
 srcpkgs/chromaprint/template              |   2 +-
 2 files changed, 570 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromaprint/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromaprint/patches/ffmpeg5.patch b/srcpkgs/chromaprint/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..a9fd307a23c8
--- /dev/null
+++ b/srcpkgs/chromaprint/patches/ffmpeg5.patch
@@ -0,0 +1,569 @@
+From 8ccad6937177b1b92e40ab8f4447ea27bac009a7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= <lalinsky@gmail.com>
+Date: Fri, 4 Nov 2022 21:47:38 +0100
+Subject: [PATCH] Use FFmpeg 5.x (#120)
+
+* Use FFmpeg 5.1.2 for CI builds
+
+* Build on Ubuntu 20.04
+
+* Upgrade code to FFmpeg 5.x APIs
+
+* Only set FFmpeg include dirs if building tools
+
+* No longer needed
+
+* Use ubuntu 20.04
+---
+ .github/workflows/build.yml                   |   6 +-
+ CMakeLists.txt                                |  16 --
+ package/build.sh                              |   4 +-
+ src/audio/ffmpeg_audio_processor.h            |   2 -
+ src/audio/ffmpeg_audio_processor_avresample.h |  72 -------
+ src/audio/ffmpeg_audio_processor_swresample.h |  18 +-
+ src/audio/ffmpeg_audio_reader.h               | 197 +++++++++---------
+ tests/CMakeLists.txt                          |   6 +
+ 8 files changed, 122 insertions(+), 199 deletions(-)
+ delete mode 100644 src/audio/ffmpeg_audio_processor_avresample.h
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index f8d6a32..4da2405 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -84,9 +84,6 @@ find_package(FFmpeg)
+ if(FFMPEG_LIBRARIES)
+ 	cmake_push_check_state(RESET)
+ 	set(CMAKE_REQUIRED_LIBRARIES ${FFMPEG_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -lm)
+-	check_function_exists(av_packet_unref HAVE_AV_PACKET_UNREF)
+-	check_function_exists(av_frame_alloc HAVE_AV_FRAME_ALLOC)
+-	check_function_exists(av_frame_free HAVE_AV_FRAME_FREE)
+ 	cmake_pop_check_state()
+ endif()
+
+@@ -163,14 +160,11 @@ message(STATUS "Using ${FFT_LIB} for FFT calculations")
+ if(NOT AUDIO_PROCESSOR_LIB)
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+ 		set(AUDIO_PROCESSOR_LIB "swresample")
+-	elseif(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(AUDIO_PROCESSOR_LIB "avresample")
+ 	endif()
+ endif()
+
+ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE OFF)
+ 		set(USE_SWRESAMPLE ON)
+ 		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBSWRESAMPLE_LIBRARIES})
+ 		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBSWRESAMPLE_INCLUDE_DIRS})
+@@ -178,16 +172,6 @@ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+ 	endif()
+ 	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+-elseif(AUDIO_PROCESSOR_LIB STREQUAL "avresample")
+-	if(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE ON)
+-		set(USE_SWRESAMPLE OFF)
+-		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBAVRESAMPLE_LIBRARIES})
+-		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBAVRESAMPLE_INCLUDE_DIRS})
+-	else()
+-		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+-	endif()
+-	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+ else()
+ 	message(STATUS "Building without audio conversion support, please install FFmpeg with libswresample")
+ endif()
+diff --git a/package/build.sh b/package/build.sh
+index da631ae..b41d36e 100755
+--- a/package/build.sh
++++ b/package/build.sh
+@@ -7,8 +7,8 @@ set -eux
+
+ BASE_DIR=$(cd $(dirname $0)/.. && pwd)
+
+-FFMPEG_VERSION=4.4.1
+-FFMPEG_BUILD_TAG=v4.4.1-1
++FFMPEG_VERSION=5.1.2
++FFMPEG_BUILD_TAG=v${FFMPEG_VERSION}-1
+
+ TMP_BUILD_DIR=$BASE_DIR/$(mktemp -d build.XXXXXXXX)
+ trap 'rm -rf $TMP_BUILD_DIR' EXIT
+diff --git a/src/audio/ffmpeg_audio_processor.h b/src/audio/ffmpeg_audio_processor.h
+index 7628fc7..39f4f6d 100644
+--- a/src/audio/ffmpeg_audio_processor.h
++++ b/src/audio/ffmpeg_audio_processor.h
+@@ -10,8 +10,6 @@
+
+ #if defined(USE_SWRESAMPLE)
+ #include "audio/ffmpeg_audio_processor_swresample.h"
+-#elif defined(USE_AVRESAMPLE)
+-#include "audio/ffmpeg_audio_processor_avresample.h"
+ #else
+ #error "no audio processing library"
+ #endif
+diff --git a/src/audio/ffmpeg_audio_processor_avresample.h b/src/audio/ffmpeg_audio_processor_avresample.h
+deleted file mode 100644
+index bd85f92..0000000
+--- a/src/audio/ffmpeg_audio_processor_avresample.h
++++ /dev/null
+@@ -1,72 +0,0 @@
+-// Copyright (C) 2016  Lukas Lalinsky
+-// Distributed under the MIT license, see the LICENSE file for details.
+-
+-#ifndef CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-#define CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-
+-extern "C" {
+-#include <libavresample/avresample.h>
+-}
+-
+-namespace chromaprint {
+-
+-class FFmpegAudioProcessor {
+-public:
+-	FFmpegAudioProcessor() {
+-		m_resample_ctx = avresample_alloc_context();
+-	}
+-
+-	~FFmpegAudioProcessor() {
+-		avresample_free(&m_resample_ctx);
+-	}
+-
+-	void SetCompatibleMode() {
+-		av_opt_set_int(m_resample_ctx, "filter_size", 16, 0);
+-		av_opt_set_int(m_resample_ctx, "phase_shift", 8, 0);
+-		av_opt_set_int(m_resample_ctx, "linear_interp", 1, 0);
+-		av_opt_set_double(m_resample_ctx, "cutoff", 0.8, 0);
+-	}
+-
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "in_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_rate", sample_rate, 0);
+-	}
+-
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "out_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_rate, 0);
+-	}
+-
+-	int Init() {
+-		return avresample_open(m_resample_ctx);
+-	}
+-
+-	int Convert(uint8_t **out, int out_count, const uint8_t **in, int in_count) {
+-		return avresample_convert(m_resample_ctx, out, 0, out_count, (uint8_t **) in, 0, in_count);
+-	}
+-
+-	int Flush(uint8_t **out, int out_count) {
+-		return avresample_read(m_resample_ctx, out, out_count);
+-	}
+-
+-private:
+-	AVAudioResampleContext *m_resample_ctx = nullptr;
+-};
+-
+-}; // namespace chromaprint
+-
+-#endif
+diff --git a/src/audio/ffmpeg_audio_processor_swresample.h b/src/audio/ffmpeg_audio_processor_swresample.h
+index b86266b..b1d4bea 100644
+--- a/src/audio/ffmpeg_audio_processor_swresample.h
++++ b/src/audio/ffmpeg_audio_processor_swresample.h
+@@ -28,30 +28,28 @@ public:
+ 		av_opt_set_double(m_swr_ctx, "cutoff", 0.8, 0);
+ 	}
+
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "icl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "ich", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetInputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "in_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "isf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "in_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "isr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "in_sample_rate", sample_rate, 0);
+ 	}
+
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "ocl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "och", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetOutputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "out_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "osf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "out_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "osr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "out_sample_rate", sample_rate, 0);
+ 	}
+
+ 	int Init() {
+diff --git a/src/audio/ffmpeg_audio_reader.h b/src/audio/ffmpeg_audio_reader.h
+index 5550164..1c6b346 100644
+--- a/src/audio/ffmpeg_audio_reader.h
++++ b/src/audio/ffmpeg_audio_reader.h
+@@ -62,7 +62,7 @@ public:
+ 	bool Read(const int16_t **data, size_t *size);
+
+ 	bool IsOpen() const { return m_opened; }
+-	bool IsFinished() const { return m_finished && !m_got_frame; }
++	bool IsFinished() const { return !m_has_more_packets && !m_has_more_frames; }
+
+ 	std::string GetError() const { return m_error; }
+ 	int GetErrorCode() const { return m_error_code; }
+@@ -74,20 +74,19 @@ private:
+ 	uint8_t *m_convert_buffer[1] = { nullptr };
+ 	int m_convert_buffer_nb_samples = 0;
+
+-	AVInputFormat *m_input_fmt = nullptr;
++	const AVInputFormat *m_input_fmt = nullptr;
+ 	AVDictionary *m_input_opts = nullptr;
+
+ 	AVFormatContext *m_format_ctx = nullptr;
+ 	AVCodecContext *m_codec_ctx = nullptr;
+-	AVFrame *m_frame = nullptr;
+ 	int m_stream_index = -1;
+ 	std::string m_error;
+ 	int m_error_code = 0;
+-	bool m_finished = false;
+ 	bool m_opened = false;
+-	int m_got_frame = 0;
+-	AVPacket m_packet;
+-	AVPacket m_packet0;
++	bool m_has_more_packets = true;
++	bool m_has_more_frames = true;
++	AVPacket *m_packet = nullptr;
++	AVFrame *m_frame = nullptr;
+
+ 	int m_output_sample_rate = 0;
+ 	int m_output_channels = 0;
+@@ -98,19 +97,12 @@ private:
+
+ inline FFmpegAudioReader::FFmpegAudioReader() {
+ 	av_log_set_level(AV_LOG_QUIET);
+-
+-	av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
+ }
+
+ inline FFmpegAudioReader::~FFmpegAudioReader() {
+ 	Close();
+ 	av_dict_free(&m_input_opts);
+ 	av_freep(&m_convert_buffer[0]);
+-	av_packet_unref(&m_packet0);
+ }
+
+ inline bool FFmpegAudioReader::SetInputFormat(const char *name) {
+@@ -135,11 +127,10 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ 	Close();
+
+-    av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
++	m_packet = av_packet_alloc();
++	if (!m_packet) {
++		return false;
++	}
+
+ 	ret = avformat_open_input(&m_format_ctx, file_name.c_str(), m_input_fmt, &m_input_opts);
+ 	if (ret < 0) {
+@@ -153,26 +144,31 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		return false;
+ 	}
+
+-	AVCodec *codec;
++	const AVCodec *codec;
+ 	ret = av_find_best_stream(m_format_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &codec, 0);
+ 	if (ret < 0) {
+ 		SetError("Could not find any audio stream in the file", ret);
+ 		return false;
+ 	}
+ 	m_stream_index = ret;
++	auto stream = m_format_ctx->streams[m_stream_index];
+
+-	m_codec_ctx = m_format_ctx->streams[m_stream_index]->codec;
++	m_codec_ctx = avcodec_alloc_context3(codec);
+ 	m_codec_ctx->request_sample_fmt = AV_SAMPLE_FMT_S16;
+
++	ret = avcodec_parameters_to_context(m_codec_ctx, stream->codecpar);
++	if (ret < 0) {
++		SetError("Could not copy the stream parameters", ret);
++		return false;
++	}
++
+ 	ret = avcodec_open2(m_codec_ctx, codec, nullptr);
+ 	if (ret < 0) {
+ 		SetError("Could not open the codec", ret);
+ 		return false;
+ 	}
+
+-	if (!m_codec_ctx->channel_layout) {
+-		m_codec_ctx->channel_layout = av_get_default_channel_layout(m_codec_ctx->channels);
+-	}
++	av_dump_format(m_format_ctx, 0, "foo", 0);
+
+ 	m_frame = av_frame_alloc();
+ 	if (!m_frame) {
+@@ -183,19 +179,23 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		m_output_sample_rate = m_codec_ctx->sample_rate;
+ 	}
+
+-	if (!m_output_channels) {
+-		m_output_channels = m_codec_ctx->channels;
++	AVChannelLayout output_channel_layout;
++	if (m_output_channels) {
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
++	} else {
++		m_output_channels = m_codec_ctx->ch_layout.nb_channels;
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
+ 	}
+
+-	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
++	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->ch_layout.nb_channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
+ 		m_converter.reset(new FFmpegAudioProcessor());
+ 		m_converter->SetCompatibleMode();
+ 		m_converter->SetInputSampleFormat(m_codec_ctx->sample_fmt);
+ 		m_converter->SetInputSampleRate(m_codec_ctx->sample_rate);
+-		m_converter->SetInputChannelLayout(m_codec_ctx->channel_layout);
++		m_converter->SetInputChannelLayout(&(m_codec_ctx->ch_layout));
+ 		m_converter->SetOutputSampleFormat(AV_SAMPLE_FMT_S16);
+ 		m_converter->SetOutputSampleRate(m_output_sample_rate);
+-		m_converter->SetOutputChannelLayout(av_get_default_channel_layout(m_output_channels));
++		m_converter->SetOutputChannelLayout(&output_channel_layout);
+ 		auto ret = m_converter->Init();
+ 		if (ret != 0) {
+ 			SetError("Could not create an audio converter instance", ret);
+@@ -203,10 +203,11 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		}
+ 	}
+
++	av_channel_layout_uninit(&output_channel_layout);
++
+ 	m_opened = true;
+-	m_finished = false;
+-	m_got_frame = 0;
+-	m_nb_packets = 0;
++	m_has_more_packets = true;
++	m_has_more_frames = true;
+ 	m_decode_error = 0;
+
+ 	return true;
+@@ -214,6 +215,7 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ inline void FFmpegAudioReader::Close() {
+ 	av_frame_free(&m_frame);
++	av_packet_free(&m_packet);
+
+ 	m_stream_index = -1;
+
+@@ -252,91 +254,98 @@ inline bool FFmpegAudioReader::Read(const int16_t **data, size_t *size) {
+ 		return false;
+ 	}
+
++	*data = nullptr;
++	*size = 0;
++
+ 	int ret;
++	bool needs_packet = false;
+ 	while (true) {
+-		while (m_packet.size <= 0) {
+-			av_packet_unref(&m_packet0);
+-			av_init_packet(&m_packet);
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			ret = av_read_frame(m_format_ctx, &m_packet);
++		while (needs_packet && m_packet->size == 0) {
++			ret = av_read_frame(m_format_ctx, m_packet);
+ 			if (ret < 0) {
+ 				if (ret == AVERROR_EOF) {
+-					m_finished = true;
++					needs_packet = false;
++					m_has_more_packets = false;
+ 					break;
+-				} else {
++				}
++				SetError("Error reading from the audio source", ret);
++				return false;
++			}
++			if (m_packet->stream_index == m_stream_index) {
++				needs_packet = false;
++			} else {
++				av_packet_unref(m_packet);
++			}
++		}
++
++		if (m_packet->size != 0) {
++			ret = avcodec_send_packet(m_codec_ctx, m_packet);
++			if (ret < 0) {
++				if (ret != AVERROR(EAGAIN)) {
+ 					SetError("Error reading from the audio source", ret);
+ 					return false;
+ 				}
+-			}
+-			m_packet0 = m_packet;
+-			if (m_packet.stream_index != m_stream_index) {
+-				m_packet.data = nullptr;
+-				m_packet.size = 0;
+ 			} else {
+-				m_nb_packets++;
++				av_packet_unref(m_packet);
+ 			}
+ 		}
+
+-		ret = avcodec_decode_audio4(m_codec_ctx, m_frame, &m_got_frame, &m_packet);
++		ret = avcodec_receive_frame(m_codec_ctx, m_frame);
+ 		if (ret < 0) {
+-			if (m_decode_error) {
+-				SetError("Error decoding audio frame", m_decode_error);
+-				return false;
++			if (ret == AVERROR_EOF) {
++				m_has_more_frames = false;
++			} else if (ret == AVERROR(EAGAIN)) {
++				if (m_has_more_packets) {
++					needs_packet = true;
++					continue;
++				} else {
++					m_has_more_frames = false;
++				}
+ 			}
+-			m_decode_error = ret;
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			continue;
++			SetError("Error decoding the audio source", ret);
++			return false;
+ 		}
+
+-		break;
+-	}
+-
+-	m_decode_error = 0;
+-
+-	const int decoded = std::min(ret, m_packet.size);
+-	m_packet.data += decoded;
+-	m_packet.size -= decoded;
+-
+-	if (m_got_frame) {
+-		if (m_converter) {
+-			if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
+-				int linsize;
+-				av_freep(&m_convert_buffer[0]);
+-				m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
+-				ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
+-				if (ret < 0) {
+-					SetError("Couldn't allocate audio converter buffer", ret);
++		if (m_frame->nb_samples > 0) {
++			if (m_converter) {
++				if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
++					int linsize;
++					av_freep(&m_convert_buffer[0]);
++					m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
++					ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->ch_layout.nb_channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
++					if (ret < 0) {
++						SetError("Couldn't allocate audio converter buffer", ret);
++						return false;
++					}
++				}
++				auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
++				if (nb_samples < 0) {
++					SetError("Couldn't convert audio", ret);
+ 					return false;
+ 				}
+-			}
+-			auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			}
+-			*data = (const int16_t *) m_convert_buffer[0];
+-			*size = nb_samples;
+-		} else {
+-			*data = (const int16_t *) m_frame->data[0];
+-			*size = m_frame->nb_samples;
+-		}
+-	} else {
+-		if (m_finished && m_converter) {
+-			auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			} else if (nb_samples > 0) {
+-				m_got_frame = 1;
+ 				*data = (const int16_t *) m_convert_buffer[0];
+ 				*size = nb_samples;
++			} else {
++				*data = (const int16_t *) m_frame->data[0];
++				*size = m_frame->nb_samples;
++			}
++		} else {
++			if (m_converter) {
++				if (IsFinished()) {
++					auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
++					if (nb_samples < 0) {
++						SetError("Couldn't convert audio", ret);
++						return false;
++					} else if (nb_samples > 0) {
++						*data = (const int16_t *) m_convert_buffer[0];
++						*size = nb_samples;
++					}
++				}
+ 			}
+ 		}
+-	}
+
+-	return true;
++		return true;
++	}
+ }
+
+ inline void FFmpegAudioReader::SetError(const char *message, int errnum) {
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index a2b517b..123e643 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -38,6 +38,12 @@ set(SRCS
+
+ if(BUILD_TOOLS)
+ 	set(SRCS ${SRCS} ../src/audio/ffmpeg_audio_reader_test.cpp)
++    include_directories(
++        ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}
++        ${AUDIO_PROCESSOR_INCLUDE_DIRS}
++    )
+ 	link_libraries(fpcalc_libs)
+ endif()
+
+-- 
+2.38.1
+
+
diff --git a/srcpkgs/chromaprint/template b/srcpkgs/chromaprint/template
index 7ef7838949f3..1f7bbc70a22c 100644
--- a/srcpkgs/chromaprint/template
+++ b/srcpkgs/chromaprint/template
@@ -1,7 +1,7 @@
 # Template file for 'chromaprint'
 pkgname=chromaprint
 version=1.5.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DBUILD_TOOLS=ON"
 make_check_target="check"

From 1c6da6d1d2cf6bafddd5d947c6c9d44e5ea9e728 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 024/113] chromium: revbump for ffmpeg-6.0

---
 .../patches/chromium-93-ffmpeg-4.4.patch      | 36 --------------
 srcpkgs/chromium/patches/ffmpeg5.patch        | 47 +++++++++++++++++++
 srcpkgs/chromium/template                     |  2 +-
 3 files changed, 48 insertions(+), 37 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch
 create mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch b/srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch
deleted file mode 100644
index f0ec736f98bc..000000000000
--- a/srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch
+++ /dev/null
@@ -1,36 +0,0 @@
-diff --git a/media/filters/ffmpeg_demuxer.cc b/media/filters/ffmpeg_demuxer.cc
-index ac4713b07268..492a9a37d096 100644
---- a/media/filters/ffmpeg_demuxer.cc
-+++ b/media/filters/ffmpeg_demuxer.cc
-@@ -427,11 +427,11 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
-   scoped_refptr<DecoderBuffer> buffer;
- 
-   if (type() == DemuxerStream::TEXT) {
--    size_t id_size = 0;
-+    int id_size = 0;
-     uint8_t* id_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
- 
--    size_t settings_size = 0;
-+    int settings_size = 0;
-     uint8_t* settings_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
- 
-@@ -443,7 +443,7 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
-     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
-                                      side_data.data(), side_data.size());
-   } else {
--    size_t side_data_size = 0;
-+    int side_data_size = 0;
-     uint8_t* side_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
- 
-@@ -504,7 +504,7 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
-                                        packet->size - data_offset);
-     }
- 
--    size_t skip_samples_size = 0;
-+    int skip_samples_size = 0;
-     const uint32_t* skip_samples_ptr =
-         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
-             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..24e2da38e34c
--- /dev/null
+++ b/srcpkgs/chromium/patches/ffmpeg5.patch
@@ -0,0 +1,47 @@
+--- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
++++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
+@@ -92,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+-  if (stream->start_time != kNoFFmpegTimestamp)
++  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -1597,7 +1585,7 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+@@ -1618,7 +1606,7 @@
+     if (stream->type() != DemuxerStream::VIDEO)
+       continue;
+ 
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+ 
+     if (!stream->IsEnabled())
diff --git a/srcpkgs/chromium/template b/srcpkgs/chromium/template
index b4a39dfd3815..c29453cd1f50 100644
--- a/srcpkgs/chromium/template
+++ b/srcpkgs/chromium/template
@@ -2,7 +2,7 @@
 pkgname=chromium
 # See https://chromiumdash.appspot.com/releases?platform=Linux for the latest version
 version=114.0.5735.106
-revision=1
+revision=2
 archs="i686* x86_64* aarch64* armv7l*"
 hostmakedepends="
  $(vopt_if clang "clang lld llvm15")

From a2d6b14b4272b17888d709d2ba8eabcf91529cb1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 025/113] cmus: revbump for ffmpeg-6.0

---
 srcpkgs/cmus/patches/ffmpeg6.patch | 12 ++++++++++++
 srcpkgs/cmus/template              |  2 +-
 2 files changed, 13 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/cmus/patches/ffmpeg6.patch

diff --git a/srcpkgs/cmus/patches/ffmpeg6.patch b/srcpkgs/cmus/patches/ffmpeg6.patch
new file mode 100644
index 000000000000..ffa95ab81110
--- /dev/null
+++ b/srcpkgs/cmus/patches/ffmpeg6.patch
@@ -0,0 +1,12 @@
+--- a/ip/ffmpeg.c
++++ b/ip/ffmpeg.c
+@@ -202,9 +202,6 @@ static int ffmpeg_open(struct input_plugin_data *ip_data)
+ 			break;
+ 		}
+ 
+-		if (codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+-			cc->flags |= AV_CODEC_FLAG_TRUNCATED;
+-
+ 		if (avcodec_open2(cc, codec, NULL) < 0) {
+ 			d_print("could not open codec: %d, %s\n", cc->codec_id, avcodec_get_name(cc->codec_id));
+ 			err = -IP_ERROR_UNSUPPORTED_FILE_TYPE;
diff --git a/srcpkgs/cmus/template b/srcpkgs/cmus/template
index 0fcb424ce336..05b77d0fecae 100644
--- a/srcpkgs/cmus/template
+++ b/srcpkgs/cmus/template
@@ -1,7 +1,7 @@
 # Template file for 'cmus'
 pkgname=cmus
 version=2.10.0
-revision=1
+revision=2
 build_style=configure
 configure_args="prefix=/usr LD=$CC"
 hostmakedepends="pkg-config"

From b55280f16d6a828267eeb799c0e6ccc435da8490 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 026/113] cyanrip: revbump for ffmpeg-6.0

---
 srcpkgs/cyanrip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cyanrip/template b/srcpkgs/cyanrip/template
index 9796e3461601..5db30e020d17 100644
--- a/srcpkgs/cyanrip/template
+++ b/srcpkgs/cyanrip/template
@@ -1,7 +1,7 @@
 # Template file for 'cyanrip'
 pkgname=cyanrip
 version=0.9.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config"
 makedepends="ffmpeg-devel libcdio-devel libcdio-paranoia-devel libcurl-devel libmusicbrainz5-devel"

From 800906a10adf795f982b438446e34b3f3224026b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 027/113] deadbeef: revbump for ffmpeg4-4.4.3

---
 srcpkgs/deadbeef/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/deadbeef/template b/srcpkgs/deadbeef/template
index b664bb1b9bd9..165b3c7b9cad 100644
--- a/srcpkgs/deadbeef/template
+++ b/srcpkgs/deadbeef/template
@@ -1,14 +1,14 @@
 # Template file for 'deadbeef'
 pkgname=deadbeef
 version=1.8.8
-revision=1
+revision=2
 create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-oss --disable-lfm --disable-notify --disable-gtk2"
 hostmakedepends="automake libtool gettext gettext-devel intltool pkg-config
  yasm clang glib-devel"
 makedepends="
- alsa-lib-devel dbus-devel faad2-devel ffmpeg-devel gtk+3-devel imlib2-devel
+ alsa-lib-devel dbus-devel faad2-devel ffmpeg4-devel gtk+3-devel imlib2-devel
  jansson-devel libcddb-devel libcdio-devel libcurl-devel libflac-devel
  libmad-devel libpng-devel libsamplerate-devel libsndfile-devel libvorbis-devel
  libzip-devel mpg123-devel opusfile-devel pulseaudio-devel wavpack-devel"

From 8dd109c892c872c5e84531070a9e769e4701d707 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 028/113] dolphin-emu: revbump for ffmpeg-6.0

---
 srcpkgs/dolphin-emu/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/dolphin-emu/template b/srcpkgs/dolphin-emu/template
index 7ea197ceb2a8..7aeb0a5b645e 100644
--- a/srcpkgs/dolphin-emu/template
+++ b/srcpkgs/dolphin-emu/template
@@ -1,7 +1,7 @@
 # Template file for 'dolphin-emu'
 pkgname=dolphin-emu
 version=5.0.16101
-revision=1
+revision=2
 _dolphin_commit=8ecfa537a242de74d2e372e30d9d79b14584b2fb
 _mgba_commit=40d4c430fc36caeb7ea32fd39624947ed487d2f2
 #Version/hash pair can be found at https://dolphin-emu.org/download/

From dd30734a002ffd50973935315d955b5e39f7a58b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 029/113] droidcam-obs-plugin: revbump for ffmpeg-6.0

---
 srcpkgs/droidcam-obs-plugin/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam-obs-plugin/template b/srcpkgs/droidcam-obs-plugin/template
index fc9c9bf6b9d5..fb0480754df4 100644
--- a/srcpkgs/droidcam-obs-plugin/template
+++ b/srcpkgs/droidcam-obs-plugin/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam-obs-plugin'
 pkgname=droidcam-obs-plugin
 version=2.0.1
-revision=1
+revision=2
 build_style=gnu-makefile
 make_use_env=yes
 make_build_args="ALLOW_STATIC=no"

From 66a4cfc1088c4ad81fd0027ea0de3189d78bf230 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 030/113] droidcam: revbump for ffmpeg-6.0

---
 srcpkgs/droidcam/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam/template b/srcpkgs/droidcam/template
index 1c3f1b8b1fc6..32a9220b79a4 100644
--- a/srcpkgs/droidcam/template
+++ b/srcpkgs/droidcam/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam'
 pkgname=droidcam
 version=1.8.2
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="USBMUXD=-lusbmuxd-2.0 JPEG=-lturbojpeg"
 hostmakedepends="pkg-config"

From 0ca5ac90f8c2ab9c675aa9d4938db2f3b230d6bb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 031/113] ffmpegthumbnailer: revbump for ffmpeg-6.0

---
 .../ffmpegthumbnailer/patches/ffmpeg6.patch   | 202 ++++++++++++++++++
 srcpkgs/ffmpegthumbnailer/template            |   6 +-
 2 files changed, 205 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch

diff --git a/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
new file mode 100644
index 000000000000..363ff35a2841
--- /dev/null
+++ b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
@@ -0,0 +1,202 @@
+--- a/libffmpegthumbnailer/moviedecoder.cpp	2017-11-21 14:06:57.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.cpp	2023-05-05 13:14:47.946560668 -0400
+@@ -41,11 +41,6 @@
+ namespace ffmpegthumbnailer
+ {
+ 
+-struct SilenceLogLevel
+-{
+-    SilenceLogLevel() { av_log_set_level(AV_LOG_QUIET); }
+-};
+-
+ MovieDecoder::MovieDecoder(AVFormatContext* pavContext)
+ : m_VideoStream(-1)
+ , m_pFormatContext(pavContext)
+@@ -70,8 +65,6 @@
+ 
+ void MovieDecoder::initialize(const string& filename, bool preferEmbeddedMetadata)
+ {
+-    av_register_all();
+-    avcodec_register_all();
+     avformat_network_init();
+ 
+     string inputFile = filename == "-" ? "pipe:" : filename;
+@@ -97,8 +90,7 @@
+ {
+     if (m_pVideoCodecContext)
+     {
+-        avcodec_close(m_pVideoCodecContext);
+-        m_pVideoCodecContext = nullptr;
++        avcodec_free_context(&m_pVideoCodecContext);
+     }
+ 
+     if ((!m_FormatContextWasGiven) && m_pFormatContext)
+@@ -152,10 +144,10 @@
+     for (unsigned int i = 0; i < m_pFormatContext->nb_streams; ++i)
+     {
+         AVStream *stream = m_pFormatContext->streams[i];
+-        auto ctx = m_pFormatContext->streams[i]->codec;
+-        if (ctx->codec_type == AVMEDIA_TYPE_VIDEO)
++        auto par = m_pFormatContext->streams[i]->codecpar;
++        if (par->codec_type == AVMEDIA_TYPE_VIDEO)
+         {
+-            if (!preferEmbeddedMetadata || !isStillImageCodec(ctx->codec_id))
++            if (!preferEmbeddedMetadata || !isStillImageCodec(par->codec_id))
+             {
+                 videoStreams.push_back(i);
+                 continue;
+@@ -203,8 +195,7 @@
+     }
+ 
+     m_pVideoStream = m_pFormatContext->streams[m_VideoStream];
+-    m_pVideoCodecContext = m_pVideoStream->codec;
+-    m_pVideoCodec = avcodec_find_decoder(m_pVideoCodecContext->codec_id);
++    m_pVideoCodec = avcodec_find_decoder(m_pVideoStream->codecpar->codec_id);
+ 
+     if (m_pVideoCodec == nullptr)
+     {
+@@ -214,6 +205,20 @@
+         throw logic_error("Video Codec not found");
+     }
+ 
++    m_pVideoCodecContext = avcodec_alloc_context3(m_pVideoCodec);
++
++    if (m_pVideoCodecContext == nullptr)
++    {
++        destroy();
++        throw logic_error("Could not allocate video codec context");
++    }
++
++    if (avcodec_parameters_to_context(m_pVideoCodecContext, m_pVideoStream->codecpar) < 0)
++    {
++        destroy();
++        throw logic_error("Could not configure video codec context");
++    }
++
+     m_pVideoCodecContext->workaround_bugs = 1;
+ 
+     if (avcodec_open2(m_pVideoCodecContext, m_pVideoCodec, nullptr) < 0)
+@@ -386,13 +391,6 @@
+ 
+ void MovieDecoder::initializeFilterGraph(const AVRational& timeBase, const std::string& size, bool maintainAspectRatio)
+ {
+-    static const AVPixelFormat pixelFormats[] = { AV_PIX_FMT_RGB24, AV_PIX_FMT_NONE };
+-
+-    auto del = [] (AVBufferSinkParams* p) { av_freep(p); };
+-    std::unique_ptr<AVBufferSinkParams, decltype(del)> buffersinkParams(av_buffersink_params_alloc(), del);
+-
+-    avfilter_register_all();
+-
+     m_pFilterGraph = avfilter_graph_alloc();
+     assert(m_pFilterGraph);
+ 
+@@ -404,10 +402,8 @@
+ 
+     checkRc(avfilter_graph_create_filter(&m_pFilterSource, avfilter_get_by_name("buffer"), "thumb_buffer", ss.str().c_str(), nullptr, m_pFilterGraph),
+             "Failed to create filter source");
+-    buffersinkParams->pixel_fmts = pixelFormats;
+-    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, buffersinkParams.get(), m_pFilterGraph),
++    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, nullptr, m_pFilterGraph),
+             "Failed to create filter sink");
+-    buffersinkParams.release();
+ 
+     AVFilterContext* yadifFilter = nullptr;
+     if (m_pFrame->interlaced_frame != 0)
+@@ -500,15 +496,15 @@
+     }
+ 
+     checkRc(av_seek_frame(m_pFormatContext, -1, timestamp, 0), "Seeking in video failed");
+-    avcodec_flush_buffers(m_pFormatContext->streams[m_VideoStream]->codec);
++    avcodec_flush_buffers(m_pVideoCodecContext);
+ 
+     int keyFrameAttempts = 0;
+-    bool gotFrame = 0;
++    bool gotFrame;
+ 
+     do
+     {
+         int count = 0;
+-        gotFrame = 0;
++        gotFrame = false;
+ 
+         while (!gotFrame && count < 20)
+         {
+@@ -552,17 +548,33 @@
+         return false;
+     }
+ 
+-    av_frame_unref(m_pFrame);
+-
+-    int frameFinished;
++    int rc = avcodec_send_packet(m_pVideoCodecContext, m_pPacket);
++    if(rc == AVERROR(EAGAIN))
++    {
++        rc = 0;
++    }
+ 
+-    int bytesDecoded = avcodec_decode_video2(m_pVideoCodecContext, m_pFrame, &frameFinished, m_pPacket);
+-    if (bytesDecoded < 0)
++    if(rc == AVERROR_EOF)
++    {
++        return false;
++    }
++    else if(rc < 0)
+     {
+-        throw logic_error("Failed to decode video frame: bytesDecoded < 0");
++        throw logic_error("Failed to decode video frame: avcodec_send_packet() < 0");
+     }
+ 
+-    return frameFinished > 0;
++    rc = avcodec_receive_frame(m_pVideoCodecContext, m_pFrame);
++    switch(rc)
++    {
++        case 0:
++            return true;
++
++        case AVERROR(EAGAIN):
++            return false;
++
++        default:
++            throw logic_error("Failed to decode video frame: avcodec_receive_frame() < 0");
++    }
+ }
+ 
+ bool MovieDecoder::getVideoPacket()
+@@ -570,8 +582,6 @@
+     bool framesAvailable = true;
+     bool frameDecoded = false;
+ 
+-    int attempts = 0;
+-
+     if (m_pPacket)
+     {
+         av_packet_unref(m_pPacket);
+@@ -580,6 +590,7 @@
+ 
+     m_pPacket = new AVPacket();
+ 
++
+     while (framesAvailable && !frameDecoded)
+     {
+         framesAvailable = av_read_frame(m_pFormatContext, m_pPacket) >= 0;
+@@ -644,7 +655,7 @@
+ 
+ int32_t MovieDecoder::getStreamRotation()
+ {
+-    int32_t* matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
++    auto matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
+     if (matrix)
+     {
+         auto angle = lround(av_display_rotation_get(matrix));
+
+--- a/libffmpegthumbnailer/moviedecoder.h	2017-11-12 04:23:38.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.h	2023-05-05 13:26:07.095529911 -0400
+@@ -78,7 +78,7 @@
+     int                     m_VideoStream;
+     AVFormatContext*        m_pFormatContext;
+     AVCodecContext*         m_pVideoCodecContext;
+-    AVCodec*                m_pVideoCodec;
++    const AVCodec*          m_pVideoCodec;
+     AVFilterGraph*          m_pFilterGraph;
+     AVFilterContext*        m_pFilterSource;
+     AVFilterContext*        m_pFilterSink;
diff --git a/srcpkgs/ffmpegthumbnailer/template b/srcpkgs/ffmpegthumbnailer/template
index 039eea7622b3..35d546018d12 100644
--- a/srcpkgs/ffmpegthumbnailer/template
+++ b/srcpkgs/ffmpegthumbnailer/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbnailer'
 pkgname=ffmpegthumbnailer
 version=2.2.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libpng-devel libjpeg-turbo-devel ffmpeg-devel"
@@ -9,8 +9,8 @@ depends="ffmpeg"
 short_desc="Lightweight video thumbnailer"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
-homepage="https://github.com/dirkvdb/${pkgname}"
-distfiles="${homepage}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
+homepage="https://github.com/dirkvdb"
+distfiles="${homepage}/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
 checksum=1cb24059c38223f657b300c84dd80491b7040d4b69471c4fea69be862bc99b5b
 
 post_install() {

From 95cfc4ff7f2df5015541365b4e63bcbd81b0c633 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 032/113] ffmpegthumbs: revbump for ffmpeg-6.0

---
 srcpkgs/ffmpegthumbs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ffmpegthumbs/template b/srcpkgs/ffmpegthumbs/template
index 5f0b9414dada..11b88193528f 100644
--- a/srcpkgs/ffmpegthumbs/template
+++ b/srcpkgs/ffmpegthumbs/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbs'
 pkgname=ffmpegthumbs
 version=22.12.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules kcoreaddons kconfig-devel
  pkg-config qt5-host-tools qt5-qmake gettext"

From 96cbfd395949478b017fe42072d30f7a7e2cf12f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 033/113] ffms2: revbump for ffmpeg-6.0

---
 srcpkgs/ffms2/patches/ffmpeg5.patch | 424 ++++++++++++++++++++++++++++
 srcpkgs/ffms2/template              |   2 +-
 2 files changed, 425 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ffms2/patches/ffmpeg5.patch

diff --git a/srcpkgs/ffms2/patches/ffmpeg5.patch b/srcpkgs/ffms2/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..1479fabcafcb
--- /dev/null
+++ b/srcpkgs/ffms2/patches/ffmpeg5.patch
@@ -0,0 +1,424 @@
+From 45673149e9a2f5586855ad472e3059084eaa36b1 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:41:21 +0100
+Subject: [PATCH] Use auto for AVCodec
+
+The geniuses over at FFmpeg decided to constify this API, so old
+versions of the library will return AVCodec *, while new versions
+of the libary will return const AVCodec *, which, in C++, are not
+OK to convert between.
+
+Rather than use some macro hell in ffmscompat.h, we can work around
+this by using auto.
+
+Gross.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 2 +-
+ src/core/indexing.cpp    | 6 +++---
+ src/core/videosource.cpp | 2 +-
+ 3 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index e4ce97c..ac09666 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -469,7 +469,7 @@ void FFMS_AudioSource::OpenFile() {
+ 
+     LAVFOpenFile(SourceFile.c_str(), FormatContext, TrackNumber);
+ 
+-    AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
++    auto *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
+     if (Codec == nullptr)
+         throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+             "Audio codec not found");
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index e547c5a..59fb4e8 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -384,7 +384,7 @@ FFMS_TrackType FFMS_Indexer::GetTrackType(int Track) {
+ }
+ 
+ const char *FFMS_Indexer::GetTrackCodec(int Track) {
+-    AVCodec *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
++    auto *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
+     return codec ? codec->name : nullptr;
+ }
+ 
+@@ -402,7 +402,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             UseDTS);
+ 
+         if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            AVCodec *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (!VideoCodec) {
+                 FormatContext->streams[i]->discard = AVDISCARD_ALL;
+                 IndexMask.erase(i);
+@@ -433,7 +433,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 IndexMask.insert(i);
+             }
+         } else if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+-            AVCodec *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (AudioCodec == nullptr)
+                 throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_UNSUPPORTED,
+                     "Audio codec not found");
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index b889970..8956c22 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -171,7 +171,7 @@ FFMS_VideoSource::FFMS_VideoSource(const char *SourceFile, FFMS_Index &Index, in
+ 
+         LAVFOpenFile(SourceFile, FormatContext, VideoTrack);
+ 
+-        AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
++        auto *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
+         if (Codec == nullptr)
+             throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+                 "Video codec not found");
+-- 
+2.40.0
+
+From 96cbf38ea9381829a1314f432a2c60495dcefaad Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:12:41 +0100
+Subject: [PATCH] all: Update AVPacket API usage
+
+AVPackets must all be on the heap now, since it is no longer
+part of the libav* ABI.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 16 ++++++----
+ src/core/indexing.cpp    | 63 ++++++++++++++++++++++------------------
+ src/core/indexing.h      |  4 +--
+ src/core/utils.cpp       |  6 ----
+ src/core/utils.h         |  1 -
+ src/core/videosource.cpp | 30 ++++++++++---------
+ 6 files changed, 64 insertions(+), 56 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index 37cf9ae..e4ce97c 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -285,10 +285,15 @@ FFMS_AudioSource::AudioBlock *FFMS_AudioSource::CacheBlock(CacheIterator &pos) {
+ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     CurrentFrame = &Frames[PacketNumber];
+ 
+-    AVPacket Packet;
+-    if (!ReadPacket(&Packet))
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++    if (!ReadPacket(Packet)) {
++        av_packet_free(&Packet);
+         throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_UNKNOWN,
+             "ReadPacket unexpectedly failed to read a packet");
++    }
+ 
+     // ReadPacket may have changed the packet number
+     CurrentFrame = &Frames[PacketNumber];
+@@ -297,8 +302,9 @@ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     int NumberOfSamples = 0;
+     AudioBlock *CachedBlock = nullptr;
+     
+-    int Ret = avcodec_send_packet(CodecContext, &Packet);
+-    av_packet_unref(&Packet);
++    int Ret = avcodec_send_packet(CodecContext, Packet);
++    av_packet_unref(Packet);
++    av_packet_free(&Packet);
+ 
+     av_frame_unref(DecodeFrame);
+     Ret = avcodec_receive_frame(CodecContext, DecodeFrame);
+@@ -513,8 +519,6 @@ void FFMS_AudioSource::Seek() {
+ }
+ 
+ bool FFMS_AudioSource::ReadPacket(AVPacket *Packet) {
+-    InitNullPacket(*Packet);
+-
+     while (av_read_frame(FormatContext, Packet) >= 0) {
+         if (Packet->stream_index == TrackNumber) {
+             // Required because not all audio packets, especially in ogg, have a pts. Use the previous valid packet's pts instead.
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index 23fb95b..e547c5a 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -320,7 +320,7 @@ void FFMS_Indexer::CheckAudioProperties(int Track, AVCodecContext *Context) {
+     }
+ }
+ 
+-void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict,
++void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict,
+                                     int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct) {
+     if (VideoContext.Parser) {
+         uint8_t *OB;
+@@ -330,8 +330,8 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+         av_parser_parse2(VideoContext.Parser,
+             VideoContext.CodecContext,
+             &OB, &OBSize,
+-            pkt.data, pkt.size,
+-            pkt.pts, pkt.dts, pkt.pos);
++            pkt->data, pkt->size,
++            pkt->pts, pkt->dts, pkt->pos);
+ 
+         // H.264 (PAFF) and HEVC may have one field per packet, so we need to track
+         // when we have a full or half frame available, and mark one of them as
+@@ -351,15 +351,15 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+ 
+         *RepeatPict = VideoContext.Parser->repeat_pict;
+         *FrameType = VideoContext.Parser->pict_type;
+-        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt.flags & AV_PKT_FLAG_DISCARD));
++        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt->flags & AV_PKT_FLAG_DISCARD));
+     } else {
+-        *Invisible = !!(pkt.flags & AV_PKT_FLAG_DISCARD);
++        *Invisible = !!(pkt->flags & AV_PKT_FLAG_DISCARD);
+     }
+ 
+     if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP8)
+-        ParseVP8(pkt.data[0], Invisible, FrameType);
++        ParseVP8(pkt->data[0], Invisible, FrameType);
+     else if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP9)
+-        ParseVP9(pkt.data[0], Invisible, FrameType);
++        ParseVP9(pkt->data[0], Invisible, FrameType);
+ }
+ 
+ void FFMS_Indexer::Free() {
+@@ -458,32 +458,36 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+         }
+     }
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
+     std::vector<int64_t> LastValidTS(FormatContext->nb_streams, AV_NOPTS_VALUE);
+ 
+     int64_t filesize = avio_size(FormatContext->pb);
+     enum AVPictureStructure LastPicStruct = AV_PICTURE_STRUCTURE_UNKNOWN;
+-    while (av_read_frame(FormatContext, &Packet) >= 0) {
++    while (av_read_frame(FormatContext, Packet) >= 0) {
+         // Update progress
+         // FormatContext->pb can apparently be NULL when opening images.
+         if (IC && FormatContext->pb) {
+-            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate))
++            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate)) {
++                av_packet_free(&Packet);
+                 throw FFMS_Exception(FFMS_ERROR_CANCELLED, FFMS_ERROR_USER,
+                     "Cancelled by user");
++            }
+         }
+-        if (!IndexMask.count(Packet.stream_index)) {
+-            av_packet_unref(&Packet);
++        if (!IndexMask.count(Packet->stream_index)) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+-        int Track = Packet.stream_index;
++        int Track = Packet->stream_index;
+         FFMS_Track &TrackInfo = (*TrackIndices)[Track];
+-        bool KeyFrame = !!(Packet.flags & AV_PKT_FLAG_KEY);
++        bool KeyFrame = !!(Packet->flags & AV_PKT_FLAG_KEY);
+         ReadTS(Packet, LastValidTS[Track], (*TrackIndices)[Track].UseDTS);
+ 
+         if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            int64_t PTS = TrackInfo.UseDTS ? Packet.dts : Packet.pts;
++            int64_t PTS = TrackInfo.UseDTS ? Packet->dts : Packet->pts;
+             if (PTS == AV_NOPTS_VALUE) {
+                 // VPx alt-refs are output as packets which lack timestmps or durations, since
+                 // they are invisible. Currently, the timestamp mangling code in libavformat
+@@ -495,9 +499,11 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 // FFMS2 currently sorts packets by PTS, which will break decoding, otherwise.
+                 bool HasAltRefs = (FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP8 ||
+                                    FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP9);
+-                if (Packet.duration == 0 && !HasAltRefs)
++                if (Packet->duration == 0 && !HasAltRefs) {
++                    av_packet_free(&Packet);
+                     throw FFMS_Exception(FFMS_ERROR_INDEXING, FFMS_ERROR_PARSER,
+                         "Invalid packet pts, dts, and duration");
++                }
+ 
+                 if (TrackInfo.empty())
+                     PTS = 0;
+@@ -513,7 +519,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             ParseVideoPacket(AVContexts[Track], Packet, &RepeatPict, &FrameType, &Invisible, &LastPicStruct);
+ 
+             TrackInfo.AddVideoFrame(PTS, RepeatPict, KeyFrame,
+-                FrameType, Packet.pos, Invisible);
++                FrameType, Packet->pos, Invisible);
+         } else if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+             // For video seeking timestamps are used only if all packets have
+             // timestamps, while for audio they're used if any have timestamps,
+@@ -522,28 +528,29 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 TrackInfo.HasTS = true;
+ 
+             int64_t StartSample = AVContexts[Track].CurrentSample;
+-            uint32_t SampleCount = IndexAudioPacket(Track, &Packet, AVContexts[Track], *TrackIndices);
++            uint32_t SampleCount = IndexAudioPacket(Track, Packet, AVContexts[Track], *TrackIndices);
+             TrackInfo.SampleRate = AVContexts[Track].CodecContext->sample_rate;
+ 
+             TrackInfo.AddAudioFrame(LastValidTS[Track],
+-                StartSample, SampleCount, KeyFrame, Packet.pos, Packet.flags & AV_PKT_FLAG_DISCARD);
++                StartSample, SampleCount, KeyFrame, Packet->pos, Packet->flags & AV_PKT_FLAG_DISCARD);
+         }
+ 
+-        if (!(Packet.flags & AV_PKT_FLAG_DISCARD))
+-            TrackInfo.LastDuration = Packet.duration;
++        if (!(Packet->flags & AV_PKT_FLAG_DISCARD))
++            TrackInfo.LastDuration = Packet->duration;
+ 
+-        av_packet_unref(&Packet);
++        av_packet_unref(Packet);
+     }
++    av_packet_free(&Packet);
+ 
+     TrackIndices->Finalize(AVContexts, FormatContext->iformat->name);
+     return TrackIndices.release();
+ }
+ 
+-void FFMS_Indexer::ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS) {
+-    if (!UseDTS && Packet.pts != AV_NOPTS_VALUE)
+-        TS = Packet.pts;
++void FFMS_Indexer::ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS) {
++    if (!UseDTS && Packet->pts != AV_NOPTS_VALUE)
++        TS = Packet->pts;
+     if (TS == AV_NOPTS_VALUE)
+         UseDTS = true;
+-    if (UseDTS && Packet.dts != AV_NOPTS_VALUE)
+-        TS = Packet.dts;
++    if (UseDTS && Packet->dts != AV_NOPTS_VALUE)
++        TS = Packet->dts;
+ }
+diff --git a/src/core/indexing.h b/src/core/indexing.h
+index 3cfc3c3..5c06868 100644
+--- a/src/core/indexing.h
++++ b/src/core/indexing.h
+@@ -80,10 +80,10 @@ private:
+     int64_t Filesize;
+     uint8_t Digest[20];
+ 
+-    void ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS);
++    void ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS);
+     void CheckAudioProperties(int Track, AVCodecContext *Context);
+     uint32_t IndexAudioPacket(int Track, AVPacket *Packet, SharedAVContext &Context, FFMS_Index &TrackIndices);
+-    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
++    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
+     void Free();
+ public:
+     FFMS_Indexer(const char *Filename);
+diff --git a/src/core/utils.cpp b/src/core/utils.cpp
+index ce67533..8a2e997 100644
+--- a/src/core/utils.cpp
++++ b/src/core/utils.cpp
+@@ -62,12 +62,6 @@ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo) {
+     }
+ }
+ 
+-void InitNullPacket(AVPacket &pkt) {
+-    av_init_packet(&pkt);
+-    pkt.data = nullptr;
+-    pkt.size = 0;
+-}
+-
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames) {
+     AP.SampleFormat = static_cast<FFMS_SampleFormat>(av_get_packed_sample_fmt(CTX->sample_fmt));
+     AP.BitsPerSample = av_get_bytes_per_sample(CTX->sample_fmt) * 8;
+diff --git a/src/core/utils.h b/src/core/utils.h
+index 9819dc7..003ab79 100644
+--- a/src/core/utils.h
++++ b/src/core/utils.h
+@@ -58,7 +58,6 @@ std::unique_ptr<T> make_unique(Args&&... args) {
+ }
+ 
+ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo);
+-void InitNullPacket(AVPacket &pkt);
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames);
+ 
+ void LAVFOpenFile(const char *SourceFile, AVFormatContext *&FormatContext, int Track);
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index 06bd161..b889970 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -673,30 +673,34 @@ void FFMS_VideoSource::DecodeNextFrame(int64_t &AStartTime, int64_t &Pos) {
+     if (HasPendingDelayedFrames())
+         return;
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
+-
+-    while (ReadFrame(&Packet) >= 0) {
+-        if (Packet.stream_index != VideoTrack) {
+-            av_packet_unref(&Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++
++    while (ReadFrame(Packet) >= 0) {
++        if (Packet->stream_index != VideoTrack) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+         if (AStartTime < 0)
+-            AStartTime = Frames.UseDTS ? Packet.dts : Packet.pts;
++            AStartTime = Frames.UseDTS ? Packet->dts : Packet->pts;
+ 
+         if (Pos < 0)
+-            Pos = Packet.pos;
++            Pos = Packet->pos;
+ 
+-        bool FrameFinished = DecodePacket(&Packet);
+-        av_packet_unref(&Packet);
+-        if (FrameFinished)
++        bool FrameFinished = DecodePacket(Packet);
++        av_packet_unref(Packet);
++        if (FrameFinished) {
++            av_packet_free(&Packet);
+             return;
++        }
+     }
+ 
+     // Flush final frames
+-    InitNullPacket(Packet);
+-    DecodePacket(&Packet);
++    DecodePacket(Packet);
++    av_packet_free(&Packet);
+ }
+ 
+ bool FFMS_VideoSource::SeekTo(int n, int SeekOffset) {
+-- 
+2.40.0
+
+From bf9e03e9e08534c024e5a744a6437c4aac160201 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:20:47 +0100
+Subject: [PATCH 2/3] configure: Remove deprecated API use
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ configure.ac | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index b35ef80bc..d19714d0f 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -102,10 +102,10 @@ CFLAGS="$_CFLAGS $FFMPEG_CFLAGS"
+
+ AC_DEFUN([TEST_FFMPEG],
+          [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+-            #include <libavcodec/avcodec.h>
++            #include <libavformat/avformat.h>
+             #include <libswscale/swscale.h>
+             ]],[[
+-                avcodec_register_all();
++                avformat_network_init();
+                 swscale_version();
+             ]])], [eval $1=yes], [eval $1=no])
+         ])
+
diff --git a/srcpkgs/ffms2/template b/srcpkgs/ffms2/template
index 68e8a0c14bce..2acfadac44b3 100644
--- a/srcpkgs/ffms2/template
+++ b/srcpkgs/ffms2/template
@@ -1,7 +1,7 @@
 # Template file for 'ffms2'
 pkgname=ffms2
 version=2.40
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-shared --disable-static"
 hostmakedepends="pkg-config autoconf automake libtool"

From e874041f3f3354e6d2ec4cd3b335adbae9a02236 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 034/113] freerdp: revbump for ffmpeg-6.0

---
 .../freerdp/patches/ffmpeg6_aa2cb9aa.patch    | 42 +++++++++++++++++++
 srcpkgs/freerdp/template                      |  2 +-
 2 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch

diff --git a/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
new file mode 100644
index 000000000000..a4324da3a882
--- /dev/null
+++ b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
@@ -0,0 +1,42 @@
+From aa2cb9aa5ff5562433598ba168a466e0752bca0e Mon Sep 17 00:00:00 2001
+From: akallabeth <akallabeth@posteo.net>
+Date: Tue, 14 Feb 2023 07:48:54 +0100
+Subject: [PATCH] Fixed #8686: Update h264 to use new FFMPEG API
+
+---
+ channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c | 2 ++
+ libfreerdp/codec/h264_ffmpeg.c            | 2 ++
+ 2 files changed, 4 insertions(+)
+
+diff --git a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+index 339462d865f..beea80b7a1e 100644
+--- a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
++++ b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+@@ -239,8 +239,10 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYP
+ 		}
+ 	}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 	if (mdecoder->codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		mdecoder->codec_context->flags |= AV_CODEC_FLAG_TRUNCATED;
++#endif
+ 
+ 	return TRUE;
+ }
+diff --git a/libfreerdp/codec/h264_ffmpeg.c b/libfreerdp/codec/h264_ffmpeg.c
+index 8a23db2473c..896a333019b 100644
+--- a/libfreerdp/codec/h264_ffmpeg.c
++++ b/libfreerdp/codec/h264_ffmpeg.c
+@@ -615,10 +615,12 @@ static BOOL libavcodec_init(H264_CONTEXT* h264)
+ 			goto EXCEPTION;
+ 		}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 		if (sys->codecDecoder->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		{
+ 			sys->codecDecoderContext->flags |= AV_CODEC_FLAG_TRUNCATED;
+ 		}
++#endif
+ 
+ #ifdef WITH_VAAPI
+ 
diff --git a/srcpkgs/freerdp/template b/srcpkgs/freerdp/template
index 25e8aa9677f0..4d51c8189902 100644
--- a/srcpkgs/freerdp/template
+++ b/srcpkgs/freerdp/template
@@ -1,7 +1,7 @@
 # Template file for 'freerdp'
 pkgname=freerdp
 version=2.10.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_ALSA=ON -DWITH_CUPS=OFF -DWITH_FFMPEG=ON
  -DWITH_GSTREAMER_0_10=OFF -DWITH_GSTREAMER_1_0=OFF -DWITH_JPEG=ON

From 8c88a89ec931b6ea742d7fada33746d1f4e29937 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 035/113] gerbera: revbump for ffmpeg-6.0

---
 srcpkgs/gerbera/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gerbera/template b/srcpkgs/gerbera/template
index ae14f35c767c..2dc0ac0ce03b 100644
--- a/srcpkgs/gerbera/template
+++ b/srcpkgs/gerbera/template
@@ -1,7 +1,7 @@
 # Template file for 'gerbera'
 pkgname=gerbera
 version=1.12.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_SYSTEMD=0 -DWITH_AVCODEC=1"
 hostmakedepends="pkg-config"

From 228fe1e6a1512fdc694bed33de3f6a8d90e1777a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 036/113] goldendict: revbump for ffmpeg-6.0

---
 srcpkgs/goldendict/patches/ffmpeg5.patch | 232 +++++++++++++++++++++++
 srcpkgs/goldendict/template              |   4 +-
 2 files changed, 234 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/goldendict/patches/ffmpeg5.patch

diff --git a/srcpkgs/goldendict/patches/ffmpeg5.patch b/srcpkgs/goldendict/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..7cfc98ada368
--- /dev/null
+++ b/srcpkgs/goldendict/patches/ffmpeg5.patch
@@ -0,0 +1,232 @@
+From 03bbe01b79a1f07a6780cb60f23a087104c5d77b Mon Sep 17 00:00:00 2001
+From: Abs62 <ottomann@yandex.ru>
+Date: Fri, 30 Mar 2018 22:53:24 +0300
+Subject: [PATCH] Fix warnings while compile with FFMpeg 3.4.2 (issue #978)
+
+---
+ ffmpegaudio.cc | 68 +++++++++++++++++++++++++++++++++++++++++++++-----
+ 1 file changed, 62 insertions(+), 6 deletions(-)
+
+diff --git a/ffmpegaudio.cc b/ffmpegaudio.cc
+index ed1172bdd..56e8f788e 100644
+--- a/ffmpegaudio.cc
++++ b/ffmpegaudio.cc
+@@ -91,6 +91,7 @@ struct DecoderContext
+   QByteArray audioData_;
+   QDataStream audioDataStream_;
+   AVFormatContext * formatContext_;
++  AVCodec * codec_;
+   AVCodecContext * codecContext_;
+   AVIOContext * avioContext_;
+   AVStream * audioStream_;
+@@ -114,6 +115,7 @@ DecoderContext::DecoderContext( QByteArray const & audioData, QAtomicInt & isCan
+   audioData_( audioData ),
+   audioDataStream_( audioData_ ),
+   formatContext_( NULL ),
++  codec_( NULL ),
+   codecContext_( NULL ),
+   avioContext_( NULL ),
+   audioStream_( NULL ),
+@@ -143,7 +145,11 @@ bool DecoderContext::openCodec( QString & errorString )
+     return false;
+   }
+
++#if LIBAVCODEC_VERSION_MAJOR < 56 || ( LIBAVCODEC_VERSION_MAJOR == 56 && LIBAVCODEC_VERSION_MINOR < 56 )
+   unsigned char * avioBuffer = ( unsigned char * )av_malloc( kBufferSize + FF_INPUT_BUFFER_PADDING_SIZE );
++#else
++  unsigned char * avioBuffer = ( unsigned char * )av_malloc( kBufferSize + AV_INPUT_BUFFER_PADDING_SIZE );
++#endif
+   if ( !avioBuffer )
+   {
+     errorString = QObject::tr( "av_malloc() failed." );
+@@ -186,7 +192,11 @@ bool DecoderContext::openCodec( QString & errorString )
+   // Find audio stream, use the first audio stream if available
+   for ( unsigned i = 0; i < formatContext_->nb_streams; i++ )
+   {
++#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 33 )
+     if ( formatContext_->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO )
++#else
++      if ( formatContext_->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO )
++#endif
+     {
+       audioStream_ = formatContext_->streams[i];
+       break;
+@@ -198,22 +208,38 @@ bool DecoderContext::openCodec( QString & errorString )
+     return false;
+   }
+
++#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 33 )
+   codecContext_ = audioStream_->codec;
+-  AVCodec * codec = avcodec_find_decoder( codecContext_->codec_id );
+-  if ( !codec )
++  codec_ = avcodec_find_decoder( codecContext_->codec_id );
++  if ( !codec_ )
+   {
+     errorString = QObject::tr( "Codec [id: %1] not found." ).arg( codecContext_->codec_id );
+     return false;
+   }
++#else
++  codec_ = avcodec_find_decoder( audioStream_->codecpar->codec_id );
++  if ( !codec_ )
++  {
++    errorString = QObject::tr( "Codec [id: %1] not found." ).arg( audioStream_->codecpar->codec_id );
++    return false;
++  }
++  codecContext_ = avcodec_alloc_context3( codec_ );
++  if ( !codecContext_ )
++  {
++    errorString = QObject::tr( "avcodec_alloc_context3() failed." );
++    return false;
++  }
++  avcodec_parameters_to_context( codecContext_, audioStream_->codecpar );
++#endif
+
+-  ret = avcodec_open2( codecContext_, codec, NULL );
++  ret = avcodec_open2( codecContext_, codec_, NULL );
+   if ( ret < 0 )
+   {
+     errorString = QObject::tr( "avcodec_open2() failed: %1." ).arg( avErrorString( ret ) );
+     return false;
+   }
+
+-  av_log( NULL, AV_LOG_INFO, "Codec open: %s: channels: %d, rate: %d, format: %s\n", codec->long_name,
++  av_log( NULL, AV_LOG_INFO, "Codec open: %s: channels: %d, rate: %d, format: %s\n", codec_->long_name,
+           codecContext_->channels, codecContext_->sample_rate, av_get_sample_fmt_name( codecContext_->sample_fmt ) );
+   return true;
+ }
+@@ -252,10 +278,13 @@ void DecoderContext::closeCodec()
+
+   // Closing a codec context without prior avcodec_open2() will result in
+   // a crash in ffmpeg
+-  if ( audioStream_ && audioStream_->codec && audioStream_->codec->codec )
++  if ( audioStream_ && codecContext_ && codec_ )
+   {
+     audioStream_->discard = AVDISCARD_ALL;
+-    avcodec_close( audioStream_->codec );
++    avcodec_close( codecContext_ );
++#if LIBAVCODEC_VERSION_MAJOR > 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR >= 33 )
++    avcodec_free_context( &codecContext_ );
++#endif
+   }
+
+   avformat_close_input( &formatContext_ );
+@@ -356,6 +385,7 @@ bool DecoderContext::play( QString & errorString )
+     if ( packet.stream_index == audioStream_->index )
+     {
+       AVPacket pack = packet;
++#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 37 )
+       int gotFrame = 0;
+       do
+       {
+@@ -370,6 +400,19 @@ bool DecoderContext::play( QString & errorString )
+         pack.data += len;
+       }
+       while( pack.size > 0 );
++#else
++      int ret = avcodec_send_packet( codecContext_, &pack );
++      /* read all the output frames (in general there may be any number of them) */
++      while( ret >= 0 )
++      {
++        ret = avcodec_receive_frame( codecContext_, frame);
++
++        if ( Qt4x5::AtomicInt::loadAcquire( isCancelled_ ) || ret < 0 )
++          break;
++
++        playFrame( frame );
++      }
++#endif
+     }
+     // av_free_packet() must be called after each call to av_read_frame()
+ #if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 7 )
+@@ -379,6 +422,7 @@ bool DecoderContext::play( QString & errorString )
+ #endif
+   }
+
++#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 37 )
+   if ( !Qt4x5::AtomicInt::loadAcquire( isCancelled_ ) &&
+        codecContext_->codec->capabilities & CODEC_CAP_DELAY )
+   {
+@@ -391,6 +435,18 @@ bool DecoderContext::play( QString & errorString )
+       playFrame( frame );
+     }
+   }
++#else
++  /* flush the decoder */
++  av_init_packet( &packet );
++  int ret = avcodec_send_packet(codecContext_, &packet );
++  while( ret >= 0 )
++  {
++    ret = avcodec_receive_frame(codecContext_, frame);
++    if ( Qt4x5::AtomicInt::loadAcquire( isCancelled_ ) || ret < 0 )
++      break;
++    playFrame( frame );
++  }
++#endif
+
+ #if LIBAVCODEC_VERSION_MAJOR < 54
+   av_free( frame );
+32
+srcpkgs/goldendict/patches/ffmpeg5-2.patch
+Comment on this file
+@@ -0,0 +1,32 @@
+From 966f4a8b78e6324b930e5a50f2bb930bd87e565e Mon Sep 17 00:00:00 2001
+From: Abs62 <ottomann@yandex.ru>
+Date: Fri, 27 Sep 2019 17:00:52 +0300
+Subject: [PATCH] FFmpeg player: Fix some crashes on broken files
+
+---
+ ffmpegaudio.cc | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/ffmpegaudio.cc b/ffmpegaudio.cc
+index 56e8f788e..415fc79cb 100644
+--- a/ffmpegaudio.cc
++++ b/ffmpegaudio.cc
+@@ -51,7 +51,9 @@ AudioService & AudioService::instance()
+
+ AudioService::AudioService()
+ {
++#if LIBAVFORMAT_VERSION_MAJOR < 58 || ( LIBAVFORMAT_VERSION_MAJOR == 58 && LIBAVFORMAT_VERSION_MINOR < 9 )
+   av_register_all();
++#endif
+   ao_initialize();
+ }
+
+@@ -438,6 +440,8 @@ bool DecoderContext::play( QString & errorString )
+ #else
+   /* flush the decoder */
+   av_init_packet( &packet );
++  packet.data = NULL;
++  packet.size = 0;
+   int ret = avcodec_send_packet(codecContext_, &packet );
+   while( ret >= 0 )
+   {
+25
+srcpkgs/goldendict/patches/ffmpeg5-3.patch
+Comment on this file
+@@ -0,0 +1,25 @@
+From 8acb288c9e9bdb3c6bf2e803954dd3b6ac273c05 Mon Sep 17 00:00:00 2001
+From: Liao Junxuan <mikeljx@126.com>
+Date: Sun, 20 Feb 2022 12:28:05 +0800
+Subject: [PATCH] add support for ffmpeg 5.0
+
+---
+ ffmpegaudio.cc | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/ffmpegaudio.cc b/ffmpegaudio.cc
+index d550f4a77..7948d2187 100644
+--- a/ffmpegaudio.cc
++++ b/ffmpegaudio.cc
+@@ -94,7 +94,11 @@ struct DecoderContext
+   QByteArray audioData_;
+   QDataStream audioDataStream_;
+   AVFormatContext * formatContext_;
++#if LIBAVCODEC_VERSION_MAJOR < 59
+   AVCodec * codec_;
++#else
++  const AVCodec * codec_;
++#endif
+   AVCodecContext * codecContext_;
+   AVIOContext * avioContext_;
+   AVStream * audioStream_;
diff --git a/srcpkgs/goldendict/template b/srcpkgs/goldendict/template
index f4a05759f693..97f44347b03a 100644
--- a/srcpkgs/goldendict/template
+++ b/srcpkgs/goldendict/template
@@ -1,7 +1,7 @@
 # Template file for 'goldendict'
 pkgname=goldendict
 version=1.5.0
-revision=1
+revision=2
 build_style=qmake
 configure_args="CONFIG+=zim_support goldendict.pro"
 hostmakedepends="qt5-qmake pkg-config qt5-host-tools"
@@ -10,7 +10,7 @@ makedepends="tiff-devel qt5-devel libvorbis-devel zlib-devel
  qt5-webkit-devel lzo-devel bzip2-devel libao-devel qt5-svg-devel
  libeb-devel qt5-x11extras-devel ffmpeg-devel liblzma-devel
  qt5-multimedia-devel"
-short_desc="A feature-rich dictionary lookup program"
+short_desc="Feature-rich dictionary lookup program"
 maintainer="John <me@johnnynator.dev>"
 license="GPL-3.0-or-later"
 homepage="http://goldendict.org/"

From 1092cab70eb702338fcda39458af3075a84989eb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 037/113] gst-libav: revbump for ffmpeg-6.0

---
 srcpkgs/gst-libav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index 8c72fc3e97ee..04c39bff1489 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.22.2
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"

From 795f01f1db35fdd65c2f12c21eb11782b02bf1d7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 038/113] gst-plugins-bad1: revbump for ffmpeg-6.0

---
 srcpkgs/gst-plugins-bad1/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index 77bf79981c20..5c158724a6c7 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-plugins-bad1'
 pkgname=gst-plugins-bad1
 version=1.22.2
-revision=1
+revision=2
 build_helper="gir"
 build_style=meson
 configure_args="-Dpackage-origin=https://voidlinux.org -Ddoc=disabled

From 261cf2c0cf795d208590136485ca25ffb594fe12 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 039/113] gst-rtsp-server: revbump for ffmpeg-6.0

---
 srcpkgs/gst-rtsp-server/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index 2f0c0c45ff82..980fd72cdd4c 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
 version=1.22.2
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="glib-devel gst-plugins-bad1-devel gobject-introspection

From 4ef9daeb5fc8471959e00ed95470411c36df2827 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 040/113] guvcview: update to 2.0.8.

---
 srcpkgs/guvcview/patches/fix-include.patch | 10 ++++++++++
 srcpkgs/guvcview/template                  |  5 ++---
 2 files changed, 12 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/guvcview/patches/fix-include.patch

diff --git a/srcpkgs/guvcview/patches/fix-include.patch b/srcpkgs/guvcview/patches/fix-include.patch
new file mode 100644
index 000000000000..503c2af3b78c
--- /dev/null
+++ b/srcpkgs/guvcview/patches/fix-include.patch
@@ -0,0 +1,10 @@
+--- a/guvcview/guvcview.c
++++ b/guvcview/guvcview.c
+@@ -28,6 +28,7 @@
+ #include <sys/stat.h>
+ #include <sys/resource.h>
+ #include <errno.h>
++#include <locale.h>
+ 
+ #include "gview.h"
+ #include "gviewv4l2core.h"
diff --git a/srcpkgs/guvcview/template b/srcpkgs/guvcview/template
index 345cf6006f24..86a7fd619612 100644
--- a/srcpkgs/guvcview/template
+++ b/srcpkgs/guvcview/template
@@ -1,8 +1,7 @@
 # Template file for 'guvcview'
 pkgname=guvcview
-version=2.0.7
+version=2.0.8
 revision=1
-create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-static --disable-debian-menu"
 hostmakedepends="pkg-config intltool autoconf automake libtool glib-devel"
@@ -14,7 +13,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="http://guvcview.sourceforge.net/"
 distfiles="${SOURCEFORGE_SITE}/${pkgname}/${pkgname}-src-${version}.tar.bz2"
-checksum=f47d51fbd06e44eeaa1a82f4a153c927527c90d94514197a70b2956028cc8ad4
+checksum=a21f4e448286666cf27bafef5290cc953a0a1796b752e5bbe521266dc1230c81
 
 post_patch() {
 	sed '31a#include <locale.h>' -i  guvcview/guvcview.c

From b24f0364f0539ceeeea254a809f8c8a196a65ca8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 041/113] handbrake: update to 1.6.1

---
 .../patches/fix-missing-x265-link-flag.patch    | 11 ++++++-----
 .../handbrake/patches/libhb-vpl-include.patch   | 15 +++++++++++++++
 srcpkgs/handbrake/template                      | 17 ++++++++++-------
 3 files changed, 31 insertions(+), 12 deletions(-)
 create mode 100644 srcpkgs/handbrake/patches/libhb-vpl-include.patch

diff --git a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
index 26db03867a0c..d6bb2eda627a 100644
--- a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
+++ b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
@@ -1,14 +1,15 @@
 --- a/gtk/configure.ac
 +++ b/gtk/configure.ac
 @@ -203,7 +203,7 @@
- 
+
  AM_CONDITIONAL([MINGW], [test "x$mingw_flag" = "xyes"])
- 
--HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg"
-+HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -ldl"
+
+-HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc"
++HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc -ldl"
  HB_CPPFLAGS="$HB_CPPFLAGS $HBINC"
- 
+
  PKG_CHECK_MODULES([x264], [x264], sys_x264=yes, sys_x264=no)
+
 --- a/test/module.defs
 +++ b/test/module.defs
 @@ -69,6 +69,9 @@
diff --git a/srcpkgs/handbrake/patches/libhb-vpl-include.patch b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
new file mode 100644
index 000000000000..298f9f4ab28f
--- /dev/null
+++ b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
@@ -0,0 +1,15 @@
+--- a/libhb/module.defs	2023-01-22 11:36:49.000000000 -0500
++++ b/libhb/module.defs	2023-04-03 22:37:52.395467010 -0400
+@@ -46,11 +46,7 @@
+ LIBHB.GCC.I += $(LIBHB.build/) $(CONTRIB.build/)include
+ 
+ ifeq (1,$(FEATURE.qsv))
+-    ifeq ($(HOST.system),freebsd))
+-        LIBHB.GCC.I += $(LOCALBASE)/include/vpl
+-    else
+-        LIBHB.GCC.I += $(CONTRIB.build/)include/vpl
+-    endif
++    LIBHB.GCC.I += /usr/include/vpl
+ endif
+ 
+ ifneq (,$(filter $(HOST.system),freebsd netbsd openbsd))
diff --git a/srcpkgs/handbrake/template b/srcpkgs/handbrake/template
index ca5e4571e49c..c32cb1bfa31f 100644
--- a/srcpkgs/handbrake/template
+++ b/srcpkgs/handbrake/template
@@ -1,10 +1,10 @@
 # Template file for 'handbrake'
 pkgname=handbrake
-version=1.5.1
+version=1.6.1
 revision=1
 build_style=gnu-configure
 configure_args="--force --disable-gtk-update-checks --disable-df-fetch --harden
- $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc)"
+ $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc) $(vopt_enable qsv)"
 make_build_args="-C ${XBPS_TRIPLET}"
 make_install_args="-C ${XBPS_TRIPLET}"
 hostmakedepends="automake cmake gettext-devel glib-devel intltool libtool m4 meson nasm pkg-config python3"
@@ -12,8 +12,11 @@ makedepends="bzip2-devel ffmpeg-devel gst-plugins-base1-devel gtk+3-devel
  jansson-devel lame-devel libass-devel libbluray-devel libdav1d-devel
  libdvdnav-devel libdvdread-devel libgudev-devel libnuma-devel
  libsamplerate-devel libtheora-devel libvorbis-devel libvpx-devel libxml2-devel
- opus-devel speex-devel x264-devel x265-devel zimg-devel
+ opus-devel speex-devel x264-devel x265-devel zimg-devel libsvt-av1-devel
  $(vopt_if fdk_aac fdk-aac-devel)
+ $(vopt_if qsv libva-devel)
+ $(vopt_if qsv libdrm-devel)
+ $(vopt_if qsv onevpl-devel)
  $(vopt_if nvenc nv-codec-headers)"
 depends="desktop-file-utils gst-plugins-good1 hicolor-icon-theme"
 short_desc="Multithreaded video transcoder"
@@ -21,15 +24,15 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-2.0-only"
 homepage="https://handbrake.fr/"
 distfiles="https://github.com/HandBrake/HandBrake/releases/download/${version}/HandBrake-${version}-source.tar.bz2"
-checksum=3999fe06d5309c819799a73a968a8ec3840e7840c2b64af8f5cdb7fd8c9430f0
+checksum=94ccfe03db917a91650000c510f7fd53f844da19f19ad4b4be1b8f6bc31a8d4c
 nocross=yes
 
-build_options="fdk_aac nvenc"
+build_options="fdk_aac nvenc qsv"
 
 case "$XBPS_TARGET_MACHINE" in
 	x86_64*|i686*)
 		CFLAGS="-msse"
-		build_options_default="nvenc"
+		build_options_default="nvenc qsv"
 		;;
 esac
 
@@ -37,7 +40,7 @@ pre_configure() {
 	# use system libraries, don't download them
 	rm -rf contrib/
 	for module in fdk-aac ffmpeg libbluray libdav1d libdvdnav libdvdread nvenc \
-		x265 zimg; do
+		x265 zimg svt-av1 libvpl; do
 	    vsed -i "/MODULES += contrib\/${module}/d" make/include/main.defs
 	done
 }

From 8428634e81d946ec5f9459fb53d5150e9e25a9d9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 042/113] hedgewars: revbump for ffmpeg4-4.4.3

---
 srcpkgs/hedgewars/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/hedgewars/template b/srcpkgs/hedgewars/template
index 419f29b98b44..926fe4fe3e68 100644
--- a/srcpkgs/hedgewars/template
+++ b/srcpkgs/hedgewars/template
@@ -1,13 +1,13 @@
 # Template file for 'hedgewars'
 pkgname=hedgewars
 version=1.0.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DNOSERVER=1 -DDATA_INSTALL_DIR=/usr/share/${pkgname}
  -DPHYSFS_SYSTEM=1 -DMINIMAL_FLAGS=1"
 make_cmd=make
 hostmakedepends="lua51 pkg-config qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
+makedepends="ffmpeg4-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
  SDL2_mixer-devel SDL2_net-devel SDL2_ttf-devel"
 depends="libfreeglut"
 short_desc="Funny turn-based artillery game, featuring fighting Hedgehogs!"

From 574330a056113b2bca65a69c14f230b9ba7feebb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 043/113] idjc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/idjc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/idjc/template b/srcpkgs/idjc/template
index df60318b3db9..36a75baf597c 100644
--- a/srcpkgs/idjc/template
+++ b/srcpkgs/idjc/template
@@ -1,11 +1,11 @@
 # Template file for 'idjc'
 pkgname=idjc
 version=0.9.1
-revision=3
+revision=4
 build_style=gnu-configure
 hostmakedepends="pkg-config git python3 automake gettext-devel libtool"
 makedepends="libvorbis-devel libogg-devel jack-devel libsamplerate-devel
- libflac-devel libsndfile-devel mpg123-devel ffmpeg-devel speex-devel
+ libflac-devel libsndfile-devel mpg123-devel ffmpeg4-devel speex-devel
  glib-devel pixman-devel lame-devel python3-gobject-devel libshout-idjc-devel
  opus-devel twolame-devel python3-mutagen python3-devel"
 depends="python3-gobject python3-mutagen desktop-file-utils shared-mime-info python3-dbus jack"

From 6f9b42c7b7b39c3f7986d59aea8dc5c9f7eb8bb1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 044/113] kfilemetadata5: revbump for ffmpeg-6.0

---
 srcpkgs/kfilemetadata5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kfilemetadata5/template b/srcpkgs/kfilemetadata5/template
index 4b91cf19f298..a3671a38ce59 100644
--- a/srcpkgs/kfilemetadata5/template
+++ b/srcpkgs/kfilemetadata5/template
@@ -1,7 +1,7 @@
 # Template file for 'kfilemetadata5'
 pkgname=kfilemetadata5
 version=5.107.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="kcoreaddons extra-cmake-modules pkg-config qt5-host-tools qt5-qmake
  gettext kcoreaddons python3"

From d1bc4a76ed23f9f37afb4f94bf8ca326e7ed8f2c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 045/113] kid3: revbump for ffmpeg-6.0

---
 srcpkgs/kid3/patches/ffmpeg5.patch | 17 +++++++++++++++++
 srcpkgs/kid3/template              |  2 +-
 2 files changed, 18 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/kid3/patches/ffmpeg5.patch

diff --git a/srcpkgs/kid3/patches/ffmpeg5.patch b/srcpkgs/kid3/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..135fc50e07c9
--- /dev/null
+++ b/srcpkgs/kid3/patches/ffmpeg5.patch
@@ -0,0 +1,17 @@
+# https://aur.archlinux.org/cgit/aur.git/diff/ffmpeg5.patch?h=kid3-cli&id=12410a74906612e7efc0ec8fbce739b4a0fef7e7
+diff --git a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+index e156d424..e12b9abd 100644
+--- a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
++++ b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+@@ -232,7 +232,11 @@ private:
+   friend class Format;
+   friend class Converter;
+   AVCodecContext* m_ptr;
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 0, 0)
+   AVCodec* m_impl;
++#else
++  const AVCodec* m_impl;
++#endif
+   AVFrame* m_frame;
+   bool m_opened;
+ };
diff --git a/srcpkgs/kid3/template b/srcpkgs/kid3/template
index 456206d90e16..f32f9decb0e7 100644
--- a/srcpkgs/kid3/template
+++ b/srcpkgs/kid3/template
@@ -1,7 +1,7 @@
 # Template file for 'kid3'
 pkgname=kid3
 version=3.9.1
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DWITH_APPS='CLI;$(vopt_if KDE KDE Qt)'
  -DWITH_DOCBOOKDIR=/usr/share/xsl/docbook -DWITH_FLAC=$(vopt_if flac ON OFF)

From 54376ca79080ef08b10ed751ee48ea8a218405ab Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 046/113] kodi: revbump for ffmpeg4-4.4.3

---
 srcpkgs/kodi/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/kodi/template b/srcpkgs/kodi/template
index 8057964d78a3..6cc1874be7ba 100644
--- a/srcpkgs/kodi/template
+++ b/srcpkgs/kodi/template
@@ -1,7 +1,7 @@
 # Template file for 'kodi'
 pkgname=kodi
 version=19.4
-revision=6
+revision=7
 _codename="Matrix"
 build_style=cmake
 configure_args="-DWITH_FFMPEG=/usr -DENABLE_LDGOLD=OFF
@@ -54,7 +54,7 @@ makedepends="
  libmad-devel fontconfig-devel libXinerama-devel libsamplerate-devel libmms-devel
  enca-devel boost-devel libcurl-devel libva-devel libvdpau-devel libass-devel
  libbluetooth-devel yajl-devel libplist-devel librtmp-devel tinyxml-devel
- taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg-devel
+ taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg4-devel
  giflib-devel libxslt-devel gnutls-devel libssh-devel libmicrohttpd-devel
  libcec-devel dcadec-devel flatbuffers-devel fmt-devel lcms2-devel
  libfstrcmp-devel rapidjson libcdio-paranoia spdlog libwaylandpp-devel

From d832cdd6cfe80c8f42987e971083cfc6542e4a8e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 047/113] kpipewire: revbump for ffmpeg-6.0

---
 srcpkgs/kpipewire/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kpipewire/template b/srcpkgs/kpipewire/template
index db4e42f0d456..2334bf867806 100644
--- a/srcpkgs/kpipewire/template
+++ b/srcpkgs/kpipewire/template
@@ -1,7 +1,7 @@
 # Template file for 'kpipewire'
 pkgname=kpipewire
 version=5.27.6
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules plasma-wayland-protocols gettext
  qt5-qmake qt5-host-tools pkg-config wayland-devel kcoreaddons

From ab4875f3ded74f497d8c492553bcb394acf8230b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 048/113] libextractor: revbump for ffmpeg4-4.4.3

---
 srcpkgs/libextractor/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libextractor/template b/srcpkgs/libextractor/template
index ddd4790f93e8..1fb9ca56a96a 100644
--- a/srcpkgs/libextractor/template
+++ b/srcpkgs/libextractor/template
@@ -7,7 +7,7 @@ configure_args="--disable-static"
 hostmakedepends="pkg-config"
 makedepends="zlib-devel bzip2-devel exiv2-devel tiff-devel libpng-devel
  libjpeg-turbo-devel libvorbis-devel libflac-devel giflib-devel libmpeg2-devel
- ffmpeg-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
+ ffmpeg4-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
 short_desc="Library used to extract meta data from files"
 maintainer="Martin Riese <grauehaare@gmx.de>"
 license="GPL-3.0-or-later"

From e7b00c31422b57759e8525d97f80385aabfa2438 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 049/113] libopenal: revbump for ffmpeg-6.0

---
 srcpkgs/libopenal/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenal/template b/srcpkgs/libopenal/template
index 77218f9e539d..3f49ed75a1fd 100644
--- a/srcpkgs/libopenal/template
+++ b/srcpkgs/libopenal/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenal'
 pkgname=libopenal
 version=1.22.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DALSOFT_EXAMPLES=OFF"
 hostmakedepends="pkg-config"

From b5f31fba93e19c31a0c9640a8a848826cdf4ac52 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 050/113] libopenshot: revbump for ffmpeg-6.0

---
 srcpkgs/libopenshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenshot/template b/srcpkgs/libopenshot/template
index db831f69b474..81aa0d7136d9 100644
--- a/srcpkgs/libopenshot/template
+++ b/srcpkgs/libopenshot/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenshot'
 pkgname=libopenshot
 version=0.3.0
-revision=1
+revision=2
 build_style=cmake
 # Builds fail with Ruby-2.4.1
 configure_args="-DENABLE_RUBY=OFF -DUSE_SYSTEM_JSONCPP=ON"

From bd8ae4ebbff59acc6c76f1172a474fda776f133a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 051/113] loudgain: revbump for ffmpeg-6.0

---
 srcpkgs/loudgain/patches/ffmpeg5.patch | 11 +++++++++++
 srcpkgs/loudgain/template              |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/loudgain/patches/ffmpeg5.patch

diff --git a/srcpkgs/loudgain/patches/ffmpeg5.patch b/srcpkgs/loudgain/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..16d4510ee98f
--- /dev/null
+++ b/srcpkgs/loudgain/patches/ffmpeg5.patch
@@ -0,0 +1,11 @@
+--- a/src/scan.c	2019-09-06 11:31:19.000000000 -0400
++++ b/src/scan.c	2023-03-23 11:15:40.867968521 -0400
+@@ -69,8 +69,6 @@
+ 	 * It is now useless
+ 	 * https://github.com/FFmpeg/FFmpeg/blob/70d25268c21cbee5f08304da95be1f647c630c15/doc/APIchanges#L86
+ 	 */
+-  if (avformat_version() < AV_VERSION_INT(58,9,100))
+-    av_register_all();
+ 
+ 	av_log_set_callback(scan_av_log);
+ 
diff --git a/srcpkgs/loudgain/template b/srcpkgs/loudgain/template
index da4f2d56e94c..4d6bf29efb4f 100644
--- a/srcpkgs/loudgain/template
+++ b/srcpkgs/loudgain/template
@@ -1,7 +1,7 @@
 # Template file for 'loudgain'
 pkgname=loudgain
 version=0.6.8
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libebur128-devel taglib-devel ffmpeg-devel"

From 8092a3ab783ff6903af23fc4405a70ca56d8e959 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 052/113] mediastreamer: revbump for ffmpeg4-4.4.3

---
 srcpkgs/mediastreamer/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mediastreamer/template b/srcpkgs/mediastreamer/template
index d0e97e858e29..1bde031443a5 100644
--- a/srcpkgs/mediastreamer/template
+++ b/srcpkgs/mediastreamer/template
@@ -1,11 +1,11 @@
 # Template file for 'mediastreamer'
 pkgname=mediastreamer
 version=5.2.6
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_STRICT=0 -DENABLE_UNIT_TESTS=0"
 hostmakedepends="python3"
-makedepends="bzrtp-devel ffmpeg-devel glew-devel libXv-devel libsrtp-devel
+makedepends="bzrtp-devel ffmpeg4-devel glew-devel libXv-devel libsrtp-devel
  libupnp-devel libvpx-devel mbedtls-devel opus-devel ortp-devel pulseaudio-devel
  libtheora-devel speex-devel v4l-utils-devel bcg729-devel bcmatroska2-devel libgsm-devel"
 # zxing-cpp-devel (1.2.0 probably not compatible, check again after updaing xzing)

From d217057287f5589ab99707523c9ee4a1f2072be5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 053/113] mgba: revbump for ffmpeg-6.0

---
 srcpkgs/mgba/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mgba/template b/srcpkgs/mgba/template
index ae0504311eee..d31295a0cd3d 100644
--- a/srcpkgs/mgba/template
+++ b/srcpkgs/mgba/template
@@ -1,7 +1,7 @@
 # Template file for 'mgba'
 pkgname=mgba
 version=0.10.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake desktop-file-utils"
 makedepends="SDL2-devel ffmpeg-devel libedit-devel libepoxy-devel libmagick-devel

From c1249f47c21e7098559b780a321aaba3ce976c4a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 054/113] minidlna: revbump for ffmpeg-6.0

---
 srcpkgs/minidlna/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/minidlna/template b/srcpkgs/minidlna/template
index d551e49ed465..5fa929f3a0c1 100644
--- a/srcpkgs/minidlna/template
+++ b/srcpkgs/minidlna/template
@@ -1,7 +1,7 @@
 # Template file for 'minidlna'
 pkgname=minidlna
 version=1.3.3
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="
  --sbindir=/usr/bin

From 4ae4ddf71a2e14290d920e0a12d24e0802e601d2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 055/113] mixxx: revbump for ffmpeg-6.0

---
 srcpkgs/mixxx/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mixxx/template b/srcpkgs/mixxx/template
index 619ddca0d332..4b9ea00d3fb3 100644
--- a/srcpkgs/mixxx/template
+++ b/srcpkgs/mixxx/template
@@ -1,7 +1,7 @@
 # Template file for 'mixxx'
 pkgname=mixxx
 version=2.3.3
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="extra-cmake-modules pkg-config protobuf qt5-host-tools qt5-devel"

From a46e80408b5958bd3114b3412c985dfcc2fe0f38 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 056/113] mlt: revbump for ffmpeg4-4.4.3

---
 srcpkgs/mlt/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mlt/template b/srcpkgs/mlt/template
index 8933eb4e7bb9..73353fedafb5 100644
--- a/srcpkgs/mlt/template
+++ b/srcpkgs/mlt/template
@@ -1,14 +1,14 @@
 # Template file for 'mlt'
 pkgname=mlt
 version=6.26.1
-revision=1
+revision=2
 build_style=configure
 configure_args="--prefix=/usr --libdir=/usr/lib$XBPS_TARGET_WORDSIZE
  --enable-gpl --enable-gpl3 --disable-swfdec --without-kde
  --swig-languages=python"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which"
 # XXX: movit vid.stab
-makedepends="alsa-lib-devel ffmpeg-devel gtk+-devel jack-devel ladspa-sdk
+makedepends="alsa-lib-devel ffmpeg4-devel gtk+-devel jack-devel ladspa-sdk
  libexif-devel libsamplerate-devel libxml2-devel sox-devel SDL_image-devel
  fftw-devel frei0r-plugins python3-devel pulseaudio-devel movit-devel
  libvidstab-devel libatomic-devel"

From 14b9c837e49a8106a232cf3462e0d652fe4f4a03 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 057/113] moc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/moc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/moc/template b/srcpkgs/moc/template
index c42be650a1d2..d4f0eefbad52 100644
--- a/srcpkgs/moc/template
+++ b/srcpkgs/moc/template
@@ -1,10 +1,10 @@
 # Template file for 'moc'
 pkgname=moc
 version=2.5.2
-revision=6
+revision=7
 build_style=gnu-configure
 hostmakedepends="pkg-config"
-makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg-devel
+makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg4-devel
  jack-devel alsa-lib-devel libltdl-devel libflac-devel libvorbis-devel
  libmad-devel libmpcdec-devel libmodplug-devel libid3tag-devel faad2-devel
  taglib-devel libsndfile-devel wavpack-devel speex-devel libsamplerate-devel

From 813362ec0cc7059941f0967dffdf032ecb9a6cfb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 058/113] motion: revbump for ffmpeg-6.0

---
 srcpkgs/motion/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/motion/template b/srcpkgs/motion/template
index 3cf3c3035c5b..7dca12d851e3 100644
--- a/srcpkgs/motion/template
+++ b/srcpkgs/motion/template
@@ -1,7 +1,7 @@
 # Template file for 'motion'
 pkgname=motion
 version=4.5.1
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake pkg-config gettext-devel tar"
 makedepends="ffmpeg-devel libmicrohttpd-devel v4l-utils-devel gettext-devel"

From 1fd359b67bf608bc80cdd057aba032642a72e1d9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 059/113] mpv: revbump for ffmpeg-6.0

---
 srcpkgs/mpv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpv/template b/srcpkgs/mpv/template
index e163c496c6eb..d4fefbf5e3c7 100644
--- a/srcpkgs/mpv/template
+++ b/srcpkgs/mpv/template
@@ -1,7 +1,7 @@
 # Template file for 'mpv'
 pkgname=mpv
 version=0.35.1
-revision=2
+revision=3
 build_style=meson
 configure_args="-Dcdda=enabled -Ddvbin=enabled -Ddvdnav=enabled
  -Dlibmpv=true -Dcplugins=enabled

From c8c593da81ceff294860fcfcb47e5f1653c156d1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 060/113] musikcube: revbump for ffmpeg-6.0

---
 srcpkgs/musikcube/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/musikcube/template b/srcpkgs/musikcube/template
index 7c569303c054..a4dea460c371 100644
--- a/srcpkgs/musikcube/template
+++ b/srcpkgs/musikcube/template
@@ -1,7 +1,7 @@
 # Template file for 'musikcube'
 pkgname=musikcube
 version=3.0.0
-revision=1
+revision=2
 build_style=cmake
 make_cmd=make
 configure_args="-DNO_NCURSESW=1"

From 369943f0f44af7e348d4eba2b7f4fbab8e39529d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 061/113] notcurses: revbump for ffmpeg-6.0

---
 srcpkgs/notcurses/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/notcurses/template b/srcpkgs/notcurses/template
index 6dd8a091319f..3110c30c9aff 100644
--- a/srcpkgs/notcurses/template
+++ b/srcpkgs/notcurses/template
@@ -1,7 +1,7 @@
 # Template file for 'notcurses'
 pkgname=notcurses
 version=3.0.9
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DUSE_STATIC=ON $(vopt_bool man USE_PANDOC)"
 hostmakedepends="pkg-config $(vopt_if man pandoc)"

From 8a30cf9e6a843e1f00ff7c9afc860496b1c7fa18 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 062/113] obs: revbump for ffmpeg-6.0

---
 srcpkgs/obs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/obs/template b/srcpkgs/obs/template
index 7b69c630d30d..2c8d68d71f3a 100644
--- a/srcpkgs/obs/template
+++ b/srcpkgs/obs/template
@@ -1,7 +1,7 @@
 # Template file for 'obs'
 pkgname=obs
 version=29.1.2
-revision=1
+revision=2
 archs="i686* x86_64* ppc64le* aarch64*"
 build_style=cmake
 configure_args="-DOBS_VERSION_OVERRIDE=${version} -DENABLE_JACK=ON

From 7d4540259e2d72a59f514497f5b6e0d3003b4fed Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 063/113] olive: revbump for ffmpeg4-4.4.3

---
 srcpkgs/olive/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/olive/template b/srcpkgs/olive/template
index 12a46936c990..5c2917b9c512 100644
--- a/srcpkgs/olive/template
+++ b/srcpkgs/olive/template
@@ -1,10 +1,10 @@
 # Template file for 'olive'
 pkgname=olive
 version=0.1.2
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools pkg-config"
-makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg-devel frei0r-plugins"
+makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg4-devel frei0r-plugins"
 short_desc="Non-linear video editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"

From 508ffbec2043a331c00669816c83074f62dd4e5c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 064/113] omxplayer: revbump for ffmpeg4-4.4.3

---
 srcpkgs/omxplayer/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/omxplayer/template b/srcpkgs/omxplayer/template
index e70bf7873d4d..0e9bc70e7c8e 100644
--- a/srcpkgs/omxplayer/template
+++ b/srcpkgs/omxplayer/template
@@ -1,10 +1,10 @@
 # Template file for 'omxplayer'
 pkgname=omxplayer
 version=20190102
-revision=1
+revision=2
 short_desc="Commandline OMX player for the Raspberry Pi"
 maintainer="Orphaned <orphan@voidlinux.org>"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://github.com/popcornmix/omxplayer"
 
 _commit="f06235cc9690a6d58187514452df8cf8fcdaacec"
@@ -15,7 +15,7 @@ checksum=af2d9450f8947842ea8c401fe9f71eec444013ebbdee29f2ac828c9c493c1329
 archs="armv6l* armv7l*"
 build_style=gnu-makefile
 hostmakedepends="curl pkg-config"
-makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg-devel dbus-devel"
+makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg4-devel dbus-devel"
 depends="freefont-ttf"
 
 do_build() {

From 2cce0a838368ef79ae5e9e616cb8f444c790b9b8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 065/113] openshot: revbump for ffmpeg-6.0

---
 srcpkgs/openshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openshot/template b/srcpkgs/openshot/template
index 322717d40abc..c074e0338773 100644
--- a/srcpkgs/openshot/template
+++ b/srcpkgs/openshot/template
@@ -1,7 +1,7 @@
 # Template file for 'openshot'
 pkgname=openshot
 version=3.0.0
-revision=1
+revision=2
 build_style=python3-module
 hostmakedepends="python3 python3-setuptools"
 makedepends="ffmpeg-devel python3-PyQt5"

From 53888d63a35cc86a22ceca310d9a8c1f0e66efa9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 066/113] opentoonz: revbump for ffmpeg-6.0

---
 srcpkgs/opentoonz/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/opentoonz/template b/srcpkgs/opentoonz/template
index ee9f7603f55f..3e81834ca0ed 100644
--- a/srcpkgs/opentoonz/template
+++ b/srcpkgs/opentoonz/template
@@ -1,7 +1,7 @@
 # Template file for 'opentoonz'
 pkgname=opentoonz
 version=1.6.0
-revision=2
+revision=3
 build_wrksrc="toonz/sources"
 build_style=cmake
 make_cmd=make

From caf0d5eaf05a31c767cd67ed682f9c131e6c7766 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 067/113] pianobar: revbump for ffmpeg-6.0

---
 srcpkgs/pianobar/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pianobar/template b/srcpkgs/pianobar/template
index e3febb821a45..1e3dc1bf9308 100644
--- a/srcpkgs/pianobar/template
+++ b/srcpkgs/pianobar/template
@@ -1,7 +1,7 @@
 # Template file for 'pianobar'
 pkgname=pianobar
 version=2022.04.01
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="V=1"
 hostmakedepends="pkg-config"

From 3eeb517ecf23a25f11e8d1deebaf5088afc6ef58 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 068/113] ppsspp: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ppsspp/template | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/ppsspp/template b/srcpkgs/ppsspp/template
index 7984a733d4be..15a42fd2c993 100644
--- a/srcpkgs/ppsspp/template
+++ b/srcpkgs/ppsspp/template
@@ -1,7 +1,7 @@
 # Template file for 'ppsspp'
 pkgname=ppsspp
 version=1.14.4
-revision=1
+revision=2
 _glslang_commit=dc11adde23c455a24e13dd54de9b4ede8bdd7db8
 _SPIRV_Cross_commit=9acb9ec31f5a8ef80ea6b994bb77be787b08d3d1
 _armips_commit=6719edebaae03330ee5441d9b28280672edf00d5
@@ -13,7 +13,7 @@ configure_args="-DHEADLESS=1 -DUSE_SYSTEM_FFMPEG=1 -DUNITTEST=ON
  -DUSING_QT_UI=$(vopt_if qt ON OFF) -DUSE_SYSTEM_ZSTD=ON
  -DARMIPS_USE_STD_FILESYSTEM=ON"
 hostmakedepends="pkg-config python3 $(vopt_if qt qt5-host-tools)"
-makedepends="zlib-devel glew-devel ffmpeg-devel libzip-devel
+makedepends="zlib-devel glew-devel ffmpeg4-devel libzip-devel
  snappy-devel rapidjson libpng-devel libzstd-devel
  $(vopt_if sdl2 SDL2-devel) $(vopt_if wayland wayland-devel)
  $(vopt_if qt 'qt5-devel qt5-multimedia-devel')"
@@ -62,13 +62,12 @@ post_extract() {
 	mv ${wrksrc}/miniupnp-${_miniupnp_commit} ${wrksrc}/ext/miniupnp
 }
 
-post_patch(){
+post_patch() {
 	# disable git versioning
 	vsed -e 's|find_package(Git)|# &|' -i git-version.cmake
 }
 
 do_install() {
-	vlicense LICENSE.TXT
 	vinstall icons/icon.svg 644 usr/share/pixmaps ppsspp.svg
 	vinstall Qt/PPSSPP.desktop 644 usr/share/applications
 	vbin build/PPSSPPHeadless ppsspp-headless

From 0597f6e814a70cf830e05a0c50be208ec8964e9d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 069/113] pqiv: revbump for ffmpeg-6.0

---
 srcpkgs/pqiv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pqiv/template b/srcpkgs/pqiv/template
index 542fc27a2d32..9308d949b6a1 100644
--- a/srcpkgs/pqiv/template
+++ b/srcpkgs/pqiv/template
@@ -1,7 +1,7 @@
 # Template file for 'pqiv'
 pkgname=pqiv
 version=2.12
-revision=1
+revision=2
 build_style=gnu-makefile
 hostmakedepends="pkg-config"
 makedepends="glib-devel gtk+3-devel $(vopt_if ffmpeg ffmpeg-devel)

From c32df46cae8c8888e4782b9a471c7d265924df0b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 070/113] qmmp: revbump for ffmpeg-6.0

---
 srcpkgs/qmmp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qmmp/template b/srcpkgs/qmmp/template
index 26c661ed16be..a150d7441c7a 100644
--- a/srcpkgs/qmmp/template
+++ b/srcpkgs/qmmp/template
@@ -1,7 +1,7 @@
 # Template file for 'qmmp'
 pkgname=qmmp
 version=1.6.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DUSE_HAL:BOOL=FALSE -DQMMP_DEFAULT_UI:STRING=simple"
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From 82afd18905aeb81acd211651af3c374574f92550 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 071/113] qt5-webengine: update to 5.15.13

---
 .../chromium-media-filters-cpp14.patch        |  11 ++
 srcpkgs/qt5-webengine/patches/ffmpeg5.patch   | 179 ++++++++++++++++++
 srcpkgs/qt5-webengine/template                |  10 +-
 3 files changed, 195 insertions(+), 5 deletions(-)
 create mode 100644 srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/ffmpeg5.patch

diff --git a/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
new file mode 100644
index 000000000000..04adc540f2cb
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
@@ -0,0 +1,11 @@
+--- a/src/3rdparty/chromium/media/filters/BUILD.gn	2023-02-27 13:32:59.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/BUILD.gn	2023-04-02 17:21:39.204066384 -0400
+@@ -96,6 +96,8 @@
+     "//ui/gfx/geometry:geometry",
+   ]
+ 
++  cflags_cc = [ "-std=c++14" ]
++
+   libs = []
+ 
+   if (proprietary_codecs) {
diff --git a/srcpkgs/qt5-webengine/patches/ffmpeg5.patch b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..ac55e1634423
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
@@ -0,0 +1,179 @@
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:57.732547446 -0400
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:09.486478995 -0400
+@@ -57,6 +57,8 @@
+ 
+ namespace {
+ 
++constexpr int64_t kRelativeTsBase = static_cast<int64_t>(0x7ffeffffffffffff);
++
+ void SetAVStreamDiscard(AVStream* stream, AVDiscard discard) {
+   DCHECK(stream);
+   stream->discard = discard;
+@@ -90,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+   if (stream->start_time != kNoFFmpegTimestamp)
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (stream->first_dts != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, stream->first_dts);
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -408,11 +398,11 @@
+   scoped_refptr<DecoderBuffer> buffer;
+ 
+   if (type() == DemuxerStream::TEXT) {
+-    int id_size = 0;
++    size_t id_size = 0;
+     uint8_t* id_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
+ 
+-    int settings_size = 0;
++    size_t settings_size = 0;
+     uint8_t* settings_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
+ 
+@@ -424,7 +414,7 @@
+     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
+                                      side_data.data(), side_data.size());
+   } else {
+-    int side_data_size = 0;
++    size_t side_data_size = 0;
+     uint8_t* side_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
+ 
+@@ -485,7 +475,7 @@
+                                        packet->size - data_offset);
+     }
+ 
+-    int skip_samples_size = 0;
++    size_t skip_samples_size = 0;
+     const uint32_t* skip_samples_ptr =
+         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
+             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
+@@ -1587,6 +1577,8 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++      continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+       lowest_start_time_stream = stream.get();
+@@ -1604,6 +1596,8 @@
+     if (stream && stream->type() == DemuxerStream::VIDEO &&
+         stream->IsEnabled()) {
+       video_stream = stream.get();
++      if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++        continue;
+       if (video_stream->start_time() <= seek_time) {
+         return video_stream;
+       }
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h qtwebengine-5.15.10/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h
+--- a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-07-11 22:12:47.917192788 -0500
+@@ -29,6 +29,7 @@ extern "C" {
+ #include <libavformat/avformat.h>
+ #include <libavformat/avio.h>
+ #include <libavutil/avutil.h>
++#include <libavutil/channel_layout.h>
+ #include <libavutil/imgutils.h>
+ #include <libavutil/log.h>
+ #include <libavutil/mastering_display_metadata.h>
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/audio_file_reader.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/audio_file_reader.cc
+--- a/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -85,7 +85,7 @@ bool AudioFileReader::OpenDemuxer() {
+ }
+ 
+ bool AudioFileReader::OpenDecoder() {
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (codec) {
+     // MP3 decodes to S16P which we don't support, tell it to use S16 instead.
+     if (codec_context_->sample_fmt == AV_SAMPLE_FMT_S16P)
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -329,7 +329,7 @@ bool FFmpegAudioDecoder::ConfigureDecode
+     }
+   }
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec ||
+       avcodec_open2(codec_context_.get(), codec, &codec_options) < 0) {
+     DLOG(ERROR) << "Could not initialize audio decoder: "
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -59,7 +59,6 @@ static int64_t AVIOSeekOperation(void* o
+ }
+ 
+ void FFmpegGlue::InitializeFFmpeg() {
+-  av_register_all();
+ }
+ 
+ static void LogContainer(bool is_local_file,
+@@ -95,9 +94,6 @@ FFmpegGlue::FFmpegGlue(FFmpegURLProtocol
+   // Enable fast, but inaccurate seeks for MP3.
+   format_context_->flags |= AVFMT_FLAG_FAST_SEEK;
+ 
+-  // Ensures we can read out various metadata bits like vp8 alpha.
+-  format_context_->flags |= AVFMT_FLAG_KEEP_SIDE_DATA;
+-
+   // Ensures format parsing errors will bail out. From an audit on 11/2017, all
+   // instances were real failures. Solves bugs like http://crbug.com/710791.
+   format_context_->error_recognition |= AV_EF_EXPLODE;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -391,7 +391,7 @@ bool FFmpegVideoDecoder::ConfigureDecode
+   if (decode_nalus_)
+     codec_context_->flags2 |= AV_CODEC_FLAG2_CHUNKS;
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
+     ReleaseFFmpegResources();
+     return false;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/media_file_checker.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/media_file_checker.cc
+--- a/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -68,7 +68,7 @@ bool MediaFileChecker::Start(base::TimeD
+       auto context = AVStreamToAVCodecContext(format_context->streams[i]);
+       if (!context)
+         continue;
+-      AVCodec* codec = avcodec_find_decoder(cp->codec_id);
++      const AVCodec* codec = avcodec_find_decoder(cp->codec_id);
+       if (codec && avcodec_open2(context.get(), codec, nullptr) >= 0) {
+         auto loop = std::make_unique<FFmpegDecodingLoop>(context.get());
+         stream_contexts[i] = {std::move(context), std::move(loop)};
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc qtwebengine-5.15.10/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc
+--- a/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -203,7 +203,7 @@ int32_t H264DecoderImpl::InitDecode(cons
+   // a pointer |this|.
+   av_context_->opaque = this;
+ 
+-  AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
+   if (!codec) {
+     // This is an indication that FFmpeg has not been initialized or it has not
+     // been compiled/initialized with the correct set of codecs.
diff --git a/srcpkgs/qt5-webengine/template b/srcpkgs/qt5-webengine/template
index 85267c7cf8a3..095ab67701e4 100644
--- a/srcpkgs/qt5-webengine/template
+++ b/srcpkgs/qt5-webengine/template
@@ -1,9 +1,9 @@
 # Template file for 'qt5-webengine'
 pkgname=qt5-webengine
-version=5.15.11
-revision=3
+version=5.15.13
+revision=1
 _version="${version}-lts"
-_chromium_commit=be349eaf62e77955791d7bf29f893f1e8a37daf4
+_chromium_commit=e48df7803c7c98b0b2471c94057d32e44a301ad5
 archs="x86_64* i686* armv[67]* ppc64* aarch64*"
 create_wrksrc=yes
 build_style=qmake
@@ -32,8 +32,8 @@ license="GPL-3.0-or-later, LGPL-3.0-or-later"
 homepage="https://qt.io/"
 distfiles="https://github.com/qt/qtwebengine/archive/v${_version}.tar.gz
  https://github.com/qt/qtwebengine-chromium/archive/${_chromium_commit}.tar.gz"
-checksum="aa7466356c450c5f5870f979b93cd7e7e62da1165c328ffcab1a9928db18ad67
- 6f47ed8ab8cc062411f6f206da6353bc8263d6ed6d6290c689a05c01d91f646b"
+checksum="4b59838ed75ef788b59e1e412535a0e42dd9d311661fdeadb191b581ba815c63
+ a91686562b1d4e8b220e0bbcbab5feb64630e2de974b35ac034bf388af771a6c"
 
 no_generic_pkgconfig_link=yes
 build_options="sndio pipewire"

From da23d8ab80a6fa1b1d619f4e618a3b842f998c84 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 072/113] qt5: update to 5.15.8

---
 ...erywhere-opensource-src-5.15.8-kf5-1.patch | 12913 ++++++++++++++++
 srcpkgs/qt5/template                          |    12 +-
 2 files changed, 12919 insertions(+), 6 deletions(-)
 create mode 100644 srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch

diff --git a/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch b/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch
new file mode 100644
index 000000000000..966c98bcd3bb
--- /dev/null
+++ b/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch
@@ -0,0 +1,12913 @@
+Submitted By:            Pierre Labastie <pierre_dot_labastie_at_neuf_dot_fr>
+Date:                    2023-01-05
+Initial Package Version: 5.15.8
+Upstream Status:         Applied (according to KDE)
+Origin:                  KDE patch set
+Description:             Patch set maintained by the KDE folks
+see https://dot.kde.org/2021/04/06/announcing-kdes-qt-5-patch-collection
+Patch generated using the procedure in
+https://wiki.linuxfromscratch.org/blfs/ticket/17476#comment:3
+
+Submodule qtbase 4ee4fc18..9cf586d6:
+diff --git a/qtbase/mkspecs/common/android/qplatformdefs.h b/qtbase/mkspecs/common/android/qplatformdefs.h
+index f75bc4093b..2bd59410d4 100644
+--- a/qtbase/mkspecs/common/android/qplatformdefs.h
++++ b/qtbase/mkspecs/common/android/qplatformdefs.h
+@@ -144,11 +144,7 @@
+ #define QT_SIGNAL_ARGS          int
+ #define QT_SIGNAL_IGNORE        SIG_IGN
+ 
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+ #define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+ 
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+diff --git a/qtbase/mkspecs/features/mac/sdk.mk b/qtbase/mkspecs/features/mac/sdk.mk
+index f30b5830b4..a32ceacb6c 100644
+--- a/qtbase/mkspecs/features/mac/sdk.mk
++++ b/qtbase/mkspecs/features/mac/sdk.mk
+@@ -1,6 +1,6 @@
+ 
+ ifeq ($(QT_MAC_SDK_NO_VERSION_CHECK),)
+-    CHECK_SDK_COMMAND = /usr/bin/xcrun --sdk $(EXPORT_QMAKE_MAC_SDK) -show-sdk-version 2>&1
++    CHECK_SDK_COMMAND = /usr/bin/xcrun --sdk $(EXPORT_QMAKE_MAC_SDK) -show-sdk-version 2>/dev/null
+     CURRENT_MAC_SDK_VERSION := $(shell DEVELOPER_DIR=$(EXPORT_QMAKE_XCODE_DEVELOPER_PATH) $(CHECK_SDK_COMMAND))
+     ifneq ($(CURRENT_MAC_SDK_VERSION),$(EXPORT_QMAKE_MAC_SDK_VERSION))
+         # We don't want to complain about out of date SDK unless the target needs to be remade.
+diff --git a/qtbase/mkspecs/linux-clang/qplatformdefs.h b/qtbase/mkspecs/linux-clang/qplatformdefs.h
+index a818d973f0..c1ab72fbc6 100644
+--- a/qtbase/mkspecs/linux-clang/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-clang/qplatformdefs.h
+@@ -79,14 +79,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-g++/qplatformdefs.h b/qtbase/mkspecs/linux-g++/qplatformdefs.h
+index 13523f0702..4d2750d9ec 100644
+--- a/qtbase/mkspecs/linux-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-g++/qplatformdefs.h
+@@ -79,14 +79,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ < 2)
+-#define QT_SOCKLEN_T            int
+-#else
+-#define QT_SOCKLEN_T            socklen_t
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-llvm/qplatformdefs.h b/qtbase/mkspecs/linux-llvm/qplatformdefs.h
+index dc750ab1ef..d3cc39b47f 100644
+--- a/qtbase/mkspecs/linux-llvm/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-llvm/qplatformdefs.h
+@@ -80,14 +80,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h b/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
+index 4c4e53da2a..83baffb3e3 100644
+--- a/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
+@@ -85,16 +85,9 @@
+ #include "../common/posix/qplatformdefs.h"
+ 
+ #undef QT_OPEN_LARGEFILE
+-#undef QT_SOCKLEN_T
+ 
+ #define QT_OPEN_LARGEFILE       0
+ 
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #ifndef SIOCGIFBRDADDR
+ #  define SIOCGIFBRDADDR 0x8919
+ #endif
+diff --git a/qtbase/mkspecs/lynxos-g++/qplatformdefs.h b/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
+index 4339ea2b23..6007af0055 100644
+--- a/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
+@@ -72,14 +72,6 @@
+ 
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp b/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
+index c3c184258f..32af3f8f29 100644
+--- a/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
++++ b/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
+@@ -10,6 +10,7 @@
+ #include "libANGLE/HandleAllocator.h"
+ 
+ #include <algorithm>
++#include <limits>
+ 
+ #include "common/debug.h"
+ 
+diff --git a/qtbase/src/3rdparty/forkfd/forkfd_linux.c b/qtbase/src/3rdparty/forkfd/forkfd_linux.c
+index ffe0e9a5e2..b1f5408d11 100644
+--- a/qtbase/src/3rdparty/forkfd/forkfd_linux.c
++++ b/qtbase/src/3rdparty/forkfd/forkfd_linux.c
+@@ -82,7 +82,8 @@ static int sys_clone(unsigned long cloneflags, int *ptid)
+     return syscall(__NR_clone, cloneflags, child_stack, stack_size, ptid, newtls, ctid);
+ #elif defined(__arc__) || defined(__arm__) || defined(__aarch64__) || defined(__mips__) || \
+     defined(__nds32__) || defined(__hppa__) || defined(__powerpc__) || defined(__i386__) || \
+-    defined(__x86_64__) || defined(__xtensa__) || defined(__alpha__) || defined(__riscv)
++    defined(__x86_64__) || defined(__xtensa__) || defined(__alpha__) || defined(__riscv) || \
++    defined(__loongarch__)
+     /* ctid and newtls are inverted on CONFIG_CLONE_BACKWARDS architectures,
+      * but since both values are 0, there's no harm. */
+     return syscall(__NR_clone, cloneflags, child_stack, ptid, ctid, newtls);
+diff --git a/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java b/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
+index 5792b5b2f5..2f74750fcf 100644
+--- a/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
++++ b/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
+@@ -116,6 +116,7 @@ public class QtNative
+     public static QtThread m_qtThread = new QtThread();
+     private static HashMap<String, Uri> m_cachedUris = new HashMap<String, Uri>();
+     private static ArrayList<String> m_knownDirs = new ArrayList<String>();
++    private static final String NoPermissionErrorMessage = "No permissions to open Uri";
+ 
+     private static final Runnable runPendingCppRunnablesRunnable = new Runnable() {
+         @Override
+@@ -193,11 +194,10 @@ public class QtNative
+                     return iterUri;
+             }
+ 
+-            // Android 6 and earlier could still manage to open the file so we can return the
+-            // parsed uri here
+-            if (Build.VERSION.SDK_INT < 24)
+-                return parsedUri;
+-            return null;
++            // if we only have transient permissions on uri all the above will fail,
++            // but we will be able to read the file anyway, so continue with uri here anyway
++            // and check for SecurityExceptions later
++            return parsedUri;
+         } catch (SecurityException e) {
+             e.printStackTrace();
+             return null;
+@@ -244,7 +244,7 @@ public class QtNative
+         int error = -1;
+ 
+         if (uri == null) {
+-            Log.e(QtTAG, "openFdForContentUrl(): No permissions to open Uri");
++            Log.e(QtTAG, "openFdForContentUrl(): " + NoPermissionErrorMessage);
+             return error;
+         }
+ 
+@@ -254,12 +254,13 @@ public class QtNative
+             return fdDesc.detachFd();
+         } catch (FileNotFoundException e) {
+             e.printStackTrace();
+-            return error;
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "openFdForContentUrl(): Invalid Uri");
+             e.printStackTrace();
+-            return error;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return error;
+     }
+ 
+     public static long getSize(Context context, String contentUrl)
+@@ -270,7 +271,7 @@ public class QtNative
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+ 
+         if (uri == null) {
+-            Log.e(QtTAG, "getSize(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return size;
+         } else if (!m_cachedUris.containsKey(contentUrl)) {
+             m_cachedUris.put(contentUrl, uri);
+@@ -288,12 +289,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "getSize(): Invalid Uri");
+             e.printStackTrace();
+-            return size;
+         }  catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "getSize(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return size;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return size;
+     }
+ 
+     public static boolean checkFileExists(Context context, String contentUrl)
+@@ -303,7 +305,7 @@ public class QtNative
+         if (uri == null)
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+         if (uri == null) {
+-            Log.e(QtTAG, "checkFileExists(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return exists;
+         } else {
+             if (!m_cachedUris.containsKey(contentUrl))
+@@ -321,12 +323,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "checkFileExists(): Invalid Uri");
+             e.printStackTrace();
+-            return exists;
+         } catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "checkFileExists(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return false;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return exists;
+     }
+ 
+     public static boolean checkIfWritable(Context context, String contentUrl)
+@@ -344,7 +347,7 @@ public class QtNative
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+         }
+         if (uri == null) {
+-            Log.e(QtTAG, "isDir(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return isDir;
+         } else {
+             if (!m_cachedUris.containsKey(contentUrl))
+@@ -374,12 +377,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "checkIfDir(): Invalid Uri");
+             e.printStackTrace();
+-            return false;
+         } catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "checkIfDir(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return false;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return false;
+     }
+     public static String[] listContentsFromTreeUri(Context context, String contentUrl)
+     {
+diff --git a/qtbase/src/concurrent/qtconcurrentreducekernel.h b/qtbase/src/concurrent/qtconcurrentreducekernel.h
+index 8f9a938952..a98dedef2e 100644
+--- a/qtbase/src/concurrent/qtconcurrentreducekernel.h
++++ b/qtbase/src/concurrent/qtconcurrentreducekernel.h
+@@ -212,11 +212,13 @@ public:
+ 
+     inline bool shouldThrottle()
+     {
++        std::lock_guard<QMutex> locker(mutex);
+         return (resultsMapSize > (ReduceQueueThrottleLimit * threadCount));
+     }
+ 
+     inline bool shouldStartThread()
+     {
++        std::lock_guard<QMutex> locker(mutex);
+         return (resultsMapSize <= (ReduceQueueStartLimit * threadCount));
+     }
+ };
+diff --git a/qtbase/src/concurrent/qtconcurrentthreadengine.cpp b/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
+index ea6ce3ac42..7f91a2ba68 100644
+--- a/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
++++ b/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
+@@ -176,6 +176,39 @@ void ThreadEngineBase::startSingleThreaded()
+     finish();
+ }
+ 
++void ThreadEngineBase::startBlocking()
++{
++    start();
++    barrier.acquire();
++    startThreads();
++
++    bool throttled = false;
++#ifndef QT_NO_EXCEPTIONS
++    try {
++#endif
++        while (threadFunction() == ThrottleThread) {
++            if (threadThrottleExit()) {
++                throttled = true;
++                break;
++            }
++        }
++#ifndef QT_NO_EXCEPTIONS
++    } catch (QException &e) {
++        handleException(e);
++    } catch (...) {
++        handleException(QUnhandledException());
++    }
++#endif
++
++    if (throttled == false) {
++        barrier.release();
++    }
++
++    barrier.wait();
++    finish();
++    exceptionStore.throwPossibleException();
++}
++
+ void ThreadEngineBase::startThread()
+ {
+     startThreadInternal();
+diff --git a/qtbase/src/concurrent/qtconcurrentthreadengine.h b/qtbase/src/concurrent/qtconcurrentthreadengine.h
+index 7c30cebdbc..a4c8548cc4 100644
+--- a/qtbase/src/concurrent/qtconcurrentthreadengine.h
++++ b/qtbase/src/concurrent/qtconcurrentthreadengine.h
+@@ -91,6 +91,7 @@ public:
+     ThreadEngineBase();
+     virtual ~ThreadEngineBase();
+     void startSingleThreaded();
++    void startBlocking();
+     void startThread();
+     bool isCanceled();
+     void waitForResume();
+@@ -143,6 +144,15 @@ public:
+         return result();
+     }
+ 
++    // Runs the user algorithm using multiple threads.
++    // This function blocks until the algorithm is finished,
++    // and then returns the result.
++    T *startBlocking()
++    {
++        ThreadEngineBase::startBlocking();
++        return result();
++    }
++
+     // Runs the user algorithm using multiple threads.
+     // Does not block, returns a future.
+     QFuture<T> startAsynchronously()
+@@ -223,6 +233,13 @@ class ThreadEngineStarter : public ThreadEngineStarterBase<T>
+ public:
+     ThreadEngineStarter(TypedThreadEngine *eng)
+         : Base(eng) { }
++
++    T startBlocking()
++    {
++        T t = *this->threadEngine->startBlocking();
++        delete this->threadEngine;
++        return t;
++    }
+ };
+ 
+ // Full template specialization where T is void.
+@@ -232,6 +249,12 @@ class ThreadEngineStarter<void> : public ThreadEngineStarterBase<void>
+ public:
+     ThreadEngineStarter(ThreadEngine<void> *_threadEngine)
+         : ThreadEngineStarterBase<void>(_threadEngine) {}
++
++    void startBlocking()
++    {
++        this->threadEngine->startBlocking();
++        delete this->threadEngine;
++    }
+ };
+ 
+ //! [qtconcurrentthreadengine-1]
+diff --git a/qtbase/src/corelib/animation/qvariantanimation.cpp b/qtbase/src/corelib/animation/qvariantanimation.cpp
+index 98b02f0202..eac1524107 100644
+--- a/qtbase/src/corelib/animation/qvariantanimation.cpp
++++ b/qtbase/src/corelib/animation/qvariantanimation.cpp
+@@ -276,7 +276,9 @@ void QVariantAnimationPrivate::setCurrentValueForProgress(const qreal progress)
+ 
+     const qreal startProgress = currentInterval.start.first;
+     const qreal endProgress = currentInterval.end.first;
+-    const qreal localProgress = (progress - startProgress) / (endProgress - startProgress);
++    const qreal localProgress =
++            qIsNull(progress - startProgress) ? 0.0 // avoid 0/0 below
++            /* else */                        : (progress - startProgress) / (endProgress - startProgress);
+ 
+     QVariant ret = q->interpolated(currentInterval.start.second,
+                                    currentInterval.end.second,
+diff --git a/qtbase/src/corelib/global/qnamespace.h b/qtbase/src/corelib/global/qnamespace.h
+index ad4150b317..bf19b1627b 100644
+--- a/qtbase/src/corelib/global/qnamespace.h
++++ b/qtbase/src/corelib/global/qnamespace.h
+@@ -1864,7 +1864,7 @@ public:
+     QT_Q_ENUM(TimerType)
+     QT_Q_ENUM(ScrollPhase)
+     QT_Q_ENUM(MouseEventSource)
+-    QT_Q_FLAG(MouseEventFlag)
++    QT_Q_FLAG(MouseEventFlags)
+     QT_Q_ENUM(ChecksumType)
+     QT_Q_ENUM(HighDpiScaleFactorRoundingPolicy)
+     QT_Q_ENUM(TabFocusBehavior)
+diff --git a/qtbase/src/corelib/global/qrandom.cpp b/qtbase/src/corelib/global/qrandom.cpp
+index 10672c1f92..25f87c7e6a 100644
+--- a/qtbase/src/corelib/global/qrandom.cpp
++++ b/qtbase/src/corelib/global/qrandom.cpp
+@@ -383,7 +383,6 @@ struct QRandomGenerator::SystemAndGlobalGenerators
+ 
+         constexpr SystemAndGlobalGenerators g = {};
+         Q_UNUSED(g);
+-        Q_STATIC_ASSERT(std::is_literal_type<SystemAndGlobalGenerators>::value);
+ #endif
+     }
+ 
+diff --git a/qtbase/src/corelib/io/qbuffer.cpp b/qtbase/src/corelib/io/qbuffer.cpp
+index 595fcd2724..032c0ddd4b 100644
+--- a/qtbase/src/corelib/io/qbuffer.cpp
++++ b/qtbase/src/corelib/io/qbuffer.cpp
+@@ -41,6 +41,8 @@
+ #include <QtCore/qmetaobject.h>
+ #include "private/qiodevice_p.h"
+ 
++#include <limits>
++
+ QT_BEGIN_NAMESPACE
+ 
+ /** QBufferPrivate **/
+@@ -366,7 +368,9 @@ qint64 QBuffer::size() const
+ bool QBuffer::seek(qint64 pos)
+ {
+     Q_D(QBuffer);
+-    if (pos > d->buf->size() && isWritable()) {
++    const auto oldBufSize = d->buf->size();
++    constexpr qint64 MaxSeekPos = (std::numeric_limits<decltype(oldBufSize)>::max)();
++    if (pos <= MaxSeekPos && pos > oldBufSize && isWritable()) {
+         if (seek(d->buf->size())) {
+             const qint64 gapSize = pos - d->buf->size();
+             if (write(QByteArray(gapSize, 0)) != gapSize) {
+@@ -377,7 +381,7 @@ bool QBuffer::seek(qint64 pos)
+             return false;
+         }
+     } else if (pos > d->buf->size() || pos < 0) {
+-        qWarning("QBuffer::seek: Invalid pos: %d", int(pos));
++        qWarning("QBuffer::seek: Invalid pos: %lld", pos);
+         return false;
+     }
+     return QIODevice::seek(pos);
+diff --git a/qtbase/src/corelib/io/qfilesystemengine_win.cpp b/qtbase/src/corelib/io/qfilesystemengine_win.cpp
+index 81d3a71986..c86ed1f9b0 100644
+--- a/qtbase/src/corelib/io/qfilesystemengine_win.cpp
++++ b/qtbase/src/corelib/io/qfilesystemengine_win.cpp
+@@ -664,14 +664,14 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry)
+     return QFileSystemEntry(ret, QFileSystemEntry::FromInternalPath());
+ }
+ 
+-#if defined(Q_CC_MINGW) && WINVER < 0x0602 //  Windows 8 onwards
++#if defined(Q_CC_MINGW) && WINVER < 0x0602 && _WIN32_WINNT < _WIN32_WINNT_WIN8 //  Windows 8 onwards
+ 
+ typedef struct _FILE_ID_INFO {
+     ULONGLONG VolumeSerialNumber;
+     FILE_ID_128 FileId;
+ } FILE_ID_INFO, *PFILE_ID_INFO;
+ 
+-#endif // if defined (Q_CC_MINGW) && WINVER < 0x0602
++#endif // if defined(Q_CC_MINGW) && WINVER < 0x0602 && _WIN32_WINNT < _WIN32_WINNT_WIN8
+ 
+ // File ID for Windows up to version 7 and FAT32 drives
+ static inline QByteArray fileId(HANDLE handle)
+diff --git a/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp b/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
+index 94d9d06bcb..27e0b13b0b 100644
+--- a/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
++++ b/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
+@@ -366,7 +366,9 @@ void QInotifyFileSystemWatcherEngine::readFromInotify()
+     // qDebug("QInotifyFileSystemWatcherEngine::readFromInotify");
+ 
+     int buffSize = 0;
+-    ioctl(inotifyFd, FIONREAD, (char *) &buffSize);
++    if (ioctl(inotifyFd, FIONREAD, (char *) &buffSize) == -1 || buffSize == 0)
++        return;
++
+     QVarLengthArray<char, 4096> buffer(buffSize);
+     buffSize = read(inotifyFd, buffer.data(), buffSize);
+     char *at = buffer.data();
+diff --git a/qtbase/src/corelib/io/qlockfile_win.cpp b/qtbase/src/corelib/io/qlockfile_win.cpp
+index 277f8d4230..38ecef5550 100644
+--- a/qtbase/src/corelib/io/qlockfile_win.cpp
++++ b/qtbase/src/corelib/io/qlockfile_win.cpp
+@@ -48,6 +48,8 @@
+ #include "QtCore/qdebug.h"
+ #include "QtCore/qthread.h"
+ 
++#include "private/qsystemlibrary_p.h"
++
+ QT_BEGIN_NAMESPACE
+ 
+ static inline bool fileExists(const wchar_t *fileName)
+@@ -150,7 +152,7 @@ QString QLockFilePrivate::processNameByPid(qint64 pid)
+ #if !defined(Q_OS_WINRT)
+     typedef DWORD (WINAPI *GetModuleFileNameExFunc)(HANDLE, HMODULE, LPTSTR, DWORD);
+ 
+-    HMODULE hPsapi = LoadLibraryA("psapi");
++    HMODULE hPsapi = QSystemLibrary::load(L"psapi");
+     if (!hPsapi)
+         return QString();
+     GetModuleFileNameExFunc qGetModuleFileNameEx = reinterpret_cast<GetModuleFileNameExFunc>(
+diff --git a/qtbase/src/corelib/io/qprocess_unix.cpp b/qtbase/src/corelib/io/qprocess_unix.cpp
+index 50390e57f5..15c8f30745 100644
+--- a/qtbase/src/corelib/io/qprocess_unix.cpp
++++ b/qtbase/src/corelib/io/qprocess_unix.cpp
+@@ -1,7 +1,7 @@
+ /****************************************************************************
+ **
+ ** Copyright (C) 2016 The Qt Company Ltd.
+-** Copyright (C) 2016 Intel Corporation.
++** Copyright (C) 2022 Intel Corporation.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtCore module of the Qt Toolkit.
+@@ -422,14 +422,15 @@ void QProcessPrivate::startProcess()
+     // Add the program name to the argument list.
+     argv[0] = nullptr;
+     if (!program.contains(QLatin1Char('/'))) {
++        // findExecutable() returns its argument if it's an absolute path,
++        // otherwise it searches $PATH; returns empty if not found (we handle
++        // that case much later)
+         const QString &exeFilePath = QStandardPaths::findExecutable(program);
+-        if (!exeFilePath.isEmpty()) {
+-            const QByteArray &tmp = QFile::encodeName(exeFilePath);
+-            argv[0] = ::strdup(tmp.constData());
+-        }
+-    }
+-    if (!argv[0])
++        const QByteArray &tmp = QFile::encodeName(exeFilePath);
++        argv[0] = ::strdup(tmp.constData());
++    } else {
+         argv[0] = ::strdup(encodedProgramName.constData());
++    }
+ 
+     // Add every argument to the list
+     for (int i = 0; i < arguments.count(); ++i)
+@@ -983,15 +984,16 @@ bool QProcessPrivate::startDetached(qint64 *pid)
+                 envp = _q_dupEnvironment(environment.d.constData()->vars, &envc);
+             }
+ 
+-            QByteArray tmp;
+             if (!program.contains(QLatin1Char('/'))) {
++                // findExecutable() returns its argument if it's an absolute path,
++                // otherwise it searches $PATH; returns empty if not found (we handle
++                // that case much later)
+                 const QString &exeFilePath = QStandardPaths::findExecutable(program);
+-                if (!exeFilePath.isEmpty())
+-                    tmp = QFile::encodeName(exeFilePath);
++                const QByteArray &tmp = QFile::encodeName(exeFilePath);
++                argv[0] = ::strdup(tmp.constData());
++            } else {
++                argv[0] = ::strdup(QFile::encodeName(program));
+             }
+-            if (tmp.isEmpty())
+-                tmp = QFile::encodeName(program);
+-            argv[0] = tmp.data();
+ 
+             if (envp)
+                 qt_safe_execve(argv[0], argv, envp);
+diff --git a/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp b/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
+index 3a79c502af..997a634e76 100644
+--- a/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
++++ b/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
+@@ -3196,9 +3196,8 @@ bool QAbstractItemModel::beginMoveColumns(const QModelIndex &sourceParent, int s
+     destinationChange.needsAdjust = destinationParent.isValid() && destinationParent.row() >= sourceLast && destinationParent.parent() == sourceParent;
+     d->changes.push(destinationChange);
+ 
+-    d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Horizontal);
+-
+     emit columnsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, QPrivateSignal());
++    d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Horizontal);
+     return true;
+ }
+ 
+@@ -3231,7 +3230,6 @@ void QAbstractItemModel::endMoveColumns()
+       adjustedSource = createIndex(adjustedSource.row(), adjustedSource.column() + numMoved, adjustedSource.internalPointer());
+ 
+     d->itemsMoved(adjustedSource, removeChange.first, removeChange.last, adjustedDestination, insertChange.first, Qt::Horizontal);
+-
+     emit columnsMoved(adjustedSource, removeChange.first, removeChange.last, adjustedDestination, insertChange.first, QPrivateSignal());
+ }
+ 
+diff --git a/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+index dc6379d9fb..c5e287ee84 100644
+--- a/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
++++ b/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+@@ -939,8 +939,9 @@ void QSortFilterProxyModelPrivate::insert_source_items(
+                 q->beginInsertColumns(proxy_parent, proxy_start, proxy_end);
+         }
+ 
+-        for (int i = 0; i < source_items.size(); ++i)
+-            proxy_to_source.insert(proxy_start + i, source_items.at(i));
++        // TODO: use the range QList::insert() overload once it is implemented (QTBUG-58633).
++        proxy_to_source.insert(proxy_start, source_items.size(), 0);
++        std::copy(source_items.cbegin(), source_items.cend(), proxy_to_source.begin() + proxy_start);
+ 
+         build_source_to_proxy_mapping(proxy_to_source, source_to_proxy);
+ 
+@@ -3123,8 +3124,9 @@ bool QSortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex &
+ 
+     if (d->filter_data.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();
+@@ -3133,9 +3135,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.hasMatch(key);
+ }
+diff --git a/qtbase/src/corelib/kernel/qcoreapplication.cpp b/qtbase/src/corelib/kernel/qcoreapplication.cpp
+index ca2864df83..132b2eae52 100644
+--- a/qtbase/src/corelib/kernel/qcoreapplication.cpp
++++ b/qtbase/src/corelib/kernel/qcoreapplication.cpp
+@@ -1157,7 +1157,7 @@ static bool doNotify(QObject *receiver, QEvent *event)
+ bool QCoreApplicationPrivate::sendThroughApplicationEventFilters(QObject *receiver, QEvent *event)
+ {
+     // We can't access the application event filters outside of the main thread (race conditions)
+-    Q_ASSERT(receiver->d_func()->threadData.loadRelaxed()->thread.loadAcquire() == mainThread());
++    Q_ASSERT(receiver->d_func()->threadData.loadAcquire()->thread.loadRelaxed() == mainThread());
+ 
+     if (extraData) {
+         // application event filters are only called for objects in the GUI thread
+diff --git a/qtbase/src/corelib/kernel/qobject.cpp b/qtbase/src/corelib/kernel/qobject.cpp
+index 1eb79138d9..36cd780ee1 100644
+--- a/qtbase/src/corelib/kernel/qobject.cpp
++++ b/qtbase/src/corelib/kernel/qobject.cpp
+@@ -1010,7 +1010,7 @@ QObject::~QObject()
+         emit destroyed(this);
+     }
+ 
+-    if (d->declarativeData) {
++    if (!d->isDeletingChildren && d->declarativeData) {
+         if (static_cast<QAbstractDeclarativeDataImpl*>(d->declarativeData)->ownedByQml1) {
+             if (QAbstractDeclarativeData::destroyed_qml1)
+                 QAbstractDeclarativeData::destroyed_qml1(d->declarativeData, this);
+@@ -1580,7 +1580,7 @@ void QObject::moveToThread(QThread *targetThread)
+ 
+     QThreadData *currentData = QThreadData::current();
+     QThreadData *targetData = targetThread ? QThreadData::get2(targetThread) : nullptr;
+-    QThreadData *thisThreadData = d->threadData.loadRelaxed();
++    QThreadData *thisThreadData = d->threadData.loadAcquire();
+     if (!thisThreadData->thread.loadAcquire() && currentData == targetData) {
+         // one exception to the rule: we allow moving objects with no thread affinity to the current thread
+         currentData = d->threadData;
+@@ -2620,7 +2620,7 @@ int QObject::receivers(const char *signal) const
+         if (!d->isSignalConnected(signal_index))
+             return receivers;
+ 
+-        if (d->declarativeData && QAbstractDeclarativeData::receivers) {
++        if (!d->isDeletingChildren && d->declarativeData && QAbstractDeclarativeData::receivers) {
+             receivers += QAbstractDeclarativeData::receivers(d->declarativeData, this,
+                                                              signal_index);
+         }
+diff --git a/qtbase/src/corelib/kernel/qobject_p.h b/qtbase/src/corelib/kernel/qobject_p.h
+index 0b827a52ca..13ffb88999 100644
+--- a/qtbase/src/corelib/kernel/qobject_p.h
++++ b/qtbase/src/corelib/kernel/qobject_p.h
+@@ -444,7 +444,7 @@ inline void QObjectPrivate::checkForIncompatibleLibraryVersion(int version) cons
+ 
+ inline bool QObjectPrivate::isDeclarativeSignalConnected(uint signal_index) const
+ {
+-    return declarativeData && QAbstractDeclarativeData::isSignalConnected
++    return !isDeletingChildren && declarativeData && QAbstractDeclarativeData::isSignalConnected
+             && QAbstractDeclarativeData::isSignalConnected(declarativeData, q_func(), signal_index);
+ }
+ 
+diff --git a/qtbase/src/corelib/kernel/qtranslator.cpp b/qtbase/src/corelib/kernel/qtranslator.cpp
+index 2812ffb7ea..bc0177c5ec 100644
+--- a/qtbase/src/corelib/kernel/qtranslator.cpp
++++ b/qtbase/src/corelib/kernel/qtranslator.cpp
+@@ -902,7 +902,7 @@ static QString getMessage(const uchar *m, const uchar *end, const char *context,
+             goto end;
+         case Tag_Translation: {
+             int len = read32(m);
+-            if (len % 1)
++            if (len & 1)
+                 return QString();
+             m += 4;
+             if (!numerus--) {
+diff --git a/qtbase/src/corelib/mimetypes/qmimedatabase.cpp b/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
+index 9de22cef33..ff868a3268 100644
+--- a/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
+@@ -389,20 +389,23 @@ QMimeType QMimeDatabasePrivate::mimeTypeForFileNameAndData(const QString &fileNa
+         // Disambiguate conflicting extensions (if magic matching found something)
+         if (candidateByData.isValid() && magicAccuracy > 0) {
+             const QString sniffedMime = candidateByData.name();
+-            // If the sniffedMime matches a glob match, use it
++            // If the sniffedMime matches a highest-weight glob match, use it
+             if (candidatesByName.m_matchingMimeTypes.contains(sniffedMime)) {
+                 *accuracyPtr = 100;
+                 return candidateByData;
+             }
+-            for (const QString &m : qAsConst(candidatesByName.m_matchingMimeTypes)) {
++            for (const QString &m : qAsConst(candidatesByName.m_allMatchingMimeTypes)) {
+                 if (inherits(m, sniffedMime)) {
+                     // We have magic + pattern pointing to this, so it's a pretty good match
+                     *accuracyPtr = 100;
+                     return mimeTypeForName(m);
+                 }
+             }
+-            *accuracyPtr = magicAccuracy;
+-            return candidateByData;
++            if (candidatesByName.m_allMatchingMimeTypes.isEmpty()) {
++                // No glob, use magic
++                *accuracyPtr = magicAccuracy;
++                return candidateByData;
++            }
+         }
+     }
+ 
+diff --git a/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp b/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
+index a81112d227..fa8f4c545d 100644
+--- a/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
+@@ -83,7 +83,10 @@ void QMimeGlobMatchResult::addMatch(const QString &mimeType, int weight, const Q
+     }
+     if (!m_matchingMimeTypes.contains(mimeType)) {
+         m_matchingMimeTypes.append(mimeType);
+-        m_allMatchingMimeTypes.append(mimeType);
++        if (replace)
++            m_allMatchingMimeTypes.prepend(mimeType); // highest-weight first
++        else
++            m_allMatchingMimeTypes.append(mimeType);
+         m_knownSuffixLength = knownSuffixLength;
+     }
+ }
+@@ -94,7 +97,7 @@ QMimeGlobPattern::PatternType QMimeGlobPattern::detectPatternType(const QString
+     if (!patternLength)
+         return OtherPattern;
+ 
+-    const bool starCount = pattern.count(QLatin1Char('*')) == 1;
++    const int starCount = pattern.count(QLatin1Char('*'));
+     const bool hasSquareBracket = pattern.indexOf(QLatin1Char('[')) != -1;
+     const bool hasQuestionMark = pattern.indexOf(QLatin1Char('?')) != -1;
+ 
+@@ -106,10 +109,10 @@ QMimeGlobPattern::PatternType QMimeGlobPattern::detectPatternType(const QString
+             // Patterns like "README*" (well this is currently the only one like that...)
+             if (pattern.at(patternLength - 1) == QLatin1Char('*'))
+                 return PrefixPattern;
+-        }
+-        // Names without any wildcards like "README"
+-        if (starCount == 0)
++        } else if (starCount == 0) {
++            // Names without any wildcards like "README"
+             return LiteralPattern;
++        }
+     }
+ 
+     if (pattern == QLatin1String("[0-9][0-9][0-9].vdr"))
+diff --git a/qtbase/src/corelib/mimetypes/qmimeprovider.cpp b/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
+index 258dddf8cb..4642d0f2d0 100644
+--- a/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
+@@ -244,15 +244,18 @@ void QMimeBinaryProvider::addFileNameMatches(const QString &fileName, QMimeGlobM
+     const QString lowerFileName = fileName.toLower();
+     // Check literals (e.g. "Makefile")
+     matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosLiteralListOffset), fileName);
+-    // Check complex globs (e.g. "callgrind.out[0-9]*")
+-    matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosGlobListOffset), fileName);
+     // Check the very common *.txt cases with the suffix tree
+-    const int reverseSuffixTreeOffset = m_cacheFile->getUint32(PosReverseSuffixTreeOffset);
+-    const int numRoots = m_cacheFile->getUint32(reverseSuffixTreeOffset);
+-    const int firstRootOffset = m_cacheFile->getUint32(reverseSuffixTreeOffset + 4);
+-    matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, lowerFileName, lowerFileName.length() - 1, false);
++    if (result.m_matchingMimeTypes.isEmpty()) {
++        const int reverseSuffixTreeOffset = m_cacheFile->getUint32(PosReverseSuffixTreeOffset);
++        const int numRoots = m_cacheFile->getUint32(reverseSuffixTreeOffset);
++        const int firstRootOffset = m_cacheFile->getUint32(reverseSuffixTreeOffset + 4);
++        matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, lowerFileName, lowerFileName.length() - 1, false);
++        if (result.m_matchingMimeTypes.isEmpty())
++            matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, fileName, fileName.length() - 1, true);
++    }
++    // Check complex globs (e.g. "callgrind.out[0-9]*" or "README*")
+     if (result.m_matchingMimeTypes.isEmpty())
+-        matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, fileName, fileName.length() - 1, true);
++        matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosGlobListOffset), fileName);
+ }
+ 
+ void QMimeBinaryProvider::matchGlobList(QMimeGlobMatchResult &result, CacheFile *cacheFile, int off, const QString &fileName)
+diff --git a/qtbase/src/corelib/serialization/qjsonparser.cpp b/qtbase/src/corelib/serialization/qjsonparser.cpp
+index 17e6f111ab..2e40b6c8fb 100644
+--- a/qtbase/src/corelib/serialization/qjsonparser.cpp
++++ b/qtbase/src/corelib/serialization/qjsonparser.cpp
+@@ -379,10 +379,30 @@ error:
+     return QCborValue();
+ }
+ 
++// We need to retain the _last_ value for any duplicate keys and we need to deref containers.
++// Therefore the manual implementation of std::unique().
++template<typename Iterator, typename Compare, typename Assign>
++static Iterator customAssigningUniqueLast(Iterator first, Iterator last,
++                                          Compare compare, Assign assign)
++{
++    first = std::adjacent_find(first, last, compare);
++    if (first == last)
++        return last;
++
++    Iterator result = first;
++    while (++first != last) {
++        if (!compare(*result, *first))
++            ++result;
++        if (result != first)
++            assign(*result, *first);
++    }
++
++    return ++result;
++}
++
+ static void sortContainer(QCborContainerPrivate *container)
+ {
+     using Forward = QJsonPrivate::KeyIterator;
+-    using Reverse = std::reverse_iterator<Forward>;
+     using Value = Forward::value_type;
+ 
+     auto compare = [container](const Value &a, const Value &b)
+@@ -420,17 +440,31 @@ static void sortContainer(QCborContainerPrivate *container)
+         }
+     };
+ 
+-    std::sort(Forward(container->elements.begin()), Forward(container->elements.end()),
+-              [&compare](const Value &a, const Value &b) { return compare(a, b) < 0; });
++    // The elements' containers are owned by the outer container, not by the elements themselves.
++    auto move = [](Forward::reference target, Forward::reference source)
++    {
++        QtCbor::Element &targetValue = target.value();
++
++        // If the target has a container, deref it before overwriting, so that we don't leak.
++        if (targetValue.flags & QtCbor::Element::IsContainer)
++            targetValue.container->deref();
++
++        // Do not move, so that we can clear the value afterwards.
++        target = source;
++
++        // Clear the source value, so that we don't store the same container twice.
++        source.value() = QtCbor::Element();
++    };
++
++    std::stable_sort(
++                Forward(container->elements.begin()), Forward(container->elements.end()),
++                [&compare](const Value &a, const Value &b) { return compare(a, b) < 0; });
+ 
+-    // We need to retain the _last_ value for any duplicate keys. Therefore the reverse dance here.
+-    auto it = std::unique(Reverse(container->elements.end()), Reverse(container->elements.begin()),
+-                          [&compare](const Value &a, const Value &b) {
+-        return compare(a, b) == 0;
+-    }).base().elementsIterator();
++    Forward result = customAssigningUniqueLast(
++                Forward(container->elements.begin()),  Forward(container->elements.end()),
++                [&compare](const Value &a, const Value &b) { return compare(a, b) == 0; }, move);
+ 
+-    // The erase from beginning is expensive but hopefully rare.
+-    container->elements.erase(container->elements.begin(), it);
++    container->elements.erase(result.elementsIterator(), container->elements.end());
+ }
+ 
+ 
+diff --git a/qtbase/src/corelib/serialization/qxmlstream.cpp b/qtbase/src/corelib/serialization/qxmlstream.cpp
+index b2f846544d..7cd457ba3a 100644
+--- a/qtbase/src/corelib/serialization/qxmlstream.cpp
++++ b/qtbase/src/corelib/serialization/qxmlstream.cpp
+@@ -980,7 +980,7 @@ inline uint QXmlStreamReaderPrivate::peekChar()
+ bool QXmlStreamReaderPrivate::scanUntil(const char *str, short tokenToInject)
+ {
+     int pos = textBuffer.size();
+-    int oldLineNumber = lineNumber;
++    const auto oldLineNumber = lineNumber;
+ 
+     uint c;
+     while ((c = getChar()) != StreamEOF) {
+diff --git a/qtbase/src/corelib/text/qstring.cpp b/qtbase/src/corelib/text/qstring.cpp
+index 3e88ab4859..8deeae47bb 100644
+--- a/qtbase/src/corelib/text/qstring.cpp
++++ b/qtbase/src/corelib/text/qstring.cpp
+@@ -12312,7 +12312,7 @@ static qsizetype qLastIndexOf(Haystack haystack0, qsizetype from,
+     const auto needle = needle0.data();
+     const auto *end = haystack;
+     haystack += from;
+-    const std::size_t sl_minus_1 = sl - 1;
++    const std::size_t sl_minus_1 = sl ? sl - 1 : 0;
+     const auto *n = needle + sl_minus_1;
+     const auto *h = haystack + sl_minus_1;
+     std::size_t hashNeedle = 0, hashHaystack = 0;
+diff --git a/qtbase/src/corelib/text/qstringiterator_p.h b/qtbase/src/corelib/text/qstringiterator_p.h
+index 219589b6e4..1d0c66cc78 100644
+--- a/qtbase/src/corelib/text/qstringiterator_p.h
++++ b/qtbase/src/corelib/text/qstringiterator_p.h
+@@ -61,6 +61,8 @@ class QStringIterator
+ {
+     QString::const_iterator i, pos, e;
+     Q_STATIC_ASSERT((std::is_same<QString::const_iterator, const QChar *>::value));
++    static bool less(const QChar *lhs, const QChar *rhs) noexcept
++    { return std::less<QString::const_iterator>{}(lhs, rhs); }
+ public:
+     explicit QStringIterator(QStringView string, qsizetype idx = 0)
+         : i(string.begin()),
+@@ -95,7 +97,8 @@ public:
+ 
+     inline void setPosition(QString::const_iterator position)
+     {
+-        Q_ASSERT_X(i <= position && position <= e, Q_FUNC_INFO, "position out of bounds");
++        Q_ASSERT_X(!less(position, i) && !less(e, position),
++                   Q_FUNC_INFO, "position out of bounds");
+         pos = position;
+     }
+ 
+@@ -103,7 +106,7 @@ public:
+ 
+     inline bool hasNext() const
+     {
+-        return pos < e;
++        return less(pos, e);
+     }
+ 
+     inline void advance()
+@@ -120,16 +123,20 @@ public:
+     {
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+-        if (Q_UNLIKELY((pos++)->isHighSurrogate()))
++        if (Q_UNLIKELY((pos++)->isHighSurrogate())) {
++            Q_ASSERT(hasNext() && pos->isLowSurrogate());
+             ++pos;
++        }
+     }
+ 
+     inline uint peekNextUnchecked() const
+     {
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+-        if (Q_UNLIKELY(pos->isHighSurrogate()))
++        if (Q_UNLIKELY(pos->isHighSurrogate())) {
++            Q_ASSERT(less(pos + 1, e) && pos[1].isLowSurrogate());
+             return QChar::surrogateToUcs4(pos[0], pos[1]);
++        }
+ 
+         return pos->unicode();
+     }
+@@ -155,8 +162,10 @@ public:
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+         const QChar cur = *pos++;
+-        if (Q_UNLIKELY(cur.isHighSurrogate()))
++        if (Q_UNLIKELY(cur.isHighSurrogate())) {
++            Q_ASSERT(hasNext() && pos->isLowSurrogate());
+             return QChar::surrogateToUcs4(cur, *pos++);
++        }
+         return cur.unicode();
+     }
+ 
+@@ -166,7 +175,7 @@ public:
+ 
+         const QChar uc = *pos++;
+         if (Q_UNLIKELY(uc.isSurrogate())) {
+-            if (Q_LIKELY(uc.isHighSurrogate() && pos < e && pos->isLowSurrogate()))
++            if (Q_LIKELY(uc.isHighSurrogate() && hasNext() && pos->isLowSurrogate()))
+                 return QChar::surrogateToUcs4(uc, *pos++);
+             return invalidAs;
+         }
+@@ -178,7 +187,7 @@ public:
+ 
+     inline bool hasPrevious() const
+     {
+-        return pos > i;
++        return less(i, pos);
+     }
+ 
+     inline void recede()
+@@ -196,16 +205,20 @@ public:
+     {
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+-        if (Q_UNLIKELY((--pos)->isLowSurrogate()))
++        if (Q_UNLIKELY((--pos)->isLowSurrogate())) {
++            Q_ASSERT(hasPrevious() && pos[-1].isHighSurrogate());
+             --pos;
++        }
+     }
+ 
+     inline uint peekPreviousUnchecked() const
+     {
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+-        if (Q_UNLIKELY(pos[-1].isLowSurrogate()))
++        if (Q_UNLIKELY(pos[-1].isLowSurrogate())) {
++            Q_ASSERT(less(i + 1, pos) && pos[-2].isHighSurrogate());
+             return QChar::surrogateToUcs4(pos[-2], pos[-1]);
++        }
+         return pos[-1].unicode();
+     }
+ 
+@@ -230,8 +243,10 @@ public:
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+         const QChar cur = *--pos;
+-        if (Q_UNLIKELY(cur.isLowSurrogate()))
++        if (Q_UNLIKELY(cur.isLowSurrogate())) {
++            Q_ASSERT(hasPrevious() && pos[-1].isHighSurrogate());
+             return QChar::surrogateToUcs4(*--pos, cur);
++        }
+         return cur.unicode();
+     }
+ 
+@@ -241,7 +256,7 @@ public:
+ 
+         const QChar uc = *--pos;
+         if (Q_UNLIKELY(uc.isSurrogate())) {
+-            if (Q_LIKELY(uc.isLowSurrogate() && pos > i && pos[-1].isHighSurrogate()))
++            if (Q_LIKELY(uc.isLowSurrogate() && hasPrevious() && pos[-1].isHighSurrogate()))
+                 return QChar::surrogateToUcs4(*--pos, uc);
+             return invalidAs;
+         }
+diff --git a/qtbase/src/corelib/thread/qfutex_p.h b/qtbase/src/corelib/thread/qfutex_p.h
+index f287b752d7..e294537787 100644
+--- a/qtbase/src/corelib/thread/qfutex_p.h
++++ b/qtbase/src/corelib/thread/qfutex_p.h
+@@ -52,6 +52,7 @@
+ //
+ 
+ #include <qglobal.h>
++#include <QtCore/qtsan_impl.h>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -106,16 +107,13 @@ namespace QtLinuxFutex {
+     inline int _q_futex(int *addr, int op, int val, quintptr val2 = 0,
+                         int *addr2 = nullptr, int val3 = 0) noexcept
+     {
+-        // A futex call ensures total ordering on the futex words
+-        // (in either success or failure of the call). Instruct TSAN accordingly,
+-        // as TSAN does not understand the futex(2) syscall.
+-        _q_tsan_release(addr, addr2);
++        QtTsan::futexRelease(addr, addr2);
+ 
+         // we use __NR_futex because some libcs (like Android's bionic) don't
+         // provide SYS_futex etc.
+         int result = syscall(__NR_futex, addr, op | FUTEX_PRIVATE_FLAG, val, val2, addr2, val3);
+ 
+-        _q_tsan_acquire(addr, addr2);
++        QtTsan::futexAcquire(addr, addr2);
+ 
+         return result;
+     }
+diff --git a/qtbase/src/corelib/thread/qmutex.cpp b/qtbase/src/corelib/thread/qmutex.cpp
+index 310d1cb14f..7097122d8e 100644
+--- a/qtbase/src/corelib/thread/qmutex.cpp
++++ b/qtbase/src/corelib/thread/qmutex.cpp
+@@ -152,6 +152,7 @@ public:
+ 
+ /*!
+     \enum QMutex::RecursionMode
++    \obsolete Use QRecursiveMutex to create a recursive mutex.
+ 
+     \value Recursive  In this mode, a thread can lock the same mutex
+                       multiple times and the mutex won't be unlocked
+@@ -173,6 +174,7 @@ public:
+ 
+ /*!
+     Constructs a new mutex. The mutex is created in an unlocked state.
++    \obsolete Use QRecursiveMutex to create a recursive mutex.
+ 
+     If \a mode is QMutex::Recursive, a thread can lock the same mutex
+     multiple times and the mutex won't be unlocked until a
+@@ -197,7 +199,7 @@ QMutex::QMutex(RecursionMode mode)
+ QMutex::~QMutex()
+ {
+     QMutexData *d = d_ptr.loadRelaxed();
+-    if (isRecursive()) {
++    if (QBasicMutex::isRecursive()) {
+         delete static_cast<QRecursiveMutexPrivate *>(d);
+     } else if (d) {
+ #ifndef QT_LINUX_FUTEX
+diff --git a/qtbase/src/corelib/thread/qmutex.h b/qtbase/src/corelib/thread/qmutex.h
+index 73c9e00663..1bae573a03 100644
+--- a/qtbase/src/corelib/thread/qmutex.h
++++ b/qtbase/src/corelib/thread/qmutex.h
+@@ -42,6 +42,7 @@
+ 
+ #include <QtCore/qglobal.h>
+ #include <QtCore/qatomic.h>
++#include <QtCore/qtsan_impl.h>
+ #include <new>
+ 
+ #if __has_include(<chrono>)
+@@ -77,19 +78,37 @@ public:
+ 
+     // BasicLockable concept
+     inline void lock() QT_MUTEX_LOCK_NOEXCEPT {
++        QtTsan::mutexPreLock(this, 0u);
++
+         if (!fastTryLock())
+             lockInternal();
++
++        QtTsan::mutexPostLock(this, 0u, 0);
+     }
+ 
+     // BasicLockable concept
+     inline void unlock() noexcept {
+         Q_ASSERT(d_ptr.loadRelaxed()); //mutex must be locked
++
++        QtTsan::mutexPreUnlock(this, 0u);
++
+         if (!fastTryUnlock())
+             unlockInternal();
++
++        QtTsan::mutexPostUnlock(this, 0u);
+     }
+ 
+     bool tryLock() noexcept {
+-        return fastTryLock();
++        unsigned tsanFlags = QtTsan::TryLock;
++        QtTsan::mutexPreLock(this, tsanFlags);
++
++        const bool success = fastTryLock();
++
++        if (!success)
++            tsanFlags |= QtTsan::TryLockFailed;
++        QtTsan::mutexPostLock(this, tsanFlags, 0);
++
++        return success;
+     }
+ 
+     // Lockable concept
+@@ -134,8 +153,16 @@ public:
+ #else
+     QMutex() { d_ptr.storeRelaxed(nullptr); }
+ #endif
++#if QT_DEPRECATED_SINCE(5,15)
+     enum RecursionMode { NonRecursive, Recursive };
++    QT_DEPRECATED_VERSION_X(5, 15, "Use QRecursiveMutex instead of a recursive QMutex")
+     explicit QMutex(RecursionMode mode);
++
++    QT_DEPRECATED_VERSION_X(5, 15, "Use QRecursiveMutex instead of a recursive QMutex")
++    bool isRecursive() const noexcept
++    { return QBasicMutex::isRecursive(); }
++#endif
++
+     ~QMutex();
+ 
+     // BasicLockable concept
+@@ -166,9 +193,6 @@ public:
+     }
+ #endif
+ 
+-    bool isRecursive() const noexcept
+-    { return QBasicMutex::isRecursive(); }
+-
+ private:
+     Q_DISABLE_COPY(QMutex)
+     friend class QMutexLocker;
+diff --git a/qtbase/src/corelib/thread/qreadwritelock.cpp b/qtbase/src/corelib/thread/qreadwritelock.cpp
+index 8c28507d5a..9dd8503116 100644
+--- a/qtbase/src/corelib/thread/qreadwritelock.cpp
++++ b/qtbase/src/corelib/thread/qreadwritelock.cpp
+@@ -155,7 +155,7 @@ QReadWriteLock::QReadWriteLock(RecursionMode recursionMode)
+ */
+ QReadWriteLock::~QReadWriteLock()
+ {
+-    auto d = d_ptr.loadRelaxed();
++    auto d = d_ptr.loadAcquire();
+     if (isUncontendedLocked(d)) {
+         qWarning("QReadWriteLock: destroying locked QReadWriteLock");
+         return;
+@@ -445,7 +445,7 @@ void QReadWriteLock::unlock()
+ /*! \internal  Helper for QWaitCondition::wait */
+ QReadWriteLock::StateForWaitCondition QReadWriteLock::stateForWaitCondition() const
+ {
+-    QReadWriteLockPrivate *d = d_ptr.loadRelaxed();
++    QReadWriteLockPrivate *d = d_ptr.loadAcquire();
+     switch (quintptr(d) & StateMask) {
+     case StateLockedForRead: return LockedForRead;
+     case StateLockedForWrite: return LockedForWrite;
+@@ -453,6 +453,7 @@ QReadWriteLock::StateForWaitCondition QReadWriteLock::stateForWaitCondition() co
+ 
+     if (!d)
+         return Unlocked;
++    const auto lock = qt_scoped_lock(d->mutex);
+     if (d->writerCount > 1)
+         return RecursivelyLocked;
+     else if (d->writerCount == 1)
+diff --git a/qtbase/src/corelib/thread/qsemaphore.cpp b/qtbase/src/corelib/thread/qsemaphore.cpp
+index 1d01fc1b28..3ecdee3747 100644
+--- a/qtbase/src/corelib/thread/qsemaphore.cpp
++++ b/qtbase/src/corelib/thread/qsemaphore.cpp
+@@ -354,7 +354,12 @@ void QSemaphore::release(int n)
+         quintptr nn = unsigned(n);
+         if (futexHasWaiterCount)
+             nn |= quint64(nn) << 32;    // token count replicated in high word
+-        quintptr prevValue = u.fetchAndAddRelease(nn);
++        quintptr prevValue = u.loadRelaxed();
++        quintptr newValue;
++        do { // loop just to ensure the operations are done atomically
++            newValue = prevValue + nn;
++            newValue &= (futexNeedsWakeAllBit - 1);
++        } while (!u.testAndSetRelease(prevValue, newValue, prevValue));
+         if (futexNeedsWake(prevValue)) {
+ #ifdef FUTEX_OP
+             if (futexHasWaiterCount) {
+@@ -376,7 +381,6 @@ void QSemaphore::release(int n)
+                 quint32 oparg = 0;
+                 quint32 cmp = FUTEX_OP_CMP_NE;
+                 quint32 cmparg = 0;
+-                u.fetchAndAndRelease(futexNeedsWakeAllBit - 1);
+                 futexWakeOp(*futexLow32(&u), n, INT_MAX, *futexHigh32(&u), FUTEX_OP(op, oparg, cmp, cmparg));
+                 return;
+             }
+@@ -388,7 +392,6 @@ 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(futexNeedsWakeAllBit - 1);
+             if (futexHasWaiterCount) {
+                 futexWakeAll(*futexLow32(&u));
+                 futexWakeAll(*futexHigh32(&u));
+diff --git a/qtbase/src/corelib/thread/qthread_p.h b/qtbase/src/corelib/thread/qthread_p.h
+index b2d1628e6e..f32f6f0460 100644
+--- a/qtbase/src/corelib/thread/qthread_p.h
++++ b/qtbase/src/corelib/thread/qthread_p.h
+@@ -174,7 +174,7 @@ public:
+     int returnCode;
+ 
+     uint stackSize;
+-    QThread::Priority priority;
++    std::underlying_type<QThread::Priority>::type priority;
+ 
+     static QThread *threadForId(int id);
+ 
+@@ -213,6 +213,13 @@ public:
+             QCoreApplication::instance()->postEvent(q_ptr, new QEvent(QEvent::Quit));
+         }
+     }
++
++#ifndef Q_OS_INTEGRITY
++private:
++    // Used in QThread(Private)::start to avoid racy access to QObject::objectName,
++    // unset afterwards. On INTEGRITY we set the thread name before starting it.
++    QString objectName;
++#endif
+ };
+ 
+ #else // QT_CONFIG(thread)
+diff --git a/qtbase/src/corelib/thread/qthread_unix.cpp b/qtbase/src/corelib/thread/qthread_unix.cpp
+index 56a8e0a038..610117a640 100644
+--- a/qtbase/src/corelib/thread/qthread_unix.cpp
++++ b/qtbase/src/corelib/thread/qthread_unix.cpp
+@@ -169,8 +169,7 @@ static void set_thread_data(QThreadData *data)
+ 
+ static void clear_thread_data()
+ {
+-    currentThreadData = nullptr;
+-    pthread_setspecific(current_thread_data_key, nullptr);
++    set_thread_data(nullptr);
+ }
+ 
+ template <typename T>
+@@ -296,7 +295,7 @@ void *QThreadPrivate::start(void *arg)
+             QMutexLocker locker(&thr->d_func()->mutex);
+ 
+             // do we need to reset the thread priority?
+-            if (int(thr->d_func()->priority) & ThreadPriorityResetFlag) {
++            if (thr->d_func()->priority & ThreadPriorityResetFlag) {
+                 thr->d_func()->setPriority(QThread::Priority(thr->d_func()->priority & ~ThreadPriorityResetFlag));
+             }
+ 
+@@ -316,10 +315,10 @@ void *QThreadPrivate::start(void *arg)
+             // Sets the name of the current thread. We can only do this
+             // when the thread is starting, as we don't have a cross
+             // platform way of setting the name of an arbitrary thread.
+-            if (Q_LIKELY(thr->objectName().isEmpty()))
++            if (Q_LIKELY(thr->d_func()->objectName.isEmpty()))
+                 setCurrentThreadName(thr->metaObject()->className());
+             else
+-                setCurrentThreadName(thr->objectName().toLocal8Bit());
++                setCurrentThreadName(std::exchange(thr->d_func()->objectName, {}).toLocal8Bit());
+         }
+ #endif
+ 
+@@ -671,7 +670,7 @@ void QThread::start(Priority priority)
+                 // could not set scheduling hints, fallback to inheriting them
+                 // we'll try again from inside the thread
+                 pthread_attr_setinheritsched(&attr, PTHREAD_INHERIT_SCHED);
+-                d->priority = Priority(priority | ThreadPriorityResetFlag);
++                d->priority = static_cast<std::underlying_type<QThread::Priority>::type>(priority) | ThreadPriorityResetFlag;
+             }
+             break;
+         }
+@@ -702,7 +701,10 @@ void QThread::start(Priority priority)
+         pthread_attr_setthreadname(&attr, metaObject()->className());
+     else
+         pthread_attr_setthreadname(&attr, objectName().toLocal8Bit());
++#else
++    d->objectName = objectName();
+ #endif
++
+     pthread_t threadId;
+     int code = pthread_create(&threadId, &attr, QThreadPrivate::start, this);
+     if (code == EPERM) {
+diff --git a/qtbase/src/corelib/thread/qthread_win.cpp b/qtbase/src/corelib/thread/qthread_win.cpp
+index bc70e3178a..4e76972498 100644
+--- a/qtbase/src/corelib/thread/qthread_win.cpp
++++ b/qtbase/src/corelib/thread/qthread_win.cpp
+@@ -394,10 +394,9 @@ unsigned int __stdcall QT_ENSURE_STACK_ALIGNED_FOR_SSE QThreadPrivate::start(voi
+ 
+ #if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) && !defined(Q_OS_WINRT)
+     // sets the name of the current thread.
+-    QByteArray objectName = thr->objectName().toLocal8Bit();
+-    qt_set_thread_name(HANDLE(-1),
+-                       objectName.isEmpty() ?
+-                       thr->metaObject()->className() : objectName.constData());
++    qt_set_thread_name(HANDLE(-1), thr->d_func()->objectName.isEmpty()
++                        ? thr->metaObject()->className()
++                        : std::exchange(thr->d_func()->objectName, {}).toLocal8Bit().constData());
+ #endif
+ 
+     emit thr->started(QThread::QPrivateSignal());
+@@ -503,6 +502,7 @@ void QThread::start(Priority priority)
+     if (d->running)
+         return;
+ 
++    d->objectName = objectName();
+     d->running = true;
+     d->finished = false;
+     d->exited = false;
+@@ -548,7 +548,7 @@ void QThread::start(Priority priority)
+ 
+     int prio;
+     d->priority = priority;
+-    switch (d->priority) {
++    switch (priority) {
+     case IdlePriority:
+         prio = THREAD_PRIORITY_IDLE;
+         break;
+@@ -686,7 +686,7 @@ void QThreadPrivate::setPriority(QThread::Priority threadPriority)
+ 
+     int prio;
+     priority = threadPriority;
+-    switch (priority) {
++    switch (threadPriority) {
+     case QThread::IdlePriority:
+         prio = THREAD_PRIORITY_IDLE;
+         break;
+diff --git a/qtbase/src/corelib/thread/qtsan_impl.h b/qtbase/src/corelib/thread/qtsan_impl.h
+new file mode 100644
+index 0000000000..580a738b91
+--- /dev/null
++++ b/qtbase/src/corelib/thread/qtsan_impl.h
+@@ -0,0 +1,115 @@
++/****************************************************************************
++**
++** Copyright (C) 2017 Intel Corporation.
++** Copyright (C) 2022 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
++** 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 QTSAN_IMPL_H
++#define QTSAN_IMPL_H
++
++#include <QtCore/qglobal.h>
++
++#if (__has_feature(thread_sanitizer) || defined(__SANITIZE_THREAD__)) && __has_include(<sanitizer/tsan_interface.h>)
++#  define QT_BUILDING_UNDER_TSAN
++#  include <sanitizer/tsan_interface.h>
++#endif
++
++QT_BEGIN_NAMESPACE
++
++namespace QtTsan {
++#ifdef QT_BUILDING_UNDER_TSAN
++inline void futexAcquire(void *addr, void *addr2 = nullptr)
++{
++    // A futex call ensures total ordering on the futex words
++    // (in either success or failure of the call). Instruct TSAN accordingly,
++    // as TSAN does not understand the futex(2) syscall (or equivalent).
++    ::__tsan_acquire(addr);
++    if (addr2)
++        ::__tsan_acquire(addr2);
++}
++
++inline void futexRelease(void *addr, void *addr2 = nullptr)
++{
++    if (addr2)
++        ::__tsan_release(addr2);
++    ::__tsan_release(addr);
++}
++
++inline void mutexPreLock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_pre_lock(addr, flags);
++}
++
++inline void mutexPostLock(void *addr, unsigned flags, int recursion)
++{
++    ::__tsan_mutex_post_lock(addr, flags, recursion);
++}
++
++inline void mutexPreUnlock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_pre_unlock(addr, flags);
++}
++
++inline void mutexPostUnlock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_post_unlock(addr, flags);
++}
++
++enum : unsigned {
++    MutexWriteReentrant = ::__tsan_mutex_write_reentrant,
++    TryLock = ::__tsan_mutex_try_lock,
++    TryLockFailed = ::__tsan_mutex_try_lock_failed,
++};
++#else
++inline void futexAcquire(void *, void * = nullptr) {}
++inline void futexRelease(void *, void * = nullptr) {}
++
++enum : unsigned {
++    MutexWriteReentrant,
++    TryLock,
++    TryLockFailed,
++};
++inline void mutexPreLock(void *, unsigned) {}
++inline void mutexPostLock(void *, unsigned, int) {}
++inline void mutexPreUnlock(void *, unsigned) {}
++inline void mutexPostUnlock(void *, unsigned) {}
++#endif // QT_BUILDING_UNDER_TSAN
++} // namespace QtTsan
++
++QT_END_NAMESPACE
++
++#endif // QTSAN_IMPL_H
+diff --git a/qtbase/src/corelib/thread/qwaitcondition_unix.cpp b/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
+index 88b058f410..0f1da4dc9b 100644
+--- a/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
++++ b/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
+@@ -213,7 +213,7 @@ bool QWaitCondition::wait(QMutex *mutex, QDeadlineTimer deadline)
+ {
+     if (! mutex)
+         return false;
+-    if (mutex->isRecursive()) {
++    if (static_cast<QBasicMutex *>(mutex)->isRecursive()) {
+         qWarning("QWaitCondition: cannot wait on recursive mutexes");
+         return false;
+     }
+diff --git a/qtbase/src/corelib/time/qdatetime.cpp b/qtbase/src/corelib/time/qdatetime.cpp
+index ec12569e3f..2c0b098079 100644
+--- a/qtbase/src/corelib/time/qdatetime.cpp
++++ b/qtbase/src/corelib/time/qdatetime.cpp
+@@ -43,6 +43,7 @@
+ #if QT_CONFIG(datetimeparser)
+ #include "private/qdatetimeparser_p.h"
+ #endif
++#include <private/qnumeric_p.h>
+ 
+ #include "qdatastream.h"
+ #include "qset.h"
+@@ -1429,9 +1430,11 @@ QDate QDate::addDays(qint64 ndays) const
+     if (isNull())
+         return QDate();
+ 
+-    // Due to limits on minJd() and maxJd() we know that any overflow
+-    // will be invalid and caught by fromJulianDay().
+-    return fromJulianDay(jd + ndays);
++    qint64 r;
++    if (Q_UNLIKELY(add_overflow(jd, ndays, &r)))
++        return QDate();
++    else
++        return fromJulianDay(r);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/corelib/time/qtimezone.cpp b/qtbase/src/corelib/time/qtimezone.cpp
+index 0309e43e52..3d451696a1 100644
+--- a/qtbase/src/corelib/time/qtimezone.cpp
++++ b/qtbase/src/corelib/time/qtimezone.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2013 John Layt <jlayt@kde.org>
++** Copyright (C) 2020 John Layt <jlayt@kde.org>
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtCore module of the Qt Toolkit.
+@@ -975,9 +975,15 @@ QList<QByteArray> QTimeZone::windowsIdToIanaIds(const QByteArray &windowsId,
+ }
+ 
+ #ifndef QT_NO_DATASTREAM
++// Invalid, as an IANA ID: too long, starts with - and has other invalid characters in it
++static inline QString invalidId() { return QStringLiteral("-No Time Zone Specified!"); }
++
+ QDataStream &operator<<(QDataStream &ds, const QTimeZone &tz)
+ {
+-    tz.d->serialize(ds);
++    if (tz.isValid())
++        tz.d->serialize(ds);
++    else
++        ds << invalidId();
+     return ds;
+ }
+ 
+@@ -985,7 +991,9 @@ QDataStream &operator>>(QDataStream &ds, QTimeZone &tz)
+ {
+     QString ianaId;
+     ds >> ianaId;
+-    if (ianaId == QLatin1String("OffsetFromUtc")) {
++    if (ianaId == invalidId()) {
++        tz = QTimeZone();
++    } else if (ianaId == QLatin1String("OffsetFromUtc")) {
+         int utcOffset;
+         QString name;
+         QString abbreviation;
+diff --git a/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp b/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
+index b1611d7ddb..a7a6a72ccf 100644
+--- a/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
++++ b/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
+@@ -42,6 +42,7 @@
+ #include "qtimezone.h"
+ #include "qtimezoneprivate_p.h"
+ #include "private/qlocale_tools_p.h"
++#include "private/qlocking_p.h"
+ 
+ #include <QtCore/QDataStream>
+ #include <QtCore/QDateTime>
+@@ -62,6 +63,10 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++#if QT_CONFIG(icu)
++static QBasicMutex s_icu_mutex;
++#endif
++
+ /*
+     Private
+ 
+@@ -670,6 +675,9 @@ QTzTimeZonePrivate::~QTzTimeZonePrivate()
+ 
+ QTzTimeZonePrivate *QTzTimeZonePrivate::clone() const
+ {
++#if QT_CONFIG(icu)
++    const auto lock = qt_scoped_lock(s_icu_mutex);
++#endif
+     return new QTzTimeZonePrivate(*this);
+ }
+ 
+@@ -913,12 +921,14 @@ QString QTzTimeZonePrivate::displayName(qint64 atMSecsSinceEpoch,
+                                         const QLocale &locale) const
+ {
+ #if QT_CONFIG(icu)
++    auto lock = qt_unique_lock(s_icu_mutex);
+     if (!m_icu)
+         m_icu = new QIcuTimeZonePrivate(m_id);
+     // TODO small risk may not match if tran times differ due to outdated files
+     // TODO Some valid TZ names are not valid ICU names, use translation table?
+     if (m_icu->isValid())
+         return m_icu->displayName(atMSecsSinceEpoch, nameType, locale);
++    lock.unlock();
+ #else
+     Q_UNUSED(nameType)
+     Q_UNUSED(locale)
+@@ -932,12 +942,14 @@ QString QTzTimeZonePrivate::displayName(QTimeZone::TimeType timeType,
+                                         const QLocale &locale) const
+ {
+ #if QT_CONFIG(icu)
++    auto lock = qt_unique_lock(s_icu_mutex);
+     if (!m_icu)
+         m_icu = new QIcuTimeZonePrivate(m_id);
+     // TODO small risk may not match if tran times differ due to outdated files
+     // TODO Some valid TZ names are not valid ICU names, use translation table?
+     if (m_icu->isValid())
+         return m_icu->displayName(timeType, nameType, locale);
++    lock.unlock();
+ #else
+     Q_UNUSED(timeType)
+     Q_UNUSED(nameType)
+diff --git a/qtbase/src/corelib/tools/qarraydata.h b/qtbase/src/corelib/tools/qarraydata.h
+index dcd95924c1..d01739e7e6 100644
+--- a/qtbase/src/corelib/tools/qarraydata.h
++++ b/qtbase/src/corelib/tools/qarraydata.h
+@@ -42,6 +42,7 @@
+ 
+ #include <QtCore/qrefcount.h>
+ #include <string.h>
++#include <cstdint>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -58,14 +59,14 @@ struct Q_CORE_EXPORT QArrayData
+     {
+         Q_ASSERT(size == 0
+                 || offset < 0 || size_t(offset) >= sizeof(QArrayData));
+-        return reinterpret_cast<char *>(this) + offset;
++        return reinterpret_cast<void *> (reinterpret_cast<uintptr_t>(this) + offset);
+     }
+ 
+     const void *data() const
+     {
+         Q_ASSERT(size == 0
+                 || offset < 0 || size_t(offset) >= sizeof(QArrayData));
+-        return reinterpret_cast<const char *>(this) + offset;
++        return reinterpret_cast<void *> (reinterpret_cast<uintptr_t>(this) + offset);
+     }
+ 
+     // This refers to array data mutability, not "header data" represented by
+diff --git a/qtbase/src/corelib/tools/qfreelist_p.h b/qtbase/src/corelib/tools/qfreelist_p.h
+index 5ba23b344b..9974102136 100644
+--- a/qtbase/src/corelib/tools/qfreelist_p.h
++++ b/qtbase/src/corelib/tools/qfreelist_p.h
+@@ -161,7 +161,7 @@ class QFreeList
+                 return i;
+             x -= size;
+         }
+-        Q_ASSERT(false);
++        Q_UNREACHABLE();
+         return -1;
+     }
+ 
+diff --git a/qtbase/src/corelib/tools/qversionnumber.h b/qtbase/src/corelib/tools/qversionnumber.h
+index d43b86ba51..2843f2b043 100644
+--- a/qtbase/src/corelib/tools/qversionnumber.h
++++ b/qtbase/src/corelib/tools/qversionnumber.h
+@@ -273,10 +273,10 @@ public:
+ 
+     Q_REQUIRED_RESULT Q_CORE_EXPORT QString toString() const;
+ #if QT_STRINGVIEW_LEVEL < 2
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(const QString &string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(const QString &string, int *suffixIndex = nullptr);
+ #endif
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QLatin1String string, int *suffixIndex = nullptr);
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QStringView string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(QLatin1String string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(QStringView string, int *suffixIndex = nullptr);
+ 
+ private:
+ #ifndef QT_NO_DATASTREAM
+diff --git a/qtbase/src/dbus/qdbusintegrator.cpp b/qtbase/src/dbus/qdbusintegrator.cpp
+index 5b66ce971b..28a3b0ffea 100644
+--- a/qtbase/src/dbus/qdbusintegrator.cpp
++++ b/qtbase/src/dbus/qdbusintegrator.cpp
+@@ -1135,7 +1135,13 @@ void QDBusConnectionPrivate::closeConnection()
+         }
+     }
+ 
+-    qDeleteAll(pendingCalls);
++    for (auto it = pendingCalls.begin(); it != pendingCalls.end(); ++it) {
++        auto call = *it;
++        if (!call->ref.deref()) {
++            delete call;
++        }
++    }
++    pendingCalls.clear();
+ 
+     // Disconnect all signals from signal hooks and from the object tree to
+     // avoid QObject::destroyed being sent to dbus daemon thread which has
+@@ -2584,6 +2590,11 @@ QDBusConnectionPrivate::findMetaObject(const QString &service, const QString &pa
+         if (mo)
+             return mo;
+     }
++    if (path.isEmpty()) {
++        error = QDBusError(QDBusError::InvalidObjectPath, QLatin1String("Object path cannot be empty"));
++        lastError = error;
++        return nullptr;
++    }
+ 
+     // introspect the target object
+     QDBusMessage msg = QDBusMessage::createMethodCall(service, path,
+diff --git a/qtbase/src/dbus/qdbusmetaobject.cpp b/qtbase/src/dbus/qdbusmetaobject.cpp
+index 5265568f42..7e9f0f1acc 100644
+--- a/qtbase/src/dbus/qdbusmetaobject.cpp
++++ b/qtbase/src/dbus/qdbusmetaobject.cpp
+@@ -210,6 +210,9 @@ QDBusMetaObjectGenerator::findType(const QByteArray &signature,
+         } else if (signature == "a{ss}") {
+             result.name = "QMap<QString,QString>";
+             type = qMetaTypeId<QMap<QString, QString> >();
++        } else if (signature == "aay") {
++            result.name = "QByteArrayList";
++            type = qMetaTypeId<QByteArrayList>();
+         } else {
+             result.name = "{D-Bus type \"" + signature + "\"}";
+             type = registerComplexDBusType(result.name);
+diff --git a/qtbase/src/gui/accessible/qaccessible.cpp b/qtbase/src/gui/accessible/qaccessible.cpp
+index d705bfccb5..0caf3c808c 100644
+--- a/qtbase/src/gui/accessible/qaccessible.cpp
++++ b/qtbase/src/gui/accessible/qaccessible.cpp
+@@ -54,6 +54,7 @@
+ #include <QtCore/qdebug.h>
+ #include <QtCore/qloggingcategory.h>
+ #include <QtCore/qmetaobject.h>
++#include <QtCore/private/qmetaobject_p.h>
+ #include <QtCore/qhash.h>
+ #include <private/qfactoryloader_p.h>
+ 
+@@ -681,6 +682,25 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
+     // Create a QAccessibleInterface for the object class. Start by the most
+     // derived class and walk up the class hierarchy.
+     const QMetaObject *mo = object->metaObject();
++    const auto *objectPriv = QObjectPrivate::get(object);
++    /*
++     We do not want to cache each and every QML metaobject (Button_QMLTYPE_124,
++     Button_QMLTYPE_125, etc.). Those dynamic metaobjects shouldn't have an
++     accessible interface in any case. Instead, we start the whole checking
++     with the first non-dynamic meta-object. To avoid potential regressions
++     in other areas of Qt that also use dynamic metaobjects, we only do this
++     for objects that are QML-related (approximated by checking whether they
++     have ddata set).
++    */
++    const bool qmlRelated = !objectPriv->isDeletingChildren &&
++                            objectPriv->declarativeData;
++    while (qmlRelated && mo) {
++        auto mop = QMetaObjectPrivate::get(mo);
++        if (!mop || !(mop->flags & DynamicMetaObject))
++            break;
++
++        mo = mo->superClass();
++    };
+     while (mo) {
+         const QString cn = QLatin1String(mo->className());
+ 
+@@ -696,14 +716,15 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
+         // Find a QAccessiblePlugin (factory) for the class name. If there's
+         // no entry in the cache try to create it using the plugin loader.
+         if (!qAccessiblePlugins()->contains(cn)) {
++            QAccessiblePlugin *factory = nullptr; // 0 means "no plugin found". This is cached as well.
+             const int index = loader()->indexOf(cn);
+-            if (index != -1) {
+-                QAccessiblePlugin *factory = qobject_cast<QAccessiblePlugin *>(loader()->instance(index));
+-                qAccessiblePlugins()->insert(cn, factory);
+-            }
++            if (index != -1)
++                factory = qobject_cast<QAccessiblePlugin *>(loader()->instance(index));
++            qAccessiblePlugins()->insert(cn, factory);
+         }
+ 
+         // At this point the cache should contain a valid factory pointer or 0:
++        Q_ASSERT(qAccessiblePlugins()->contains(cn));
+         QAccessiblePlugin *factory = qAccessiblePlugins()->value(cn);
+         if (factory) {
+             QAccessibleInterface *result = factory->create(cn, object);
+diff --git a/qtbase/src/gui/configure.json b/qtbase/src/gui/configure.json
+index 1f08795c57..12c95742d2 100644
+--- a/qtbase/src/gui/configure.json
++++ b/qtbase/src/gui/configure.json
+@@ -834,7 +834,8 @@
+                     "// embedded devices, are not intended to be used together with X. EGL support",
+                     "// has to be disabled in plugins like xcb in this case since the native display,",
+                     "// window and pixmap types will be different than what an X-based platform",
+-                    "// plugin would expect."
++                    "// plugin would expect.",
++                    "#define USE_X11"
+                 ],
+                 "include": [ "EGL/egl.h", "X11/Xlib.h" ],
+                 "main": [
+diff --git a/qtbase/src/gui/image/qbmphandler.cpp b/qtbase/src/gui/image/qbmphandler.cpp
+index 96f1e8cb1d..0e73bbbdb0 100644
+--- a/qtbase/src/gui/image/qbmphandler.cpp
++++ b/qtbase/src/gui/image/qbmphandler.cpp
+@@ -150,16 +150,42 @@ static QDataStream &operator<<(QDataStream &s, const BMP_INFOHDR &bi)
+     return s;
+ }
+ 
+-static int calc_shift(uint mask)
++static uint calc_shift(uint mask)
+ {
+-    int result = 0;
+-    while (mask && !(mask & 1)) {
++    uint result = 0;
++    while ((mask >= 0x100) || (!(mask & 1) && mask)) {
+         result++;
+         mask >>= 1;
+     }
+     return result;
+ }
+ 
++static uint calc_scale(uint low_mask)
++{
++    uint result = 8;
++    while (low_mask && result) {
++        result--;
++        low_mask >>= 1;
++    }
++    return result;
++}
++
++static inline uint apply_scale(uint value, uint scale)
++{
++    if (!(scale & 0x07)) // return immediately if scale == 8 or 0
++        return value;
++
++    uint filled = 8 - scale;
++    uint result = value << scale;
++
++    do {
++        result |= result >> filled;
++        filled <<= 1;
++    } while (filled < 8);
++
++    return result;
++}
++
+ static bool read_dib_fileheader(QDataStream &s, BMP_FILEHDR &bf)
+ {
+     // read BMP file header
+@@ -222,14 +248,14 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+     uint green_mask = 0;
+     uint blue_mask = 0;
+     uint alpha_mask = 0;
+-    int red_shift = 0;
+-    int green_shift = 0;
+-    int blue_shift = 0;
+-    int alpha_shift = 0;
+-    int red_scale = 0;
+-    int green_scale = 0;
+-    int blue_scale = 0;
+-    int alpha_scale = 0;
++    uint red_shift = 0;
++    uint green_shift = 0;
++    uint blue_shift = 0;
++    uint alpha_shift = 0;
++    uint red_scale = 0;
++    uint green_scale = 0;
++    uint blue_scale = 0;
++    uint alpha_scale = 0;
+ 
+     if (!d->isSequential())
+         d->seek(startpos + BMP_FILEHDR_SIZE + bi.biSize); // goto start of colormap or masks
+@@ -308,19 +334,19 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+         red_shift = calc_shift(red_mask);
+         if (((red_mask >> red_shift) + 1) == 0)
+             return false;
+-        red_scale = 256 / ((red_mask >> red_shift) + 1);
++        red_scale = calc_scale(red_mask >> red_shift);
+         green_shift = calc_shift(green_mask);
+         if (((green_mask >> green_shift) + 1) == 0)
+             return false;
+-        green_scale = 256 / ((green_mask >> green_shift) + 1);
++        green_scale = calc_scale(green_mask >> green_shift);
+         blue_shift = calc_shift(blue_mask);
+         if (((blue_mask >> blue_shift) + 1) == 0)
+             return false;
+-        blue_scale = 256 / ((blue_mask >> blue_shift) + 1);
++        blue_scale = calc_scale(blue_mask >> blue_shift);
+         alpha_shift = calc_shift(alpha_mask);
+         if (((alpha_mask >> alpha_shift) + 1) == 0)
+             return false;
+-        alpha_scale = 256 / ((alpha_mask >> alpha_shift) + 1);
++        alpha_scale = calc_scale(alpha_mask >> alpha_shift);
+     } else if (comp == BMP_RGB && (nbits == 24 || nbits == 32)) {
+         blue_mask = 0x000000ff;
+         green_mask = 0x0000ff00;
+@@ -328,17 +354,15 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+         blue_shift = 0;
+         green_shift = 8;
+         red_shift = 16;
+-        blue_scale = green_scale = red_scale = 1;
++        blue_scale = green_scale = red_scale = 0;
+     } else if (comp == BMP_RGB && nbits == 16) {
+         blue_mask = 0x001f;
+         green_mask = 0x03e0;
+         red_mask = 0x7c00;
+         blue_shift = 0;
+-        green_shift = 2;
+-        red_shift = 7;
+-        red_scale = 1;
+-        green_scale = 1;
+-        blue_scale = 8;
++        green_shift = 5;
++        red_shift = 10;
++        blue_scale = green_scale = red_scale = 3;
+     }
+ 
+ #if 0
+@@ -544,10 +568,10 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+                     c |= *(uchar*)(b+2)<<16;
+                 if (nbits > 24)
+                     c |= *(uchar*)(b+3)<<24;
+-                *p++ = qRgba(((c & red_mask) >> red_shift) * red_scale,
+-                                        ((c & green_mask) >> green_shift) * green_scale,
+-                                        ((c & blue_mask) >> blue_shift) * blue_scale,
+-                                        transp ? ((c & alpha_mask) >> alpha_shift) * alpha_scale : 0xff);
++                *p++ = qRgba(apply_scale((c & red_mask) >> red_shift, red_scale),
++                             apply_scale((c & green_mask) >> green_shift, green_scale),
++                             apply_scale((c & blue_mask) >> blue_shift, blue_scale),
++                             transp ? apply_scale((c & alpha_mask) >> alpha_shift, alpha_scale) : 0xff);
+                 b += nbits/8;
+             }
+         }
+diff --git a/qtbase/src/gui/image/qimage.cpp b/qtbase/src/gui/image/qimage.cpp
+index 7152ac1607..0df772564c 100644
+--- a/qtbase/src/gui/image/qimage.cpp
++++ b/qtbase/src/gui/image/qimage.cpp
+@@ -4694,6 +4694,8 @@ QImage QImage::smoothScaled(int w, int h) const {
+ static QImage rotated90(const QImage &image)
+ {
+     QImage out(image.height(), image.width(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+@@ -4722,6 +4724,8 @@ static QImage rotated180(const QImage &image)
+         return image.mirrored(true, true);
+ 
+     QImage out(image.width(), image.height(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+@@ -4734,6 +4738,8 @@ static QImage rotated180(const QImage &image)
+ static QImage rotated270(const QImage &image)
+ {
+     QImage out(image.height(), image.width(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+diff --git a/qtbase/src/gui/kernel/qcursor.cpp b/qtbase/src/gui/kernel/qcursor.cpp
+index d6ccaff8ed..455088241c 100644
+--- a/qtbase/src/gui/kernel/qcursor.cpp
++++ b/qtbase/src/gui/kernel/qcursor.cpp
+@@ -251,7 +251,8 @@ void QCursor::setPos(QScreen *screen, int x, int y)
+ {
+     if (screen) {
+         if (QPlatformCursor *cursor = screen->handle()->cursor()) {
+-            const QPoint devicePos = QHighDpi::toNativePixels(QPoint(x, y), screen);
++            const QPoint pos(x, y);
++            const QPoint devicePos = QHighDpi::toNativePixels(pos, screen->virtualSiblingAt(pos));
+             // Need to check, since some X servers generate null mouse move
+             // events, causing looping in applications which call setPos() on
+             // every mouse move event.
+diff --git a/qtbase/src/gui/kernel/qhighdpiscaling.cpp b/qtbase/src/gui/kernel/qhighdpiscaling.cpp
+index 9bbf2773a9..3ac4a4d8b6 100644
+--- a/qtbase/src/gui/kernel/qhighdpiscaling.cpp
++++ b/qtbase/src/gui/kernel/qhighdpiscaling.cpp
+@@ -580,9 +580,8 @@ void QHighDpiScaling::setScreenFactor(QScreen *screen, qreal factor)
+     else
+         qNamedScreenScaleFactors()->insert(name, factor);
+ 
+-    // hack to force re-evaluation of screen geometry
+     if (screen->handle())
+-        screen->d_func()->setPlatformScreen(screen->handle()); // updates geometries based on scale factor
++        screen->d_func()->updateLogicalDpi();
+ }
+ 
+ QPoint QHighDpiScaling::mapPositionToNative(const QPoint &pos, const QPlatformScreen *platformScreen)
+diff --git a/qtbase/src/gui/kernel/qkeysequence.cpp b/qtbase/src/gui/kernel/qkeysequence.cpp
+index a75b8ef920..4f2d294739 100644
+--- a/qtbase/src/gui/kernel/qkeysequence.cpp
++++ b/qtbase/src/gui/kernel/qkeysequence.cpp
+@@ -701,6 +701,10 @@ static const struct {
+     { Qt::Key_TouchpadToggle,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad Toggle") },
+     { Qt::Key_TouchpadOn,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad On") },
+     { Qt::Key_TouchpadOff,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad Off") },
++    { Qt::Key_Shift,  QT_TRANSLATE_NOOP("QShortcut", "Shift") },
++    { Qt::Key_Control,  QT_TRANSLATE_NOOP("QShortcut", "Control") },
++    { Qt::Key_Alt,  QT_TRANSLATE_NOOP("QShortcut", "Alt") },
++    { Qt::Key_Meta,  QT_TRANSLATE_NOOP("QShortcut", "Meta") },
+ 
+ };
+ static Q_CONSTEXPR int numKeyNames = sizeof keyname / sizeof *keyname;
+diff --git a/qtbase/src/gui/kernel/qplatformservices.cpp b/qtbase/src/gui/kernel/qplatformservices.cpp
+index fdc6a6c4aa..ac47f98c5d 100644
+--- a/qtbase/src/gui/kernel/qplatformservices.cpp
++++ b/qtbase/src/gui/kernel/qplatformservices.cpp
+@@ -55,6 +55,19 @@ QT_BEGIN_NAMESPACE
+     \brief The QPlatformServices provides the backend for desktop-related functionality.
+ */
+ 
++/*!
++    \enum QPlatformServices::Capability
++
++    Capabilities are used to determine a specific platform service's availability.
++
++    \value ColorPickingFromScreen The platform natively supports color picking from screen.
++    This capability indicates that the platform supports "opaque" color picking, where the
++    platform implements a complete user experience for color picking and outputs a color.
++    This is in contrast to the application implementing the color picking user experience
++    (taking care of showing a cross hair, instructing the platform integration to obtain
++    the color at a given pixel, etc.). The related service function is pickColor().
++ */
++
+ QPlatformServices::QPlatformServices()
+ { }
+ 
+@@ -85,5 +98,16 @@ QByteArray QPlatformServices::desktopEnvironment() const
+     return QByteArray("UNKNOWN");
+ }
+ 
++QPlatformServiceColorPicker *QPlatformServices::colorPicker(QWindow *parent)
++{
++    Q_UNUSED(parent);
++    return nullptr;
++}
++
++bool QPlatformServices::hasCapability(Capability capability) const
++{
++    Q_UNUSED(capability)
++    return false;
++}
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/gui/kernel/qplatformservices.h b/qtbase/src/gui/kernel/qplatformservices.h
+index 5de96cfa7d..a8b2a4ce71 100644
+--- a/qtbase/src/gui/kernel/qplatformservices.h
++++ b/qtbase/src/gui/kernel/qplatformservices.h
+@@ -50,16 +50,32 @@
+ //
+ 
+ #include <QtGui/qtguiglobal.h>
++#include <QtCore/qobject.h>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+ class QUrl;
++class QWindow;
++
++class Q_GUI_EXPORT QPlatformServiceColorPicker : public QObject
++{
++    Q_OBJECT
++public:
++    using QObject::QObject;
++    virtual void pickColor() = 0;
++Q_SIGNALS:
++    void colorPicked(const QColor &color);
++};
+ 
+ class Q_GUI_EXPORT QPlatformServices
+ {
+ public:
+     Q_DISABLE_COPY_MOVE(QPlatformServices)
+ 
++    enum Capability {
++        ColorPicking,
++    };
++
+     QPlatformServices();
+     virtual ~QPlatformServices() { }
+ 
+@@ -67,6 +83,10 @@ public:
+     virtual bool openDocument(const QUrl &url);
+ 
+     virtual QByteArray desktopEnvironment() const;
++
++    virtual bool hasCapability(Capability capability) const;
++
++    virtual QPlatformServiceColorPicker *colorPicker(QWindow *parent = nullptr);
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/gui/kernel/qplatformtheme.cpp b/qtbase/src/gui/kernel/qplatformtheme.cpp
+index 71521c0339..2325873245 100644
+--- a/qtbase/src/gui/kernel/qplatformtheme.cpp
++++ b/qtbase/src/gui/kernel/qplatformtheme.cpp
+@@ -163,6 +163,8 @@ QT_BEGIN_NAMESPACE
+ 
+     \value ShowShortcutsInContextMenus (bool) Whether to display shortcut key sequences in context menus.
+ 
++    \value ButtonPressKeys (QList<Qt::Key>) A list of keys that can be used to press buttons via keyboard input.
++
+     \sa themeHint(), QStyle::pixelMetric()
+ */
+ 
+@@ -563,6 +565,8 @@ QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint)
+         }
+     case MouseQuickSelectionThreshold:
+         return QVariant(10);
++    case ButtonPressKeys:
++        return QVariant::fromValue(QList<Qt::Key>({ Qt::Key_Space, Qt::Key_Select }));
+     }
+     return QVariant();
+ }
+diff --git a/qtbase/src/gui/kernel/qplatformtheme.h b/qtbase/src/gui/kernel/qplatformtheme.h
+index 3185fc4541..7e6c9d5740 100644
+--- a/qtbase/src/gui/kernel/qplatformtheme.h
++++ b/qtbase/src/gui/kernel/qplatformtheme.h
+@@ -120,7 +120,8 @@ public:
+         TouchDoubleTapDistance,
+         ShowShortcutsInContextMenus,
+         IconFallbackSearchPaths,
+-        MouseQuickSelectionThreshold
++        MouseQuickSelectionThreshold,
++        ButtonPressKeys
+     };
+ 
+     enum DialogType {
+diff --git a/qtbase/src/gui/kernel/qscreen.cpp b/qtbase/src/gui/kernel/qscreen.cpp
+index 8e0eb35116..5d172a58dd 100644
+--- a/qtbase/src/gui/kernel/qscreen.cpp
++++ b/qtbase/src/gui/kernel/qscreen.cpp
+@@ -77,6 +77,12 @@ QScreen::QScreen(QPlatformScreen *screen)
+     d->setPlatformScreen(screen);
+ }
+ 
++void QScreenPrivate::updateLogicalDpi()
++{
++    logicalDpi = QPlatformScreen::overrideDpi(platformScreen->logicalDpi());
++    updateGeometriesWithSignals(); // updates geometries based on scale factor
++}
++
+ void QScreenPrivate::updateGeometriesWithSignals()
+ {
+     const QRect oldGeometry = geometry;
+diff --git a/qtbase/src/gui/kernel/qscreen_p.h b/qtbase/src/gui/kernel/qscreen_p.h
+index 7da542c25e..e50fc3190b 100644
+--- a/qtbase/src/gui/kernel/qscreen_p.h
++++ b/qtbase/src/gui/kernel/qscreen_p.h
+@@ -70,6 +70,7 @@ public:
+         geometry = platformScreen->deviceIndependentGeometry();
+         availableGeometry = QHighDpi::fromNative(platformScreen->availableGeometry(), QHighDpiScaling::factor(platformScreen), geometry.topLeft());
+     }
++    void updateLogicalDpi();
+ 
+     void updatePrimaryOrientation();
+     void updateGeometriesWithSignals();
+diff --git a/qtbase/src/gui/painting/qblendfunctions_p.h b/qtbase/src/gui/painting/qblendfunctions_p.h
+index 080da98ec4..6997d62b3c 100644
+--- a/qtbase/src/gui/painting/qblendfunctions_p.h
++++ b/qtbase/src/gui/painting/qblendfunctions_p.h
+@@ -246,25 +246,32 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+                                   int dudx, int dvdx, int dudy, int dvdy, int u0, int v0,
+                                   Blender blender)
+ {
+-    int fromY = qMax(qRound(topY), clip.top());
+-    int toY = qMin(qRound(bottomY), clip.top() + clip.height());
++    qint64 fromY = qMax(qRound(topY), clip.top());
++    qint64 toY = qMin(qRound(bottomY), clip.top() + clip.height());
+     if (fromY >= toY)
+         return;
+ 
+     qreal leftSlope = (bottomLeft.x - topLeft.x) / (bottomLeft.y - topLeft.y);
+     qreal rightSlope = (bottomRight.x - topRight.x) / (bottomRight.y - topRight.y);
+-    int dx_l = int(leftSlope * 0x10000);
+-    int dx_r = int(rightSlope * 0x10000);
+-    int x_l = int((topLeft.x + (qreal(0.5) + fromY - topLeft.y) * leftSlope + qreal(0.5)) * 0x10000);
+-    int x_r = int((topRight.x + (qreal(0.5) + fromY - topRight.y) * rightSlope + qreal(0.5)) * 0x10000);
+-
+-    int fromX, toX, x1, x2, u, v, i, ii;
++    qint64 dx_l = qint64(leftSlope * 0x10000);
++    qint64 dx_r = qint64(rightSlope * 0x10000);
++    qint64 x_l = qint64((topLeft.x + (qreal(0.5) + fromY - topLeft.y) * leftSlope + qreal(0.5)) * 0x10000);
++    qint64 x_r = qint64((topRight.x + (qreal(0.5) + fromY - topRight.y) * rightSlope + qreal(0.5)) * 0x10000);
++
++    qint64 sourceRectTop = qint64(sourceRect.top());
++    qint64 sourceRectLeft = qint64(sourceRect.left());
++    qint64 sourceRectWidth = qint64(sourceRect.width());
++    qint64 sourceRectHeight = qint64(sourceRect.height());
++    qint64 clipLeft = qint64(clip.left());
++    qint64 clipWidth = qint64(clip.width());
++
++    qint64 fromX, toX, x1, x2, u, v, i, ii;
+     DestT *line;
+-    for (int y = fromY; y < toY; ++y) {
++    for (qint64 y = fromY; y < toY; ++y) {
+         line = reinterpret_cast<DestT *>(reinterpret_cast<uchar *>(destPixels) + y * dbpl);
+ 
+-        fromX = qMax(x_l >> 16, clip.left());
+-        toX = qMin(x_r >> 16, clip.left() + clip.width());
++        fromX = qMax(x_l >> 16, clipLeft);
++        toX = qMin(x_r >> 16, clipLeft + clipWidth);
+         if (fromX < toX) {
+             // Because of rounding, we can get source coordinates outside the source image.
+             // Clamp these coordinates to the source rect to avoid segmentation fault and
+@@ -275,10 +282,10 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             u = x1 * dudx + y * dudy + u0;
+             v = x1 * dvdx + y * dvdy + v0;
+             for (; x1 < toX; ++x1) {
+-                int uu = u >> 16;
+-                int vv = v >> 16;
+-                if (uu >= sourceRect.left() && uu < sourceRect.left() + sourceRect.width()
+-                    && vv >= sourceRect.top() && vv < sourceRect.top() + sourceRect.height()) {
++                qint64 uu = u >> 16;
++                qint64 vv = v >> 16;
++                if (uu >= sourceRectLeft && uu < sourceRectLeft + sourceRectWidth
++                    && vv >= sourceRectTop && vv < sourceRectTop + sourceRectHeight) {
+                     break;
+                 }
+                 u += dudx;
+@@ -290,10 +297,10 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             u = (x2 - 1) * dudx + y * dudy + u0;
+             v = (x2 - 1) * dvdx + y * dvdy + v0;
+             for (; x2 > x1; --x2) {
+-                int uu = u >> 16;
+-                int vv = v >> 16;
+-                if (uu >= sourceRect.left() && uu < sourceRect.left() + sourceRect.width()
+-                    && vv >= sourceRect.top() && vv < sourceRect.top() + sourceRect.height()) {
++                qint64 uu = u >> 16;
++                qint64 vv = v >> 16;
++                if (uu >= sourceRectLeft && uu < sourceRectLeft + sourceRectWidth
++                    && vv >= sourceRectTop && vv < sourceRectTop + sourceRectHeight) {
+                     break;
+                 }
+                 u -= dudx;
+@@ -308,8 +315,8 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             // Beginning of the scan line, with per-pixel checks.
+             i = x1 - fromX;
+             while (i) {
+-                int uu = qBound(sourceRect.left(), u >> 16, sourceRect.left() + sourceRect.width() - 1);
+-                int vv = qBound(sourceRect.top(), v >> 16, sourceRect.top() + sourceRect.height() - 1);
++                qint64 uu = qBound(sourceRectLeft, u >> 16, sourceRectLeft + sourceRectWidth - 1);
++                qint64 vv = qBound(sourceRectTop, v >> 16, sourceRectTop + sourceRectHeight - 1);
+                 blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + vv * sbpl)[uu]);
+                 u += dudx;
+                 v += dvdx;
+@@ -348,8 +355,8 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             // End of the scan line, with per-pixel checks.
+             i = toX - x2;
+             while (i) {
+-                int uu = qBound(sourceRect.left(), u >> 16, sourceRect.left() + sourceRect.width() - 1);
+-                int vv = qBound(sourceRect.top(), v >> 16, sourceRect.top() + sourceRect.height() - 1);
++                qint64 uu = qBound(sourceRectLeft, u >> 16, sourceRectLeft + sourceRectWidth - 1);
++                qint64 vv = qBound(sourceRectTop, v >> 16, sourceRectTop + sourceRectHeight - 1);
+                 blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + vv * sbpl)[uu]);
+                 u += dudx;
+                 v += dvdx;
+diff --git a/qtbase/src/gui/painting/qcolortrclut_p.h b/qtbase/src/gui/painting/qcolortrclut_p.h
+index 76a6a60803..24fd522e6c 100644
+--- a/qtbase/src/gui/painting/qcolortrclut_p.h
++++ b/qtbase/src/gui/painting/qcolortrclut_p.h
+@@ -118,6 +118,7 @@ public:
+         return QRgba64::fromRgba64(r, g, b, qAlpha(rgb32) * 257);
+ #endif
+     }
++    QRgba64 toLinear64(QRgba64) const = delete;
+ 
+     QRgb toLinear(QRgb rgb32) const
+     {
+diff --git a/qtbase/src/gui/painting/qdrawhelper.cpp b/qtbase/src/gui/painting/qdrawhelper.cpp
+index a61793508a..5ba2d277b7 100644
+--- a/qtbase/src/gui/painting/qdrawhelper.cpp
++++ b/qtbase/src/gui/painting/qdrawhelper.cpp
+@@ -6091,7 +6091,7 @@ static inline void alphargbblend_argb32(quint32 *dst, uint coverage, const QRgba
+ static inline void rgbBlendPixel(QRgba64 &dst, int coverage, QRgba64 slinear, const QColorTrcLut *colorProfile)
+ {
+     // Do a gammacorrected RGB alphablend...
+-    const QRgba64 dlinear = colorProfile ? colorProfile->toLinear64(dst) : dst;
++    const QRgba64 dlinear = colorProfile ? colorProfile->toLinear(dst) : dst;
+ 
+     QRgba64 blend = rgbBlend(dlinear, slinear, coverage);
+ 
+diff --git a/qtbase/src/gui/painting/qpaintengine_raster.cpp b/qtbase/src/gui/painting/qpaintengine_raster.cpp
+index 283923de52..f08eb9cbee 100644
+--- a/qtbase/src/gui/painting/qpaintengine_raster.cpp
++++ b/qtbase/src/gui/painting/qpaintengine_raster.cpp
+@@ -560,31 +560,6 @@ void QRasterPaintEngine::updateMatrix(const QTransform &matrix)
+     QRasterPaintEngineState *s = state();
+     // FALCON: get rid of this line, see drawImage call below.
+     s->matrix = matrix;
+-    QTransform::TransformationType txop = s->matrix.type();
+-
+-    switch (txop) {
+-
+-    case QTransform::TxNone:
+-        s->flags.int_xform = true;
+-        break;
+-
+-    case QTransform::TxTranslate:
+-        s->flags.int_xform = qreal(int(s->matrix.dx())) == s->matrix.dx()
+-                            && qreal(int(s->matrix.dy())) == s->matrix.dy();
+-        break;
+-
+-    case QTransform::TxScale:
+-        s->flags.int_xform = qreal(int(s->matrix.dx())) == s->matrix.dx()
+-                            && qreal(int(s->matrix.dy())) == s->matrix.dy()
+-                            && qreal(int(s->matrix.m11())) == s->matrix.m11()
+-                            && qreal(int(s->matrix.m22())) == s->matrix.m22();
+-        break;
+-
+-    default: // shear / perspective...
+-        s->flags.int_xform = false;
+-        break;
+-    }
+-
+     s->flags.tx_noshear = qt_scaleForTransform(s->matrix, &s->txscale);
+ 
+     ensureOutlineMapper();
+@@ -617,7 +592,6 @@ QRasterPaintEngineState::QRasterPaintEngineState()
+     flags.bilinear = false;
+     flags.legacy_rounding = false;
+     flags.fast_text = true;
+-    flags.int_xform = true;
+     flags.tx_noshear = true;
+     flags.fast_images = true;
+ 
+@@ -1793,7 +1767,7 @@ void QRasterPaintEngine::fill(const QVectorPath &path, const QBrush &brush)
+     QRectF cpRect = path.controlPointRect();
+     const QRectF pathDeviceRect = s->matrix.mapRect(cpRect);
+     // Skip paths that by conservative estimates are completely outside the paint device.
+-    if (!pathDeviceRect.intersects(QRectF(d->deviceRect)))
++    if (!pathDeviceRect.intersects(QRectF(d->deviceRect)) || !pathDeviceRect.isValid())
+         return;
+ 
+     ProcessSpans blend = d->getBrushFunc(pathDeviceRect, &s->brushData);
+diff --git a/qtbase/src/gui/painting/qpaintengine_raster_p.h b/qtbase/src/gui/painting/qpaintengine_raster_p.h
+index 089aadc3f7..bf7363d5aa 100644
+--- a/qtbase/src/gui/painting/qpaintengine_raster_p.h
++++ b/qtbase/src/gui/painting/qpaintengine_raster_p.h
+@@ -111,7 +111,6 @@ public:
+         uint bilinear : 1;
+         uint legacy_rounding : 1;
+         uint fast_text : 1;
+-        uint int_xform : 1;
+         uint tx_noshear : 1;
+         uint fast_images : 1;
+     };
+diff --git a/qtbase/src/gui/painting/qpainterpath.cpp b/qtbase/src/gui/painting/qpainterpath.cpp
+index f9544a3241..d80fafeaf1 100644
+--- a/qtbase/src/gui/painting/qpainterpath.cpp
++++ b/qtbase/src/gui/painting/qpainterpath.cpp
+@@ -1253,7 +1253,7 @@ void QPainterPath::addText(const QPointF &point, const QFont &f, const QString &
+ 
+         if (si.analysis.flags < QScriptAnalysis::TabOrObject) {
+             QGlyphLayout glyphs = eng->shapedGlyphs(&si);
+-            QFontEngine *fe = f.d->engineForScript(si.analysis.script);
++            QFontEngine *fe = eng->fontEngine(si);
+             Q_ASSERT(fe);
+             fe->addOutlineToPath(x, y, glyphs, this,
+                                  si.analysis.bidiLevel % 2
+diff --git a/qtbase/src/gui/painting/qpathclipper_p.h b/qtbase/src/gui/painting/qpathclipper_p.h
+index 9444a87b71..18f64c5e8c 100644
+--- a/qtbase/src/gui/painting/qpathclipper_p.h
++++ b/qtbase/src/gui/painting/qpathclipper_p.h
+@@ -156,7 +156,7 @@ public:
+     int vertex(Direction direction) const;
+ 
+ private:
+-    int m_next[2][2];
++    int m_next[2][2] = { { -1, -1 }, { -1, -1 } };
+ };
+ 
+ class QPathSegments
+@@ -296,10 +296,6 @@ inline QPathEdge::QPathEdge(int a, int b)
+     , angle(0)
+     , invAngle(0)
+ {
+-    m_next[0][0] = -1;
+-    m_next[1][0] = -1;
+-    m_next[0][0] = -1;
+-    m_next[1][0] = -1;
+ }
+ 
+ inline int QPathEdge::next(Traversal traversal, Direction direction) const
+diff --git a/qtbase/src/gui/painting/qpdf.cpp b/qtbase/src/gui/painting/qpdf.cpp
+index 3066744f1b..2c8d3c3b53 100644
+--- a/qtbase/src/gui/painting/qpdf.cpp
++++ b/qtbase/src/gui/painting/qpdf.cpp
+@@ -2760,6 +2760,8 @@ int QPdfEnginePrivate::addBrushPattern(const QTransform &m, bool *specifyColor,
+         return gradientBrush(brush, matrix, gStateObject);
+     }
+ 
++    matrix = brush.transform() * matrix;
++
+     if ((!brush.isOpaque() && brush.style() < Qt::LinearGradientPattern) || opacity != 1.0)
+         *gStateObject = addConstantAlphaObject(qRound(brush.color().alpha() * opacity),
+                                                qRound(pen.color().alpha() * opacity));
+diff --git a/qtbase/src/gui/painting/qstroker.cpp b/qtbase/src/gui/painting/qstroker.cpp
+index cb5d395e80..3b6357a893 100644
+--- a/qtbase/src/gui/painting/qstroker.cpp
++++ b/qtbase/src/gui/painting/qstroker.cpp
+@@ -1182,6 +1182,7 @@ void QDashStroker::processCurrentSubpath()
+         // Check if the entire line should be clipped away or simplified
+         bool clipIt = clipping && !lineIntersectsRect(prev, e, clip_tl, clip_br);
+         bool skipDashing = elen * invSumLength > repetitionLimit();
++        int maxDashes = dashCount;
+         if (skipDashing || clipIt) {
+             // Cut away full dash sequences.
+             elen -= std::floor(elen * invSumLength) * sumLength;
+@@ -1196,7 +1197,7 @@ void QDashStroker::processCurrentSubpath()
+                     pos = estop; // move pos to next path element
+                     done = true;
+                 } else { // Dash is on this line
+-                    pos = dpos + estart;
++                    pos = --maxDashes > 0 ? dpos + estart : estop;
+                     done = pos >= estop;
+                     if (++idash >= dashCount)
+                         idash = 0;
+diff --git a/qtbase/src/gui/painting/qt_attribution.json b/qtbase/src/gui/painting/qt_attribution.json
+index 7b16e8c211..0e87d30aa2 100644
+--- a/qtbase/src/gui/painting/qt_attribution.json
++++ b/qtbase/src/gui/painting/qt_attribution.json
+@@ -10,7 +10,7 @@
+         "Homepage": "http://www.freetype.org",
+         "License": "Freetype Project License or GNU General Public License v2.0 only",
+         "LicenseId": "FTL or GPL-2.0",
+-        "LicenseFile": "../../3rdparty/freetype/docs/LICENSE.TXT",
++        "LicenseFile": "../../3rdparty/freetype/LICENSE.TXT",
+         "Copyright": "Copyright 2000-2016 by David Turner, Robert Wilhelm, and Werner Lemberg."
+     },
+     {
+diff --git a/qtbase/src/gui/rhi/qshader_p_p.h b/qtbase/src/gui/rhi/qshader_p_p.h
+index ec9d25971f..4a5a7a6d51 100644
+--- a/qtbase/src/gui/rhi/qshader_p_p.h
++++ b/qtbase/src/gui/rhi/qshader_p_p.h
+@@ -68,13 +68,13 @@ struct Q_GUI_EXPORT QShaderPrivate
+     {
+     }
+ 
+-    QShaderPrivate(const QShaderPrivate *other)
++    QShaderPrivate(const QShaderPrivate &other)
+         : ref(1),
+-          qsbVersion(other->qsbVersion),
+-          stage(other->stage),
+-          desc(other->desc),
+-          shaders(other->shaders),
+-          bindings(other->bindings)
++          qsbVersion(other.qsbVersion),
++          stage(other.stage),
++          desc(other.desc),
++          shaders(other.shaders),
++          bindings(other.bindings)
+     {
+     }
+ 
+diff --git a/qtbase/src/gui/rhi/qshaderdescription_p_p.h b/qtbase/src/gui/rhi/qshaderdescription_p_p.h
+index ec2b0b6b4c..3da33a8a2b 100644
+--- a/qtbase/src/gui/rhi/qshaderdescription_p_p.h
++++ b/qtbase/src/gui/rhi/qshaderdescription_p_p.h
+@@ -63,16 +63,16 @@ struct Q_GUI_EXPORT QShaderDescriptionPrivate
+         localSize[0] = localSize[1] = localSize[2] = 0;
+     }
+ 
+-    QShaderDescriptionPrivate(const QShaderDescriptionPrivate *other)
++    QShaderDescriptionPrivate(const QShaderDescriptionPrivate &other)
+         : ref(1),
+-          inVars(other->inVars),
+-          outVars(other->outVars),
+-          uniformBlocks(other->uniformBlocks),
+-          pushConstantBlocks(other->pushConstantBlocks),
+-          storageBlocks(other->storageBlocks),
+-          combinedImageSamplers(other->combinedImageSamplers),
+-          storageImages(other->storageImages),
+-          localSize(other->localSize)
++          inVars(other.inVars),
++          outVars(other.outVars),
++          uniformBlocks(other.uniformBlocks),
++          pushConstantBlocks(other.pushConstantBlocks),
++          storageBlocks(other.storageBlocks),
++          combinedImageSamplers(other.combinedImageSamplers),
++          storageImages(other.storageImages),
++          localSize(other.localSize)
+     {
+     }
+ 
+diff --git a/qtbase/src/gui/text/qfontdatabase.cpp b/qtbase/src/gui/text/qfontdatabase.cpp
+index a657a8c516..4fc0100958 100644
+--- a/qtbase/src/gui/text/qfontdatabase.cpp
++++ b/qtbase/src/gui/text/qfontdatabase.cpp
+@@ -983,7 +983,7 @@ QFontEngine *loadSingleEngine(int script,
+         if (style->key.stretch != 0 && request.stretch != 0
+             && (request.styleName.isEmpty() || request.styleName != style->styleName)) {
+             def.stretch = (request.stretch * 100 + style->key.stretch / 2) / style->key.stretch;
+-        } else {
++        } else if (request.stretch == QFont::AnyStretch) {
+             def.stretch = 100;
+         }
+ 
+diff --git a/qtbase/src/gui/text/qtextdocumentlayout.cpp b/qtbase/src/gui/text/qtextdocumentlayout.cpp
+index f3e6ea2100..72267e9380 100644
+--- a/qtbase/src/gui/text/qtextdocumentlayout.cpp
++++ b/qtbase/src/gui/text/qtextdocumentlayout.cpp
+@@ -2123,7 +2123,7 @@ void QTextDocumentLayoutPrivate::drawListItem(const QPointF &offset, QPainter *p
+ {
+     Q_Q(const QTextDocumentLayout);
+     const QTextBlockFormat blockFormat = bl.blockFormat();
+-    const QTextCharFormat charFormat = QTextCursor(bl).charFormat();
++    const QTextCharFormat charFormat = bl.charFormat();
+     QFont font(charFormat.font());
+     if (q->paintDevice())
+         font = QFont(font, q->paintDevice());
+diff --git a/qtbase/src/gui/text/qtextengine.cpp b/qtbase/src/gui/text/qtextengine.cpp
+index ce4abac472..a6c66e5d2d 100644
+--- a/qtbase/src/gui/text/qtextengine.cpp
++++ b/qtbase/src/gui/text/qtextengine.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2021 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtGui module of the Qt Toolkit.
+@@ -1565,6 +1565,12 @@ void QTextEngine::shapeText(int item) const
+         // Overwrite with 0 token to indicate failure
+         QGlyphLayout g = availableGlyphs(&si);
+         g.glyphs[0] = 0;
++        g.attributes[0].clusterStart = true;
++
++        ushort *log_clusters = logClusters(&si);
++        for (int i = 0; i < itemLength; ++i)
++            log_clusters[i] = 0;
++
+         return;
+     }
+ 
+diff --git a/qtbase/src/gui/util/qdesktopservices.cpp b/qtbase/src/gui/util/qdesktopservices.cpp
+index fbb63a9408..4d5fafaaa7 100644
+--- a/qtbase/src/gui/util/qdesktopservices.cpp
++++ b/qtbase/src/gui/util/qdesktopservices.cpp
+@@ -54,6 +54,8 @@
+ #include <qpa/qplatformintegration.h>
+ #include <qdir.h>
+ 
++#include <QtCore/private/qlocking_p.h>
++
+ QT_BEGIN_NAMESPACE
+ 
+ class QOpenUrlHandlerRegistry : public QObject
+@@ -81,6 +83,7 @@ Q_GLOBAL_STATIC(QOpenUrlHandlerRegistry, handlerRegistry)
+ 
+ void QOpenUrlHandlerRegistry::handlerDestroyed(QObject *handler)
+ {
++    const auto lock = qt_scoped_lock(mutex);
+     HandlerHash::Iterator it = handlers.begin();
+     while (it != handlers.end()) {
+         if (it->receiver == handler) {
+@@ -294,7 +297,8 @@ void QDesktopServices::setUrlHandler(const QString &scheme, QObject *receiver, c
+     h.name = method;
+     registry->handlers.insert(scheme.toLower(), h);
+     QObject::connect(receiver, SIGNAL(destroyed(QObject*)),
+-                     registry, SLOT(handlerDestroyed(QObject*)));
++                     registry, SLOT(handlerDestroyed(QObject*)),
++                     Qt::DirectConnection);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/gui/util/qpkmhandler.cpp b/qtbase/src/gui/util/qpkmhandler.cpp
+index e0c3b75efe..3414f9d8ba 100644
+--- a/qtbase/src/gui/util/qpkmhandler.cpp
++++ b/qtbase/src/gui/util/qpkmhandler.cpp
+@@ -57,7 +57,7 @@ struct PkmType
+     quint32 bytesPerBlock;
+ };
+ 
+-static PkmType typeMap[5] = {
++static constexpr PkmType typeMap[5] = {
+     { 0x8D64,  8 },   // GL_ETC1_RGB8_OES
+     { 0x9274,  8 },   // GL_COMPRESSED_RGB8_ETC2
+     { 0, 0 },         // unused (obsolete)
+diff --git a/qtbase/src/network/access/qnetworkreplyfileimpl.cpp b/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
+index b6be93147a..6e69b4c4d3 100644
+--- a/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
++++ b/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
+@@ -89,9 +89,10 @@ QNetworkReplyFileImpl::QNetworkReplyFileImpl(QNetworkAccessManager *manager, con
+         // we handle only local files
+         QString msg = QCoreApplication::translate("QNetworkAccessFileBackend", "Request for opening non-local file %1").arg(url.toString());
+         setError(QNetworkReply::ProtocolInvalidOperationError, msg);
++        setFinished(true); // We're finished, will emit finished() after ctor is done.
+         QMetaObject::invokeMethod(this, "errorOccurred", Qt::QueuedConnection,
+             Q_ARG(QNetworkReply::NetworkError, QNetworkReply::ProtocolInvalidOperationError));
+-        fileOpenFinished(false);
++        QMetaObject::invokeMethod(this, [this](){ fileOpenFinished(false); }, Qt::QueuedConnection);
+         return;
+     }
+ #endif
+diff --git a/qtbase/src/network/access/qnetworkreplyimpl.cpp b/qtbase/src/network/access/qnetworkreplyimpl.cpp
+index bcdf6ee2f1..3b6deb82bd 100644
+--- a/qtbase/src/network/access/qnetworkreplyimpl.cpp
++++ b/qtbase/src/network/access/qnetworkreplyimpl.cpp
+@@ -680,7 +680,7 @@ void QNetworkReplyImplPrivate::appendDownstreamData(QIODevice *data)
+     // read until EOF from data
+     if (Q_UNLIKELY(copyDevice)) {
+         qCritical("QNetworkReplyImpl: copy from QIODevice already in progress -- "
+-                  "backend probly needs to be fixed");
++                  "backend probably needs to be fixed");
+         return;
+     }
+ 
+diff --git a/qtbase/src/network/kernel/qauthenticator.cpp b/qtbase/src/network/kernel/qauthenticator.cpp
+index d9fe7bc47b..ccd04b294a 100644
+--- a/qtbase/src/network/kernel/qauthenticator.cpp
++++ b/qtbase/src/network/kernel/qauthenticator.cpp
+@@ -50,6 +50,7 @@
+ #include <qstring.h>
+ #include <qdatetime.h>
+ #include <qrandom.h>
++#include "private/qsystemlibrary_p.h"
+ 
+ #ifdef Q_OS_WIN
+ #include <qmutex.h>
+@@ -1563,7 +1564,7 @@ static bool q_SSPI_library_load()
+ 
+     // Initialize security interface
+     if (pSecurityFunctionTable == nullptr) {
+-        securityDLLHandle = LoadLibrary(L"secur32.dll");
++        securityDLLHandle = QSystemLibrary::load(L"secur32");
+         if (securityDLLHandle != nullptr) {
+             INIT_SECURITY_INTERFACE pInitSecurityInterface =
+                 reinterpret_cast<INIT_SECURITY_INTERFACE>(
+diff --git a/qtbase/src/network/kernel/qhostinfo_unix.cpp b/qtbase/src/network/kernel/qhostinfo_unix.cpp
+index 9b0a2ee669..73679c9ef1 100644
+--- a/qtbase/src/network/kernel/qhostinfo_unix.cpp
++++ b/qtbase/src/network/kernel/qhostinfo_unix.cpp
+@@ -122,7 +122,6 @@ static QFunctionPointer resolveSymbol(QLibrary &lib, const char *sym)
+ 
+ LibResolv::LibResolv()
+ {
+-    QLibrary lib;
+ #ifdef LIBRESOLV_SO
+     lib.setFileName(QStringLiteral(LIBRESOLV_SO));
+     if (!lib.load())
+diff --git a/qtbase/src/network/socket/qsocks5socketengine.cpp b/qtbase/src/network/socket/qsocks5socketengine.cpp
+index 3a046fd116..97fadca0b3 100644
+--- a/qtbase/src/network/socket/qsocks5socketengine.cpp
++++ b/qtbase/src/network/socket/qsocks5socketengine.cpp
+@@ -1296,7 +1296,7 @@ void QSocks5SocketEnginePrivate::_q_udpSocketReadNotification()
+         int pos = 0;
+         const char *buf = inBuf.constData();
+         if (inBuf.size() < 4) {
+-            QSOCKS5_D_DEBUG << "bugus udp data, discarding";
++            QSOCKS5_D_DEBUG << "bogus udp data, discarding";
+             return;
+         }
+         QSocks5RevivedDatagram datagram;
+diff --git a/qtbase/src/network/ssl/qsslcontext_openssl.cpp b/qtbase/src/network/ssl/qsslcontext_openssl.cpp
+index c9f202f573..c992da9d8e 100644
+--- a/qtbase/src/network/ssl/qsslcontext_openssl.cpp
++++ b/qtbase/src/network/ssl/qsslcontext_openssl.cpp
+@@ -409,7 +409,7 @@ init_context:
+         break;
+     case QSsl::DtlsV1_0OrLater:
+         minVersion = DTLS1_VERSION;
+-        maxVersion = DTLS_MAX_VERSION;
++        maxVersion = 0;
+         break;
+     case QSsl::DtlsV1_2:
+         minVersion = DTLS1_2_VERSION;
+@@ -417,7 +417,7 @@ init_context:
+         break;
+     case QSsl::DtlsV1_2OrLater:
+         minVersion = DTLS1_2_VERSION;
+-        maxVersion = DTLS_MAX_VERSION;
++        maxVersion = 0;
+         break;
+     case QSsl::TlsV1_3OrLater:
+ #ifdef TLS1_3_VERSION
+@@ -455,7 +455,7 @@ init_context:
+     }
+ 
+     // Enable bug workarounds.
+-    long options = QSslSocketBackendPrivate::setupOpenSslOptions(configuration.protocol(), configuration.d->sslOptions);
++    qssloptions options = QSslSocketBackendPrivate::setupOpenSslOptions(configuration.protocol(), configuration.d->sslOptions);
+     q_SSL_CTX_set_options(sslContext->ctx, options);
+ 
+     // Tell OpenSSL to release memory early
+diff --git a/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp b/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
+index aaf8741130..b58935372c 100644
+--- a/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
++++ b/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
+@@ -59,57 +59,6 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-#ifdef OPENSSL_NO_DEPRECATED_3_0
+-
+-static int q_DH_check(DH *dh, int *status)
+-{
+-    // DH_check was first deprecated in OpenSSL 3.0.0, as low-level
+-    // API; the EVP_PKEY family of functions was advised as an alternative.
+-    // As of now EVP_PKEY_params_check ends up calling ... DH_check,
+-    // which is good enough.
+-
+-    Q_ASSERT(dh);
+-    Q_ASSERT(status);
+-
+-    EVP_PKEY *key = q_EVP_PKEY_new();
+-    if (!key) {
+-        qCWarning(lcSsl, "EVP_PKEY_new failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-    const auto keyDeleter = qScopeGuard([key](){
+-        q_EVP_PKEY_free(key);
+-    });
+-    if (!q_EVP_PKEY_set1_DH(key, dh)) {
+-        qCWarning(lcSsl, "EVP_PKEY_set1_DH failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-
+-    EVP_PKEY_CTX *keyCtx = q_EVP_PKEY_CTX_new(key, nullptr);
+-    if (!keyCtx) {
+-        qCWarning(lcSsl, "EVP_PKEY_CTX_new failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-    const auto ctxDeleter = qScopeGuard([keyCtx]{
+-        q_EVP_PKEY_CTX_free(keyCtx);
+-    });
+-
+-    const int result = q_EVP_PKEY_param_check(keyCtx);
+-    QSslSocketBackendPrivate::logAndClearErrorQueue();
+-    // Note: unlike DH_check, we cannot obtain the 'status',
+-    // if the 'result' is 0 (actually the result is 1 only
+-    // if this 'status' was 0). We could probably check the
+-    // errors from the error queue, but it's not needed anyway
+-    // - see the 'isSafeDH' below, how it returns immediately
+-    // on 0.
+-    Q_UNUSED(status)
+-
+-    return result;
+-}
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+-
+ static bool isSafeDH(DH *dh)
+ {
+     int status = 0;
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl.cpp b/qtbase/src/network/ssl/qsslsocket_openssl.cpp
+index 37fad2a68f..8f6858c867 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl.cpp
++++ b/qtbase/src/network/ssl/qsslsocket_openssl.cpp
+@@ -550,9 +550,9 @@ static void q_loadCiphersForConnection(SSL *connection, QList<QSslCipher> &ciphe
+ // Defined in qsslsocket.cpp
+ void q_setDefaultDtlsCiphers(const QList<QSslCipher> &ciphers);
+ 
+-long QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions)
++qssloptions QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions)
+ {
+-    long options;
++    qssloptions options;
+     if (protocol == QSsl::TlsV1SslV3)
+         options = SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3;
+     else if (protocol == QSsl::SecureProtocols)
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_p.h b/qtbase/src/network/ssl/qsslsocket_openssl_p.h
+index 4103de23e8..5547589256 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_p.h
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_p.h
+@@ -107,6 +107,12 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++typedef uint64_t qssloptions;
++#else
++typedef unsigned long qssloptions;
++#endif
++
+ struct QSslErrorEntry {
+     int code;
+     int depth;
+@@ -171,7 +177,7 @@ public:
+     QVector<QSslError> ocspErrors;
+     QByteArray ocspResponseDer;
+ 
+-    Q_AUTOTEST_EXPORT static long setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions);
++    Q_AUTOTEST_EXPORT static qssloptions setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions);
+     static QSslCipher QSslCipher_from_SSL_CIPHER(const SSL_CIPHER *cipher);
+     static QList<QSslCertificate> STACKOFX509_to_QSslCertificates(STACK_OF(X509) *x509);
+     static QList<QSslError> verify(const QList<QSslCertificate> &certificateChain, const QString &hostName);
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp b/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
+index e53fb279f0..459ccd0b19 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
+@@ -148,7 +148,6 @@ DEFINEFUNC(int, EVP_PKEY_up_ref, EVP_PKEY *a, a, return 0, return)
+ DEFINEFUNC2(EVP_PKEY_CTX *, EVP_PKEY_CTX_new, EVP_PKEY *pkey, pkey, ENGINE *e, e, return nullptr, return)
+ DEFINEFUNC(int, EVP_PKEY_param_check, EVP_PKEY_CTX *ctx, ctx, return 0, return)
+ DEFINEFUNC(void, EVP_PKEY_CTX_free, EVP_PKEY_CTX *ctx, ctx, return, return)
+-DEFINEFUNC(int, EVP_PKEY_base_id, EVP_PKEY *a, a, return NID_undef, return)
+ DEFINEFUNC(int, RSA_bits, RSA *a, a, return 0, return)
+ DEFINEFUNC(int, DSA_bits, DSA *a, a, return 0, return)
+ DEFINEFUNC(int, OPENSSL_sk_num, OPENSSL_STACK *a, a, return -1, return)
+@@ -158,7 +157,7 @@ DEFINEFUNC2(void, OPENSSL_sk_push, OPENSSL_STACK *a, a, void *b, b, return, DUMM
+ DEFINEFUNC(void, OPENSSL_sk_free, OPENSSL_STACK *a, a, return, DUMMYARG)
+ DEFINEFUNC2(void *, OPENSSL_sk_value, OPENSSL_STACK *a, a, int b, b, return nullptr, return)
+ DEFINEFUNC(int, SSL_session_reused, SSL *a, a, return 0, return)
+-DEFINEFUNC2(unsigned long, SSL_CTX_set_options, SSL_CTX *ctx, ctx, unsigned long op, op, return 0, return)
++DEFINEFUNC2(qssloptions, SSL_CTX_set_options, SSL_CTX *ctx, ctx, qssloptions op, op, return 0, return)
+ DEFINEFUNC(int, SSL_CTX_get_security_level, const SSL_CTX *ctx, ctx, return -1, return)
+ DEFINEFUNC2(void, SSL_CTX_set_security_level, SSL_CTX *ctx, ctx, int level, level, return, return)
+ #ifdef TLS1_3_VERSION
+@@ -371,7 +370,15 @@ DEFINEFUNC(const SSL_CIPHER *, SSL_get_current_cipher, SSL *a, a, return nullptr
+ DEFINEFUNC(int, SSL_version, const SSL *a, a, return 0, return)
+ DEFINEFUNC2(int, SSL_get_error, SSL *a, a, int b, b, return -1, return)
+ DEFINEFUNC(STACK_OF(X509) *, SSL_get_peer_cert_chain, SSL *a, a, return nullptr, return)
++
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++DEFINEFUNC(X509 *, SSL_get1_peer_certificate, SSL *a, a, return nullptr, return)
++DEFINEFUNC(int, EVP_PKEY_get_base_id, const EVP_PKEY *pkey, pkey, return -1, return)
++#else
+ DEFINEFUNC(X509 *, SSL_get_peer_certificate, SSL *a, a, return nullptr, return)
++DEFINEFUNC(int, EVP_PKEY_base_id, EVP_PKEY *a, a, return NID_undef, return)
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+ DEFINEFUNC(long, SSL_get_verify_result, const SSL *a, a, return -1, return)
+ DEFINEFUNC(SSL *, SSL_new, SSL_CTX *a, a, return nullptr, return)
+ DEFINEFUNC(SSL_CTX *, SSL_get_SSL_CTX, SSL *a, a, return nullptr, return)
+@@ -492,9 +499,7 @@ DEFINEFUNC(DH *, DH_new, DUMMYARG, DUMMYARG, return nullptr, return)
+ DEFINEFUNC(void, DH_free, DH *dh, dh, return, DUMMYARG)
+ DEFINEFUNC3(DH *, d2i_DHparams, DH**a, a, const unsigned char **pp, pp, long length, length, return nullptr, return)
+ DEFINEFUNC2(int, i2d_DHparams, DH *a, a, unsigned char **p, p, return -1, return)
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+ DEFINEFUNC2(int, DH_check, DH *dh, dh, int *codes, codes, return 0, return)
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+ DEFINEFUNC3(BIGNUM *, BN_bin2bn, const unsigned char *s, s, int len, len, BIGNUM *ret, ret, return nullptr, return)
+ 
+ #ifndef OPENSSL_NO_EC
+@@ -868,7 +873,6 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(EVP_PKEY_CTX_new)
+     RESOLVEFUNC(EVP_PKEY_param_check)
+     RESOLVEFUNC(EVP_PKEY_CTX_free)
+-    RESOLVEFUNC(EVP_PKEY_base_id)
+     RESOLVEFUNC(RSA_bits)
+     RESOLVEFUNC(OPENSSL_sk_new_null)
+     RESOLVEFUNC(OPENSSL_sk_push)
+@@ -1107,7 +1111,15 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(SSL_version)
+     RESOLVEFUNC(SSL_get_error)
+     RESOLVEFUNC(SSL_get_peer_cert_chain)
++
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++    RESOLVEFUNC(SSL_get1_peer_certificate)
++    RESOLVEFUNC(EVP_PKEY_get_base_id)
++#else
+     RESOLVEFUNC(SSL_get_peer_certificate)
++    RESOLVEFUNC(EVP_PKEY_base_id)
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+     RESOLVEFUNC(SSL_get_verify_result)
+     RESOLVEFUNC(SSL_new)
+     RESOLVEFUNC(SSL_get_SSL_CTX)
+@@ -1206,9 +1218,7 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(DH_free)
+     RESOLVEFUNC(d2i_DHparams)
+     RESOLVEFUNC(i2d_DHparams)
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+     RESOLVEFUNC(DH_check)
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+     RESOLVEFUNC(BN_bin2bn)
+ 
+ #ifndef OPENSSL_NO_EC
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h b/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
+index 95e8897a3b..27aeffa18a 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
+@@ -237,7 +237,6 @@ Q_AUTOTEST_EXPORT int q_EVP_PKEY_up_ref(EVP_PKEY *a);
+ EVP_PKEY_CTX *q_EVP_PKEY_CTX_new(EVP_PKEY *pkey, ENGINE *e);
+ void q_EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx);
+ int q_EVP_PKEY_param_check(EVP_PKEY_CTX *ctx);
+-int q_EVP_PKEY_base_id(EVP_PKEY *a);
+ int q_RSA_bits(RSA *a);
+ Q_AUTOTEST_EXPORT int q_OPENSSL_sk_num(OPENSSL_STACK *a);
+ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_pop_free(OPENSSL_STACK *a, void (*b)(void *));
+@@ -246,7 +245,7 @@ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_push(OPENSSL_STACK *st, void *data);
+ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_free(OPENSSL_STACK *a);
+ Q_AUTOTEST_EXPORT void * q_OPENSSL_sk_value(OPENSSL_STACK *a, int b);
+ int q_SSL_session_reused(SSL *a);
+-unsigned long q_SSL_CTX_set_options(SSL_CTX *ctx, unsigned long op);
++qssloptions q_SSL_CTX_set_options(SSL_CTX *ctx, qssloptions op);
+ int q_OPENSSL_init_ssl(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings);
+ size_t q_SSL_get_client_random(SSL *a, unsigned char *out, size_t outlen);
+ size_t q_SSL_SESSION_get_master_key(const SSL_SESSION *session, unsigned char *out, size_t outlen);
+@@ -510,7 +509,6 @@ const SSL_CIPHER *q_SSL_get_current_cipher(SSL *a);
+ int q_SSL_version(const SSL *a);
+ int q_SSL_get_error(SSL *a, int b);
+ STACK_OF(X509) *q_SSL_get_peer_cert_chain(SSL *a);
+-X509 *q_SSL_get_peer_certificate(SSL *a);
+ long q_SSL_get_verify_result(const SSL *a);
+ SSL *q_SSL_new(SSL_CTX *a);
+ SSL_CTX *q_SSL_get_SSL_CTX(SSL *a);
+@@ -582,10 +580,7 @@ DH *q_DH_new();
+ void q_DH_free(DH *dh);
+ DH *q_d2i_DHparams(DH **a, const unsigned char **pp, long length);
+ int q_i2d_DHparams(DH *a, unsigned char **p);
+-
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+ int q_DH_check(DH *dh, int *codes);
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+ 
+ BIGNUM *q_BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret);
+ #define q_SSL_CTX_set_tmp_dh(ctx, dh) q_SSL_CTX_ctrl((ctx), SSL_CTRL_SET_TMP_DH, 0, (char *)dh)
+@@ -754,6 +749,17 @@ void q_CRYPTO_free(void *str, const char *file, int line);
+ int q_SSL_CTX_get_security_level(const SSL_CTX *ctx);
+ void q_SSL_CTX_set_security_level(SSL_CTX *ctx, int level);
+ 
++// Here we have the ones that make difference between OpenSSL pre/post v3:
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++X509 *q_SSL_get1_peer_certificate(SSL *a);
++#define q_SSL_get_peer_certificate q_SSL_get1_peer_certificate
++int q_EVP_PKEY_get_base_id(const EVP_PKEY *pkey);
++#define q_EVP_PKEY_base_id q_EVP_PKEY_get_base_id
++#else
++X509 *q_SSL_get_peer_certificate(SSL *a);
++int q_EVP_PKEY_base_id(EVP_PKEY *a);
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+ QT_END_NAMESPACE
+ 
+ #endif
+diff --git a/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h b/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
+index bf37d07fd8..dbd42fb799 100644
+--- a/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
++++ b/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
+@@ -61,7 +61,11 @@
+ # if !defined(Q_OS_INTEGRITY)
+ #  define WIN_INTERFACE_CUSTOM   // NV
+ # endif // Q_OS_INTEGRITY
+-#endif  // QT_EGL_NO_X11
++#else // QT_EGL_NO_X11
++// If one has an eglplatform.h with https://github.com/KhronosGroup/EGL-Registry/pull/130
++// that needs USE_X11 to be defined.
++# define USE_X11
++#endif
+ 
+ #ifdef QT_EGL_WAYLAND
+ # define WAYLAND // NV
+diff --git a/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+index 159b490ce0..00aa80cd58 100644
+--- a/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
++++ b/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+@@ -567,6 +567,8 @@ void QFontconfigDatabase::populateFontDatabase()
+         fonts = FcFontList(nullptr, pattern, os);
+         FcObjectSetDestroy(os);
+         FcPatternDestroy(pattern);
++        if (!fonts)
++            return;
+     }
+ 
+     for (int i = 0; i < fonts->nfont; i++)
+diff --git a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
+index b713c19447..7cb9a8c79a 100644
+--- a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
++++ b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
+@@ -95,6 +95,7 @@ static constexpr const auto KeyTbl = qMakeArray(
+         Xkb2Qt<XKB_KEY_Clear,                   Qt::Key_Delete>,
+         Xkb2Qt<XKB_KEY_Pause,                   Qt::Key_Pause>,
+         Xkb2Qt<XKB_KEY_Print,                   Qt::Key_Print>,
++        Xkb2Qt<XKB_KEY_Sys_Req,                 Qt::Key_SysReq>,
+         Xkb2Qt<0x1005FF60,                      Qt::Key_SysReq>,         // hardcoded Sun SysReq
+         Xkb2Qt<0x1007ff00,                      Qt::Key_SysReq>,         // hardcoded X386 SysReq
+ 
+@@ -471,7 +472,7 @@ QVector<xkb_keysym_t> QXkbCommon::toKeysym(QKeyEvent *event)
+     } else if (event->modifiers() & Qt::KeypadModifier) {
+         if (qtKey >= Qt::Key_0 && qtKey <= Qt::Key_9)
+             keysyms.append(XKB_KEY_KP_0 + (qtKey - Qt::Key_0));
+-    } else if (isLatin(qtKey) && event->text().isUpper()) {
++    } else if (isLatin1(qtKey) && event->text().isUpper()) {
+         keysyms.append(qtKey);
+     }
+ 
+@@ -523,7 +524,7 @@ int QXkbCommon::keysymToQtKey(xkb_keysym_t keysym, Qt::KeyboardModifiers modifie
+         // With standard shortcuts we should prefer a latin character, this is
+         // for checks like "some qkeyevent == QKeySequence::Copy" to work even
+         // when using for example 'russian' keyboard layout.
+-        if (!QXkbCommon::isLatin(keysym)) {
++        if (!QXkbCommon::isLatin1(keysym)) {
+             xkb_keysym_t latinKeysym = QXkbCommon::lookupLatinKeysym(state, code);
+             if (latinKeysym != XKB_KEY_NoSymbol)
+                 keysym = latinKeysym;
+@@ -546,7 +547,7 @@ static int keysymToQtKey_internal(xkb_keysym_t keysym, Qt::KeyboardModifiers mod
+     } else if (keysym >= XKB_KEY_KP_0 && keysym <= XKB_KEY_KP_9) {
+         // numeric keypad keys
+         qtKey = Qt::Key_0 + (keysym - XKB_KEY_KP_0);
+-    } else if (QXkbCommon::isLatin(keysym)) {
++    } else if (QXkbCommon::isLatin1(keysym)) {
+         qtKey = QXkbCommon::qxkbcommon_xkb_keysym_to_upper(keysym);
+     } else {
+         // check if we have a direct mapping
+@@ -678,7 +679,7 @@ QList<int> QXkbCommon::possibleKeys(xkb_state *state, const QKeyEvent *event,
+         Qt::KeyboardModifiers neededMods = ModsTbl[i];
+         if ((modifiers & neededMods) == neededMods) {
+             if (i == 8) {
+-                if (isLatin(baseQtKey))
++                if (isLatin1(baseQtKey))
+                     continue;
+                 // add a latin key as a fall back key
+                 sym = lookupLatinKeysym(state, keycode);
+@@ -733,7 +734,7 @@ void QXkbCommon::verifyHasLatinLayout(xkb_keymap *keymap)
+     for (xkb_layout_index_t layout = 0; layout < layoutCount; ++layout) {
+         for (xkb_keycode_t code = minKeycode; code < maxKeycode; ++code) {
+             xkb_keymap_key_get_syms_by_level(keymap, code, layout, 0, &keysyms);
+-            if (keysyms && isLatin(keysyms[0]))
++            if (keysyms && isLatin1(keysyms[0]))
+                 nrLatinKeys++;
+             if (nrLatinKeys > 10) // arbitrarily chosen threshold
+                 return;
+@@ -766,7 +767,7 @@ xkb_keysym_t QXkbCommon::lookupLatinKeysym(xkb_state *state, xkb_keycode_t keyco
+         xkb_level_index_t level = xkb_state_key_get_level(state, keycode, layout);
+         if (xkb_keymap_key_get_syms_by_level(keymap, keycode, layout, level, &syms) != 1)
+             continue;
+-        if (isLatin(syms[0])) {
++        if (isLatin1(syms[0])) {
+             sym = syms[0];
+             break;
+         }
+diff --git a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
+index 561eae03db..8389bd8f5a 100644
+--- a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
++++ b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
+@@ -94,8 +94,8 @@ public:
+     static void verifyHasLatinLayout(xkb_keymap *keymap);
+     static xkb_keysym_t lookupLatinKeysym(xkb_state *state, xkb_keycode_t keycode);
+ 
+-    static bool isLatin(xkb_keysym_t sym) {
+-        return ((sym >= 'a' && sym <= 'z') || (sym >= 'A' && sym <= 'Z'));
++    static bool isLatin1(xkb_keysym_t sym) {
++        return sym <= 0xff;
+     }
+     static bool isKeypad(xkb_keysym_t sym) {
+         return sym >= XKB_KEY_KP_Space && sym <= XKB_KEY_KP_9;
+diff --git a/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp b/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
+index 8cd7f9b368..406f84663f 100644
+--- a/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
++++ b/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
+@@ -318,7 +318,7 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources,
+ 
+     if (current < 0 && crtc_mode.clock != 0) {
+         modes << crtc_mode;
+-        current = mode.size() - 1;
++        current = modes.size() - 1;
+     }
+ 
+     if (configuration == OutputConfigCurrent)
+diff --git a/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp b/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
+index 9153fd20bb..255ea5e33e 100644
+--- a/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
++++ b/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
+@@ -194,6 +194,9 @@ QString AtSpiAdaptor::introspect(const QString &path) const
+                 "      <arg direction=\"out\" type=\"(so)\"/>\n"
+                 "      <annotation value=\"QSpiObjectReference\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n"
+                 "    </method>\n"
++                "    <method name=\"GetAccessibleId\">\n"
++                "      <arg direction=\"out\" type=\"s\"/>\n"
++                "    </method>\n"
+                 "  </interface>\n"
+                 );
+ 
+@@ -913,8 +916,17 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+     }
+     case QAccessible::NameChanged: {
+         if (sendObject || sendObject_property_change || sendObject_property_change_accessible_name) {
+-            QString path = pathForInterface(event->accessibleInterface());
+-            QVariantList args = packDBusSignalArguments(QLatin1String("accessible-name"), 0, 0, variantForPath(path));
++            QAccessibleInterface *iface = event->accessibleInterface();
++            if (!iface) {
++                qCDebug(lcAccessibilityAtspi,
++                        "NameChanged event from invalid accessible.");
++                return;
++            }
++
++            QString path = pathForInterface(iface);
++            QVariantList args = packDBusSignalArguments(
++                QLatin1String("accessible-name"), 0, 0,
++                QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Name))));
+             sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                            QLatin1String("PropertyChange"), args);
+         }
+@@ -922,8 +934,17 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+     }
+     case QAccessible::DescriptionChanged: {
+         if (sendObject || sendObject_property_change || sendObject_property_change_accessible_description) {
+-            QString path = pathForInterface(event->accessibleInterface());
+-            QVariantList args = packDBusSignalArguments(QLatin1String("accessible-description"), 0, 0, variantForPath(path));
++            QAccessibleInterface *iface = event->accessibleInterface();
++            if (!iface) {
++                qCDebug(lcAccessibilityAtspi,
++                        "DescriptionChanged event from invalid accessible.");
++                return;
++            }
++
++            QString path = pathForInterface(iface);
++            QVariantList args = packDBusSignalArguments(
++                QLatin1String("accessible-description"), 0, 0,
++                QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Description))));
+             sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                            QLatin1String("PropertyChange"), args);
+         }
+@@ -1038,7 +1059,9 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+                 // Combo Box with AT-SPI likes to be special
+                 // It requires a name-change to update caches and then selection-changed
+                 QString path = pathForInterface(iface);
+-                QVariantList args1 = packDBusSignalArguments(QLatin1String("accessible-name"), 0, 0, variantForPath(path));
++                QVariantList args1 = packDBusSignalArguments(
++                    QLatin1String("accessible-name"), 0, 0,
++                    QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Name))));
+                 sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                                QLatin1String("PropertyChange"), args1);
+                 QVariantList args2 = packDBusSignalArguments(QString(), 0, 0, QVariant::fromValue(QDBusVariant(QVariant(0))));
+@@ -1358,6 +1381,26 @@ void AtSpiAdaptor::registerApplication()
+     delete registry;
+ }
+ 
++namespace {
++QString accessibleIdForAccessible(QAccessibleInterface *accessible)
++{
++    QString result;
++    while (accessible) {
++        if (!result.isEmpty())
++            result.prepend(QLatin1Char('.'));
++        if (auto obj = accessible->object()) {
++            const QString name = obj->objectName();
++            if (!name.isEmpty())
++                result.prepend(name);
++            else
++                result.prepend(QString::fromUtf8(obj->metaObject()->className()));
++        }
++        accessible = accessible->parent();
++    }
++    return result;
++}
++} // namespace
++
+ // Accessible
+ bool AtSpiAdaptor::accessibleInterface(QAccessibleInterface *interface, const QString &function, const QDBusMessage &message, const QDBusConnection &connection)
+ {
+@@ -1441,6 +1484,9 @@ bool AtSpiAdaptor::accessibleInterface(QAccessibleInterface *interface, const QS
+             children << ref;
+         }
+         connection.send(message.createReply(QVariant::fromValue(children)));
++    } else if (function == QLatin1String("GetAccessibleId")) {
++        sendReply(connection, message,
++                  QVariant::fromValue(QDBusVariant(accessibleIdForAccessible(interface))));
+     } else {
+         qCDebug(lcAccessibilityAtspi) << "WARNING: AtSpiAdaptor::accessibleInterface does not implement " << function << message.path();
+         return false;
+diff --git a/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp b/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
+index 45ddc8e496..cc734abc63 100644
+--- a/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
++++ b/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
+@@ -69,6 +69,21 @@ QT_BEGIN_NAMESPACE
+ DBusConnection::DBusConnection(QObject *parent)
+     : QObject(parent), m_a11yConnection(QString()), m_enabled(false)
+ {
++    // If the bus is explicitly set via env var it overrides everything else.
++    QByteArray addressEnv = qgetenv("AT_SPI_BUS_ADDRESS");
++    if (!addressEnv.isEmpty()) {
++        // Only connect on next loop run, connections to our enabled signal are
++        // only established after the ctor returns.
++        QMetaObject::invokeMethod(
++                this,
++                [this, addressEnv] {
++                    m_enabled = true;
++                    connectA11yBus(QString::fromLocal8Bit(addressEnv));
++                },
++                Qt::QueuedConnection);
++        return;
++    }
++
+     // Start monitoring if "org.a11y.Bus" is registered as DBus service.
+     QDBusConnection c = QDBusConnection::sessionBus();
+     if (!c.isConnected()) {
+diff --git a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
+index 1a3cab275d..2abe039126 100644
+--- a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
++++ b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
+@@ -51,6 +51,9 @@
+ #include <QtCore/QStandardPaths>
+ #include <QtCore/QUrl>
+ 
++#include <QtGui/QGuiApplication>
++#include <QtGui/QWindow>
++
+ #if QT_CONFIG(dbus)
+ // These QtCore includes are needed for xdg-desktop-portal support
+ #include <QtCore/private/qcore_unix_p.h>
+@@ -58,6 +61,8 @@
+ #include <QtCore/QFileInfo>
+ #include <QtCore/QUrlQuery>
+ 
++#include <QtGui/QColor>
++
+ #include <QtDBus/QDBusConnection>
+ #include <QtDBus/QDBusMessage>
+ #include <QtDBus/QDBusPendingCall>
+@@ -142,6 +147,8 @@ static inline bool detectWebBrowser(const QByteArray &desktop,
+     }
+ 
+     if (desktop == QByteArray("KDE")) {
++        if (checkExecutable(QStringLiteral("kde-open5"), browser))
++            return true;
+         // Konqueror launcher
+         if (checkExecutable(QStringLiteral("kfmclient"), browser)) {
+             browser->append(QLatin1String(" exec"));
+@@ -296,8 +303,135 @@ static inline QDBusMessage xdgDesktopPortalSendEmail(const QUrl &url)
+ 
+     return QDBusConnection::sessionBus().call(message);
+ }
++
++namespace {
++struct XDGDesktopColor
++{
++    double r = 0;
++    double g = 0;
++    double b = 0;
++
++    QColor toQColor() const
++    {
++        constexpr auto rgbMax = 255;
++        return { static_cast<int>(r * rgbMax), static_cast<int>(g * rgbMax),
++                 static_cast<int>(b * rgbMax) };
++    }
++};
++
++const QDBusArgument &operator>>(const QDBusArgument &argument, XDGDesktopColor &myStruct)
++{
++    argument.beginStructure();
++    argument >> myStruct.r >> myStruct.g >> myStruct.b;
++    argument.endStructure();
++    return argument;
++}
++
++class XdgDesktopPortalColorPicker : public QPlatformServiceColorPicker
++{
++    Q_OBJECT
++public:
++    XdgDesktopPortalColorPicker(const QString &parentWindowId, QWindow *parent)
++        : QPlatformServiceColorPicker(parent), m_parentWindowId(parentWindowId)
++    {
++    }
++
++    void pickColor() override
++    {
++        // DBus signature:
++        // PickColor (IN   s      parent_window,
++        //            IN   a{sv}  options
++        //            OUT  o      handle)
++        // Options:
++        // handle_token (s) -  A string that will be used as the last element of the @handle.
++
++        QDBusMessage message = QDBusMessage::createMethodCall(
++                QStringLiteral("org.freedesktop.portal.Desktop"), QStringLiteral("/org/freedesktop/portal/desktop"),
++                QStringLiteral("org.freedesktop.portal.Screenshot"), QStringLiteral("PickColor"));
++        message << m_parentWindowId << QVariantMap();
++
++        QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
++        auto watcher = new QDBusPendingCallWatcher(pendingCall, this);
++        connect(watcher, &QDBusPendingCallWatcher::finished, this,
++                [this](QDBusPendingCallWatcher *watcher) {
++                    watcher->deleteLater();
++                    QDBusPendingReply<QDBusObjectPath> reply = *watcher;
++                    if (reply.isError()) {
++                        qWarning("DBus call to pick color failed: %s",
++                                 qPrintable(reply.error().message()));
++                        Q_EMIT colorPicked({});
++                    } else {
++                        QDBusConnection::sessionBus().connect(
++                                QStringLiteral("org.freedesktop.portal.Desktop"), reply.value().path(),
++                                QStringLiteral("org.freedesktop.portal.Request"), QStringLiteral("Response"), this,
++                                // clang-format off
++                                SLOT(gotColorResponse(uint,QVariantMap))
++                                // clang-format on
++                        );
++                    }
++                });
++    }
++
++private Q_SLOTS:
++    void gotColorResponse(uint result, const QVariantMap &map)
++    {
++        if (result != 0)
++            return;
++        XDGDesktopColor color{};
++        map.value(QStringLiteral("color")).value<QDBusArgument>() >> color;
++        Q_EMIT colorPicked(color.toQColor());
++        deleteLater();
++    }
++
++private:
++    const QString m_parentWindowId;
++};
++} // namespace
++
+ #endif // QT_CONFIG(dbus)
+ 
++QGenericUnixServices::QGenericUnixServices()
++{
++#if QT_CONFIG(dbus)
++    if (qEnvironmentVariableIntValue("QT_NO_XDG_DESKTOP_PORTAL") > 0) {
++        return;
++    }
++    QDBusMessage message = QDBusMessage::createMethodCall(
++            QStringLiteral("org.freedesktop.portal.Desktop"), QStringLiteral("/org/freedesktop/portal/desktop"),
++            QStringLiteral("org.freedesktop.DBus.Properties"), QStringLiteral("Get"));
++    message << QStringLiteral("org.freedesktop.portal.Screenshot")
++            << QStringLiteral("version");
++
++    QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
++    auto watcher = new QDBusPendingCallWatcher(pendingCall);
++    QObject::connect(watcher, &QDBusPendingCallWatcher::finished, watcher,
++                     [this](QDBusPendingCallWatcher *watcher) {
++                         watcher->deleteLater();
++                         QDBusPendingReply<QVariant> reply = *watcher;
++                         if (!reply.isError() && reply.value().toUInt() >= 2)
++                             m_hasScreenshotPortalWithColorPicking = true;
++                     });
++
++#endif
++}
++
++QPlatformServiceColorPicker *QGenericUnixServices::colorPicker(QWindow *parent)
++{
++#if QT_CONFIG(dbus)
++    // Make double sure that we are in a wayland environment. In particular check
++    // WAYLAND_DISPLAY so also XWayland apps benefit from portal-based color picking.
++    // Outside wayland we'll rather rely on other means than the XDG desktop portal.
++    if (!qEnvironmentVariableIsEmpty("WAYLAND_DISPLAY")
++        || QGuiApplication::platformName().startsWith(QLatin1String("wayland"))) {
++        return new XdgDesktopPortalColorPicker(portalWindowIdentifier(parent), parent);
++    }
++    return nullptr;
++#else
++    Q_UNUSED(parent);
++    return nullptr;
++#endif
++}
++
+ QByteArray QGenericUnixServices::desktopEnvironment() const
+ {
+     static const QByteArray result = detectDesktopEnvironment();
+@@ -352,6 +486,8 @@ bool QGenericUnixServices::openDocument(const QUrl &url)
+ }
+ 
+ #else
++QGenericUnixServices::QGenericUnixServices() = default;
++
+ QByteArray QGenericUnixServices::desktopEnvironment() const
+ {
+     return QByteArrayLiteral("UNKNOWN");
+@@ -371,6 +507,30 @@ bool QGenericUnixServices::openDocument(const QUrl &url)
+     return false;
+ }
+ 
++QPlatformServiceColorPicker *QGenericUnixServices::colorPicker(QWindow *parent)
++{
++    Q_UNUSED(parent);
++    return nullptr;
++}
++
+ #endif // QT_NO_MULTIPROCESS
+ 
++QString QGenericUnixServices::portalWindowIdentifier(QWindow *window)
++{
++    if (QGuiApplication::platformName() == QLatin1String("xcb"))
++        return QStringLiteral("x11:") + QString::number(window->winId(), 16);
++    return QString();
++}
++
++bool QGenericUnixServices::hasCapability(Capability capability) const
++{
++    switch (capability) {
++    case Capability::ColorPicking:
++        return m_hasScreenshotPortalWithColorPicking;
++    }
++    return false;
++}
++
+ QT_END_NAMESPACE
++
++#include "qgenericunixservices.moc"
+diff --git a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
+index 8ac3de6f03..30924e64bd 100644
+--- a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
++++ b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
+@@ -59,16 +59,21 @@ QT_BEGIN_NAMESPACE
+ class QGenericUnixServices : public QPlatformServices
+ {
+ public:
+-    QGenericUnixServices() {}
++    QGenericUnixServices();
+ 
+     QByteArray desktopEnvironment() const override;
+ 
++    bool hasCapability(Capability capability) const override;
+     bool openUrl(const QUrl &url) override;
+     bool openDocument(const QUrl &url) override;
++    QPlatformServiceColorPicker *colorPicker(QWindow *parent = nullptr) override;
++
++    virtual QString portalWindowIdentifier(QWindow *window);
+ 
+ private:
+     QString m_webBrowser;
+     QString m_documentLauncher;
++    bool m_hasScreenshotPortalWithColorPicking = false;
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
+index 09470bccc6..cc7c7d4d8a 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
+@@ -69,6 +69,7 @@ const QString MenuBarPath = QLatin1String("/MenuBar");
+ */
+ QDBusMenuConnection::QDBusMenuConnection(QObject *parent, const QString &serviceName)
+     : QObject(parent)
++    , m_serviceName(serviceName)
+     , m_connection(serviceName.isNull() ? QDBusConnection::sessionBus()
+                                         : QDBusConnection::connectToBus(QDBusConnection::SessionBus, serviceName))
+     , m_dbusWatcher(new QDBusServiceWatcher(StatusNotifierWatcherService, m_connection, QDBusServiceWatcher::WatchForRegistration, this))
+@@ -83,6 +84,12 @@ QDBusMenuConnection::QDBusMenuConnection(QObject *parent, const QString &service
+ #endif
+ }
+ 
++QDBusMenuConnection::~QDBusMenuConnection()
++{
++  if (!m_serviceName.isEmpty() && m_connection.isConnected())
++      QDBusConnection::disconnectFromBus(m_serviceName);
++}
++
+ void QDBusMenuConnection::dbusError(const QDBusError &error)
+ {
+     qWarning() << "QDBusTrayIcon encountered a D-Bus error:" << error;
+@@ -105,13 +112,7 @@ void QDBusMenuConnection::unregisterTrayIconMenu(QDBusTrayIcon *item)
+ 
+ bool QDBusMenuConnection::registerTrayIcon(QDBusTrayIcon *item)
+ {
+-    bool success = connection().registerService(item->instanceId());
+-    if (!success) {
+-        qWarning() << "failed to register service" << item->instanceId();
+-        return false;
+-    }
+-
+-    success = connection().registerObject(StatusNotifierItemPath, item);
++    bool success = connection().registerObject(StatusNotifierItemPath, item);
+     if (!success) {
+         unregisterTrayIcon(item);
+         qWarning() << "failed to register" << item->instanceId() << StatusNotifierItemPath;
+@@ -126,21 +127,18 @@ bool QDBusMenuConnection::registerTrayIcon(QDBusTrayIcon *item)
+ 
+ bool QDBusMenuConnection::registerTrayIconWithWatcher(QDBusTrayIcon *item)
+ {
++    Q_UNUSED(item);
+     QDBusMessage registerMethod = QDBusMessage::createMethodCall(
+                 StatusNotifierWatcherService, StatusNotifierWatcherPath, StatusNotifierWatcherService,
+                 QLatin1String("RegisterStatusNotifierItem"));
+-    registerMethod.setArguments(QVariantList() << item->instanceId());
++    registerMethod.setArguments(QVariantList() << m_connection.baseService());
+     return m_connection.callWithCallback(registerMethod, this, SIGNAL(trayIconRegistered()), SLOT(dbusError(QDBusError)));
+ }
+ 
+-bool QDBusMenuConnection::unregisterTrayIcon(QDBusTrayIcon *item)
++void QDBusMenuConnection::unregisterTrayIcon(QDBusTrayIcon *item)
+ {
+     unregisterTrayIconMenu(item);
+     connection().unregisterObject(StatusNotifierItemPath);
+-    bool success = connection().unregisterService(item->instanceId());
+-    if (!success)
+-        qWarning() << "failed to unregister service" << item->instanceId();
+-    return success;
+ }
+ #endif // QT_NO_SYSTEMTRAYICON
+ 
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
+index f484795fbb..97bdfabb85 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
++++ b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
+@@ -70,6 +70,7 @@ class QDBusMenuConnection : public QObject
+ 
+ public:
+     QDBusMenuConnection(QObject *parent = nullptr, const QString &serviceName = QString());
++    ~QDBusMenuConnection();
+     QDBusConnection connection() const { return m_connection; }
+     QDBusServiceWatcher *dbusWatcher() const { return m_dbusWatcher; }
+     bool isStatusNotifierHostRegistered() const { return m_statusNotifierHostRegistered; }
+@@ -78,7 +79,7 @@ public:
+     void unregisterTrayIconMenu(QDBusTrayIcon *item);
+     bool registerTrayIcon(QDBusTrayIcon *item);
+     bool registerTrayIconWithWatcher(QDBusTrayIcon *item);
+-    bool unregisterTrayIcon(QDBusTrayIcon *item);
++    void unregisterTrayIcon(QDBusTrayIcon *item);
+ #endif // QT_NO_SYSTEMTRAYICON
+ 
+ Q_SIGNALS:
+@@ -90,6 +91,7 @@ private Q_SLOTS:
+     void dbusError(const QDBusError &error);
+ 
+ private:
++    QString m_serviceName;
+     QDBusConnection m_connection;
+     QDBusServiceWatcher *m_dbusWatcher;
+     bool m_statusNotifierHostRegistered;
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp b/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
+index bede70975a..76bfec5e5a 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
+@@ -71,8 +71,12 @@ Q_LOGGING_CATEGORY(qLcTray, "qt.qpa.tray")
+ static QString iconTempPath()
+ {
+     QString tempPath = QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation);
+-    if (!tempPath.isEmpty())
++    if (!tempPath.isEmpty()) {
++        QString flatpakId = qEnvironmentVariable("FLATPAK_ID");
++        if (!flatpakId.isEmpty() && QFileInfo::exists(QLatin1String("/.flatpak-info")))
++            tempPath += QLatin1String("/app/") + flatpakId;
+         return tempPath;
++    }
+ 
+     tempPath = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation);
+ 
+diff --git a/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+index cb1b39db64..6e01af052c 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+@@ -755,6 +755,9 @@ QVariant QGnomeTheme::themeHint(QPlatformTheme::ThemeHint hint) const
+         return QVariant(QChar(0x2022));
+     case QPlatformTheme::UiEffects:
+         return QVariant(int(HoverEffect));
++    case QPlatformTheme::ButtonPressKeys:
++        return QVariant::fromValue(
++                QList<Qt::Key>({ Qt::Key_Space, Qt::Key_Return, Qt::Key_Enter, Qt::Key_Select }));
+     default:
+         break;
+     }
+diff --git a/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp b/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
+index 98e05195ee..1e92f43dec 100644
+--- a/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
++++ b/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
+@@ -343,8 +343,7 @@ void QEglFSCursor::paintOnScreen()
+     // screens are siblings of each other. When not enabled, the sibling list
+     // only contains m_screen itself.
+     for (QPlatformScreen *screen : m_screen->virtualSiblings()) {
+-        if (screen->geometry().contains(cr.topLeft().toPoint() + m_cursor.hotSpot)
+-            && QOpenGLContext::currentContext()->screen() == screen->screen())
++        if (screen->geometry().contains(cr.topLeft().toPoint() + m_cursor.hotSpot))
+         {
+             cr.translate(-screen->geometry().topLeft());
+             const QSize screenSize = screen->geometry().size();
+@@ -468,11 +467,12 @@ void QEglFSCursor::draw(const QRectF &r)
+ {
+     StateSaver stateSaver;
+ 
+-    QEglFSCursorData &gfx = static_cast<QEglFSContext*>(QOpenGLContext::currentContext()->handle())->cursorData;
+-    if (!gfx.program) {
+-        // one time initialization
++    // one time initialization
++    if (!QOpenGLFunctions::d_ptr)
+         initializeOpenGLFunctions();
+ 
++    QEglFSCursorData &gfx = static_cast<QEglFSContext*>(QOpenGLContext::currentContext()->handle())->cursorData;
++    if (!gfx.program) {
+         createShaderPrograms();
+ 
+         if (!gfx.atlasTexture) {
+diff --git a/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp b/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
+index 645a0ae2e9..3e0e406f1a 100644
+--- a/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
++++ b/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
+@@ -179,7 +179,7 @@ void QEglFSKmsEventReader::create(QEglFSKmsDevice *device)
+ 
+     m_device = device;
+ 
+-    qCDebug(qLcEglfsKmsDebug, "Initalizing event reader for device %p fd %d",
++    qCDebug(qLcEglfsKmsDebug, "Initializing event reader for device %p fd %d",
+             m_device, m_device->fd());
+ 
+     m_thread = new QEglFSKmsEventReaderThread(m_device->fd());
+diff --git a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
+index 141fb68a23..d4294d425a 100644
+--- a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
++++ b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
+@@ -122,11 +122,13 @@ QOffscreenIntegration::QOffscreenIntegration()
+ #endif
+     m_services.reset(new QPlatformServices);
+ 
+-    QWindowSystemInterface::handleScreenAdded(new QOffscreenScreen);
++    m_screen = new QOffscreenScreen;
++    QWindowSystemInterface::handleScreenAdded(m_screen);
+ }
+ 
+ QOffscreenIntegration::~QOffscreenIntegration()
+ {
++    QWindowSystemInterface::handleScreenRemoved(m_screen);
+ }
+ 
+ void QOffscreenIntegration::initialize()
+diff --git a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
+index 0ea90f6c2f..fe00fde07c 100644
+--- a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
++++ b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
+@@ -84,6 +84,7 @@ protected:
+ #endif
+     QScopedPointer<QPlatformInputContext> m_inputContext;
+     QScopedPointer<QPlatformServices> m_services;
++    QPlatformScreen *m_screen;
+     mutable QScopedPointer<QPlatformNativeInterface> m_nativeInterface;
+ };
+ 
+diff --git a/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp b/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
+index 6fa5a8a2b3..1f49f0aefd 100644
+--- a/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
++++ b/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
+@@ -48,6 +48,7 @@
+ #include <qpa/qplatformnativeinterface.h>
+ #include <QtPlatformHeaders/qwglnativecontext.h>
+ 
++#include <private/qsystemlibrary_p.h>
+ #include <algorithm>
+ 
+ #include <wingdi.h>
+@@ -162,19 +163,25 @@ QFunctionPointer QWindowsOpengl32DLL::resolve(const char *name)
+ 
+ bool QWindowsOpengl32DLL::init(bool softwareRendering)
+ {
+-    const QByteArray opengl32 = QByteArrayLiteral("opengl32.dll");
+-    const QByteArray swopengl = QByteArrayLiteral("opengl32sw.dll");
++    const QByteArray opengl32 = QByteArrayLiteral("opengl32");
++    const QByteArray swopengl = QByteArrayLiteral("opengl32sw");
++    bool useSystemLib = false;
+ 
+     QByteArray openglDll = qgetenv("QT_OPENGL_DLL");
+-    if (openglDll.isEmpty())
++    if (openglDll.isEmpty()) {
+         openglDll = softwareRendering ? swopengl : opengl32;
++        useSystemLib = !softwareRendering;
++    }
+ 
+     openglDll = openglDll.toLower();
+     m_nonOpengl32 = openglDll != opengl32;
+ 
+     qCDebug(lcQpaGl) << "Qt: Using WGL and OpenGL from" << openglDll;
+ 
+-    m_lib = ::LoadLibraryA(openglDll.constData());
++    if (useSystemLib)
++        m_lib = QSystemLibrary::load((wchar_t*)(QString::fromLatin1(openglDll).utf16()));
++    else
++        m_lib = LoadLibraryA(openglDll.constData());
+     if (!m_lib) {
+         qErrnoWarning(::GetLastError(), "Failed to load %s", openglDll.constData());
+         return false;
+@@ -184,7 +191,7 @@ bool QWindowsOpengl32DLL::init(bool softwareRendering)
+         // Load opengl32.dll always. GDI functions like ChoosePixelFormat do
+         // GetModuleHandle for opengl32.dll and behave differently (and call back into
+         // opengl32) when the module is present. This is fine for dummy contexts and windows.
+-        ::LoadLibraryA("opengl32.dll");
++        QSystemLibrary::load(L"opengl32");
+     }
+ 
+     wglCreateContext = reinterpret_cast<HGLRC (WINAPI *)(HDC)>(resolve("wglCreateContext"));
+diff --git a/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp b/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
+index d7d186e804..9eb4011bf2 100644
+--- a/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
++++ b/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
+@@ -49,6 +49,7 @@
+ #include <QtCore/qstandardpaths.h>
+ #include <QtCore/qlibraryinfo.h>
+ #include <QtCore/qhash.h>
++#include <private/qsystemlibrary_p.h>
+ 
+ #ifndef QT_NO_OPENGL
+ #include <private/qopengl_p.h>
+@@ -396,7 +397,7 @@ bool QWindowsOpenGLTester::testDesktopGL()
+ 
+     // Test #1: Load opengl32.dll and try to resolve an OpenGL 2 function.
+     // This will typically fail on systems that do not have a real OpenGL driver.
+-    lib = LoadLibraryA("opengl32.dll");
++    lib = QSystemLibrary::load(L"opengl32");
+     if (lib) {
+         CreateContext = reinterpret_cast<CreateContextType>(
+             reinterpret_cast<QFunctionPointer>(::GetProcAddress(lib, "wglCreateContext")));
+diff --git a/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp b/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
+index 1afa00cfc9..118af6ce73 100644
+--- a/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
++++ b/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
+@@ -41,6 +41,7 @@
+ 
+ #include <QRect>
+ #include <QList>
++#include <QMap>
+ #include <QDebug>
+ 
+ #include <qmath.h>
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp b/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
+index 9e2a37a6a1..e6e175a118 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
+@@ -488,12 +488,12 @@ void QXcbConnection::printXcbError(const char *message, xcb_generic_error_t *err
+     uint clamped_error_code = qMin<uint>(error->error_code, (sizeof(xcb_errors) / sizeof(xcb_errors[0])) - 1);
+     uint clamped_major_code = qMin<uint>(error->major_code, (sizeof(xcb_protocol_request_codes) / sizeof(xcb_protocol_request_codes[0])) - 1);
+ 
+-    qCWarning(lcQpaXcb, "%s: %d (%s), sequence: %d, resource id: %d, major code: %d (%s), minor code: %d",
+-             message,
+-             int(error->error_code), xcb_errors[clamped_error_code],
+-             int(error->sequence), int(error->resource_id),
+-             int(error->major_code), xcb_protocol_request_codes[clamped_major_code],
+-             int(error->minor_code));
++    qCDebug(lcQpaXcb, "%s: %d (%s), sequence: %d, resource id: %d, major code: %d (%s), minor code: %d",
++            message,
++            int(error->error_code), xcb_errors[clamped_error_code],
++            int(error->sequence), int(error->resource_id),
++            int(error->major_code), xcb_protocol_request_codes[clamped_major_code],
++            int(error->minor_code));
+ }
+ 
+ static Qt::MouseButtons translateMouseButtons(int s)
+@@ -702,6 +702,8 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
+             QXcbVirtualDesktop *virtualDesktop = virtualDesktopForRootWindow(propertyNotify->window);
+             if (virtualDesktop)
+                 virtualDesktop->updateWorkArea();
++        } else if (propertyNotify->atom == atom(QXcbAtom::_NET_SUPPORTED)) {
++            m_wmSupport->updateNetWMAtoms();
+         } else {
+             HANDLE_PLATFORM_WINDOW_EVENT(xcb_property_notify_event_t, window, handlePropertyNotifyEvent);
+         }
+@@ -750,7 +752,7 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
+                 case XCB_XKB_NEW_KEYBOARD_NOTIFY: {
+                     xcb_xkb_new_keyboard_notify_event_t *ev = &xkb_event->new_keyboard_notify;
+                     if (ev->changed & XCB_XKB_NKN_DETAIL_KEYCODES)
+-                        m_keyboard->updateKeymap(ev);
++                        m_keyboard->updateKeymap();
+                     break;
+                 }
+                 default:
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp b/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
+index 76869ced60..02d2eebb56 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
+@@ -274,8 +274,7 @@ QPlatformWindow *QXcbIntegration::createForeignWindow(QWindow *window, WId nativ
+ #ifndef QT_NO_OPENGL
+ QPlatformOpenGLContext *QXcbIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
+ {
+-    QXcbScreen *screen = static_cast<QXcbScreen *>(context->screen()->handle());
+-    QXcbGlIntegration *glIntegration = screen->connection()->glIntegration();
++    QXcbGlIntegration *glIntegration = defaultConnection()->glIntegration();
+     if (!glIntegration) {
+         qWarning("QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled");
+         return nullptr;
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+index efecd7e2d1..e8286381a2 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+@@ -365,17 +365,6 @@ void QXcbKeyboard::updateKeymap(xcb_mapping_notify_event_t *event)
+     updateKeymap();
+ }
+ 
+-void QXcbKeyboard::updateKeymap(xcb_xkb_new_keyboard_notify_event_t *event)
+-{
+-    if (!event)
+-        return;
+-
+-    if (event->deviceID != event->oldDeviceID)
+-        m_config = false;
+-
+-    updateKeymap();
+-}
+-
+ void QXcbKeyboard::updateKeymap()
+ {
+     KeysymModifierMap keysymMods;
+@@ -383,6 +372,8 @@ void QXcbKeyboard::updateKeymap()
+         keysymMods = keysymsToModifiers();
+     updateModifiers(keysymMods);
+ 
++    m_config = true;
++
+     if (!m_xkbContext) {
+         m_xkbContext.reset(xkb_context_new(XKB_CONTEXT_NO_DEFAULT_INCLUDES));
+         if (!m_xkbContext) {
+@@ -398,13 +389,8 @@ void QXcbKeyboard::updateKeymap()
+     if (connection()->hasXKB()) {
+         m_xkbKeymap.reset(xkb_x11_keymap_new_from_device(m_xkbContext.get(), xcb_connection(),
+                                                          core_device_id, XKB_KEYMAP_COMPILE_NO_FLAGS));
+-        if (m_xkbKeymap) {
+-            if (m_config)
+-                m_xkbState.reset(xkb_state_new(m_xkbKeymap.get()));
+-            else
+-                m_xkbState.reset(xkb_x11_state_new_from_device(m_xkbKeymap.get(), xcb_connection(), core_device_id));
+-
+-        }
++        if (m_xkbKeymap)
++            m_xkbState.reset(xkb_x11_state_new_from_device(m_xkbKeymap.get(), xcb_connection(), core_device_id));
+     } else {
+         m_xkbKeymap.reset(keymapFromCore(keysymMods));
+         if (m_xkbKeymap)
+@@ -425,8 +411,6 @@ void QXcbKeyboard::updateKeymap()
+     updateXKBMods();
+ 
+     QXkbCommon::verifyHasLatinLayout(m_xkbKeymap.get());
+-
+-    m_config = true;
+ }
+ 
+ QList<int> QXcbKeyboard::possibleKeys(const QKeyEvent *event) const
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
+index b652c85fe3..0ee08aeff2 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
++++ b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
+@@ -69,7 +69,6 @@ public:
+ 
+     Qt::KeyboardModifiers translateModifiers(int s) const;
+     void updateKeymap(xcb_mapping_notify_event_t *event);
+-    void updateKeymap(xcb_xkb_new_keyboard_notify_event_t *event);
+     void updateKeymap();
+     QList<int> possibleKeys(const QKeyEvent *event) const;
+ 
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp b/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
+index ffda7b6a57..863e961f4c 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
+@@ -564,11 +564,6 @@ void QXcbWindow::setGeometry(const QRect &rect)
+ {
+     QPlatformWindow::setGeometry(rect);
+ 
+-    if (shouldDeferTask(Task::SetGeometry)) {
+-        m_deferredGeometry = rect;
+-        return;
+-    }
+-
+     propagateSizeHints();
+ 
+     QXcbScreen *currentScreen = xcbScreen();
+@@ -693,9 +688,6 @@ void QXcbWindow::setVisible(bool visible)
+ 
+ void QXcbWindow::show()
+ {
+-    if (shouldDeferTask(Task::Map))
+-        return;
+-
+     if (window()->isTopLevel()) {
+ 
+         // update WM_NORMAL_HINTS
+@@ -706,7 +698,7 @@ void QXcbWindow::show()
+         if (isTransient(window())) {
+             const QWindow *tp = window()->transientParent();
+             if (tp && tp->handle())
+-                transientXcbParent = static_cast<const QXcbWindow *>(tp->handle())->winId();
++                transientXcbParent = tp->handle()->winId();
+             // Default to client leader if there is no transient parent, else modal dialogs can
+             // be hidden by their parents.
+             if (!transientXcbParent)
+@@ -746,10 +738,6 @@ void QXcbWindow::show()
+ 
+ void QXcbWindow::hide()
+ {
+-    if (shouldDeferTask(Task::Unmap))
+-        return;
+-
+-    m_wmStateValid = false;
+     xcb_unmap_window(xcb_connection(), m_window);
+ 
+     // send synthetic UnmapNotify event according to icccm 4.1.4
+@@ -909,9 +897,6 @@ QXcbWindow::NetWmStates QXcbWindow::netWmStates()
+ 
+ void QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
+ {
+-    if (shouldDeferTask(Task::SetWindowFlags))
+-        return;
+-
+     Qt::WindowType type = static_cast<Qt::WindowType>(int(flags & Qt::WindowType_Mask));
+ 
+     if (type == Qt::ToolTip)
+@@ -941,8 +926,6 @@ void QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
+ 
+     setTransparentForMouseEvents(flags & Qt::WindowTransparentForInput);
+     updateDoesNotAcceptFocus(flags & Qt::WindowDoesNotAcceptFocus);
+-
+-    m_isWmManagedWindow = !(flags & Qt::X11BypassWindowManagerHint);
+ }
+ 
+ void QXcbWindow::setMotifWmHints(Qt::WindowFlags flags)
+@@ -1142,9 +1125,6 @@ void QXcbWindow::setWindowState(Qt::WindowStates state)
+     if (state == m_windowState)
+         return;
+ 
+-    if (shouldDeferTask(Task::SetWindowState))
+-        return;
+-
+     // unset old state
+     if (m_windowState & Qt::WindowMinimized)
+         xcb_map_window(xcb_connection(), m_window);
+@@ -1350,6 +1330,12 @@ void QXcbWindow::setWindowIcon(const QIcon &icon)
+     }
+ 
+     if (!icon_data.isEmpty()) {
++        // Ignore icon exceeding maximum xcb request length
++        if (icon_data.size() > xcb_get_maximum_request_length(xcb_connection())) {
++            qWarning("Ignoring window icon: Size %llu exceeds maximum xcb request length %u.",
++                     icon_data.size(), xcb_get_maximum_request_length(xcb_connection()));
++            return;
++        }
+         xcb_change_property(xcb_connection(),
+                             XCB_PROP_MODE_REPLACE,
+                             m_window,
+@@ -1639,7 +1625,7 @@ void QXcbWindow::setWmWindowType(QXcbWindowFunctions::WmWindowTypes types, Qt::W
+         break;
+     }
+ 
+-    if ((flags & Qt::FramelessWindowHint) && !(type & QXcbWindowFunctions::KdeOverride)) {
++    if ((flags & Qt::FramelessWindowHint) && !(types & QXcbWindowFunctions::KdeOverride)) {
+         // override netwm type - quick and easy for KDE noborder
+         atoms.append(atom(QXcbAtom::_KDE_NET_WM_WINDOW_TYPE_OVERRIDE));
+     }
+@@ -1894,10 +1880,6 @@ void QXcbWindow::handleUnmapNotifyEvent(const xcb_unmap_notify_event_t *event)
+     if (event->window == m_window) {
+         m_mapped = false;
+         QWindowSystemInterface::handleExposeEvent(window(), QRegion());
+-        if (!m_isWmManagedWindow || parent()) {
+-            m_wmStateValid = true;
+-            handleDeferredTasks();
+-        }
+     }
+ }
+ 
+@@ -2212,98 +2194,30 @@ void QXcbWindow::handleLeaveNotifyEvent(const xcb_leave_notify_event_t *event)
+     handleLeaveNotifyEvent(event->root_x, event->root_y, event->mode, event->detail, event->time);
+ }
+ 
+-bool QXcbWindow::shouldDeferTask(Task task)
+-{
+-    if (m_wmStateValid)
+-        return false;
+-
+-    m_deferredTasks.append(task);
+-    return true;
+-}
+-
+-void QXcbWindow::handleDeferredTasks()
+-{
+-    Q_ASSERT(m_wmStateValid == true);
+-    if (m_deferredTasks.isEmpty())
+-        return;
+-
+-    bool map = false;
+-    bool unmap = false;
+-
+-    QVector<Task> tasks;
+-    for (auto taskIt = m_deferredTasks.rbegin(); taskIt != m_deferredTasks.rend(); ++taskIt) {
+-        if (!tasks.contains(*taskIt))
+-            tasks.prepend(*taskIt);
+-    }
+-
+-    for (Task task : tasks) {
+-        switch (task) {
+-        case Task::Map:
+-            map = true;
+-            unmap = false;
+-            break;
+-        case Task::Unmap:
+-            unmap = true;
+-            map = false;
+-            break;
+-        case Task::SetGeometry:
+-            setGeometry(m_deferredGeometry);
+-            break;
+-        case Task::SetWindowFlags:
+-            setWindowFlags(window()->flags());
+-            break;
+-        case Task::SetWindowState:
+-            setWindowState(window()->windowState());
+-            break;
+-        }
+-    }
+-    m_deferredTasks.clear();
+-
+-    if (map) {
+-        Q_ASSERT(unmap == false);
+-        show();
+-    }
+-    if (unmap) {
+-        Q_ASSERT(map == false);
+-        hide();
+-    }
+-}
+-
+ void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *event)
+ {
+     connection()->setTime(event->time);
+ 
+-    const bool wmStateChanged = event->atom == atom(QXcbAtom::WM_STATE);
+-    const bool netWmStateChanged = event->atom == atom(QXcbAtom::_NET_WM_STATE);
+-    if (netWmStateChanged || wmStateChanged) {
+-        if (wmStateChanged && !m_wmStateValid && m_isWmManagedWindow) {
+-            // ICCCM 4.1.4
+-            // Clients that want to re-use a client window (e.g. by mapping it again)
+-            // after withdrawing it must wait for the withdrawal to be complete before
+-            // proceeding. The preferred method for doing this is for clients to wait for
+-            // a window manager to update or remove the WM_STATE property.
+-            m_wmStateValid = true;
+-            handleDeferredTasks();
+-        }
+-        if (event->state == XCB_PROPERTY_DELETE)
++    const bool propertyDeleted = event->state == XCB_PROPERTY_DELETE;
++
++    if (event->atom == atom(QXcbAtom::_NET_WM_STATE) || event->atom == atom(QXcbAtom::WM_STATE)) {
++        if (propertyDeleted)
+             return;
+ 
+-        if (wmStateChanged) {
++        Qt::WindowStates newState = Qt::WindowNoState;
++
++        if (event->atom == atom(QXcbAtom::WM_STATE)) { // WM_STATE: Quick check for 'Minimize'.
+             auto reply = Q_XCB_REPLY(xcb_get_property, xcb_connection(),
+                                      0, m_window, atom(QXcbAtom::WM_STATE),
+                                      XCB_ATOM_ANY, 0, 1024);
+             if (reply && reply->format == 32 && reply->type == atom(QXcbAtom::WM_STATE)) {
+-                auto data = static_cast<const quint32 *>(xcb_get_property_value(reply.get()));
+-                if (reply->length != 0) {
+-                    const bool changedToWithdrawn = data[0] == XCB_ICCCM_WM_STATE_WITHDRAWN;
+-                    const bool changedToIconic = data[0] == XCB_ICCCM_WM_STATE_ICONIC;
+-                    m_minimized = changedToIconic || (changedToWithdrawn && m_minimized);
+-                }
++                const quint32 *data = (const quint32 *)xcb_get_property_value(reply.get());
++                if (reply->length != 0)
++                    m_minimized = (data[0] == XCB_ICCCM_WM_STATE_ICONIC
++                                   || (data[0] == XCB_ICCCM_WM_STATE_WITHDRAWN && m_minimized));
+             }
+         }
+ 
+-        // _NET_WM_STATE handling
+-        Qt::WindowStates newState = Qt::WindowNoState;
+         const NetWmStates states = netWmStates();
+         // _NET_WM_STATE_HIDDEN should be set by the Window Manager to indicate that a window would
+         // not be visible on the screen if its desktop/viewport were active and its coordinates were
+@@ -2325,6 +2239,7 @@ void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *ev
+             if ((m_windowState & Qt::WindowMinimized) && connection()->mouseGrabber() == this)
+                 connection()->setMouseGrabber(nullptr);
+         }
++        return;
+     } else if (event->atom == atom(QXcbAtom::_NET_FRAME_EXTENTS)) {
+         m_dirtyFrameMargins = true;
+     }
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbwindow.h b/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
+index 55af9279b1..6f5c1f5ed9 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
++++ b/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
+@@ -74,14 +74,6 @@ public:
+ 
+     Q_DECLARE_FLAGS(NetWmStates, NetWmState)
+ 
+-    enum Task {
+-        Map,
+-        Unmap,
+-        SetGeometry,
+-        SetWindowFlags,
+-        SetWindowState
+-    };
+-
+     QXcbWindow(QWindow *window);
+     ~QXcbWindow();
+ 
+@@ -151,9 +143,6 @@ public:
+ 
+     QXcbWindow *toWindow() override;
+ 
+-    bool shouldDeferTask(Task task);
+-    void handleDeferredTasks();
+-
+     void handleMouseEvent(xcb_timestamp_t time, const QPoint &local, const QPoint &global,
+                           Qt::KeyboardModifiers modifiers, QEvent::Type type, Qt::MouseEventSource source);
+ 
+@@ -292,11 +281,6 @@ protected:
+     int m_swapInterval = -1;
+ 
+     qreal m_sizeHintsScaleFactor = 1.0;
+-
+-    bool m_wmStateValid = true;
+-    QVector<Task> m_deferredTasks;
+-    bool m_isWmManagedWindow = true;
+-    QRect m_deferredGeometry;
+ };
+ 
+ class QXcbForeignWindow : public QXcbWindow
+diff --git a/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp b/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
+index d9d117faeb..640b49daa0 100644
+--- a/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
++++ b/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
+@@ -85,6 +85,7 @@ QGtk3MenuItem::QGtk3MenuItem()
+       m_checkable(false),
+       m_checked(false),
+       m_enabled(true),
++      m_exclusive(false),
+       m_underline(false),
+       m_invalid(true),
+       m_menu(nullptr),
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
+index 0048bbc1e6..396e7f6d1c 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
+@@ -102,15 +102,12 @@ const QDBusArgument &operator >>(const QDBusArgument &arg, QXdgDesktopPortalFile
+ class QXdgDesktopPortalFileDialogPrivate
+ {
+ public:
+-    QXdgDesktopPortalFileDialogPrivate(QPlatformFileDialogHelper *nativeFileDialog)
++    QXdgDesktopPortalFileDialogPrivate(QPlatformFileDialogHelper *nativeFileDialog, uint fileChooserPortalVersion)
+         : nativeFileDialog(nativeFileDialog)
++        , fileChooserPortalVersion(fileChooserPortalVersion)
+     { }
+ 
+-    WId winId = 0;
+-    bool directoryMode = false;
+-    bool modal = false;
+-    bool multipleFiles = false;
+-    bool saveFile = false;
++    QEventLoop loop;
+     QString acceptLabel;
+     QString directory;
+     QString title;
+@@ -121,19 +118,27 @@ public:
+     QString selectedMimeTypeFilter;
+     QString selectedNameFilter;
+     QStringList selectedFiles;
+-    QPlatformFileDialogHelper *nativeFileDialog = nullptr;
++    std::unique_ptr<QPlatformFileDialogHelper> nativeFileDialog;
++    uint fileChooserPortalVersion = 0;
++    bool failedToOpen = false;
++    bool directoryMode = false;
++    bool multipleFiles = false;
++    bool saveFile = false;
+ };
+ 
+-QXdgDesktopPortalFileDialog::QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog)
++QXdgDesktopPortalFileDialog::QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog, uint fileChooserPortalVersion)
+     : QPlatformFileDialogHelper()
+-    , d_ptr(new QXdgDesktopPortalFileDialogPrivate(nativeFileDialog))
++    , d_ptr(new QXdgDesktopPortalFileDialogPrivate(nativeFileDialog, fileChooserPortalVersion))
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+     if (d->nativeFileDialog) {
+-        connect(d->nativeFileDialog, SIGNAL(accept()), this, SIGNAL(accept()));
+-        connect(d->nativeFileDialog, SIGNAL(reject()), this, SIGNAL(reject()));
++        connect(d->nativeFileDialog.get(), SIGNAL(accept()), this, SIGNAL(accept()));
++        connect(d->nativeFileDialog.get(), SIGNAL(reject()), this, SIGNAL(reject()));
+     }
++
++    d->loop.connect(this, SIGNAL(accept()), SLOT(quit()));
++    d->loop.connect(this, SIGNAL(reject()), SLOT(quit()));
+ }
+ 
+ QXdgDesktopPortalFileDialog::~QXdgDesktopPortalFileDialog()
+@@ -177,7 +182,7 @@ void QXdgDesktopPortalFileDialog::initializeDialog()
+     setDirectory(options()->initialDirectory());
+ }
+ 
+-void QXdgDesktopPortalFileDialog::openPortal()
++void QXdgDesktopPortalFileDialog::openPortal(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent)
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+@@ -185,13 +190,13 @@ void QXdgDesktopPortalFileDialog::openPortal()
+                                                           QLatin1String("/org/freedesktop/portal/desktop"),
+                                                           QLatin1String("org.freedesktop.portal.FileChooser"),
+                                                           d->saveFile ? QLatin1String("SaveFile") : QLatin1String("OpenFile"));
+-    QString parentWindowId = QLatin1String("x11:") + QString::number(d->winId, 16);
++    QString parentWindowId = QLatin1String("x11:") + QString::number(parent ? parent->winId() : 0, 16);
+ 
+     QVariantMap options;
+     if (!d->acceptLabel.isEmpty())
+         options.insert(QLatin1String("accept_label"), d->acceptLabel);
+ 
+-    options.insert(QLatin1String("modal"), d->modal);
++    options.insert(QLatin1String("modal"), windowModality != Qt::NonModal);
+     options.insert(QLatin1String("multiple"), d->multipleFiles);
+     options.insert(QLatin1String("directory"), d->directoryMode);
+ 
+@@ -290,10 +295,18 @@ void QXdgDesktopPortalFileDialog::openPortal()
+ 
+     QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
+     QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingCall);
+-    connect(watcher, &QDBusPendingCallWatcher::finished, this, [this] (QDBusPendingCallWatcher *watcher) {
++    connect(watcher, &QDBusPendingCallWatcher::finished, this, [=] (QDBusPendingCallWatcher *watcher) {
+         QDBusPendingReply<QDBusObjectPath> reply = *watcher;
+-        if (reply.isError()) {
+-            Q_EMIT reject();
++        // Any error means the dialog is not shown and we need to fallback
++        d->failedToOpen = reply.isError();
++        if (d->failedToOpen) {
++            if (d->nativeFileDialog) {
++                d->nativeFileDialog->show(windowFlags, windowModality, parent);
++                if (d->loop.isRunning())
++                    d->nativeFileDialog->exec();
++            } else {
++                Q_EMIT reject();
++            }
+         } else {
+             QDBusConnection::sessionBus().connect(nullptr,
+                                                   reply.value().path(),
+@@ -302,6 +315,7 @@ void QXdgDesktopPortalFileDialog::openPortal()
+                                                   this,
+                                                   SLOT(gotResponse(uint,QVariantMap)));
+         }
++        watcher->deleteLater();
+     });
+ }
+ 
+@@ -326,7 +340,7 @@ QUrl QXdgDesktopPortalFileDialog::directory() const
+ {
+     Q_D(const QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog())
+         return d->nativeFileDialog->directory();
+ 
+     return d->directory;
+@@ -348,7 +362,7 @@ QList<QUrl> QXdgDesktopPortalFileDialog::selectedFiles() const
+ {
+     Q_D(const QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog())
+         return d->nativeFileDialog->selectedFiles();
+ 
+     QList<QUrl> files;
+@@ -403,16 +417,13 @@ void QXdgDesktopPortalFileDialog::exec()
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly)) {
++    if (d->nativeFileDialog && useNativeFileDialog()) {
+         d->nativeFileDialog->exec();
+         return;
+     }
+ 
+     // HACK we have to avoid returning until we emit that the dialog was accepted or rejected
+-    QEventLoop loop;
+-    loop.connect(this, SIGNAL(accept()), SLOT(quit()));
+-    loop.connect(this, SIGNAL(reject()), SLOT(quit()));
+-    loop.exec();
++    d->loop.exec();
+ }
+ 
+ void QXdgDesktopPortalFileDialog::hide()
+@@ -429,13 +440,10 @@ bool QXdgDesktopPortalFileDialog::show(Qt::WindowFlags windowFlags, Qt::WindowMo
+ 
+     initializeDialog();
+ 
+-    d->modal = windowModality != Qt::NonModal;
+-    d->winId = parent ? parent->winId() : 0;
+-
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog(OpenFallback))
+         return d->nativeFileDialog->show(windowFlags, windowModality, parent);
+ 
+-    openPortal();
++    openPortal(windowFlags, windowModality, parent);
+ 
+     return true;
+ }
+@@ -465,4 +473,21 @@ void QXdgDesktopPortalFileDialog::gotResponse(uint response, const QVariantMap &
+     }
+ }
+ 
++bool QXdgDesktopPortalFileDialog::useNativeFileDialog(QXdgDesktopPortalFileDialog::FallbackType fallbackType) const
++{
++    Q_D(const QXdgDesktopPortalFileDialog);
++
++    if (d->failedToOpen && fallbackType != OpenFallback)
++        return true;
++
++    if (d->fileChooserPortalVersion < 3) {
++        if (options()->fileMode() == QFileDialogOptions::Directory)
++            return true;
++        else if (options()->fileMode() == QFileDialogOptions::DirectoryOnly)
++            return true;
++    }
++
++    return false;
++}
++
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
+index 4f4de96ecf..65e22a5cf2 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
+@@ -51,6 +51,11 @@ class QXdgDesktopPortalFileDialog : public QPlatformFileDialogHelper
+     Q_OBJECT
+     Q_DECLARE_PRIVATE(QXdgDesktopPortalFileDialog)
+ public:
++    enum FallbackType {
++        GenericFallback,
++        OpenFallback
++    };
++
+     enum ConditionType : uint {
+         GlobalPattern = 0,
+         MimeType = 1
+@@ -69,7 +74,7 @@ public:
+     };
+     typedef QVector<Filter> FilterList;
+ 
+-    QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog = nullptr);
++    QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog = nullptr, uint fileChooserPortalVersion = 0);
+     ~QXdgDesktopPortalFileDialog();
+ 
+     bool defaultNameFilterDisables() const override;
+@@ -92,7 +97,8 @@ private Q_SLOTS:
+ 
+ private:
+     void initializeDialog();
+-    void openPortal();
++    void openPortal(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent);
++    bool useNativeFileDialog(FallbackType fallbackType = GenericFallback) const;
+ 
+     QScopedPointer<QXdgDesktopPortalFileDialogPrivate> d_ptr;
+ };
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
+index fb324afbd8..b809503122 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
+@@ -111,6 +111,7 @@ QXdgDesktopPortalTheme::QXdgDesktopPortalTheme()
+         if (reply.isValid()) {
+             d->fileChooserPortalVersion = reply.value().toUInt();
+         }
++        watcher->deleteLater();
+     });
+ }
+ 
+@@ -152,11 +153,12 @@ QPlatformDialogHelper* QXdgDesktopPortalTheme::createPlatformDialogHelper(Dialog
+ {
+     Q_D(const QXdgDesktopPortalTheme);
+ 
+-    if (type == FileDialog) {
++    if (type == FileDialog && d->fileChooserPortalVersion) {
+         // Older versions of FileChooser portal don't support opening directories, therefore we fallback
+         // to native file dialog opened inside the sandbox to open a directory.
+-        if (d->fileChooserPortalVersion < 3 && d->baseTheme->usePlatformNativeDialog(type))
+-            return new QXdgDesktopPortalFileDialog(static_cast<QPlatformFileDialogHelper*>(d->baseTheme->createPlatformDialogHelper(type)));
++        if (d->baseTheme->usePlatformNativeDialog(type))
++            return new QXdgDesktopPortalFileDialog(static_cast<QPlatformFileDialogHelper*>(d->baseTheme->createPlatformDialogHelper(type)),
++                                                   d->fileChooserPortalVersion);
+ 
+         return new QXdgDesktopPortalFileDialog;
+     }
+diff --git a/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp b/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
+index 43d5e119ad..1f9cbc4565 100644
+--- a/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
++++ b/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
+@@ -89,8 +89,10 @@ void QCupsPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &v
+         break;
+     case PPK_Duplex: {
+         QPrint::DuplexMode mode = QPrint::DuplexMode(value.toInt());
+-        if (mode != d->duplex && d->m_printDevice.supportedDuplexModes().contains(mode))
++        if (d->m_printDevice.supportedDuplexModes().contains(mode)) {
+             d->duplex = mode;
++            d->duplexRequestedExplicitly = true;
++        }
+         break;
+     }
+     case PPK_PrinterName:
+@@ -277,9 +279,12 @@ void QCupsPrintEnginePrivate::changePrinter(const QString &newPrinter)
+     m_printDevice.swap(printDevice);
+     printerName = m_printDevice.id();
+ 
+-    // Check if new printer supports current settings, otherwise us defaults
+-    if (duplex != QPrint::DuplexAuto && !m_printDevice.supportedDuplexModes().contains(duplex))
++    // in case a duplex value was explicitly set, check if new printer supports current value,
++    // otherwise use device default
++    if (!duplexRequestedExplicitly || !m_printDevice.supportedDuplexModes().contains(duplex)) {
+         duplex = m_printDevice.defaultDuplexMode();
++        duplexRequestedExplicitly = false;
++    }
+     QPrint::ColorMode colorMode = grayscale ? QPrint::GrayScale : QPrint::Color;
+     if (!m_printDevice.supportedColorModes().contains(colorMode))
+         grayscale = m_printDevice.defaultColorMode() == QPrint::GrayScale;
+diff --git a/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h b/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
+index c021b0c643..8f81fe478d 100644
+--- a/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
++++ b/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
+@@ -100,6 +100,7 @@ private:
+     QStringList cupsOptions;
+     QString cupsTempFile;
+     QPrint::DuplexMode duplex;
++    bool duplexRequestedExplicitly = false;
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp b/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
+index 67e7154fa6..40876152e5 100644
+--- a/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
++++ b/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
+@@ -817,7 +817,7 @@ bool QIBaseResultPrivate::writeArray(int column, const QList<QVariant> &list)
+     ba.resize(int(bufLen));
+ 
+     if (list.size() > arraySize) {
+-        error = QLatin1String("Array size missmatch: size of %1 is %2, size of provided list is %3");
++        error = QLatin1String("Array size mismatch: size of %1 is %2, size of provided list is %3");
+         error = error.arg(QLatin1String(sqlname)).arg(arraySize).arg(list.size());
+         q->setLastError(QSqlError(error, QLatin1String(""), QSqlError::StatementError));
+         return false;
+diff --git a/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp b/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
+index 7ca055eea2..6bc9d46755 100644
+--- a/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
++++ b/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
+@@ -223,7 +223,7 @@ public:
+     struct QMyField
+     {
+         char *outField = nullptr;
+-        MYSQL_FIELD *myField = nullptr;
++        const MYSQL_FIELD *myField = nullptr;
+         QMetaType::Type type = QMetaType::UnknownType;
+         my_bool nullIndicator = false;
+         ulong bufLength = 0ul;
+@@ -361,7 +361,7 @@ static bool qIsInteger(int t)
+ void QMYSQLResultPrivate::bindBlobs()
+ {
+     int i;
+-    MYSQL_FIELD *fieldInfo;
++    const MYSQL_FIELD *fieldInfo;
+     MYSQL_BIND *bind;
+ 
+     for(i = 0; i < fields.count(); ++i) {
+@@ -379,7 +379,6 @@ void QMYSQLResultPrivate::bindBlobs()
+ bool QMYSQLResultPrivate::bindInValues()
+ {
+     MYSQL_BIND *bind;
+-    char *field;
+     int i = 0;
+ 
+     if (!meta)
+@@ -392,35 +391,34 @@ bool QMYSQLResultPrivate::bindInValues()
+     inBinds = new MYSQL_BIND[fields.size()];
+     memset(inBinds, 0, fields.size() * sizeof(MYSQL_BIND));
+ 
+-    MYSQL_FIELD *fieldInfo;
++    const MYSQL_FIELD *fieldInfo;
+ 
+     while((fieldInfo = mysql_fetch_field(meta))) {
++        bind = &inBinds[i];
++
+         QMyField &f = fields[i];
+         f.myField = fieldInfo;
+-
++        bind->buffer_length = f.bufLength = fieldInfo->length + 1;
++        bind->buffer_type = fieldInfo->type;
+         f.type = qDecodeMYSQLType(fieldInfo->type, fieldInfo->flags);
+         if (qIsBlob(fieldInfo->type)) {
+             // the size of a blob-field is available as soon as we call
+             // mysql_stmt_store_result()
+             // after mysql_stmt_exec() in QMYSQLResult::exec()
+-            fieldInfo->length = 0;
++            bind->buffer_length = f.bufLength = 0;
+             hasBlobs = true;
+         } else if (qIsInteger(f.type)) {
+-            fieldInfo->length = 8;
++            bind->buffer_length = f.bufLength = 8;
+         } else {
+-            fieldInfo->type = MYSQL_TYPE_STRING;
++            bind->buffer_type = MYSQL_TYPE_STRING;
+         }
+-        bind = &inBinds[i];
+-        field = new char[fieldInfo->length + 1];
+-        memset(field, 0, fieldInfo->length + 1);
+ 
+-        bind->buffer_type = fieldInfo->type;
+-        bind->buffer = field;
+-        bind->buffer_length = f.bufLength = fieldInfo->length + 1;
+         bind->is_null = &f.nullIndicator;
+         bind->length = &f.bufLength;
+         bind->is_unsigned = fieldInfo->flags & UNSIGNED_FLAG ? 1 : 0;
+-        f.outField=field;
++
++        char *field = new char[bind->buffer_length + 1]{};
++        bind->buffer = f.outField = field;
+ 
+         ++i;
+     }
+@@ -1369,20 +1367,20 @@ bool QMYSQLDriver::open(const QString& db,
+     }
+ 
+ #if MYSQL_VERSION_ID >= 50007
+-    if (mysql_get_client_version() >= 50503 && mysql_get_server_version(d->mysql) >= 50503) {
+-        // force the communication to be utf8mb4 (only utf8mb4 supports 4-byte characters)
+-        mysql_set_character_set(d->mysql, "utf8mb4");
++    // force the communication to be utf8mb4 (only utf8mb4 supports 4-byte characters)
++    if (mysql_set_character_set(d->mysql, "utf8mb4")) {
++        // this failed, try forcing it to utf (BMP only)
++        if (mysql_set_character_set(d->mysql, "utf8"))
++            qWarning() << "MySQL: Unable to set the client character set to utf8.";
+ #if QT_CONFIG(textcodec)
+-        d->tc = QTextCodec::codecForName("UTF-8");
++        else
++            d->tc = codec(d->mysql);
+ #endif
+-    } else
+-    {
+-        // force the communication to be utf8
+-        mysql_set_character_set(d->mysql, "utf8");
++    }
+ #if QT_CONFIG(textcodec)
+-        d->tc = codec(d->mysql);
++    else
++        d->tc = QTextCodec::codecForName("UTF-8");
+ #endif
+-    }
+ #endif  // MYSQL_VERSION_ID >= 50007
+ 
+     d->preparedQuerysEnabled = checkPreparedQueries(d->mysql);
+diff --git a/qtbase/src/printsupport/dialogs/images/print-24.png b/qtbase/src/printsupport/dialogs/images/printer-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/print-24.png
+rename to src/printsupport/dialogs/images/printer-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/print-32.png b/qtbase/src/printsupport/dialogs/images/printer-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/print-32.png
+rename to src/printsupport/dialogs/images/printer-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-sided-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-facing-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-sided-24.png
+rename to src/printsupport/dialogs/images/view-pages-facing-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-sided-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-facing-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-sided-32.png
+rename to src/printsupport/dialogs/images/view-pages-facing-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-multi-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-overview-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-multi-24.png
+rename to src/printsupport/dialogs/images/view-pages-overview-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-multi-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-overview-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-multi-32.png
+rename to src/printsupport/dialogs/images/view-pages-overview-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-one-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-single-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-one-24.png
+rename to src/printsupport/dialogs/images/view-pages-single-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-one-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-single-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-one-32.png
+rename to src/printsupport/dialogs/images/view-pages-single-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-page-24.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-page-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-page-24.png
+rename to src/printsupport/dialogs/images/zoom-fit-page-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-page-32.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-page-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-page-32.png
+rename to src/printsupport/dialogs/images/zoom-fit-page-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-width-24.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-width-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-width-24.png
+rename to src/printsupport/dialogs/images/zoom-fit-width-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-width-32.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-width-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-width-32.png
+rename to src/printsupport/dialogs/images/zoom-fit-width-32.png
+diff --git a/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp b/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
+index 78e5b8d1ef..2a28516719 100644
+--- a/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
++++ b/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
+@@ -532,6 +532,7 @@ void QPageSetupWidget::updateWidget()
+ void QPageSetupWidget::setupPrinter() const
+ {
+     m_printer->setPageLayout(m_pageLayout);
++    m_printer->setPageOrientation(m_pageLayout.orientation());
+ #if QT_CONFIG(cups)
+     QCUPSSupport::PagesPerSheet pagesPerSheet = qvariant_cast<QCUPSSupport::PagesPerSheet>(m_ui.pagesPerSheetCombo->currentData()
+ );
+diff --git a/qtbase/src/printsupport/dialogs/qprintdialog.qrc b/qtbase/src/printsupport/dialogs/qprintdialog.qrc
+index 5a579baa55..10b8e1d341 100644
+--- a/qtbase/src/printsupport/dialogs/qprintdialog.qrc
++++ b/qtbase/src/printsupport/dialogs/qprintdialog.qrc
+@@ -1,9 +1,9 @@
+ <!DOCTYPE RCC><RCC version="1.0">
+ <qresource prefix="/qt-project.org/dialogs/qprintpreviewdialog">
+-<file>images/fit-page-24.png</file>
+-<file>images/fit-page-32.png</file>
+-<file>images/fit-width-24.png</file>
+-<file>images/fit-width-32.png</file>
++<file>images/zoom-fit-page-24.png</file>
++<file>images/zoom-fit-page-32.png</file>
++<file>images/zoom-fit-width-24.png</file>
++<file>images/zoom-fit-width-32.png</file>
+ <file>images/go-first-24.png</file>
+ <file>images/go-first-32.png</file>
+ <file>images/go-last-24.png</file>
+@@ -18,14 +18,14 @@
+ <file>images/layout-portrait-32.png</file>
+ <file>images/page-setup-24.png</file>
+ <file>images/page-setup-32.png</file>
+-<file>images/print-24.png</file>
+-<file>images/print-32.png</file>
+-<file>images/view-page-multi-24.png</file>
+-<file>images/view-page-multi-32.png</file>
+-<file>images/view-page-one-24.png</file>
+-<file>images/view-page-one-32.png</file>
+-<file>images/view-page-sided-24.png</file>
+-<file>images/view-page-sided-32.png</file>
++<file>images/printer-24.png</file>
++<file>images/printer-32.png</file>
++<file>images/view-pages-overview-24.png</file>
++<file>images/view-pages-overview-32.png</file>
++<file>images/view-pages-single-24.png</file>
++<file>images/view-pages-single-32.png</file>
++<file>images/view-pages-facing-24.png</file>
++<file>images/view-pages-facing-32.png</file>
+ <file>images/zoom-in-24.png</file>
+ <file>images/zoom-in-32.png</file>
+ <file>images/zoom-out-24.png</file>
+diff --git a/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp b/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
+index c5b845f4ec..5a5ba1d0a8 100644
+--- a/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
++++ b/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
+@@ -702,13 +702,14 @@ void QPrintDialogPrivate::selectPrinter(const QPrinter::OutputFormat outputForma
+         else
+             options.grayscale->setChecked(true);
+ 
+-        // keep duplex value explicitly set by user, if any, and selected printer supports it;
+-        // use device default otherwise
++        // duplex priorities to be as follows:
++        // 1) a user-selected duplex value in the dialog has highest prority
++        // 2) duplex value set in the QPrinter
+         QPrint::DuplexMode duplex;
+         if (explicitDuplexMode != QPrint::DuplexAuto && supportedDuplexMode.contains(explicitDuplexMode))
+             duplex = explicitDuplexMode;
+         else
+-            duplex = top->d->m_currentPrintDevice.defaultDuplexMode();
++            duplex = static_cast<QPrint::DuplexMode>(p->duplex());
+         switch (duplex) {
+         case QPrint::DuplexNone:
+             options.noDuplex->setChecked(true); break;
+@@ -1242,10 +1243,10 @@ void QUnixPrintWidgetPrivate::_q_printerChanged(int index)
+             QString filename = widget.filename->text();
+             widget.filename->setText(filename);
+             widget.lOutput->setEnabled(true);
+-            if (optionsPane)
+-                optionsPane->selectPrinter(QPrinter::PdfFormat);
+             printer->setOutputFormat(QPrinter::PdfFormat);
+             m_currentPrintDevice = QPrintDevice();
++            if (optionsPane)
++                optionsPane->selectPrinter(QPrinter::PdfFormat);
+             return;
+         }
+     }
+diff --git a/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp b/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
+index 39575d5f57..23b7e89538 100644
+--- a/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
++++ b/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
+@@ -352,7 +352,7 @@ void QPrintPreviewDialogPrivate::init(QPrinter *_printer)
+ static inline void qt_setupActionIcon(QAction *action, QLatin1String name)
+ {
+     QLatin1String imagePrefix(":/qt-project.org/dialogs/qprintpreviewdialog/images/");
+-    QIcon icon;
++    QIcon icon = QIcon::fromTheme(name);
+     icon.addFile(imagePrefix + name + QLatin1String("-24.png"), QSize(24, 24));
+     icon.addFile(imagePrefix + name + QLatin1String("-32.png"), QSize(32, 32));
+     action->setIcon(icon);
+@@ -383,8 +383,8 @@ void QPrintPreviewDialogPrivate::setupActions()
+     fitPageAction->setObjectName(QLatin1String("fitPageAction"));
+     fitWidthAction->setCheckable(true);
+     fitPageAction->setCheckable(true);
+-    qt_setupActionIcon(fitWidthAction, QLatin1String("fit-width"));
+-    qt_setupActionIcon(fitPageAction, QLatin1String("fit-page"));
++    qt_setupActionIcon(fitWidthAction, QLatin1String("zoom-fit-width"));
++    qt_setupActionIcon(fitPageAction, QLatin1String("zoom-fit-page"));
+     QObject::connect(fitGroup, SIGNAL(triggered(QAction*)), q, SLOT(_q_fit(QAction*)));
+ 
+     // Zoom
+@@ -410,9 +410,9 @@ void QPrintPreviewDialogPrivate::setupActions()
+     singleModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show single page"));
+     facingModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show facing pages"));
+     overviewModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show overview of all pages"));
+-    qt_setupActionIcon(singleModeAction, QLatin1String("view-page-one"));
+-    qt_setupActionIcon(facingModeAction, QLatin1String("view-page-sided"));
+-    qt_setupActionIcon(overviewModeAction, QLatin1String("view-page-multi"));
++    qt_setupActionIcon(singleModeAction, QLatin1String("view-pages-single"));
++    qt_setupActionIcon(facingModeAction, QLatin1String("view-pages-facing"));
++    qt_setupActionIcon(overviewModeAction, QLatin1String("view-pages-overview"));
+     singleModeAction->setObjectName(QLatin1String("singleModeAction"));
+     facingModeAction->setObjectName(QLatin1String("facingModeAction"));
+     overviewModeAction->setObjectName(QLatin1String("overviewModeAction"));
+@@ -426,7 +426,7 @@ void QPrintPreviewDialogPrivate::setupActions()
+     printerGroup = new QActionGroup(q);
+     printAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Print"));
+     pageSetupAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Page setup"));
+-    qt_setupActionIcon(printAction, QLatin1String("print"));
++    qt_setupActionIcon(printAction, QLatin1String("printer"));
+     qt_setupActionIcon(pageSetupAction, QLatin1String("page-setup"));
+     QObject::connect(printAction, SIGNAL(triggered(bool)), q, SLOT(_q_print()));
+     QObject::connect(pageSetupAction, SIGNAL(triggered(bool)), q, SLOT(_q_pageSetup()));
+diff --git a/qtbase/src/sql/kernel/qsqlquery.cpp b/qtbase/src/sql/kernel/qsqlquery.cpp
+index 32c6166c79..60afef10c3 100644
+--- a/qtbase/src/sql/kernel/qsqlquery.cpp
++++ b/qtbase/src/sql/kernel/qsqlquery.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2022 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtSql module of the Qt Toolkit.
+@@ -377,6 +377,10 @@ bool QSqlQuery::exec(const QString& query)
+     QElapsedTimer t;
+     t.start();
+ #endif
++    if (!driver()) {
++        qWarning("QSqlQuery::exec: called before driver has been set up");
++        return false;
++    }
+     if (d->ref.loadRelaxed() != 1) {
+         bool fo = isForwardOnly();
+         *this = QSqlQuery(driver()->createResult());
+diff --git a/qtbase/src/testlib/qabstractitemmodeltester.cpp b/qtbase/src/testlib/qabstractitemmodeltester.cpp
+index 8efb9c53d4..ce062f66d7 100644
+--- a/qtbase/src/testlib/qabstractitemmodeltester.cpp
++++ b/qtbase/src/testlib/qabstractitemmodeltester.cpp
+@@ -454,7 +454,7 @@ void QAbstractItemModelTesterPrivate::parent()
+ 
+     // Common error test #2, make sure that a second level index has a parent
+     // that is the first level index.
+-    if (model->rowCount(topIndex) > 0) {
++    if (model->rowCount(topIndex) > 0 && model->columnCount(topIndex) > 0) {
+         QModelIndex childIndex = model->index(0, 0, topIndex);
+         MODELTESTER_VERIFY(childIndex.isValid());
+         MODELTESTER_COMPARE(model->parent(childIndex), topIndex);
+diff --git a/qtbase/src/testlib/qasciikey.cpp b/qtbase/src/testlib/qasciikey.cpp
+index 9a308da2bc..93498b256f 100644
+--- a/qtbase/src/testlib/qasciikey.cpp
++++ b/qtbase/src/testlib/qasciikey.cpp
+@@ -498,6 +498,11 @@ char QTest::keyToAscii(Qt::Key key)
+     case Qt::Key_LaunchE : return 0; // = 0x10b0,
+     case Qt::Key_LaunchF : return 0; // = 0x10b1,
+ 
++    // Keypad navigation keys
++    case Qt::Key_Select : return 0; // = 0x01010000
++    case Qt::Key_Yes : return 0; // = 0x01010001
++    case Qt::Key_No : return 0; // = 0x01010002
++
+     default: QTEST_ASSERT(false); return 0;
+     }
+ }
+diff --git a/qtbase/src/testlib/qtestresult.cpp b/qtbase/src/testlib/qtestresult.cpp
+index 88028aac6e..2e89930776 100644
+--- a/qtbase/src/testlib/qtestresult.cpp
++++ b/qtbase/src/testlib/qtestresult.cpp
+@@ -251,7 +251,8 @@ bool QTestResult::verify(bool statement, const char *statementStr,
+ {
+     QTEST_ASSERT(statementStr);
+ 
+-    char msg[1024] = {'\0'};
++    char msg[1024];
++    msg[0] = '\0';
+ 
+     if (QTestLog::verboseLevel() >= 2) {
+         qsnprintf(msg, 1024, "QVERIFY(%s)", statementStr);
+@@ -309,7 +310,8 @@ static bool compareHelper(bool success, const char *failureMsg,
+                           bool hasValues = true)
+ {
+     const size_t maxMsgLen = 1024;
+-    char msg[maxMsgLen] = {'\0'};
++    char msg[maxMsgLen];
++    msg[0] = '\0';
+ 
+     QTEST_ASSERT(expected);
+     QTEST_ASSERT(actual);
+diff --git a/qtbase/src/widgets/dialogs/qcolordialog.cpp b/qtbase/src/widgets/dialogs/qcolordialog.cpp
+index 4247731275..cb325be85c 100644
+--- a/qtbase/src/widgets/dialogs/qcolordialog.cpp
++++ b/qtbase/src/widgets/dialogs/qcolordialog.cpp
+@@ -78,7 +78,10 @@
+ #include "qwindow.h"
+ 
+ #include "private/qdialog_p.h"
++#include "private/qguiapplication_p.h"
+ 
++#include <qpa/qplatformservices.h>
++#include <qpa/qplatformintegration.h>
+ #include <algorithm>
+ 
+ QT_BEGIN_NAMESPACE
+@@ -1611,6 +1614,20 @@ void QColorDialogPrivate::_q_newStandard(int r, int c)
+ void QColorDialogPrivate::_q_pickScreenColor()
+ {
+     Q_Q(QColorDialog);
++
++    auto *platformServices = QGuiApplicationPrivate::platformIntegration()->services();
++    if (platformServices->hasCapability(QPlatformServices::Capability::ColorPicking)) {
++        if (auto *colorPicker = platformServices->colorPicker(q->windowHandle())) {
++            q->connect(colorPicker, &QPlatformServiceColorPicker::colorPicked, q,
++                       [q, colorPicker](const QColor &color) {
++                           colorPicker->deleteLater();
++                           q->setCurrentColor(color);
++                       });
++            colorPicker->pickColor();
++            return;
++        }
++    }
++
+     if (!colorPickingEventFilter)
+         colorPickingEventFilter = new QColorPickingEventFilter(this, q);
+     q->installEventFilter(colorPickingEventFilter);
+diff --git a/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp b/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
+index e120817edc..8ea36b5427 100644
+--- a/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
++++ b/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
+@@ -400,12 +400,7 @@ bool QAbstractItemDelegate::helpEvent(QHelpEvent *event,
+         const QString tooltip = index.isValid() ?
+               d->textForRole(Qt::ToolTipRole, index.data(Qt::ToolTipRole), option.locale, precision) :
+               QString();
+-        QRect rect;
+-        if (index.isValid()) {
+-            const QRect r = view->visualRect(index);
+-            rect = QRect(view->mapToGlobal(r.topLeft()), r.size());
+-        }
+-        QToolTip::showText(he->globalPos(), tooltip, view, rect);
++        QToolTip::showText(he->globalPos(), tooltip, view->viewport(), option.rect);
+         event->setAccepted(!tooltip.isEmpty());
+         break;
+         }
+diff --git a/qtbase/src/widgets/itemviews/qlistview.cpp b/qtbase/src/widgets/itemviews/qlistview.cpp
+index 2b34476642..eebfaa030e 100644
+--- a/qtbase/src/widgets/itemviews/qlistview.cpp
++++ b/qtbase/src/widgets/itemviews/qlistview.cpp
+@@ -3386,6 +3386,7 @@ void QIconModeViewBase::updateContentsSize()
+ */
+ void QListView::currentChanged(const QModelIndex &current, const QModelIndex &previous)
+ {
++    QAbstractItemView::currentChanged(current, previous);
+ #ifndef QT_NO_ACCESSIBILITY
+     if (QAccessible::isActive()) {
+         if (current.isValid()) {
+@@ -3396,7 +3397,6 @@ void QListView::currentChanged(const QModelIndex &current, const QModelIndex &pr
+         }
+     }
+ #endif
+-    QAbstractItemView::currentChanged(current, previous);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/widgets/itemviews/qtableview.cpp b/qtbase/src/widgets/itemviews/qtableview.cpp
+index 934ac581b2..f79bb24249 100644
+--- a/qtbase/src/widgets/itemviews/qtableview.cpp
++++ b/qtbase/src/widgets/itemviews/qtableview.cpp
+@@ -1013,6 +1013,7 @@ void QTableViewPrivate::drawCell(QPainter *painter, const QStyleOptionViewItem &
+ int QTableViewPrivate::widthHintForIndex(const QModelIndex &index, int hint, const QStyleOptionViewItem &option) const
+ {
+     Q_Q(const QTableView);
++    const int oldHint = hint;
+     QWidget *editor = editorForIndex(index).widget.data();
+     if (editor && persistent.contains(editor)) {
+         hint = qMax(hint, editor->sizeHint().width());
+@@ -1021,6 +1022,17 @@ int QTableViewPrivate::widthHintForIndex(const QModelIndex &index, int hint, con
+         hint = qBound(min, hint, max);
+     }
+     hint = qMax(hint, q->itemDelegate(index)->sizeHint(option, index).width());
++
++    if (hasSpans()) {
++        auto span = spans.spanAt(index.column(), index.row());
++        if (span && span->m_left == index.column() && span->m_top == index.row()) {
++            // spans are screwed up when sections are moved
++            const auto left = logicalColumn(span->m_left);
++            for (int i = 1; i <= span->width(); ++i)
++               hint -= q->columnWidth(visualColumn(left + i));
++        }
++        hint = std::max(hint, oldHint);
++    }
+     return hint;
+ }
+ 
+@@ -1053,6 +1065,11 @@ int QTableViewPrivate::heightHintForIndex(const QModelIndex &index, int hint, QS
+         option.rect.setHeight(height);
+         option.rect.setX(q->columnViewportPosition(index.column()));
+         option.rect.setWidth(q->columnWidth(index.column()));
++        if (hasSpans()) {
++            auto span = spans.spanAt(index.column(), index.row());
++            if (span && span->m_left == index.column() && span->m_top == index.row())
++                option.rect.setWidth(std::max(option.rect.width(), visualSpanRect(*span).width()));
++        }
+         // 1px less space when grid is shown (see drawCell)
+         if (showGrid)
+             option.rect.setWidth(option.rect.width() - 1);
+diff --git a/qtbase/src/widgets/kernel/qaction.h b/qtbase/src/widgets/kernel/qaction.h
+index 258a1ea0a0..737c1e8285 100644
+--- a/qtbase/src/widgets/kernel/qaction.h
++++ b/qtbase/src/widgets/kernel/qaction.h
+@@ -81,7 +81,7 @@ class Q_WIDGETS_EXPORT QAction : public QObject
+     Q_PROPERTY(MenuRole menuRole READ menuRole WRITE setMenuRole NOTIFY changed)
+     Q_PROPERTY(bool iconVisibleInMenu READ isIconVisibleInMenu WRITE setIconVisibleInMenu NOTIFY changed)
+     Q_PROPERTY(bool shortcutVisibleInContextMenu READ isShortcutVisibleInContextMenu WRITE setShortcutVisibleInContextMenu NOTIFY changed)
+-    Q_PROPERTY(Priority priority READ priority WRITE setPriority)
++    Q_PROPERTY(Priority priority READ priority WRITE setPriority NOTIFY changed)
+ 
+ public:
+     // note this is copied into qplatformmenu.h, which must stay in sync
+diff --git a/qtbase/src/widgets/kernel/qwidget.cpp b/qtbase/src/widgets/kernel/qwidget.cpp
+index 9eba1e001e..26f6d27e18 100644
+--- a/qtbase/src/widgets/kernel/qwidget.cpp
++++ b/qtbase/src/widgets/kernel/qwidget.cpp
+@@ -5296,7 +5296,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
+         QWidgetEffectSourcePrivate *sourced = static_cast<QWidgetEffectSourcePrivate *>
+                                                          (source->d_func());
+         if (!sourced->context) {
+-            const QRegion effectRgn(rgn.boundingRect());
++            const QRegion effectRgn((flags & UseEffectRegionBounds) ? rgn.boundingRect() : rgn);
+             QWidgetPaintContext context(pdev, effectRgn, offset, flags, sharedPainter, repaintManager);
+             sourced->context = &context;
+             if (!sharedPainter) {
+@@ -5328,6 +5328,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
+         }
+     }
+ #endif // QT_CONFIG(graphicseffect)
++    flags = flags & ~UseEffectRegionBounds;
+ 
+     const bool alsoOnScreen = flags & DrawPaintOnScreen;
+     const bool recursive = flags & DrawRecursive;
+diff --git a/qtbase/src/widgets/kernel/qwidget_p.h b/qtbase/src/widgets/kernel/qwidget_p.h
+index eef6b8fa2c..c432f4b5d5 100644
+--- a/qtbase/src/widgets/kernel/qwidget_p.h
++++ b/qtbase/src/widgets/kernel/qwidget_p.h
+@@ -229,7 +229,8 @@ public:
+         DontSubtractOpaqueChildren = 0x10,
+         DontDrawOpaqueChildren = 0x20,
+         DontDrawNativeChildren = 0x40,
+-        DontSetCompositionMode = 0x80
++        DontSetCompositionMode = 0x80,
++        UseEffectRegionBounds = 0x100
+     };
+     Q_DECLARE_FLAGS(DrawWidgetFlags, DrawWidgetFlag)
+     Q_FLAG(DrawWidgetFlags)
+diff --git a/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp b/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
+index 02880b34da..0d44e1326d 100644
+--- a/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
++++ b/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
+@@ -1018,7 +1018,8 @@ void QWidgetRepaintManager::paintAndFlush()
+ 
+     // Paint the rest with composition.
+     if (repaintAllWidgets || !dirtyCopy.isEmpty()) {
+-        QWidgetPrivate::DrawWidgetFlags flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive;
++        QWidgetPrivate::DrawWidgetFlags flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive
++                | QWidgetPrivate::UseEffectRegionBounds;
+         tlw->d_func()->drawWidget(store->paintDevice(), dirtyCopy, QPoint(), flags, nullptr, this);
+     }
+ 
+diff --git a/qtbase/src/widgets/styles/qfusionstyle.cpp b/qtbase/src/widgets/styles/qfusionstyle.cpp
+index f4345d97c4..962912c838 100644
+--- a/qtbase/src/widgets/styles/qfusionstyle.cpp
++++ b/qtbase/src/widgets/styles/qfusionstyle.cpp
+@@ -1772,14 +1772,6 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio
+             proxy()->drawControl(CE_PushButtonLabel, &subopt, painter, widget);
+         }
+         break;
+-    case CE_PushButtonLabel:
+-        if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
+-            QStyleOptionButton b(*button);
+-            // no PM_ButtonShiftHorizontal and PM_ButtonShiftVertical for fusion style
+-            b.state &= ~(State_On | State_Sunken);
+-            QCommonStyle::drawControl(element, &b, painter, widget);
+-        }
+-        break;
+     case CE_MenuBarEmptyArea:
+         painter->save();
+     {
+diff --git a/qtbase/src/widgets/util/qcompleter.cpp b/qtbase/src/widgets/util/qcompleter.cpp
+index 18b24063d8..ef7207a8a3 100644
+--- a/qtbase/src/widgets/util/qcompleter.cpp
++++ b/qtbase/src/widgets/util/qcompleter.cpp
+@@ -1120,6 +1120,8 @@ void QCompleter::setModel(QAbstractItemModel *model)
+ {
+     Q_D(QCompleter);
+     QAbstractItemModel *oldModel = d->proxy->sourceModel();
++    if (oldModel == model)
++        return;
+ #if QT_CONFIG(filesystemmodel)
+     if (qobject_cast<const QFileSystemModel *>(oldModel))
+         setCompletionRole(Qt::EditRole); // QTBUG-54642, clear FileNameRole set by QFileSystemModel
+diff --git a/qtbase/src/widgets/widgets/qabstractbutton.cpp b/qtbase/src/widgets/widgets/qabstractbutton.cpp
+index a128b23950..dc40bf62fb 100644
+--- a/qtbase/src/widgets/widgets/qabstractbutton.cpp
++++ b/qtbase/src/widgets/widgets/qabstractbutton.cpp
+@@ -56,6 +56,7 @@
+ #ifndef QT_NO_ACCESSIBILITY
+ #include "qaccessible.h"
+ #endif
++#include <qpa/qplatformtheme.h>
+ 
+ #include <algorithm>
+ 
+@@ -1076,19 +1077,19 @@ void QAbstractButton::keyPressEvent(QKeyEvent *e)
+ {
+     Q_D(QAbstractButton);
+     bool next = true;
+-    switch (e->key()) {
+-    case Qt::Key_Enter:
+-    case Qt::Key_Return:
+-        e->ignore();
+-        break;
+-    case Qt::Key_Select:
+-    case Qt::Key_Space:
+-        if (!e->isAutoRepeat()) {
+-            setDown(true);
+-            repaint();
+-            d->emitPressed();
+-        }
+-        break;
++
++    const auto key = static_cast<Qt::Key>(e->key());
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(key) && !e->isAutoRepeat()) {
++        setDown(true);
++        repaint();
++        d->emitPressed();
++        return;
++    }
++
++    switch (key) {
+     case Qt::Key_Up:
+         next = false;
+         Q_FALLTHROUGH();
+@@ -1153,15 +1154,15 @@ void QAbstractButton::keyReleaseEvent(QKeyEvent *e)
+     if (!e->isAutoRepeat())
+         d->repeatTimer.stop();
+ 
+-    switch (e->key()) {
+-    case Qt::Key_Select:
+-    case Qt::Key_Space:
+-        if (!e->isAutoRepeat() && d->down)
+-            d->click();
+-        break;
+-    default:
+-        e->ignore();
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(static_cast<Qt::Key>(e->key())) && !e->isAutoRepeat() && d->down) {
++        d->click();
++        return;
+     }
++
++    e->ignore();
+ }
+ 
+ /*!\reimp
+diff --git a/qtbase/src/widgets/widgets/qcombobox.cpp b/qtbase/src/widgets/widgets/qcombobox.cpp
+index 7a496c27e0..0a3d96647b 100644
+--- a/qtbase/src/widgets/widgets/qcombobox.cpp
++++ b/qtbase/src/widgets/widgets/qcombobox.cpp
+@@ -3352,7 +3352,23 @@ void QComboBox::keyPressEvent(QKeyEvent *e)
+ 
+     Move move = NoMove;
+     int newIndex = currentIndex();
+-    switch (e->key()) {
++
++    bool pressLikeButton = !d->lineEdit;
++#ifdef QT_KEYPAD_NAVIGATION
++    pressLikeButton |= QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus();
++#endif
++    auto key = static_cast<Qt::Key>(e->key());
++    if (pressLikeButton) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(key)) {
++            showPopup();
++            return;
++        }
++    }
++
++    switch (key) {
+     case Qt::Key_Up:
+         if (e->modifiers() & Qt::ControlModifier)
+             break; // pass to line edit for auto completion
+@@ -3394,26 +3410,11 @@ void QComboBox::keyPressEvent(QKeyEvent *e)
+             return;
+         }
+         break;
+-    case Qt::Key_Space:
+-        if (!d->lineEdit) {
+-            showPopup();
+-            return;
+-        }
+-        break;
+-    case Qt::Key_Enter:
+-    case Qt::Key_Return:
+     case Qt::Key_Escape:
+         if (!d->lineEdit)
+             e->ignore();
+         break;
+ #ifdef QT_KEYPAD_NAVIGATION
+-    case Qt::Key_Select:
+-        if (QApplicationPrivate::keypadNavigationEnabled()
+-                && (!hasEditFocus() || !d->lineEdit)) {
+-            showPopup();
+-            return;
+-        }
+-        break;
+     case Qt::Key_Left:
+     case Qt::Key_Right:
+         if (QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus())
+diff --git a/qtbase/src/widgets/widgets/qdatetimeedit_p.h b/qtbase/src/widgets/widgets/qdatetimeedit_p.h
+index d36b6f8f9a..e0df5b5158 100644
+--- a/qtbase/src/widgets/widgets/qdatetimeedit_p.h
++++ b/qtbase/src/widgets/widgets/qdatetimeedit_p.h
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2018 The Qt Company Ltd.
++** Copyright (C) 2021 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtWidgets module of the Qt Toolkit.
+diff --git a/qtbase/src/widgets/widgets/qgroupbox.cpp b/qtbase/src/widgets/widgets/qgroupbox.cpp
+index 02a0bed325..3f3eccc370 100644
+--- a/qtbase/src/widgets/widgets/qgroupbox.cpp
++++ b/qtbase/src/widgets/widgets/qgroupbox.cpp
+@@ -54,6 +54,8 @@
+ #include "qaccessible.h"
+ #endif
+ #include <private/qwidget_p.h>
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
+ 
+ #include "qdebug.h"
+ 
+@@ -360,7 +362,10 @@ bool QGroupBox::event(QEvent *e)
+         return true;
+     case QEvent::KeyPress: {
+         QKeyEvent *k = static_cast<QKeyEvent*>(e);
+-        if (!k->isAutoRepeat() && (k->key() == Qt::Key_Select || k->key() == Qt::Key_Space)) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (!k->isAutoRepeat() && buttonPressKeys.contains(static_cast<Qt::Key>(k->key()))) {
+             d->pressedControl = QStyle::SC_GroupBoxCheckBox;
+             update(style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxCheckBox, this));
+             return true;
+@@ -369,7 +374,10 @@ bool QGroupBox::event(QEvent *e)
+     }
+     case QEvent::KeyRelease: {
+         QKeyEvent *k = static_cast<QKeyEvent*>(e);
+-        if (!k->isAutoRepeat() && (k->key() == Qt::Key_Select || k->key() == Qt::Key_Space)) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (!k->isAutoRepeat() && buttonPressKeys.contains(static_cast<Qt::Key>(k->key()))) {
+             bool toggle = (d->pressedControl == QStyle::SC_GroupBoxLabel
+                            || d->pressedControl == QStyle::SC_GroupBoxCheckBox);
+             d->pressedControl = QStyle::SC_None;
+diff --git a/qtbase/src/widgets/widgets/qlabel.cpp b/qtbase/src/widgets/widgets/qlabel.cpp
+index 30ff80cbb0..cf2605c17c 100644
+--- a/qtbase/src/widgets/widgets/qlabel.cpp
++++ b/qtbase/src/widgets/widgets/qlabel.cpp
+@@ -421,9 +421,6 @@ void QLabel::setPixmap(const QPixmap &pixmap)
+         d->pixmap = new QPixmap(pixmap);
+     }
+ 
+-    if (d->pixmap->depth() == 1 && !d->pixmap->mask())
+-        d->pixmap->setMask(*((QBitmap *)d->pixmap));
+-
+     d->updateLabel();
+ }
+ 
+diff --git a/qtbase/src/widgets/widgets/qtoolbararealayout.cpp b/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
+index 493c094cc1..d5f4b59017 100644
+--- a/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
++++ b/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
+@@ -1367,7 +1367,7 @@ bool QToolBarAreaLayout::restoreState(QDataStream &stream, const QList<QToolBar*
+                 item.widgetItem = new QWidgetItemV2(toolBar);
+                 toolBar->setOrientation(floating ? ((shown & 2) ? Qt::Vertical : Qt::Horizontal) : dock.o);
+                 toolBar->setVisible(shown & 1);
+-                toolBar->d_func()->setWindowState(floating, true, rect);
++                toolBar->d_func()->setWindowState(floating, false, rect);
+ 
+                 item.preferredSize = item.size;
+                 line.toolBarItems.append(item);
+diff --git a/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp b/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
+index 212c0a2e13..3c77b1ba0b 100644
+--- a/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
++++ b/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
+@@ -126,8 +126,7 @@ public:
+ 
+ void tst_QtConcurrentIterateKernel::instantiate()
+ {
+-    auto future = startThreadEngine(new PrintFor(0, 40)).startAsynchronously();
+-    future.waitForFinished();
++    startThreadEngine(new PrintFor(0, 40)).startBlocking();
+     QCOMPARE(iterations.loadRelaxed(), 40);
+ }
+ 
+@@ -166,10 +165,8 @@ void tst_QtConcurrentIterateKernel::stresstest()
+     const int times = 50;
+     for (int i = 0; i < times; ++i) {
+         counter.storeRelaxed(0);
+-        // ThreadEngine will delete f when it finishes
+-        auto f = new CountFor(0, iterations);
+-        auto future = f->startAsynchronously();
+-        future.waitForFinished();
++        CountFor f(0, iterations);
++        f.startBlocking();
+         QCOMPARE(counter.loadRelaxed(), iterations);
+     }
+ }
+@@ -177,11 +174,8 @@ void tst_QtConcurrentIterateKernel::stresstest()
+ void tst_QtConcurrentIterateKernel::noIterations()
+ {
+     const int times = 20000;
+-    for (int i = 0; i < times; ++i) {
+-        auto future = startThreadEngine(new IterateKernel<TestIterator, void>(0, 0))
+-                              .startAsynchronously();
+-        future.waitForFinished();
+-    }
++    for (int i = 0; i < times; ++i)
++        startThreadEngine(new IterateKernel<TestIterator, void>(0, 0)).startBlocking();
+ }
+ 
+ QMutex threadsMutex;
+@@ -236,10 +230,8 @@ void tst_QtConcurrentIterateKernel::throttling()
+ 
+     threads.clear();
+ 
+-    // ThreadEngine will delete f when it finishes
+-    auto f = new ThrottleFor(0, totalIterations);
+-    auto future = f->startAsynchronously();
+-    future.waitForFinished();
++    ThrottleFor f(0, totalIterations);
++    f.startBlocking();
+ 
+     QCOMPARE(iterations.loadRelaxed(), totalIterations);
+ 
+diff --git a/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp b/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
+index ac7be7acdd..81bc64c8d9 100644
+--- a/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
++++ b/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
+@@ -65,9 +65,16 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::runDirectly()
+ {
+-    PrintUser *engine = new PrintUser();
+-    QFuture<void> f = engine->startAsynchronously();
+-    f.waitForFinished();
++    {
++        PrintUser engine;
++        engine.startSingleThreaded();
++        engine.startBlocking();
++    }
++    {
++        PrintUser *engine = new PrintUser();
++        QFuture<void> f = engine->startAsynchronously();
++        f.waitForFinished();
++    }
+ }
+ 
+ class StringResultUser : public ThreadEngine<QString>
+@@ -99,10 +106,8 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::result()
+ {
+-    // ThreadEngine will delete 'engine' when it finishes
+-    auto engine = new StringResultUser();
+-    auto future = engine->startAsynchronously();
+-    QCOMPARE(future.result(), QString("Foo"));
++    StringResultUser engine;
++    QCOMPARE(*engine.startBlocking(), QString("Foo"));
+ }
+ 
+ class VoidResultUser : public ThreadEngine<void>
+@@ -128,9 +133,17 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::runThroughStarter()
+ {
+-    ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
+-    QFuture<QString> f = starter.startAsynchronously();
+-    QCOMPARE(f.result(), QString("Foo"));
++    {
++        ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
++        QFuture<QString>  f = starter.startAsynchronously();
++        QCOMPARE(f.result(), QString("Foo"));
++    }
++
++    {
++        ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
++        QString str = starter.startBlocking();
++        QCOMPARE(str, QString("Foo"));
++    }
+ }
+ 
+ class CancelUser : public ThreadEngine<void>
+@@ -213,6 +226,12 @@ void tst_QtConcurrentThreadEngine::throttle()
+         f.waitForFinished();
+         QCOMPARE(count.loadRelaxed(), 0);
+     }
++
++    for (int i = 0; i < repeats; ++i) {
++        ThrottleAlwaysUser t;
++        t.startBlocking();
++        QCOMPARE(count.loadRelaxed(), 0);
++    }
+ }
+ 
+ QSet<QThread *> threads;
+@@ -249,17 +268,35 @@ void tst_QtConcurrentThreadEngine::threadCount()
+ {
+     const int repeats = 10;
+     for (int i = 0; i < repeats; ++i) {
++        ThreadCountUser t;
++        t.startBlocking();
++        int count = threads.count();
++        int count_expected = QThreadPool::globalInstance()->maxThreadCount() + 1; // +1 for the main thread.
++        if (count != count_expected)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, count_expected);
++
+         (new ThreadCountUser())->startAsynchronously().waitForFinished();
+-        const auto count = threads.count();
+-        const auto maxThreadCount = QThreadPool::globalInstance()->maxThreadCount();
+-        QVERIFY(count <= maxThreadCount);
+-        QVERIFY(!threads.contains(QThread::currentThread()));
++        count = threads.count();
++        count_expected = QThreadPool::globalInstance()->maxThreadCount();
++        if (count != count_expected)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, count_expected);
+     }
+ 
+     // Set the finish flag immediately, this should give us one thread only.
+     for (int i = 0; i < repeats; ++i) {
++        ThreadCountUser t(true /*finishImmediately*/);
++        t.startBlocking();
++        int count = threads.count();
++        if (count != 1)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, 1);
++
+         (new ThreadCountUser(true /*finishImmediately*/))->startAsynchronously().waitForFinished();
+-        const auto count = threads.count();
++        count = threads.count();
++        if (count != 1)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
+         QCOMPARE(count, 1);
+         QVERIFY(!threads.contains(QThread::currentThread()));
+     }
+@@ -400,6 +437,7 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::exceptions()
+ {
++    // Asynchronous mode:
+     {
+         bool caught = false;
+         try  {
+@@ -412,6 +450,32 @@ void tst_QtConcurrentThreadEngine::exceptions()
+         QVERIFY2(caught, "did not get exception");
+     }
+ 
++    // Blocking mode:
++    // test throwing the exception from a worker thread.
++    {
++        bool caught = false;
++        try  {
++            QtConcurrentExceptionThrower e(QThread::currentThread());
++            e.startBlocking();
++        } catch (const QException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // test throwing the exception from the main thread (different code path)
++    {
++        bool caught = false;
++        try  {
++            QtConcurrentExceptionThrower e(0);
++            e.startBlocking();
++        } catch (const QException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // Asynchronous mode:
+     {
+         bool caught = false;
+         try  {
+@@ -423,6 +487,31 @@ void tst_QtConcurrentThreadEngine::exceptions()
+         }
+         QVERIFY2(caught, "did not get exception");
+     }
++
++    // Blocking mode:
++    // test throwing the exception from a worker thread.
++    {
++        bool caught = false;
++        try  {
++            UnrelatedExceptionThrower e(QThread::currentThread());
++            e.startBlocking();
++        } catch (const QUnhandledException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // test throwing the exception from the main thread (different code path)
++    {
++        bool caught = false;
++        try  {
++            UnrelatedExceptionThrower e(0);
++            e.startBlocking();
++        } catch (const QUnhandledException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
+ }
+ 
+ #endif
+diff --git a/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp b/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
+index 4968742110..f4c3fb711d 100644
+--- a/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
++++ b/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
+@@ -42,6 +42,7 @@ private slots:
+     void writeBlock_data();
+     void writeBlock();
+     void seek();
++    void invalidSeeks();
+     void seekTest_data();
+     void seekTest();
+     void read_rawdata();
+@@ -286,6 +287,29 @@ void tst_QBuffer::seek()
+     QCOMPARE(buffer.size(), pos);
+ }
+ 
++void tst_QBuffer::invalidSeeks()
++{
++    if constexpr (sizeof(qsizetype) == sizeof(qint64)) {
++        // sizeof(qsizetype) == sizeof(qint64), so +1 would overflow
++        QSKIP("This is a 32-bit-only test.");
++    } else {
++        QBuffer buffer;
++        buffer.open(QIODevice::WriteOnly);
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++        constexpr qint64 MaxQByteArrayCapacity = (std::numeric_limits<qsizetype>::max)();
++        // this should fail fast, not after trying to allocate nearly 2 GiB of data,
++        // potentially crashing in the process:
++        QVERIFY(!buffer.seek(2 * MaxQByteArrayCapacity - 1));
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++        // ditto:
++        QVERIFY(!buffer.seek(MaxQByteArrayCapacity + 1));
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++    }
++}
++
+ void tst_QBuffer::seekTest_data()
+ {
+     writeBlock_data();
+diff --git a/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp b/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
+index da5327594c..4a04e0f7c6 100644
+--- a/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
++++ b/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
+@@ -561,7 +561,8 @@ protected:
+     qint64 readData(char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf->size() - offset));
+-        memcpy(data, buf->constData() + offset, maxSize);
++        if (maxSize > 0)
++            memcpy(data, buf->constData() + offset, maxSize);
+         offset += maxSize;
+         return maxSize;
+     }
+@@ -604,13 +605,15 @@ protected:
+     qint64 readData(char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf.size() - pos()));
+-        memcpy(data, buf.constData() + pos(), maxSize);
++        if (maxSize > 0)
++            memcpy(data, buf.constData() + pos(), maxSize);
+         return maxSize;
+     }
+     qint64 writeData(const char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf.size() - pos()));
+-        memcpy(buf.data() + pos(), data, maxSize);
++        if (maxSize > 0)
++            memcpy(buf.data() + pos(), data, maxSize);
+         return maxSize;
+     }
+ 
+diff --git a/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+index db60bead64..f345a44414 100644
+--- a/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
++++ b/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+@@ -1,7 +1,8 @@
+ /****************************************************************************
+ **
+ ** Copyright (C) 2021 The Qt Company Ltd.
+-** Copyright (C) 2020 Intel Corporation.
++** Copyright (C) 2020 The Qt Company Ltd.
++** Copyright (C) 2022 Intel Corporation.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the test suite of the Qt Toolkit.
+@@ -150,6 +151,8 @@ private slots:
+     void startStopStartStopBuffers();
+     void processEventsInAReadyReadSlot_data();
+     void processEventsInAReadyReadSlot();
++    void startFromCurrentWorkingDir_data();
++    void startFromCurrentWorkingDir();
+ 
+     // keep these at the end, since they use lots of processes and sometimes
+     // caused obscure failures to occur in tests that followed them (esp. on the Mac)
+@@ -2731,5 +2734,94 @@ void tst_QProcess::finishProcessBeforeReadingDone_deprecated()
+ 
+ #endif
+ 
++enum class ChdirMode {
++    None = 0,
++    InParent,
++    InChild
++};
++Q_DECLARE_METATYPE(ChdirMode)
++
++void tst_QProcess::startFromCurrentWorkingDir_data()
++{
++    qRegisterMetaType<ChdirMode>();
++    QTest::addColumn<QString>("programPrefix");
++    QTest::addColumn<ChdirMode>("chdirMode");
++    QTest::addColumn<bool>("success");
++
++    constexpr bool IsWindows = true
++#ifdef Q_OS_UNIX
++            && false
++#endif
++            ;
++
++    // baseline: trying to execute the directory, this can't possibly succeed!
++    QTest::newRow("plain-same-cwd") << QString() << ChdirMode::None << false;
++
++    // cross-platform behavior: neither OS searches the setWorkingDirectory()
++    // dir without "./"
++    QTest::newRow("plain-child-chdir") << QString() << ChdirMode::InChild << false;
++
++    // cross-platform behavior: both OSes search the parent's CWD with "./"
++    QTest::newRow("prefixed-parent-chdir") << "./" << ChdirMode::InParent << true;
++
++    // opposite behaviors: Windows searches the parent's CWD and Unix searches
++    // the child's with "./"
++    QTest::newRow("prefixed-child-chdir") << "./" << ChdirMode::InChild << !IsWindows;
++
++    // Windows searches the parent's CWD without "./"
++    QTest::newRow("plain-parent-chdir") << QString() << ChdirMode::InParent << IsWindows;
++}
++
++void tst_QProcess::startFromCurrentWorkingDir()
++{
++    QFETCH(QString, programPrefix);
++    QFETCH(ChdirMode, chdirMode);
++    QFETCH(bool, success);
++
++    QProcess process;
++    qRegisterMetaType<QProcess::ProcessError>();
++    QSignalSpy errorSpy(&process, &QProcess::errorOccurred);
++    QVERIFY(errorSpy.isValid());
++
++    // both the dir name and the executable name
++    const QString target = QStringLiteral("testProcessNormal");
++    process.setProgram(programPrefix + target);
++
++#ifdef Q_OS_UNIX
++    // Reset PATH, to be sure it doesn't contain . or the empty path.
++    // We can't do this on Windows because DLLs are searched in PATH
++    // and Windows always searches "." anyway.
++    auto restoreEnv = qScopeGuard([old = qgetenv("PATH")] {
++        qputenv("PATH", old);
++    });
++    qputenv("PATH", "/");
++#endif
++
++    switch (chdirMode) {
++    case ChdirMode::InParent: {
++        auto restoreCwd = qScopeGuard([old = QDir::currentPath()] {
++            QDir::setCurrent(old);
++        });
++        QVERIFY(QDir::setCurrent(target));
++        process.start();
++        break;
++    }
++    case ChdirMode::InChild:
++        process.setWorkingDirectory(target);
++        Q_FALLTHROUGH();
++    case ChdirMode::None:
++        process.start();
++        break;
++    }
++
++    QCOMPARE(process.waitForStarted(), success);
++    QCOMPARE(errorSpy.count(), int(!success));
++    if (success) {
++        QVERIFY(process.waitForFinished());
++    } else {
++        QCOMPARE(process.error(), QProcess::FailedToStart);
++    }
++}
++
+ QTEST_MAIN(tst_QProcess)
+ #include "tst_qprocess.moc"
+diff --git a/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp b/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp
+index e1ea7a4552..90972caa57 100644
+--- a/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp
++++ b/qtbase/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"
+diff --git a/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+index 9bd66c0835..ed4a0bae5d 100644
+--- a/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
++++ b/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+@@ -158,6 +158,7 @@ private slots:
+     void nullReceiver();
+     void functorReferencesConnection();
+     void disconnectDisconnects();
++    void declarativeData();
+ };
+ 
+ struct QObjectCreatedOnShutdown
+@@ -7679,5 +7680,81 @@ void tst_QObject::disconnectDisconnects()
+ Q_STATIC_ASSERT(QtPrivate::HasQ_OBJECT_Macro<tst_QObject>::Value);
+ Q_STATIC_ASSERT(!QtPrivate::HasQ_OBJECT_Macro<SiblingDeleter>::Value);
+ 
++#ifdef QT_BUILD_INTERNAL
++/*
++    Since QObjectPrivate stores the declarativeData pointer in a union with the pointer
++    to the currently destroyed child, calls to the QtDeclarative handlers need to be
++    correctly guarded. QTBUG-105286
++*/
++namespace QtDeclarative {
++static QAbstractDeclarativeData *theData;
++
++static void destroyed(QAbstractDeclarativeData *data, QObject *)
++{
++    QCOMPARE(data, theData);
++}
++static void signalEmitted(QAbstractDeclarativeData *data, QObject *, int, void **)
++{
++    QCOMPARE(data, theData);
++}
++// we can't use QCOMPARE in the next two functions, as they don't return void
++static int receivers(QAbstractDeclarativeData *data, const QObject *, int)
++{
++    QTest::qCompare(data, theData, "data", "theData", __FILE__, __LINE__);
++    return 0;
++}
++static bool isSignalConnected(QAbstractDeclarativeData *data, const QObject *, int)
++{
++    QTest::qCompare(data, theData, "data", "theData", __FILE__, __LINE__);
++    return true;
++}
++
++class Object : public QObject
++{
++    Q_OBJECT
++public:
++    using QObject::QObject;
++    ~Object()
++    {
++        if (Object *p = static_cast<Object *>(parent()))
++            p->emitSignal();
++    }
++
++    void emitSignal()
++    {
++        emit theSignal();
++    }
++
++signals:
++    void theSignal();
++};
++
++}
++#endif
++
++void tst_QObject::declarativeData()
++{
++#ifdef QT_BUILD_INTERNAL
++    QScopedValueRollback destroyed(QAbstractDeclarativeData::destroyed,
++                                   QtDeclarative::destroyed);
++    QScopedValueRollback signalEmitted(QAbstractDeclarativeData::signalEmitted,
++                                       QtDeclarative::signalEmitted);
++    QScopedValueRollback receivers(QAbstractDeclarativeData::receivers,
++                                   QtDeclarative::receivers);
++    QScopedValueRollback isSignalConnected(QAbstractDeclarativeData::isSignalConnected,
++                                           QtDeclarative::isSignalConnected);
++
++    QtDeclarative::Object p;
++    QObjectPrivate *priv = QObjectPrivate::get(&p);
++    priv->declarativeData = QtDeclarative::theData = new QAbstractDeclarativeData;
++
++    connect(&p, &QtDeclarative::Object::theSignal, &p, []{
++    });
++
++    QtDeclarative::Object *child = new QtDeclarative::Object;
++    child->setParent(&p);
++#endif
++}
++
+ QTEST_MAIN(tst_QObject)
+ #include "tst_qobject.moc"
+diff --git a/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp b/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
+index 0ea422ecbc..1a3256534b 100644
+--- a/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
++++ b/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
+@@ -70,15 +70,15 @@ static inline QString testSuiteWarning()
+ 
+     QString result;
+     QTextStream str(&result);
+-    str << "\nCannot find the shared-mime-info test suite\nstarting from: "
++    str << "\nCannot find the shared-mime-info test suite\nin the parent of: "
+         << QDir::toNativeSeparators(QDir::currentPath()) << "\n"
+            "cd " << QDir::toNativeSeparators(QStringLiteral("tests/auto/corelib/mimetypes/qmimedatabase")) << "\n"
+-           "wget http://cgit.freedesktop.org/xdg/shared-mime-info/snapshot/Release-1-10.zip\n"
+-           "unzip Release-1-10.zip\n";
++           "wget https://gitlab.freedesktop.org/xdg/shared-mime-info/-/archive/2.1/shared-mime-info-2.1.zip\n"
++           "unzip shared-mime-info-2.1.zip\n";
+ #ifdef Q_OS_WIN
+-    str << "mkdir testfiles\nxcopy /s Release-1-10 s-m-i\n";
++    str << "mkdir testfiles\nxcopy /s shared-mime-info-2.1 s-m-i\n";
+ #else
+-    str << "ln -s Release-1-10 s-m-i\n";
++    str << "ln -s shared-mime-info-2.1 s-m-i\n";
+ #endif
+     return result;
+ }
+@@ -154,7 +154,7 @@ void tst_QMimeDatabase::initTestCase()
+     QVERIFY2(copyResourceFile(xmlFileName, xmlTargetFileName, &errorMessage), qPrintable(errorMessage));
+ #endif
+ 
+-    m_testSuite = QFINDTESTDATA("s-m-i/tests");
++    m_testSuite = QFINDTESTDATA("s-m-i/tests/mime-detection");
+     if (m_testSuite.isEmpty())
+         qWarning("%s", qPrintable(testSuiteWarning()));
+ 
+@@ -611,7 +611,7 @@ void tst_QMimeDatabase::allMimeTypes()
+     QVERIFY(!lst.isEmpty());
+ 
+     // Hardcoding this is the only way to check both providers find the same number of mimetypes.
+-    QCOMPARE(lst.count(), 779);
++    QCOMPARE(lst.count(), 811);
+ 
+     foreach (const QMimeType &mime, lst) {
+         const QString name = mime.name();
+@@ -631,10 +631,9 @@ void tst_QMimeDatabase::suffixes_data()
+ 
+     QTest::newRow("mimetype with a single pattern") << "application/pdf" << "*.pdf" << "pdf";
+     QTest::newRow("mimetype with multiple patterns") << "application/x-kpresenter" << "*.kpr;*.kpt" << "kpr";
+-    QTest::newRow("jpeg") << "image/jpeg" << "*.jpe;*.jpg;*.jpeg" << "jpeg";
+-    //if (KMimeType::sharedMimeInfoVersion() > KDE_MAKE_VERSION(0, 60, 0)) {
+-        QTest::newRow("mimetype with many patterns") << "application/vnd.wordperfect" << "*.wp;*.wp4;*.wp5;*.wp6;*.wpd;*.wpp" << "wp";
+-    //}
++    // The preferred suffix for image/jpeg is *.jpg, as per https://bugs.kde.org/show_bug.cgi?id=176737
++    QTest::newRow("jpeg") << "image/jpeg" << "*.jpe;*.jpg;*.jpeg" << "jpg";
++    QTest::newRow("mimetype with many patterns") << "application/vnd.wordperfect" << "*.wp;*.wp4;*.wp5;*.wp6;*.wpd;*.wpp" << "wp";
+     QTest::newRow("oasis text mimetype") << "application/vnd.oasis.opendocument.text" << "*.odt" << "odt";
+     QTest::newRow("oasis presentation mimetype") << "application/vnd.oasis.opendocument.presentation" << "*.odp" << "odp";
+     QTest::newRow("mimetype with multiple patterns") << "text/plain" << "*.asc;*.txt;*,v" << "txt";
+diff --git a/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp b/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
+index 3e58dd03cc..c8f82ef5d5 100644
+--- a/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
++++ b/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
+@@ -176,6 +176,8 @@ private Q_SLOTS:
+     void fromToVariantConversions_data();
+     void fromToVariantConversions();
+ 
++    void noLeakOnNameClash();
++
+ private:
+     QString testDataDir;
+ };
+@@ -3685,5 +3687,23 @@ void tst_QtJson::fromToVariantConversions()
+     }
+ }
+ 
++void tst_QtJson::noLeakOnNameClash()
++{
++    QJsonDocument doc = QJsonDocument::fromJson("{\"\":{\"\":0},\"\":0}");
++    QVERIFY(!doc.isNull());
++    const QJsonObject obj = doc.object();
++
++    // Removed the duplicate key.
++    QCOMPARE(obj.length(), 1);
++
++    // Retained the last of the duplicates.
++    const QJsonValue val = obj.begin().value();
++    QVERIFY(val.isDouble());
++    QCOMPARE(val.toDouble(), 0.0);
++
++    // It should not leak.
++    // In particular it should not forget to deref the container for the inner object.
++}
++
+ QTEST_MAIN(tst_QtJson)
+ #include "tst_qtjson.moc"
+diff --git a/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp b/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
+index a59b58d57f..241c3e84ac 100644
+--- a/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
++++ b/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
+@@ -63,6 +63,7 @@ private slots:
+     void isValidId_data();
+     void isValidId();
+     void malformed();
++    void serialize();
+     // Backend tests
+     void utcTest();
+     void icuTest();
+@@ -947,6 +948,33 @@ void tst_QTimeZone::malformed()
+         barf.offsetFromUtc(now);
+ }
+ 
++void tst_QTimeZone::serialize()
++{
++    int parts = 0;
++#ifndef QT_NO_DEBUG_STREAM
++    qDebug() << QTimeZone(); // to verify no crash
++    parts++;
++#endif
++#ifndef QT_NO_DATASTREAM
++    QByteArray blob;
++    {
++        QDataStream stream(&blob, QIODevice::WriteOnly);
++        stream << QTimeZone("Europe/Oslo") << QTimeZone(420) << QTimeZone() << qint64(-1);
++    }
++    QDataStream stream(&blob, QIODevice::ReadOnly);
++    QTimeZone invalid, offset, oslo;
++    qint64 minusone;
++    stream >> oslo >> offset >> invalid >> minusone;
++    QCOMPARE(oslo, QTimeZone("Europe/Oslo"));
++    QCOMPARE(offset, QTimeZone(420));
++    QVERIFY(!invalid.isValid());
++    QCOMPARE(minusone, qint64(-1));
++    parts++;
++#endif
++    if (!parts)
++        QSKIP("No serialization enabled");
++}
++
+ void tst_QTimeZone::utcTest()
+ {
+ #ifdef QT_BUILD_INTERNAL
+diff --git a/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp b/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
+index 05480c6dd2..70f4c75756 100644
+--- a/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
++++ b/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
+@@ -324,6 +324,13 @@ void tst_QDBusInterface::notValid()
+ 
+     QVERIFY(!interface.isValid());
+     QVERIFY(!QMetaObject::invokeMethod(&interface, "ListNames", Qt::DirectConnection));
++
++    // With a connection, but empty/null service and path specified
++    QDBusConnection con = QDBusConnection::sessionBus();
++    QVERIFY(con.isConnected());
++    QDBusInterface iface({}, {}, {}, con);
++    QVERIFY(!iface.isValid());
++    QVERIFY(!QMetaObject::invokeMethod(&interface, "ListNames", Qt::DirectConnection));
+ }
+ 
+ void tst_QDBusInterface::notValidDerived()
+diff --git a/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp b/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
+index 874468c954..04ceb4ab65 100644
+--- a/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
++++ b/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
+@@ -507,6 +507,10 @@ void tst_QKeySequence::toStringFromKeycode_data()
+     QTest::newRow("Ctrl+Alt+Num+Del") << QKeySequence(Qt::ControlModifier | Qt::AltModifier | Qt::KeypadModifier | Qt::Key_Delete) << "Ctrl+Alt+Num+Del";
+     QTest::newRow("Ctrl+Ins") << QKeySequence(Qt::ControlModifier | Qt::Key_Insert) << "Ctrl+Ins";
+     QTest::newRow("Ctrl+Num+Ins(1)") << QKeySequence(Qt::Key_Insert | Qt::KeypadModifier | Qt::ControlModifier) << "Ctrl+Num+Ins";
++    QTest::newRow("Ctrl") << QKeySequence(Qt::Key_Control) << "Control";
++    QTest::newRow("Alt") << QKeySequence(Qt::Key_Alt) << "Alt";
++    QTest::newRow("Shift") << QKeySequence(Qt::Key_Shift) << "Shift";
++    QTest::newRow("Meta") << QKeySequence(Qt::Key_Meta) << "Meta";
+ }
+ 
+ void tst_QKeySequence::toStringFromKeycode()
+diff --git a/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp b/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+index 15e0ecadaa..b4eca74283 100644
+--- a/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
++++ b/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+@@ -81,6 +81,8 @@ private slots:
+     void registerOpenTypePreferredNamesSystem();
+     void registerOpenTypePreferredNamesApplication();
+ 
++    void stretchRespected();
++
+ private:
+     QString m_ledFont;
+     QString m_testFont;
+@@ -355,6 +357,28 @@ static QString testString()
+     return QStringLiteral("foo bar");
+ }
+ 
++void tst_QFontDatabase::stretchRespected()
++{
++    int italicId = QFontDatabase::addApplicationFont(m_testFontItalic);
++    QVERIFY(italicId != -1);
++
++    QVERIFY(!QFontDatabase::applicationFontFamilies(italicId).isEmpty());
++
++    QString italicFontName = QFontDatabase::applicationFontFamilies(italicId).first();
++
++    QFont italicFont = QFontDatabase().font(italicFontName,
++                                            QString::fromLatin1("Italic"), 14);
++    QVERIFY(italicFont.italic());
++
++    QFont italicStretchedFont = italicFont;
++    italicStretchedFont.setStretch( 400 );
++
++    QVERIFY(QFontMetricsF(italicFont).horizontalAdvance(QStringLiteral("foobar")) <
++            QFontMetricsF(italicStretchedFont).horizontalAdvance(QStringLiteral("foobar")));
++
++    QFontDatabase::removeApplicationFont(italicId);
++}
++
+ void tst_QFontDatabase::condensedFontWidthNoFontMerging()
+ {
+     int regularFontId = QFontDatabase::addApplicationFont(m_testFont);
+diff --git a/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+index 3d4a094c43..b423e11a99 100644
+--- a/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
++++ b/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+@@ -281,6 +281,7 @@ private Q_SLOTS:
+     void ioGetFromFileSpecial();
+     void ioGetFromFile_data();
+     void ioGetFromFile();
++    void ioGetFromFileUrl();
+     void ioGetFromFtp_data();
+     void ioGetFromFtp();
+     void ioGetFromFtpWithReuse();
+@@ -3300,6 +3301,18 @@ void tst_QNetworkReply::ioGetFromFile()
+     QCOMPARE(reader.data, data);
+ }
+ 
++void tst_QNetworkReply::ioGetFromFileUrl()
++{
++    // This immediately fails on non-windows platforms:
++    QNetworkRequest request(QUrl("file://unc-server/some/path"));
++    QNetworkReplyPtr reply(manager.get(request));
++    QSignalSpy finishedSpy(reply.get(), &QNetworkReply::finished);
++    // QTBUG-105618: This would, on non-Windows platforms, never happen because the signal
++    // was emitted before the constructor finished, leaving no chance at all to connect to the
++    // signal
++    QVERIFY(finishedSpy.wait());
++}
++
+ void tst_QNetworkReply::ioGetFromFtp_data()
+ {
+     QTest::addColumn<QString>("fileName");
+diff --git a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
+index 069fa6b341..4cc4d9a5ea 100644
+--- a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
++++ b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
+@@ -1,75 +1,34 @@
+-Certificate:
+-    Data:
+-        Version: 3 (0x2)
+-        Serial Number: 0 (0x0)
+-        Signature Algorithm: sha1WithRSAEncryption
+-        Issuer: C=NO, ST=Oslo, L=Nydalen, O=Nokia Corporation and/or its subsidiary(-ies), OU=Development, CN=fluke.troll.no/emailAddress=ahanssen@trolltech.com
+-        Validity
+-            Not Before: Dec  4 01:10:32 2007 GMT
+-            Not After : Apr 21 01:10:32 2035 GMT
+-        Subject: C=NO, ST=Oslo, O=Nokia Corporation and/or its subsidiary(-ies), OU=Development, CN=fluke.troll.no
+-        Subject Public Key Info:
+-            Public Key Algorithm: rsaEncryption
+-            RSA Public Key: (1024 bit)
+-                Modulus (1024 bit):
+-                    00:a7:c8:a0:4a:c4:19:05:1b:66:ba:32:e2:d2:f1:
+-                    1c:6f:17:82:e4:39:2e:01:51:90:db:04:34:32:11:
+-                    21:c2:0d:6f:59:d8:53:90:54:3f:83:8f:a9:d3:b3:
+-                    d5:ee:1a:9b:80:ae:c3:25:c9:5e:a5:af:4b:60:05:
+-                    aa:a0:d1:91:01:1f:ca:04:83:e3:58:1c:99:32:45:
+-                    84:70:72:58:03:98:4a:63:8b:41:f5:08:49:d2:91:
+-                    02:60:6b:e4:64:fe:dd:a0:aa:74:08:e9:34:4c:91:
+-                    5f:12:3d:37:4d:54:2c:ad:7f:5b:98:60:36:02:8c:
+-                    3b:f6:45:f3:27:6a:9b:94:9d
+-                Exponent: 65537 (0x10001)
+-        X509v3 extensions:
+-            X509v3 Basic Constraints: 
+-                CA:FALSE
+-            Netscape Comment: 
+-                OpenSSL Generated Certificate
+-            X509v3 Subject Key Identifier: 
+-                21:85:04:3D:23:01:66:E5:F7:9F:1A:84:24:8A:AF:0A:79:F4:E5:AC
+-            X509v3 Authority Key Identifier: 
+-                DirName:/C=NO/ST=Oslo/L=Nydalen/O=Nokia Corporation and/or its subsidiary(-ies)/OU=Development/CN=fluke.troll.no/emailAddress=ahanssen@trolltech.com
+-                serial:8E:A8:B4:E8:91:B7:54:2E
+-
+-    Signature Algorithm: sha1WithRSAEncryption
+-        6d:57:5f:d1:05:43:f0:62:05:ec:2a:71:a5:dc:19:08:f2:c4:
+-        a6:bd:bb:25:d9:ca:89:01:0e:e4:cf:1f:c1:8c:c8:24:18:35:
+-        53:59:7b:c0:43:b4:32:e6:98:b2:a6:ef:15:05:0b:48:5f:e1:
+-        a0:0c:97:a9:a1:77:d8:35:18:30:bc:a9:8f:d3:b7:54:c7:f1:
+-        a9:9e:5d:e6:19:bf:f6:3c:5b:2b:d8:e4:3e:62:18:88:8b:d3:
+-        24:e1:40:9b:0c:e6:29:16:62:ab:ea:05:24:70:36:aa:55:93:
+-        ef:02:81:1b:23:10:a2:04:eb:56:95:75:fc:f8:94:b1:5d:42:
+-        c5:3f:36:44:85:5d:3a:2e:90:46:8a:a2:b9:6f:87:ae:0c:15:
+-        40:19:31:90:fc:3b:25:bb:ae:f1:66:13:0d:85:90:d9:49:34:
+-        8f:f2:5d:f9:7a:db:4d:5d:27:f6:76:9d:35:8c:06:a6:4c:a3:
+-        b1:b2:b6:6f:1d:d7:a3:00:fd:72:eb:9e:ea:44:a1:af:21:34:
+-        7d:c7:42:e2:49:91:19:8b:c0:ad:ba:82:80:a8:71:70:f4:35:
+-        31:91:63:84:20:95:e9:60:af:64:8b:cc:ff:3d:8a:76:74:3d:
+-        c8:55:6d:e4:8e:c3:2b:1c:e8:42:18:ae:9f:e6:6b:9c:34:06:
+-        ec:6a:f2:c3
+ -----BEGIN CERTIFICATE-----
+-MIIEEzCCAvugAwIBAgIBADANBgkqhkiG9w0BAQUFADCBnDELMAkGA1UEBhMCTk8x
+-DTALBgNVBAgTBE9zbG8xEDAOBgNVBAcTB055ZGFsZW4xFjAUBgNVBAoTDVRyb2xs
+-dGVjaCBBU0ExFDASBgNVBAsTC0RldmVsb3BtZW50MRcwFQYDVQQDEw5mbHVrZS50
+-cm9sbC5ubzElMCMGCSqGSIb3DQEJARYWYWhhbnNzZW5AdHJvbGx0ZWNoLmNvbTAe
+-Fw0wNzEyMDQwMTEwMzJaFw0zNTA0MjEwMTEwMzJaMGMxCzAJBgNVBAYTAk5PMQ0w
+-CwYDVQQIEwRPc2xvMRYwFAYDVQQKEw1Ucm9sbHRlY2ggQVNBMRQwEgYDVQQLEwtE
+-ZXZlbG9wbWVudDEXMBUGA1UEAxMOZmx1a2UudHJvbGwubm8wgZ8wDQYJKoZIhvcN
+-AQEBBQADgY0AMIGJAoGBAKfIoErEGQUbZroy4tLxHG8XguQ5LgFRkNsENDIRIcIN
+-b1nYU5BUP4OPqdOz1e4am4CuwyXJXqWvS2AFqqDRkQEfygSD41gcmTJFhHByWAOY
+-SmOLQfUISdKRAmBr5GT+3aCqdAjpNEyRXxI9N01ULK1/W5hgNgKMO/ZF8ydqm5Sd
+-AgMBAAGjggEaMIIBFjAJBgNVHRMEAjAAMCwGCWCGSAGG+EIBDQQfFh1PcGVuU1NM
+-IEdlbmVyYXRlZCBDZXJ0aWZpY2F0ZTAdBgNVHQ4EFgQUIYUEPSMBZuX3nxqEJIqv
+-Cnn05awwgbsGA1UdIwSBszCBsKGBoqSBnzCBnDELMAkGA1UEBhMCTk8xDTALBgNV
+-BAgTBE9zbG8xEDAOBgNVBAcTB055ZGFsZW4xFjAUBgNVBAoTDVRyb2xsdGVjaCBB
+-U0ExFDASBgNVBAsTC0RldmVsb3BtZW50MRcwFQYDVQQDEw5mbHVrZS50cm9sbC5u
+-bzElMCMGCSqGSIb3DQEJARYWYWhhbnNzZW5AdHJvbGx0ZWNoLmNvbYIJAI6otOiR
+-t1QuMA0GCSqGSIb3DQEBBQUAA4IBAQBtV1/RBUPwYgXsKnGl3BkI8sSmvbsl2cqJ
+-AQ7kzx/BjMgkGDVTWXvAQ7Qy5piypu8VBQtIX+GgDJepoXfYNRgwvKmP07dUx/Gp
+-nl3mGb/2PFsr2OQ+YhiIi9Mk4UCbDOYpFmKr6gUkcDaqVZPvAoEbIxCiBOtWlXX8
+-+JSxXULFPzZEhV06LpBGiqK5b4euDBVAGTGQ/Dslu67xZhMNhZDZSTSP8l35ettN
+-XSf2dp01jAamTKOxsrZvHdejAP1y657qRKGvITR9x0LiSZEZi8CtuoKAqHFw9DUx
+-kWOEIJXpYK9ki8z/PYp2dD3IVW3kjsMrHOhCGK6f5mucNAbsavLD
++MIIF6zCCA9OgAwIBAgIUfo9amJtJGWqWE6f+SkAO85zkGr4wDQYJKoZIhvcNAQEL
++BQAwgYMxCzAJBgNVBAYTAk5PMQ0wCwYDVQQIDARPc2xvMQ0wCwYDVQQHDARPc2xv
++MRcwFQYDVQQKDA5UaGUgUXQgQ29tcGFueTEMMAoGA1UECwwDUiZEMRIwEAYDVQQD
++DAlIMiBUZXN0ZXIxGzAZBgkqhkiG9w0BCQEWDG1pbmltaUBxdC5pbzAgFw0yMDEw
++MjYxMjAxMzFaGA8yMTIwMTAwMjEyMDEzMVowgYMxCzAJBgNVBAYTAk5PMQ0wCwYD
++VQQIDARPc2xvMQ0wCwYDVQQHDARPc2xvMRcwFQYDVQQKDA5UaGUgUXQgQ29tcGFu
++eTEMMAoGA1UECwwDUiZEMRIwEAYDVQQDDAlIMiBUZXN0ZXIxGzAZBgkqhkiG9w0B
++CQEWDG1pbmltaUBxdC5pbzCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIB
++AOiUp5+E4blouKH7q+rVNR8NoYX2XkBW+q+rpy1zu5ssRSzbqxAjDx9dkht7Qlnf
++VlDT00JvpOWdeuPon5915edQRsY4Unl6mKH29ra3OtUa1/yCJXsGVJTKCj7k4Bxb
++5mZzb/fTlZntMLdTIBMfUbw62FKir1WjKIcJ9fCoG8JaGeKVO4Rh5p0ezd4UUUId
++r1BXl5Nqdqy2vTMsEDnjOsD3egkv8I2SKN4O6n/C3wWYpMOWYZkGoZiKz7rJs/i/
++ez7bsV7JlwdzTlhpJzkcOSVFBP6JlEOxTNNxZ1wtKy7PtZGmsSSATq2e6+bw38Ae
++Op0XnzzqcGjtDDofBmT7OFzZWjS9VZS6+DOOe2QHWle1nCHcHyH4ku6IRlsr9xkR
++NAIlOfnvHHxqJUenoeaZ4oQDjCBKS1KXygJO/tL7BLTQVn/xK1EmPvKNnjzWk4tR
++PnibUhhs5635qpOU/YPqFBh1JjVruZbsWcDAhRcew0uxONXOa9E+4lttQ9ySYa1A
++LvWqJuAX7gu2BsBMLyqfm811YnA7CIFMyO+HlqmkLFfv5L/xIRAXR7l26YGO0VwX
++CGjMfz4NVPMMke4nB7qa9NkpXQBQKMms3Qzd5JW0Hy9Ruj5O8GPcFZmV0twjd1uJ
++PD/cAjkWLaXjdNsJ16QWc2nghQRS6HYqKRX6j+CXOxupAgMBAAGjUzBRMB0GA1Ud
++DgQWBBRSCOU58j9NJZkMamt623qyCrhN3TAfBgNVHSMEGDAWgBRSCOU58j9NJZkM
++amt623qyCrhN3TAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4ICAQCq
++q4jxsWeNDv5Nq14hJtF9HB+ZL64zcZtRjJP1YgNs0QppKICmjPOL2nIMGmI/jKrs
++0eGAL/9XXNVHPxm1OPOncvimMMmU6emZfpMdEtTfKP43+Pg9HgKRjLoQp406vGeQ
++8ki/mbBhrItVPgEm3tu2AFA02XTYi+YxCI9kRZLGkM3FbgtOuTLPl0Z9y+kiPc9F
++uCSC03anBEqv+vDSI8+wODymQ/IJ3Jyz1lxIRDfp4qAekmy0jU2c91VOHHEmOmqq
++kqygGFRdwbe99m9yP63r6q0b5K3X2UnJ6bns0hmTwThYwpVPXLU8jdaTddbMukN2
++/Ef96Tsw8nWOEOPMySHOTIPgwyZRp26b0kA9EmhLwOP401SxXVQCmSRmtwNagmtg
++jJKmZoYBN+//D45ibK8z6Q0oOm9P+Whf/uUXehcRxBxyV3xz7k0wKGQbHj/ddwcy
++IUoIN4lrAlib+lK170kTKN352PDmrpo2gmIzPEsfurKAIMSelDl6H+kih16BtZ8y
++Nz6fh9Soqrg3OSAware8pxV7k51crBMoPLN78KoRV8MFCK4K7Fddq4rRISq6hiXq
++r1nsjoEPuKM9huprmZVZe9t5YcDa2I+wb3IiE3uwpZbAdaLDyQ5n6F/qpsiIkZXn
++gtcF7oqpG5oYrwCcZ53y/ezUgUg7PlSz2XwAGvQtgg==
+ -----END CERTIFICATE-----
+diff --git a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
+index 9d1664d609..337ce541a6 100644
+--- a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
++++ b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
+@@ -1,15 +1,52 @@
+------BEGIN RSA PRIVATE KEY-----
+-MIICXAIBAAKBgQCnyKBKxBkFG2a6MuLS8RxvF4LkOS4BUZDbBDQyESHCDW9Z2FOQ
+-VD+Dj6nTs9XuGpuArsMlyV6lr0tgBaqg0ZEBH8oEg+NYHJkyRYRwclgDmEpji0H1
+-CEnSkQJga+Rk/t2gqnQI6TRMkV8SPTdNVCytf1uYYDYCjDv2RfMnapuUnQIDAQAB
+-AoGANFzLkanTeSGNFM0uttBipFT9F4a00dqHz6JnO7zXAT26I5r8sU1pqQBb6uLz
+-/+Qz5Zwk8RUAQcsMRgJetuPQUb0JZjF6Duv24hNazqXBCu7AZzUenjafwmKC/8ri
+-KpX3fTwqzfzi//FKGgbXQ80yykSSliDL3kn/drATxsLCgQECQQDXhEFWLJ0vVZ1s
+-1Ekf+3NITE+DR16X+LQ4W6vyEHAjTbaNWtcTKdAWLA2l6N4WAAPYSi6awm+zMxx4
+-VomVTsjdAkEAx0z+e7natLeFcrrq8pbU+wa6SAP1VfhQWKitxL1e7u/QO90NCpxE
+-oQYKzMkmmpOOFjQwEMAy1dvFMbm4LHlewQJAC/ksDBaUcQHHqjktCtrUb8rVjAyW
+-A8lscckeB2fEYyG5J6dJVaY4ClNOOs5yMDS2Afk1F6H/xKvtQ/5CzInA/QJATDub
+-K+BPU8jO9q+gpuIi3VIZdupssVGmCgObVCHLakG4uO04y9IyPhV9lA9tALtoIf4c
+-VIvv5fWGXBrZ48kZAQJBAJmVCdzQxd9LZI5vxijUCj5EI4e+x5DRqVUvyP8KCZrC
+-AiNyoDP85T+hBZaSXK3aYGpVwelyj3bvo1GrTNwNWLw=
+------END RSA PRIVATE KEY-----
++-----BEGIN PRIVATE KEY-----
++MIIJQgIBADANBgkqhkiG9w0BAQEFAASCCSwwggkoAgEAAoICAQDolKefhOG5aLih
+++6vq1TUfDaGF9l5AVvqvq6ctc7ubLEUs26sQIw8fXZIbe0JZ31ZQ09NCb6TlnXrj
++6J+fdeXnUEbGOFJ5epih9va2tzrVGtf8giV7BlSUygo+5OAcW+Zmc2/305WZ7TC3
++UyATH1G8OthSoq9VoyiHCfXwqBvCWhnilTuEYeadHs3eFFFCHa9QV5eTanastr0z
++LBA54zrA93oJL/CNkijeDup/wt8FmKTDlmGZBqGYis+6ybP4v3s+27FeyZcHc05Y
++aSc5HDklRQT+iZRDsUzTcWdcLSsuz7WRprEkgE6tnuvm8N/AHjqdF5886nBo7Qw6
++HwZk+zhc2Vo0vVWUuvgzjntkB1pXtZwh3B8h+JLuiEZbK/cZETQCJTn57xx8aiVH
++p6HmmeKEA4wgSktSl8oCTv7S+wS00FZ/8StRJj7yjZ481pOLUT54m1IYbOet+aqT
++lP2D6hQYdSY1a7mW7FnAwIUXHsNLsTjVzmvRPuJbbUPckmGtQC71qibgF+4LtgbA
++TC8qn5vNdWJwOwiBTMjvh5appCxX7+S/8SEQF0e5dumBjtFcFwhozH8+DVTzDJHu
++Jwe6mvTZKV0AUCjJrN0M3eSVtB8vUbo+TvBj3BWZldLcI3dbiTw/3AI5Fi2l43Tb
++CdekFnNp4IUEUuh2KikV+o/glzsbqQIDAQABAoICAFw1q6tr5I48vY7DF+rXsuLn
++5ZUWE1IQ6fzB4lr72nJv/9EEGnMgYzt9PpMUsD6vdCpBgS2C0+6RHArFzJtNA+RM
++iHLIG7K7702veyr/xBx/MwiSlMeMv/XpkFxVI6E6skMGG2s3AMXxKvJTy5CpRx+I
++eQFyLG+Ya1X2lgJes/q+/CpAHkOjCOpcLySQC5NZ74q734V7nSdmn+Zs3tYEh+O/
++eiuwTP/j5b38Te5vVTqDxTciJPmljmXLCwa0N100lWlbcpvw8qbqiTI2Jm3XCbUE
++AzHjW9vmrF3cRS1fXxKFGShw3SRqlkbxjfeWoi8qDPUBS4m8LOr8qG9Wo5Nfon0z
++zLP4bci3zHDvVcaaZrrsUBs/yZbg+Dgka1DmX7ekmeccr2yTdKDFgPupYUyxVbTl
++a9ZLJysjFD7rgBv1ZclHonLp6Vbm+ZoTqvteo4ikAy6L9RtBWJ23XEK34PkP/+c5
++2vWZaOrnjSeBHbFce8cdJSxqWpP+eSCI5I9XbDrYFIsQ/gqKgtzDKy2ihJ2Y8STL
++yO4hyFPFjxc+Gg4/P2PpmT5CY2ty44M0BWs+JGW96CJPrrplf2lmQUQJj5LZY66X
++Z/4C9L7ZYtKZ+bs5SvU46yWugAvQZX22Xm9xLXWyVXRdx3bj+3M3fDnF9di/zdbh
++CgLx7oWPNrXc7FCajnn9AoIBAQD5FMYwRpw9NWT9WDxQwx+cSI4Icbd88ByTW63S
++LzeRwZA0J9/SfwO+aBRupzc9GkGXCiZcGMw3AGsCtig8yFlw8E5KnzN7KlftDMnM
++9NUxxzlR8VwKyLnZfG7sDTl057ZlUujnqhmt/F8F7dIy7FVO1dE/8nngA+FYTCOG
++UZdGjwyBDlDM0JJdUWGY3xslutcpCDN5mzSTKjy9drMvImAshRawxRF6WBpn7vr2
++nC6vciqfx1Mzx1vyk0Jm0ilaydDdLMADjt/iL4Nkr0BEs4k+UzQiKDwp8gu7abQ1
++eBfxd9Iar4htQa2I1Ewl6P01G/q+ZYwgHhJ9RVn4AxQXefILAoIBAQDvCouORdQX
++C8wsyp7MwXlF/3NQeNN5/+B2mhbxrBOf7PmMCXLnkRWcjwJtzypWFqJ0sqai/2+0
++bqbMcjX5maT8stT2shl3zXe/Ejt2e3TBYpc1tyuses8Kb5BMU8hu6tTd3G2CMXpD
++dT6DVemJZCTtwj9aBNIxSizvlgMolJnCpzhPnlfHSI6E+g3m/LTTo3HwbjMSw/Uq
++irgjOpI2wSBB6LZPSgjvfcYPRyWUk16L4A5uSX0cADnovDFLa5/h0wJvN/OoCSQg
++rLCXG5E18EyL5Wc58BCY1ZvxmjG3lQtgPxYu2Jwc36R/y/JKlxW5suER5ZNpbbD4
++uOyTt2VxMQ2bAoIBAQC5+MzRFqdo/AjfL5Y5JrbfVTzXCTDa09xCGd16ZU60QTWN
+++4ed/r+o1sUKqUcRFB2MzEM/2DQBjQpZB/CbEWvWa1XJWXxypXbowveZU+QqOnmN
++uQvj8WLyA3o+PNF9e9QvauwCrHpn8VpxbtPWuaYoKnUFreFZZQxHhPGxRBIS2JOZ
++eDrT8ZaWnkCkh1AZp5smQ71LOprSlmKrg4jd1GjCVMxQR5N5KXbtyv0OTCZ/UFqK
++2aRBsMPyJgkaBChkZPLRcKwc+/wlQRx1fHQb14DNTApMxoXFO7eOwqmOkpAt9iyl
++SBIwoS0UUI5ab88+bBmXNvKcuFdNuQ4nowTJUn9pAoIBADMNkILBXSvS5DeIyuO2
++Sp1tkoZUV+5NfPY3sMDK3KIibaW/+t+EOBZo4L7tKQCb8vRzl21mmsfxfgRaPDbj
++3r3tv9g0b4YLxxBy52pFscj/soXRai17SS7UZwA2QK+XzgDYbDcLNC6mIsTQG4Gx
++dsWk3/zs3KuUSQaehmwrWK+fIUK38c1pLK8v7LoxrLkqxlHwZ04RthHw8KTthH7X
++Pnl1J0LF8CSeOyfWLSuPUfkT0GEzptnNHpEbaHfQM6R6eaGhVJPF6AZme4y6YYgg
++m2ihhSt1n0XVEWpHYWjxFy3mK2mz75unFC4LM+NEY2p2zuUQoCw7NjnY3QYrfCnx
++rRMCggEAXeXsMSLFjjyuoL7iKbAxo52HD/P0fBoy58LyRcwfNVr0lvYan4pYEx+o
++KijIh9K16PqXZXKMA9v003B+ulmF8bJ7SddCZ5NGvnFhUTDe4DdTKgp2RuwQ3Bsc
++3skPIDbhVETyOLCtys34USHrq8U/0DlGY3eLRfxw9GnbKxSBGa/KEu/qQLPNUo50
++7xHZDg7GKeC3kqNJeqKM9rkp0VzIGkEnaD9127LeNDmERDfftxJzFoC/THvUBLfU
++6Sus2ZYwRE8VFvKC30Q45t/c54X3IuhYvAuiCuTmyfE4ruyzyOwKzhUkeeLq1APX
++g0veFbyfzlJ0q8qzD/iffqqIa2ZSmQ==
++-----END PRIVATE KEY-----
+diff --git a/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp b/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
+index 7ba3715e13..752aa122f6 100644
+--- a/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
++++ b/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
+@@ -179,6 +179,7 @@ void tst_QAccessibilityLinux::initTestCase()
+     QVERIFY(!address.isEmpty());
+ 
+     m_window = new AccessibleTestWindow();
++    m_window->setObjectName("mainWindow"_L1);
+     m_window->show();
+ 
+     QVERIFY(QTest::qWaitForWindowExposed(m_window));
+@@ -236,8 +237,11 @@ bool hasState(QDBusInterface *interface, AtspiStateType state)
+ void tst_QAccessibilityLinux::testLabel()
+ {
+     QLabel *l = new QLabel(m_window);
++    l->setObjectName("theObjectName"_L1);
+     l->setText("Hello A11y");
+     m_window->addWidget(l);
++    auto a11yEmpty = new QLabel(m_window);
++    m_window->addWidget(l);
+ 
+     // Application
+     QCOMPARE(getParent(mainWindow), QLatin1String(ATSPI_DBUS_PATH_ROOT));
+@@ -249,6 +253,8 @@ void tst_QAccessibilityLinux::testLabel()
+     QCOMPARE(getChildren(labelInterface).count(), 0);
+     QCOMPARE(labelInterface->call(QDBus::Block, "GetRoleName").arguments().first().toString(), QLatin1String("label"));
+     QCOMPARE(labelInterface->call(QDBus::Block, "GetRole").arguments().first().toUInt(), 29u);
++    QCOMPARE(labelInterface->call(QDBus::Block, "GetAccessibleId").arguments().first().toString(),
++             QLatin1String("mainWindow.theObjectName"));
+     QCOMPARE(getParent(labelInterface), mainWindow->path());
+     QVERIFY(!hasState(labelInterface, ATSPI_STATE_EDITABLE));
+     QVERIFY(hasState(labelInterface, ATSPI_STATE_READ_ONLY));
+@@ -256,7 +262,12 @@ void tst_QAccessibilityLinux::testLabel()
+     l->setText("New text");
+     QCOMPARE(labelInterface->property("Name").toString(), l->text());
+ 
++    auto *a11yEmptyInterface = getInterface(children.at(1), "org.a11y.atspi.Accessible");
++    QCOMPARE(a11yEmptyInterface->call(QDBus::Block, "GetAccessibleId").arguments().first().toString(),
++             QLatin1String("mainWindow.QLabel"));
++
+     m_window->clearChildren();
++    delete a11yEmptyInterface;
+     delete labelInterface;
+ }
+ 
+diff --git a/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+index 76df61c892..6d6d65b791 100644
+--- a/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
++++ b/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2022 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the test suite of the Qt Toolkit.
+@@ -68,6 +68,8 @@ private slots:
+     void query_exec();
+     void execErrorRecovery_data() { generic_data(); }
+     void execErrorRecovery();
++    void prematureExec_data() { generic_data(); }
++    void prematureExec();
+     void first_data() { generic_data(); }
+     void first();
+     void next_data() { generic_data(); }
+@@ -2770,6 +2772,35 @@ void tst_QSqlQuery::execErrorRecovery()
+     QVERIFY_SQL( q, exec() );
+ }
+ 
++void tst_QSqlQuery::prematureExec()
++{
++    QFETCH(QString, dbName);
++    // We only want the engine name, for addDatabase():
++    int cut = dbName.indexOf(QChar('@'));
++    if (cut < 0)
++        QSKIP("Failed to parse database type out of name");
++    dbName.truncate(cut);
++    cut = dbName.indexOf(QChar('_'));
++    if (cut >= 0)
++        dbName = dbName.mid(cut + 1);
++
++    auto db = QSqlDatabase::addDatabase(dbName);
++    QSqlQuery q(db);
++
++    QTest::ignoreMessage(QtWarningMsg,
++                         "QSqlDatabasePrivate::removeDatabase: connection "
++                         "'qt_sql_default_connection' is still in use, all "
++                         "queries will cease to work.");
++    QTest::ignoreMessage(QtWarningMsg,
++                         "QSqlDatabasePrivate::addDatabase: duplicate connection name "
++                         "'qt_sql_default_connection', old connection removed.");
++    auto otherDb = QSqlDatabase::addDatabase(dbName);
++
++    QTest::ignoreMessage(QtWarningMsg, "QSqlQuery::exec: called before driver has been set up");
++    // QTBUG-100037: shouldn't crash !
++    QVERIFY(!q.exec("select stuff from TheVoid"));
++}
++
+ void tst_QSqlQuery::lastInsertId()
+ {
+     QFETCH( QString, dbName );
+diff --git a/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp b/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
+index 4aa3f8d60b..d2050a61aa 100644
+--- a/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
++++ b/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
+@@ -115,6 +115,10 @@ void tst_QAbstractItemModelTester::standardItemModelZeroColumns()
+     // QTBUG-92886
+     model.insertRows(0, 5);
+     model.removeRows(1, 2);
++
++    const QModelIndex parentIndex = model.index(0, 0);
++    model.insertRows(0, 5, parentIndex);
++    model.removeRows(1, 2, parentIndex);
+ }
+ 
+ void tst_QAbstractItemModelTester::testInsertThroughProxy()
+diff --git a/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json b/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
+index 12a4a22a19..ce518e78fb 100644
+--- a/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
++++ b/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
+@@ -668,50 +668,6 @@
+         "inputFile": "task192552.h",
+         "outputRevision": 67
+     },
+-    {
+-        "classes": [
+-            {
+-                "className": "InlineSlotsWithThrowDeclaration",
+-                "object": true,
+-                "qualifiedClassName": "InlineSlotsWithThrowDeclaration",
+-                "slots": [
+-                    {
+-                        "access": "public",
+-                        "name": "a",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "b",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "c",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "d",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "e",
+-                        "returnType": "void"
+-                    }
+-                ],
+-                "superClasses": [
+-                    {
+-                        "access": "public",
+-                        "name": "QObject"
+-                    }
+-                ]
+-            }
+-        ],
+-        "inputFile": "task189996.h",
+-        "outputRevision": 67
+-    },
+     {
+         "classes": [
+             {
+diff --git a/qtbase/tests/auto/tools/moc/moc.pro b/qtbase/tests/auto/tools/moc/moc.pro
+index c324b3a8cd..4aceb78dc0 100644
+--- a/qtbase/tests/auto/tools/moc/moc.pro
++++ b/qtbase/tests/auto/tools/moc/moc.pro
+@@ -15,7 +15,7 @@ cross_compile: DEFINES += MOC_CROSS_COMPILED
+ HEADERS += using-namespaces.h no-keywords.h task87883.h c-comments.h backslash-newlines.h oldstyle-casts.h \
+            slots-with-void-template.h qinvokable.h namespaced-flags.h trigraphs.h \
+            escapes-in-string-literals.h cstyle-enums.h qprivateslots.h gadgetwithnoenums.h \
+-           dir-in-include-path.h single_function_keyword.h task192552.h task189996.h \
++           dir-in-include-path.h single_function_keyword.h task192552.h \
+            task234909.h task240368.h pure-virtual-signals.h cxx11-enums.h \
+            cxx11-final-classes.h \
+            cxx11-explicit-override-control.h \
+diff --git a/qtbase/tests/auto/tools/moc/task189996.h b/qtbase/tests/auto/tools/moc/task189996.h
+deleted file mode 100644
+index f94a051b3a..0000000000
+--- a/qtbase/tests/auto/tools/moc/task189996.h
++++ /dev/null
+@@ -1,47 +0,0 @@
+-/****************************************************************************
+-**
+-** Copyright (C) 2016 The Qt Company Ltd.
+-** Contact: https://www.qt.io/licensing/
+-**
+-** This file is part of the test suite of the Qt Toolkit.
+-**
+-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+-** 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 General Public License Usage
+-** Alternatively, this file may be used under the terms of the GNU
+-** General Public License version 3 as published by the Free Software
+-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+-** 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-3.0.html.
+-**
+-** $QT_END_LICENSE$
+-**
+-****************************************************************************/
+-// inline functions can have throw declarations
+-
+-#ifndef TASK189996_H
+-#define TASK189996_H
+-
+-#include <QObject>
+-
+-class InlineSlotsWithThrowDeclaration : public QObject
+-{
+-    Q_OBJECT
+-
+-public slots:
+-    void a() throw() { }
+-    void b() const throw() { }
+-    void c() throw();
+-    void d() throw(int) { }
+-    void e() const throw(int,double) { }
+-};
+-
+-#endif
+diff --git a/qtbase/tests/auto/tools/moc/tst_moc.cpp b/qtbase/tests/auto/tools/moc/tst_moc.cpp
+index c716aead21..15dd9e41e5 100644
+--- a/qtbase/tests/auto/tools/moc/tst_moc.cpp
++++ b/qtbase/tests/auto/tools/moc/tst_moc.cpp
+@@ -631,7 +631,6 @@ public:
+ private slots:
+     void initTestCase();
+ 
+-    void slotWithException() throw(MyStruct);
+     void dontStripNamespaces();
+     void oldStyleCasts();
+     void warnOnExtraSignalSlotQualifiaction();
+@@ -673,7 +672,6 @@ private slots:
+     void templateGtGt();
+     void qprivateslots();
+     void qprivateproperties();
+-    void inlineSlotsWithThrowDeclaration();
+     void warnOnPropertyWithoutREAD();
+     void constructors();
+     void typenameWithUnsigned();
+@@ -784,12 +782,6 @@ void tst_Moc::initTestCase()
+ #endif
+ }
+ 
+-void tst_Moc::slotWithException() throw(MyStruct)
+-{
+-    // be happy
+-    QVERIFY(true);
+-}
+-
+ void tst_Moc::dontStripNamespaces()
+ {
+     Sender sender;
+@@ -824,7 +816,7 @@ void tst_Moc::oldStyleCasts()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-Wold-style-cast" << "-I" << "."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -894,7 +886,7 @@ void tst_Moc::inputFileNameWithDotsButNoExtension()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-I" << ".."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -1174,7 +1166,7 @@ void tst_Moc::ignoreOptionClashes()
+     QStringList gccArgs;
+     gccArgs << "-c" << "-x" << "c++" << "-I" << ".."
+          << "-I" << qtIncludePath << "-I" << includeDir << "-o" << "/dev/null"
+-         << "-fPIC" << "-std=c++11" <<  "-";
++         << "-fPIC" << "-std=c++1z" <<  "-";
+     proc.start("gcc", gccArgs);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -1593,21 +1585,6 @@ void tst_Moc::qprivateproperties()
+ 
+ }
+ 
+-#include "task189996.h"
+-
+-void InlineSlotsWithThrowDeclaration::c() throw() {}
+-
+-void tst_Moc::inlineSlotsWithThrowDeclaration()
+-{
+-    InlineSlotsWithThrowDeclaration tst;
+-    const QMetaObject *mobj = tst.metaObject();
+-    QVERIFY(mobj->indexOfSlot("a()") != -1);
+-    QVERIFY(mobj->indexOfSlot("b()") != -1);
+-    QVERIFY(mobj->indexOfSlot("c()") != -1);
+-    QVERIFY(mobj->indexOfSlot("d()") != -1);
+-    QVERIFY(mobj->indexOfSlot("e()") != -1);
+-}
+-
+ void tst_Moc::warnOnPropertyWithoutREAD()
+ {
+ #ifdef MOC_CROSS_COMPILED
+@@ -1869,7 +1846,7 @@ void tst_Moc::notifyError()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-I" << "."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+diff --git a/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+index c355ee9665..88c09de8e0 100644
+--- a/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
++++ b/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+@@ -251,6 +251,7 @@ private slots:
+     void testResetCachedSizeHint();
+     void statusTips();
+     void testRemovingColumnsViaLayoutChanged();
++    void testModelMovingColumns();
+ 
+ protected:
+     void setupTestData(bool use_reset_model = false);
+@@ -360,6 +361,12 @@ public:
+         endRemoveColumns();
+     }
+ 
++    void moveColumn(int from, int to)
++    {
++        beginMoveColumns(QModelIndex(), from, from, QModelIndex(), to);
++        endMoveColumns();
++    }
++
+     void cleanup()
+     {
+         emit layoutAboutToBeChanged();
+@@ -3627,5 +3634,18 @@ void tst_QHeaderView::testRemovingColumnsViaLayoutChanged()
+     // The main point of this test is that the section-size restoring code didn't go out of bounds.
+ }
+ 
++void tst_QHeaderView::testModelMovingColumns()
++{
++    QtTestModel model(10, 10);
++    QHeaderView hv(Qt::Horizontal);
++    hv.setModel(&model);
++    hv.resizeSections(QHeaderView::ResizeToContents);
++    hv.show();
++
++    QPersistentModelIndex index3 = model.index(0, 3);
++    model.moveColumn(3, 1);
++    QCOMPARE(index3.column(), 1);
++}
++
+ QTEST_MAIN(tst_QHeaderView)
+ #include "tst_qheaderview.moc"
+diff --git a/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+index 761357b252..06bb706074 100644
+--- a/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
++++ b/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+@@ -397,6 +397,7 @@ private slots:
+     void checkHeaderMinSize();
+ 
+     void resizeToContents();
++    void resizeToContentsSpans();
+ 
+     void tabFocus();
+     void bigModel();
+@@ -3721,6 +3722,70 @@ void tst_QTableView::resizeToContents()
+ 
+ }
+ 
++
++class SpanModel : public QAbstractTableModel
++{
++public:
++    SpanModel(bool sectionsMoved)
++        : _sectionsMoved(sectionsMoved)
++    {}
++    int columnCount(const QModelIndex & = {}) const override { return 2; }
++    int rowCount(const QModelIndex & = {}) const override { return 1; }
++    QVariant data(const QModelIndex &idx, int role = Qt::DisplayRole) const override
++    {
++        if (role != Qt::DisplayRole)
++            return QVariant();
++        const int col = _sectionsMoved ? 1 - idx.column() : idx.column();
++        if (col == 0)
++            return "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.";
++        return QVariant();
++    }
++private:
++    bool _sectionsMoved;
++};
++
++
++void tst_QTableView::resizeToContentsSpans()
++{
++    SpanModel model1(false);
++    SpanModel model2(true);
++    QTableView view1, view2, view3;
++    view1.setModel(&model1);
++    view2.setModel(&model2);
++    view2.horizontalHeader()->moveSection(0, 1);
++    view3.setModel(&model1);
++
++    view1.setSpan(0, 0, 1, 2);
++    view2.setSpan(0, 1, 1, 2);
++    view1.show();
++    view2.show();
++    view3.show();
++    QVERIFY(QTest::qWaitForWindowExposed(&view1));
++    QVERIFY(QTest::qWaitForWindowExposed(&view2));
++    QVERIFY(QTest::qWaitForWindowExposed(&view3));
++    view1.setColumnWidth(0, 100);
++    view1.setColumnWidth(1, 100);
++    view2.setColumnWidth(0, 100);
++    view2.setColumnWidth(1, 100);
++    view3.setColumnWidth(0, 200);
++
++    view1.resizeRowToContents(0);
++    view2.resizeRowToContents(0);
++    view3.resizeRowToContents(0);
++    QCOMPARE(view1.rowHeight(0), view3.rowHeight(0));
++    QCOMPARE(view2.rowHeight(0), view3.rowHeight(0));
++
++    view3.resizeColumnToContents(0);
++    view3.resizeRowToContents(0);
++    // height should be only 1 text line for easy testing
++    view1.setRowHeight(0, view3.verticalHeader()->sectionSize(0));
++    view2.setRowHeight(0, view3.verticalHeader()->sectionSize(0));
++    view1.resizeColumnToContents(0);
++    view2.resizeColumnToContents(1);
++    QCOMPARE(view1.columnWidth(0), view3.columnWidth(0) - view1.columnWidth(1));
++    QCOMPARE(view2.columnWidth(0), view3.columnWidth(0) - view2.columnWidth(1));
++}
++
+ QT_BEGIN_NAMESPACE
+ extern bool Q_WIDGETS_EXPORT qt_tab_all_widgets(); // qapplication.cpp
+ QT_END_NAMESPACE
+diff --git a/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+index a3b8ef78d8..4955cebd5d 100644
+--- a/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
++++ b/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+@@ -1498,7 +1498,7 @@ void tst_QApplication::desktopSettingsAware()
+     environment += QLatin1String("QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM=1");
+     testProcess.setEnvironment(environment);
+ #endif
+-    testProcess.start("desktopsettingsaware_helper");
++    testProcess.start("./desktopsettingsaware_helper");
+     QVERIFY2(testProcess.waitForStarted(),
+              qPrintable(QString::fromLatin1("Cannot start 'desktopsettingsaware_helper': %1").arg(testProcess.errorString())));
+     QVERIFY(testProcess.waitForFinished(10000));
+@@ -2452,7 +2452,7 @@ void tst_QApplication::qtbug_12673()
+ #if QT_CONFIG(process)
+     QProcess testProcess;
+     QStringList arguments;
+-    testProcess.start("modal_helper", arguments);
++    testProcess.start("./modal_helper", arguments);
+     QVERIFY2(testProcess.waitForStarted(),
+              qPrintable(QString::fromLatin1("Cannot start 'modal_helper': %1").arg(testProcess.errorString())));
+     QVERIFY(testProcess.waitForFinished(20000));
+diff --git a/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp b/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
+index eb108a40de..dca5528c1b 100644
+--- a/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
+@@ -41,6 +41,7 @@
+ 
+ #include <private/qguiapplication_p.h>
+ #include <qpa/qplatformintegration.h>
++#include <qpa/qplatformtheme.h>
+ 
+ class tst_QAbstractButton : public QObject
+ {
+@@ -76,6 +77,8 @@ private slots:
+     void keyNavigation();
+ #endif
+ 
++    void buttonPressKeys();
++
+ protected slots:
+     void onClicked();
+     void onToggled( bool on );
+@@ -269,7 +272,13 @@ void tst_QAbstractButton::setAutoRepeat()
+         QCOMPARE(press_count, click_count);
+         QVERIFY(click_count > 1);
+         break;
+-    case 4:
++    case 4: {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(Qt::Key_Enter)) {
++            QSKIP("platform theme has Key_Enter in ButtonPressKeys");
++        }
+         // check that pressing ENTER has no effect when autorepeat is false
+         testWidget->setDown( false );
+         testWidget->setAutoRepeat( false );
+@@ -286,7 +295,14 @@ void tst_QAbstractButton::setAutoRepeat()
+ 
+         QVERIFY( click_count == 0 );
+         break;
+-    case 5:
++    }
++    case 5: {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(Qt::Key_Enter)) {
++            QSKIP("platform theme has Key_Enter in ButtonPressKeys");
++        }
+         // check that pressing ENTER has no effect when autorepeat is true
+         testWidget->setDown( false );
+         testWidget->setAutoRepeat( true );
+@@ -304,6 +320,7 @@ void tst_QAbstractButton::setAutoRepeat()
+ 
+         QVERIFY( click_count == 0 );
+         break;
++    }
+     case 6:
+         // verify autorepeat is off by default.
+         MyButton tmp( 0);
+@@ -651,5 +668,16 @@ void tst_QAbstractButton::keyNavigation()
+ }
+ #endif
+ 
++void tst_QAbstractButton::buttonPressKeys()
++{
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(testWidget, buttonPressKeys[i]);
++        QCOMPARE(click_count, i + 1);
++    }
++}
++
+ QTEST_MAIN(tst_QAbstractButton)
+ #include "tst_qabstractbutton.moc"
+diff --git a/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+index 32437050f5..46b5af6d63 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+@@ -168,6 +168,7 @@ private slots:
+     void checkMenuItemPosWhenStyleSheetIsSet();
+     void checkEmbeddedLineEditWhenStyleSheetIsSet();
+     void propagateStyleChanges();
++    void buttonPressKeys();
+ 
+ private:
+     PlatformInputContext m_platformInputContext;
+@@ -1682,6 +1683,16 @@ void tst_QComboBox::setModel()
+     QCOMPARE(box.rootModelIndex(), rootModelIndex);
+     box.setModel(box.model());
+     QCOMPARE(box.rootModelIndex(), rootModelIndex);
++
++    // check that setting the same model as the completer's doesn't crash
++    QCompleter *completer = new QCompleter(&box);
++    box.setEditable(true);
++    box.setCompleter(completer);
++    auto *listModel = new QStringListModel({ "one", "two" }, completer);
++    completer->setModel(listModel);
++    QCOMPARE(listModel->rowCount(), 2); // make sure it wasn't deleted
++    box.setModel(listModel);
++    QCOMPARE(listModel->rowCount(), 2); // make sure it wasn't deleted
+ }
+ 
+ void tst_QComboBox::setCustomModelAndView()
+@@ -3632,5 +3643,24 @@ void tst_QComboBox::propagateStyleChanges()
+     QVERIFY(frameStyle.inquired);
+ }
+ 
++void tst_QComboBox::buttonPressKeys()
++{
++    QComboBox comboBox;
++    comboBox.setEditable(false);
++    comboBox.addItem(QString::number(1));
++    comboBox.addItem(QString::number(2));
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(&comboBox, buttonPressKeys[i]);
++        // On some platforms, a window will not be immediately visible,
++        // but take some event-loop iterations to complete.
++        // Using QTRY_VERIFY to deal with that.
++        QTRY_VERIFY(comboBox.view()->isVisible());
++        comboBox.hidePopup();
++    }
++}
++
+ QTEST_MAIN(tst_QComboBox)
+ #include "tst_qcombobox.moc"
+diff --git a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
+index be3cfcd104..c228fdfcca 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
++++ b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qcommandlinkbutton
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qcommandlinkbutton.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
+index 0044d33c66..4cf06296e4 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
+@@ -40,6 +40,9 @@
+ #include <QGridLayout>
+ #include <QPainter>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ class tst_QCommandLinkButton : public QObject
+ {
+     Q_OBJECT
+@@ -223,6 +226,13 @@ void tst_QCommandLinkButton::setAutoRepeat()
+     // check that pressing ENTER has no effect
+     resetCounters();
+     testWidget->setDown( false );
++    // Skip after reset if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
+     testWidget->setAutoRepeat( false );
+     QTest::keyPress( testWidget, Qt::Key_Enter );
+ 
+@@ -255,6 +265,14 @@ void tst_QCommandLinkButton::pressed()
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+ 
++    // Skip if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
++
+     QTest::keyPress( testWidget,Qt::Key_Enter );
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+diff --git a/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro b/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
+index 4a5e76ff65..a235fa1fac 100644
+--- a/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
++++ b/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qgroupbox
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qgroupbox.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp b/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
+index 4fb5d262ca..d8d7562b73 100644
+--- a/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
+@@ -35,6 +35,9 @@
+ #include <QRadioButton>
+ #include <QDialog>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ #include "qgroupbox.h"
+ 
+ class tst_QGroupBox : public QObject
+@@ -69,6 +72,7 @@ private slots:
+     void propagateFocus();
+     void task_QTBUG_19170_ignoreMouseReleaseEvent();
+     void task_QTBUG_15519_propagateMouseEvents();
++    void buttonPressKeys();
+ 
+ private:
+     bool checked;
+@@ -610,6 +614,20 @@ void tst_QGroupBox::task_QTBUG_15519_propagateMouseEvents()
+     QCOMPARE(parent.mouseMoved, true);
+ }
+ 
++void tst_QGroupBox::buttonPressKeys()
++{
++    QGroupBox groupBox;
++    groupBox.setCheckable(true);
++    QSignalSpy clickedSpy(&groupBox, &QGroupBox::clicked);
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(&groupBox, buttonPressKeys[i]);
++        QCOMPARE(clickedSpy.length(), i + 1);
++    }
++}
++
+ void tst_QGroupBox::sendMouseMoveEvent(QWidget *widget, const QPoint &localPos)
+ {
+     // Send a MouseMove event without actually moving the pointer
+diff --git a/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro b/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
+index 353ad06ca2..e55f6148f2 100644
+--- a/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
++++ b/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qpushbutton
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qpushbutton.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp b/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
+index e818514a79..4043e9326a 100644
+--- a/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
+@@ -41,6 +41,9 @@
+ #include <QStyleFactory>
+ #include <QTabWidget>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ class tst_QPushButton : public QObject
+ {
+ Q_OBJECT
+@@ -212,6 +215,13 @@ void tst_QPushButton::autoRepeat()
+     // check that pressing ENTER has no effect
+     resetCounters();
+     testWidget->setDown( false );
++    // Skip after reset if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
+     testWidget->setAutoRepeat( false );
+     QTest::keyPress( testWidget, Qt::Key_Enter );
+ 
+@@ -247,6 +257,14 @@ void tst_QPushButton::pressed()
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+ 
++    // Skip if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
++
+     QTest::keyPress( testWidget,Qt::Key_Enter );
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+diff --git a/qtbase/tests/manual/rhi/cubemap_render/buildshader.bat b/qtbase/tests/manual/rhi/cubemap_render/buildshader.bat
+old mode 100755
+new mode 100644
+Submodule qtconnectivity e957d481..056294c0:
+diff --git a/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp b/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
+index e2635fae..a8b8e3b9 100644
+--- a/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
++++ b/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
+@@ -563,9 +563,11 @@ void HciManager::handleHciAclPacket(const quint8 *data, int size)
+ 
+ void HciManager::handleLeMetaEvent(const quint8 *data)
+ {
+-    // Spec v4.2, Vol 2, part E, 7.7.65ff
++    // Spec v5.3, Vol 4, part E, 7.7.65.*
+     switch (*data) {
+-    case 0x1: {
++    case 0x1: // HCI_LE_Connection_Complete
++    case 0xA: // HCI_LE_Enhanced_Connection_Complete
++    {
+         const quint16 handle = bt_get_le16(data + 2);
+         emit connectionComplete(handle);
+         break;
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp b/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
+index 6a93143b..4a18cfc7 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
+@@ -320,7 +320,10 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_finishSdpScan(QBluetoothServiceD
+             for (const QBluetoothUuid &id : serviceClassUuids) {
+                 if (id.minimumSize() == 16) {
+                     serviceInfo.setServiceUuid(id);
+-                    serviceInfo.setServiceName(QBluetoothServiceDiscoveryAgent::tr("Custom Service"));
++                    if (serviceInfo.serviceName().isEmpty()) {
++                        serviceInfo.setServiceName(
++                                    QBluetoothServiceDiscoveryAgent::tr("Custom Service"));
++                    }
+                     QBluetoothServiceInfo::Sequence modSeq =
+                             serviceInfo.attribute(QBluetoothServiceInfo::ServiceClassIds).value<QBluetoothServiceInfo::Sequence>();
+                     modSeq.removeOne(QVariant::fromValue(id));
+@@ -334,8 +337,10 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_finishSdpScan(QBluetoothServiceD
+                 qCDebug(QT_BT_BLUEZ) << "Discovered services" << discoveredDevices.at(0).address().toString()
+                                      << serviceInfo.serviceName() << serviceInfo.serviceUuid()
+                                      << ">>>" << serviceInfo.serviceClassUuids();
+-
+-                emit q->serviceDiscovered(serviceInfo);
++                // Use queued connection to allow us finish the service looping; the application
++                // might call stop() when it has detected the service-of-interest.
++                QMetaObject::invokeMethod(q, "serviceDiscovered", Qt::QueuedConnection,
++                                          Q_ARG(QBluetoothServiceInfo, serviceInfo));
+             }
+         }
+     }
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp b/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
+index e4d85447..aadd4755 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
+@@ -593,7 +593,7 @@ void QBluetoothSocket::setSocketState(QBluetoothSocket::SocketState state)
+ bool QBluetoothSocket::canReadLine() const
+ {
+     Q_D(const QBluetoothSocketBase);
+-    return d->canReadLine();
++    return d->canReadLine() || QIODevice::canReadLine();
+ }
+ 
+ /*!
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp b/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
+index 084aa958..d6aa17a7 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
+@@ -284,6 +284,10 @@ void QBluetoothSocketPrivateBluezDBus::connectToService(
+         return;
+     }
+ 
++    if (service.socketProtocol() != QBluetoothServiceInfo::Protocol::UnknownProtocol)
++        socketType = service.socketProtocol();
++    qCDebug(QT_BT_BLUEZ) << "Socket protocol used:" << socketType;
++
+     connectToService(service.device().address(), targetService, openMode);
+ }
+ 
+diff --git a/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp b/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
+index 05bc1a0f..a7b5ef1f 100644
+--- a/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
++++ b/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
+@@ -142,7 +142,7 @@ void tst_QBluetoothSocket::initTestCase()
+     qDebug() << "Starting discovery";
+ 
+     sda->setUuidFilter(QBluetoothUuid(QString(TEST_SERVICE_UUID)));
+-    sda->start(QBluetoothServiceDiscoveryAgent::MinimalDiscovery);
++    sda->start(QBluetoothServiceDiscoveryAgent::FullDiscovery);
+ 
+     for (int connectTime = MaxConnectTime; !done_discovery && connectTime > 0; connectTime -= 1000)
+         QTest::qWait(1000);
+Submodule qtdeclarative f5701f0d..8defe7bf:
+diff --git a/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h b/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
+index b65b994d6c..15a8cd6878 100644
+--- a/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
++++ b/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
+@@ -86,7 +86,7 @@ public:
+         if (QTypeInfo<T>::isComplex) {
+             for (int i = 0; i < count; ++i)
+                 new (data + i) T(vector.at(i));
+-        } else {
++        } else if (count) {
+             memcpy(data, static_cast<const void*>(vector.constData()), count * sizeof(T));
+         }
+     }
+diff --git a/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp b/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
+index e57cdd8278..94613598af 100644
+--- a/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
++++ b/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
+@@ -1145,8 +1145,7 @@ void Heap::QObjectWrapper::markObjects(Heap::Base *that, QV4::MarkStack *markSta
+ void QObjectWrapper::destroyObject(bool lastCall)
+ {
+     Heap::QObjectWrapper *h = d();
+-    if (!h->internalClass)
+-        return; // destroyObject already got called
++    Q_ASSERT(h->internalClass);
+ 
+     if (h->object()) {
+         QQmlData *ddata = QQmlData::get(h->object(), false);
+@@ -1176,7 +1175,7 @@ void QObjectWrapper::destroyObject(bool lastCall)
+         }
+     }
+ 
+-    h->~Data();
++    h->destroy();
+ }
+ 
+ 
+diff --git a/qtdeclarative/src/qml/memory/qv4mm.cpp b/qtdeclarative/src/qml/memory/qv4mm.cpp
+index 06caf04e5a..da149a67c4 100644
+--- a/qtdeclarative/src/qml/memory/qv4mm.cpp
++++ b/qtdeclarative/src/qml/memory/qv4mm.cpp
+@@ -981,7 +981,7 @@ void MemoryManager::sweep(bool lastSweep, ClassDestroyStatsCallback classCountPt
+ 
+     if (MultiplyWrappedQObjectMap *multiplyWrappedQObjects = engine->m_multiplyWrappedQObjects) {
+         for (MultiplyWrappedQObjectMap::Iterator it = multiplyWrappedQObjects->begin(); it != multiplyWrappedQObjects->end();) {
+-            if (!it.value().isNullOrUndefined())
++            if (it.value().isNullOrUndefined())
+                 it = multiplyWrappedQObjects->erase(it);
+             else
+                 ++it;
+diff --git a/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp b/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
+index 2079a8ed04..a577cb2351 100644
+--- a/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
++++ b/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
+@@ -389,6 +389,12 @@ void QQmlDelegateModelPrivate::connectToAbstractItemModel()
+                       q,  QQmlDelegateModel, SLOT(_q_rowsRemoved(QModelIndex,int,int)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
+                       q,  QQmlDelegateModel, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsInserted(QModelIndex,int,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsInserted(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsRemoved(QModelIndex,int,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsRemoved(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsMoved(QModelIndex,int,int,QModelIndex,int)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
+                       q, QQmlDelegateModel, SLOT(_q_dataChanged(QModelIndex,QModelIndex,QVector<int>)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
+@@ -413,6 +419,12 @@ void QQmlDelegateModelPrivate::disconnectFromAbstractItemModel()
+                         q, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int)));
+     QObject::disconnect(aim, SIGNAL(rowsRemoved(QModelIndex,int,int)),
+                         q, SLOT(_q_rowsRemoved(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsInserted(QModelIndex,int,int)), q,
++                        SLOT(_q_columnsInserted(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsRemoved(QModelIndex,int,int)), q,
++                        SLOT(_q_columnsRemoved(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)), q,
++                        SLOT(_q_columnsMoved(QModelIndex,int,int,QModelIndex,int)));
+     QObject::disconnect(aim, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
+                         q, SLOT(_q_dataChanged(QModelIndex,QModelIndex,QVector<int>)));
+     QObject::disconnect(aim, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
+@@ -1973,6 +1985,38 @@ void QQmlDelegateModel::_q_rowsMoved(
+     }
+ }
+ 
++void QQmlDelegateModel::_q_columnsInserted(const QModelIndex &parent, int begin, int end)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if (parent == d->m_adaptorModel.rootIndex && begin == 0) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
++void QQmlDelegateModel::_q_columnsRemoved(const QModelIndex &parent, int begin, int end)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if (parent == d->m_adaptorModel.rootIndex && begin == 0) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
++void QQmlDelegateModel::_q_columnsMoved(const QModelIndex &parent, int start, int end,
++                                        const QModelIndex &destination, int column)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if ((parent == d->m_adaptorModel.rootIndex && start == 0)
++        || (destination == d->m_adaptorModel.rootIndex && column == 0)) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
+ void QQmlDelegateModel::_q_dataChanged(const QModelIndex &begin, const QModelIndex &end, const QVector<int> &roles)
+ {
+     Q_D(QQmlDelegateModel);
+diff --git a/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h b/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
+index 8aab4badca..d140bfbaaf 100644
+--- a/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
++++ b/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
+@@ -152,6 +152,9 @@ private Q_SLOTS:
+     void _q_itemsMoved(int from, int to, int count);
+     void _q_modelReset();
+     void _q_rowsInserted(const QModelIndex &,int,int);
++    void _q_columnsInserted(const QModelIndex &, int, int);
++    void _q_columnsRemoved(const QModelIndex &, int, int);
++    void _q_columnsMoved(const QModelIndex &, int, int, const QModelIndex &, int);
+     void _q_rowsAboutToBeRemoved(const QModelIndex &parent, int begin, int end);
+     void _q_rowsRemoved(const QModelIndex &,int,int);
+     void _q_rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int);
+diff --git a/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp b/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
+index 85719fdc80..78e2ab302c 100644
+--- a/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
++++ b/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
+@@ -46,6 +46,7 @@
+ #include "QtQuick/private/qquicktextinput_p.h"
+ #include "QtQuick/private/qquickaccessibleattached_p.h"
+ #include "QtQuick/qquicktextdocument.h"
++#include "QtQuick/qquickrendercontrol.h"
+ QT_BEGIN_NAMESPACE
+ 
+ #if QT_CONFIG(accessibility)
+@@ -57,7 +58,19 @@ QAccessibleQuickItem::QAccessibleQuickItem(QQuickItem *item)
+ 
+ QWindow *QAccessibleQuickItem::window() const
+ {
+-    return item()->window();
++    QQuickWindow *window = item()->window();
++
++    // For QQuickWidget the above window will be the offscreen QQuickWindow,
++    // which is not a part of the accessibility tree. Detect this case and
++    // return the window for the QQuickWidget instead.
++    if (window && !window->handle()) {
++        if (QQuickRenderControl *renderControl = QQuickWindowPrivate::get(window)->renderControl) {
++            if (QWindow *renderWindow = renderControl->renderWindow(nullptr))
++                return renderWindow;
++        }
++    }
++
++    return window;
+ }
+ 
+ int QAccessibleQuickItem::childCount() const
+@@ -113,19 +126,15 @@ QAccessibleInterface *QAccessibleQuickItem::childAt(int x, int y) const
+ QAccessibleInterface *QAccessibleQuickItem::parent() const
+ {
+     QQuickItem *parent = item()->parentItem();
+-    QQuickWindow *window = item()->window();
+-    QQuickItem *ci = window ? window->contentItem() : nullptr;
++    QQuickWindow *itemWindow = item()->window();
++    QQuickItem *ci = itemWindow ? itemWindow->contentItem() : nullptr;
+     while (parent && !QQuickItemPrivate::get(parent)->isAccessible && parent != ci)
+         parent = parent->parentItem();
+ 
+     if (parent) {
+         if (parent == ci) {
+-            // Jump out to the scene widget if the parent is the root item.
+-            // There are two root items, QQuickWindow::rootItem and
+-            // QQuickView::declarativeRoot. The former is the true root item,
+-            // but is not a part of the accessibility tree. Check if we hit
+-            // it here and return an interface for the scene instead.
+-            return QAccessible::queryAccessibleInterface(window);
++            // Jump out to the window if the parent is the root item
++            return QAccessible::queryAccessibleInterface(window());
+         } else {
+             while (parent && !parent->d_func()->isAccessible)
+                 parent = parent->parentItem();
+@@ -188,7 +197,7 @@ QAccessible::State QAccessibleQuickItem::state() const
+     QRect viewRect_ = viewRect();
+     QRect itemRect = rect();
+ 
+-    if (viewRect_.isNull() || itemRect.isNull() || !item()->window() || !item()->window()->isVisible() ||!item()->isVisible() || qFuzzyIsNull(item()->opacity()))
++    if (viewRect_.isNull() || itemRect.isNull() || !window() || !window()->isVisible() ||!item()->isVisible() || qFuzzyIsNull(item()->opacity()))
+         state.invisible = true;
+     if (!viewRect_.intersects(itemRect))
+         state.offscreen = true;
+@@ -201,6 +210,10 @@ QAccessible::State QAccessibleQuickItem::state() const
+     if (role() == QAccessible::EditableText)
+         if (auto ti = qobject_cast<QQuickTextInput *>(item()))
+             state.passwordEdit = ti->echoMode() != QQuickTextInput::Normal;
++    if (!item()->isEnabled()) {
++        state.focusable = false;
++        state.disabled = true;
++    }
+     return state;
+ }
+ 
+diff --git a/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h b/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
+index 39ffcaf39c..8baa01330c 100644
+--- a/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
++++ b/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
+@@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE
+ 
+ #if QT_CONFIG(accessibility)
+ 
+-class QAccessibleQuickWindow : public QAccessibleObject
++class Q_QUICK_EXPORT QAccessibleQuickWindow : public QAccessibleObject
+ {
+ public:
+     QAccessibleQuickWindow(QQuickWindow *object);
+diff --git a/qtdeclarative/src/quick/items/qquickdrag.cpp b/qtdeclarative/src/quick/items/qquickdrag.cpp
+index 8321fcfeed..383078b3b9 100644
+--- a/qtdeclarative/src/quick/items/qquickdrag.cpp
++++ b/qtdeclarative/src/quick/items/qquickdrag.cpp
+@@ -481,7 +481,9 @@ void QQuickDragAttached::setKeys(const QStringList &keys)
+     \qmlattachedproperty stringlist QtQuick::Drag::mimeData
+     \since 5.2
+ 
+-    This property holds a map of mimeData that is used during startDrag.
++    This property holds a map from mime type to data that is used during startDrag.
++    The mime data needs to be a \c string, or an \c ArrayBuffer with the data encoded
++    according to the mime type.
+ */
+ 
+ QVariantMap QQuickDragAttached::mimeData() const
+@@ -766,8 +768,12 @@ Qt::DropAction QQuickDragAttachedPrivate::startDrag(Qt::DropActions supportedAct
+     QDrag *drag = new QDrag(source ? source : q);
+     QMimeData *mimeData = new QMimeData();
+ 
+-    for (auto it = externalMimeData.cbegin(), end = externalMimeData.cend(); it != end; ++it)
+-        mimeData->setData(it.key(), it.value().toString().toUtf8());
++    for (auto it = externalMimeData.cbegin(), end = externalMimeData.cend(); it != end; ++it) {
++        if (static_cast<QMetaType::Type>(it.value().type()) == QMetaType::QByteArray)
++            mimeData->setData(it.key(), it.value().toByteArray());
++        else
++            mimeData->setData(it.key(), it.value().toString().toUtf8());
++    }
+ 
+     drag->setMimeData(mimeData);
+     if (pixmapLoader.isReady()) {
+diff --git a/qtdeclarative/src/quick/items/qquickitem.cpp b/qtdeclarative/src/quick/items/qquickitem.cpp
+index 75f1457816..dec0ae19ae 100644
+--- a/qtdeclarative/src/quick/items/qquickitem.cpp
++++ b/qtdeclarative/src/quick/items/qquickitem.cpp
+@@ -59,6 +59,7 @@
+ #include <QtCore/private/qnumeric_p.h>
+ #include <QtGui/qpa/qplatformtheme.h>
+ #include <QtCore/qloggingcategory.h>
++#include <QtCore/private/qduplicatetracker_p.h>
+ 
+ #include <private/qqmlglobal_p.h>
+ #include <private/qqmlengine_p.h>
+@@ -2326,6 +2327,7 @@ QQuickItem::QQuickItem(QQuickItemPrivate &dd, QQuickItem *parent)
+ QQuickItem::~QQuickItem()
+ {
+     Q_D(QQuickItem);
++    d->inDestructor = true;
+ 
+     if (d->windowRefCount > 1)
+         d->windowRefCount = 1; // Make sure window is set to null in next call to derefWindow().
+@@ -2526,6 +2528,7 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo
+     QQuickItem *current = item;
+     qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: startItem:" << startItem;
+     qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: firstFromItem:" << firstFromItem;
++    QDuplicateTracker<QQuickItem *> cycleDetector;
+     do {
+         qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: current:" << current;
+         qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: from:" << from;
+@@ -2592,7 +2595,10 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo
+         // traversed all of the chain (by compare the [current] item with [startItem])
+         // Since the [startItem] might be promoted to its parent if it is invisible,
+         // we still have to check [current] item with original start item
+-        if ((current == startItem || current == originalStartItem) && from == firstFromItem) {
++        // We might also run into a cycle before we reach firstFromItem again
++        // but note that we have to ignore current if we are meant to skip it
++        if (((current == startItem || current == originalStartItem) && from == firstFromItem) ||
++                (!skip && cycleDetector.hasSeen(current))) {
+             // wrapped around, avoid endless loops
+             if (item == contentItem) {
+                 qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: looped, return contentItem";
+@@ -2689,9 +2695,8 @@ void QQuickItem::setParentItem(QQuickItem *parentItem)
+ 
+         const bool wasVisible = isVisible();
+         op->removeChild(this);
+-        if (wasVisible) {
++        if (wasVisible && !op->inDestructor)
+             emit oldParentItem->visibleChildrenChanged();
+-        }
+     } else if (d->window) {
+         QQuickWindowPrivate::get(d->window)->parentlessItems.remove(this);
+     }
+@@ -2768,8 +2773,9 @@ void QQuickItem::setParentItem(QQuickItem *parentItem)
+ 
+     d->itemChange(ItemParentHasChanged, d->parentItem);
+ 
+-    emit parentChanged(d->parentItem);
+-    if (isVisible() && d->parentItem)
++    if (!d->inDestructor)
++        emit parentChanged(d->parentItem);
++    if (isVisible() && d->parentItem && !QQuickItemPrivate::get(d->parentItem)->inDestructor)
+         emit d->parentItem->visibleChildrenChanged();
+ }
+ 
+@@ -2965,7 +2971,8 @@ void QQuickItemPrivate::removeChild(QQuickItem *child)
+ 
+     itemChange(QQuickItem::ItemChildRemovedChange, child);
+ 
+-    emit q->childrenChanged();
++    if (!inDestructor)
++        emit q->childrenChanged();
+ }
+ 
+ void QQuickItemPrivate::refWindow(QQuickWindow *c)
+@@ -3194,6 +3201,7 @@ QQuickItemPrivate::QQuickItemPrivate()
+     , touchEnabled(false)
+ #endif
+     , hasCursorHandler(false)
++    , inDestructor(false)
+     , dirtyAttributes(0)
+     , nextDirtyItem(nullptr)
+     , prevDirtyItem(nullptr)
+@@ -5120,6 +5128,13 @@ void QQuickItem::componentComplete()
+         d->addToDirtyList();
+         QQuickWindowPrivate::get(d->window)->dirtyItem(this);
+     }
++
++#if QT_CONFIG(accessibility)
++    if (d->isAccessible && d->effectiveVisible) {
++        QAccessibleEvent ev(this, QAccessible::ObjectShow);
++        QAccessible::updateAccessibility(&ev);
++    }
++#endif
+ }
+ 
+ QQuickStateGroup *QQuickItemPrivate::_states()
+@@ -6106,9 +6121,11 @@ bool QQuickItemPrivate::setEffectiveVisibleRecur(bool newEffectiveVisible)
+         QAccessible::updateAccessibility(&ev);
+     }
+ #endif
+-    emit q->visibleChanged();
+-    if (childVisibilityChanged)
+-        emit q->visibleChildrenChanged();
++    if (!inDestructor) {
++        emit q->visibleChanged();
++        if (childVisibilityChanged)
++            emit q->visibleChildrenChanged();
++    }
+ 
+     return true;    // effective visibility DID change
+ }
+@@ -6157,6 +6174,15 @@ void QQuickItemPrivate::setEffectiveEnableRecur(QQuickItem *scope, bool newEffec
+     }
+ 
+     itemChange(QQuickItem::ItemEnabledHasChanged, effectiveEnable);
++#if QT_CONFIG(accessibility)
++    if (isAccessible) {
++        QAccessible::State changedState;
++        changedState.disabled = true;
++        changedState.focusable = true;
++        QAccessibleStateChangeEvent ev(q, changedState);
++        QAccessible::updateAccessibility(&ev);
++    }
++#endif
+     emit q->enabledChanged();
+ }
+ 
+diff --git a/qtdeclarative/src/quick/items/qquickitem_p.h b/qtdeclarative/src/quick/items/qquickitem_p.h
+index 841d91bb40..ade8fb61f2 100644
+--- a/qtdeclarative/src/quick/items/qquickitem_p.h
++++ b/qtdeclarative/src/quick/items/qquickitem_p.h
+@@ -472,6 +472,7 @@ public:
+     bool replayingPressEvent:1;
+     bool touchEnabled:1;
+     bool hasCursorHandler:1;
++    quint32 inDestructor:1; // has entered ~QQuickItem
+ 
+     enum DirtyType {
+         TransformOrigin         = 0x00000001,
+diff --git a/qtdeclarative/src/quick/items/qquickitemview.cpp b/qtdeclarative/src/quick/items/qquickitemview.cpp
+index 010a0152e1..f8ad168a17 100644
+--- a/qtdeclarative/src/quick/items/qquickitemview.cpp
++++ b/qtdeclarative/src/quick/items/qquickitemview.cpp
+@@ -1785,7 +1785,7 @@ void QQuickItemViewPrivate::refill(qreal from, qreal to)
+ 
+     do {
+         bufferPause.stop();
+-        if (currentChanges.hasPendingChanges() || bufferedChanges.hasPendingChanges()) {
++        if (currentChanges.hasPendingChanges() || bufferedChanges.hasPendingChanges() || currentChanges.active) {
+             currentChanges.reset();
+             bufferedChanges.reset();
+             releaseVisibleItems(reusableFlag);
+diff --git a/qtdeclarative/src/quick/items/qquickmousearea_p_p.h b/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
+index fba383e268..0d63618622 100644
+--- a/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
++++ b/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
+@@ -61,7 +61,6 @@ QT_BEGIN_NAMESPACE
+ 
+ class QQuickMouseEvent;
+ class QQuickMouseArea;
+-class QQuickPointerMask;
+ class QQuickMouseAreaPrivate : public QQuickItemPrivate
+ {
+     Q_DECLARE_PUBLIC(QQuickMouseArea)
+@@ -100,7 +99,6 @@ public:
+ #if QT_CONFIG(quick_draganddrop)
+     QQuickDrag *drag;
+ #endif
+-    QPointer<QQuickPointerMask> mask;
+     QPointF startScene;
+     QPointF targetStartPos;
+     QPointF lastPos;
+diff --git a/qtdeclarative/src/quick/items/qquicktext.cpp b/qtdeclarative/src/quick/items/qquicktext.cpp
+index 6230186933..e823ca1095 100644
+--- a/qtdeclarative/src/quick/items/qquicktext.cpp
++++ b/qtdeclarative/src/quick/items/qquicktext.cpp
+@@ -2168,7 +2168,7 @@ void QQuickText::resetMaximumLineCount()
+     <img src="" align="top,middle,bottom" width="" height=""> - inline images
+     <ol type="">, <ul type=""> and <li> - ordered and unordered lists
+     <pre></pre> - preformatted
+-    &gt; &lt; &amp;
++    &gt; &lt; &amp; &quot; &nbsp; &apos;
+     \endcode
+ 
+     \c Text.StyledText parser is strict, requiring tags to be correctly nested.
+diff --git a/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp b/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
+index eb4db0f85e..2325a2665b 100644
+--- a/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
++++ b/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
+@@ -446,7 +446,7 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+         const char *textureRecord = allocatorData;
+         for (int i = 0; i < textureCount; ++i, textureRecord += Qtdf::TextureRecordSize) {
+-            if (textureRecord + Qtdf::TextureRecordSize > qtdfTableEnd) {
++            if (qtdfTableEnd - textureRecord < Qtdf::TextureRecordSize) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+@@ -462,7 +462,7 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+         const char *glyphRecord = textureRecord;
+         for (quint32 i = 0; i < glyphCount; ++i, glyphRecord += Qtdf::GlyphRecordSize) {
+-            if (glyphRecord + Qtdf::GlyphRecordSize > qtdfTableEnd) {
++            if (qtdfTableEnd - glyphRecord < Qtdf:: GlyphRecordSize) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+@@ -512,8 +512,8 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+             int width = texInfo->allocatedArea.width();
+             int height = texInfo->allocatedArea.height();
+-            qint64 size = width * height;
+-            if (reinterpret_cast<const char *>(textureData + size) > qtdfTableEnd) {
++            qint64 size = qint64(width) * height;
++            if (qtdfTableEnd - reinterpret_cast<const char *>(textureData) < size) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+diff --git a/qtdeclarative/src/quick/util/qquickstyledtext.cpp b/qtdeclarative/src/quick/util/qquickstyledtext.cpp
+index d531fc9205..a25af90414 100644
+--- a/qtdeclarative/src/quick/util/qquickstyledtext.cpp
++++ b/qtdeclarative/src/quick/util/qquickstyledtext.cpp
+@@ -564,6 +564,8 @@ void QQuickStyledTextPrivate::parseEntity(const QChar *&ch, const QString &textI
+                 textOut += QChar(60);
+             else if (entity == QLatin1String("amp"))
+                 textOut += QChar(38);
++            else if (entity == QLatin1String("apos"))
++                textOut += QChar(39);
+             else if (entity == QLatin1String("quot"))
+                 textOut += QChar(34);
+             else if (entity == QLatin1String("nbsp"))
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp
+new file mode 100644
+index 0000000000..8a1c901880
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp
+@@ -0,0 +1,110 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include "qaccessiblequickwidget_p.h"
++
++#include "qquickwidget_p.h"
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleQuickWidget::QAccessibleQuickWidget(QQuickWidget* widget)
++: QAccessibleWidget(widget)
++, m_accessibleWindow(QQuickWidgetPrivate::get(widget)->offscreenWindow)
++{
++    // NOTE: m_accessibleWindow is a QAccessibleQuickWindow, and not a
++    // QAccessibleQuickWidgetOffscreenWindow (defined below). This means
++    // it will return the Quick item child interfaces, which is what's needed here
++    // (unlike QAccessibleQuickWidgetOffscreenWindow, which will report 0 children).
++}
++
++QAccessibleInterface *QAccessibleQuickWidget::child(int index) const
++{
++    return m_accessibleWindow.child(index);
++}
++
++int QAccessibleQuickWidget::childCount() const
++{
++    return m_accessibleWindow.childCount();
++}
++
++int QAccessibleQuickWidget::indexOfChild(const QAccessibleInterface *iface) const
++{
++    return m_accessibleWindow.indexOfChild(iface);
++}
++
++QAccessibleInterface *QAccessibleQuickWidget::childAt(int x, int y) const
++{
++    return m_accessibleWindow.childAt(x, y);
++}
++
++QAccessibleQuickWidgetOffscreenWindow::QAccessibleQuickWidgetOffscreenWindow(QQuickWindow *window)
++:QAccessibleQuickWindow(window)
++{
++
++}
++
++QAccessibleInterface *QAccessibleQuickWidgetOffscreenWindow::child(int index) const
++{
++    Q_UNUSED(index);
++    return nullptr;
++}
++
++int QAccessibleQuickWidgetOffscreenWindow::childCount() const
++{
++    return 0;
++}
++
++int QAccessibleQuickWidgetOffscreenWindow::indexOfChild(const QAccessibleInterface *iface) const
++{
++    Q_UNUSED(iface);
++    return -1;
++}
++
++QAccessibleInterface *QAccessibleQuickWidgetOffscreenWindow::QAccessibleQuickWidgetOffscreenWindow::childAt(int x, int y) const
++{
++    Q_UNUSED(x);
++    Q_UNUSED(y);
++    return nullptr;
++}
++
++#endif // accessibility
++
++QT_END_NAMESPACE
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h
+new file mode 100644
+index 0000000000..7c2ab930e0
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h
+@@ -0,0 +1,95 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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 QACCESSIBLEQUICKWIDGET_H
++#define QACCESSIBLEQUICKWIDGET_H
++
++//
++//  W A R N I N G
++//  -------------
++//
++// This file is not part of the Qt API.  It exists purely as an
++// implementation detail.  This header file may change from version to
++// version without notice, or even be removed.
++//
++// We mean it.
++//
++
++#include "qquickwidget.h"
++#include <QtWidgets/qaccessiblewidget.h>
++
++#include <private/qaccessiblequickview_p.h>
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++// These classes implement the QQuickWiget accessibility switcharoo,
++// where the child items of the QQuickWidgetOffscreenWindow are reported
++// as child accessible interfaces of the QAccessibleQuickWidget.
++class QAccessibleQuickWidget: public QAccessibleWidget
++{
++public:
++    QAccessibleQuickWidget(QQuickWidget* widget);
++
++    QAccessibleInterface *child(int index) const override;
++    int childCount() const override;
++    int indexOfChild(const QAccessibleInterface *iface) const override;
++    QAccessibleInterface *childAt(int x, int y) const override;
++
++private:
++    QAccessibleQuickWindow m_accessibleWindow;
++    Q_DISABLE_COPY(QAccessibleQuickWidget)
++};
++
++class QAccessibleQuickWidgetOffscreenWindow: public QAccessibleQuickWindow
++{
++public:
++    QAccessibleQuickWidgetOffscreenWindow(QQuickWindow *window);
++    QAccessibleInterface *child(int index) const override;
++    int childCount() const override;
++    int indexOfChild(const QAccessibleInterface *iface) const override;
++    QAccessibleInterface *childAt(int x, int y) const override;
++};
++
++#endif // accessibility
++
++QT_END_NAMESPACE
++
++#endif
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp
+new file mode 100644
+index 0000000000..7ba88a1769
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp
+@@ -0,0 +1,60 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include "qaccessiblequickwidgetfactory_p.h"
++#include "qaccessiblequickwidget_p.h"
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleInterface *qAccessibleQuickWidgetFactory(const QString &classname, QObject *object)
++{
++    if (classname == QLatin1String("QQuickWidget")) {
++        return new QAccessibleQuickWidget(qobject_cast<QQuickWidget *>(object));
++    } else if (classname == QLatin1String("QQuickWidgetOffscreenWindow")) {
++        return new QAccessibleQuickWidgetOffscreenWindow(qobject_cast<QQuickWindow *>(object));
++    }
++    return 0;
++}
++
++#endif // accessibility
++
++QT_END_NAMESPACE
++
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h
+new file mode 100644
+index 0000000000..8c63b09f81
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h
+@@ -0,0 +1,66 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include <QtGui/qaccessible.h>
++
++#ifndef QACCESSIBLEQUICKWIDGETFACTORY_H
++#define QACCESSIBLEQUICKWIDGETFACTORY_H
++
++//
++//  W A R N I N G
++//  -------------
++//
++// This file is not part of the Qt API.  It exists purely as an
++// implementation detail.  This header file may change from version to
++// version without notice, or even be removed.
++//
++// We mean it.
++//
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleInterface *qAccessibleQuickWidgetFactory(const QString &classname, QObject *object);
++
++#endif
++
++QT_END_NAMESPACE
++
++#endif
+diff --git a/qtdeclarative/src/quickwidgets/qquickwidget.cpp b/qtdeclarative/src/quickwidgets/qquickwidget.cpp
+index 39780f8de3..9c97b43518 100644
+--- a/qtdeclarative/src/quickwidgets/qquickwidget.cpp
++++ b/qtdeclarative/src/quickwidgets/qquickwidget.cpp
+@@ -39,6 +39,7 @@
+ 
+ #include "qquickwidget.h"
+ #include "qquickwidget_p.h"
++#include "qaccessiblequickwidgetfactory_p.h"
+ 
+ #include "private/qquickwindow_p.h"
+ #include "private/qquickitem_p.h"
+@@ -75,9 +76,16 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++QQuickWidgetOffscreenWindow::QQuickWidgetOffscreenWindow(QQuickWindowPrivate &dd, QQuickRenderControl *control)
++:QQuickWindow(dd, control)
++{
++    setTitle(QString::fromLatin1("Offscreen"));
++    setObjectName(QString::fromLatin1("QQuickOffScreenWindow"));
++}
++
+ // override setVisble to prevent accidental offscreen window being created
+ // by base class.
+-class QQuickOffcreenWindowPrivate: public QQuickWindowPrivate {
++class QQuickWidgetOffscreenWindowPrivate: public QQuickWindowPrivate {
+ public:
+     void setVisible(bool visible) override {
+         Q_Q(QWindow);
+@@ -105,9 +113,8 @@ void QQuickWidgetPrivate::init(QQmlEngine* e)
+     Q_Q(QQuickWidget);
+ 
+     renderControl = new QQuickWidgetRenderControl(q);
+-    offscreenWindow = new QQuickWindow(*new QQuickOffcreenWindowPrivate(),renderControl);
+-    offscreenWindow->setTitle(QString::fromLatin1("Offscreen"));
+-    offscreenWindow->setObjectName(QString::fromLatin1("QQuickOffScreenWindow"));
++    offscreenWindow = new QQuickWidgetOffscreenWindow(*new QQuickWidgetOffscreenWindowPrivate(), renderControl);
++    offscreenWindow->setScreen(q->screen());
+     // Do not call create() on offscreenWindow.
+ 
+     // Check if the Software Adaptation is being used
+@@ -138,6 +145,10 @@ void QQuickWidgetPrivate::init(QQmlEngine* e)
+     QWidget::connect(offscreenWindow, &QQuickWindow::focusObjectChanged, q, &QQuickWidget::propagateFocusObjectChanged);
+     QObject::connect(renderControl, SIGNAL(renderRequested()), q, SLOT(triggerUpdate()));
+     QObject::connect(renderControl, SIGNAL(sceneChanged()), q, SLOT(triggerUpdate()));
++
++#if QT_CONFIG(accessibility)
++    QAccessible::installFactory(&qAccessibleQuickWidgetFactory);
++#endif
+ }
+ 
+ void QQuickWidgetPrivate::ensureEngine() const
+@@ -901,9 +912,7 @@ void QQuickWidgetPrivate::createContext()
+ 
+         context = new QOpenGLContext;
+         context->setFormat(offscreenWindow->requestedFormat());
+-        const QWindow *win = q->window()->windowHandle();
+-        if (win && win->screen())
+-            context->setScreen(win->screen());
++        context->setScreen(q->screen());
+         QOpenGLContext *shareContext = qt_gl_global_share_context();
+         if (!shareContext)
+             shareContext = QWidgetPrivate::get(q->window())->shareContext();
+@@ -1520,19 +1529,16 @@ bool QQuickWidget::event(QEvent *e)
+         d->handleWindowChange();
+         break;
+ 
+-    case QEvent::ScreenChangeInternal:
+-        if (QWindow *window = this->window()->windowHandle()) {
+-            QScreen *newScreen = window->screen();
+-
+-            if (d->offscreenWindow)
+-                d->offscreenWindow->setScreen(newScreen);
+-            if (d->offscreenSurface)
+-                d->offscreenSurface->setScreen(newScreen);
++    case QEvent::ScreenChangeInternal: {
++        QScreen *newScreen = screen();
++        if (d->offscreenWindow)
++            d->offscreenWindow->setScreen(newScreen);
++        if (d->offscreenSurface)
++            d->offscreenSurface->setScreen(newScreen);
+ #if QT_CONFIG(opengl)
+-            if (d->context)
+-                d->context->setScreen(newScreen);
++        if (d->context)
++            d->context->setScreen(newScreen);
+ #endif
+-        }
+ 
+         if (d->useSoftwareRenderer
+ #if QT_CONFIG(opengl)
+@@ -1545,7 +1551,7 @@ bool QQuickWidget::event(QEvent *e)
+             d->render(true);
+         }
+         break;
+-
++    }
+     case QEvent::Show:
+     case QEvent::Move:
+         d->updatePosition();
+diff --git a/qtdeclarative/src/quickwidgets/qquickwidget_p.h b/qtdeclarative/src/quickwidgets/qquickwidget_p.h
+index 881f7f9220..1a946bcc71 100644
+--- a/qtdeclarative/src/quickwidgets/qquickwidget_p.h
++++ b/qtdeclarative/src/quickwidgets/qquickwidget_p.h
+@@ -148,6 +148,14 @@ public:
+     bool forceFullUpdate;
+ };
+ 
++class QQuickWidgetOffscreenWindow: public QQuickWindow
++{
++    Q_OBJECT
++
++public:
++    QQuickWidgetOffscreenWindow(QQuickWindowPrivate &dd, QQuickRenderControl *control);
++};
++
+ QT_END_NAMESPACE
+ 
+ #endif // QQuickWidget_P_H
+diff --git a/qtdeclarative/src/quickwidgets/quickwidgets.pro b/qtdeclarative/src/quickwidgets/quickwidgets.pro
+index 2438e577ae..85d156b8a3 100644
+--- a/qtdeclarative/src/quickwidgets/quickwidgets.pro
++++ b/qtdeclarative/src/quickwidgets/quickwidgets.pro
+@@ -7,9 +7,13 @@ DEFINES   += QT_NO_URL_CAST_FROM_STRING QT_NO_INTEGER_EVENT_COORDINATES QT_NO_FO
+ HEADERS += \
+     qquickwidget.h \
+     qquickwidget_p.h \
+-    qtquickwidgetsglobal.h
++    qtquickwidgetsglobal.h \
++    qaccessiblequickwidget_p.h \
++    qaccessiblequickwidgetfactory_p.h
+ 
+ SOURCES += \
+-    qquickwidget.cpp
++    qquickwidget.cpp \
++    qaccessiblequickwidget.cpp \
++    qaccessiblequickwidgetfactory.cpp
+ 
+ load(qt_module)
+diff --git a/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+index 3b7d74df63..b75bf820d5 100644
+--- a/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
++++ b/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+@@ -102,6 +102,7 @@ private slots:
+     void valueConversion_RegularExpression();
+     void castWithMultipleInheritance();
+     void collectGarbage();
++    void collectGarbageNestedWrappersTwoEngines();
+     void gcWithNestedDataStructure();
+     void stacktrace();
+     void numberParsing_data();
+@@ -1809,6 +1810,44 @@ void tst_QJSEngine::collectGarbage()
+     QVERIFY(ptr.isNull());
+ }
+ 
++class TestObjectContainer : public QObject
++{
++    Q_OBJECT
++    Q_PROPERTY(QObject *dummy MEMBER m_dummy CONSTANT)
++
++public:
++    TestObjectContainer() : m_dummy(new QObject(this)) {}
++
++private:
++    QObject *m_dummy;
++};
++
++void tst_QJSEngine::collectGarbageNestedWrappersTwoEngines()
++{
++    QJSEngine engine1;
++    QJSEngine engine2;
++
++    TestObjectContainer container;
++    QQmlEngine::setObjectOwnership(&container, QQmlEngine::CppOwnership);
++
++    engine1.globalObject().setProperty("foobar", engine1.newQObject(&container));
++    engine2.globalObject().setProperty("foobar", engine2.newQObject(&container));
++
++    engine1.evaluate("foobar.dummy.baz = 42");
++    engine2.evaluate("foobar.dummy.baz = 43");
++
++    QCOMPARE(engine1.evaluate("foobar.dummy.baz").toInt(), 42);
++    QCOMPARE(engine2.evaluate("foobar.dummy.baz").toInt(), 43);
++
++    engine1.collectGarbage();
++    engine2.collectGarbage();
++
++    // The GC should not collect dummy object wrappers neither in engine1 nor engine2, we
++    // verify that by checking whether the baz property still has its previous value.
++    QCOMPARE(engine1.evaluate("foobar.dummy.baz").toInt(), 42);
++    QCOMPARE(engine2.evaluate("foobar.dummy.baz").toInt(), 43);
++}
++
+ void tst_QJSEngine::gcWithNestedDataStructure()
+ {
+     // The GC must be able to traverse deeply nested objects, otherwise this
+diff --git a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml
+new file mode 100644
+index 0000000000..206133bb39
+--- /dev/null
++++ b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml
+@@ -0,0 +1,11 @@
++import QtQuick 2.8
++
++ListView {
++    id: root
++    width: 200
++    height: 200
++
++    delegate: Text {
++        text: display
++    }
++}
+diff --git a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
+index 35f1e2c94d..1722447830 100644
+--- a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
++++ b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
+@@ -27,6 +27,8 @@
+ ****************************************************************************/
+ 
+ #include <QtTest/qtest.h>
++#include <QtCore/QConcatenateTablesProxyModel>
++#include <QtGui/QStandardItemModel>
+ #include <QtQml/qqmlcomponent.h>
+ #include <QtQmlModels/private/qqmldelegatemodel_p.h>
+ #include <QtQuick/qquickview.h>
+@@ -47,6 +49,7 @@ private slots:
+     void filterOnGroup_removeWhenCompleted();
+     void qtbug_86017();
+     void contextAccessedByHandler();
++    void redrawUponColumnChange();
+ };
+ 
+ class AbstractItemModel : public QAbstractItemModel
+@@ -186,6 +189,30 @@ void tst_QQmlDelegateModel::contextAccessedByHandler()
+     QVERIFY(root->property("works").toBool());
+ }
+ 
++void tst_QQmlDelegateModel::redrawUponColumnChange()
++{
++    QStandardItemModel m1;
++    m1.appendRow({
++            new QStandardItem("Banana"),
++            new QStandardItem("Coconut"),
++    });
++
++    QQuickView view(testFileUrl("redrawUponColumnChange.qml"));
++    QCOMPARE(view.status(), QQuickView::Ready);
++    view.show();
++    QQuickItem *root = view.rootObject();
++    root->setProperty("model", QVariant::fromValue<QObject *>(&m1));
++
++    QObject *item = root->property("currentItem").value<QObject *>();
++    QVERIFY(item);
++    QCOMPARE(item->property("text").toString(), "Banana");
++
++    QVERIFY(root);
++    m1.removeColumn(0);
++
++    QCOMPARE(item->property("text").toString(), "Coconut");
++}
++
+ QTEST_MAIN(tst_QQmlDelegateModel)
+ 
+ #include "tst_qqmldelegatemodel.moc"
+diff --git a/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp b/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
+index 5d635aa63b..824fd89e5b 100644
+--- a/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
++++ b/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
+@@ -76,10 +76,10 @@ void tst_qv4mm::multiWrappedQObjects()
+         QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 1);
+         QCOMPARE(engine2.memoryManager->m_pendingFreedObjectWrapperValue.size(), 0);
+ 
+-        // Moves the additional WeakValue from m_multiplyWrappedQObjects to
+-        // m_pendingFreedObjectWrapperValue. It's still alive after all.
++        // The additional WeakValue from m_multiplyWrappedQObjects hasn't been moved
++        // to m_pendingFreedObjectWrapperValue yet. It's still alive after all.
+         engine1.memoryManager->runGC();
+-        QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 2);
++        QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 1);
+ 
+         // engine2 doesn't own the object as engine1 was the first to wrap it above.
+         // Therefore, no effect here.
+diff --git a/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml b/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml
+new file mode 100644
+index 0000000000..889e480f3b
+--- /dev/null
++++ b/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml
+@@ -0,0 +1,13 @@
++import QtQuick 2.6
++
++Item {
++    visible: true
++    Item {
++        visible: false
++        Item {
++            objectName: "hiddenChild"
++            activeFocusOnTab: true
++            focus: true
++        }
++    }
++}
+diff --git a/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp b/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+index c8f251dbe1..c8ef36ee68 100644
+--- a/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
++++ b/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+@@ -67,6 +67,7 @@ private slots:
+     void activeFocusOnTab10();
+     void activeFocusOnTab_infiniteLoop_data();
+     void activeFocusOnTab_infiniteLoop();
++    void activeFocusOnTab_infiniteLoopControls();
+ 
+     void nextItemInFocusChain();
+     void nextItemInFocusChain2();
+@@ -1057,6 +1058,17 @@ void tst_QQuickItem::activeFocusOnTab_infiniteLoop()
+     QCOMPARE(item, window->rootObject());
+ }
+ 
++
++void tst_QQuickItem::activeFocusOnTab_infiniteLoopControls()
++{
++    auto source = testFileUrl("activeFocusOnTab_infiniteLoop3.qml");
++    QScopedPointer<QQuickView>window(new QQuickView());
++    window->setSource(source);
++    window->show();
++    QVERIFY(window->errors().isEmpty());
++    QTest::keyClick(window.get(), Qt::Key_Tab); // should not hang
++}
++
+ void tst_QQuickItem::nextItemInFocusChain()
+ {
+     if (!qt_tab_all_widgets())
+Submodule qtdoc c0c7bf07...79d6ef69:
+Submodule qtimageformats 2dcf2899..abe44c0f:
+diff --git a/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp b/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
+index dde783c..1bf9074 100644
+--- a/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
+@@ -462,8 +462,12 @@ static bool parseIconEntryInfo(ICNSEntry &icon)
+     if (isIconCompressed(icon))
+         return true;
+     // Icon depth:
+-    if (!depth.isEmpty())
+-        icon.depth = ICNSEntry::Depth(depth.toUInt());
++    if (!depth.isEmpty()) {
++        const uint depthUInt = depth.toUInt();
++        if (depthUInt > 32)
++            return false;
++        icon.depth = ICNSEntry::Depth(depthUInt);
++    }
+     // Try mono if depth not found
+     if (icon.depth == ICNSEntry::DepthUnknown)
+         icon.depth = ICNSEntry::DepthMono;
+@@ -515,6 +519,9 @@ static bool parseIconEntryInfo(ICNSEntry &icon)
+         }
+         icon.height = icon.width;
+     }
++    // Sanity check
++    if (icon.width == 0 || icon.width > 4096)
++        return false;
+     return true;
+ }
+ 
+@@ -685,7 +692,7 @@ bool QICNSHandler::canRead() const
+ bool QICNSHandler::read(QImage *outImage)
+ {
+     QImage img;
+-    if (!ensureScanned()) {
++    if (!ensureScanned() || m_currentIconIndex >= m_icons.size()) {
+         qWarning("QICNSHandler::read(): The device wasn't parsed properly!");
+         return false;
+     }
+@@ -892,7 +899,7 @@ bool QICNSHandler::scanDevice()
+             return false;
+ 
+         const qint64 blockDataOffset = device()->pos();
+-        if (!isBlockHeaderValid(blockHeader)) {
++        if (!isBlockHeaderValid(blockHeader, ICNSBlockHeaderSize + filelength - blockDataOffset)) {
+             qWarning("QICNSHandler::scanDevice(): Failed, bad header at pos %s. OSType \"%s\", length %u",
+                      QByteArray::number(blockDataOffset).constData(),
+                      nameFromOSType(blockHeader.ostype).constData(), blockHeader.length);
+@@ -927,11 +934,14 @@ bool QICNSHandler::scanDevice()
+         case ICNSBlockHeader::TypeOdrp:
+             // Icns container seems to have an embedded icon variant container
+             // Let's start a scan for entries
+-            while (device()->pos() < nextBlockOffset) {
++            while (!stream.atEnd() && device()->pos() < nextBlockOffset) {
+                 ICNSBlockHeader icon;
+                 stream >> icon;
++                if (stream.status() != QDataStream::Ok)
++                    return false;
+                 // Check for incorrect variant entry header and stop scan
+-                if (!isBlockHeaderValid(icon, blockDataLength))
++                quint64 remaining = blockDataLength - (device()->pos() - blockDataOffset);
++                if (!isBlockHeaderValid(icon, ICNSBlockHeaderSize + remaining))
+                     break;
+                 if (!addEntry(icon, device()->pos(), blockHeader.ostype))
+                     return false;
+@@ -1003,7 +1013,7 @@ bool QICNSHandler::scanDevice()
+             break;
+         }
+     }
+-    return true;
++    return (m_icons.size() > 0);
+ }
+ 
+ const ICNSEntry &QICNSHandler::getIconMask(const ICNSEntry &icon) const
+diff --git a/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp b/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
+index 5082023..cb34374 100644
+--- a/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
++++ b/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
+@@ -43,6 +43,7 @@
+ #include "qimage.h"
+ #include "qvariant.h"
+ #include "qcolor.h"
++#include "qimagereader.h"
+ 
+ #include <jasper/jasper.h>
+ #include <math.h> // for pow
+@@ -333,16 +334,46 @@ private:
+ Jpeg2000JasperReader::Jpeg2000JasperReader(QIODevice *iod, SubFormat format)
+     : jasperOk(true), ioDevice(iod), format(format), hasAlpha(false)
+ {
++#if JAS_VERSION_MAJOR < 3
+     if (jas_init()) {
+         jasperOk = false;
+         qDebug("Jasper Library initialization failed");
+     }
++#else
++    jas_conf_clear();
++#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
++    jas_conf_set_max_mem_usage(QImageReader::allocationLimit() * 1024 * 1024);
++#else
++    // 128MB seems to be enough.
++    jas_conf_set_max_mem_usage(128 * 1024 * 1024);
++#endif
++    if (jas_init_library()) {
++        jasperOk = false;
++        qDebug("Jasper library initialization failed");
++    }
++    if (jas_init_thread()) {
++        jas_cleanup_library();
++        jasperOk = false;
++        qDebug("Jasper thread initialization failed");
++    }
++#endif
+ }
+ 
+ Jpeg2000JasperReader::~Jpeg2000JasperReader()
+ {
++#if JAS_VERSION_MAJOR < 3
+     if (jasperOk)
+         jas_cleanup();
++#else
++    if (jasperOk) {
++        if (jas_cleanup_thread()) {
++            qDebug("Jasper thread cleanup failed");
++        }
++        if (jas_cleanup_library()) {
++            qDebug("Jasper library cleanup failed");
++        }
++    }
++#endif
+ }
+ 
+ /*! \internal
+@@ -857,7 +888,7 @@ bool Jpeg2000JasperReader::write(const QImage &image, int quality)
+     }
+ 
+     // Open an empty jasper stream that grows automatically
+-    jas_stream_t * memory_stream = jas_stream_memopen(0, -1);
++    jas_stream_t * memory_stream = jas_stream_memopen(0, 0);
+ 
+     // Jasper wants a non-const string.
+     char *str = qstrdup(jasperFormatString.toLatin1().constData());
+diff --git a/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp b/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
+index 1386750..ac8956c 100644
+--- a/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
+@@ -361,6 +361,8 @@ bool QTiffHandler::read(QImage *image)
+     }
+ 
+     TIFF *const tiff = d->tiff;
++    if (TIFFIsTiled(tiff) && TIFFTileSize64(tiff) > uint64_t(image->sizeInBytes())) // Corrupt image
++        return false;
+     const quint32 width = d->size.width();
+     const quint32 height = d->size.height();
+ 
+diff --git a/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp b/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
+index 82d38cb..d02eb05 100644
+--- a/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
+@@ -45,6 +45,7 @@
+ #include <qdebug.h>
+ #include <qpainter.h>
+ #include <qvariant.h>
++#include <QtEndian>
+ 
+ static const int riffHeaderSize = 12; // RIFF_HEADER_SIZE from webp/format_constants.h
+ 
+@@ -102,21 +103,23 @@ bool QWebpHandler::ensureScanned() const
+ 
+     m_scanState = ScanError;
+ 
+-    if (device()->isSequential()) {
+-        qWarning() << "Sequential devices are not supported";
++    QWebpHandler *that = const_cast<QWebpHandler *>(this);
++    const int headerBytesNeeded = sizeof(WebPBitstreamFeatures);
++    QByteArray header = device()->peek(headerBytesNeeded);
++    if (header.size() < headerBytesNeeded)
+         return false;
+-    }
+ 
+-    qint64 oldPos = device()->pos();
+-    device()->seek(0);
+-
+-    QWebpHandler *that = const_cast<QWebpHandler *>(this);
+-    QByteArray header = device()->peek(sizeof(WebPBitstreamFeatures));
++    // We do no random access during decoding, just a readAll() of the whole image file. So if
++    // if it is all available already, we can accept a sequential device. The riff header contains
++    // the file size minus 8 bytes header
++    qint64 byteSize = qFromLittleEndian<quint32>(header.constData() + 4);
++    if (device()->isSequential() && device()->bytesAvailable() < byteSize + 8) {
++        qWarning() << "QWebpHandler: Insufficient data available in sequential device";
++        return false;
++    }
+     if (WebPGetFeatures((const uint8_t*)header.constData(), header.size(), &(that->m_features)) == VP8_STATUS_OK) {
+         if (m_features.has_animation) {
+             // For animation, we have to read and scan whole file to determine loop count and images count
+-            device()->seek(oldPos);
+-
+             if (that->ensureDemuxer()) {
+                 that->m_loop = WebPDemuxGetI(m_demuxer, WEBP_FF_LOOP_COUNT);
+                 that->m_frameCount = WebPDemuxGetI(m_demuxer, WEBP_FF_FRAME_COUNT);
+@@ -126,17 +129,13 @@ bool QWebpHandler::ensureScanned() const
+                 if (that->m_features.has_alpha)
+                     that->m_composited->fill(Qt::transparent);
+ 
+-                // We do not reset device position since we have read in all data
+                 m_scanState = ScanSuccess;
+-                return true;
+             }
+         } else {
+             m_scanState = ScanSuccess;
+         }
+     }
+ 
+-    device()->seek(oldPos);
+-
+     return m_scanState == ScanSuccess;
+ }
+ 
+@@ -159,7 +158,7 @@ bool QWebpHandler::ensureDemuxer()
+ 
+ bool QWebpHandler::read(QImage *image)
+ {
+-    if (!ensureScanned() || device()->isSequential() || !ensureDemuxer())
++    if (!ensureScanned() || !ensureDemuxer())
+         return false;
+ 
+     QRect prevFrameRect;
+Submodule qtlocation 98a5c511..f991e28c:
+diff --git a/qtlocation/src/location/configure.json b/qtlocation/src/location/configure.json
+index 6d01a9a3..d1e623a1 100644
+--- a/qtlocation/src/location/configure.json
++++ b/qtlocation/src/location/configure.json
+@@ -9,7 +9,7 @@
+             "label": "Qt.labs.location experimental QML plugin",
+             "purpose": "Provides experimental QtLocation QML types",
+             "section": "Location",
+-            "condition": "config.opengl",
++            "condition": "features.opengl",
+             "output": [ "privateFeature" ]
+         },
+         "geoservices_osm": {
+diff --git a/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp b/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
+index a978573d..11e1466f 100644
+--- a/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
++++ b/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
+@@ -158,7 +158,7 @@ void QGeoMapObjectQSGSupport::updateMapObjects(QSGNode *root, QQuickWindow *wind
+     if (!root)
+         return;
+ 
+-    if (m_mapObjectsRootNode && m_mapObjectsRootNode->parent())
++    if (m_mapObjectsRootNode && !m_mapObjectsRootNode->parent())
+         root->appendChildNode(m_mapObjectsRootNode.get());
+ 
+     if (!m_mapObjectsRootNode) {
+diff --git a/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
+index 5a40467e..d123c6a8 100644
+--- a/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
+@@ -59,8 +59,10 @@ QT_BEGIN_NAMESPACE
+ static const QString kPrefixEsri(QStringLiteral("esri."));
+ static const QString kParamUserAgent(kPrefixEsri + QStringLiteral("useragent"));
+ 
+-static const QString kUrlGeocode(QStringLiteral("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates"));
+-static const QString kUrlReverseGeocode(QStringLiteral("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode"));
++static const QString kUrlGeocode(QStringLiteral("https://geocode.arcgis.com/arcgis/rest/services/"
++                                                "World/GeocodeServer/findAddressCandidates"));
++static const QString kUrlReverseGeocode(QStringLiteral(
++        "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode"));
+ 
+ static QString addressToQuery(const QGeoAddress &address)
+ {
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
+index 17492d94..96c12b1b 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
+@@ -46,7 +46,8 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-// JSON reference: http://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
++// JSON reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
+ 
+ static const QString kErrorMessage(QStringLiteral("Error %1: %2."));
+ static const QString kErrorJson(QStringLiteral("Error: invalide JSON document."));
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
+index 8cadfb29..92b6bb13 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
+@@ -44,7 +44,8 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-// JSON reference: http://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
++// JSON reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
+ 
+ GeoRouteReplyEsri::GeoRouteReplyEsri(QNetworkReply *reply, const QGeoRouteRequest &request,
+                                      QObject *parent) :
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
+index 0e6bc2c7..ed613f4b 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
+@@ -48,7 +48,8 @@ static const QString kPrefixEsri(QStringLiteral("esri."));
+ static const QString kParamUserAgent(kPrefixEsri + QStringLiteral("useragent"));
+ static const QString kParamToken(kPrefixEsri + QStringLiteral("token"));
+ 
+-static const QString kUrlRouting(QStringLiteral("http://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve"));
++static const QString kUrlRouting(QStringLiteral(
++        "https://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve"));
+ 
+ GeoRoutingManagerEngineEsri::GeoRoutingManagerEngineEsri(const QVariantMap &parameters,
+                                                          QGeoServiceProvider::Error *error,
+@@ -70,7 +71,8 @@ GeoRoutingManagerEngineEsri::~GeoRoutingManagerEngineEsri()
+ {
+ }
+ 
+-// REST reference: http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
++// REST reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
+ 
+ QGeoRouteReply *GeoRoutingManagerEngineEsri::calculateRoute(const QGeoRouteRequest &request)
+ {
+@@ -125,7 +127,7 @@ void GeoRoutingManagerEngineEsri::replyError(QGeoRouteReply::Error errorCode, co
+ QString GeoRoutingManagerEngineEsri::preferedDirectionLangage()
+ {
+     // list of supported langages is defined in:
+-    // http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
++    // https://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
+     const QStringList supportedLanguages = {
+         "ar", // Generate directions in Arabic
+         "cs", // Generate directions in Czech
+diff --git a/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
+index 5d15835d..24148f95 100644
+--- a/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
+@@ -230,7 +230,8 @@ QGeoMap *GeoTiledMappingManagerEngineEsri::createMap()
+ // ${y} = Y
+ // ${token} = Token
+ 
+-// template = 'http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{{z}}/{{y}}/{{x}}.png'
++// template =
++// 'https://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{{z}}/{{y}}/{{x}}.png'
+ 
+ bool GeoTiledMappingManagerEngineEsri::initializeMapSources(QGeoServiceProvider::Error *error,
+                                                             QString *errorString,
+diff --git a/qtlocation/src/plugins/geoservices/esri/maps.json b/qtlocation/src/plugins/geoservices/esri/maps.json
+index 8167ae7d..862e087d 100644
+--- a/qtlocation/src/plugins/geoservices/esri/maps.json
++++ b/qtlocation/src/plugins/geoservices/esri/maps.json
+@@ -6,8 +6,8 @@
+             "description": "ArcGIS Online World Street Map",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=3b93337983e9436f8db950e38a8629af'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=3b93337983e9436f8db950e38a8629af'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -16,8 +16,8 @@
+             "": "ArcGIS Online World Imagery",
+             "mobile": true,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -26,8 +26,8 @@
+             "description": "ArcGIS Online World Terrain Base",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=c61ad8ab017d49e1a82f580ee1298931'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=c61ad8ab017d49e1a82f580ee1298931'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -36,8 +36,8 @@
+             "description": "ArcGIS Online World Topography",
+             "mobile": true,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=30e5fe3149c34df1ba922e6f5bbf808f'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=30e5fe3149c34df1ba922e6f5bbf808f'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -46,8 +46,8 @@
+             "description": "This map presents land cover and detailed topographic maps for the United States.",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=99cd5fbd98934028802b4f797c4b1732'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=99cd5fbd98934028802b4f797c4b1732'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -56,8 +56,8 @@
+             "description": "National Geographic World Map",
+             "mobile": false,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=b9b1b422198944fbbd5250b3241691b6'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=b9b1b422198944fbbd5250b3241691b6'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -66,8 +66,8 @@
+             "description": "Thematic content providing a neutral background with minimal colors",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=ed712cb1db3e4bae9e85329040fb9a49'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=ed712cb1db3e4bae9e85329040fb9a49'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -76,8 +76,8 @@
+             "description": "Natural Earth physical map for the world",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=c4ec722a1cd34cf0a23904aadf8923a0'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=c4ec722a1cd34cf0a23904aadf8923a0'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -86,8 +86,8 @@
+             "description": "Portrays surface elevation as shaded relief",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=9c5370d0b54f4de1b48a3792d7377ff2'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=9c5370d0b54f4de1b48a3792d7377ff2'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -96,8 +96,8 @@
+             "description": "This map is designed to be used as a basemap by marine GIS professionals and as a reference map by anyone interested in ocean data",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=1e126e7520f9466c9ca28b8f28b5e500'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=1e126e7520f9466c9ca28b8f28b5e500'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -106,8 +106,8 @@
+             "description": "Thematic content providing a neutral background with minimal colors",
+             "mobile": false,
+             "night": true,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=a284a9b99b3446a3910d4144a50990f6'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=a284a9b99b3446a3910d4144a50990f6'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -116,8 +116,8 @@
+             "description": "DeLorme’s topographic basemap is a seamless global data set that portrays transportation, hydrography, jurisdiction boundaries, and major geographic features",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/Specialty/DeLorme_World_Base_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=b165c3df453e4be6b5ac4fdb241effbe'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/Specialty/DeLorme_World_Base_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=b165c3df453e4be6b5ac4fdb241effbe'>Esri</a> contributors"
+         }
+     ]
+ }
+diff --git a/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
+index 3858ddf5..af66f28e 100644
+--- a/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
+@@ -63,8 +63,10 @@ static const QString kCountriesKey(QStringLiteral("detailedCountries"));
+ static const QString kLocalizedNamesKey(QStringLiteral("localizedNames"));
+ static const QString kMaxLocationsKey(QStringLiteral("maxLocations"));
+ 
+-static const QUrl kUrlGeocodeServer("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer?f=pjson");
+-static const QUrl kUrlFindAddressCandidates("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates");
++static const QUrl kUrlGeocodeServer(
++        "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer?f=pjson");
++static const QUrl kUrlFindAddressCandidates("https://geocode.arcgis.com/arcgis/rest/services/World/"
++                                            "GeocodeServer/findAddressCandidates");
+ 
+ PlaceManagerEngineEsri::PlaceManagerEngineEsri(const QVariantMap &parameters, QGeoServiceProvider::Error *error,
+                                                QString *errorString) :
+Submodule qtmultimedia f0344079..0d7cc33a:
+diff --git a/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp b/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
+index 2b5325132..b68b4af1b 100644
+--- a/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
++++ b/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
+@@ -402,6 +402,8 @@ int QPulseAudioInput::bytesReady() const
+ 
+ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ {
++    Q_ASSERT(data != nullptr || len == 0);
++
+     m_bytesAvailable = checkBytesReady();
+ 
+     setError(QAudio::NoError);
+@@ -411,7 +413,8 @@ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ 
+     if (!m_pullMode && !m_tempBuffer.isEmpty()) {
+         readBytes = qMin(static_cast<int>(len), m_tempBuffer.size());
+-        memcpy(data, m_tempBuffer.constData(), readBytes);
++        if (readBytes)
++            memcpy(data, m_tempBuffer.constData(), readBytes);
+         m_totalTimeValue += readBytes;
+ 
+         if (readBytes < m_tempBuffer.size()) {
+@@ -502,9 +505,10 @@ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ 
+ void QPulseAudioInput::applyVolume(const void *src, void *dest, int len)
+ {
++    Q_ASSERT((src && dest) || len == 0);
+     if (m_volume < 1.f)
+         QAudioHelperInternal::qMultiplySamples(m_volume, m_format, src, dest, len);
+-    else
++    else if (len)
+         memcpy(dest, src, len);
+ }
+ 
+Submodule qtpim 02efef5e...f9a8f0fc (commits not present)
+Submodule qtquick3d b85cf622..47defc8b:
+diff --git a/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro b/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
+index ca5c499e..174a075b 100644
+--- a/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
++++ b/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
+@@ -10,7 +10,7 @@ QT_FOR_CONFIG += assetimporters-private
+ include($$OUT_PWD/../qtassetimporters-config.pri)
+ 
+ qtConfig(system-assimp):!if(cross_compile:host_build) {
+-    QMAKE_USE_PRIVATE += assimp
++    QMAKE_USE_PRIVATE += quick3d-assimp
+ } else {
+     include(../../../3rdparty/assimp/assimp.pri)
+ }
+Submodule qtquickcontrols2 3a657dc0..56ce8233:
+diff --git a/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp b/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
+index e5fe734f7..e36922775 100644
+--- a/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
++++ b/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
+@@ -38,6 +38,7 @@
+ #include "qwidgetplatformmenuitem_p.h"
+ 
+ #include <QtGui/qwindow.h>
++#include <QtGui/private/qhighdpiscaling_p.h>
+ #include <QtWidgets/qmenu.h>
+ #include <QtWidgets/qaction.h>
+ 
+@@ -145,7 +146,7 @@ void QWidgetPlatformMenu::showPopup(const QWindow *window, const QRect &targetRe
+ 
+     QPoint targetPos = targetRect.bottomLeft();
+     if (window)
+-        targetPos = window->mapToGlobal(targetPos);
++        targetPos = window->mapToGlobal(QHighDpi::fromNativeLocalPosition(targetPos, window));
+ 
+     const QWidgetPlatformMenuItem *widgetItem = qobject_cast<const QWidgetPlatformMenuItem *>(item);
+     m_menu->popup(targetPos, widgetItem ? widgetItem->action() : nullptr);
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
+index 950e4e099..b81fbea0b 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
+@@ -387,6 +387,17 @@ void QQuickAbstractButtonPrivate::itemImplicitHeightChanged(QQuickItem *item)
+         emit q->implicitIndicatorHeightChanged();
+ }
+ 
++void QQuickAbstractButtonPrivate::itemDestroyed(QQuickItem *item)
++{
++    Q_Q(QQuickAbstractButton);
++    QQuickControlPrivate::itemDestroyed(item);
++    if (item == indicator) {
++        indicator = nullptr;
++        emit q->implicitIndicatorWidthChanged();
++        emit q->implicitIndicatorHeightChanged();
++    }
++}
++
+ QQuickAbstractButton *QQuickAbstractButtonPrivate::findCheckedButton() const
+ {
+     Q_Q(const QQuickAbstractButton);
+@@ -1176,6 +1187,12 @@ QAccessible::Role QQuickAbstractButton::accessibleRole() const
+     }
+     return QAccessible::Button;
+ }
++
++void QQuickAbstractButton::accessiblePressAction()
++{
++    Q_D(QQuickAbstractButton);
++    d->trigger();
++}
+ #endif
+ 
+ QT_END_NAMESPACE
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
+index 0fa48980e..ab66220d0 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
+@@ -209,6 +209,7 @@ protected:
+ #if QT_CONFIG(accessibility)
+     void accessibilityActiveChanged(bool active) override;
+     QAccessible::Role accessibleRole() const override;
++    Q_INVOKABLE void accessiblePressAction();
+ #endif
+ 
+ private:
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
+index 9291c1a87..b729720f2 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
+@@ -109,6 +109,7 @@ public:
+ 
+     void itemImplicitWidthChanged(QQuickItem *item) override;
+     void itemImplicitHeightChanged(QQuickItem *item) override;
++    void itemDestroyed(QQuickItem *item) override;
+ 
+     // copied from qabstractbutton.cpp
+     static const int AUTO_REPEAT_DELAY = 300;
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp b/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
+index 2041e7741..8610cdfae 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
+@@ -145,7 +145,7 @@ int QQuickActionPrivate::ShortcutEntry::shortcutId() const
+ 
+ void QQuickActionPrivate::ShortcutEntry::grab(const QKeySequence &shortcut, bool enabled)
+ {
+-    if (shortcut.isEmpty())
++    if (shortcut.isEmpty() || m_shortcutId)
+         return;
+ 
+     Qt::ShortcutContext context = Qt::WindowShortcut; // TODO
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp b/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
+index f38c2b09c..6eed2a024 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
+@@ -225,6 +225,7 @@ void QQuickContainerPrivate::cleanup()
+     QObject::disconnect(contentModel, &QQmlObjectModel::countChanged, q, &QQuickContainer::countChanged);
+     QObject::disconnect(contentModel, &QQmlObjectModel::childrenChanged, q, &QQuickContainer::contentChildrenChanged);
+     delete contentModel;
++    contentModel = nullptr;
+ }
+ 
+ QQuickItem *QQuickContainerPrivate::itemAt(int index) const
+@@ -436,7 +437,7 @@ void QQuickContainerPrivate::contentChildren_clear(QQmlListProperty<QQuickItem>
+ void QQuickContainerPrivate::updateContentWidth()
+ {
+     Q_Q(QQuickContainer);
+-    if (hasContentWidth || qFuzzyCompare(contentWidth, implicitContentWidth))
++    if (hasContentWidth || qFuzzyCompare(contentWidth, implicitContentWidth) || !contentModel)
+         return;
+ 
+     contentWidth = implicitContentWidth;
+@@ -446,7 +447,7 @@ void QQuickContainerPrivate::updateContentWidth()
+ void QQuickContainerPrivate::updateContentHeight()
+ {
+     Q_Q(QQuickContainer);
+-    if (hasContentHeight || qFuzzyCompare(contentHeight, implicitContentHeight))
++    if (hasContentHeight || qFuzzyCompare(contentHeight, implicitContentHeight) || !contentModel)
+         return;
+ 
+     contentHeight = implicitContentHeight;
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp b/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
+index bbbd0e622..1f4b47343 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
+@@ -845,6 +845,13 @@ void QQuickControlPrivate::executeBackground(bool complete)
+         quickCompleteDeferred(q, backgroundName(), background);
+ }
+ 
++/*
++    \internal
++
++    Hides an item that was replaced by a newer one, rather than
++    deleting it, as the item is typically created in QML and hence
++    we don't own it.
++*/
+ void QQuickControlPrivate::hideOldItem(QQuickItem *item)
+ {
+     if (!item)
+@@ -863,6 +870,29 @@ void QQuickControlPrivate::hideOldItem(QQuickItem *item)
+ #endif
+ }
+ 
++/*
++    \internal
++
++    Named "unhide" because it's used for cases where an item
++    that was previously hidden by \l hideOldItem() wants to be
++    shown by a control again, such as a ScrollBar in ScrollView.
++*/
++void QQuickControlPrivate::unhideOldItem(QQuickControl *control, QQuickItem *item)
++{
++    Q_ASSERT(item);
++    qCDebug(lcItemManagement) << "unhiding old item" << item;
++
++    item->setVisible(true);
++    item->setParentItem(control);
++
++#if QT_CONFIG(accessibility)
++    // Add the item back in to the accessibility tree.
++    QQuickAccessibleAttached *accessible = accessibleAttached(item);
++    if (accessible)
++        accessible->setIgnored(false);
++#endif
++}
++
+ void QQuickControlPrivate::updateBaselineOffset()
+ {
+     Q_Q(QQuickControl);
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h b/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
+index 8e979079e..a6e624c91 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
+@@ -173,6 +173,7 @@ public:
+     virtual void executeBackground(bool complete = false);
+ 
+     static void hideOldItem(QQuickItem *item);
++    static void unhideOldItem(QQuickControl *control, QQuickItem *item);
+ 
+     void updateBaselineOffset();
+ 
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp b/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
+index e6db14eb5..6197d1547 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
+@@ -237,7 +237,7 @@ static QRectF alignedRect(Qt::LayoutDirection direction, Qt::Alignment alignment
+ void QQuickDialogButtonBoxPrivate::resizeContent()
+ {
+     Q_Q(QQuickDialogButtonBox);
+-    if (!contentItem)
++    if (!contentItem || !contentModel)
+         return;
+ 
+     QRectF geometry = q->boundingRect().adjusted(q->leftPadding(), q->topPadding(), -q->rightPadding(), -q->bottomPadding());
+@@ -322,6 +322,9 @@ void QQuickDialogButtonBoxPrivate::updateLayout()
+ qreal QQuickDialogButtonBoxPrivate::getContentWidth() const
+ {
+     Q_Q(const QQuickDialogButtonBox);
++    if (!contentModel)
++        return 0;
++
+     const int count = contentModel->count();
+     const qreal totalSpacing = qMax(0, count - 1) * spacing;
+     qreal totalWidth = totalSpacing;
+@@ -341,6 +344,9 @@ qreal QQuickDialogButtonBoxPrivate::getContentWidth() const
+ qreal QQuickDialogButtonBoxPrivate::getContentHeight() const
+ {
+     Q_Q(const QQuickDialogButtonBox);
++    if (!contentModel)
++        return 0;
++
+     const int count = contentModel->count();
+     qreal maxHeight = 0;
+     for (int i = 0; i < count; ++i) {
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp b/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
+index 91bd59184..0ce518f84 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
+@@ -399,8 +399,11 @@ void QQuickOverlay::itemChange(ItemChange change, const ItemChangeData &data)
+     Q_D(QQuickOverlay);
+     QQuickItem::itemChange(change, data);
+ 
+-    if (change == ItemChildAddedChange || change == ItemChildRemovedChange)
++    if (change == ItemChildAddedChange || change == ItemChildRemovedChange) {
+         setVisible(!d->allDrawers.isEmpty() || !childItems().isEmpty());
++        if (data.item->parent() == d->mouseGrabberPopup)
++            d->setMouseGrabberPopup(nullptr);
++    }
+ }
+ 
+ void QQuickOverlay::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp b/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
+index 4e2f509db..1c4b308cd 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
+@@ -797,6 +797,14 @@ void QQuickScrollBarAttachedPrivate::initHorizontal()
+     if (parent && parent == flickable->parentItem())
+         horizontal->stackAfter(flickable);
+ 
++    // If a scroll bar was previously hidden (due to e.g. setting a new contentItem
++    // on a ScrollView), we need to make sure that we un-hide it.
++    // We don't bother checking if the item is actually the old one, because
++    // if it's not, all of the things the function does (setting parent, visibility, etc.)
++    // should be no-ops anyway.
++    if (auto control = qobject_cast<QQuickControl*>(q_ptr->parent()))
++        QQuickControlPrivate::unhideOldItem(control, horizontal);
++
+     layoutHorizontal();
+     horizontal->setSize(area->property("widthRatio").toReal());
+     horizontal->setPosition(area->property("xPosition").toReal());
+@@ -818,6 +826,9 @@ void QQuickScrollBarAttachedPrivate::initVertical()
+     if (parent && parent == flickable->parentItem())
+         vertical->stackAfter(flickable);
+ 
++    if (auto control = qobject_cast<QQuickControl*>(q_ptr->parent()))
++        QQuickControlPrivate::unhideOldItem(control, vertical);
++
+     layoutVertical();
+     vertical->setSize(area->property("heightRatio").toReal());
+     vertical->setPosition(area->property("yPosition").toReal());
+diff --git a/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml b/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
+index 0e8b08352..cd4931184 100644
+--- a/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
++++ b/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
+@@ -576,4 +576,51 @@ TestCase {
+         verify(newHorizontalScrollBar.visible)
+         verify(!oldHorizontalScrollBar.visible)
+     }
++
++    Component {
++        id: bindingToContentItemAndStandaloneFlickable
++
++        Item {
++            width: 200
++            height: 200
++
++            property alias scrollView: scrollView
++
++            ScrollView {
++                id: scrollView
++                anchors.fill: parent
++                contentItem: listView
++
++                property Item someBinding: contentItem
++            }
++            ListView {
++                id: listView
++                model: 10
++                delegate: ItemDelegate {
++                    text: modelData
++                    width: listView.width
++                }
++            }
++        }
++    }
++
++    // Tests that scroll bars show up for a ScrollView where
++    // - its contentItem is declared as a standalone, separate item
++    // - there is a binding to contentItem (which causes a default Flickable to be created)
++    function test_bindingToContentItemAndStandaloneFlickable() {
++        let root = createTemporaryObject(bindingToContentItemAndStandaloneFlickable, testCase)
++        verify(root)
++
++        let control = root.scrollView
++        let verticalScrollBar = control.ScrollBar.vertical
++        let horizontalScrollBar = control.ScrollBar.horizontal
++        compare(verticalScrollBar.parent, control)
++        compare(horizontalScrollBar.parent, control)
++        verify(verticalScrollBar.visible)
++        verify(horizontalScrollBar.visible)
++
++        mouseDrag(verticalScrollBar, verticalScrollBar.width / 2, verticalScrollBar.height / 2, 0, 50)
++        verify(verticalScrollBar.active)
++        verify(horizontalScrollBar.active)
++    }
+ }
+diff --git a/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml b/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
+index b3fab41ca..10b6baa02 100644
+--- a/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
++++ b/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
+@@ -608,4 +608,27 @@ TestCase {
+         mouseClick(control.indicator)
+         verify(control.activeFocus)
+     }
++
++    Component {
++        id: deletionOrder1
++        Item {
++            Image { id: innerImage }
++            Switch { indicator: innerImage }
++        }
++    }
++
++    Component {
++        id: deletionOrder2
++        Item {
++            Switch { indicator: innerImage }
++            Image { id: innerImage }
++        }
++    }
++
++    function test_deletionOrder() {
++        var control1 = createTemporaryObject(deletionOrder1, testCase)
++        verify(control1)
++        var control2 = createTemporaryObject(deletionOrder2, testCase)
++        verify(control2)
++    }
+ }
+diff --git a/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml b/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml
+new file mode 100644
+index 000000000..9e4598b9f
+--- /dev/null
++++ b/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml
+@@ -0,0 +1,78 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the test suite of the Qt Toolkit.
++**
++** $QT_BEGIN_LICENSE:BSD$
++** Commercial License Usage
++** Licensees holding valid commercial Qt licenses may use this file in
++** accordance with the commercial license agreement provided with the
++** Software or, alternatively, in accordance with the terms contained in
++** a written agreement between you and The Qt Company. For licensing terms
++** and conditions see https://www.qt.io/terms-conditions. For further
++** information use the contact form at https://www.qt.io/contact-us.
++**
++** BSD License Usage
++** Alternatively, you may use this file under the terms of the BSD license
++** as follows:
++**
++** "Redistribution and use in source and binary forms, with or without
++** modification, are permitted provided that the following conditions are
++** met:
++**   * Redistributions of source code must retain the above copyright
++**     notice, this list of conditions and the following disclaimer.
++**   * Redistributions in binary form must reproduce the above copyright
++**     notice, this list of conditions and the following disclaimer in
++**     the documentation and/or other materials provided with the
++**     distribution.
++**   * Neither the name of The Qt Company Ltd nor the names of its
++**     contributors may be used to endorse or promote products derived
++**     from this software without specific prior written permission.
++**
++**
++** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
++** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
++** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
++** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
++** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
++** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
++** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
++** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
++** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
++** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
++** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
++**
++** $QT_END_LICENSE$
++**
++****************************************************************************/
++
++import QtQuick 2.15
++import QtQuick.Controls 2.15
++
++ApplicationWindow {
++    id: window
++    width: 400
++    height: 400
++    title: "releaseAfterExitTransition"
++
++    property alias popup: popup
++    property alias modalPopup: modalPopup
++
++    Popup {
++        id: popup
++        y: parent.height - height
++        width: 50
++        height: 50
++    }
++
++    Popup {
++        id: modalPopup
++        modal: true
++        y: parent.height - height
++        width: 50
++        height: 50
++        exit:  Transition { PauseAnimation { duration: 100 } }
++    }
++}
+diff --git a/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp b/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
+index 54952d128..3d50e2dd4 100644
+--- a/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
++++ b/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
+@@ -100,6 +100,7 @@ private slots:
+     void invisibleToolTipOpen();
+     void centerInOverlayWithinStackViewItem();
+     void destroyDuringExitTransition();
++    void releaseAfterExitTransition();
+ };
+ 
+ void tst_QQuickPopup::initTestCase()
+@@ -1575,6 +1576,34 @@ void tst_QQuickPopup::destroyDuringExitTransition()
+     QVERIFY(!button->isDown());
+ }
+ 
++void tst_QQuickPopup::releaseAfterExitTransition()
++{
++    QQuickApplicationHelper helper(this, "releaseAfterExitTransition.qml");
++    QVERIFY2(helper.ready, helper.failureMessage());
++
++    QQuickWindow *window = helper.window;
++    window->show();
++    QVERIFY(QTest::qWaitForWindowActive(window));
++
++    QQuickOverlay *overlay = QQuickOverlay::overlay(window);
++    QQuickPopup *modalPopup = window->property("modalPopup").value<QQuickPopup *>();
++    QQuickPopup *popup = window->property("popup").value<QQuickPopup *>();
++
++    modalPopup->open();
++    QTRY_VERIFY(modalPopup->isOpened());
++
++    QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++    // wait until the transition is finished and the overlay hides itself
++    QTRY_VERIFY(!overlay->isVisible());
++    QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++
++    popup->open();
++    QTRY_VERIFY(popup->isOpened());
++    QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++    QTRY_VERIFY(!popup->isOpened());
++}
++
++
+ QTEST_QUICKCONTROLS_MAIN(tst_QQuickPopup)
+ 
+ #include "tst_qquickpopup.moc"
+Submodule qtscript 5be95f96...4d8e4bd2 (commits not present)
+Submodule qtspeech 17fc9fde..255845e2:
+diff --git a/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp b/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
+index 6eb74b8..bcc7dd1 100644
+--- a/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
++++ b/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
+@@ -357,7 +357,9 @@ QVector<QLocale> QTextToSpeechEngineSpeechd::availableLocales() const
+ 
+ QVector<QVoice> QTextToSpeechEngineSpeechd::availableVoices() const
+ {
+-    return m_voices.values(m_currentLocale.name()).toVector();
++    QList<QVoice> resultList = m_voices.values(m_currentLocale.name());
++    std::reverse(resultList.begin(), resultList.end());
++    return resultList.toVector();
+ }
+ 
+ // We have no way of knowing our own client_id since speech-dispatcher seems to be incomplete
+Submodule qtsvg 0c05780e..a7a0f249:
+diff --git a/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp b/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
+index 561e77e..12e0574 100644
+--- a/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
++++ b/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
+@@ -191,6 +191,8 @@ bool QSvgIOHandler::read(QImage *image)
+             }
+         }
+         if (!finalSize.isEmpty()) {
++            if (qMax(finalSize.width(), finalSize.height()) > 0xffff)
++                return false; // Assume corrupted file
+             image->fill(d->backColor.rgba());
+             QPainter p(image);
+             d->r.render(&p, bounds);
+diff --git a/qtsvg/src/svg/qsvghandler.cpp b/qtsvg/src/svg/qsvghandler.cpp
+index a5f877f..8dda563 100644
+--- a/qtsvg/src/svg/qsvghandler.cpp
++++ b/qtsvg/src/svg/qsvghandler.cpp
+@@ -1393,9 +1393,10 @@ static void parseFont(QSvgNode *node,
+         case FontSizeNone:
+             break;
+         case FontSizeValue: {
+-            QSvgHandler::LengthType dummy; // should always be pixel size
+-            fontStyle->setSize(qMin(parseLength(attributes.fontSize, dummy, handler),
+-                                    qreal(0xffff)));
++            QSvgHandler::LengthType type;
++            qreal fs = parseLength(attributes.fontSize, type, handler);
++            fs = convertToPixels(fs, true, type);
++            fontStyle->setSize(qMin(fs, qreal(0xffff)));
+         }
+             break;
+         default:
+@@ -2513,6 +2514,8 @@ static bool parseAnimateTransformNode(QSvgNode *parent,
+             ++s;
+         }
+     }
++    if (vals.count() % 3 != 0)
++        return false;
+ 
+     bool ok = true;
+     int begin = parseClockValue(beginStr, &ok);
+@@ -2576,6 +2579,8 @@ static QSvgNode *createCircleNode(QSvgNode *parent,
+     qreal ncx = toDouble(cx);
+     qreal ncy = toDouble(cy);
+     qreal nr  = toDouble(r);
++    if (nr < 0.0)
++        return nullptr;
+ 
+     QRectF rect(ncx-nr, ncy-nr, nr*2, nr*2);
+     QSvgNode *circle = new QSvgCircle(parent, rect);
+@@ -3046,15 +3051,16 @@ static QSvgStyleProperty *createRadialGradientNode(QSvgNode *node,
+ 
+     qreal ncx = 0.5;
+     qreal ncy = 0.5;
+-    qreal nr  = 0.5;
+     if (!cx.isEmpty())
+         ncx = toDouble(cx);
+     if (!cy.isEmpty())
+         ncy = toDouble(cy);
++
++    qreal nr = 0.0;
+     if (!r.isEmpty())
+         nr = toDouble(r);
+-    if (nr < 0.5)
+-        nr = 0.5;
++    if (nr <= 0.0)
++        return nullptr;
+ 
+     qreal nfx = ncx;
+     if (!fx.isEmpty())
+@@ -3350,7 +3356,9 @@ static QSvgNode *createTextNode(QSvgNode *parent,
+     //### editable and rotate not handled
+     QSvgHandler::LengthType type;
+     qreal nx = parseLength(x, type, handler);
++    nx = convertToPixels(nx, true, type);
+     qreal ny = parseLength(y, type, handler);
++    ny = convertToPixels(ny, true, type);
+ 
+     QSvgNode *text = new QSvgText(parent, QPointF(nx, ny));
+     return text;
+@@ -3691,9 +3699,7 @@ void QSvgHandler::parse()
+         case QXmlStreamReader::EndElement:
+             endElement(xml->name());
+             ++remainingUnfinishedElements;
+-            // if we are using somebody else's qxmlstreamreader
+-            // we should not read until the end of the stream
+-            done = !m_ownsReader && (xml->name() == QLatin1String("svg"));
++            done = (xml->name() == QLatin1String("svg"));
+             break;
+         case QXmlStreamReader::Characters:
+             characters(xml->text());
+diff --git a/qtsvg/src/svg/qsvgstructure.cpp b/qtsvg/src/svg/qsvgstructure.cpp
+index b89608b..89c9e4e 100644
+--- a/qtsvg/src/svg/qsvgstructure.cpp
++++ b/qtsvg/src/svg/qsvgstructure.cpp
+@@ -255,9 +255,13 @@ inline static bool isSupportedSvgFeature(const QString &str)
+     };
+ 
+     if (str.length() <= MAX_WORD_LENGTH && str.length() >= MIN_WORD_LENGTH) {
++        const char16_t unicode44 = str.at(44).unicode();
++        const char16_t unicode45 = str.at(45).unicode();
++        if (unicode44 >= sizeof(asso_values) || unicode45 >= sizeof(asso_values))
++            return false;
+         const int key = str.length()
+-                        + asso_values[str.at(45).unicode()]
+-                        + asso_values[str.at(44).unicode()];
++                        + asso_values[unicode45]
++                        + asso_values[unicode44];
+         if (key <= MAX_HASH_VALUE && key >= 0)
+             return str == QLatin1String(wordlist[key]);
+     }
+diff --git a/qtsvg/src/svg/qsvgtinydocument.cpp b/qtsvg/src/svg/qsvgtinydocument.cpp
+index 63d0797..19e7154 100644
+--- a/qtsvg/src/svg/qsvgtinydocument.cpp
++++ b/qtsvg/src/svg/qsvgtinydocument.cpp
+@@ -433,8 +433,16 @@ void QSvgTinyDocument::draw(QPainter *p, QSvgExtraStates &)
+     draw(p);
+ }
+ 
++static bool isValidMatrix(const QTransform &transform)
++{
++    qreal determinant = transform.determinant();
++    return qIsFinite(determinant);
++}
++
+ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect, const QRectF &sourceRect)
+ {
++    QTransform oldTransform = p->worldTransform();
++
+     QRectF target = targetRect;
+     if (target.isEmpty()) {
+         QPaintDevice *dev = p->device();
+@@ -487,6 +495,9 @@ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect,
+         }
+ #endif
+     }
++
++    if (!isValidMatrix(p->worldTransform()))
++        p->setWorldTransform(oldTransform);
+ }
+ 
+ QRectF QSvgTinyDocument::boundsOnElement(const QString &id) const
+diff --git a/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp b/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
+index 36c76ec..db71e02 100644
+--- a/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
++++ b/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
+@@ -86,6 +86,8 @@ private slots:
+     void oss_fuzz_23731();
+     void oss_fuzz_24131();
+     void oss_fuzz_24738();
++    void illegalAnimateTransform_data();
++    void illegalAnimateTransform();
+ 
+ #ifndef QT_NO_COMPRESS
+     void testGzLoading();
+@@ -1646,5 +1648,22 @@ void tst_QSvgRenderer::oss_fuzz_24738()
+     QSvgRenderer().load(QByteArray("<svg><path d=\"a 2 1e-212.....\">"));
+ }
+ 
++void tst_QSvgRenderer::illegalAnimateTransform_data()
++{
++    QTest::addColumn<QByteArray>("svg");
++
++    QTest::newRow("case1") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" values=\"8,0,5,0\">");
++    QTest::newRow("case2") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" values=\"1,2\">");
++    QTest::newRow("case3") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" from=\".. 5 2\" to=\"f\">");
++    QTest::newRow("case4") << QByteArray("<svg><animateTransform type=\"scale\" begin=\"1\" dur=\"2\" by=\"--,..\">");
++}
++
++void tst_QSvgRenderer::illegalAnimateTransform()
++{
++    QFETCH(QByteArray, svg);
++    QSvgRenderer renderer;
++    QVERIFY(!renderer.load(svg)); // also shouldn't assert
++}
++
+ QTEST_MAIN(tst_QSvgRenderer)
+ #include "tst_qsvgrenderer.moc"
+Submodule qttools 6914f7c8..090e526e:
+diff --git a/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp b/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
+index feab1e2d5..cbfb82507 100644
+--- a/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
++++ b/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
+@@ -445,7 +445,9 @@ bool HelpGeneratorPrivate::insertFiles(const QStringList &files, const QString &
+     if (filterSetId < 0)
+         return false;
+     ++filterSetId;
+-    for (int attId : qAsConst(filterAtts)) {
++    QList<int> attValues = filterAtts.values();
++    std::sort(attValues.begin(), attValues.end());
++    for (int attId : qAsConst(attValues)) {
+         m_query->prepare(QLatin1String("INSERT INTO FileAttributeSetTable "
+             "VALUES(?, ?)"));
+         m_query->bindValue(0, filterSetId);
+Submodule qtwayland dfb0129c..2904e1b3:
+diff --git a/qtwayland/src/client/configure.json b/qtwayland/src/client/configure.json
+index 2f424580..29222357 100644
+--- a/qtwayland/src/client/configure.json
++++ b/qtwayland/src/client/configure.json
+@@ -149,8 +149,7 @@
+                     "#endif"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "vulkan-server-buffer": {
+             "label": "Vulkan Buffer Sharing",
+@@ -168,7 +167,8 @@
+                     "exportAllocInfo.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR;",
+                     "return 0;"
+                 ]
+-            }
++            },
++            "use": "wayland-client"
+         },
+         "egl_1_5-wayland": {
+             "label": "EGL 1.5 with Wayland Platform",
+@@ -183,7 +183,7 @@
+                     "eglGetPlatformDisplay(EGL_PLATFORM_WAYLAND_EXT, (struct wl_display *)(nullptr), nullptr);"
+                 ]
+             },
+-            "use": "egl"
++            "use": "egl wayland-client"
+         }
+     },
+ 
+diff --git a/qtwayland/src/client/global/qwaylandclientextension.cpp b/qtwayland/src/client/global/qwaylandclientextension.cpp
+index 125b1e19..edccfe63 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension.cpp
++++ b/qtwayland/src/client/global/qwaylandclientextension.cpp
+@@ -74,7 +74,10 @@ void QWaylandClientExtensionPrivate::handleRegistryGlobal(void *data, ::wl_regis
+ void QWaylandClientExtension::addRegistryListener()
+ {
+     Q_D(QWaylandClientExtension);
+-    d->waylandIntegration->display()->addRegistryListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++    if (!d->registered) {
++        d->waylandIntegration->display()->addRegistryListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++        d->registered = true;
++    }
+ }
+ 
+ QWaylandClientExtension::QWaylandClientExtension(const int ver)
+@@ -88,6 +91,13 @@ QWaylandClientExtension::QWaylandClientExtension(const int ver)
+     QMetaObject::invokeMethod(this, "addRegistryListener", Qt::QueuedConnection);
+ }
+ 
++QWaylandClientExtension::~QWaylandClientExtension()
++{
++    Q_D(QWaylandClientExtension);
++    if (d->registered && !QCoreApplication::closingDown())
++        d->waylandIntegration->display()->removeListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++}
++
+ QtWaylandClient::QWaylandIntegration *QWaylandClientExtension::integration() const
+ {
+     Q_D(const QWaylandClientExtension);
+diff --git a/qtwayland/src/client/global/qwaylandclientextension.h b/qtwayland/src/client/global/qwaylandclientextension.h
+index 98272e57..5bd28398 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension.h
++++ b/qtwayland/src/client/global/qwaylandclientextension.h
+@@ -63,6 +63,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandClientExtension : public QObject
+     Q_PROPERTY(bool active READ isActive NOTIFY activeChanged)
+ public:
+     QWaylandClientExtension(const int version);
++    ~QWaylandClientExtension();
+ 
+     QtWaylandClient::QWaylandIntegration *integration() const;
+     int version() const;
+diff --git a/qtwayland/src/client/global/qwaylandclientextension_p.h b/qtwayland/src/client/global/qwaylandclientextension_p.h
+index 69cc46a0..9091efbe 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension_p.h
++++ b/qtwayland/src/client/global/qwaylandclientextension_p.h
+@@ -68,6 +68,7 @@ public:
+     QtWaylandClient::QWaylandIntegration *waylandIntegration = nullptr;
+     int version = -1;
+     bool active = false;
++    bool registered = false;
+ };
+ 
+ class Q_WAYLAND_CLIENT_EXPORT QWaylandClientExtensionTemplatePrivate : public QWaylandClientExtensionPrivate
+diff --git a/qtwayland/src/client/qwaylanddatadevice.cpp b/qtwayland/src/client/qwaylanddatadevice.cpp
+index 7e2e3308..e3e60ed5 100644
+--- a/qtwayland/src/client/qwaylanddatadevice.cpp
++++ b/qtwayland/src/client/qwaylanddatadevice.cpp
+@@ -72,6 +72,8 @@ QWaylandDataDevice::QWaylandDataDevice(QWaylandDataDeviceManager *manager, QWayl
+ 
+ QWaylandDataDevice::~QWaylandDataDevice()
+ {
++    if (wl_data_device_get_version(object()) >= WL_DATA_DEVICE_RELEASE_SINCE_VERSION)
++        release();
+ }
+ 
+ QWaylandDataOffer *QWaylandDataDevice::selectionOffer() const
+@@ -110,7 +112,7 @@ QWaylandDataOffer *QWaylandDataDevice::dragOffer() const
+     return m_dragOffer.data();
+ }
+ 
+-bool QWaylandDataDevice::startDrag(QMimeData *mimeData, QWaylandWindow *icon)
++bool QWaylandDataDevice::startDrag(QMimeData *mimeData, Qt::DropActions supportedActions, QWaylandWindow *icon)
+ {
+     auto *seat = m_display->currentInputDevice();
+     auto *origin = seat->pointerFocus();
+@@ -123,7 +125,28 @@ bool QWaylandDataDevice::startDrag(QMimeData *mimeData, QWaylandWindow *icon)
+     }
+ 
+     m_dragSource.reset(new QWaylandDataSource(m_display->dndSelectionHandler(), mimeData));
++
++    if (wl_data_device_get_version(object()) >= 3)
++        m_dragSource->set_actions(dropActionsToWl(supportedActions));
++
+     connect(m_dragSource.data(), &QWaylandDataSource::cancelled, this, &QWaylandDataDevice::dragSourceCancelled);
++    connect(m_dragSource.data(), &QWaylandDataSource::dndResponseUpdated, this, [this](bool accepted, Qt::DropAction action) {
++            auto drag = static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag());
++            // in old versions drop action is not set, so we guess
++            if (wl_data_source_get_version(m_dragSource->object()) < 3) {
++                drag->setResponse(accepted);
++            } else {
++                QPlatformDropQtResponse response(accepted, action);
++                drag->setResponse(response);
++            }
++    });
++    connect(m_dragSource.data(), &QWaylandDataSource::dndDropped, this, [](bool accepted, Qt::DropAction action) {
++        QPlatformDropQtResponse response(accepted, action);
++        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setDropResponse(response);
++    });
++    connect(m_dragSource.data(), &QWaylandDataSource::finished, this, []() {
++        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag();
++    });
+ 
+     start_drag(m_dragSource->object(), origin->wlSurface(), icon->wlSurface(), m_display->currentInputDevice()->serial());
+     return true;
+@@ -152,7 +175,7 @@ void QWaylandDataDevice::data_device_drop()
+         supportedActions = drag->supportedActions();
+     } else if (m_dragOffer) {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     } else {
+         return;
+     }
+@@ -162,7 +185,11 @@ void QWaylandDataDevice::data_device_drop()
+                                                                           QGuiApplication::keyboardModifiers());
+ 
+     if (drag) {
+-        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag(response);
++        auto drag =  static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag());
++        drag->setDropResponse(response);
++        drag->finishDrag();
++    } else if (m_dragOffer) {
++        m_dragOffer->finish();
+     }
+ }
+ 
+@@ -186,7 +213,7 @@ void QWaylandDataDevice::data_device_enter(uint32_t serial, wl_surface *surface,
+         supportedActions = drag->supportedActions();
+     } else if (m_dragOffer) {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     }
+ 
+     const QPlatformDragQtResponse &response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
+@@ -197,11 +224,7 @@ void QWaylandDataDevice::data_device_enter(uint32_t serial, wl_surface *surface,
+         static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setResponse(response);
+     }
+ 
+-    if (response.isAccepted()) {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, m_dragOffer->firstFormat().toUtf8().constData());
+-    } else {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, nullptr);
+-    }
++    sendResponse(supportedActions, response);
+ }
+ 
+ void QWaylandDataDevice::data_device_leave()
+@@ -235,10 +258,10 @@ void QWaylandDataDevice::data_device_motion(uint32_t time, wl_fixed_t x, wl_fixe
+         supportedActions = drag->supportedActions();
+     } else {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     }
+ 
+-    QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
++    const QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
+                                                                           QGuiApplication::mouseButtons(),
+                                                                           QGuiApplication::keyboardModifiers());
+ 
+@@ -246,11 +269,7 @@ void QWaylandDataDevice::data_device_motion(uint32_t time, wl_fixed_t x, wl_fixe
+         static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setResponse(response);
+     }
+ 
+-    if (response.isAccepted()) {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, m_dragOffer->firstFormat().toUtf8().constData());
+-    } else {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, nullptr);
+-    }
++    sendResponse(supportedActions, response);
+ }
+ #endif // QT_CONFIG(draganddrop)
+ 
+@@ -277,14 +296,10 @@ void QWaylandDataDevice::selectionSourceCancelled()
+ #if QT_CONFIG(draganddrop)
+ void QWaylandDataDevice::dragSourceCancelled()
+ {
++    static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag();
+     m_dragSource.reset();
+ }
+ 
+-void QWaylandDataDevice::dragSourceTargetChanged(const QString &mimeType)
+-{
+-    static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->updateTarget(mimeType);
+-}
+-
+ QPoint QWaylandDataDevice::calculateDragPosition(int x, int y, QWindow *wnd) const
+ {
+     QPoint pnt(wl_fixed_to_int(x), wl_fixed_to_int(y));
+@@ -297,6 +312,33 @@ QPoint QWaylandDataDevice::calculateDragPosition(int x, int y, QWindow *wnd) con
+     }
+     return pnt;
+ }
++
++void QWaylandDataDevice::sendResponse(Qt::DropActions supportedActions, const QPlatformDragQtResponse &response)
++{
++    if (response.isAccepted()) {
++        if (wl_data_device_get_version(object()) >= 3)
++            m_dragOffer->set_actions(dropActionsToWl(supportedActions), dropActionsToWl(response.acceptedAction()));
++
++        m_dragOffer->accept(m_enterSerial, m_dragOffer->firstFormat());
++    } else {
++        m_dragOffer->accept(m_enterSerial, QString());
++    }
++}
++
++int QWaylandDataDevice::dropActionsToWl(Qt::DropActions actions)
++{
++
++    int wlActions = WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE;
++    if (actions & Qt::CopyAction)
++        wlActions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY;
++    if (actions & (Qt::MoveAction | Qt::TargetMoveAction))
++        wlActions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE;
++
++    // wayland does not support LinkAction at the time of writing
++    return wlActions;
++}
++
++
+ #endif // QT_CONFIG(draganddrop)
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddatadevice_p.h b/qtwayland/src/client/qwaylanddatadevice_p.h
+index 16c3ad28..801dcc2c 100644
+--- a/qtwayland/src/client/qwaylanddatadevice_p.h
++++ b/qtwayland/src/client/qwaylanddatadevice_p.h
+@@ -64,6 +64,7 @@ QT_REQUIRE_CONFIG(wayland_datadevice);
+ QT_BEGIN_NAMESPACE
+ 
+ class QMimeData;
++class QPlatformDragQtResponse;
+ class QWindow;
+ 
+ namespace QtWaylandClient {
+@@ -89,7 +90,7 @@ public:
+ 
+ #if QT_CONFIG(draganddrop)
+     QWaylandDataOffer *dragOffer() const;
+-    bool startDrag(QMimeData *mimeData, QWaylandWindow *icon);
++    bool startDrag(QMimeData *mimeData, Qt::DropActions supportedActions, QWaylandWindow *icon);
+     void cancelDrag();
+ #endif
+ 
+@@ -109,13 +110,16 @@ private Q_SLOTS:
+ 
+ #if QT_CONFIG(draganddrop)
+     void dragSourceCancelled();
+-    void dragSourceTargetChanged(const QString &mimeType);
+ #endif
+ 
+ private:
+ #if QT_CONFIG(draganddrop)
+     QPoint calculateDragPosition(int x, int y, QWindow *wnd) const;
+ #endif
++    void sendResponse(Qt::DropActions supportedActions, const QPlatformDragQtResponse &response);
++
++    static int dropActionsToWl(Qt::DropActions dropActions);
++
+ 
+     QWaylandDisplay *m_display = nullptr;
+     QWaylandInputDevice *m_inputDevice = nullptr;
+diff --git a/qtwayland/src/client/qwaylanddatadevicemanager.cpp b/qtwayland/src/client/qwaylanddatadevicemanager.cpp
+index 35d67307..6dc4f77f 100644
+--- a/qtwayland/src/client/qwaylanddatadevicemanager.cpp
++++ b/qtwayland/src/client/qwaylanddatadevicemanager.cpp
+@@ -50,8 +50,8 @@ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
+-QWaylandDataDeviceManager::QWaylandDataDeviceManager(QWaylandDisplay *display, uint32_t id)
+-    : wl_data_device_manager(display->wl_registry(), id, 1)
++QWaylandDataDeviceManager::QWaylandDataDeviceManager(QWaylandDisplay *display, int version, uint32_t id)
++    : wl_data_device_manager(display->wl_registry(), id, qMin(version, 3))
+     , m_display(display)
+ {
+     // Create transfer devices for all input devices.
+diff --git a/qtwayland/src/client/qwaylanddatadevicemanager_p.h b/qtwayland/src/client/qwaylanddatadevicemanager_p.h
+index bd05c0fb..510d9be4 100644
+--- a/qtwayland/src/client/qwaylanddatadevicemanager_p.h
++++ b/qtwayland/src/client/qwaylanddatadevicemanager_p.h
+@@ -68,7 +68,7 @@ class QWaylandInputDevice;
+ class Q_WAYLAND_CLIENT_EXPORT QWaylandDataDeviceManager : public QtWayland::wl_data_device_manager
+ {
+ public:
+-    QWaylandDataDeviceManager(QWaylandDisplay *display, uint32_t id);
++    QWaylandDataDeviceManager(QWaylandDisplay *display, int version, uint32_t id);
+     ~QWaylandDataDeviceManager() override;
+ 
+     QWaylandDataDevice *getDataDevice(QWaylandInputDevice *inputDevice);
+diff --git a/qtwayland/src/client/qwaylanddataoffer.cpp b/qtwayland/src/client/qwaylanddataoffer.cpp
+index 2297e8a1..fe0ea8c9 100644
+--- a/qtwayland/src/client/qwaylanddataoffer.cpp
++++ b/qtwayland/src/client/qwaylanddataoffer.cpp
+@@ -82,6 +82,15 @@ QMimeData *QWaylandDataOffer::mimeData()
+     return m_mimeData.data();
+ }
+ 
++Qt::DropActions QWaylandDataOffer::supportedActions() const
++{
++    if (wl_data_offer_get_version(const_cast<::wl_data_offer*>(object())) < 3) {
++        return Qt::MoveAction | Qt::CopyAction;
++    }
++
++    return m_supportedActions;
++}
++
+ void QWaylandDataOffer::startReceiving(const QString &mimeType, int fd)
+ {
+     receive(mimeType, fd);
+@@ -93,6 +102,22 @@ void QWaylandDataOffer::data_offer_offer(const QString &mime_type)
+     m_mimeData->appendFormat(mime_type);
+ }
+ 
++void QWaylandDataOffer::data_offer_action(uint32_t dnd_action)
++{
++    Q_UNUSED(dnd_action);
++    // This is the compositor telling the drag target what action it should perform
++    // It does not map nicely into Qt final drop semantics, other than pretending there is only one supported action?
++}
++
++void QWaylandDataOffer::data_offer_source_actions(uint32_t source_actions)
++{
++    m_supportedActions = Qt::DropActions();
++    if (source_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
++        m_supportedActions |= Qt::MoveAction;
++    if (source_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
++        m_supportedActions |= Qt::CopyAction;
++}
++
+ QWaylandMimeData::QWaylandMimeData(QWaylandAbstractDataOffer *dataOffer)
+     : m_dataOffer(dataOffer)
+ {
+@@ -163,17 +188,18 @@ QVariant QWaylandMimeData::retrieveData_sys(const QString &mimeType, QVariant::T
+ 
+ int QWaylandMimeData::readData(int fd, QByteArray &data) const
+ {
+-    fd_set readset;
+-    FD_ZERO(&readset);
+-    FD_SET(fd, &readset);
+-    struct timeval timeout;
++    struct pollfd readset;
++    readset.fd = fd;
++    readset.events = POLLIN;
++    struct timespec timeout;
+     timeout.tv_sec = 1;
+-    timeout.tv_usec = 0;
++    timeout.tv_nsec = 0;
++
+ 
+     Q_FOREVER {
+-        int ready = select(FD_SETSIZE, &readset, nullptr, nullptr, &timeout);
++        int ready = qt_safe_poll(&readset, 1, &timeout);
+         if (ready < 0) {
+-            qWarning() << "QWaylandDataOffer: select() failed";
++            qWarning() << "QWaylandDataOffer: qt_safe_poll() failed";
+             return -1;
+         } else if (ready == 0) {
+             qWarning("QWaylandDataOffer: timeout reading from pipe");
+diff --git a/qtwayland/src/client/qwaylanddataoffer_p.h b/qtwayland/src/client/qwaylanddataoffer_p.h
+index 9cf1483c..6f667398 100644
+--- a/qtwayland/src/client/qwaylanddataoffer_p.h
++++ b/qtwayland/src/client/qwaylanddataoffer_p.h
+@@ -82,6 +82,7 @@ public:
+     explicit QWaylandDataOffer(QWaylandDisplay *display, struct ::wl_data_offer *offer);
+     ~QWaylandDataOffer() override;
+     QMimeData *mimeData() override;
++    Qt::DropActions supportedActions() const;
+ 
+     QString firstFormat() const;
+ 
+@@ -89,10 +90,13 @@ public:
+ 
+ protected:
+     void data_offer_offer(const QString &mime_type) override;
++    void data_offer_source_actions(uint32_t source_actions) override;
++    void data_offer_action(uint32_t dnd_action) override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+     QScopedPointer<QWaylandMimeData> m_mimeData;
++    Qt::DropActions m_supportedActions;
+ };
+ 
+ 
+diff --git a/qtwayland/src/client/qwaylanddatasource.cpp b/qtwayland/src/client/qwaylanddatasource.cpp
+index f45122fb..5599cbd4 100644
+--- a/qtwayland/src/client/qwaylanddatasource.cpp
++++ b/qtwayland/src/client/qwaylanddatasource.cpp
+@@ -101,7 +101,32 @@ void QWaylandDataSource::data_source_send(const QString &mime_type, int32_t fd)
+ 
+ void QWaylandDataSource::data_source_target(const QString &mime_type)
+ {
+-    Q_EMIT targetChanged(mime_type);
++    m_accepted = !mime_type.isEmpty();
++    Q_EMIT dndResponseUpdated(m_accepted, m_dropAction);
++}
++
++void QWaylandDataSource::data_source_action(uint32_t action)
++{
++    Qt::DropAction qtAction = Qt::IgnoreAction;
++
++    if (action == WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
++        qtAction = Qt::MoveAction;
++    else if (action == WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
++        qtAction = Qt::CopyAction;
++
++    m_dropAction = qtAction;
++    Q_EMIT dndResponseUpdated(m_accepted, m_dropAction);
++}
++
++void QWaylandDataSource::data_source_dnd_finished()
++{
++    Q_EMIT finished();
++}
++
++void QWaylandDataSource::data_source_dnd_drop_performed()
++{
++
++    Q_EMIT dndDropped(m_accepted, m_dropAction);
+ }
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddatasource_p.h b/qtwayland/src/client/qwaylanddatasource_p.h
+index 25afff79..96f07bc3 100644
+--- a/qtwayland/src/client/qwaylanddatasource_p.h
++++ b/qtwayland/src/client/qwaylanddatasource_p.h
+@@ -77,17 +77,25 @@ public:
+     QMimeData *mimeData() const;
+ 
+ Q_SIGNALS:
+-    void targetChanged(const QString &mime_type);
+     void cancelled();
++    void finished();
++
++    void dndResponseUpdated(bool accepted, Qt::DropAction action);
++    void dndDropped(bool accepted, Qt::DropAction action);
+ 
+ protected:
+     void data_source_cancelled() override;
+     void data_source_send(const QString &mime_type, int32_t fd) override;
+     void data_source_target(const QString &mime_type) override;
++    void data_source_dnd_drop_performed() override;
++    void data_source_dnd_finished() override;
++    void data_source_action(uint32_t action) override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+     QMimeData *m_mime_data = nullptr;
++    bool m_accepted = false;
++    Qt::DropAction m_dropAction = Qt::IgnoreAction;
+ };
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddisplay.cpp b/qtwayland/src/client/qwaylanddisplay.cpp
+index f10c1f79..c01e238b 100644
+--- a/qtwayland/src/client/qwaylanddisplay.cpp
++++ b/qtwayland/src/client/qwaylanddisplay.cpp
+@@ -85,10 +85,203 @@
+ 
+ #include <errno.h>
+ 
++#include <tuple> // for std::tie
++
++static void checkWaylandError(struct wl_display *display)
++{
++    int ecode = wl_display_get_error(display);
++    if ((ecode == EPIPE || ecode == ECONNRESET)) {
++        // special case this to provide a nicer error
++        qWarning("The Wayland connection broke. Did the Wayland compositor die?");
++    } else {
++        qWarning("The Wayland connection experienced a fatal error: %s", strerror(ecode));
++    }
++    _exit(1);
++}
++
+ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
++class EventThread : public QThread
++{
++    Q_OBJECT
++public:
++    enum OperatingMode {
++        EmitToDispatch, // Emit the signal, allow dispatching in a differnt thread.
++        SelfDispatch, // Dispatch the events inside this thread.
++    };
++
++    EventThread(struct wl_display * wl, struct wl_event_queue * ev_queue,
++                OperatingMode mode)
++        : m_fd(wl_display_get_fd(wl))
++        , m_pipefd{ -1, -1 }
++        , m_wldisplay(wl)
++        , m_wlevqueue(ev_queue)
++        , m_mode(mode)
++        , m_reading(true)
++        , m_quitting(false)
++    {
++        setObjectName(QStringLiteral("WaylandEventThread"));
++    }
++
++    void readAndDispatchEvents()
++    {
++        /*
++         * Dispatch pending events and flush the requests at least once. If the event thread
++         * is not reading, try to call _prepare_read() to allow the event thread to poll().
++         * If that fails, re-try dispatch & flush again until _prepare_read() is successful.
++         *
++         * This allow any call to readAndDispatchEvents() to start event thread's polling,
++         * not only the one issued from event thread's waitForReading(), which means functions
++         * called from dispatch_pending() can safely spin an event loop.
++         */
++        for (;;) {
++            if (dispatchQueuePending() < 0) {
++                checkWaylandError(m_wldisplay);
++                return;
++            }
++
++            wl_display_flush(m_wldisplay);
++
++            // We have to check if event thread is reading every time we dispatch
++            // something, as that may recursively call this function.
++            if (m_reading.loadAcquire())
++                break;
++
++            if (prepareReadQueue() == 0) {
++                QMutexLocker l(&m_mutex);
++                m_reading.storeRelease(true);
++                m_cond.wakeOne();
++                break;
++            }
++        }
++    }
++
++    void stop()
++    {
++        // We have to both write to the pipe and set the flag, as the thread may be
++        // either in the poll() or waiting for _prepare_read().
++        if (m_pipefd[1] != -1 && write(m_pipefd[1], "\0", 1) == -1)
++            qWarning("Failed to write to the pipe: %s.", strerror(errno));
++
++        {
++            QMutexLocker l(&m_mutex);
++            m_quitting = true;
++            m_cond.wakeOne();
++        }
++
++        wait();
++    }
++
++Q_SIGNALS:
++    void needReadAndDispatch();
++
++protected:
++    void run() override
++    {
++        // we use this pipe to make the loop exit otherwise if we simply used a flag on the loop condition, if stop() gets
++        // called while poll() is blocking the thread will never quit since there are no wayland messages coming anymore.
++        struct Pipe
++        {
++            Pipe(int *fds)
++                : fds(fds)
++            {
++                if (qt_safe_pipe(fds) != 0)
++                    qWarning("Pipe creation failed. Quitting may hang.");
++            }
++            ~Pipe()
++            {
++                if (fds[0] != -1) {
++                    close(fds[0]);
++                    close(fds[1]);
++                }
++            }
++
++            int *fds;
++        } pipe(m_pipefd);
++
++        // Make the main thread call wl_prepare_read(), dispatch the pending messages and flush the
++        // outbound ones. Wait until it's done before proceeding, unless we're told to quit.
++        while (waitForReading()) {
++            pollfd fds[2] = { { m_fd, POLLIN, 0 }, { m_pipefd[0], POLLIN, 0 } };
++            poll(fds, 2, -1);
++
++            if (fds[1].revents & POLLIN) {
++                // we don't really care to read the byte that was written here since we're closing down
++                wl_display_cancel_read(m_wldisplay);
++                break;
++            }
++
++            if (fds[0].revents & POLLIN)
++                wl_display_read_events(m_wldisplay);
++                // The polll was succesfull and the event thread did the wl_display_read_events(). On the next iteration of the loop
++                // the event sent to the main thread will cause it to dispatch the messages just read, unless the loop exits in which
++                // case we don't care anymore about them.
++            else
++                wl_display_cancel_read(m_wldisplay);
++        }
++    }
++
++private:
++    bool waitForReading()
++    {
++        Q_ASSERT(QThread::currentThread() == this);
++
++        m_reading.storeRelease(false);
++
++        if (m_mode == SelfDispatch) {
++            readAndDispatchEvents();
++        } else {
++            Q_EMIT needReadAndDispatch();
++
++            QMutexLocker lock(&m_mutex);
++            // m_reading might be set from our emit or some other invocation of
++            // readAndDispatchEvents().
++            while (!m_reading.loadRelaxed() && !m_quitting)
++                m_cond.wait(&m_mutex);
++        }
++
++        return !m_quitting;
++    }
++
++    int dispatchQueuePending()
++    {
++        if (m_wlevqueue)
++            return wl_display_dispatch_queue_pending(m_wldisplay, m_wlevqueue);
++        else
++            return wl_display_dispatch_pending(m_wldisplay);
++    }
++
++    int prepareReadQueue()
++    {
++        if (m_wlevqueue)
++            return wl_display_prepare_read_queue(m_wldisplay, m_wlevqueue);
++        else
++            return wl_display_prepare_read(m_wldisplay);
++    }
++
++    int m_fd;
++    int m_pipefd[2];
++    wl_display *m_wldisplay;
++    wl_event_queue *m_wlevqueue;
++    OperatingMode m_mode;
++
++    /* Concurrency note when operating in EmitToDispatch mode:
++     * m_reading is set to false inside event thread's waitForReading(), and is
++     * set to true inside main thread's readAndDispatchEvents().
++     * The lock is not taken when setting m_reading to false, as the main thread
++     * is not actively waiting for it to turn false. However, the lock is taken
++     * inside readAndDispatchEvents() before setting m_reading to true,
++     * as the event thread is actively waiting for it under the wait condition.
++     */
++
++    QAtomicInteger<bool> m_reading;
++    bool m_quitting;
++    QMutex m_mutex;
++    QWaitCondition m_cond;
++};
++
+ Q_LOGGING_CATEGORY(lcQpaWayland, "qt.qpa.wayland"); // for general (uncategorized) Wayland platform logging
+ 
+ struct wl_surface *QWaylandDisplay::createSurface(void *handle)
+@@ -158,17 +351,16 @@ QWaylandDisplay::QWaylandDisplay(QWaylandIntegration *waylandIntegration)
+     if (!mXkbContext)
+         qCWarning(lcQpaWayland, "failed to create xkb context");
+ #endif
+-
+-    forceRoundTrip();
+-
+-    if (!mWaitingScreens.isEmpty()) {
+-        // Give wl_output.done and zxdg_output_v1.done events a chance to arrive
+-        forceRoundTrip();
+-    }
+ }
+ 
+ QWaylandDisplay::~QWaylandDisplay(void)
+ {
++    if (m_eventThread)
++        m_eventThread->stop();
++
++    if (m_frameEventQueueThread)
++        m_frameEventQueueThread->stop();
++
+     if (mSyncCallback)
+         wl_callback_destroy(mSyncCallback);
+ 
+@@ -187,6 +379,21 @@ QWaylandDisplay::~QWaylandDisplay(void)
+ #endif
+     if (mDisplay)
+         wl_display_disconnect(mDisplay);
++
++    if (m_frameEventQueue)
++        wl_event_queue_destroy(m_frameEventQueue);
++}
++
++// Steps which is called just after constructor. This separates registry_global() out of the constructor
++// so that factory functions in integration can be overridden.
++void QWaylandDisplay::initialize()
++{
++    forceRoundTrip();
++
++    if (!mWaitingScreens.isEmpty()) {
++        // Give wl_output.done and zxdg_output_v1.done events a chance to arrive
++        forceRoundTrip();
++    }
+ }
+ 
+ void QWaylandDisplay::ensureScreen()
+@@ -203,98 +410,37 @@ void QWaylandDisplay::ensureScreen()
+ 
+ void QWaylandDisplay::checkError() const
+ {
+-    int ecode = wl_display_get_error(mDisplay);
+-    if ((ecode == EPIPE || ecode == ECONNRESET)) {
+-        // special case this to provide a nicer error
+-        qWarning("The Wayland connection broke. Did the Wayland compositor die?");
+-    } else {
+-        qWarning("The Wayland connection experienced a fatal error: %s", strerror(ecode));
+-    }
+-    _exit(1);
++    checkWaylandError(mDisplay);
+ }
+ 
++// Called in main thread, either from queued signal or directly.
+ void QWaylandDisplay::flushRequests()
+ {
+-    if (wl_display_prepare_read(mDisplay) == 0) {
+-        wl_display_read_events(mDisplay);
+-    }
+-
+-    if (wl_display_dispatch_pending(mDisplay) < 0)
+-        checkError();
+-
+-    {
+-        QReadLocker locker(&m_frameQueueLock);
+-        for (const FrameQueue &q : mExternalQueues) {
+-            QMutexLocker locker(q.mutex);
+-            while (wl_display_prepare_read_queue(mDisplay, q.queue) != 0)
+-                wl_display_dispatch_queue_pending(mDisplay, q.queue);
+-            wl_display_read_events(mDisplay);
+-            wl_display_dispatch_queue_pending(mDisplay, q.queue);
+-        }
+-    }
+-
+-    wl_display_flush(mDisplay);
+-}
+-
+-void QWaylandDisplay::blockingReadEvents()
+-{
+-    if (wl_display_dispatch(mDisplay) < 0)
+-        checkError();
+-}
+-
+-void QWaylandDisplay::destroyFrameQueue(const QWaylandDisplay::FrameQueue &q)
+-{
+-    QWriteLocker locker(&m_frameQueueLock);
+-    auto it = std::find_if(mExternalQueues.begin(),
+-                           mExternalQueues.end(),
+-                           [&q] (const QWaylandDisplay::FrameQueue &other){ return other.queue == q.queue; });
+-    Q_ASSERT(it != mExternalQueues.end());
+-    mExternalQueues.erase(it);
+-    if (q.queue != nullptr)
+-        wl_event_queue_destroy(q.queue);
+-    delete q.mutex;
++    m_eventThread->readAndDispatchEvents();
+ }
+ 
+-QWaylandDisplay::FrameQueue QWaylandDisplay::createFrameQueue()
++// We have to wait until we have an eventDispatcher before creating the eventThread,
++// otherwise forceRoundTrip() may block inside _events_read() because eventThread is
++// polling.
++void QWaylandDisplay::initEventThread()
+ {
+-    QWriteLocker locker(&m_frameQueueLock);
+-    FrameQueue q{createEventQueue()};
+-    mExternalQueues.append(q);
+-    return q;
+-}
++    m_eventThread.reset(
++            new EventThread(mDisplay, /* default queue */ nullptr, EventThread::EmitToDispatch));
++    connect(m_eventThread.get(), &EventThread::needReadAndDispatch, this,
++            &QWaylandDisplay::flushRequests, Qt::QueuedConnection);
++    m_eventThread->start();
+ 
+-wl_event_queue *QWaylandDisplay::createEventQueue()
+-{
+-    return wl_display_create_queue(mDisplay);
++    // wl_display_disconnect() free this.
++    m_frameEventQueue = wl_display_create_queue(mDisplay);
++    m_frameEventQueueThread.reset(
++            new EventThread(mDisplay, m_frameEventQueue, EventThread::SelfDispatch));
++    m_frameEventQueueThread->start();
+ }
+ 
+-void QWaylandDisplay::dispatchQueueWhile(wl_event_queue *queue, std::function<bool ()> condition, int timeout)
++void QWaylandDisplay::blockingReadEvents()
+ {
+-    if (!condition())
+-        return;
+-
+-    QElapsedTimer timer;
+-    timer.start();
+-    struct pollfd pFd = qt_make_pollfd(wl_display_get_fd(mDisplay), POLLIN);
+-    while (timeout == -1 || timer.elapsed() < timeout) {
+-        while (wl_display_prepare_read_queue(mDisplay, queue) != 0)
+-            wl_display_dispatch_queue_pending(mDisplay, queue);
+-
+-        wl_display_flush(mDisplay);
+-
+-        const int remaining = qMax(timeout - timer.elapsed(), 0ll);
+-        const int pollTimeout = timeout == -1 ? -1 : remaining;
+-        if (qt_poll_msecs(&pFd, 1, pollTimeout) > 0)
+-            wl_display_read_events(mDisplay);
+-        else
+-            wl_display_cancel_read(mDisplay);
+-
+-        if (wl_display_dispatch_queue_pending(mDisplay, queue) < 0)
+-            checkError();
+-
+-        if (!condition())
+-            break;
+-    }
++    if (wl_display_dispatch(mDisplay) < 0)
++        checkWaylandError(mDisplay);
+ }
+ 
+ QWaylandScreen *QWaylandDisplay::screenForOutput(struct wl_output *output) const
+@@ -345,7 +491,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+     if (interface == QStringLiteral("wl_output")) {
+         mWaitingScreens << new QWaylandScreen(this, version, id);
+     } else if (interface == QStringLiteral("wl_compositor")) {
+-        mCompositorVersion = qMin((int)version, 3);
++        mCompositorVersion = qMin((int)version, 4);
+         mCompositor.init(registry, id, mCompositorVersion);
+     } else if (interface == QStringLiteral("wl_shm")) {
+         mShm.reset(new QWaylandShm(this, version, id));
+@@ -354,7 +500,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+         mInputDevices.append(inputDevice);
+ #if QT_CONFIG(wayland_datadevice)
+     } else if (interface == QStringLiteral("wl_data_device_manager")) {
+-        mDndSelectionHandler.reset(new QWaylandDataDeviceManager(this, id));
++        mDndSelectionHandler.reset(new QWaylandDataDeviceManager(this, version, id));
+ #endif
+     } else if (interface == QStringLiteral("qt_surface_extension")) {
+         mWindowExtension.reset(new QtWayland::qt_surface_extension(registry, id, 1));
+@@ -369,6 +515,8 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+ #if QT_CONFIG(wayland_client_primary_selection)
+     } else if (interface == QStringLiteral("zwp_primary_selection_device_manager_v1")) {
+         mPrimarySelectionManager.reset(new QWaylandPrimarySelectionDeviceManagerV1(this, id, 1));
++        for (QWaylandInputDevice *inputDevice : qAsConst(mInputDevices))
++            inputDevice->setPrimarySelectionDevice(mPrimarySelectionManager->createDevice(inputDevice));
+ #endif
+     } else if (interface == QStringLiteral("zwp_text_input_manager_v2") && !mClientSideInputContextRequested) {
+         mTextInputManager.reset(new QtWayland::zwp_text_input_manager_v2(registry, id, 1));
+@@ -427,6 +575,13 @@ void QWaylandDisplay::registry_global_remove(uint32_t id)
+                     inputDevice->setTextInput(nullptr);
+                 mWaylandIntegration->reconfigureInputContext();
+             }
++#if QT_CONFIG(wayland_client_primary_selection)
++            if (global.interface == QStringLiteral("zwp_primary_selection_device_manager_v1")) {
++                mPrimarySelectionManager.reset();
++                for (QWaylandInputDevice *inputDevice : qAsConst(mInputDevices))
++                    inputDevice->setPrimarySelectionDevice(nullptr);
++            }
++#endif
+             mGlobals.removeAt(i);
+             break;
+         }
+@@ -452,9 +607,10 @@ void QWaylandDisplay::addRegistryListener(RegistryListener listener, void *data)
+ 
+ void QWaylandDisplay::removeListener(RegistryListener listener, void *data)
+ {
+-    std::remove_if(mRegistryListeners.begin(), mRegistryListeners.end(), [=](Listener l){
++    auto iter = std::remove_if(mRegistryListeners.begin(), mRegistryListeners.end(), [=](Listener l){
+         return (l.listener == listener && l.data == data);
+     });
++    mRegistryListeners.erase(iter, mRegistryListeners.end());
+ }
+ 
+ uint32_t QWaylandDisplay::currentTimeMillisec()
+@@ -467,50 +623,9 @@ uint32_t QWaylandDisplay::currentTimeMillisec()
+     return 0;
+ }
+ 
+-static void
+-sync_callback(void *data, struct wl_callback *callback, uint32_t serial)
+-{
+-    Q_UNUSED(serial)
+-    bool *done = static_cast<bool *>(data);
+-
+-    *done = true;
+-
+-    // If the wl_callback done event is received after the condition check in the while loop in
+-    // forceRoundTrip(), but before the call to processEvents, the call to processEvents may block
+-    // forever if no more events are posted (eventhough the callback is handled in response to the
+-    // aboutToBlock signal). Hence, we wake up the event dispatcher so forceRoundTrip may return.
+-    // (QTBUG-64696)
+-    if (auto *dispatcher = QThread::currentThread()->eventDispatcher())
+-        dispatcher->wakeUp();
+-
+-    wl_callback_destroy(callback);
+-}
+-
+-static const struct wl_callback_listener sync_listener = {
+-    sync_callback
+-};
+-
+ void QWaylandDisplay::forceRoundTrip()
+ {
+-    // wl_display_roundtrip() works on the main queue only,
+-    // but we use a separate one, so basically reimplement it here
+-    int ret = 0;
+-    bool done = false;
+-    wl_callback *callback = wl_display_sync(mDisplay);
+-    wl_callback_add_listener(callback, &sync_listener, &done);
+-    flushRequests();
+-    if (QThread::currentThread()->eventDispatcher()) {
+-        while (!done && ret >= 0) {
+-            QThread::currentThread()->eventDispatcher()->processEvents(QEventLoop::WaitForMoreEvents);
+-            ret = wl_display_dispatch_pending(mDisplay);
+-        }
+-    } else {
+-        while (!done && ret >= 0)
+-            ret = wl_display_dispatch(mDisplay);
+-    }
+-
+-    if (ret == -1 && !done)
+-        wl_callback_destroy(callback);
++     wl_display_roundtrip(mDisplay);
+ }
+ 
+ bool QWaylandDisplay::supportsWindowDecoration() const
+@@ -574,14 +689,10 @@ void QWaylandDisplay::handleKeyboardFocusChanged(QWaylandInputDevice *inputDevic
+     if (mLastKeyboardFocus == keyboardFocus)
+         return;
+ 
+-    if (mWaylandIntegration->mShellIntegration) {
+-        mWaylandIntegration->mShellIntegration->handleKeyboardFocusChanged(keyboardFocus, mLastKeyboardFocus);
+-    } else {
+-        if (keyboardFocus)
+-            handleWindowActivated(keyboardFocus);
+-        if (mLastKeyboardFocus)
+-            handleWindowDeactivated(mLastKeyboardFocus);
+-    }
++    if (keyboardFocus)
++        handleWindowActivated(keyboardFocus);
++    if (mLastKeyboardFocus)
++        handleWindowDeactivated(mLastKeyboardFocus);
+ 
+     mLastKeyboardFocus = keyboardFocus;
+ }
+@@ -600,6 +711,19 @@ void QWaylandDisplay::handleWaylandSync()
+     QWindow *activeWindow = mActiveWindows.empty() ? nullptr : mActiveWindows.last()->window();
+     if (activeWindow != QGuiApplication::focusWindow())
+         QWindowSystemInterface::handleWindowActivated(activeWindow);
++
++    if (!activeWindow) {
++        if (lastInputDevice()) {
++#if QT_CONFIG(clipboard)
++            if (auto *dataDevice = lastInputDevice()->dataDevice())
++                dataDevice->invalidateSelectionOffer();
++#endif
++#if QT_CONFIG(wayland_client_primary_selection)
++            if (auto *device = lastInputDevice()->primarySelectionDevice())
++                device->invalidateSelectionOffer();
++#endif
++        }
++    }
+ }
+ 
+ const wl_callback_listener QWaylandDisplay::syncCallbackListener = {
+@@ -626,6 +750,13 @@ QWaylandInputDevice *QWaylandDisplay::defaultInputDevice() const
+     return mInputDevices.isEmpty() ? 0 : mInputDevices.first();
+ }
+ 
++bool QWaylandDisplay::isKeyboardAvailable() const
++{
++    return std::any_of(
++            mInputDevices.constBegin(), mInputDevices.constEnd(),
++            [this](const QWaylandInputDevice *device) { return device->keyboard() != nullptr; });
++}
++
+ #if QT_CONFIG(cursor)
+ 
+ QWaylandCursor *QWaylandDisplay::waylandCursor()
+@@ -652,4 +783,6 @@ QWaylandCursorTheme *QWaylandDisplay::loadCursorTheme(const QString &name, int p
+ 
+ } // namespace QtWaylandClient
+ 
++#include "qwaylanddisplay.moc"
++
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/client/qwaylanddisplay_p.h b/qtwayland/src/client/qwaylanddisplay_p.h
+index 3b092bc8..42bc661d 100644
+--- a/qtwayland/src/client/qwaylanddisplay_p.h
++++ b/qtwayland/src/client/qwaylanddisplay_p.h
+@@ -109,6 +109,7 @@ class QWaylandSurface;
+ class QWaylandShellIntegration;
+ class QWaylandCursor;
+ class QWaylandCursorTheme;
++class EventThread;
+ 
+ typedef void (*RegistryListener)(void *data,
+                                  struct wl_registry *registry,
+@@ -120,15 +121,11 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandDisplay : public QObject, public QtWayland
+     Q_OBJECT
+ 
+ public:
+-    struct FrameQueue {
+-        FrameQueue(wl_event_queue *q = nullptr) : queue(q), mutex(new QMutex) {}
+-        wl_event_queue *queue;
+-        QMutex *mutex;
+-    };
+-
+     QWaylandDisplay(QWaylandIntegration *waylandIntegration);
+     ~QWaylandDisplay(void) override;
+ 
++    void initialize();
++
+ #if QT_CONFIG(xkbcommon)
+     struct xkb_context *xkbContext() const { return mXkbContext.get(); }
+ #endif
+@@ -210,11 +207,11 @@ public:
+     void handleKeyboardFocusChanged(QWaylandInputDevice *inputDevice);
+     void handleWindowDestroyed(QWaylandWindow *window);
+ 
+-    wl_event_queue *createEventQueue();
+-    FrameQueue createFrameQueue();
+-    void destroyFrameQueue(const FrameQueue &q);
+-    void dispatchQueueWhile(wl_event_queue *queue, std::function<bool()> condition, int timeout = -1);
++    wl_event_queue *frameEventQueue() { return m_frameEventQueue; };
++
++    bool isKeyboardAvailable() const;
+ 
++    void initEventThread();
+ public slots:
+     void blockingReadEvents();
+     void flushRequests();
+@@ -237,6 +234,9 @@ private:
+     };
+ 
+     struct wl_display *mDisplay = nullptr;
++    QScopedPointer<EventThread> m_eventThread;
++    wl_event_queue *m_frameEventQueue = nullptr;
++    QScopedPointer<EventThread> m_frameEventQueueThread;
+     QtWayland::wl_compositor mCompositor;
+     QScopedPointer<QWaylandShm> mShm;
+     QList<QWaylandScreen *> mWaitingScreens;
+@@ -273,11 +273,9 @@ private:
+     QWaylandInputDevice *mLastInputDevice = nullptr;
+     QPointer<QWaylandWindow> mLastInputWindow;
+     QPointer<QWaylandWindow> mLastKeyboardFocus;
+-    QVector<QWaylandWindow *> mActiveWindows;
+-    QVector<FrameQueue> mExternalQueues;
++    QList<QWaylandWindow *> mActiveWindows;
+     struct wl_callback *mSyncCallback = nullptr;
+     static const wl_callback_listener syncCallbackListener;
+-    QReadWriteLock m_frameQueueLock;
+ 
+     bool mClientSideInputContextRequested = !QPlatformInputContextFactory::requested().isNull();
+ 
+diff --git a/qtwayland/src/client/qwaylanddnd.cpp b/qtwayland/src/client/qwaylanddnd.cpp
+index 6535aa16..7c53f5fa 100644
+--- a/qtwayland/src/client/qwaylanddnd.cpp
++++ b/qtwayland/src/client/qwaylanddnd.cpp
+@@ -66,7 +66,7 @@ void QWaylandDrag::startDrag()
+ {
+     QBasicDrag::startDrag();
+     QWaylandWindow *icon = static_cast<QWaylandWindow *>(shapedPixmapWindow()->handle());
+-    if (m_display->currentInputDevice()->dataDevice()->startDrag(drag()->mimeData(), icon)) {
++    if (m_display->currentInputDevice()->dataDevice()->startDrag(drag()->mimeData(), drag()->supportedActions(), icon)) {
+         icon->addAttachOffset(-drag()->hotSpot());
+     } else {
+         // Cancelling immediately does not work, since the event loop for QDrag::exec is started
+@@ -80,6 +80,9 @@ void QWaylandDrag::cancel()
+     QBasicDrag::cancel();
+ 
+     m_display->currentInputDevice()->dataDevice()->cancelDrag();
++
++    if (drag())
++        drag()->deleteLater();
+ }
+ 
+ void QWaylandDrag::move(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods)
+@@ -103,33 +106,41 @@ void QWaylandDrag::endDrag()
+     m_display->currentInputDevice()->handleEndDrag();
+ }
+ 
+-void QWaylandDrag::updateTarget(const QString &mimeType)
++void QWaylandDrag::setResponse(bool accepted)
+ {
+-    setCanDrop(!mimeType.isEmpty());
+-
+-    if (canDrop()) {
+-        updateCursor(defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers()));
+-    } else {
+-        updateCursor(Qt::IgnoreAction);
+-    }
++    // This method is used for old DataDevices where the drag action is not communicated
++    Qt::DropAction action = defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers());
++    setResponse(QPlatformDropQtResponse(accepted, action));
+ }
+ 
+-void QWaylandDrag::setResponse(const QPlatformDragQtResponse &response)
++void QWaylandDrag::setResponse(const QPlatformDropQtResponse &response)
+ {
+     setCanDrop(response.isAccepted());
+ 
+     if (canDrop()) {
+-        updateCursor(defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers()));
++        updateCursor(response.acceptedAction());
+     } else {
+         updateCursor(Qt::IgnoreAction);
+     }
+ }
+ 
+-void QWaylandDrag::finishDrag(const QPlatformDropQtResponse &response)
++void QWaylandDrag::setDropResponse(const QPlatformDropQtResponse &response)
+ {
+     setExecutedDropAction(response.acceptedAction());
++}
++
++void QWaylandDrag::finishDrag()
++{
+     QKeyEvent event(QEvent::KeyPress, Qt::Key_Escape, Qt::NoModifier);
+     eventFilter(shapedPixmapWindow(), &event);
++
++    if (drag())
++        drag()->deleteLater();
++}
++
++bool QWaylandDrag::ownsDragObject() const
++{
++    return true;
+ }
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddnd_p.h b/qtwayland/src/client/qwaylanddnd_p.h
+index 474fe2ab..46f629ac 100644
+--- a/qtwayland/src/client/qwaylanddnd_p.h
++++ b/qtwayland/src/client/qwaylanddnd_p.h
+@@ -71,9 +71,10 @@ public:
+     QWaylandDrag(QWaylandDisplay *display);
+     ~QWaylandDrag() override;
+ 
+-    void updateTarget(const QString &mimeType);
+-    void setResponse(const QPlatformDragQtResponse &response);
+-    void finishDrag(const QPlatformDropQtResponse &response);
++    void setResponse(bool accepted);
++    void setResponse(const QPlatformDropQtResponse &response);
++    void setDropResponse(const QPlatformDropQtResponse &response);
++    void finishDrag();
+ 
+ protected:
+     void startDrag() override;
+@@ -82,6 +83,7 @@ protected:
+     void drop(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods) override;
+     void endDrag() override;
+ 
++    bool ownsDragObject() const override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+diff --git a/qtwayland/src/client/qwaylandinputdevice.cpp b/qtwayland/src/client/qwaylandinputdevice.cpp
+index 613fe862..4b90de84 100644
+--- a/qtwayland/src/client/qwaylandinputdevice.cpp
++++ b/qtwayland/src/client/qwaylandinputdevice.cpp
+@@ -685,6 +685,11 @@ public:
+ 
+ void QWaylandInputDevice::Pointer::pointer_leave(uint32_t time, struct wl_surface *surface)
+ {
++    invalidateFocus();
++    mButtons = Qt::NoButton;
++
++    mParent->mTime = time;
++
+     // The event may arrive after destroying the window, indicated by
+     // a null surface.
+     if (!surface)
+@@ -696,11 +701,6 @@ void QWaylandInputDevice::Pointer::pointer_leave(uint32_t time, struct wl_surfac
+ 
+     if (!QWaylandWindow::mouseGrab())
+         setFrameEvent(new LeaveEvent(window, mSurfacePos, mGlobalPos));
+-
+-    invalidateFocus();
+-    mButtons = Qt::NoButton;
+-
+-    mParent->mTime = time;
+ }
+ 
+ class MotionEvent : public QWaylandPointerEvent
+@@ -1300,14 +1300,6 @@ void QWaylandInputDevice::Keyboard::handleFocusDestroyed()
+ void QWaylandInputDevice::Keyboard::handleFocusLost()
+ {
+     mFocus = nullptr;
+-#if QT_CONFIG(clipboard)
+-    if (auto *dataDevice = mParent->dataDevice())
+-        dataDevice->invalidateSelectionOffer();
+-#endif
+-#if QT_CONFIG(wayland_client_primary_selection)
+-    if (auto *device = mParent->primarySelectionDevice())
+-        device->invalidateSelectionOffer();
+-#endif
+     mParent->mQDisplay->handleKeyboardFocusChanged(mParent);
+     mRepeatTimer.stop();
+ }
+@@ -1396,6 +1388,7 @@ void QWaylandInputDevice::Touch::touch_cancel()
+     if (touchExt)
+         touchExt->touchCanceled();
+ 
++    mFocus = nullptr;
+     QWindowSystemInterface::handleTouchCancelEvent(nullptr, mParent->mTouchDevice);
+ }
+ 
+diff --git a/qtwayland/src/client/qwaylandintegration.cpp b/qtwayland/src/client/qwaylandintegration.cpp
+index c53ccb78..54861600 100644
+--- a/qtwayland/src/client/qwaylandintegration.cpp
++++ b/qtwayland/src/client/qwaylandintegration.cpp
+@@ -125,6 +125,9 @@ QWaylandIntegration::QWaylandIntegration()
+ #endif
+ 
+     reconfigureInputContext();
++
++    QWaylandWindow::fixedToplevelPositions =
++            !qEnvironmentVariableIsSet("QT_WAYLAND_DISABLE_FIXED_POSITIONS");
+ }
+ 
+ QWaylandIntegration::~QWaylandIntegration()
+@@ -192,14 +195,18 @@ QAbstractEventDispatcher *QWaylandIntegration::createEventDispatcher() const
+ 
+ void QWaylandIntegration::initialize()
+ {
++    mDisplay->initEventThread();
++
++    // Call after eventDispatcher is fully connected, for QWaylandDisplay::forceRoundTrip()
++    mDisplay->initialize();
++
++    // But the aboutToBlock() and awake() should be connected after initializePlatform().
++    // Otherwise the connected flushRequests() may consumes up all events before processEvents starts to wait,
++    // so that processEvents(QEventLoop::WaitForMoreEvents) may be blocked in the forceRoundTrip().
+     QAbstractEventDispatcher *dispatcher = QGuiApplicationPrivate::eventDispatcher;
+     QObject::connect(dispatcher, SIGNAL(aboutToBlock()), mDisplay.data(), SLOT(flushRequests()));
+     QObject::connect(dispatcher, SIGNAL(awake()), mDisplay.data(), SLOT(flushRequests()));
+ 
+-    int fd = wl_display_get_fd(mDisplay->wl_display());
+-    QSocketNotifier *sn = new QSocketNotifier(fd, QSocketNotifier::Read, mDisplay.data());
+-    QObject::connect(sn, SIGNAL(activated(QSocketDescriptor)), mDisplay.data(), SLOT(flushRequests()));
+-
+     // Qt does not support running with no screens
+     mDisplay->ensureScreen();
+ }
+@@ -262,6 +269,14 @@ QWaylandDisplay *QWaylandIntegration::display() const
+     return mDisplay.data();
+ }
+ 
++Qt::KeyboardModifiers QWaylandIntegration::queryKeyboardModifiers() const
++{
++    if (auto *seat = mDisplay->currentInputDevice()) {
++        return seat->modifiers();
++    }
++    return Qt::NoModifier;
++}
++
+ QList<int> QWaylandIntegration::possibleKeys(const QKeyEvent *event) const
+ {
+     if (auto *seat = mDisplay->currentInputDevice())
+@@ -479,7 +494,7 @@ void QWaylandIntegration::reconfigureInputContext()
+     }
+ #endif
+ 
+-    qCDebug(lcQpaWayland) << "using input method:" << inputContext()->metaObject()->className();
++    qCDebug(lcQpaWayland) << "using input method:" << (inputContext() ? inputContext()->metaObject()->className() : "<none>");
+ }
+ 
+ QWaylandShellIntegration *QWaylandIntegration::createShellIntegration(const QString &integrationName)
+diff --git a/qtwayland/src/client/qwaylandintegration_p.h b/qtwayland/src/client/qwaylandintegration_p.h
+index ff70ae25..73b80658 100644
+--- a/qtwayland/src/client/qwaylandintegration_p.h
++++ b/qtwayland/src/client/qwaylandintegration_p.h
+@@ -107,6 +107,8 @@ public:
+ 
+     QWaylandDisplay *display() const;
+ 
++    Qt::KeyboardModifiers queryKeyboardModifiers() const override;
++
+     QList<int> possibleKeys(const QKeyEvent *event) const override;
+ 
+     QStringList themeNames() const override;
+diff --git a/qtwayland/src/client/qwaylandprimaryselectionv1.cpp b/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
+index 832f9678..ea508771 100644
+--- a/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
++++ b/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
+@@ -54,11 +54,6 @@ QWaylandPrimarySelectionDeviceManagerV1::QWaylandPrimarySelectionDeviceManagerV1
+     : zwp_primary_selection_device_manager_v1(display->wl_registry(), id, qMin(version, uint(1)))
+     , m_display(display)
+ {
+-    // Create devices for all seats.
+-    // This only works if we get the global before all devices
+-    const auto seats = m_display->inputDevices();
+-    for (auto *seat : seats)
+-        seat->setPrimarySelectionDevice(createDevice(seat));
+ }
+ 
+ QWaylandPrimarySelectionDeviceV1 *QWaylandPrimarySelectionDeviceManagerV1::createDevice(QWaylandInputDevice *seat)
+diff --git a/qtwayland/src/client/qwaylandscreen.cpp b/qtwayland/src/client/qwaylandscreen.cpp
+index 6cb337de..5537dafd 100644
+--- a/qtwayland/src/client/qwaylandscreen.cpp
++++ b/qtwayland/src/client/qwaylandscreen.cpp
+@@ -60,7 +60,7 @@ QWaylandXdgOutputManagerV1::QWaylandXdgOutputManagerV1(QWaylandDisplay* display,
+ }
+ 
+ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uint32_t id)
+-    : QtWayland::wl_output(waylandDisplay->wl_registry(), id, qMin(version, 2))
++    : QtWayland::wl_output(waylandDisplay->wl_registry(), id, qMin(version, 3))
+     , m_outputId(id)
+     , mWaylandDisplay(waylandDisplay)
+     , mOutputName(QStringLiteral("Screen%1").arg(id))
+@@ -72,7 +72,7 @@ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uin
+         qCWarning(lcQpaWayland) << "wl_output done event not supported by compositor,"
+                                 << "QScreen may not work correctly";
+         mWaylandDisplay->forceRoundTrip(); // Give the compositor a chance to send geometry etc.
+-        mOutputDone = true; // Fake the done event
++        mProcessedEvents |= OutputDoneEvent; // Fake the done event
+         maybeInitialize();
+     }
+ }
+@@ -81,16 +81,29 @@ QWaylandScreen::~QWaylandScreen()
+ {
+     if (zxdg_output_v1::isInitialized())
+         zxdg_output_v1::destroy();
++    if (wl_output::isInitialized() && wl_output_get_version(wl_output::object()) >= WL_OUTPUT_RELEASE_SINCE_VERSION)
++        wl_output::release();
++}
++
++uint QWaylandScreen::requiredEvents() const
++{
++    uint ret = OutputDoneEvent;
++
++    if (mWaylandDisplay->xdgOutputManager()) {
++        ret |= XdgOutputNameEvent;
++
++        if (mWaylandDisplay->xdgOutputManager()->version() < 3)
++            ret |= XdgOutputDoneEvent;
++    }
++    return ret;
+ }
+ 
+ void QWaylandScreen::maybeInitialize()
+ {
+     Q_ASSERT(!mInitialized);
+ 
+-    if (!mOutputDone)
+-        return;
+-
+-    if (mWaylandDisplay->xdgOutputManager() && !mXdgOutputDone)
++    const uint requiredEvents = this->requiredEvents();
++    if ((mProcessedEvents & requiredEvents) != requiredEvents)
+         return;
+ 
+     mInitialized = true;
+@@ -276,9 +289,8 @@ void QWaylandScreen::output_scale(int32_t factor)
+ 
+ void QWaylandScreen::output_done()
+ {
+-    mOutputDone = true;
+-    if (zxdg_output_v1::isInitialized() && mWaylandDisplay->xdgOutputManager()->version() >= 3)
+-        mXdgOutputDone = true;
++    mProcessedEvents |= OutputDoneEvent;
++
+     if (mInitialized) {
+         updateOutputProperties();
+         if (zxdg_output_v1::isInitialized())
+@@ -339,7 +351,7 @@ void QWaylandScreen::zxdg_output_v1_done()
+     if (Q_UNLIKELY(mWaylandDisplay->xdgOutputManager()->version() >= 3))
+         qWarning(lcQpaWayland) << "zxdg_output_v1.done received on version 3 or newer, this is most likely a bug in the compositor";
+ 
+-    mXdgOutputDone = true;
++    mProcessedEvents |= XdgOutputDoneEvent;
+     if (mInitialized)
+         updateXdgOutputProperties();
+     else
+@@ -348,7 +360,11 @@ void QWaylandScreen::zxdg_output_v1_done()
+ 
+ void QWaylandScreen::zxdg_output_v1_name(const QString &name)
+ {
++    if (Q_UNLIKELY(mInitialized))
++        qWarning(lcQpaWayland) << "zxdg_output_v1.name received after output has been initialized, this is most likely a bug in the compositor";
++
+     mOutputName = name;
++    mProcessedEvents |= XdgOutputNameEvent;
+ }
+ 
+ void QWaylandScreen::updateXdgOutputProperties()
+diff --git a/qtwayland/src/client/qwaylandscreen_p.h b/qtwayland/src/client/qwaylandscreen_p.h
+index df1c94f2..050cfdc0 100644
+--- a/qtwayland/src/client/qwaylandscreen_p.h
++++ b/qtwayland/src/client/qwaylandscreen_p.h
+@@ -116,6 +116,13 @@ public:
+     static QWaylandScreen *fromWlOutput(::wl_output *output);
+ 
+ private:
++    enum Event : uint {
++        XdgOutputDoneEvent = 0x1,
++        OutputDoneEvent = 0x2,
++        XdgOutputNameEvent = 0x4,
++    };
++    uint requiredEvents() const;
++
+     void output_mode(uint32_t flags, int width, int height, int refresh) override;
+     void output_geometry(int32_t x, int32_t y,
+                          int32_t width, int32_t height,
+@@ -148,8 +155,7 @@ private:
+     QSize mPhysicalSize;
+     QString mOutputName;
+     Qt::ScreenOrientation m_orientation = Qt::PrimaryOrientation;
+-    bool mOutputDone = false;
+-    bool mXdgOutputDone = false;
++    uint mProcessedEvents = 0;
+     bool mInitialized = false;
+ 
+ #if QT_CONFIG(cursor)
+diff --git a/qtwayland/src/client/qwaylandshmbackingstore.cpp b/qtwayland/src/client/qwaylandshmbackingstore.cpp
+index dc7ff670..41cffdf7 100644
+--- a/qtwayland/src/client/qwaylandshmbackingstore.cpp
++++ b/qtwayland/src/client/qwaylandshmbackingstore.cpp
+@@ -52,6 +52,7 @@
+ 
+ #include <QtWaylandClient/private/wayland-wayland-client-protocol.h>
+ 
++#include <fcntl.h>
+ #include <unistd.h>
+ #include <sys/mman.h>
+ 
+@@ -61,6 +62,9 @@
+ #  ifndef MFD_CLOEXEC
+ #    define MFD_CLOEXEC     0x0001U
+ #  endif
++#  ifndef MFD_ALLOW_SEALING
++#    define MFD_ALLOW_SEALING 0x0002U
++#  endif
+ #endif
+ 
+ QT_BEGIN_NAMESPACE
+@@ -74,8 +78,10 @@ QWaylandShmBuffer::QWaylandShmBuffer(QWaylandDisplay *display,
+     int alloc = stride * size.height();
+     int fd = -1;
+ 
+-#ifdef SYS_memfd_create
+-    fd = syscall(SYS_memfd_create, "wayland-shm", MFD_CLOEXEC);
++#if defined(SYS_memfd_create) && defined(F_SEAL_SEAL)
++    fd = syscall(SYS_memfd_create, "wayland-shm", MFD_CLOEXEC | MFD_ALLOW_SEALING);
++    if (fd >= 0)
++        fcntl(fd, F_ADD_SEALS, F_SEAL_SHRINK | F_SEAL_SEAL);
+ #endif
+ 
+     QScopedPointer<QFile> filePointer;
+diff --git a/qtwayland/src/client/qwaylandwindow.cpp b/qtwayland/src/client/qwaylandwindow.cpp
+index cb82857a..fb2c59dc 100644
+--- a/qtwayland/src/client/qwaylandwindow.cpp
++++ b/qtwayland/src/client/qwaylandwindow.cpp
+@@ -76,7 +76,6 @@ QWaylandWindow *QWaylandWindow::mMouseGrab = nullptr;
+ QWaylandWindow::QWaylandWindow(QWindow *window, QWaylandDisplay *display)
+     : QPlatformWindow(window)
+     , mDisplay(display)
+-    , mFrameQueue(mDisplay->createFrameQueue())
+     , mResizeAfterSwap(qEnvironmentVariableIsSet("QT_WAYLAND_RESIZE_AFTER_SWAP"))
+ {
+     {
+@@ -95,9 +94,6 @@ QWaylandWindow::QWaylandWindow(QWindow *window, QWaylandDisplay *display)
+ 
+ QWaylandWindow::~QWaylandWindow()
+ {
+-    mDisplay->destroyFrameQueue(mFrameQueue);
+-    mDisplay->handleWindowDestroyed(this);
+-
+     delete mWindowDecoration;
+ 
+     if (mSurface)
+@@ -243,6 +239,7 @@ bool QWaylandWindow::shouldCreateSubSurface() const
+ 
+ void QWaylandWindow::reset()
+ {
++    closeChildPopups();
+     delete mShellSurface;
+     mShellSurface = nullptr;
+     delete mSubSurfaceWindow;
+@@ -255,17 +252,22 @@ void QWaylandWindow::reset()
+         mSurface.reset();
+     }
+ 
+-    if (mFrameCallback) {
+-        wl_callback_destroy(mFrameCallback);
+-        mFrameCallback = nullptr;
+-    }
++    {
++        QMutexLocker lock(&mFrameSyncMutex);
++        if (mFrameCallback) {
++            wl_callback_destroy(mFrameCallback);
++            mFrameCallback = nullptr;
++        }
+ 
+-    mFrameCallbackElapsedTimer.invalidate();
+-    mWaitingForFrameCallback = false;
++        mFrameCallbackElapsedTimer.invalidate();
++        mWaitingForFrameCallback = false;
++    }
+     mFrameCallbackTimedOut = false;
+ 
+     mMask = QRegion();
+     mQueuedBuffer = nullptr;
++
++    mDisplay->handleWindowDestroyed(this);
+ }
+ 
+ QWaylandWindow *QWaylandWindow::fromWlSurface(::wl_surface *surface)
+@@ -351,19 +353,25 @@ void QWaylandWindow::setGeometry_helper(const QRect &rect)
+     }
+ }
+ 
+-void QWaylandWindow::setGeometry(const QRect &rect)
++void QWaylandWindow::setGeometry(const QRect &r)
+ {
++    auto rect = r;
++    if (fixedToplevelPositions && !QPlatformWindow::parent() && window()->type() != Qt::Popup
++        && window()->type() != Qt::ToolTip) {
++        rect.moveTo(screen()->geometry().topLeft());
++    }
+     setGeometry_helper(rect);
+ 
+     if (window()->isVisible() && rect.isValid()) {
+         if (mWindowDecoration)
+             mWindowDecoration->update();
+ 
+-        if (mResizeAfterSwap && windowType() == Egl && mSentInitialResize)
++        if (mResizeAfterSwap && windowType() == Egl && mSentInitialResize) {
++            QMutexLocker lock(&mResizeLock);
+             mResizeDirty = true;
+-        else
++        } else {
+             QWindowSystemInterface::handleGeometryChange(window(), geometry());
+-
++        }
+         mSentInitialResize = true;
+     }
+     QRect exposeGeometry(QPoint(), geometry().size());
+@@ -374,7 +382,7 @@ void QWaylandWindow::setGeometry(const QRect &rect)
+         mShellSurface->setWindowGeometry(windowContentGeometry());
+ 
+     if (isOpaque() && mMask.isEmpty())
+-        setOpaqueArea(rect);
++        setOpaqueArea(QRect(QPoint(0, 0), rect.size()));
+ }
+ 
+ void QWaylandWindow::resizeFromApplyConfigure(const QSize &sizeWithMargins, const QPoint &offset)
+@@ -399,21 +407,6 @@ void QWaylandWindow::sendExposeEvent(const QRect &rect)
+     mLastExposeGeometry = rect;
+ }
+ 
+-
+-static QVector<QPointer<QWaylandWindow>> activePopups;
+-
+-void QWaylandWindow::closePopups(QWaylandWindow *parent)
+-{
+-    while (!activePopups.isEmpty()) {
+-        auto popup = activePopups.takeLast();
+-        if (popup.isNull())
+-            continue;
+-        if (popup.data() == parent)
+-            return;
+-        popup->reset();
+-    }
+-}
+-
+ QPlatformScreen *QWaylandWindow::calculateScreenFromSurfaceEvents() const
+ {
+     QReadLocker lock(&mSurfaceLock);
+@@ -433,10 +426,7 @@ void QWaylandWindow::setVisible(bool visible)
+     lastVisible = visible;
+ 
+     if (visible) {
+-        if (window()->type() == Qt::Popup || window()->type() == Qt::ToolTip)
+-            activePopups << this;
+         initWindow();
+-        mDisplay->flushRequests();
+ 
+         setGeometry(windowGeometry());
+         // Don't flush the events here, or else the newly visible window may start drawing, but since
+@@ -444,7 +434,6 @@ void QWaylandWindow::setVisible(bool visible)
+         // QWaylandShmBackingStore::beginPaint().
+     } else {
+         sendExposeEvent(QRect());
+-        closePopups(this);
+         reset();
+     }
+ }
+@@ -556,12 +545,12 @@ void QWaylandWindow::sendRecursiveExposeEvent()
+ 
+ void QWaylandWindow::attach(QWaylandBuffer *buffer, int x, int y)
+ {
+-    Q_ASSERT(!buffer->committed());
+     QReadLocker locker(&mSurfaceLock);
+     if (mSurface == nullptr)
+         return;
+ 
+     if (buffer) {
++        Q_ASSERT(!buffer->committed());
+         handleUpdate();
+         buffer->setBusy();
+ 
+@@ -583,7 +572,11 @@ void QWaylandWindow::damage(const QRect &rect)
+     if (mSurface == nullptr)
+         return;
+ 
+-    mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    const int s = scale();
++    if (mDisplay->compositorVersion() >= 4)
++        mSurface->damage_buffer(s * rect.x(), s * rect.y(), s * rect.width(), s * rect.height());
++    else
++        mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
+ }
+ 
+ void QWaylandWindow::safeCommit(QWaylandBuffer *buffer, const QRegion &damage)
+@@ -619,8 +612,14 @@ void QWaylandWindow::commit(QWaylandBuffer *buffer, const QRegion &damage)
+         return;
+ 
+     attachOffset(buffer);
+-    for (const QRect &rect: damage)
+-        mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    if (mDisplay->compositorVersion() >= 4) {
++        const int s = scale();
++        for (const QRect &rect: damage)
++            mSurface->damage_buffer(s * rect.x(), s * rect.y(), s * rect.width(), s * rect.height());
++    } else {
++        for (const QRect &rect: damage)
++            mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    }
+     Q_ASSERT(!buffer->committed());
+     buffer->setCommitted();
+     mSurface->commit();
+@@ -635,42 +634,53 @@ void QWaylandWindow::commit()
+ 
+ const wl_callback_listener QWaylandWindow::callbackListener = {
+     [](void *data, wl_callback *callback, uint32_t time) {
+-        Q_UNUSED(callback);
+         Q_UNUSED(time);
+         auto *window = static_cast<QWaylandWindow*>(data);
+-        window->handleFrameCallback();
++        window->handleFrameCallback(callback);
+     }
+ };
+ 
+-void QWaylandWindow::handleFrameCallback()
++void QWaylandWindow::handleFrameCallback(wl_callback* callback)
+ {
++    QMutexLocker locker(&mFrameSyncMutex);
++    if (!mFrameCallback) {
++        // This means the callback is already unset by QWaylandWindow::reset.
++        // The wl_callback object will be destroyed there too.
++        return;
++    }
++    Q_ASSERT(callback == mFrameCallback);
++    wl_callback_destroy(callback);
++    mFrameCallback = nullptr;
++
+     mWaitingForFrameCallback = false;
+     mFrameCallbackElapsedTimer.invalidate();
+ 
+     // The rest can wait until we can run it on the correct thread
+-    if (!mWaitingForUpdateDelivery) {
+-        auto doHandleExpose = [this]() {
+-            bool wasExposed = isExposed();
+-            mFrameCallbackTimedOut = false;
+-            if (!wasExposed && isExposed()) // Did setting mFrameCallbackTimedOut make the window exposed?
+-                sendExposeEvent(QRect(QPoint(), geometry().size()));
+-            if (wasExposed && hasPendingUpdateRequest())
+-                deliverUpdateRequest();
+-
+-            mWaitingForUpdateDelivery = false;
+-        };
++    auto doHandleExpose = [this]() {
++        mWaitingForUpdateDelivery.storeRelease(false);
++        bool wasExposed = isExposed();
++        mFrameCallbackTimedOut = false;
++        if (!wasExposed && isExposed()) // Did setting mFrameCallbackTimedOut make the window exposed?
++            sendExposeEvent(QRect(QPoint(), geometry().size()));
++        if (wasExposed && hasPendingUpdateRequest())
++            deliverUpdateRequest();
++    };
+ 
++    if (mWaitingForUpdateDelivery.testAndSetAcquire(false, true)) {
+         // Queued connection, to make sure we don't call handleUpdate() from inside waitForFrameSync()
+         // in the single-threaded case.
+-        mWaitingForUpdateDelivery = true;
+         QMetaObject::invokeMethod(this, doHandleExpose, Qt::QueuedConnection);
+     }
++
++    mFrameSyncWait.notify_all();
+ }
+ 
+ bool QWaylandWindow::waitForFrameSync(int timeout)
+ {
+-    QMutexLocker locker(mFrameQueue.mutex);
+-    mDisplay->dispatchQueueWhile(mFrameQueue.queue, [&]() { return mWaitingForFrameCallback; }, timeout);
++    QMutexLocker locker(&mFrameSyncMutex);
++
++    QDeadlineTimer deadline(timeout);
++    while (mWaitingForFrameCallback && mFrameSyncWait.wait(&mFrameSyncMutex, deadline)) { }
+ 
+     if (mWaitingForFrameCallback) {
+         qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
+@@ -868,6 +878,17 @@ bool QWaylandWindow::createDecoration()
+             subsurf->set_position(pos.x() + m.left(), pos.y() + m.top());
+         }
+         sendExposeEvent(QRect(QPoint(), geometry().size()));
++
++        // This is a special case where the buffer is recreated, but since
++        // the content rect remains the same, the widgets remain the same
++        // size and are not redrawn, leaving the new buffer empty. As a simple
++        // work-around, we trigger a full extra update whenever the client-side
++        // window decorations are toggled while the window is showing.
++        // Note: createDecoration() is sometimes called from the render thread
++        // of Qt Quick. This is essentially wrong and could potentially cause problems,
++        // but until the underlying issue has been fixed, we have to use invokeMethod()
++        // here to avoid asserts.
++        QMetaObject::invokeMethod(window(), &QWindow::requestUpdate);
+     }
+ 
+     return mWindowDecoration;
+@@ -1023,6 +1044,13 @@ void QWaylandWindow::handleScreensChanged()
+ 
+     QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->QPlatformScreen::screen());
+     mLastReportedScreen = newScreen;
++    if (fixedToplevelPositions && !QPlatformWindow::parent() && window()->type() != Qt::Popup
++        && window()->type() != Qt::ToolTip
++        && geometry().topLeft() != newScreen->geometry().topLeft()) {
++        auto geometry = this->geometry();
++        geometry.moveTo(newScreen->geometry().topLeft());
++        setGeometry(geometry);
++    }
+ 
+     int scale = newScreen->isPlaceholder() ? 1 : static_cast<QWaylandScreen *>(newScreen)->scale();
+     if (scale != mScale) {
+@@ -1094,10 +1122,18 @@ bool QWaylandWindow::setMouseGrabEnabled(bool grab)
+     return true;
+ }
+ 
++Qt::WindowStates QWaylandWindow::windowStates() const
++{
++    return mLastReportedWindowStates;
++}
++
+ void QWaylandWindow::handleWindowStatesChanged(Qt::WindowStates states)
+ {
+     createDecoration();
+-    QWindowSystemInterface::handleWindowStateChanged(window(), states, mLastReportedWindowStates);
++    Qt::WindowStates statesWithoutActive = states & ~Qt::WindowActive;
++    Qt::WindowStates lastStatesWithoutActive = mLastReportedWindowStates & ~Qt::WindowActive;
++    QWindowSystemInterface::handleWindowStateChanged(window(), statesWithoutActive,
++                                                     lastStatesWithoutActive);
+     mLastReportedWindowStates = states;
+ }
+ 
+@@ -1139,19 +1175,24 @@ void QWaylandWindow::timerEvent(QTimerEvent *event)
+     if (event->timerId() != mFrameCallbackCheckIntervalTimerId)
+         return;
+ 
+-    bool callbackTimerExpired = mFrameCallbackElapsedTimer.hasExpired(mFrameCallbackTimeout);
+-    if (!mFrameCallbackElapsedTimer.isValid() || callbackTimerExpired ) {
+-        killTimer(mFrameCallbackCheckIntervalTimerId);
+-        mFrameCallbackCheckIntervalTimerId = -1;
+-    }
+-    if (mFrameCallbackElapsedTimer.isValid() && callbackTimerExpired) {
+-        mFrameCallbackElapsedTimer.invalidate();
++    {
++        QMutexLocker lock(&mFrameSyncMutex);
+ 
+-        qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
+-        mFrameCallbackTimedOut = true;
+-        mWaitingForUpdate = false;
+-        sendExposeEvent(QRect());
++        bool callbackTimerExpired = mFrameCallbackElapsedTimer.hasExpired(mFrameCallbackTimeout);
++        if (!mFrameCallbackElapsedTimer.isValid() || callbackTimerExpired ) {
++            killTimer(mFrameCallbackCheckIntervalTimerId);
++            mFrameCallbackCheckIntervalTimerId = -1;
++        }
++        if (!mFrameCallbackElapsedTimer.isValid() || !callbackTimerExpired) {
++            return;
++        }
++        mFrameCallbackElapsedTimer.invalidate();
+     }
++
++    qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
++    mFrameCallbackTimedOut = true;
++    mWaitingForUpdate = false;
++    sendExposeEvent(QRect());
+ }
+ 
+ void QWaylandWindow::requestUpdate()
+@@ -1160,8 +1201,11 @@ void QWaylandWindow::requestUpdate()
+     Q_ASSERT(hasPendingUpdateRequest()); // should be set by QPA
+ 
+     // If we have a frame callback all is good and will be taken care of there
+-    if (mWaitingForFrameCallback)
+-        return;
++    {
++        QMutexLocker locker(&mFrameSyncMutex);
++        if (mWaitingForFrameCallback)
++            return;
++    }
+ 
+     // If we've already called deliverUpdateRequest(), but haven't seen any attach+commit/swap yet
+     // This is a somewhat redundant behavior and might indicate a bug in the calling code, so log
+@@ -1174,7 +1218,12 @@ void QWaylandWindow::requestUpdate()
+     // so use invokeMethod to delay the delivery a bit.
+     QMetaObject::invokeMethod(this, [this] {
+         // Things might have changed in the meantime
+-        if (hasPendingUpdateRequest() && !mWaitingForFrameCallback)
++        {
++            QMutexLocker locker(&mFrameSyncMutex);
++            if (mWaitingForFrameCallback)
++                return;
++        }
++        if (hasPendingUpdateRequest())
+             deliverUpdateRequest();
+     }, Qt::QueuedConnection);
+ }
+@@ -1185,19 +1234,18 @@ void QWaylandWindow::requestUpdate()
+ void QWaylandWindow::handleUpdate()
+ {
+     qCDebug(lcWaylandBackingstore) << "handleUpdate" << QThread::currentThread();
++
+     // TODO: Should sync subsurfaces avoid requesting frame callbacks?
+     QReadLocker lock(&mSurfaceLock);
+     if (!mSurface)
+         return;
+ 
+-    if (mFrameCallback) {
+-        wl_callback_destroy(mFrameCallback);
+-        mFrameCallback = nullptr;
+-    }
++    QMutexLocker locker(&mFrameSyncMutex);
++    if (mWaitingForFrameCallback)
++        return;
+ 
+-    QMutexLocker locker(mFrameQueue.mutex);
+     struct ::wl_surface *wrappedSurface = reinterpret_cast<struct ::wl_surface *>(wl_proxy_create_wrapper(mSurface->object()));
+-    wl_proxy_set_queue(reinterpret_cast<wl_proxy *>(wrappedSurface), mFrameQueue.queue);
++    wl_proxy_set_queue(reinterpret_cast<wl_proxy *>(wrappedSurface), mDisplay->frameEventQueue());
+     mFrameCallback = wl_surface_frame(wrappedSurface);
+     wl_proxy_wrapper_destroy(wrappedSurface);
+     wl_callback_add_listener(mFrameCallback, &QWaylandWindow::callbackListener, this);
+@@ -1207,6 +1255,8 @@ void QWaylandWindow::handleUpdate()
+     // Start a timer for handling the case when the compositor stops sending frame callbacks.
+     if (mFrameCallbackTimeout > 0) {
+         QMetaObject::invokeMethod(this, [this] {
++            QMutexLocker locker(&mFrameSyncMutex);
++
+             if (mWaitingForFrameCallback) {
+                 if (mFrameCallbackCheckIntervalTimerId < 0)
+                     mFrameCallbackCheckIntervalTimerId = startTimer(mFrameCallbackTimeout);
+@@ -1267,6 +1317,20 @@ void QWaylandWindow::setOpaqueArea(const QRegion &opaqueArea)
+     wl_region_destroy(region);
+ }
+ 
++void QWaylandWindow::addChildPopup(QWaylandWindow *surface) {
++    mChildPopups.append(surface);
++}
++
++void QWaylandWindow::removeChildPopup(QWaylandWindow *surface) {
++    mChildPopups.removeAll(surface);
++}
++
++void QWaylandWindow::closeChildPopups() {
++    while (!mChildPopups.isEmpty()) {
++        auto popup = mChildPopups.takeLast();
++        popup->reset();
++    }
++}
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/client/qwaylandwindow_p.h b/qtwayland/src/client/qwaylandwindow_p.h
+index 01337cff..2f219d8c 100644
+--- a/qtwayland/src/client/qwaylandwindow_p.h
++++ b/qtwayland/src/client/qwaylandwindow_p.h
+@@ -98,6 +98,9 @@ public:
+     QWaylandWindow(QWindow *window, QWaylandDisplay *display);
+     ~QWaylandWindow() override;
+ 
++    // Keep Toplevels position on the top left corner of their screen
++    static inline bool fixedToplevelPositions = true;
++
+     virtual WindowType windowType() const = 0;
+     virtual void ensureSize();
+     WId winId() const override;
+@@ -148,6 +151,7 @@ public:
+     void setWindowState(Qt::WindowStates states) override;
+     void setWindowFlags(Qt::WindowFlags flags) override;
+     void handleWindowStatesChanged(Qt::WindowStates states);
++    Qt::WindowStates windowStates() const;
+ 
+     void raise() override;
+     void lower() override;
+@@ -206,6 +210,10 @@ public:
+     void handleUpdate();
+     void deliverUpdateRequest() override;
+ 
++    void addChildPopup(QWaylandWindow* child);
++    void removeChildPopup(QWaylandWindow* child);
++    void closeChildPopups();
++
+ public slots:
+     void applyConfigure();
+ 
+@@ -215,7 +223,11 @@ signals:
+ 
+ protected:
+     QWaylandDisplay *mDisplay = nullptr;
++
++    // mSurface can be written by the main thread. Other threads should claim a read lock for access
++    mutable QReadWriteLock mSurfaceLock;
+     QScopedPointer<QWaylandSurface> mSurface;
++
+     QWaylandShellSurface *mShellSurface = nullptr;
+     QWaylandSubSurface *mSubSurfaceWindow = nullptr;
+     QVector<QWaylandSubSurface *> mChildren;
+@@ -225,13 +237,14 @@ protected:
+     Qt::MouseButtons mMousePressedInContentArea = Qt::NoButton;
+ 
+     WId mWindowId;
+-    bool mWaitingForFrameCallback = false;
+     bool mFrameCallbackTimedOut = false; // Whether the frame callback has timed out
+-    bool mWaitingForUpdateDelivery = false;
+     int mFrameCallbackCheckIntervalTimerId = -1;
+-    QElapsedTimer mFrameCallbackElapsedTimer;
+-    struct ::wl_callback *mFrameCallback = nullptr;
+-    QWaylandDisplay::FrameQueue mFrameQueue;
++    QAtomicInt mWaitingForUpdateDelivery = false;
++
++    bool mWaitingForFrameCallback = false; // Protected by mFrameSyncMutex
++    QElapsedTimer mFrameCallbackElapsedTimer; // Protected by mFrameSyncMutex
++    struct ::wl_callback *mFrameCallback = nullptr; // Protected by mFrameSyncMutex
++    QMutex mFrameSyncMutex;
+     QWaitCondition mFrameSyncWait;
+ 
+     // True when we have called deliverRequestUpdate, but the client has not yet attached a new buffer
+@@ -261,6 +274,8 @@ protected:
+     QWaylandBuffer *mQueuedBuffer = nullptr;
+     QRegion mQueuedBufferDamage;
+ 
++    QList<QPointer<QWaylandWindow>> mChildPopups;
++
+ private:
+     void setGeometry_helper(const QRect &rect);
+     void initWindow();
+@@ -283,12 +298,10 @@ private:
+     QRect mLastExposeGeometry;
+ 
+     static const wl_callback_listener callbackListener;
+-    void handleFrameCallback();
++    void handleFrameCallback(struct ::wl_callback* callback);
+ 
+     static QWaylandWindow *mMouseGrab;
+ 
+-    mutable QReadWriteLock mSurfaceLock;
+-
+     friend class QWaylandSubSurface;
+ };
+ 
+diff --git a/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h b/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
+index ccad0048..4cc9b3b8 100644
+--- a/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
++++ b/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
+@@ -73,11 +73,10 @@ public:
+         return true;
+     }
+     virtual QWaylandShellSurface *createShellSurface(QWaylandWindow *window) = 0;
++    // kept for binary compat with layer-shell-qt
+     virtual void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) {
+-        if (newFocus)
+-            m_display->handleWindowActivated(newFocus);
+-        if (oldFocus)
+-            m_display->handleWindowDeactivated(oldFocus);
++        Q_UNUSED(newFocus);
++        Q_UNUSED(oldFocus);
+     }
+     virtual void *nativeResourceForWindow(const QByteArray &resource, QWindow *window) {
+         Q_UNUSED(resource);
+diff --git a/qtwayland/src/compositor/configure.json b/qtwayland/src/compositor/configure.json
+index bcfd5215..da95d07b 100644
+--- a/qtwayland/src/compositor/configure.json
++++ b/qtwayland/src/compositor/configure.json
+@@ -7,6 +7,31 @@
+     "testDir": "../../config.tests",
+ 
+     "libraries": {
++        "wayland-client": {
++            "label": "Wayland client library",
++            "headers": "wayland-version.h",
++            "test": {
++                "main": [
++                    "#if WAYLAND_VERSION_MAJOR < 1",
++                    "# error Wayland 1.8.0 or higher required",
++                    "#endif",
++                    "#if WAYLAND_VERSION_MAJOR == 1",
++                    "# if WAYLAND_VERSION_MINOR < 8",
++                    "#  error Wayland 1.8.0 or higher required",
++                    "# endif",
++                    "# if WAYLAND_VERSION_MINOR == 8",
++                    "#  if WAYLAND_VERSION_MICRO < 0",
++                    "#   error Wayland 1.8.0 or higher required",
++                    "#  endif",
++                    "# endif",
++                    "#endif"
++                 ]
++            },
++            "sources": [
++                { "type": "pkgConfig", "args": "wayland-client" },
++                "-lwayland-client"
++            ]
++        },
+         "wayland-server": {
+             "label": "wayland-server",
+             "headers": "wayland-version.h",
+@@ -151,8 +176,7 @@
+                     "#endif"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "dmabuf-client-buffer": {
+             "label": "Linux Client dma-buf Buffer Sharing",
+@@ -176,8 +200,7 @@
+                     "return 0;"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "vulkan-server-buffer": {
+             "label": "Vulkan Buffer Sharing",
+@@ -195,7 +218,8 @@
+                     "exportAllocInfo.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR;",
+                     "return 0;"
+                 ]
+-            }
++            },
++            "use": "wayland-client"
+         }
+     },
+ 
+diff --git a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
+index 7889f575..64140672 100644
+--- a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
++++ b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
+@@ -40,6 +40,7 @@
+ #include "qwaylandeglwindow.h"
+ 
+ #include <QtWaylandClient/private/qwaylandscreen_p.h>
++#include <QtWaylandClient/private/qwaylandsurface_p.h>
+ #include "qwaylandglcontext.h"
+ 
+ #include <QtEglSupport/private/qeglconvenience_p.h>
+@@ -124,6 +125,7 @@ void QWaylandEglWindow::updateSurface(bool create)
+         }
+         mOffset = QPoint();
+     } else {
++        QReadLocker locker(&mSurfaceLock);
+         if (m_waylandEglWindow) {
+             int current_width, current_height;
+             static bool disableResizeCheck = qgetenv("QT_WAYLAND_DISABLE_RESIZECHECK").toInt();
+@@ -131,14 +133,16 @@ void QWaylandEglWindow::updateSurface(bool create)
+             if (!disableResizeCheck) {
+                 wl_egl_window_get_attached_size(m_waylandEglWindow, &current_width, &current_height);
+             }
+-            if (disableResizeCheck || (current_width != sizeWithMargins.width() || current_height != sizeWithMargins.height())) {
++            if (disableResizeCheck || (current_width != sizeWithMargins.width() || current_height != sizeWithMargins.height()) || m_requestedSize != sizeWithMargins) {
+                 wl_egl_window_resize(m_waylandEglWindow, sizeWithMargins.width(), sizeWithMargins.height(), mOffset.x(), mOffset.y());
++                m_requestedSize = sizeWithMargins;
+                 mOffset = QPoint();
+ 
+                 m_resize = true;
+             }
+-        } else if (create && wlSurface()) {
+-            m_waylandEglWindow = wl_egl_window_create(wlSurface(), sizeWithMargins.width(), sizeWithMargins.height());
++        } else if (create && mSurface) {
++            m_waylandEglWindow = wl_egl_window_create(mSurface->object(), sizeWithMargins.width(), sizeWithMargins.height());
++            m_requestedSize = sizeWithMargins;
+         }
+ 
+         if (!m_eglSurface && m_waylandEglWindow && create) {
+diff --git a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
+index 5b1f4d56..0079dfef 100644
+--- a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
++++ b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
+@@ -88,6 +88,7 @@ private:
+     mutable QOpenGLFramebufferObject *m_contentFBO = nullptr;
+ 
+     QSurfaceFormat m_format;
++    QSize m_requestedSize;
+ };
+ 
+ }
+diff --git a/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h b/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
+index 56a710c3..c6a8b6c6 100644
+--- a/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
++++ b/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
+@@ -41,6 +41,8 @@
+ #include <QtCore/QTextStream>
+ #include <QtGui/QOpenGLTexture>
+ 
++#include <array>
++
+ #include <EGL/egl.h>
+ #include <EGL/eglext.h>
+ 
+diff --git a/qtwayland/src/plugins/decorations/bradient/main.cpp b/qtwayland/src/plugins/decorations/bradient/main.cpp
+index e75fda3c..fa885143 100644
+--- a/qtwayland/src/plugins/decorations/bradient/main.cpp
++++ b/qtwayland/src/plugins/decorations/bradient/main.cpp
+@@ -164,13 +164,10 @@ void QWaylandBradientDecoration::paint(QPaintDevice *device)
+     // Window icon
+     QIcon icon = waylandWindow()->windowIcon();
+     if (!icon.isNull()) {
+-        QPixmap pixmap = icon.pixmap(QSize(128, 128));
+-        QPixmap scaled = pixmap.scaled(22, 22, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+-
+         QRectF iconRect(0, 0, 22, 22);
+-        p.drawPixmap(iconRect.adjusted(margins().left() + BUTTON_SPACING, 4,
+-                                       margins().left() + BUTTON_SPACING, 4),
+-                     scaled, iconRect);
++        iconRect.adjust(margins().left() + BUTTON_SPACING, 4,
++                        margins().left() + BUTTON_SPACING, 4),
++        icon.paint(&p, iconRect.toRect());
+     }
+ 
+     // Window title
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
+index 85d25e3c..60bdd491 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
+@@ -47,18 +47,21 @@ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
+-QWaylandXdgPopupV5::QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow *window)
++QWaylandXdgPopupV5::QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow* parent, QWaylandWindow *window)
+     : QWaylandShellSurface(window)
+     , QtWayland::xdg_popup_v5(popup)
++    , m_parent(parent)
+     , m_window(window)
+ {
+     if (window->display()->windowExtension())
+         m_extendedWindow = new QWaylandExtendedSurface(window);
++    m_parent->addChildPopup(m_window);
+ }
+ 
+ QWaylandXdgPopupV5::~QWaylandXdgPopupV5()
+ {
+     xdg_popup_destroy(object());
++    m_parent->removeChildPopup(m_window);
+     delete m_extendedWindow;
+ }
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
+index 7494f6a6..d85f130b 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
+@@ -70,7 +70,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgPopupV5 : public QWaylandShellSurface
+ {
+     Q_OBJECT
+ public:
+-    QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow *window);
++    QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow* parent, QWaylandWindow *window);
+     ~QWaylandXdgPopupV5() override;
+ 
+ protected:
+@@ -78,6 +78,7 @@ protected:
+ 
+ private:
+     QWaylandExtendedSurface *m_extendedWindow = nullptr;
++    QWaylandWindow *m_parent = nullptr;
+     QWaylandWindow *m_window = nullptr;
+ };
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
+index 7e242c4a..def8452a 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
+@@ -84,7 +84,7 @@ QWaylandXdgPopupV5 *QWaylandXdgShellV5::createXdgPopup(QWaylandWindow *window, Q
+     int x = position.x() + parentWindow->frameMargins().left();
+     int y = position.y() + parentWindow->frameMargins().top();
+ 
+-    auto popup = new QWaylandXdgPopupV5(get_xdg_popup(window->wlSurface(), parentSurface, seat, m_popupSerial, x, y), window);
++    auto popup = new QWaylandXdgPopupV5(get_xdg_popup(window->wlSurface(), parentSurface, seat, m_popupSerial, x, y), parentWindow, window);
+     m_popups.append(window);
+     QObject::connect(popup, &QWaylandXdgPopupV5::destroyed, [this, window](){
+         m_popups.removeOne(window);
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
+index 4e25949f..cfc60939 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
+@@ -85,13 +85,6 @@ QWaylandShellSurface *QWaylandXdgShellV5Integration::createShellSurface(QWayland
+     return m_xdgShell->createXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellV5Integration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) {
+-    if (newFocus && qobject_cast<QWaylandXdgPopupV5 *>(newFocus->shellSurface()))
+-        m_display->handleWindowActivated(newFocus);
+-    if (oldFocus && qobject_cast<QWaylandXdgPopupV5 *>(oldFocus->shellSurface()))
+-        m_display->handleWindowDeactivated(oldFocus);
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
+index ce6bdb9e..aed88670 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
+@@ -67,7 +67,6 @@ public:
+     QWaylandXdgShellV5Integration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShellV5> m_xdgShell;
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
+index 8c371661..151c78e3 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
+@@ -174,6 +174,7 @@ QWaylandXdgSurfaceV6::Popup::Popup(QWaylandXdgSurfaceV6 *xdgSurface, QWaylandXdg
+     , m_xdgSurface(xdgSurface)
+     , m_parent(parent)
+ {
++    m_parent->window()->addChildPopup(m_xdgSurface->window());
+ }
+ 
+ QWaylandXdgSurfaceV6::Popup::~Popup()
+@@ -181,6 +182,8 @@ QWaylandXdgSurfaceV6::Popup::~Popup()
+     if (isInitialized())
+         destroy();
+ 
++    m_parent->window()->removeChildPopup(m_xdgSurface->window());
++
+     if (m_grabbing) {
+         auto *shell = m_xdgSurface->m_shell;
+         Q_ASSERT(shell->m_topmostGrabbingPopup == this);
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
+index 03164316..e8da8ba1 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
+@@ -68,20 +68,6 @@ QWaylandShellSurface *QWaylandXdgShellV6Integration::createShellSurface(QWayland
+     return m_xdgShell->getXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellV6Integration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus)
+-{
+-    if (newFocus) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurfaceV6 *>(newFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowActivated(newFocus);
+-    }
+-    if (oldFocus && qobject_cast<QWaylandXdgSurfaceV6 *>(oldFocus->shellSurface())) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurfaceV6 *>(oldFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowDeactivated(oldFocus);
+-    }
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
+index 261f8cbb..c1bcd5c6 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
+@@ -65,7 +65,6 @@ public:
+     QWaylandXdgShellV6Integration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShellV6> m_xdgShell;
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
+index f3e3c330..fa6d5808 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
+@@ -67,11 +67,6 @@ QWaylandXdgSurface::Toplevel::Toplevel(QWaylandXdgSurface *xdgSurface)
+ 
+ QWaylandXdgSurface::Toplevel::~Toplevel()
+ {
+-    if (m_applied.states & Qt::WindowActive) {
+-        QWaylandWindow *window = m_xdgSurface->window();
+-        window->display()->handleWindowDeactivated(window);
+-    }
+-
+     // The protocol spec requires that the decoration object is deleted before xdg_toplevel.
+     delete m_decoration;
+     m_decoration = nullptr;
+@@ -85,16 +80,15 @@ void QWaylandXdgSurface::Toplevel::applyConfigure()
+     if (!(m_applied.states & (Qt::WindowMaximized|Qt::WindowFullScreen)))
+         m_normalSize = m_xdgSurface->m_window->windowFrameGeometry().size();
+ 
+-    if ((m_pending.states & Qt::WindowActive) && !(m_applied.states & Qt::WindowActive))
++    if ((m_pending.states & Qt::WindowActive) && !(m_applied.states & Qt::WindowActive)
++        && !m_xdgSurface->m_window->display()->isKeyboardAvailable())
+         m_xdgSurface->m_window->display()->handleWindowActivated(m_xdgSurface->m_window);
+ 
+-    if (!(m_pending.states & Qt::WindowActive) && (m_applied.states & Qt::WindowActive))
++    if (!(m_pending.states & Qt::WindowActive) && (m_applied.states & Qt::WindowActive)
++        && !m_xdgSurface->m_window->display()->isKeyboardAvailable())
+         m_xdgSurface->m_window->display()->handleWindowDeactivated(m_xdgSurface->m_window);
+ 
+-    // TODO: none of the other plugins send WindowActive either, but is it on purpose?
+-    Qt::WindowStates statesWithoutActive = m_pending.states & ~Qt::WindowActive;
+-
+-    m_xdgSurface->m_window->handleWindowStatesChanged(statesWithoutActive);
++    m_xdgSurface->m_window->handleWindowStatesChanged(m_pending.states);
+ 
+     if (m_pending.size.isEmpty()) {
+         // An empty size in the configure means it's up to the client to choose the size
+@@ -105,8 +99,6 @@ void QWaylandXdgSurface::Toplevel::applyConfigure()
+         m_xdgSurface->m_window->resizeFromApplyConfigure(m_pending.size);
+     }
+ 
+-    m_xdgSurface->setSizeHints();
+-
+     m_applied = m_pending;
+     qCDebug(lcQpaWayland) << "Applied pending xdg_toplevel configure event:" << m_applied.size << m_applied.states;
+ }
+@@ -203,12 +195,17 @@ QtWayland::xdg_toplevel::resize_edge QWaylandXdgSurface::Toplevel::convertToResi
+                 | ((edges & Qt::RightEdge) ? resize_edge_right : 0));
+ }
+ 
+-QWaylandXdgSurface::Popup::Popup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parent,
++QWaylandXdgSurface::Popup::Popup(QWaylandXdgSurface *xdgSurface, QWaylandWindow *parent,
+                                  QtWayland::xdg_positioner *positioner)
+-    : xdg_popup(xdgSurface->get_popup(parent->object(), positioner->object()))
+-    , m_xdgSurface(xdgSurface)
++    : m_xdgSurface(xdgSurface)
++    , m_parentXdgSurface(qobject_cast<QWaylandXdgSurface *>(parent->shellSurface()))
+     , m_parent(parent)
+ {
++
++    init(xdgSurface->get_popup(m_parentXdgSurface ? m_parentXdgSurface->object() : nullptr, positioner->object()));
++    if (m_parent) {
++        m_parent->addChildPopup(m_xdgSurface->window());
++    }
+ }
+ 
+ QWaylandXdgSurface::Popup::~Popup()
+@@ -216,10 +213,24 @@ QWaylandXdgSurface::Popup::~Popup()
+     if (isInitialized())
+         destroy();
+ 
++    if (m_parent) {
++        m_parent->removeChildPopup(m_xdgSurface->window());
++    }
++
+     if (m_grabbing) {
+         auto *shell = m_xdgSurface->m_shell;
+         Q_ASSERT(shell->m_topmostGrabbingPopup == this);
+-        shell->m_topmostGrabbingPopup = m_parent->m_popup;
++        shell->m_topmostGrabbingPopup = m_parentXdgSurface ? m_parentXdgSurface->m_popup : nullptr;
++        m_grabbing = false;
++
++        // Synthesize Qt enter/leave events for popup
++        QWindow *leave = nullptr;
++        if (m_xdgSurface && m_xdgSurface->window())
++            leave = m_xdgSurface->window()->window();
++        QWindowSystemInterface::handleLeaveEvent(leave);
++
++        if (QWindow *enter = QGuiApplication::topLevelAt(QCursor::pos()))
++            QWindowSystemInterface::handleEnterEvent(enter, enter->mapFromGlobal(QCursor::pos()), QCursor::pos());
+     }
+ }
+ 
+@@ -257,6 +268,7 @@ QWaylandXdgSurface::QWaylandXdgSurface(QWaylandXdgShell *shell, ::xdg_surface *s
+                 m_toplevel->set_parent(parentXdgSurface->m_toplevel->object());
+         }
+     }
++    setSizeHints();
+ }
+ 
+ QWaylandXdgSurface::~QWaylandXdgSurface()
+@@ -400,8 +412,6 @@ void QWaylandXdgSurface::setPopup(QWaylandWindow *parent)
+ {
+     Q_ASSERT(!m_toplevel && !m_popup);
+ 
+-    auto parentXdgSurface = static_cast<QWaylandXdgSurface *>(parent->shellSurface());
+-
+     auto positioner = new QtWayland::xdg_positioner(m_shell->create_positioner());
+     // set_popup expects a position relative to the parent
+     QPoint transientPos = m_window->geometry().topLeft(); // this is absolute
+@@ -414,8 +424,9 @@ void QWaylandXdgSurface::setPopup(QWaylandWindow *parent)
+     positioner->set_anchor(QtWayland::xdg_positioner::anchor_top_left);
+     positioner->set_gravity(QtWayland::xdg_positioner::gravity_bottom_right);
+     positioner->set_size(m_window->geometry().width(), m_window->geometry().height());
+-    m_popup = new Popup(this, parentXdgSurface, positioner);
++    m_popup = new Popup(this, parent, positioner);
+     positioner->destroy();
++
+     delete positioner;
+ }
+ 
+@@ -437,6 +448,23 @@ void QWaylandXdgSurface::setGrabPopup(QWaylandWindow *parent, QWaylandInputDevic
+     }
+     setPopup(parent);
+     m_popup->grab(device, serial);
++
++    // Synthesize Qt enter/leave events for popup
++    if (!parent)
++        return;
++    QWindow *current = QGuiApplication::topLevelAt(QCursor::pos());
++    QWindow *leave = parent->window();
++    if (current != leave)
++        return;
++
++    QWindowSystemInterface::handleLeaveEvent(leave);
++
++    QWindow *enter = nullptr;
++    if (m_popup && m_popup->m_xdgSurface && m_popup->m_xdgSurface->window())
++        enter = m_popup->m_xdgSurface->window()->window();
++
++    if (enter)
++        QWindowSystemInterface::handleEnterEvent(enter, enter->mapFromGlobal(QCursor::pos()), QCursor::pos());
+ }
+ 
+ void QWaylandXdgSurface::xdg_surface_configure(uint32_t serial)
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
+index 96785205..4b518f0a 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
+@@ -131,14 +131,15 @@ private:
+ 
+     class Popup : public QtWayland::xdg_popup {
+     public:
+-        Popup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parent, QtWayland::xdg_positioner *positioner);
++        Popup(QWaylandXdgSurface *xdgSurface, QWaylandWindow *parent, QtWayland::xdg_positioner *positioner);
+         ~Popup() override;
+ 
+         void grab(QWaylandInputDevice *seat, uint serial);
+         void xdg_popup_popup_done() override;
+ 
+         QWaylandXdgSurface *m_xdgSurface = nullptr;
+-        QWaylandXdgSurface *m_parent = nullptr;
++        QWaylandXdgSurface *m_parentXdgSurface = nullptr;
++        QWaylandWindow *m_parent = nullptr;
+         bool m_grabbing = false;
+     };
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
+index 8769d971..da0dd6a7 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
+@@ -69,20 +69,6 @@ QWaylandShellSurface *QWaylandXdgShellIntegration::createShellSurface(QWaylandWi
+     return m_xdgShell->getXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellIntegration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus)
+-{
+-    if (newFocus) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurface *>(newFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowActivated(newFocus);
+-    }
+-    if (oldFocus && qobject_cast<QWaylandXdgSurface *>(oldFocus->shellSurface())) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurface *>(oldFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowDeactivated(oldFocus);
+-    }
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
+index b6caa6c9..2f929f98 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
+@@ -65,7 +65,6 @@ public:
+     QWaylandXdgShellIntegration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShell> m_xdgShell;
+diff --git a/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp b/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
+index 526d0ef4..f50ccf30 100644
+--- a/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
++++ b/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
+@@ -39,7 +39,10 @@
+ 
+ #include "qwaylandinputmethodeventbuilder_p.h"
+ 
++#include <QBrush>
++#include <QGuiApplication>
+ #include <QInputMethod>
++#include <QPalette>
+ #include <QTextCharFormat>
+ 
+ #ifdef QT_BUILD_WAYLANDCOMPOSITOR_LIB
+@@ -81,32 +84,38 @@ void QWaylandInputMethodEventBuilder::addPreeditStyling(uint32_t index, uint32_t
+     QTextCharFormat format;
+ 
+     switch (style) {
+-    case 0:
+-    case 1:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_NONE:
++        break;
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_DEFAULT:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_UNDERLINE:
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-    case 2:
+-    case 3:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_ACTIVE:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_INACTIVE:
+         format.setFontWeight(QFont::Bold);
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-    case 4:
+-        format.setFontUnderline(true);
+-        format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+-        m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_HIGHLIGHT:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_SELECTION:
++        {
++            format.setFontUnderline(true);
++            format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
++            QPalette palette = qApp->palette();
++            format.setBackground(QBrush(palette.color(QPalette::Active, QPalette::Highlight)));
++            format.setForeground(QBrush(palette.color(QPalette::Active, QPalette::HighlightedText)));
++            m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
++        }
+         break;
+-    case 5:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_INCORRECT:
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::WaveUnderline);
+         format.setUnderlineColor(QColor(Qt::red));
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-//    case QtWayland::wl_text_input::preedit_style_selection:
+-//    case QtWayland::wl_text_input::preedit_style_none:
+     default:
+         break;
+     }
+@@ -153,7 +162,7 @@ QInputMethodEvent QWaylandInputMethodEventBuilder::buildPreedit(const QString &t
+ 
+     if (m_preeditCursor < 0) {
+         attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, 0, QVariant()));
+-    } else if (m_preeditCursor > 0) {
++    } else {
+         attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, indexFromWayland(text, m_preeditCursor), 1, QVariant()));
+     }
+ 
+diff --git a/qtwayland/src/shared/qwaylandmimehelper.cpp b/qtwayland/src/shared/qwaylandmimehelper.cpp
+index a5fdd34d..e2fe1928 100644
+--- a/qtwayland/src/shared/qwaylandmimehelper.cpp
++++ b/qtwayland/src/shared/qwaylandmimehelper.cpp
+@@ -60,7 +60,7 @@ QByteArray QWaylandMimeHelper::getByteArray(QMimeData *mimeData, const QString &
+             buf.open(QIODevice::ReadWrite);
+             QByteArray fmt = "BMP";
+             if (mimeType.startsWith(QLatin1String("image/"))) {
+-                QByteArray imgFmt = mimeType.mid(6).toUpper().toLatin1();
++                QByteArray imgFmt = mimeType.mid(6).toLower().toLatin1();
+                 if (QImageWriter::supportedImageFormats().contains(imgFmt))
+                     fmt = imgFmt;
+             }
+@@ -74,7 +74,7 @@ QByteArray QWaylandMimeHelper::getByteArray(QMimeData *mimeData, const QString &
+         QList<QUrl> urls = mimeData->urls();
+         for (int i = 0; i < urls.count(); ++i) {
+             content.append(urls.at(i).toEncoded());
+-            content.append('\n');
++            content.append("\r\n");
+         }
+     } else {
+         content = mimeData->data(mimeType);
+diff --git a/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp b/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
+index 1568b3b9..067410d0 100644
+--- a/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
++++ b/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
+@@ -35,7 +35,7 @@
+ 
+ using namespace MockCompositor;
+ 
+-constexpr int dataDeviceVersion = 1;
++constexpr int dataDeviceVersion = 3;
+ 
+ class DataDeviceCompositor : public DefaultCompositor {
+ public:
+diff --git a/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp b/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
+index 9312c2e5..2ea382f1 100644
+--- a/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
++++ b/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
+@@ -73,6 +73,7 @@ private slots:
+     void multiTouch();
+     void multiTouchUpAndMotionFrame();
+     void tapAndMoveInSameFrame();
++    void cancelTouch();
+ };
+ 
+ void tst_seatv5::bindsToSeat()
+@@ -646,5 +647,34 @@ void tst_seatv5::tapAndMoveInSameFrame()
+     QTRY_COMPARE(window.m_events.last().touchPoints.first().state(), Qt::TouchPointState::TouchPointReleased);
+ }
+ 
++void tst_seatv5::cancelTouch()
++{
++    TouchWindow window;
++    QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
++
++    exec([=] {
++        auto *t = touch();
++        auto *c = client();
++        t->sendDown(xdgToplevel()->surface(), {32, 32}, 1);
++        t->sendFrame(c);
++        t->sendCancel(c);
++        t->sendFrame(c);
++    });
++
++    QTRY_VERIFY(!window.m_events.empty());
++    {
++        auto e = window.m_events.takeFirst();
++        QCOMPARE(e.type, QEvent::TouchBegin);
++        QCOMPARE(e.touchPointStates, Qt::TouchPointPressed);
++        QCOMPARE(e.touchPoints.length(), 1);
++        QCOMPARE(e.touchPoints.first().pos(), QPointF(32-window.frameMargins().left(), 32-window.frameMargins().top()));
++    }
++    {
++        auto e = window.m_events.takeFirst();
++        QCOMPARE(e.type, QEvent::TouchCancel);
++        QCOMPARE(e.touchPoints.length(), 0);
++    }
++}
++
+ QCOMPOSITOR_TEST_MAIN(tst_seatv5)
+ #include "tst_seatv5.moc"
+diff --git a/qtwayland/tests/auto/client/shared/corecompositor.cpp b/qtwayland/tests/auto/client/shared/corecompositor.cpp
+index 5c6c83ba..fa9b7662 100644
+--- a/qtwayland/tests/auto/client/shared/corecompositor.cpp
++++ b/qtwayland/tests/auto/client/shared/corecompositor.cpp
+@@ -27,6 +27,7 @@
+ ****************************************************************************/
+ 
+ #include "corecompositor.h"
++#include <thread>
+ 
+ namespace MockCompositor {
+ 
+diff --git a/qtwayland/tests/auto/client/shared/coreprotocol.cpp b/qtwayland/tests/auto/client/shared/coreprotocol.cpp
+index 0d988521..d1a2e7cb 100644
+--- a/qtwayland/tests/auto/client/shared/coreprotocol.cpp
++++ b/qtwayland/tests/auto/client/shared/coreprotocol.cpp
+@@ -451,6 +451,13 @@ void Touch::sendFrame(wl_client *client)
+         send_frame(r->handle);
+ }
+ 
++void Touch::sendCancel(wl_client *client)
++{
++    const auto touchResources = resourceMap().values(client);
++    for (auto *r : touchResources)
++        send_cancel(r->handle);
++}
++
+ uint Keyboard::sendEnter(Surface *surface)
+ {
+     auto serial = m_seat->m_compositor->nextSerial();
+diff --git a/qtwayland/tests/auto/client/shared/coreprotocol.h b/qtwayland/tests/auto/client/shared/coreprotocol.h
+index a1af137a..210d8ddb 100644
+--- a/qtwayland/tests/auto/client/shared/coreprotocol.h
++++ b/qtwayland/tests/auto/client/shared/coreprotocol.h
+@@ -158,7 +158,7 @@ class WlCompositor : public Global, public QtWaylandServer::wl_compositor
+ {
+     Q_OBJECT
+ public:
+-    explicit WlCompositor(CoreCompositor *compositor, int version = 3)
++    explicit WlCompositor(CoreCompositor *compositor, int version = 4)
+         : QtWaylandServer::wl_compositor(compositor->m_display, version)
+         , m_compositor(compositor)
+     {}
+@@ -364,6 +364,7 @@ public:
+     uint sendUp(wl_client *client, int id);
+     void sendMotion(wl_client *client, const QPointF &position, int id);
+     void sendFrame(wl_client *client);
++    void sendCancel(wl_client *client);
+ 
+     Seat *m_seat = nullptr;
+ };
+diff --git a/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp b/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
+index a415cbf5..b1d3d07d 100644
+--- a/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
++++ b/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
+@@ -342,7 +342,7 @@ Compositor::Compositor(MockCompositor *mockCompositor)
+         exit(EXIT_FAILURE);
+     }
+ 
+-    wl_global_create(m_display, &wl_compositor_interface, 1, this, bindCompositor);
++    wl_global_create(m_display, &wl_compositor_interface, 4, this, bindCompositor);
+ 
+     m_data_device_manager.reset(new DataDeviceManager(this, m_display));
+ 
+diff --git a/qtwayland/tests/auto/client/shared_old/mocksurface.cpp b/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
+index e9df5f90..c3246e4a 100644
+--- a/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
++++ b/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
+@@ -125,6 +125,16 @@ void Surface::surface_damage(Resource *resource,
+     Q_UNUSED(height);
+ }
+ 
++void Surface::surface_damage_buffer(Resource *resource,
++                                    int32_t x, int32_t y, int32_t width, int32_t height)
++{
++    Q_UNUSED(resource);
++    Q_UNUSED(x);
++    Q_UNUSED(y);
++    Q_UNUSED(width);
++    Q_UNUSED(height);
++}
++
+ void Surface::surface_frame(Resource *resource,
+                             uint32_t callback)
+ {
+diff --git a/qtwayland/tests/auto/client/shared_old/mocksurface.h b/qtwayland/tests/auto/client/shared_old/mocksurface.h
+index 949dc23d..d176837e 100644
+--- a/qtwayland/tests/auto/client/shared_old/mocksurface.h
++++ b/qtwayland/tests/auto/client/shared_old/mocksurface.h
+@@ -65,6 +65,8 @@ protected:
+                         struct wl_resource *buffer, int x, int y) override;
+     void surface_damage(Resource *resource,
+                         int32_t x, int32_t y, int32_t width, int32_t height) override;
++    void surface_damage_buffer(Resource *resource,
++                               int32_t x, int32_t y, int32_t width, int32_t height) override;
+     void surface_frame(Resource *resource,
+                        uint32_t callback) override;
+     void surface_commit(Resource *resource) override;
+diff --git a/qtwayland/tests/auto/client/surface/tst_surface.cpp b/qtwayland/tests/auto/client/surface/tst_surface.cpp
+index 95e4e609..60c672ce 100644
+--- a/qtwayland/tests/auto/client/surface/tst_surface.cpp
++++ b/qtwayland/tests/auto/client/surface/tst_surface.cpp
+@@ -129,6 +129,10 @@ void tst_surface::waitForFrameCallbackGl()
+     // Make sure we follow frame callbacks for some frames
+     for (int i = 0; i < 5; ++i) {
+         xdgPingAndWaitForPong(); // Make sure things have happened on the client
++        if (!qEnvironmentVariableIntValue("QT_WAYLAND_DISABLE_WINDOWDECORATION") && i == 0) {
++            QCOMPARE(bufferSpy.count(), 1);
++            bufferSpy.removeFirst();
++        }
+         exec([&] {
+             QVERIFY(bufferSpy.empty()); // Make sure no extra buffers have arrived
+             QVERIFY(!xdgToplevel()->surface()->m_waitingFrameCallbacks.empty());
+diff --git a/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp b/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
+index 2277bbb8..747875b4 100644
+--- a/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
++++ b/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
+@@ -31,6 +31,7 @@
+ #include <QtGui/QOpenGLWindow>
+ #include <QtGui/qpa/qplatformnativeinterface.h>
+ #include <QtWaylandClient/private/wayland-wayland-client-protocol.h>
++#include <QtWaylandClient/private/qwaylandwindow_p.h>
+ 
+ using namespace MockCompositor;
+ 
+@@ -45,6 +46,7 @@ private slots:
+     void configureStates();
+     void popup();
+     void tooltipOnPopup();
++    void tooltipAndSiblingPopup();
+     void switchPopups();
+     void hidePopupParent();
+     void pongs();
+@@ -138,6 +140,7 @@ void tst_xdgshell::configureSize()
+ 
+ void tst_xdgshell::configureStates()
+ {
++    QVERIFY(qputenv("QT_WAYLAND_FRAME_CALLBACK_TIMEOUT", "0"));
+     QRasterWindow window;
+     window.resize(64, 48);
+     window.show();
+@@ -154,9 +157,12 @@ void tst_xdgshell::configureStates()
+     // Toplevel windows don't know their position on xdg-shell
+ //    QCOMPARE(window.frameGeometry().topLeft(), QPoint()); // TODO: this doesn't currently work when window decorations are enabled
+ 
+-//    QEXPECT_FAIL("", "configure has already been acked, we shouldn't have to wait for isActive", Continue);
+-//    QVERIFY(window.isActive());
+-    QTRY_VERIFY(window.isActive()); // Just make sure it eventually get's set correctly
++    // window.windowstate() is driven by keyboard focus, however for decorations we want to follow
++    // XDGShell this is internal to QtWayland so it is queried directly
++    auto waylandWindow = static_cast<QtWaylandClient::QWaylandWindow *>(window.handle());
++    Q_ASSERT(waylandWindow);
++    QTRY_VERIFY(waylandWindow->windowStates().testFlag(
++            Qt::WindowActive)); // Just make sure it eventually get's set correctly
+ 
+     const QSize screenSize(640, 480);
+     const uint maximizedSerial = exec([=] {
+@@ -186,6 +192,7 @@ void tst_xdgshell::configureStates()
+     QCOMPARE(window.windowStates(), Qt::WindowNoState);
+     QCOMPARE(window.frameGeometry().size(), windowedSize);
+ //    QCOMPARE(window.frameGeometry().topLeft(), QPoint()); // TODO: this doesn't currently work when window decorations are enabled
++    QVERIFY(qunsetenv("QT_WAYLAND_FRAME_CALLBACK_TIMEOUT"));
+ }
+ 
+ void tst_xdgshell::popup()
+@@ -340,6 +347,92 @@ void tst_xdgshell::tooltipOnPopup()
+     QCOMPOSITOR_TRY_COMPARE(xdgPopup(0), nullptr);
+ }
+ 
++void tst_xdgshell::tooltipAndSiblingPopup()
++{
++    class ToolTip : public QRasterWindow {
++    public:
++        explicit ToolTip(QWindow *parent) {
++            setTransientParent(parent);
++            setFlags(Qt::ToolTip);
++            resize(100, 100);
++            show();
++        }
++        void mousePressEvent(QMouseEvent *event) override {
++            QRasterWindow::mousePressEvent(event);
++            m_popup = new QRasterWindow;
++            m_popup->setTransientParent(transientParent());
++            m_popup->setFlags(Qt::Popup);
++            m_popup->resize(100, 100);
++            m_popup->show();
++        }
++
++        QRasterWindow *m_popup = nullptr;
++    };
++
++    class Window : public QRasterWindow {
++    public:
++        void mousePressEvent(QMouseEvent *event) override {
++            QRasterWindow::mousePressEvent(event);
++            m_tooltip = new ToolTip(this);
++        }
++        ToolTip *m_tooltip = nullptr;
++    };
++
++    Window window;
++    window.resize(200, 200);
++    window.show();
++
++    QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
++    exec([=] { xdgToplevel()->sendCompleteConfigure(); });
++    QCOMPOSITOR_TRY_VERIFY(xdgToplevel()->m_xdgSurface->m_committedConfigureSerial);
++
++    exec([=] {
++        auto *surface = xdgToplevel()->surface();
++        auto *p = pointer();
++        auto *c = client();
++        p->sendEnter(surface, {100, 100});
++        p->sendFrame(c);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_pressed);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_released);
++        p->sendFrame(c);
++        p->sendLeave(surface);
++        p->sendFrame(c);
++    });
++
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup());
++    exec([=] { xdgPopup()->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup()->m_xdgSurface->m_committedConfigureSerial);
++    QCOMPOSITOR_TRY_VERIFY(!xdgPopup()->m_grabbed);
++
++    exec([=] {
++        auto *surface = xdgPopup()->surface();
++        auto *p = pointer();
++        auto *c = client();
++        p->sendEnter(surface, {100, 100});
++        p->sendFrame(c);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_pressed);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_released);
++        p->sendFrame(c);
++    });
++
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1));
++    exec([=] { xdgPopup(1)->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1)->m_xdgSurface->m_committedConfigureSerial);
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1)->m_grabbed);
++
++    // Close the middle tooltip (it should not close the sibling popup)
++    window.m_tooltip->close();
++
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(1), nullptr);
++    // Verify the remaining xdg surface is a grab popup..
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(0));
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(0)->m_grabbed);
++
++    window.m_tooltip->m_popup->close();
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(1), nullptr);
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(0), nullptr);
++}
++
+ // QTBUG-65680
+ void tst_xdgshell::switchPopups()
+ {
+@@ -505,7 +598,7 @@ void tst_xdgshell::minMaxSize()
+     window.show();
+     QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
+ 
+-    exec([=] { xdgToplevel()->sendCompleteConfigure(); });
++    // we don't roundtrip with our configuration the initial commit should be correct
+ 
+     QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.minSize, QSize(100, 100));
+     QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.maxSize, QSize(1000, 1000));
+Submodule qtwebchannel 618422ee..f8949655:
+diff --git a/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp b/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
+index 536eb5c..898d769 100644
+--- a/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
++++ b/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
+@@ -186,8 +186,6 @@ Q_DECLARE_TYPEINFO(OverloadResolutionCandidate, Q_MOVABLE_TYPE);
+ QMetaObjectPublisher::QMetaObjectPublisher(QWebChannel *webChannel)
+     : QObject(webChannel)
+     , webChannel(webChannel)
+-    , signalHandler(this)
+-    , clientIsIdle(false)
+     , blockUpdates(false)
+     , propertyUpdatesInitialized(false)
+ {
+@@ -301,17 +299,17 @@ QJsonObject QMetaObjectPublisher::classInfoForObject(const QObject *object, QWeb
+     return data;
+ }
+ 
+-void QMetaObjectPublisher::setClientIsIdle(bool isIdle)
++void QMetaObjectPublisher::setClientIsIdle(bool isIdle, QWebChannelAbstractTransport *transport)
+ {
+-    if (clientIsIdle == isIdle) {
+-        return;
+-    }
+-    clientIsIdle = isIdle;
+-    if (!isIdle && timer.isActive()) {
+-        timer.stop();
+-    } else if (isIdle && !timer.isActive()) {
+-        timer.start(PROPERTY_UPDATE_INTERVAL, this);
+-    }
++    transportState[transport].clientIsIdle = isIdle;
++    if (isIdle)
++        sendEnqueuedPropertyUpdates(transport);
++}
++
++bool QMetaObjectPublisher::isClientIdle(QWebChannelAbstractTransport *transport)
++{
++    auto found = transportState.find(transport);
++    return found != transportState.end() && found.value().clientIsIdle;
+ }
+ 
+ QJsonObject QMetaObjectPublisher::initializeClient(QWebChannelAbstractTransport *transport)
+@@ -333,6 +331,7 @@ QJsonObject QMetaObjectPublisher::initializeClient(QWebChannelAbstractTransport
+ 
+ void QMetaObjectPublisher::initializePropertyUpdates(const QObject *const object, const QJsonObject &objectInfo)
+ {
++    auto *signalHandler = signalHandlerFor(object);
+     foreach (const QJsonValue &propertyInfoVar, objectInfo[KEY_PROPERTIES].toArray()) {
+         const QJsonArray &propertyInfo = propertyInfoVar.toArray();
+         if (propertyInfo.size() < 2) {
+@@ -353,19 +352,19 @@ void QMetaObjectPublisher::initializePropertyUpdates(const QObject *const object
+ 
+         // Only connect for a property update once
+         if (connectedProperties.isEmpty()) {
+-            signalHandler.connectTo(object, signalIndex);
++            signalHandler->connectTo(object, signalIndex);
+         }
+ 
+         connectedProperties.insert(propertyIndex);
+     }
+ 
+     // also always connect to destroyed signal
+-    signalHandler.connectTo(object, s_destroyedSignalIndex);
++    signalHandler->connectTo(object, s_destroyedSignalIndex);
+ }
+ 
+ void QMetaObjectPublisher::sendPendingPropertyUpdates()
+ {
+-    if (blockUpdates || !clientIsIdle || pendingPropertyUpdates.isEmpty()) {
++    if (blockUpdates) {
+         return;
+     }
+ 
+@@ -415,18 +414,19 @@ void QMetaObjectPublisher::sendPendingPropertyUpdates()
+ 
+     // data does not contain specific updates
+     if (!data.isEmpty()) {
+-        setClientIsIdle(false);
+-
+         message[KEY_DATA] = data;
+-        broadcastMessage(message);
++        enqueueBroadcastMessage(message);
+     }
+ 
+     // send every property update which is not supposed to be broadcasted
+     const QHash<QWebChannelAbstractTransport*, QJsonArray>::const_iterator suend = specificUpdates.constEnd();
+     for (QHash<QWebChannelAbstractTransport*, QJsonArray>::const_iterator it = specificUpdates.constBegin(); it != suend; ++it) {
+         message[KEY_DATA] = it.value();
+-        it.key()->sendMessage(message);
++        enqueueMessage(message, it.key());
+     }
++
++    for (auto state = transportState.begin(); state != transportState.end(); ++state)
++        sendEnqueuedPropertyUpdates(state.key());
+ }
+ 
+ QVariant QMetaObjectPublisher::invokeMethod(QObject *const object, const QMetaMethod &method,
+@@ -572,7 +572,7 @@ void QMetaObjectPublisher::signalEmitted(const QObject *object, const int signal
+         }
+     } else {
+         pendingPropertyUpdates[object][signalIndex] = arguments;
+-        if (clientIsIdle && !blockUpdates && !timer.isActive()) {
++        if (!blockUpdates && !timer.isActive()) {
+             timer.start(PROPERTY_UPDATE_INTERVAL, this);
+         }
+     }
+@@ -590,7 +590,7 @@ void QMetaObjectPublisher::objectDestroyed(const QObject *object)
+     // only remove from handler when we initialized the property updates
+     // cf: https://bugreports.qt.io/browse/QTBUG-60250
+     if (propertyUpdatesInitialized) {
+-        signalHandler.remove(object);
++        signalHandlerFor(object)->remove(object);
+         signalToPropertyMap.remove(object);
+     }
+     pendingPropertyUpdates.remove(object);
+@@ -852,6 +852,52 @@ void QMetaObjectPublisher::broadcastMessage(const QJsonObject &message) const
+     }
+ }
+ 
++void QMetaObjectPublisher::enqueueBroadcastMessage(const QJsonObject &message)
++{
++    if (webChannel->d_func()->transports.isEmpty()) {
++        qWarning("QWebChannel is not connected to any transports, cannot send message: %s",
++                 QJsonDocument(message).toJson().constData());
++        return;
++    }
++
++    for (auto *transport : webChannel->d_func()->transports) {
++        auto &state = transportState[transport];
++        state.queuedMessages.append(message);
++    }
++}
++
++void QMetaObjectPublisher::enqueueMessage(const QJsonObject &message,
++                                          QWebChannelAbstractTransport *transport)
++{
++    auto &state = transportState[transport];
++    state.queuedMessages.append(message);
++}
++
++void QMetaObjectPublisher::sendEnqueuedPropertyUpdates(QWebChannelAbstractTransport *transport)
++{
++    auto found = transportState.find(transport);
++    if (found != transportState.end() && found.value().clientIsIdle
++        && !found.value().queuedMessages.isEmpty()) {
++
++        // If the client is connected with an in-process transport, it can
++        // happen that a message triggers a subsequent property change. In
++        // that case, we need to ensure that the queued messages have already
++        // been cleared; otherwise the recursive call will send everythig again.
++        // Case in point: The qmlwebchannel tests fail if we don't clear the
++        // queued messages before sending them out.
++        // For that same reason set the client to "busy" (aka non-idle) just
++        // right before sending out the messages; otherwise a potential
++        // "Idle" type message will not correctly restore the Idle state.
++        const auto messages = std::move(found.value().queuedMessages);
++        Q_ASSERT(found.value().queuedMessages.isEmpty());
++        found.value().clientIsIdle = false;
++
++        for (const auto &message : messages) {
++            transport->sendMessage(message);
++        }
++    }
++}
++
+ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannelAbstractTransport *transport)
+ {
+     if (!webChannel->d_func()->transports.contains(transport)) {
+@@ -866,7 +912,7 @@ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannel
+ 
+     const MessageType type = toType(message.value(KEY_TYPE));
+     if (type == TypeIdle) {
+-        setClientIsIdle(true);
++        setClientIsIdle(true, transport);
+     } else if (type == TypeInit) {
+         if (!message.contains(KEY_ID)) {
+             qWarning("JSON message object is missing the id property: %s",
+@@ -913,9 +959,9 @@ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannel
+                 return;
+             transport->sendMessage(createResponse(message.value(KEY_ID), wrapResult(result, transport)));
+         } else if (type == TypeConnectToSignal) {
+-            signalHandler.connectTo(object, message.value(KEY_SIGNAL).toInt(-1));
++            signalHandlerFor(object)->connectTo(object, message.value(KEY_SIGNAL).toInt(-1));
+         } else if (type == TypeDisconnectFromSignal) {
+-            signalHandler.disconnectFrom(object, message.value(KEY_SIGNAL).toInt(-1));
++            signalHandlerFor(object)->disconnectFrom(object, message.value(KEY_SIGNAL).toInt(-1));
+         } else if (type == TypeSetProperty) {
+             setProperty(object, message.value(KEY_PROPERTY).toInt(-1),
+                         message.value(KEY_VALUE));
+@@ -931,6 +977,7 @@ void QMetaObjectPublisher::setBlockUpdates(bool block)
+     blockUpdates = block;
+ 
+     if (!blockUpdates) {
++        timer.start(PROPERTY_UPDATE_INTERVAL, this);
+         sendPendingPropertyUpdates();
+     } else if (timer.isActive()) {
+         timer.stop();
+@@ -948,4 +995,15 @@ void QMetaObjectPublisher::timerEvent(QTimerEvent *event)
+     }
+ }
+ 
++SignalHandler<QMetaObjectPublisher> *QMetaObjectPublisher::signalHandlerFor(const QObject *object)
++{
++    auto thread = object->thread();
++    auto it = signalHandlers.find(thread);
++    if (it == signalHandlers.end()) {
++        it = signalHandlers.emplace(thread, this).first;
++        it->second.moveToThread(thread);
++    }
++    return &it->second;
++}
++
+ QT_END_NAMESPACE
+diff --git a/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h b/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
+index bbd9875..4713ef1 100644
+--- a/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
++++ b/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
+@@ -59,6 +59,9 @@
+ #include <QBasicTimer>
+ #include <QPointer>
+ #include <QJsonObject>
++#include <QQueue>
++
++#include <unordered_map>
+ 
+ #include "qwebchannelglobal.h"
+ 
+@@ -109,17 +112,36 @@ public:
+      */
+     void broadcastMessage(const QJsonObject &message) const;
+ 
++    /**
++     * Enqueue the given @p message to all known transports.
++     */
++    void enqueueBroadcastMessage(const QJsonObject &message);
++
++    /**
++     * Enqueue the given @p message to @p transport.
++     */
++    void enqueueMessage(const QJsonObject &message, QWebChannelAbstractTransport *transport);
++
++    /**
++     * If client for given @p transport is idle, send queued messaged to @p transport and then mark
++     * the client as not idle.
++     */
++    void sendEnqueuedPropertyUpdates(QWebChannelAbstractTransport *transport);
++
+     /**
+      * Serialize the QMetaObject of @p object and return it in JSON form.
+      */
+     QJsonObject classInfoForObject(const QObject *object, QWebChannelAbstractTransport *transport);
+ 
+     /**
+-     * Set the client to idle or busy, based on the value of @p isIdle.
+-     *
+-     * When the value changed, start/stop the property update timer accordingly.
++     * Set the client to idle or busy for a single @p transport, based on the value of @p isIdle.
++     */
++    void setClientIsIdle(bool isIdle, QWebChannelAbstractTransport *transport);
++
++    /**
++     * Check that client is idle for @p transport.
+      */
+-    void setClientIsIdle(bool isIdle);
++    bool isClientIdle(QWebChannelAbstractTransport *transport);
+ 
+     /**
+      * Initialize clients by sending them the class information of the registered objects.
+@@ -272,10 +294,18 @@ private:
+     friend class TestWebChannel;
+ 
+     QWebChannel *webChannel;
+-    SignalHandler<QMetaObjectPublisher> signalHandler;
++    std::unordered_map<const QThread*, SignalHandler<QMetaObjectPublisher>> signalHandlers;
++    SignalHandler<QMetaObjectPublisher> *signalHandlerFor(const QObject *object);
+ 
+-    // true when the client is idle, false otherwise
+-    bool clientIsIdle;
++    struct TransportState
++    {
++        TransportState() : clientIsIdle(false) { }
++        // true when the client is idle, false otherwise
++        bool clientIsIdle;
++        // messages to send
++        QQueue<QJsonObject> queuedMessages;
++    };
++    QHash<QWebChannelAbstractTransport *, TransportState> transportState;
+ 
+     // true when no property updates should be sent, false otherwise
+     bool blockUpdates;
+diff --git a/qtwebchannel/src/webchannel/signalhandler_p.h b/qtwebchannel/src/webchannel/signalhandler_p.h
+index 27afadb..d77373c 100644
+--- a/qtwebchannel/src/webchannel/signalhandler_p.h
++++ b/qtwebchannel/src/webchannel/signalhandler_p.h
+@@ -56,6 +56,7 @@
+ #include <QVector>
+ #include <QMetaMethod>
+ #include <QDebug>
++#include <QThread>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -71,6 +72,7 @@ static const int s_destroyedSignalIndex = QObject::staticMetaObject.indexOfMetho
+ template<class Receiver>
+ class SignalHandler : public QObject
+ {
++    Q_DISABLE_COPY(SignalHandler)
+ public:
+     SignalHandler(Receiver *receiver, QObject *parent = 0);
+ 
+@@ -268,6 +270,7 @@ int SignalHandler<Receiver>::qt_metacall(QMetaObject::Call call, int methodId, v
+     if (call == QMetaObject::InvokeMetaMethod) {
+         const QObject *object = sender();
+         Q_ASSERT(object);
++        Q_ASSERT(QThread::currentThread() == object->thread());
+         Q_ASSERT(senderSignalIndex() == methodId);
+         Q_ASSERT(m_connectionsCounter.contains(object));
+         Q_ASSERT(m_connectionsCounter.value(object).contains(methodId));
+diff --git a/qtwebchannel/tests/auto/qml/testwebchannel.cpp b/qtwebchannel/tests/auto/qml/testwebchannel.cpp
+index 9891687..3ca81c2 100644
+--- a/qtwebchannel/tests/auto/qml/testwebchannel.cpp
++++ b/qtwebchannel/tests/auto/qml/testwebchannel.cpp
+@@ -46,7 +46,11 @@ TestWebChannel::~TestWebChannel()
+ 
+ bool TestWebChannel::clientIsIdle() const
+ {
+-    return QWebChannel::d_func()->publisher->clientIsIdle;
++    for (auto *transport : QWebChannel::d_func()->transports) {
++        if (QWebChannel::d_func()->publisher->isClientIdle(transport))
++            return true;
++    }
++    return false;
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp b/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
+index 181da9e..37f989a 100644
+--- a/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
++++ b/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
+@@ -785,7 +785,7 @@ void TestWebChannel::testTransportWrapObjectProperties()
+     DummyTransport *dummyTransport = new DummyTransport(this);
+     channel.connectTo(dummyTransport);
+     channel.d_func()->publisher->initializeClient(dummyTransport);
+-    channel.d_func()->publisher->setClientIsIdle(true);
++    channel.d_func()->publisher->setClientIsIdle(true, dummyTransport);
+ 
+     QCOMPARE(channel.d_func()->publisher->transportedWrappedObjects.size(), 0);
+ 
+@@ -943,8 +943,6 @@ void TestWebChannel::testInfiniteRecursion()
+ 
+ void TestWebChannel::testAsyncObject()
+ {
+-    QSKIP("This test is broken. See QTBUG-80729");
+-
+     QWebChannel channel;
+     channel.connectTo(m_dummyTransport);
+ 
+@@ -990,6 +988,50 @@ void TestWebChannel::testAsyncObject()
+     thread.wait();
+ }
+ 
++void TestWebChannel::testPropertyMultipleTransports()
++{
++    DummyTransport transport1;
++    DummyTransport transport2;
++
++    QWebChannel channel;
++    QMetaObjectPublisher *publisher = channel.d_func()->publisher;
++
++    TestObject testObj;
++    testObj.setObjectName("testObject");
++    channel.registerObject(testObj.objectName(), &testObj);
++    channel.connectTo(&transport1);
++    channel.connectTo(&transport2);
++
++    testObj.setProp("Hello");
++
++    publisher->initializeClient(&transport1);
++    publisher->initializeClient(&transport2);
++    publisher->setClientIsIdle(true, &transport1);
++    QCOMPARE(publisher->isClientIdle(&transport1), true);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++    QVERIFY(transport1.messagesSent().isEmpty());
++    QVERIFY(transport2.messagesSent().isEmpty());
++
++    testObj.setProp("World");
++    QTRY_COMPARE_WITH_TIMEOUT(transport1.messagesSent().size(), 1u, 2000);
++    QCOMPARE(transport2.messagesSent().size(), 0u);
++    publisher->setClientIsIdle(true, &transport2);
++    QTRY_COMPARE_WITH_TIMEOUT(transport2.messagesSent().size(), 1u, 2000);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++
++    testObj.setProp("!!!");
++    publisher->setClientIsIdle(true, &transport2);
++    QCOMPARE(publisher->isClientIdle(&transport2), true);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QTRY_COMPARE_WITH_TIMEOUT(transport2.messagesSent().size(), 2u, 2000);
++    QCOMPARE(transport1.messagesSent().size(), 1u);
++    publisher->setClientIsIdle(true, &transport1);
++    QTRY_COMPARE_WITH_TIMEOUT(transport1.messagesSent().size(), 2u, 2000);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++}
++
+ class FunctionWrapper : public QObject
+ {
+     Q_OBJECT
+@@ -1082,7 +1124,7 @@ void TestWebChannel::benchInitializeClients()
+ 
+         publisher->propertyUpdatesInitialized = false;
+         publisher->signalToPropertyMap.clear();
+-        publisher->signalHandler.clear();
++        publisher->signalHandlers.clear();
+     }
+ }
+ 
+@@ -1107,7 +1149,7 @@ void TestWebChannel::benchPropertyUpdates()
+             obj->change();
+         }
+ 
+-        channel.d_func()->publisher->clientIsIdle = true;
++        channel.d_func()->publisher->setClientIsIdle(true, m_dummyTransport);
+         channel.d_func()->publisher->sendPendingPropertyUpdates();
+     }
+ }
+diff --git a/qtwebchannel/tests/auto/webchannel/tst_webchannel.h b/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
+index eae21f4..dd4e690 100644
+--- a/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
++++ b/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
+@@ -348,6 +348,7 @@ private slots:
+     void testJsonToVariant();
+     void testInfiniteRecursion();
+     void testAsyncObject();
++    void testPropertyMultipleTransports();
+     void testDeletionDuringMethodInvocation_data();
+     void testDeletionDuringMethodInvocation();
+ 
+Submodule qtwebengine f328054d...38e0df6c (commits not present)
+Submodule qtwebsockets 65850954..63fb8da1:
+diff --git a/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp b/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
+index 2affdd5..95f1194 100644
+--- a/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
++++ b/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
+@@ -273,6 +273,7 @@ void QWebSocketDataProcessor::clear()
+     if (!m_pConverterState)
+         m_pConverterState = new QTextCodec::ConverterState(QTextCodec::ConvertInvalidToNull |
+                                                            QTextCodec::IgnoreHeader);
++    frame.clear();
+ }
+ 
+ /*!
+diff --git a/qtwebsockets/src/websockets/qwebsocketprotocol.cpp b/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
+index df87a93..d0465f1 100644
+--- a/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
++++ b/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
+@@ -210,7 +210,7 @@ void QWebSocketProtocol::mask(char *payload, quint64 size, quint32 maskingKey)
+                             quint8((maskingKey & 0x0000FF00u) >> 8),
+                             quint8((maskingKey & 0x000000FFu))
+                           };
+-    int i = 0;
++    quint64 i = 0;
+     while (size-- > 0)
+         *payload++ ^= mask[i++ % 4];
+ }
diff --git a/srcpkgs/qt5/template b/srcpkgs/qt5/template
index a79d25e69da8..6dddce7f3e46 100644
--- a/srcpkgs/qt5/template
+++ b/srcpkgs/qt5/template
@@ -2,11 +2,11 @@
 #
 # revbump libqtxdg after bumping patch version
 pkgname=qt5
-version=5.15.7+20221119
+version=5.15.8
+revision=1
+build_style=meta
 # commit f8c9fb304bc3e53b3aa07f962cd74e9160decccc
 # base repo: https://invent.kde.org/qt/qt/qt5
-revision=5
-build_style=meta
 hostmakedepends="cmake clang flex perl glib-devel pkg-config
  python re2c ruby which"
 makedepends="SDL2-devel Vulkan-Headers alsa-lib-devel double-conversion-devel
@@ -29,8 +29,9 @@ homepage="https://qt.io/"
 # tarball is generated with `git archive-all qt5-$version.tar.gz`
 # to keep the size smaller qtwebengine, qtwebview, qtdocgallery, qtactiveqt and qtpim
 # can be marked with the export-ignore attribute
-distfiles="https://void.johnnynator.dev/distfiles/qt5-${version}.tar.gz"
-checksum=9d57af471c78029a362276b7c99108ea009f511bb9ba6ff6cb884f6ddd255e9f
+#distfiles="https://void.johnnynator.dev/distfiles/qt5-${version}.tar.gz"
+distfiles="https://download.qt.io/archive/qt/5.15/${version}/single/qt-everywhere-opensource-src-${version}.tar.xz"
+checksum=776a9302c336671f9406a53bd30b8e36f825742b2ec44a57c08217bff0fa86b9
 python_version=2 #unverified
 replaces="qt5-doc<5.6.0 qt5-quick1<5.6.0 qt5-quick1-devel<5.6.0 qt5-webkit<5.6.0 qt5-webkit-devel<5.6.0
  qt5-enginio<5.7.1 qt5-enginio-devel<5.7.1 qt5-plugin-gtk<5.7.1 qt5-canvas3d<5.13.0"
@@ -250,7 +251,6 @@ do_configure() {
 	# opts+=" -v"
 	opts+=" -skip qtwebengine"
 	opts+=" -skip qtwebview"
-	opts+=" -skip qtdocgallery"
 	opts+=" -skip qtpim"
 	opts+=" -skip qtsystems"
 	opts+=" -skip qtspeech"

From 07f9e418df0e95689228438b5cd8f772c8d5c498 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 073/113] qtav: revbump for ffmpeg4-4.4.3

---
 srcpkgs/qtav/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtav/template b/srcpkgs/qtav/template
index 34c30b2c0c78..2d00ad104355 100644
--- a/srcpkgs/qtav/template
+++ b/srcpkgs/qtav/template
@@ -1,10 +1,10 @@
 # Template file for 'qtav'
 pkgname=qtav
 version=1.13.0
-revision=1
+revision=2
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel libass-devel libopenal-devel
+makedepends="ffmpeg4-devel libass-devel libopenal-devel
  libva-glx-devel libXv-devel pulseaudio-devel
  qt5-declarative-devel qt5-svg-devel
  qt5-quickcontrols"

From 8b7025fdeeb68bf8ce545fe3cbd96c4c0fcb2ab0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 074/113] qtox: revbump for ffmpeg-6.0

---
 srcpkgs/qtox/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qtox/template b/srcpkgs/qtox/template
index 16019d7eaec9..5cea0b11b697 100644
--- a/srcpkgs/qtox/template
+++ b/srcpkgs/qtox/template
@@ -1,7 +1,7 @@
 # Template file for 'qtox'
 pkgname=qtox
 version=1.17.6
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DUPDATE_CHECK=OFF
  -DGIT_DESCRIBE=${version}

From 333666008f8d0c907795ac5a126cbc4d22ada441 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 075/113] retroarch: revbump for ffmpeg-6.0

---
 srcpkgs/retroarch/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroarch/template b/srcpkgs/retroarch/template
index 28016aa0129e..20a1415913be 100644
--- a/srcpkgs/retroarch/template
+++ b/srcpkgs/retroarch/template
@@ -1,7 +1,7 @@
 # Template file for 'retroarch'
 pkgname=retroarch
 version=1.15.0
-revision=1
+revision=2
 build_style=configure
 configure_args="--prefix=/usr --sysconfdir=/etc --enable-networking
  --enable-udev --disable-builtinflac --disable-builtinglslang

From 960e55dadbbdbdb8f8993e88f1c7bb0f1a5ed30d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 076/113] scrcpy: revbump for ffmpeg-6.0

---
 srcpkgs/scrcpy/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/scrcpy/template b/srcpkgs/scrcpy/template
index 06208c389ca9..a5de935c7def 100644
--- a/srcpkgs/scrcpy/template
+++ b/srcpkgs/scrcpy/template
@@ -1,7 +1,7 @@
 # Template file for 'scrcpy'
 pkgname=scrcpy
 version=2.1
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcompile_server=false
  -Dprebuilt_server=/usr/share/scrcpy/scrcpy-server-v${version}"

From f5906f05caf1b039a36e4452776bbb51ebe7efbd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 077/113] spek-alternative: revbump for ffmpeg4-4.4.3

---
 srcpkgs/spek-alternative/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/spek-alternative/template b/srcpkgs/spek-alternative/template
index d65086b8f008..05246f1b8d0c 100644
--- a/srcpkgs/spek-alternative/template
+++ b/srcpkgs/spek-alternative/template
@@ -1,11 +1,11 @@
 # Template file for 'spek-alternative'
 pkgname=spek-alternative
 version=0.8.2.3
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake gettext-devel intltool libtool pkg-config wxWidgets-common"
-makedepends="ffmpeg-devel wxWidgets-gtk3-devel"
-depends="ffmpeg"
+makedepends="ffmpeg4-devel wxWidgets-gtk3-devel"
+depends="ffmpeg4"
 short_desc="Acoustic spectrum analyser"
 maintainer="Kartik Singh <kartik.ynwa@gmail.com>"
 license="GPL-3.0-or-later"

From 3f4d164b94becf46041dee99e9bd9fb07212b525 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 078/113] ssr: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ssr/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/ssr/template b/srcpkgs/ssr/template
index b055b9ec0774..3448ca110eb0 100644
--- a/srcpkgs/ssr/template
+++ b/srcpkgs/ssr/template
@@ -1,11 +1,11 @@
 # Template file for 'ssr'
 pkgname=ssr
 version=0.4.4
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_QT5=ON"
 hostmakedepends="pkg-config"
-makedepends="alsa-lib-devel ffmpeg-devel glu-devel jack-devel pulseaudio-devel
+makedepends="alsa-lib-devel ffmpeg4-devel glu-devel jack-devel pulseaudio-devel
  qt5-tools-devel qt5-x11extras-devel libXinerama-devel v4l-utils-devel"
 depends="desktop-file-utils hicolor-icon-theme"
 short_desc="Simple Screen Recorder for programs and games"

From 7e927ff3fe535dadc79ecd1ba9810586b9d268e4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 079/113] sumo: revbump for ffmpeg-6.0

---
 srcpkgs/sumo/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/sumo/template b/srcpkgs/sumo/template
index 0f9b9ec815f5..a3fe134aa5ac 100644
--- a/srcpkgs/sumo/template
+++ b/srcpkgs/sumo/template
@@ -1,7 +1,7 @@
 # Template file for 'sumo'
 pkgname=sumo
 version=1.12.0
-revision=5
+revision=6
 build_style=cmake
 hostmakedepends="libgdal-tools pkg-config swig python3-setuptools"
 makedepends="python3-devel ffmpeg-devel fox-devel gl2ps-devel libgdal-devel

From 8822756174a2753faee503aa7831a480783d559a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 080/113] synfig: revbump for ffmpeg-6.0 and mlt7

---
 srcpkgs/synfig/patches/ffmpeg6.patch | 71 ++++++++++++++++++++++++++++
 srcpkgs/synfig/template              |  6 +--
 2 files changed, 74 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/synfig/patches/ffmpeg6.patch

diff --git a/srcpkgs/synfig/patches/ffmpeg6.patch b/srcpkgs/synfig/patches/ffmpeg6.patch
new file mode 100644
index 000000000000..10780b42782f
--- /dev/null
+++ b/srcpkgs/synfig/patches/ffmpeg6.patch
@@ -0,0 +1,71 @@
+--- a/src/modules/mod_libavcodec/trgt_av.cpp	2022-10-25 09:14:12.000000000 -0400
++++ b/src/modules/mod_libavcodec/trgt_av.cpp	2023-05-05 21:34:17.899194559 -0400
+@@ -38,6 +41,7 @@
+ extern "C"
+ {
+ #ifdef HAVE_LIBAVFORMAT_AVFORMAT_H
++#	include <libavcodec/avcodec.h>
+ #	include <libavformat/avformat.h>
+ #elif defined(HAVE_AVFORMAT_H)
+ #	include <avformat.h>
+@@ -155,11 +156,11 @@
+     }
+ 
+ 	bool open_video_stream() {
+-		if (avcodec_open2(video_context, NULL, NULL) < 0) {
++		if (avcodec_open2(video_context, nullptr, nullptr) < 0) {
+ 			synfig::error("Target_LibAVCodec: could not open video codec");
+ 			// seems the calling of avcodec_free_context after error will cause crash
+ 			// so just forget about this context
+-			video_context = NULL;
++			video_context = nullptr;
+ 			close();
+ 			return false;
+         }
+@@ -234,15 +235,21 @@
+ 		close();
+ 
+ 		if (!av_registered) {
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 			av_register_all();
++#endif
+ 			av_registered = true;
+ 		}
+ 
+ 		// guess format
+-		AVOutputFormat *format = av_guess_format(NULL, filename.c_str(), NULL);
++#if LIBAVCODEC_VERSION_MAJOR < 59 // FFMPEG < 5.0
++		AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#else
++		const AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#endif
+ 		if (!format) {
+ 			synfig::warning("Target_LibAVCodec: unable to guess the output format, defaulting to MPEG");
+-			format = av_guess_format("mpeg", NULL, NULL);
++			format = av_guess_format("mpeg", nullptr, nullptr);
+ 		}
+ 		if (!format) {
+ 			synfig::error("Target_LibAVCodec: unable to find 'mpeg' output format");
+@@ -254,6 +261,7 @@
+ 		context = avformat_alloc_context();
+ 		assert(context);
+ 		context->oformat = format;
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 		if (filename.size() + 1 > sizeof(context->filename)) {
+ 			synfig::error(
+ 				"Target_LibAVCodec: filename too long, max length is %d, filename is '%s'",
+@@ -263,6 +271,14 @@
+ 			return false;
+ 		}
+ 		memcpy(context->filename, filename.c_str(), filename.size() + 1);
++#else
++		context->url = av_strndup(filename.c_str(), filename.size());
++		if (!context->url) {
++			synfig::error("Target_LibAVCodec: cannot allocate space for filename");
++			close();
++			return false;
++		}
++#endif
+ 
+ 		packet = av_packet_alloc();
+ 		assert(packet);
diff --git a/srcpkgs/synfig/template b/srcpkgs/synfig/template
index 30109541ec4f..703cfd7ebac8 100644
--- a/srcpkgs/synfig/template
+++ b/srcpkgs/synfig/template
@@ -2,11 +2,11 @@
 # Should be kept in sync with 'synfigstudio' and 'ETL'
 pkgname=synfig
 version=1.4.4
-revision=3
+revision=4
 build_style=gnu-configure
 configure_args="--with-boost-libdir=${XBPS_CROSS_BASE}/usr/lib"
 hostmakedepends="boost-build ImageMagick pkg-config intltool"
-makedepends="ETL gettext-devel libxml++-devel mlt-devel libmagick-devel
+makedepends="ETL gettext-devel libxml++-devel mlt7-devel libmagick-devel
  libmng-devel boost-build boost-devel libopenexr-devel ffmpeg-devel"
 depends="ImageMagick"
 short_desc="CLI 2D vector and timeline-based animation software"
@@ -20,7 +20,7 @@ CXXFLAGS="-std=c++11 -DHAVE_LOCALE_H=1"
 
 synfig-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision}
-	 libopenexr-devel libxml++-devel mlt-devel"
+	 libopenexr-devel libxml++-devel mlt7-devel"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/bin/synfig-config

From fa6964dd7790c038a16826e838e30810dfd0887f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 081/113] tg_owt: revbump for ffmpeg-6.0

---
 srcpkgs/tg_owt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tg_owt/template b/srcpkgs/tg_owt/template
index 97d195ddb34a..551614b24956 100644
--- a/srcpkgs/tg_owt/template
+++ b/srcpkgs/tg_owt/template
@@ -1,7 +1,7 @@
 # Template file for 'tg_owt'
 pkgname=tg_owt
 version=0.0.0.20230107
-revision=1
+revision=2
 _commit=5098730b9eb6173f0b52068fe2555b7c1015123a
 _libyuv_commit=00950840d1c9bcbb3eb6ebc5aac5793e71166c8b
 _abseil_commit=8c0b94e793a66495e0b1f34a5eb26bd7dc672db0

From 5c3c404b622934625a12c3142215df710b8a5875 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 082/113] timg: revbump for ffmpeg-6.0

---
 srcpkgs/timg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/timg/template b/srcpkgs/timg/template
index 2a2ab763d2fd..8fb4327535ef 100644
--- a/srcpkgs/timg/template
+++ b/srcpkgs/timg/template
@@ -1,7 +1,7 @@
 # Template file for 'timg'
 pkgname=timg
 version=1.4.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_OPENSLIDE_SUPPORT=off -Wno-dev"
 hostmakedepends="pkg-config git"

From 37f63173ff5bb0b5fa47231a44916a0d4983eb8d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 083/113] tvheadend: revbump for ffmpeg4-4.4.3

---
 srcpkgs/tvheadend/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/tvheadend/template b/srcpkgs/tvheadend/template
index e6b16d7ccf3b..46b52b6fb7f9 100644
--- a/srcpkgs/tvheadend/template
+++ b/srcpkgs/tvheadend/template
@@ -1,14 +1,14 @@
 # Template file for 'tvheadend'
 pkgname=tvheadend
 version=4.2.8
-revision=6
+revision=7
 build_style=gnu-configure
 configure_args="--enable-dvbscan --disable-ffmpeg_static
 --disable-hdhomerun_static --disable-bintray_cache --disable-libx264_static
 --disable-libx265_static --disable-libvpx_static --disable-libtheora_static
 --disable-libvorbis_static --disable-libfdkaac_static"
 hostmakedepends="gettext pkg-config python git which"
-makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg-devel"
+makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg4-devel"
 short_desc="TV streaming server"
 maintainer="lemmi <lemmi@nerd2nerd.org>"
 license="GPL-3.0-only"

From e9ce70891df44c9e6344d38e11857eeb6dbbcf51 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 084/113] unpaper: update to 7.0.0.

---
 srcpkgs/unpaper/template | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/srcpkgs/unpaper/template b/srcpkgs/unpaper/template
index 38ed47a58401..1ff910e722af 100644
--- a/srcpkgs/unpaper/template
+++ b/srcpkgs/unpaper/template
@@ -1,13 +1,13 @@
 # Template file for 'unpaper'
 pkgname=unpaper
-version=6.1
-revision=3
-build_style=gnu-configure
+version=7.0.0
+revision=1
+build_style=meson
+hostmakedepends="pkg-config meson libxslt"
+makedepends="ffmpeg-devel python3-Sphinx"
+short_desc="Post-processing tool for scanned sheets of paper"
 maintainer="Orphaned <orphan@voidlinux.org>"
-hostmakedepends="pkg-config libxslt"
-makedepends="ffmpeg-devel"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://www.flameeyes.eu/projects/unpaper"
-short_desc="A post-processing tool for scanned sheets of paper"
 distfiles="https://www.flameeyes.eu/files/${pkgname}-${version}.tar.xz"
-checksum=237c84f5da544b3f7709827f9f12c37c346cdf029b1128fb4633f9bafa5cb930
+checksum=2575fbbf26c22719d1cb882b59602c9900c7f747118ac130883f63419be46a80

From ed12bda552159cd702103463017d07f6f22c5e9b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 085/113] vba-m: revbump for ffmpeg-6.0

---
 srcpkgs/vba-m/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vba-m/template b/srcpkgs/vba-m/template
index ba153e0b58ca..aa6093645e97 100644
--- a/srcpkgs/vba-m/template
+++ b/srcpkgs/vba-m/template
@@ -2,7 +2,7 @@
 pkgname=vba-m
 reverts=1292_2
 version=2.1.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_GTK=TRUE -DENABLE_FFMPEG=TRUE -DENABLE_LINK=TRUE -DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="gettext pkg-config unzip zip yasm wxWidgets-gtk3-devel"

From 4b6892c2659a0b06b1f13c39d6041628e35a7ac5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 086/113] vice: revbump for ffmpeg4-4.4.3

---
 srcpkgs/vice/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/vice/template b/srcpkgs/vice/template
index fe9d33a81194..4beab2c5f9eb 100644
--- a/srcpkgs/vice/template
+++ b/srcpkgs/vice/template
@@ -1,7 +1,7 @@
 # Template file for 'vice'
 pkgname=vice
 version=3.7.1
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="
 	$(vopt_enable sdl2 sdlui2)
@@ -26,7 +26,7 @@ makedepends="
 	$(vopt_if gtk3 gtk+3-devel)
 	$(vopt_if gtk3 pulseaudio-devel)
 	$(vopt_if gtk3 pango-devel)
-	$(vopt_if ffmpeg ffmpeg-devel)"
+	$(vopt_if ffmpeg ffmpeg4-devel)"
 short_desc="Emulator for C64, C128, CBM-II, PET, VIC20, Plus4 and C16"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"

From 0c8e0fb5875a53dca2306c0e5976add145438e61 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 087/113] waypipe: revbump for ffmpeg-6.0

---
 srcpkgs/waypipe/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waypipe/template b/srcpkgs/waypipe/template
index 5c4161900060..1a46fe27f7d8 100644
--- a/srcpkgs/waypipe/template
+++ b/srcpkgs/waypipe/template
@@ -1,7 +1,7 @@
 # Template file for 'waypipe'
 pkgname=waypipe
 version=0.8.4
-revision=1
+revision=2
 build_style=meson
 # lto is off because it causes linking errors in armv6l and armv7l (due to NEON)
 configure_args="-Dwerror=false -Dwith_dmabuf=enabled -Dwith_lz4=enabled

From 38e67558347d8ba8b7bfff93792c692fb257cb76 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 088/113] wf-recorder: revbump for ffmpeg-6.0

---
 srcpkgs/wf-recorder/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/wf-recorder/template b/srcpkgs/wf-recorder/template
index e278eb001600..5d014a5f28af 100644
--- a/srcpkgs/wf-recorder/template
+++ b/srcpkgs/wf-recorder/template
@@ -1,7 +1,7 @@
 # Template file for 'wf-recorder'
 pkgname=wf-recorder
 version=0.3.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config scdoc wayland-devel"
 makedepends="wayland-protocols wayland-devel ffmpeg-devel x264-devel

From a94bd83fa833fa99b7179eb526713edda87b0b09 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 089/113] xpra: revbump for ffmpeg-6.0

---
 srcpkgs/xpra/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xpra/template b/srcpkgs/xpra/template
index 0a63fdb6c743..d5acc1981c5f 100644
--- a/srcpkgs/xpra/template
+++ b/srcpkgs/xpra/template
@@ -1,7 +1,7 @@
 # Template file for 'xpra'
 pkgname=xpra
 version=4.4.6
-revision=1
+revision=2
 build_style=python3-module
 make_build_args="--without-cuda_kernels --without-cuda_rebuild"
 make_install_args="$(vopt_with docs) ${make_build_args}"

From ab55a4f5916befadd758601f12e6ecf6b364a5a3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:07:40 -0400
Subject: [PATCH 090/113] nv-codec-headers: update to 12.0.16.0

---
 srcpkgs/nv-codec-headers/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/nv-codec-headers/template b/srcpkgs/nv-codec-headers/template
index 3d422a61e489..251e057f826f 100644
--- a/srcpkgs/nv-codec-headers/template
+++ b/srcpkgs/nv-codec-headers/template
@@ -1,6 +1,6 @@
 # Template file for 'nv-codec-headers'
 pkgname=nv-codec-headers
-version=11.1.5.1
+version=12.0.16.0
 revision=1
 build_style=gnu-makefile
 short_desc="FFmpeg version of headers required to interface with Nvidias codec APIs"
@@ -8,7 +8,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="MIT"
 homepage="http://git.videolan.org/?p=ffmpeg/nv-codec-headers.git"
 distfiles="https://github.com/FFmpeg/nv-codec-headers/archive/n${version}.tar.gz"
-checksum=d095fbd56aa93772471a323be0ebe65504a0f43f06c76a30b6d25da77b06ae9c
+checksum=2a1533b65f55f9da52956faf0627ed3b74868ac0c7f269990edd21369113b48f
 
 post_install() {
 	sed -n '4,25p' include/ffnvcodec/nvEncodeAPI.h > LICENSE

From a9fb66fa48ee4186e924726c5ac23068923cbd46 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:08:40 -0400
Subject: [PATCH 091/113] openimagedenoise: revbump for ffmpeg-6.0

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index db5ccdb055cc..cb90045afb63 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,7 +1,7 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
 version=1.4.3
-revision=1
+revision=2
 archs="x86_64*"
 build_style=cmake
 hostmakedepends="ispc python3"

From 70397fe860b5a49531a195548fd16bf4ae0e2ec7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:31:45 -0400
Subject: [PATCH 092/113] shotcut: revbump for ffmpeg-6.0

---
 srcpkgs/shotcut/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/shotcut/template b/srcpkgs/shotcut/template
index 7d2af7b0470b..c416c906ff73 100644
--- a/srcpkgs/shotcut/template
+++ b/srcpkgs/shotcut/template
@@ -1,7 +1,7 @@
 # Template file for 'shotcut'
 pkgname=shotcut
 version=23.05.14
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSHOTCUT_VERSION=${version}"
 hostmakedepends="pkg-config qt6-tools-devel"

From 8b0f54619bf135b53610d93559d8d9a8e70f2a69 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:30 -0400
Subject: [PATCH 093/113] shiboken2: revbump for qt5-5.15.8

---
 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch | 1 +
 srcpkgs/shiboken2/template                                 | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
 create mode 120000 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
new file mode 120000
index 000000000000..efcf3249bd88
--- /dev/null
+++ b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1 @@
+../../python3-pyside2/patches/importlib-machinery-bypass.patch
\ No newline at end of file
diff --git a/srcpkgs/shiboken2/template b/srcpkgs/shiboken2/template
index 084ecc3ba1e1..2a21998997eb 100644
--- a/srcpkgs/shiboken2/template
+++ b/srcpkgs/shiboken2/template
@@ -1,7 +1,7 @@
 # Template file for 'shiboken2'
 pkgname=shiboken2
 version=5.15.7
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/shiboken2"
 build_style=cmake

From d3469c611566e6c27c9e957b6fb662df133a23fc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:53 -0400
Subject: [PATCH 094/113] python3-pyside2: update to 5.15.8

---
 .../patches/importlib-machinery-bypass.patch      | 15 +++++++++++++++
 srcpkgs/python3-pyside2/template                  |  9 +++++----
 2 files changed, 20 insertions(+), 4 deletions(-)
 create mode 100644 srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
new file mode 100644
index 000000000000..64c429584776
--- /dev/null
+++ b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1,15 @@
+Using this prevents an error around line 220 below it.
+"AttributeError: module 'importlib' has no attribute 'machinery'"
+The old backup logic is in place and compiles without issues.
+--- a/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:09:34.688912402 -0400
++++ b/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:10:03.395529582 -0400
+@@ -170,9 +170,6 @@
+
+     # 'zipstring_sequence' comes from signature.cpp
+     zipbytes = base64.b64decode(''.join(zipstring_sequence))
+-    if sys.version_info[0] >= 3:
+-        vzip = zipfile.ZipFile(io.BytesIO(zipbytes))
+-        return sys.meta_path, EmbeddableZipImporter(vzip)
+
+     # Old version for Python 2.7, only.
+     import os
diff --git a/srcpkgs/python3-pyside2/template b/srcpkgs/python3-pyside2/template
index 50e6ff260d3b..b50e62bd215d 100644
--- a/srcpkgs/python3-pyside2/template
+++ b/srcpkgs/python3-pyside2/template
@@ -1,11 +1,12 @@
 # Template file for 'python3-pyside2'
 pkgname=python3-pyside2
-version=5.15.5
-revision=2
+version=5.15.8
+revision=1
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/pyside2"
 build_style=cmake
-configure_args="-DPYTHON_EXECUTABLE=/usr/bin/python"
+configure_args="-DPYTHON_EXECUTABLE=/usr/bin/python -DCMAKE_BUILD_TYPE=None
+ -DBUILD_TESTS=OFF"
 hostmakedepends="cmake python3 shiboken2"
 makedepends="python3-devel libshiboken2-devel qt5-devel
  qt5-multimedia-devel qt5-tools-devel qt5-plugin-mysql qt5-plugin-odbc
@@ -23,7 +24,7 @@ maintainer="yopito <pierre.bourgin@free.fr>"
 license="LGPL-3.0-or-later"
 homepage="https://wiki.qt.io/Qt_for_Python"
 distfiles="https://download.qt.io/official_releases/QtForPython/pyside2/PySide2-${version}-src/${_pkgname}.tar.xz"
-checksum=3920a4fb353300260c9bc46ff70f1fb975c5e7efa22e9d51222588928ce19b33
+checksum=23436302c8deb5b4cbc769b205d09604e38ba83b40708efccb7bd8c9af6f6b5d
 
 build_options="webengine"
 desc_option_webengine="Build Qt5 WebEngine bindings"

From 1283bdb74e2bac200cb064b8498e6c42b12a68ce Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:35 -0400
Subject: [PATCH 095/113] konqueror: revbump for ffmpeg-6.0

---
 srcpkgs/konqueror/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/konqueror/template b/srcpkgs/konqueror/template
index d8d0e73a78ab..c5bdba601d3c 100644
--- a/srcpkgs/konqueror/template
+++ b/srcpkgs/konqueror/template
@@ -1,11 +1,11 @@
 # Template file for 'konqueror'
 pkgname=konqueror
 version=23.04.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DDESKTOPTOJSON_EXECUTABLE=/usr/bin/desktoptojson"
 hostmakedepends="extra-cmake-modules python3 qt5-host-tools qt5-qmake kdoctools
-kcoreaddons kconfig gettext"
+ kcoreaddons kconfig gettext"
 makedepends="qt5-devel qt5-webengine-devel qt5-declarative-devel
  qt5-webchannel-devel qt5-location-devel kcmutils-devel kdelibs4support-devel
  karchive-devel khtml-devel kdesu-devel kactivities5-devel"

From c9d16345621ba50cbe8308a3e33e4b6c7db6b4da Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:58 -0400
Subject: [PATCH 096/113] qt5-speech: revbump for qt5-5.15.8

---
 srcpkgs/qt5-speech/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-speech/template b/srcpkgs/qt5-speech/template
index 3ecd10d50650..2d7d4d4d2453 100644
--- a/srcpkgs/qt5-speech/template
+++ b/srcpkgs/qt5-speech/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-speech'
 pkgname=qt5-speech
 version=5.15.7
-revision=2
+revision=3
 _commit=d32f4a479d38a11f547598004b975f4356424a16
 build_style=qmake
 configure_args="-- -flite -flite-alsa -speechd"

From 652e89c8fc826c3a13c26a7624666bbe16f4cf4a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 18:38:50 -0400
Subject: [PATCH 097/113] qt5-styleplugins: revbump for qt5-5.15.8

---
 srcpkgs/qt5-styleplugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-styleplugins/template b/srcpkgs/qt5-styleplugins/template
index 96ed97d12cd2..30d93660a2a4 100644
--- a/srcpkgs/qt5-styleplugins/template
+++ b/srcpkgs/qt5-styleplugins/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-styleplugins'
 pkgname=qt5-styleplugins
 version=5.0.0
-revision=20
+revision=21
 _gitrev=335dbece103e2cbf6c7cf819ab6672c2956b17b3
 build_style=qmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From b8db05daa8125a247cd8c203c8a711a3447790ca Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 7 May 2023 20:14:14 -0400
Subject: [PATCH 098/113] mlt7: revbump for ffmpeg-6.0

---
 srcpkgs/gst-libav/template | 2 +-
 srcpkgs/mlt7/template      | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index 04c39bff1489..8c72fc3e97ee 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.22.2
-revision=2
+revision=1
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"
diff --git a/srcpkgs/mlt7/template b/srcpkgs/mlt7/template
index 9fb7f60d692e..cca0eb68cfc3 100644
--- a/srcpkgs/mlt7/template
+++ b/srcpkgs/mlt7/template
@@ -1,7 +1,7 @@
 # Template file for 'mlt7'
 pkgname=mlt7
 version=7.14.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSWIG_PYTHON=ON"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which

From 8d49b29b9ceab759ef3689f4bb3f8e58da79f99f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 7 May 2023 20:15:03 -0400
Subject: [PATCH 099/113] qt6-webengine: revbump for ffmpeg-6.0

---
 srcpkgs/qt6-webengine/template | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-webengine/template b/srcpkgs/qt6-webengine/template
index 4e22cb6e8863..43778b568d3f 100644
--- a/srcpkgs/qt6-webengine/template
+++ b/srcpkgs/qt6-webengine/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-webengine'
 pkgname=qt6-webengine
 version=6.5.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="
  -DQT_FEATURE_webengine_system_ffmpeg=ON
@@ -145,6 +145,7 @@ pre_install() {
 }
 
 post_install() {
+	vlicense LICENSES/BSD-3-Clause.txt
 	local _file
 	find "${DESTDIR}"/usr/lib/qt6/examples \
 		-path '*/lib/qt6/**/lib/qt6/*' -type f |

From a6f5b723228955d57cd68805809a878b5adf4e07 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 7 May 2023 20:15:29 -0400
Subject: [PATCH 100/113] tracker-miners: revbump for ffmpeg-6.0

---
 srcpkgs/tracker-miners/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tracker-miners/template b/srcpkgs/tracker-miners/template
index 8c005d697fa4..a6e5aa577702 100644
--- a/srcpkgs/tracker-miners/template
+++ b/srcpkgs/tracker-miners/template
@@ -1,7 +1,7 @@
 # Template file for 'tracker-miners'
 pkgname=tracker-miners
 version=3.5.0
-revision=3
+revision=4
 build_style=meson
 build_helper=qemu
 # missing libgrss for miner_rss

From 61039ebf953cf9299f310cd9efef436410ee2b8a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 7 May 2023 20:20:58 -0400
Subject: [PATCH 101/113] mpd: revbump for ffmpeg-6.0

---
 srcpkgs/mpd/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpd/template b/srcpkgs/mpd/template
index 9dbd4c935acc..9f058b62df2f 100644
--- a/srcpkgs/mpd/template
+++ b/srcpkgs/mpd/template
@@ -1,7 +1,7 @@
 # Template file for 'mpd'
 pkgname=mpd
 version=0.23.13
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dopus=enabled -Dmikmod=enabled -Dneighbor=true
  -Dsoundcloud=enabled -Dpipe=true -Dtwolame=enabled -Dbzip2=enabled

From ac4662930dd7a1e5fb7bbb7613099172862c5e32 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 11 May 2023 14:05:14 -0400
Subject: [PATCH 102/113] openmw: revbump for ffmpeg-6.0

---
 srcpkgs/openmw/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openmw/template b/srcpkgs/openmw/template
index e3771c7aaf1a..3cbf20b06577 100644
--- a/srcpkgs/openmw/template
+++ b/srcpkgs/openmw/template
@@ -1,7 +1,7 @@
 # Template file for 'openmw'
 pkgname=openmw
 version=0.47.0
-revision=5
+revision=6
 build_style=cmake
 _recast_commit=e75adf86f91eb3082220085e42dda62679f9a3ea
 _bullet_tag=3.17

From 360b969af0ff30874d6bd75b5c494c779ca9a42c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 21 May 2023 12:44:11 -0400
Subject: [PATCH 103/113] electron24: revbump for ffmpeg-6.0

---
 srcpkgs/electron24/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron24/template b/srcpkgs/electron24/template
index bdaa56adc8a6..ff3d5e3ef381 100644
--- a/srcpkgs/electron24/template
+++ b/srcpkgs/electron24/template
@@ -1,7 +1,7 @@
 # Template file for 'electron24'
 pkgname=electron24
 version=24.3.0
-revision=1
+revision=2
 _nodever=18.14.0
 _chromiumver=112.0.5615.165
 archs="x86_64* aarch64*"

From faddb18286f1dc8ac8e0c8ac2ca81df604036f25 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Jun 2023 08:20:22 -0400
Subject: [PATCH 104/113] gtk4: revbump for ffmpeg-6.0

---
 srcpkgs/gtk4/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gtk4/template b/srcpkgs/gtk4/template
index b318b7bae1dd..e3bde4a50e54 100644
--- a/srcpkgs/gtk4/template
+++ b/srcpkgs/gtk4/template
@@ -1,7 +1,7 @@
 # Template file for 'gtk4'
 pkgname=gtk4
 version=4.10.4
-revision=1
+revision=2
 build_style=meson
 build_helper="gir"
 configure_args="-Dman-pages=true -Dgtk_doc=true -Dbuild-tests=false

From 09f99f2f3ea510c4b14b154329e6aa37ec144b48 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:25:50 -0400
Subject: [PATCH 105/113] electron19: revbump for ffmpeg-6.0

---
 srcpkgs/electron19/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron19/template b/srcpkgs/electron19/template
index 32ce301e730c..ab7f308f5e8a 100644
--- a/srcpkgs/electron19/template
+++ b/srcpkgs/electron19/template
@@ -1,7 +1,7 @@
 # Template file for 'electron19'
 pkgname=electron19
 version=19.0.8
-revision=3
+revision=4
 _nodever=16.14.2
 _chromiumver=102.0.5005.125
 archs="x86_64* aarch64* ppc64le*"

From 8174e587b45289a2e54b8d41792e47a0c16acbea Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:28:26 -0400
Subject: [PATCH 106/113] siril: revbump for ffmpeg-6.0

---
 srcpkgs/siril/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/siril/template b/srcpkgs/siril/template
index 84332f79d060..62750dd24754 100644
--- a/srcpkgs/siril/template
+++ b/srcpkgs/siril/template
@@ -1,7 +1,7 @@
 # Template file for 'siril'
 pkgname=siril
 version=0.9.12
-revision=10
+revision=11
 build_style=gnu-configure
 hostmakedepends="pkg-config intltool autoconf automake gettext-devel"
 makedepends="fftw-devel libconfig-devel libopencv-devel libffms2-devel

From 5d65dda3eaf41a73c77b42fdd076edec444f55f1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:29:08 -0400
Subject: [PATCH 107/113] telegram-desktop: revbump for ffmpeg-6.0

---
 srcpkgs/telegram-desktop/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/telegram-desktop/template b/srcpkgs/telegram-desktop/template
index f114b2341dc5..9db9f80c1a53 100644
--- a/srcpkgs/telegram-desktop/template
+++ b/srcpkgs/telegram-desktop/template
@@ -1,7 +1,7 @@
 # Template file for 'telegram-desktop'
 pkgname=telegram-desktop
 version=4.8.1
-revision=3
+revision=4
 build_style=cmake
 build_helper="qemu"
 configure_args="-DTDESKTOP_API_ID=209235

From 0621ab4b4ce9ae1c549c50e9c4184a4ccb8ba12d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 10 Jun 2023 00:40:39 -0400
Subject: [PATCH 108/113] freecad: revbump for qt5-webengine-5.15.13

---
 srcpkgs/freecad/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/freecad/template b/srcpkgs/freecad/template
index a4a3f5f76b29..8608d1670c87 100644
--- a/srcpkgs/freecad/template
+++ b/srcpkgs/freecad/template
@@ -1,7 +1,7 @@
 # Template file for 'freecad'
 pkgname=freecad
 version=0.20.2
-revision=5
+revision=6
 build_style=cmake
 
 _inst_prefix=/usr/lib/${pkgname}

From 3e9bdeea13f55fe8999fedce9ea52e72dff8dfc7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 10 Jun 2023 00:57:09 -0400
Subject: [PATCH 109/113] qt6-multimedia: revbump for ffmpeg-6.0

---
 srcpkgs/qt6-multimedia/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-multimedia/template b/srcpkgs/qt6-multimedia/template
index a6832fdd69bf..c9ffac914ab8 100644
--- a/srcpkgs/qt6-multimedia/template
+++ b/srcpkgs/qt6-multimedia/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-multimedia'
 pkgname=qt6-multimedia
 version=6.5.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DQT_FEATURE_gstreamer=ON"
 hostmakedepends="perl qt6-declarative-host-tools pkg-config qt6-shadertools"

From e431082ec2d089ef95b916a542b3288af4f18884 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 22 Jun 2023 10:25:02 -0400
Subject: [PATCH 110/113] kdenlive: revbump for ffmpeg-6.0

---
 srcpkgs/kdenlive/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kdenlive/template b/srcpkgs/kdenlive/template
index 89c0dcfb8577..75495b3a3586 100644
--- a/srcpkgs/kdenlive/template
+++ b/srcpkgs/kdenlive/template
@@ -1,7 +1,7 @@
 # Template file for 'kdenlive'
 pkgname=kdenlive
 version=23.04.2
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="
  extra-cmake-modules kconfig kcoreaddons kdoctools pkg-config python3

From 28908f16b61797cef5c47f92a5fb7fe8b097f92b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Jul 2023 09:18:23 -0400
Subject: [PATCH 111/113] gmic: revbump for opencv-4.7.0

---
 srcpkgs/gmic/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gmic/template b/srcpkgs/gmic/template
index 0bb4034d5cc8..808953e9b543 100644
--- a/srcpkgs/gmic/template
+++ b/srcpkgs/gmic/template
@@ -1,7 +1,7 @@
 # Template file for 'gmic'
 pkgname=gmic
 version=3.1.6
-revision=4
+revision=5
 _zart_hash=34ebf6cce0bafb98abe57cec83c4a02cd1abeca0
 create_wrksrc=yes
 build_wrksrc="src"

From 6427f55e166b1c3a8a79cb59624e5d2d25c529b5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Jul 2023 09:29:52 -0400
Subject: [PATCH 112/113] synfigstudio: revbump for synfig mlt7

---
 srcpkgs/synfigstudio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/synfigstudio/template b/srcpkgs/synfigstudio/template
index af1c5a296ef0..09e442da9a68 100644
--- a/srcpkgs/synfigstudio/template
+++ b/srcpkgs/synfigstudio/template
@@ -2,7 +2,7 @@
 # Should be kept in sync with 'synfig' and 'ETL'
 pkgname=synfigstudio
 version=1.4.4
-revision=3
+revision=4
 build_style=gnu-configure
 configure_args="--disable-update-mimedb"
 hostmakedepends="pkg-config intltool gettext synfig"

From e2ae58981344c6169a0c33839896c545abdefc86 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Jul 2023 10:19:17 -0400
Subject: [PATCH 113/113] openimageio: revbump for ffmpeg6.0

---
 srcpkgs/openimageio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimageio/template b/srcpkgs/openimageio/template
index 0e9e22e9685d..e74a8dbd683e 100644
--- a/srcpkgs/openimageio/template
+++ b/srcpkgs/openimageio/template
@@ -1,7 +1,7 @@
 # Template file for 'openimageio'
 pkgname=openimageio
 version=2.4.9.0
-revision=5
+revision=6
 build_style=cmake
 build_helper=qemu
 configure_args="-DUSE_QT=0 -DUSE_PYTHON=0 -DOIIO_BUILD_TESTS=0

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (17 preceding siblings ...)
  2023-07-04 14:19 ` zlice
@ 2023-07-09 14:54 ` zlice
  2023-07-09 14:58 ` zlice
                   ` (78 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2023-07-09 14:54 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 3488 bytes --]

There is an updated pull request by zlice against master on the void-packages repository

https://github.com/zlice/void-packages ffmpeg6-split
https://github.com/void-linux/void-packages/pull/43761

ffmpeg6 split
[ci skip]


#### Testing the changes

- I tested the changes in this PR: **YES**

main testing has been vaapi in Firefox Nightly and enc/dec in Shotcut on Intel A770

#### New package

- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**

#### Local build testing

- I built this PR locally for my native architecture, **x86_64**

#### Discussion

Continuation of https://github.com/void-linux/void-packages/pull/36315

`libavresample` is deprecated, but marked as a dependency when trying to build other packages and install `ffmpeg`(6). I think the right way to handle this is make a meta package and the add to removals?


##### Commit naming / misc

~~Commits are 'dirty' right now, running with [gstreamer 1.22.1 updates](https://github.com/void-linux/void-packages/pull/42861) and [Intel OpenCL](https://github.com/void-linux/void-packages/pull/43084). This will also make [intel packages pr](https://github.com/void-linux/void-packages/pull/41132) obsolete.~~ (see Requirements below)

Maintainer for previous ffmpeg(4) was orphaned, I can put my name in there if that matters, though I don't exactly see myself keeping up on ffmpeg.

This updates QT5 which looks like it is usually hosted by Johnny. Not sure if there's any reason to stay there or these sources are fine.

##### STILL FFMPEG4

These are a mix of emulators, games and/or older packages.

- attract (multiple patches in master)
- audacity (https://github.com/audacity/audacity/issues/2305 and https://sourceforge.net/p/portmedia/wiki/portsmf/ is 'beta')
- ccextractor (master patches? no release)
- vice
- kodi
- mlt (only dep left is flowblade)
- ~~synfig (mlt)~~ (work with mlt7, bump synfigstudio)
- tvheadend
- ssr
- spek-alternative
- ppsspp
- olive
- moc
- mediastreamer
- libextractor
- idjc
- hedgewars
- ~~ffmpegthumbnailer~~ (patches for moviedecoder.xxx files)
- ~~ffmpegthumbs~~ (latest compiles)
- deadbeef
- omxplayer
- qtav (fork has ffmpeg 5 patch - https://github.com/cmguo/QtAV)
- `vlc` (vlc4 will support ffmpeg5, there's a patch to build 3.x with ffmpeg5 but it will lack vaapi)
- `osg` (OpenSceneGraph plus `xine-lib`)


##### HAVE NOT BUILT YET

- omxplayer (rpi only? ffmpeg4)
- kodi (big, but ffmpeg4)


##### UPDATED (for ffmpeg6)

- ~~blender: update to 3.5.1~~ ~~will be revbump with~~ https://github.com/void-linux/void-packages/pull/43992
- unpaper: update to 7.0.0.
- guvcview: update to 2.0.8.
- qt5: update to 5.15.8
- qt5-webengine: update to 5.18.13
- shiboken2: revbump for qt5.15.8 (patch)
- python3-pyside2: update to 5.15.8 (patch)


##### Requirements

- ~~[gstreamer 1.22.2](https://github.com/void-linux/void-packages/pull/42861)~~ - a few packages use ffmpeg-devel and require a revbump

- [Intel Packages](https://github.com/void-linux/void-packages/pull/41132) - ffmpeg4 uses different libraries than 6 (libmfx / Intel-MediaSDK vs only oneVPL that Intel is moving to), both are included here

- ~~[shotcut 23.05.14](https://github.com/void-linux/void-packages/pull/44260)~~

A patch file from https://github.com/void-linux/void-packages/pull/43761.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ffmpeg6-split-43761.patch --]
[-- Type: text/x-diff, Size: 789322 bytes --]

From 6265985acbfb97144fcc2d90b848d5463e30b5b7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:55:46 -0400
Subject: [PATCH 001/115] ffmpeg: update to 6.0.

---
 common/shlibs                                 | 26 +++++---
 srcpkgs/ffmpeg/files/altivec.patch            | 60 -------------------
 .../patches/armv5tel-floating-point.patch     | 18 ------
 ...h-libavcodec-libsvtav1-ten_bit_format.diff | 40 -------------
 .../workaround-mesa-readeon-vaapi-bug.patch   | 28 ---------
 srcpkgs/ffmpeg/template                       | 38 ++++++------
 6 files changed, 37 insertions(+), 173 deletions(-)
 delete mode 100644 srcpkgs/ffmpeg/files/altivec.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 delete mode 100644 srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch

diff --git a/common/shlibs b/common/shlibs
index 4b2122d1b199..93b272573eaa 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -392,15 +392,23 @@ libid3tag.so.0 libid3tag-0.15.1b_1
 libgif.so.7 giflib-5.1.0_1
 libImlib2.so.1 imlib2-1.4.2_1
 libmp3lame.so.0 lame-3.98.2_1
-libavdevice.so.58 libavdevice-4.0_1
-libavformat.so.58 libavformat-4.0_1
-libswscale.so.5 libswscale-4.0_1
-libswresample.so.3 libswresample-4.0_1
-libavresample.so.4 libavresample-4.0_1
-libpostproc.so.55 libpostproc-4.0_1
-libavcodec.so.58 libavcodec-4.0_1
-libavutil.so.56 libavutil-4.0_1
-libavfilter.so.7 libavfilter-4.0_1
+libavdevice.so.60 libavdevice-6.0_1
+libavformat.so.60 libavformat-6.0_1
+libswscale.so.7 libswscale-6.0_1
+libswresample.so.4 libswresample-6.0_1
+libpostproc.so.57 libpostproc-6.0_1
+libavcodec.so.60 libavcodec-6.0_1
+libavutil.so.58 libavutil-6.0_1
+libavfilter.so.9 libavfilter-6.0_1
+libavdevice.so.58 libavdevice4-4.0_1
+libavformat.so.58 libavformat4-4.0_1
+libswscale.so.5 libswscale4-4.0_1
+libswresample.so.3 libswresample4-4.0_1
+libavresample.so.4 libavresample4-4.0_1
+libpostproc.so.55 libpostproc4-4.0_1
+libavcodec.so.58 libavcodec4-4.0_1
+libavutil.so.56 libavutil4-4.0_1
+libavfilter.so.7 libavfilter4-4.0_1
 libSDL-1.2.so.0 SDL-1.2.14_1
 libSDL_image-1.2.so.0 SDL_image-1.2.10_1
 libx264.so.157 x264-20190507.2245_1
diff --git a/srcpkgs/ffmpeg/files/altivec.patch b/srcpkgs/ffmpeg/files/altivec.patch
deleted file mode 100644
index 9c5720046332..000000000000
--- a/srcpkgs/ffmpeg/files/altivec.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-revert some altivec specific change on all ppc* except ppc64le*
-
-q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
-conditionally, for ppc* but not ppc64le* (the new code is valid for
-POWER8 VSX which LE targets as a baseline but not BE)"
-
-
-This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
----
- libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
- 1 file changed, 20 insertions(+), 4 deletions(-)
-
-diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
-index 536545293d..c1e2852adb 100644
---- a/libswscale/ppc/yuv2rgb_altivec.c
-+++ b/libswscale/ppc/yuv2rgb_altivec.c
-@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-     vector signed short R1, G1, B1;                                           \
-     vector unsigned char R, G, B;                                             \
-                                                                               \
-+    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
-+    vector unsigned char align_perm;                                          \
-+                                                                              \
-     vector signed short lCY       = c->CY;                                    \
-     vector signed short lOY       = c->OY;                                    \
-     vector signed short lCRV      = c->CRV;                                   \
-@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
-                                                                               \
-         for (j = 0; j < w / 16; j++) {                                        \
--            y0 = vec_xl(0, y1i);                                              \
-+            y1ivP = (const vector unsigned char *) y1i;                       \
-+            y2ivP = (const vector unsigned char *) y2i;                       \
-+            uivP  = (const vector unsigned char *) ui;                        \
-+            vivP  = (const vector unsigned char *) vi;                        \
-+                                                                              \
-+            align_perm = vec_lvsl(0, y1i);                                    \
-+            y0 = (vector unsigned char)                                       \
-+                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
-                                                                               \
--            y1 = vec_xl(0, y2i);                                              \
-+            align_perm = vec_lvsl(0, y2i);                                    \
-+            y1 = (vector unsigned char)                                       \
-+                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
-                                                                               \
--            u = (vector signed char) vec_xl(0, ui);                           \
-+            align_perm = vec_lvsl(0, ui);                                     \
-+            u = (vector signed char)                                          \
-+                    vec_perm(uivP[0], uivP[1], align_perm);                   \
-                                                                               \
--            v = (vector signed char) vec_xl(0, vi);                           \
-+            align_perm = vec_lvsl(0, vi);                                     \
-+            v = (vector signed char)                                          \
-+                    vec_perm(vivP[0], vivP[1], align_perm);                   \
-                                                                               \
-             u = (vector signed char)                                          \
-                     vec_sub(u,                                                \
--- 
-2.27.0
-
diff --git a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
deleted file mode 100644
index 9a55178c74f0..000000000000
--- a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
-+++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
-@@ -39,6 +39,15 @@
- #endif
- #include <fenv.h>
- 
-+#if (FE_ALL_EXCEPT == 0)
-+/* E.g. ARM soft float does not define these */
-+#define FE_INVALID    0
-+#define FE_DIVBYZERO  0
-+#define FE_OVERFLOW   0
-+#define FE_UNDERFLOW  0
-+#define FE_INEXACT    0
-+#endif
-+
- #if CONFIG_LIBFONTCONFIG
- #include <fontconfig/fontconfig.h>
- #endif
diff --git a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
deleted file mode 100644
index aa948f7a8a2d..000000000000
--- a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
+++ /dev/null
@@ -1,40 +0,0 @@
-#==================================================================================================
-# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
-# From: Christopher Degawa <christopher.degawa@intel.com>
-# Date: Thu, 20 Oct 2022 22:55:27 -0500
-# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
-#
-# compressed_ten_bit_format has been deprecated upstream and has no effect
-# and can be removed. Plus, technically it was never used in the first place
-# since it would require the app (ffmpeg) to set it and do additional
-# processing of the input frames.
-#
-# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
-#
-# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
-#==================================================================================================
---- a/libavcodec/libsvtav1.c
-+++ b/libavcodec/libsvtav1.c
-@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
- 
- static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
- {
--    const int    pack_mode_10bit =
--        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
--    const size_t luma_size_8bit  =
--        config->source_width * config->source_height * (1 << pack_mode_10bit);
--    const size_t luma_size_10bit =
--        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
-+    const size_t luma_size = config->source_width * config->source_height *
-+        (config->encoder_bit_depth > 8 ? 2 : 1);
- 
-     EbSvtIOFormat *in_data;
- 
--    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
-+    svt_enc->raw_size = luma_size * 3 / 2;
- 
-     // allocate buffer for in and out
-     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
--- 
-GitLab
-
diff --git a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
deleted file mode 100644
index 00e3f68a415b..000000000000
--- a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
-From: Rainer Hochecker <fernetmenta@online.de>
-Date: Sat, 26 Jan 2019 19:48:35 +0100
-Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
-
-This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
-It was hit frequently when watching h264 channels received via DVB-X.
-Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
----
- libavcodec/vaapi_h264.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
-index 5854587a255..f12fdc457a4 100644
---- a/libavcodec/vaapi_h264.c
-+++ b/libavcodec/vaapi_h264.c
-@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
-     H264SliceContext *sl = &h->slice_ctx[0];
-     int ret;
- 
-+    if (pic->nb_slices == 0) {
-+        ret = AVERROR_INVALIDDATA;
-+        goto finish;
-+    }
-+
-     ret = ff_vaapi_decode_issue(avctx, pic);
-     if (ret < 0)
-         goto finish;
diff --git a/srcpkgs/ffmpeg/template b/srcpkgs/ffmpeg/template
index aa058aab9ca9..b877f86c1c69 100644
--- a/srcpkgs/ffmpeg/template
+++ b/srcpkgs/ffmpeg/template
@@ -1,15 +1,15 @@
 # Template file for 'ffmpeg'
 # audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
 pkgname=ffmpeg
-version=4.4.4
-revision=2
+version=6.0
+revision=1
 short_desc="Decoding, encoding and streaming software"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="https://www.ffmpeg.org"
 changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
 distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
-checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+checksum=57be87c22d9b49c112b6d24bc67d42508660e6b718b3db89c44e47e289137082
 
 hostmakedepends="pkg-config perl"
 makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
@@ -26,12 +26,13 @@ makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-deve
  $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
  $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
  $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
- $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers Vulkan-Tools Vulkan-ValidationLayers')
+ $(vopt_if onevpl 'onevpl onevpl-devel')
  $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
 depends="ffplay>=${version}_${revision}"
 
 build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
- dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec onevpl"
 build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
 desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
 desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
@@ -39,9 +40,13 @@ desc_option_sofa="Enable support for AES SOFA"
 desc_option_webp="Enable support for WebP"
 
 case "$XBPS_TARGET_MACHINE" in
-	i686*|x86_64*)
-		hostmakedepends+=" nasm"
+	i686*)
 		build_options_default+=" vaapi vdpau nvenc nvdec"
+		hostmakedepends+=" nasm"
+		;;
+	x86_64*)
+		hostmakedepends+=" nasm"
+		build_options_default+=" vaapi vdpau nvenc nvdec onevpl"
 		;;
 	ppc64*) build_options_default+=" vaapi vdpau";;
 	mips*) CFLAGS="-mnan=legacy";;
@@ -119,18 +124,19 @@ do_configure() {
 		$(vopt_enable x265 libx265) \
 		$(vopt_enable v4l2 libv4l2) \
 		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
-		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		--enable-libbs2b --enable-libvidstab \
 		$(vopt_enable dav1d libdav1d) \
 		$(vopt_enable zimg libzimg) \
 		$(vopt_enable webp libwebp) \
 		$(vopt_enable sofa libmysofa) \
 		$(vopt_enable vulkan) \
+		$(vopt_enable onevpl libvpl) \
 		$(vopt_enable drm libdrm) \
 		$(vopt_enable svtav1 libsvtav1) \
 		$(vopt_enable srt libsrt) \
 		$(vopt_enable rist librist) \
-		$(vopt_if nvenc '--enable-nvenc') \
-		$(vopt_if nvdec '--enable-nvdec')
+		$(vopt_enable nvenc nvenc) \
+		$(vopt_enable nvdec nvdec)
 }
 
 do_build() {
@@ -157,10 +163,8 @@ libavdevice_package() {
 }
 
 libavresample_package() {
-	short_desc="FFmpeg audio resampling library"
-	pkg_install() {
-		vmove "usr/lib/libavresample.so.*"
-	}
+	short_desc="Package deprecated, removal needed"
+	build_style=meta
 }
 
 libavformat_package() {
@@ -214,15 +218,13 @@ ffmpeg-devel_package() {
 		libavfilter>=${version}_${revision}
 		libpostproc>=${version}_${revision}
 		libswscale>=${version}_${revision}
-		libswresample>=${version}_${revision}
-		libavresample>=${version}_${revision}"
+		libswresample>=${version}_${revision}"
 	short_desc+=" - development files"
-
+	conflicts="ffmpeg4-devel"
 	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
 		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
 		nostrip_files="/usr/lib/libavfilter.a"
 	fi
-
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig

From d2ddccedad308160353f9382380e134d6c0c380d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:56:22 -0400
Subject: [PATCH 002/115] New package: ffmpeg4-4.4.4.

---
 srcpkgs/ffmpeg4-devel                         |   1 +
 srcpkgs/ffmpeg4/files/altivec.patch           |  60 +++++
 .../patches/armv5tel-floating-point.patch     |  18 ++
 ...h-libavcodec-libsvtav1-ten_bit_format.diff |  40 +++
 .../workaround-mesa-readeon-vaapi-bug.patch   |  28 ++
 srcpkgs/ffmpeg4/template                      | 240 ++++++++++++++++++
 srcpkgs/libavcodec4                           |   1 +
 srcpkgs/libavdevice4                          |   1 +
 srcpkgs/libavfilter4                          |   1 +
 srcpkgs/libavformat4                          |   1 +
 srcpkgs/libavresample4                        |   1 +
 srcpkgs/libavutil4                            |   1 +
 srcpkgs/libpostproc4                          |   1 +
 srcpkgs/libswresample4                        |   1 +
 srcpkgs/libswscale4                           |   1 +
 15 files changed, 396 insertions(+)
 create mode 120000 srcpkgs/ffmpeg4-devel
 create mode 100644 srcpkgs/ffmpeg4/files/altivec.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 create mode 100644 srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
 create mode 100644 srcpkgs/ffmpeg4/template
 create mode 120000 srcpkgs/libavcodec4
 create mode 120000 srcpkgs/libavdevice4
 create mode 120000 srcpkgs/libavfilter4
 create mode 120000 srcpkgs/libavformat4
 create mode 120000 srcpkgs/libavresample4
 create mode 120000 srcpkgs/libavutil4
 create mode 120000 srcpkgs/libpostproc4
 create mode 120000 srcpkgs/libswresample4
 create mode 120000 srcpkgs/libswscale4

diff --git a/srcpkgs/ffmpeg4-devel b/srcpkgs/ffmpeg4-devel
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/ffmpeg4-devel
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/ffmpeg4/files/altivec.patch b/srcpkgs/ffmpeg4/files/altivec.patch
new file mode 100644
index 000000000000..9c5720046332
--- /dev/null
+++ b/srcpkgs/ffmpeg4/files/altivec.patch
@@ -0,0 +1,60 @@
+revert some altivec specific change on all ppc* except ppc64le*
+
+q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
+conditionally, for ppc* but not ppc64le* (the new code is valid for
+POWER8 VSX which LE targets as a baseline but not BE)"
+
+
+This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
+---
+ libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
+ 1 file changed, 20 insertions(+), 4 deletions(-)
+
+diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
+index 536545293d..c1e2852adb 100644
+--- a/libswscale/ppc/yuv2rgb_altivec.c
++++ b/libswscale/ppc/yuv2rgb_altivec.c
+@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+     vector signed short R1, G1, B1;                                           \
+     vector unsigned char R, G, B;                                             \
+                                                                               \
++    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
++    vector unsigned char align_perm;                                          \
++                                                                              \
+     vector signed short lCY       = c->CY;                                    \
+     vector signed short lOY       = c->OY;                                    \
+     vector signed short lCRV      = c->CRV;                                   \
+@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
+                                                                               \
+         for (j = 0; j < w / 16; j++) {                                        \
+-            y0 = vec_xl(0, y1i);                                              \
++            y1ivP = (const vector unsigned char *) y1i;                       \
++            y2ivP = (const vector unsigned char *) y2i;                       \
++            uivP  = (const vector unsigned char *) ui;                        \
++            vivP  = (const vector unsigned char *) vi;                        \
++                                                                              \
++            align_perm = vec_lvsl(0, y1i);                                    \
++            y0 = (vector unsigned char)                                       \
++                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
+                                                                               \
+-            y1 = vec_xl(0, y2i);                                              \
++            align_perm = vec_lvsl(0, y2i);                                    \
++            y1 = (vector unsigned char)                                       \
++                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
+                                                                               \
+-            u = (vector signed char) vec_xl(0, ui);                           \
++            align_perm = vec_lvsl(0, ui);                                     \
++            u = (vector signed char)                                          \
++                    vec_perm(uivP[0], uivP[1], align_perm);                   \
+                                                                               \
+-            v = (vector signed char) vec_xl(0, vi);                           \
++            align_perm = vec_lvsl(0, vi);                                     \
++            v = (vector signed char)                                          \
++                    vec_perm(vivP[0], vivP[1], align_perm);                   \
+                                                                               \
+             u = (vector signed char)                                          \
+                     vec_sub(u,                                                \
+-- 
+2.27.0
+
diff --git a/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
new file mode 100644
index 000000000000..9a55178c74f0
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
@@ -0,0 +1,18 @@
+--- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
++++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
+@@ -39,6 +39,15 @@
+ #endif
+ #include <fenv.h>
+ 
++#if (FE_ALL_EXCEPT == 0)
++/* E.g. ARM soft float does not define these */
++#define FE_INVALID    0
++#define FE_DIVBYZERO  0
++#define FE_OVERFLOW   0
++#define FE_UNDERFLOW  0
++#define FE_INEXACT    0
++#endif
++
+ #if CONFIG_LIBFONTCONFIG
+ #include <fontconfig/fontconfig.h>
+ #endif
diff --git a/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
new file mode 100644
index 000000000000..aa948f7a8a2d
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
@@ -0,0 +1,40 @@
+#==================================================================================================
+# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
+# From: Christopher Degawa <christopher.degawa@intel.com>
+# Date: Thu, 20 Oct 2022 22:55:27 -0500
+# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
+#
+# compressed_ten_bit_format has been deprecated upstream and has no effect
+# and can be removed. Plus, technically it was never used in the first place
+# since it would require the app (ffmpeg) to set it and do additional
+# processing of the input frames.
+#
+# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
+#
+# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
+#==================================================================================================
+--- a/libavcodec/libsvtav1.c
++++ b/libavcodec/libsvtav1.c
+@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
+ 
+ static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
+ {
+-    const int    pack_mode_10bit =
+-        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
+-    const size_t luma_size_8bit  =
+-        config->source_width * config->source_height * (1 << pack_mode_10bit);
+-    const size_t luma_size_10bit =
+-        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
++    const size_t luma_size = config->source_width * config->source_height *
++        (config->encoder_bit_depth > 8 ? 2 : 1);
+ 
+     EbSvtIOFormat *in_data;
+ 
+-    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
++    svt_enc->raw_size = luma_size * 3 / 2;
+ 
+     // allocate buffer for in and out
+     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
+-- 
+GitLab
+
diff --git a/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
new file mode 100644
index 000000000000..00e3f68a415b
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
@@ -0,0 +1,28 @@
+From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
+From: Rainer Hochecker <fernetmenta@online.de>
+Date: Sat, 26 Jan 2019 19:48:35 +0100
+Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
+
+This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
+It was hit frequently when watching h264 channels received via DVB-X.
+Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
+---
+ libavcodec/vaapi_h264.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
+index 5854587a255..f12fdc457a4 100644
+--- a/libavcodec/vaapi_h264.c
++++ b/libavcodec/vaapi_h264.c
+@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
+     H264SliceContext *sl = &h->slice_ctx[0];
+     int ret;
+ 
++    if (pic->nb_slices == 0) {
++        ret = AVERROR_INVALIDDATA;
++        goto finish;
++    }
++
+     ret = ff_vaapi_decode_issue(avctx, pic);
+     if (ret < 0)
+         goto finish;
diff --git a/srcpkgs/ffmpeg4/template b/srcpkgs/ffmpeg4/template
new file mode 100644
index 000000000000..f2c851693d36
--- /dev/null
+++ b/srcpkgs/ffmpeg4/template
@@ -0,0 +1,240 @@
+# Template file for 'ffmpeg4'
+# audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
+pkgname=ffmpeg4
+version=4.4.4
+revision=1
+short_desc="Decoding, encoding and streaming software - ffmpeg4 libraries only"
+maintainer="Orphaned <orphan@voidlinux.org>"
+license="GPL-3.0-or-later"
+homepage="https://www.ffmpeg.org"
+changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
+distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
+checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+
+hostmakedepends="pkg-config perl"
+makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
+ libXext-devel libXvMC-devel libxcb-devel lame-devel libtheora-devel
+ libvorbis-devel x264-devel xvidcore-devel jack-devel SDL2-devel
+ libcdio-paranoia-devel librtmp-devel libmodplug-devel gnutls-devel
+ speex-devel celt-devel harfbuzz-devel libass-devel opus-devel ocl-icd-devel
+ libbs2b-devel libvidstab-devel vmaf-devel $(vopt_if pulseaudio pulseaudio-devel)
+ $(vopt_if vaapi libva-devel) $(vopt_if vdpau libvdpau-devel)
+ $(vopt_if x265 x265-devel) $(vopt_if v4l2 v4l-utils-devel)
+ $(vopt_if fdk_aac fdk-aac-devel) $(vopt_if vpx libvpx-devel)
+ $(vopt_if aom libaom-devel) $(vopt_if sndio sndio-devel)
+ $(vopt_if dav1d libdav1d-devel) $(vopt_if zimg zimg-devel)
+ $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
+ $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
+ $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if mfx 'libmfx libmfx-devel')
+ $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
+
+build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec mfx"
+build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
+
+desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
+desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
+desc_option_sofa="Enable support for AES SOFA"
+desc_option_webp="Enable support for WebP"
+
+case "$XBPS_TARGET_MACHINE" in
+	i686*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau nvenc nvdec"
+			;;
+	x86_64*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau mfx nvenc nvdec"
+			;;
+	ppc64*) build_options_default+=" vaapi vdpau";;
+	mips*) CFLAGS="-mnan=legacy";;
+esac
+
+if [ "$XBPS_TARGET_WORDSIZE" != "32" ]; then
+	build_options_default+=" svtav1"
+fi
+
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+fi
+
+_apply_patch() {
+	local args="$1" pname="$(basename $2)"
+
+	if [ ! -f ".${pname}_done" ]; then
+		patch -N $args -i $2
+		touch .${pname}_done
+	fi
+}
+
+post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64le*) ;;
+		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
+	esac
+
+	vsed -i libavfilter/vf_libvmaf.c -e 's!/usr/local/share/model/\(vmaf_v0.6.1\).pkl!/usr/share/vmaf/\1.json!'
+}
+
+do_configure() {
+	# Fix gcc on x86_64-musl only
+	if [ "$XBPS_TARGET_MACHINE" = "x86_64-musl" ]; then
+		vsed -i configure -e "s;_cflags_speed='-O3';_cflags_speed='-O2';"
+	fi
+
+	if [ "$CROSS_BUILD" ]; then
+		case "$XBPS_TARGET_MACHINE" in
+			arm*) _arch="arm";;
+			aarch64*) _arch="aarch64";;
+			mips*) _arch="mips";;
+			ppc64*) _arch="ppc64";;
+			ppc*) _arch="ppc";;
+			*) _arch="${XBPS_TARGET_MACHINE%%-musl}";;
+		esac
+
+		_args+=" --enable-cross-compile
+			--sysroot=$XBPS_CROSS_BASE
+			--cross-prefix=${XBPS_CROSS_TRIPLET}-
+			--target-os=linux --arch=${_arch}"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc|ppc-musl) _args+=" --disable-altivec";;
+	esac
+
+	if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+		_args+=" --extra-libs=-latomic"
+	fi
+
+	./configure --prefix=/usr --disable-debug --enable-gpl --enable-gnutls \
+		--disable-stripping \
+		--enable-libcdio --enable-version3 --enable-runtime-cpudetect \
+		--enable-libmp3lame --enable-libvorbis --enable-libxvid \
+		--enable-libx264 $(vopt_enable vpx libvpx) --enable-libtheora \
+		--enable-shared --enable-static --enable-libxcb \
+		$(vopt_enable pulseaudio libpulse) --enable-libfreetype --enable-libmodplug \
+		--enable-libspeex --enable-libcelt --enable-libass \
+		--enable-libopus --enable-librtmp --enable-libjack \
+		$(vopt_if fdk_aac '--enable-nonfree --enable-libfdk-aac') \
+		--disable-libopencore_amrnb --disable-libopencore_amrwb \
+		--disable-libopenjpeg \
+		--enable-postproc --enable-opencl ${_args} --enable-libvmaf ${_args} \
+		$(vopt_enable x265 libx265) \
+		$(vopt_enable v4l2 libv4l2) \
+		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
+		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		$(vopt_enable dav1d libdav1d) \
+		$(vopt_enable zimg libzimg) \
+		$(vopt_enable webp libwebp) \
+		$(vopt_enable sofa libmysofa) \
+		$(vopt_enable vulkan) \
+		$(vopt_enable drm libdrm) \
+		$(vopt_enable svtav1 libsvtav1) \
+		$(vopt_enable srt libsrt) \
+		$(vopt_enable rist librist) \
+		$(vopt_enable mfx libmfx) \
+		$(vopt_if nvenc '--enable-nvenc') \
+		$(vopt_if nvdec '--enable-nvdec')
+}
+
+do_build() {
+	make ${makejobs}
+	make doc/ff{mpeg,play}.1
+}
+
+do_install() {
+	make DESTDIR=${DESTDIR} install install-man
+	rm -rf ${DESTDIR}/usr/bin
+}
+
+libavcodec4_package() {
+	short_desc="FFmpeg codec library"
+	pkg_install() {
+		vmove "usr/lib/libavcodec.so.*"
+	}
+}
+
+libavdevice4_package() {
+	short_desc="FFmpeg device handling library"
+	pkg_install() {
+		vmove "usr/lib/libavdevice.so.*"
+	}
+}
+
+libavresample4_package() {
+	short_desc="FFmpeg audio resampling library"
+	pkg_install() {
+		vmove "usr/lib/libavresample.so.*"
+	}
+}
+
+libavformat4_package() {
+	short_desc="FFmpeg file format library"
+	pkg_install() {
+		vmove "usr/lib/libavformat.so.*"
+	}
+}
+
+libavutil4_package() {
+	short_desc="FFmpeg utility library"
+	pkg_install() {
+		vmove "usr/lib/libavutil.so.*"
+	}
+}
+
+libavfilter4_package() {
+	short_desc="FFmpeg audio/video filter library"
+	pkg_install() {
+		vmove "usr/lib/libavfilter.so.*"
+	}
+}
+
+libpostproc4_package() {
+	short_desc="FFmpeg video postprocessing library"
+	pkg_install() {
+		vmove "usr/lib/libpostproc.so.*"
+	}
+}
+
+libswscale4_package() {
+	short_desc="FFmpeg video scaling library"
+	pkg_install() {
+		vmove "usr/lib/libswscale.so.*"
+	}
+}
+
+libswresample4_package() {
+	short_desc="FFmpeg video resampling library"
+	pkg_install() {
+		vmove "usr/lib/libswresample.so.*"
+	}
+}
+
+ffmpeg4-devel_package() {
+	depends="
+		libavcodec4>=${version}_${revision}
+		libavdevice4>=${version}_${revision}
+		libavformat4>=${version}_${revision}
+		libavutil4>=${version}_${revision}
+		libavfilter4>=${version}_${revision}
+		libpostproc4>=${version}_${revision}
+		libswscale4>=${version}_${revision}
+		libswresample4>=${version}_${revision}
+		libavresample4>=${version}_${revision}"
+	short_desc+=" - development files"
+	conflicts="ffmpeg-devel"
+	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
+		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
+		nostrip_files="/usr/lib/libavfilter.a"
+	fi
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.a"
+		vmove "usr/lib/*.so"
+		vmove usr/share/ffmpeg/examples
+		vmove usr/share/man/man3
+	}
+}
diff --git a/srcpkgs/libavcodec4 b/srcpkgs/libavcodec4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavcodec4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavdevice4 b/srcpkgs/libavdevice4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavdevice4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavfilter4 b/srcpkgs/libavfilter4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavfilter4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavformat4 b/srcpkgs/libavformat4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavformat4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavresample4 b/srcpkgs/libavresample4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavutil4 b/srcpkgs/libavutil4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavutil4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libpostproc4 b/srcpkgs/libpostproc4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libpostproc4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswresample4 b/srcpkgs/libswresample4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libswresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswscale4 b/srcpkgs/libswscale4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libswscale4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file

From 1777eebef5b2cd6aa2f306a60f2be04ce298c39b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:04 -0400
Subject: [PATCH 003/115] opencv: update to 4.7.0.

---
 common/shlibs           | 104 ++++++++++++++++++++--------------------
 srcpkgs/opencv/template |   8 ++--
 2 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index 93b272573eaa..27ae0b223a0b 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2141,58 +2141,58 @@ libcapstone.so.4 capstone-4.0_1
 libhavege.so.2 libhaveged-1.9.11_1
 libnih.so.1 libnih-1.0.3_1
 libnih-dbus.so.1 libnih-1.0.3_1
-libopencv_quality.so.406 libopencv-4.6.0_1
-libopencv_reg.so.406 libopencv-4.6.0_1
-libopencv_surface_matching.so.406 libopencv-4.6.0_1
-libopencv_xphoto.so.406 libopencv-4.6.0_1
-libopencv_freetype.so.406 libopencv-4.6.0_1
-libopencv_fuzzy.so.406 libopencv-4.6.0_1
-libopencv_hfs.so.406 libopencv-4.6.0_1
-libopencv_img_hash.so.406 libopencv-4.6.0_1
-libopencv_line_descriptor.so.406 libopencv-4.6.0_1
-libopencv_saliency.so.406 libopencv-4.6.0_1
-libopencv_structured_light.so.406 libopencv-4.6.0_1
-libopencv_aruco.so.406 libopencv-4.6.0_1
-libopencv_bgsegm.so.406 libopencv-4.6.0_1
-libopencv_bioinspired.so.406 libopencv-4.6.0_1
-libopencv_ccalib.so.406 libopencv-4.6.0_1
-libopencv_face.so.406 libopencv-4.6.0_1
-libopencv_tracking.so.406 libopencv-4.6.0_1
-libopencv_xfeatures2d.so.406 libopencv-4.6.0_1
-libopencv_optflow.so.406 libopencv-4.6.0_1
-libopencv_ximgproc.so.406 libopencv-4.6.0_1
-libopencv_plot.so.406 libopencv-4.6.0_1
-libopencv_text.so.406 libopencv-4.6.0_1
-libopencv_ml.so.406 libopencv-4.6.0_1
-libopencv_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn.so.406 libopencv-4.6.0_1
-libopencv_shape.so.406 libopencv-4.6.0_1
-libopencv_stitching.so.406 libopencv-4.6.0_1
-libopencv_photo.so.406 libopencv-4.6.0_1
-libopencv_video.so.406 libopencv-4.6.0_1
-libopencv_calib3d.so.406 libopencv-4.6.0_1
-libopencv_features2d.so.406 libopencv-4.6.0_1
-libopencv_flann.so.406 libopencv-4.6.0_1
-libopencv_highgui.so.406 libopencv-4.6.0_1
-libopencv_videoio.so.406 libopencv-4.6.0_1
-libopencv_imgcodecs.so.406 libopencv-4.6.0_1
-libopencv_imgproc.so.406 libopencv-4.6.0_1
-libopencv_core.so.406 libopencv-4.6.0_1
-libopencv_superres.so.406 libopencv-4.6.0_1
-libopencv_videostab.so.406 libopencv-4.6.0_1
-libopencv_gapi.so.406 libopencv-4.6.0_1
-libopencv_xobjdetect.so.406 libopencv-4.6.0_1
-libopencv_datasets.so.406 libopencv-4.6.0_1
-libopencv_dnn_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn_superres.so.406 libopencv-4.6.0_1
-libopencv_dpm.so.406 libopencv-4.6.0_1
-libopencv_phase_unwrapping.so.406 libopencv-4.6.0_1
-libopencv_stereo.so.406 libopencv-4.6.0_1
-libopencv_rapid.so.406 libopencv-4.6.0_1
-libopencv_intensity_transform.so.406 libopencv-4.6.0_1
-libopencv_alphamat.so.406 libopencv-4.6.0_1
-libopencv_barcode.so.406 libopencv-4.6.0_1
-libopencv_mcc.so.406 libopencv-4.6.0_1
+libopencv_quality.so.407 libopencv-4.7.0_1
+libopencv_reg.so.407 libopencv-4.7.0_1
+libopencv_surface_matching.so.407 libopencv-4.7.0_1
+libopencv_xphoto.so.407 libopencv-4.7.0_1
+libopencv_freetype.so.407 libopencv-4.7.0_1
+libopencv_fuzzy.so.407 libopencv-4.7.0_1
+libopencv_hfs.so.407 libopencv-4.7.0_1
+libopencv_img_hash.so.407 libopencv-4.7.0_1
+libopencv_line_descriptor.so.407 libopencv-4.7.0_1
+libopencv_saliency.so.407 libopencv-4.7.0_1
+libopencv_structured_light.so.407 libopencv-4.7.0_1
+libopencv_aruco.so.407 libopencv-4.7.0_1
+libopencv_bgsegm.so.407 libopencv-4.7.0_1
+libopencv_bioinspired.so.407 libopencv-4.7.0_1
+libopencv_ccalib.so.407 libopencv-4.7.0_1
+libopencv_face.so.407 libopencv-4.7.0_1
+libopencv_tracking.so.407 libopencv-4.7.0_1
+libopencv_xfeatures2d.so.407 libopencv-4.7.0_1
+libopencv_optflow.so.407 libopencv-4.7.0_1
+libopencv_ximgproc.so.407 libopencv-4.7.0_1
+libopencv_plot.so.407 libopencv-4.7.0_1
+libopencv_text.so.407 libopencv-4.7.0_1
+libopencv_ml.so.407 libopencv-4.7.0_1
+libopencv_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn.so.407 libopencv-4.7.0_1
+libopencv_shape.so.407 libopencv-4.7.0_1
+libopencv_stitching.so.407 libopencv-4.7.0_1
+libopencv_photo.so.407 libopencv-4.7.0_1
+libopencv_video.so.407 libopencv-4.7.0_1
+libopencv_calib3d.so.407 libopencv-4.7.0_1
+libopencv_features2d.so.407 libopencv-4.7.0_1
+libopencv_flann.so.407 libopencv-4.7.0_1
+libopencv_highgui.so.407 libopencv-4.7.0_1
+libopencv_videoio.so.407 libopencv-4.7.0_1
+libopencv_imgcodecs.so.407 libopencv-4.7.0_1
+libopencv_imgproc.so.407 libopencv-4.7.0_1
+libopencv_core.so.407 libopencv-4.7.0_1
+libopencv_superres.so.407 libopencv-4.7.0_1
+libopencv_videostab.so.407 libopencv-4.7.0_1
+libopencv_gapi.so.407 libopencv-4.7.0_1
+libopencv_xobjdetect.so.407 libopencv-4.7.0_1
+libopencv_datasets.so.407 libopencv-4.7.0_1
+libopencv_dnn_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn_superres.so.407 libopencv-4.7.0_1
+libopencv_dpm.so.407 libopencv-4.7.0_1
+libopencv_phase_unwrapping.so.407 libopencv-4.7.0_1
+libopencv_stereo.so.407 libopencv-4.7.0_1
+libopencv_rapid.so.407 libopencv-4.7.0_1
+libopencv_intensity_transform.so.407 libopencv-4.7.0_1
+libopencv_alphamat.so.407 libopencv-4.7.0_1
+libopencv_barcode.so.407 libopencv-4.7.0_1
+libopencv_mcc.so.407 libopencv-4.7.0_1
 libuniconf.so.4.6 wvstreams-4.6.1_20
 libwvbase.so.4.6 wvstreams-4.6.1_20
 libwvutils.so.4.6 wvstreams-4.6.1_20
diff --git a/srcpkgs/opencv/template b/srcpkgs/opencv/template
index 69c635b1ad2b..41f3183f1582 100644
--- a/srcpkgs/opencv/template
+++ b/srcpkgs/opencv/template
@@ -1,7 +1,7 @@
 # Template file for 'opencv'
 pkgname=opencv
-version=4.6.0
-revision=4
+version=4.7.0
+revision=1
 create_wrksrc=yes
 build_wrksrc=${pkgname}-${version}
 build_style=cmake
@@ -24,8 +24,8 @@ homepage="https://opencv.org"
 changelog="https://github.com/opencv/opencv/wiki/ChangeLog"
 distfiles="https://github.com/opencv/opencv/archive/${version}.tar.gz
  https://github.com/opencv/opencv_contrib/archive/${version}.tar.gz>contrib.tar.gz"
-checksum="1ec1cba65f9f20fe5a41fda1586e01c70ea0c9a6d7b67c9e13edf0cfe2239277
- 1777d5fd2b59029cf537e5fd6f8aa68d707075822f90bde683fcde086f85f7a7"
+checksum="8df0079cdbe179748a18d44731af62a245a45ebf5085223dc03133954c662973
+ 42df840cf9055e59d0e22c249cfb19f04743e1bdad113d31b1573d3934d62584"
 patch_args="-Np1 -d ${build_wrksrc}"
 # tests hang indenfinitely, even with test data included
 make_check=no

From 7c9ebe823bab068540b4a8f2bbb17ba688ec63c6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 004/115] actiona: revbump for opencv-4.7.0

---
 srcpkgs/actiona/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/actiona/template b/srcpkgs/actiona/template
index cf5f0b7a2ae6..0d899311e6df 100644
--- a/srcpkgs/actiona/template
+++ b/srcpkgs/actiona/template
@@ -1,7 +1,7 @@
 # Template file for 'actiona'
 pkgname=actiona
 version=3.10.1
-revision=2
+revision=3
 build_style=qmake
 configure_args="PKGCONFIG_OPENCV=opencv4"
 hostmakedepends="pkg-config qt5-plugin-mysql qt5-qmake qt5-host-tools"

From 7bd59c9f859c657ba092cfb8b3fb4062189c7ca5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 005/115] qimgv: revbump for opencv-4.7.0

---
 srcpkgs/qimgv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qimgv/template b/srcpkgs/qimgv/template
index 7eb30db33992..dd341dfe1bfc 100644
--- a/srcpkgs/qimgv/template
+++ b/srcpkgs/qimgv/template
@@ -1,7 +1,7 @@
 # Template file for 'qimgv'
 pkgname=qimgv
 version=1.0.2
-revision=2
+revision=3
 build_style=cmake
 configure_args="$(vopt_if video -DVIDEO_SUPPORT=ON -DVIDEO_SUPPORT=OFF)
  $(vopt_if scale -DOPENCV_SUPPORT=ON -DOPENCV_SUPPORT=OFF)

From 44e87e4a3680401f24583e9c6233b3d07520230b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 006/115] retroshare: revbump for opencv-4.7.0

---
 srcpkgs/retroshare/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroshare/template b/srcpkgs/retroshare/template
index 8a0786c21a08..72023fa98b75 100644
--- a/srcpkgs/retroshare/template
+++ b/srcpkgs/retroshare/template
@@ -1,7 +1,7 @@
 # Template file for 'retroshare'
 pkgname=retroshare
 version=0.6.6
-revision=2
+revision=4
 build_style=qmake
 #XXX broadcast feature requires an ancient udp-discovery-cpp which either needs
 # to be fetched+patched (FTBFS) here or packaged :/

From 380c9484a3eb1cd2d7dd616fdd1ff8490904506a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 007/115] waifu2x-converter-cpp: revbump for opencv-4.7.0

---
 srcpkgs/waifu2x-converter-cpp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waifu2x-converter-cpp/template b/srcpkgs/waifu2x-converter-cpp/template
index 8c095d0d7bab..aa52d8c981a8 100644
--- a/srcpkgs/waifu2x-converter-cpp/template
+++ b/srcpkgs/waifu2x-converter-cpp/template
@@ -1,7 +1,7 @@
 # Template file for 'waifu2x-converter-cpp'
 pkgname=waifu2x-converter-cpp
 version=5.2.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DINSTALL_MODELS=ON"
 hostmakedepends="pkg-config"

From a781d872da2403855e75a6a65d9f566d5a93dc88 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:38 -0400
Subject: [PATCH 008/115] vlc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/vlc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/vlc/template b/srcpkgs/vlc/template
index 210762b0a7e2..855ca5238662 100644
--- a/srcpkgs/vlc/template
+++ b/srcpkgs/vlc/template
@@ -1,7 +1,7 @@
 # Template file for 'vlc'
 pkgname=vlc
 version=3.0.18
-revision=3
+revision=4
 build_style=gnu-configure
 configure_args="--disable-gme --disable-libtar --enable-jack
  --enable-live555 --disable-fluidsynth --enable-dvdread
@@ -25,7 +25,7 @@ lib32disabled=yes
 hostmakedepends="automake libtool pkg-config flex gettext libgcrypt-devel
  live555-devel gettext-devel $(vopt_if lua lua52) $(vopt_if chromecast protobuf)"
 makedepends="
- avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg-devel freefont-ttf
+ avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg4-devel freefont-ttf
  gnutls-devel jack-devel liba52-devel libass-devel libbluray-devel
  libcdio-devel libdca-devel libdvbpsi-devel libdvdnav-devel libmad-devel
  libmatroska-devel libmodplug-devel libmpcdec-devel libmpeg2-devel

From 0c9723c9a21b8cb614023d02ad43e26e5534e388 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:55 -0400
Subject: [PATCH 009/115] osg: revbump for ffmpeg4-4.4.3

---
 srcpkgs/osg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/osg/template b/srcpkgs/osg/template
index a9ebbd287933..755793f7e11b 100644
--- a/srcpkgs/osg/template
+++ b/srcpkgs/osg/template
@@ -8,7 +8,7 @@ build_helper="qemu"
 configure_args="-DLIB_POSTFIX="
 hostmakedepends="pkg-config xrandr"
 makedepends="MesaLib-devel gtkglext-devel libcurl-devel giflib-devel librsvg-devel
- jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg-devel xine-lib-devel
+ jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg4-devel xine-lib-devel
  SDL2-devel gst-plugins-base1-devel
  $(vopt_if openexr libopenexr-devel)
  $(vopt_if poppler poppler-glib-devel)

From 263a07c91a83c8e6e785d4632e51aa5fbd0ebcae Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:13 -0400
Subject: [PATCH 010/115] xine-lib: revbump for ffmpeg4-4.4.3

---
 srcpkgs/xine-lib/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/xine-lib/template b/srcpkgs/xine-lib/template
index f713eff49b07..ed6194c17d11 100644
--- a/srcpkgs/xine-lib/template
+++ b/srcpkgs/xine-lib/template
@@ -1,6 +1,6 @@
 # Template file for 'xine-lib'
 pkgname=xine-lib
-version=1.2.12
+version=1.2.13
 revision=1
 build_style=gnu-configure
 configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
@@ -8,7 +8,7 @@ configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
 hostmakedepends="automake gettext-devel libtool pkg-config perl"
 makedepends="
  zlib-devel alsa-lib-devel libxcb-devel libSM-devel libXext-devel libXv-devel
- libXvMC-devel liba52-devel libmad-devel ffmpeg-devel pulseaudio-devel
+ libXvMC-devel liba52-devel libmad-devel ffmpeg4-devel pulseaudio-devel
  jack-devel samba-devel libflac-devel libmodplug-devel libmpcdec-devel
  speex-devel libtheora-devel libvorbis-devel libdca-devel faad2-devel
  libcdio-devel libbluray-devel aalib-devel libcaca-devel libXinerama-devel
@@ -19,7 +19,7 @@ license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="http://www.xine-project.org"
 changelog="https://sourceforge.net/projects/xine/files/xine-lib/${version}/README.txt/view"
 distfiles="${SOURCEFORGE_SITE}/xine/${pkgname}-${version}.tar.xz"
-checksum=d606270468e1540c2a89c0d7f5fdf11e17ecc0c2698cc0bcb1065ff26abee098
+checksum=5f10d6d718a4a51c17ed1b32b031d4f9b80b061e8276535b2be31e5ac4b75e6f
 
 case "$XBPS_TARGET_MACHINE" in
 	i686-musl)

From 7f89814dccf9322ca9fee4294a2660fa2854c6ad Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 011/115] QMPlay2: revbump for ffmpeg-6.0

---
 srcpkgs/QMPlay2/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/QMPlay2/template b/srcpkgs/QMPlay2/template
index 850df9d418b9..8d2ce7a76156 100644
--- a/srcpkgs/QMPlay2/template
+++ b/srcpkgs/QMPlay2/template
@@ -1,7 +1,7 @@
 # Template file for 'QMPlay2'
 pkgname=QMPlay2
 version=23.06.17
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools"
 makedepends="alsa-lib-devel ffmpeg-devel libass-devel libcdio-devel libgme-devel

From 48ed3cb1186c3cf4f5d880d08007cc01fcb08135 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 012/115] alsa-plugins: revbump for ffmpeg-6.0

---
 srcpkgs/alsa-plugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/alsa-plugins/template b/srcpkgs/alsa-plugins/template
index 0bfa6d9fd264..a5708a7d82a8 100644
--- a/srcpkgs/alsa-plugins/template
+++ b/srcpkgs/alsa-plugins/template
@@ -1,7 +1,7 @@
 # Template file for 'alsa-plugins'
 pkgname=alsa-plugins
 version=1.2.7.1
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--disable-maemo-plugin"
 hostmakedepends="pkg-config"

From d9a8631d9892d355004bc2d622c2f3de77a50047 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 013/115] arcan: revbump for ffmpeg-6.0

---
 srcpkgs/arcan/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/arcan/template b/srcpkgs/arcan/template
index 7be9652eccf3..ccc7df11ceac 100644
--- a/srcpkgs/arcan/template
+++ b/srcpkgs/arcan/template
@@ -2,7 +2,7 @@
 # !! keep synced with: acfgfs aclip aloadimage
 pkgname=arcan
 version=0.6.2.1
-revision=1
+revision=2
 create_wrksrc=yes
 build_wrksrc=arcan/src
 build_style=cmake

From 02524e4a1cc9e9955ad6e91796e1a0baa276e90f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 014/115] attract: revbump for ffmpeg4-4.4.3

---
 srcpkgs/attract/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/attract/template b/srcpkgs/attract/template
index 26144e931a3c..e760bf0d18ae 100644
--- a/srcpkgs/attract/template
+++ b/srcpkgs/attract/template
@@ -1,12 +1,12 @@
 # Template file for 'attract'
 pkgname=attract
 version=2.6.2
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="VERBOSE=1"
 make_use_env=yes
 hostmakedepends="pkg-config"
-makedepends="SFML-devel ffmpeg-devel fontconfig-devel glu-devel libarchive-devel
+makedepends="SFML-devel ffmpeg4-devel fontconfig-devel glu-devel libarchive-devel
  libcurl-devel libjpeg-turbo-devel xine-lib rapidjson libXrandr-devel"
 depends="git"
 short_desc="Attract-Mode is a graphical frontend for emulators"

From 1581d471e870866ca00ebf2f3063f10701a6482e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 015/115] aubio: revbump for ffmpeg-6.0

---
 srcpkgs/aubio/patches/ffmpeg5.patch | 25 +++++++++++++++++++++++++
 srcpkgs/aubio/template              |  2 +-
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/aubio/patches/ffmpeg5.patch

diff --git a/srcpkgs/aubio/patches/ffmpeg5.patch b/srcpkgs/aubio/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..aace41a6e6d9
--- /dev/null
+++ b/srcpkgs/aubio/patches/ffmpeg5.patch
@@ -0,0 +1,25 @@
+From 8a05420e5dd8c7b8b2447f82dc919765876511b3 Mon Sep 17 00:00:00 2001
+From: Paul Brossier <piem@piem.org>
+Date: Tue, 25 Jan 2022 18:30:27 +0100
+Subject: [PATCH] [source_avcodec] define FF_API_LAVF_AVCTX for libavcodec >
+ 59, thx @berolinux (closes gh-353)
+
+---
+ src/io/source_avcodec.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/io/source_avcodec.c b/src/io/source_avcodec.c
+index e0ae93b5..1421bd9a 100644
+--- a/src/io/source_avcodec.c
++++ b/src/io/source_avcodec.c
+@@ -68,6 +68,10 @@
+ #define AUBIO_AVCODEC_MAX_BUFFER_SIZE AV_INPUT_BUFFER_MIN_SIZE
+ #endif
+ 
++#if LIBAVCODEC_VERSION_MAJOR >= 59
++#define FF_API_LAVF_AVCTX 1
++#endif
++
+ struct _aubio_source_avcodec_t {
+   uint_t hop_size;
+   uint_t samplerate;
diff --git a/srcpkgs/aubio/template b/srcpkgs/aubio/template
index ad1c4b256991..7d875cc02541 100644
--- a/srcpkgs/aubio/template
+++ b/srcpkgs/aubio/template
@@ -1,7 +1,7 @@
 # Template file for 'aubio'
 pkgname=aubio
 version=0.4.9
-revision=1
+revision=2
 build_style=waf3
 # XXX lash, pure and swig support.
 hostmakedepends="pkg-config txt2man"

From 8cff7f98da4571e8b4b5a64e3a783446ebdc4612 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 016/115] audacious-plugins: revbump for ffmpeg-6.0

---
 .../audacious-plugins/patches/ffmpeg5.patch   | 43 +++++++++++++++++++
 srcpkgs/audacious-plugins/template            |  2 +-
 2 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/audacious-plugins/patches/ffmpeg5.patch

diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg5.patch b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..4e5e34099d71
--- /dev/null
+++ b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
@@ -0,0 +1,43 @@
+commit 298aa371c56c2f52c25a33d9bdec4918b11cebdc
+Author: tibequadorian <tibequadorian@posteo.de>
+Date:   Sat Mar 19 18:40:12 2022 +0100
+
+    audacious-plugins: rebuild against ffmpeg-5.0
+
+diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+new file mode 100644
+index 0000000000..617c11215b
+--- /dev/null
++++ b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+@@ -0,0 +1,31 @@
++From f60beb400eeb1e4778bbfd738bc4a4ccef3de539 Mon Sep 17 00:00:00 2001
++From: John Lindgren <john@jlindgren.net>
++Date: Sat, 5 Mar 2022 12:05:34 -0500
++Subject: [PATCH] Fix build with FFmpeg 5.0
++
++---
++ src/ffaudio/ffaudio-core.cc | 4 ++--
++ 1 file changed, 2 insertions(+), 2 deletions(-)
++
++diff --git a/src/ffaudio/ffaudio-core.cc b/src/ffaudio/ffaudio-core.cc
++index 16dc63e3a..a2b95fd6c 100644
++--- a/src/ffaudio/ffaudio-core.cc
+++++ b/src/ffaudio/ffaudio-core.cc
++@@ -274,7 +274,7 @@ static AVInputFormat * get_format_by_content (const char * name, VFSFile & file)
++         AVProbeData d = {name, buf, filled};
++         score = target;
++ 
++-        f = av_probe_input_format2 (& d, true, & score);
+++        f = (AVInputFormat *) av_probe_input_format2 (& d, true, & score);
++         if (f)
++             break;
++ 
++@@ -347,7 +347,7 @@ static bool find_codec (AVFormatContext * c, CodecInfo * cinfo)
++ #endif
++         if (stream && stream->codecpar && stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
++         {
++-            AVCodec * codec = avcodec_find_decoder (stream->codecpar->codec_id);
+++            AVCodec * codec = (AVCodec *) avcodec_find_decoder (stream->codecpar->codec_id);
++ 
++             if (codec)
++             {
diff --git a/srcpkgs/audacious-plugins/template b/srcpkgs/audacious-plugins/template
index 88cbc1671fc6..beebfae59ed4 100644
--- a/srcpkgs/audacious-plugins/template
+++ b/srcpkgs/audacious-plugins/template
@@ -2,7 +2,7 @@
 #Keep in sync with audacious!
 pkgname=audacious-plugins
 version=4.3.1
-revision=1
+revision=2
 build_style=meson
 configure_args="$(vopt_bool gtk3 gtk) $(vopt_bool gtk3)
  $(vopt_bool qt) $(vopt_bool qt qt6)"

From d46b9995a37fc983e0ed30bd01f428e5c22111f5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 017/115] audacity: revbump for ffmpeg4-4.4.3

---
 srcpkgs/audacity/template | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/audacity/template b/srcpkgs/audacity/template
index d509c0a89407..11e20255685b 100644
--- a/srcpkgs/audacity/template
+++ b/srcpkgs/audacity/template
@@ -1,7 +1,7 @@
 # Template file for 'audacity'
 pkgname=audacity
 version=2.4.1
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--with-ffmpeg=system --with-libsndfile=system --with-expat=system
  --with-libsoxr=system --with-lame=system --with-lv2=system ac_cv_path_WX_CONFIG=wx-config-gtk3"
@@ -9,7 +9,7 @@ hostmakedepends="pkg-config cmake gettext libtool m4 which"
 makedepends="jack-devel wxWidgets-gtk3-devel gtk+3-devel
  libmad-devel soundtouch-devel libsoxr-devel
  vamp-plugin-sdk-devel lame-devel libid3tag-devel libflac-devel
- ffmpeg-devel twolame-devel serd-devel lv2 lilv-devel suil-devel"
+ ffmpeg4-devel twolame-devel serd-devel lv2 lilv-devel suil-devel"
 depends="desktop-file-utils hicolor-icon-theme"
 short_desc="Graphical cross-platform audio editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
@@ -33,5 +33,4 @@ post_install() {
 	vcopy plug-ins /usr/share/audacity
 
 	rm ${DESTDIR}/usr/share/doc/audacity/LICENSE.txt
-	vlicense LICENSE.txt LICENSE
 }

From 8b8b1b694ffb1f6cf7f821c67422f2d3da09509c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 018/115] avidemux: revbump for ffmpeg-6.0

---
 srcpkgs/avidemux/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/avidemux/template b/srcpkgs/avidemux/template
index 253a0243e225..557285982d2b 100644
--- a/srcpkgs/avidemux/template
+++ b/srcpkgs/avidemux/template
@@ -1,7 +1,7 @@
 # Template file for 'avidemux'
 pkgname=avidemux
 version=2.8.0
-revision=2
+revision=3
 # Can't be compiled for aarch64, arm* or mips*
 archs="x86_64* i686*"
 hostmakedepends="cmake pkg-config qt5-host-tools qt5-devel tar yasm"

From 0aeca042a10f3a524aa17a202b647265f90ceb09 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 019/115] baresip: revbump for ffmpeg-6.0

---
 srcpkgs/baresip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/baresip/template b/srcpkgs/baresip/template
index f1bd1817048b..b21e22334316 100644
--- a/srcpkgs/baresip/template
+++ b/srcpkgs/baresip/template
@@ -1,7 +1,7 @@
 # Template file for 'baresip'
 pkgname=baresip
 version=2.10.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config glib-devel"
 makedepends="libgsm-devel libpng-devel openssl-devel libsndfile-devel

From 835b71ee6ce0cf93fb03699c4fb41492e43d2349 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 020/115] blender: revbump for ffmpeg-6.0

---
 srcpkgs/blender/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index 7a710ac0df49..0f72876d4d70 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -9,8 +9,8 @@ configure_args="-DWITH_INSTALL_PORTABLE=OFF -DWITH_PYTHON_INSTALL=OFF
  -DWITH_JACK=ON -DWITH_CODEC_FFMPEG=ON -DWITH_CODEC_SNDFILE=ON -DWITH_OPENMP=ON
  -DWITH_FFTW3=ON -DWITH_MOD_OCEANSIM=ON -DWITH_CYCLES_EMBREE=OFF -DWITH_OPENCOLORIO=ON
  -DWITH_IMAGE_OPENEXR=ON -DWITH_IMAGE_OPENJPEG=ON -DWITH_OPENSUBDIV=ON
- -DWITH_OPENCOLLADA=ON -DWITH_SYSTEM_GLEW=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
- -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_LIBDECOR=ON
+ -DWITH_OPENCOLLADA=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
+ -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_WAYLAND_LIBDECOR=ON
  -DWITH_BUILDINFO=OFF -DPYTHON_VERSION=${py3_ver} -DPYTHON_LIBPATH=/usr/lib
  -DPYTHON_LIBRARY=python${py3_ver}${py3_abiver} -DPYTHON_INCLUDE_DIRS=/${py3_inc}
  -DWITH_SYSTEM_LZO=ON -DWITH_SYSTEM_EIGEN3=ON -DWITH_SYSTEM_FREETYPE=ON"

From 1b03ffd13b13dde3f28a3e3681a65a9bdd5b98ed Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 021/115] cantata: revbump for ffmpeg-6.0

---
 srcpkgs/cantata/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cantata/template b/srcpkgs/cantata/template
index 4b417d80d5c2..8a90aaa4c07a 100644
--- a/srcpkgs/cantata/template
+++ b/srcpkgs/cantata/template
@@ -1,7 +1,7 @@
 # Template file for 'cantata'
 pkgname=cantata
 version=2.5.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools qt5-tools"
 makedepends="qt5-devel qt5-tools-devel qt5-svg-devel qt5-xmlpatterns-devel

From a5e4e7d1e70a1451642a865569363d1836ec3049 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 022/115] ccextractor: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ccextractor/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/ccextractor/template b/srcpkgs/ccextractor/template
index 9abcd82852b2..6eccad5885af 100644
--- a/srcpkgs/ccextractor/template
+++ b/srcpkgs/ccextractor/template
@@ -1,12 +1,12 @@
 # Template file for 'ccextractor'
 pkgname=ccextractor
 version=0.93
-revision=1
+revision=2
 build_wrksrc="linux"
 build_style=gnu-configure
 configure_args="--enable-ocr --enable-hardsubx"
 hostmakedepends="automake pkg-config"
-makedepends="leptonica-devel tesseract-ocr-devel ffmpeg-devel"
+makedepends="leptonica-devel tesseract-ocr-devel ffmpeg4-devel"
 short_desc="Extract subtitles from video streams"
 maintainer="newbluemoon <blaumolch@mailbox.org>"
 license="GPL-2.0-or-later"

From f592664181efbd521cdd5ebe81e34b9301ebed82 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 023/115] chromaprint: revbump for ffmpeg-6.0

---
 srcpkgs/chromaprint/patches/ffmpeg5.patch | 569 ++++++++++++++++++++++
 srcpkgs/chromaprint/template              |   2 +-
 2 files changed, 570 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromaprint/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromaprint/patches/ffmpeg5.patch b/srcpkgs/chromaprint/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..a9fd307a23c8
--- /dev/null
+++ b/srcpkgs/chromaprint/patches/ffmpeg5.patch
@@ -0,0 +1,569 @@
+From 8ccad6937177b1b92e40ab8f4447ea27bac009a7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= <lalinsky@gmail.com>
+Date: Fri, 4 Nov 2022 21:47:38 +0100
+Subject: [PATCH] Use FFmpeg 5.x (#120)
+
+* Use FFmpeg 5.1.2 for CI builds
+
+* Build on Ubuntu 20.04
+
+* Upgrade code to FFmpeg 5.x APIs
+
+* Only set FFmpeg include dirs if building tools
+
+* No longer needed
+
+* Use ubuntu 20.04
+---
+ .github/workflows/build.yml                   |   6 +-
+ CMakeLists.txt                                |  16 --
+ package/build.sh                              |   4 +-
+ src/audio/ffmpeg_audio_processor.h            |   2 -
+ src/audio/ffmpeg_audio_processor_avresample.h |  72 -------
+ src/audio/ffmpeg_audio_processor_swresample.h |  18 +-
+ src/audio/ffmpeg_audio_reader.h               | 197 +++++++++---------
+ tests/CMakeLists.txt                          |   6 +
+ 8 files changed, 122 insertions(+), 199 deletions(-)
+ delete mode 100644 src/audio/ffmpeg_audio_processor_avresample.h
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index f8d6a32..4da2405 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -84,9 +84,6 @@ find_package(FFmpeg)
+ if(FFMPEG_LIBRARIES)
+ 	cmake_push_check_state(RESET)
+ 	set(CMAKE_REQUIRED_LIBRARIES ${FFMPEG_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -lm)
+-	check_function_exists(av_packet_unref HAVE_AV_PACKET_UNREF)
+-	check_function_exists(av_frame_alloc HAVE_AV_FRAME_ALLOC)
+-	check_function_exists(av_frame_free HAVE_AV_FRAME_FREE)
+ 	cmake_pop_check_state()
+ endif()
+
+@@ -163,14 +160,11 @@ message(STATUS "Using ${FFT_LIB} for FFT calculations")
+ if(NOT AUDIO_PROCESSOR_LIB)
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+ 		set(AUDIO_PROCESSOR_LIB "swresample")
+-	elseif(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(AUDIO_PROCESSOR_LIB "avresample")
+ 	endif()
+ endif()
+
+ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE OFF)
+ 		set(USE_SWRESAMPLE ON)
+ 		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBSWRESAMPLE_LIBRARIES})
+ 		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBSWRESAMPLE_INCLUDE_DIRS})
+@@ -178,16 +172,6 @@ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+ 	endif()
+ 	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+-elseif(AUDIO_PROCESSOR_LIB STREQUAL "avresample")
+-	if(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE ON)
+-		set(USE_SWRESAMPLE OFF)
+-		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBAVRESAMPLE_LIBRARIES})
+-		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBAVRESAMPLE_INCLUDE_DIRS})
+-	else()
+-		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+-	endif()
+-	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+ else()
+ 	message(STATUS "Building without audio conversion support, please install FFmpeg with libswresample")
+ endif()
+diff --git a/package/build.sh b/package/build.sh
+index da631ae..b41d36e 100755
+--- a/package/build.sh
++++ b/package/build.sh
+@@ -7,8 +7,8 @@ set -eux
+
+ BASE_DIR=$(cd $(dirname $0)/.. && pwd)
+
+-FFMPEG_VERSION=4.4.1
+-FFMPEG_BUILD_TAG=v4.4.1-1
++FFMPEG_VERSION=5.1.2
++FFMPEG_BUILD_TAG=v${FFMPEG_VERSION}-1
+
+ TMP_BUILD_DIR=$BASE_DIR/$(mktemp -d build.XXXXXXXX)
+ trap 'rm -rf $TMP_BUILD_DIR' EXIT
+diff --git a/src/audio/ffmpeg_audio_processor.h b/src/audio/ffmpeg_audio_processor.h
+index 7628fc7..39f4f6d 100644
+--- a/src/audio/ffmpeg_audio_processor.h
++++ b/src/audio/ffmpeg_audio_processor.h
+@@ -10,8 +10,6 @@
+
+ #if defined(USE_SWRESAMPLE)
+ #include "audio/ffmpeg_audio_processor_swresample.h"
+-#elif defined(USE_AVRESAMPLE)
+-#include "audio/ffmpeg_audio_processor_avresample.h"
+ #else
+ #error "no audio processing library"
+ #endif
+diff --git a/src/audio/ffmpeg_audio_processor_avresample.h b/src/audio/ffmpeg_audio_processor_avresample.h
+deleted file mode 100644
+index bd85f92..0000000
+--- a/src/audio/ffmpeg_audio_processor_avresample.h
++++ /dev/null
+@@ -1,72 +0,0 @@
+-// Copyright (C) 2016  Lukas Lalinsky
+-// Distributed under the MIT license, see the LICENSE file for details.
+-
+-#ifndef CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-#define CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-
+-extern "C" {
+-#include <libavresample/avresample.h>
+-}
+-
+-namespace chromaprint {
+-
+-class FFmpegAudioProcessor {
+-public:
+-	FFmpegAudioProcessor() {
+-		m_resample_ctx = avresample_alloc_context();
+-	}
+-
+-	~FFmpegAudioProcessor() {
+-		avresample_free(&m_resample_ctx);
+-	}
+-
+-	void SetCompatibleMode() {
+-		av_opt_set_int(m_resample_ctx, "filter_size", 16, 0);
+-		av_opt_set_int(m_resample_ctx, "phase_shift", 8, 0);
+-		av_opt_set_int(m_resample_ctx, "linear_interp", 1, 0);
+-		av_opt_set_double(m_resample_ctx, "cutoff", 0.8, 0);
+-	}
+-
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "in_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_rate", sample_rate, 0);
+-	}
+-
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "out_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_rate, 0);
+-	}
+-
+-	int Init() {
+-		return avresample_open(m_resample_ctx);
+-	}
+-
+-	int Convert(uint8_t **out, int out_count, const uint8_t **in, int in_count) {
+-		return avresample_convert(m_resample_ctx, out, 0, out_count, (uint8_t **) in, 0, in_count);
+-	}
+-
+-	int Flush(uint8_t **out, int out_count) {
+-		return avresample_read(m_resample_ctx, out, out_count);
+-	}
+-
+-private:
+-	AVAudioResampleContext *m_resample_ctx = nullptr;
+-};
+-
+-}; // namespace chromaprint
+-
+-#endif
+diff --git a/src/audio/ffmpeg_audio_processor_swresample.h b/src/audio/ffmpeg_audio_processor_swresample.h
+index b86266b..b1d4bea 100644
+--- a/src/audio/ffmpeg_audio_processor_swresample.h
++++ b/src/audio/ffmpeg_audio_processor_swresample.h
+@@ -28,30 +28,28 @@ public:
+ 		av_opt_set_double(m_swr_ctx, "cutoff", 0.8, 0);
+ 	}
+
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "icl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "ich", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetInputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "in_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "isf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "in_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "isr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "in_sample_rate", sample_rate, 0);
+ 	}
+
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "ocl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "och", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetOutputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "out_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "osf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "out_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "osr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "out_sample_rate", sample_rate, 0);
+ 	}
+
+ 	int Init() {
+diff --git a/src/audio/ffmpeg_audio_reader.h b/src/audio/ffmpeg_audio_reader.h
+index 5550164..1c6b346 100644
+--- a/src/audio/ffmpeg_audio_reader.h
++++ b/src/audio/ffmpeg_audio_reader.h
+@@ -62,7 +62,7 @@ public:
+ 	bool Read(const int16_t **data, size_t *size);
+
+ 	bool IsOpen() const { return m_opened; }
+-	bool IsFinished() const { return m_finished && !m_got_frame; }
++	bool IsFinished() const { return !m_has_more_packets && !m_has_more_frames; }
+
+ 	std::string GetError() const { return m_error; }
+ 	int GetErrorCode() const { return m_error_code; }
+@@ -74,20 +74,19 @@ private:
+ 	uint8_t *m_convert_buffer[1] = { nullptr };
+ 	int m_convert_buffer_nb_samples = 0;
+
+-	AVInputFormat *m_input_fmt = nullptr;
++	const AVInputFormat *m_input_fmt = nullptr;
+ 	AVDictionary *m_input_opts = nullptr;
+
+ 	AVFormatContext *m_format_ctx = nullptr;
+ 	AVCodecContext *m_codec_ctx = nullptr;
+-	AVFrame *m_frame = nullptr;
+ 	int m_stream_index = -1;
+ 	std::string m_error;
+ 	int m_error_code = 0;
+-	bool m_finished = false;
+ 	bool m_opened = false;
+-	int m_got_frame = 0;
+-	AVPacket m_packet;
+-	AVPacket m_packet0;
++	bool m_has_more_packets = true;
++	bool m_has_more_frames = true;
++	AVPacket *m_packet = nullptr;
++	AVFrame *m_frame = nullptr;
+
+ 	int m_output_sample_rate = 0;
+ 	int m_output_channels = 0;
+@@ -98,19 +97,12 @@ private:
+
+ inline FFmpegAudioReader::FFmpegAudioReader() {
+ 	av_log_set_level(AV_LOG_QUIET);
+-
+-	av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
+ }
+
+ inline FFmpegAudioReader::~FFmpegAudioReader() {
+ 	Close();
+ 	av_dict_free(&m_input_opts);
+ 	av_freep(&m_convert_buffer[0]);
+-	av_packet_unref(&m_packet0);
+ }
+
+ inline bool FFmpegAudioReader::SetInputFormat(const char *name) {
+@@ -135,11 +127,10 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ 	Close();
+
+-    av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
++	m_packet = av_packet_alloc();
++	if (!m_packet) {
++		return false;
++	}
+
+ 	ret = avformat_open_input(&m_format_ctx, file_name.c_str(), m_input_fmt, &m_input_opts);
+ 	if (ret < 0) {
+@@ -153,26 +144,31 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		return false;
+ 	}
+
+-	AVCodec *codec;
++	const AVCodec *codec;
+ 	ret = av_find_best_stream(m_format_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &codec, 0);
+ 	if (ret < 0) {
+ 		SetError("Could not find any audio stream in the file", ret);
+ 		return false;
+ 	}
+ 	m_stream_index = ret;
++	auto stream = m_format_ctx->streams[m_stream_index];
+
+-	m_codec_ctx = m_format_ctx->streams[m_stream_index]->codec;
++	m_codec_ctx = avcodec_alloc_context3(codec);
+ 	m_codec_ctx->request_sample_fmt = AV_SAMPLE_FMT_S16;
+
++	ret = avcodec_parameters_to_context(m_codec_ctx, stream->codecpar);
++	if (ret < 0) {
++		SetError("Could not copy the stream parameters", ret);
++		return false;
++	}
++
+ 	ret = avcodec_open2(m_codec_ctx, codec, nullptr);
+ 	if (ret < 0) {
+ 		SetError("Could not open the codec", ret);
+ 		return false;
+ 	}
+
+-	if (!m_codec_ctx->channel_layout) {
+-		m_codec_ctx->channel_layout = av_get_default_channel_layout(m_codec_ctx->channels);
+-	}
++	av_dump_format(m_format_ctx, 0, "foo", 0);
+
+ 	m_frame = av_frame_alloc();
+ 	if (!m_frame) {
+@@ -183,19 +179,23 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		m_output_sample_rate = m_codec_ctx->sample_rate;
+ 	}
+
+-	if (!m_output_channels) {
+-		m_output_channels = m_codec_ctx->channels;
++	AVChannelLayout output_channel_layout;
++	if (m_output_channels) {
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
++	} else {
++		m_output_channels = m_codec_ctx->ch_layout.nb_channels;
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
+ 	}
+
+-	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
++	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->ch_layout.nb_channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
+ 		m_converter.reset(new FFmpegAudioProcessor());
+ 		m_converter->SetCompatibleMode();
+ 		m_converter->SetInputSampleFormat(m_codec_ctx->sample_fmt);
+ 		m_converter->SetInputSampleRate(m_codec_ctx->sample_rate);
+-		m_converter->SetInputChannelLayout(m_codec_ctx->channel_layout);
++		m_converter->SetInputChannelLayout(&(m_codec_ctx->ch_layout));
+ 		m_converter->SetOutputSampleFormat(AV_SAMPLE_FMT_S16);
+ 		m_converter->SetOutputSampleRate(m_output_sample_rate);
+-		m_converter->SetOutputChannelLayout(av_get_default_channel_layout(m_output_channels));
++		m_converter->SetOutputChannelLayout(&output_channel_layout);
+ 		auto ret = m_converter->Init();
+ 		if (ret != 0) {
+ 			SetError("Could not create an audio converter instance", ret);
+@@ -203,10 +203,11 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		}
+ 	}
+
++	av_channel_layout_uninit(&output_channel_layout);
++
+ 	m_opened = true;
+-	m_finished = false;
+-	m_got_frame = 0;
+-	m_nb_packets = 0;
++	m_has_more_packets = true;
++	m_has_more_frames = true;
+ 	m_decode_error = 0;
+
+ 	return true;
+@@ -214,6 +215,7 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ inline void FFmpegAudioReader::Close() {
+ 	av_frame_free(&m_frame);
++	av_packet_free(&m_packet);
+
+ 	m_stream_index = -1;
+
+@@ -252,91 +254,98 @@ inline bool FFmpegAudioReader::Read(const int16_t **data, size_t *size) {
+ 		return false;
+ 	}
+
++	*data = nullptr;
++	*size = 0;
++
+ 	int ret;
++	bool needs_packet = false;
+ 	while (true) {
+-		while (m_packet.size <= 0) {
+-			av_packet_unref(&m_packet0);
+-			av_init_packet(&m_packet);
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			ret = av_read_frame(m_format_ctx, &m_packet);
++		while (needs_packet && m_packet->size == 0) {
++			ret = av_read_frame(m_format_ctx, m_packet);
+ 			if (ret < 0) {
+ 				if (ret == AVERROR_EOF) {
+-					m_finished = true;
++					needs_packet = false;
++					m_has_more_packets = false;
+ 					break;
+-				} else {
++				}
++				SetError("Error reading from the audio source", ret);
++				return false;
++			}
++			if (m_packet->stream_index == m_stream_index) {
++				needs_packet = false;
++			} else {
++				av_packet_unref(m_packet);
++			}
++		}
++
++		if (m_packet->size != 0) {
++			ret = avcodec_send_packet(m_codec_ctx, m_packet);
++			if (ret < 0) {
++				if (ret != AVERROR(EAGAIN)) {
+ 					SetError("Error reading from the audio source", ret);
+ 					return false;
+ 				}
+-			}
+-			m_packet0 = m_packet;
+-			if (m_packet.stream_index != m_stream_index) {
+-				m_packet.data = nullptr;
+-				m_packet.size = 0;
+ 			} else {
+-				m_nb_packets++;
++				av_packet_unref(m_packet);
+ 			}
+ 		}
+
+-		ret = avcodec_decode_audio4(m_codec_ctx, m_frame, &m_got_frame, &m_packet);
++		ret = avcodec_receive_frame(m_codec_ctx, m_frame);
+ 		if (ret < 0) {
+-			if (m_decode_error) {
+-				SetError("Error decoding audio frame", m_decode_error);
+-				return false;
++			if (ret == AVERROR_EOF) {
++				m_has_more_frames = false;
++			} else if (ret == AVERROR(EAGAIN)) {
++				if (m_has_more_packets) {
++					needs_packet = true;
++					continue;
++				} else {
++					m_has_more_frames = false;
++				}
+ 			}
+-			m_decode_error = ret;
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			continue;
++			SetError("Error decoding the audio source", ret);
++			return false;
+ 		}
+
+-		break;
+-	}
+-
+-	m_decode_error = 0;
+-
+-	const int decoded = std::min(ret, m_packet.size);
+-	m_packet.data += decoded;
+-	m_packet.size -= decoded;
+-
+-	if (m_got_frame) {
+-		if (m_converter) {
+-			if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
+-				int linsize;
+-				av_freep(&m_convert_buffer[0]);
+-				m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
+-				ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
+-				if (ret < 0) {
+-					SetError("Couldn't allocate audio converter buffer", ret);
++		if (m_frame->nb_samples > 0) {
++			if (m_converter) {
++				if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
++					int linsize;
++					av_freep(&m_convert_buffer[0]);
++					m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
++					ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->ch_layout.nb_channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
++					if (ret < 0) {
++						SetError("Couldn't allocate audio converter buffer", ret);
++						return false;
++					}
++				}
++				auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
++				if (nb_samples < 0) {
++					SetError("Couldn't convert audio", ret);
+ 					return false;
+ 				}
+-			}
+-			auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			}
+-			*data = (const int16_t *) m_convert_buffer[0];
+-			*size = nb_samples;
+-		} else {
+-			*data = (const int16_t *) m_frame->data[0];
+-			*size = m_frame->nb_samples;
+-		}
+-	} else {
+-		if (m_finished && m_converter) {
+-			auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			} else if (nb_samples > 0) {
+-				m_got_frame = 1;
+ 				*data = (const int16_t *) m_convert_buffer[0];
+ 				*size = nb_samples;
++			} else {
++				*data = (const int16_t *) m_frame->data[0];
++				*size = m_frame->nb_samples;
++			}
++		} else {
++			if (m_converter) {
++				if (IsFinished()) {
++					auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
++					if (nb_samples < 0) {
++						SetError("Couldn't convert audio", ret);
++						return false;
++					} else if (nb_samples > 0) {
++						*data = (const int16_t *) m_convert_buffer[0];
++						*size = nb_samples;
++					}
++				}
+ 			}
+ 		}
+-	}
+
+-	return true;
++		return true;
++	}
+ }
+
+ inline void FFmpegAudioReader::SetError(const char *message, int errnum) {
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index a2b517b..123e643 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -38,6 +38,12 @@ set(SRCS
+
+ if(BUILD_TOOLS)
+ 	set(SRCS ${SRCS} ../src/audio/ffmpeg_audio_reader_test.cpp)
++    include_directories(
++        ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}
++        ${AUDIO_PROCESSOR_INCLUDE_DIRS}
++    )
+ 	link_libraries(fpcalc_libs)
+ endif()
+
+-- 
+2.38.1
+
+
diff --git a/srcpkgs/chromaprint/template b/srcpkgs/chromaprint/template
index 7ef7838949f3..1f7bbc70a22c 100644
--- a/srcpkgs/chromaprint/template
+++ b/srcpkgs/chromaprint/template
@@ -1,7 +1,7 @@
 # Template file for 'chromaprint'
 pkgname=chromaprint
 version=1.5.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DBUILD_TOOLS=ON"
 make_check_target="check"

From 81c74d4e3fbdde7a80d86c10b3e3859c21d85540 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 024/115] chromium: revbump for ffmpeg-6.0

---
 .../patches/chromium-93-ffmpeg-4.4.patch      | 36 --------------
 srcpkgs/chromium/patches/ffmpeg5.patch        | 47 +++++++++++++++++++
 srcpkgs/chromium/template                     |  2 +-
 3 files changed, 48 insertions(+), 37 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch
 create mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch b/srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch
deleted file mode 100644
index f0ec736f98bc..000000000000
--- a/srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch
+++ /dev/null
@@ -1,36 +0,0 @@
-diff --git a/media/filters/ffmpeg_demuxer.cc b/media/filters/ffmpeg_demuxer.cc
-index ac4713b07268..492a9a37d096 100644
---- a/media/filters/ffmpeg_demuxer.cc
-+++ b/media/filters/ffmpeg_demuxer.cc
-@@ -427,11 +427,11 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
-   scoped_refptr<DecoderBuffer> buffer;
- 
-   if (type() == DemuxerStream::TEXT) {
--    size_t id_size = 0;
-+    int id_size = 0;
-     uint8_t* id_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
- 
--    size_t settings_size = 0;
-+    int settings_size = 0;
-     uint8_t* settings_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
- 
-@@ -443,7 +443,7 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
-     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
-                                      side_data.data(), side_data.size());
-   } else {
--    size_t side_data_size = 0;
-+    int side_data_size = 0;
-     uint8_t* side_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
- 
-@@ -504,7 +504,7 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
-                                        packet->size - data_offset);
-     }
- 
--    size_t skip_samples_size = 0;
-+    int skip_samples_size = 0;
-     const uint32_t* skip_samples_ptr =
-         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
-             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..24e2da38e34c
--- /dev/null
+++ b/srcpkgs/chromium/patches/ffmpeg5.patch
@@ -0,0 +1,47 @@
+--- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
++++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
+@@ -92,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+-  if (stream->start_time != kNoFFmpegTimestamp)
++  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -1597,7 +1585,7 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+@@ -1618,7 +1606,7 @@
+     if (stream->type() != DemuxerStream::VIDEO)
+       continue;
+ 
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+ 
+     if (!stream->IsEnabled())
diff --git a/srcpkgs/chromium/template b/srcpkgs/chromium/template
index b4a39dfd3815..c29453cd1f50 100644
--- a/srcpkgs/chromium/template
+++ b/srcpkgs/chromium/template
@@ -2,7 +2,7 @@
 pkgname=chromium
 # See https://chromiumdash.appspot.com/releases?platform=Linux for the latest version
 version=114.0.5735.106
-revision=1
+revision=2
 archs="i686* x86_64* aarch64* armv7l*"
 hostmakedepends="
  $(vopt_if clang "clang lld llvm15")

From edbec0d9ce3fb5a30c9e7c4467442a66a04215a9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 025/115] cmus: revbump for ffmpeg-6.0

---
 srcpkgs/cmus/patches/ffmpeg6.patch | 12 ++++++++++++
 srcpkgs/cmus/template              |  2 +-
 2 files changed, 13 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/cmus/patches/ffmpeg6.patch

diff --git a/srcpkgs/cmus/patches/ffmpeg6.patch b/srcpkgs/cmus/patches/ffmpeg6.patch
new file mode 100644
index 000000000000..ffa95ab81110
--- /dev/null
+++ b/srcpkgs/cmus/patches/ffmpeg6.patch
@@ -0,0 +1,12 @@
+--- a/ip/ffmpeg.c
++++ b/ip/ffmpeg.c
+@@ -202,9 +202,6 @@ static int ffmpeg_open(struct input_plugin_data *ip_data)
+ 			break;
+ 		}
+ 
+-		if (codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+-			cc->flags |= AV_CODEC_FLAG_TRUNCATED;
+-
+ 		if (avcodec_open2(cc, codec, NULL) < 0) {
+ 			d_print("could not open codec: %d, %s\n", cc->codec_id, avcodec_get_name(cc->codec_id));
+ 			err = -IP_ERROR_UNSUPPORTED_FILE_TYPE;
diff --git a/srcpkgs/cmus/template b/srcpkgs/cmus/template
index 0fcb424ce336..05b77d0fecae 100644
--- a/srcpkgs/cmus/template
+++ b/srcpkgs/cmus/template
@@ -1,7 +1,7 @@
 # Template file for 'cmus'
 pkgname=cmus
 version=2.10.0
-revision=1
+revision=2
 build_style=configure
 configure_args="prefix=/usr LD=$CC"
 hostmakedepends="pkg-config"

From d89794eb4e4b47a577f903feab16bffe8505bb52 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 026/115] cyanrip: revbump for ffmpeg-6.0

---
 srcpkgs/cyanrip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cyanrip/template b/srcpkgs/cyanrip/template
index 9796e3461601..5db30e020d17 100644
--- a/srcpkgs/cyanrip/template
+++ b/srcpkgs/cyanrip/template
@@ -1,7 +1,7 @@
 # Template file for 'cyanrip'
 pkgname=cyanrip
 version=0.9.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config"
 makedepends="ffmpeg-devel libcdio-devel libcdio-paranoia-devel libcurl-devel libmusicbrainz5-devel"

From e087c18e73c42973ce9e6f1a75a065424bb1b88f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 027/115] deadbeef: revbump for ffmpeg4-4.4.3

---
 srcpkgs/deadbeef/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/deadbeef/template b/srcpkgs/deadbeef/template
index b664bb1b9bd9..165b3c7b9cad 100644
--- a/srcpkgs/deadbeef/template
+++ b/srcpkgs/deadbeef/template
@@ -1,14 +1,14 @@
 # Template file for 'deadbeef'
 pkgname=deadbeef
 version=1.8.8
-revision=1
+revision=2
 create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-oss --disable-lfm --disable-notify --disable-gtk2"
 hostmakedepends="automake libtool gettext gettext-devel intltool pkg-config
  yasm clang glib-devel"
 makedepends="
- alsa-lib-devel dbus-devel faad2-devel ffmpeg-devel gtk+3-devel imlib2-devel
+ alsa-lib-devel dbus-devel faad2-devel ffmpeg4-devel gtk+3-devel imlib2-devel
  jansson-devel libcddb-devel libcdio-devel libcurl-devel libflac-devel
  libmad-devel libpng-devel libsamplerate-devel libsndfile-devel libvorbis-devel
  libzip-devel mpg123-devel opusfile-devel pulseaudio-devel wavpack-devel"

From b858fc2e87a63013b02dc8139982fdb0fd4b1523 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 028/115] dolphin-emu: revbump for ffmpeg-6.0

---
 srcpkgs/dolphin-emu/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/dolphin-emu/template b/srcpkgs/dolphin-emu/template
index b4c8b64368a4..070993aac31d 100644
--- a/srcpkgs/dolphin-emu/template
+++ b/srcpkgs/dolphin-emu/template
@@ -1,7 +1,7 @@
 # Template file for 'dolphin-emu'
 pkgname=dolphin-emu
 version=5.0.19368
-revision=1
+revision=2
 _dolphin_commit=dadbeb4bae7e7fa23af2b46e0add4143094dc107
 _mgba_commit=44e074a15e9651481f7f652ac006a7c9d58cbeb9
 _googletest_commit=be03d00f5f0cc3a997d1a368bee8a1fe93651f48

From 3297aadb422ba7f99c18fbd308db3359fe9a15c3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 029/115] droidcam-obs-plugin: revbump for ffmpeg-6.0

---
 srcpkgs/droidcam-obs-plugin/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam-obs-plugin/template b/srcpkgs/droidcam-obs-plugin/template
index fc9c9bf6b9d5..fb0480754df4 100644
--- a/srcpkgs/droidcam-obs-plugin/template
+++ b/srcpkgs/droidcam-obs-plugin/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam-obs-plugin'
 pkgname=droidcam-obs-plugin
 version=2.0.1
-revision=1
+revision=2
 build_style=gnu-makefile
 make_use_env=yes
 make_build_args="ALLOW_STATIC=no"

From 4a6413cac2c32ef60974e967514e0f2503199c1f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 030/115] droidcam: revbump for ffmpeg-6.0

---
 srcpkgs/droidcam/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam/template b/srcpkgs/droidcam/template
index 1c3f1b8b1fc6..32a9220b79a4 100644
--- a/srcpkgs/droidcam/template
+++ b/srcpkgs/droidcam/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam'
 pkgname=droidcam
 version=1.8.2
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="USBMUXD=-lusbmuxd-2.0 JPEG=-lturbojpeg"
 hostmakedepends="pkg-config"

From 742bdc88af0498afeb7df8d11d511499b40dbec2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 031/115] ffmpegthumbnailer: revbump for ffmpeg-6.0

---
 .../ffmpegthumbnailer/patches/ffmpeg6.patch   | 202 ++++++++++++++++++
 srcpkgs/ffmpegthumbnailer/template            |   6 +-
 2 files changed, 205 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch

diff --git a/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
new file mode 100644
index 000000000000..363ff35a2841
--- /dev/null
+++ b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
@@ -0,0 +1,202 @@
+--- a/libffmpegthumbnailer/moviedecoder.cpp	2017-11-21 14:06:57.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.cpp	2023-05-05 13:14:47.946560668 -0400
+@@ -41,11 +41,6 @@
+ namespace ffmpegthumbnailer
+ {
+ 
+-struct SilenceLogLevel
+-{
+-    SilenceLogLevel() { av_log_set_level(AV_LOG_QUIET); }
+-};
+-
+ MovieDecoder::MovieDecoder(AVFormatContext* pavContext)
+ : m_VideoStream(-1)
+ , m_pFormatContext(pavContext)
+@@ -70,8 +65,6 @@
+ 
+ void MovieDecoder::initialize(const string& filename, bool preferEmbeddedMetadata)
+ {
+-    av_register_all();
+-    avcodec_register_all();
+     avformat_network_init();
+ 
+     string inputFile = filename == "-" ? "pipe:" : filename;
+@@ -97,8 +90,7 @@
+ {
+     if (m_pVideoCodecContext)
+     {
+-        avcodec_close(m_pVideoCodecContext);
+-        m_pVideoCodecContext = nullptr;
++        avcodec_free_context(&m_pVideoCodecContext);
+     }
+ 
+     if ((!m_FormatContextWasGiven) && m_pFormatContext)
+@@ -152,10 +144,10 @@
+     for (unsigned int i = 0; i < m_pFormatContext->nb_streams; ++i)
+     {
+         AVStream *stream = m_pFormatContext->streams[i];
+-        auto ctx = m_pFormatContext->streams[i]->codec;
+-        if (ctx->codec_type == AVMEDIA_TYPE_VIDEO)
++        auto par = m_pFormatContext->streams[i]->codecpar;
++        if (par->codec_type == AVMEDIA_TYPE_VIDEO)
+         {
+-            if (!preferEmbeddedMetadata || !isStillImageCodec(ctx->codec_id))
++            if (!preferEmbeddedMetadata || !isStillImageCodec(par->codec_id))
+             {
+                 videoStreams.push_back(i);
+                 continue;
+@@ -203,8 +195,7 @@
+     }
+ 
+     m_pVideoStream = m_pFormatContext->streams[m_VideoStream];
+-    m_pVideoCodecContext = m_pVideoStream->codec;
+-    m_pVideoCodec = avcodec_find_decoder(m_pVideoCodecContext->codec_id);
++    m_pVideoCodec = avcodec_find_decoder(m_pVideoStream->codecpar->codec_id);
+ 
+     if (m_pVideoCodec == nullptr)
+     {
+@@ -214,6 +205,20 @@
+         throw logic_error("Video Codec not found");
+     }
+ 
++    m_pVideoCodecContext = avcodec_alloc_context3(m_pVideoCodec);
++
++    if (m_pVideoCodecContext == nullptr)
++    {
++        destroy();
++        throw logic_error("Could not allocate video codec context");
++    }
++
++    if (avcodec_parameters_to_context(m_pVideoCodecContext, m_pVideoStream->codecpar) < 0)
++    {
++        destroy();
++        throw logic_error("Could not configure video codec context");
++    }
++
+     m_pVideoCodecContext->workaround_bugs = 1;
+ 
+     if (avcodec_open2(m_pVideoCodecContext, m_pVideoCodec, nullptr) < 0)
+@@ -386,13 +391,6 @@
+ 
+ void MovieDecoder::initializeFilterGraph(const AVRational& timeBase, const std::string& size, bool maintainAspectRatio)
+ {
+-    static const AVPixelFormat pixelFormats[] = { AV_PIX_FMT_RGB24, AV_PIX_FMT_NONE };
+-
+-    auto del = [] (AVBufferSinkParams* p) { av_freep(p); };
+-    std::unique_ptr<AVBufferSinkParams, decltype(del)> buffersinkParams(av_buffersink_params_alloc(), del);
+-
+-    avfilter_register_all();
+-
+     m_pFilterGraph = avfilter_graph_alloc();
+     assert(m_pFilterGraph);
+ 
+@@ -404,10 +402,8 @@
+ 
+     checkRc(avfilter_graph_create_filter(&m_pFilterSource, avfilter_get_by_name("buffer"), "thumb_buffer", ss.str().c_str(), nullptr, m_pFilterGraph),
+             "Failed to create filter source");
+-    buffersinkParams->pixel_fmts = pixelFormats;
+-    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, buffersinkParams.get(), m_pFilterGraph),
++    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, nullptr, m_pFilterGraph),
+             "Failed to create filter sink");
+-    buffersinkParams.release();
+ 
+     AVFilterContext* yadifFilter = nullptr;
+     if (m_pFrame->interlaced_frame != 0)
+@@ -500,15 +496,15 @@
+     }
+ 
+     checkRc(av_seek_frame(m_pFormatContext, -1, timestamp, 0), "Seeking in video failed");
+-    avcodec_flush_buffers(m_pFormatContext->streams[m_VideoStream]->codec);
++    avcodec_flush_buffers(m_pVideoCodecContext);
+ 
+     int keyFrameAttempts = 0;
+-    bool gotFrame = 0;
++    bool gotFrame;
+ 
+     do
+     {
+         int count = 0;
+-        gotFrame = 0;
++        gotFrame = false;
+ 
+         while (!gotFrame && count < 20)
+         {
+@@ -552,17 +548,33 @@
+         return false;
+     }
+ 
+-    av_frame_unref(m_pFrame);
+-
+-    int frameFinished;
++    int rc = avcodec_send_packet(m_pVideoCodecContext, m_pPacket);
++    if(rc == AVERROR(EAGAIN))
++    {
++        rc = 0;
++    }
+ 
+-    int bytesDecoded = avcodec_decode_video2(m_pVideoCodecContext, m_pFrame, &frameFinished, m_pPacket);
+-    if (bytesDecoded < 0)
++    if(rc == AVERROR_EOF)
++    {
++        return false;
++    }
++    else if(rc < 0)
+     {
+-        throw logic_error("Failed to decode video frame: bytesDecoded < 0");
++        throw logic_error("Failed to decode video frame: avcodec_send_packet() < 0");
+     }
+ 
+-    return frameFinished > 0;
++    rc = avcodec_receive_frame(m_pVideoCodecContext, m_pFrame);
++    switch(rc)
++    {
++        case 0:
++            return true;
++
++        case AVERROR(EAGAIN):
++            return false;
++
++        default:
++            throw logic_error("Failed to decode video frame: avcodec_receive_frame() < 0");
++    }
+ }
+ 
+ bool MovieDecoder::getVideoPacket()
+@@ -570,8 +582,6 @@
+     bool framesAvailable = true;
+     bool frameDecoded = false;
+ 
+-    int attempts = 0;
+-
+     if (m_pPacket)
+     {
+         av_packet_unref(m_pPacket);
+@@ -580,6 +590,7 @@
+ 
+     m_pPacket = new AVPacket();
+ 
++
+     while (framesAvailable && !frameDecoded)
+     {
+         framesAvailable = av_read_frame(m_pFormatContext, m_pPacket) >= 0;
+@@ -644,7 +655,7 @@
+ 
+ int32_t MovieDecoder::getStreamRotation()
+ {
+-    int32_t* matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
++    auto matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
+     if (matrix)
+     {
+         auto angle = lround(av_display_rotation_get(matrix));
+
+--- a/libffmpegthumbnailer/moviedecoder.h	2017-11-12 04:23:38.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.h	2023-05-05 13:26:07.095529911 -0400
+@@ -78,7 +78,7 @@
+     int                     m_VideoStream;
+     AVFormatContext*        m_pFormatContext;
+     AVCodecContext*         m_pVideoCodecContext;
+-    AVCodec*                m_pVideoCodec;
++    const AVCodec*          m_pVideoCodec;
+     AVFilterGraph*          m_pFilterGraph;
+     AVFilterContext*        m_pFilterSource;
+     AVFilterContext*        m_pFilterSink;
diff --git a/srcpkgs/ffmpegthumbnailer/template b/srcpkgs/ffmpegthumbnailer/template
index 039eea7622b3..35d546018d12 100644
--- a/srcpkgs/ffmpegthumbnailer/template
+++ b/srcpkgs/ffmpegthumbnailer/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbnailer'
 pkgname=ffmpegthumbnailer
 version=2.2.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libpng-devel libjpeg-turbo-devel ffmpeg-devel"
@@ -9,8 +9,8 @@ depends="ffmpeg"
 short_desc="Lightweight video thumbnailer"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
-homepage="https://github.com/dirkvdb/${pkgname}"
-distfiles="${homepage}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
+homepage="https://github.com/dirkvdb"
+distfiles="${homepage}/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
 checksum=1cb24059c38223f657b300c84dd80491b7040d4b69471c4fea69be862bc99b5b
 
 post_install() {

From f9e5b9fdfd1522c9a28f70d8f33c66f5ae4fe8a9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 032/115] ffmpegthumbs: revbump for ffmpeg-6.0

---
 srcpkgs/ffmpegthumbs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ffmpegthumbs/template b/srcpkgs/ffmpegthumbs/template
index 5f0b9414dada..11b88193528f 100644
--- a/srcpkgs/ffmpegthumbs/template
+++ b/srcpkgs/ffmpegthumbs/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbs'
 pkgname=ffmpegthumbs
 version=22.12.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules kcoreaddons kconfig-devel
  pkg-config qt5-host-tools qt5-qmake gettext"

From 964bdf721f3dfcca1a5cc6e4b6b54d7defcb1637 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 033/115] ffms2: revbump for ffmpeg-6.0

---
 srcpkgs/ffms2/patches/ffmpeg5.patch | 424 ++++++++++++++++++++++++++++
 srcpkgs/ffms2/template              |   2 +-
 2 files changed, 425 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ffms2/patches/ffmpeg5.patch

diff --git a/srcpkgs/ffms2/patches/ffmpeg5.patch b/srcpkgs/ffms2/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..1479fabcafcb
--- /dev/null
+++ b/srcpkgs/ffms2/patches/ffmpeg5.patch
@@ -0,0 +1,424 @@
+From 45673149e9a2f5586855ad472e3059084eaa36b1 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:41:21 +0100
+Subject: [PATCH] Use auto for AVCodec
+
+The geniuses over at FFmpeg decided to constify this API, so old
+versions of the library will return AVCodec *, while new versions
+of the libary will return const AVCodec *, which, in C++, are not
+OK to convert between.
+
+Rather than use some macro hell in ffmscompat.h, we can work around
+this by using auto.
+
+Gross.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 2 +-
+ src/core/indexing.cpp    | 6 +++---
+ src/core/videosource.cpp | 2 +-
+ 3 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index e4ce97c..ac09666 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -469,7 +469,7 @@ void FFMS_AudioSource::OpenFile() {
+ 
+     LAVFOpenFile(SourceFile.c_str(), FormatContext, TrackNumber);
+ 
+-    AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
++    auto *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
+     if (Codec == nullptr)
+         throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+             "Audio codec not found");
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index e547c5a..59fb4e8 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -384,7 +384,7 @@ FFMS_TrackType FFMS_Indexer::GetTrackType(int Track) {
+ }
+ 
+ const char *FFMS_Indexer::GetTrackCodec(int Track) {
+-    AVCodec *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
++    auto *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
+     return codec ? codec->name : nullptr;
+ }
+ 
+@@ -402,7 +402,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             UseDTS);
+ 
+         if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            AVCodec *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (!VideoCodec) {
+                 FormatContext->streams[i]->discard = AVDISCARD_ALL;
+                 IndexMask.erase(i);
+@@ -433,7 +433,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 IndexMask.insert(i);
+             }
+         } else if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+-            AVCodec *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (AudioCodec == nullptr)
+                 throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_UNSUPPORTED,
+                     "Audio codec not found");
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index b889970..8956c22 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -171,7 +171,7 @@ FFMS_VideoSource::FFMS_VideoSource(const char *SourceFile, FFMS_Index &Index, in
+ 
+         LAVFOpenFile(SourceFile, FormatContext, VideoTrack);
+ 
+-        AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
++        auto *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
+         if (Codec == nullptr)
+             throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+                 "Video codec not found");
+-- 
+2.40.0
+
+From 96cbf38ea9381829a1314f432a2c60495dcefaad Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:12:41 +0100
+Subject: [PATCH] all: Update AVPacket API usage
+
+AVPackets must all be on the heap now, since it is no longer
+part of the libav* ABI.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 16 ++++++----
+ src/core/indexing.cpp    | 63 ++++++++++++++++++++++------------------
+ src/core/indexing.h      |  4 +--
+ src/core/utils.cpp       |  6 ----
+ src/core/utils.h         |  1 -
+ src/core/videosource.cpp | 30 ++++++++++---------
+ 6 files changed, 64 insertions(+), 56 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index 37cf9ae..e4ce97c 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -285,10 +285,15 @@ FFMS_AudioSource::AudioBlock *FFMS_AudioSource::CacheBlock(CacheIterator &pos) {
+ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     CurrentFrame = &Frames[PacketNumber];
+ 
+-    AVPacket Packet;
+-    if (!ReadPacket(&Packet))
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++    if (!ReadPacket(Packet)) {
++        av_packet_free(&Packet);
+         throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_UNKNOWN,
+             "ReadPacket unexpectedly failed to read a packet");
++    }
+ 
+     // ReadPacket may have changed the packet number
+     CurrentFrame = &Frames[PacketNumber];
+@@ -297,8 +302,9 @@ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     int NumberOfSamples = 0;
+     AudioBlock *CachedBlock = nullptr;
+     
+-    int Ret = avcodec_send_packet(CodecContext, &Packet);
+-    av_packet_unref(&Packet);
++    int Ret = avcodec_send_packet(CodecContext, Packet);
++    av_packet_unref(Packet);
++    av_packet_free(&Packet);
+ 
+     av_frame_unref(DecodeFrame);
+     Ret = avcodec_receive_frame(CodecContext, DecodeFrame);
+@@ -513,8 +519,6 @@ void FFMS_AudioSource::Seek() {
+ }
+ 
+ bool FFMS_AudioSource::ReadPacket(AVPacket *Packet) {
+-    InitNullPacket(*Packet);
+-
+     while (av_read_frame(FormatContext, Packet) >= 0) {
+         if (Packet->stream_index == TrackNumber) {
+             // Required because not all audio packets, especially in ogg, have a pts. Use the previous valid packet's pts instead.
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index 23fb95b..e547c5a 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -320,7 +320,7 @@ void FFMS_Indexer::CheckAudioProperties(int Track, AVCodecContext *Context) {
+     }
+ }
+ 
+-void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict,
++void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict,
+                                     int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct) {
+     if (VideoContext.Parser) {
+         uint8_t *OB;
+@@ -330,8 +330,8 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+         av_parser_parse2(VideoContext.Parser,
+             VideoContext.CodecContext,
+             &OB, &OBSize,
+-            pkt.data, pkt.size,
+-            pkt.pts, pkt.dts, pkt.pos);
++            pkt->data, pkt->size,
++            pkt->pts, pkt->dts, pkt->pos);
+ 
+         // H.264 (PAFF) and HEVC may have one field per packet, so we need to track
+         // when we have a full or half frame available, and mark one of them as
+@@ -351,15 +351,15 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+ 
+         *RepeatPict = VideoContext.Parser->repeat_pict;
+         *FrameType = VideoContext.Parser->pict_type;
+-        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt.flags & AV_PKT_FLAG_DISCARD));
++        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt->flags & AV_PKT_FLAG_DISCARD));
+     } else {
+-        *Invisible = !!(pkt.flags & AV_PKT_FLAG_DISCARD);
++        *Invisible = !!(pkt->flags & AV_PKT_FLAG_DISCARD);
+     }
+ 
+     if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP8)
+-        ParseVP8(pkt.data[0], Invisible, FrameType);
++        ParseVP8(pkt->data[0], Invisible, FrameType);
+     else if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP9)
+-        ParseVP9(pkt.data[0], Invisible, FrameType);
++        ParseVP9(pkt->data[0], Invisible, FrameType);
+ }
+ 
+ void FFMS_Indexer::Free() {
+@@ -458,32 +458,36 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+         }
+     }
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
+     std::vector<int64_t> LastValidTS(FormatContext->nb_streams, AV_NOPTS_VALUE);
+ 
+     int64_t filesize = avio_size(FormatContext->pb);
+     enum AVPictureStructure LastPicStruct = AV_PICTURE_STRUCTURE_UNKNOWN;
+-    while (av_read_frame(FormatContext, &Packet) >= 0) {
++    while (av_read_frame(FormatContext, Packet) >= 0) {
+         // Update progress
+         // FormatContext->pb can apparently be NULL when opening images.
+         if (IC && FormatContext->pb) {
+-            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate))
++            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate)) {
++                av_packet_free(&Packet);
+                 throw FFMS_Exception(FFMS_ERROR_CANCELLED, FFMS_ERROR_USER,
+                     "Cancelled by user");
++            }
+         }
+-        if (!IndexMask.count(Packet.stream_index)) {
+-            av_packet_unref(&Packet);
++        if (!IndexMask.count(Packet->stream_index)) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+-        int Track = Packet.stream_index;
++        int Track = Packet->stream_index;
+         FFMS_Track &TrackInfo = (*TrackIndices)[Track];
+-        bool KeyFrame = !!(Packet.flags & AV_PKT_FLAG_KEY);
++        bool KeyFrame = !!(Packet->flags & AV_PKT_FLAG_KEY);
+         ReadTS(Packet, LastValidTS[Track], (*TrackIndices)[Track].UseDTS);
+ 
+         if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            int64_t PTS = TrackInfo.UseDTS ? Packet.dts : Packet.pts;
++            int64_t PTS = TrackInfo.UseDTS ? Packet->dts : Packet->pts;
+             if (PTS == AV_NOPTS_VALUE) {
+                 // VPx alt-refs are output as packets which lack timestmps or durations, since
+                 // they are invisible. Currently, the timestamp mangling code in libavformat
+@@ -495,9 +499,11 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 // FFMS2 currently sorts packets by PTS, which will break decoding, otherwise.
+                 bool HasAltRefs = (FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP8 ||
+                                    FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP9);
+-                if (Packet.duration == 0 && !HasAltRefs)
++                if (Packet->duration == 0 && !HasAltRefs) {
++                    av_packet_free(&Packet);
+                     throw FFMS_Exception(FFMS_ERROR_INDEXING, FFMS_ERROR_PARSER,
+                         "Invalid packet pts, dts, and duration");
++                }
+ 
+                 if (TrackInfo.empty())
+                     PTS = 0;
+@@ -513,7 +519,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             ParseVideoPacket(AVContexts[Track], Packet, &RepeatPict, &FrameType, &Invisible, &LastPicStruct);
+ 
+             TrackInfo.AddVideoFrame(PTS, RepeatPict, KeyFrame,
+-                FrameType, Packet.pos, Invisible);
++                FrameType, Packet->pos, Invisible);
+         } else if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+             // For video seeking timestamps are used only if all packets have
+             // timestamps, while for audio they're used if any have timestamps,
+@@ -522,28 +528,29 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 TrackInfo.HasTS = true;
+ 
+             int64_t StartSample = AVContexts[Track].CurrentSample;
+-            uint32_t SampleCount = IndexAudioPacket(Track, &Packet, AVContexts[Track], *TrackIndices);
++            uint32_t SampleCount = IndexAudioPacket(Track, Packet, AVContexts[Track], *TrackIndices);
+             TrackInfo.SampleRate = AVContexts[Track].CodecContext->sample_rate;
+ 
+             TrackInfo.AddAudioFrame(LastValidTS[Track],
+-                StartSample, SampleCount, KeyFrame, Packet.pos, Packet.flags & AV_PKT_FLAG_DISCARD);
++                StartSample, SampleCount, KeyFrame, Packet->pos, Packet->flags & AV_PKT_FLAG_DISCARD);
+         }
+ 
+-        if (!(Packet.flags & AV_PKT_FLAG_DISCARD))
+-            TrackInfo.LastDuration = Packet.duration;
++        if (!(Packet->flags & AV_PKT_FLAG_DISCARD))
++            TrackInfo.LastDuration = Packet->duration;
+ 
+-        av_packet_unref(&Packet);
++        av_packet_unref(Packet);
+     }
++    av_packet_free(&Packet);
+ 
+     TrackIndices->Finalize(AVContexts, FormatContext->iformat->name);
+     return TrackIndices.release();
+ }
+ 
+-void FFMS_Indexer::ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS) {
+-    if (!UseDTS && Packet.pts != AV_NOPTS_VALUE)
+-        TS = Packet.pts;
++void FFMS_Indexer::ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS) {
++    if (!UseDTS && Packet->pts != AV_NOPTS_VALUE)
++        TS = Packet->pts;
+     if (TS == AV_NOPTS_VALUE)
+         UseDTS = true;
+-    if (UseDTS && Packet.dts != AV_NOPTS_VALUE)
+-        TS = Packet.dts;
++    if (UseDTS && Packet->dts != AV_NOPTS_VALUE)
++        TS = Packet->dts;
+ }
+diff --git a/src/core/indexing.h b/src/core/indexing.h
+index 3cfc3c3..5c06868 100644
+--- a/src/core/indexing.h
++++ b/src/core/indexing.h
+@@ -80,10 +80,10 @@ private:
+     int64_t Filesize;
+     uint8_t Digest[20];
+ 
+-    void ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS);
++    void ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS);
+     void CheckAudioProperties(int Track, AVCodecContext *Context);
+     uint32_t IndexAudioPacket(int Track, AVPacket *Packet, SharedAVContext &Context, FFMS_Index &TrackIndices);
+-    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
++    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
+     void Free();
+ public:
+     FFMS_Indexer(const char *Filename);
+diff --git a/src/core/utils.cpp b/src/core/utils.cpp
+index ce67533..8a2e997 100644
+--- a/src/core/utils.cpp
++++ b/src/core/utils.cpp
+@@ -62,12 +62,6 @@ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo) {
+     }
+ }
+ 
+-void InitNullPacket(AVPacket &pkt) {
+-    av_init_packet(&pkt);
+-    pkt.data = nullptr;
+-    pkt.size = 0;
+-}
+-
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames) {
+     AP.SampleFormat = static_cast<FFMS_SampleFormat>(av_get_packed_sample_fmt(CTX->sample_fmt));
+     AP.BitsPerSample = av_get_bytes_per_sample(CTX->sample_fmt) * 8;
+diff --git a/src/core/utils.h b/src/core/utils.h
+index 9819dc7..003ab79 100644
+--- a/src/core/utils.h
++++ b/src/core/utils.h
+@@ -58,7 +58,6 @@ std::unique_ptr<T> make_unique(Args&&... args) {
+ }
+ 
+ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo);
+-void InitNullPacket(AVPacket &pkt);
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames);
+ 
+ void LAVFOpenFile(const char *SourceFile, AVFormatContext *&FormatContext, int Track);
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index 06bd161..b889970 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -673,30 +673,34 @@ void FFMS_VideoSource::DecodeNextFrame(int64_t &AStartTime, int64_t &Pos) {
+     if (HasPendingDelayedFrames())
+         return;
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
+-
+-    while (ReadFrame(&Packet) >= 0) {
+-        if (Packet.stream_index != VideoTrack) {
+-            av_packet_unref(&Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++
++    while (ReadFrame(Packet) >= 0) {
++        if (Packet->stream_index != VideoTrack) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+         if (AStartTime < 0)
+-            AStartTime = Frames.UseDTS ? Packet.dts : Packet.pts;
++            AStartTime = Frames.UseDTS ? Packet->dts : Packet->pts;
+ 
+         if (Pos < 0)
+-            Pos = Packet.pos;
++            Pos = Packet->pos;
+ 
+-        bool FrameFinished = DecodePacket(&Packet);
+-        av_packet_unref(&Packet);
+-        if (FrameFinished)
++        bool FrameFinished = DecodePacket(Packet);
++        av_packet_unref(Packet);
++        if (FrameFinished) {
++            av_packet_free(&Packet);
+             return;
++        }
+     }
+ 
+     // Flush final frames
+-    InitNullPacket(Packet);
+-    DecodePacket(&Packet);
++    DecodePacket(Packet);
++    av_packet_free(&Packet);
+ }
+ 
+ bool FFMS_VideoSource::SeekTo(int n, int SeekOffset) {
+-- 
+2.40.0
+
+From bf9e03e9e08534c024e5a744a6437c4aac160201 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:20:47 +0100
+Subject: [PATCH 2/3] configure: Remove deprecated API use
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ configure.ac | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index b35ef80bc..d19714d0f 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -102,10 +102,10 @@ CFLAGS="$_CFLAGS $FFMPEG_CFLAGS"
+
+ AC_DEFUN([TEST_FFMPEG],
+          [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+-            #include <libavcodec/avcodec.h>
++            #include <libavformat/avformat.h>
+             #include <libswscale/swscale.h>
+             ]],[[
+-                avcodec_register_all();
++                avformat_network_init();
+                 swscale_version();
+             ]])], [eval $1=yes], [eval $1=no])
+         ])
+
diff --git a/srcpkgs/ffms2/template b/srcpkgs/ffms2/template
index 68e8a0c14bce..2acfadac44b3 100644
--- a/srcpkgs/ffms2/template
+++ b/srcpkgs/ffms2/template
@@ -1,7 +1,7 @@
 # Template file for 'ffms2'
 pkgname=ffms2
 version=2.40
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-shared --disable-static"
 hostmakedepends="pkg-config autoconf automake libtool"

From a1344cfb086f946702e6fc02825367f1e20656f0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 034/115] freerdp: revbump for ffmpeg-6.0

---
 .../freerdp/patches/ffmpeg6_aa2cb9aa.patch    | 42 +++++++++++++++++++
 srcpkgs/freerdp/template                      |  2 +-
 2 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch

diff --git a/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
new file mode 100644
index 000000000000..a4324da3a882
--- /dev/null
+++ b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
@@ -0,0 +1,42 @@
+From aa2cb9aa5ff5562433598ba168a466e0752bca0e Mon Sep 17 00:00:00 2001
+From: akallabeth <akallabeth@posteo.net>
+Date: Tue, 14 Feb 2023 07:48:54 +0100
+Subject: [PATCH] Fixed #8686: Update h264 to use new FFMPEG API
+
+---
+ channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c | 2 ++
+ libfreerdp/codec/h264_ffmpeg.c            | 2 ++
+ 2 files changed, 4 insertions(+)
+
+diff --git a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+index 339462d865f..beea80b7a1e 100644
+--- a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
++++ b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+@@ -239,8 +239,10 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYP
+ 		}
+ 	}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 	if (mdecoder->codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		mdecoder->codec_context->flags |= AV_CODEC_FLAG_TRUNCATED;
++#endif
+ 
+ 	return TRUE;
+ }
+diff --git a/libfreerdp/codec/h264_ffmpeg.c b/libfreerdp/codec/h264_ffmpeg.c
+index 8a23db2473c..896a333019b 100644
+--- a/libfreerdp/codec/h264_ffmpeg.c
++++ b/libfreerdp/codec/h264_ffmpeg.c
+@@ -615,10 +615,12 @@ static BOOL libavcodec_init(H264_CONTEXT* h264)
+ 			goto EXCEPTION;
+ 		}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 		if (sys->codecDecoder->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		{
+ 			sys->codecDecoderContext->flags |= AV_CODEC_FLAG_TRUNCATED;
+ 		}
++#endif
+ 
+ #ifdef WITH_VAAPI
+ 
diff --git a/srcpkgs/freerdp/template b/srcpkgs/freerdp/template
index 25e8aa9677f0..4d51c8189902 100644
--- a/srcpkgs/freerdp/template
+++ b/srcpkgs/freerdp/template
@@ -1,7 +1,7 @@
 # Template file for 'freerdp'
 pkgname=freerdp
 version=2.10.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_ALSA=ON -DWITH_CUPS=OFF -DWITH_FFMPEG=ON
  -DWITH_GSTREAMER_0_10=OFF -DWITH_GSTREAMER_1_0=OFF -DWITH_JPEG=ON

From 36129ef1da9bf8fe857299c4181bb3b6160dc5f1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 035/115] gerbera: revbump for ffmpeg-6.0

---
 srcpkgs/gerbera/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gerbera/template b/srcpkgs/gerbera/template
index ae14f35c767c..2dc0ac0ce03b 100644
--- a/srcpkgs/gerbera/template
+++ b/srcpkgs/gerbera/template
@@ -1,7 +1,7 @@
 # Template file for 'gerbera'
 pkgname=gerbera
 version=1.12.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_SYSTEMD=0 -DWITH_AVCODEC=1"
 hostmakedepends="pkg-config"

From 4eb2ef24f95ae5b28da6b1684197fde3d8958acb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 036/115] goldendict: revbump for ffmpeg-6.0

---
 srcpkgs/goldendict/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/goldendict/template b/srcpkgs/goldendict/template
index f4a05759f693..97f44347b03a 100644
--- a/srcpkgs/goldendict/template
+++ b/srcpkgs/goldendict/template
@@ -1,7 +1,7 @@
 # Template file for 'goldendict'
 pkgname=goldendict
 version=1.5.0
-revision=1
+revision=2
 build_style=qmake
 configure_args="CONFIG+=zim_support goldendict.pro"
 hostmakedepends="qt5-qmake pkg-config qt5-host-tools"
@@ -10,7 +10,7 @@ makedepends="tiff-devel qt5-devel libvorbis-devel zlib-devel
  qt5-webkit-devel lzo-devel bzip2-devel libao-devel qt5-svg-devel
  libeb-devel qt5-x11extras-devel ffmpeg-devel liblzma-devel
  qt5-multimedia-devel"
-short_desc="A feature-rich dictionary lookup program"
+short_desc="Feature-rich dictionary lookup program"
 maintainer="John <me@johnnynator.dev>"
 license="GPL-3.0-or-later"
 homepage="http://goldendict.org/"

From 9f630dfbabfa1a73334145be0244278274e8c656 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 037/115] gst-libav: revbump for ffmpeg-6.0

---
 srcpkgs/gst-libav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index 8c72fc3e97ee..04c39bff1489 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.22.2
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"

From 8251f82fac839ab063ce2766487c823705ca5cea Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 038/115] gst-plugins-bad1: revbump for ffmpeg-6.0

---
 srcpkgs/gst-plugins-bad1/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index 77bf79981c20..5c158724a6c7 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-plugins-bad1'
 pkgname=gst-plugins-bad1
 version=1.22.2
-revision=1
+revision=2
 build_helper="gir"
 build_style=meson
 configure_args="-Dpackage-origin=https://voidlinux.org -Ddoc=disabled

From 88a840c3a759636ff0f86e9d01360ac1c40f3ed1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 039/115] gst-rtsp-server: revbump for ffmpeg-6.0

---
 srcpkgs/gst-rtsp-server/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index 2f0c0c45ff82..980fd72cdd4c 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
 version=1.22.2
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="glib-devel gst-plugins-bad1-devel gobject-introspection

From d40493006c4a7ee9021c412ee29ca318dcb52688 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 040/115] guvcview: update to 2.0.8.

---
 srcpkgs/guvcview/patches/fix-include.patch | 10 ++++++++++
 srcpkgs/guvcview/template                  |  5 ++---
 2 files changed, 12 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/guvcview/patches/fix-include.patch

diff --git a/srcpkgs/guvcview/patches/fix-include.patch b/srcpkgs/guvcview/patches/fix-include.patch
new file mode 100644
index 000000000000..503c2af3b78c
--- /dev/null
+++ b/srcpkgs/guvcview/patches/fix-include.patch
@@ -0,0 +1,10 @@
+--- a/guvcview/guvcview.c
++++ b/guvcview/guvcview.c
+@@ -28,6 +28,7 @@
+ #include <sys/stat.h>
+ #include <sys/resource.h>
+ #include <errno.h>
++#include <locale.h>
+ 
+ #include "gview.h"
+ #include "gviewv4l2core.h"
diff --git a/srcpkgs/guvcview/template b/srcpkgs/guvcview/template
index 345cf6006f24..86a7fd619612 100644
--- a/srcpkgs/guvcview/template
+++ b/srcpkgs/guvcview/template
@@ -1,8 +1,7 @@
 # Template file for 'guvcview'
 pkgname=guvcview
-version=2.0.7
+version=2.0.8
 revision=1
-create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-static --disable-debian-menu"
 hostmakedepends="pkg-config intltool autoconf automake libtool glib-devel"
@@ -14,7 +13,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="http://guvcview.sourceforge.net/"
 distfiles="${SOURCEFORGE_SITE}/${pkgname}/${pkgname}-src-${version}.tar.bz2"
-checksum=f47d51fbd06e44eeaa1a82f4a153c927527c90d94514197a70b2956028cc8ad4
+checksum=a21f4e448286666cf27bafef5290cc953a0a1796b752e5bbe521266dc1230c81
 
 post_patch() {
 	sed '31a#include <locale.h>' -i  guvcview/guvcview.c

From 7936a947031463c53cdc5c873b881848f748dde6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 041/115] handbrake: update to 1.6.1

---
 .../patches/fix-missing-x265-link-flag.patch    | 11 ++++++-----
 .../handbrake/patches/libhb-vpl-include.patch   | 15 +++++++++++++++
 srcpkgs/handbrake/template                      | 17 ++++++++++-------
 3 files changed, 31 insertions(+), 12 deletions(-)
 create mode 100644 srcpkgs/handbrake/patches/libhb-vpl-include.patch

diff --git a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
index 26db03867a0c..d6bb2eda627a 100644
--- a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
+++ b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
@@ -1,14 +1,15 @@
 --- a/gtk/configure.ac
 +++ b/gtk/configure.ac
 @@ -203,7 +203,7 @@
- 
+
  AM_CONDITIONAL([MINGW], [test "x$mingw_flag" = "xyes"])
- 
--HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg"
-+HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -ldl"
+
+-HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc"
++HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc -ldl"
  HB_CPPFLAGS="$HB_CPPFLAGS $HBINC"
- 
+
  PKG_CHECK_MODULES([x264], [x264], sys_x264=yes, sys_x264=no)
+
 --- a/test/module.defs
 +++ b/test/module.defs
 @@ -69,6 +69,9 @@
diff --git a/srcpkgs/handbrake/patches/libhb-vpl-include.patch b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
new file mode 100644
index 000000000000..298f9f4ab28f
--- /dev/null
+++ b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
@@ -0,0 +1,15 @@
+--- a/libhb/module.defs	2023-01-22 11:36:49.000000000 -0500
++++ b/libhb/module.defs	2023-04-03 22:37:52.395467010 -0400
+@@ -46,11 +46,7 @@
+ LIBHB.GCC.I += $(LIBHB.build/) $(CONTRIB.build/)include
+ 
+ ifeq (1,$(FEATURE.qsv))
+-    ifeq ($(HOST.system),freebsd))
+-        LIBHB.GCC.I += $(LOCALBASE)/include/vpl
+-    else
+-        LIBHB.GCC.I += $(CONTRIB.build/)include/vpl
+-    endif
++    LIBHB.GCC.I += /usr/include/vpl
+ endif
+ 
+ ifneq (,$(filter $(HOST.system),freebsd netbsd openbsd))
diff --git a/srcpkgs/handbrake/template b/srcpkgs/handbrake/template
index ca5e4571e49c..c32cb1bfa31f 100644
--- a/srcpkgs/handbrake/template
+++ b/srcpkgs/handbrake/template
@@ -1,10 +1,10 @@
 # Template file for 'handbrake'
 pkgname=handbrake
-version=1.5.1
+version=1.6.1
 revision=1
 build_style=gnu-configure
 configure_args="--force --disable-gtk-update-checks --disable-df-fetch --harden
- $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc)"
+ $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc) $(vopt_enable qsv)"
 make_build_args="-C ${XBPS_TRIPLET}"
 make_install_args="-C ${XBPS_TRIPLET}"
 hostmakedepends="automake cmake gettext-devel glib-devel intltool libtool m4 meson nasm pkg-config python3"
@@ -12,8 +12,11 @@ makedepends="bzip2-devel ffmpeg-devel gst-plugins-base1-devel gtk+3-devel
  jansson-devel lame-devel libass-devel libbluray-devel libdav1d-devel
  libdvdnav-devel libdvdread-devel libgudev-devel libnuma-devel
  libsamplerate-devel libtheora-devel libvorbis-devel libvpx-devel libxml2-devel
- opus-devel speex-devel x264-devel x265-devel zimg-devel
+ opus-devel speex-devel x264-devel x265-devel zimg-devel libsvt-av1-devel
  $(vopt_if fdk_aac fdk-aac-devel)
+ $(vopt_if qsv libva-devel)
+ $(vopt_if qsv libdrm-devel)
+ $(vopt_if qsv onevpl-devel)
  $(vopt_if nvenc nv-codec-headers)"
 depends="desktop-file-utils gst-plugins-good1 hicolor-icon-theme"
 short_desc="Multithreaded video transcoder"
@@ -21,15 +24,15 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-2.0-only"
 homepage="https://handbrake.fr/"
 distfiles="https://github.com/HandBrake/HandBrake/releases/download/${version}/HandBrake-${version}-source.tar.bz2"
-checksum=3999fe06d5309c819799a73a968a8ec3840e7840c2b64af8f5cdb7fd8c9430f0
+checksum=94ccfe03db917a91650000c510f7fd53f844da19f19ad4b4be1b8f6bc31a8d4c
 nocross=yes
 
-build_options="fdk_aac nvenc"
+build_options="fdk_aac nvenc qsv"
 
 case "$XBPS_TARGET_MACHINE" in
 	x86_64*|i686*)
 		CFLAGS="-msse"
-		build_options_default="nvenc"
+		build_options_default="nvenc qsv"
 		;;
 esac
 
@@ -37,7 +40,7 @@ pre_configure() {
 	# use system libraries, don't download them
 	rm -rf contrib/
 	for module in fdk-aac ffmpeg libbluray libdav1d libdvdnav libdvdread nvenc \
-		x265 zimg; do
+		x265 zimg svt-av1 libvpl; do
 	    vsed -i "/MODULES += contrib\/${module}/d" make/include/main.defs
 	done
 }

From dd3ebe5ea026dbc80db460637a97f68eda79fe23 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 042/115] hedgewars: revbump for ffmpeg4-4.4.3

---
 srcpkgs/hedgewars/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/hedgewars/template b/srcpkgs/hedgewars/template
index 419f29b98b44..926fe4fe3e68 100644
--- a/srcpkgs/hedgewars/template
+++ b/srcpkgs/hedgewars/template
@@ -1,13 +1,13 @@
 # Template file for 'hedgewars'
 pkgname=hedgewars
 version=1.0.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DNOSERVER=1 -DDATA_INSTALL_DIR=/usr/share/${pkgname}
  -DPHYSFS_SYSTEM=1 -DMINIMAL_FLAGS=1"
 make_cmd=make
 hostmakedepends="lua51 pkg-config qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
+makedepends="ffmpeg4-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
  SDL2_mixer-devel SDL2_net-devel SDL2_ttf-devel"
 depends="libfreeglut"
 short_desc="Funny turn-based artillery game, featuring fighting Hedgehogs!"

From ad0cce14cec0d322358ee085c1c4c8da58cee29d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 043/115] idjc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/idjc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/idjc/template b/srcpkgs/idjc/template
index df60318b3db9..36a75baf597c 100644
--- a/srcpkgs/idjc/template
+++ b/srcpkgs/idjc/template
@@ -1,11 +1,11 @@
 # Template file for 'idjc'
 pkgname=idjc
 version=0.9.1
-revision=3
+revision=4
 build_style=gnu-configure
 hostmakedepends="pkg-config git python3 automake gettext-devel libtool"
 makedepends="libvorbis-devel libogg-devel jack-devel libsamplerate-devel
- libflac-devel libsndfile-devel mpg123-devel ffmpeg-devel speex-devel
+ libflac-devel libsndfile-devel mpg123-devel ffmpeg4-devel speex-devel
  glib-devel pixman-devel lame-devel python3-gobject-devel libshout-idjc-devel
  opus-devel twolame-devel python3-mutagen python3-devel"
 depends="python3-gobject python3-mutagen desktop-file-utils shared-mime-info python3-dbus jack"

From c21b5b9986992b198ed1700c6c3ffc7fb2bf7cb7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 044/115] kfilemetadata5: revbump for ffmpeg-6.0

---
 srcpkgs/kfilemetadata5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kfilemetadata5/template b/srcpkgs/kfilemetadata5/template
index 4b91cf19f298..a3671a38ce59 100644
--- a/srcpkgs/kfilemetadata5/template
+++ b/srcpkgs/kfilemetadata5/template
@@ -1,7 +1,7 @@
 # Template file for 'kfilemetadata5'
 pkgname=kfilemetadata5
 version=5.107.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="kcoreaddons extra-cmake-modules pkg-config qt5-host-tools qt5-qmake
  gettext kcoreaddons python3"

From 95bc47535165f814bc8d616e438b306f6887c2fb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 045/115] kid3: revbump for ffmpeg-6.0

---
 srcpkgs/kid3/patches/ffmpeg5.patch | 17 +++++++++++++++++
 srcpkgs/kid3/template              |  2 +-
 2 files changed, 18 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/kid3/patches/ffmpeg5.patch

diff --git a/srcpkgs/kid3/patches/ffmpeg5.patch b/srcpkgs/kid3/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..135fc50e07c9
--- /dev/null
+++ b/srcpkgs/kid3/patches/ffmpeg5.patch
@@ -0,0 +1,17 @@
+# https://aur.archlinux.org/cgit/aur.git/diff/ffmpeg5.patch?h=kid3-cli&id=12410a74906612e7efc0ec8fbce739b4a0fef7e7
+diff --git a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+index e156d424..e12b9abd 100644
+--- a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
++++ b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+@@ -232,7 +232,11 @@ private:
+   friend class Format;
+   friend class Converter;
+   AVCodecContext* m_ptr;
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 0, 0)
+   AVCodec* m_impl;
++#else
++  const AVCodec* m_impl;
++#endif
+   AVFrame* m_frame;
+   bool m_opened;
+ };
diff --git a/srcpkgs/kid3/template b/srcpkgs/kid3/template
index 456206d90e16..f32f9decb0e7 100644
--- a/srcpkgs/kid3/template
+++ b/srcpkgs/kid3/template
@@ -1,7 +1,7 @@
 # Template file for 'kid3'
 pkgname=kid3
 version=3.9.1
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DWITH_APPS='CLI;$(vopt_if KDE KDE Qt)'
  -DWITH_DOCBOOKDIR=/usr/share/xsl/docbook -DWITH_FLAC=$(vopt_if flac ON OFF)

From 66d91f02e62af65823d6544114a568d152ac00a3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 046/115] kodi: revbump for ffmpeg4-4.4.3

---
 srcpkgs/kodi/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/kodi/template b/srcpkgs/kodi/template
index 8057964d78a3..6cc1874be7ba 100644
--- a/srcpkgs/kodi/template
+++ b/srcpkgs/kodi/template
@@ -1,7 +1,7 @@
 # Template file for 'kodi'
 pkgname=kodi
 version=19.4
-revision=6
+revision=7
 _codename="Matrix"
 build_style=cmake
 configure_args="-DWITH_FFMPEG=/usr -DENABLE_LDGOLD=OFF
@@ -54,7 +54,7 @@ makedepends="
  libmad-devel fontconfig-devel libXinerama-devel libsamplerate-devel libmms-devel
  enca-devel boost-devel libcurl-devel libva-devel libvdpau-devel libass-devel
  libbluetooth-devel yajl-devel libplist-devel librtmp-devel tinyxml-devel
- taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg-devel
+ taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg4-devel
  giflib-devel libxslt-devel gnutls-devel libssh-devel libmicrohttpd-devel
  libcec-devel dcadec-devel flatbuffers-devel fmt-devel lcms2-devel
  libfstrcmp-devel rapidjson libcdio-paranoia spdlog libwaylandpp-devel

From 8edbdc022799357e6eff033b65ad14e8e1b6fc35 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 047/115] kpipewire: revbump for ffmpeg-6.0

---
 srcpkgs/kpipewire/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kpipewire/template b/srcpkgs/kpipewire/template
index db4e42f0d456..2334bf867806 100644
--- a/srcpkgs/kpipewire/template
+++ b/srcpkgs/kpipewire/template
@@ -1,7 +1,7 @@
 # Template file for 'kpipewire'
 pkgname=kpipewire
 version=5.27.6
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules plasma-wayland-protocols gettext
  qt5-qmake qt5-host-tools pkg-config wayland-devel kcoreaddons

From 420e4228548bb59e03cf8693b21215a4f932c6b8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 048/115] libextractor: revbump for ffmpeg4-4.4.3

---
 srcpkgs/libextractor/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libextractor/template b/srcpkgs/libextractor/template
index ddd4790f93e8..1fb9ca56a96a 100644
--- a/srcpkgs/libextractor/template
+++ b/srcpkgs/libextractor/template
@@ -7,7 +7,7 @@ configure_args="--disable-static"
 hostmakedepends="pkg-config"
 makedepends="zlib-devel bzip2-devel exiv2-devel tiff-devel libpng-devel
  libjpeg-turbo-devel libvorbis-devel libflac-devel giflib-devel libmpeg2-devel
- ffmpeg-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
+ ffmpeg4-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
 short_desc="Library used to extract meta data from files"
 maintainer="Martin Riese <grauehaare@gmx.de>"
 license="GPL-3.0-or-later"

From fee3fb4b4191a372cd8c22970cc883e7f5a28eba Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 049/115] libopenal: revbump for ffmpeg-6.0

---
 srcpkgs/libopenal/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenal/template b/srcpkgs/libopenal/template
index 77218f9e539d..3f49ed75a1fd 100644
--- a/srcpkgs/libopenal/template
+++ b/srcpkgs/libopenal/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenal'
 pkgname=libopenal
 version=1.22.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DALSOFT_EXAMPLES=OFF"
 hostmakedepends="pkg-config"

From 3d35e2cf054c4dab9332363d2c0998a91adb6426 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 050/115] libopenshot: revbump for ffmpeg-6.0

---
 srcpkgs/libopenshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenshot/template b/srcpkgs/libopenshot/template
index db831f69b474..81aa0d7136d9 100644
--- a/srcpkgs/libopenshot/template
+++ b/srcpkgs/libopenshot/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenshot'
 pkgname=libopenshot
 version=0.3.0
-revision=1
+revision=2
 build_style=cmake
 # Builds fail with Ruby-2.4.1
 configure_args="-DENABLE_RUBY=OFF -DUSE_SYSTEM_JSONCPP=ON"

From 80bce59cf2b787abdf9b7edf3b12e736bf6908cf Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 051/115] loudgain: revbump for ffmpeg-6.0

---
 srcpkgs/loudgain/patches/ffmpeg5.patch | 11 +++++++++++
 srcpkgs/loudgain/template              |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/loudgain/patches/ffmpeg5.patch

diff --git a/srcpkgs/loudgain/patches/ffmpeg5.patch b/srcpkgs/loudgain/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..16d4510ee98f
--- /dev/null
+++ b/srcpkgs/loudgain/patches/ffmpeg5.patch
@@ -0,0 +1,11 @@
+--- a/src/scan.c	2019-09-06 11:31:19.000000000 -0400
++++ b/src/scan.c	2023-03-23 11:15:40.867968521 -0400
+@@ -69,8 +69,6 @@
+ 	 * It is now useless
+ 	 * https://github.com/FFmpeg/FFmpeg/blob/70d25268c21cbee5f08304da95be1f647c630c15/doc/APIchanges#L86
+ 	 */
+-  if (avformat_version() < AV_VERSION_INT(58,9,100))
+-    av_register_all();
+ 
+ 	av_log_set_callback(scan_av_log);
+ 
diff --git a/srcpkgs/loudgain/template b/srcpkgs/loudgain/template
index da4f2d56e94c..4d6bf29efb4f 100644
--- a/srcpkgs/loudgain/template
+++ b/srcpkgs/loudgain/template
@@ -1,7 +1,7 @@
 # Template file for 'loudgain'
 pkgname=loudgain
 version=0.6.8
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libebur128-devel taglib-devel ffmpeg-devel"

From 9b163bbbfa517f5ecf8f1db5f6ad11a8a311131f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 052/115] mediastreamer: revbump for ffmpeg4-4.4.3

---
 srcpkgs/mediastreamer/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mediastreamer/template b/srcpkgs/mediastreamer/template
index d0e97e858e29..1bde031443a5 100644
--- a/srcpkgs/mediastreamer/template
+++ b/srcpkgs/mediastreamer/template
@@ -1,11 +1,11 @@
 # Template file for 'mediastreamer'
 pkgname=mediastreamer
 version=5.2.6
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_STRICT=0 -DENABLE_UNIT_TESTS=0"
 hostmakedepends="python3"
-makedepends="bzrtp-devel ffmpeg-devel glew-devel libXv-devel libsrtp-devel
+makedepends="bzrtp-devel ffmpeg4-devel glew-devel libXv-devel libsrtp-devel
  libupnp-devel libvpx-devel mbedtls-devel opus-devel ortp-devel pulseaudio-devel
  libtheora-devel speex-devel v4l-utils-devel bcg729-devel bcmatroska2-devel libgsm-devel"
 # zxing-cpp-devel (1.2.0 probably not compatible, check again after updaing xzing)

From ff24ea79e406981820ec54df2be6c064868317e5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 053/115] mgba: revbump for ffmpeg-6.0

---
 srcpkgs/mgba/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mgba/template b/srcpkgs/mgba/template
index ae0504311eee..d31295a0cd3d 100644
--- a/srcpkgs/mgba/template
+++ b/srcpkgs/mgba/template
@@ -1,7 +1,7 @@
 # Template file for 'mgba'
 pkgname=mgba
 version=0.10.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake desktop-file-utils"
 makedepends="SDL2-devel ffmpeg-devel libedit-devel libepoxy-devel libmagick-devel

From 9dd2abdc0066beae6d539ee1ace9a4739491fd69 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 054/115] minidlna: revbump for ffmpeg-6.0

---
 srcpkgs/minidlna/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/minidlna/template b/srcpkgs/minidlna/template
index d551e49ed465..5fa929f3a0c1 100644
--- a/srcpkgs/minidlna/template
+++ b/srcpkgs/minidlna/template
@@ -1,7 +1,7 @@
 # Template file for 'minidlna'
 pkgname=minidlna
 version=1.3.3
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="
  --sbindir=/usr/bin

From 6bae8561e188894520a21112702f80b027bd3717 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 055/115] mixxx: revbump for ffmpeg-6.0

---
 srcpkgs/mixxx/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mixxx/template b/srcpkgs/mixxx/template
index 619ddca0d332..4b9ea00d3fb3 100644
--- a/srcpkgs/mixxx/template
+++ b/srcpkgs/mixxx/template
@@ -1,7 +1,7 @@
 # Template file for 'mixxx'
 pkgname=mixxx
 version=2.3.3
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="extra-cmake-modules pkg-config protobuf qt5-host-tools qt5-devel"

From 98b78f8fd999cfe0d6a8271672fc244e9d6037e3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 056/115] mlt: revbump for ffmpeg4-4.4.3

---
 srcpkgs/mlt/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mlt/template b/srcpkgs/mlt/template
index 8933eb4e7bb9..73353fedafb5 100644
--- a/srcpkgs/mlt/template
+++ b/srcpkgs/mlt/template
@@ -1,14 +1,14 @@
 # Template file for 'mlt'
 pkgname=mlt
 version=6.26.1
-revision=1
+revision=2
 build_style=configure
 configure_args="--prefix=/usr --libdir=/usr/lib$XBPS_TARGET_WORDSIZE
  --enable-gpl --enable-gpl3 --disable-swfdec --without-kde
  --swig-languages=python"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which"
 # XXX: movit vid.stab
-makedepends="alsa-lib-devel ffmpeg-devel gtk+-devel jack-devel ladspa-sdk
+makedepends="alsa-lib-devel ffmpeg4-devel gtk+-devel jack-devel ladspa-sdk
  libexif-devel libsamplerate-devel libxml2-devel sox-devel SDL_image-devel
  fftw-devel frei0r-plugins python3-devel pulseaudio-devel movit-devel
  libvidstab-devel libatomic-devel"

From c0f9d3c7c20edfb287d047129cd68bd573c6ab8e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 057/115] moc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/moc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/moc/template b/srcpkgs/moc/template
index 5aed5d36558d..d8de816026b6 100644
--- a/srcpkgs/moc/template
+++ b/srcpkgs/moc/template
@@ -1,10 +1,10 @@
 # Template file for 'moc'
 pkgname=moc
 version=2.5.2
-revision=6
+revision=7
 build_style=gnu-configure
 hostmakedepends="pkg-config"
-makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg-devel
+makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg4-devel
  jack-devel alsa-lib-devel libltdl-devel libflac-devel libvorbis-devel
  libmad-devel libmpcdec-devel libmodplug-devel libid3tag-devel faad2-devel
  taglib-devel libsndfile-devel wavpack-devel speex-devel libsamplerate-devel

From e8c42cb263ef4daa6349db9b20cccc169314da9b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 058/115] motion: revbump for ffmpeg-6.0

---
 srcpkgs/motion/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/motion/template b/srcpkgs/motion/template
index 3cf3c3035c5b..7dca12d851e3 100644
--- a/srcpkgs/motion/template
+++ b/srcpkgs/motion/template
@@ -1,7 +1,7 @@
 # Template file for 'motion'
 pkgname=motion
 version=4.5.1
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake pkg-config gettext-devel tar"
 makedepends="ffmpeg-devel libmicrohttpd-devel v4l-utils-devel gettext-devel"

From 40daffef7fcdb8a709c5d6d5633057f60f2b80b8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 059/115] mpv: revbump for ffmpeg-6.0

---
 srcpkgs/mpv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpv/template b/srcpkgs/mpv/template
index e163c496c6eb..d4fefbf5e3c7 100644
--- a/srcpkgs/mpv/template
+++ b/srcpkgs/mpv/template
@@ -1,7 +1,7 @@
 # Template file for 'mpv'
 pkgname=mpv
 version=0.35.1
-revision=2
+revision=3
 build_style=meson
 configure_args="-Dcdda=enabled -Ddvbin=enabled -Ddvdnav=enabled
  -Dlibmpv=true -Dcplugins=enabled

From 25cde5ac9d617a8e3fe2f645d6cdfa80664e5bed Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 060/115] musikcube: revbump for ffmpeg-6.0

---
 srcpkgs/musikcube/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/musikcube/template b/srcpkgs/musikcube/template
index 7c569303c054..a4dea460c371 100644
--- a/srcpkgs/musikcube/template
+++ b/srcpkgs/musikcube/template
@@ -1,7 +1,7 @@
 # Template file for 'musikcube'
 pkgname=musikcube
 version=3.0.0
-revision=1
+revision=2
 build_style=cmake
 make_cmd=make
 configure_args="-DNO_NCURSESW=1"

From f7ea6ed904f54fd8ab848ba20e4cacdbb834e7cb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 061/115] notcurses: revbump for ffmpeg-6.0

---
 srcpkgs/notcurses/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/notcurses/template b/srcpkgs/notcurses/template
index 6dd8a091319f..3110c30c9aff 100644
--- a/srcpkgs/notcurses/template
+++ b/srcpkgs/notcurses/template
@@ -1,7 +1,7 @@
 # Template file for 'notcurses'
 pkgname=notcurses
 version=3.0.9
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DUSE_STATIC=ON $(vopt_bool man USE_PANDOC)"
 hostmakedepends="pkg-config $(vopt_if man pandoc)"

From c4e84a2d9836e14306615cff0b8b28a8e9c59620 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 062/115] obs: revbump for ffmpeg-6.0

---
 srcpkgs/obs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/obs/template b/srcpkgs/obs/template
index 7b69c630d30d..2c8d68d71f3a 100644
--- a/srcpkgs/obs/template
+++ b/srcpkgs/obs/template
@@ -1,7 +1,7 @@
 # Template file for 'obs'
 pkgname=obs
 version=29.1.2
-revision=1
+revision=2
 archs="i686* x86_64* ppc64le* aarch64*"
 build_style=cmake
 configure_args="-DOBS_VERSION_OVERRIDE=${version} -DENABLE_JACK=ON

From b9c7584847e525b2132df2dff7e6fef17f129001 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 063/115] olive: revbump for ffmpeg4-4.4.3

---
 srcpkgs/olive/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/olive/template b/srcpkgs/olive/template
index 12a46936c990..5c2917b9c512 100644
--- a/srcpkgs/olive/template
+++ b/srcpkgs/olive/template
@@ -1,10 +1,10 @@
 # Template file for 'olive'
 pkgname=olive
 version=0.1.2
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools pkg-config"
-makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg-devel frei0r-plugins"
+makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg4-devel frei0r-plugins"
 short_desc="Non-linear video editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"

From fee5f3b91ac6410c7fd7867fcc62155fc0696c45 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 064/115] omxplayer: revbump for ffmpeg4-4.4.3

---
 srcpkgs/omxplayer/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/omxplayer/template b/srcpkgs/omxplayer/template
index e70bf7873d4d..0e9bc70e7c8e 100644
--- a/srcpkgs/omxplayer/template
+++ b/srcpkgs/omxplayer/template
@@ -1,10 +1,10 @@
 # Template file for 'omxplayer'
 pkgname=omxplayer
 version=20190102
-revision=1
+revision=2
 short_desc="Commandline OMX player for the Raspberry Pi"
 maintainer="Orphaned <orphan@voidlinux.org>"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://github.com/popcornmix/omxplayer"
 
 _commit="f06235cc9690a6d58187514452df8cf8fcdaacec"
@@ -15,7 +15,7 @@ checksum=af2d9450f8947842ea8c401fe9f71eec444013ebbdee29f2ac828c9c493c1329
 archs="armv6l* armv7l*"
 build_style=gnu-makefile
 hostmakedepends="curl pkg-config"
-makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg-devel dbus-devel"
+makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg4-devel dbus-devel"
 depends="freefont-ttf"
 
 do_build() {

From 786d0b5eb13a5fb5cae4428670e67ea3c5405141 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 065/115] openshot: revbump for ffmpeg-6.0

---
 srcpkgs/openshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openshot/template b/srcpkgs/openshot/template
index 322717d40abc..c074e0338773 100644
--- a/srcpkgs/openshot/template
+++ b/srcpkgs/openshot/template
@@ -1,7 +1,7 @@
 # Template file for 'openshot'
 pkgname=openshot
 version=3.0.0
-revision=1
+revision=2
 build_style=python3-module
 hostmakedepends="python3 python3-setuptools"
 makedepends="ffmpeg-devel python3-PyQt5"

From 2239abb95b5c8f12a057e325103961be92a9ba36 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 066/115] opentoonz: revbump for ffmpeg-6.0

---
 srcpkgs/opentoonz/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/opentoonz/template b/srcpkgs/opentoonz/template
index ee9f7603f55f..3e81834ca0ed 100644
--- a/srcpkgs/opentoonz/template
+++ b/srcpkgs/opentoonz/template
@@ -1,7 +1,7 @@
 # Template file for 'opentoonz'
 pkgname=opentoonz
 version=1.6.0
-revision=2
+revision=3
 build_wrksrc="toonz/sources"
 build_style=cmake
 make_cmd=make

From ac386417e07b6c404f5eaeca46fd16b5307a871c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 067/115] pianobar: revbump for ffmpeg-6.0

---
 srcpkgs/pianobar/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pianobar/template b/srcpkgs/pianobar/template
index e3febb821a45..1e3dc1bf9308 100644
--- a/srcpkgs/pianobar/template
+++ b/srcpkgs/pianobar/template
@@ -1,7 +1,7 @@
 # Template file for 'pianobar'
 pkgname=pianobar
 version=2022.04.01
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="V=1"
 hostmakedepends="pkg-config"

From 5beb3538b87f8efaa29bd1fcdd85058c256ac3d4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 068/115] ppsspp: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ppsspp/template | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/ppsspp/template b/srcpkgs/ppsspp/template
index 7984a733d4be..15a42fd2c993 100644
--- a/srcpkgs/ppsspp/template
+++ b/srcpkgs/ppsspp/template
@@ -1,7 +1,7 @@
 # Template file for 'ppsspp'
 pkgname=ppsspp
 version=1.14.4
-revision=1
+revision=2
 _glslang_commit=dc11adde23c455a24e13dd54de9b4ede8bdd7db8
 _SPIRV_Cross_commit=9acb9ec31f5a8ef80ea6b994bb77be787b08d3d1
 _armips_commit=6719edebaae03330ee5441d9b28280672edf00d5
@@ -13,7 +13,7 @@ configure_args="-DHEADLESS=1 -DUSE_SYSTEM_FFMPEG=1 -DUNITTEST=ON
  -DUSING_QT_UI=$(vopt_if qt ON OFF) -DUSE_SYSTEM_ZSTD=ON
  -DARMIPS_USE_STD_FILESYSTEM=ON"
 hostmakedepends="pkg-config python3 $(vopt_if qt qt5-host-tools)"
-makedepends="zlib-devel glew-devel ffmpeg-devel libzip-devel
+makedepends="zlib-devel glew-devel ffmpeg4-devel libzip-devel
  snappy-devel rapidjson libpng-devel libzstd-devel
  $(vopt_if sdl2 SDL2-devel) $(vopt_if wayland wayland-devel)
  $(vopt_if qt 'qt5-devel qt5-multimedia-devel')"
@@ -62,13 +62,12 @@ post_extract() {
 	mv ${wrksrc}/miniupnp-${_miniupnp_commit} ${wrksrc}/ext/miniupnp
 }
 
-post_patch(){
+post_patch() {
 	# disable git versioning
 	vsed -e 's|find_package(Git)|# &|' -i git-version.cmake
 }
 
 do_install() {
-	vlicense LICENSE.TXT
 	vinstall icons/icon.svg 644 usr/share/pixmaps ppsspp.svg
 	vinstall Qt/PPSSPP.desktop 644 usr/share/applications
 	vbin build/PPSSPPHeadless ppsspp-headless

From a8c30bea42d65e91ffe939578ca55e0b0b2f7ee2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 069/115] pqiv: revbump for ffmpeg-6.0

---
 srcpkgs/pqiv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pqiv/template b/srcpkgs/pqiv/template
index 542fc27a2d32..9308d949b6a1 100644
--- a/srcpkgs/pqiv/template
+++ b/srcpkgs/pqiv/template
@@ -1,7 +1,7 @@
 # Template file for 'pqiv'
 pkgname=pqiv
 version=2.12
-revision=1
+revision=2
 build_style=gnu-makefile
 hostmakedepends="pkg-config"
 makedepends="glib-devel gtk+3-devel $(vopt_if ffmpeg ffmpeg-devel)

From 80b306ceb98dac6de2d09c105bf7d248c1d81441 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 070/115] qmmp: revbump for ffmpeg-6.0

---
 srcpkgs/qmmp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qmmp/template b/srcpkgs/qmmp/template
index 26c661ed16be..a150d7441c7a 100644
--- a/srcpkgs/qmmp/template
+++ b/srcpkgs/qmmp/template
@@ -1,7 +1,7 @@
 # Template file for 'qmmp'
 pkgname=qmmp
 version=1.6.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DUSE_HAL:BOOL=FALSE -DQMMP_DEFAULT_UI:STRING=simple"
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From 35f6dde15053ac7eca5d278cea2b41b4d593b03b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 071/115] qt5-webengine: update to 5.15.13

---
 .../chromium-media-filters-cpp14.patch        |  11 ++
 srcpkgs/qt5-webengine/patches/ffmpeg5.patch   | 179 ++++++++++++++++++
 srcpkgs/qt5-webengine/template                |  10 +-
 3 files changed, 195 insertions(+), 5 deletions(-)
 create mode 100644 srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/ffmpeg5.patch

diff --git a/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
new file mode 100644
index 000000000000..04adc540f2cb
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
@@ -0,0 +1,11 @@
+--- a/src/3rdparty/chromium/media/filters/BUILD.gn	2023-02-27 13:32:59.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/BUILD.gn	2023-04-02 17:21:39.204066384 -0400
+@@ -96,6 +96,8 @@
+     "//ui/gfx/geometry:geometry",
+   ]
+ 
++  cflags_cc = [ "-std=c++14" ]
++
+   libs = []
+ 
+   if (proprietary_codecs) {
diff --git a/srcpkgs/qt5-webengine/patches/ffmpeg5.patch b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..ac55e1634423
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
@@ -0,0 +1,179 @@
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:57.732547446 -0400
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:09.486478995 -0400
+@@ -57,6 +57,8 @@
+ 
+ namespace {
+ 
++constexpr int64_t kRelativeTsBase = static_cast<int64_t>(0x7ffeffffffffffff);
++
+ void SetAVStreamDiscard(AVStream* stream, AVDiscard discard) {
+   DCHECK(stream);
+   stream->discard = discard;
+@@ -90,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+   if (stream->start_time != kNoFFmpegTimestamp)
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (stream->first_dts != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, stream->first_dts);
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -408,11 +398,11 @@
+   scoped_refptr<DecoderBuffer> buffer;
+ 
+   if (type() == DemuxerStream::TEXT) {
+-    int id_size = 0;
++    size_t id_size = 0;
+     uint8_t* id_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
+ 
+-    int settings_size = 0;
++    size_t settings_size = 0;
+     uint8_t* settings_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
+ 
+@@ -424,7 +414,7 @@
+     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
+                                      side_data.data(), side_data.size());
+   } else {
+-    int side_data_size = 0;
++    size_t side_data_size = 0;
+     uint8_t* side_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
+ 
+@@ -485,7 +475,7 @@
+                                        packet->size - data_offset);
+     }
+ 
+-    int skip_samples_size = 0;
++    size_t skip_samples_size = 0;
+     const uint32_t* skip_samples_ptr =
+         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
+             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
+@@ -1587,6 +1577,8 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++      continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+       lowest_start_time_stream = stream.get();
+@@ -1604,6 +1596,8 @@
+     if (stream && stream->type() == DemuxerStream::VIDEO &&
+         stream->IsEnabled()) {
+       video_stream = stream.get();
++      if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++        continue;
+       if (video_stream->start_time() <= seek_time) {
+         return video_stream;
+       }
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h qtwebengine-5.15.10/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h
+--- a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-07-11 22:12:47.917192788 -0500
+@@ -29,6 +29,7 @@ extern "C" {
+ #include <libavformat/avformat.h>
+ #include <libavformat/avio.h>
+ #include <libavutil/avutil.h>
++#include <libavutil/channel_layout.h>
+ #include <libavutil/imgutils.h>
+ #include <libavutil/log.h>
+ #include <libavutil/mastering_display_metadata.h>
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/audio_file_reader.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/audio_file_reader.cc
+--- a/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -85,7 +85,7 @@ bool AudioFileReader::OpenDemuxer() {
+ }
+ 
+ bool AudioFileReader::OpenDecoder() {
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (codec) {
+     // MP3 decodes to S16P which we don't support, tell it to use S16 instead.
+     if (codec_context_->sample_fmt == AV_SAMPLE_FMT_S16P)
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -329,7 +329,7 @@ bool FFmpegAudioDecoder::ConfigureDecode
+     }
+   }
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec ||
+       avcodec_open2(codec_context_.get(), codec, &codec_options) < 0) {
+     DLOG(ERROR) << "Could not initialize audio decoder: "
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -59,7 +59,6 @@ static int64_t AVIOSeekOperation(void* o
+ }
+ 
+ void FFmpegGlue::InitializeFFmpeg() {
+-  av_register_all();
+ }
+ 
+ static void LogContainer(bool is_local_file,
+@@ -95,9 +94,6 @@ FFmpegGlue::FFmpegGlue(FFmpegURLProtocol
+   // Enable fast, but inaccurate seeks for MP3.
+   format_context_->flags |= AVFMT_FLAG_FAST_SEEK;
+ 
+-  // Ensures we can read out various metadata bits like vp8 alpha.
+-  format_context_->flags |= AVFMT_FLAG_KEEP_SIDE_DATA;
+-
+   // Ensures format parsing errors will bail out. From an audit on 11/2017, all
+   // instances were real failures. Solves bugs like http://crbug.com/710791.
+   format_context_->error_recognition |= AV_EF_EXPLODE;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -391,7 +391,7 @@ bool FFmpegVideoDecoder::ConfigureDecode
+   if (decode_nalus_)
+     codec_context_->flags2 |= AV_CODEC_FLAG2_CHUNKS;
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
+     ReleaseFFmpegResources();
+     return false;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/media_file_checker.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/media_file_checker.cc
+--- a/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -68,7 +68,7 @@ bool MediaFileChecker::Start(base::TimeD
+       auto context = AVStreamToAVCodecContext(format_context->streams[i]);
+       if (!context)
+         continue;
+-      AVCodec* codec = avcodec_find_decoder(cp->codec_id);
++      const AVCodec* codec = avcodec_find_decoder(cp->codec_id);
+       if (codec && avcodec_open2(context.get(), codec, nullptr) >= 0) {
+         auto loop = std::make_unique<FFmpegDecodingLoop>(context.get());
+         stream_contexts[i] = {std::move(context), std::move(loop)};
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc qtwebengine-5.15.10/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc
+--- a/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -203,7 +203,7 @@ int32_t H264DecoderImpl::InitDecode(cons
+   // a pointer |this|.
+   av_context_->opaque = this;
+ 
+-  AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
+   if (!codec) {
+     // This is an indication that FFmpeg has not been initialized or it has not
+     // been compiled/initialized with the correct set of codecs.
diff --git a/srcpkgs/qt5-webengine/template b/srcpkgs/qt5-webengine/template
index edeb07f1ab7a..095ab67701e4 100644
--- a/srcpkgs/qt5-webengine/template
+++ b/srcpkgs/qt5-webengine/template
@@ -1,9 +1,9 @@
 # Template file for 'qt5-webengine'
 pkgname=qt5-webengine
-version=5.15.11
-revision=4
+version=5.15.13
+revision=1
 _version="${version}-lts"
-_chromium_commit=be349eaf62e77955791d7bf29f893f1e8a37daf4
+_chromium_commit=e48df7803c7c98b0b2471c94057d32e44a301ad5
 archs="x86_64* i686* armv[67]* ppc64* aarch64*"
 create_wrksrc=yes
 build_style=qmake
@@ -32,8 +32,8 @@ license="GPL-3.0-or-later, LGPL-3.0-or-later"
 homepage="https://qt.io/"
 distfiles="https://github.com/qt/qtwebengine/archive/v${_version}.tar.gz
  https://github.com/qt/qtwebengine-chromium/archive/${_chromium_commit}.tar.gz"
-checksum="aa7466356c450c5f5870f979b93cd7e7e62da1165c328ffcab1a9928db18ad67
- 6f47ed8ab8cc062411f6f206da6353bc8263d6ed6d6290c689a05c01d91f646b"
+checksum="4b59838ed75ef788b59e1e412535a0e42dd9d311661fdeadb191b581ba815c63
+ a91686562b1d4e8b220e0bbcbab5feb64630e2de974b35ac034bf388af771a6c"
 
 no_generic_pkgconfig_link=yes
 build_options="sndio pipewire"

From 509f6368d15aeb7e0ff84655d77ed3f6842dbf62 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 072/115] qt5: update to 5.15.8

---
 ...erywhere-opensource-src-5.15.8-kf5-1.patch | 12913 ++++++++++++++++
 srcpkgs/qt5/template                          |    12 +-
 2 files changed, 12919 insertions(+), 6 deletions(-)
 create mode 100644 srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch

diff --git a/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch b/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch
new file mode 100644
index 000000000000..966c98bcd3bb
--- /dev/null
+++ b/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch
@@ -0,0 +1,12913 @@
+Submitted By:            Pierre Labastie <pierre_dot_labastie_at_neuf_dot_fr>
+Date:                    2023-01-05
+Initial Package Version: 5.15.8
+Upstream Status:         Applied (according to KDE)
+Origin:                  KDE patch set
+Description:             Patch set maintained by the KDE folks
+see https://dot.kde.org/2021/04/06/announcing-kdes-qt-5-patch-collection
+Patch generated using the procedure in
+https://wiki.linuxfromscratch.org/blfs/ticket/17476#comment:3
+
+Submodule qtbase 4ee4fc18..9cf586d6:
+diff --git a/qtbase/mkspecs/common/android/qplatformdefs.h b/qtbase/mkspecs/common/android/qplatformdefs.h
+index f75bc4093b..2bd59410d4 100644
+--- a/qtbase/mkspecs/common/android/qplatformdefs.h
++++ b/qtbase/mkspecs/common/android/qplatformdefs.h
+@@ -144,11 +144,7 @@
+ #define QT_SIGNAL_ARGS          int
+ #define QT_SIGNAL_IGNORE        SIG_IGN
+ 
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+ #define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+ 
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+diff --git a/qtbase/mkspecs/features/mac/sdk.mk b/qtbase/mkspecs/features/mac/sdk.mk
+index f30b5830b4..a32ceacb6c 100644
+--- a/qtbase/mkspecs/features/mac/sdk.mk
++++ b/qtbase/mkspecs/features/mac/sdk.mk
+@@ -1,6 +1,6 @@
+ 
+ ifeq ($(QT_MAC_SDK_NO_VERSION_CHECK),)
+-    CHECK_SDK_COMMAND = /usr/bin/xcrun --sdk $(EXPORT_QMAKE_MAC_SDK) -show-sdk-version 2>&1
++    CHECK_SDK_COMMAND = /usr/bin/xcrun --sdk $(EXPORT_QMAKE_MAC_SDK) -show-sdk-version 2>/dev/null
+     CURRENT_MAC_SDK_VERSION := $(shell DEVELOPER_DIR=$(EXPORT_QMAKE_XCODE_DEVELOPER_PATH) $(CHECK_SDK_COMMAND))
+     ifneq ($(CURRENT_MAC_SDK_VERSION),$(EXPORT_QMAKE_MAC_SDK_VERSION))
+         # We don't want to complain about out of date SDK unless the target needs to be remade.
+diff --git a/qtbase/mkspecs/linux-clang/qplatformdefs.h b/qtbase/mkspecs/linux-clang/qplatformdefs.h
+index a818d973f0..c1ab72fbc6 100644
+--- a/qtbase/mkspecs/linux-clang/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-clang/qplatformdefs.h
+@@ -79,14 +79,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-g++/qplatformdefs.h b/qtbase/mkspecs/linux-g++/qplatformdefs.h
+index 13523f0702..4d2750d9ec 100644
+--- a/qtbase/mkspecs/linux-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-g++/qplatformdefs.h
+@@ -79,14 +79,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ < 2)
+-#define QT_SOCKLEN_T            int
+-#else
+-#define QT_SOCKLEN_T            socklen_t
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-llvm/qplatformdefs.h b/qtbase/mkspecs/linux-llvm/qplatformdefs.h
+index dc750ab1ef..d3cc39b47f 100644
+--- a/qtbase/mkspecs/linux-llvm/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-llvm/qplatformdefs.h
+@@ -80,14 +80,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h b/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
+index 4c4e53da2a..83baffb3e3 100644
+--- a/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
+@@ -85,16 +85,9 @@
+ #include "../common/posix/qplatformdefs.h"
+ 
+ #undef QT_OPEN_LARGEFILE
+-#undef QT_SOCKLEN_T
+ 
+ #define QT_OPEN_LARGEFILE       0
+ 
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #ifndef SIOCGIFBRDADDR
+ #  define SIOCGIFBRDADDR 0x8919
+ #endif
+diff --git a/qtbase/mkspecs/lynxos-g++/qplatformdefs.h b/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
+index 4339ea2b23..6007af0055 100644
+--- a/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
+@@ -72,14 +72,6 @@
+ 
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp b/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
+index c3c184258f..32af3f8f29 100644
+--- a/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
++++ b/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
+@@ -10,6 +10,7 @@
+ #include "libANGLE/HandleAllocator.h"
+ 
+ #include <algorithm>
++#include <limits>
+ 
+ #include "common/debug.h"
+ 
+diff --git a/qtbase/src/3rdparty/forkfd/forkfd_linux.c b/qtbase/src/3rdparty/forkfd/forkfd_linux.c
+index ffe0e9a5e2..b1f5408d11 100644
+--- a/qtbase/src/3rdparty/forkfd/forkfd_linux.c
++++ b/qtbase/src/3rdparty/forkfd/forkfd_linux.c
+@@ -82,7 +82,8 @@ static int sys_clone(unsigned long cloneflags, int *ptid)
+     return syscall(__NR_clone, cloneflags, child_stack, stack_size, ptid, newtls, ctid);
+ #elif defined(__arc__) || defined(__arm__) || defined(__aarch64__) || defined(__mips__) || \
+     defined(__nds32__) || defined(__hppa__) || defined(__powerpc__) || defined(__i386__) || \
+-    defined(__x86_64__) || defined(__xtensa__) || defined(__alpha__) || defined(__riscv)
++    defined(__x86_64__) || defined(__xtensa__) || defined(__alpha__) || defined(__riscv) || \
++    defined(__loongarch__)
+     /* ctid and newtls are inverted on CONFIG_CLONE_BACKWARDS architectures,
+      * but since both values are 0, there's no harm. */
+     return syscall(__NR_clone, cloneflags, child_stack, ptid, ctid, newtls);
+diff --git a/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java b/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
+index 5792b5b2f5..2f74750fcf 100644
+--- a/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
++++ b/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
+@@ -116,6 +116,7 @@ public class QtNative
+     public static QtThread m_qtThread = new QtThread();
+     private static HashMap<String, Uri> m_cachedUris = new HashMap<String, Uri>();
+     private static ArrayList<String> m_knownDirs = new ArrayList<String>();
++    private static final String NoPermissionErrorMessage = "No permissions to open Uri";
+ 
+     private static final Runnable runPendingCppRunnablesRunnable = new Runnable() {
+         @Override
+@@ -193,11 +194,10 @@ public class QtNative
+                     return iterUri;
+             }
+ 
+-            // Android 6 and earlier could still manage to open the file so we can return the
+-            // parsed uri here
+-            if (Build.VERSION.SDK_INT < 24)
+-                return parsedUri;
+-            return null;
++            // if we only have transient permissions on uri all the above will fail,
++            // but we will be able to read the file anyway, so continue with uri here anyway
++            // and check for SecurityExceptions later
++            return parsedUri;
+         } catch (SecurityException e) {
+             e.printStackTrace();
+             return null;
+@@ -244,7 +244,7 @@ public class QtNative
+         int error = -1;
+ 
+         if (uri == null) {
+-            Log.e(QtTAG, "openFdForContentUrl(): No permissions to open Uri");
++            Log.e(QtTAG, "openFdForContentUrl(): " + NoPermissionErrorMessage);
+             return error;
+         }
+ 
+@@ -254,12 +254,13 @@ public class QtNative
+             return fdDesc.detachFd();
+         } catch (FileNotFoundException e) {
+             e.printStackTrace();
+-            return error;
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "openFdForContentUrl(): Invalid Uri");
+             e.printStackTrace();
+-            return error;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return error;
+     }
+ 
+     public static long getSize(Context context, String contentUrl)
+@@ -270,7 +271,7 @@ public class QtNative
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+ 
+         if (uri == null) {
+-            Log.e(QtTAG, "getSize(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return size;
+         } else if (!m_cachedUris.containsKey(contentUrl)) {
+             m_cachedUris.put(contentUrl, uri);
+@@ -288,12 +289,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "getSize(): Invalid Uri");
+             e.printStackTrace();
+-            return size;
+         }  catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "getSize(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return size;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return size;
+     }
+ 
+     public static boolean checkFileExists(Context context, String contentUrl)
+@@ -303,7 +305,7 @@ public class QtNative
+         if (uri == null)
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+         if (uri == null) {
+-            Log.e(QtTAG, "checkFileExists(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return exists;
+         } else {
+             if (!m_cachedUris.containsKey(contentUrl))
+@@ -321,12 +323,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "checkFileExists(): Invalid Uri");
+             e.printStackTrace();
+-            return exists;
+         } catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "checkFileExists(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return false;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return exists;
+     }
+ 
+     public static boolean checkIfWritable(Context context, String contentUrl)
+@@ -344,7 +347,7 @@ public class QtNative
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+         }
+         if (uri == null) {
+-            Log.e(QtTAG, "isDir(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return isDir;
+         } else {
+             if (!m_cachedUris.containsKey(contentUrl))
+@@ -374,12 +377,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "checkIfDir(): Invalid Uri");
+             e.printStackTrace();
+-            return false;
+         } catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "checkIfDir(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return false;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return false;
+     }
+     public static String[] listContentsFromTreeUri(Context context, String contentUrl)
+     {
+diff --git a/qtbase/src/concurrent/qtconcurrentreducekernel.h b/qtbase/src/concurrent/qtconcurrentreducekernel.h
+index 8f9a938952..a98dedef2e 100644
+--- a/qtbase/src/concurrent/qtconcurrentreducekernel.h
++++ b/qtbase/src/concurrent/qtconcurrentreducekernel.h
+@@ -212,11 +212,13 @@ public:
+ 
+     inline bool shouldThrottle()
+     {
++        std::lock_guard<QMutex> locker(mutex);
+         return (resultsMapSize > (ReduceQueueThrottleLimit * threadCount));
+     }
+ 
+     inline bool shouldStartThread()
+     {
++        std::lock_guard<QMutex> locker(mutex);
+         return (resultsMapSize <= (ReduceQueueStartLimit * threadCount));
+     }
+ };
+diff --git a/qtbase/src/concurrent/qtconcurrentthreadengine.cpp b/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
+index ea6ce3ac42..7f91a2ba68 100644
+--- a/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
++++ b/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
+@@ -176,6 +176,39 @@ void ThreadEngineBase::startSingleThreaded()
+     finish();
+ }
+ 
++void ThreadEngineBase::startBlocking()
++{
++    start();
++    barrier.acquire();
++    startThreads();
++
++    bool throttled = false;
++#ifndef QT_NO_EXCEPTIONS
++    try {
++#endif
++        while (threadFunction() == ThrottleThread) {
++            if (threadThrottleExit()) {
++                throttled = true;
++                break;
++            }
++        }
++#ifndef QT_NO_EXCEPTIONS
++    } catch (QException &e) {
++        handleException(e);
++    } catch (...) {
++        handleException(QUnhandledException());
++    }
++#endif
++
++    if (throttled == false) {
++        barrier.release();
++    }
++
++    barrier.wait();
++    finish();
++    exceptionStore.throwPossibleException();
++}
++
+ void ThreadEngineBase::startThread()
+ {
+     startThreadInternal();
+diff --git a/qtbase/src/concurrent/qtconcurrentthreadengine.h b/qtbase/src/concurrent/qtconcurrentthreadengine.h
+index 7c30cebdbc..a4c8548cc4 100644
+--- a/qtbase/src/concurrent/qtconcurrentthreadengine.h
++++ b/qtbase/src/concurrent/qtconcurrentthreadengine.h
+@@ -91,6 +91,7 @@ public:
+     ThreadEngineBase();
+     virtual ~ThreadEngineBase();
+     void startSingleThreaded();
++    void startBlocking();
+     void startThread();
+     bool isCanceled();
+     void waitForResume();
+@@ -143,6 +144,15 @@ public:
+         return result();
+     }
+ 
++    // Runs the user algorithm using multiple threads.
++    // This function blocks until the algorithm is finished,
++    // and then returns the result.
++    T *startBlocking()
++    {
++        ThreadEngineBase::startBlocking();
++        return result();
++    }
++
+     // Runs the user algorithm using multiple threads.
+     // Does not block, returns a future.
+     QFuture<T> startAsynchronously()
+@@ -223,6 +233,13 @@ class ThreadEngineStarter : public ThreadEngineStarterBase<T>
+ public:
+     ThreadEngineStarter(TypedThreadEngine *eng)
+         : Base(eng) { }
++
++    T startBlocking()
++    {
++        T t = *this->threadEngine->startBlocking();
++        delete this->threadEngine;
++        return t;
++    }
+ };
+ 
+ // Full template specialization where T is void.
+@@ -232,6 +249,12 @@ class ThreadEngineStarter<void> : public ThreadEngineStarterBase<void>
+ public:
+     ThreadEngineStarter(ThreadEngine<void> *_threadEngine)
+         : ThreadEngineStarterBase<void>(_threadEngine) {}
++
++    void startBlocking()
++    {
++        this->threadEngine->startBlocking();
++        delete this->threadEngine;
++    }
+ };
+ 
+ //! [qtconcurrentthreadengine-1]
+diff --git a/qtbase/src/corelib/animation/qvariantanimation.cpp b/qtbase/src/corelib/animation/qvariantanimation.cpp
+index 98b02f0202..eac1524107 100644
+--- a/qtbase/src/corelib/animation/qvariantanimation.cpp
++++ b/qtbase/src/corelib/animation/qvariantanimation.cpp
+@@ -276,7 +276,9 @@ void QVariantAnimationPrivate::setCurrentValueForProgress(const qreal progress)
+ 
+     const qreal startProgress = currentInterval.start.first;
+     const qreal endProgress = currentInterval.end.first;
+-    const qreal localProgress = (progress - startProgress) / (endProgress - startProgress);
++    const qreal localProgress =
++            qIsNull(progress - startProgress) ? 0.0 // avoid 0/0 below
++            /* else */                        : (progress - startProgress) / (endProgress - startProgress);
+ 
+     QVariant ret = q->interpolated(currentInterval.start.second,
+                                    currentInterval.end.second,
+diff --git a/qtbase/src/corelib/global/qnamespace.h b/qtbase/src/corelib/global/qnamespace.h
+index ad4150b317..bf19b1627b 100644
+--- a/qtbase/src/corelib/global/qnamespace.h
++++ b/qtbase/src/corelib/global/qnamespace.h
+@@ -1864,7 +1864,7 @@ public:
+     QT_Q_ENUM(TimerType)
+     QT_Q_ENUM(ScrollPhase)
+     QT_Q_ENUM(MouseEventSource)
+-    QT_Q_FLAG(MouseEventFlag)
++    QT_Q_FLAG(MouseEventFlags)
+     QT_Q_ENUM(ChecksumType)
+     QT_Q_ENUM(HighDpiScaleFactorRoundingPolicy)
+     QT_Q_ENUM(TabFocusBehavior)
+diff --git a/qtbase/src/corelib/global/qrandom.cpp b/qtbase/src/corelib/global/qrandom.cpp
+index 10672c1f92..25f87c7e6a 100644
+--- a/qtbase/src/corelib/global/qrandom.cpp
++++ b/qtbase/src/corelib/global/qrandom.cpp
+@@ -383,7 +383,6 @@ struct QRandomGenerator::SystemAndGlobalGenerators
+ 
+         constexpr SystemAndGlobalGenerators g = {};
+         Q_UNUSED(g);
+-        Q_STATIC_ASSERT(std::is_literal_type<SystemAndGlobalGenerators>::value);
+ #endif
+     }
+ 
+diff --git a/qtbase/src/corelib/io/qbuffer.cpp b/qtbase/src/corelib/io/qbuffer.cpp
+index 595fcd2724..032c0ddd4b 100644
+--- a/qtbase/src/corelib/io/qbuffer.cpp
++++ b/qtbase/src/corelib/io/qbuffer.cpp
+@@ -41,6 +41,8 @@
+ #include <QtCore/qmetaobject.h>
+ #include "private/qiodevice_p.h"
+ 
++#include <limits>
++
+ QT_BEGIN_NAMESPACE
+ 
+ /** QBufferPrivate **/
+@@ -366,7 +368,9 @@ qint64 QBuffer::size() const
+ bool QBuffer::seek(qint64 pos)
+ {
+     Q_D(QBuffer);
+-    if (pos > d->buf->size() && isWritable()) {
++    const auto oldBufSize = d->buf->size();
++    constexpr qint64 MaxSeekPos = (std::numeric_limits<decltype(oldBufSize)>::max)();
++    if (pos <= MaxSeekPos && pos > oldBufSize && isWritable()) {
+         if (seek(d->buf->size())) {
+             const qint64 gapSize = pos - d->buf->size();
+             if (write(QByteArray(gapSize, 0)) != gapSize) {
+@@ -377,7 +381,7 @@ bool QBuffer::seek(qint64 pos)
+             return false;
+         }
+     } else if (pos > d->buf->size() || pos < 0) {
+-        qWarning("QBuffer::seek: Invalid pos: %d", int(pos));
++        qWarning("QBuffer::seek: Invalid pos: %lld", pos);
+         return false;
+     }
+     return QIODevice::seek(pos);
+diff --git a/qtbase/src/corelib/io/qfilesystemengine_win.cpp b/qtbase/src/corelib/io/qfilesystemengine_win.cpp
+index 81d3a71986..c86ed1f9b0 100644
+--- a/qtbase/src/corelib/io/qfilesystemengine_win.cpp
++++ b/qtbase/src/corelib/io/qfilesystemengine_win.cpp
+@@ -664,14 +664,14 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry)
+     return QFileSystemEntry(ret, QFileSystemEntry::FromInternalPath());
+ }
+ 
+-#if defined(Q_CC_MINGW) && WINVER < 0x0602 //  Windows 8 onwards
++#if defined(Q_CC_MINGW) && WINVER < 0x0602 && _WIN32_WINNT < _WIN32_WINNT_WIN8 //  Windows 8 onwards
+ 
+ typedef struct _FILE_ID_INFO {
+     ULONGLONG VolumeSerialNumber;
+     FILE_ID_128 FileId;
+ } FILE_ID_INFO, *PFILE_ID_INFO;
+ 
+-#endif // if defined (Q_CC_MINGW) && WINVER < 0x0602
++#endif // if defined(Q_CC_MINGW) && WINVER < 0x0602 && _WIN32_WINNT < _WIN32_WINNT_WIN8
+ 
+ // File ID for Windows up to version 7 and FAT32 drives
+ static inline QByteArray fileId(HANDLE handle)
+diff --git a/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp b/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
+index 94d9d06bcb..27e0b13b0b 100644
+--- a/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
++++ b/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
+@@ -366,7 +366,9 @@ void QInotifyFileSystemWatcherEngine::readFromInotify()
+     // qDebug("QInotifyFileSystemWatcherEngine::readFromInotify");
+ 
+     int buffSize = 0;
+-    ioctl(inotifyFd, FIONREAD, (char *) &buffSize);
++    if (ioctl(inotifyFd, FIONREAD, (char *) &buffSize) == -1 || buffSize == 0)
++        return;
++
+     QVarLengthArray<char, 4096> buffer(buffSize);
+     buffSize = read(inotifyFd, buffer.data(), buffSize);
+     char *at = buffer.data();
+diff --git a/qtbase/src/corelib/io/qlockfile_win.cpp b/qtbase/src/corelib/io/qlockfile_win.cpp
+index 277f8d4230..38ecef5550 100644
+--- a/qtbase/src/corelib/io/qlockfile_win.cpp
++++ b/qtbase/src/corelib/io/qlockfile_win.cpp
+@@ -48,6 +48,8 @@
+ #include "QtCore/qdebug.h"
+ #include "QtCore/qthread.h"
+ 
++#include "private/qsystemlibrary_p.h"
++
+ QT_BEGIN_NAMESPACE
+ 
+ static inline bool fileExists(const wchar_t *fileName)
+@@ -150,7 +152,7 @@ QString QLockFilePrivate::processNameByPid(qint64 pid)
+ #if !defined(Q_OS_WINRT)
+     typedef DWORD (WINAPI *GetModuleFileNameExFunc)(HANDLE, HMODULE, LPTSTR, DWORD);
+ 
+-    HMODULE hPsapi = LoadLibraryA("psapi");
++    HMODULE hPsapi = QSystemLibrary::load(L"psapi");
+     if (!hPsapi)
+         return QString();
+     GetModuleFileNameExFunc qGetModuleFileNameEx = reinterpret_cast<GetModuleFileNameExFunc>(
+diff --git a/qtbase/src/corelib/io/qprocess_unix.cpp b/qtbase/src/corelib/io/qprocess_unix.cpp
+index 50390e57f5..15c8f30745 100644
+--- a/qtbase/src/corelib/io/qprocess_unix.cpp
++++ b/qtbase/src/corelib/io/qprocess_unix.cpp
+@@ -1,7 +1,7 @@
+ /****************************************************************************
+ **
+ ** Copyright (C) 2016 The Qt Company Ltd.
+-** Copyright (C) 2016 Intel Corporation.
++** Copyright (C) 2022 Intel Corporation.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtCore module of the Qt Toolkit.
+@@ -422,14 +422,15 @@ void QProcessPrivate::startProcess()
+     // Add the program name to the argument list.
+     argv[0] = nullptr;
+     if (!program.contains(QLatin1Char('/'))) {
++        // findExecutable() returns its argument if it's an absolute path,
++        // otherwise it searches $PATH; returns empty if not found (we handle
++        // that case much later)
+         const QString &exeFilePath = QStandardPaths::findExecutable(program);
+-        if (!exeFilePath.isEmpty()) {
+-            const QByteArray &tmp = QFile::encodeName(exeFilePath);
+-            argv[0] = ::strdup(tmp.constData());
+-        }
+-    }
+-    if (!argv[0])
++        const QByteArray &tmp = QFile::encodeName(exeFilePath);
++        argv[0] = ::strdup(tmp.constData());
++    } else {
+         argv[0] = ::strdup(encodedProgramName.constData());
++    }
+ 
+     // Add every argument to the list
+     for (int i = 0; i < arguments.count(); ++i)
+@@ -983,15 +984,16 @@ bool QProcessPrivate::startDetached(qint64 *pid)
+                 envp = _q_dupEnvironment(environment.d.constData()->vars, &envc);
+             }
+ 
+-            QByteArray tmp;
+             if (!program.contains(QLatin1Char('/'))) {
++                // findExecutable() returns its argument if it's an absolute path,
++                // otherwise it searches $PATH; returns empty if not found (we handle
++                // that case much later)
+                 const QString &exeFilePath = QStandardPaths::findExecutable(program);
+-                if (!exeFilePath.isEmpty())
+-                    tmp = QFile::encodeName(exeFilePath);
++                const QByteArray &tmp = QFile::encodeName(exeFilePath);
++                argv[0] = ::strdup(tmp.constData());
++            } else {
++                argv[0] = ::strdup(QFile::encodeName(program));
+             }
+-            if (tmp.isEmpty())
+-                tmp = QFile::encodeName(program);
+-            argv[0] = tmp.data();
+ 
+             if (envp)
+                 qt_safe_execve(argv[0], argv, envp);
+diff --git a/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp b/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
+index 3a79c502af..997a634e76 100644
+--- a/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
++++ b/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
+@@ -3196,9 +3196,8 @@ bool QAbstractItemModel::beginMoveColumns(const QModelIndex &sourceParent, int s
+     destinationChange.needsAdjust = destinationParent.isValid() && destinationParent.row() >= sourceLast && destinationParent.parent() == sourceParent;
+     d->changes.push(destinationChange);
+ 
+-    d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Horizontal);
+-
+     emit columnsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, QPrivateSignal());
++    d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Horizontal);
+     return true;
+ }
+ 
+@@ -3231,7 +3230,6 @@ void QAbstractItemModel::endMoveColumns()
+       adjustedSource = createIndex(adjustedSource.row(), adjustedSource.column() + numMoved, adjustedSource.internalPointer());
+ 
+     d->itemsMoved(adjustedSource, removeChange.first, removeChange.last, adjustedDestination, insertChange.first, Qt::Horizontal);
+-
+     emit columnsMoved(adjustedSource, removeChange.first, removeChange.last, adjustedDestination, insertChange.first, QPrivateSignal());
+ }
+ 
+diff --git a/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+index dc6379d9fb..c5e287ee84 100644
+--- a/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
++++ b/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+@@ -939,8 +939,9 @@ void QSortFilterProxyModelPrivate::insert_source_items(
+                 q->beginInsertColumns(proxy_parent, proxy_start, proxy_end);
+         }
+ 
+-        for (int i = 0; i < source_items.size(); ++i)
+-            proxy_to_source.insert(proxy_start + i, source_items.at(i));
++        // TODO: use the range QList::insert() overload once it is implemented (QTBUG-58633).
++        proxy_to_source.insert(proxy_start, source_items.size(), 0);
++        std::copy(source_items.cbegin(), source_items.cend(), proxy_to_source.begin() + proxy_start);
+ 
+         build_source_to_proxy_mapping(proxy_to_source, source_to_proxy);
+ 
+@@ -3123,8 +3124,9 @@ bool QSortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex &
+ 
+     if (d->filter_data.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();
+@@ -3133,9 +3135,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.hasMatch(key);
+ }
+diff --git a/qtbase/src/corelib/kernel/qcoreapplication.cpp b/qtbase/src/corelib/kernel/qcoreapplication.cpp
+index ca2864df83..132b2eae52 100644
+--- a/qtbase/src/corelib/kernel/qcoreapplication.cpp
++++ b/qtbase/src/corelib/kernel/qcoreapplication.cpp
+@@ -1157,7 +1157,7 @@ static bool doNotify(QObject *receiver, QEvent *event)
+ bool QCoreApplicationPrivate::sendThroughApplicationEventFilters(QObject *receiver, QEvent *event)
+ {
+     // We can't access the application event filters outside of the main thread (race conditions)
+-    Q_ASSERT(receiver->d_func()->threadData.loadRelaxed()->thread.loadAcquire() == mainThread());
++    Q_ASSERT(receiver->d_func()->threadData.loadAcquire()->thread.loadRelaxed() == mainThread());
+ 
+     if (extraData) {
+         // application event filters are only called for objects in the GUI thread
+diff --git a/qtbase/src/corelib/kernel/qobject.cpp b/qtbase/src/corelib/kernel/qobject.cpp
+index 1eb79138d9..36cd780ee1 100644
+--- a/qtbase/src/corelib/kernel/qobject.cpp
++++ b/qtbase/src/corelib/kernel/qobject.cpp
+@@ -1010,7 +1010,7 @@ QObject::~QObject()
+         emit destroyed(this);
+     }
+ 
+-    if (d->declarativeData) {
++    if (!d->isDeletingChildren && d->declarativeData) {
+         if (static_cast<QAbstractDeclarativeDataImpl*>(d->declarativeData)->ownedByQml1) {
+             if (QAbstractDeclarativeData::destroyed_qml1)
+                 QAbstractDeclarativeData::destroyed_qml1(d->declarativeData, this);
+@@ -1580,7 +1580,7 @@ void QObject::moveToThread(QThread *targetThread)
+ 
+     QThreadData *currentData = QThreadData::current();
+     QThreadData *targetData = targetThread ? QThreadData::get2(targetThread) : nullptr;
+-    QThreadData *thisThreadData = d->threadData.loadRelaxed();
++    QThreadData *thisThreadData = d->threadData.loadAcquire();
+     if (!thisThreadData->thread.loadAcquire() && currentData == targetData) {
+         // one exception to the rule: we allow moving objects with no thread affinity to the current thread
+         currentData = d->threadData;
+@@ -2620,7 +2620,7 @@ int QObject::receivers(const char *signal) const
+         if (!d->isSignalConnected(signal_index))
+             return receivers;
+ 
+-        if (d->declarativeData && QAbstractDeclarativeData::receivers) {
++        if (!d->isDeletingChildren && d->declarativeData && QAbstractDeclarativeData::receivers) {
+             receivers += QAbstractDeclarativeData::receivers(d->declarativeData, this,
+                                                              signal_index);
+         }
+diff --git a/qtbase/src/corelib/kernel/qobject_p.h b/qtbase/src/corelib/kernel/qobject_p.h
+index 0b827a52ca..13ffb88999 100644
+--- a/qtbase/src/corelib/kernel/qobject_p.h
++++ b/qtbase/src/corelib/kernel/qobject_p.h
+@@ -444,7 +444,7 @@ inline void QObjectPrivate::checkForIncompatibleLibraryVersion(int version) cons
+ 
+ inline bool QObjectPrivate::isDeclarativeSignalConnected(uint signal_index) const
+ {
+-    return declarativeData && QAbstractDeclarativeData::isSignalConnected
++    return !isDeletingChildren && declarativeData && QAbstractDeclarativeData::isSignalConnected
+             && QAbstractDeclarativeData::isSignalConnected(declarativeData, q_func(), signal_index);
+ }
+ 
+diff --git a/qtbase/src/corelib/kernel/qtranslator.cpp b/qtbase/src/corelib/kernel/qtranslator.cpp
+index 2812ffb7ea..bc0177c5ec 100644
+--- a/qtbase/src/corelib/kernel/qtranslator.cpp
++++ b/qtbase/src/corelib/kernel/qtranslator.cpp
+@@ -902,7 +902,7 @@ static QString getMessage(const uchar *m, const uchar *end, const char *context,
+             goto end;
+         case Tag_Translation: {
+             int len = read32(m);
+-            if (len % 1)
++            if (len & 1)
+                 return QString();
+             m += 4;
+             if (!numerus--) {
+diff --git a/qtbase/src/corelib/mimetypes/qmimedatabase.cpp b/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
+index 9de22cef33..ff868a3268 100644
+--- a/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
+@@ -389,20 +389,23 @@ QMimeType QMimeDatabasePrivate::mimeTypeForFileNameAndData(const QString &fileNa
+         // Disambiguate conflicting extensions (if magic matching found something)
+         if (candidateByData.isValid() && magicAccuracy > 0) {
+             const QString sniffedMime = candidateByData.name();
+-            // If the sniffedMime matches a glob match, use it
++            // If the sniffedMime matches a highest-weight glob match, use it
+             if (candidatesByName.m_matchingMimeTypes.contains(sniffedMime)) {
+                 *accuracyPtr = 100;
+                 return candidateByData;
+             }
+-            for (const QString &m : qAsConst(candidatesByName.m_matchingMimeTypes)) {
++            for (const QString &m : qAsConst(candidatesByName.m_allMatchingMimeTypes)) {
+                 if (inherits(m, sniffedMime)) {
+                     // We have magic + pattern pointing to this, so it's a pretty good match
+                     *accuracyPtr = 100;
+                     return mimeTypeForName(m);
+                 }
+             }
+-            *accuracyPtr = magicAccuracy;
+-            return candidateByData;
++            if (candidatesByName.m_allMatchingMimeTypes.isEmpty()) {
++                // No glob, use magic
++                *accuracyPtr = magicAccuracy;
++                return candidateByData;
++            }
+         }
+     }
+ 
+diff --git a/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp b/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
+index a81112d227..fa8f4c545d 100644
+--- a/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
+@@ -83,7 +83,10 @@ void QMimeGlobMatchResult::addMatch(const QString &mimeType, int weight, const Q
+     }
+     if (!m_matchingMimeTypes.contains(mimeType)) {
+         m_matchingMimeTypes.append(mimeType);
+-        m_allMatchingMimeTypes.append(mimeType);
++        if (replace)
++            m_allMatchingMimeTypes.prepend(mimeType); // highest-weight first
++        else
++            m_allMatchingMimeTypes.append(mimeType);
+         m_knownSuffixLength = knownSuffixLength;
+     }
+ }
+@@ -94,7 +97,7 @@ QMimeGlobPattern::PatternType QMimeGlobPattern::detectPatternType(const QString
+     if (!patternLength)
+         return OtherPattern;
+ 
+-    const bool starCount = pattern.count(QLatin1Char('*')) == 1;
++    const int starCount = pattern.count(QLatin1Char('*'));
+     const bool hasSquareBracket = pattern.indexOf(QLatin1Char('[')) != -1;
+     const bool hasQuestionMark = pattern.indexOf(QLatin1Char('?')) != -1;
+ 
+@@ -106,10 +109,10 @@ QMimeGlobPattern::PatternType QMimeGlobPattern::detectPatternType(const QString
+             // Patterns like "README*" (well this is currently the only one like that...)
+             if (pattern.at(patternLength - 1) == QLatin1Char('*'))
+                 return PrefixPattern;
+-        }
+-        // Names without any wildcards like "README"
+-        if (starCount == 0)
++        } else if (starCount == 0) {
++            // Names without any wildcards like "README"
+             return LiteralPattern;
++        }
+     }
+ 
+     if (pattern == QLatin1String("[0-9][0-9][0-9].vdr"))
+diff --git a/qtbase/src/corelib/mimetypes/qmimeprovider.cpp b/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
+index 258dddf8cb..4642d0f2d0 100644
+--- a/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
+@@ -244,15 +244,18 @@ void QMimeBinaryProvider::addFileNameMatches(const QString &fileName, QMimeGlobM
+     const QString lowerFileName = fileName.toLower();
+     // Check literals (e.g. "Makefile")
+     matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosLiteralListOffset), fileName);
+-    // Check complex globs (e.g. "callgrind.out[0-9]*")
+-    matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosGlobListOffset), fileName);
+     // Check the very common *.txt cases with the suffix tree
+-    const int reverseSuffixTreeOffset = m_cacheFile->getUint32(PosReverseSuffixTreeOffset);
+-    const int numRoots = m_cacheFile->getUint32(reverseSuffixTreeOffset);
+-    const int firstRootOffset = m_cacheFile->getUint32(reverseSuffixTreeOffset + 4);
+-    matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, lowerFileName, lowerFileName.length() - 1, false);
++    if (result.m_matchingMimeTypes.isEmpty()) {
++        const int reverseSuffixTreeOffset = m_cacheFile->getUint32(PosReverseSuffixTreeOffset);
++        const int numRoots = m_cacheFile->getUint32(reverseSuffixTreeOffset);
++        const int firstRootOffset = m_cacheFile->getUint32(reverseSuffixTreeOffset + 4);
++        matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, lowerFileName, lowerFileName.length() - 1, false);
++        if (result.m_matchingMimeTypes.isEmpty())
++            matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, fileName, fileName.length() - 1, true);
++    }
++    // Check complex globs (e.g. "callgrind.out[0-9]*" or "README*")
+     if (result.m_matchingMimeTypes.isEmpty())
+-        matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, fileName, fileName.length() - 1, true);
++        matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosGlobListOffset), fileName);
+ }
+ 
+ void QMimeBinaryProvider::matchGlobList(QMimeGlobMatchResult &result, CacheFile *cacheFile, int off, const QString &fileName)
+diff --git a/qtbase/src/corelib/serialization/qjsonparser.cpp b/qtbase/src/corelib/serialization/qjsonparser.cpp
+index 17e6f111ab..2e40b6c8fb 100644
+--- a/qtbase/src/corelib/serialization/qjsonparser.cpp
++++ b/qtbase/src/corelib/serialization/qjsonparser.cpp
+@@ -379,10 +379,30 @@ error:
+     return QCborValue();
+ }
+ 
++// We need to retain the _last_ value for any duplicate keys and we need to deref containers.
++// Therefore the manual implementation of std::unique().
++template<typename Iterator, typename Compare, typename Assign>
++static Iterator customAssigningUniqueLast(Iterator first, Iterator last,
++                                          Compare compare, Assign assign)
++{
++    first = std::adjacent_find(first, last, compare);
++    if (first == last)
++        return last;
++
++    Iterator result = first;
++    while (++first != last) {
++        if (!compare(*result, *first))
++            ++result;
++        if (result != first)
++            assign(*result, *first);
++    }
++
++    return ++result;
++}
++
+ static void sortContainer(QCborContainerPrivate *container)
+ {
+     using Forward = QJsonPrivate::KeyIterator;
+-    using Reverse = std::reverse_iterator<Forward>;
+     using Value = Forward::value_type;
+ 
+     auto compare = [container](const Value &a, const Value &b)
+@@ -420,17 +440,31 @@ static void sortContainer(QCborContainerPrivate *container)
+         }
+     };
+ 
+-    std::sort(Forward(container->elements.begin()), Forward(container->elements.end()),
+-              [&compare](const Value &a, const Value &b) { return compare(a, b) < 0; });
++    // The elements' containers are owned by the outer container, not by the elements themselves.
++    auto move = [](Forward::reference target, Forward::reference source)
++    {
++        QtCbor::Element &targetValue = target.value();
++
++        // If the target has a container, deref it before overwriting, so that we don't leak.
++        if (targetValue.flags & QtCbor::Element::IsContainer)
++            targetValue.container->deref();
++
++        // Do not move, so that we can clear the value afterwards.
++        target = source;
++
++        // Clear the source value, so that we don't store the same container twice.
++        source.value() = QtCbor::Element();
++    };
++
++    std::stable_sort(
++                Forward(container->elements.begin()), Forward(container->elements.end()),
++                [&compare](const Value &a, const Value &b) { return compare(a, b) < 0; });
+ 
+-    // We need to retain the _last_ value for any duplicate keys. Therefore the reverse dance here.
+-    auto it = std::unique(Reverse(container->elements.end()), Reverse(container->elements.begin()),
+-                          [&compare](const Value &a, const Value &b) {
+-        return compare(a, b) == 0;
+-    }).base().elementsIterator();
++    Forward result = customAssigningUniqueLast(
++                Forward(container->elements.begin()),  Forward(container->elements.end()),
++                [&compare](const Value &a, const Value &b) { return compare(a, b) == 0; }, move);
+ 
+-    // The erase from beginning is expensive but hopefully rare.
+-    container->elements.erase(container->elements.begin(), it);
++    container->elements.erase(result.elementsIterator(), container->elements.end());
+ }
+ 
+ 
+diff --git a/qtbase/src/corelib/serialization/qxmlstream.cpp b/qtbase/src/corelib/serialization/qxmlstream.cpp
+index b2f846544d..7cd457ba3a 100644
+--- a/qtbase/src/corelib/serialization/qxmlstream.cpp
++++ b/qtbase/src/corelib/serialization/qxmlstream.cpp
+@@ -980,7 +980,7 @@ inline uint QXmlStreamReaderPrivate::peekChar()
+ bool QXmlStreamReaderPrivate::scanUntil(const char *str, short tokenToInject)
+ {
+     int pos = textBuffer.size();
+-    int oldLineNumber = lineNumber;
++    const auto oldLineNumber = lineNumber;
+ 
+     uint c;
+     while ((c = getChar()) != StreamEOF) {
+diff --git a/qtbase/src/corelib/text/qstring.cpp b/qtbase/src/corelib/text/qstring.cpp
+index 3e88ab4859..8deeae47bb 100644
+--- a/qtbase/src/corelib/text/qstring.cpp
++++ b/qtbase/src/corelib/text/qstring.cpp
+@@ -12312,7 +12312,7 @@ static qsizetype qLastIndexOf(Haystack haystack0, qsizetype from,
+     const auto needle = needle0.data();
+     const auto *end = haystack;
+     haystack += from;
+-    const std::size_t sl_minus_1 = sl - 1;
++    const std::size_t sl_minus_1 = sl ? sl - 1 : 0;
+     const auto *n = needle + sl_minus_1;
+     const auto *h = haystack + sl_minus_1;
+     std::size_t hashNeedle = 0, hashHaystack = 0;
+diff --git a/qtbase/src/corelib/text/qstringiterator_p.h b/qtbase/src/corelib/text/qstringiterator_p.h
+index 219589b6e4..1d0c66cc78 100644
+--- a/qtbase/src/corelib/text/qstringiterator_p.h
++++ b/qtbase/src/corelib/text/qstringiterator_p.h
+@@ -61,6 +61,8 @@ class QStringIterator
+ {
+     QString::const_iterator i, pos, e;
+     Q_STATIC_ASSERT((std::is_same<QString::const_iterator, const QChar *>::value));
++    static bool less(const QChar *lhs, const QChar *rhs) noexcept
++    { return std::less<QString::const_iterator>{}(lhs, rhs); }
+ public:
+     explicit QStringIterator(QStringView string, qsizetype idx = 0)
+         : i(string.begin()),
+@@ -95,7 +97,8 @@ public:
+ 
+     inline void setPosition(QString::const_iterator position)
+     {
+-        Q_ASSERT_X(i <= position && position <= e, Q_FUNC_INFO, "position out of bounds");
++        Q_ASSERT_X(!less(position, i) && !less(e, position),
++                   Q_FUNC_INFO, "position out of bounds");
+         pos = position;
+     }
+ 
+@@ -103,7 +106,7 @@ public:
+ 
+     inline bool hasNext() const
+     {
+-        return pos < e;
++        return less(pos, e);
+     }
+ 
+     inline void advance()
+@@ -120,16 +123,20 @@ public:
+     {
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+-        if (Q_UNLIKELY((pos++)->isHighSurrogate()))
++        if (Q_UNLIKELY((pos++)->isHighSurrogate())) {
++            Q_ASSERT(hasNext() && pos->isLowSurrogate());
+             ++pos;
++        }
+     }
+ 
+     inline uint peekNextUnchecked() const
+     {
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+-        if (Q_UNLIKELY(pos->isHighSurrogate()))
++        if (Q_UNLIKELY(pos->isHighSurrogate())) {
++            Q_ASSERT(less(pos + 1, e) && pos[1].isLowSurrogate());
+             return QChar::surrogateToUcs4(pos[0], pos[1]);
++        }
+ 
+         return pos->unicode();
+     }
+@@ -155,8 +162,10 @@ public:
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+         const QChar cur = *pos++;
+-        if (Q_UNLIKELY(cur.isHighSurrogate()))
++        if (Q_UNLIKELY(cur.isHighSurrogate())) {
++            Q_ASSERT(hasNext() && pos->isLowSurrogate());
+             return QChar::surrogateToUcs4(cur, *pos++);
++        }
+         return cur.unicode();
+     }
+ 
+@@ -166,7 +175,7 @@ public:
+ 
+         const QChar uc = *pos++;
+         if (Q_UNLIKELY(uc.isSurrogate())) {
+-            if (Q_LIKELY(uc.isHighSurrogate() && pos < e && pos->isLowSurrogate()))
++            if (Q_LIKELY(uc.isHighSurrogate() && hasNext() && pos->isLowSurrogate()))
+                 return QChar::surrogateToUcs4(uc, *pos++);
+             return invalidAs;
+         }
+@@ -178,7 +187,7 @@ public:
+ 
+     inline bool hasPrevious() const
+     {
+-        return pos > i;
++        return less(i, pos);
+     }
+ 
+     inline void recede()
+@@ -196,16 +205,20 @@ public:
+     {
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+-        if (Q_UNLIKELY((--pos)->isLowSurrogate()))
++        if (Q_UNLIKELY((--pos)->isLowSurrogate())) {
++            Q_ASSERT(hasPrevious() && pos[-1].isHighSurrogate());
+             --pos;
++        }
+     }
+ 
+     inline uint peekPreviousUnchecked() const
+     {
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+-        if (Q_UNLIKELY(pos[-1].isLowSurrogate()))
++        if (Q_UNLIKELY(pos[-1].isLowSurrogate())) {
++            Q_ASSERT(less(i + 1, pos) && pos[-2].isHighSurrogate());
+             return QChar::surrogateToUcs4(pos[-2], pos[-1]);
++        }
+         return pos[-1].unicode();
+     }
+ 
+@@ -230,8 +243,10 @@ public:
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+         const QChar cur = *--pos;
+-        if (Q_UNLIKELY(cur.isLowSurrogate()))
++        if (Q_UNLIKELY(cur.isLowSurrogate())) {
++            Q_ASSERT(hasPrevious() && pos[-1].isHighSurrogate());
+             return QChar::surrogateToUcs4(*--pos, cur);
++        }
+         return cur.unicode();
+     }
+ 
+@@ -241,7 +256,7 @@ public:
+ 
+         const QChar uc = *--pos;
+         if (Q_UNLIKELY(uc.isSurrogate())) {
+-            if (Q_LIKELY(uc.isLowSurrogate() && pos > i && pos[-1].isHighSurrogate()))
++            if (Q_LIKELY(uc.isLowSurrogate() && hasPrevious() && pos[-1].isHighSurrogate()))
+                 return QChar::surrogateToUcs4(*--pos, uc);
+             return invalidAs;
+         }
+diff --git a/qtbase/src/corelib/thread/qfutex_p.h b/qtbase/src/corelib/thread/qfutex_p.h
+index f287b752d7..e294537787 100644
+--- a/qtbase/src/corelib/thread/qfutex_p.h
++++ b/qtbase/src/corelib/thread/qfutex_p.h
+@@ -52,6 +52,7 @@
+ //
+ 
+ #include <qglobal.h>
++#include <QtCore/qtsan_impl.h>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -106,16 +107,13 @@ namespace QtLinuxFutex {
+     inline int _q_futex(int *addr, int op, int val, quintptr val2 = 0,
+                         int *addr2 = nullptr, int val3 = 0) noexcept
+     {
+-        // A futex call ensures total ordering on the futex words
+-        // (in either success or failure of the call). Instruct TSAN accordingly,
+-        // as TSAN does not understand the futex(2) syscall.
+-        _q_tsan_release(addr, addr2);
++        QtTsan::futexRelease(addr, addr2);
+ 
+         // we use __NR_futex because some libcs (like Android's bionic) don't
+         // provide SYS_futex etc.
+         int result = syscall(__NR_futex, addr, op | FUTEX_PRIVATE_FLAG, val, val2, addr2, val3);
+ 
+-        _q_tsan_acquire(addr, addr2);
++        QtTsan::futexAcquire(addr, addr2);
+ 
+         return result;
+     }
+diff --git a/qtbase/src/corelib/thread/qmutex.cpp b/qtbase/src/corelib/thread/qmutex.cpp
+index 310d1cb14f..7097122d8e 100644
+--- a/qtbase/src/corelib/thread/qmutex.cpp
++++ b/qtbase/src/corelib/thread/qmutex.cpp
+@@ -152,6 +152,7 @@ public:
+ 
+ /*!
+     \enum QMutex::RecursionMode
++    \obsolete Use QRecursiveMutex to create a recursive mutex.
+ 
+     \value Recursive  In this mode, a thread can lock the same mutex
+                       multiple times and the mutex won't be unlocked
+@@ -173,6 +174,7 @@ public:
+ 
+ /*!
+     Constructs a new mutex. The mutex is created in an unlocked state.
++    \obsolete Use QRecursiveMutex to create a recursive mutex.
+ 
+     If \a mode is QMutex::Recursive, a thread can lock the same mutex
+     multiple times and the mutex won't be unlocked until a
+@@ -197,7 +199,7 @@ QMutex::QMutex(RecursionMode mode)
+ QMutex::~QMutex()
+ {
+     QMutexData *d = d_ptr.loadRelaxed();
+-    if (isRecursive()) {
++    if (QBasicMutex::isRecursive()) {
+         delete static_cast<QRecursiveMutexPrivate *>(d);
+     } else if (d) {
+ #ifndef QT_LINUX_FUTEX
+diff --git a/qtbase/src/corelib/thread/qmutex.h b/qtbase/src/corelib/thread/qmutex.h
+index 73c9e00663..1bae573a03 100644
+--- a/qtbase/src/corelib/thread/qmutex.h
++++ b/qtbase/src/corelib/thread/qmutex.h
+@@ -42,6 +42,7 @@
+ 
+ #include <QtCore/qglobal.h>
+ #include <QtCore/qatomic.h>
++#include <QtCore/qtsan_impl.h>
+ #include <new>
+ 
+ #if __has_include(<chrono>)
+@@ -77,19 +78,37 @@ public:
+ 
+     // BasicLockable concept
+     inline void lock() QT_MUTEX_LOCK_NOEXCEPT {
++        QtTsan::mutexPreLock(this, 0u);
++
+         if (!fastTryLock())
+             lockInternal();
++
++        QtTsan::mutexPostLock(this, 0u, 0);
+     }
+ 
+     // BasicLockable concept
+     inline void unlock() noexcept {
+         Q_ASSERT(d_ptr.loadRelaxed()); //mutex must be locked
++
++        QtTsan::mutexPreUnlock(this, 0u);
++
+         if (!fastTryUnlock())
+             unlockInternal();
++
++        QtTsan::mutexPostUnlock(this, 0u);
+     }
+ 
+     bool tryLock() noexcept {
+-        return fastTryLock();
++        unsigned tsanFlags = QtTsan::TryLock;
++        QtTsan::mutexPreLock(this, tsanFlags);
++
++        const bool success = fastTryLock();
++
++        if (!success)
++            tsanFlags |= QtTsan::TryLockFailed;
++        QtTsan::mutexPostLock(this, tsanFlags, 0);
++
++        return success;
+     }
+ 
+     // Lockable concept
+@@ -134,8 +153,16 @@ public:
+ #else
+     QMutex() { d_ptr.storeRelaxed(nullptr); }
+ #endif
++#if QT_DEPRECATED_SINCE(5,15)
+     enum RecursionMode { NonRecursive, Recursive };
++    QT_DEPRECATED_VERSION_X(5, 15, "Use QRecursiveMutex instead of a recursive QMutex")
+     explicit QMutex(RecursionMode mode);
++
++    QT_DEPRECATED_VERSION_X(5, 15, "Use QRecursiveMutex instead of a recursive QMutex")
++    bool isRecursive() const noexcept
++    { return QBasicMutex::isRecursive(); }
++#endif
++
+     ~QMutex();
+ 
+     // BasicLockable concept
+@@ -166,9 +193,6 @@ public:
+     }
+ #endif
+ 
+-    bool isRecursive() const noexcept
+-    { return QBasicMutex::isRecursive(); }
+-
+ private:
+     Q_DISABLE_COPY(QMutex)
+     friend class QMutexLocker;
+diff --git a/qtbase/src/corelib/thread/qreadwritelock.cpp b/qtbase/src/corelib/thread/qreadwritelock.cpp
+index 8c28507d5a..9dd8503116 100644
+--- a/qtbase/src/corelib/thread/qreadwritelock.cpp
++++ b/qtbase/src/corelib/thread/qreadwritelock.cpp
+@@ -155,7 +155,7 @@ QReadWriteLock::QReadWriteLock(RecursionMode recursionMode)
+ */
+ QReadWriteLock::~QReadWriteLock()
+ {
+-    auto d = d_ptr.loadRelaxed();
++    auto d = d_ptr.loadAcquire();
+     if (isUncontendedLocked(d)) {
+         qWarning("QReadWriteLock: destroying locked QReadWriteLock");
+         return;
+@@ -445,7 +445,7 @@ void QReadWriteLock::unlock()
+ /*! \internal  Helper for QWaitCondition::wait */
+ QReadWriteLock::StateForWaitCondition QReadWriteLock::stateForWaitCondition() const
+ {
+-    QReadWriteLockPrivate *d = d_ptr.loadRelaxed();
++    QReadWriteLockPrivate *d = d_ptr.loadAcquire();
+     switch (quintptr(d) & StateMask) {
+     case StateLockedForRead: return LockedForRead;
+     case StateLockedForWrite: return LockedForWrite;
+@@ -453,6 +453,7 @@ QReadWriteLock::StateForWaitCondition QReadWriteLock::stateForWaitCondition() co
+ 
+     if (!d)
+         return Unlocked;
++    const auto lock = qt_scoped_lock(d->mutex);
+     if (d->writerCount > 1)
+         return RecursivelyLocked;
+     else if (d->writerCount == 1)
+diff --git a/qtbase/src/corelib/thread/qsemaphore.cpp b/qtbase/src/corelib/thread/qsemaphore.cpp
+index 1d01fc1b28..3ecdee3747 100644
+--- a/qtbase/src/corelib/thread/qsemaphore.cpp
++++ b/qtbase/src/corelib/thread/qsemaphore.cpp
+@@ -354,7 +354,12 @@ void QSemaphore::release(int n)
+         quintptr nn = unsigned(n);
+         if (futexHasWaiterCount)
+             nn |= quint64(nn) << 32;    // token count replicated in high word
+-        quintptr prevValue = u.fetchAndAddRelease(nn);
++        quintptr prevValue = u.loadRelaxed();
++        quintptr newValue;
++        do { // loop just to ensure the operations are done atomically
++            newValue = prevValue + nn;
++            newValue &= (futexNeedsWakeAllBit - 1);
++        } while (!u.testAndSetRelease(prevValue, newValue, prevValue));
+         if (futexNeedsWake(prevValue)) {
+ #ifdef FUTEX_OP
+             if (futexHasWaiterCount) {
+@@ -376,7 +381,6 @@ void QSemaphore::release(int n)
+                 quint32 oparg = 0;
+                 quint32 cmp = FUTEX_OP_CMP_NE;
+                 quint32 cmparg = 0;
+-                u.fetchAndAndRelease(futexNeedsWakeAllBit - 1);
+                 futexWakeOp(*futexLow32(&u), n, INT_MAX, *futexHigh32(&u), FUTEX_OP(op, oparg, cmp, cmparg));
+                 return;
+             }
+@@ -388,7 +392,6 @@ 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(futexNeedsWakeAllBit - 1);
+             if (futexHasWaiterCount) {
+                 futexWakeAll(*futexLow32(&u));
+                 futexWakeAll(*futexHigh32(&u));
+diff --git a/qtbase/src/corelib/thread/qthread_p.h b/qtbase/src/corelib/thread/qthread_p.h
+index b2d1628e6e..f32f6f0460 100644
+--- a/qtbase/src/corelib/thread/qthread_p.h
++++ b/qtbase/src/corelib/thread/qthread_p.h
+@@ -174,7 +174,7 @@ public:
+     int returnCode;
+ 
+     uint stackSize;
+-    QThread::Priority priority;
++    std::underlying_type<QThread::Priority>::type priority;
+ 
+     static QThread *threadForId(int id);
+ 
+@@ -213,6 +213,13 @@ public:
+             QCoreApplication::instance()->postEvent(q_ptr, new QEvent(QEvent::Quit));
+         }
+     }
++
++#ifndef Q_OS_INTEGRITY
++private:
++    // Used in QThread(Private)::start to avoid racy access to QObject::objectName,
++    // unset afterwards. On INTEGRITY we set the thread name before starting it.
++    QString objectName;
++#endif
+ };
+ 
+ #else // QT_CONFIG(thread)
+diff --git a/qtbase/src/corelib/thread/qthread_unix.cpp b/qtbase/src/corelib/thread/qthread_unix.cpp
+index 56a8e0a038..610117a640 100644
+--- a/qtbase/src/corelib/thread/qthread_unix.cpp
++++ b/qtbase/src/corelib/thread/qthread_unix.cpp
+@@ -169,8 +169,7 @@ static void set_thread_data(QThreadData *data)
+ 
+ static void clear_thread_data()
+ {
+-    currentThreadData = nullptr;
+-    pthread_setspecific(current_thread_data_key, nullptr);
++    set_thread_data(nullptr);
+ }
+ 
+ template <typename T>
+@@ -296,7 +295,7 @@ void *QThreadPrivate::start(void *arg)
+             QMutexLocker locker(&thr->d_func()->mutex);
+ 
+             // do we need to reset the thread priority?
+-            if (int(thr->d_func()->priority) & ThreadPriorityResetFlag) {
++            if (thr->d_func()->priority & ThreadPriorityResetFlag) {
+                 thr->d_func()->setPriority(QThread::Priority(thr->d_func()->priority & ~ThreadPriorityResetFlag));
+             }
+ 
+@@ -316,10 +315,10 @@ void *QThreadPrivate::start(void *arg)
+             // Sets the name of the current thread. We can only do this
+             // when the thread is starting, as we don't have a cross
+             // platform way of setting the name of an arbitrary thread.
+-            if (Q_LIKELY(thr->objectName().isEmpty()))
++            if (Q_LIKELY(thr->d_func()->objectName.isEmpty()))
+                 setCurrentThreadName(thr->metaObject()->className());
+             else
+-                setCurrentThreadName(thr->objectName().toLocal8Bit());
++                setCurrentThreadName(std::exchange(thr->d_func()->objectName, {}).toLocal8Bit());
+         }
+ #endif
+ 
+@@ -671,7 +670,7 @@ void QThread::start(Priority priority)
+                 // could not set scheduling hints, fallback to inheriting them
+                 // we'll try again from inside the thread
+                 pthread_attr_setinheritsched(&attr, PTHREAD_INHERIT_SCHED);
+-                d->priority = Priority(priority | ThreadPriorityResetFlag);
++                d->priority = static_cast<std::underlying_type<QThread::Priority>::type>(priority) | ThreadPriorityResetFlag;
+             }
+             break;
+         }
+@@ -702,7 +701,10 @@ void QThread::start(Priority priority)
+         pthread_attr_setthreadname(&attr, metaObject()->className());
+     else
+         pthread_attr_setthreadname(&attr, objectName().toLocal8Bit());
++#else
++    d->objectName = objectName();
+ #endif
++
+     pthread_t threadId;
+     int code = pthread_create(&threadId, &attr, QThreadPrivate::start, this);
+     if (code == EPERM) {
+diff --git a/qtbase/src/corelib/thread/qthread_win.cpp b/qtbase/src/corelib/thread/qthread_win.cpp
+index bc70e3178a..4e76972498 100644
+--- a/qtbase/src/corelib/thread/qthread_win.cpp
++++ b/qtbase/src/corelib/thread/qthread_win.cpp
+@@ -394,10 +394,9 @@ unsigned int __stdcall QT_ENSURE_STACK_ALIGNED_FOR_SSE QThreadPrivate::start(voi
+ 
+ #if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) && !defined(Q_OS_WINRT)
+     // sets the name of the current thread.
+-    QByteArray objectName = thr->objectName().toLocal8Bit();
+-    qt_set_thread_name(HANDLE(-1),
+-                       objectName.isEmpty() ?
+-                       thr->metaObject()->className() : objectName.constData());
++    qt_set_thread_name(HANDLE(-1), thr->d_func()->objectName.isEmpty()
++                        ? thr->metaObject()->className()
++                        : std::exchange(thr->d_func()->objectName, {}).toLocal8Bit().constData());
+ #endif
+ 
+     emit thr->started(QThread::QPrivateSignal());
+@@ -503,6 +502,7 @@ void QThread::start(Priority priority)
+     if (d->running)
+         return;
+ 
++    d->objectName = objectName();
+     d->running = true;
+     d->finished = false;
+     d->exited = false;
+@@ -548,7 +548,7 @@ void QThread::start(Priority priority)
+ 
+     int prio;
+     d->priority = priority;
+-    switch (d->priority) {
++    switch (priority) {
+     case IdlePriority:
+         prio = THREAD_PRIORITY_IDLE;
+         break;
+@@ -686,7 +686,7 @@ void QThreadPrivate::setPriority(QThread::Priority threadPriority)
+ 
+     int prio;
+     priority = threadPriority;
+-    switch (priority) {
++    switch (threadPriority) {
+     case QThread::IdlePriority:
+         prio = THREAD_PRIORITY_IDLE;
+         break;
+diff --git a/qtbase/src/corelib/thread/qtsan_impl.h b/qtbase/src/corelib/thread/qtsan_impl.h
+new file mode 100644
+index 0000000000..580a738b91
+--- /dev/null
++++ b/qtbase/src/corelib/thread/qtsan_impl.h
+@@ -0,0 +1,115 @@
++/****************************************************************************
++**
++** Copyright (C) 2017 Intel Corporation.
++** Copyright (C) 2022 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
++** 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 QTSAN_IMPL_H
++#define QTSAN_IMPL_H
++
++#include <QtCore/qglobal.h>
++
++#if (__has_feature(thread_sanitizer) || defined(__SANITIZE_THREAD__)) && __has_include(<sanitizer/tsan_interface.h>)
++#  define QT_BUILDING_UNDER_TSAN
++#  include <sanitizer/tsan_interface.h>
++#endif
++
++QT_BEGIN_NAMESPACE
++
++namespace QtTsan {
++#ifdef QT_BUILDING_UNDER_TSAN
++inline void futexAcquire(void *addr, void *addr2 = nullptr)
++{
++    // A futex call ensures total ordering on the futex words
++    // (in either success or failure of the call). Instruct TSAN accordingly,
++    // as TSAN does not understand the futex(2) syscall (or equivalent).
++    ::__tsan_acquire(addr);
++    if (addr2)
++        ::__tsan_acquire(addr2);
++}
++
++inline void futexRelease(void *addr, void *addr2 = nullptr)
++{
++    if (addr2)
++        ::__tsan_release(addr2);
++    ::__tsan_release(addr);
++}
++
++inline void mutexPreLock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_pre_lock(addr, flags);
++}
++
++inline void mutexPostLock(void *addr, unsigned flags, int recursion)
++{
++    ::__tsan_mutex_post_lock(addr, flags, recursion);
++}
++
++inline void mutexPreUnlock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_pre_unlock(addr, flags);
++}
++
++inline void mutexPostUnlock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_post_unlock(addr, flags);
++}
++
++enum : unsigned {
++    MutexWriteReentrant = ::__tsan_mutex_write_reentrant,
++    TryLock = ::__tsan_mutex_try_lock,
++    TryLockFailed = ::__tsan_mutex_try_lock_failed,
++};
++#else
++inline void futexAcquire(void *, void * = nullptr) {}
++inline void futexRelease(void *, void * = nullptr) {}
++
++enum : unsigned {
++    MutexWriteReentrant,
++    TryLock,
++    TryLockFailed,
++};
++inline void mutexPreLock(void *, unsigned) {}
++inline void mutexPostLock(void *, unsigned, int) {}
++inline void mutexPreUnlock(void *, unsigned) {}
++inline void mutexPostUnlock(void *, unsigned) {}
++#endif // QT_BUILDING_UNDER_TSAN
++} // namespace QtTsan
++
++QT_END_NAMESPACE
++
++#endif // QTSAN_IMPL_H
+diff --git a/qtbase/src/corelib/thread/qwaitcondition_unix.cpp b/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
+index 88b058f410..0f1da4dc9b 100644
+--- a/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
++++ b/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
+@@ -213,7 +213,7 @@ bool QWaitCondition::wait(QMutex *mutex, QDeadlineTimer deadline)
+ {
+     if (! mutex)
+         return false;
+-    if (mutex->isRecursive()) {
++    if (static_cast<QBasicMutex *>(mutex)->isRecursive()) {
+         qWarning("QWaitCondition: cannot wait on recursive mutexes");
+         return false;
+     }
+diff --git a/qtbase/src/corelib/time/qdatetime.cpp b/qtbase/src/corelib/time/qdatetime.cpp
+index ec12569e3f..2c0b098079 100644
+--- a/qtbase/src/corelib/time/qdatetime.cpp
++++ b/qtbase/src/corelib/time/qdatetime.cpp
+@@ -43,6 +43,7 @@
+ #if QT_CONFIG(datetimeparser)
+ #include "private/qdatetimeparser_p.h"
+ #endif
++#include <private/qnumeric_p.h>
+ 
+ #include "qdatastream.h"
+ #include "qset.h"
+@@ -1429,9 +1430,11 @@ QDate QDate::addDays(qint64 ndays) const
+     if (isNull())
+         return QDate();
+ 
+-    // Due to limits on minJd() and maxJd() we know that any overflow
+-    // will be invalid and caught by fromJulianDay().
+-    return fromJulianDay(jd + ndays);
++    qint64 r;
++    if (Q_UNLIKELY(add_overflow(jd, ndays, &r)))
++        return QDate();
++    else
++        return fromJulianDay(r);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/corelib/time/qtimezone.cpp b/qtbase/src/corelib/time/qtimezone.cpp
+index 0309e43e52..3d451696a1 100644
+--- a/qtbase/src/corelib/time/qtimezone.cpp
++++ b/qtbase/src/corelib/time/qtimezone.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2013 John Layt <jlayt@kde.org>
++** Copyright (C) 2020 John Layt <jlayt@kde.org>
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtCore module of the Qt Toolkit.
+@@ -975,9 +975,15 @@ QList<QByteArray> QTimeZone::windowsIdToIanaIds(const QByteArray &windowsId,
+ }
+ 
+ #ifndef QT_NO_DATASTREAM
++// Invalid, as an IANA ID: too long, starts with - and has other invalid characters in it
++static inline QString invalidId() { return QStringLiteral("-No Time Zone Specified!"); }
++
+ QDataStream &operator<<(QDataStream &ds, const QTimeZone &tz)
+ {
+-    tz.d->serialize(ds);
++    if (tz.isValid())
++        tz.d->serialize(ds);
++    else
++        ds << invalidId();
+     return ds;
+ }
+ 
+@@ -985,7 +991,9 @@ QDataStream &operator>>(QDataStream &ds, QTimeZone &tz)
+ {
+     QString ianaId;
+     ds >> ianaId;
+-    if (ianaId == QLatin1String("OffsetFromUtc")) {
++    if (ianaId == invalidId()) {
++        tz = QTimeZone();
++    } else if (ianaId == QLatin1String("OffsetFromUtc")) {
+         int utcOffset;
+         QString name;
+         QString abbreviation;
+diff --git a/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp b/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
+index b1611d7ddb..a7a6a72ccf 100644
+--- a/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
++++ b/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
+@@ -42,6 +42,7 @@
+ #include "qtimezone.h"
+ #include "qtimezoneprivate_p.h"
+ #include "private/qlocale_tools_p.h"
++#include "private/qlocking_p.h"
+ 
+ #include <QtCore/QDataStream>
+ #include <QtCore/QDateTime>
+@@ -62,6 +63,10 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++#if QT_CONFIG(icu)
++static QBasicMutex s_icu_mutex;
++#endif
++
+ /*
+     Private
+ 
+@@ -670,6 +675,9 @@ QTzTimeZonePrivate::~QTzTimeZonePrivate()
+ 
+ QTzTimeZonePrivate *QTzTimeZonePrivate::clone() const
+ {
++#if QT_CONFIG(icu)
++    const auto lock = qt_scoped_lock(s_icu_mutex);
++#endif
+     return new QTzTimeZonePrivate(*this);
+ }
+ 
+@@ -913,12 +921,14 @@ QString QTzTimeZonePrivate::displayName(qint64 atMSecsSinceEpoch,
+                                         const QLocale &locale) const
+ {
+ #if QT_CONFIG(icu)
++    auto lock = qt_unique_lock(s_icu_mutex);
+     if (!m_icu)
+         m_icu = new QIcuTimeZonePrivate(m_id);
+     // TODO small risk may not match if tran times differ due to outdated files
+     // TODO Some valid TZ names are not valid ICU names, use translation table?
+     if (m_icu->isValid())
+         return m_icu->displayName(atMSecsSinceEpoch, nameType, locale);
++    lock.unlock();
+ #else
+     Q_UNUSED(nameType)
+     Q_UNUSED(locale)
+@@ -932,12 +942,14 @@ QString QTzTimeZonePrivate::displayName(QTimeZone::TimeType timeType,
+                                         const QLocale &locale) const
+ {
+ #if QT_CONFIG(icu)
++    auto lock = qt_unique_lock(s_icu_mutex);
+     if (!m_icu)
+         m_icu = new QIcuTimeZonePrivate(m_id);
+     // TODO small risk may not match if tran times differ due to outdated files
+     // TODO Some valid TZ names are not valid ICU names, use translation table?
+     if (m_icu->isValid())
+         return m_icu->displayName(timeType, nameType, locale);
++    lock.unlock();
+ #else
+     Q_UNUSED(timeType)
+     Q_UNUSED(nameType)
+diff --git a/qtbase/src/corelib/tools/qarraydata.h b/qtbase/src/corelib/tools/qarraydata.h
+index dcd95924c1..d01739e7e6 100644
+--- a/qtbase/src/corelib/tools/qarraydata.h
++++ b/qtbase/src/corelib/tools/qarraydata.h
+@@ -42,6 +42,7 @@
+ 
+ #include <QtCore/qrefcount.h>
+ #include <string.h>
++#include <cstdint>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -58,14 +59,14 @@ struct Q_CORE_EXPORT QArrayData
+     {
+         Q_ASSERT(size == 0
+                 || offset < 0 || size_t(offset) >= sizeof(QArrayData));
+-        return reinterpret_cast<char *>(this) + offset;
++        return reinterpret_cast<void *> (reinterpret_cast<uintptr_t>(this) + offset);
+     }
+ 
+     const void *data() const
+     {
+         Q_ASSERT(size == 0
+                 || offset < 0 || size_t(offset) >= sizeof(QArrayData));
+-        return reinterpret_cast<const char *>(this) + offset;
++        return reinterpret_cast<void *> (reinterpret_cast<uintptr_t>(this) + offset);
+     }
+ 
+     // This refers to array data mutability, not "header data" represented by
+diff --git a/qtbase/src/corelib/tools/qfreelist_p.h b/qtbase/src/corelib/tools/qfreelist_p.h
+index 5ba23b344b..9974102136 100644
+--- a/qtbase/src/corelib/tools/qfreelist_p.h
++++ b/qtbase/src/corelib/tools/qfreelist_p.h
+@@ -161,7 +161,7 @@ class QFreeList
+                 return i;
+             x -= size;
+         }
+-        Q_ASSERT(false);
++        Q_UNREACHABLE();
+         return -1;
+     }
+ 
+diff --git a/qtbase/src/corelib/tools/qversionnumber.h b/qtbase/src/corelib/tools/qversionnumber.h
+index d43b86ba51..2843f2b043 100644
+--- a/qtbase/src/corelib/tools/qversionnumber.h
++++ b/qtbase/src/corelib/tools/qversionnumber.h
+@@ -273,10 +273,10 @@ public:
+ 
+     Q_REQUIRED_RESULT Q_CORE_EXPORT QString toString() const;
+ #if QT_STRINGVIEW_LEVEL < 2
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(const QString &string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(const QString &string, int *suffixIndex = nullptr);
+ #endif
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QLatin1String string, int *suffixIndex = nullptr);
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QStringView string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(QLatin1String string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(QStringView string, int *suffixIndex = nullptr);
+ 
+ private:
+ #ifndef QT_NO_DATASTREAM
+diff --git a/qtbase/src/dbus/qdbusintegrator.cpp b/qtbase/src/dbus/qdbusintegrator.cpp
+index 5b66ce971b..28a3b0ffea 100644
+--- a/qtbase/src/dbus/qdbusintegrator.cpp
++++ b/qtbase/src/dbus/qdbusintegrator.cpp
+@@ -1135,7 +1135,13 @@ void QDBusConnectionPrivate::closeConnection()
+         }
+     }
+ 
+-    qDeleteAll(pendingCalls);
++    for (auto it = pendingCalls.begin(); it != pendingCalls.end(); ++it) {
++        auto call = *it;
++        if (!call->ref.deref()) {
++            delete call;
++        }
++    }
++    pendingCalls.clear();
+ 
+     // Disconnect all signals from signal hooks and from the object tree to
+     // avoid QObject::destroyed being sent to dbus daemon thread which has
+@@ -2584,6 +2590,11 @@ QDBusConnectionPrivate::findMetaObject(const QString &service, const QString &pa
+         if (mo)
+             return mo;
+     }
++    if (path.isEmpty()) {
++        error = QDBusError(QDBusError::InvalidObjectPath, QLatin1String("Object path cannot be empty"));
++        lastError = error;
++        return nullptr;
++    }
+ 
+     // introspect the target object
+     QDBusMessage msg = QDBusMessage::createMethodCall(service, path,
+diff --git a/qtbase/src/dbus/qdbusmetaobject.cpp b/qtbase/src/dbus/qdbusmetaobject.cpp
+index 5265568f42..7e9f0f1acc 100644
+--- a/qtbase/src/dbus/qdbusmetaobject.cpp
++++ b/qtbase/src/dbus/qdbusmetaobject.cpp
+@@ -210,6 +210,9 @@ QDBusMetaObjectGenerator::findType(const QByteArray &signature,
+         } else if (signature == "a{ss}") {
+             result.name = "QMap<QString,QString>";
+             type = qMetaTypeId<QMap<QString, QString> >();
++        } else if (signature == "aay") {
++            result.name = "QByteArrayList";
++            type = qMetaTypeId<QByteArrayList>();
+         } else {
+             result.name = "{D-Bus type \"" + signature + "\"}";
+             type = registerComplexDBusType(result.name);
+diff --git a/qtbase/src/gui/accessible/qaccessible.cpp b/qtbase/src/gui/accessible/qaccessible.cpp
+index d705bfccb5..0caf3c808c 100644
+--- a/qtbase/src/gui/accessible/qaccessible.cpp
++++ b/qtbase/src/gui/accessible/qaccessible.cpp
+@@ -54,6 +54,7 @@
+ #include <QtCore/qdebug.h>
+ #include <QtCore/qloggingcategory.h>
+ #include <QtCore/qmetaobject.h>
++#include <QtCore/private/qmetaobject_p.h>
+ #include <QtCore/qhash.h>
+ #include <private/qfactoryloader_p.h>
+ 
+@@ -681,6 +682,25 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
+     // Create a QAccessibleInterface for the object class. Start by the most
+     // derived class and walk up the class hierarchy.
+     const QMetaObject *mo = object->metaObject();
++    const auto *objectPriv = QObjectPrivate::get(object);
++    /*
++     We do not want to cache each and every QML metaobject (Button_QMLTYPE_124,
++     Button_QMLTYPE_125, etc.). Those dynamic metaobjects shouldn't have an
++     accessible interface in any case. Instead, we start the whole checking
++     with the first non-dynamic meta-object. To avoid potential regressions
++     in other areas of Qt that also use dynamic metaobjects, we only do this
++     for objects that are QML-related (approximated by checking whether they
++     have ddata set).
++    */
++    const bool qmlRelated = !objectPriv->isDeletingChildren &&
++                            objectPriv->declarativeData;
++    while (qmlRelated && mo) {
++        auto mop = QMetaObjectPrivate::get(mo);
++        if (!mop || !(mop->flags & DynamicMetaObject))
++            break;
++
++        mo = mo->superClass();
++    };
+     while (mo) {
+         const QString cn = QLatin1String(mo->className());
+ 
+@@ -696,14 +716,15 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
+         // Find a QAccessiblePlugin (factory) for the class name. If there's
+         // no entry in the cache try to create it using the plugin loader.
+         if (!qAccessiblePlugins()->contains(cn)) {
++            QAccessiblePlugin *factory = nullptr; // 0 means "no plugin found". This is cached as well.
+             const int index = loader()->indexOf(cn);
+-            if (index != -1) {
+-                QAccessiblePlugin *factory = qobject_cast<QAccessiblePlugin *>(loader()->instance(index));
+-                qAccessiblePlugins()->insert(cn, factory);
+-            }
++            if (index != -1)
++                factory = qobject_cast<QAccessiblePlugin *>(loader()->instance(index));
++            qAccessiblePlugins()->insert(cn, factory);
+         }
+ 
+         // At this point the cache should contain a valid factory pointer or 0:
++        Q_ASSERT(qAccessiblePlugins()->contains(cn));
+         QAccessiblePlugin *factory = qAccessiblePlugins()->value(cn);
+         if (factory) {
+             QAccessibleInterface *result = factory->create(cn, object);
+diff --git a/qtbase/src/gui/configure.json b/qtbase/src/gui/configure.json
+index 1f08795c57..12c95742d2 100644
+--- a/qtbase/src/gui/configure.json
++++ b/qtbase/src/gui/configure.json
+@@ -834,7 +834,8 @@
+                     "// embedded devices, are not intended to be used together with X. EGL support",
+                     "// has to be disabled in plugins like xcb in this case since the native display,",
+                     "// window and pixmap types will be different than what an X-based platform",
+-                    "// plugin would expect."
++                    "// plugin would expect.",
++                    "#define USE_X11"
+                 ],
+                 "include": [ "EGL/egl.h", "X11/Xlib.h" ],
+                 "main": [
+diff --git a/qtbase/src/gui/image/qbmphandler.cpp b/qtbase/src/gui/image/qbmphandler.cpp
+index 96f1e8cb1d..0e73bbbdb0 100644
+--- a/qtbase/src/gui/image/qbmphandler.cpp
++++ b/qtbase/src/gui/image/qbmphandler.cpp
+@@ -150,16 +150,42 @@ static QDataStream &operator<<(QDataStream &s, const BMP_INFOHDR &bi)
+     return s;
+ }
+ 
+-static int calc_shift(uint mask)
++static uint calc_shift(uint mask)
+ {
+-    int result = 0;
+-    while (mask && !(mask & 1)) {
++    uint result = 0;
++    while ((mask >= 0x100) || (!(mask & 1) && mask)) {
+         result++;
+         mask >>= 1;
+     }
+     return result;
+ }
+ 
++static uint calc_scale(uint low_mask)
++{
++    uint result = 8;
++    while (low_mask && result) {
++        result--;
++        low_mask >>= 1;
++    }
++    return result;
++}
++
++static inline uint apply_scale(uint value, uint scale)
++{
++    if (!(scale & 0x07)) // return immediately if scale == 8 or 0
++        return value;
++
++    uint filled = 8 - scale;
++    uint result = value << scale;
++
++    do {
++        result |= result >> filled;
++        filled <<= 1;
++    } while (filled < 8);
++
++    return result;
++}
++
+ static bool read_dib_fileheader(QDataStream &s, BMP_FILEHDR &bf)
+ {
+     // read BMP file header
+@@ -222,14 +248,14 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+     uint green_mask = 0;
+     uint blue_mask = 0;
+     uint alpha_mask = 0;
+-    int red_shift = 0;
+-    int green_shift = 0;
+-    int blue_shift = 0;
+-    int alpha_shift = 0;
+-    int red_scale = 0;
+-    int green_scale = 0;
+-    int blue_scale = 0;
+-    int alpha_scale = 0;
++    uint red_shift = 0;
++    uint green_shift = 0;
++    uint blue_shift = 0;
++    uint alpha_shift = 0;
++    uint red_scale = 0;
++    uint green_scale = 0;
++    uint blue_scale = 0;
++    uint alpha_scale = 0;
+ 
+     if (!d->isSequential())
+         d->seek(startpos + BMP_FILEHDR_SIZE + bi.biSize); // goto start of colormap or masks
+@@ -308,19 +334,19 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+         red_shift = calc_shift(red_mask);
+         if (((red_mask >> red_shift) + 1) == 0)
+             return false;
+-        red_scale = 256 / ((red_mask >> red_shift) + 1);
++        red_scale = calc_scale(red_mask >> red_shift);
+         green_shift = calc_shift(green_mask);
+         if (((green_mask >> green_shift) + 1) == 0)
+             return false;
+-        green_scale = 256 / ((green_mask >> green_shift) + 1);
++        green_scale = calc_scale(green_mask >> green_shift);
+         blue_shift = calc_shift(blue_mask);
+         if (((blue_mask >> blue_shift) + 1) == 0)
+             return false;
+-        blue_scale = 256 / ((blue_mask >> blue_shift) + 1);
++        blue_scale = calc_scale(blue_mask >> blue_shift);
+         alpha_shift = calc_shift(alpha_mask);
+         if (((alpha_mask >> alpha_shift) + 1) == 0)
+             return false;
+-        alpha_scale = 256 / ((alpha_mask >> alpha_shift) + 1);
++        alpha_scale = calc_scale(alpha_mask >> alpha_shift);
+     } else if (comp == BMP_RGB && (nbits == 24 || nbits == 32)) {
+         blue_mask = 0x000000ff;
+         green_mask = 0x0000ff00;
+@@ -328,17 +354,15 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+         blue_shift = 0;
+         green_shift = 8;
+         red_shift = 16;
+-        blue_scale = green_scale = red_scale = 1;
++        blue_scale = green_scale = red_scale = 0;
+     } else if (comp == BMP_RGB && nbits == 16) {
+         blue_mask = 0x001f;
+         green_mask = 0x03e0;
+         red_mask = 0x7c00;
+         blue_shift = 0;
+-        green_shift = 2;
+-        red_shift = 7;
+-        red_scale = 1;
+-        green_scale = 1;
+-        blue_scale = 8;
++        green_shift = 5;
++        red_shift = 10;
++        blue_scale = green_scale = red_scale = 3;
+     }
+ 
+ #if 0
+@@ -544,10 +568,10 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+                     c |= *(uchar*)(b+2)<<16;
+                 if (nbits > 24)
+                     c |= *(uchar*)(b+3)<<24;
+-                *p++ = qRgba(((c & red_mask) >> red_shift) * red_scale,
+-                                        ((c & green_mask) >> green_shift) * green_scale,
+-                                        ((c & blue_mask) >> blue_shift) * blue_scale,
+-                                        transp ? ((c & alpha_mask) >> alpha_shift) * alpha_scale : 0xff);
++                *p++ = qRgba(apply_scale((c & red_mask) >> red_shift, red_scale),
++                             apply_scale((c & green_mask) >> green_shift, green_scale),
++                             apply_scale((c & blue_mask) >> blue_shift, blue_scale),
++                             transp ? apply_scale((c & alpha_mask) >> alpha_shift, alpha_scale) : 0xff);
+                 b += nbits/8;
+             }
+         }
+diff --git a/qtbase/src/gui/image/qimage.cpp b/qtbase/src/gui/image/qimage.cpp
+index 7152ac1607..0df772564c 100644
+--- a/qtbase/src/gui/image/qimage.cpp
++++ b/qtbase/src/gui/image/qimage.cpp
+@@ -4694,6 +4694,8 @@ QImage QImage::smoothScaled(int w, int h) const {
+ static QImage rotated90(const QImage &image)
+ {
+     QImage out(image.height(), image.width(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+@@ -4722,6 +4724,8 @@ static QImage rotated180(const QImage &image)
+         return image.mirrored(true, true);
+ 
+     QImage out(image.width(), image.height(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+@@ -4734,6 +4738,8 @@ static QImage rotated180(const QImage &image)
+ static QImage rotated270(const QImage &image)
+ {
+     QImage out(image.height(), image.width(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+diff --git a/qtbase/src/gui/kernel/qcursor.cpp b/qtbase/src/gui/kernel/qcursor.cpp
+index d6ccaff8ed..455088241c 100644
+--- a/qtbase/src/gui/kernel/qcursor.cpp
++++ b/qtbase/src/gui/kernel/qcursor.cpp
+@@ -251,7 +251,8 @@ void QCursor::setPos(QScreen *screen, int x, int y)
+ {
+     if (screen) {
+         if (QPlatformCursor *cursor = screen->handle()->cursor()) {
+-            const QPoint devicePos = QHighDpi::toNativePixels(QPoint(x, y), screen);
++            const QPoint pos(x, y);
++            const QPoint devicePos = QHighDpi::toNativePixels(pos, screen->virtualSiblingAt(pos));
+             // Need to check, since some X servers generate null mouse move
+             // events, causing looping in applications which call setPos() on
+             // every mouse move event.
+diff --git a/qtbase/src/gui/kernel/qhighdpiscaling.cpp b/qtbase/src/gui/kernel/qhighdpiscaling.cpp
+index 9bbf2773a9..3ac4a4d8b6 100644
+--- a/qtbase/src/gui/kernel/qhighdpiscaling.cpp
++++ b/qtbase/src/gui/kernel/qhighdpiscaling.cpp
+@@ -580,9 +580,8 @@ void QHighDpiScaling::setScreenFactor(QScreen *screen, qreal factor)
+     else
+         qNamedScreenScaleFactors()->insert(name, factor);
+ 
+-    // hack to force re-evaluation of screen geometry
+     if (screen->handle())
+-        screen->d_func()->setPlatformScreen(screen->handle()); // updates geometries based on scale factor
++        screen->d_func()->updateLogicalDpi();
+ }
+ 
+ QPoint QHighDpiScaling::mapPositionToNative(const QPoint &pos, const QPlatformScreen *platformScreen)
+diff --git a/qtbase/src/gui/kernel/qkeysequence.cpp b/qtbase/src/gui/kernel/qkeysequence.cpp
+index a75b8ef920..4f2d294739 100644
+--- a/qtbase/src/gui/kernel/qkeysequence.cpp
++++ b/qtbase/src/gui/kernel/qkeysequence.cpp
+@@ -701,6 +701,10 @@ static const struct {
+     { Qt::Key_TouchpadToggle,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad Toggle") },
+     { Qt::Key_TouchpadOn,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad On") },
+     { Qt::Key_TouchpadOff,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad Off") },
++    { Qt::Key_Shift,  QT_TRANSLATE_NOOP("QShortcut", "Shift") },
++    { Qt::Key_Control,  QT_TRANSLATE_NOOP("QShortcut", "Control") },
++    { Qt::Key_Alt,  QT_TRANSLATE_NOOP("QShortcut", "Alt") },
++    { Qt::Key_Meta,  QT_TRANSLATE_NOOP("QShortcut", "Meta") },
+ 
+ };
+ static Q_CONSTEXPR int numKeyNames = sizeof keyname / sizeof *keyname;
+diff --git a/qtbase/src/gui/kernel/qplatformservices.cpp b/qtbase/src/gui/kernel/qplatformservices.cpp
+index fdc6a6c4aa..ac47f98c5d 100644
+--- a/qtbase/src/gui/kernel/qplatformservices.cpp
++++ b/qtbase/src/gui/kernel/qplatformservices.cpp
+@@ -55,6 +55,19 @@ QT_BEGIN_NAMESPACE
+     \brief The QPlatformServices provides the backend for desktop-related functionality.
+ */
+ 
++/*!
++    \enum QPlatformServices::Capability
++
++    Capabilities are used to determine a specific platform service's availability.
++
++    \value ColorPickingFromScreen The platform natively supports color picking from screen.
++    This capability indicates that the platform supports "opaque" color picking, where the
++    platform implements a complete user experience for color picking and outputs a color.
++    This is in contrast to the application implementing the color picking user experience
++    (taking care of showing a cross hair, instructing the platform integration to obtain
++    the color at a given pixel, etc.). The related service function is pickColor().
++ */
++
+ QPlatformServices::QPlatformServices()
+ { }
+ 
+@@ -85,5 +98,16 @@ QByteArray QPlatformServices::desktopEnvironment() const
+     return QByteArray("UNKNOWN");
+ }
+ 
++QPlatformServiceColorPicker *QPlatformServices::colorPicker(QWindow *parent)
++{
++    Q_UNUSED(parent);
++    return nullptr;
++}
++
++bool QPlatformServices::hasCapability(Capability capability) const
++{
++    Q_UNUSED(capability)
++    return false;
++}
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/gui/kernel/qplatformservices.h b/qtbase/src/gui/kernel/qplatformservices.h
+index 5de96cfa7d..a8b2a4ce71 100644
+--- a/qtbase/src/gui/kernel/qplatformservices.h
++++ b/qtbase/src/gui/kernel/qplatformservices.h
+@@ -50,16 +50,32 @@
+ //
+ 
+ #include <QtGui/qtguiglobal.h>
++#include <QtCore/qobject.h>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+ class QUrl;
++class QWindow;
++
++class Q_GUI_EXPORT QPlatformServiceColorPicker : public QObject
++{
++    Q_OBJECT
++public:
++    using QObject::QObject;
++    virtual void pickColor() = 0;
++Q_SIGNALS:
++    void colorPicked(const QColor &color);
++};
+ 
+ class Q_GUI_EXPORT QPlatformServices
+ {
+ public:
+     Q_DISABLE_COPY_MOVE(QPlatformServices)
+ 
++    enum Capability {
++        ColorPicking,
++    };
++
+     QPlatformServices();
+     virtual ~QPlatformServices() { }
+ 
+@@ -67,6 +83,10 @@ public:
+     virtual bool openDocument(const QUrl &url);
+ 
+     virtual QByteArray desktopEnvironment() const;
++
++    virtual bool hasCapability(Capability capability) const;
++
++    virtual QPlatformServiceColorPicker *colorPicker(QWindow *parent = nullptr);
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/gui/kernel/qplatformtheme.cpp b/qtbase/src/gui/kernel/qplatformtheme.cpp
+index 71521c0339..2325873245 100644
+--- a/qtbase/src/gui/kernel/qplatformtheme.cpp
++++ b/qtbase/src/gui/kernel/qplatformtheme.cpp
+@@ -163,6 +163,8 @@ QT_BEGIN_NAMESPACE
+ 
+     \value ShowShortcutsInContextMenus (bool) Whether to display shortcut key sequences in context menus.
+ 
++    \value ButtonPressKeys (QList<Qt::Key>) A list of keys that can be used to press buttons via keyboard input.
++
+     \sa themeHint(), QStyle::pixelMetric()
+ */
+ 
+@@ -563,6 +565,8 @@ QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint)
+         }
+     case MouseQuickSelectionThreshold:
+         return QVariant(10);
++    case ButtonPressKeys:
++        return QVariant::fromValue(QList<Qt::Key>({ Qt::Key_Space, Qt::Key_Select }));
+     }
+     return QVariant();
+ }
+diff --git a/qtbase/src/gui/kernel/qplatformtheme.h b/qtbase/src/gui/kernel/qplatformtheme.h
+index 3185fc4541..7e6c9d5740 100644
+--- a/qtbase/src/gui/kernel/qplatformtheme.h
++++ b/qtbase/src/gui/kernel/qplatformtheme.h
+@@ -120,7 +120,8 @@ public:
+         TouchDoubleTapDistance,
+         ShowShortcutsInContextMenus,
+         IconFallbackSearchPaths,
+-        MouseQuickSelectionThreshold
++        MouseQuickSelectionThreshold,
++        ButtonPressKeys
+     };
+ 
+     enum DialogType {
+diff --git a/qtbase/src/gui/kernel/qscreen.cpp b/qtbase/src/gui/kernel/qscreen.cpp
+index 8e0eb35116..5d172a58dd 100644
+--- a/qtbase/src/gui/kernel/qscreen.cpp
++++ b/qtbase/src/gui/kernel/qscreen.cpp
+@@ -77,6 +77,12 @@ QScreen::QScreen(QPlatformScreen *screen)
+     d->setPlatformScreen(screen);
+ }
+ 
++void QScreenPrivate::updateLogicalDpi()
++{
++    logicalDpi = QPlatformScreen::overrideDpi(platformScreen->logicalDpi());
++    updateGeometriesWithSignals(); // updates geometries based on scale factor
++}
++
+ void QScreenPrivate::updateGeometriesWithSignals()
+ {
+     const QRect oldGeometry = geometry;
+diff --git a/qtbase/src/gui/kernel/qscreen_p.h b/qtbase/src/gui/kernel/qscreen_p.h
+index 7da542c25e..e50fc3190b 100644
+--- a/qtbase/src/gui/kernel/qscreen_p.h
++++ b/qtbase/src/gui/kernel/qscreen_p.h
+@@ -70,6 +70,7 @@ public:
+         geometry = platformScreen->deviceIndependentGeometry();
+         availableGeometry = QHighDpi::fromNative(platformScreen->availableGeometry(), QHighDpiScaling::factor(platformScreen), geometry.topLeft());
+     }
++    void updateLogicalDpi();
+ 
+     void updatePrimaryOrientation();
+     void updateGeometriesWithSignals();
+diff --git a/qtbase/src/gui/painting/qblendfunctions_p.h b/qtbase/src/gui/painting/qblendfunctions_p.h
+index 080da98ec4..6997d62b3c 100644
+--- a/qtbase/src/gui/painting/qblendfunctions_p.h
++++ b/qtbase/src/gui/painting/qblendfunctions_p.h
+@@ -246,25 +246,32 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+                                   int dudx, int dvdx, int dudy, int dvdy, int u0, int v0,
+                                   Blender blender)
+ {
+-    int fromY = qMax(qRound(topY), clip.top());
+-    int toY = qMin(qRound(bottomY), clip.top() + clip.height());
++    qint64 fromY = qMax(qRound(topY), clip.top());
++    qint64 toY = qMin(qRound(bottomY), clip.top() + clip.height());
+     if (fromY >= toY)
+         return;
+ 
+     qreal leftSlope = (bottomLeft.x - topLeft.x) / (bottomLeft.y - topLeft.y);
+     qreal rightSlope = (bottomRight.x - topRight.x) / (bottomRight.y - topRight.y);
+-    int dx_l = int(leftSlope * 0x10000);
+-    int dx_r = int(rightSlope * 0x10000);
+-    int x_l = int((topLeft.x + (qreal(0.5) + fromY - topLeft.y) * leftSlope + qreal(0.5)) * 0x10000);
+-    int x_r = int((topRight.x + (qreal(0.5) + fromY - topRight.y) * rightSlope + qreal(0.5)) * 0x10000);
+-
+-    int fromX, toX, x1, x2, u, v, i, ii;
++    qint64 dx_l = qint64(leftSlope * 0x10000);
++    qint64 dx_r = qint64(rightSlope * 0x10000);
++    qint64 x_l = qint64((topLeft.x + (qreal(0.5) + fromY - topLeft.y) * leftSlope + qreal(0.5)) * 0x10000);
++    qint64 x_r = qint64((topRight.x + (qreal(0.5) + fromY - topRight.y) * rightSlope + qreal(0.5)) * 0x10000);
++
++    qint64 sourceRectTop = qint64(sourceRect.top());
++    qint64 sourceRectLeft = qint64(sourceRect.left());
++    qint64 sourceRectWidth = qint64(sourceRect.width());
++    qint64 sourceRectHeight = qint64(sourceRect.height());
++    qint64 clipLeft = qint64(clip.left());
++    qint64 clipWidth = qint64(clip.width());
++
++    qint64 fromX, toX, x1, x2, u, v, i, ii;
+     DestT *line;
+-    for (int y = fromY; y < toY; ++y) {
++    for (qint64 y = fromY; y < toY; ++y) {
+         line = reinterpret_cast<DestT *>(reinterpret_cast<uchar *>(destPixels) + y * dbpl);
+ 
+-        fromX = qMax(x_l >> 16, clip.left());
+-        toX = qMin(x_r >> 16, clip.left() + clip.width());
++        fromX = qMax(x_l >> 16, clipLeft);
++        toX = qMin(x_r >> 16, clipLeft + clipWidth);
+         if (fromX < toX) {
+             // Because of rounding, we can get source coordinates outside the source image.
+             // Clamp these coordinates to the source rect to avoid segmentation fault and
+@@ -275,10 +282,10 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             u = x1 * dudx + y * dudy + u0;
+             v = x1 * dvdx + y * dvdy + v0;
+             for (; x1 < toX; ++x1) {
+-                int uu = u >> 16;
+-                int vv = v >> 16;
+-                if (uu >= sourceRect.left() && uu < sourceRect.left() + sourceRect.width()
+-                    && vv >= sourceRect.top() && vv < sourceRect.top() + sourceRect.height()) {
++                qint64 uu = u >> 16;
++                qint64 vv = v >> 16;
++                if (uu >= sourceRectLeft && uu < sourceRectLeft + sourceRectWidth
++                    && vv >= sourceRectTop && vv < sourceRectTop + sourceRectHeight) {
+                     break;
+                 }
+                 u += dudx;
+@@ -290,10 +297,10 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             u = (x2 - 1) * dudx + y * dudy + u0;
+             v = (x2 - 1) * dvdx + y * dvdy + v0;
+             for (; x2 > x1; --x2) {
+-                int uu = u >> 16;
+-                int vv = v >> 16;
+-                if (uu >= sourceRect.left() && uu < sourceRect.left() + sourceRect.width()
+-                    && vv >= sourceRect.top() && vv < sourceRect.top() + sourceRect.height()) {
++                qint64 uu = u >> 16;
++                qint64 vv = v >> 16;
++                if (uu >= sourceRectLeft && uu < sourceRectLeft + sourceRectWidth
++                    && vv >= sourceRectTop && vv < sourceRectTop + sourceRectHeight) {
+                     break;
+                 }
+                 u -= dudx;
+@@ -308,8 +315,8 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             // Beginning of the scan line, with per-pixel checks.
+             i = x1 - fromX;
+             while (i) {
+-                int uu = qBound(sourceRect.left(), u >> 16, sourceRect.left() + sourceRect.width() - 1);
+-                int vv = qBound(sourceRect.top(), v >> 16, sourceRect.top() + sourceRect.height() - 1);
++                qint64 uu = qBound(sourceRectLeft, u >> 16, sourceRectLeft + sourceRectWidth - 1);
++                qint64 vv = qBound(sourceRectTop, v >> 16, sourceRectTop + sourceRectHeight - 1);
+                 blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + vv * sbpl)[uu]);
+                 u += dudx;
+                 v += dvdx;
+@@ -348,8 +355,8 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             // End of the scan line, with per-pixel checks.
+             i = toX - x2;
+             while (i) {
+-                int uu = qBound(sourceRect.left(), u >> 16, sourceRect.left() + sourceRect.width() - 1);
+-                int vv = qBound(sourceRect.top(), v >> 16, sourceRect.top() + sourceRect.height() - 1);
++                qint64 uu = qBound(sourceRectLeft, u >> 16, sourceRectLeft + sourceRectWidth - 1);
++                qint64 vv = qBound(sourceRectTop, v >> 16, sourceRectTop + sourceRectHeight - 1);
+                 blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + vv * sbpl)[uu]);
+                 u += dudx;
+                 v += dvdx;
+diff --git a/qtbase/src/gui/painting/qcolortrclut_p.h b/qtbase/src/gui/painting/qcolortrclut_p.h
+index 76a6a60803..24fd522e6c 100644
+--- a/qtbase/src/gui/painting/qcolortrclut_p.h
++++ b/qtbase/src/gui/painting/qcolortrclut_p.h
+@@ -118,6 +118,7 @@ public:
+         return QRgba64::fromRgba64(r, g, b, qAlpha(rgb32) * 257);
+ #endif
+     }
++    QRgba64 toLinear64(QRgba64) const = delete;
+ 
+     QRgb toLinear(QRgb rgb32) const
+     {
+diff --git a/qtbase/src/gui/painting/qdrawhelper.cpp b/qtbase/src/gui/painting/qdrawhelper.cpp
+index a61793508a..5ba2d277b7 100644
+--- a/qtbase/src/gui/painting/qdrawhelper.cpp
++++ b/qtbase/src/gui/painting/qdrawhelper.cpp
+@@ -6091,7 +6091,7 @@ static inline void alphargbblend_argb32(quint32 *dst, uint coverage, const QRgba
+ static inline void rgbBlendPixel(QRgba64 &dst, int coverage, QRgba64 slinear, const QColorTrcLut *colorProfile)
+ {
+     // Do a gammacorrected RGB alphablend...
+-    const QRgba64 dlinear = colorProfile ? colorProfile->toLinear64(dst) : dst;
++    const QRgba64 dlinear = colorProfile ? colorProfile->toLinear(dst) : dst;
+ 
+     QRgba64 blend = rgbBlend(dlinear, slinear, coverage);
+ 
+diff --git a/qtbase/src/gui/painting/qpaintengine_raster.cpp b/qtbase/src/gui/painting/qpaintengine_raster.cpp
+index 283923de52..f08eb9cbee 100644
+--- a/qtbase/src/gui/painting/qpaintengine_raster.cpp
++++ b/qtbase/src/gui/painting/qpaintengine_raster.cpp
+@@ -560,31 +560,6 @@ void QRasterPaintEngine::updateMatrix(const QTransform &matrix)
+     QRasterPaintEngineState *s = state();
+     // FALCON: get rid of this line, see drawImage call below.
+     s->matrix = matrix;
+-    QTransform::TransformationType txop = s->matrix.type();
+-
+-    switch (txop) {
+-
+-    case QTransform::TxNone:
+-        s->flags.int_xform = true;
+-        break;
+-
+-    case QTransform::TxTranslate:
+-        s->flags.int_xform = qreal(int(s->matrix.dx())) == s->matrix.dx()
+-                            && qreal(int(s->matrix.dy())) == s->matrix.dy();
+-        break;
+-
+-    case QTransform::TxScale:
+-        s->flags.int_xform = qreal(int(s->matrix.dx())) == s->matrix.dx()
+-                            && qreal(int(s->matrix.dy())) == s->matrix.dy()
+-                            && qreal(int(s->matrix.m11())) == s->matrix.m11()
+-                            && qreal(int(s->matrix.m22())) == s->matrix.m22();
+-        break;
+-
+-    default: // shear / perspective...
+-        s->flags.int_xform = false;
+-        break;
+-    }
+-
+     s->flags.tx_noshear = qt_scaleForTransform(s->matrix, &s->txscale);
+ 
+     ensureOutlineMapper();
+@@ -617,7 +592,6 @@ QRasterPaintEngineState::QRasterPaintEngineState()
+     flags.bilinear = false;
+     flags.legacy_rounding = false;
+     flags.fast_text = true;
+-    flags.int_xform = true;
+     flags.tx_noshear = true;
+     flags.fast_images = true;
+ 
+@@ -1793,7 +1767,7 @@ void QRasterPaintEngine::fill(const QVectorPath &path, const QBrush &brush)
+     QRectF cpRect = path.controlPointRect();
+     const QRectF pathDeviceRect = s->matrix.mapRect(cpRect);
+     // Skip paths that by conservative estimates are completely outside the paint device.
+-    if (!pathDeviceRect.intersects(QRectF(d->deviceRect)))
++    if (!pathDeviceRect.intersects(QRectF(d->deviceRect)) || !pathDeviceRect.isValid())
+         return;
+ 
+     ProcessSpans blend = d->getBrushFunc(pathDeviceRect, &s->brushData);
+diff --git a/qtbase/src/gui/painting/qpaintengine_raster_p.h b/qtbase/src/gui/painting/qpaintengine_raster_p.h
+index 089aadc3f7..bf7363d5aa 100644
+--- a/qtbase/src/gui/painting/qpaintengine_raster_p.h
++++ b/qtbase/src/gui/painting/qpaintengine_raster_p.h
+@@ -111,7 +111,6 @@ public:
+         uint bilinear : 1;
+         uint legacy_rounding : 1;
+         uint fast_text : 1;
+-        uint int_xform : 1;
+         uint tx_noshear : 1;
+         uint fast_images : 1;
+     };
+diff --git a/qtbase/src/gui/painting/qpainterpath.cpp b/qtbase/src/gui/painting/qpainterpath.cpp
+index f9544a3241..d80fafeaf1 100644
+--- a/qtbase/src/gui/painting/qpainterpath.cpp
++++ b/qtbase/src/gui/painting/qpainterpath.cpp
+@@ -1253,7 +1253,7 @@ void QPainterPath::addText(const QPointF &point, const QFont &f, const QString &
+ 
+         if (si.analysis.flags < QScriptAnalysis::TabOrObject) {
+             QGlyphLayout glyphs = eng->shapedGlyphs(&si);
+-            QFontEngine *fe = f.d->engineForScript(si.analysis.script);
++            QFontEngine *fe = eng->fontEngine(si);
+             Q_ASSERT(fe);
+             fe->addOutlineToPath(x, y, glyphs, this,
+                                  si.analysis.bidiLevel % 2
+diff --git a/qtbase/src/gui/painting/qpathclipper_p.h b/qtbase/src/gui/painting/qpathclipper_p.h
+index 9444a87b71..18f64c5e8c 100644
+--- a/qtbase/src/gui/painting/qpathclipper_p.h
++++ b/qtbase/src/gui/painting/qpathclipper_p.h
+@@ -156,7 +156,7 @@ public:
+     int vertex(Direction direction) const;
+ 
+ private:
+-    int m_next[2][2];
++    int m_next[2][2] = { { -1, -1 }, { -1, -1 } };
+ };
+ 
+ class QPathSegments
+@@ -296,10 +296,6 @@ inline QPathEdge::QPathEdge(int a, int b)
+     , angle(0)
+     , invAngle(0)
+ {
+-    m_next[0][0] = -1;
+-    m_next[1][0] = -1;
+-    m_next[0][0] = -1;
+-    m_next[1][0] = -1;
+ }
+ 
+ inline int QPathEdge::next(Traversal traversal, Direction direction) const
+diff --git a/qtbase/src/gui/painting/qpdf.cpp b/qtbase/src/gui/painting/qpdf.cpp
+index 3066744f1b..2c8d3c3b53 100644
+--- a/qtbase/src/gui/painting/qpdf.cpp
++++ b/qtbase/src/gui/painting/qpdf.cpp
+@@ -2760,6 +2760,8 @@ int QPdfEnginePrivate::addBrushPattern(const QTransform &m, bool *specifyColor,
+         return gradientBrush(brush, matrix, gStateObject);
+     }
+ 
++    matrix = brush.transform() * matrix;
++
+     if ((!brush.isOpaque() && brush.style() < Qt::LinearGradientPattern) || opacity != 1.0)
+         *gStateObject = addConstantAlphaObject(qRound(brush.color().alpha() * opacity),
+                                                qRound(pen.color().alpha() * opacity));
+diff --git a/qtbase/src/gui/painting/qstroker.cpp b/qtbase/src/gui/painting/qstroker.cpp
+index cb5d395e80..3b6357a893 100644
+--- a/qtbase/src/gui/painting/qstroker.cpp
++++ b/qtbase/src/gui/painting/qstroker.cpp
+@@ -1182,6 +1182,7 @@ void QDashStroker::processCurrentSubpath()
+         // Check if the entire line should be clipped away or simplified
+         bool clipIt = clipping && !lineIntersectsRect(prev, e, clip_tl, clip_br);
+         bool skipDashing = elen * invSumLength > repetitionLimit();
++        int maxDashes = dashCount;
+         if (skipDashing || clipIt) {
+             // Cut away full dash sequences.
+             elen -= std::floor(elen * invSumLength) * sumLength;
+@@ -1196,7 +1197,7 @@ void QDashStroker::processCurrentSubpath()
+                     pos = estop; // move pos to next path element
+                     done = true;
+                 } else { // Dash is on this line
+-                    pos = dpos + estart;
++                    pos = --maxDashes > 0 ? dpos + estart : estop;
+                     done = pos >= estop;
+                     if (++idash >= dashCount)
+                         idash = 0;
+diff --git a/qtbase/src/gui/painting/qt_attribution.json b/qtbase/src/gui/painting/qt_attribution.json
+index 7b16e8c211..0e87d30aa2 100644
+--- a/qtbase/src/gui/painting/qt_attribution.json
++++ b/qtbase/src/gui/painting/qt_attribution.json
+@@ -10,7 +10,7 @@
+         "Homepage": "http://www.freetype.org",
+         "License": "Freetype Project License or GNU General Public License v2.0 only",
+         "LicenseId": "FTL or GPL-2.0",
+-        "LicenseFile": "../../3rdparty/freetype/docs/LICENSE.TXT",
++        "LicenseFile": "../../3rdparty/freetype/LICENSE.TXT",
+         "Copyright": "Copyright 2000-2016 by David Turner, Robert Wilhelm, and Werner Lemberg."
+     },
+     {
+diff --git a/qtbase/src/gui/rhi/qshader_p_p.h b/qtbase/src/gui/rhi/qshader_p_p.h
+index ec9d25971f..4a5a7a6d51 100644
+--- a/qtbase/src/gui/rhi/qshader_p_p.h
++++ b/qtbase/src/gui/rhi/qshader_p_p.h
+@@ -68,13 +68,13 @@ struct Q_GUI_EXPORT QShaderPrivate
+     {
+     }
+ 
+-    QShaderPrivate(const QShaderPrivate *other)
++    QShaderPrivate(const QShaderPrivate &other)
+         : ref(1),
+-          qsbVersion(other->qsbVersion),
+-          stage(other->stage),
+-          desc(other->desc),
+-          shaders(other->shaders),
+-          bindings(other->bindings)
++          qsbVersion(other.qsbVersion),
++          stage(other.stage),
++          desc(other.desc),
++          shaders(other.shaders),
++          bindings(other.bindings)
+     {
+     }
+ 
+diff --git a/qtbase/src/gui/rhi/qshaderdescription_p_p.h b/qtbase/src/gui/rhi/qshaderdescription_p_p.h
+index ec2b0b6b4c..3da33a8a2b 100644
+--- a/qtbase/src/gui/rhi/qshaderdescription_p_p.h
++++ b/qtbase/src/gui/rhi/qshaderdescription_p_p.h
+@@ -63,16 +63,16 @@ struct Q_GUI_EXPORT QShaderDescriptionPrivate
+         localSize[0] = localSize[1] = localSize[2] = 0;
+     }
+ 
+-    QShaderDescriptionPrivate(const QShaderDescriptionPrivate *other)
++    QShaderDescriptionPrivate(const QShaderDescriptionPrivate &other)
+         : ref(1),
+-          inVars(other->inVars),
+-          outVars(other->outVars),
+-          uniformBlocks(other->uniformBlocks),
+-          pushConstantBlocks(other->pushConstantBlocks),
+-          storageBlocks(other->storageBlocks),
+-          combinedImageSamplers(other->combinedImageSamplers),
+-          storageImages(other->storageImages),
+-          localSize(other->localSize)
++          inVars(other.inVars),
++          outVars(other.outVars),
++          uniformBlocks(other.uniformBlocks),
++          pushConstantBlocks(other.pushConstantBlocks),
++          storageBlocks(other.storageBlocks),
++          combinedImageSamplers(other.combinedImageSamplers),
++          storageImages(other.storageImages),
++          localSize(other.localSize)
+     {
+     }
+ 
+diff --git a/qtbase/src/gui/text/qfontdatabase.cpp b/qtbase/src/gui/text/qfontdatabase.cpp
+index a657a8c516..4fc0100958 100644
+--- a/qtbase/src/gui/text/qfontdatabase.cpp
++++ b/qtbase/src/gui/text/qfontdatabase.cpp
+@@ -983,7 +983,7 @@ QFontEngine *loadSingleEngine(int script,
+         if (style->key.stretch != 0 && request.stretch != 0
+             && (request.styleName.isEmpty() || request.styleName != style->styleName)) {
+             def.stretch = (request.stretch * 100 + style->key.stretch / 2) / style->key.stretch;
+-        } else {
++        } else if (request.stretch == QFont::AnyStretch) {
+             def.stretch = 100;
+         }
+ 
+diff --git a/qtbase/src/gui/text/qtextdocumentlayout.cpp b/qtbase/src/gui/text/qtextdocumentlayout.cpp
+index f3e6ea2100..72267e9380 100644
+--- a/qtbase/src/gui/text/qtextdocumentlayout.cpp
++++ b/qtbase/src/gui/text/qtextdocumentlayout.cpp
+@@ -2123,7 +2123,7 @@ void QTextDocumentLayoutPrivate::drawListItem(const QPointF &offset, QPainter *p
+ {
+     Q_Q(const QTextDocumentLayout);
+     const QTextBlockFormat blockFormat = bl.blockFormat();
+-    const QTextCharFormat charFormat = QTextCursor(bl).charFormat();
++    const QTextCharFormat charFormat = bl.charFormat();
+     QFont font(charFormat.font());
+     if (q->paintDevice())
+         font = QFont(font, q->paintDevice());
+diff --git a/qtbase/src/gui/text/qtextengine.cpp b/qtbase/src/gui/text/qtextengine.cpp
+index ce4abac472..a6c66e5d2d 100644
+--- a/qtbase/src/gui/text/qtextengine.cpp
++++ b/qtbase/src/gui/text/qtextengine.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2021 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtGui module of the Qt Toolkit.
+@@ -1565,6 +1565,12 @@ void QTextEngine::shapeText(int item) const
+         // Overwrite with 0 token to indicate failure
+         QGlyphLayout g = availableGlyphs(&si);
+         g.glyphs[0] = 0;
++        g.attributes[0].clusterStart = true;
++
++        ushort *log_clusters = logClusters(&si);
++        for (int i = 0; i < itemLength; ++i)
++            log_clusters[i] = 0;
++
+         return;
+     }
+ 
+diff --git a/qtbase/src/gui/util/qdesktopservices.cpp b/qtbase/src/gui/util/qdesktopservices.cpp
+index fbb63a9408..4d5fafaaa7 100644
+--- a/qtbase/src/gui/util/qdesktopservices.cpp
++++ b/qtbase/src/gui/util/qdesktopservices.cpp
+@@ -54,6 +54,8 @@
+ #include <qpa/qplatformintegration.h>
+ #include <qdir.h>
+ 
++#include <QtCore/private/qlocking_p.h>
++
+ QT_BEGIN_NAMESPACE
+ 
+ class QOpenUrlHandlerRegistry : public QObject
+@@ -81,6 +83,7 @@ Q_GLOBAL_STATIC(QOpenUrlHandlerRegistry, handlerRegistry)
+ 
+ void QOpenUrlHandlerRegistry::handlerDestroyed(QObject *handler)
+ {
++    const auto lock = qt_scoped_lock(mutex);
+     HandlerHash::Iterator it = handlers.begin();
+     while (it != handlers.end()) {
+         if (it->receiver == handler) {
+@@ -294,7 +297,8 @@ void QDesktopServices::setUrlHandler(const QString &scheme, QObject *receiver, c
+     h.name = method;
+     registry->handlers.insert(scheme.toLower(), h);
+     QObject::connect(receiver, SIGNAL(destroyed(QObject*)),
+-                     registry, SLOT(handlerDestroyed(QObject*)));
++                     registry, SLOT(handlerDestroyed(QObject*)),
++                     Qt::DirectConnection);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/gui/util/qpkmhandler.cpp b/qtbase/src/gui/util/qpkmhandler.cpp
+index e0c3b75efe..3414f9d8ba 100644
+--- a/qtbase/src/gui/util/qpkmhandler.cpp
++++ b/qtbase/src/gui/util/qpkmhandler.cpp
+@@ -57,7 +57,7 @@ struct PkmType
+     quint32 bytesPerBlock;
+ };
+ 
+-static PkmType typeMap[5] = {
++static constexpr PkmType typeMap[5] = {
+     { 0x8D64,  8 },   // GL_ETC1_RGB8_OES
+     { 0x9274,  8 },   // GL_COMPRESSED_RGB8_ETC2
+     { 0, 0 },         // unused (obsolete)
+diff --git a/qtbase/src/network/access/qnetworkreplyfileimpl.cpp b/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
+index b6be93147a..6e69b4c4d3 100644
+--- a/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
++++ b/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
+@@ -89,9 +89,10 @@ QNetworkReplyFileImpl::QNetworkReplyFileImpl(QNetworkAccessManager *manager, con
+         // we handle only local files
+         QString msg = QCoreApplication::translate("QNetworkAccessFileBackend", "Request for opening non-local file %1").arg(url.toString());
+         setError(QNetworkReply::ProtocolInvalidOperationError, msg);
++        setFinished(true); // We're finished, will emit finished() after ctor is done.
+         QMetaObject::invokeMethod(this, "errorOccurred", Qt::QueuedConnection,
+             Q_ARG(QNetworkReply::NetworkError, QNetworkReply::ProtocolInvalidOperationError));
+-        fileOpenFinished(false);
++        QMetaObject::invokeMethod(this, [this](){ fileOpenFinished(false); }, Qt::QueuedConnection);
+         return;
+     }
+ #endif
+diff --git a/qtbase/src/network/access/qnetworkreplyimpl.cpp b/qtbase/src/network/access/qnetworkreplyimpl.cpp
+index bcdf6ee2f1..3b6deb82bd 100644
+--- a/qtbase/src/network/access/qnetworkreplyimpl.cpp
++++ b/qtbase/src/network/access/qnetworkreplyimpl.cpp
+@@ -680,7 +680,7 @@ void QNetworkReplyImplPrivate::appendDownstreamData(QIODevice *data)
+     // read until EOF from data
+     if (Q_UNLIKELY(copyDevice)) {
+         qCritical("QNetworkReplyImpl: copy from QIODevice already in progress -- "
+-                  "backend probly needs to be fixed");
++                  "backend probably needs to be fixed");
+         return;
+     }
+ 
+diff --git a/qtbase/src/network/kernel/qauthenticator.cpp b/qtbase/src/network/kernel/qauthenticator.cpp
+index d9fe7bc47b..ccd04b294a 100644
+--- a/qtbase/src/network/kernel/qauthenticator.cpp
++++ b/qtbase/src/network/kernel/qauthenticator.cpp
+@@ -50,6 +50,7 @@
+ #include <qstring.h>
+ #include <qdatetime.h>
+ #include <qrandom.h>
++#include "private/qsystemlibrary_p.h"
+ 
+ #ifdef Q_OS_WIN
+ #include <qmutex.h>
+@@ -1563,7 +1564,7 @@ static bool q_SSPI_library_load()
+ 
+     // Initialize security interface
+     if (pSecurityFunctionTable == nullptr) {
+-        securityDLLHandle = LoadLibrary(L"secur32.dll");
++        securityDLLHandle = QSystemLibrary::load(L"secur32");
+         if (securityDLLHandle != nullptr) {
+             INIT_SECURITY_INTERFACE pInitSecurityInterface =
+                 reinterpret_cast<INIT_SECURITY_INTERFACE>(
+diff --git a/qtbase/src/network/kernel/qhostinfo_unix.cpp b/qtbase/src/network/kernel/qhostinfo_unix.cpp
+index 9b0a2ee669..73679c9ef1 100644
+--- a/qtbase/src/network/kernel/qhostinfo_unix.cpp
++++ b/qtbase/src/network/kernel/qhostinfo_unix.cpp
+@@ -122,7 +122,6 @@ static QFunctionPointer resolveSymbol(QLibrary &lib, const char *sym)
+ 
+ LibResolv::LibResolv()
+ {
+-    QLibrary lib;
+ #ifdef LIBRESOLV_SO
+     lib.setFileName(QStringLiteral(LIBRESOLV_SO));
+     if (!lib.load())
+diff --git a/qtbase/src/network/socket/qsocks5socketengine.cpp b/qtbase/src/network/socket/qsocks5socketengine.cpp
+index 3a046fd116..97fadca0b3 100644
+--- a/qtbase/src/network/socket/qsocks5socketengine.cpp
++++ b/qtbase/src/network/socket/qsocks5socketengine.cpp
+@@ -1296,7 +1296,7 @@ void QSocks5SocketEnginePrivate::_q_udpSocketReadNotification()
+         int pos = 0;
+         const char *buf = inBuf.constData();
+         if (inBuf.size() < 4) {
+-            QSOCKS5_D_DEBUG << "bugus udp data, discarding";
++            QSOCKS5_D_DEBUG << "bogus udp data, discarding";
+             return;
+         }
+         QSocks5RevivedDatagram datagram;
+diff --git a/qtbase/src/network/ssl/qsslcontext_openssl.cpp b/qtbase/src/network/ssl/qsslcontext_openssl.cpp
+index c9f202f573..c992da9d8e 100644
+--- a/qtbase/src/network/ssl/qsslcontext_openssl.cpp
++++ b/qtbase/src/network/ssl/qsslcontext_openssl.cpp
+@@ -409,7 +409,7 @@ init_context:
+         break;
+     case QSsl::DtlsV1_0OrLater:
+         minVersion = DTLS1_VERSION;
+-        maxVersion = DTLS_MAX_VERSION;
++        maxVersion = 0;
+         break;
+     case QSsl::DtlsV1_2:
+         minVersion = DTLS1_2_VERSION;
+@@ -417,7 +417,7 @@ init_context:
+         break;
+     case QSsl::DtlsV1_2OrLater:
+         minVersion = DTLS1_2_VERSION;
+-        maxVersion = DTLS_MAX_VERSION;
++        maxVersion = 0;
+         break;
+     case QSsl::TlsV1_3OrLater:
+ #ifdef TLS1_3_VERSION
+@@ -455,7 +455,7 @@ init_context:
+     }
+ 
+     // Enable bug workarounds.
+-    long options = QSslSocketBackendPrivate::setupOpenSslOptions(configuration.protocol(), configuration.d->sslOptions);
++    qssloptions options = QSslSocketBackendPrivate::setupOpenSslOptions(configuration.protocol(), configuration.d->sslOptions);
+     q_SSL_CTX_set_options(sslContext->ctx, options);
+ 
+     // Tell OpenSSL to release memory early
+diff --git a/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp b/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
+index aaf8741130..b58935372c 100644
+--- a/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
++++ b/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
+@@ -59,57 +59,6 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-#ifdef OPENSSL_NO_DEPRECATED_3_0
+-
+-static int q_DH_check(DH *dh, int *status)
+-{
+-    // DH_check was first deprecated in OpenSSL 3.0.0, as low-level
+-    // API; the EVP_PKEY family of functions was advised as an alternative.
+-    // As of now EVP_PKEY_params_check ends up calling ... DH_check,
+-    // which is good enough.
+-
+-    Q_ASSERT(dh);
+-    Q_ASSERT(status);
+-
+-    EVP_PKEY *key = q_EVP_PKEY_new();
+-    if (!key) {
+-        qCWarning(lcSsl, "EVP_PKEY_new failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-    const auto keyDeleter = qScopeGuard([key](){
+-        q_EVP_PKEY_free(key);
+-    });
+-    if (!q_EVP_PKEY_set1_DH(key, dh)) {
+-        qCWarning(lcSsl, "EVP_PKEY_set1_DH failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-
+-    EVP_PKEY_CTX *keyCtx = q_EVP_PKEY_CTX_new(key, nullptr);
+-    if (!keyCtx) {
+-        qCWarning(lcSsl, "EVP_PKEY_CTX_new failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-    const auto ctxDeleter = qScopeGuard([keyCtx]{
+-        q_EVP_PKEY_CTX_free(keyCtx);
+-    });
+-
+-    const int result = q_EVP_PKEY_param_check(keyCtx);
+-    QSslSocketBackendPrivate::logAndClearErrorQueue();
+-    // Note: unlike DH_check, we cannot obtain the 'status',
+-    // if the 'result' is 0 (actually the result is 1 only
+-    // if this 'status' was 0). We could probably check the
+-    // errors from the error queue, but it's not needed anyway
+-    // - see the 'isSafeDH' below, how it returns immediately
+-    // on 0.
+-    Q_UNUSED(status)
+-
+-    return result;
+-}
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+-
+ static bool isSafeDH(DH *dh)
+ {
+     int status = 0;
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl.cpp b/qtbase/src/network/ssl/qsslsocket_openssl.cpp
+index 37fad2a68f..8f6858c867 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl.cpp
++++ b/qtbase/src/network/ssl/qsslsocket_openssl.cpp
+@@ -550,9 +550,9 @@ static void q_loadCiphersForConnection(SSL *connection, QList<QSslCipher> &ciphe
+ // Defined in qsslsocket.cpp
+ void q_setDefaultDtlsCiphers(const QList<QSslCipher> &ciphers);
+ 
+-long QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions)
++qssloptions QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions)
+ {
+-    long options;
++    qssloptions options;
+     if (protocol == QSsl::TlsV1SslV3)
+         options = SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3;
+     else if (protocol == QSsl::SecureProtocols)
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_p.h b/qtbase/src/network/ssl/qsslsocket_openssl_p.h
+index 4103de23e8..5547589256 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_p.h
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_p.h
+@@ -107,6 +107,12 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++typedef uint64_t qssloptions;
++#else
++typedef unsigned long qssloptions;
++#endif
++
+ struct QSslErrorEntry {
+     int code;
+     int depth;
+@@ -171,7 +177,7 @@ public:
+     QVector<QSslError> ocspErrors;
+     QByteArray ocspResponseDer;
+ 
+-    Q_AUTOTEST_EXPORT static long setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions);
++    Q_AUTOTEST_EXPORT static qssloptions setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions);
+     static QSslCipher QSslCipher_from_SSL_CIPHER(const SSL_CIPHER *cipher);
+     static QList<QSslCertificate> STACKOFX509_to_QSslCertificates(STACK_OF(X509) *x509);
+     static QList<QSslError> verify(const QList<QSslCertificate> &certificateChain, const QString &hostName);
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp b/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
+index e53fb279f0..459ccd0b19 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
+@@ -148,7 +148,6 @@ DEFINEFUNC(int, EVP_PKEY_up_ref, EVP_PKEY *a, a, return 0, return)
+ DEFINEFUNC2(EVP_PKEY_CTX *, EVP_PKEY_CTX_new, EVP_PKEY *pkey, pkey, ENGINE *e, e, return nullptr, return)
+ DEFINEFUNC(int, EVP_PKEY_param_check, EVP_PKEY_CTX *ctx, ctx, return 0, return)
+ DEFINEFUNC(void, EVP_PKEY_CTX_free, EVP_PKEY_CTX *ctx, ctx, return, return)
+-DEFINEFUNC(int, EVP_PKEY_base_id, EVP_PKEY *a, a, return NID_undef, return)
+ DEFINEFUNC(int, RSA_bits, RSA *a, a, return 0, return)
+ DEFINEFUNC(int, DSA_bits, DSA *a, a, return 0, return)
+ DEFINEFUNC(int, OPENSSL_sk_num, OPENSSL_STACK *a, a, return -1, return)
+@@ -158,7 +157,7 @@ DEFINEFUNC2(void, OPENSSL_sk_push, OPENSSL_STACK *a, a, void *b, b, return, DUMM
+ DEFINEFUNC(void, OPENSSL_sk_free, OPENSSL_STACK *a, a, return, DUMMYARG)
+ DEFINEFUNC2(void *, OPENSSL_sk_value, OPENSSL_STACK *a, a, int b, b, return nullptr, return)
+ DEFINEFUNC(int, SSL_session_reused, SSL *a, a, return 0, return)
+-DEFINEFUNC2(unsigned long, SSL_CTX_set_options, SSL_CTX *ctx, ctx, unsigned long op, op, return 0, return)
++DEFINEFUNC2(qssloptions, SSL_CTX_set_options, SSL_CTX *ctx, ctx, qssloptions op, op, return 0, return)
+ DEFINEFUNC(int, SSL_CTX_get_security_level, const SSL_CTX *ctx, ctx, return -1, return)
+ DEFINEFUNC2(void, SSL_CTX_set_security_level, SSL_CTX *ctx, ctx, int level, level, return, return)
+ #ifdef TLS1_3_VERSION
+@@ -371,7 +370,15 @@ DEFINEFUNC(const SSL_CIPHER *, SSL_get_current_cipher, SSL *a, a, return nullptr
+ DEFINEFUNC(int, SSL_version, const SSL *a, a, return 0, return)
+ DEFINEFUNC2(int, SSL_get_error, SSL *a, a, int b, b, return -1, return)
+ DEFINEFUNC(STACK_OF(X509) *, SSL_get_peer_cert_chain, SSL *a, a, return nullptr, return)
++
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++DEFINEFUNC(X509 *, SSL_get1_peer_certificate, SSL *a, a, return nullptr, return)
++DEFINEFUNC(int, EVP_PKEY_get_base_id, const EVP_PKEY *pkey, pkey, return -1, return)
++#else
+ DEFINEFUNC(X509 *, SSL_get_peer_certificate, SSL *a, a, return nullptr, return)
++DEFINEFUNC(int, EVP_PKEY_base_id, EVP_PKEY *a, a, return NID_undef, return)
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+ DEFINEFUNC(long, SSL_get_verify_result, const SSL *a, a, return -1, return)
+ DEFINEFUNC(SSL *, SSL_new, SSL_CTX *a, a, return nullptr, return)
+ DEFINEFUNC(SSL_CTX *, SSL_get_SSL_CTX, SSL *a, a, return nullptr, return)
+@@ -492,9 +499,7 @@ DEFINEFUNC(DH *, DH_new, DUMMYARG, DUMMYARG, return nullptr, return)
+ DEFINEFUNC(void, DH_free, DH *dh, dh, return, DUMMYARG)
+ DEFINEFUNC3(DH *, d2i_DHparams, DH**a, a, const unsigned char **pp, pp, long length, length, return nullptr, return)
+ DEFINEFUNC2(int, i2d_DHparams, DH *a, a, unsigned char **p, p, return -1, return)
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+ DEFINEFUNC2(int, DH_check, DH *dh, dh, int *codes, codes, return 0, return)
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+ DEFINEFUNC3(BIGNUM *, BN_bin2bn, const unsigned char *s, s, int len, len, BIGNUM *ret, ret, return nullptr, return)
+ 
+ #ifndef OPENSSL_NO_EC
+@@ -868,7 +873,6 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(EVP_PKEY_CTX_new)
+     RESOLVEFUNC(EVP_PKEY_param_check)
+     RESOLVEFUNC(EVP_PKEY_CTX_free)
+-    RESOLVEFUNC(EVP_PKEY_base_id)
+     RESOLVEFUNC(RSA_bits)
+     RESOLVEFUNC(OPENSSL_sk_new_null)
+     RESOLVEFUNC(OPENSSL_sk_push)
+@@ -1107,7 +1111,15 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(SSL_version)
+     RESOLVEFUNC(SSL_get_error)
+     RESOLVEFUNC(SSL_get_peer_cert_chain)
++
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++    RESOLVEFUNC(SSL_get1_peer_certificate)
++    RESOLVEFUNC(EVP_PKEY_get_base_id)
++#else
+     RESOLVEFUNC(SSL_get_peer_certificate)
++    RESOLVEFUNC(EVP_PKEY_base_id)
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+     RESOLVEFUNC(SSL_get_verify_result)
+     RESOLVEFUNC(SSL_new)
+     RESOLVEFUNC(SSL_get_SSL_CTX)
+@@ -1206,9 +1218,7 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(DH_free)
+     RESOLVEFUNC(d2i_DHparams)
+     RESOLVEFUNC(i2d_DHparams)
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+     RESOLVEFUNC(DH_check)
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+     RESOLVEFUNC(BN_bin2bn)
+ 
+ #ifndef OPENSSL_NO_EC
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h b/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
+index 95e8897a3b..27aeffa18a 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
+@@ -237,7 +237,6 @@ Q_AUTOTEST_EXPORT int q_EVP_PKEY_up_ref(EVP_PKEY *a);
+ EVP_PKEY_CTX *q_EVP_PKEY_CTX_new(EVP_PKEY *pkey, ENGINE *e);
+ void q_EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx);
+ int q_EVP_PKEY_param_check(EVP_PKEY_CTX *ctx);
+-int q_EVP_PKEY_base_id(EVP_PKEY *a);
+ int q_RSA_bits(RSA *a);
+ Q_AUTOTEST_EXPORT int q_OPENSSL_sk_num(OPENSSL_STACK *a);
+ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_pop_free(OPENSSL_STACK *a, void (*b)(void *));
+@@ -246,7 +245,7 @@ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_push(OPENSSL_STACK *st, void *data);
+ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_free(OPENSSL_STACK *a);
+ Q_AUTOTEST_EXPORT void * q_OPENSSL_sk_value(OPENSSL_STACK *a, int b);
+ int q_SSL_session_reused(SSL *a);
+-unsigned long q_SSL_CTX_set_options(SSL_CTX *ctx, unsigned long op);
++qssloptions q_SSL_CTX_set_options(SSL_CTX *ctx, qssloptions op);
+ int q_OPENSSL_init_ssl(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings);
+ size_t q_SSL_get_client_random(SSL *a, unsigned char *out, size_t outlen);
+ size_t q_SSL_SESSION_get_master_key(const SSL_SESSION *session, unsigned char *out, size_t outlen);
+@@ -510,7 +509,6 @@ const SSL_CIPHER *q_SSL_get_current_cipher(SSL *a);
+ int q_SSL_version(const SSL *a);
+ int q_SSL_get_error(SSL *a, int b);
+ STACK_OF(X509) *q_SSL_get_peer_cert_chain(SSL *a);
+-X509 *q_SSL_get_peer_certificate(SSL *a);
+ long q_SSL_get_verify_result(const SSL *a);
+ SSL *q_SSL_new(SSL_CTX *a);
+ SSL_CTX *q_SSL_get_SSL_CTX(SSL *a);
+@@ -582,10 +580,7 @@ DH *q_DH_new();
+ void q_DH_free(DH *dh);
+ DH *q_d2i_DHparams(DH **a, const unsigned char **pp, long length);
+ int q_i2d_DHparams(DH *a, unsigned char **p);
+-
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+ int q_DH_check(DH *dh, int *codes);
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+ 
+ BIGNUM *q_BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret);
+ #define q_SSL_CTX_set_tmp_dh(ctx, dh) q_SSL_CTX_ctrl((ctx), SSL_CTRL_SET_TMP_DH, 0, (char *)dh)
+@@ -754,6 +749,17 @@ void q_CRYPTO_free(void *str, const char *file, int line);
+ int q_SSL_CTX_get_security_level(const SSL_CTX *ctx);
+ void q_SSL_CTX_set_security_level(SSL_CTX *ctx, int level);
+ 
++// Here we have the ones that make difference between OpenSSL pre/post v3:
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++X509 *q_SSL_get1_peer_certificate(SSL *a);
++#define q_SSL_get_peer_certificate q_SSL_get1_peer_certificate
++int q_EVP_PKEY_get_base_id(const EVP_PKEY *pkey);
++#define q_EVP_PKEY_base_id q_EVP_PKEY_get_base_id
++#else
++X509 *q_SSL_get_peer_certificate(SSL *a);
++int q_EVP_PKEY_base_id(EVP_PKEY *a);
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+ QT_END_NAMESPACE
+ 
+ #endif
+diff --git a/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h b/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
+index bf37d07fd8..dbd42fb799 100644
+--- a/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
++++ b/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
+@@ -61,7 +61,11 @@
+ # if !defined(Q_OS_INTEGRITY)
+ #  define WIN_INTERFACE_CUSTOM   // NV
+ # endif // Q_OS_INTEGRITY
+-#endif  // QT_EGL_NO_X11
++#else // QT_EGL_NO_X11
++// If one has an eglplatform.h with https://github.com/KhronosGroup/EGL-Registry/pull/130
++// that needs USE_X11 to be defined.
++# define USE_X11
++#endif
+ 
+ #ifdef QT_EGL_WAYLAND
+ # define WAYLAND // NV
+diff --git a/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+index 159b490ce0..00aa80cd58 100644
+--- a/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
++++ b/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+@@ -567,6 +567,8 @@ void QFontconfigDatabase::populateFontDatabase()
+         fonts = FcFontList(nullptr, pattern, os);
+         FcObjectSetDestroy(os);
+         FcPatternDestroy(pattern);
++        if (!fonts)
++            return;
+     }
+ 
+     for (int i = 0; i < fonts->nfont; i++)
+diff --git a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
+index b713c19447..7cb9a8c79a 100644
+--- a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
++++ b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
+@@ -95,6 +95,7 @@ static constexpr const auto KeyTbl = qMakeArray(
+         Xkb2Qt<XKB_KEY_Clear,                   Qt::Key_Delete>,
+         Xkb2Qt<XKB_KEY_Pause,                   Qt::Key_Pause>,
+         Xkb2Qt<XKB_KEY_Print,                   Qt::Key_Print>,
++        Xkb2Qt<XKB_KEY_Sys_Req,                 Qt::Key_SysReq>,
+         Xkb2Qt<0x1005FF60,                      Qt::Key_SysReq>,         // hardcoded Sun SysReq
+         Xkb2Qt<0x1007ff00,                      Qt::Key_SysReq>,         // hardcoded X386 SysReq
+ 
+@@ -471,7 +472,7 @@ QVector<xkb_keysym_t> QXkbCommon::toKeysym(QKeyEvent *event)
+     } else if (event->modifiers() & Qt::KeypadModifier) {
+         if (qtKey >= Qt::Key_0 && qtKey <= Qt::Key_9)
+             keysyms.append(XKB_KEY_KP_0 + (qtKey - Qt::Key_0));
+-    } else if (isLatin(qtKey) && event->text().isUpper()) {
++    } else if (isLatin1(qtKey) && event->text().isUpper()) {
+         keysyms.append(qtKey);
+     }
+ 
+@@ -523,7 +524,7 @@ int QXkbCommon::keysymToQtKey(xkb_keysym_t keysym, Qt::KeyboardModifiers modifie
+         // With standard shortcuts we should prefer a latin character, this is
+         // for checks like "some qkeyevent == QKeySequence::Copy" to work even
+         // when using for example 'russian' keyboard layout.
+-        if (!QXkbCommon::isLatin(keysym)) {
++        if (!QXkbCommon::isLatin1(keysym)) {
+             xkb_keysym_t latinKeysym = QXkbCommon::lookupLatinKeysym(state, code);
+             if (latinKeysym != XKB_KEY_NoSymbol)
+                 keysym = latinKeysym;
+@@ -546,7 +547,7 @@ static int keysymToQtKey_internal(xkb_keysym_t keysym, Qt::KeyboardModifiers mod
+     } else if (keysym >= XKB_KEY_KP_0 && keysym <= XKB_KEY_KP_9) {
+         // numeric keypad keys
+         qtKey = Qt::Key_0 + (keysym - XKB_KEY_KP_0);
+-    } else if (QXkbCommon::isLatin(keysym)) {
++    } else if (QXkbCommon::isLatin1(keysym)) {
+         qtKey = QXkbCommon::qxkbcommon_xkb_keysym_to_upper(keysym);
+     } else {
+         // check if we have a direct mapping
+@@ -678,7 +679,7 @@ QList<int> QXkbCommon::possibleKeys(xkb_state *state, const QKeyEvent *event,
+         Qt::KeyboardModifiers neededMods = ModsTbl[i];
+         if ((modifiers & neededMods) == neededMods) {
+             if (i == 8) {
+-                if (isLatin(baseQtKey))
++                if (isLatin1(baseQtKey))
+                     continue;
+                 // add a latin key as a fall back key
+                 sym = lookupLatinKeysym(state, keycode);
+@@ -733,7 +734,7 @@ void QXkbCommon::verifyHasLatinLayout(xkb_keymap *keymap)
+     for (xkb_layout_index_t layout = 0; layout < layoutCount; ++layout) {
+         for (xkb_keycode_t code = minKeycode; code < maxKeycode; ++code) {
+             xkb_keymap_key_get_syms_by_level(keymap, code, layout, 0, &keysyms);
+-            if (keysyms && isLatin(keysyms[0]))
++            if (keysyms && isLatin1(keysyms[0]))
+                 nrLatinKeys++;
+             if (nrLatinKeys > 10) // arbitrarily chosen threshold
+                 return;
+@@ -766,7 +767,7 @@ xkb_keysym_t QXkbCommon::lookupLatinKeysym(xkb_state *state, xkb_keycode_t keyco
+         xkb_level_index_t level = xkb_state_key_get_level(state, keycode, layout);
+         if (xkb_keymap_key_get_syms_by_level(keymap, keycode, layout, level, &syms) != 1)
+             continue;
+-        if (isLatin(syms[0])) {
++        if (isLatin1(syms[0])) {
+             sym = syms[0];
+             break;
+         }
+diff --git a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
+index 561eae03db..8389bd8f5a 100644
+--- a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
++++ b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
+@@ -94,8 +94,8 @@ public:
+     static void verifyHasLatinLayout(xkb_keymap *keymap);
+     static xkb_keysym_t lookupLatinKeysym(xkb_state *state, xkb_keycode_t keycode);
+ 
+-    static bool isLatin(xkb_keysym_t sym) {
+-        return ((sym >= 'a' && sym <= 'z') || (sym >= 'A' && sym <= 'Z'));
++    static bool isLatin1(xkb_keysym_t sym) {
++        return sym <= 0xff;
+     }
+     static bool isKeypad(xkb_keysym_t sym) {
+         return sym >= XKB_KEY_KP_Space && sym <= XKB_KEY_KP_9;
+diff --git a/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp b/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
+index 8cd7f9b368..406f84663f 100644
+--- a/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
++++ b/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
+@@ -318,7 +318,7 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources,
+ 
+     if (current < 0 && crtc_mode.clock != 0) {
+         modes << crtc_mode;
+-        current = mode.size() - 1;
++        current = modes.size() - 1;
+     }
+ 
+     if (configuration == OutputConfigCurrent)
+diff --git a/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp b/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
+index 9153fd20bb..255ea5e33e 100644
+--- a/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
++++ b/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
+@@ -194,6 +194,9 @@ QString AtSpiAdaptor::introspect(const QString &path) const
+                 "      <arg direction=\"out\" type=\"(so)\"/>\n"
+                 "      <annotation value=\"QSpiObjectReference\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n"
+                 "    </method>\n"
++                "    <method name=\"GetAccessibleId\">\n"
++                "      <arg direction=\"out\" type=\"s\"/>\n"
++                "    </method>\n"
+                 "  </interface>\n"
+                 );
+ 
+@@ -913,8 +916,17 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+     }
+     case QAccessible::NameChanged: {
+         if (sendObject || sendObject_property_change || sendObject_property_change_accessible_name) {
+-            QString path = pathForInterface(event->accessibleInterface());
+-            QVariantList args = packDBusSignalArguments(QLatin1String("accessible-name"), 0, 0, variantForPath(path));
++            QAccessibleInterface *iface = event->accessibleInterface();
++            if (!iface) {
++                qCDebug(lcAccessibilityAtspi,
++                        "NameChanged event from invalid accessible.");
++                return;
++            }
++
++            QString path = pathForInterface(iface);
++            QVariantList args = packDBusSignalArguments(
++                QLatin1String("accessible-name"), 0, 0,
++                QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Name))));
+             sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                            QLatin1String("PropertyChange"), args);
+         }
+@@ -922,8 +934,17 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+     }
+     case QAccessible::DescriptionChanged: {
+         if (sendObject || sendObject_property_change || sendObject_property_change_accessible_description) {
+-            QString path = pathForInterface(event->accessibleInterface());
+-            QVariantList args = packDBusSignalArguments(QLatin1String("accessible-description"), 0, 0, variantForPath(path));
++            QAccessibleInterface *iface = event->accessibleInterface();
++            if (!iface) {
++                qCDebug(lcAccessibilityAtspi,
++                        "DescriptionChanged event from invalid accessible.");
++                return;
++            }
++
++            QString path = pathForInterface(iface);
++            QVariantList args = packDBusSignalArguments(
++                QLatin1String("accessible-description"), 0, 0,
++                QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Description))));
+             sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                            QLatin1String("PropertyChange"), args);
+         }
+@@ -1038,7 +1059,9 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+                 // Combo Box with AT-SPI likes to be special
+                 // It requires a name-change to update caches and then selection-changed
+                 QString path = pathForInterface(iface);
+-                QVariantList args1 = packDBusSignalArguments(QLatin1String("accessible-name"), 0, 0, variantForPath(path));
++                QVariantList args1 = packDBusSignalArguments(
++                    QLatin1String("accessible-name"), 0, 0,
++                    QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Name))));
+                 sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                                QLatin1String("PropertyChange"), args1);
+                 QVariantList args2 = packDBusSignalArguments(QString(), 0, 0, QVariant::fromValue(QDBusVariant(QVariant(0))));
+@@ -1358,6 +1381,26 @@ void AtSpiAdaptor::registerApplication()
+     delete registry;
+ }
+ 
++namespace {
++QString accessibleIdForAccessible(QAccessibleInterface *accessible)
++{
++    QString result;
++    while (accessible) {
++        if (!result.isEmpty())
++            result.prepend(QLatin1Char('.'));
++        if (auto obj = accessible->object()) {
++            const QString name = obj->objectName();
++            if (!name.isEmpty())
++                result.prepend(name);
++            else
++                result.prepend(QString::fromUtf8(obj->metaObject()->className()));
++        }
++        accessible = accessible->parent();
++    }
++    return result;
++}
++} // namespace
++
+ // Accessible
+ bool AtSpiAdaptor::accessibleInterface(QAccessibleInterface *interface, const QString &function, const QDBusMessage &message, const QDBusConnection &connection)
+ {
+@@ -1441,6 +1484,9 @@ bool AtSpiAdaptor::accessibleInterface(QAccessibleInterface *interface, const QS
+             children << ref;
+         }
+         connection.send(message.createReply(QVariant::fromValue(children)));
++    } else if (function == QLatin1String("GetAccessibleId")) {
++        sendReply(connection, message,
++                  QVariant::fromValue(QDBusVariant(accessibleIdForAccessible(interface))));
+     } else {
+         qCDebug(lcAccessibilityAtspi) << "WARNING: AtSpiAdaptor::accessibleInterface does not implement " << function << message.path();
+         return false;
+diff --git a/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp b/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
+index 45ddc8e496..cc734abc63 100644
+--- a/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
++++ b/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
+@@ -69,6 +69,21 @@ QT_BEGIN_NAMESPACE
+ DBusConnection::DBusConnection(QObject *parent)
+     : QObject(parent), m_a11yConnection(QString()), m_enabled(false)
+ {
++    // If the bus is explicitly set via env var it overrides everything else.
++    QByteArray addressEnv = qgetenv("AT_SPI_BUS_ADDRESS");
++    if (!addressEnv.isEmpty()) {
++        // Only connect on next loop run, connections to our enabled signal are
++        // only established after the ctor returns.
++        QMetaObject::invokeMethod(
++                this,
++                [this, addressEnv] {
++                    m_enabled = true;
++                    connectA11yBus(QString::fromLocal8Bit(addressEnv));
++                },
++                Qt::QueuedConnection);
++        return;
++    }
++
+     // Start monitoring if "org.a11y.Bus" is registered as DBus service.
+     QDBusConnection c = QDBusConnection::sessionBus();
+     if (!c.isConnected()) {
+diff --git a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
+index 1a3cab275d..2abe039126 100644
+--- a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
++++ b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
+@@ -51,6 +51,9 @@
+ #include <QtCore/QStandardPaths>
+ #include <QtCore/QUrl>
+ 
++#include <QtGui/QGuiApplication>
++#include <QtGui/QWindow>
++
+ #if QT_CONFIG(dbus)
+ // These QtCore includes are needed for xdg-desktop-portal support
+ #include <QtCore/private/qcore_unix_p.h>
+@@ -58,6 +61,8 @@
+ #include <QtCore/QFileInfo>
+ #include <QtCore/QUrlQuery>
+ 
++#include <QtGui/QColor>
++
+ #include <QtDBus/QDBusConnection>
+ #include <QtDBus/QDBusMessage>
+ #include <QtDBus/QDBusPendingCall>
+@@ -142,6 +147,8 @@ static inline bool detectWebBrowser(const QByteArray &desktop,
+     }
+ 
+     if (desktop == QByteArray("KDE")) {
++        if (checkExecutable(QStringLiteral("kde-open5"), browser))
++            return true;
+         // Konqueror launcher
+         if (checkExecutable(QStringLiteral("kfmclient"), browser)) {
+             browser->append(QLatin1String(" exec"));
+@@ -296,8 +303,135 @@ static inline QDBusMessage xdgDesktopPortalSendEmail(const QUrl &url)
+ 
+     return QDBusConnection::sessionBus().call(message);
+ }
++
++namespace {
++struct XDGDesktopColor
++{
++    double r = 0;
++    double g = 0;
++    double b = 0;
++
++    QColor toQColor() const
++    {
++        constexpr auto rgbMax = 255;
++        return { static_cast<int>(r * rgbMax), static_cast<int>(g * rgbMax),
++                 static_cast<int>(b * rgbMax) };
++    }
++};
++
++const QDBusArgument &operator>>(const QDBusArgument &argument, XDGDesktopColor &myStruct)
++{
++    argument.beginStructure();
++    argument >> myStruct.r >> myStruct.g >> myStruct.b;
++    argument.endStructure();
++    return argument;
++}
++
++class XdgDesktopPortalColorPicker : public QPlatformServiceColorPicker
++{
++    Q_OBJECT
++public:
++    XdgDesktopPortalColorPicker(const QString &parentWindowId, QWindow *parent)
++        : QPlatformServiceColorPicker(parent), m_parentWindowId(parentWindowId)
++    {
++    }
++
++    void pickColor() override
++    {
++        // DBus signature:
++        // PickColor (IN   s      parent_window,
++        //            IN   a{sv}  options
++        //            OUT  o      handle)
++        // Options:
++        // handle_token (s) -  A string that will be used as the last element of the @handle.
++
++        QDBusMessage message = QDBusMessage::createMethodCall(
++                QStringLiteral("org.freedesktop.portal.Desktop"), QStringLiteral("/org/freedesktop/portal/desktop"),
++                QStringLiteral("org.freedesktop.portal.Screenshot"), QStringLiteral("PickColor"));
++        message << m_parentWindowId << QVariantMap();
++
++        QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
++        auto watcher = new QDBusPendingCallWatcher(pendingCall, this);
++        connect(watcher, &QDBusPendingCallWatcher::finished, this,
++                [this](QDBusPendingCallWatcher *watcher) {
++                    watcher->deleteLater();
++                    QDBusPendingReply<QDBusObjectPath> reply = *watcher;
++                    if (reply.isError()) {
++                        qWarning("DBus call to pick color failed: %s",
++                                 qPrintable(reply.error().message()));
++                        Q_EMIT colorPicked({});
++                    } else {
++                        QDBusConnection::sessionBus().connect(
++                                QStringLiteral("org.freedesktop.portal.Desktop"), reply.value().path(),
++                                QStringLiteral("org.freedesktop.portal.Request"), QStringLiteral("Response"), this,
++                                // clang-format off
++                                SLOT(gotColorResponse(uint,QVariantMap))
++                                // clang-format on
++                        );
++                    }
++                });
++    }
++
++private Q_SLOTS:
++    void gotColorResponse(uint result, const QVariantMap &map)
++    {
++        if (result != 0)
++            return;
++        XDGDesktopColor color{};
++        map.value(QStringLiteral("color")).value<QDBusArgument>() >> color;
++        Q_EMIT colorPicked(color.toQColor());
++        deleteLater();
++    }
++
++private:
++    const QString m_parentWindowId;
++};
++} // namespace
++
+ #endif // QT_CONFIG(dbus)
+ 
++QGenericUnixServices::QGenericUnixServices()
++{
++#if QT_CONFIG(dbus)
++    if (qEnvironmentVariableIntValue("QT_NO_XDG_DESKTOP_PORTAL") > 0) {
++        return;
++    }
++    QDBusMessage message = QDBusMessage::createMethodCall(
++            QStringLiteral("org.freedesktop.portal.Desktop"), QStringLiteral("/org/freedesktop/portal/desktop"),
++            QStringLiteral("org.freedesktop.DBus.Properties"), QStringLiteral("Get"));
++    message << QStringLiteral("org.freedesktop.portal.Screenshot")
++            << QStringLiteral("version");
++
++    QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
++    auto watcher = new QDBusPendingCallWatcher(pendingCall);
++    QObject::connect(watcher, &QDBusPendingCallWatcher::finished, watcher,
++                     [this](QDBusPendingCallWatcher *watcher) {
++                         watcher->deleteLater();
++                         QDBusPendingReply<QVariant> reply = *watcher;
++                         if (!reply.isError() && reply.value().toUInt() >= 2)
++                             m_hasScreenshotPortalWithColorPicking = true;
++                     });
++
++#endif
++}
++
++QPlatformServiceColorPicker *QGenericUnixServices::colorPicker(QWindow *parent)
++{
++#if QT_CONFIG(dbus)
++    // Make double sure that we are in a wayland environment. In particular check
++    // WAYLAND_DISPLAY so also XWayland apps benefit from portal-based color picking.
++    // Outside wayland we'll rather rely on other means than the XDG desktop portal.
++    if (!qEnvironmentVariableIsEmpty("WAYLAND_DISPLAY")
++        || QGuiApplication::platformName().startsWith(QLatin1String("wayland"))) {
++        return new XdgDesktopPortalColorPicker(portalWindowIdentifier(parent), parent);
++    }
++    return nullptr;
++#else
++    Q_UNUSED(parent);
++    return nullptr;
++#endif
++}
++
+ QByteArray QGenericUnixServices::desktopEnvironment() const
+ {
+     static const QByteArray result = detectDesktopEnvironment();
+@@ -352,6 +486,8 @@ bool QGenericUnixServices::openDocument(const QUrl &url)
+ }
+ 
+ #else
++QGenericUnixServices::QGenericUnixServices() = default;
++
+ QByteArray QGenericUnixServices::desktopEnvironment() const
+ {
+     return QByteArrayLiteral("UNKNOWN");
+@@ -371,6 +507,30 @@ bool QGenericUnixServices::openDocument(const QUrl &url)
+     return false;
+ }
+ 
++QPlatformServiceColorPicker *QGenericUnixServices::colorPicker(QWindow *parent)
++{
++    Q_UNUSED(parent);
++    return nullptr;
++}
++
+ #endif // QT_NO_MULTIPROCESS
+ 
++QString QGenericUnixServices::portalWindowIdentifier(QWindow *window)
++{
++    if (QGuiApplication::platformName() == QLatin1String("xcb"))
++        return QStringLiteral("x11:") + QString::number(window->winId(), 16);
++    return QString();
++}
++
++bool QGenericUnixServices::hasCapability(Capability capability) const
++{
++    switch (capability) {
++    case Capability::ColorPicking:
++        return m_hasScreenshotPortalWithColorPicking;
++    }
++    return false;
++}
++
+ QT_END_NAMESPACE
++
++#include "qgenericunixservices.moc"
+diff --git a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
+index 8ac3de6f03..30924e64bd 100644
+--- a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
++++ b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
+@@ -59,16 +59,21 @@ QT_BEGIN_NAMESPACE
+ class QGenericUnixServices : public QPlatformServices
+ {
+ public:
+-    QGenericUnixServices() {}
++    QGenericUnixServices();
+ 
+     QByteArray desktopEnvironment() const override;
+ 
++    bool hasCapability(Capability capability) const override;
+     bool openUrl(const QUrl &url) override;
+     bool openDocument(const QUrl &url) override;
++    QPlatformServiceColorPicker *colorPicker(QWindow *parent = nullptr) override;
++
++    virtual QString portalWindowIdentifier(QWindow *window);
+ 
+ private:
+     QString m_webBrowser;
+     QString m_documentLauncher;
++    bool m_hasScreenshotPortalWithColorPicking = false;
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
+index 09470bccc6..cc7c7d4d8a 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
+@@ -69,6 +69,7 @@ const QString MenuBarPath = QLatin1String("/MenuBar");
+ */
+ QDBusMenuConnection::QDBusMenuConnection(QObject *parent, const QString &serviceName)
+     : QObject(parent)
++    , m_serviceName(serviceName)
+     , m_connection(serviceName.isNull() ? QDBusConnection::sessionBus()
+                                         : QDBusConnection::connectToBus(QDBusConnection::SessionBus, serviceName))
+     , m_dbusWatcher(new QDBusServiceWatcher(StatusNotifierWatcherService, m_connection, QDBusServiceWatcher::WatchForRegistration, this))
+@@ -83,6 +84,12 @@ QDBusMenuConnection::QDBusMenuConnection(QObject *parent, const QString &service
+ #endif
+ }
+ 
++QDBusMenuConnection::~QDBusMenuConnection()
++{
++  if (!m_serviceName.isEmpty() && m_connection.isConnected())
++      QDBusConnection::disconnectFromBus(m_serviceName);
++}
++
+ void QDBusMenuConnection::dbusError(const QDBusError &error)
+ {
+     qWarning() << "QDBusTrayIcon encountered a D-Bus error:" << error;
+@@ -105,13 +112,7 @@ void QDBusMenuConnection::unregisterTrayIconMenu(QDBusTrayIcon *item)
+ 
+ bool QDBusMenuConnection::registerTrayIcon(QDBusTrayIcon *item)
+ {
+-    bool success = connection().registerService(item->instanceId());
+-    if (!success) {
+-        qWarning() << "failed to register service" << item->instanceId();
+-        return false;
+-    }
+-
+-    success = connection().registerObject(StatusNotifierItemPath, item);
++    bool success = connection().registerObject(StatusNotifierItemPath, item);
+     if (!success) {
+         unregisterTrayIcon(item);
+         qWarning() << "failed to register" << item->instanceId() << StatusNotifierItemPath;
+@@ -126,21 +127,18 @@ bool QDBusMenuConnection::registerTrayIcon(QDBusTrayIcon *item)
+ 
+ bool QDBusMenuConnection::registerTrayIconWithWatcher(QDBusTrayIcon *item)
+ {
++    Q_UNUSED(item);
+     QDBusMessage registerMethod = QDBusMessage::createMethodCall(
+                 StatusNotifierWatcherService, StatusNotifierWatcherPath, StatusNotifierWatcherService,
+                 QLatin1String("RegisterStatusNotifierItem"));
+-    registerMethod.setArguments(QVariantList() << item->instanceId());
++    registerMethod.setArguments(QVariantList() << m_connection.baseService());
+     return m_connection.callWithCallback(registerMethod, this, SIGNAL(trayIconRegistered()), SLOT(dbusError(QDBusError)));
+ }
+ 
+-bool QDBusMenuConnection::unregisterTrayIcon(QDBusTrayIcon *item)
++void QDBusMenuConnection::unregisterTrayIcon(QDBusTrayIcon *item)
+ {
+     unregisterTrayIconMenu(item);
+     connection().unregisterObject(StatusNotifierItemPath);
+-    bool success = connection().unregisterService(item->instanceId());
+-    if (!success)
+-        qWarning() << "failed to unregister service" << item->instanceId();
+-    return success;
+ }
+ #endif // QT_NO_SYSTEMTRAYICON
+ 
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
+index f484795fbb..97bdfabb85 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
++++ b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
+@@ -70,6 +70,7 @@ class QDBusMenuConnection : public QObject
+ 
+ public:
+     QDBusMenuConnection(QObject *parent = nullptr, const QString &serviceName = QString());
++    ~QDBusMenuConnection();
+     QDBusConnection connection() const { return m_connection; }
+     QDBusServiceWatcher *dbusWatcher() const { return m_dbusWatcher; }
+     bool isStatusNotifierHostRegistered() const { return m_statusNotifierHostRegistered; }
+@@ -78,7 +79,7 @@ public:
+     void unregisterTrayIconMenu(QDBusTrayIcon *item);
+     bool registerTrayIcon(QDBusTrayIcon *item);
+     bool registerTrayIconWithWatcher(QDBusTrayIcon *item);
+-    bool unregisterTrayIcon(QDBusTrayIcon *item);
++    void unregisterTrayIcon(QDBusTrayIcon *item);
+ #endif // QT_NO_SYSTEMTRAYICON
+ 
+ Q_SIGNALS:
+@@ -90,6 +91,7 @@ private Q_SLOTS:
+     void dbusError(const QDBusError &error);
+ 
+ private:
++    QString m_serviceName;
+     QDBusConnection m_connection;
+     QDBusServiceWatcher *m_dbusWatcher;
+     bool m_statusNotifierHostRegistered;
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp b/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
+index bede70975a..76bfec5e5a 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
+@@ -71,8 +71,12 @@ Q_LOGGING_CATEGORY(qLcTray, "qt.qpa.tray")
+ static QString iconTempPath()
+ {
+     QString tempPath = QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation);
+-    if (!tempPath.isEmpty())
++    if (!tempPath.isEmpty()) {
++        QString flatpakId = qEnvironmentVariable("FLATPAK_ID");
++        if (!flatpakId.isEmpty() && QFileInfo::exists(QLatin1String("/.flatpak-info")))
++            tempPath += QLatin1String("/app/") + flatpakId;
+         return tempPath;
++    }
+ 
+     tempPath = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation);
+ 
+diff --git a/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+index cb1b39db64..6e01af052c 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+@@ -755,6 +755,9 @@ QVariant QGnomeTheme::themeHint(QPlatformTheme::ThemeHint hint) const
+         return QVariant(QChar(0x2022));
+     case QPlatformTheme::UiEffects:
+         return QVariant(int(HoverEffect));
++    case QPlatformTheme::ButtonPressKeys:
++        return QVariant::fromValue(
++                QList<Qt::Key>({ Qt::Key_Space, Qt::Key_Return, Qt::Key_Enter, Qt::Key_Select }));
+     default:
+         break;
+     }
+diff --git a/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp b/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
+index 98e05195ee..1e92f43dec 100644
+--- a/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
++++ b/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
+@@ -343,8 +343,7 @@ void QEglFSCursor::paintOnScreen()
+     // screens are siblings of each other. When not enabled, the sibling list
+     // only contains m_screen itself.
+     for (QPlatformScreen *screen : m_screen->virtualSiblings()) {
+-        if (screen->geometry().contains(cr.topLeft().toPoint() + m_cursor.hotSpot)
+-            && QOpenGLContext::currentContext()->screen() == screen->screen())
++        if (screen->geometry().contains(cr.topLeft().toPoint() + m_cursor.hotSpot))
+         {
+             cr.translate(-screen->geometry().topLeft());
+             const QSize screenSize = screen->geometry().size();
+@@ -468,11 +467,12 @@ void QEglFSCursor::draw(const QRectF &r)
+ {
+     StateSaver stateSaver;
+ 
+-    QEglFSCursorData &gfx = static_cast<QEglFSContext*>(QOpenGLContext::currentContext()->handle())->cursorData;
+-    if (!gfx.program) {
+-        // one time initialization
++    // one time initialization
++    if (!QOpenGLFunctions::d_ptr)
+         initializeOpenGLFunctions();
+ 
++    QEglFSCursorData &gfx = static_cast<QEglFSContext*>(QOpenGLContext::currentContext()->handle())->cursorData;
++    if (!gfx.program) {
+         createShaderPrograms();
+ 
+         if (!gfx.atlasTexture) {
+diff --git a/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp b/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
+index 645a0ae2e9..3e0e406f1a 100644
+--- a/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
++++ b/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
+@@ -179,7 +179,7 @@ void QEglFSKmsEventReader::create(QEglFSKmsDevice *device)
+ 
+     m_device = device;
+ 
+-    qCDebug(qLcEglfsKmsDebug, "Initalizing event reader for device %p fd %d",
++    qCDebug(qLcEglfsKmsDebug, "Initializing event reader for device %p fd %d",
+             m_device, m_device->fd());
+ 
+     m_thread = new QEglFSKmsEventReaderThread(m_device->fd());
+diff --git a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
+index 141fb68a23..d4294d425a 100644
+--- a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
++++ b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
+@@ -122,11 +122,13 @@ QOffscreenIntegration::QOffscreenIntegration()
+ #endif
+     m_services.reset(new QPlatformServices);
+ 
+-    QWindowSystemInterface::handleScreenAdded(new QOffscreenScreen);
++    m_screen = new QOffscreenScreen;
++    QWindowSystemInterface::handleScreenAdded(m_screen);
+ }
+ 
+ QOffscreenIntegration::~QOffscreenIntegration()
+ {
++    QWindowSystemInterface::handleScreenRemoved(m_screen);
+ }
+ 
+ void QOffscreenIntegration::initialize()
+diff --git a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
+index 0ea90f6c2f..fe00fde07c 100644
+--- a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
++++ b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
+@@ -84,6 +84,7 @@ protected:
+ #endif
+     QScopedPointer<QPlatformInputContext> m_inputContext;
+     QScopedPointer<QPlatformServices> m_services;
++    QPlatformScreen *m_screen;
+     mutable QScopedPointer<QPlatformNativeInterface> m_nativeInterface;
+ };
+ 
+diff --git a/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp b/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
+index 6fa5a8a2b3..1f49f0aefd 100644
+--- a/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
++++ b/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
+@@ -48,6 +48,7 @@
+ #include <qpa/qplatformnativeinterface.h>
+ #include <QtPlatformHeaders/qwglnativecontext.h>
+ 
++#include <private/qsystemlibrary_p.h>
+ #include <algorithm>
+ 
+ #include <wingdi.h>
+@@ -162,19 +163,25 @@ QFunctionPointer QWindowsOpengl32DLL::resolve(const char *name)
+ 
+ bool QWindowsOpengl32DLL::init(bool softwareRendering)
+ {
+-    const QByteArray opengl32 = QByteArrayLiteral("opengl32.dll");
+-    const QByteArray swopengl = QByteArrayLiteral("opengl32sw.dll");
++    const QByteArray opengl32 = QByteArrayLiteral("opengl32");
++    const QByteArray swopengl = QByteArrayLiteral("opengl32sw");
++    bool useSystemLib = false;
+ 
+     QByteArray openglDll = qgetenv("QT_OPENGL_DLL");
+-    if (openglDll.isEmpty())
++    if (openglDll.isEmpty()) {
+         openglDll = softwareRendering ? swopengl : opengl32;
++        useSystemLib = !softwareRendering;
++    }
+ 
+     openglDll = openglDll.toLower();
+     m_nonOpengl32 = openglDll != opengl32;
+ 
+     qCDebug(lcQpaGl) << "Qt: Using WGL and OpenGL from" << openglDll;
+ 
+-    m_lib = ::LoadLibraryA(openglDll.constData());
++    if (useSystemLib)
++        m_lib = QSystemLibrary::load((wchar_t*)(QString::fromLatin1(openglDll).utf16()));
++    else
++        m_lib = LoadLibraryA(openglDll.constData());
+     if (!m_lib) {
+         qErrnoWarning(::GetLastError(), "Failed to load %s", openglDll.constData());
+         return false;
+@@ -184,7 +191,7 @@ bool QWindowsOpengl32DLL::init(bool softwareRendering)
+         // Load opengl32.dll always. GDI functions like ChoosePixelFormat do
+         // GetModuleHandle for opengl32.dll and behave differently (and call back into
+         // opengl32) when the module is present. This is fine for dummy contexts and windows.
+-        ::LoadLibraryA("opengl32.dll");
++        QSystemLibrary::load(L"opengl32");
+     }
+ 
+     wglCreateContext = reinterpret_cast<HGLRC (WINAPI *)(HDC)>(resolve("wglCreateContext"));
+diff --git a/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp b/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
+index d7d186e804..9eb4011bf2 100644
+--- a/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
++++ b/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
+@@ -49,6 +49,7 @@
+ #include <QtCore/qstandardpaths.h>
+ #include <QtCore/qlibraryinfo.h>
+ #include <QtCore/qhash.h>
++#include <private/qsystemlibrary_p.h>
+ 
+ #ifndef QT_NO_OPENGL
+ #include <private/qopengl_p.h>
+@@ -396,7 +397,7 @@ bool QWindowsOpenGLTester::testDesktopGL()
+ 
+     // Test #1: Load opengl32.dll and try to resolve an OpenGL 2 function.
+     // This will typically fail on systems that do not have a real OpenGL driver.
+-    lib = LoadLibraryA("opengl32.dll");
++    lib = QSystemLibrary::load(L"opengl32");
+     if (lib) {
+         CreateContext = reinterpret_cast<CreateContextType>(
+             reinterpret_cast<QFunctionPointer>(::GetProcAddress(lib, "wglCreateContext")));
+diff --git a/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp b/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
+index 1afa00cfc9..118af6ce73 100644
+--- a/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
++++ b/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
+@@ -41,6 +41,7 @@
+ 
+ #include <QRect>
+ #include <QList>
++#include <QMap>
+ #include <QDebug>
+ 
+ #include <qmath.h>
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp b/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
+index 9e2a37a6a1..e6e175a118 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
+@@ -488,12 +488,12 @@ void QXcbConnection::printXcbError(const char *message, xcb_generic_error_t *err
+     uint clamped_error_code = qMin<uint>(error->error_code, (sizeof(xcb_errors) / sizeof(xcb_errors[0])) - 1);
+     uint clamped_major_code = qMin<uint>(error->major_code, (sizeof(xcb_protocol_request_codes) / sizeof(xcb_protocol_request_codes[0])) - 1);
+ 
+-    qCWarning(lcQpaXcb, "%s: %d (%s), sequence: %d, resource id: %d, major code: %d (%s), minor code: %d",
+-             message,
+-             int(error->error_code), xcb_errors[clamped_error_code],
+-             int(error->sequence), int(error->resource_id),
+-             int(error->major_code), xcb_protocol_request_codes[clamped_major_code],
+-             int(error->minor_code));
++    qCDebug(lcQpaXcb, "%s: %d (%s), sequence: %d, resource id: %d, major code: %d (%s), minor code: %d",
++            message,
++            int(error->error_code), xcb_errors[clamped_error_code],
++            int(error->sequence), int(error->resource_id),
++            int(error->major_code), xcb_protocol_request_codes[clamped_major_code],
++            int(error->minor_code));
+ }
+ 
+ static Qt::MouseButtons translateMouseButtons(int s)
+@@ -702,6 +702,8 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
+             QXcbVirtualDesktop *virtualDesktop = virtualDesktopForRootWindow(propertyNotify->window);
+             if (virtualDesktop)
+                 virtualDesktop->updateWorkArea();
++        } else if (propertyNotify->atom == atom(QXcbAtom::_NET_SUPPORTED)) {
++            m_wmSupport->updateNetWMAtoms();
+         } else {
+             HANDLE_PLATFORM_WINDOW_EVENT(xcb_property_notify_event_t, window, handlePropertyNotifyEvent);
+         }
+@@ -750,7 +752,7 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
+                 case XCB_XKB_NEW_KEYBOARD_NOTIFY: {
+                     xcb_xkb_new_keyboard_notify_event_t *ev = &xkb_event->new_keyboard_notify;
+                     if (ev->changed & XCB_XKB_NKN_DETAIL_KEYCODES)
+-                        m_keyboard->updateKeymap(ev);
++                        m_keyboard->updateKeymap();
+                     break;
+                 }
+                 default:
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp b/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
+index 76869ced60..02d2eebb56 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
+@@ -274,8 +274,7 @@ QPlatformWindow *QXcbIntegration::createForeignWindow(QWindow *window, WId nativ
+ #ifndef QT_NO_OPENGL
+ QPlatformOpenGLContext *QXcbIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
+ {
+-    QXcbScreen *screen = static_cast<QXcbScreen *>(context->screen()->handle());
+-    QXcbGlIntegration *glIntegration = screen->connection()->glIntegration();
++    QXcbGlIntegration *glIntegration = defaultConnection()->glIntegration();
+     if (!glIntegration) {
+         qWarning("QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled");
+         return nullptr;
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+index efecd7e2d1..e8286381a2 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+@@ -365,17 +365,6 @@ void QXcbKeyboard::updateKeymap(xcb_mapping_notify_event_t *event)
+     updateKeymap();
+ }
+ 
+-void QXcbKeyboard::updateKeymap(xcb_xkb_new_keyboard_notify_event_t *event)
+-{
+-    if (!event)
+-        return;
+-
+-    if (event->deviceID != event->oldDeviceID)
+-        m_config = false;
+-
+-    updateKeymap();
+-}
+-
+ void QXcbKeyboard::updateKeymap()
+ {
+     KeysymModifierMap keysymMods;
+@@ -383,6 +372,8 @@ void QXcbKeyboard::updateKeymap()
+         keysymMods = keysymsToModifiers();
+     updateModifiers(keysymMods);
+ 
++    m_config = true;
++
+     if (!m_xkbContext) {
+         m_xkbContext.reset(xkb_context_new(XKB_CONTEXT_NO_DEFAULT_INCLUDES));
+         if (!m_xkbContext) {
+@@ -398,13 +389,8 @@ void QXcbKeyboard::updateKeymap()
+     if (connection()->hasXKB()) {
+         m_xkbKeymap.reset(xkb_x11_keymap_new_from_device(m_xkbContext.get(), xcb_connection(),
+                                                          core_device_id, XKB_KEYMAP_COMPILE_NO_FLAGS));
+-        if (m_xkbKeymap) {
+-            if (m_config)
+-                m_xkbState.reset(xkb_state_new(m_xkbKeymap.get()));
+-            else
+-                m_xkbState.reset(xkb_x11_state_new_from_device(m_xkbKeymap.get(), xcb_connection(), core_device_id));
+-
+-        }
++        if (m_xkbKeymap)
++            m_xkbState.reset(xkb_x11_state_new_from_device(m_xkbKeymap.get(), xcb_connection(), core_device_id));
+     } else {
+         m_xkbKeymap.reset(keymapFromCore(keysymMods));
+         if (m_xkbKeymap)
+@@ -425,8 +411,6 @@ void QXcbKeyboard::updateKeymap()
+     updateXKBMods();
+ 
+     QXkbCommon::verifyHasLatinLayout(m_xkbKeymap.get());
+-
+-    m_config = true;
+ }
+ 
+ QList<int> QXcbKeyboard::possibleKeys(const QKeyEvent *event) const
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
+index b652c85fe3..0ee08aeff2 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
++++ b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
+@@ -69,7 +69,6 @@ public:
+ 
+     Qt::KeyboardModifiers translateModifiers(int s) const;
+     void updateKeymap(xcb_mapping_notify_event_t *event);
+-    void updateKeymap(xcb_xkb_new_keyboard_notify_event_t *event);
+     void updateKeymap();
+     QList<int> possibleKeys(const QKeyEvent *event) const;
+ 
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp b/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
+index ffda7b6a57..863e961f4c 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
+@@ -564,11 +564,6 @@ void QXcbWindow::setGeometry(const QRect &rect)
+ {
+     QPlatformWindow::setGeometry(rect);
+ 
+-    if (shouldDeferTask(Task::SetGeometry)) {
+-        m_deferredGeometry = rect;
+-        return;
+-    }
+-
+     propagateSizeHints();
+ 
+     QXcbScreen *currentScreen = xcbScreen();
+@@ -693,9 +688,6 @@ void QXcbWindow::setVisible(bool visible)
+ 
+ void QXcbWindow::show()
+ {
+-    if (shouldDeferTask(Task::Map))
+-        return;
+-
+     if (window()->isTopLevel()) {
+ 
+         // update WM_NORMAL_HINTS
+@@ -706,7 +698,7 @@ void QXcbWindow::show()
+         if (isTransient(window())) {
+             const QWindow *tp = window()->transientParent();
+             if (tp && tp->handle())
+-                transientXcbParent = static_cast<const QXcbWindow *>(tp->handle())->winId();
++                transientXcbParent = tp->handle()->winId();
+             // Default to client leader if there is no transient parent, else modal dialogs can
+             // be hidden by their parents.
+             if (!transientXcbParent)
+@@ -746,10 +738,6 @@ void QXcbWindow::show()
+ 
+ void QXcbWindow::hide()
+ {
+-    if (shouldDeferTask(Task::Unmap))
+-        return;
+-
+-    m_wmStateValid = false;
+     xcb_unmap_window(xcb_connection(), m_window);
+ 
+     // send synthetic UnmapNotify event according to icccm 4.1.4
+@@ -909,9 +897,6 @@ QXcbWindow::NetWmStates QXcbWindow::netWmStates()
+ 
+ void QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
+ {
+-    if (shouldDeferTask(Task::SetWindowFlags))
+-        return;
+-
+     Qt::WindowType type = static_cast<Qt::WindowType>(int(flags & Qt::WindowType_Mask));
+ 
+     if (type == Qt::ToolTip)
+@@ -941,8 +926,6 @@ void QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
+ 
+     setTransparentForMouseEvents(flags & Qt::WindowTransparentForInput);
+     updateDoesNotAcceptFocus(flags & Qt::WindowDoesNotAcceptFocus);
+-
+-    m_isWmManagedWindow = !(flags & Qt::X11BypassWindowManagerHint);
+ }
+ 
+ void QXcbWindow::setMotifWmHints(Qt::WindowFlags flags)
+@@ -1142,9 +1125,6 @@ void QXcbWindow::setWindowState(Qt::WindowStates state)
+     if (state == m_windowState)
+         return;
+ 
+-    if (shouldDeferTask(Task::SetWindowState))
+-        return;
+-
+     // unset old state
+     if (m_windowState & Qt::WindowMinimized)
+         xcb_map_window(xcb_connection(), m_window);
+@@ -1350,6 +1330,12 @@ void QXcbWindow::setWindowIcon(const QIcon &icon)
+     }
+ 
+     if (!icon_data.isEmpty()) {
++        // Ignore icon exceeding maximum xcb request length
++        if (icon_data.size() > xcb_get_maximum_request_length(xcb_connection())) {
++            qWarning("Ignoring window icon: Size %llu exceeds maximum xcb request length %u.",
++                     icon_data.size(), xcb_get_maximum_request_length(xcb_connection()));
++            return;
++        }
+         xcb_change_property(xcb_connection(),
+                             XCB_PROP_MODE_REPLACE,
+                             m_window,
+@@ -1639,7 +1625,7 @@ void QXcbWindow::setWmWindowType(QXcbWindowFunctions::WmWindowTypes types, Qt::W
+         break;
+     }
+ 
+-    if ((flags & Qt::FramelessWindowHint) && !(type & QXcbWindowFunctions::KdeOverride)) {
++    if ((flags & Qt::FramelessWindowHint) && !(types & QXcbWindowFunctions::KdeOverride)) {
+         // override netwm type - quick and easy for KDE noborder
+         atoms.append(atom(QXcbAtom::_KDE_NET_WM_WINDOW_TYPE_OVERRIDE));
+     }
+@@ -1894,10 +1880,6 @@ void QXcbWindow::handleUnmapNotifyEvent(const xcb_unmap_notify_event_t *event)
+     if (event->window == m_window) {
+         m_mapped = false;
+         QWindowSystemInterface::handleExposeEvent(window(), QRegion());
+-        if (!m_isWmManagedWindow || parent()) {
+-            m_wmStateValid = true;
+-            handleDeferredTasks();
+-        }
+     }
+ }
+ 
+@@ -2212,98 +2194,30 @@ void QXcbWindow::handleLeaveNotifyEvent(const xcb_leave_notify_event_t *event)
+     handleLeaveNotifyEvent(event->root_x, event->root_y, event->mode, event->detail, event->time);
+ }
+ 
+-bool QXcbWindow::shouldDeferTask(Task task)
+-{
+-    if (m_wmStateValid)
+-        return false;
+-
+-    m_deferredTasks.append(task);
+-    return true;
+-}
+-
+-void QXcbWindow::handleDeferredTasks()
+-{
+-    Q_ASSERT(m_wmStateValid == true);
+-    if (m_deferredTasks.isEmpty())
+-        return;
+-
+-    bool map = false;
+-    bool unmap = false;
+-
+-    QVector<Task> tasks;
+-    for (auto taskIt = m_deferredTasks.rbegin(); taskIt != m_deferredTasks.rend(); ++taskIt) {
+-        if (!tasks.contains(*taskIt))
+-            tasks.prepend(*taskIt);
+-    }
+-
+-    for (Task task : tasks) {
+-        switch (task) {
+-        case Task::Map:
+-            map = true;
+-            unmap = false;
+-            break;
+-        case Task::Unmap:
+-            unmap = true;
+-            map = false;
+-            break;
+-        case Task::SetGeometry:
+-            setGeometry(m_deferredGeometry);
+-            break;
+-        case Task::SetWindowFlags:
+-            setWindowFlags(window()->flags());
+-            break;
+-        case Task::SetWindowState:
+-            setWindowState(window()->windowState());
+-            break;
+-        }
+-    }
+-    m_deferredTasks.clear();
+-
+-    if (map) {
+-        Q_ASSERT(unmap == false);
+-        show();
+-    }
+-    if (unmap) {
+-        Q_ASSERT(map == false);
+-        hide();
+-    }
+-}
+-
+ void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *event)
+ {
+     connection()->setTime(event->time);
+ 
+-    const bool wmStateChanged = event->atom == atom(QXcbAtom::WM_STATE);
+-    const bool netWmStateChanged = event->atom == atom(QXcbAtom::_NET_WM_STATE);
+-    if (netWmStateChanged || wmStateChanged) {
+-        if (wmStateChanged && !m_wmStateValid && m_isWmManagedWindow) {
+-            // ICCCM 4.1.4
+-            // Clients that want to re-use a client window (e.g. by mapping it again)
+-            // after withdrawing it must wait for the withdrawal to be complete before
+-            // proceeding. The preferred method for doing this is for clients to wait for
+-            // a window manager to update or remove the WM_STATE property.
+-            m_wmStateValid = true;
+-            handleDeferredTasks();
+-        }
+-        if (event->state == XCB_PROPERTY_DELETE)
++    const bool propertyDeleted = event->state == XCB_PROPERTY_DELETE;
++
++    if (event->atom == atom(QXcbAtom::_NET_WM_STATE) || event->atom == atom(QXcbAtom::WM_STATE)) {
++        if (propertyDeleted)
+             return;
+ 
+-        if (wmStateChanged) {
++        Qt::WindowStates newState = Qt::WindowNoState;
++
++        if (event->atom == atom(QXcbAtom::WM_STATE)) { // WM_STATE: Quick check for 'Minimize'.
+             auto reply = Q_XCB_REPLY(xcb_get_property, xcb_connection(),
+                                      0, m_window, atom(QXcbAtom::WM_STATE),
+                                      XCB_ATOM_ANY, 0, 1024);
+             if (reply && reply->format == 32 && reply->type == atom(QXcbAtom::WM_STATE)) {
+-                auto data = static_cast<const quint32 *>(xcb_get_property_value(reply.get()));
+-                if (reply->length != 0) {
+-                    const bool changedToWithdrawn = data[0] == XCB_ICCCM_WM_STATE_WITHDRAWN;
+-                    const bool changedToIconic = data[0] == XCB_ICCCM_WM_STATE_ICONIC;
+-                    m_minimized = changedToIconic || (changedToWithdrawn && m_minimized);
+-                }
++                const quint32 *data = (const quint32 *)xcb_get_property_value(reply.get());
++                if (reply->length != 0)
++                    m_minimized = (data[0] == XCB_ICCCM_WM_STATE_ICONIC
++                                   || (data[0] == XCB_ICCCM_WM_STATE_WITHDRAWN && m_minimized));
+             }
+         }
+ 
+-        // _NET_WM_STATE handling
+-        Qt::WindowStates newState = Qt::WindowNoState;
+         const NetWmStates states = netWmStates();
+         // _NET_WM_STATE_HIDDEN should be set by the Window Manager to indicate that a window would
+         // not be visible on the screen if its desktop/viewport were active and its coordinates were
+@@ -2325,6 +2239,7 @@ void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *ev
+             if ((m_windowState & Qt::WindowMinimized) && connection()->mouseGrabber() == this)
+                 connection()->setMouseGrabber(nullptr);
+         }
++        return;
+     } else if (event->atom == atom(QXcbAtom::_NET_FRAME_EXTENTS)) {
+         m_dirtyFrameMargins = true;
+     }
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbwindow.h b/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
+index 55af9279b1..6f5c1f5ed9 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
++++ b/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
+@@ -74,14 +74,6 @@ public:
+ 
+     Q_DECLARE_FLAGS(NetWmStates, NetWmState)
+ 
+-    enum Task {
+-        Map,
+-        Unmap,
+-        SetGeometry,
+-        SetWindowFlags,
+-        SetWindowState
+-    };
+-
+     QXcbWindow(QWindow *window);
+     ~QXcbWindow();
+ 
+@@ -151,9 +143,6 @@ public:
+ 
+     QXcbWindow *toWindow() override;
+ 
+-    bool shouldDeferTask(Task task);
+-    void handleDeferredTasks();
+-
+     void handleMouseEvent(xcb_timestamp_t time, const QPoint &local, const QPoint &global,
+                           Qt::KeyboardModifiers modifiers, QEvent::Type type, Qt::MouseEventSource source);
+ 
+@@ -292,11 +281,6 @@ protected:
+     int m_swapInterval = -1;
+ 
+     qreal m_sizeHintsScaleFactor = 1.0;
+-
+-    bool m_wmStateValid = true;
+-    QVector<Task> m_deferredTasks;
+-    bool m_isWmManagedWindow = true;
+-    QRect m_deferredGeometry;
+ };
+ 
+ class QXcbForeignWindow : public QXcbWindow
+diff --git a/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp b/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
+index d9d117faeb..640b49daa0 100644
+--- a/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
++++ b/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
+@@ -85,6 +85,7 @@ QGtk3MenuItem::QGtk3MenuItem()
+       m_checkable(false),
+       m_checked(false),
+       m_enabled(true),
++      m_exclusive(false),
+       m_underline(false),
+       m_invalid(true),
+       m_menu(nullptr),
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
+index 0048bbc1e6..396e7f6d1c 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
+@@ -102,15 +102,12 @@ const QDBusArgument &operator >>(const QDBusArgument &arg, QXdgDesktopPortalFile
+ class QXdgDesktopPortalFileDialogPrivate
+ {
+ public:
+-    QXdgDesktopPortalFileDialogPrivate(QPlatformFileDialogHelper *nativeFileDialog)
++    QXdgDesktopPortalFileDialogPrivate(QPlatformFileDialogHelper *nativeFileDialog, uint fileChooserPortalVersion)
+         : nativeFileDialog(nativeFileDialog)
++        , fileChooserPortalVersion(fileChooserPortalVersion)
+     { }
+ 
+-    WId winId = 0;
+-    bool directoryMode = false;
+-    bool modal = false;
+-    bool multipleFiles = false;
+-    bool saveFile = false;
++    QEventLoop loop;
+     QString acceptLabel;
+     QString directory;
+     QString title;
+@@ -121,19 +118,27 @@ public:
+     QString selectedMimeTypeFilter;
+     QString selectedNameFilter;
+     QStringList selectedFiles;
+-    QPlatformFileDialogHelper *nativeFileDialog = nullptr;
++    std::unique_ptr<QPlatformFileDialogHelper> nativeFileDialog;
++    uint fileChooserPortalVersion = 0;
++    bool failedToOpen = false;
++    bool directoryMode = false;
++    bool multipleFiles = false;
++    bool saveFile = false;
+ };
+ 
+-QXdgDesktopPortalFileDialog::QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog)
++QXdgDesktopPortalFileDialog::QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog, uint fileChooserPortalVersion)
+     : QPlatformFileDialogHelper()
+-    , d_ptr(new QXdgDesktopPortalFileDialogPrivate(nativeFileDialog))
++    , d_ptr(new QXdgDesktopPortalFileDialogPrivate(nativeFileDialog, fileChooserPortalVersion))
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+     if (d->nativeFileDialog) {
+-        connect(d->nativeFileDialog, SIGNAL(accept()), this, SIGNAL(accept()));
+-        connect(d->nativeFileDialog, SIGNAL(reject()), this, SIGNAL(reject()));
++        connect(d->nativeFileDialog.get(), SIGNAL(accept()), this, SIGNAL(accept()));
++        connect(d->nativeFileDialog.get(), SIGNAL(reject()), this, SIGNAL(reject()));
+     }
++
++    d->loop.connect(this, SIGNAL(accept()), SLOT(quit()));
++    d->loop.connect(this, SIGNAL(reject()), SLOT(quit()));
+ }
+ 
+ QXdgDesktopPortalFileDialog::~QXdgDesktopPortalFileDialog()
+@@ -177,7 +182,7 @@ void QXdgDesktopPortalFileDialog::initializeDialog()
+     setDirectory(options()->initialDirectory());
+ }
+ 
+-void QXdgDesktopPortalFileDialog::openPortal()
++void QXdgDesktopPortalFileDialog::openPortal(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent)
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+@@ -185,13 +190,13 @@ void QXdgDesktopPortalFileDialog::openPortal()
+                                                           QLatin1String("/org/freedesktop/portal/desktop"),
+                                                           QLatin1String("org.freedesktop.portal.FileChooser"),
+                                                           d->saveFile ? QLatin1String("SaveFile") : QLatin1String("OpenFile"));
+-    QString parentWindowId = QLatin1String("x11:") + QString::number(d->winId, 16);
++    QString parentWindowId = QLatin1String("x11:") + QString::number(parent ? parent->winId() : 0, 16);
+ 
+     QVariantMap options;
+     if (!d->acceptLabel.isEmpty())
+         options.insert(QLatin1String("accept_label"), d->acceptLabel);
+ 
+-    options.insert(QLatin1String("modal"), d->modal);
++    options.insert(QLatin1String("modal"), windowModality != Qt::NonModal);
+     options.insert(QLatin1String("multiple"), d->multipleFiles);
+     options.insert(QLatin1String("directory"), d->directoryMode);
+ 
+@@ -290,10 +295,18 @@ void QXdgDesktopPortalFileDialog::openPortal()
+ 
+     QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
+     QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingCall);
+-    connect(watcher, &QDBusPendingCallWatcher::finished, this, [this] (QDBusPendingCallWatcher *watcher) {
++    connect(watcher, &QDBusPendingCallWatcher::finished, this, [=] (QDBusPendingCallWatcher *watcher) {
+         QDBusPendingReply<QDBusObjectPath> reply = *watcher;
+-        if (reply.isError()) {
+-            Q_EMIT reject();
++        // Any error means the dialog is not shown and we need to fallback
++        d->failedToOpen = reply.isError();
++        if (d->failedToOpen) {
++            if (d->nativeFileDialog) {
++                d->nativeFileDialog->show(windowFlags, windowModality, parent);
++                if (d->loop.isRunning())
++                    d->nativeFileDialog->exec();
++            } else {
++                Q_EMIT reject();
++            }
+         } else {
+             QDBusConnection::sessionBus().connect(nullptr,
+                                                   reply.value().path(),
+@@ -302,6 +315,7 @@ void QXdgDesktopPortalFileDialog::openPortal()
+                                                   this,
+                                                   SLOT(gotResponse(uint,QVariantMap)));
+         }
++        watcher->deleteLater();
+     });
+ }
+ 
+@@ -326,7 +340,7 @@ QUrl QXdgDesktopPortalFileDialog::directory() const
+ {
+     Q_D(const QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog())
+         return d->nativeFileDialog->directory();
+ 
+     return d->directory;
+@@ -348,7 +362,7 @@ QList<QUrl> QXdgDesktopPortalFileDialog::selectedFiles() const
+ {
+     Q_D(const QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog())
+         return d->nativeFileDialog->selectedFiles();
+ 
+     QList<QUrl> files;
+@@ -403,16 +417,13 @@ void QXdgDesktopPortalFileDialog::exec()
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly)) {
++    if (d->nativeFileDialog && useNativeFileDialog()) {
+         d->nativeFileDialog->exec();
+         return;
+     }
+ 
+     // HACK we have to avoid returning until we emit that the dialog was accepted or rejected
+-    QEventLoop loop;
+-    loop.connect(this, SIGNAL(accept()), SLOT(quit()));
+-    loop.connect(this, SIGNAL(reject()), SLOT(quit()));
+-    loop.exec();
++    d->loop.exec();
+ }
+ 
+ void QXdgDesktopPortalFileDialog::hide()
+@@ -429,13 +440,10 @@ bool QXdgDesktopPortalFileDialog::show(Qt::WindowFlags windowFlags, Qt::WindowMo
+ 
+     initializeDialog();
+ 
+-    d->modal = windowModality != Qt::NonModal;
+-    d->winId = parent ? parent->winId() : 0;
+-
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog(OpenFallback))
+         return d->nativeFileDialog->show(windowFlags, windowModality, parent);
+ 
+-    openPortal();
++    openPortal(windowFlags, windowModality, parent);
+ 
+     return true;
+ }
+@@ -465,4 +473,21 @@ void QXdgDesktopPortalFileDialog::gotResponse(uint response, const QVariantMap &
+     }
+ }
+ 
++bool QXdgDesktopPortalFileDialog::useNativeFileDialog(QXdgDesktopPortalFileDialog::FallbackType fallbackType) const
++{
++    Q_D(const QXdgDesktopPortalFileDialog);
++
++    if (d->failedToOpen && fallbackType != OpenFallback)
++        return true;
++
++    if (d->fileChooserPortalVersion < 3) {
++        if (options()->fileMode() == QFileDialogOptions::Directory)
++            return true;
++        else if (options()->fileMode() == QFileDialogOptions::DirectoryOnly)
++            return true;
++    }
++
++    return false;
++}
++
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
+index 4f4de96ecf..65e22a5cf2 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
+@@ -51,6 +51,11 @@ class QXdgDesktopPortalFileDialog : public QPlatformFileDialogHelper
+     Q_OBJECT
+     Q_DECLARE_PRIVATE(QXdgDesktopPortalFileDialog)
+ public:
++    enum FallbackType {
++        GenericFallback,
++        OpenFallback
++    };
++
+     enum ConditionType : uint {
+         GlobalPattern = 0,
+         MimeType = 1
+@@ -69,7 +74,7 @@ public:
+     };
+     typedef QVector<Filter> FilterList;
+ 
+-    QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog = nullptr);
++    QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog = nullptr, uint fileChooserPortalVersion = 0);
+     ~QXdgDesktopPortalFileDialog();
+ 
+     bool defaultNameFilterDisables() const override;
+@@ -92,7 +97,8 @@ private Q_SLOTS:
+ 
+ private:
+     void initializeDialog();
+-    void openPortal();
++    void openPortal(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent);
++    bool useNativeFileDialog(FallbackType fallbackType = GenericFallback) const;
+ 
+     QScopedPointer<QXdgDesktopPortalFileDialogPrivate> d_ptr;
+ };
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
+index fb324afbd8..b809503122 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
+@@ -111,6 +111,7 @@ QXdgDesktopPortalTheme::QXdgDesktopPortalTheme()
+         if (reply.isValid()) {
+             d->fileChooserPortalVersion = reply.value().toUInt();
+         }
++        watcher->deleteLater();
+     });
+ }
+ 
+@@ -152,11 +153,12 @@ QPlatformDialogHelper* QXdgDesktopPortalTheme::createPlatformDialogHelper(Dialog
+ {
+     Q_D(const QXdgDesktopPortalTheme);
+ 
+-    if (type == FileDialog) {
++    if (type == FileDialog && d->fileChooserPortalVersion) {
+         // Older versions of FileChooser portal don't support opening directories, therefore we fallback
+         // to native file dialog opened inside the sandbox to open a directory.
+-        if (d->fileChooserPortalVersion < 3 && d->baseTheme->usePlatformNativeDialog(type))
+-            return new QXdgDesktopPortalFileDialog(static_cast<QPlatformFileDialogHelper*>(d->baseTheme->createPlatformDialogHelper(type)));
++        if (d->baseTheme->usePlatformNativeDialog(type))
++            return new QXdgDesktopPortalFileDialog(static_cast<QPlatformFileDialogHelper*>(d->baseTheme->createPlatformDialogHelper(type)),
++                                                   d->fileChooserPortalVersion);
+ 
+         return new QXdgDesktopPortalFileDialog;
+     }
+diff --git a/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp b/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
+index 43d5e119ad..1f9cbc4565 100644
+--- a/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
++++ b/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
+@@ -89,8 +89,10 @@ void QCupsPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &v
+         break;
+     case PPK_Duplex: {
+         QPrint::DuplexMode mode = QPrint::DuplexMode(value.toInt());
+-        if (mode != d->duplex && d->m_printDevice.supportedDuplexModes().contains(mode))
++        if (d->m_printDevice.supportedDuplexModes().contains(mode)) {
+             d->duplex = mode;
++            d->duplexRequestedExplicitly = true;
++        }
+         break;
+     }
+     case PPK_PrinterName:
+@@ -277,9 +279,12 @@ void QCupsPrintEnginePrivate::changePrinter(const QString &newPrinter)
+     m_printDevice.swap(printDevice);
+     printerName = m_printDevice.id();
+ 
+-    // Check if new printer supports current settings, otherwise us defaults
+-    if (duplex != QPrint::DuplexAuto && !m_printDevice.supportedDuplexModes().contains(duplex))
++    // in case a duplex value was explicitly set, check if new printer supports current value,
++    // otherwise use device default
++    if (!duplexRequestedExplicitly || !m_printDevice.supportedDuplexModes().contains(duplex)) {
+         duplex = m_printDevice.defaultDuplexMode();
++        duplexRequestedExplicitly = false;
++    }
+     QPrint::ColorMode colorMode = grayscale ? QPrint::GrayScale : QPrint::Color;
+     if (!m_printDevice.supportedColorModes().contains(colorMode))
+         grayscale = m_printDevice.defaultColorMode() == QPrint::GrayScale;
+diff --git a/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h b/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
+index c021b0c643..8f81fe478d 100644
+--- a/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
++++ b/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
+@@ -100,6 +100,7 @@ private:
+     QStringList cupsOptions;
+     QString cupsTempFile;
+     QPrint::DuplexMode duplex;
++    bool duplexRequestedExplicitly = false;
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp b/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
+index 67e7154fa6..40876152e5 100644
+--- a/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
++++ b/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
+@@ -817,7 +817,7 @@ bool QIBaseResultPrivate::writeArray(int column, const QList<QVariant> &list)
+     ba.resize(int(bufLen));
+ 
+     if (list.size() > arraySize) {
+-        error = QLatin1String("Array size missmatch: size of %1 is %2, size of provided list is %3");
++        error = QLatin1String("Array size mismatch: size of %1 is %2, size of provided list is %3");
+         error = error.arg(QLatin1String(sqlname)).arg(arraySize).arg(list.size());
+         q->setLastError(QSqlError(error, QLatin1String(""), QSqlError::StatementError));
+         return false;
+diff --git a/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp b/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
+index 7ca055eea2..6bc9d46755 100644
+--- a/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
++++ b/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
+@@ -223,7 +223,7 @@ public:
+     struct QMyField
+     {
+         char *outField = nullptr;
+-        MYSQL_FIELD *myField = nullptr;
++        const MYSQL_FIELD *myField = nullptr;
+         QMetaType::Type type = QMetaType::UnknownType;
+         my_bool nullIndicator = false;
+         ulong bufLength = 0ul;
+@@ -361,7 +361,7 @@ static bool qIsInteger(int t)
+ void QMYSQLResultPrivate::bindBlobs()
+ {
+     int i;
+-    MYSQL_FIELD *fieldInfo;
++    const MYSQL_FIELD *fieldInfo;
+     MYSQL_BIND *bind;
+ 
+     for(i = 0; i < fields.count(); ++i) {
+@@ -379,7 +379,6 @@ void QMYSQLResultPrivate::bindBlobs()
+ bool QMYSQLResultPrivate::bindInValues()
+ {
+     MYSQL_BIND *bind;
+-    char *field;
+     int i = 0;
+ 
+     if (!meta)
+@@ -392,35 +391,34 @@ bool QMYSQLResultPrivate::bindInValues()
+     inBinds = new MYSQL_BIND[fields.size()];
+     memset(inBinds, 0, fields.size() * sizeof(MYSQL_BIND));
+ 
+-    MYSQL_FIELD *fieldInfo;
++    const MYSQL_FIELD *fieldInfo;
+ 
+     while((fieldInfo = mysql_fetch_field(meta))) {
++        bind = &inBinds[i];
++
+         QMyField &f = fields[i];
+         f.myField = fieldInfo;
+-
++        bind->buffer_length = f.bufLength = fieldInfo->length + 1;
++        bind->buffer_type = fieldInfo->type;
+         f.type = qDecodeMYSQLType(fieldInfo->type, fieldInfo->flags);
+         if (qIsBlob(fieldInfo->type)) {
+             // the size of a blob-field is available as soon as we call
+             // mysql_stmt_store_result()
+             // after mysql_stmt_exec() in QMYSQLResult::exec()
+-            fieldInfo->length = 0;
++            bind->buffer_length = f.bufLength = 0;
+             hasBlobs = true;
+         } else if (qIsInteger(f.type)) {
+-            fieldInfo->length = 8;
++            bind->buffer_length = f.bufLength = 8;
+         } else {
+-            fieldInfo->type = MYSQL_TYPE_STRING;
++            bind->buffer_type = MYSQL_TYPE_STRING;
+         }
+-        bind = &inBinds[i];
+-        field = new char[fieldInfo->length + 1];
+-        memset(field, 0, fieldInfo->length + 1);
+ 
+-        bind->buffer_type = fieldInfo->type;
+-        bind->buffer = field;
+-        bind->buffer_length = f.bufLength = fieldInfo->length + 1;
+         bind->is_null = &f.nullIndicator;
+         bind->length = &f.bufLength;
+         bind->is_unsigned = fieldInfo->flags & UNSIGNED_FLAG ? 1 : 0;
+-        f.outField=field;
++
++        char *field = new char[bind->buffer_length + 1]{};
++        bind->buffer = f.outField = field;
+ 
+         ++i;
+     }
+@@ -1369,20 +1367,20 @@ bool QMYSQLDriver::open(const QString& db,
+     }
+ 
+ #if MYSQL_VERSION_ID >= 50007
+-    if (mysql_get_client_version() >= 50503 && mysql_get_server_version(d->mysql) >= 50503) {
+-        // force the communication to be utf8mb4 (only utf8mb4 supports 4-byte characters)
+-        mysql_set_character_set(d->mysql, "utf8mb4");
++    // force the communication to be utf8mb4 (only utf8mb4 supports 4-byte characters)
++    if (mysql_set_character_set(d->mysql, "utf8mb4")) {
++        // this failed, try forcing it to utf (BMP only)
++        if (mysql_set_character_set(d->mysql, "utf8"))
++            qWarning() << "MySQL: Unable to set the client character set to utf8.";
+ #if QT_CONFIG(textcodec)
+-        d->tc = QTextCodec::codecForName("UTF-8");
++        else
++            d->tc = codec(d->mysql);
+ #endif
+-    } else
+-    {
+-        // force the communication to be utf8
+-        mysql_set_character_set(d->mysql, "utf8");
++    }
+ #if QT_CONFIG(textcodec)
+-        d->tc = codec(d->mysql);
++    else
++        d->tc = QTextCodec::codecForName("UTF-8");
+ #endif
+-    }
+ #endif  // MYSQL_VERSION_ID >= 50007
+ 
+     d->preparedQuerysEnabled = checkPreparedQueries(d->mysql);
+diff --git a/qtbase/src/printsupport/dialogs/images/print-24.png b/qtbase/src/printsupport/dialogs/images/printer-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/print-24.png
+rename to src/printsupport/dialogs/images/printer-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/print-32.png b/qtbase/src/printsupport/dialogs/images/printer-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/print-32.png
+rename to src/printsupport/dialogs/images/printer-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-sided-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-facing-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-sided-24.png
+rename to src/printsupport/dialogs/images/view-pages-facing-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-sided-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-facing-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-sided-32.png
+rename to src/printsupport/dialogs/images/view-pages-facing-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-multi-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-overview-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-multi-24.png
+rename to src/printsupport/dialogs/images/view-pages-overview-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-multi-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-overview-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-multi-32.png
+rename to src/printsupport/dialogs/images/view-pages-overview-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-one-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-single-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-one-24.png
+rename to src/printsupport/dialogs/images/view-pages-single-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-one-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-single-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-one-32.png
+rename to src/printsupport/dialogs/images/view-pages-single-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-page-24.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-page-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-page-24.png
+rename to src/printsupport/dialogs/images/zoom-fit-page-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-page-32.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-page-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-page-32.png
+rename to src/printsupport/dialogs/images/zoom-fit-page-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-width-24.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-width-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-width-24.png
+rename to src/printsupport/dialogs/images/zoom-fit-width-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-width-32.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-width-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-width-32.png
+rename to src/printsupport/dialogs/images/zoom-fit-width-32.png
+diff --git a/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp b/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
+index 78e5b8d1ef..2a28516719 100644
+--- a/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
++++ b/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
+@@ -532,6 +532,7 @@ void QPageSetupWidget::updateWidget()
+ void QPageSetupWidget::setupPrinter() const
+ {
+     m_printer->setPageLayout(m_pageLayout);
++    m_printer->setPageOrientation(m_pageLayout.orientation());
+ #if QT_CONFIG(cups)
+     QCUPSSupport::PagesPerSheet pagesPerSheet = qvariant_cast<QCUPSSupport::PagesPerSheet>(m_ui.pagesPerSheetCombo->currentData()
+ );
+diff --git a/qtbase/src/printsupport/dialogs/qprintdialog.qrc b/qtbase/src/printsupport/dialogs/qprintdialog.qrc
+index 5a579baa55..10b8e1d341 100644
+--- a/qtbase/src/printsupport/dialogs/qprintdialog.qrc
++++ b/qtbase/src/printsupport/dialogs/qprintdialog.qrc
+@@ -1,9 +1,9 @@
+ <!DOCTYPE RCC><RCC version="1.0">
+ <qresource prefix="/qt-project.org/dialogs/qprintpreviewdialog">
+-<file>images/fit-page-24.png</file>
+-<file>images/fit-page-32.png</file>
+-<file>images/fit-width-24.png</file>
+-<file>images/fit-width-32.png</file>
++<file>images/zoom-fit-page-24.png</file>
++<file>images/zoom-fit-page-32.png</file>
++<file>images/zoom-fit-width-24.png</file>
++<file>images/zoom-fit-width-32.png</file>
+ <file>images/go-first-24.png</file>
+ <file>images/go-first-32.png</file>
+ <file>images/go-last-24.png</file>
+@@ -18,14 +18,14 @@
+ <file>images/layout-portrait-32.png</file>
+ <file>images/page-setup-24.png</file>
+ <file>images/page-setup-32.png</file>
+-<file>images/print-24.png</file>
+-<file>images/print-32.png</file>
+-<file>images/view-page-multi-24.png</file>
+-<file>images/view-page-multi-32.png</file>
+-<file>images/view-page-one-24.png</file>
+-<file>images/view-page-one-32.png</file>
+-<file>images/view-page-sided-24.png</file>
+-<file>images/view-page-sided-32.png</file>
++<file>images/printer-24.png</file>
++<file>images/printer-32.png</file>
++<file>images/view-pages-overview-24.png</file>
++<file>images/view-pages-overview-32.png</file>
++<file>images/view-pages-single-24.png</file>
++<file>images/view-pages-single-32.png</file>
++<file>images/view-pages-facing-24.png</file>
++<file>images/view-pages-facing-32.png</file>
+ <file>images/zoom-in-24.png</file>
+ <file>images/zoom-in-32.png</file>
+ <file>images/zoom-out-24.png</file>
+diff --git a/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp b/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
+index c5b845f4ec..5a5ba1d0a8 100644
+--- a/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
++++ b/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
+@@ -702,13 +702,14 @@ void QPrintDialogPrivate::selectPrinter(const QPrinter::OutputFormat outputForma
+         else
+             options.grayscale->setChecked(true);
+ 
+-        // keep duplex value explicitly set by user, if any, and selected printer supports it;
+-        // use device default otherwise
++        // duplex priorities to be as follows:
++        // 1) a user-selected duplex value in the dialog has highest prority
++        // 2) duplex value set in the QPrinter
+         QPrint::DuplexMode duplex;
+         if (explicitDuplexMode != QPrint::DuplexAuto && supportedDuplexMode.contains(explicitDuplexMode))
+             duplex = explicitDuplexMode;
+         else
+-            duplex = top->d->m_currentPrintDevice.defaultDuplexMode();
++            duplex = static_cast<QPrint::DuplexMode>(p->duplex());
+         switch (duplex) {
+         case QPrint::DuplexNone:
+             options.noDuplex->setChecked(true); break;
+@@ -1242,10 +1243,10 @@ void QUnixPrintWidgetPrivate::_q_printerChanged(int index)
+             QString filename = widget.filename->text();
+             widget.filename->setText(filename);
+             widget.lOutput->setEnabled(true);
+-            if (optionsPane)
+-                optionsPane->selectPrinter(QPrinter::PdfFormat);
+             printer->setOutputFormat(QPrinter::PdfFormat);
+             m_currentPrintDevice = QPrintDevice();
++            if (optionsPane)
++                optionsPane->selectPrinter(QPrinter::PdfFormat);
+             return;
+         }
+     }
+diff --git a/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp b/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
+index 39575d5f57..23b7e89538 100644
+--- a/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
++++ b/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
+@@ -352,7 +352,7 @@ void QPrintPreviewDialogPrivate::init(QPrinter *_printer)
+ static inline void qt_setupActionIcon(QAction *action, QLatin1String name)
+ {
+     QLatin1String imagePrefix(":/qt-project.org/dialogs/qprintpreviewdialog/images/");
+-    QIcon icon;
++    QIcon icon = QIcon::fromTheme(name);
+     icon.addFile(imagePrefix + name + QLatin1String("-24.png"), QSize(24, 24));
+     icon.addFile(imagePrefix + name + QLatin1String("-32.png"), QSize(32, 32));
+     action->setIcon(icon);
+@@ -383,8 +383,8 @@ void QPrintPreviewDialogPrivate::setupActions()
+     fitPageAction->setObjectName(QLatin1String("fitPageAction"));
+     fitWidthAction->setCheckable(true);
+     fitPageAction->setCheckable(true);
+-    qt_setupActionIcon(fitWidthAction, QLatin1String("fit-width"));
+-    qt_setupActionIcon(fitPageAction, QLatin1String("fit-page"));
++    qt_setupActionIcon(fitWidthAction, QLatin1String("zoom-fit-width"));
++    qt_setupActionIcon(fitPageAction, QLatin1String("zoom-fit-page"));
+     QObject::connect(fitGroup, SIGNAL(triggered(QAction*)), q, SLOT(_q_fit(QAction*)));
+ 
+     // Zoom
+@@ -410,9 +410,9 @@ void QPrintPreviewDialogPrivate::setupActions()
+     singleModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show single page"));
+     facingModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show facing pages"));
+     overviewModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show overview of all pages"));
+-    qt_setupActionIcon(singleModeAction, QLatin1String("view-page-one"));
+-    qt_setupActionIcon(facingModeAction, QLatin1String("view-page-sided"));
+-    qt_setupActionIcon(overviewModeAction, QLatin1String("view-page-multi"));
++    qt_setupActionIcon(singleModeAction, QLatin1String("view-pages-single"));
++    qt_setupActionIcon(facingModeAction, QLatin1String("view-pages-facing"));
++    qt_setupActionIcon(overviewModeAction, QLatin1String("view-pages-overview"));
+     singleModeAction->setObjectName(QLatin1String("singleModeAction"));
+     facingModeAction->setObjectName(QLatin1String("facingModeAction"));
+     overviewModeAction->setObjectName(QLatin1String("overviewModeAction"));
+@@ -426,7 +426,7 @@ void QPrintPreviewDialogPrivate::setupActions()
+     printerGroup = new QActionGroup(q);
+     printAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Print"));
+     pageSetupAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Page setup"));
+-    qt_setupActionIcon(printAction, QLatin1String("print"));
++    qt_setupActionIcon(printAction, QLatin1String("printer"));
+     qt_setupActionIcon(pageSetupAction, QLatin1String("page-setup"));
+     QObject::connect(printAction, SIGNAL(triggered(bool)), q, SLOT(_q_print()));
+     QObject::connect(pageSetupAction, SIGNAL(triggered(bool)), q, SLOT(_q_pageSetup()));
+diff --git a/qtbase/src/sql/kernel/qsqlquery.cpp b/qtbase/src/sql/kernel/qsqlquery.cpp
+index 32c6166c79..60afef10c3 100644
+--- a/qtbase/src/sql/kernel/qsqlquery.cpp
++++ b/qtbase/src/sql/kernel/qsqlquery.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2022 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtSql module of the Qt Toolkit.
+@@ -377,6 +377,10 @@ bool QSqlQuery::exec(const QString& query)
+     QElapsedTimer t;
+     t.start();
+ #endif
++    if (!driver()) {
++        qWarning("QSqlQuery::exec: called before driver has been set up");
++        return false;
++    }
+     if (d->ref.loadRelaxed() != 1) {
+         bool fo = isForwardOnly();
+         *this = QSqlQuery(driver()->createResult());
+diff --git a/qtbase/src/testlib/qabstractitemmodeltester.cpp b/qtbase/src/testlib/qabstractitemmodeltester.cpp
+index 8efb9c53d4..ce062f66d7 100644
+--- a/qtbase/src/testlib/qabstractitemmodeltester.cpp
++++ b/qtbase/src/testlib/qabstractitemmodeltester.cpp
+@@ -454,7 +454,7 @@ void QAbstractItemModelTesterPrivate::parent()
+ 
+     // Common error test #2, make sure that a second level index has a parent
+     // that is the first level index.
+-    if (model->rowCount(topIndex) > 0) {
++    if (model->rowCount(topIndex) > 0 && model->columnCount(topIndex) > 0) {
+         QModelIndex childIndex = model->index(0, 0, topIndex);
+         MODELTESTER_VERIFY(childIndex.isValid());
+         MODELTESTER_COMPARE(model->parent(childIndex), topIndex);
+diff --git a/qtbase/src/testlib/qasciikey.cpp b/qtbase/src/testlib/qasciikey.cpp
+index 9a308da2bc..93498b256f 100644
+--- a/qtbase/src/testlib/qasciikey.cpp
++++ b/qtbase/src/testlib/qasciikey.cpp
+@@ -498,6 +498,11 @@ char QTest::keyToAscii(Qt::Key key)
+     case Qt::Key_LaunchE : return 0; // = 0x10b0,
+     case Qt::Key_LaunchF : return 0; // = 0x10b1,
+ 
++    // Keypad navigation keys
++    case Qt::Key_Select : return 0; // = 0x01010000
++    case Qt::Key_Yes : return 0; // = 0x01010001
++    case Qt::Key_No : return 0; // = 0x01010002
++
+     default: QTEST_ASSERT(false); return 0;
+     }
+ }
+diff --git a/qtbase/src/testlib/qtestresult.cpp b/qtbase/src/testlib/qtestresult.cpp
+index 88028aac6e..2e89930776 100644
+--- a/qtbase/src/testlib/qtestresult.cpp
++++ b/qtbase/src/testlib/qtestresult.cpp
+@@ -251,7 +251,8 @@ bool QTestResult::verify(bool statement, const char *statementStr,
+ {
+     QTEST_ASSERT(statementStr);
+ 
+-    char msg[1024] = {'\0'};
++    char msg[1024];
++    msg[0] = '\0';
+ 
+     if (QTestLog::verboseLevel() >= 2) {
+         qsnprintf(msg, 1024, "QVERIFY(%s)", statementStr);
+@@ -309,7 +310,8 @@ static bool compareHelper(bool success, const char *failureMsg,
+                           bool hasValues = true)
+ {
+     const size_t maxMsgLen = 1024;
+-    char msg[maxMsgLen] = {'\0'};
++    char msg[maxMsgLen];
++    msg[0] = '\0';
+ 
+     QTEST_ASSERT(expected);
+     QTEST_ASSERT(actual);
+diff --git a/qtbase/src/widgets/dialogs/qcolordialog.cpp b/qtbase/src/widgets/dialogs/qcolordialog.cpp
+index 4247731275..cb325be85c 100644
+--- a/qtbase/src/widgets/dialogs/qcolordialog.cpp
++++ b/qtbase/src/widgets/dialogs/qcolordialog.cpp
+@@ -78,7 +78,10 @@
+ #include "qwindow.h"
+ 
+ #include "private/qdialog_p.h"
++#include "private/qguiapplication_p.h"
+ 
++#include <qpa/qplatformservices.h>
++#include <qpa/qplatformintegration.h>
+ #include <algorithm>
+ 
+ QT_BEGIN_NAMESPACE
+@@ -1611,6 +1614,20 @@ void QColorDialogPrivate::_q_newStandard(int r, int c)
+ void QColorDialogPrivate::_q_pickScreenColor()
+ {
+     Q_Q(QColorDialog);
++
++    auto *platformServices = QGuiApplicationPrivate::platformIntegration()->services();
++    if (platformServices->hasCapability(QPlatformServices::Capability::ColorPicking)) {
++        if (auto *colorPicker = platformServices->colorPicker(q->windowHandle())) {
++            q->connect(colorPicker, &QPlatformServiceColorPicker::colorPicked, q,
++                       [q, colorPicker](const QColor &color) {
++                           colorPicker->deleteLater();
++                           q->setCurrentColor(color);
++                       });
++            colorPicker->pickColor();
++            return;
++        }
++    }
++
+     if (!colorPickingEventFilter)
+         colorPickingEventFilter = new QColorPickingEventFilter(this, q);
+     q->installEventFilter(colorPickingEventFilter);
+diff --git a/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp b/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
+index e120817edc..8ea36b5427 100644
+--- a/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
++++ b/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
+@@ -400,12 +400,7 @@ bool QAbstractItemDelegate::helpEvent(QHelpEvent *event,
+         const QString tooltip = index.isValid() ?
+               d->textForRole(Qt::ToolTipRole, index.data(Qt::ToolTipRole), option.locale, precision) :
+               QString();
+-        QRect rect;
+-        if (index.isValid()) {
+-            const QRect r = view->visualRect(index);
+-            rect = QRect(view->mapToGlobal(r.topLeft()), r.size());
+-        }
+-        QToolTip::showText(he->globalPos(), tooltip, view, rect);
++        QToolTip::showText(he->globalPos(), tooltip, view->viewport(), option.rect);
+         event->setAccepted(!tooltip.isEmpty());
+         break;
+         }
+diff --git a/qtbase/src/widgets/itemviews/qlistview.cpp b/qtbase/src/widgets/itemviews/qlistview.cpp
+index 2b34476642..eebfaa030e 100644
+--- a/qtbase/src/widgets/itemviews/qlistview.cpp
++++ b/qtbase/src/widgets/itemviews/qlistview.cpp
+@@ -3386,6 +3386,7 @@ void QIconModeViewBase::updateContentsSize()
+ */
+ void QListView::currentChanged(const QModelIndex &current, const QModelIndex &previous)
+ {
++    QAbstractItemView::currentChanged(current, previous);
+ #ifndef QT_NO_ACCESSIBILITY
+     if (QAccessible::isActive()) {
+         if (current.isValid()) {
+@@ -3396,7 +3397,6 @@ void QListView::currentChanged(const QModelIndex &current, const QModelIndex &pr
+         }
+     }
+ #endif
+-    QAbstractItemView::currentChanged(current, previous);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/widgets/itemviews/qtableview.cpp b/qtbase/src/widgets/itemviews/qtableview.cpp
+index 934ac581b2..f79bb24249 100644
+--- a/qtbase/src/widgets/itemviews/qtableview.cpp
++++ b/qtbase/src/widgets/itemviews/qtableview.cpp
+@@ -1013,6 +1013,7 @@ void QTableViewPrivate::drawCell(QPainter *painter, const QStyleOptionViewItem &
+ int QTableViewPrivate::widthHintForIndex(const QModelIndex &index, int hint, const QStyleOptionViewItem &option) const
+ {
+     Q_Q(const QTableView);
++    const int oldHint = hint;
+     QWidget *editor = editorForIndex(index).widget.data();
+     if (editor && persistent.contains(editor)) {
+         hint = qMax(hint, editor->sizeHint().width());
+@@ -1021,6 +1022,17 @@ int QTableViewPrivate::widthHintForIndex(const QModelIndex &index, int hint, con
+         hint = qBound(min, hint, max);
+     }
+     hint = qMax(hint, q->itemDelegate(index)->sizeHint(option, index).width());
++
++    if (hasSpans()) {
++        auto span = spans.spanAt(index.column(), index.row());
++        if (span && span->m_left == index.column() && span->m_top == index.row()) {
++            // spans are screwed up when sections are moved
++            const auto left = logicalColumn(span->m_left);
++            for (int i = 1; i <= span->width(); ++i)
++               hint -= q->columnWidth(visualColumn(left + i));
++        }
++        hint = std::max(hint, oldHint);
++    }
+     return hint;
+ }
+ 
+@@ -1053,6 +1065,11 @@ int QTableViewPrivate::heightHintForIndex(const QModelIndex &index, int hint, QS
+         option.rect.setHeight(height);
+         option.rect.setX(q->columnViewportPosition(index.column()));
+         option.rect.setWidth(q->columnWidth(index.column()));
++        if (hasSpans()) {
++            auto span = spans.spanAt(index.column(), index.row());
++            if (span && span->m_left == index.column() && span->m_top == index.row())
++                option.rect.setWidth(std::max(option.rect.width(), visualSpanRect(*span).width()));
++        }
+         // 1px less space when grid is shown (see drawCell)
+         if (showGrid)
+             option.rect.setWidth(option.rect.width() - 1);
+diff --git a/qtbase/src/widgets/kernel/qaction.h b/qtbase/src/widgets/kernel/qaction.h
+index 258a1ea0a0..737c1e8285 100644
+--- a/qtbase/src/widgets/kernel/qaction.h
++++ b/qtbase/src/widgets/kernel/qaction.h
+@@ -81,7 +81,7 @@ class Q_WIDGETS_EXPORT QAction : public QObject
+     Q_PROPERTY(MenuRole menuRole READ menuRole WRITE setMenuRole NOTIFY changed)
+     Q_PROPERTY(bool iconVisibleInMenu READ isIconVisibleInMenu WRITE setIconVisibleInMenu NOTIFY changed)
+     Q_PROPERTY(bool shortcutVisibleInContextMenu READ isShortcutVisibleInContextMenu WRITE setShortcutVisibleInContextMenu NOTIFY changed)
+-    Q_PROPERTY(Priority priority READ priority WRITE setPriority)
++    Q_PROPERTY(Priority priority READ priority WRITE setPriority NOTIFY changed)
+ 
+ public:
+     // note this is copied into qplatformmenu.h, which must stay in sync
+diff --git a/qtbase/src/widgets/kernel/qwidget.cpp b/qtbase/src/widgets/kernel/qwidget.cpp
+index 9eba1e001e..26f6d27e18 100644
+--- a/qtbase/src/widgets/kernel/qwidget.cpp
++++ b/qtbase/src/widgets/kernel/qwidget.cpp
+@@ -5296,7 +5296,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
+         QWidgetEffectSourcePrivate *sourced = static_cast<QWidgetEffectSourcePrivate *>
+                                                          (source->d_func());
+         if (!sourced->context) {
+-            const QRegion effectRgn(rgn.boundingRect());
++            const QRegion effectRgn((flags & UseEffectRegionBounds) ? rgn.boundingRect() : rgn);
+             QWidgetPaintContext context(pdev, effectRgn, offset, flags, sharedPainter, repaintManager);
+             sourced->context = &context;
+             if (!sharedPainter) {
+@@ -5328,6 +5328,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
+         }
+     }
+ #endif // QT_CONFIG(graphicseffect)
++    flags = flags & ~UseEffectRegionBounds;
+ 
+     const bool alsoOnScreen = flags & DrawPaintOnScreen;
+     const bool recursive = flags & DrawRecursive;
+diff --git a/qtbase/src/widgets/kernel/qwidget_p.h b/qtbase/src/widgets/kernel/qwidget_p.h
+index eef6b8fa2c..c432f4b5d5 100644
+--- a/qtbase/src/widgets/kernel/qwidget_p.h
++++ b/qtbase/src/widgets/kernel/qwidget_p.h
+@@ -229,7 +229,8 @@ public:
+         DontSubtractOpaqueChildren = 0x10,
+         DontDrawOpaqueChildren = 0x20,
+         DontDrawNativeChildren = 0x40,
+-        DontSetCompositionMode = 0x80
++        DontSetCompositionMode = 0x80,
++        UseEffectRegionBounds = 0x100
+     };
+     Q_DECLARE_FLAGS(DrawWidgetFlags, DrawWidgetFlag)
+     Q_FLAG(DrawWidgetFlags)
+diff --git a/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp b/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
+index 02880b34da..0d44e1326d 100644
+--- a/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
++++ b/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
+@@ -1018,7 +1018,8 @@ void QWidgetRepaintManager::paintAndFlush()
+ 
+     // Paint the rest with composition.
+     if (repaintAllWidgets || !dirtyCopy.isEmpty()) {
+-        QWidgetPrivate::DrawWidgetFlags flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive;
++        QWidgetPrivate::DrawWidgetFlags flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive
++                | QWidgetPrivate::UseEffectRegionBounds;
+         tlw->d_func()->drawWidget(store->paintDevice(), dirtyCopy, QPoint(), flags, nullptr, this);
+     }
+ 
+diff --git a/qtbase/src/widgets/styles/qfusionstyle.cpp b/qtbase/src/widgets/styles/qfusionstyle.cpp
+index f4345d97c4..962912c838 100644
+--- a/qtbase/src/widgets/styles/qfusionstyle.cpp
++++ b/qtbase/src/widgets/styles/qfusionstyle.cpp
+@@ -1772,14 +1772,6 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio
+             proxy()->drawControl(CE_PushButtonLabel, &subopt, painter, widget);
+         }
+         break;
+-    case CE_PushButtonLabel:
+-        if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
+-            QStyleOptionButton b(*button);
+-            // no PM_ButtonShiftHorizontal and PM_ButtonShiftVertical for fusion style
+-            b.state &= ~(State_On | State_Sunken);
+-            QCommonStyle::drawControl(element, &b, painter, widget);
+-        }
+-        break;
+     case CE_MenuBarEmptyArea:
+         painter->save();
+     {
+diff --git a/qtbase/src/widgets/util/qcompleter.cpp b/qtbase/src/widgets/util/qcompleter.cpp
+index 18b24063d8..ef7207a8a3 100644
+--- a/qtbase/src/widgets/util/qcompleter.cpp
++++ b/qtbase/src/widgets/util/qcompleter.cpp
+@@ -1120,6 +1120,8 @@ void QCompleter::setModel(QAbstractItemModel *model)
+ {
+     Q_D(QCompleter);
+     QAbstractItemModel *oldModel = d->proxy->sourceModel();
++    if (oldModel == model)
++        return;
+ #if QT_CONFIG(filesystemmodel)
+     if (qobject_cast<const QFileSystemModel *>(oldModel))
+         setCompletionRole(Qt::EditRole); // QTBUG-54642, clear FileNameRole set by QFileSystemModel
+diff --git a/qtbase/src/widgets/widgets/qabstractbutton.cpp b/qtbase/src/widgets/widgets/qabstractbutton.cpp
+index a128b23950..dc40bf62fb 100644
+--- a/qtbase/src/widgets/widgets/qabstractbutton.cpp
++++ b/qtbase/src/widgets/widgets/qabstractbutton.cpp
+@@ -56,6 +56,7 @@
+ #ifndef QT_NO_ACCESSIBILITY
+ #include "qaccessible.h"
+ #endif
++#include <qpa/qplatformtheme.h>
+ 
+ #include <algorithm>
+ 
+@@ -1076,19 +1077,19 @@ void QAbstractButton::keyPressEvent(QKeyEvent *e)
+ {
+     Q_D(QAbstractButton);
+     bool next = true;
+-    switch (e->key()) {
+-    case Qt::Key_Enter:
+-    case Qt::Key_Return:
+-        e->ignore();
+-        break;
+-    case Qt::Key_Select:
+-    case Qt::Key_Space:
+-        if (!e->isAutoRepeat()) {
+-            setDown(true);
+-            repaint();
+-            d->emitPressed();
+-        }
+-        break;
++
++    const auto key = static_cast<Qt::Key>(e->key());
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(key) && !e->isAutoRepeat()) {
++        setDown(true);
++        repaint();
++        d->emitPressed();
++        return;
++    }
++
++    switch (key) {
+     case Qt::Key_Up:
+         next = false;
+         Q_FALLTHROUGH();
+@@ -1153,15 +1154,15 @@ void QAbstractButton::keyReleaseEvent(QKeyEvent *e)
+     if (!e->isAutoRepeat())
+         d->repeatTimer.stop();
+ 
+-    switch (e->key()) {
+-    case Qt::Key_Select:
+-    case Qt::Key_Space:
+-        if (!e->isAutoRepeat() && d->down)
+-            d->click();
+-        break;
+-    default:
+-        e->ignore();
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(static_cast<Qt::Key>(e->key())) && !e->isAutoRepeat() && d->down) {
++        d->click();
++        return;
+     }
++
++    e->ignore();
+ }
+ 
+ /*!\reimp
+diff --git a/qtbase/src/widgets/widgets/qcombobox.cpp b/qtbase/src/widgets/widgets/qcombobox.cpp
+index 7a496c27e0..0a3d96647b 100644
+--- a/qtbase/src/widgets/widgets/qcombobox.cpp
++++ b/qtbase/src/widgets/widgets/qcombobox.cpp
+@@ -3352,7 +3352,23 @@ void QComboBox::keyPressEvent(QKeyEvent *e)
+ 
+     Move move = NoMove;
+     int newIndex = currentIndex();
+-    switch (e->key()) {
++
++    bool pressLikeButton = !d->lineEdit;
++#ifdef QT_KEYPAD_NAVIGATION
++    pressLikeButton |= QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus();
++#endif
++    auto key = static_cast<Qt::Key>(e->key());
++    if (pressLikeButton) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(key)) {
++            showPopup();
++            return;
++        }
++    }
++
++    switch (key) {
+     case Qt::Key_Up:
+         if (e->modifiers() & Qt::ControlModifier)
+             break; // pass to line edit for auto completion
+@@ -3394,26 +3410,11 @@ void QComboBox::keyPressEvent(QKeyEvent *e)
+             return;
+         }
+         break;
+-    case Qt::Key_Space:
+-        if (!d->lineEdit) {
+-            showPopup();
+-            return;
+-        }
+-        break;
+-    case Qt::Key_Enter:
+-    case Qt::Key_Return:
+     case Qt::Key_Escape:
+         if (!d->lineEdit)
+             e->ignore();
+         break;
+ #ifdef QT_KEYPAD_NAVIGATION
+-    case Qt::Key_Select:
+-        if (QApplicationPrivate::keypadNavigationEnabled()
+-                && (!hasEditFocus() || !d->lineEdit)) {
+-            showPopup();
+-            return;
+-        }
+-        break;
+     case Qt::Key_Left:
+     case Qt::Key_Right:
+         if (QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus())
+diff --git a/qtbase/src/widgets/widgets/qdatetimeedit_p.h b/qtbase/src/widgets/widgets/qdatetimeedit_p.h
+index d36b6f8f9a..e0df5b5158 100644
+--- a/qtbase/src/widgets/widgets/qdatetimeedit_p.h
++++ b/qtbase/src/widgets/widgets/qdatetimeedit_p.h
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2018 The Qt Company Ltd.
++** Copyright (C) 2021 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtWidgets module of the Qt Toolkit.
+diff --git a/qtbase/src/widgets/widgets/qgroupbox.cpp b/qtbase/src/widgets/widgets/qgroupbox.cpp
+index 02a0bed325..3f3eccc370 100644
+--- a/qtbase/src/widgets/widgets/qgroupbox.cpp
++++ b/qtbase/src/widgets/widgets/qgroupbox.cpp
+@@ -54,6 +54,8 @@
+ #include "qaccessible.h"
+ #endif
+ #include <private/qwidget_p.h>
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
+ 
+ #include "qdebug.h"
+ 
+@@ -360,7 +362,10 @@ bool QGroupBox::event(QEvent *e)
+         return true;
+     case QEvent::KeyPress: {
+         QKeyEvent *k = static_cast<QKeyEvent*>(e);
+-        if (!k->isAutoRepeat() && (k->key() == Qt::Key_Select || k->key() == Qt::Key_Space)) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (!k->isAutoRepeat() && buttonPressKeys.contains(static_cast<Qt::Key>(k->key()))) {
+             d->pressedControl = QStyle::SC_GroupBoxCheckBox;
+             update(style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxCheckBox, this));
+             return true;
+@@ -369,7 +374,10 @@ bool QGroupBox::event(QEvent *e)
+     }
+     case QEvent::KeyRelease: {
+         QKeyEvent *k = static_cast<QKeyEvent*>(e);
+-        if (!k->isAutoRepeat() && (k->key() == Qt::Key_Select || k->key() == Qt::Key_Space)) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (!k->isAutoRepeat() && buttonPressKeys.contains(static_cast<Qt::Key>(k->key()))) {
+             bool toggle = (d->pressedControl == QStyle::SC_GroupBoxLabel
+                            || d->pressedControl == QStyle::SC_GroupBoxCheckBox);
+             d->pressedControl = QStyle::SC_None;
+diff --git a/qtbase/src/widgets/widgets/qlabel.cpp b/qtbase/src/widgets/widgets/qlabel.cpp
+index 30ff80cbb0..cf2605c17c 100644
+--- a/qtbase/src/widgets/widgets/qlabel.cpp
++++ b/qtbase/src/widgets/widgets/qlabel.cpp
+@@ -421,9 +421,6 @@ void QLabel::setPixmap(const QPixmap &pixmap)
+         d->pixmap = new QPixmap(pixmap);
+     }
+ 
+-    if (d->pixmap->depth() == 1 && !d->pixmap->mask())
+-        d->pixmap->setMask(*((QBitmap *)d->pixmap));
+-
+     d->updateLabel();
+ }
+ 
+diff --git a/qtbase/src/widgets/widgets/qtoolbararealayout.cpp b/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
+index 493c094cc1..d5f4b59017 100644
+--- a/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
++++ b/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
+@@ -1367,7 +1367,7 @@ bool QToolBarAreaLayout::restoreState(QDataStream &stream, const QList<QToolBar*
+                 item.widgetItem = new QWidgetItemV2(toolBar);
+                 toolBar->setOrientation(floating ? ((shown & 2) ? Qt::Vertical : Qt::Horizontal) : dock.o);
+                 toolBar->setVisible(shown & 1);
+-                toolBar->d_func()->setWindowState(floating, true, rect);
++                toolBar->d_func()->setWindowState(floating, false, rect);
+ 
+                 item.preferredSize = item.size;
+                 line.toolBarItems.append(item);
+diff --git a/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp b/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
+index 212c0a2e13..3c77b1ba0b 100644
+--- a/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
++++ b/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
+@@ -126,8 +126,7 @@ public:
+ 
+ void tst_QtConcurrentIterateKernel::instantiate()
+ {
+-    auto future = startThreadEngine(new PrintFor(0, 40)).startAsynchronously();
+-    future.waitForFinished();
++    startThreadEngine(new PrintFor(0, 40)).startBlocking();
+     QCOMPARE(iterations.loadRelaxed(), 40);
+ }
+ 
+@@ -166,10 +165,8 @@ void tst_QtConcurrentIterateKernel::stresstest()
+     const int times = 50;
+     for (int i = 0; i < times; ++i) {
+         counter.storeRelaxed(0);
+-        // ThreadEngine will delete f when it finishes
+-        auto f = new CountFor(0, iterations);
+-        auto future = f->startAsynchronously();
+-        future.waitForFinished();
++        CountFor f(0, iterations);
++        f.startBlocking();
+         QCOMPARE(counter.loadRelaxed(), iterations);
+     }
+ }
+@@ -177,11 +174,8 @@ void tst_QtConcurrentIterateKernel::stresstest()
+ void tst_QtConcurrentIterateKernel::noIterations()
+ {
+     const int times = 20000;
+-    for (int i = 0; i < times; ++i) {
+-        auto future = startThreadEngine(new IterateKernel<TestIterator, void>(0, 0))
+-                              .startAsynchronously();
+-        future.waitForFinished();
+-    }
++    for (int i = 0; i < times; ++i)
++        startThreadEngine(new IterateKernel<TestIterator, void>(0, 0)).startBlocking();
+ }
+ 
+ QMutex threadsMutex;
+@@ -236,10 +230,8 @@ void tst_QtConcurrentIterateKernel::throttling()
+ 
+     threads.clear();
+ 
+-    // ThreadEngine will delete f when it finishes
+-    auto f = new ThrottleFor(0, totalIterations);
+-    auto future = f->startAsynchronously();
+-    future.waitForFinished();
++    ThrottleFor f(0, totalIterations);
++    f.startBlocking();
+ 
+     QCOMPARE(iterations.loadRelaxed(), totalIterations);
+ 
+diff --git a/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp b/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
+index ac7be7acdd..81bc64c8d9 100644
+--- a/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
++++ b/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
+@@ -65,9 +65,16 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::runDirectly()
+ {
+-    PrintUser *engine = new PrintUser();
+-    QFuture<void> f = engine->startAsynchronously();
+-    f.waitForFinished();
++    {
++        PrintUser engine;
++        engine.startSingleThreaded();
++        engine.startBlocking();
++    }
++    {
++        PrintUser *engine = new PrintUser();
++        QFuture<void> f = engine->startAsynchronously();
++        f.waitForFinished();
++    }
+ }
+ 
+ class StringResultUser : public ThreadEngine<QString>
+@@ -99,10 +106,8 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::result()
+ {
+-    // ThreadEngine will delete 'engine' when it finishes
+-    auto engine = new StringResultUser();
+-    auto future = engine->startAsynchronously();
+-    QCOMPARE(future.result(), QString("Foo"));
++    StringResultUser engine;
++    QCOMPARE(*engine.startBlocking(), QString("Foo"));
+ }
+ 
+ class VoidResultUser : public ThreadEngine<void>
+@@ -128,9 +133,17 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::runThroughStarter()
+ {
+-    ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
+-    QFuture<QString> f = starter.startAsynchronously();
+-    QCOMPARE(f.result(), QString("Foo"));
++    {
++        ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
++        QFuture<QString>  f = starter.startAsynchronously();
++        QCOMPARE(f.result(), QString("Foo"));
++    }
++
++    {
++        ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
++        QString str = starter.startBlocking();
++        QCOMPARE(str, QString("Foo"));
++    }
+ }
+ 
+ class CancelUser : public ThreadEngine<void>
+@@ -213,6 +226,12 @@ void tst_QtConcurrentThreadEngine::throttle()
+         f.waitForFinished();
+         QCOMPARE(count.loadRelaxed(), 0);
+     }
++
++    for (int i = 0; i < repeats; ++i) {
++        ThrottleAlwaysUser t;
++        t.startBlocking();
++        QCOMPARE(count.loadRelaxed(), 0);
++    }
+ }
+ 
+ QSet<QThread *> threads;
+@@ -249,17 +268,35 @@ void tst_QtConcurrentThreadEngine::threadCount()
+ {
+     const int repeats = 10;
+     for (int i = 0; i < repeats; ++i) {
++        ThreadCountUser t;
++        t.startBlocking();
++        int count = threads.count();
++        int count_expected = QThreadPool::globalInstance()->maxThreadCount() + 1; // +1 for the main thread.
++        if (count != count_expected)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, count_expected);
++
+         (new ThreadCountUser())->startAsynchronously().waitForFinished();
+-        const auto count = threads.count();
+-        const auto maxThreadCount = QThreadPool::globalInstance()->maxThreadCount();
+-        QVERIFY(count <= maxThreadCount);
+-        QVERIFY(!threads.contains(QThread::currentThread()));
++        count = threads.count();
++        count_expected = QThreadPool::globalInstance()->maxThreadCount();
++        if (count != count_expected)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, count_expected);
+     }
+ 
+     // Set the finish flag immediately, this should give us one thread only.
+     for (int i = 0; i < repeats; ++i) {
++        ThreadCountUser t(true /*finishImmediately*/);
++        t.startBlocking();
++        int count = threads.count();
++        if (count != 1)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, 1);
++
+         (new ThreadCountUser(true /*finishImmediately*/))->startAsynchronously().waitForFinished();
+-        const auto count = threads.count();
++        count = threads.count();
++        if (count != 1)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
+         QCOMPARE(count, 1);
+         QVERIFY(!threads.contains(QThread::currentThread()));
+     }
+@@ -400,6 +437,7 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::exceptions()
+ {
++    // Asynchronous mode:
+     {
+         bool caught = false;
+         try  {
+@@ -412,6 +450,32 @@ void tst_QtConcurrentThreadEngine::exceptions()
+         QVERIFY2(caught, "did not get exception");
+     }
+ 
++    // Blocking mode:
++    // test throwing the exception from a worker thread.
++    {
++        bool caught = false;
++        try  {
++            QtConcurrentExceptionThrower e(QThread::currentThread());
++            e.startBlocking();
++        } catch (const QException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // test throwing the exception from the main thread (different code path)
++    {
++        bool caught = false;
++        try  {
++            QtConcurrentExceptionThrower e(0);
++            e.startBlocking();
++        } catch (const QException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // Asynchronous mode:
+     {
+         bool caught = false;
+         try  {
+@@ -423,6 +487,31 @@ void tst_QtConcurrentThreadEngine::exceptions()
+         }
+         QVERIFY2(caught, "did not get exception");
+     }
++
++    // Blocking mode:
++    // test throwing the exception from a worker thread.
++    {
++        bool caught = false;
++        try  {
++            UnrelatedExceptionThrower e(QThread::currentThread());
++            e.startBlocking();
++        } catch (const QUnhandledException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // test throwing the exception from the main thread (different code path)
++    {
++        bool caught = false;
++        try  {
++            UnrelatedExceptionThrower e(0);
++            e.startBlocking();
++        } catch (const QUnhandledException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
+ }
+ 
+ #endif
+diff --git a/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp b/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
+index 4968742110..f4c3fb711d 100644
+--- a/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
++++ b/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
+@@ -42,6 +42,7 @@ private slots:
+     void writeBlock_data();
+     void writeBlock();
+     void seek();
++    void invalidSeeks();
+     void seekTest_data();
+     void seekTest();
+     void read_rawdata();
+@@ -286,6 +287,29 @@ void tst_QBuffer::seek()
+     QCOMPARE(buffer.size(), pos);
+ }
+ 
++void tst_QBuffer::invalidSeeks()
++{
++    if constexpr (sizeof(qsizetype) == sizeof(qint64)) {
++        // sizeof(qsizetype) == sizeof(qint64), so +1 would overflow
++        QSKIP("This is a 32-bit-only test.");
++    } else {
++        QBuffer buffer;
++        buffer.open(QIODevice::WriteOnly);
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++        constexpr qint64 MaxQByteArrayCapacity = (std::numeric_limits<qsizetype>::max)();
++        // this should fail fast, not after trying to allocate nearly 2 GiB of data,
++        // potentially crashing in the process:
++        QVERIFY(!buffer.seek(2 * MaxQByteArrayCapacity - 1));
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++        // ditto:
++        QVERIFY(!buffer.seek(MaxQByteArrayCapacity + 1));
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++    }
++}
++
+ void tst_QBuffer::seekTest_data()
+ {
+     writeBlock_data();
+diff --git a/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp b/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
+index da5327594c..4a04e0f7c6 100644
+--- a/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
++++ b/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
+@@ -561,7 +561,8 @@ protected:
+     qint64 readData(char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf->size() - offset));
+-        memcpy(data, buf->constData() + offset, maxSize);
++        if (maxSize > 0)
++            memcpy(data, buf->constData() + offset, maxSize);
+         offset += maxSize;
+         return maxSize;
+     }
+@@ -604,13 +605,15 @@ protected:
+     qint64 readData(char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf.size() - pos()));
+-        memcpy(data, buf.constData() + pos(), maxSize);
++        if (maxSize > 0)
++            memcpy(data, buf.constData() + pos(), maxSize);
+         return maxSize;
+     }
+     qint64 writeData(const char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf.size() - pos()));
+-        memcpy(buf.data() + pos(), data, maxSize);
++        if (maxSize > 0)
++            memcpy(buf.data() + pos(), data, maxSize);
+         return maxSize;
+     }
+ 
+diff --git a/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+index db60bead64..f345a44414 100644
+--- a/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
++++ b/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+@@ -1,7 +1,8 @@
+ /****************************************************************************
+ **
+ ** Copyright (C) 2021 The Qt Company Ltd.
+-** Copyright (C) 2020 Intel Corporation.
++** Copyright (C) 2020 The Qt Company Ltd.
++** Copyright (C) 2022 Intel Corporation.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the test suite of the Qt Toolkit.
+@@ -150,6 +151,8 @@ private slots:
+     void startStopStartStopBuffers();
+     void processEventsInAReadyReadSlot_data();
+     void processEventsInAReadyReadSlot();
++    void startFromCurrentWorkingDir_data();
++    void startFromCurrentWorkingDir();
+ 
+     // keep these at the end, since they use lots of processes and sometimes
+     // caused obscure failures to occur in tests that followed them (esp. on the Mac)
+@@ -2731,5 +2734,94 @@ void tst_QProcess::finishProcessBeforeReadingDone_deprecated()
+ 
+ #endif
+ 
++enum class ChdirMode {
++    None = 0,
++    InParent,
++    InChild
++};
++Q_DECLARE_METATYPE(ChdirMode)
++
++void tst_QProcess::startFromCurrentWorkingDir_data()
++{
++    qRegisterMetaType<ChdirMode>();
++    QTest::addColumn<QString>("programPrefix");
++    QTest::addColumn<ChdirMode>("chdirMode");
++    QTest::addColumn<bool>("success");
++
++    constexpr bool IsWindows = true
++#ifdef Q_OS_UNIX
++            && false
++#endif
++            ;
++
++    // baseline: trying to execute the directory, this can't possibly succeed!
++    QTest::newRow("plain-same-cwd") << QString() << ChdirMode::None << false;
++
++    // cross-platform behavior: neither OS searches the setWorkingDirectory()
++    // dir without "./"
++    QTest::newRow("plain-child-chdir") << QString() << ChdirMode::InChild << false;
++
++    // cross-platform behavior: both OSes search the parent's CWD with "./"
++    QTest::newRow("prefixed-parent-chdir") << "./" << ChdirMode::InParent << true;
++
++    // opposite behaviors: Windows searches the parent's CWD and Unix searches
++    // the child's with "./"
++    QTest::newRow("prefixed-child-chdir") << "./" << ChdirMode::InChild << !IsWindows;
++
++    // Windows searches the parent's CWD without "./"
++    QTest::newRow("plain-parent-chdir") << QString() << ChdirMode::InParent << IsWindows;
++}
++
++void tst_QProcess::startFromCurrentWorkingDir()
++{
++    QFETCH(QString, programPrefix);
++    QFETCH(ChdirMode, chdirMode);
++    QFETCH(bool, success);
++
++    QProcess process;
++    qRegisterMetaType<QProcess::ProcessError>();
++    QSignalSpy errorSpy(&process, &QProcess::errorOccurred);
++    QVERIFY(errorSpy.isValid());
++
++    // both the dir name and the executable name
++    const QString target = QStringLiteral("testProcessNormal");
++    process.setProgram(programPrefix + target);
++
++#ifdef Q_OS_UNIX
++    // Reset PATH, to be sure it doesn't contain . or the empty path.
++    // We can't do this on Windows because DLLs are searched in PATH
++    // and Windows always searches "." anyway.
++    auto restoreEnv = qScopeGuard([old = qgetenv("PATH")] {
++        qputenv("PATH", old);
++    });
++    qputenv("PATH", "/");
++#endif
++
++    switch (chdirMode) {
++    case ChdirMode::InParent: {
++        auto restoreCwd = qScopeGuard([old = QDir::currentPath()] {
++            QDir::setCurrent(old);
++        });
++        QVERIFY(QDir::setCurrent(target));
++        process.start();
++        break;
++    }
++    case ChdirMode::InChild:
++        process.setWorkingDirectory(target);
++        Q_FALLTHROUGH();
++    case ChdirMode::None:
++        process.start();
++        break;
++    }
++
++    QCOMPARE(process.waitForStarted(), success);
++    QCOMPARE(errorSpy.count(), int(!success));
++    if (success) {
++        QVERIFY(process.waitForFinished());
++    } else {
++        QCOMPARE(process.error(), QProcess::FailedToStart);
++    }
++}
++
+ QTEST_MAIN(tst_QProcess)
+ #include "tst_qprocess.moc"
+diff --git a/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp b/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp
+index e1ea7a4552..90972caa57 100644
+--- a/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp
++++ b/qtbase/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"
+diff --git a/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+index 9bd66c0835..ed4a0bae5d 100644
+--- a/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
++++ b/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+@@ -158,6 +158,7 @@ private slots:
+     void nullReceiver();
+     void functorReferencesConnection();
+     void disconnectDisconnects();
++    void declarativeData();
+ };
+ 
+ struct QObjectCreatedOnShutdown
+@@ -7679,5 +7680,81 @@ void tst_QObject::disconnectDisconnects()
+ Q_STATIC_ASSERT(QtPrivate::HasQ_OBJECT_Macro<tst_QObject>::Value);
+ Q_STATIC_ASSERT(!QtPrivate::HasQ_OBJECT_Macro<SiblingDeleter>::Value);
+ 
++#ifdef QT_BUILD_INTERNAL
++/*
++    Since QObjectPrivate stores the declarativeData pointer in a union with the pointer
++    to the currently destroyed child, calls to the QtDeclarative handlers need to be
++    correctly guarded. QTBUG-105286
++*/
++namespace QtDeclarative {
++static QAbstractDeclarativeData *theData;
++
++static void destroyed(QAbstractDeclarativeData *data, QObject *)
++{
++    QCOMPARE(data, theData);
++}
++static void signalEmitted(QAbstractDeclarativeData *data, QObject *, int, void **)
++{
++    QCOMPARE(data, theData);
++}
++// we can't use QCOMPARE in the next two functions, as they don't return void
++static int receivers(QAbstractDeclarativeData *data, const QObject *, int)
++{
++    QTest::qCompare(data, theData, "data", "theData", __FILE__, __LINE__);
++    return 0;
++}
++static bool isSignalConnected(QAbstractDeclarativeData *data, const QObject *, int)
++{
++    QTest::qCompare(data, theData, "data", "theData", __FILE__, __LINE__);
++    return true;
++}
++
++class Object : public QObject
++{
++    Q_OBJECT
++public:
++    using QObject::QObject;
++    ~Object()
++    {
++        if (Object *p = static_cast<Object *>(parent()))
++            p->emitSignal();
++    }
++
++    void emitSignal()
++    {
++        emit theSignal();
++    }
++
++signals:
++    void theSignal();
++};
++
++}
++#endif
++
++void tst_QObject::declarativeData()
++{
++#ifdef QT_BUILD_INTERNAL
++    QScopedValueRollback destroyed(QAbstractDeclarativeData::destroyed,
++                                   QtDeclarative::destroyed);
++    QScopedValueRollback signalEmitted(QAbstractDeclarativeData::signalEmitted,
++                                       QtDeclarative::signalEmitted);
++    QScopedValueRollback receivers(QAbstractDeclarativeData::receivers,
++                                   QtDeclarative::receivers);
++    QScopedValueRollback isSignalConnected(QAbstractDeclarativeData::isSignalConnected,
++                                           QtDeclarative::isSignalConnected);
++
++    QtDeclarative::Object p;
++    QObjectPrivate *priv = QObjectPrivate::get(&p);
++    priv->declarativeData = QtDeclarative::theData = new QAbstractDeclarativeData;
++
++    connect(&p, &QtDeclarative::Object::theSignal, &p, []{
++    });
++
++    QtDeclarative::Object *child = new QtDeclarative::Object;
++    child->setParent(&p);
++#endif
++}
++
+ QTEST_MAIN(tst_QObject)
+ #include "tst_qobject.moc"
+diff --git a/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp b/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
+index 0ea422ecbc..1a3256534b 100644
+--- a/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
++++ b/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
+@@ -70,15 +70,15 @@ static inline QString testSuiteWarning()
+ 
+     QString result;
+     QTextStream str(&result);
+-    str << "\nCannot find the shared-mime-info test suite\nstarting from: "
++    str << "\nCannot find the shared-mime-info test suite\nin the parent of: "
+         << QDir::toNativeSeparators(QDir::currentPath()) << "\n"
+            "cd " << QDir::toNativeSeparators(QStringLiteral("tests/auto/corelib/mimetypes/qmimedatabase")) << "\n"
+-           "wget http://cgit.freedesktop.org/xdg/shared-mime-info/snapshot/Release-1-10.zip\n"
+-           "unzip Release-1-10.zip\n";
++           "wget https://gitlab.freedesktop.org/xdg/shared-mime-info/-/archive/2.1/shared-mime-info-2.1.zip\n"
++           "unzip shared-mime-info-2.1.zip\n";
+ #ifdef Q_OS_WIN
+-    str << "mkdir testfiles\nxcopy /s Release-1-10 s-m-i\n";
++    str << "mkdir testfiles\nxcopy /s shared-mime-info-2.1 s-m-i\n";
+ #else
+-    str << "ln -s Release-1-10 s-m-i\n";
++    str << "ln -s shared-mime-info-2.1 s-m-i\n";
+ #endif
+     return result;
+ }
+@@ -154,7 +154,7 @@ void tst_QMimeDatabase::initTestCase()
+     QVERIFY2(copyResourceFile(xmlFileName, xmlTargetFileName, &errorMessage), qPrintable(errorMessage));
+ #endif
+ 
+-    m_testSuite = QFINDTESTDATA("s-m-i/tests");
++    m_testSuite = QFINDTESTDATA("s-m-i/tests/mime-detection");
+     if (m_testSuite.isEmpty())
+         qWarning("%s", qPrintable(testSuiteWarning()));
+ 
+@@ -611,7 +611,7 @@ void tst_QMimeDatabase::allMimeTypes()
+     QVERIFY(!lst.isEmpty());
+ 
+     // Hardcoding this is the only way to check both providers find the same number of mimetypes.
+-    QCOMPARE(lst.count(), 779);
++    QCOMPARE(lst.count(), 811);
+ 
+     foreach (const QMimeType &mime, lst) {
+         const QString name = mime.name();
+@@ -631,10 +631,9 @@ void tst_QMimeDatabase::suffixes_data()
+ 
+     QTest::newRow("mimetype with a single pattern") << "application/pdf" << "*.pdf" << "pdf";
+     QTest::newRow("mimetype with multiple patterns") << "application/x-kpresenter" << "*.kpr;*.kpt" << "kpr";
+-    QTest::newRow("jpeg") << "image/jpeg" << "*.jpe;*.jpg;*.jpeg" << "jpeg";
+-    //if (KMimeType::sharedMimeInfoVersion() > KDE_MAKE_VERSION(0, 60, 0)) {
+-        QTest::newRow("mimetype with many patterns") << "application/vnd.wordperfect" << "*.wp;*.wp4;*.wp5;*.wp6;*.wpd;*.wpp" << "wp";
+-    //}
++    // The preferred suffix for image/jpeg is *.jpg, as per https://bugs.kde.org/show_bug.cgi?id=176737
++    QTest::newRow("jpeg") << "image/jpeg" << "*.jpe;*.jpg;*.jpeg" << "jpg";
++    QTest::newRow("mimetype with many patterns") << "application/vnd.wordperfect" << "*.wp;*.wp4;*.wp5;*.wp6;*.wpd;*.wpp" << "wp";
+     QTest::newRow("oasis text mimetype") << "application/vnd.oasis.opendocument.text" << "*.odt" << "odt";
+     QTest::newRow("oasis presentation mimetype") << "application/vnd.oasis.opendocument.presentation" << "*.odp" << "odp";
+     QTest::newRow("mimetype with multiple patterns") << "text/plain" << "*.asc;*.txt;*,v" << "txt";
+diff --git a/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp b/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
+index 3e58dd03cc..c8f82ef5d5 100644
+--- a/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
++++ b/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
+@@ -176,6 +176,8 @@ private Q_SLOTS:
+     void fromToVariantConversions_data();
+     void fromToVariantConversions();
+ 
++    void noLeakOnNameClash();
++
+ private:
+     QString testDataDir;
+ };
+@@ -3685,5 +3687,23 @@ void tst_QtJson::fromToVariantConversions()
+     }
+ }
+ 
++void tst_QtJson::noLeakOnNameClash()
++{
++    QJsonDocument doc = QJsonDocument::fromJson("{\"\":{\"\":0},\"\":0}");
++    QVERIFY(!doc.isNull());
++    const QJsonObject obj = doc.object();
++
++    // Removed the duplicate key.
++    QCOMPARE(obj.length(), 1);
++
++    // Retained the last of the duplicates.
++    const QJsonValue val = obj.begin().value();
++    QVERIFY(val.isDouble());
++    QCOMPARE(val.toDouble(), 0.0);
++
++    // It should not leak.
++    // In particular it should not forget to deref the container for the inner object.
++}
++
+ QTEST_MAIN(tst_QtJson)
+ #include "tst_qtjson.moc"
+diff --git a/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp b/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
+index a59b58d57f..241c3e84ac 100644
+--- a/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
++++ b/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
+@@ -63,6 +63,7 @@ private slots:
+     void isValidId_data();
+     void isValidId();
+     void malformed();
++    void serialize();
+     // Backend tests
+     void utcTest();
+     void icuTest();
+@@ -947,6 +948,33 @@ void tst_QTimeZone::malformed()
+         barf.offsetFromUtc(now);
+ }
+ 
++void tst_QTimeZone::serialize()
++{
++    int parts = 0;
++#ifndef QT_NO_DEBUG_STREAM
++    qDebug() << QTimeZone(); // to verify no crash
++    parts++;
++#endif
++#ifndef QT_NO_DATASTREAM
++    QByteArray blob;
++    {
++        QDataStream stream(&blob, QIODevice::WriteOnly);
++        stream << QTimeZone("Europe/Oslo") << QTimeZone(420) << QTimeZone() << qint64(-1);
++    }
++    QDataStream stream(&blob, QIODevice::ReadOnly);
++    QTimeZone invalid, offset, oslo;
++    qint64 minusone;
++    stream >> oslo >> offset >> invalid >> minusone;
++    QCOMPARE(oslo, QTimeZone("Europe/Oslo"));
++    QCOMPARE(offset, QTimeZone(420));
++    QVERIFY(!invalid.isValid());
++    QCOMPARE(minusone, qint64(-1));
++    parts++;
++#endif
++    if (!parts)
++        QSKIP("No serialization enabled");
++}
++
+ void tst_QTimeZone::utcTest()
+ {
+ #ifdef QT_BUILD_INTERNAL
+diff --git a/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp b/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
+index 05480c6dd2..70f4c75756 100644
+--- a/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
++++ b/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
+@@ -324,6 +324,13 @@ void tst_QDBusInterface::notValid()
+ 
+     QVERIFY(!interface.isValid());
+     QVERIFY(!QMetaObject::invokeMethod(&interface, "ListNames", Qt::DirectConnection));
++
++    // With a connection, but empty/null service and path specified
++    QDBusConnection con = QDBusConnection::sessionBus();
++    QVERIFY(con.isConnected());
++    QDBusInterface iface({}, {}, {}, con);
++    QVERIFY(!iface.isValid());
++    QVERIFY(!QMetaObject::invokeMethod(&interface, "ListNames", Qt::DirectConnection));
+ }
+ 
+ void tst_QDBusInterface::notValidDerived()
+diff --git a/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp b/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
+index 874468c954..04ceb4ab65 100644
+--- a/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
++++ b/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
+@@ -507,6 +507,10 @@ void tst_QKeySequence::toStringFromKeycode_data()
+     QTest::newRow("Ctrl+Alt+Num+Del") << QKeySequence(Qt::ControlModifier | Qt::AltModifier | Qt::KeypadModifier | Qt::Key_Delete) << "Ctrl+Alt+Num+Del";
+     QTest::newRow("Ctrl+Ins") << QKeySequence(Qt::ControlModifier | Qt::Key_Insert) << "Ctrl+Ins";
+     QTest::newRow("Ctrl+Num+Ins(1)") << QKeySequence(Qt::Key_Insert | Qt::KeypadModifier | Qt::ControlModifier) << "Ctrl+Num+Ins";
++    QTest::newRow("Ctrl") << QKeySequence(Qt::Key_Control) << "Control";
++    QTest::newRow("Alt") << QKeySequence(Qt::Key_Alt) << "Alt";
++    QTest::newRow("Shift") << QKeySequence(Qt::Key_Shift) << "Shift";
++    QTest::newRow("Meta") << QKeySequence(Qt::Key_Meta) << "Meta";
+ }
+ 
+ void tst_QKeySequence::toStringFromKeycode()
+diff --git a/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp b/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+index 15e0ecadaa..b4eca74283 100644
+--- a/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
++++ b/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+@@ -81,6 +81,8 @@ private slots:
+     void registerOpenTypePreferredNamesSystem();
+     void registerOpenTypePreferredNamesApplication();
+ 
++    void stretchRespected();
++
+ private:
+     QString m_ledFont;
+     QString m_testFont;
+@@ -355,6 +357,28 @@ static QString testString()
+     return QStringLiteral("foo bar");
+ }
+ 
++void tst_QFontDatabase::stretchRespected()
++{
++    int italicId = QFontDatabase::addApplicationFont(m_testFontItalic);
++    QVERIFY(italicId != -1);
++
++    QVERIFY(!QFontDatabase::applicationFontFamilies(italicId).isEmpty());
++
++    QString italicFontName = QFontDatabase::applicationFontFamilies(italicId).first();
++
++    QFont italicFont = QFontDatabase().font(italicFontName,
++                                            QString::fromLatin1("Italic"), 14);
++    QVERIFY(italicFont.italic());
++
++    QFont italicStretchedFont = italicFont;
++    italicStretchedFont.setStretch( 400 );
++
++    QVERIFY(QFontMetricsF(italicFont).horizontalAdvance(QStringLiteral("foobar")) <
++            QFontMetricsF(italicStretchedFont).horizontalAdvance(QStringLiteral("foobar")));
++
++    QFontDatabase::removeApplicationFont(italicId);
++}
++
+ void tst_QFontDatabase::condensedFontWidthNoFontMerging()
+ {
+     int regularFontId = QFontDatabase::addApplicationFont(m_testFont);
+diff --git a/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+index 3d4a094c43..b423e11a99 100644
+--- a/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
++++ b/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+@@ -281,6 +281,7 @@ private Q_SLOTS:
+     void ioGetFromFileSpecial();
+     void ioGetFromFile_data();
+     void ioGetFromFile();
++    void ioGetFromFileUrl();
+     void ioGetFromFtp_data();
+     void ioGetFromFtp();
+     void ioGetFromFtpWithReuse();
+@@ -3300,6 +3301,18 @@ void tst_QNetworkReply::ioGetFromFile()
+     QCOMPARE(reader.data, data);
+ }
+ 
++void tst_QNetworkReply::ioGetFromFileUrl()
++{
++    // This immediately fails on non-windows platforms:
++    QNetworkRequest request(QUrl("file://unc-server/some/path"));
++    QNetworkReplyPtr reply(manager.get(request));
++    QSignalSpy finishedSpy(reply.get(), &QNetworkReply::finished);
++    // QTBUG-105618: This would, on non-Windows platforms, never happen because the signal
++    // was emitted before the constructor finished, leaving no chance at all to connect to the
++    // signal
++    QVERIFY(finishedSpy.wait());
++}
++
+ void tst_QNetworkReply::ioGetFromFtp_data()
+ {
+     QTest::addColumn<QString>("fileName");
+diff --git a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
+index 069fa6b341..4cc4d9a5ea 100644
+--- a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
++++ b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
+@@ -1,75 +1,34 @@
+-Certificate:
+-    Data:
+-        Version: 3 (0x2)
+-        Serial Number: 0 (0x0)
+-        Signature Algorithm: sha1WithRSAEncryption
+-        Issuer: C=NO, ST=Oslo, L=Nydalen, O=Nokia Corporation and/or its subsidiary(-ies), OU=Development, CN=fluke.troll.no/emailAddress=ahanssen@trolltech.com
+-        Validity
+-            Not Before: Dec  4 01:10:32 2007 GMT
+-            Not After : Apr 21 01:10:32 2035 GMT
+-        Subject: C=NO, ST=Oslo, O=Nokia Corporation and/or its subsidiary(-ies), OU=Development, CN=fluke.troll.no
+-        Subject Public Key Info:
+-            Public Key Algorithm: rsaEncryption
+-            RSA Public Key: (1024 bit)
+-                Modulus (1024 bit):
+-                    00:a7:c8:a0:4a:c4:19:05:1b:66:ba:32:e2:d2:f1:
+-                    1c:6f:17:82:e4:39:2e:01:51:90:db:04:34:32:11:
+-                    21:c2:0d:6f:59:d8:53:90:54:3f:83:8f:a9:d3:b3:
+-                    d5:ee:1a:9b:80:ae:c3:25:c9:5e:a5:af:4b:60:05:
+-                    aa:a0:d1:91:01:1f:ca:04:83:e3:58:1c:99:32:45:
+-                    84:70:72:58:03:98:4a:63:8b:41:f5:08:49:d2:91:
+-                    02:60:6b:e4:64:fe:dd:a0:aa:74:08:e9:34:4c:91:
+-                    5f:12:3d:37:4d:54:2c:ad:7f:5b:98:60:36:02:8c:
+-                    3b:f6:45:f3:27:6a:9b:94:9d
+-                Exponent: 65537 (0x10001)
+-        X509v3 extensions:
+-            X509v3 Basic Constraints: 
+-                CA:FALSE
+-            Netscape Comment: 
+-                OpenSSL Generated Certificate
+-            X509v3 Subject Key Identifier: 
+-                21:85:04:3D:23:01:66:E5:F7:9F:1A:84:24:8A:AF:0A:79:F4:E5:AC
+-            X509v3 Authority Key Identifier: 
+-                DirName:/C=NO/ST=Oslo/L=Nydalen/O=Nokia Corporation and/or its subsidiary(-ies)/OU=Development/CN=fluke.troll.no/emailAddress=ahanssen@trolltech.com
+-                serial:8E:A8:B4:E8:91:B7:54:2E
+-
+-    Signature Algorithm: sha1WithRSAEncryption
+-        6d:57:5f:d1:05:43:f0:62:05:ec:2a:71:a5:dc:19:08:f2:c4:
+-        a6:bd:bb:25:d9:ca:89:01:0e:e4:cf:1f:c1:8c:c8:24:18:35:
+-        53:59:7b:c0:43:b4:32:e6:98:b2:a6:ef:15:05:0b:48:5f:e1:
+-        a0:0c:97:a9:a1:77:d8:35:18:30:bc:a9:8f:d3:b7:54:c7:f1:
+-        a9:9e:5d:e6:19:bf:f6:3c:5b:2b:d8:e4:3e:62:18:88:8b:d3:
+-        24:e1:40:9b:0c:e6:29:16:62:ab:ea:05:24:70:36:aa:55:93:
+-        ef:02:81:1b:23:10:a2:04:eb:56:95:75:fc:f8:94:b1:5d:42:
+-        c5:3f:36:44:85:5d:3a:2e:90:46:8a:a2:b9:6f:87:ae:0c:15:
+-        40:19:31:90:fc:3b:25:bb:ae:f1:66:13:0d:85:90:d9:49:34:
+-        8f:f2:5d:f9:7a:db:4d:5d:27:f6:76:9d:35:8c:06:a6:4c:a3:
+-        b1:b2:b6:6f:1d:d7:a3:00:fd:72:eb:9e:ea:44:a1:af:21:34:
+-        7d:c7:42:e2:49:91:19:8b:c0:ad:ba:82:80:a8:71:70:f4:35:
+-        31:91:63:84:20:95:e9:60:af:64:8b:cc:ff:3d:8a:76:74:3d:
+-        c8:55:6d:e4:8e:c3:2b:1c:e8:42:18:ae:9f:e6:6b:9c:34:06:
+-        ec:6a:f2:c3
+ -----BEGIN CERTIFICATE-----
+-MIIEEzCCAvugAwIBAgIBADANBgkqhkiG9w0BAQUFADCBnDELMAkGA1UEBhMCTk8x
+-DTALBgNVBAgTBE9zbG8xEDAOBgNVBAcTB055ZGFsZW4xFjAUBgNVBAoTDVRyb2xs
+-dGVjaCBBU0ExFDASBgNVBAsTC0RldmVsb3BtZW50MRcwFQYDVQQDEw5mbHVrZS50
+-cm9sbC5ubzElMCMGCSqGSIb3DQEJARYWYWhhbnNzZW5AdHJvbGx0ZWNoLmNvbTAe
+-Fw0wNzEyMDQwMTEwMzJaFw0zNTA0MjEwMTEwMzJaMGMxCzAJBgNVBAYTAk5PMQ0w
+-CwYDVQQIEwRPc2xvMRYwFAYDVQQKEw1Ucm9sbHRlY2ggQVNBMRQwEgYDVQQLEwtE
+-ZXZlbG9wbWVudDEXMBUGA1UEAxMOZmx1a2UudHJvbGwubm8wgZ8wDQYJKoZIhvcN
+-AQEBBQADgY0AMIGJAoGBAKfIoErEGQUbZroy4tLxHG8XguQ5LgFRkNsENDIRIcIN
+-b1nYU5BUP4OPqdOz1e4am4CuwyXJXqWvS2AFqqDRkQEfygSD41gcmTJFhHByWAOY
+-SmOLQfUISdKRAmBr5GT+3aCqdAjpNEyRXxI9N01ULK1/W5hgNgKMO/ZF8ydqm5Sd
+-AgMBAAGjggEaMIIBFjAJBgNVHRMEAjAAMCwGCWCGSAGG+EIBDQQfFh1PcGVuU1NM
+-IEdlbmVyYXRlZCBDZXJ0aWZpY2F0ZTAdBgNVHQ4EFgQUIYUEPSMBZuX3nxqEJIqv
+-Cnn05awwgbsGA1UdIwSBszCBsKGBoqSBnzCBnDELMAkGA1UEBhMCTk8xDTALBgNV
+-BAgTBE9zbG8xEDAOBgNVBAcTB055ZGFsZW4xFjAUBgNVBAoTDVRyb2xsdGVjaCBB
+-U0ExFDASBgNVBAsTC0RldmVsb3BtZW50MRcwFQYDVQQDEw5mbHVrZS50cm9sbC5u
+-bzElMCMGCSqGSIb3DQEJARYWYWhhbnNzZW5AdHJvbGx0ZWNoLmNvbYIJAI6otOiR
+-t1QuMA0GCSqGSIb3DQEBBQUAA4IBAQBtV1/RBUPwYgXsKnGl3BkI8sSmvbsl2cqJ
+-AQ7kzx/BjMgkGDVTWXvAQ7Qy5piypu8VBQtIX+GgDJepoXfYNRgwvKmP07dUx/Gp
+-nl3mGb/2PFsr2OQ+YhiIi9Mk4UCbDOYpFmKr6gUkcDaqVZPvAoEbIxCiBOtWlXX8
+-+JSxXULFPzZEhV06LpBGiqK5b4euDBVAGTGQ/Dslu67xZhMNhZDZSTSP8l35ettN
+-XSf2dp01jAamTKOxsrZvHdejAP1y657qRKGvITR9x0LiSZEZi8CtuoKAqHFw9DUx
+-kWOEIJXpYK9ki8z/PYp2dD3IVW3kjsMrHOhCGK6f5mucNAbsavLD
++MIIF6zCCA9OgAwIBAgIUfo9amJtJGWqWE6f+SkAO85zkGr4wDQYJKoZIhvcNAQEL
++BQAwgYMxCzAJBgNVBAYTAk5PMQ0wCwYDVQQIDARPc2xvMQ0wCwYDVQQHDARPc2xv
++MRcwFQYDVQQKDA5UaGUgUXQgQ29tcGFueTEMMAoGA1UECwwDUiZEMRIwEAYDVQQD
++DAlIMiBUZXN0ZXIxGzAZBgkqhkiG9w0BCQEWDG1pbmltaUBxdC5pbzAgFw0yMDEw
++MjYxMjAxMzFaGA8yMTIwMTAwMjEyMDEzMVowgYMxCzAJBgNVBAYTAk5PMQ0wCwYD
++VQQIDARPc2xvMQ0wCwYDVQQHDARPc2xvMRcwFQYDVQQKDA5UaGUgUXQgQ29tcGFu
++eTEMMAoGA1UECwwDUiZEMRIwEAYDVQQDDAlIMiBUZXN0ZXIxGzAZBgkqhkiG9w0B
++CQEWDG1pbmltaUBxdC5pbzCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIB
++AOiUp5+E4blouKH7q+rVNR8NoYX2XkBW+q+rpy1zu5ssRSzbqxAjDx9dkht7Qlnf
++VlDT00JvpOWdeuPon5915edQRsY4Unl6mKH29ra3OtUa1/yCJXsGVJTKCj7k4Bxb
++5mZzb/fTlZntMLdTIBMfUbw62FKir1WjKIcJ9fCoG8JaGeKVO4Rh5p0ezd4UUUId
++r1BXl5Nqdqy2vTMsEDnjOsD3egkv8I2SKN4O6n/C3wWYpMOWYZkGoZiKz7rJs/i/
++ez7bsV7JlwdzTlhpJzkcOSVFBP6JlEOxTNNxZ1wtKy7PtZGmsSSATq2e6+bw38Ae
++Op0XnzzqcGjtDDofBmT7OFzZWjS9VZS6+DOOe2QHWle1nCHcHyH4ku6IRlsr9xkR
++NAIlOfnvHHxqJUenoeaZ4oQDjCBKS1KXygJO/tL7BLTQVn/xK1EmPvKNnjzWk4tR
++PnibUhhs5635qpOU/YPqFBh1JjVruZbsWcDAhRcew0uxONXOa9E+4lttQ9ySYa1A
++LvWqJuAX7gu2BsBMLyqfm811YnA7CIFMyO+HlqmkLFfv5L/xIRAXR7l26YGO0VwX
++CGjMfz4NVPMMke4nB7qa9NkpXQBQKMms3Qzd5JW0Hy9Ruj5O8GPcFZmV0twjd1uJ
++PD/cAjkWLaXjdNsJ16QWc2nghQRS6HYqKRX6j+CXOxupAgMBAAGjUzBRMB0GA1Ud
++DgQWBBRSCOU58j9NJZkMamt623qyCrhN3TAfBgNVHSMEGDAWgBRSCOU58j9NJZkM
++amt623qyCrhN3TAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4ICAQCq
++q4jxsWeNDv5Nq14hJtF9HB+ZL64zcZtRjJP1YgNs0QppKICmjPOL2nIMGmI/jKrs
++0eGAL/9XXNVHPxm1OPOncvimMMmU6emZfpMdEtTfKP43+Pg9HgKRjLoQp406vGeQ
++8ki/mbBhrItVPgEm3tu2AFA02XTYi+YxCI9kRZLGkM3FbgtOuTLPl0Z9y+kiPc9F
++uCSC03anBEqv+vDSI8+wODymQ/IJ3Jyz1lxIRDfp4qAekmy0jU2c91VOHHEmOmqq
++kqygGFRdwbe99m9yP63r6q0b5K3X2UnJ6bns0hmTwThYwpVPXLU8jdaTddbMukN2
++/Ef96Tsw8nWOEOPMySHOTIPgwyZRp26b0kA9EmhLwOP401SxXVQCmSRmtwNagmtg
++jJKmZoYBN+//D45ibK8z6Q0oOm9P+Whf/uUXehcRxBxyV3xz7k0wKGQbHj/ddwcy
++IUoIN4lrAlib+lK170kTKN352PDmrpo2gmIzPEsfurKAIMSelDl6H+kih16BtZ8y
++Nz6fh9Soqrg3OSAware8pxV7k51crBMoPLN78KoRV8MFCK4K7Fddq4rRISq6hiXq
++r1nsjoEPuKM9huprmZVZe9t5YcDa2I+wb3IiE3uwpZbAdaLDyQ5n6F/qpsiIkZXn
++gtcF7oqpG5oYrwCcZ53y/ezUgUg7PlSz2XwAGvQtgg==
+ -----END CERTIFICATE-----
+diff --git a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
+index 9d1664d609..337ce541a6 100644
+--- a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
++++ b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
+@@ -1,15 +1,52 @@
+------BEGIN RSA PRIVATE KEY-----
+-MIICXAIBAAKBgQCnyKBKxBkFG2a6MuLS8RxvF4LkOS4BUZDbBDQyESHCDW9Z2FOQ
+-VD+Dj6nTs9XuGpuArsMlyV6lr0tgBaqg0ZEBH8oEg+NYHJkyRYRwclgDmEpji0H1
+-CEnSkQJga+Rk/t2gqnQI6TRMkV8SPTdNVCytf1uYYDYCjDv2RfMnapuUnQIDAQAB
+-AoGANFzLkanTeSGNFM0uttBipFT9F4a00dqHz6JnO7zXAT26I5r8sU1pqQBb6uLz
+-/+Qz5Zwk8RUAQcsMRgJetuPQUb0JZjF6Duv24hNazqXBCu7AZzUenjafwmKC/8ri
+-KpX3fTwqzfzi//FKGgbXQ80yykSSliDL3kn/drATxsLCgQECQQDXhEFWLJ0vVZ1s
+-1Ekf+3NITE+DR16X+LQ4W6vyEHAjTbaNWtcTKdAWLA2l6N4WAAPYSi6awm+zMxx4
+-VomVTsjdAkEAx0z+e7natLeFcrrq8pbU+wa6SAP1VfhQWKitxL1e7u/QO90NCpxE
+-oQYKzMkmmpOOFjQwEMAy1dvFMbm4LHlewQJAC/ksDBaUcQHHqjktCtrUb8rVjAyW
+-A8lscckeB2fEYyG5J6dJVaY4ClNOOs5yMDS2Afk1F6H/xKvtQ/5CzInA/QJATDub
+-K+BPU8jO9q+gpuIi3VIZdupssVGmCgObVCHLakG4uO04y9IyPhV9lA9tALtoIf4c
+-VIvv5fWGXBrZ48kZAQJBAJmVCdzQxd9LZI5vxijUCj5EI4e+x5DRqVUvyP8KCZrC
+-AiNyoDP85T+hBZaSXK3aYGpVwelyj3bvo1GrTNwNWLw=
+------END RSA PRIVATE KEY-----
++-----BEGIN PRIVATE KEY-----
++MIIJQgIBADANBgkqhkiG9w0BAQEFAASCCSwwggkoAgEAAoICAQDolKefhOG5aLih
+++6vq1TUfDaGF9l5AVvqvq6ctc7ubLEUs26sQIw8fXZIbe0JZ31ZQ09NCb6TlnXrj
++6J+fdeXnUEbGOFJ5epih9va2tzrVGtf8giV7BlSUygo+5OAcW+Zmc2/305WZ7TC3
++UyATH1G8OthSoq9VoyiHCfXwqBvCWhnilTuEYeadHs3eFFFCHa9QV5eTanastr0z
++LBA54zrA93oJL/CNkijeDup/wt8FmKTDlmGZBqGYis+6ybP4v3s+27FeyZcHc05Y
++aSc5HDklRQT+iZRDsUzTcWdcLSsuz7WRprEkgE6tnuvm8N/AHjqdF5886nBo7Qw6
++HwZk+zhc2Vo0vVWUuvgzjntkB1pXtZwh3B8h+JLuiEZbK/cZETQCJTn57xx8aiVH
++p6HmmeKEA4wgSktSl8oCTv7S+wS00FZ/8StRJj7yjZ481pOLUT54m1IYbOet+aqT
++lP2D6hQYdSY1a7mW7FnAwIUXHsNLsTjVzmvRPuJbbUPckmGtQC71qibgF+4LtgbA
++TC8qn5vNdWJwOwiBTMjvh5appCxX7+S/8SEQF0e5dumBjtFcFwhozH8+DVTzDJHu
++Jwe6mvTZKV0AUCjJrN0M3eSVtB8vUbo+TvBj3BWZldLcI3dbiTw/3AI5Fi2l43Tb
++CdekFnNp4IUEUuh2KikV+o/glzsbqQIDAQABAoICAFw1q6tr5I48vY7DF+rXsuLn
++5ZUWE1IQ6fzB4lr72nJv/9EEGnMgYzt9PpMUsD6vdCpBgS2C0+6RHArFzJtNA+RM
++iHLIG7K7702veyr/xBx/MwiSlMeMv/XpkFxVI6E6skMGG2s3AMXxKvJTy5CpRx+I
++eQFyLG+Ya1X2lgJes/q+/CpAHkOjCOpcLySQC5NZ74q734V7nSdmn+Zs3tYEh+O/
++eiuwTP/j5b38Te5vVTqDxTciJPmljmXLCwa0N100lWlbcpvw8qbqiTI2Jm3XCbUE
++AzHjW9vmrF3cRS1fXxKFGShw3SRqlkbxjfeWoi8qDPUBS4m8LOr8qG9Wo5Nfon0z
++zLP4bci3zHDvVcaaZrrsUBs/yZbg+Dgka1DmX7ekmeccr2yTdKDFgPupYUyxVbTl
++a9ZLJysjFD7rgBv1ZclHonLp6Vbm+ZoTqvteo4ikAy6L9RtBWJ23XEK34PkP/+c5
++2vWZaOrnjSeBHbFce8cdJSxqWpP+eSCI5I9XbDrYFIsQ/gqKgtzDKy2ihJ2Y8STL
++yO4hyFPFjxc+Gg4/P2PpmT5CY2ty44M0BWs+JGW96CJPrrplf2lmQUQJj5LZY66X
++Z/4C9L7ZYtKZ+bs5SvU46yWugAvQZX22Xm9xLXWyVXRdx3bj+3M3fDnF9di/zdbh
++CgLx7oWPNrXc7FCajnn9AoIBAQD5FMYwRpw9NWT9WDxQwx+cSI4Icbd88ByTW63S
++LzeRwZA0J9/SfwO+aBRupzc9GkGXCiZcGMw3AGsCtig8yFlw8E5KnzN7KlftDMnM
++9NUxxzlR8VwKyLnZfG7sDTl057ZlUujnqhmt/F8F7dIy7FVO1dE/8nngA+FYTCOG
++UZdGjwyBDlDM0JJdUWGY3xslutcpCDN5mzSTKjy9drMvImAshRawxRF6WBpn7vr2
++nC6vciqfx1Mzx1vyk0Jm0ilaydDdLMADjt/iL4Nkr0BEs4k+UzQiKDwp8gu7abQ1
++eBfxd9Iar4htQa2I1Ewl6P01G/q+ZYwgHhJ9RVn4AxQXefILAoIBAQDvCouORdQX
++C8wsyp7MwXlF/3NQeNN5/+B2mhbxrBOf7PmMCXLnkRWcjwJtzypWFqJ0sqai/2+0
++bqbMcjX5maT8stT2shl3zXe/Ejt2e3TBYpc1tyuses8Kb5BMU8hu6tTd3G2CMXpD
++dT6DVemJZCTtwj9aBNIxSizvlgMolJnCpzhPnlfHSI6E+g3m/LTTo3HwbjMSw/Uq
++irgjOpI2wSBB6LZPSgjvfcYPRyWUk16L4A5uSX0cADnovDFLa5/h0wJvN/OoCSQg
++rLCXG5E18EyL5Wc58BCY1ZvxmjG3lQtgPxYu2Jwc36R/y/JKlxW5suER5ZNpbbD4
++uOyTt2VxMQ2bAoIBAQC5+MzRFqdo/AjfL5Y5JrbfVTzXCTDa09xCGd16ZU60QTWN
+++4ed/r+o1sUKqUcRFB2MzEM/2DQBjQpZB/CbEWvWa1XJWXxypXbowveZU+QqOnmN
++uQvj8WLyA3o+PNF9e9QvauwCrHpn8VpxbtPWuaYoKnUFreFZZQxHhPGxRBIS2JOZ
++eDrT8ZaWnkCkh1AZp5smQ71LOprSlmKrg4jd1GjCVMxQR5N5KXbtyv0OTCZ/UFqK
++2aRBsMPyJgkaBChkZPLRcKwc+/wlQRx1fHQb14DNTApMxoXFO7eOwqmOkpAt9iyl
++SBIwoS0UUI5ab88+bBmXNvKcuFdNuQ4nowTJUn9pAoIBADMNkILBXSvS5DeIyuO2
++Sp1tkoZUV+5NfPY3sMDK3KIibaW/+t+EOBZo4L7tKQCb8vRzl21mmsfxfgRaPDbj
++3r3tv9g0b4YLxxBy52pFscj/soXRai17SS7UZwA2QK+XzgDYbDcLNC6mIsTQG4Gx
++dsWk3/zs3KuUSQaehmwrWK+fIUK38c1pLK8v7LoxrLkqxlHwZ04RthHw8KTthH7X
++Pnl1J0LF8CSeOyfWLSuPUfkT0GEzptnNHpEbaHfQM6R6eaGhVJPF6AZme4y6YYgg
++m2ihhSt1n0XVEWpHYWjxFy3mK2mz75unFC4LM+NEY2p2zuUQoCw7NjnY3QYrfCnx
++rRMCggEAXeXsMSLFjjyuoL7iKbAxo52HD/P0fBoy58LyRcwfNVr0lvYan4pYEx+o
++KijIh9K16PqXZXKMA9v003B+ulmF8bJ7SddCZ5NGvnFhUTDe4DdTKgp2RuwQ3Bsc
++3skPIDbhVETyOLCtys34USHrq8U/0DlGY3eLRfxw9GnbKxSBGa/KEu/qQLPNUo50
++7xHZDg7GKeC3kqNJeqKM9rkp0VzIGkEnaD9127LeNDmERDfftxJzFoC/THvUBLfU
++6Sus2ZYwRE8VFvKC30Q45t/c54X3IuhYvAuiCuTmyfE4ruyzyOwKzhUkeeLq1APX
++g0veFbyfzlJ0q8qzD/iffqqIa2ZSmQ==
++-----END PRIVATE KEY-----
+diff --git a/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp b/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
+index 7ba3715e13..752aa122f6 100644
+--- a/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
++++ b/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
+@@ -179,6 +179,7 @@ void tst_QAccessibilityLinux::initTestCase()
+     QVERIFY(!address.isEmpty());
+ 
+     m_window = new AccessibleTestWindow();
++    m_window->setObjectName("mainWindow"_L1);
+     m_window->show();
+ 
+     QVERIFY(QTest::qWaitForWindowExposed(m_window));
+@@ -236,8 +237,11 @@ bool hasState(QDBusInterface *interface, AtspiStateType state)
+ void tst_QAccessibilityLinux::testLabel()
+ {
+     QLabel *l = new QLabel(m_window);
++    l->setObjectName("theObjectName"_L1);
+     l->setText("Hello A11y");
+     m_window->addWidget(l);
++    auto a11yEmpty = new QLabel(m_window);
++    m_window->addWidget(l);
+ 
+     // Application
+     QCOMPARE(getParent(mainWindow), QLatin1String(ATSPI_DBUS_PATH_ROOT));
+@@ -249,6 +253,8 @@ void tst_QAccessibilityLinux::testLabel()
+     QCOMPARE(getChildren(labelInterface).count(), 0);
+     QCOMPARE(labelInterface->call(QDBus::Block, "GetRoleName").arguments().first().toString(), QLatin1String("label"));
+     QCOMPARE(labelInterface->call(QDBus::Block, "GetRole").arguments().first().toUInt(), 29u);
++    QCOMPARE(labelInterface->call(QDBus::Block, "GetAccessibleId").arguments().first().toString(),
++             QLatin1String("mainWindow.theObjectName"));
+     QCOMPARE(getParent(labelInterface), mainWindow->path());
+     QVERIFY(!hasState(labelInterface, ATSPI_STATE_EDITABLE));
+     QVERIFY(hasState(labelInterface, ATSPI_STATE_READ_ONLY));
+@@ -256,7 +262,12 @@ void tst_QAccessibilityLinux::testLabel()
+     l->setText("New text");
+     QCOMPARE(labelInterface->property("Name").toString(), l->text());
+ 
++    auto *a11yEmptyInterface = getInterface(children.at(1), "org.a11y.atspi.Accessible");
++    QCOMPARE(a11yEmptyInterface->call(QDBus::Block, "GetAccessibleId").arguments().first().toString(),
++             QLatin1String("mainWindow.QLabel"));
++
+     m_window->clearChildren();
++    delete a11yEmptyInterface;
+     delete labelInterface;
+ }
+ 
+diff --git a/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+index 76df61c892..6d6d65b791 100644
+--- a/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
++++ b/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2022 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the test suite of the Qt Toolkit.
+@@ -68,6 +68,8 @@ private slots:
+     void query_exec();
+     void execErrorRecovery_data() { generic_data(); }
+     void execErrorRecovery();
++    void prematureExec_data() { generic_data(); }
++    void prematureExec();
+     void first_data() { generic_data(); }
+     void first();
+     void next_data() { generic_data(); }
+@@ -2770,6 +2772,35 @@ void tst_QSqlQuery::execErrorRecovery()
+     QVERIFY_SQL( q, exec() );
+ }
+ 
++void tst_QSqlQuery::prematureExec()
++{
++    QFETCH(QString, dbName);
++    // We only want the engine name, for addDatabase():
++    int cut = dbName.indexOf(QChar('@'));
++    if (cut < 0)
++        QSKIP("Failed to parse database type out of name");
++    dbName.truncate(cut);
++    cut = dbName.indexOf(QChar('_'));
++    if (cut >= 0)
++        dbName = dbName.mid(cut + 1);
++
++    auto db = QSqlDatabase::addDatabase(dbName);
++    QSqlQuery q(db);
++
++    QTest::ignoreMessage(QtWarningMsg,
++                         "QSqlDatabasePrivate::removeDatabase: connection "
++                         "'qt_sql_default_connection' is still in use, all "
++                         "queries will cease to work.");
++    QTest::ignoreMessage(QtWarningMsg,
++                         "QSqlDatabasePrivate::addDatabase: duplicate connection name "
++                         "'qt_sql_default_connection', old connection removed.");
++    auto otherDb = QSqlDatabase::addDatabase(dbName);
++
++    QTest::ignoreMessage(QtWarningMsg, "QSqlQuery::exec: called before driver has been set up");
++    // QTBUG-100037: shouldn't crash !
++    QVERIFY(!q.exec("select stuff from TheVoid"));
++}
++
+ void tst_QSqlQuery::lastInsertId()
+ {
+     QFETCH( QString, dbName );
+diff --git a/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp b/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
+index 4aa3f8d60b..d2050a61aa 100644
+--- a/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
++++ b/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
+@@ -115,6 +115,10 @@ void tst_QAbstractItemModelTester::standardItemModelZeroColumns()
+     // QTBUG-92886
+     model.insertRows(0, 5);
+     model.removeRows(1, 2);
++
++    const QModelIndex parentIndex = model.index(0, 0);
++    model.insertRows(0, 5, parentIndex);
++    model.removeRows(1, 2, parentIndex);
+ }
+ 
+ void tst_QAbstractItemModelTester::testInsertThroughProxy()
+diff --git a/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json b/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
+index 12a4a22a19..ce518e78fb 100644
+--- a/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
++++ b/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
+@@ -668,50 +668,6 @@
+         "inputFile": "task192552.h",
+         "outputRevision": 67
+     },
+-    {
+-        "classes": [
+-            {
+-                "className": "InlineSlotsWithThrowDeclaration",
+-                "object": true,
+-                "qualifiedClassName": "InlineSlotsWithThrowDeclaration",
+-                "slots": [
+-                    {
+-                        "access": "public",
+-                        "name": "a",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "b",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "c",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "d",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "e",
+-                        "returnType": "void"
+-                    }
+-                ],
+-                "superClasses": [
+-                    {
+-                        "access": "public",
+-                        "name": "QObject"
+-                    }
+-                ]
+-            }
+-        ],
+-        "inputFile": "task189996.h",
+-        "outputRevision": 67
+-    },
+     {
+         "classes": [
+             {
+diff --git a/qtbase/tests/auto/tools/moc/moc.pro b/qtbase/tests/auto/tools/moc/moc.pro
+index c324b3a8cd..4aceb78dc0 100644
+--- a/qtbase/tests/auto/tools/moc/moc.pro
++++ b/qtbase/tests/auto/tools/moc/moc.pro
+@@ -15,7 +15,7 @@ cross_compile: DEFINES += MOC_CROSS_COMPILED
+ HEADERS += using-namespaces.h no-keywords.h task87883.h c-comments.h backslash-newlines.h oldstyle-casts.h \
+            slots-with-void-template.h qinvokable.h namespaced-flags.h trigraphs.h \
+            escapes-in-string-literals.h cstyle-enums.h qprivateslots.h gadgetwithnoenums.h \
+-           dir-in-include-path.h single_function_keyword.h task192552.h task189996.h \
++           dir-in-include-path.h single_function_keyword.h task192552.h \
+            task234909.h task240368.h pure-virtual-signals.h cxx11-enums.h \
+            cxx11-final-classes.h \
+            cxx11-explicit-override-control.h \
+diff --git a/qtbase/tests/auto/tools/moc/task189996.h b/qtbase/tests/auto/tools/moc/task189996.h
+deleted file mode 100644
+index f94a051b3a..0000000000
+--- a/qtbase/tests/auto/tools/moc/task189996.h
++++ /dev/null
+@@ -1,47 +0,0 @@
+-/****************************************************************************
+-**
+-** Copyright (C) 2016 The Qt Company Ltd.
+-** Contact: https://www.qt.io/licensing/
+-**
+-** This file is part of the test suite of the Qt Toolkit.
+-**
+-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+-** 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 General Public License Usage
+-** Alternatively, this file may be used under the terms of the GNU
+-** General Public License version 3 as published by the Free Software
+-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+-** 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-3.0.html.
+-**
+-** $QT_END_LICENSE$
+-**
+-****************************************************************************/
+-// inline functions can have throw declarations
+-
+-#ifndef TASK189996_H
+-#define TASK189996_H
+-
+-#include <QObject>
+-
+-class InlineSlotsWithThrowDeclaration : public QObject
+-{
+-    Q_OBJECT
+-
+-public slots:
+-    void a() throw() { }
+-    void b() const throw() { }
+-    void c() throw();
+-    void d() throw(int) { }
+-    void e() const throw(int,double) { }
+-};
+-
+-#endif
+diff --git a/qtbase/tests/auto/tools/moc/tst_moc.cpp b/qtbase/tests/auto/tools/moc/tst_moc.cpp
+index c716aead21..15dd9e41e5 100644
+--- a/qtbase/tests/auto/tools/moc/tst_moc.cpp
++++ b/qtbase/tests/auto/tools/moc/tst_moc.cpp
+@@ -631,7 +631,6 @@ public:
+ private slots:
+     void initTestCase();
+ 
+-    void slotWithException() throw(MyStruct);
+     void dontStripNamespaces();
+     void oldStyleCasts();
+     void warnOnExtraSignalSlotQualifiaction();
+@@ -673,7 +672,6 @@ private slots:
+     void templateGtGt();
+     void qprivateslots();
+     void qprivateproperties();
+-    void inlineSlotsWithThrowDeclaration();
+     void warnOnPropertyWithoutREAD();
+     void constructors();
+     void typenameWithUnsigned();
+@@ -784,12 +782,6 @@ void tst_Moc::initTestCase()
+ #endif
+ }
+ 
+-void tst_Moc::slotWithException() throw(MyStruct)
+-{
+-    // be happy
+-    QVERIFY(true);
+-}
+-
+ void tst_Moc::dontStripNamespaces()
+ {
+     Sender sender;
+@@ -824,7 +816,7 @@ void tst_Moc::oldStyleCasts()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-Wold-style-cast" << "-I" << "."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -894,7 +886,7 @@ void tst_Moc::inputFileNameWithDotsButNoExtension()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-I" << ".."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -1174,7 +1166,7 @@ void tst_Moc::ignoreOptionClashes()
+     QStringList gccArgs;
+     gccArgs << "-c" << "-x" << "c++" << "-I" << ".."
+          << "-I" << qtIncludePath << "-I" << includeDir << "-o" << "/dev/null"
+-         << "-fPIC" << "-std=c++11" <<  "-";
++         << "-fPIC" << "-std=c++1z" <<  "-";
+     proc.start("gcc", gccArgs);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -1593,21 +1585,6 @@ void tst_Moc::qprivateproperties()
+ 
+ }
+ 
+-#include "task189996.h"
+-
+-void InlineSlotsWithThrowDeclaration::c() throw() {}
+-
+-void tst_Moc::inlineSlotsWithThrowDeclaration()
+-{
+-    InlineSlotsWithThrowDeclaration tst;
+-    const QMetaObject *mobj = tst.metaObject();
+-    QVERIFY(mobj->indexOfSlot("a()") != -1);
+-    QVERIFY(mobj->indexOfSlot("b()") != -1);
+-    QVERIFY(mobj->indexOfSlot("c()") != -1);
+-    QVERIFY(mobj->indexOfSlot("d()") != -1);
+-    QVERIFY(mobj->indexOfSlot("e()") != -1);
+-}
+-
+ void tst_Moc::warnOnPropertyWithoutREAD()
+ {
+ #ifdef MOC_CROSS_COMPILED
+@@ -1869,7 +1846,7 @@ void tst_Moc::notifyError()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-I" << "."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+diff --git a/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+index c355ee9665..88c09de8e0 100644
+--- a/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
++++ b/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+@@ -251,6 +251,7 @@ private slots:
+     void testResetCachedSizeHint();
+     void statusTips();
+     void testRemovingColumnsViaLayoutChanged();
++    void testModelMovingColumns();
+ 
+ protected:
+     void setupTestData(bool use_reset_model = false);
+@@ -360,6 +361,12 @@ public:
+         endRemoveColumns();
+     }
+ 
++    void moveColumn(int from, int to)
++    {
++        beginMoveColumns(QModelIndex(), from, from, QModelIndex(), to);
++        endMoveColumns();
++    }
++
+     void cleanup()
+     {
+         emit layoutAboutToBeChanged();
+@@ -3627,5 +3634,18 @@ void tst_QHeaderView::testRemovingColumnsViaLayoutChanged()
+     // The main point of this test is that the section-size restoring code didn't go out of bounds.
+ }
+ 
++void tst_QHeaderView::testModelMovingColumns()
++{
++    QtTestModel model(10, 10);
++    QHeaderView hv(Qt::Horizontal);
++    hv.setModel(&model);
++    hv.resizeSections(QHeaderView::ResizeToContents);
++    hv.show();
++
++    QPersistentModelIndex index3 = model.index(0, 3);
++    model.moveColumn(3, 1);
++    QCOMPARE(index3.column(), 1);
++}
++
+ QTEST_MAIN(tst_QHeaderView)
+ #include "tst_qheaderview.moc"
+diff --git a/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+index 761357b252..06bb706074 100644
+--- a/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
++++ b/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+@@ -397,6 +397,7 @@ private slots:
+     void checkHeaderMinSize();
+ 
+     void resizeToContents();
++    void resizeToContentsSpans();
+ 
+     void tabFocus();
+     void bigModel();
+@@ -3721,6 +3722,70 @@ void tst_QTableView::resizeToContents()
+ 
+ }
+ 
++
++class SpanModel : public QAbstractTableModel
++{
++public:
++    SpanModel(bool sectionsMoved)
++        : _sectionsMoved(sectionsMoved)
++    {}
++    int columnCount(const QModelIndex & = {}) const override { return 2; }
++    int rowCount(const QModelIndex & = {}) const override { return 1; }
++    QVariant data(const QModelIndex &idx, int role = Qt::DisplayRole) const override
++    {
++        if (role != Qt::DisplayRole)
++            return QVariant();
++        const int col = _sectionsMoved ? 1 - idx.column() : idx.column();
++        if (col == 0)
++            return "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.";
++        return QVariant();
++    }
++private:
++    bool _sectionsMoved;
++};
++
++
++void tst_QTableView::resizeToContentsSpans()
++{
++    SpanModel model1(false);
++    SpanModel model2(true);
++    QTableView view1, view2, view3;
++    view1.setModel(&model1);
++    view2.setModel(&model2);
++    view2.horizontalHeader()->moveSection(0, 1);
++    view3.setModel(&model1);
++
++    view1.setSpan(0, 0, 1, 2);
++    view2.setSpan(0, 1, 1, 2);
++    view1.show();
++    view2.show();
++    view3.show();
++    QVERIFY(QTest::qWaitForWindowExposed(&view1));
++    QVERIFY(QTest::qWaitForWindowExposed(&view2));
++    QVERIFY(QTest::qWaitForWindowExposed(&view3));
++    view1.setColumnWidth(0, 100);
++    view1.setColumnWidth(1, 100);
++    view2.setColumnWidth(0, 100);
++    view2.setColumnWidth(1, 100);
++    view3.setColumnWidth(0, 200);
++
++    view1.resizeRowToContents(0);
++    view2.resizeRowToContents(0);
++    view3.resizeRowToContents(0);
++    QCOMPARE(view1.rowHeight(0), view3.rowHeight(0));
++    QCOMPARE(view2.rowHeight(0), view3.rowHeight(0));
++
++    view3.resizeColumnToContents(0);
++    view3.resizeRowToContents(0);
++    // height should be only 1 text line for easy testing
++    view1.setRowHeight(0, view3.verticalHeader()->sectionSize(0));
++    view2.setRowHeight(0, view3.verticalHeader()->sectionSize(0));
++    view1.resizeColumnToContents(0);
++    view2.resizeColumnToContents(1);
++    QCOMPARE(view1.columnWidth(0), view3.columnWidth(0) - view1.columnWidth(1));
++    QCOMPARE(view2.columnWidth(0), view3.columnWidth(0) - view2.columnWidth(1));
++}
++
+ QT_BEGIN_NAMESPACE
+ extern bool Q_WIDGETS_EXPORT qt_tab_all_widgets(); // qapplication.cpp
+ QT_END_NAMESPACE
+diff --git a/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+index a3b8ef78d8..4955cebd5d 100644
+--- a/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
++++ b/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+@@ -1498,7 +1498,7 @@ void tst_QApplication::desktopSettingsAware()
+     environment += QLatin1String("QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM=1");
+     testProcess.setEnvironment(environment);
+ #endif
+-    testProcess.start("desktopsettingsaware_helper");
++    testProcess.start("./desktopsettingsaware_helper");
+     QVERIFY2(testProcess.waitForStarted(),
+              qPrintable(QString::fromLatin1("Cannot start 'desktopsettingsaware_helper': %1").arg(testProcess.errorString())));
+     QVERIFY(testProcess.waitForFinished(10000));
+@@ -2452,7 +2452,7 @@ void tst_QApplication::qtbug_12673()
+ #if QT_CONFIG(process)
+     QProcess testProcess;
+     QStringList arguments;
+-    testProcess.start("modal_helper", arguments);
++    testProcess.start("./modal_helper", arguments);
+     QVERIFY2(testProcess.waitForStarted(),
+              qPrintable(QString::fromLatin1("Cannot start 'modal_helper': %1").arg(testProcess.errorString())));
+     QVERIFY(testProcess.waitForFinished(20000));
+diff --git a/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp b/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
+index eb108a40de..dca5528c1b 100644
+--- a/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
+@@ -41,6 +41,7 @@
+ 
+ #include <private/qguiapplication_p.h>
+ #include <qpa/qplatformintegration.h>
++#include <qpa/qplatformtheme.h>
+ 
+ class tst_QAbstractButton : public QObject
+ {
+@@ -76,6 +77,8 @@ private slots:
+     void keyNavigation();
+ #endif
+ 
++    void buttonPressKeys();
++
+ protected slots:
+     void onClicked();
+     void onToggled( bool on );
+@@ -269,7 +272,13 @@ void tst_QAbstractButton::setAutoRepeat()
+         QCOMPARE(press_count, click_count);
+         QVERIFY(click_count > 1);
+         break;
+-    case 4:
++    case 4: {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(Qt::Key_Enter)) {
++            QSKIP("platform theme has Key_Enter in ButtonPressKeys");
++        }
+         // check that pressing ENTER has no effect when autorepeat is false
+         testWidget->setDown( false );
+         testWidget->setAutoRepeat( false );
+@@ -286,7 +295,14 @@ void tst_QAbstractButton::setAutoRepeat()
+ 
+         QVERIFY( click_count == 0 );
+         break;
+-    case 5:
++    }
++    case 5: {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(Qt::Key_Enter)) {
++            QSKIP("platform theme has Key_Enter in ButtonPressKeys");
++        }
+         // check that pressing ENTER has no effect when autorepeat is true
+         testWidget->setDown( false );
+         testWidget->setAutoRepeat( true );
+@@ -304,6 +320,7 @@ void tst_QAbstractButton::setAutoRepeat()
+ 
+         QVERIFY( click_count == 0 );
+         break;
++    }
+     case 6:
+         // verify autorepeat is off by default.
+         MyButton tmp( 0);
+@@ -651,5 +668,16 @@ void tst_QAbstractButton::keyNavigation()
+ }
+ #endif
+ 
++void tst_QAbstractButton::buttonPressKeys()
++{
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(testWidget, buttonPressKeys[i]);
++        QCOMPARE(click_count, i + 1);
++    }
++}
++
+ QTEST_MAIN(tst_QAbstractButton)
+ #include "tst_qabstractbutton.moc"
+diff --git a/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+index 32437050f5..46b5af6d63 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+@@ -168,6 +168,7 @@ private slots:
+     void checkMenuItemPosWhenStyleSheetIsSet();
+     void checkEmbeddedLineEditWhenStyleSheetIsSet();
+     void propagateStyleChanges();
++    void buttonPressKeys();
+ 
+ private:
+     PlatformInputContext m_platformInputContext;
+@@ -1682,6 +1683,16 @@ void tst_QComboBox::setModel()
+     QCOMPARE(box.rootModelIndex(), rootModelIndex);
+     box.setModel(box.model());
+     QCOMPARE(box.rootModelIndex(), rootModelIndex);
++
++    // check that setting the same model as the completer's doesn't crash
++    QCompleter *completer = new QCompleter(&box);
++    box.setEditable(true);
++    box.setCompleter(completer);
++    auto *listModel = new QStringListModel({ "one", "two" }, completer);
++    completer->setModel(listModel);
++    QCOMPARE(listModel->rowCount(), 2); // make sure it wasn't deleted
++    box.setModel(listModel);
++    QCOMPARE(listModel->rowCount(), 2); // make sure it wasn't deleted
+ }
+ 
+ void tst_QComboBox::setCustomModelAndView()
+@@ -3632,5 +3643,24 @@ void tst_QComboBox::propagateStyleChanges()
+     QVERIFY(frameStyle.inquired);
+ }
+ 
++void tst_QComboBox::buttonPressKeys()
++{
++    QComboBox comboBox;
++    comboBox.setEditable(false);
++    comboBox.addItem(QString::number(1));
++    comboBox.addItem(QString::number(2));
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(&comboBox, buttonPressKeys[i]);
++        // On some platforms, a window will not be immediately visible,
++        // but take some event-loop iterations to complete.
++        // Using QTRY_VERIFY to deal with that.
++        QTRY_VERIFY(comboBox.view()->isVisible());
++        comboBox.hidePopup();
++    }
++}
++
+ QTEST_MAIN(tst_QComboBox)
+ #include "tst_qcombobox.moc"
+diff --git a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
+index be3cfcd104..c228fdfcca 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
++++ b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qcommandlinkbutton
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qcommandlinkbutton.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
+index 0044d33c66..4cf06296e4 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
+@@ -40,6 +40,9 @@
+ #include <QGridLayout>
+ #include <QPainter>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ class tst_QCommandLinkButton : public QObject
+ {
+     Q_OBJECT
+@@ -223,6 +226,13 @@ void tst_QCommandLinkButton::setAutoRepeat()
+     // check that pressing ENTER has no effect
+     resetCounters();
+     testWidget->setDown( false );
++    // Skip after reset if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
+     testWidget->setAutoRepeat( false );
+     QTest::keyPress( testWidget, Qt::Key_Enter );
+ 
+@@ -255,6 +265,14 @@ void tst_QCommandLinkButton::pressed()
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+ 
++    // Skip if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
++
+     QTest::keyPress( testWidget,Qt::Key_Enter );
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+diff --git a/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro b/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
+index 4a5e76ff65..a235fa1fac 100644
+--- a/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
++++ b/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qgroupbox
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qgroupbox.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp b/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
+index 4fb5d262ca..d8d7562b73 100644
+--- a/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
+@@ -35,6 +35,9 @@
+ #include <QRadioButton>
+ #include <QDialog>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ #include "qgroupbox.h"
+ 
+ class tst_QGroupBox : public QObject
+@@ -69,6 +72,7 @@ private slots:
+     void propagateFocus();
+     void task_QTBUG_19170_ignoreMouseReleaseEvent();
+     void task_QTBUG_15519_propagateMouseEvents();
++    void buttonPressKeys();
+ 
+ private:
+     bool checked;
+@@ -610,6 +614,20 @@ void tst_QGroupBox::task_QTBUG_15519_propagateMouseEvents()
+     QCOMPARE(parent.mouseMoved, true);
+ }
+ 
++void tst_QGroupBox::buttonPressKeys()
++{
++    QGroupBox groupBox;
++    groupBox.setCheckable(true);
++    QSignalSpy clickedSpy(&groupBox, &QGroupBox::clicked);
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(&groupBox, buttonPressKeys[i]);
++        QCOMPARE(clickedSpy.length(), i + 1);
++    }
++}
++
+ void tst_QGroupBox::sendMouseMoveEvent(QWidget *widget, const QPoint &localPos)
+ {
+     // Send a MouseMove event without actually moving the pointer
+diff --git a/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro b/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
+index 353ad06ca2..e55f6148f2 100644
+--- a/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
++++ b/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qpushbutton
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qpushbutton.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp b/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
+index e818514a79..4043e9326a 100644
+--- a/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
+@@ -41,6 +41,9 @@
+ #include <QStyleFactory>
+ #include <QTabWidget>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ class tst_QPushButton : public QObject
+ {
+ Q_OBJECT
+@@ -212,6 +215,13 @@ void tst_QPushButton::autoRepeat()
+     // check that pressing ENTER has no effect
+     resetCounters();
+     testWidget->setDown( false );
++    // Skip after reset if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
+     testWidget->setAutoRepeat( false );
+     QTest::keyPress( testWidget, Qt::Key_Enter );
+ 
+@@ -247,6 +257,14 @@ void tst_QPushButton::pressed()
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+ 
++    // Skip if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
++
+     QTest::keyPress( testWidget,Qt::Key_Enter );
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+diff --git a/qtbase/tests/manual/rhi/cubemap_render/buildshader.bat b/qtbase/tests/manual/rhi/cubemap_render/buildshader.bat
+old mode 100755
+new mode 100644
+Submodule qtconnectivity e957d481..056294c0:
+diff --git a/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp b/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
+index e2635fae..a8b8e3b9 100644
+--- a/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
++++ b/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
+@@ -563,9 +563,11 @@ void HciManager::handleHciAclPacket(const quint8 *data, int size)
+ 
+ void HciManager::handleLeMetaEvent(const quint8 *data)
+ {
+-    // Spec v4.2, Vol 2, part E, 7.7.65ff
++    // Spec v5.3, Vol 4, part E, 7.7.65.*
+     switch (*data) {
+-    case 0x1: {
++    case 0x1: // HCI_LE_Connection_Complete
++    case 0xA: // HCI_LE_Enhanced_Connection_Complete
++    {
+         const quint16 handle = bt_get_le16(data + 2);
+         emit connectionComplete(handle);
+         break;
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp b/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
+index 6a93143b..4a18cfc7 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
+@@ -320,7 +320,10 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_finishSdpScan(QBluetoothServiceD
+             for (const QBluetoothUuid &id : serviceClassUuids) {
+                 if (id.minimumSize() == 16) {
+                     serviceInfo.setServiceUuid(id);
+-                    serviceInfo.setServiceName(QBluetoothServiceDiscoveryAgent::tr("Custom Service"));
++                    if (serviceInfo.serviceName().isEmpty()) {
++                        serviceInfo.setServiceName(
++                                    QBluetoothServiceDiscoveryAgent::tr("Custom Service"));
++                    }
+                     QBluetoothServiceInfo::Sequence modSeq =
+                             serviceInfo.attribute(QBluetoothServiceInfo::ServiceClassIds).value<QBluetoothServiceInfo::Sequence>();
+                     modSeq.removeOne(QVariant::fromValue(id));
+@@ -334,8 +337,10 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_finishSdpScan(QBluetoothServiceD
+                 qCDebug(QT_BT_BLUEZ) << "Discovered services" << discoveredDevices.at(0).address().toString()
+                                      << serviceInfo.serviceName() << serviceInfo.serviceUuid()
+                                      << ">>>" << serviceInfo.serviceClassUuids();
+-
+-                emit q->serviceDiscovered(serviceInfo);
++                // Use queued connection to allow us finish the service looping; the application
++                // might call stop() when it has detected the service-of-interest.
++                QMetaObject::invokeMethod(q, "serviceDiscovered", Qt::QueuedConnection,
++                                          Q_ARG(QBluetoothServiceInfo, serviceInfo));
+             }
+         }
+     }
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp b/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
+index e4d85447..aadd4755 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
+@@ -593,7 +593,7 @@ void QBluetoothSocket::setSocketState(QBluetoothSocket::SocketState state)
+ bool QBluetoothSocket::canReadLine() const
+ {
+     Q_D(const QBluetoothSocketBase);
+-    return d->canReadLine();
++    return d->canReadLine() || QIODevice::canReadLine();
+ }
+ 
+ /*!
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp b/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
+index 084aa958..d6aa17a7 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
+@@ -284,6 +284,10 @@ void QBluetoothSocketPrivateBluezDBus::connectToService(
+         return;
+     }
+ 
++    if (service.socketProtocol() != QBluetoothServiceInfo::Protocol::UnknownProtocol)
++        socketType = service.socketProtocol();
++    qCDebug(QT_BT_BLUEZ) << "Socket protocol used:" << socketType;
++
+     connectToService(service.device().address(), targetService, openMode);
+ }
+ 
+diff --git a/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp b/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
+index 05bc1a0f..a7b5ef1f 100644
+--- a/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
++++ b/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
+@@ -142,7 +142,7 @@ void tst_QBluetoothSocket::initTestCase()
+     qDebug() << "Starting discovery";
+ 
+     sda->setUuidFilter(QBluetoothUuid(QString(TEST_SERVICE_UUID)));
+-    sda->start(QBluetoothServiceDiscoveryAgent::MinimalDiscovery);
++    sda->start(QBluetoothServiceDiscoveryAgent::FullDiscovery);
+ 
+     for (int connectTime = MaxConnectTime; !done_discovery && connectTime > 0; connectTime -= 1000)
+         QTest::qWait(1000);
+Submodule qtdeclarative f5701f0d..8defe7bf:
+diff --git a/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h b/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
+index b65b994d6c..15a8cd6878 100644
+--- a/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
++++ b/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
+@@ -86,7 +86,7 @@ public:
+         if (QTypeInfo<T>::isComplex) {
+             for (int i = 0; i < count; ++i)
+                 new (data + i) T(vector.at(i));
+-        } else {
++        } else if (count) {
+             memcpy(data, static_cast<const void*>(vector.constData()), count * sizeof(T));
+         }
+     }
+diff --git a/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp b/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
+index e57cdd8278..94613598af 100644
+--- a/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
++++ b/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
+@@ -1145,8 +1145,7 @@ void Heap::QObjectWrapper::markObjects(Heap::Base *that, QV4::MarkStack *markSta
+ void QObjectWrapper::destroyObject(bool lastCall)
+ {
+     Heap::QObjectWrapper *h = d();
+-    if (!h->internalClass)
+-        return; // destroyObject already got called
++    Q_ASSERT(h->internalClass);
+ 
+     if (h->object()) {
+         QQmlData *ddata = QQmlData::get(h->object(), false);
+@@ -1176,7 +1175,7 @@ void QObjectWrapper::destroyObject(bool lastCall)
+         }
+     }
+ 
+-    h->~Data();
++    h->destroy();
+ }
+ 
+ 
+diff --git a/qtdeclarative/src/qml/memory/qv4mm.cpp b/qtdeclarative/src/qml/memory/qv4mm.cpp
+index 06caf04e5a..da149a67c4 100644
+--- a/qtdeclarative/src/qml/memory/qv4mm.cpp
++++ b/qtdeclarative/src/qml/memory/qv4mm.cpp
+@@ -981,7 +981,7 @@ void MemoryManager::sweep(bool lastSweep, ClassDestroyStatsCallback classCountPt
+ 
+     if (MultiplyWrappedQObjectMap *multiplyWrappedQObjects = engine->m_multiplyWrappedQObjects) {
+         for (MultiplyWrappedQObjectMap::Iterator it = multiplyWrappedQObjects->begin(); it != multiplyWrappedQObjects->end();) {
+-            if (!it.value().isNullOrUndefined())
++            if (it.value().isNullOrUndefined())
+                 it = multiplyWrappedQObjects->erase(it);
+             else
+                 ++it;
+diff --git a/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp b/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
+index 2079a8ed04..a577cb2351 100644
+--- a/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
++++ b/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
+@@ -389,6 +389,12 @@ void QQmlDelegateModelPrivate::connectToAbstractItemModel()
+                       q,  QQmlDelegateModel, SLOT(_q_rowsRemoved(QModelIndex,int,int)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
+                       q,  QQmlDelegateModel, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsInserted(QModelIndex,int,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsInserted(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsRemoved(QModelIndex,int,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsRemoved(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsMoved(QModelIndex,int,int,QModelIndex,int)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
+                       q, QQmlDelegateModel, SLOT(_q_dataChanged(QModelIndex,QModelIndex,QVector<int>)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
+@@ -413,6 +419,12 @@ void QQmlDelegateModelPrivate::disconnectFromAbstractItemModel()
+                         q, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int)));
+     QObject::disconnect(aim, SIGNAL(rowsRemoved(QModelIndex,int,int)),
+                         q, SLOT(_q_rowsRemoved(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsInserted(QModelIndex,int,int)), q,
++                        SLOT(_q_columnsInserted(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsRemoved(QModelIndex,int,int)), q,
++                        SLOT(_q_columnsRemoved(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)), q,
++                        SLOT(_q_columnsMoved(QModelIndex,int,int,QModelIndex,int)));
+     QObject::disconnect(aim, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
+                         q, SLOT(_q_dataChanged(QModelIndex,QModelIndex,QVector<int>)));
+     QObject::disconnect(aim, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
+@@ -1973,6 +1985,38 @@ void QQmlDelegateModel::_q_rowsMoved(
+     }
+ }
+ 
++void QQmlDelegateModel::_q_columnsInserted(const QModelIndex &parent, int begin, int end)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if (parent == d->m_adaptorModel.rootIndex && begin == 0) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
++void QQmlDelegateModel::_q_columnsRemoved(const QModelIndex &parent, int begin, int end)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if (parent == d->m_adaptorModel.rootIndex && begin == 0) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
++void QQmlDelegateModel::_q_columnsMoved(const QModelIndex &parent, int start, int end,
++                                        const QModelIndex &destination, int column)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if ((parent == d->m_adaptorModel.rootIndex && start == 0)
++        || (destination == d->m_adaptorModel.rootIndex && column == 0)) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
+ void QQmlDelegateModel::_q_dataChanged(const QModelIndex &begin, const QModelIndex &end, const QVector<int> &roles)
+ {
+     Q_D(QQmlDelegateModel);
+diff --git a/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h b/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
+index 8aab4badca..d140bfbaaf 100644
+--- a/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
++++ b/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
+@@ -152,6 +152,9 @@ private Q_SLOTS:
+     void _q_itemsMoved(int from, int to, int count);
+     void _q_modelReset();
+     void _q_rowsInserted(const QModelIndex &,int,int);
++    void _q_columnsInserted(const QModelIndex &, int, int);
++    void _q_columnsRemoved(const QModelIndex &, int, int);
++    void _q_columnsMoved(const QModelIndex &, int, int, const QModelIndex &, int);
+     void _q_rowsAboutToBeRemoved(const QModelIndex &parent, int begin, int end);
+     void _q_rowsRemoved(const QModelIndex &,int,int);
+     void _q_rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int);
+diff --git a/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp b/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
+index 85719fdc80..78e2ab302c 100644
+--- a/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
++++ b/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
+@@ -46,6 +46,7 @@
+ #include "QtQuick/private/qquicktextinput_p.h"
+ #include "QtQuick/private/qquickaccessibleattached_p.h"
+ #include "QtQuick/qquicktextdocument.h"
++#include "QtQuick/qquickrendercontrol.h"
+ QT_BEGIN_NAMESPACE
+ 
+ #if QT_CONFIG(accessibility)
+@@ -57,7 +58,19 @@ QAccessibleQuickItem::QAccessibleQuickItem(QQuickItem *item)
+ 
+ QWindow *QAccessibleQuickItem::window() const
+ {
+-    return item()->window();
++    QQuickWindow *window = item()->window();
++
++    // For QQuickWidget the above window will be the offscreen QQuickWindow,
++    // which is not a part of the accessibility tree. Detect this case and
++    // return the window for the QQuickWidget instead.
++    if (window && !window->handle()) {
++        if (QQuickRenderControl *renderControl = QQuickWindowPrivate::get(window)->renderControl) {
++            if (QWindow *renderWindow = renderControl->renderWindow(nullptr))
++                return renderWindow;
++        }
++    }
++
++    return window;
+ }
+ 
+ int QAccessibleQuickItem::childCount() const
+@@ -113,19 +126,15 @@ QAccessibleInterface *QAccessibleQuickItem::childAt(int x, int y) const
+ QAccessibleInterface *QAccessibleQuickItem::parent() const
+ {
+     QQuickItem *parent = item()->parentItem();
+-    QQuickWindow *window = item()->window();
+-    QQuickItem *ci = window ? window->contentItem() : nullptr;
++    QQuickWindow *itemWindow = item()->window();
++    QQuickItem *ci = itemWindow ? itemWindow->contentItem() : nullptr;
+     while (parent && !QQuickItemPrivate::get(parent)->isAccessible && parent != ci)
+         parent = parent->parentItem();
+ 
+     if (parent) {
+         if (parent == ci) {
+-            // Jump out to the scene widget if the parent is the root item.
+-            // There are two root items, QQuickWindow::rootItem and
+-            // QQuickView::declarativeRoot. The former is the true root item,
+-            // but is not a part of the accessibility tree. Check if we hit
+-            // it here and return an interface for the scene instead.
+-            return QAccessible::queryAccessibleInterface(window);
++            // Jump out to the window if the parent is the root item
++            return QAccessible::queryAccessibleInterface(window());
+         } else {
+             while (parent && !parent->d_func()->isAccessible)
+                 parent = parent->parentItem();
+@@ -188,7 +197,7 @@ QAccessible::State QAccessibleQuickItem::state() const
+     QRect viewRect_ = viewRect();
+     QRect itemRect = rect();
+ 
+-    if (viewRect_.isNull() || itemRect.isNull() || !item()->window() || !item()->window()->isVisible() ||!item()->isVisible() || qFuzzyIsNull(item()->opacity()))
++    if (viewRect_.isNull() || itemRect.isNull() || !window() || !window()->isVisible() ||!item()->isVisible() || qFuzzyIsNull(item()->opacity()))
+         state.invisible = true;
+     if (!viewRect_.intersects(itemRect))
+         state.offscreen = true;
+@@ -201,6 +210,10 @@ QAccessible::State QAccessibleQuickItem::state() const
+     if (role() == QAccessible::EditableText)
+         if (auto ti = qobject_cast<QQuickTextInput *>(item()))
+             state.passwordEdit = ti->echoMode() != QQuickTextInput::Normal;
++    if (!item()->isEnabled()) {
++        state.focusable = false;
++        state.disabled = true;
++    }
+     return state;
+ }
+ 
+diff --git a/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h b/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
+index 39ffcaf39c..8baa01330c 100644
+--- a/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
++++ b/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
+@@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE
+ 
+ #if QT_CONFIG(accessibility)
+ 
+-class QAccessibleQuickWindow : public QAccessibleObject
++class Q_QUICK_EXPORT QAccessibleQuickWindow : public QAccessibleObject
+ {
+ public:
+     QAccessibleQuickWindow(QQuickWindow *object);
+diff --git a/qtdeclarative/src/quick/items/qquickdrag.cpp b/qtdeclarative/src/quick/items/qquickdrag.cpp
+index 8321fcfeed..383078b3b9 100644
+--- a/qtdeclarative/src/quick/items/qquickdrag.cpp
++++ b/qtdeclarative/src/quick/items/qquickdrag.cpp
+@@ -481,7 +481,9 @@ void QQuickDragAttached::setKeys(const QStringList &keys)
+     \qmlattachedproperty stringlist QtQuick::Drag::mimeData
+     \since 5.2
+ 
+-    This property holds a map of mimeData that is used during startDrag.
++    This property holds a map from mime type to data that is used during startDrag.
++    The mime data needs to be a \c string, or an \c ArrayBuffer with the data encoded
++    according to the mime type.
+ */
+ 
+ QVariantMap QQuickDragAttached::mimeData() const
+@@ -766,8 +768,12 @@ Qt::DropAction QQuickDragAttachedPrivate::startDrag(Qt::DropActions supportedAct
+     QDrag *drag = new QDrag(source ? source : q);
+     QMimeData *mimeData = new QMimeData();
+ 
+-    for (auto it = externalMimeData.cbegin(), end = externalMimeData.cend(); it != end; ++it)
+-        mimeData->setData(it.key(), it.value().toString().toUtf8());
++    for (auto it = externalMimeData.cbegin(), end = externalMimeData.cend(); it != end; ++it) {
++        if (static_cast<QMetaType::Type>(it.value().type()) == QMetaType::QByteArray)
++            mimeData->setData(it.key(), it.value().toByteArray());
++        else
++            mimeData->setData(it.key(), it.value().toString().toUtf8());
++    }
+ 
+     drag->setMimeData(mimeData);
+     if (pixmapLoader.isReady()) {
+diff --git a/qtdeclarative/src/quick/items/qquickitem.cpp b/qtdeclarative/src/quick/items/qquickitem.cpp
+index 75f1457816..dec0ae19ae 100644
+--- a/qtdeclarative/src/quick/items/qquickitem.cpp
++++ b/qtdeclarative/src/quick/items/qquickitem.cpp
+@@ -59,6 +59,7 @@
+ #include <QtCore/private/qnumeric_p.h>
+ #include <QtGui/qpa/qplatformtheme.h>
+ #include <QtCore/qloggingcategory.h>
++#include <QtCore/private/qduplicatetracker_p.h>
+ 
+ #include <private/qqmlglobal_p.h>
+ #include <private/qqmlengine_p.h>
+@@ -2326,6 +2327,7 @@ QQuickItem::QQuickItem(QQuickItemPrivate &dd, QQuickItem *parent)
+ QQuickItem::~QQuickItem()
+ {
+     Q_D(QQuickItem);
++    d->inDestructor = true;
+ 
+     if (d->windowRefCount > 1)
+         d->windowRefCount = 1; // Make sure window is set to null in next call to derefWindow().
+@@ -2526,6 +2528,7 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo
+     QQuickItem *current = item;
+     qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: startItem:" << startItem;
+     qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: firstFromItem:" << firstFromItem;
++    QDuplicateTracker<QQuickItem *> cycleDetector;
+     do {
+         qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: current:" << current;
+         qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: from:" << from;
+@@ -2592,7 +2595,10 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo
+         // traversed all of the chain (by compare the [current] item with [startItem])
+         // Since the [startItem] might be promoted to its parent if it is invisible,
+         // we still have to check [current] item with original start item
+-        if ((current == startItem || current == originalStartItem) && from == firstFromItem) {
++        // We might also run into a cycle before we reach firstFromItem again
++        // but note that we have to ignore current if we are meant to skip it
++        if (((current == startItem || current == originalStartItem) && from == firstFromItem) ||
++                (!skip && cycleDetector.hasSeen(current))) {
+             // wrapped around, avoid endless loops
+             if (item == contentItem) {
+                 qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: looped, return contentItem";
+@@ -2689,9 +2695,8 @@ void QQuickItem::setParentItem(QQuickItem *parentItem)
+ 
+         const bool wasVisible = isVisible();
+         op->removeChild(this);
+-        if (wasVisible) {
++        if (wasVisible && !op->inDestructor)
+             emit oldParentItem->visibleChildrenChanged();
+-        }
+     } else if (d->window) {
+         QQuickWindowPrivate::get(d->window)->parentlessItems.remove(this);
+     }
+@@ -2768,8 +2773,9 @@ void QQuickItem::setParentItem(QQuickItem *parentItem)
+ 
+     d->itemChange(ItemParentHasChanged, d->parentItem);
+ 
+-    emit parentChanged(d->parentItem);
+-    if (isVisible() && d->parentItem)
++    if (!d->inDestructor)
++        emit parentChanged(d->parentItem);
++    if (isVisible() && d->parentItem && !QQuickItemPrivate::get(d->parentItem)->inDestructor)
+         emit d->parentItem->visibleChildrenChanged();
+ }
+ 
+@@ -2965,7 +2971,8 @@ void QQuickItemPrivate::removeChild(QQuickItem *child)
+ 
+     itemChange(QQuickItem::ItemChildRemovedChange, child);
+ 
+-    emit q->childrenChanged();
++    if (!inDestructor)
++        emit q->childrenChanged();
+ }
+ 
+ void QQuickItemPrivate::refWindow(QQuickWindow *c)
+@@ -3194,6 +3201,7 @@ QQuickItemPrivate::QQuickItemPrivate()
+     , touchEnabled(false)
+ #endif
+     , hasCursorHandler(false)
++    , inDestructor(false)
+     , dirtyAttributes(0)
+     , nextDirtyItem(nullptr)
+     , prevDirtyItem(nullptr)
+@@ -5120,6 +5128,13 @@ void QQuickItem::componentComplete()
+         d->addToDirtyList();
+         QQuickWindowPrivate::get(d->window)->dirtyItem(this);
+     }
++
++#if QT_CONFIG(accessibility)
++    if (d->isAccessible && d->effectiveVisible) {
++        QAccessibleEvent ev(this, QAccessible::ObjectShow);
++        QAccessible::updateAccessibility(&ev);
++    }
++#endif
+ }
+ 
+ QQuickStateGroup *QQuickItemPrivate::_states()
+@@ -6106,9 +6121,11 @@ bool QQuickItemPrivate::setEffectiveVisibleRecur(bool newEffectiveVisible)
+         QAccessible::updateAccessibility(&ev);
+     }
+ #endif
+-    emit q->visibleChanged();
+-    if (childVisibilityChanged)
+-        emit q->visibleChildrenChanged();
++    if (!inDestructor) {
++        emit q->visibleChanged();
++        if (childVisibilityChanged)
++            emit q->visibleChildrenChanged();
++    }
+ 
+     return true;    // effective visibility DID change
+ }
+@@ -6157,6 +6174,15 @@ void QQuickItemPrivate::setEffectiveEnableRecur(QQuickItem *scope, bool newEffec
+     }
+ 
+     itemChange(QQuickItem::ItemEnabledHasChanged, effectiveEnable);
++#if QT_CONFIG(accessibility)
++    if (isAccessible) {
++        QAccessible::State changedState;
++        changedState.disabled = true;
++        changedState.focusable = true;
++        QAccessibleStateChangeEvent ev(q, changedState);
++        QAccessible::updateAccessibility(&ev);
++    }
++#endif
+     emit q->enabledChanged();
+ }
+ 
+diff --git a/qtdeclarative/src/quick/items/qquickitem_p.h b/qtdeclarative/src/quick/items/qquickitem_p.h
+index 841d91bb40..ade8fb61f2 100644
+--- a/qtdeclarative/src/quick/items/qquickitem_p.h
++++ b/qtdeclarative/src/quick/items/qquickitem_p.h
+@@ -472,6 +472,7 @@ public:
+     bool replayingPressEvent:1;
+     bool touchEnabled:1;
+     bool hasCursorHandler:1;
++    quint32 inDestructor:1; // has entered ~QQuickItem
+ 
+     enum DirtyType {
+         TransformOrigin         = 0x00000001,
+diff --git a/qtdeclarative/src/quick/items/qquickitemview.cpp b/qtdeclarative/src/quick/items/qquickitemview.cpp
+index 010a0152e1..f8ad168a17 100644
+--- a/qtdeclarative/src/quick/items/qquickitemview.cpp
++++ b/qtdeclarative/src/quick/items/qquickitemview.cpp
+@@ -1785,7 +1785,7 @@ void QQuickItemViewPrivate::refill(qreal from, qreal to)
+ 
+     do {
+         bufferPause.stop();
+-        if (currentChanges.hasPendingChanges() || bufferedChanges.hasPendingChanges()) {
++        if (currentChanges.hasPendingChanges() || bufferedChanges.hasPendingChanges() || currentChanges.active) {
+             currentChanges.reset();
+             bufferedChanges.reset();
+             releaseVisibleItems(reusableFlag);
+diff --git a/qtdeclarative/src/quick/items/qquickmousearea_p_p.h b/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
+index fba383e268..0d63618622 100644
+--- a/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
++++ b/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
+@@ -61,7 +61,6 @@ QT_BEGIN_NAMESPACE
+ 
+ class QQuickMouseEvent;
+ class QQuickMouseArea;
+-class QQuickPointerMask;
+ class QQuickMouseAreaPrivate : public QQuickItemPrivate
+ {
+     Q_DECLARE_PUBLIC(QQuickMouseArea)
+@@ -100,7 +99,6 @@ public:
+ #if QT_CONFIG(quick_draganddrop)
+     QQuickDrag *drag;
+ #endif
+-    QPointer<QQuickPointerMask> mask;
+     QPointF startScene;
+     QPointF targetStartPos;
+     QPointF lastPos;
+diff --git a/qtdeclarative/src/quick/items/qquicktext.cpp b/qtdeclarative/src/quick/items/qquicktext.cpp
+index 6230186933..e823ca1095 100644
+--- a/qtdeclarative/src/quick/items/qquicktext.cpp
++++ b/qtdeclarative/src/quick/items/qquicktext.cpp
+@@ -2168,7 +2168,7 @@ void QQuickText::resetMaximumLineCount()
+     <img src="" align="top,middle,bottom" width="" height=""> - inline images
+     <ol type="">, <ul type=""> and <li> - ordered and unordered lists
+     <pre></pre> - preformatted
+-    &gt; &lt; &amp;
++    &gt; &lt; &amp; &quot; &nbsp; &apos;
+     \endcode
+ 
+     \c Text.StyledText parser is strict, requiring tags to be correctly nested.
+diff --git a/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp b/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
+index eb4db0f85e..2325a2665b 100644
+--- a/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
++++ b/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
+@@ -446,7 +446,7 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+         const char *textureRecord = allocatorData;
+         for (int i = 0; i < textureCount; ++i, textureRecord += Qtdf::TextureRecordSize) {
+-            if (textureRecord + Qtdf::TextureRecordSize > qtdfTableEnd) {
++            if (qtdfTableEnd - textureRecord < Qtdf::TextureRecordSize) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+@@ -462,7 +462,7 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+         const char *glyphRecord = textureRecord;
+         for (quint32 i = 0; i < glyphCount; ++i, glyphRecord += Qtdf::GlyphRecordSize) {
+-            if (glyphRecord + Qtdf::GlyphRecordSize > qtdfTableEnd) {
++            if (qtdfTableEnd - glyphRecord < Qtdf:: GlyphRecordSize) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+@@ -512,8 +512,8 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+             int width = texInfo->allocatedArea.width();
+             int height = texInfo->allocatedArea.height();
+-            qint64 size = width * height;
+-            if (reinterpret_cast<const char *>(textureData + size) > qtdfTableEnd) {
++            qint64 size = qint64(width) * height;
++            if (qtdfTableEnd - reinterpret_cast<const char *>(textureData) < size) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+diff --git a/qtdeclarative/src/quick/util/qquickstyledtext.cpp b/qtdeclarative/src/quick/util/qquickstyledtext.cpp
+index d531fc9205..a25af90414 100644
+--- a/qtdeclarative/src/quick/util/qquickstyledtext.cpp
++++ b/qtdeclarative/src/quick/util/qquickstyledtext.cpp
+@@ -564,6 +564,8 @@ void QQuickStyledTextPrivate::parseEntity(const QChar *&ch, const QString &textI
+                 textOut += QChar(60);
+             else if (entity == QLatin1String("amp"))
+                 textOut += QChar(38);
++            else if (entity == QLatin1String("apos"))
++                textOut += QChar(39);
+             else if (entity == QLatin1String("quot"))
+                 textOut += QChar(34);
+             else if (entity == QLatin1String("nbsp"))
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp
+new file mode 100644
+index 0000000000..8a1c901880
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp
+@@ -0,0 +1,110 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include "qaccessiblequickwidget_p.h"
++
++#include "qquickwidget_p.h"
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleQuickWidget::QAccessibleQuickWidget(QQuickWidget* widget)
++: QAccessibleWidget(widget)
++, m_accessibleWindow(QQuickWidgetPrivate::get(widget)->offscreenWindow)
++{
++    // NOTE: m_accessibleWindow is a QAccessibleQuickWindow, and not a
++    // QAccessibleQuickWidgetOffscreenWindow (defined below). This means
++    // it will return the Quick item child interfaces, which is what's needed here
++    // (unlike QAccessibleQuickWidgetOffscreenWindow, which will report 0 children).
++}
++
++QAccessibleInterface *QAccessibleQuickWidget::child(int index) const
++{
++    return m_accessibleWindow.child(index);
++}
++
++int QAccessibleQuickWidget::childCount() const
++{
++    return m_accessibleWindow.childCount();
++}
++
++int QAccessibleQuickWidget::indexOfChild(const QAccessibleInterface *iface) const
++{
++    return m_accessibleWindow.indexOfChild(iface);
++}
++
++QAccessibleInterface *QAccessibleQuickWidget::childAt(int x, int y) const
++{
++    return m_accessibleWindow.childAt(x, y);
++}
++
++QAccessibleQuickWidgetOffscreenWindow::QAccessibleQuickWidgetOffscreenWindow(QQuickWindow *window)
++:QAccessibleQuickWindow(window)
++{
++
++}
++
++QAccessibleInterface *QAccessibleQuickWidgetOffscreenWindow::child(int index) const
++{
++    Q_UNUSED(index);
++    return nullptr;
++}
++
++int QAccessibleQuickWidgetOffscreenWindow::childCount() const
++{
++    return 0;
++}
++
++int QAccessibleQuickWidgetOffscreenWindow::indexOfChild(const QAccessibleInterface *iface) const
++{
++    Q_UNUSED(iface);
++    return -1;
++}
++
++QAccessibleInterface *QAccessibleQuickWidgetOffscreenWindow::QAccessibleQuickWidgetOffscreenWindow::childAt(int x, int y) const
++{
++    Q_UNUSED(x);
++    Q_UNUSED(y);
++    return nullptr;
++}
++
++#endif // accessibility
++
++QT_END_NAMESPACE
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h
+new file mode 100644
+index 0000000000..7c2ab930e0
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h
+@@ -0,0 +1,95 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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 QACCESSIBLEQUICKWIDGET_H
++#define QACCESSIBLEQUICKWIDGET_H
++
++//
++//  W A R N I N G
++//  -------------
++//
++// This file is not part of the Qt API.  It exists purely as an
++// implementation detail.  This header file may change from version to
++// version without notice, or even be removed.
++//
++// We mean it.
++//
++
++#include "qquickwidget.h"
++#include <QtWidgets/qaccessiblewidget.h>
++
++#include <private/qaccessiblequickview_p.h>
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++// These classes implement the QQuickWiget accessibility switcharoo,
++// where the child items of the QQuickWidgetOffscreenWindow are reported
++// as child accessible interfaces of the QAccessibleQuickWidget.
++class QAccessibleQuickWidget: public QAccessibleWidget
++{
++public:
++    QAccessibleQuickWidget(QQuickWidget* widget);
++
++    QAccessibleInterface *child(int index) const override;
++    int childCount() const override;
++    int indexOfChild(const QAccessibleInterface *iface) const override;
++    QAccessibleInterface *childAt(int x, int y) const override;
++
++private:
++    QAccessibleQuickWindow m_accessibleWindow;
++    Q_DISABLE_COPY(QAccessibleQuickWidget)
++};
++
++class QAccessibleQuickWidgetOffscreenWindow: public QAccessibleQuickWindow
++{
++public:
++    QAccessibleQuickWidgetOffscreenWindow(QQuickWindow *window);
++    QAccessibleInterface *child(int index) const override;
++    int childCount() const override;
++    int indexOfChild(const QAccessibleInterface *iface) const override;
++    QAccessibleInterface *childAt(int x, int y) const override;
++};
++
++#endif // accessibility
++
++QT_END_NAMESPACE
++
++#endif
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp
+new file mode 100644
+index 0000000000..7ba88a1769
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp
+@@ -0,0 +1,60 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include "qaccessiblequickwidgetfactory_p.h"
++#include "qaccessiblequickwidget_p.h"
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleInterface *qAccessibleQuickWidgetFactory(const QString &classname, QObject *object)
++{
++    if (classname == QLatin1String("QQuickWidget")) {
++        return new QAccessibleQuickWidget(qobject_cast<QQuickWidget *>(object));
++    } else if (classname == QLatin1String("QQuickWidgetOffscreenWindow")) {
++        return new QAccessibleQuickWidgetOffscreenWindow(qobject_cast<QQuickWindow *>(object));
++    }
++    return 0;
++}
++
++#endif // accessibility
++
++QT_END_NAMESPACE
++
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h
+new file mode 100644
+index 0000000000..8c63b09f81
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h
+@@ -0,0 +1,66 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include <QtGui/qaccessible.h>
++
++#ifndef QACCESSIBLEQUICKWIDGETFACTORY_H
++#define QACCESSIBLEQUICKWIDGETFACTORY_H
++
++//
++//  W A R N I N G
++//  -------------
++//
++// This file is not part of the Qt API.  It exists purely as an
++// implementation detail.  This header file may change from version to
++// version without notice, or even be removed.
++//
++// We mean it.
++//
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleInterface *qAccessibleQuickWidgetFactory(const QString &classname, QObject *object);
++
++#endif
++
++QT_END_NAMESPACE
++
++#endif
+diff --git a/qtdeclarative/src/quickwidgets/qquickwidget.cpp b/qtdeclarative/src/quickwidgets/qquickwidget.cpp
+index 39780f8de3..9c97b43518 100644
+--- a/qtdeclarative/src/quickwidgets/qquickwidget.cpp
++++ b/qtdeclarative/src/quickwidgets/qquickwidget.cpp
+@@ -39,6 +39,7 @@
+ 
+ #include "qquickwidget.h"
+ #include "qquickwidget_p.h"
++#include "qaccessiblequickwidgetfactory_p.h"
+ 
+ #include "private/qquickwindow_p.h"
+ #include "private/qquickitem_p.h"
+@@ -75,9 +76,16 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++QQuickWidgetOffscreenWindow::QQuickWidgetOffscreenWindow(QQuickWindowPrivate &dd, QQuickRenderControl *control)
++:QQuickWindow(dd, control)
++{
++    setTitle(QString::fromLatin1("Offscreen"));
++    setObjectName(QString::fromLatin1("QQuickOffScreenWindow"));
++}
++
+ // override setVisble to prevent accidental offscreen window being created
+ // by base class.
+-class QQuickOffcreenWindowPrivate: public QQuickWindowPrivate {
++class QQuickWidgetOffscreenWindowPrivate: public QQuickWindowPrivate {
+ public:
+     void setVisible(bool visible) override {
+         Q_Q(QWindow);
+@@ -105,9 +113,8 @@ void QQuickWidgetPrivate::init(QQmlEngine* e)
+     Q_Q(QQuickWidget);
+ 
+     renderControl = new QQuickWidgetRenderControl(q);
+-    offscreenWindow = new QQuickWindow(*new QQuickOffcreenWindowPrivate(),renderControl);
+-    offscreenWindow->setTitle(QString::fromLatin1("Offscreen"));
+-    offscreenWindow->setObjectName(QString::fromLatin1("QQuickOffScreenWindow"));
++    offscreenWindow = new QQuickWidgetOffscreenWindow(*new QQuickWidgetOffscreenWindowPrivate(), renderControl);
++    offscreenWindow->setScreen(q->screen());
+     // Do not call create() on offscreenWindow.
+ 
+     // Check if the Software Adaptation is being used
+@@ -138,6 +145,10 @@ void QQuickWidgetPrivate::init(QQmlEngine* e)
+     QWidget::connect(offscreenWindow, &QQuickWindow::focusObjectChanged, q, &QQuickWidget::propagateFocusObjectChanged);
+     QObject::connect(renderControl, SIGNAL(renderRequested()), q, SLOT(triggerUpdate()));
+     QObject::connect(renderControl, SIGNAL(sceneChanged()), q, SLOT(triggerUpdate()));
++
++#if QT_CONFIG(accessibility)
++    QAccessible::installFactory(&qAccessibleQuickWidgetFactory);
++#endif
+ }
+ 
+ void QQuickWidgetPrivate::ensureEngine() const
+@@ -901,9 +912,7 @@ void QQuickWidgetPrivate::createContext()
+ 
+         context = new QOpenGLContext;
+         context->setFormat(offscreenWindow->requestedFormat());
+-        const QWindow *win = q->window()->windowHandle();
+-        if (win && win->screen())
+-            context->setScreen(win->screen());
++        context->setScreen(q->screen());
+         QOpenGLContext *shareContext = qt_gl_global_share_context();
+         if (!shareContext)
+             shareContext = QWidgetPrivate::get(q->window())->shareContext();
+@@ -1520,19 +1529,16 @@ bool QQuickWidget::event(QEvent *e)
+         d->handleWindowChange();
+         break;
+ 
+-    case QEvent::ScreenChangeInternal:
+-        if (QWindow *window = this->window()->windowHandle()) {
+-            QScreen *newScreen = window->screen();
+-
+-            if (d->offscreenWindow)
+-                d->offscreenWindow->setScreen(newScreen);
+-            if (d->offscreenSurface)
+-                d->offscreenSurface->setScreen(newScreen);
++    case QEvent::ScreenChangeInternal: {
++        QScreen *newScreen = screen();
++        if (d->offscreenWindow)
++            d->offscreenWindow->setScreen(newScreen);
++        if (d->offscreenSurface)
++            d->offscreenSurface->setScreen(newScreen);
+ #if QT_CONFIG(opengl)
+-            if (d->context)
+-                d->context->setScreen(newScreen);
++        if (d->context)
++            d->context->setScreen(newScreen);
+ #endif
+-        }
+ 
+         if (d->useSoftwareRenderer
+ #if QT_CONFIG(opengl)
+@@ -1545,7 +1551,7 @@ bool QQuickWidget::event(QEvent *e)
+             d->render(true);
+         }
+         break;
+-
++    }
+     case QEvent::Show:
+     case QEvent::Move:
+         d->updatePosition();
+diff --git a/qtdeclarative/src/quickwidgets/qquickwidget_p.h b/qtdeclarative/src/quickwidgets/qquickwidget_p.h
+index 881f7f9220..1a946bcc71 100644
+--- a/qtdeclarative/src/quickwidgets/qquickwidget_p.h
++++ b/qtdeclarative/src/quickwidgets/qquickwidget_p.h
+@@ -148,6 +148,14 @@ public:
+     bool forceFullUpdate;
+ };
+ 
++class QQuickWidgetOffscreenWindow: public QQuickWindow
++{
++    Q_OBJECT
++
++public:
++    QQuickWidgetOffscreenWindow(QQuickWindowPrivate &dd, QQuickRenderControl *control);
++};
++
+ QT_END_NAMESPACE
+ 
+ #endif // QQuickWidget_P_H
+diff --git a/qtdeclarative/src/quickwidgets/quickwidgets.pro b/qtdeclarative/src/quickwidgets/quickwidgets.pro
+index 2438e577ae..85d156b8a3 100644
+--- a/qtdeclarative/src/quickwidgets/quickwidgets.pro
++++ b/qtdeclarative/src/quickwidgets/quickwidgets.pro
+@@ -7,9 +7,13 @@ DEFINES   += QT_NO_URL_CAST_FROM_STRING QT_NO_INTEGER_EVENT_COORDINATES QT_NO_FO
+ HEADERS += \
+     qquickwidget.h \
+     qquickwidget_p.h \
+-    qtquickwidgetsglobal.h
++    qtquickwidgetsglobal.h \
++    qaccessiblequickwidget_p.h \
++    qaccessiblequickwidgetfactory_p.h
+ 
+ SOURCES += \
+-    qquickwidget.cpp
++    qquickwidget.cpp \
++    qaccessiblequickwidget.cpp \
++    qaccessiblequickwidgetfactory.cpp
+ 
+ load(qt_module)
+diff --git a/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+index 3b7d74df63..b75bf820d5 100644
+--- a/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
++++ b/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+@@ -102,6 +102,7 @@ private slots:
+     void valueConversion_RegularExpression();
+     void castWithMultipleInheritance();
+     void collectGarbage();
++    void collectGarbageNestedWrappersTwoEngines();
+     void gcWithNestedDataStructure();
+     void stacktrace();
+     void numberParsing_data();
+@@ -1809,6 +1810,44 @@ void tst_QJSEngine::collectGarbage()
+     QVERIFY(ptr.isNull());
+ }
+ 
++class TestObjectContainer : public QObject
++{
++    Q_OBJECT
++    Q_PROPERTY(QObject *dummy MEMBER m_dummy CONSTANT)
++
++public:
++    TestObjectContainer() : m_dummy(new QObject(this)) {}
++
++private:
++    QObject *m_dummy;
++};
++
++void tst_QJSEngine::collectGarbageNestedWrappersTwoEngines()
++{
++    QJSEngine engine1;
++    QJSEngine engine2;
++
++    TestObjectContainer container;
++    QQmlEngine::setObjectOwnership(&container, QQmlEngine::CppOwnership);
++
++    engine1.globalObject().setProperty("foobar", engine1.newQObject(&container));
++    engine2.globalObject().setProperty("foobar", engine2.newQObject(&container));
++
++    engine1.evaluate("foobar.dummy.baz = 42");
++    engine2.evaluate("foobar.dummy.baz = 43");
++
++    QCOMPARE(engine1.evaluate("foobar.dummy.baz").toInt(), 42);
++    QCOMPARE(engine2.evaluate("foobar.dummy.baz").toInt(), 43);
++
++    engine1.collectGarbage();
++    engine2.collectGarbage();
++
++    // The GC should not collect dummy object wrappers neither in engine1 nor engine2, we
++    // verify that by checking whether the baz property still has its previous value.
++    QCOMPARE(engine1.evaluate("foobar.dummy.baz").toInt(), 42);
++    QCOMPARE(engine2.evaluate("foobar.dummy.baz").toInt(), 43);
++}
++
+ void tst_QJSEngine::gcWithNestedDataStructure()
+ {
+     // The GC must be able to traverse deeply nested objects, otherwise this
+diff --git a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml
+new file mode 100644
+index 0000000000..206133bb39
+--- /dev/null
++++ b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml
+@@ -0,0 +1,11 @@
++import QtQuick 2.8
++
++ListView {
++    id: root
++    width: 200
++    height: 200
++
++    delegate: Text {
++        text: display
++    }
++}
+diff --git a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
+index 35f1e2c94d..1722447830 100644
+--- a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
++++ b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
+@@ -27,6 +27,8 @@
+ ****************************************************************************/
+ 
+ #include <QtTest/qtest.h>
++#include <QtCore/QConcatenateTablesProxyModel>
++#include <QtGui/QStandardItemModel>
+ #include <QtQml/qqmlcomponent.h>
+ #include <QtQmlModels/private/qqmldelegatemodel_p.h>
+ #include <QtQuick/qquickview.h>
+@@ -47,6 +49,7 @@ private slots:
+     void filterOnGroup_removeWhenCompleted();
+     void qtbug_86017();
+     void contextAccessedByHandler();
++    void redrawUponColumnChange();
+ };
+ 
+ class AbstractItemModel : public QAbstractItemModel
+@@ -186,6 +189,30 @@ void tst_QQmlDelegateModel::contextAccessedByHandler()
+     QVERIFY(root->property("works").toBool());
+ }
+ 
++void tst_QQmlDelegateModel::redrawUponColumnChange()
++{
++    QStandardItemModel m1;
++    m1.appendRow({
++            new QStandardItem("Banana"),
++            new QStandardItem("Coconut"),
++    });
++
++    QQuickView view(testFileUrl("redrawUponColumnChange.qml"));
++    QCOMPARE(view.status(), QQuickView::Ready);
++    view.show();
++    QQuickItem *root = view.rootObject();
++    root->setProperty("model", QVariant::fromValue<QObject *>(&m1));
++
++    QObject *item = root->property("currentItem").value<QObject *>();
++    QVERIFY(item);
++    QCOMPARE(item->property("text").toString(), "Banana");
++
++    QVERIFY(root);
++    m1.removeColumn(0);
++
++    QCOMPARE(item->property("text").toString(), "Coconut");
++}
++
+ QTEST_MAIN(tst_QQmlDelegateModel)
+ 
+ #include "tst_qqmldelegatemodel.moc"
+diff --git a/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp b/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
+index 5d635aa63b..824fd89e5b 100644
+--- a/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
++++ b/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
+@@ -76,10 +76,10 @@ void tst_qv4mm::multiWrappedQObjects()
+         QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 1);
+         QCOMPARE(engine2.memoryManager->m_pendingFreedObjectWrapperValue.size(), 0);
+ 
+-        // Moves the additional WeakValue from m_multiplyWrappedQObjects to
+-        // m_pendingFreedObjectWrapperValue. It's still alive after all.
++        // The additional WeakValue from m_multiplyWrappedQObjects hasn't been moved
++        // to m_pendingFreedObjectWrapperValue yet. It's still alive after all.
+         engine1.memoryManager->runGC();
+-        QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 2);
++        QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 1);
+ 
+         // engine2 doesn't own the object as engine1 was the first to wrap it above.
+         // Therefore, no effect here.
+diff --git a/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml b/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml
+new file mode 100644
+index 0000000000..889e480f3b
+--- /dev/null
++++ b/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml
+@@ -0,0 +1,13 @@
++import QtQuick 2.6
++
++Item {
++    visible: true
++    Item {
++        visible: false
++        Item {
++            objectName: "hiddenChild"
++            activeFocusOnTab: true
++            focus: true
++        }
++    }
++}
+diff --git a/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp b/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+index c8f251dbe1..c8ef36ee68 100644
+--- a/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
++++ b/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+@@ -67,6 +67,7 @@ private slots:
+     void activeFocusOnTab10();
+     void activeFocusOnTab_infiniteLoop_data();
+     void activeFocusOnTab_infiniteLoop();
++    void activeFocusOnTab_infiniteLoopControls();
+ 
+     void nextItemInFocusChain();
+     void nextItemInFocusChain2();
+@@ -1057,6 +1058,17 @@ void tst_QQuickItem::activeFocusOnTab_infiniteLoop()
+     QCOMPARE(item, window->rootObject());
+ }
+ 
++
++void tst_QQuickItem::activeFocusOnTab_infiniteLoopControls()
++{
++    auto source = testFileUrl("activeFocusOnTab_infiniteLoop3.qml");
++    QScopedPointer<QQuickView>window(new QQuickView());
++    window->setSource(source);
++    window->show();
++    QVERIFY(window->errors().isEmpty());
++    QTest::keyClick(window.get(), Qt::Key_Tab); // should not hang
++}
++
+ void tst_QQuickItem::nextItemInFocusChain()
+ {
+     if (!qt_tab_all_widgets())
+Submodule qtdoc c0c7bf07...79d6ef69:
+Submodule qtimageformats 2dcf2899..abe44c0f:
+diff --git a/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp b/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
+index dde783c..1bf9074 100644
+--- a/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
+@@ -462,8 +462,12 @@ static bool parseIconEntryInfo(ICNSEntry &icon)
+     if (isIconCompressed(icon))
+         return true;
+     // Icon depth:
+-    if (!depth.isEmpty())
+-        icon.depth = ICNSEntry::Depth(depth.toUInt());
++    if (!depth.isEmpty()) {
++        const uint depthUInt = depth.toUInt();
++        if (depthUInt > 32)
++            return false;
++        icon.depth = ICNSEntry::Depth(depthUInt);
++    }
+     // Try mono if depth not found
+     if (icon.depth == ICNSEntry::DepthUnknown)
+         icon.depth = ICNSEntry::DepthMono;
+@@ -515,6 +519,9 @@ static bool parseIconEntryInfo(ICNSEntry &icon)
+         }
+         icon.height = icon.width;
+     }
++    // Sanity check
++    if (icon.width == 0 || icon.width > 4096)
++        return false;
+     return true;
+ }
+ 
+@@ -685,7 +692,7 @@ bool QICNSHandler::canRead() const
+ bool QICNSHandler::read(QImage *outImage)
+ {
+     QImage img;
+-    if (!ensureScanned()) {
++    if (!ensureScanned() || m_currentIconIndex >= m_icons.size()) {
+         qWarning("QICNSHandler::read(): The device wasn't parsed properly!");
+         return false;
+     }
+@@ -892,7 +899,7 @@ bool QICNSHandler::scanDevice()
+             return false;
+ 
+         const qint64 blockDataOffset = device()->pos();
+-        if (!isBlockHeaderValid(blockHeader)) {
++        if (!isBlockHeaderValid(blockHeader, ICNSBlockHeaderSize + filelength - blockDataOffset)) {
+             qWarning("QICNSHandler::scanDevice(): Failed, bad header at pos %s. OSType \"%s\", length %u",
+                      QByteArray::number(blockDataOffset).constData(),
+                      nameFromOSType(blockHeader.ostype).constData(), blockHeader.length);
+@@ -927,11 +934,14 @@ bool QICNSHandler::scanDevice()
+         case ICNSBlockHeader::TypeOdrp:
+             // Icns container seems to have an embedded icon variant container
+             // Let's start a scan for entries
+-            while (device()->pos() < nextBlockOffset) {
++            while (!stream.atEnd() && device()->pos() < nextBlockOffset) {
+                 ICNSBlockHeader icon;
+                 stream >> icon;
++                if (stream.status() != QDataStream::Ok)
++                    return false;
+                 // Check for incorrect variant entry header and stop scan
+-                if (!isBlockHeaderValid(icon, blockDataLength))
++                quint64 remaining = blockDataLength - (device()->pos() - blockDataOffset);
++                if (!isBlockHeaderValid(icon, ICNSBlockHeaderSize + remaining))
+                     break;
+                 if (!addEntry(icon, device()->pos(), blockHeader.ostype))
+                     return false;
+@@ -1003,7 +1013,7 @@ bool QICNSHandler::scanDevice()
+             break;
+         }
+     }
+-    return true;
++    return (m_icons.size() > 0);
+ }
+ 
+ const ICNSEntry &QICNSHandler::getIconMask(const ICNSEntry &icon) const
+diff --git a/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp b/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
+index 5082023..cb34374 100644
+--- a/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
++++ b/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
+@@ -43,6 +43,7 @@
+ #include "qimage.h"
+ #include "qvariant.h"
+ #include "qcolor.h"
++#include "qimagereader.h"
+ 
+ #include <jasper/jasper.h>
+ #include <math.h> // for pow
+@@ -333,16 +334,46 @@ private:
+ Jpeg2000JasperReader::Jpeg2000JasperReader(QIODevice *iod, SubFormat format)
+     : jasperOk(true), ioDevice(iod), format(format), hasAlpha(false)
+ {
++#if JAS_VERSION_MAJOR < 3
+     if (jas_init()) {
+         jasperOk = false;
+         qDebug("Jasper Library initialization failed");
+     }
++#else
++    jas_conf_clear();
++#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
++    jas_conf_set_max_mem_usage(QImageReader::allocationLimit() * 1024 * 1024);
++#else
++    // 128MB seems to be enough.
++    jas_conf_set_max_mem_usage(128 * 1024 * 1024);
++#endif
++    if (jas_init_library()) {
++        jasperOk = false;
++        qDebug("Jasper library initialization failed");
++    }
++    if (jas_init_thread()) {
++        jas_cleanup_library();
++        jasperOk = false;
++        qDebug("Jasper thread initialization failed");
++    }
++#endif
+ }
+ 
+ Jpeg2000JasperReader::~Jpeg2000JasperReader()
+ {
++#if JAS_VERSION_MAJOR < 3
+     if (jasperOk)
+         jas_cleanup();
++#else
++    if (jasperOk) {
++        if (jas_cleanup_thread()) {
++            qDebug("Jasper thread cleanup failed");
++        }
++        if (jas_cleanup_library()) {
++            qDebug("Jasper library cleanup failed");
++        }
++    }
++#endif
+ }
+ 
+ /*! \internal
+@@ -857,7 +888,7 @@ bool Jpeg2000JasperReader::write(const QImage &image, int quality)
+     }
+ 
+     // Open an empty jasper stream that grows automatically
+-    jas_stream_t * memory_stream = jas_stream_memopen(0, -1);
++    jas_stream_t * memory_stream = jas_stream_memopen(0, 0);
+ 
+     // Jasper wants a non-const string.
+     char *str = qstrdup(jasperFormatString.toLatin1().constData());
+diff --git a/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp b/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
+index 1386750..ac8956c 100644
+--- a/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
+@@ -361,6 +361,8 @@ bool QTiffHandler::read(QImage *image)
+     }
+ 
+     TIFF *const tiff = d->tiff;
++    if (TIFFIsTiled(tiff) && TIFFTileSize64(tiff) > uint64_t(image->sizeInBytes())) // Corrupt image
++        return false;
+     const quint32 width = d->size.width();
+     const quint32 height = d->size.height();
+ 
+diff --git a/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp b/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
+index 82d38cb..d02eb05 100644
+--- a/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
+@@ -45,6 +45,7 @@
+ #include <qdebug.h>
+ #include <qpainter.h>
+ #include <qvariant.h>
++#include <QtEndian>
+ 
+ static const int riffHeaderSize = 12; // RIFF_HEADER_SIZE from webp/format_constants.h
+ 
+@@ -102,21 +103,23 @@ bool QWebpHandler::ensureScanned() const
+ 
+     m_scanState = ScanError;
+ 
+-    if (device()->isSequential()) {
+-        qWarning() << "Sequential devices are not supported";
++    QWebpHandler *that = const_cast<QWebpHandler *>(this);
++    const int headerBytesNeeded = sizeof(WebPBitstreamFeatures);
++    QByteArray header = device()->peek(headerBytesNeeded);
++    if (header.size() < headerBytesNeeded)
+         return false;
+-    }
+ 
+-    qint64 oldPos = device()->pos();
+-    device()->seek(0);
+-
+-    QWebpHandler *that = const_cast<QWebpHandler *>(this);
+-    QByteArray header = device()->peek(sizeof(WebPBitstreamFeatures));
++    // We do no random access during decoding, just a readAll() of the whole image file. So if
++    // if it is all available already, we can accept a sequential device. The riff header contains
++    // the file size minus 8 bytes header
++    qint64 byteSize = qFromLittleEndian<quint32>(header.constData() + 4);
++    if (device()->isSequential() && device()->bytesAvailable() < byteSize + 8) {
++        qWarning() << "QWebpHandler: Insufficient data available in sequential device";
++        return false;
++    }
+     if (WebPGetFeatures((const uint8_t*)header.constData(), header.size(), &(that->m_features)) == VP8_STATUS_OK) {
+         if (m_features.has_animation) {
+             // For animation, we have to read and scan whole file to determine loop count and images count
+-            device()->seek(oldPos);
+-
+             if (that->ensureDemuxer()) {
+                 that->m_loop = WebPDemuxGetI(m_demuxer, WEBP_FF_LOOP_COUNT);
+                 that->m_frameCount = WebPDemuxGetI(m_demuxer, WEBP_FF_FRAME_COUNT);
+@@ -126,17 +129,13 @@ bool QWebpHandler::ensureScanned() const
+                 if (that->m_features.has_alpha)
+                     that->m_composited->fill(Qt::transparent);
+ 
+-                // We do not reset device position since we have read in all data
+                 m_scanState = ScanSuccess;
+-                return true;
+             }
+         } else {
+             m_scanState = ScanSuccess;
+         }
+     }
+ 
+-    device()->seek(oldPos);
+-
+     return m_scanState == ScanSuccess;
+ }
+ 
+@@ -159,7 +158,7 @@ bool QWebpHandler::ensureDemuxer()
+ 
+ bool QWebpHandler::read(QImage *image)
+ {
+-    if (!ensureScanned() || device()->isSequential() || !ensureDemuxer())
++    if (!ensureScanned() || !ensureDemuxer())
+         return false;
+ 
+     QRect prevFrameRect;
+Submodule qtlocation 98a5c511..f991e28c:
+diff --git a/qtlocation/src/location/configure.json b/qtlocation/src/location/configure.json
+index 6d01a9a3..d1e623a1 100644
+--- a/qtlocation/src/location/configure.json
++++ b/qtlocation/src/location/configure.json
+@@ -9,7 +9,7 @@
+             "label": "Qt.labs.location experimental QML plugin",
+             "purpose": "Provides experimental QtLocation QML types",
+             "section": "Location",
+-            "condition": "config.opengl",
++            "condition": "features.opengl",
+             "output": [ "privateFeature" ]
+         },
+         "geoservices_osm": {
+diff --git a/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp b/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
+index a978573d..11e1466f 100644
+--- a/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
++++ b/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
+@@ -158,7 +158,7 @@ void QGeoMapObjectQSGSupport::updateMapObjects(QSGNode *root, QQuickWindow *wind
+     if (!root)
+         return;
+ 
+-    if (m_mapObjectsRootNode && m_mapObjectsRootNode->parent())
++    if (m_mapObjectsRootNode && !m_mapObjectsRootNode->parent())
+         root->appendChildNode(m_mapObjectsRootNode.get());
+ 
+     if (!m_mapObjectsRootNode) {
+diff --git a/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
+index 5a40467e..d123c6a8 100644
+--- a/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
+@@ -59,8 +59,10 @@ QT_BEGIN_NAMESPACE
+ static const QString kPrefixEsri(QStringLiteral("esri."));
+ static const QString kParamUserAgent(kPrefixEsri + QStringLiteral("useragent"));
+ 
+-static const QString kUrlGeocode(QStringLiteral("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates"));
+-static const QString kUrlReverseGeocode(QStringLiteral("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode"));
++static const QString kUrlGeocode(QStringLiteral("https://geocode.arcgis.com/arcgis/rest/services/"
++                                                "World/GeocodeServer/findAddressCandidates"));
++static const QString kUrlReverseGeocode(QStringLiteral(
++        "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode"));
+ 
+ static QString addressToQuery(const QGeoAddress &address)
+ {
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
+index 17492d94..96c12b1b 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
+@@ -46,7 +46,8 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-// JSON reference: http://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
++// JSON reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
+ 
+ static const QString kErrorMessage(QStringLiteral("Error %1: %2."));
+ static const QString kErrorJson(QStringLiteral("Error: invalide JSON document."));
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
+index 8cadfb29..92b6bb13 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
+@@ -44,7 +44,8 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-// JSON reference: http://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
++// JSON reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
+ 
+ GeoRouteReplyEsri::GeoRouteReplyEsri(QNetworkReply *reply, const QGeoRouteRequest &request,
+                                      QObject *parent) :
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
+index 0e6bc2c7..ed613f4b 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
+@@ -48,7 +48,8 @@ static const QString kPrefixEsri(QStringLiteral("esri."));
+ static const QString kParamUserAgent(kPrefixEsri + QStringLiteral("useragent"));
+ static const QString kParamToken(kPrefixEsri + QStringLiteral("token"));
+ 
+-static const QString kUrlRouting(QStringLiteral("http://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve"));
++static const QString kUrlRouting(QStringLiteral(
++        "https://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve"));
+ 
+ GeoRoutingManagerEngineEsri::GeoRoutingManagerEngineEsri(const QVariantMap &parameters,
+                                                          QGeoServiceProvider::Error *error,
+@@ -70,7 +71,8 @@ GeoRoutingManagerEngineEsri::~GeoRoutingManagerEngineEsri()
+ {
+ }
+ 
+-// REST reference: http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
++// REST reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
+ 
+ QGeoRouteReply *GeoRoutingManagerEngineEsri::calculateRoute(const QGeoRouteRequest &request)
+ {
+@@ -125,7 +127,7 @@ void GeoRoutingManagerEngineEsri::replyError(QGeoRouteReply::Error errorCode, co
+ QString GeoRoutingManagerEngineEsri::preferedDirectionLangage()
+ {
+     // list of supported langages is defined in:
+-    // http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
++    // https://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
+     const QStringList supportedLanguages = {
+         "ar", // Generate directions in Arabic
+         "cs", // Generate directions in Czech
+diff --git a/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
+index 5d15835d..24148f95 100644
+--- a/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
+@@ -230,7 +230,8 @@ QGeoMap *GeoTiledMappingManagerEngineEsri::createMap()
+ // ${y} = Y
+ // ${token} = Token
+ 
+-// template = 'http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{{z}}/{{y}}/{{x}}.png'
++// template =
++// 'https://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{{z}}/{{y}}/{{x}}.png'
+ 
+ bool GeoTiledMappingManagerEngineEsri::initializeMapSources(QGeoServiceProvider::Error *error,
+                                                             QString *errorString,
+diff --git a/qtlocation/src/plugins/geoservices/esri/maps.json b/qtlocation/src/plugins/geoservices/esri/maps.json
+index 8167ae7d..862e087d 100644
+--- a/qtlocation/src/plugins/geoservices/esri/maps.json
++++ b/qtlocation/src/plugins/geoservices/esri/maps.json
+@@ -6,8 +6,8 @@
+             "description": "ArcGIS Online World Street Map",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=3b93337983e9436f8db950e38a8629af'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=3b93337983e9436f8db950e38a8629af'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -16,8 +16,8 @@
+             "": "ArcGIS Online World Imagery",
+             "mobile": true,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -26,8 +26,8 @@
+             "description": "ArcGIS Online World Terrain Base",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=c61ad8ab017d49e1a82f580ee1298931'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=c61ad8ab017d49e1a82f580ee1298931'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -36,8 +36,8 @@
+             "description": "ArcGIS Online World Topography",
+             "mobile": true,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=30e5fe3149c34df1ba922e6f5bbf808f'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=30e5fe3149c34df1ba922e6f5bbf808f'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -46,8 +46,8 @@
+             "description": "This map presents land cover and detailed topographic maps for the United States.",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=99cd5fbd98934028802b4f797c4b1732'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=99cd5fbd98934028802b4f797c4b1732'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -56,8 +56,8 @@
+             "description": "National Geographic World Map",
+             "mobile": false,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=b9b1b422198944fbbd5250b3241691b6'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=b9b1b422198944fbbd5250b3241691b6'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -66,8 +66,8 @@
+             "description": "Thematic content providing a neutral background with minimal colors",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=ed712cb1db3e4bae9e85329040fb9a49'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=ed712cb1db3e4bae9e85329040fb9a49'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -76,8 +76,8 @@
+             "description": "Natural Earth physical map for the world",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=c4ec722a1cd34cf0a23904aadf8923a0'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=c4ec722a1cd34cf0a23904aadf8923a0'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -86,8 +86,8 @@
+             "description": "Portrays surface elevation as shaded relief",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=9c5370d0b54f4de1b48a3792d7377ff2'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=9c5370d0b54f4de1b48a3792d7377ff2'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -96,8 +96,8 @@
+             "description": "This map is designed to be used as a basemap by marine GIS professionals and as a reference map by anyone interested in ocean data",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=1e126e7520f9466c9ca28b8f28b5e500'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=1e126e7520f9466c9ca28b8f28b5e500'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -106,8 +106,8 @@
+             "description": "Thematic content providing a neutral background with minimal colors",
+             "mobile": false,
+             "night": true,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=a284a9b99b3446a3910d4144a50990f6'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=a284a9b99b3446a3910d4144a50990f6'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -116,8 +116,8 @@
+             "description": "DeLorme’s topographic basemap is a seamless global data set that portrays transportation, hydrography, jurisdiction boundaries, and major geographic features",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/Specialty/DeLorme_World_Base_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=b165c3df453e4be6b5ac4fdb241effbe'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/Specialty/DeLorme_World_Base_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=b165c3df453e4be6b5ac4fdb241effbe'>Esri</a> contributors"
+         }
+     ]
+ }
+diff --git a/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
+index 3858ddf5..af66f28e 100644
+--- a/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
+@@ -63,8 +63,10 @@ static const QString kCountriesKey(QStringLiteral("detailedCountries"));
+ static const QString kLocalizedNamesKey(QStringLiteral("localizedNames"));
+ static const QString kMaxLocationsKey(QStringLiteral("maxLocations"));
+ 
+-static const QUrl kUrlGeocodeServer("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer?f=pjson");
+-static const QUrl kUrlFindAddressCandidates("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates");
++static const QUrl kUrlGeocodeServer(
++        "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer?f=pjson");
++static const QUrl kUrlFindAddressCandidates("https://geocode.arcgis.com/arcgis/rest/services/World/"
++                                            "GeocodeServer/findAddressCandidates");
+ 
+ PlaceManagerEngineEsri::PlaceManagerEngineEsri(const QVariantMap &parameters, QGeoServiceProvider::Error *error,
+                                                QString *errorString) :
+Submodule qtmultimedia f0344079..0d7cc33a:
+diff --git a/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp b/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
+index 2b5325132..b68b4af1b 100644
+--- a/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
++++ b/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
+@@ -402,6 +402,8 @@ int QPulseAudioInput::bytesReady() const
+ 
+ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ {
++    Q_ASSERT(data != nullptr || len == 0);
++
+     m_bytesAvailable = checkBytesReady();
+ 
+     setError(QAudio::NoError);
+@@ -411,7 +413,8 @@ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ 
+     if (!m_pullMode && !m_tempBuffer.isEmpty()) {
+         readBytes = qMin(static_cast<int>(len), m_tempBuffer.size());
+-        memcpy(data, m_tempBuffer.constData(), readBytes);
++        if (readBytes)
++            memcpy(data, m_tempBuffer.constData(), readBytes);
+         m_totalTimeValue += readBytes;
+ 
+         if (readBytes < m_tempBuffer.size()) {
+@@ -502,9 +505,10 @@ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ 
+ void QPulseAudioInput::applyVolume(const void *src, void *dest, int len)
+ {
++    Q_ASSERT((src && dest) || len == 0);
+     if (m_volume < 1.f)
+         QAudioHelperInternal::qMultiplySamples(m_volume, m_format, src, dest, len);
+-    else
++    else if (len)
+         memcpy(dest, src, len);
+ }
+ 
+Submodule qtpim 02efef5e...f9a8f0fc (commits not present)
+Submodule qtquick3d b85cf622..47defc8b:
+diff --git a/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro b/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
+index ca5c499e..174a075b 100644
+--- a/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
++++ b/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
+@@ -10,7 +10,7 @@ QT_FOR_CONFIG += assetimporters-private
+ include($$OUT_PWD/../qtassetimporters-config.pri)
+ 
+ qtConfig(system-assimp):!if(cross_compile:host_build) {
+-    QMAKE_USE_PRIVATE += assimp
++    QMAKE_USE_PRIVATE += quick3d-assimp
+ } else {
+     include(../../../3rdparty/assimp/assimp.pri)
+ }
+Submodule qtquickcontrols2 3a657dc0..56ce8233:
+diff --git a/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp b/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
+index e5fe734f7..e36922775 100644
+--- a/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
++++ b/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
+@@ -38,6 +38,7 @@
+ #include "qwidgetplatformmenuitem_p.h"
+ 
+ #include <QtGui/qwindow.h>
++#include <QtGui/private/qhighdpiscaling_p.h>
+ #include <QtWidgets/qmenu.h>
+ #include <QtWidgets/qaction.h>
+ 
+@@ -145,7 +146,7 @@ void QWidgetPlatformMenu::showPopup(const QWindow *window, const QRect &targetRe
+ 
+     QPoint targetPos = targetRect.bottomLeft();
+     if (window)
+-        targetPos = window->mapToGlobal(targetPos);
++        targetPos = window->mapToGlobal(QHighDpi::fromNativeLocalPosition(targetPos, window));
+ 
+     const QWidgetPlatformMenuItem *widgetItem = qobject_cast<const QWidgetPlatformMenuItem *>(item);
+     m_menu->popup(targetPos, widgetItem ? widgetItem->action() : nullptr);
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
+index 950e4e099..b81fbea0b 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
+@@ -387,6 +387,17 @@ void QQuickAbstractButtonPrivate::itemImplicitHeightChanged(QQuickItem *item)
+         emit q->implicitIndicatorHeightChanged();
+ }
+ 
++void QQuickAbstractButtonPrivate::itemDestroyed(QQuickItem *item)
++{
++    Q_Q(QQuickAbstractButton);
++    QQuickControlPrivate::itemDestroyed(item);
++    if (item == indicator) {
++        indicator = nullptr;
++        emit q->implicitIndicatorWidthChanged();
++        emit q->implicitIndicatorHeightChanged();
++    }
++}
++
+ QQuickAbstractButton *QQuickAbstractButtonPrivate::findCheckedButton() const
+ {
+     Q_Q(const QQuickAbstractButton);
+@@ -1176,6 +1187,12 @@ QAccessible::Role QQuickAbstractButton::accessibleRole() const
+     }
+     return QAccessible::Button;
+ }
++
++void QQuickAbstractButton::accessiblePressAction()
++{
++    Q_D(QQuickAbstractButton);
++    d->trigger();
++}
+ #endif
+ 
+ QT_END_NAMESPACE
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
+index 0fa48980e..ab66220d0 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
+@@ -209,6 +209,7 @@ protected:
+ #if QT_CONFIG(accessibility)
+     void accessibilityActiveChanged(bool active) override;
+     QAccessible::Role accessibleRole() const override;
++    Q_INVOKABLE void accessiblePressAction();
+ #endif
+ 
+ private:
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
+index 9291c1a87..b729720f2 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
+@@ -109,6 +109,7 @@ public:
+ 
+     void itemImplicitWidthChanged(QQuickItem *item) override;
+     void itemImplicitHeightChanged(QQuickItem *item) override;
++    void itemDestroyed(QQuickItem *item) override;
+ 
+     // copied from qabstractbutton.cpp
+     static const int AUTO_REPEAT_DELAY = 300;
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp b/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
+index 2041e7741..8610cdfae 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
+@@ -145,7 +145,7 @@ int QQuickActionPrivate::ShortcutEntry::shortcutId() const
+ 
+ void QQuickActionPrivate::ShortcutEntry::grab(const QKeySequence &shortcut, bool enabled)
+ {
+-    if (shortcut.isEmpty())
++    if (shortcut.isEmpty() || m_shortcutId)
+         return;
+ 
+     Qt::ShortcutContext context = Qt::WindowShortcut; // TODO
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp b/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
+index f38c2b09c..6eed2a024 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
+@@ -225,6 +225,7 @@ void QQuickContainerPrivate::cleanup()
+     QObject::disconnect(contentModel, &QQmlObjectModel::countChanged, q, &QQuickContainer::countChanged);
+     QObject::disconnect(contentModel, &QQmlObjectModel::childrenChanged, q, &QQuickContainer::contentChildrenChanged);
+     delete contentModel;
++    contentModel = nullptr;
+ }
+ 
+ QQuickItem *QQuickContainerPrivate::itemAt(int index) const
+@@ -436,7 +437,7 @@ void QQuickContainerPrivate::contentChildren_clear(QQmlListProperty<QQuickItem>
+ void QQuickContainerPrivate::updateContentWidth()
+ {
+     Q_Q(QQuickContainer);
+-    if (hasContentWidth || qFuzzyCompare(contentWidth, implicitContentWidth))
++    if (hasContentWidth || qFuzzyCompare(contentWidth, implicitContentWidth) || !contentModel)
+         return;
+ 
+     contentWidth = implicitContentWidth;
+@@ -446,7 +447,7 @@ void QQuickContainerPrivate::updateContentWidth()
+ void QQuickContainerPrivate::updateContentHeight()
+ {
+     Q_Q(QQuickContainer);
+-    if (hasContentHeight || qFuzzyCompare(contentHeight, implicitContentHeight))
++    if (hasContentHeight || qFuzzyCompare(contentHeight, implicitContentHeight) || !contentModel)
+         return;
+ 
+     contentHeight = implicitContentHeight;
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp b/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
+index bbbd0e622..1f4b47343 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
+@@ -845,6 +845,13 @@ void QQuickControlPrivate::executeBackground(bool complete)
+         quickCompleteDeferred(q, backgroundName(), background);
+ }
+ 
++/*
++    \internal
++
++    Hides an item that was replaced by a newer one, rather than
++    deleting it, as the item is typically created in QML and hence
++    we don't own it.
++*/
+ void QQuickControlPrivate::hideOldItem(QQuickItem *item)
+ {
+     if (!item)
+@@ -863,6 +870,29 @@ void QQuickControlPrivate::hideOldItem(QQuickItem *item)
+ #endif
+ }
+ 
++/*
++    \internal
++
++    Named "unhide" because it's used for cases where an item
++    that was previously hidden by \l hideOldItem() wants to be
++    shown by a control again, such as a ScrollBar in ScrollView.
++*/
++void QQuickControlPrivate::unhideOldItem(QQuickControl *control, QQuickItem *item)
++{
++    Q_ASSERT(item);
++    qCDebug(lcItemManagement) << "unhiding old item" << item;
++
++    item->setVisible(true);
++    item->setParentItem(control);
++
++#if QT_CONFIG(accessibility)
++    // Add the item back in to the accessibility tree.
++    QQuickAccessibleAttached *accessible = accessibleAttached(item);
++    if (accessible)
++        accessible->setIgnored(false);
++#endif
++}
++
+ void QQuickControlPrivate::updateBaselineOffset()
+ {
+     Q_Q(QQuickControl);
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h b/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
+index 8e979079e..a6e624c91 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
+@@ -173,6 +173,7 @@ public:
+     virtual void executeBackground(bool complete = false);
+ 
+     static void hideOldItem(QQuickItem *item);
++    static void unhideOldItem(QQuickControl *control, QQuickItem *item);
+ 
+     void updateBaselineOffset();
+ 
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp b/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
+index e6db14eb5..6197d1547 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
+@@ -237,7 +237,7 @@ static QRectF alignedRect(Qt::LayoutDirection direction, Qt::Alignment alignment
+ void QQuickDialogButtonBoxPrivate::resizeContent()
+ {
+     Q_Q(QQuickDialogButtonBox);
+-    if (!contentItem)
++    if (!contentItem || !contentModel)
+         return;
+ 
+     QRectF geometry = q->boundingRect().adjusted(q->leftPadding(), q->topPadding(), -q->rightPadding(), -q->bottomPadding());
+@@ -322,6 +322,9 @@ void QQuickDialogButtonBoxPrivate::updateLayout()
+ qreal QQuickDialogButtonBoxPrivate::getContentWidth() const
+ {
+     Q_Q(const QQuickDialogButtonBox);
++    if (!contentModel)
++        return 0;
++
+     const int count = contentModel->count();
+     const qreal totalSpacing = qMax(0, count - 1) * spacing;
+     qreal totalWidth = totalSpacing;
+@@ -341,6 +344,9 @@ qreal QQuickDialogButtonBoxPrivate::getContentWidth() const
+ qreal QQuickDialogButtonBoxPrivate::getContentHeight() const
+ {
+     Q_Q(const QQuickDialogButtonBox);
++    if (!contentModel)
++        return 0;
++
+     const int count = contentModel->count();
+     qreal maxHeight = 0;
+     for (int i = 0; i < count; ++i) {
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp b/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
+index 91bd59184..0ce518f84 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
+@@ -399,8 +399,11 @@ void QQuickOverlay::itemChange(ItemChange change, const ItemChangeData &data)
+     Q_D(QQuickOverlay);
+     QQuickItem::itemChange(change, data);
+ 
+-    if (change == ItemChildAddedChange || change == ItemChildRemovedChange)
++    if (change == ItemChildAddedChange || change == ItemChildRemovedChange) {
+         setVisible(!d->allDrawers.isEmpty() || !childItems().isEmpty());
++        if (data.item->parent() == d->mouseGrabberPopup)
++            d->setMouseGrabberPopup(nullptr);
++    }
+ }
+ 
+ void QQuickOverlay::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp b/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
+index 4e2f509db..1c4b308cd 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
+@@ -797,6 +797,14 @@ void QQuickScrollBarAttachedPrivate::initHorizontal()
+     if (parent && parent == flickable->parentItem())
+         horizontal->stackAfter(flickable);
+ 
++    // If a scroll bar was previously hidden (due to e.g. setting a new contentItem
++    // on a ScrollView), we need to make sure that we un-hide it.
++    // We don't bother checking if the item is actually the old one, because
++    // if it's not, all of the things the function does (setting parent, visibility, etc.)
++    // should be no-ops anyway.
++    if (auto control = qobject_cast<QQuickControl*>(q_ptr->parent()))
++        QQuickControlPrivate::unhideOldItem(control, horizontal);
++
+     layoutHorizontal();
+     horizontal->setSize(area->property("widthRatio").toReal());
+     horizontal->setPosition(area->property("xPosition").toReal());
+@@ -818,6 +826,9 @@ void QQuickScrollBarAttachedPrivate::initVertical()
+     if (parent && parent == flickable->parentItem())
+         vertical->stackAfter(flickable);
+ 
++    if (auto control = qobject_cast<QQuickControl*>(q_ptr->parent()))
++        QQuickControlPrivate::unhideOldItem(control, vertical);
++
+     layoutVertical();
+     vertical->setSize(area->property("heightRatio").toReal());
+     vertical->setPosition(area->property("yPosition").toReal());
+diff --git a/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml b/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
+index 0e8b08352..cd4931184 100644
+--- a/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
++++ b/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
+@@ -576,4 +576,51 @@ TestCase {
+         verify(newHorizontalScrollBar.visible)
+         verify(!oldHorizontalScrollBar.visible)
+     }
++
++    Component {
++        id: bindingToContentItemAndStandaloneFlickable
++
++        Item {
++            width: 200
++            height: 200
++
++            property alias scrollView: scrollView
++
++            ScrollView {
++                id: scrollView
++                anchors.fill: parent
++                contentItem: listView
++
++                property Item someBinding: contentItem
++            }
++            ListView {
++                id: listView
++                model: 10
++                delegate: ItemDelegate {
++                    text: modelData
++                    width: listView.width
++                }
++            }
++        }
++    }
++
++    // Tests that scroll bars show up for a ScrollView where
++    // - its contentItem is declared as a standalone, separate item
++    // - there is a binding to contentItem (which causes a default Flickable to be created)
++    function test_bindingToContentItemAndStandaloneFlickable() {
++        let root = createTemporaryObject(bindingToContentItemAndStandaloneFlickable, testCase)
++        verify(root)
++
++        let control = root.scrollView
++        let verticalScrollBar = control.ScrollBar.vertical
++        let horizontalScrollBar = control.ScrollBar.horizontal
++        compare(verticalScrollBar.parent, control)
++        compare(horizontalScrollBar.parent, control)
++        verify(verticalScrollBar.visible)
++        verify(horizontalScrollBar.visible)
++
++        mouseDrag(verticalScrollBar, verticalScrollBar.width / 2, verticalScrollBar.height / 2, 0, 50)
++        verify(verticalScrollBar.active)
++        verify(horizontalScrollBar.active)
++    }
+ }
+diff --git a/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml b/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
+index b3fab41ca..10b6baa02 100644
+--- a/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
++++ b/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
+@@ -608,4 +608,27 @@ TestCase {
+         mouseClick(control.indicator)
+         verify(control.activeFocus)
+     }
++
++    Component {
++        id: deletionOrder1
++        Item {
++            Image { id: innerImage }
++            Switch { indicator: innerImage }
++        }
++    }
++
++    Component {
++        id: deletionOrder2
++        Item {
++            Switch { indicator: innerImage }
++            Image { id: innerImage }
++        }
++    }
++
++    function test_deletionOrder() {
++        var control1 = createTemporaryObject(deletionOrder1, testCase)
++        verify(control1)
++        var control2 = createTemporaryObject(deletionOrder2, testCase)
++        verify(control2)
++    }
+ }
+diff --git a/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml b/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml
+new file mode 100644
+index 000000000..9e4598b9f
+--- /dev/null
++++ b/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml
+@@ -0,0 +1,78 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the test suite of the Qt Toolkit.
++**
++** $QT_BEGIN_LICENSE:BSD$
++** Commercial License Usage
++** Licensees holding valid commercial Qt licenses may use this file in
++** accordance with the commercial license agreement provided with the
++** Software or, alternatively, in accordance with the terms contained in
++** a written agreement between you and The Qt Company. For licensing terms
++** and conditions see https://www.qt.io/terms-conditions. For further
++** information use the contact form at https://www.qt.io/contact-us.
++**
++** BSD License Usage
++** Alternatively, you may use this file under the terms of the BSD license
++** as follows:
++**
++** "Redistribution and use in source and binary forms, with or without
++** modification, are permitted provided that the following conditions are
++** met:
++**   * Redistributions of source code must retain the above copyright
++**     notice, this list of conditions and the following disclaimer.
++**   * Redistributions in binary form must reproduce the above copyright
++**     notice, this list of conditions and the following disclaimer in
++**     the documentation and/or other materials provided with the
++**     distribution.
++**   * Neither the name of The Qt Company Ltd nor the names of its
++**     contributors may be used to endorse or promote products derived
++**     from this software without specific prior written permission.
++**
++**
++** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
++** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
++** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
++** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
++** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
++** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
++** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
++** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
++** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
++** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
++** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
++**
++** $QT_END_LICENSE$
++**
++****************************************************************************/
++
++import QtQuick 2.15
++import QtQuick.Controls 2.15
++
++ApplicationWindow {
++    id: window
++    width: 400
++    height: 400
++    title: "releaseAfterExitTransition"
++
++    property alias popup: popup
++    property alias modalPopup: modalPopup
++
++    Popup {
++        id: popup
++        y: parent.height - height
++        width: 50
++        height: 50
++    }
++
++    Popup {
++        id: modalPopup
++        modal: true
++        y: parent.height - height
++        width: 50
++        height: 50
++        exit:  Transition { PauseAnimation { duration: 100 } }
++    }
++}
+diff --git a/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp b/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
+index 54952d128..3d50e2dd4 100644
+--- a/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
++++ b/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
+@@ -100,6 +100,7 @@ private slots:
+     void invisibleToolTipOpen();
+     void centerInOverlayWithinStackViewItem();
+     void destroyDuringExitTransition();
++    void releaseAfterExitTransition();
+ };
+ 
+ void tst_QQuickPopup::initTestCase()
+@@ -1575,6 +1576,34 @@ void tst_QQuickPopup::destroyDuringExitTransition()
+     QVERIFY(!button->isDown());
+ }
+ 
++void tst_QQuickPopup::releaseAfterExitTransition()
++{
++    QQuickApplicationHelper helper(this, "releaseAfterExitTransition.qml");
++    QVERIFY2(helper.ready, helper.failureMessage());
++
++    QQuickWindow *window = helper.window;
++    window->show();
++    QVERIFY(QTest::qWaitForWindowActive(window));
++
++    QQuickOverlay *overlay = QQuickOverlay::overlay(window);
++    QQuickPopup *modalPopup = window->property("modalPopup").value<QQuickPopup *>();
++    QQuickPopup *popup = window->property("popup").value<QQuickPopup *>();
++
++    modalPopup->open();
++    QTRY_VERIFY(modalPopup->isOpened());
++
++    QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++    // wait until the transition is finished and the overlay hides itself
++    QTRY_VERIFY(!overlay->isVisible());
++    QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++
++    popup->open();
++    QTRY_VERIFY(popup->isOpened());
++    QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++    QTRY_VERIFY(!popup->isOpened());
++}
++
++
+ QTEST_QUICKCONTROLS_MAIN(tst_QQuickPopup)
+ 
+ #include "tst_qquickpopup.moc"
+Submodule qtscript 5be95f96...4d8e4bd2 (commits not present)
+Submodule qtspeech 17fc9fde..255845e2:
+diff --git a/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp b/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
+index 6eb74b8..bcc7dd1 100644
+--- a/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
++++ b/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
+@@ -357,7 +357,9 @@ QVector<QLocale> QTextToSpeechEngineSpeechd::availableLocales() const
+ 
+ QVector<QVoice> QTextToSpeechEngineSpeechd::availableVoices() const
+ {
+-    return m_voices.values(m_currentLocale.name()).toVector();
++    QList<QVoice> resultList = m_voices.values(m_currentLocale.name());
++    std::reverse(resultList.begin(), resultList.end());
++    return resultList.toVector();
+ }
+ 
+ // We have no way of knowing our own client_id since speech-dispatcher seems to be incomplete
+Submodule qtsvg 0c05780e..a7a0f249:
+diff --git a/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp b/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
+index 561e77e..12e0574 100644
+--- a/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
++++ b/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
+@@ -191,6 +191,8 @@ bool QSvgIOHandler::read(QImage *image)
+             }
+         }
+         if (!finalSize.isEmpty()) {
++            if (qMax(finalSize.width(), finalSize.height()) > 0xffff)
++                return false; // Assume corrupted file
+             image->fill(d->backColor.rgba());
+             QPainter p(image);
+             d->r.render(&p, bounds);
+diff --git a/qtsvg/src/svg/qsvghandler.cpp b/qtsvg/src/svg/qsvghandler.cpp
+index a5f877f..8dda563 100644
+--- a/qtsvg/src/svg/qsvghandler.cpp
++++ b/qtsvg/src/svg/qsvghandler.cpp
+@@ -1393,9 +1393,10 @@ static void parseFont(QSvgNode *node,
+         case FontSizeNone:
+             break;
+         case FontSizeValue: {
+-            QSvgHandler::LengthType dummy; // should always be pixel size
+-            fontStyle->setSize(qMin(parseLength(attributes.fontSize, dummy, handler),
+-                                    qreal(0xffff)));
++            QSvgHandler::LengthType type;
++            qreal fs = parseLength(attributes.fontSize, type, handler);
++            fs = convertToPixels(fs, true, type);
++            fontStyle->setSize(qMin(fs, qreal(0xffff)));
+         }
+             break;
+         default:
+@@ -2513,6 +2514,8 @@ static bool parseAnimateTransformNode(QSvgNode *parent,
+             ++s;
+         }
+     }
++    if (vals.count() % 3 != 0)
++        return false;
+ 
+     bool ok = true;
+     int begin = parseClockValue(beginStr, &ok);
+@@ -2576,6 +2579,8 @@ static QSvgNode *createCircleNode(QSvgNode *parent,
+     qreal ncx = toDouble(cx);
+     qreal ncy = toDouble(cy);
+     qreal nr  = toDouble(r);
++    if (nr < 0.0)
++        return nullptr;
+ 
+     QRectF rect(ncx-nr, ncy-nr, nr*2, nr*2);
+     QSvgNode *circle = new QSvgCircle(parent, rect);
+@@ -3046,15 +3051,16 @@ static QSvgStyleProperty *createRadialGradientNode(QSvgNode *node,
+ 
+     qreal ncx = 0.5;
+     qreal ncy = 0.5;
+-    qreal nr  = 0.5;
+     if (!cx.isEmpty())
+         ncx = toDouble(cx);
+     if (!cy.isEmpty())
+         ncy = toDouble(cy);
++
++    qreal nr = 0.0;
+     if (!r.isEmpty())
+         nr = toDouble(r);
+-    if (nr < 0.5)
+-        nr = 0.5;
++    if (nr <= 0.0)
++        return nullptr;
+ 
+     qreal nfx = ncx;
+     if (!fx.isEmpty())
+@@ -3350,7 +3356,9 @@ static QSvgNode *createTextNode(QSvgNode *parent,
+     //### editable and rotate not handled
+     QSvgHandler::LengthType type;
+     qreal nx = parseLength(x, type, handler);
++    nx = convertToPixels(nx, true, type);
+     qreal ny = parseLength(y, type, handler);
++    ny = convertToPixels(ny, true, type);
+ 
+     QSvgNode *text = new QSvgText(parent, QPointF(nx, ny));
+     return text;
+@@ -3691,9 +3699,7 @@ void QSvgHandler::parse()
+         case QXmlStreamReader::EndElement:
+             endElement(xml->name());
+             ++remainingUnfinishedElements;
+-            // if we are using somebody else's qxmlstreamreader
+-            // we should not read until the end of the stream
+-            done = !m_ownsReader && (xml->name() == QLatin1String("svg"));
++            done = (xml->name() == QLatin1String("svg"));
+             break;
+         case QXmlStreamReader::Characters:
+             characters(xml->text());
+diff --git a/qtsvg/src/svg/qsvgstructure.cpp b/qtsvg/src/svg/qsvgstructure.cpp
+index b89608b..89c9e4e 100644
+--- a/qtsvg/src/svg/qsvgstructure.cpp
++++ b/qtsvg/src/svg/qsvgstructure.cpp
+@@ -255,9 +255,13 @@ inline static bool isSupportedSvgFeature(const QString &str)
+     };
+ 
+     if (str.length() <= MAX_WORD_LENGTH && str.length() >= MIN_WORD_LENGTH) {
++        const char16_t unicode44 = str.at(44).unicode();
++        const char16_t unicode45 = str.at(45).unicode();
++        if (unicode44 >= sizeof(asso_values) || unicode45 >= sizeof(asso_values))
++            return false;
+         const int key = str.length()
+-                        + asso_values[str.at(45).unicode()]
+-                        + asso_values[str.at(44).unicode()];
++                        + asso_values[unicode45]
++                        + asso_values[unicode44];
+         if (key <= MAX_HASH_VALUE && key >= 0)
+             return str == QLatin1String(wordlist[key]);
+     }
+diff --git a/qtsvg/src/svg/qsvgtinydocument.cpp b/qtsvg/src/svg/qsvgtinydocument.cpp
+index 63d0797..19e7154 100644
+--- a/qtsvg/src/svg/qsvgtinydocument.cpp
++++ b/qtsvg/src/svg/qsvgtinydocument.cpp
+@@ -433,8 +433,16 @@ void QSvgTinyDocument::draw(QPainter *p, QSvgExtraStates &)
+     draw(p);
+ }
+ 
++static bool isValidMatrix(const QTransform &transform)
++{
++    qreal determinant = transform.determinant();
++    return qIsFinite(determinant);
++}
++
+ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect, const QRectF &sourceRect)
+ {
++    QTransform oldTransform = p->worldTransform();
++
+     QRectF target = targetRect;
+     if (target.isEmpty()) {
+         QPaintDevice *dev = p->device();
+@@ -487,6 +495,9 @@ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect,
+         }
+ #endif
+     }
++
++    if (!isValidMatrix(p->worldTransform()))
++        p->setWorldTransform(oldTransform);
+ }
+ 
+ QRectF QSvgTinyDocument::boundsOnElement(const QString &id) const
+diff --git a/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp b/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
+index 36c76ec..db71e02 100644
+--- a/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
++++ b/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
+@@ -86,6 +86,8 @@ private slots:
+     void oss_fuzz_23731();
+     void oss_fuzz_24131();
+     void oss_fuzz_24738();
++    void illegalAnimateTransform_data();
++    void illegalAnimateTransform();
+ 
+ #ifndef QT_NO_COMPRESS
+     void testGzLoading();
+@@ -1646,5 +1648,22 @@ void tst_QSvgRenderer::oss_fuzz_24738()
+     QSvgRenderer().load(QByteArray("<svg><path d=\"a 2 1e-212.....\">"));
+ }
+ 
++void tst_QSvgRenderer::illegalAnimateTransform_data()
++{
++    QTest::addColumn<QByteArray>("svg");
++
++    QTest::newRow("case1") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" values=\"8,0,5,0\">");
++    QTest::newRow("case2") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" values=\"1,2\">");
++    QTest::newRow("case3") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" from=\".. 5 2\" to=\"f\">");
++    QTest::newRow("case4") << QByteArray("<svg><animateTransform type=\"scale\" begin=\"1\" dur=\"2\" by=\"--,..\">");
++}
++
++void tst_QSvgRenderer::illegalAnimateTransform()
++{
++    QFETCH(QByteArray, svg);
++    QSvgRenderer renderer;
++    QVERIFY(!renderer.load(svg)); // also shouldn't assert
++}
++
+ QTEST_MAIN(tst_QSvgRenderer)
+ #include "tst_qsvgrenderer.moc"
+Submodule qttools 6914f7c8..090e526e:
+diff --git a/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp b/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
+index feab1e2d5..cbfb82507 100644
+--- a/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
++++ b/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
+@@ -445,7 +445,9 @@ bool HelpGeneratorPrivate::insertFiles(const QStringList &files, const QString &
+     if (filterSetId < 0)
+         return false;
+     ++filterSetId;
+-    for (int attId : qAsConst(filterAtts)) {
++    QList<int> attValues = filterAtts.values();
++    std::sort(attValues.begin(), attValues.end());
++    for (int attId : qAsConst(attValues)) {
+         m_query->prepare(QLatin1String("INSERT INTO FileAttributeSetTable "
+             "VALUES(?, ?)"));
+         m_query->bindValue(0, filterSetId);
+Submodule qtwayland dfb0129c..2904e1b3:
+diff --git a/qtwayland/src/client/configure.json b/qtwayland/src/client/configure.json
+index 2f424580..29222357 100644
+--- a/qtwayland/src/client/configure.json
++++ b/qtwayland/src/client/configure.json
+@@ -149,8 +149,7 @@
+                     "#endif"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "vulkan-server-buffer": {
+             "label": "Vulkan Buffer Sharing",
+@@ -168,7 +167,8 @@
+                     "exportAllocInfo.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR;",
+                     "return 0;"
+                 ]
+-            }
++            },
++            "use": "wayland-client"
+         },
+         "egl_1_5-wayland": {
+             "label": "EGL 1.5 with Wayland Platform",
+@@ -183,7 +183,7 @@
+                     "eglGetPlatformDisplay(EGL_PLATFORM_WAYLAND_EXT, (struct wl_display *)(nullptr), nullptr);"
+                 ]
+             },
+-            "use": "egl"
++            "use": "egl wayland-client"
+         }
+     },
+ 
+diff --git a/qtwayland/src/client/global/qwaylandclientextension.cpp b/qtwayland/src/client/global/qwaylandclientextension.cpp
+index 125b1e19..edccfe63 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension.cpp
++++ b/qtwayland/src/client/global/qwaylandclientextension.cpp
+@@ -74,7 +74,10 @@ void QWaylandClientExtensionPrivate::handleRegistryGlobal(void *data, ::wl_regis
+ void QWaylandClientExtension::addRegistryListener()
+ {
+     Q_D(QWaylandClientExtension);
+-    d->waylandIntegration->display()->addRegistryListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++    if (!d->registered) {
++        d->waylandIntegration->display()->addRegistryListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++        d->registered = true;
++    }
+ }
+ 
+ QWaylandClientExtension::QWaylandClientExtension(const int ver)
+@@ -88,6 +91,13 @@ QWaylandClientExtension::QWaylandClientExtension(const int ver)
+     QMetaObject::invokeMethod(this, "addRegistryListener", Qt::QueuedConnection);
+ }
+ 
++QWaylandClientExtension::~QWaylandClientExtension()
++{
++    Q_D(QWaylandClientExtension);
++    if (d->registered && !QCoreApplication::closingDown())
++        d->waylandIntegration->display()->removeListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++}
++
+ QtWaylandClient::QWaylandIntegration *QWaylandClientExtension::integration() const
+ {
+     Q_D(const QWaylandClientExtension);
+diff --git a/qtwayland/src/client/global/qwaylandclientextension.h b/qtwayland/src/client/global/qwaylandclientextension.h
+index 98272e57..5bd28398 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension.h
++++ b/qtwayland/src/client/global/qwaylandclientextension.h
+@@ -63,6 +63,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandClientExtension : public QObject
+     Q_PROPERTY(bool active READ isActive NOTIFY activeChanged)
+ public:
+     QWaylandClientExtension(const int version);
++    ~QWaylandClientExtension();
+ 
+     QtWaylandClient::QWaylandIntegration *integration() const;
+     int version() const;
+diff --git a/qtwayland/src/client/global/qwaylandclientextension_p.h b/qtwayland/src/client/global/qwaylandclientextension_p.h
+index 69cc46a0..9091efbe 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension_p.h
++++ b/qtwayland/src/client/global/qwaylandclientextension_p.h
+@@ -68,6 +68,7 @@ public:
+     QtWaylandClient::QWaylandIntegration *waylandIntegration = nullptr;
+     int version = -1;
+     bool active = false;
++    bool registered = false;
+ };
+ 
+ class Q_WAYLAND_CLIENT_EXPORT QWaylandClientExtensionTemplatePrivate : public QWaylandClientExtensionPrivate
+diff --git a/qtwayland/src/client/qwaylanddatadevice.cpp b/qtwayland/src/client/qwaylanddatadevice.cpp
+index 7e2e3308..e3e60ed5 100644
+--- a/qtwayland/src/client/qwaylanddatadevice.cpp
++++ b/qtwayland/src/client/qwaylanddatadevice.cpp
+@@ -72,6 +72,8 @@ QWaylandDataDevice::QWaylandDataDevice(QWaylandDataDeviceManager *manager, QWayl
+ 
+ QWaylandDataDevice::~QWaylandDataDevice()
+ {
++    if (wl_data_device_get_version(object()) >= WL_DATA_DEVICE_RELEASE_SINCE_VERSION)
++        release();
+ }
+ 
+ QWaylandDataOffer *QWaylandDataDevice::selectionOffer() const
+@@ -110,7 +112,7 @@ QWaylandDataOffer *QWaylandDataDevice::dragOffer() const
+     return m_dragOffer.data();
+ }
+ 
+-bool QWaylandDataDevice::startDrag(QMimeData *mimeData, QWaylandWindow *icon)
++bool QWaylandDataDevice::startDrag(QMimeData *mimeData, Qt::DropActions supportedActions, QWaylandWindow *icon)
+ {
+     auto *seat = m_display->currentInputDevice();
+     auto *origin = seat->pointerFocus();
+@@ -123,7 +125,28 @@ bool QWaylandDataDevice::startDrag(QMimeData *mimeData, QWaylandWindow *icon)
+     }
+ 
+     m_dragSource.reset(new QWaylandDataSource(m_display->dndSelectionHandler(), mimeData));
++
++    if (wl_data_device_get_version(object()) >= 3)
++        m_dragSource->set_actions(dropActionsToWl(supportedActions));
++
+     connect(m_dragSource.data(), &QWaylandDataSource::cancelled, this, &QWaylandDataDevice::dragSourceCancelled);
++    connect(m_dragSource.data(), &QWaylandDataSource::dndResponseUpdated, this, [this](bool accepted, Qt::DropAction action) {
++            auto drag = static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag());
++            // in old versions drop action is not set, so we guess
++            if (wl_data_source_get_version(m_dragSource->object()) < 3) {
++                drag->setResponse(accepted);
++            } else {
++                QPlatformDropQtResponse response(accepted, action);
++                drag->setResponse(response);
++            }
++    });
++    connect(m_dragSource.data(), &QWaylandDataSource::dndDropped, this, [](bool accepted, Qt::DropAction action) {
++        QPlatformDropQtResponse response(accepted, action);
++        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setDropResponse(response);
++    });
++    connect(m_dragSource.data(), &QWaylandDataSource::finished, this, []() {
++        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag();
++    });
+ 
+     start_drag(m_dragSource->object(), origin->wlSurface(), icon->wlSurface(), m_display->currentInputDevice()->serial());
+     return true;
+@@ -152,7 +175,7 @@ void QWaylandDataDevice::data_device_drop()
+         supportedActions = drag->supportedActions();
+     } else if (m_dragOffer) {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     } else {
+         return;
+     }
+@@ -162,7 +185,11 @@ void QWaylandDataDevice::data_device_drop()
+                                                                           QGuiApplication::keyboardModifiers());
+ 
+     if (drag) {
+-        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag(response);
++        auto drag =  static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag());
++        drag->setDropResponse(response);
++        drag->finishDrag();
++    } else if (m_dragOffer) {
++        m_dragOffer->finish();
+     }
+ }
+ 
+@@ -186,7 +213,7 @@ void QWaylandDataDevice::data_device_enter(uint32_t serial, wl_surface *surface,
+         supportedActions = drag->supportedActions();
+     } else if (m_dragOffer) {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     }
+ 
+     const QPlatformDragQtResponse &response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
+@@ -197,11 +224,7 @@ void QWaylandDataDevice::data_device_enter(uint32_t serial, wl_surface *surface,
+         static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setResponse(response);
+     }
+ 
+-    if (response.isAccepted()) {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, m_dragOffer->firstFormat().toUtf8().constData());
+-    } else {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, nullptr);
+-    }
++    sendResponse(supportedActions, response);
+ }
+ 
+ void QWaylandDataDevice::data_device_leave()
+@@ -235,10 +258,10 @@ void QWaylandDataDevice::data_device_motion(uint32_t time, wl_fixed_t x, wl_fixe
+         supportedActions = drag->supportedActions();
+     } else {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     }
+ 
+-    QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
++    const QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
+                                                                           QGuiApplication::mouseButtons(),
+                                                                           QGuiApplication::keyboardModifiers());
+ 
+@@ -246,11 +269,7 @@ void QWaylandDataDevice::data_device_motion(uint32_t time, wl_fixed_t x, wl_fixe
+         static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setResponse(response);
+     }
+ 
+-    if (response.isAccepted()) {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, m_dragOffer->firstFormat().toUtf8().constData());
+-    } else {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, nullptr);
+-    }
++    sendResponse(supportedActions, response);
+ }
+ #endif // QT_CONFIG(draganddrop)
+ 
+@@ -277,14 +296,10 @@ void QWaylandDataDevice::selectionSourceCancelled()
+ #if QT_CONFIG(draganddrop)
+ void QWaylandDataDevice::dragSourceCancelled()
+ {
++    static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag();
+     m_dragSource.reset();
+ }
+ 
+-void QWaylandDataDevice::dragSourceTargetChanged(const QString &mimeType)
+-{
+-    static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->updateTarget(mimeType);
+-}
+-
+ QPoint QWaylandDataDevice::calculateDragPosition(int x, int y, QWindow *wnd) const
+ {
+     QPoint pnt(wl_fixed_to_int(x), wl_fixed_to_int(y));
+@@ -297,6 +312,33 @@ QPoint QWaylandDataDevice::calculateDragPosition(int x, int y, QWindow *wnd) con
+     }
+     return pnt;
+ }
++
++void QWaylandDataDevice::sendResponse(Qt::DropActions supportedActions, const QPlatformDragQtResponse &response)
++{
++    if (response.isAccepted()) {
++        if (wl_data_device_get_version(object()) >= 3)
++            m_dragOffer->set_actions(dropActionsToWl(supportedActions), dropActionsToWl(response.acceptedAction()));
++
++        m_dragOffer->accept(m_enterSerial, m_dragOffer->firstFormat());
++    } else {
++        m_dragOffer->accept(m_enterSerial, QString());
++    }
++}
++
++int QWaylandDataDevice::dropActionsToWl(Qt::DropActions actions)
++{
++
++    int wlActions = WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE;
++    if (actions & Qt::CopyAction)
++        wlActions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY;
++    if (actions & (Qt::MoveAction | Qt::TargetMoveAction))
++        wlActions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE;
++
++    // wayland does not support LinkAction at the time of writing
++    return wlActions;
++}
++
++
+ #endif // QT_CONFIG(draganddrop)
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddatadevice_p.h b/qtwayland/src/client/qwaylanddatadevice_p.h
+index 16c3ad28..801dcc2c 100644
+--- a/qtwayland/src/client/qwaylanddatadevice_p.h
++++ b/qtwayland/src/client/qwaylanddatadevice_p.h
+@@ -64,6 +64,7 @@ QT_REQUIRE_CONFIG(wayland_datadevice);
+ QT_BEGIN_NAMESPACE
+ 
+ class QMimeData;
++class QPlatformDragQtResponse;
+ class QWindow;
+ 
+ namespace QtWaylandClient {
+@@ -89,7 +90,7 @@ public:
+ 
+ #if QT_CONFIG(draganddrop)
+     QWaylandDataOffer *dragOffer() const;
+-    bool startDrag(QMimeData *mimeData, QWaylandWindow *icon);
++    bool startDrag(QMimeData *mimeData, Qt::DropActions supportedActions, QWaylandWindow *icon);
+     void cancelDrag();
+ #endif
+ 
+@@ -109,13 +110,16 @@ private Q_SLOTS:
+ 
+ #if QT_CONFIG(draganddrop)
+     void dragSourceCancelled();
+-    void dragSourceTargetChanged(const QString &mimeType);
+ #endif
+ 
+ private:
+ #if QT_CONFIG(draganddrop)
+     QPoint calculateDragPosition(int x, int y, QWindow *wnd) const;
+ #endif
++    void sendResponse(Qt::DropActions supportedActions, const QPlatformDragQtResponse &response);
++
++    static int dropActionsToWl(Qt::DropActions dropActions);
++
+ 
+     QWaylandDisplay *m_display = nullptr;
+     QWaylandInputDevice *m_inputDevice = nullptr;
+diff --git a/qtwayland/src/client/qwaylanddatadevicemanager.cpp b/qtwayland/src/client/qwaylanddatadevicemanager.cpp
+index 35d67307..6dc4f77f 100644
+--- a/qtwayland/src/client/qwaylanddatadevicemanager.cpp
++++ b/qtwayland/src/client/qwaylanddatadevicemanager.cpp
+@@ -50,8 +50,8 @@ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
+-QWaylandDataDeviceManager::QWaylandDataDeviceManager(QWaylandDisplay *display, uint32_t id)
+-    : wl_data_device_manager(display->wl_registry(), id, 1)
++QWaylandDataDeviceManager::QWaylandDataDeviceManager(QWaylandDisplay *display, int version, uint32_t id)
++    : wl_data_device_manager(display->wl_registry(), id, qMin(version, 3))
+     , m_display(display)
+ {
+     // Create transfer devices for all input devices.
+diff --git a/qtwayland/src/client/qwaylanddatadevicemanager_p.h b/qtwayland/src/client/qwaylanddatadevicemanager_p.h
+index bd05c0fb..510d9be4 100644
+--- a/qtwayland/src/client/qwaylanddatadevicemanager_p.h
++++ b/qtwayland/src/client/qwaylanddatadevicemanager_p.h
+@@ -68,7 +68,7 @@ class QWaylandInputDevice;
+ class Q_WAYLAND_CLIENT_EXPORT QWaylandDataDeviceManager : public QtWayland::wl_data_device_manager
+ {
+ public:
+-    QWaylandDataDeviceManager(QWaylandDisplay *display, uint32_t id);
++    QWaylandDataDeviceManager(QWaylandDisplay *display, int version, uint32_t id);
+     ~QWaylandDataDeviceManager() override;
+ 
+     QWaylandDataDevice *getDataDevice(QWaylandInputDevice *inputDevice);
+diff --git a/qtwayland/src/client/qwaylanddataoffer.cpp b/qtwayland/src/client/qwaylanddataoffer.cpp
+index 2297e8a1..fe0ea8c9 100644
+--- a/qtwayland/src/client/qwaylanddataoffer.cpp
++++ b/qtwayland/src/client/qwaylanddataoffer.cpp
+@@ -82,6 +82,15 @@ QMimeData *QWaylandDataOffer::mimeData()
+     return m_mimeData.data();
+ }
+ 
++Qt::DropActions QWaylandDataOffer::supportedActions() const
++{
++    if (wl_data_offer_get_version(const_cast<::wl_data_offer*>(object())) < 3) {
++        return Qt::MoveAction | Qt::CopyAction;
++    }
++
++    return m_supportedActions;
++}
++
+ void QWaylandDataOffer::startReceiving(const QString &mimeType, int fd)
+ {
+     receive(mimeType, fd);
+@@ -93,6 +102,22 @@ void QWaylandDataOffer::data_offer_offer(const QString &mime_type)
+     m_mimeData->appendFormat(mime_type);
+ }
+ 
++void QWaylandDataOffer::data_offer_action(uint32_t dnd_action)
++{
++    Q_UNUSED(dnd_action);
++    // This is the compositor telling the drag target what action it should perform
++    // It does not map nicely into Qt final drop semantics, other than pretending there is only one supported action?
++}
++
++void QWaylandDataOffer::data_offer_source_actions(uint32_t source_actions)
++{
++    m_supportedActions = Qt::DropActions();
++    if (source_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
++        m_supportedActions |= Qt::MoveAction;
++    if (source_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
++        m_supportedActions |= Qt::CopyAction;
++}
++
+ QWaylandMimeData::QWaylandMimeData(QWaylandAbstractDataOffer *dataOffer)
+     : m_dataOffer(dataOffer)
+ {
+@@ -163,17 +188,18 @@ QVariant QWaylandMimeData::retrieveData_sys(const QString &mimeType, QVariant::T
+ 
+ int QWaylandMimeData::readData(int fd, QByteArray &data) const
+ {
+-    fd_set readset;
+-    FD_ZERO(&readset);
+-    FD_SET(fd, &readset);
+-    struct timeval timeout;
++    struct pollfd readset;
++    readset.fd = fd;
++    readset.events = POLLIN;
++    struct timespec timeout;
+     timeout.tv_sec = 1;
+-    timeout.tv_usec = 0;
++    timeout.tv_nsec = 0;
++
+ 
+     Q_FOREVER {
+-        int ready = select(FD_SETSIZE, &readset, nullptr, nullptr, &timeout);
++        int ready = qt_safe_poll(&readset, 1, &timeout);
+         if (ready < 0) {
+-            qWarning() << "QWaylandDataOffer: select() failed";
++            qWarning() << "QWaylandDataOffer: qt_safe_poll() failed";
+             return -1;
+         } else if (ready == 0) {
+             qWarning("QWaylandDataOffer: timeout reading from pipe");
+diff --git a/qtwayland/src/client/qwaylanddataoffer_p.h b/qtwayland/src/client/qwaylanddataoffer_p.h
+index 9cf1483c..6f667398 100644
+--- a/qtwayland/src/client/qwaylanddataoffer_p.h
++++ b/qtwayland/src/client/qwaylanddataoffer_p.h
+@@ -82,6 +82,7 @@ public:
+     explicit QWaylandDataOffer(QWaylandDisplay *display, struct ::wl_data_offer *offer);
+     ~QWaylandDataOffer() override;
+     QMimeData *mimeData() override;
++    Qt::DropActions supportedActions() const;
+ 
+     QString firstFormat() const;
+ 
+@@ -89,10 +90,13 @@ public:
+ 
+ protected:
+     void data_offer_offer(const QString &mime_type) override;
++    void data_offer_source_actions(uint32_t source_actions) override;
++    void data_offer_action(uint32_t dnd_action) override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+     QScopedPointer<QWaylandMimeData> m_mimeData;
++    Qt::DropActions m_supportedActions;
+ };
+ 
+ 
+diff --git a/qtwayland/src/client/qwaylanddatasource.cpp b/qtwayland/src/client/qwaylanddatasource.cpp
+index f45122fb..5599cbd4 100644
+--- a/qtwayland/src/client/qwaylanddatasource.cpp
++++ b/qtwayland/src/client/qwaylanddatasource.cpp
+@@ -101,7 +101,32 @@ void QWaylandDataSource::data_source_send(const QString &mime_type, int32_t fd)
+ 
+ void QWaylandDataSource::data_source_target(const QString &mime_type)
+ {
+-    Q_EMIT targetChanged(mime_type);
++    m_accepted = !mime_type.isEmpty();
++    Q_EMIT dndResponseUpdated(m_accepted, m_dropAction);
++}
++
++void QWaylandDataSource::data_source_action(uint32_t action)
++{
++    Qt::DropAction qtAction = Qt::IgnoreAction;
++
++    if (action == WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
++        qtAction = Qt::MoveAction;
++    else if (action == WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
++        qtAction = Qt::CopyAction;
++
++    m_dropAction = qtAction;
++    Q_EMIT dndResponseUpdated(m_accepted, m_dropAction);
++}
++
++void QWaylandDataSource::data_source_dnd_finished()
++{
++    Q_EMIT finished();
++}
++
++void QWaylandDataSource::data_source_dnd_drop_performed()
++{
++
++    Q_EMIT dndDropped(m_accepted, m_dropAction);
+ }
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddatasource_p.h b/qtwayland/src/client/qwaylanddatasource_p.h
+index 25afff79..96f07bc3 100644
+--- a/qtwayland/src/client/qwaylanddatasource_p.h
++++ b/qtwayland/src/client/qwaylanddatasource_p.h
+@@ -77,17 +77,25 @@ public:
+     QMimeData *mimeData() const;
+ 
+ Q_SIGNALS:
+-    void targetChanged(const QString &mime_type);
+     void cancelled();
++    void finished();
++
++    void dndResponseUpdated(bool accepted, Qt::DropAction action);
++    void dndDropped(bool accepted, Qt::DropAction action);
+ 
+ protected:
+     void data_source_cancelled() override;
+     void data_source_send(const QString &mime_type, int32_t fd) override;
+     void data_source_target(const QString &mime_type) override;
++    void data_source_dnd_drop_performed() override;
++    void data_source_dnd_finished() override;
++    void data_source_action(uint32_t action) override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+     QMimeData *m_mime_data = nullptr;
++    bool m_accepted = false;
++    Qt::DropAction m_dropAction = Qt::IgnoreAction;
+ };
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddisplay.cpp b/qtwayland/src/client/qwaylanddisplay.cpp
+index f10c1f79..c01e238b 100644
+--- a/qtwayland/src/client/qwaylanddisplay.cpp
++++ b/qtwayland/src/client/qwaylanddisplay.cpp
+@@ -85,10 +85,203 @@
+ 
+ #include <errno.h>
+ 
++#include <tuple> // for std::tie
++
++static void checkWaylandError(struct wl_display *display)
++{
++    int ecode = wl_display_get_error(display);
++    if ((ecode == EPIPE || ecode == ECONNRESET)) {
++        // special case this to provide a nicer error
++        qWarning("The Wayland connection broke. Did the Wayland compositor die?");
++    } else {
++        qWarning("The Wayland connection experienced a fatal error: %s", strerror(ecode));
++    }
++    _exit(1);
++}
++
+ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
++class EventThread : public QThread
++{
++    Q_OBJECT
++public:
++    enum OperatingMode {
++        EmitToDispatch, // Emit the signal, allow dispatching in a differnt thread.
++        SelfDispatch, // Dispatch the events inside this thread.
++    };
++
++    EventThread(struct wl_display * wl, struct wl_event_queue * ev_queue,
++                OperatingMode mode)
++        : m_fd(wl_display_get_fd(wl))
++        , m_pipefd{ -1, -1 }
++        , m_wldisplay(wl)
++        , m_wlevqueue(ev_queue)
++        , m_mode(mode)
++        , m_reading(true)
++        , m_quitting(false)
++    {
++        setObjectName(QStringLiteral("WaylandEventThread"));
++    }
++
++    void readAndDispatchEvents()
++    {
++        /*
++         * Dispatch pending events and flush the requests at least once. If the event thread
++         * is not reading, try to call _prepare_read() to allow the event thread to poll().
++         * If that fails, re-try dispatch & flush again until _prepare_read() is successful.
++         *
++         * This allow any call to readAndDispatchEvents() to start event thread's polling,
++         * not only the one issued from event thread's waitForReading(), which means functions
++         * called from dispatch_pending() can safely spin an event loop.
++         */
++        for (;;) {
++            if (dispatchQueuePending() < 0) {
++                checkWaylandError(m_wldisplay);
++                return;
++            }
++
++            wl_display_flush(m_wldisplay);
++
++            // We have to check if event thread is reading every time we dispatch
++            // something, as that may recursively call this function.
++            if (m_reading.loadAcquire())
++                break;
++
++            if (prepareReadQueue() == 0) {
++                QMutexLocker l(&m_mutex);
++                m_reading.storeRelease(true);
++                m_cond.wakeOne();
++                break;
++            }
++        }
++    }
++
++    void stop()
++    {
++        // We have to both write to the pipe and set the flag, as the thread may be
++        // either in the poll() or waiting for _prepare_read().
++        if (m_pipefd[1] != -1 && write(m_pipefd[1], "\0", 1) == -1)
++            qWarning("Failed to write to the pipe: %s.", strerror(errno));
++
++        {
++            QMutexLocker l(&m_mutex);
++            m_quitting = true;
++            m_cond.wakeOne();
++        }
++
++        wait();
++    }
++
++Q_SIGNALS:
++    void needReadAndDispatch();
++
++protected:
++    void run() override
++    {
++        // we use this pipe to make the loop exit otherwise if we simply used a flag on the loop condition, if stop() gets
++        // called while poll() is blocking the thread will never quit since there are no wayland messages coming anymore.
++        struct Pipe
++        {
++            Pipe(int *fds)
++                : fds(fds)
++            {
++                if (qt_safe_pipe(fds) != 0)
++                    qWarning("Pipe creation failed. Quitting may hang.");
++            }
++            ~Pipe()
++            {
++                if (fds[0] != -1) {
++                    close(fds[0]);
++                    close(fds[1]);
++                }
++            }
++
++            int *fds;
++        } pipe(m_pipefd);
++
++        // Make the main thread call wl_prepare_read(), dispatch the pending messages and flush the
++        // outbound ones. Wait until it's done before proceeding, unless we're told to quit.
++        while (waitForReading()) {
++            pollfd fds[2] = { { m_fd, POLLIN, 0 }, { m_pipefd[0], POLLIN, 0 } };
++            poll(fds, 2, -1);
++
++            if (fds[1].revents & POLLIN) {
++                // we don't really care to read the byte that was written here since we're closing down
++                wl_display_cancel_read(m_wldisplay);
++                break;
++            }
++
++            if (fds[0].revents & POLLIN)
++                wl_display_read_events(m_wldisplay);
++                // The polll was succesfull and the event thread did the wl_display_read_events(). On the next iteration of the loop
++                // the event sent to the main thread will cause it to dispatch the messages just read, unless the loop exits in which
++                // case we don't care anymore about them.
++            else
++                wl_display_cancel_read(m_wldisplay);
++        }
++    }
++
++private:
++    bool waitForReading()
++    {
++        Q_ASSERT(QThread::currentThread() == this);
++
++        m_reading.storeRelease(false);
++
++        if (m_mode == SelfDispatch) {
++            readAndDispatchEvents();
++        } else {
++            Q_EMIT needReadAndDispatch();
++
++            QMutexLocker lock(&m_mutex);
++            // m_reading might be set from our emit or some other invocation of
++            // readAndDispatchEvents().
++            while (!m_reading.loadRelaxed() && !m_quitting)
++                m_cond.wait(&m_mutex);
++        }
++
++        return !m_quitting;
++    }
++
++    int dispatchQueuePending()
++    {
++        if (m_wlevqueue)
++            return wl_display_dispatch_queue_pending(m_wldisplay, m_wlevqueue);
++        else
++            return wl_display_dispatch_pending(m_wldisplay);
++    }
++
++    int prepareReadQueue()
++    {
++        if (m_wlevqueue)
++            return wl_display_prepare_read_queue(m_wldisplay, m_wlevqueue);
++        else
++            return wl_display_prepare_read(m_wldisplay);
++    }
++
++    int m_fd;
++    int m_pipefd[2];
++    wl_display *m_wldisplay;
++    wl_event_queue *m_wlevqueue;
++    OperatingMode m_mode;
++
++    /* Concurrency note when operating in EmitToDispatch mode:
++     * m_reading is set to false inside event thread's waitForReading(), and is
++     * set to true inside main thread's readAndDispatchEvents().
++     * The lock is not taken when setting m_reading to false, as the main thread
++     * is not actively waiting for it to turn false. However, the lock is taken
++     * inside readAndDispatchEvents() before setting m_reading to true,
++     * as the event thread is actively waiting for it under the wait condition.
++     */
++
++    QAtomicInteger<bool> m_reading;
++    bool m_quitting;
++    QMutex m_mutex;
++    QWaitCondition m_cond;
++};
++
+ Q_LOGGING_CATEGORY(lcQpaWayland, "qt.qpa.wayland"); // for general (uncategorized) Wayland platform logging
+ 
+ struct wl_surface *QWaylandDisplay::createSurface(void *handle)
+@@ -158,17 +351,16 @@ QWaylandDisplay::QWaylandDisplay(QWaylandIntegration *waylandIntegration)
+     if (!mXkbContext)
+         qCWarning(lcQpaWayland, "failed to create xkb context");
+ #endif
+-
+-    forceRoundTrip();
+-
+-    if (!mWaitingScreens.isEmpty()) {
+-        // Give wl_output.done and zxdg_output_v1.done events a chance to arrive
+-        forceRoundTrip();
+-    }
+ }
+ 
+ QWaylandDisplay::~QWaylandDisplay(void)
+ {
++    if (m_eventThread)
++        m_eventThread->stop();
++
++    if (m_frameEventQueueThread)
++        m_frameEventQueueThread->stop();
++
+     if (mSyncCallback)
+         wl_callback_destroy(mSyncCallback);
+ 
+@@ -187,6 +379,21 @@ QWaylandDisplay::~QWaylandDisplay(void)
+ #endif
+     if (mDisplay)
+         wl_display_disconnect(mDisplay);
++
++    if (m_frameEventQueue)
++        wl_event_queue_destroy(m_frameEventQueue);
++}
++
++// Steps which is called just after constructor. This separates registry_global() out of the constructor
++// so that factory functions in integration can be overridden.
++void QWaylandDisplay::initialize()
++{
++    forceRoundTrip();
++
++    if (!mWaitingScreens.isEmpty()) {
++        // Give wl_output.done and zxdg_output_v1.done events a chance to arrive
++        forceRoundTrip();
++    }
+ }
+ 
+ void QWaylandDisplay::ensureScreen()
+@@ -203,98 +410,37 @@ void QWaylandDisplay::ensureScreen()
+ 
+ void QWaylandDisplay::checkError() const
+ {
+-    int ecode = wl_display_get_error(mDisplay);
+-    if ((ecode == EPIPE || ecode == ECONNRESET)) {
+-        // special case this to provide a nicer error
+-        qWarning("The Wayland connection broke. Did the Wayland compositor die?");
+-    } else {
+-        qWarning("The Wayland connection experienced a fatal error: %s", strerror(ecode));
+-    }
+-    _exit(1);
++    checkWaylandError(mDisplay);
+ }
+ 
++// Called in main thread, either from queued signal or directly.
+ void QWaylandDisplay::flushRequests()
+ {
+-    if (wl_display_prepare_read(mDisplay) == 0) {
+-        wl_display_read_events(mDisplay);
+-    }
+-
+-    if (wl_display_dispatch_pending(mDisplay) < 0)
+-        checkError();
+-
+-    {
+-        QReadLocker locker(&m_frameQueueLock);
+-        for (const FrameQueue &q : mExternalQueues) {
+-            QMutexLocker locker(q.mutex);
+-            while (wl_display_prepare_read_queue(mDisplay, q.queue) != 0)
+-                wl_display_dispatch_queue_pending(mDisplay, q.queue);
+-            wl_display_read_events(mDisplay);
+-            wl_display_dispatch_queue_pending(mDisplay, q.queue);
+-        }
+-    }
+-
+-    wl_display_flush(mDisplay);
+-}
+-
+-void QWaylandDisplay::blockingReadEvents()
+-{
+-    if (wl_display_dispatch(mDisplay) < 0)
+-        checkError();
+-}
+-
+-void QWaylandDisplay::destroyFrameQueue(const QWaylandDisplay::FrameQueue &q)
+-{
+-    QWriteLocker locker(&m_frameQueueLock);
+-    auto it = std::find_if(mExternalQueues.begin(),
+-                           mExternalQueues.end(),
+-                           [&q] (const QWaylandDisplay::FrameQueue &other){ return other.queue == q.queue; });
+-    Q_ASSERT(it != mExternalQueues.end());
+-    mExternalQueues.erase(it);
+-    if (q.queue != nullptr)
+-        wl_event_queue_destroy(q.queue);
+-    delete q.mutex;
++    m_eventThread->readAndDispatchEvents();
+ }
+ 
+-QWaylandDisplay::FrameQueue QWaylandDisplay::createFrameQueue()
++// We have to wait until we have an eventDispatcher before creating the eventThread,
++// otherwise forceRoundTrip() may block inside _events_read() because eventThread is
++// polling.
++void QWaylandDisplay::initEventThread()
+ {
+-    QWriteLocker locker(&m_frameQueueLock);
+-    FrameQueue q{createEventQueue()};
+-    mExternalQueues.append(q);
+-    return q;
+-}
++    m_eventThread.reset(
++            new EventThread(mDisplay, /* default queue */ nullptr, EventThread::EmitToDispatch));
++    connect(m_eventThread.get(), &EventThread::needReadAndDispatch, this,
++            &QWaylandDisplay::flushRequests, Qt::QueuedConnection);
++    m_eventThread->start();
+ 
+-wl_event_queue *QWaylandDisplay::createEventQueue()
+-{
+-    return wl_display_create_queue(mDisplay);
++    // wl_display_disconnect() free this.
++    m_frameEventQueue = wl_display_create_queue(mDisplay);
++    m_frameEventQueueThread.reset(
++            new EventThread(mDisplay, m_frameEventQueue, EventThread::SelfDispatch));
++    m_frameEventQueueThread->start();
+ }
+ 
+-void QWaylandDisplay::dispatchQueueWhile(wl_event_queue *queue, std::function<bool ()> condition, int timeout)
++void QWaylandDisplay::blockingReadEvents()
+ {
+-    if (!condition())
+-        return;
+-
+-    QElapsedTimer timer;
+-    timer.start();
+-    struct pollfd pFd = qt_make_pollfd(wl_display_get_fd(mDisplay), POLLIN);
+-    while (timeout == -1 || timer.elapsed() < timeout) {
+-        while (wl_display_prepare_read_queue(mDisplay, queue) != 0)
+-            wl_display_dispatch_queue_pending(mDisplay, queue);
+-
+-        wl_display_flush(mDisplay);
+-
+-        const int remaining = qMax(timeout - timer.elapsed(), 0ll);
+-        const int pollTimeout = timeout == -1 ? -1 : remaining;
+-        if (qt_poll_msecs(&pFd, 1, pollTimeout) > 0)
+-            wl_display_read_events(mDisplay);
+-        else
+-            wl_display_cancel_read(mDisplay);
+-
+-        if (wl_display_dispatch_queue_pending(mDisplay, queue) < 0)
+-            checkError();
+-
+-        if (!condition())
+-            break;
+-    }
++    if (wl_display_dispatch(mDisplay) < 0)
++        checkWaylandError(mDisplay);
+ }
+ 
+ QWaylandScreen *QWaylandDisplay::screenForOutput(struct wl_output *output) const
+@@ -345,7 +491,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+     if (interface == QStringLiteral("wl_output")) {
+         mWaitingScreens << new QWaylandScreen(this, version, id);
+     } else if (interface == QStringLiteral("wl_compositor")) {
+-        mCompositorVersion = qMin((int)version, 3);
++        mCompositorVersion = qMin((int)version, 4);
+         mCompositor.init(registry, id, mCompositorVersion);
+     } else if (interface == QStringLiteral("wl_shm")) {
+         mShm.reset(new QWaylandShm(this, version, id));
+@@ -354,7 +500,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+         mInputDevices.append(inputDevice);
+ #if QT_CONFIG(wayland_datadevice)
+     } else if (interface == QStringLiteral("wl_data_device_manager")) {
+-        mDndSelectionHandler.reset(new QWaylandDataDeviceManager(this, id));
++        mDndSelectionHandler.reset(new QWaylandDataDeviceManager(this, version, id));
+ #endif
+     } else if (interface == QStringLiteral("qt_surface_extension")) {
+         mWindowExtension.reset(new QtWayland::qt_surface_extension(registry, id, 1));
+@@ -369,6 +515,8 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+ #if QT_CONFIG(wayland_client_primary_selection)
+     } else if (interface == QStringLiteral("zwp_primary_selection_device_manager_v1")) {
+         mPrimarySelectionManager.reset(new QWaylandPrimarySelectionDeviceManagerV1(this, id, 1));
++        for (QWaylandInputDevice *inputDevice : qAsConst(mInputDevices))
++            inputDevice->setPrimarySelectionDevice(mPrimarySelectionManager->createDevice(inputDevice));
+ #endif
+     } else if (interface == QStringLiteral("zwp_text_input_manager_v2") && !mClientSideInputContextRequested) {
+         mTextInputManager.reset(new QtWayland::zwp_text_input_manager_v2(registry, id, 1));
+@@ -427,6 +575,13 @@ void QWaylandDisplay::registry_global_remove(uint32_t id)
+                     inputDevice->setTextInput(nullptr);
+                 mWaylandIntegration->reconfigureInputContext();
+             }
++#if QT_CONFIG(wayland_client_primary_selection)
++            if (global.interface == QStringLiteral("zwp_primary_selection_device_manager_v1")) {
++                mPrimarySelectionManager.reset();
++                for (QWaylandInputDevice *inputDevice : qAsConst(mInputDevices))
++                    inputDevice->setPrimarySelectionDevice(nullptr);
++            }
++#endif
+             mGlobals.removeAt(i);
+             break;
+         }
+@@ -452,9 +607,10 @@ void QWaylandDisplay::addRegistryListener(RegistryListener listener, void *data)
+ 
+ void QWaylandDisplay::removeListener(RegistryListener listener, void *data)
+ {
+-    std::remove_if(mRegistryListeners.begin(), mRegistryListeners.end(), [=](Listener l){
++    auto iter = std::remove_if(mRegistryListeners.begin(), mRegistryListeners.end(), [=](Listener l){
+         return (l.listener == listener && l.data == data);
+     });
++    mRegistryListeners.erase(iter, mRegistryListeners.end());
+ }
+ 
+ uint32_t QWaylandDisplay::currentTimeMillisec()
+@@ -467,50 +623,9 @@ uint32_t QWaylandDisplay::currentTimeMillisec()
+     return 0;
+ }
+ 
+-static void
+-sync_callback(void *data, struct wl_callback *callback, uint32_t serial)
+-{
+-    Q_UNUSED(serial)
+-    bool *done = static_cast<bool *>(data);
+-
+-    *done = true;
+-
+-    // If the wl_callback done event is received after the condition check in the while loop in
+-    // forceRoundTrip(), but before the call to processEvents, the call to processEvents may block
+-    // forever if no more events are posted (eventhough the callback is handled in response to the
+-    // aboutToBlock signal). Hence, we wake up the event dispatcher so forceRoundTrip may return.
+-    // (QTBUG-64696)
+-    if (auto *dispatcher = QThread::currentThread()->eventDispatcher())
+-        dispatcher->wakeUp();
+-
+-    wl_callback_destroy(callback);
+-}
+-
+-static const struct wl_callback_listener sync_listener = {
+-    sync_callback
+-};
+-
+ void QWaylandDisplay::forceRoundTrip()
+ {
+-    // wl_display_roundtrip() works on the main queue only,
+-    // but we use a separate one, so basically reimplement it here
+-    int ret = 0;
+-    bool done = false;
+-    wl_callback *callback = wl_display_sync(mDisplay);
+-    wl_callback_add_listener(callback, &sync_listener, &done);
+-    flushRequests();
+-    if (QThread::currentThread()->eventDispatcher()) {
+-        while (!done && ret >= 0) {
+-            QThread::currentThread()->eventDispatcher()->processEvents(QEventLoop::WaitForMoreEvents);
+-            ret = wl_display_dispatch_pending(mDisplay);
+-        }
+-    } else {
+-        while (!done && ret >= 0)
+-            ret = wl_display_dispatch(mDisplay);
+-    }
+-
+-    if (ret == -1 && !done)
+-        wl_callback_destroy(callback);
++     wl_display_roundtrip(mDisplay);
+ }
+ 
+ bool QWaylandDisplay::supportsWindowDecoration() const
+@@ -574,14 +689,10 @@ void QWaylandDisplay::handleKeyboardFocusChanged(QWaylandInputDevice *inputDevic
+     if (mLastKeyboardFocus == keyboardFocus)
+         return;
+ 
+-    if (mWaylandIntegration->mShellIntegration) {
+-        mWaylandIntegration->mShellIntegration->handleKeyboardFocusChanged(keyboardFocus, mLastKeyboardFocus);
+-    } else {
+-        if (keyboardFocus)
+-            handleWindowActivated(keyboardFocus);
+-        if (mLastKeyboardFocus)
+-            handleWindowDeactivated(mLastKeyboardFocus);
+-    }
++    if (keyboardFocus)
++        handleWindowActivated(keyboardFocus);
++    if (mLastKeyboardFocus)
++        handleWindowDeactivated(mLastKeyboardFocus);
+ 
+     mLastKeyboardFocus = keyboardFocus;
+ }
+@@ -600,6 +711,19 @@ void QWaylandDisplay::handleWaylandSync()
+     QWindow *activeWindow = mActiveWindows.empty() ? nullptr : mActiveWindows.last()->window();
+     if (activeWindow != QGuiApplication::focusWindow())
+         QWindowSystemInterface::handleWindowActivated(activeWindow);
++
++    if (!activeWindow) {
++        if (lastInputDevice()) {
++#if QT_CONFIG(clipboard)
++            if (auto *dataDevice = lastInputDevice()->dataDevice())
++                dataDevice->invalidateSelectionOffer();
++#endif
++#if QT_CONFIG(wayland_client_primary_selection)
++            if (auto *device = lastInputDevice()->primarySelectionDevice())
++                device->invalidateSelectionOffer();
++#endif
++        }
++    }
+ }
+ 
+ const wl_callback_listener QWaylandDisplay::syncCallbackListener = {
+@@ -626,6 +750,13 @@ QWaylandInputDevice *QWaylandDisplay::defaultInputDevice() const
+     return mInputDevices.isEmpty() ? 0 : mInputDevices.first();
+ }
+ 
++bool QWaylandDisplay::isKeyboardAvailable() const
++{
++    return std::any_of(
++            mInputDevices.constBegin(), mInputDevices.constEnd(),
++            [this](const QWaylandInputDevice *device) { return device->keyboard() != nullptr; });
++}
++
+ #if QT_CONFIG(cursor)
+ 
+ QWaylandCursor *QWaylandDisplay::waylandCursor()
+@@ -652,4 +783,6 @@ QWaylandCursorTheme *QWaylandDisplay::loadCursorTheme(const QString &name, int p
+ 
+ } // namespace QtWaylandClient
+ 
++#include "qwaylanddisplay.moc"
++
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/client/qwaylanddisplay_p.h b/qtwayland/src/client/qwaylanddisplay_p.h
+index 3b092bc8..42bc661d 100644
+--- a/qtwayland/src/client/qwaylanddisplay_p.h
++++ b/qtwayland/src/client/qwaylanddisplay_p.h
+@@ -109,6 +109,7 @@ class QWaylandSurface;
+ class QWaylandShellIntegration;
+ class QWaylandCursor;
+ class QWaylandCursorTheme;
++class EventThread;
+ 
+ typedef void (*RegistryListener)(void *data,
+                                  struct wl_registry *registry,
+@@ -120,15 +121,11 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandDisplay : public QObject, public QtWayland
+     Q_OBJECT
+ 
+ public:
+-    struct FrameQueue {
+-        FrameQueue(wl_event_queue *q = nullptr) : queue(q), mutex(new QMutex) {}
+-        wl_event_queue *queue;
+-        QMutex *mutex;
+-    };
+-
+     QWaylandDisplay(QWaylandIntegration *waylandIntegration);
+     ~QWaylandDisplay(void) override;
+ 
++    void initialize();
++
+ #if QT_CONFIG(xkbcommon)
+     struct xkb_context *xkbContext() const { return mXkbContext.get(); }
+ #endif
+@@ -210,11 +207,11 @@ public:
+     void handleKeyboardFocusChanged(QWaylandInputDevice *inputDevice);
+     void handleWindowDestroyed(QWaylandWindow *window);
+ 
+-    wl_event_queue *createEventQueue();
+-    FrameQueue createFrameQueue();
+-    void destroyFrameQueue(const FrameQueue &q);
+-    void dispatchQueueWhile(wl_event_queue *queue, std::function<bool()> condition, int timeout = -1);
++    wl_event_queue *frameEventQueue() { return m_frameEventQueue; };
++
++    bool isKeyboardAvailable() const;
+ 
++    void initEventThread();
+ public slots:
+     void blockingReadEvents();
+     void flushRequests();
+@@ -237,6 +234,9 @@ private:
+     };
+ 
+     struct wl_display *mDisplay = nullptr;
++    QScopedPointer<EventThread> m_eventThread;
++    wl_event_queue *m_frameEventQueue = nullptr;
++    QScopedPointer<EventThread> m_frameEventQueueThread;
+     QtWayland::wl_compositor mCompositor;
+     QScopedPointer<QWaylandShm> mShm;
+     QList<QWaylandScreen *> mWaitingScreens;
+@@ -273,11 +273,9 @@ private:
+     QWaylandInputDevice *mLastInputDevice = nullptr;
+     QPointer<QWaylandWindow> mLastInputWindow;
+     QPointer<QWaylandWindow> mLastKeyboardFocus;
+-    QVector<QWaylandWindow *> mActiveWindows;
+-    QVector<FrameQueue> mExternalQueues;
++    QList<QWaylandWindow *> mActiveWindows;
+     struct wl_callback *mSyncCallback = nullptr;
+     static const wl_callback_listener syncCallbackListener;
+-    QReadWriteLock m_frameQueueLock;
+ 
+     bool mClientSideInputContextRequested = !QPlatformInputContextFactory::requested().isNull();
+ 
+diff --git a/qtwayland/src/client/qwaylanddnd.cpp b/qtwayland/src/client/qwaylanddnd.cpp
+index 6535aa16..7c53f5fa 100644
+--- a/qtwayland/src/client/qwaylanddnd.cpp
++++ b/qtwayland/src/client/qwaylanddnd.cpp
+@@ -66,7 +66,7 @@ void QWaylandDrag::startDrag()
+ {
+     QBasicDrag::startDrag();
+     QWaylandWindow *icon = static_cast<QWaylandWindow *>(shapedPixmapWindow()->handle());
+-    if (m_display->currentInputDevice()->dataDevice()->startDrag(drag()->mimeData(), icon)) {
++    if (m_display->currentInputDevice()->dataDevice()->startDrag(drag()->mimeData(), drag()->supportedActions(), icon)) {
+         icon->addAttachOffset(-drag()->hotSpot());
+     } else {
+         // Cancelling immediately does not work, since the event loop for QDrag::exec is started
+@@ -80,6 +80,9 @@ void QWaylandDrag::cancel()
+     QBasicDrag::cancel();
+ 
+     m_display->currentInputDevice()->dataDevice()->cancelDrag();
++
++    if (drag())
++        drag()->deleteLater();
+ }
+ 
+ void QWaylandDrag::move(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods)
+@@ -103,33 +106,41 @@ void QWaylandDrag::endDrag()
+     m_display->currentInputDevice()->handleEndDrag();
+ }
+ 
+-void QWaylandDrag::updateTarget(const QString &mimeType)
++void QWaylandDrag::setResponse(bool accepted)
+ {
+-    setCanDrop(!mimeType.isEmpty());
+-
+-    if (canDrop()) {
+-        updateCursor(defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers()));
+-    } else {
+-        updateCursor(Qt::IgnoreAction);
+-    }
++    // This method is used for old DataDevices where the drag action is not communicated
++    Qt::DropAction action = defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers());
++    setResponse(QPlatformDropQtResponse(accepted, action));
+ }
+ 
+-void QWaylandDrag::setResponse(const QPlatformDragQtResponse &response)
++void QWaylandDrag::setResponse(const QPlatformDropQtResponse &response)
+ {
+     setCanDrop(response.isAccepted());
+ 
+     if (canDrop()) {
+-        updateCursor(defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers()));
++        updateCursor(response.acceptedAction());
+     } else {
+         updateCursor(Qt::IgnoreAction);
+     }
+ }
+ 
+-void QWaylandDrag::finishDrag(const QPlatformDropQtResponse &response)
++void QWaylandDrag::setDropResponse(const QPlatformDropQtResponse &response)
+ {
+     setExecutedDropAction(response.acceptedAction());
++}
++
++void QWaylandDrag::finishDrag()
++{
+     QKeyEvent event(QEvent::KeyPress, Qt::Key_Escape, Qt::NoModifier);
+     eventFilter(shapedPixmapWindow(), &event);
++
++    if (drag())
++        drag()->deleteLater();
++}
++
++bool QWaylandDrag::ownsDragObject() const
++{
++    return true;
+ }
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddnd_p.h b/qtwayland/src/client/qwaylanddnd_p.h
+index 474fe2ab..46f629ac 100644
+--- a/qtwayland/src/client/qwaylanddnd_p.h
++++ b/qtwayland/src/client/qwaylanddnd_p.h
+@@ -71,9 +71,10 @@ public:
+     QWaylandDrag(QWaylandDisplay *display);
+     ~QWaylandDrag() override;
+ 
+-    void updateTarget(const QString &mimeType);
+-    void setResponse(const QPlatformDragQtResponse &response);
+-    void finishDrag(const QPlatformDropQtResponse &response);
++    void setResponse(bool accepted);
++    void setResponse(const QPlatformDropQtResponse &response);
++    void setDropResponse(const QPlatformDropQtResponse &response);
++    void finishDrag();
+ 
+ protected:
+     void startDrag() override;
+@@ -82,6 +83,7 @@ protected:
+     void drop(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods) override;
+     void endDrag() override;
+ 
++    bool ownsDragObject() const override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+diff --git a/qtwayland/src/client/qwaylandinputdevice.cpp b/qtwayland/src/client/qwaylandinputdevice.cpp
+index 613fe862..4b90de84 100644
+--- a/qtwayland/src/client/qwaylandinputdevice.cpp
++++ b/qtwayland/src/client/qwaylandinputdevice.cpp
+@@ -685,6 +685,11 @@ public:
+ 
+ void QWaylandInputDevice::Pointer::pointer_leave(uint32_t time, struct wl_surface *surface)
+ {
++    invalidateFocus();
++    mButtons = Qt::NoButton;
++
++    mParent->mTime = time;
++
+     // The event may arrive after destroying the window, indicated by
+     // a null surface.
+     if (!surface)
+@@ -696,11 +701,6 @@ void QWaylandInputDevice::Pointer::pointer_leave(uint32_t time, struct wl_surfac
+ 
+     if (!QWaylandWindow::mouseGrab())
+         setFrameEvent(new LeaveEvent(window, mSurfacePos, mGlobalPos));
+-
+-    invalidateFocus();
+-    mButtons = Qt::NoButton;
+-
+-    mParent->mTime = time;
+ }
+ 
+ class MotionEvent : public QWaylandPointerEvent
+@@ -1300,14 +1300,6 @@ void QWaylandInputDevice::Keyboard::handleFocusDestroyed()
+ void QWaylandInputDevice::Keyboard::handleFocusLost()
+ {
+     mFocus = nullptr;
+-#if QT_CONFIG(clipboard)
+-    if (auto *dataDevice = mParent->dataDevice())
+-        dataDevice->invalidateSelectionOffer();
+-#endif
+-#if QT_CONFIG(wayland_client_primary_selection)
+-    if (auto *device = mParent->primarySelectionDevice())
+-        device->invalidateSelectionOffer();
+-#endif
+     mParent->mQDisplay->handleKeyboardFocusChanged(mParent);
+     mRepeatTimer.stop();
+ }
+@@ -1396,6 +1388,7 @@ void QWaylandInputDevice::Touch::touch_cancel()
+     if (touchExt)
+         touchExt->touchCanceled();
+ 
++    mFocus = nullptr;
+     QWindowSystemInterface::handleTouchCancelEvent(nullptr, mParent->mTouchDevice);
+ }
+ 
+diff --git a/qtwayland/src/client/qwaylandintegration.cpp b/qtwayland/src/client/qwaylandintegration.cpp
+index c53ccb78..54861600 100644
+--- a/qtwayland/src/client/qwaylandintegration.cpp
++++ b/qtwayland/src/client/qwaylandintegration.cpp
+@@ -125,6 +125,9 @@ QWaylandIntegration::QWaylandIntegration()
+ #endif
+ 
+     reconfigureInputContext();
++
++    QWaylandWindow::fixedToplevelPositions =
++            !qEnvironmentVariableIsSet("QT_WAYLAND_DISABLE_FIXED_POSITIONS");
+ }
+ 
+ QWaylandIntegration::~QWaylandIntegration()
+@@ -192,14 +195,18 @@ QAbstractEventDispatcher *QWaylandIntegration::createEventDispatcher() const
+ 
+ void QWaylandIntegration::initialize()
+ {
++    mDisplay->initEventThread();
++
++    // Call after eventDispatcher is fully connected, for QWaylandDisplay::forceRoundTrip()
++    mDisplay->initialize();
++
++    // But the aboutToBlock() and awake() should be connected after initializePlatform().
++    // Otherwise the connected flushRequests() may consumes up all events before processEvents starts to wait,
++    // so that processEvents(QEventLoop::WaitForMoreEvents) may be blocked in the forceRoundTrip().
+     QAbstractEventDispatcher *dispatcher = QGuiApplicationPrivate::eventDispatcher;
+     QObject::connect(dispatcher, SIGNAL(aboutToBlock()), mDisplay.data(), SLOT(flushRequests()));
+     QObject::connect(dispatcher, SIGNAL(awake()), mDisplay.data(), SLOT(flushRequests()));
+ 
+-    int fd = wl_display_get_fd(mDisplay->wl_display());
+-    QSocketNotifier *sn = new QSocketNotifier(fd, QSocketNotifier::Read, mDisplay.data());
+-    QObject::connect(sn, SIGNAL(activated(QSocketDescriptor)), mDisplay.data(), SLOT(flushRequests()));
+-
+     // Qt does not support running with no screens
+     mDisplay->ensureScreen();
+ }
+@@ -262,6 +269,14 @@ QWaylandDisplay *QWaylandIntegration::display() const
+     return mDisplay.data();
+ }
+ 
++Qt::KeyboardModifiers QWaylandIntegration::queryKeyboardModifiers() const
++{
++    if (auto *seat = mDisplay->currentInputDevice()) {
++        return seat->modifiers();
++    }
++    return Qt::NoModifier;
++}
++
+ QList<int> QWaylandIntegration::possibleKeys(const QKeyEvent *event) const
+ {
+     if (auto *seat = mDisplay->currentInputDevice())
+@@ -479,7 +494,7 @@ void QWaylandIntegration::reconfigureInputContext()
+     }
+ #endif
+ 
+-    qCDebug(lcQpaWayland) << "using input method:" << inputContext()->metaObject()->className();
++    qCDebug(lcQpaWayland) << "using input method:" << (inputContext() ? inputContext()->metaObject()->className() : "<none>");
+ }
+ 
+ QWaylandShellIntegration *QWaylandIntegration::createShellIntegration(const QString &integrationName)
+diff --git a/qtwayland/src/client/qwaylandintegration_p.h b/qtwayland/src/client/qwaylandintegration_p.h
+index ff70ae25..73b80658 100644
+--- a/qtwayland/src/client/qwaylandintegration_p.h
++++ b/qtwayland/src/client/qwaylandintegration_p.h
+@@ -107,6 +107,8 @@ public:
+ 
+     QWaylandDisplay *display() const;
+ 
++    Qt::KeyboardModifiers queryKeyboardModifiers() const override;
++
+     QList<int> possibleKeys(const QKeyEvent *event) const override;
+ 
+     QStringList themeNames() const override;
+diff --git a/qtwayland/src/client/qwaylandprimaryselectionv1.cpp b/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
+index 832f9678..ea508771 100644
+--- a/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
++++ b/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
+@@ -54,11 +54,6 @@ QWaylandPrimarySelectionDeviceManagerV1::QWaylandPrimarySelectionDeviceManagerV1
+     : zwp_primary_selection_device_manager_v1(display->wl_registry(), id, qMin(version, uint(1)))
+     , m_display(display)
+ {
+-    // Create devices for all seats.
+-    // This only works if we get the global before all devices
+-    const auto seats = m_display->inputDevices();
+-    for (auto *seat : seats)
+-        seat->setPrimarySelectionDevice(createDevice(seat));
+ }
+ 
+ QWaylandPrimarySelectionDeviceV1 *QWaylandPrimarySelectionDeviceManagerV1::createDevice(QWaylandInputDevice *seat)
+diff --git a/qtwayland/src/client/qwaylandscreen.cpp b/qtwayland/src/client/qwaylandscreen.cpp
+index 6cb337de..5537dafd 100644
+--- a/qtwayland/src/client/qwaylandscreen.cpp
++++ b/qtwayland/src/client/qwaylandscreen.cpp
+@@ -60,7 +60,7 @@ QWaylandXdgOutputManagerV1::QWaylandXdgOutputManagerV1(QWaylandDisplay* display,
+ }
+ 
+ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uint32_t id)
+-    : QtWayland::wl_output(waylandDisplay->wl_registry(), id, qMin(version, 2))
++    : QtWayland::wl_output(waylandDisplay->wl_registry(), id, qMin(version, 3))
+     , m_outputId(id)
+     , mWaylandDisplay(waylandDisplay)
+     , mOutputName(QStringLiteral("Screen%1").arg(id))
+@@ -72,7 +72,7 @@ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uin
+         qCWarning(lcQpaWayland) << "wl_output done event not supported by compositor,"
+                                 << "QScreen may not work correctly";
+         mWaylandDisplay->forceRoundTrip(); // Give the compositor a chance to send geometry etc.
+-        mOutputDone = true; // Fake the done event
++        mProcessedEvents |= OutputDoneEvent; // Fake the done event
+         maybeInitialize();
+     }
+ }
+@@ -81,16 +81,29 @@ QWaylandScreen::~QWaylandScreen()
+ {
+     if (zxdg_output_v1::isInitialized())
+         zxdg_output_v1::destroy();
++    if (wl_output::isInitialized() && wl_output_get_version(wl_output::object()) >= WL_OUTPUT_RELEASE_SINCE_VERSION)
++        wl_output::release();
++}
++
++uint QWaylandScreen::requiredEvents() const
++{
++    uint ret = OutputDoneEvent;
++
++    if (mWaylandDisplay->xdgOutputManager()) {
++        ret |= XdgOutputNameEvent;
++
++        if (mWaylandDisplay->xdgOutputManager()->version() < 3)
++            ret |= XdgOutputDoneEvent;
++    }
++    return ret;
+ }
+ 
+ void QWaylandScreen::maybeInitialize()
+ {
+     Q_ASSERT(!mInitialized);
+ 
+-    if (!mOutputDone)
+-        return;
+-
+-    if (mWaylandDisplay->xdgOutputManager() && !mXdgOutputDone)
++    const uint requiredEvents = this->requiredEvents();
++    if ((mProcessedEvents & requiredEvents) != requiredEvents)
+         return;
+ 
+     mInitialized = true;
+@@ -276,9 +289,8 @@ void QWaylandScreen::output_scale(int32_t factor)
+ 
+ void QWaylandScreen::output_done()
+ {
+-    mOutputDone = true;
+-    if (zxdg_output_v1::isInitialized() && mWaylandDisplay->xdgOutputManager()->version() >= 3)
+-        mXdgOutputDone = true;
++    mProcessedEvents |= OutputDoneEvent;
++
+     if (mInitialized) {
+         updateOutputProperties();
+         if (zxdg_output_v1::isInitialized())
+@@ -339,7 +351,7 @@ void QWaylandScreen::zxdg_output_v1_done()
+     if (Q_UNLIKELY(mWaylandDisplay->xdgOutputManager()->version() >= 3))
+         qWarning(lcQpaWayland) << "zxdg_output_v1.done received on version 3 or newer, this is most likely a bug in the compositor";
+ 
+-    mXdgOutputDone = true;
++    mProcessedEvents |= XdgOutputDoneEvent;
+     if (mInitialized)
+         updateXdgOutputProperties();
+     else
+@@ -348,7 +360,11 @@ void QWaylandScreen::zxdg_output_v1_done()
+ 
+ void QWaylandScreen::zxdg_output_v1_name(const QString &name)
+ {
++    if (Q_UNLIKELY(mInitialized))
++        qWarning(lcQpaWayland) << "zxdg_output_v1.name received after output has been initialized, this is most likely a bug in the compositor";
++
+     mOutputName = name;
++    mProcessedEvents |= XdgOutputNameEvent;
+ }
+ 
+ void QWaylandScreen::updateXdgOutputProperties()
+diff --git a/qtwayland/src/client/qwaylandscreen_p.h b/qtwayland/src/client/qwaylandscreen_p.h
+index df1c94f2..050cfdc0 100644
+--- a/qtwayland/src/client/qwaylandscreen_p.h
++++ b/qtwayland/src/client/qwaylandscreen_p.h
+@@ -116,6 +116,13 @@ public:
+     static QWaylandScreen *fromWlOutput(::wl_output *output);
+ 
+ private:
++    enum Event : uint {
++        XdgOutputDoneEvent = 0x1,
++        OutputDoneEvent = 0x2,
++        XdgOutputNameEvent = 0x4,
++    };
++    uint requiredEvents() const;
++
+     void output_mode(uint32_t flags, int width, int height, int refresh) override;
+     void output_geometry(int32_t x, int32_t y,
+                          int32_t width, int32_t height,
+@@ -148,8 +155,7 @@ private:
+     QSize mPhysicalSize;
+     QString mOutputName;
+     Qt::ScreenOrientation m_orientation = Qt::PrimaryOrientation;
+-    bool mOutputDone = false;
+-    bool mXdgOutputDone = false;
++    uint mProcessedEvents = 0;
+     bool mInitialized = false;
+ 
+ #if QT_CONFIG(cursor)
+diff --git a/qtwayland/src/client/qwaylandshmbackingstore.cpp b/qtwayland/src/client/qwaylandshmbackingstore.cpp
+index dc7ff670..41cffdf7 100644
+--- a/qtwayland/src/client/qwaylandshmbackingstore.cpp
++++ b/qtwayland/src/client/qwaylandshmbackingstore.cpp
+@@ -52,6 +52,7 @@
+ 
+ #include <QtWaylandClient/private/wayland-wayland-client-protocol.h>
+ 
++#include <fcntl.h>
+ #include <unistd.h>
+ #include <sys/mman.h>
+ 
+@@ -61,6 +62,9 @@
+ #  ifndef MFD_CLOEXEC
+ #    define MFD_CLOEXEC     0x0001U
+ #  endif
++#  ifndef MFD_ALLOW_SEALING
++#    define MFD_ALLOW_SEALING 0x0002U
++#  endif
+ #endif
+ 
+ QT_BEGIN_NAMESPACE
+@@ -74,8 +78,10 @@ QWaylandShmBuffer::QWaylandShmBuffer(QWaylandDisplay *display,
+     int alloc = stride * size.height();
+     int fd = -1;
+ 
+-#ifdef SYS_memfd_create
+-    fd = syscall(SYS_memfd_create, "wayland-shm", MFD_CLOEXEC);
++#if defined(SYS_memfd_create) && defined(F_SEAL_SEAL)
++    fd = syscall(SYS_memfd_create, "wayland-shm", MFD_CLOEXEC | MFD_ALLOW_SEALING);
++    if (fd >= 0)
++        fcntl(fd, F_ADD_SEALS, F_SEAL_SHRINK | F_SEAL_SEAL);
+ #endif
+ 
+     QScopedPointer<QFile> filePointer;
+diff --git a/qtwayland/src/client/qwaylandwindow.cpp b/qtwayland/src/client/qwaylandwindow.cpp
+index cb82857a..fb2c59dc 100644
+--- a/qtwayland/src/client/qwaylandwindow.cpp
++++ b/qtwayland/src/client/qwaylandwindow.cpp
+@@ -76,7 +76,6 @@ QWaylandWindow *QWaylandWindow::mMouseGrab = nullptr;
+ QWaylandWindow::QWaylandWindow(QWindow *window, QWaylandDisplay *display)
+     : QPlatformWindow(window)
+     , mDisplay(display)
+-    , mFrameQueue(mDisplay->createFrameQueue())
+     , mResizeAfterSwap(qEnvironmentVariableIsSet("QT_WAYLAND_RESIZE_AFTER_SWAP"))
+ {
+     {
+@@ -95,9 +94,6 @@ QWaylandWindow::QWaylandWindow(QWindow *window, QWaylandDisplay *display)
+ 
+ QWaylandWindow::~QWaylandWindow()
+ {
+-    mDisplay->destroyFrameQueue(mFrameQueue);
+-    mDisplay->handleWindowDestroyed(this);
+-
+     delete mWindowDecoration;
+ 
+     if (mSurface)
+@@ -243,6 +239,7 @@ bool QWaylandWindow::shouldCreateSubSurface() const
+ 
+ void QWaylandWindow::reset()
+ {
++    closeChildPopups();
+     delete mShellSurface;
+     mShellSurface = nullptr;
+     delete mSubSurfaceWindow;
+@@ -255,17 +252,22 @@ void QWaylandWindow::reset()
+         mSurface.reset();
+     }
+ 
+-    if (mFrameCallback) {
+-        wl_callback_destroy(mFrameCallback);
+-        mFrameCallback = nullptr;
+-    }
++    {
++        QMutexLocker lock(&mFrameSyncMutex);
++        if (mFrameCallback) {
++            wl_callback_destroy(mFrameCallback);
++            mFrameCallback = nullptr;
++        }
+ 
+-    mFrameCallbackElapsedTimer.invalidate();
+-    mWaitingForFrameCallback = false;
++        mFrameCallbackElapsedTimer.invalidate();
++        mWaitingForFrameCallback = false;
++    }
+     mFrameCallbackTimedOut = false;
+ 
+     mMask = QRegion();
+     mQueuedBuffer = nullptr;
++
++    mDisplay->handleWindowDestroyed(this);
+ }
+ 
+ QWaylandWindow *QWaylandWindow::fromWlSurface(::wl_surface *surface)
+@@ -351,19 +353,25 @@ void QWaylandWindow::setGeometry_helper(const QRect &rect)
+     }
+ }
+ 
+-void QWaylandWindow::setGeometry(const QRect &rect)
++void QWaylandWindow::setGeometry(const QRect &r)
+ {
++    auto rect = r;
++    if (fixedToplevelPositions && !QPlatformWindow::parent() && window()->type() != Qt::Popup
++        && window()->type() != Qt::ToolTip) {
++        rect.moveTo(screen()->geometry().topLeft());
++    }
+     setGeometry_helper(rect);
+ 
+     if (window()->isVisible() && rect.isValid()) {
+         if (mWindowDecoration)
+             mWindowDecoration->update();
+ 
+-        if (mResizeAfterSwap && windowType() == Egl && mSentInitialResize)
++        if (mResizeAfterSwap && windowType() == Egl && mSentInitialResize) {
++            QMutexLocker lock(&mResizeLock);
+             mResizeDirty = true;
+-        else
++        } else {
+             QWindowSystemInterface::handleGeometryChange(window(), geometry());
+-
++        }
+         mSentInitialResize = true;
+     }
+     QRect exposeGeometry(QPoint(), geometry().size());
+@@ -374,7 +382,7 @@ void QWaylandWindow::setGeometry(const QRect &rect)
+         mShellSurface->setWindowGeometry(windowContentGeometry());
+ 
+     if (isOpaque() && mMask.isEmpty())
+-        setOpaqueArea(rect);
++        setOpaqueArea(QRect(QPoint(0, 0), rect.size()));
+ }
+ 
+ void QWaylandWindow::resizeFromApplyConfigure(const QSize &sizeWithMargins, const QPoint &offset)
+@@ -399,21 +407,6 @@ void QWaylandWindow::sendExposeEvent(const QRect &rect)
+     mLastExposeGeometry = rect;
+ }
+ 
+-
+-static QVector<QPointer<QWaylandWindow>> activePopups;
+-
+-void QWaylandWindow::closePopups(QWaylandWindow *parent)
+-{
+-    while (!activePopups.isEmpty()) {
+-        auto popup = activePopups.takeLast();
+-        if (popup.isNull())
+-            continue;
+-        if (popup.data() == parent)
+-            return;
+-        popup->reset();
+-    }
+-}
+-
+ QPlatformScreen *QWaylandWindow::calculateScreenFromSurfaceEvents() const
+ {
+     QReadLocker lock(&mSurfaceLock);
+@@ -433,10 +426,7 @@ void QWaylandWindow::setVisible(bool visible)
+     lastVisible = visible;
+ 
+     if (visible) {
+-        if (window()->type() == Qt::Popup || window()->type() == Qt::ToolTip)
+-            activePopups << this;
+         initWindow();
+-        mDisplay->flushRequests();
+ 
+         setGeometry(windowGeometry());
+         // Don't flush the events here, or else the newly visible window may start drawing, but since
+@@ -444,7 +434,6 @@ void QWaylandWindow::setVisible(bool visible)
+         // QWaylandShmBackingStore::beginPaint().
+     } else {
+         sendExposeEvent(QRect());
+-        closePopups(this);
+         reset();
+     }
+ }
+@@ -556,12 +545,12 @@ void QWaylandWindow::sendRecursiveExposeEvent()
+ 
+ void QWaylandWindow::attach(QWaylandBuffer *buffer, int x, int y)
+ {
+-    Q_ASSERT(!buffer->committed());
+     QReadLocker locker(&mSurfaceLock);
+     if (mSurface == nullptr)
+         return;
+ 
+     if (buffer) {
++        Q_ASSERT(!buffer->committed());
+         handleUpdate();
+         buffer->setBusy();
+ 
+@@ -583,7 +572,11 @@ void QWaylandWindow::damage(const QRect &rect)
+     if (mSurface == nullptr)
+         return;
+ 
+-    mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    const int s = scale();
++    if (mDisplay->compositorVersion() >= 4)
++        mSurface->damage_buffer(s * rect.x(), s * rect.y(), s * rect.width(), s * rect.height());
++    else
++        mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
+ }
+ 
+ void QWaylandWindow::safeCommit(QWaylandBuffer *buffer, const QRegion &damage)
+@@ -619,8 +612,14 @@ void QWaylandWindow::commit(QWaylandBuffer *buffer, const QRegion &damage)
+         return;
+ 
+     attachOffset(buffer);
+-    for (const QRect &rect: damage)
+-        mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    if (mDisplay->compositorVersion() >= 4) {
++        const int s = scale();
++        for (const QRect &rect: damage)
++            mSurface->damage_buffer(s * rect.x(), s * rect.y(), s * rect.width(), s * rect.height());
++    } else {
++        for (const QRect &rect: damage)
++            mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    }
+     Q_ASSERT(!buffer->committed());
+     buffer->setCommitted();
+     mSurface->commit();
+@@ -635,42 +634,53 @@ void QWaylandWindow::commit()
+ 
+ const wl_callback_listener QWaylandWindow::callbackListener = {
+     [](void *data, wl_callback *callback, uint32_t time) {
+-        Q_UNUSED(callback);
+         Q_UNUSED(time);
+         auto *window = static_cast<QWaylandWindow*>(data);
+-        window->handleFrameCallback();
++        window->handleFrameCallback(callback);
+     }
+ };
+ 
+-void QWaylandWindow::handleFrameCallback()
++void QWaylandWindow::handleFrameCallback(wl_callback* callback)
+ {
++    QMutexLocker locker(&mFrameSyncMutex);
++    if (!mFrameCallback) {
++        // This means the callback is already unset by QWaylandWindow::reset.
++        // The wl_callback object will be destroyed there too.
++        return;
++    }
++    Q_ASSERT(callback == mFrameCallback);
++    wl_callback_destroy(callback);
++    mFrameCallback = nullptr;
++
+     mWaitingForFrameCallback = false;
+     mFrameCallbackElapsedTimer.invalidate();
+ 
+     // The rest can wait until we can run it on the correct thread
+-    if (!mWaitingForUpdateDelivery) {
+-        auto doHandleExpose = [this]() {
+-            bool wasExposed = isExposed();
+-            mFrameCallbackTimedOut = false;
+-            if (!wasExposed && isExposed()) // Did setting mFrameCallbackTimedOut make the window exposed?
+-                sendExposeEvent(QRect(QPoint(), geometry().size()));
+-            if (wasExposed && hasPendingUpdateRequest())
+-                deliverUpdateRequest();
+-
+-            mWaitingForUpdateDelivery = false;
+-        };
++    auto doHandleExpose = [this]() {
++        mWaitingForUpdateDelivery.storeRelease(false);
++        bool wasExposed = isExposed();
++        mFrameCallbackTimedOut = false;
++        if (!wasExposed && isExposed()) // Did setting mFrameCallbackTimedOut make the window exposed?
++            sendExposeEvent(QRect(QPoint(), geometry().size()));
++        if (wasExposed && hasPendingUpdateRequest())
++            deliverUpdateRequest();
++    };
+ 
++    if (mWaitingForUpdateDelivery.testAndSetAcquire(false, true)) {
+         // Queued connection, to make sure we don't call handleUpdate() from inside waitForFrameSync()
+         // in the single-threaded case.
+-        mWaitingForUpdateDelivery = true;
+         QMetaObject::invokeMethod(this, doHandleExpose, Qt::QueuedConnection);
+     }
++
++    mFrameSyncWait.notify_all();
+ }
+ 
+ bool QWaylandWindow::waitForFrameSync(int timeout)
+ {
+-    QMutexLocker locker(mFrameQueue.mutex);
+-    mDisplay->dispatchQueueWhile(mFrameQueue.queue, [&]() { return mWaitingForFrameCallback; }, timeout);
++    QMutexLocker locker(&mFrameSyncMutex);
++
++    QDeadlineTimer deadline(timeout);
++    while (mWaitingForFrameCallback && mFrameSyncWait.wait(&mFrameSyncMutex, deadline)) { }
+ 
+     if (mWaitingForFrameCallback) {
+         qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
+@@ -868,6 +878,17 @@ bool QWaylandWindow::createDecoration()
+             subsurf->set_position(pos.x() + m.left(), pos.y() + m.top());
+         }
+         sendExposeEvent(QRect(QPoint(), geometry().size()));
++
++        // This is a special case where the buffer is recreated, but since
++        // the content rect remains the same, the widgets remain the same
++        // size and are not redrawn, leaving the new buffer empty. As a simple
++        // work-around, we trigger a full extra update whenever the client-side
++        // window decorations are toggled while the window is showing.
++        // Note: createDecoration() is sometimes called from the render thread
++        // of Qt Quick. This is essentially wrong and could potentially cause problems,
++        // but until the underlying issue has been fixed, we have to use invokeMethod()
++        // here to avoid asserts.
++        QMetaObject::invokeMethod(window(), &QWindow::requestUpdate);
+     }
+ 
+     return mWindowDecoration;
+@@ -1023,6 +1044,13 @@ void QWaylandWindow::handleScreensChanged()
+ 
+     QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->QPlatformScreen::screen());
+     mLastReportedScreen = newScreen;
++    if (fixedToplevelPositions && !QPlatformWindow::parent() && window()->type() != Qt::Popup
++        && window()->type() != Qt::ToolTip
++        && geometry().topLeft() != newScreen->geometry().topLeft()) {
++        auto geometry = this->geometry();
++        geometry.moveTo(newScreen->geometry().topLeft());
++        setGeometry(geometry);
++    }
+ 
+     int scale = newScreen->isPlaceholder() ? 1 : static_cast<QWaylandScreen *>(newScreen)->scale();
+     if (scale != mScale) {
+@@ -1094,10 +1122,18 @@ bool QWaylandWindow::setMouseGrabEnabled(bool grab)
+     return true;
+ }
+ 
++Qt::WindowStates QWaylandWindow::windowStates() const
++{
++    return mLastReportedWindowStates;
++}
++
+ void QWaylandWindow::handleWindowStatesChanged(Qt::WindowStates states)
+ {
+     createDecoration();
+-    QWindowSystemInterface::handleWindowStateChanged(window(), states, mLastReportedWindowStates);
++    Qt::WindowStates statesWithoutActive = states & ~Qt::WindowActive;
++    Qt::WindowStates lastStatesWithoutActive = mLastReportedWindowStates & ~Qt::WindowActive;
++    QWindowSystemInterface::handleWindowStateChanged(window(), statesWithoutActive,
++                                                     lastStatesWithoutActive);
+     mLastReportedWindowStates = states;
+ }
+ 
+@@ -1139,19 +1175,24 @@ void QWaylandWindow::timerEvent(QTimerEvent *event)
+     if (event->timerId() != mFrameCallbackCheckIntervalTimerId)
+         return;
+ 
+-    bool callbackTimerExpired = mFrameCallbackElapsedTimer.hasExpired(mFrameCallbackTimeout);
+-    if (!mFrameCallbackElapsedTimer.isValid() || callbackTimerExpired ) {
+-        killTimer(mFrameCallbackCheckIntervalTimerId);
+-        mFrameCallbackCheckIntervalTimerId = -1;
+-    }
+-    if (mFrameCallbackElapsedTimer.isValid() && callbackTimerExpired) {
+-        mFrameCallbackElapsedTimer.invalidate();
++    {
++        QMutexLocker lock(&mFrameSyncMutex);
+ 
+-        qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
+-        mFrameCallbackTimedOut = true;
+-        mWaitingForUpdate = false;
+-        sendExposeEvent(QRect());
++        bool callbackTimerExpired = mFrameCallbackElapsedTimer.hasExpired(mFrameCallbackTimeout);
++        if (!mFrameCallbackElapsedTimer.isValid() || callbackTimerExpired ) {
++            killTimer(mFrameCallbackCheckIntervalTimerId);
++            mFrameCallbackCheckIntervalTimerId = -1;
++        }
++        if (!mFrameCallbackElapsedTimer.isValid() || !callbackTimerExpired) {
++            return;
++        }
++        mFrameCallbackElapsedTimer.invalidate();
+     }
++
++    qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
++    mFrameCallbackTimedOut = true;
++    mWaitingForUpdate = false;
++    sendExposeEvent(QRect());
+ }
+ 
+ void QWaylandWindow::requestUpdate()
+@@ -1160,8 +1201,11 @@ void QWaylandWindow::requestUpdate()
+     Q_ASSERT(hasPendingUpdateRequest()); // should be set by QPA
+ 
+     // If we have a frame callback all is good and will be taken care of there
+-    if (mWaitingForFrameCallback)
+-        return;
++    {
++        QMutexLocker locker(&mFrameSyncMutex);
++        if (mWaitingForFrameCallback)
++            return;
++    }
+ 
+     // If we've already called deliverUpdateRequest(), but haven't seen any attach+commit/swap yet
+     // This is a somewhat redundant behavior and might indicate a bug in the calling code, so log
+@@ -1174,7 +1218,12 @@ void QWaylandWindow::requestUpdate()
+     // so use invokeMethod to delay the delivery a bit.
+     QMetaObject::invokeMethod(this, [this] {
+         // Things might have changed in the meantime
+-        if (hasPendingUpdateRequest() && !mWaitingForFrameCallback)
++        {
++            QMutexLocker locker(&mFrameSyncMutex);
++            if (mWaitingForFrameCallback)
++                return;
++        }
++        if (hasPendingUpdateRequest())
+             deliverUpdateRequest();
+     }, Qt::QueuedConnection);
+ }
+@@ -1185,19 +1234,18 @@ void QWaylandWindow::requestUpdate()
+ void QWaylandWindow::handleUpdate()
+ {
+     qCDebug(lcWaylandBackingstore) << "handleUpdate" << QThread::currentThread();
++
+     // TODO: Should sync subsurfaces avoid requesting frame callbacks?
+     QReadLocker lock(&mSurfaceLock);
+     if (!mSurface)
+         return;
+ 
+-    if (mFrameCallback) {
+-        wl_callback_destroy(mFrameCallback);
+-        mFrameCallback = nullptr;
+-    }
++    QMutexLocker locker(&mFrameSyncMutex);
++    if (mWaitingForFrameCallback)
++        return;
+ 
+-    QMutexLocker locker(mFrameQueue.mutex);
+     struct ::wl_surface *wrappedSurface = reinterpret_cast<struct ::wl_surface *>(wl_proxy_create_wrapper(mSurface->object()));
+-    wl_proxy_set_queue(reinterpret_cast<wl_proxy *>(wrappedSurface), mFrameQueue.queue);
++    wl_proxy_set_queue(reinterpret_cast<wl_proxy *>(wrappedSurface), mDisplay->frameEventQueue());
+     mFrameCallback = wl_surface_frame(wrappedSurface);
+     wl_proxy_wrapper_destroy(wrappedSurface);
+     wl_callback_add_listener(mFrameCallback, &QWaylandWindow::callbackListener, this);
+@@ -1207,6 +1255,8 @@ void QWaylandWindow::handleUpdate()
+     // Start a timer for handling the case when the compositor stops sending frame callbacks.
+     if (mFrameCallbackTimeout > 0) {
+         QMetaObject::invokeMethod(this, [this] {
++            QMutexLocker locker(&mFrameSyncMutex);
++
+             if (mWaitingForFrameCallback) {
+                 if (mFrameCallbackCheckIntervalTimerId < 0)
+                     mFrameCallbackCheckIntervalTimerId = startTimer(mFrameCallbackTimeout);
+@@ -1267,6 +1317,20 @@ void QWaylandWindow::setOpaqueArea(const QRegion &opaqueArea)
+     wl_region_destroy(region);
+ }
+ 
++void QWaylandWindow::addChildPopup(QWaylandWindow *surface) {
++    mChildPopups.append(surface);
++}
++
++void QWaylandWindow::removeChildPopup(QWaylandWindow *surface) {
++    mChildPopups.removeAll(surface);
++}
++
++void QWaylandWindow::closeChildPopups() {
++    while (!mChildPopups.isEmpty()) {
++        auto popup = mChildPopups.takeLast();
++        popup->reset();
++    }
++}
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/client/qwaylandwindow_p.h b/qtwayland/src/client/qwaylandwindow_p.h
+index 01337cff..2f219d8c 100644
+--- a/qtwayland/src/client/qwaylandwindow_p.h
++++ b/qtwayland/src/client/qwaylandwindow_p.h
+@@ -98,6 +98,9 @@ public:
+     QWaylandWindow(QWindow *window, QWaylandDisplay *display);
+     ~QWaylandWindow() override;
+ 
++    // Keep Toplevels position on the top left corner of their screen
++    static inline bool fixedToplevelPositions = true;
++
+     virtual WindowType windowType() const = 0;
+     virtual void ensureSize();
+     WId winId() const override;
+@@ -148,6 +151,7 @@ public:
+     void setWindowState(Qt::WindowStates states) override;
+     void setWindowFlags(Qt::WindowFlags flags) override;
+     void handleWindowStatesChanged(Qt::WindowStates states);
++    Qt::WindowStates windowStates() const;
+ 
+     void raise() override;
+     void lower() override;
+@@ -206,6 +210,10 @@ public:
+     void handleUpdate();
+     void deliverUpdateRequest() override;
+ 
++    void addChildPopup(QWaylandWindow* child);
++    void removeChildPopup(QWaylandWindow* child);
++    void closeChildPopups();
++
+ public slots:
+     void applyConfigure();
+ 
+@@ -215,7 +223,11 @@ signals:
+ 
+ protected:
+     QWaylandDisplay *mDisplay = nullptr;
++
++    // mSurface can be written by the main thread. Other threads should claim a read lock for access
++    mutable QReadWriteLock mSurfaceLock;
+     QScopedPointer<QWaylandSurface> mSurface;
++
+     QWaylandShellSurface *mShellSurface = nullptr;
+     QWaylandSubSurface *mSubSurfaceWindow = nullptr;
+     QVector<QWaylandSubSurface *> mChildren;
+@@ -225,13 +237,14 @@ protected:
+     Qt::MouseButtons mMousePressedInContentArea = Qt::NoButton;
+ 
+     WId mWindowId;
+-    bool mWaitingForFrameCallback = false;
+     bool mFrameCallbackTimedOut = false; // Whether the frame callback has timed out
+-    bool mWaitingForUpdateDelivery = false;
+     int mFrameCallbackCheckIntervalTimerId = -1;
+-    QElapsedTimer mFrameCallbackElapsedTimer;
+-    struct ::wl_callback *mFrameCallback = nullptr;
+-    QWaylandDisplay::FrameQueue mFrameQueue;
++    QAtomicInt mWaitingForUpdateDelivery = false;
++
++    bool mWaitingForFrameCallback = false; // Protected by mFrameSyncMutex
++    QElapsedTimer mFrameCallbackElapsedTimer; // Protected by mFrameSyncMutex
++    struct ::wl_callback *mFrameCallback = nullptr; // Protected by mFrameSyncMutex
++    QMutex mFrameSyncMutex;
+     QWaitCondition mFrameSyncWait;
+ 
+     // True when we have called deliverRequestUpdate, but the client has not yet attached a new buffer
+@@ -261,6 +274,8 @@ protected:
+     QWaylandBuffer *mQueuedBuffer = nullptr;
+     QRegion mQueuedBufferDamage;
+ 
++    QList<QPointer<QWaylandWindow>> mChildPopups;
++
+ private:
+     void setGeometry_helper(const QRect &rect);
+     void initWindow();
+@@ -283,12 +298,10 @@ private:
+     QRect mLastExposeGeometry;
+ 
+     static const wl_callback_listener callbackListener;
+-    void handleFrameCallback();
++    void handleFrameCallback(struct ::wl_callback* callback);
+ 
+     static QWaylandWindow *mMouseGrab;
+ 
+-    mutable QReadWriteLock mSurfaceLock;
+-
+     friend class QWaylandSubSurface;
+ };
+ 
+diff --git a/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h b/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
+index ccad0048..4cc9b3b8 100644
+--- a/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
++++ b/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
+@@ -73,11 +73,10 @@ public:
+         return true;
+     }
+     virtual QWaylandShellSurface *createShellSurface(QWaylandWindow *window) = 0;
++    // kept for binary compat with layer-shell-qt
+     virtual void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) {
+-        if (newFocus)
+-            m_display->handleWindowActivated(newFocus);
+-        if (oldFocus)
+-            m_display->handleWindowDeactivated(oldFocus);
++        Q_UNUSED(newFocus);
++        Q_UNUSED(oldFocus);
+     }
+     virtual void *nativeResourceForWindow(const QByteArray &resource, QWindow *window) {
+         Q_UNUSED(resource);
+diff --git a/qtwayland/src/compositor/configure.json b/qtwayland/src/compositor/configure.json
+index bcfd5215..da95d07b 100644
+--- a/qtwayland/src/compositor/configure.json
++++ b/qtwayland/src/compositor/configure.json
+@@ -7,6 +7,31 @@
+     "testDir": "../../config.tests",
+ 
+     "libraries": {
++        "wayland-client": {
++            "label": "Wayland client library",
++            "headers": "wayland-version.h",
++            "test": {
++                "main": [
++                    "#if WAYLAND_VERSION_MAJOR < 1",
++                    "# error Wayland 1.8.0 or higher required",
++                    "#endif",
++                    "#if WAYLAND_VERSION_MAJOR == 1",
++                    "# if WAYLAND_VERSION_MINOR < 8",
++                    "#  error Wayland 1.8.0 or higher required",
++                    "# endif",
++                    "# if WAYLAND_VERSION_MINOR == 8",
++                    "#  if WAYLAND_VERSION_MICRO < 0",
++                    "#   error Wayland 1.8.0 or higher required",
++                    "#  endif",
++                    "# endif",
++                    "#endif"
++                 ]
++            },
++            "sources": [
++                { "type": "pkgConfig", "args": "wayland-client" },
++                "-lwayland-client"
++            ]
++        },
+         "wayland-server": {
+             "label": "wayland-server",
+             "headers": "wayland-version.h",
+@@ -151,8 +176,7 @@
+                     "#endif"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "dmabuf-client-buffer": {
+             "label": "Linux Client dma-buf Buffer Sharing",
+@@ -176,8 +200,7 @@
+                     "return 0;"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "vulkan-server-buffer": {
+             "label": "Vulkan Buffer Sharing",
+@@ -195,7 +218,8 @@
+                     "exportAllocInfo.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR;",
+                     "return 0;"
+                 ]
+-            }
++            },
++            "use": "wayland-client"
+         }
+     },
+ 
+diff --git a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
+index 7889f575..64140672 100644
+--- a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
++++ b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
+@@ -40,6 +40,7 @@
+ #include "qwaylandeglwindow.h"
+ 
+ #include <QtWaylandClient/private/qwaylandscreen_p.h>
++#include <QtWaylandClient/private/qwaylandsurface_p.h>
+ #include "qwaylandglcontext.h"
+ 
+ #include <QtEglSupport/private/qeglconvenience_p.h>
+@@ -124,6 +125,7 @@ void QWaylandEglWindow::updateSurface(bool create)
+         }
+         mOffset = QPoint();
+     } else {
++        QReadLocker locker(&mSurfaceLock);
+         if (m_waylandEglWindow) {
+             int current_width, current_height;
+             static bool disableResizeCheck = qgetenv("QT_WAYLAND_DISABLE_RESIZECHECK").toInt();
+@@ -131,14 +133,16 @@ void QWaylandEglWindow::updateSurface(bool create)
+             if (!disableResizeCheck) {
+                 wl_egl_window_get_attached_size(m_waylandEglWindow, &current_width, &current_height);
+             }
+-            if (disableResizeCheck || (current_width != sizeWithMargins.width() || current_height != sizeWithMargins.height())) {
++            if (disableResizeCheck || (current_width != sizeWithMargins.width() || current_height != sizeWithMargins.height()) || m_requestedSize != sizeWithMargins) {
+                 wl_egl_window_resize(m_waylandEglWindow, sizeWithMargins.width(), sizeWithMargins.height(), mOffset.x(), mOffset.y());
++                m_requestedSize = sizeWithMargins;
+                 mOffset = QPoint();
+ 
+                 m_resize = true;
+             }
+-        } else if (create && wlSurface()) {
+-            m_waylandEglWindow = wl_egl_window_create(wlSurface(), sizeWithMargins.width(), sizeWithMargins.height());
++        } else if (create && mSurface) {
++            m_waylandEglWindow = wl_egl_window_create(mSurface->object(), sizeWithMargins.width(), sizeWithMargins.height());
++            m_requestedSize = sizeWithMargins;
+         }
+ 
+         if (!m_eglSurface && m_waylandEglWindow && create) {
+diff --git a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
+index 5b1f4d56..0079dfef 100644
+--- a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
++++ b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
+@@ -88,6 +88,7 @@ private:
+     mutable QOpenGLFramebufferObject *m_contentFBO = nullptr;
+ 
+     QSurfaceFormat m_format;
++    QSize m_requestedSize;
+ };
+ 
+ }
+diff --git a/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h b/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
+index 56a710c3..c6a8b6c6 100644
+--- a/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
++++ b/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
+@@ -41,6 +41,8 @@
+ #include <QtCore/QTextStream>
+ #include <QtGui/QOpenGLTexture>
+ 
++#include <array>
++
+ #include <EGL/egl.h>
+ #include <EGL/eglext.h>
+ 
+diff --git a/qtwayland/src/plugins/decorations/bradient/main.cpp b/qtwayland/src/plugins/decorations/bradient/main.cpp
+index e75fda3c..fa885143 100644
+--- a/qtwayland/src/plugins/decorations/bradient/main.cpp
++++ b/qtwayland/src/plugins/decorations/bradient/main.cpp
+@@ -164,13 +164,10 @@ void QWaylandBradientDecoration::paint(QPaintDevice *device)
+     // Window icon
+     QIcon icon = waylandWindow()->windowIcon();
+     if (!icon.isNull()) {
+-        QPixmap pixmap = icon.pixmap(QSize(128, 128));
+-        QPixmap scaled = pixmap.scaled(22, 22, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+-
+         QRectF iconRect(0, 0, 22, 22);
+-        p.drawPixmap(iconRect.adjusted(margins().left() + BUTTON_SPACING, 4,
+-                                       margins().left() + BUTTON_SPACING, 4),
+-                     scaled, iconRect);
++        iconRect.adjust(margins().left() + BUTTON_SPACING, 4,
++                        margins().left() + BUTTON_SPACING, 4),
++        icon.paint(&p, iconRect.toRect());
+     }
+ 
+     // Window title
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
+index 85d25e3c..60bdd491 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
+@@ -47,18 +47,21 @@ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
+-QWaylandXdgPopupV5::QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow *window)
++QWaylandXdgPopupV5::QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow* parent, QWaylandWindow *window)
+     : QWaylandShellSurface(window)
+     , QtWayland::xdg_popup_v5(popup)
++    , m_parent(parent)
+     , m_window(window)
+ {
+     if (window->display()->windowExtension())
+         m_extendedWindow = new QWaylandExtendedSurface(window);
++    m_parent->addChildPopup(m_window);
+ }
+ 
+ QWaylandXdgPopupV5::~QWaylandXdgPopupV5()
+ {
+     xdg_popup_destroy(object());
++    m_parent->removeChildPopup(m_window);
+     delete m_extendedWindow;
+ }
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
+index 7494f6a6..d85f130b 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
+@@ -70,7 +70,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgPopupV5 : public QWaylandShellSurface
+ {
+     Q_OBJECT
+ public:
+-    QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow *window);
++    QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow* parent, QWaylandWindow *window);
+     ~QWaylandXdgPopupV5() override;
+ 
+ protected:
+@@ -78,6 +78,7 @@ protected:
+ 
+ private:
+     QWaylandExtendedSurface *m_extendedWindow = nullptr;
++    QWaylandWindow *m_parent = nullptr;
+     QWaylandWindow *m_window = nullptr;
+ };
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
+index 7e242c4a..def8452a 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
+@@ -84,7 +84,7 @@ QWaylandXdgPopupV5 *QWaylandXdgShellV5::createXdgPopup(QWaylandWindow *window, Q
+     int x = position.x() + parentWindow->frameMargins().left();
+     int y = position.y() + parentWindow->frameMargins().top();
+ 
+-    auto popup = new QWaylandXdgPopupV5(get_xdg_popup(window->wlSurface(), parentSurface, seat, m_popupSerial, x, y), window);
++    auto popup = new QWaylandXdgPopupV5(get_xdg_popup(window->wlSurface(), parentSurface, seat, m_popupSerial, x, y), parentWindow, window);
+     m_popups.append(window);
+     QObject::connect(popup, &QWaylandXdgPopupV5::destroyed, [this, window](){
+         m_popups.removeOne(window);
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
+index 4e25949f..cfc60939 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
+@@ -85,13 +85,6 @@ QWaylandShellSurface *QWaylandXdgShellV5Integration::createShellSurface(QWayland
+     return m_xdgShell->createXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellV5Integration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) {
+-    if (newFocus && qobject_cast<QWaylandXdgPopupV5 *>(newFocus->shellSurface()))
+-        m_display->handleWindowActivated(newFocus);
+-    if (oldFocus && qobject_cast<QWaylandXdgPopupV5 *>(oldFocus->shellSurface()))
+-        m_display->handleWindowDeactivated(oldFocus);
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
+index ce6bdb9e..aed88670 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
+@@ -67,7 +67,6 @@ public:
+     QWaylandXdgShellV5Integration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShellV5> m_xdgShell;
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
+index 8c371661..151c78e3 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
+@@ -174,6 +174,7 @@ QWaylandXdgSurfaceV6::Popup::Popup(QWaylandXdgSurfaceV6 *xdgSurface, QWaylandXdg
+     , m_xdgSurface(xdgSurface)
+     , m_parent(parent)
+ {
++    m_parent->window()->addChildPopup(m_xdgSurface->window());
+ }
+ 
+ QWaylandXdgSurfaceV6::Popup::~Popup()
+@@ -181,6 +182,8 @@ QWaylandXdgSurfaceV6::Popup::~Popup()
+     if (isInitialized())
+         destroy();
+ 
++    m_parent->window()->removeChildPopup(m_xdgSurface->window());
++
+     if (m_grabbing) {
+         auto *shell = m_xdgSurface->m_shell;
+         Q_ASSERT(shell->m_topmostGrabbingPopup == this);
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
+index 03164316..e8da8ba1 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
+@@ -68,20 +68,6 @@ QWaylandShellSurface *QWaylandXdgShellV6Integration::createShellSurface(QWayland
+     return m_xdgShell->getXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellV6Integration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus)
+-{
+-    if (newFocus) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurfaceV6 *>(newFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowActivated(newFocus);
+-    }
+-    if (oldFocus && qobject_cast<QWaylandXdgSurfaceV6 *>(oldFocus->shellSurface())) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurfaceV6 *>(oldFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowDeactivated(oldFocus);
+-    }
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
+index 261f8cbb..c1bcd5c6 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
+@@ -65,7 +65,6 @@ public:
+     QWaylandXdgShellV6Integration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShellV6> m_xdgShell;
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
+index f3e3c330..fa6d5808 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
+@@ -67,11 +67,6 @@ QWaylandXdgSurface::Toplevel::Toplevel(QWaylandXdgSurface *xdgSurface)
+ 
+ QWaylandXdgSurface::Toplevel::~Toplevel()
+ {
+-    if (m_applied.states & Qt::WindowActive) {
+-        QWaylandWindow *window = m_xdgSurface->window();
+-        window->display()->handleWindowDeactivated(window);
+-    }
+-
+     // The protocol spec requires that the decoration object is deleted before xdg_toplevel.
+     delete m_decoration;
+     m_decoration = nullptr;
+@@ -85,16 +80,15 @@ void QWaylandXdgSurface::Toplevel::applyConfigure()
+     if (!(m_applied.states & (Qt::WindowMaximized|Qt::WindowFullScreen)))
+         m_normalSize = m_xdgSurface->m_window->windowFrameGeometry().size();
+ 
+-    if ((m_pending.states & Qt::WindowActive) && !(m_applied.states & Qt::WindowActive))
++    if ((m_pending.states & Qt::WindowActive) && !(m_applied.states & Qt::WindowActive)
++        && !m_xdgSurface->m_window->display()->isKeyboardAvailable())
+         m_xdgSurface->m_window->display()->handleWindowActivated(m_xdgSurface->m_window);
+ 
+-    if (!(m_pending.states & Qt::WindowActive) && (m_applied.states & Qt::WindowActive))
++    if (!(m_pending.states & Qt::WindowActive) && (m_applied.states & Qt::WindowActive)
++        && !m_xdgSurface->m_window->display()->isKeyboardAvailable())
+         m_xdgSurface->m_window->display()->handleWindowDeactivated(m_xdgSurface->m_window);
+ 
+-    // TODO: none of the other plugins send WindowActive either, but is it on purpose?
+-    Qt::WindowStates statesWithoutActive = m_pending.states & ~Qt::WindowActive;
+-
+-    m_xdgSurface->m_window->handleWindowStatesChanged(statesWithoutActive);
++    m_xdgSurface->m_window->handleWindowStatesChanged(m_pending.states);
+ 
+     if (m_pending.size.isEmpty()) {
+         // An empty size in the configure means it's up to the client to choose the size
+@@ -105,8 +99,6 @@ void QWaylandXdgSurface::Toplevel::applyConfigure()
+         m_xdgSurface->m_window->resizeFromApplyConfigure(m_pending.size);
+     }
+ 
+-    m_xdgSurface->setSizeHints();
+-
+     m_applied = m_pending;
+     qCDebug(lcQpaWayland) << "Applied pending xdg_toplevel configure event:" << m_applied.size << m_applied.states;
+ }
+@@ -203,12 +195,17 @@ QtWayland::xdg_toplevel::resize_edge QWaylandXdgSurface::Toplevel::convertToResi
+                 | ((edges & Qt::RightEdge) ? resize_edge_right : 0));
+ }
+ 
+-QWaylandXdgSurface::Popup::Popup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parent,
++QWaylandXdgSurface::Popup::Popup(QWaylandXdgSurface *xdgSurface, QWaylandWindow *parent,
+                                  QtWayland::xdg_positioner *positioner)
+-    : xdg_popup(xdgSurface->get_popup(parent->object(), positioner->object()))
+-    , m_xdgSurface(xdgSurface)
++    : m_xdgSurface(xdgSurface)
++    , m_parentXdgSurface(qobject_cast<QWaylandXdgSurface *>(parent->shellSurface()))
+     , m_parent(parent)
+ {
++
++    init(xdgSurface->get_popup(m_parentXdgSurface ? m_parentXdgSurface->object() : nullptr, positioner->object()));
++    if (m_parent) {
++        m_parent->addChildPopup(m_xdgSurface->window());
++    }
+ }
+ 
+ QWaylandXdgSurface::Popup::~Popup()
+@@ -216,10 +213,24 @@ QWaylandXdgSurface::Popup::~Popup()
+     if (isInitialized())
+         destroy();
+ 
++    if (m_parent) {
++        m_parent->removeChildPopup(m_xdgSurface->window());
++    }
++
+     if (m_grabbing) {
+         auto *shell = m_xdgSurface->m_shell;
+         Q_ASSERT(shell->m_topmostGrabbingPopup == this);
+-        shell->m_topmostGrabbingPopup = m_parent->m_popup;
++        shell->m_topmostGrabbingPopup = m_parentXdgSurface ? m_parentXdgSurface->m_popup : nullptr;
++        m_grabbing = false;
++
++        // Synthesize Qt enter/leave events for popup
++        QWindow *leave = nullptr;
++        if (m_xdgSurface && m_xdgSurface->window())
++            leave = m_xdgSurface->window()->window();
++        QWindowSystemInterface::handleLeaveEvent(leave);
++
++        if (QWindow *enter = QGuiApplication::topLevelAt(QCursor::pos()))
++            QWindowSystemInterface::handleEnterEvent(enter, enter->mapFromGlobal(QCursor::pos()), QCursor::pos());
+     }
+ }
+ 
+@@ -257,6 +268,7 @@ QWaylandXdgSurface::QWaylandXdgSurface(QWaylandXdgShell *shell, ::xdg_surface *s
+                 m_toplevel->set_parent(parentXdgSurface->m_toplevel->object());
+         }
+     }
++    setSizeHints();
+ }
+ 
+ QWaylandXdgSurface::~QWaylandXdgSurface()
+@@ -400,8 +412,6 @@ void QWaylandXdgSurface::setPopup(QWaylandWindow *parent)
+ {
+     Q_ASSERT(!m_toplevel && !m_popup);
+ 
+-    auto parentXdgSurface = static_cast<QWaylandXdgSurface *>(parent->shellSurface());
+-
+     auto positioner = new QtWayland::xdg_positioner(m_shell->create_positioner());
+     // set_popup expects a position relative to the parent
+     QPoint transientPos = m_window->geometry().topLeft(); // this is absolute
+@@ -414,8 +424,9 @@ void QWaylandXdgSurface::setPopup(QWaylandWindow *parent)
+     positioner->set_anchor(QtWayland::xdg_positioner::anchor_top_left);
+     positioner->set_gravity(QtWayland::xdg_positioner::gravity_bottom_right);
+     positioner->set_size(m_window->geometry().width(), m_window->geometry().height());
+-    m_popup = new Popup(this, parentXdgSurface, positioner);
++    m_popup = new Popup(this, parent, positioner);
+     positioner->destroy();
++
+     delete positioner;
+ }
+ 
+@@ -437,6 +448,23 @@ void QWaylandXdgSurface::setGrabPopup(QWaylandWindow *parent, QWaylandInputDevic
+     }
+     setPopup(parent);
+     m_popup->grab(device, serial);
++
++    // Synthesize Qt enter/leave events for popup
++    if (!parent)
++        return;
++    QWindow *current = QGuiApplication::topLevelAt(QCursor::pos());
++    QWindow *leave = parent->window();
++    if (current != leave)
++        return;
++
++    QWindowSystemInterface::handleLeaveEvent(leave);
++
++    QWindow *enter = nullptr;
++    if (m_popup && m_popup->m_xdgSurface && m_popup->m_xdgSurface->window())
++        enter = m_popup->m_xdgSurface->window()->window();
++
++    if (enter)
++        QWindowSystemInterface::handleEnterEvent(enter, enter->mapFromGlobal(QCursor::pos()), QCursor::pos());
+ }
+ 
+ void QWaylandXdgSurface::xdg_surface_configure(uint32_t serial)
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
+index 96785205..4b518f0a 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
+@@ -131,14 +131,15 @@ private:
+ 
+     class Popup : public QtWayland::xdg_popup {
+     public:
+-        Popup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parent, QtWayland::xdg_positioner *positioner);
++        Popup(QWaylandXdgSurface *xdgSurface, QWaylandWindow *parent, QtWayland::xdg_positioner *positioner);
+         ~Popup() override;
+ 
+         void grab(QWaylandInputDevice *seat, uint serial);
+         void xdg_popup_popup_done() override;
+ 
+         QWaylandXdgSurface *m_xdgSurface = nullptr;
+-        QWaylandXdgSurface *m_parent = nullptr;
++        QWaylandXdgSurface *m_parentXdgSurface = nullptr;
++        QWaylandWindow *m_parent = nullptr;
+         bool m_grabbing = false;
+     };
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
+index 8769d971..da0dd6a7 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
+@@ -69,20 +69,6 @@ QWaylandShellSurface *QWaylandXdgShellIntegration::createShellSurface(QWaylandWi
+     return m_xdgShell->getXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellIntegration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus)
+-{
+-    if (newFocus) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurface *>(newFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowActivated(newFocus);
+-    }
+-    if (oldFocus && qobject_cast<QWaylandXdgSurface *>(oldFocus->shellSurface())) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurface *>(oldFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowDeactivated(oldFocus);
+-    }
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
+index b6caa6c9..2f929f98 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
+@@ -65,7 +65,6 @@ public:
+     QWaylandXdgShellIntegration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShell> m_xdgShell;
+diff --git a/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp b/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
+index 526d0ef4..f50ccf30 100644
+--- a/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
++++ b/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
+@@ -39,7 +39,10 @@
+ 
+ #include "qwaylandinputmethodeventbuilder_p.h"
+ 
++#include <QBrush>
++#include <QGuiApplication>
+ #include <QInputMethod>
++#include <QPalette>
+ #include <QTextCharFormat>
+ 
+ #ifdef QT_BUILD_WAYLANDCOMPOSITOR_LIB
+@@ -81,32 +84,38 @@ void QWaylandInputMethodEventBuilder::addPreeditStyling(uint32_t index, uint32_t
+     QTextCharFormat format;
+ 
+     switch (style) {
+-    case 0:
+-    case 1:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_NONE:
++        break;
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_DEFAULT:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_UNDERLINE:
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-    case 2:
+-    case 3:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_ACTIVE:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_INACTIVE:
+         format.setFontWeight(QFont::Bold);
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-    case 4:
+-        format.setFontUnderline(true);
+-        format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+-        m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_HIGHLIGHT:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_SELECTION:
++        {
++            format.setFontUnderline(true);
++            format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
++            QPalette palette = qApp->palette();
++            format.setBackground(QBrush(palette.color(QPalette::Active, QPalette::Highlight)));
++            format.setForeground(QBrush(palette.color(QPalette::Active, QPalette::HighlightedText)));
++            m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
++        }
+         break;
+-    case 5:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_INCORRECT:
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::WaveUnderline);
+         format.setUnderlineColor(QColor(Qt::red));
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-//    case QtWayland::wl_text_input::preedit_style_selection:
+-//    case QtWayland::wl_text_input::preedit_style_none:
+     default:
+         break;
+     }
+@@ -153,7 +162,7 @@ QInputMethodEvent QWaylandInputMethodEventBuilder::buildPreedit(const QString &t
+ 
+     if (m_preeditCursor < 0) {
+         attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, 0, QVariant()));
+-    } else if (m_preeditCursor > 0) {
++    } else {
+         attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, indexFromWayland(text, m_preeditCursor), 1, QVariant()));
+     }
+ 
+diff --git a/qtwayland/src/shared/qwaylandmimehelper.cpp b/qtwayland/src/shared/qwaylandmimehelper.cpp
+index a5fdd34d..e2fe1928 100644
+--- a/qtwayland/src/shared/qwaylandmimehelper.cpp
++++ b/qtwayland/src/shared/qwaylandmimehelper.cpp
+@@ -60,7 +60,7 @@ QByteArray QWaylandMimeHelper::getByteArray(QMimeData *mimeData, const QString &
+             buf.open(QIODevice::ReadWrite);
+             QByteArray fmt = "BMP";
+             if (mimeType.startsWith(QLatin1String("image/"))) {
+-                QByteArray imgFmt = mimeType.mid(6).toUpper().toLatin1();
++                QByteArray imgFmt = mimeType.mid(6).toLower().toLatin1();
+                 if (QImageWriter::supportedImageFormats().contains(imgFmt))
+                     fmt = imgFmt;
+             }
+@@ -74,7 +74,7 @@ QByteArray QWaylandMimeHelper::getByteArray(QMimeData *mimeData, const QString &
+         QList<QUrl> urls = mimeData->urls();
+         for (int i = 0; i < urls.count(); ++i) {
+             content.append(urls.at(i).toEncoded());
+-            content.append('\n');
++            content.append("\r\n");
+         }
+     } else {
+         content = mimeData->data(mimeType);
+diff --git a/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp b/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
+index 1568b3b9..067410d0 100644
+--- a/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
++++ b/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
+@@ -35,7 +35,7 @@
+ 
+ using namespace MockCompositor;
+ 
+-constexpr int dataDeviceVersion = 1;
++constexpr int dataDeviceVersion = 3;
+ 
+ class DataDeviceCompositor : public DefaultCompositor {
+ public:
+diff --git a/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp b/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
+index 9312c2e5..2ea382f1 100644
+--- a/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
++++ b/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
+@@ -73,6 +73,7 @@ private slots:
+     void multiTouch();
+     void multiTouchUpAndMotionFrame();
+     void tapAndMoveInSameFrame();
++    void cancelTouch();
+ };
+ 
+ void tst_seatv5::bindsToSeat()
+@@ -646,5 +647,34 @@ void tst_seatv5::tapAndMoveInSameFrame()
+     QTRY_COMPARE(window.m_events.last().touchPoints.first().state(), Qt::TouchPointState::TouchPointReleased);
+ }
+ 
++void tst_seatv5::cancelTouch()
++{
++    TouchWindow window;
++    QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
++
++    exec([=] {
++        auto *t = touch();
++        auto *c = client();
++        t->sendDown(xdgToplevel()->surface(), {32, 32}, 1);
++        t->sendFrame(c);
++        t->sendCancel(c);
++        t->sendFrame(c);
++    });
++
++    QTRY_VERIFY(!window.m_events.empty());
++    {
++        auto e = window.m_events.takeFirst();
++        QCOMPARE(e.type, QEvent::TouchBegin);
++        QCOMPARE(e.touchPointStates, Qt::TouchPointPressed);
++        QCOMPARE(e.touchPoints.length(), 1);
++        QCOMPARE(e.touchPoints.first().pos(), QPointF(32-window.frameMargins().left(), 32-window.frameMargins().top()));
++    }
++    {
++        auto e = window.m_events.takeFirst();
++        QCOMPARE(e.type, QEvent::TouchCancel);
++        QCOMPARE(e.touchPoints.length(), 0);
++    }
++}
++
+ QCOMPOSITOR_TEST_MAIN(tst_seatv5)
+ #include "tst_seatv5.moc"
+diff --git a/qtwayland/tests/auto/client/shared/corecompositor.cpp b/qtwayland/tests/auto/client/shared/corecompositor.cpp
+index 5c6c83ba..fa9b7662 100644
+--- a/qtwayland/tests/auto/client/shared/corecompositor.cpp
++++ b/qtwayland/tests/auto/client/shared/corecompositor.cpp
+@@ -27,6 +27,7 @@
+ ****************************************************************************/
+ 
+ #include "corecompositor.h"
++#include <thread>
+ 
+ namespace MockCompositor {
+ 
+diff --git a/qtwayland/tests/auto/client/shared/coreprotocol.cpp b/qtwayland/tests/auto/client/shared/coreprotocol.cpp
+index 0d988521..d1a2e7cb 100644
+--- a/qtwayland/tests/auto/client/shared/coreprotocol.cpp
++++ b/qtwayland/tests/auto/client/shared/coreprotocol.cpp
+@@ -451,6 +451,13 @@ void Touch::sendFrame(wl_client *client)
+         send_frame(r->handle);
+ }
+ 
++void Touch::sendCancel(wl_client *client)
++{
++    const auto touchResources = resourceMap().values(client);
++    for (auto *r : touchResources)
++        send_cancel(r->handle);
++}
++
+ uint Keyboard::sendEnter(Surface *surface)
+ {
+     auto serial = m_seat->m_compositor->nextSerial();
+diff --git a/qtwayland/tests/auto/client/shared/coreprotocol.h b/qtwayland/tests/auto/client/shared/coreprotocol.h
+index a1af137a..210d8ddb 100644
+--- a/qtwayland/tests/auto/client/shared/coreprotocol.h
++++ b/qtwayland/tests/auto/client/shared/coreprotocol.h
+@@ -158,7 +158,7 @@ class WlCompositor : public Global, public QtWaylandServer::wl_compositor
+ {
+     Q_OBJECT
+ public:
+-    explicit WlCompositor(CoreCompositor *compositor, int version = 3)
++    explicit WlCompositor(CoreCompositor *compositor, int version = 4)
+         : QtWaylandServer::wl_compositor(compositor->m_display, version)
+         , m_compositor(compositor)
+     {}
+@@ -364,6 +364,7 @@ public:
+     uint sendUp(wl_client *client, int id);
+     void sendMotion(wl_client *client, const QPointF &position, int id);
+     void sendFrame(wl_client *client);
++    void sendCancel(wl_client *client);
+ 
+     Seat *m_seat = nullptr;
+ };
+diff --git a/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp b/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
+index a415cbf5..b1d3d07d 100644
+--- a/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
++++ b/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
+@@ -342,7 +342,7 @@ Compositor::Compositor(MockCompositor *mockCompositor)
+         exit(EXIT_FAILURE);
+     }
+ 
+-    wl_global_create(m_display, &wl_compositor_interface, 1, this, bindCompositor);
++    wl_global_create(m_display, &wl_compositor_interface, 4, this, bindCompositor);
+ 
+     m_data_device_manager.reset(new DataDeviceManager(this, m_display));
+ 
+diff --git a/qtwayland/tests/auto/client/shared_old/mocksurface.cpp b/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
+index e9df5f90..c3246e4a 100644
+--- a/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
++++ b/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
+@@ -125,6 +125,16 @@ void Surface::surface_damage(Resource *resource,
+     Q_UNUSED(height);
+ }
+ 
++void Surface::surface_damage_buffer(Resource *resource,
++                                    int32_t x, int32_t y, int32_t width, int32_t height)
++{
++    Q_UNUSED(resource);
++    Q_UNUSED(x);
++    Q_UNUSED(y);
++    Q_UNUSED(width);
++    Q_UNUSED(height);
++}
++
+ void Surface::surface_frame(Resource *resource,
+                             uint32_t callback)
+ {
+diff --git a/qtwayland/tests/auto/client/shared_old/mocksurface.h b/qtwayland/tests/auto/client/shared_old/mocksurface.h
+index 949dc23d..d176837e 100644
+--- a/qtwayland/tests/auto/client/shared_old/mocksurface.h
++++ b/qtwayland/tests/auto/client/shared_old/mocksurface.h
+@@ -65,6 +65,8 @@ protected:
+                         struct wl_resource *buffer, int x, int y) override;
+     void surface_damage(Resource *resource,
+                         int32_t x, int32_t y, int32_t width, int32_t height) override;
++    void surface_damage_buffer(Resource *resource,
++                               int32_t x, int32_t y, int32_t width, int32_t height) override;
+     void surface_frame(Resource *resource,
+                        uint32_t callback) override;
+     void surface_commit(Resource *resource) override;
+diff --git a/qtwayland/tests/auto/client/surface/tst_surface.cpp b/qtwayland/tests/auto/client/surface/tst_surface.cpp
+index 95e4e609..60c672ce 100644
+--- a/qtwayland/tests/auto/client/surface/tst_surface.cpp
++++ b/qtwayland/tests/auto/client/surface/tst_surface.cpp
+@@ -129,6 +129,10 @@ void tst_surface::waitForFrameCallbackGl()
+     // Make sure we follow frame callbacks for some frames
+     for (int i = 0; i < 5; ++i) {
+         xdgPingAndWaitForPong(); // Make sure things have happened on the client
++        if (!qEnvironmentVariableIntValue("QT_WAYLAND_DISABLE_WINDOWDECORATION") && i == 0) {
++            QCOMPARE(bufferSpy.count(), 1);
++            bufferSpy.removeFirst();
++        }
+         exec([&] {
+             QVERIFY(bufferSpy.empty()); // Make sure no extra buffers have arrived
+             QVERIFY(!xdgToplevel()->surface()->m_waitingFrameCallbacks.empty());
+diff --git a/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp b/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
+index 2277bbb8..747875b4 100644
+--- a/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
++++ b/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
+@@ -31,6 +31,7 @@
+ #include <QtGui/QOpenGLWindow>
+ #include <QtGui/qpa/qplatformnativeinterface.h>
+ #include <QtWaylandClient/private/wayland-wayland-client-protocol.h>
++#include <QtWaylandClient/private/qwaylandwindow_p.h>
+ 
+ using namespace MockCompositor;
+ 
+@@ -45,6 +46,7 @@ private slots:
+     void configureStates();
+     void popup();
+     void tooltipOnPopup();
++    void tooltipAndSiblingPopup();
+     void switchPopups();
+     void hidePopupParent();
+     void pongs();
+@@ -138,6 +140,7 @@ void tst_xdgshell::configureSize()
+ 
+ void tst_xdgshell::configureStates()
+ {
++    QVERIFY(qputenv("QT_WAYLAND_FRAME_CALLBACK_TIMEOUT", "0"));
+     QRasterWindow window;
+     window.resize(64, 48);
+     window.show();
+@@ -154,9 +157,12 @@ void tst_xdgshell::configureStates()
+     // Toplevel windows don't know their position on xdg-shell
+ //    QCOMPARE(window.frameGeometry().topLeft(), QPoint()); // TODO: this doesn't currently work when window decorations are enabled
+ 
+-//    QEXPECT_FAIL("", "configure has already been acked, we shouldn't have to wait for isActive", Continue);
+-//    QVERIFY(window.isActive());
+-    QTRY_VERIFY(window.isActive()); // Just make sure it eventually get's set correctly
++    // window.windowstate() is driven by keyboard focus, however for decorations we want to follow
++    // XDGShell this is internal to QtWayland so it is queried directly
++    auto waylandWindow = static_cast<QtWaylandClient::QWaylandWindow *>(window.handle());
++    Q_ASSERT(waylandWindow);
++    QTRY_VERIFY(waylandWindow->windowStates().testFlag(
++            Qt::WindowActive)); // Just make sure it eventually get's set correctly
+ 
+     const QSize screenSize(640, 480);
+     const uint maximizedSerial = exec([=] {
+@@ -186,6 +192,7 @@ void tst_xdgshell::configureStates()
+     QCOMPARE(window.windowStates(), Qt::WindowNoState);
+     QCOMPARE(window.frameGeometry().size(), windowedSize);
+ //    QCOMPARE(window.frameGeometry().topLeft(), QPoint()); // TODO: this doesn't currently work when window decorations are enabled
++    QVERIFY(qunsetenv("QT_WAYLAND_FRAME_CALLBACK_TIMEOUT"));
+ }
+ 
+ void tst_xdgshell::popup()
+@@ -340,6 +347,92 @@ void tst_xdgshell::tooltipOnPopup()
+     QCOMPOSITOR_TRY_COMPARE(xdgPopup(0), nullptr);
+ }
+ 
++void tst_xdgshell::tooltipAndSiblingPopup()
++{
++    class ToolTip : public QRasterWindow {
++    public:
++        explicit ToolTip(QWindow *parent) {
++            setTransientParent(parent);
++            setFlags(Qt::ToolTip);
++            resize(100, 100);
++            show();
++        }
++        void mousePressEvent(QMouseEvent *event) override {
++            QRasterWindow::mousePressEvent(event);
++            m_popup = new QRasterWindow;
++            m_popup->setTransientParent(transientParent());
++            m_popup->setFlags(Qt::Popup);
++            m_popup->resize(100, 100);
++            m_popup->show();
++        }
++
++        QRasterWindow *m_popup = nullptr;
++    };
++
++    class Window : public QRasterWindow {
++    public:
++        void mousePressEvent(QMouseEvent *event) override {
++            QRasterWindow::mousePressEvent(event);
++            m_tooltip = new ToolTip(this);
++        }
++        ToolTip *m_tooltip = nullptr;
++    };
++
++    Window window;
++    window.resize(200, 200);
++    window.show();
++
++    QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
++    exec([=] { xdgToplevel()->sendCompleteConfigure(); });
++    QCOMPOSITOR_TRY_VERIFY(xdgToplevel()->m_xdgSurface->m_committedConfigureSerial);
++
++    exec([=] {
++        auto *surface = xdgToplevel()->surface();
++        auto *p = pointer();
++        auto *c = client();
++        p->sendEnter(surface, {100, 100});
++        p->sendFrame(c);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_pressed);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_released);
++        p->sendFrame(c);
++        p->sendLeave(surface);
++        p->sendFrame(c);
++    });
++
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup());
++    exec([=] { xdgPopup()->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup()->m_xdgSurface->m_committedConfigureSerial);
++    QCOMPOSITOR_TRY_VERIFY(!xdgPopup()->m_grabbed);
++
++    exec([=] {
++        auto *surface = xdgPopup()->surface();
++        auto *p = pointer();
++        auto *c = client();
++        p->sendEnter(surface, {100, 100});
++        p->sendFrame(c);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_pressed);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_released);
++        p->sendFrame(c);
++    });
++
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1));
++    exec([=] { xdgPopup(1)->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1)->m_xdgSurface->m_committedConfigureSerial);
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1)->m_grabbed);
++
++    // Close the middle tooltip (it should not close the sibling popup)
++    window.m_tooltip->close();
++
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(1), nullptr);
++    // Verify the remaining xdg surface is a grab popup..
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(0));
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(0)->m_grabbed);
++
++    window.m_tooltip->m_popup->close();
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(1), nullptr);
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(0), nullptr);
++}
++
+ // QTBUG-65680
+ void tst_xdgshell::switchPopups()
+ {
+@@ -505,7 +598,7 @@ void tst_xdgshell::minMaxSize()
+     window.show();
+     QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
+ 
+-    exec([=] { xdgToplevel()->sendCompleteConfigure(); });
++    // we don't roundtrip with our configuration the initial commit should be correct
+ 
+     QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.minSize, QSize(100, 100));
+     QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.maxSize, QSize(1000, 1000));
+Submodule qtwebchannel 618422ee..f8949655:
+diff --git a/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp b/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
+index 536eb5c..898d769 100644
+--- a/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
++++ b/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
+@@ -186,8 +186,6 @@ Q_DECLARE_TYPEINFO(OverloadResolutionCandidate, Q_MOVABLE_TYPE);
+ QMetaObjectPublisher::QMetaObjectPublisher(QWebChannel *webChannel)
+     : QObject(webChannel)
+     , webChannel(webChannel)
+-    , signalHandler(this)
+-    , clientIsIdle(false)
+     , blockUpdates(false)
+     , propertyUpdatesInitialized(false)
+ {
+@@ -301,17 +299,17 @@ QJsonObject QMetaObjectPublisher::classInfoForObject(const QObject *object, QWeb
+     return data;
+ }
+ 
+-void QMetaObjectPublisher::setClientIsIdle(bool isIdle)
++void QMetaObjectPublisher::setClientIsIdle(bool isIdle, QWebChannelAbstractTransport *transport)
+ {
+-    if (clientIsIdle == isIdle) {
+-        return;
+-    }
+-    clientIsIdle = isIdle;
+-    if (!isIdle && timer.isActive()) {
+-        timer.stop();
+-    } else if (isIdle && !timer.isActive()) {
+-        timer.start(PROPERTY_UPDATE_INTERVAL, this);
+-    }
++    transportState[transport].clientIsIdle = isIdle;
++    if (isIdle)
++        sendEnqueuedPropertyUpdates(transport);
++}
++
++bool QMetaObjectPublisher::isClientIdle(QWebChannelAbstractTransport *transport)
++{
++    auto found = transportState.find(transport);
++    return found != transportState.end() && found.value().clientIsIdle;
+ }
+ 
+ QJsonObject QMetaObjectPublisher::initializeClient(QWebChannelAbstractTransport *transport)
+@@ -333,6 +331,7 @@ QJsonObject QMetaObjectPublisher::initializeClient(QWebChannelAbstractTransport
+ 
+ void QMetaObjectPublisher::initializePropertyUpdates(const QObject *const object, const QJsonObject &objectInfo)
+ {
++    auto *signalHandler = signalHandlerFor(object);
+     foreach (const QJsonValue &propertyInfoVar, objectInfo[KEY_PROPERTIES].toArray()) {
+         const QJsonArray &propertyInfo = propertyInfoVar.toArray();
+         if (propertyInfo.size() < 2) {
+@@ -353,19 +352,19 @@ void QMetaObjectPublisher::initializePropertyUpdates(const QObject *const object
+ 
+         // Only connect for a property update once
+         if (connectedProperties.isEmpty()) {
+-            signalHandler.connectTo(object, signalIndex);
++            signalHandler->connectTo(object, signalIndex);
+         }
+ 
+         connectedProperties.insert(propertyIndex);
+     }
+ 
+     // also always connect to destroyed signal
+-    signalHandler.connectTo(object, s_destroyedSignalIndex);
++    signalHandler->connectTo(object, s_destroyedSignalIndex);
+ }
+ 
+ void QMetaObjectPublisher::sendPendingPropertyUpdates()
+ {
+-    if (blockUpdates || !clientIsIdle || pendingPropertyUpdates.isEmpty()) {
++    if (blockUpdates) {
+         return;
+     }
+ 
+@@ -415,18 +414,19 @@ void QMetaObjectPublisher::sendPendingPropertyUpdates()
+ 
+     // data does not contain specific updates
+     if (!data.isEmpty()) {
+-        setClientIsIdle(false);
+-
+         message[KEY_DATA] = data;
+-        broadcastMessage(message);
++        enqueueBroadcastMessage(message);
+     }
+ 
+     // send every property update which is not supposed to be broadcasted
+     const QHash<QWebChannelAbstractTransport*, QJsonArray>::const_iterator suend = specificUpdates.constEnd();
+     for (QHash<QWebChannelAbstractTransport*, QJsonArray>::const_iterator it = specificUpdates.constBegin(); it != suend; ++it) {
+         message[KEY_DATA] = it.value();
+-        it.key()->sendMessage(message);
++        enqueueMessage(message, it.key());
+     }
++
++    for (auto state = transportState.begin(); state != transportState.end(); ++state)
++        sendEnqueuedPropertyUpdates(state.key());
+ }
+ 
+ QVariant QMetaObjectPublisher::invokeMethod(QObject *const object, const QMetaMethod &method,
+@@ -572,7 +572,7 @@ void QMetaObjectPublisher::signalEmitted(const QObject *object, const int signal
+         }
+     } else {
+         pendingPropertyUpdates[object][signalIndex] = arguments;
+-        if (clientIsIdle && !blockUpdates && !timer.isActive()) {
++        if (!blockUpdates && !timer.isActive()) {
+             timer.start(PROPERTY_UPDATE_INTERVAL, this);
+         }
+     }
+@@ -590,7 +590,7 @@ void QMetaObjectPublisher::objectDestroyed(const QObject *object)
+     // only remove from handler when we initialized the property updates
+     // cf: https://bugreports.qt.io/browse/QTBUG-60250
+     if (propertyUpdatesInitialized) {
+-        signalHandler.remove(object);
++        signalHandlerFor(object)->remove(object);
+         signalToPropertyMap.remove(object);
+     }
+     pendingPropertyUpdates.remove(object);
+@@ -852,6 +852,52 @@ void QMetaObjectPublisher::broadcastMessage(const QJsonObject &message) const
+     }
+ }
+ 
++void QMetaObjectPublisher::enqueueBroadcastMessage(const QJsonObject &message)
++{
++    if (webChannel->d_func()->transports.isEmpty()) {
++        qWarning("QWebChannel is not connected to any transports, cannot send message: %s",
++                 QJsonDocument(message).toJson().constData());
++        return;
++    }
++
++    for (auto *transport : webChannel->d_func()->transports) {
++        auto &state = transportState[transport];
++        state.queuedMessages.append(message);
++    }
++}
++
++void QMetaObjectPublisher::enqueueMessage(const QJsonObject &message,
++                                          QWebChannelAbstractTransport *transport)
++{
++    auto &state = transportState[transport];
++    state.queuedMessages.append(message);
++}
++
++void QMetaObjectPublisher::sendEnqueuedPropertyUpdates(QWebChannelAbstractTransport *transport)
++{
++    auto found = transportState.find(transport);
++    if (found != transportState.end() && found.value().clientIsIdle
++        && !found.value().queuedMessages.isEmpty()) {
++
++        // If the client is connected with an in-process transport, it can
++        // happen that a message triggers a subsequent property change. In
++        // that case, we need to ensure that the queued messages have already
++        // been cleared; otherwise the recursive call will send everythig again.
++        // Case in point: The qmlwebchannel tests fail if we don't clear the
++        // queued messages before sending them out.
++        // For that same reason set the client to "busy" (aka non-idle) just
++        // right before sending out the messages; otherwise a potential
++        // "Idle" type message will not correctly restore the Idle state.
++        const auto messages = std::move(found.value().queuedMessages);
++        Q_ASSERT(found.value().queuedMessages.isEmpty());
++        found.value().clientIsIdle = false;
++
++        for (const auto &message : messages) {
++            transport->sendMessage(message);
++        }
++    }
++}
++
+ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannelAbstractTransport *transport)
+ {
+     if (!webChannel->d_func()->transports.contains(transport)) {
+@@ -866,7 +912,7 @@ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannel
+ 
+     const MessageType type = toType(message.value(KEY_TYPE));
+     if (type == TypeIdle) {
+-        setClientIsIdle(true);
++        setClientIsIdle(true, transport);
+     } else if (type == TypeInit) {
+         if (!message.contains(KEY_ID)) {
+             qWarning("JSON message object is missing the id property: %s",
+@@ -913,9 +959,9 @@ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannel
+                 return;
+             transport->sendMessage(createResponse(message.value(KEY_ID), wrapResult(result, transport)));
+         } else if (type == TypeConnectToSignal) {
+-            signalHandler.connectTo(object, message.value(KEY_SIGNAL).toInt(-1));
++            signalHandlerFor(object)->connectTo(object, message.value(KEY_SIGNAL).toInt(-1));
+         } else if (type == TypeDisconnectFromSignal) {
+-            signalHandler.disconnectFrom(object, message.value(KEY_SIGNAL).toInt(-1));
++            signalHandlerFor(object)->disconnectFrom(object, message.value(KEY_SIGNAL).toInt(-1));
+         } else if (type == TypeSetProperty) {
+             setProperty(object, message.value(KEY_PROPERTY).toInt(-1),
+                         message.value(KEY_VALUE));
+@@ -931,6 +977,7 @@ void QMetaObjectPublisher::setBlockUpdates(bool block)
+     blockUpdates = block;
+ 
+     if (!blockUpdates) {
++        timer.start(PROPERTY_UPDATE_INTERVAL, this);
+         sendPendingPropertyUpdates();
+     } else if (timer.isActive()) {
+         timer.stop();
+@@ -948,4 +995,15 @@ void QMetaObjectPublisher::timerEvent(QTimerEvent *event)
+     }
+ }
+ 
++SignalHandler<QMetaObjectPublisher> *QMetaObjectPublisher::signalHandlerFor(const QObject *object)
++{
++    auto thread = object->thread();
++    auto it = signalHandlers.find(thread);
++    if (it == signalHandlers.end()) {
++        it = signalHandlers.emplace(thread, this).first;
++        it->second.moveToThread(thread);
++    }
++    return &it->second;
++}
++
+ QT_END_NAMESPACE
+diff --git a/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h b/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
+index bbd9875..4713ef1 100644
+--- a/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
++++ b/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
+@@ -59,6 +59,9 @@
+ #include <QBasicTimer>
+ #include <QPointer>
+ #include <QJsonObject>
++#include <QQueue>
++
++#include <unordered_map>
+ 
+ #include "qwebchannelglobal.h"
+ 
+@@ -109,17 +112,36 @@ public:
+      */
+     void broadcastMessage(const QJsonObject &message) const;
+ 
++    /**
++     * Enqueue the given @p message to all known transports.
++     */
++    void enqueueBroadcastMessage(const QJsonObject &message);
++
++    /**
++     * Enqueue the given @p message to @p transport.
++     */
++    void enqueueMessage(const QJsonObject &message, QWebChannelAbstractTransport *transport);
++
++    /**
++     * If client for given @p transport is idle, send queued messaged to @p transport and then mark
++     * the client as not idle.
++     */
++    void sendEnqueuedPropertyUpdates(QWebChannelAbstractTransport *transport);
++
+     /**
+      * Serialize the QMetaObject of @p object and return it in JSON form.
+      */
+     QJsonObject classInfoForObject(const QObject *object, QWebChannelAbstractTransport *transport);
+ 
+     /**
+-     * Set the client to idle or busy, based on the value of @p isIdle.
+-     *
+-     * When the value changed, start/stop the property update timer accordingly.
++     * Set the client to idle or busy for a single @p transport, based on the value of @p isIdle.
++     */
++    void setClientIsIdle(bool isIdle, QWebChannelAbstractTransport *transport);
++
++    /**
++     * Check that client is idle for @p transport.
+      */
+-    void setClientIsIdle(bool isIdle);
++    bool isClientIdle(QWebChannelAbstractTransport *transport);
+ 
+     /**
+      * Initialize clients by sending them the class information of the registered objects.
+@@ -272,10 +294,18 @@ private:
+     friend class TestWebChannel;
+ 
+     QWebChannel *webChannel;
+-    SignalHandler<QMetaObjectPublisher> signalHandler;
++    std::unordered_map<const QThread*, SignalHandler<QMetaObjectPublisher>> signalHandlers;
++    SignalHandler<QMetaObjectPublisher> *signalHandlerFor(const QObject *object);
+ 
+-    // true when the client is idle, false otherwise
+-    bool clientIsIdle;
++    struct TransportState
++    {
++        TransportState() : clientIsIdle(false) { }
++        // true when the client is idle, false otherwise
++        bool clientIsIdle;
++        // messages to send
++        QQueue<QJsonObject> queuedMessages;
++    };
++    QHash<QWebChannelAbstractTransport *, TransportState> transportState;
+ 
+     // true when no property updates should be sent, false otherwise
+     bool blockUpdates;
+diff --git a/qtwebchannel/src/webchannel/signalhandler_p.h b/qtwebchannel/src/webchannel/signalhandler_p.h
+index 27afadb..d77373c 100644
+--- a/qtwebchannel/src/webchannel/signalhandler_p.h
++++ b/qtwebchannel/src/webchannel/signalhandler_p.h
+@@ -56,6 +56,7 @@
+ #include <QVector>
+ #include <QMetaMethod>
+ #include <QDebug>
++#include <QThread>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -71,6 +72,7 @@ static const int s_destroyedSignalIndex = QObject::staticMetaObject.indexOfMetho
+ template<class Receiver>
+ class SignalHandler : public QObject
+ {
++    Q_DISABLE_COPY(SignalHandler)
+ public:
+     SignalHandler(Receiver *receiver, QObject *parent = 0);
+ 
+@@ -268,6 +270,7 @@ int SignalHandler<Receiver>::qt_metacall(QMetaObject::Call call, int methodId, v
+     if (call == QMetaObject::InvokeMetaMethod) {
+         const QObject *object = sender();
+         Q_ASSERT(object);
++        Q_ASSERT(QThread::currentThread() == object->thread());
+         Q_ASSERT(senderSignalIndex() == methodId);
+         Q_ASSERT(m_connectionsCounter.contains(object));
+         Q_ASSERT(m_connectionsCounter.value(object).contains(methodId));
+diff --git a/qtwebchannel/tests/auto/qml/testwebchannel.cpp b/qtwebchannel/tests/auto/qml/testwebchannel.cpp
+index 9891687..3ca81c2 100644
+--- a/qtwebchannel/tests/auto/qml/testwebchannel.cpp
++++ b/qtwebchannel/tests/auto/qml/testwebchannel.cpp
+@@ -46,7 +46,11 @@ TestWebChannel::~TestWebChannel()
+ 
+ bool TestWebChannel::clientIsIdle() const
+ {
+-    return QWebChannel::d_func()->publisher->clientIsIdle;
++    for (auto *transport : QWebChannel::d_func()->transports) {
++        if (QWebChannel::d_func()->publisher->isClientIdle(transport))
++            return true;
++    }
++    return false;
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp b/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
+index 181da9e..37f989a 100644
+--- a/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
++++ b/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
+@@ -785,7 +785,7 @@ void TestWebChannel::testTransportWrapObjectProperties()
+     DummyTransport *dummyTransport = new DummyTransport(this);
+     channel.connectTo(dummyTransport);
+     channel.d_func()->publisher->initializeClient(dummyTransport);
+-    channel.d_func()->publisher->setClientIsIdle(true);
++    channel.d_func()->publisher->setClientIsIdle(true, dummyTransport);
+ 
+     QCOMPARE(channel.d_func()->publisher->transportedWrappedObjects.size(), 0);
+ 
+@@ -943,8 +943,6 @@ void TestWebChannel::testInfiniteRecursion()
+ 
+ void TestWebChannel::testAsyncObject()
+ {
+-    QSKIP("This test is broken. See QTBUG-80729");
+-
+     QWebChannel channel;
+     channel.connectTo(m_dummyTransport);
+ 
+@@ -990,6 +988,50 @@ void TestWebChannel::testAsyncObject()
+     thread.wait();
+ }
+ 
++void TestWebChannel::testPropertyMultipleTransports()
++{
++    DummyTransport transport1;
++    DummyTransport transport2;
++
++    QWebChannel channel;
++    QMetaObjectPublisher *publisher = channel.d_func()->publisher;
++
++    TestObject testObj;
++    testObj.setObjectName("testObject");
++    channel.registerObject(testObj.objectName(), &testObj);
++    channel.connectTo(&transport1);
++    channel.connectTo(&transport2);
++
++    testObj.setProp("Hello");
++
++    publisher->initializeClient(&transport1);
++    publisher->initializeClient(&transport2);
++    publisher->setClientIsIdle(true, &transport1);
++    QCOMPARE(publisher->isClientIdle(&transport1), true);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++    QVERIFY(transport1.messagesSent().isEmpty());
++    QVERIFY(transport2.messagesSent().isEmpty());
++
++    testObj.setProp("World");
++    QTRY_COMPARE_WITH_TIMEOUT(transport1.messagesSent().size(), 1u, 2000);
++    QCOMPARE(transport2.messagesSent().size(), 0u);
++    publisher->setClientIsIdle(true, &transport2);
++    QTRY_COMPARE_WITH_TIMEOUT(transport2.messagesSent().size(), 1u, 2000);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++
++    testObj.setProp("!!!");
++    publisher->setClientIsIdle(true, &transport2);
++    QCOMPARE(publisher->isClientIdle(&transport2), true);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QTRY_COMPARE_WITH_TIMEOUT(transport2.messagesSent().size(), 2u, 2000);
++    QCOMPARE(transport1.messagesSent().size(), 1u);
++    publisher->setClientIsIdle(true, &transport1);
++    QTRY_COMPARE_WITH_TIMEOUT(transport1.messagesSent().size(), 2u, 2000);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++}
++
+ class FunctionWrapper : public QObject
+ {
+     Q_OBJECT
+@@ -1082,7 +1124,7 @@ void TestWebChannel::benchInitializeClients()
+ 
+         publisher->propertyUpdatesInitialized = false;
+         publisher->signalToPropertyMap.clear();
+-        publisher->signalHandler.clear();
++        publisher->signalHandlers.clear();
+     }
+ }
+ 
+@@ -1107,7 +1149,7 @@ void TestWebChannel::benchPropertyUpdates()
+             obj->change();
+         }
+ 
+-        channel.d_func()->publisher->clientIsIdle = true;
++        channel.d_func()->publisher->setClientIsIdle(true, m_dummyTransport);
+         channel.d_func()->publisher->sendPendingPropertyUpdates();
+     }
+ }
+diff --git a/qtwebchannel/tests/auto/webchannel/tst_webchannel.h b/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
+index eae21f4..dd4e690 100644
+--- a/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
++++ b/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
+@@ -348,6 +348,7 @@ private slots:
+     void testJsonToVariant();
+     void testInfiniteRecursion();
+     void testAsyncObject();
++    void testPropertyMultipleTransports();
+     void testDeletionDuringMethodInvocation_data();
+     void testDeletionDuringMethodInvocation();
+ 
+Submodule qtwebengine f328054d...38e0df6c (commits not present)
+Submodule qtwebsockets 65850954..63fb8da1:
+diff --git a/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp b/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
+index 2affdd5..95f1194 100644
+--- a/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
++++ b/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
+@@ -273,6 +273,7 @@ void QWebSocketDataProcessor::clear()
+     if (!m_pConverterState)
+         m_pConverterState = new QTextCodec::ConverterState(QTextCodec::ConvertInvalidToNull |
+                                                            QTextCodec::IgnoreHeader);
++    frame.clear();
+ }
+ 
+ /*!
+diff --git a/qtwebsockets/src/websockets/qwebsocketprotocol.cpp b/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
+index df87a93..d0465f1 100644
+--- a/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
++++ b/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
+@@ -210,7 +210,7 @@ void QWebSocketProtocol::mask(char *payload, quint64 size, quint32 maskingKey)
+                             quint8((maskingKey & 0x0000FF00u) >> 8),
+                             quint8((maskingKey & 0x000000FFu))
+                           };
+-    int i = 0;
++    quint64 i = 0;
+     while (size-- > 0)
+         *payload++ ^= mask[i++ % 4];
+ }
diff --git a/srcpkgs/qt5/template b/srcpkgs/qt5/template
index d3821efbe378..6dddce7f3e46 100644
--- a/srcpkgs/qt5/template
+++ b/srcpkgs/qt5/template
@@ -2,11 +2,11 @@
 #
 # revbump libqtxdg after bumping patch version
 pkgname=qt5
-version=5.15.7+20221119
+version=5.15.8
+revision=1
+build_style=meta
 # commit f8c9fb304bc3e53b3aa07f962cd74e9160decccc
 # base repo: https://invent.kde.org/qt/qt/qt5
-revision=6
-build_style=meta
 hostmakedepends="cmake clang flex perl glib-devel pkg-config
  python re2c ruby which"
 makedepends="SDL2-devel Vulkan-Headers alsa-lib-devel double-conversion-devel
@@ -29,8 +29,9 @@ homepage="https://qt.io/"
 # tarball is generated with `git archive-all qt5-$version.tar.gz`
 # to keep the size smaller qtwebengine, qtwebview, qtdocgallery, qtactiveqt and qtpim
 # can be marked with the export-ignore attribute
-distfiles="https://void.johnnynator.dev/distfiles/qt5-${version}.tar.gz"
-checksum=9d57af471c78029a362276b7c99108ea009f511bb9ba6ff6cb884f6ddd255e9f
+#distfiles="https://void.johnnynator.dev/distfiles/qt5-${version}.tar.gz"
+distfiles="https://download.qt.io/archive/qt/5.15/${version}/single/qt-everywhere-opensource-src-${version}.tar.xz"
+checksum=776a9302c336671f9406a53bd30b8e36f825742b2ec44a57c08217bff0fa86b9
 python_version=2 #unverified
 replaces="qt5-doc<5.6.0 qt5-quick1<5.6.0 qt5-quick1-devel<5.6.0 qt5-webkit<5.6.0 qt5-webkit-devel<5.6.0
  qt5-enginio<5.7.1 qt5-enginio-devel<5.7.1 qt5-plugin-gtk<5.7.1 qt5-canvas3d<5.13.0"
@@ -250,7 +251,6 @@ do_configure() {
 	# opts+=" -v"
 	opts+=" -skip qtwebengine"
 	opts+=" -skip qtwebview"
-	opts+=" -skip qtdocgallery"
 	opts+=" -skip qtpim"
 	opts+=" -skip qtsystems"
 	opts+=" -skip qtspeech"

From 8a9a3478109fe1219de9c611cf524a20b37bb870 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 073/115] qtav: revbump for ffmpeg4-4.4.3

---
 srcpkgs/qtav/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtav/template b/srcpkgs/qtav/template
index 34c30b2c0c78..2d00ad104355 100644
--- a/srcpkgs/qtav/template
+++ b/srcpkgs/qtav/template
@@ -1,10 +1,10 @@
 # Template file for 'qtav'
 pkgname=qtav
 version=1.13.0
-revision=1
+revision=2
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel libass-devel libopenal-devel
+makedepends="ffmpeg4-devel libass-devel libopenal-devel
  libva-glx-devel libXv-devel pulseaudio-devel
  qt5-declarative-devel qt5-svg-devel
  qt5-quickcontrols"

From 1cf56e8d5923b58086e43a7c256b5e5f560d679b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 074/115] qtox: revbump for ffmpeg-6.0

---
 srcpkgs/qtox/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qtox/template b/srcpkgs/qtox/template
index 16019d7eaec9..5cea0b11b697 100644
--- a/srcpkgs/qtox/template
+++ b/srcpkgs/qtox/template
@@ -1,7 +1,7 @@
 # Template file for 'qtox'
 pkgname=qtox
 version=1.17.6
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DUPDATE_CHECK=OFF
  -DGIT_DESCRIBE=${version}

From 9589e7be978f1038d0f30a1ba4c323b8be831955 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 075/115] retroarch: revbump for ffmpeg-6.0

---
 srcpkgs/retroarch/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroarch/template b/srcpkgs/retroarch/template
index 28016aa0129e..20a1415913be 100644
--- a/srcpkgs/retroarch/template
+++ b/srcpkgs/retroarch/template
@@ -1,7 +1,7 @@
 # Template file for 'retroarch'
 pkgname=retroarch
 version=1.15.0
-revision=1
+revision=2
 build_style=configure
 configure_args="--prefix=/usr --sysconfdir=/etc --enable-networking
  --enable-udev --disable-builtinflac --disable-builtinglslang

From ea90609a72d97e1444f84bd8b3c252ec111038b5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 076/115] scrcpy: revbump for ffmpeg-6.0

---
 srcpkgs/scrcpy/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/scrcpy/template b/srcpkgs/scrcpy/template
index 06208c389ca9..a5de935c7def 100644
--- a/srcpkgs/scrcpy/template
+++ b/srcpkgs/scrcpy/template
@@ -1,7 +1,7 @@
 # Template file for 'scrcpy'
 pkgname=scrcpy
 version=2.1
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcompile_server=false
  -Dprebuilt_server=/usr/share/scrcpy/scrcpy-server-v${version}"

From eca5cd6fe77583c2ce2b42ec1d27db6757ab021e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 077/115] spek-alternative: revbump for ffmpeg4-4.4.3

---
 srcpkgs/spek-alternative/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/spek-alternative/template b/srcpkgs/spek-alternative/template
index d65086b8f008..05246f1b8d0c 100644
--- a/srcpkgs/spek-alternative/template
+++ b/srcpkgs/spek-alternative/template
@@ -1,11 +1,11 @@
 # Template file for 'spek-alternative'
 pkgname=spek-alternative
 version=0.8.2.3
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake gettext-devel intltool libtool pkg-config wxWidgets-common"
-makedepends="ffmpeg-devel wxWidgets-gtk3-devel"
-depends="ffmpeg"
+makedepends="ffmpeg4-devel wxWidgets-gtk3-devel"
+depends="ffmpeg4"
 short_desc="Acoustic spectrum analyser"
 maintainer="Kartik Singh <kartik.ynwa@gmail.com>"
 license="GPL-3.0-or-later"

From 1ac4bfddacb7a49ca9063b0a214c87452f28b01f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 078/115] ssr: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ssr/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/ssr/template b/srcpkgs/ssr/template
index b055b9ec0774..3448ca110eb0 100644
--- a/srcpkgs/ssr/template
+++ b/srcpkgs/ssr/template
@@ -1,11 +1,11 @@
 # Template file for 'ssr'
 pkgname=ssr
 version=0.4.4
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_QT5=ON"
 hostmakedepends="pkg-config"
-makedepends="alsa-lib-devel ffmpeg-devel glu-devel jack-devel pulseaudio-devel
+makedepends="alsa-lib-devel ffmpeg4-devel glu-devel jack-devel pulseaudio-devel
  qt5-tools-devel qt5-x11extras-devel libXinerama-devel v4l-utils-devel"
 depends="desktop-file-utils hicolor-icon-theme"
 short_desc="Simple Screen Recorder for programs and games"

From b67903ef7a88025f5da8b7aba9dce5f34ad6f882 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 079/115] sumo: revbump for ffmpeg-6.0

---
 srcpkgs/sumo/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/sumo/template b/srcpkgs/sumo/template
index 0f9b9ec815f5..a3fe134aa5ac 100644
--- a/srcpkgs/sumo/template
+++ b/srcpkgs/sumo/template
@@ -1,7 +1,7 @@
 # Template file for 'sumo'
 pkgname=sumo
 version=1.12.0
-revision=5
+revision=6
 build_style=cmake
 hostmakedepends="libgdal-tools pkg-config swig python3-setuptools"
 makedepends="python3-devel ffmpeg-devel fox-devel gl2ps-devel libgdal-devel

From 76902060201f5adef4272268dce1d5b8b84e6ce5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 080/115] synfig: revbump for ffmpeg-6.0 and mlt7

---
 srcpkgs/synfig/patches/ffmpeg6.patch | 71 ++++++++++++++++++++++++++++
 srcpkgs/synfig/template              |  6 +--
 2 files changed, 74 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/synfig/patches/ffmpeg6.patch

diff --git a/srcpkgs/synfig/patches/ffmpeg6.patch b/srcpkgs/synfig/patches/ffmpeg6.patch
new file mode 100644
index 000000000000..10780b42782f
--- /dev/null
+++ b/srcpkgs/synfig/patches/ffmpeg6.patch
@@ -0,0 +1,71 @@
+--- a/src/modules/mod_libavcodec/trgt_av.cpp	2022-10-25 09:14:12.000000000 -0400
++++ b/src/modules/mod_libavcodec/trgt_av.cpp	2023-05-05 21:34:17.899194559 -0400
+@@ -38,6 +41,7 @@
+ extern "C"
+ {
+ #ifdef HAVE_LIBAVFORMAT_AVFORMAT_H
++#	include <libavcodec/avcodec.h>
+ #	include <libavformat/avformat.h>
+ #elif defined(HAVE_AVFORMAT_H)
+ #	include <avformat.h>
+@@ -155,11 +156,11 @@
+     }
+ 
+ 	bool open_video_stream() {
+-		if (avcodec_open2(video_context, NULL, NULL) < 0) {
++		if (avcodec_open2(video_context, nullptr, nullptr) < 0) {
+ 			synfig::error("Target_LibAVCodec: could not open video codec");
+ 			// seems the calling of avcodec_free_context after error will cause crash
+ 			// so just forget about this context
+-			video_context = NULL;
++			video_context = nullptr;
+ 			close();
+ 			return false;
+         }
+@@ -234,15 +235,21 @@
+ 		close();
+ 
+ 		if (!av_registered) {
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 			av_register_all();
++#endif
+ 			av_registered = true;
+ 		}
+ 
+ 		// guess format
+-		AVOutputFormat *format = av_guess_format(NULL, filename.c_str(), NULL);
++#if LIBAVCODEC_VERSION_MAJOR < 59 // FFMPEG < 5.0
++		AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#else
++		const AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#endif
+ 		if (!format) {
+ 			synfig::warning("Target_LibAVCodec: unable to guess the output format, defaulting to MPEG");
+-			format = av_guess_format("mpeg", NULL, NULL);
++			format = av_guess_format("mpeg", nullptr, nullptr);
+ 		}
+ 		if (!format) {
+ 			synfig::error("Target_LibAVCodec: unable to find 'mpeg' output format");
+@@ -254,6 +261,7 @@
+ 		context = avformat_alloc_context();
+ 		assert(context);
+ 		context->oformat = format;
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 		if (filename.size() + 1 > sizeof(context->filename)) {
+ 			synfig::error(
+ 				"Target_LibAVCodec: filename too long, max length is %d, filename is '%s'",
+@@ -263,6 +271,14 @@
+ 			return false;
+ 		}
+ 		memcpy(context->filename, filename.c_str(), filename.size() + 1);
++#else
++		context->url = av_strndup(filename.c_str(), filename.size());
++		if (!context->url) {
++			synfig::error("Target_LibAVCodec: cannot allocate space for filename");
++			close();
++			return false;
++		}
++#endif
+ 
+ 		packet = av_packet_alloc();
+ 		assert(packet);
diff --git a/srcpkgs/synfig/template b/srcpkgs/synfig/template
index 30109541ec4f..703cfd7ebac8 100644
--- a/srcpkgs/synfig/template
+++ b/srcpkgs/synfig/template
@@ -2,11 +2,11 @@
 # Should be kept in sync with 'synfigstudio' and 'ETL'
 pkgname=synfig
 version=1.4.4
-revision=3
+revision=4
 build_style=gnu-configure
 configure_args="--with-boost-libdir=${XBPS_CROSS_BASE}/usr/lib"
 hostmakedepends="boost-build ImageMagick pkg-config intltool"
-makedepends="ETL gettext-devel libxml++-devel mlt-devel libmagick-devel
+makedepends="ETL gettext-devel libxml++-devel mlt7-devel libmagick-devel
  libmng-devel boost-build boost-devel libopenexr-devel ffmpeg-devel"
 depends="ImageMagick"
 short_desc="CLI 2D vector and timeline-based animation software"
@@ -20,7 +20,7 @@ CXXFLAGS="-std=c++11 -DHAVE_LOCALE_H=1"
 
 synfig-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision}
-	 libopenexr-devel libxml++-devel mlt-devel"
+	 libopenexr-devel libxml++-devel mlt7-devel"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/bin/synfig-config

From ca54a26c4f1a781db9709fb2a89f1132e2526b18 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 081/115] tg_owt: revbump for ffmpeg-6.0

---
 srcpkgs/tg_owt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tg_owt/template b/srcpkgs/tg_owt/template
index 97d195ddb34a..551614b24956 100644
--- a/srcpkgs/tg_owt/template
+++ b/srcpkgs/tg_owt/template
@@ -1,7 +1,7 @@
 # Template file for 'tg_owt'
 pkgname=tg_owt
 version=0.0.0.20230107
-revision=1
+revision=2
 _commit=5098730b9eb6173f0b52068fe2555b7c1015123a
 _libyuv_commit=00950840d1c9bcbb3eb6ebc5aac5793e71166c8b
 _abseil_commit=8c0b94e793a66495e0b1f34a5eb26bd7dc672db0

From 21bcbca0cd1341cbe2de2132aedb69faa58a0e74 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 082/115] timg: revbump for ffmpeg-6.0

---
 srcpkgs/timg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/timg/template b/srcpkgs/timg/template
index 2a2ab763d2fd..8fb4327535ef 100644
--- a/srcpkgs/timg/template
+++ b/srcpkgs/timg/template
@@ -1,7 +1,7 @@
 # Template file for 'timg'
 pkgname=timg
 version=1.4.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_OPENSLIDE_SUPPORT=off -Wno-dev"
 hostmakedepends="pkg-config git"

From ded044254b2554d742f340bac729dc6abb1b9469 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 083/115] tvheadend: revbump for ffmpeg4-4.4.3

---
 srcpkgs/tvheadend/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/tvheadend/template b/srcpkgs/tvheadend/template
index e6b16d7ccf3b..46b52b6fb7f9 100644
--- a/srcpkgs/tvheadend/template
+++ b/srcpkgs/tvheadend/template
@@ -1,14 +1,14 @@
 # Template file for 'tvheadend'
 pkgname=tvheadend
 version=4.2.8
-revision=6
+revision=7
 build_style=gnu-configure
 configure_args="--enable-dvbscan --disable-ffmpeg_static
 --disable-hdhomerun_static --disable-bintray_cache --disable-libx264_static
 --disable-libx265_static --disable-libvpx_static --disable-libtheora_static
 --disable-libvorbis_static --disable-libfdkaac_static"
 hostmakedepends="gettext pkg-config python git which"
-makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg-devel"
+makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg4-devel"
 short_desc="TV streaming server"
 maintainer="lemmi <lemmi@nerd2nerd.org>"
 license="GPL-3.0-only"

From 97f16d65ba94e2d70df613f20af57124a7b2c33c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 084/115] unpaper: update to 7.0.0.

---
 srcpkgs/unpaper/template | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/srcpkgs/unpaper/template b/srcpkgs/unpaper/template
index 38ed47a58401..1ff910e722af 100644
--- a/srcpkgs/unpaper/template
+++ b/srcpkgs/unpaper/template
@@ -1,13 +1,13 @@
 # Template file for 'unpaper'
 pkgname=unpaper
-version=6.1
-revision=3
-build_style=gnu-configure
+version=7.0.0
+revision=1
+build_style=meson
+hostmakedepends="pkg-config meson libxslt"
+makedepends="ffmpeg-devel python3-Sphinx"
+short_desc="Post-processing tool for scanned sheets of paper"
 maintainer="Orphaned <orphan@voidlinux.org>"
-hostmakedepends="pkg-config libxslt"
-makedepends="ffmpeg-devel"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://www.flameeyes.eu/projects/unpaper"
-short_desc="A post-processing tool for scanned sheets of paper"
 distfiles="https://www.flameeyes.eu/files/${pkgname}-${version}.tar.xz"
-checksum=237c84f5da544b3f7709827f9f12c37c346cdf029b1128fb4633f9bafa5cb930
+checksum=2575fbbf26c22719d1cb882b59602c9900c7f747118ac130883f63419be46a80

From 0c059da7a4cf540ed8621d32c8e1334a62b2f913 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 085/115] vba-m: revbump for ffmpeg-6.0

---
 srcpkgs/vba-m/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vba-m/template b/srcpkgs/vba-m/template
index ba153e0b58ca..aa6093645e97 100644
--- a/srcpkgs/vba-m/template
+++ b/srcpkgs/vba-m/template
@@ -2,7 +2,7 @@
 pkgname=vba-m
 reverts=1292_2
 version=2.1.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_GTK=TRUE -DENABLE_FFMPEG=TRUE -DENABLE_LINK=TRUE -DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="gettext pkg-config unzip zip yasm wxWidgets-gtk3-devel"

From 162ae4628e389c44e681f5cfb0c0a711c6def4a9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 086/115] vice: revbump for ffmpeg4-4.4.3

---
 srcpkgs/vice/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/vice/template b/srcpkgs/vice/template
index fe9d33a81194..4beab2c5f9eb 100644
--- a/srcpkgs/vice/template
+++ b/srcpkgs/vice/template
@@ -1,7 +1,7 @@
 # Template file for 'vice'
 pkgname=vice
 version=3.7.1
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="
 	$(vopt_enable sdl2 sdlui2)
@@ -26,7 +26,7 @@ makedepends="
 	$(vopt_if gtk3 gtk+3-devel)
 	$(vopt_if gtk3 pulseaudio-devel)
 	$(vopt_if gtk3 pango-devel)
-	$(vopt_if ffmpeg ffmpeg-devel)"
+	$(vopt_if ffmpeg ffmpeg4-devel)"
 short_desc="Emulator for C64, C128, CBM-II, PET, VIC20, Plus4 and C16"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"

From f019a1378dc2e4f7de261736aa674d41dd7b144d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 087/115] waypipe: revbump for ffmpeg-6.0

---
 srcpkgs/waypipe/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waypipe/template b/srcpkgs/waypipe/template
index 5c4161900060..1a46fe27f7d8 100644
--- a/srcpkgs/waypipe/template
+++ b/srcpkgs/waypipe/template
@@ -1,7 +1,7 @@
 # Template file for 'waypipe'
 pkgname=waypipe
 version=0.8.4
-revision=1
+revision=2
 build_style=meson
 # lto is off because it causes linking errors in armv6l and armv7l (due to NEON)
 configure_args="-Dwerror=false -Dwith_dmabuf=enabled -Dwith_lz4=enabled

From 9b64c94df7adb73bbf6669665b015de496ea454a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 088/115] wf-recorder: revbump for ffmpeg-6.0

---
 srcpkgs/wf-recorder/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/wf-recorder/template b/srcpkgs/wf-recorder/template
index e278eb001600..5d014a5f28af 100644
--- a/srcpkgs/wf-recorder/template
+++ b/srcpkgs/wf-recorder/template
@@ -1,7 +1,7 @@
 # Template file for 'wf-recorder'
 pkgname=wf-recorder
 version=0.3.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config scdoc wayland-devel"
 makedepends="wayland-protocols wayland-devel ffmpeg-devel x264-devel

From 68f506fda18111c02c2d12d644a5ddca76307048 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 089/115] xpra: revbump for ffmpeg-6.0

---
 srcpkgs/xpra/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xpra/template b/srcpkgs/xpra/template
index 0a63fdb6c743..d5acc1981c5f 100644
--- a/srcpkgs/xpra/template
+++ b/srcpkgs/xpra/template
@@ -1,7 +1,7 @@
 # Template file for 'xpra'
 pkgname=xpra
 version=4.4.6
-revision=1
+revision=2
 build_style=python3-module
 make_build_args="--without-cuda_kernels --without-cuda_rebuild"
 make_install_args="$(vopt_with docs) ${make_build_args}"

From 0d013ef300cdb1e631f46404a8e11014c5b368f5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:07:40 -0400
Subject: [PATCH 090/115] nv-codec-headers: update to 12.0.16.0

---
 srcpkgs/nv-codec-headers/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/nv-codec-headers/template b/srcpkgs/nv-codec-headers/template
index 3d422a61e489..251e057f826f 100644
--- a/srcpkgs/nv-codec-headers/template
+++ b/srcpkgs/nv-codec-headers/template
@@ -1,6 +1,6 @@
 # Template file for 'nv-codec-headers'
 pkgname=nv-codec-headers
-version=11.1.5.1
+version=12.0.16.0
 revision=1
 build_style=gnu-makefile
 short_desc="FFmpeg version of headers required to interface with Nvidias codec APIs"
@@ -8,7 +8,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="MIT"
 homepage="http://git.videolan.org/?p=ffmpeg/nv-codec-headers.git"
 distfiles="https://github.com/FFmpeg/nv-codec-headers/archive/n${version}.tar.gz"
-checksum=d095fbd56aa93772471a323be0ebe65504a0f43f06c76a30b6d25da77b06ae9c
+checksum=2a1533b65f55f9da52956faf0627ed3b74868ac0c7f269990edd21369113b48f
 
 post_install() {
 	sed -n '4,25p' include/ffnvcodec/nvEncodeAPI.h > LICENSE

From c5a14eda9173310aae150ea1ef247a3e800fdc4d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:08:40 -0400
Subject: [PATCH 091/115] openimagedenoise: revbump for ffmpeg-6.0

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index db5ccdb055cc..cb90045afb63 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,7 +1,7 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
 version=1.4.3
-revision=1
+revision=2
 archs="x86_64*"
 build_style=cmake
 hostmakedepends="ispc python3"

From 82af45878eeb51c9aa160a71c9b3c0303fd96e21 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:31:45 -0400
Subject: [PATCH 092/115] shotcut: revbump for ffmpeg-6.0

---
 srcpkgs/shotcut/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/shotcut/template b/srcpkgs/shotcut/template
index 7d2af7b0470b..c416c906ff73 100644
--- a/srcpkgs/shotcut/template
+++ b/srcpkgs/shotcut/template
@@ -1,7 +1,7 @@
 # Template file for 'shotcut'
 pkgname=shotcut
 version=23.05.14
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSHOTCUT_VERSION=${version}"
 hostmakedepends="pkg-config qt6-tools-devel"

From e65be3bae17f2a6fd636361643ca4eb2cb9f56ef Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:30 -0400
Subject: [PATCH 093/115] shiboken2: revbump for qt5-5.15.8

---
 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch | 1 +
 srcpkgs/shiboken2/template                                 | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
 create mode 120000 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
new file mode 120000
index 000000000000..efcf3249bd88
--- /dev/null
+++ b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1 @@
+../../python3-pyside2/patches/importlib-machinery-bypass.patch
\ No newline at end of file
diff --git a/srcpkgs/shiboken2/template b/srcpkgs/shiboken2/template
index 084ecc3ba1e1..2a21998997eb 100644
--- a/srcpkgs/shiboken2/template
+++ b/srcpkgs/shiboken2/template
@@ -1,7 +1,7 @@
 # Template file for 'shiboken2'
 pkgname=shiboken2
 version=5.15.7
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/shiboken2"
 build_style=cmake

From 5f120759b7e066465eb55141686e3b7eeffb91ef Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:53 -0400
Subject: [PATCH 094/115] python3-pyside2: update to 5.15.8

---
 .../patches/importlib-machinery-bypass.patch      | 15 +++++++++++++++
 srcpkgs/python3-pyside2/template                  |  9 +++++----
 2 files changed, 20 insertions(+), 4 deletions(-)
 create mode 100644 srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
new file mode 100644
index 000000000000..64c429584776
--- /dev/null
+++ b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1,15 @@
+Using this prevents an error around line 220 below it.
+"AttributeError: module 'importlib' has no attribute 'machinery'"
+The old backup logic is in place and compiles without issues.
+--- a/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:09:34.688912402 -0400
++++ b/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:10:03.395529582 -0400
+@@ -170,9 +170,6 @@
+
+     # 'zipstring_sequence' comes from signature.cpp
+     zipbytes = base64.b64decode(''.join(zipstring_sequence))
+-    if sys.version_info[0] >= 3:
+-        vzip = zipfile.ZipFile(io.BytesIO(zipbytes))
+-        return sys.meta_path, EmbeddableZipImporter(vzip)
+
+     # Old version for Python 2.7, only.
+     import os
diff --git a/srcpkgs/python3-pyside2/template b/srcpkgs/python3-pyside2/template
index 50e6ff260d3b..b50e62bd215d 100644
--- a/srcpkgs/python3-pyside2/template
+++ b/srcpkgs/python3-pyside2/template
@@ -1,11 +1,12 @@
 # Template file for 'python3-pyside2'
 pkgname=python3-pyside2
-version=5.15.5
-revision=2
+version=5.15.8
+revision=1
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/pyside2"
 build_style=cmake
-configure_args="-DPYTHON_EXECUTABLE=/usr/bin/python"
+configure_args="-DPYTHON_EXECUTABLE=/usr/bin/python -DCMAKE_BUILD_TYPE=None
+ -DBUILD_TESTS=OFF"
 hostmakedepends="cmake python3 shiboken2"
 makedepends="python3-devel libshiboken2-devel qt5-devel
  qt5-multimedia-devel qt5-tools-devel qt5-plugin-mysql qt5-plugin-odbc
@@ -23,7 +24,7 @@ maintainer="yopito <pierre.bourgin@free.fr>"
 license="LGPL-3.0-or-later"
 homepage="https://wiki.qt.io/Qt_for_Python"
 distfiles="https://download.qt.io/official_releases/QtForPython/pyside2/PySide2-${version}-src/${_pkgname}.tar.xz"
-checksum=3920a4fb353300260c9bc46ff70f1fb975c5e7efa22e9d51222588928ce19b33
+checksum=23436302c8deb5b4cbc769b205d09604e38ba83b40708efccb7bd8c9af6f6b5d
 
 build_options="webengine"
 desc_option_webengine="Build Qt5 WebEngine bindings"

From a6b45440acbcf604629c026dc7f59d1d300f1def Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:35 -0400
Subject: [PATCH 095/115] konqueror: revbump for ffmpeg-6.0

---
 srcpkgs/konqueror/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/konqueror/template b/srcpkgs/konqueror/template
index d8d0e73a78ab..c5bdba601d3c 100644
--- a/srcpkgs/konqueror/template
+++ b/srcpkgs/konqueror/template
@@ -1,11 +1,11 @@
 # Template file for 'konqueror'
 pkgname=konqueror
 version=23.04.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DDESKTOPTOJSON_EXECUTABLE=/usr/bin/desktoptojson"
 hostmakedepends="extra-cmake-modules python3 qt5-host-tools qt5-qmake kdoctools
-kcoreaddons kconfig gettext"
+ kcoreaddons kconfig gettext"
 makedepends="qt5-devel qt5-webengine-devel qt5-declarative-devel
  qt5-webchannel-devel qt5-location-devel kcmutils-devel kdelibs4support-devel
  karchive-devel khtml-devel kdesu-devel kactivities5-devel"

From ba3008cdf0b6da45a3384eb12c0d9e6a309ea10d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:58 -0400
Subject: [PATCH 096/115] qt5-speech: revbump for qt5-5.15.8

---
 srcpkgs/qt5-speech/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-speech/template b/srcpkgs/qt5-speech/template
index 3ecd10d50650..2d7d4d4d2453 100644
--- a/srcpkgs/qt5-speech/template
+++ b/srcpkgs/qt5-speech/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-speech'
 pkgname=qt5-speech
 version=5.15.7
-revision=2
+revision=3
 _commit=d32f4a479d38a11f547598004b975f4356424a16
 build_style=qmake
 configure_args="-- -flite -flite-alsa -speechd"

From 7ba659a03e3edea850b9760b830ca68a54f8e27f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 18:38:50 -0400
Subject: [PATCH 097/115] qt5-styleplugins: revbump for qt5-5.15.8

---
 srcpkgs/qt5-styleplugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-styleplugins/template b/srcpkgs/qt5-styleplugins/template
index 96ed97d12cd2..30d93660a2a4 100644
--- a/srcpkgs/qt5-styleplugins/template
+++ b/srcpkgs/qt5-styleplugins/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-styleplugins'
 pkgname=qt5-styleplugins
 version=5.0.0
-revision=20
+revision=21
 _gitrev=335dbece103e2cbf6c7cf819ab6672c2956b17b3
 build_style=qmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From 66ac6debfef12865adc86b57fca88c815feb317d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 7 May 2023 20:14:14 -0400
Subject: [PATCH 098/115] mlt7: revbump for ffmpeg-6.0

---
 srcpkgs/gst-libav/template | 2 +-
 srcpkgs/mlt7/template      | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index 04c39bff1489..8c72fc3e97ee 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.22.2
-revision=2
+revision=1
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"
diff --git a/srcpkgs/mlt7/template b/srcpkgs/mlt7/template
index 9fb7f60d692e..cca0eb68cfc3 100644
--- a/srcpkgs/mlt7/template
+++ b/srcpkgs/mlt7/template
@@ -1,7 +1,7 @@
 # Template file for 'mlt7'
 pkgname=mlt7
 version=7.14.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSWIG_PYTHON=ON"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which

From 060b99f9e673430e4f449c5c5d8856e7e1b69b0c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 7 May 2023 20:15:03 -0400
Subject: [PATCH 099/115] qt6-webengine: revbump for ffmpeg-6.0

---
 srcpkgs/qt6-webengine/template | 1 +
 1 file changed, 1 insertion(+)

diff --git a/srcpkgs/qt6-webengine/template b/srcpkgs/qt6-webengine/template
index f948dc919a15..43778b568d3f 100644
--- a/srcpkgs/qt6-webengine/template
+++ b/srcpkgs/qt6-webengine/template
@@ -145,6 +145,7 @@ pre_install() {
 }
 
 post_install() {
+	vlicense LICENSES/BSD-3-Clause.txt
 	local _file
 	find "${DESTDIR}"/usr/lib/qt6/examples \
 		-path '*/lib/qt6/**/lib/qt6/*' -type f |

From c997a7db2063d2d1479ae7267df794922f391362 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 11 May 2023 14:05:14 -0400
Subject: [PATCH 100/115] openmw: revbump for ffmpeg-6.0

---
 srcpkgs/openmw/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openmw/template b/srcpkgs/openmw/template
index e3771c7aaf1a..3cbf20b06577 100644
--- a/srcpkgs/openmw/template
+++ b/srcpkgs/openmw/template
@@ -1,7 +1,7 @@
 # Template file for 'openmw'
 pkgname=openmw
 version=0.47.0
-revision=5
+revision=6
 build_style=cmake
 _recast_commit=e75adf86f91eb3082220085e42dda62679f9a3ea
 _bullet_tag=3.17

From 8211429d9f795407b84158279b1b224330093b93 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 21 May 2023 12:44:11 -0400
Subject: [PATCH 101/115] electron24: revbump for ffmpeg-6.0

---
 srcpkgs/electron24/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron24/template b/srcpkgs/electron24/template
index bdaa56adc8a6..ff3d5e3ef381 100644
--- a/srcpkgs/electron24/template
+++ b/srcpkgs/electron24/template
@@ -1,7 +1,7 @@
 # Template file for 'electron24'
 pkgname=electron24
 version=24.3.0
-revision=1
+revision=2
 _nodever=18.14.0
 _chromiumver=112.0.5615.165
 archs="x86_64* aarch64*"

From 8c8d59739f44e5fd9e44a41d5b5b9a9f52abd3d1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Jun 2023 08:20:22 -0400
Subject: [PATCH 102/115] gtk4: revbump for ffmpeg-6.0

---
 srcpkgs/gtk4/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gtk4/template b/srcpkgs/gtk4/template
index b318b7bae1dd..e3bde4a50e54 100644
--- a/srcpkgs/gtk4/template
+++ b/srcpkgs/gtk4/template
@@ -1,7 +1,7 @@
 # Template file for 'gtk4'
 pkgname=gtk4
 version=4.10.4
-revision=1
+revision=2
 build_style=meson
 build_helper="gir"
 configure_args="-Dman-pages=true -Dgtk_doc=true -Dbuild-tests=false

From 1ae6a5c9e3c6b307197d7fc0e20ddf21687c351b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:25:50 -0400
Subject: [PATCH 103/115] electron19: revbump for ffmpeg-6.0

---
 srcpkgs/electron19/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron19/template b/srcpkgs/electron19/template
index 32ce301e730c..ab7f308f5e8a 100644
--- a/srcpkgs/electron19/template
+++ b/srcpkgs/electron19/template
@@ -1,7 +1,7 @@
 # Template file for 'electron19'
 pkgname=electron19
 version=19.0.8
-revision=3
+revision=4
 _nodever=16.14.2
 _chromiumver=102.0.5005.125
 archs="x86_64* aarch64* ppc64le*"

From 58f3afda2335486ab2327ed9e2fa41024848c856 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:28:26 -0400
Subject: [PATCH 104/115] siril: revbump for ffmpeg-6.0

---
 srcpkgs/siril/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/siril/template b/srcpkgs/siril/template
index 84332f79d060..62750dd24754 100644
--- a/srcpkgs/siril/template
+++ b/srcpkgs/siril/template
@@ -1,7 +1,7 @@
 # Template file for 'siril'
 pkgname=siril
 version=0.9.12
-revision=10
+revision=11
 build_style=gnu-configure
 hostmakedepends="pkg-config intltool autoconf automake gettext-devel"
 makedepends="fftw-devel libconfig-devel libopencv-devel libffms2-devel

From e13064950ec775cc26bdfd5b96e937c67c05a14e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:29:08 -0400
Subject: [PATCH 105/115] telegram-desktop: revbump for ffmpeg-6.0

---
 srcpkgs/telegram-desktop/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/telegram-desktop/template b/srcpkgs/telegram-desktop/template
index f114b2341dc5..9db9f80c1a53 100644
--- a/srcpkgs/telegram-desktop/template
+++ b/srcpkgs/telegram-desktop/template
@@ -1,7 +1,7 @@
 # Template file for 'telegram-desktop'
 pkgname=telegram-desktop
 version=4.8.1
-revision=3
+revision=4
 build_style=cmake
 build_helper="qemu"
 configure_args="-DTDESKTOP_API_ID=209235

From d051286efef38861b4c5bf61e039fce5068b62c4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 10 Jun 2023 00:40:39 -0400
Subject: [PATCH 106/115] freecad: revbump for qt5-webengine-5.15.13

---
 srcpkgs/freecad/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/freecad/template b/srcpkgs/freecad/template
index a4a3f5f76b29..8608d1670c87 100644
--- a/srcpkgs/freecad/template
+++ b/srcpkgs/freecad/template
@@ -1,7 +1,7 @@
 # Template file for 'freecad'
 pkgname=freecad
 version=0.20.2
-revision=5
+revision=6
 build_style=cmake
 
 _inst_prefix=/usr/lib/${pkgname}

From e979a896c1933974d7b2e6aba900e10bda99ba99 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 10 Jun 2023 00:57:09 -0400
Subject: [PATCH 107/115] qt6-multimedia: revbump for ffmpeg-6.0

---
 srcpkgs/qt6-multimedia/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-multimedia/template b/srcpkgs/qt6-multimedia/template
index a6832fdd69bf..c9ffac914ab8 100644
--- a/srcpkgs/qt6-multimedia/template
+++ b/srcpkgs/qt6-multimedia/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-multimedia'
 pkgname=qt6-multimedia
 version=6.5.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DQT_FEATURE_gstreamer=ON"
 hostmakedepends="perl qt6-declarative-host-tools pkg-config qt6-shadertools"

From 91eaa4c51b2f17b21e485d28aa4388b8256c901b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 22 Jun 2023 10:25:02 -0400
Subject: [PATCH 108/115] kdenlive: revbump for ffmpeg-6.0

---
 srcpkgs/kdenlive/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kdenlive/template b/srcpkgs/kdenlive/template
index 89c0dcfb8577..75495b3a3586 100644
--- a/srcpkgs/kdenlive/template
+++ b/srcpkgs/kdenlive/template
@@ -1,7 +1,7 @@
 # Template file for 'kdenlive'
 pkgname=kdenlive
 version=23.04.2
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="
  extra-cmake-modules kconfig kcoreaddons kdoctools pkg-config python3

From a30c97e4e60b681fba77a1a406a57fa1f88c0d53 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Jul 2023 09:18:23 -0400
Subject: [PATCH 109/115] gmic: revbump for opencv-4.7.0

---
 srcpkgs/gmic/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gmic/template b/srcpkgs/gmic/template
index 0bb4034d5cc8..808953e9b543 100644
--- a/srcpkgs/gmic/template
+++ b/srcpkgs/gmic/template
@@ -1,7 +1,7 @@
 # Template file for 'gmic'
 pkgname=gmic
 version=3.1.6
-revision=4
+revision=5
 _zart_hash=34ebf6cce0bafb98abe57cec83c4a02cd1abeca0
 create_wrksrc=yes
 build_wrksrc="src"

From d30987f7326467481255fbe9c3bcc070c606c04e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Jul 2023 09:29:52 -0400
Subject: [PATCH 110/115] synfigstudio: revbump for synfig mlt7

---
 srcpkgs/synfigstudio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/synfigstudio/template b/srcpkgs/synfigstudio/template
index af1c5a296ef0..09e442da9a68 100644
--- a/srcpkgs/synfigstudio/template
+++ b/srcpkgs/synfigstudio/template
@@ -2,7 +2,7 @@
 # Should be kept in sync with 'synfig' and 'ETL'
 pkgname=synfigstudio
 version=1.4.4
-revision=3
+revision=4
 build_style=gnu-configure
 configure_args="--disable-update-mimedb"
 hostmakedepends="pkg-config intltool gettext synfig"

From d11d87693e4f2ac06fdf206c96fc94df9fd143d1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Jul 2023 10:19:17 -0400
Subject: [PATCH 111/115] openimageio: revbump for ffmpeg6.0

---
 srcpkgs/openimageio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimageio/template b/srcpkgs/openimageio/template
index 0e9e22e9685d..e74a8dbd683e 100644
--- a/srcpkgs/openimageio/template
+++ b/srcpkgs/openimageio/template
@@ -1,7 +1,7 @@
 # Template file for 'openimageio'
 pkgname=openimageio
 version=2.4.9.0
-revision=5
+revision=6
 build_style=cmake
 build_helper=qemu
 configure_args="-DUSE_QT=0 -DUSE_PYTHON=0 -DOIIO_BUILD_TESTS=0

From 2c6375832c4b49f6775b607b1f3ca4bebeb9db9a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Jul 2023 11:17:37 -0400
Subject: [PATCH 112/115] DELETE: intel_packages

---
 common/shlibs                                 |   2 +
 srcpkgs/intel-gmmlib/template                 |   6 +-
 ...mmon-Enable-MMC-in-free-kernel-build.patch | 125 ++++++++++++++++++
 srcpkgs/intel-media-driver/template           |   6 +-
 srcpkgs/intel-media-sdk/patches/musl.patch    |  14 ++
 srcpkgs/intel-media-sdk/template              |  37 ++++++
 srcpkgs/intel-media-sdk/update                |   1 +
 srcpkgs/onevpl-devel                          |   1 +
 srcpkgs/onevpl-intel-gpu-devel                |   1 +
 srcpkgs/onevpl-intel-gpu/template             |  27 ++++
 srcpkgs/onevpl/template                       |  34 +++++
 11 files changed, 248 insertions(+), 6 deletions(-)
 create mode 100644 srcpkgs/intel-media-driver/patches/0001-Media-Common-Enable-MMC-in-free-kernel-build.patch
 create mode 100644 srcpkgs/intel-media-sdk/patches/musl.patch
 create mode 100644 srcpkgs/intel-media-sdk/template
 create mode 100644 srcpkgs/intel-media-sdk/update
 create mode 120000 srcpkgs/onevpl-devel
 create mode 120000 srcpkgs/onevpl-intel-gpu-devel
 create mode 100644 srcpkgs/onevpl-intel-gpu/template
 create mode 100644 srcpkgs/onevpl/template

diff --git a/common/shlibs b/common/shlibs
index 27ae0b223a0b..bd24ffaadeda 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4289,5 +4289,7 @@ libgsoapssl++-2.8.124.so gsoap-2.8.124_1
 libjxl.so.0.8 libjxl-0.8.2_1
 libjxl_dec.so.0.8 libjxl-0.8.2_1
 libjxl_threads.so.0.8 libjxl-0.8.2_1
+libmfx.so.1 libmfx-22.6.4_1
+libvpl.so.2 onevpl-2023.1.2_1
 libtext-engine-0.1.so.0 text-engine-0.1.1_1
 libvmaf.so.1 vmaf-2.3.1_1
diff --git a/srcpkgs/intel-gmmlib/template b/srcpkgs/intel-gmmlib/template
index 04e407b1de4d..2605226152e5 100644
--- a/srcpkgs/intel-gmmlib/template
+++ b/srcpkgs/intel-gmmlib/template
@@ -1,6 +1,6 @@
 # Template file for 'intel-gmmlib'
 pkgname=intel-gmmlib
-version=22.2.0
+version=22.3.3
 revision=1
 archs="i686* x86_64*"
 build_style=cmake
@@ -14,11 +14,11 @@ build_style=cmake
 # compilers flag in use.
 configure_args="-Wno-dev"
 short_desc="Intel Graphics Memory Management Library"
-maintainer="Orphaned <orphan@voidlinux.org>"
+maintainer="Stefano Ragni <st3r4g@protonmail.com>"
 license="MIT"
 homepage="https://github.com/intel/gmmlib"
 distfiles="https://github.com/intel/gmmlib/archive/intel-gmmlib-${version}.tar.gz"
-checksum=0b2253894c6fc8455b6d7c5e87e6504a76d6f60ea192e1445c2f93164bf529c0
+checksum=86651bd2803c9f0afd82471bec784e65d2b418dee315a053d22215eb2a679be7
 
 lib32disabled=yes
 
diff --git a/srcpkgs/intel-media-driver/patches/0001-Media-Common-Enable-MMC-in-free-kernel-build.patch b/srcpkgs/intel-media-driver/patches/0001-Media-Common-Enable-MMC-in-free-kernel-build.patch
new file mode 100644
index 000000000000..525fb688722c
--- /dev/null
+++ b/srcpkgs/intel-media-driver/patches/0001-Media-Common-Enable-MMC-in-free-kernel-build.patch
@@ -0,0 +1,125 @@
+From e68feab7db036838d9521ba3b9f00717c37c024c Mon Sep 17 00:00:00 2001
+From: JayYang <jay.yang@intel.com>
+Date: Tue, 21 Mar 2023 17:17:55 +0800
+Subject: [PATCH] [Media Common] Enable MMC in free kernel build
+
+Add mmc build definition in free kernel build
+---
+ media_driver/agnostic/gen9/codec/hal/media_srcs.cmake          | 2 +-
+ media_driver/cmake/linux/media_feature_flags_linux.cmake       | 3 +--
+ .../media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp        | 2 +-
+ .../media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp        | 2 +-
+ .../media_interfaces_m9_glk/media_interfaces_g9_glk.cpp        | 2 +-
+ .../media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp        | 2 +-
+ .../media_interfaces_m9_skl/media_interfaces_g9_skl.cpp        | 2 +-
+ 7 files changed, 7 insertions(+), 8 deletions(-)
+
+diff --git a/media_driver/agnostic/gen9/codec/hal/media_srcs.cmake b/media_driver/agnostic/gen9/codec/hal/media_srcs.cmake
+index 8bb36bafe..78902a22d 100644
+--- a/media_driver/agnostic/gen9/codec/hal/media_srcs.cmake
++++ b/media_driver/agnostic/gen9/codec/hal/media_srcs.cmake
+@@ -27,7 +27,7 @@ set(TMP_1_HEADERS_
+     ${CMAKE_CURRENT_LIST_DIR}/codechal_hw_g9_X.h
+ )
+ 
+-if(${MMC_Supported} STREQUAL "yes")
++if(${MMC_Supported} STREQUAL "yes" AND ENABLE_NONFREE_KERNELS AND ENABLE_KERNELS)
+     set(TMP_1_SOURCES_
+         ${TMP_1_SOURCES_}
+         ${CMAKE_CURRENT_LIST_DIR}/codechal_memdecomp_g9.cpp
+diff --git a/media_driver/cmake/linux/media_feature_flags_linux.cmake b/media_driver/cmake/linux/media_feature_flags_linux.cmake
+index de0ca853f..8121ea60c 100644
+--- a/media_driver/cmake/linux/media_feature_flags_linux.cmake
++++ b/media_driver/cmake/linux/media_feature_flags_linux.cmake
+@@ -35,7 +35,6 @@ if(NOT ENABLE_KERNELS OR NOT ENABLE_NONFREE_KERNELS)
+     bs_set_if_undefined(HEVC_Encode_VME_Supported "no")
+     bs_set_if_undefined(MPEG2_Encode_VME_Supported "no")
+     bs_set_if_undefined(CMRT_HEVC_ENC_FEI_Supported "no")
+-    bs_set_if_undefined(MMC_Supported "no")
+     bs_set_if_undefined(VC1_Decode_Supported "no")
+     bs_set_if_undefined(Decode_Processing_Supported "no")
+     bs_set_if_undefined(Kernel_Auto_Denoise_Supported "no")
+@@ -46,7 +45,6 @@ else()
+     bs_set_if_undefined(HEVC_Encode_VME_Supported "${Encode_VME_Supported}")
+     bs_set_if_undefined(MPEG2_Encode_VME_Supported "${Encode_VME_Supported}")
+     bs_set_if_undefined(CMRT_HEVC_ENC_FEI_Supported "yes")
+-    bs_set_if_undefined(MMC_Supported "yes")
+     bs_set_if_undefined(VC1_Decode_Supported "yes")
+     bs_set_if_undefined(Decode_Processing_Supported "yes")
+     bs_set_if_undefined(Kernel_Auto_Denoise_Supported "yes")
+@@ -64,6 +62,7 @@ bs_set_if_undefined(VP9_Decode_Supported "yes")
+ bs_set_if_undefined(VP_SFC_Supported "yes")
+ bs_set_if_undefined(Common_Encode_Supported "yes")
+ bs_set_if_undefined(Media_Scalability_Supported "yes")
++bs_set_if_undefined(MMC_Supported "yes")
+ 
+ # features controlled by global flag Encode_VDEnc_Supported
+ bs_set_if_undefined(AVC_Encode_VDEnc_Supported "${Encode_VDEnc_Supported}")
+diff --git a/media_driver/media_interface/media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp b/media_driver/media_interface/media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp
+index 3f306ee2a..8e4c0f532 100644
+--- a/media_driver/media_interface/media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp
+@@ -135,7 +135,7 @@ MOS_STATUS MhwInterfacesG9Bxt::Initialize(
+ 
+     return MOS_STATUS_SUCCESS;
+ }
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool bxtRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Bxt>((uint32_t)IGFX_BROXTON);
+diff --git a/media_driver/media_interface/media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp b/media_driver/media_interface/media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp
+index b8fa1eec0..84e0fad1d 100644
+--- a/media_driver/media_interface/media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp
+@@ -44,7 +44,7 @@ static bool cflRegisteredMhw =
+     MediaFactory<uint32_t, MhwInterfaces>::
+     Register<MhwInterfacesG9Kbl>((uint32_t)IGFX_COFFEELAKE);
+ 
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool cflRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Kbl>((uint32_t)IGFX_COFFEELAKE);
+diff --git a/media_driver/media_interface/media_interfaces_m9_glk/media_interfaces_g9_glk.cpp b/media_driver/media_interface/media_interfaces_m9_glk/media_interfaces_g9_glk.cpp
+index de81e6091..2638cb3a6 100644
+--- a/media_driver/media_interface/media_interfaces_m9_glk/media_interfaces_g9_glk.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_glk/media_interfaces_g9_glk.cpp
+@@ -65,7 +65,7 @@ static bool glkRegisteredMhw =
+     MediaFactory<uint32_t, MhwInterfaces>::
+     Register<MhwInterfacesG9Kbl>((uint32_t)IGFX_GEMINILAKE);
+ 
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool glkRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Kbl>((uint32_t)IGFX_GEMINILAKE);
+diff --git a/media_driver/media_interface/media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp b/media_driver/media_interface/media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp
+index 99d786185..4e9c6e7f1 100644
+--- a/media_driver/media_interface/media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp
+@@ -131,7 +131,7 @@ MOS_STATUS MhwInterfacesG9Kbl::Initialize(
+ 
+     return MOS_STATUS_SUCCESS;
+ }
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool kblRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Kbl>((uint32_t)IGFX_KABYLAKE);
+diff --git a/media_driver/media_interface/media_interfaces_m9_skl/media_interfaces_g9_skl.cpp b/media_driver/media_interface/media_interfaces_m9_skl/media_interfaces_g9_skl.cpp
+index e2520edf7..4b0012c64 100644
+--- a/media_driver/media_interface/media_interfaces_m9_skl/media_interfaces_g9_skl.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_skl/media_interfaces_g9_skl.cpp
+@@ -139,7 +139,7 @@ MOS_STATUS MhwInterfacesG9Skl::Initialize(
+ 
+     return MOS_STATUS_SUCCESS;
+ }
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool sklRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Skl>((uint32_t)IGFX_SKYLAKE);
+-- 
+2.40.0
+
diff --git a/srcpkgs/intel-media-driver/template b/srcpkgs/intel-media-driver/template
index a5bab06ac947..1735b90c65ce 100644
--- a/srcpkgs/intel-media-driver/template
+++ b/srcpkgs/intel-media-driver/template
@@ -1,6 +1,6 @@
 # Template file for 'intel-media-driver'
 pkgname=intel-media-driver
-version=22.5.3
+version=22.6.4
 revision=1
 archs="x86_64*"
 build_style=cmake
@@ -8,11 +8,11 @@ configure_args="-Wno-dev -DENABLE_NONFREE_KERNELS=$(vopt_if nonfree ON OFF)"
 hostmakedepends="pkg-config"
 makedepends="libva-devel libX11-devel intel-gmmlib-devel libpciaccess-devel"
 short_desc="Intel Media Driver for VAAPI (Broadwell+)"
-maintainer="Orphaned <orphan@voidlinux.org>"
+maintainer="Stefano Ragni <st3r4g@protonmail.com>"
 license="MIT, BSD-3-Clause"
 homepage="https://github.com/intel/media-driver"
 distfiles="https://github.com/intel/media-driver/archive/intel-media-${version}.tar.gz"
-checksum=65652b365d48be3c9f0b3c561502952b92ee5fcc587520b88d0d752cf2a6a3b5
+checksum=0c04b9d74b92de41fd409b62913ce4afd799236c0b6bc1983a496990764e5d90
 
 build_options="nonfree"
 desc_option_nonfree="Enable nonfree kernels"
diff --git a/srcpkgs/intel-media-sdk/patches/musl.patch b/srcpkgs/intel-media-sdk/patches/musl.patch
new file mode 100644
index 000000000000..4ae70924b744
--- /dev/null
+++ b/srcpkgs/intel-media-sdk/patches/musl.patch
@@ -0,0 +1,14 @@
+--- a/tools/tracer/tracer/tracer_linux.cpp	2022-11-18 03:02:59.000000000 -0500
++++ b/tools/tracer/tracer/tracer_linux.cpp	2022-12-18 01:44:51.341542572 -0500
+@@ -32,6 +32,11 @@
+ #include <dlfcn.h>
+ #include "tracer.h"
+
++#ifndef RTLD_DEEPBIND
++// musl neither defines nor can use RTLD_DEEPBIND
++#define RTLD_DEEPBIND 0
++#endif
++
+ #if defined(__i386__)
+     #define LIBMFXHW "libmfxhw32.so.1"
+ #elif defined(__x86_64__)
diff --git a/srcpkgs/intel-media-sdk/template b/srcpkgs/intel-media-sdk/template
new file mode 100644
index 000000000000..7aeab51802f8
--- /dev/null
+++ b/srcpkgs/intel-media-sdk/template
@@ -0,0 +1,37 @@
+# Template file for 'intel-media-sdk'
+pkgname=intel-media-sdk
+version=22.6.4
+revision=1
+archs="x86_64*"
+build_style=cmake
+configure_args="-Wno-dev -DBUILD_SAMPLES=OFF -DBUILD_TESTS=ON"
+hostmakedepends="pkg-config"
+makedepends="libva-devel libdrm-devel intel-gmmlib-devel"
+short_desc="Intel Media SDK"
+maintainer="Stefano Ragni <st3r4g@protonmail.com>"
+license="MIT, BSD-3-Clause"
+homepage="https://github.com/Intel-Media-SDK/MediaSDK"
+distfiles="https://github.com/Intel-Media-SDK/MediaSDK/archive/refs/tags/intel-mediasdk-${version}.tar.gz"
+checksum=197acd056f81e9ff1c27068d50e8c84c2014d94c7ac17cad69d5c2d61e445fd3
+
+post_install() {
+	vlicense LICENSE
+}
+
+libmfx_package() {
+	depends="${makedepends} ${sourcepkg}-${version}_${revision}"
+	short_desc="Intel MediaSDK mfx lib"
+	pkg_install() {
+		vmove usr/lib/mfx
+		vmove "usr/lib/libmfx*.so*"
+	}
+}
+
+libmfx-devel_package() {
+	depends="${makedepends} ${sourcepkg}-${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+	}
+}
diff --git a/srcpkgs/intel-media-sdk/update b/srcpkgs/intel-media-sdk/update
new file mode 100644
index 000000000000..434a2bc67f7a
--- /dev/null
+++ b/srcpkgs/intel-media-sdk/update
@@ -0,0 +1 @@
+pkgname=intel-media
diff --git a/srcpkgs/onevpl-devel b/srcpkgs/onevpl-devel
new file mode 120000
index 000000000000..e2306500b487
--- /dev/null
+++ b/srcpkgs/onevpl-devel
@@ -0,0 +1 @@
+onevpl
\ No newline at end of file
diff --git a/srcpkgs/onevpl-intel-gpu-devel b/srcpkgs/onevpl-intel-gpu-devel
new file mode 120000
index 000000000000..47920ceecf91
--- /dev/null
+++ b/srcpkgs/onevpl-intel-gpu-devel
@@ -0,0 +1 @@
+onevpl-intel-gpu
\ No newline at end of file
diff --git a/srcpkgs/onevpl-intel-gpu/template b/srcpkgs/onevpl-intel-gpu/template
new file mode 100644
index 000000000000..f14acb728a54
--- /dev/null
+++ b/srcpkgs/onevpl-intel-gpu/template
@@ -0,0 +1,27 @@
+# Template file for 'onevpl-intel-gpu'
+pkgname=onevpl-intel-gpu
+version=22.6.4
+revision=1
+archs="x86_64*"
+build_style=cmake
+configure_args="-Wno-dev -DCMAKE_BUILD_TYPE=Release"
+hostmakedepends="cmake pkg-config"
+makedepends="libdrm-devel libva-devel onevpl-devel"
+short_desc="Runtime implementation of oneVPL API for Intel Gen GPUs"
+maintainer="zlice <zlice555@gmail.com>"
+license="MIT"
+homepage="https://github.com/oneapi-src/oneVPL-intel-gpu"
+changelog="https://github.com/oneapi-src/oneVPL-intel-gpu/blob/main/CHANGELOG.md"
+distfiles="https://github.com/oneapi-src/oneVPL-intel-gpu/archive/refs/tags/intel-onevpl-${version}.tar.gz"
+checksum=74b0979dcb2af1b7c68edb8cbcb02d539de511090b12fac50652cbacd707c4e6
+
+post_install() {
+	vlicense LICENSE
+}
+
+onevpl-intel-gpu-devel_package() {
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/lib/pkgconfig
+	}
+}
diff --git a/srcpkgs/onevpl/template b/srcpkgs/onevpl/template
new file mode 100644
index 000000000000..85c7c2da85ce
--- /dev/null
+++ b/srcpkgs/onevpl/template
@@ -0,0 +1,34 @@
+# Template file for 'onevpl'
+pkgname=onevpl
+version=2023.1.2
+revision=1
+archs="x86_64*"
+build_style=cmake
+configure_args="
+	-DCMAKE_BUILD_TYPE=Release -Wno-dev
+	-DBUILD_PYTHON_BINDING:BOOL='OFF'
+	-DBUILD_EXAMPLES:BOOL='OFF'
+	-DBUILD_TESTS:BOOL='ON'
+	-DINSTALL_EXAMPLE_CODE:BOOL='OFF'"
+hostmakedepends="cmake libX11 python wayland-protocols pkg-config"
+makedepends="libva-devel libX11-devel wayland-devel"
+short_desc="Intel oneAPI Video Processing library"
+maintainer="zlice <zlice555@gmail.com>"
+license="MIT"
+homepage="https://www.intel.com/content/www/us/en/developer/tools/oneapi/onevpl.html"
+distfiles="https://github.com/oneapi-src/oneVPL/archive/v${version}/${pkgname}-${version}.tar.gz"
+checksum=b2261cca174ce1815f3d47c647921ab17f68267c69c1e2444ff27aab7d199cbb
+
+post_install() {
+	vlicense LICENSE
+}
+
+onevpl-devel_package() {
+	depends="${makedepends} ${sourcepkg}-${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.so"
+	}
+}

From accf1f408704e340110d1d62e3dd25167cc83f68 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:20:59 -0400
Subject: [PATCH 113/115] tracker-miners: revbump for ffmpeg-6.0

---
 srcpkgs/tracker-miners/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tracker-miners/template b/srcpkgs/tracker-miners/template
index a6e5aa577702..aa0f443927cd 100644
--- a/srcpkgs/tracker-miners/template
+++ b/srcpkgs/tracker-miners/template
@@ -1,7 +1,7 @@
 # Template file for 'tracker-miners'
 pkgname=tracker-miners
 version=3.5.0
-revision=4
+revision=5
 build_style=meson
 build_helper=qemu
 # missing libgrss for miner_rss

From 132d20075f4b9033fab2db769927fa92daba03ff Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:21:21 -0400
Subject: [PATCH 114/115] mpd: revbump for ffmpeg-6.0

---
 srcpkgs/mpd/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpd/template b/srcpkgs/mpd/template
index 9f058b62df2f..0dc47dd2a3e8 100644
--- a/srcpkgs/mpd/template
+++ b/srcpkgs/mpd/template
@@ -1,7 +1,7 @@
 # Template file for 'mpd'
 pkgname=mpd
 version=0.23.13
-revision=2
+revision=3
 build_style=meson
 configure_args="-Dopus=enabled -Dmikmod=enabled -Dneighbor=true
  -Dsoundcloud=enabled -Dpipe=true -Dtwolame=enabled -Dbzip2=enabled

From 36edccd1ca1210610420f37b925df287fd530d0e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:27:17 -0400
Subject: [PATCH 115/115] lms: revbump for ffmpeg-6.0

---
 srcpkgs/lms/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/lms/template b/srcpkgs/lms/template
index d20ae1ec1fc8..691ad73a840c 100644
--- a/srcpkgs/lms/template
+++ b/srcpkgs/lms/template
@@ -1,7 +1,7 @@
 # Template file for 'lms'
 pkgname=lms
 version=3.40.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="wt-devel ffmpeg-devel boost-devel libconfig++-devel taglib-devel pam-devel libgraphicsmagick-devel gtest-devel libarchive-devel"

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (18 preceding siblings ...)
  2023-07-09 14:54 ` zlice
@ 2023-07-09 14:58 ` zlice
  2023-07-17 19:52 ` [PR PATCH] [Updated] " zlice
                   ` (77 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2023-07-09 14:58 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 227 bytes --]

New comment by zlice on void-packages repository

https://github.com/void-linux/void-packages/pull/43761#issuecomment-1627738857

Comment:
ICU updated, and many other things since my last full build test. building fine for now

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (19 preceding siblings ...)
  2023-07-09 14:58 ` zlice
@ 2023-07-17 19:52 ` zlice
  2023-08-02 14:18 ` zlice
                   ` (76 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2023-07-17 19:52 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 3573 bytes --]

There is an updated pull request by zlice against master on the void-packages repository

https://github.com/zlice/void-packages ffmpeg6-split
https://github.com/void-linux/void-packages/pull/43761

ffmpeg6 split
[ci skip]


#### Testing the changes

- I tested the changes in this PR: **YES**

main testing has been vaapi in Firefox Nightly and enc/dec in Shotcut on Intel A770

#### New package

- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**

#### Local build testing

- I built this PR locally for my native architecture, **x86_64**

#### Discussion

Continuation of https://github.com/void-linux/void-packages/pull/36315

`libavresample` is deprecated, but marked as a dependency when trying to build other packages and install `ffmpeg`(6). I think the right way to handle this is make a meta package and the add to removals?


##### Commit naming / misc

~~Commits are 'dirty' right now, running with [gstreamer 1.22.1 updates](https://github.com/void-linux/void-packages/pull/42861) and [Intel OpenCL](https://github.com/void-linux/void-packages/pull/43084). This will also make [intel packages pr](https://github.com/void-linux/void-packages/pull/41132) obsolete.~~ (see Requirements below)

Maintainer for previous ffmpeg(4) was orphaned, I can put my name in there if that matters, though I don't exactly see myself keeping up on ffmpeg.

This updates QT5 which looks like it is usually hosted by Johnny. Not sure if there's any reason to stay there or these sources are fine.

##### STILL FFMPEG4

These are a mix of emulators, games and/or older packages.

- attract (multiple patches in master)
- audacity (https://github.com/audacity/audacity/issues/2305 and https://sourceforge.net/p/portmedia/wiki/portsmf/ is 'beta')
- ccextractor (master patches? no release)
- vice
- kodi
- mlt (only dep left is flowblade)
- ~~synfig (mlt)~~ (work with mlt7, bump synfigstudio)
- tvheadend
- ssr
- spek-alternative
- ppsspp
- olive
- moc
- mediastreamer
- libextractor
- idjc
- hedgewars
- ~~ffmpegthumbnailer~~ (patches for moviedecoder.xxx files)
- ~~ffmpegthumbs~~ (latest compiles)
- deadbeef
- omxplayer
- qtav (fork has ffmpeg 5 patch - https://github.com/cmguo/QtAV)
- `vlc` (vlc4 will support ffmpeg5, there's a patch to build 3.x with ffmpeg5 but it will lack vaapi)
- `osg` (OpenSceneGraph plus `xine-lib`)


##### HAVE NOT BUILT YET

- omxplayer (rpi only? ffmpeg4)
- kodi (big, but ffmpeg4)


##### UPDATED (for ffmpeg6)

- ~~blender: update to 3.5.1~~ ~~will be revbump with~~ https://github.com/void-linux/void-packages/pull/43992
- unpaper: update to 7.0.0.
- guvcview: update to 2.0.8.
- qt5: update to 5.15.8
- qt5-webengine: update to 5.18.13
- shiboken2: revbump for qt5.15.8 (patch)
- python3-pyside2: update to 5.15.8 (patch)


##### Requirements

- ~~[gstreamer 1.22.2](https://github.com/void-linux/void-packages/pull/42861)~~ - a few packages use ffmpeg-devel and require a revbump

- [Intel Packages](https://github.com/void-linux/void-packages/pull/41132) - ffmpeg4 uses different libraries than 6 (libmfx / Intel-MediaSDK vs only oneVPL that Intel is moving to), both are included here

- ~~[shotcut 23.05.14](https://github.com/void-linux/void-packages/pull/44260)~~

- https://github.com/void-linux/void-packages/pull/44781 will remove from this PR

A patch file from https://github.com/void-linux/void-packages/pull/43761.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ffmpeg6-split-43761.patch --]
[-- Type: text/x-diff, Size: 789288 bytes --]

From d803e18988e0d5dd34780ed2bfa095d30addd36b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:55:46 -0400
Subject: [PATCH 001/115] ffmpeg: update to 6.0.

---
 common/shlibs                                 | 26 +++++---
 srcpkgs/ffmpeg/files/altivec.patch            | 60 -------------------
 .../patches/armv5tel-floating-point.patch     | 18 ------
 ...h-libavcodec-libsvtav1-ten_bit_format.diff | 40 -------------
 .../workaround-mesa-readeon-vaapi-bug.patch   | 28 ---------
 srcpkgs/ffmpeg/template                       | 38 ++++++------
 6 files changed, 37 insertions(+), 173 deletions(-)
 delete mode 100644 srcpkgs/ffmpeg/files/altivec.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 delete mode 100644 srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch

diff --git a/common/shlibs b/common/shlibs
index 23c9adb2dd31..84ea00eb9fc1 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -392,15 +392,23 @@ libid3tag.so.0 libid3tag-0.15.1b_1
 libgif.so.7 giflib-5.1.0_1
 libImlib2.so.1 imlib2-1.4.2_1
 libmp3lame.so.0 lame-3.98.2_1
-libavdevice.so.58 libavdevice-4.0_1
-libavformat.so.58 libavformat-4.0_1
-libswscale.so.5 libswscale-4.0_1
-libswresample.so.3 libswresample-4.0_1
-libavresample.so.4 libavresample-4.0_1
-libpostproc.so.55 libpostproc-4.0_1
-libavcodec.so.58 libavcodec-4.0_1
-libavutil.so.56 libavutil-4.0_1
-libavfilter.so.7 libavfilter-4.0_1
+libavdevice.so.60 libavdevice-6.0_1
+libavformat.so.60 libavformat-6.0_1
+libswscale.so.7 libswscale-6.0_1
+libswresample.so.4 libswresample-6.0_1
+libpostproc.so.57 libpostproc-6.0_1
+libavcodec.so.60 libavcodec-6.0_1
+libavutil.so.58 libavutil-6.0_1
+libavfilter.so.9 libavfilter-6.0_1
+libavdevice.so.58 libavdevice4-4.0_1
+libavformat.so.58 libavformat4-4.0_1
+libswscale.so.5 libswscale4-4.0_1
+libswresample.so.3 libswresample4-4.0_1
+libavresample.so.4 libavresample4-4.0_1
+libpostproc.so.55 libpostproc4-4.0_1
+libavcodec.so.58 libavcodec4-4.0_1
+libavutil.so.56 libavutil4-4.0_1
+libavfilter.so.7 libavfilter4-4.0_1
 libSDL-1.2.so.0 SDL-1.2.14_1
 libSDL_image-1.2.so.0 SDL_image-1.2.10_1
 libx264.so.157 x264-20190507.2245_1
diff --git a/srcpkgs/ffmpeg/files/altivec.patch b/srcpkgs/ffmpeg/files/altivec.patch
deleted file mode 100644
index 9c5720046332..000000000000
--- a/srcpkgs/ffmpeg/files/altivec.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-revert some altivec specific change on all ppc* except ppc64le*
-
-q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
-conditionally, for ppc* but not ppc64le* (the new code is valid for
-POWER8 VSX which LE targets as a baseline but not BE)"
-
-
-This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
----
- libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
- 1 file changed, 20 insertions(+), 4 deletions(-)
-
-diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
-index 536545293d..c1e2852adb 100644
---- a/libswscale/ppc/yuv2rgb_altivec.c
-+++ b/libswscale/ppc/yuv2rgb_altivec.c
-@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-     vector signed short R1, G1, B1;                                           \
-     vector unsigned char R, G, B;                                             \
-                                                                               \
-+    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
-+    vector unsigned char align_perm;                                          \
-+                                                                              \
-     vector signed short lCY       = c->CY;                                    \
-     vector signed short lOY       = c->OY;                                    \
-     vector signed short lCRV      = c->CRV;                                   \
-@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
-                                                                               \
-         for (j = 0; j < w / 16; j++) {                                        \
--            y0 = vec_xl(0, y1i);                                              \
-+            y1ivP = (const vector unsigned char *) y1i;                       \
-+            y2ivP = (const vector unsigned char *) y2i;                       \
-+            uivP  = (const vector unsigned char *) ui;                        \
-+            vivP  = (const vector unsigned char *) vi;                        \
-+                                                                              \
-+            align_perm = vec_lvsl(0, y1i);                                    \
-+            y0 = (vector unsigned char)                                       \
-+                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
-                                                                               \
--            y1 = vec_xl(0, y2i);                                              \
-+            align_perm = vec_lvsl(0, y2i);                                    \
-+            y1 = (vector unsigned char)                                       \
-+                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
-                                                                               \
--            u = (vector signed char) vec_xl(0, ui);                           \
-+            align_perm = vec_lvsl(0, ui);                                     \
-+            u = (vector signed char)                                          \
-+                    vec_perm(uivP[0], uivP[1], align_perm);                   \
-                                                                               \
--            v = (vector signed char) vec_xl(0, vi);                           \
-+            align_perm = vec_lvsl(0, vi);                                     \
-+            v = (vector signed char)                                          \
-+                    vec_perm(vivP[0], vivP[1], align_perm);                   \
-                                                                               \
-             u = (vector signed char)                                          \
-                     vec_sub(u,                                                \
--- 
-2.27.0
-
diff --git a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
deleted file mode 100644
index 9a55178c74f0..000000000000
--- a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
-+++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
-@@ -39,6 +39,15 @@
- #endif
- #include <fenv.h>
- 
-+#if (FE_ALL_EXCEPT == 0)
-+/* E.g. ARM soft float does not define these */
-+#define FE_INVALID    0
-+#define FE_DIVBYZERO  0
-+#define FE_OVERFLOW   0
-+#define FE_UNDERFLOW  0
-+#define FE_INEXACT    0
-+#endif
-+
- #if CONFIG_LIBFONTCONFIG
- #include <fontconfig/fontconfig.h>
- #endif
diff --git a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
deleted file mode 100644
index aa948f7a8a2d..000000000000
--- a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
+++ /dev/null
@@ -1,40 +0,0 @@
-#==================================================================================================
-# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
-# From: Christopher Degawa <christopher.degawa@intel.com>
-# Date: Thu, 20 Oct 2022 22:55:27 -0500
-# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
-#
-# compressed_ten_bit_format has been deprecated upstream and has no effect
-# and can be removed. Plus, technically it was never used in the first place
-# since it would require the app (ffmpeg) to set it and do additional
-# processing of the input frames.
-#
-# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
-#
-# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
-#==================================================================================================
---- a/libavcodec/libsvtav1.c
-+++ b/libavcodec/libsvtav1.c
-@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
- 
- static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
- {
--    const int    pack_mode_10bit =
--        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
--    const size_t luma_size_8bit  =
--        config->source_width * config->source_height * (1 << pack_mode_10bit);
--    const size_t luma_size_10bit =
--        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
-+    const size_t luma_size = config->source_width * config->source_height *
-+        (config->encoder_bit_depth > 8 ? 2 : 1);
- 
-     EbSvtIOFormat *in_data;
- 
--    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
-+    svt_enc->raw_size = luma_size * 3 / 2;
- 
-     // allocate buffer for in and out
-     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
--- 
-GitLab
-
diff --git a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
deleted file mode 100644
index 00e3f68a415b..000000000000
--- a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
-From: Rainer Hochecker <fernetmenta@online.de>
-Date: Sat, 26 Jan 2019 19:48:35 +0100
-Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
-
-This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
-It was hit frequently when watching h264 channels received via DVB-X.
-Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
----
- libavcodec/vaapi_h264.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
-index 5854587a255..f12fdc457a4 100644
---- a/libavcodec/vaapi_h264.c
-+++ b/libavcodec/vaapi_h264.c
-@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
-     H264SliceContext *sl = &h->slice_ctx[0];
-     int ret;
- 
-+    if (pic->nb_slices == 0) {
-+        ret = AVERROR_INVALIDDATA;
-+        goto finish;
-+    }
-+
-     ret = ff_vaapi_decode_issue(avctx, pic);
-     if (ret < 0)
-         goto finish;
diff --git a/srcpkgs/ffmpeg/template b/srcpkgs/ffmpeg/template
index aa058aab9ca9..b877f86c1c69 100644
--- a/srcpkgs/ffmpeg/template
+++ b/srcpkgs/ffmpeg/template
@@ -1,15 +1,15 @@
 # Template file for 'ffmpeg'
 # audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
 pkgname=ffmpeg
-version=4.4.4
-revision=2
+version=6.0
+revision=1
 short_desc="Decoding, encoding and streaming software"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="https://www.ffmpeg.org"
 changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
 distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
-checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+checksum=57be87c22d9b49c112b6d24bc67d42508660e6b718b3db89c44e47e289137082
 
 hostmakedepends="pkg-config perl"
 makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
@@ -26,12 +26,13 @@ makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-deve
  $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
  $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
  $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
- $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers Vulkan-Tools Vulkan-ValidationLayers')
+ $(vopt_if onevpl 'onevpl onevpl-devel')
  $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
 depends="ffplay>=${version}_${revision}"
 
 build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
- dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec onevpl"
 build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
 desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
 desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
@@ -39,9 +40,13 @@ desc_option_sofa="Enable support for AES SOFA"
 desc_option_webp="Enable support for WebP"
 
 case "$XBPS_TARGET_MACHINE" in
-	i686*|x86_64*)
-		hostmakedepends+=" nasm"
+	i686*)
 		build_options_default+=" vaapi vdpau nvenc nvdec"
+		hostmakedepends+=" nasm"
+		;;
+	x86_64*)
+		hostmakedepends+=" nasm"
+		build_options_default+=" vaapi vdpau nvenc nvdec onevpl"
 		;;
 	ppc64*) build_options_default+=" vaapi vdpau";;
 	mips*) CFLAGS="-mnan=legacy";;
@@ -119,18 +124,19 @@ do_configure() {
 		$(vopt_enable x265 libx265) \
 		$(vopt_enable v4l2 libv4l2) \
 		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
-		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		--enable-libbs2b --enable-libvidstab \
 		$(vopt_enable dav1d libdav1d) \
 		$(vopt_enable zimg libzimg) \
 		$(vopt_enable webp libwebp) \
 		$(vopt_enable sofa libmysofa) \
 		$(vopt_enable vulkan) \
+		$(vopt_enable onevpl libvpl) \
 		$(vopt_enable drm libdrm) \
 		$(vopt_enable svtav1 libsvtav1) \
 		$(vopt_enable srt libsrt) \
 		$(vopt_enable rist librist) \
-		$(vopt_if nvenc '--enable-nvenc') \
-		$(vopt_if nvdec '--enable-nvdec')
+		$(vopt_enable nvenc nvenc) \
+		$(vopt_enable nvdec nvdec)
 }
 
 do_build() {
@@ -157,10 +163,8 @@ libavdevice_package() {
 }
 
 libavresample_package() {
-	short_desc="FFmpeg audio resampling library"
-	pkg_install() {
-		vmove "usr/lib/libavresample.so.*"
-	}
+	short_desc="Package deprecated, removal needed"
+	build_style=meta
 }
 
 libavformat_package() {
@@ -214,15 +218,13 @@ ffmpeg-devel_package() {
 		libavfilter>=${version}_${revision}
 		libpostproc>=${version}_${revision}
 		libswscale>=${version}_${revision}
-		libswresample>=${version}_${revision}
-		libavresample>=${version}_${revision}"
+		libswresample>=${version}_${revision}"
 	short_desc+=" - development files"
-
+	conflicts="ffmpeg4-devel"
 	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
 		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
 		nostrip_files="/usr/lib/libavfilter.a"
 	fi
-
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig

From e829cc1d873b76de724f77f2602dc27eb59de9a9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:56:22 -0400
Subject: [PATCH 002/115] New package: ffmpeg4-4.4.4.

---
 srcpkgs/ffmpeg4-devel                         |   1 +
 srcpkgs/ffmpeg4/files/altivec.patch           |  60 +++++
 .../patches/armv5tel-floating-point.patch     |  18 ++
 ...h-libavcodec-libsvtav1-ten_bit_format.diff |  40 +++
 .../workaround-mesa-readeon-vaapi-bug.patch   |  28 ++
 srcpkgs/ffmpeg4/template                      | 240 ++++++++++++++++++
 srcpkgs/libavcodec4                           |   1 +
 srcpkgs/libavdevice4                          |   1 +
 srcpkgs/libavfilter4                          |   1 +
 srcpkgs/libavformat4                          |   1 +
 srcpkgs/libavresample4                        |   1 +
 srcpkgs/libavutil4                            |   1 +
 srcpkgs/libpostproc4                          |   1 +
 srcpkgs/libswresample4                        |   1 +
 srcpkgs/libswscale4                           |   1 +
 15 files changed, 396 insertions(+)
 create mode 120000 srcpkgs/ffmpeg4-devel
 create mode 100644 srcpkgs/ffmpeg4/files/altivec.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 create mode 100644 srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
 create mode 100644 srcpkgs/ffmpeg4/template
 create mode 120000 srcpkgs/libavcodec4
 create mode 120000 srcpkgs/libavdevice4
 create mode 120000 srcpkgs/libavfilter4
 create mode 120000 srcpkgs/libavformat4
 create mode 120000 srcpkgs/libavresample4
 create mode 120000 srcpkgs/libavutil4
 create mode 120000 srcpkgs/libpostproc4
 create mode 120000 srcpkgs/libswresample4
 create mode 120000 srcpkgs/libswscale4

diff --git a/srcpkgs/ffmpeg4-devel b/srcpkgs/ffmpeg4-devel
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/ffmpeg4-devel
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/ffmpeg4/files/altivec.patch b/srcpkgs/ffmpeg4/files/altivec.patch
new file mode 100644
index 000000000000..9c5720046332
--- /dev/null
+++ b/srcpkgs/ffmpeg4/files/altivec.patch
@@ -0,0 +1,60 @@
+revert some altivec specific change on all ppc* except ppc64le*
+
+q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
+conditionally, for ppc* but not ppc64le* (the new code is valid for
+POWER8 VSX which LE targets as a baseline but not BE)"
+
+
+This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
+---
+ libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
+ 1 file changed, 20 insertions(+), 4 deletions(-)
+
+diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
+index 536545293d..c1e2852adb 100644
+--- a/libswscale/ppc/yuv2rgb_altivec.c
++++ b/libswscale/ppc/yuv2rgb_altivec.c
+@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+     vector signed short R1, G1, B1;                                           \
+     vector unsigned char R, G, B;                                             \
+                                                                               \
++    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
++    vector unsigned char align_perm;                                          \
++                                                                              \
+     vector signed short lCY       = c->CY;                                    \
+     vector signed short lOY       = c->OY;                                    \
+     vector signed short lCRV      = c->CRV;                                   \
+@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
+                                                                               \
+         for (j = 0; j < w / 16; j++) {                                        \
+-            y0 = vec_xl(0, y1i);                                              \
++            y1ivP = (const vector unsigned char *) y1i;                       \
++            y2ivP = (const vector unsigned char *) y2i;                       \
++            uivP  = (const vector unsigned char *) ui;                        \
++            vivP  = (const vector unsigned char *) vi;                        \
++                                                                              \
++            align_perm = vec_lvsl(0, y1i);                                    \
++            y0 = (vector unsigned char)                                       \
++                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
+                                                                               \
+-            y1 = vec_xl(0, y2i);                                              \
++            align_perm = vec_lvsl(0, y2i);                                    \
++            y1 = (vector unsigned char)                                       \
++                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
+                                                                               \
+-            u = (vector signed char) vec_xl(0, ui);                           \
++            align_perm = vec_lvsl(0, ui);                                     \
++            u = (vector signed char)                                          \
++                    vec_perm(uivP[0], uivP[1], align_perm);                   \
+                                                                               \
+-            v = (vector signed char) vec_xl(0, vi);                           \
++            align_perm = vec_lvsl(0, vi);                                     \
++            v = (vector signed char)                                          \
++                    vec_perm(vivP[0], vivP[1], align_perm);                   \
+                                                                               \
+             u = (vector signed char)                                          \
+                     vec_sub(u,                                                \
+-- 
+2.27.0
+
diff --git a/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
new file mode 100644
index 000000000000..9a55178c74f0
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
@@ -0,0 +1,18 @@
+--- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
++++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
+@@ -39,6 +39,15 @@
+ #endif
+ #include <fenv.h>
+ 
++#if (FE_ALL_EXCEPT == 0)
++/* E.g. ARM soft float does not define these */
++#define FE_INVALID    0
++#define FE_DIVBYZERO  0
++#define FE_OVERFLOW   0
++#define FE_UNDERFLOW  0
++#define FE_INEXACT    0
++#endif
++
+ #if CONFIG_LIBFONTCONFIG
+ #include <fontconfig/fontconfig.h>
+ #endif
diff --git a/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
new file mode 100644
index 000000000000..aa948f7a8a2d
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
@@ -0,0 +1,40 @@
+#==================================================================================================
+# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
+# From: Christopher Degawa <christopher.degawa@intel.com>
+# Date: Thu, 20 Oct 2022 22:55:27 -0500
+# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
+#
+# compressed_ten_bit_format has been deprecated upstream and has no effect
+# and can be removed. Plus, technically it was never used in the first place
+# since it would require the app (ffmpeg) to set it and do additional
+# processing of the input frames.
+#
+# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
+#
+# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
+#==================================================================================================
+--- a/libavcodec/libsvtav1.c
++++ b/libavcodec/libsvtav1.c
+@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
+ 
+ static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
+ {
+-    const int    pack_mode_10bit =
+-        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
+-    const size_t luma_size_8bit  =
+-        config->source_width * config->source_height * (1 << pack_mode_10bit);
+-    const size_t luma_size_10bit =
+-        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
++    const size_t luma_size = config->source_width * config->source_height *
++        (config->encoder_bit_depth > 8 ? 2 : 1);
+ 
+     EbSvtIOFormat *in_data;
+ 
+-    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
++    svt_enc->raw_size = luma_size * 3 / 2;
+ 
+     // allocate buffer for in and out
+     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
+-- 
+GitLab
+
diff --git a/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
new file mode 100644
index 000000000000..00e3f68a415b
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
@@ -0,0 +1,28 @@
+From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
+From: Rainer Hochecker <fernetmenta@online.de>
+Date: Sat, 26 Jan 2019 19:48:35 +0100
+Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
+
+This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
+It was hit frequently when watching h264 channels received via DVB-X.
+Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
+---
+ libavcodec/vaapi_h264.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
+index 5854587a255..f12fdc457a4 100644
+--- a/libavcodec/vaapi_h264.c
++++ b/libavcodec/vaapi_h264.c
+@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
+     H264SliceContext *sl = &h->slice_ctx[0];
+     int ret;
+ 
++    if (pic->nb_slices == 0) {
++        ret = AVERROR_INVALIDDATA;
++        goto finish;
++    }
++
+     ret = ff_vaapi_decode_issue(avctx, pic);
+     if (ret < 0)
+         goto finish;
diff --git a/srcpkgs/ffmpeg4/template b/srcpkgs/ffmpeg4/template
new file mode 100644
index 000000000000..f2c851693d36
--- /dev/null
+++ b/srcpkgs/ffmpeg4/template
@@ -0,0 +1,240 @@
+# Template file for 'ffmpeg4'
+# audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
+pkgname=ffmpeg4
+version=4.4.4
+revision=1
+short_desc="Decoding, encoding and streaming software - ffmpeg4 libraries only"
+maintainer="Orphaned <orphan@voidlinux.org>"
+license="GPL-3.0-or-later"
+homepage="https://www.ffmpeg.org"
+changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
+distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
+checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+
+hostmakedepends="pkg-config perl"
+makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
+ libXext-devel libXvMC-devel libxcb-devel lame-devel libtheora-devel
+ libvorbis-devel x264-devel xvidcore-devel jack-devel SDL2-devel
+ libcdio-paranoia-devel librtmp-devel libmodplug-devel gnutls-devel
+ speex-devel celt-devel harfbuzz-devel libass-devel opus-devel ocl-icd-devel
+ libbs2b-devel libvidstab-devel vmaf-devel $(vopt_if pulseaudio pulseaudio-devel)
+ $(vopt_if vaapi libva-devel) $(vopt_if vdpau libvdpau-devel)
+ $(vopt_if x265 x265-devel) $(vopt_if v4l2 v4l-utils-devel)
+ $(vopt_if fdk_aac fdk-aac-devel) $(vopt_if vpx libvpx-devel)
+ $(vopt_if aom libaom-devel) $(vopt_if sndio sndio-devel)
+ $(vopt_if dav1d libdav1d-devel) $(vopt_if zimg zimg-devel)
+ $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
+ $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
+ $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if mfx 'libmfx libmfx-devel')
+ $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
+
+build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec mfx"
+build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
+
+desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
+desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
+desc_option_sofa="Enable support for AES SOFA"
+desc_option_webp="Enable support for WebP"
+
+case "$XBPS_TARGET_MACHINE" in
+	i686*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau nvenc nvdec"
+			;;
+	x86_64*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau mfx nvenc nvdec"
+			;;
+	ppc64*) build_options_default+=" vaapi vdpau";;
+	mips*) CFLAGS="-mnan=legacy";;
+esac
+
+if [ "$XBPS_TARGET_WORDSIZE" != "32" ]; then
+	build_options_default+=" svtav1"
+fi
+
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+fi
+
+_apply_patch() {
+	local args="$1" pname="$(basename $2)"
+
+	if [ ! -f ".${pname}_done" ]; then
+		patch -N $args -i $2
+		touch .${pname}_done
+	fi
+}
+
+post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64le*) ;;
+		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
+	esac
+
+	vsed -i libavfilter/vf_libvmaf.c -e 's!/usr/local/share/model/\(vmaf_v0.6.1\).pkl!/usr/share/vmaf/\1.json!'
+}
+
+do_configure() {
+	# Fix gcc on x86_64-musl only
+	if [ "$XBPS_TARGET_MACHINE" = "x86_64-musl" ]; then
+		vsed -i configure -e "s;_cflags_speed='-O3';_cflags_speed='-O2';"
+	fi
+
+	if [ "$CROSS_BUILD" ]; then
+		case "$XBPS_TARGET_MACHINE" in
+			arm*) _arch="arm";;
+			aarch64*) _arch="aarch64";;
+			mips*) _arch="mips";;
+			ppc64*) _arch="ppc64";;
+			ppc*) _arch="ppc";;
+			*) _arch="${XBPS_TARGET_MACHINE%%-musl}";;
+		esac
+
+		_args+=" --enable-cross-compile
+			--sysroot=$XBPS_CROSS_BASE
+			--cross-prefix=${XBPS_CROSS_TRIPLET}-
+			--target-os=linux --arch=${_arch}"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc|ppc-musl) _args+=" --disable-altivec";;
+	esac
+
+	if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+		_args+=" --extra-libs=-latomic"
+	fi
+
+	./configure --prefix=/usr --disable-debug --enable-gpl --enable-gnutls \
+		--disable-stripping \
+		--enable-libcdio --enable-version3 --enable-runtime-cpudetect \
+		--enable-libmp3lame --enable-libvorbis --enable-libxvid \
+		--enable-libx264 $(vopt_enable vpx libvpx) --enable-libtheora \
+		--enable-shared --enable-static --enable-libxcb \
+		$(vopt_enable pulseaudio libpulse) --enable-libfreetype --enable-libmodplug \
+		--enable-libspeex --enable-libcelt --enable-libass \
+		--enable-libopus --enable-librtmp --enable-libjack \
+		$(vopt_if fdk_aac '--enable-nonfree --enable-libfdk-aac') \
+		--disable-libopencore_amrnb --disable-libopencore_amrwb \
+		--disable-libopenjpeg \
+		--enable-postproc --enable-opencl ${_args} --enable-libvmaf ${_args} \
+		$(vopt_enable x265 libx265) \
+		$(vopt_enable v4l2 libv4l2) \
+		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
+		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		$(vopt_enable dav1d libdav1d) \
+		$(vopt_enable zimg libzimg) \
+		$(vopt_enable webp libwebp) \
+		$(vopt_enable sofa libmysofa) \
+		$(vopt_enable vulkan) \
+		$(vopt_enable drm libdrm) \
+		$(vopt_enable svtav1 libsvtav1) \
+		$(vopt_enable srt libsrt) \
+		$(vopt_enable rist librist) \
+		$(vopt_enable mfx libmfx) \
+		$(vopt_if nvenc '--enable-nvenc') \
+		$(vopt_if nvdec '--enable-nvdec')
+}
+
+do_build() {
+	make ${makejobs}
+	make doc/ff{mpeg,play}.1
+}
+
+do_install() {
+	make DESTDIR=${DESTDIR} install install-man
+	rm -rf ${DESTDIR}/usr/bin
+}
+
+libavcodec4_package() {
+	short_desc="FFmpeg codec library"
+	pkg_install() {
+		vmove "usr/lib/libavcodec.so.*"
+	}
+}
+
+libavdevice4_package() {
+	short_desc="FFmpeg device handling library"
+	pkg_install() {
+		vmove "usr/lib/libavdevice.so.*"
+	}
+}
+
+libavresample4_package() {
+	short_desc="FFmpeg audio resampling library"
+	pkg_install() {
+		vmove "usr/lib/libavresample.so.*"
+	}
+}
+
+libavformat4_package() {
+	short_desc="FFmpeg file format library"
+	pkg_install() {
+		vmove "usr/lib/libavformat.so.*"
+	}
+}
+
+libavutil4_package() {
+	short_desc="FFmpeg utility library"
+	pkg_install() {
+		vmove "usr/lib/libavutil.so.*"
+	}
+}
+
+libavfilter4_package() {
+	short_desc="FFmpeg audio/video filter library"
+	pkg_install() {
+		vmove "usr/lib/libavfilter.so.*"
+	}
+}
+
+libpostproc4_package() {
+	short_desc="FFmpeg video postprocessing library"
+	pkg_install() {
+		vmove "usr/lib/libpostproc.so.*"
+	}
+}
+
+libswscale4_package() {
+	short_desc="FFmpeg video scaling library"
+	pkg_install() {
+		vmove "usr/lib/libswscale.so.*"
+	}
+}
+
+libswresample4_package() {
+	short_desc="FFmpeg video resampling library"
+	pkg_install() {
+		vmove "usr/lib/libswresample.so.*"
+	}
+}
+
+ffmpeg4-devel_package() {
+	depends="
+		libavcodec4>=${version}_${revision}
+		libavdevice4>=${version}_${revision}
+		libavformat4>=${version}_${revision}
+		libavutil4>=${version}_${revision}
+		libavfilter4>=${version}_${revision}
+		libpostproc4>=${version}_${revision}
+		libswscale4>=${version}_${revision}
+		libswresample4>=${version}_${revision}
+		libavresample4>=${version}_${revision}"
+	short_desc+=" - development files"
+	conflicts="ffmpeg-devel"
+	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
+		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
+		nostrip_files="/usr/lib/libavfilter.a"
+	fi
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.a"
+		vmove "usr/lib/*.so"
+		vmove usr/share/ffmpeg/examples
+		vmove usr/share/man/man3
+	}
+}
diff --git a/srcpkgs/libavcodec4 b/srcpkgs/libavcodec4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavcodec4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavdevice4 b/srcpkgs/libavdevice4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavdevice4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavfilter4 b/srcpkgs/libavfilter4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavfilter4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavformat4 b/srcpkgs/libavformat4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavformat4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavresample4 b/srcpkgs/libavresample4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavutil4 b/srcpkgs/libavutil4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libavutil4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libpostproc4 b/srcpkgs/libpostproc4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libpostproc4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswresample4 b/srcpkgs/libswresample4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libswresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswscale4 b/srcpkgs/libswscale4
new file mode 120000
index 000000000000..887f354e7c6b
--- /dev/null
+++ b/srcpkgs/libswscale4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file

From b033892299876236e726223001a1a63a612b67b8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:04 -0400
Subject: [PATCH 003/115] opencv: update to 4.7.0.

---
 common/shlibs           | 104 ++++++++++++++++++++--------------------
 srcpkgs/opencv/template |   8 ++--
 2 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index 84ea00eb9fc1..d4dd04a6ab3b 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2141,58 +2141,58 @@ libcapstone.so.4 capstone-4.0_1
 libhavege.so.2 libhaveged-1.9.11_1
 libnih.so.1 libnih-1.0.3_1
 libnih-dbus.so.1 libnih-1.0.3_1
-libopencv_quality.so.406 libopencv-4.6.0_1
-libopencv_reg.so.406 libopencv-4.6.0_1
-libopencv_surface_matching.so.406 libopencv-4.6.0_1
-libopencv_xphoto.so.406 libopencv-4.6.0_1
-libopencv_freetype.so.406 libopencv-4.6.0_1
-libopencv_fuzzy.so.406 libopencv-4.6.0_1
-libopencv_hfs.so.406 libopencv-4.6.0_1
-libopencv_img_hash.so.406 libopencv-4.6.0_1
-libopencv_line_descriptor.so.406 libopencv-4.6.0_1
-libopencv_saliency.so.406 libopencv-4.6.0_1
-libopencv_structured_light.so.406 libopencv-4.6.0_1
-libopencv_aruco.so.406 libopencv-4.6.0_1
-libopencv_bgsegm.so.406 libopencv-4.6.0_1
-libopencv_bioinspired.so.406 libopencv-4.6.0_1
-libopencv_ccalib.so.406 libopencv-4.6.0_1
-libopencv_face.so.406 libopencv-4.6.0_1
-libopencv_tracking.so.406 libopencv-4.6.0_1
-libopencv_xfeatures2d.so.406 libopencv-4.6.0_1
-libopencv_optflow.so.406 libopencv-4.6.0_1
-libopencv_ximgproc.so.406 libopencv-4.6.0_1
-libopencv_plot.so.406 libopencv-4.6.0_1
-libopencv_text.so.406 libopencv-4.6.0_1
-libopencv_ml.so.406 libopencv-4.6.0_1
-libopencv_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn.so.406 libopencv-4.6.0_1
-libopencv_shape.so.406 libopencv-4.6.0_1
-libopencv_stitching.so.406 libopencv-4.6.0_1
-libopencv_photo.so.406 libopencv-4.6.0_1
-libopencv_video.so.406 libopencv-4.6.0_1
-libopencv_calib3d.so.406 libopencv-4.6.0_1
-libopencv_features2d.so.406 libopencv-4.6.0_1
-libopencv_flann.so.406 libopencv-4.6.0_1
-libopencv_highgui.so.406 libopencv-4.6.0_1
-libopencv_videoio.so.406 libopencv-4.6.0_1
-libopencv_imgcodecs.so.406 libopencv-4.6.0_1
-libopencv_imgproc.so.406 libopencv-4.6.0_1
-libopencv_core.so.406 libopencv-4.6.0_1
-libopencv_superres.so.406 libopencv-4.6.0_1
-libopencv_videostab.so.406 libopencv-4.6.0_1
-libopencv_gapi.so.406 libopencv-4.6.0_1
-libopencv_xobjdetect.so.406 libopencv-4.6.0_1
-libopencv_datasets.so.406 libopencv-4.6.0_1
-libopencv_dnn_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn_superres.so.406 libopencv-4.6.0_1
-libopencv_dpm.so.406 libopencv-4.6.0_1
-libopencv_phase_unwrapping.so.406 libopencv-4.6.0_1
-libopencv_stereo.so.406 libopencv-4.6.0_1
-libopencv_rapid.so.406 libopencv-4.6.0_1
-libopencv_intensity_transform.so.406 libopencv-4.6.0_1
-libopencv_alphamat.so.406 libopencv-4.6.0_1
-libopencv_barcode.so.406 libopencv-4.6.0_1
-libopencv_mcc.so.406 libopencv-4.6.0_1
+libopencv_quality.so.407 libopencv-4.7.0_1
+libopencv_reg.so.407 libopencv-4.7.0_1
+libopencv_surface_matching.so.407 libopencv-4.7.0_1
+libopencv_xphoto.so.407 libopencv-4.7.0_1
+libopencv_freetype.so.407 libopencv-4.7.0_1
+libopencv_fuzzy.so.407 libopencv-4.7.0_1
+libopencv_hfs.so.407 libopencv-4.7.0_1
+libopencv_img_hash.so.407 libopencv-4.7.0_1
+libopencv_line_descriptor.so.407 libopencv-4.7.0_1
+libopencv_saliency.so.407 libopencv-4.7.0_1
+libopencv_structured_light.so.407 libopencv-4.7.0_1
+libopencv_aruco.so.407 libopencv-4.7.0_1
+libopencv_bgsegm.so.407 libopencv-4.7.0_1
+libopencv_bioinspired.so.407 libopencv-4.7.0_1
+libopencv_ccalib.so.407 libopencv-4.7.0_1
+libopencv_face.so.407 libopencv-4.7.0_1
+libopencv_tracking.so.407 libopencv-4.7.0_1
+libopencv_xfeatures2d.so.407 libopencv-4.7.0_1
+libopencv_optflow.so.407 libopencv-4.7.0_1
+libopencv_ximgproc.so.407 libopencv-4.7.0_1
+libopencv_plot.so.407 libopencv-4.7.0_1
+libopencv_text.so.407 libopencv-4.7.0_1
+libopencv_ml.so.407 libopencv-4.7.0_1
+libopencv_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn.so.407 libopencv-4.7.0_1
+libopencv_shape.so.407 libopencv-4.7.0_1
+libopencv_stitching.so.407 libopencv-4.7.0_1
+libopencv_photo.so.407 libopencv-4.7.0_1
+libopencv_video.so.407 libopencv-4.7.0_1
+libopencv_calib3d.so.407 libopencv-4.7.0_1
+libopencv_features2d.so.407 libopencv-4.7.0_1
+libopencv_flann.so.407 libopencv-4.7.0_1
+libopencv_highgui.so.407 libopencv-4.7.0_1
+libopencv_videoio.so.407 libopencv-4.7.0_1
+libopencv_imgcodecs.so.407 libopencv-4.7.0_1
+libopencv_imgproc.so.407 libopencv-4.7.0_1
+libopencv_core.so.407 libopencv-4.7.0_1
+libopencv_superres.so.407 libopencv-4.7.0_1
+libopencv_videostab.so.407 libopencv-4.7.0_1
+libopencv_gapi.so.407 libopencv-4.7.0_1
+libopencv_xobjdetect.so.407 libopencv-4.7.0_1
+libopencv_datasets.so.407 libopencv-4.7.0_1
+libopencv_dnn_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn_superres.so.407 libopencv-4.7.0_1
+libopencv_dpm.so.407 libopencv-4.7.0_1
+libopencv_phase_unwrapping.so.407 libopencv-4.7.0_1
+libopencv_stereo.so.407 libopencv-4.7.0_1
+libopencv_rapid.so.407 libopencv-4.7.0_1
+libopencv_intensity_transform.so.407 libopencv-4.7.0_1
+libopencv_alphamat.so.407 libopencv-4.7.0_1
+libopencv_barcode.so.407 libopencv-4.7.0_1
+libopencv_mcc.so.407 libopencv-4.7.0_1
 libuniconf.so.4.6 wvstreams-4.6.1_20
 libwvbase.so.4.6 wvstreams-4.6.1_20
 libwvutils.so.4.6 wvstreams-4.6.1_20
diff --git a/srcpkgs/opencv/template b/srcpkgs/opencv/template
index 69c635b1ad2b..41f3183f1582 100644
--- a/srcpkgs/opencv/template
+++ b/srcpkgs/opencv/template
@@ -1,7 +1,7 @@
 # Template file for 'opencv'
 pkgname=opencv
-version=4.6.0
-revision=4
+version=4.7.0
+revision=1
 create_wrksrc=yes
 build_wrksrc=${pkgname}-${version}
 build_style=cmake
@@ -24,8 +24,8 @@ homepage="https://opencv.org"
 changelog="https://github.com/opencv/opencv/wiki/ChangeLog"
 distfiles="https://github.com/opencv/opencv/archive/${version}.tar.gz
  https://github.com/opencv/opencv_contrib/archive/${version}.tar.gz>contrib.tar.gz"
-checksum="1ec1cba65f9f20fe5a41fda1586e01c70ea0c9a6d7b67c9e13edf0cfe2239277
- 1777d5fd2b59029cf537e5fd6f8aa68d707075822f90bde683fcde086f85f7a7"
+checksum="8df0079cdbe179748a18d44731af62a245a45ebf5085223dc03133954c662973
+ 42df840cf9055e59d0e22c249cfb19f04743e1bdad113d31b1573d3934d62584"
 patch_args="-Np1 -d ${build_wrksrc}"
 # tests hang indenfinitely, even with test data included
 make_check=no

From 2f957719832f178fc653340642316b49a9109d49 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 004/115] actiona: revbump for opencv-4.7.0

---
 srcpkgs/actiona/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/actiona/template b/srcpkgs/actiona/template
index cf5f0b7a2ae6..0d899311e6df 100644
--- a/srcpkgs/actiona/template
+++ b/srcpkgs/actiona/template
@@ -1,7 +1,7 @@
 # Template file for 'actiona'
 pkgname=actiona
 version=3.10.1
-revision=2
+revision=3
 build_style=qmake
 configure_args="PKGCONFIG_OPENCV=opencv4"
 hostmakedepends="pkg-config qt5-plugin-mysql qt5-qmake qt5-host-tools"

From bb3bd5f05a73d721120ce0f8e843425fde46aa75 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 005/115] qimgv: revbump for opencv-4.7.0

---
 srcpkgs/qimgv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qimgv/template b/srcpkgs/qimgv/template
index 7eb30db33992..dd341dfe1bfc 100644
--- a/srcpkgs/qimgv/template
+++ b/srcpkgs/qimgv/template
@@ -1,7 +1,7 @@
 # Template file for 'qimgv'
 pkgname=qimgv
 version=1.0.2
-revision=2
+revision=3
 build_style=cmake
 configure_args="$(vopt_if video -DVIDEO_SUPPORT=ON -DVIDEO_SUPPORT=OFF)
  $(vopt_if scale -DOPENCV_SUPPORT=ON -DOPENCV_SUPPORT=OFF)

From a085221468395a99b332f1e962e80f9d2d17655e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 006/115] retroshare: revbump for opencv-4.7.0

---
 srcpkgs/retroshare/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroshare/template b/srcpkgs/retroshare/template
index 8a0786c21a08..72023fa98b75 100644
--- a/srcpkgs/retroshare/template
+++ b/srcpkgs/retroshare/template
@@ -1,7 +1,7 @@
 # Template file for 'retroshare'
 pkgname=retroshare
 version=0.6.6
-revision=2
+revision=4
 build_style=qmake
 #XXX broadcast feature requires an ancient udp-discovery-cpp which either needs
 # to be fetched+patched (FTBFS) here or packaged :/

From 2e45ddd301a457901ebebeb8188b14d9c47a45a6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 007/115] waifu2x-converter-cpp: revbump for opencv-4.7.0

---
 srcpkgs/waifu2x-converter-cpp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waifu2x-converter-cpp/template b/srcpkgs/waifu2x-converter-cpp/template
index 8c095d0d7bab..aa52d8c981a8 100644
--- a/srcpkgs/waifu2x-converter-cpp/template
+++ b/srcpkgs/waifu2x-converter-cpp/template
@@ -1,7 +1,7 @@
 # Template file for 'waifu2x-converter-cpp'
 pkgname=waifu2x-converter-cpp
 version=5.2.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DINSTALL_MODELS=ON"
 hostmakedepends="pkg-config"

From 0111f0bd6e422d5b5e87182f65f95356084ef322 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:38 -0400
Subject: [PATCH 008/115] vlc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/vlc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vlc/template b/srcpkgs/vlc/template
index 651c94a1353a..855ca5238662 100644
--- a/srcpkgs/vlc/template
+++ b/srcpkgs/vlc/template
@@ -25,7 +25,7 @@ lib32disabled=yes
 hostmakedepends="automake libtool pkg-config flex gettext libgcrypt-devel
  live555-devel gettext-devel $(vopt_if lua lua52) $(vopt_if chromecast protobuf)"
 makedepends="
- avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg-devel freefont-ttf
+ avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg4-devel freefont-ttf
  gnutls-devel jack-devel liba52-devel libass-devel libbluray-devel
  libcdio-devel libdca-devel libdvbpsi-devel libdvdnav-devel libmad-devel
  libmatroska-devel libmodplug-devel libmpcdec-devel libmpeg2-devel

From e91c77476940f44a89f85b01fdc48c24e711ae2d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:55 -0400
Subject: [PATCH 009/115] osg: revbump for ffmpeg4-4.4.3

---
 srcpkgs/osg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/osg/template b/srcpkgs/osg/template
index a9ebbd287933..755793f7e11b 100644
--- a/srcpkgs/osg/template
+++ b/srcpkgs/osg/template
@@ -8,7 +8,7 @@ build_helper="qemu"
 configure_args="-DLIB_POSTFIX="
 hostmakedepends="pkg-config xrandr"
 makedepends="MesaLib-devel gtkglext-devel libcurl-devel giflib-devel librsvg-devel
- jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg-devel xine-lib-devel
+ jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg4-devel xine-lib-devel
  SDL2-devel gst-plugins-base1-devel
  $(vopt_if openexr libopenexr-devel)
  $(vopt_if poppler poppler-glib-devel)

From 65ffe1c2571ec81533c74ca7f93ea9e01b1254fc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:13 -0400
Subject: [PATCH 010/115] xine-lib: revbump for ffmpeg4-4.4.3

---
 srcpkgs/xine-lib/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/xine-lib/template b/srcpkgs/xine-lib/template
index f713eff49b07..ed6194c17d11 100644
--- a/srcpkgs/xine-lib/template
+++ b/srcpkgs/xine-lib/template
@@ -1,6 +1,6 @@
 # Template file for 'xine-lib'
 pkgname=xine-lib
-version=1.2.12
+version=1.2.13
 revision=1
 build_style=gnu-configure
 configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
@@ -8,7 +8,7 @@ configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
 hostmakedepends="automake gettext-devel libtool pkg-config perl"
 makedepends="
  zlib-devel alsa-lib-devel libxcb-devel libSM-devel libXext-devel libXv-devel
- libXvMC-devel liba52-devel libmad-devel ffmpeg-devel pulseaudio-devel
+ libXvMC-devel liba52-devel libmad-devel ffmpeg4-devel pulseaudio-devel
  jack-devel samba-devel libflac-devel libmodplug-devel libmpcdec-devel
  speex-devel libtheora-devel libvorbis-devel libdca-devel faad2-devel
  libcdio-devel libbluray-devel aalib-devel libcaca-devel libXinerama-devel
@@ -19,7 +19,7 @@ license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="http://www.xine-project.org"
 changelog="https://sourceforge.net/projects/xine/files/xine-lib/${version}/README.txt/view"
 distfiles="${SOURCEFORGE_SITE}/xine/${pkgname}-${version}.tar.xz"
-checksum=d606270468e1540c2a89c0d7f5fdf11e17ecc0c2698cc0bcb1065ff26abee098
+checksum=5f10d6d718a4a51c17ed1b32b031d4f9b80b061e8276535b2be31e5ac4b75e6f
 
 case "$XBPS_TARGET_MACHINE" in
 	i686-musl)

From f0f5343087b629108c29c467a78a435825978c4f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 011/115] QMPlay2: revbump for ffmpeg-6.0

---
 srcpkgs/QMPlay2/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/QMPlay2/template b/srcpkgs/QMPlay2/template
index 850df9d418b9..8d2ce7a76156 100644
--- a/srcpkgs/QMPlay2/template
+++ b/srcpkgs/QMPlay2/template
@@ -1,7 +1,7 @@
 # Template file for 'QMPlay2'
 pkgname=QMPlay2
 version=23.06.17
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools"
 makedepends="alsa-lib-devel ffmpeg-devel libass-devel libcdio-devel libgme-devel

From d27d55fab5485edaabdd3da60366a3a07784d3c8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 012/115] alsa-plugins: revbump for ffmpeg-6.0

---
 srcpkgs/alsa-plugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/alsa-plugins/template b/srcpkgs/alsa-plugins/template
index 0bfa6d9fd264..a5708a7d82a8 100644
--- a/srcpkgs/alsa-plugins/template
+++ b/srcpkgs/alsa-plugins/template
@@ -1,7 +1,7 @@
 # Template file for 'alsa-plugins'
 pkgname=alsa-plugins
 version=1.2.7.1
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--disable-maemo-plugin"
 hostmakedepends="pkg-config"

From e2e9c59756487c7aefa4fa41d15020094c69db3d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 013/115] arcan: revbump for ffmpeg-6.0

---
 srcpkgs/arcan/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/arcan/template b/srcpkgs/arcan/template
index 7be9652eccf3..ccc7df11ceac 100644
--- a/srcpkgs/arcan/template
+++ b/srcpkgs/arcan/template
@@ -2,7 +2,7 @@
 # !! keep synced with: acfgfs aclip aloadimage
 pkgname=arcan
 version=0.6.2.1
-revision=1
+revision=2
 create_wrksrc=yes
 build_wrksrc=arcan/src
 build_style=cmake

From 97625b27c6f3d0bae864928bf2ba2fa7aa6c07fd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 014/115] attract: revbump for ffmpeg4-4.4.3

---
 srcpkgs/attract/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/attract/template b/srcpkgs/attract/template
index 26144e931a3c..e760bf0d18ae 100644
--- a/srcpkgs/attract/template
+++ b/srcpkgs/attract/template
@@ -1,12 +1,12 @@
 # Template file for 'attract'
 pkgname=attract
 version=2.6.2
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="VERBOSE=1"
 make_use_env=yes
 hostmakedepends="pkg-config"
-makedepends="SFML-devel ffmpeg-devel fontconfig-devel glu-devel libarchive-devel
+makedepends="SFML-devel ffmpeg4-devel fontconfig-devel glu-devel libarchive-devel
  libcurl-devel libjpeg-turbo-devel xine-lib rapidjson libXrandr-devel"
 depends="git"
 short_desc="Attract-Mode is a graphical frontend for emulators"

From 4ddc49f5c1738bbf513a09c5d763ca07ae7f00ea Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 015/115] aubio: revbump for ffmpeg-6.0

---
 srcpkgs/aubio/patches/ffmpeg5.patch | 25 +++++++++++++++++++++++++
 srcpkgs/aubio/template              |  2 +-
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/aubio/patches/ffmpeg5.patch

diff --git a/srcpkgs/aubio/patches/ffmpeg5.patch b/srcpkgs/aubio/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..aace41a6e6d9
--- /dev/null
+++ b/srcpkgs/aubio/patches/ffmpeg5.patch
@@ -0,0 +1,25 @@
+From 8a05420e5dd8c7b8b2447f82dc919765876511b3 Mon Sep 17 00:00:00 2001
+From: Paul Brossier <piem@piem.org>
+Date: Tue, 25 Jan 2022 18:30:27 +0100
+Subject: [PATCH] [source_avcodec] define FF_API_LAVF_AVCTX for libavcodec >
+ 59, thx @berolinux (closes gh-353)
+
+---
+ src/io/source_avcodec.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/io/source_avcodec.c b/src/io/source_avcodec.c
+index e0ae93b5..1421bd9a 100644
+--- a/src/io/source_avcodec.c
++++ b/src/io/source_avcodec.c
+@@ -68,6 +68,10 @@
+ #define AUBIO_AVCODEC_MAX_BUFFER_SIZE AV_INPUT_BUFFER_MIN_SIZE
+ #endif
+ 
++#if LIBAVCODEC_VERSION_MAJOR >= 59
++#define FF_API_LAVF_AVCTX 1
++#endif
++
+ struct _aubio_source_avcodec_t {
+   uint_t hop_size;
+   uint_t samplerate;
diff --git a/srcpkgs/aubio/template b/srcpkgs/aubio/template
index ad1c4b256991..7d875cc02541 100644
--- a/srcpkgs/aubio/template
+++ b/srcpkgs/aubio/template
@@ -1,7 +1,7 @@
 # Template file for 'aubio'
 pkgname=aubio
 version=0.4.9
-revision=1
+revision=2
 build_style=waf3
 # XXX lash, pure and swig support.
 hostmakedepends="pkg-config txt2man"

From 5ee255293d87466fb798e6dba5bdf142f7b7bab0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 016/115] audacious-plugins: revbump for ffmpeg-6.0

---
 .../audacious-plugins/patches/ffmpeg5.patch   | 43 +++++++++++++++++++
 srcpkgs/audacious-plugins/template            |  2 +-
 2 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/audacious-plugins/patches/ffmpeg5.patch

diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg5.patch b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..4e5e34099d71
--- /dev/null
+++ b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
@@ -0,0 +1,43 @@
+commit 298aa371c56c2f52c25a33d9bdec4918b11cebdc
+Author: tibequadorian <tibequadorian@posteo.de>
+Date:   Sat Mar 19 18:40:12 2022 +0100
+
+    audacious-plugins: rebuild against ffmpeg-5.0
+
+diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+new file mode 100644
+index 0000000000..617c11215b
+--- /dev/null
++++ b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+@@ -0,0 +1,31 @@
++From f60beb400eeb1e4778bbfd738bc4a4ccef3de539 Mon Sep 17 00:00:00 2001
++From: John Lindgren <john@jlindgren.net>
++Date: Sat, 5 Mar 2022 12:05:34 -0500
++Subject: [PATCH] Fix build with FFmpeg 5.0
++
++---
++ src/ffaudio/ffaudio-core.cc | 4 ++--
++ 1 file changed, 2 insertions(+), 2 deletions(-)
++
++diff --git a/src/ffaudio/ffaudio-core.cc b/src/ffaudio/ffaudio-core.cc
++index 16dc63e3a..a2b95fd6c 100644
++--- a/src/ffaudio/ffaudio-core.cc
+++++ b/src/ffaudio/ffaudio-core.cc
++@@ -274,7 +274,7 @@ static AVInputFormat * get_format_by_content (const char * name, VFSFile & file)
++         AVProbeData d = {name, buf, filled};
++         score = target;
++ 
++-        f = av_probe_input_format2 (& d, true, & score);
+++        f = (AVInputFormat *) av_probe_input_format2 (& d, true, & score);
++         if (f)
++             break;
++ 
++@@ -347,7 +347,7 @@ static bool find_codec (AVFormatContext * c, CodecInfo * cinfo)
++ #endif
++         if (stream && stream->codecpar && stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
++         {
++-            AVCodec * codec = avcodec_find_decoder (stream->codecpar->codec_id);
+++            AVCodec * codec = (AVCodec *) avcodec_find_decoder (stream->codecpar->codec_id);
++ 
++             if (codec)
++             {
diff --git a/srcpkgs/audacious-plugins/template b/srcpkgs/audacious-plugins/template
index 88cbc1671fc6..beebfae59ed4 100644
--- a/srcpkgs/audacious-plugins/template
+++ b/srcpkgs/audacious-plugins/template
@@ -2,7 +2,7 @@
 #Keep in sync with audacious!
 pkgname=audacious-plugins
 version=4.3.1
-revision=1
+revision=2
 build_style=meson
 configure_args="$(vopt_bool gtk3 gtk) $(vopt_bool gtk3)
  $(vopt_bool qt) $(vopt_bool qt qt6)"

From 6f05c8928311acda0fff1d9d201246860c53a95e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 017/115] audacity: revbump for ffmpeg4-4.4.3

---
 srcpkgs/audacity/template | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/audacity/template b/srcpkgs/audacity/template
index d509c0a89407..11e20255685b 100644
--- a/srcpkgs/audacity/template
+++ b/srcpkgs/audacity/template
@@ -1,7 +1,7 @@
 # Template file for 'audacity'
 pkgname=audacity
 version=2.4.1
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--with-ffmpeg=system --with-libsndfile=system --with-expat=system
  --with-libsoxr=system --with-lame=system --with-lv2=system ac_cv_path_WX_CONFIG=wx-config-gtk3"
@@ -9,7 +9,7 @@ hostmakedepends="pkg-config cmake gettext libtool m4 which"
 makedepends="jack-devel wxWidgets-gtk3-devel gtk+3-devel
  libmad-devel soundtouch-devel libsoxr-devel
  vamp-plugin-sdk-devel lame-devel libid3tag-devel libflac-devel
- ffmpeg-devel twolame-devel serd-devel lv2 lilv-devel suil-devel"
+ ffmpeg4-devel twolame-devel serd-devel lv2 lilv-devel suil-devel"
 depends="desktop-file-utils hicolor-icon-theme"
 short_desc="Graphical cross-platform audio editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
@@ -33,5 +33,4 @@ post_install() {
 	vcopy plug-ins /usr/share/audacity
 
 	rm ${DESTDIR}/usr/share/doc/audacity/LICENSE.txt
-	vlicense LICENSE.txt LICENSE
 }

From 7f175bd134e1e3bbe8e6063e7f1387eb12c5b134 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 018/115] avidemux: revbump for ffmpeg-6.0

---
 srcpkgs/avidemux/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/avidemux/template b/srcpkgs/avidemux/template
index 253a0243e225..557285982d2b 100644
--- a/srcpkgs/avidemux/template
+++ b/srcpkgs/avidemux/template
@@ -1,7 +1,7 @@
 # Template file for 'avidemux'
 pkgname=avidemux
 version=2.8.0
-revision=2
+revision=3
 # Can't be compiled for aarch64, arm* or mips*
 archs="x86_64* i686*"
 hostmakedepends="cmake pkg-config qt5-host-tools qt5-devel tar yasm"

From 527e92ea068fd1cd3aac12891cabac2415819feb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 019/115] baresip: revbump for ffmpeg-6.0

---
 srcpkgs/baresip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/baresip/template b/srcpkgs/baresip/template
index f1bd1817048b..b21e22334316 100644
--- a/srcpkgs/baresip/template
+++ b/srcpkgs/baresip/template
@@ -1,7 +1,7 @@
 # Template file for 'baresip'
 pkgname=baresip
 version=2.10.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config glib-devel"
 makedepends="libgsm-devel libpng-devel openssl-devel libsndfile-devel

From 5f7f0a4f1eff945305dbe8f12d91ef2bc1fa0fbe Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 020/115] blender: revbump for ffmpeg-6.0

---
 srcpkgs/blender/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index 6ba9f6618d72..0630dbe7ff42 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -1,7 +1,7 @@
 # Template file for 'blender'
 pkgname=blender
 version=3.6.0
-revision=1
+revision=2
 archs="x86_64* ppc64*"
 build_style="cmake"
 pycompile_dirs="/usr/share/blender/${version%.*}/scripts"
@@ -9,8 +9,8 @@ configure_args="-DWITH_INSTALL_PORTABLE=OFF -DWITH_PYTHON_INSTALL=OFF
  -DWITH_JACK=ON -DWITH_CODEC_FFMPEG=ON -DWITH_CODEC_SNDFILE=ON -DWITH_OPENMP=ON
  -DWITH_FFTW3=ON -DWITH_MOD_OCEANSIM=ON -DWITH_CYCLES_EMBREE=OFF -DWITH_OPENCOLORIO=ON
  -DWITH_IMAGE_OPENEXR=ON -DWITH_IMAGE_OPENJPEG=ON -DWITH_OPENSUBDIV=ON
- -DWITH_OPENCOLLADA=ON -DWITH_SYSTEM_GLEW=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
- -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_LIBDECOR=ON
+ -DWITH_OPENCOLLADA=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
+ -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_WAYLAND_LIBDECOR=ON
  -DWITH_BUILDINFO=OFF -DPYTHON_VERSION=${py3_ver} -DPYTHON_LIBPATH=/usr/lib
  -DPYTHON_LIBRARY=python${py3_ver}${py3_abiver} -DPYTHON_INCLUDE_DIRS=/${py3_inc}
  -DWITH_SYSTEM_LZO=ON -DWITH_SYSTEM_EIGEN3=ON -DWITH_SYSTEM_FREETYPE=ON"

From 9f404a3a6758f392a7964e56802b16bff5b8dbec Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 021/115] cantata: revbump for ffmpeg-6.0

---
 srcpkgs/cantata/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cantata/template b/srcpkgs/cantata/template
index 4b417d80d5c2..8a90aaa4c07a 100644
--- a/srcpkgs/cantata/template
+++ b/srcpkgs/cantata/template
@@ -1,7 +1,7 @@
 # Template file for 'cantata'
 pkgname=cantata
 version=2.5.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools qt5-tools"
 makedepends="qt5-devel qt5-tools-devel qt5-svg-devel qt5-xmlpatterns-devel

From a2cfc239bd7efd64faf3392baf0d627676c52b47 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 022/115] ccextractor: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ccextractor/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/ccextractor/template b/srcpkgs/ccextractor/template
index 9abcd82852b2..6eccad5885af 100644
--- a/srcpkgs/ccextractor/template
+++ b/srcpkgs/ccextractor/template
@@ -1,12 +1,12 @@
 # Template file for 'ccextractor'
 pkgname=ccextractor
 version=0.93
-revision=1
+revision=2
 build_wrksrc="linux"
 build_style=gnu-configure
 configure_args="--enable-ocr --enable-hardsubx"
 hostmakedepends="automake pkg-config"
-makedepends="leptonica-devel tesseract-ocr-devel ffmpeg-devel"
+makedepends="leptonica-devel tesseract-ocr-devel ffmpeg4-devel"
 short_desc="Extract subtitles from video streams"
 maintainer="newbluemoon <blaumolch@mailbox.org>"
 license="GPL-2.0-or-later"

From 3bfb0288ad4674f7fd6fdb5142404d8df871e889 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 023/115] chromaprint: revbump for ffmpeg-6.0

---
 srcpkgs/chromaprint/patches/ffmpeg5.patch | 569 ++++++++++++++++++++++
 srcpkgs/chromaprint/template              |   2 +-
 2 files changed, 570 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromaprint/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromaprint/patches/ffmpeg5.patch b/srcpkgs/chromaprint/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..a9fd307a23c8
--- /dev/null
+++ b/srcpkgs/chromaprint/patches/ffmpeg5.patch
@@ -0,0 +1,569 @@
+From 8ccad6937177b1b92e40ab8f4447ea27bac009a7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= <lalinsky@gmail.com>
+Date: Fri, 4 Nov 2022 21:47:38 +0100
+Subject: [PATCH] Use FFmpeg 5.x (#120)
+
+* Use FFmpeg 5.1.2 for CI builds
+
+* Build on Ubuntu 20.04
+
+* Upgrade code to FFmpeg 5.x APIs
+
+* Only set FFmpeg include dirs if building tools
+
+* No longer needed
+
+* Use ubuntu 20.04
+---
+ .github/workflows/build.yml                   |   6 +-
+ CMakeLists.txt                                |  16 --
+ package/build.sh                              |   4 +-
+ src/audio/ffmpeg_audio_processor.h            |   2 -
+ src/audio/ffmpeg_audio_processor_avresample.h |  72 -------
+ src/audio/ffmpeg_audio_processor_swresample.h |  18 +-
+ src/audio/ffmpeg_audio_reader.h               | 197 +++++++++---------
+ tests/CMakeLists.txt                          |   6 +
+ 8 files changed, 122 insertions(+), 199 deletions(-)
+ delete mode 100644 src/audio/ffmpeg_audio_processor_avresample.h
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index f8d6a32..4da2405 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -84,9 +84,6 @@ find_package(FFmpeg)
+ if(FFMPEG_LIBRARIES)
+ 	cmake_push_check_state(RESET)
+ 	set(CMAKE_REQUIRED_LIBRARIES ${FFMPEG_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -lm)
+-	check_function_exists(av_packet_unref HAVE_AV_PACKET_UNREF)
+-	check_function_exists(av_frame_alloc HAVE_AV_FRAME_ALLOC)
+-	check_function_exists(av_frame_free HAVE_AV_FRAME_FREE)
+ 	cmake_pop_check_state()
+ endif()
+
+@@ -163,14 +160,11 @@ message(STATUS "Using ${FFT_LIB} for FFT calculations")
+ if(NOT AUDIO_PROCESSOR_LIB)
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+ 		set(AUDIO_PROCESSOR_LIB "swresample")
+-	elseif(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(AUDIO_PROCESSOR_LIB "avresample")
+ 	endif()
+ endif()
+
+ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE OFF)
+ 		set(USE_SWRESAMPLE ON)
+ 		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBSWRESAMPLE_LIBRARIES})
+ 		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBSWRESAMPLE_INCLUDE_DIRS})
+@@ -178,16 +172,6 @@ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+ 	endif()
+ 	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+-elseif(AUDIO_PROCESSOR_LIB STREQUAL "avresample")
+-	if(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE ON)
+-		set(USE_SWRESAMPLE OFF)
+-		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBAVRESAMPLE_LIBRARIES})
+-		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBAVRESAMPLE_INCLUDE_DIRS})
+-	else()
+-		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+-	endif()
+-	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+ else()
+ 	message(STATUS "Building without audio conversion support, please install FFmpeg with libswresample")
+ endif()
+diff --git a/package/build.sh b/package/build.sh
+index da631ae..b41d36e 100755
+--- a/package/build.sh
++++ b/package/build.sh
+@@ -7,8 +7,8 @@ set -eux
+
+ BASE_DIR=$(cd $(dirname $0)/.. && pwd)
+
+-FFMPEG_VERSION=4.4.1
+-FFMPEG_BUILD_TAG=v4.4.1-1
++FFMPEG_VERSION=5.1.2
++FFMPEG_BUILD_TAG=v${FFMPEG_VERSION}-1
+
+ TMP_BUILD_DIR=$BASE_DIR/$(mktemp -d build.XXXXXXXX)
+ trap 'rm -rf $TMP_BUILD_DIR' EXIT
+diff --git a/src/audio/ffmpeg_audio_processor.h b/src/audio/ffmpeg_audio_processor.h
+index 7628fc7..39f4f6d 100644
+--- a/src/audio/ffmpeg_audio_processor.h
++++ b/src/audio/ffmpeg_audio_processor.h
+@@ -10,8 +10,6 @@
+
+ #if defined(USE_SWRESAMPLE)
+ #include "audio/ffmpeg_audio_processor_swresample.h"
+-#elif defined(USE_AVRESAMPLE)
+-#include "audio/ffmpeg_audio_processor_avresample.h"
+ #else
+ #error "no audio processing library"
+ #endif
+diff --git a/src/audio/ffmpeg_audio_processor_avresample.h b/src/audio/ffmpeg_audio_processor_avresample.h
+deleted file mode 100644
+index bd85f92..0000000
+--- a/src/audio/ffmpeg_audio_processor_avresample.h
++++ /dev/null
+@@ -1,72 +0,0 @@
+-// Copyright (C) 2016  Lukas Lalinsky
+-// Distributed under the MIT license, see the LICENSE file for details.
+-
+-#ifndef CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-#define CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-
+-extern "C" {
+-#include <libavresample/avresample.h>
+-}
+-
+-namespace chromaprint {
+-
+-class FFmpegAudioProcessor {
+-public:
+-	FFmpegAudioProcessor() {
+-		m_resample_ctx = avresample_alloc_context();
+-	}
+-
+-	~FFmpegAudioProcessor() {
+-		avresample_free(&m_resample_ctx);
+-	}
+-
+-	void SetCompatibleMode() {
+-		av_opt_set_int(m_resample_ctx, "filter_size", 16, 0);
+-		av_opt_set_int(m_resample_ctx, "phase_shift", 8, 0);
+-		av_opt_set_int(m_resample_ctx, "linear_interp", 1, 0);
+-		av_opt_set_double(m_resample_ctx, "cutoff", 0.8, 0);
+-	}
+-
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "in_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_rate", sample_rate, 0);
+-	}
+-
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "out_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_rate, 0);
+-	}
+-
+-	int Init() {
+-		return avresample_open(m_resample_ctx);
+-	}
+-
+-	int Convert(uint8_t **out, int out_count, const uint8_t **in, int in_count) {
+-		return avresample_convert(m_resample_ctx, out, 0, out_count, (uint8_t **) in, 0, in_count);
+-	}
+-
+-	int Flush(uint8_t **out, int out_count) {
+-		return avresample_read(m_resample_ctx, out, out_count);
+-	}
+-
+-private:
+-	AVAudioResampleContext *m_resample_ctx = nullptr;
+-};
+-
+-}; // namespace chromaprint
+-
+-#endif
+diff --git a/src/audio/ffmpeg_audio_processor_swresample.h b/src/audio/ffmpeg_audio_processor_swresample.h
+index b86266b..b1d4bea 100644
+--- a/src/audio/ffmpeg_audio_processor_swresample.h
++++ b/src/audio/ffmpeg_audio_processor_swresample.h
+@@ -28,30 +28,28 @@ public:
+ 		av_opt_set_double(m_swr_ctx, "cutoff", 0.8, 0);
+ 	}
+
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "icl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "ich", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetInputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "in_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "isf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "in_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "isr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "in_sample_rate", sample_rate, 0);
+ 	}
+
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "ocl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "och", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetOutputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "out_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "osf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "out_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "osr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "out_sample_rate", sample_rate, 0);
+ 	}
+
+ 	int Init() {
+diff --git a/src/audio/ffmpeg_audio_reader.h b/src/audio/ffmpeg_audio_reader.h
+index 5550164..1c6b346 100644
+--- a/src/audio/ffmpeg_audio_reader.h
++++ b/src/audio/ffmpeg_audio_reader.h
+@@ -62,7 +62,7 @@ public:
+ 	bool Read(const int16_t **data, size_t *size);
+
+ 	bool IsOpen() const { return m_opened; }
+-	bool IsFinished() const { return m_finished && !m_got_frame; }
++	bool IsFinished() const { return !m_has_more_packets && !m_has_more_frames; }
+
+ 	std::string GetError() const { return m_error; }
+ 	int GetErrorCode() const { return m_error_code; }
+@@ -74,20 +74,19 @@ private:
+ 	uint8_t *m_convert_buffer[1] = { nullptr };
+ 	int m_convert_buffer_nb_samples = 0;
+
+-	AVInputFormat *m_input_fmt = nullptr;
++	const AVInputFormat *m_input_fmt = nullptr;
+ 	AVDictionary *m_input_opts = nullptr;
+
+ 	AVFormatContext *m_format_ctx = nullptr;
+ 	AVCodecContext *m_codec_ctx = nullptr;
+-	AVFrame *m_frame = nullptr;
+ 	int m_stream_index = -1;
+ 	std::string m_error;
+ 	int m_error_code = 0;
+-	bool m_finished = false;
+ 	bool m_opened = false;
+-	int m_got_frame = 0;
+-	AVPacket m_packet;
+-	AVPacket m_packet0;
++	bool m_has_more_packets = true;
++	bool m_has_more_frames = true;
++	AVPacket *m_packet = nullptr;
++	AVFrame *m_frame = nullptr;
+
+ 	int m_output_sample_rate = 0;
+ 	int m_output_channels = 0;
+@@ -98,19 +97,12 @@ private:
+
+ inline FFmpegAudioReader::FFmpegAudioReader() {
+ 	av_log_set_level(AV_LOG_QUIET);
+-
+-	av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
+ }
+
+ inline FFmpegAudioReader::~FFmpegAudioReader() {
+ 	Close();
+ 	av_dict_free(&m_input_opts);
+ 	av_freep(&m_convert_buffer[0]);
+-	av_packet_unref(&m_packet0);
+ }
+
+ inline bool FFmpegAudioReader::SetInputFormat(const char *name) {
+@@ -135,11 +127,10 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ 	Close();
+
+-    av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
++	m_packet = av_packet_alloc();
++	if (!m_packet) {
++		return false;
++	}
+
+ 	ret = avformat_open_input(&m_format_ctx, file_name.c_str(), m_input_fmt, &m_input_opts);
+ 	if (ret < 0) {
+@@ -153,26 +144,31 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		return false;
+ 	}
+
+-	AVCodec *codec;
++	const AVCodec *codec;
+ 	ret = av_find_best_stream(m_format_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &codec, 0);
+ 	if (ret < 0) {
+ 		SetError("Could not find any audio stream in the file", ret);
+ 		return false;
+ 	}
+ 	m_stream_index = ret;
++	auto stream = m_format_ctx->streams[m_stream_index];
+
+-	m_codec_ctx = m_format_ctx->streams[m_stream_index]->codec;
++	m_codec_ctx = avcodec_alloc_context3(codec);
+ 	m_codec_ctx->request_sample_fmt = AV_SAMPLE_FMT_S16;
+
++	ret = avcodec_parameters_to_context(m_codec_ctx, stream->codecpar);
++	if (ret < 0) {
++		SetError("Could not copy the stream parameters", ret);
++		return false;
++	}
++
+ 	ret = avcodec_open2(m_codec_ctx, codec, nullptr);
+ 	if (ret < 0) {
+ 		SetError("Could not open the codec", ret);
+ 		return false;
+ 	}
+
+-	if (!m_codec_ctx->channel_layout) {
+-		m_codec_ctx->channel_layout = av_get_default_channel_layout(m_codec_ctx->channels);
+-	}
++	av_dump_format(m_format_ctx, 0, "foo", 0);
+
+ 	m_frame = av_frame_alloc();
+ 	if (!m_frame) {
+@@ -183,19 +179,23 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		m_output_sample_rate = m_codec_ctx->sample_rate;
+ 	}
+
+-	if (!m_output_channels) {
+-		m_output_channels = m_codec_ctx->channels;
++	AVChannelLayout output_channel_layout;
++	if (m_output_channels) {
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
++	} else {
++		m_output_channels = m_codec_ctx->ch_layout.nb_channels;
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
+ 	}
+
+-	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
++	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->ch_layout.nb_channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
+ 		m_converter.reset(new FFmpegAudioProcessor());
+ 		m_converter->SetCompatibleMode();
+ 		m_converter->SetInputSampleFormat(m_codec_ctx->sample_fmt);
+ 		m_converter->SetInputSampleRate(m_codec_ctx->sample_rate);
+-		m_converter->SetInputChannelLayout(m_codec_ctx->channel_layout);
++		m_converter->SetInputChannelLayout(&(m_codec_ctx->ch_layout));
+ 		m_converter->SetOutputSampleFormat(AV_SAMPLE_FMT_S16);
+ 		m_converter->SetOutputSampleRate(m_output_sample_rate);
+-		m_converter->SetOutputChannelLayout(av_get_default_channel_layout(m_output_channels));
++		m_converter->SetOutputChannelLayout(&output_channel_layout);
+ 		auto ret = m_converter->Init();
+ 		if (ret != 0) {
+ 			SetError("Could not create an audio converter instance", ret);
+@@ -203,10 +203,11 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		}
+ 	}
+
++	av_channel_layout_uninit(&output_channel_layout);
++
+ 	m_opened = true;
+-	m_finished = false;
+-	m_got_frame = 0;
+-	m_nb_packets = 0;
++	m_has_more_packets = true;
++	m_has_more_frames = true;
+ 	m_decode_error = 0;
+
+ 	return true;
+@@ -214,6 +215,7 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ inline void FFmpegAudioReader::Close() {
+ 	av_frame_free(&m_frame);
++	av_packet_free(&m_packet);
+
+ 	m_stream_index = -1;
+
+@@ -252,91 +254,98 @@ inline bool FFmpegAudioReader::Read(const int16_t **data, size_t *size) {
+ 		return false;
+ 	}
+
++	*data = nullptr;
++	*size = 0;
++
+ 	int ret;
++	bool needs_packet = false;
+ 	while (true) {
+-		while (m_packet.size <= 0) {
+-			av_packet_unref(&m_packet0);
+-			av_init_packet(&m_packet);
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			ret = av_read_frame(m_format_ctx, &m_packet);
++		while (needs_packet && m_packet->size == 0) {
++			ret = av_read_frame(m_format_ctx, m_packet);
+ 			if (ret < 0) {
+ 				if (ret == AVERROR_EOF) {
+-					m_finished = true;
++					needs_packet = false;
++					m_has_more_packets = false;
+ 					break;
+-				} else {
++				}
++				SetError("Error reading from the audio source", ret);
++				return false;
++			}
++			if (m_packet->stream_index == m_stream_index) {
++				needs_packet = false;
++			} else {
++				av_packet_unref(m_packet);
++			}
++		}
++
++		if (m_packet->size != 0) {
++			ret = avcodec_send_packet(m_codec_ctx, m_packet);
++			if (ret < 0) {
++				if (ret != AVERROR(EAGAIN)) {
+ 					SetError("Error reading from the audio source", ret);
+ 					return false;
+ 				}
+-			}
+-			m_packet0 = m_packet;
+-			if (m_packet.stream_index != m_stream_index) {
+-				m_packet.data = nullptr;
+-				m_packet.size = 0;
+ 			} else {
+-				m_nb_packets++;
++				av_packet_unref(m_packet);
+ 			}
+ 		}
+
+-		ret = avcodec_decode_audio4(m_codec_ctx, m_frame, &m_got_frame, &m_packet);
++		ret = avcodec_receive_frame(m_codec_ctx, m_frame);
+ 		if (ret < 0) {
+-			if (m_decode_error) {
+-				SetError("Error decoding audio frame", m_decode_error);
+-				return false;
++			if (ret == AVERROR_EOF) {
++				m_has_more_frames = false;
++			} else if (ret == AVERROR(EAGAIN)) {
++				if (m_has_more_packets) {
++					needs_packet = true;
++					continue;
++				} else {
++					m_has_more_frames = false;
++				}
+ 			}
+-			m_decode_error = ret;
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			continue;
++			SetError("Error decoding the audio source", ret);
++			return false;
+ 		}
+
+-		break;
+-	}
+-
+-	m_decode_error = 0;
+-
+-	const int decoded = std::min(ret, m_packet.size);
+-	m_packet.data += decoded;
+-	m_packet.size -= decoded;
+-
+-	if (m_got_frame) {
+-		if (m_converter) {
+-			if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
+-				int linsize;
+-				av_freep(&m_convert_buffer[0]);
+-				m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
+-				ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
+-				if (ret < 0) {
+-					SetError("Couldn't allocate audio converter buffer", ret);
++		if (m_frame->nb_samples > 0) {
++			if (m_converter) {
++				if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
++					int linsize;
++					av_freep(&m_convert_buffer[0]);
++					m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
++					ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->ch_layout.nb_channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
++					if (ret < 0) {
++						SetError("Couldn't allocate audio converter buffer", ret);
++						return false;
++					}
++				}
++				auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
++				if (nb_samples < 0) {
++					SetError("Couldn't convert audio", ret);
+ 					return false;
+ 				}
+-			}
+-			auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			}
+-			*data = (const int16_t *) m_convert_buffer[0];
+-			*size = nb_samples;
+-		} else {
+-			*data = (const int16_t *) m_frame->data[0];
+-			*size = m_frame->nb_samples;
+-		}
+-	} else {
+-		if (m_finished && m_converter) {
+-			auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			} else if (nb_samples > 0) {
+-				m_got_frame = 1;
+ 				*data = (const int16_t *) m_convert_buffer[0];
+ 				*size = nb_samples;
++			} else {
++				*data = (const int16_t *) m_frame->data[0];
++				*size = m_frame->nb_samples;
++			}
++		} else {
++			if (m_converter) {
++				if (IsFinished()) {
++					auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
++					if (nb_samples < 0) {
++						SetError("Couldn't convert audio", ret);
++						return false;
++					} else if (nb_samples > 0) {
++						*data = (const int16_t *) m_convert_buffer[0];
++						*size = nb_samples;
++					}
++				}
+ 			}
+ 		}
+-	}
+
+-	return true;
++		return true;
++	}
+ }
+
+ inline void FFmpegAudioReader::SetError(const char *message, int errnum) {
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index a2b517b..123e643 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -38,6 +38,12 @@ set(SRCS
+
+ if(BUILD_TOOLS)
+ 	set(SRCS ${SRCS} ../src/audio/ffmpeg_audio_reader_test.cpp)
++    include_directories(
++        ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}
++        ${AUDIO_PROCESSOR_INCLUDE_DIRS}
++    )
+ 	link_libraries(fpcalc_libs)
+ endif()
+
+-- 
+2.38.1
+
+
diff --git a/srcpkgs/chromaprint/template b/srcpkgs/chromaprint/template
index 7ef7838949f3..1f7bbc70a22c 100644
--- a/srcpkgs/chromaprint/template
+++ b/srcpkgs/chromaprint/template
@@ -1,7 +1,7 @@
 # Template file for 'chromaprint'
 pkgname=chromaprint
 version=1.5.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DBUILD_TOOLS=ON"
 make_check_target="check"

From 609891dacd2983f43b52c80daa0eb38029a73021 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 024/115] chromium: revbump for ffmpeg-6.0

---
 .../patches/chromium-93-ffmpeg-4.4.patch      | 36 --------------
 srcpkgs/chromium/patches/ffmpeg5.patch        | 47 +++++++++++++++++++
 srcpkgs/chromium/template                     |  2 +-
 3 files changed, 48 insertions(+), 37 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch
 create mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch b/srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch
deleted file mode 100644
index f0ec736f98bc..000000000000
--- a/srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch
+++ /dev/null
@@ -1,36 +0,0 @@
-diff --git a/media/filters/ffmpeg_demuxer.cc b/media/filters/ffmpeg_demuxer.cc
-index ac4713b07268..492a9a37d096 100644
---- a/media/filters/ffmpeg_demuxer.cc
-+++ b/media/filters/ffmpeg_demuxer.cc
-@@ -427,11 +427,11 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
-   scoped_refptr<DecoderBuffer> buffer;
- 
-   if (type() == DemuxerStream::TEXT) {
--    size_t id_size = 0;
-+    int id_size = 0;
-     uint8_t* id_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
- 
--    size_t settings_size = 0;
-+    int settings_size = 0;
-     uint8_t* settings_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
- 
-@@ -443,7 +443,7 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
-     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
-                                      side_data.data(), side_data.size());
-   } else {
--    size_t side_data_size = 0;
-+    int side_data_size = 0;
-     uint8_t* side_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
- 
-@@ -504,7 +504,7 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
-                                        packet->size - data_offset);
-     }
- 
--    size_t skip_samples_size = 0;
-+    int skip_samples_size = 0;
-     const uint32_t* skip_samples_ptr =
-         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
-             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..24e2da38e34c
--- /dev/null
+++ b/srcpkgs/chromium/patches/ffmpeg5.patch
@@ -0,0 +1,47 @@
+--- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
++++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
+@@ -92,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+-  if (stream->start_time != kNoFFmpegTimestamp)
++  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -1597,7 +1585,7 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+@@ -1618,7 +1606,7 @@
+     if (stream->type() != DemuxerStream::VIDEO)
+       continue;
+ 
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+ 
+     if (!stream->IsEnabled())
diff --git a/srcpkgs/chromium/template b/srcpkgs/chromium/template
index b4a39dfd3815..c29453cd1f50 100644
--- a/srcpkgs/chromium/template
+++ b/srcpkgs/chromium/template
@@ -2,7 +2,7 @@
 pkgname=chromium
 # See https://chromiumdash.appspot.com/releases?platform=Linux for the latest version
 version=114.0.5735.106
-revision=1
+revision=2
 archs="i686* x86_64* aarch64* armv7l*"
 hostmakedepends="
  $(vopt_if clang "clang lld llvm15")

From 48368c55484606451082b2609a6f4f66405a0715 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 025/115] cmus: revbump for ffmpeg-6.0

---
 srcpkgs/cmus/patches/ffmpeg6.patch | 12 ++++++++++++
 srcpkgs/cmus/template              |  2 +-
 2 files changed, 13 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/cmus/patches/ffmpeg6.patch

diff --git a/srcpkgs/cmus/patches/ffmpeg6.patch b/srcpkgs/cmus/patches/ffmpeg6.patch
new file mode 100644
index 000000000000..ffa95ab81110
--- /dev/null
+++ b/srcpkgs/cmus/patches/ffmpeg6.patch
@@ -0,0 +1,12 @@
+--- a/ip/ffmpeg.c
++++ b/ip/ffmpeg.c
+@@ -202,9 +202,6 @@ static int ffmpeg_open(struct input_plugin_data *ip_data)
+ 			break;
+ 		}
+ 
+-		if (codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+-			cc->flags |= AV_CODEC_FLAG_TRUNCATED;
+-
+ 		if (avcodec_open2(cc, codec, NULL) < 0) {
+ 			d_print("could not open codec: %d, %s\n", cc->codec_id, avcodec_get_name(cc->codec_id));
+ 			err = -IP_ERROR_UNSUPPORTED_FILE_TYPE;
diff --git a/srcpkgs/cmus/template b/srcpkgs/cmus/template
index 0fcb424ce336..05b77d0fecae 100644
--- a/srcpkgs/cmus/template
+++ b/srcpkgs/cmus/template
@@ -1,7 +1,7 @@
 # Template file for 'cmus'
 pkgname=cmus
 version=2.10.0
-revision=1
+revision=2
 build_style=configure
 configure_args="prefix=/usr LD=$CC"
 hostmakedepends="pkg-config"

From c9d5eec457331db7e74232a9858d73e4a414d158 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 026/115] cyanrip: revbump for ffmpeg-6.0

---
 srcpkgs/cyanrip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cyanrip/template b/srcpkgs/cyanrip/template
index 9796e3461601..5db30e020d17 100644
--- a/srcpkgs/cyanrip/template
+++ b/srcpkgs/cyanrip/template
@@ -1,7 +1,7 @@
 # Template file for 'cyanrip'
 pkgname=cyanrip
 version=0.9.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config"
 makedepends="ffmpeg-devel libcdio-devel libcdio-paranoia-devel libcurl-devel libmusicbrainz5-devel"

From b0dc76ad46beb85cfafeddd59ecdcf0aa26b39b1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 027/115] deadbeef: revbump for ffmpeg4-4.4.3

---
 srcpkgs/deadbeef/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/deadbeef/template b/srcpkgs/deadbeef/template
index b664bb1b9bd9..165b3c7b9cad 100644
--- a/srcpkgs/deadbeef/template
+++ b/srcpkgs/deadbeef/template
@@ -1,14 +1,14 @@
 # Template file for 'deadbeef'
 pkgname=deadbeef
 version=1.8.8
-revision=1
+revision=2
 create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-oss --disable-lfm --disable-notify --disable-gtk2"
 hostmakedepends="automake libtool gettext gettext-devel intltool pkg-config
  yasm clang glib-devel"
 makedepends="
- alsa-lib-devel dbus-devel faad2-devel ffmpeg-devel gtk+3-devel imlib2-devel
+ alsa-lib-devel dbus-devel faad2-devel ffmpeg4-devel gtk+3-devel imlib2-devel
  jansson-devel libcddb-devel libcdio-devel libcurl-devel libflac-devel
  libmad-devel libpng-devel libsamplerate-devel libsndfile-devel libvorbis-devel
  libzip-devel mpg123-devel opusfile-devel pulseaudio-devel wavpack-devel"

From eed82b8ffcb920db8b1480210b8a1eccf020c307 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 028/115] dolphin-emu: revbump for ffmpeg-6.0

---
 srcpkgs/dolphin-emu/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/dolphin-emu/template b/srcpkgs/dolphin-emu/template
index b4c8b64368a4..070993aac31d 100644
--- a/srcpkgs/dolphin-emu/template
+++ b/srcpkgs/dolphin-emu/template
@@ -1,7 +1,7 @@
 # Template file for 'dolphin-emu'
 pkgname=dolphin-emu
 version=5.0.19368
-revision=1
+revision=2
 _dolphin_commit=dadbeb4bae7e7fa23af2b46e0add4143094dc107
 _mgba_commit=44e074a15e9651481f7f652ac006a7c9d58cbeb9
 _googletest_commit=be03d00f5f0cc3a997d1a368bee8a1fe93651f48

From 3f6375537c7aba3ce8189ccd1e1c6b06f5fd0f1d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 029/115] droidcam-obs-plugin: revbump for ffmpeg-6.0

---
 srcpkgs/droidcam-obs-plugin/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam-obs-plugin/template b/srcpkgs/droidcam-obs-plugin/template
index fc9c9bf6b9d5..fb0480754df4 100644
--- a/srcpkgs/droidcam-obs-plugin/template
+++ b/srcpkgs/droidcam-obs-plugin/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam-obs-plugin'
 pkgname=droidcam-obs-plugin
 version=2.0.1
-revision=1
+revision=2
 build_style=gnu-makefile
 make_use_env=yes
 make_build_args="ALLOW_STATIC=no"

From 32b1d6cba49560918adb1d761c6bc15546022910 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 030/115] droidcam: revbump for ffmpeg-6.0

---
 srcpkgs/droidcam/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam/template b/srcpkgs/droidcam/template
index 1c3f1b8b1fc6..32a9220b79a4 100644
--- a/srcpkgs/droidcam/template
+++ b/srcpkgs/droidcam/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam'
 pkgname=droidcam
 version=1.8.2
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="USBMUXD=-lusbmuxd-2.0 JPEG=-lturbojpeg"
 hostmakedepends="pkg-config"

From a64d0006c60aa238a3059c6896898e6e0e4dafdb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 031/115] ffmpegthumbnailer: revbump for ffmpeg-6.0

---
 .../ffmpegthumbnailer/patches/ffmpeg6.patch   | 202 ++++++++++++++++++
 srcpkgs/ffmpegthumbnailer/template            |   6 +-
 2 files changed, 205 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch

diff --git a/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
new file mode 100644
index 000000000000..363ff35a2841
--- /dev/null
+++ b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
@@ -0,0 +1,202 @@
+--- a/libffmpegthumbnailer/moviedecoder.cpp	2017-11-21 14:06:57.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.cpp	2023-05-05 13:14:47.946560668 -0400
+@@ -41,11 +41,6 @@
+ namespace ffmpegthumbnailer
+ {
+ 
+-struct SilenceLogLevel
+-{
+-    SilenceLogLevel() { av_log_set_level(AV_LOG_QUIET); }
+-};
+-
+ MovieDecoder::MovieDecoder(AVFormatContext* pavContext)
+ : m_VideoStream(-1)
+ , m_pFormatContext(pavContext)
+@@ -70,8 +65,6 @@
+ 
+ void MovieDecoder::initialize(const string& filename, bool preferEmbeddedMetadata)
+ {
+-    av_register_all();
+-    avcodec_register_all();
+     avformat_network_init();
+ 
+     string inputFile = filename == "-" ? "pipe:" : filename;
+@@ -97,8 +90,7 @@
+ {
+     if (m_pVideoCodecContext)
+     {
+-        avcodec_close(m_pVideoCodecContext);
+-        m_pVideoCodecContext = nullptr;
++        avcodec_free_context(&m_pVideoCodecContext);
+     }
+ 
+     if ((!m_FormatContextWasGiven) && m_pFormatContext)
+@@ -152,10 +144,10 @@
+     for (unsigned int i = 0; i < m_pFormatContext->nb_streams; ++i)
+     {
+         AVStream *stream = m_pFormatContext->streams[i];
+-        auto ctx = m_pFormatContext->streams[i]->codec;
+-        if (ctx->codec_type == AVMEDIA_TYPE_VIDEO)
++        auto par = m_pFormatContext->streams[i]->codecpar;
++        if (par->codec_type == AVMEDIA_TYPE_VIDEO)
+         {
+-            if (!preferEmbeddedMetadata || !isStillImageCodec(ctx->codec_id))
++            if (!preferEmbeddedMetadata || !isStillImageCodec(par->codec_id))
+             {
+                 videoStreams.push_back(i);
+                 continue;
+@@ -203,8 +195,7 @@
+     }
+ 
+     m_pVideoStream = m_pFormatContext->streams[m_VideoStream];
+-    m_pVideoCodecContext = m_pVideoStream->codec;
+-    m_pVideoCodec = avcodec_find_decoder(m_pVideoCodecContext->codec_id);
++    m_pVideoCodec = avcodec_find_decoder(m_pVideoStream->codecpar->codec_id);
+ 
+     if (m_pVideoCodec == nullptr)
+     {
+@@ -214,6 +205,20 @@
+         throw logic_error("Video Codec not found");
+     }
+ 
++    m_pVideoCodecContext = avcodec_alloc_context3(m_pVideoCodec);
++
++    if (m_pVideoCodecContext == nullptr)
++    {
++        destroy();
++        throw logic_error("Could not allocate video codec context");
++    }
++
++    if (avcodec_parameters_to_context(m_pVideoCodecContext, m_pVideoStream->codecpar) < 0)
++    {
++        destroy();
++        throw logic_error("Could not configure video codec context");
++    }
++
+     m_pVideoCodecContext->workaround_bugs = 1;
+ 
+     if (avcodec_open2(m_pVideoCodecContext, m_pVideoCodec, nullptr) < 0)
+@@ -386,13 +391,6 @@
+ 
+ void MovieDecoder::initializeFilterGraph(const AVRational& timeBase, const std::string& size, bool maintainAspectRatio)
+ {
+-    static const AVPixelFormat pixelFormats[] = { AV_PIX_FMT_RGB24, AV_PIX_FMT_NONE };
+-
+-    auto del = [] (AVBufferSinkParams* p) { av_freep(p); };
+-    std::unique_ptr<AVBufferSinkParams, decltype(del)> buffersinkParams(av_buffersink_params_alloc(), del);
+-
+-    avfilter_register_all();
+-
+     m_pFilterGraph = avfilter_graph_alloc();
+     assert(m_pFilterGraph);
+ 
+@@ -404,10 +402,8 @@
+ 
+     checkRc(avfilter_graph_create_filter(&m_pFilterSource, avfilter_get_by_name("buffer"), "thumb_buffer", ss.str().c_str(), nullptr, m_pFilterGraph),
+             "Failed to create filter source");
+-    buffersinkParams->pixel_fmts = pixelFormats;
+-    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, buffersinkParams.get(), m_pFilterGraph),
++    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, nullptr, m_pFilterGraph),
+             "Failed to create filter sink");
+-    buffersinkParams.release();
+ 
+     AVFilterContext* yadifFilter = nullptr;
+     if (m_pFrame->interlaced_frame != 0)
+@@ -500,15 +496,15 @@
+     }
+ 
+     checkRc(av_seek_frame(m_pFormatContext, -1, timestamp, 0), "Seeking in video failed");
+-    avcodec_flush_buffers(m_pFormatContext->streams[m_VideoStream]->codec);
++    avcodec_flush_buffers(m_pVideoCodecContext);
+ 
+     int keyFrameAttempts = 0;
+-    bool gotFrame = 0;
++    bool gotFrame;
+ 
+     do
+     {
+         int count = 0;
+-        gotFrame = 0;
++        gotFrame = false;
+ 
+         while (!gotFrame && count < 20)
+         {
+@@ -552,17 +548,33 @@
+         return false;
+     }
+ 
+-    av_frame_unref(m_pFrame);
+-
+-    int frameFinished;
++    int rc = avcodec_send_packet(m_pVideoCodecContext, m_pPacket);
++    if(rc == AVERROR(EAGAIN))
++    {
++        rc = 0;
++    }
+ 
+-    int bytesDecoded = avcodec_decode_video2(m_pVideoCodecContext, m_pFrame, &frameFinished, m_pPacket);
+-    if (bytesDecoded < 0)
++    if(rc == AVERROR_EOF)
++    {
++        return false;
++    }
++    else if(rc < 0)
+     {
+-        throw logic_error("Failed to decode video frame: bytesDecoded < 0");
++        throw logic_error("Failed to decode video frame: avcodec_send_packet() < 0");
+     }
+ 
+-    return frameFinished > 0;
++    rc = avcodec_receive_frame(m_pVideoCodecContext, m_pFrame);
++    switch(rc)
++    {
++        case 0:
++            return true;
++
++        case AVERROR(EAGAIN):
++            return false;
++
++        default:
++            throw logic_error("Failed to decode video frame: avcodec_receive_frame() < 0");
++    }
+ }
+ 
+ bool MovieDecoder::getVideoPacket()
+@@ -570,8 +582,6 @@
+     bool framesAvailable = true;
+     bool frameDecoded = false;
+ 
+-    int attempts = 0;
+-
+     if (m_pPacket)
+     {
+         av_packet_unref(m_pPacket);
+@@ -580,6 +590,7 @@
+ 
+     m_pPacket = new AVPacket();
+ 
++
+     while (framesAvailable && !frameDecoded)
+     {
+         framesAvailable = av_read_frame(m_pFormatContext, m_pPacket) >= 0;
+@@ -644,7 +655,7 @@
+ 
+ int32_t MovieDecoder::getStreamRotation()
+ {
+-    int32_t* matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
++    auto matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
+     if (matrix)
+     {
+         auto angle = lround(av_display_rotation_get(matrix));
+
+--- a/libffmpegthumbnailer/moviedecoder.h	2017-11-12 04:23:38.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.h	2023-05-05 13:26:07.095529911 -0400
+@@ -78,7 +78,7 @@
+     int                     m_VideoStream;
+     AVFormatContext*        m_pFormatContext;
+     AVCodecContext*         m_pVideoCodecContext;
+-    AVCodec*                m_pVideoCodec;
++    const AVCodec*          m_pVideoCodec;
+     AVFilterGraph*          m_pFilterGraph;
+     AVFilterContext*        m_pFilterSource;
+     AVFilterContext*        m_pFilterSink;
diff --git a/srcpkgs/ffmpegthumbnailer/template b/srcpkgs/ffmpegthumbnailer/template
index 039eea7622b3..35d546018d12 100644
--- a/srcpkgs/ffmpegthumbnailer/template
+++ b/srcpkgs/ffmpegthumbnailer/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbnailer'
 pkgname=ffmpegthumbnailer
 version=2.2.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libpng-devel libjpeg-turbo-devel ffmpeg-devel"
@@ -9,8 +9,8 @@ depends="ffmpeg"
 short_desc="Lightweight video thumbnailer"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
-homepage="https://github.com/dirkvdb/${pkgname}"
-distfiles="${homepage}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
+homepage="https://github.com/dirkvdb"
+distfiles="${homepage}/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
 checksum=1cb24059c38223f657b300c84dd80491b7040d4b69471c4fea69be862bc99b5b
 
 post_install() {

From 3e79fea26a6ee342a2c631a4277bf7a4cfb7eb8e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 032/115] ffmpegthumbs: revbump for ffmpeg-6.0

---
 srcpkgs/ffmpegthumbs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ffmpegthumbs/template b/srcpkgs/ffmpegthumbs/template
index 5f0b9414dada..11b88193528f 100644
--- a/srcpkgs/ffmpegthumbs/template
+++ b/srcpkgs/ffmpegthumbs/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbs'
 pkgname=ffmpegthumbs
 version=22.12.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules kcoreaddons kconfig-devel
  pkg-config qt5-host-tools qt5-qmake gettext"

From de3c447df856a42ec2ea11ba92108ed7287433c9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 033/115] ffms2: revbump for ffmpeg-6.0

---
 srcpkgs/ffms2/patches/ffmpeg5.patch | 424 ++++++++++++++++++++++++++++
 srcpkgs/ffms2/template              |   2 +-
 2 files changed, 425 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ffms2/patches/ffmpeg5.patch

diff --git a/srcpkgs/ffms2/patches/ffmpeg5.patch b/srcpkgs/ffms2/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..1479fabcafcb
--- /dev/null
+++ b/srcpkgs/ffms2/patches/ffmpeg5.patch
@@ -0,0 +1,424 @@
+From 45673149e9a2f5586855ad472e3059084eaa36b1 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:41:21 +0100
+Subject: [PATCH] Use auto for AVCodec
+
+The geniuses over at FFmpeg decided to constify this API, so old
+versions of the library will return AVCodec *, while new versions
+of the libary will return const AVCodec *, which, in C++, are not
+OK to convert between.
+
+Rather than use some macro hell in ffmscompat.h, we can work around
+this by using auto.
+
+Gross.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 2 +-
+ src/core/indexing.cpp    | 6 +++---
+ src/core/videosource.cpp | 2 +-
+ 3 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index e4ce97c..ac09666 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -469,7 +469,7 @@ void FFMS_AudioSource::OpenFile() {
+ 
+     LAVFOpenFile(SourceFile.c_str(), FormatContext, TrackNumber);
+ 
+-    AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
++    auto *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
+     if (Codec == nullptr)
+         throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+             "Audio codec not found");
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index e547c5a..59fb4e8 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -384,7 +384,7 @@ FFMS_TrackType FFMS_Indexer::GetTrackType(int Track) {
+ }
+ 
+ const char *FFMS_Indexer::GetTrackCodec(int Track) {
+-    AVCodec *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
++    auto *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
+     return codec ? codec->name : nullptr;
+ }
+ 
+@@ -402,7 +402,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             UseDTS);
+ 
+         if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            AVCodec *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (!VideoCodec) {
+                 FormatContext->streams[i]->discard = AVDISCARD_ALL;
+                 IndexMask.erase(i);
+@@ -433,7 +433,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 IndexMask.insert(i);
+             }
+         } else if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+-            AVCodec *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (AudioCodec == nullptr)
+                 throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_UNSUPPORTED,
+                     "Audio codec not found");
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index b889970..8956c22 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -171,7 +171,7 @@ FFMS_VideoSource::FFMS_VideoSource(const char *SourceFile, FFMS_Index &Index, in
+ 
+         LAVFOpenFile(SourceFile, FormatContext, VideoTrack);
+ 
+-        AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
++        auto *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
+         if (Codec == nullptr)
+             throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+                 "Video codec not found");
+-- 
+2.40.0
+
+From 96cbf38ea9381829a1314f432a2c60495dcefaad Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:12:41 +0100
+Subject: [PATCH] all: Update AVPacket API usage
+
+AVPackets must all be on the heap now, since it is no longer
+part of the libav* ABI.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 16 ++++++----
+ src/core/indexing.cpp    | 63 ++++++++++++++++++++++------------------
+ src/core/indexing.h      |  4 +--
+ src/core/utils.cpp       |  6 ----
+ src/core/utils.h         |  1 -
+ src/core/videosource.cpp | 30 ++++++++++---------
+ 6 files changed, 64 insertions(+), 56 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index 37cf9ae..e4ce97c 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -285,10 +285,15 @@ FFMS_AudioSource::AudioBlock *FFMS_AudioSource::CacheBlock(CacheIterator &pos) {
+ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     CurrentFrame = &Frames[PacketNumber];
+ 
+-    AVPacket Packet;
+-    if (!ReadPacket(&Packet))
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++    if (!ReadPacket(Packet)) {
++        av_packet_free(&Packet);
+         throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_UNKNOWN,
+             "ReadPacket unexpectedly failed to read a packet");
++    }
+ 
+     // ReadPacket may have changed the packet number
+     CurrentFrame = &Frames[PacketNumber];
+@@ -297,8 +302,9 @@ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     int NumberOfSamples = 0;
+     AudioBlock *CachedBlock = nullptr;
+     
+-    int Ret = avcodec_send_packet(CodecContext, &Packet);
+-    av_packet_unref(&Packet);
++    int Ret = avcodec_send_packet(CodecContext, Packet);
++    av_packet_unref(Packet);
++    av_packet_free(&Packet);
+ 
+     av_frame_unref(DecodeFrame);
+     Ret = avcodec_receive_frame(CodecContext, DecodeFrame);
+@@ -513,8 +519,6 @@ void FFMS_AudioSource::Seek() {
+ }
+ 
+ bool FFMS_AudioSource::ReadPacket(AVPacket *Packet) {
+-    InitNullPacket(*Packet);
+-
+     while (av_read_frame(FormatContext, Packet) >= 0) {
+         if (Packet->stream_index == TrackNumber) {
+             // Required because not all audio packets, especially in ogg, have a pts. Use the previous valid packet's pts instead.
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index 23fb95b..e547c5a 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -320,7 +320,7 @@ void FFMS_Indexer::CheckAudioProperties(int Track, AVCodecContext *Context) {
+     }
+ }
+ 
+-void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict,
++void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict,
+                                     int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct) {
+     if (VideoContext.Parser) {
+         uint8_t *OB;
+@@ -330,8 +330,8 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+         av_parser_parse2(VideoContext.Parser,
+             VideoContext.CodecContext,
+             &OB, &OBSize,
+-            pkt.data, pkt.size,
+-            pkt.pts, pkt.dts, pkt.pos);
++            pkt->data, pkt->size,
++            pkt->pts, pkt->dts, pkt->pos);
+ 
+         // H.264 (PAFF) and HEVC may have one field per packet, so we need to track
+         // when we have a full or half frame available, and mark one of them as
+@@ -351,15 +351,15 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+ 
+         *RepeatPict = VideoContext.Parser->repeat_pict;
+         *FrameType = VideoContext.Parser->pict_type;
+-        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt.flags & AV_PKT_FLAG_DISCARD));
++        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt->flags & AV_PKT_FLAG_DISCARD));
+     } else {
+-        *Invisible = !!(pkt.flags & AV_PKT_FLAG_DISCARD);
++        *Invisible = !!(pkt->flags & AV_PKT_FLAG_DISCARD);
+     }
+ 
+     if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP8)
+-        ParseVP8(pkt.data[0], Invisible, FrameType);
++        ParseVP8(pkt->data[0], Invisible, FrameType);
+     else if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP9)
+-        ParseVP9(pkt.data[0], Invisible, FrameType);
++        ParseVP9(pkt->data[0], Invisible, FrameType);
+ }
+ 
+ void FFMS_Indexer::Free() {
+@@ -458,32 +458,36 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+         }
+     }
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
+     std::vector<int64_t> LastValidTS(FormatContext->nb_streams, AV_NOPTS_VALUE);
+ 
+     int64_t filesize = avio_size(FormatContext->pb);
+     enum AVPictureStructure LastPicStruct = AV_PICTURE_STRUCTURE_UNKNOWN;
+-    while (av_read_frame(FormatContext, &Packet) >= 0) {
++    while (av_read_frame(FormatContext, Packet) >= 0) {
+         // Update progress
+         // FormatContext->pb can apparently be NULL when opening images.
+         if (IC && FormatContext->pb) {
+-            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate))
++            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate)) {
++                av_packet_free(&Packet);
+                 throw FFMS_Exception(FFMS_ERROR_CANCELLED, FFMS_ERROR_USER,
+                     "Cancelled by user");
++            }
+         }
+-        if (!IndexMask.count(Packet.stream_index)) {
+-            av_packet_unref(&Packet);
++        if (!IndexMask.count(Packet->stream_index)) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+-        int Track = Packet.stream_index;
++        int Track = Packet->stream_index;
+         FFMS_Track &TrackInfo = (*TrackIndices)[Track];
+-        bool KeyFrame = !!(Packet.flags & AV_PKT_FLAG_KEY);
++        bool KeyFrame = !!(Packet->flags & AV_PKT_FLAG_KEY);
+         ReadTS(Packet, LastValidTS[Track], (*TrackIndices)[Track].UseDTS);
+ 
+         if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            int64_t PTS = TrackInfo.UseDTS ? Packet.dts : Packet.pts;
++            int64_t PTS = TrackInfo.UseDTS ? Packet->dts : Packet->pts;
+             if (PTS == AV_NOPTS_VALUE) {
+                 // VPx alt-refs are output as packets which lack timestmps or durations, since
+                 // they are invisible. Currently, the timestamp mangling code in libavformat
+@@ -495,9 +499,11 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 // FFMS2 currently sorts packets by PTS, which will break decoding, otherwise.
+                 bool HasAltRefs = (FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP8 ||
+                                    FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP9);
+-                if (Packet.duration == 0 && !HasAltRefs)
++                if (Packet->duration == 0 && !HasAltRefs) {
++                    av_packet_free(&Packet);
+                     throw FFMS_Exception(FFMS_ERROR_INDEXING, FFMS_ERROR_PARSER,
+                         "Invalid packet pts, dts, and duration");
++                }
+ 
+                 if (TrackInfo.empty())
+                     PTS = 0;
+@@ -513,7 +519,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             ParseVideoPacket(AVContexts[Track], Packet, &RepeatPict, &FrameType, &Invisible, &LastPicStruct);
+ 
+             TrackInfo.AddVideoFrame(PTS, RepeatPict, KeyFrame,
+-                FrameType, Packet.pos, Invisible);
++                FrameType, Packet->pos, Invisible);
+         } else if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+             // For video seeking timestamps are used only if all packets have
+             // timestamps, while for audio they're used if any have timestamps,
+@@ -522,28 +528,29 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 TrackInfo.HasTS = true;
+ 
+             int64_t StartSample = AVContexts[Track].CurrentSample;
+-            uint32_t SampleCount = IndexAudioPacket(Track, &Packet, AVContexts[Track], *TrackIndices);
++            uint32_t SampleCount = IndexAudioPacket(Track, Packet, AVContexts[Track], *TrackIndices);
+             TrackInfo.SampleRate = AVContexts[Track].CodecContext->sample_rate;
+ 
+             TrackInfo.AddAudioFrame(LastValidTS[Track],
+-                StartSample, SampleCount, KeyFrame, Packet.pos, Packet.flags & AV_PKT_FLAG_DISCARD);
++                StartSample, SampleCount, KeyFrame, Packet->pos, Packet->flags & AV_PKT_FLAG_DISCARD);
+         }
+ 
+-        if (!(Packet.flags & AV_PKT_FLAG_DISCARD))
+-            TrackInfo.LastDuration = Packet.duration;
++        if (!(Packet->flags & AV_PKT_FLAG_DISCARD))
++            TrackInfo.LastDuration = Packet->duration;
+ 
+-        av_packet_unref(&Packet);
++        av_packet_unref(Packet);
+     }
++    av_packet_free(&Packet);
+ 
+     TrackIndices->Finalize(AVContexts, FormatContext->iformat->name);
+     return TrackIndices.release();
+ }
+ 
+-void FFMS_Indexer::ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS) {
+-    if (!UseDTS && Packet.pts != AV_NOPTS_VALUE)
+-        TS = Packet.pts;
++void FFMS_Indexer::ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS) {
++    if (!UseDTS && Packet->pts != AV_NOPTS_VALUE)
++        TS = Packet->pts;
+     if (TS == AV_NOPTS_VALUE)
+         UseDTS = true;
+-    if (UseDTS && Packet.dts != AV_NOPTS_VALUE)
+-        TS = Packet.dts;
++    if (UseDTS && Packet->dts != AV_NOPTS_VALUE)
++        TS = Packet->dts;
+ }
+diff --git a/src/core/indexing.h b/src/core/indexing.h
+index 3cfc3c3..5c06868 100644
+--- a/src/core/indexing.h
++++ b/src/core/indexing.h
+@@ -80,10 +80,10 @@ private:
+     int64_t Filesize;
+     uint8_t Digest[20];
+ 
+-    void ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS);
++    void ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS);
+     void CheckAudioProperties(int Track, AVCodecContext *Context);
+     uint32_t IndexAudioPacket(int Track, AVPacket *Packet, SharedAVContext &Context, FFMS_Index &TrackIndices);
+-    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
++    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
+     void Free();
+ public:
+     FFMS_Indexer(const char *Filename);
+diff --git a/src/core/utils.cpp b/src/core/utils.cpp
+index ce67533..8a2e997 100644
+--- a/src/core/utils.cpp
++++ b/src/core/utils.cpp
+@@ -62,12 +62,6 @@ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo) {
+     }
+ }
+ 
+-void InitNullPacket(AVPacket &pkt) {
+-    av_init_packet(&pkt);
+-    pkt.data = nullptr;
+-    pkt.size = 0;
+-}
+-
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames) {
+     AP.SampleFormat = static_cast<FFMS_SampleFormat>(av_get_packed_sample_fmt(CTX->sample_fmt));
+     AP.BitsPerSample = av_get_bytes_per_sample(CTX->sample_fmt) * 8;
+diff --git a/src/core/utils.h b/src/core/utils.h
+index 9819dc7..003ab79 100644
+--- a/src/core/utils.h
++++ b/src/core/utils.h
+@@ -58,7 +58,6 @@ std::unique_ptr<T> make_unique(Args&&... args) {
+ }
+ 
+ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo);
+-void InitNullPacket(AVPacket &pkt);
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames);
+ 
+ void LAVFOpenFile(const char *SourceFile, AVFormatContext *&FormatContext, int Track);
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index 06bd161..b889970 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -673,30 +673,34 @@ void FFMS_VideoSource::DecodeNextFrame(int64_t &AStartTime, int64_t &Pos) {
+     if (HasPendingDelayedFrames())
+         return;
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
+-
+-    while (ReadFrame(&Packet) >= 0) {
+-        if (Packet.stream_index != VideoTrack) {
+-            av_packet_unref(&Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++
++    while (ReadFrame(Packet) >= 0) {
++        if (Packet->stream_index != VideoTrack) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+         if (AStartTime < 0)
+-            AStartTime = Frames.UseDTS ? Packet.dts : Packet.pts;
++            AStartTime = Frames.UseDTS ? Packet->dts : Packet->pts;
+ 
+         if (Pos < 0)
+-            Pos = Packet.pos;
++            Pos = Packet->pos;
+ 
+-        bool FrameFinished = DecodePacket(&Packet);
+-        av_packet_unref(&Packet);
+-        if (FrameFinished)
++        bool FrameFinished = DecodePacket(Packet);
++        av_packet_unref(Packet);
++        if (FrameFinished) {
++            av_packet_free(&Packet);
+             return;
++        }
+     }
+ 
+     // Flush final frames
+-    InitNullPacket(Packet);
+-    DecodePacket(&Packet);
++    DecodePacket(Packet);
++    av_packet_free(&Packet);
+ }
+ 
+ bool FFMS_VideoSource::SeekTo(int n, int SeekOffset) {
+-- 
+2.40.0
+
+From bf9e03e9e08534c024e5a744a6437c4aac160201 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:20:47 +0100
+Subject: [PATCH 2/3] configure: Remove deprecated API use
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ configure.ac | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index b35ef80bc..d19714d0f 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -102,10 +102,10 @@ CFLAGS="$_CFLAGS $FFMPEG_CFLAGS"
+
+ AC_DEFUN([TEST_FFMPEG],
+          [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+-            #include <libavcodec/avcodec.h>
++            #include <libavformat/avformat.h>
+             #include <libswscale/swscale.h>
+             ]],[[
+-                avcodec_register_all();
++                avformat_network_init();
+                 swscale_version();
+             ]])], [eval $1=yes], [eval $1=no])
+         ])
+
diff --git a/srcpkgs/ffms2/template b/srcpkgs/ffms2/template
index 68e8a0c14bce..2acfadac44b3 100644
--- a/srcpkgs/ffms2/template
+++ b/srcpkgs/ffms2/template
@@ -1,7 +1,7 @@
 # Template file for 'ffms2'
 pkgname=ffms2
 version=2.40
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-shared --disable-static"
 hostmakedepends="pkg-config autoconf automake libtool"

From fa4e7e8ef03bfeff211ac7360fbf19d7dce1a86a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 034/115] freerdp: revbump for ffmpeg-6.0

---
 .../freerdp/patches/ffmpeg6_aa2cb9aa.patch    | 42 +++++++++++++++++++
 srcpkgs/freerdp/template                      |  2 +-
 2 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch

diff --git a/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
new file mode 100644
index 000000000000..a4324da3a882
--- /dev/null
+++ b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
@@ -0,0 +1,42 @@
+From aa2cb9aa5ff5562433598ba168a466e0752bca0e Mon Sep 17 00:00:00 2001
+From: akallabeth <akallabeth@posteo.net>
+Date: Tue, 14 Feb 2023 07:48:54 +0100
+Subject: [PATCH] Fixed #8686: Update h264 to use new FFMPEG API
+
+---
+ channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c | 2 ++
+ libfreerdp/codec/h264_ffmpeg.c            | 2 ++
+ 2 files changed, 4 insertions(+)
+
+diff --git a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+index 339462d865f..beea80b7a1e 100644
+--- a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
++++ b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+@@ -239,8 +239,10 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYP
+ 		}
+ 	}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 	if (mdecoder->codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		mdecoder->codec_context->flags |= AV_CODEC_FLAG_TRUNCATED;
++#endif
+ 
+ 	return TRUE;
+ }
+diff --git a/libfreerdp/codec/h264_ffmpeg.c b/libfreerdp/codec/h264_ffmpeg.c
+index 8a23db2473c..896a333019b 100644
+--- a/libfreerdp/codec/h264_ffmpeg.c
++++ b/libfreerdp/codec/h264_ffmpeg.c
+@@ -615,10 +615,12 @@ static BOOL libavcodec_init(H264_CONTEXT* h264)
+ 			goto EXCEPTION;
+ 		}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 		if (sys->codecDecoder->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		{
+ 			sys->codecDecoderContext->flags |= AV_CODEC_FLAG_TRUNCATED;
+ 		}
++#endif
+ 
+ #ifdef WITH_VAAPI
+ 
diff --git a/srcpkgs/freerdp/template b/srcpkgs/freerdp/template
index 25e8aa9677f0..4d51c8189902 100644
--- a/srcpkgs/freerdp/template
+++ b/srcpkgs/freerdp/template
@@ -1,7 +1,7 @@
 # Template file for 'freerdp'
 pkgname=freerdp
 version=2.10.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_ALSA=ON -DWITH_CUPS=OFF -DWITH_FFMPEG=ON
  -DWITH_GSTREAMER_0_10=OFF -DWITH_GSTREAMER_1_0=OFF -DWITH_JPEG=ON

From 032a3a4afbbf008d6c182c0eb186af062df18b48 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 035/115] gerbera: revbump for ffmpeg-6.0

---
 srcpkgs/gerbera/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gerbera/template b/srcpkgs/gerbera/template
index ae14f35c767c..2dc0ac0ce03b 100644
--- a/srcpkgs/gerbera/template
+++ b/srcpkgs/gerbera/template
@@ -1,7 +1,7 @@
 # Template file for 'gerbera'
 pkgname=gerbera
 version=1.12.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_SYSTEMD=0 -DWITH_AVCODEC=1"
 hostmakedepends="pkg-config"

From e97d7b0bbe6c9e39348f74dd0e68daa875b119bf Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 036/115] goldendict: revbump for ffmpeg-6.0

---
 srcpkgs/goldendict/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/goldendict/template b/srcpkgs/goldendict/template
index f4a05759f693..97f44347b03a 100644
--- a/srcpkgs/goldendict/template
+++ b/srcpkgs/goldendict/template
@@ -1,7 +1,7 @@
 # Template file for 'goldendict'
 pkgname=goldendict
 version=1.5.0
-revision=1
+revision=2
 build_style=qmake
 configure_args="CONFIG+=zim_support goldendict.pro"
 hostmakedepends="qt5-qmake pkg-config qt5-host-tools"
@@ -10,7 +10,7 @@ makedepends="tiff-devel qt5-devel libvorbis-devel zlib-devel
  qt5-webkit-devel lzo-devel bzip2-devel libao-devel qt5-svg-devel
  libeb-devel qt5-x11extras-devel ffmpeg-devel liblzma-devel
  qt5-multimedia-devel"
-short_desc="A feature-rich dictionary lookup program"
+short_desc="Feature-rich dictionary lookup program"
 maintainer="John <me@johnnynator.dev>"
 license="GPL-3.0-or-later"
 homepage="http://goldendict.org/"

From cfe4fd0d062efb5b9b79ef5047101a499257a409 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 037/115] gst-libav: revbump for ffmpeg-6.0

---
 srcpkgs/gst-libav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index 8c72fc3e97ee..04c39bff1489 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.22.2
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"

From 17485e9a27f98c9d13e4f90a74b5feae25205e34 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 038/115] gst-plugins-bad1: revbump for ffmpeg-6.0

---
 srcpkgs/gst-plugins-bad1/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index 77bf79981c20..5c158724a6c7 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-plugins-bad1'
 pkgname=gst-plugins-bad1
 version=1.22.2
-revision=1
+revision=2
 build_helper="gir"
 build_style=meson
 configure_args="-Dpackage-origin=https://voidlinux.org -Ddoc=disabled

From 36d3de1ad7e599b2f4b1829d889830320eff1596 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 039/115] gst-rtsp-server: revbump for ffmpeg-6.0

---
 srcpkgs/gst-rtsp-server/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index 2f0c0c45ff82..980fd72cdd4c 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
 version=1.22.2
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="glib-devel gst-plugins-bad1-devel gobject-introspection

From bdce3ac61ae2c631bbccca27de8da070768bd603 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 040/115] guvcview: update to 2.0.8.

---
 srcpkgs/guvcview/patches/fix-include.patch | 10 ++++++++++
 srcpkgs/guvcview/template                  |  5 ++---
 2 files changed, 12 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/guvcview/patches/fix-include.patch

diff --git a/srcpkgs/guvcview/patches/fix-include.patch b/srcpkgs/guvcview/patches/fix-include.patch
new file mode 100644
index 000000000000..503c2af3b78c
--- /dev/null
+++ b/srcpkgs/guvcview/patches/fix-include.patch
@@ -0,0 +1,10 @@
+--- a/guvcview/guvcview.c
++++ b/guvcview/guvcview.c
+@@ -28,6 +28,7 @@
+ #include <sys/stat.h>
+ #include <sys/resource.h>
+ #include <errno.h>
++#include <locale.h>
+ 
+ #include "gview.h"
+ #include "gviewv4l2core.h"
diff --git a/srcpkgs/guvcview/template b/srcpkgs/guvcview/template
index 345cf6006f24..86a7fd619612 100644
--- a/srcpkgs/guvcview/template
+++ b/srcpkgs/guvcview/template
@@ -1,8 +1,7 @@
 # Template file for 'guvcview'
 pkgname=guvcview
-version=2.0.7
+version=2.0.8
 revision=1
-create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-static --disable-debian-menu"
 hostmakedepends="pkg-config intltool autoconf automake libtool glib-devel"
@@ -14,7 +13,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="http://guvcview.sourceforge.net/"
 distfiles="${SOURCEFORGE_SITE}/${pkgname}/${pkgname}-src-${version}.tar.bz2"
-checksum=f47d51fbd06e44eeaa1a82f4a153c927527c90d94514197a70b2956028cc8ad4
+checksum=a21f4e448286666cf27bafef5290cc953a0a1796b752e5bbe521266dc1230c81
 
 post_patch() {
 	sed '31a#include <locale.h>' -i  guvcview/guvcview.c

From 5b2a3bdc39cc40aa96207de8b1422fd29342a48d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 041/115] handbrake: update to 1.6.1

---
 .../patches/fix-missing-x265-link-flag.patch    | 11 ++++++-----
 .../handbrake/patches/libhb-vpl-include.patch   | 15 +++++++++++++++
 srcpkgs/handbrake/template                      | 17 ++++++++++-------
 3 files changed, 31 insertions(+), 12 deletions(-)
 create mode 100644 srcpkgs/handbrake/patches/libhb-vpl-include.patch

diff --git a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
index 26db03867a0c..d6bb2eda627a 100644
--- a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
+++ b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
@@ -1,14 +1,15 @@
 --- a/gtk/configure.ac
 +++ b/gtk/configure.ac
 @@ -203,7 +203,7 @@
- 
+
  AM_CONDITIONAL([MINGW], [test "x$mingw_flag" = "xyes"])
- 
--HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg"
-+HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -ldl"
+
+-HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc"
++HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc -ldl"
  HB_CPPFLAGS="$HB_CPPFLAGS $HBINC"
- 
+
  PKG_CHECK_MODULES([x264], [x264], sys_x264=yes, sys_x264=no)
+
 --- a/test/module.defs
 +++ b/test/module.defs
 @@ -69,6 +69,9 @@
diff --git a/srcpkgs/handbrake/patches/libhb-vpl-include.patch b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
new file mode 100644
index 000000000000..298f9f4ab28f
--- /dev/null
+++ b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
@@ -0,0 +1,15 @@
+--- a/libhb/module.defs	2023-01-22 11:36:49.000000000 -0500
++++ b/libhb/module.defs	2023-04-03 22:37:52.395467010 -0400
+@@ -46,11 +46,7 @@
+ LIBHB.GCC.I += $(LIBHB.build/) $(CONTRIB.build/)include
+ 
+ ifeq (1,$(FEATURE.qsv))
+-    ifeq ($(HOST.system),freebsd))
+-        LIBHB.GCC.I += $(LOCALBASE)/include/vpl
+-    else
+-        LIBHB.GCC.I += $(CONTRIB.build/)include/vpl
+-    endif
++    LIBHB.GCC.I += /usr/include/vpl
+ endif
+ 
+ ifneq (,$(filter $(HOST.system),freebsd netbsd openbsd))
diff --git a/srcpkgs/handbrake/template b/srcpkgs/handbrake/template
index ca5e4571e49c..c32cb1bfa31f 100644
--- a/srcpkgs/handbrake/template
+++ b/srcpkgs/handbrake/template
@@ -1,10 +1,10 @@
 # Template file for 'handbrake'
 pkgname=handbrake
-version=1.5.1
+version=1.6.1
 revision=1
 build_style=gnu-configure
 configure_args="--force --disable-gtk-update-checks --disable-df-fetch --harden
- $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc)"
+ $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc) $(vopt_enable qsv)"
 make_build_args="-C ${XBPS_TRIPLET}"
 make_install_args="-C ${XBPS_TRIPLET}"
 hostmakedepends="automake cmake gettext-devel glib-devel intltool libtool m4 meson nasm pkg-config python3"
@@ -12,8 +12,11 @@ makedepends="bzip2-devel ffmpeg-devel gst-plugins-base1-devel gtk+3-devel
  jansson-devel lame-devel libass-devel libbluray-devel libdav1d-devel
  libdvdnav-devel libdvdread-devel libgudev-devel libnuma-devel
  libsamplerate-devel libtheora-devel libvorbis-devel libvpx-devel libxml2-devel
- opus-devel speex-devel x264-devel x265-devel zimg-devel
+ opus-devel speex-devel x264-devel x265-devel zimg-devel libsvt-av1-devel
  $(vopt_if fdk_aac fdk-aac-devel)
+ $(vopt_if qsv libva-devel)
+ $(vopt_if qsv libdrm-devel)
+ $(vopt_if qsv onevpl-devel)
  $(vopt_if nvenc nv-codec-headers)"
 depends="desktop-file-utils gst-plugins-good1 hicolor-icon-theme"
 short_desc="Multithreaded video transcoder"
@@ -21,15 +24,15 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-2.0-only"
 homepage="https://handbrake.fr/"
 distfiles="https://github.com/HandBrake/HandBrake/releases/download/${version}/HandBrake-${version}-source.tar.bz2"
-checksum=3999fe06d5309c819799a73a968a8ec3840e7840c2b64af8f5cdb7fd8c9430f0
+checksum=94ccfe03db917a91650000c510f7fd53f844da19f19ad4b4be1b8f6bc31a8d4c
 nocross=yes
 
-build_options="fdk_aac nvenc"
+build_options="fdk_aac nvenc qsv"
 
 case "$XBPS_TARGET_MACHINE" in
 	x86_64*|i686*)
 		CFLAGS="-msse"
-		build_options_default="nvenc"
+		build_options_default="nvenc qsv"
 		;;
 esac
 
@@ -37,7 +40,7 @@ pre_configure() {
 	# use system libraries, don't download them
 	rm -rf contrib/
 	for module in fdk-aac ffmpeg libbluray libdav1d libdvdnav libdvdread nvenc \
-		x265 zimg; do
+		x265 zimg svt-av1 libvpl; do
 	    vsed -i "/MODULES += contrib\/${module}/d" make/include/main.defs
 	done
 }

From eaec25d3d7557fc080bc976c66e65110000e738f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 042/115] hedgewars: revbump for ffmpeg4-4.4.3

---
 srcpkgs/hedgewars/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/hedgewars/template b/srcpkgs/hedgewars/template
index 419f29b98b44..926fe4fe3e68 100644
--- a/srcpkgs/hedgewars/template
+++ b/srcpkgs/hedgewars/template
@@ -1,13 +1,13 @@
 # Template file for 'hedgewars'
 pkgname=hedgewars
 version=1.0.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DNOSERVER=1 -DDATA_INSTALL_DIR=/usr/share/${pkgname}
  -DPHYSFS_SYSTEM=1 -DMINIMAL_FLAGS=1"
 make_cmd=make
 hostmakedepends="lua51 pkg-config qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
+makedepends="ffmpeg4-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
  SDL2_mixer-devel SDL2_net-devel SDL2_ttf-devel"
 depends="libfreeglut"
 short_desc="Funny turn-based artillery game, featuring fighting Hedgehogs!"

From e36b744f9d421c9f67537d47f8a66f00ffbe4164 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 043/115] idjc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/idjc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/idjc/template b/srcpkgs/idjc/template
index df60318b3db9..36a75baf597c 100644
--- a/srcpkgs/idjc/template
+++ b/srcpkgs/idjc/template
@@ -1,11 +1,11 @@
 # Template file for 'idjc'
 pkgname=idjc
 version=0.9.1
-revision=3
+revision=4
 build_style=gnu-configure
 hostmakedepends="pkg-config git python3 automake gettext-devel libtool"
 makedepends="libvorbis-devel libogg-devel jack-devel libsamplerate-devel
- libflac-devel libsndfile-devel mpg123-devel ffmpeg-devel speex-devel
+ libflac-devel libsndfile-devel mpg123-devel ffmpeg4-devel speex-devel
  glib-devel pixman-devel lame-devel python3-gobject-devel libshout-idjc-devel
  opus-devel twolame-devel python3-mutagen python3-devel"
 depends="python3-gobject python3-mutagen desktop-file-utils shared-mime-info python3-dbus jack"

From 4b3275f9b266a33c196c278785d82d252b05ca4b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 044/115] kfilemetadata5: revbump for ffmpeg-6.0

---
 srcpkgs/kfilemetadata5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kfilemetadata5/template b/srcpkgs/kfilemetadata5/template
index 4b91cf19f298..a3671a38ce59 100644
--- a/srcpkgs/kfilemetadata5/template
+++ b/srcpkgs/kfilemetadata5/template
@@ -1,7 +1,7 @@
 # Template file for 'kfilemetadata5'
 pkgname=kfilemetadata5
 version=5.107.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="kcoreaddons extra-cmake-modules pkg-config qt5-host-tools qt5-qmake
  gettext kcoreaddons python3"

From f7236197747bf9db56037cd20ac6e6754b437511 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 045/115] kid3: revbump for ffmpeg-6.0

---
 srcpkgs/kid3/patches/ffmpeg5.patch | 17 +++++++++++++++++
 srcpkgs/kid3/template              |  2 +-
 2 files changed, 18 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/kid3/patches/ffmpeg5.patch

diff --git a/srcpkgs/kid3/patches/ffmpeg5.patch b/srcpkgs/kid3/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..135fc50e07c9
--- /dev/null
+++ b/srcpkgs/kid3/patches/ffmpeg5.patch
@@ -0,0 +1,17 @@
+# https://aur.archlinux.org/cgit/aur.git/diff/ffmpeg5.patch?h=kid3-cli&id=12410a74906612e7efc0ec8fbce739b4a0fef7e7
+diff --git a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+index e156d424..e12b9abd 100644
+--- a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
++++ b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+@@ -232,7 +232,11 @@ private:
+   friend class Format;
+   friend class Converter;
+   AVCodecContext* m_ptr;
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 0, 0)
+   AVCodec* m_impl;
++#else
++  const AVCodec* m_impl;
++#endif
+   AVFrame* m_frame;
+   bool m_opened;
+ };
diff --git a/srcpkgs/kid3/template b/srcpkgs/kid3/template
index 456206d90e16..f32f9decb0e7 100644
--- a/srcpkgs/kid3/template
+++ b/srcpkgs/kid3/template
@@ -1,7 +1,7 @@
 # Template file for 'kid3'
 pkgname=kid3
 version=3.9.1
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DWITH_APPS='CLI;$(vopt_if KDE KDE Qt)'
  -DWITH_DOCBOOKDIR=/usr/share/xsl/docbook -DWITH_FLAC=$(vopt_if flac ON OFF)

From 2fbcd960ce8f66564b59ac1049a165b82ad4c05e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 046/115] kodi: revbump for ffmpeg4-4.4.3

---
 srcpkgs/kodi/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/kodi/template b/srcpkgs/kodi/template
index 8057964d78a3..6cc1874be7ba 100644
--- a/srcpkgs/kodi/template
+++ b/srcpkgs/kodi/template
@@ -1,7 +1,7 @@
 # Template file for 'kodi'
 pkgname=kodi
 version=19.4
-revision=6
+revision=7
 _codename="Matrix"
 build_style=cmake
 configure_args="-DWITH_FFMPEG=/usr -DENABLE_LDGOLD=OFF
@@ -54,7 +54,7 @@ makedepends="
  libmad-devel fontconfig-devel libXinerama-devel libsamplerate-devel libmms-devel
  enca-devel boost-devel libcurl-devel libva-devel libvdpau-devel libass-devel
  libbluetooth-devel yajl-devel libplist-devel librtmp-devel tinyxml-devel
- taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg-devel
+ taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg4-devel
  giflib-devel libxslt-devel gnutls-devel libssh-devel libmicrohttpd-devel
  libcec-devel dcadec-devel flatbuffers-devel fmt-devel lcms2-devel
  libfstrcmp-devel rapidjson libcdio-paranoia spdlog libwaylandpp-devel

From e039902f3307f0d1e84d23bf983f1f3987616b2d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 047/115] kpipewire: revbump for ffmpeg-6.0

---
 srcpkgs/kpipewire/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kpipewire/template b/srcpkgs/kpipewire/template
index db4e42f0d456..2334bf867806 100644
--- a/srcpkgs/kpipewire/template
+++ b/srcpkgs/kpipewire/template
@@ -1,7 +1,7 @@
 # Template file for 'kpipewire'
 pkgname=kpipewire
 version=5.27.6
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules plasma-wayland-protocols gettext
  qt5-qmake qt5-host-tools pkg-config wayland-devel kcoreaddons

From 8ffca03b42df38e48cea2b1645b864261a9cd962 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 048/115] libextractor: revbump for ffmpeg4-4.4.3

---
 srcpkgs/libextractor/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libextractor/template b/srcpkgs/libextractor/template
index ddd4790f93e8..1fb9ca56a96a 100644
--- a/srcpkgs/libextractor/template
+++ b/srcpkgs/libextractor/template
@@ -7,7 +7,7 @@ configure_args="--disable-static"
 hostmakedepends="pkg-config"
 makedepends="zlib-devel bzip2-devel exiv2-devel tiff-devel libpng-devel
  libjpeg-turbo-devel libvorbis-devel libflac-devel giflib-devel libmpeg2-devel
- ffmpeg-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
+ ffmpeg4-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
 short_desc="Library used to extract meta data from files"
 maintainer="Martin Riese <grauehaare@gmx.de>"
 license="GPL-3.0-or-later"

From 0c915d811b06b592eaf3604fbcdbd8b9e8a5f5af Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 049/115] libopenal: revbump for ffmpeg-6.0

---
 srcpkgs/libopenal/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenal/template b/srcpkgs/libopenal/template
index 77218f9e539d..3f49ed75a1fd 100644
--- a/srcpkgs/libopenal/template
+++ b/srcpkgs/libopenal/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenal'
 pkgname=libopenal
 version=1.22.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DALSOFT_EXAMPLES=OFF"
 hostmakedepends="pkg-config"

From 88bb3c97d8f927e0003c05cc1e65eb2453f49aef Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 050/115] libopenshot: revbump for ffmpeg-6.0

---
 srcpkgs/libopenshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenshot/template b/srcpkgs/libopenshot/template
index db831f69b474..81aa0d7136d9 100644
--- a/srcpkgs/libopenshot/template
+++ b/srcpkgs/libopenshot/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenshot'
 pkgname=libopenshot
 version=0.3.0
-revision=1
+revision=2
 build_style=cmake
 # Builds fail with Ruby-2.4.1
 configure_args="-DENABLE_RUBY=OFF -DUSE_SYSTEM_JSONCPP=ON"

From d47046315ca5c2d6ee958d2a98ff3d40963842d0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 051/115] loudgain: revbump for ffmpeg-6.0

---
 srcpkgs/loudgain/patches/ffmpeg5.patch | 11 +++++++++++
 srcpkgs/loudgain/template              |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/loudgain/patches/ffmpeg5.patch

diff --git a/srcpkgs/loudgain/patches/ffmpeg5.patch b/srcpkgs/loudgain/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..16d4510ee98f
--- /dev/null
+++ b/srcpkgs/loudgain/patches/ffmpeg5.patch
@@ -0,0 +1,11 @@
+--- a/src/scan.c	2019-09-06 11:31:19.000000000 -0400
++++ b/src/scan.c	2023-03-23 11:15:40.867968521 -0400
+@@ -69,8 +69,6 @@
+ 	 * It is now useless
+ 	 * https://github.com/FFmpeg/FFmpeg/blob/70d25268c21cbee5f08304da95be1f647c630c15/doc/APIchanges#L86
+ 	 */
+-  if (avformat_version() < AV_VERSION_INT(58,9,100))
+-    av_register_all();
+ 
+ 	av_log_set_callback(scan_av_log);
+ 
diff --git a/srcpkgs/loudgain/template b/srcpkgs/loudgain/template
index da4f2d56e94c..4d6bf29efb4f 100644
--- a/srcpkgs/loudgain/template
+++ b/srcpkgs/loudgain/template
@@ -1,7 +1,7 @@
 # Template file for 'loudgain'
 pkgname=loudgain
 version=0.6.8
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libebur128-devel taglib-devel ffmpeg-devel"

From 8e815329a264ec3e8dd55066a4f0dbb3a7befe0c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 052/115] mediastreamer: revbump for ffmpeg4-4.4.3

---
 srcpkgs/mediastreamer/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mediastreamer/template b/srcpkgs/mediastreamer/template
index d0e97e858e29..1bde031443a5 100644
--- a/srcpkgs/mediastreamer/template
+++ b/srcpkgs/mediastreamer/template
@@ -1,11 +1,11 @@
 # Template file for 'mediastreamer'
 pkgname=mediastreamer
 version=5.2.6
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_STRICT=0 -DENABLE_UNIT_TESTS=0"
 hostmakedepends="python3"
-makedepends="bzrtp-devel ffmpeg-devel glew-devel libXv-devel libsrtp-devel
+makedepends="bzrtp-devel ffmpeg4-devel glew-devel libXv-devel libsrtp-devel
  libupnp-devel libvpx-devel mbedtls-devel opus-devel ortp-devel pulseaudio-devel
  libtheora-devel speex-devel v4l-utils-devel bcg729-devel bcmatroska2-devel libgsm-devel"
 # zxing-cpp-devel (1.2.0 probably not compatible, check again after updaing xzing)

From 6507a5eafcbc16f8b0c64ef595a687dc56478769 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 053/115] mgba: revbump for ffmpeg-6.0

---
 srcpkgs/mgba/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mgba/template b/srcpkgs/mgba/template
index ae0504311eee..d31295a0cd3d 100644
--- a/srcpkgs/mgba/template
+++ b/srcpkgs/mgba/template
@@ -1,7 +1,7 @@
 # Template file for 'mgba'
 pkgname=mgba
 version=0.10.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake desktop-file-utils"
 makedepends="SDL2-devel ffmpeg-devel libedit-devel libepoxy-devel libmagick-devel

From ff8ede555048b58af8ea9812aa2f05d37c203d7a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 054/115] minidlna: revbump for ffmpeg-6.0

---
 srcpkgs/minidlna/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/minidlna/template b/srcpkgs/minidlna/template
index d551e49ed465..5fa929f3a0c1 100644
--- a/srcpkgs/minidlna/template
+++ b/srcpkgs/minidlna/template
@@ -1,7 +1,7 @@
 # Template file for 'minidlna'
 pkgname=minidlna
 version=1.3.3
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="
  --sbindir=/usr/bin

From 3597120f196ce82156e6ec8506374236dadfbed3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 055/115] mlt: revbump for ffmpeg4-4.4.3

---
 srcpkgs/mlt/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mlt/template b/srcpkgs/mlt/template
index 8933eb4e7bb9..73353fedafb5 100644
--- a/srcpkgs/mlt/template
+++ b/srcpkgs/mlt/template
@@ -1,14 +1,14 @@
 # Template file for 'mlt'
 pkgname=mlt
 version=6.26.1
-revision=1
+revision=2
 build_style=configure
 configure_args="--prefix=/usr --libdir=/usr/lib$XBPS_TARGET_WORDSIZE
  --enable-gpl --enable-gpl3 --disable-swfdec --without-kde
  --swig-languages=python"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which"
 # XXX: movit vid.stab
-makedepends="alsa-lib-devel ffmpeg-devel gtk+-devel jack-devel ladspa-sdk
+makedepends="alsa-lib-devel ffmpeg4-devel gtk+-devel jack-devel ladspa-sdk
  libexif-devel libsamplerate-devel libxml2-devel sox-devel SDL_image-devel
  fftw-devel frei0r-plugins python3-devel pulseaudio-devel movit-devel
  libvidstab-devel libatomic-devel"

From 669b6382455c4cbe10827cb0c1923e03294c3b3d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 056/115] moc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/moc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/moc/template b/srcpkgs/moc/template
index 5aed5d36558d..d8de816026b6 100644
--- a/srcpkgs/moc/template
+++ b/srcpkgs/moc/template
@@ -1,10 +1,10 @@
 # Template file for 'moc'
 pkgname=moc
 version=2.5.2
-revision=6
+revision=7
 build_style=gnu-configure
 hostmakedepends="pkg-config"
-makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg-devel
+makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg4-devel
  jack-devel alsa-lib-devel libltdl-devel libflac-devel libvorbis-devel
  libmad-devel libmpcdec-devel libmodplug-devel libid3tag-devel faad2-devel
  taglib-devel libsndfile-devel wavpack-devel speex-devel libsamplerate-devel

From 5127c91f1158fb44d59db4d18dda2c78433ba6b8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 057/115] motion: revbump for ffmpeg-6.0

---
 srcpkgs/motion/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/motion/template b/srcpkgs/motion/template
index 3cf3c3035c5b..7dca12d851e3 100644
--- a/srcpkgs/motion/template
+++ b/srcpkgs/motion/template
@@ -1,7 +1,7 @@
 # Template file for 'motion'
 pkgname=motion
 version=4.5.1
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake pkg-config gettext-devel tar"
 makedepends="ffmpeg-devel libmicrohttpd-devel v4l-utils-devel gettext-devel"

From 00e66697af956aa9157620c3b781fd8b1e8847dd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 058/115] mpv: revbump for ffmpeg-6.0

---
 srcpkgs/mpv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpv/template b/srcpkgs/mpv/template
index e163c496c6eb..d4fefbf5e3c7 100644
--- a/srcpkgs/mpv/template
+++ b/srcpkgs/mpv/template
@@ -1,7 +1,7 @@
 # Template file for 'mpv'
 pkgname=mpv
 version=0.35.1
-revision=2
+revision=3
 build_style=meson
 configure_args="-Dcdda=enabled -Ddvbin=enabled -Ddvdnav=enabled
  -Dlibmpv=true -Dcplugins=enabled

From 3e51c8c9d6cd51eee9652663aa88e1e9f201d915 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 059/115] musikcube: revbump for ffmpeg-6.0

---
 srcpkgs/musikcube/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/musikcube/template b/srcpkgs/musikcube/template
index 7c569303c054..a4dea460c371 100644
--- a/srcpkgs/musikcube/template
+++ b/srcpkgs/musikcube/template
@@ -1,7 +1,7 @@
 # Template file for 'musikcube'
 pkgname=musikcube
 version=3.0.0
-revision=1
+revision=2
 build_style=cmake
 make_cmd=make
 configure_args="-DNO_NCURSESW=1"

From 281ec29bf13a41685197d790123e4d55cb107eee Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 060/115] notcurses: revbump for ffmpeg-6.0

---
 srcpkgs/notcurses/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/notcurses/template b/srcpkgs/notcurses/template
index 6dd8a091319f..3110c30c9aff 100644
--- a/srcpkgs/notcurses/template
+++ b/srcpkgs/notcurses/template
@@ -1,7 +1,7 @@
 # Template file for 'notcurses'
 pkgname=notcurses
 version=3.0.9
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DUSE_STATIC=ON $(vopt_bool man USE_PANDOC)"
 hostmakedepends="pkg-config $(vopt_if man pandoc)"

From 2c9a99fc9586bbb66a4620f0e4a0ef7067bbc7cb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 061/115] obs: revbump for ffmpeg-6.0

---
 srcpkgs/obs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/obs/template b/srcpkgs/obs/template
index 7b69c630d30d..2c8d68d71f3a 100644
--- a/srcpkgs/obs/template
+++ b/srcpkgs/obs/template
@@ -1,7 +1,7 @@
 # Template file for 'obs'
 pkgname=obs
 version=29.1.2
-revision=1
+revision=2
 archs="i686* x86_64* ppc64le* aarch64*"
 build_style=cmake
 configure_args="-DOBS_VERSION_OVERRIDE=${version} -DENABLE_JACK=ON

From f6a58bb3b3a1e3034d8be88c5702ddee2e50f620 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 062/115] olive: revbump for ffmpeg4-4.4.3

---
 srcpkgs/olive/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/olive/template b/srcpkgs/olive/template
index 12a46936c990..5c2917b9c512 100644
--- a/srcpkgs/olive/template
+++ b/srcpkgs/olive/template
@@ -1,10 +1,10 @@
 # Template file for 'olive'
 pkgname=olive
 version=0.1.2
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools pkg-config"
-makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg-devel frei0r-plugins"
+makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg4-devel frei0r-plugins"
 short_desc="Non-linear video editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"

From 77546270ec78437b27c7fc1a95ff45b88ab56d96 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 063/115] omxplayer: revbump for ffmpeg4-4.4.3

---
 srcpkgs/omxplayer/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/omxplayer/template b/srcpkgs/omxplayer/template
index e70bf7873d4d..0e9bc70e7c8e 100644
--- a/srcpkgs/omxplayer/template
+++ b/srcpkgs/omxplayer/template
@@ -1,10 +1,10 @@
 # Template file for 'omxplayer'
 pkgname=omxplayer
 version=20190102
-revision=1
+revision=2
 short_desc="Commandline OMX player for the Raspberry Pi"
 maintainer="Orphaned <orphan@voidlinux.org>"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://github.com/popcornmix/omxplayer"
 
 _commit="f06235cc9690a6d58187514452df8cf8fcdaacec"
@@ -15,7 +15,7 @@ checksum=af2d9450f8947842ea8c401fe9f71eec444013ebbdee29f2ac828c9c493c1329
 archs="armv6l* armv7l*"
 build_style=gnu-makefile
 hostmakedepends="curl pkg-config"
-makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg-devel dbus-devel"
+makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg4-devel dbus-devel"
 depends="freefont-ttf"
 
 do_build() {

From a941ec9d6354a9113f16fd70da955db3d5cfc034 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 064/115] openshot: revbump for ffmpeg-6.0

---
 srcpkgs/openshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openshot/template b/srcpkgs/openshot/template
index 322717d40abc..c074e0338773 100644
--- a/srcpkgs/openshot/template
+++ b/srcpkgs/openshot/template
@@ -1,7 +1,7 @@
 # Template file for 'openshot'
 pkgname=openshot
 version=3.0.0
-revision=1
+revision=2
 build_style=python3-module
 hostmakedepends="python3 python3-setuptools"
 makedepends="ffmpeg-devel python3-PyQt5"

From 458e98b2b1fab8f26a0306b19c543e6755a2874d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 065/115] opentoonz: revbump for ffmpeg-6.0

---
 srcpkgs/opentoonz/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/opentoonz/template b/srcpkgs/opentoonz/template
index ee9f7603f55f..3e81834ca0ed 100644
--- a/srcpkgs/opentoonz/template
+++ b/srcpkgs/opentoonz/template
@@ -1,7 +1,7 @@
 # Template file for 'opentoonz'
 pkgname=opentoonz
 version=1.6.0
-revision=2
+revision=3
 build_wrksrc="toonz/sources"
 build_style=cmake
 make_cmd=make

From 124afba6a3c0aa10446d0307aa61fdbae7de2743 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 066/115] pianobar: revbump for ffmpeg-6.0

---
 srcpkgs/pianobar/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pianobar/template b/srcpkgs/pianobar/template
index e3febb821a45..1e3dc1bf9308 100644
--- a/srcpkgs/pianobar/template
+++ b/srcpkgs/pianobar/template
@@ -1,7 +1,7 @@
 # Template file for 'pianobar'
 pkgname=pianobar
 version=2022.04.01
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="V=1"
 hostmakedepends="pkg-config"

From 5212bf6daae1277bff66239dc45c21ad8477775c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 067/115] ppsspp: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ppsspp/template | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/ppsspp/template b/srcpkgs/ppsspp/template
index 7984a733d4be..15a42fd2c993 100644
--- a/srcpkgs/ppsspp/template
+++ b/srcpkgs/ppsspp/template
@@ -1,7 +1,7 @@
 # Template file for 'ppsspp'
 pkgname=ppsspp
 version=1.14.4
-revision=1
+revision=2
 _glslang_commit=dc11adde23c455a24e13dd54de9b4ede8bdd7db8
 _SPIRV_Cross_commit=9acb9ec31f5a8ef80ea6b994bb77be787b08d3d1
 _armips_commit=6719edebaae03330ee5441d9b28280672edf00d5
@@ -13,7 +13,7 @@ configure_args="-DHEADLESS=1 -DUSE_SYSTEM_FFMPEG=1 -DUNITTEST=ON
  -DUSING_QT_UI=$(vopt_if qt ON OFF) -DUSE_SYSTEM_ZSTD=ON
  -DARMIPS_USE_STD_FILESYSTEM=ON"
 hostmakedepends="pkg-config python3 $(vopt_if qt qt5-host-tools)"
-makedepends="zlib-devel glew-devel ffmpeg-devel libzip-devel
+makedepends="zlib-devel glew-devel ffmpeg4-devel libzip-devel
  snappy-devel rapidjson libpng-devel libzstd-devel
  $(vopt_if sdl2 SDL2-devel) $(vopt_if wayland wayland-devel)
  $(vopt_if qt 'qt5-devel qt5-multimedia-devel')"
@@ -62,13 +62,12 @@ post_extract() {
 	mv ${wrksrc}/miniupnp-${_miniupnp_commit} ${wrksrc}/ext/miniupnp
 }
 
-post_patch(){
+post_patch() {
 	# disable git versioning
 	vsed -e 's|find_package(Git)|# &|' -i git-version.cmake
 }
 
 do_install() {
-	vlicense LICENSE.TXT
 	vinstall icons/icon.svg 644 usr/share/pixmaps ppsspp.svg
 	vinstall Qt/PPSSPP.desktop 644 usr/share/applications
 	vbin build/PPSSPPHeadless ppsspp-headless

From 8cebaa621005217574814e0145ac5bd80a6fbe14 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 068/115] pqiv: revbump for ffmpeg-6.0

---
 srcpkgs/pqiv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pqiv/template b/srcpkgs/pqiv/template
index 542fc27a2d32..9308d949b6a1 100644
--- a/srcpkgs/pqiv/template
+++ b/srcpkgs/pqiv/template
@@ -1,7 +1,7 @@
 # Template file for 'pqiv'
 pkgname=pqiv
 version=2.12
-revision=1
+revision=2
 build_style=gnu-makefile
 hostmakedepends="pkg-config"
 makedepends="glib-devel gtk+3-devel $(vopt_if ffmpeg ffmpeg-devel)

From febcf4bf73fdf6f547167f232ff146ed38ec237e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 069/115] qmmp: revbump for ffmpeg-6.0

---
 srcpkgs/qmmp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qmmp/template b/srcpkgs/qmmp/template
index 26c661ed16be..a150d7441c7a 100644
--- a/srcpkgs/qmmp/template
+++ b/srcpkgs/qmmp/template
@@ -1,7 +1,7 @@
 # Template file for 'qmmp'
 pkgname=qmmp
 version=1.6.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DUSE_HAL:BOOL=FALSE -DQMMP_DEFAULT_UI:STRING=simple"
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From 4a2259be4df6ec399d8057e520bb1af91719b2d4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 070/115] qt5-webengine: update to 5.15.13

---
 .../chromium-media-filters-cpp14.patch        |  11 ++
 srcpkgs/qt5-webengine/patches/ffmpeg5.patch   | 179 ++++++++++++++++++
 srcpkgs/qt5-webengine/template                |  10 +-
 3 files changed, 195 insertions(+), 5 deletions(-)
 create mode 100644 srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/ffmpeg5.patch

diff --git a/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
new file mode 100644
index 000000000000..04adc540f2cb
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
@@ -0,0 +1,11 @@
+--- a/src/3rdparty/chromium/media/filters/BUILD.gn	2023-02-27 13:32:59.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/BUILD.gn	2023-04-02 17:21:39.204066384 -0400
+@@ -96,6 +96,8 @@
+     "//ui/gfx/geometry:geometry",
+   ]
+ 
++  cflags_cc = [ "-std=c++14" ]
++
+   libs = []
+ 
+   if (proprietary_codecs) {
diff --git a/srcpkgs/qt5-webengine/patches/ffmpeg5.patch b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
new file mode 100644
index 000000000000..ac55e1634423
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
@@ -0,0 +1,179 @@
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:57.732547446 -0400
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:09.486478995 -0400
+@@ -57,6 +57,8 @@
+ 
+ namespace {
+ 
++constexpr int64_t kRelativeTsBase = static_cast<int64_t>(0x7ffeffffffffffff);
++
+ void SetAVStreamDiscard(AVStream* stream, AVDiscard discard) {
+   DCHECK(stream);
+   stream->discard = discard;
+@@ -90,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+   if (stream->start_time != kNoFFmpegTimestamp)
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (stream->first_dts != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, stream->first_dts);
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -408,11 +398,11 @@
+   scoped_refptr<DecoderBuffer> buffer;
+ 
+   if (type() == DemuxerStream::TEXT) {
+-    int id_size = 0;
++    size_t id_size = 0;
+     uint8_t* id_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
+ 
+-    int settings_size = 0;
++    size_t settings_size = 0;
+     uint8_t* settings_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
+ 
+@@ -424,7 +414,7 @@
+     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
+                                      side_data.data(), side_data.size());
+   } else {
+-    int side_data_size = 0;
++    size_t side_data_size = 0;
+     uint8_t* side_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
+ 
+@@ -485,7 +475,7 @@
+                                        packet->size - data_offset);
+     }
+ 
+-    int skip_samples_size = 0;
++    size_t skip_samples_size = 0;
+     const uint32_t* skip_samples_ptr =
+         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
+             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
+@@ -1587,6 +1577,8 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++      continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+       lowest_start_time_stream = stream.get();
+@@ -1604,6 +1596,8 @@
+     if (stream && stream->type() == DemuxerStream::VIDEO &&
+         stream->IsEnabled()) {
+       video_stream = stream.get();
++      if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++        continue;
+       if (video_stream->start_time() <= seek_time) {
+         return video_stream;
+       }
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h qtwebengine-5.15.10/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h
+--- a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-07-11 22:12:47.917192788 -0500
+@@ -29,6 +29,7 @@ extern "C" {
+ #include <libavformat/avformat.h>
+ #include <libavformat/avio.h>
+ #include <libavutil/avutil.h>
++#include <libavutil/channel_layout.h>
+ #include <libavutil/imgutils.h>
+ #include <libavutil/log.h>
+ #include <libavutil/mastering_display_metadata.h>
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/audio_file_reader.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/audio_file_reader.cc
+--- a/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -85,7 +85,7 @@ bool AudioFileReader::OpenDemuxer() {
+ }
+ 
+ bool AudioFileReader::OpenDecoder() {
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (codec) {
+     // MP3 decodes to S16P which we don't support, tell it to use S16 instead.
+     if (codec_context_->sample_fmt == AV_SAMPLE_FMT_S16P)
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -329,7 +329,7 @@ bool FFmpegAudioDecoder::ConfigureDecode
+     }
+   }
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec ||
+       avcodec_open2(codec_context_.get(), codec, &codec_options) < 0) {
+     DLOG(ERROR) << "Could not initialize audio decoder: "
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -59,7 +59,6 @@ static int64_t AVIOSeekOperation(void* o
+ }
+ 
+ void FFmpegGlue::InitializeFFmpeg() {
+-  av_register_all();
+ }
+ 
+ static void LogContainer(bool is_local_file,
+@@ -95,9 +94,6 @@ FFmpegGlue::FFmpegGlue(FFmpegURLProtocol
+   // Enable fast, but inaccurate seeks for MP3.
+   format_context_->flags |= AVFMT_FLAG_FAST_SEEK;
+ 
+-  // Ensures we can read out various metadata bits like vp8 alpha.
+-  format_context_->flags |= AVFMT_FLAG_KEEP_SIDE_DATA;
+-
+   // Ensures format parsing errors will bail out. From an audit on 11/2017, all
+   // instances were real failures. Solves bugs like http://crbug.com/710791.
+   format_context_->error_recognition |= AV_EF_EXPLODE;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -391,7 +391,7 @@ bool FFmpegVideoDecoder::ConfigureDecode
+   if (decode_nalus_)
+     codec_context_->flags2 |= AV_CODEC_FLAG2_CHUNKS;
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
+     ReleaseFFmpegResources();
+     return false;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/media_file_checker.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/media_file_checker.cc
+--- a/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -68,7 +68,7 @@ bool MediaFileChecker::Start(base::TimeD
+       auto context = AVStreamToAVCodecContext(format_context->streams[i]);
+       if (!context)
+         continue;
+-      AVCodec* codec = avcodec_find_decoder(cp->codec_id);
++      const AVCodec* codec = avcodec_find_decoder(cp->codec_id);
+       if (codec && avcodec_open2(context.get(), codec, nullptr) >= 0) {
+         auto loop = std::make_unique<FFmpegDecodingLoop>(context.get());
+         stream_contexts[i] = {std::move(context), std::move(loop)};
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc qtwebengine-5.15.10/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc
+--- a/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -203,7 +203,7 @@ int32_t H264DecoderImpl::InitDecode(cons
+   // a pointer |this|.
+   av_context_->opaque = this;
+ 
+-  AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
+   if (!codec) {
+     // This is an indication that FFmpeg has not been initialized or it has not
+     // been compiled/initialized with the correct set of codecs.
diff --git a/srcpkgs/qt5-webengine/template b/srcpkgs/qt5-webengine/template
index edeb07f1ab7a..095ab67701e4 100644
--- a/srcpkgs/qt5-webengine/template
+++ b/srcpkgs/qt5-webengine/template
@@ -1,9 +1,9 @@
 # Template file for 'qt5-webengine'
 pkgname=qt5-webengine
-version=5.15.11
-revision=4
+version=5.15.13
+revision=1
 _version="${version}-lts"
-_chromium_commit=be349eaf62e77955791d7bf29f893f1e8a37daf4
+_chromium_commit=e48df7803c7c98b0b2471c94057d32e44a301ad5
 archs="x86_64* i686* armv[67]* ppc64* aarch64*"
 create_wrksrc=yes
 build_style=qmake
@@ -32,8 +32,8 @@ license="GPL-3.0-or-later, LGPL-3.0-or-later"
 homepage="https://qt.io/"
 distfiles="https://github.com/qt/qtwebengine/archive/v${_version}.tar.gz
  https://github.com/qt/qtwebengine-chromium/archive/${_chromium_commit}.tar.gz"
-checksum="aa7466356c450c5f5870f979b93cd7e7e62da1165c328ffcab1a9928db18ad67
- 6f47ed8ab8cc062411f6f206da6353bc8263d6ed6d6290c689a05c01d91f646b"
+checksum="4b59838ed75ef788b59e1e412535a0e42dd9d311661fdeadb191b581ba815c63
+ a91686562b1d4e8b220e0bbcbab5feb64630e2de974b35ac034bf388af771a6c"
 
 no_generic_pkgconfig_link=yes
 build_options="sndio pipewire"

From a1a92811aba7a42b8b064c4a7e2fdbb83744c4bc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 071/115] qt5: update to 5.15.8

---
 ...erywhere-opensource-src-5.15.8-kf5-1.patch | 12913 ++++++++++++++++
 srcpkgs/qt5/template                          |    12 +-
 2 files changed, 12919 insertions(+), 6 deletions(-)
 create mode 100644 srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch

diff --git a/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch b/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch
new file mode 100644
index 000000000000..966c98bcd3bb
--- /dev/null
+++ b/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch
@@ -0,0 +1,12913 @@
+Submitted By:            Pierre Labastie <pierre_dot_labastie_at_neuf_dot_fr>
+Date:                    2023-01-05
+Initial Package Version: 5.15.8
+Upstream Status:         Applied (according to KDE)
+Origin:                  KDE patch set
+Description:             Patch set maintained by the KDE folks
+see https://dot.kde.org/2021/04/06/announcing-kdes-qt-5-patch-collection
+Patch generated using the procedure in
+https://wiki.linuxfromscratch.org/blfs/ticket/17476#comment:3
+
+Submodule qtbase 4ee4fc18..9cf586d6:
+diff --git a/qtbase/mkspecs/common/android/qplatformdefs.h b/qtbase/mkspecs/common/android/qplatformdefs.h
+index f75bc4093b..2bd59410d4 100644
+--- a/qtbase/mkspecs/common/android/qplatformdefs.h
++++ b/qtbase/mkspecs/common/android/qplatformdefs.h
+@@ -144,11 +144,7 @@
+ #define QT_SIGNAL_ARGS          int
+ #define QT_SIGNAL_IGNORE        SIG_IGN
+ 
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+ #define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+ 
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+diff --git a/qtbase/mkspecs/features/mac/sdk.mk b/qtbase/mkspecs/features/mac/sdk.mk
+index f30b5830b4..a32ceacb6c 100644
+--- a/qtbase/mkspecs/features/mac/sdk.mk
++++ b/qtbase/mkspecs/features/mac/sdk.mk
+@@ -1,6 +1,6 @@
+ 
+ ifeq ($(QT_MAC_SDK_NO_VERSION_CHECK),)
+-    CHECK_SDK_COMMAND = /usr/bin/xcrun --sdk $(EXPORT_QMAKE_MAC_SDK) -show-sdk-version 2>&1
++    CHECK_SDK_COMMAND = /usr/bin/xcrun --sdk $(EXPORT_QMAKE_MAC_SDK) -show-sdk-version 2>/dev/null
+     CURRENT_MAC_SDK_VERSION := $(shell DEVELOPER_DIR=$(EXPORT_QMAKE_XCODE_DEVELOPER_PATH) $(CHECK_SDK_COMMAND))
+     ifneq ($(CURRENT_MAC_SDK_VERSION),$(EXPORT_QMAKE_MAC_SDK_VERSION))
+         # We don't want to complain about out of date SDK unless the target needs to be remade.
+diff --git a/qtbase/mkspecs/linux-clang/qplatformdefs.h b/qtbase/mkspecs/linux-clang/qplatformdefs.h
+index a818d973f0..c1ab72fbc6 100644
+--- a/qtbase/mkspecs/linux-clang/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-clang/qplatformdefs.h
+@@ -79,14 +79,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-g++/qplatformdefs.h b/qtbase/mkspecs/linux-g++/qplatformdefs.h
+index 13523f0702..4d2750d9ec 100644
+--- a/qtbase/mkspecs/linux-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-g++/qplatformdefs.h
+@@ -79,14 +79,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ < 2)
+-#define QT_SOCKLEN_T            int
+-#else
+-#define QT_SOCKLEN_T            socklen_t
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-llvm/qplatformdefs.h b/qtbase/mkspecs/linux-llvm/qplatformdefs.h
+index dc750ab1ef..d3cc39b47f 100644
+--- a/qtbase/mkspecs/linux-llvm/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-llvm/qplatformdefs.h
+@@ -80,14 +80,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h b/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
+index 4c4e53da2a..83baffb3e3 100644
+--- a/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
+@@ -85,16 +85,9 @@
+ #include "../common/posix/qplatformdefs.h"
+ 
+ #undef QT_OPEN_LARGEFILE
+-#undef QT_SOCKLEN_T
+ 
+ #define QT_OPEN_LARGEFILE       0
+ 
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #ifndef SIOCGIFBRDADDR
+ #  define SIOCGIFBRDADDR 0x8919
+ #endif
+diff --git a/qtbase/mkspecs/lynxos-g++/qplatformdefs.h b/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
+index 4339ea2b23..6007af0055 100644
+--- a/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
+@@ -72,14 +72,6 @@
+ 
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp b/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
+index c3c184258f..32af3f8f29 100644
+--- a/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
++++ b/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
+@@ -10,6 +10,7 @@
+ #include "libANGLE/HandleAllocator.h"
+ 
+ #include <algorithm>
++#include <limits>
+ 
+ #include "common/debug.h"
+ 
+diff --git a/qtbase/src/3rdparty/forkfd/forkfd_linux.c b/qtbase/src/3rdparty/forkfd/forkfd_linux.c
+index ffe0e9a5e2..b1f5408d11 100644
+--- a/qtbase/src/3rdparty/forkfd/forkfd_linux.c
++++ b/qtbase/src/3rdparty/forkfd/forkfd_linux.c
+@@ -82,7 +82,8 @@ static int sys_clone(unsigned long cloneflags, int *ptid)
+     return syscall(__NR_clone, cloneflags, child_stack, stack_size, ptid, newtls, ctid);
+ #elif defined(__arc__) || defined(__arm__) || defined(__aarch64__) || defined(__mips__) || \
+     defined(__nds32__) || defined(__hppa__) || defined(__powerpc__) || defined(__i386__) || \
+-    defined(__x86_64__) || defined(__xtensa__) || defined(__alpha__) || defined(__riscv)
++    defined(__x86_64__) || defined(__xtensa__) || defined(__alpha__) || defined(__riscv) || \
++    defined(__loongarch__)
+     /* ctid and newtls are inverted on CONFIG_CLONE_BACKWARDS architectures,
+      * but since both values are 0, there's no harm. */
+     return syscall(__NR_clone, cloneflags, child_stack, ptid, ctid, newtls);
+diff --git a/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java b/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
+index 5792b5b2f5..2f74750fcf 100644
+--- a/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
++++ b/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
+@@ -116,6 +116,7 @@ public class QtNative
+     public static QtThread m_qtThread = new QtThread();
+     private static HashMap<String, Uri> m_cachedUris = new HashMap<String, Uri>();
+     private static ArrayList<String> m_knownDirs = new ArrayList<String>();
++    private static final String NoPermissionErrorMessage = "No permissions to open Uri";
+ 
+     private static final Runnable runPendingCppRunnablesRunnable = new Runnable() {
+         @Override
+@@ -193,11 +194,10 @@ public class QtNative
+                     return iterUri;
+             }
+ 
+-            // Android 6 and earlier could still manage to open the file so we can return the
+-            // parsed uri here
+-            if (Build.VERSION.SDK_INT < 24)
+-                return parsedUri;
+-            return null;
++            // if we only have transient permissions on uri all the above will fail,
++            // but we will be able to read the file anyway, so continue with uri here anyway
++            // and check for SecurityExceptions later
++            return parsedUri;
+         } catch (SecurityException e) {
+             e.printStackTrace();
+             return null;
+@@ -244,7 +244,7 @@ public class QtNative
+         int error = -1;
+ 
+         if (uri == null) {
+-            Log.e(QtTAG, "openFdForContentUrl(): No permissions to open Uri");
++            Log.e(QtTAG, "openFdForContentUrl(): " + NoPermissionErrorMessage);
+             return error;
+         }
+ 
+@@ -254,12 +254,13 @@ public class QtNative
+             return fdDesc.detachFd();
+         } catch (FileNotFoundException e) {
+             e.printStackTrace();
+-            return error;
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "openFdForContentUrl(): Invalid Uri");
+             e.printStackTrace();
+-            return error;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return error;
+     }
+ 
+     public static long getSize(Context context, String contentUrl)
+@@ -270,7 +271,7 @@ public class QtNative
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+ 
+         if (uri == null) {
+-            Log.e(QtTAG, "getSize(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return size;
+         } else if (!m_cachedUris.containsKey(contentUrl)) {
+             m_cachedUris.put(contentUrl, uri);
+@@ -288,12 +289,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "getSize(): Invalid Uri");
+             e.printStackTrace();
+-            return size;
+         }  catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "getSize(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return size;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return size;
+     }
+ 
+     public static boolean checkFileExists(Context context, String contentUrl)
+@@ -303,7 +305,7 @@ public class QtNative
+         if (uri == null)
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+         if (uri == null) {
+-            Log.e(QtTAG, "checkFileExists(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return exists;
+         } else {
+             if (!m_cachedUris.containsKey(contentUrl))
+@@ -321,12 +323,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "checkFileExists(): Invalid Uri");
+             e.printStackTrace();
+-            return exists;
+         } catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "checkFileExists(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return false;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return exists;
+     }
+ 
+     public static boolean checkIfWritable(Context context, String contentUrl)
+@@ -344,7 +347,7 @@ public class QtNative
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+         }
+         if (uri == null) {
+-            Log.e(QtTAG, "isDir(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return isDir;
+         } else {
+             if (!m_cachedUris.containsKey(contentUrl))
+@@ -374,12 +377,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "checkIfDir(): Invalid Uri");
+             e.printStackTrace();
+-            return false;
+         } catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "checkIfDir(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return false;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return false;
+     }
+     public static String[] listContentsFromTreeUri(Context context, String contentUrl)
+     {
+diff --git a/qtbase/src/concurrent/qtconcurrentreducekernel.h b/qtbase/src/concurrent/qtconcurrentreducekernel.h
+index 8f9a938952..a98dedef2e 100644
+--- a/qtbase/src/concurrent/qtconcurrentreducekernel.h
++++ b/qtbase/src/concurrent/qtconcurrentreducekernel.h
+@@ -212,11 +212,13 @@ public:
+ 
+     inline bool shouldThrottle()
+     {
++        std::lock_guard<QMutex> locker(mutex);
+         return (resultsMapSize > (ReduceQueueThrottleLimit * threadCount));
+     }
+ 
+     inline bool shouldStartThread()
+     {
++        std::lock_guard<QMutex> locker(mutex);
+         return (resultsMapSize <= (ReduceQueueStartLimit * threadCount));
+     }
+ };
+diff --git a/qtbase/src/concurrent/qtconcurrentthreadengine.cpp b/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
+index ea6ce3ac42..7f91a2ba68 100644
+--- a/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
++++ b/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
+@@ -176,6 +176,39 @@ void ThreadEngineBase::startSingleThreaded()
+     finish();
+ }
+ 
++void ThreadEngineBase::startBlocking()
++{
++    start();
++    barrier.acquire();
++    startThreads();
++
++    bool throttled = false;
++#ifndef QT_NO_EXCEPTIONS
++    try {
++#endif
++        while (threadFunction() == ThrottleThread) {
++            if (threadThrottleExit()) {
++                throttled = true;
++                break;
++            }
++        }
++#ifndef QT_NO_EXCEPTIONS
++    } catch (QException &e) {
++        handleException(e);
++    } catch (...) {
++        handleException(QUnhandledException());
++    }
++#endif
++
++    if (throttled == false) {
++        barrier.release();
++    }
++
++    barrier.wait();
++    finish();
++    exceptionStore.throwPossibleException();
++}
++
+ void ThreadEngineBase::startThread()
+ {
+     startThreadInternal();
+diff --git a/qtbase/src/concurrent/qtconcurrentthreadengine.h b/qtbase/src/concurrent/qtconcurrentthreadengine.h
+index 7c30cebdbc..a4c8548cc4 100644
+--- a/qtbase/src/concurrent/qtconcurrentthreadengine.h
++++ b/qtbase/src/concurrent/qtconcurrentthreadengine.h
+@@ -91,6 +91,7 @@ public:
+     ThreadEngineBase();
+     virtual ~ThreadEngineBase();
+     void startSingleThreaded();
++    void startBlocking();
+     void startThread();
+     bool isCanceled();
+     void waitForResume();
+@@ -143,6 +144,15 @@ public:
+         return result();
+     }
+ 
++    // Runs the user algorithm using multiple threads.
++    // This function blocks until the algorithm is finished,
++    // and then returns the result.
++    T *startBlocking()
++    {
++        ThreadEngineBase::startBlocking();
++        return result();
++    }
++
+     // Runs the user algorithm using multiple threads.
+     // Does not block, returns a future.
+     QFuture<T> startAsynchronously()
+@@ -223,6 +233,13 @@ class ThreadEngineStarter : public ThreadEngineStarterBase<T>
+ public:
+     ThreadEngineStarter(TypedThreadEngine *eng)
+         : Base(eng) { }
++
++    T startBlocking()
++    {
++        T t = *this->threadEngine->startBlocking();
++        delete this->threadEngine;
++        return t;
++    }
+ };
+ 
+ // Full template specialization where T is void.
+@@ -232,6 +249,12 @@ class ThreadEngineStarter<void> : public ThreadEngineStarterBase<void>
+ public:
+     ThreadEngineStarter(ThreadEngine<void> *_threadEngine)
+         : ThreadEngineStarterBase<void>(_threadEngine) {}
++
++    void startBlocking()
++    {
++        this->threadEngine->startBlocking();
++        delete this->threadEngine;
++    }
+ };
+ 
+ //! [qtconcurrentthreadengine-1]
+diff --git a/qtbase/src/corelib/animation/qvariantanimation.cpp b/qtbase/src/corelib/animation/qvariantanimation.cpp
+index 98b02f0202..eac1524107 100644
+--- a/qtbase/src/corelib/animation/qvariantanimation.cpp
++++ b/qtbase/src/corelib/animation/qvariantanimation.cpp
+@@ -276,7 +276,9 @@ void QVariantAnimationPrivate::setCurrentValueForProgress(const qreal progress)
+ 
+     const qreal startProgress = currentInterval.start.first;
+     const qreal endProgress = currentInterval.end.first;
+-    const qreal localProgress = (progress - startProgress) / (endProgress - startProgress);
++    const qreal localProgress =
++            qIsNull(progress - startProgress) ? 0.0 // avoid 0/0 below
++            /* else */                        : (progress - startProgress) / (endProgress - startProgress);
+ 
+     QVariant ret = q->interpolated(currentInterval.start.second,
+                                    currentInterval.end.second,
+diff --git a/qtbase/src/corelib/global/qnamespace.h b/qtbase/src/corelib/global/qnamespace.h
+index ad4150b317..bf19b1627b 100644
+--- a/qtbase/src/corelib/global/qnamespace.h
++++ b/qtbase/src/corelib/global/qnamespace.h
+@@ -1864,7 +1864,7 @@ public:
+     QT_Q_ENUM(TimerType)
+     QT_Q_ENUM(ScrollPhase)
+     QT_Q_ENUM(MouseEventSource)
+-    QT_Q_FLAG(MouseEventFlag)
++    QT_Q_FLAG(MouseEventFlags)
+     QT_Q_ENUM(ChecksumType)
+     QT_Q_ENUM(HighDpiScaleFactorRoundingPolicy)
+     QT_Q_ENUM(TabFocusBehavior)
+diff --git a/qtbase/src/corelib/global/qrandom.cpp b/qtbase/src/corelib/global/qrandom.cpp
+index 10672c1f92..25f87c7e6a 100644
+--- a/qtbase/src/corelib/global/qrandom.cpp
++++ b/qtbase/src/corelib/global/qrandom.cpp
+@@ -383,7 +383,6 @@ struct QRandomGenerator::SystemAndGlobalGenerators
+ 
+         constexpr SystemAndGlobalGenerators g = {};
+         Q_UNUSED(g);
+-        Q_STATIC_ASSERT(std::is_literal_type<SystemAndGlobalGenerators>::value);
+ #endif
+     }
+ 
+diff --git a/qtbase/src/corelib/io/qbuffer.cpp b/qtbase/src/corelib/io/qbuffer.cpp
+index 595fcd2724..032c0ddd4b 100644
+--- a/qtbase/src/corelib/io/qbuffer.cpp
++++ b/qtbase/src/corelib/io/qbuffer.cpp
+@@ -41,6 +41,8 @@
+ #include <QtCore/qmetaobject.h>
+ #include "private/qiodevice_p.h"
+ 
++#include <limits>
++
+ QT_BEGIN_NAMESPACE
+ 
+ /** QBufferPrivate **/
+@@ -366,7 +368,9 @@ qint64 QBuffer::size() const
+ bool QBuffer::seek(qint64 pos)
+ {
+     Q_D(QBuffer);
+-    if (pos > d->buf->size() && isWritable()) {
++    const auto oldBufSize = d->buf->size();
++    constexpr qint64 MaxSeekPos = (std::numeric_limits<decltype(oldBufSize)>::max)();
++    if (pos <= MaxSeekPos && pos > oldBufSize && isWritable()) {
+         if (seek(d->buf->size())) {
+             const qint64 gapSize = pos - d->buf->size();
+             if (write(QByteArray(gapSize, 0)) != gapSize) {
+@@ -377,7 +381,7 @@ bool QBuffer::seek(qint64 pos)
+             return false;
+         }
+     } else if (pos > d->buf->size() || pos < 0) {
+-        qWarning("QBuffer::seek: Invalid pos: %d", int(pos));
++        qWarning("QBuffer::seek: Invalid pos: %lld", pos);
+         return false;
+     }
+     return QIODevice::seek(pos);
+diff --git a/qtbase/src/corelib/io/qfilesystemengine_win.cpp b/qtbase/src/corelib/io/qfilesystemengine_win.cpp
+index 81d3a71986..c86ed1f9b0 100644
+--- a/qtbase/src/corelib/io/qfilesystemengine_win.cpp
++++ b/qtbase/src/corelib/io/qfilesystemengine_win.cpp
+@@ -664,14 +664,14 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry)
+     return QFileSystemEntry(ret, QFileSystemEntry::FromInternalPath());
+ }
+ 
+-#if defined(Q_CC_MINGW) && WINVER < 0x0602 //  Windows 8 onwards
++#if defined(Q_CC_MINGW) && WINVER < 0x0602 && _WIN32_WINNT < _WIN32_WINNT_WIN8 //  Windows 8 onwards
+ 
+ typedef struct _FILE_ID_INFO {
+     ULONGLONG VolumeSerialNumber;
+     FILE_ID_128 FileId;
+ } FILE_ID_INFO, *PFILE_ID_INFO;
+ 
+-#endif // if defined (Q_CC_MINGW) && WINVER < 0x0602
++#endif // if defined(Q_CC_MINGW) && WINVER < 0x0602 && _WIN32_WINNT < _WIN32_WINNT_WIN8
+ 
+ // File ID for Windows up to version 7 and FAT32 drives
+ static inline QByteArray fileId(HANDLE handle)
+diff --git a/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp b/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
+index 94d9d06bcb..27e0b13b0b 100644
+--- a/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
++++ b/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
+@@ -366,7 +366,9 @@ void QInotifyFileSystemWatcherEngine::readFromInotify()
+     // qDebug("QInotifyFileSystemWatcherEngine::readFromInotify");
+ 
+     int buffSize = 0;
+-    ioctl(inotifyFd, FIONREAD, (char *) &buffSize);
++    if (ioctl(inotifyFd, FIONREAD, (char *) &buffSize) == -1 || buffSize == 0)
++        return;
++
+     QVarLengthArray<char, 4096> buffer(buffSize);
+     buffSize = read(inotifyFd, buffer.data(), buffSize);
+     char *at = buffer.data();
+diff --git a/qtbase/src/corelib/io/qlockfile_win.cpp b/qtbase/src/corelib/io/qlockfile_win.cpp
+index 277f8d4230..38ecef5550 100644
+--- a/qtbase/src/corelib/io/qlockfile_win.cpp
++++ b/qtbase/src/corelib/io/qlockfile_win.cpp
+@@ -48,6 +48,8 @@
+ #include "QtCore/qdebug.h"
+ #include "QtCore/qthread.h"
+ 
++#include "private/qsystemlibrary_p.h"
++
+ QT_BEGIN_NAMESPACE
+ 
+ static inline bool fileExists(const wchar_t *fileName)
+@@ -150,7 +152,7 @@ QString QLockFilePrivate::processNameByPid(qint64 pid)
+ #if !defined(Q_OS_WINRT)
+     typedef DWORD (WINAPI *GetModuleFileNameExFunc)(HANDLE, HMODULE, LPTSTR, DWORD);
+ 
+-    HMODULE hPsapi = LoadLibraryA("psapi");
++    HMODULE hPsapi = QSystemLibrary::load(L"psapi");
+     if (!hPsapi)
+         return QString();
+     GetModuleFileNameExFunc qGetModuleFileNameEx = reinterpret_cast<GetModuleFileNameExFunc>(
+diff --git a/qtbase/src/corelib/io/qprocess_unix.cpp b/qtbase/src/corelib/io/qprocess_unix.cpp
+index 50390e57f5..15c8f30745 100644
+--- a/qtbase/src/corelib/io/qprocess_unix.cpp
++++ b/qtbase/src/corelib/io/qprocess_unix.cpp
+@@ -1,7 +1,7 @@
+ /****************************************************************************
+ **
+ ** Copyright (C) 2016 The Qt Company Ltd.
+-** Copyright (C) 2016 Intel Corporation.
++** Copyright (C) 2022 Intel Corporation.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtCore module of the Qt Toolkit.
+@@ -422,14 +422,15 @@ void QProcessPrivate::startProcess()
+     // Add the program name to the argument list.
+     argv[0] = nullptr;
+     if (!program.contains(QLatin1Char('/'))) {
++        // findExecutable() returns its argument if it's an absolute path,
++        // otherwise it searches $PATH; returns empty if not found (we handle
++        // that case much later)
+         const QString &exeFilePath = QStandardPaths::findExecutable(program);
+-        if (!exeFilePath.isEmpty()) {
+-            const QByteArray &tmp = QFile::encodeName(exeFilePath);
+-            argv[0] = ::strdup(tmp.constData());
+-        }
+-    }
+-    if (!argv[0])
++        const QByteArray &tmp = QFile::encodeName(exeFilePath);
++        argv[0] = ::strdup(tmp.constData());
++    } else {
+         argv[0] = ::strdup(encodedProgramName.constData());
++    }
+ 
+     // Add every argument to the list
+     for (int i = 0; i < arguments.count(); ++i)
+@@ -983,15 +984,16 @@ bool QProcessPrivate::startDetached(qint64 *pid)
+                 envp = _q_dupEnvironment(environment.d.constData()->vars, &envc);
+             }
+ 
+-            QByteArray tmp;
+             if (!program.contains(QLatin1Char('/'))) {
++                // findExecutable() returns its argument if it's an absolute path,
++                // otherwise it searches $PATH; returns empty if not found (we handle
++                // that case much later)
+                 const QString &exeFilePath = QStandardPaths::findExecutable(program);
+-                if (!exeFilePath.isEmpty())
+-                    tmp = QFile::encodeName(exeFilePath);
++                const QByteArray &tmp = QFile::encodeName(exeFilePath);
++                argv[0] = ::strdup(tmp.constData());
++            } else {
++                argv[0] = ::strdup(QFile::encodeName(program));
+             }
+-            if (tmp.isEmpty())
+-                tmp = QFile::encodeName(program);
+-            argv[0] = tmp.data();
+ 
+             if (envp)
+                 qt_safe_execve(argv[0], argv, envp);
+diff --git a/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp b/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
+index 3a79c502af..997a634e76 100644
+--- a/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
++++ b/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
+@@ -3196,9 +3196,8 @@ bool QAbstractItemModel::beginMoveColumns(const QModelIndex &sourceParent, int s
+     destinationChange.needsAdjust = destinationParent.isValid() && destinationParent.row() >= sourceLast && destinationParent.parent() == sourceParent;
+     d->changes.push(destinationChange);
+ 
+-    d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Horizontal);
+-
+     emit columnsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, QPrivateSignal());
++    d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Horizontal);
+     return true;
+ }
+ 
+@@ -3231,7 +3230,6 @@ void QAbstractItemModel::endMoveColumns()
+       adjustedSource = createIndex(adjustedSource.row(), adjustedSource.column() + numMoved, adjustedSource.internalPointer());
+ 
+     d->itemsMoved(adjustedSource, removeChange.first, removeChange.last, adjustedDestination, insertChange.first, Qt::Horizontal);
+-
+     emit columnsMoved(adjustedSource, removeChange.first, removeChange.last, adjustedDestination, insertChange.first, QPrivateSignal());
+ }
+ 
+diff --git a/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+index dc6379d9fb..c5e287ee84 100644
+--- a/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
++++ b/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+@@ -939,8 +939,9 @@ void QSortFilterProxyModelPrivate::insert_source_items(
+                 q->beginInsertColumns(proxy_parent, proxy_start, proxy_end);
+         }
+ 
+-        for (int i = 0; i < source_items.size(); ++i)
+-            proxy_to_source.insert(proxy_start + i, source_items.at(i));
++        // TODO: use the range QList::insert() overload once it is implemented (QTBUG-58633).
++        proxy_to_source.insert(proxy_start, source_items.size(), 0);
++        std::copy(source_items.cbegin(), source_items.cend(), proxy_to_source.begin() + proxy_start);
+ 
+         build_source_to_proxy_mapping(proxy_to_source, source_to_proxy);
+ 
+@@ -3123,8 +3124,9 @@ bool QSortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex &
+ 
+     if (d->filter_data.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();
+@@ -3133,9 +3135,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.hasMatch(key);
+ }
+diff --git a/qtbase/src/corelib/kernel/qcoreapplication.cpp b/qtbase/src/corelib/kernel/qcoreapplication.cpp
+index ca2864df83..132b2eae52 100644
+--- a/qtbase/src/corelib/kernel/qcoreapplication.cpp
++++ b/qtbase/src/corelib/kernel/qcoreapplication.cpp
+@@ -1157,7 +1157,7 @@ static bool doNotify(QObject *receiver, QEvent *event)
+ bool QCoreApplicationPrivate::sendThroughApplicationEventFilters(QObject *receiver, QEvent *event)
+ {
+     // We can't access the application event filters outside of the main thread (race conditions)
+-    Q_ASSERT(receiver->d_func()->threadData.loadRelaxed()->thread.loadAcquire() == mainThread());
++    Q_ASSERT(receiver->d_func()->threadData.loadAcquire()->thread.loadRelaxed() == mainThread());
+ 
+     if (extraData) {
+         // application event filters are only called for objects in the GUI thread
+diff --git a/qtbase/src/corelib/kernel/qobject.cpp b/qtbase/src/corelib/kernel/qobject.cpp
+index 1eb79138d9..36cd780ee1 100644
+--- a/qtbase/src/corelib/kernel/qobject.cpp
++++ b/qtbase/src/corelib/kernel/qobject.cpp
+@@ -1010,7 +1010,7 @@ QObject::~QObject()
+         emit destroyed(this);
+     }
+ 
+-    if (d->declarativeData) {
++    if (!d->isDeletingChildren && d->declarativeData) {
+         if (static_cast<QAbstractDeclarativeDataImpl*>(d->declarativeData)->ownedByQml1) {
+             if (QAbstractDeclarativeData::destroyed_qml1)
+                 QAbstractDeclarativeData::destroyed_qml1(d->declarativeData, this);
+@@ -1580,7 +1580,7 @@ void QObject::moveToThread(QThread *targetThread)
+ 
+     QThreadData *currentData = QThreadData::current();
+     QThreadData *targetData = targetThread ? QThreadData::get2(targetThread) : nullptr;
+-    QThreadData *thisThreadData = d->threadData.loadRelaxed();
++    QThreadData *thisThreadData = d->threadData.loadAcquire();
+     if (!thisThreadData->thread.loadAcquire() && currentData == targetData) {
+         // one exception to the rule: we allow moving objects with no thread affinity to the current thread
+         currentData = d->threadData;
+@@ -2620,7 +2620,7 @@ int QObject::receivers(const char *signal) const
+         if (!d->isSignalConnected(signal_index))
+             return receivers;
+ 
+-        if (d->declarativeData && QAbstractDeclarativeData::receivers) {
++        if (!d->isDeletingChildren && d->declarativeData && QAbstractDeclarativeData::receivers) {
+             receivers += QAbstractDeclarativeData::receivers(d->declarativeData, this,
+                                                              signal_index);
+         }
+diff --git a/qtbase/src/corelib/kernel/qobject_p.h b/qtbase/src/corelib/kernel/qobject_p.h
+index 0b827a52ca..13ffb88999 100644
+--- a/qtbase/src/corelib/kernel/qobject_p.h
++++ b/qtbase/src/corelib/kernel/qobject_p.h
+@@ -444,7 +444,7 @@ inline void QObjectPrivate::checkForIncompatibleLibraryVersion(int version) cons
+ 
+ inline bool QObjectPrivate::isDeclarativeSignalConnected(uint signal_index) const
+ {
+-    return declarativeData && QAbstractDeclarativeData::isSignalConnected
++    return !isDeletingChildren && declarativeData && QAbstractDeclarativeData::isSignalConnected
+             && QAbstractDeclarativeData::isSignalConnected(declarativeData, q_func(), signal_index);
+ }
+ 
+diff --git a/qtbase/src/corelib/kernel/qtranslator.cpp b/qtbase/src/corelib/kernel/qtranslator.cpp
+index 2812ffb7ea..bc0177c5ec 100644
+--- a/qtbase/src/corelib/kernel/qtranslator.cpp
++++ b/qtbase/src/corelib/kernel/qtranslator.cpp
+@@ -902,7 +902,7 @@ static QString getMessage(const uchar *m, const uchar *end, const char *context,
+             goto end;
+         case Tag_Translation: {
+             int len = read32(m);
+-            if (len % 1)
++            if (len & 1)
+                 return QString();
+             m += 4;
+             if (!numerus--) {
+diff --git a/qtbase/src/corelib/mimetypes/qmimedatabase.cpp b/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
+index 9de22cef33..ff868a3268 100644
+--- a/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
+@@ -389,20 +389,23 @@ QMimeType QMimeDatabasePrivate::mimeTypeForFileNameAndData(const QString &fileNa
+         // Disambiguate conflicting extensions (if magic matching found something)
+         if (candidateByData.isValid() && magicAccuracy > 0) {
+             const QString sniffedMime = candidateByData.name();
+-            // If the sniffedMime matches a glob match, use it
++            // If the sniffedMime matches a highest-weight glob match, use it
+             if (candidatesByName.m_matchingMimeTypes.contains(sniffedMime)) {
+                 *accuracyPtr = 100;
+                 return candidateByData;
+             }
+-            for (const QString &m : qAsConst(candidatesByName.m_matchingMimeTypes)) {
++            for (const QString &m : qAsConst(candidatesByName.m_allMatchingMimeTypes)) {
+                 if (inherits(m, sniffedMime)) {
+                     // We have magic + pattern pointing to this, so it's a pretty good match
+                     *accuracyPtr = 100;
+                     return mimeTypeForName(m);
+                 }
+             }
+-            *accuracyPtr = magicAccuracy;
+-            return candidateByData;
++            if (candidatesByName.m_allMatchingMimeTypes.isEmpty()) {
++                // No glob, use magic
++                *accuracyPtr = magicAccuracy;
++                return candidateByData;
++            }
+         }
+     }
+ 
+diff --git a/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp b/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
+index a81112d227..fa8f4c545d 100644
+--- a/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
+@@ -83,7 +83,10 @@ void QMimeGlobMatchResult::addMatch(const QString &mimeType, int weight, const Q
+     }
+     if (!m_matchingMimeTypes.contains(mimeType)) {
+         m_matchingMimeTypes.append(mimeType);
+-        m_allMatchingMimeTypes.append(mimeType);
++        if (replace)
++            m_allMatchingMimeTypes.prepend(mimeType); // highest-weight first
++        else
++            m_allMatchingMimeTypes.append(mimeType);
+         m_knownSuffixLength = knownSuffixLength;
+     }
+ }
+@@ -94,7 +97,7 @@ QMimeGlobPattern::PatternType QMimeGlobPattern::detectPatternType(const QString
+     if (!patternLength)
+         return OtherPattern;
+ 
+-    const bool starCount = pattern.count(QLatin1Char('*')) == 1;
++    const int starCount = pattern.count(QLatin1Char('*'));
+     const bool hasSquareBracket = pattern.indexOf(QLatin1Char('[')) != -1;
+     const bool hasQuestionMark = pattern.indexOf(QLatin1Char('?')) != -1;
+ 
+@@ -106,10 +109,10 @@ QMimeGlobPattern::PatternType QMimeGlobPattern::detectPatternType(const QString
+             // Patterns like "README*" (well this is currently the only one like that...)
+             if (pattern.at(patternLength - 1) == QLatin1Char('*'))
+                 return PrefixPattern;
+-        }
+-        // Names without any wildcards like "README"
+-        if (starCount == 0)
++        } else if (starCount == 0) {
++            // Names without any wildcards like "README"
+             return LiteralPattern;
++        }
+     }
+ 
+     if (pattern == QLatin1String("[0-9][0-9][0-9].vdr"))
+diff --git a/qtbase/src/corelib/mimetypes/qmimeprovider.cpp b/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
+index 258dddf8cb..4642d0f2d0 100644
+--- a/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
+@@ -244,15 +244,18 @@ void QMimeBinaryProvider::addFileNameMatches(const QString &fileName, QMimeGlobM
+     const QString lowerFileName = fileName.toLower();
+     // Check literals (e.g. "Makefile")
+     matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosLiteralListOffset), fileName);
+-    // Check complex globs (e.g. "callgrind.out[0-9]*")
+-    matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosGlobListOffset), fileName);
+     // Check the very common *.txt cases with the suffix tree
+-    const int reverseSuffixTreeOffset = m_cacheFile->getUint32(PosReverseSuffixTreeOffset);
+-    const int numRoots = m_cacheFile->getUint32(reverseSuffixTreeOffset);
+-    const int firstRootOffset = m_cacheFile->getUint32(reverseSuffixTreeOffset + 4);
+-    matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, lowerFileName, lowerFileName.length() - 1, false);
++    if (result.m_matchingMimeTypes.isEmpty()) {
++        const int reverseSuffixTreeOffset = m_cacheFile->getUint32(PosReverseSuffixTreeOffset);
++        const int numRoots = m_cacheFile->getUint32(reverseSuffixTreeOffset);
++        const int firstRootOffset = m_cacheFile->getUint32(reverseSuffixTreeOffset + 4);
++        matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, lowerFileName, lowerFileName.length() - 1, false);
++        if (result.m_matchingMimeTypes.isEmpty())
++            matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, fileName, fileName.length() - 1, true);
++    }
++    // Check complex globs (e.g. "callgrind.out[0-9]*" or "README*")
+     if (result.m_matchingMimeTypes.isEmpty())
+-        matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, fileName, fileName.length() - 1, true);
++        matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosGlobListOffset), fileName);
+ }
+ 
+ void QMimeBinaryProvider::matchGlobList(QMimeGlobMatchResult &result, CacheFile *cacheFile, int off, const QString &fileName)
+diff --git a/qtbase/src/corelib/serialization/qjsonparser.cpp b/qtbase/src/corelib/serialization/qjsonparser.cpp
+index 17e6f111ab..2e40b6c8fb 100644
+--- a/qtbase/src/corelib/serialization/qjsonparser.cpp
++++ b/qtbase/src/corelib/serialization/qjsonparser.cpp
+@@ -379,10 +379,30 @@ error:
+     return QCborValue();
+ }
+ 
++// We need to retain the _last_ value for any duplicate keys and we need to deref containers.
++// Therefore the manual implementation of std::unique().
++template<typename Iterator, typename Compare, typename Assign>
++static Iterator customAssigningUniqueLast(Iterator first, Iterator last,
++                                          Compare compare, Assign assign)
++{
++    first = std::adjacent_find(first, last, compare);
++    if (first == last)
++        return last;
++
++    Iterator result = first;
++    while (++first != last) {
++        if (!compare(*result, *first))
++            ++result;
++        if (result != first)
++            assign(*result, *first);
++    }
++
++    return ++result;
++}
++
+ static void sortContainer(QCborContainerPrivate *container)
+ {
+     using Forward = QJsonPrivate::KeyIterator;
+-    using Reverse = std::reverse_iterator<Forward>;
+     using Value = Forward::value_type;
+ 
+     auto compare = [container](const Value &a, const Value &b)
+@@ -420,17 +440,31 @@ static void sortContainer(QCborContainerPrivate *container)
+         }
+     };
+ 
+-    std::sort(Forward(container->elements.begin()), Forward(container->elements.end()),
+-              [&compare](const Value &a, const Value &b) { return compare(a, b) < 0; });
++    // The elements' containers are owned by the outer container, not by the elements themselves.
++    auto move = [](Forward::reference target, Forward::reference source)
++    {
++        QtCbor::Element &targetValue = target.value();
++
++        // If the target has a container, deref it before overwriting, so that we don't leak.
++        if (targetValue.flags & QtCbor::Element::IsContainer)
++            targetValue.container->deref();
++
++        // Do not move, so that we can clear the value afterwards.
++        target = source;
++
++        // Clear the source value, so that we don't store the same container twice.
++        source.value() = QtCbor::Element();
++    };
++
++    std::stable_sort(
++                Forward(container->elements.begin()), Forward(container->elements.end()),
++                [&compare](const Value &a, const Value &b) { return compare(a, b) < 0; });
+ 
+-    // We need to retain the _last_ value for any duplicate keys. Therefore the reverse dance here.
+-    auto it = std::unique(Reverse(container->elements.end()), Reverse(container->elements.begin()),
+-                          [&compare](const Value &a, const Value &b) {
+-        return compare(a, b) == 0;
+-    }).base().elementsIterator();
++    Forward result = customAssigningUniqueLast(
++                Forward(container->elements.begin()),  Forward(container->elements.end()),
++                [&compare](const Value &a, const Value &b) { return compare(a, b) == 0; }, move);
+ 
+-    // The erase from beginning is expensive but hopefully rare.
+-    container->elements.erase(container->elements.begin(), it);
++    container->elements.erase(result.elementsIterator(), container->elements.end());
+ }
+ 
+ 
+diff --git a/qtbase/src/corelib/serialization/qxmlstream.cpp b/qtbase/src/corelib/serialization/qxmlstream.cpp
+index b2f846544d..7cd457ba3a 100644
+--- a/qtbase/src/corelib/serialization/qxmlstream.cpp
++++ b/qtbase/src/corelib/serialization/qxmlstream.cpp
+@@ -980,7 +980,7 @@ inline uint QXmlStreamReaderPrivate::peekChar()
+ bool QXmlStreamReaderPrivate::scanUntil(const char *str, short tokenToInject)
+ {
+     int pos = textBuffer.size();
+-    int oldLineNumber = lineNumber;
++    const auto oldLineNumber = lineNumber;
+ 
+     uint c;
+     while ((c = getChar()) != StreamEOF) {
+diff --git a/qtbase/src/corelib/text/qstring.cpp b/qtbase/src/corelib/text/qstring.cpp
+index 3e88ab4859..8deeae47bb 100644
+--- a/qtbase/src/corelib/text/qstring.cpp
++++ b/qtbase/src/corelib/text/qstring.cpp
+@@ -12312,7 +12312,7 @@ static qsizetype qLastIndexOf(Haystack haystack0, qsizetype from,
+     const auto needle = needle0.data();
+     const auto *end = haystack;
+     haystack += from;
+-    const std::size_t sl_minus_1 = sl - 1;
++    const std::size_t sl_minus_1 = sl ? sl - 1 : 0;
+     const auto *n = needle + sl_minus_1;
+     const auto *h = haystack + sl_minus_1;
+     std::size_t hashNeedle = 0, hashHaystack = 0;
+diff --git a/qtbase/src/corelib/text/qstringiterator_p.h b/qtbase/src/corelib/text/qstringiterator_p.h
+index 219589b6e4..1d0c66cc78 100644
+--- a/qtbase/src/corelib/text/qstringiterator_p.h
++++ b/qtbase/src/corelib/text/qstringiterator_p.h
+@@ -61,6 +61,8 @@ class QStringIterator
+ {
+     QString::const_iterator i, pos, e;
+     Q_STATIC_ASSERT((std::is_same<QString::const_iterator, const QChar *>::value));
++    static bool less(const QChar *lhs, const QChar *rhs) noexcept
++    { return std::less<QString::const_iterator>{}(lhs, rhs); }
+ public:
+     explicit QStringIterator(QStringView string, qsizetype idx = 0)
+         : i(string.begin()),
+@@ -95,7 +97,8 @@ public:
+ 
+     inline void setPosition(QString::const_iterator position)
+     {
+-        Q_ASSERT_X(i <= position && position <= e, Q_FUNC_INFO, "position out of bounds");
++        Q_ASSERT_X(!less(position, i) && !less(e, position),
++                   Q_FUNC_INFO, "position out of bounds");
+         pos = position;
+     }
+ 
+@@ -103,7 +106,7 @@ public:
+ 
+     inline bool hasNext() const
+     {
+-        return pos < e;
++        return less(pos, e);
+     }
+ 
+     inline void advance()
+@@ -120,16 +123,20 @@ public:
+     {
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+-        if (Q_UNLIKELY((pos++)->isHighSurrogate()))
++        if (Q_UNLIKELY((pos++)->isHighSurrogate())) {
++            Q_ASSERT(hasNext() && pos->isLowSurrogate());
+             ++pos;
++        }
+     }
+ 
+     inline uint peekNextUnchecked() const
+     {
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+-        if (Q_UNLIKELY(pos->isHighSurrogate()))
++        if (Q_UNLIKELY(pos->isHighSurrogate())) {
++            Q_ASSERT(less(pos + 1, e) && pos[1].isLowSurrogate());
+             return QChar::surrogateToUcs4(pos[0], pos[1]);
++        }
+ 
+         return pos->unicode();
+     }
+@@ -155,8 +162,10 @@ public:
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+         const QChar cur = *pos++;
+-        if (Q_UNLIKELY(cur.isHighSurrogate()))
++        if (Q_UNLIKELY(cur.isHighSurrogate())) {
++            Q_ASSERT(hasNext() && pos->isLowSurrogate());
+             return QChar::surrogateToUcs4(cur, *pos++);
++        }
+         return cur.unicode();
+     }
+ 
+@@ -166,7 +175,7 @@ public:
+ 
+         const QChar uc = *pos++;
+         if (Q_UNLIKELY(uc.isSurrogate())) {
+-            if (Q_LIKELY(uc.isHighSurrogate() && pos < e && pos->isLowSurrogate()))
++            if (Q_LIKELY(uc.isHighSurrogate() && hasNext() && pos->isLowSurrogate()))
+                 return QChar::surrogateToUcs4(uc, *pos++);
+             return invalidAs;
+         }
+@@ -178,7 +187,7 @@ public:
+ 
+     inline bool hasPrevious() const
+     {
+-        return pos > i;
++        return less(i, pos);
+     }
+ 
+     inline void recede()
+@@ -196,16 +205,20 @@ public:
+     {
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+-        if (Q_UNLIKELY((--pos)->isLowSurrogate()))
++        if (Q_UNLIKELY((--pos)->isLowSurrogate())) {
++            Q_ASSERT(hasPrevious() && pos[-1].isHighSurrogate());
+             --pos;
++        }
+     }
+ 
+     inline uint peekPreviousUnchecked() const
+     {
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+-        if (Q_UNLIKELY(pos[-1].isLowSurrogate()))
++        if (Q_UNLIKELY(pos[-1].isLowSurrogate())) {
++            Q_ASSERT(less(i + 1, pos) && pos[-2].isHighSurrogate());
+             return QChar::surrogateToUcs4(pos[-2], pos[-1]);
++        }
+         return pos[-1].unicode();
+     }
+ 
+@@ -230,8 +243,10 @@ public:
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+         const QChar cur = *--pos;
+-        if (Q_UNLIKELY(cur.isLowSurrogate()))
++        if (Q_UNLIKELY(cur.isLowSurrogate())) {
++            Q_ASSERT(hasPrevious() && pos[-1].isHighSurrogate());
+             return QChar::surrogateToUcs4(*--pos, cur);
++        }
+         return cur.unicode();
+     }
+ 
+@@ -241,7 +256,7 @@ public:
+ 
+         const QChar uc = *--pos;
+         if (Q_UNLIKELY(uc.isSurrogate())) {
+-            if (Q_LIKELY(uc.isLowSurrogate() && pos > i && pos[-1].isHighSurrogate()))
++            if (Q_LIKELY(uc.isLowSurrogate() && hasPrevious() && pos[-1].isHighSurrogate()))
+                 return QChar::surrogateToUcs4(*--pos, uc);
+             return invalidAs;
+         }
+diff --git a/qtbase/src/corelib/thread/qfutex_p.h b/qtbase/src/corelib/thread/qfutex_p.h
+index f287b752d7..e294537787 100644
+--- a/qtbase/src/corelib/thread/qfutex_p.h
++++ b/qtbase/src/corelib/thread/qfutex_p.h
+@@ -52,6 +52,7 @@
+ //
+ 
+ #include <qglobal.h>
++#include <QtCore/qtsan_impl.h>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -106,16 +107,13 @@ namespace QtLinuxFutex {
+     inline int _q_futex(int *addr, int op, int val, quintptr val2 = 0,
+                         int *addr2 = nullptr, int val3 = 0) noexcept
+     {
+-        // A futex call ensures total ordering on the futex words
+-        // (in either success or failure of the call). Instruct TSAN accordingly,
+-        // as TSAN does not understand the futex(2) syscall.
+-        _q_tsan_release(addr, addr2);
++        QtTsan::futexRelease(addr, addr2);
+ 
+         // we use __NR_futex because some libcs (like Android's bionic) don't
+         // provide SYS_futex etc.
+         int result = syscall(__NR_futex, addr, op | FUTEX_PRIVATE_FLAG, val, val2, addr2, val3);
+ 
+-        _q_tsan_acquire(addr, addr2);
++        QtTsan::futexAcquire(addr, addr2);
+ 
+         return result;
+     }
+diff --git a/qtbase/src/corelib/thread/qmutex.cpp b/qtbase/src/corelib/thread/qmutex.cpp
+index 310d1cb14f..7097122d8e 100644
+--- a/qtbase/src/corelib/thread/qmutex.cpp
++++ b/qtbase/src/corelib/thread/qmutex.cpp
+@@ -152,6 +152,7 @@ public:
+ 
+ /*!
+     \enum QMutex::RecursionMode
++    \obsolete Use QRecursiveMutex to create a recursive mutex.
+ 
+     \value Recursive  In this mode, a thread can lock the same mutex
+                       multiple times and the mutex won't be unlocked
+@@ -173,6 +174,7 @@ public:
+ 
+ /*!
+     Constructs a new mutex. The mutex is created in an unlocked state.
++    \obsolete Use QRecursiveMutex to create a recursive mutex.
+ 
+     If \a mode is QMutex::Recursive, a thread can lock the same mutex
+     multiple times and the mutex won't be unlocked until a
+@@ -197,7 +199,7 @@ QMutex::QMutex(RecursionMode mode)
+ QMutex::~QMutex()
+ {
+     QMutexData *d = d_ptr.loadRelaxed();
+-    if (isRecursive()) {
++    if (QBasicMutex::isRecursive()) {
+         delete static_cast<QRecursiveMutexPrivate *>(d);
+     } else if (d) {
+ #ifndef QT_LINUX_FUTEX
+diff --git a/qtbase/src/corelib/thread/qmutex.h b/qtbase/src/corelib/thread/qmutex.h
+index 73c9e00663..1bae573a03 100644
+--- a/qtbase/src/corelib/thread/qmutex.h
++++ b/qtbase/src/corelib/thread/qmutex.h
+@@ -42,6 +42,7 @@
+ 
+ #include <QtCore/qglobal.h>
+ #include <QtCore/qatomic.h>
++#include <QtCore/qtsan_impl.h>
+ #include <new>
+ 
+ #if __has_include(<chrono>)
+@@ -77,19 +78,37 @@ public:
+ 
+     // BasicLockable concept
+     inline void lock() QT_MUTEX_LOCK_NOEXCEPT {
++        QtTsan::mutexPreLock(this, 0u);
++
+         if (!fastTryLock())
+             lockInternal();
++
++        QtTsan::mutexPostLock(this, 0u, 0);
+     }
+ 
+     // BasicLockable concept
+     inline void unlock() noexcept {
+         Q_ASSERT(d_ptr.loadRelaxed()); //mutex must be locked
++
++        QtTsan::mutexPreUnlock(this, 0u);
++
+         if (!fastTryUnlock())
+             unlockInternal();
++
++        QtTsan::mutexPostUnlock(this, 0u);
+     }
+ 
+     bool tryLock() noexcept {
+-        return fastTryLock();
++        unsigned tsanFlags = QtTsan::TryLock;
++        QtTsan::mutexPreLock(this, tsanFlags);
++
++        const bool success = fastTryLock();
++
++        if (!success)
++            tsanFlags |= QtTsan::TryLockFailed;
++        QtTsan::mutexPostLock(this, tsanFlags, 0);
++
++        return success;
+     }
+ 
+     // Lockable concept
+@@ -134,8 +153,16 @@ public:
+ #else
+     QMutex() { d_ptr.storeRelaxed(nullptr); }
+ #endif
++#if QT_DEPRECATED_SINCE(5,15)
+     enum RecursionMode { NonRecursive, Recursive };
++    QT_DEPRECATED_VERSION_X(5, 15, "Use QRecursiveMutex instead of a recursive QMutex")
+     explicit QMutex(RecursionMode mode);
++
++    QT_DEPRECATED_VERSION_X(5, 15, "Use QRecursiveMutex instead of a recursive QMutex")
++    bool isRecursive() const noexcept
++    { return QBasicMutex::isRecursive(); }
++#endif
++
+     ~QMutex();
+ 
+     // BasicLockable concept
+@@ -166,9 +193,6 @@ public:
+     }
+ #endif
+ 
+-    bool isRecursive() const noexcept
+-    { return QBasicMutex::isRecursive(); }
+-
+ private:
+     Q_DISABLE_COPY(QMutex)
+     friend class QMutexLocker;
+diff --git a/qtbase/src/corelib/thread/qreadwritelock.cpp b/qtbase/src/corelib/thread/qreadwritelock.cpp
+index 8c28507d5a..9dd8503116 100644
+--- a/qtbase/src/corelib/thread/qreadwritelock.cpp
++++ b/qtbase/src/corelib/thread/qreadwritelock.cpp
+@@ -155,7 +155,7 @@ QReadWriteLock::QReadWriteLock(RecursionMode recursionMode)
+ */
+ QReadWriteLock::~QReadWriteLock()
+ {
+-    auto d = d_ptr.loadRelaxed();
++    auto d = d_ptr.loadAcquire();
+     if (isUncontendedLocked(d)) {
+         qWarning("QReadWriteLock: destroying locked QReadWriteLock");
+         return;
+@@ -445,7 +445,7 @@ void QReadWriteLock::unlock()
+ /*! \internal  Helper for QWaitCondition::wait */
+ QReadWriteLock::StateForWaitCondition QReadWriteLock::stateForWaitCondition() const
+ {
+-    QReadWriteLockPrivate *d = d_ptr.loadRelaxed();
++    QReadWriteLockPrivate *d = d_ptr.loadAcquire();
+     switch (quintptr(d) & StateMask) {
+     case StateLockedForRead: return LockedForRead;
+     case StateLockedForWrite: return LockedForWrite;
+@@ -453,6 +453,7 @@ QReadWriteLock::StateForWaitCondition QReadWriteLock::stateForWaitCondition() co
+ 
+     if (!d)
+         return Unlocked;
++    const auto lock = qt_scoped_lock(d->mutex);
+     if (d->writerCount > 1)
+         return RecursivelyLocked;
+     else if (d->writerCount == 1)
+diff --git a/qtbase/src/corelib/thread/qsemaphore.cpp b/qtbase/src/corelib/thread/qsemaphore.cpp
+index 1d01fc1b28..3ecdee3747 100644
+--- a/qtbase/src/corelib/thread/qsemaphore.cpp
++++ b/qtbase/src/corelib/thread/qsemaphore.cpp
+@@ -354,7 +354,12 @@ void QSemaphore::release(int n)
+         quintptr nn = unsigned(n);
+         if (futexHasWaiterCount)
+             nn |= quint64(nn) << 32;    // token count replicated in high word
+-        quintptr prevValue = u.fetchAndAddRelease(nn);
++        quintptr prevValue = u.loadRelaxed();
++        quintptr newValue;
++        do { // loop just to ensure the operations are done atomically
++            newValue = prevValue + nn;
++            newValue &= (futexNeedsWakeAllBit - 1);
++        } while (!u.testAndSetRelease(prevValue, newValue, prevValue));
+         if (futexNeedsWake(prevValue)) {
+ #ifdef FUTEX_OP
+             if (futexHasWaiterCount) {
+@@ -376,7 +381,6 @@ void QSemaphore::release(int n)
+                 quint32 oparg = 0;
+                 quint32 cmp = FUTEX_OP_CMP_NE;
+                 quint32 cmparg = 0;
+-                u.fetchAndAndRelease(futexNeedsWakeAllBit - 1);
+                 futexWakeOp(*futexLow32(&u), n, INT_MAX, *futexHigh32(&u), FUTEX_OP(op, oparg, cmp, cmparg));
+                 return;
+             }
+@@ -388,7 +392,6 @@ 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(futexNeedsWakeAllBit - 1);
+             if (futexHasWaiterCount) {
+                 futexWakeAll(*futexLow32(&u));
+                 futexWakeAll(*futexHigh32(&u));
+diff --git a/qtbase/src/corelib/thread/qthread_p.h b/qtbase/src/corelib/thread/qthread_p.h
+index b2d1628e6e..f32f6f0460 100644
+--- a/qtbase/src/corelib/thread/qthread_p.h
++++ b/qtbase/src/corelib/thread/qthread_p.h
+@@ -174,7 +174,7 @@ public:
+     int returnCode;
+ 
+     uint stackSize;
+-    QThread::Priority priority;
++    std::underlying_type<QThread::Priority>::type priority;
+ 
+     static QThread *threadForId(int id);
+ 
+@@ -213,6 +213,13 @@ public:
+             QCoreApplication::instance()->postEvent(q_ptr, new QEvent(QEvent::Quit));
+         }
+     }
++
++#ifndef Q_OS_INTEGRITY
++private:
++    // Used in QThread(Private)::start to avoid racy access to QObject::objectName,
++    // unset afterwards. On INTEGRITY we set the thread name before starting it.
++    QString objectName;
++#endif
+ };
+ 
+ #else // QT_CONFIG(thread)
+diff --git a/qtbase/src/corelib/thread/qthread_unix.cpp b/qtbase/src/corelib/thread/qthread_unix.cpp
+index 56a8e0a038..610117a640 100644
+--- a/qtbase/src/corelib/thread/qthread_unix.cpp
++++ b/qtbase/src/corelib/thread/qthread_unix.cpp
+@@ -169,8 +169,7 @@ static void set_thread_data(QThreadData *data)
+ 
+ static void clear_thread_data()
+ {
+-    currentThreadData = nullptr;
+-    pthread_setspecific(current_thread_data_key, nullptr);
++    set_thread_data(nullptr);
+ }
+ 
+ template <typename T>
+@@ -296,7 +295,7 @@ void *QThreadPrivate::start(void *arg)
+             QMutexLocker locker(&thr->d_func()->mutex);
+ 
+             // do we need to reset the thread priority?
+-            if (int(thr->d_func()->priority) & ThreadPriorityResetFlag) {
++            if (thr->d_func()->priority & ThreadPriorityResetFlag) {
+                 thr->d_func()->setPriority(QThread::Priority(thr->d_func()->priority & ~ThreadPriorityResetFlag));
+             }
+ 
+@@ -316,10 +315,10 @@ void *QThreadPrivate::start(void *arg)
+             // Sets the name of the current thread. We can only do this
+             // when the thread is starting, as we don't have a cross
+             // platform way of setting the name of an arbitrary thread.
+-            if (Q_LIKELY(thr->objectName().isEmpty()))
++            if (Q_LIKELY(thr->d_func()->objectName.isEmpty()))
+                 setCurrentThreadName(thr->metaObject()->className());
+             else
+-                setCurrentThreadName(thr->objectName().toLocal8Bit());
++                setCurrentThreadName(std::exchange(thr->d_func()->objectName, {}).toLocal8Bit());
+         }
+ #endif
+ 
+@@ -671,7 +670,7 @@ void QThread::start(Priority priority)
+                 // could not set scheduling hints, fallback to inheriting them
+                 // we'll try again from inside the thread
+                 pthread_attr_setinheritsched(&attr, PTHREAD_INHERIT_SCHED);
+-                d->priority = Priority(priority | ThreadPriorityResetFlag);
++                d->priority = static_cast<std::underlying_type<QThread::Priority>::type>(priority) | ThreadPriorityResetFlag;
+             }
+             break;
+         }
+@@ -702,7 +701,10 @@ void QThread::start(Priority priority)
+         pthread_attr_setthreadname(&attr, metaObject()->className());
+     else
+         pthread_attr_setthreadname(&attr, objectName().toLocal8Bit());
++#else
++    d->objectName = objectName();
+ #endif
++
+     pthread_t threadId;
+     int code = pthread_create(&threadId, &attr, QThreadPrivate::start, this);
+     if (code == EPERM) {
+diff --git a/qtbase/src/corelib/thread/qthread_win.cpp b/qtbase/src/corelib/thread/qthread_win.cpp
+index bc70e3178a..4e76972498 100644
+--- a/qtbase/src/corelib/thread/qthread_win.cpp
++++ b/qtbase/src/corelib/thread/qthread_win.cpp
+@@ -394,10 +394,9 @@ unsigned int __stdcall QT_ENSURE_STACK_ALIGNED_FOR_SSE QThreadPrivate::start(voi
+ 
+ #if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) && !defined(Q_OS_WINRT)
+     // sets the name of the current thread.
+-    QByteArray objectName = thr->objectName().toLocal8Bit();
+-    qt_set_thread_name(HANDLE(-1),
+-                       objectName.isEmpty() ?
+-                       thr->metaObject()->className() : objectName.constData());
++    qt_set_thread_name(HANDLE(-1), thr->d_func()->objectName.isEmpty()
++                        ? thr->metaObject()->className()
++                        : std::exchange(thr->d_func()->objectName, {}).toLocal8Bit().constData());
+ #endif
+ 
+     emit thr->started(QThread::QPrivateSignal());
+@@ -503,6 +502,7 @@ void QThread::start(Priority priority)
+     if (d->running)
+         return;
+ 
++    d->objectName = objectName();
+     d->running = true;
+     d->finished = false;
+     d->exited = false;
+@@ -548,7 +548,7 @@ void QThread::start(Priority priority)
+ 
+     int prio;
+     d->priority = priority;
+-    switch (d->priority) {
++    switch (priority) {
+     case IdlePriority:
+         prio = THREAD_PRIORITY_IDLE;
+         break;
+@@ -686,7 +686,7 @@ void QThreadPrivate::setPriority(QThread::Priority threadPriority)
+ 
+     int prio;
+     priority = threadPriority;
+-    switch (priority) {
++    switch (threadPriority) {
+     case QThread::IdlePriority:
+         prio = THREAD_PRIORITY_IDLE;
+         break;
+diff --git a/qtbase/src/corelib/thread/qtsan_impl.h b/qtbase/src/corelib/thread/qtsan_impl.h
+new file mode 100644
+index 0000000000..580a738b91
+--- /dev/null
++++ b/qtbase/src/corelib/thread/qtsan_impl.h
+@@ -0,0 +1,115 @@
++/****************************************************************************
++**
++** Copyright (C) 2017 Intel Corporation.
++** Copyright (C) 2022 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
++** 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 QTSAN_IMPL_H
++#define QTSAN_IMPL_H
++
++#include <QtCore/qglobal.h>
++
++#if (__has_feature(thread_sanitizer) || defined(__SANITIZE_THREAD__)) && __has_include(<sanitizer/tsan_interface.h>)
++#  define QT_BUILDING_UNDER_TSAN
++#  include <sanitizer/tsan_interface.h>
++#endif
++
++QT_BEGIN_NAMESPACE
++
++namespace QtTsan {
++#ifdef QT_BUILDING_UNDER_TSAN
++inline void futexAcquire(void *addr, void *addr2 = nullptr)
++{
++    // A futex call ensures total ordering on the futex words
++    // (in either success or failure of the call). Instruct TSAN accordingly,
++    // as TSAN does not understand the futex(2) syscall (or equivalent).
++    ::__tsan_acquire(addr);
++    if (addr2)
++        ::__tsan_acquire(addr2);
++}
++
++inline void futexRelease(void *addr, void *addr2 = nullptr)
++{
++    if (addr2)
++        ::__tsan_release(addr2);
++    ::__tsan_release(addr);
++}
++
++inline void mutexPreLock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_pre_lock(addr, flags);
++}
++
++inline void mutexPostLock(void *addr, unsigned flags, int recursion)
++{
++    ::__tsan_mutex_post_lock(addr, flags, recursion);
++}
++
++inline void mutexPreUnlock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_pre_unlock(addr, flags);
++}
++
++inline void mutexPostUnlock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_post_unlock(addr, flags);
++}
++
++enum : unsigned {
++    MutexWriteReentrant = ::__tsan_mutex_write_reentrant,
++    TryLock = ::__tsan_mutex_try_lock,
++    TryLockFailed = ::__tsan_mutex_try_lock_failed,
++};
++#else
++inline void futexAcquire(void *, void * = nullptr) {}
++inline void futexRelease(void *, void * = nullptr) {}
++
++enum : unsigned {
++    MutexWriteReentrant,
++    TryLock,
++    TryLockFailed,
++};
++inline void mutexPreLock(void *, unsigned) {}
++inline void mutexPostLock(void *, unsigned, int) {}
++inline void mutexPreUnlock(void *, unsigned) {}
++inline void mutexPostUnlock(void *, unsigned) {}
++#endif // QT_BUILDING_UNDER_TSAN
++} // namespace QtTsan
++
++QT_END_NAMESPACE
++
++#endif // QTSAN_IMPL_H
+diff --git a/qtbase/src/corelib/thread/qwaitcondition_unix.cpp b/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
+index 88b058f410..0f1da4dc9b 100644
+--- a/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
++++ b/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
+@@ -213,7 +213,7 @@ bool QWaitCondition::wait(QMutex *mutex, QDeadlineTimer deadline)
+ {
+     if (! mutex)
+         return false;
+-    if (mutex->isRecursive()) {
++    if (static_cast<QBasicMutex *>(mutex)->isRecursive()) {
+         qWarning("QWaitCondition: cannot wait on recursive mutexes");
+         return false;
+     }
+diff --git a/qtbase/src/corelib/time/qdatetime.cpp b/qtbase/src/corelib/time/qdatetime.cpp
+index ec12569e3f..2c0b098079 100644
+--- a/qtbase/src/corelib/time/qdatetime.cpp
++++ b/qtbase/src/corelib/time/qdatetime.cpp
+@@ -43,6 +43,7 @@
+ #if QT_CONFIG(datetimeparser)
+ #include "private/qdatetimeparser_p.h"
+ #endif
++#include <private/qnumeric_p.h>
+ 
+ #include "qdatastream.h"
+ #include "qset.h"
+@@ -1429,9 +1430,11 @@ QDate QDate::addDays(qint64 ndays) const
+     if (isNull())
+         return QDate();
+ 
+-    // Due to limits on minJd() and maxJd() we know that any overflow
+-    // will be invalid and caught by fromJulianDay().
+-    return fromJulianDay(jd + ndays);
++    qint64 r;
++    if (Q_UNLIKELY(add_overflow(jd, ndays, &r)))
++        return QDate();
++    else
++        return fromJulianDay(r);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/corelib/time/qtimezone.cpp b/qtbase/src/corelib/time/qtimezone.cpp
+index 0309e43e52..3d451696a1 100644
+--- a/qtbase/src/corelib/time/qtimezone.cpp
++++ b/qtbase/src/corelib/time/qtimezone.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2013 John Layt <jlayt@kde.org>
++** Copyright (C) 2020 John Layt <jlayt@kde.org>
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtCore module of the Qt Toolkit.
+@@ -975,9 +975,15 @@ QList<QByteArray> QTimeZone::windowsIdToIanaIds(const QByteArray &windowsId,
+ }
+ 
+ #ifndef QT_NO_DATASTREAM
++// Invalid, as an IANA ID: too long, starts with - and has other invalid characters in it
++static inline QString invalidId() { return QStringLiteral("-No Time Zone Specified!"); }
++
+ QDataStream &operator<<(QDataStream &ds, const QTimeZone &tz)
+ {
+-    tz.d->serialize(ds);
++    if (tz.isValid())
++        tz.d->serialize(ds);
++    else
++        ds << invalidId();
+     return ds;
+ }
+ 
+@@ -985,7 +991,9 @@ QDataStream &operator>>(QDataStream &ds, QTimeZone &tz)
+ {
+     QString ianaId;
+     ds >> ianaId;
+-    if (ianaId == QLatin1String("OffsetFromUtc")) {
++    if (ianaId == invalidId()) {
++        tz = QTimeZone();
++    } else if (ianaId == QLatin1String("OffsetFromUtc")) {
+         int utcOffset;
+         QString name;
+         QString abbreviation;
+diff --git a/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp b/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
+index b1611d7ddb..a7a6a72ccf 100644
+--- a/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
++++ b/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
+@@ -42,6 +42,7 @@
+ #include "qtimezone.h"
+ #include "qtimezoneprivate_p.h"
+ #include "private/qlocale_tools_p.h"
++#include "private/qlocking_p.h"
+ 
+ #include <QtCore/QDataStream>
+ #include <QtCore/QDateTime>
+@@ -62,6 +63,10 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++#if QT_CONFIG(icu)
++static QBasicMutex s_icu_mutex;
++#endif
++
+ /*
+     Private
+ 
+@@ -670,6 +675,9 @@ QTzTimeZonePrivate::~QTzTimeZonePrivate()
+ 
+ QTzTimeZonePrivate *QTzTimeZonePrivate::clone() const
+ {
++#if QT_CONFIG(icu)
++    const auto lock = qt_scoped_lock(s_icu_mutex);
++#endif
+     return new QTzTimeZonePrivate(*this);
+ }
+ 
+@@ -913,12 +921,14 @@ QString QTzTimeZonePrivate::displayName(qint64 atMSecsSinceEpoch,
+                                         const QLocale &locale) const
+ {
+ #if QT_CONFIG(icu)
++    auto lock = qt_unique_lock(s_icu_mutex);
+     if (!m_icu)
+         m_icu = new QIcuTimeZonePrivate(m_id);
+     // TODO small risk may not match if tran times differ due to outdated files
+     // TODO Some valid TZ names are not valid ICU names, use translation table?
+     if (m_icu->isValid())
+         return m_icu->displayName(atMSecsSinceEpoch, nameType, locale);
++    lock.unlock();
+ #else
+     Q_UNUSED(nameType)
+     Q_UNUSED(locale)
+@@ -932,12 +942,14 @@ QString QTzTimeZonePrivate::displayName(QTimeZone::TimeType timeType,
+                                         const QLocale &locale) const
+ {
+ #if QT_CONFIG(icu)
++    auto lock = qt_unique_lock(s_icu_mutex);
+     if (!m_icu)
+         m_icu = new QIcuTimeZonePrivate(m_id);
+     // TODO small risk may not match if tran times differ due to outdated files
+     // TODO Some valid TZ names are not valid ICU names, use translation table?
+     if (m_icu->isValid())
+         return m_icu->displayName(timeType, nameType, locale);
++    lock.unlock();
+ #else
+     Q_UNUSED(timeType)
+     Q_UNUSED(nameType)
+diff --git a/qtbase/src/corelib/tools/qarraydata.h b/qtbase/src/corelib/tools/qarraydata.h
+index dcd95924c1..d01739e7e6 100644
+--- a/qtbase/src/corelib/tools/qarraydata.h
++++ b/qtbase/src/corelib/tools/qarraydata.h
+@@ -42,6 +42,7 @@
+ 
+ #include <QtCore/qrefcount.h>
+ #include <string.h>
++#include <cstdint>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -58,14 +59,14 @@ struct Q_CORE_EXPORT QArrayData
+     {
+         Q_ASSERT(size == 0
+                 || offset < 0 || size_t(offset) >= sizeof(QArrayData));
+-        return reinterpret_cast<char *>(this) + offset;
++        return reinterpret_cast<void *> (reinterpret_cast<uintptr_t>(this) + offset);
+     }
+ 
+     const void *data() const
+     {
+         Q_ASSERT(size == 0
+                 || offset < 0 || size_t(offset) >= sizeof(QArrayData));
+-        return reinterpret_cast<const char *>(this) + offset;
++        return reinterpret_cast<void *> (reinterpret_cast<uintptr_t>(this) + offset);
+     }
+ 
+     // This refers to array data mutability, not "header data" represented by
+diff --git a/qtbase/src/corelib/tools/qfreelist_p.h b/qtbase/src/corelib/tools/qfreelist_p.h
+index 5ba23b344b..9974102136 100644
+--- a/qtbase/src/corelib/tools/qfreelist_p.h
++++ b/qtbase/src/corelib/tools/qfreelist_p.h
+@@ -161,7 +161,7 @@ class QFreeList
+                 return i;
+             x -= size;
+         }
+-        Q_ASSERT(false);
++        Q_UNREACHABLE();
+         return -1;
+     }
+ 
+diff --git a/qtbase/src/corelib/tools/qversionnumber.h b/qtbase/src/corelib/tools/qversionnumber.h
+index d43b86ba51..2843f2b043 100644
+--- a/qtbase/src/corelib/tools/qversionnumber.h
++++ b/qtbase/src/corelib/tools/qversionnumber.h
+@@ -273,10 +273,10 @@ public:
+ 
+     Q_REQUIRED_RESULT Q_CORE_EXPORT QString toString() const;
+ #if QT_STRINGVIEW_LEVEL < 2
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(const QString &string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(const QString &string, int *suffixIndex = nullptr);
+ #endif
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QLatin1String string, int *suffixIndex = nullptr);
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QStringView string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(QLatin1String string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(QStringView string, int *suffixIndex = nullptr);
+ 
+ private:
+ #ifndef QT_NO_DATASTREAM
+diff --git a/qtbase/src/dbus/qdbusintegrator.cpp b/qtbase/src/dbus/qdbusintegrator.cpp
+index 5b66ce971b..28a3b0ffea 100644
+--- a/qtbase/src/dbus/qdbusintegrator.cpp
++++ b/qtbase/src/dbus/qdbusintegrator.cpp
+@@ -1135,7 +1135,13 @@ void QDBusConnectionPrivate::closeConnection()
+         }
+     }
+ 
+-    qDeleteAll(pendingCalls);
++    for (auto it = pendingCalls.begin(); it != pendingCalls.end(); ++it) {
++        auto call = *it;
++        if (!call->ref.deref()) {
++            delete call;
++        }
++    }
++    pendingCalls.clear();
+ 
+     // Disconnect all signals from signal hooks and from the object tree to
+     // avoid QObject::destroyed being sent to dbus daemon thread which has
+@@ -2584,6 +2590,11 @@ QDBusConnectionPrivate::findMetaObject(const QString &service, const QString &pa
+         if (mo)
+             return mo;
+     }
++    if (path.isEmpty()) {
++        error = QDBusError(QDBusError::InvalidObjectPath, QLatin1String("Object path cannot be empty"));
++        lastError = error;
++        return nullptr;
++    }
+ 
+     // introspect the target object
+     QDBusMessage msg = QDBusMessage::createMethodCall(service, path,
+diff --git a/qtbase/src/dbus/qdbusmetaobject.cpp b/qtbase/src/dbus/qdbusmetaobject.cpp
+index 5265568f42..7e9f0f1acc 100644
+--- a/qtbase/src/dbus/qdbusmetaobject.cpp
++++ b/qtbase/src/dbus/qdbusmetaobject.cpp
+@@ -210,6 +210,9 @@ QDBusMetaObjectGenerator::findType(const QByteArray &signature,
+         } else if (signature == "a{ss}") {
+             result.name = "QMap<QString,QString>";
+             type = qMetaTypeId<QMap<QString, QString> >();
++        } else if (signature == "aay") {
++            result.name = "QByteArrayList";
++            type = qMetaTypeId<QByteArrayList>();
+         } else {
+             result.name = "{D-Bus type \"" + signature + "\"}";
+             type = registerComplexDBusType(result.name);
+diff --git a/qtbase/src/gui/accessible/qaccessible.cpp b/qtbase/src/gui/accessible/qaccessible.cpp
+index d705bfccb5..0caf3c808c 100644
+--- a/qtbase/src/gui/accessible/qaccessible.cpp
++++ b/qtbase/src/gui/accessible/qaccessible.cpp
+@@ -54,6 +54,7 @@
+ #include <QtCore/qdebug.h>
+ #include <QtCore/qloggingcategory.h>
+ #include <QtCore/qmetaobject.h>
++#include <QtCore/private/qmetaobject_p.h>
+ #include <QtCore/qhash.h>
+ #include <private/qfactoryloader_p.h>
+ 
+@@ -681,6 +682,25 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
+     // Create a QAccessibleInterface for the object class. Start by the most
+     // derived class and walk up the class hierarchy.
+     const QMetaObject *mo = object->metaObject();
++    const auto *objectPriv = QObjectPrivate::get(object);
++    /*
++     We do not want to cache each and every QML metaobject (Button_QMLTYPE_124,
++     Button_QMLTYPE_125, etc.). Those dynamic metaobjects shouldn't have an
++     accessible interface in any case. Instead, we start the whole checking
++     with the first non-dynamic meta-object. To avoid potential regressions
++     in other areas of Qt that also use dynamic metaobjects, we only do this
++     for objects that are QML-related (approximated by checking whether they
++     have ddata set).
++    */
++    const bool qmlRelated = !objectPriv->isDeletingChildren &&
++                            objectPriv->declarativeData;
++    while (qmlRelated && mo) {
++        auto mop = QMetaObjectPrivate::get(mo);
++        if (!mop || !(mop->flags & DynamicMetaObject))
++            break;
++
++        mo = mo->superClass();
++    };
+     while (mo) {
+         const QString cn = QLatin1String(mo->className());
+ 
+@@ -696,14 +716,15 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
+         // Find a QAccessiblePlugin (factory) for the class name. If there's
+         // no entry in the cache try to create it using the plugin loader.
+         if (!qAccessiblePlugins()->contains(cn)) {
++            QAccessiblePlugin *factory = nullptr; // 0 means "no plugin found". This is cached as well.
+             const int index = loader()->indexOf(cn);
+-            if (index != -1) {
+-                QAccessiblePlugin *factory = qobject_cast<QAccessiblePlugin *>(loader()->instance(index));
+-                qAccessiblePlugins()->insert(cn, factory);
+-            }
++            if (index != -1)
++                factory = qobject_cast<QAccessiblePlugin *>(loader()->instance(index));
++            qAccessiblePlugins()->insert(cn, factory);
+         }
+ 
+         // At this point the cache should contain a valid factory pointer or 0:
++        Q_ASSERT(qAccessiblePlugins()->contains(cn));
+         QAccessiblePlugin *factory = qAccessiblePlugins()->value(cn);
+         if (factory) {
+             QAccessibleInterface *result = factory->create(cn, object);
+diff --git a/qtbase/src/gui/configure.json b/qtbase/src/gui/configure.json
+index 1f08795c57..12c95742d2 100644
+--- a/qtbase/src/gui/configure.json
++++ b/qtbase/src/gui/configure.json
+@@ -834,7 +834,8 @@
+                     "// embedded devices, are not intended to be used together with X. EGL support",
+                     "// has to be disabled in plugins like xcb in this case since the native display,",
+                     "// window and pixmap types will be different than what an X-based platform",
+-                    "// plugin would expect."
++                    "// plugin would expect.",
++                    "#define USE_X11"
+                 ],
+                 "include": [ "EGL/egl.h", "X11/Xlib.h" ],
+                 "main": [
+diff --git a/qtbase/src/gui/image/qbmphandler.cpp b/qtbase/src/gui/image/qbmphandler.cpp
+index 96f1e8cb1d..0e73bbbdb0 100644
+--- a/qtbase/src/gui/image/qbmphandler.cpp
++++ b/qtbase/src/gui/image/qbmphandler.cpp
+@@ -150,16 +150,42 @@ static QDataStream &operator<<(QDataStream &s, const BMP_INFOHDR &bi)
+     return s;
+ }
+ 
+-static int calc_shift(uint mask)
++static uint calc_shift(uint mask)
+ {
+-    int result = 0;
+-    while (mask && !(mask & 1)) {
++    uint result = 0;
++    while ((mask >= 0x100) || (!(mask & 1) && mask)) {
+         result++;
+         mask >>= 1;
+     }
+     return result;
+ }
+ 
++static uint calc_scale(uint low_mask)
++{
++    uint result = 8;
++    while (low_mask && result) {
++        result--;
++        low_mask >>= 1;
++    }
++    return result;
++}
++
++static inline uint apply_scale(uint value, uint scale)
++{
++    if (!(scale & 0x07)) // return immediately if scale == 8 or 0
++        return value;
++
++    uint filled = 8 - scale;
++    uint result = value << scale;
++
++    do {
++        result |= result >> filled;
++        filled <<= 1;
++    } while (filled < 8);
++
++    return result;
++}
++
+ static bool read_dib_fileheader(QDataStream &s, BMP_FILEHDR &bf)
+ {
+     // read BMP file header
+@@ -222,14 +248,14 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+     uint green_mask = 0;
+     uint blue_mask = 0;
+     uint alpha_mask = 0;
+-    int red_shift = 0;
+-    int green_shift = 0;
+-    int blue_shift = 0;
+-    int alpha_shift = 0;
+-    int red_scale = 0;
+-    int green_scale = 0;
+-    int blue_scale = 0;
+-    int alpha_scale = 0;
++    uint red_shift = 0;
++    uint green_shift = 0;
++    uint blue_shift = 0;
++    uint alpha_shift = 0;
++    uint red_scale = 0;
++    uint green_scale = 0;
++    uint blue_scale = 0;
++    uint alpha_scale = 0;
+ 
+     if (!d->isSequential())
+         d->seek(startpos + BMP_FILEHDR_SIZE + bi.biSize); // goto start of colormap or masks
+@@ -308,19 +334,19 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+         red_shift = calc_shift(red_mask);
+         if (((red_mask >> red_shift) + 1) == 0)
+             return false;
+-        red_scale = 256 / ((red_mask >> red_shift) + 1);
++        red_scale = calc_scale(red_mask >> red_shift);
+         green_shift = calc_shift(green_mask);
+         if (((green_mask >> green_shift) + 1) == 0)
+             return false;
+-        green_scale = 256 / ((green_mask >> green_shift) + 1);
++        green_scale = calc_scale(green_mask >> green_shift);
+         blue_shift = calc_shift(blue_mask);
+         if (((blue_mask >> blue_shift) + 1) == 0)
+             return false;
+-        blue_scale = 256 / ((blue_mask >> blue_shift) + 1);
++        blue_scale = calc_scale(blue_mask >> blue_shift);
+         alpha_shift = calc_shift(alpha_mask);
+         if (((alpha_mask >> alpha_shift) + 1) == 0)
+             return false;
+-        alpha_scale = 256 / ((alpha_mask >> alpha_shift) + 1);
++        alpha_scale = calc_scale(alpha_mask >> alpha_shift);
+     } else if (comp == BMP_RGB && (nbits == 24 || nbits == 32)) {
+         blue_mask = 0x000000ff;
+         green_mask = 0x0000ff00;
+@@ -328,17 +354,15 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+         blue_shift = 0;
+         green_shift = 8;
+         red_shift = 16;
+-        blue_scale = green_scale = red_scale = 1;
++        blue_scale = green_scale = red_scale = 0;
+     } else if (comp == BMP_RGB && nbits == 16) {
+         blue_mask = 0x001f;
+         green_mask = 0x03e0;
+         red_mask = 0x7c00;
+         blue_shift = 0;
+-        green_shift = 2;
+-        red_shift = 7;
+-        red_scale = 1;
+-        green_scale = 1;
+-        blue_scale = 8;
++        green_shift = 5;
++        red_shift = 10;
++        blue_scale = green_scale = red_scale = 3;
+     }
+ 
+ #if 0
+@@ -544,10 +568,10 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+                     c |= *(uchar*)(b+2)<<16;
+                 if (nbits > 24)
+                     c |= *(uchar*)(b+3)<<24;
+-                *p++ = qRgba(((c & red_mask) >> red_shift) * red_scale,
+-                                        ((c & green_mask) >> green_shift) * green_scale,
+-                                        ((c & blue_mask) >> blue_shift) * blue_scale,
+-                                        transp ? ((c & alpha_mask) >> alpha_shift) * alpha_scale : 0xff);
++                *p++ = qRgba(apply_scale((c & red_mask) >> red_shift, red_scale),
++                             apply_scale((c & green_mask) >> green_shift, green_scale),
++                             apply_scale((c & blue_mask) >> blue_shift, blue_scale),
++                             transp ? apply_scale((c & alpha_mask) >> alpha_shift, alpha_scale) : 0xff);
+                 b += nbits/8;
+             }
+         }
+diff --git a/qtbase/src/gui/image/qimage.cpp b/qtbase/src/gui/image/qimage.cpp
+index 7152ac1607..0df772564c 100644
+--- a/qtbase/src/gui/image/qimage.cpp
++++ b/qtbase/src/gui/image/qimage.cpp
+@@ -4694,6 +4694,8 @@ QImage QImage::smoothScaled(int w, int h) const {
+ static QImage rotated90(const QImage &image)
+ {
+     QImage out(image.height(), image.width(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+@@ -4722,6 +4724,8 @@ static QImage rotated180(const QImage &image)
+         return image.mirrored(true, true);
+ 
+     QImage out(image.width(), image.height(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+@@ -4734,6 +4738,8 @@ static QImage rotated180(const QImage &image)
+ static QImage rotated270(const QImage &image)
+ {
+     QImage out(image.height(), image.width(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+diff --git a/qtbase/src/gui/kernel/qcursor.cpp b/qtbase/src/gui/kernel/qcursor.cpp
+index d6ccaff8ed..455088241c 100644
+--- a/qtbase/src/gui/kernel/qcursor.cpp
++++ b/qtbase/src/gui/kernel/qcursor.cpp
+@@ -251,7 +251,8 @@ void QCursor::setPos(QScreen *screen, int x, int y)
+ {
+     if (screen) {
+         if (QPlatformCursor *cursor = screen->handle()->cursor()) {
+-            const QPoint devicePos = QHighDpi::toNativePixels(QPoint(x, y), screen);
++            const QPoint pos(x, y);
++            const QPoint devicePos = QHighDpi::toNativePixels(pos, screen->virtualSiblingAt(pos));
+             // Need to check, since some X servers generate null mouse move
+             // events, causing looping in applications which call setPos() on
+             // every mouse move event.
+diff --git a/qtbase/src/gui/kernel/qhighdpiscaling.cpp b/qtbase/src/gui/kernel/qhighdpiscaling.cpp
+index 9bbf2773a9..3ac4a4d8b6 100644
+--- a/qtbase/src/gui/kernel/qhighdpiscaling.cpp
++++ b/qtbase/src/gui/kernel/qhighdpiscaling.cpp
+@@ -580,9 +580,8 @@ void QHighDpiScaling::setScreenFactor(QScreen *screen, qreal factor)
+     else
+         qNamedScreenScaleFactors()->insert(name, factor);
+ 
+-    // hack to force re-evaluation of screen geometry
+     if (screen->handle())
+-        screen->d_func()->setPlatformScreen(screen->handle()); // updates geometries based on scale factor
++        screen->d_func()->updateLogicalDpi();
+ }
+ 
+ QPoint QHighDpiScaling::mapPositionToNative(const QPoint &pos, const QPlatformScreen *platformScreen)
+diff --git a/qtbase/src/gui/kernel/qkeysequence.cpp b/qtbase/src/gui/kernel/qkeysequence.cpp
+index a75b8ef920..4f2d294739 100644
+--- a/qtbase/src/gui/kernel/qkeysequence.cpp
++++ b/qtbase/src/gui/kernel/qkeysequence.cpp
+@@ -701,6 +701,10 @@ static const struct {
+     { Qt::Key_TouchpadToggle,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad Toggle") },
+     { Qt::Key_TouchpadOn,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad On") },
+     { Qt::Key_TouchpadOff,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad Off") },
++    { Qt::Key_Shift,  QT_TRANSLATE_NOOP("QShortcut", "Shift") },
++    { Qt::Key_Control,  QT_TRANSLATE_NOOP("QShortcut", "Control") },
++    { Qt::Key_Alt,  QT_TRANSLATE_NOOP("QShortcut", "Alt") },
++    { Qt::Key_Meta,  QT_TRANSLATE_NOOP("QShortcut", "Meta") },
+ 
+ };
+ static Q_CONSTEXPR int numKeyNames = sizeof keyname / sizeof *keyname;
+diff --git a/qtbase/src/gui/kernel/qplatformservices.cpp b/qtbase/src/gui/kernel/qplatformservices.cpp
+index fdc6a6c4aa..ac47f98c5d 100644
+--- a/qtbase/src/gui/kernel/qplatformservices.cpp
++++ b/qtbase/src/gui/kernel/qplatformservices.cpp
+@@ -55,6 +55,19 @@ QT_BEGIN_NAMESPACE
+     \brief The QPlatformServices provides the backend for desktop-related functionality.
+ */
+ 
++/*!
++    \enum QPlatformServices::Capability
++
++    Capabilities are used to determine a specific platform service's availability.
++
++    \value ColorPickingFromScreen The platform natively supports color picking from screen.
++    This capability indicates that the platform supports "opaque" color picking, where the
++    platform implements a complete user experience for color picking and outputs a color.
++    This is in contrast to the application implementing the color picking user experience
++    (taking care of showing a cross hair, instructing the platform integration to obtain
++    the color at a given pixel, etc.). The related service function is pickColor().
++ */
++
+ QPlatformServices::QPlatformServices()
+ { }
+ 
+@@ -85,5 +98,16 @@ QByteArray QPlatformServices::desktopEnvironment() const
+     return QByteArray("UNKNOWN");
+ }
+ 
++QPlatformServiceColorPicker *QPlatformServices::colorPicker(QWindow *parent)
++{
++    Q_UNUSED(parent);
++    return nullptr;
++}
++
++bool QPlatformServices::hasCapability(Capability capability) const
++{
++    Q_UNUSED(capability)
++    return false;
++}
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/gui/kernel/qplatformservices.h b/qtbase/src/gui/kernel/qplatformservices.h
+index 5de96cfa7d..a8b2a4ce71 100644
+--- a/qtbase/src/gui/kernel/qplatformservices.h
++++ b/qtbase/src/gui/kernel/qplatformservices.h
+@@ -50,16 +50,32 @@
+ //
+ 
+ #include <QtGui/qtguiglobal.h>
++#include <QtCore/qobject.h>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+ class QUrl;
++class QWindow;
++
++class Q_GUI_EXPORT QPlatformServiceColorPicker : public QObject
++{
++    Q_OBJECT
++public:
++    using QObject::QObject;
++    virtual void pickColor() = 0;
++Q_SIGNALS:
++    void colorPicked(const QColor &color);
++};
+ 
+ class Q_GUI_EXPORT QPlatformServices
+ {
+ public:
+     Q_DISABLE_COPY_MOVE(QPlatformServices)
+ 
++    enum Capability {
++        ColorPicking,
++    };
++
+     QPlatformServices();
+     virtual ~QPlatformServices() { }
+ 
+@@ -67,6 +83,10 @@ public:
+     virtual bool openDocument(const QUrl &url);
+ 
+     virtual QByteArray desktopEnvironment() const;
++
++    virtual bool hasCapability(Capability capability) const;
++
++    virtual QPlatformServiceColorPicker *colorPicker(QWindow *parent = nullptr);
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/gui/kernel/qplatformtheme.cpp b/qtbase/src/gui/kernel/qplatformtheme.cpp
+index 71521c0339..2325873245 100644
+--- a/qtbase/src/gui/kernel/qplatformtheme.cpp
++++ b/qtbase/src/gui/kernel/qplatformtheme.cpp
+@@ -163,6 +163,8 @@ QT_BEGIN_NAMESPACE
+ 
+     \value ShowShortcutsInContextMenus (bool) Whether to display shortcut key sequences in context menus.
+ 
++    \value ButtonPressKeys (QList<Qt::Key>) A list of keys that can be used to press buttons via keyboard input.
++
+     \sa themeHint(), QStyle::pixelMetric()
+ */
+ 
+@@ -563,6 +565,8 @@ QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint)
+         }
+     case MouseQuickSelectionThreshold:
+         return QVariant(10);
++    case ButtonPressKeys:
++        return QVariant::fromValue(QList<Qt::Key>({ Qt::Key_Space, Qt::Key_Select }));
+     }
+     return QVariant();
+ }
+diff --git a/qtbase/src/gui/kernel/qplatformtheme.h b/qtbase/src/gui/kernel/qplatformtheme.h
+index 3185fc4541..7e6c9d5740 100644
+--- a/qtbase/src/gui/kernel/qplatformtheme.h
++++ b/qtbase/src/gui/kernel/qplatformtheme.h
+@@ -120,7 +120,8 @@ public:
+         TouchDoubleTapDistance,
+         ShowShortcutsInContextMenus,
+         IconFallbackSearchPaths,
+-        MouseQuickSelectionThreshold
++        MouseQuickSelectionThreshold,
++        ButtonPressKeys
+     };
+ 
+     enum DialogType {
+diff --git a/qtbase/src/gui/kernel/qscreen.cpp b/qtbase/src/gui/kernel/qscreen.cpp
+index 8e0eb35116..5d172a58dd 100644
+--- a/qtbase/src/gui/kernel/qscreen.cpp
++++ b/qtbase/src/gui/kernel/qscreen.cpp
+@@ -77,6 +77,12 @@ QScreen::QScreen(QPlatformScreen *screen)
+     d->setPlatformScreen(screen);
+ }
+ 
++void QScreenPrivate::updateLogicalDpi()
++{
++    logicalDpi = QPlatformScreen::overrideDpi(platformScreen->logicalDpi());
++    updateGeometriesWithSignals(); // updates geometries based on scale factor
++}
++
+ void QScreenPrivate::updateGeometriesWithSignals()
+ {
+     const QRect oldGeometry = geometry;
+diff --git a/qtbase/src/gui/kernel/qscreen_p.h b/qtbase/src/gui/kernel/qscreen_p.h
+index 7da542c25e..e50fc3190b 100644
+--- a/qtbase/src/gui/kernel/qscreen_p.h
++++ b/qtbase/src/gui/kernel/qscreen_p.h
+@@ -70,6 +70,7 @@ public:
+         geometry = platformScreen->deviceIndependentGeometry();
+         availableGeometry = QHighDpi::fromNative(platformScreen->availableGeometry(), QHighDpiScaling::factor(platformScreen), geometry.topLeft());
+     }
++    void updateLogicalDpi();
+ 
+     void updatePrimaryOrientation();
+     void updateGeometriesWithSignals();
+diff --git a/qtbase/src/gui/painting/qblendfunctions_p.h b/qtbase/src/gui/painting/qblendfunctions_p.h
+index 080da98ec4..6997d62b3c 100644
+--- a/qtbase/src/gui/painting/qblendfunctions_p.h
++++ b/qtbase/src/gui/painting/qblendfunctions_p.h
+@@ -246,25 +246,32 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+                                   int dudx, int dvdx, int dudy, int dvdy, int u0, int v0,
+                                   Blender blender)
+ {
+-    int fromY = qMax(qRound(topY), clip.top());
+-    int toY = qMin(qRound(bottomY), clip.top() + clip.height());
++    qint64 fromY = qMax(qRound(topY), clip.top());
++    qint64 toY = qMin(qRound(bottomY), clip.top() + clip.height());
+     if (fromY >= toY)
+         return;
+ 
+     qreal leftSlope = (bottomLeft.x - topLeft.x) / (bottomLeft.y - topLeft.y);
+     qreal rightSlope = (bottomRight.x - topRight.x) / (bottomRight.y - topRight.y);
+-    int dx_l = int(leftSlope * 0x10000);
+-    int dx_r = int(rightSlope * 0x10000);
+-    int x_l = int((topLeft.x + (qreal(0.5) + fromY - topLeft.y) * leftSlope + qreal(0.5)) * 0x10000);
+-    int x_r = int((topRight.x + (qreal(0.5) + fromY - topRight.y) * rightSlope + qreal(0.5)) * 0x10000);
+-
+-    int fromX, toX, x1, x2, u, v, i, ii;
++    qint64 dx_l = qint64(leftSlope * 0x10000);
++    qint64 dx_r = qint64(rightSlope * 0x10000);
++    qint64 x_l = qint64((topLeft.x + (qreal(0.5) + fromY - topLeft.y) * leftSlope + qreal(0.5)) * 0x10000);
++    qint64 x_r = qint64((topRight.x + (qreal(0.5) + fromY - topRight.y) * rightSlope + qreal(0.5)) * 0x10000);
++
++    qint64 sourceRectTop = qint64(sourceRect.top());
++    qint64 sourceRectLeft = qint64(sourceRect.left());
++    qint64 sourceRectWidth = qint64(sourceRect.width());
++    qint64 sourceRectHeight = qint64(sourceRect.height());
++    qint64 clipLeft = qint64(clip.left());
++    qint64 clipWidth = qint64(clip.width());
++
++    qint64 fromX, toX, x1, x2, u, v, i, ii;
+     DestT *line;
+-    for (int y = fromY; y < toY; ++y) {
++    for (qint64 y = fromY; y < toY; ++y) {
+         line = reinterpret_cast<DestT *>(reinterpret_cast<uchar *>(destPixels) + y * dbpl);
+ 
+-        fromX = qMax(x_l >> 16, clip.left());
+-        toX = qMin(x_r >> 16, clip.left() + clip.width());
++        fromX = qMax(x_l >> 16, clipLeft);
++        toX = qMin(x_r >> 16, clipLeft + clipWidth);
+         if (fromX < toX) {
+             // Because of rounding, we can get source coordinates outside the source image.
+             // Clamp these coordinates to the source rect to avoid segmentation fault and
+@@ -275,10 +282,10 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             u = x1 * dudx + y * dudy + u0;
+             v = x1 * dvdx + y * dvdy + v0;
+             for (; x1 < toX; ++x1) {
+-                int uu = u >> 16;
+-                int vv = v >> 16;
+-                if (uu >= sourceRect.left() && uu < sourceRect.left() + sourceRect.width()
+-                    && vv >= sourceRect.top() && vv < sourceRect.top() + sourceRect.height()) {
++                qint64 uu = u >> 16;
++                qint64 vv = v >> 16;
++                if (uu >= sourceRectLeft && uu < sourceRectLeft + sourceRectWidth
++                    && vv >= sourceRectTop && vv < sourceRectTop + sourceRectHeight) {
+                     break;
+                 }
+                 u += dudx;
+@@ -290,10 +297,10 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             u = (x2 - 1) * dudx + y * dudy + u0;
+             v = (x2 - 1) * dvdx + y * dvdy + v0;
+             for (; x2 > x1; --x2) {
+-                int uu = u >> 16;
+-                int vv = v >> 16;
+-                if (uu >= sourceRect.left() && uu < sourceRect.left() + sourceRect.width()
+-                    && vv >= sourceRect.top() && vv < sourceRect.top() + sourceRect.height()) {
++                qint64 uu = u >> 16;
++                qint64 vv = v >> 16;
++                if (uu >= sourceRectLeft && uu < sourceRectLeft + sourceRectWidth
++                    && vv >= sourceRectTop && vv < sourceRectTop + sourceRectHeight) {
+                     break;
+                 }
+                 u -= dudx;
+@@ -308,8 +315,8 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             // Beginning of the scan line, with per-pixel checks.
+             i = x1 - fromX;
+             while (i) {
+-                int uu = qBound(sourceRect.left(), u >> 16, sourceRect.left() + sourceRect.width() - 1);
+-                int vv = qBound(sourceRect.top(), v >> 16, sourceRect.top() + sourceRect.height() - 1);
++                qint64 uu = qBound(sourceRectLeft, u >> 16, sourceRectLeft + sourceRectWidth - 1);
++                qint64 vv = qBound(sourceRectTop, v >> 16, sourceRectTop + sourceRectHeight - 1);
+                 blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + vv * sbpl)[uu]);
+                 u += dudx;
+                 v += dvdx;
+@@ -348,8 +355,8 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             // End of the scan line, with per-pixel checks.
+             i = toX - x2;
+             while (i) {
+-                int uu = qBound(sourceRect.left(), u >> 16, sourceRect.left() + sourceRect.width() - 1);
+-                int vv = qBound(sourceRect.top(), v >> 16, sourceRect.top() + sourceRect.height() - 1);
++                qint64 uu = qBound(sourceRectLeft, u >> 16, sourceRectLeft + sourceRectWidth - 1);
++                qint64 vv = qBound(sourceRectTop, v >> 16, sourceRectTop + sourceRectHeight - 1);
+                 blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + vv * sbpl)[uu]);
+                 u += dudx;
+                 v += dvdx;
+diff --git a/qtbase/src/gui/painting/qcolortrclut_p.h b/qtbase/src/gui/painting/qcolortrclut_p.h
+index 76a6a60803..24fd522e6c 100644
+--- a/qtbase/src/gui/painting/qcolortrclut_p.h
++++ b/qtbase/src/gui/painting/qcolortrclut_p.h
+@@ -118,6 +118,7 @@ public:
+         return QRgba64::fromRgba64(r, g, b, qAlpha(rgb32) * 257);
+ #endif
+     }
++    QRgba64 toLinear64(QRgba64) const = delete;
+ 
+     QRgb toLinear(QRgb rgb32) const
+     {
+diff --git a/qtbase/src/gui/painting/qdrawhelper.cpp b/qtbase/src/gui/painting/qdrawhelper.cpp
+index a61793508a..5ba2d277b7 100644
+--- a/qtbase/src/gui/painting/qdrawhelper.cpp
++++ b/qtbase/src/gui/painting/qdrawhelper.cpp
+@@ -6091,7 +6091,7 @@ static inline void alphargbblend_argb32(quint32 *dst, uint coverage, const QRgba
+ static inline void rgbBlendPixel(QRgba64 &dst, int coverage, QRgba64 slinear, const QColorTrcLut *colorProfile)
+ {
+     // Do a gammacorrected RGB alphablend...
+-    const QRgba64 dlinear = colorProfile ? colorProfile->toLinear64(dst) : dst;
++    const QRgba64 dlinear = colorProfile ? colorProfile->toLinear(dst) : dst;
+ 
+     QRgba64 blend = rgbBlend(dlinear, slinear, coverage);
+ 
+diff --git a/qtbase/src/gui/painting/qpaintengine_raster.cpp b/qtbase/src/gui/painting/qpaintengine_raster.cpp
+index 283923de52..f08eb9cbee 100644
+--- a/qtbase/src/gui/painting/qpaintengine_raster.cpp
++++ b/qtbase/src/gui/painting/qpaintengine_raster.cpp
+@@ -560,31 +560,6 @@ void QRasterPaintEngine::updateMatrix(const QTransform &matrix)
+     QRasterPaintEngineState *s = state();
+     // FALCON: get rid of this line, see drawImage call below.
+     s->matrix = matrix;
+-    QTransform::TransformationType txop = s->matrix.type();
+-
+-    switch (txop) {
+-
+-    case QTransform::TxNone:
+-        s->flags.int_xform = true;
+-        break;
+-
+-    case QTransform::TxTranslate:
+-        s->flags.int_xform = qreal(int(s->matrix.dx())) == s->matrix.dx()
+-                            && qreal(int(s->matrix.dy())) == s->matrix.dy();
+-        break;
+-
+-    case QTransform::TxScale:
+-        s->flags.int_xform = qreal(int(s->matrix.dx())) == s->matrix.dx()
+-                            && qreal(int(s->matrix.dy())) == s->matrix.dy()
+-                            && qreal(int(s->matrix.m11())) == s->matrix.m11()
+-                            && qreal(int(s->matrix.m22())) == s->matrix.m22();
+-        break;
+-
+-    default: // shear / perspective...
+-        s->flags.int_xform = false;
+-        break;
+-    }
+-
+     s->flags.tx_noshear = qt_scaleForTransform(s->matrix, &s->txscale);
+ 
+     ensureOutlineMapper();
+@@ -617,7 +592,6 @@ QRasterPaintEngineState::QRasterPaintEngineState()
+     flags.bilinear = false;
+     flags.legacy_rounding = false;
+     flags.fast_text = true;
+-    flags.int_xform = true;
+     flags.tx_noshear = true;
+     flags.fast_images = true;
+ 
+@@ -1793,7 +1767,7 @@ void QRasterPaintEngine::fill(const QVectorPath &path, const QBrush &brush)
+     QRectF cpRect = path.controlPointRect();
+     const QRectF pathDeviceRect = s->matrix.mapRect(cpRect);
+     // Skip paths that by conservative estimates are completely outside the paint device.
+-    if (!pathDeviceRect.intersects(QRectF(d->deviceRect)))
++    if (!pathDeviceRect.intersects(QRectF(d->deviceRect)) || !pathDeviceRect.isValid())
+         return;
+ 
+     ProcessSpans blend = d->getBrushFunc(pathDeviceRect, &s->brushData);
+diff --git a/qtbase/src/gui/painting/qpaintengine_raster_p.h b/qtbase/src/gui/painting/qpaintengine_raster_p.h
+index 089aadc3f7..bf7363d5aa 100644
+--- a/qtbase/src/gui/painting/qpaintengine_raster_p.h
++++ b/qtbase/src/gui/painting/qpaintengine_raster_p.h
+@@ -111,7 +111,6 @@ public:
+         uint bilinear : 1;
+         uint legacy_rounding : 1;
+         uint fast_text : 1;
+-        uint int_xform : 1;
+         uint tx_noshear : 1;
+         uint fast_images : 1;
+     };
+diff --git a/qtbase/src/gui/painting/qpainterpath.cpp b/qtbase/src/gui/painting/qpainterpath.cpp
+index f9544a3241..d80fafeaf1 100644
+--- a/qtbase/src/gui/painting/qpainterpath.cpp
++++ b/qtbase/src/gui/painting/qpainterpath.cpp
+@@ -1253,7 +1253,7 @@ void QPainterPath::addText(const QPointF &point, const QFont &f, const QString &
+ 
+         if (si.analysis.flags < QScriptAnalysis::TabOrObject) {
+             QGlyphLayout glyphs = eng->shapedGlyphs(&si);
+-            QFontEngine *fe = f.d->engineForScript(si.analysis.script);
++            QFontEngine *fe = eng->fontEngine(si);
+             Q_ASSERT(fe);
+             fe->addOutlineToPath(x, y, glyphs, this,
+                                  si.analysis.bidiLevel % 2
+diff --git a/qtbase/src/gui/painting/qpathclipper_p.h b/qtbase/src/gui/painting/qpathclipper_p.h
+index 9444a87b71..18f64c5e8c 100644
+--- a/qtbase/src/gui/painting/qpathclipper_p.h
++++ b/qtbase/src/gui/painting/qpathclipper_p.h
+@@ -156,7 +156,7 @@ public:
+     int vertex(Direction direction) const;
+ 
+ private:
+-    int m_next[2][2];
++    int m_next[2][2] = { { -1, -1 }, { -1, -1 } };
+ };
+ 
+ class QPathSegments
+@@ -296,10 +296,6 @@ inline QPathEdge::QPathEdge(int a, int b)
+     , angle(0)
+     , invAngle(0)
+ {
+-    m_next[0][0] = -1;
+-    m_next[1][0] = -1;
+-    m_next[0][0] = -1;
+-    m_next[1][0] = -1;
+ }
+ 
+ inline int QPathEdge::next(Traversal traversal, Direction direction) const
+diff --git a/qtbase/src/gui/painting/qpdf.cpp b/qtbase/src/gui/painting/qpdf.cpp
+index 3066744f1b..2c8d3c3b53 100644
+--- a/qtbase/src/gui/painting/qpdf.cpp
++++ b/qtbase/src/gui/painting/qpdf.cpp
+@@ -2760,6 +2760,8 @@ int QPdfEnginePrivate::addBrushPattern(const QTransform &m, bool *specifyColor,
+         return gradientBrush(brush, matrix, gStateObject);
+     }
+ 
++    matrix = brush.transform() * matrix;
++
+     if ((!brush.isOpaque() && brush.style() < Qt::LinearGradientPattern) || opacity != 1.0)
+         *gStateObject = addConstantAlphaObject(qRound(brush.color().alpha() * opacity),
+                                                qRound(pen.color().alpha() * opacity));
+diff --git a/qtbase/src/gui/painting/qstroker.cpp b/qtbase/src/gui/painting/qstroker.cpp
+index cb5d395e80..3b6357a893 100644
+--- a/qtbase/src/gui/painting/qstroker.cpp
++++ b/qtbase/src/gui/painting/qstroker.cpp
+@@ -1182,6 +1182,7 @@ void QDashStroker::processCurrentSubpath()
+         // Check if the entire line should be clipped away or simplified
+         bool clipIt = clipping && !lineIntersectsRect(prev, e, clip_tl, clip_br);
+         bool skipDashing = elen * invSumLength > repetitionLimit();
++        int maxDashes = dashCount;
+         if (skipDashing || clipIt) {
+             // Cut away full dash sequences.
+             elen -= std::floor(elen * invSumLength) * sumLength;
+@@ -1196,7 +1197,7 @@ void QDashStroker::processCurrentSubpath()
+                     pos = estop; // move pos to next path element
+                     done = true;
+                 } else { // Dash is on this line
+-                    pos = dpos + estart;
++                    pos = --maxDashes > 0 ? dpos + estart : estop;
+                     done = pos >= estop;
+                     if (++idash >= dashCount)
+                         idash = 0;
+diff --git a/qtbase/src/gui/painting/qt_attribution.json b/qtbase/src/gui/painting/qt_attribution.json
+index 7b16e8c211..0e87d30aa2 100644
+--- a/qtbase/src/gui/painting/qt_attribution.json
++++ b/qtbase/src/gui/painting/qt_attribution.json
+@@ -10,7 +10,7 @@
+         "Homepage": "http://www.freetype.org",
+         "License": "Freetype Project License or GNU General Public License v2.0 only",
+         "LicenseId": "FTL or GPL-2.0",
+-        "LicenseFile": "../../3rdparty/freetype/docs/LICENSE.TXT",
++        "LicenseFile": "../../3rdparty/freetype/LICENSE.TXT",
+         "Copyright": "Copyright 2000-2016 by David Turner, Robert Wilhelm, and Werner Lemberg."
+     },
+     {
+diff --git a/qtbase/src/gui/rhi/qshader_p_p.h b/qtbase/src/gui/rhi/qshader_p_p.h
+index ec9d25971f..4a5a7a6d51 100644
+--- a/qtbase/src/gui/rhi/qshader_p_p.h
++++ b/qtbase/src/gui/rhi/qshader_p_p.h
+@@ -68,13 +68,13 @@ struct Q_GUI_EXPORT QShaderPrivate
+     {
+     }
+ 
+-    QShaderPrivate(const QShaderPrivate *other)
++    QShaderPrivate(const QShaderPrivate &other)
+         : ref(1),
+-          qsbVersion(other->qsbVersion),
+-          stage(other->stage),
+-          desc(other->desc),
+-          shaders(other->shaders),
+-          bindings(other->bindings)
++          qsbVersion(other.qsbVersion),
++          stage(other.stage),
++          desc(other.desc),
++          shaders(other.shaders),
++          bindings(other.bindings)
+     {
+     }
+ 
+diff --git a/qtbase/src/gui/rhi/qshaderdescription_p_p.h b/qtbase/src/gui/rhi/qshaderdescription_p_p.h
+index ec2b0b6b4c..3da33a8a2b 100644
+--- a/qtbase/src/gui/rhi/qshaderdescription_p_p.h
++++ b/qtbase/src/gui/rhi/qshaderdescription_p_p.h
+@@ -63,16 +63,16 @@ struct Q_GUI_EXPORT QShaderDescriptionPrivate
+         localSize[0] = localSize[1] = localSize[2] = 0;
+     }
+ 
+-    QShaderDescriptionPrivate(const QShaderDescriptionPrivate *other)
++    QShaderDescriptionPrivate(const QShaderDescriptionPrivate &other)
+         : ref(1),
+-          inVars(other->inVars),
+-          outVars(other->outVars),
+-          uniformBlocks(other->uniformBlocks),
+-          pushConstantBlocks(other->pushConstantBlocks),
+-          storageBlocks(other->storageBlocks),
+-          combinedImageSamplers(other->combinedImageSamplers),
+-          storageImages(other->storageImages),
+-          localSize(other->localSize)
++          inVars(other.inVars),
++          outVars(other.outVars),
++          uniformBlocks(other.uniformBlocks),
++          pushConstantBlocks(other.pushConstantBlocks),
++          storageBlocks(other.storageBlocks),
++          combinedImageSamplers(other.combinedImageSamplers),
++          storageImages(other.storageImages),
++          localSize(other.localSize)
+     {
+     }
+ 
+diff --git a/qtbase/src/gui/text/qfontdatabase.cpp b/qtbase/src/gui/text/qfontdatabase.cpp
+index a657a8c516..4fc0100958 100644
+--- a/qtbase/src/gui/text/qfontdatabase.cpp
++++ b/qtbase/src/gui/text/qfontdatabase.cpp
+@@ -983,7 +983,7 @@ QFontEngine *loadSingleEngine(int script,
+         if (style->key.stretch != 0 && request.stretch != 0
+             && (request.styleName.isEmpty() || request.styleName != style->styleName)) {
+             def.stretch = (request.stretch * 100 + style->key.stretch / 2) / style->key.stretch;
+-        } else {
++        } else if (request.stretch == QFont::AnyStretch) {
+             def.stretch = 100;
+         }
+ 
+diff --git a/qtbase/src/gui/text/qtextdocumentlayout.cpp b/qtbase/src/gui/text/qtextdocumentlayout.cpp
+index f3e6ea2100..72267e9380 100644
+--- a/qtbase/src/gui/text/qtextdocumentlayout.cpp
++++ b/qtbase/src/gui/text/qtextdocumentlayout.cpp
+@@ -2123,7 +2123,7 @@ void QTextDocumentLayoutPrivate::drawListItem(const QPointF &offset, QPainter *p
+ {
+     Q_Q(const QTextDocumentLayout);
+     const QTextBlockFormat blockFormat = bl.blockFormat();
+-    const QTextCharFormat charFormat = QTextCursor(bl).charFormat();
++    const QTextCharFormat charFormat = bl.charFormat();
+     QFont font(charFormat.font());
+     if (q->paintDevice())
+         font = QFont(font, q->paintDevice());
+diff --git a/qtbase/src/gui/text/qtextengine.cpp b/qtbase/src/gui/text/qtextengine.cpp
+index ce4abac472..a6c66e5d2d 100644
+--- a/qtbase/src/gui/text/qtextengine.cpp
++++ b/qtbase/src/gui/text/qtextengine.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2021 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtGui module of the Qt Toolkit.
+@@ -1565,6 +1565,12 @@ void QTextEngine::shapeText(int item) const
+         // Overwrite with 0 token to indicate failure
+         QGlyphLayout g = availableGlyphs(&si);
+         g.glyphs[0] = 0;
++        g.attributes[0].clusterStart = true;
++
++        ushort *log_clusters = logClusters(&si);
++        for (int i = 0; i < itemLength; ++i)
++            log_clusters[i] = 0;
++
+         return;
+     }
+ 
+diff --git a/qtbase/src/gui/util/qdesktopservices.cpp b/qtbase/src/gui/util/qdesktopservices.cpp
+index fbb63a9408..4d5fafaaa7 100644
+--- a/qtbase/src/gui/util/qdesktopservices.cpp
++++ b/qtbase/src/gui/util/qdesktopservices.cpp
+@@ -54,6 +54,8 @@
+ #include <qpa/qplatformintegration.h>
+ #include <qdir.h>
+ 
++#include <QtCore/private/qlocking_p.h>
++
+ QT_BEGIN_NAMESPACE
+ 
+ class QOpenUrlHandlerRegistry : public QObject
+@@ -81,6 +83,7 @@ Q_GLOBAL_STATIC(QOpenUrlHandlerRegistry, handlerRegistry)
+ 
+ void QOpenUrlHandlerRegistry::handlerDestroyed(QObject *handler)
+ {
++    const auto lock = qt_scoped_lock(mutex);
+     HandlerHash::Iterator it = handlers.begin();
+     while (it != handlers.end()) {
+         if (it->receiver == handler) {
+@@ -294,7 +297,8 @@ void QDesktopServices::setUrlHandler(const QString &scheme, QObject *receiver, c
+     h.name = method;
+     registry->handlers.insert(scheme.toLower(), h);
+     QObject::connect(receiver, SIGNAL(destroyed(QObject*)),
+-                     registry, SLOT(handlerDestroyed(QObject*)));
++                     registry, SLOT(handlerDestroyed(QObject*)),
++                     Qt::DirectConnection);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/gui/util/qpkmhandler.cpp b/qtbase/src/gui/util/qpkmhandler.cpp
+index e0c3b75efe..3414f9d8ba 100644
+--- a/qtbase/src/gui/util/qpkmhandler.cpp
++++ b/qtbase/src/gui/util/qpkmhandler.cpp
+@@ -57,7 +57,7 @@ struct PkmType
+     quint32 bytesPerBlock;
+ };
+ 
+-static PkmType typeMap[5] = {
++static constexpr PkmType typeMap[5] = {
+     { 0x8D64,  8 },   // GL_ETC1_RGB8_OES
+     { 0x9274,  8 },   // GL_COMPRESSED_RGB8_ETC2
+     { 0, 0 },         // unused (obsolete)
+diff --git a/qtbase/src/network/access/qnetworkreplyfileimpl.cpp b/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
+index b6be93147a..6e69b4c4d3 100644
+--- a/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
++++ b/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
+@@ -89,9 +89,10 @@ QNetworkReplyFileImpl::QNetworkReplyFileImpl(QNetworkAccessManager *manager, con
+         // we handle only local files
+         QString msg = QCoreApplication::translate("QNetworkAccessFileBackend", "Request for opening non-local file %1").arg(url.toString());
+         setError(QNetworkReply::ProtocolInvalidOperationError, msg);
++        setFinished(true); // We're finished, will emit finished() after ctor is done.
+         QMetaObject::invokeMethod(this, "errorOccurred", Qt::QueuedConnection,
+             Q_ARG(QNetworkReply::NetworkError, QNetworkReply::ProtocolInvalidOperationError));
+-        fileOpenFinished(false);
++        QMetaObject::invokeMethod(this, [this](){ fileOpenFinished(false); }, Qt::QueuedConnection);
+         return;
+     }
+ #endif
+diff --git a/qtbase/src/network/access/qnetworkreplyimpl.cpp b/qtbase/src/network/access/qnetworkreplyimpl.cpp
+index bcdf6ee2f1..3b6deb82bd 100644
+--- a/qtbase/src/network/access/qnetworkreplyimpl.cpp
++++ b/qtbase/src/network/access/qnetworkreplyimpl.cpp
+@@ -680,7 +680,7 @@ void QNetworkReplyImplPrivate::appendDownstreamData(QIODevice *data)
+     // read until EOF from data
+     if (Q_UNLIKELY(copyDevice)) {
+         qCritical("QNetworkReplyImpl: copy from QIODevice already in progress -- "
+-                  "backend probly needs to be fixed");
++                  "backend probably needs to be fixed");
+         return;
+     }
+ 
+diff --git a/qtbase/src/network/kernel/qauthenticator.cpp b/qtbase/src/network/kernel/qauthenticator.cpp
+index d9fe7bc47b..ccd04b294a 100644
+--- a/qtbase/src/network/kernel/qauthenticator.cpp
++++ b/qtbase/src/network/kernel/qauthenticator.cpp
+@@ -50,6 +50,7 @@
+ #include <qstring.h>
+ #include <qdatetime.h>
+ #include <qrandom.h>
++#include "private/qsystemlibrary_p.h"
+ 
+ #ifdef Q_OS_WIN
+ #include <qmutex.h>
+@@ -1563,7 +1564,7 @@ static bool q_SSPI_library_load()
+ 
+     // Initialize security interface
+     if (pSecurityFunctionTable == nullptr) {
+-        securityDLLHandle = LoadLibrary(L"secur32.dll");
++        securityDLLHandle = QSystemLibrary::load(L"secur32");
+         if (securityDLLHandle != nullptr) {
+             INIT_SECURITY_INTERFACE pInitSecurityInterface =
+                 reinterpret_cast<INIT_SECURITY_INTERFACE>(
+diff --git a/qtbase/src/network/kernel/qhostinfo_unix.cpp b/qtbase/src/network/kernel/qhostinfo_unix.cpp
+index 9b0a2ee669..73679c9ef1 100644
+--- a/qtbase/src/network/kernel/qhostinfo_unix.cpp
++++ b/qtbase/src/network/kernel/qhostinfo_unix.cpp
+@@ -122,7 +122,6 @@ static QFunctionPointer resolveSymbol(QLibrary &lib, const char *sym)
+ 
+ LibResolv::LibResolv()
+ {
+-    QLibrary lib;
+ #ifdef LIBRESOLV_SO
+     lib.setFileName(QStringLiteral(LIBRESOLV_SO));
+     if (!lib.load())
+diff --git a/qtbase/src/network/socket/qsocks5socketengine.cpp b/qtbase/src/network/socket/qsocks5socketengine.cpp
+index 3a046fd116..97fadca0b3 100644
+--- a/qtbase/src/network/socket/qsocks5socketengine.cpp
++++ b/qtbase/src/network/socket/qsocks5socketengine.cpp
+@@ -1296,7 +1296,7 @@ void QSocks5SocketEnginePrivate::_q_udpSocketReadNotification()
+         int pos = 0;
+         const char *buf = inBuf.constData();
+         if (inBuf.size() < 4) {
+-            QSOCKS5_D_DEBUG << "bugus udp data, discarding";
++            QSOCKS5_D_DEBUG << "bogus udp data, discarding";
+             return;
+         }
+         QSocks5RevivedDatagram datagram;
+diff --git a/qtbase/src/network/ssl/qsslcontext_openssl.cpp b/qtbase/src/network/ssl/qsslcontext_openssl.cpp
+index c9f202f573..c992da9d8e 100644
+--- a/qtbase/src/network/ssl/qsslcontext_openssl.cpp
++++ b/qtbase/src/network/ssl/qsslcontext_openssl.cpp
+@@ -409,7 +409,7 @@ init_context:
+         break;
+     case QSsl::DtlsV1_0OrLater:
+         minVersion = DTLS1_VERSION;
+-        maxVersion = DTLS_MAX_VERSION;
++        maxVersion = 0;
+         break;
+     case QSsl::DtlsV1_2:
+         minVersion = DTLS1_2_VERSION;
+@@ -417,7 +417,7 @@ init_context:
+         break;
+     case QSsl::DtlsV1_2OrLater:
+         minVersion = DTLS1_2_VERSION;
+-        maxVersion = DTLS_MAX_VERSION;
++        maxVersion = 0;
+         break;
+     case QSsl::TlsV1_3OrLater:
+ #ifdef TLS1_3_VERSION
+@@ -455,7 +455,7 @@ init_context:
+     }
+ 
+     // Enable bug workarounds.
+-    long options = QSslSocketBackendPrivate::setupOpenSslOptions(configuration.protocol(), configuration.d->sslOptions);
++    qssloptions options = QSslSocketBackendPrivate::setupOpenSslOptions(configuration.protocol(), configuration.d->sslOptions);
+     q_SSL_CTX_set_options(sslContext->ctx, options);
+ 
+     // Tell OpenSSL to release memory early
+diff --git a/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp b/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
+index aaf8741130..b58935372c 100644
+--- a/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
++++ b/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
+@@ -59,57 +59,6 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-#ifdef OPENSSL_NO_DEPRECATED_3_0
+-
+-static int q_DH_check(DH *dh, int *status)
+-{
+-    // DH_check was first deprecated in OpenSSL 3.0.0, as low-level
+-    // API; the EVP_PKEY family of functions was advised as an alternative.
+-    // As of now EVP_PKEY_params_check ends up calling ... DH_check,
+-    // which is good enough.
+-
+-    Q_ASSERT(dh);
+-    Q_ASSERT(status);
+-
+-    EVP_PKEY *key = q_EVP_PKEY_new();
+-    if (!key) {
+-        qCWarning(lcSsl, "EVP_PKEY_new failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-    const auto keyDeleter = qScopeGuard([key](){
+-        q_EVP_PKEY_free(key);
+-    });
+-    if (!q_EVP_PKEY_set1_DH(key, dh)) {
+-        qCWarning(lcSsl, "EVP_PKEY_set1_DH failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-
+-    EVP_PKEY_CTX *keyCtx = q_EVP_PKEY_CTX_new(key, nullptr);
+-    if (!keyCtx) {
+-        qCWarning(lcSsl, "EVP_PKEY_CTX_new failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-    const auto ctxDeleter = qScopeGuard([keyCtx]{
+-        q_EVP_PKEY_CTX_free(keyCtx);
+-    });
+-
+-    const int result = q_EVP_PKEY_param_check(keyCtx);
+-    QSslSocketBackendPrivate::logAndClearErrorQueue();
+-    // Note: unlike DH_check, we cannot obtain the 'status',
+-    // if the 'result' is 0 (actually the result is 1 only
+-    // if this 'status' was 0). We could probably check the
+-    // errors from the error queue, but it's not needed anyway
+-    // - see the 'isSafeDH' below, how it returns immediately
+-    // on 0.
+-    Q_UNUSED(status)
+-
+-    return result;
+-}
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+-
+ static bool isSafeDH(DH *dh)
+ {
+     int status = 0;
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl.cpp b/qtbase/src/network/ssl/qsslsocket_openssl.cpp
+index 37fad2a68f..8f6858c867 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl.cpp
++++ b/qtbase/src/network/ssl/qsslsocket_openssl.cpp
+@@ -550,9 +550,9 @@ static void q_loadCiphersForConnection(SSL *connection, QList<QSslCipher> &ciphe
+ // Defined in qsslsocket.cpp
+ void q_setDefaultDtlsCiphers(const QList<QSslCipher> &ciphers);
+ 
+-long QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions)
++qssloptions QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions)
+ {
+-    long options;
++    qssloptions options;
+     if (protocol == QSsl::TlsV1SslV3)
+         options = SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3;
+     else if (protocol == QSsl::SecureProtocols)
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_p.h b/qtbase/src/network/ssl/qsslsocket_openssl_p.h
+index 4103de23e8..5547589256 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_p.h
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_p.h
+@@ -107,6 +107,12 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++typedef uint64_t qssloptions;
++#else
++typedef unsigned long qssloptions;
++#endif
++
+ struct QSslErrorEntry {
+     int code;
+     int depth;
+@@ -171,7 +177,7 @@ public:
+     QVector<QSslError> ocspErrors;
+     QByteArray ocspResponseDer;
+ 
+-    Q_AUTOTEST_EXPORT static long setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions);
++    Q_AUTOTEST_EXPORT static qssloptions setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions);
+     static QSslCipher QSslCipher_from_SSL_CIPHER(const SSL_CIPHER *cipher);
+     static QList<QSslCertificate> STACKOFX509_to_QSslCertificates(STACK_OF(X509) *x509);
+     static QList<QSslError> verify(const QList<QSslCertificate> &certificateChain, const QString &hostName);
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp b/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
+index e53fb279f0..459ccd0b19 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
+@@ -148,7 +148,6 @@ DEFINEFUNC(int, EVP_PKEY_up_ref, EVP_PKEY *a, a, return 0, return)
+ DEFINEFUNC2(EVP_PKEY_CTX *, EVP_PKEY_CTX_new, EVP_PKEY *pkey, pkey, ENGINE *e, e, return nullptr, return)
+ DEFINEFUNC(int, EVP_PKEY_param_check, EVP_PKEY_CTX *ctx, ctx, return 0, return)
+ DEFINEFUNC(void, EVP_PKEY_CTX_free, EVP_PKEY_CTX *ctx, ctx, return, return)
+-DEFINEFUNC(int, EVP_PKEY_base_id, EVP_PKEY *a, a, return NID_undef, return)
+ DEFINEFUNC(int, RSA_bits, RSA *a, a, return 0, return)
+ DEFINEFUNC(int, DSA_bits, DSA *a, a, return 0, return)
+ DEFINEFUNC(int, OPENSSL_sk_num, OPENSSL_STACK *a, a, return -1, return)
+@@ -158,7 +157,7 @@ DEFINEFUNC2(void, OPENSSL_sk_push, OPENSSL_STACK *a, a, void *b, b, return, DUMM
+ DEFINEFUNC(void, OPENSSL_sk_free, OPENSSL_STACK *a, a, return, DUMMYARG)
+ DEFINEFUNC2(void *, OPENSSL_sk_value, OPENSSL_STACK *a, a, int b, b, return nullptr, return)
+ DEFINEFUNC(int, SSL_session_reused, SSL *a, a, return 0, return)
+-DEFINEFUNC2(unsigned long, SSL_CTX_set_options, SSL_CTX *ctx, ctx, unsigned long op, op, return 0, return)
++DEFINEFUNC2(qssloptions, SSL_CTX_set_options, SSL_CTX *ctx, ctx, qssloptions op, op, return 0, return)
+ DEFINEFUNC(int, SSL_CTX_get_security_level, const SSL_CTX *ctx, ctx, return -1, return)
+ DEFINEFUNC2(void, SSL_CTX_set_security_level, SSL_CTX *ctx, ctx, int level, level, return, return)
+ #ifdef TLS1_3_VERSION
+@@ -371,7 +370,15 @@ DEFINEFUNC(const SSL_CIPHER *, SSL_get_current_cipher, SSL *a, a, return nullptr
+ DEFINEFUNC(int, SSL_version, const SSL *a, a, return 0, return)
+ DEFINEFUNC2(int, SSL_get_error, SSL *a, a, int b, b, return -1, return)
+ DEFINEFUNC(STACK_OF(X509) *, SSL_get_peer_cert_chain, SSL *a, a, return nullptr, return)
++
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++DEFINEFUNC(X509 *, SSL_get1_peer_certificate, SSL *a, a, return nullptr, return)
++DEFINEFUNC(int, EVP_PKEY_get_base_id, const EVP_PKEY *pkey, pkey, return -1, return)
++#else
+ DEFINEFUNC(X509 *, SSL_get_peer_certificate, SSL *a, a, return nullptr, return)
++DEFINEFUNC(int, EVP_PKEY_base_id, EVP_PKEY *a, a, return NID_undef, return)
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+ DEFINEFUNC(long, SSL_get_verify_result, const SSL *a, a, return -1, return)
+ DEFINEFUNC(SSL *, SSL_new, SSL_CTX *a, a, return nullptr, return)
+ DEFINEFUNC(SSL_CTX *, SSL_get_SSL_CTX, SSL *a, a, return nullptr, return)
+@@ -492,9 +499,7 @@ DEFINEFUNC(DH *, DH_new, DUMMYARG, DUMMYARG, return nullptr, return)
+ DEFINEFUNC(void, DH_free, DH *dh, dh, return, DUMMYARG)
+ DEFINEFUNC3(DH *, d2i_DHparams, DH**a, a, const unsigned char **pp, pp, long length, length, return nullptr, return)
+ DEFINEFUNC2(int, i2d_DHparams, DH *a, a, unsigned char **p, p, return -1, return)
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+ DEFINEFUNC2(int, DH_check, DH *dh, dh, int *codes, codes, return 0, return)
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+ DEFINEFUNC3(BIGNUM *, BN_bin2bn, const unsigned char *s, s, int len, len, BIGNUM *ret, ret, return nullptr, return)
+ 
+ #ifndef OPENSSL_NO_EC
+@@ -868,7 +873,6 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(EVP_PKEY_CTX_new)
+     RESOLVEFUNC(EVP_PKEY_param_check)
+     RESOLVEFUNC(EVP_PKEY_CTX_free)
+-    RESOLVEFUNC(EVP_PKEY_base_id)
+     RESOLVEFUNC(RSA_bits)
+     RESOLVEFUNC(OPENSSL_sk_new_null)
+     RESOLVEFUNC(OPENSSL_sk_push)
+@@ -1107,7 +1111,15 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(SSL_version)
+     RESOLVEFUNC(SSL_get_error)
+     RESOLVEFUNC(SSL_get_peer_cert_chain)
++
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++    RESOLVEFUNC(SSL_get1_peer_certificate)
++    RESOLVEFUNC(EVP_PKEY_get_base_id)
++#else
+     RESOLVEFUNC(SSL_get_peer_certificate)
++    RESOLVEFUNC(EVP_PKEY_base_id)
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+     RESOLVEFUNC(SSL_get_verify_result)
+     RESOLVEFUNC(SSL_new)
+     RESOLVEFUNC(SSL_get_SSL_CTX)
+@@ -1206,9 +1218,7 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(DH_free)
+     RESOLVEFUNC(d2i_DHparams)
+     RESOLVEFUNC(i2d_DHparams)
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+     RESOLVEFUNC(DH_check)
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+     RESOLVEFUNC(BN_bin2bn)
+ 
+ #ifndef OPENSSL_NO_EC
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h b/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
+index 95e8897a3b..27aeffa18a 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
+@@ -237,7 +237,6 @@ Q_AUTOTEST_EXPORT int q_EVP_PKEY_up_ref(EVP_PKEY *a);
+ EVP_PKEY_CTX *q_EVP_PKEY_CTX_new(EVP_PKEY *pkey, ENGINE *e);
+ void q_EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx);
+ int q_EVP_PKEY_param_check(EVP_PKEY_CTX *ctx);
+-int q_EVP_PKEY_base_id(EVP_PKEY *a);
+ int q_RSA_bits(RSA *a);
+ Q_AUTOTEST_EXPORT int q_OPENSSL_sk_num(OPENSSL_STACK *a);
+ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_pop_free(OPENSSL_STACK *a, void (*b)(void *));
+@@ -246,7 +245,7 @@ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_push(OPENSSL_STACK *st, void *data);
+ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_free(OPENSSL_STACK *a);
+ Q_AUTOTEST_EXPORT void * q_OPENSSL_sk_value(OPENSSL_STACK *a, int b);
+ int q_SSL_session_reused(SSL *a);
+-unsigned long q_SSL_CTX_set_options(SSL_CTX *ctx, unsigned long op);
++qssloptions q_SSL_CTX_set_options(SSL_CTX *ctx, qssloptions op);
+ int q_OPENSSL_init_ssl(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings);
+ size_t q_SSL_get_client_random(SSL *a, unsigned char *out, size_t outlen);
+ size_t q_SSL_SESSION_get_master_key(const SSL_SESSION *session, unsigned char *out, size_t outlen);
+@@ -510,7 +509,6 @@ const SSL_CIPHER *q_SSL_get_current_cipher(SSL *a);
+ int q_SSL_version(const SSL *a);
+ int q_SSL_get_error(SSL *a, int b);
+ STACK_OF(X509) *q_SSL_get_peer_cert_chain(SSL *a);
+-X509 *q_SSL_get_peer_certificate(SSL *a);
+ long q_SSL_get_verify_result(const SSL *a);
+ SSL *q_SSL_new(SSL_CTX *a);
+ SSL_CTX *q_SSL_get_SSL_CTX(SSL *a);
+@@ -582,10 +580,7 @@ DH *q_DH_new();
+ void q_DH_free(DH *dh);
+ DH *q_d2i_DHparams(DH **a, const unsigned char **pp, long length);
+ int q_i2d_DHparams(DH *a, unsigned char **p);
+-
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+ int q_DH_check(DH *dh, int *codes);
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+ 
+ BIGNUM *q_BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret);
+ #define q_SSL_CTX_set_tmp_dh(ctx, dh) q_SSL_CTX_ctrl((ctx), SSL_CTRL_SET_TMP_DH, 0, (char *)dh)
+@@ -754,6 +749,17 @@ void q_CRYPTO_free(void *str, const char *file, int line);
+ int q_SSL_CTX_get_security_level(const SSL_CTX *ctx);
+ void q_SSL_CTX_set_security_level(SSL_CTX *ctx, int level);
+ 
++// Here we have the ones that make difference between OpenSSL pre/post v3:
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++X509 *q_SSL_get1_peer_certificate(SSL *a);
++#define q_SSL_get_peer_certificate q_SSL_get1_peer_certificate
++int q_EVP_PKEY_get_base_id(const EVP_PKEY *pkey);
++#define q_EVP_PKEY_base_id q_EVP_PKEY_get_base_id
++#else
++X509 *q_SSL_get_peer_certificate(SSL *a);
++int q_EVP_PKEY_base_id(EVP_PKEY *a);
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+ QT_END_NAMESPACE
+ 
+ #endif
+diff --git a/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h b/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
+index bf37d07fd8..dbd42fb799 100644
+--- a/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
++++ b/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
+@@ -61,7 +61,11 @@
+ # if !defined(Q_OS_INTEGRITY)
+ #  define WIN_INTERFACE_CUSTOM   // NV
+ # endif // Q_OS_INTEGRITY
+-#endif  // QT_EGL_NO_X11
++#else // QT_EGL_NO_X11
++// If one has an eglplatform.h with https://github.com/KhronosGroup/EGL-Registry/pull/130
++// that needs USE_X11 to be defined.
++# define USE_X11
++#endif
+ 
+ #ifdef QT_EGL_WAYLAND
+ # define WAYLAND // NV
+diff --git a/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+index 159b490ce0..00aa80cd58 100644
+--- a/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
++++ b/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+@@ -567,6 +567,8 @@ void QFontconfigDatabase::populateFontDatabase()
+         fonts = FcFontList(nullptr, pattern, os);
+         FcObjectSetDestroy(os);
+         FcPatternDestroy(pattern);
++        if (!fonts)
++            return;
+     }
+ 
+     for (int i = 0; i < fonts->nfont; i++)
+diff --git a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
+index b713c19447..7cb9a8c79a 100644
+--- a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
++++ b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
+@@ -95,6 +95,7 @@ static constexpr const auto KeyTbl = qMakeArray(
+         Xkb2Qt<XKB_KEY_Clear,                   Qt::Key_Delete>,
+         Xkb2Qt<XKB_KEY_Pause,                   Qt::Key_Pause>,
+         Xkb2Qt<XKB_KEY_Print,                   Qt::Key_Print>,
++        Xkb2Qt<XKB_KEY_Sys_Req,                 Qt::Key_SysReq>,
+         Xkb2Qt<0x1005FF60,                      Qt::Key_SysReq>,         // hardcoded Sun SysReq
+         Xkb2Qt<0x1007ff00,                      Qt::Key_SysReq>,         // hardcoded X386 SysReq
+ 
+@@ -471,7 +472,7 @@ QVector<xkb_keysym_t> QXkbCommon::toKeysym(QKeyEvent *event)
+     } else if (event->modifiers() & Qt::KeypadModifier) {
+         if (qtKey >= Qt::Key_0 && qtKey <= Qt::Key_9)
+             keysyms.append(XKB_KEY_KP_0 + (qtKey - Qt::Key_0));
+-    } else if (isLatin(qtKey) && event->text().isUpper()) {
++    } else if (isLatin1(qtKey) && event->text().isUpper()) {
+         keysyms.append(qtKey);
+     }
+ 
+@@ -523,7 +524,7 @@ int QXkbCommon::keysymToQtKey(xkb_keysym_t keysym, Qt::KeyboardModifiers modifie
+         // With standard shortcuts we should prefer a latin character, this is
+         // for checks like "some qkeyevent == QKeySequence::Copy" to work even
+         // when using for example 'russian' keyboard layout.
+-        if (!QXkbCommon::isLatin(keysym)) {
++        if (!QXkbCommon::isLatin1(keysym)) {
+             xkb_keysym_t latinKeysym = QXkbCommon::lookupLatinKeysym(state, code);
+             if (latinKeysym != XKB_KEY_NoSymbol)
+                 keysym = latinKeysym;
+@@ -546,7 +547,7 @@ static int keysymToQtKey_internal(xkb_keysym_t keysym, Qt::KeyboardModifiers mod
+     } else if (keysym >= XKB_KEY_KP_0 && keysym <= XKB_KEY_KP_9) {
+         // numeric keypad keys
+         qtKey = Qt::Key_0 + (keysym - XKB_KEY_KP_0);
+-    } else if (QXkbCommon::isLatin(keysym)) {
++    } else if (QXkbCommon::isLatin1(keysym)) {
+         qtKey = QXkbCommon::qxkbcommon_xkb_keysym_to_upper(keysym);
+     } else {
+         // check if we have a direct mapping
+@@ -678,7 +679,7 @@ QList<int> QXkbCommon::possibleKeys(xkb_state *state, const QKeyEvent *event,
+         Qt::KeyboardModifiers neededMods = ModsTbl[i];
+         if ((modifiers & neededMods) == neededMods) {
+             if (i == 8) {
+-                if (isLatin(baseQtKey))
++                if (isLatin1(baseQtKey))
+                     continue;
+                 // add a latin key as a fall back key
+                 sym = lookupLatinKeysym(state, keycode);
+@@ -733,7 +734,7 @@ void QXkbCommon::verifyHasLatinLayout(xkb_keymap *keymap)
+     for (xkb_layout_index_t layout = 0; layout < layoutCount; ++layout) {
+         for (xkb_keycode_t code = minKeycode; code < maxKeycode; ++code) {
+             xkb_keymap_key_get_syms_by_level(keymap, code, layout, 0, &keysyms);
+-            if (keysyms && isLatin(keysyms[0]))
++            if (keysyms && isLatin1(keysyms[0]))
+                 nrLatinKeys++;
+             if (nrLatinKeys > 10) // arbitrarily chosen threshold
+                 return;
+@@ -766,7 +767,7 @@ xkb_keysym_t QXkbCommon::lookupLatinKeysym(xkb_state *state, xkb_keycode_t keyco
+         xkb_level_index_t level = xkb_state_key_get_level(state, keycode, layout);
+         if (xkb_keymap_key_get_syms_by_level(keymap, keycode, layout, level, &syms) != 1)
+             continue;
+-        if (isLatin(syms[0])) {
++        if (isLatin1(syms[0])) {
+             sym = syms[0];
+             break;
+         }
+diff --git a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
+index 561eae03db..8389bd8f5a 100644
+--- a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
++++ b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
+@@ -94,8 +94,8 @@ public:
+     static void verifyHasLatinLayout(xkb_keymap *keymap);
+     static xkb_keysym_t lookupLatinKeysym(xkb_state *state, xkb_keycode_t keycode);
+ 
+-    static bool isLatin(xkb_keysym_t sym) {
+-        return ((sym >= 'a' && sym <= 'z') || (sym >= 'A' && sym <= 'Z'));
++    static bool isLatin1(xkb_keysym_t sym) {
++        return sym <= 0xff;
+     }
+     static bool isKeypad(xkb_keysym_t sym) {
+         return sym >= XKB_KEY_KP_Space && sym <= XKB_KEY_KP_9;
+diff --git a/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp b/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
+index 8cd7f9b368..406f84663f 100644
+--- a/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
++++ b/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
+@@ -318,7 +318,7 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources,
+ 
+     if (current < 0 && crtc_mode.clock != 0) {
+         modes << crtc_mode;
+-        current = mode.size() - 1;
++        current = modes.size() - 1;
+     }
+ 
+     if (configuration == OutputConfigCurrent)
+diff --git a/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp b/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
+index 9153fd20bb..255ea5e33e 100644
+--- a/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
++++ b/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
+@@ -194,6 +194,9 @@ QString AtSpiAdaptor::introspect(const QString &path) const
+                 "      <arg direction=\"out\" type=\"(so)\"/>\n"
+                 "      <annotation value=\"QSpiObjectReference\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n"
+                 "    </method>\n"
++                "    <method name=\"GetAccessibleId\">\n"
++                "      <arg direction=\"out\" type=\"s\"/>\n"
++                "    </method>\n"
+                 "  </interface>\n"
+                 );
+ 
+@@ -913,8 +916,17 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+     }
+     case QAccessible::NameChanged: {
+         if (sendObject || sendObject_property_change || sendObject_property_change_accessible_name) {
+-            QString path = pathForInterface(event->accessibleInterface());
+-            QVariantList args = packDBusSignalArguments(QLatin1String("accessible-name"), 0, 0, variantForPath(path));
++            QAccessibleInterface *iface = event->accessibleInterface();
++            if (!iface) {
++                qCDebug(lcAccessibilityAtspi,
++                        "NameChanged event from invalid accessible.");
++                return;
++            }
++
++            QString path = pathForInterface(iface);
++            QVariantList args = packDBusSignalArguments(
++                QLatin1String("accessible-name"), 0, 0,
++                QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Name))));
+             sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                            QLatin1String("PropertyChange"), args);
+         }
+@@ -922,8 +934,17 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+     }
+     case QAccessible::DescriptionChanged: {
+         if (sendObject || sendObject_property_change || sendObject_property_change_accessible_description) {
+-            QString path = pathForInterface(event->accessibleInterface());
+-            QVariantList args = packDBusSignalArguments(QLatin1String("accessible-description"), 0, 0, variantForPath(path));
++            QAccessibleInterface *iface = event->accessibleInterface();
++            if (!iface) {
++                qCDebug(lcAccessibilityAtspi,
++                        "DescriptionChanged event from invalid accessible.");
++                return;
++            }
++
++            QString path = pathForInterface(iface);
++            QVariantList args = packDBusSignalArguments(
++                QLatin1String("accessible-description"), 0, 0,
++                QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Description))));
+             sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                            QLatin1String("PropertyChange"), args);
+         }
+@@ -1038,7 +1059,9 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+                 // Combo Box with AT-SPI likes to be special
+                 // It requires a name-change to update caches and then selection-changed
+                 QString path = pathForInterface(iface);
+-                QVariantList args1 = packDBusSignalArguments(QLatin1String("accessible-name"), 0, 0, variantForPath(path));
++                QVariantList args1 = packDBusSignalArguments(
++                    QLatin1String("accessible-name"), 0, 0,
++                    QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Name))));
+                 sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                                QLatin1String("PropertyChange"), args1);
+                 QVariantList args2 = packDBusSignalArguments(QString(), 0, 0, QVariant::fromValue(QDBusVariant(QVariant(0))));
+@@ -1358,6 +1381,26 @@ void AtSpiAdaptor::registerApplication()
+     delete registry;
+ }
+ 
++namespace {
++QString accessibleIdForAccessible(QAccessibleInterface *accessible)
++{
++    QString result;
++    while (accessible) {
++        if (!result.isEmpty())
++            result.prepend(QLatin1Char('.'));
++        if (auto obj = accessible->object()) {
++            const QString name = obj->objectName();
++            if (!name.isEmpty())
++                result.prepend(name);
++            else
++                result.prepend(QString::fromUtf8(obj->metaObject()->className()));
++        }
++        accessible = accessible->parent();
++    }
++    return result;
++}
++} // namespace
++
+ // Accessible
+ bool AtSpiAdaptor::accessibleInterface(QAccessibleInterface *interface, const QString &function, const QDBusMessage &message, const QDBusConnection &connection)
+ {
+@@ -1441,6 +1484,9 @@ bool AtSpiAdaptor::accessibleInterface(QAccessibleInterface *interface, const QS
+             children << ref;
+         }
+         connection.send(message.createReply(QVariant::fromValue(children)));
++    } else if (function == QLatin1String("GetAccessibleId")) {
++        sendReply(connection, message,
++                  QVariant::fromValue(QDBusVariant(accessibleIdForAccessible(interface))));
+     } else {
+         qCDebug(lcAccessibilityAtspi) << "WARNING: AtSpiAdaptor::accessibleInterface does not implement " << function << message.path();
+         return false;
+diff --git a/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp b/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
+index 45ddc8e496..cc734abc63 100644
+--- a/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
++++ b/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
+@@ -69,6 +69,21 @@ QT_BEGIN_NAMESPACE
+ DBusConnection::DBusConnection(QObject *parent)
+     : QObject(parent), m_a11yConnection(QString()), m_enabled(false)
+ {
++    // If the bus is explicitly set via env var it overrides everything else.
++    QByteArray addressEnv = qgetenv("AT_SPI_BUS_ADDRESS");
++    if (!addressEnv.isEmpty()) {
++        // Only connect on next loop run, connections to our enabled signal are
++        // only established after the ctor returns.
++        QMetaObject::invokeMethod(
++                this,
++                [this, addressEnv] {
++                    m_enabled = true;
++                    connectA11yBus(QString::fromLocal8Bit(addressEnv));
++                },
++                Qt::QueuedConnection);
++        return;
++    }
++
+     // Start monitoring if "org.a11y.Bus" is registered as DBus service.
+     QDBusConnection c = QDBusConnection::sessionBus();
+     if (!c.isConnected()) {
+diff --git a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
+index 1a3cab275d..2abe039126 100644
+--- a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
++++ b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
+@@ -51,6 +51,9 @@
+ #include <QtCore/QStandardPaths>
+ #include <QtCore/QUrl>
+ 
++#include <QtGui/QGuiApplication>
++#include <QtGui/QWindow>
++
+ #if QT_CONFIG(dbus)
+ // These QtCore includes are needed for xdg-desktop-portal support
+ #include <QtCore/private/qcore_unix_p.h>
+@@ -58,6 +61,8 @@
+ #include <QtCore/QFileInfo>
+ #include <QtCore/QUrlQuery>
+ 
++#include <QtGui/QColor>
++
+ #include <QtDBus/QDBusConnection>
+ #include <QtDBus/QDBusMessage>
+ #include <QtDBus/QDBusPendingCall>
+@@ -142,6 +147,8 @@ static inline bool detectWebBrowser(const QByteArray &desktop,
+     }
+ 
+     if (desktop == QByteArray("KDE")) {
++        if (checkExecutable(QStringLiteral("kde-open5"), browser))
++            return true;
+         // Konqueror launcher
+         if (checkExecutable(QStringLiteral("kfmclient"), browser)) {
+             browser->append(QLatin1String(" exec"));
+@@ -296,8 +303,135 @@ static inline QDBusMessage xdgDesktopPortalSendEmail(const QUrl &url)
+ 
+     return QDBusConnection::sessionBus().call(message);
+ }
++
++namespace {
++struct XDGDesktopColor
++{
++    double r = 0;
++    double g = 0;
++    double b = 0;
++
++    QColor toQColor() const
++    {
++        constexpr auto rgbMax = 255;
++        return { static_cast<int>(r * rgbMax), static_cast<int>(g * rgbMax),
++                 static_cast<int>(b * rgbMax) };
++    }
++};
++
++const QDBusArgument &operator>>(const QDBusArgument &argument, XDGDesktopColor &myStruct)
++{
++    argument.beginStructure();
++    argument >> myStruct.r >> myStruct.g >> myStruct.b;
++    argument.endStructure();
++    return argument;
++}
++
++class XdgDesktopPortalColorPicker : public QPlatformServiceColorPicker
++{
++    Q_OBJECT
++public:
++    XdgDesktopPortalColorPicker(const QString &parentWindowId, QWindow *parent)
++        : QPlatformServiceColorPicker(parent), m_parentWindowId(parentWindowId)
++    {
++    }
++
++    void pickColor() override
++    {
++        // DBus signature:
++        // PickColor (IN   s      parent_window,
++        //            IN   a{sv}  options
++        //            OUT  o      handle)
++        // Options:
++        // handle_token (s) -  A string that will be used as the last element of the @handle.
++
++        QDBusMessage message = QDBusMessage::createMethodCall(
++                QStringLiteral("org.freedesktop.portal.Desktop"), QStringLiteral("/org/freedesktop/portal/desktop"),
++                QStringLiteral("org.freedesktop.portal.Screenshot"), QStringLiteral("PickColor"));
++        message << m_parentWindowId << QVariantMap();
++
++        QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
++        auto watcher = new QDBusPendingCallWatcher(pendingCall, this);
++        connect(watcher, &QDBusPendingCallWatcher::finished, this,
++                [this](QDBusPendingCallWatcher *watcher) {
++                    watcher->deleteLater();
++                    QDBusPendingReply<QDBusObjectPath> reply = *watcher;
++                    if (reply.isError()) {
++                        qWarning("DBus call to pick color failed: %s",
++                                 qPrintable(reply.error().message()));
++                        Q_EMIT colorPicked({});
++                    } else {
++                        QDBusConnection::sessionBus().connect(
++                                QStringLiteral("org.freedesktop.portal.Desktop"), reply.value().path(),
++                                QStringLiteral("org.freedesktop.portal.Request"), QStringLiteral("Response"), this,
++                                // clang-format off
++                                SLOT(gotColorResponse(uint,QVariantMap))
++                                // clang-format on
++                        );
++                    }
++                });
++    }
++
++private Q_SLOTS:
++    void gotColorResponse(uint result, const QVariantMap &map)
++    {
++        if (result != 0)
++            return;
++        XDGDesktopColor color{};
++        map.value(QStringLiteral("color")).value<QDBusArgument>() >> color;
++        Q_EMIT colorPicked(color.toQColor());
++        deleteLater();
++    }
++
++private:
++    const QString m_parentWindowId;
++};
++} // namespace
++
+ #endif // QT_CONFIG(dbus)
+ 
++QGenericUnixServices::QGenericUnixServices()
++{
++#if QT_CONFIG(dbus)
++    if (qEnvironmentVariableIntValue("QT_NO_XDG_DESKTOP_PORTAL") > 0) {
++        return;
++    }
++    QDBusMessage message = QDBusMessage::createMethodCall(
++            QStringLiteral("org.freedesktop.portal.Desktop"), QStringLiteral("/org/freedesktop/portal/desktop"),
++            QStringLiteral("org.freedesktop.DBus.Properties"), QStringLiteral("Get"));
++    message << QStringLiteral("org.freedesktop.portal.Screenshot")
++            << QStringLiteral("version");
++
++    QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
++    auto watcher = new QDBusPendingCallWatcher(pendingCall);
++    QObject::connect(watcher, &QDBusPendingCallWatcher::finished, watcher,
++                     [this](QDBusPendingCallWatcher *watcher) {
++                         watcher->deleteLater();
++                         QDBusPendingReply<QVariant> reply = *watcher;
++                         if (!reply.isError() && reply.value().toUInt() >= 2)
++                             m_hasScreenshotPortalWithColorPicking = true;
++                     });
++
++#endif
++}
++
++QPlatformServiceColorPicker *QGenericUnixServices::colorPicker(QWindow *parent)
++{
++#if QT_CONFIG(dbus)
++    // Make double sure that we are in a wayland environment. In particular check
++    // WAYLAND_DISPLAY so also XWayland apps benefit from portal-based color picking.
++    // Outside wayland we'll rather rely on other means than the XDG desktop portal.
++    if (!qEnvironmentVariableIsEmpty("WAYLAND_DISPLAY")
++        || QGuiApplication::platformName().startsWith(QLatin1String("wayland"))) {
++        return new XdgDesktopPortalColorPicker(portalWindowIdentifier(parent), parent);
++    }
++    return nullptr;
++#else
++    Q_UNUSED(parent);
++    return nullptr;
++#endif
++}
++
+ QByteArray QGenericUnixServices::desktopEnvironment() const
+ {
+     static const QByteArray result = detectDesktopEnvironment();
+@@ -352,6 +486,8 @@ bool QGenericUnixServices::openDocument(const QUrl &url)
+ }
+ 
+ #else
++QGenericUnixServices::QGenericUnixServices() = default;
++
+ QByteArray QGenericUnixServices::desktopEnvironment() const
+ {
+     return QByteArrayLiteral("UNKNOWN");
+@@ -371,6 +507,30 @@ bool QGenericUnixServices::openDocument(const QUrl &url)
+     return false;
+ }
+ 
++QPlatformServiceColorPicker *QGenericUnixServices::colorPicker(QWindow *parent)
++{
++    Q_UNUSED(parent);
++    return nullptr;
++}
++
+ #endif // QT_NO_MULTIPROCESS
+ 
++QString QGenericUnixServices::portalWindowIdentifier(QWindow *window)
++{
++    if (QGuiApplication::platformName() == QLatin1String("xcb"))
++        return QStringLiteral("x11:") + QString::number(window->winId(), 16);
++    return QString();
++}
++
++bool QGenericUnixServices::hasCapability(Capability capability) const
++{
++    switch (capability) {
++    case Capability::ColorPicking:
++        return m_hasScreenshotPortalWithColorPicking;
++    }
++    return false;
++}
++
+ QT_END_NAMESPACE
++
++#include "qgenericunixservices.moc"
+diff --git a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
+index 8ac3de6f03..30924e64bd 100644
+--- a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
++++ b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
+@@ -59,16 +59,21 @@ QT_BEGIN_NAMESPACE
+ class QGenericUnixServices : public QPlatformServices
+ {
+ public:
+-    QGenericUnixServices() {}
++    QGenericUnixServices();
+ 
+     QByteArray desktopEnvironment() const override;
+ 
++    bool hasCapability(Capability capability) const override;
+     bool openUrl(const QUrl &url) override;
+     bool openDocument(const QUrl &url) override;
++    QPlatformServiceColorPicker *colorPicker(QWindow *parent = nullptr) override;
++
++    virtual QString portalWindowIdentifier(QWindow *window);
+ 
+ private:
+     QString m_webBrowser;
+     QString m_documentLauncher;
++    bool m_hasScreenshotPortalWithColorPicking = false;
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
+index 09470bccc6..cc7c7d4d8a 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
+@@ -69,6 +69,7 @@ const QString MenuBarPath = QLatin1String("/MenuBar");
+ */
+ QDBusMenuConnection::QDBusMenuConnection(QObject *parent, const QString &serviceName)
+     : QObject(parent)
++    , m_serviceName(serviceName)
+     , m_connection(serviceName.isNull() ? QDBusConnection::sessionBus()
+                                         : QDBusConnection::connectToBus(QDBusConnection::SessionBus, serviceName))
+     , m_dbusWatcher(new QDBusServiceWatcher(StatusNotifierWatcherService, m_connection, QDBusServiceWatcher::WatchForRegistration, this))
+@@ -83,6 +84,12 @@ QDBusMenuConnection::QDBusMenuConnection(QObject *parent, const QString &service
+ #endif
+ }
+ 
++QDBusMenuConnection::~QDBusMenuConnection()
++{
++  if (!m_serviceName.isEmpty() && m_connection.isConnected())
++      QDBusConnection::disconnectFromBus(m_serviceName);
++}
++
+ void QDBusMenuConnection::dbusError(const QDBusError &error)
+ {
+     qWarning() << "QDBusTrayIcon encountered a D-Bus error:" << error;
+@@ -105,13 +112,7 @@ void QDBusMenuConnection::unregisterTrayIconMenu(QDBusTrayIcon *item)
+ 
+ bool QDBusMenuConnection::registerTrayIcon(QDBusTrayIcon *item)
+ {
+-    bool success = connection().registerService(item->instanceId());
+-    if (!success) {
+-        qWarning() << "failed to register service" << item->instanceId();
+-        return false;
+-    }
+-
+-    success = connection().registerObject(StatusNotifierItemPath, item);
++    bool success = connection().registerObject(StatusNotifierItemPath, item);
+     if (!success) {
+         unregisterTrayIcon(item);
+         qWarning() << "failed to register" << item->instanceId() << StatusNotifierItemPath;
+@@ -126,21 +127,18 @@ bool QDBusMenuConnection::registerTrayIcon(QDBusTrayIcon *item)
+ 
+ bool QDBusMenuConnection::registerTrayIconWithWatcher(QDBusTrayIcon *item)
+ {
++    Q_UNUSED(item);
+     QDBusMessage registerMethod = QDBusMessage::createMethodCall(
+                 StatusNotifierWatcherService, StatusNotifierWatcherPath, StatusNotifierWatcherService,
+                 QLatin1String("RegisterStatusNotifierItem"));
+-    registerMethod.setArguments(QVariantList() << item->instanceId());
++    registerMethod.setArguments(QVariantList() << m_connection.baseService());
+     return m_connection.callWithCallback(registerMethod, this, SIGNAL(trayIconRegistered()), SLOT(dbusError(QDBusError)));
+ }
+ 
+-bool QDBusMenuConnection::unregisterTrayIcon(QDBusTrayIcon *item)
++void QDBusMenuConnection::unregisterTrayIcon(QDBusTrayIcon *item)
+ {
+     unregisterTrayIconMenu(item);
+     connection().unregisterObject(StatusNotifierItemPath);
+-    bool success = connection().unregisterService(item->instanceId());
+-    if (!success)
+-        qWarning() << "failed to unregister service" << item->instanceId();
+-    return success;
+ }
+ #endif // QT_NO_SYSTEMTRAYICON
+ 
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
+index f484795fbb..97bdfabb85 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
++++ b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
+@@ -70,6 +70,7 @@ class QDBusMenuConnection : public QObject
+ 
+ public:
+     QDBusMenuConnection(QObject *parent = nullptr, const QString &serviceName = QString());
++    ~QDBusMenuConnection();
+     QDBusConnection connection() const { return m_connection; }
+     QDBusServiceWatcher *dbusWatcher() const { return m_dbusWatcher; }
+     bool isStatusNotifierHostRegistered() const { return m_statusNotifierHostRegistered; }
+@@ -78,7 +79,7 @@ public:
+     void unregisterTrayIconMenu(QDBusTrayIcon *item);
+     bool registerTrayIcon(QDBusTrayIcon *item);
+     bool registerTrayIconWithWatcher(QDBusTrayIcon *item);
+-    bool unregisterTrayIcon(QDBusTrayIcon *item);
++    void unregisterTrayIcon(QDBusTrayIcon *item);
+ #endif // QT_NO_SYSTEMTRAYICON
+ 
+ Q_SIGNALS:
+@@ -90,6 +91,7 @@ private Q_SLOTS:
+     void dbusError(const QDBusError &error);
+ 
+ private:
++    QString m_serviceName;
+     QDBusConnection m_connection;
+     QDBusServiceWatcher *m_dbusWatcher;
+     bool m_statusNotifierHostRegistered;
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp b/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
+index bede70975a..76bfec5e5a 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
+@@ -71,8 +71,12 @@ Q_LOGGING_CATEGORY(qLcTray, "qt.qpa.tray")
+ static QString iconTempPath()
+ {
+     QString tempPath = QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation);
+-    if (!tempPath.isEmpty())
++    if (!tempPath.isEmpty()) {
++        QString flatpakId = qEnvironmentVariable("FLATPAK_ID");
++        if (!flatpakId.isEmpty() && QFileInfo::exists(QLatin1String("/.flatpak-info")))
++            tempPath += QLatin1String("/app/") + flatpakId;
+         return tempPath;
++    }
+ 
+     tempPath = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation);
+ 
+diff --git a/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+index cb1b39db64..6e01af052c 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+@@ -755,6 +755,9 @@ QVariant QGnomeTheme::themeHint(QPlatformTheme::ThemeHint hint) const
+         return QVariant(QChar(0x2022));
+     case QPlatformTheme::UiEffects:
+         return QVariant(int(HoverEffect));
++    case QPlatformTheme::ButtonPressKeys:
++        return QVariant::fromValue(
++                QList<Qt::Key>({ Qt::Key_Space, Qt::Key_Return, Qt::Key_Enter, Qt::Key_Select }));
+     default:
+         break;
+     }
+diff --git a/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp b/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
+index 98e05195ee..1e92f43dec 100644
+--- a/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
++++ b/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
+@@ -343,8 +343,7 @@ void QEglFSCursor::paintOnScreen()
+     // screens are siblings of each other. When not enabled, the sibling list
+     // only contains m_screen itself.
+     for (QPlatformScreen *screen : m_screen->virtualSiblings()) {
+-        if (screen->geometry().contains(cr.topLeft().toPoint() + m_cursor.hotSpot)
+-            && QOpenGLContext::currentContext()->screen() == screen->screen())
++        if (screen->geometry().contains(cr.topLeft().toPoint() + m_cursor.hotSpot))
+         {
+             cr.translate(-screen->geometry().topLeft());
+             const QSize screenSize = screen->geometry().size();
+@@ -468,11 +467,12 @@ void QEglFSCursor::draw(const QRectF &r)
+ {
+     StateSaver stateSaver;
+ 
+-    QEglFSCursorData &gfx = static_cast<QEglFSContext*>(QOpenGLContext::currentContext()->handle())->cursorData;
+-    if (!gfx.program) {
+-        // one time initialization
++    // one time initialization
++    if (!QOpenGLFunctions::d_ptr)
+         initializeOpenGLFunctions();
+ 
++    QEglFSCursorData &gfx = static_cast<QEglFSContext*>(QOpenGLContext::currentContext()->handle())->cursorData;
++    if (!gfx.program) {
+         createShaderPrograms();
+ 
+         if (!gfx.atlasTexture) {
+diff --git a/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp b/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
+index 645a0ae2e9..3e0e406f1a 100644
+--- a/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
++++ b/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
+@@ -179,7 +179,7 @@ void QEglFSKmsEventReader::create(QEglFSKmsDevice *device)
+ 
+     m_device = device;
+ 
+-    qCDebug(qLcEglfsKmsDebug, "Initalizing event reader for device %p fd %d",
++    qCDebug(qLcEglfsKmsDebug, "Initializing event reader for device %p fd %d",
+             m_device, m_device->fd());
+ 
+     m_thread = new QEglFSKmsEventReaderThread(m_device->fd());
+diff --git a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
+index 141fb68a23..d4294d425a 100644
+--- a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
++++ b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
+@@ -122,11 +122,13 @@ QOffscreenIntegration::QOffscreenIntegration()
+ #endif
+     m_services.reset(new QPlatformServices);
+ 
+-    QWindowSystemInterface::handleScreenAdded(new QOffscreenScreen);
++    m_screen = new QOffscreenScreen;
++    QWindowSystemInterface::handleScreenAdded(m_screen);
+ }
+ 
+ QOffscreenIntegration::~QOffscreenIntegration()
+ {
++    QWindowSystemInterface::handleScreenRemoved(m_screen);
+ }
+ 
+ void QOffscreenIntegration::initialize()
+diff --git a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
+index 0ea90f6c2f..fe00fde07c 100644
+--- a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
++++ b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
+@@ -84,6 +84,7 @@ protected:
+ #endif
+     QScopedPointer<QPlatformInputContext> m_inputContext;
+     QScopedPointer<QPlatformServices> m_services;
++    QPlatformScreen *m_screen;
+     mutable QScopedPointer<QPlatformNativeInterface> m_nativeInterface;
+ };
+ 
+diff --git a/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp b/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
+index 6fa5a8a2b3..1f49f0aefd 100644
+--- a/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
++++ b/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
+@@ -48,6 +48,7 @@
+ #include <qpa/qplatformnativeinterface.h>
+ #include <QtPlatformHeaders/qwglnativecontext.h>
+ 
++#include <private/qsystemlibrary_p.h>
+ #include <algorithm>
+ 
+ #include <wingdi.h>
+@@ -162,19 +163,25 @@ QFunctionPointer QWindowsOpengl32DLL::resolve(const char *name)
+ 
+ bool QWindowsOpengl32DLL::init(bool softwareRendering)
+ {
+-    const QByteArray opengl32 = QByteArrayLiteral("opengl32.dll");
+-    const QByteArray swopengl = QByteArrayLiteral("opengl32sw.dll");
++    const QByteArray opengl32 = QByteArrayLiteral("opengl32");
++    const QByteArray swopengl = QByteArrayLiteral("opengl32sw");
++    bool useSystemLib = false;
+ 
+     QByteArray openglDll = qgetenv("QT_OPENGL_DLL");
+-    if (openglDll.isEmpty())
++    if (openglDll.isEmpty()) {
+         openglDll = softwareRendering ? swopengl : opengl32;
++        useSystemLib = !softwareRendering;
++    }
+ 
+     openglDll = openglDll.toLower();
+     m_nonOpengl32 = openglDll != opengl32;
+ 
+     qCDebug(lcQpaGl) << "Qt: Using WGL and OpenGL from" << openglDll;
+ 
+-    m_lib = ::LoadLibraryA(openglDll.constData());
++    if (useSystemLib)
++        m_lib = QSystemLibrary::load((wchar_t*)(QString::fromLatin1(openglDll).utf16()));
++    else
++        m_lib = LoadLibraryA(openglDll.constData());
+     if (!m_lib) {
+         qErrnoWarning(::GetLastError(), "Failed to load %s", openglDll.constData());
+         return false;
+@@ -184,7 +191,7 @@ bool QWindowsOpengl32DLL::init(bool softwareRendering)
+         // Load opengl32.dll always. GDI functions like ChoosePixelFormat do
+         // GetModuleHandle for opengl32.dll and behave differently (and call back into
+         // opengl32) when the module is present. This is fine for dummy contexts and windows.
+-        ::LoadLibraryA("opengl32.dll");
++        QSystemLibrary::load(L"opengl32");
+     }
+ 
+     wglCreateContext = reinterpret_cast<HGLRC (WINAPI *)(HDC)>(resolve("wglCreateContext"));
+diff --git a/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp b/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
+index d7d186e804..9eb4011bf2 100644
+--- a/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
++++ b/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
+@@ -49,6 +49,7 @@
+ #include <QtCore/qstandardpaths.h>
+ #include <QtCore/qlibraryinfo.h>
+ #include <QtCore/qhash.h>
++#include <private/qsystemlibrary_p.h>
+ 
+ #ifndef QT_NO_OPENGL
+ #include <private/qopengl_p.h>
+@@ -396,7 +397,7 @@ bool QWindowsOpenGLTester::testDesktopGL()
+ 
+     // Test #1: Load opengl32.dll and try to resolve an OpenGL 2 function.
+     // This will typically fail on systems that do not have a real OpenGL driver.
+-    lib = LoadLibraryA("opengl32.dll");
++    lib = QSystemLibrary::load(L"opengl32");
+     if (lib) {
+         CreateContext = reinterpret_cast<CreateContextType>(
+             reinterpret_cast<QFunctionPointer>(::GetProcAddress(lib, "wglCreateContext")));
+diff --git a/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp b/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
+index 1afa00cfc9..118af6ce73 100644
+--- a/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
++++ b/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
+@@ -41,6 +41,7 @@
+ 
+ #include <QRect>
+ #include <QList>
++#include <QMap>
+ #include <QDebug>
+ 
+ #include <qmath.h>
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp b/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
+index 9e2a37a6a1..e6e175a118 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
+@@ -488,12 +488,12 @@ void QXcbConnection::printXcbError(const char *message, xcb_generic_error_t *err
+     uint clamped_error_code = qMin<uint>(error->error_code, (sizeof(xcb_errors) / sizeof(xcb_errors[0])) - 1);
+     uint clamped_major_code = qMin<uint>(error->major_code, (sizeof(xcb_protocol_request_codes) / sizeof(xcb_protocol_request_codes[0])) - 1);
+ 
+-    qCWarning(lcQpaXcb, "%s: %d (%s), sequence: %d, resource id: %d, major code: %d (%s), minor code: %d",
+-             message,
+-             int(error->error_code), xcb_errors[clamped_error_code],
+-             int(error->sequence), int(error->resource_id),
+-             int(error->major_code), xcb_protocol_request_codes[clamped_major_code],
+-             int(error->minor_code));
++    qCDebug(lcQpaXcb, "%s: %d (%s), sequence: %d, resource id: %d, major code: %d (%s), minor code: %d",
++            message,
++            int(error->error_code), xcb_errors[clamped_error_code],
++            int(error->sequence), int(error->resource_id),
++            int(error->major_code), xcb_protocol_request_codes[clamped_major_code],
++            int(error->minor_code));
+ }
+ 
+ static Qt::MouseButtons translateMouseButtons(int s)
+@@ -702,6 +702,8 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
+             QXcbVirtualDesktop *virtualDesktop = virtualDesktopForRootWindow(propertyNotify->window);
+             if (virtualDesktop)
+                 virtualDesktop->updateWorkArea();
++        } else if (propertyNotify->atom == atom(QXcbAtom::_NET_SUPPORTED)) {
++            m_wmSupport->updateNetWMAtoms();
+         } else {
+             HANDLE_PLATFORM_WINDOW_EVENT(xcb_property_notify_event_t, window, handlePropertyNotifyEvent);
+         }
+@@ -750,7 +752,7 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
+                 case XCB_XKB_NEW_KEYBOARD_NOTIFY: {
+                     xcb_xkb_new_keyboard_notify_event_t *ev = &xkb_event->new_keyboard_notify;
+                     if (ev->changed & XCB_XKB_NKN_DETAIL_KEYCODES)
+-                        m_keyboard->updateKeymap(ev);
++                        m_keyboard->updateKeymap();
+                     break;
+                 }
+                 default:
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp b/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
+index 76869ced60..02d2eebb56 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
+@@ -274,8 +274,7 @@ QPlatformWindow *QXcbIntegration::createForeignWindow(QWindow *window, WId nativ
+ #ifndef QT_NO_OPENGL
+ QPlatformOpenGLContext *QXcbIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
+ {
+-    QXcbScreen *screen = static_cast<QXcbScreen *>(context->screen()->handle());
+-    QXcbGlIntegration *glIntegration = screen->connection()->glIntegration();
++    QXcbGlIntegration *glIntegration = defaultConnection()->glIntegration();
+     if (!glIntegration) {
+         qWarning("QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled");
+         return nullptr;
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+index efecd7e2d1..e8286381a2 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+@@ -365,17 +365,6 @@ void QXcbKeyboard::updateKeymap(xcb_mapping_notify_event_t *event)
+     updateKeymap();
+ }
+ 
+-void QXcbKeyboard::updateKeymap(xcb_xkb_new_keyboard_notify_event_t *event)
+-{
+-    if (!event)
+-        return;
+-
+-    if (event->deviceID != event->oldDeviceID)
+-        m_config = false;
+-
+-    updateKeymap();
+-}
+-
+ void QXcbKeyboard::updateKeymap()
+ {
+     KeysymModifierMap keysymMods;
+@@ -383,6 +372,8 @@ void QXcbKeyboard::updateKeymap()
+         keysymMods = keysymsToModifiers();
+     updateModifiers(keysymMods);
+ 
++    m_config = true;
++
+     if (!m_xkbContext) {
+         m_xkbContext.reset(xkb_context_new(XKB_CONTEXT_NO_DEFAULT_INCLUDES));
+         if (!m_xkbContext) {
+@@ -398,13 +389,8 @@ void QXcbKeyboard::updateKeymap()
+     if (connection()->hasXKB()) {
+         m_xkbKeymap.reset(xkb_x11_keymap_new_from_device(m_xkbContext.get(), xcb_connection(),
+                                                          core_device_id, XKB_KEYMAP_COMPILE_NO_FLAGS));
+-        if (m_xkbKeymap) {
+-            if (m_config)
+-                m_xkbState.reset(xkb_state_new(m_xkbKeymap.get()));
+-            else
+-                m_xkbState.reset(xkb_x11_state_new_from_device(m_xkbKeymap.get(), xcb_connection(), core_device_id));
+-
+-        }
++        if (m_xkbKeymap)
++            m_xkbState.reset(xkb_x11_state_new_from_device(m_xkbKeymap.get(), xcb_connection(), core_device_id));
+     } else {
+         m_xkbKeymap.reset(keymapFromCore(keysymMods));
+         if (m_xkbKeymap)
+@@ -425,8 +411,6 @@ void QXcbKeyboard::updateKeymap()
+     updateXKBMods();
+ 
+     QXkbCommon::verifyHasLatinLayout(m_xkbKeymap.get());
+-
+-    m_config = true;
+ }
+ 
+ QList<int> QXcbKeyboard::possibleKeys(const QKeyEvent *event) const
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
+index b652c85fe3..0ee08aeff2 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
++++ b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
+@@ -69,7 +69,6 @@ public:
+ 
+     Qt::KeyboardModifiers translateModifiers(int s) const;
+     void updateKeymap(xcb_mapping_notify_event_t *event);
+-    void updateKeymap(xcb_xkb_new_keyboard_notify_event_t *event);
+     void updateKeymap();
+     QList<int> possibleKeys(const QKeyEvent *event) const;
+ 
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp b/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
+index ffda7b6a57..863e961f4c 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
+@@ -564,11 +564,6 @@ void QXcbWindow::setGeometry(const QRect &rect)
+ {
+     QPlatformWindow::setGeometry(rect);
+ 
+-    if (shouldDeferTask(Task::SetGeometry)) {
+-        m_deferredGeometry = rect;
+-        return;
+-    }
+-
+     propagateSizeHints();
+ 
+     QXcbScreen *currentScreen = xcbScreen();
+@@ -693,9 +688,6 @@ void QXcbWindow::setVisible(bool visible)
+ 
+ void QXcbWindow::show()
+ {
+-    if (shouldDeferTask(Task::Map))
+-        return;
+-
+     if (window()->isTopLevel()) {
+ 
+         // update WM_NORMAL_HINTS
+@@ -706,7 +698,7 @@ void QXcbWindow::show()
+         if (isTransient(window())) {
+             const QWindow *tp = window()->transientParent();
+             if (tp && tp->handle())
+-                transientXcbParent = static_cast<const QXcbWindow *>(tp->handle())->winId();
++                transientXcbParent = tp->handle()->winId();
+             // Default to client leader if there is no transient parent, else modal dialogs can
+             // be hidden by their parents.
+             if (!transientXcbParent)
+@@ -746,10 +738,6 @@ void QXcbWindow::show()
+ 
+ void QXcbWindow::hide()
+ {
+-    if (shouldDeferTask(Task::Unmap))
+-        return;
+-
+-    m_wmStateValid = false;
+     xcb_unmap_window(xcb_connection(), m_window);
+ 
+     // send synthetic UnmapNotify event according to icccm 4.1.4
+@@ -909,9 +897,6 @@ QXcbWindow::NetWmStates QXcbWindow::netWmStates()
+ 
+ void QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
+ {
+-    if (shouldDeferTask(Task::SetWindowFlags))
+-        return;
+-
+     Qt::WindowType type = static_cast<Qt::WindowType>(int(flags & Qt::WindowType_Mask));
+ 
+     if (type == Qt::ToolTip)
+@@ -941,8 +926,6 @@ void QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
+ 
+     setTransparentForMouseEvents(flags & Qt::WindowTransparentForInput);
+     updateDoesNotAcceptFocus(flags & Qt::WindowDoesNotAcceptFocus);
+-
+-    m_isWmManagedWindow = !(flags & Qt::X11BypassWindowManagerHint);
+ }
+ 
+ void QXcbWindow::setMotifWmHints(Qt::WindowFlags flags)
+@@ -1142,9 +1125,6 @@ void QXcbWindow::setWindowState(Qt::WindowStates state)
+     if (state == m_windowState)
+         return;
+ 
+-    if (shouldDeferTask(Task::SetWindowState))
+-        return;
+-
+     // unset old state
+     if (m_windowState & Qt::WindowMinimized)
+         xcb_map_window(xcb_connection(), m_window);
+@@ -1350,6 +1330,12 @@ void QXcbWindow::setWindowIcon(const QIcon &icon)
+     }
+ 
+     if (!icon_data.isEmpty()) {
++        // Ignore icon exceeding maximum xcb request length
++        if (icon_data.size() > xcb_get_maximum_request_length(xcb_connection())) {
++            qWarning("Ignoring window icon: Size %llu exceeds maximum xcb request length %u.",
++                     icon_data.size(), xcb_get_maximum_request_length(xcb_connection()));
++            return;
++        }
+         xcb_change_property(xcb_connection(),
+                             XCB_PROP_MODE_REPLACE,
+                             m_window,
+@@ -1639,7 +1625,7 @@ void QXcbWindow::setWmWindowType(QXcbWindowFunctions::WmWindowTypes types, Qt::W
+         break;
+     }
+ 
+-    if ((flags & Qt::FramelessWindowHint) && !(type & QXcbWindowFunctions::KdeOverride)) {
++    if ((flags & Qt::FramelessWindowHint) && !(types & QXcbWindowFunctions::KdeOverride)) {
+         // override netwm type - quick and easy for KDE noborder
+         atoms.append(atom(QXcbAtom::_KDE_NET_WM_WINDOW_TYPE_OVERRIDE));
+     }
+@@ -1894,10 +1880,6 @@ void QXcbWindow::handleUnmapNotifyEvent(const xcb_unmap_notify_event_t *event)
+     if (event->window == m_window) {
+         m_mapped = false;
+         QWindowSystemInterface::handleExposeEvent(window(), QRegion());
+-        if (!m_isWmManagedWindow || parent()) {
+-            m_wmStateValid = true;
+-            handleDeferredTasks();
+-        }
+     }
+ }
+ 
+@@ -2212,98 +2194,30 @@ void QXcbWindow::handleLeaveNotifyEvent(const xcb_leave_notify_event_t *event)
+     handleLeaveNotifyEvent(event->root_x, event->root_y, event->mode, event->detail, event->time);
+ }
+ 
+-bool QXcbWindow::shouldDeferTask(Task task)
+-{
+-    if (m_wmStateValid)
+-        return false;
+-
+-    m_deferredTasks.append(task);
+-    return true;
+-}
+-
+-void QXcbWindow::handleDeferredTasks()
+-{
+-    Q_ASSERT(m_wmStateValid == true);
+-    if (m_deferredTasks.isEmpty())
+-        return;
+-
+-    bool map = false;
+-    bool unmap = false;
+-
+-    QVector<Task> tasks;
+-    for (auto taskIt = m_deferredTasks.rbegin(); taskIt != m_deferredTasks.rend(); ++taskIt) {
+-        if (!tasks.contains(*taskIt))
+-            tasks.prepend(*taskIt);
+-    }
+-
+-    for (Task task : tasks) {
+-        switch (task) {
+-        case Task::Map:
+-            map = true;
+-            unmap = false;
+-            break;
+-        case Task::Unmap:
+-            unmap = true;
+-            map = false;
+-            break;
+-        case Task::SetGeometry:
+-            setGeometry(m_deferredGeometry);
+-            break;
+-        case Task::SetWindowFlags:
+-            setWindowFlags(window()->flags());
+-            break;
+-        case Task::SetWindowState:
+-            setWindowState(window()->windowState());
+-            break;
+-        }
+-    }
+-    m_deferredTasks.clear();
+-
+-    if (map) {
+-        Q_ASSERT(unmap == false);
+-        show();
+-    }
+-    if (unmap) {
+-        Q_ASSERT(map == false);
+-        hide();
+-    }
+-}
+-
+ void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *event)
+ {
+     connection()->setTime(event->time);
+ 
+-    const bool wmStateChanged = event->atom == atom(QXcbAtom::WM_STATE);
+-    const bool netWmStateChanged = event->atom == atom(QXcbAtom::_NET_WM_STATE);
+-    if (netWmStateChanged || wmStateChanged) {
+-        if (wmStateChanged && !m_wmStateValid && m_isWmManagedWindow) {
+-            // ICCCM 4.1.4
+-            // Clients that want to re-use a client window (e.g. by mapping it again)
+-            // after withdrawing it must wait for the withdrawal to be complete before
+-            // proceeding. The preferred method for doing this is for clients to wait for
+-            // a window manager to update or remove the WM_STATE property.
+-            m_wmStateValid = true;
+-            handleDeferredTasks();
+-        }
+-        if (event->state == XCB_PROPERTY_DELETE)
++    const bool propertyDeleted = event->state == XCB_PROPERTY_DELETE;
++
++    if (event->atom == atom(QXcbAtom::_NET_WM_STATE) || event->atom == atom(QXcbAtom::WM_STATE)) {
++        if (propertyDeleted)
+             return;
+ 
+-        if (wmStateChanged) {
++        Qt::WindowStates newState = Qt::WindowNoState;
++
++        if (event->atom == atom(QXcbAtom::WM_STATE)) { // WM_STATE: Quick check for 'Minimize'.
+             auto reply = Q_XCB_REPLY(xcb_get_property, xcb_connection(),
+                                      0, m_window, atom(QXcbAtom::WM_STATE),
+                                      XCB_ATOM_ANY, 0, 1024);
+             if (reply && reply->format == 32 && reply->type == atom(QXcbAtom::WM_STATE)) {
+-                auto data = static_cast<const quint32 *>(xcb_get_property_value(reply.get()));
+-                if (reply->length != 0) {
+-                    const bool changedToWithdrawn = data[0] == XCB_ICCCM_WM_STATE_WITHDRAWN;
+-                    const bool changedToIconic = data[0] == XCB_ICCCM_WM_STATE_ICONIC;
+-                    m_minimized = changedToIconic || (changedToWithdrawn && m_minimized);
+-                }
++                const quint32 *data = (const quint32 *)xcb_get_property_value(reply.get());
++                if (reply->length != 0)
++                    m_minimized = (data[0] == XCB_ICCCM_WM_STATE_ICONIC
++                                   || (data[0] == XCB_ICCCM_WM_STATE_WITHDRAWN && m_minimized));
+             }
+         }
+ 
+-        // _NET_WM_STATE handling
+-        Qt::WindowStates newState = Qt::WindowNoState;
+         const NetWmStates states = netWmStates();
+         // _NET_WM_STATE_HIDDEN should be set by the Window Manager to indicate that a window would
+         // not be visible on the screen if its desktop/viewport were active and its coordinates were
+@@ -2325,6 +2239,7 @@ void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *ev
+             if ((m_windowState & Qt::WindowMinimized) && connection()->mouseGrabber() == this)
+                 connection()->setMouseGrabber(nullptr);
+         }
++        return;
+     } else if (event->atom == atom(QXcbAtom::_NET_FRAME_EXTENTS)) {
+         m_dirtyFrameMargins = true;
+     }
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbwindow.h b/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
+index 55af9279b1..6f5c1f5ed9 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
++++ b/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
+@@ -74,14 +74,6 @@ public:
+ 
+     Q_DECLARE_FLAGS(NetWmStates, NetWmState)
+ 
+-    enum Task {
+-        Map,
+-        Unmap,
+-        SetGeometry,
+-        SetWindowFlags,
+-        SetWindowState
+-    };
+-
+     QXcbWindow(QWindow *window);
+     ~QXcbWindow();
+ 
+@@ -151,9 +143,6 @@ public:
+ 
+     QXcbWindow *toWindow() override;
+ 
+-    bool shouldDeferTask(Task task);
+-    void handleDeferredTasks();
+-
+     void handleMouseEvent(xcb_timestamp_t time, const QPoint &local, const QPoint &global,
+                           Qt::KeyboardModifiers modifiers, QEvent::Type type, Qt::MouseEventSource source);
+ 
+@@ -292,11 +281,6 @@ protected:
+     int m_swapInterval = -1;
+ 
+     qreal m_sizeHintsScaleFactor = 1.0;
+-
+-    bool m_wmStateValid = true;
+-    QVector<Task> m_deferredTasks;
+-    bool m_isWmManagedWindow = true;
+-    QRect m_deferredGeometry;
+ };
+ 
+ class QXcbForeignWindow : public QXcbWindow
+diff --git a/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp b/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
+index d9d117faeb..640b49daa0 100644
+--- a/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
++++ b/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
+@@ -85,6 +85,7 @@ QGtk3MenuItem::QGtk3MenuItem()
+       m_checkable(false),
+       m_checked(false),
+       m_enabled(true),
++      m_exclusive(false),
+       m_underline(false),
+       m_invalid(true),
+       m_menu(nullptr),
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
+index 0048bbc1e6..396e7f6d1c 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
+@@ -102,15 +102,12 @@ const QDBusArgument &operator >>(const QDBusArgument &arg, QXdgDesktopPortalFile
+ class QXdgDesktopPortalFileDialogPrivate
+ {
+ public:
+-    QXdgDesktopPortalFileDialogPrivate(QPlatformFileDialogHelper *nativeFileDialog)
++    QXdgDesktopPortalFileDialogPrivate(QPlatformFileDialogHelper *nativeFileDialog, uint fileChooserPortalVersion)
+         : nativeFileDialog(nativeFileDialog)
++        , fileChooserPortalVersion(fileChooserPortalVersion)
+     { }
+ 
+-    WId winId = 0;
+-    bool directoryMode = false;
+-    bool modal = false;
+-    bool multipleFiles = false;
+-    bool saveFile = false;
++    QEventLoop loop;
+     QString acceptLabel;
+     QString directory;
+     QString title;
+@@ -121,19 +118,27 @@ public:
+     QString selectedMimeTypeFilter;
+     QString selectedNameFilter;
+     QStringList selectedFiles;
+-    QPlatformFileDialogHelper *nativeFileDialog = nullptr;
++    std::unique_ptr<QPlatformFileDialogHelper> nativeFileDialog;
++    uint fileChooserPortalVersion = 0;
++    bool failedToOpen = false;
++    bool directoryMode = false;
++    bool multipleFiles = false;
++    bool saveFile = false;
+ };
+ 
+-QXdgDesktopPortalFileDialog::QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog)
++QXdgDesktopPortalFileDialog::QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog, uint fileChooserPortalVersion)
+     : QPlatformFileDialogHelper()
+-    , d_ptr(new QXdgDesktopPortalFileDialogPrivate(nativeFileDialog))
++    , d_ptr(new QXdgDesktopPortalFileDialogPrivate(nativeFileDialog, fileChooserPortalVersion))
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+     if (d->nativeFileDialog) {
+-        connect(d->nativeFileDialog, SIGNAL(accept()), this, SIGNAL(accept()));
+-        connect(d->nativeFileDialog, SIGNAL(reject()), this, SIGNAL(reject()));
++        connect(d->nativeFileDialog.get(), SIGNAL(accept()), this, SIGNAL(accept()));
++        connect(d->nativeFileDialog.get(), SIGNAL(reject()), this, SIGNAL(reject()));
+     }
++
++    d->loop.connect(this, SIGNAL(accept()), SLOT(quit()));
++    d->loop.connect(this, SIGNAL(reject()), SLOT(quit()));
+ }
+ 
+ QXdgDesktopPortalFileDialog::~QXdgDesktopPortalFileDialog()
+@@ -177,7 +182,7 @@ void QXdgDesktopPortalFileDialog::initializeDialog()
+     setDirectory(options()->initialDirectory());
+ }
+ 
+-void QXdgDesktopPortalFileDialog::openPortal()
++void QXdgDesktopPortalFileDialog::openPortal(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent)
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+@@ -185,13 +190,13 @@ void QXdgDesktopPortalFileDialog::openPortal()
+                                                           QLatin1String("/org/freedesktop/portal/desktop"),
+                                                           QLatin1String("org.freedesktop.portal.FileChooser"),
+                                                           d->saveFile ? QLatin1String("SaveFile") : QLatin1String("OpenFile"));
+-    QString parentWindowId = QLatin1String("x11:") + QString::number(d->winId, 16);
++    QString parentWindowId = QLatin1String("x11:") + QString::number(parent ? parent->winId() : 0, 16);
+ 
+     QVariantMap options;
+     if (!d->acceptLabel.isEmpty())
+         options.insert(QLatin1String("accept_label"), d->acceptLabel);
+ 
+-    options.insert(QLatin1String("modal"), d->modal);
++    options.insert(QLatin1String("modal"), windowModality != Qt::NonModal);
+     options.insert(QLatin1String("multiple"), d->multipleFiles);
+     options.insert(QLatin1String("directory"), d->directoryMode);
+ 
+@@ -290,10 +295,18 @@ void QXdgDesktopPortalFileDialog::openPortal()
+ 
+     QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
+     QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingCall);
+-    connect(watcher, &QDBusPendingCallWatcher::finished, this, [this] (QDBusPendingCallWatcher *watcher) {
++    connect(watcher, &QDBusPendingCallWatcher::finished, this, [=] (QDBusPendingCallWatcher *watcher) {
+         QDBusPendingReply<QDBusObjectPath> reply = *watcher;
+-        if (reply.isError()) {
+-            Q_EMIT reject();
++        // Any error means the dialog is not shown and we need to fallback
++        d->failedToOpen = reply.isError();
++        if (d->failedToOpen) {
++            if (d->nativeFileDialog) {
++                d->nativeFileDialog->show(windowFlags, windowModality, parent);
++                if (d->loop.isRunning())
++                    d->nativeFileDialog->exec();
++            } else {
++                Q_EMIT reject();
++            }
+         } else {
+             QDBusConnection::sessionBus().connect(nullptr,
+                                                   reply.value().path(),
+@@ -302,6 +315,7 @@ void QXdgDesktopPortalFileDialog::openPortal()
+                                                   this,
+                                                   SLOT(gotResponse(uint,QVariantMap)));
+         }
++        watcher->deleteLater();
+     });
+ }
+ 
+@@ -326,7 +340,7 @@ QUrl QXdgDesktopPortalFileDialog::directory() const
+ {
+     Q_D(const QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog())
+         return d->nativeFileDialog->directory();
+ 
+     return d->directory;
+@@ -348,7 +362,7 @@ QList<QUrl> QXdgDesktopPortalFileDialog::selectedFiles() const
+ {
+     Q_D(const QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog())
+         return d->nativeFileDialog->selectedFiles();
+ 
+     QList<QUrl> files;
+@@ -403,16 +417,13 @@ void QXdgDesktopPortalFileDialog::exec()
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly)) {
++    if (d->nativeFileDialog && useNativeFileDialog()) {
+         d->nativeFileDialog->exec();
+         return;
+     }
+ 
+     // HACK we have to avoid returning until we emit that the dialog was accepted or rejected
+-    QEventLoop loop;
+-    loop.connect(this, SIGNAL(accept()), SLOT(quit()));
+-    loop.connect(this, SIGNAL(reject()), SLOT(quit()));
+-    loop.exec();
++    d->loop.exec();
+ }
+ 
+ void QXdgDesktopPortalFileDialog::hide()
+@@ -429,13 +440,10 @@ bool QXdgDesktopPortalFileDialog::show(Qt::WindowFlags windowFlags, Qt::WindowMo
+ 
+     initializeDialog();
+ 
+-    d->modal = windowModality != Qt::NonModal;
+-    d->winId = parent ? parent->winId() : 0;
+-
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog(OpenFallback))
+         return d->nativeFileDialog->show(windowFlags, windowModality, parent);
+ 
+-    openPortal();
++    openPortal(windowFlags, windowModality, parent);
+ 
+     return true;
+ }
+@@ -465,4 +473,21 @@ void QXdgDesktopPortalFileDialog::gotResponse(uint response, const QVariantMap &
+     }
+ }
+ 
++bool QXdgDesktopPortalFileDialog::useNativeFileDialog(QXdgDesktopPortalFileDialog::FallbackType fallbackType) const
++{
++    Q_D(const QXdgDesktopPortalFileDialog);
++
++    if (d->failedToOpen && fallbackType != OpenFallback)
++        return true;
++
++    if (d->fileChooserPortalVersion < 3) {
++        if (options()->fileMode() == QFileDialogOptions::Directory)
++            return true;
++        else if (options()->fileMode() == QFileDialogOptions::DirectoryOnly)
++            return true;
++    }
++
++    return false;
++}
++
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
+index 4f4de96ecf..65e22a5cf2 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
+@@ -51,6 +51,11 @@ class QXdgDesktopPortalFileDialog : public QPlatformFileDialogHelper
+     Q_OBJECT
+     Q_DECLARE_PRIVATE(QXdgDesktopPortalFileDialog)
+ public:
++    enum FallbackType {
++        GenericFallback,
++        OpenFallback
++    };
++
+     enum ConditionType : uint {
+         GlobalPattern = 0,
+         MimeType = 1
+@@ -69,7 +74,7 @@ public:
+     };
+     typedef QVector<Filter> FilterList;
+ 
+-    QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog = nullptr);
++    QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog = nullptr, uint fileChooserPortalVersion = 0);
+     ~QXdgDesktopPortalFileDialog();
+ 
+     bool defaultNameFilterDisables() const override;
+@@ -92,7 +97,8 @@ private Q_SLOTS:
+ 
+ private:
+     void initializeDialog();
+-    void openPortal();
++    void openPortal(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent);
++    bool useNativeFileDialog(FallbackType fallbackType = GenericFallback) const;
+ 
+     QScopedPointer<QXdgDesktopPortalFileDialogPrivate> d_ptr;
+ };
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
+index fb324afbd8..b809503122 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
+@@ -111,6 +111,7 @@ QXdgDesktopPortalTheme::QXdgDesktopPortalTheme()
+         if (reply.isValid()) {
+             d->fileChooserPortalVersion = reply.value().toUInt();
+         }
++        watcher->deleteLater();
+     });
+ }
+ 
+@@ -152,11 +153,12 @@ QPlatformDialogHelper* QXdgDesktopPortalTheme::createPlatformDialogHelper(Dialog
+ {
+     Q_D(const QXdgDesktopPortalTheme);
+ 
+-    if (type == FileDialog) {
++    if (type == FileDialog && d->fileChooserPortalVersion) {
+         // Older versions of FileChooser portal don't support opening directories, therefore we fallback
+         // to native file dialog opened inside the sandbox to open a directory.
+-        if (d->fileChooserPortalVersion < 3 && d->baseTheme->usePlatformNativeDialog(type))
+-            return new QXdgDesktopPortalFileDialog(static_cast<QPlatformFileDialogHelper*>(d->baseTheme->createPlatformDialogHelper(type)));
++        if (d->baseTheme->usePlatformNativeDialog(type))
++            return new QXdgDesktopPortalFileDialog(static_cast<QPlatformFileDialogHelper*>(d->baseTheme->createPlatformDialogHelper(type)),
++                                                   d->fileChooserPortalVersion);
+ 
+         return new QXdgDesktopPortalFileDialog;
+     }
+diff --git a/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp b/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
+index 43d5e119ad..1f9cbc4565 100644
+--- a/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
++++ b/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
+@@ -89,8 +89,10 @@ void QCupsPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &v
+         break;
+     case PPK_Duplex: {
+         QPrint::DuplexMode mode = QPrint::DuplexMode(value.toInt());
+-        if (mode != d->duplex && d->m_printDevice.supportedDuplexModes().contains(mode))
++        if (d->m_printDevice.supportedDuplexModes().contains(mode)) {
+             d->duplex = mode;
++            d->duplexRequestedExplicitly = true;
++        }
+         break;
+     }
+     case PPK_PrinterName:
+@@ -277,9 +279,12 @@ void QCupsPrintEnginePrivate::changePrinter(const QString &newPrinter)
+     m_printDevice.swap(printDevice);
+     printerName = m_printDevice.id();
+ 
+-    // Check if new printer supports current settings, otherwise us defaults
+-    if (duplex != QPrint::DuplexAuto && !m_printDevice.supportedDuplexModes().contains(duplex))
++    // in case a duplex value was explicitly set, check if new printer supports current value,
++    // otherwise use device default
++    if (!duplexRequestedExplicitly || !m_printDevice.supportedDuplexModes().contains(duplex)) {
+         duplex = m_printDevice.defaultDuplexMode();
++        duplexRequestedExplicitly = false;
++    }
+     QPrint::ColorMode colorMode = grayscale ? QPrint::GrayScale : QPrint::Color;
+     if (!m_printDevice.supportedColorModes().contains(colorMode))
+         grayscale = m_printDevice.defaultColorMode() == QPrint::GrayScale;
+diff --git a/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h b/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
+index c021b0c643..8f81fe478d 100644
+--- a/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
++++ b/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
+@@ -100,6 +100,7 @@ private:
+     QStringList cupsOptions;
+     QString cupsTempFile;
+     QPrint::DuplexMode duplex;
++    bool duplexRequestedExplicitly = false;
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp b/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
+index 67e7154fa6..40876152e5 100644
+--- a/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
++++ b/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
+@@ -817,7 +817,7 @@ bool QIBaseResultPrivate::writeArray(int column, const QList<QVariant> &list)
+     ba.resize(int(bufLen));
+ 
+     if (list.size() > arraySize) {
+-        error = QLatin1String("Array size missmatch: size of %1 is %2, size of provided list is %3");
++        error = QLatin1String("Array size mismatch: size of %1 is %2, size of provided list is %3");
+         error = error.arg(QLatin1String(sqlname)).arg(arraySize).arg(list.size());
+         q->setLastError(QSqlError(error, QLatin1String(""), QSqlError::StatementError));
+         return false;
+diff --git a/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp b/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
+index 7ca055eea2..6bc9d46755 100644
+--- a/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
++++ b/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
+@@ -223,7 +223,7 @@ public:
+     struct QMyField
+     {
+         char *outField = nullptr;
+-        MYSQL_FIELD *myField = nullptr;
++        const MYSQL_FIELD *myField = nullptr;
+         QMetaType::Type type = QMetaType::UnknownType;
+         my_bool nullIndicator = false;
+         ulong bufLength = 0ul;
+@@ -361,7 +361,7 @@ static bool qIsInteger(int t)
+ void QMYSQLResultPrivate::bindBlobs()
+ {
+     int i;
+-    MYSQL_FIELD *fieldInfo;
++    const MYSQL_FIELD *fieldInfo;
+     MYSQL_BIND *bind;
+ 
+     for(i = 0; i < fields.count(); ++i) {
+@@ -379,7 +379,6 @@ void QMYSQLResultPrivate::bindBlobs()
+ bool QMYSQLResultPrivate::bindInValues()
+ {
+     MYSQL_BIND *bind;
+-    char *field;
+     int i = 0;
+ 
+     if (!meta)
+@@ -392,35 +391,34 @@ bool QMYSQLResultPrivate::bindInValues()
+     inBinds = new MYSQL_BIND[fields.size()];
+     memset(inBinds, 0, fields.size() * sizeof(MYSQL_BIND));
+ 
+-    MYSQL_FIELD *fieldInfo;
++    const MYSQL_FIELD *fieldInfo;
+ 
+     while((fieldInfo = mysql_fetch_field(meta))) {
++        bind = &inBinds[i];
++
+         QMyField &f = fields[i];
+         f.myField = fieldInfo;
+-
++        bind->buffer_length = f.bufLength = fieldInfo->length + 1;
++        bind->buffer_type = fieldInfo->type;
+         f.type = qDecodeMYSQLType(fieldInfo->type, fieldInfo->flags);
+         if (qIsBlob(fieldInfo->type)) {
+             // the size of a blob-field is available as soon as we call
+             // mysql_stmt_store_result()
+             // after mysql_stmt_exec() in QMYSQLResult::exec()
+-            fieldInfo->length = 0;
++            bind->buffer_length = f.bufLength = 0;
+             hasBlobs = true;
+         } else if (qIsInteger(f.type)) {
+-            fieldInfo->length = 8;
++            bind->buffer_length = f.bufLength = 8;
+         } else {
+-            fieldInfo->type = MYSQL_TYPE_STRING;
++            bind->buffer_type = MYSQL_TYPE_STRING;
+         }
+-        bind = &inBinds[i];
+-        field = new char[fieldInfo->length + 1];
+-        memset(field, 0, fieldInfo->length + 1);
+ 
+-        bind->buffer_type = fieldInfo->type;
+-        bind->buffer = field;
+-        bind->buffer_length = f.bufLength = fieldInfo->length + 1;
+         bind->is_null = &f.nullIndicator;
+         bind->length = &f.bufLength;
+         bind->is_unsigned = fieldInfo->flags & UNSIGNED_FLAG ? 1 : 0;
+-        f.outField=field;
++
++        char *field = new char[bind->buffer_length + 1]{};
++        bind->buffer = f.outField = field;
+ 
+         ++i;
+     }
+@@ -1369,20 +1367,20 @@ bool QMYSQLDriver::open(const QString& db,
+     }
+ 
+ #if MYSQL_VERSION_ID >= 50007
+-    if (mysql_get_client_version() >= 50503 && mysql_get_server_version(d->mysql) >= 50503) {
+-        // force the communication to be utf8mb4 (only utf8mb4 supports 4-byte characters)
+-        mysql_set_character_set(d->mysql, "utf8mb4");
++    // force the communication to be utf8mb4 (only utf8mb4 supports 4-byte characters)
++    if (mysql_set_character_set(d->mysql, "utf8mb4")) {
++        // this failed, try forcing it to utf (BMP only)
++        if (mysql_set_character_set(d->mysql, "utf8"))
++            qWarning() << "MySQL: Unable to set the client character set to utf8.";
+ #if QT_CONFIG(textcodec)
+-        d->tc = QTextCodec::codecForName("UTF-8");
++        else
++            d->tc = codec(d->mysql);
+ #endif
+-    } else
+-    {
+-        // force the communication to be utf8
+-        mysql_set_character_set(d->mysql, "utf8");
++    }
+ #if QT_CONFIG(textcodec)
+-        d->tc = codec(d->mysql);
++    else
++        d->tc = QTextCodec::codecForName("UTF-8");
+ #endif
+-    }
+ #endif  // MYSQL_VERSION_ID >= 50007
+ 
+     d->preparedQuerysEnabled = checkPreparedQueries(d->mysql);
+diff --git a/qtbase/src/printsupport/dialogs/images/print-24.png b/qtbase/src/printsupport/dialogs/images/printer-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/print-24.png
+rename to src/printsupport/dialogs/images/printer-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/print-32.png b/qtbase/src/printsupport/dialogs/images/printer-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/print-32.png
+rename to src/printsupport/dialogs/images/printer-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-sided-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-facing-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-sided-24.png
+rename to src/printsupport/dialogs/images/view-pages-facing-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-sided-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-facing-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-sided-32.png
+rename to src/printsupport/dialogs/images/view-pages-facing-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-multi-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-overview-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-multi-24.png
+rename to src/printsupport/dialogs/images/view-pages-overview-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-multi-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-overview-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-multi-32.png
+rename to src/printsupport/dialogs/images/view-pages-overview-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-one-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-single-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-one-24.png
+rename to src/printsupport/dialogs/images/view-pages-single-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-one-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-single-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-one-32.png
+rename to src/printsupport/dialogs/images/view-pages-single-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-page-24.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-page-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-page-24.png
+rename to src/printsupport/dialogs/images/zoom-fit-page-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-page-32.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-page-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-page-32.png
+rename to src/printsupport/dialogs/images/zoom-fit-page-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-width-24.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-width-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-width-24.png
+rename to src/printsupport/dialogs/images/zoom-fit-width-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-width-32.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-width-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-width-32.png
+rename to src/printsupport/dialogs/images/zoom-fit-width-32.png
+diff --git a/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp b/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
+index 78e5b8d1ef..2a28516719 100644
+--- a/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
++++ b/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
+@@ -532,6 +532,7 @@ void QPageSetupWidget::updateWidget()
+ void QPageSetupWidget::setupPrinter() const
+ {
+     m_printer->setPageLayout(m_pageLayout);
++    m_printer->setPageOrientation(m_pageLayout.orientation());
+ #if QT_CONFIG(cups)
+     QCUPSSupport::PagesPerSheet pagesPerSheet = qvariant_cast<QCUPSSupport::PagesPerSheet>(m_ui.pagesPerSheetCombo->currentData()
+ );
+diff --git a/qtbase/src/printsupport/dialogs/qprintdialog.qrc b/qtbase/src/printsupport/dialogs/qprintdialog.qrc
+index 5a579baa55..10b8e1d341 100644
+--- a/qtbase/src/printsupport/dialogs/qprintdialog.qrc
++++ b/qtbase/src/printsupport/dialogs/qprintdialog.qrc
+@@ -1,9 +1,9 @@
+ <!DOCTYPE RCC><RCC version="1.0">
+ <qresource prefix="/qt-project.org/dialogs/qprintpreviewdialog">
+-<file>images/fit-page-24.png</file>
+-<file>images/fit-page-32.png</file>
+-<file>images/fit-width-24.png</file>
+-<file>images/fit-width-32.png</file>
++<file>images/zoom-fit-page-24.png</file>
++<file>images/zoom-fit-page-32.png</file>
++<file>images/zoom-fit-width-24.png</file>
++<file>images/zoom-fit-width-32.png</file>
+ <file>images/go-first-24.png</file>
+ <file>images/go-first-32.png</file>
+ <file>images/go-last-24.png</file>
+@@ -18,14 +18,14 @@
+ <file>images/layout-portrait-32.png</file>
+ <file>images/page-setup-24.png</file>
+ <file>images/page-setup-32.png</file>
+-<file>images/print-24.png</file>
+-<file>images/print-32.png</file>
+-<file>images/view-page-multi-24.png</file>
+-<file>images/view-page-multi-32.png</file>
+-<file>images/view-page-one-24.png</file>
+-<file>images/view-page-one-32.png</file>
+-<file>images/view-page-sided-24.png</file>
+-<file>images/view-page-sided-32.png</file>
++<file>images/printer-24.png</file>
++<file>images/printer-32.png</file>
++<file>images/view-pages-overview-24.png</file>
++<file>images/view-pages-overview-32.png</file>
++<file>images/view-pages-single-24.png</file>
++<file>images/view-pages-single-32.png</file>
++<file>images/view-pages-facing-24.png</file>
++<file>images/view-pages-facing-32.png</file>
+ <file>images/zoom-in-24.png</file>
+ <file>images/zoom-in-32.png</file>
+ <file>images/zoom-out-24.png</file>
+diff --git a/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp b/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
+index c5b845f4ec..5a5ba1d0a8 100644
+--- a/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
++++ b/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
+@@ -702,13 +702,14 @@ void QPrintDialogPrivate::selectPrinter(const QPrinter::OutputFormat outputForma
+         else
+             options.grayscale->setChecked(true);
+ 
+-        // keep duplex value explicitly set by user, if any, and selected printer supports it;
+-        // use device default otherwise
++        // duplex priorities to be as follows:
++        // 1) a user-selected duplex value in the dialog has highest prority
++        // 2) duplex value set in the QPrinter
+         QPrint::DuplexMode duplex;
+         if (explicitDuplexMode != QPrint::DuplexAuto && supportedDuplexMode.contains(explicitDuplexMode))
+             duplex = explicitDuplexMode;
+         else
+-            duplex = top->d->m_currentPrintDevice.defaultDuplexMode();
++            duplex = static_cast<QPrint::DuplexMode>(p->duplex());
+         switch (duplex) {
+         case QPrint::DuplexNone:
+             options.noDuplex->setChecked(true); break;
+@@ -1242,10 +1243,10 @@ void QUnixPrintWidgetPrivate::_q_printerChanged(int index)
+             QString filename = widget.filename->text();
+             widget.filename->setText(filename);
+             widget.lOutput->setEnabled(true);
+-            if (optionsPane)
+-                optionsPane->selectPrinter(QPrinter::PdfFormat);
+             printer->setOutputFormat(QPrinter::PdfFormat);
+             m_currentPrintDevice = QPrintDevice();
++            if (optionsPane)
++                optionsPane->selectPrinter(QPrinter::PdfFormat);
+             return;
+         }
+     }
+diff --git a/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp b/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
+index 39575d5f57..23b7e89538 100644
+--- a/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
++++ b/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
+@@ -352,7 +352,7 @@ void QPrintPreviewDialogPrivate::init(QPrinter *_printer)
+ static inline void qt_setupActionIcon(QAction *action, QLatin1String name)
+ {
+     QLatin1String imagePrefix(":/qt-project.org/dialogs/qprintpreviewdialog/images/");
+-    QIcon icon;
++    QIcon icon = QIcon::fromTheme(name);
+     icon.addFile(imagePrefix + name + QLatin1String("-24.png"), QSize(24, 24));
+     icon.addFile(imagePrefix + name + QLatin1String("-32.png"), QSize(32, 32));
+     action->setIcon(icon);
+@@ -383,8 +383,8 @@ void QPrintPreviewDialogPrivate::setupActions()
+     fitPageAction->setObjectName(QLatin1String("fitPageAction"));
+     fitWidthAction->setCheckable(true);
+     fitPageAction->setCheckable(true);
+-    qt_setupActionIcon(fitWidthAction, QLatin1String("fit-width"));
+-    qt_setupActionIcon(fitPageAction, QLatin1String("fit-page"));
++    qt_setupActionIcon(fitWidthAction, QLatin1String("zoom-fit-width"));
++    qt_setupActionIcon(fitPageAction, QLatin1String("zoom-fit-page"));
+     QObject::connect(fitGroup, SIGNAL(triggered(QAction*)), q, SLOT(_q_fit(QAction*)));
+ 
+     // Zoom
+@@ -410,9 +410,9 @@ void QPrintPreviewDialogPrivate::setupActions()
+     singleModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show single page"));
+     facingModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show facing pages"));
+     overviewModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show overview of all pages"));
+-    qt_setupActionIcon(singleModeAction, QLatin1String("view-page-one"));
+-    qt_setupActionIcon(facingModeAction, QLatin1String("view-page-sided"));
+-    qt_setupActionIcon(overviewModeAction, QLatin1String("view-page-multi"));
++    qt_setupActionIcon(singleModeAction, QLatin1String("view-pages-single"));
++    qt_setupActionIcon(facingModeAction, QLatin1String("view-pages-facing"));
++    qt_setupActionIcon(overviewModeAction, QLatin1String("view-pages-overview"));
+     singleModeAction->setObjectName(QLatin1String("singleModeAction"));
+     facingModeAction->setObjectName(QLatin1String("facingModeAction"));
+     overviewModeAction->setObjectName(QLatin1String("overviewModeAction"));
+@@ -426,7 +426,7 @@ void QPrintPreviewDialogPrivate::setupActions()
+     printerGroup = new QActionGroup(q);
+     printAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Print"));
+     pageSetupAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Page setup"));
+-    qt_setupActionIcon(printAction, QLatin1String("print"));
++    qt_setupActionIcon(printAction, QLatin1String("printer"));
+     qt_setupActionIcon(pageSetupAction, QLatin1String("page-setup"));
+     QObject::connect(printAction, SIGNAL(triggered(bool)), q, SLOT(_q_print()));
+     QObject::connect(pageSetupAction, SIGNAL(triggered(bool)), q, SLOT(_q_pageSetup()));
+diff --git a/qtbase/src/sql/kernel/qsqlquery.cpp b/qtbase/src/sql/kernel/qsqlquery.cpp
+index 32c6166c79..60afef10c3 100644
+--- a/qtbase/src/sql/kernel/qsqlquery.cpp
++++ b/qtbase/src/sql/kernel/qsqlquery.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2022 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtSql module of the Qt Toolkit.
+@@ -377,6 +377,10 @@ bool QSqlQuery::exec(const QString& query)
+     QElapsedTimer t;
+     t.start();
+ #endif
++    if (!driver()) {
++        qWarning("QSqlQuery::exec: called before driver has been set up");
++        return false;
++    }
+     if (d->ref.loadRelaxed() != 1) {
+         bool fo = isForwardOnly();
+         *this = QSqlQuery(driver()->createResult());
+diff --git a/qtbase/src/testlib/qabstractitemmodeltester.cpp b/qtbase/src/testlib/qabstractitemmodeltester.cpp
+index 8efb9c53d4..ce062f66d7 100644
+--- a/qtbase/src/testlib/qabstractitemmodeltester.cpp
++++ b/qtbase/src/testlib/qabstractitemmodeltester.cpp
+@@ -454,7 +454,7 @@ void QAbstractItemModelTesterPrivate::parent()
+ 
+     // Common error test #2, make sure that a second level index has a parent
+     // that is the first level index.
+-    if (model->rowCount(topIndex) > 0) {
++    if (model->rowCount(topIndex) > 0 && model->columnCount(topIndex) > 0) {
+         QModelIndex childIndex = model->index(0, 0, topIndex);
+         MODELTESTER_VERIFY(childIndex.isValid());
+         MODELTESTER_COMPARE(model->parent(childIndex), topIndex);
+diff --git a/qtbase/src/testlib/qasciikey.cpp b/qtbase/src/testlib/qasciikey.cpp
+index 9a308da2bc..93498b256f 100644
+--- a/qtbase/src/testlib/qasciikey.cpp
++++ b/qtbase/src/testlib/qasciikey.cpp
+@@ -498,6 +498,11 @@ char QTest::keyToAscii(Qt::Key key)
+     case Qt::Key_LaunchE : return 0; // = 0x10b0,
+     case Qt::Key_LaunchF : return 0; // = 0x10b1,
+ 
++    // Keypad navigation keys
++    case Qt::Key_Select : return 0; // = 0x01010000
++    case Qt::Key_Yes : return 0; // = 0x01010001
++    case Qt::Key_No : return 0; // = 0x01010002
++
+     default: QTEST_ASSERT(false); return 0;
+     }
+ }
+diff --git a/qtbase/src/testlib/qtestresult.cpp b/qtbase/src/testlib/qtestresult.cpp
+index 88028aac6e..2e89930776 100644
+--- a/qtbase/src/testlib/qtestresult.cpp
++++ b/qtbase/src/testlib/qtestresult.cpp
+@@ -251,7 +251,8 @@ bool QTestResult::verify(bool statement, const char *statementStr,
+ {
+     QTEST_ASSERT(statementStr);
+ 
+-    char msg[1024] = {'\0'};
++    char msg[1024];
++    msg[0] = '\0';
+ 
+     if (QTestLog::verboseLevel() >= 2) {
+         qsnprintf(msg, 1024, "QVERIFY(%s)", statementStr);
+@@ -309,7 +310,8 @@ static bool compareHelper(bool success, const char *failureMsg,
+                           bool hasValues = true)
+ {
+     const size_t maxMsgLen = 1024;
+-    char msg[maxMsgLen] = {'\0'};
++    char msg[maxMsgLen];
++    msg[0] = '\0';
+ 
+     QTEST_ASSERT(expected);
+     QTEST_ASSERT(actual);
+diff --git a/qtbase/src/widgets/dialogs/qcolordialog.cpp b/qtbase/src/widgets/dialogs/qcolordialog.cpp
+index 4247731275..cb325be85c 100644
+--- a/qtbase/src/widgets/dialogs/qcolordialog.cpp
++++ b/qtbase/src/widgets/dialogs/qcolordialog.cpp
+@@ -78,7 +78,10 @@
+ #include "qwindow.h"
+ 
+ #include "private/qdialog_p.h"
++#include "private/qguiapplication_p.h"
+ 
++#include <qpa/qplatformservices.h>
++#include <qpa/qplatformintegration.h>
+ #include <algorithm>
+ 
+ QT_BEGIN_NAMESPACE
+@@ -1611,6 +1614,20 @@ void QColorDialogPrivate::_q_newStandard(int r, int c)
+ void QColorDialogPrivate::_q_pickScreenColor()
+ {
+     Q_Q(QColorDialog);
++
++    auto *platformServices = QGuiApplicationPrivate::platformIntegration()->services();
++    if (platformServices->hasCapability(QPlatformServices::Capability::ColorPicking)) {
++        if (auto *colorPicker = platformServices->colorPicker(q->windowHandle())) {
++            q->connect(colorPicker, &QPlatformServiceColorPicker::colorPicked, q,
++                       [q, colorPicker](const QColor &color) {
++                           colorPicker->deleteLater();
++                           q->setCurrentColor(color);
++                       });
++            colorPicker->pickColor();
++            return;
++        }
++    }
++
+     if (!colorPickingEventFilter)
+         colorPickingEventFilter = new QColorPickingEventFilter(this, q);
+     q->installEventFilter(colorPickingEventFilter);
+diff --git a/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp b/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
+index e120817edc..8ea36b5427 100644
+--- a/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
++++ b/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
+@@ -400,12 +400,7 @@ bool QAbstractItemDelegate::helpEvent(QHelpEvent *event,
+         const QString tooltip = index.isValid() ?
+               d->textForRole(Qt::ToolTipRole, index.data(Qt::ToolTipRole), option.locale, precision) :
+               QString();
+-        QRect rect;
+-        if (index.isValid()) {
+-            const QRect r = view->visualRect(index);
+-            rect = QRect(view->mapToGlobal(r.topLeft()), r.size());
+-        }
+-        QToolTip::showText(he->globalPos(), tooltip, view, rect);
++        QToolTip::showText(he->globalPos(), tooltip, view->viewport(), option.rect);
+         event->setAccepted(!tooltip.isEmpty());
+         break;
+         }
+diff --git a/qtbase/src/widgets/itemviews/qlistview.cpp b/qtbase/src/widgets/itemviews/qlistview.cpp
+index 2b34476642..eebfaa030e 100644
+--- a/qtbase/src/widgets/itemviews/qlistview.cpp
++++ b/qtbase/src/widgets/itemviews/qlistview.cpp
+@@ -3386,6 +3386,7 @@ void QIconModeViewBase::updateContentsSize()
+ */
+ void QListView::currentChanged(const QModelIndex &current, const QModelIndex &previous)
+ {
++    QAbstractItemView::currentChanged(current, previous);
+ #ifndef QT_NO_ACCESSIBILITY
+     if (QAccessible::isActive()) {
+         if (current.isValid()) {
+@@ -3396,7 +3397,6 @@ void QListView::currentChanged(const QModelIndex &current, const QModelIndex &pr
+         }
+     }
+ #endif
+-    QAbstractItemView::currentChanged(current, previous);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/widgets/itemviews/qtableview.cpp b/qtbase/src/widgets/itemviews/qtableview.cpp
+index 934ac581b2..f79bb24249 100644
+--- a/qtbase/src/widgets/itemviews/qtableview.cpp
++++ b/qtbase/src/widgets/itemviews/qtableview.cpp
+@@ -1013,6 +1013,7 @@ void QTableViewPrivate::drawCell(QPainter *painter, const QStyleOptionViewItem &
+ int QTableViewPrivate::widthHintForIndex(const QModelIndex &index, int hint, const QStyleOptionViewItem &option) const
+ {
+     Q_Q(const QTableView);
++    const int oldHint = hint;
+     QWidget *editor = editorForIndex(index).widget.data();
+     if (editor && persistent.contains(editor)) {
+         hint = qMax(hint, editor->sizeHint().width());
+@@ -1021,6 +1022,17 @@ int QTableViewPrivate::widthHintForIndex(const QModelIndex &index, int hint, con
+         hint = qBound(min, hint, max);
+     }
+     hint = qMax(hint, q->itemDelegate(index)->sizeHint(option, index).width());
++
++    if (hasSpans()) {
++        auto span = spans.spanAt(index.column(), index.row());
++        if (span && span->m_left == index.column() && span->m_top == index.row()) {
++            // spans are screwed up when sections are moved
++            const auto left = logicalColumn(span->m_left);
++            for (int i = 1; i <= span->width(); ++i)
++               hint -= q->columnWidth(visualColumn(left + i));
++        }
++        hint = std::max(hint, oldHint);
++    }
+     return hint;
+ }
+ 
+@@ -1053,6 +1065,11 @@ int QTableViewPrivate::heightHintForIndex(const QModelIndex &index, int hint, QS
+         option.rect.setHeight(height);
+         option.rect.setX(q->columnViewportPosition(index.column()));
+         option.rect.setWidth(q->columnWidth(index.column()));
++        if (hasSpans()) {
++            auto span = spans.spanAt(index.column(), index.row());
++            if (span && span->m_left == index.column() && span->m_top == index.row())
++                option.rect.setWidth(std::max(option.rect.width(), visualSpanRect(*span).width()));
++        }
+         // 1px less space when grid is shown (see drawCell)
+         if (showGrid)
+             option.rect.setWidth(option.rect.width() - 1);
+diff --git a/qtbase/src/widgets/kernel/qaction.h b/qtbase/src/widgets/kernel/qaction.h
+index 258a1ea0a0..737c1e8285 100644
+--- a/qtbase/src/widgets/kernel/qaction.h
++++ b/qtbase/src/widgets/kernel/qaction.h
+@@ -81,7 +81,7 @@ class Q_WIDGETS_EXPORT QAction : public QObject
+     Q_PROPERTY(MenuRole menuRole READ menuRole WRITE setMenuRole NOTIFY changed)
+     Q_PROPERTY(bool iconVisibleInMenu READ isIconVisibleInMenu WRITE setIconVisibleInMenu NOTIFY changed)
+     Q_PROPERTY(bool shortcutVisibleInContextMenu READ isShortcutVisibleInContextMenu WRITE setShortcutVisibleInContextMenu NOTIFY changed)
+-    Q_PROPERTY(Priority priority READ priority WRITE setPriority)
++    Q_PROPERTY(Priority priority READ priority WRITE setPriority NOTIFY changed)
+ 
+ public:
+     // note this is copied into qplatformmenu.h, which must stay in sync
+diff --git a/qtbase/src/widgets/kernel/qwidget.cpp b/qtbase/src/widgets/kernel/qwidget.cpp
+index 9eba1e001e..26f6d27e18 100644
+--- a/qtbase/src/widgets/kernel/qwidget.cpp
++++ b/qtbase/src/widgets/kernel/qwidget.cpp
+@@ -5296,7 +5296,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
+         QWidgetEffectSourcePrivate *sourced = static_cast<QWidgetEffectSourcePrivate *>
+                                                          (source->d_func());
+         if (!sourced->context) {
+-            const QRegion effectRgn(rgn.boundingRect());
++            const QRegion effectRgn((flags & UseEffectRegionBounds) ? rgn.boundingRect() : rgn);
+             QWidgetPaintContext context(pdev, effectRgn, offset, flags, sharedPainter, repaintManager);
+             sourced->context = &context;
+             if (!sharedPainter) {
+@@ -5328,6 +5328,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
+         }
+     }
+ #endif // QT_CONFIG(graphicseffect)
++    flags = flags & ~UseEffectRegionBounds;
+ 
+     const bool alsoOnScreen = flags & DrawPaintOnScreen;
+     const bool recursive = flags & DrawRecursive;
+diff --git a/qtbase/src/widgets/kernel/qwidget_p.h b/qtbase/src/widgets/kernel/qwidget_p.h
+index eef6b8fa2c..c432f4b5d5 100644
+--- a/qtbase/src/widgets/kernel/qwidget_p.h
++++ b/qtbase/src/widgets/kernel/qwidget_p.h
+@@ -229,7 +229,8 @@ public:
+         DontSubtractOpaqueChildren = 0x10,
+         DontDrawOpaqueChildren = 0x20,
+         DontDrawNativeChildren = 0x40,
+-        DontSetCompositionMode = 0x80
++        DontSetCompositionMode = 0x80,
++        UseEffectRegionBounds = 0x100
+     };
+     Q_DECLARE_FLAGS(DrawWidgetFlags, DrawWidgetFlag)
+     Q_FLAG(DrawWidgetFlags)
+diff --git a/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp b/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
+index 02880b34da..0d44e1326d 100644
+--- a/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
++++ b/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
+@@ -1018,7 +1018,8 @@ void QWidgetRepaintManager::paintAndFlush()
+ 
+     // Paint the rest with composition.
+     if (repaintAllWidgets || !dirtyCopy.isEmpty()) {
+-        QWidgetPrivate::DrawWidgetFlags flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive;
++        QWidgetPrivate::DrawWidgetFlags flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive
++                | QWidgetPrivate::UseEffectRegionBounds;
+         tlw->d_func()->drawWidget(store->paintDevice(), dirtyCopy, QPoint(), flags, nullptr, this);
+     }
+ 
+diff --git a/qtbase/src/widgets/styles/qfusionstyle.cpp b/qtbase/src/widgets/styles/qfusionstyle.cpp
+index f4345d97c4..962912c838 100644
+--- a/qtbase/src/widgets/styles/qfusionstyle.cpp
++++ b/qtbase/src/widgets/styles/qfusionstyle.cpp
+@@ -1772,14 +1772,6 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio
+             proxy()->drawControl(CE_PushButtonLabel, &subopt, painter, widget);
+         }
+         break;
+-    case CE_PushButtonLabel:
+-        if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
+-            QStyleOptionButton b(*button);
+-            // no PM_ButtonShiftHorizontal and PM_ButtonShiftVertical for fusion style
+-            b.state &= ~(State_On | State_Sunken);
+-            QCommonStyle::drawControl(element, &b, painter, widget);
+-        }
+-        break;
+     case CE_MenuBarEmptyArea:
+         painter->save();
+     {
+diff --git a/qtbase/src/widgets/util/qcompleter.cpp b/qtbase/src/widgets/util/qcompleter.cpp
+index 18b24063d8..ef7207a8a3 100644
+--- a/qtbase/src/widgets/util/qcompleter.cpp
++++ b/qtbase/src/widgets/util/qcompleter.cpp
+@@ -1120,6 +1120,8 @@ void QCompleter::setModel(QAbstractItemModel *model)
+ {
+     Q_D(QCompleter);
+     QAbstractItemModel *oldModel = d->proxy->sourceModel();
++    if (oldModel == model)
++        return;
+ #if QT_CONFIG(filesystemmodel)
+     if (qobject_cast<const QFileSystemModel *>(oldModel))
+         setCompletionRole(Qt::EditRole); // QTBUG-54642, clear FileNameRole set by QFileSystemModel
+diff --git a/qtbase/src/widgets/widgets/qabstractbutton.cpp b/qtbase/src/widgets/widgets/qabstractbutton.cpp
+index a128b23950..dc40bf62fb 100644
+--- a/qtbase/src/widgets/widgets/qabstractbutton.cpp
++++ b/qtbase/src/widgets/widgets/qabstractbutton.cpp
+@@ -56,6 +56,7 @@
+ #ifndef QT_NO_ACCESSIBILITY
+ #include "qaccessible.h"
+ #endif
++#include <qpa/qplatformtheme.h>
+ 
+ #include <algorithm>
+ 
+@@ -1076,19 +1077,19 @@ void QAbstractButton::keyPressEvent(QKeyEvent *e)
+ {
+     Q_D(QAbstractButton);
+     bool next = true;
+-    switch (e->key()) {
+-    case Qt::Key_Enter:
+-    case Qt::Key_Return:
+-        e->ignore();
+-        break;
+-    case Qt::Key_Select:
+-    case Qt::Key_Space:
+-        if (!e->isAutoRepeat()) {
+-            setDown(true);
+-            repaint();
+-            d->emitPressed();
+-        }
+-        break;
++
++    const auto key = static_cast<Qt::Key>(e->key());
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(key) && !e->isAutoRepeat()) {
++        setDown(true);
++        repaint();
++        d->emitPressed();
++        return;
++    }
++
++    switch (key) {
+     case Qt::Key_Up:
+         next = false;
+         Q_FALLTHROUGH();
+@@ -1153,15 +1154,15 @@ void QAbstractButton::keyReleaseEvent(QKeyEvent *e)
+     if (!e->isAutoRepeat())
+         d->repeatTimer.stop();
+ 
+-    switch (e->key()) {
+-    case Qt::Key_Select:
+-    case Qt::Key_Space:
+-        if (!e->isAutoRepeat() && d->down)
+-            d->click();
+-        break;
+-    default:
+-        e->ignore();
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(static_cast<Qt::Key>(e->key())) && !e->isAutoRepeat() && d->down) {
++        d->click();
++        return;
+     }
++
++    e->ignore();
+ }
+ 
+ /*!\reimp
+diff --git a/qtbase/src/widgets/widgets/qcombobox.cpp b/qtbase/src/widgets/widgets/qcombobox.cpp
+index 7a496c27e0..0a3d96647b 100644
+--- a/qtbase/src/widgets/widgets/qcombobox.cpp
++++ b/qtbase/src/widgets/widgets/qcombobox.cpp
+@@ -3352,7 +3352,23 @@ void QComboBox::keyPressEvent(QKeyEvent *e)
+ 
+     Move move = NoMove;
+     int newIndex = currentIndex();
+-    switch (e->key()) {
++
++    bool pressLikeButton = !d->lineEdit;
++#ifdef QT_KEYPAD_NAVIGATION
++    pressLikeButton |= QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus();
++#endif
++    auto key = static_cast<Qt::Key>(e->key());
++    if (pressLikeButton) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(key)) {
++            showPopup();
++            return;
++        }
++    }
++
++    switch (key) {
+     case Qt::Key_Up:
+         if (e->modifiers() & Qt::ControlModifier)
+             break; // pass to line edit for auto completion
+@@ -3394,26 +3410,11 @@ void QComboBox::keyPressEvent(QKeyEvent *e)
+             return;
+         }
+         break;
+-    case Qt::Key_Space:
+-        if (!d->lineEdit) {
+-            showPopup();
+-            return;
+-        }
+-        break;
+-    case Qt::Key_Enter:
+-    case Qt::Key_Return:
+     case Qt::Key_Escape:
+         if (!d->lineEdit)
+             e->ignore();
+         break;
+ #ifdef QT_KEYPAD_NAVIGATION
+-    case Qt::Key_Select:
+-        if (QApplicationPrivate::keypadNavigationEnabled()
+-                && (!hasEditFocus() || !d->lineEdit)) {
+-            showPopup();
+-            return;
+-        }
+-        break;
+     case Qt::Key_Left:
+     case Qt::Key_Right:
+         if (QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus())
+diff --git a/qtbase/src/widgets/widgets/qdatetimeedit_p.h b/qtbase/src/widgets/widgets/qdatetimeedit_p.h
+index d36b6f8f9a..e0df5b5158 100644
+--- a/qtbase/src/widgets/widgets/qdatetimeedit_p.h
++++ b/qtbase/src/widgets/widgets/qdatetimeedit_p.h
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2018 The Qt Company Ltd.
++** Copyright (C) 2021 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtWidgets module of the Qt Toolkit.
+diff --git a/qtbase/src/widgets/widgets/qgroupbox.cpp b/qtbase/src/widgets/widgets/qgroupbox.cpp
+index 02a0bed325..3f3eccc370 100644
+--- a/qtbase/src/widgets/widgets/qgroupbox.cpp
++++ b/qtbase/src/widgets/widgets/qgroupbox.cpp
+@@ -54,6 +54,8 @@
+ #include "qaccessible.h"
+ #endif
+ #include <private/qwidget_p.h>
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
+ 
+ #include "qdebug.h"
+ 
+@@ -360,7 +362,10 @@ bool QGroupBox::event(QEvent *e)
+         return true;
+     case QEvent::KeyPress: {
+         QKeyEvent *k = static_cast<QKeyEvent*>(e);
+-        if (!k->isAutoRepeat() && (k->key() == Qt::Key_Select || k->key() == Qt::Key_Space)) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (!k->isAutoRepeat() && buttonPressKeys.contains(static_cast<Qt::Key>(k->key()))) {
+             d->pressedControl = QStyle::SC_GroupBoxCheckBox;
+             update(style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxCheckBox, this));
+             return true;
+@@ -369,7 +374,10 @@ bool QGroupBox::event(QEvent *e)
+     }
+     case QEvent::KeyRelease: {
+         QKeyEvent *k = static_cast<QKeyEvent*>(e);
+-        if (!k->isAutoRepeat() && (k->key() == Qt::Key_Select || k->key() == Qt::Key_Space)) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (!k->isAutoRepeat() && buttonPressKeys.contains(static_cast<Qt::Key>(k->key()))) {
+             bool toggle = (d->pressedControl == QStyle::SC_GroupBoxLabel
+                            || d->pressedControl == QStyle::SC_GroupBoxCheckBox);
+             d->pressedControl = QStyle::SC_None;
+diff --git a/qtbase/src/widgets/widgets/qlabel.cpp b/qtbase/src/widgets/widgets/qlabel.cpp
+index 30ff80cbb0..cf2605c17c 100644
+--- a/qtbase/src/widgets/widgets/qlabel.cpp
++++ b/qtbase/src/widgets/widgets/qlabel.cpp
+@@ -421,9 +421,6 @@ void QLabel::setPixmap(const QPixmap &pixmap)
+         d->pixmap = new QPixmap(pixmap);
+     }
+ 
+-    if (d->pixmap->depth() == 1 && !d->pixmap->mask())
+-        d->pixmap->setMask(*((QBitmap *)d->pixmap));
+-
+     d->updateLabel();
+ }
+ 
+diff --git a/qtbase/src/widgets/widgets/qtoolbararealayout.cpp b/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
+index 493c094cc1..d5f4b59017 100644
+--- a/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
++++ b/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
+@@ -1367,7 +1367,7 @@ bool QToolBarAreaLayout::restoreState(QDataStream &stream, const QList<QToolBar*
+                 item.widgetItem = new QWidgetItemV2(toolBar);
+                 toolBar->setOrientation(floating ? ((shown & 2) ? Qt::Vertical : Qt::Horizontal) : dock.o);
+                 toolBar->setVisible(shown & 1);
+-                toolBar->d_func()->setWindowState(floating, true, rect);
++                toolBar->d_func()->setWindowState(floating, false, rect);
+ 
+                 item.preferredSize = item.size;
+                 line.toolBarItems.append(item);
+diff --git a/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp b/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
+index 212c0a2e13..3c77b1ba0b 100644
+--- a/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
++++ b/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
+@@ -126,8 +126,7 @@ public:
+ 
+ void tst_QtConcurrentIterateKernel::instantiate()
+ {
+-    auto future = startThreadEngine(new PrintFor(0, 40)).startAsynchronously();
+-    future.waitForFinished();
++    startThreadEngine(new PrintFor(0, 40)).startBlocking();
+     QCOMPARE(iterations.loadRelaxed(), 40);
+ }
+ 
+@@ -166,10 +165,8 @@ void tst_QtConcurrentIterateKernel::stresstest()
+     const int times = 50;
+     for (int i = 0; i < times; ++i) {
+         counter.storeRelaxed(0);
+-        // ThreadEngine will delete f when it finishes
+-        auto f = new CountFor(0, iterations);
+-        auto future = f->startAsynchronously();
+-        future.waitForFinished();
++        CountFor f(0, iterations);
++        f.startBlocking();
+         QCOMPARE(counter.loadRelaxed(), iterations);
+     }
+ }
+@@ -177,11 +174,8 @@ void tst_QtConcurrentIterateKernel::stresstest()
+ void tst_QtConcurrentIterateKernel::noIterations()
+ {
+     const int times = 20000;
+-    for (int i = 0; i < times; ++i) {
+-        auto future = startThreadEngine(new IterateKernel<TestIterator, void>(0, 0))
+-                              .startAsynchronously();
+-        future.waitForFinished();
+-    }
++    for (int i = 0; i < times; ++i)
++        startThreadEngine(new IterateKernel<TestIterator, void>(0, 0)).startBlocking();
+ }
+ 
+ QMutex threadsMutex;
+@@ -236,10 +230,8 @@ void tst_QtConcurrentIterateKernel::throttling()
+ 
+     threads.clear();
+ 
+-    // ThreadEngine will delete f when it finishes
+-    auto f = new ThrottleFor(0, totalIterations);
+-    auto future = f->startAsynchronously();
+-    future.waitForFinished();
++    ThrottleFor f(0, totalIterations);
++    f.startBlocking();
+ 
+     QCOMPARE(iterations.loadRelaxed(), totalIterations);
+ 
+diff --git a/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp b/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
+index ac7be7acdd..81bc64c8d9 100644
+--- a/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
++++ b/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
+@@ -65,9 +65,16 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::runDirectly()
+ {
+-    PrintUser *engine = new PrintUser();
+-    QFuture<void> f = engine->startAsynchronously();
+-    f.waitForFinished();
++    {
++        PrintUser engine;
++        engine.startSingleThreaded();
++        engine.startBlocking();
++    }
++    {
++        PrintUser *engine = new PrintUser();
++        QFuture<void> f = engine->startAsynchronously();
++        f.waitForFinished();
++    }
+ }
+ 
+ class StringResultUser : public ThreadEngine<QString>
+@@ -99,10 +106,8 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::result()
+ {
+-    // ThreadEngine will delete 'engine' when it finishes
+-    auto engine = new StringResultUser();
+-    auto future = engine->startAsynchronously();
+-    QCOMPARE(future.result(), QString("Foo"));
++    StringResultUser engine;
++    QCOMPARE(*engine.startBlocking(), QString("Foo"));
+ }
+ 
+ class VoidResultUser : public ThreadEngine<void>
+@@ -128,9 +133,17 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::runThroughStarter()
+ {
+-    ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
+-    QFuture<QString> f = starter.startAsynchronously();
+-    QCOMPARE(f.result(), QString("Foo"));
++    {
++        ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
++        QFuture<QString>  f = starter.startAsynchronously();
++        QCOMPARE(f.result(), QString("Foo"));
++    }
++
++    {
++        ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
++        QString str = starter.startBlocking();
++        QCOMPARE(str, QString("Foo"));
++    }
+ }
+ 
+ class CancelUser : public ThreadEngine<void>
+@@ -213,6 +226,12 @@ void tst_QtConcurrentThreadEngine::throttle()
+         f.waitForFinished();
+         QCOMPARE(count.loadRelaxed(), 0);
+     }
++
++    for (int i = 0; i < repeats; ++i) {
++        ThrottleAlwaysUser t;
++        t.startBlocking();
++        QCOMPARE(count.loadRelaxed(), 0);
++    }
+ }
+ 
+ QSet<QThread *> threads;
+@@ -249,17 +268,35 @@ void tst_QtConcurrentThreadEngine::threadCount()
+ {
+     const int repeats = 10;
+     for (int i = 0; i < repeats; ++i) {
++        ThreadCountUser t;
++        t.startBlocking();
++        int count = threads.count();
++        int count_expected = QThreadPool::globalInstance()->maxThreadCount() + 1; // +1 for the main thread.
++        if (count != count_expected)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, count_expected);
++
+         (new ThreadCountUser())->startAsynchronously().waitForFinished();
+-        const auto count = threads.count();
+-        const auto maxThreadCount = QThreadPool::globalInstance()->maxThreadCount();
+-        QVERIFY(count <= maxThreadCount);
+-        QVERIFY(!threads.contains(QThread::currentThread()));
++        count = threads.count();
++        count_expected = QThreadPool::globalInstance()->maxThreadCount();
++        if (count != count_expected)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, count_expected);
+     }
+ 
+     // Set the finish flag immediately, this should give us one thread only.
+     for (int i = 0; i < repeats; ++i) {
++        ThreadCountUser t(true /*finishImmediately*/);
++        t.startBlocking();
++        int count = threads.count();
++        if (count != 1)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, 1);
++
+         (new ThreadCountUser(true /*finishImmediately*/))->startAsynchronously().waitForFinished();
+-        const auto count = threads.count();
++        count = threads.count();
++        if (count != 1)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
+         QCOMPARE(count, 1);
+         QVERIFY(!threads.contains(QThread::currentThread()));
+     }
+@@ -400,6 +437,7 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::exceptions()
+ {
++    // Asynchronous mode:
+     {
+         bool caught = false;
+         try  {
+@@ -412,6 +450,32 @@ void tst_QtConcurrentThreadEngine::exceptions()
+         QVERIFY2(caught, "did not get exception");
+     }
+ 
++    // Blocking mode:
++    // test throwing the exception from a worker thread.
++    {
++        bool caught = false;
++        try  {
++            QtConcurrentExceptionThrower e(QThread::currentThread());
++            e.startBlocking();
++        } catch (const QException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // test throwing the exception from the main thread (different code path)
++    {
++        bool caught = false;
++        try  {
++            QtConcurrentExceptionThrower e(0);
++            e.startBlocking();
++        } catch (const QException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // Asynchronous mode:
+     {
+         bool caught = false;
+         try  {
+@@ -423,6 +487,31 @@ void tst_QtConcurrentThreadEngine::exceptions()
+         }
+         QVERIFY2(caught, "did not get exception");
+     }
++
++    // Blocking mode:
++    // test throwing the exception from a worker thread.
++    {
++        bool caught = false;
++        try  {
++            UnrelatedExceptionThrower e(QThread::currentThread());
++            e.startBlocking();
++        } catch (const QUnhandledException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // test throwing the exception from the main thread (different code path)
++    {
++        bool caught = false;
++        try  {
++            UnrelatedExceptionThrower e(0);
++            e.startBlocking();
++        } catch (const QUnhandledException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
+ }
+ 
+ #endif
+diff --git a/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp b/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
+index 4968742110..f4c3fb711d 100644
+--- a/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
++++ b/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
+@@ -42,6 +42,7 @@ private slots:
+     void writeBlock_data();
+     void writeBlock();
+     void seek();
++    void invalidSeeks();
+     void seekTest_data();
+     void seekTest();
+     void read_rawdata();
+@@ -286,6 +287,29 @@ void tst_QBuffer::seek()
+     QCOMPARE(buffer.size(), pos);
+ }
+ 
++void tst_QBuffer::invalidSeeks()
++{
++    if constexpr (sizeof(qsizetype) == sizeof(qint64)) {
++        // sizeof(qsizetype) == sizeof(qint64), so +1 would overflow
++        QSKIP("This is a 32-bit-only test.");
++    } else {
++        QBuffer buffer;
++        buffer.open(QIODevice::WriteOnly);
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++        constexpr qint64 MaxQByteArrayCapacity = (std::numeric_limits<qsizetype>::max)();
++        // this should fail fast, not after trying to allocate nearly 2 GiB of data,
++        // potentially crashing in the process:
++        QVERIFY(!buffer.seek(2 * MaxQByteArrayCapacity - 1));
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++        // ditto:
++        QVERIFY(!buffer.seek(MaxQByteArrayCapacity + 1));
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++    }
++}
++
+ void tst_QBuffer::seekTest_data()
+ {
+     writeBlock_data();
+diff --git a/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp b/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
+index da5327594c..4a04e0f7c6 100644
+--- a/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
++++ b/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
+@@ -561,7 +561,8 @@ protected:
+     qint64 readData(char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf->size() - offset));
+-        memcpy(data, buf->constData() + offset, maxSize);
++        if (maxSize > 0)
++            memcpy(data, buf->constData() + offset, maxSize);
+         offset += maxSize;
+         return maxSize;
+     }
+@@ -604,13 +605,15 @@ protected:
+     qint64 readData(char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf.size() - pos()));
+-        memcpy(data, buf.constData() + pos(), maxSize);
++        if (maxSize > 0)
++            memcpy(data, buf.constData() + pos(), maxSize);
+         return maxSize;
+     }
+     qint64 writeData(const char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf.size() - pos()));
+-        memcpy(buf.data() + pos(), data, maxSize);
++        if (maxSize > 0)
++            memcpy(buf.data() + pos(), data, maxSize);
+         return maxSize;
+     }
+ 
+diff --git a/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+index db60bead64..f345a44414 100644
+--- a/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
++++ b/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+@@ -1,7 +1,8 @@
+ /****************************************************************************
+ **
+ ** Copyright (C) 2021 The Qt Company Ltd.
+-** Copyright (C) 2020 Intel Corporation.
++** Copyright (C) 2020 The Qt Company Ltd.
++** Copyright (C) 2022 Intel Corporation.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the test suite of the Qt Toolkit.
+@@ -150,6 +151,8 @@ private slots:
+     void startStopStartStopBuffers();
+     void processEventsInAReadyReadSlot_data();
+     void processEventsInAReadyReadSlot();
++    void startFromCurrentWorkingDir_data();
++    void startFromCurrentWorkingDir();
+ 
+     // keep these at the end, since they use lots of processes and sometimes
+     // caused obscure failures to occur in tests that followed them (esp. on the Mac)
+@@ -2731,5 +2734,94 @@ void tst_QProcess::finishProcessBeforeReadingDone_deprecated()
+ 
+ #endif
+ 
++enum class ChdirMode {
++    None = 0,
++    InParent,
++    InChild
++};
++Q_DECLARE_METATYPE(ChdirMode)
++
++void tst_QProcess::startFromCurrentWorkingDir_data()
++{
++    qRegisterMetaType<ChdirMode>();
++    QTest::addColumn<QString>("programPrefix");
++    QTest::addColumn<ChdirMode>("chdirMode");
++    QTest::addColumn<bool>("success");
++
++    constexpr bool IsWindows = true
++#ifdef Q_OS_UNIX
++            && false
++#endif
++            ;
++
++    // baseline: trying to execute the directory, this can't possibly succeed!
++    QTest::newRow("plain-same-cwd") << QString() << ChdirMode::None << false;
++
++    // cross-platform behavior: neither OS searches the setWorkingDirectory()
++    // dir without "./"
++    QTest::newRow("plain-child-chdir") << QString() << ChdirMode::InChild << false;
++
++    // cross-platform behavior: both OSes search the parent's CWD with "./"
++    QTest::newRow("prefixed-parent-chdir") << "./" << ChdirMode::InParent << true;
++
++    // opposite behaviors: Windows searches the parent's CWD and Unix searches
++    // the child's with "./"
++    QTest::newRow("prefixed-child-chdir") << "./" << ChdirMode::InChild << !IsWindows;
++
++    // Windows searches the parent's CWD without "./"
++    QTest::newRow("plain-parent-chdir") << QString() << ChdirMode::InParent << IsWindows;
++}
++
++void tst_QProcess::startFromCurrentWorkingDir()
++{
++    QFETCH(QString, programPrefix);
++    QFETCH(ChdirMode, chdirMode);
++    QFETCH(bool, success);
++
++    QProcess process;
++    qRegisterMetaType<QProcess::ProcessError>();
++    QSignalSpy errorSpy(&process, &QProcess::errorOccurred);
++    QVERIFY(errorSpy.isValid());
++
++    // both the dir name and the executable name
++    const QString target = QStringLiteral("testProcessNormal");
++    process.setProgram(programPrefix + target);
++
++#ifdef Q_OS_UNIX
++    // Reset PATH, to be sure it doesn't contain . or the empty path.
++    // We can't do this on Windows because DLLs are searched in PATH
++    // and Windows always searches "." anyway.
++    auto restoreEnv = qScopeGuard([old = qgetenv("PATH")] {
++        qputenv("PATH", old);
++    });
++    qputenv("PATH", "/");
++#endif
++
++    switch (chdirMode) {
++    case ChdirMode::InParent: {
++        auto restoreCwd = qScopeGuard([old = QDir::currentPath()] {
++            QDir::setCurrent(old);
++        });
++        QVERIFY(QDir::setCurrent(target));
++        process.start();
++        break;
++    }
++    case ChdirMode::InChild:
++        process.setWorkingDirectory(target);
++        Q_FALLTHROUGH();
++    case ChdirMode::None:
++        process.start();
++        break;
++    }
++
++    QCOMPARE(process.waitForStarted(), success);
++    QCOMPARE(errorSpy.count(), int(!success));
++    if (success) {
++        QVERIFY(process.waitForFinished());
++    } else {
++        QCOMPARE(process.error(), QProcess::FailedToStart);
++    }
++}
++
+ QTEST_MAIN(tst_QProcess)
+ #include "tst_qprocess.moc"
+diff --git a/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp b/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp
+index e1ea7a4552..90972caa57 100644
+--- a/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp
++++ b/qtbase/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"
+diff --git a/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+index 9bd66c0835..ed4a0bae5d 100644
+--- a/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
++++ b/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+@@ -158,6 +158,7 @@ private slots:
+     void nullReceiver();
+     void functorReferencesConnection();
+     void disconnectDisconnects();
++    void declarativeData();
+ };
+ 
+ struct QObjectCreatedOnShutdown
+@@ -7679,5 +7680,81 @@ void tst_QObject::disconnectDisconnects()
+ Q_STATIC_ASSERT(QtPrivate::HasQ_OBJECT_Macro<tst_QObject>::Value);
+ Q_STATIC_ASSERT(!QtPrivate::HasQ_OBJECT_Macro<SiblingDeleter>::Value);
+ 
++#ifdef QT_BUILD_INTERNAL
++/*
++    Since QObjectPrivate stores the declarativeData pointer in a union with the pointer
++    to the currently destroyed child, calls to the QtDeclarative handlers need to be
++    correctly guarded. QTBUG-105286
++*/
++namespace QtDeclarative {
++static QAbstractDeclarativeData *theData;
++
++static void destroyed(QAbstractDeclarativeData *data, QObject *)
++{
++    QCOMPARE(data, theData);
++}
++static void signalEmitted(QAbstractDeclarativeData *data, QObject *, int, void **)
++{
++    QCOMPARE(data, theData);
++}
++// we can't use QCOMPARE in the next two functions, as they don't return void
++static int receivers(QAbstractDeclarativeData *data, const QObject *, int)
++{
++    QTest::qCompare(data, theData, "data", "theData", __FILE__, __LINE__);
++    return 0;
++}
++static bool isSignalConnected(QAbstractDeclarativeData *data, const QObject *, int)
++{
++    QTest::qCompare(data, theData, "data", "theData", __FILE__, __LINE__);
++    return true;
++}
++
++class Object : public QObject
++{
++    Q_OBJECT
++public:
++    using QObject::QObject;
++    ~Object()
++    {
++        if (Object *p = static_cast<Object *>(parent()))
++            p->emitSignal();
++    }
++
++    void emitSignal()
++    {
++        emit theSignal();
++    }
++
++signals:
++    void theSignal();
++};
++
++}
++#endif
++
++void tst_QObject::declarativeData()
++{
++#ifdef QT_BUILD_INTERNAL
++    QScopedValueRollback destroyed(QAbstractDeclarativeData::destroyed,
++                                   QtDeclarative::destroyed);
++    QScopedValueRollback signalEmitted(QAbstractDeclarativeData::signalEmitted,
++                                       QtDeclarative::signalEmitted);
++    QScopedValueRollback receivers(QAbstractDeclarativeData::receivers,
++                                   QtDeclarative::receivers);
++    QScopedValueRollback isSignalConnected(QAbstractDeclarativeData::isSignalConnected,
++                                           QtDeclarative::isSignalConnected);
++
++    QtDeclarative::Object p;
++    QObjectPrivate *priv = QObjectPrivate::get(&p);
++    priv->declarativeData = QtDeclarative::theData = new QAbstractDeclarativeData;
++
++    connect(&p, &QtDeclarative::Object::theSignal, &p, []{
++    });
++
++    QtDeclarative::Object *child = new QtDeclarative::Object;
++    child->setParent(&p);
++#endif
++}
++
+ QTEST_MAIN(tst_QObject)
+ #include "tst_qobject.moc"
+diff --git a/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp b/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
+index 0ea422ecbc..1a3256534b 100644
+--- a/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
++++ b/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
+@@ -70,15 +70,15 @@ static inline QString testSuiteWarning()
+ 
+     QString result;
+     QTextStream str(&result);
+-    str << "\nCannot find the shared-mime-info test suite\nstarting from: "
++    str << "\nCannot find the shared-mime-info test suite\nin the parent of: "
+         << QDir::toNativeSeparators(QDir::currentPath()) << "\n"
+            "cd " << QDir::toNativeSeparators(QStringLiteral("tests/auto/corelib/mimetypes/qmimedatabase")) << "\n"
+-           "wget http://cgit.freedesktop.org/xdg/shared-mime-info/snapshot/Release-1-10.zip\n"
+-           "unzip Release-1-10.zip\n";
++           "wget https://gitlab.freedesktop.org/xdg/shared-mime-info/-/archive/2.1/shared-mime-info-2.1.zip\n"
++           "unzip shared-mime-info-2.1.zip\n";
+ #ifdef Q_OS_WIN
+-    str << "mkdir testfiles\nxcopy /s Release-1-10 s-m-i\n";
++    str << "mkdir testfiles\nxcopy /s shared-mime-info-2.1 s-m-i\n";
+ #else
+-    str << "ln -s Release-1-10 s-m-i\n";
++    str << "ln -s shared-mime-info-2.1 s-m-i\n";
+ #endif
+     return result;
+ }
+@@ -154,7 +154,7 @@ void tst_QMimeDatabase::initTestCase()
+     QVERIFY2(copyResourceFile(xmlFileName, xmlTargetFileName, &errorMessage), qPrintable(errorMessage));
+ #endif
+ 
+-    m_testSuite = QFINDTESTDATA("s-m-i/tests");
++    m_testSuite = QFINDTESTDATA("s-m-i/tests/mime-detection");
+     if (m_testSuite.isEmpty())
+         qWarning("%s", qPrintable(testSuiteWarning()));
+ 
+@@ -611,7 +611,7 @@ void tst_QMimeDatabase::allMimeTypes()
+     QVERIFY(!lst.isEmpty());
+ 
+     // Hardcoding this is the only way to check both providers find the same number of mimetypes.
+-    QCOMPARE(lst.count(), 779);
++    QCOMPARE(lst.count(), 811);
+ 
+     foreach (const QMimeType &mime, lst) {
+         const QString name = mime.name();
+@@ -631,10 +631,9 @@ void tst_QMimeDatabase::suffixes_data()
+ 
+     QTest::newRow("mimetype with a single pattern") << "application/pdf" << "*.pdf" << "pdf";
+     QTest::newRow("mimetype with multiple patterns") << "application/x-kpresenter" << "*.kpr;*.kpt" << "kpr";
+-    QTest::newRow("jpeg") << "image/jpeg" << "*.jpe;*.jpg;*.jpeg" << "jpeg";
+-    //if (KMimeType::sharedMimeInfoVersion() > KDE_MAKE_VERSION(0, 60, 0)) {
+-        QTest::newRow("mimetype with many patterns") << "application/vnd.wordperfect" << "*.wp;*.wp4;*.wp5;*.wp6;*.wpd;*.wpp" << "wp";
+-    //}
++    // The preferred suffix for image/jpeg is *.jpg, as per https://bugs.kde.org/show_bug.cgi?id=176737
++    QTest::newRow("jpeg") << "image/jpeg" << "*.jpe;*.jpg;*.jpeg" << "jpg";
++    QTest::newRow("mimetype with many patterns") << "application/vnd.wordperfect" << "*.wp;*.wp4;*.wp5;*.wp6;*.wpd;*.wpp" << "wp";
+     QTest::newRow("oasis text mimetype") << "application/vnd.oasis.opendocument.text" << "*.odt" << "odt";
+     QTest::newRow("oasis presentation mimetype") << "application/vnd.oasis.opendocument.presentation" << "*.odp" << "odp";
+     QTest::newRow("mimetype with multiple patterns") << "text/plain" << "*.asc;*.txt;*,v" << "txt";
+diff --git a/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp b/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
+index 3e58dd03cc..c8f82ef5d5 100644
+--- a/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
++++ b/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
+@@ -176,6 +176,8 @@ private Q_SLOTS:
+     void fromToVariantConversions_data();
+     void fromToVariantConversions();
+ 
++    void noLeakOnNameClash();
++
+ private:
+     QString testDataDir;
+ };
+@@ -3685,5 +3687,23 @@ void tst_QtJson::fromToVariantConversions()
+     }
+ }
+ 
++void tst_QtJson::noLeakOnNameClash()
++{
++    QJsonDocument doc = QJsonDocument::fromJson("{\"\":{\"\":0},\"\":0}");
++    QVERIFY(!doc.isNull());
++    const QJsonObject obj = doc.object();
++
++    // Removed the duplicate key.
++    QCOMPARE(obj.length(), 1);
++
++    // Retained the last of the duplicates.
++    const QJsonValue val = obj.begin().value();
++    QVERIFY(val.isDouble());
++    QCOMPARE(val.toDouble(), 0.0);
++
++    // It should not leak.
++    // In particular it should not forget to deref the container for the inner object.
++}
++
+ QTEST_MAIN(tst_QtJson)
+ #include "tst_qtjson.moc"
+diff --git a/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp b/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
+index a59b58d57f..241c3e84ac 100644
+--- a/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
++++ b/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
+@@ -63,6 +63,7 @@ private slots:
+     void isValidId_data();
+     void isValidId();
+     void malformed();
++    void serialize();
+     // Backend tests
+     void utcTest();
+     void icuTest();
+@@ -947,6 +948,33 @@ void tst_QTimeZone::malformed()
+         barf.offsetFromUtc(now);
+ }
+ 
++void tst_QTimeZone::serialize()
++{
++    int parts = 0;
++#ifndef QT_NO_DEBUG_STREAM
++    qDebug() << QTimeZone(); // to verify no crash
++    parts++;
++#endif
++#ifndef QT_NO_DATASTREAM
++    QByteArray blob;
++    {
++        QDataStream stream(&blob, QIODevice::WriteOnly);
++        stream << QTimeZone("Europe/Oslo") << QTimeZone(420) << QTimeZone() << qint64(-1);
++    }
++    QDataStream stream(&blob, QIODevice::ReadOnly);
++    QTimeZone invalid, offset, oslo;
++    qint64 minusone;
++    stream >> oslo >> offset >> invalid >> minusone;
++    QCOMPARE(oslo, QTimeZone("Europe/Oslo"));
++    QCOMPARE(offset, QTimeZone(420));
++    QVERIFY(!invalid.isValid());
++    QCOMPARE(minusone, qint64(-1));
++    parts++;
++#endif
++    if (!parts)
++        QSKIP("No serialization enabled");
++}
++
+ void tst_QTimeZone::utcTest()
+ {
+ #ifdef QT_BUILD_INTERNAL
+diff --git a/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp b/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
+index 05480c6dd2..70f4c75756 100644
+--- a/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
++++ b/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
+@@ -324,6 +324,13 @@ void tst_QDBusInterface::notValid()
+ 
+     QVERIFY(!interface.isValid());
+     QVERIFY(!QMetaObject::invokeMethod(&interface, "ListNames", Qt::DirectConnection));
++
++    // With a connection, but empty/null service and path specified
++    QDBusConnection con = QDBusConnection::sessionBus();
++    QVERIFY(con.isConnected());
++    QDBusInterface iface({}, {}, {}, con);
++    QVERIFY(!iface.isValid());
++    QVERIFY(!QMetaObject::invokeMethod(&interface, "ListNames", Qt::DirectConnection));
+ }
+ 
+ void tst_QDBusInterface::notValidDerived()
+diff --git a/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp b/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
+index 874468c954..04ceb4ab65 100644
+--- a/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
++++ b/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
+@@ -507,6 +507,10 @@ void tst_QKeySequence::toStringFromKeycode_data()
+     QTest::newRow("Ctrl+Alt+Num+Del") << QKeySequence(Qt::ControlModifier | Qt::AltModifier | Qt::KeypadModifier | Qt::Key_Delete) << "Ctrl+Alt+Num+Del";
+     QTest::newRow("Ctrl+Ins") << QKeySequence(Qt::ControlModifier | Qt::Key_Insert) << "Ctrl+Ins";
+     QTest::newRow("Ctrl+Num+Ins(1)") << QKeySequence(Qt::Key_Insert | Qt::KeypadModifier | Qt::ControlModifier) << "Ctrl+Num+Ins";
++    QTest::newRow("Ctrl") << QKeySequence(Qt::Key_Control) << "Control";
++    QTest::newRow("Alt") << QKeySequence(Qt::Key_Alt) << "Alt";
++    QTest::newRow("Shift") << QKeySequence(Qt::Key_Shift) << "Shift";
++    QTest::newRow("Meta") << QKeySequence(Qt::Key_Meta) << "Meta";
+ }
+ 
+ void tst_QKeySequence::toStringFromKeycode()
+diff --git a/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp b/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+index 15e0ecadaa..b4eca74283 100644
+--- a/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
++++ b/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+@@ -81,6 +81,8 @@ private slots:
+     void registerOpenTypePreferredNamesSystem();
+     void registerOpenTypePreferredNamesApplication();
+ 
++    void stretchRespected();
++
+ private:
+     QString m_ledFont;
+     QString m_testFont;
+@@ -355,6 +357,28 @@ static QString testString()
+     return QStringLiteral("foo bar");
+ }
+ 
++void tst_QFontDatabase::stretchRespected()
++{
++    int italicId = QFontDatabase::addApplicationFont(m_testFontItalic);
++    QVERIFY(italicId != -1);
++
++    QVERIFY(!QFontDatabase::applicationFontFamilies(italicId).isEmpty());
++
++    QString italicFontName = QFontDatabase::applicationFontFamilies(italicId).first();
++
++    QFont italicFont = QFontDatabase().font(italicFontName,
++                                            QString::fromLatin1("Italic"), 14);
++    QVERIFY(italicFont.italic());
++
++    QFont italicStretchedFont = italicFont;
++    italicStretchedFont.setStretch( 400 );
++
++    QVERIFY(QFontMetricsF(italicFont).horizontalAdvance(QStringLiteral("foobar")) <
++            QFontMetricsF(italicStretchedFont).horizontalAdvance(QStringLiteral("foobar")));
++
++    QFontDatabase::removeApplicationFont(italicId);
++}
++
+ void tst_QFontDatabase::condensedFontWidthNoFontMerging()
+ {
+     int regularFontId = QFontDatabase::addApplicationFont(m_testFont);
+diff --git a/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+index 3d4a094c43..b423e11a99 100644
+--- a/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
++++ b/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+@@ -281,6 +281,7 @@ private Q_SLOTS:
+     void ioGetFromFileSpecial();
+     void ioGetFromFile_data();
+     void ioGetFromFile();
++    void ioGetFromFileUrl();
+     void ioGetFromFtp_data();
+     void ioGetFromFtp();
+     void ioGetFromFtpWithReuse();
+@@ -3300,6 +3301,18 @@ void tst_QNetworkReply::ioGetFromFile()
+     QCOMPARE(reader.data, data);
+ }
+ 
++void tst_QNetworkReply::ioGetFromFileUrl()
++{
++    // This immediately fails on non-windows platforms:
++    QNetworkRequest request(QUrl("file://unc-server/some/path"));
++    QNetworkReplyPtr reply(manager.get(request));
++    QSignalSpy finishedSpy(reply.get(), &QNetworkReply::finished);
++    // QTBUG-105618: This would, on non-Windows platforms, never happen because the signal
++    // was emitted before the constructor finished, leaving no chance at all to connect to the
++    // signal
++    QVERIFY(finishedSpy.wait());
++}
++
+ void tst_QNetworkReply::ioGetFromFtp_data()
+ {
+     QTest::addColumn<QString>("fileName");
+diff --git a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
+index 069fa6b341..4cc4d9a5ea 100644
+--- a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
++++ b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
+@@ -1,75 +1,34 @@
+-Certificate:
+-    Data:
+-        Version: 3 (0x2)
+-        Serial Number: 0 (0x0)
+-        Signature Algorithm: sha1WithRSAEncryption
+-        Issuer: C=NO, ST=Oslo, L=Nydalen, O=Nokia Corporation and/or its subsidiary(-ies), OU=Development, CN=fluke.troll.no/emailAddress=ahanssen@trolltech.com
+-        Validity
+-            Not Before: Dec  4 01:10:32 2007 GMT
+-            Not After : Apr 21 01:10:32 2035 GMT
+-        Subject: C=NO, ST=Oslo, O=Nokia Corporation and/or its subsidiary(-ies), OU=Development, CN=fluke.troll.no
+-        Subject Public Key Info:
+-            Public Key Algorithm: rsaEncryption
+-            RSA Public Key: (1024 bit)
+-                Modulus (1024 bit):
+-                    00:a7:c8:a0:4a:c4:19:05:1b:66:ba:32:e2:d2:f1:
+-                    1c:6f:17:82:e4:39:2e:01:51:90:db:04:34:32:11:
+-                    21:c2:0d:6f:59:d8:53:90:54:3f:83:8f:a9:d3:b3:
+-                    d5:ee:1a:9b:80:ae:c3:25:c9:5e:a5:af:4b:60:05:
+-                    aa:a0:d1:91:01:1f:ca:04:83:e3:58:1c:99:32:45:
+-                    84:70:72:58:03:98:4a:63:8b:41:f5:08:49:d2:91:
+-                    02:60:6b:e4:64:fe:dd:a0:aa:74:08:e9:34:4c:91:
+-                    5f:12:3d:37:4d:54:2c:ad:7f:5b:98:60:36:02:8c:
+-                    3b:f6:45:f3:27:6a:9b:94:9d
+-                Exponent: 65537 (0x10001)
+-        X509v3 extensions:
+-            X509v3 Basic Constraints: 
+-                CA:FALSE
+-            Netscape Comment: 
+-                OpenSSL Generated Certificate
+-            X509v3 Subject Key Identifier: 
+-                21:85:04:3D:23:01:66:E5:F7:9F:1A:84:24:8A:AF:0A:79:F4:E5:AC
+-            X509v3 Authority Key Identifier: 
+-                DirName:/C=NO/ST=Oslo/L=Nydalen/O=Nokia Corporation and/or its subsidiary(-ies)/OU=Development/CN=fluke.troll.no/emailAddress=ahanssen@trolltech.com
+-                serial:8E:A8:B4:E8:91:B7:54:2E
+-
+-    Signature Algorithm: sha1WithRSAEncryption
+-        6d:57:5f:d1:05:43:f0:62:05:ec:2a:71:a5:dc:19:08:f2:c4:
+-        a6:bd:bb:25:d9:ca:89:01:0e:e4:cf:1f:c1:8c:c8:24:18:35:
+-        53:59:7b:c0:43:b4:32:e6:98:b2:a6:ef:15:05:0b:48:5f:e1:
+-        a0:0c:97:a9:a1:77:d8:35:18:30:bc:a9:8f:d3:b7:54:c7:f1:
+-        a9:9e:5d:e6:19:bf:f6:3c:5b:2b:d8:e4:3e:62:18:88:8b:d3:
+-        24:e1:40:9b:0c:e6:29:16:62:ab:ea:05:24:70:36:aa:55:93:
+-        ef:02:81:1b:23:10:a2:04:eb:56:95:75:fc:f8:94:b1:5d:42:
+-        c5:3f:36:44:85:5d:3a:2e:90:46:8a:a2:b9:6f:87:ae:0c:15:
+-        40:19:31:90:fc:3b:25:bb:ae:f1:66:13:0d:85:90:d9:49:34:
+-        8f:f2:5d:f9:7a:db:4d:5d:27:f6:76:9d:35:8c:06:a6:4c:a3:
+-        b1:b2:b6:6f:1d:d7:a3:00:fd:72:eb:9e:ea:44:a1:af:21:34:
+-        7d:c7:42:e2:49:91:19:8b:c0:ad:ba:82:80:a8:71:70:f4:35:
+-        31:91:63:84:20:95:e9:60:af:64:8b:cc:ff:3d:8a:76:74:3d:
+-        c8:55:6d:e4:8e:c3:2b:1c:e8:42:18:ae:9f:e6:6b:9c:34:06:
+-        ec:6a:f2:c3
+ -----BEGIN CERTIFICATE-----
+-MIIEEzCCAvugAwIBAgIBADANBgkqhkiG9w0BAQUFADCBnDELMAkGA1UEBhMCTk8x
+-DTALBgNVBAgTBE9zbG8xEDAOBgNVBAcTB055ZGFsZW4xFjAUBgNVBAoTDVRyb2xs
+-dGVjaCBBU0ExFDASBgNVBAsTC0RldmVsb3BtZW50MRcwFQYDVQQDEw5mbHVrZS50
+-cm9sbC5ubzElMCMGCSqGSIb3DQEJARYWYWhhbnNzZW5AdHJvbGx0ZWNoLmNvbTAe
+-Fw0wNzEyMDQwMTEwMzJaFw0zNTA0MjEwMTEwMzJaMGMxCzAJBgNVBAYTAk5PMQ0w
+-CwYDVQQIEwRPc2xvMRYwFAYDVQQKEw1Ucm9sbHRlY2ggQVNBMRQwEgYDVQQLEwtE
+-ZXZlbG9wbWVudDEXMBUGA1UEAxMOZmx1a2UudHJvbGwubm8wgZ8wDQYJKoZIhvcN
+-AQEBBQADgY0AMIGJAoGBAKfIoErEGQUbZroy4tLxHG8XguQ5LgFRkNsENDIRIcIN
+-b1nYU5BUP4OPqdOz1e4am4CuwyXJXqWvS2AFqqDRkQEfygSD41gcmTJFhHByWAOY
+-SmOLQfUISdKRAmBr5GT+3aCqdAjpNEyRXxI9N01ULK1/W5hgNgKMO/ZF8ydqm5Sd
+-AgMBAAGjggEaMIIBFjAJBgNVHRMEAjAAMCwGCWCGSAGG+EIBDQQfFh1PcGVuU1NM
+-IEdlbmVyYXRlZCBDZXJ0aWZpY2F0ZTAdBgNVHQ4EFgQUIYUEPSMBZuX3nxqEJIqv
+-Cnn05awwgbsGA1UdIwSBszCBsKGBoqSBnzCBnDELMAkGA1UEBhMCTk8xDTALBgNV
+-BAgTBE9zbG8xEDAOBgNVBAcTB055ZGFsZW4xFjAUBgNVBAoTDVRyb2xsdGVjaCBB
+-U0ExFDASBgNVBAsTC0RldmVsb3BtZW50MRcwFQYDVQQDEw5mbHVrZS50cm9sbC5u
+-bzElMCMGCSqGSIb3DQEJARYWYWhhbnNzZW5AdHJvbGx0ZWNoLmNvbYIJAI6otOiR
+-t1QuMA0GCSqGSIb3DQEBBQUAA4IBAQBtV1/RBUPwYgXsKnGl3BkI8sSmvbsl2cqJ
+-AQ7kzx/BjMgkGDVTWXvAQ7Qy5piypu8VBQtIX+GgDJepoXfYNRgwvKmP07dUx/Gp
+-nl3mGb/2PFsr2OQ+YhiIi9Mk4UCbDOYpFmKr6gUkcDaqVZPvAoEbIxCiBOtWlXX8
+-+JSxXULFPzZEhV06LpBGiqK5b4euDBVAGTGQ/Dslu67xZhMNhZDZSTSP8l35ettN
+-XSf2dp01jAamTKOxsrZvHdejAP1y657qRKGvITR9x0LiSZEZi8CtuoKAqHFw9DUx
+-kWOEIJXpYK9ki8z/PYp2dD3IVW3kjsMrHOhCGK6f5mucNAbsavLD
++MIIF6zCCA9OgAwIBAgIUfo9amJtJGWqWE6f+SkAO85zkGr4wDQYJKoZIhvcNAQEL
++BQAwgYMxCzAJBgNVBAYTAk5PMQ0wCwYDVQQIDARPc2xvMQ0wCwYDVQQHDARPc2xv
++MRcwFQYDVQQKDA5UaGUgUXQgQ29tcGFueTEMMAoGA1UECwwDUiZEMRIwEAYDVQQD
++DAlIMiBUZXN0ZXIxGzAZBgkqhkiG9w0BCQEWDG1pbmltaUBxdC5pbzAgFw0yMDEw
++MjYxMjAxMzFaGA8yMTIwMTAwMjEyMDEzMVowgYMxCzAJBgNVBAYTAk5PMQ0wCwYD
++VQQIDARPc2xvMQ0wCwYDVQQHDARPc2xvMRcwFQYDVQQKDA5UaGUgUXQgQ29tcGFu
++eTEMMAoGA1UECwwDUiZEMRIwEAYDVQQDDAlIMiBUZXN0ZXIxGzAZBgkqhkiG9w0B
++CQEWDG1pbmltaUBxdC5pbzCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIB
++AOiUp5+E4blouKH7q+rVNR8NoYX2XkBW+q+rpy1zu5ssRSzbqxAjDx9dkht7Qlnf
++VlDT00JvpOWdeuPon5915edQRsY4Unl6mKH29ra3OtUa1/yCJXsGVJTKCj7k4Bxb
++5mZzb/fTlZntMLdTIBMfUbw62FKir1WjKIcJ9fCoG8JaGeKVO4Rh5p0ezd4UUUId
++r1BXl5Nqdqy2vTMsEDnjOsD3egkv8I2SKN4O6n/C3wWYpMOWYZkGoZiKz7rJs/i/
++ez7bsV7JlwdzTlhpJzkcOSVFBP6JlEOxTNNxZ1wtKy7PtZGmsSSATq2e6+bw38Ae
++Op0XnzzqcGjtDDofBmT7OFzZWjS9VZS6+DOOe2QHWle1nCHcHyH4ku6IRlsr9xkR
++NAIlOfnvHHxqJUenoeaZ4oQDjCBKS1KXygJO/tL7BLTQVn/xK1EmPvKNnjzWk4tR
++PnibUhhs5635qpOU/YPqFBh1JjVruZbsWcDAhRcew0uxONXOa9E+4lttQ9ySYa1A
++LvWqJuAX7gu2BsBMLyqfm811YnA7CIFMyO+HlqmkLFfv5L/xIRAXR7l26YGO0VwX
++CGjMfz4NVPMMke4nB7qa9NkpXQBQKMms3Qzd5JW0Hy9Ruj5O8GPcFZmV0twjd1uJ
++PD/cAjkWLaXjdNsJ16QWc2nghQRS6HYqKRX6j+CXOxupAgMBAAGjUzBRMB0GA1Ud
++DgQWBBRSCOU58j9NJZkMamt623qyCrhN3TAfBgNVHSMEGDAWgBRSCOU58j9NJZkM
++amt623qyCrhN3TAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4ICAQCq
++q4jxsWeNDv5Nq14hJtF9HB+ZL64zcZtRjJP1YgNs0QppKICmjPOL2nIMGmI/jKrs
++0eGAL/9XXNVHPxm1OPOncvimMMmU6emZfpMdEtTfKP43+Pg9HgKRjLoQp406vGeQ
++8ki/mbBhrItVPgEm3tu2AFA02XTYi+YxCI9kRZLGkM3FbgtOuTLPl0Z9y+kiPc9F
++uCSC03anBEqv+vDSI8+wODymQ/IJ3Jyz1lxIRDfp4qAekmy0jU2c91VOHHEmOmqq
++kqygGFRdwbe99m9yP63r6q0b5K3X2UnJ6bns0hmTwThYwpVPXLU8jdaTddbMukN2
++/Ef96Tsw8nWOEOPMySHOTIPgwyZRp26b0kA9EmhLwOP401SxXVQCmSRmtwNagmtg
++jJKmZoYBN+//D45ibK8z6Q0oOm9P+Whf/uUXehcRxBxyV3xz7k0wKGQbHj/ddwcy
++IUoIN4lrAlib+lK170kTKN352PDmrpo2gmIzPEsfurKAIMSelDl6H+kih16BtZ8y
++Nz6fh9Soqrg3OSAware8pxV7k51crBMoPLN78KoRV8MFCK4K7Fddq4rRISq6hiXq
++r1nsjoEPuKM9huprmZVZe9t5YcDa2I+wb3IiE3uwpZbAdaLDyQ5n6F/qpsiIkZXn
++gtcF7oqpG5oYrwCcZ53y/ezUgUg7PlSz2XwAGvQtgg==
+ -----END CERTIFICATE-----
+diff --git a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
+index 9d1664d609..337ce541a6 100644
+--- a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
++++ b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
+@@ -1,15 +1,52 @@
+------BEGIN RSA PRIVATE KEY-----
+-MIICXAIBAAKBgQCnyKBKxBkFG2a6MuLS8RxvF4LkOS4BUZDbBDQyESHCDW9Z2FOQ
+-VD+Dj6nTs9XuGpuArsMlyV6lr0tgBaqg0ZEBH8oEg+NYHJkyRYRwclgDmEpji0H1
+-CEnSkQJga+Rk/t2gqnQI6TRMkV8SPTdNVCytf1uYYDYCjDv2RfMnapuUnQIDAQAB
+-AoGANFzLkanTeSGNFM0uttBipFT9F4a00dqHz6JnO7zXAT26I5r8sU1pqQBb6uLz
+-/+Qz5Zwk8RUAQcsMRgJetuPQUb0JZjF6Duv24hNazqXBCu7AZzUenjafwmKC/8ri
+-KpX3fTwqzfzi//FKGgbXQ80yykSSliDL3kn/drATxsLCgQECQQDXhEFWLJ0vVZ1s
+-1Ekf+3NITE+DR16X+LQ4W6vyEHAjTbaNWtcTKdAWLA2l6N4WAAPYSi6awm+zMxx4
+-VomVTsjdAkEAx0z+e7natLeFcrrq8pbU+wa6SAP1VfhQWKitxL1e7u/QO90NCpxE
+-oQYKzMkmmpOOFjQwEMAy1dvFMbm4LHlewQJAC/ksDBaUcQHHqjktCtrUb8rVjAyW
+-A8lscckeB2fEYyG5J6dJVaY4ClNOOs5yMDS2Afk1F6H/xKvtQ/5CzInA/QJATDub
+-K+BPU8jO9q+gpuIi3VIZdupssVGmCgObVCHLakG4uO04y9IyPhV9lA9tALtoIf4c
+-VIvv5fWGXBrZ48kZAQJBAJmVCdzQxd9LZI5vxijUCj5EI4e+x5DRqVUvyP8KCZrC
+-AiNyoDP85T+hBZaSXK3aYGpVwelyj3bvo1GrTNwNWLw=
+------END RSA PRIVATE KEY-----
++-----BEGIN PRIVATE KEY-----
++MIIJQgIBADANBgkqhkiG9w0BAQEFAASCCSwwggkoAgEAAoICAQDolKefhOG5aLih
+++6vq1TUfDaGF9l5AVvqvq6ctc7ubLEUs26sQIw8fXZIbe0JZ31ZQ09NCb6TlnXrj
++6J+fdeXnUEbGOFJ5epih9va2tzrVGtf8giV7BlSUygo+5OAcW+Zmc2/305WZ7TC3
++UyATH1G8OthSoq9VoyiHCfXwqBvCWhnilTuEYeadHs3eFFFCHa9QV5eTanastr0z
++LBA54zrA93oJL/CNkijeDup/wt8FmKTDlmGZBqGYis+6ybP4v3s+27FeyZcHc05Y
++aSc5HDklRQT+iZRDsUzTcWdcLSsuz7WRprEkgE6tnuvm8N/AHjqdF5886nBo7Qw6
++HwZk+zhc2Vo0vVWUuvgzjntkB1pXtZwh3B8h+JLuiEZbK/cZETQCJTn57xx8aiVH
++p6HmmeKEA4wgSktSl8oCTv7S+wS00FZ/8StRJj7yjZ481pOLUT54m1IYbOet+aqT
++lP2D6hQYdSY1a7mW7FnAwIUXHsNLsTjVzmvRPuJbbUPckmGtQC71qibgF+4LtgbA
++TC8qn5vNdWJwOwiBTMjvh5appCxX7+S/8SEQF0e5dumBjtFcFwhozH8+DVTzDJHu
++Jwe6mvTZKV0AUCjJrN0M3eSVtB8vUbo+TvBj3BWZldLcI3dbiTw/3AI5Fi2l43Tb
++CdekFnNp4IUEUuh2KikV+o/glzsbqQIDAQABAoICAFw1q6tr5I48vY7DF+rXsuLn
++5ZUWE1IQ6fzB4lr72nJv/9EEGnMgYzt9PpMUsD6vdCpBgS2C0+6RHArFzJtNA+RM
++iHLIG7K7702veyr/xBx/MwiSlMeMv/XpkFxVI6E6skMGG2s3AMXxKvJTy5CpRx+I
++eQFyLG+Ya1X2lgJes/q+/CpAHkOjCOpcLySQC5NZ74q734V7nSdmn+Zs3tYEh+O/
++eiuwTP/j5b38Te5vVTqDxTciJPmljmXLCwa0N100lWlbcpvw8qbqiTI2Jm3XCbUE
++AzHjW9vmrF3cRS1fXxKFGShw3SRqlkbxjfeWoi8qDPUBS4m8LOr8qG9Wo5Nfon0z
++zLP4bci3zHDvVcaaZrrsUBs/yZbg+Dgka1DmX7ekmeccr2yTdKDFgPupYUyxVbTl
++a9ZLJysjFD7rgBv1ZclHonLp6Vbm+ZoTqvteo4ikAy6L9RtBWJ23XEK34PkP/+c5
++2vWZaOrnjSeBHbFce8cdJSxqWpP+eSCI5I9XbDrYFIsQ/gqKgtzDKy2ihJ2Y8STL
++yO4hyFPFjxc+Gg4/P2PpmT5CY2ty44M0BWs+JGW96CJPrrplf2lmQUQJj5LZY66X
++Z/4C9L7ZYtKZ+bs5SvU46yWugAvQZX22Xm9xLXWyVXRdx3bj+3M3fDnF9di/zdbh
++CgLx7oWPNrXc7FCajnn9AoIBAQD5FMYwRpw9NWT9WDxQwx+cSI4Icbd88ByTW63S
++LzeRwZA0J9/SfwO+aBRupzc9GkGXCiZcGMw3AGsCtig8yFlw8E5KnzN7KlftDMnM
++9NUxxzlR8VwKyLnZfG7sDTl057ZlUujnqhmt/F8F7dIy7FVO1dE/8nngA+FYTCOG
++UZdGjwyBDlDM0JJdUWGY3xslutcpCDN5mzSTKjy9drMvImAshRawxRF6WBpn7vr2
++nC6vciqfx1Mzx1vyk0Jm0ilaydDdLMADjt/iL4Nkr0BEs4k+UzQiKDwp8gu7abQ1
++eBfxd9Iar4htQa2I1Ewl6P01G/q+ZYwgHhJ9RVn4AxQXefILAoIBAQDvCouORdQX
++C8wsyp7MwXlF/3NQeNN5/+B2mhbxrBOf7PmMCXLnkRWcjwJtzypWFqJ0sqai/2+0
++bqbMcjX5maT8stT2shl3zXe/Ejt2e3TBYpc1tyuses8Kb5BMU8hu6tTd3G2CMXpD
++dT6DVemJZCTtwj9aBNIxSizvlgMolJnCpzhPnlfHSI6E+g3m/LTTo3HwbjMSw/Uq
++irgjOpI2wSBB6LZPSgjvfcYPRyWUk16L4A5uSX0cADnovDFLa5/h0wJvN/OoCSQg
++rLCXG5E18EyL5Wc58BCY1ZvxmjG3lQtgPxYu2Jwc36R/y/JKlxW5suER5ZNpbbD4
++uOyTt2VxMQ2bAoIBAQC5+MzRFqdo/AjfL5Y5JrbfVTzXCTDa09xCGd16ZU60QTWN
+++4ed/r+o1sUKqUcRFB2MzEM/2DQBjQpZB/CbEWvWa1XJWXxypXbowveZU+QqOnmN
++uQvj8WLyA3o+PNF9e9QvauwCrHpn8VpxbtPWuaYoKnUFreFZZQxHhPGxRBIS2JOZ
++eDrT8ZaWnkCkh1AZp5smQ71LOprSlmKrg4jd1GjCVMxQR5N5KXbtyv0OTCZ/UFqK
++2aRBsMPyJgkaBChkZPLRcKwc+/wlQRx1fHQb14DNTApMxoXFO7eOwqmOkpAt9iyl
++SBIwoS0UUI5ab88+bBmXNvKcuFdNuQ4nowTJUn9pAoIBADMNkILBXSvS5DeIyuO2
++Sp1tkoZUV+5NfPY3sMDK3KIibaW/+t+EOBZo4L7tKQCb8vRzl21mmsfxfgRaPDbj
++3r3tv9g0b4YLxxBy52pFscj/soXRai17SS7UZwA2QK+XzgDYbDcLNC6mIsTQG4Gx
++dsWk3/zs3KuUSQaehmwrWK+fIUK38c1pLK8v7LoxrLkqxlHwZ04RthHw8KTthH7X
++Pnl1J0LF8CSeOyfWLSuPUfkT0GEzptnNHpEbaHfQM6R6eaGhVJPF6AZme4y6YYgg
++m2ihhSt1n0XVEWpHYWjxFy3mK2mz75unFC4LM+NEY2p2zuUQoCw7NjnY3QYrfCnx
++rRMCggEAXeXsMSLFjjyuoL7iKbAxo52HD/P0fBoy58LyRcwfNVr0lvYan4pYEx+o
++KijIh9K16PqXZXKMA9v003B+ulmF8bJ7SddCZ5NGvnFhUTDe4DdTKgp2RuwQ3Bsc
++3skPIDbhVETyOLCtys34USHrq8U/0DlGY3eLRfxw9GnbKxSBGa/KEu/qQLPNUo50
++7xHZDg7GKeC3kqNJeqKM9rkp0VzIGkEnaD9127LeNDmERDfftxJzFoC/THvUBLfU
++6Sus2ZYwRE8VFvKC30Q45t/c54X3IuhYvAuiCuTmyfE4ruyzyOwKzhUkeeLq1APX
++g0veFbyfzlJ0q8qzD/iffqqIa2ZSmQ==
++-----END PRIVATE KEY-----
+diff --git a/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp b/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
+index 7ba3715e13..752aa122f6 100644
+--- a/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
++++ b/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
+@@ -179,6 +179,7 @@ void tst_QAccessibilityLinux::initTestCase()
+     QVERIFY(!address.isEmpty());
+ 
+     m_window = new AccessibleTestWindow();
++    m_window->setObjectName("mainWindow"_L1);
+     m_window->show();
+ 
+     QVERIFY(QTest::qWaitForWindowExposed(m_window));
+@@ -236,8 +237,11 @@ bool hasState(QDBusInterface *interface, AtspiStateType state)
+ void tst_QAccessibilityLinux::testLabel()
+ {
+     QLabel *l = new QLabel(m_window);
++    l->setObjectName("theObjectName"_L1);
+     l->setText("Hello A11y");
+     m_window->addWidget(l);
++    auto a11yEmpty = new QLabel(m_window);
++    m_window->addWidget(l);
+ 
+     // Application
+     QCOMPARE(getParent(mainWindow), QLatin1String(ATSPI_DBUS_PATH_ROOT));
+@@ -249,6 +253,8 @@ void tst_QAccessibilityLinux::testLabel()
+     QCOMPARE(getChildren(labelInterface).count(), 0);
+     QCOMPARE(labelInterface->call(QDBus::Block, "GetRoleName").arguments().first().toString(), QLatin1String("label"));
+     QCOMPARE(labelInterface->call(QDBus::Block, "GetRole").arguments().first().toUInt(), 29u);
++    QCOMPARE(labelInterface->call(QDBus::Block, "GetAccessibleId").arguments().first().toString(),
++             QLatin1String("mainWindow.theObjectName"));
+     QCOMPARE(getParent(labelInterface), mainWindow->path());
+     QVERIFY(!hasState(labelInterface, ATSPI_STATE_EDITABLE));
+     QVERIFY(hasState(labelInterface, ATSPI_STATE_READ_ONLY));
+@@ -256,7 +262,12 @@ void tst_QAccessibilityLinux::testLabel()
+     l->setText("New text");
+     QCOMPARE(labelInterface->property("Name").toString(), l->text());
+ 
++    auto *a11yEmptyInterface = getInterface(children.at(1), "org.a11y.atspi.Accessible");
++    QCOMPARE(a11yEmptyInterface->call(QDBus::Block, "GetAccessibleId").arguments().first().toString(),
++             QLatin1String("mainWindow.QLabel"));
++
+     m_window->clearChildren();
++    delete a11yEmptyInterface;
+     delete labelInterface;
+ }
+ 
+diff --git a/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+index 76df61c892..6d6d65b791 100644
+--- a/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
++++ b/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2022 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the test suite of the Qt Toolkit.
+@@ -68,6 +68,8 @@ private slots:
+     void query_exec();
+     void execErrorRecovery_data() { generic_data(); }
+     void execErrorRecovery();
++    void prematureExec_data() { generic_data(); }
++    void prematureExec();
+     void first_data() { generic_data(); }
+     void first();
+     void next_data() { generic_data(); }
+@@ -2770,6 +2772,35 @@ void tst_QSqlQuery::execErrorRecovery()
+     QVERIFY_SQL( q, exec() );
+ }
+ 
++void tst_QSqlQuery::prematureExec()
++{
++    QFETCH(QString, dbName);
++    // We only want the engine name, for addDatabase():
++    int cut = dbName.indexOf(QChar('@'));
++    if (cut < 0)
++        QSKIP("Failed to parse database type out of name");
++    dbName.truncate(cut);
++    cut = dbName.indexOf(QChar('_'));
++    if (cut >= 0)
++        dbName = dbName.mid(cut + 1);
++
++    auto db = QSqlDatabase::addDatabase(dbName);
++    QSqlQuery q(db);
++
++    QTest::ignoreMessage(QtWarningMsg,
++                         "QSqlDatabasePrivate::removeDatabase: connection "
++                         "'qt_sql_default_connection' is still in use, all "
++                         "queries will cease to work.");
++    QTest::ignoreMessage(QtWarningMsg,
++                         "QSqlDatabasePrivate::addDatabase: duplicate connection name "
++                         "'qt_sql_default_connection', old connection removed.");
++    auto otherDb = QSqlDatabase::addDatabase(dbName);
++
++    QTest::ignoreMessage(QtWarningMsg, "QSqlQuery::exec: called before driver has been set up");
++    // QTBUG-100037: shouldn't crash !
++    QVERIFY(!q.exec("select stuff from TheVoid"));
++}
++
+ void tst_QSqlQuery::lastInsertId()
+ {
+     QFETCH( QString, dbName );
+diff --git a/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp b/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
+index 4aa3f8d60b..d2050a61aa 100644
+--- a/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
++++ b/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
+@@ -115,6 +115,10 @@ void tst_QAbstractItemModelTester::standardItemModelZeroColumns()
+     // QTBUG-92886
+     model.insertRows(0, 5);
+     model.removeRows(1, 2);
++
++    const QModelIndex parentIndex = model.index(0, 0);
++    model.insertRows(0, 5, parentIndex);
++    model.removeRows(1, 2, parentIndex);
+ }
+ 
+ void tst_QAbstractItemModelTester::testInsertThroughProxy()
+diff --git a/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json b/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
+index 12a4a22a19..ce518e78fb 100644
+--- a/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
++++ b/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
+@@ -668,50 +668,6 @@
+         "inputFile": "task192552.h",
+         "outputRevision": 67
+     },
+-    {
+-        "classes": [
+-            {
+-                "className": "InlineSlotsWithThrowDeclaration",
+-                "object": true,
+-                "qualifiedClassName": "InlineSlotsWithThrowDeclaration",
+-                "slots": [
+-                    {
+-                        "access": "public",
+-                        "name": "a",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "b",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "c",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "d",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "e",
+-                        "returnType": "void"
+-                    }
+-                ],
+-                "superClasses": [
+-                    {
+-                        "access": "public",
+-                        "name": "QObject"
+-                    }
+-                ]
+-            }
+-        ],
+-        "inputFile": "task189996.h",
+-        "outputRevision": 67
+-    },
+     {
+         "classes": [
+             {
+diff --git a/qtbase/tests/auto/tools/moc/moc.pro b/qtbase/tests/auto/tools/moc/moc.pro
+index c324b3a8cd..4aceb78dc0 100644
+--- a/qtbase/tests/auto/tools/moc/moc.pro
++++ b/qtbase/tests/auto/tools/moc/moc.pro
+@@ -15,7 +15,7 @@ cross_compile: DEFINES += MOC_CROSS_COMPILED
+ HEADERS += using-namespaces.h no-keywords.h task87883.h c-comments.h backslash-newlines.h oldstyle-casts.h \
+            slots-with-void-template.h qinvokable.h namespaced-flags.h trigraphs.h \
+            escapes-in-string-literals.h cstyle-enums.h qprivateslots.h gadgetwithnoenums.h \
+-           dir-in-include-path.h single_function_keyword.h task192552.h task189996.h \
++           dir-in-include-path.h single_function_keyword.h task192552.h \
+            task234909.h task240368.h pure-virtual-signals.h cxx11-enums.h \
+            cxx11-final-classes.h \
+            cxx11-explicit-override-control.h \
+diff --git a/qtbase/tests/auto/tools/moc/task189996.h b/qtbase/tests/auto/tools/moc/task189996.h
+deleted file mode 100644
+index f94a051b3a..0000000000
+--- a/qtbase/tests/auto/tools/moc/task189996.h
++++ /dev/null
+@@ -1,47 +0,0 @@
+-/****************************************************************************
+-**
+-** Copyright (C) 2016 The Qt Company Ltd.
+-** Contact: https://www.qt.io/licensing/
+-**
+-** This file is part of the test suite of the Qt Toolkit.
+-**
+-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+-** 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 General Public License Usage
+-** Alternatively, this file may be used under the terms of the GNU
+-** General Public License version 3 as published by the Free Software
+-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+-** 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-3.0.html.
+-**
+-** $QT_END_LICENSE$
+-**
+-****************************************************************************/
+-// inline functions can have throw declarations
+-
+-#ifndef TASK189996_H
+-#define TASK189996_H
+-
+-#include <QObject>
+-
+-class InlineSlotsWithThrowDeclaration : public QObject
+-{
+-    Q_OBJECT
+-
+-public slots:
+-    void a() throw() { }
+-    void b() const throw() { }
+-    void c() throw();
+-    void d() throw(int) { }
+-    void e() const throw(int,double) { }
+-};
+-
+-#endif
+diff --git a/qtbase/tests/auto/tools/moc/tst_moc.cpp b/qtbase/tests/auto/tools/moc/tst_moc.cpp
+index c716aead21..15dd9e41e5 100644
+--- a/qtbase/tests/auto/tools/moc/tst_moc.cpp
++++ b/qtbase/tests/auto/tools/moc/tst_moc.cpp
+@@ -631,7 +631,6 @@ public:
+ private slots:
+     void initTestCase();
+ 
+-    void slotWithException() throw(MyStruct);
+     void dontStripNamespaces();
+     void oldStyleCasts();
+     void warnOnExtraSignalSlotQualifiaction();
+@@ -673,7 +672,6 @@ private slots:
+     void templateGtGt();
+     void qprivateslots();
+     void qprivateproperties();
+-    void inlineSlotsWithThrowDeclaration();
+     void warnOnPropertyWithoutREAD();
+     void constructors();
+     void typenameWithUnsigned();
+@@ -784,12 +782,6 @@ void tst_Moc::initTestCase()
+ #endif
+ }
+ 
+-void tst_Moc::slotWithException() throw(MyStruct)
+-{
+-    // be happy
+-    QVERIFY(true);
+-}
+-
+ void tst_Moc::dontStripNamespaces()
+ {
+     Sender sender;
+@@ -824,7 +816,7 @@ void tst_Moc::oldStyleCasts()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-Wold-style-cast" << "-I" << "."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -894,7 +886,7 @@ void tst_Moc::inputFileNameWithDotsButNoExtension()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-I" << ".."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -1174,7 +1166,7 @@ void tst_Moc::ignoreOptionClashes()
+     QStringList gccArgs;
+     gccArgs << "-c" << "-x" << "c++" << "-I" << ".."
+          << "-I" << qtIncludePath << "-I" << includeDir << "-o" << "/dev/null"
+-         << "-fPIC" << "-std=c++11" <<  "-";
++         << "-fPIC" << "-std=c++1z" <<  "-";
+     proc.start("gcc", gccArgs);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -1593,21 +1585,6 @@ void tst_Moc::qprivateproperties()
+ 
+ }
+ 
+-#include "task189996.h"
+-
+-void InlineSlotsWithThrowDeclaration::c() throw() {}
+-
+-void tst_Moc::inlineSlotsWithThrowDeclaration()
+-{
+-    InlineSlotsWithThrowDeclaration tst;
+-    const QMetaObject *mobj = tst.metaObject();
+-    QVERIFY(mobj->indexOfSlot("a()") != -1);
+-    QVERIFY(mobj->indexOfSlot("b()") != -1);
+-    QVERIFY(mobj->indexOfSlot("c()") != -1);
+-    QVERIFY(mobj->indexOfSlot("d()") != -1);
+-    QVERIFY(mobj->indexOfSlot("e()") != -1);
+-}
+-
+ void tst_Moc::warnOnPropertyWithoutREAD()
+ {
+ #ifdef MOC_CROSS_COMPILED
+@@ -1869,7 +1846,7 @@ void tst_Moc::notifyError()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-I" << "."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+diff --git a/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+index c355ee9665..88c09de8e0 100644
+--- a/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
++++ b/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+@@ -251,6 +251,7 @@ private slots:
+     void testResetCachedSizeHint();
+     void statusTips();
+     void testRemovingColumnsViaLayoutChanged();
++    void testModelMovingColumns();
+ 
+ protected:
+     void setupTestData(bool use_reset_model = false);
+@@ -360,6 +361,12 @@ public:
+         endRemoveColumns();
+     }
+ 
++    void moveColumn(int from, int to)
++    {
++        beginMoveColumns(QModelIndex(), from, from, QModelIndex(), to);
++        endMoveColumns();
++    }
++
+     void cleanup()
+     {
+         emit layoutAboutToBeChanged();
+@@ -3627,5 +3634,18 @@ void tst_QHeaderView::testRemovingColumnsViaLayoutChanged()
+     // The main point of this test is that the section-size restoring code didn't go out of bounds.
+ }
+ 
++void tst_QHeaderView::testModelMovingColumns()
++{
++    QtTestModel model(10, 10);
++    QHeaderView hv(Qt::Horizontal);
++    hv.setModel(&model);
++    hv.resizeSections(QHeaderView::ResizeToContents);
++    hv.show();
++
++    QPersistentModelIndex index3 = model.index(0, 3);
++    model.moveColumn(3, 1);
++    QCOMPARE(index3.column(), 1);
++}
++
+ QTEST_MAIN(tst_QHeaderView)
+ #include "tst_qheaderview.moc"
+diff --git a/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+index 761357b252..06bb706074 100644
+--- a/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
++++ b/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+@@ -397,6 +397,7 @@ private slots:
+     void checkHeaderMinSize();
+ 
+     void resizeToContents();
++    void resizeToContentsSpans();
+ 
+     void tabFocus();
+     void bigModel();
+@@ -3721,6 +3722,70 @@ void tst_QTableView::resizeToContents()
+ 
+ }
+ 
++
++class SpanModel : public QAbstractTableModel
++{
++public:
++    SpanModel(bool sectionsMoved)
++        : _sectionsMoved(sectionsMoved)
++    {}
++    int columnCount(const QModelIndex & = {}) const override { return 2; }
++    int rowCount(const QModelIndex & = {}) const override { return 1; }
++    QVariant data(const QModelIndex &idx, int role = Qt::DisplayRole) const override
++    {
++        if (role != Qt::DisplayRole)
++            return QVariant();
++        const int col = _sectionsMoved ? 1 - idx.column() : idx.column();
++        if (col == 0)
++            return "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.";
++        return QVariant();
++    }
++private:
++    bool _sectionsMoved;
++};
++
++
++void tst_QTableView::resizeToContentsSpans()
++{
++    SpanModel model1(false);
++    SpanModel model2(true);
++    QTableView view1, view2, view3;
++    view1.setModel(&model1);
++    view2.setModel(&model2);
++    view2.horizontalHeader()->moveSection(0, 1);
++    view3.setModel(&model1);
++
++    view1.setSpan(0, 0, 1, 2);
++    view2.setSpan(0, 1, 1, 2);
++    view1.show();
++    view2.show();
++    view3.show();
++    QVERIFY(QTest::qWaitForWindowExposed(&view1));
++    QVERIFY(QTest::qWaitForWindowExposed(&view2));
++    QVERIFY(QTest::qWaitForWindowExposed(&view3));
++    view1.setColumnWidth(0, 100);
++    view1.setColumnWidth(1, 100);
++    view2.setColumnWidth(0, 100);
++    view2.setColumnWidth(1, 100);
++    view3.setColumnWidth(0, 200);
++
++    view1.resizeRowToContents(0);
++    view2.resizeRowToContents(0);
++    view3.resizeRowToContents(0);
++    QCOMPARE(view1.rowHeight(0), view3.rowHeight(0));
++    QCOMPARE(view2.rowHeight(0), view3.rowHeight(0));
++
++    view3.resizeColumnToContents(0);
++    view3.resizeRowToContents(0);
++    // height should be only 1 text line for easy testing
++    view1.setRowHeight(0, view3.verticalHeader()->sectionSize(0));
++    view2.setRowHeight(0, view3.verticalHeader()->sectionSize(0));
++    view1.resizeColumnToContents(0);
++    view2.resizeColumnToContents(1);
++    QCOMPARE(view1.columnWidth(0), view3.columnWidth(0) - view1.columnWidth(1));
++    QCOMPARE(view2.columnWidth(0), view3.columnWidth(0) - view2.columnWidth(1));
++}
++
+ QT_BEGIN_NAMESPACE
+ extern bool Q_WIDGETS_EXPORT qt_tab_all_widgets(); // qapplication.cpp
+ QT_END_NAMESPACE
+diff --git a/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+index a3b8ef78d8..4955cebd5d 100644
+--- a/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
++++ b/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+@@ -1498,7 +1498,7 @@ void tst_QApplication::desktopSettingsAware()
+     environment += QLatin1String("QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM=1");
+     testProcess.setEnvironment(environment);
+ #endif
+-    testProcess.start("desktopsettingsaware_helper");
++    testProcess.start("./desktopsettingsaware_helper");
+     QVERIFY2(testProcess.waitForStarted(),
+              qPrintable(QString::fromLatin1("Cannot start 'desktopsettingsaware_helper': %1").arg(testProcess.errorString())));
+     QVERIFY(testProcess.waitForFinished(10000));
+@@ -2452,7 +2452,7 @@ void tst_QApplication::qtbug_12673()
+ #if QT_CONFIG(process)
+     QProcess testProcess;
+     QStringList arguments;
+-    testProcess.start("modal_helper", arguments);
++    testProcess.start("./modal_helper", arguments);
+     QVERIFY2(testProcess.waitForStarted(),
+              qPrintable(QString::fromLatin1("Cannot start 'modal_helper': %1").arg(testProcess.errorString())));
+     QVERIFY(testProcess.waitForFinished(20000));
+diff --git a/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp b/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
+index eb108a40de..dca5528c1b 100644
+--- a/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
+@@ -41,6 +41,7 @@
+ 
+ #include <private/qguiapplication_p.h>
+ #include <qpa/qplatformintegration.h>
++#include <qpa/qplatformtheme.h>
+ 
+ class tst_QAbstractButton : public QObject
+ {
+@@ -76,6 +77,8 @@ private slots:
+     void keyNavigation();
+ #endif
+ 
++    void buttonPressKeys();
++
+ protected slots:
+     void onClicked();
+     void onToggled( bool on );
+@@ -269,7 +272,13 @@ void tst_QAbstractButton::setAutoRepeat()
+         QCOMPARE(press_count, click_count);
+         QVERIFY(click_count > 1);
+         break;
+-    case 4:
++    case 4: {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(Qt::Key_Enter)) {
++            QSKIP("platform theme has Key_Enter in ButtonPressKeys");
++        }
+         // check that pressing ENTER has no effect when autorepeat is false
+         testWidget->setDown( false );
+         testWidget->setAutoRepeat( false );
+@@ -286,7 +295,14 @@ void tst_QAbstractButton::setAutoRepeat()
+ 
+         QVERIFY( click_count == 0 );
+         break;
+-    case 5:
++    }
++    case 5: {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(Qt::Key_Enter)) {
++            QSKIP("platform theme has Key_Enter in ButtonPressKeys");
++        }
+         // check that pressing ENTER has no effect when autorepeat is true
+         testWidget->setDown( false );
+         testWidget->setAutoRepeat( true );
+@@ -304,6 +320,7 @@ void tst_QAbstractButton::setAutoRepeat()
+ 
+         QVERIFY( click_count == 0 );
+         break;
++    }
+     case 6:
+         // verify autorepeat is off by default.
+         MyButton tmp( 0);
+@@ -651,5 +668,16 @@ void tst_QAbstractButton::keyNavigation()
+ }
+ #endif
+ 
++void tst_QAbstractButton::buttonPressKeys()
++{
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(testWidget, buttonPressKeys[i]);
++        QCOMPARE(click_count, i + 1);
++    }
++}
++
+ QTEST_MAIN(tst_QAbstractButton)
+ #include "tst_qabstractbutton.moc"
+diff --git a/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+index 32437050f5..46b5af6d63 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+@@ -168,6 +168,7 @@ private slots:
+     void checkMenuItemPosWhenStyleSheetIsSet();
+     void checkEmbeddedLineEditWhenStyleSheetIsSet();
+     void propagateStyleChanges();
++    void buttonPressKeys();
+ 
+ private:
+     PlatformInputContext m_platformInputContext;
+@@ -1682,6 +1683,16 @@ void tst_QComboBox::setModel()
+     QCOMPARE(box.rootModelIndex(), rootModelIndex);
+     box.setModel(box.model());
+     QCOMPARE(box.rootModelIndex(), rootModelIndex);
++
++    // check that setting the same model as the completer's doesn't crash
++    QCompleter *completer = new QCompleter(&box);
++    box.setEditable(true);
++    box.setCompleter(completer);
++    auto *listModel = new QStringListModel({ "one", "two" }, completer);
++    completer->setModel(listModel);
++    QCOMPARE(listModel->rowCount(), 2); // make sure it wasn't deleted
++    box.setModel(listModel);
++    QCOMPARE(listModel->rowCount(), 2); // make sure it wasn't deleted
+ }
+ 
+ void tst_QComboBox::setCustomModelAndView()
+@@ -3632,5 +3643,24 @@ void tst_QComboBox::propagateStyleChanges()
+     QVERIFY(frameStyle.inquired);
+ }
+ 
++void tst_QComboBox::buttonPressKeys()
++{
++    QComboBox comboBox;
++    comboBox.setEditable(false);
++    comboBox.addItem(QString::number(1));
++    comboBox.addItem(QString::number(2));
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(&comboBox, buttonPressKeys[i]);
++        // On some platforms, a window will not be immediately visible,
++        // but take some event-loop iterations to complete.
++        // Using QTRY_VERIFY to deal with that.
++        QTRY_VERIFY(comboBox.view()->isVisible());
++        comboBox.hidePopup();
++    }
++}
++
+ QTEST_MAIN(tst_QComboBox)
+ #include "tst_qcombobox.moc"
+diff --git a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
+index be3cfcd104..c228fdfcca 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
++++ b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qcommandlinkbutton
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qcommandlinkbutton.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
+index 0044d33c66..4cf06296e4 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
+@@ -40,6 +40,9 @@
+ #include <QGridLayout>
+ #include <QPainter>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ class tst_QCommandLinkButton : public QObject
+ {
+     Q_OBJECT
+@@ -223,6 +226,13 @@ void tst_QCommandLinkButton::setAutoRepeat()
+     // check that pressing ENTER has no effect
+     resetCounters();
+     testWidget->setDown( false );
++    // Skip after reset if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
+     testWidget->setAutoRepeat( false );
+     QTest::keyPress( testWidget, Qt::Key_Enter );
+ 
+@@ -255,6 +265,14 @@ void tst_QCommandLinkButton::pressed()
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+ 
++    // Skip if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
++
+     QTest::keyPress( testWidget,Qt::Key_Enter );
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+diff --git a/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro b/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
+index 4a5e76ff65..a235fa1fac 100644
+--- a/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
++++ b/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qgroupbox
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qgroupbox.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp b/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
+index 4fb5d262ca..d8d7562b73 100644
+--- a/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
+@@ -35,6 +35,9 @@
+ #include <QRadioButton>
+ #include <QDialog>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ #include "qgroupbox.h"
+ 
+ class tst_QGroupBox : public QObject
+@@ -69,6 +72,7 @@ private slots:
+     void propagateFocus();
+     void task_QTBUG_19170_ignoreMouseReleaseEvent();
+     void task_QTBUG_15519_propagateMouseEvents();
++    void buttonPressKeys();
+ 
+ private:
+     bool checked;
+@@ -610,6 +614,20 @@ void tst_QGroupBox::task_QTBUG_15519_propagateMouseEvents()
+     QCOMPARE(parent.mouseMoved, true);
+ }
+ 
++void tst_QGroupBox::buttonPressKeys()
++{
++    QGroupBox groupBox;
++    groupBox.setCheckable(true);
++    QSignalSpy clickedSpy(&groupBox, &QGroupBox::clicked);
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(&groupBox, buttonPressKeys[i]);
++        QCOMPARE(clickedSpy.length(), i + 1);
++    }
++}
++
+ void tst_QGroupBox::sendMouseMoveEvent(QWidget *widget, const QPoint &localPos)
+ {
+     // Send a MouseMove event without actually moving the pointer
+diff --git a/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro b/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
+index 353ad06ca2..e55f6148f2 100644
+--- a/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
++++ b/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qpushbutton
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qpushbutton.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp b/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
+index e818514a79..4043e9326a 100644
+--- a/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
+@@ -41,6 +41,9 @@
+ #include <QStyleFactory>
+ #include <QTabWidget>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ class tst_QPushButton : public QObject
+ {
+ Q_OBJECT
+@@ -212,6 +215,13 @@ void tst_QPushButton::autoRepeat()
+     // check that pressing ENTER has no effect
+     resetCounters();
+     testWidget->setDown( false );
++    // Skip after reset if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
+     testWidget->setAutoRepeat( false );
+     QTest::keyPress( testWidget, Qt::Key_Enter );
+ 
+@@ -247,6 +257,14 @@ void tst_QPushButton::pressed()
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+ 
++    // Skip if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
++
+     QTest::keyPress( testWidget,Qt::Key_Enter );
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+diff --git a/qtbase/tests/manual/rhi/cubemap_render/buildshader.bat b/qtbase/tests/manual/rhi/cubemap_render/buildshader.bat
+old mode 100755
+new mode 100644
+Submodule qtconnectivity e957d481..056294c0:
+diff --git a/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp b/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
+index e2635fae..a8b8e3b9 100644
+--- a/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
++++ b/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
+@@ -563,9 +563,11 @@ void HciManager::handleHciAclPacket(const quint8 *data, int size)
+ 
+ void HciManager::handleLeMetaEvent(const quint8 *data)
+ {
+-    // Spec v4.2, Vol 2, part E, 7.7.65ff
++    // Spec v5.3, Vol 4, part E, 7.7.65.*
+     switch (*data) {
+-    case 0x1: {
++    case 0x1: // HCI_LE_Connection_Complete
++    case 0xA: // HCI_LE_Enhanced_Connection_Complete
++    {
+         const quint16 handle = bt_get_le16(data + 2);
+         emit connectionComplete(handle);
+         break;
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp b/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
+index 6a93143b..4a18cfc7 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
+@@ -320,7 +320,10 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_finishSdpScan(QBluetoothServiceD
+             for (const QBluetoothUuid &id : serviceClassUuids) {
+                 if (id.minimumSize() == 16) {
+                     serviceInfo.setServiceUuid(id);
+-                    serviceInfo.setServiceName(QBluetoothServiceDiscoveryAgent::tr("Custom Service"));
++                    if (serviceInfo.serviceName().isEmpty()) {
++                        serviceInfo.setServiceName(
++                                    QBluetoothServiceDiscoveryAgent::tr("Custom Service"));
++                    }
+                     QBluetoothServiceInfo::Sequence modSeq =
+                             serviceInfo.attribute(QBluetoothServiceInfo::ServiceClassIds).value<QBluetoothServiceInfo::Sequence>();
+                     modSeq.removeOne(QVariant::fromValue(id));
+@@ -334,8 +337,10 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_finishSdpScan(QBluetoothServiceD
+                 qCDebug(QT_BT_BLUEZ) << "Discovered services" << discoveredDevices.at(0).address().toString()
+                                      << serviceInfo.serviceName() << serviceInfo.serviceUuid()
+                                      << ">>>" << serviceInfo.serviceClassUuids();
+-
+-                emit q->serviceDiscovered(serviceInfo);
++                // Use queued connection to allow us finish the service looping; the application
++                // might call stop() when it has detected the service-of-interest.
++                QMetaObject::invokeMethod(q, "serviceDiscovered", Qt::QueuedConnection,
++                                          Q_ARG(QBluetoothServiceInfo, serviceInfo));
+             }
+         }
+     }
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp b/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
+index e4d85447..aadd4755 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
+@@ -593,7 +593,7 @@ void QBluetoothSocket::setSocketState(QBluetoothSocket::SocketState state)
+ bool QBluetoothSocket::canReadLine() const
+ {
+     Q_D(const QBluetoothSocketBase);
+-    return d->canReadLine();
++    return d->canReadLine() || QIODevice::canReadLine();
+ }
+ 
+ /*!
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp b/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
+index 084aa958..d6aa17a7 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
+@@ -284,6 +284,10 @@ void QBluetoothSocketPrivateBluezDBus::connectToService(
+         return;
+     }
+ 
++    if (service.socketProtocol() != QBluetoothServiceInfo::Protocol::UnknownProtocol)
++        socketType = service.socketProtocol();
++    qCDebug(QT_BT_BLUEZ) << "Socket protocol used:" << socketType;
++
+     connectToService(service.device().address(), targetService, openMode);
+ }
+ 
+diff --git a/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp b/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
+index 05bc1a0f..a7b5ef1f 100644
+--- a/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
++++ b/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
+@@ -142,7 +142,7 @@ void tst_QBluetoothSocket::initTestCase()
+     qDebug() << "Starting discovery";
+ 
+     sda->setUuidFilter(QBluetoothUuid(QString(TEST_SERVICE_UUID)));
+-    sda->start(QBluetoothServiceDiscoveryAgent::MinimalDiscovery);
++    sda->start(QBluetoothServiceDiscoveryAgent::FullDiscovery);
+ 
+     for (int connectTime = MaxConnectTime; !done_discovery && connectTime > 0; connectTime -= 1000)
+         QTest::qWait(1000);
+Submodule qtdeclarative f5701f0d..8defe7bf:
+diff --git a/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h b/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
+index b65b994d6c..15a8cd6878 100644
+--- a/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
++++ b/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
+@@ -86,7 +86,7 @@ public:
+         if (QTypeInfo<T>::isComplex) {
+             for (int i = 0; i < count; ++i)
+                 new (data + i) T(vector.at(i));
+-        } else {
++        } else if (count) {
+             memcpy(data, static_cast<const void*>(vector.constData()), count * sizeof(T));
+         }
+     }
+diff --git a/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp b/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
+index e57cdd8278..94613598af 100644
+--- a/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
++++ b/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
+@@ -1145,8 +1145,7 @@ void Heap::QObjectWrapper::markObjects(Heap::Base *that, QV4::MarkStack *markSta
+ void QObjectWrapper::destroyObject(bool lastCall)
+ {
+     Heap::QObjectWrapper *h = d();
+-    if (!h->internalClass)
+-        return; // destroyObject already got called
++    Q_ASSERT(h->internalClass);
+ 
+     if (h->object()) {
+         QQmlData *ddata = QQmlData::get(h->object(), false);
+@@ -1176,7 +1175,7 @@ void QObjectWrapper::destroyObject(bool lastCall)
+         }
+     }
+ 
+-    h->~Data();
++    h->destroy();
+ }
+ 
+ 
+diff --git a/qtdeclarative/src/qml/memory/qv4mm.cpp b/qtdeclarative/src/qml/memory/qv4mm.cpp
+index 06caf04e5a..da149a67c4 100644
+--- a/qtdeclarative/src/qml/memory/qv4mm.cpp
++++ b/qtdeclarative/src/qml/memory/qv4mm.cpp
+@@ -981,7 +981,7 @@ void MemoryManager::sweep(bool lastSweep, ClassDestroyStatsCallback classCountPt
+ 
+     if (MultiplyWrappedQObjectMap *multiplyWrappedQObjects = engine->m_multiplyWrappedQObjects) {
+         for (MultiplyWrappedQObjectMap::Iterator it = multiplyWrappedQObjects->begin(); it != multiplyWrappedQObjects->end();) {
+-            if (!it.value().isNullOrUndefined())
++            if (it.value().isNullOrUndefined())
+                 it = multiplyWrappedQObjects->erase(it);
+             else
+                 ++it;
+diff --git a/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp b/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
+index 2079a8ed04..a577cb2351 100644
+--- a/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
++++ b/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
+@@ -389,6 +389,12 @@ void QQmlDelegateModelPrivate::connectToAbstractItemModel()
+                       q,  QQmlDelegateModel, SLOT(_q_rowsRemoved(QModelIndex,int,int)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
+                       q,  QQmlDelegateModel, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsInserted(QModelIndex,int,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsInserted(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsRemoved(QModelIndex,int,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsRemoved(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsMoved(QModelIndex,int,int,QModelIndex,int)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
+                       q, QQmlDelegateModel, SLOT(_q_dataChanged(QModelIndex,QModelIndex,QVector<int>)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
+@@ -413,6 +419,12 @@ void QQmlDelegateModelPrivate::disconnectFromAbstractItemModel()
+                         q, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int)));
+     QObject::disconnect(aim, SIGNAL(rowsRemoved(QModelIndex,int,int)),
+                         q, SLOT(_q_rowsRemoved(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsInserted(QModelIndex,int,int)), q,
++                        SLOT(_q_columnsInserted(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsRemoved(QModelIndex,int,int)), q,
++                        SLOT(_q_columnsRemoved(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)), q,
++                        SLOT(_q_columnsMoved(QModelIndex,int,int,QModelIndex,int)));
+     QObject::disconnect(aim, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
+                         q, SLOT(_q_dataChanged(QModelIndex,QModelIndex,QVector<int>)));
+     QObject::disconnect(aim, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
+@@ -1973,6 +1985,38 @@ void QQmlDelegateModel::_q_rowsMoved(
+     }
+ }
+ 
++void QQmlDelegateModel::_q_columnsInserted(const QModelIndex &parent, int begin, int end)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if (parent == d->m_adaptorModel.rootIndex && begin == 0) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
++void QQmlDelegateModel::_q_columnsRemoved(const QModelIndex &parent, int begin, int end)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if (parent == d->m_adaptorModel.rootIndex && begin == 0) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
++void QQmlDelegateModel::_q_columnsMoved(const QModelIndex &parent, int start, int end,
++                                        const QModelIndex &destination, int column)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if ((parent == d->m_adaptorModel.rootIndex && start == 0)
++        || (destination == d->m_adaptorModel.rootIndex && column == 0)) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
+ void QQmlDelegateModel::_q_dataChanged(const QModelIndex &begin, const QModelIndex &end, const QVector<int> &roles)
+ {
+     Q_D(QQmlDelegateModel);
+diff --git a/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h b/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
+index 8aab4badca..d140bfbaaf 100644
+--- a/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
++++ b/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
+@@ -152,6 +152,9 @@ private Q_SLOTS:
+     void _q_itemsMoved(int from, int to, int count);
+     void _q_modelReset();
+     void _q_rowsInserted(const QModelIndex &,int,int);
++    void _q_columnsInserted(const QModelIndex &, int, int);
++    void _q_columnsRemoved(const QModelIndex &, int, int);
++    void _q_columnsMoved(const QModelIndex &, int, int, const QModelIndex &, int);
+     void _q_rowsAboutToBeRemoved(const QModelIndex &parent, int begin, int end);
+     void _q_rowsRemoved(const QModelIndex &,int,int);
+     void _q_rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int);
+diff --git a/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp b/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
+index 85719fdc80..78e2ab302c 100644
+--- a/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
++++ b/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
+@@ -46,6 +46,7 @@
+ #include "QtQuick/private/qquicktextinput_p.h"
+ #include "QtQuick/private/qquickaccessibleattached_p.h"
+ #include "QtQuick/qquicktextdocument.h"
++#include "QtQuick/qquickrendercontrol.h"
+ QT_BEGIN_NAMESPACE
+ 
+ #if QT_CONFIG(accessibility)
+@@ -57,7 +58,19 @@ QAccessibleQuickItem::QAccessibleQuickItem(QQuickItem *item)
+ 
+ QWindow *QAccessibleQuickItem::window() const
+ {
+-    return item()->window();
++    QQuickWindow *window = item()->window();
++
++    // For QQuickWidget the above window will be the offscreen QQuickWindow,
++    // which is not a part of the accessibility tree. Detect this case and
++    // return the window for the QQuickWidget instead.
++    if (window && !window->handle()) {
++        if (QQuickRenderControl *renderControl = QQuickWindowPrivate::get(window)->renderControl) {
++            if (QWindow *renderWindow = renderControl->renderWindow(nullptr))
++                return renderWindow;
++        }
++    }
++
++    return window;
+ }
+ 
+ int QAccessibleQuickItem::childCount() const
+@@ -113,19 +126,15 @@ QAccessibleInterface *QAccessibleQuickItem::childAt(int x, int y) const
+ QAccessibleInterface *QAccessibleQuickItem::parent() const
+ {
+     QQuickItem *parent = item()->parentItem();
+-    QQuickWindow *window = item()->window();
+-    QQuickItem *ci = window ? window->contentItem() : nullptr;
++    QQuickWindow *itemWindow = item()->window();
++    QQuickItem *ci = itemWindow ? itemWindow->contentItem() : nullptr;
+     while (parent && !QQuickItemPrivate::get(parent)->isAccessible && parent != ci)
+         parent = parent->parentItem();
+ 
+     if (parent) {
+         if (parent == ci) {
+-            // Jump out to the scene widget if the parent is the root item.
+-            // There are two root items, QQuickWindow::rootItem and
+-            // QQuickView::declarativeRoot. The former is the true root item,
+-            // but is not a part of the accessibility tree. Check if we hit
+-            // it here and return an interface for the scene instead.
+-            return QAccessible::queryAccessibleInterface(window);
++            // Jump out to the window if the parent is the root item
++            return QAccessible::queryAccessibleInterface(window());
+         } else {
+             while (parent && !parent->d_func()->isAccessible)
+                 parent = parent->parentItem();
+@@ -188,7 +197,7 @@ QAccessible::State QAccessibleQuickItem::state() const
+     QRect viewRect_ = viewRect();
+     QRect itemRect = rect();
+ 
+-    if (viewRect_.isNull() || itemRect.isNull() || !item()->window() || !item()->window()->isVisible() ||!item()->isVisible() || qFuzzyIsNull(item()->opacity()))
++    if (viewRect_.isNull() || itemRect.isNull() || !window() || !window()->isVisible() ||!item()->isVisible() || qFuzzyIsNull(item()->opacity()))
+         state.invisible = true;
+     if (!viewRect_.intersects(itemRect))
+         state.offscreen = true;
+@@ -201,6 +210,10 @@ QAccessible::State QAccessibleQuickItem::state() const
+     if (role() == QAccessible::EditableText)
+         if (auto ti = qobject_cast<QQuickTextInput *>(item()))
+             state.passwordEdit = ti->echoMode() != QQuickTextInput::Normal;
++    if (!item()->isEnabled()) {
++        state.focusable = false;
++        state.disabled = true;
++    }
+     return state;
+ }
+ 
+diff --git a/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h b/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
+index 39ffcaf39c..8baa01330c 100644
+--- a/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
++++ b/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
+@@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE
+ 
+ #if QT_CONFIG(accessibility)
+ 
+-class QAccessibleQuickWindow : public QAccessibleObject
++class Q_QUICK_EXPORT QAccessibleQuickWindow : public QAccessibleObject
+ {
+ public:
+     QAccessibleQuickWindow(QQuickWindow *object);
+diff --git a/qtdeclarative/src/quick/items/qquickdrag.cpp b/qtdeclarative/src/quick/items/qquickdrag.cpp
+index 8321fcfeed..383078b3b9 100644
+--- a/qtdeclarative/src/quick/items/qquickdrag.cpp
++++ b/qtdeclarative/src/quick/items/qquickdrag.cpp
+@@ -481,7 +481,9 @@ void QQuickDragAttached::setKeys(const QStringList &keys)
+     \qmlattachedproperty stringlist QtQuick::Drag::mimeData
+     \since 5.2
+ 
+-    This property holds a map of mimeData that is used during startDrag.
++    This property holds a map from mime type to data that is used during startDrag.
++    The mime data needs to be a \c string, or an \c ArrayBuffer with the data encoded
++    according to the mime type.
+ */
+ 
+ QVariantMap QQuickDragAttached::mimeData() const
+@@ -766,8 +768,12 @@ Qt::DropAction QQuickDragAttachedPrivate::startDrag(Qt::DropActions supportedAct
+     QDrag *drag = new QDrag(source ? source : q);
+     QMimeData *mimeData = new QMimeData();
+ 
+-    for (auto it = externalMimeData.cbegin(), end = externalMimeData.cend(); it != end; ++it)
+-        mimeData->setData(it.key(), it.value().toString().toUtf8());
++    for (auto it = externalMimeData.cbegin(), end = externalMimeData.cend(); it != end; ++it) {
++        if (static_cast<QMetaType::Type>(it.value().type()) == QMetaType::QByteArray)
++            mimeData->setData(it.key(), it.value().toByteArray());
++        else
++            mimeData->setData(it.key(), it.value().toString().toUtf8());
++    }
+ 
+     drag->setMimeData(mimeData);
+     if (pixmapLoader.isReady()) {
+diff --git a/qtdeclarative/src/quick/items/qquickitem.cpp b/qtdeclarative/src/quick/items/qquickitem.cpp
+index 75f1457816..dec0ae19ae 100644
+--- a/qtdeclarative/src/quick/items/qquickitem.cpp
++++ b/qtdeclarative/src/quick/items/qquickitem.cpp
+@@ -59,6 +59,7 @@
+ #include <QtCore/private/qnumeric_p.h>
+ #include <QtGui/qpa/qplatformtheme.h>
+ #include <QtCore/qloggingcategory.h>
++#include <QtCore/private/qduplicatetracker_p.h>
+ 
+ #include <private/qqmlglobal_p.h>
+ #include <private/qqmlengine_p.h>
+@@ -2326,6 +2327,7 @@ QQuickItem::QQuickItem(QQuickItemPrivate &dd, QQuickItem *parent)
+ QQuickItem::~QQuickItem()
+ {
+     Q_D(QQuickItem);
++    d->inDestructor = true;
+ 
+     if (d->windowRefCount > 1)
+         d->windowRefCount = 1; // Make sure window is set to null in next call to derefWindow().
+@@ -2526,6 +2528,7 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo
+     QQuickItem *current = item;
+     qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: startItem:" << startItem;
+     qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: firstFromItem:" << firstFromItem;
++    QDuplicateTracker<QQuickItem *> cycleDetector;
+     do {
+         qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: current:" << current;
+         qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: from:" << from;
+@@ -2592,7 +2595,10 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo
+         // traversed all of the chain (by compare the [current] item with [startItem])
+         // Since the [startItem] might be promoted to its parent if it is invisible,
+         // we still have to check [current] item with original start item
+-        if ((current == startItem || current == originalStartItem) && from == firstFromItem) {
++        // We might also run into a cycle before we reach firstFromItem again
++        // but note that we have to ignore current if we are meant to skip it
++        if (((current == startItem || current == originalStartItem) && from == firstFromItem) ||
++                (!skip && cycleDetector.hasSeen(current))) {
+             // wrapped around, avoid endless loops
+             if (item == contentItem) {
+                 qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: looped, return contentItem";
+@@ -2689,9 +2695,8 @@ void QQuickItem::setParentItem(QQuickItem *parentItem)
+ 
+         const bool wasVisible = isVisible();
+         op->removeChild(this);
+-        if (wasVisible) {
++        if (wasVisible && !op->inDestructor)
+             emit oldParentItem->visibleChildrenChanged();
+-        }
+     } else if (d->window) {
+         QQuickWindowPrivate::get(d->window)->parentlessItems.remove(this);
+     }
+@@ -2768,8 +2773,9 @@ void QQuickItem::setParentItem(QQuickItem *parentItem)
+ 
+     d->itemChange(ItemParentHasChanged, d->parentItem);
+ 
+-    emit parentChanged(d->parentItem);
+-    if (isVisible() && d->parentItem)
++    if (!d->inDestructor)
++        emit parentChanged(d->parentItem);
++    if (isVisible() && d->parentItem && !QQuickItemPrivate::get(d->parentItem)->inDestructor)
+         emit d->parentItem->visibleChildrenChanged();
+ }
+ 
+@@ -2965,7 +2971,8 @@ void QQuickItemPrivate::removeChild(QQuickItem *child)
+ 
+     itemChange(QQuickItem::ItemChildRemovedChange, child);
+ 
+-    emit q->childrenChanged();
++    if (!inDestructor)
++        emit q->childrenChanged();
+ }
+ 
+ void QQuickItemPrivate::refWindow(QQuickWindow *c)
+@@ -3194,6 +3201,7 @@ QQuickItemPrivate::QQuickItemPrivate()
+     , touchEnabled(false)
+ #endif
+     , hasCursorHandler(false)
++    , inDestructor(false)
+     , dirtyAttributes(0)
+     , nextDirtyItem(nullptr)
+     , prevDirtyItem(nullptr)
+@@ -5120,6 +5128,13 @@ void QQuickItem::componentComplete()
+         d->addToDirtyList();
+         QQuickWindowPrivate::get(d->window)->dirtyItem(this);
+     }
++
++#if QT_CONFIG(accessibility)
++    if (d->isAccessible && d->effectiveVisible) {
++        QAccessibleEvent ev(this, QAccessible::ObjectShow);
++        QAccessible::updateAccessibility(&ev);
++    }
++#endif
+ }
+ 
+ QQuickStateGroup *QQuickItemPrivate::_states()
+@@ -6106,9 +6121,11 @@ bool QQuickItemPrivate::setEffectiveVisibleRecur(bool newEffectiveVisible)
+         QAccessible::updateAccessibility(&ev);
+     }
+ #endif
+-    emit q->visibleChanged();
+-    if (childVisibilityChanged)
+-        emit q->visibleChildrenChanged();
++    if (!inDestructor) {
++        emit q->visibleChanged();
++        if (childVisibilityChanged)
++            emit q->visibleChildrenChanged();
++    }
+ 
+     return true;    // effective visibility DID change
+ }
+@@ -6157,6 +6174,15 @@ void QQuickItemPrivate::setEffectiveEnableRecur(QQuickItem *scope, bool newEffec
+     }
+ 
+     itemChange(QQuickItem::ItemEnabledHasChanged, effectiveEnable);
++#if QT_CONFIG(accessibility)
++    if (isAccessible) {
++        QAccessible::State changedState;
++        changedState.disabled = true;
++        changedState.focusable = true;
++        QAccessibleStateChangeEvent ev(q, changedState);
++        QAccessible::updateAccessibility(&ev);
++    }
++#endif
+     emit q->enabledChanged();
+ }
+ 
+diff --git a/qtdeclarative/src/quick/items/qquickitem_p.h b/qtdeclarative/src/quick/items/qquickitem_p.h
+index 841d91bb40..ade8fb61f2 100644
+--- a/qtdeclarative/src/quick/items/qquickitem_p.h
++++ b/qtdeclarative/src/quick/items/qquickitem_p.h
+@@ -472,6 +472,7 @@ public:
+     bool replayingPressEvent:1;
+     bool touchEnabled:1;
+     bool hasCursorHandler:1;
++    quint32 inDestructor:1; // has entered ~QQuickItem
+ 
+     enum DirtyType {
+         TransformOrigin         = 0x00000001,
+diff --git a/qtdeclarative/src/quick/items/qquickitemview.cpp b/qtdeclarative/src/quick/items/qquickitemview.cpp
+index 010a0152e1..f8ad168a17 100644
+--- a/qtdeclarative/src/quick/items/qquickitemview.cpp
++++ b/qtdeclarative/src/quick/items/qquickitemview.cpp
+@@ -1785,7 +1785,7 @@ void QQuickItemViewPrivate::refill(qreal from, qreal to)
+ 
+     do {
+         bufferPause.stop();
+-        if (currentChanges.hasPendingChanges() || bufferedChanges.hasPendingChanges()) {
++        if (currentChanges.hasPendingChanges() || bufferedChanges.hasPendingChanges() || currentChanges.active) {
+             currentChanges.reset();
+             bufferedChanges.reset();
+             releaseVisibleItems(reusableFlag);
+diff --git a/qtdeclarative/src/quick/items/qquickmousearea_p_p.h b/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
+index fba383e268..0d63618622 100644
+--- a/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
++++ b/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
+@@ -61,7 +61,6 @@ QT_BEGIN_NAMESPACE
+ 
+ class QQuickMouseEvent;
+ class QQuickMouseArea;
+-class QQuickPointerMask;
+ class QQuickMouseAreaPrivate : public QQuickItemPrivate
+ {
+     Q_DECLARE_PUBLIC(QQuickMouseArea)
+@@ -100,7 +99,6 @@ public:
+ #if QT_CONFIG(quick_draganddrop)
+     QQuickDrag *drag;
+ #endif
+-    QPointer<QQuickPointerMask> mask;
+     QPointF startScene;
+     QPointF targetStartPos;
+     QPointF lastPos;
+diff --git a/qtdeclarative/src/quick/items/qquicktext.cpp b/qtdeclarative/src/quick/items/qquicktext.cpp
+index 6230186933..e823ca1095 100644
+--- a/qtdeclarative/src/quick/items/qquicktext.cpp
++++ b/qtdeclarative/src/quick/items/qquicktext.cpp
+@@ -2168,7 +2168,7 @@ void QQuickText::resetMaximumLineCount()
+     <img src="" align="top,middle,bottom" width="" height=""> - inline images
+     <ol type="">, <ul type=""> and <li> - ordered and unordered lists
+     <pre></pre> - preformatted
+-    &gt; &lt; &amp;
++    &gt; &lt; &amp; &quot; &nbsp; &apos;
+     \endcode
+ 
+     \c Text.StyledText parser is strict, requiring tags to be correctly nested.
+diff --git a/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp b/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
+index eb4db0f85e..2325a2665b 100644
+--- a/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
++++ b/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
+@@ -446,7 +446,7 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+         const char *textureRecord = allocatorData;
+         for (int i = 0; i < textureCount; ++i, textureRecord += Qtdf::TextureRecordSize) {
+-            if (textureRecord + Qtdf::TextureRecordSize > qtdfTableEnd) {
++            if (qtdfTableEnd - textureRecord < Qtdf::TextureRecordSize) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+@@ -462,7 +462,7 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+         const char *glyphRecord = textureRecord;
+         for (quint32 i = 0; i < glyphCount; ++i, glyphRecord += Qtdf::GlyphRecordSize) {
+-            if (glyphRecord + Qtdf::GlyphRecordSize > qtdfTableEnd) {
++            if (qtdfTableEnd - glyphRecord < Qtdf:: GlyphRecordSize) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+@@ -512,8 +512,8 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+             int width = texInfo->allocatedArea.width();
+             int height = texInfo->allocatedArea.height();
+-            qint64 size = width * height;
+-            if (reinterpret_cast<const char *>(textureData + size) > qtdfTableEnd) {
++            qint64 size = qint64(width) * height;
++            if (qtdfTableEnd - reinterpret_cast<const char *>(textureData) < size) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+diff --git a/qtdeclarative/src/quick/util/qquickstyledtext.cpp b/qtdeclarative/src/quick/util/qquickstyledtext.cpp
+index d531fc9205..a25af90414 100644
+--- a/qtdeclarative/src/quick/util/qquickstyledtext.cpp
++++ b/qtdeclarative/src/quick/util/qquickstyledtext.cpp
+@@ -564,6 +564,8 @@ void QQuickStyledTextPrivate::parseEntity(const QChar *&ch, const QString &textI
+                 textOut += QChar(60);
+             else if (entity == QLatin1String("amp"))
+                 textOut += QChar(38);
++            else if (entity == QLatin1String("apos"))
++                textOut += QChar(39);
+             else if (entity == QLatin1String("quot"))
+                 textOut += QChar(34);
+             else if (entity == QLatin1String("nbsp"))
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp
+new file mode 100644
+index 0000000000..8a1c901880
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp
+@@ -0,0 +1,110 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include "qaccessiblequickwidget_p.h"
++
++#include "qquickwidget_p.h"
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleQuickWidget::QAccessibleQuickWidget(QQuickWidget* widget)
++: QAccessibleWidget(widget)
++, m_accessibleWindow(QQuickWidgetPrivate::get(widget)->offscreenWindow)
++{
++    // NOTE: m_accessibleWindow is a QAccessibleQuickWindow, and not a
++    // QAccessibleQuickWidgetOffscreenWindow (defined below). This means
++    // it will return the Quick item child interfaces, which is what's needed here
++    // (unlike QAccessibleQuickWidgetOffscreenWindow, which will report 0 children).
++}
++
++QAccessibleInterface *QAccessibleQuickWidget::child(int index) const
++{
++    return m_accessibleWindow.child(index);
++}
++
++int QAccessibleQuickWidget::childCount() const
++{
++    return m_accessibleWindow.childCount();
++}
++
++int QAccessibleQuickWidget::indexOfChild(const QAccessibleInterface *iface) const
++{
++    return m_accessibleWindow.indexOfChild(iface);
++}
++
++QAccessibleInterface *QAccessibleQuickWidget::childAt(int x, int y) const
++{
++    return m_accessibleWindow.childAt(x, y);
++}
++
++QAccessibleQuickWidgetOffscreenWindow::QAccessibleQuickWidgetOffscreenWindow(QQuickWindow *window)
++:QAccessibleQuickWindow(window)
++{
++
++}
++
++QAccessibleInterface *QAccessibleQuickWidgetOffscreenWindow::child(int index) const
++{
++    Q_UNUSED(index);
++    return nullptr;
++}
++
++int QAccessibleQuickWidgetOffscreenWindow::childCount() const
++{
++    return 0;
++}
++
++int QAccessibleQuickWidgetOffscreenWindow::indexOfChild(const QAccessibleInterface *iface) const
++{
++    Q_UNUSED(iface);
++    return -1;
++}
++
++QAccessibleInterface *QAccessibleQuickWidgetOffscreenWindow::QAccessibleQuickWidgetOffscreenWindow::childAt(int x, int y) const
++{
++    Q_UNUSED(x);
++    Q_UNUSED(y);
++    return nullptr;
++}
++
++#endif // accessibility
++
++QT_END_NAMESPACE
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h
+new file mode 100644
+index 0000000000..7c2ab930e0
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h
+@@ -0,0 +1,95 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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 QACCESSIBLEQUICKWIDGET_H
++#define QACCESSIBLEQUICKWIDGET_H
++
++//
++//  W A R N I N G
++//  -------------
++//
++// This file is not part of the Qt API.  It exists purely as an
++// implementation detail.  This header file may change from version to
++// version without notice, or even be removed.
++//
++// We mean it.
++//
++
++#include "qquickwidget.h"
++#include <QtWidgets/qaccessiblewidget.h>
++
++#include <private/qaccessiblequickview_p.h>
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++// These classes implement the QQuickWiget accessibility switcharoo,
++// where the child items of the QQuickWidgetOffscreenWindow are reported
++// as child accessible interfaces of the QAccessibleQuickWidget.
++class QAccessibleQuickWidget: public QAccessibleWidget
++{
++public:
++    QAccessibleQuickWidget(QQuickWidget* widget);
++
++    QAccessibleInterface *child(int index) const override;
++    int childCount() const override;
++    int indexOfChild(const QAccessibleInterface *iface) const override;
++    QAccessibleInterface *childAt(int x, int y) const override;
++
++private:
++    QAccessibleQuickWindow m_accessibleWindow;
++    Q_DISABLE_COPY(QAccessibleQuickWidget)
++};
++
++class QAccessibleQuickWidgetOffscreenWindow: public QAccessibleQuickWindow
++{
++public:
++    QAccessibleQuickWidgetOffscreenWindow(QQuickWindow *window);
++    QAccessibleInterface *child(int index) const override;
++    int childCount() const override;
++    int indexOfChild(const QAccessibleInterface *iface) const override;
++    QAccessibleInterface *childAt(int x, int y) const override;
++};
++
++#endif // accessibility
++
++QT_END_NAMESPACE
++
++#endif
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp
+new file mode 100644
+index 0000000000..7ba88a1769
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp
+@@ -0,0 +1,60 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include "qaccessiblequickwidgetfactory_p.h"
++#include "qaccessiblequickwidget_p.h"
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleInterface *qAccessibleQuickWidgetFactory(const QString &classname, QObject *object)
++{
++    if (classname == QLatin1String("QQuickWidget")) {
++        return new QAccessibleQuickWidget(qobject_cast<QQuickWidget *>(object));
++    } else if (classname == QLatin1String("QQuickWidgetOffscreenWindow")) {
++        return new QAccessibleQuickWidgetOffscreenWindow(qobject_cast<QQuickWindow *>(object));
++    }
++    return 0;
++}
++
++#endif // accessibility
++
++QT_END_NAMESPACE
++
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h
+new file mode 100644
+index 0000000000..8c63b09f81
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h
+@@ -0,0 +1,66 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include <QtGui/qaccessible.h>
++
++#ifndef QACCESSIBLEQUICKWIDGETFACTORY_H
++#define QACCESSIBLEQUICKWIDGETFACTORY_H
++
++//
++//  W A R N I N G
++//  -------------
++//
++// This file is not part of the Qt API.  It exists purely as an
++// implementation detail.  This header file may change from version to
++// version without notice, or even be removed.
++//
++// We mean it.
++//
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleInterface *qAccessibleQuickWidgetFactory(const QString &classname, QObject *object);
++
++#endif
++
++QT_END_NAMESPACE
++
++#endif
+diff --git a/qtdeclarative/src/quickwidgets/qquickwidget.cpp b/qtdeclarative/src/quickwidgets/qquickwidget.cpp
+index 39780f8de3..9c97b43518 100644
+--- a/qtdeclarative/src/quickwidgets/qquickwidget.cpp
++++ b/qtdeclarative/src/quickwidgets/qquickwidget.cpp
+@@ -39,6 +39,7 @@
+ 
+ #include "qquickwidget.h"
+ #include "qquickwidget_p.h"
++#include "qaccessiblequickwidgetfactory_p.h"
+ 
+ #include "private/qquickwindow_p.h"
+ #include "private/qquickitem_p.h"
+@@ -75,9 +76,16 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++QQuickWidgetOffscreenWindow::QQuickWidgetOffscreenWindow(QQuickWindowPrivate &dd, QQuickRenderControl *control)
++:QQuickWindow(dd, control)
++{
++    setTitle(QString::fromLatin1("Offscreen"));
++    setObjectName(QString::fromLatin1("QQuickOffScreenWindow"));
++}
++
+ // override setVisble to prevent accidental offscreen window being created
+ // by base class.
+-class QQuickOffcreenWindowPrivate: public QQuickWindowPrivate {
++class QQuickWidgetOffscreenWindowPrivate: public QQuickWindowPrivate {
+ public:
+     void setVisible(bool visible) override {
+         Q_Q(QWindow);
+@@ -105,9 +113,8 @@ void QQuickWidgetPrivate::init(QQmlEngine* e)
+     Q_Q(QQuickWidget);
+ 
+     renderControl = new QQuickWidgetRenderControl(q);
+-    offscreenWindow = new QQuickWindow(*new QQuickOffcreenWindowPrivate(),renderControl);
+-    offscreenWindow->setTitle(QString::fromLatin1("Offscreen"));
+-    offscreenWindow->setObjectName(QString::fromLatin1("QQuickOffScreenWindow"));
++    offscreenWindow = new QQuickWidgetOffscreenWindow(*new QQuickWidgetOffscreenWindowPrivate(), renderControl);
++    offscreenWindow->setScreen(q->screen());
+     // Do not call create() on offscreenWindow.
+ 
+     // Check if the Software Adaptation is being used
+@@ -138,6 +145,10 @@ void QQuickWidgetPrivate::init(QQmlEngine* e)
+     QWidget::connect(offscreenWindow, &QQuickWindow::focusObjectChanged, q, &QQuickWidget::propagateFocusObjectChanged);
+     QObject::connect(renderControl, SIGNAL(renderRequested()), q, SLOT(triggerUpdate()));
+     QObject::connect(renderControl, SIGNAL(sceneChanged()), q, SLOT(triggerUpdate()));
++
++#if QT_CONFIG(accessibility)
++    QAccessible::installFactory(&qAccessibleQuickWidgetFactory);
++#endif
+ }
+ 
+ void QQuickWidgetPrivate::ensureEngine() const
+@@ -901,9 +912,7 @@ void QQuickWidgetPrivate::createContext()
+ 
+         context = new QOpenGLContext;
+         context->setFormat(offscreenWindow->requestedFormat());
+-        const QWindow *win = q->window()->windowHandle();
+-        if (win && win->screen())
+-            context->setScreen(win->screen());
++        context->setScreen(q->screen());
+         QOpenGLContext *shareContext = qt_gl_global_share_context();
+         if (!shareContext)
+             shareContext = QWidgetPrivate::get(q->window())->shareContext();
+@@ -1520,19 +1529,16 @@ bool QQuickWidget::event(QEvent *e)
+         d->handleWindowChange();
+         break;
+ 
+-    case QEvent::ScreenChangeInternal:
+-        if (QWindow *window = this->window()->windowHandle()) {
+-            QScreen *newScreen = window->screen();
+-
+-            if (d->offscreenWindow)
+-                d->offscreenWindow->setScreen(newScreen);
+-            if (d->offscreenSurface)
+-                d->offscreenSurface->setScreen(newScreen);
++    case QEvent::ScreenChangeInternal: {
++        QScreen *newScreen = screen();
++        if (d->offscreenWindow)
++            d->offscreenWindow->setScreen(newScreen);
++        if (d->offscreenSurface)
++            d->offscreenSurface->setScreen(newScreen);
+ #if QT_CONFIG(opengl)
+-            if (d->context)
+-                d->context->setScreen(newScreen);
++        if (d->context)
++            d->context->setScreen(newScreen);
+ #endif
+-        }
+ 
+         if (d->useSoftwareRenderer
+ #if QT_CONFIG(opengl)
+@@ -1545,7 +1551,7 @@ bool QQuickWidget::event(QEvent *e)
+             d->render(true);
+         }
+         break;
+-
++    }
+     case QEvent::Show:
+     case QEvent::Move:
+         d->updatePosition();
+diff --git a/qtdeclarative/src/quickwidgets/qquickwidget_p.h b/qtdeclarative/src/quickwidgets/qquickwidget_p.h
+index 881f7f9220..1a946bcc71 100644
+--- a/qtdeclarative/src/quickwidgets/qquickwidget_p.h
++++ b/qtdeclarative/src/quickwidgets/qquickwidget_p.h
+@@ -148,6 +148,14 @@ public:
+     bool forceFullUpdate;
+ };
+ 
++class QQuickWidgetOffscreenWindow: public QQuickWindow
++{
++    Q_OBJECT
++
++public:
++    QQuickWidgetOffscreenWindow(QQuickWindowPrivate &dd, QQuickRenderControl *control);
++};
++
+ QT_END_NAMESPACE
+ 
+ #endif // QQuickWidget_P_H
+diff --git a/qtdeclarative/src/quickwidgets/quickwidgets.pro b/qtdeclarative/src/quickwidgets/quickwidgets.pro
+index 2438e577ae..85d156b8a3 100644
+--- a/qtdeclarative/src/quickwidgets/quickwidgets.pro
++++ b/qtdeclarative/src/quickwidgets/quickwidgets.pro
+@@ -7,9 +7,13 @@ DEFINES   += QT_NO_URL_CAST_FROM_STRING QT_NO_INTEGER_EVENT_COORDINATES QT_NO_FO
+ HEADERS += \
+     qquickwidget.h \
+     qquickwidget_p.h \
+-    qtquickwidgetsglobal.h
++    qtquickwidgetsglobal.h \
++    qaccessiblequickwidget_p.h \
++    qaccessiblequickwidgetfactory_p.h
+ 
+ SOURCES += \
+-    qquickwidget.cpp
++    qquickwidget.cpp \
++    qaccessiblequickwidget.cpp \
++    qaccessiblequickwidgetfactory.cpp
+ 
+ load(qt_module)
+diff --git a/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+index 3b7d74df63..b75bf820d5 100644
+--- a/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
++++ b/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+@@ -102,6 +102,7 @@ private slots:
+     void valueConversion_RegularExpression();
+     void castWithMultipleInheritance();
+     void collectGarbage();
++    void collectGarbageNestedWrappersTwoEngines();
+     void gcWithNestedDataStructure();
+     void stacktrace();
+     void numberParsing_data();
+@@ -1809,6 +1810,44 @@ void tst_QJSEngine::collectGarbage()
+     QVERIFY(ptr.isNull());
+ }
+ 
++class TestObjectContainer : public QObject
++{
++    Q_OBJECT
++    Q_PROPERTY(QObject *dummy MEMBER m_dummy CONSTANT)
++
++public:
++    TestObjectContainer() : m_dummy(new QObject(this)) {}
++
++private:
++    QObject *m_dummy;
++};
++
++void tst_QJSEngine::collectGarbageNestedWrappersTwoEngines()
++{
++    QJSEngine engine1;
++    QJSEngine engine2;
++
++    TestObjectContainer container;
++    QQmlEngine::setObjectOwnership(&container, QQmlEngine::CppOwnership);
++
++    engine1.globalObject().setProperty("foobar", engine1.newQObject(&container));
++    engine2.globalObject().setProperty("foobar", engine2.newQObject(&container));
++
++    engine1.evaluate("foobar.dummy.baz = 42");
++    engine2.evaluate("foobar.dummy.baz = 43");
++
++    QCOMPARE(engine1.evaluate("foobar.dummy.baz").toInt(), 42);
++    QCOMPARE(engine2.evaluate("foobar.dummy.baz").toInt(), 43);
++
++    engine1.collectGarbage();
++    engine2.collectGarbage();
++
++    // The GC should not collect dummy object wrappers neither in engine1 nor engine2, we
++    // verify that by checking whether the baz property still has its previous value.
++    QCOMPARE(engine1.evaluate("foobar.dummy.baz").toInt(), 42);
++    QCOMPARE(engine2.evaluate("foobar.dummy.baz").toInt(), 43);
++}
++
+ void tst_QJSEngine::gcWithNestedDataStructure()
+ {
+     // The GC must be able to traverse deeply nested objects, otherwise this
+diff --git a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml
+new file mode 100644
+index 0000000000..206133bb39
+--- /dev/null
++++ b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml
+@@ -0,0 +1,11 @@
++import QtQuick 2.8
++
++ListView {
++    id: root
++    width: 200
++    height: 200
++
++    delegate: Text {
++        text: display
++    }
++}
+diff --git a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
+index 35f1e2c94d..1722447830 100644
+--- a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
++++ b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
+@@ -27,6 +27,8 @@
+ ****************************************************************************/
+ 
+ #include <QtTest/qtest.h>
++#include <QtCore/QConcatenateTablesProxyModel>
++#include <QtGui/QStandardItemModel>
+ #include <QtQml/qqmlcomponent.h>
+ #include <QtQmlModels/private/qqmldelegatemodel_p.h>
+ #include <QtQuick/qquickview.h>
+@@ -47,6 +49,7 @@ private slots:
+     void filterOnGroup_removeWhenCompleted();
+     void qtbug_86017();
+     void contextAccessedByHandler();
++    void redrawUponColumnChange();
+ };
+ 
+ class AbstractItemModel : public QAbstractItemModel
+@@ -186,6 +189,30 @@ void tst_QQmlDelegateModel::contextAccessedByHandler()
+     QVERIFY(root->property("works").toBool());
+ }
+ 
++void tst_QQmlDelegateModel::redrawUponColumnChange()
++{
++    QStandardItemModel m1;
++    m1.appendRow({
++            new QStandardItem("Banana"),
++            new QStandardItem("Coconut"),
++    });
++
++    QQuickView view(testFileUrl("redrawUponColumnChange.qml"));
++    QCOMPARE(view.status(), QQuickView::Ready);
++    view.show();
++    QQuickItem *root = view.rootObject();
++    root->setProperty("model", QVariant::fromValue<QObject *>(&m1));
++
++    QObject *item = root->property("currentItem").value<QObject *>();
++    QVERIFY(item);
++    QCOMPARE(item->property("text").toString(), "Banana");
++
++    QVERIFY(root);
++    m1.removeColumn(0);
++
++    QCOMPARE(item->property("text").toString(), "Coconut");
++}
++
+ QTEST_MAIN(tst_QQmlDelegateModel)
+ 
+ #include "tst_qqmldelegatemodel.moc"
+diff --git a/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp b/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
+index 5d635aa63b..824fd89e5b 100644
+--- a/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
++++ b/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
+@@ -76,10 +76,10 @@ void tst_qv4mm::multiWrappedQObjects()
+         QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 1);
+         QCOMPARE(engine2.memoryManager->m_pendingFreedObjectWrapperValue.size(), 0);
+ 
+-        // Moves the additional WeakValue from m_multiplyWrappedQObjects to
+-        // m_pendingFreedObjectWrapperValue. It's still alive after all.
++        // The additional WeakValue from m_multiplyWrappedQObjects hasn't been moved
++        // to m_pendingFreedObjectWrapperValue yet. It's still alive after all.
+         engine1.memoryManager->runGC();
+-        QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 2);
++        QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 1);
+ 
+         // engine2 doesn't own the object as engine1 was the first to wrap it above.
+         // Therefore, no effect here.
+diff --git a/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml b/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml
+new file mode 100644
+index 0000000000..889e480f3b
+--- /dev/null
++++ b/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml
+@@ -0,0 +1,13 @@
++import QtQuick 2.6
++
++Item {
++    visible: true
++    Item {
++        visible: false
++        Item {
++            objectName: "hiddenChild"
++            activeFocusOnTab: true
++            focus: true
++        }
++    }
++}
+diff --git a/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp b/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+index c8f251dbe1..c8ef36ee68 100644
+--- a/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
++++ b/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+@@ -67,6 +67,7 @@ private slots:
+     void activeFocusOnTab10();
+     void activeFocusOnTab_infiniteLoop_data();
+     void activeFocusOnTab_infiniteLoop();
++    void activeFocusOnTab_infiniteLoopControls();
+ 
+     void nextItemInFocusChain();
+     void nextItemInFocusChain2();
+@@ -1057,6 +1058,17 @@ void tst_QQuickItem::activeFocusOnTab_infiniteLoop()
+     QCOMPARE(item, window->rootObject());
+ }
+ 
++
++void tst_QQuickItem::activeFocusOnTab_infiniteLoopControls()
++{
++    auto source = testFileUrl("activeFocusOnTab_infiniteLoop3.qml");
++    QScopedPointer<QQuickView>window(new QQuickView());
++    window->setSource(source);
++    window->show();
++    QVERIFY(window->errors().isEmpty());
++    QTest::keyClick(window.get(), Qt::Key_Tab); // should not hang
++}
++
+ void tst_QQuickItem::nextItemInFocusChain()
+ {
+     if (!qt_tab_all_widgets())
+Submodule qtdoc c0c7bf07...79d6ef69:
+Submodule qtimageformats 2dcf2899..abe44c0f:
+diff --git a/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp b/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
+index dde783c..1bf9074 100644
+--- a/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
+@@ -462,8 +462,12 @@ static bool parseIconEntryInfo(ICNSEntry &icon)
+     if (isIconCompressed(icon))
+         return true;
+     // Icon depth:
+-    if (!depth.isEmpty())
+-        icon.depth = ICNSEntry::Depth(depth.toUInt());
++    if (!depth.isEmpty()) {
++        const uint depthUInt = depth.toUInt();
++        if (depthUInt > 32)
++            return false;
++        icon.depth = ICNSEntry::Depth(depthUInt);
++    }
+     // Try mono if depth not found
+     if (icon.depth == ICNSEntry::DepthUnknown)
+         icon.depth = ICNSEntry::DepthMono;
+@@ -515,6 +519,9 @@ static bool parseIconEntryInfo(ICNSEntry &icon)
+         }
+         icon.height = icon.width;
+     }
++    // Sanity check
++    if (icon.width == 0 || icon.width > 4096)
++        return false;
+     return true;
+ }
+ 
+@@ -685,7 +692,7 @@ bool QICNSHandler::canRead() const
+ bool QICNSHandler::read(QImage *outImage)
+ {
+     QImage img;
+-    if (!ensureScanned()) {
++    if (!ensureScanned() || m_currentIconIndex >= m_icons.size()) {
+         qWarning("QICNSHandler::read(): The device wasn't parsed properly!");
+         return false;
+     }
+@@ -892,7 +899,7 @@ bool QICNSHandler::scanDevice()
+             return false;
+ 
+         const qint64 blockDataOffset = device()->pos();
+-        if (!isBlockHeaderValid(blockHeader)) {
++        if (!isBlockHeaderValid(blockHeader, ICNSBlockHeaderSize + filelength - blockDataOffset)) {
+             qWarning("QICNSHandler::scanDevice(): Failed, bad header at pos %s. OSType \"%s\", length %u",
+                      QByteArray::number(blockDataOffset).constData(),
+                      nameFromOSType(blockHeader.ostype).constData(), blockHeader.length);
+@@ -927,11 +934,14 @@ bool QICNSHandler::scanDevice()
+         case ICNSBlockHeader::TypeOdrp:
+             // Icns container seems to have an embedded icon variant container
+             // Let's start a scan for entries
+-            while (device()->pos() < nextBlockOffset) {
++            while (!stream.atEnd() && device()->pos() < nextBlockOffset) {
+                 ICNSBlockHeader icon;
+                 stream >> icon;
++                if (stream.status() != QDataStream::Ok)
++                    return false;
+                 // Check for incorrect variant entry header and stop scan
+-                if (!isBlockHeaderValid(icon, blockDataLength))
++                quint64 remaining = blockDataLength - (device()->pos() - blockDataOffset);
++                if (!isBlockHeaderValid(icon, ICNSBlockHeaderSize + remaining))
+                     break;
+                 if (!addEntry(icon, device()->pos(), blockHeader.ostype))
+                     return false;
+@@ -1003,7 +1013,7 @@ bool QICNSHandler::scanDevice()
+             break;
+         }
+     }
+-    return true;
++    return (m_icons.size() > 0);
+ }
+ 
+ const ICNSEntry &QICNSHandler::getIconMask(const ICNSEntry &icon) const
+diff --git a/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp b/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
+index 5082023..cb34374 100644
+--- a/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
++++ b/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
+@@ -43,6 +43,7 @@
+ #include "qimage.h"
+ #include "qvariant.h"
+ #include "qcolor.h"
++#include "qimagereader.h"
+ 
+ #include <jasper/jasper.h>
+ #include <math.h> // for pow
+@@ -333,16 +334,46 @@ private:
+ Jpeg2000JasperReader::Jpeg2000JasperReader(QIODevice *iod, SubFormat format)
+     : jasperOk(true), ioDevice(iod), format(format), hasAlpha(false)
+ {
++#if JAS_VERSION_MAJOR < 3
+     if (jas_init()) {
+         jasperOk = false;
+         qDebug("Jasper Library initialization failed");
+     }
++#else
++    jas_conf_clear();
++#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
++    jas_conf_set_max_mem_usage(QImageReader::allocationLimit() * 1024 * 1024);
++#else
++    // 128MB seems to be enough.
++    jas_conf_set_max_mem_usage(128 * 1024 * 1024);
++#endif
++    if (jas_init_library()) {
++        jasperOk = false;
++        qDebug("Jasper library initialization failed");
++    }
++    if (jas_init_thread()) {
++        jas_cleanup_library();
++        jasperOk = false;
++        qDebug("Jasper thread initialization failed");
++    }
++#endif
+ }
+ 
+ Jpeg2000JasperReader::~Jpeg2000JasperReader()
+ {
++#if JAS_VERSION_MAJOR < 3
+     if (jasperOk)
+         jas_cleanup();
++#else
++    if (jasperOk) {
++        if (jas_cleanup_thread()) {
++            qDebug("Jasper thread cleanup failed");
++        }
++        if (jas_cleanup_library()) {
++            qDebug("Jasper library cleanup failed");
++        }
++    }
++#endif
+ }
+ 
+ /*! \internal
+@@ -857,7 +888,7 @@ bool Jpeg2000JasperReader::write(const QImage &image, int quality)
+     }
+ 
+     // Open an empty jasper stream that grows automatically
+-    jas_stream_t * memory_stream = jas_stream_memopen(0, -1);
++    jas_stream_t * memory_stream = jas_stream_memopen(0, 0);
+ 
+     // Jasper wants a non-const string.
+     char *str = qstrdup(jasperFormatString.toLatin1().constData());
+diff --git a/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp b/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
+index 1386750..ac8956c 100644
+--- a/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
+@@ -361,6 +361,8 @@ bool QTiffHandler::read(QImage *image)
+     }
+ 
+     TIFF *const tiff = d->tiff;
++    if (TIFFIsTiled(tiff) && TIFFTileSize64(tiff) > uint64_t(image->sizeInBytes())) // Corrupt image
++        return false;
+     const quint32 width = d->size.width();
+     const quint32 height = d->size.height();
+ 
+diff --git a/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp b/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
+index 82d38cb..d02eb05 100644
+--- a/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
+@@ -45,6 +45,7 @@
+ #include <qdebug.h>
+ #include <qpainter.h>
+ #include <qvariant.h>
++#include <QtEndian>
+ 
+ static const int riffHeaderSize = 12; // RIFF_HEADER_SIZE from webp/format_constants.h
+ 
+@@ -102,21 +103,23 @@ bool QWebpHandler::ensureScanned() const
+ 
+     m_scanState = ScanError;
+ 
+-    if (device()->isSequential()) {
+-        qWarning() << "Sequential devices are not supported";
++    QWebpHandler *that = const_cast<QWebpHandler *>(this);
++    const int headerBytesNeeded = sizeof(WebPBitstreamFeatures);
++    QByteArray header = device()->peek(headerBytesNeeded);
++    if (header.size() < headerBytesNeeded)
+         return false;
+-    }
+ 
+-    qint64 oldPos = device()->pos();
+-    device()->seek(0);
+-
+-    QWebpHandler *that = const_cast<QWebpHandler *>(this);
+-    QByteArray header = device()->peek(sizeof(WebPBitstreamFeatures));
++    // We do no random access during decoding, just a readAll() of the whole image file. So if
++    // if it is all available already, we can accept a sequential device. The riff header contains
++    // the file size minus 8 bytes header
++    qint64 byteSize = qFromLittleEndian<quint32>(header.constData() + 4);
++    if (device()->isSequential() && device()->bytesAvailable() < byteSize + 8) {
++        qWarning() << "QWebpHandler: Insufficient data available in sequential device";
++        return false;
++    }
+     if (WebPGetFeatures((const uint8_t*)header.constData(), header.size(), &(that->m_features)) == VP8_STATUS_OK) {
+         if (m_features.has_animation) {
+             // For animation, we have to read and scan whole file to determine loop count and images count
+-            device()->seek(oldPos);
+-
+             if (that->ensureDemuxer()) {
+                 that->m_loop = WebPDemuxGetI(m_demuxer, WEBP_FF_LOOP_COUNT);
+                 that->m_frameCount = WebPDemuxGetI(m_demuxer, WEBP_FF_FRAME_COUNT);
+@@ -126,17 +129,13 @@ bool QWebpHandler::ensureScanned() const
+                 if (that->m_features.has_alpha)
+                     that->m_composited->fill(Qt::transparent);
+ 
+-                // We do not reset device position since we have read in all data
+                 m_scanState = ScanSuccess;
+-                return true;
+             }
+         } else {
+             m_scanState = ScanSuccess;
+         }
+     }
+ 
+-    device()->seek(oldPos);
+-
+     return m_scanState == ScanSuccess;
+ }
+ 
+@@ -159,7 +158,7 @@ bool QWebpHandler::ensureDemuxer()
+ 
+ bool QWebpHandler::read(QImage *image)
+ {
+-    if (!ensureScanned() || device()->isSequential() || !ensureDemuxer())
++    if (!ensureScanned() || !ensureDemuxer())
+         return false;
+ 
+     QRect prevFrameRect;
+Submodule qtlocation 98a5c511..f991e28c:
+diff --git a/qtlocation/src/location/configure.json b/qtlocation/src/location/configure.json
+index 6d01a9a3..d1e623a1 100644
+--- a/qtlocation/src/location/configure.json
++++ b/qtlocation/src/location/configure.json
+@@ -9,7 +9,7 @@
+             "label": "Qt.labs.location experimental QML plugin",
+             "purpose": "Provides experimental QtLocation QML types",
+             "section": "Location",
+-            "condition": "config.opengl",
++            "condition": "features.opengl",
+             "output": [ "privateFeature" ]
+         },
+         "geoservices_osm": {
+diff --git a/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp b/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
+index a978573d..11e1466f 100644
+--- a/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
++++ b/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
+@@ -158,7 +158,7 @@ void QGeoMapObjectQSGSupport::updateMapObjects(QSGNode *root, QQuickWindow *wind
+     if (!root)
+         return;
+ 
+-    if (m_mapObjectsRootNode && m_mapObjectsRootNode->parent())
++    if (m_mapObjectsRootNode && !m_mapObjectsRootNode->parent())
+         root->appendChildNode(m_mapObjectsRootNode.get());
+ 
+     if (!m_mapObjectsRootNode) {
+diff --git a/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
+index 5a40467e..d123c6a8 100644
+--- a/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
+@@ -59,8 +59,10 @@ QT_BEGIN_NAMESPACE
+ static const QString kPrefixEsri(QStringLiteral("esri."));
+ static const QString kParamUserAgent(kPrefixEsri + QStringLiteral("useragent"));
+ 
+-static const QString kUrlGeocode(QStringLiteral("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates"));
+-static const QString kUrlReverseGeocode(QStringLiteral("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode"));
++static const QString kUrlGeocode(QStringLiteral("https://geocode.arcgis.com/arcgis/rest/services/"
++                                                "World/GeocodeServer/findAddressCandidates"));
++static const QString kUrlReverseGeocode(QStringLiteral(
++        "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode"));
+ 
+ static QString addressToQuery(const QGeoAddress &address)
+ {
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
+index 17492d94..96c12b1b 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
+@@ -46,7 +46,8 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-// JSON reference: http://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
++// JSON reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
+ 
+ static const QString kErrorMessage(QStringLiteral("Error %1: %2."));
+ static const QString kErrorJson(QStringLiteral("Error: invalide JSON document."));
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
+index 8cadfb29..92b6bb13 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
+@@ -44,7 +44,8 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-// JSON reference: http://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
++// JSON reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
+ 
+ GeoRouteReplyEsri::GeoRouteReplyEsri(QNetworkReply *reply, const QGeoRouteRequest &request,
+                                      QObject *parent) :
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
+index 0e6bc2c7..ed613f4b 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
+@@ -48,7 +48,8 @@ static const QString kPrefixEsri(QStringLiteral("esri."));
+ static const QString kParamUserAgent(kPrefixEsri + QStringLiteral("useragent"));
+ static const QString kParamToken(kPrefixEsri + QStringLiteral("token"));
+ 
+-static const QString kUrlRouting(QStringLiteral("http://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve"));
++static const QString kUrlRouting(QStringLiteral(
++        "https://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve"));
+ 
+ GeoRoutingManagerEngineEsri::GeoRoutingManagerEngineEsri(const QVariantMap &parameters,
+                                                          QGeoServiceProvider::Error *error,
+@@ -70,7 +71,8 @@ GeoRoutingManagerEngineEsri::~GeoRoutingManagerEngineEsri()
+ {
+ }
+ 
+-// REST reference: http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
++// REST reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
+ 
+ QGeoRouteReply *GeoRoutingManagerEngineEsri::calculateRoute(const QGeoRouteRequest &request)
+ {
+@@ -125,7 +127,7 @@ void GeoRoutingManagerEngineEsri::replyError(QGeoRouteReply::Error errorCode, co
+ QString GeoRoutingManagerEngineEsri::preferedDirectionLangage()
+ {
+     // list of supported langages is defined in:
+-    // http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
++    // https://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
+     const QStringList supportedLanguages = {
+         "ar", // Generate directions in Arabic
+         "cs", // Generate directions in Czech
+diff --git a/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
+index 5d15835d..24148f95 100644
+--- a/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
+@@ -230,7 +230,8 @@ QGeoMap *GeoTiledMappingManagerEngineEsri::createMap()
+ // ${y} = Y
+ // ${token} = Token
+ 
+-// template = 'http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{{z}}/{{y}}/{{x}}.png'
++// template =
++// 'https://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{{z}}/{{y}}/{{x}}.png'
+ 
+ bool GeoTiledMappingManagerEngineEsri::initializeMapSources(QGeoServiceProvider::Error *error,
+                                                             QString *errorString,
+diff --git a/qtlocation/src/plugins/geoservices/esri/maps.json b/qtlocation/src/plugins/geoservices/esri/maps.json
+index 8167ae7d..862e087d 100644
+--- a/qtlocation/src/plugins/geoservices/esri/maps.json
++++ b/qtlocation/src/plugins/geoservices/esri/maps.json
+@@ -6,8 +6,8 @@
+             "description": "ArcGIS Online World Street Map",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=3b93337983e9436f8db950e38a8629af'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=3b93337983e9436f8db950e38a8629af'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -16,8 +16,8 @@
+             "": "ArcGIS Online World Imagery",
+             "mobile": true,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -26,8 +26,8 @@
+             "description": "ArcGIS Online World Terrain Base",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=c61ad8ab017d49e1a82f580ee1298931'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=c61ad8ab017d49e1a82f580ee1298931'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -36,8 +36,8 @@
+             "description": "ArcGIS Online World Topography",
+             "mobile": true,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=30e5fe3149c34df1ba922e6f5bbf808f'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=30e5fe3149c34df1ba922e6f5bbf808f'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -46,8 +46,8 @@
+             "description": "This map presents land cover and detailed topographic maps for the United States.",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=99cd5fbd98934028802b4f797c4b1732'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=99cd5fbd98934028802b4f797c4b1732'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -56,8 +56,8 @@
+             "description": "National Geographic World Map",
+             "mobile": false,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=b9b1b422198944fbbd5250b3241691b6'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=b9b1b422198944fbbd5250b3241691b6'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -66,8 +66,8 @@
+             "description": "Thematic content providing a neutral background with minimal colors",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=ed712cb1db3e4bae9e85329040fb9a49'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=ed712cb1db3e4bae9e85329040fb9a49'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -76,8 +76,8 @@
+             "description": "Natural Earth physical map for the world",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=c4ec722a1cd34cf0a23904aadf8923a0'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=c4ec722a1cd34cf0a23904aadf8923a0'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -86,8 +86,8 @@
+             "description": "Portrays surface elevation as shaded relief",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=9c5370d0b54f4de1b48a3792d7377ff2'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=9c5370d0b54f4de1b48a3792d7377ff2'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -96,8 +96,8 @@
+             "description": "This map is designed to be used as a basemap by marine GIS professionals and as a reference map by anyone interested in ocean data",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=1e126e7520f9466c9ca28b8f28b5e500'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=1e126e7520f9466c9ca28b8f28b5e500'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -106,8 +106,8 @@
+             "description": "Thematic content providing a neutral background with minimal colors",
+             "mobile": false,
+             "night": true,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=a284a9b99b3446a3910d4144a50990f6'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=a284a9b99b3446a3910d4144a50990f6'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -116,8 +116,8 @@
+             "description": "DeLorme’s topographic basemap is a seamless global data set that portrays transportation, hydrography, jurisdiction boundaries, and major geographic features",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/Specialty/DeLorme_World_Base_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=b165c3df453e4be6b5ac4fdb241effbe'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/Specialty/DeLorme_World_Base_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=b165c3df453e4be6b5ac4fdb241effbe'>Esri</a> contributors"
+         }
+     ]
+ }
+diff --git a/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
+index 3858ddf5..af66f28e 100644
+--- a/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
+@@ -63,8 +63,10 @@ static const QString kCountriesKey(QStringLiteral("detailedCountries"));
+ static const QString kLocalizedNamesKey(QStringLiteral("localizedNames"));
+ static const QString kMaxLocationsKey(QStringLiteral("maxLocations"));
+ 
+-static const QUrl kUrlGeocodeServer("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer?f=pjson");
+-static const QUrl kUrlFindAddressCandidates("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates");
++static const QUrl kUrlGeocodeServer(
++        "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer?f=pjson");
++static const QUrl kUrlFindAddressCandidates("https://geocode.arcgis.com/arcgis/rest/services/World/"
++                                            "GeocodeServer/findAddressCandidates");
+ 
+ PlaceManagerEngineEsri::PlaceManagerEngineEsri(const QVariantMap &parameters, QGeoServiceProvider::Error *error,
+                                                QString *errorString) :
+Submodule qtmultimedia f0344079..0d7cc33a:
+diff --git a/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp b/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
+index 2b5325132..b68b4af1b 100644
+--- a/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
++++ b/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
+@@ -402,6 +402,8 @@ int QPulseAudioInput::bytesReady() const
+ 
+ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ {
++    Q_ASSERT(data != nullptr || len == 0);
++
+     m_bytesAvailable = checkBytesReady();
+ 
+     setError(QAudio::NoError);
+@@ -411,7 +413,8 @@ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ 
+     if (!m_pullMode && !m_tempBuffer.isEmpty()) {
+         readBytes = qMin(static_cast<int>(len), m_tempBuffer.size());
+-        memcpy(data, m_tempBuffer.constData(), readBytes);
++        if (readBytes)
++            memcpy(data, m_tempBuffer.constData(), readBytes);
+         m_totalTimeValue += readBytes;
+ 
+         if (readBytes < m_tempBuffer.size()) {
+@@ -502,9 +505,10 @@ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ 
+ void QPulseAudioInput::applyVolume(const void *src, void *dest, int len)
+ {
++    Q_ASSERT((src && dest) || len == 0);
+     if (m_volume < 1.f)
+         QAudioHelperInternal::qMultiplySamples(m_volume, m_format, src, dest, len);
+-    else
++    else if (len)
+         memcpy(dest, src, len);
+ }
+ 
+Submodule qtpim 02efef5e...f9a8f0fc (commits not present)
+Submodule qtquick3d b85cf622..47defc8b:
+diff --git a/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro b/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
+index ca5c499e..174a075b 100644
+--- a/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
++++ b/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
+@@ -10,7 +10,7 @@ QT_FOR_CONFIG += assetimporters-private
+ include($$OUT_PWD/../qtassetimporters-config.pri)
+ 
+ qtConfig(system-assimp):!if(cross_compile:host_build) {
+-    QMAKE_USE_PRIVATE += assimp
++    QMAKE_USE_PRIVATE += quick3d-assimp
+ } else {
+     include(../../../3rdparty/assimp/assimp.pri)
+ }
+Submodule qtquickcontrols2 3a657dc0..56ce8233:
+diff --git a/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp b/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
+index e5fe734f7..e36922775 100644
+--- a/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
++++ b/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
+@@ -38,6 +38,7 @@
+ #include "qwidgetplatformmenuitem_p.h"
+ 
+ #include <QtGui/qwindow.h>
++#include <QtGui/private/qhighdpiscaling_p.h>
+ #include <QtWidgets/qmenu.h>
+ #include <QtWidgets/qaction.h>
+ 
+@@ -145,7 +146,7 @@ void QWidgetPlatformMenu::showPopup(const QWindow *window, const QRect &targetRe
+ 
+     QPoint targetPos = targetRect.bottomLeft();
+     if (window)
+-        targetPos = window->mapToGlobal(targetPos);
++        targetPos = window->mapToGlobal(QHighDpi::fromNativeLocalPosition(targetPos, window));
+ 
+     const QWidgetPlatformMenuItem *widgetItem = qobject_cast<const QWidgetPlatformMenuItem *>(item);
+     m_menu->popup(targetPos, widgetItem ? widgetItem->action() : nullptr);
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
+index 950e4e099..b81fbea0b 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
+@@ -387,6 +387,17 @@ void QQuickAbstractButtonPrivate::itemImplicitHeightChanged(QQuickItem *item)
+         emit q->implicitIndicatorHeightChanged();
+ }
+ 
++void QQuickAbstractButtonPrivate::itemDestroyed(QQuickItem *item)
++{
++    Q_Q(QQuickAbstractButton);
++    QQuickControlPrivate::itemDestroyed(item);
++    if (item == indicator) {
++        indicator = nullptr;
++        emit q->implicitIndicatorWidthChanged();
++        emit q->implicitIndicatorHeightChanged();
++    }
++}
++
+ QQuickAbstractButton *QQuickAbstractButtonPrivate::findCheckedButton() const
+ {
+     Q_Q(const QQuickAbstractButton);
+@@ -1176,6 +1187,12 @@ QAccessible::Role QQuickAbstractButton::accessibleRole() const
+     }
+     return QAccessible::Button;
+ }
++
++void QQuickAbstractButton::accessiblePressAction()
++{
++    Q_D(QQuickAbstractButton);
++    d->trigger();
++}
+ #endif
+ 
+ QT_END_NAMESPACE
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
+index 0fa48980e..ab66220d0 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
+@@ -209,6 +209,7 @@ protected:
+ #if QT_CONFIG(accessibility)
+     void accessibilityActiveChanged(bool active) override;
+     QAccessible::Role accessibleRole() const override;
++    Q_INVOKABLE void accessiblePressAction();
+ #endif
+ 
+ private:
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
+index 9291c1a87..b729720f2 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
+@@ -109,6 +109,7 @@ public:
+ 
+     void itemImplicitWidthChanged(QQuickItem *item) override;
+     void itemImplicitHeightChanged(QQuickItem *item) override;
++    void itemDestroyed(QQuickItem *item) override;
+ 
+     // copied from qabstractbutton.cpp
+     static const int AUTO_REPEAT_DELAY = 300;
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp b/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
+index 2041e7741..8610cdfae 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
+@@ -145,7 +145,7 @@ int QQuickActionPrivate::ShortcutEntry::shortcutId() const
+ 
+ void QQuickActionPrivate::ShortcutEntry::grab(const QKeySequence &shortcut, bool enabled)
+ {
+-    if (shortcut.isEmpty())
++    if (shortcut.isEmpty() || m_shortcutId)
+         return;
+ 
+     Qt::ShortcutContext context = Qt::WindowShortcut; // TODO
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp b/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
+index f38c2b09c..6eed2a024 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
+@@ -225,6 +225,7 @@ void QQuickContainerPrivate::cleanup()
+     QObject::disconnect(contentModel, &QQmlObjectModel::countChanged, q, &QQuickContainer::countChanged);
+     QObject::disconnect(contentModel, &QQmlObjectModel::childrenChanged, q, &QQuickContainer::contentChildrenChanged);
+     delete contentModel;
++    contentModel = nullptr;
+ }
+ 
+ QQuickItem *QQuickContainerPrivate::itemAt(int index) const
+@@ -436,7 +437,7 @@ void QQuickContainerPrivate::contentChildren_clear(QQmlListProperty<QQuickItem>
+ void QQuickContainerPrivate::updateContentWidth()
+ {
+     Q_Q(QQuickContainer);
+-    if (hasContentWidth || qFuzzyCompare(contentWidth, implicitContentWidth))
++    if (hasContentWidth || qFuzzyCompare(contentWidth, implicitContentWidth) || !contentModel)
+         return;
+ 
+     contentWidth = implicitContentWidth;
+@@ -446,7 +447,7 @@ void QQuickContainerPrivate::updateContentWidth()
+ void QQuickContainerPrivate::updateContentHeight()
+ {
+     Q_Q(QQuickContainer);
+-    if (hasContentHeight || qFuzzyCompare(contentHeight, implicitContentHeight))
++    if (hasContentHeight || qFuzzyCompare(contentHeight, implicitContentHeight) || !contentModel)
+         return;
+ 
+     contentHeight = implicitContentHeight;
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp b/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
+index bbbd0e622..1f4b47343 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
+@@ -845,6 +845,13 @@ void QQuickControlPrivate::executeBackground(bool complete)
+         quickCompleteDeferred(q, backgroundName(), background);
+ }
+ 
++/*
++    \internal
++
++    Hides an item that was replaced by a newer one, rather than
++    deleting it, as the item is typically created in QML and hence
++    we don't own it.
++*/
+ void QQuickControlPrivate::hideOldItem(QQuickItem *item)
+ {
+     if (!item)
+@@ -863,6 +870,29 @@ void QQuickControlPrivate::hideOldItem(QQuickItem *item)
+ #endif
+ }
+ 
++/*
++    \internal
++
++    Named "unhide" because it's used for cases where an item
++    that was previously hidden by \l hideOldItem() wants to be
++    shown by a control again, such as a ScrollBar in ScrollView.
++*/
++void QQuickControlPrivate::unhideOldItem(QQuickControl *control, QQuickItem *item)
++{
++    Q_ASSERT(item);
++    qCDebug(lcItemManagement) << "unhiding old item" << item;
++
++    item->setVisible(true);
++    item->setParentItem(control);
++
++#if QT_CONFIG(accessibility)
++    // Add the item back in to the accessibility tree.
++    QQuickAccessibleAttached *accessible = accessibleAttached(item);
++    if (accessible)
++        accessible->setIgnored(false);
++#endif
++}
++
+ void QQuickControlPrivate::updateBaselineOffset()
+ {
+     Q_Q(QQuickControl);
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h b/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
+index 8e979079e..a6e624c91 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
+@@ -173,6 +173,7 @@ public:
+     virtual void executeBackground(bool complete = false);
+ 
+     static void hideOldItem(QQuickItem *item);
++    static void unhideOldItem(QQuickControl *control, QQuickItem *item);
+ 
+     void updateBaselineOffset();
+ 
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp b/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
+index e6db14eb5..6197d1547 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
+@@ -237,7 +237,7 @@ static QRectF alignedRect(Qt::LayoutDirection direction, Qt::Alignment alignment
+ void QQuickDialogButtonBoxPrivate::resizeContent()
+ {
+     Q_Q(QQuickDialogButtonBox);
+-    if (!contentItem)
++    if (!contentItem || !contentModel)
+         return;
+ 
+     QRectF geometry = q->boundingRect().adjusted(q->leftPadding(), q->topPadding(), -q->rightPadding(), -q->bottomPadding());
+@@ -322,6 +322,9 @@ void QQuickDialogButtonBoxPrivate::updateLayout()
+ qreal QQuickDialogButtonBoxPrivate::getContentWidth() const
+ {
+     Q_Q(const QQuickDialogButtonBox);
++    if (!contentModel)
++        return 0;
++
+     const int count = contentModel->count();
+     const qreal totalSpacing = qMax(0, count - 1) * spacing;
+     qreal totalWidth = totalSpacing;
+@@ -341,6 +344,9 @@ qreal QQuickDialogButtonBoxPrivate::getContentWidth() const
+ qreal QQuickDialogButtonBoxPrivate::getContentHeight() const
+ {
+     Q_Q(const QQuickDialogButtonBox);
++    if (!contentModel)
++        return 0;
++
+     const int count = contentModel->count();
+     qreal maxHeight = 0;
+     for (int i = 0; i < count; ++i) {
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp b/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
+index 91bd59184..0ce518f84 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
+@@ -399,8 +399,11 @@ void QQuickOverlay::itemChange(ItemChange change, const ItemChangeData &data)
+     Q_D(QQuickOverlay);
+     QQuickItem::itemChange(change, data);
+ 
+-    if (change == ItemChildAddedChange || change == ItemChildRemovedChange)
++    if (change == ItemChildAddedChange || change == ItemChildRemovedChange) {
+         setVisible(!d->allDrawers.isEmpty() || !childItems().isEmpty());
++        if (data.item->parent() == d->mouseGrabberPopup)
++            d->setMouseGrabberPopup(nullptr);
++    }
+ }
+ 
+ void QQuickOverlay::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp b/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
+index 4e2f509db..1c4b308cd 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
+@@ -797,6 +797,14 @@ void QQuickScrollBarAttachedPrivate::initHorizontal()
+     if (parent && parent == flickable->parentItem())
+         horizontal->stackAfter(flickable);
+ 
++    // If a scroll bar was previously hidden (due to e.g. setting a new contentItem
++    // on a ScrollView), we need to make sure that we un-hide it.
++    // We don't bother checking if the item is actually the old one, because
++    // if it's not, all of the things the function does (setting parent, visibility, etc.)
++    // should be no-ops anyway.
++    if (auto control = qobject_cast<QQuickControl*>(q_ptr->parent()))
++        QQuickControlPrivate::unhideOldItem(control, horizontal);
++
+     layoutHorizontal();
+     horizontal->setSize(area->property("widthRatio").toReal());
+     horizontal->setPosition(area->property("xPosition").toReal());
+@@ -818,6 +826,9 @@ void QQuickScrollBarAttachedPrivate::initVertical()
+     if (parent && parent == flickable->parentItem())
+         vertical->stackAfter(flickable);
+ 
++    if (auto control = qobject_cast<QQuickControl*>(q_ptr->parent()))
++        QQuickControlPrivate::unhideOldItem(control, vertical);
++
+     layoutVertical();
+     vertical->setSize(area->property("heightRatio").toReal());
+     vertical->setPosition(area->property("yPosition").toReal());
+diff --git a/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml b/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
+index 0e8b08352..cd4931184 100644
+--- a/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
++++ b/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
+@@ -576,4 +576,51 @@ TestCase {
+         verify(newHorizontalScrollBar.visible)
+         verify(!oldHorizontalScrollBar.visible)
+     }
++
++    Component {
++        id: bindingToContentItemAndStandaloneFlickable
++
++        Item {
++            width: 200
++            height: 200
++
++            property alias scrollView: scrollView
++
++            ScrollView {
++                id: scrollView
++                anchors.fill: parent
++                contentItem: listView
++
++                property Item someBinding: contentItem
++            }
++            ListView {
++                id: listView
++                model: 10
++                delegate: ItemDelegate {
++                    text: modelData
++                    width: listView.width
++                }
++            }
++        }
++    }
++
++    // Tests that scroll bars show up for a ScrollView where
++    // - its contentItem is declared as a standalone, separate item
++    // - there is a binding to contentItem (which causes a default Flickable to be created)
++    function test_bindingToContentItemAndStandaloneFlickable() {
++        let root = createTemporaryObject(bindingToContentItemAndStandaloneFlickable, testCase)
++        verify(root)
++
++        let control = root.scrollView
++        let verticalScrollBar = control.ScrollBar.vertical
++        let horizontalScrollBar = control.ScrollBar.horizontal
++        compare(verticalScrollBar.parent, control)
++        compare(horizontalScrollBar.parent, control)
++        verify(verticalScrollBar.visible)
++        verify(horizontalScrollBar.visible)
++
++        mouseDrag(verticalScrollBar, verticalScrollBar.width / 2, verticalScrollBar.height / 2, 0, 50)
++        verify(verticalScrollBar.active)
++        verify(horizontalScrollBar.active)
++    }
+ }
+diff --git a/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml b/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
+index b3fab41ca..10b6baa02 100644
+--- a/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
++++ b/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
+@@ -608,4 +608,27 @@ TestCase {
+         mouseClick(control.indicator)
+         verify(control.activeFocus)
+     }
++
++    Component {
++        id: deletionOrder1
++        Item {
++            Image { id: innerImage }
++            Switch { indicator: innerImage }
++        }
++    }
++
++    Component {
++        id: deletionOrder2
++        Item {
++            Switch { indicator: innerImage }
++            Image { id: innerImage }
++        }
++    }
++
++    function test_deletionOrder() {
++        var control1 = createTemporaryObject(deletionOrder1, testCase)
++        verify(control1)
++        var control2 = createTemporaryObject(deletionOrder2, testCase)
++        verify(control2)
++    }
+ }
+diff --git a/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml b/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml
+new file mode 100644
+index 000000000..9e4598b9f
+--- /dev/null
++++ b/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml
+@@ -0,0 +1,78 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the test suite of the Qt Toolkit.
++**
++** $QT_BEGIN_LICENSE:BSD$
++** Commercial License Usage
++** Licensees holding valid commercial Qt licenses may use this file in
++** accordance with the commercial license agreement provided with the
++** Software or, alternatively, in accordance with the terms contained in
++** a written agreement between you and The Qt Company. For licensing terms
++** and conditions see https://www.qt.io/terms-conditions. For further
++** information use the contact form at https://www.qt.io/contact-us.
++**
++** BSD License Usage
++** Alternatively, you may use this file under the terms of the BSD license
++** as follows:
++**
++** "Redistribution and use in source and binary forms, with or without
++** modification, are permitted provided that the following conditions are
++** met:
++**   * Redistributions of source code must retain the above copyright
++**     notice, this list of conditions and the following disclaimer.
++**   * Redistributions in binary form must reproduce the above copyright
++**     notice, this list of conditions and the following disclaimer in
++**     the documentation and/or other materials provided with the
++**     distribution.
++**   * Neither the name of The Qt Company Ltd nor the names of its
++**     contributors may be used to endorse or promote products derived
++**     from this software without specific prior written permission.
++**
++**
++** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
++** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
++** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
++** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
++** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
++** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
++** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
++** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
++** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
++** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
++** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
++**
++** $QT_END_LICENSE$
++**
++****************************************************************************/
++
++import QtQuick 2.15
++import QtQuick.Controls 2.15
++
++ApplicationWindow {
++    id: window
++    width: 400
++    height: 400
++    title: "releaseAfterExitTransition"
++
++    property alias popup: popup
++    property alias modalPopup: modalPopup
++
++    Popup {
++        id: popup
++        y: parent.height - height
++        width: 50
++        height: 50
++    }
++
++    Popup {
++        id: modalPopup
++        modal: true
++        y: parent.height - height
++        width: 50
++        height: 50
++        exit:  Transition { PauseAnimation { duration: 100 } }
++    }
++}
+diff --git a/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp b/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
+index 54952d128..3d50e2dd4 100644
+--- a/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
++++ b/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
+@@ -100,6 +100,7 @@ private slots:
+     void invisibleToolTipOpen();
+     void centerInOverlayWithinStackViewItem();
+     void destroyDuringExitTransition();
++    void releaseAfterExitTransition();
+ };
+ 
+ void tst_QQuickPopup::initTestCase()
+@@ -1575,6 +1576,34 @@ void tst_QQuickPopup::destroyDuringExitTransition()
+     QVERIFY(!button->isDown());
+ }
+ 
++void tst_QQuickPopup::releaseAfterExitTransition()
++{
++    QQuickApplicationHelper helper(this, "releaseAfterExitTransition.qml");
++    QVERIFY2(helper.ready, helper.failureMessage());
++
++    QQuickWindow *window = helper.window;
++    window->show();
++    QVERIFY(QTest::qWaitForWindowActive(window));
++
++    QQuickOverlay *overlay = QQuickOverlay::overlay(window);
++    QQuickPopup *modalPopup = window->property("modalPopup").value<QQuickPopup *>();
++    QQuickPopup *popup = window->property("popup").value<QQuickPopup *>();
++
++    modalPopup->open();
++    QTRY_VERIFY(modalPopup->isOpened());
++
++    QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++    // wait until the transition is finished and the overlay hides itself
++    QTRY_VERIFY(!overlay->isVisible());
++    QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++
++    popup->open();
++    QTRY_VERIFY(popup->isOpened());
++    QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++    QTRY_VERIFY(!popup->isOpened());
++}
++
++
+ QTEST_QUICKCONTROLS_MAIN(tst_QQuickPopup)
+ 
+ #include "tst_qquickpopup.moc"
+Submodule qtscript 5be95f96...4d8e4bd2 (commits not present)
+Submodule qtspeech 17fc9fde..255845e2:
+diff --git a/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp b/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
+index 6eb74b8..bcc7dd1 100644
+--- a/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
++++ b/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
+@@ -357,7 +357,9 @@ QVector<QLocale> QTextToSpeechEngineSpeechd::availableLocales() const
+ 
+ QVector<QVoice> QTextToSpeechEngineSpeechd::availableVoices() const
+ {
+-    return m_voices.values(m_currentLocale.name()).toVector();
++    QList<QVoice> resultList = m_voices.values(m_currentLocale.name());
++    std::reverse(resultList.begin(), resultList.end());
++    return resultList.toVector();
+ }
+ 
+ // We have no way of knowing our own client_id since speech-dispatcher seems to be incomplete
+Submodule qtsvg 0c05780e..a7a0f249:
+diff --git a/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp b/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
+index 561e77e..12e0574 100644
+--- a/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
++++ b/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
+@@ -191,6 +191,8 @@ bool QSvgIOHandler::read(QImage *image)
+             }
+         }
+         if (!finalSize.isEmpty()) {
++            if (qMax(finalSize.width(), finalSize.height()) > 0xffff)
++                return false; // Assume corrupted file
+             image->fill(d->backColor.rgba());
+             QPainter p(image);
+             d->r.render(&p, bounds);
+diff --git a/qtsvg/src/svg/qsvghandler.cpp b/qtsvg/src/svg/qsvghandler.cpp
+index a5f877f..8dda563 100644
+--- a/qtsvg/src/svg/qsvghandler.cpp
++++ b/qtsvg/src/svg/qsvghandler.cpp
+@@ -1393,9 +1393,10 @@ static void parseFont(QSvgNode *node,
+         case FontSizeNone:
+             break;
+         case FontSizeValue: {
+-            QSvgHandler::LengthType dummy; // should always be pixel size
+-            fontStyle->setSize(qMin(parseLength(attributes.fontSize, dummy, handler),
+-                                    qreal(0xffff)));
++            QSvgHandler::LengthType type;
++            qreal fs = parseLength(attributes.fontSize, type, handler);
++            fs = convertToPixels(fs, true, type);
++            fontStyle->setSize(qMin(fs, qreal(0xffff)));
+         }
+             break;
+         default:
+@@ -2513,6 +2514,8 @@ static bool parseAnimateTransformNode(QSvgNode *parent,
+             ++s;
+         }
+     }
++    if (vals.count() % 3 != 0)
++        return false;
+ 
+     bool ok = true;
+     int begin = parseClockValue(beginStr, &ok);
+@@ -2576,6 +2579,8 @@ static QSvgNode *createCircleNode(QSvgNode *parent,
+     qreal ncx = toDouble(cx);
+     qreal ncy = toDouble(cy);
+     qreal nr  = toDouble(r);
++    if (nr < 0.0)
++        return nullptr;
+ 
+     QRectF rect(ncx-nr, ncy-nr, nr*2, nr*2);
+     QSvgNode *circle = new QSvgCircle(parent, rect);
+@@ -3046,15 +3051,16 @@ static QSvgStyleProperty *createRadialGradientNode(QSvgNode *node,
+ 
+     qreal ncx = 0.5;
+     qreal ncy = 0.5;
+-    qreal nr  = 0.5;
+     if (!cx.isEmpty())
+         ncx = toDouble(cx);
+     if (!cy.isEmpty())
+         ncy = toDouble(cy);
++
++    qreal nr = 0.0;
+     if (!r.isEmpty())
+         nr = toDouble(r);
+-    if (nr < 0.5)
+-        nr = 0.5;
++    if (nr <= 0.0)
++        return nullptr;
+ 
+     qreal nfx = ncx;
+     if (!fx.isEmpty())
+@@ -3350,7 +3356,9 @@ static QSvgNode *createTextNode(QSvgNode *parent,
+     //### editable and rotate not handled
+     QSvgHandler::LengthType type;
+     qreal nx = parseLength(x, type, handler);
++    nx = convertToPixels(nx, true, type);
+     qreal ny = parseLength(y, type, handler);
++    ny = convertToPixels(ny, true, type);
+ 
+     QSvgNode *text = new QSvgText(parent, QPointF(nx, ny));
+     return text;
+@@ -3691,9 +3699,7 @@ void QSvgHandler::parse()
+         case QXmlStreamReader::EndElement:
+             endElement(xml->name());
+             ++remainingUnfinishedElements;
+-            // if we are using somebody else's qxmlstreamreader
+-            // we should not read until the end of the stream
+-            done = !m_ownsReader && (xml->name() == QLatin1String("svg"));
++            done = (xml->name() == QLatin1String("svg"));
+             break;
+         case QXmlStreamReader::Characters:
+             characters(xml->text());
+diff --git a/qtsvg/src/svg/qsvgstructure.cpp b/qtsvg/src/svg/qsvgstructure.cpp
+index b89608b..89c9e4e 100644
+--- a/qtsvg/src/svg/qsvgstructure.cpp
++++ b/qtsvg/src/svg/qsvgstructure.cpp
+@@ -255,9 +255,13 @@ inline static bool isSupportedSvgFeature(const QString &str)
+     };
+ 
+     if (str.length() <= MAX_WORD_LENGTH && str.length() >= MIN_WORD_LENGTH) {
++        const char16_t unicode44 = str.at(44).unicode();
++        const char16_t unicode45 = str.at(45).unicode();
++        if (unicode44 >= sizeof(asso_values) || unicode45 >= sizeof(asso_values))
++            return false;
+         const int key = str.length()
+-                        + asso_values[str.at(45).unicode()]
+-                        + asso_values[str.at(44).unicode()];
++                        + asso_values[unicode45]
++                        + asso_values[unicode44];
+         if (key <= MAX_HASH_VALUE && key >= 0)
+             return str == QLatin1String(wordlist[key]);
+     }
+diff --git a/qtsvg/src/svg/qsvgtinydocument.cpp b/qtsvg/src/svg/qsvgtinydocument.cpp
+index 63d0797..19e7154 100644
+--- a/qtsvg/src/svg/qsvgtinydocument.cpp
++++ b/qtsvg/src/svg/qsvgtinydocument.cpp
+@@ -433,8 +433,16 @@ void QSvgTinyDocument::draw(QPainter *p, QSvgExtraStates &)
+     draw(p);
+ }
+ 
++static bool isValidMatrix(const QTransform &transform)
++{
++    qreal determinant = transform.determinant();
++    return qIsFinite(determinant);
++}
++
+ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect, const QRectF &sourceRect)
+ {
++    QTransform oldTransform = p->worldTransform();
++
+     QRectF target = targetRect;
+     if (target.isEmpty()) {
+         QPaintDevice *dev = p->device();
+@@ -487,6 +495,9 @@ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect,
+         }
+ #endif
+     }
++
++    if (!isValidMatrix(p->worldTransform()))
++        p->setWorldTransform(oldTransform);
+ }
+ 
+ QRectF QSvgTinyDocument::boundsOnElement(const QString &id) const
+diff --git a/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp b/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
+index 36c76ec..db71e02 100644
+--- a/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
++++ b/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
+@@ -86,6 +86,8 @@ private slots:
+     void oss_fuzz_23731();
+     void oss_fuzz_24131();
+     void oss_fuzz_24738();
++    void illegalAnimateTransform_data();
++    void illegalAnimateTransform();
+ 
+ #ifndef QT_NO_COMPRESS
+     void testGzLoading();
+@@ -1646,5 +1648,22 @@ void tst_QSvgRenderer::oss_fuzz_24738()
+     QSvgRenderer().load(QByteArray("<svg><path d=\"a 2 1e-212.....\">"));
+ }
+ 
++void tst_QSvgRenderer::illegalAnimateTransform_data()
++{
++    QTest::addColumn<QByteArray>("svg");
++
++    QTest::newRow("case1") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" values=\"8,0,5,0\">");
++    QTest::newRow("case2") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" values=\"1,2\">");
++    QTest::newRow("case3") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" from=\".. 5 2\" to=\"f\">");
++    QTest::newRow("case4") << QByteArray("<svg><animateTransform type=\"scale\" begin=\"1\" dur=\"2\" by=\"--,..\">");
++}
++
++void tst_QSvgRenderer::illegalAnimateTransform()
++{
++    QFETCH(QByteArray, svg);
++    QSvgRenderer renderer;
++    QVERIFY(!renderer.load(svg)); // also shouldn't assert
++}
++
+ QTEST_MAIN(tst_QSvgRenderer)
+ #include "tst_qsvgrenderer.moc"
+Submodule qttools 6914f7c8..090e526e:
+diff --git a/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp b/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
+index feab1e2d5..cbfb82507 100644
+--- a/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
++++ b/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
+@@ -445,7 +445,9 @@ bool HelpGeneratorPrivate::insertFiles(const QStringList &files, const QString &
+     if (filterSetId < 0)
+         return false;
+     ++filterSetId;
+-    for (int attId : qAsConst(filterAtts)) {
++    QList<int> attValues = filterAtts.values();
++    std::sort(attValues.begin(), attValues.end());
++    for (int attId : qAsConst(attValues)) {
+         m_query->prepare(QLatin1String("INSERT INTO FileAttributeSetTable "
+             "VALUES(?, ?)"));
+         m_query->bindValue(0, filterSetId);
+Submodule qtwayland dfb0129c..2904e1b3:
+diff --git a/qtwayland/src/client/configure.json b/qtwayland/src/client/configure.json
+index 2f424580..29222357 100644
+--- a/qtwayland/src/client/configure.json
++++ b/qtwayland/src/client/configure.json
+@@ -149,8 +149,7 @@
+                     "#endif"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "vulkan-server-buffer": {
+             "label": "Vulkan Buffer Sharing",
+@@ -168,7 +167,8 @@
+                     "exportAllocInfo.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR;",
+                     "return 0;"
+                 ]
+-            }
++            },
++            "use": "wayland-client"
+         },
+         "egl_1_5-wayland": {
+             "label": "EGL 1.5 with Wayland Platform",
+@@ -183,7 +183,7 @@
+                     "eglGetPlatformDisplay(EGL_PLATFORM_WAYLAND_EXT, (struct wl_display *)(nullptr), nullptr);"
+                 ]
+             },
+-            "use": "egl"
++            "use": "egl wayland-client"
+         }
+     },
+ 
+diff --git a/qtwayland/src/client/global/qwaylandclientextension.cpp b/qtwayland/src/client/global/qwaylandclientextension.cpp
+index 125b1e19..edccfe63 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension.cpp
++++ b/qtwayland/src/client/global/qwaylandclientextension.cpp
+@@ -74,7 +74,10 @@ void QWaylandClientExtensionPrivate::handleRegistryGlobal(void *data, ::wl_regis
+ void QWaylandClientExtension::addRegistryListener()
+ {
+     Q_D(QWaylandClientExtension);
+-    d->waylandIntegration->display()->addRegistryListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++    if (!d->registered) {
++        d->waylandIntegration->display()->addRegistryListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++        d->registered = true;
++    }
+ }
+ 
+ QWaylandClientExtension::QWaylandClientExtension(const int ver)
+@@ -88,6 +91,13 @@ QWaylandClientExtension::QWaylandClientExtension(const int ver)
+     QMetaObject::invokeMethod(this, "addRegistryListener", Qt::QueuedConnection);
+ }
+ 
++QWaylandClientExtension::~QWaylandClientExtension()
++{
++    Q_D(QWaylandClientExtension);
++    if (d->registered && !QCoreApplication::closingDown())
++        d->waylandIntegration->display()->removeListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++}
++
+ QtWaylandClient::QWaylandIntegration *QWaylandClientExtension::integration() const
+ {
+     Q_D(const QWaylandClientExtension);
+diff --git a/qtwayland/src/client/global/qwaylandclientextension.h b/qtwayland/src/client/global/qwaylandclientextension.h
+index 98272e57..5bd28398 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension.h
++++ b/qtwayland/src/client/global/qwaylandclientextension.h
+@@ -63,6 +63,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandClientExtension : public QObject
+     Q_PROPERTY(bool active READ isActive NOTIFY activeChanged)
+ public:
+     QWaylandClientExtension(const int version);
++    ~QWaylandClientExtension();
+ 
+     QtWaylandClient::QWaylandIntegration *integration() const;
+     int version() const;
+diff --git a/qtwayland/src/client/global/qwaylandclientextension_p.h b/qtwayland/src/client/global/qwaylandclientextension_p.h
+index 69cc46a0..9091efbe 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension_p.h
++++ b/qtwayland/src/client/global/qwaylandclientextension_p.h
+@@ -68,6 +68,7 @@ public:
+     QtWaylandClient::QWaylandIntegration *waylandIntegration = nullptr;
+     int version = -1;
+     bool active = false;
++    bool registered = false;
+ };
+ 
+ class Q_WAYLAND_CLIENT_EXPORT QWaylandClientExtensionTemplatePrivate : public QWaylandClientExtensionPrivate
+diff --git a/qtwayland/src/client/qwaylanddatadevice.cpp b/qtwayland/src/client/qwaylanddatadevice.cpp
+index 7e2e3308..e3e60ed5 100644
+--- a/qtwayland/src/client/qwaylanddatadevice.cpp
++++ b/qtwayland/src/client/qwaylanddatadevice.cpp
+@@ -72,6 +72,8 @@ QWaylandDataDevice::QWaylandDataDevice(QWaylandDataDeviceManager *manager, QWayl
+ 
+ QWaylandDataDevice::~QWaylandDataDevice()
+ {
++    if (wl_data_device_get_version(object()) >= WL_DATA_DEVICE_RELEASE_SINCE_VERSION)
++        release();
+ }
+ 
+ QWaylandDataOffer *QWaylandDataDevice::selectionOffer() const
+@@ -110,7 +112,7 @@ QWaylandDataOffer *QWaylandDataDevice::dragOffer() const
+     return m_dragOffer.data();
+ }
+ 
+-bool QWaylandDataDevice::startDrag(QMimeData *mimeData, QWaylandWindow *icon)
++bool QWaylandDataDevice::startDrag(QMimeData *mimeData, Qt::DropActions supportedActions, QWaylandWindow *icon)
+ {
+     auto *seat = m_display->currentInputDevice();
+     auto *origin = seat->pointerFocus();
+@@ -123,7 +125,28 @@ bool QWaylandDataDevice::startDrag(QMimeData *mimeData, QWaylandWindow *icon)
+     }
+ 
+     m_dragSource.reset(new QWaylandDataSource(m_display->dndSelectionHandler(), mimeData));
++
++    if (wl_data_device_get_version(object()) >= 3)
++        m_dragSource->set_actions(dropActionsToWl(supportedActions));
++
+     connect(m_dragSource.data(), &QWaylandDataSource::cancelled, this, &QWaylandDataDevice::dragSourceCancelled);
++    connect(m_dragSource.data(), &QWaylandDataSource::dndResponseUpdated, this, [this](bool accepted, Qt::DropAction action) {
++            auto drag = static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag());
++            // in old versions drop action is not set, so we guess
++            if (wl_data_source_get_version(m_dragSource->object()) < 3) {
++                drag->setResponse(accepted);
++            } else {
++                QPlatformDropQtResponse response(accepted, action);
++                drag->setResponse(response);
++            }
++    });
++    connect(m_dragSource.data(), &QWaylandDataSource::dndDropped, this, [](bool accepted, Qt::DropAction action) {
++        QPlatformDropQtResponse response(accepted, action);
++        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setDropResponse(response);
++    });
++    connect(m_dragSource.data(), &QWaylandDataSource::finished, this, []() {
++        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag();
++    });
+ 
+     start_drag(m_dragSource->object(), origin->wlSurface(), icon->wlSurface(), m_display->currentInputDevice()->serial());
+     return true;
+@@ -152,7 +175,7 @@ void QWaylandDataDevice::data_device_drop()
+         supportedActions = drag->supportedActions();
+     } else if (m_dragOffer) {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     } else {
+         return;
+     }
+@@ -162,7 +185,11 @@ void QWaylandDataDevice::data_device_drop()
+                                                                           QGuiApplication::keyboardModifiers());
+ 
+     if (drag) {
+-        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag(response);
++        auto drag =  static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag());
++        drag->setDropResponse(response);
++        drag->finishDrag();
++    } else if (m_dragOffer) {
++        m_dragOffer->finish();
+     }
+ }
+ 
+@@ -186,7 +213,7 @@ void QWaylandDataDevice::data_device_enter(uint32_t serial, wl_surface *surface,
+         supportedActions = drag->supportedActions();
+     } else if (m_dragOffer) {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     }
+ 
+     const QPlatformDragQtResponse &response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
+@@ -197,11 +224,7 @@ void QWaylandDataDevice::data_device_enter(uint32_t serial, wl_surface *surface,
+         static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setResponse(response);
+     }
+ 
+-    if (response.isAccepted()) {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, m_dragOffer->firstFormat().toUtf8().constData());
+-    } else {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, nullptr);
+-    }
++    sendResponse(supportedActions, response);
+ }
+ 
+ void QWaylandDataDevice::data_device_leave()
+@@ -235,10 +258,10 @@ void QWaylandDataDevice::data_device_motion(uint32_t time, wl_fixed_t x, wl_fixe
+         supportedActions = drag->supportedActions();
+     } else {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     }
+ 
+-    QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
++    const QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
+                                                                           QGuiApplication::mouseButtons(),
+                                                                           QGuiApplication::keyboardModifiers());
+ 
+@@ -246,11 +269,7 @@ void QWaylandDataDevice::data_device_motion(uint32_t time, wl_fixed_t x, wl_fixe
+         static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setResponse(response);
+     }
+ 
+-    if (response.isAccepted()) {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, m_dragOffer->firstFormat().toUtf8().constData());
+-    } else {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, nullptr);
+-    }
++    sendResponse(supportedActions, response);
+ }
+ #endif // QT_CONFIG(draganddrop)
+ 
+@@ -277,14 +296,10 @@ void QWaylandDataDevice::selectionSourceCancelled()
+ #if QT_CONFIG(draganddrop)
+ void QWaylandDataDevice::dragSourceCancelled()
+ {
++    static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag();
+     m_dragSource.reset();
+ }
+ 
+-void QWaylandDataDevice::dragSourceTargetChanged(const QString &mimeType)
+-{
+-    static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->updateTarget(mimeType);
+-}
+-
+ QPoint QWaylandDataDevice::calculateDragPosition(int x, int y, QWindow *wnd) const
+ {
+     QPoint pnt(wl_fixed_to_int(x), wl_fixed_to_int(y));
+@@ -297,6 +312,33 @@ QPoint QWaylandDataDevice::calculateDragPosition(int x, int y, QWindow *wnd) con
+     }
+     return pnt;
+ }
++
++void QWaylandDataDevice::sendResponse(Qt::DropActions supportedActions, const QPlatformDragQtResponse &response)
++{
++    if (response.isAccepted()) {
++        if (wl_data_device_get_version(object()) >= 3)
++            m_dragOffer->set_actions(dropActionsToWl(supportedActions), dropActionsToWl(response.acceptedAction()));
++
++        m_dragOffer->accept(m_enterSerial, m_dragOffer->firstFormat());
++    } else {
++        m_dragOffer->accept(m_enterSerial, QString());
++    }
++}
++
++int QWaylandDataDevice::dropActionsToWl(Qt::DropActions actions)
++{
++
++    int wlActions = WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE;
++    if (actions & Qt::CopyAction)
++        wlActions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY;
++    if (actions & (Qt::MoveAction | Qt::TargetMoveAction))
++        wlActions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE;
++
++    // wayland does not support LinkAction at the time of writing
++    return wlActions;
++}
++
++
+ #endif // QT_CONFIG(draganddrop)
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddatadevice_p.h b/qtwayland/src/client/qwaylanddatadevice_p.h
+index 16c3ad28..801dcc2c 100644
+--- a/qtwayland/src/client/qwaylanddatadevice_p.h
++++ b/qtwayland/src/client/qwaylanddatadevice_p.h
+@@ -64,6 +64,7 @@ QT_REQUIRE_CONFIG(wayland_datadevice);
+ QT_BEGIN_NAMESPACE
+ 
+ class QMimeData;
++class QPlatformDragQtResponse;
+ class QWindow;
+ 
+ namespace QtWaylandClient {
+@@ -89,7 +90,7 @@ public:
+ 
+ #if QT_CONFIG(draganddrop)
+     QWaylandDataOffer *dragOffer() const;
+-    bool startDrag(QMimeData *mimeData, QWaylandWindow *icon);
++    bool startDrag(QMimeData *mimeData, Qt::DropActions supportedActions, QWaylandWindow *icon);
+     void cancelDrag();
+ #endif
+ 
+@@ -109,13 +110,16 @@ private Q_SLOTS:
+ 
+ #if QT_CONFIG(draganddrop)
+     void dragSourceCancelled();
+-    void dragSourceTargetChanged(const QString &mimeType);
+ #endif
+ 
+ private:
+ #if QT_CONFIG(draganddrop)
+     QPoint calculateDragPosition(int x, int y, QWindow *wnd) const;
+ #endif
++    void sendResponse(Qt::DropActions supportedActions, const QPlatformDragQtResponse &response);
++
++    static int dropActionsToWl(Qt::DropActions dropActions);
++
+ 
+     QWaylandDisplay *m_display = nullptr;
+     QWaylandInputDevice *m_inputDevice = nullptr;
+diff --git a/qtwayland/src/client/qwaylanddatadevicemanager.cpp b/qtwayland/src/client/qwaylanddatadevicemanager.cpp
+index 35d67307..6dc4f77f 100644
+--- a/qtwayland/src/client/qwaylanddatadevicemanager.cpp
++++ b/qtwayland/src/client/qwaylanddatadevicemanager.cpp
+@@ -50,8 +50,8 @@ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
+-QWaylandDataDeviceManager::QWaylandDataDeviceManager(QWaylandDisplay *display, uint32_t id)
+-    : wl_data_device_manager(display->wl_registry(), id, 1)
++QWaylandDataDeviceManager::QWaylandDataDeviceManager(QWaylandDisplay *display, int version, uint32_t id)
++    : wl_data_device_manager(display->wl_registry(), id, qMin(version, 3))
+     , m_display(display)
+ {
+     // Create transfer devices for all input devices.
+diff --git a/qtwayland/src/client/qwaylanddatadevicemanager_p.h b/qtwayland/src/client/qwaylanddatadevicemanager_p.h
+index bd05c0fb..510d9be4 100644
+--- a/qtwayland/src/client/qwaylanddatadevicemanager_p.h
++++ b/qtwayland/src/client/qwaylanddatadevicemanager_p.h
+@@ -68,7 +68,7 @@ class QWaylandInputDevice;
+ class Q_WAYLAND_CLIENT_EXPORT QWaylandDataDeviceManager : public QtWayland::wl_data_device_manager
+ {
+ public:
+-    QWaylandDataDeviceManager(QWaylandDisplay *display, uint32_t id);
++    QWaylandDataDeviceManager(QWaylandDisplay *display, int version, uint32_t id);
+     ~QWaylandDataDeviceManager() override;
+ 
+     QWaylandDataDevice *getDataDevice(QWaylandInputDevice *inputDevice);
+diff --git a/qtwayland/src/client/qwaylanddataoffer.cpp b/qtwayland/src/client/qwaylanddataoffer.cpp
+index 2297e8a1..fe0ea8c9 100644
+--- a/qtwayland/src/client/qwaylanddataoffer.cpp
++++ b/qtwayland/src/client/qwaylanddataoffer.cpp
+@@ -82,6 +82,15 @@ QMimeData *QWaylandDataOffer::mimeData()
+     return m_mimeData.data();
+ }
+ 
++Qt::DropActions QWaylandDataOffer::supportedActions() const
++{
++    if (wl_data_offer_get_version(const_cast<::wl_data_offer*>(object())) < 3) {
++        return Qt::MoveAction | Qt::CopyAction;
++    }
++
++    return m_supportedActions;
++}
++
+ void QWaylandDataOffer::startReceiving(const QString &mimeType, int fd)
+ {
+     receive(mimeType, fd);
+@@ -93,6 +102,22 @@ void QWaylandDataOffer::data_offer_offer(const QString &mime_type)
+     m_mimeData->appendFormat(mime_type);
+ }
+ 
++void QWaylandDataOffer::data_offer_action(uint32_t dnd_action)
++{
++    Q_UNUSED(dnd_action);
++    // This is the compositor telling the drag target what action it should perform
++    // It does not map nicely into Qt final drop semantics, other than pretending there is only one supported action?
++}
++
++void QWaylandDataOffer::data_offer_source_actions(uint32_t source_actions)
++{
++    m_supportedActions = Qt::DropActions();
++    if (source_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
++        m_supportedActions |= Qt::MoveAction;
++    if (source_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
++        m_supportedActions |= Qt::CopyAction;
++}
++
+ QWaylandMimeData::QWaylandMimeData(QWaylandAbstractDataOffer *dataOffer)
+     : m_dataOffer(dataOffer)
+ {
+@@ -163,17 +188,18 @@ QVariant QWaylandMimeData::retrieveData_sys(const QString &mimeType, QVariant::T
+ 
+ int QWaylandMimeData::readData(int fd, QByteArray &data) const
+ {
+-    fd_set readset;
+-    FD_ZERO(&readset);
+-    FD_SET(fd, &readset);
+-    struct timeval timeout;
++    struct pollfd readset;
++    readset.fd = fd;
++    readset.events = POLLIN;
++    struct timespec timeout;
+     timeout.tv_sec = 1;
+-    timeout.tv_usec = 0;
++    timeout.tv_nsec = 0;
++
+ 
+     Q_FOREVER {
+-        int ready = select(FD_SETSIZE, &readset, nullptr, nullptr, &timeout);
++        int ready = qt_safe_poll(&readset, 1, &timeout);
+         if (ready < 0) {
+-            qWarning() << "QWaylandDataOffer: select() failed";
++            qWarning() << "QWaylandDataOffer: qt_safe_poll() failed";
+             return -1;
+         } else if (ready == 0) {
+             qWarning("QWaylandDataOffer: timeout reading from pipe");
+diff --git a/qtwayland/src/client/qwaylanddataoffer_p.h b/qtwayland/src/client/qwaylanddataoffer_p.h
+index 9cf1483c..6f667398 100644
+--- a/qtwayland/src/client/qwaylanddataoffer_p.h
++++ b/qtwayland/src/client/qwaylanddataoffer_p.h
+@@ -82,6 +82,7 @@ public:
+     explicit QWaylandDataOffer(QWaylandDisplay *display, struct ::wl_data_offer *offer);
+     ~QWaylandDataOffer() override;
+     QMimeData *mimeData() override;
++    Qt::DropActions supportedActions() const;
+ 
+     QString firstFormat() const;
+ 
+@@ -89,10 +90,13 @@ public:
+ 
+ protected:
+     void data_offer_offer(const QString &mime_type) override;
++    void data_offer_source_actions(uint32_t source_actions) override;
++    void data_offer_action(uint32_t dnd_action) override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+     QScopedPointer<QWaylandMimeData> m_mimeData;
++    Qt::DropActions m_supportedActions;
+ };
+ 
+ 
+diff --git a/qtwayland/src/client/qwaylanddatasource.cpp b/qtwayland/src/client/qwaylanddatasource.cpp
+index f45122fb..5599cbd4 100644
+--- a/qtwayland/src/client/qwaylanddatasource.cpp
++++ b/qtwayland/src/client/qwaylanddatasource.cpp
+@@ -101,7 +101,32 @@ void QWaylandDataSource::data_source_send(const QString &mime_type, int32_t fd)
+ 
+ void QWaylandDataSource::data_source_target(const QString &mime_type)
+ {
+-    Q_EMIT targetChanged(mime_type);
++    m_accepted = !mime_type.isEmpty();
++    Q_EMIT dndResponseUpdated(m_accepted, m_dropAction);
++}
++
++void QWaylandDataSource::data_source_action(uint32_t action)
++{
++    Qt::DropAction qtAction = Qt::IgnoreAction;
++
++    if (action == WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
++        qtAction = Qt::MoveAction;
++    else if (action == WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
++        qtAction = Qt::CopyAction;
++
++    m_dropAction = qtAction;
++    Q_EMIT dndResponseUpdated(m_accepted, m_dropAction);
++}
++
++void QWaylandDataSource::data_source_dnd_finished()
++{
++    Q_EMIT finished();
++}
++
++void QWaylandDataSource::data_source_dnd_drop_performed()
++{
++
++    Q_EMIT dndDropped(m_accepted, m_dropAction);
+ }
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddatasource_p.h b/qtwayland/src/client/qwaylanddatasource_p.h
+index 25afff79..96f07bc3 100644
+--- a/qtwayland/src/client/qwaylanddatasource_p.h
++++ b/qtwayland/src/client/qwaylanddatasource_p.h
+@@ -77,17 +77,25 @@ public:
+     QMimeData *mimeData() const;
+ 
+ Q_SIGNALS:
+-    void targetChanged(const QString &mime_type);
+     void cancelled();
++    void finished();
++
++    void dndResponseUpdated(bool accepted, Qt::DropAction action);
++    void dndDropped(bool accepted, Qt::DropAction action);
+ 
+ protected:
+     void data_source_cancelled() override;
+     void data_source_send(const QString &mime_type, int32_t fd) override;
+     void data_source_target(const QString &mime_type) override;
++    void data_source_dnd_drop_performed() override;
++    void data_source_dnd_finished() override;
++    void data_source_action(uint32_t action) override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+     QMimeData *m_mime_data = nullptr;
++    bool m_accepted = false;
++    Qt::DropAction m_dropAction = Qt::IgnoreAction;
+ };
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddisplay.cpp b/qtwayland/src/client/qwaylanddisplay.cpp
+index f10c1f79..c01e238b 100644
+--- a/qtwayland/src/client/qwaylanddisplay.cpp
++++ b/qtwayland/src/client/qwaylanddisplay.cpp
+@@ -85,10 +85,203 @@
+ 
+ #include <errno.h>
+ 
++#include <tuple> // for std::tie
++
++static void checkWaylandError(struct wl_display *display)
++{
++    int ecode = wl_display_get_error(display);
++    if ((ecode == EPIPE || ecode == ECONNRESET)) {
++        // special case this to provide a nicer error
++        qWarning("The Wayland connection broke. Did the Wayland compositor die?");
++    } else {
++        qWarning("The Wayland connection experienced a fatal error: %s", strerror(ecode));
++    }
++    _exit(1);
++}
++
+ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
++class EventThread : public QThread
++{
++    Q_OBJECT
++public:
++    enum OperatingMode {
++        EmitToDispatch, // Emit the signal, allow dispatching in a differnt thread.
++        SelfDispatch, // Dispatch the events inside this thread.
++    };
++
++    EventThread(struct wl_display * wl, struct wl_event_queue * ev_queue,
++                OperatingMode mode)
++        : m_fd(wl_display_get_fd(wl))
++        , m_pipefd{ -1, -1 }
++        , m_wldisplay(wl)
++        , m_wlevqueue(ev_queue)
++        , m_mode(mode)
++        , m_reading(true)
++        , m_quitting(false)
++    {
++        setObjectName(QStringLiteral("WaylandEventThread"));
++    }
++
++    void readAndDispatchEvents()
++    {
++        /*
++         * Dispatch pending events and flush the requests at least once. If the event thread
++         * is not reading, try to call _prepare_read() to allow the event thread to poll().
++         * If that fails, re-try dispatch & flush again until _prepare_read() is successful.
++         *
++         * This allow any call to readAndDispatchEvents() to start event thread's polling,
++         * not only the one issued from event thread's waitForReading(), which means functions
++         * called from dispatch_pending() can safely spin an event loop.
++         */
++        for (;;) {
++            if (dispatchQueuePending() < 0) {
++                checkWaylandError(m_wldisplay);
++                return;
++            }
++
++            wl_display_flush(m_wldisplay);
++
++            // We have to check if event thread is reading every time we dispatch
++            // something, as that may recursively call this function.
++            if (m_reading.loadAcquire())
++                break;
++
++            if (prepareReadQueue() == 0) {
++                QMutexLocker l(&m_mutex);
++                m_reading.storeRelease(true);
++                m_cond.wakeOne();
++                break;
++            }
++        }
++    }
++
++    void stop()
++    {
++        // We have to both write to the pipe and set the flag, as the thread may be
++        // either in the poll() or waiting for _prepare_read().
++        if (m_pipefd[1] != -1 && write(m_pipefd[1], "\0", 1) == -1)
++            qWarning("Failed to write to the pipe: %s.", strerror(errno));
++
++        {
++            QMutexLocker l(&m_mutex);
++            m_quitting = true;
++            m_cond.wakeOne();
++        }
++
++        wait();
++    }
++
++Q_SIGNALS:
++    void needReadAndDispatch();
++
++protected:
++    void run() override
++    {
++        // we use this pipe to make the loop exit otherwise if we simply used a flag on the loop condition, if stop() gets
++        // called while poll() is blocking the thread will never quit since there are no wayland messages coming anymore.
++        struct Pipe
++        {
++            Pipe(int *fds)
++                : fds(fds)
++            {
++                if (qt_safe_pipe(fds) != 0)
++                    qWarning("Pipe creation failed. Quitting may hang.");
++            }
++            ~Pipe()
++            {
++                if (fds[0] != -1) {
++                    close(fds[0]);
++                    close(fds[1]);
++                }
++            }
++
++            int *fds;
++        } pipe(m_pipefd);
++
++        // Make the main thread call wl_prepare_read(), dispatch the pending messages and flush the
++        // outbound ones. Wait until it's done before proceeding, unless we're told to quit.
++        while (waitForReading()) {
++            pollfd fds[2] = { { m_fd, POLLIN, 0 }, { m_pipefd[0], POLLIN, 0 } };
++            poll(fds, 2, -1);
++
++            if (fds[1].revents & POLLIN) {
++                // we don't really care to read the byte that was written here since we're closing down
++                wl_display_cancel_read(m_wldisplay);
++                break;
++            }
++
++            if (fds[0].revents & POLLIN)
++                wl_display_read_events(m_wldisplay);
++                // The polll was succesfull and the event thread did the wl_display_read_events(). On the next iteration of the loop
++                // the event sent to the main thread will cause it to dispatch the messages just read, unless the loop exits in which
++                // case we don't care anymore about them.
++            else
++                wl_display_cancel_read(m_wldisplay);
++        }
++    }
++
++private:
++    bool waitForReading()
++    {
++        Q_ASSERT(QThread::currentThread() == this);
++
++        m_reading.storeRelease(false);
++
++        if (m_mode == SelfDispatch) {
++            readAndDispatchEvents();
++        } else {
++            Q_EMIT needReadAndDispatch();
++
++            QMutexLocker lock(&m_mutex);
++            // m_reading might be set from our emit or some other invocation of
++            // readAndDispatchEvents().
++            while (!m_reading.loadRelaxed() && !m_quitting)
++                m_cond.wait(&m_mutex);
++        }
++
++        return !m_quitting;
++    }
++
++    int dispatchQueuePending()
++    {
++        if (m_wlevqueue)
++            return wl_display_dispatch_queue_pending(m_wldisplay, m_wlevqueue);
++        else
++            return wl_display_dispatch_pending(m_wldisplay);
++    }
++
++    int prepareReadQueue()
++    {
++        if (m_wlevqueue)
++            return wl_display_prepare_read_queue(m_wldisplay, m_wlevqueue);
++        else
++            return wl_display_prepare_read(m_wldisplay);
++    }
++
++    int m_fd;
++    int m_pipefd[2];
++    wl_display *m_wldisplay;
++    wl_event_queue *m_wlevqueue;
++    OperatingMode m_mode;
++
++    /* Concurrency note when operating in EmitToDispatch mode:
++     * m_reading is set to false inside event thread's waitForReading(), and is
++     * set to true inside main thread's readAndDispatchEvents().
++     * The lock is not taken when setting m_reading to false, as the main thread
++     * is not actively waiting for it to turn false. However, the lock is taken
++     * inside readAndDispatchEvents() before setting m_reading to true,
++     * as the event thread is actively waiting for it under the wait condition.
++     */
++
++    QAtomicInteger<bool> m_reading;
++    bool m_quitting;
++    QMutex m_mutex;
++    QWaitCondition m_cond;
++};
++
+ Q_LOGGING_CATEGORY(lcQpaWayland, "qt.qpa.wayland"); // for general (uncategorized) Wayland platform logging
+ 
+ struct wl_surface *QWaylandDisplay::createSurface(void *handle)
+@@ -158,17 +351,16 @@ QWaylandDisplay::QWaylandDisplay(QWaylandIntegration *waylandIntegration)
+     if (!mXkbContext)
+         qCWarning(lcQpaWayland, "failed to create xkb context");
+ #endif
+-
+-    forceRoundTrip();
+-
+-    if (!mWaitingScreens.isEmpty()) {
+-        // Give wl_output.done and zxdg_output_v1.done events a chance to arrive
+-        forceRoundTrip();
+-    }
+ }
+ 
+ QWaylandDisplay::~QWaylandDisplay(void)
+ {
++    if (m_eventThread)
++        m_eventThread->stop();
++
++    if (m_frameEventQueueThread)
++        m_frameEventQueueThread->stop();
++
+     if (mSyncCallback)
+         wl_callback_destroy(mSyncCallback);
+ 
+@@ -187,6 +379,21 @@ QWaylandDisplay::~QWaylandDisplay(void)
+ #endif
+     if (mDisplay)
+         wl_display_disconnect(mDisplay);
++
++    if (m_frameEventQueue)
++        wl_event_queue_destroy(m_frameEventQueue);
++}
++
++// Steps which is called just after constructor. This separates registry_global() out of the constructor
++// so that factory functions in integration can be overridden.
++void QWaylandDisplay::initialize()
++{
++    forceRoundTrip();
++
++    if (!mWaitingScreens.isEmpty()) {
++        // Give wl_output.done and zxdg_output_v1.done events a chance to arrive
++        forceRoundTrip();
++    }
+ }
+ 
+ void QWaylandDisplay::ensureScreen()
+@@ -203,98 +410,37 @@ void QWaylandDisplay::ensureScreen()
+ 
+ void QWaylandDisplay::checkError() const
+ {
+-    int ecode = wl_display_get_error(mDisplay);
+-    if ((ecode == EPIPE || ecode == ECONNRESET)) {
+-        // special case this to provide a nicer error
+-        qWarning("The Wayland connection broke. Did the Wayland compositor die?");
+-    } else {
+-        qWarning("The Wayland connection experienced a fatal error: %s", strerror(ecode));
+-    }
+-    _exit(1);
++    checkWaylandError(mDisplay);
+ }
+ 
++// Called in main thread, either from queued signal or directly.
+ void QWaylandDisplay::flushRequests()
+ {
+-    if (wl_display_prepare_read(mDisplay) == 0) {
+-        wl_display_read_events(mDisplay);
+-    }
+-
+-    if (wl_display_dispatch_pending(mDisplay) < 0)
+-        checkError();
+-
+-    {
+-        QReadLocker locker(&m_frameQueueLock);
+-        for (const FrameQueue &q : mExternalQueues) {
+-            QMutexLocker locker(q.mutex);
+-            while (wl_display_prepare_read_queue(mDisplay, q.queue) != 0)
+-                wl_display_dispatch_queue_pending(mDisplay, q.queue);
+-            wl_display_read_events(mDisplay);
+-            wl_display_dispatch_queue_pending(mDisplay, q.queue);
+-        }
+-    }
+-
+-    wl_display_flush(mDisplay);
+-}
+-
+-void QWaylandDisplay::blockingReadEvents()
+-{
+-    if (wl_display_dispatch(mDisplay) < 0)
+-        checkError();
+-}
+-
+-void QWaylandDisplay::destroyFrameQueue(const QWaylandDisplay::FrameQueue &q)
+-{
+-    QWriteLocker locker(&m_frameQueueLock);
+-    auto it = std::find_if(mExternalQueues.begin(),
+-                           mExternalQueues.end(),
+-                           [&q] (const QWaylandDisplay::FrameQueue &other){ return other.queue == q.queue; });
+-    Q_ASSERT(it != mExternalQueues.end());
+-    mExternalQueues.erase(it);
+-    if (q.queue != nullptr)
+-        wl_event_queue_destroy(q.queue);
+-    delete q.mutex;
++    m_eventThread->readAndDispatchEvents();
+ }
+ 
+-QWaylandDisplay::FrameQueue QWaylandDisplay::createFrameQueue()
++// We have to wait until we have an eventDispatcher before creating the eventThread,
++// otherwise forceRoundTrip() may block inside _events_read() because eventThread is
++// polling.
++void QWaylandDisplay::initEventThread()
+ {
+-    QWriteLocker locker(&m_frameQueueLock);
+-    FrameQueue q{createEventQueue()};
+-    mExternalQueues.append(q);
+-    return q;
+-}
++    m_eventThread.reset(
++            new EventThread(mDisplay, /* default queue */ nullptr, EventThread::EmitToDispatch));
++    connect(m_eventThread.get(), &EventThread::needReadAndDispatch, this,
++            &QWaylandDisplay::flushRequests, Qt::QueuedConnection);
++    m_eventThread->start();
+ 
+-wl_event_queue *QWaylandDisplay::createEventQueue()
+-{
+-    return wl_display_create_queue(mDisplay);
++    // wl_display_disconnect() free this.
++    m_frameEventQueue = wl_display_create_queue(mDisplay);
++    m_frameEventQueueThread.reset(
++            new EventThread(mDisplay, m_frameEventQueue, EventThread::SelfDispatch));
++    m_frameEventQueueThread->start();
+ }
+ 
+-void QWaylandDisplay::dispatchQueueWhile(wl_event_queue *queue, std::function<bool ()> condition, int timeout)
++void QWaylandDisplay::blockingReadEvents()
+ {
+-    if (!condition())
+-        return;
+-
+-    QElapsedTimer timer;
+-    timer.start();
+-    struct pollfd pFd = qt_make_pollfd(wl_display_get_fd(mDisplay), POLLIN);
+-    while (timeout == -1 || timer.elapsed() < timeout) {
+-        while (wl_display_prepare_read_queue(mDisplay, queue) != 0)
+-            wl_display_dispatch_queue_pending(mDisplay, queue);
+-
+-        wl_display_flush(mDisplay);
+-
+-        const int remaining = qMax(timeout - timer.elapsed(), 0ll);
+-        const int pollTimeout = timeout == -1 ? -1 : remaining;
+-        if (qt_poll_msecs(&pFd, 1, pollTimeout) > 0)
+-            wl_display_read_events(mDisplay);
+-        else
+-            wl_display_cancel_read(mDisplay);
+-
+-        if (wl_display_dispatch_queue_pending(mDisplay, queue) < 0)
+-            checkError();
+-
+-        if (!condition())
+-            break;
+-    }
++    if (wl_display_dispatch(mDisplay) < 0)
++        checkWaylandError(mDisplay);
+ }
+ 
+ QWaylandScreen *QWaylandDisplay::screenForOutput(struct wl_output *output) const
+@@ -345,7 +491,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+     if (interface == QStringLiteral("wl_output")) {
+         mWaitingScreens << new QWaylandScreen(this, version, id);
+     } else if (interface == QStringLiteral("wl_compositor")) {
+-        mCompositorVersion = qMin((int)version, 3);
++        mCompositorVersion = qMin((int)version, 4);
+         mCompositor.init(registry, id, mCompositorVersion);
+     } else if (interface == QStringLiteral("wl_shm")) {
+         mShm.reset(new QWaylandShm(this, version, id));
+@@ -354,7 +500,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+         mInputDevices.append(inputDevice);
+ #if QT_CONFIG(wayland_datadevice)
+     } else if (interface == QStringLiteral("wl_data_device_manager")) {
+-        mDndSelectionHandler.reset(new QWaylandDataDeviceManager(this, id));
++        mDndSelectionHandler.reset(new QWaylandDataDeviceManager(this, version, id));
+ #endif
+     } else if (interface == QStringLiteral("qt_surface_extension")) {
+         mWindowExtension.reset(new QtWayland::qt_surface_extension(registry, id, 1));
+@@ -369,6 +515,8 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+ #if QT_CONFIG(wayland_client_primary_selection)
+     } else if (interface == QStringLiteral("zwp_primary_selection_device_manager_v1")) {
+         mPrimarySelectionManager.reset(new QWaylandPrimarySelectionDeviceManagerV1(this, id, 1));
++        for (QWaylandInputDevice *inputDevice : qAsConst(mInputDevices))
++            inputDevice->setPrimarySelectionDevice(mPrimarySelectionManager->createDevice(inputDevice));
+ #endif
+     } else if (interface == QStringLiteral("zwp_text_input_manager_v2") && !mClientSideInputContextRequested) {
+         mTextInputManager.reset(new QtWayland::zwp_text_input_manager_v2(registry, id, 1));
+@@ -427,6 +575,13 @@ void QWaylandDisplay::registry_global_remove(uint32_t id)
+                     inputDevice->setTextInput(nullptr);
+                 mWaylandIntegration->reconfigureInputContext();
+             }
++#if QT_CONFIG(wayland_client_primary_selection)
++            if (global.interface == QStringLiteral("zwp_primary_selection_device_manager_v1")) {
++                mPrimarySelectionManager.reset();
++                for (QWaylandInputDevice *inputDevice : qAsConst(mInputDevices))
++                    inputDevice->setPrimarySelectionDevice(nullptr);
++            }
++#endif
+             mGlobals.removeAt(i);
+             break;
+         }
+@@ -452,9 +607,10 @@ void QWaylandDisplay::addRegistryListener(RegistryListener listener, void *data)
+ 
+ void QWaylandDisplay::removeListener(RegistryListener listener, void *data)
+ {
+-    std::remove_if(mRegistryListeners.begin(), mRegistryListeners.end(), [=](Listener l){
++    auto iter = std::remove_if(mRegistryListeners.begin(), mRegistryListeners.end(), [=](Listener l){
+         return (l.listener == listener && l.data == data);
+     });
++    mRegistryListeners.erase(iter, mRegistryListeners.end());
+ }
+ 
+ uint32_t QWaylandDisplay::currentTimeMillisec()
+@@ -467,50 +623,9 @@ uint32_t QWaylandDisplay::currentTimeMillisec()
+     return 0;
+ }
+ 
+-static void
+-sync_callback(void *data, struct wl_callback *callback, uint32_t serial)
+-{
+-    Q_UNUSED(serial)
+-    bool *done = static_cast<bool *>(data);
+-
+-    *done = true;
+-
+-    // If the wl_callback done event is received after the condition check in the while loop in
+-    // forceRoundTrip(), but before the call to processEvents, the call to processEvents may block
+-    // forever if no more events are posted (eventhough the callback is handled in response to the
+-    // aboutToBlock signal). Hence, we wake up the event dispatcher so forceRoundTrip may return.
+-    // (QTBUG-64696)
+-    if (auto *dispatcher = QThread::currentThread()->eventDispatcher())
+-        dispatcher->wakeUp();
+-
+-    wl_callback_destroy(callback);
+-}
+-
+-static const struct wl_callback_listener sync_listener = {
+-    sync_callback
+-};
+-
+ void QWaylandDisplay::forceRoundTrip()
+ {
+-    // wl_display_roundtrip() works on the main queue only,
+-    // but we use a separate one, so basically reimplement it here
+-    int ret = 0;
+-    bool done = false;
+-    wl_callback *callback = wl_display_sync(mDisplay);
+-    wl_callback_add_listener(callback, &sync_listener, &done);
+-    flushRequests();
+-    if (QThread::currentThread()->eventDispatcher()) {
+-        while (!done && ret >= 0) {
+-            QThread::currentThread()->eventDispatcher()->processEvents(QEventLoop::WaitForMoreEvents);
+-            ret = wl_display_dispatch_pending(mDisplay);
+-        }
+-    } else {
+-        while (!done && ret >= 0)
+-            ret = wl_display_dispatch(mDisplay);
+-    }
+-
+-    if (ret == -1 && !done)
+-        wl_callback_destroy(callback);
++     wl_display_roundtrip(mDisplay);
+ }
+ 
+ bool QWaylandDisplay::supportsWindowDecoration() const
+@@ -574,14 +689,10 @@ void QWaylandDisplay::handleKeyboardFocusChanged(QWaylandInputDevice *inputDevic
+     if (mLastKeyboardFocus == keyboardFocus)
+         return;
+ 
+-    if (mWaylandIntegration->mShellIntegration) {
+-        mWaylandIntegration->mShellIntegration->handleKeyboardFocusChanged(keyboardFocus, mLastKeyboardFocus);
+-    } else {
+-        if (keyboardFocus)
+-            handleWindowActivated(keyboardFocus);
+-        if (mLastKeyboardFocus)
+-            handleWindowDeactivated(mLastKeyboardFocus);
+-    }
++    if (keyboardFocus)
++        handleWindowActivated(keyboardFocus);
++    if (mLastKeyboardFocus)
++        handleWindowDeactivated(mLastKeyboardFocus);
+ 
+     mLastKeyboardFocus = keyboardFocus;
+ }
+@@ -600,6 +711,19 @@ void QWaylandDisplay::handleWaylandSync()
+     QWindow *activeWindow = mActiveWindows.empty() ? nullptr : mActiveWindows.last()->window();
+     if (activeWindow != QGuiApplication::focusWindow())
+         QWindowSystemInterface::handleWindowActivated(activeWindow);
++
++    if (!activeWindow) {
++        if (lastInputDevice()) {
++#if QT_CONFIG(clipboard)
++            if (auto *dataDevice = lastInputDevice()->dataDevice())
++                dataDevice->invalidateSelectionOffer();
++#endif
++#if QT_CONFIG(wayland_client_primary_selection)
++            if (auto *device = lastInputDevice()->primarySelectionDevice())
++                device->invalidateSelectionOffer();
++#endif
++        }
++    }
+ }
+ 
+ const wl_callback_listener QWaylandDisplay::syncCallbackListener = {
+@@ -626,6 +750,13 @@ QWaylandInputDevice *QWaylandDisplay::defaultInputDevice() const
+     return mInputDevices.isEmpty() ? 0 : mInputDevices.first();
+ }
+ 
++bool QWaylandDisplay::isKeyboardAvailable() const
++{
++    return std::any_of(
++            mInputDevices.constBegin(), mInputDevices.constEnd(),
++            [this](const QWaylandInputDevice *device) { return device->keyboard() != nullptr; });
++}
++
+ #if QT_CONFIG(cursor)
+ 
+ QWaylandCursor *QWaylandDisplay::waylandCursor()
+@@ -652,4 +783,6 @@ QWaylandCursorTheme *QWaylandDisplay::loadCursorTheme(const QString &name, int p
+ 
+ } // namespace QtWaylandClient
+ 
++#include "qwaylanddisplay.moc"
++
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/client/qwaylanddisplay_p.h b/qtwayland/src/client/qwaylanddisplay_p.h
+index 3b092bc8..42bc661d 100644
+--- a/qtwayland/src/client/qwaylanddisplay_p.h
++++ b/qtwayland/src/client/qwaylanddisplay_p.h
+@@ -109,6 +109,7 @@ class QWaylandSurface;
+ class QWaylandShellIntegration;
+ class QWaylandCursor;
+ class QWaylandCursorTheme;
++class EventThread;
+ 
+ typedef void (*RegistryListener)(void *data,
+                                  struct wl_registry *registry,
+@@ -120,15 +121,11 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandDisplay : public QObject, public QtWayland
+     Q_OBJECT
+ 
+ public:
+-    struct FrameQueue {
+-        FrameQueue(wl_event_queue *q = nullptr) : queue(q), mutex(new QMutex) {}
+-        wl_event_queue *queue;
+-        QMutex *mutex;
+-    };
+-
+     QWaylandDisplay(QWaylandIntegration *waylandIntegration);
+     ~QWaylandDisplay(void) override;
+ 
++    void initialize();
++
+ #if QT_CONFIG(xkbcommon)
+     struct xkb_context *xkbContext() const { return mXkbContext.get(); }
+ #endif
+@@ -210,11 +207,11 @@ public:
+     void handleKeyboardFocusChanged(QWaylandInputDevice *inputDevice);
+     void handleWindowDestroyed(QWaylandWindow *window);
+ 
+-    wl_event_queue *createEventQueue();
+-    FrameQueue createFrameQueue();
+-    void destroyFrameQueue(const FrameQueue &q);
+-    void dispatchQueueWhile(wl_event_queue *queue, std::function<bool()> condition, int timeout = -1);
++    wl_event_queue *frameEventQueue() { return m_frameEventQueue; };
++
++    bool isKeyboardAvailable() const;
+ 
++    void initEventThread();
+ public slots:
+     void blockingReadEvents();
+     void flushRequests();
+@@ -237,6 +234,9 @@ private:
+     };
+ 
+     struct wl_display *mDisplay = nullptr;
++    QScopedPointer<EventThread> m_eventThread;
++    wl_event_queue *m_frameEventQueue = nullptr;
++    QScopedPointer<EventThread> m_frameEventQueueThread;
+     QtWayland::wl_compositor mCompositor;
+     QScopedPointer<QWaylandShm> mShm;
+     QList<QWaylandScreen *> mWaitingScreens;
+@@ -273,11 +273,9 @@ private:
+     QWaylandInputDevice *mLastInputDevice = nullptr;
+     QPointer<QWaylandWindow> mLastInputWindow;
+     QPointer<QWaylandWindow> mLastKeyboardFocus;
+-    QVector<QWaylandWindow *> mActiveWindows;
+-    QVector<FrameQueue> mExternalQueues;
++    QList<QWaylandWindow *> mActiveWindows;
+     struct wl_callback *mSyncCallback = nullptr;
+     static const wl_callback_listener syncCallbackListener;
+-    QReadWriteLock m_frameQueueLock;
+ 
+     bool mClientSideInputContextRequested = !QPlatformInputContextFactory::requested().isNull();
+ 
+diff --git a/qtwayland/src/client/qwaylanddnd.cpp b/qtwayland/src/client/qwaylanddnd.cpp
+index 6535aa16..7c53f5fa 100644
+--- a/qtwayland/src/client/qwaylanddnd.cpp
++++ b/qtwayland/src/client/qwaylanddnd.cpp
+@@ -66,7 +66,7 @@ void QWaylandDrag::startDrag()
+ {
+     QBasicDrag::startDrag();
+     QWaylandWindow *icon = static_cast<QWaylandWindow *>(shapedPixmapWindow()->handle());
+-    if (m_display->currentInputDevice()->dataDevice()->startDrag(drag()->mimeData(), icon)) {
++    if (m_display->currentInputDevice()->dataDevice()->startDrag(drag()->mimeData(), drag()->supportedActions(), icon)) {
+         icon->addAttachOffset(-drag()->hotSpot());
+     } else {
+         // Cancelling immediately does not work, since the event loop for QDrag::exec is started
+@@ -80,6 +80,9 @@ void QWaylandDrag::cancel()
+     QBasicDrag::cancel();
+ 
+     m_display->currentInputDevice()->dataDevice()->cancelDrag();
++
++    if (drag())
++        drag()->deleteLater();
+ }
+ 
+ void QWaylandDrag::move(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods)
+@@ -103,33 +106,41 @@ void QWaylandDrag::endDrag()
+     m_display->currentInputDevice()->handleEndDrag();
+ }
+ 
+-void QWaylandDrag::updateTarget(const QString &mimeType)
++void QWaylandDrag::setResponse(bool accepted)
+ {
+-    setCanDrop(!mimeType.isEmpty());
+-
+-    if (canDrop()) {
+-        updateCursor(defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers()));
+-    } else {
+-        updateCursor(Qt::IgnoreAction);
+-    }
++    // This method is used for old DataDevices where the drag action is not communicated
++    Qt::DropAction action = defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers());
++    setResponse(QPlatformDropQtResponse(accepted, action));
+ }
+ 
+-void QWaylandDrag::setResponse(const QPlatformDragQtResponse &response)
++void QWaylandDrag::setResponse(const QPlatformDropQtResponse &response)
+ {
+     setCanDrop(response.isAccepted());
+ 
+     if (canDrop()) {
+-        updateCursor(defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers()));
++        updateCursor(response.acceptedAction());
+     } else {
+         updateCursor(Qt::IgnoreAction);
+     }
+ }
+ 
+-void QWaylandDrag::finishDrag(const QPlatformDropQtResponse &response)
++void QWaylandDrag::setDropResponse(const QPlatformDropQtResponse &response)
+ {
+     setExecutedDropAction(response.acceptedAction());
++}
++
++void QWaylandDrag::finishDrag()
++{
+     QKeyEvent event(QEvent::KeyPress, Qt::Key_Escape, Qt::NoModifier);
+     eventFilter(shapedPixmapWindow(), &event);
++
++    if (drag())
++        drag()->deleteLater();
++}
++
++bool QWaylandDrag::ownsDragObject() const
++{
++    return true;
+ }
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddnd_p.h b/qtwayland/src/client/qwaylanddnd_p.h
+index 474fe2ab..46f629ac 100644
+--- a/qtwayland/src/client/qwaylanddnd_p.h
++++ b/qtwayland/src/client/qwaylanddnd_p.h
+@@ -71,9 +71,10 @@ public:
+     QWaylandDrag(QWaylandDisplay *display);
+     ~QWaylandDrag() override;
+ 
+-    void updateTarget(const QString &mimeType);
+-    void setResponse(const QPlatformDragQtResponse &response);
+-    void finishDrag(const QPlatformDropQtResponse &response);
++    void setResponse(bool accepted);
++    void setResponse(const QPlatformDropQtResponse &response);
++    void setDropResponse(const QPlatformDropQtResponse &response);
++    void finishDrag();
+ 
+ protected:
+     void startDrag() override;
+@@ -82,6 +83,7 @@ protected:
+     void drop(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods) override;
+     void endDrag() override;
+ 
++    bool ownsDragObject() const override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+diff --git a/qtwayland/src/client/qwaylandinputdevice.cpp b/qtwayland/src/client/qwaylandinputdevice.cpp
+index 613fe862..4b90de84 100644
+--- a/qtwayland/src/client/qwaylandinputdevice.cpp
++++ b/qtwayland/src/client/qwaylandinputdevice.cpp
+@@ -685,6 +685,11 @@ public:
+ 
+ void QWaylandInputDevice::Pointer::pointer_leave(uint32_t time, struct wl_surface *surface)
+ {
++    invalidateFocus();
++    mButtons = Qt::NoButton;
++
++    mParent->mTime = time;
++
+     // The event may arrive after destroying the window, indicated by
+     // a null surface.
+     if (!surface)
+@@ -696,11 +701,6 @@ void QWaylandInputDevice::Pointer::pointer_leave(uint32_t time, struct wl_surfac
+ 
+     if (!QWaylandWindow::mouseGrab())
+         setFrameEvent(new LeaveEvent(window, mSurfacePos, mGlobalPos));
+-
+-    invalidateFocus();
+-    mButtons = Qt::NoButton;
+-
+-    mParent->mTime = time;
+ }
+ 
+ class MotionEvent : public QWaylandPointerEvent
+@@ -1300,14 +1300,6 @@ void QWaylandInputDevice::Keyboard::handleFocusDestroyed()
+ void QWaylandInputDevice::Keyboard::handleFocusLost()
+ {
+     mFocus = nullptr;
+-#if QT_CONFIG(clipboard)
+-    if (auto *dataDevice = mParent->dataDevice())
+-        dataDevice->invalidateSelectionOffer();
+-#endif
+-#if QT_CONFIG(wayland_client_primary_selection)
+-    if (auto *device = mParent->primarySelectionDevice())
+-        device->invalidateSelectionOffer();
+-#endif
+     mParent->mQDisplay->handleKeyboardFocusChanged(mParent);
+     mRepeatTimer.stop();
+ }
+@@ -1396,6 +1388,7 @@ void QWaylandInputDevice::Touch::touch_cancel()
+     if (touchExt)
+         touchExt->touchCanceled();
+ 
++    mFocus = nullptr;
+     QWindowSystemInterface::handleTouchCancelEvent(nullptr, mParent->mTouchDevice);
+ }
+ 
+diff --git a/qtwayland/src/client/qwaylandintegration.cpp b/qtwayland/src/client/qwaylandintegration.cpp
+index c53ccb78..54861600 100644
+--- a/qtwayland/src/client/qwaylandintegration.cpp
++++ b/qtwayland/src/client/qwaylandintegration.cpp
+@@ -125,6 +125,9 @@ QWaylandIntegration::QWaylandIntegration()
+ #endif
+ 
+     reconfigureInputContext();
++
++    QWaylandWindow::fixedToplevelPositions =
++            !qEnvironmentVariableIsSet("QT_WAYLAND_DISABLE_FIXED_POSITIONS");
+ }
+ 
+ QWaylandIntegration::~QWaylandIntegration()
+@@ -192,14 +195,18 @@ QAbstractEventDispatcher *QWaylandIntegration::createEventDispatcher() const
+ 
+ void QWaylandIntegration::initialize()
+ {
++    mDisplay->initEventThread();
++
++    // Call after eventDispatcher is fully connected, for QWaylandDisplay::forceRoundTrip()
++    mDisplay->initialize();
++
++    // But the aboutToBlock() and awake() should be connected after initializePlatform().
++    // Otherwise the connected flushRequests() may consumes up all events before processEvents starts to wait,
++    // so that processEvents(QEventLoop::WaitForMoreEvents) may be blocked in the forceRoundTrip().
+     QAbstractEventDispatcher *dispatcher = QGuiApplicationPrivate::eventDispatcher;
+     QObject::connect(dispatcher, SIGNAL(aboutToBlock()), mDisplay.data(), SLOT(flushRequests()));
+     QObject::connect(dispatcher, SIGNAL(awake()), mDisplay.data(), SLOT(flushRequests()));
+ 
+-    int fd = wl_display_get_fd(mDisplay->wl_display());
+-    QSocketNotifier *sn = new QSocketNotifier(fd, QSocketNotifier::Read, mDisplay.data());
+-    QObject::connect(sn, SIGNAL(activated(QSocketDescriptor)), mDisplay.data(), SLOT(flushRequests()));
+-
+     // Qt does not support running with no screens
+     mDisplay->ensureScreen();
+ }
+@@ -262,6 +269,14 @@ QWaylandDisplay *QWaylandIntegration::display() const
+     return mDisplay.data();
+ }
+ 
++Qt::KeyboardModifiers QWaylandIntegration::queryKeyboardModifiers() const
++{
++    if (auto *seat = mDisplay->currentInputDevice()) {
++        return seat->modifiers();
++    }
++    return Qt::NoModifier;
++}
++
+ QList<int> QWaylandIntegration::possibleKeys(const QKeyEvent *event) const
+ {
+     if (auto *seat = mDisplay->currentInputDevice())
+@@ -479,7 +494,7 @@ void QWaylandIntegration::reconfigureInputContext()
+     }
+ #endif
+ 
+-    qCDebug(lcQpaWayland) << "using input method:" << inputContext()->metaObject()->className();
++    qCDebug(lcQpaWayland) << "using input method:" << (inputContext() ? inputContext()->metaObject()->className() : "<none>");
+ }
+ 
+ QWaylandShellIntegration *QWaylandIntegration::createShellIntegration(const QString &integrationName)
+diff --git a/qtwayland/src/client/qwaylandintegration_p.h b/qtwayland/src/client/qwaylandintegration_p.h
+index ff70ae25..73b80658 100644
+--- a/qtwayland/src/client/qwaylandintegration_p.h
++++ b/qtwayland/src/client/qwaylandintegration_p.h
+@@ -107,6 +107,8 @@ public:
+ 
+     QWaylandDisplay *display() const;
+ 
++    Qt::KeyboardModifiers queryKeyboardModifiers() const override;
++
+     QList<int> possibleKeys(const QKeyEvent *event) const override;
+ 
+     QStringList themeNames() const override;
+diff --git a/qtwayland/src/client/qwaylandprimaryselectionv1.cpp b/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
+index 832f9678..ea508771 100644
+--- a/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
++++ b/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
+@@ -54,11 +54,6 @@ QWaylandPrimarySelectionDeviceManagerV1::QWaylandPrimarySelectionDeviceManagerV1
+     : zwp_primary_selection_device_manager_v1(display->wl_registry(), id, qMin(version, uint(1)))
+     , m_display(display)
+ {
+-    // Create devices for all seats.
+-    // This only works if we get the global before all devices
+-    const auto seats = m_display->inputDevices();
+-    for (auto *seat : seats)
+-        seat->setPrimarySelectionDevice(createDevice(seat));
+ }
+ 
+ QWaylandPrimarySelectionDeviceV1 *QWaylandPrimarySelectionDeviceManagerV1::createDevice(QWaylandInputDevice *seat)
+diff --git a/qtwayland/src/client/qwaylandscreen.cpp b/qtwayland/src/client/qwaylandscreen.cpp
+index 6cb337de..5537dafd 100644
+--- a/qtwayland/src/client/qwaylandscreen.cpp
++++ b/qtwayland/src/client/qwaylandscreen.cpp
+@@ -60,7 +60,7 @@ QWaylandXdgOutputManagerV1::QWaylandXdgOutputManagerV1(QWaylandDisplay* display,
+ }
+ 
+ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uint32_t id)
+-    : QtWayland::wl_output(waylandDisplay->wl_registry(), id, qMin(version, 2))
++    : QtWayland::wl_output(waylandDisplay->wl_registry(), id, qMin(version, 3))
+     , m_outputId(id)
+     , mWaylandDisplay(waylandDisplay)
+     , mOutputName(QStringLiteral("Screen%1").arg(id))
+@@ -72,7 +72,7 @@ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uin
+         qCWarning(lcQpaWayland) << "wl_output done event not supported by compositor,"
+                                 << "QScreen may not work correctly";
+         mWaylandDisplay->forceRoundTrip(); // Give the compositor a chance to send geometry etc.
+-        mOutputDone = true; // Fake the done event
++        mProcessedEvents |= OutputDoneEvent; // Fake the done event
+         maybeInitialize();
+     }
+ }
+@@ -81,16 +81,29 @@ QWaylandScreen::~QWaylandScreen()
+ {
+     if (zxdg_output_v1::isInitialized())
+         zxdg_output_v1::destroy();
++    if (wl_output::isInitialized() && wl_output_get_version(wl_output::object()) >= WL_OUTPUT_RELEASE_SINCE_VERSION)
++        wl_output::release();
++}
++
++uint QWaylandScreen::requiredEvents() const
++{
++    uint ret = OutputDoneEvent;
++
++    if (mWaylandDisplay->xdgOutputManager()) {
++        ret |= XdgOutputNameEvent;
++
++        if (mWaylandDisplay->xdgOutputManager()->version() < 3)
++            ret |= XdgOutputDoneEvent;
++    }
++    return ret;
+ }
+ 
+ void QWaylandScreen::maybeInitialize()
+ {
+     Q_ASSERT(!mInitialized);
+ 
+-    if (!mOutputDone)
+-        return;
+-
+-    if (mWaylandDisplay->xdgOutputManager() && !mXdgOutputDone)
++    const uint requiredEvents = this->requiredEvents();
++    if ((mProcessedEvents & requiredEvents) != requiredEvents)
+         return;
+ 
+     mInitialized = true;
+@@ -276,9 +289,8 @@ void QWaylandScreen::output_scale(int32_t factor)
+ 
+ void QWaylandScreen::output_done()
+ {
+-    mOutputDone = true;
+-    if (zxdg_output_v1::isInitialized() && mWaylandDisplay->xdgOutputManager()->version() >= 3)
+-        mXdgOutputDone = true;
++    mProcessedEvents |= OutputDoneEvent;
++
+     if (mInitialized) {
+         updateOutputProperties();
+         if (zxdg_output_v1::isInitialized())
+@@ -339,7 +351,7 @@ void QWaylandScreen::zxdg_output_v1_done()
+     if (Q_UNLIKELY(mWaylandDisplay->xdgOutputManager()->version() >= 3))
+         qWarning(lcQpaWayland) << "zxdg_output_v1.done received on version 3 or newer, this is most likely a bug in the compositor";
+ 
+-    mXdgOutputDone = true;
++    mProcessedEvents |= XdgOutputDoneEvent;
+     if (mInitialized)
+         updateXdgOutputProperties();
+     else
+@@ -348,7 +360,11 @@ void QWaylandScreen::zxdg_output_v1_done()
+ 
+ void QWaylandScreen::zxdg_output_v1_name(const QString &name)
+ {
++    if (Q_UNLIKELY(mInitialized))
++        qWarning(lcQpaWayland) << "zxdg_output_v1.name received after output has been initialized, this is most likely a bug in the compositor";
++
+     mOutputName = name;
++    mProcessedEvents |= XdgOutputNameEvent;
+ }
+ 
+ void QWaylandScreen::updateXdgOutputProperties()
+diff --git a/qtwayland/src/client/qwaylandscreen_p.h b/qtwayland/src/client/qwaylandscreen_p.h
+index df1c94f2..050cfdc0 100644
+--- a/qtwayland/src/client/qwaylandscreen_p.h
++++ b/qtwayland/src/client/qwaylandscreen_p.h
+@@ -116,6 +116,13 @@ public:
+     static QWaylandScreen *fromWlOutput(::wl_output *output);
+ 
+ private:
++    enum Event : uint {
++        XdgOutputDoneEvent = 0x1,
++        OutputDoneEvent = 0x2,
++        XdgOutputNameEvent = 0x4,
++    };
++    uint requiredEvents() const;
++
+     void output_mode(uint32_t flags, int width, int height, int refresh) override;
+     void output_geometry(int32_t x, int32_t y,
+                          int32_t width, int32_t height,
+@@ -148,8 +155,7 @@ private:
+     QSize mPhysicalSize;
+     QString mOutputName;
+     Qt::ScreenOrientation m_orientation = Qt::PrimaryOrientation;
+-    bool mOutputDone = false;
+-    bool mXdgOutputDone = false;
++    uint mProcessedEvents = 0;
+     bool mInitialized = false;
+ 
+ #if QT_CONFIG(cursor)
+diff --git a/qtwayland/src/client/qwaylandshmbackingstore.cpp b/qtwayland/src/client/qwaylandshmbackingstore.cpp
+index dc7ff670..41cffdf7 100644
+--- a/qtwayland/src/client/qwaylandshmbackingstore.cpp
++++ b/qtwayland/src/client/qwaylandshmbackingstore.cpp
+@@ -52,6 +52,7 @@
+ 
+ #include <QtWaylandClient/private/wayland-wayland-client-protocol.h>
+ 
++#include <fcntl.h>
+ #include <unistd.h>
+ #include <sys/mman.h>
+ 
+@@ -61,6 +62,9 @@
+ #  ifndef MFD_CLOEXEC
+ #    define MFD_CLOEXEC     0x0001U
+ #  endif
++#  ifndef MFD_ALLOW_SEALING
++#    define MFD_ALLOW_SEALING 0x0002U
++#  endif
+ #endif
+ 
+ QT_BEGIN_NAMESPACE
+@@ -74,8 +78,10 @@ QWaylandShmBuffer::QWaylandShmBuffer(QWaylandDisplay *display,
+     int alloc = stride * size.height();
+     int fd = -1;
+ 
+-#ifdef SYS_memfd_create
+-    fd = syscall(SYS_memfd_create, "wayland-shm", MFD_CLOEXEC);
++#if defined(SYS_memfd_create) && defined(F_SEAL_SEAL)
++    fd = syscall(SYS_memfd_create, "wayland-shm", MFD_CLOEXEC | MFD_ALLOW_SEALING);
++    if (fd >= 0)
++        fcntl(fd, F_ADD_SEALS, F_SEAL_SHRINK | F_SEAL_SEAL);
+ #endif
+ 
+     QScopedPointer<QFile> filePointer;
+diff --git a/qtwayland/src/client/qwaylandwindow.cpp b/qtwayland/src/client/qwaylandwindow.cpp
+index cb82857a..fb2c59dc 100644
+--- a/qtwayland/src/client/qwaylandwindow.cpp
++++ b/qtwayland/src/client/qwaylandwindow.cpp
+@@ -76,7 +76,6 @@ QWaylandWindow *QWaylandWindow::mMouseGrab = nullptr;
+ QWaylandWindow::QWaylandWindow(QWindow *window, QWaylandDisplay *display)
+     : QPlatformWindow(window)
+     , mDisplay(display)
+-    , mFrameQueue(mDisplay->createFrameQueue())
+     , mResizeAfterSwap(qEnvironmentVariableIsSet("QT_WAYLAND_RESIZE_AFTER_SWAP"))
+ {
+     {
+@@ -95,9 +94,6 @@ QWaylandWindow::QWaylandWindow(QWindow *window, QWaylandDisplay *display)
+ 
+ QWaylandWindow::~QWaylandWindow()
+ {
+-    mDisplay->destroyFrameQueue(mFrameQueue);
+-    mDisplay->handleWindowDestroyed(this);
+-
+     delete mWindowDecoration;
+ 
+     if (mSurface)
+@@ -243,6 +239,7 @@ bool QWaylandWindow::shouldCreateSubSurface() const
+ 
+ void QWaylandWindow::reset()
+ {
++    closeChildPopups();
+     delete mShellSurface;
+     mShellSurface = nullptr;
+     delete mSubSurfaceWindow;
+@@ -255,17 +252,22 @@ void QWaylandWindow::reset()
+         mSurface.reset();
+     }
+ 
+-    if (mFrameCallback) {
+-        wl_callback_destroy(mFrameCallback);
+-        mFrameCallback = nullptr;
+-    }
++    {
++        QMutexLocker lock(&mFrameSyncMutex);
++        if (mFrameCallback) {
++            wl_callback_destroy(mFrameCallback);
++            mFrameCallback = nullptr;
++        }
+ 
+-    mFrameCallbackElapsedTimer.invalidate();
+-    mWaitingForFrameCallback = false;
++        mFrameCallbackElapsedTimer.invalidate();
++        mWaitingForFrameCallback = false;
++    }
+     mFrameCallbackTimedOut = false;
+ 
+     mMask = QRegion();
+     mQueuedBuffer = nullptr;
++
++    mDisplay->handleWindowDestroyed(this);
+ }
+ 
+ QWaylandWindow *QWaylandWindow::fromWlSurface(::wl_surface *surface)
+@@ -351,19 +353,25 @@ void QWaylandWindow::setGeometry_helper(const QRect &rect)
+     }
+ }
+ 
+-void QWaylandWindow::setGeometry(const QRect &rect)
++void QWaylandWindow::setGeometry(const QRect &r)
+ {
++    auto rect = r;
++    if (fixedToplevelPositions && !QPlatformWindow::parent() && window()->type() != Qt::Popup
++        && window()->type() != Qt::ToolTip) {
++        rect.moveTo(screen()->geometry().topLeft());
++    }
+     setGeometry_helper(rect);
+ 
+     if (window()->isVisible() && rect.isValid()) {
+         if (mWindowDecoration)
+             mWindowDecoration->update();
+ 
+-        if (mResizeAfterSwap && windowType() == Egl && mSentInitialResize)
++        if (mResizeAfterSwap && windowType() == Egl && mSentInitialResize) {
++            QMutexLocker lock(&mResizeLock);
+             mResizeDirty = true;
+-        else
++        } else {
+             QWindowSystemInterface::handleGeometryChange(window(), geometry());
+-
++        }
+         mSentInitialResize = true;
+     }
+     QRect exposeGeometry(QPoint(), geometry().size());
+@@ -374,7 +382,7 @@ void QWaylandWindow::setGeometry(const QRect &rect)
+         mShellSurface->setWindowGeometry(windowContentGeometry());
+ 
+     if (isOpaque() && mMask.isEmpty())
+-        setOpaqueArea(rect);
++        setOpaqueArea(QRect(QPoint(0, 0), rect.size()));
+ }
+ 
+ void QWaylandWindow::resizeFromApplyConfigure(const QSize &sizeWithMargins, const QPoint &offset)
+@@ -399,21 +407,6 @@ void QWaylandWindow::sendExposeEvent(const QRect &rect)
+     mLastExposeGeometry = rect;
+ }
+ 
+-
+-static QVector<QPointer<QWaylandWindow>> activePopups;
+-
+-void QWaylandWindow::closePopups(QWaylandWindow *parent)
+-{
+-    while (!activePopups.isEmpty()) {
+-        auto popup = activePopups.takeLast();
+-        if (popup.isNull())
+-            continue;
+-        if (popup.data() == parent)
+-            return;
+-        popup->reset();
+-    }
+-}
+-
+ QPlatformScreen *QWaylandWindow::calculateScreenFromSurfaceEvents() const
+ {
+     QReadLocker lock(&mSurfaceLock);
+@@ -433,10 +426,7 @@ void QWaylandWindow::setVisible(bool visible)
+     lastVisible = visible;
+ 
+     if (visible) {
+-        if (window()->type() == Qt::Popup || window()->type() == Qt::ToolTip)
+-            activePopups << this;
+         initWindow();
+-        mDisplay->flushRequests();
+ 
+         setGeometry(windowGeometry());
+         // Don't flush the events here, or else the newly visible window may start drawing, but since
+@@ -444,7 +434,6 @@ void QWaylandWindow::setVisible(bool visible)
+         // QWaylandShmBackingStore::beginPaint().
+     } else {
+         sendExposeEvent(QRect());
+-        closePopups(this);
+         reset();
+     }
+ }
+@@ -556,12 +545,12 @@ void QWaylandWindow::sendRecursiveExposeEvent()
+ 
+ void QWaylandWindow::attach(QWaylandBuffer *buffer, int x, int y)
+ {
+-    Q_ASSERT(!buffer->committed());
+     QReadLocker locker(&mSurfaceLock);
+     if (mSurface == nullptr)
+         return;
+ 
+     if (buffer) {
++        Q_ASSERT(!buffer->committed());
+         handleUpdate();
+         buffer->setBusy();
+ 
+@@ -583,7 +572,11 @@ void QWaylandWindow::damage(const QRect &rect)
+     if (mSurface == nullptr)
+         return;
+ 
+-    mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    const int s = scale();
++    if (mDisplay->compositorVersion() >= 4)
++        mSurface->damage_buffer(s * rect.x(), s * rect.y(), s * rect.width(), s * rect.height());
++    else
++        mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
+ }
+ 
+ void QWaylandWindow::safeCommit(QWaylandBuffer *buffer, const QRegion &damage)
+@@ -619,8 +612,14 @@ void QWaylandWindow::commit(QWaylandBuffer *buffer, const QRegion &damage)
+         return;
+ 
+     attachOffset(buffer);
+-    for (const QRect &rect: damage)
+-        mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    if (mDisplay->compositorVersion() >= 4) {
++        const int s = scale();
++        for (const QRect &rect: damage)
++            mSurface->damage_buffer(s * rect.x(), s * rect.y(), s * rect.width(), s * rect.height());
++    } else {
++        for (const QRect &rect: damage)
++            mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    }
+     Q_ASSERT(!buffer->committed());
+     buffer->setCommitted();
+     mSurface->commit();
+@@ -635,42 +634,53 @@ void QWaylandWindow::commit()
+ 
+ const wl_callback_listener QWaylandWindow::callbackListener = {
+     [](void *data, wl_callback *callback, uint32_t time) {
+-        Q_UNUSED(callback);
+         Q_UNUSED(time);
+         auto *window = static_cast<QWaylandWindow*>(data);
+-        window->handleFrameCallback();
++        window->handleFrameCallback(callback);
+     }
+ };
+ 
+-void QWaylandWindow::handleFrameCallback()
++void QWaylandWindow::handleFrameCallback(wl_callback* callback)
+ {
++    QMutexLocker locker(&mFrameSyncMutex);
++    if (!mFrameCallback) {
++        // This means the callback is already unset by QWaylandWindow::reset.
++        // The wl_callback object will be destroyed there too.
++        return;
++    }
++    Q_ASSERT(callback == mFrameCallback);
++    wl_callback_destroy(callback);
++    mFrameCallback = nullptr;
++
+     mWaitingForFrameCallback = false;
+     mFrameCallbackElapsedTimer.invalidate();
+ 
+     // The rest can wait until we can run it on the correct thread
+-    if (!mWaitingForUpdateDelivery) {
+-        auto doHandleExpose = [this]() {
+-            bool wasExposed = isExposed();
+-            mFrameCallbackTimedOut = false;
+-            if (!wasExposed && isExposed()) // Did setting mFrameCallbackTimedOut make the window exposed?
+-                sendExposeEvent(QRect(QPoint(), geometry().size()));
+-            if (wasExposed && hasPendingUpdateRequest())
+-                deliverUpdateRequest();
+-
+-            mWaitingForUpdateDelivery = false;
+-        };
++    auto doHandleExpose = [this]() {
++        mWaitingForUpdateDelivery.storeRelease(false);
++        bool wasExposed = isExposed();
++        mFrameCallbackTimedOut = false;
++        if (!wasExposed && isExposed()) // Did setting mFrameCallbackTimedOut make the window exposed?
++            sendExposeEvent(QRect(QPoint(), geometry().size()));
++        if (wasExposed && hasPendingUpdateRequest())
++            deliverUpdateRequest();
++    };
+ 
++    if (mWaitingForUpdateDelivery.testAndSetAcquire(false, true)) {
+         // Queued connection, to make sure we don't call handleUpdate() from inside waitForFrameSync()
+         // in the single-threaded case.
+-        mWaitingForUpdateDelivery = true;
+         QMetaObject::invokeMethod(this, doHandleExpose, Qt::QueuedConnection);
+     }
++
++    mFrameSyncWait.notify_all();
+ }
+ 
+ bool QWaylandWindow::waitForFrameSync(int timeout)
+ {
+-    QMutexLocker locker(mFrameQueue.mutex);
+-    mDisplay->dispatchQueueWhile(mFrameQueue.queue, [&]() { return mWaitingForFrameCallback; }, timeout);
++    QMutexLocker locker(&mFrameSyncMutex);
++
++    QDeadlineTimer deadline(timeout);
++    while (mWaitingForFrameCallback && mFrameSyncWait.wait(&mFrameSyncMutex, deadline)) { }
+ 
+     if (mWaitingForFrameCallback) {
+         qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
+@@ -868,6 +878,17 @@ bool QWaylandWindow::createDecoration()
+             subsurf->set_position(pos.x() + m.left(), pos.y() + m.top());
+         }
+         sendExposeEvent(QRect(QPoint(), geometry().size()));
++
++        // This is a special case where the buffer is recreated, but since
++        // the content rect remains the same, the widgets remain the same
++        // size and are not redrawn, leaving the new buffer empty. As a simple
++        // work-around, we trigger a full extra update whenever the client-side
++        // window decorations are toggled while the window is showing.
++        // Note: createDecoration() is sometimes called from the render thread
++        // of Qt Quick. This is essentially wrong and could potentially cause problems,
++        // but until the underlying issue has been fixed, we have to use invokeMethod()
++        // here to avoid asserts.
++        QMetaObject::invokeMethod(window(), &QWindow::requestUpdate);
+     }
+ 
+     return mWindowDecoration;
+@@ -1023,6 +1044,13 @@ void QWaylandWindow::handleScreensChanged()
+ 
+     QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->QPlatformScreen::screen());
+     mLastReportedScreen = newScreen;
++    if (fixedToplevelPositions && !QPlatformWindow::parent() && window()->type() != Qt::Popup
++        && window()->type() != Qt::ToolTip
++        && geometry().topLeft() != newScreen->geometry().topLeft()) {
++        auto geometry = this->geometry();
++        geometry.moveTo(newScreen->geometry().topLeft());
++        setGeometry(geometry);
++    }
+ 
+     int scale = newScreen->isPlaceholder() ? 1 : static_cast<QWaylandScreen *>(newScreen)->scale();
+     if (scale != mScale) {
+@@ -1094,10 +1122,18 @@ bool QWaylandWindow::setMouseGrabEnabled(bool grab)
+     return true;
+ }
+ 
++Qt::WindowStates QWaylandWindow::windowStates() const
++{
++    return mLastReportedWindowStates;
++}
++
+ void QWaylandWindow::handleWindowStatesChanged(Qt::WindowStates states)
+ {
+     createDecoration();
+-    QWindowSystemInterface::handleWindowStateChanged(window(), states, mLastReportedWindowStates);
++    Qt::WindowStates statesWithoutActive = states & ~Qt::WindowActive;
++    Qt::WindowStates lastStatesWithoutActive = mLastReportedWindowStates & ~Qt::WindowActive;
++    QWindowSystemInterface::handleWindowStateChanged(window(), statesWithoutActive,
++                                                     lastStatesWithoutActive);
+     mLastReportedWindowStates = states;
+ }
+ 
+@@ -1139,19 +1175,24 @@ void QWaylandWindow::timerEvent(QTimerEvent *event)
+     if (event->timerId() != mFrameCallbackCheckIntervalTimerId)
+         return;
+ 
+-    bool callbackTimerExpired = mFrameCallbackElapsedTimer.hasExpired(mFrameCallbackTimeout);
+-    if (!mFrameCallbackElapsedTimer.isValid() || callbackTimerExpired ) {
+-        killTimer(mFrameCallbackCheckIntervalTimerId);
+-        mFrameCallbackCheckIntervalTimerId = -1;
+-    }
+-    if (mFrameCallbackElapsedTimer.isValid() && callbackTimerExpired) {
+-        mFrameCallbackElapsedTimer.invalidate();
++    {
++        QMutexLocker lock(&mFrameSyncMutex);
+ 
+-        qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
+-        mFrameCallbackTimedOut = true;
+-        mWaitingForUpdate = false;
+-        sendExposeEvent(QRect());
++        bool callbackTimerExpired = mFrameCallbackElapsedTimer.hasExpired(mFrameCallbackTimeout);
++        if (!mFrameCallbackElapsedTimer.isValid() || callbackTimerExpired ) {
++            killTimer(mFrameCallbackCheckIntervalTimerId);
++            mFrameCallbackCheckIntervalTimerId = -1;
++        }
++        if (!mFrameCallbackElapsedTimer.isValid() || !callbackTimerExpired) {
++            return;
++        }
++        mFrameCallbackElapsedTimer.invalidate();
+     }
++
++    qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
++    mFrameCallbackTimedOut = true;
++    mWaitingForUpdate = false;
++    sendExposeEvent(QRect());
+ }
+ 
+ void QWaylandWindow::requestUpdate()
+@@ -1160,8 +1201,11 @@ void QWaylandWindow::requestUpdate()
+     Q_ASSERT(hasPendingUpdateRequest()); // should be set by QPA
+ 
+     // If we have a frame callback all is good and will be taken care of there
+-    if (mWaitingForFrameCallback)
+-        return;
++    {
++        QMutexLocker locker(&mFrameSyncMutex);
++        if (mWaitingForFrameCallback)
++            return;
++    }
+ 
+     // If we've already called deliverUpdateRequest(), but haven't seen any attach+commit/swap yet
+     // This is a somewhat redundant behavior and might indicate a bug in the calling code, so log
+@@ -1174,7 +1218,12 @@ void QWaylandWindow::requestUpdate()
+     // so use invokeMethod to delay the delivery a bit.
+     QMetaObject::invokeMethod(this, [this] {
+         // Things might have changed in the meantime
+-        if (hasPendingUpdateRequest() && !mWaitingForFrameCallback)
++        {
++            QMutexLocker locker(&mFrameSyncMutex);
++            if (mWaitingForFrameCallback)
++                return;
++        }
++        if (hasPendingUpdateRequest())
+             deliverUpdateRequest();
+     }, Qt::QueuedConnection);
+ }
+@@ -1185,19 +1234,18 @@ void QWaylandWindow::requestUpdate()
+ void QWaylandWindow::handleUpdate()
+ {
+     qCDebug(lcWaylandBackingstore) << "handleUpdate" << QThread::currentThread();
++
+     // TODO: Should sync subsurfaces avoid requesting frame callbacks?
+     QReadLocker lock(&mSurfaceLock);
+     if (!mSurface)
+         return;
+ 
+-    if (mFrameCallback) {
+-        wl_callback_destroy(mFrameCallback);
+-        mFrameCallback = nullptr;
+-    }
++    QMutexLocker locker(&mFrameSyncMutex);
++    if (mWaitingForFrameCallback)
++        return;
+ 
+-    QMutexLocker locker(mFrameQueue.mutex);
+     struct ::wl_surface *wrappedSurface = reinterpret_cast<struct ::wl_surface *>(wl_proxy_create_wrapper(mSurface->object()));
+-    wl_proxy_set_queue(reinterpret_cast<wl_proxy *>(wrappedSurface), mFrameQueue.queue);
++    wl_proxy_set_queue(reinterpret_cast<wl_proxy *>(wrappedSurface), mDisplay->frameEventQueue());
+     mFrameCallback = wl_surface_frame(wrappedSurface);
+     wl_proxy_wrapper_destroy(wrappedSurface);
+     wl_callback_add_listener(mFrameCallback, &QWaylandWindow::callbackListener, this);
+@@ -1207,6 +1255,8 @@ void QWaylandWindow::handleUpdate()
+     // Start a timer for handling the case when the compositor stops sending frame callbacks.
+     if (mFrameCallbackTimeout > 0) {
+         QMetaObject::invokeMethod(this, [this] {
++            QMutexLocker locker(&mFrameSyncMutex);
++
+             if (mWaitingForFrameCallback) {
+                 if (mFrameCallbackCheckIntervalTimerId < 0)
+                     mFrameCallbackCheckIntervalTimerId = startTimer(mFrameCallbackTimeout);
+@@ -1267,6 +1317,20 @@ void QWaylandWindow::setOpaqueArea(const QRegion &opaqueArea)
+     wl_region_destroy(region);
+ }
+ 
++void QWaylandWindow::addChildPopup(QWaylandWindow *surface) {
++    mChildPopups.append(surface);
++}
++
++void QWaylandWindow::removeChildPopup(QWaylandWindow *surface) {
++    mChildPopups.removeAll(surface);
++}
++
++void QWaylandWindow::closeChildPopups() {
++    while (!mChildPopups.isEmpty()) {
++        auto popup = mChildPopups.takeLast();
++        popup->reset();
++    }
++}
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/client/qwaylandwindow_p.h b/qtwayland/src/client/qwaylandwindow_p.h
+index 01337cff..2f219d8c 100644
+--- a/qtwayland/src/client/qwaylandwindow_p.h
++++ b/qtwayland/src/client/qwaylandwindow_p.h
+@@ -98,6 +98,9 @@ public:
+     QWaylandWindow(QWindow *window, QWaylandDisplay *display);
+     ~QWaylandWindow() override;
+ 
++    // Keep Toplevels position on the top left corner of their screen
++    static inline bool fixedToplevelPositions = true;
++
+     virtual WindowType windowType() const = 0;
+     virtual void ensureSize();
+     WId winId() const override;
+@@ -148,6 +151,7 @@ public:
+     void setWindowState(Qt::WindowStates states) override;
+     void setWindowFlags(Qt::WindowFlags flags) override;
+     void handleWindowStatesChanged(Qt::WindowStates states);
++    Qt::WindowStates windowStates() const;
+ 
+     void raise() override;
+     void lower() override;
+@@ -206,6 +210,10 @@ public:
+     void handleUpdate();
+     void deliverUpdateRequest() override;
+ 
++    void addChildPopup(QWaylandWindow* child);
++    void removeChildPopup(QWaylandWindow* child);
++    void closeChildPopups();
++
+ public slots:
+     void applyConfigure();
+ 
+@@ -215,7 +223,11 @@ signals:
+ 
+ protected:
+     QWaylandDisplay *mDisplay = nullptr;
++
++    // mSurface can be written by the main thread. Other threads should claim a read lock for access
++    mutable QReadWriteLock mSurfaceLock;
+     QScopedPointer<QWaylandSurface> mSurface;
++
+     QWaylandShellSurface *mShellSurface = nullptr;
+     QWaylandSubSurface *mSubSurfaceWindow = nullptr;
+     QVector<QWaylandSubSurface *> mChildren;
+@@ -225,13 +237,14 @@ protected:
+     Qt::MouseButtons mMousePressedInContentArea = Qt::NoButton;
+ 
+     WId mWindowId;
+-    bool mWaitingForFrameCallback = false;
+     bool mFrameCallbackTimedOut = false; // Whether the frame callback has timed out
+-    bool mWaitingForUpdateDelivery = false;
+     int mFrameCallbackCheckIntervalTimerId = -1;
+-    QElapsedTimer mFrameCallbackElapsedTimer;
+-    struct ::wl_callback *mFrameCallback = nullptr;
+-    QWaylandDisplay::FrameQueue mFrameQueue;
++    QAtomicInt mWaitingForUpdateDelivery = false;
++
++    bool mWaitingForFrameCallback = false; // Protected by mFrameSyncMutex
++    QElapsedTimer mFrameCallbackElapsedTimer; // Protected by mFrameSyncMutex
++    struct ::wl_callback *mFrameCallback = nullptr; // Protected by mFrameSyncMutex
++    QMutex mFrameSyncMutex;
+     QWaitCondition mFrameSyncWait;
+ 
+     // True when we have called deliverRequestUpdate, but the client has not yet attached a new buffer
+@@ -261,6 +274,8 @@ protected:
+     QWaylandBuffer *mQueuedBuffer = nullptr;
+     QRegion mQueuedBufferDamage;
+ 
++    QList<QPointer<QWaylandWindow>> mChildPopups;
++
+ private:
+     void setGeometry_helper(const QRect &rect);
+     void initWindow();
+@@ -283,12 +298,10 @@ private:
+     QRect mLastExposeGeometry;
+ 
+     static const wl_callback_listener callbackListener;
+-    void handleFrameCallback();
++    void handleFrameCallback(struct ::wl_callback* callback);
+ 
+     static QWaylandWindow *mMouseGrab;
+ 
+-    mutable QReadWriteLock mSurfaceLock;
+-
+     friend class QWaylandSubSurface;
+ };
+ 
+diff --git a/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h b/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
+index ccad0048..4cc9b3b8 100644
+--- a/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
++++ b/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
+@@ -73,11 +73,10 @@ public:
+         return true;
+     }
+     virtual QWaylandShellSurface *createShellSurface(QWaylandWindow *window) = 0;
++    // kept for binary compat with layer-shell-qt
+     virtual void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) {
+-        if (newFocus)
+-            m_display->handleWindowActivated(newFocus);
+-        if (oldFocus)
+-            m_display->handleWindowDeactivated(oldFocus);
++        Q_UNUSED(newFocus);
++        Q_UNUSED(oldFocus);
+     }
+     virtual void *nativeResourceForWindow(const QByteArray &resource, QWindow *window) {
+         Q_UNUSED(resource);
+diff --git a/qtwayland/src/compositor/configure.json b/qtwayland/src/compositor/configure.json
+index bcfd5215..da95d07b 100644
+--- a/qtwayland/src/compositor/configure.json
++++ b/qtwayland/src/compositor/configure.json
+@@ -7,6 +7,31 @@
+     "testDir": "../../config.tests",
+ 
+     "libraries": {
++        "wayland-client": {
++            "label": "Wayland client library",
++            "headers": "wayland-version.h",
++            "test": {
++                "main": [
++                    "#if WAYLAND_VERSION_MAJOR < 1",
++                    "# error Wayland 1.8.0 or higher required",
++                    "#endif",
++                    "#if WAYLAND_VERSION_MAJOR == 1",
++                    "# if WAYLAND_VERSION_MINOR < 8",
++                    "#  error Wayland 1.8.0 or higher required",
++                    "# endif",
++                    "# if WAYLAND_VERSION_MINOR == 8",
++                    "#  if WAYLAND_VERSION_MICRO < 0",
++                    "#   error Wayland 1.8.0 or higher required",
++                    "#  endif",
++                    "# endif",
++                    "#endif"
++                 ]
++            },
++            "sources": [
++                { "type": "pkgConfig", "args": "wayland-client" },
++                "-lwayland-client"
++            ]
++        },
+         "wayland-server": {
+             "label": "wayland-server",
+             "headers": "wayland-version.h",
+@@ -151,8 +176,7 @@
+                     "#endif"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "dmabuf-client-buffer": {
+             "label": "Linux Client dma-buf Buffer Sharing",
+@@ -176,8 +200,7 @@
+                     "return 0;"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "vulkan-server-buffer": {
+             "label": "Vulkan Buffer Sharing",
+@@ -195,7 +218,8 @@
+                     "exportAllocInfo.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR;",
+                     "return 0;"
+                 ]
+-            }
++            },
++            "use": "wayland-client"
+         }
+     },
+ 
+diff --git a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
+index 7889f575..64140672 100644
+--- a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
++++ b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
+@@ -40,6 +40,7 @@
+ #include "qwaylandeglwindow.h"
+ 
+ #include <QtWaylandClient/private/qwaylandscreen_p.h>
++#include <QtWaylandClient/private/qwaylandsurface_p.h>
+ #include "qwaylandglcontext.h"
+ 
+ #include <QtEglSupport/private/qeglconvenience_p.h>
+@@ -124,6 +125,7 @@ void QWaylandEglWindow::updateSurface(bool create)
+         }
+         mOffset = QPoint();
+     } else {
++        QReadLocker locker(&mSurfaceLock);
+         if (m_waylandEglWindow) {
+             int current_width, current_height;
+             static bool disableResizeCheck = qgetenv("QT_WAYLAND_DISABLE_RESIZECHECK").toInt();
+@@ -131,14 +133,16 @@ void QWaylandEglWindow::updateSurface(bool create)
+             if (!disableResizeCheck) {
+                 wl_egl_window_get_attached_size(m_waylandEglWindow, &current_width, &current_height);
+             }
+-            if (disableResizeCheck || (current_width != sizeWithMargins.width() || current_height != sizeWithMargins.height())) {
++            if (disableResizeCheck || (current_width != sizeWithMargins.width() || current_height != sizeWithMargins.height()) || m_requestedSize != sizeWithMargins) {
+                 wl_egl_window_resize(m_waylandEglWindow, sizeWithMargins.width(), sizeWithMargins.height(), mOffset.x(), mOffset.y());
++                m_requestedSize = sizeWithMargins;
+                 mOffset = QPoint();
+ 
+                 m_resize = true;
+             }
+-        } else if (create && wlSurface()) {
+-            m_waylandEglWindow = wl_egl_window_create(wlSurface(), sizeWithMargins.width(), sizeWithMargins.height());
++        } else if (create && mSurface) {
++            m_waylandEglWindow = wl_egl_window_create(mSurface->object(), sizeWithMargins.width(), sizeWithMargins.height());
++            m_requestedSize = sizeWithMargins;
+         }
+ 
+         if (!m_eglSurface && m_waylandEglWindow && create) {
+diff --git a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
+index 5b1f4d56..0079dfef 100644
+--- a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
++++ b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
+@@ -88,6 +88,7 @@ private:
+     mutable QOpenGLFramebufferObject *m_contentFBO = nullptr;
+ 
+     QSurfaceFormat m_format;
++    QSize m_requestedSize;
+ };
+ 
+ }
+diff --git a/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h b/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
+index 56a710c3..c6a8b6c6 100644
+--- a/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
++++ b/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
+@@ -41,6 +41,8 @@
+ #include <QtCore/QTextStream>
+ #include <QtGui/QOpenGLTexture>
+ 
++#include <array>
++
+ #include <EGL/egl.h>
+ #include <EGL/eglext.h>
+ 
+diff --git a/qtwayland/src/plugins/decorations/bradient/main.cpp b/qtwayland/src/plugins/decorations/bradient/main.cpp
+index e75fda3c..fa885143 100644
+--- a/qtwayland/src/plugins/decorations/bradient/main.cpp
++++ b/qtwayland/src/plugins/decorations/bradient/main.cpp
+@@ -164,13 +164,10 @@ void QWaylandBradientDecoration::paint(QPaintDevice *device)
+     // Window icon
+     QIcon icon = waylandWindow()->windowIcon();
+     if (!icon.isNull()) {
+-        QPixmap pixmap = icon.pixmap(QSize(128, 128));
+-        QPixmap scaled = pixmap.scaled(22, 22, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+-
+         QRectF iconRect(0, 0, 22, 22);
+-        p.drawPixmap(iconRect.adjusted(margins().left() + BUTTON_SPACING, 4,
+-                                       margins().left() + BUTTON_SPACING, 4),
+-                     scaled, iconRect);
++        iconRect.adjust(margins().left() + BUTTON_SPACING, 4,
++                        margins().left() + BUTTON_SPACING, 4),
++        icon.paint(&p, iconRect.toRect());
+     }
+ 
+     // Window title
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
+index 85d25e3c..60bdd491 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
+@@ -47,18 +47,21 @@ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
+-QWaylandXdgPopupV5::QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow *window)
++QWaylandXdgPopupV5::QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow* parent, QWaylandWindow *window)
+     : QWaylandShellSurface(window)
+     , QtWayland::xdg_popup_v5(popup)
++    , m_parent(parent)
+     , m_window(window)
+ {
+     if (window->display()->windowExtension())
+         m_extendedWindow = new QWaylandExtendedSurface(window);
++    m_parent->addChildPopup(m_window);
+ }
+ 
+ QWaylandXdgPopupV5::~QWaylandXdgPopupV5()
+ {
+     xdg_popup_destroy(object());
++    m_parent->removeChildPopup(m_window);
+     delete m_extendedWindow;
+ }
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
+index 7494f6a6..d85f130b 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
+@@ -70,7 +70,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgPopupV5 : public QWaylandShellSurface
+ {
+     Q_OBJECT
+ public:
+-    QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow *window);
++    QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow* parent, QWaylandWindow *window);
+     ~QWaylandXdgPopupV5() override;
+ 
+ protected:
+@@ -78,6 +78,7 @@ protected:
+ 
+ private:
+     QWaylandExtendedSurface *m_extendedWindow = nullptr;
++    QWaylandWindow *m_parent = nullptr;
+     QWaylandWindow *m_window = nullptr;
+ };
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
+index 7e242c4a..def8452a 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
+@@ -84,7 +84,7 @@ QWaylandXdgPopupV5 *QWaylandXdgShellV5::createXdgPopup(QWaylandWindow *window, Q
+     int x = position.x() + parentWindow->frameMargins().left();
+     int y = position.y() + parentWindow->frameMargins().top();
+ 
+-    auto popup = new QWaylandXdgPopupV5(get_xdg_popup(window->wlSurface(), parentSurface, seat, m_popupSerial, x, y), window);
++    auto popup = new QWaylandXdgPopupV5(get_xdg_popup(window->wlSurface(), parentSurface, seat, m_popupSerial, x, y), parentWindow, window);
+     m_popups.append(window);
+     QObject::connect(popup, &QWaylandXdgPopupV5::destroyed, [this, window](){
+         m_popups.removeOne(window);
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
+index 4e25949f..cfc60939 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
+@@ -85,13 +85,6 @@ QWaylandShellSurface *QWaylandXdgShellV5Integration::createShellSurface(QWayland
+     return m_xdgShell->createXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellV5Integration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) {
+-    if (newFocus && qobject_cast<QWaylandXdgPopupV5 *>(newFocus->shellSurface()))
+-        m_display->handleWindowActivated(newFocus);
+-    if (oldFocus && qobject_cast<QWaylandXdgPopupV5 *>(oldFocus->shellSurface()))
+-        m_display->handleWindowDeactivated(oldFocus);
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
+index ce6bdb9e..aed88670 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
+@@ -67,7 +67,6 @@ public:
+     QWaylandXdgShellV5Integration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShellV5> m_xdgShell;
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
+index 8c371661..151c78e3 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
+@@ -174,6 +174,7 @@ QWaylandXdgSurfaceV6::Popup::Popup(QWaylandXdgSurfaceV6 *xdgSurface, QWaylandXdg
+     , m_xdgSurface(xdgSurface)
+     , m_parent(parent)
+ {
++    m_parent->window()->addChildPopup(m_xdgSurface->window());
+ }
+ 
+ QWaylandXdgSurfaceV6::Popup::~Popup()
+@@ -181,6 +182,8 @@ QWaylandXdgSurfaceV6::Popup::~Popup()
+     if (isInitialized())
+         destroy();
+ 
++    m_parent->window()->removeChildPopup(m_xdgSurface->window());
++
+     if (m_grabbing) {
+         auto *shell = m_xdgSurface->m_shell;
+         Q_ASSERT(shell->m_topmostGrabbingPopup == this);
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
+index 03164316..e8da8ba1 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
+@@ -68,20 +68,6 @@ QWaylandShellSurface *QWaylandXdgShellV6Integration::createShellSurface(QWayland
+     return m_xdgShell->getXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellV6Integration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus)
+-{
+-    if (newFocus) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurfaceV6 *>(newFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowActivated(newFocus);
+-    }
+-    if (oldFocus && qobject_cast<QWaylandXdgSurfaceV6 *>(oldFocus->shellSurface())) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurfaceV6 *>(oldFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowDeactivated(oldFocus);
+-    }
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
+index 261f8cbb..c1bcd5c6 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
+@@ -65,7 +65,6 @@ public:
+     QWaylandXdgShellV6Integration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShellV6> m_xdgShell;
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
+index f3e3c330..fa6d5808 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
+@@ -67,11 +67,6 @@ QWaylandXdgSurface::Toplevel::Toplevel(QWaylandXdgSurface *xdgSurface)
+ 
+ QWaylandXdgSurface::Toplevel::~Toplevel()
+ {
+-    if (m_applied.states & Qt::WindowActive) {
+-        QWaylandWindow *window = m_xdgSurface->window();
+-        window->display()->handleWindowDeactivated(window);
+-    }
+-
+     // The protocol spec requires that the decoration object is deleted before xdg_toplevel.
+     delete m_decoration;
+     m_decoration = nullptr;
+@@ -85,16 +80,15 @@ void QWaylandXdgSurface::Toplevel::applyConfigure()
+     if (!(m_applied.states & (Qt::WindowMaximized|Qt::WindowFullScreen)))
+         m_normalSize = m_xdgSurface->m_window->windowFrameGeometry().size();
+ 
+-    if ((m_pending.states & Qt::WindowActive) && !(m_applied.states & Qt::WindowActive))
++    if ((m_pending.states & Qt::WindowActive) && !(m_applied.states & Qt::WindowActive)
++        && !m_xdgSurface->m_window->display()->isKeyboardAvailable())
+         m_xdgSurface->m_window->display()->handleWindowActivated(m_xdgSurface->m_window);
+ 
+-    if (!(m_pending.states & Qt::WindowActive) && (m_applied.states & Qt::WindowActive))
++    if (!(m_pending.states & Qt::WindowActive) && (m_applied.states & Qt::WindowActive)
++        && !m_xdgSurface->m_window->display()->isKeyboardAvailable())
+         m_xdgSurface->m_window->display()->handleWindowDeactivated(m_xdgSurface->m_window);
+ 
+-    // TODO: none of the other plugins send WindowActive either, but is it on purpose?
+-    Qt::WindowStates statesWithoutActive = m_pending.states & ~Qt::WindowActive;
+-
+-    m_xdgSurface->m_window->handleWindowStatesChanged(statesWithoutActive);
++    m_xdgSurface->m_window->handleWindowStatesChanged(m_pending.states);
+ 
+     if (m_pending.size.isEmpty()) {
+         // An empty size in the configure means it's up to the client to choose the size
+@@ -105,8 +99,6 @@ void QWaylandXdgSurface::Toplevel::applyConfigure()
+         m_xdgSurface->m_window->resizeFromApplyConfigure(m_pending.size);
+     }
+ 
+-    m_xdgSurface->setSizeHints();
+-
+     m_applied = m_pending;
+     qCDebug(lcQpaWayland) << "Applied pending xdg_toplevel configure event:" << m_applied.size << m_applied.states;
+ }
+@@ -203,12 +195,17 @@ QtWayland::xdg_toplevel::resize_edge QWaylandXdgSurface::Toplevel::convertToResi
+                 | ((edges & Qt::RightEdge) ? resize_edge_right : 0));
+ }
+ 
+-QWaylandXdgSurface::Popup::Popup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parent,
++QWaylandXdgSurface::Popup::Popup(QWaylandXdgSurface *xdgSurface, QWaylandWindow *parent,
+                                  QtWayland::xdg_positioner *positioner)
+-    : xdg_popup(xdgSurface->get_popup(parent->object(), positioner->object()))
+-    , m_xdgSurface(xdgSurface)
++    : m_xdgSurface(xdgSurface)
++    , m_parentXdgSurface(qobject_cast<QWaylandXdgSurface *>(parent->shellSurface()))
+     , m_parent(parent)
+ {
++
++    init(xdgSurface->get_popup(m_parentXdgSurface ? m_parentXdgSurface->object() : nullptr, positioner->object()));
++    if (m_parent) {
++        m_parent->addChildPopup(m_xdgSurface->window());
++    }
+ }
+ 
+ QWaylandXdgSurface::Popup::~Popup()
+@@ -216,10 +213,24 @@ QWaylandXdgSurface::Popup::~Popup()
+     if (isInitialized())
+         destroy();
+ 
++    if (m_parent) {
++        m_parent->removeChildPopup(m_xdgSurface->window());
++    }
++
+     if (m_grabbing) {
+         auto *shell = m_xdgSurface->m_shell;
+         Q_ASSERT(shell->m_topmostGrabbingPopup == this);
+-        shell->m_topmostGrabbingPopup = m_parent->m_popup;
++        shell->m_topmostGrabbingPopup = m_parentXdgSurface ? m_parentXdgSurface->m_popup : nullptr;
++        m_grabbing = false;
++
++        // Synthesize Qt enter/leave events for popup
++        QWindow *leave = nullptr;
++        if (m_xdgSurface && m_xdgSurface->window())
++            leave = m_xdgSurface->window()->window();
++        QWindowSystemInterface::handleLeaveEvent(leave);
++
++        if (QWindow *enter = QGuiApplication::topLevelAt(QCursor::pos()))
++            QWindowSystemInterface::handleEnterEvent(enter, enter->mapFromGlobal(QCursor::pos()), QCursor::pos());
+     }
+ }
+ 
+@@ -257,6 +268,7 @@ QWaylandXdgSurface::QWaylandXdgSurface(QWaylandXdgShell *shell, ::xdg_surface *s
+                 m_toplevel->set_parent(parentXdgSurface->m_toplevel->object());
+         }
+     }
++    setSizeHints();
+ }
+ 
+ QWaylandXdgSurface::~QWaylandXdgSurface()
+@@ -400,8 +412,6 @@ void QWaylandXdgSurface::setPopup(QWaylandWindow *parent)
+ {
+     Q_ASSERT(!m_toplevel && !m_popup);
+ 
+-    auto parentXdgSurface = static_cast<QWaylandXdgSurface *>(parent->shellSurface());
+-
+     auto positioner = new QtWayland::xdg_positioner(m_shell->create_positioner());
+     // set_popup expects a position relative to the parent
+     QPoint transientPos = m_window->geometry().topLeft(); // this is absolute
+@@ -414,8 +424,9 @@ void QWaylandXdgSurface::setPopup(QWaylandWindow *parent)
+     positioner->set_anchor(QtWayland::xdg_positioner::anchor_top_left);
+     positioner->set_gravity(QtWayland::xdg_positioner::gravity_bottom_right);
+     positioner->set_size(m_window->geometry().width(), m_window->geometry().height());
+-    m_popup = new Popup(this, parentXdgSurface, positioner);
++    m_popup = new Popup(this, parent, positioner);
+     positioner->destroy();
++
+     delete positioner;
+ }
+ 
+@@ -437,6 +448,23 @@ void QWaylandXdgSurface::setGrabPopup(QWaylandWindow *parent, QWaylandInputDevic
+     }
+     setPopup(parent);
+     m_popup->grab(device, serial);
++
++    // Synthesize Qt enter/leave events for popup
++    if (!parent)
++        return;
++    QWindow *current = QGuiApplication::topLevelAt(QCursor::pos());
++    QWindow *leave = parent->window();
++    if (current != leave)
++        return;
++
++    QWindowSystemInterface::handleLeaveEvent(leave);
++
++    QWindow *enter = nullptr;
++    if (m_popup && m_popup->m_xdgSurface && m_popup->m_xdgSurface->window())
++        enter = m_popup->m_xdgSurface->window()->window();
++
++    if (enter)
++        QWindowSystemInterface::handleEnterEvent(enter, enter->mapFromGlobal(QCursor::pos()), QCursor::pos());
+ }
+ 
+ void QWaylandXdgSurface::xdg_surface_configure(uint32_t serial)
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
+index 96785205..4b518f0a 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
+@@ -131,14 +131,15 @@ private:
+ 
+     class Popup : public QtWayland::xdg_popup {
+     public:
+-        Popup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parent, QtWayland::xdg_positioner *positioner);
++        Popup(QWaylandXdgSurface *xdgSurface, QWaylandWindow *parent, QtWayland::xdg_positioner *positioner);
+         ~Popup() override;
+ 
+         void grab(QWaylandInputDevice *seat, uint serial);
+         void xdg_popup_popup_done() override;
+ 
+         QWaylandXdgSurface *m_xdgSurface = nullptr;
+-        QWaylandXdgSurface *m_parent = nullptr;
++        QWaylandXdgSurface *m_parentXdgSurface = nullptr;
++        QWaylandWindow *m_parent = nullptr;
+         bool m_grabbing = false;
+     };
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
+index 8769d971..da0dd6a7 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
+@@ -69,20 +69,6 @@ QWaylandShellSurface *QWaylandXdgShellIntegration::createShellSurface(QWaylandWi
+     return m_xdgShell->getXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellIntegration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus)
+-{
+-    if (newFocus) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurface *>(newFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowActivated(newFocus);
+-    }
+-    if (oldFocus && qobject_cast<QWaylandXdgSurface *>(oldFocus->shellSurface())) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurface *>(oldFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowDeactivated(oldFocus);
+-    }
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
+index b6caa6c9..2f929f98 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
+@@ -65,7 +65,6 @@ public:
+     QWaylandXdgShellIntegration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShell> m_xdgShell;
+diff --git a/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp b/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
+index 526d0ef4..f50ccf30 100644
+--- a/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
++++ b/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
+@@ -39,7 +39,10 @@
+ 
+ #include "qwaylandinputmethodeventbuilder_p.h"
+ 
++#include <QBrush>
++#include <QGuiApplication>
+ #include <QInputMethod>
++#include <QPalette>
+ #include <QTextCharFormat>
+ 
+ #ifdef QT_BUILD_WAYLANDCOMPOSITOR_LIB
+@@ -81,32 +84,38 @@ void QWaylandInputMethodEventBuilder::addPreeditStyling(uint32_t index, uint32_t
+     QTextCharFormat format;
+ 
+     switch (style) {
+-    case 0:
+-    case 1:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_NONE:
++        break;
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_DEFAULT:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_UNDERLINE:
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-    case 2:
+-    case 3:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_ACTIVE:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_INACTIVE:
+         format.setFontWeight(QFont::Bold);
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-    case 4:
+-        format.setFontUnderline(true);
+-        format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+-        m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_HIGHLIGHT:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_SELECTION:
++        {
++            format.setFontUnderline(true);
++            format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
++            QPalette palette = qApp->palette();
++            format.setBackground(QBrush(palette.color(QPalette::Active, QPalette::Highlight)));
++            format.setForeground(QBrush(palette.color(QPalette::Active, QPalette::HighlightedText)));
++            m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
++        }
+         break;
+-    case 5:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_INCORRECT:
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::WaveUnderline);
+         format.setUnderlineColor(QColor(Qt::red));
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-//    case QtWayland::wl_text_input::preedit_style_selection:
+-//    case QtWayland::wl_text_input::preedit_style_none:
+     default:
+         break;
+     }
+@@ -153,7 +162,7 @@ QInputMethodEvent QWaylandInputMethodEventBuilder::buildPreedit(const QString &t
+ 
+     if (m_preeditCursor < 0) {
+         attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, 0, QVariant()));
+-    } else if (m_preeditCursor > 0) {
++    } else {
+         attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, indexFromWayland(text, m_preeditCursor), 1, QVariant()));
+     }
+ 
+diff --git a/qtwayland/src/shared/qwaylandmimehelper.cpp b/qtwayland/src/shared/qwaylandmimehelper.cpp
+index a5fdd34d..e2fe1928 100644
+--- a/qtwayland/src/shared/qwaylandmimehelper.cpp
++++ b/qtwayland/src/shared/qwaylandmimehelper.cpp
+@@ -60,7 +60,7 @@ QByteArray QWaylandMimeHelper::getByteArray(QMimeData *mimeData, const QString &
+             buf.open(QIODevice::ReadWrite);
+             QByteArray fmt = "BMP";
+             if (mimeType.startsWith(QLatin1String("image/"))) {
+-                QByteArray imgFmt = mimeType.mid(6).toUpper().toLatin1();
++                QByteArray imgFmt = mimeType.mid(6).toLower().toLatin1();
+                 if (QImageWriter::supportedImageFormats().contains(imgFmt))
+                     fmt = imgFmt;
+             }
+@@ -74,7 +74,7 @@ QByteArray QWaylandMimeHelper::getByteArray(QMimeData *mimeData, const QString &
+         QList<QUrl> urls = mimeData->urls();
+         for (int i = 0; i < urls.count(); ++i) {
+             content.append(urls.at(i).toEncoded());
+-            content.append('\n');
++            content.append("\r\n");
+         }
+     } else {
+         content = mimeData->data(mimeType);
+diff --git a/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp b/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
+index 1568b3b9..067410d0 100644
+--- a/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
++++ b/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
+@@ -35,7 +35,7 @@
+ 
+ using namespace MockCompositor;
+ 
+-constexpr int dataDeviceVersion = 1;
++constexpr int dataDeviceVersion = 3;
+ 
+ class DataDeviceCompositor : public DefaultCompositor {
+ public:
+diff --git a/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp b/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
+index 9312c2e5..2ea382f1 100644
+--- a/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
++++ b/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
+@@ -73,6 +73,7 @@ private slots:
+     void multiTouch();
+     void multiTouchUpAndMotionFrame();
+     void tapAndMoveInSameFrame();
++    void cancelTouch();
+ };
+ 
+ void tst_seatv5::bindsToSeat()
+@@ -646,5 +647,34 @@ void tst_seatv5::tapAndMoveInSameFrame()
+     QTRY_COMPARE(window.m_events.last().touchPoints.first().state(), Qt::TouchPointState::TouchPointReleased);
+ }
+ 
++void tst_seatv5::cancelTouch()
++{
++    TouchWindow window;
++    QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
++
++    exec([=] {
++        auto *t = touch();
++        auto *c = client();
++        t->sendDown(xdgToplevel()->surface(), {32, 32}, 1);
++        t->sendFrame(c);
++        t->sendCancel(c);
++        t->sendFrame(c);
++    });
++
++    QTRY_VERIFY(!window.m_events.empty());
++    {
++        auto e = window.m_events.takeFirst();
++        QCOMPARE(e.type, QEvent::TouchBegin);
++        QCOMPARE(e.touchPointStates, Qt::TouchPointPressed);
++        QCOMPARE(e.touchPoints.length(), 1);
++        QCOMPARE(e.touchPoints.first().pos(), QPointF(32-window.frameMargins().left(), 32-window.frameMargins().top()));
++    }
++    {
++        auto e = window.m_events.takeFirst();
++        QCOMPARE(e.type, QEvent::TouchCancel);
++        QCOMPARE(e.touchPoints.length(), 0);
++    }
++}
++
+ QCOMPOSITOR_TEST_MAIN(tst_seatv5)
+ #include "tst_seatv5.moc"
+diff --git a/qtwayland/tests/auto/client/shared/corecompositor.cpp b/qtwayland/tests/auto/client/shared/corecompositor.cpp
+index 5c6c83ba..fa9b7662 100644
+--- a/qtwayland/tests/auto/client/shared/corecompositor.cpp
++++ b/qtwayland/tests/auto/client/shared/corecompositor.cpp
+@@ -27,6 +27,7 @@
+ ****************************************************************************/
+ 
+ #include "corecompositor.h"
++#include <thread>
+ 
+ namespace MockCompositor {
+ 
+diff --git a/qtwayland/tests/auto/client/shared/coreprotocol.cpp b/qtwayland/tests/auto/client/shared/coreprotocol.cpp
+index 0d988521..d1a2e7cb 100644
+--- a/qtwayland/tests/auto/client/shared/coreprotocol.cpp
++++ b/qtwayland/tests/auto/client/shared/coreprotocol.cpp
+@@ -451,6 +451,13 @@ void Touch::sendFrame(wl_client *client)
+         send_frame(r->handle);
+ }
+ 
++void Touch::sendCancel(wl_client *client)
++{
++    const auto touchResources = resourceMap().values(client);
++    for (auto *r : touchResources)
++        send_cancel(r->handle);
++}
++
+ uint Keyboard::sendEnter(Surface *surface)
+ {
+     auto serial = m_seat->m_compositor->nextSerial();
+diff --git a/qtwayland/tests/auto/client/shared/coreprotocol.h b/qtwayland/tests/auto/client/shared/coreprotocol.h
+index a1af137a..210d8ddb 100644
+--- a/qtwayland/tests/auto/client/shared/coreprotocol.h
++++ b/qtwayland/tests/auto/client/shared/coreprotocol.h
+@@ -158,7 +158,7 @@ class WlCompositor : public Global, public QtWaylandServer::wl_compositor
+ {
+     Q_OBJECT
+ public:
+-    explicit WlCompositor(CoreCompositor *compositor, int version = 3)
++    explicit WlCompositor(CoreCompositor *compositor, int version = 4)
+         : QtWaylandServer::wl_compositor(compositor->m_display, version)
+         , m_compositor(compositor)
+     {}
+@@ -364,6 +364,7 @@ public:
+     uint sendUp(wl_client *client, int id);
+     void sendMotion(wl_client *client, const QPointF &position, int id);
+     void sendFrame(wl_client *client);
++    void sendCancel(wl_client *client);
+ 
+     Seat *m_seat = nullptr;
+ };
+diff --git a/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp b/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
+index a415cbf5..b1d3d07d 100644
+--- a/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
++++ b/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
+@@ -342,7 +342,7 @@ Compositor::Compositor(MockCompositor *mockCompositor)
+         exit(EXIT_FAILURE);
+     }
+ 
+-    wl_global_create(m_display, &wl_compositor_interface, 1, this, bindCompositor);
++    wl_global_create(m_display, &wl_compositor_interface, 4, this, bindCompositor);
+ 
+     m_data_device_manager.reset(new DataDeviceManager(this, m_display));
+ 
+diff --git a/qtwayland/tests/auto/client/shared_old/mocksurface.cpp b/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
+index e9df5f90..c3246e4a 100644
+--- a/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
++++ b/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
+@@ -125,6 +125,16 @@ void Surface::surface_damage(Resource *resource,
+     Q_UNUSED(height);
+ }
+ 
++void Surface::surface_damage_buffer(Resource *resource,
++                                    int32_t x, int32_t y, int32_t width, int32_t height)
++{
++    Q_UNUSED(resource);
++    Q_UNUSED(x);
++    Q_UNUSED(y);
++    Q_UNUSED(width);
++    Q_UNUSED(height);
++}
++
+ void Surface::surface_frame(Resource *resource,
+                             uint32_t callback)
+ {
+diff --git a/qtwayland/tests/auto/client/shared_old/mocksurface.h b/qtwayland/tests/auto/client/shared_old/mocksurface.h
+index 949dc23d..d176837e 100644
+--- a/qtwayland/tests/auto/client/shared_old/mocksurface.h
++++ b/qtwayland/tests/auto/client/shared_old/mocksurface.h
+@@ -65,6 +65,8 @@ protected:
+                         struct wl_resource *buffer, int x, int y) override;
+     void surface_damage(Resource *resource,
+                         int32_t x, int32_t y, int32_t width, int32_t height) override;
++    void surface_damage_buffer(Resource *resource,
++                               int32_t x, int32_t y, int32_t width, int32_t height) override;
+     void surface_frame(Resource *resource,
+                        uint32_t callback) override;
+     void surface_commit(Resource *resource) override;
+diff --git a/qtwayland/tests/auto/client/surface/tst_surface.cpp b/qtwayland/tests/auto/client/surface/tst_surface.cpp
+index 95e4e609..60c672ce 100644
+--- a/qtwayland/tests/auto/client/surface/tst_surface.cpp
++++ b/qtwayland/tests/auto/client/surface/tst_surface.cpp
+@@ -129,6 +129,10 @@ void tst_surface::waitForFrameCallbackGl()
+     // Make sure we follow frame callbacks for some frames
+     for (int i = 0; i < 5; ++i) {
+         xdgPingAndWaitForPong(); // Make sure things have happened on the client
++        if (!qEnvironmentVariableIntValue("QT_WAYLAND_DISABLE_WINDOWDECORATION") && i == 0) {
++            QCOMPARE(bufferSpy.count(), 1);
++            bufferSpy.removeFirst();
++        }
+         exec([&] {
+             QVERIFY(bufferSpy.empty()); // Make sure no extra buffers have arrived
+             QVERIFY(!xdgToplevel()->surface()->m_waitingFrameCallbacks.empty());
+diff --git a/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp b/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
+index 2277bbb8..747875b4 100644
+--- a/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
++++ b/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
+@@ -31,6 +31,7 @@
+ #include <QtGui/QOpenGLWindow>
+ #include <QtGui/qpa/qplatformnativeinterface.h>
+ #include <QtWaylandClient/private/wayland-wayland-client-protocol.h>
++#include <QtWaylandClient/private/qwaylandwindow_p.h>
+ 
+ using namespace MockCompositor;
+ 
+@@ -45,6 +46,7 @@ private slots:
+     void configureStates();
+     void popup();
+     void tooltipOnPopup();
++    void tooltipAndSiblingPopup();
+     void switchPopups();
+     void hidePopupParent();
+     void pongs();
+@@ -138,6 +140,7 @@ void tst_xdgshell::configureSize()
+ 
+ void tst_xdgshell::configureStates()
+ {
++    QVERIFY(qputenv("QT_WAYLAND_FRAME_CALLBACK_TIMEOUT", "0"));
+     QRasterWindow window;
+     window.resize(64, 48);
+     window.show();
+@@ -154,9 +157,12 @@ void tst_xdgshell::configureStates()
+     // Toplevel windows don't know their position on xdg-shell
+ //    QCOMPARE(window.frameGeometry().topLeft(), QPoint()); // TODO: this doesn't currently work when window decorations are enabled
+ 
+-//    QEXPECT_FAIL("", "configure has already been acked, we shouldn't have to wait for isActive", Continue);
+-//    QVERIFY(window.isActive());
+-    QTRY_VERIFY(window.isActive()); // Just make sure it eventually get's set correctly
++    // window.windowstate() is driven by keyboard focus, however for decorations we want to follow
++    // XDGShell this is internal to QtWayland so it is queried directly
++    auto waylandWindow = static_cast<QtWaylandClient::QWaylandWindow *>(window.handle());
++    Q_ASSERT(waylandWindow);
++    QTRY_VERIFY(waylandWindow->windowStates().testFlag(
++            Qt::WindowActive)); // Just make sure it eventually get's set correctly
+ 
+     const QSize screenSize(640, 480);
+     const uint maximizedSerial = exec([=] {
+@@ -186,6 +192,7 @@ void tst_xdgshell::configureStates()
+     QCOMPARE(window.windowStates(), Qt::WindowNoState);
+     QCOMPARE(window.frameGeometry().size(), windowedSize);
+ //    QCOMPARE(window.frameGeometry().topLeft(), QPoint()); // TODO: this doesn't currently work when window decorations are enabled
++    QVERIFY(qunsetenv("QT_WAYLAND_FRAME_CALLBACK_TIMEOUT"));
+ }
+ 
+ void tst_xdgshell::popup()
+@@ -340,6 +347,92 @@ void tst_xdgshell::tooltipOnPopup()
+     QCOMPOSITOR_TRY_COMPARE(xdgPopup(0), nullptr);
+ }
+ 
++void tst_xdgshell::tooltipAndSiblingPopup()
++{
++    class ToolTip : public QRasterWindow {
++    public:
++        explicit ToolTip(QWindow *parent) {
++            setTransientParent(parent);
++            setFlags(Qt::ToolTip);
++            resize(100, 100);
++            show();
++        }
++        void mousePressEvent(QMouseEvent *event) override {
++            QRasterWindow::mousePressEvent(event);
++            m_popup = new QRasterWindow;
++            m_popup->setTransientParent(transientParent());
++            m_popup->setFlags(Qt::Popup);
++            m_popup->resize(100, 100);
++            m_popup->show();
++        }
++
++        QRasterWindow *m_popup = nullptr;
++    };
++
++    class Window : public QRasterWindow {
++    public:
++        void mousePressEvent(QMouseEvent *event) override {
++            QRasterWindow::mousePressEvent(event);
++            m_tooltip = new ToolTip(this);
++        }
++        ToolTip *m_tooltip = nullptr;
++    };
++
++    Window window;
++    window.resize(200, 200);
++    window.show();
++
++    QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
++    exec([=] { xdgToplevel()->sendCompleteConfigure(); });
++    QCOMPOSITOR_TRY_VERIFY(xdgToplevel()->m_xdgSurface->m_committedConfigureSerial);
++
++    exec([=] {
++        auto *surface = xdgToplevel()->surface();
++        auto *p = pointer();
++        auto *c = client();
++        p->sendEnter(surface, {100, 100});
++        p->sendFrame(c);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_pressed);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_released);
++        p->sendFrame(c);
++        p->sendLeave(surface);
++        p->sendFrame(c);
++    });
++
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup());
++    exec([=] { xdgPopup()->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup()->m_xdgSurface->m_committedConfigureSerial);
++    QCOMPOSITOR_TRY_VERIFY(!xdgPopup()->m_grabbed);
++
++    exec([=] {
++        auto *surface = xdgPopup()->surface();
++        auto *p = pointer();
++        auto *c = client();
++        p->sendEnter(surface, {100, 100});
++        p->sendFrame(c);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_pressed);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_released);
++        p->sendFrame(c);
++    });
++
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1));
++    exec([=] { xdgPopup(1)->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1)->m_xdgSurface->m_committedConfigureSerial);
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1)->m_grabbed);
++
++    // Close the middle tooltip (it should not close the sibling popup)
++    window.m_tooltip->close();
++
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(1), nullptr);
++    // Verify the remaining xdg surface is a grab popup..
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(0));
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(0)->m_grabbed);
++
++    window.m_tooltip->m_popup->close();
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(1), nullptr);
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(0), nullptr);
++}
++
+ // QTBUG-65680
+ void tst_xdgshell::switchPopups()
+ {
+@@ -505,7 +598,7 @@ void tst_xdgshell::minMaxSize()
+     window.show();
+     QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
+ 
+-    exec([=] { xdgToplevel()->sendCompleteConfigure(); });
++    // we don't roundtrip with our configuration the initial commit should be correct
+ 
+     QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.minSize, QSize(100, 100));
+     QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.maxSize, QSize(1000, 1000));
+Submodule qtwebchannel 618422ee..f8949655:
+diff --git a/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp b/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
+index 536eb5c..898d769 100644
+--- a/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
++++ b/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
+@@ -186,8 +186,6 @@ Q_DECLARE_TYPEINFO(OverloadResolutionCandidate, Q_MOVABLE_TYPE);
+ QMetaObjectPublisher::QMetaObjectPublisher(QWebChannel *webChannel)
+     : QObject(webChannel)
+     , webChannel(webChannel)
+-    , signalHandler(this)
+-    , clientIsIdle(false)
+     , blockUpdates(false)
+     , propertyUpdatesInitialized(false)
+ {
+@@ -301,17 +299,17 @@ QJsonObject QMetaObjectPublisher::classInfoForObject(const QObject *object, QWeb
+     return data;
+ }
+ 
+-void QMetaObjectPublisher::setClientIsIdle(bool isIdle)
++void QMetaObjectPublisher::setClientIsIdle(bool isIdle, QWebChannelAbstractTransport *transport)
+ {
+-    if (clientIsIdle == isIdle) {
+-        return;
+-    }
+-    clientIsIdle = isIdle;
+-    if (!isIdle && timer.isActive()) {
+-        timer.stop();
+-    } else if (isIdle && !timer.isActive()) {
+-        timer.start(PROPERTY_UPDATE_INTERVAL, this);
+-    }
++    transportState[transport].clientIsIdle = isIdle;
++    if (isIdle)
++        sendEnqueuedPropertyUpdates(transport);
++}
++
++bool QMetaObjectPublisher::isClientIdle(QWebChannelAbstractTransport *transport)
++{
++    auto found = transportState.find(transport);
++    return found != transportState.end() && found.value().clientIsIdle;
+ }
+ 
+ QJsonObject QMetaObjectPublisher::initializeClient(QWebChannelAbstractTransport *transport)
+@@ -333,6 +331,7 @@ QJsonObject QMetaObjectPublisher::initializeClient(QWebChannelAbstractTransport
+ 
+ void QMetaObjectPublisher::initializePropertyUpdates(const QObject *const object, const QJsonObject &objectInfo)
+ {
++    auto *signalHandler = signalHandlerFor(object);
+     foreach (const QJsonValue &propertyInfoVar, objectInfo[KEY_PROPERTIES].toArray()) {
+         const QJsonArray &propertyInfo = propertyInfoVar.toArray();
+         if (propertyInfo.size() < 2) {
+@@ -353,19 +352,19 @@ void QMetaObjectPublisher::initializePropertyUpdates(const QObject *const object
+ 
+         // Only connect for a property update once
+         if (connectedProperties.isEmpty()) {
+-            signalHandler.connectTo(object, signalIndex);
++            signalHandler->connectTo(object, signalIndex);
+         }
+ 
+         connectedProperties.insert(propertyIndex);
+     }
+ 
+     // also always connect to destroyed signal
+-    signalHandler.connectTo(object, s_destroyedSignalIndex);
++    signalHandler->connectTo(object, s_destroyedSignalIndex);
+ }
+ 
+ void QMetaObjectPublisher::sendPendingPropertyUpdates()
+ {
+-    if (blockUpdates || !clientIsIdle || pendingPropertyUpdates.isEmpty()) {
++    if (blockUpdates) {
+         return;
+     }
+ 
+@@ -415,18 +414,19 @@ void QMetaObjectPublisher::sendPendingPropertyUpdates()
+ 
+     // data does not contain specific updates
+     if (!data.isEmpty()) {
+-        setClientIsIdle(false);
+-
+         message[KEY_DATA] = data;
+-        broadcastMessage(message);
++        enqueueBroadcastMessage(message);
+     }
+ 
+     // send every property update which is not supposed to be broadcasted
+     const QHash<QWebChannelAbstractTransport*, QJsonArray>::const_iterator suend = specificUpdates.constEnd();
+     for (QHash<QWebChannelAbstractTransport*, QJsonArray>::const_iterator it = specificUpdates.constBegin(); it != suend; ++it) {
+         message[KEY_DATA] = it.value();
+-        it.key()->sendMessage(message);
++        enqueueMessage(message, it.key());
+     }
++
++    for (auto state = transportState.begin(); state != transportState.end(); ++state)
++        sendEnqueuedPropertyUpdates(state.key());
+ }
+ 
+ QVariant QMetaObjectPublisher::invokeMethod(QObject *const object, const QMetaMethod &method,
+@@ -572,7 +572,7 @@ void QMetaObjectPublisher::signalEmitted(const QObject *object, const int signal
+         }
+     } else {
+         pendingPropertyUpdates[object][signalIndex] = arguments;
+-        if (clientIsIdle && !blockUpdates && !timer.isActive()) {
++        if (!blockUpdates && !timer.isActive()) {
+             timer.start(PROPERTY_UPDATE_INTERVAL, this);
+         }
+     }
+@@ -590,7 +590,7 @@ void QMetaObjectPublisher::objectDestroyed(const QObject *object)
+     // only remove from handler when we initialized the property updates
+     // cf: https://bugreports.qt.io/browse/QTBUG-60250
+     if (propertyUpdatesInitialized) {
+-        signalHandler.remove(object);
++        signalHandlerFor(object)->remove(object);
+         signalToPropertyMap.remove(object);
+     }
+     pendingPropertyUpdates.remove(object);
+@@ -852,6 +852,52 @@ void QMetaObjectPublisher::broadcastMessage(const QJsonObject &message) const
+     }
+ }
+ 
++void QMetaObjectPublisher::enqueueBroadcastMessage(const QJsonObject &message)
++{
++    if (webChannel->d_func()->transports.isEmpty()) {
++        qWarning("QWebChannel is not connected to any transports, cannot send message: %s",
++                 QJsonDocument(message).toJson().constData());
++        return;
++    }
++
++    for (auto *transport : webChannel->d_func()->transports) {
++        auto &state = transportState[transport];
++        state.queuedMessages.append(message);
++    }
++}
++
++void QMetaObjectPublisher::enqueueMessage(const QJsonObject &message,
++                                          QWebChannelAbstractTransport *transport)
++{
++    auto &state = transportState[transport];
++    state.queuedMessages.append(message);
++}
++
++void QMetaObjectPublisher::sendEnqueuedPropertyUpdates(QWebChannelAbstractTransport *transport)
++{
++    auto found = transportState.find(transport);
++    if (found != transportState.end() && found.value().clientIsIdle
++        && !found.value().queuedMessages.isEmpty()) {
++
++        // If the client is connected with an in-process transport, it can
++        // happen that a message triggers a subsequent property change. In
++        // that case, we need to ensure that the queued messages have already
++        // been cleared; otherwise the recursive call will send everythig again.
++        // Case in point: The qmlwebchannel tests fail if we don't clear the
++        // queued messages before sending them out.
++        // For that same reason set the client to "busy" (aka non-idle) just
++        // right before sending out the messages; otherwise a potential
++        // "Idle" type message will not correctly restore the Idle state.
++        const auto messages = std::move(found.value().queuedMessages);
++        Q_ASSERT(found.value().queuedMessages.isEmpty());
++        found.value().clientIsIdle = false;
++
++        for (const auto &message : messages) {
++            transport->sendMessage(message);
++        }
++    }
++}
++
+ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannelAbstractTransport *transport)
+ {
+     if (!webChannel->d_func()->transports.contains(transport)) {
+@@ -866,7 +912,7 @@ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannel
+ 
+     const MessageType type = toType(message.value(KEY_TYPE));
+     if (type == TypeIdle) {
+-        setClientIsIdle(true);
++        setClientIsIdle(true, transport);
+     } else if (type == TypeInit) {
+         if (!message.contains(KEY_ID)) {
+             qWarning("JSON message object is missing the id property: %s",
+@@ -913,9 +959,9 @@ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannel
+                 return;
+             transport->sendMessage(createResponse(message.value(KEY_ID), wrapResult(result, transport)));
+         } else if (type == TypeConnectToSignal) {
+-            signalHandler.connectTo(object, message.value(KEY_SIGNAL).toInt(-1));
++            signalHandlerFor(object)->connectTo(object, message.value(KEY_SIGNAL).toInt(-1));
+         } else if (type == TypeDisconnectFromSignal) {
+-            signalHandler.disconnectFrom(object, message.value(KEY_SIGNAL).toInt(-1));
++            signalHandlerFor(object)->disconnectFrom(object, message.value(KEY_SIGNAL).toInt(-1));
+         } else if (type == TypeSetProperty) {
+             setProperty(object, message.value(KEY_PROPERTY).toInt(-1),
+                         message.value(KEY_VALUE));
+@@ -931,6 +977,7 @@ void QMetaObjectPublisher::setBlockUpdates(bool block)
+     blockUpdates = block;
+ 
+     if (!blockUpdates) {
++        timer.start(PROPERTY_UPDATE_INTERVAL, this);
+         sendPendingPropertyUpdates();
+     } else if (timer.isActive()) {
+         timer.stop();
+@@ -948,4 +995,15 @@ void QMetaObjectPublisher::timerEvent(QTimerEvent *event)
+     }
+ }
+ 
++SignalHandler<QMetaObjectPublisher> *QMetaObjectPublisher::signalHandlerFor(const QObject *object)
++{
++    auto thread = object->thread();
++    auto it = signalHandlers.find(thread);
++    if (it == signalHandlers.end()) {
++        it = signalHandlers.emplace(thread, this).first;
++        it->second.moveToThread(thread);
++    }
++    return &it->second;
++}
++
+ QT_END_NAMESPACE
+diff --git a/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h b/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
+index bbd9875..4713ef1 100644
+--- a/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
++++ b/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
+@@ -59,6 +59,9 @@
+ #include <QBasicTimer>
+ #include <QPointer>
+ #include <QJsonObject>
++#include <QQueue>
++
++#include <unordered_map>
+ 
+ #include "qwebchannelglobal.h"
+ 
+@@ -109,17 +112,36 @@ public:
+      */
+     void broadcastMessage(const QJsonObject &message) const;
+ 
++    /**
++     * Enqueue the given @p message to all known transports.
++     */
++    void enqueueBroadcastMessage(const QJsonObject &message);
++
++    /**
++     * Enqueue the given @p message to @p transport.
++     */
++    void enqueueMessage(const QJsonObject &message, QWebChannelAbstractTransport *transport);
++
++    /**
++     * If client for given @p transport is idle, send queued messaged to @p transport and then mark
++     * the client as not idle.
++     */
++    void sendEnqueuedPropertyUpdates(QWebChannelAbstractTransport *transport);
++
+     /**
+      * Serialize the QMetaObject of @p object and return it in JSON form.
+      */
+     QJsonObject classInfoForObject(const QObject *object, QWebChannelAbstractTransport *transport);
+ 
+     /**
+-     * Set the client to idle or busy, based on the value of @p isIdle.
+-     *
+-     * When the value changed, start/stop the property update timer accordingly.
++     * Set the client to idle or busy for a single @p transport, based on the value of @p isIdle.
++     */
++    void setClientIsIdle(bool isIdle, QWebChannelAbstractTransport *transport);
++
++    /**
++     * Check that client is idle for @p transport.
+      */
+-    void setClientIsIdle(bool isIdle);
++    bool isClientIdle(QWebChannelAbstractTransport *transport);
+ 
+     /**
+      * Initialize clients by sending them the class information of the registered objects.
+@@ -272,10 +294,18 @@ private:
+     friend class TestWebChannel;
+ 
+     QWebChannel *webChannel;
+-    SignalHandler<QMetaObjectPublisher> signalHandler;
++    std::unordered_map<const QThread*, SignalHandler<QMetaObjectPublisher>> signalHandlers;
++    SignalHandler<QMetaObjectPublisher> *signalHandlerFor(const QObject *object);
+ 
+-    // true when the client is idle, false otherwise
+-    bool clientIsIdle;
++    struct TransportState
++    {
++        TransportState() : clientIsIdle(false) { }
++        // true when the client is idle, false otherwise
++        bool clientIsIdle;
++        // messages to send
++        QQueue<QJsonObject> queuedMessages;
++    };
++    QHash<QWebChannelAbstractTransport *, TransportState> transportState;
+ 
+     // true when no property updates should be sent, false otherwise
+     bool blockUpdates;
+diff --git a/qtwebchannel/src/webchannel/signalhandler_p.h b/qtwebchannel/src/webchannel/signalhandler_p.h
+index 27afadb..d77373c 100644
+--- a/qtwebchannel/src/webchannel/signalhandler_p.h
++++ b/qtwebchannel/src/webchannel/signalhandler_p.h
+@@ -56,6 +56,7 @@
+ #include <QVector>
+ #include <QMetaMethod>
+ #include <QDebug>
++#include <QThread>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -71,6 +72,7 @@ static const int s_destroyedSignalIndex = QObject::staticMetaObject.indexOfMetho
+ template<class Receiver>
+ class SignalHandler : public QObject
+ {
++    Q_DISABLE_COPY(SignalHandler)
+ public:
+     SignalHandler(Receiver *receiver, QObject *parent = 0);
+ 
+@@ -268,6 +270,7 @@ int SignalHandler<Receiver>::qt_metacall(QMetaObject::Call call, int methodId, v
+     if (call == QMetaObject::InvokeMetaMethod) {
+         const QObject *object = sender();
+         Q_ASSERT(object);
++        Q_ASSERT(QThread::currentThread() == object->thread());
+         Q_ASSERT(senderSignalIndex() == methodId);
+         Q_ASSERT(m_connectionsCounter.contains(object));
+         Q_ASSERT(m_connectionsCounter.value(object).contains(methodId));
+diff --git a/qtwebchannel/tests/auto/qml/testwebchannel.cpp b/qtwebchannel/tests/auto/qml/testwebchannel.cpp
+index 9891687..3ca81c2 100644
+--- a/qtwebchannel/tests/auto/qml/testwebchannel.cpp
++++ b/qtwebchannel/tests/auto/qml/testwebchannel.cpp
+@@ -46,7 +46,11 @@ TestWebChannel::~TestWebChannel()
+ 
+ bool TestWebChannel::clientIsIdle() const
+ {
+-    return QWebChannel::d_func()->publisher->clientIsIdle;
++    for (auto *transport : QWebChannel::d_func()->transports) {
++        if (QWebChannel::d_func()->publisher->isClientIdle(transport))
++            return true;
++    }
++    return false;
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp b/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
+index 181da9e..37f989a 100644
+--- a/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
++++ b/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
+@@ -785,7 +785,7 @@ void TestWebChannel::testTransportWrapObjectProperties()
+     DummyTransport *dummyTransport = new DummyTransport(this);
+     channel.connectTo(dummyTransport);
+     channel.d_func()->publisher->initializeClient(dummyTransport);
+-    channel.d_func()->publisher->setClientIsIdle(true);
++    channel.d_func()->publisher->setClientIsIdle(true, dummyTransport);
+ 
+     QCOMPARE(channel.d_func()->publisher->transportedWrappedObjects.size(), 0);
+ 
+@@ -943,8 +943,6 @@ void TestWebChannel::testInfiniteRecursion()
+ 
+ void TestWebChannel::testAsyncObject()
+ {
+-    QSKIP("This test is broken. See QTBUG-80729");
+-
+     QWebChannel channel;
+     channel.connectTo(m_dummyTransport);
+ 
+@@ -990,6 +988,50 @@ void TestWebChannel::testAsyncObject()
+     thread.wait();
+ }
+ 
++void TestWebChannel::testPropertyMultipleTransports()
++{
++    DummyTransport transport1;
++    DummyTransport transport2;
++
++    QWebChannel channel;
++    QMetaObjectPublisher *publisher = channel.d_func()->publisher;
++
++    TestObject testObj;
++    testObj.setObjectName("testObject");
++    channel.registerObject(testObj.objectName(), &testObj);
++    channel.connectTo(&transport1);
++    channel.connectTo(&transport2);
++
++    testObj.setProp("Hello");
++
++    publisher->initializeClient(&transport1);
++    publisher->initializeClient(&transport2);
++    publisher->setClientIsIdle(true, &transport1);
++    QCOMPARE(publisher->isClientIdle(&transport1), true);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++    QVERIFY(transport1.messagesSent().isEmpty());
++    QVERIFY(transport2.messagesSent().isEmpty());
++
++    testObj.setProp("World");
++    QTRY_COMPARE_WITH_TIMEOUT(transport1.messagesSent().size(), 1u, 2000);
++    QCOMPARE(transport2.messagesSent().size(), 0u);
++    publisher->setClientIsIdle(true, &transport2);
++    QTRY_COMPARE_WITH_TIMEOUT(transport2.messagesSent().size(), 1u, 2000);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++
++    testObj.setProp("!!!");
++    publisher->setClientIsIdle(true, &transport2);
++    QCOMPARE(publisher->isClientIdle(&transport2), true);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QTRY_COMPARE_WITH_TIMEOUT(transport2.messagesSent().size(), 2u, 2000);
++    QCOMPARE(transport1.messagesSent().size(), 1u);
++    publisher->setClientIsIdle(true, &transport1);
++    QTRY_COMPARE_WITH_TIMEOUT(transport1.messagesSent().size(), 2u, 2000);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++}
++
+ class FunctionWrapper : public QObject
+ {
+     Q_OBJECT
+@@ -1082,7 +1124,7 @@ void TestWebChannel::benchInitializeClients()
+ 
+         publisher->propertyUpdatesInitialized = false;
+         publisher->signalToPropertyMap.clear();
+-        publisher->signalHandler.clear();
++        publisher->signalHandlers.clear();
+     }
+ }
+ 
+@@ -1107,7 +1149,7 @@ void TestWebChannel::benchPropertyUpdates()
+             obj->change();
+         }
+ 
+-        channel.d_func()->publisher->clientIsIdle = true;
++        channel.d_func()->publisher->setClientIsIdle(true, m_dummyTransport);
+         channel.d_func()->publisher->sendPendingPropertyUpdates();
+     }
+ }
+diff --git a/qtwebchannel/tests/auto/webchannel/tst_webchannel.h b/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
+index eae21f4..dd4e690 100644
+--- a/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
++++ b/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
+@@ -348,6 +348,7 @@ private slots:
+     void testJsonToVariant();
+     void testInfiniteRecursion();
+     void testAsyncObject();
++    void testPropertyMultipleTransports();
+     void testDeletionDuringMethodInvocation_data();
+     void testDeletionDuringMethodInvocation();
+ 
+Submodule qtwebengine f328054d...38e0df6c (commits not present)
+Submodule qtwebsockets 65850954..63fb8da1:
+diff --git a/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp b/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
+index 2affdd5..95f1194 100644
+--- a/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
++++ b/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
+@@ -273,6 +273,7 @@ void QWebSocketDataProcessor::clear()
+     if (!m_pConverterState)
+         m_pConverterState = new QTextCodec::ConverterState(QTextCodec::ConvertInvalidToNull |
+                                                            QTextCodec::IgnoreHeader);
++    frame.clear();
+ }
+ 
+ /*!
+diff --git a/qtwebsockets/src/websockets/qwebsocketprotocol.cpp b/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
+index df87a93..d0465f1 100644
+--- a/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
++++ b/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
+@@ -210,7 +210,7 @@ void QWebSocketProtocol::mask(char *payload, quint64 size, quint32 maskingKey)
+                             quint8((maskingKey & 0x0000FF00u) >> 8),
+                             quint8((maskingKey & 0x000000FFu))
+                           };
+-    int i = 0;
++    quint64 i = 0;
+     while (size-- > 0)
+         *payload++ ^= mask[i++ % 4];
+ }
diff --git a/srcpkgs/qt5/template b/srcpkgs/qt5/template
index d3821efbe378..6dddce7f3e46 100644
--- a/srcpkgs/qt5/template
+++ b/srcpkgs/qt5/template
@@ -2,11 +2,11 @@
 #
 # revbump libqtxdg after bumping patch version
 pkgname=qt5
-version=5.15.7+20221119
+version=5.15.8
+revision=1
+build_style=meta
 # commit f8c9fb304bc3e53b3aa07f962cd74e9160decccc
 # base repo: https://invent.kde.org/qt/qt/qt5
-revision=6
-build_style=meta
 hostmakedepends="cmake clang flex perl glib-devel pkg-config
  python re2c ruby which"
 makedepends="SDL2-devel Vulkan-Headers alsa-lib-devel double-conversion-devel
@@ -29,8 +29,9 @@ homepage="https://qt.io/"
 # tarball is generated with `git archive-all qt5-$version.tar.gz`
 # to keep the size smaller qtwebengine, qtwebview, qtdocgallery, qtactiveqt and qtpim
 # can be marked with the export-ignore attribute
-distfiles="https://void.johnnynator.dev/distfiles/qt5-${version}.tar.gz"
-checksum=9d57af471c78029a362276b7c99108ea009f511bb9ba6ff6cb884f6ddd255e9f
+#distfiles="https://void.johnnynator.dev/distfiles/qt5-${version}.tar.gz"
+distfiles="https://download.qt.io/archive/qt/5.15/${version}/single/qt-everywhere-opensource-src-${version}.tar.xz"
+checksum=776a9302c336671f9406a53bd30b8e36f825742b2ec44a57c08217bff0fa86b9
 python_version=2 #unverified
 replaces="qt5-doc<5.6.0 qt5-quick1<5.6.0 qt5-quick1-devel<5.6.0 qt5-webkit<5.6.0 qt5-webkit-devel<5.6.0
  qt5-enginio<5.7.1 qt5-enginio-devel<5.7.1 qt5-plugin-gtk<5.7.1 qt5-canvas3d<5.13.0"
@@ -250,7 +251,6 @@ do_configure() {
 	# opts+=" -v"
 	opts+=" -skip qtwebengine"
 	opts+=" -skip qtwebview"
-	opts+=" -skip qtdocgallery"
 	opts+=" -skip qtpim"
 	opts+=" -skip qtsystems"
 	opts+=" -skip qtspeech"

From dbd9f4b6d9dc0e74be0e25b5d50b2e8432d42dd0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 072/115] qtav: revbump for ffmpeg4-4.4.3

---
 srcpkgs/qtav/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtav/template b/srcpkgs/qtav/template
index 34c30b2c0c78..2d00ad104355 100644
--- a/srcpkgs/qtav/template
+++ b/srcpkgs/qtav/template
@@ -1,10 +1,10 @@
 # Template file for 'qtav'
 pkgname=qtav
 version=1.13.0
-revision=1
+revision=2
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel libass-devel libopenal-devel
+makedepends="ffmpeg4-devel libass-devel libopenal-devel
  libva-glx-devel libXv-devel pulseaudio-devel
  qt5-declarative-devel qt5-svg-devel
  qt5-quickcontrols"

From 29996009d233c883d8ef56113dbecd2999a24209 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 073/115] qtox: revbump for ffmpeg-6.0

---
 srcpkgs/qtox/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qtox/template b/srcpkgs/qtox/template
index 16019d7eaec9..5cea0b11b697 100644
--- a/srcpkgs/qtox/template
+++ b/srcpkgs/qtox/template
@@ -1,7 +1,7 @@
 # Template file for 'qtox'
 pkgname=qtox
 version=1.17.6
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DUPDATE_CHECK=OFF
  -DGIT_DESCRIBE=${version}

From 3dc2d2a2e7cbe843e2845f9e4bd5be9a54a01971 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 074/115] retroarch: revbump for ffmpeg-6.0

---
 srcpkgs/retroarch/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroarch/template b/srcpkgs/retroarch/template
index 28016aa0129e..20a1415913be 100644
--- a/srcpkgs/retroarch/template
+++ b/srcpkgs/retroarch/template
@@ -1,7 +1,7 @@
 # Template file for 'retroarch'
 pkgname=retroarch
 version=1.15.0
-revision=1
+revision=2
 build_style=configure
 configure_args="--prefix=/usr --sysconfdir=/etc --enable-networking
  --enable-udev --disable-builtinflac --disable-builtinglslang

From 70d5c5a230b6dcd6bca921daeca11e396eca13d9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 075/115] scrcpy: revbump for ffmpeg-6.0

---
 srcpkgs/scrcpy/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/scrcpy/template b/srcpkgs/scrcpy/template
index ac18bc03418c..f39a7f678ab3 100644
--- a/srcpkgs/scrcpy/template
+++ b/srcpkgs/scrcpy/template
@@ -1,7 +1,7 @@
 # Template file for 'scrcpy'
 pkgname=scrcpy
 version=2.1.1
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcompile_server=false
  -Dprebuilt_server=/usr/share/scrcpy/scrcpy-server-v${version}"

From 0fbbf348827f142cc969a3849c3e1d189a59d1bf Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 076/115] spek-alternative: revbump for ffmpeg4-4.4.3

---
 srcpkgs/spek-alternative/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/spek-alternative/template b/srcpkgs/spek-alternative/template
index d65086b8f008..05246f1b8d0c 100644
--- a/srcpkgs/spek-alternative/template
+++ b/srcpkgs/spek-alternative/template
@@ -1,11 +1,11 @@
 # Template file for 'spek-alternative'
 pkgname=spek-alternative
 version=0.8.2.3
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake gettext-devel intltool libtool pkg-config wxWidgets-common"
-makedepends="ffmpeg-devel wxWidgets-gtk3-devel"
-depends="ffmpeg"
+makedepends="ffmpeg4-devel wxWidgets-gtk3-devel"
+depends="ffmpeg4"
 short_desc="Acoustic spectrum analyser"
 maintainer="Kartik Singh <kartik.ynwa@gmail.com>"
 license="GPL-3.0-or-later"

From 6d3ad5b691068c925d763b10f8816db4a1179604 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 077/115] ssr: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ssr/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/ssr/template b/srcpkgs/ssr/template
index b055b9ec0774..3448ca110eb0 100644
--- a/srcpkgs/ssr/template
+++ b/srcpkgs/ssr/template
@@ -1,11 +1,11 @@
 # Template file for 'ssr'
 pkgname=ssr
 version=0.4.4
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_QT5=ON"
 hostmakedepends="pkg-config"
-makedepends="alsa-lib-devel ffmpeg-devel glu-devel jack-devel pulseaudio-devel
+makedepends="alsa-lib-devel ffmpeg4-devel glu-devel jack-devel pulseaudio-devel
  qt5-tools-devel qt5-x11extras-devel libXinerama-devel v4l-utils-devel"
 depends="desktop-file-utils hicolor-icon-theme"
 short_desc="Simple Screen Recorder for programs and games"

From 2655ad167a932187e934a63c36f87d29160c8cb3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 078/115] sumo: revbump for ffmpeg-6.0

---
 srcpkgs/sumo/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/sumo/template b/srcpkgs/sumo/template
index 0f9b9ec815f5..a3fe134aa5ac 100644
--- a/srcpkgs/sumo/template
+++ b/srcpkgs/sumo/template
@@ -1,7 +1,7 @@
 # Template file for 'sumo'
 pkgname=sumo
 version=1.12.0
-revision=5
+revision=6
 build_style=cmake
 hostmakedepends="libgdal-tools pkg-config swig python3-setuptools"
 makedepends="python3-devel ffmpeg-devel fox-devel gl2ps-devel libgdal-devel

From 4f2e4c6dcae4312355885ef143952ceadee89f5f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 079/115] synfig: revbump for ffmpeg-6.0 and mlt7

---
 srcpkgs/synfig/patches/ffmpeg6.patch | 71 ++++++++++++++++++++++++++++
 srcpkgs/synfig/template              |  6 +--
 2 files changed, 74 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/synfig/patches/ffmpeg6.patch

diff --git a/srcpkgs/synfig/patches/ffmpeg6.patch b/srcpkgs/synfig/patches/ffmpeg6.patch
new file mode 100644
index 000000000000..10780b42782f
--- /dev/null
+++ b/srcpkgs/synfig/patches/ffmpeg6.patch
@@ -0,0 +1,71 @@
+--- a/src/modules/mod_libavcodec/trgt_av.cpp	2022-10-25 09:14:12.000000000 -0400
++++ b/src/modules/mod_libavcodec/trgt_av.cpp	2023-05-05 21:34:17.899194559 -0400
+@@ -38,6 +41,7 @@
+ extern "C"
+ {
+ #ifdef HAVE_LIBAVFORMAT_AVFORMAT_H
++#	include <libavcodec/avcodec.h>
+ #	include <libavformat/avformat.h>
+ #elif defined(HAVE_AVFORMAT_H)
+ #	include <avformat.h>
+@@ -155,11 +156,11 @@
+     }
+ 
+ 	bool open_video_stream() {
+-		if (avcodec_open2(video_context, NULL, NULL) < 0) {
++		if (avcodec_open2(video_context, nullptr, nullptr) < 0) {
+ 			synfig::error("Target_LibAVCodec: could not open video codec");
+ 			// seems the calling of avcodec_free_context after error will cause crash
+ 			// so just forget about this context
+-			video_context = NULL;
++			video_context = nullptr;
+ 			close();
+ 			return false;
+         }
+@@ -234,15 +235,21 @@
+ 		close();
+ 
+ 		if (!av_registered) {
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 			av_register_all();
++#endif
+ 			av_registered = true;
+ 		}
+ 
+ 		// guess format
+-		AVOutputFormat *format = av_guess_format(NULL, filename.c_str(), NULL);
++#if LIBAVCODEC_VERSION_MAJOR < 59 // FFMPEG < 5.0
++		AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#else
++		const AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#endif
+ 		if (!format) {
+ 			synfig::warning("Target_LibAVCodec: unable to guess the output format, defaulting to MPEG");
+-			format = av_guess_format("mpeg", NULL, NULL);
++			format = av_guess_format("mpeg", nullptr, nullptr);
+ 		}
+ 		if (!format) {
+ 			synfig::error("Target_LibAVCodec: unable to find 'mpeg' output format");
+@@ -254,6 +261,7 @@
+ 		context = avformat_alloc_context();
+ 		assert(context);
+ 		context->oformat = format;
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 		if (filename.size() + 1 > sizeof(context->filename)) {
+ 			synfig::error(
+ 				"Target_LibAVCodec: filename too long, max length is %d, filename is '%s'",
+@@ -263,6 +271,14 @@
+ 			return false;
+ 		}
+ 		memcpy(context->filename, filename.c_str(), filename.size() + 1);
++#else
++		context->url = av_strndup(filename.c_str(), filename.size());
++		if (!context->url) {
++			synfig::error("Target_LibAVCodec: cannot allocate space for filename");
++			close();
++			return false;
++		}
++#endif
+ 
+ 		packet = av_packet_alloc();
+ 		assert(packet);
diff --git a/srcpkgs/synfig/template b/srcpkgs/synfig/template
index 30109541ec4f..703cfd7ebac8 100644
--- a/srcpkgs/synfig/template
+++ b/srcpkgs/synfig/template
@@ -2,11 +2,11 @@
 # Should be kept in sync with 'synfigstudio' and 'ETL'
 pkgname=synfig
 version=1.4.4
-revision=3
+revision=4
 build_style=gnu-configure
 configure_args="--with-boost-libdir=${XBPS_CROSS_BASE}/usr/lib"
 hostmakedepends="boost-build ImageMagick pkg-config intltool"
-makedepends="ETL gettext-devel libxml++-devel mlt-devel libmagick-devel
+makedepends="ETL gettext-devel libxml++-devel mlt7-devel libmagick-devel
  libmng-devel boost-build boost-devel libopenexr-devel ffmpeg-devel"
 depends="ImageMagick"
 short_desc="CLI 2D vector and timeline-based animation software"
@@ -20,7 +20,7 @@ CXXFLAGS="-std=c++11 -DHAVE_LOCALE_H=1"
 
 synfig-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision}
-	 libopenexr-devel libxml++-devel mlt-devel"
+	 libopenexr-devel libxml++-devel mlt7-devel"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/bin/synfig-config

From 55ad255c553f8113788f31009fbaa93150f93ea2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 080/115] tg_owt: revbump for ffmpeg-6.0

---
 srcpkgs/tg_owt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tg_owt/template b/srcpkgs/tg_owt/template
index 97d195ddb34a..551614b24956 100644
--- a/srcpkgs/tg_owt/template
+++ b/srcpkgs/tg_owt/template
@@ -1,7 +1,7 @@
 # Template file for 'tg_owt'
 pkgname=tg_owt
 version=0.0.0.20230107
-revision=1
+revision=2
 _commit=5098730b9eb6173f0b52068fe2555b7c1015123a
 _libyuv_commit=00950840d1c9bcbb3eb6ebc5aac5793e71166c8b
 _abseil_commit=8c0b94e793a66495e0b1f34a5eb26bd7dc672db0

From ae0566366392f00fc236f4b5da4f68b771222893 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 081/115] timg: revbump for ffmpeg-6.0

---
 srcpkgs/timg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/timg/template b/srcpkgs/timg/template
index 2a2ab763d2fd..8fb4327535ef 100644
--- a/srcpkgs/timg/template
+++ b/srcpkgs/timg/template
@@ -1,7 +1,7 @@
 # Template file for 'timg'
 pkgname=timg
 version=1.4.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_OPENSLIDE_SUPPORT=off -Wno-dev"
 hostmakedepends="pkg-config git"

From 9373c987ce220519c9aeb17ad0d8c4b3d0b86611 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 082/115] tvheadend: revbump for ffmpeg4-4.4.3

---
 srcpkgs/tvheadend/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/tvheadend/template b/srcpkgs/tvheadend/template
index e6b16d7ccf3b..46b52b6fb7f9 100644
--- a/srcpkgs/tvheadend/template
+++ b/srcpkgs/tvheadend/template
@@ -1,14 +1,14 @@
 # Template file for 'tvheadend'
 pkgname=tvheadend
 version=4.2.8
-revision=6
+revision=7
 build_style=gnu-configure
 configure_args="--enable-dvbscan --disable-ffmpeg_static
 --disable-hdhomerun_static --disable-bintray_cache --disable-libx264_static
 --disable-libx265_static --disable-libvpx_static --disable-libtheora_static
 --disable-libvorbis_static --disable-libfdkaac_static"
 hostmakedepends="gettext pkg-config python git which"
-makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg-devel"
+makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg4-devel"
 short_desc="TV streaming server"
 maintainer="lemmi <lemmi@nerd2nerd.org>"
 license="GPL-3.0-only"

From cbd0364381c4e2d13f776cdd7d3af97e2c506544 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 083/115] unpaper: update to 7.0.0.

---
 srcpkgs/unpaper/template | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/srcpkgs/unpaper/template b/srcpkgs/unpaper/template
index 38ed47a58401..1ff910e722af 100644
--- a/srcpkgs/unpaper/template
+++ b/srcpkgs/unpaper/template
@@ -1,13 +1,13 @@
 # Template file for 'unpaper'
 pkgname=unpaper
-version=6.1
-revision=3
-build_style=gnu-configure
+version=7.0.0
+revision=1
+build_style=meson
+hostmakedepends="pkg-config meson libxslt"
+makedepends="ffmpeg-devel python3-Sphinx"
+short_desc="Post-processing tool for scanned sheets of paper"
 maintainer="Orphaned <orphan@voidlinux.org>"
-hostmakedepends="pkg-config libxslt"
-makedepends="ffmpeg-devel"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://www.flameeyes.eu/projects/unpaper"
-short_desc="A post-processing tool for scanned sheets of paper"
 distfiles="https://www.flameeyes.eu/files/${pkgname}-${version}.tar.xz"
-checksum=237c84f5da544b3f7709827f9f12c37c346cdf029b1128fb4633f9bafa5cb930
+checksum=2575fbbf26c22719d1cb882b59602c9900c7f747118ac130883f63419be46a80

From 4274fa0f576183c6705a719d4b9066de40109eb6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 084/115] vba-m: revbump for ffmpeg-6.0

---
 srcpkgs/vba-m/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vba-m/template b/srcpkgs/vba-m/template
index 809343f465f2..e3f7785de0d2 100644
--- a/srcpkgs/vba-m/template
+++ b/srcpkgs/vba-m/template
@@ -2,7 +2,7 @@
 pkgname=vba-m
 reverts=1292_2
 version=2.1.6
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_GTK=TRUE -DENABLE_FFMPEG=TRUE -DENABLE_LINK=TRUE -DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="gettext pkg-config unzip zip yasm wxWidgets-gtk3-devel"

From 75a6a6f8a03bb08f9986ab07ec6f5674ce5be762 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 085/115] vice: revbump for ffmpeg4-4.4.3

---
 srcpkgs/vice/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/vice/template b/srcpkgs/vice/template
index fe9d33a81194..4beab2c5f9eb 100644
--- a/srcpkgs/vice/template
+++ b/srcpkgs/vice/template
@@ -1,7 +1,7 @@
 # Template file for 'vice'
 pkgname=vice
 version=3.7.1
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="
 	$(vopt_enable sdl2 sdlui2)
@@ -26,7 +26,7 @@ makedepends="
 	$(vopt_if gtk3 gtk+3-devel)
 	$(vopt_if gtk3 pulseaudio-devel)
 	$(vopt_if gtk3 pango-devel)
-	$(vopt_if ffmpeg ffmpeg-devel)"
+	$(vopt_if ffmpeg ffmpeg4-devel)"
 short_desc="Emulator for C64, C128, CBM-II, PET, VIC20, Plus4 and C16"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"

From 3738a72869ff678761811c9c46165fde0fa7795b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 086/115] waypipe: revbump for ffmpeg-6.0

---
 srcpkgs/waypipe/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waypipe/template b/srcpkgs/waypipe/template
index 5c4161900060..1a46fe27f7d8 100644
--- a/srcpkgs/waypipe/template
+++ b/srcpkgs/waypipe/template
@@ -1,7 +1,7 @@
 # Template file for 'waypipe'
 pkgname=waypipe
 version=0.8.4
-revision=1
+revision=2
 build_style=meson
 # lto is off because it causes linking errors in armv6l and armv7l (due to NEON)
 configure_args="-Dwerror=false -Dwith_dmabuf=enabled -Dwith_lz4=enabled

From f348587896fe6e81f037c86713fe2b9fd24327f6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 087/115] wf-recorder: revbump for ffmpeg-6.0

---
 srcpkgs/wf-recorder/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/wf-recorder/template b/srcpkgs/wf-recorder/template
index e278eb001600..5d014a5f28af 100644
--- a/srcpkgs/wf-recorder/template
+++ b/srcpkgs/wf-recorder/template
@@ -1,7 +1,7 @@
 # Template file for 'wf-recorder'
 pkgname=wf-recorder
 version=0.3.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config scdoc wayland-devel"
 makedepends="wayland-protocols wayland-devel ffmpeg-devel x264-devel

From a1cad74024d7e7adf6a5f3c13c430d08a15df29a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 088/115] xpra: revbump for ffmpeg-6.0

---
 srcpkgs/xpra/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xpra/template b/srcpkgs/xpra/template
index 0a63fdb6c743..d5acc1981c5f 100644
--- a/srcpkgs/xpra/template
+++ b/srcpkgs/xpra/template
@@ -1,7 +1,7 @@
 # Template file for 'xpra'
 pkgname=xpra
 version=4.4.6
-revision=1
+revision=2
 build_style=python3-module
 make_build_args="--without-cuda_kernels --without-cuda_rebuild"
 make_install_args="$(vopt_with docs) ${make_build_args}"

From fdf22f47d38a3e904a19d5da3069da6f881d9c7f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:07:40 -0400
Subject: [PATCH 089/115] nv-codec-headers: update to 12.0.16.0

---
 srcpkgs/nv-codec-headers/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/nv-codec-headers/template b/srcpkgs/nv-codec-headers/template
index 3d422a61e489..251e057f826f 100644
--- a/srcpkgs/nv-codec-headers/template
+++ b/srcpkgs/nv-codec-headers/template
@@ -1,6 +1,6 @@
 # Template file for 'nv-codec-headers'
 pkgname=nv-codec-headers
-version=11.1.5.1
+version=12.0.16.0
 revision=1
 build_style=gnu-makefile
 short_desc="FFmpeg version of headers required to interface with Nvidias codec APIs"
@@ -8,7 +8,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="MIT"
 homepage="http://git.videolan.org/?p=ffmpeg/nv-codec-headers.git"
 distfiles="https://github.com/FFmpeg/nv-codec-headers/archive/n${version}.tar.gz"
-checksum=d095fbd56aa93772471a323be0ebe65504a0f43f06c76a30b6d25da77b06ae9c
+checksum=2a1533b65f55f9da52956faf0627ed3b74868ac0c7f269990edd21369113b48f
 
 post_install() {
 	sed -n '4,25p' include/ffnvcodec/nvEncodeAPI.h > LICENSE

From a66b0022dc9da665a48607cb63ac2a82d299c00f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:08:40 -0400
Subject: [PATCH 090/115] openimagedenoise: revbump for ffmpeg-6.0

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index db5ccdb055cc..cb90045afb63 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,7 +1,7 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
 version=1.4.3
-revision=1
+revision=2
 archs="x86_64*"
 build_style=cmake
 hostmakedepends="ispc python3"

From cb9fa315626aaa70e36117b24c8ced2ecf67adc8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:31:45 -0400
Subject: [PATCH 091/115] shotcut: revbump for ffmpeg-6.0

---
 srcpkgs/shotcut/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/shotcut/template b/srcpkgs/shotcut/template
index 7d2af7b0470b..c416c906ff73 100644
--- a/srcpkgs/shotcut/template
+++ b/srcpkgs/shotcut/template
@@ -1,7 +1,7 @@
 # Template file for 'shotcut'
 pkgname=shotcut
 version=23.05.14
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSHOTCUT_VERSION=${version}"
 hostmakedepends="pkg-config qt6-tools-devel"

From 5634a326993fc251325989cb56c0d2092c9133d5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:30 -0400
Subject: [PATCH 092/115] shiboken2: revbump for qt5-5.15.8

---
 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch | 1 +
 srcpkgs/shiboken2/template                                 | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
 create mode 120000 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
new file mode 120000
index 000000000000..efcf3249bd88
--- /dev/null
+++ b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1 @@
+../../python3-pyside2/patches/importlib-machinery-bypass.patch
\ No newline at end of file
diff --git a/srcpkgs/shiboken2/template b/srcpkgs/shiboken2/template
index 084ecc3ba1e1..2a21998997eb 100644
--- a/srcpkgs/shiboken2/template
+++ b/srcpkgs/shiboken2/template
@@ -1,7 +1,7 @@
 # Template file for 'shiboken2'
 pkgname=shiboken2
 version=5.15.7
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/shiboken2"
 build_style=cmake

From d73c4d9da53b71a79865a2561d373d1864f7415d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:53 -0400
Subject: [PATCH 093/115] python3-pyside2: update to 5.15.8

---
 .../patches/importlib-machinery-bypass.patch      | 15 +++++++++++++++
 srcpkgs/python3-pyside2/template                  |  9 +++++----
 2 files changed, 20 insertions(+), 4 deletions(-)
 create mode 100644 srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
new file mode 100644
index 000000000000..64c429584776
--- /dev/null
+++ b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1,15 @@
+Using this prevents an error around line 220 below it.
+"AttributeError: module 'importlib' has no attribute 'machinery'"
+The old backup logic is in place and compiles without issues.
+--- a/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:09:34.688912402 -0400
++++ b/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:10:03.395529582 -0400
+@@ -170,9 +170,6 @@
+
+     # 'zipstring_sequence' comes from signature.cpp
+     zipbytes = base64.b64decode(''.join(zipstring_sequence))
+-    if sys.version_info[0] >= 3:
+-        vzip = zipfile.ZipFile(io.BytesIO(zipbytes))
+-        return sys.meta_path, EmbeddableZipImporter(vzip)
+
+     # Old version for Python 2.7, only.
+     import os
diff --git a/srcpkgs/python3-pyside2/template b/srcpkgs/python3-pyside2/template
index 50e6ff260d3b..b50e62bd215d 100644
--- a/srcpkgs/python3-pyside2/template
+++ b/srcpkgs/python3-pyside2/template
@@ -1,11 +1,12 @@
 # Template file for 'python3-pyside2'
 pkgname=python3-pyside2
-version=5.15.5
-revision=2
+version=5.15.8
+revision=1
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/pyside2"
 build_style=cmake
-configure_args="-DPYTHON_EXECUTABLE=/usr/bin/python"
+configure_args="-DPYTHON_EXECUTABLE=/usr/bin/python -DCMAKE_BUILD_TYPE=None
+ -DBUILD_TESTS=OFF"
 hostmakedepends="cmake python3 shiboken2"
 makedepends="python3-devel libshiboken2-devel qt5-devel
  qt5-multimedia-devel qt5-tools-devel qt5-plugin-mysql qt5-plugin-odbc
@@ -23,7 +24,7 @@ maintainer="yopito <pierre.bourgin@free.fr>"
 license="LGPL-3.0-or-later"
 homepage="https://wiki.qt.io/Qt_for_Python"
 distfiles="https://download.qt.io/official_releases/QtForPython/pyside2/PySide2-${version}-src/${_pkgname}.tar.xz"
-checksum=3920a4fb353300260c9bc46ff70f1fb975c5e7efa22e9d51222588928ce19b33
+checksum=23436302c8deb5b4cbc769b205d09604e38ba83b40708efccb7bd8c9af6f6b5d
 
 build_options="webengine"
 desc_option_webengine="Build Qt5 WebEngine bindings"

From 8190b1e5ad10989fb16e3000891054dffdebd18a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:35 -0400
Subject: [PATCH 094/115] konqueror: revbump for ffmpeg-6.0

---
 srcpkgs/konqueror/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/konqueror/template b/srcpkgs/konqueror/template
index d8d0e73a78ab..c5bdba601d3c 100644
--- a/srcpkgs/konqueror/template
+++ b/srcpkgs/konqueror/template
@@ -1,11 +1,11 @@
 # Template file for 'konqueror'
 pkgname=konqueror
 version=23.04.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DDESKTOPTOJSON_EXECUTABLE=/usr/bin/desktoptojson"
 hostmakedepends="extra-cmake-modules python3 qt5-host-tools qt5-qmake kdoctools
-kcoreaddons kconfig gettext"
+ kcoreaddons kconfig gettext"
 makedepends="qt5-devel qt5-webengine-devel qt5-declarative-devel
  qt5-webchannel-devel qt5-location-devel kcmutils-devel kdelibs4support-devel
  karchive-devel khtml-devel kdesu-devel kactivities5-devel"

From e556bf5e78b61296ba4f546057053370b53f3123 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:58 -0400
Subject: [PATCH 095/115] qt5-speech: revbump for qt5-5.15.8

---
 srcpkgs/qt5-speech/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-speech/template b/srcpkgs/qt5-speech/template
index 3ecd10d50650..2d7d4d4d2453 100644
--- a/srcpkgs/qt5-speech/template
+++ b/srcpkgs/qt5-speech/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-speech'
 pkgname=qt5-speech
 version=5.15.7
-revision=2
+revision=3
 _commit=d32f4a479d38a11f547598004b975f4356424a16
 build_style=qmake
 configure_args="-- -flite -flite-alsa -speechd"

From ba093c87465ab800ec38a976de691ad7df2c8cc1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 18:38:50 -0400
Subject: [PATCH 096/115] qt5-styleplugins: revbump for qt5-5.15.8

---
 srcpkgs/qt5-styleplugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-styleplugins/template b/srcpkgs/qt5-styleplugins/template
index 96ed97d12cd2..30d93660a2a4 100644
--- a/srcpkgs/qt5-styleplugins/template
+++ b/srcpkgs/qt5-styleplugins/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-styleplugins'
 pkgname=qt5-styleplugins
 version=5.0.0
-revision=20
+revision=21
 _gitrev=335dbece103e2cbf6c7cf819ab6672c2956b17b3
 build_style=qmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From b9b203095de8403373ed21c779bfb8d863f20f8f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 7 May 2023 20:14:14 -0400
Subject: [PATCH 097/115] mlt7: revbump for ffmpeg-6.0

---
 srcpkgs/gst-libav/template | 2 +-
 srcpkgs/mlt7/template      | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index 04c39bff1489..8c72fc3e97ee 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.22.2
-revision=2
+revision=1
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"
diff --git a/srcpkgs/mlt7/template b/srcpkgs/mlt7/template
index 9fb7f60d692e..cca0eb68cfc3 100644
--- a/srcpkgs/mlt7/template
+++ b/srcpkgs/mlt7/template
@@ -1,7 +1,7 @@
 # Template file for 'mlt7'
 pkgname=mlt7
 version=7.14.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSWIG_PYTHON=ON"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which

From cd7598a3a6ebe0fdfbacd055d550d8b07426ec39 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 7 May 2023 20:15:03 -0400
Subject: [PATCH 098/115] qt6-webengine: revbump for ffmpeg-6.0

---
 srcpkgs/qt6-webengine/template | 1 +
 1 file changed, 1 insertion(+)

diff --git a/srcpkgs/qt6-webengine/template b/srcpkgs/qt6-webengine/template
index f948dc919a15..43778b568d3f 100644
--- a/srcpkgs/qt6-webengine/template
+++ b/srcpkgs/qt6-webengine/template
@@ -145,6 +145,7 @@ pre_install() {
 }
 
 post_install() {
+	vlicense LICENSES/BSD-3-Clause.txt
 	local _file
 	find "${DESTDIR}"/usr/lib/qt6/examples \
 		-path '*/lib/qt6/**/lib/qt6/*' -type f |

From 33d68e803ad70eef605bdef06aa590b6a6cccc53 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 11 May 2023 14:05:14 -0400
Subject: [PATCH 099/115] openmw: revbump for ffmpeg-6.0

---
 srcpkgs/openmw/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openmw/template b/srcpkgs/openmw/template
index e3771c7aaf1a..3cbf20b06577 100644
--- a/srcpkgs/openmw/template
+++ b/srcpkgs/openmw/template
@@ -1,7 +1,7 @@
 # Template file for 'openmw'
 pkgname=openmw
 version=0.47.0
-revision=5
+revision=6
 build_style=cmake
 _recast_commit=e75adf86f91eb3082220085e42dda62679f9a3ea
 _bullet_tag=3.17

From eb635a9ec09907f0dd4ac195906c3651a517efdb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 21 May 2023 12:44:11 -0400
Subject: [PATCH 100/115] electron24: revbump for ffmpeg-6.0

---
 srcpkgs/electron24/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron24/template b/srcpkgs/electron24/template
index bdaa56adc8a6..ff3d5e3ef381 100644
--- a/srcpkgs/electron24/template
+++ b/srcpkgs/electron24/template
@@ -1,7 +1,7 @@
 # Template file for 'electron24'
 pkgname=electron24
 version=24.3.0
-revision=1
+revision=2
 _nodever=18.14.0
 _chromiumver=112.0.5615.165
 archs="x86_64* aarch64*"

From f36c472b7ba0ff6453c50c8d31fba915b7fd86ae Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Jun 2023 08:20:22 -0400
Subject: [PATCH 101/115] gtk4: revbump for ffmpeg-6.0

---
 srcpkgs/gtk4/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gtk4/template b/srcpkgs/gtk4/template
index b318b7bae1dd..e3bde4a50e54 100644
--- a/srcpkgs/gtk4/template
+++ b/srcpkgs/gtk4/template
@@ -1,7 +1,7 @@
 # Template file for 'gtk4'
 pkgname=gtk4
 version=4.10.4
-revision=1
+revision=2
 build_style=meson
 build_helper="gir"
 configure_args="-Dman-pages=true -Dgtk_doc=true -Dbuild-tests=false

From 5db75e6442b5692580518ac7c57003aa564e50a0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:25:50 -0400
Subject: [PATCH 102/115] electron19: revbump for ffmpeg-6.0

---
 srcpkgs/electron19/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron19/template b/srcpkgs/electron19/template
index 32ce301e730c..ab7f308f5e8a 100644
--- a/srcpkgs/electron19/template
+++ b/srcpkgs/electron19/template
@@ -1,7 +1,7 @@
 # Template file for 'electron19'
 pkgname=electron19
 version=19.0.8
-revision=3
+revision=4
 _nodever=16.14.2
 _chromiumver=102.0.5005.125
 archs="x86_64* aarch64* ppc64le*"

From 200583294d44d515b8e46af34882032c5ac971a2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:28:26 -0400
Subject: [PATCH 103/115] siril: revbump for ffmpeg-6.0

---
 srcpkgs/siril/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/siril/template b/srcpkgs/siril/template
index 84332f79d060..62750dd24754 100644
--- a/srcpkgs/siril/template
+++ b/srcpkgs/siril/template
@@ -1,7 +1,7 @@
 # Template file for 'siril'
 pkgname=siril
 version=0.9.12
-revision=10
+revision=11
 build_style=gnu-configure
 hostmakedepends="pkg-config intltool autoconf automake gettext-devel"
 makedepends="fftw-devel libconfig-devel libopencv-devel libffms2-devel

From 31637a1b89c20edc28ac1d3425d0407f379182b7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 10 Jun 2023 00:40:39 -0400
Subject: [PATCH 104/115] freecad: revbump for qt5-webengine-5.15.13

---
 srcpkgs/freecad/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/freecad/template b/srcpkgs/freecad/template
index a4a3f5f76b29..8608d1670c87 100644
--- a/srcpkgs/freecad/template
+++ b/srcpkgs/freecad/template
@@ -1,7 +1,7 @@
 # Template file for 'freecad'
 pkgname=freecad
 version=0.20.2
-revision=5
+revision=6
 build_style=cmake
 
 _inst_prefix=/usr/lib/${pkgname}

From 621b6cdcc3db381e74173b3cab05fb781d0cabe6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 10 Jun 2023 00:57:09 -0400
Subject: [PATCH 105/115] qt6-multimedia: revbump for ffmpeg-6.0

---
 srcpkgs/qt6-multimedia/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-multimedia/template b/srcpkgs/qt6-multimedia/template
index a6832fdd69bf..c9ffac914ab8 100644
--- a/srcpkgs/qt6-multimedia/template
+++ b/srcpkgs/qt6-multimedia/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-multimedia'
 pkgname=qt6-multimedia
 version=6.5.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DQT_FEATURE_gstreamer=ON"
 hostmakedepends="perl qt6-declarative-host-tools pkg-config qt6-shadertools"

From d2665e486da8f0a0cb099149d183c9f6d1dc18d8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 22 Jun 2023 10:25:02 -0400
Subject: [PATCH 106/115] kdenlive: revbump for ffmpeg-6.0

---
 srcpkgs/kdenlive/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kdenlive/template b/srcpkgs/kdenlive/template
index 89c0dcfb8577..75495b3a3586 100644
--- a/srcpkgs/kdenlive/template
+++ b/srcpkgs/kdenlive/template
@@ -1,7 +1,7 @@
 # Template file for 'kdenlive'
 pkgname=kdenlive
 version=23.04.2
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="
  extra-cmake-modules kconfig kcoreaddons kdoctools pkg-config python3

From c8bf752f81843ed6a6493146322f30aa46a98b47 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Jul 2023 09:18:23 -0400
Subject: [PATCH 107/115] gmic: revbump for opencv-4.7.0

---
 srcpkgs/gmic/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gmic/template b/srcpkgs/gmic/template
index 0bb4034d5cc8..808953e9b543 100644
--- a/srcpkgs/gmic/template
+++ b/srcpkgs/gmic/template
@@ -1,7 +1,7 @@
 # Template file for 'gmic'
 pkgname=gmic
 version=3.1.6
-revision=4
+revision=5
 _zart_hash=34ebf6cce0bafb98abe57cec83c4a02cd1abeca0
 create_wrksrc=yes
 build_wrksrc="src"

From 69d2ca950cdc8ff9aa2aeec731391468b8bd4e19 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Jul 2023 09:29:52 -0400
Subject: [PATCH 108/115] synfigstudio: revbump for synfig mlt7

---
 srcpkgs/synfigstudio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/synfigstudio/template b/srcpkgs/synfigstudio/template
index af1c5a296ef0..09e442da9a68 100644
--- a/srcpkgs/synfigstudio/template
+++ b/srcpkgs/synfigstudio/template
@@ -2,7 +2,7 @@
 # Should be kept in sync with 'synfig' and 'ETL'
 pkgname=synfigstudio
 version=1.4.4
-revision=3
+revision=4
 build_style=gnu-configure
 configure_args="--disable-update-mimedb"
 hostmakedepends="pkg-config intltool gettext synfig"

From aef7c4b9567c8855bb515e791ff12b629edbeca9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Jul 2023 10:19:17 -0400
Subject: [PATCH 109/115] openimageio: revbump for ffmpeg6.0

---
 srcpkgs/openimageio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimageio/template b/srcpkgs/openimageio/template
index 0e9e22e9685d..e74a8dbd683e 100644
--- a/srcpkgs/openimageio/template
+++ b/srcpkgs/openimageio/template
@@ -1,7 +1,7 @@
 # Template file for 'openimageio'
 pkgname=openimageio
 version=2.4.9.0
-revision=5
+revision=6
 build_style=cmake
 build_helper=qemu
 configure_args="-DUSE_QT=0 -DUSE_PYTHON=0 -DOIIO_BUILD_TESTS=0

From 0743c37f8d42755f07e818c3b115cbb0d8ffd469 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Jul 2023 11:17:37 -0400
Subject: [PATCH 110/115] DELETE: intel_packages

---
 common/shlibs                                 |   2 +
 srcpkgs/intel-gmmlib/template                 |   6 +-
 ...mmon-Enable-MMC-in-free-kernel-build.patch | 125 ++++++++++++++++++
 srcpkgs/intel-media-driver/template           |   6 +-
 srcpkgs/intel-media-sdk/patches/musl.patch    |  14 ++
 srcpkgs/intel-media-sdk/template              |  37 ++++++
 srcpkgs/intel-media-sdk/update                |   1 +
 srcpkgs/onevpl-devel                          |   1 +
 srcpkgs/onevpl-intel-gpu-devel                |   1 +
 srcpkgs/onevpl-intel-gpu/template             |  27 ++++
 srcpkgs/onevpl/template                       |  34 +++++
 11 files changed, 248 insertions(+), 6 deletions(-)
 create mode 100644 srcpkgs/intel-media-driver/patches/0001-Media-Common-Enable-MMC-in-free-kernel-build.patch
 create mode 100644 srcpkgs/intel-media-sdk/patches/musl.patch
 create mode 100644 srcpkgs/intel-media-sdk/template
 create mode 100644 srcpkgs/intel-media-sdk/update
 create mode 120000 srcpkgs/onevpl-devel
 create mode 120000 srcpkgs/onevpl-intel-gpu-devel
 create mode 100644 srcpkgs/onevpl-intel-gpu/template
 create mode 100644 srcpkgs/onevpl/template

diff --git a/common/shlibs b/common/shlibs
index d4dd04a6ab3b..69ed72927826 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4327,5 +4327,7 @@ libgsoapssl++-2.8.124.so gsoap-2.8.124_1
 libjxl.so.0.8 libjxl-0.8.2_1
 libjxl_dec.so.0.8 libjxl-0.8.2_1
 libjxl_threads.so.0.8 libjxl-0.8.2_1
+libmfx.so.1 libmfx-22.6.4_1
+libvpl.so.2 onevpl-2023.1.2_1
 libtext-engine-0.1.so.0 text-engine-0.1.1_1
 libvmaf.so.1 vmaf-2.3.1_1
diff --git a/srcpkgs/intel-gmmlib/template b/srcpkgs/intel-gmmlib/template
index 04e407b1de4d..2605226152e5 100644
--- a/srcpkgs/intel-gmmlib/template
+++ b/srcpkgs/intel-gmmlib/template
@@ -1,6 +1,6 @@
 # Template file for 'intel-gmmlib'
 pkgname=intel-gmmlib
-version=22.2.0
+version=22.3.3
 revision=1
 archs="i686* x86_64*"
 build_style=cmake
@@ -14,11 +14,11 @@ build_style=cmake
 # compilers flag in use.
 configure_args="-Wno-dev"
 short_desc="Intel Graphics Memory Management Library"
-maintainer="Orphaned <orphan@voidlinux.org>"
+maintainer="Stefano Ragni <st3r4g@protonmail.com>"
 license="MIT"
 homepage="https://github.com/intel/gmmlib"
 distfiles="https://github.com/intel/gmmlib/archive/intel-gmmlib-${version}.tar.gz"
-checksum=0b2253894c6fc8455b6d7c5e87e6504a76d6f60ea192e1445c2f93164bf529c0
+checksum=86651bd2803c9f0afd82471bec784e65d2b418dee315a053d22215eb2a679be7
 
 lib32disabled=yes
 
diff --git a/srcpkgs/intel-media-driver/patches/0001-Media-Common-Enable-MMC-in-free-kernel-build.patch b/srcpkgs/intel-media-driver/patches/0001-Media-Common-Enable-MMC-in-free-kernel-build.patch
new file mode 100644
index 000000000000..525fb688722c
--- /dev/null
+++ b/srcpkgs/intel-media-driver/patches/0001-Media-Common-Enable-MMC-in-free-kernel-build.patch
@@ -0,0 +1,125 @@
+From e68feab7db036838d9521ba3b9f00717c37c024c Mon Sep 17 00:00:00 2001
+From: JayYang <jay.yang@intel.com>
+Date: Tue, 21 Mar 2023 17:17:55 +0800
+Subject: [PATCH] [Media Common] Enable MMC in free kernel build
+
+Add mmc build definition in free kernel build
+---
+ media_driver/agnostic/gen9/codec/hal/media_srcs.cmake          | 2 +-
+ media_driver/cmake/linux/media_feature_flags_linux.cmake       | 3 +--
+ .../media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp        | 2 +-
+ .../media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp        | 2 +-
+ .../media_interfaces_m9_glk/media_interfaces_g9_glk.cpp        | 2 +-
+ .../media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp        | 2 +-
+ .../media_interfaces_m9_skl/media_interfaces_g9_skl.cpp        | 2 +-
+ 7 files changed, 7 insertions(+), 8 deletions(-)
+
+diff --git a/media_driver/agnostic/gen9/codec/hal/media_srcs.cmake b/media_driver/agnostic/gen9/codec/hal/media_srcs.cmake
+index 8bb36bafe..78902a22d 100644
+--- a/media_driver/agnostic/gen9/codec/hal/media_srcs.cmake
++++ b/media_driver/agnostic/gen9/codec/hal/media_srcs.cmake
+@@ -27,7 +27,7 @@ set(TMP_1_HEADERS_
+     ${CMAKE_CURRENT_LIST_DIR}/codechal_hw_g9_X.h
+ )
+ 
+-if(${MMC_Supported} STREQUAL "yes")
++if(${MMC_Supported} STREQUAL "yes" AND ENABLE_NONFREE_KERNELS AND ENABLE_KERNELS)
+     set(TMP_1_SOURCES_
+         ${TMP_1_SOURCES_}
+         ${CMAKE_CURRENT_LIST_DIR}/codechal_memdecomp_g9.cpp
+diff --git a/media_driver/cmake/linux/media_feature_flags_linux.cmake b/media_driver/cmake/linux/media_feature_flags_linux.cmake
+index de0ca853f..8121ea60c 100644
+--- a/media_driver/cmake/linux/media_feature_flags_linux.cmake
++++ b/media_driver/cmake/linux/media_feature_flags_linux.cmake
+@@ -35,7 +35,6 @@ if(NOT ENABLE_KERNELS OR NOT ENABLE_NONFREE_KERNELS)
+     bs_set_if_undefined(HEVC_Encode_VME_Supported "no")
+     bs_set_if_undefined(MPEG2_Encode_VME_Supported "no")
+     bs_set_if_undefined(CMRT_HEVC_ENC_FEI_Supported "no")
+-    bs_set_if_undefined(MMC_Supported "no")
+     bs_set_if_undefined(VC1_Decode_Supported "no")
+     bs_set_if_undefined(Decode_Processing_Supported "no")
+     bs_set_if_undefined(Kernel_Auto_Denoise_Supported "no")
+@@ -46,7 +45,6 @@ else()
+     bs_set_if_undefined(HEVC_Encode_VME_Supported "${Encode_VME_Supported}")
+     bs_set_if_undefined(MPEG2_Encode_VME_Supported "${Encode_VME_Supported}")
+     bs_set_if_undefined(CMRT_HEVC_ENC_FEI_Supported "yes")
+-    bs_set_if_undefined(MMC_Supported "yes")
+     bs_set_if_undefined(VC1_Decode_Supported "yes")
+     bs_set_if_undefined(Decode_Processing_Supported "yes")
+     bs_set_if_undefined(Kernel_Auto_Denoise_Supported "yes")
+@@ -64,6 +62,7 @@ bs_set_if_undefined(VP9_Decode_Supported "yes")
+ bs_set_if_undefined(VP_SFC_Supported "yes")
+ bs_set_if_undefined(Common_Encode_Supported "yes")
+ bs_set_if_undefined(Media_Scalability_Supported "yes")
++bs_set_if_undefined(MMC_Supported "yes")
+ 
+ # features controlled by global flag Encode_VDEnc_Supported
+ bs_set_if_undefined(AVC_Encode_VDEnc_Supported "${Encode_VDEnc_Supported}")
+diff --git a/media_driver/media_interface/media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp b/media_driver/media_interface/media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp
+index 3f306ee2a..8e4c0f532 100644
+--- a/media_driver/media_interface/media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp
+@@ -135,7 +135,7 @@ MOS_STATUS MhwInterfacesG9Bxt::Initialize(
+ 
+     return MOS_STATUS_SUCCESS;
+ }
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool bxtRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Bxt>((uint32_t)IGFX_BROXTON);
+diff --git a/media_driver/media_interface/media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp b/media_driver/media_interface/media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp
+index b8fa1eec0..84e0fad1d 100644
+--- a/media_driver/media_interface/media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp
+@@ -44,7 +44,7 @@ static bool cflRegisteredMhw =
+     MediaFactory<uint32_t, MhwInterfaces>::
+     Register<MhwInterfacesG9Kbl>((uint32_t)IGFX_COFFEELAKE);
+ 
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool cflRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Kbl>((uint32_t)IGFX_COFFEELAKE);
+diff --git a/media_driver/media_interface/media_interfaces_m9_glk/media_interfaces_g9_glk.cpp b/media_driver/media_interface/media_interfaces_m9_glk/media_interfaces_g9_glk.cpp
+index de81e6091..2638cb3a6 100644
+--- a/media_driver/media_interface/media_interfaces_m9_glk/media_interfaces_g9_glk.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_glk/media_interfaces_g9_glk.cpp
+@@ -65,7 +65,7 @@ static bool glkRegisteredMhw =
+     MediaFactory<uint32_t, MhwInterfaces>::
+     Register<MhwInterfacesG9Kbl>((uint32_t)IGFX_GEMINILAKE);
+ 
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool glkRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Kbl>((uint32_t)IGFX_GEMINILAKE);
+diff --git a/media_driver/media_interface/media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp b/media_driver/media_interface/media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp
+index 99d786185..4e9c6e7f1 100644
+--- a/media_driver/media_interface/media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp
+@@ -131,7 +131,7 @@ MOS_STATUS MhwInterfacesG9Kbl::Initialize(
+ 
+     return MOS_STATUS_SUCCESS;
+ }
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool kblRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Kbl>((uint32_t)IGFX_KABYLAKE);
+diff --git a/media_driver/media_interface/media_interfaces_m9_skl/media_interfaces_g9_skl.cpp b/media_driver/media_interface/media_interfaces_m9_skl/media_interfaces_g9_skl.cpp
+index e2520edf7..4b0012c64 100644
+--- a/media_driver/media_interface/media_interfaces_m9_skl/media_interfaces_g9_skl.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_skl/media_interfaces_g9_skl.cpp
+@@ -139,7 +139,7 @@ MOS_STATUS MhwInterfacesG9Skl::Initialize(
+ 
+     return MOS_STATUS_SUCCESS;
+ }
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool sklRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Skl>((uint32_t)IGFX_SKYLAKE);
+-- 
+2.40.0
+
diff --git a/srcpkgs/intel-media-driver/template b/srcpkgs/intel-media-driver/template
index a5bab06ac947..1735b90c65ce 100644
--- a/srcpkgs/intel-media-driver/template
+++ b/srcpkgs/intel-media-driver/template
@@ -1,6 +1,6 @@
 # Template file for 'intel-media-driver'
 pkgname=intel-media-driver
-version=22.5.3
+version=22.6.4
 revision=1
 archs="x86_64*"
 build_style=cmake
@@ -8,11 +8,11 @@ configure_args="-Wno-dev -DENABLE_NONFREE_KERNELS=$(vopt_if nonfree ON OFF)"
 hostmakedepends="pkg-config"
 makedepends="libva-devel libX11-devel intel-gmmlib-devel libpciaccess-devel"
 short_desc="Intel Media Driver for VAAPI (Broadwell+)"
-maintainer="Orphaned <orphan@voidlinux.org>"
+maintainer="Stefano Ragni <st3r4g@protonmail.com>"
 license="MIT, BSD-3-Clause"
 homepage="https://github.com/intel/media-driver"
 distfiles="https://github.com/intel/media-driver/archive/intel-media-${version}.tar.gz"
-checksum=65652b365d48be3c9f0b3c561502952b92ee5fcc587520b88d0d752cf2a6a3b5
+checksum=0c04b9d74b92de41fd409b62913ce4afd799236c0b6bc1983a496990764e5d90
 
 build_options="nonfree"
 desc_option_nonfree="Enable nonfree kernels"
diff --git a/srcpkgs/intel-media-sdk/patches/musl.patch b/srcpkgs/intel-media-sdk/patches/musl.patch
new file mode 100644
index 000000000000..4ae70924b744
--- /dev/null
+++ b/srcpkgs/intel-media-sdk/patches/musl.patch
@@ -0,0 +1,14 @@
+--- a/tools/tracer/tracer/tracer_linux.cpp	2022-11-18 03:02:59.000000000 -0500
++++ b/tools/tracer/tracer/tracer_linux.cpp	2022-12-18 01:44:51.341542572 -0500
+@@ -32,6 +32,11 @@
+ #include <dlfcn.h>
+ #include "tracer.h"
+
++#ifndef RTLD_DEEPBIND
++// musl neither defines nor can use RTLD_DEEPBIND
++#define RTLD_DEEPBIND 0
++#endif
++
+ #if defined(__i386__)
+     #define LIBMFXHW "libmfxhw32.so.1"
+ #elif defined(__x86_64__)
diff --git a/srcpkgs/intel-media-sdk/template b/srcpkgs/intel-media-sdk/template
new file mode 100644
index 000000000000..7aeab51802f8
--- /dev/null
+++ b/srcpkgs/intel-media-sdk/template
@@ -0,0 +1,37 @@
+# Template file for 'intel-media-sdk'
+pkgname=intel-media-sdk
+version=22.6.4
+revision=1
+archs="x86_64*"
+build_style=cmake
+configure_args="-Wno-dev -DBUILD_SAMPLES=OFF -DBUILD_TESTS=ON"
+hostmakedepends="pkg-config"
+makedepends="libva-devel libdrm-devel intel-gmmlib-devel"
+short_desc="Intel Media SDK"
+maintainer="Stefano Ragni <st3r4g@protonmail.com>"
+license="MIT, BSD-3-Clause"
+homepage="https://github.com/Intel-Media-SDK/MediaSDK"
+distfiles="https://github.com/Intel-Media-SDK/MediaSDK/archive/refs/tags/intel-mediasdk-${version}.tar.gz"
+checksum=197acd056f81e9ff1c27068d50e8c84c2014d94c7ac17cad69d5c2d61e445fd3
+
+post_install() {
+	vlicense LICENSE
+}
+
+libmfx_package() {
+	depends="${makedepends} ${sourcepkg}-${version}_${revision}"
+	short_desc="Intel MediaSDK mfx lib"
+	pkg_install() {
+		vmove usr/lib/mfx
+		vmove "usr/lib/libmfx*.so*"
+	}
+}
+
+libmfx-devel_package() {
+	depends="${makedepends} ${sourcepkg}-${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+	}
+}
diff --git a/srcpkgs/intel-media-sdk/update b/srcpkgs/intel-media-sdk/update
new file mode 100644
index 000000000000..434a2bc67f7a
--- /dev/null
+++ b/srcpkgs/intel-media-sdk/update
@@ -0,0 +1 @@
+pkgname=intel-media
diff --git a/srcpkgs/onevpl-devel b/srcpkgs/onevpl-devel
new file mode 120000
index 000000000000..e2306500b487
--- /dev/null
+++ b/srcpkgs/onevpl-devel
@@ -0,0 +1 @@
+onevpl
\ No newline at end of file
diff --git a/srcpkgs/onevpl-intel-gpu-devel b/srcpkgs/onevpl-intel-gpu-devel
new file mode 120000
index 000000000000..47920ceecf91
--- /dev/null
+++ b/srcpkgs/onevpl-intel-gpu-devel
@@ -0,0 +1 @@
+onevpl-intel-gpu
\ No newline at end of file
diff --git a/srcpkgs/onevpl-intel-gpu/template b/srcpkgs/onevpl-intel-gpu/template
new file mode 100644
index 000000000000..f14acb728a54
--- /dev/null
+++ b/srcpkgs/onevpl-intel-gpu/template
@@ -0,0 +1,27 @@
+# Template file for 'onevpl-intel-gpu'
+pkgname=onevpl-intel-gpu
+version=22.6.4
+revision=1
+archs="x86_64*"
+build_style=cmake
+configure_args="-Wno-dev -DCMAKE_BUILD_TYPE=Release"
+hostmakedepends="cmake pkg-config"
+makedepends="libdrm-devel libva-devel onevpl-devel"
+short_desc="Runtime implementation of oneVPL API for Intel Gen GPUs"
+maintainer="zlice <zlice555@gmail.com>"
+license="MIT"
+homepage="https://github.com/oneapi-src/oneVPL-intel-gpu"
+changelog="https://github.com/oneapi-src/oneVPL-intel-gpu/blob/main/CHANGELOG.md"
+distfiles="https://github.com/oneapi-src/oneVPL-intel-gpu/archive/refs/tags/intel-onevpl-${version}.tar.gz"
+checksum=74b0979dcb2af1b7c68edb8cbcb02d539de511090b12fac50652cbacd707c4e6
+
+post_install() {
+	vlicense LICENSE
+}
+
+onevpl-intel-gpu-devel_package() {
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/lib/pkgconfig
+	}
+}
diff --git a/srcpkgs/onevpl/template b/srcpkgs/onevpl/template
new file mode 100644
index 000000000000..85c7c2da85ce
--- /dev/null
+++ b/srcpkgs/onevpl/template
@@ -0,0 +1,34 @@
+# Template file for 'onevpl'
+pkgname=onevpl
+version=2023.1.2
+revision=1
+archs="x86_64*"
+build_style=cmake
+configure_args="
+	-DCMAKE_BUILD_TYPE=Release -Wno-dev
+	-DBUILD_PYTHON_BINDING:BOOL='OFF'
+	-DBUILD_EXAMPLES:BOOL='OFF'
+	-DBUILD_TESTS:BOOL='ON'
+	-DINSTALL_EXAMPLE_CODE:BOOL='OFF'"
+hostmakedepends="cmake libX11 python wayland-protocols pkg-config"
+makedepends="libva-devel libX11-devel wayland-devel"
+short_desc="Intel oneAPI Video Processing library"
+maintainer="zlice <zlice555@gmail.com>"
+license="MIT"
+homepage="https://www.intel.com/content/www/us/en/developer/tools/oneapi/onevpl.html"
+distfiles="https://github.com/oneapi-src/oneVPL/archive/v${version}/${pkgname}-${version}.tar.gz"
+checksum=b2261cca174ce1815f3d47c647921ab17f68267c69c1e2444ff27aab7d199cbb
+
+post_install() {
+	vlicense LICENSE
+}
+
+onevpl-devel_package() {
+	depends="${makedepends} ${sourcepkg}-${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.so"
+	}
+}

From 1506adc700a42819bf9a55b140ebff0ba9460ed5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:20:59 -0400
Subject: [PATCH 111/115] tracker-miners: revbump for ffmpeg-6.0

---
 srcpkgs/tracker-miners/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tracker-miners/template b/srcpkgs/tracker-miners/template
index a6e5aa577702..aa0f443927cd 100644
--- a/srcpkgs/tracker-miners/template
+++ b/srcpkgs/tracker-miners/template
@@ -1,7 +1,7 @@
 # Template file for 'tracker-miners'
 pkgname=tracker-miners
 version=3.5.0
-revision=4
+revision=5
 build_style=meson
 build_helper=qemu
 # missing libgrss for miner_rss

From f9275f0dbbd8d132e4d72d92c543d14cb63e9327 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:21:21 -0400
Subject: [PATCH 112/115] mpd: revbump for ffmpeg-6.0

---
 srcpkgs/mpd/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpd/template b/srcpkgs/mpd/template
index 9f058b62df2f..0dc47dd2a3e8 100644
--- a/srcpkgs/mpd/template
+++ b/srcpkgs/mpd/template
@@ -1,7 +1,7 @@
 # Template file for 'mpd'
 pkgname=mpd
 version=0.23.13
-revision=2
+revision=3
 build_style=meson
 configure_args="-Dopus=enabled -Dmikmod=enabled -Dneighbor=true
  -Dsoundcloud=enabled -Dpipe=true -Dtwolame=enabled -Dbzip2=enabled

From 1eb1dc90c919348159ef4e9009da50f5ad4c87a6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:27:17 -0400
Subject: [PATCH 113/115] lms: revbump for ffmpeg-6.0

---
 srcpkgs/lms/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/lms/template b/srcpkgs/lms/template
index d20ae1ec1fc8..691ad73a840c 100644
--- a/srcpkgs/lms/template
+++ b/srcpkgs/lms/template
@@ -1,7 +1,7 @@
 # Template file for 'lms'
 pkgname=lms
 version=3.40.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="wt-devel ffmpeg-devel boost-devel libconfig++-devel taglib-devel pam-devel libgraphicsmagick-devel gtest-devel libarchive-devel"

From 53cb98da81f3b22db6dd24be0acdecf60ba6f95b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 17 Jul 2023 15:37:44 -0400
Subject: [PATCH 114/115] mixxx: revbump for ffmpeg-6.0

---
 srcpkgs/mixxx/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mixxx/template b/srcpkgs/mixxx/template
index 4b9ea00d3fb3..a861d11a4872 100644
--- a/srcpkgs/mixxx/template
+++ b/srcpkgs/mixxx/template
@@ -1,7 +1,7 @@
 # Template file for 'mixxx'
 pkgname=mixxx
 version=2.3.3
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="extra-cmake-modules pkg-config protobuf qt5-host-tools qt5-devel"

From 885f0fe123f06bf10040b89bd836205fba6df2f2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 17 Jul 2023 15:38:14 -0400
Subject: [PATCH 115/115] telegram-desktop: revbump for ffmpeg-6.0

---
 srcpkgs/telegram-desktop/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/telegram-desktop/template b/srcpkgs/telegram-desktop/template
index 9db9f80c1a53..cc5cda531285 100644
--- a/srcpkgs/telegram-desktop/template
+++ b/srcpkgs/telegram-desktop/template
@@ -1,7 +1,7 @@
 # Template file for 'telegram-desktop'
 pkgname=telegram-desktop
 version=4.8.1
-revision=4
+revision=5
 build_style=cmake
 build_helper="qemu"
 configure_args="-DTDESKTOP_API_ID=209235

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (20 preceding siblings ...)
  2023-07-17 19:52 ` [PR PATCH] [Updated] " zlice
@ 2023-08-02 14:18 ` zlice
  2023-08-30 13:18 ` zlice
                   ` (75 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2023-08-02 14:18 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 3573 bytes --]

There is an updated pull request by zlice against master on the void-packages repository

https://github.com/zlice/void-packages ffmpeg6-split
https://github.com/void-linux/void-packages/pull/43761

ffmpeg6 split
[ci skip]


#### Testing the changes

- I tested the changes in this PR: **YES**

main testing has been vaapi in Firefox Nightly and enc/dec in Shotcut on Intel A770

#### New package

- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**

#### Local build testing

- I built this PR locally for my native architecture, **x86_64**

#### Discussion

Continuation of https://github.com/void-linux/void-packages/pull/36315

`libavresample` is deprecated, but marked as a dependency when trying to build other packages and install `ffmpeg`(6). I think the right way to handle this is make a meta package and the add to removals?


##### Commit naming / misc

~~Commits are 'dirty' right now, running with [gstreamer 1.22.1 updates](https://github.com/void-linux/void-packages/pull/42861) and [Intel OpenCL](https://github.com/void-linux/void-packages/pull/43084). This will also make [intel packages pr](https://github.com/void-linux/void-packages/pull/41132) obsolete.~~ (see Requirements below)

Maintainer for previous ffmpeg(4) was orphaned, I can put my name in there if that matters, though I don't exactly see myself keeping up on ffmpeg.

This updates QT5 which looks like it is usually hosted by Johnny. Not sure if there's any reason to stay there or these sources are fine.

##### STILL FFMPEG4

These are a mix of emulators, games and/or older packages.

- attract (multiple patches in master)
- audacity (https://github.com/audacity/audacity/issues/2305 and https://sourceforge.net/p/portmedia/wiki/portsmf/ is 'beta')
- ccextractor (master patches? no release)
- vice
- kodi
- mlt (only dep left is flowblade)
- ~~synfig (mlt)~~ (work with mlt7, bump synfigstudio)
- tvheadend
- ssr
- spek-alternative
- ppsspp
- olive
- moc
- mediastreamer
- libextractor
- idjc
- hedgewars
- ~~ffmpegthumbnailer~~ (patches for moviedecoder.xxx files)
- ~~ffmpegthumbs~~ (latest compiles)
- deadbeef
- omxplayer
- qtav (fork has ffmpeg 5 patch - https://github.com/cmguo/QtAV)
- `vlc` (vlc4 will support ffmpeg5, there's a patch to build 3.x with ffmpeg5 but it will lack vaapi)
- `osg` (OpenSceneGraph plus `xine-lib`)


##### HAVE NOT BUILT YET

- omxplayer (rpi only? ffmpeg4)
- kodi (big, but ffmpeg4)


##### UPDATED (for ffmpeg6)

- ~~blender: update to 3.5.1~~ ~~will be revbump with~~ https://github.com/void-linux/void-packages/pull/43992
- unpaper: update to 7.0.0.
- guvcview: update to 2.0.8.
- qt5: update to 5.15.8
- qt5-webengine: update to 5.18.13
- shiboken2: revbump for qt5.15.8 (patch)
- python3-pyside2: update to 5.15.8 (patch)


##### Requirements

- ~~[gstreamer 1.22.2](https://github.com/void-linux/void-packages/pull/42861)~~ - a few packages use ffmpeg-devel and require a revbump

- [Intel Packages](https://github.com/void-linux/void-packages/pull/41132) - ffmpeg4 uses different libraries than 6 (libmfx / Intel-MediaSDK vs only oneVPL that Intel is moving to), both are included here

- ~~[shotcut 23.05.14](https://github.com/void-linux/void-packages/pull/44260)~~

- https://github.com/void-linux/void-packages/pull/44781 will remove from this PR

A patch file from https://github.com/void-linux/void-packages/pull/43761.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ffmpeg6-split-43761.patch --]
[-- Type: text/x-diff, Size: 789567 bytes --]

From 745c0bc9ae5cc71c3f1dbcd469cf9bb162d929df Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:55:46 -0400
Subject: [PATCH 001/115] ffmpeg: update to 6.0.

---
 common/shlibs                                 | 26 +++++---
 srcpkgs/ffmpeg/files/altivec.patch            | 60 -------------------
 .../patches/armv5tel-floating-point.patch     | 18 ------
 ...h-libavcodec-libsvtav1-ten_bit_format.diff | 40 -------------
 .../workaround-mesa-readeon-vaapi-bug.patch   | 28 ---------
 srcpkgs/ffmpeg/template                       | 38 ++++++------
 6 files changed, 37 insertions(+), 173 deletions(-)
 delete mode 100644 srcpkgs/ffmpeg/files/altivec.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 delete mode 100644 srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch

diff --git a/common/shlibs b/common/shlibs
index 2d528aa798ee5..4906a4a29efb7 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -393,15 +393,23 @@ libid3tag.so.0 libid3tag-0.15.1b_1
 libgif.so.7 giflib-5.1.0_1
 libImlib2.so.1 imlib2-1.4.2_1
 libmp3lame.so.0 lame-3.98.2_1
-libavdevice.so.58 libavdevice-4.0_1
-libavformat.so.58 libavformat-4.0_1
-libswscale.so.5 libswscale-4.0_1
-libswresample.so.3 libswresample-4.0_1
-libavresample.so.4 libavresample-4.0_1
-libpostproc.so.55 libpostproc-4.0_1
-libavcodec.so.58 libavcodec-4.0_1
-libavutil.so.56 libavutil-4.0_1
-libavfilter.so.7 libavfilter-4.0_1
+libavdevice.so.60 libavdevice-6.0_1
+libavformat.so.60 libavformat-6.0_1
+libswscale.so.7 libswscale-6.0_1
+libswresample.so.4 libswresample-6.0_1
+libpostproc.so.57 libpostproc-6.0_1
+libavcodec.so.60 libavcodec-6.0_1
+libavutil.so.58 libavutil-6.0_1
+libavfilter.so.9 libavfilter-6.0_1
+libavdevice.so.58 libavdevice4-4.0_1
+libavformat.so.58 libavformat4-4.0_1
+libswscale.so.5 libswscale4-4.0_1
+libswresample.so.3 libswresample4-4.0_1
+libavresample.so.4 libavresample4-4.0_1
+libpostproc.so.55 libpostproc4-4.0_1
+libavcodec.so.58 libavcodec4-4.0_1
+libavutil.so.56 libavutil4-4.0_1
+libavfilter.so.7 libavfilter4-4.0_1
 libSDL-1.2.so.0 SDL-1.2.14_1
 libSDL_image-1.2.so.0 SDL_image-1.2.10_1
 libx264.so.157 x264-20190507.2245_1
diff --git a/srcpkgs/ffmpeg/files/altivec.patch b/srcpkgs/ffmpeg/files/altivec.patch
deleted file mode 100644
index 9c57200463320..0000000000000
--- a/srcpkgs/ffmpeg/files/altivec.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-revert some altivec specific change on all ppc* except ppc64le*
-
-q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
-conditionally, for ppc* but not ppc64le* (the new code is valid for
-POWER8 VSX which LE targets as a baseline but not BE)"
-
-
-This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
----
- libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
- 1 file changed, 20 insertions(+), 4 deletions(-)
-
-diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
-index 536545293d..c1e2852adb 100644
---- a/libswscale/ppc/yuv2rgb_altivec.c
-+++ b/libswscale/ppc/yuv2rgb_altivec.c
-@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-     vector signed short R1, G1, B1;                                           \
-     vector unsigned char R, G, B;                                             \
-                                                                               \
-+    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
-+    vector unsigned char align_perm;                                          \
-+                                                                              \
-     vector signed short lCY       = c->CY;                                    \
-     vector signed short lOY       = c->OY;                                    \
-     vector signed short lCRV      = c->CRV;                                   \
-@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
-                                                                               \
-         for (j = 0; j < w / 16; j++) {                                        \
--            y0 = vec_xl(0, y1i);                                              \
-+            y1ivP = (const vector unsigned char *) y1i;                       \
-+            y2ivP = (const vector unsigned char *) y2i;                       \
-+            uivP  = (const vector unsigned char *) ui;                        \
-+            vivP  = (const vector unsigned char *) vi;                        \
-+                                                                              \
-+            align_perm = vec_lvsl(0, y1i);                                    \
-+            y0 = (vector unsigned char)                                       \
-+                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
-                                                                               \
--            y1 = vec_xl(0, y2i);                                              \
-+            align_perm = vec_lvsl(0, y2i);                                    \
-+            y1 = (vector unsigned char)                                       \
-+                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
-                                                                               \
--            u = (vector signed char) vec_xl(0, ui);                           \
-+            align_perm = vec_lvsl(0, ui);                                     \
-+            u = (vector signed char)                                          \
-+                    vec_perm(uivP[0], uivP[1], align_perm);                   \
-                                                                               \
--            v = (vector signed char) vec_xl(0, vi);                           \
-+            align_perm = vec_lvsl(0, vi);                                     \
-+            v = (vector signed char)                                          \
-+                    vec_perm(vivP[0], vivP[1], align_perm);                   \
-                                                                               \
-             u = (vector signed char)                                          \
-                     vec_sub(u,                                                \
--- 
-2.27.0
-
diff --git a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
deleted file mode 100644
index 9a55178c74f0f..0000000000000
--- a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
-+++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
-@@ -39,6 +39,15 @@
- #endif
- #include <fenv.h>
- 
-+#if (FE_ALL_EXCEPT == 0)
-+/* E.g. ARM soft float does not define these */
-+#define FE_INVALID    0
-+#define FE_DIVBYZERO  0
-+#define FE_OVERFLOW   0
-+#define FE_UNDERFLOW  0
-+#define FE_INEXACT    0
-+#endif
-+
- #if CONFIG_LIBFONTCONFIG
- #include <fontconfig/fontconfig.h>
- #endif
diff --git a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
deleted file mode 100644
index aa948f7a8a2df..0000000000000
--- a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
+++ /dev/null
@@ -1,40 +0,0 @@
-#==================================================================================================
-# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
-# From: Christopher Degawa <christopher.degawa@intel.com>
-# Date: Thu, 20 Oct 2022 22:55:27 -0500
-# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
-#
-# compressed_ten_bit_format has been deprecated upstream and has no effect
-# and can be removed. Plus, technically it was never used in the first place
-# since it would require the app (ffmpeg) to set it and do additional
-# processing of the input frames.
-#
-# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
-#
-# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
-#==================================================================================================
---- a/libavcodec/libsvtav1.c
-+++ b/libavcodec/libsvtav1.c
-@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
- 
- static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
- {
--    const int    pack_mode_10bit =
--        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
--    const size_t luma_size_8bit  =
--        config->source_width * config->source_height * (1 << pack_mode_10bit);
--    const size_t luma_size_10bit =
--        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
-+    const size_t luma_size = config->source_width * config->source_height *
-+        (config->encoder_bit_depth > 8 ? 2 : 1);
- 
-     EbSvtIOFormat *in_data;
- 
--    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
-+    svt_enc->raw_size = luma_size * 3 / 2;
- 
-     // allocate buffer for in and out
-     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
--- 
-GitLab
-
diff --git a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
deleted file mode 100644
index 00e3f68a415b8..0000000000000
--- a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
-From: Rainer Hochecker <fernetmenta@online.de>
-Date: Sat, 26 Jan 2019 19:48:35 +0100
-Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
-
-This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
-It was hit frequently when watching h264 channels received via DVB-X.
-Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
----
- libavcodec/vaapi_h264.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
-index 5854587a255..f12fdc457a4 100644
---- a/libavcodec/vaapi_h264.c
-+++ b/libavcodec/vaapi_h264.c
-@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
-     H264SliceContext *sl = &h->slice_ctx[0];
-     int ret;
- 
-+    if (pic->nb_slices == 0) {
-+        ret = AVERROR_INVALIDDATA;
-+        goto finish;
-+    }
-+
-     ret = ff_vaapi_decode_issue(avctx, pic);
-     if (ret < 0)
-         goto finish;
diff --git a/srcpkgs/ffmpeg/template b/srcpkgs/ffmpeg/template
index ae26496e79293..c1f9b7efe40e3 100644
--- a/srcpkgs/ffmpeg/template
+++ b/srcpkgs/ffmpeg/template
@@ -1,15 +1,15 @@
 # Template file for 'ffmpeg'
 # audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
 pkgname=ffmpeg
-version=4.4.4
-revision=2
+version=6.0
+revision=1
 short_desc="Decoding, encoding and streaming software"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="https://www.ffmpeg.org"
 changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
 distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
-checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+checksum=57be87c22d9b49c112b6d24bc67d42508660e6b718b3db89c44e47e289137082
 
 hostmakedepends="pkg-config perl"
 makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
@@ -26,12 +26,13 @@ makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-deve
  $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
  $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
  $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
- $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers Vulkan-Tools Vulkan-ValidationLayers')
+ $(vopt_if onevpl 'onevpl onevpl-devel')
  $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
 depends="ffplay>=${version}_${revision}"
 
 build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
- dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec onevpl"
 build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
 desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
 desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
@@ -39,9 +40,13 @@ desc_option_sofa="Enable support for AES SOFA"
 desc_option_webp="Enable support for WebP"
 
 case "$XBPS_TARGET_MACHINE" in
-	i686*|x86_64*)
-		hostmakedepends+=" nasm"
+	i686*)
 		build_options_default+=" vaapi vdpau nvenc nvdec"
+		hostmakedepends+=" nasm"
+		;;
+	x86_64*)
+		hostmakedepends+=" nasm"
+		build_options_default+=" vaapi vdpau nvenc nvdec onevpl"
 		;;
 	ppc64*) build_options_default+=" vaapi vdpau";;
 	mips*) CFLAGS="-mnan=legacy";;
@@ -115,18 +120,19 @@ do_configure() {
 		$(vopt_enable x265 libx265) \
 		$(vopt_enable v4l2 libv4l2) \
 		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
-		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		--enable-libbs2b --enable-libvidstab \
 		$(vopt_enable dav1d libdav1d) \
 		$(vopt_enable zimg libzimg) \
 		$(vopt_enable webp libwebp) \
 		$(vopt_enable sofa libmysofa) \
 		$(vopt_enable vulkan) \
+		$(vopt_enable onevpl libvpl) \
 		$(vopt_enable drm libdrm) \
 		$(vopt_enable svtav1 libsvtav1) \
 		$(vopt_enable srt libsrt) \
 		$(vopt_enable rist librist) \
-		$(vopt_if nvenc '--enable-nvenc') \
-		$(vopt_if nvdec '--enable-nvdec')
+		$(vopt_enable nvenc nvenc) \
+		$(vopt_enable nvdec nvdec)
 }
 
 do_build() {
@@ -153,10 +159,8 @@ libavdevice_package() {
 }
 
 libavresample_package() {
-	short_desc="FFmpeg audio resampling library"
-	pkg_install() {
-		vmove "usr/lib/libavresample.so.*"
-	}
+	short_desc="Package deprecated, removal needed"
+	build_style=meta
 }
 
 libavformat_package() {
@@ -210,15 +214,13 @@ ffmpeg-devel_package() {
 		libavfilter>=${version}_${revision}
 		libpostproc>=${version}_${revision}
 		libswscale>=${version}_${revision}
-		libswresample>=${version}_${revision}
-		libavresample>=${version}_${revision}"
+		libswresample>=${version}_${revision}"
 	short_desc+=" - development files"
-
+	conflicts="ffmpeg4-devel"
 	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
 		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
 		nostrip_files="/usr/lib/libavfilter.a"
 	fi
-
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig

From 1d6b2267c9656891fd91c6189f55b8ac1014cd96 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:56:22 -0400
Subject: [PATCH 002/115] New package: ffmpeg4-4.4.4.

---
 srcpkgs/ffmpeg4-devel                         |   1 +
 srcpkgs/ffmpeg4/files/altivec.patch           |  60 +++++
 .../patches/armv5tel-floating-point.patch     |  18 ++
 ...h-libavcodec-libsvtav1-ten_bit_format.diff |  40 +++
 .../workaround-mesa-readeon-vaapi-bug.patch   |  28 ++
 srcpkgs/ffmpeg4/template                      | 240 ++++++++++++++++++
 srcpkgs/libavcodec4                           |   1 +
 srcpkgs/libavdevice4                          |   1 +
 srcpkgs/libavfilter4                          |   1 +
 srcpkgs/libavformat4                          |   1 +
 srcpkgs/libavresample4                        |   1 +
 srcpkgs/libavutil4                            |   1 +
 srcpkgs/libpostproc4                          |   1 +
 srcpkgs/libswresample4                        |   1 +
 srcpkgs/libswscale4                           |   1 +
 15 files changed, 396 insertions(+)
 create mode 120000 srcpkgs/ffmpeg4-devel
 create mode 100644 srcpkgs/ffmpeg4/files/altivec.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 create mode 100644 srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
 create mode 100644 srcpkgs/ffmpeg4/template
 create mode 120000 srcpkgs/libavcodec4
 create mode 120000 srcpkgs/libavdevice4
 create mode 120000 srcpkgs/libavfilter4
 create mode 120000 srcpkgs/libavformat4
 create mode 120000 srcpkgs/libavresample4
 create mode 120000 srcpkgs/libavutil4
 create mode 120000 srcpkgs/libpostproc4
 create mode 120000 srcpkgs/libswresample4
 create mode 120000 srcpkgs/libswscale4

diff --git a/srcpkgs/ffmpeg4-devel b/srcpkgs/ffmpeg4-devel
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/ffmpeg4-devel
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/ffmpeg4/files/altivec.patch b/srcpkgs/ffmpeg4/files/altivec.patch
new file mode 100644
index 0000000000000..9c57200463320
--- /dev/null
+++ b/srcpkgs/ffmpeg4/files/altivec.patch
@@ -0,0 +1,60 @@
+revert some altivec specific change on all ppc* except ppc64le*
+
+q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
+conditionally, for ppc* but not ppc64le* (the new code is valid for
+POWER8 VSX which LE targets as a baseline but not BE)"
+
+
+This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
+---
+ libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
+ 1 file changed, 20 insertions(+), 4 deletions(-)
+
+diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
+index 536545293d..c1e2852adb 100644
+--- a/libswscale/ppc/yuv2rgb_altivec.c
++++ b/libswscale/ppc/yuv2rgb_altivec.c
+@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+     vector signed short R1, G1, B1;                                           \
+     vector unsigned char R, G, B;                                             \
+                                                                               \
++    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
++    vector unsigned char align_perm;                                          \
++                                                                              \
+     vector signed short lCY       = c->CY;                                    \
+     vector signed short lOY       = c->OY;                                    \
+     vector signed short lCRV      = c->CRV;                                   \
+@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
+                                                                               \
+         for (j = 0; j < w / 16; j++) {                                        \
+-            y0 = vec_xl(0, y1i);                                              \
++            y1ivP = (const vector unsigned char *) y1i;                       \
++            y2ivP = (const vector unsigned char *) y2i;                       \
++            uivP  = (const vector unsigned char *) ui;                        \
++            vivP  = (const vector unsigned char *) vi;                        \
++                                                                              \
++            align_perm = vec_lvsl(0, y1i);                                    \
++            y0 = (vector unsigned char)                                       \
++                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
+                                                                               \
+-            y1 = vec_xl(0, y2i);                                              \
++            align_perm = vec_lvsl(0, y2i);                                    \
++            y1 = (vector unsigned char)                                       \
++                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
+                                                                               \
+-            u = (vector signed char) vec_xl(0, ui);                           \
++            align_perm = vec_lvsl(0, ui);                                     \
++            u = (vector signed char)                                          \
++                    vec_perm(uivP[0], uivP[1], align_perm);                   \
+                                                                               \
+-            v = (vector signed char) vec_xl(0, vi);                           \
++            align_perm = vec_lvsl(0, vi);                                     \
++            v = (vector signed char)                                          \
++                    vec_perm(vivP[0], vivP[1], align_perm);                   \
+                                                                               \
+             u = (vector signed char)                                          \
+                     vec_sub(u,                                                \
+-- 
+2.27.0
+
diff --git a/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
new file mode 100644
index 0000000000000..9a55178c74f0f
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
@@ -0,0 +1,18 @@
+--- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
++++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
+@@ -39,6 +39,15 @@
+ #endif
+ #include <fenv.h>
+ 
++#if (FE_ALL_EXCEPT == 0)
++/* E.g. ARM soft float does not define these */
++#define FE_INVALID    0
++#define FE_DIVBYZERO  0
++#define FE_OVERFLOW   0
++#define FE_UNDERFLOW  0
++#define FE_INEXACT    0
++#endif
++
+ #if CONFIG_LIBFONTCONFIG
+ #include <fontconfig/fontconfig.h>
+ #endif
diff --git a/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
new file mode 100644
index 0000000000000..aa948f7a8a2df
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
@@ -0,0 +1,40 @@
+#==================================================================================================
+# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
+# From: Christopher Degawa <christopher.degawa@intel.com>
+# Date: Thu, 20 Oct 2022 22:55:27 -0500
+# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
+#
+# compressed_ten_bit_format has been deprecated upstream and has no effect
+# and can be removed. Plus, technically it was never used in the first place
+# since it would require the app (ffmpeg) to set it and do additional
+# processing of the input frames.
+#
+# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
+#
+# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
+#==================================================================================================
+--- a/libavcodec/libsvtav1.c
++++ b/libavcodec/libsvtav1.c
+@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
+ 
+ static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
+ {
+-    const int    pack_mode_10bit =
+-        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
+-    const size_t luma_size_8bit  =
+-        config->source_width * config->source_height * (1 << pack_mode_10bit);
+-    const size_t luma_size_10bit =
+-        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
++    const size_t luma_size = config->source_width * config->source_height *
++        (config->encoder_bit_depth > 8 ? 2 : 1);
+ 
+     EbSvtIOFormat *in_data;
+ 
+-    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
++    svt_enc->raw_size = luma_size * 3 / 2;
+ 
+     // allocate buffer for in and out
+     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
+-- 
+GitLab
+
diff --git a/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
new file mode 100644
index 0000000000000..00e3f68a415b8
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
@@ -0,0 +1,28 @@
+From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
+From: Rainer Hochecker <fernetmenta@online.de>
+Date: Sat, 26 Jan 2019 19:48:35 +0100
+Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
+
+This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
+It was hit frequently when watching h264 channels received via DVB-X.
+Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
+---
+ libavcodec/vaapi_h264.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
+index 5854587a255..f12fdc457a4 100644
+--- a/libavcodec/vaapi_h264.c
++++ b/libavcodec/vaapi_h264.c
+@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
+     H264SliceContext *sl = &h->slice_ctx[0];
+     int ret;
+ 
++    if (pic->nb_slices == 0) {
++        ret = AVERROR_INVALIDDATA;
++        goto finish;
++    }
++
+     ret = ff_vaapi_decode_issue(avctx, pic);
+     if (ret < 0)
+         goto finish;
diff --git a/srcpkgs/ffmpeg4/template b/srcpkgs/ffmpeg4/template
new file mode 100644
index 0000000000000..f2c851693d367
--- /dev/null
+++ b/srcpkgs/ffmpeg4/template
@@ -0,0 +1,240 @@
+# Template file for 'ffmpeg4'
+# audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
+pkgname=ffmpeg4
+version=4.4.4
+revision=1
+short_desc="Decoding, encoding and streaming software - ffmpeg4 libraries only"
+maintainer="Orphaned <orphan@voidlinux.org>"
+license="GPL-3.0-or-later"
+homepage="https://www.ffmpeg.org"
+changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
+distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
+checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+
+hostmakedepends="pkg-config perl"
+makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
+ libXext-devel libXvMC-devel libxcb-devel lame-devel libtheora-devel
+ libvorbis-devel x264-devel xvidcore-devel jack-devel SDL2-devel
+ libcdio-paranoia-devel librtmp-devel libmodplug-devel gnutls-devel
+ speex-devel celt-devel harfbuzz-devel libass-devel opus-devel ocl-icd-devel
+ libbs2b-devel libvidstab-devel vmaf-devel $(vopt_if pulseaudio pulseaudio-devel)
+ $(vopt_if vaapi libva-devel) $(vopt_if vdpau libvdpau-devel)
+ $(vopt_if x265 x265-devel) $(vopt_if v4l2 v4l-utils-devel)
+ $(vopt_if fdk_aac fdk-aac-devel) $(vopt_if vpx libvpx-devel)
+ $(vopt_if aom libaom-devel) $(vopt_if sndio sndio-devel)
+ $(vopt_if dav1d libdav1d-devel) $(vopt_if zimg zimg-devel)
+ $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
+ $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
+ $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if mfx 'libmfx libmfx-devel')
+ $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
+
+build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec mfx"
+build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
+
+desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
+desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
+desc_option_sofa="Enable support for AES SOFA"
+desc_option_webp="Enable support for WebP"
+
+case "$XBPS_TARGET_MACHINE" in
+	i686*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau nvenc nvdec"
+			;;
+	x86_64*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau mfx nvenc nvdec"
+			;;
+	ppc64*) build_options_default+=" vaapi vdpau";;
+	mips*) CFLAGS="-mnan=legacy";;
+esac
+
+if [ "$XBPS_TARGET_WORDSIZE" != "32" ]; then
+	build_options_default+=" svtav1"
+fi
+
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+fi
+
+_apply_patch() {
+	local args="$1" pname="$(basename $2)"
+
+	if [ ! -f ".${pname}_done" ]; then
+		patch -N $args -i $2
+		touch .${pname}_done
+	fi
+}
+
+post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64le*) ;;
+		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
+	esac
+
+	vsed -i libavfilter/vf_libvmaf.c -e 's!/usr/local/share/model/\(vmaf_v0.6.1\).pkl!/usr/share/vmaf/\1.json!'
+}
+
+do_configure() {
+	# Fix gcc on x86_64-musl only
+	if [ "$XBPS_TARGET_MACHINE" = "x86_64-musl" ]; then
+		vsed -i configure -e "s;_cflags_speed='-O3';_cflags_speed='-O2';"
+	fi
+
+	if [ "$CROSS_BUILD" ]; then
+		case "$XBPS_TARGET_MACHINE" in
+			arm*) _arch="arm";;
+			aarch64*) _arch="aarch64";;
+			mips*) _arch="mips";;
+			ppc64*) _arch="ppc64";;
+			ppc*) _arch="ppc";;
+			*) _arch="${XBPS_TARGET_MACHINE%%-musl}";;
+		esac
+
+		_args+=" --enable-cross-compile
+			--sysroot=$XBPS_CROSS_BASE
+			--cross-prefix=${XBPS_CROSS_TRIPLET}-
+			--target-os=linux --arch=${_arch}"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc|ppc-musl) _args+=" --disable-altivec";;
+	esac
+
+	if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+		_args+=" --extra-libs=-latomic"
+	fi
+
+	./configure --prefix=/usr --disable-debug --enable-gpl --enable-gnutls \
+		--disable-stripping \
+		--enable-libcdio --enable-version3 --enable-runtime-cpudetect \
+		--enable-libmp3lame --enable-libvorbis --enable-libxvid \
+		--enable-libx264 $(vopt_enable vpx libvpx) --enable-libtheora \
+		--enable-shared --enable-static --enable-libxcb \
+		$(vopt_enable pulseaudio libpulse) --enable-libfreetype --enable-libmodplug \
+		--enable-libspeex --enable-libcelt --enable-libass \
+		--enable-libopus --enable-librtmp --enable-libjack \
+		$(vopt_if fdk_aac '--enable-nonfree --enable-libfdk-aac') \
+		--disable-libopencore_amrnb --disable-libopencore_amrwb \
+		--disable-libopenjpeg \
+		--enable-postproc --enable-opencl ${_args} --enable-libvmaf ${_args} \
+		$(vopt_enable x265 libx265) \
+		$(vopt_enable v4l2 libv4l2) \
+		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
+		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		$(vopt_enable dav1d libdav1d) \
+		$(vopt_enable zimg libzimg) \
+		$(vopt_enable webp libwebp) \
+		$(vopt_enable sofa libmysofa) \
+		$(vopt_enable vulkan) \
+		$(vopt_enable drm libdrm) \
+		$(vopt_enable svtav1 libsvtav1) \
+		$(vopt_enable srt libsrt) \
+		$(vopt_enable rist librist) \
+		$(vopt_enable mfx libmfx) \
+		$(vopt_if nvenc '--enable-nvenc') \
+		$(vopt_if nvdec '--enable-nvdec')
+}
+
+do_build() {
+	make ${makejobs}
+	make doc/ff{mpeg,play}.1
+}
+
+do_install() {
+	make DESTDIR=${DESTDIR} install install-man
+	rm -rf ${DESTDIR}/usr/bin
+}
+
+libavcodec4_package() {
+	short_desc="FFmpeg codec library"
+	pkg_install() {
+		vmove "usr/lib/libavcodec.so.*"
+	}
+}
+
+libavdevice4_package() {
+	short_desc="FFmpeg device handling library"
+	pkg_install() {
+		vmove "usr/lib/libavdevice.so.*"
+	}
+}
+
+libavresample4_package() {
+	short_desc="FFmpeg audio resampling library"
+	pkg_install() {
+		vmove "usr/lib/libavresample.so.*"
+	}
+}
+
+libavformat4_package() {
+	short_desc="FFmpeg file format library"
+	pkg_install() {
+		vmove "usr/lib/libavformat.so.*"
+	}
+}
+
+libavutil4_package() {
+	short_desc="FFmpeg utility library"
+	pkg_install() {
+		vmove "usr/lib/libavutil.so.*"
+	}
+}
+
+libavfilter4_package() {
+	short_desc="FFmpeg audio/video filter library"
+	pkg_install() {
+		vmove "usr/lib/libavfilter.so.*"
+	}
+}
+
+libpostproc4_package() {
+	short_desc="FFmpeg video postprocessing library"
+	pkg_install() {
+		vmove "usr/lib/libpostproc.so.*"
+	}
+}
+
+libswscale4_package() {
+	short_desc="FFmpeg video scaling library"
+	pkg_install() {
+		vmove "usr/lib/libswscale.so.*"
+	}
+}
+
+libswresample4_package() {
+	short_desc="FFmpeg video resampling library"
+	pkg_install() {
+		vmove "usr/lib/libswresample.so.*"
+	}
+}
+
+ffmpeg4-devel_package() {
+	depends="
+		libavcodec4>=${version}_${revision}
+		libavdevice4>=${version}_${revision}
+		libavformat4>=${version}_${revision}
+		libavutil4>=${version}_${revision}
+		libavfilter4>=${version}_${revision}
+		libpostproc4>=${version}_${revision}
+		libswscale4>=${version}_${revision}
+		libswresample4>=${version}_${revision}
+		libavresample4>=${version}_${revision}"
+	short_desc+=" - development files"
+	conflicts="ffmpeg-devel"
+	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
+		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
+		nostrip_files="/usr/lib/libavfilter.a"
+	fi
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.a"
+		vmove "usr/lib/*.so"
+		vmove usr/share/ffmpeg/examples
+		vmove usr/share/man/man3
+	}
+}
diff --git a/srcpkgs/libavcodec4 b/srcpkgs/libavcodec4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavcodec4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavdevice4 b/srcpkgs/libavdevice4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavdevice4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavfilter4 b/srcpkgs/libavfilter4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavfilter4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavformat4 b/srcpkgs/libavformat4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavformat4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavresample4 b/srcpkgs/libavresample4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavutil4 b/srcpkgs/libavutil4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavutil4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libpostproc4 b/srcpkgs/libpostproc4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libpostproc4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswresample4 b/srcpkgs/libswresample4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libswresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswscale4 b/srcpkgs/libswscale4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libswscale4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file

From eeb85017db20c22b70a721f36f518a2a8df188eb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:04 -0400
Subject: [PATCH 003/115] opencv: update to 4.7.0.

---
 common/shlibs           | 104 ++++++++++++++++++++--------------------
 srcpkgs/opencv/template |   8 ++--
 2 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index 4906a4a29efb7..b73cd277054fb 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2144,58 +2144,58 @@ libcapstone.so.4 capstone-4.0_1
 libhavege.so.2 libhaveged-1.9.11_1
 libnih.so.1 libnih-1.0.3_1
 libnih-dbus.so.1 libnih-1.0.3_1
-libopencv_quality.so.406 libopencv-4.6.0_1
-libopencv_reg.so.406 libopencv-4.6.0_1
-libopencv_surface_matching.so.406 libopencv-4.6.0_1
-libopencv_xphoto.so.406 libopencv-4.6.0_1
-libopencv_freetype.so.406 libopencv-4.6.0_1
-libopencv_fuzzy.so.406 libopencv-4.6.0_1
-libopencv_hfs.so.406 libopencv-4.6.0_1
-libopencv_img_hash.so.406 libopencv-4.6.0_1
-libopencv_line_descriptor.so.406 libopencv-4.6.0_1
-libopencv_saliency.so.406 libopencv-4.6.0_1
-libopencv_structured_light.so.406 libopencv-4.6.0_1
-libopencv_aruco.so.406 libopencv-4.6.0_1
-libopencv_bgsegm.so.406 libopencv-4.6.0_1
-libopencv_bioinspired.so.406 libopencv-4.6.0_1
-libopencv_ccalib.so.406 libopencv-4.6.0_1
-libopencv_face.so.406 libopencv-4.6.0_1
-libopencv_tracking.so.406 libopencv-4.6.0_1
-libopencv_xfeatures2d.so.406 libopencv-4.6.0_1
-libopencv_optflow.so.406 libopencv-4.6.0_1
-libopencv_ximgproc.so.406 libopencv-4.6.0_1
-libopencv_plot.so.406 libopencv-4.6.0_1
-libopencv_text.so.406 libopencv-4.6.0_1
-libopencv_ml.so.406 libopencv-4.6.0_1
-libopencv_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn.so.406 libopencv-4.6.0_1
-libopencv_shape.so.406 libopencv-4.6.0_1
-libopencv_stitching.so.406 libopencv-4.6.0_1
-libopencv_photo.so.406 libopencv-4.6.0_1
-libopencv_video.so.406 libopencv-4.6.0_1
-libopencv_calib3d.so.406 libopencv-4.6.0_1
-libopencv_features2d.so.406 libopencv-4.6.0_1
-libopencv_flann.so.406 libopencv-4.6.0_1
-libopencv_highgui.so.406 libopencv-4.6.0_1
-libopencv_videoio.so.406 libopencv-4.6.0_1
-libopencv_imgcodecs.so.406 libopencv-4.6.0_1
-libopencv_imgproc.so.406 libopencv-4.6.0_1
-libopencv_core.so.406 libopencv-4.6.0_1
-libopencv_superres.so.406 libopencv-4.6.0_1
-libopencv_videostab.so.406 libopencv-4.6.0_1
-libopencv_gapi.so.406 libopencv-4.6.0_1
-libopencv_xobjdetect.so.406 libopencv-4.6.0_1
-libopencv_datasets.so.406 libopencv-4.6.0_1
-libopencv_dnn_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn_superres.so.406 libopencv-4.6.0_1
-libopencv_dpm.so.406 libopencv-4.6.0_1
-libopencv_phase_unwrapping.so.406 libopencv-4.6.0_1
-libopencv_stereo.so.406 libopencv-4.6.0_1
-libopencv_rapid.so.406 libopencv-4.6.0_1
-libopencv_intensity_transform.so.406 libopencv-4.6.0_1
-libopencv_alphamat.so.406 libopencv-4.6.0_1
-libopencv_barcode.so.406 libopencv-4.6.0_1
-libopencv_mcc.so.406 libopencv-4.6.0_1
+libopencv_quality.so.407 libopencv-4.7.0_1
+libopencv_reg.so.407 libopencv-4.7.0_1
+libopencv_surface_matching.so.407 libopencv-4.7.0_1
+libopencv_xphoto.so.407 libopencv-4.7.0_1
+libopencv_freetype.so.407 libopencv-4.7.0_1
+libopencv_fuzzy.so.407 libopencv-4.7.0_1
+libopencv_hfs.so.407 libopencv-4.7.0_1
+libopencv_img_hash.so.407 libopencv-4.7.0_1
+libopencv_line_descriptor.so.407 libopencv-4.7.0_1
+libopencv_saliency.so.407 libopencv-4.7.0_1
+libopencv_structured_light.so.407 libopencv-4.7.0_1
+libopencv_aruco.so.407 libopencv-4.7.0_1
+libopencv_bgsegm.so.407 libopencv-4.7.0_1
+libopencv_bioinspired.so.407 libopencv-4.7.0_1
+libopencv_ccalib.so.407 libopencv-4.7.0_1
+libopencv_face.so.407 libopencv-4.7.0_1
+libopencv_tracking.so.407 libopencv-4.7.0_1
+libopencv_xfeatures2d.so.407 libopencv-4.7.0_1
+libopencv_optflow.so.407 libopencv-4.7.0_1
+libopencv_ximgproc.so.407 libopencv-4.7.0_1
+libopencv_plot.so.407 libopencv-4.7.0_1
+libopencv_text.so.407 libopencv-4.7.0_1
+libopencv_ml.so.407 libopencv-4.7.0_1
+libopencv_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn.so.407 libopencv-4.7.0_1
+libopencv_shape.so.407 libopencv-4.7.0_1
+libopencv_stitching.so.407 libopencv-4.7.0_1
+libopencv_photo.so.407 libopencv-4.7.0_1
+libopencv_video.so.407 libopencv-4.7.0_1
+libopencv_calib3d.so.407 libopencv-4.7.0_1
+libopencv_features2d.so.407 libopencv-4.7.0_1
+libopencv_flann.so.407 libopencv-4.7.0_1
+libopencv_highgui.so.407 libopencv-4.7.0_1
+libopencv_videoio.so.407 libopencv-4.7.0_1
+libopencv_imgcodecs.so.407 libopencv-4.7.0_1
+libopencv_imgproc.so.407 libopencv-4.7.0_1
+libopencv_core.so.407 libopencv-4.7.0_1
+libopencv_superres.so.407 libopencv-4.7.0_1
+libopencv_videostab.so.407 libopencv-4.7.0_1
+libopencv_gapi.so.407 libopencv-4.7.0_1
+libopencv_xobjdetect.so.407 libopencv-4.7.0_1
+libopencv_datasets.so.407 libopencv-4.7.0_1
+libopencv_dnn_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn_superres.so.407 libopencv-4.7.0_1
+libopencv_dpm.so.407 libopencv-4.7.0_1
+libopencv_phase_unwrapping.so.407 libopencv-4.7.0_1
+libopencv_stereo.so.407 libopencv-4.7.0_1
+libopencv_rapid.so.407 libopencv-4.7.0_1
+libopencv_intensity_transform.so.407 libopencv-4.7.0_1
+libopencv_alphamat.so.407 libopencv-4.7.0_1
+libopencv_barcode.so.407 libopencv-4.7.0_1
+libopencv_mcc.so.407 libopencv-4.7.0_1
 libuniconf.so.4.6 wvstreams-4.6.1_20
 libwvbase.so.4.6 wvstreams-4.6.1_20
 libwvutils.so.4.6 wvstreams-4.6.1_20
diff --git a/srcpkgs/opencv/template b/srcpkgs/opencv/template
index 62226978fa3e0..93b58cb6af146 100644
--- a/srcpkgs/opencv/template
+++ b/srcpkgs/opencv/template
@@ -1,7 +1,7 @@
 # Template file for 'opencv'
 pkgname=opencv
-version=4.6.0
-revision=4
+version=4.7.0
+revision=1
 create_wrksrc=yes
 build_wrksrc=${pkgname}-${version}
 build_style=cmake
@@ -24,8 +24,8 @@ homepage="https://opencv.org"
 changelog="https://github.com/opencv/opencv/wiki/ChangeLog"
 distfiles="https://github.com/opencv/opencv/archive/${version}.tar.gz
  https://github.com/opencv/opencv_contrib/archive/${version}.tar.gz>contrib.tar.gz"
-checksum="1ec1cba65f9f20fe5a41fda1586e01c70ea0c9a6d7b67c9e13edf0cfe2239277
- 1777d5fd2b59029cf537e5fd6f8aa68d707075822f90bde683fcde086f85f7a7"
+checksum="8df0079cdbe179748a18d44731af62a245a45ebf5085223dc03133954c662973
+ 42df840cf9055e59d0e22c249cfb19f04743e1bdad113d31b1573d3934d62584"
 patch_args="-Np1 -d ${build_wrksrc}"
 # tests hang indenfinitely, even with test data included
 make_check=no

From 04d07fb264756433f7052b969b17f54e28815b99 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 004/115] actiona: revbump for opencv-4.7.0

---
 srcpkgs/actiona/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/actiona/template b/srcpkgs/actiona/template
index cf5f0b7a2ae61..0d899311e6df7 100644
--- a/srcpkgs/actiona/template
+++ b/srcpkgs/actiona/template
@@ -1,7 +1,7 @@
 # Template file for 'actiona'
 pkgname=actiona
 version=3.10.1
-revision=2
+revision=3
 build_style=qmake
 configure_args="PKGCONFIG_OPENCV=opencv4"
 hostmakedepends="pkg-config qt5-plugin-mysql qt5-qmake qt5-host-tools"

From ad0102a1db144ededba5edc1e0951ade6322c79c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 005/115] qimgv: revbump for opencv-4.7.0

---
 srcpkgs/qimgv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qimgv/template b/srcpkgs/qimgv/template
index 7eb30db33992c..dd341dfe1bfce 100644
--- a/srcpkgs/qimgv/template
+++ b/srcpkgs/qimgv/template
@@ -1,7 +1,7 @@
 # Template file for 'qimgv'
 pkgname=qimgv
 version=1.0.2
-revision=2
+revision=3
 build_style=cmake
 configure_args="$(vopt_if video -DVIDEO_SUPPORT=ON -DVIDEO_SUPPORT=OFF)
  $(vopt_if scale -DOPENCV_SUPPORT=ON -DOPENCV_SUPPORT=OFF)

From a1a69b7ace0db80cf97c0fb70fbc06fd0f4653ca Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 006/115] retroshare: revbump for opencv-4.7.0

---
 srcpkgs/retroshare/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroshare/template b/srcpkgs/retroshare/template
index 5fe0e45e4cb0b..49e2c1cbe8a53 100644
--- a/srcpkgs/retroshare/template
+++ b/srcpkgs/retroshare/template
@@ -1,7 +1,7 @@
 # Template file for 'retroshare'
 pkgname=retroshare
 version=0.6.6
-revision=2
+revision=4
 build_style=qmake
 #XXX broadcast feature requires an ancient udp-discovery-cpp which either needs
 # to be fetched+patched (FTBFS) here or packaged :/

From 7a489e57b5c0665f97cf4dbe94793de9b14b0923 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 007/115] waifu2x-converter-cpp: revbump for opencv-4.7.0

---
 srcpkgs/waifu2x-converter-cpp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waifu2x-converter-cpp/template b/srcpkgs/waifu2x-converter-cpp/template
index 8c095d0d7baba..aa52d8c981a84 100644
--- a/srcpkgs/waifu2x-converter-cpp/template
+++ b/srcpkgs/waifu2x-converter-cpp/template
@@ -1,7 +1,7 @@
 # Template file for 'waifu2x-converter-cpp'
 pkgname=waifu2x-converter-cpp
 version=5.2.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DINSTALL_MODELS=ON"
 hostmakedepends="pkg-config"

From 03ee71734144601327f6721508db8bb0ba8acbf6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:38 -0400
Subject: [PATCH 008/115] vlc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/vlc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vlc/template b/srcpkgs/vlc/template
index 651c94a1353a3..855ca52386626 100644
--- a/srcpkgs/vlc/template
+++ b/srcpkgs/vlc/template
@@ -25,7 +25,7 @@ lib32disabled=yes
 hostmakedepends="automake libtool pkg-config flex gettext libgcrypt-devel
  live555-devel gettext-devel $(vopt_if lua lua52) $(vopt_if chromecast protobuf)"
 makedepends="
- avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg-devel freefont-ttf
+ avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg4-devel freefont-ttf
  gnutls-devel jack-devel liba52-devel libass-devel libbluray-devel
  libcdio-devel libdca-devel libdvbpsi-devel libdvdnav-devel libmad-devel
  libmatroska-devel libmodplug-devel libmpcdec-devel libmpeg2-devel

From 0becfcc368c3aa76add7aa91240bce8923a5a65f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:55 -0400
Subject: [PATCH 009/115] osg: revbump for ffmpeg4-4.4.3

---
 srcpkgs/osg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/osg/template b/srcpkgs/osg/template
index a9ebbd287933b..755793f7e11bf 100644
--- a/srcpkgs/osg/template
+++ b/srcpkgs/osg/template
@@ -8,7 +8,7 @@ build_helper="qemu"
 configure_args="-DLIB_POSTFIX="
 hostmakedepends="pkg-config xrandr"
 makedepends="MesaLib-devel gtkglext-devel libcurl-devel giflib-devel librsvg-devel
- jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg-devel xine-lib-devel
+ jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg4-devel xine-lib-devel
  SDL2-devel gst-plugins-base1-devel
  $(vopt_if openexr libopenexr-devel)
  $(vopt_if poppler poppler-glib-devel)

From 8499e2cf2eb2c45cc074064cac9f23539fba21a0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:13 -0400
Subject: [PATCH 010/115] xine-lib: revbump for ffmpeg4-4.4.3

---
 srcpkgs/xine-lib/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/xine-lib/template b/srcpkgs/xine-lib/template
index f713eff49b07c..ed6194c17d11e 100644
--- a/srcpkgs/xine-lib/template
+++ b/srcpkgs/xine-lib/template
@@ -1,6 +1,6 @@
 # Template file for 'xine-lib'
 pkgname=xine-lib
-version=1.2.12
+version=1.2.13
 revision=1
 build_style=gnu-configure
 configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
@@ -8,7 +8,7 @@ configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
 hostmakedepends="automake gettext-devel libtool pkg-config perl"
 makedepends="
  zlib-devel alsa-lib-devel libxcb-devel libSM-devel libXext-devel libXv-devel
- libXvMC-devel liba52-devel libmad-devel ffmpeg-devel pulseaudio-devel
+ libXvMC-devel liba52-devel libmad-devel ffmpeg4-devel pulseaudio-devel
  jack-devel samba-devel libflac-devel libmodplug-devel libmpcdec-devel
  speex-devel libtheora-devel libvorbis-devel libdca-devel faad2-devel
  libcdio-devel libbluray-devel aalib-devel libcaca-devel libXinerama-devel
@@ -19,7 +19,7 @@ license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="http://www.xine-project.org"
 changelog="https://sourceforge.net/projects/xine/files/xine-lib/${version}/README.txt/view"
 distfiles="${SOURCEFORGE_SITE}/xine/${pkgname}-${version}.tar.xz"
-checksum=d606270468e1540c2a89c0d7f5fdf11e17ecc0c2698cc0bcb1065ff26abee098
+checksum=5f10d6d718a4a51c17ed1b32b031d4f9b80b061e8276535b2be31e5ac4b75e6f
 
 case "$XBPS_TARGET_MACHINE" in
 	i686-musl)

From aa59982572f205e2de28c1f6c78eed2730448b7e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 011/115] QMPlay2: revbump for ffmpeg-6.0

---
 srcpkgs/QMPlay2/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/QMPlay2/template b/srcpkgs/QMPlay2/template
index 00a55417659f6..fc191a5be7d80 100644
--- a/srcpkgs/QMPlay2/template
+++ b/srcpkgs/QMPlay2/template
@@ -1,7 +1,7 @@
 # Template file for 'QMPlay2'
 pkgname=QMPlay2
 version=23.06.17
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools"
 makedepends="alsa-lib-devel ffmpeg-devel libass-devel libcdio-devel libgme-devel

From e657b3bf22b27302bceff96ef2121f6c7b6b1586 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 012/115] alsa-plugins: revbump for ffmpeg-6.0

---
 srcpkgs/alsa-plugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/alsa-plugins/template b/srcpkgs/alsa-plugins/template
index 0bfa6d9fd2643..a5708a7d82a8f 100644
--- a/srcpkgs/alsa-plugins/template
+++ b/srcpkgs/alsa-plugins/template
@@ -1,7 +1,7 @@
 # Template file for 'alsa-plugins'
 pkgname=alsa-plugins
 version=1.2.7.1
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--disable-maemo-plugin"
 hostmakedepends="pkg-config"

From aa82b050a284bb44b063149fc24034b8b697c6dd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 013/115] arcan: revbump for ffmpeg-6.0

---
 srcpkgs/arcan/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/arcan/template b/srcpkgs/arcan/template
index 853e16fcad391..6b2da6fa6e62e 100644
--- a/srcpkgs/arcan/template
+++ b/srcpkgs/arcan/template
@@ -2,7 +2,7 @@
 # !! keep synced with: acfgfs aclip aloadimage
 pkgname=arcan
 version=0.6.2.1
-revision=1
+revision=2
 create_wrksrc=yes
 build_wrksrc=arcan/src
 build_style=cmake

From 084e6b5d77ddbe303d548fe56e02f0488283b6d4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 014/115] attract: revbump for ffmpeg4-4.4.3

---
 srcpkgs/attract/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/attract/template b/srcpkgs/attract/template
index 26144e931a3c7..e760bf0d18aec 100644
--- a/srcpkgs/attract/template
+++ b/srcpkgs/attract/template
@@ -1,12 +1,12 @@
 # Template file for 'attract'
 pkgname=attract
 version=2.6.2
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="VERBOSE=1"
 make_use_env=yes
 hostmakedepends="pkg-config"
-makedepends="SFML-devel ffmpeg-devel fontconfig-devel glu-devel libarchive-devel
+makedepends="SFML-devel ffmpeg4-devel fontconfig-devel glu-devel libarchive-devel
  libcurl-devel libjpeg-turbo-devel xine-lib rapidjson libXrandr-devel"
 depends="git"
 short_desc="Attract-Mode is a graphical frontend for emulators"

From 588b70adcb070b5bcac91cfdfe53ff3f9e614bc7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 015/115] aubio: revbump for ffmpeg-6.0

---
 srcpkgs/aubio/patches/ffmpeg5.patch | 25 +++++++++++++++++++++++++
 srcpkgs/aubio/template              |  2 +-
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/aubio/patches/ffmpeg5.patch

diff --git a/srcpkgs/aubio/patches/ffmpeg5.patch b/srcpkgs/aubio/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..aace41a6e6d9a
--- /dev/null
+++ b/srcpkgs/aubio/patches/ffmpeg5.patch
@@ -0,0 +1,25 @@
+From 8a05420e5dd8c7b8b2447f82dc919765876511b3 Mon Sep 17 00:00:00 2001
+From: Paul Brossier <piem@piem.org>
+Date: Tue, 25 Jan 2022 18:30:27 +0100
+Subject: [PATCH] [source_avcodec] define FF_API_LAVF_AVCTX for libavcodec >
+ 59, thx @berolinux (closes gh-353)
+
+---
+ src/io/source_avcodec.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/io/source_avcodec.c b/src/io/source_avcodec.c
+index e0ae93b5..1421bd9a 100644
+--- a/src/io/source_avcodec.c
++++ b/src/io/source_avcodec.c
+@@ -68,6 +68,10 @@
+ #define AUBIO_AVCODEC_MAX_BUFFER_SIZE AV_INPUT_BUFFER_MIN_SIZE
+ #endif
+ 
++#if LIBAVCODEC_VERSION_MAJOR >= 59
++#define FF_API_LAVF_AVCTX 1
++#endif
++
+ struct _aubio_source_avcodec_t {
+   uint_t hop_size;
+   uint_t samplerate;
diff --git a/srcpkgs/aubio/template b/srcpkgs/aubio/template
index ad1c4b2569917..7d875cc02541a 100644
--- a/srcpkgs/aubio/template
+++ b/srcpkgs/aubio/template
@@ -1,7 +1,7 @@
 # Template file for 'aubio'
 pkgname=aubio
 version=0.4.9
-revision=1
+revision=2
 build_style=waf3
 # XXX lash, pure and swig support.
 hostmakedepends="pkg-config txt2man"

From fd385cf7d2f37c3e96fa14de5d118ce7398a134f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 016/115] audacious-plugins: revbump for ffmpeg-6.0

---
 .../audacious-plugins/patches/ffmpeg5.patch   | 43 +++++++++++++++++++
 srcpkgs/audacious-plugins/template            |  2 +-
 2 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/audacious-plugins/patches/ffmpeg5.patch

diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg5.patch b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..4e5e34099d71c
--- /dev/null
+++ b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
@@ -0,0 +1,43 @@
+commit 298aa371c56c2f52c25a33d9bdec4918b11cebdc
+Author: tibequadorian <tibequadorian@posteo.de>
+Date:   Sat Mar 19 18:40:12 2022 +0100
+
+    audacious-plugins: rebuild against ffmpeg-5.0
+
+diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+new file mode 100644
+index 0000000000..617c11215b
+--- /dev/null
++++ b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+@@ -0,0 +1,31 @@
++From f60beb400eeb1e4778bbfd738bc4a4ccef3de539 Mon Sep 17 00:00:00 2001
++From: John Lindgren <john@jlindgren.net>
++Date: Sat, 5 Mar 2022 12:05:34 -0500
++Subject: [PATCH] Fix build with FFmpeg 5.0
++
++---
++ src/ffaudio/ffaudio-core.cc | 4 ++--
++ 1 file changed, 2 insertions(+), 2 deletions(-)
++
++diff --git a/src/ffaudio/ffaudio-core.cc b/src/ffaudio/ffaudio-core.cc
++index 16dc63e3a..a2b95fd6c 100644
++--- a/src/ffaudio/ffaudio-core.cc
+++++ b/src/ffaudio/ffaudio-core.cc
++@@ -274,7 +274,7 @@ static AVInputFormat * get_format_by_content (const char * name, VFSFile & file)
++         AVProbeData d = {name, buf, filled};
++         score = target;
++ 
++-        f = av_probe_input_format2 (& d, true, & score);
+++        f = (AVInputFormat *) av_probe_input_format2 (& d, true, & score);
++         if (f)
++             break;
++ 
++@@ -347,7 +347,7 @@ static bool find_codec (AVFormatContext * c, CodecInfo * cinfo)
++ #endif
++         if (stream && stream->codecpar && stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
++         {
++-            AVCodec * codec = avcodec_find_decoder (stream->codecpar->codec_id);
+++            AVCodec * codec = (AVCodec *) avcodec_find_decoder (stream->codecpar->codec_id);
++ 
++             if (codec)
++             {
diff --git a/srcpkgs/audacious-plugins/template b/srcpkgs/audacious-plugins/template
index 88cbc1671fc6a..beebfae59ed44 100644
--- a/srcpkgs/audacious-plugins/template
+++ b/srcpkgs/audacious-plugins/template
@@ -2,7 +2,7 @@
 #Keep in sync with audacious!
 pkgname=audacious-plugins
 version=4.3.1
-revision=1
+revision=2
 build_style=meson
 configure_args="$(vopt_bool gtk3 gtk) $(vopt_bool gtk3)
  $(vopt_bool qt) $(vopt_bool qt qt6)"

From 7490a3d397abb3e05f6aecf4d3cf18b770530b3b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 017/115] audacity: revbump for ffmpeg4-4.4.3

---
 srcpkgs/audacity/template | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/audacity/template b/srcpkgs/audacity/template
index 28e9c4a3528f1..4e5125bae03b9 100644
--- a/srcpkgs/audacity/template
+++ b/srcpkgs/audacity/template
@@ -1,7 +1,7 @@
 # Template file for 'audacity'
 pkgname=audacity
 version=2.4.1
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--with-ffmpeg=system --with-libsndfile=system --with-expat=system
  --with-libsoxr=system --with-lame=system --with-lv2=system ac_cv_path_WX_CONFIG=wx-config-gtk3"
@@ -9,7 +9,7 @@ hostmakedepends="pkg-config cmake gettext libtool m4 which"
 makedepends="jack-devel wxWidgets-gtk3-devel gtk+3-devel
  libmad-devel soundtouch-devel libsoxr-devel
  vamp-plugin-sdk-devel lame-devel libid3tag-devel libflac-devel
- ffmpeg-devel twolame-devel serd-devel lv2 lilv-devel suil-devel"
+ ffmpeg4-devel twolame-devel serd-devel lv2 lilv-devel suil-devel"
 depends="desktop-file-utils hicolor-icon-theme"
 short_desc="Graphical cross-platform audio editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
@@ -32,5 +32,4 @@ post_install() {
 	vcopy plug-ins /usr/share/audacity
 
 	rm ${DESTDIR}/usr/share/doc/audacity/LICENSE.txt
-	vlicense LICENSE.txt LICENSE
 }

From 57f987dbad3e24cce93e7ae286f28f653b714754 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 018/115] avidemux: revbump for ffmpeg-6.0

---
 srcpkgs/avidemux/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/avidemux/template b/srcpkgs/avidemux/template
index 253a0243e2259..557285982d2b8 100644
--- a/srcpkgs/avidemux/template
+++ b/srcpkgs/avidemux/template
@@ -1,7 +1,7 @@
 # Template file for 'avidemux'
 pkgname=avidemux
 version=2.8.0
-revision=2
+revision=3
 # Can't be compiled for aarch64, arm* or mips*
 archs="x86_64* i686*"
 hostmakedepends="cmake pkg-config qt5-host-tools qt5-devel tar yasm"

From 88fb04079490112a4f5d29e1f05e1c2da4da06f7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 019/115] baresip: revbump for ffmpeg-6.0

---
 srcpkgs/baresip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/baresip/template b/srcpkgs/baresip/template
index f1bd1817048b5..b21e22334316e 100644
--- a/srcpkgs/baresip/template
+++ b/srcpkgs/baresip/template
@@ -1,7 +1,7 @@
 # Template file for 'baresip'
 pkgname=baresip
 version=2.10.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config glib-devel"
 makedepends="libgsm-devel libpng-devel openssl-devel libsndfile-devel

From e055cace4cb5d57ce9a64f362ae39101c208f8c8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 020/115] blender: revbump for ffmpeg-6.0

---
 srcpkgs/blender/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index 094f17c34c74c..3500ad95ad98b 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -1,7 +1,7 @@
 # Template file for 'blender'
 pkgname=blender
 version=3.6.1
-revision=1
+revision=2
 archs="x86_64* ppc64*"
 build_style="cmake"
 pycompile_dirs="/usr/share/blender/${version%.*}/scripts"
@@ -9,8 +9,8 @@ configure_args="-DWITH_INSTALL_PORTABLE=OFF -DWITH_PYTHON_INSTALL=OFF
  -DWITH_JACK=ON -DWITH_CODEC_FFMPEG=ON -DWITH_CODEC_SNDFILE=ON -DWITH_OPENMP=ON
  -DWITH_FFTW3=ON -DWITH_MOD_OCEANSIM=ON -DWITH_CYCLES_EMBREE=OFF -DWITH_OPENCOLORIO=ON
  -DWITH_IMAGE_OPENEXR=ON -DWITH_IMAGE_OPENJPEG=ON -DWITH_OPENSUBDIV=ON
- -DWITH_OPENCOLLADA=ON -DWITH_SYSTEM_GLEW=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
- -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_LIBDECOR=ON
+ -DWITH_OPENCOLLADA=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
+ -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_WAYLAND_LIBDECOR=ON
  -DWITH_BUILDINFO=OFF -DPYTHON_VERSION=${py3_ver} -DPYTHON_LIBPATH=/usr/lib
  -DPYTHON_LIBRARY=python${py3_ver}${py3_abiver} -DPYTHON_INCLUDE_DIRS=/${py3_inc}
  -DWITH_SYSTEM_LZO=ON -DWITH_SYSTEM_EIGEN3=ON -DWITH_SYSTEM_FREETYPE=ON"

From 7e55ad4847ff9daae080fee082940b2ba6e64d58 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 021/115] cantata: revbump for ffmpeg-6.0

---
 srcpkgs/cantata/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cantata/template b/srcpkgs/cantata/template
index 4b417d80d5c2d..8a90aaa4c07a2 100644
--- a/srcpkgs/cantata/template
+++ b/srcpkgs/cantata/template
@@ -1,7 +1,7 @@
 # Template file for 'cantata'
 pkgname=cantata
 version=2.5.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools qt5-tools"
 makedepends="qt5-devel qt5-tools-devel qt5-svg-devel qt5-xmlpatterns-devel

From 3fc2573f11e2c9d2185603d691e94d580d5a62e5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 022/115] ccextractor: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ccextractor/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/ccextractor/template b/srcpkgs/ccextractor/template
index 9abcd82852b27..6eccad5885af9 100644
--- a/srcpkgs/ccextractor/template
+++ b/srcpkgs/ccextractor/template
@@ -1,12 +1,12 @@
 # Template file for 'ccextractor'
 pkgname=ccextractor
 version=0.93
-revision=1
+revision=2
 build_wrksrc="linux"
 build_style=gnu-configure
 configure_args="--enable-ocr --enable-hardsubx"
 hostmakedepends="automake pkg-config"
-makedepends="leptonica-devel tesseract-ocr-devel ffmpeg-devel"
+makedepends="leptonica-devel tesseract-ocr-devel ffmpeg4-devel"
 short_desc="Extract subtitles from video streams"
 maintainer="newbluemoon <blaumolch@mailbox.org>"
 license="GPL-2.0-or-later"

From 20e04e47c9b620d53a54a8dbbf997177c3434d23 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 023/115] chromaprint: revbump for ffmpeg-6.0

---
 srcpkgs/chromaprint/patches/ffmpeg5.patch | 569 ++++++++++++++++++++++
 srcpkgs/chromaprint/template              |   2 +-
 2 files changed, 570 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromaprint/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromaprint/patches/ffmpeg5.patch b/srcpkgs/chromaprint/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..a9fd307a23c8a
--- /dev/null
+++ b/srcpkgs/chromaprint/patches/ffmpeg5.patch
@@ -0,0 +1,569 @@
+From 8ccad6937177b1b92e40ab8f4447ea27bac009a7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= <lalinsky@gmail.com>
+Date: Fri, 4 Nov 2022 21:47:38 +0100
+Subject: [PATCH] Use FFmpeg 5.x (#120)
+
+* Use FFmpeg 5.1.2 for CI builds
+
+* Build on Ubuntu 20.04
+
+* Upgrade code to FFmpeg 5.x APIs
+
+* Only set FFmpeg include dirs if building tools
+
+* No longer needed
+
+* Use ubuntu 20.04
+---
+ .github/workflows/build.yml                   |   6 +-
+ CMakeLists.txt                                |  16 --
+ package/build.sh                              |   4 +-
+ src/audio/ffmpeg_audio_processor.h            |   2 -
+ src/audio/ffmpeg_audio_processor_avresample.h |  72 -------
+ src/audio/ffmpeg_audio_processor_swresample.h |  18 +-
+ src/audio/ffmpeg_audio_reader.h               | 197 +++++++++---------
+ tests/CMakeLists.txt                          |   6 +
+ 8 files changed, 122 insertions(+), 199 deletions(-)
+ delete mode 100644 src/audio/ffmpeg_audio_processor_avresample.h
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index f8d6a32..4da2405 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -84,9 +84,6 @@ find_package(FFmpeg)
+ if(FFMPEG_LIBRARIES)
+ 	cmake_push_check_state(RESET)
+ 	set(CMAKE_REQUIRED_LIBRARIES ${FFMPEG_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -lm)
+-	check_function_exists(av_packet_unref HAVE_AV_PACKET_UNREF)
+-	check_function_exists(av_frame_alloc HAVE_AV_FRAME_ALLOC)
+-	check_function_exists(av_frame_free HAVE_AV_FRAME_FREE)
+ 	cmake_pop_check_state()
+ endif()
+
+@@ -163,14 +160,11 @@ message(STATUS "Using ${FFT_LIB} for FFT calculations")
+ if(NOT AUDIO_PROCESSOR_LIB)
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+ 		set(AUDIO_PROCESSOR_LIB "swresample")
+-	elseif(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(AUDIO_PROCESSOR_LIB "avresample")
+ 	endif()
+ endif()
+
+ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE OFF)
+ 		set(USE_SWRESAMPLE ON)
+ 		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBSWRESAMPLE_LIBRARIES})
+ 		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBSWRESAMPLE_INCLUDE_DIRS})
+@@ -178,16 +172,6 @@ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+ 	endif()
+ 	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+-elseif(AUDIO_PROCESSOR_LIB STREQUAL "avresample")
+-	if(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE ON)
+-		set(USE_SWRESAMPLE OFF)
+-		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBAVRESAMPLE_LIBRARIES})
+-		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBAVRESAMPLE_INCLUDE_DIRS})
+-	else()
+-		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+-	endif()
+-	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+ else()
+ 	message(STATUS "Building without audio conversion support, please install FFmpeg with libswresample")
+ endif()
+diff --git a/package/build.sh b/package/build.sh
+index da631ae..b41d36e 100755
+--- a/package/build.sh
++++ b/package/build.sh
+@@ -7,8 +7,8 @@ set -eux
+
+ BASE_DIR=$(cd $(dirname $0)/.. && pwd)
+
+-FFMPEG_VERSION=4.4.1
+-FFMPEG_BUILD_TAG=v4.4.1-1
++FFMPEG_VERSION=5.1.2
++FFMPEG_BUILD_TAG=v${FFMPEG_VERSION}-1
+
+ TMP_BUILD_DIR=$BASE_DIR/$(mktemp -d build.XXXXXXXX)
+ trap 'rm -rf $TMP_BUILD_DIR' EXIT
+diff --git a/src/audio/ffmpeg_audio_processor.h b/src/audio/ffmpeg_audio_processor.h
+index 7628fc7..39f4f6d 100644
+--- a/src/audio/ffmpeg_audio_processor.h
++++ b/src/audio/ffmpeg_audio_processor.h
+@@ -10,8 +10,6 @@
+
+ #if defined(USE_SWRESAMPLE)
+ #include "audio/ffmpeg_audio_processor_swresample.h"
+-#elif defined(USE_AVRESAMPLE)
+-#include "audio/ffmpeg_audio_processor_avresample.h"
+ #else
+ #error "no audio processing library"
+ #endif
+diff --git a/src/audio/ffmpeg_audio_processor_avresample.h b/src/audio/ffmpeg_audio_processor_avresample.h
+deleted file mode 100644
+index bd85f92..0000000
+--- a/src/audio/ffmpeg_audio_processor_avresample.h
++++ /dev/null
+@@ -1,72 +0,0 @@
+-// Copyright (C) 2016  Lukas Lalinsky
+-// Distributed under the MIT license, see the LICENSE file for details.
+-
+-#ifndef CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-#define CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-
+-extern "C" {
+-#include <libavresample/avresample.h>
+-}
+-
+-namespace chromaprint {
+-
+-class FFmpegAudioProcessor {
+-public:
+-	FFmpegAudioProcessor() {
+-		m_resample_ctx = avresample_alloc_context();
+-	}
+-
+-	~FFmpegAudioProcessor() {
+-		avresample_free(&m_resample_ctx);
+-	}
+-
+-	void SetCompatibleMode() {
+-		av_opt_set_int(m_resample_ctx, "filter_size", 16, 0);
+-		av_opt_set_int(m_resample_ctx, "phase_shift", 8, 0);
+-		av_opt_set_int(m_resample_ctx, "linear_interp", 1, 0);
+-		av_opt_set_double(m_resample_ctx, "cutoff", 0.8, 0);
+-	}
+-
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "in_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_rate", sample_rate, 0);
+-	}
+-
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "out_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_rate, 0);
+-	}
+-
+-	int Init() {
+-		return avresample_open(m_resample_ctx);
+-	}
+-
+-	int Convert(uint8_t **out, int out_count, const uint8_t **in, int in_count) {
+-		return avresample_convert(m_resample_ctx, out, 0, out_count, (uint8_t **) in, 0, in_count);
+-	}
+-
+-	int Flush(uint8_t **out, int out_count) {
+-		return avresample_read(m_resample_ctx, out, out_count);
+-	}
+-
+-private:
+-	AVAudioResampleContext *m_resample_ctx = nullptr;
+-};
+-
+-}; // namespace chromaprint
+-
+-#endif
+diff --git a/src/audio/ffmpeg_audio_processor_swresample.h b/src/audio/ffmpeg_audio_processor_swresample.h
+index b86266b..b1d4bea 100644
+--- a/src/audio/ffmpeg_audio_processor_swresample.h
++++ b/src/audio/ffmpeg_audio_processor_swresample.h
+@@ -28,30 +28,28 @@ public:
+ 		av_opt_set_double(m_swr_ctx, "cutoff", 0.8, 0);
+ 	}
+
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "icl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "ich", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetInputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "in_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "isf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "in_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "isr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "in_sample_rate", sample_rate, 0);
+ 	}
+
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "ocl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "och", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetOutputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "out_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "osf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "out_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "osr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "out_sample_rate", sample_rate, 0);
+ 	}
+
+ 	int Init() {
+diff --git a/src/audio/ffmpeg_audio_reader.h b/src/audio/ffmpeg_audio_reader.h
+index 5550164..1c6b346 100644
+--- a/src/audio/ffmpeg_audio_reader.h
++++ b/src/audio/ffmpeg_audio_reader.h
+@@ -62,7 +62,7 @@ public:
+ 	bool Read(const int16_t **data, size_t *size);
+
+ 	bool IsOpen() const { return m_opened; }
+-	bool IsFinished() const { return m_finished && !m_got_frame; }
++	bool IsFinished() const { return !m_has_more_packets && !m_has_more_frames; }
+
+ 	std::string GetError() const { return m_error; }
+ 	int GetErrorCode() const { return m_error_code; }
+@@ -74,20 +74,19 @@ private:
+ 	uint8_t *m_convert_buffer[1] = { nullptr };
+ 	int m_convert_buffer_nb_samples = 0;
+
+-	AVInputFormat *m_input_fmt = nullptr;
++	const AVInputFormat *m_input_fmt = nullptr;
+ 	AVDictionary *m_input_opts = nullptr;
+
+ 	AVFormatContext *m_format_ctx = nullptr;
+ 	AVCodecContext *m_codec_ctx = nullptr;
+-	AVFrame *m_frame = nullptr;
+ 	int m_stream_index = -1;
+ 	std::string m_error;
+ 	int m_error_code = 0;
+-	bool m_finished = false;
+ 	bool m_opened = false;
+-	int m_got_frame = 0;
+-	AVPacket m_packet;
+-	AVPacket m_packet0;
++	bool m_has_more_packets = true;
++	bool m_has_more_frames = true;
++	AVPacket *m_packet = nullptr;
++	AVFrame *m_frame = nullptr;
+
+ 	int m_output_sample_rate = 0;
+ 	int m_output_channels = 0;
+@@ -98,19 +97,12 @@ private:
+
+ inline FFmpegAudioReader::FFmpegAudioReader() {
+ 	av_log_set_level(AV_LOG_QUIET);
+-
+-	av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
+ }
+
+ inline FFmpegAudioReader::~FFmpegAudioReader() {
+ 	Close();
+ 	av_dict_free(&m_input_opts);
+ 	av_freep(&m_convert_buffer[0]);
+-	av_packet_unref(&m_packet0);
+ }
+
+ inline bool FFmpegAudioReader::SetInputFormat(const char *name) {
+@@ -135,11 +127,10 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ 	Close();
+
+-    av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
++	m_packet = av_packet_alloc();
++	if (!m_packet) {
++		return false;
++	}
+
+ 	ret = avformat_open_input(&m_format_ctx, file_name.c_str(), m_input_fmt, &m_input_opts);
+ 	if (ret < 0) {
+@@ -153,26 +144,31 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		return false;
+ 	}
+
+-	AVCodec *codec;
++	const AVCodec *codec;
+ 	ret = av_find_best_stream(m_format_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &codec, 0);
+ 	if (ret < 0) {
+ 		SetError("Could not find any audio stream in the file", ret);
+ 		return false;
+ 	}
+ 	m_stream_index = ret;
++	auto stream = m_format_ctx->streams[m_stream_index];
+
+-	m_codec_ctx = m_format_ctx->streams[m_stream_index]->codec;
++	m_codec_ctx = avcodec_alloc_context3(codec);
+ 	m_codec_ctx->request_sample_fmt = AV_SAMPLE_FMT_S16;
+
++	ret = avcodec_parameters_to_context(m_codec_ctx, stream->codecpar);
++	if (ret < 0) {
++		SetError("Could not copy the stream parameters", ret);
++		return false;
++	}
++
+ 	ret = avcodec_open2(m_codec_ctx, codec, nullptr);
+ 	if (ret < 0) {
+ 		SetError("Could not open the codec", ret);
+ 		return false;
+ 	}
+
+-	if (!m_codec_ctx->channel_layout) {
+-		m_codec_ctx->channel_layout = av_get_default_channel_layout(m_codec_ctx->channels);
+-	}
++	av_dump_format(m_format_ctx, 0, "foo", 0);
+
+ 	m_frame = av_frame_alloc();
+ 	if (!m_frame) {
+@@ -183,19 +179,23 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		m_output_sample_rate = m_codec_ctx->sample_rate;
+ 	}
+
+-	if (!m_output_channels) {
+-		m_output_channels = m_codec_ctx->channels;
++	AVChannelLayout output_channel_layout;
++	if (m_output_channels) {
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
++	} else {
++		m_output_channels = m_codec_ctx->ch_layout.nb_channels;
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
+ 	}
+
+-	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
++	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->ch_layout.nb_channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
+ 		m_converter.reset(new FFmpegAudioProcessor());
+ 		m_converter->SetCompatibleMode();
+ 		m_converter->SetInputSampleFormat(m_codec_ctx->sample_fmt);
+ 		m_converter->SetInputSampleRate(m_codec_ctx->sample_rate);
+-		m_converter->SetInputChannelLayout(m_codec_ctx->channel_layout);
++		m_converter->SetInputChannelLayout(&(m_codec_ctx->ch_layout));
+ 		m_converter->SetOutputSampleFormat(AV_SAMPLE_FMT_S16);
+ 		m_converter->SetOutputSampleRate(m_output_sample_rate);
+-		m_converter->SetOutputChannelLayout(av_get_default_channel_layout(m_output_channels));
++		m_converter->SetOutputChannelLayout(&output_channel_layout);
+ 		auto ret = m_converter->Init();
+ 		if (ret != 0) {
+ 			SetError("Could not create an audio converter instance", ret);
+@@ -203,10 +203,11 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		}
+ 	}
+
++	av_channel_layout_uninit(&output_channel_layout);
++
+ 	m_opened = true;
+-	m_finished = false;
+-	m_got_frame = 0;
+-	m_nb_packets = 0;
++	m_has_more_packets = true;
++	m_has_more_frames = true;
+ 	m_decode_error = 0;
+
+ 	return true;
+@@ -214,6 +215,7 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ inline void FFmpegAudioReader::Close() {
+ 	av_frame_free(&m_frame);
++	av_packet_free(&m_packet);
+
+ 	m_stream_index = -1;
+
+@@ -252,91 +254,98 @@ inline bool FFmpegAudioReader::Read(const int16_t **data, size_t *size) {
+ 		return false;
+ 	}
+
++	*data = nullptr;
++	*size = 0;
++
+ 	int ret;
++	bool needs_packet = false;
+ 	while (true) {
+-		while (m_packet.size <= 0) {
+-			av_packet_unref(&m_packet0);
+-			av_init_packet(&m_packet);
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			ret = av_read_frame(m_format_ctx, &m_packet);
++		while (needs_packet && m_packet->size == 0) {
++			ret = av_read_frame(m_format_ctx, m_packet);
+ 			if (ret < 0) {
+ 				if (ret == AVERROR_EOF) {
+-					m_finished = true;
++					needs_packet = false;
++					m_has_more_packets = false;
+ 					break;
+-				} else {
++				}
++				SetError("Error reading from the audio source", ret);
++				return false;
++			}
++			if (m_packet->stream_index == m_stream_index) {
++				needs_packet = false;
++			} else {
++				av_packet_unref(m_packet);
++			}
++		}
++
++		if (m_packet->size != 0) {
++			ret = avcodec_send_packet(m_codec_ctx, m_packet);
++			if (ret < 0) {
++				if (ret != AVERROR(EAGAIN)) {
+ 					SetError("Error reading from the audio source", ret);
+ 					return false;
+ 				}
+-			}
+-			m_packet0 = m_packet;
+-			if (m_packet.stream_index != m_stream_index) {
+-				m_packet.data = nullptr;
+-				m_packet.size = 0;
+ 			} else {
+-				m_nb_packets++;
++				av_packet_unref(m_packet);
+ 			}
+ 		}
+
+-		ret = avcodec_decode_audio4(m_codec_ctx, m_frame, &m_got_frame, &m_packet);
++		ret = avcodec_receive_frame(m_codec_ctx, m_frame);
+ 		if (ret < 0) {
+-			if (m_decode_error) {
+-				SetError("Error decoding audio frame", m_decode_error);
+-				return false;
++			if (ret == AVERROR_EOF) {
++				m_has_more_frames = false;
++			} else if (ret == AVERROR(EAGAIN)) {
++				if (m_has_more_packets) {
++					needs_packet = true;
++					continue;
++				} else {
++					m_has_more_frames = false;
++				}
+ 			}
+-			m_decode_error = ret;
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			continue;
++			SetError("Error decoding the audio source", ret);
++			return false;
+ 		}
+
+-		break;
+-	}
+-
+-	m_decode_error = 0;
+-
+-	const int decoded = std::min(ret, m_packet.size);
+-	m_packet.data += decoded;
+-	m_packet.size -= decoded;
+-
+-	if (m_got_frame) {
+-		if (m_converter) {
+-			if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
+-				int linsize;
+-				av_freep(&m_convert_buffer[0]);
+-				m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
+-				ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
+-				if (ret < 0) {
+-					SetError("Couldn't allocate audio converter buffer", ret);
++		if (m_frame->nb_samples > 0) {
++			if (m_converter) {
++				if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
++					int linsize;
++					av_freep(&m_convert_buffer[0]);
++					m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
++					ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->ch_layout.nb_channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
++					if (ret < 0) {
++						SetError("Couldn't allocate audio converter buffer", ret);
++						return false;
++					}
++				}
++				auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
++				if (nb_samples < 0) {
++					SetError("Couldn't convert audio", ret);
+ 					return false;
+ 				}
+-			}
+-			auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			}
+-			*data = (const int16_t *) m_convert_buffer[0];
+-			*size = nb_samples;
+-		} else {
+-			*data = (const int16_t *) m_frame->data[0];
+-			*size = m_frame->nb_samples;
+-		}
+-	} else {
+-		if (m_finished && m_converter) {
+-			auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			} else if (nb_samples > 0) {
+-				m_got_frame = 1;
+ 				*data = (const int16_t *) m_convert_buffer[0];
+ 				*size = nb_samples;
++			} else {
++				*data = (const int16_t *) m_frame->data[0];
++				*size = m_frame->nb_samples;
++			}
++		} else {
++			if (m_converter) {
++				if (IsFinished()) {
++					auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
++					if (nb_samples < 0) {
++						SetError("Couldn't convert audio", ret);
++						return false;
++					} else if (nb_samples > 0) {
++						*data = (const int16_t *) m_convert_buffer[0];
++						*size = nb_samples;
++					}
++				}
+ 			}
+ 		}
+-	}
+
+-	return true;
++		return true;
++	}
+ }
+
+ inline void FFmpegAudioReader::SetError(const char *message, int errnum) {
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index a2b517b..123e643 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -38,6 +38,12 @@ set(SRCS
+
+ if(BUILD_TOOLS)
+ 	set(SRCS ${SRCS} ../src/audio/ffmpeg_audio_reader_test.cpp)
++    include_directories(
++        ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}
++        ${AUDIO_PROCESSOR_INCLUDE_DIRS}
++    )
+ 	link_libraries(fpcalc_libs)
+ endif()
+
+-- 
+2.38.1
+
+
diff --git a/srcpkgs/chromaprint/template b/srcpkgs/chromaprint/template
index 7ef7838949f3a..1f7bbc70a22c8 100644
--- a/srcpkgs/chromaprint/template
+++ b/srcpkgs/chromaprint/template
@@ -1,7 +1,7 @@
 # Template file for 'chromaprint'
 pkgname=chromaprint
 version=1.5.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DBUILD_TOOLS=ON"
 make_check_target="check"

From 1c9367b7cbcb4ae94e2685161c93658f5871b92b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 024/115] chromium: revbump for ffmpeg-6.0

---
 .../patches/chromium-93-ffmpeg-4.4.patch      | 36 --------------
 srcpkgs/chromium/patches/ffmpeg5.patch        | 47 +++++++++++++++++++
 srcpkgs/chromium/template                     |  2 +-
 3 files changed, 48 insertions(+), 37 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch
 create mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch b/srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch
deleted file mode 100644
index f0ec736f98bc7..0000000000000
--- a/srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch
+++ /dev/null
@@ -1,36 +0,0 @@
-diff --git a/media/filters/ffmpeg_demuxer.cc b/media/filters/ffmpeg_demuxer.cc
-index ac4713b07268..492a9a37d096 100644
---- a/media/filters/ffmpeg_demuxer.cc
-+++ b/media/filters/ffmpeg_demuxer.cc
-@@ -427,11 +427,11 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
-   scoped_refptr<DecoderBuffer> buffer;
- 
-   if (type() == DemuxerStream::TEXT) {
--    size_t id_size = 0;
-+    int id_size = 0;
-     uint8_t* id_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
- 
--    size_t settings_size = 0;
-+    int settings_size = 0;
-     uint8_t* settings_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
- 
-@@ -443,7 +443,7 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
-     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
-                                      side_data.data(), side_data.size());
-   } else {
--    size_t side_data_size = 0;
-+    int side_data_size = 0;
-     uint8_t* side_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
- 
-@@ -504,7 +504,7 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
-                                        packet->size - data_offset);
-     }
- 
--    size_t skip_samples_size = 0;
-+    int skip_samples_size = 0;
-     const uint32_t* skip_samples_ptr =
-         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
-             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..24e2da38e34ca
--- /dev/null
+++ b/srcpkgs/chromium/patches/ffmpeg5.patch
@@ -0,0 +1,47 @@
+--- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
++++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
+@@ -92,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+-  if (stream->start_time != kNoFFmpegTimestamp)
++  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -1597,7 +1585,7 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+@@ -1618,7 +1606,7 @@
+     if (stream->type() != DemuxerStream::VIDEO)
+       continue;
+ 
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+ 
+     if (!stream->IsEnabled())
diff --git a/srcpkgs/chromium/template b/srcpkgs/chromium/template
index da966f5303796..9dc7d12871c2d 100644
--- a/srcpkgs/chromium/template
+++ b/srcpkgs/chromium/template
@@ -2,7 +2,7 @@
 pkgname=chromium
 # See https://chromiumdash.appspot.com/releases?platform=Linux for the latest version
 version=115.0.5790.98
-revision=1
+revision=2
 archs="i686* x86_64* aarch64* armv7l*"
 hostmakedepends="
  $(vopt_if clang "clang lld llvm15")

From 4c3a12669609c6199a3e2c72898415e5b418d19f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 025/115] cmus: revbump for ffmpeg-6.0

---
 srcpkgs/cmus/patches/ffmpeg6.patch | 12 ++++++++++++
 srcpkgs/cmus/template              |  2 +-
 2 files changed, 13 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/cmus/patches/ffmpeg6.patch

diff --git a/srcpkgs/cmus/patches/ffmpeg6.patch b/srcpkgs/cmus/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..ffa95ab811101
--- /dev/null
+++ b/srcpkgs/cmus/patches/ffmpeg6.patch
@@ -0,0 +1,12 @@
+--- a/ip/ffmpeg.c
++++ b/ip/ffmpeg.c
+@@ -202,9 +202,6 @@ static int ffmpeg_open(struct input_plugin_data *ip_data)
+ 			break;
+ 		}
+ 
+-		if (codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+-			cc->flags |= AV_CODEC_FLAG_TRUNCATED;
+-
+ 		if (avcodec_open2(cc, codec, NULL) < 0) {
+ 			d_print("could not open codec: %d, %s\n", cc->codec_id, avcodec_get_name(cc->codec_id));
+ 			err = -IP_ERROR_UNSUPPORTED_FILE_TYPE;
diff --git a/srcpkgs/cmus/template b/srcpkgs/cmus/template
index 0fdcec461c217..6c07e25e6d727 100644
--- a/srcpkgs/cmus/template
+++ b/srcpkgs/cmus/template
@@ -1,7 +1,7 @@
 # Template file for 'cmus'
 pkgname=cmus
 version=2.10.0
-revision=1
+revision=2
 build_style=configure
 configure_args="prefix=/usr LD=$CC"
 hostmakedepends="pkg-config"

From d9dd81367a07d06effb2c13a3ad34410a7d23ad0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 026/115] cyanrip: revbump for ffmpeg-6.0

---
 srcpkgs/cyanrip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cyanrip/template b/srcpkgs/cyanrip/template
index 9796e3461601a..5db30e020d17e 100644
--- a/srcpkgs/cyanrip/template
+++ b/srcpkgs/cyanrip/template
@@ -1,7 +1,7 @@
 # Template file for 'cyanrip'
 pkgname=cyanrip
 version=0.9.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config"
 makedepends="ffmpeg-devel libcdio-devel libcdio-paranoia-devel libcurl-devel libmusicbrainz5-devel"

From 970362a81261d53c5380c8eb834ad2abf917969e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 027/115] deadbeef: revbump for ffmpeg4-4.4.3

---
 srcpkgs/deadbeef/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/deadbeef/template b/srcpkgs/deadbeef/template
index b664bb1b9bd9f..165b3c7b9cad8 100644
--- a/srcpkgs/deadbeef/template
+++ b/srcpkgs/deadbeef/template
@@ -1,14 +1,14 @@
 # Template file for 'deadbeef'
 pkgname=deadbeef
 version=1.8.8
-revision=1
+revision=2
 create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-oss --disable-lfm --disable-notify --disable-gtk2"
 hostmakedepends="automake libtool gettext gettext-devel intltool pkg-config
  yasm clang glib-devel"
 makedepends="
- alsa-lib-devel dbus-devel faad2-devel ffmpeg-devel gtk+3-devel imlib2-devel
+ alsa-lib-devel dbus-devel faad2-devel ffmpeg4-devel gtk+3-devel imlib2-devel
  jansson-devel libcddb-devel libcdio-devel libcurl-devel libflac-devel
  libmad-devel libpng-devel libsamplerate-devel libsndfile-devel libvorbis-devel
  libzip-devel mpg123-devel opusfile-devel pulseaudio-devel wavpack-devel"

From a6d6d8813b6ac37a178eb5fc4ce3f11a57aa8522 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 028/115] dolphin-emu: revbump for ffmpeg-6.0

---
 srcpkgs/dolphin-emu/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/dolphin-emu/template b/srcpkgs/dolphin-emu/template
index b4c8b64368a4b..070993aac31d2 100644
--- a/srcpkgs/dolphin-emu/template
+++ b/srcpkgs/dolphin-emu/template
@@ -1,7 +1,7 @@
 # Template file for 'dolphin-emu'
 pkgname=dolphin-emu
 version=5.0.19368
-revision=1
+revision=2
 _dolphin_commit=dadbeb4bae7e7fa23af2b46e0add4143094dc107
 _mgba_commit=44e074a15e9651481f7f652ac006a7c9d58cbeb9
 _googletest_commit=be03d00f5f0cc3a997d1a368bee8a1fe93651f48

From 99324235a7001a3ba368e21167122fb16fdcb562 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 029/115] droidcam-obs-plugin: revbump for ffmpeg-6.0

---
 srcpkgs/droidcam-obs-plugin/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam-obs-plugin/template b/srcpkgs/droidcam-obs-plugin/template
index fc9c9bf6b9d54..fb0480754df4d 100644
--- a/srcpkgs/droidcam-obs-plugin/template
+++ b/srcpkgs/droidcam-obs-plugin/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam-obs-plugin'
 pkgname=droidcam-obs-plugin
 version=2.0.1
-revision=1
+revision=2
 build_style=gnu-makefile
 make_use_env=yes
 make_build_args="ALLOW_STATIC=no"

From 0a11433d95957dfd9d7e8bf78e4fa7699cfc0bc8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 030/115] droidcam: revbump for ffmpeg-6.0

---
 srcpkgs/droidcam/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam/template b/srcpkgs/droidcam/template
index 1c3f1b8b1fc67..32a9220b79a4d 100644
--- a/srcpkgs/droidcam/template
+++ b/srcpkgs/droidcam/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam'
 pkgname=droidcam
 version=1.8.2
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="USBMUXD=-lusbmuxd-2.0 JPEG=-lturbojpeg"
 hostmakedepends="pkg-config"

From de7e9e730a378999f1078c59726ee68dfb3e181a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 031/115] ffmpegthumbnailer: revbump for ffmpeg-6.0

---
 .../ffmpegthumbnailer/patches/ffmpeg6.patch   | 202 ++++++++++++++++++
 srcpkgs/ffmpegthumbnailer/template            |   6 +-
 2 files changed, 205 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch

diff --git a/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..363ff35a28419
--- /dev/null
+++ b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
@@ -0,0 +1,202 @@
+--- a/libffmpegthumbnailer/moviedecoder.cpp	2017-11-21 14:06:57.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.cpp	2023-05-05 13:14:47.946560668 -0400
+@@ -41,11 +41,6 @@
+ namespace ffmpegthumbnailer
+ {
+ 
+-struct SilenceLogLevel
+-{
+-    SilenceLogLevel() { av_log_set_level(AV_LOG_QUIET); }
+-};
+-
+ MovieDecoder::MovieDecoder(AVFormatContext* pavContext)
+ : m_VideoStream(-1)
+ , m_pFormatContext(pavContext)
+@@ -70,8 +65,6 @@
+ 
+ void MovieDecoder::initialize(const string& filename, bool preferEmbeddedMetadata)
+ {
+-    av_register_all();
+-    avcodec_register_all();
+     avformat_network_init();
+ 
+     string inputFile = filename == "-" ? "pipe:" : filename;
+@@ -97,8 +90,7 @@
+ {
+     if (m_pVideoCodecContext)
+     {
+-        avcodec_close(m_pVideoCodecContext);
+-        m_pVideoCodecContext = nullptr;
++        avcodec_free_context(&m_pVideoCodecContext);
+     }
+ 
+     if ((!m_FormatContextWasGiven) && m_pFormatContext)
+@@ -152,10 +144,10 @@
+     for (unsigned int i = 0; i < m_pFormatContext->nb_streams; ++i)
+     {
+         AVStream *stream = m_pFormatContext->streams[i];
+-        auto ctx = m_pFormatContext->streams[i]->codec;
+-        if (ctx->codec_type == AVMEDIA_TYPE_VIDEO)
++        auto par = m_pFormatContext->streams[i]->codecpar;
++        if (par->codec_type == AVMEDIA_TYPE_VIDEO)
+         {
+-            if (!preferEmbeddedMetadata || !isStillImageCodec(ctx->codec_id))
++            if (!preferEmbeddedMetadata || !isStillImageCodec(par->codec_id))
+             {
+                 videoStreams.push_back(i);
+                 continue;
+@@ -203,8 +195,7 @@
+     }
+ 
+     m_pVideoStream = m_pFormatContext->streams[m_VideoStream];
+-    m_pVideoCodecContext = m_pVideoStream->codec;
+-    m_pVideoCodec = avcodec_find_decoder(m_pVideoCodecContext->codec_id);
++    m_pVideoCodec = avcodec_find_decoder(m_pVideoStream->codecpar->codec_id);
+ 
+     if (m_pVideoCodec == nullptr)
+     {
+@@ -214,6 +205,20 @@
+         throw logic_error("Video Codec not found");
+     }
+ 
++    m_pVideoCodecContext = avcodec_alloc_context3(m_pVideoCodec);
++
++    if (m_pVideoCodecContext == nullptr)
++    {
++        destroy();
++        throw logic_error("Could not allocate video codec context");
++    }
++
++    if (avcodec_parameters_to_context(m_pVideoCodecContext, m_pVideoStream->codecpar) < 0)
++    {
++        destroy();
++        throw logic_error("Could not configure video codec context");
++    }
++
+     m_pVideoCodecContext->workaround_bugs = 1;
+ 
+     if (avcodec_open2(m_pVideoCodecContext, m_pVideoCodec, nullptr) < 0)
+@@ -386,13 +391,6 @@
+ 
+ void MovieDecoder::initializeFilterGraph(const AVRational& timeBase, const std::string& size, bool maintainAspectRatio)
+ {
+-    static const AVPixelFormat pixelFormats[] = { AV_PIX_FMT_RGB24, AV_PIX_FMT_NONE };
+-
+-    auto del = [] (AVBufferSinkParams* p) { av_freep(p); };
+-    std::unique_ptr<AVBufferSinkParams, decltype(del)> buffersinkParams(av_buffersink_params_alloc(), del);
+-
+-    avfilter_register_all();
+-
+     m_pFilterGraph = avfilter_graph_alloc();
+     assert(m_pFilterGraph);
+ 
+@@ -404,10 +402,8 @@
+ 
+     checkRc(avfilter_graph_create_filter(&m_pFilterSource, avfilter_get_by_name("buffer"), "thumb_buffer", ss.str().c_str(), nullptr, m_pFilterGraph),
+             "Failed to create filter source");
+-    buffersinkParams->pixel_fmts = pixelFormats;
+-    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, buffersinkParams.get(), m_pFilterGraph),
++    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, nullptr, m_pFilterGraph),
+             "Failed to create filter sink");
+-    buffersinkParams.release();
+ 
+     AVFilterContext* yadifFilter = nullptr;
+     if (m_pFrame->interlaced_frame != 0)
+@@ -500,15 +496,15 @@
+     }
+ 
+     checkRc(av_seek_frame(m_pFormatContext, -1, timestamp, 0), "Seeking in video failed");
+-    avcodec_flush_buffers(m_pFormatContext->streams[m_VideoStream]->codec);
++    avcodec_flush_buffers(m_pVideoCodecContext);
+ 
+     int keyFrameAttempts = 0;
+-    bool gotFrame = 0;
++    bool gotFrame;
+ 
+     do
+     {
+         int count = 0;
+-        gotFrame = 0;
++        gotFrame = false;
+ 
+         while (!gotFrame && count < 20)
+         {
+@@ -552,17 +548,33 @@
+         return false;
+     }
+ 
+-    av_frame_unref(m_pFrame);
+-
+-    int frameFinished;
++    int rc = avcodec_send_packet(m_pVideoCodecContext, m_pPacket);
++    if(rc == AVERROR(EAGAIN))
++    {
++        rc = 0;
++    }
+ 
+-    int bytesDecoded = avcodec_decode_video2(m_pVideoCodecContext, m_pFrame, &frameFinished, m_pPacket);
+-    if (bytesDecoded < 0)
++    if(rc == AVERROR_EOF)
++    {
++        return false;
++    }
++    else if(rc < 0)
+     {
+-        throw logic_error("Failed to decode video frame: bytesDecoded < 0");
++        throw logic_error("Failed to decode video frame: avcodec_send_packet() < 0");
+     }
+ 
+-    return frameFinished > 0;
++    rc = avcodec_receive_frame(m_pVideoCodecContext, m_pFrame);
++    switch(rc)
++    {
++        case 0:
++            return true;
++
++        case AVERROR(EAGAIN):
++            return false;
++
++        default:
++            throw logic_error("Failed to decode video frame: avcodec_receive_frame() < 0");
++    }
+ }
+ 
+ bool MovieDecoder::getVideoPacket()
+@@ -570,8 +582,6 @@
+     bool framesAvailable = true;
+     bool frameDecoded = false;
+ 
+-    int attempts = 0;
+-
+     if (m_pPacket)
+     {
+         av_packet_unref(m_pPacket);
+@@ -580,6 +590,7 @@
+ 
+     m_pPacket = new AVPacket();
+ 
++
+     while (framesAvailable && !frameDecoded)
+     {
+         framesAvailable = av_read_frame(m_pFormatContext, m_pPacket) >= 0;
+@@ -644,7 +655,7 @@
+ 
+ int32_t MovieDecoder::getStreamRotation()
+ {
+-    int32_t* matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
++    auto matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
+     if (matrix)
+     {
+         auto angle = lround(av_display_rotation_get(matrix));
+
+--- a/libffmpegthumbnailer/moviedecoder.h	2017-11-12 04:23:38.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.h	2023-05-05 13:26:07.095529911 -0400
+@@ -78,7 +78,7 @@
+     int                     m_VideoStream;
+     AVFormatContext*        m_pFormatContext;
+     AVCodecContext*         m_pVideoCodecContext;
+-    AVCodec*                m_pVideoCodec;
++    const AVCodec*          m_pVideoCodec;
+     AVFilterGraph*          m_pFilterGraph;
+     AVFilterContext*        m_pFilterSource;
+     AVFilterContext*        m_pFilterSink;
diff --git a/srcpkgs/ffmpegthumbnailer/template b/srcpkgs/ffmpegthumbnailer/template
index 039eea7622b39..35d546018d12a 100644
--- a/srcpkgs/ffmpegthumbnailer/template
+++ b/srcpkgs/ffmpegthumbnailer/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbnailer'
 pkgname=ffmpegthumbnailer
 version=2.2.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libpng-devel libjpeg-turbo-devel ffmpeg-devel"
@@ -9,8 +9,8 @@ depends="ffmpeg"
 short_desc="Lightweight video thumbnailer"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
-homepage="https://github.com/dirkvdb/${pkgname}"
-distfiles="${homepage}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
+homepage="https://github.com/dirkvdb"
+distfiles="${homepage}/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
 checksum=1cb24059c38223f657b300c84dd80491b7040d4b69471c4fea69be862bc99b5b
 
 post_install() {

From eb916c486b3c369150fa428cabfdd0a77b2b8b81 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 032/115] ffmpegthumbs: revbump for ffmpeg-6.0

---
 srcpkgs/ffmpegthumbs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ffmpegthumbs/template b/srcpkgs/ffmpegthumbs/template
index 5f0b9414dadaf..11b88193528f4 100644
--- a/srcpkgs/ffmpegthumbs/template
+++ b/srcpkgs/ffmpegthumbs/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbs'
 pkgname=ffmpegthumbs
 version=22.12.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules kcoreaddons kconfig-devel
  pkg-config qt5-host-tools qt5-qmake gettext"

From 86d7fb660cf342f265f18f0c6f9d6d2c6efca2ca Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 033/115] ffms2: revbump for ffmpeg-6.0

---
 srcpkgs/ffms2/patches/ffmpeg5.patch | 424 ++++++++++++++++++++++++++++
 srcpkgs/ffms2/template              |   2 +-
 2 files changed, 425 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ffms2/patches/ffmpeg5.patch

diff --git a/srcpkgs/ffms2/patches/ffmpeg5.patch b/srcpkgs/ffms2/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..1479fabcafcb4
--- /dev/null
+++ b/srcpkgs/ffms2/patches/ffmpeg5.patch
@@ -0,0 +1,424 @@
+From 45673149e9a2f5586855ad472e3059084eaa36b1 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:41:21 +0100
+Subject: [PATCH] Use auto for AVCodec
+
+The geniuses over at FFmpeg decided to constify this API, so old
+versions of the library will return AVCodec *, while new versions
+of the libary will return const AVCodec *, which, in C++, are not
+OK to convert between.
+
+Rather than use some macro hell in ffmscompat.h, we can work around
+this by using auto.
+
+Gross.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 2 +-
+ src/core/indexing.cpp    | 6 +++---
+ src/core/videosource.cpp | 2 +-
+ 3 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index e4ce97c..ac09666 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -469,7 +469,7 @@ void FFMS_AudioSource::OpenFile() {
+ 
+     LAVFOpenFile(SourceFile.c_str(), FormatContext, TrackNumber);
+ 
+-    AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
++    auto *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
+     if (Codec == nullptr)
+         throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+             "Audio codec not found");
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index e547c5a..59fb4e8 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -384,7 +384,7 @@ FFMS_TrackType FFMS_Indexer::GetTrackType(int Track) {
+ }
+ 
+ const char *FFMS_Indexer::GetTrackCodec(int Track) {
+-    AVCodec *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
++    auto *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
+     return codec ? codec->name : nullptr;
+ }
+ 
+@@ -402,7 +402,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             UseDTS);
+ 
+         if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            AVCodec *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (!VideoCodec) {
+                 FormatContext->streams[i]->discard = AVDISCARD_ALL;
+                 IndexMask.erase(i);
+@@ -433,7 +433,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 IndexMask.insert(i);
+             }
+         } else if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+-            AVCodec *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (AudioCodec == nullptr)
+                 throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_UNSUPPORTED,
+                     "Audio codec not found");
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index b889970..8956c22 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -171,7 +171,7 @@ FFMS_VideoSource::FFMS_VideoSource(const char *SourceFile, FFMS_Index &Index, in
+ 
+         LAVFOpenFile(SourceFile, FormatContext, VideoTrack);
+ 
+-        AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
++        auto *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
+         if (Codec == nullptr)
+             throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+                 "Video codec not found");
+-- 
+2.40.0
+
+From 96cbf38ea9381829a1314f432a2c60495dcefaad Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:12:41 +0100
+Subject: [PATCH] all: Update AVPacket API usage
+
+AVPackets must all be on the heap now, since it is no longer
+part of the libav* ABI.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 16 ++++++----
+ src/core/indexing.cpp    | 63 ++++++++++++++++++++++------------------
+ src/core/indexing.h      |  4 +--
+ src/core/utils.cpp       |  6 ----
+ src/core/utils.h         |  1 -
+ src/core/videosource.cpp | 30 ++++++++++---------
+ 6 files changed, 64 insertions(+), 56 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index 37cf9ae..e4ce97c 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -285,10 +285,15 @@ FFMS_AudioSource::AudioBlock *FFMS_AudioSource::CacheBlock(CacheIterator &pos) {
+ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     CurrentFrame = &Frames[PacketNumber];
+ 
+-    AVPacket Packet;
+-    if (!ReadPacket(&Packet))
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++    if (!ReadPacket(Packet)) {
++        av_packet_free(&Packet);
+         throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_UNKNOWN,
+             "ReadPacket unexpectedly failed to read a packet");
++    }
+ 
+     // ReadPacket may have changed the packet number
+     CurrentFrame = &Frames[PacketNumber];
+@@ -297,8 +302,9 @@ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     int NumberOfSamples = 0;
+     AudioBlock *CachedBlock = nullptr;
+     
+-    int Ret = avcodec_send_packet(CodecContext, &Packet);
+-    av_packet_unref(&Packet);
++    int Ret = avcodec_send_packet(CodecContext, Packet);
++    av_packet_unref(Packet);
++    av_packet_free(&Packet);
+ 
+     av_frame_unref(DecodeFrame);
+     Ret = avcodec_receive_frame(CodecContext, DecodeFrame);
+@@ -513,8 +519,6 @@ void FFMS_AudioSource::Seek() {
+ }
+ 
+ bool FFMS_AudioSource::ReadPacket(AVPacket *Packet) {
+-    InitNullPacket(*Packet);
+-
+     while (av_read_frame(FormatContext, Packet) >= 0) {
+         if (Packet->stream_index == TrackNumber) {
+             // Required because not all audio packets, especially in ogg, have a pts. Use the previous valid packet's pts instead.
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index 23fb95b..e547c5a 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -320,7 +320,7 @@ void FFMS_Indexer::CheckAudioProperties(int Track, AVCodecContext *Context) {
+     }
+ }
+ 
+-void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict,
++void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict,
+                                     int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct) {
+     if (VideoContext.Parser) {
+         uint8_t *OB;
+@@ -330,8 +330,8 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+         av_parser_parse2(VideoContext.Parser,
+             VideoContext.CodecContext,
+             &OB, &OBSize,
+-            pkt.data, pkt.size,
+-            pkt.pts, pkt.dts, pkt.pos);
++            pkt->data, pkt->size,
++            pkt->pts, pkt->dts, pkt->pos);
+ 
+         // H.264 (PAFF) and HEVC may have one field per packet, so we need to track
+         // when we have a full or half frame available, and mark one of them as
+@@ -351,15 +351,15 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+ 
+         *RepeatPict = VideoContext.Parser->repeat_pict;
+         *FrameType = VideoContext.Parser->pict_type;
+-        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt.flags & AV_PKT_FLAG_DISCARD));
++        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt->flags & AV_PKT_FLAG_DISCARD));
+     } else {
+-        *Invisible = !!(pkt.flags & AV_PKT_FLAG_DISCARD);
++        *Invisible = !!(pkt->flags & AV_PKT_FLAG_DISCARD);
+     }
+ 
+     if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP8)
+-        ParseVP8(pkt.data[0], Invisible, FrameType);
++        ParseVP8(pkt->data[0], Invisible, FrameType);
+     else if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP9)
+-        ParseVP9(pkt.data[0], Invisible, FrameType);
++        ParseVP9(pkt->data[0], Invisible, FrameType);
+ }
+ 
+ void FFMS_Indexer::Free() {
+@@ -458,32 +458,36 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+         }
+     }
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
+     std::vector<int64_t> LastValidTS(FormatContext->nb_streams, AV_NOPTS_VALUE);
+ 
+     int64_t filesize = avio_size(FormatContext->pb);
+     enum AVPictureStructure LastPicStruct = AV_PICTURE_STRUCTURE_UNKNOWN;
+-    while (av_read_frame(FormatContext, &Packet) >= 0) {
++    while (av_read_frame(FormatContext, Packet) >= 0) {
+         // Update progress
+         // FormatContext->pb can apparently be NULL when opening images.
+         if (IC && FormatContext->pb) {
+-            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate))
++            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate)) {
++                av_packet_free(&Packet);
+                 throw FFMS_Exception(FFMS_ERROR_CANCELLED, FFMS_ERROR_USER,
+                     "Cancelled by user");
++            }
+         }
+-        if (!IndexMask.count(Packet.stream_index)) {
+-            av_packet_unref(&Packet);
++        if (!IndexMask.count(Packet->stream_index)) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+-        int Track = Packet.stream_index;
++        int Track = Packet->stream_index;
+         FFMS_Track &TrackInfo = (*TrackIndices)[Track];
+-        bool KeyFrame = !!(Packet.flags & AV_PKT_FLAG_KEY);
++        bool KeyFrame = !!(Packet->flags & AV_PKT_FLAG_KEY);
+         ReadTS(Packet, LastValidTS[Track], (*TrackIndices)[Track].UseDTS);
+ 
+         if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            int64_t PTS = TrackInfo.UseDTS ? Packet.dts : Packet.pts;
++            int64_t PTS = TrackInfo.UseDTS ? Packet->dts : Packet->pts;
+             if (PTS == AV_NOPTS_VALUE) {
+                 // VPx alt-refs are output as packets which lack timestmps or durations, since
+                 // they are invisible. Currently, the timestamp mangling code in libavformat
+@@ -495,9 +499,11 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 // FFMS2 currently sorts packets by PTS, which will break decoding, otherwise.
+                 bool HasAltRefs = (FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP8 ||
+                                    FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP9);
+-                if (Packet.duration == 0 && !HasAltRefs)
++                if (Packet->duration == 0 && !HasAltRefs) {
++                    av_packet_free(&Packet);
+                     throw FFMS_Exception(FFMS_ERROR_INDEXING, FFMS_ERROR_PARSER,
+                         "Invalid packet pts, dts, and duration");
++                }
+ 
+                 if (TrackInfo.empty())
+                     PTS = 0;
+@@ -513,7 +519,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             ParseVideoPacket(AVContexts[Track], Packet, &RepeatPict, &FrameType, &Invisible, &LastPicStruct);
+ 
+             TrackInfo.AddVideoFrame(PTS, RepeatPict, KeyFrame,
+-                FrameType, Packet.pos, Invisible);
++                FrameType, Packet->pos, Invisible);
+         } else if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+             // For video seeking timestamps are used only if all packets have
+             // timestamps, while for audio they're used if any have timestamps,
+@@ -522,28 +528,29 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 TrackInfo.HasTS = true;
+ 
+             int64_t StartSample = AVContexts[Track].CurrentSample;
+-            uint32_t SampleCount = IndexAudioPacket(Track, &Packet, AVContexts[Track], *TrackIndices);
++            uint32_t SampleCount = IndexAudioPacket(Track, Packet, AVContexts[Track], *TrackIndices);
+             TrackInfo.SampleRate = AVContexts[Track].CodecContext->sample_rate;
+ 
+             TrackInfo.AddAudioFrame(LastValidTS[Track],
+-                StartSample, SampleCount, KeyFrame, Packet.pos, Packet.flags & AV_PKT_FLAG_DISCARD);
++                StartSample, SampleCount, KeyFrame, Packet->pos, Packet->flags & AV_PKT_FLAG_DISCARD);
+         }
+ 
+-        if (!(Packet.flags & AV_PKT_FLAG_DISCARD))
+-            TrackInfo.LastDuration = Packet.duration;
++        if (!(Packet->flags & AV_PKT_FLAG_DISCARD))
++            TrackInfo.LastDuration = Packet->duration;
+ 
+-        av_packet_unref(&Packet);
++        av_packet_unref(Packet);
+     }
++    av_packet_free(&Packet);
+ 
+     TrackIndices->Finalize(AVContexts, FormatContext->iformat->name);
+     return TrackIndices.release();
+ }
+ 
+-void FFMS_Indexer::ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS) {
+-    if (!UseDTS && Packet.pts != AV_NOPTS_VALUE)
+-        TS = Packet.pts;
++void FFMS_Indexer::ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS) {
++    if (!UseDTS && Packet->pts != AV_NOPTS_VALUE)
++        TS = Packet->pts;
+     if (TS == AV_NOPTS_VALUE)
+         UseDTS = true;
+-    if (UseDTS && Packet.dts != AV_NOPTS_VALUE)
+-        TS = Packet.dts;
++    if (UseDTS && Packet->dts != AV_NOPTS_VALUE)
++        TS = Packet->dts;
+ }
+diff --git a/src/core/indexing.h b/src/core/indexing.h
+index 3cfc3c3..5c06868 100644
+--- a/src/core/indexing.h
++++ b/src/core/indexing.h
+@@ -80,10 +80,10 @@ private:
+     int64_t Filesize;
+     uint8_t Digest[20];
+ 
+-    void ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS);
++    void ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS);
+     void CheckAudioProperties(int Track, AVCodecContext *Context);
+     uint32_t IndexAudioPacket(int Track, AVPacket *Packet, SharedAVContext &Context, FFMS_Index &TrackIndices);
+-    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
++    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
+     void Free();
+ public:
+     FFMS_Indexer(const char *Filename);
+diff --git a/src/core/utils.cpp b/src/core/utils.cpp
+index ce67533..8a2e997 100644
+--- a/src/core/utils.cpp
++++ b/src/core/utils.cpp
+@@ -62,12 +62,6 @@ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo) {
+     }
+ }
+ 
+-void InitNullPacket(AVPacket &pkt) {
+-    av_init_packet(&pkt);
+-    pkt.data = nullptr;
+-    pkt.size = 0;
+-}
+-
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames) {
+     AP.SampleFormat = static_cast<FFMS_SampleFormat>(av_get_packed_sample_fmt(CTX->sample_fmt));
+     AP.BitsPerSample = av_get_bytes_per_sample(CTX->sample_fmt) * 8;
+diff --git a/src/core/utils.h b/src/core/utils.h
+index 9819dc7..003ab79 100644
+--- a/src/core/utils.h
++++ b/src/core/utils.h
+@@ -58,7 +58,6 @@ std::unique_ptr<T> make_unique(Args&&... args) {
+ }
+ 
+ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo);
+-void InitNullPacket(AVPacket &pkt);
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames);
+ 
+ void LAVFOpenFile(const char *SourceFile, AVFormatContext *&FormatContext, int Track);
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index 06bd161..b889970 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -673,30 +673,34 @@ void FFMS_VideoSource::DecodeNextFrame(int64_t &AStartTime, int64_t &Pos) {
+     if (HasPendingDelayedFrames())
+         return;
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
+-
+-    while (ReadFrame(&Packet) >= 0) {
+-        if (Packet.stream_index != VideoTrack) {
+-            av_packet_unref(&Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++
++    while (ReadFrame(Packet) >= 0) {
++        if (Packet->stream_index != VideoTrack) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+         if (AStartTime < 0)
+-            AStartTime = Frames.UseDTS ? Packet.dts : Packet.pts;
++            AStartTime = Frames.UseDTS ? Packet->dts : Packet->pts;
+ 
+         if (Pos < 0)
+-            Pos = Packet.pos;
++            Pos = Packet->pos;
+ 
+-        bool FrameFinished = DecodePacket(&Packet);
+-        av_packet_unref(&Packet);
+-        if (FrameFinished)
++        bool FrameFinished = DecodePacket(Packet);
++        av_packet_unref(Packet);
++        if (FrameFinished) {
++            av_packet_free(&Packet);
+             return;
++        }
+     }
+ 
+     // Flush final frames
+-    InitNullPacket(Packet);
+-    DecodePacket(&Packet);
++    DecodePacket(Packet);
++    av_packet_free(&Packet);
+ }
+ 
+ bool FFMS_VideoSource::SeekTo(int n, int SeekOffset) {
+-- 
+2.40.0
+
+From bf9e03e9e08534c024e5a744a6437c4aac160201 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:20:47 +0100
+Subject: [PATCH 2/3] configure: Remove deprecated API use
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ configure.ac | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index b35ef80bc..d19714d0f 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -102,10 +102,10 @@ CFLAGS="$_CFLAGS $FFMPEG_CFLAGS"
+
+ AC_DEFUN([TEST_FFMPEG],
+          [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+-            #include <libavcodec/avcodec.h>
++            #include <libavformat/avformat.h>
+             #include <libswscale/swscale.h>
+             ]],[[
+-                avcodec_register_all();
++                avformat_network_init();
+                 swscale_version();
+             ]])], [eval $1=yes], [eval $1=no])
+         ])
+
diff --git a/srcpkgs/ffms2/template b/srcpkgs/ffms2/template
index bfeb9698ceb46..ac01d9321f0bd 100644
--- a/srcpkgs/ffms2/template
+++ b/srcpkgs/ffms2/template
@@ -1,7 +1,7 @@
 # Template file for 'ffms2'
 pkgname=ffms2
 version=2.40
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-shared --disable-static"
 hostmakedepends="pkg-config autoconf automake libtool"

From d5a8264ed17c39d99eef1b741be43b70c8718784 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 034/115] freerdp: revbump for ffmpeg-6.0

---
 .../freerdp/patches/ffmpeg6_aa2cb9aa.patch    | 42 +++++++++++++++++++
 srcpkgs/freerdp/template                      |  2 +-
 2 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch

diff --git a/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
new file mode 100644
index 0000000000000..a4324da3a8822
--- /dev/null
+++ b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
@@ -0,0 +1,42 @@
+From aa2cb9aa5ff5562433598ba168a466e0752bca0e Mon Sep 17 00:00:00 2001
+From: akallabeth <akallabeth@posteo.net>
+Date: Tue, 14 Feb 2023 07:48:54 +0100
+Subject: [PATCH] Fixed #8686: Update h264 to use new FFMPEG API
+
+---
+ channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c | 2 ++
+ libfreerdp/codec/h264_ffmpeg.c            | 2 ++
+ 2 files changed, 4 insertions(+)
+
+diff --git a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+index 339462d865f..beea80b7a1e 100644
+--- a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
++++ b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+@@ -239,8 +239,10 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYP
+ 		}
+ 	}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 	if (mdecoder->codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		mdecoder->codec_context->flags |= AV_CODEC_FLAG_TRUNCATED;
++#endif
+ 
+ 	return TRUE;
+ }
+diff --git a/libfreerdp/codec/h264_ffmpeg.c b/libfreerdp/codec/h264_ffmpeg.c
+index 8a23db2473c..896a333019b 100644
+--- a/libfreerdp/codec/h264_ffmpeg.c
++++ b/libfreerdp/codec/h264_ffmpeg.c
+@@ -615,10 +615,12 @@ static BOOL libavcodec_init(H264_CONTEXT* h264)
+ 			goto EXCEPTION;
+ 		}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 		if (sys->codecDecoder->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		{
+ 			sys->codecDecoderContext->flags |= AV_CODEC_FLAG_TRUNCATED;
+ 		}
++#endif
+ 
+ #ifdef WITH_VAAPI
+ 
diff --git a/srcpkgs/freerdp/template b/srcpkgs/freerdp/template
index 25e8aa9677f0b..4d51c8189902a 100644
--- a/srcpkgs/freerdp/template
+++ b/srcpkgs/freerdp/template
@@ -1,7 +1,7 @@
 # Template file for 'freerdp'
 pkgname=freerdp
 version=2.10.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_ALSA=ON -DWITH_CUPS=OFF -DWITH_FFMPEG=ON
  -DWITH_GSTREAMER_0_10=OFF -DWITH_GSTREAMER_1_0=OFF -DWITH_JPEG=ON

From c09d1820df6aa753e3ffa99ad4a31d73608b3a45 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 035/115] gerbera: revbump for ffmpeg-6.0

---
 srcpkgs/gerbera/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gerbera/template b/srcpkgs/gerbera/template
index ae14f35c767c0..2dc0ac0ce03b5 100644
--- a/srcpkgs/gerbera/template
+++ b/srcpkgs/gerbera/template
@@ -1,7 +1,7 @@
 # Template file for 'gerbera'
 pkgname=gerbera
 version=1.12.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_SYSTEMD=0 -DWITH_AVCODEC=1"
 hostmakedepends="pkg-config"

From 8d954dc40ca5f34194c38d7fa700d9e300f9f0b1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 036/115] goldendict: revbump for ffmpeg-6.0

---
 srcpkgs/goldendict/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/goldendict/template b/srcpkgs/goldendict/template
index f4a05759f693d..97f44347b03a6 100644
--- a/srcpkgs/goldendict/template
+++ b/srcpkgs/goldendict/template
@@ -1,7 +1,7 @@
 # Template file for 'goldendict'
 pkgname=goldendict
 version=1.5.0
-revision=1
+revision=2
 build_style=qmake
 configure_args="CONFIG+=zim_support goldendict.pro"
 hostmakedepends="qt5-qmake pkg-config qt5-host-tools"
@@ -10,7 +10,7 @@ makedepends="tiff-devel qt5-devel libvorbis-devel zlib-devel
  qt5-webkit-devel lzo-devel bzip2-devel libao-devel qt5-svg-devel
  libeb-devel qt5-x11extras-devel ffmpeg-devel liblzma-devel
  qt5-multimedia-devel"
-short_desc="A feature-rich dictionary lookup program"
+short_desc="Feature-rich dictionary lookup program"
 maintainer="John <me@johnnynator.dev>"
 license="GPL-3.0-or-later"
 homepage="http://goldendict.org/"

From b110677793a1b0a13058bbb8513f19c7feda7e85 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 037/115] gst-libav: revbump for ffmpeg-6.0

---
 srcpkgs/gst-libav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index 8c72fc3e97eee..04c39bff14896 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.22.2
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"

From 80ecf207d3bdff9368be3eb7780118923e878f0d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 038/115] gst-rtsp-server: revbump for ffmpeg-6.0

---
 srcpkgs/gst-rtsp-server/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index 2f0c0c45ff820..980fd72cdd4c5 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
 version=1.22.2
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="glib-devel gst-plugins-bad1-devel gobject-introspection

From 1aecb0981bc767381a3c5cc37eafd4303fc11070 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 039/115] guvcview: update to 2.0.8.

---
 srcpkgs/guvcview/patches/fix-include.patch | 10 ++++++++++
 srcpkgs/guvcview/template                  |  5 ++---
 2 files changed, 12 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/guvcview/patches/fix-include.patch

diff --git a/srcpkgs/guvcview/patches/fix-include.patch b/srcpkgs/guvcview/patches/fix-include.patch
new file mode 100644
index 0000000000000..503c2af3b78c1
--- /dev/null
+++ b/srcpkgs/guvcview/patches/fix-include.patch
@@ -0,0 +1,10 @@
+--- a/guvcview/guvcview.c
++++ b/guvcview/guvcview.c
+@@ -28,6 +28,7 @@
+ #include <sys/stat.h>
+ #include <sys/resource.h>
+ #include <errno.h>
++#include <locale.h>
+ 
+ #include "gview.h"
+ #include "gviewv4l2core.h"
diff --git a/srcpkgs/guvcview/template b/srcpkgs/guvcview/template
index 345cf6006f246..86a7fd619612c 100644
--- a/srcpkgs/guvcview/template
+++ b/srcpkgs/guvcview/template
@@ -1,8 +1,7 @@
 # Template file for 'guvcview'
 pkgname=guvcview
-version=2.0.7
+version=2.0.8
 revision=1
-create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-static --disable-debian-menu"
 hostmakedepends="pkg-config intltool autoconf automake libtool glib-devel"
@@ -14,7 +13,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="http://guvcview.sourceforge.net/"
 distfiles="${SOURCEFORGE_SITE}/${pkgname}/${pkgname}-src-${version}.tar.bz2"
-checksum=f47d51fbd06e44eeaa1a82f4a153c927527c90d94514197a70b2956028cc8ad4
+checksum=a21f4e448286666cf27bafef5290cc953a0a1796b752e5bbe521266dc1230c81
 
 post_patch() {
 	sed '31a#include <locale.h>' -i  guvcview/guvcview.c

From 4fa1f2c643f8f81d6f614c716d385aad36199b10 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 040/115] handbrake: update to 1.6.1

---
 .../patches/fix-missing-x265-link-flag.patch    | 11 ++++++-----
 .../handbrake/patches/libhb-vpl-include.patch   | 15 +++++++++++++++
 srcpkgs/handbrake/template                      | 17 ++++++++++-------
 3 files changed, 31 insertions(+), 12 deletions(-)
 create mode 100644 srcpkgs/handbrake/patches/libhb-vpl-include.patch

diff --git a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
index 26db03867a0c8..d6bb2eda627a3 100644
--- a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
+++ b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
@@ -1,14 +1,15 @@
 --- a/gtk/configure.ac
 +++ b/gtk/configure.ac
 @@ -203,7 +203,7 @@
- 
+
  AM_CONDITIONAL([MINGW], [test "x$mingw_flag" = "xyes"])
- 
--HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg"
-+HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -ldl"
+
+-HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc"
++HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc -ldl"
  HB_CPPFLAGS="$HB_CPPFLAGS $HBINC"
- 
+
  PKG_CHECK_MODULES([x264], [x264], sys_x264=yes, sys_x264=no)
+
 --- a/test/module.defs
 +++ b/test/module.defs
 @@ -69,6 +69,9 @@
diff --git a/srcpkgs/handbrake/patches/libhb-vpl-include.patch b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
new file mode 100644
index 0000000000000..298f9f4ab28f2
--- /dev/null
+++ b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
@@ -0,0 +1,15 @@
+--- a/libhb/module.defs	2023-01-22 11:36:49.000000000 -0500
++++ b/libhb/module.defs	2023-04-03 22:37:52.395467010 -0400
+@@ -46,11 +46,7 @@
+ LIBHB.GCC.I += $(LIBHB.build/) $(CONTRIB.build/)include
+ 
+ ifeq (1,$(FEATURE.qsv))
+-    ifeq ($(HOST.system),freebsd))
+-        LIBHB.GCC.I += $(LOCALBASE)/include/vpl
+-    else
+-        LIBHB.GCC.I += $(CONTRIB.build/)include/vpl
+-    endif
++    LIBHB.GCC.I += /usr/include/vpl
+ endif
+ 
+ ifneq (,$(filter $(HOST.system),freebsd netbsd openbsd))
diff --git a/srcpkgs/handbrake/template b/srcpkgs/handbrake/template
index ca5e4571e49c3..c32cb1bfa31f4 100644
--- a/srcpkgs/handbrake/template
+++ b/srcpkgs/handbrake/template
@@ -1,10 +1,10 @@
 # Template file for 'handbrake'
 pkgname=handbrake
-version=1.5.1
+version=1.6.1
 revision=1
 build_style=gnu-configure
 configure_args="--force --disable-gtk-update-checks --disable-df-fetch --harden
- $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc)"
+ $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc) $(vopt_enable qsv)"
 make_build_args="-C ${XBPS_TRIPLET}"
 make_install_args="-C ${XBPS_TRIPLET}"
 hostmakedepends="automake cmake gettext-devel glib-devel intltool libtool m4 meson nasm pkg-config python3"
@@ -12,8 +12,11 @@ makedepends="bzip2-devel ffmpeg-devel gst-plugins-base1-devel gtk+3-devel
  jansson-devel lame-devel libass-devel libbluray-devel libdav1d-devel
  libdvdnav-devel libdvdread-devel libgudev-devel libnuma-devel
  libsamplerate-devel libtheora-devel libvorbis-devel libvpx-devel libxml2-devel
- opus-devel speex-devel x264-devel x265-devel zimg-devel
+ opus-devel speex-devel x264-devel x265-devel zimg-devel libsvt-av1-devel
  $(vopt_if fdk_aac fdk-aac-devel)
+ $(vopt_if qsv libva-devel)
+ $(vopt_if qsv libdrm-devel)
+ $(vopt_if qsv onevpl-devel)
  $(vopt_if nvenc nv-codec-headers)"
 depends="desktop-file-utils gst-plugins-good1 hicolor-icon-theme"
 short_desc="Multithreaded video transcoder"
@@ -21,15 +24,15 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-2.0-only"
 homepage="https://handbrake.fr/"
 distfiles="https://github.com/HandBrake/HandBrake/releases/download/${version}/HandBrake-${version}-source.tar.bz2"
-checksum=3999fe06d5309c819799a73a968a8ec3840e7840c2b64af8f5cdb7fd8c9430f0
+checksum=94ccfe03db917a91650000c510f7fd53f844da19f19ad4b4be1b8f6bc31a8d4c
 nocross=yes
 
-build_options="fdk_aac nvenc"
+build_options="fdk_aac nvenc qsv"
 
 case "$XBPS_TARGET_MACHINE" in
 	x86_64*|i686*)
 		CFLAGS="-msse"
-		build_options_default="nvenc"
+		build_options_default="nvenc qsv"
 		;;
 esac
 
@@ -37,7 +40,7 @@ pre_configure() {
 	# use system libraries, don't download them
 	rm -rf contrib/
 	for module in fdk-aac ffmpeg libbluray libdav1d libdvdnav libdvdread nvenc \
-		x265 zimg; do
+		x265 zimg svt-av1 libvpl; do
 	    vsed -i "/MODULES += contrib\/${module}/d" make/include/main.defs
 	done
 }

From b82dfb7361743af0e92013f7381326344175ad46 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 041/115] hedgewars: revbump for ffmpeg4-4.4.3

---
 srcpkgs/hedgewars/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/hedgewars/template b/srcpkgs/hedgewars/template
index 15a1df6d8861d..d1b7290bfdc19 100644
--- a/srcpkgs/hedgewars/template
+++ b/srcpkgs/hedgewars/template
@@ -1,13 +1,13 @@
 # Template file for 'hedgewars'
 pkgname=hedgewars
 version=1.0.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DNOSERVER=1 -DDATA_INSTALL_DIR=/usr/share/${pkgname}
  -DPHYSFS_SYSTEM=1 -DMINIMAL_FLAGS=1"
 make_cmd=make
 hostmakedepends="lua51 pkg-config qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
+makedepends="ffmpeg4-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
  SDL2_mixer-devel SDL2_net-devel SDL2_ttf-devel"
 depends="libfreeglut"
 short_desc="Funny turn-based artillery game, featuring fighting Hedgehogs!"

From 72ac3f3ef711f12f46103a66c47857febba042fc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 042/115] idjc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/idjc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/idjc/template b/srcpkgs/idjc/template
index df60318b3db96..36a75baf597c5 100644
--- a/srcpkgs/idjc/template
+++ b/srcpkgs/idjc/template
@@ -1,11 +1,11 @@
 # Template file for 'idjc'
 pkgname=idjc
 version=0.9.1
-revision=3
+revision=4
 build_style=gnu-configure
 hostmakedepends="pkg-config git python3 automake gettext-devel libtool"
 makedepends="libvorbis-devel libogg-devel jack-devel libsamplerate-devel
- libflac-devel libsndfile-devel mpg123-devel ffmpeg-devel speex-devel
+ libflac-devel libsndfile-devel mpg123-devel ffmpeg4-devel speex-devel
  glib-devel pixman-devel lame-devel python3-gobject-devel libshout-idjc-devel
  opus-devel twolame-devel python3-mutagen python3-devel"
 depends="python3-gobject python3-mutagen desktop-file-utils shared-mime-info python3-dbus jack"

From 8000a7199e1e91e2fbd75c5fc441496b35b9cc83 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 043/115] kfilemetadata5: revbump for ffmpeg-6.0

---
 srcpkgs/kfilemetadata5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kfilemetadata5/template b/srcpkgs/kfilemetadata5/template
index c3e3eb116a67b..30ffc31b1cb6b 100644
--- a/srcpkgs/kfilemetadata5/template
+++ b/srcpkgs/kfilemetadata5/template
@@ -1,7 +1,7 @@
 # Template file for 'kfilemetadata5'
 pkgname=kfilemetadata5
 version=5.108.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="kcoreaddons extra-cmake-modules pkg-config qt5-host-tools qt5-qmake
  gettext kcoreaddons python3"

From af67294b9ad2ae6801721e5ee348f9ca5480be54 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 044/115] kid3: revbump for ffmpeg-6.0

---
 srcpkgs/kid3/patches/ffmpeg5.patch | 17 +++++++++++++++++
 srcpkgs/kid3/template              |  2 +-
 2 files changed, 18 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/kid3/patches/ffmpeg5.patch

diff --git a/srcpkgs/kid3/patches/ffmpeg5.patch b/srcpkgs/kid3/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..135fc50e07c9b
--- /dev/null
+++ b/srcpkgs/kid3/patches/ffmpeg5.patch
@@ -0,0 +1,17 @@
+# https://aur.archlinux.org/cgit/aur.git/diff/ffmpeg5.patch?h=kid3-cli&id=12410a74906612e7efc0ec8fbce739b4a0fef7e7
+diff --git a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+index e156d424..e12b9abd 100644
+--- a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
++++ b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+@@ -232,7 +232,11 @@ private:
+   friend class Format;
+   friend class Converter;
+   AVCodecContext* m_ptr;
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 0, 0)
+   AVCodec* m_impl;
++#else
++  const AVCodec* m_impl;
++#endif
+   AVFrame* m_frame;
+   bool m_opened;
+ };
diff --git a/srcpkgs/kid3/template b/srcpkgs/kid3/template
index 456206d90e16a..f32f9decb0e7f 100644
--- a/srcpkgs/kid3/template
+++ b/srcpkgs/kid3/template
@@ -1,7 +1,7 @@
 # Template file for 'kid3'
 pkgname=kid3
 version=3.9.1
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DWITH_APPS='CLI;$(vopt_if KDE KDE Qt)'
  -DWITH_DOCBOOKDIR=/usr/share/xsl/docbook -DWITH_FLAC=$(vopt_if flac ON OFF)

From 9306f99062368ce203c365b0a647e0e1e97c4bb8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 045/115] kodi: revbump for ffmpeg4-4.4.3

---
 srcpkgs/kodi/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/kodi/template b/srcpkgs/kodi/template
index bd5433969db64..25744f69107f4 100644
--- a/srcpkgs/kodi/template
+++ b/srcpkgs/kodi/template
@@ -1,7 +1,7 @@
 # Template file for 'kodi'
 pkgname=kodi
 version=19.4
-revision=6
+revision=7
 _codename="Matrix"
 build_style=cmake
 configure_args="-DWITH_FFMPEG=/usr -DENABLE_LDGOLD=OFF
@@ -54,7 +54,7 @@ makedepends="
  libmad-devel fontconfig-devel libXinerama-devel libsamplerate-devel libmms-devel
  enca-devel boost-devel libcurl-devel libva-devel libvdpau-devel libass-devel
  libbluetooth-devel yajl-devel libplist-devel librtmp-devel tinyxml-devel
- taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg-devel
+ taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg4-devel
  giflib-devel libxslt-devel gnutls-devel libssh-devel libmicrohttpd-devel
  libcec-devel dcadec-devel flatbuffers-devel fmt-devel lcms2-devel
  libfstrcmp-devel rapidjson libcdio-paranoia spdlog libwaylandpp-devel

From a39ceeb04fc6df6a48247422986a70d8b7bb00b2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 046/115] kpipewire: revbump for ffmpeg-6.0

---
 srcpkgs/kpipewire/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kpipewire/template b/srcpkgs/kpipewire/template
index db4e42f0d456a..2334bf8678062 100644
--- a/srcpkgs/kpipewire/template
+++ b/srcpkgs/kpipewire/template
@@ -1,7 +1,7 @@
 # Template file for 'kpipewire'
 pkgname=kpipewire
 version=5.27.6
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules plasma-wayland-protocols gettext
  qt5-qmake qt5-host-tools pkg-config wayland-devel kcoreaddons

From a025ab9b54e5ee5ac2f9d61184312195431b86f8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 047/115] libextractor: revbump for ffmpeg4-4.4.3

---
 srcpkgs/libextractor/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libextractor/template b/srcpkgs/libextractor/template
index ddd4790f93e88..1fb9ca56a96ae 100644
--- a/srcpkgs/libextractor/template
+++ b/srcpkgs/libextractor/template
@@ -7,7 +7,7 @@ configure_args="--disable-static"
 hostmakedepends="pkg-config"
 makedepends="zlib-devel bzip2-devel exiv2-devel tiff-devel libpng-devel
  libjpeg-turbo-devel libvorbis-devel libflac-devel giflib-devel libmpeg2-devel
- ffmpeg-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
+ ffmpeg4-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
 short_desc="Library used to extract meta data from files"
 maintainer="Martin Riese <grauehaare@gmx.de>"
 license="GPL-3.0-or-later"

From 8d1ceb15ffda4a5f9dd172fc06aa55b1d684b5f0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 048/115] libopenal: revbump for ffmpeg-6.0

---
 srcpkgs/libopenal/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenal/template b/srcpkgs/libopenal/template
index 77218f9e539df..3f49ed75a1fdc 100644
--- a/srcpkgs/libopenal/template
+++ b/srcpkgs/libopenal/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenal'
 pkgname=libopenal
 version=1.22.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DALSOFT_EXAMPLES=OFF"
 hostmakedepends="pkg-config"

From c876579fe61cc0254ca34a6a42be42080e5a7065 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 049/115] loudgain: revbump for ffmpeg-6.0

---
 srcpkgs/loudgain/patches/ffmpeg5.patch | 11 +++++++++++
 srcpkgs/loudgain/template              |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/loudgain/patches/ffmpeg5.patch

diff --git a/srcpkgs/loudgain/patches/ffmpeg5.patch b/srcpkgs/loudgain/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..16d4510ee98fa
--- /dev/null
+++ b/srcpkgs/loudgain/patches/ffmpeg5.patch
@@ -0,0 +1,11 @@
+--- a/src/scan.c	2019-09-06 11:31:19.000000000 -0400
++++ b/src/scan.c	2023-03-23 11:15:40.867968521 -0400
+@@ -69,8 +69,6 @@
+ 	 * It is now useless
+ 	 * https://github.com/FFmpeg/FFmpeg/blob/70d25268c21cbee5f08304da95be1f647c630c15/doc/APIchanges#L86
+ 	 */
+-  if (avformat_version() < AV_VERSION_INT(58,9,100))
+-    av_register_all();
+ 
+ 	av_log_set_callback(scan_av_log);
+ 
diff --git a/srcpkgs/loudgain/template b/srcpkgs/loudgain/template
index da4f2d56e94c3..4d6bf29efb4fd 100644
--- a/srcpkgs/loudgain/template
+++ b/srcpkgs/loudgain/template
@@ -1,7 +1,7 @@
 # Template file for 'loudgain'
 pkgname=loudgain
 version=0.6.8
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libebur128-devel taglib-devel ffmpeg-devel"

From 51d323d7e88fa64aef1ca33f9510629730f1e4a1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 050/115] mediastreamer: revbump for ffmpeg4-4.4.3

---
 srcpkgs/mediastreamer/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mediastreamer/template b/srcpkgs/mediastreamer/template
index d0e97e858e29a..1bde031443a59 100644
--- a/srcpkgs/mediastreamer/template
+++ b/srcpkgs/mediastreamer/template
@@ -1,11 +1,11 @@
 # Template file for 'mediastreamer'
 pkgname=mediastreamer
 version=5.2.6
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_STRICT=0 -DENABLE_UNIT_TESTS=0"
 hostmakedepends="python3"
-makedepends="bzrtp-devel ffmpeg-devel glew-devel libXv-devel libsrtp-devel
+makedepends="bzrtp-devel ffmpeg4-devel glew-devel libXv-devel libsrtp-devel
  libupnp-devel libvpx-devel mbedtls-devel opus-devel ortp-devel pulseaudio-devel
  libtheora-devel speex-devel v4l-utils-devel bcg729-devel bcmatroska2-devel libgsm-devel"
 # zxing-cpp-devel (1.2.0 probably not compatible, check again after updaing xzing)

From a7dea02ee8080c9d70dfd3d0ff839e4d2ee45834 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 051/115] mgba: revbump for ffmpeg-6.0

---
 srcpkgs/mgba/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mgba/template b/srcpkgs/mgba/template
index 4af085188bf44..01ec4176bd602 100644
--- a/srcpkgs/mgba/template
+++ b/srcpkgs/mgba/template
@@ -1,7 +1,7 @@
 # Template file for 'mgba'
 pkgname=mgba
 version=0.10.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake desktop-file-utils"
 makedepends="SDL2-devel ffmpeg-devel libedit-devel libepoxy-devel libmagick-devel

From 189a38789b13020a06bab9ba7bd58ece30f67840 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 052/115] minidlna: revbump for ffmpeg-6.0

---
 srcpkgs/minidlna/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/minidlna/template b/srcpkgs/minidlna/template
index d551e49ed4653..5fa929f3a0c12 100644
--- a/srcpkgs/minidlna/template
+++ b/srcpkgs/minidlna/template
@@ -1,7 +1,7 @@
 # Template file for 'minidlna'
 pkgname=minidlna
 version=1.3.3
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="
  --sbindir=/usr/bin

From fb152f793e4d59105f74f675a89b9f27b9d150e1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 053/115] mlt: revbump for ffmpeg4-4.4.3

---
 srcpkgs/mlt/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mlt/template b/srcpkgs/mlt/template
index 5ad199461e694..f0b3af193db2c 100644
--- a/srcpkgs/mlt/template
+++ b/srcpkgs/mlt/template
@@ -1,14 +1,14 @@
 # Template file for 'mlt'
 pkgname=mlt
 version=6.26.1
-revision=1
+revision=2
 build_style=configure
 configure_args="--prefix=/usr --libdir=/usr/lib$XBPS_TARGET_WORDSIZE
  --enable-gpl --enable-gpl3 --disable-swfdec --without-kde
  --swig-languages=python"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which"
 # XXX: movit vid.stab
-makedepends="alsa-lib-devel ffmpeg-devel gtk+-devel jack-devel ladspa-sdk
+makedepends="alsa-lib-devel ffmpeg4-devel gtk+-devel jack-devel ladspa-sdk
  libexif-devel libsamplerate-devel libxml2-devel sox-devel SDL_image-devel
  fftw-devel frei0r-plugins python3-devel pulseaudio-devel movit-devel
  libvidstab-devel"

From 14e34be8388431674d9120637002f349793d28fb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 054/115] moc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/moc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/moc/template b/srcpkgs/moc/template
index 5aed5d36558d3..d8de816026b64 100644
--- a/srcpkgs/moc/template
+++ b/srcpkgs/moc/template
@@ -1,10 +1,10 @@
 # Template file for 'moc'
 pkgname=moc
 version=2.5.2
-revision=6
+revision=7
 build_style=gnu-configure
 hostmakedepends="pkg-config"
-makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg-devel
+makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg4-devel
  jack-devel alsa-lib-devel libltdl-devel libflac-devel libvorbis-devel
  libmad-devel libmpcdec-devel libmodplug-devel libid3tag-devel faad2-devel
  taglib-devel libsndfile-devel wavpack-devel speex-devel libsamplerate-devel

From 04eca721bb2dc3864cd00e7e4f6badc15d2fc9ea Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 055/115] motion: revbump for ffmpeg-6.0

---
 srcpkgs/motion/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/motion/template b/srcpkgs/motion/template
index 3cf3c3035c5b7..7dca12d851e33 100644
--- a/srcpkgs/motion/template
+++ b/srcpkgs/motion/template
@@ -1,7 +1,7 @@
 # Template file for 'motion'
 pkgname=motion
 version=4.5.1
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake pkg-config gettext-devel tar"
 makedepends="ffmpeg-devel libmicrohttpd-devel v4l-utils-devel gettext-devel"

From aceb9222b301a96854a8a9da7868076f4cde2728 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 056/115] musikcube: revbump for ffmpeg-6.0

---
 srcpkgs/musikcube/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/musikcube/template b/srcpkgs/musikcube/template
index 193cb06a5fadb..1f78ada1451b6 100644
--- a/srcpkgs/musikcube/template
+++ b/srcpkgs/musikcube/template
@@ -1,7 +1,7 @@
 # Template file for 'musikcube'
 pkgname=musikcube
 version=3.0.0
-revision=1
+revision=2
 build_style=cmake
 make_cmd=make
 configure_args="-DNO_NCURSESW=1"

From 075cd6f0672e2d252fd8ac941519711e42cc86f1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 057/115] notcurses: revbump for ffmpeg-6.0

---
 srcpkgs/notcurses/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/notcurses/template b/srcpkgs/notcurses/template
index 6dd8a091319f7..3110c30c9aff2 100644
--- a/srcpkgs/notcurses/template
+++ b/srcpkgs/notcurses/template
@@ -1,7 +1,7 @@
 # Template file for 'notcurses'
 pkgname=notcurses
 version=3.0.9
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DUSE_STATIC=ON $(vopt_bool man USE_PANDOC)"
 hostmakedepends="pkg-config $(vopt_if man pandoc)"

From 9a8ab06fc58ede2c970e8260686a09d0bfe8a9db Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 058/115] obs: revbump for ffmpeg-6.0

---
 srcpkgs/obs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/obs/template b/srcpkgs/obs/template
index 7b69c630d30d4..2c8d68d71f3a1 100644
--- a/srcpkgs/obs/template
+++ b/srcpkgs/obs/template
@@ -1,7 +1,7 @@
 # Template file for 'obs'
 pkgname=obs
 version=29.1.2
-revision=1
+revision=2
 archs="i686* x86_64* ppc64le* aarch64*"
 build_style=cmake
 configure_args="-DOBS_VERSION_OVERRIDE=${version} -DENABLE_JACK=ON

From d032f8d3e4a3834dcb82a5f2ddaec6f25565ba8c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 059/115] olive: revbump for ffmpeg4-4.4.3

---
 srcpkgs/olive/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/olive/template b/srcpkgs/olive/template
index 12a46936c9900..5c2917b9c5124 100644
--- a/srcpkgs/olive/template
+++ b/srcpkgs/olive/template
@@ -1,10 +1,10 @@
 # Template file for 'olive'
 pkgname=olive
 version=0.1.2
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools pkg-config"
-makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg-devel frei0r-plugins"
+makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg4-devel frei0r-plugins"
 short_desc="Non-linear video editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"

From e6c1de48ced1e6c7456a41c9c4c7b3d429220333 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 060/115] omxplayer: revbump for ffmpeg4-4.4.3

---
 srcpkgs/omxplayer/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/omxplayer/template b/srcpkgs/omxplayer/template
index e70bf7873d4de..0e9bc70e7c8eb 100644
--- a/srcpkgs/omxplayer/template
+++ b/srcpkgs/omxplayer/template
@@ -1,10 +1,10 @@
 # Template file for 'omxplayer'
 pkgname=omxplayer
 version=20190102
-revision=1
+revision=2
 short_desc="Commandline OMX player for the Raspberry Pi"
 maintainer="Orphaned <orphan@voidlinux.org>"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://github.com/popcornmix/omxplayer"
 
 _commit="f06235cc9690a6d58187514452df8cf8fcdaacec"
@@ -15,7 +15,7 @@ checksum=af2d9450f8947842ea8c401fe9f71eec444013ebbdee29f2ac828c9c493c1329
 archs="armv6l* armv7l*"
 build_style=gnu-makefile
 hostmakedepends="curl pkg-config"
-makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg-devel dbus-devel"
+makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg4-devel dbus-devel"
 depends="freefont-ttf"
 
 do_build() {

From 10bfd6ebb1b5d5299861446c7f8def6602f5ff28 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 061/115] openshot: revbump for ffmpeg-6.0

---
 srcpkgs/openshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openshot/template b/srcpkgs/openshot/template
index 5d2adeba269fd..8f47851eef354 100644
--- a/srcpkgs/openshot/template
+++ b/srcpkgs/openshot/template
@@ -1,7 +1,7 @@
 # Template file for 'openshot'
 pkgname=openshot
 version=3.0.0
-revision=1
+revision=2
 build_style=python3-module
 hostmakedepends="python3 python3-setuptools"
 makedepends="ffmpeg-devel python3-PyQt5"

From a72e05832b784976d7e5d1f6094a53c2a99f6cc2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 062/115] opentoonz: revbump for ffmpeg-6.0

---
 srcpkgs/opentoonz/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/opentoonz/template b/srcpkgs/opentoonz/template
index ee9f7603f55fd..3e81834ca0edd 100644
--- a/srcpkgs/opentoonz/template
+++ b/srcpkgs/opentoonz/template
@@ -1,7 +1,7 @@
 # Template file for 'opentoonz'
 pkgname=opentoonz
 version=1.6.0
-revision=2
+revision=3
 build_wrksrc="toonz/sources"
 build_style=cmake
 make_cmd=make

From bb08dd1f42a6220c66df0687a9ce066d180db48a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 063/115] pianobar: revbump for ffmpeg-6.0

---
 srcpkgs/pianobar/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pianobar/template b/srcpkgs/pianobar/template
index e3febb821a451..1e3dc1bf9308e 100644
--- a/srcpkgs/pianobar/template
+++ b/srcpkgs/pianobar/template
@@ -1,7 +1,7 @@
 # Template file for 'pianobar'
 pkgname=pianobar
 version=2022.04.01
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="V=1"
 hostmakedepends="pkg-config"

From 37f47c49a9c0a572385a000033f0a567e5fb82d3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 064/115] ppsspp: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ppsspp/template | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/ppsspp/template b/srcpkgs/ppsspp/template
index 86511ef515dea..d56d5c37d5848 100644
--- a/srcpkgs/ppsspp/template
+++ b/srcpkgs/ppsspp/template
@@ -1,7 +1,7 @@
 # Template file for 'ppsspp'
 pkgname=ppsspp
 version=1.15.4
-revision=1
+revision=2
 _glslang_commit=b34f619e1c85810dcb3c578107d2e48ba4ee2b37
 _SPIRV_Cross_commit=4212eef67ed0ca048cb726a6767185504e7695e5
 _armips_commit=7bd1ec93d4586985ba1ef420b43b5e620f68695e
@@ -14,7 +14,7 @@ configure_args="-DHEADLESS=1 -DUSE_SYSTEM_FFMPEG=1 -DUNITTEST=ON
  -DUSING_QT_UI=$(vopt_if qt ON OFF) -DUSE_SYSTEM_ZSTD=ON
  -DARMIPS_USE_STD_FILESYSTEM=ON"
 hostmakedepends="pkg-config python3 $(vopt_if qt qt5-host-tools)"
-makedepends="zlib-devel glew-devel ffmpeg-devel libzip-devel
+makedepends="zlib-devel glew-devel ffmpeg4-devel libzip-devel
  snappy-devel rapidjson libpng-devel libzstd-devel
  $(vopt_if sdl2 SDL2-devel) $(vopt_if wayland wayland-devel)
  $(vopt_if qt 'qt5-devel qt5-multimedia-devel')"
@@ -68,13 +68,12 @@ post_extract() {
 
 }
 
-post_patch(){
+post_patch() {
 	# disable git versioning
 	vsed -e 's|find_package(Git)|# &|' -i git-version.cmake
 }
 
 do_install() {
-	vlicense LICENSE.TXT
 	vinstall icons/icon.svg 644 usr/share/pixmaps ppsspp.svg
 	vinstall Qt/PPSSPP.desktop 644 usr/share/applications
 	vbin build/PPSSPPHeadless ppsspp-headless

From 3aa99c11a584e8e5d824fdb3c588081df61ad760 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 065/115] pqiv: revbump for ffmpeg-6.0

---
 srcpkgs/pqiv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pqiv/template b/srcpkgs/pqiv/template
index 542fc27a2d32a..9308d949b6a1c 100644
--- a/srcpkgs/pqiv/template
+++ b/srcpkgs/pqiv/template
@@ -1,7 +1,7 @@
 # Template file for 'pqiv'
 pkgname=pqiv
 version=2.12
-revision=1
+revision=2
 build_style=gnu-makefile
 hostmakedepends="pkg-config"
 makedepends="glib-devel gtk+3-devel $(vopt_if ffmpeg ffmpeg-devel)

From b786b245b488e1ecf967661c38bf71f6236a942c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 066/115] qmmp: revbump for ffmpeg-6.0

---
 srcpkgs/qmmp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qmmp/template b/srcpkgs/qmmp/template
index 26c661ed16bea..a150d7441c7a6 100644
--- a/srcpkgs/qmmp/template
+++ b/srcpkgs/qmmp/template
@@ -1,7 +1,7 @@
 # Template file for 'qmmp'
 pkgname=qmmp
 version=1.6.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DUSE_HAL:BOOL=FALSE -DQMMP_DEFAULT_UI:STRING=simple"
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From 0e2f0584b1ab7c559a8748bfa16a95ca6f246914 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 067/115] qt5-webengine: update to 5.15.13

---
 .../chromium-media-filters-cpp14.patch        |  11 ++
 srcpkgs/qt5-webengine/patches/ffmpeg5.patch   | 179 ++++++++++++++++++
 srcpkgs/qt5-webengine/template                |  10 +-
 3 files changed, 195 insertions(+), 5 deletions(-)
 create mode 100644 srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/ffmpeg5.patch

diff --git a/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
new file mode 100644
index 0000000000000..04adc540f2cbc
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
@@ -0,0 +1,11 @@
+--- a/src/3rdparty/chromium/media/filters/BUILD.gn	2023-02-27 13:32:59.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/BUILD.gn	2023-04-02 17:21:39.204066384 -0400
+@@ -96,6 +96,8 @@
+     "//ui/gfx/geometry:geometry",
+   ]
+ 
++  cflags_cc = [ "-std=c++14" ]
++
+   libs = []
+ 
+   if (proprietary_codecs) {
diff --git a/srcpkgs/qt5-webengine/patches/ffmpeg5.patch b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..ac55e1634423a
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
@@ -0,0 +1,179 @@
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:57.732547446 -0400
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:09.486478995 -0400
+@@ -57,6 +57,8 @@
+ 
+ namespace {
+ 
++constexpr int64_t kRelativeTsBase = static_cast<int64_t>(0x7ffeffffffffffff);
++
+ void SetAVStreamDiscard(AVStream* stream, AVDiscard discard) {
+   DCHECK(stream);
+   stream->discard = discard;
+@@ -90,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+   if (stream->start_time != kNoFFmpegTimestamp)
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (stream->first_dts != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, stream->first_dts);
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -408,11 +398,11 @@
+   scoped_refptr<DecoderBuffer> buffer;
+ 
+   if (type() == DemuxerStream::TEXT) {
+-    int id_size = 0;
++    size_t id_size = 0;
+     uint8_t* id_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
+ 
+-    int settings_size = 0;
++    size_t settings_size = 0;
+     uint8_t* settings_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
+ 
+@@ -424,7 +414,7 @@
+     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
+                                      side_data.data(), side_data.size());
+   } else {
+-    int side_data_size = 0;
++    size_t side_data_size = 0;
+     uint8_t* side_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
+ 
+@@ -485,7 +475,7 @@
+                                        packet->size - data_offset);
+     }
+ 
+-    int skip_samples_size = 0;
++    size_t skip_samples_size = 0;
+     const uint32_t* skip_samples_ptr =
+         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
+             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
+@@ -1587,6 +1577,8 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++      continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+       lowest_start_time_stream = stream.get();
+@@ -1604,6 +1596,8 @@
+     if (stream && stream->type() == DemuxerStream::VIDEO &&
+         stream->IsEnabled()) {
+       video_stream = stream.get();
++      if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++        continue;
+       if (video_stream->start_time() <= seek_time) {
+         return video_stream;
+       }
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h qtwebengine-5.15.10/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h
+--- a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-07-11 22:12:47.917192788 -0500
+@@ -29,6 +29,7 @@ extern "C" {
+ #include <libavformat/avformat.h>
+ #include <libavformat/avio.h>
+ #include <libavutil/avutil.h>
++#include <libavutil/channel_layout.h>
+ #include <libavutil/imgutils.h>
+ #include <libavutil/log.h>
+ #include <libavutil/mastering_display_metadata.h>
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/audio_file_reader.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/audio_file_reader.cc
+--- a/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -85,7 +85,7 @@ bool AudioFileReader::OpenDemuxer() {
+ }
+ 
+ bool AudioFileReader::OpenDecoder() {
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (codec) {
+     // MP3 decodes to S16P which we don't support, tell it to use S16 instead.
+     if (codec_context_->sample_fmt == AV_SAMPLE_FMT_S16P)
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -329,7 +329,7 @@ bool FFmpegAudioDecoder::ConfigureDecode
+     }
+   }
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec ||
+       avcodec_open2(codec_context_.get(), codec, &codec_options) < 0) {
+     DLOG(ERROR) << "Could not initialize audio decoder: "
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -59,7 +59,6 @@ static int64_t AVIOSeekOperation(void* o
+ }
+ 
+ void FFmpegGlue::InitializeFFmpeg() {
+-  av_register_all();
+ }
+ 
+ static void LogContainer(bool is_local_file,
+@@ -95,9 +94,6 @@ FFmpegGlue::FFmpegGlue(FFmpegURLProtocol
+   // Enable fast, but inaccurate seeks for MP3.
+   format_context_->flags |= AVFMT_FLAG_FAST_SEEK;
+ 
+-  // Ensures we can read out various metadata bits like vp8 alpha.
+-  format_context_->flags |= AVFMT_FLAG_KEEP_SIDE_DATA;
+-
+   // Ensures format parsing errors will bail out. From an audit on 11/2017, all
+   // instances were real failures. Solves bugs like http://crbug.com/710791.
+   format_context_->error_recognition |= AV_EF_EXPLODE;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -391,7 +391,7 @@ bool FFmpegVideoDecoder::ConfigureDecode
+   if (decode_nalus_)
+     codec_context_->flags2 |= AV_CODEC_FLAG2_CHUNKS;
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
+     ReleaseFFmpegResources();
+     return false;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/media_file_checker.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/media_file_checker.cc
+--- a/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -68,7 +68,7 @@ bool MediaFileChecker::Start(base::TimeD
+       auto context = AVStreamToAVCodecContext(format_context->streams[i]);
+       if (!context)
+         continue;
+-      AVCodec* codec = avcodec_find_decoder(cp->codec_id);
++      const AVCodec* codec = avcodec_find_decoder(cp->codec_id);
+       if (codec && avcodec_open2(context.get(), codec, nullptr) >= 0) {
+         auto loop = std::make_unique<FFmpegDecodingLoop>(context.get());
+         stream_contexts[i] = {std::move(context), std::move(loop)};
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc qtwebengine-5.15.10/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc
+--- a/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -203,7 +203,7 @@ int32_t H264DecoderImpl::InitDecode(cons
+   // a pointer |this|.
+   av_context_->opaque = this;
+ 
+-  AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
+   if (!codec) {
+     // This is an indication that FFmpeg has not been initialized or it has not
+     // been compiled/initialized with the correct set of codecs.
diff --git a/srcpkgs/qt5-webengine/template b/srcpkgs/qt5-webengine/template
index 679d0fa2ad84b..b89fe4c1ad50a 100644
--- a/srcpkgs/qt5-webengine/template
+++ b/srcpkgs/qt5-webengine/template
@@ -1,9 +1,9 @@
 # Template file for 'qt5-webengine'
 pkgname=qt5-webengine
-version=5.15.11
-revision=4
+version=5.15.13
+revision=1
 _version="${version}-lts"
-_chromium_commit=be349eaf62e77955791d7bf29f893f1e8a37daf4
+_chromium_commit=e48df7803c7c98b0b2471c94057d32e44a301ad5
 archs="x86_64* i686* armv[67]* ppc64* aarch64*"
 create_wrksrc=yes
 build_style=qmake
@@ -32,8 +32,8 @@ license="GPL-3.0-or-later, LGPL-3.0-or-later"
 homepage="https://qt.io/"
 distfiles="https://github.com/qt/qtwebengine/archive/v${_version}.tar.gz
  https://github.com/qt/qtwebengine-chromium/archive/${_chromium_commit}.tar.gz"
-checksum="aa7466356c450c5f5870f979b93cd7e7e62da1165c328ffcab1a9928db18ad67
- 6f47ed8ab8cc062411f6f206da6353bc8263d6ed6d6290c689a05c01d91f646b"
+checksum="4b59838ed75ef788b59e1e412535a0e42dd9d311661fdeadb191b581ba815c63
+ a91686562b1d4e8b220e0bbcbab5feb64630e2de974b35ac034bf388af771a6c"
 
 no_generic_pkgconfig_link=yes
 build_options="sndio pipewire"

From f693208d6295ba4e8980a7e0a568f1eaefb5becc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 068/115] qt5: update to 5.15.8

---
 ...erywhere-opensource-src-5.15.8-kf5-1.patch | 12913 ++++++++++++++++
 srcpkgs/qt5/template                          |    12 +-
 2 files changed, 12919 insertions(+), 6 deletions(-)
 create mode 100644 srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch

diff --git a/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch b/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch
new file mode 100644
index 0000000000000..966c98bcd3bb1
--- /dev/null
+++ b/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch
@@ -0,0 +1,12913 @@
+Submitted By:            Pierre Labastie <pierre_dot_labastie_at_neuf_dot_fr>
+Date:                    2023-01-05
+Initial Package Version: 5.15.8
+Upstream Status:         Applied (according to KDE)
+Origin:                  KDE patch set
+Description:             Patch set maintained by the KDE folks
+see https://dot.kde.org/2021/04/06/announcing-kdes-qt-5-patch-collection
+Patch generated using the procedure in
+https://wiki.linuxfromscratch.org/blfs/ticket/17476#comment:3
+
+Submodule qtbase 4ee4fc18..9cf586d6:
+diff --git a/qtbase/mkspecs/common/android/qplatformdefs.h b/qtbase/mkspecs/common/android/qplatformdefs.h
+index f75bc4093b..2bd59410d4 100644
+--- a/qtbase/mkspecs/common/android/qplatformdefs.h
++++ b/qtbase/mkspecs/common/android/qplatformdefs.h
+@@ -144,11 +144,7 @@
+ #define QT_SIGNAL_ARGS          int
+ #define QT_SIGNAL_IGNORE        SIG_IGN
+ 
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+ #define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+ 
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+diff --git a/qtbase/mkspecs/features/mac/sdk.mk b/qtbase/mkspecs/features/mac/sdk.mk
+index f30b5830b4..a32ceacb6c 100644
+--- a/qtbase/mkspecs/features/mac/sdk.mk
++++ b/qtbase/mkspecs/features/mac/sdk.mk
+@@ -1,6 +1,6 @@
+ 
+ ifeq ($(QT_MAC_SDK_NO_VERSION_CHECK),)
+-    CHECK_SDK_COMMAND = /usr/bin/xcrun --sdk $(EXPORT_QMAKE_MAC_SDK) -show-sdk-version 2>&1
++    CHECK_SDK_COMMAND = /usr/bin/xcrun --sdk $(EXPORT_QMAKE_MAC_SDK) -show-sdk-version 2>/dev/null
+     CURRENT_MAC_SDK_VERSION := $(shell DEVELOPER_DIR=$(EXPORT_QMAKE_XCODE_DEVELOPER_PATH) $(CHECK_SDK_COMMAND))
+     ifneq ($(CURRENT_MAC_SDK_VERSION),$(EXPORT_QMAKE_MAC_SDK_VERSION))
+         # We don't want to complain about out of date SDK unless the target needs to be remade.
+diff --git a/qtbase/mkspecs/linux-clang/qplatformdefs.h b/qtbase/mkspecs/linux-clang/qplatformdefs.h
+index a818d973f0..c1ab72fbc6 100644
+--- a/qtbase/mkspecs/linux-clang/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-clang/qplatformdefs.h
+@@ -79,14 +79,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-g++/qplatformdefs.h b/qtbase/mkspecs/linux-g++/qplatformdefs.h
+index 13523f0702..4d2750d9ec 100644
+--- a/qtbase/mkspecs/linux-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-g++/qplatformdefs.h
+@@ -79,14 +79,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ < 2)
+-#define QT_SOCKLEN_T            int
+-#else
+-#define QT_SOCKLEN_T            socklen_t
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-llvm/qplatformdefs.h b/qtbase/mkspecs/linux-llvm/qplatformdefs.h
+index dc750ab1ef..d3cc39b47f 100644
+--- a/qtbase/mkspecs/linux-llvm/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-llvm/qplatformdefs.h
+@@ -80,14 +80,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h b/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
+index 4c4e53da2a..83baffb3e3 100644
+--- a/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
+@@ -85,16 +85,9 @@
+ #include "../common/posix/qplatformdefs.h"
+ 
+ #undef QT_OPEN_LARGEFILE
+-#undef QT_SOCKLEN_T
+ 
+ #define QT_OPEN_LARGEFILE       0
+ 
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #ifndef SIOCGIFBRDADDR
+ #  define SIOCGIFBRDADDR 0x8919
+ #endif
+diff --git a/qtbase/mkspecs/lynxos-g++/qplatformdefs.h b/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
+index 4339ea2b23..6007af0055 100644
+--- a/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
+@@ -72,14 +72,6 @@
+ 
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp b/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
+index c3c184258f..32af3f8f29 100644
+--- a/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
++++ b/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
+@@ -10,6 +10,7 @@
+ #include "libANGLE/HandleAllocator.h"
+ 
+ #include <algorithm>
++#include <limits>
+ 
+ #include "common/debug.h"
+ 
+diff --git a/qtbase/src/3rdparty/forkfd/forkfd_linux.c b/qtbase/src/3rdparty/forkfd/forkfd_linux.c
+index ffe0e9a5e2..b1f5408d11 100644
+--- a/qtbase/src/3rdparty/forkfd/forkfd_linux.c
++++ b/qtbase/src/3rdparty/forkfd/forkfd_linux.c
+@@ -82,7 +82,8 @@ static int sys_clone(unsigned long cloneflags, int *ptid)
+     return syscall(__NR_clone, cloneflags, child_stack, stack_size, ptid, newtls, ctid);
+ #elif defined(__arc__) || defined(__arm__) || defined(__aarch64__) || defined(__mips__) || \
+     defined(__nds32__) || defined(__hppa__) || defined(__powerpc__) || defined(__i386__) || \
+-    defined(__x86_64__) || defined(__xtensa__) || defined(__alpha__) || defined(__riscv)
++    defined(__x86_64__) || defined(__xtensa__) || defined(__alpha__) || defined(__riscv) || \
++    defined(__loongarch__)
+     /* ctid and newtls are inverted on CONFIG_CLONE_BACKWARDS architectures,
+      * but since both values are 0, there's no harm. */
+     return syscall(__NR_clone, cloneflags, child_stack, ptid, ctid, newtls);
+diff --git a/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java b/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
+index 5792b5b2f5..2f74750fcf 100644
+--- a/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
++++ b/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
+@@ -116,6 +116,7 @@ public class QtNative
+     public static QtThread m_qtThread = new QtThread();
+     private static HashMap<String, Uri> m_cachedUris = new HashMap<String, Uri>();
+     private static ArrayList<String> m_knownDirs = new ArrayList<String>();
++    private static final String NoPermissionErrorMessage = "No permissions to open Uri";
+ 
+     private static final Runnable runPendingCppRunnablesRunnable = new Runnable() {
+         @Override
+@@ -193,11 +194,10 @@ public class QtNative
+                     return iterUri;
+             }
+ 
+-            // Android 6 and earlier could still manage to open the file so we can return the
+-            // parsed uri here
+-            if (Build.VERSION.SDK_INT < 24)
+-                return parsedUri;
+-            return null;
++            // if we only have transient permissions on uri all the above will fail,
++            // but we will be able to read the file anyway, so continue with uri here anyway
++            // and check for SecurityExceptions later
++            return parsedUri;
+         } catch (SecurityException e) {
+             e.printStackTrace();
+             return null;
+@@ -244,7 +244,7 @@ public class QtNative
+         int error = -1;
+ 
+         if (uri == null) {
+-            Log.e(QtTAG, "openFdForContentUrl(): No permissions to open Uri");
++            Log.e(QtTAG, "openFdForContentUrl(): " + NoPermissionErrorMessage);
+             return error;
+         }
+ 
+@@ -254,12 +254,13 @@ public class QtNative
+             return fdDesc.detachFd();
+         } catch (FileNotFoundException e) {
+             e.printStackTrace();
+-            return error;
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "openFdForContentUrl(): Invalid Uri");
+             e.printStackTrace();
+-            return error;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return error;
+     }
+ 
+     public static long getSize(Context context, String contentUrl)
+@@ -270,7 +271,7 @@ public class QtNative
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+ 
+         if (uri == null) {
+-            Log.e(QtTAG, "getSize(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return size;
+         } else if (!m_cachedUris.containsKey(contentUrl)) {
+             m_cachedUris.put(contentUrl, uri);
+@@ -288,12 +289,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "getSize(): Invalid Uri");
+             e.printStackTrace();
+-            return size;
+         }  catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "getSize(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return size;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return size;
+     }
+ 
+     public static boolean checkFileExists(Context context, String contentUrl)
+@@ -303,7 +305,7 @@ public class QtNative
+         if (uri == null)
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+         if (uri == null) {
+-            Log.e(QtTAG, "checkFileExists(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return exists;
+         } else {
+             if (!m_cachedUris.containsKey(contentUrl))
+@@ -321,12 +323,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "checkFileExists(): Invalid Uri");
+             e.printStackTrace();
+-            return exists;
+         } catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "checkFileExists(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return false;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return exists;
+     }
+ 
+     public static boolean checkIfWritable(Context context, String contentUrl)
+@@ -344,7 +347,7 @@ public class QtNative
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+         }
+         if (uri == null) {
+-            Log.e(QtTAG, "isDir(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return isDir;
+         } else {
+             if (!m_cachedUris.containsKey(contentUrl))
+@@ -374,12 +377,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "checkIfDir(): Invalid Uri");
+             e.printStackTrace();
+-            return false;
+         } catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "checkIfDir(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return false;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return false;
+     }
+     public static String[] listContentsFromTreeUri(Context context, String contentUrl)
+     {
+diff --git a/qtbase/src/concurrent/qtconcurrentreducekernel.h b/qtbase/src/concurrent/qtconcurrentreducekernel.h
+index 8f9a938952..a98dedef2e 100644
+--- a/qtbase/src/concurrent/qtconcurrentreducekernel.h
++++ b/qtbase/src/concurrent/qtconcurrentreducekernel.h
+@@ -212,11 +212,13 @@ public:
+ 
+     inline bool shouldThrottle()
+     {
++        std::lock_guard<QMutex> locker(mutex);
+         return (resultsMapSize > (ReduceQueueThrottleLimit * threadCount));
+     }
+ 
+     inline bool shouldStartThread()
+     {
++        std::lock_guard<QMutex> locker(mutex);
+         return (resultsMapSize <= (ReduceQueueStartLimit * threadCount));
+     }
+ };
+diff --git a/qtbase/src/concurrent/qtconcurrentthreadengine.cpp b/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
+index ea6ce3ac42..7f91a2ba68 100644
+--- a/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
++++ b/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
+@@ -176,6 +176,39 @@ void ThreadEngineBase::startSingleThreaded()
+     finish();
+ }
+ 
++void ThreadEngineBase::startBlocking()
++{
++    start();
++    barrier.acquire();
++    startThreads();
++
++    bool throttled = false;
++#ifndef QT_NO_EXCEPTIONS
++    try {
++#endif
++        while (threadFunction() == ThrottleThread) {
++            if (threadThrottleExit()) {
++                throttled = true;
++                break;
++            }
++        }
++#ifndef QT_NO_EXCEPTIONS
++    } catch (QException &e) {
++        handleException(e);
++    } catch (...) {
++        handleException(QUnhandledException());
++    }
++#endif
++
++    if (throttled == false) {
++        barrier.release();
++    }
++
++    barrier.wait();
++    finish();
++    exceptionStore.throwPossibleException();
++}
++
+ void ThreadEngineBase::startThread()
+ {
+     startThreadInternal();
+diff --git a/qtbase/src/concurrent/qtconcurrentthreadengine.h b/qtbase/src/concurrent/qtconcurrentthreadengine.h
+index 7c30cebdbc..a4c8548cc4 100644
+--- a/qtbase/src/concurrent/qtconcurrentthreadengine.h
++++ b/qtbase/src/concurrent/qtconcurrentthreadengine.h
+@@ -91,6 +91,7 @@ public:
+     ThreadEngineBase();
+     virtual ~ThreadEngineBase();
+     void startSingleThreaded();
++    void startBlocking();
+     void startThread();
+     bool isCanceled();
+     void waitForResume();
+@@ -143,6 +144,15 @@ public:
+         return result();
+     }
+ 
++    // Runs the user algorithm using multiple threads.
++    // This function blocks until the algorithm is finished,
++    // and then returns the result.
++    T *startBlocking()
++    {
++        ThreadEngineBase::startBlocking();
++        return result();
++    }
++
+     // Runs the user algorithm using multiple threads.
+     // Does not block, returns a future.
+     QFuture<T> startAsynchronously()
+@@ -223,6 +233,13 @@ class ThreadEngineStarter : public ThreadEngineStarterBase<T>
+ public:
+     ThreadEngineStarter(TypedThreadEngine *eng)
+         : Base(eng) { }
++
++    T startBlocking()
++    {
++        T t = *this->threadEngine->startBlocking();
++        delete this->threadEngine;
++        return t;
++    }
+ };
+ 
+ // Full template specialization where T is void.
+@@ -232,6 +249,12 @@ class ThreadEngineStarter<void> : public ThreadEngineStarterBase<void>
+ public:
+     ThreadEngineStarter(ThreadEngine<void> *_threadEngine)
+         : ThreadEngineStarterBase<void>(_threadEngine) {}
++
++    void startBlocking()
++    {
++        this->threadEngine->startBlocking();
++        delete this->threadEngine;
++    }
+ };
+ 
+ //! [qtconcurrentthreadengine-1]
+diff --git a/qtbase/src/corelib/animation/qvariantanimation.cpp b/qtbase/src/corelib/animation/qvariantanimation.cpp
+index 98b02f0202..eac1524107 100644
+--- a/qtbase/src/corelib/animation/qvariantanimation.cpp
++++ b/qtbase/src/corelib/animation/qvariantanimation.cpp
+@@ -276,7 +276,9 @@ void QVariantAnimationPrivate::setCurrentValueForProgress(const qreal progress)
+ 
+     const qreal startProgress = currentInterval.start.first;
+     const qreal endProgress = currentInterval.end.first;
+-    const qreal localProgress = (progress - startProgress) / (endProgress - startProgress);
++    const qreal localProgress =
++            qIsNull(progress - startProgress) ? 0.0 // avoid 0/0 below
++            /* else */                        : (progress - startProgress) / (endProgress - startProgress);
+ 
+     QVariant ret = q->interpolated(currentInterval.start.second,
+                                    currentInterval.end.second,
+diff --git a/qtbase/src/corelib/global/qnamespace.h b/qtbase/src/corelib/global/qnamespace.h
+index ad4150b317..bf19b1627b 100644
+--- a/qtbase/src/corelib/global/qnamespace.h
++++ b/qtbase/src/corelib/global/qnamespace.h
+@@ -1864,7 +1864,7 @@ public:
+     QT_Q_ENUM(TimerType)
+     QT_Q_ENUM(ScrollPhase)
+     QT_Q_ENUM(MouseEventSource)
+-    QT_Q_FLAG(MouseEventFlag)
++    QT_Q_FLAG(MouseEventFlags)
+     QT_Q_ENUM(ChecksumType)
+     QT_Q_ENUM(HighDpiScaleFactorRoundingPolicy)
+     QT_Q_ENUM(TabFocusBehavior)
+diff --git a/qtbase/src/corelib/global/qrandom.cpp b/qtbase/src/corelib/global/qrandom.cpp
+index 10672c1f92..25f87c7e6a 100644
+--- a/qtbase/src/corelib/global/qrandom.cpp
++++ b/qtbase/src/corelib/global/qrandom.cpp
+@@ -383,7 +383,6 @@ struct QRandomGenerator::SystemAndGlobalGenerators
+ 
+         constexpr SystemAndGlobalGenerators g = {};
+         Q_UNUSED(g);
+-        Q_STATIC_ASSERT(std::is_literal_type<SystemAndGlobalGenerators>::value);
+ #endif
+     }
+ 
+diff --git a/qtbase/src/corelib/io/qbuffer.cpp b/qtbase/src/corelib/io/qbuffer.cpp
+index 595fcd2724..032c0ddd4b 100644
+--- a/qtbase/src/corelib/io/qbuffer.cpp
++++ b/qtbase/src/corelib/io/qbuffer.cpp
+@@ -41,6 +41,8 @@
+ #include <QtCore/qmetaobject.h>
+ #include "private/qiodevice_p.h"
+ 
++#include <limits>
++
+ QT_BEGIN_NAMESPACE
+ 
+ /** QBufferPrivate **/
+@@ -366,7 +368,9 @@ qint64 QBuffer::size() const
+ bool QBuffer::seek(qint64 pos)
+ {
+     Q_D(QBuffer);
+-    if (pos > d->buf->size() && isWritable()) {
++    const auto oldBufSize = d->buf->size();
++    constexpr qint64 MaxSeekPos = (std::numeric_limits<decltype(oldBufSize)>::max)();
++    if (pos <= MaxSeekPos && pos > oldBufSize && isWritable()) {
+         if (seek(d->buf->size())) {
+             const qint64 gapSize = pos - d->buf->size();
+             if (write(QByteArray(gapSize, 0)) != gapSize) {
+@@ -377,7 +381,7 @@ bool QBuffer::seek(qint64 pos)
+             return false;
+         }
+     } else if (pos > d->buf->size() || pos < 0) {
+-        qWarning("QBuffer::seek: Invalid pos: %d", int(pos));
++        qWarning("QBuffer::seek: Invalid pos: %lld", pos);
+         return false;
+     }
+     return QIODevice::seek(pos);
+diff --git a/qtbase/src/corelib/io/qfilesystemengine_win.cpp b/qtbase/src/corelib/io/qfilesystemengine_win.cpp
+index 81d3a71986..c86ed1f9b0 100644
+--- a/qtbase/src/corelib/io/qfilesystemengine_win.cpp
++++ b/qtbase/src/corelib/io/qfilesystemengine_win.cpp
+@@ -664,14 +664,14 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry)
+     return QFileSystemEntry(ret, QFileSystemEntry::FromInternalPath());
+ }
+ 
+-#if defined(Q_CC_MINGW) && WINVER < 0x0602 //  Windows 8 onwards
++#if defined(Q_CC_MINGW) && WINVER < 0x0602 && _WIN32_WINNT < _WIN32_WINNT_WIN8 //  Windows 8 onwards
+ 
+ typedef struct _FILE_ID_INFO {
+     ULONGLONG VolumeSerialNumber;
+     FILE_ID_128 FileId;
+ } FILE_ID_INFO, *PFILE_ID_INFO;
+ 
+-#endif // if defined (Q_CC_MINGW) && WINVER < 0x0602
++#endif // if defined(Q_CC_MINGW) && WINVER < 0x0602 && _WIN32_WINNT < _WIN32_WINNT_WIN8
+ 
+ // File ID for Windows up to version 7 and FAT32 drives
+ static inline QByteArray fileId(HANDLE handle)
+diff --git a/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp b/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
+index 94d9d06bcb..27e0b13b0b 100644
+--- a/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
++++ b/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
+@@ -366,7 +366,9 @@ void QInotifyFileSystemWatcherEngine::readFromInotify()
+     // qDebug("QInotifyFileSystemWatcherEngine::readFromInotify");
+ 
+     int buffSize = 0;
+-    ioctl(inotifyFd, FIONREAD, (char *) &buffSize);
++    if (ioctl(inotifyFd, FIONREAD, (char *) &buffSize) == -1 || buffSize == 0)
++        return;
++
+     QVarLengthArray<char, 4096> buffer(buffSize);
+     buffSize = read(inotifyFd, buffer.data(), buffSize);
+     char *at = buffer.data();
+diff --git a/qtbase/src/corelib/io/qlockfile_win.cpp b/qtbase/src/corelib/io/qlockfile_win.cpp
+index 277f8d4230..38ecef5550 100644
+--- a/qtbase/src/corelib/io/qlockfile_win.cpp
++++ b/qtbase/src/corelib/io/qlockfile_win.cpp
+@@ -48,6 +48,8 @@
+ #include "QtCore/qdebug.h"
+ #include "QtCore/qthread.h"
+ 
++#include "private/qsystemlibrary_p.h"
++
+ QT_BEGIN_NAMESPACE
+ 
+ static inline bool fileExists(const wchar_t *fileName)
+@@ -150,7 +152,7 @@ QString QLockFilePrivate::processNameByPid(qint64 pid)
+ #if !defined(Q_OS_WINRT)
+     typedef DWORD (WINAPI *GetModuleFileNameExFunc)(HANDLE, HMODULE, LPTSTR, DWORD);
+ 
+-    HMODULE hPsapi = LoadLibraryA("psapi");
++    HMODULE hPsapi = QSystemLibrary::load(L"psapi");
+     if (!hPsapi)
+         return QString();
+     GetModuleFileNameExFunc qGetModuleFileNameEx = reinterpret_cast<GetModuleFileNameExFunc>(
+diff --git a/qtbase/src/corelib/io/qprocess_unix.cpp b/qtbase/src/corelib/io/qprocess_unix.cpp
+index 50390e57f5..15c8f30745 100644
+--- a/qtbase/src/corelib/io/qprocess_unix.cpp
++++ b/qtbase/src/corelib/io/qprocess_unix.cpp
+@@ -1,7 +1,7 @@
+ /****************************************************************************
+ **
+ ** Copyright (C) 2016 The Qt Company Ltd.
+-** Copyright (C) 2016 Intel Corporation.
++** Copyright (C) 2022 Intel Corporation.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtCore module of the Qt Toolkit.
+@@ -422,14 +422,15 @@ void QProcessPrivate::startProcess()
+     // Add the program name to the argument list.
+     argv[0] = nullptr;
+     if (!program.contains(QLatin1Char('/'))) {
++        // findExecutable() returns its argument if it's an absolute path,
++        // otherwise it searches $PATH; returns empty if not found (we handle
++        // that case much later)
+         const QString &exeFilePath = QStandardPaths::findExecutable(program);
+-        if (!exeFilePath.isEmpty()) {
+-            const QByteArray &tmp = QFile::encodeName(exeFilePath);
+-            argv[0] = ::strdup(tmp.constData());
+-        }
+-    }
+-    if (!argv[0])
++        const QByteArray &tmp = QFile::encodeName(exeFilePath);
++        argv[0] = ::strdup(tmp.constData());
++    } else {
+         argv[0] = ::strdup(encodedProgramName.constData());
++    }
+ 
+     // Add every argument to the list
+     for (int i = 0; i < arguments.count(); ++i)
+@@ -983,15 +984,16 @@ bool QProcessPrivate::startDetached(qint64 *pid)
+                 envp = _q_dupEnvironment(environment.d.constData()->vars, &envc);
+             }
+ 
+-            QByteArray tmp;
+             if (!program.contains(QLatin1Char('/'))) {
++                // findExecutable() returns its argument if it's an absolute path,
++                // otherwise it searches $PATH; returns empty if not found (we handle
++                // that case much later)
+                 const QString &exeFilePath = QStandardPaths::findExecutable(program);
+-                if (!exeFilePath.isEmpty())
+-                    tmp = QFile::encodeName(exeFilePath);
++                const QByteArray &tmp = QFile::encodeName(exeFilePath);
++                argv[0] = ::strdup(tmp.constData());
++            } else {
++                argv[0] = ::strdup(QFile::encodeName(program));
+             }
+-            if (tmp.isEmpty())
+-                tmp = QFile::encodeName(program);
+-            argv[0] = tmp.data();
+ 
+             if (envp)
+                 qt_safe_execve(argv[0], argv, envp);
+diff --git a/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp b/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
+index 3a79c502af..997a634e76 100644
+--- a/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
++++ b/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
+@@ -3196,9 +3196,8 @@ bool QAbstractItemModel::beginMoveColumns(const QModelIndex &sourceParent, int s
+     destinationChange.needsAdjust = destinationParent.isValid() && destinationParent.row() >= sourceLast && destinationParent.parent() == sourceParent;
+     d->changes.push(destinationChange);
+ 
+-    d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Horizontal);
+-
+     emit columnsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, QPrivateSignal());
++    d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Horizontal);
+     return true;
+ }
+ 
+@@ -3231,7 +3230,6 @@ void QAbstractItemModel::endMoveColumns()
+       adjustedSource = createIndex(adjustedSource.row(), adjustedSource.column() + numMoved, adjustedSource.internalPointer());
+ 
+     d->itemsMoved(adjustedSource, removeChange.first, removeChange.last, adjustedDestination, insertChange.first, Qt::Horizontal);
+-
+     emit columnsMoved(adjustedSource, removeChange.first, removeChange.last, adjustedDestination, insertChange.first, QPrivateSignal());
+ }
+ 
+diff --git a/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+index dc6379d9fb..c5e287ee84 100644
+--- a/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
++++ b/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+@@ -939,8 +939,9 @@ void QSortFilterProxyModelPrivate::insert_source_items(
+                 q->beginInsertColumns(proxy_parent, proxy_start, proxy_end);
+         }
+ 
+-        for (int i = 0; i < source_items.size(); ++i)
+-            proxy_to_source.insert(proxy_start + i, source_items.at(i));
++        // TODO: use the range QList::insert() overload once it is implemented (QTBUG-58633).
++        proxy_to_source.insert(proxy_start, source_items.size(), 0);
++        std::copy(source_items.cbegin(), source_items.cend(), proxy_to_source.begin() + proxy_start);
+ 
+         build_source_to_proxy_mapping(proxy_to_source, source_to_proxy);
+ 
+@@ -3123,8 +3124,9 @@ bool QSortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex &
+ 
+     if (d->filter_data.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();
+@@ -3133,9 +3135,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.hasMatch(key);
+ }
+diff --git a/qtbase/src/corelib/kernel/qcoreapplication.cpp b/qtbase/src/corelib/kernel/qcoreapplication.cpp
+index ca2864df83..132b2eae52 100644
+--- a/qtbase/src/corelib/kernel/qcoreapplication.cpp
++++ b/qtbase/src/corelib/kernel/qcoreapplication.cpp
+@@ -1157,7 +1157,7 @@ static bool doNotify(QObject *receiver, QEvent *event)
+ bool QCoreApplicationPrivate::sendThroughApplicationEventFilters(QObject *receiver, QEvent *event)
+ {
+     // We can't access the application event filters outside of the main thread (race conditions)
+-    Q_ASSERT(receiver->d_func()->threadData.loadRelaxed()->thread.loadAcquire() == mainThread());
++    Q_ASSERT(receiver->d_func()->threadData.loadAcquire()->thread.loadRelaxed() == mainThread());
+ 
+     if (extraData) {
+         // application event filters are only called for objects in the GUI thread
+diff --git a/qtbase/src/corelib/kernel/qobject.cpp b/qtbase/src/corelib/kernel/qobject.cpp
+index 1eb79138d9..36cd780ee1 100644
+--- a/qtbase/src/corelib/kernel/qobject.cpp
++++ b/qtbase/src/corelib/kernel/qobject.cpp
+@@ -1010,7 +1010,7 @@ QObject::~QObject()
+         emit destroyed(this);
+     }
+ 
+-    if (d->declarativeData) {
++    if (!d->isDeletingChildren && d->declarativeData) {
+         if (static_cast<QAbstractDeclarativeDataImpl*>(d->declarativeData)->ownedByQml1) {
+             if (QAbstractDeclarativeData::destroyed_qml1)
+                 QAbstractDeclarativeData::destroyed_qml1(d->declarativeData, this);
+@@ -1580,7 +1580,7 @@ void QObject::moveToThread(QThread *targetThread)
+ 
+     QThreadData *currentData = QThreadData::current();
+     QThreadData *targetData = targetThread ? QThreadData::get2(targetThread) : nullptr;
+-    QThreadData *thisThreadData = d->threadData.loadRelaxed();
++    QThreadData *thisThreadData = d->threadData.loadAcquire();
+     if (!thisThreadData->thread.loadAcquire() && currentData == targetData) {
+         // one exception to the rule: we allow moving objects with no thread affinity to the current thread
+         currentData = d->threadData;
+@@ -2620,7 +2620,7 @@ int QObject::receivers(const char *signal) const
+         if (!d->isSignalConnected(signal_index))
+             return receivers;
+ 
+-        if (d->declarativeData && QAbstractDeclarativeData::receivers) {
++        if (!d->isDeletingChildren && d->declarativeData && QAbstractDeclarativeData::receivers) {
+             receivers += QAbstractDeclarativeData::receivers(d->declarativeData, this,
+                                                              signal_index);
+         }
+diff --git a/qtbase/src/corelib/kernel/qobject_p.h b/qtbase/src/corelib/kernel/qobject_p.h
+index 0b827a52ca..13ffb88999 100644
+--- a/qtbase/src/corelib/kernel/qobject_p.h
++++ b/qtbase/src/corelib/kernel/qobject_p.h
+@@ -444,7 +444,7 @@ inline void QObjectPrivate::checkForIncompatibleLibraryVersion(int version) cons
+ 
+ inline bool QObjectPrivate::isDeclarativeSignalConnected(uint signal_index) const
+ {
+-    return declarativeData && QAbstractDeclarativeData::isSignalConnected
++    return !isDeletingChildren && declarativeData && QAbstractDeclarativeData::isSignalConnected
+             && QAbstractDeclarativeData::isSignalConnected(declarativeData, q_func(), signal_index);
+ }
+ 
+diff --git a/qtbase/src/corelib/kernel/qtranslator.cpp b/qtbase/src/corelib/kernel/qtranslator.cpp
+index 2812ffb7ea..bc0177c5ec 100644
+--- a/qtbase/src/corelib/kernel/qtranslator.cpp
++++ b/qtbase/src/corelib/kernel/qtranslator.cpp
+@@ -902,7 +902,7 @@ static QString getMessage(const uchar *m, const uchar *end, const char *context,
+             goto end;
+         case Tag_Translation: {
+             int len = read32(m);
+-            if (len % 1)
++            if (len & 1)
+                 return QString();
+             m += 4;
+             if (!numerus--) {
+diff --git a/qtbase/src/corelib/mimetypes/qmimedatabase.cpp b/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
+index 9de22cef33..ff868a3268 100644
+--- a/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
+@@ -389,20 +389,23 @@ QMimeType QMimeDatabasePrivate::mimeTypeForFileNameAndData(const QString &fileNa
+         // Disambiguate conflicting extensions (if magic matching found something)
+         if (candidateByData.isValid() && magicAccuracy > 0) {
+             const QString sniffedMime = candidateByData.name();
+-            // If the sniffedMime matches a glob match, use it
++            // If the sniffedMime matches a highest-weight glob match, use it
+             if (candidatesByName.m_matchingMimeTypes.contains(sniffedMime)) {
+                 *accuracyPtr = 100;
+                 return candidateByData;
+             }
+-            for (const QString &m : qAsConst(candidatesByName.m_matchingMimeTypes)) {
++            for (const QString &m : qAsConst(candidatesByName.m_allMatchingMimeTypes)) {
+                 if (inherits(m, sniffedMime)) {
+                     // We have magic + pattern pointing to this, so it's a pretty good match
+                     *accuracyPtr = 100;
+                     return mimeTypeForName(m);
+                 }
+             }
+-            *accuracyPtr = magicAccuracy;
+-            return candidateByData;
++            if (candidatesByName.m_allMatchingMimeTypes.isEmpty()) {
++                // No glob, use magic
++                *accuracyPtr = magicAccuracy;
++                return candidateByData;
++            }
+         }
+     }
+ 
+diff --git a/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp b/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
+index a81112d227..fa8f4c545d 100644
+--- a/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
+@@ -83,7 +83,10 @@ void QMimeGlobMatchResult::addMatch(const QString &mimeType, int weight, const Q
+     }
+     if (!m_matchingMimeTypes.contains(mimeType)) {
+         m_matchingMimeTypes.append(mimeType);
+-        m_allMatchingMimeTypes.append(mimeType);
++        if (replace)
++            m_allMatchingMimeTypes.prepend(mimeType); // highest-weight first
++        else
++            m_allMatchingMimeTypes.append(mimeType);
+         m_knownSuffixLength = knownSuffixLength;
+     }
+ }
+@@ -94,7 +97,7 @@ QMimeGlobPattern::PatternType QMimeGlobPattern::detectPatternType(const QString
+     if (!patternLength)
+         return OtherPattern;
+ 
+-    const bool starCount = pattern.count(QLatin1Char('*')) == 1;
++    const int starCount = pattern.count(QLatin1Char('*'));
+     const bool hasSquareBracket = pattern.indexOf(QLatin1Char('[')) != -1;
+     const bool hasQuestionMark = pattern.indexOf(QLatin1Char('?')) != -1;
+ 
+@@ -106,10 +109,10 @@ QMimeGlobPattern::PatternType QMimeGlobPattern::detectPatternType(const QString
+             // Patterns like "README*" (well this is currently the only one like that...)
+             if (pattern.at(patternLength - 1) == QLatin1Char('*'))
+                 return PrefixPattern;
+-        }
+-        // Names without any wildcards like "README"
+-        if (starCount == 0)
++        } else if (starCount == 0) {
++            // Names without any wildcards like "README"
+             return LiteralPattern;
++        }
+     }
+ 
+     if (pattern == QLatin1String("[0-9][0-9][0-9].vdr"))
+diff --git a/qtbase/src/corelib/mimetypes/qmimeprovider.cpp b/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
+index 258dddf8cb..4642d0f2d0 100644
+--- a/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
+@@ -244,15 +244,18 @@ void QMimeBinaryProvider::addFileNameMatches(const QString &fileName, QMimeGlobM
+     const QString lowerFileName = fileName.toLower();
+     // Check literals (e.g. "Makefile")
+     matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosLiteralListOffset), fileName);
+-    // Check complex globs (e.g. "callgrind.out[0-9]*")
+-    matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosGlobListOffset), fileName);
+     // Check the very common *.txt cases with the suffix tree
+-    const int reverseSuffixTreeOffset = m_cacheFile->getUint32(PosReverseSuffixTreeOffset);
+-    const int numRoots = m_cacheFile->getUint32(reverseSuffixTreeOffset);
+-    const int firstRootOffset = m_cacheFile->getUint32(reverseSuffixTreeOffset + 4);
+-    matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, lowerFileName, lowerFileName.length() - 1, false);
++    if (result.m_matchingMimeTypes.isEmpty()) {
++        const int reverseSuffixTreeOffset = m_cacheFile->getUint32(PosReverseSuffixTreeOffset);
++        const int numRoots = m_cacheFile->getUint32(reverseSuffixTreeOffset);
++        const int firstRootOffset = m_cacheFile->getUint32(reverseSuffixTreeOffset + 4);
++        matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, lowerFileName, lowerFileName.length() - 1, false);
++        if (result.m_matchingMimeTypes.isEmpty())
++            matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, fileName, fileName.length() - 1, true);
++    }
++    // Check complex globs (e.g. "callgrind.out[0-9]*" or "README*")
+     if (result.m_matchingMimeTypes.isEmpty())
+-        matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, fileName, fileName.length() - 1, true);
++        matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosGlobListOffset), fileName);
+ }
+ 
+ void QMimeBinaryProvider::matchGlobList(QMimeGlobMatchResult &result, CacheFile *cacheFile, int off, const QString &fileName)
+diff --git a/qtbase/src/corelib/serialization/qjsonparser.cpp b/qtbase/src/corelib/serialization/qjsonparser.cpp
+index 17e6f111ab..2e40b6c8fb 100644
+--- a/qtbase/src/corelib/serialization/qjsonparser.cpp
++++ b/qtbase/src/corelib/serialization/qjsonparser.cpp
+@@ -379,10 +379,30 @@ error:
+     return QCborValue();
+ }
+ 
++// We need to retain the _last_ value for any duplicate keys and we need to deref containers.
++// Therefore the manual implementation of std::unique().
++template<typename Iterator, typename Compare, typename Assign>
++static Iterator customAssigningUniqueLast(Iterator first, Iterator last,
++                                          Compare compare, Assign assign)
++{
++    first = std::adjacent_find(first, last, compare);
++    if (first == last)
++        return last;
++
++    Iterator result = first;
++    while (++first != last) {
++        if (!compare(*result, *first))
++            ++result;
++        if (result != first)
++            assign(*result, *first);
++    }
++
++    return ++result;
++}
++
+ static void sortContainer(QCborContainerPrivate *container)
+ {
+     using Forward = QJsonPrivate::KeyIterator;
+-    using Reverse = std::reverse_iterator<Forward>;
+     using Value = Forward::value_type;
+ 
+     auto compare = [container](const Value &a, const Value &b)
+@@ -420,17 +440,31 @@ static void sortContainer(QCborContainerPrivate *container)
+         }
+     };
+ 
+-    std::sort(Forward(container->elements.begin()), Forward(container->elements.end()),
+-              [&compare](const Value &a, const Value &b) { return compare(a, b) < 0; });
++    // The elements' containers are owned by the outer container, not by the elements themselves.
++    auto move = [](Forward::reference target, Forward::reference source)
++    {
++        QtCbor::Element &targetValue = target.value();
++
++        // If the target has a container, deref it before overwriting, so that we don't leak.
++        if (targetValue.flags & QtCbor::Element::IsContainer)
++            targetValue.container->deref();
++
++        // Do not move, so that we can clear the value afterwards.
++        target = source;
++
++        // Clear the source value, so that we don't store the same container twice.
++        source.value() = QtCbor::Element();
++    };
++
++    std::stable_sort(
++                Forward(container->elements.begin()), Forward(container->elements.end()),
++                [&compare](const Value &a, const Value &b) { return compare(a, b) < 0; });
+ 
+-    // We need to retain the _last_ value for any duplicate keys. Therefore the reverse dance here.
+-    auto it = std::unique(Reverse(container->elements.end()), Reverse(container->elements.begin()),
+-                          [&compare](const Value &a, const Value &b) {
+-        return compare(a, b) == 0;
+-    }).base().elementsIterator();
++    Forward result = customAssigningUniqueLast(
++                Forward(container->elements.begin()),  Forward(container->elements.end()),
++                [&compare](const Value &a, const Value &b) { return compare(a, b) == 0; }, move);
+ 
+-    // The erase from beginning is expensive but hopefully rare.
+-    container->elements.erase(container->elements.begin(), it);
++    container->elements.erase(result.elementsIterator(), container->elements.end());
+ }
+ 
+ 
+diff --git a/qtbase/src/corelib/serialization/qxmlstream.cpp b/qtbase/src/corelib/serialization/qxmlstream.cpp
+index b2f846544d..7cd457ba3a 100644
+--- a/qtbase/src/corelib/serialization/qxmlstream.cpp
++++ b/qtbase/src/corelib/serialization/qxmlstream.cpp
+@@ -980,7 +980,7 @@ inline uint QXmlStreamReaderPrivate::peekChar()
+ bool QXmlStreamReaderPrivate::scanUntil(const char *str, short tokenToInject)
+ {
+     int pos = textBuffer.size();
+-    int oldLineNumber = lineNumber;
++    const auto oldLineNumber = lineNumber;
+ 
+     uint c;
+     while ((c = getChar()) != StreamEOF) {
+diff --git a/qtbase/src/corelib/text/qstring.cpp b/qtbase/src/corelib/text/qstring.cpp
+index 3e88ab4859..8deeae47bb 100644
+--- a/qtbase/src/corelib/text/qstring.cpp
++++ b/qtbase/src/corelib/text/qstring.cpp
+@@ -12312,7 +12312,7 @@ static qsizetype qLastIndexOf(Haystack haystack0, qsizetype from,
+     const auto needle = needle0.data();
+     const auto *end = haystack;
+     haystack += from;
+-    const std::size_t sl_minus_1 = sl - 1;
++    const std::size_t sl_minus_1 = sl ? sl - 1 : 0;
+     const auto *n = needle + sl_minus_1;
+     const auto *h = haystack + sl_minus_1;
+     std::size_t hashNeedle = 0, hashHaystack = 0;
+diff --git a/qtbase/src/corelib/text/qstringiterator_p.h b/qtbase/src/corelib/text/qstringiterator_p.h
+index 219589b6e4..1d0c66cc78 100644
+--- a/qtbase/src/corelib/text/qstringiterator_p.h
++++ b/qtbase/src/corelib/text/qstringiterator_p.h
+@@ -61,6 +61,8 @@ class QStringIterator
+ {
+     QString::const_iterator i, pos, e;
+     Q_STATIC_ASSERT((std::is_same<QString::const_iterator, const QChar *>::value));
++    static bool less(const QChar *lhs, const QChar *rhs) noexcept
++    { return std::less<QString::const_iterator>{}(lhs, rhs); }
+ public:
+     explicit QStringIterator(QStringView string, qsizetype idx = 0)
+         : i(string.begin()),
+@@ -95,7 +97,8 @@ public:
+ 
+     inline void setPosition(QString::const_iterator position)
+     {
+-        Q_ASSERT_X(i <= position && position <= e, Q_FUNC_INFO, "position out of bounds");
++        Q_ASSERT_X(!less(position, i) && !less(e, position),
++                   Q_FUNC_INFO, "position out of bounds");
+         pos = position;
+     }
+ 
+@@ -103,7 +106,7 @@ public:
+ 
+     inline bool hasNext() const
+     {
+-        return pos < e;
++        return less(pos, e);
+     }
+ 
+     inline void advance()
+@@ -120,16 +123,20 @@ public:
+     {
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+-        if (Q_UNLIKELY((pos++)->isHighSurrogate()))
++        if (Q_UNLIKELY((pos++)->isHighSurrogate())) {
++            Q_ASSERT(hasNext() && pos->isLowSurrogate());
+             ++pos;
++        }
+     }
+ 
+     inline uint peekNextUnchecked() const
+     {
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+-        if (Q_UNLIKELY(pos->isHighSurrogate()))
++        if (Q_UNLIKELY(pos->isHighSurrogate())) {
++            Q_ASSERT(less(pos + 1, e) && pos[1].isLowSurrogate());
+             return QChar::surrogateToUcs4(pos[0], pos[1]);
++        }
+ 
+         return pos->unicode();
+     }
+@@ -155,8 +162,10 @@ public:
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+         const QChar cur = *pos++;
+-        if (Q_UNLIKELY(cur.isHighSurrogate()))
++        if (Q_UNLIKELY(cur.isHighSurrogate())) {
++            Q_ASSERT(hasNext() && pos->isLowSurrogate());
+             return QChar::surrogateToUcs4(cur, *pos++);
++        }
+         return cur.unicode();
+     }
+ 
+@@ -166,7 +175,7 @@ public:
+ 
+         const QChar uc = *pos++;
+         if (Q_UNLIKELY(uc.isSurrogate())) {
+-            if (Q_LIKELY(uc.isHighSurrogate() && pos < e && pos->isLowSurrogate()))
++            if (Q_LIKELY(uc.isHighSurrogate() && hasNext() && pos->isLowSurrogate()))
+                 return QChar::surrogateToUcs4(uc, *pos++);
+             return invalidAs;
+         }
+@@ -178,7 +187,7 @@ public:
+ 
+     inline bool hasPrevious() const
+     {
+-        return pos > i;
++        return less(i, pos);
+     }
+ 
+     inline void recede()
+@@ -196,16 +205,20 @@ public:
+     {
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+-        if (Q_UNLIKELY((--pos)->isLowSurrogate()))
++        if (Q_UNLIKELY((--pos)->isLowSurrogate())) {
++            Q_ASSERT(hasPrevious() && pos[-1].isHighSurrogate());
+             --pos;
++        }
+     }
+ 
+     inline uint peekPreviousUnchecked() const
+     {
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+-        if (Q_UNLIKELY(pos[-1].isLowSurrogate()))
++        if (Q_UNLIKELY(pos[-1].isLowSurrogate())) {
++            Q_ASSERT(less(i + 1, pos) && pos[-2].isHighSurrogate());
+             return QChar::surrogateToUcs4(pos[-2], pos[-1]);
++        }
+         return pos[-1].unicode();
+     }
+ 
+@@ -230,8 +243,10 @@ public:
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+         const QChar cur = *--pos;
+-        if (Q_UNLIKELY(cur.isLowSurrogate()))
++        if (Q_UNLIKELY(cur.isLowSurrogate())) {
++            Q_ASSERT(hasPrevious() && pos[-1].isHighSurrogate());
+             return QChar::surrogateToUcs4(*--pos, cur);
++        }
+         return cur.unicode();
+     }
+ 
+@@ -241,7 +256,7 @@ public:
+ 
+         const QChar uc = *--pos;
+         if (Q_UNLIKELY(uc.isSurrogate())) {
+-            if (Q_LIKELY(uc.isLowSurrogate() && pos > i && pos[-1].isHighSurrogate()))
++            if (Q_LIKELY(uc.isLowSurrogate() && hasPrevious() && pos[-1].isHighSurrogate()))
+                 return QChar::surrogateToUcs4(*--pos, uc);
+             return invalidAs;
+         }
+diff --git a/qtbase/src/corelib/thread/qfutex_p.h b/qtbase/src/corelib/thread/qfutex_p.h
+index f287b752d7..e294537787 100644
+--- a/qtbase/src/corelib/thread/qfutex_p.h
++++ b/qtbase/src/corelib/thread/qfutex_p.h
+@@ -52,6 +52,7 @@
+ //
+ 
+ #include <qglobal.h>
++#include <QtCore/qtsan_impl.h>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -106,16 +107,13 @@ namespace QtLinuxFutex {
+     inline int _q_futex(int *addr, int op, int val, quintptr val2 = 0,
+                         int *addr2 = nullptr, int val3 = 0) noexcept
+     {
+-        // A futex call ensures total ordering on the futex words
+-        // (in either success or failure of the call). Instruct TSAN accordingly,
+-        // as TSAN does not understand the futex(2) syscall.
+-        _q_tsan_release(addr, addr2);
++        QtTsan::futexRelease(addr, addr2);
+ 
+         // we use __NR_futex because some libcs (like Android's bionic) don't
+         // provide SYS_futex etc.
+         int result = syscall(__NR_futex, addr, op | FUTEX_PRIVATE_FLAG, val, val2, addr2, val3);
+ 
+-        _q_tsan_acquire(addr, addr2);
++        QtTsan::futexAcquire(addr, addr2);
+ 
+         return result;
+     }
+diff --git a/qtbase/src/corelib/thread/qmutex.cpp b/qtbase/src/corelib/thread/qmutex.cpp
+index 310d1cb14f..7097122d8e 100644
+--- a/qtbase/src/corelib/thread/qmutex.cpp
++++ b/qtbase/src/corelib/thread/qmutex.cpp
+@@ -152,6 +152,7 @@ public:
+ 
+ /*!
+     \enum QMutex::RecursionMode
++    \obsolete Use QRecursiveMutex to create a recursive mutex.
+ 
+     \value Recursive  In this mode, a thread can lock the same mutex
+                       multiple times and the mutex won't be unlocked
+@@ -173,6 +174,7 @@ public:
+ 
+ /*!
+     Constructs a new mutex. The mutex is created in an unlocked state.
++    \obsolete Use QRecursiveMutex to create a recursive mutex.
+ 
+     If \a mode is QMutex::Recursive, a thread can lock the same mutex
+     multiple times and the mutex won't be unlocked until a
+@@ -197,7 +199,7 @@ QMutex::QMutex(RecursionMode mode)
+ QMutex::~QMutex()
+ {
+     QMutexData *d = d_ptr.loadRelaxed();
+-    if (isRecursive()) {
++    if (QBasicMutex::isRecursive()) {
+         delete static_cast<QRecursiveMutexPrivate *>(d);
+     } else if (d) {
+ #ifndef QT_LINUX_FUTEX
+diff --git a/qtbase/src/corelib/thread/qmutex.h b/qtbase/src/corelib/thread/qmutex.h
+index 73c9e00663..1bae573a03 100644
+--- a/qtbase/src/corelib/thread/qmutex.h
++++ b/qtbase/src/corelib/thread/qmutex.h
+@@ -42,6 +42,7 @@
+ 
+ #include <QtCore/qglobal.h>
+ #include <QtCore/qatomic.h>
++#include <QtCore/qtsan_impl.h>
+ #include <new>
+ 
+ #if __has_include(<chrono>)
+@@ -77,19 +78,37 @@ public:
+ 
+     // BasicLockable concept
+     inline void lock() QT_MUTEX_LOCK_NOEXCEPT {
++        QtTsan::mutexPreLock(this, 0u);
++
+         if (!fastTryLock())
+             lockInternal();
++
++        QtTsan::mutexPostLock(this, 0u, 0);
+     }
+ 
+     // BasicLockable concept
+     inline void unlock() noexcept {
+         Q_ASSERT(d_ptr.loadRelaxed()); //mutex must be locked
++
++        QtTsan::mutexPreUnlock(this, 0u);
++
+         if (!fastTryUnlock())
+             unlockInternal();
++
++        QtTsan::mutexPostUnlock(this, 0u);
+     }
+ 
+     bool tryLock() noexcept {
+-        return fastTryLock();
++        unsigned tsanFlags = QtTsan::TryLock;
++        QtTsan::mutexPreLock(this, tsanFlags);
++
++        const bool success = fastTryLock();
++
++        if (!success)
++            tsanFlags |= QtTsan::TryLockFailed;
++        QtTsan::mutexPostLock(this, tsanFlags, 0);
++
++        return success;
+     }
+ 
+     // Lockable concept
+@@ -134,8 +153,16 @@ public:
+ #else
+     QMutex() { d_ptr.storeRelaxed(nullptr); }
+ #endif
++#if QT_DEPRECATED_SINCE(5,15)
+     enum RecursionMode { NonRecursive, Recursive };
++    QT_DEPRECATED_VERSION_X(5, 15, "Use QRecursiveMutex instead of a recursive QMutex")
+     explicit QMutex(RecursionMode mode);
++
++    QT_DEPRECATED_VERSION_X(5, 15, "Use QRecursiveMutex instead of a recursive QMutex")
++    bool isRecursive() const noexcept
++    { return QBasicMutex::isRecursive(); }
++#endif
++
+     ~QMutex();
+ 
+     // BasicLockable concept
+@@ -166,9 +193,6 @@ public:
+     }
+ #endif
+ 
+-    bool isRecursive() const noexcept
+-    { return QBasicMutex::isRecursive(); }
+-
+ private:
+     Q_DISABLE_COPY(QMutex)
+     friend class QMutexLocker;
+diff --git a/qtbase/src/corelib/thread/qreadwritelock.cpp b/qtbase/src/corelib/thread/qreadwritelock.cpp
+index 8c28507d5a..9dd8503116 100644
+--- a/qtbase/src/corelib/thread/qreadwritelock.cpp
++++ b/qtbase/src/corelib/thread/qreadwritelock.cpp
+@@ -155,7 +155,7 @@ QReadWriteLock::QReadWriteLock(RecursionMode recursionMode)
+ */
+ QReadWriteLock::~QReadWriteLock()
+ {
+-    auto d = d_ptr.loadRelaxed();
++    auto d = d_ptr.loadAcquire();
+     if (isUncontendedLocked(d)) {
+         qWarning("QReadWriteLock: destroying locked QReadWriteLock");
+         return;
+@@ -445,7 +445,7 @@ void QReadWriteLock::unlock()
+ /*! \internal  Helper for QWaitCondition::wait */
+ QReadWriteLock::StateForWaitCondition QReadWriteLock::stateForWaitCondition() const
+ {
+-    QReadWriteLockPrivate *d = d_ptr.loadRelaxed();
++    QReadWriteLockPrivate *d = d_ptr.loadAcquire();
+     switch (quintptr(d) & StateMask) {
+     case StateLockedForRead: return LockedForRead;
+     case StateLockedForWrite: return LockedForWrite;
+@@ -453,6 +453,7 @@ QReadWriteLock::StateForWaitCondition QReadWriteLock::stateForWaitCondition() co
+ 
+     if (!d)
+         return Unlocked;
++    const auto lock = qt_scoped_lock(d->mutex);
+     if (d->writerCount > 1)
+         return RecursivelyLocked;
+     else if (d->writerCount == 1)
+diff --git a/qtbase/src/corelib/thread/qsemaphore.cpp b/qtbase/src/corelib/thread/qsemaphore.cpp
+index 1d01fc1b28..3ecdee3747 100644
+--- a/qtbase/src/corelib/thread/qsemaphore.cpp
++++ b/qtbase/src/corelib/thread/qsemaphore.cpp
+@@ -354,7 +354,12 @@ void QSemaphore::release(int n)
+         quintptr nn = unsigned(n);
+         if (futexHasWaiterCount)
+             nn |= quint64(nn) << 32;    // token count replicated in high word
+-        quintptr prevValue = u.fetchAndAddRelease(nn);
++        quintptr prevValue = u.loadRelaxed();
++        quintptr newValue;
++        do { // loop just to ensure the operations are done atomically
++            newValue = prevValue + nn;
++            newValue &= (futexNeedsWakeAllBit - 1);
++        } while (!u.testAndSetRelease(prevValue, newValue, prevValue));
+         if (futexNeedsWake(prevValue)) {
+ #ifdef FUTEX_OP
+             if (futexHasWaiterCount) {
+@@ -376,7 +381,6 @@ void QSemaphore::release(int n)
+                 quint32 oparg = 0;
+                 quint32 cmp = FUTEX_OP_CMP_NE;
+                 quint32 cmparg = 0;
+-                u.fetchAndAndRelease(futexNeedsWakeAllBit - 1);
+                 futexWakeOp(*futexLow32(&u), n, INT_MAX, *futexHigh32(&u), FUTEX_OP(op, oparg, cmp, cmparg));
+                 return;
+             }
+@@ -388,7 +392,6 @@ 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(futexNeedsWakeAllBit - 1);
+             if (futexHasWaiterCount) {
+                 futexWakeAll(*futexLow32(&u));
+                 futexWakeAll(*futexHigh32(&u));
+diff --git a/qtbase/src/corelib/thread/qthread_p.h b/qtbase/src/corelib/thread/qthread_p.h
+index b2d1628e6e..f32f6f0460 100644
+--- a/qtbase/src/corelib/thread/qthread_p.h
++++ b/qtbase/src/corelib/thread/qthread_p.h
+@@ -174,7 +174,7 @@ public:
+     int returnCode;
+ 
+     uint stackSize;
+-    QThread::Priority priority;
++    std::underlying_type<QThread::Priority>::type priority;
+ 
+     static QThread *threadForId(int id);
+ 
+@@ -213,6 +213,13 @@ public:
+             QCoreApplication::instance()->postEvent(q_ptr, new QEvent(QEvent::Quit));
+         }
+     }
++
++#ifndef Q_OS_INTEGRITY
++private:
++    // Used in QThread(Private)::start to avoid racy access to QObject::objectName,
++    // unset afterwards. On INTEGRITY we set the thread name before starting it.
++    QString objectName;
++#endif
+ };
+ 
+ #else // QT_CONFIG(thread)
+diff --git a/qtbase/src/corelib/thread/qthread_unix.cpp b/qtbase/src/corelib/thread/qthread_unix.cpp
+index 56a8e0a038..610117a640 100644
+--- a/qtbase/src/corelib/thread/qthread_unix.cpp
++++ b/qtbase/src/corelib/thread/qthread_unix.cpp
+@@ -169,8 +169,7 @@ static void set_thread_data(QThreadData *data)
+ 
+ static void clear_thread_data()
+ {
+-    currentThreadData = nullptr;
+-    pthread_setspecific(current_thread_data_key, nullptr);
++    set_thread_data(nullptr);
+ }
+ 
+ template <typename T>
+@@ -296,7 +295,7 @@ void *QThreadPrivate::start(void *arg)
+             QMutexLocker locker(&thr->d_func()->mutex);
+ 
+             // do we need to reset the thread priority?
+-            if (int(thr->d_func()->priority) & ThreadPriorityResetFlag) {
++            if (thr->d_func()->priority & ThreadPriorityResetFlag) {
+                 thr->d_func()->setPriority(QThread::Priority(thr->d_func()->priority & ~ThreadPriorityResetFlag));
+             }
+ 
+@@ -316,10 +315,10 @@ void *QThreadPrivate::start(void *arg)
+             // Sets the name of the current thread. We can only do this
+             // when the thread is starting, as we don't have a cross
+             // platform way of setting the name of an arbitrary thread.
+-            if (Q_LIKELY(thr->objectName().isEmpty()))
++            if (Q_LIKELY(thr->d_func()->objectName.isEmpty()))
+                 setCurrentThreadName(thr->metaObject()->className());
+             else
+-                setCurrentThreadName(thr->objectName().toLocal8Bit());
++                setCurrentThreadName(std::exchange(thr->d_func()->objectName, {}).toLocal8Bit());
+         }
+ #endif
+ 
+@@ -671,7 +670,7 @@ void QThread::start(Priority priority)
+                 // could not set scheduling hints, fallback to inheriting them
+                 // we'll try again from inside the thread
+                 pthread_attr_setinheritsched(&attr, PTHREAD_INHERIT_SCHED);
+-                d->priority = Priority(priority | ThreadPriorityResetFlag);
++                d->priority = static_cast<std::underlying_type<QThread::Priority>::type>(priority) | ThreadPriorityResetFlag;
+             }
+             break;
+         }
+@@ -702,7 +701,10 @@ void QThread::start(Priority priority)
+         pthread_attr_setthreadname(&attr, metaObject()->className());
+     else
+         pthread_attr_setthreadname(&attr, objectName().toLocal8Bit());
++#else
++    d->objectName = objectName();
+ #endif
++
+     pthread_t threadId;
+     int code = pthread_create(&threadId, &attr, QThreadPrivate::start, this);
+     if (code == EPERM) {
+diff --git a/qtbase/src/corelib/thread/qthread_win.cpp b/qtbase/src/corelib/thread/qthread_win.cpp
+index bc70e3178a..4e76972498 100644
+--- a/qtbase/src/corelib/thread/qthread_win.cpp
++++ b/qtbase/src/corelib/thread/qthread_win.cpp
+@@ -394,10 +394,9 @@ unsigned int __stdcall QT_ENSURE_STACK_ALIGNED_FOR_SSE QThreadPrivate::start(voi
+ 
+ #if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) && !defined(Q_OS_WINRT)
+     // sets the name of the current thread.
+-    QByteArray objectName = thr->objectName().toLocal8Bit();
+-    qt_set_thread_name(HANDLE(-1),
+-                       objectName.isEmpty() ?
+-                       thr->metaObject()->className() : objectName.constData());
++    qt_set_thread_name(HANDLE(-1), thr->d_func()->objectName.isEmpty()
++                        ? thr->metaObject()->className()
++                        : std::exchange(thr->d_func()->objectName, {}).toLocal8Bit().constData());
+ #endif
+ 
+     emit thr->started(QThread::QPrivateSignal());
+@@ -503,6 +502,7 @@ void QThread::start(Priority priority)
+     if (d->running)
+         return;
+ 
++    d->objectName = objectName();
+     d->running = true;
+     d->finished = false;
+     d->exited = false;
+@@ -548,7 +548,7 @@ void QThread::start(Priority priority)
+ 
+     int prio;
+     d->priority = priority;
+-    switch (d->priority) {
++    switch (priority) {
+     case IdlePriority:
+         prio = THREAD_PRIORITY_IDLE;
+         break;
+@@ -686,7 +686,7 @@ void QThreadPrivate::setPriority(QThread::Priority threadPriority)
+ 
+     int prio;
+     priority = threadPriority;
+-    switch (priority) {
++    switch (threadPriority) {
+     case QThread::IdlePriority:
+         prio = THREAD_PRIORITY_IDLE;
+         break;
+diff --git a/qtbase/src/corelib/thread/qtsan_impl.h b/qtbase/src/corelib/thread/qtsan_impl.h
+new file mode 100644
+index 0000000000..580a738b91
+--- /dev/null
++++ b/qtbase/src/corelib/thread/qtsan_impl.h
+@@ -0,0 +1,115 @@
++/****************************************************************************
++**
++** Copyright (C) 2017 Intel Corporation.
++** Copyright (C) 2022 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
++** 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 QTSAN_IMPL_H
++#define QTSAN_IMPL_H
++
++#include <QtCore/qglobal.h>
++
++#if (__has_feature(thread_sanitizer) || defined(__SANITIZE_THREAD__)) && __has_include(<sanitizer/tsan_interface.h>)
++#  define QT_BUILDING_UNDER_TSAN
++#  include <sanitizer/tsan_interface.h>
++#endif
++
++QT_BEGIN_NAMESPACE
++
++namespace QtTsan {
++#ifdef QT_BUILDING_UNDER_TSAN
++inline void futexAcquire(void *addr, void *addr2 = nullptr)
++{
++    // A futex call ensures total ordering on the futex words
++    // (in either success or failure of the call). Instruct TSAN accordingly,
++    // as TSAN does not understand the futex(2) syscall (or equivalent).
++    ::__tsan_acquire(addr);
++    if (addr2)
++        ::__tsan_acquire(addr2);
++}
++
++inline void futexRelease(void *addr, void *addr2 = nullptr)
++{
++    if (addr2)
++        ::__tsan_release(addr2);
++    ::__tsan_release(addr);
++}
++
++inline void mutexPreLock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_pre_lock(addr, flags);
++}
++
++inline void mutexPostLock(void *addr, unsigned flags, int recursion)
++{
++    ::__tsan_mutex_post_lock(addr, flags, recursion);
++}
++
++inline void mutexPreUnlock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_pre_unlock(addr, flags);
++}
++
++inline void mutexPostUnlock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_post_unlock(addr, flags);
++}
++
++enum : unsigned {
++    MutexWriteReentrant = ::__tsan_mutex_write_reentrant,
++    TryLock = ::__tsan_mutex_try_lock,
++    TryLockFailed = ::__tsan_mutex_try_lock_failed,
++};
++#else
++inline void futexAcquire(void *, void * = nullptr) {}
++inline void futexRelease(void *, void * = nullptr) {}
++
++enum : unsigned {
++    MutexWriteReentrant,
++    TryLock,
++    TryLockFailed,
++};
++inline void mutexPreLock(void *, unsigned) {}
++inline void mutexPostLock(void *, unsigned, int) {}
++inline void mutexPreUnlock(void *, unsigned) {}
++inline void mutexPostUnlock(void *, unsigned) {}
++#endif // QT_BUILDING_UNDER_TSAN
++} // namespace QtTsan
++
++QT_END_NAMESPACE
++
++#endif // QTSAN_IMPL_H
+diff --git a/qtbase/src/corelib/thread/qwaitcondition_unix.cpp b/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
+index 88b058f410..0f1da4dc9b 100644
+--- a/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
++++ b/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
+@@ -213,7 +213,7 @@ bool QWaitCondition::wait(QMutex *mutex, QDeadlineTimer deadline)
+ {
+     if (! mutex)
+         return false;
+-    if (mutex->isRecursive()) {
++    if (static_cast<QBasicMutex *>(mutex)->isRecursive()) {
+         qWarning("QWaitCondition: cannot wait on recursive mutexes");
+         return false;
+     }
+diff --git a/qtbase/src/corelib/time/qdatetime.cpp b/qtbase/src/corelib/time/qdatetime.cpp
+index ec12569e3f..2c0b098079 100644
+--- a/qtbase/src/corelib/time/qdatetime.cpp
++++ b/qtbase/src/corelib/time/qdatetime.cpp
+@@ -43,6 +43,7 @@
+ #if QT_CONFIG(datetimeparser)
+ #include "private/qdatetimeparser_p.h"
+ #endif
++#include <private/qnumeric_p.h>
+ 
+ #include "qdatastream.h"
+ #include "qset.h"
+@@ -1429,9 +1430,11 @@ QDate QDate::addDays(qint64 ndays) const
+     if (isNull())
+         return QDate();
+ 
+-    // Due to limits on minJd() and maxJd() we know that any overflow
+-    // will be invalid and caught by fromJulianDay().
+-    return fromJulianDay(jd + ndays);
++    qint64 r;
++    if (Q_UNLIKELY(add_overflow(jd, ndays, &r)))
++        return QDate();
++    else
++        return fromJulianDay(r);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/corelib/time/qtimezone.cpp b/qtbase/src/corelib/time/qtimezone.cpp
+index 0309e43e52..3d451696a1 100644
+--- a/qtbase/src/corelib/time/qtimezone.cpp
++++ b/qtbase/src/corelib/time/qtimezone.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2013 John Layt <jlayt@kde.org>
++** Copyright (C) 2020 John Layt <jlayt@kde.org>
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtCore module of the Qt Toolkit.
+@@ -975,9 +975,15 @@ QList<QByteArray> QTimeZone::windowsIdToIanaIds(const QByteArray &windowsId,
+ }
+ 
+ #ifndef QT_NO_DATASTREAM
++// Invalid, as an IANA ID: too long, starts with - and has other invalid characters in it
++static inline QString invalidId() { return QStringLiteral("-No Time Zone Specified!"); }
++
+ QDataStream &operator<<(QDataStream &ds, const QTimeZone &tz)
+ {
+-    tz.d->serialize(ds);
++    if (tz.isValid())
++        tz.d->serialize(ds);
++    else
++        ds << invalidId();
+     return ds;
+ }
+ 
+@@ -985,7 +991,9 @@ QDataStream &operator>>(QDataStream &ds, QTimeZone &tz)
+ {
+     QString ianaId;
+     ds >> ianaId;
+-    if (ianaId == QLatin1String("OffsetFromUtc")) {
++    if (ianaId == invalidId()) {
++        tz = QTimeZone();
++    } else if (ianaId == QLatin1String("OffsetFromUtc")) {
+         int utcOffset;
+         QString name;
+         QString abbreviation;
+diff --git a/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp b/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
+index b1611d7ddb..a7a6a72ccf 100644
+--- a/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
++++ b/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
+@@ -42,6 +42,7 @@
+ #include "qtimezone.h"
+ #include "qtimezoneprivate_p.h"
+ #include "private/qlocale_tools_p.h"
++#include "private/qlocking_p.h"
+ 
+ #include <QtCore/QDataStream>
+ #include <QtCore/QDateTime>
+@@ -62,6 +63,10 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++#if QT_CONFIG(icu)
++static QBasicMutex s_icu_mutex;
++#endif
++
+ /*
+     Private
+ 
+@@ -670,6 +675,9 @@ QTzTimeZonePrivate::~QTzTimeZonePrivate()
+ 
+ QTzTimeZonePrivate *QTzTimeZonePrivate::clone() const
+ {
++#if QT_CONFIG(icu)
++    const auto lock = qt_scoped_lock(s_icu_mutex);
++#endif
+     return new QTzTimeZonePrivate(*this);
+ }
+ 
+@@ -913,12 +921,14 @@ QString QTzTimeZonePrivate::displayName(qint64 atMSecsSinceEpoch,
+                                         const QLocale &locale) const
+ {
+ #if QT_CONFIG(icu)
++    auto lock = qt_unique_lock(s_icu_mutex);
+     if (!m_icu)
+         m_icu = new QIcuTimeZonePrivate(m_id);
+     // TODO small risk may not match if tran times differ due to outdated files
+     // TODO Some valid TZ names are not valid ICU names, use translation table?
+     if (m_icu->isValid())
+         return m_icu->displayName(atMSecsSinceEpoch, nameType, locale);
++    lock.unlock();
+ #else
+     Q_UNUSED(nameType)
+     Q_UNUSED(locale)
+@@ -932,12 +942,14 @@ QString QTzTimeZonePrivate::displayName(QTimeZone::TimeType timeType,
+                                         const QLocale &locale) const
+ {
+ #if QT_CONFIG(icu)
++    auto lock = qt_unique_lock(s_icu_mutex);
+     if (!m_icu)
+         m_icu = new QIcuTimeZonePrivate(m_id);
+     // TODO small risk may not match if tran times differ due to outdated files
+     // TODO Some valid TZ names are not valid ICU names, use translation table?
+     if (m_icu->isValid())
+         return m_icu->displayName(timeType, nameType, locale);
++    lock.unlock();
+ #else
+     Q_UNUSED(timeType)
+     Q_UNUSED(nameType)
+diff --git a/qtbase/src/corelib/tools/qarraydata.h b/qtbase/src/corelib/tools/qarraydata.h
+index dcd95924c1..d01739e7e6 100644
+--- a/qtbase/src/corelib/tools/qarraydata.h
++++ b/qtbase/src/corelib/tools/qarraydata.h
+@@ -42,6 +42,7 @@
+ 
+ #include <QtCore/qrefcount.h>
+ #include <string.h>
++#include <cstdint>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -58,14 +59,14 @@ struct Q_CORE_EXPORT QArrayData
+     {
+         Q_ASSERT(size == 0
+                 || offset < 0 || size_t(offset) >= sizeof(QArrayData));
+-        return reinterpret_cast<char *>(this) + offset;
++        return reinterpret_cast<void *> (reinterpret_cast<uintptr_t>(this) + offset);
+     }
+ 
+     const void *data() const
+     {
+         Q_ASSERT(size == 0
+                 || offset < 0 || size_t(offset) >= sizeof(QArrayData));
+-        return reinterpret_cast<const char *>(this) + offset;
++        return reinterpret_cast<void *> (reinterpret_cast<uintptr_t>(this) + offset);
+     }
+ 
+     // This refers to array data mutability, not "header data" represented by
+diff --git a/qtbase/src/corelib/tools/qfreelist_p.h b/qtbase/src/corelib/tools/qfreelist_p.h
+index 5ba23b344b..9974102136 100644
+--- a/qtbase/src/corelib/tools/qfreelist_p.h
++++ b/qtbase/src/corelib/tools/qfreelist_p.h
+@@ -161,7 +161,7 @@ class QFreeList
+                 return i;
+             x -= size;
+         }
+-        Q_ASSERT(false);
++        Q_UNREACHABLE();
+         return -1;
+     }
+ 
+diff --git a/qtbase/src/corelib/tools/qversionnumber.h b/qtbase/src/corelib/tools/qversionnumber.h
+index d43b86ba51..2843f2b043 100644
+--- a/qtbase/src/corelib/tools/qversionnumber.h
++++ b/qtbase/src/corelib/tools/qversionnumber.h
+@@ -273,10 +273,10 @@ public:
+ 
+     Q_REQUIRED_RESULT Q_CORE_EXPORT QString toString() const;
+ #if QT_STRINGVIEW_LEVEL < 2
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(const QString &string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(const QString &string, int *suffixIndex = nullptr);
+ #endif
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QLatin1String string, int *suffixIndex = nullptr);
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QStringView string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(QLatin1String string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(QStringView string, int *suffixIndex = nullptr);
+ 
+ private:
+ #ifndef QT_NO_DATASTREAM
+diff --git a/qtbase/src/dbus/qdbusintegrator.cpp b/qtbase/src/dbus/qdbusintegrator.cpp
+index 5b66ce971b..28a3b0ffea 100644
+--- a/qtbase/src/dbus/qdbusintegrator.cpp
++++ b/qtbase/src/dbus/qdbusintegrator.cpp
+@@ -1135,7 +1135,13 @@ void QDBusConnectionPrivate::closeConnection()
+         }
+     }
+ 
+-    qDeleteAll(pendingCalls);
++    for (auto it = pendingCalls.begin(); it != pendingCalls.end(); ++it) {
++        auto call = *it;
++        if (!call->ref.deref()) {
++            delete call;
++        }
++    }
++    pendingCalls.clear();
+ 
+     // Disconnect all signals from signal hooks and from the object tree to
+     // avoid QObject::destroyed being sent to dbus daemon thread which has
+@@ -2584,6 +2590,11 @@ QDBusConnectionPrivate::findMetaObject(const QString &service, const QString &pa
+         if (mo)
+             return mo;
+     }
++    if (path.isEmpty()) {
++        error = QDBusError(QDBusError::InvalidObjectPath, QLatin1String("Object path cannot be empty"));
++        lastError = error;
++        return nullptr;
++    }
+ 
+     // introspect the target object
+     QDBusMessage msg = QDBusMessage::createMethodCall(service, path,
+diff --git a/qtbase/src/dbus/qdbusmetaobject.cpp b/qtbase/src/dbus/qdbusmetaobject.cpp
+index 5265568f42..7e9f0f1acc 100644
+--- a/qtbase/src/dbus/qdbusmetaobject.cpp
++++ b/qtbase/src/dbus/qdbusmetaobject.cpp
+@@ -210,6 +210,9 @@ QDBusMetaObjectGenerator::findType(const QByteArray &signature,
+         } else if (signature == "a{ss}") {
+             result.name = "QMap<QString,QString>";
+             type = qMetaTypeId<QMap<QString, QString> >();
++        } else if (signature == "aay") {
++            result.name = "QByteArrayList";
++            type = qMetaTypeId<QByteArrayList>();
+         } else {
+             result.name = "{D-Bus type \"" + signature + "\"}";
+             type = registerComplexDBusType(result.name);
+diff --git a/qtbase/src/gui/accessible/qaccessible.cpp b/qtbase/src/gui/accessible/qaccessible.cpp
+index d705bfccb5..0caf3c808c 100644
+--- a/qtbase/src/gui/accessible/qaccessible.cpp
++++ b/qtbase/src/gui/accessible/qaccessible.cpp
+@@ -54,6 +54,7 @@
+ #include <QtCore/qdebug.h>
+ #include <QtCore/qloggingcategory.h>
+ #include <QtCore/qmetaobject.h>
++#include <QtCore/private/qmetaobject_p.h>
+ #include <QtCore/qhash.h>
+ #include <private/qfactoryloader_p.h>
+ 
+@@ -681,6 +682,25 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
+     // Create a QAccessibleInterface for the object class. Start by the most
+     // derived class and walk up the class hierarchy.
+     const QMetaObject *mo = object->metaObject();
++    const auto *objectPriv = QObjectPrivate::get(object);
++    /*
++     We do not want to cache each and every QML metaobject (Button_QMLTYPE_124,
++     Button_QMLTYPE_125, etc.). Those dynamic metaobjects shouldn't have an
++     accessible interface in any case. Instead, we start the whole checking
++     with the first non-dynamic meta-object. To avoid potential regressions
++     in other areas of Qt that also use dynamic metaobjects, we only do this
++     for objects that are QML-related (approximated by checking whether they
++     have ddata set).
++    */
++    const bool qmlRelated = !objectPriv->isDeletingChildren &&
++                            objectPriv->declarativeData;
++    while (qmlRelated && mo) {
++        auto mop = QMetaObjectPrivate::get(mo);
++        if (!mop || !(mop->flags & DynamicMetaObject))
++            break;
++
++        mo = mo->superClass();
++    };
+     while (mo) {
+         const QString cn = QLatin1String(mo->className());
+ 
+@@ -696,14 +716,15 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
+         // Find a QAccessiblePlugin (factory) for the class name. If there's
+         // no entry in the cache try to create it using the plugin loader.
+         if (!qAccessiblePlugins()->contains(cn)) {
++            QAccessiblePlugin *factory = nullptr; // 0 means "no plugin found". This is cached as well.
+             const int index = loader()->indexOf(cn);
+-            if (index != -1) {
+-                QAccessiblePlugin *factory = qobject_cast<QAccessiblePlugin *>(loader()->instance(index));
+-                qAccessiblePlugins()->insert(cn, factory);
+-            }
++            if (index != -1)
++                factory = qobject_cast<QAccessiblePlugin *>(loader()->instance(index));
++            qAccessiblePlugins()->insert(cn, factory);
+         }
+ 
+         // At this point the cache should contain a valid factory pointer or 0:
++        Q_ASSERT(qAccessiblePlugins()->contains(cn));
+         QAccessiblePlugin *factory = qAccessiblePlugins()->value(cn);
+         if (factory) {
+             QAccessibleInterface *result = factory->create(cn, object);
+diff --git a/qtbase/src/gui/configure.json b/qtbase/src/gui/configure.json
+index 1f08795c57..12c95742d2 100644
+--- a/qtbase/src/gui/configure.json
++++ b/qtbase/src/gui/configure.json
+@@ -834,7 +834,8 @@
+                     "// embedded devices, are not intended to be used together with X. EGL support",
+                     "// has to be disabled in plugins like xcb in this case since the native display,",
+                     "// window and pixmap types will be different than what an X-based platform",
+-                    "// plugin would expect."
++                    "// plugin would expect.",
++                    "#define USE_X11"
+                 ],
+                 "include": [ "EGL/egl.h", "X11/Xlib.h" ],
+                 "main": [
+diff --git a/qtbase/src/gui/image/qbmphandler.cpp b/qtbase/src/gui/image/qbmphandler.cpp
+index 96f1e8cb1d..0e73bbbdb0 100644
+--- a/qtbase/src/gui/image/qbmphandler.cpp
++++ b/qtbase/src/gui/image/qbmphandler.cpp
+@@ -150,16 +150,42 @@ static QDataStream &operator<<(QDataStream &s, const BMP_INFOHDR &bi)
+     return s;
+ }
+ 
+-static int calc_shift(uint mask)
++static uint calc_shift(uint mask)
+ {
+-    int result = 0;
+-    while (mask && !(mask & 1)) {
++    uint result = 0;
++    while ((mask >= 0x100) || (!(mask & 1) && mask)) {
+         result++;
+         mask >>= 1;
+     }
+     return result;
+ }
+ 
++static uint calc_scale(uint low_mask)
++{
++    uint result = 8;
++    while (low_mask && result) {
++        result--;
++        low_mask >>= 1;
++    }
++    return result;
++}
++
++static inline uint apply_scale(uint value, uint scale)
++{
++    if (!(scale & 0x07)) // return immediately if scale == 8 or 0
++        return value;
++
++    uint filled = 8 - scale;
++    uint result = value << scale;
++
++    do {
++        result |= result >> filled;
++        filled <<= 1;
++    } while (filled < 8);
++
++    return result;
++}
++
+ static bool read_dib_fileheader(QDataStream &s, BMP_FILEHDR &bf)
+ {
+     // read BMP file header
+@@ -222,14 +248,14 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+     uint green_mask = 0;
+     uint blue_mask = 0;
+     uint alpha_mask = 0;
+-    int red_shift = 0;
+-    int green_shift = 0;
+-    int blue_shift = 0;
+-    int alpha_shift = 0;
+-    int red_scale = 0;
+-    int green_scale = 0;
+-    int blue_scale = 0;
+-    int alpha_scale = 0;
++    uint red_shift = 0;
++    uint green_shift = 0;
++    uint blue_shift = 0;
++    uint alpha_shift = 0;
++    uint red_scale = 0;
++    uint green_scale = 0;
++    uint blue_scale = 0;
++    uint alpha_scale = 0;
+ 
+     if (!d->isSequential())
+         d->seek(startpos + BMP_FILEHDR_SIZE + bi.biSize); // goto start of colormap or masks
+@@ -308,19 +334,19 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+         red_shift = calc_shift(red_mask);
+         if (((red_mask >> red_shift) + 1) == 0)
+             return false;
+-        red_scale = 256 / ((red_mask >> red_shift) + 1);
++        red_scale = calc_scale(red_mask >> red_shift);
+         green_shift = calc_shift(green_mask);
+         if (((green_mask >> green_shift) + 1) == 0)
+             return false;
+-        green_scale = 256 / ((green_mask >> green_shift) + 1);
++        green_scale = calc_scale(green_mask >> green_shift);
+         blue_shift = calc_shift(blue_mask);
+         if (((blue_mask >> blue_shift) + 1) == 0)
+             return false;
+-        blue_scale = 256 / ((blue_mask >> blue_shift) + 1);
++        blue_scale = calc_scale(blue_mask >> blue_shift);
+         alpha_shift = calc_shift(alpha_mask);
+         if (((alpha_mask >> alpha_shift) + 1) == 0)
+             return false;
+-        alpha_scale = 256 / ((alpha_mask >> alpha_shift) + 1);
++        alpha_scale = calc_scale(alpha_mask >> alpha_shift);
+     } else if (comp == BMP_RGB && (nbits == 24 || nbits == 32)) {
+         blue_mask = 0x000000ff;
+         green_mask = 0x0000ff00;
+@@ -328,17 +354,15 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+         blue_shift = 0;
+         green_shift = 8;
+         red_shift = 16;
+-        blue_scale = green_scale = red_scale = 1;
++        blue_scale = green_scale = red_scale = 0;
+     } else if (comp == BMP_RGB && nbits == 16) {
+         blue_mask = 0x001f;
+         green_mask = 0x03e0;
+         red_mask = 0x7c00;
+         blue_shift = 0;
+-        green_shift = 2;
+-        red_shift = 7;
+-        red_scale = 1;
+-        green_scale = 1;
+-        blue_scale = 8;
++        green_shift = 5;
++        red_shift = 10;
++        blue_scale = green_scale = red_scale = 3;
+     }
+ 
+ #if 0
+@@ -544,10 +568,10 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+                     c |= *(uchar*)(b+2)<<16;
+                 if (nbits > 24)
+                     c |= *(uchar*)(b+3)<<24;
+-                *p++ = qRgba(((c & red_mask) >> red_shift) * red_scale,
+-                                        ((c & green_mask) >> green_shift) * green_scale,
+-                                        ((c & blue_mask) >> blue_shift) * blue_scale,
+-                                        transp ? ((c & alpha_mask) >> alpha_shift) * alpha_scale : 0xff);
++                *p++ = qRgba(apply_scale((c & red_mask) >> red_shift, red_scale),
++                             apply_scale((c & green_mask) >> green_shift, green_scale),
++                             apply_scale((c & blue_mask) >> blue_shift, blue_scale),
++                             transp ? apply_scale((c & alpha_mask) >> alpha_shift, alpha_scale) : 0xff);
+                 b += nbits/8;
+             }
+         }
+diff --git a/qtbase/src/gui/image/qimage.cpp b/qtbase/src/gui/image/qimage.cpp
+index 7152ac1607..0df772564c 100644
+--- a/qtbase/src/gui/image/qimage.cpp
++++ b/qtbase/src/gui/image/qimage.cpp
+@@ -4694,6 +4694,8 @@ QImage QImage::smoothScaled(int w, int h) const {
+ static QImage rotated90(const QImage &image)
+ {
+     QImage out(image.height(), image.width(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+@@ -4722,6 +4724,8 @@ static QImage rotated180(const QImage &image)
+         return image.mirrored(true, true);
+ 
+     QImage out(image.width(), image.height(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+@@ -4734,6 +4738,8 @@ static QImage rotated180(const QImage &image)
+ static QImage rotated270(const QImage &image)
+ {
+     QImage out(image.height(), image.width(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+diff --git a/qtbase/src/gui/kernel/qcursor.cpp b/qtbase/src/gui/kernel/qcursor.cpp
+index d6ccaff8ed..455088241c 100644
+--- a/qtbase/src/gui/kernel/qcursor.cpp
++++ b/qtbase/src/gui/kernel/qcursor.cpp
+@@ -251,7 +251,8 @@ void QCursor::setPos(QScreen *screen, int x, int y)
+ {
+     if (screen) {
+         if (QPlatformCursor *cursor = screen->handle()->cursor()) {
+-            const QPoint devicePos = QHighDpi::toNativePixels(QPoint(x, y), screen);
++            const QPoint pos(x, y);
++            const QPoint devicePos = QHighDpi::toNativePixels(pos, screen->virtualSiblingAt(pos));
+             // Need to check, since some X servers generate null mouse move
+             // events, causing looping in applications which call setPos() on
+             // every mouse move event.
+diff --git a/qtbase/src/gui/kernel/qhighdpiscaling.cpp b/qtbase/src/gui/kernel/qhighdpiscaling.cpp
+index 9bbf2773a9..3ac4a4d8b6 100644
+--- a/qtbase/src/gui/kernel/qhighdpiscaling.cpp
++++ b/qtbase/src/gui/kernel/qhighdpiscaling.cpp
+@@ -580,9 +580,8 @@ void QHighDpiScaling::setScreenFactor(QScreen *screen, qreal factor)
+     else
+         qNamedScreenScaleFactors()->insert(name, factor);
+ 
+-    // hack to force re-evaluation of screen geometry
+     if (screen->handle())
+-        screen->d_func()->setPlatformScreen(screen->handle()); // updates geometries based on scale factor
++        screen->d_func()->updateLogicalDpi();
+ }
+ 
+ QPoint QHighDpiScaling::mapPositionToNative(const QPoint &pos, const QPlatformScreen *platformScreen)
+diff --git a/qtbase/src/gui/kernel/qkeysequence.cpp b/qtbase/src/gui/kernel/qkeysequence.cpp
+index a75b8ef920..4f2d294739 100644
+--- a/qtbase/src/gui/kernel/qkeysequence.cpp
++++ b/qtbase/src/gui/kernel/qkeysequence.cpp
+@@ -701,6 +701,10 @@ static const struct {
+     { Qt::Key_TouchpadToggle,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad Toggle") },
+     { Qt::Key_TouchpadOn,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad On") },
+     { Qt::Key_TouchpadOff,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad Off") },
++    { Qt::Key_Shift,  QT_TRANSLATE_NOOP("QShortcut", "Shift") },
++    { Qt::Key_Control,  QT_TRANSLATE_NOOP("QShortcut", "Control") },
++    { Qt::Key_Alt,  QT_TRANSLATE_NOOP("QShortcut", "Alt") },
++    { Qt::Key_Meta,  QT_TRANSLATE_NOOP("QShortcut", "Meta") },
+ 
+ };
+ static Q_CONSTEXPR int numKeyNames = sizeof keyname / sizeof *keyname;
+diff --git a/qtbase/src/gui/kernel/qplatformservices.cpp b/qtbase/src/gui/kernel/qplatformservices.cpp
+index fdc6a6c4aa..ac47f98c5d 100644
+--- a/qtbase/src/gui/kernel/qplatformservices.cpp
++++ b/qtbase/src/gui/kernel/qplatformservices.cpp
+@@ -55,6 +55,19 @@ QT_BEGIN_NAMESPACE
+     \brief The QPlatformServices provides the backend for desktop-related functionality.
+ */
+ 
++/*!
++    \enum QPlatformServices::Capability
++
++    Capabilities are used to determine a specific platform service's availability.
++
++    \value ColorPickingFromScreen The platform natively supports color picking from screen.
++    This capability indicates that the platform supports "opaque" color picking, where the
++    platform implements a complete user experience for color picking and outputs a color.
++    This is in contrast to the application implementing the color picking user experience
++    (taking care of showing a cross hair, instructing the platform integration to obtain
++    the color at a given pixel, etc.). The related service function is pickColor().
++ */
++
+ QPlatformServices::QPlatformServices()
+ { }
+ 
+@@ -85,5 +98,16 @@ QByteArray QPlatformServices::desktopEnvironment() const
+     return QByteArray("UNKNOWN");
+ }
+ 
++QPlatformServiceColorPicker *QPlatformServices::colorPicker(QWindow *parent)
++{
++    Q_UNUSED(parent);
++    return nullptr;
++}
++
++bool QPlatformServices::hasCapability(Capability capability) const
++{
++    Q_UNUSED(capability)
++    return false;
++}
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/gui/kernel/qplatformservices.h b/qtbase/src/gui/kernel/qplatformservices.h
+index 5de96cfa7d..a8b2a4ce71 100644
+--- a/qtbase/src/gui/kernel/qplatformservices.h
++++ b/qtbase/src/gui/kernel/qplatformservices.h
+@@ -50,16 +50,32 @@
+ //
+ 
+ #include <QtGui/qtguiglobal.h>
++#include <QtCore/qobject.h>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+ class QUrl;
++class QWindow;
++
++class Q_GUI_EXPORT QPlatformServiceColorPicker : public QObject
++{
++    Q_OBJECT
++public:
++    using QObject::QObject;
++    virtual void pickColor() = 0;
++Q_SIGNALS:
++    void colorPicked(const QColor &color);
++};
+ 
+ class Q_GUI_EXPORT QPlatformServices
+ {
+ public:
+     Q_DISABLE_COPY_MOVE(QPlatformServices)
+ 
++    enum Capability {
++        ColorPicking,
++    };
++
+     QPlatformServices();
+     virtual ~QPlatformServices() { }
+ 
+@@ -67,6 +83,10 @@ public:
+     virtual bool openDocument(const QUrl &url);
+ 
+     virtual QByteArray desktopEnvironment() const;
++
++    virtual bool hasCapability(Capability capability) const;
++
++    virtual QPlatformServiceColorPicker *colorPicker(QWindow *parent = nullptr);
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/gui/kernel/qplatformtheme.cpp b/qtbase/src/gui/kernel/qplatformtheme.cpp
+index 71521c0339..2325873245 100644
+--- a/qtbase/src/gui/kernel/qplatformtheme.cpp
++++ b/qtbase/src/gui/kernel/qplatformtheme.cpp
+@@ -163,6 +163,8 @@ QT_BEGIN_NAMESPACE
+ 
+     \value ShowShortcutsInContextMenus (bool) Whether to display shortcut key sequences in context menus.
+ 
++    \value ButtonPressKeys (QList<Qt::Key>) A list of keys that can be used to press buttons via keyboard input.
++
+     \sa themeHint(), QStyle::pixelMetric()
+ */
+ 
+@@ -563,6 +565,8 @@ QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint)
+         }
+     case MouseQuickSelectionThreshold:
+         return QVariant(10);
++    case ButtonPressKeys:
++        return QVariant::fromValue(QList<Qt::Key>({ Qt::Key_Space, Qt::Key_Select }));
+     }
+     return QVariant();
+ }
+diff --git a/qtbase/src/gui/kernel/qplatformtheme.h b/qtbase/src/gui/kernel/qplatformtheme.h
+index 3185fc4541..7e6c9d5740 100644
+--- a/qtbase/src/gui/kernel/qplatformtheme.h
++++ b/qtbase/src/gui/kernel/qplatformtheme.h
+@@ -120,7 +120,8 @@ public:
+         TouchDoubleTapDistance,
+         ShowShortcutsInContextMenus,
+         IconFallbackSearchPaths,
+-        MouseQuickSelectionThreshold
++        MouseQuickSelectionThreshold,
++        ButtonPressKeys
+     };
+ 
+     enum DialogType {
+diff --git a/qtbase/src/gui/kernel/qscreen.cpp b/qtbase/src/gui/kernel/qscreen.cpp
+index 8e0eb35116..5d172a58dd 100644
+--- a/qtbase/src/gui/kernel/qscreen.cpp
++++ b/qtbase/src/gui/kernel/qscreen.cpp
+@@ -77,6 +77,12 @@ QScreen::QScreen(QPlatformScreen *screen)
+     d->setPlatformScreen(screen);
+ }
+ 
++void QScreenPrivate::updateLogicalDpi()
++{
++    logicalDpi = QPlatformScreen::overrideDpi(platformScreen->logicalDpi());
++    updateGeometriesWithSignals(); // updates geometries based on scale factor
++}
++
+ void QScreenPrivate::updateGeometriesWithSignals()
+ {
+     const QRect oldGeometry = geometry;
+diff --git a/qtbase/src/gui/kernel/qscreen_p.h b/qtbase/src/gui/kernel/qscreen_p.h
+index 7da542c25e..e50fc3190b 100644
+--- a/qtbase/src/gui/kernel/qscreen_p.h
++++ b/qtbase/src/gui/kernel/qscreen_p.h
+@@ -70,6 +70,7 @@ public:
+         geometry = platformScreen->deviceIndependentGeometry();
+         availableGeometry = QHighDpi::fromNative(platformScreen->availableGeometry(), QHighDpiScaling::factor(platformScreen), geometry.topLeft());
+     }
++    void updateLogicalDpi();
+ 
+     void updatePrimaryOrientation();
+     void updateGeometriesWithSignals();
+diff --git a/qtbase/src/gui/painting/qblendfunctions_p.h b/qtbase/src/gui/painting/qblendfunctions_p.h
+index 080da98ec4..6997d62b3c 100644
+--- a/qtbase/src/gui/painting/qblendfunctions_p.h
++++ b/qtbase/src/gui/painting/qblendfunctions_p.h
+@@ -246,25 +246,32 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+                                   int dudx, int dvdx, int dudy, int dvdy, int u0, int v0,
+                                   Blender blender)
+ {
+-    int fromY = qMax(qRound(topY), clip.top());
+-    int toY = qMin(qRound(bottomY), clip.top() + clip.height());
++    qint64 fromY = qMax(qRound(topY), clip.top());
++    qint64 toY = qMin(qRound(bottomY), clip.top() + clip.height());
+     if (fromY >= toY)
+         return;
+ 
+     qreal leftSlope = (bottomLeft.x - topLeft.x) / (bottomLeft.y - topLeft.y);
+     qreal rightSlope = (bottomRight.x - topRight.x) / (bottomRight.y - topRight.y);
+-    int dx_l = int(leftSlope * 0x10000);
+-    int dx_r = int(rightSlope * 0x10000);
+-    int x_l = int((topLeft.x + (qreal(0.5) + fromY - topLeft.y) * leftSlope + qreal(0.5)) * 0x10000);
+-    int x_r = int((topRight.x + (qreal(0.5) + fromY - topRight.y) * rightSlope + qreal(0.5)) * 0x10000);
+-
+-    int fromX, toX, x1, x2, u, v, i, ii;
++    qint64 dx_l = qint64(leftSlope * 0x10000);
++    qint64 dx_r = qint64(rightSlope * 0x10000);
++    qint64 x_l = qint64((topLeft.x + (qreal(0.5) + fromY - topLeft.y) * leftSlope + qreal(0.5)) * 0x10000);
++    qint64 x_r = qint64((topRight.x + (qreal(0.5) + fromY - topRight.y) * rightSlope + qreal(0.5)) * 0x10000);
++
++    qint64 sourceRectTop = qint64(sourceRect.top());
++    qint64 sourceRectLeft = qint64(sourceRect.left());
++    qint64 sourceRectWidth = qint64(sourceRect.width());
++    qint64 sourceRectHeight = qint64(sourceRect.height());
++    qint64 clipLeft = qint64(clip.left());
++    qint64 clipWidth = qint64(clip.width());
++
++    qint64 fromX, toX, x1, x2, u, v, i, ii;
+     DestT *line;
+-    for (int y = fromY; y < toY; ++y) {
++    for (qint64 y = fromY; y < toY; ++y) {
+         line = reinterpret_cast<DestT *>(reinterpret_cast<uchar *>(destPixels) + y * dbpl);
+ 
+-        fromX = qMax(x_l >> 16, clip.left());
+-        toX = qMin(x_r >> 16, clip.left() + clip.width());
++        fromX = qMax(x_l >> 16, clipLeft);
++        toX = qMin(x_r >> 16, clipLeft + clipWidth);
+         if (fromX < toX) {
+             // Because of rounding, we can get source coordinates outside the source image.
+             // Clamp these coordinates to the source rect to avoid segmentation fault and
+@@ -275,10 +282,10 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             u = x1 * dudx + y * dudy + u0;
+             v = x1 * dvdx + y * dvdy + v0;
+             for (; x1 < toX; ++x1) {
+-                int uu = u >> 16;
+-                int vv = v >> 16;
+-                if (uu >= sourceRect.left() && uu < sourceRect.left() + sourceRect.width()
+-                    && vv >= sourceRect.top() && vv < sourceRect.top() + sourceRect.height()) {
++                qint64 uu = u >> 16;
++                qint64 vv = v >> 16;
++                if (uu >= sourceRectLeft && uu < sourceRectLeft + sourceRectWidth
++                    && vv >= sourceRectTop && vv < sourceRectTop + sourceRectHeight) {
+                     break;
+                 }
+                 u += dudx;
+@@ -290,10 +297,10 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             u = (x2 - 1) * dudx + y * dudy + u0;
+             v = (x2 - 1) * dvdx + y * dvdy + v0;
+             for (; x2 > x1; --x2) {
+-                int uu = u >> 16;
+-                int vv = v >> 16;
+-                if (uu >= sourceRect.left() && uu < sourceRect.left() + sourceRect.width()
+-                    && vv >= sourceRect.top() && vv < sourceRect.top() + sourceRect.height()) {
++                qint64 uu = u >> 16;
++                qint64 vv = v >> 16;
++                if (uu >= sourceRectLeft && uu < sourceRectLeft + sourceRectWidth
++                    && vv >= sourceRectTop && vv < sourceRectTop + sourceRectHeight) {
+                     break;
+                 }
+                 u -= dudx;
+@@ -308,8 +315,8 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             // Beginning of the scan line, with per-pixel checks.
+             i = x1 - fromX;
+             while (i) {
+-                int uu = qBound(sourceRect.left(), u >> 16, sourceRect.left() + sourceRect.width() - 1);
+-                int vv = qBound(sourceRect.top(), v >> 16, sourceRect.top() + sourceRect.height() - 1);
++                qint64 uu = qBound(sourceRectLeft, u >> 16, sourceRectLeft + sourceRectWidth - 1);
++                qint64 vv = qBound(sourceRectTop, v >> 16, sourceRectTop + sourceRectHeight - 1);
+                 blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + vv * sbpl)[uu]);
+                 u += dudx;
+                 v += dvdx;
+@@ -348,8 +355,8 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             // End of the scan line, with per-pixel checks.
+             i = toX - x2;
+             while (i) {
+-                int uu = qBound(sourceRect.left(), u >> 16, sourceRect.left() + sourceRect.width() - 1);
+-                int vv = qBound(sourceRect.top(), v >> 16, sourceRect.top() + sourceRect.height() - 1);
++                qint64 uu = qBound(sourceRectLeft, u >> 16, sourceRectLeft + sourceRectWidth - 1);
++                qint64 vv = qBound(sourceRectTop, v >> 16, sourceRectTop + sourceRectHeight - 1);
+                 blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + vv * sbpl)[uu]);
+                 u += dudx;
+                 v += dvdx;
+diff --git a/qtbase/src/gui/painting/qcolortrclut_p.h b/qtbase/src/gui/painting/qcolortrclut_p.h
+index 76a6a60803..24fd522e6c 100644
+--- a/qtbase/src/gui/painting/qcolortrclut_p.h
++++ b/qtbase/src/gui/painting/qcolortrclut_p.h
+@@ -118,6 +118,7 @@ public:
+         return QRgba64::fromRgba64(r, g, b, qAlpha(rgb32) * 257);
+ #endif
+     }
++    QRgba64 toLinear64(QRgba64) const = delete;
+ 
+     QRgb toLinear(QRgb rgb32) const
+     {
+diff --git a/qtbase/src/gui/painting/qdrawhelper.cpp b/qtbase/src/gui/painting/qdrawhelper.cpp
+index a61793508a..5ba2d277b7 100644
+--- a/qtbase/src/gui/painting/qdrawhelper.cpp
++++ b/qtbase/src/gui/painting/qdrawhelper.cpp
+@@ -6091,7 +6091,7 @@ static inline void alphargbblend_argb32(quint32 *dst, uint coverage, const QRgba
+ static inline void rgbBlendPixel(QRgba64 &dst, int coverage, QRgba64 slinear, const QColorTrcLut *colorProfile)
+ {
+     // Do a gammacorrected RGB alphablend...
+-    const QRgba64 dlinear = colorProfile ? colorProfile->toLinear64(dst) : dst;
++    const QRgba64 dlinear = colorProfile ? colorProfile->toLinear(dst) : dst;
+ 
+     QRgba64 blend = rgbBlend(dlinear, slinear, coverage);
+ 
+diff --git a/qtbase/src/gui/painting/qpaintengine_raster.cpp b/qtbase/src/gui/painting/qpaintengine_raster.cpp
+index 283923de52..f08eb9cbee 100644
+--- a/qtbase/src/gui/painting/qpaintengine_raster.cpp
++++ b/qtbase/src/gui/painting/qpaintengine_raster.cpp
+@@ -560,31 +560,6 @@ void QRasterPaintEngine::updateMatrix(const QTransform &matrix)
+     QRasterPaintEngineState *s = state();
+     // FALCON: get rid of this line, see drawImage call below.
+     s->matrix = matrix;
+-    QTransform::TransformationType txop = s->matrix.type();
+-
+-    switch (txop) {
+-
+-    case QTransform::TxNone:
+-        s->flags.int_xform = true;
+-        break;
+-
+-    case QTransform::TxTranslate:
+-        s->flags.int_xform = qreal(int(s->matrix.dx())) == s->matrix.dx()
+-                            && qreal(int(s->matrix.dy())) == s->matrix.dy();
+-        break;
+-
+-    case QTransform::TxScale:
+-        s->flags.int_xform = qreal(int(s->matrix.dx())) == s->matrix.dx()
+-                            && qreal(int(s->matrix.dy())) == s->matrix.dy()
+-                            && qreal(int(s->matrix.m11())) == s->matrix.m11()
+-                            && qreal(int(s->matrix.m22())) == s->matrix.m22();
+-        break;
+-
+-    default: // shear / perspective...
+-        s->flags.int_xform = false;
+-        break;
+-    }
+-
+     s->flags.tx_noshear = qt_scaleForTransform(s->matrix, &s->txscale);
+ 
+     ensureOutlineMapper();
+@@ -617,7 +592,6 @@ QRasterPaintEngineState::QRasterPaintEngineState()
+     flags.bilinear = false;
+     flags.legacy_rounding = false;
+     flags.fast_text = true;
+-    flags.int_xform = true;
+     flags.tx_noshear = true;
+     flags.fast_images = true;
+ 
+@@ -1793,7 +1767,7 @@ void QRasterPaintEngine::fill(const QVectorPath &path, const QBrush &brush)
+     QRectF cpRect = path.controlPointRect();
+     const QRectF pathDeviceRect = s->matrix.mapRect(cpRect);
+     // Skip paths that by conservative estimates are completely outside the paint device.
+-    if (!pathDeviceRect.intersects(QRectF(d->deviceRect)))
++    if (!pathDeviceRect.intersects(QRectF(d->deviceRect)) || !pathDeviceRect.isValid())
+         return;
+ 
+     ProcessSpans blend = d->getBrushFunc(pathDeviceRect, &s->brushData);
+diff --git a/qtbase/src/gui/painting/qpaintengine_raster_p.h b/qtbase/src/gui/painting/qpaintengine_raster_p.h
+index 089aadc3f7..bf7363d5aa 100644
+--- a/qtbase/src/gui/painting/qpaintengine_raster_p.h
++++ b/qtbase/src/gui/painting/qpaintengine_raster_p.h
+@@ -111,7 +111,6 @@ public:
+         uint bilinear : 1;
+         uint legacy_rounding : 1;
+         uint fast_text : 1;
+-        uint int_xform : 1;
+         uint tx_noshear : 1;
+         uint fast_images : 1;
+     };
+diff --git a/qtbase/src/gui/painting/qpainterpath.cpp b/qtbase/src/gui/painting/qpainterpath.cpp
+index f9544a3241..d80fafeaf1 100644
+--- a/qtbase/src/gui/painting/qpainterpath.cpp
++++ b/qtbase/src/gui/painting/qpainterpath.cpp
+@@ -1253,7 +1253,7 @@ void QPainterPath::addText(const QPointF &point, const QFont &f, const QString &
+ 
+         if (si.analysis.flags < QScriptAnalysis::TabOrObject) {
+             QGlyphLayout glyphs = eng->shapedGlyphs(&si);
+-            QFontEngine *fe = f.d->engineForScript(si.analysis.script);
++            QFontEngine *fe = eng->fontEngine(si);
+             Q_ASSERT(fe);
+             fe->addOutlineToPath(x, y, glyphs, this,
+                                  si.analysis.bidiLevel % 2
+diff --git a/qtbase/src/gui/painting/qpathclipper_p.h b/qtbase/src/gui/painting/qpathclipper_p.h
+index 9444a87b71..18f64c5e8c 100644
+--- a/qtbase/src/gui/painting/qpathclipper_p.h
++++ b/qtbase/src/gui/painting/qpathclipper_p.h
+@@ -156,7 +156,7 @@ public:
+     int vertex(Direction direction) const;
+ 
+ private:
+-    int m_next[2][2];
++    int m_next[2][2] = { { -1, -1 }, { -1, -1 } };
+ };
+ 
+ class QPathSegments
+@@ -296,10 +296,6 @@ inline QPathEdge::QPathEdge(int a, int b)
+     , angle(0)
+     , invAngle(0)
+ {
+-    m_next[0][0] = -1;
+-    m_next[1][0] = -1;
+-    m_next[0][0] = -1;
+-    m_next[1][0] = -1;
+ }
+ 
+ inline int QPathEdge::next(Traversal traversal, Direction direction) const
+diff --git a/qtbase/src/gui/painting/qpdf.cpp b/qtbase/src/gui/painting/qpdf.cpp
+index 3066744f1b..2c8d3c3b53 100644
+--- a/qtbase/src/gui/painting/qpdf.cpp
++++ b/qtbase/src/gui/painting/qpdf.cpp
+@@ -2760,6 +2760,8 @@ int QPdfEnginePrivate::addBrushPattern(const QTransform &m, bool *specifyColor,
+         return gradientBrush(brush, matrix, gStateObject);
+     }
+ 
++    matrix = brush.transform() * matrix;
++
+     if ((!brush.isOpaque() && brush.style() < Qt::LinearGradientPattern) || opacity != 1.0)
+         *gStateObject = addConstantAlphaObject(qRound(brush.color().alpha() * opacity),
+                                                qRound(pen.color().alpha() * opacity));
+diff --git a/qtbase/src/gui/painting/qstroker.cpp b/qtbase/src/gui/painting/qstroker.cpp
+index cb5d395e80..3b6357a893 100644
+--- a/qtbase/src/gui/painting/qstroker.cpp
++++ b/qtbase/src/gui/painting/qstroker.cpp
+@@ -1182,6 +1182,7 @@ void QDashStroker::processCurrentSubpath()
+         // Check if the entire line should be clipped away or simplified
+         bool clipIt = clipping && !lineIntersectsRect(prev, e, clip_tl, clip_br);
+         bool skipDashing = elen * invSumLength > repetitionLimit();
++        int maxDashes = dashCount;
+         if (skipDashing || clipIt) {
+             // Cut away full dash sequences.
+             elen -= std::floor(elen * invSumLength) * sumLength;
+@@ -1196,7 +1197,7 @@ void QDashStroker::processCurrentSubpath()
+                     pos = estop; // move pos to next path element
+                     done = true;
+                 } else { // Dash is on this line
+-                    pos = dpos + estart;
++                    pos = --maxDashes > 0 ? dpos + estart : estop;
+                     done = pos >= estop;
+                     if (++idash >= dashCount)
+                         idash = 0;
+diff --git a/qtbase/src/gui/painting/qt_attribution.json b/qtbase/src/gui/painting/qt_attribution.json
+index 7b16e8c211..0e87d30aa2 100644
+--- a/qtbase/src/gui/painting/qt_attribution.json
++++ b/qtbase/src/gui/painting/qt_attribution.json
+@@ -10,7 +10,7 @@
+         "Homepage": "http://www.freetype.org",
+         "License": "Freetype Project License or GNU General Public License v2.0 only",
+         "LicenseId": "FTL or GPL-2.0",
+-        "LicenseFile": "../../3rdparty/freetype/docs/LICENSE.TXT",
++        "LicenseFile": "../../3rdparty/freetype/LICENSE.TXT",
+         "Copyright": "Copyright 2000-2016 by David Turner, Robert Wilhelm, and Werner Lemberg."
+     },
+     {
+diff --git a/qtbase/src/gui/rhi/qshader_p_p.h b/qtbase/src/gui/rhi/qshader_p_p.h
+index ec9d25971f..4a5a7a6d51 100644
+--- a/qtbase/src/gui/rhi/qshader_p_p.h
++++ b/qtbase/src/gui/rhi/qshader_p_p.h
+@@ -68,13 +68,13 @@ struct Q_GUI_EXPORT QShaderPrivate
+     {
+     }
+ 
+-    QShaderPrivate(const QShaderPrivate *other)
++    QShaderPrivate(const QShaderPrivate &other)
+         : ref(1),
+-          qsbVersion(other->qsbVersion),
+-          stage(other->stage),
+-          desc(other->desc),
+-          shaders(other->shaders),
+-          bindings(other->bindings)
++          qsbVersion(other.qsbVersion),
++          stage(other.stage),
++          desc(other.desc),
++          shaders(other.shaders),
++          bindings(other.bindings)
+     {
+     }
+ 
+diff --git a/qtbase/src/gui/rhi/qshaderdescription_p_p.h b/qtbase/src/gui/rhi/qshaderdescription_p_p.h
+index ec2b0b6b4c..3da33a8a2b 100644
+--- a/qtbase/src/gui/rhi/qshaderdescription_p_p.h
++++ b/qtbase/src/gui/rhi/qshaderdescription_p_p.h
+@@ -63,16 +63,16 @@ struct Q_GUI_EXPORT QShaderDescriptionPrivate
+         localSize[0] = localSize[1] = localSize[2] = 0;
+     }
+ 
+-    QShaderDescriptionPrivate(const QShaderDescriptionPrivate *other)
++    QShaderDescriptionPrivate(const QShaderDescriptionPrivate &other)
+         : ref(1),
+-          inVars(other->inVars),
+-          outVars(other->outVars),
+-          uniformBlocks(other->uniformBlocks),
+-          pushConstantBlocks(other->pushConstantBlocks),
+-          storageBlocks(other->storageBlocks),
+-          combinedImageSamplers(other->combinedImageSamplers),
+-          storageImages(other->storageImages),
+-          localSize(other->localSize)
++          inVars(other.inVars),
++          outVars(other.outVars),
++          uniformBlocks(other.uniformBlocks),
++          pushConstantBlocks(other.pushConstantBlocks),
++          storageBlocks(other.storageBlocks),
++          combinedImageSamplers(other.combinedImageSamplers),
++          storageImages(other.storageImages),
++          localSize(other.localSize)
+     {
+     }
+ 
+diff --git a/qtbase/src/gui/text/qfontdatabase.cpp b/qtbase/src/gui/text/qfontdatabase.cpp
+index a657a8c516..4fc0100958 100644
+--- a/qtbase/src/gui/text/qfontdatabase.cpp
++++ b/qtbase/src/gui/text/qfontdatabase.cpp
+@@ -983,7 +983,7 @@ QFontEngine *loadSingleEngine(int script,
+         if (style->key.stretch != 0 && request.stretch != 0
+             && (request.styleName.isEmpty() || request.styleName != style->styleName)) {
+             def.stretch = (request.stretch * 100 + style->key.stretch / 2) / style->key.stretch;
+-        } else {
++        } else if (request.stretch == QFont::AnyStretch) {
+             def.stretch = 100;
+         }
+ 
+diff --git a/qtbase/src/gui/text/qtextdocumentlayout.cpp b/qtbase/src/gui/text/qtextdocumentlayout.cpp
+index f3e6ea2100..72267e9380 100644
+--- a/qtbase/src/gui/text/qtextdocumentlayout.cpp
++++ b/qtbase/src/gui/text/qtextdocumentlayout.cpp
+@@ -2123,7 +2123,7 @@ void QTextDocumentLayoutPrivate::drawListItem(const QPointF &offset, QPainter *p
+ {
+     Q_Q(const QTextDocumentLayout);
+     const QTextBlockFormat blockFormat = bl.blockFormat();
+-    const QTextCharFormat charFormat = QTextCursor(bl).charFormat();
++    const QTextCharFormat charFormat = bl.charFormat();
+     QFont font(charFormat.font());
+     if (q->paintDevice())
+         font = QFont(font, q->paintDevice());
+diff --git a/qtbase/src/gui/text/qtextengine.cpp b/qtbase/src/gui/text/qtextengine.cpp
+index ce4abac472..a6c66e5d2d 100644
+--- a/qtbase/src/gui/text/qtextengine.cpp
++++ b/qtbase/src/gui/text/qtextengine.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2021 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtGui module of the Qt Toolkit.
+@@ -1565,6 +1565,12 @@ void QTextEngine::shapeText(int item) const
+         // Overwrite with 0 token to indicate failure
+         QGlyphLayout g = availableGlyphs(&si);
+         g.glyphs[0] = 0;
++        g.attributes[0].clusterStart = true;
++
++        ushort *log_clusters = logClusters(&si);
++        for (int i = 0; i < itemLength; ++i)
++            log_clusters[i] = 0;
++
+         return;
+     }
+ 
+diff --git a/qtbase/src/gui/util/qdesktopservices.cpp b/qtbase/src/gui/util/qdesktopservices.cpp
+index fbb63a9408..4d5fafaaa7 100644
+--- a/qtbase/src/gui/util/qdesktopservices.cpp
++++ b/qtbase/src/gui/util/qdesktopservices.cpp
+@@ -54,6 +54,8 @@
+ #include <qpa/qplatformintegration.h>
+ #include <qdir.h>
+ 
++#include <QtCore/private/qlocking_p.h>
++
+ QT_BEGIN_NAMESPACE
+ 
+ class QOpenUrlHandlerRegistry : public QObject
+@@ -81,6 +83,7 @@ Q_GLOBAL_STATIC(QOpenUrlHandlerRegistry, handlerRegistry)
+ 
+ void QOpenUrlHandlerRegistry::handlerDestroyed(QObject *handler)
+ {
++    const auto lock = qt_scoped_lock(mutex);
+     HandlerHash::Iterator it = handlers.begin();
+     while (it != handlers.end()) {
+         if (it->receiver == handler) {
+@@ -294,7 +297,8 @@ void QDesktopServices::setUrlHandler(const QString &scheme, QObject *receiver, c
+     h.name = method;
+     registry->handlers.insert(scheme.toLower(), h);
+     QObject::connect(receiver, SIGNAL(destroyed(QObject*)),
+-                     registry, SLOT(handlerDestroyed(QObject*)));
++                     registry, SLOT(handlerDestroyed(QObject*)),
++                     Qt::DirectConnection);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/gui/util/qpkmhandler.cpp b/qtbase/src/gui/util/qpkmhandler.cpp
+index e0c3b75efe..3414f9d8ba 100644
+--- a/qtbase/src/gui/util/qpkmhandler.cpp
++++ b/qtbase/src/gui/util/qpkmhandler.cpp
+@@ -57,7 +57,7 @@ struct PkmType
+     quint32 bytesPerBlock;
+ };
+ 
+-static PkmType typeMap[5] = {
++static constexpr PkmType typeMap[5] = {
+     { 0x8D64,  8 },   // GL_ETC1_RGB8_OES
+     { 0x9274,  8 },   // GL_COMPRESSED_RGB8_ETC2
+     { 0, 0 },         // unused (obsolete)
+diff --git a/qtbase/src/network/access/qnetworkreplyfileimpl.cpp b/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
+index b6be93147a..6e69b4c4d3 100644
+--- a/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
++++ b/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
+@@ -89,9 +89,10 @@ QNetworkReplyFileImpl::QNetworkReplyFileImpl(QNetworkAccessManager *manager, con
+         // we handle only local files
+         QString msg = QCoreApplication::translate("QNetworkAccessFileBackend", "Request for opening non-local file %1").arg(url.toString());
+         setError(QNetworkReply::ProtocolInvalidOperationError, msg);
++        setFinished(true); // We're finished, will emit finished() after ctor is done.
+         QMetaObject::invokeMethod(this, "errorOccurred", Qt::QueuedConnection,
+             Q_ARG(QNetworkReply::NetworkError, QNetworkReply::ProtocolInvalidOperationError));
+-        fileOpenFinished(false);
++        QMetaObject::invokeMethod(this, [this](){ fileOpenFinished(false); }, Qt::QueuedConnection);
+         return;
+     }
+ #endif
+diff --git a/qtbase/src/network/access/qnetworkreplyimpl.cpp b/qtbase/src/network/access/qnetworkreplyimpl.cpp
+index bcdf6ee2f1..3b6deb82bd 100644
+--- a/qtbase/src/network/access/qnetworkreplyimpl.cpp
++++ b/qtbase/src/network/access/qnetworkreplyimpl.cpp
+@@ -680,7 +680,7 @@ void QNetworkReplyImplPrivate::appendDownstreamData(QIODevice *data)
+     // read until EOF from data
+     if (Q_UNLIKELY(copyDevice)) {
+         qCritical("QNetworkReplyImpl: copy from QIODevice already in progress -- "
+-                  "backend probly needs to be fixed");
++                  "backend probably needs to be fixed");
+         return;
+     }
+ 
+diff --git a/qtbase/src/network/kernel/qauthenticator.cpp b/qtbase/src/network/kernel/qauthenticator.cpp
+index d9fe7bc47b..ccd04b294a 100644
+--- a/qtbase/src/network/kernel/qauthenticator.cpp
++++ b/qtbase/src/network/kernel/qauthenticator.cpp
+@@ -50,6 +50,7 @@
+ #include <qstring.h>
+ #include <qdatetime.h>
+ #include <qrandom.h>
++#include "private/qsystemlibrary_p.h"
+ 
+ #ifdef Q_OS_WIN
+ #include <qmutex.h>
+@@ -1563,7 +1564,7 @@ static bool q_SSPI_library_load()
+ 
+     // Initialize security interface
+     if (pSecurityFunctionTable == nullptr) {
+-        securityDLLHandle = LoadLibrary(L"secur32.dll");
++        securityDLLHandle = QSystemLibrary::load(L"secur32");
+         if (securityDLLHandle != nullptr) {
+             INIT_SECURITY_INTERFACE pInitSecurityInterface =
+                 reinterpret_cast<INIT_SECURITY_INTERFACE>(
+diff --git a/qtbase/src/network/kernel/qhostinfo_unix.cpp b/qtbase/src/network/kernel/qhostinfo_unix.cpp
+index 9b0a2ee669..73679c9ef1 100644
+--- a/qtbase/src/network/kernel/qhostinfo_unix.cpp
++++ b/qtbase/src/network/kernel/qhostinfo_unix.cpp
+@@ -122,7 +122,6 @@ static QFunctionPointer resolveSymbol(QLibrary &lib, const char *sym)
+ 
+ LibResolv::LibResolv()
+ {
+-    QLibrary lib;
+ #ifdef LIBRESOLV_SO
+     lib.setFileName(QStringLiteral(LIBRESOLV_SO));
+     if (!lib.load())
+diff --git a/qtbase/src/network/socket/qsocks5socketengine.cpp b/qtbase/src/network/socket/qsocks5socketengine.cpp
+index 3a046fd116..97fadca0b3 100644
+--- a/qtbase/src/network/socket/qsocks5socketengine.cpp
++++ b/qtbase/src/network/socket/qsocks5socketengine.cpp
+@@ -1296,7 +1296,7 @@ void QSocks5SocketEnginePrivate::_q_udpSocketReadNotification()
+         int pos = 0;
+         const char *buf = inBuf.constData();
+         if (inBuf.size() < 4) {
+-            QSOCKS5_D_DEBUG << "bugus udp data, discarding";
++            QSOCKS5_D_DEBUG << "bogus udp data, discarding";
+             return;
+         }
+         QSocks5RevivedDatagram datagram;
+diff --git a/qtbase/src/network/ssl/qsslcontext_openssl.cpp b/qtbase/src/network/ssl/qsslcontext_openssl.cpp
+index c9f202f573..c992da9d8e 100644
+--- a/qtbase/src/network/ssl/qsslcontext_openssl.cpp
++++ b/qtbase/src/network/ssl/qsslcontext_openssl.cpp
+@@ -409,7 +409,7 @@ init_context:
+         break;
+     case QSsl::DtlsV1_0OrLater:
+         minVersion = DTLS1_VERSION;
+-        maxVersion = DTLS_MAX_VERSION;
++        maxVersion = 0;
+         break;
+     case QSsl::DtlsV1_2:
+         minVersion = DTLS1_2_VERSION;
+@@ -417,7 +417,7 @@ init_context:
+         break;
+     case QSsl::DtlsV1_2OrLater:
+         minVersion = DTLS1_2_VERSION;
+-        maxVersion = DTLS_MAX_VERSION;
++        maxVersion = 0;
+         break;
+     case QSsl::TlsV1_3OrLater:
+ #ifdef TLS1_3_VERSION
+@@ -455,7 +455,7 @@ init_context:
+     }
+ 
+     // Enable bug workarounds.
+-    long options = QSslSocketBackendPrivate::setupOpenSslOptions(configuration.protocol(), configuration.d->sslOptions);
++    qssloptions options = QSslSocketBackendPrivate::setupOpenSslOptions(configuration.protocol(), configuration.d->sslOptions);
+     q_SSL_CTX_set_options(sslContext->ctx, options);
+ 
+     // Tell OpenSSL to release memory early
+diff --git a/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp b/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
+index aaf8741130..b58935372c 100644
+--- a/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
++++ b/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
+@@ -59,57 +59,6 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-#ifdef OPENSSL_NO_DEPRECATED_3_0
+-
+-static int q_DH_check(DH *dh, int *status)
+-{
+-    // DH_check was first deprecated in OpenSSL 3.0.0, as low-level
+-    // API; the EVP_PKEY family of functions was advised as an alternative.
+-    // As of now EVP_PKEY_params_check ends up calling ... DH_check,
+-    // which is good enough.
+-
+-    Q_ASSERT(dh);
+-    Q_ASSERT(status);
+-
+-    EVP_PKEY *key = q_EVP_PKEY_new();
+-    if (!key) {
+-        qCWarning(lcSsl, "EVP_PKEY_new failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-    const auto keyDeleter = qScopeGuard([key](){
+-        q_EVP_PKEY_free(key);
+-    });
+-    if (!q_EVP_PKEY_set1_DH(key, dh)) {
+-        qCWarning(lcSsl, "EVP_PKEY_set1_DH failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-
+-    EVP_PKEY_CTX *keyCtx = q_EVP_PKEY_CTX_new(key, nullptr);
+-    if (!keyCtx) {
+-        qCWarning(lcSsl, "EVP_PKEY_CTX_new failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-    const auto ctxDeleter = qScopeGuard([keyCtx]{
+-        q_EVP_PKEY_CTX_free(keyCtx);
+-    });
+-
+-    const int result = q_EVP_PKEY_param_check(keyCtx);
+-    QSslSocketBackendPrivate::logAndClearErrorQueue();
+-    // Note: unlike DH_check, we cannot obtain the 'status',
+-    // if the 'result' is 0 (actually the result is 1 only
+-    // if this 'status' was 0). We could probably check the
+-    // errors from the error queue, but it's not needed anyway
+-    // - see the 'isSafeDH' below, how it returns immediately
+-    // on 0.
+-    Q_UNUSED(status)
+-
+-    return result;
+-}
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+-
+ static bool isSafeDH(DH *dh)
+ {
+     int status = 0;
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl.cpp b/qtbase/src/network/ssl/qsslsocket_openssl.cpp
+index 37fad2a68f..8f6858c867 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl.cpp
++++ b/qtbase/src/network/ssl/qsslsocket_openssl.cpp
+@@ -550,9 +550,9 @@ static void q_loadCiphersForConnection(SSL *connection, QList<QSslCipher> &ciphe
+ // Defined in qsslsocket.cpp
+ void q_setDefaultDtlsCiphers(const QList<QSslCipher> &ciphers);
+ 
+-long QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions)
++qssloptions QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions)
+ {
+-    long options;
++    qssloptions options;
+     if (protocol == QSsl::TlsV1SslV3)
+         options = SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3;
+     else if (protocol == QSsl::SecureProtocols)
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_p.h b/qtbase/src/network/ssl/qsslsocket_openssl_p.h
+index 4103de23e8..5547589256 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_p.h
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_p.h
+@@ -107,6 +107,12 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++typedef uint64_t qssloptions;
++#else
++typedef unsigned long qssloptions;
++#endif
++
+ struct QSslErrorEntry {
+     int code;
+     int depth;
+@@ -171,7 +177,7 @@ public:
+     QVector<QSslError> ocspErrors;
+     QByteArray ocspResponseDer;
+ 
+-    Q_AUTOTEST_EXPORT static long setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions);
++    Q_AUTOTEST_EXPORT static qssloptions setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions);
+     static QSslCipher QSslCipher_from_SSL_CIPHER(const SSL_CIPHER *cipher);
+     static QList<QSslCertificate> STACKOFX509_to_QSslCertificates(STACK_OF(X509) *x509);
+     static QList<QSslError> verify(const QList<QSslCertificate> &certificateChain, const QString &hostName);
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp b/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
+index e53fb279f0..459ccd0b19 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
+@@ -148,7 +148,6 @@ DEFINEFUNC(int, EVP_PKEY_up_ref, EVP_PKEY *a, a, return 0, return)
+ DEFINEFUNC2(EVP_PKEY_CTX *, EVP_PKEY_CTX_new, EVP_PKEY *pkey, pkey, ENGINE *e, e, return nullptr, return)
+ DEFINEFUNC(int, EVP_PKEY_param_check, EVP_PKEY_CTX *ctx, ctx, return 0, return)
+ DEFINEFUNC(void, EVP_PKEY_CTX_free, EVP_PKEY_CTX *ctx, ctx, return, return)
+-DEFINEFUNC(int, EVP_PKEY_base_id, EVP_PKEY *a, a, return NID_undef, return)
+ DEFINEFUNC(int, RSA_bits, RSA *a, a, return 0, return)
+ DEFINEFUNC(int, DSA_bits, DSA *a, a, return 0, return)
+ DEFINEFUNC(int, OPENSSL_sk_num, OPENSSL_STACK *a, a, return -1, return)
+@@ -158,7 +157,7 @@ DEFINEFUNC2(void, OPENSSL_sk_push, OPENSSL_STACK *a, a, void *b, b, return, DUMM
+ DEFINEFUNC(void, OPENSSL_sk_free, OPENSSL_STACK *a, a, return, DUMMYARG)
+ DEFINEFUNC2(void *, OPENSSL_sk_value, OPENSSL_STACK *a, a, int b, b, return nullptr, return)
+ DEFINEFUNC(int, SSL_session_reused, SSL *a, a, return 0, return)
+-DEFINEFUNC2(unsigned long, SSL_CTX_set_options, SSL_CTX *ctx, ctx, unsigned long op, op, return 0, return)
++DEFINEFUNC2(qssloptions, SSL_CTX_set_options, SSL_CTX *ctx, ctx, qssloptions op, op, return 0, return)
+ DEFINEFUNC(int, SSL_CTX_get_security_level, const SSL_CTX *ctx, ctx, return -1, return)
+ DEFINEFUNC2(void, SSL_CTX_set_security_level, SSL_CTX *ctx, ctx, int level, level, return, return)
+ #ifdef TLS1_3_VERSION
+@@ -371,7 +370,15 @@ DEFINEFUNC(const SSL_CIPHER *, SSL_get_current_cipher, SSL *a, a, return nullptr
+ DEFINEFUNC(int, SSL_version, const SSL *a, a, return 0, return)
+ DEFINEFUNC2(int, SSL_get_error, SSL *a, a, int b, b, return -1, return)
+ DEFINEFUNC(STACK_OF(X509) *, SSL_get_peer_cert_chain, SSL *a, a, return nullptr, return)
++
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++DEFINEFUNC(X509 *, SSL_get1_peer_certificate, SSL *a, a, return nullptr, return)
++DEFINEFUNC(int, EVP_PKEY_get_base_id, const EVP_PKEY *pkey, pkey, return -1, return)
++#else
+ DEFINEFUNC(X509 *, SSL_get_peer_certificate, SSL *a, a, return nullptr, return)
++DEFINEFUNC(int, EVP_PKEY_base_id, EVP_PKEY *a, a, return NID_undef, return)
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+ DEFINEFUNC(long, SSL_get_verify_result, const SSL *a, a, return -1, return)
+ DEFINEFUNC(SSL *, SSL_new, SSL_CTX *a, a, return nullptr, return)
+ DEFINEFUNC(SSL_CTX *, SSL_get_SSL_CTX, SSL *a, a, return nullptr, return)
+@@ -492,9 +499,7 @@ DEFINEFUNC(DH *, DH_new, DUMMYARG, DUMMYARG, return nullptr, return)
+ DEFINEFUNC(void, DH_free, DH *dh, dh, return, DUMMYARG)
+ DEFINEFUNC3(DH *, d2i_DHparams, DH**a, a, const unsigned char **pp, pp, long length, length, return nullptr, return)
+ DEFINEFUNC2(int, i2d_DHparams, DH *a, a, unsigned char **p, p, return -1, return)
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+ DEFINEFUNC2(int, DH_check, DH *dh, dh, int *codes, codes, return 0, return)
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+ DEFINEFUNC3(BIGNUM *, BN_bin2bn, const unsigned char *s, s, int len, len, BIGNUM *ret, ret, return nullptr, return)
+ 
+ #ifndef OPENSSL_NO_EC
+@@ -868,7 +873,6 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(EVP_PKEY_CTX_new)
+     RESOLVEFUNC(EVP_PKEY_param_check)
+     RESOLVEFUNC(EVP_PKEY_CTX_free)
+-    RESOLVEFUNC(EVP_PKEY_base_id)
+     RESOLVEFUNC(RSA_bits)
+     RESOLVEFUNC(OPENSSL_sk_new_null)
+     RESOLVEFUNC(OPENSSL_sk_push)
+@@ -1107,7 +1111,15 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(SSL_version)
+     RESOLVEFUNC(SSL_get_error)
+     RESOLVEFUNC(SSL_get_peer_cert_chain)
++
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++    RESOLVEFUNC(SSL_get1_peer_certificate)
++    RESOLVEFUNC(EVP_PKEY_get_base_id)
++#else
+     RESOLVEFUNC(SSL_get_peer_certificate)
++    RESOLVEFUNC(EVP_PKEY_base_id)
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+     RESOLVEFUNC(SSL_get_verify_result)
+     RESOLVEFUNC(SSL_new)
+     RESOLVEFUNC(SSL_get_SSL_CTX)
+@@ -1206,9 +1218,7 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(DH_free)
+     RESOLVEFUNC(d2i_DHparams)
+     RESOLVEFUNC(i2d_DHparams)
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+     RESOLVEFUNC(DH_check)
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+     RESOLVEFUNC(BN_bin2bn)
+ 
+ #ifndef OPENSSL_NO_EC
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h b/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
+index 95e8897a3b..27aeffa18a 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
+@@ -237,7 +237,6 @@ Q_AUTOTEST_EXPORT int q_EVP_PKEY_up_ref(EVP_PKEY *a);
+ EVP_PKEY_CTX *q_EVP_PKEY_CTX_new(EVP_PKEY *pkey, ENGINE *e);
+ void q_EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx);
+ int q_EVP_PKEY_param_check(EVP_PKEY_CTX *ctx);
+-int q_EVP_PKEY_base_id(EVP_PKEY *a);
+ int q_RSA_bits(RSA *a);
+ Q_AUTOTEST_EXPORT int q_OPENSSL_sk_num(OPENSSL_STACK *a);
+ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_pop_free(OPENSSL_STACK *a, void (*b)(void *));
+@@ -246,7 +245,7 @@ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_push(OPENSSL_STACK *st, void *data);
+ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_free(OPENSSL_STACK *a);
+ Q_AUTOTEST_EXPORT void * q_OPENSSL_sk_value(OPENSSL_STACK *a, int b);
+ int q_SSL_session_reused(SSL *a);
+-unsigned long q_SSL_CTX_set_options(SSL_CTX *ctx, unsigned long op);
++qssloptions q_SSL_CTX_set_options(SSL_CTX *ctx, qssloptions op);
+ int q_OPENSSL_init_ssl(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings);
+ size_t q_SSL_get_client_random(SSL *a, unsigned char *out, size_t outlen);
+ size_t q_SSL_SESSION_get_master_key(const SSL_SESSION *session, unsigned char *out, size_t outlen);
+@@ -510,7 +509,6 @@ const SSL_CIPHER *q_SSL_get_current_cipher(SSL *a);
+ int q_SSL_version(const SSL *a);
+ int q_SSL_get_error(SSL *a, int b);
+ STACK_OF(X509) *q_SSL_get_peer_cert_chain(SSL *a);
+-X509 *q_SSL_get_peer_certificate(SSL *a);
+ long q_SSL_get_verify_result(const SSL *a);
+ SSL *q_SSL_new(SSL_CTX *a);
+ SSL_CTX *q_SSL_get_SSL_CTX(SSL *a);
+@@ -582,10 +580,7 @@ DH *q_DH_new();
+ void q_DH_free(DH *dh);
+ DH *q_d2i_DHparams(DH **a, const unsigned char **pp, long length);
+ int q_i2d_DHparams(DH *a, unsigned char **p);
+-
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+ int q_DH_check(DH *dh, int *codes);
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+ 
+ BIGNUM *q_BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret);
+ #define q_SSL_CTX_set_tmp_dh(ctx, dh) q_SSL_CTX_ctrl((ctx), SSL_CTRL_SET_TMP_DH, 0, (char *)dh)
+@@ -754,6 +749,17 @@ void q_CRYPTO_free(void *str, const char *file, int line);
+ int q_SSL_CTX_get_security_level(const SSL_CTX *ctx);
+ void q_SSL_CTX_set_security_level(SSL_CTX *ctx, int level);
+ 
++// Here we have the ones that make difference between OpenSSL pre/post v3:
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++X509 *q_SSL_get1_peer_certificate(SSL *a);
++#define q_SSL_get_peer_certificate q_SSL_get1_peer_certificate
++int q_EVP_PKEY_get_base_id(const EVP_PKEY *pkey);
++#define q_EVP_PKEY_base_id q_EVP_PKEY_get_base_id
++#else
++X509 *q_SSL_get_peer_certificate(SSL *a);
++int q_EVP_PKEY_base_id(EVP_PKEY *a);
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+ QT_END_NAMESPACE
+ 
+ #endif
+diff --git a/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h b/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
+index bf37d07fd8..dbd42fb799 100644
+--- a/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
++++ b/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
+@@ -61,7 +61,11 @@
+ # if !defined(Q_OS_INTEGRITY)
+ #  define WIN_INTERFACE_CUSTOM   // NV
+ # endif // Q_OS_INTEGRITY
+-#endif  // QT_EGL_NO_X11
++#else // QT_EGL_NO_X11
++// If one has an eglplatform.h with https://github.com/KhronosGroup/EGL-Registry/pull/130
++// that needs USE_X11 to be defined.
++# define USE_X11
++#endif
+ 
+ #ifdef QT_EGL_WAYLAND
+ # define WAYLAND // NV
+diff --git a/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+index 159b490ce0..00aa80cd58 100644
+--- a/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
++++ b/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+@@ -567,6 +567,8 @@ void QFontconfigDatabase::populateFontDatabase()
+         fonts = FcFontList(nullptr, pattern, os);
+         FcObjectSetDestroy(os);
+         FcPatternDestroy(pattern);
++        if (!fonts)
++            return;
+     }
+ 
+     for (int i = 0; i < fonts->nfont; i++)
+diff --git a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
+index b713c19447..7cb9a8c79a 100644
+--- a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
++++ b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
+@@ -95,6 +95,7 @@ static constexpr const auto KeyTbl = qMakeArray(
+         Xkb2Qt<XKB_KEY_Clear,                   Qt::Key_Delete>,
+         Xkb2Qt<XKB_KEY_Pause,                   Qt::Key_Pause>,
+         Xkb2Qt<XKB_KEY_Print,                   Qt::Key_Print>,
++        Xkb2Qt<XKB_KEY_Sys_Req,                 Qt::Key_SysReq>,
+         Xkb2Qt<0x1005FF60,                      Qt::Key_SysReq>,         // hardcoded Sun SysReq
+         Xkb2Qt<0x1007ff00,                      Qt::Key_SysReq>,         // hardcoded X386 SysReq
+ 
+@@ -471,7 +472,7 @@ QVector<xkb_keysym_t> QXkbCommon::toKeysym(QKeyEvent *event)
+     } else if (event->modifiers() & Qt::KeypadModifier) {
+         if (qtKey >= Qt::Key_0 && qtKey <= Qt::Key_9)
+             keysyms.append(XKB_KEY_KP_0 + (qtKey - Qt::Key_0));
+-    } else if (isLatin(qtKey) && event->text().isUpper()) {
++    } else if (isLatin1(qtKey) && event->text().isUpper()) {
+         keysyms.append(qtKey);
+     }
+ 
+@@ -523,7 +524,7 @@ int QXkbCommon::keysymToQtKey(xkb_keysym_t keysym, Qt::KeyboardModifiers modifie
+         // With standard shortcuts we should prefer a latin character, this is
+         // for checks like "some qkeyevent == QKeySequence::Copy" to work even
+         // when using for example 'russian' keyboard layout.
+-        if (!QXkbCommon::isLatin(keysym)) {
++        if (!QXkbCommon::isLatin1(keysym)) {
+             xkb_keysym_t latinKeysym = QXkbCommon::lookupLatinKeysym(state, code);
+             if (latinKeysym != XKB_KEY_NoSymbol)
+                 keysym = latinKeysym;
+@@ -546,7 +547,7 @@ static int keysymToQtKey_internal(xkb_keysym_t keysym, Qt::KeyboardModifiers mod
+     } else if (keysym >= XKB_KEY_KP_0 && keysym <= XKB_KEY_KP_9) {
+         // numeric keypad keys
+         qtKey = Qt::Key_0 + (keysym - XKB_KEY_KP_0);
+-    } else if (QXkbCommon::isLatin(keysym)) {
++    } else if (QXkbCommon::isLatin1(keysym)) {
+         qtKey = QXkbCommon::qxkbcommon_xkb_keysym_to_upper(keysym);
+     } else {
+         // check if we have a direct mapping
+@@ -678,7 +679,7 @@ QList<int> QXkbCommon::possibleKeys(xkb_state *state, const QKeyEvent *event,
+         Qt::KeyboardModifiers neededMods = ModsTbl[i];
+         if ((modifiers & neededMods) == neededMods) {
+             if (i == 8) {
+-                if (isLatin(baseQtKey))
++                if (isLatin1(baseQtKey))
+                     continue;
+                 // add a latin key as a fall back key
+                 sym = lookupLatinKeysym(state, keycode);
+@@ -733,7 +734,7 @@ void QXkbCommon::verifyHasLatinLayout(xkb_keymap *keymap)
+     for (xkb_layout_index_t layout = 0; layout < layoutCount; ++layout) {
+         for (xkb_keycode_t code = minKeycode; code < maxKeycode; ++code) {
+             xkb_keymap_key_get_syms_by_level(keymap, code, layout, 0, &keysyms);
+-            if (keysyms && isLatin(keysyms[0]))
++            if (keysyms && isLatin1(keysyms[0]))
+                 nrLatinKeys++;
+             if (nrLatinKeys > 10) // arbitrarily chosen threshold
+                 return;
+@@ -766,7 +767,7 @@ xkb_keysym_t QXkbCommon::lookupLatinKeysym(xkb_state *state, xkb_keycode_t keyco
+         xkb_level_index_t level = xkb_state_key_get_level(state, keycode, layout);
+         if (xkb_keymap_key_get_syms_by_level(keymap, keycode, layout, level, &syms) != 1)
+             continue;
+-        if (isLatin(syms[0])) {
++        if (isLatin1(syms[0])) {
+             sym = syms[0];
+             break;
+         }
+diff --git a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
+index 561eae03db..8389bd8f5a 100644
+--- a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
++++ b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
+@@ -94,8 +94,8 @@ public:
+     static void verifyHasLatinLayout(xkb_keymap *keymap);
+     static xkb_keysym_t lookupLatinKeysym(xkb_state *state, xkb_keycode_t keycode);
+ 
+-    static bool isLatin(xkb_keysym_t sym) {
+-        return ((sym >= 'a' && sym <= 'z') || (sym >= 'A' && sym <= 'Z'));
++    static bool isLatin1(xkb_keysym_t sym) {
++        return sym <= 0xff;
+     }
+     static bool isKeypad(xkb_keysym_t sym) {
+         return sym >= XKB_KEY_KP_Space && sym <= XKB_KEY_KP_9;
+diff --git a/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp b/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
+index 8cd7f9b368..406f84663f 100644
+--- a/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
++++ b/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
+@@ -318,7 +318,7 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources,
+ 
+     if (current < 0 && crtc_mode.clock != 0) {
+         modes << crtc_mode;
+-        current = mode.size() - 1;
++        current = modes.size() - 1;
+     }
+ 
+     if (configuration == OutputConfigCurrent)
+diff --git a/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp b/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
+index 9153fd20bb..255ea5e33e 100644
+--- a/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
++++ b/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
+@@ -194,6 +194,9 @@ QString AtSpiAdaptor::introspect(const QString &path) const
+                 "      <arg direction=\"out\" type=\"(so)\"/>\n"
+                 "      <annotation value=\"QSpiObjectReference\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n"
+                 "    </method>\n"
++                "    <method name=\"GetAccessibleId\">\n"
++                "      <arg direction=\"out\" type=\"s\"/>\n"
++                "    </method>\n"
+                 "  </interface>\n"
+                 );
+ 
+@@ -913,8 +916,17 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+     }
+     case QAccessible::NameChanged: {
+         if (sendObject || sendObject_property_change || sendObject_property_change_accessible_name) {
+-            QString path = pathForInterface(event->accessibleInterface());
+-            QVariantList args = packDBusSignalArguments(QLatin1String("accessible-name"), 0, 0, variantForPath(path));
++            QAccessibleInterface *iface = event->accessibleInterface();
++            if (!iface) {
++                qCDebug(lcAccessibilityAtspi,
++                        "NameChanged event from invalid accessible.");
++                return;
++            }
++
++            QString path = pathForInterface(iface);
++            QVariantList args = packDBusSignalArguments(
++                QLatin1String("accessible-name"), 0, 0,
++                QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Name))));
+             sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                            QLatin1String("PropertyChange"), args);
+         }
+@@ -922,8 +934,17 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+     }
+     case QAccessible::DescriptionChanged: {
+         if (sendObject || sendObject_property_change || sendObject_property_change_accessible_description) {
+-            QString path = pathForInterface(event->accessibleInterface());
+-            QVariantList args = packDBusSignalArguments(QLatin1String("accessible-description"), 0, 0, variantForPath(path));
++            QAccessibleInterface *iface = event->accessibleInterface();
++            if (!iface) {
++                qCDebug(lcAccessibilityAtspi,
++                        "DescriptionChanged event from invalid accessible.");
++                return;
++            }
++
++            QString path = pathForInterface(iface);
++            QVariantList args = packDBusSignalArguments(
++                QLatin1String("accessible-description"), 0, 0,
++                QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Description))));
+             sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                            QLatin1String("PropertyChange"), args);
+         }
+@@ -1038,7 +1059,9 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+                 // Combo Box with AT-SPI likes to be special
+                 // It requires a name-change to update caches and then selection-changed
+                 QString path = pathForInterface(iface);
+-                QVariantList args1 = packDBusSignalArguments(QLatin1String("accessible-name"), 0, 0, variantForPath(path));
++                QVariantList args1 = packDBusSignalArguments(
++                    QLatin1String("accessible-name"), 0, 0,
++                    QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Name))));
+                 sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                                QLatin1String("PropertyChange"), args1);
+                 QVariantList args2 = packDBusSignalArguments(QString(), 0, 0, QVariant::fromValue(QDBusVariant(QVariant(0))));
+@@ -1358,6 +1381,26 @@ void AtSpiAdaptor::registerApplication()
+     delete registry;
+ }
+ 
++namespace {
++QString accessibleIdForAccessible(QAccessibleInterface *accessible)
++{
++    QString result;
++    while (accessible) {
++        if (!result.isEmpty())
++            result.prepend(QLatin1Char('.'));
++        if (auto obj = accessible->object()) {
++            const QString name = obj->objectName();
++            if (!name.isEmpty())
++                result.prepend(name);
++            else
++                result.prepend(QString::fromUtf8(obj->metaObject()->className()));
++        }
++        accessible = accessible->parent();
++    }
++    return result;
++}
++} // namespace
++
+ // Accessible
+ bool AtSpiAdaptor::accessibleInterface(QAccessibleInterface *interface, const QString &function, const QDBusMessage &message, const QDBusConnection &connection)
+ {
+@@ -1441,6 +1484,9 @@ bool AtSpiAdaptor::accessibleInterface(QAccessibleInterface *interface, const QS
+             children << ref;
+         }
+         connection.send(message.createReply(QVariant::fromValue(children)));
++    } else if (function == QLatin1String("GetAccessibleId")) {
++        sendReply(connection, message,
++                  QVariant::fromValue(QDBusVariant(accessibleIdForAccessible(interface))));
+     } else {
+         qCDebug(lcAccessibilityAtspi) << "WARNING: AtSpiAdaptor::accessibleInterface does not implement " << function << message.path();
+         return false;
+diff --git a/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp b/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
+index 45ddc8e496..cc734abc63 100644
+--- a/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
++++ b/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
+@@ -69,6 +69,21 @@ QT_BEGIN_NAMESPACE
+ DBusConnection::DBusConnection(QObject *parent)
+     : QObject(parent), m_a11yConnection(QString()), m_enabled(false)
+ {
++    // If the bus is explicitly set via env var it overrides everything else.
++    QByteArray addressEnv = qgetenv("AT_SPI_BUS_ADDRESS");
++    if (!addressEnv.isEmpty()) {
++        // Only connect on next loop run, connections to our enabled signal are
++        // only established after the ctor returns.
++        QMetaObject::invokeMethod(
++                this,
++                [this, addressEnv] {
++                    m_enabled = true;
++                    connectA11yBus(QString::fromLocal8Bit(addressEnv));
++                },
++                Qt::QueuedConnection);
++        return;
++    }
++
+     // Start monitoring if "org.a11y.Bus" is registered as DBus service.
+     QDBusConnection c = QDBusConnection::sessionBus();
+     if (!c.isConnected()) {
+diff --git a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
+index 1a3cab275d..2abe039126 100644
+--- a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
++++ b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
+@@ -51,6 +51,9 @@
+ #include <QtCore/QStandardPaths>
+ #include <QtCore/QUrl>
+ 
++#include <QtGui/QGuiApplication>
++#include <QtGui/QWindow>
++
+ #if QT_CONFIG(dbus)
+ // These QtCore includes are needed for xdg-desktop-portal support
+ #include <QtCore/private/qcore_unix_p.h>
+@@ -58,6 +61,8 @@
+ #include <QtCore/QFileInfo>
+ #include <QtCore/QUrlQuery>
+ 
++#include <QtGui/QColor>
++
+ #include <QtDBus/QDBusConnection>
+ #include <QtDBus/QDBusMessage>
+ #include <QtDBus/QDBusPendingCall>
+@@ -142,6 +147,8 @@ static inline bool detectWebBrowser(const QByteArray &desktop,
+     }
+ 
+     if (desktop == QByteArray("KDE")) {
++        if (checkExecutable(QStringLiteral("kde-open5"), browser))
++            return true;
+         // Konqueror launcher
+         if (checkExecutable(QStringLiteral("kfmclient"), browser)) {
+             browser->append(QLatin1String(" exec"));
+@@ -296,8 +303,135 @@ static inline QDBusMessage xdgDesktopPortalSendEmail(const QUrl &url)
+ 
+     return QDBusConnection::sessionBus().call(message);
+ }
++
++namespace {
++struct XDGDesktopColor
++{
++    double r = 0;
++    double g = 0;
++    double b = 0;
++
++    QColor toQColor() const
++    {
++        constexpr auto rgbMax = 255;
++        return { static_cast<int>(r * rgbMax), static_cast<int>(g * rgbMax),
++                 static_cast<int>(b * rgbMax) };
++    }
++};
++
++const QDBusArgument &operator>>(const QDBusArgument &argument, XDGDesktopColor &myStruct)
++{
++    argument.beginStructure();
++    argument >> myStruct.r >> myStruct.g >> myStruct.b;
++    argument.endStructure();
++    return argument;
++}
++
++class XdgDesktopPortalColorPicker : public QPlatformServiceColorPicker
++{
++    Q_OBJECT
++public:
++    XdgDesktopPortalColorPicker(const QString &parentWindowId, QWindow *parent)
++        : QPlatformServiceColorPicker(parent), m_parentWindowId(parentWindowId)
++    {
++    }
++
++    void pickColor() override
++    {
++        // DBus signature:
++        // PickColor (IN   s      parent_window,
++        //            IN   a{sv}  options
++        //            OUT  o      handle)
++        // Options:
++        // handle_token (s) -  A string that will be used as the last element of the @handle.
++
++        QDBusMessage message = QDBusMessage::createMethodCall(
++                QStringLiteral("org.freedesktop.portal.Desktop"), QStringLiteral("/org/freedesktop/portal/desktop"),
++                QStringLiteral("org.freedesktop.portal.Screenshot"), QStringLiteral("PickColor"));
++        message << m_parentWindowId << QVariantMap();
++
++        QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
++        auto watcher = new QDBusPendingCallWatcher(pendingCall, this);
++        connect(watcher, &QDBusPendingCallWatcher::finished, this,
++                [this](QDBusPendingCallWatcher *watcher) {
++                    watcher->deleteLater();
++                    QDBusPendingReply<QDBusObjectPath> reply = *watcher;
++                    if (reply.isError()) {
++                        qWarning("DBus call to pick color failed: %s",
++                                 qPrintable(reply.error().message()));
++                        Q_EMIT colorPicked({});
++                    } else {
++                        QDBusConnection::sessionBus().connect(
++                                QStringLiteral("org.freedesktop.portal.Desktop"), reply.value().path(),
++                                QStringLiteral("org.freedesktop.portal.Request"), QStringLiteral("Response"), this,
++                                // clang-format off
++                                SLOT(gotColorResponse(uint,QVariantMap))
++                                // clang-format on
++                        );
++                    }
++                });
++    }
++
++private Q_SLOTS:
++    void gotColorResponse(uint result, const QVariantMap &map)
++    {
++        if (result != 0)
++            return;
++        XDGDesktopColor color{};
++        map.value(QStringLiteral("color")).value<QDBusArgument>() >> color;
++        Q_EMIT colorPicked(color.toQColor());
++        deleteLater();
++    }
++
++private:
++    const QString m_parentWindowId;
++};
++} // namespace
++
+ #endif // QT_CONFIG(dbus)
+ 
++QGenericUnixServices::QGenericUnixServices()
++{
++#if QT_CONFIG(dbus)
++    if (qEnvironmentVariableIntValue("QT_NO_XDG_DESKTOP_PORTAL") > 0) {
++        return;
++    }
++    QDBusMessage message = QDBusMessage::createMethodCall(
++            QStringLiteral("org.freedesktop.portal.Desktop"), QStringLiteral("/org/freedesktop/portal/desktop"),
++            QStringLiteral("org.freedesktop.DBus.Properties"), QStringLiteral("Get"));
++    message << QStringLiteral("org.freedesktop.portal.Screenshot")
++            << QStringLiteral("version");
++
++    QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
++    auto watcher = new QDBusPendingCallWatcher(pendingCall);
++    QObject::connect(watcher, &QDBusPendingCallWatcher::finished, watcher,
++                     [this](QDBusPendingCallWatcher *watcher) {
++                         watcher->deleteLater();
++                         QDBusPendingReply<QVariant> reply = *watcher;
++                         if (!reply.isError() && reply.value().toUInt() >= 2)
++                             m_hasScreenshotPortalWithColorPicking = true;
++                     });
++
++#endif
++}
++
++QPlatformServiceColorPicker *QGenericUnixServices::colorPicker(QWindow *parent)
++{
++#if QT_CONFIG(dbus)
++    // Make double sure that we are in a wayland environment. In particular check
++    // WAYLAND_DISPLAY so also XWayland apps benefit from portal-based color picking.
++    // Outside wayland we'll rather rely on other means than the XDG desktop portal.
++    if (!qEnvironmentVariableIsEmpty("WAYLAND_DISPLAY")
++        || QGuiApplication::platformName().startsWith(QLatin1String("wayland"))) {
++        return new XdgDesktopPortalColorPicker(portalWindowIdentifier(parent), parent);
++    }
++    return nullptr;
++#else
++    Q_UNUSED(parent);
++    return nullptr;
++#endif
++}
++
+ QByteArray QGenericUnixServices::desktopEnvironment() const
+ {
+     static const QByteArray result = detectDesktopEnvironment();
+@@ -352,6 +486,8 @@ bool QGenericUnixServices::openDocument(const QUrl &url)
+ }
+ 
+ #else
++QGenericUnixServices::QGenericUnixServices() = default;
++
+ QByteArray QGenericUnixServices::desktopEnvironment() const
+ {
+     return QByteArrayLiteral("UNKNOWN");
+@@ -371,6 +507,30 @@ bool QGenericUnixServices::openDocument(const QUrl &url)
+     return false;
+ }
+ 
++QPlatformServiceColorPicker *QGenericUnixServices::colorPicker(QWindow *parent)
++{
++    Q_UNUSED(parent);
++    return nullptr;
++}
++
+ #endif // QT_NO_MULTIPROCESS
+ 
++QString QGenericUnixServices::portalWindowIdentifier(QWindow *window)
++{
++    if (QGuiApplication::platformName() == QLatin1String("xcb"))
++        return QStringLiteral("x11:") + QString::number(window->winId(), 16);
++    return QString();
++}
++
++bool QGenericUnixServices::hasCapability(Capability capability) const
++{
++    switch (capability) {
++    case Capability::ColorPicking:
++        return m_hasScreenshotPortalWithColorPicking;
++    }
++    return false;
++}
++
+ QT_END_NAMESPACE
++
++#include "qgenericunixservices.moc"
+diff --git a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
+index 8ac3de6f03..30924e64bd 100644
+--- a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
++++ b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
+@@ -59,16 +59,21 @@ QT_BEGIN_NAMESPACE
+ class QGenericUnixServices : public QPlatformServices
+ {
+ public:
+-    QGenericUnixServices() {}
++    QGenericUnixServices();
+ 
+     QByteArray desktopEnvironment() const override;
+ 
++    bool hasCapability(Capability capability) const override;
+     bool openUrl(const QUrl &url) override;
+     bool openDocument(const QUrl &url) override;
++    QPlatformServiceColorPicker *colorPicker(QWindow *parent = nullptr) override;
++
++    virtual QString portalWindowIdentifier(QWindow *window);
+ 
+ private:
+     QString m_webBrowser;
+     QString m_documentLauncher;
++    bool m_hasScreenshotPortalWithColorPicking = false;
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
+index 09470bccc6..cc7c7d4d8a 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
+@@ -69,6 +69,7 @@ const QString MenuBarPath = QLatin1String("/MenuBar");
+ */
+ QDBusMenuConnection::QDBusMenuConnection(QObject *parent, const QString &serviceName)
+     : QObject(parent)
++    , m_serviceName(serviceName)
+     , m_connection(serviceName.isNull() ? QDBusConnection::sessionBus()
+                                         : QDBusConnection::connectToBus(QDBusConnection::SessionBus, serviceName))
+     , m_dbusWatcher(new QDBusServiceWatcher(StatusNotifierWatcherService, m_connection, QDBusServiceWatcher::WatchForRegistration, this))
+@@ -83,6 +84,12 @@ QDBusMenuConnection::QDBusMenuConnection(QObject *parent, const QString &service
+ #endif
+ }
+ 
++QDBusMenuConnection::~QDBusMenuConnection()
++{
++  if (!m_serviceName.isEmpty() && m_connection.isConnected())
++      QDBusConnection::disconnectFromBus(m_serviceName);
++}
++
+ void QDBusMenuConnection::dbusError(const QDBusError &error)
+ {
+     qWarning() << "QDBusTrayIcon encountered a D-Bus error:" << error;
+@@ -105,13 +112,7 @@ void QDBusMenuConnection::unregisterTrayIconMenu(QDBusTrayIcon *item)
+ 
+ bool QDBusMenuConnection::registerTrayIcon(QDBusTrayIcon *item)
+ {
+-    bool success = connection().registerService(item->instanceId());
+-    if (!success) {
+-        qWarning() << "failed to register service" << item->instanceId();
+-        return false;
+-    }
+-
+-    success = connection().registerObject(StatusNotifierItemPath, item);
++    bool success = connection().registerObject(StatusNotifierItemPath, item);
+     if (!success) {
+         unregisterTrayIcon(item);
+         qWarning() << "failed to register" << item->instanceId() << StatusNotifierItemPath;
+@@ -126,21 +127,18 @@ bool QDBusMenuConnection::registerTrayIcon(QDBusTrayIcon *item)
+ 
+ bool QDBusMenuConnection::registerTrayIconWithWatcher(QDBusTrayIcon *item)
+ {
++    Q_UNUSED(item);
+     QDBusMessage registerMethod = QDBusMessage::createMethodCall(
+                 StatusNotifierWatcherService, StatusNotifierWatcherPath, StatusNotifierWatcherService,
+                 QLatin1String("RegisterStatusNotifierItem"));
+-    registerMethod.setArguments(QVariantList() << item->instanceId());
++    registerMethod.setArguments(QVariantList() << m_connection.baseService());
+     return m_connection.callWithCallback(registerMethod, this, SIGNAL(trayIconRegistered()), SLOT(dbusError(QDBusError)));
+ }
+ 
+-bool QDBusMenuConnection::unregisterTrayIcon(QDBusTrayIcon *item)
++void QDBusMenuConnection::unregisterTrayIcon(QDBusTrayIcon *item)
+ {
+     unregisterTrayIconMenu(item);
+     connection().unregisterObject(StatusNotifierItemPath);
+-    bool success = connection().unregisterService(item->instanceId());
+-    if (!success)
+-        qWarning() << "failed to unregister service" << item->instanceId();
+-    return success;
+ }
+ #endif // QT_NO_SYSTEMTRAYICON
+ 
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
+index f484795fbb..97bdfabb85 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
++++ b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
+@@ -70,6 +70,7 @@ class QDBusMenuConnection : public QObject
+ 
+ public:
+     QDBusMenuConnection(QObject *parent = nullptr, const QString &serviceName = QString());
++    ~QDBusMenuConnection();
+     QDBusConnection connection() const { return m_connection; }
+     QDBusServiceWatcher *dbusWatcher() const { return m_dbusWatcher; }
+     bool isStatusNotifierHostRegistered() const { return m_statusNotifierHostRegistered; }
+@@ -78,7 +79,7 @@ public:
+     void unregisterTrayIconMenu(QDBusTrayIcon *item);
+     bool registerTrayIcon(QDBusTrayIcon *item);
+     bool registerTrayIconWithWatcher(QDBusTrayIcon *item);
+-    bool unregisterTrayIcon(QDBusTrayIcon *item);
++    void unregisterTrayIcon(QDBusTrayIcon *item);
+ #endif // QT_NO_SYSTEMTRAYICON
+ 
+ Q_SIGNALS:
+@@ -90,6 +91,7 @@ private Q_SLOTS:
+     void dbusError(const QDBusError &error);
+ 
+ private:
++    QString m_serviceName;
+     QDBusConnection m_connection;
+     QDBusServiceWatcher *m_dbusWatcher;
+     bool m_statusNotifierHostRegistered;
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp b/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
+index bede70975a..76bfec5e5a 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
+@@ -71,8 +71,12 @@ Q_LOGGING_CATEGORY(qLcTray, "qt.qpa.tray")
+ static QString iconTempPath()
+ {
+     QString tempPath = QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation);
+-    if (!tempPath.isEmpty())
++    if (!tempPath.isEmpty()) {
++        QString flatpakId = qEnvironmentVariable("FLATPAK_ID");
++        if (!flatpakId.isEmpty() && QFileInfo::exists(QLatin1String("/.flatpak-info")))
++            tempPath += QLatin1String("/app/") + flatpakId;
+         return tempPath;
++    }
+ 
+     tempPath = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation);
+ 
+diff --git a/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+index cb1b39db64..6e01af052c 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+@@ -755,6 +755,9 @@ QVariant QGnomeTheme::themeHint(QPlatformTheme::ThemeHint hint) const
+         return QVariant(QChar(0x2022));
+     case QPlatformTheme::UiEffects:
+         return QVariant(int(HoverEffect));
++    case QPlatformTheme::ButtonPressKeys:
++        return QVariant::fromValue(
++                QList<Qt::Key>({ Qt::Key_Space, Qt::Key_Return, Qt::Key_Enter, Qt::Key_Select }));
+     default:
+         break;
+     }
+diff --git a/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp b/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
+index 98e05195ee..1e92f43dec 100644
+--- a/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
++++ b/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
+@@ -343,8 +343,7 @@ void QEglFSCursor::paintOnScreen()
+     // screens are siblings of each other. When not enabled, the sibling list
+     // only contains m_screen itself.
+     for (QPlatformScreen *screen : m_screen->virtualSiblings()) {
+-        if (screen->geometry().contains(cr.topLeft().toPoint() + m_cursor.hotSpot)
+-            && QOpenGLContext::currentContext()->screen() == screen->screen())
++        if (screen->geometry().contains(cr.topLeft().toPoint() + m_cursor.hotSpot))
+         {
+             cr.translate(-screen->geometry().topLeft());
+             const QSize screenSize = screen->geometry().size();
+@@ -468,11 +467,12 @@ void QEglFSCursor::draw(const QRectF &r)
+ {
+     StateSaver stateSaver;
+ 
+-    QEglFSCursorData &gfx = static_cast<QEglFSContext*>(QOpenGLContext::currentContext()->handle())->cursorData;
+-    if (!gfx.program) {
+-        // one time initialization
++    // one time initialization
++    if (!QOpenGLFunctions::d_ptr)
+         initializeOpenGLFunctions();
+ 
++    QEglFSCursorData &gfx = static_cast<QEglFSContext*>(QOpenGLContext::currentContext()->handle())->cursorData;
++    if (!gfx.program) {
+         createShaderPrograms();
+ 
+         if (!gfx.atlasTexture) {
+diff --git a/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp b/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
+index 645a0ae2e9..3e0e406f1a 100644
+--- a/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
++++ b/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
+@@ -179,7 +179,7 @@ void QEglFSKmsEventReader::create(QEglFSKmsDevice *device)
+ 
+     m_device = device;
+ 
+-    qCDebug(qLcEglfsKmsDebug, "Initalizing event reader for device %p fd %d",
++    qCDebug(qLcEglfsKmsDebug, "Initializing event reader for device %p fd %d",
+             m_device, m_device->fd());
+ 
+     m_thread = new QEglFSKmsEventReaderThread(m_device->fd());
+diff --git a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
+index 141fb68a23..d4294d425a 100644
+--- a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
++++ b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
+@@ -122,11 +122,13 @@ QOffscreenIntegration::QOffscreenIntegration()
+ #endif
+     m_services.reset(new QPlatformServices);
+ 
+-    QWindowSystemInterface::handleScreenAdded(new QOffscreenScreen);
++    m_screen = new QOffscreenScreen;
++    QWindowSystemInterface::handleScreenAdded(m_screen);
+ }
+ 
+ QOffscreenIntegration::~QOffscreenIntegration()
+ {
++    QWindowSystemInterface::handleScreenRemoved(m_screen);
+ }
+ 
+ void QOffscreenIntegration::initialize()
+diff --git a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
+index 0ea90f6c2f..fe00fde07c 100644
+--- a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
++++ b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
+@@ -84,6 +84,7 @@ protected:
+ #endif
+     QScopedPointer<QPlatformInputContext> m_inputContext;
+     QScopedPointer<QPlatformServices> m_services;
++    QPlatformScreen *m_screen;
+     mutable QScopedPointer<QPlatformNativeInterface> m_nativeInterface;
+ };
+ 
+diff --git a/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp b/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
+index 6fa5a8a2b3..1f49f0aefd 100644
+--- a/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
++++ b/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
+@@ -48,6 +48,7 @@
+ #include <qpa/qplatformnativeinterface.h>
+ #include <QtPlatformHeaders/qwglnativecontext.h>
+ 
++#include <private/qsystemlibrary_p.h>
+ #include <algorithm>
+ 
+ #include <wingdi.h>
+@@ -162,19 +163,25 @@ QFunctionPointer QWindowsOpengl32DLL::resolve(const char *name)
+ 
+ bool QWindowsOpengl32DLL::init(bool softwareRendering)
+ {
+-    const QByteArray opengl32 = QByteArrayLiteral("opengl32.dll");
+-    const QByteArray swopengl = QByteArrayLiteral("opengl32sw.dll");
++    const QByteArray opengl32 = QByteArrayLiteral("opengl32");
++    const QByteArray swopengl = QByteArrayLiteral("opengl32sw");
++    bool useSystemLib = false;
+ 
+     QByteArray openglDll = qgetenv("QT_OPENGL_DLL");
+-    if (openglDll.isEmpty())
++    if (openglDll.isEmpty()) {
+         openglDll = softwareRendering ? swopengl : opengl32;
++        useSystemLib = !softwareRendering;
++    }
+ 
+     openglDll = openglDll.toLower();
+     m_nonOpengl32 = openglDll != opengl32;
+ 
+     qCDebug(lcQpaGl) << "Qt: Using WGL and OpenGL from" << openglDll;
+ 
+-    m_lib = ::LoadLibraryA(openglDll.constData());
++    if (useSystemLib)
++        m_lib = QSystemLibrary::load((wchar_t*)(QString::fromLatin1(openglDll).utf16()));
++    else
++        m_lib = LoadLibraryA(openglDll.constData());
+     if (!m_lib) {
+         qErrnoWarning(::GetLastError(), "Failed to load %s", openglDll.constData());
+         return false;
+@@ -184,7 +191,7 @@ bool QWindowsOpengl32DLL::init(bool softwareRendering)
+         // Load opengl32.dll always. GDI functions like ChoosePixelFormat do
+         // GetModuleHandle for opengl32.dll and behave differently (and call back into
+         // opengl32) when the module is present. This is fine for dummy contexts and windows.
+-        ::LoadLibraryA("opengl32.dll");
++        QSystemLibrary::load(L"opengl32");
+     }
+ 
+     wglCreateContext = reinterpret_cast<HGLRC (WINAPI *)(HDC)>(resolve("wglCreateContext"));
+diff --git a/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp b/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
+index d7d186e804..9eb4011bf2 100644
+--- a/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
++++ b/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
+@@ -49,6 +49,7 @@
+ #include <QtCore/qstandardpaths.h>
+ #include <QtCore/qlibraryinfo.h>
+ #include <QtCore/qhash.h>
++#include <private/qsystemlibrary_p.h>
+ 
+ #ifndef QT_NO_OPENGL
+ #include <private/qopengl_p.h>
+@@ -396,7 +397,7 @@ bool QWindowsOpenGLTester::testDesktopGL()
+ 
+     // Test #1: Load opengl32.dll and try to resolve an OpenGL 2 function.
+     // This will typically fail on systems that do not have a real OpenGL driver.
+-    lib = LoadLibraryA("opengl32.dll");
++    lib = QSystemLibrary::load(L"opengl32");
+     if (lib) {
+         CreateContext = reinterpret_cast<CreateContextType>(
+             reinterpret_cast<QFunctionPointer>(::GetProcAddress(lib, "wglCreateContext")));
+diff --git a/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp b/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
+index 1afa00cfc9..118af6ce73 100644
+--- a/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
++++ b/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
+@@ -41,6 +41,7 @@
+ 
+ #include <QRect>
+ #include <QList>
++#include <QMap>
+ #include <QDebug>
+ 
+ #include <qmath.h>
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp b/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
+index 9e2a37a6a1..e6e175a118 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
+@@ -488,12 +488,12 @@ void QXcbConnection::printXcbError(const char *message, xcb_generic_error_t *err
+     uint clamped_error_code = qMin<uint>(error->error_code, (sizeof(xcb_errors) / sizeof(xcb_errors[0])) - 1);
+     uint clamped_major_code = qMin<uint>(error->major_code, (sizeof(xcb_protocol_request_codes) / sizeof(xcb_protocol_request_codes[0])) - 1);
+ 
+-    qCWarning(lcQpaXcb, "%s: %d (%s), sequence: %d, resource id: %d, major code: %d (%s), minor code: %d",
+-             message,
+-             int(error->error_code), xcb_errors[clamped_error_code],
+-             int(error->sequence), int(error->resource_id),
+-             int(error->major_code), xcb_protocol_request_codes[clamped_major_code],
+-             int(error->minor_code));
++    qCDebug(lcQpaXcb, "%s: %d (%s), sequence: %d, resource id: %d, major code: %d (%s), minor code: %d",
++            message,
++            int(error->error_code), xcb_errors[clamped_error_code],
++            int(error->sequence), int(error->resource_id),
++            int(error->major_code), xcb_protocol_request_codes[clamped_major_code],
++            int(error->minor_code));
+ }
+ 
+ static Qt::MouseButtons translateMouseButtons(int s)
+@@ -702,6 +702,8 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
+             QXcbVirtualDesktop *virtualDesktop = virtualDesktopForRootWindow(propertyNotify->window);
+             if (virtualDesktop)
+                 virtualDesktop->updateWorkArea();
++        } else if (propertyNotify->atom == atom(QXcbAtom::_NET_SUPPORTED)) {
++            m_wmSupport->updateNetWMAtoms();
+         } else {
+             HANDLE_PLATFORM_WINDOW_EVENT(xcb_property_notify_event_t, window, handlePropertyNotifyEvent);
+         }
+@@ -750,7 +752,7 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
+                 case XCB_XKB_NEW_KEYBOARD_NOTIFY: {
+                     xcb_xkb_new_keyboard_notify_event_t *ev = &xkb_event->new_keyboard_notify;
+                     if (ev->changed & XCB_XKB_NKN_DETAIL_KEYCODES)
+-                        m_keyboard->updateKeymap(ev);
++                        m_keyboard->updateKeymap();
+                     break;
+                 }
+                 default:
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp b/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
+index 76869ced60..02d2eebb56 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
+@@ -274,8 +274,7 @@ QPlatformWindow *QXcbIntegration::createForeignWindow(QWindow *window, WId nativ
+ #ifndef QT_NO_OPENGL
+ QPlatformOpenGLContext *QXcbIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
+ {
+-    QXcbScreen *screen = static_cast<QXcbScreen *>(context->screen()->handle());
+-    QXcbGlIntegration *glIntegration = screen->connection()->glIntegration();
++    QXcbGlIntegration *glIntegration = defaultConnection()->glIntegration();
+     if (!glIntegration) {
+         qWarning("QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled");
+         return nullptr;
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+index efecd7e2d1..e8286381a2 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+@@ -365,17 +365,6 @@ void QXcbKeyboard::updateKeymap(xcb_mapping_notify_event_t *event)
+     updateKeymap();
+ }
+ 
+-void QXcbKeyboard::updateKeymap(xcb_xkb_new_keyboard_notify_event_t *event)
+-{
+-    if (!event)
+-        return;
+-
+-    if (event->deviceID != event->oldDeviceID)
+-        m_config = false;
+-
+-    updateKeymap();
+-}
+-
+ void QXcbKeyboard::updateKeymap()
+ {
+     KeysymModifierMap keysymMods;
+@@ -383,6 +372,8 @@ void QXcbKeyboard::updateKeymap()
+         keysymMods = keysymsToModifiers();
+     updateModifiers(keysymMods);
+ 
++    m_config = true;
++
+     if (!m_xkbContext) {
+         m_xkbContext.reset(xkb_context_new(XKB_CONTEXT_NO_DEFAULT_INCLUDES));
+         if (!m_xkbContext) {
+@@ -398,13 +389,8 @@ void QXcbKeyboard::updateKeymap()
+     if (connection()->hasXKB()) {
+         m_xkbKeymap.reset(xkb_x11_keymap_new_from_device(m_xkbContext.get(), xcb_connection(),
+                                                          core_device_id, XKB_KEYMAP_COMPILE_NO_FLAGS));
+-        if (m_xkbKeymap) {
+-            if (m_config)
+-                m_xkbState.reset(xkb_state_new(m_xkbKeymap.get()));
+-            else
+-                m_xkbState.reset(xkb_x11_state_new_from_device(m_xkbKeymap.get(), xcb_connection(), core_device_id));
+-
+-        }
++        if (m_xkbKeymap)
++            m_xkbState.reset(xkb_x11_state_new_from_device(m_xkbKeymap.get(), xcb_connection(), core_device_id));
+     } else {
+         m_xkbKeymap.reset(keymapFromCore(keysymMods));
+         if (m_xkbKeymap)
+@@ -425,8 +411,6 @@ void QXcbKeyboard::updateKeymap()
+     updateXKBMods();
+ 
+     QXkbCommon::verifyHasLatinLayout(m_xkbKeymap.get());
+-
+-    m_config = true;
+ }
+ 
+ QList<int> QXcbKeyboard::possibleKeys(const QKeyEvent *event) const
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
+index b652c85fe3..0ee08aeff2 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
++++ b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
+@@ -69,7 +69,6 @@ public:
+ 
+     Qt::KeyboardModifiers translateModifiers(int s) const;
+     void updateKeymap(xcb_mapping_notify_event_t *event);
+-    void updateKeymap(xcb_xkb_new_keyboard_notify_event_t *event);
+     void updateKeymap();
+     QList<int> possibleKeys(const QKeyEvent *event) const;
+ 
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp b/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
+index ffda7b6a57..863e961f4c 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
+@@ -564,11 +564,6 @@ void QXcbWindow::setGeometry(const QRect &rect)
+ {
+     QPlatformWindow::setGeometry(rect);
+ 
+-    if (shouldDeferTask(Task::SetGeometry)) {
+-        m_deferredGeometry = rect;
+-        return;
+-    }
+-
+     propagateSizeHints();
+ 
+     QXcbScreen *currentScreen = xcbScreen();
+@@ -693,9 +688,6 @@ void QXcbWindow::setVisible(bool visible)
+ 
+ void QXcbWindow::show()
+ {
+-    if (shouldDeferTask(Task::Map))
+-        return;
+-
+     if (window()->isTopLevel()) {
+ 
+         // update WM_NORMAL_HINTS
+@@ -706,7 +698,7 @@ void QXcbWindow::show()
+         if (isTransient(window())) {
+             const QWindow *tp = window()->transientParent();
+             if (tp && tp->handle())
+-                transientXcbParent = static_cast<const QXcbWindow *>(tp->handle())->winId();
++                transientXcbParent = tp->handle()->winId();
+             // Default to client leader if there is no transient parent, else modal dialogs can
+             // be hidden by their parents.
+             if (!transientXcbParent)
+@@ -746,10 +738,6 @@ void QXcbWindow::show()
+ 
+ void QXcbWindow::hide()
+ {
+-    if (shouldDeferTask(Task::Unmap))
+-        return;
+-
+-    m_wmStateValid = false;
+     xcb_unmap_window(xcb_connection(), m_window);
+ 
+     // send synthetic UnmapNotify event according to icccm 4.1.4
+@@ -909,9 +897,6 @@ QXcbWindow::NetWmStates QXcbWindow::netWmStates()
+ 
+ void QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
+ {
+-    if (shouldDeferTask(Task::SetWindowFlags))
+-        return;
+-
+     Qt::WindowType type = static_cast<Qt::WindowType>(int(flags & Qt::WindowType_Mask));
+ 
+     if (type == Qt::ToolTip)
+@@ -941,8 +926,6 @@ void QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
+ 
+     setTransparentForMouseEvents(flags & Qt::WindowTransparentForInput);
+     updateDoesNotAcceptFocus(flags & Qt::WindowDoesNotAcceptFocus);
+-
+-    m_isWmManagedWindow = !(flags & Qt::X11BypassWindowManagerHint);
+ }
+ 
+ void QXcbWindow::setMotifWmHints(Qt::WindowFlags flags)
+@@ -1142,9 +1125,6 @@ void QXcbWindow::setWindowState(Qt::WindowStates state)
+     if (state == m_windowState)
+         return;
+ 
+-    if (shouldDeferTask(Task::SetWindowState))
+-        return;
+-
+     // unset old state
+     if (m_windowState & Qt::WindowMinimized)
+         xcb_map_window(xcb_connection(), m_window);
+@@ -1350,6 +1330,12 @@ void QXcbWindow::setWindowIcon(const QIcon &icon)
+     }
+ 
+     if (!icon_data.isEmpty()) {
++        // Ignore icon exceeding maximum xcb request length
++        if (icon_data.size() > xcb_get_maximum_request_length(xcb_connection())) {
++            qWarning("Ignoring window icon: Size %llu exceeds maximum xcb request length %u.",
++                     icon_data.size(), xcb_get_maximum_request_length(xcb_connection()));
++            return;
++        }
+         xcb_change_property(xcb_connection(),
+                             XCB_PROP_MODE_REPLACE,
+                             m_window,
+@@ -1639,7 +1625,7 @@ void QXcbWindow::setWmWindowType(QXcbWindowFunctions::WmWindowTypes types, Qt::W
+         break;
+     }
+ 
+-    if ((flags & Qt::FramelessWindowHint) && !(type & QXcbWindowFunctions::KdeOverride)) {
++    if ((flags & Qt::FramelessWindowHint) && !(types & QXcbWindowFunctions::KdeOverride)) {
+         // override netwm type - quick and easy for KDE noborder
+         atoms.append(atom(QXcbAtom::_KDE_NET_WM_WINDOW_TYPE_OVERRIDE));
+     }
+@@ -1894,10 +1880,6 @@ void QXcbWindow::handleUnmapNotifyEvent(const xcb_unmap_notify_event_t *event)
+     if (event->window == m_window) {
+         m_mapped = false;
+         QWindowSystemInterface::handleExposeEvent(window(), QRegion());
+-        if (!m_isWmManagedWindow || parent()) {
+-            m_wmStateValid = true;
+-            handleDeferredTasks();
+-        }
+     }
+ }
+ 
+@@ -2212,98 +2194,30 @@ void QXcbWindow::handleLeaveNotifyEvent(const xcb_leave_notify_event_t *event)
+     handleLeaveNotifyEvent(event->root_x, event->root_y, event->mode, event->detail, event->time);
+ }
+ 
+-bool QXcbWindow::shouldDeferTask(Task task)
+-{
+-    if (m_wmStateValid)
+-        return false;
+-
+-    m_deferredTasks.append(task);
+-    return true;
+-}
+-
+-void QXcbWindow::handleDeferredTasks()
+-{
+-    Q_ASSERT(m_wmStateValid == true);
+-    if (m_deferredTasks.isEmpty())
+-        return;
+-
+-    bool map = false;
+-    bool unmap = false;
+-
+-    QVector<Task> tasks;
+-    for (auto taskIt = m_deferredTasks.rbegin(); taskIt != m_deferredTasks.rend(); ++taskIt) {
+-        if (!tasks.contains(*taskIt))
+-            tasks.prepend(*taskIt);
+-    }
+-
+-    for (Task task : tasks) {
+-        switch (task) {
+-        case Task::Map:
+-            map = true;
+-            unmap = false;
+-            break;
+-        case Task::Unmap:
+-            unmap = true;
+-            map = false;
+-            break;
+-        case Task::SetGeometry:
+-            setGeometry(m_deferredGeometry);
+-            break;
+-        case Task::SetWindowFlags:
+-            setWindowFlags(window()->flags());
+-            break;
+-        case Task::SetWindowState:
+-            setWindowState(window()->windowState());
+-            break;
+-        }
+-    }
+-    m_deferredTasks.clear();
+-
+-    if (map) {
+-        Q_ASSERT(unmap == false);
+-        show();
+-    }
+-    if (unmap) {
+-        Q_ASSERT(map == false);
+-        hide();
+-    }
+-}
+-
+ void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *event)
+ {
+     connection()->setTime(event->time);
+ 
+-    const bool wmStateChanged = event->atom == atom(QXcbAtom::WM_STATE);
+-    const bool netWmStateChanged = event->atom == atom(QXcbAtom::_NET_WM_STATE);
+-    if (netWmStateChanged || wmStateChanged) {
+-        if (wmStateChanged && !m_wmStateValid && m_isWmManagedWindow) {
+-            // ICCCM 4.1.4
+-            // Clients that want to re-use a client window (e.g. by mapping it again)
+-            // after withdrawing it must wait for the withdrawal to be complete before
+-            // proceeding. The preferred method for doing this is for clients to wait for
+-            // a window manager to update or remove the WM_STATE property.
+-            m_wmStateValid = true;
+-            handleDeferredTasks();
+-        }
+-        if (event->state == XCB_PROPERTY_DELETE)
++    const bool propertyDeleted = event->state == XCB_PROPERTY_DELETE;
++
++    if (event->atom == atom(QXcbAtom::_NET_WM_STATE) || event->atom == atom(QXcbAtom::WM_STATE)) {
++        if (propertyDeleted)
+             return;
+ 
+-        if (wmStateChanged) {
++        Qt::WindowStates newState = Qt::WindowNoState;
++
++        if (event->atom == atom(QXcbAtom::WM_STATE)) { // WM_STATE: Quick check for 'Minimize'.
+             auto reply = Q_XCB_REPLY(xcb_get_property, xcb_connection(),
+                                      0, m_window, atom(QXcbAtom::WM_STATE),
+                                      XCB_ATOM_ANY, 0, 1024);
+             if (reply && reply->format == 32 && reply->type == atom(QXcbAtom::WM_STATE)) {
+-                auto data = static_cast<const quint32 *>(xcb_get_property_value(reply.get()));
+-                if (reply->length != 0) {
+-                    const bool changedToWithdrawn = data[0] == XCB_ICCCM_WM_STATE_WITHDRAWN;
+-                    const bool changedToIconic = data[0] == XCB_ICCCM_WM_STATE_ICONIC;
+-                    m_minimized = changedToIconic || (changedToWithdrawn && m_minimized);
+-                }
++                const quint32 *data = (const quint32 *)xcb_get_property_value(reply.get());
++                if (reply->length != 0)
++                    m_minimized = (data[0] == XCB_ICCCM_WM_STATE_ICONIC
++                                   || (data[0] == XCB_ICCCM_WM_STATE_WITHDRAWN && m_minimized));
+             }
+         }
+ 
+-        // _NET_WM_STATE handling
+-        Qt::WindowStates newState = Qt::WindowNoState;
+         const NetWmStates states = netWmStates();
+         // _NET_WM_STATE_HIDDEN should be set by the Window Manager to indicate that a window would
+         // not be visible on the screen if its desktop/viewport were active and its coordinates were
+@@ -2325,6 +2239,7 @@ void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *ev
+             if ((m_windowState & Qt::WindowMinimized) && connection()->mouseGrabber() == this)
+                 connection()->setMouseGrabber(nullptr);
+         }
++        return;
+     } else if (event->atom == atom(QXcbAtom::_NET_FRAME_EXTENTS)) {
+         m_dirtyFrameMargins = true;
+     }
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbwindow.h b/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
+index 55af9279b1..6f5c1f5ed9 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
++++ b/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
+@@ -74,14 +74,6 @@ public:
+ 
+     Q_DECLARE_FLAGS(NetWmStates, NetWmState)
+ 
+-    enum Task {
+-        Map,
+-        Unmap,
+-        SetGeometry,
+-        SetWindowFlags,
+-        SetWindowState
+-    };
+-
+     QXcbWindow(QWindow *window);
+     ~QXcbWindow();
+ 
+@@ -151,9 +143,6 @@ public:
+ 
+     QXcbWindow *toWindow() override;
+ 
+-    bool shouldDeferTask(Task task);
+-    void handleDeferredTasks();
+-
+     void handleMouseEvent(xcb_timestamp_t time, const QPoint &local, const QPoint &global,
+                           Qt::KeyboardModifiers modifiers, QEvent::Type type, Qt::MouseEventSource source);
+ 
+@@ -292,11 +281,6 @@ protected:
+     int m_swapInterval = -1;
+ 
+     qreal m_sizeHintsScaleFactor = 1.0;
+-
+-    bool m_wmStateValid = true;
+-    QVector<Task> m_deferredTasks;
+-    bool m_isWmManagedWindow = true;
+-    QRect m_deferredGeometry;
+ };
+ 
+ class QXcbForeignWindow : public QXcbWindow
+diff --git a/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp b/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
+index d9d117faeb..640b49daa0 100644
+--- a/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
++++ b/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
+@@ -85,6 +85,7 @@ QGtk3MenuItem::QGtk3MenuItem()
+       m_checkable(false),
+       m_checked(false),
+       m_enabled(true),
++      m_exclusive(false),
+       m_underline(false),
+       m_invalid(true),
+       m_menu(nullptr),
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
+index 0048bbc1e6..396e7f6d1c 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
+@@ -102,15 +102,12 @@ const QDBusArgument &operator >>(const QDBusArgument &arg, QXdgDesktopPortalFile
+ class QXdgDesktopPortalFileDialogPrivate
+ {
+ public:
+-    QXdgDesktopPortalFileDialogPrivate(QPlatformFileDialogHelper *nativeFileDialog)
++    QXdgDesktopPortalFileDialogPrivate(QPlatformFileDialogHelper *nativeFileDialog, uint fileChooserPortalVersion)
+         : nativeFileDialog(nativeFileDialog)
++        , fileChooserPortalVersion(fileChooserPortalVersion)
+     { }
+ 
+-    WId winId = 0;
+-    bool directoryMode = false;
+-    bool modal = false;
+-    bool multipleFiles = false;
+-    bool saveFile = false;
++    QEventLoop loop;
+     QString acceptLabel;
+     QString directory;
+     QString title;
+@@ -121,19 +118,27 @@ public:
+     QString selectedMimeTypeFilter;
+     QString selectedNameFilter;
+     QStringList selectedFiles;
+-    QPlatformFileDialogHelper *nativeFileDialog = nullptr;
++    std::unique_ptr<QPlatformFileDialogHelper> nativeFileDialog;
++    uint fileChooserPortalVersion = 0;
++    bool failedToOpen = false;
++    bool directoryMode = false;
++    bool multipleFiles = false;
++    bool saveFile = false;
+ };
+ 
+-QXdgDesktopPortalFileDialog::QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog)
++QXdgDesktopPortalFileDialog::QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog, uint fileChooserPortalVersion)
+     : QPlatformFileDialogHelper()
+-    , d_ptr(new QXdgDesktopPortalFileDialogPrivate(nativeFileDialog))
++    , d_ptr(new QXdgDesktopPortalFileDialogPrivate(nativeFileDialog, fileChooserPortalVersion))
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+     if (d->nativeFileDialog) {
+-        connect(d->nativeFileDialog, SIGNAL(accept()), this, SIGNAL(accept()));
+-        connect(d->nativeFileDialog, SIGNAL(reject()), this, SIGNAL(reject()));
++        connect(d->nativeFileDialog.get(), SIGNAL(accept()), this, SIGNAL(accept()));
++        connect(d->nativeFileDialog.get(), SIGNAL(reject()), this, SIGNAL(reject()));
+     }
++
++    d->loop.connect(this, SIGNAL(accept()), SLOT(quit()));
++    d->loop.connect(this, SIGNAL(reject()), SLOT(quit()));
+ }
+ 
+ QXdgDesktopPortalFileDialog::~QXdgDesktopPortalFileDialog()
+@@ -177,7 +182,7 @@ void QXdgDesktopPortalFileDialog::initializeDialog()
+     setDirectory(options()->initialDirectory());
+ }
+ 
+-void QXdgDesktopPortalFileDialog::openPortal()
++void QXdgDesktopPortalFileDialog::openPortal(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent)
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+@@ -185,13 +190,13 @@ void QXdgDesktopPortalFileDialog::openPortal()
+                                                           QLatin1String("/org/freedesktop/portal/desktop"),
+                                                           QLatin1String("org.freedesktop.portal.FileChooser"),
+                                                           d->saveFile ? QLatin1String("SaveFile") : QLatin1String("OpenFile"));
+-    QString parentWindowId = QLatin1String("x11:") + QString::number(d->winId, 16);
++    QString parentWindowId = QLatin1String("x11:") + QString::number(parent ? parent->winId() : 0, 16);
+ 
+     QVariantMap options;
+     if (!d->acceptLabel.isEmpty())
+         options.insert(QLatin1String("accept_label"), d->acceptLabel);
+ 
+-    options.insert(QLatin1String("modal"), d->modal);
++    options.insert(QLatin1String("modal"), windowModality != Qt::NonModal);
+     options.insert(QLatin1String("multiple"), d->multipleFiles);
+     options.insert(QLatin1String("directory"), d->directoryMode);
+ 
+@@ -290,10 +295,18 @@ void QXdgDesktopPortalFileDialog::openPortal()
+ 
+     QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
+     QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingCall);
+-    connect(watcher, &QDBusPendingCallWatcher::finished, this, [this] (QDBusPendingCallWatcher *watcher) {
++    connect(watcher, &QDBusPendingCallWatcher::finished, this, [=] (QDBusPendingCallWatcher *watcher) {
+         QDBusPendingReply<QDBusObjectPath> reply = *watcher;
+-        if (reply.isError()) {
+-            Q_EMIT reject();
++        // Any error means the dialog is not shown and we need to fallback
++        d->failedToOpen = reply.isError();
++        if (d->failedToOpen) {
++            if (d->nativeFileDialog) {
++                d->nativeFileDialog->show(windowFlags, windowModality, parent);
++                if (d->loop.isRunning())
++                    d->nativeFileDialog->exec();
++            } else {
++                Q_EMIT reject();
++            }
+         } else {
+             QDBusConnection::sessionBus().connect(nullptr,
+                                                   reply.value().path(),
+@@ -302,6 +315,7 @@ void QXdgDesktopPortalFileDialog::openPortal()
+                                                   this,
+                                                   SLOT(gotResponse(uint,QVariantMap)));
+         }
++        watcher->deleteLater();
+     });
+ }
+ 
+@@ -326,7 +340,7 @@ QUrl QXdgDesktopPortalFileDialog::directory() const
+ {
+     Q_D(const QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog())
+         return d->nativeFileDialog->directory();
+ 
+     return d->directory;
+@@ -348,7 +362,7 @@ QList<QUrl> QXdgDesktopPortalFileDialog::selectedFiles() const
+ {
+     Q_D(const QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog())
+         return d->nativeFileDialog->selectedFiles();
+ 
+     QList<QUrl> files;
+@@ -403,16 +417,13 @@ void QXdgDesktopPortalFileDialog::exec()
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly)) {
++    if (d->nativeFileDialog && useNativeFileDialog()) {
+         d->nativeFileDialog->exec();
+         return;
+     }
+ 
+     // HACK we have to avoid returning until we emit that the dialog was accepted or rejected
+-    QEventLoop loop;
+-    loop.connect(this, SIGNAL(accept()), SLOT(quit()));
+-    loop.connect(this, SIGNAL(reject()), SLOT(quit()));
+-    loop.exec();
++    d->loop.exec();
+ }
+ 
+ void QXdgDesktopPortalFileDialog::hide()
+@@ -429,13 +440,10 @@ bool QXdgDesktopPortalFileDialog::show(Qt::WindowFlags windowFlags, Qt::WindowMo
+ 
+     initializeDialog();
+ 
+-    d->modal = windowModality != Qt::NonModal;
+-    d->winId = parent ? parent->winId() : 0;
+-
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog(OpenFallback))
+         return d->nativeFileDialog->show(windowFlags, windowModality, parent);
+ 
+-    openPortal();
++    openPortal(windowFlags, windowModality, parent);
+ 
+     return true;
+ }
+@@ -465,4 +473,21 @@ void QXdgDesktopPortalFileDialog::gotResponse(uint response, const QVariantMap &
+     }
+ }
+ 
++bool QXdgDesktopPortalFileDialog::useNativeFileDialog(QXdgDesktopPortalFileDialog::FallbackType fallbackType) const
++{
++    Q_D(const QXdgDesktopPortalFileDialog);
++
++    if (d->failedToOpen && fallbackType != OpenFallback)
++        return true;
++
++    if (d->fileChooserPortalVersion < 3) {
++        if (options()->fileMode() == QFileDialogOptions::Directory)
++            return true;
++        else if (options()->fileMode() == QFileDialogOptions::DirectoryOnly)
++            return true;
++    }
++
++    return false;
++}
++
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
+index 4f4de96ecf..65e22a5cf2 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
+@@ -51,6 +51,11 @@ class QXdgDesktopPortalFileDialog : public QPlatformFileDialogHelper
+     Q_OBJECT
+     Q_DECLARE_PRIVATE(QXdgDesktopPortalFileDialog)
+ public:
++    enum FallbackType {
++        GenericFallback,
++        OpenFallback
++    };
++
+     enum ConditionType : uint {
+         GlobalPattern = 0,
+         MimeType = 1
+@@ -69,7 +74,7 @@ public:
+     };
+     typedef QVector<Filter> FilterList;
+ 
+-    QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog = nullptr);
++    QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog = nullptr, uint fileChooserPortalVersion = 0);
+     ~QXdgDesktopPortalFileDialog();
+ 
+     bool defaultNameFilterDisables() const override;
+@@ -92,7 +97,8 @@ private Q_SLOTS:
+ 
+ private:
+     void initializeDialog();
+-    void openPortal();
++    void openPortal(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent);
++    bool useNativeFileDialog(FallbackType fallbackType = GenericFallback) const;
+ 
+     QScopedPointer<QXdgDesktopPortalFileDialogPrivate> d_ptr;
+ };
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
+index fb324afbd8..b809503122 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
+@@ -111,6 +111,7 @@ QXdgDesktopPortalTheme::QXdgDesktopPortalTheme()
+         if (reply.isValid()) {
+             d->fileChooserPortalVersion = reply.value().toUInt();
+         }
++        watcher->deleteLater();
+     });
+ }
+ 
+@@ -152,11 +153,12 @@ QPlatformDialogHelper* QXdgDesktopPortalTheme::createPlatformDialogHelper(Dialog
+ {
+     Q_D(const QXdgDesktopPortalTheme);
+ 
+-    if (type == FileDialog) {
++    if (type == FileDialog && d->fileChooserPortalVersion) {
+         // Older versions of FileChooser portal don't support opening directories, therefore we fallback
+         // to native file dialog opened inside the sandbox to open a directory.
+-        if (d->fileChooserPortalVersion < 3 && d->baseTheme->usePlatformNativeDialog(type))
+-            return new QXdgDesktopPortalFileDialog(static_cast<QPlatformFileDialogHelper*>(d->baseTheme->createPlatformDialogHelper(type)));
++        if (d->baseTheme->usePlatformNativeDialog(type))
++            return new QXdgDesktopPortalFileDialog(static_cast<QPlatformFileDialogHelper*>(d->baseTheme->createPlatformDialogHelper(type)),
++                                                   d->fileChooserPortalVersion);
+ 
+         return new QXdgDesktopPortalFileDialog;
+     }
+diff --git a/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp b/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
+index 43d5e119ad..1f9cbc4565 100644
+--- a/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
++++ b/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
+@@ -89,8 +89,10 @@ void QCupsPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &v
+         break;
+     case PPK_Duplex: {
+         QPrint::DuplexMode mode = QPrint::DuplexMode(value.toInt());
+-        if (mode != d->duplex && d->m_printDevice.supportedDuplexModes().contains(mode))
++        if (d->m_printDevice.supportedDuplexModes().contains(mode)) {
+             d->duplex = mode;
++            d->duplexRequestedExplicitly = true;
++        }
+         break;
+     }
+     case PPK_PrinterName:
+@@ -277,9 +279,12 @@ void QCupsPrintEnginePrivate::changePrinter(const QString &newPrinter)
+     m_printDevice.swap(printDevice);
+     printerName = m_printDevice.id();
+ 
+-    // Check if new printer supports current settings, otherwise us defaults
+-    if (duplex != QPrint::DuplexAuto && !m_printDevice.supportedDuplexModes().contains(duplex))
++    // in case a duplex value was explicitly set, check if new printer supports current value,
++    // otherwise use device default
++    if (!duplexRequestedExplicitly || !m_printDevice.supportedDuplexModes().contains(duplex)) {
+         duplex = m_printDevice.defaultDuplexMode();
++        duplexRequestedExplicitly = false;
++    }
+     QPrint::ColorMode colorMode = grayscale ? QPrint::GrayScale : QPrint::Color;
+     if (!m_printDevice.supportedColorModes().contains(colorMode))
+         grayscale = m_printDevice.defaultColorMode() == QPrint::GrayScale;
+diff --git a/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h b/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
+index c021b0c643..8f81fe478d 100644
+--- a/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
++++ b/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
+@@ -100,6 +100,7 @@ private:
+     QStringList cupsOptions;
+     QString cupsTempFile;
+     QPrint::DuplexMode duplex;
++    bool duplexRequestedExplicitly = false;
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp b/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
+index 67e7154fa6..40876152e5 100644
+--- a/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
++++ b/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
+@@ -817,7 +817,7 @@ bool QIBaseResultPrivate::writeArray(int column, const QList<QVariant> &list)
+     ba.resize(int(bufLen));
+ 
+     if (list.size() > arraySize) {
+-        error = QLatin1String("Array size missmatch: size of %1 is %2, size of provided list is %3");
++        error = QLatin1String("Array size mismatch: size of %1 is %2, size of provided list is %3");
+         error = error.arg(QLatin1String(sqlname)).arg(arraySize).arg(list.size());
+         q->setLastError(QSqlError(error, QLatin1String(""), QSqlError::StatementError));
+         return false;
+diff --git a/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp b/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
+index 7ca055eea2..6bc9d46755 100644
+--- a/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
++++ b/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
+@@ -223,7 +223,7 @@ public:
+     struct QMyField
+     {
+         char *outField = nullptr;
+-        MYSQL_FIELD *myField = nullptr;
++        const MYSQL_FIELD *myField = nullptr;
+         QMetaType::Type type = QMetaType::UnknownType;
+         my_bool nullIndicator = false;
+         ulong bufLength = 0ul;
+@@ -361,7 +361,7 @@ static bool qIsInteger(int t)
+ void QMYSQLResultPrivate::bindBlobs()
+ {
+     int i;
+-    MYSQL_FIELD *fieldInfo;
++    const MYSQL_FIELD *fieldInfo;
+     MYSQL_BIND *bind;
+ 
+     for(i = 0; i < fields.count(); ++i) {
+@@ -379,7 +379,6 @@ void QMYSQLResultPrivate::bindBlobs()
+ bool QMYSQLResultPrivate::bindInValues()
+ {
+     MYSQL_BIND *bind;
+-    char *field;
+     int i = 0;
+ 
+     if (!meta)
+@@ -392,35 +391,34 @@ bool QMYSQLResultPrivate::bindInValues()
+     inBinds = new MYSQL_BIND[fields.size()];
+     memset(inBinds, 0, fields.size() * sizeof(MYSQL_BIND));
+ 
+-    MYSQL_FIELD *fieldInfo;
++    const MYSQL_FIELD *fieldInfo;
+ 
+     while((fieldInfo = mysql_fetch_field(meta))) {
++        bind = &inBinds[i];
++
+         QMyField &f = fields[i];
+         f.myField = fieldInfo;
+-
++        bind->buffer_length = f.bufLength = fieldInfo->length + 1;
++        bind->buffer_type = fieldInfo->type;
+         f.type = qDecodeMYSQLType(fieldInfo->type, fieldInfo->flags);
+         if (qIsBlob(fieldInfo->type)) {
+             // the size of a blob-field is available as soon as we call
+             // mysql_stmt_store_result()
+             // after mysql_stmt_exec() in QMYSQLResult::exec()
+-            fieldInfo->length = 0;
++            bind->buffer_length = f.bufLength = 0;
+             hasBlobs = true;
+         } else if (qIsInteger(f.type)) {
+-            fieldInfo->length = 8;
++            bind->buffer_length = f.bufLength = 8;
+         } else {
+-            fieldInfo->type = MYSQL_TYPE_STRING;
++            bind->buffer_type = MYSQL_TYPE_STRING;
+         }
+-        bind = &inBinds[i];
+-        field = new char[fieldInfo->length + 1];
+-        memset(field, 0, fieldInfo->length + 1);
+ 
+-        bind->buffer_type = fieldInfo->type;
+-        bind->buffer = field;
+-        bind->buffer_length = f.bufLength = fieldInfo->length + 1;
+         bind->is_null = &f.nullIndicator;
+         bind->length = &f.bufLength;
+         bind->is_unsigned = fieldInfo->flags & UNSIGNED_FLAG ? 1 : 0;
+-        f.outField=field;
++
++        char *field = new char[bind->buffer_length + 1]{};
++        bind->buffer = f.outField = field;
+ 
+         ++i;
+     }
+@@ -1369,20 +1367,20 @@ bool QMYSQLDriver::open(const QString& db,
+     }
+ 
+ #if MYSQL_VERSION_ID >= 50007
+-    if (mysql_get_client_version() >= 50503 && mysql_get_server_version(d->mysql) >= 50503) {
+-        // force the communication to be utf8mb4 (only utf8mb4 supports 4-byte characters)
+-        mysql_set_character_set(d->mysql, "utf8mb4");
++    // force the communication to be utf8mb4 (only utf8mb4 supports 4-byte characters)
++    if (mysql_set_character_set(d->mysql, "utf8mb4")) {
++        // this failed, try forcing it to utf (BMP only)
++        if (mysql_set_character_set(d->mysql, "utf8"))
++            qWarning() << "MySQL: Unable to set the client character set to utf8.";
+ #if QT_CONFIG(textcodec)
+-        d->tc = QTextCodec::codecForName("UTF-8");
++        else
++            d->tc = codec(d->mysql);
+ #endif
+-    } else
+-    {
+-        // force the communication to be utf8
+-        mysql_set_character_set(d->mysql, "utf8");
++    }
+ #if QT_CONFIG(textcodec)
+-        d->tc = codec(d->mysql);
++    else
++        d->tc = QTextCodec::codecForName("UTF-8");
+ #endif
+-    }
+ #endif  // MYSQL_VERSION_ID >= 50007
+ 
+     d->preparedQuerysEnabled = checkPreparedQueries(d->mysql);
+diff --git a/qtbase/src/printsupport/dialogs/images/print-24.png b/qtbase/src/printsupport/dialogs/images/printer-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/print-24.png
+rename to src/printsupport/dialogs/images/printer-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/print-32.png b/qtbase/src/printsupport/dialogs/images/printer-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/print-32.png
+rename to src/printsupport/dialogs/images/printer-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-sided-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-facing-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-sided-24.png
+rename to src/printsupport/dialogs/images/view-pages-facing-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-sided-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-facing-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-sided-32.png
+rename to src/printsupport/dialogs/images/view-pages-facing-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-multi-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-overview-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-multi-24.png
+rename to src/printsupport/dialogs/images/view-pages-overview-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-multi-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-overview-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-multi-32.png
+rename to src/printsupport/dialogs/images/view-pages-overview-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-one-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-single-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-one-24.png
+rename to src/printsupport/dialogs/images/view-pages-single-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-one-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-single-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-one-32.png
+rename to src/printsupport/dialogs/images/view-pages-single-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-page-24.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-page-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-page-24.png
+rename to src/printsupport/dialogs/images/zoom-fit-page-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-page-32.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-page-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-page-32.png
+rename to src/printsupport/dialogs/images/zoom-fit-page-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-width-24.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-width-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-width-24.png
+rename to src/printsupport/dialogs/images/zoom-fit-width-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-width-32.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-width-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-width-32.png
+rename to src/printsupport/dialogs/images/zoom-fit-width-32.png
+diff --git a/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp b/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
+index 78e5b8d1ef..2a28516719 100644
+--- a/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
++++ b/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
+@@ -532,6 +532,7 @@ void QPageSetupWidget::updateWidget()
+ void QPageSetupWidget::setupPrinter() const
+ {
+     m_printer->setPageLayout(m_pageLayout);
++    m_printer->setPageOrientation(m_pageLayout.orientation());
+ #if QT_CONFIG(cups)
+     QCUPSSupport::PagesPerSheet pagesPerSheet = qvariant_cast<QCUPSSupport::PagesPerSheet>(m_ui.pagesPerSheetCombo->currentData()
+ );
+diff --git a/qtbase/src/printsupport/dialogs/qprintdialog.qrc b/qtbase/src/printsupport/dialogs/qprintdialog.qrc
+index 5a579baa55..10b8e1d341 100644
+--- a/qtbase/src/printsupport/dialogs/qprintdialog.qrc
++++ b/qtbase/src/printsupport/dialogs/qprintdialog.qrc
+@@ -1,9 +1,9 @@
+ <!DOCTYPE RCC><RCC version="1.0">
+ <qresource prefix="/qt-project.org/dialogs/qprintpreviewdialog">
+-<file>images/fit-page-24.png</file>
+-<file>images/fit-page-32.png</file>
+-<file>images/fit-width-24.png</file>
+-<file>images/fit-width-32.png</file>
++<file>images/zoom-fit-page-24.png</file>
++<file>images/zoom-fit-page-32.png</file>
++<file>images/zoom-fit-width-24.png</file>
++<file>images/zoom-fit-width-32.png</file>
+ <file>images/go-first-24.png</file>
+ <file>images/go-first-32.png</file>
+ <file>images/go-last-24.png</file>
+@@ -18,14 +18,14 @@
+ <file>images/layout-portrait-32.png</file>
+ <file>images/page-setup-24.png</file>
+ <file>images/page-setup-32.png</file>
+-<file>images/print-24.png</file>
+-<file>images/print-32.png</file>
+-<file>images/view-page-multi-24.png</file>
+-<file>images/view-page-multi-32.png</file>
+-<file>images/view-page-one-24.png</file>
+-<file>images/view-page-one-32.png</file>
+-<file>images/view-page-sided-24.png</file>
+-<file>images/view-page-sided-32.png</file>
++<file>images/printer-24.png</file>
++<file>images/printer-32.png</file>
++<file>images/view-pages-overview-24.png</file>
++<file>images/view-pages-overview-32.png</file>
++<file>images/view-pages-single-24.png</file>
++<file>images/view-pages-single-32.png</file>
++<file>images/view-pages-facing-24.png</file>
++<file>images/view-pages-facing-32.png</file>
+ <file>images/zoom-in-24.png</file>
+ <file>images/zoom-in-32.png</file>
+ <file>images/zoom-out-24.png</file>
+diff --git a/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp b/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
+index c5b845f4ec..5a5ba1d0a8 100644
+--- a/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
++++ b/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
+@@ -702,13 +702,14 @@ void QPrintDialogPrivate::selectPrinter(const QPrinter::OutputFormat outputForma
+         else
+             options.grayscale->setChecked(true);
+ 
+-        // keep duplex value explicitly set by user, if any, and selected printer supports it;
+-        // use device default otherwise
++        // duplex priorities to be as follows:
++        // 1) a user-selected duplex value in the dialog has highest prority
++        // 2) duplex value set in the QPrinter
+         QPrint::DuplexMode duplex;
+         if (explicitDuplexMode != QPrint::DuplexAuto && supportedDuplexMode.contains(explicitDuplexMode))
+             duplex = explicitDuplexMode;
+         else
+-            duplex = top->d->m_currentPrintDevice.defaultDuplexMode();
++            duplex = static_cast<QPrint::DuplexMode>(p->duplex());
+         switch (duplex) {
+         case QPrint::DuplexNone:
+             options.noDuplex->setChecked(true); break;
+@@ -1242,10 +1243,10 @@ void QUnixPrintWidgetPrivate::_q_printerChanged(int index)
+             QString filename = widget.filename->text();
+             widget.filename->setText(filename);
+             widget.lOutput->setEnabled(true);
+-            if (optionsPane)
+-                optionsPane->selectPrinter(QPrinter::PdfFormat);
+             printer->setOutputFormat(QPrinter::PdfFormat);
+             m_currentPrintDevice = QPrintDevice();
++            if (optionsPane)
++                optionsPane->selectPrinter(QPrinter::PdfFormat);
+             return;
+         }
+     }
+diff --git a/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp b/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
+index 39575d5f57..23b7e89538 100644
+--- a/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
++++ b/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
+@@ -352,7 +352,7 @@ void QPrintPreviewDialogPrivate::init(QPrinter *_printer)
+ static inline void qt_setupActionIcon(QAction *action, QLatin1String name)
+ {
+     QLatin1String imagePrefix(":/qt-project.org/dialogs/qprintpreviewdialog/images/");
+-    QIcon icon;
++    QIcon icon = QIcon::fromTheme(name);
+     icon.addFile(imagePrefix + name + QLatin1String("-24.png"), QSize(24, 24));
+     icon.addFile(imagePrefix + name + QLatin1String("-32.png"), QSize(32, 32));
+     action->setIcon(icon);
+@@ -383,8 +383,8 @@ void QPrintPreviewDialogPrivate::setupActions()
+     fitPageAction->setObjectName(QLatin1String("fitPageAction"));
+     fitWidthAction->setCheckable(true);
+     fitPageAction->setCheckable(true);
+-    qt_setupActionIcon(fitWidthAction, QLatin1String("fit-width"));
+-    qt_setupActionIcon(fitPageAction, QLatin1String("fit-page"));
++    qt_setupActionIcon(fitWidthAction, QLatin1String("zoom-fit-width"));
++    qt_setupActionIcon(fitPageAction, QLatin1String("zoom-fit-page"));
+     QObject::connect(fitGroup, SIGNAL(triggered(QAction*)), q, SLOT(_q_fit(QAction*)));
+ 
+     // Zoom
+@@ -410,9 +410,9 @@ void QPrintPreviewDialogPrivate::setupActions()
+     singleModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show single page"));
+     facingModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show facing pages"));
+     overviewModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show overview of all pages"));
+-    qt_setupActionIcon(singleModeAction, QLatin1String("view-page-one"));
+-    qt_setupActionIcon(facingModeAction, QLatin1String("view-page-sided"));
+-    qt_setupActionIcon(overviewModeAction, QLatin1String("view-page-multi"));
++    qt_setupActionIcon(singleModeAction, QLatin1String("view-pages-single"));
++    qt_setupActionIcon(facingModeAction, QLatin1String("view-pages-facing"));
++    qt_setupActionIcon(overviewModeAction, QLatin1String("view-pages-overview"));
+     singleModeAction->setObjectName(QLatin1String("singleModeAction"));
+     facingModeAction->setObjectName(QLatin1String("facingModeAction"));
+     overviewModeAction->setObjectName(QLatin1String("overviewModeAction"));
+@@ -426,7 +426,7 @@ void QPrintPreviewDialogPrivate::setupActions()
+     printerGroup = new QActionGroup(q);
+     printAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Print"));
+     pageSetupAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Page setup"));
+-    qt_setupActionIcon(printAction, QLatin1String("print"));
++    qt_setupActionIcon(printAction, QLatin1String("printer"));
+     qt_setupActionIcon(pageSetupAction, QLatin1String("page-setup"));
+     QObject::connect(printAction, SIGNAL(triggered(bool)), q, SLOT(_q_print()));
+     QObject::connect(pageSetupAction, SIGNAL(triggered(bool)), q, SLOT(_q_pageSetup()));
+diff --git a/qtbase/src/sql/kernel/qsqlquery.cpp b/qtbase/src/sql/kernel/qsqlquery.cpp
+index 32c6166c79..60afef10c3 100644
+--- a/qtbase/src/sql/kernel/qsqlquery.cpp
++++ b/qtbase/src/sql/kernel/qsqlquery.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2022 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtSql module of the Qt Toolkit.
+@@ -377,6 +377,10 @@ bool QSqlQuery::exec(const QString& query)
+     QElapsedTimer t;
+     t.start();
+ #endif
++    if (!driver()) {
++        qWarning("QSqlQuery::exec: called before driver has been set up");
++        return false;
++    }
+     if (d->ref.loadRelaxed() != 1) {
+         bool fo = isForwardOnly();
+         *this = QSqlQuery(driver()->createResult());
+diff --git a/qtbase/src/testlib/qabstractitemmodeltester.cpp b/qtbase/src/testlib/qabstractitemmodeltester.cpp
+index 8efb9c53d4..ce062f66d7 100644
+--- a/qtbase/src/testlib/qabstractitemmodeltester.cpp
++++ b/qtbase/src/testlib/qabstractitemmodeltester.cpp
+@@ -454,7 +454,7 @@ void QAbstractItemModelTesterPrivate::parent()
+ 
+     // Common error test #2, make sure that a second level index has a parent
+     // that is the first level index.
+-    if (model->rowCount(topIndex) > 0) {
++    if (model->rowCount(topIndex) > 0 && model->columnCount(topIndex) > 0) {
+         QModelIndex childIndex = model->index(0, 0, topIndex);
+         MODELTESTER_VERIFY(childIndex.isValid());
+         MODELTESTER_COMPARE(model->parent(childIndex), topIndex);
+diff --git a/qtbase/src/testlib/qasciikey.cpp b/qtbase/src/testlib/qasciikey.cpp
+index 9a308da2bc..93498b256f 100644
+--- a/qtbase/src/testlib/qasciikey.cpp
++++ b/qtbase/src/testlib/qasciikey.cpp
+@@ -498,6 +498,11 @@ char QTest::keyToAscii(Qt::Key key)
+     case Qt::Key_LaunchE : return 0; // = 0x10b0,
+     case Qt::Key_LaunchF : return 0; // = 0x10b1,
+ 
++    // Keypad navigation keys
++    case Qt::Key_Select : return 0; // = 0x01010000
++    case Qt::Key_Yes : return 0; // = 0x01010001
++    case Qt::Key_No : return 0; // = 0x01010002
++
+     default: QTEST_ASSERT(false); return 0;
+     }
+ }
+diff --git a/qtbase/src/testlib/qtestresult.cpp b/qtbase/src/testlib/qtestresult.cpp
+index 88028aac6e..2e89930776 100644
+--- a/qtbase/src/testlib/qtestresult.cpp
++++ b/qtbase/src/testlib/qtestresult.cpp
+@@ -251,7 +251,8 @@ bool QTestResult::verify(bool statement, const char *statementStr,
+ {
+     QTEST_ASSERT(statementStr);
+ 
+-    char msg[1024] = {'\0'};
++    char msg[1024];
++    msg[0] = '\0';
+ 
+     if (QTestLog::verboseLevel() >= 2) {
+         qsnprintf(msg, 1024, "QVERIFY(%s)", statementStr);
+@@ -309,7 +310,8 @@ static bool compareHelper(bool success, const char *failureMsg,
+                           bool hasValues = true)
+ {
+     const size_t maxMsgLen = 1024;
+-    char msg[maxMsgLen] = {'\0'};
++    char msg[maxMsgLen];
++    msg[0] = '\0';
+ 
+     QTEST_ASSERT(expected);
+     QTEST_ASSERT(actual);
+diff --git a/qtbase/src/widgets/dialogs/qcolordialog.cpp b/qtbase/src/widgets/dialogs/qcolordialog.cpp
+index 4247731275..cb325be85c 100644
+--- a/qtbase/src/widgets/dialogs/qcolordialog.cpp
++++ b/qtbase/src/widgets/dialogs/qcolordialog.cpp
+@@ -78,7 +78,10 @@
+ #include "qwindow.h"
+ 
+ #include "private/qdialog_p.h"
++#include "private/qguiapplication_p.h"
+ 
++#include <qpa/qplatformservices.h>
++#include <qpa/qplatformintegration.h>
+ #include <algorithm>
+ 
+ QT_BEGIN_NAMESPACE
+@@ -1611,6 +1614,20 @@ void QColorDialogPrivate::_q_newStandard(int r, int c)
+ void QColorDialogPrivate::_q_pickScreenColor()
+ {
+     Q_Q(QColorDialog);
++
++    auto *platformServices = QGuiApplicationPrivate::platformIntegration()->services();
++    if (platformServices->hasCapability(QPlatformServices::Capability::ColorPicking)) {
++        if (auto *colorPicker = platformServices->colorPicker(q->windowHandle())) {
++            q->connect(colorPicker, &QPlatformServiceColorPicker::colorPicked, q,
++                       [q, colorPicker](const QColor &color) {
++                           colorPicker->deleteLater();
++                           q->setCurrentColor(color);
++                       });
++            colorPicker->pickColor();
++            return;
++        }
++    }
++
+     if (!colorPickingEventFilter)
+         colorPickingEventFilter = new QColorPickingEventFilter(this, q);
+     q->installEventFilter(colorPickingEventFilter);
+diff --git a/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp b/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
+index e120817edc..8ea36b5427 100644
+--- a/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
++++ b/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
+@@ -400,12 +400,7 @@ bool QAbstractItemDelegate::helpEvent(QHelpEvent *event,
+         const QString tooltip = index.isValid() ?
+               d->textForRole(Qt::ToolTipRole, index.data(Qt::ToolTipRole), option.locale, precision) :
+               QString();
+-        QRect rect;
+-        if (index.isValid()) {
+-            const QRect r = view->visualRect(index);
+-            rect = QRect(view->mapToGlobal(r.topLeft()), r.size());
+-        }
+-        QToolTip::showText(he->globalPos(), tooltip, view, rect);
++        QToolTip::showText(he->globalPos(), tooltip, view->viewport(), option.rect);
+         event->setAccepted(!tooltip.isEmpty());
+         break;
+         }
+diff --git a/qtbase/src/widgets/itemviews/qlistview.cpp b/qtbase/src/widgets/itemviews/qlistview.cpp
+index 2b34476642..eebfaa030e 100644
+--- a/qtbase/src/widgets/itemviews/qlistview.cpp
++++ b/qtbase/src/widgets/itemviews/qlistview.cpp
+@@ -3386,6 +3386,7 @@ void QIconModeViewBase::updateContentsSize()
+ */
+ void QListView::currentChanged(const QModelIndex &current, const QModelIndex &previous)
+ {
++    QAbstractItemView::currentChanged(current, previous);
+ #ifndef QT_NO_ACCESSIBILITY
+     if (QAccessible::isActive()) {
+         if (current.isValid()) {
+@@ -3396,7 +3397,6 @@ void QListView::currentChanged(const QModelIndex &current, const QModelIndex &pr
+         }
+     }
+ #endif
+-    QAbstractItemView::currentChanged(current, previous);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/widgets/itemviews/qtableview.cpp b/qtbase/src/widgets/itemviews/qtableview.cpp
+index 934ac581b2..f79bb24249 100644
+--- a/qtbase/src/widgets/itemviews/qtableview.cpp
++++ b/qtbase/src/widgets/itemviews/qtableview.cpp
+@@ -1013,6 +1013,7 @@ void QTableViewPrivate::drawCell(QPainter *painter, const QStyleOptionViewItem &
+ int QTableViewPrivate::widthHintForIndex(const QModelIndex &index, int hint, const QStyleOptionViewItem &option) const
+ {
+     Q_Q(const QTableView);
++    const int oldHint = hint;
+     QWidget *editor = editorForIndex(index).widget.data();
+     if (editor && persistent.contains(editor)) {
+         hint = qMax(hint, editor->sizeHint().width());
+@@ -1021,6 +1022,17 @@ int QTableViewPrivate::widthHintForIndex(const QModelIndex &index, int hint, con
+         hint = qBound(min, hint, max);
+     }
+     hint = qMax(hint, q->itemDelegate(index)->sizeHint(option, index).width());
++
++    if (hasSpans()) {
++        auto span = spans.spanAt(index.column(), index.row());
++        if (span && span->m_left == index.column() && span->m_top == index.row()) {
++            // spans are screwed up when sections are moved
++            const auto left = logicalColumn(span->m_left);
++            for (int i = 1; i <= span->width(); ++i)
++               hint -= q->columnWidth(visualColumn(left + i));
++        }
++        hint = std::max(hint, oldHint);
++    }
+     return hint;
+ }
+ 
+@@ -1053,6 +1065,11 @@ int QTableViewPrivate::heightHintForIndex(const QModelIndex &index, int hint, QS
+         option.rect.setHeight(height);
+         option.rect.setX(q->columnViewportPosition(index.column()));
+         option.rect.setWidth(q->columnWidth(index.column()));
++        if (hasSpans()) {
++            auto span = spans.spanAt(index.column(), index.row());
++            if (span && span->m_left == index.column() && span->m_top == index.row())
++                option.rect.setWidth(std::max(option.rect.width(), visualSpanRect(*span).width()));
++        }
+         // 1px less space when grid is shown (see drawCell)
+         if (showGrid)
+             option.rect.setWidth(option.rect.width() - 1);
+diff --git a/qtbase/src/widgets/kernel/qaction.h b/qtbase/src/widgets/kernel/qaction.h
+index 258a1ea0a0..737c1e8285 100644
+--- a/qtbase/src/widgets/kernel/qaction.h
++++ b/qtbase/src/widgets/kernel/qaction.h
+@@ -81,7 +81,7 @@ class Q_WIDGETS_EXPORT QAction : public QObject
+     Q_PROPERTY(MenuRole menuRole READ menuRole WRITE setMenuRole NOTIFY changed)
+     Q_PROPERTY(bool iconVisibleInMenu READ isIconVisibleInMenu WRITE setIconVisibleInMenu NOTIFY changed)
+     Q_PROPERTY(bool shortcutVisibleInContextMenu READ isShortcutVisibleInContextMenu WRITE setShortcutVisibleInContextMenu NOTIFY changed)
+-    Q_PROPERTY(Priority priority READ priority WRITE setPriority)
++    Q_PROPERTY(Priority priority READ priority WRITE setPriority NOTIFY changed)
+ 
+ public:
+     // note this is copied into qplatformmenu.h, which must stay in sync
+diff --git a/qtbase/src/widgets/kernel/qwidget.cpp b/qtbase/src/widgets/kernel/qwidget.cpp
+index 9eba1e001e..26f6d27e18 100644
+--- a/qtbase/src/widgets/kernel/qwidget.cpp
++++ b/qtbase/src/widgets/kernel/qwidget.cpp
+@@ -5296,7 +5296,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
+         QWidgetEffectSourcePrivate *sourced = static_cast<QWidgetEffectSourcePrivate *>
+                                                          (source->d_func());
+         if (!sourced->context) {
+-            const QRegion effectRgn(rgn.boundingRect());
++            const QRegion effectRgn((flags & UseEffectRegionBounds) ? rgn.boundingRect() : rgn);
+             QWidgetPaintContext context(pdev, effectRgn, offset, flags, sharedPainter, repaintManager);
+             sourced->context = &context;
+             if (!sharedPainter) {
+@@ -5328,6 +5328,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
+         }
+     }
+ #endif // QT_CONFIG(graphicseffect)
++    flags = flags & ~UseEffectRegionBounds;
+ 
+     const bool alsoOnScreen = flags & DrawPaintOnScreen;
+     const bool recursive = flags & DrawRecursive;
+diff --git a/qtbase/src/widgets/kernel/qwidget_p.h b/qtbase/src/widgets/kernel/qwidget_p.h
+index eef6b8fa2c..c432f4b5d5 100644
+--- a/qtbase/src/widgets/kernel/qwidget_p.h
++++ b/qtbase/src/widgets/kernel/qwidget_p.h
+@@ -229,7 +229,8 @@ public:
+         DontSubtractOpaqueChildren = 0x10,
+         DontDrawOpaqueChildren = 0x20,
+         DontDrawNativeChildren = 0x40,
+-        DontSetCompositionMode = 0x80
++        DontSetCompositionMode = 0x80,
++        UseEffectRegionBounds = 0x100
+     };
+     Q_DECLARE_FLAGS(DrawWidgetFlags, DrawWidgetFlag)
+     Q_FLAG(DrawWidgetFlags)
+diff --git a/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp b/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
+index 02880b34da..0d44e1326d 100644
+--- a/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
++++ b/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
+@@ -1018,7 +1018,8 @@ void QWidgetRepaintManager::paintAndFlush()
+ 
+     // Paint the rest with composition.
+     if (repaintAllWidgets || !dirtyCopy.isEmpty()) {
+-        QWidgetPrivate::DrawWidgetFlags flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive;
++        QWidgetPrivate::DrawWidgetFlags flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive
++                | QWidgetPrivate::UseEffectRegionBounds;
+         tlw->d_func()->drawWidget(store->paintDevice(), dirtyCopy, QPoint(), flags, nullptr, this);
+     }
+ 
+diff --git a/qtbase/src/widgets/styles/qfusionstyle.cpp b/qtbase/src/widgets/styles/qfusionstyle.cpp
+index f4345d97c4..962912c838 100644
+--- a/qtbase/src/widgets/styles/qfusionstyle.cpp
++++ b/qtbase/src/widgets/styles/qfusionstyle.cpp
+@@ -1772,14 +1772,6 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio
+             proxy()->drawControl(CE_PushButtonLabel, &subopt, painter, widget);
+         }
+         break;
+-    case CE_PushButtonLabel:
+-        if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
+-            QStyleOptionButton b(*button);
+-            // no PM_ButtonShiftHorizontal and PM_ButtonShiftVertical for fusion style
+-            b.state &= ~(State_On | State_Sunken);
+-            QCommonStyle::drawControl(element, &b, painter, widget);
+-        }
+-        break;
+     case CE_MenuBarEmptyArea:
+         painter->save();
+     {
+diff --git a/qtbase/src/widgets/util/qcompleter.cpp b/qtbase/src/widgets/util/qcompleter.cpp
+index 18b24063d8..ef7207a8a3 100644
+--- a/qtbase/src/widgets/util/qcompleter.cpp
++++ b/qtbase/src/widgets/util/qcompleter.cpp
+@@ -1120,6 +1120,8 @@ void QCompleter::setModel(QAbstractItemModel *model)
+ {
+     Q_D(QCompleter);
+     QAbstractItemModel *oldModel = d->proxy->sourceModel();
++    if (oldModel == model)
++        return;
+ #if QT_CONFIG(filesystemmodel)
+     if (qobject_cast<const QFileSystemModel *>(oldModel))
+         setCompletionRole(Qt::EditRole); // QTBUG-54642, clear FileNameRole set by QFileSystemModel
+diff --git a/qtbase/src/widgets/widgets/qabstractbutton.cpp b/qtbase/src/widgets/widgets/qabstractbutton.cpp
+index a128b23950..dc40bf62fb 100644
+--- a/qtbase/src/widgets/widgets/qabstractbutton.cpp
++++ b/qtbase/src/widgets/widgets/qabstractbutton.cpp
+@@ -56,6 +56,7 @@
+ #ifndef QT_NO_ACCESSIBILITY
+ #include "qaccessible.h"
+ #endif
++#include <qpa/qplatformtheme.h>
+ 
+ #include <algorithm>
+ 
+@@ -1076,19 +1077,19 @@ void QAbstractButton::keyPressEvent(QKeyEvent *e)
+ {
+     Q_D(QAbstractButton);
+     bool next = true;
+-    switch (e->key()) {
+-    case Qt::Key_Enter:
+-    case Qt::Key_Return:
+-        e->ignore();
+-        break;
+-    case Qt::Key_Select:
+-    case Qt::Key_Space:
+-        if (!e->isAutoRepeat()) {
+-            setDown(true);
+-            repaint();
+-            d->emitPressed();
+-        }
+-        break;
++
++    const auto key = static_cast<Qt::Key>(e->key());
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(key) && !e->isAutoRepeat()) {
++        setDown(true);
++        repaint();
++        d->emitPressed();
++        return;
++    }
++
++    switch (key) {
+     case Qt::Key_Up:
+         next = false;
+         Q_FALLTHROUGH();
+@@ -1153,15 +1154,15 @@ void QAbstractButton::keyReleaseEvent(QKeyEvent *e)
+     if (!e->isAutoRepeat())
+         d->repeatTimer.stop();
+ 
+-    switch (e->key()) {
+-    case Qt::Key_Select:
+-    case Qt::Key_Space:
+-        if (!e->isAutoRepeat() && d->down)
+-            d->click();
+-        break;
+-    default:
+-        e->ignore();
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(static_cast<Qt::Key>(e->key())) && !e->isAutoRepeat() && d->down) {
++        d->click();
++        return;
+     }
++
++    e->ignore();
+ }
+ 
+ /*!\reimp
+diff --git a/qtbase/src/widgets/widgets/qcombobox.cpp b/qtbase/src/widgets/widgets/qcombobox.cpp
+index 7a496c27e0..0a3d96647b 100644
+--- a/qtbase/src/widgets/widgets/qcombobox.cpp
++++ b/qtbase/src/widgets/widgets/qcombobox.cpp
+@@ -3352,7 +3352,23 @@ void QComboBox::keyPressEvent(QKeyEvent *e)
+ 
+     Move move = NoMove;
+     int newIndex = currentIndex();
+-    switch (e->key()) {
++
++    bool pressLikeButton = !d->lineEdit;
++#ifdef QT_KEYPAD_NAVIGATION
++    pressLikeButton |= QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus();
++#endif
++    auto key = static_cast<Qt::Key>(e->key());
++    if (pressLikeButton) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(key)) {
++            showPopup();
++            return;
++        }
++    }
++
++    switch (key) {
+     case Qt::Key_Up:
+         if (e->modifiers() & Qt::ControlModifier)
+             break; // pass to line edit for auto completion
+@@ -3394,26 +3410,11 @@ void QComboBox::keyPressEvent(QKeyEvent *e)
+             return;
+         }
+         break;
+-    case Qt::Key_Space:
+-        if (!d->lineEdit) {
+-            showPopup();
+-            return;
+-        }
+-        break;
+-    case Qt::Key_Enter:
+-    case Qt::Key_Return:
+     case Qt::Key_Escape:
+         if (!d->lineEdit)
+             e->ignore();
+         break;
+ #ifdef QT_KEYPAD_NAVIGATION
+-    case Qt::Key_Select:
+-        if (QApplicationPrivate::keypadNavigationEnabled()
+-                && (!hasEditFocus() || !d->lineEdit)) {
+-            showPopup();
+-            return;
+-        }
+-        break;
+     case Qt::Key_Left:
+     case Qt::Key_Right:
+         if (QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus())
+diff --git a/qtbase/src/widgets/widgets/qdatetimeedit_p.h b/qtbase/src/widgets/widgets/qdatetimeedit_p.h
+index d36b6f8f9a..e0df5b5158 100644
+--- a/qtbase/src/widgets/widgets/qdatetimeedit_p.h
++++ b/qtbase/src/widgets/widgets/qdatetimeedit_p.h
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2018 The Qt Company Ltd.
++** Copyright (C) 2021 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtWidgets module of the Qt Toolkit.
+diff --git a/qtbase/src/widgets/widgets/qgroupbox.cpp b/qtbase/src/widgets/widgets/qgroupbox.cpp
+index 02a0bed325..3f3eccc370 100644
+--- a/qtbase/src/widgets/widgets/qgroupbox.cpp
++++ b/qtbase/src/widgets/widgets/qgroupbox.cpp
+@@ -54,6 +54,8 @@
+ #include "qaccessible.h"
+ #endif
+ #include <private/qwidget_p.h>
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
+ 
+ #include "qdebug.h"
+ 
+@@ -360,7 +362,10 @@ bool QGroupBox::event(QEvent *e)
+         return true;
+     case QEvent::KeyPress: {
+         QKeyEvent *k = static_cast<QKeyEvent*>(e);
+-        if (!k->isAutoRepeat() && (k->key() == Qt::Key_Select || k->key() == Qt::Key_Space)) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (!k->isAutoRepeat() && buttonPressKeys.contains(static_cast<Qt::Key>(k->key()))) {
+             d->pressedControl = QStyle::SC_GroupBoxCheckBox;
+             update(style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxCheckBox, this));
+             return true;
+@@ -369,7 +374,10 @@ bool QGroupBox::event(QEvent *e)
+     }
+     case QEvent::KeyRelease: {
+         QKeyEvent *k = static_cast<QKeyEvent*>(e);
+-        if (!k->isAutoRepeat() && (k->key() == Qt::Key_Select || k->key() == Qt::Key_Space)) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (!k->isAutoRepeat() && buttonPressKeys.contains(static_cast<Qt::Key>(k->key()))) {
+             bool toggle = (d->pressedControl == QStyle::SC_GroupBoxLabel
+                            || d->pressedControl == QStyle::SC_GroupBoxCheckBox);
+             d->pressedControl = QStyle::SC_None;
+diff --git a/qtbase/src/widgets/widgets/qlabel.cpp b/qtbase/src/widgets/widgets/qlabel.cpp
+index 30ff80cbb0..cf2605c17c 100644
+--- a/qtbase/src/widgets/widgets/qlabel.cpp
++++ b/qtbase/src/widgets/widgets/qlabel.cpp
+@@ -421,9 +421,6 @@ void QLabel::setPixmap(const QPixmap &pixmap)
+         d->pixmap = new QPixmap(pixmap);
+     }
+ 
+-    if (d->pixmap->depth() == 1 && !d->pixmap->mask())
+-        d->pixmap->setMask(*((QBitmap *)d->pixmap));
+-
+     d->updateLabel();
+ }
+ 
+diff --git a/qtbase/src/widgets/widgets/qtoolbararealayout.cpp b/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
+index 493c094cc1..d5f4b59017 100644
+--- a/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
++++ b/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
+@@ -1367,7 +1367,7 @@ bool QToolBarAreaLayout::restoreState(QDataStream &stream, const QList<QToolBar*
+                 item.widgetItem = new QWidgetItemV2(toolBar);
+                 toolBar->setOrientation(floating ? ((shown & 2) ? Qt::Vertical : Qt::Horizontal) : dock.o);
+                 toolBar->setVisible(shown & 1);
+-                toolBar->d_func()->setWindowState(floating, true, rect);
++                toolBar->d_func()->setWindowState(floating, false, rect);
+ 
+                 item.preferredSize = item.size;
+                 line.toolBarItems.append(item);
+diff --git a/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp b/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
+index 212c0a2e13..3c77b1ba0b 100644
+--- a/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
++++ b/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
+@@ -126,8 +126,7 @@ public:
+ 
+ void tst_QtConcurrentIterateKernel::instantiate()
+ {
+-    auto future = startThreadEngine(new PrintFor(0, 40)).startAsynchronously();
+-    future.waitForFinished();
++    startThreadEngine(new PrintFor(0, 40)).startBlocking();
+     QCOMPARE(iterations.loadRelaxed(), 40);
+ }
+ 
+@@ -166,10 +165,8 @@ void tst_QtConcurrentIterateKernel::stresstest()
+     const int times = 50;
+     for (int i = 0; i < times; ++i) {
+         counter.storeRelaxed(0);
+-        // ThreadEngine will delete f when it finishes
+-        auto f = new CountFor(0, iterations);
+-        auto future = f->startAsynchronously();
+-        future.waitForFinished();
++        CountFor f(0, iterations);
++        f.startBlocking();
+         QCOMPARE(counter.loadRelaxed(), iterations);
+     }
+ }
+@@ -177,11 +174,8 @@ void tst_QtConcurrentIterateKernel::stresstest()
+ void tst_QtConcurrentIterateKernel::noIterations()
+ {
+     const int times = 20000;
+-    for (int i = 0; i < times; ++i) {
+-        auto future = startThreadEngine(new IterateKernel<TestIterator, void>(0, 0))
+-                              .startAsynchronously();
+-        future.waitForFinished();
+-    }
++    for (int i = 0; i < times; ++i)
++        startThreadEngine(new IterateKernel<TestIterator, void>(0, 0)).startBlocking();
+ }
+ 
+ QMutex threadsMutex;
+@@ -236,10 +230,8 @@ void tst_QtConcurrentIterateKernel::throttling()
+ 
+     threads.clear();
+ 
+-    // ThreadEngine will delete f when it finishes
+-    auto f = new ThrottleFor(0, totalIterations);
+-    auto future = f->startAsynchronously();
+-    future.waitForFinished();
++    ThrottleFor f(0, totalIterations);
++    f.startBlocking();
+ 
+     QCOMPARE(iterations.loadRelaxed(), totalIterations);
+ 
+diff --git a/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp b/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
+index ac7be7acdd..81bc64c8d9 100644
+--- a/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
++++ b/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
+@@ -65,9 +65,16 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::runDirectly()
+ {
+-    PrintUser *engine = new PrintUser();
+-    QFuture<void> f = engine->startAsynchronously();
+-    f.waitForFinished();
++    {
++        PrintUser engine;
++        engine.startSingleThreaded();
++        engine.startBlocking();
++    }
++    {
++        PrintUser *engine = new PrintUser();
++        QFuture<void> f = engine->startAsynchronously();
++        f.waitForFinished();
++    }
+ }
+ 
+ class StringResultUser : public ThreadEngine<QString>
+@@ -99,10 +106,8 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::result()
+ {
+-    // ThreadEngine will delete 'engine' when it finishes
+-    auto engine = new StringResultUser();
+-    auto future = engine->startAsynchronously();
+-    QCOMPARE(future.result(), QString("Foo"));
++    StringResultUser engine;
++    QCOMPARE(*engine.startBlocking(), QString("Foo"));
+ }
+ 
+ class VoidResultUser : public ThreadEngine<void>
+@@ -128,9 +133,17 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::runThroughStarter()
+ {
+-    ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
+-    QFuture<QString> f = starter.startAsynchronously();
+-    QCOMPARE(f.result(), QString("Foo"));
++    {
++        ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
++        QFuture<QString>  f = starter.startAsynchronously();
++        QCOMPARE(f.result(), QString("Foo"));
++    }
++
++    {
++        ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
++        QString str = starter.startBlocking();
++        QCOMPARE(str, QString("Foo"));
++    }
+ }
+ 
+ class CancelUser : public ThreadEngine<void>
+@@ -213,6 +226,12 @@ void tst_QtConcurrentThreadEngine::throttle()
+         f.waitForFinished();
+         QCOMPARE(count.loadRelaxed(), 0);
+     }
++
++    for (int i = 0; i < repeats; ++i) {
++        ThrottleAlwaysUser t;
++        t.startBlocking();
++        QCOMPARE(count.loadRelaxed(), 0);
++    }
+ }
+ 
+ QSet<QThread *> threads;
+@@ -249,17 +268,35 @@ void tst_QtConcurrentThreadEngine::threadCount()
+ {
+     const int repeats = 10;
+     for (int i = 0; i < repeats; ++i) {
++        ThreadCountUser t;
++        t.startBlocking();
++        int count = threads.count();
++        int count_expected = QThreadPool::globalInstance()->maxThreadCount() + 1; // +1 for the main thread.
++        if (count != count_expected)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, count_expected);
++
+         (new ThreadCountUser())->startAsynchronously().waitForFinished();
+-        const auto count = threads.count();
+-        const auto maxThreadCount = QThreadPool::globalInstance()->maxThreadCount();
+-        QVERIFY(count <= maxThreadCount);
+-        QVERIFY(!threads.contains(QThread::currentThread()));
++        count = threads.count();
++        count_expected = QThreadPool::globalInstance()->maxThreadCount();
++        if (count != count_expected)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, count_expected);
+     }
+ 
+     // Set the finish flag immediately, this should give us one thread only.
+     for (int i = 0; i < repeats; ++i) {
++        ThreadCountUser t(true /*finishImmediately*/);
++        t.startBlocking();
++        int count = threads.count();
++        if (count != 1)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, 1);
++
+         (new ThreadCountUser(true /*finishImmediately*/))->startAsynchronously().waitForFinished();
+-        const auto count = threads.count();
++        count = threads.count();
++        if (count != 1)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
+         QCOMPARE(count, 1);
+         QVERIFY(!threads.contains(QThread::currentThread()));
+     }
+@@ -400,6 +437,7 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::exceptions()
+ {
++    // Asynchronous mode:
+     {
+         bool caught = false;
+         try  {
+@@ -412,6 +450,32 @@ void tst_QtConcurrentThreadEngine::exceptions()
+         QVERIFY2(caught, "did not get exception");
+     }
+ 
++    // Blocking mode:
++    // test throwing the exception from a worker thread.
++    {
++        bool caught = false;
++        try  {
++            QtConcurrentExceptionThrower e(QThread::currentThread());
++            e.startBlocking();
++        } catch (const QException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // test throwing the exception from the main thread (different code path)
++    {
++        bool caught = false;
++        try  {
++            QtConcurrentExceptionThrower e(0);
++            e.startBlocking();
++        } catch (const QException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // Asynchronous mode:
+     {
+         bool caught = false;
+         try  {
+@@ -423,6 +487,31 @@ void tst_QtConcurrentThreadEngine::exceptions()
+         }
+         QVERIFY2(caught, "did not get exception");
+     }
++
++    // Blocking mode:
++    // test throwing the exception from a worker thread.
++    {
++        bool caught = false;
++        try  {
++            UnrelatedExceptionThrower e(QThread::currentThread());
++            e.startBlocking();
++        } catch (const QUnhandledException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // test throwing the exception from the main thread (different code path)
++    {
++        bool caught = false;
++        try  {
++            UnrelatedExceptionThrower e(0);
++            e.startBlocking();
++        } catch (const QUnhandledException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
+ }
+ 
+ #endif
+diff --git a/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp b/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
+index 4968742110..f4c3fb711d 100644
+--- a/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
++++ b/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
+@@ -42,6 +42,7 @@ private slots:
+     void writeBlock_data();
+     void writeBlock();
+     void seek();
++    void invalidSeeks();
+     void seekTest_data();
+     void seekTest();
+     void read_rawdata();
+@@ -286,6 +287,29 @@ void tst_QBuffer::seek()
+     QCOMPARE(buffer.size(), pos);
+ }
+ 
++void tst_QBuffer::invalidSeeks()
++{
++    if constexpr (sizeof(qsizetype) == sizeof(qint64)) {
++        // sizeof(qsizetype) == sizeof(qint64), so +1 would overflow
++        QSKIP("This is a 32-bit-only test.");
++    } else {
++        QBuffer buffer;
++        buffer.open(QIODevice::WriteOnly);
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++        constexpr qint64 MaxQByteArrayCapacity = (std::numeric_limits<qsizetype>::max)();
++        // this should fail fast, not after trying to allocate nearly 2 GiB of data,
++        // potentially crashing in the process:
++        QVERIFY(!buffer.seek(2 * MaxQByteArrayCapacity - 1));
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++        // ditto:
++        QVERIFY(!buffer.seek(MaxQByteArrayCapacity + 1));
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++    }
++}
++
+ void tst_QBuffer::seekTest_data()
+ {
+     writeBlock_data();
+diff --git a/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp b/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
+index da5327594c..4a04e0f7c6 100644
+--- a/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
++++ b/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
+@@ -561,7 +561,8 @@ protected:
+     qint64 readData(char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf->size() - offset));
+-        memcpy(data, buf->constData() + offset, maxSize);
++        if (maxSize > 0)
++            memcpy(data, buf->constData() + offset, maxSize);
+         offset += maxSize;
+         return maxSize;
+     }
+@@ -604,13 +605,15 @@ protected:
+     qint64 readData(char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf.size() - pos()));
+-        memcpy(data, buf.constData() + pos(), maxSize);
++        if (maxSize > 0)
++            memcpy(data, buf.constData() + pos(), maxSize);
+         return maxSize;
+     }
+     qint64 writeData(const char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf.size() - pos()));
+-        memcpy(buf.data() + pos(), data, maxSize);
++        if (maxSize > 0)
++            memcpy(buf.data() + pos(), data, maxSize);
+         return maxSize;
+     }
+ 
+diff --git a/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+index db60bead64..f345a44414 100644
+--- a/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
++++ b/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+@@ -1,7 +1,8 @@
+ /****************************************************************************
+ **
+ ** Copyright (C) 2021 The Qt Company Ltd.
+-** Copyright (C) 2020 Intel Corporation.
++** Copyright (C) 2020 The Qt Company Ltd.
++** Copyright (C) 2022 Intel Corporation.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the test suite of the Qt Toolkit.
+@@ -150,6 +151,8 @@ private slots:
+     void startStopStartStopBuffers();
+     void processEventsInAReadyReadSlot_data();
+     void processEventsInAReadyReadSlot();
++    void startFromCurrentWorkingDir_data();
++    void startFromCurrentWorkingDir();
+ 
+     // keep these at the end, since they use lots of processes and sometimes
+     // caused obscure failures to occur in tests that followed them (esp. on the Mac)
+@@ -2731,5 +2734,94 @@ void tst_QProcess::finishProcessBeforeReadingDone_deprecated()
+ 
+ #endif
+ 
++enum class ChdirMode {
++    None = 0,
++    InParent,
++    InChild
++};
++Q_DECLARE_METATYPE(ChdirMode)
++
++void tst_QProcess::startFromCurrentWorkingDir_data()
++{
++    qRegisterMetaType<ChdirMode>();
++    QTest::addColumn<QString>("programPrefix");
++    QTest::addColumn<ChdirMode>("chdirMode");
++    QTest::addColumn<bool>("success");
++
++    constexpr bool IsWindows = true
++#ifdef Q_OS_UNIX
++            && false
++#endif
++            ;
++
++    // baseline: trying to execute the directory, this can't possibly succeed!
++    QTest::newRow("plain-same-cwd") << QString() << ChdirMode::None << false;
++
++    // cross-platform behavior: neither OS searches the setWorkingDirectory()
++    // dir without "./"
++    QTest::newRow("plain-child-chdir") << QString() << ChdirMode::InChild << false;
++
++    // cross-platform behavior: both OSes search the parent's CWD with "./"
++    QTest::newRow("prefixed-parent-chdir") << "./" << ChdirMode::InParent << true;
++
++    // opposite behaviors: Windows searches the parent's CWD and Unix searches
++    // the child's with "./"
++    QTest::newRow("prefixed-child-chdir") << "./" << ChdirMode::InChild << !IsWindows;
++
++    // Windows searches the parent's CWD without "./"
++    QTest::newRow("plain-parent-chdir") << QString() << ChdirMode::InParent << IsWindows;
++}
++
++void tst_QProcess::startFromCurrentWorkingDir()
++{
++    QFETCH(QString, programPrefix);
++    QFETCH(ChdirMode, chdirMode);
++    QFETCH(bool, success);
++
++    QProcess process;
++    qRegisterMetaType<QProcess::ProcessError>();
++    QSignalSpy errorSpy(&process, &QProcess::errorOccurred);
++    QVERIFY(errorSpy.isValid());
++
++    // both the dir name and the executable name
++    const QString target = QStringLiteral("testProcessNormal");
++    process.setProgram(programPrefix + target);
++
++#ifdef Q_OS_UNIX
++    // Reset PATH, to be sure it doesn't contain . or the empty path.
++    // We can't do this on Windows because DLLs are searched in PATH
++    // and Windows always searches "." anyway.
++    auto restoreEnv = qScopeGuard([old = qgetenv("PATH")] {
++        qputenv("PATH", old);
++    });
++    qputenv("PATH", "/");
++#endif
++
++    switch (chdirMode) {
++    case ChdirMode::InParent: {
++        auto restoreCwd = qScopeGuard([old = QDir::currentPath()] {
++            QDir::setCurrent(old);
++        });
++        QVERIFY(QDir::setCurrent(target));
++        process.start();
++        break;
++    }
++    case ChdirMode::InChild:
++        process.setWorkingDirectory(target);
++        Q_FALLTHROUGH();
++    case ChdirMode::None:
++        process.start();
++        break;
++    }
++
++    QCOMPARE(process.waitForStarted(), success);
++    QCOMPARE(errorSpy.count(), int(!success));
++    if (success) {
++        QVERIFY(process.waitForFinished());
++    } else {
++        QCOMPARE(process.error(), QProcess::FailedToStart);
++    }
++}
++
+ QTEST_MAIN(tst_QProcess)
+ #include "tst_qprocess.moc"
+diff --git a/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp b/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp
+index e1ea7a4552..90972caa57 100644
+--- a/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp
++++ b/qtbase/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"
+diff --git a/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+index 9bd66c0835..ed4a0bae5d 100644
+--- a/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
++++ b/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+@@ -158,6 +158,7 @@ private slots:
+     void nullReceiver();
+     void functorReferencesConnection();
+     void disconnectDisconnects();
++    void declarativeData();
+ };
+ 
+ struct QObjectCreatedOnShutdown
+@@ -7679,5 +7680,81 @@ void tst_QObject::disconnectDisconnects()
+ Q_STATIC_ASSERT(QtPrivate::HasQ_OBJECT_Macro<tst_QObject>::Value);
+ Q_STATIC_ASSERT(!QtPrivate::HasQ_OBJECT_Macro<SiblingDeleter>::Value);
+ 
++#ifdef QT_BUILD_INTERNAL
++/*
++    Since QObjectPrivate stores the declarativeData pointer in a union with the pointer
++    to the currently destroyed child, calls to the QtDeclarative handlers need to be
++    correctly guarded. QTBUG-105286
++*/
++namespace QtDeclarative {
++static QAbstractDeclarativeData *theData;
++
++static void destroyed(QAbstractDeclarativeData *data, QObject *)
++{
++    QCOMPARE(data, theData);
++}
++static void signalEmitted(QAbstractDeclarativeData *data, QObject *, int, void **)
++{
++    QCOMPARE(data, theData);
++}
++// we can't use QCOMPARE in the next two functions, as they don't return void
++static int receivers(QAbstractDeclarativeData *data, const QObject *, int)
++{
++    QTest::qCompare(data, theData, "data", "theData", __FILE__, __LINE__);
++    return 0;
++}
++static bool isSignalConnected(QAbstractDeclarativeData *data, const QObject *, int)
++{
++    QTest::qCompare(data, theData, "data", "theData", __FILE__, __LINE__);
++    return true;
++}
++
++class Object : public QObject
++{
++    Q_OBJECT
++public:
++    using QObject::QObject;
++    ~Object()
++    {
++        if (Object *p = static_cast<Object *>(parent()))
++            p->emitSignal();
++    }
++
++    void emitSignal()
++    {
++        emit theSignal();
++    }
++
++signals:
++    void theSignal();
++};
++
++}
++#endif
++
++void tst_QObject::declarativeData()
++{
++#ifdef QT_BUILD_INTERNAL
++    QScopedValueRollback destroyed(QAbstractDeclarativeData::destroyed,
++                                   QtDeclarative::destroyed);
++    QScopedValueRollback signalEmitted(QAbstractDeclarativeData::signalEmitted,
++                                       QtDeclarative::signalEmitted);
++    QScopedValueRollback receivers(QAbstractDeclarativeData::receivers,
++                                   QtDeclarative::receivers);
++    QScopedValueRollback isSignalConnected(QAbstractDeclarativeData::isSignalConnected,
++                                           QtDeclarative::isSignalConnected);
++
++    QtDeclarative::Object p;
++    QObjectPrivate *priv = QObjectPrivate::get(&p);
++    priv->declarativeData = QtDeclarative::theData = new QAbstractDeclarativeData;
++
++    connect(&p, &QtDeclarative::Object::theSignal, &p, []{
++    });
++
++    QtDeclarative::Object *child = new QtDeclarative::Object;
++    child->setParent(&p);
++#endif
++}
++
+ QTEST_MAIN(tst_QObject)
+ #include "tst_qobject.moc"
+diff --git a/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp b/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
+index 0ea422ecbc..1a3256534b 100644
+--- a/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
++++ b/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
+@@ -70,15 +70,15 @@ static inline QString testSuiteWarning()
+ 
+     QString result;
+     QTextStream str(&result);
+-    str << "\nCannot find the shared-mime-info test suite\nstarting from: "
++    str << "\nCannot find the shared-mime-info test suite\nin the parent of: "
+         << QDir::toNativeSeparators(QDir::currentPath()) << "\n"
+            "cd " << QDir::toNativeSeparators(QStringLiteral("tests/auto/corelib/mimetypes/qmimedatabase")) << "\n"
+-           "wget http://cgit.freedesktop.org/xdg/shared-mime-info/snapshot/Release-1-10.zip\n"
+-           "unzip Release-1-10.zip\n";
++           "wget https://gitlab.freedesktop.org/xdg/shared-mime-info/-/archive/2.1/shared-mime-info-2.1.zip\n"
++           "unzip shared-mime-info-2.1.zip\n";
+ #ifdef Q_OS_WIN
+-    str << "mkdir testfiles\nxcopy /s Release-1-10 s-m-i\n";
++    str << "mkdir testfiles\nxcopy /s shared-mime-info-2.1 s-m-i\n";
+ #else
+-    str << "ln -s Release-1-10 s-m-i\n";
++    str << "ln -s shared-mime-info-2.1 s-m-i\n";
+ #endif
+     return result;
+ }
+@@ -154,7 +154,7 @@ void tst_QMimeDatabase::initTestCase()
+     QVERIFY2(copyResourceFile(xmlFileName, xmlTargetFileName, &errorMessage), qPrintable(errorMessage));
+ #endif
+ 
+-    m_testSuite = QFINDTESTDATA("s-m-i/tests");
++    m_testSuite = QFINDTESTDATA("s-m-i/tests/mime-detection");
+     if (m_testSuite.isEmpty())
+         qWarning("%s", qPrintable(testSuiteWarning()));
+ 
+@@ -611,7 +611,7 @@ void tst_QMimeDatabase::allMimeTypes()
+     QVERIFY(!lst.isEmpty());
+ 
+     // Hardcoding this is the only way to check both providers find the same number of mimetypes.
+-    QCOMPARE(lst.count(), 779);
++    QCOMPARE(lst.count(), 811);
+ 
+     foreach (const QMimeType &mime, lst) {
+         const QString name = mime.name();
+@@ -631,10 +631,9 @@ void tst_QMimeDatabase::suffixes_data()
+ 
+     QTest::newRow("mimetype with a single pattern") << "application/pdf" << "*.pdf" << "pdf";
+     QTest::newRow("mimetype with multiple patterns") << "application/x-kpresenter" << "*.kpr;*.kpt" << "kpr";
+-    QTest::newRow("jpeg") << "image/jpeg" << "*.jpe;*.jpg;*.jpeg" << "jpeg";
+-    //if (KMimeType::sharedMimeInfoVersion() > KDE_MAKE_VERSION(0, 60, 0)) {
+-        QTest::newRow("mimetype with many patterns") << "application/vnd.wordperfect" << "*.wp;*.wp4;*.wp5;*.wp6;*.wpd;*.wpp" << "wp";
+-    //}
++    // The preferred suffix for image/jpeg is *.jpg, as per https://bugs.kde.org/show_bug.cgi?id=176737
++    QTest::newRow("jpeg") << "image/jpeg" << "*.jpe;*.jpg;*.jpeg" << "jpg";
++    QTest::newRow("mimetype with many patterns") << "application/vnd.wordperfect" << "*.wp;*.wp4;*.wp5;*.wp6;*.wpd;*.wpp" << "wp";
+     QTest::newRow("oasis text mimetype") << "application/vnd.oasis.opendocument.text" << "*.odt" << "odt";
+     QTest::newRow("oasis presentation mimetype") << "application/vnd.oasis.opendocument.presentation" << "*.odp" << "odp";
+     QTest::newRow("mimetype with multiple patterns") << "text/plain" << "*.asc;*.txt;*,v" << "txt";
+diff --git a/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp b/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
+index 3e58dd03cc..c8f82ef5d5 100644
+--- a/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
++++ b/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
+@@ -176,6 +176,8 @@ private Q_SLOTS:
+     void fromToVariantConversions_data();
+     void fromToVariantConversions();
+ 
++    void noLeakOnNameClash();
++
+ private:
+     QString testDataDir;
+ };
+@@ -3685,5 +3687,23 @@ void tst_QtJson::fromToVariantConversions()
+     }
+ }
+ 
++void tst_QtJson::noLeakOnNameClash()
++{
++    QJsonDocument doc = QJsonDocument::fromJson("{\"\":{\"\":0},\"\":0}");
++    QVERIFY(!doc.isNull());
++    const QJsonObject obj = doc.object();
++
++    // Removed the duplicate key.
++    QCOMPARE(obj.length(), 1);
++
++    // Retained the last of the duplicates.
++    const QJsonValue val = obj.begin().value();
++    QVERIFY(val.isDouble());
++    QCOMPARE(val.toDouble(), 0.0);
++
++    // It should not leak.
++    // In particular it should not forget to deref the container for the inner object.
++}
++
+ QTEST_MAIN(tst_QtJson)
+ #include "tst_qtjson.moc"
+diff --git a/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp b/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
+index a59b58d57f..241c3e84ac 100644
+--- a/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
++++ b/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
+@@ -63,6 +63,7 @@ private slots:
+     void isValidId_data();
+     void isValidId();
+     void malformed();
++    void serialize();
+     // Backend tests
+     void utcTest();
+     void icuTest();
+@@ -947,6 +948,33 @@ void tst_QTimeZone::malformed()
+         barf.offsetFromUtc(now);
+ }
+ 
++void tst_QTimeZone::serialize()
++{
++    int parts = 0;
++#ifndef QT_NO_DEBUG_STREAM
++    qDebug() << QTimeZone(); // to verify no crash
++    parts++;
++#endif
++#ifndef QT_NO_DATASTREAM
++    QByteArray blob;
++    {
++        QDataStream stream(&blob, QIODevice::WriteOnly);
++        stream << QTimeZone("Europe/Oslo") << QTimeZone(420) << QTimeZone() << qint64(-1);
++    }
++    QDataStream stream(&blob, QIODevice::ReadOnly);
++    QTimeZone invalid, offset, oslo;
++    qint64 minusone;
++    stream >> oslo >> offset >> invalid >> minusone;
++    QCOMPARE(oslo, QTimeZone("Europe/Oslo"));
++    QCOMPARE(offset, QTimeZone(420));
++    QVERIFY(!invalid.isValid());
++    QCOMPARE(minusone, qint64(-1));
++    parts++;
++#endif
++    if (!parts)
++        QSKIP("No serialization enabled");
++}
++
+ void tst_QTimeZone::utcTest()
+ {
+ #ifdef QT_BUILD_INTERNAL
+diff --git a/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp b/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
+index 05480c6dd2..70f4c75756 100644
+--- a/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
++++ b/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
+@@ -324,6 +324,13 @@ void tst_QDBusInterface::notValid()
+ 
+     QVERIFY(!interface.isValid());
+     QVERIFY(!QMetaObject::invokeMethod(&interface, "ListNames", Qt::DirectConnection));
++
++    // With a connection, but empty/null service and path specified
++    QDBusConnection con = QDBusConnection::sessionBus();
++    QVERIFY(con.isConnected());
++    QDBusInterface iface({}, {}, {}, con);
++    QVERIFY(!iface.isValid());
++    QVERIFY(!QMetaObject::invokeMethod(&interface, "ListNames", Qt::DirectConnection));
+ }
+ 
+ void tst_QDBusInterface::notValidDerived()
+diff --git a/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp b/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
+index 874468c954..04ceb4ab65 100644
+--- a/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
++++ b/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
+@@ -507,6 +507,10 @@ void tst_QKeySequence::toStringFromKeycode_data()
+     QTest::newRow("Ctrl+Alt+Num+Del") << QKeySequence(Qt::ControlModifier | Qt::AltModifier | Qt::KeypadModifier | Qt::Key_Delete) << "Ctrl+Alt+Num+Del";
+     QTest::newRow("Ctrl+Ins") << QKeySequence(Qt::ControlModifier | Qt::Key_Insert) << "Ctrl+Ins";
+     QTest::newRow("Ctrl+Num+Ins(1)") << QKeySequence(Qt::Key_Insert | Qt::KeypadModifier | Qt::ControlModifier) << "Ctrl+Num+Ins";
++    QTest::newRow("Ctrl") << QKeySequence(Qt::Key_Control) << "Control";
++    QTest::newRow("Alt") << QKeySequence(Qt::Key_Alt) << "Alt";
++    QTest::newRow("Shift") << QKeySequence(Qt::Key_Shift) << "Shift";
++    QTest::newRow("Meta") << QKeySequence(Qt::Key_Meta) << "Meta";
+ }
+ 
+ void tst_QKeySequence::toStringFromKeycode()
+diff --git a/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp b/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+index 15e0ecadaa..b4eca74283 100644
+--- a/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
++++ b/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+@@ -81,6 +81,8 @@ private slots:
+     void registerOpenTypePreferredNamesSystem();
+     void registerOpenTypePreferredNamesApplication();
+ 
++    void stretchRespected();
++
+ private:
+     QString m_ledFont;
+     QString m_testFont;
+@@ -355,6 +357,28 @@ static QString testString()
+     return QStringLiteral("foo bar");
+ }
+ 
++void tst_QFontDatabase::stretchRespected()
++{
++    int italicId = QFontDatabase::addApplicationFont(m_testFontItalic);
++    QVERIFY(italicId != -1);
++
++    QVERIFY(!QFontDatabase::applicationFontFamilies(italicId).isEmpty());
++
++    QString italicFontName = QFontDatabase::applicationFontFamilies(italicId).first();
++
++    QFont italicFont = QFontDatabase().font(italicFontName,
++                                            QString::fromLatin1("Italic"), 14);
++    QVERIFY(italicFont.italic());
++
++    QFont italicStretchedFont = italicFont;
++    italicStretchedFont.setStretch( 400 );
++
++    QVERIFY(QFontMetricsF(italicFont).horizontalAdvance(QStringLiteral("foobar")) <
++            QFontMetricsF(italicStretchedFont).horizontalAdvance(QStringLiteral("foobar")));
++
++    QFontDatabase::removeApplicationFont(italicId);
++}
++
+ void tst_QFontDatabase::condensedFontWidthNoFontMerging()
+ {
+     int regularFontId = QFontDatabase::addApplicationFont(m_testFont);
+diff --git a/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+index 3d4a094c43..b423e11a99 100644
+--- a/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
++++ b/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+@@ -281,6 +281,7 @@ private Q_SLOTS:
+     void ioGetFromFileSpecial();
+     void ioGetFromFile_data();
+     void ioGetFromFile();
++    void ioGetFromFileUrl();
+     void ioGetFromFtp_data();
+     void ioGetFromFtp();
+     void ioGetFromFtpWithReuse();
+@@ -3300,6 +3301,18 @@ void tst_QNetworkReply::ioGetFromFile()
+     QCOMPARE(reader.data, data);
+ }
+ 
++void tst_QNetworkReply::ioGetFromFileUrl()
++{
++    // This immediately fails on non-windows platforms:
++    QNetworkRequest request(QUrl("file://unc-server/some/path"));
++    QNetworkReplyPtr reply(manager.get(request));
++    QSignalSpy finishedSpy(reply.get(), &QNetworkReply::finished);
++    // QTBUG-105618: This would, on non-Windows platforms, never happen because the signal
++    // was emitted before the constructor finished, leaving no chance at all to connect to the
++    // signal
++    QVERIFY(finishedSpy.wait());
++}
++
+ void tst_QNetworkReply::ioGetFromFtp_data()
+ {
+     QTest::addColumn<QString>("fileName");
+diff --git a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
+index 069fa6b341..4cc4d9a5ea 100644
+--- a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
++++ b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
+@@ -1,75 +1,34 @@
+-Certificate:
+-    Data:
+-        Version: 3 (0x2)
+-        Serial Number: 0 (0x0)
+-        Signature Algorithm: sha1WithRSAEncryption
+-        Issuer: C=NO, ST=Oslo, L=Nydalen, O=Nokia Corporation and/or its subsidiary(-ies), OU=Development, CN=fluke.troll.no/emailAddress=ahanssen@trolltech.com
+-        Validity
+-            Not Before: Dec  4 01:10:32 2007 GMT
+-            Not After : Apr 21 01:10:32 2035 GMT
+-        Subject: C=NO, ST=Oslo, O=Nokia Corporation and/or its subsidiary(-ies), OU=Development, CN=fluke.troll.no
+-        Subject Public Key Info:
+-            Public Key Algorithm: rsaEncryption
+-            RSA Public Key: (1024 bit)
+-                Modulus (1024 bit):
+-                    00:a7:c8:a0:4a:c4:19:05:1b:66:ba:32:e2:d2:f1:
+-                    1c:6f:17:82:e4:39:2e:01:51:90:db:04:34:32:11:
+-                    21:c2:0d:6f:59:d8:53:90:54:3f:83:8f:a9:d3:b3:
+-                    d5:ee:1a:9b:80:ae:c3:25:c9:5e:a5:af:4b:60:05:
+-                    aa:a0:d1:91:01:1f:ca:04:83:e3:58:1c:99:32:45:
+-                    84:70:72:58:03:98:4a:63:8b:41:f5:08:49:d2:91:
+-                    02:60:6b:e4:64:fe:dd:a0:aa:74:08:e9:34:4c:91:
+-                    5f:12:3d:37:4d:54:2c:ad:7f:5b:98:60:36:02:8c:
+-                    3b:f6:45:f3:27:6a:9b:94:9d
+-                Exponent: 65537 (0x10001)
+-        X509v3 extensions:
+-            X509v3 Basic Constraints: 
+-                CA:FALSE
+-            Netscape Comment: 
+-                OpenSSL Generated Certificate
+-            X509v3 Subject Key Identifier: 
+-                21:85:04:3D:23:01:66:E5:F7:9F:1A:84:24:8A:AF:0A:79:F4:E5:AC
+-            X509v3 Authority Key Identifier: 
+-                DirName:/C=NO/ST=Oslo/L=Nydalen/O=Nokia Corporation and/or its subsidiary(-ies)/OU=Development/CN=fluke.troll.no/emailAddress=ahanssen@trolltech.com
+-                serial:8E:A8:B4:E8:91:B7:54:2E
+-
+-    Signature Algorithm: sha1WithRSAEncryption
+-        6d:57:5f:d1:05:43:f0:62:05:ec:2a:71:a5:dc:19:08:f2:c4:
+-        a6:bd:bb:25:d9:ca:89:01:0e:e4:cf:1f:c1:8c:c8:24:18:35:
+-        53:59:7b:c0:43:b4:32:e6:98:b2:a6:ef:15:05:0b:48:5f:e1:
+-        a0:0c:97:a9:a1:77:d8:35:18:30:bc:a9:8f:d3:b7:54:c7:f1:
+-        a9:9e:5d:e6:19:bf:f6:3c:5b:2b:d8:e4:3e:62:18:88:8b:d3:
+-        24:e1:40:9b:0c:e6:29:16:62:ab:ea:05:24:70:36:aa:55:93:
+-        ef:02:81:1b:23:10:a2:04:eb:56:95:75:fc:f8:94:b1:5d:42:
+-        c5:3f:36:44:85:5d:3a:2e:90:46:8a:a2:b9:6f:87:ae:0c:15:
+-        40:19:31:90:fc:3b:25:bb:ae:f1:66:13:0d:85:90:d9:49:34:
+-        8f:f2:5d:f9:7a:db:4d:5d:27:f6:76:9d:35:8c:06:a6:4c:a3:
+-        b1:b2:b6:6f:1d:d7:a3:00:fd:72:eb:9e:ea:44:a1:af:21:34:
+-        7d:c7:42:e2:49:91:19:8b:c0:ad:ba:82:80:a8:71:70:f4:35:
+-        31:91:63:84:20:95:e9:60:af:64:8b:cc:ff:3d:8a:76:74:3d:
+-        c8:55:6d:e4:8e:c3:2b:1c:e8:42:18:ae:9f:e6:6b:9c:34:06:
+-        ec:6a:f2:c3
+ -----BEGIN CERTIFICATE-----
+-MIIEEzCCAvugAwIBAgIBADANBgkqhkiG9w0BAQUFADCBnDELMAkGA1UEBhMCTk8x
+-DTALBgNVBAgTBE9zbG8xEDAOBgNVBAcTB055ZGFsZW4xFjAUBgNVBAoTDVRyb2xs
+-dGVjaCBBU0ExFDASBgNVBAsTC0RldmVsb3BtZW50MRcwFQYDVQQDEw5mbHVrZS50
+-cm9sbC5ubzElMCMGCSqGSIb3DQEJARYWYWhhbnNzZW5AdHJvbGx0ZWNoLmNvbTAe
+-Fw0wNzEyMDQwMTEwMzJaFw0zNTA0MjEwMTEwMzJaMGMxCzAJBgNVBAYTAk5PMQ0w
+-CwYDVQQIEwRPc2xvMRYwFAYDVQQKEw1Ucm9sbHRlY2ggQVNBMRQwEgYDVQQLEwtE
+-ZXZlbG9wbWVudDEXMBUGA1UEAxMOZmx1a2UudHJvbGwubm8wgZ8wDQYJKoZIhvcN
+-AQEBBQADgY0AMIGJAoGBAKfIoErEGQUbZroy4tLxHG8XguQ5LgFRkNsENDIRIcIN
+-b1nYU5BUP4OPqdOz1e4am4CuwyXJXqWvS2AFqqDRkQEfygSD41gcmTJFhHByWAOY
+-SmOLQfUISdKRAmBr5GT+3aCqdAjpNEyRXxI9N01ULK1/W5hgNgKMO/ZF8ydqm5Sd
+-AgMBAAGjggEaMIIBFjAJBgNVHRMEAjAAMCwGCWCGSAGG+EIBDQQfFh1PcGVuU1NM
+-IEdlbmVyYXRlZCBDZXJ0aWZpY2F0ZTAdBgNVHQ4EFgQUIYUEPSMBZuX3nxqEJIqv
+-Cnn05awwgbsGA1UdIwSBszCBsKGBoqSBnzCBnDELMAkGA1UEBhMCTk8xDTALBgNV
+-BAgTBE9zbG8xEDAOBgNVBAcTB055ZGFsZW4xFjAUBgNVBAoTDVRyb2xsdGVjaCBB
+-U0ExFDASBgNVBAsTC0RldmVsb3BtZW50MRcwFQYDVQQDEw5mbHVrZS50cm9sbC5u
+-bzElMCMGCSqGSIb3DQEJARYWYWhhbnNzZW5AdHJvbGx0ZWNoLmNvbYIJAI6otOiR
+-t1QuMA0GCSqGSIb3DQEBBQUAA4IBAQBtV1/RBUPwYgXsKnGl3BkI8sSmvbsl2cqJ
+-AQ7kzx/BjMgkGDVTWXvAQ7Qy5piypu8VBQtIX+GgDJepoXfYNRgwvKmP07dUx/Gp
+-nl3mGb/2PFsr2OQ+YhiIi9Mk4UCbDOYpFmKr6gUkcDaqVZPvAoEbIxCiBOtWlXX8
+-+JSxXULFPzZEhV06LpBGiqK5b4euDBVAGTGQ/Dslu67xZhMNhZDZSTSP8l35ettN
+-XSf2dp01jAamTKOxsrZvHdejAP1y657qRKGvITR9x0LiSZEZi8CtuoKAqHFw9DUx
+-kWOEIJXpYK9ki8z/PYp2dD3IVW3kjsMrHOhCGK6f5mucNAbsavLD
++MIIF6zCCA9OgAwIBAgIUfo9amJtJGWqWE6f+SkAO85zkGr4wDQYJKoZIhvcNAQEL
++BQAwgYMxCzAJBgNVBAYTAk5PMQ0wCwYDVQQIDARPc2xvMQ0wCwYDVQQHDARPc2xv
++MRcwFQYDVQQKDA5UaGUgUXQgQ29tcGFueTEMMAoGA1UECwwDUiZEMRIwEAYDVQQD
++DAlIMiBUZXN0ZXIxGzAZBgkqhkiG9w0BCQEWDG1pbmltaUBxdC5pbzAgFw0yMDEw
++MjYxMjAxMzFaGA8yMTIwMTAwMjEyMDEzMVowgYMxCzAJBgNVBAYTAk5PMQ0wCwYD
++VQQIDARPc2xvMQ0wCwYDVQQHDARPc2xvMRcwFQYDVQQKDA5UaGUgUXQgQ29tcGFu
++eTEMMAoGA1UECwwDUiZEMRIwEAYDVQQDDAlIMiBUZXN0ZXIxGzAZBgkqhkiG9w0B
++CQEWDG1pbmltaUBxdC5pbzCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIB
++AOiUp5+E4blouKH7q+rVNR8NoYX2XkBW+q+rpy1zu5ssRSzbqxAjDx9dkht7Qlnf
++VlDT00JvpOWdeuPon5915edQRsY4Unl6mKH29ra3OtUa1/yCJXsGVJTKCj7k4Bxb
++5mZzb/fTlZntMLdTIBMfUbw62FKir1WjKIcJ9fCoG8JaGeKVO4Rh5p0ezd4UUUId
++r1BXl5Nqdqy2vTMsEDnjOsD3egkv8I2SKN4O6n/C3wWYpMOWYZkGoZiKz7rJs/i/
++ez7bsV7JlwdzTlhpJzkcOSVFBP6JlEOxTNNxZ1wtKy7PtZGmsSSATq2e6+bw38Ae
++Op0XnzzqcGjtDDofBmT7OFzZWjS9VZS6+DOOe2QHWle1nCHcHyH4ku6IRlsr9xkR
++NAIlOfnvHHxqJUenoeaZ4oQDjCBKS1KXygJO/tL7BLTQVn/xK1EmPvKNnjzWk4tR
++PnibUhhs5635qpOU/YPqFBh1JjVruZbsWcDAhRcew0uxONXOa9E+4lttQ9ySYa1A
++LvWqJuAX7gu2BsBMLyqfm811YnA7CIFMyO+HlqmkLFfv5L/xIRAXR7l26YGO0VwX
++CGjMfz4NVPMMke4nB7qa9NkpXQBQKMms3Qzd5JW0Hy9Ruj5O8GPcFZmV0twjd1uJ
++PD/cAjkWLaXjdNsJ16QWc2nghQRS6HYqKRX6j+CXOxupAgMBAAGjUzBRMB0GA1Ud
++DgQWBBRSCOU58j9NJZkMamt623qyCrhN3TAfBgNVHSMEGDAWgBRSCOU58j9NJZkM
++amt623qyCrhN3TAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4ICAQCq
++q4jxsWeNDv5Nq14hJtF9HB+ZL64zcZtRjJP1YgNs0QppKICmjPOL2nIMGmI/jKrs
++0eGAL/9XXNVHPxm1OPOncvimMMmU6emZfpMdEtTfKP43+Pg9HgKRjLoQp406vGeQ
++8ki/mbBhrItVPgEm3tu2AFA02XTYi+YxCI9kRZLGkM3FbgtOuTLPl0Z9y+kiPc9F
++uCSC03anBEqv+vDSI8+wODymQ/IJ3Jyz1lxIRDfp4qAekmy0jU2c91VOHHEmOmqq
++kqygGFRdwbe99m9yP63r6q0b5K3X2UnJ6bns0hmTwThYwpVPXLU8jdaTddbMukN2
++/Ef96Tsw8nWOEOPMySHOTIPgwyZRp26b0kA9EmhLwOP401SxXVQCmSRmtwNagmtg
++jJKmZoYBN+//D45ibK8z6Q0oOm9P+Whf/uUXehcRxBxyV3xz7k0wKGQbHj/ddwcy
++IUoIN4lrAlib+lK170kTKN352PDmrpo2gmIzPEsfurKAIMSelDl6H+kih16BtZ8y
++Nz6fh9Soqrg3OSAware8pxV7k51crBMoPLN78KoRV8MFCK4K7Fddq4rRISq6hiXq
++r1nsjoEPuKM9huprmZVZe9t5YcDa2I+wb3IiE3uwpZbAdaLDyQ5n6F/qpsiIkZXn
++gtcF7oqpG5oYrwCcZ53y/ezUgUg7PlSz2XwAGvQtgg==
+ -----END CERTIFICATE-----
+diff --git a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
+index 9d1664d609..337ce541a6 100644
+--- a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
++++ b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
+@@ -1,15 +1,52 @@
+------BEGIN RSA PRIVATE KEY-----
+-MIICXAIBAAKBgQCnyKBKxBkFG2a6MuLS8RxvF4LkOS4BUZDbBDQyESHCDW9Z2FOQ
+-VD+Dj6nTs9XuGpuArsMlyV6lr0tgBaqg0ZEBH8oEg+NYHJkyRYRwclgDmEpji0H1
+-CEnSkQJga+Rk/t2gqnQI6TRMkV8SPTdNVCytf1uYYDYCjDv2RfMnapuUnQIDAQAB
+-AoGANFzLkanTeSGNFM0uttBipFT9F4a00dqHz6JnO7zXAT26I5r8sU1pqQBb6uLz
+-/+Qz5Zwk8RUAQcsMRgJetuPQUb0JZjF6Duv24hNazqXBCu7AZzUenjafwmKC/8ri
+-KpX3fTwqzfzi//FKGgbXQ80yykSSliDL3kn/drATxsLCgQECQQDXhEFWLJ0vVZ1s
+-1Ekf+3NITE+DR16X+LQ4W6vyEHAjTbaNWtcTKdAWLA2l6N4WAAPYSi6awm+zMxx4
+-VomVTsjdAkEAx0z+e7natLeFcrrq8pbU+wa6SAP1VfhQWKitxL1e7u/QO90NCpxE
+-oQYKzMkmmpOOFjQwEMAy1dvFMbm4LHlewQJAC/ksDBaUcQHHqjktCtrUb8rVjAyW
+-A8lscckeB2fEYyG5J6dJVaY4ClNOOs5yMDS2Afk1F6H/xKvtQ/5CzInA/QJATDub
+-K+BPU8jO9q+gpuIi3VIZdupssVGmCgObVCHLakG4uO04y9IyPhV9lA9tALtoIf4c
+-VIvv5fWGXBrZ48kZAQJBAJmVCdzQxd9LZI5vxijUCj5EI4e+x5DRqVUvyP8KCZrC
+-AiNyoDP85T+hBZaSXK3aYGpVwelyj3bvo1GrTNwNWLw=
+------END RSA PRIVATE KEY-----
++-----BEGIN PRIVATE KEY-----
++MIIJQgIBADANBgkqhkiG9w0BAQEFAASCCSwwggkoAgEAAoICAQDolKefhOG5aLih
+++6vq1TUfDaGF9l5AVvqvq6ctc7ubLEUs26sQIw8fXZIbe0JZ31ZQ09NCb6TlnXrj
++6J+fdeXnUEbGOFJ5epih9va2tzrVGtf8giV7BlSUygo+5OAcW+Zmc2/305WZ7TC3
++UyATH1G8OthSoq9VoyiHCfXwqBvCWhnilTuEYeadHs3eFFFCHa9QV5eTanastr0z
++LBA54zrA93oJL/CNkijeDup/wt8FmKTDlmGZBqGYis+6ybP4v3s+27FeyZcHc05Y
++aSc5HDklRQT+iZRDsUzTcWdcLSsuz7WRprEkgE6tnuvm8N/AHjqdF5886nBo7Qw6
++HwZk+zhc2Vo0vVWUuvgzjntkB1pXtZwh3B8h+JLuiEZbK/cZETQCJTn57xx8aiVH
++p6HmmeKEA4wgSktSl8oCTv7S+wS00FZ/8StRJj7yjZ481pOLUT54m1IYbOet+aqT
++lP2D6hQYdSY1a7mW7FnAwIUXHsNLsTjVzmvRPuJbbUPckmGtQC71qibgF+4LtgbA
++TC8qn5vNdWJwOwiBTMjvh5appCxX7+S/8SEQF0e5dumBjtFcFwhozH8+DVTzDJHu
++Jwe6mvTZKV0AUCjJrN0M3eSVtB8vUbo+TvBj3BWZldLcI3dbiTw/3AI5Fi2l43Tb
++CdekFnNp4IUEUuh2KikV+o/glzsbqQIDAQABAoICAFw1q6tr5I48vY7DF+rXsuLn
++5ZUWE1IQ6fzB4lr72nJv/9EEGnMgYzt9PpMUsD6vdCpBgS2C0+6RHArFzJtNA+RM
++iHLIG7K7702veyr/xBx/MwiSlMeMv/XpkFxVI6E6skMGG2s3AMXxKvJTy5CpRx+I
++eQFyLG+Ya1X2lgJes/q+/CpAHkOjCOpcLySQC5NZ74q734V7nSdmn+Zs3tYEh+O/
++eiuwTP/j5b38Te5vVTqDxTciJPmljmXLCwa0N100lWlbcpvw8qbqiTI2Jm3XCbUE
++AzHjW9vmrF3cRS1fXxKFGShw3SRqlkbxjfeWoi8qDPUBS4m8LOr8qG9Wo5Nfon0z
++zLP4bci3zHDvVcaaZrrsUBs/yZbg+Dgka1DmX7ekmeccr2yTdKDFgPupYUyxVbTl
++a9ZLJysjFD7rgBv1ZclHonLp6Vbm+ZoTqvteo4ikAy6L9RtBWJ23XEK34PkP/+c5
++2vWZaOrnjSeBHbFce8cdJSxqWpP+eSCI5I9XbDrYFIsQ/gqKgtzDKy2ihJ2Y8STL
++yO4hyFPFjxc+Gg4/P2PpmT5CY2ty44M0BWs+JGW96CJPrrplf2lmQUQJj5LZY66X
++Z/4C9L7ZYtKZ+bs5SvU46yWugAvQZX22Xm9xLXWyVXRdx3bj+3M3fDnF9di/zdbh
++CgLx7oWPNrXc7FCajnn9AoIBAQD5FMYwRpw9NWT9WDxQwx+cSI4Icbd88ByTW63S
++LzeRwZA0J9/SfwO+aBRupzc9GkGXCiZcGMw3AGsCtig8yFlw8E5KnzN7KlftDMnM
++9NUxxzlR8VwKyLnZfG7sDTl057ZlUujnqhmt/F8F7dIy7FVO1dE/8nngA+FYTCOG
++UZdGjwyBDlDM0JJdUWGY3xslutcpCDN5mzSTKjy9drMvImAshRawxRF6WBpn7vr2
++nC6vciqfx1Mzx1vyk0Jm0ilaydDdLMADjt/iL4Nkr0BEs4k+UzQiKDwp8gu7abQ1
++eBfxd9Iar4htQa2I1Ewl6P01G/q+ZYwgHhJ9RVn4AxQXefILAoIBAQDvCouORdQX
++C8wsyp7MwXlF/3NQeNN5/+B2mhbxrBOf7PmMCXLnkRWcjwJtzypWFqJ0sqai/2+0
++bqbMcjX5maT8stT2shl3zXe/Ejt2e3TBYpc1tyuses8Kb5BMU8hu6tTd3G2CMXpD
++dT6DVemJZCTtwj9aBNIxSizvlgMolJnCpzhPnlfHSI6E+g3m/LTTo3HwbjMSw/Uq
++irgjOpI2wSBB6LZPSgjvfcYPRyWUk16L4A5uSX0cADnovDFLa5/h0wJvN/OoCSQg
++rLCXG5E18EyL5Wc58BCY1ZvxmjG3lQtgPxYu2Jwc36R/y/JKlxW5suER5ZNpbbD4
++uOyTt2VxMQ2bAoIBAQC5+MzRFqdo/AjfL5Y5JrbfVTzXCTDa09xCGd16ZU60QTWN
+++4ed/r+o1sUKqUcRFB2MzEM/2DQBjQpZB/CbEWvWa1XJWXxypXbowveZU+QqOnmN
++uQvj8WLyA3o+PNF9e9QvauwCrHpn8VpxbtPWuaYoKnUFreFZZQxHhPGxRBIS2JOZ
++eDrT8ZaWnkCkh1AZp5smQ71LOprSlmKrg4jd1GjCVMxQR5N5KXbtyv0OTCZ/UFqK
++2aRBsMPyJgkaBChkZPLRcKwc+/wlQRx1fHQb14DNTApMxoXFO7eOwqmOkpAt9iyl
++SBIwoS0UUI5ab88+bBmXNvKcuFdNuQ4nowTJUn9pAoIBADMNkILBXSvS5DeIyuO2
++Sp1tkoZUV+5NfPY3sMDK3KIibaW/+t+EOBZo4L7tKQCb8vRzl21mmsfxfgRaPDbj
++3r3tv9g0b4YLxxBy52pFscj/soXRai17SS7UZwA2QK+XzgDYbDcLNC6mIsTQG4Gx
++dsWk3/zs3KuUSQaehmwrWK+fIUK38c1pLK8v7LoxrLkqxlHwZ04RthHw8KTthH7X
++Pnl1J0LF8CSeOyfWLSuPUfkT0GEzptnNHpEbaHfQM6R6eaGhVJPF6AZme4y6YYgg
++m2ihhSt1n0XVEWpHYWjxFy3mK2mz75unFC4LM+NEY2p2zuUQoCw7NjnY3QYrfCnx
++rRMCggEAXeXsMSLFjjyuoL7iKbAxo52HD/P0fBoy58LyRcwfNVr0lvYan4pYEx+o
++KijIh9K16PqXZXKMA9v003B+ulmF8bJ7SddCZ5NGvnFhUTDe4DdTKgp2RuwQ3Bsc
++3skPIDbhVETyOLCtys34USHrq8U/0DlGY3eLRfxw9GnbKxSBGa/KEu/qQLPNUo50
++7xHZDg7GKeC3kqNJeqKM9rkp0VzIGkEnaD9127LeNDmERDfftxJzFoC/THvUBLfU
++6Sus2ZYwRE8VFvKC30Q45t/c54X3IuhYvAuiCuTmyfE4ruyzyOwKzhUkeeLq1APX
++g0veFbyfzlJ0q8qzD/iffqqIa2ZSmQ==
++-----END PRIVATE KEY-----
+diff --git a/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp b/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
+index 7ba3715e13..752aa122f6 100644
+--- a/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
++++ b/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
+@@ -179,6 +179,7 @@ void tst_QAccessibilityLinux::initTestCase()
+     QVERIFY(!address.isEmpty());
+ 
+     m_window = new AccessibleTestWindow();
++    m_window->setObjectName("mainWindow"_L1);
+     m_window->show();
+ 
+     QVERIFY(QTest::qWaitForWindowExposed(m_window));
+@@ -236,8 +237,11 @@ bool hasState(QDBusInterface *interface, AtspiStateType state)
+ void tst_QAccessibilityLinux::testLabel()
+ {
+     QLabel *l = new QLabel(m_window);
++    l->setObjectName("theObjectName"_L1);
+     l->setText("Hello A11y");
+     m_window->addWidget(l);
++    auto a11yEmpty = new QLabel(m_window);
++    m_window->addWidget(l);
+ 
+     // Application
+     QCOMPARE(getParent(mainWindow), QLatin1String(ATSPI_DBUS_PATH_ROOT));
+@@ -249,6 +253,8 @@ void tst_QAccessibilityLinux::testLabel()
+     QCOMPARE(getChildren(labelInterface).count(), 0);
+     QCOMPARE(labelInterface->call(QDBus::Block, "GetRoleName").arguments().first().toString(), QLatin1String("label"));
+     QCOMPARE(labelInterface->call(QDBus::Block, "GetRole").arguments().first().toUInt(), 29u);
++    QCOMPARE(labelInterface->call(QDBus::Block, "GetAccessibleId").arguments().first().toString(),
++             QLatin1String("mainWindow.theObjectName"));
+     QCOMPARE(getParent(labelInterface), mainWindow->path());
+     QVERIFY(!hasState(labelInterface, ATSPI_STATE_EDITABLE));
+     QVERIFY(hasState(labelInterface, ATSPI_STATE_READ_ONLY));
+@@ -256,7 +262,12 @@ void tst_QAccessibilityLinux::testLabel()
+     l->setText("New text");
+     QCOMPARE(labelInterface->property("Name").toString(), l->text());
+ 
++    auto *a11yEmptyInterface = getInterface(children.at(1), "org.a11y.atspi.Accessible");
++    QCOMPARE(a11yEmptyInterface->call(QDBus::Block, "GetAccessibleId").arguments().first().toString(),
++             QLatin1String("mainWindow.QLabel"));
++
+     m_window->clearChildren();
++    delete a11yEmptyInterface;
+     delete labelInterface;
+ }
+ 
+diff --git a/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+index 76df61c892..6d6d65b791 100644
+--- a/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
++++ b/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2022 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the test suite of the Qt Toolkit.
+@@ -68,6 +68,8 @@ private slots:
+     void query_exec();
+     void execErrorRecovery_data() { generic_data(); }
+     void execErrorRecovery();
++    void prematureExec_data() { generic_data(); }
++    void prematureExec();
+     void first_data() { generic_data(); }
+     void first();
+     void next_data() { generic_data(); }
+@@ -2770,6 +2772,35 @@ void tst_QSqlQuery::execErrorRecovery()
+     QVERIFY_SQL( q, exec() );
+ }
+ 
++void tst_QSqlQuery::prematureExec()
++{
++    QFETCH(QString, dbName);
++    // We only want the engine name, for addDatabase():
++    int cut = dbName.indexOf(QChar('@'));
++    if (cut < 0)
++        QSKIP("Failed to parse database type out of name");
++    dbName.truncate(cut);
++    cut = dbName.indexOf(QChar('_'));
++    if (cut >= 0)
++        dbName = dbName.mid(cut + 1);
++
++    auto db = QSqlDatabase::addDatabase(dbName);
++    QSqlQuery q(db);
++
++    QTest::ignoreMessage(QtWarningMsg,
++                         "QSqlDatabasePrivate::removeDatabase: connection "
++                         "'qt_sql_default_connection' is still in use, all "
++                         "queries will cease to work.");
++    QTest::ignoreMessage(QtWarningMsg,
++                         "QSqlDatabasePrivate::addDatabase: duplicate connection name "
++                         "'qt_sql_default_connection', old connection removed.");
++    auto otherDb = QSqlDatabase::addDatabase(dbName);
++
++    QTest::ignoreMessage(QtWarningMsg, "QSqlQuery::exec: called before driver has been set up");
++    // QTBUG-100037: shouldn't crash !
++    QVERIFY(!q.exec("select stuff from TheVoid"));
++}
++
+ void tst_QSqlQuery::lastInsertId()
+ {
+     QFETCH( QString, dbName );
+diff --git a/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp b/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
+index 4aa3f8d60b..d2050a61aa 100644
+--- a/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
++++ b/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
+@@ -115,6 +115,10 @@ void tst_QAbstractItemModelTester::standardItemModelZeroColumns()
+     // QTBUG-92886
+     model.insertRows(0, 5);
+     model.removeRows(1, 2);
++
++    const QModelIndex parentIndex = model.index(0, 0);
++    model.insertRows(0, 5, parentIndex);
++    model.removeRows(1, 2, parentIndex);
+ }
+ 
+ void tst_QAbstractItemModelTester::testInsertThroughProxy()
+diff --git a/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json b/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
+index 12a4a22a19..ce518e78fb 100644
+--- a/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
++++ b/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
+@@ -668,50 +668,6 @@
+         "inputFile": "task192552.h",
+         "outputRevision": 67
+     },
+-    {
+-        "classes": [
+-            {
+-                "className": "InlineSlotsWithThrowDeclaration",
+-                "object": true,
+-                "qualifiedClassName": "InlineSlotsWithThrowDeclaration",
+-                "slots": [
+-                    {
+-                        "access": "public",
+-                        "name": "a",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "b",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "c",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "d",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "e",
+-                        "returnType": "void"
+-                    }
+-                ],
+-                "superClasses": [
+-                    {
+-                        "access": "public",
+-                        "name": "QObject"
+-                    }
+-                ]
+-            }
+-        ],
+-        "inputFile": "task189996.h",
+-        "outputRevision": 67
+-    },
+     {
+         "classes": [
+             {
+diff --git a/qtbase/tests/auto/tools/moc/moc.pro b/qtbase/tests/auto/tools/moc/moc.pro
+index c324b3a8cd..4aceb78dc0 100644
+--- a/qtbase/tests/auto/tools/moc/moc.pro
++++ b/qtbase/tests/auto/tools/moc/moc.pro
+@@ -15,7 +15,7 @@ cross_compile: DEFINES += MOC_CROSS_COMPILED
+ HEADERS += using-namespaces.h no-keywords.h task87883.h c-comments.h backslash-newlines.h oldstyle-casts.h \
+            slots-with-void-template.h qinvokable.h namespaced-flags.h trigraphs.h \
+            escapes-in-string-literals.h cstyle-enums.h qprivateslots.h gadgetwithnoenums.h \
+-           dir-in-include-path.h single_function_keyword.h task192552.h task189996.h \
++           dir-in-include-path.h single_function_keyword.h task192552.h \
+            task234909.h task240368.h pure-virtual-signals.h cxx11-enums.h \
+            cxx11-final-classes.h \
+            cxx11-explicit-override-control.h \
+diff --git a/qtbase/tests/auto/tools/moc/task189996.h b/qtbase/tests/auto/tools/moc/task189996.h
+deleted file mode 100644
+index f94a051b3a..0000000000
+--- a/qtbase/tests/auto/tools/moc/task189996.h
++++ /dev/null
+@@ -1,47 +0,0 @@
+-/****************************************************************************
+-**
+-** Copyright (C) 2016 The Qt Company Ltd.
+-** Contact: https://www.qt.io/licensing/
+-**
+-** This file is part of the test suite of the Qt Toolkit.
+-**
+-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+-** 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 General Public License Usage
+-** Alternatively, this file may be used under the terms of the GNU
+-** General Public License version 3 as published by the Free Software
+-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+-** 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-3.0.html.
+-**
+-** $QT_END_LICENSE$
+-**
+-****************************************************************************/
+-// inline functions can have throw declarations
+-
+-#ifndef TASK189996_H
+-#define TASK189996_H
+-
+-#include <QObject>
+-
+-class InlineSlotsWithThrowDeclaration : public QObject
+-{
+-    Q_OBJECT
+-
+-public slots:
+-    void a() throw() { }
+-    void b() const throw() { }
+-    void c() throw();
+-    void d() throw(int) { }
+-    void e() const throw(int,double) { }
+-};
+-
+-#endif
+diff --git a/qtbase/tests/auto/tools/moc/tst_moc.cpp b/qtbase/tests/auto/tools/moc/tst_moc.cpp
+index c716aead21..15dd9e41e5 100644
+--- a/qtbase/tests/auto/tools/moc/tst_moc.cpp
++++ b/qtbase/tests/auto/tools/moc/tst_moc.cpp
+@@ -631,7 +631,6 @@ public:
+ private slots:
+     void initTestCase();
+ 
+-    void slotWithException() throw(MyStruct);
+     void dontStripNamespaces();
+     void oldStyleCasts();
+     void warnOnExtraSignalSlotQualifiaction();
+@@ -673,7 +672,6 @@ private slots:
+     void templateGtGt();
+     void qprivateslots();
+     void qprivateproperties();
+-    void inlineSlotsWithThrowDeclaration();
+     void warnOnPropertyWithoutREAD();
+     void constructors();
+     void typenameWithUnsigned();
+@@ -784,12 +782,6 @@ void tst_Moc::initTestCase()
+ #endif
+ }
+ 
+-void tst_Moc::slotWithException() throw(MyStruct)
+-{
+-    // be happy
+-    QVERIFY(true);
+-}
+-
+ void tst_Moc::dontStripNamespaces()
+ {
+     Sender sender;
+@@ -824,7 +816,7 @@ void tst_Moc::oldStyleCasts()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-Wold-style-cast" << "-I" << "."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -894,7 +886,7 @@ void tst_Moc::inputFileNameWithDotsButNoExtension()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-I" << ".."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -1174,7 +1166,7 @@ void tst_Moc::ignoreOptionClashes()
+     QStringList gccArgs;
+     gccArgs << "-c" << "-x" << "c++" << "-I" << ".."
+          << "-I" << qtIncludePath << "-I" << includeDir << "-o" << "/dev/null"
+-         << "-fPIC" << "-std=c++11" <<  "-";
++         << "-fPIC" << "-std=c++1z" <<  "-";
+     proc.start("gcc", gccArgs);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -1593,21 +1585,6 @@ void tst_Moc::qprivateproperties()
+ 
+ }
+ 
+-#include "task189996.h"
+-
+-void InlineSlotsWithThrowDeclaration::c() throw() {}
+-
+-void tst_Moc::inlineSlotsWithThrowDeclaration()
+-{
+-    InlineSlotsWithThrowDeclaration tst;
+-    const QMetaObject *mobj = tst.metaObject();
+-    QVERIFY(mobj->indexOfSlot("a()") != -1);
+-    QVERIFY(mobj->indexOfSlot("b()") != -1);
+-    QVERIFY(mobj->indexOfSlot("c()") != -1);
+-    QVERIFY(mobj->indexOfSlot("d()") != -1);
+-    QVERIFY(mobj->indexOfSlot("e()") != -1);
+-}
+-
+ void tst_Moc::warnOnPropertyWithoutREAD()
+ {
+ #ifdef MOC_CROSS_COMPILED
+@@ -1869,7 +1846,7 @@ void tst_Moc::notifyError()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-I" << "."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+diff --git a/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+index c355ee9665..88c09de8e0 100644
+--- a/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
++++ b/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+@@ -251,6 +251,7 @@ private slots:
+     void testResetCachedSizeHint();
+     void statusTips();
+     void testRemovingColumnsViaLayoutChanged();
++    void testModelMovingColumns();
+ 
+ protected:
+     void setupTestData(bool use_reset_model = false);
+@@ -360,6 +361,12 @@ public:
+         endRemoveColumns();
+     }
+ 
++    void moveColumn(int from, int to)
++    {
++        beginMoveColumns(QModelIndex(), from, from, QModelIndex(), to);
++        endMoveColumns();
++    }
++
+     void cleanup()
+     {
+         emit layoutAboutToBeChanged();
+@@ -3627,5 +3634,18 @@ void tst_QHeaderView::testRemovingColumnsViaLayoutChanged()
+     // The main point of this test is that the section-size restoring code didn't go out of bounds.
+ }
+ 
++void tst_QHeaderView::testModelMovingColumns()
++{
++    QtTestModel model(10, 10);
++    QHeaderView hv(Qt::Horizontal);
++    hv.setModel(&model);
++    hv.resizeSections(QHeaderView::ResizeToContents);
++    hv.show();
++
++    QPersistentModelIndex index3 = model.index(0, 3);
++    model.moveColumn(3, 1);
++    QCOMPARE(index3.column(), 1);
++}
++
+ QTEST_MAIN(tst_QHeaderView)
+ #include "tst_qheaderview.moc"
+diff --git a/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+index 761357b252..06bb706074 100644
+--- a/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
++++ b/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+@@ -397,6 +397,7 @@ private slots:
+     void checkHeaderMinSize();
+ 
+     void resizeToContents();
++    void resizeToContentsSpans();
+ 
+     void tabFocus();
+     void bigModel();
+@@ -3721,6 +3722,70 @@ void tst_QTableView::resizeToContents()
+ 
+ }
+ 
++
++class SpanModel : public QAbstractTableModel
++{
++public:
++    SpanModel(bool sectionsMoved)
++        : _sectionsMoved(sectionsMoved)
++    {}
++    int columnCount(const QModelIndex & = {}) const override { return 2; }
++    int rowCount(const QModelIndex & = {}) const override { return 1; }
++    QVariant data(const QModelIndex &idx, int role = Qt::DisplayRole) const override
++    {
++        if (role != Qt::DisplayRole)
++            return QVariant();
++        const int col = _sectionsMoved ? 1 - idx.column() : idx.column();
++        if (col == 0)
++            return "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.";
++        return QVariant();
++    }
++private:
++    bool _sectionsMoved;
++};
++
++
++void tst_QTableView::resizeToContentsSpans()
++{
++    SpanModel model1(false);
++    SpanModel model2(true);
++    QTableView view1, view2, view3;
++    view1.setModel(&model1);
++    view2.setModel(&model2);
++    view2.horizontalHeader()->moveSection(0, 1);
++    view3.setModel(&model1);
++
++    view1.setSpan(0, 0, 1, 2);
++    view2.setSpan(0, 1, 1, 2);
++    view1.show();
++    view2.show();
++    view3.show();
++    QVERIFY(QTest::qWaitForWindowExposed(&view1));
++    QVERIFY(QTest::qWaitForWindowExposed(&view2));
++    QVERIFY(QTest::qWaitForWindowExposed(&view3));
++    view1.setColumnWidth(0, 100);
++    view1.setColumnWidth(1, 100);
++    view2.setColumnWidth(0, 100);
++    view2.setColumnWidth(1, 100);
++    view3.setColumnWidth(0, 200);
++
++    view1.resizeRowToContents(0);
++    view2.resizeRowToContents(0);
++    view3.resizeRowToContents(0);
++    QCOMPARE(view1.rowHeight(0), view3.rowHeight(0));
++    QCOMPARE(view2.rowHeight(0), view3.rowHeight(0));
++
++    view3.resizeColumnToContents(0);
++    view3.resizeRowToContents(0);
++    // height should be only 1 text line for easy testing
++    view1.setRowHeight(0, view3.verticalHeader()->sectionSize(0));
++    view2.setRowHeight(0, view3.verticalHeader()->sectionSize(0));
++    view1.resizeColumnToContents(0);
++    view2.resizeColumnToContents(1);
++    QCOMPARE(view1.columnWidth(0), view3.columnWidth(0) - view1.columnWidth(1));
++    QCOMPARE(view2.columnWidth(0), view3.columnWidth(0) - view2.columnWidth(1));
++}
++
+ QT_BEGIN_NAMESPACE
+ extern bool Q_WIDGETS_EXPORT qt_tab_all_widgets(); // qapplication.cpp
+ QT_END_NAMESPACE
+diff --git a/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+index a3b8ef78d8..4955cebd5d 100644
+--- a/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
++++ b/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+@@ -1498,7 +1498,7 @@ void tst_QApplication::desktopSettingsAware()
+     environment += QLatin1String("QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM=1");
+     testProcess.setEnvironment(environment);
+ #endif
+-    testProcess.start("desktopsettingsaware_helper");
++    testProcess.start("./desktopsettingsaware_helper");
+     QVERIFY2(testProcess.waitForStarted(),
+              qPrintable(QString::fromLatin1("Cannot start 'desktopsettingsaware_helper': %1").arg(testProcess.errorString())));
+     QVERIFY(testProcess.waitForFinished(10000));
+@@ -2452,7 +2452,7 @@ void tst_QApplication::qtbug_12673()
+ #if QT_CONFIG(process)
+     QProcess testProcess;
+     QStringList arguments;
+-    testProcess.start("modal_helper", arguments);
++    testProcess.start("./modal_helper", arguments);
+     QVERIFY2(testProcess.waitForStarted(),
+              qPrintable(QString::fromLatin1("Cannot start 'modal_helper': %1").arg(testProcess.errorString())));
+     QVERIFY(testProcess.waitForFinished(20000));
+diff --git a/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp b/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
+index eb108a40de..dca5528c1b 100644
+--- a/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
+@@ -41,6 +41,7 @@
+ 
+ #include <private/qguiapplication_p.h>
+ #include <qpa/qplatformintegration.h>
++#include <qpa/qplatformtheme.h>
+ 
+ class tst_QAbstractButton : public QObject
+ {
+@@ -76,6 +77,8 @@ private slots:
+     void keyNavigation();
+ #endif
+ 
++    void buttonPressKeys();
++
+ protected slots:
+     void onClicked();
+     void onToggled( bool on );
+@@ -269,7 +272,13 @@ void tst_QAbstractButton::setAutoRepeat()
+         QCOMPARE(press_count, click_count);
+         QVERIFY(click_count > 1);
+         break;
+-    case 4:
++    case 4: {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(Qt::Key_Enter)) {
++            QSKIP("platform theme has Key_Enter in ButtonPressKeys");
++        }
+         // check that pressing ENTER has no effect when autorepeat is false
+         testWidget->setDown( false );
+         testWidget->setAutoRepeat( false );
+@@ -286,7 +295,14 @@ void tst_QAbstractButton::setAutoRepeat()
+ 
+         QVERIFY( click_count == 0 );
+         break;
+-    case 5:
++    }
++    case 5: {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(Qt::Key_Enter)) {
++            QSKIP("platform theme has Key_Enter in ButtonPressKeys");
++        }
+         // check that pressing ENTER has no effect when autorepeat is true
+         testWidget->setDown( false );
+         testWidget->setAutoRepeat( true );
+@@ -304,6 +320,7 @@ void tst_QAbstractButton::setAutoRepeat()
+ 
+         QVERIFY( click_count == 0 );
+         break;
++    }
+     case 6:
+         // verify autorepeat is off by default.
+         MyButton tmp( 0);
+@@ -651,5 +668,16 @@ void tst_QAbstractButton::keyNavigation()
+ }
+ #endif
+ 
++void tst_QAbstractButton::buttonPressKeys()
++{
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(testWidget, buttonPressKeys[i]);
++        QCOMPARE(click_count, i + 1);
++    }
++}
++
+ QTEST_MAIN(tst_QAbstractButton)
+ #include "tst_qabstractbutton.moc"
+diff --git a/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+index 32437050f5..46b5af6d63 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+@@ -168,6 +168,7 @@ private slots:
+     void checkMenuItemPosWhenStyleSheetIsSet();
+     void checkEmbeddedLineEditWhenStyleSheetIsSet();
+     void propagateStyleChanges();
++    void buttonPressKeys();
+ 
+ private:
+     PlatformInputContext m_platformInputContext;
+@@ -1682,6 +1683,16 @@ void tst_QComboBox::setModel()
+     QCOMPARE(box.rootModelIndex(), rootModelIndex);
+     box.setModel(box.model());
+     QCOMPARE(box.rootModelIndex(), rootModelIndex);
++
++    // check that setting the same model as the completer's doesn't crash
++    QCompleter *completer = new QCompleter(&box);
++    box.setEditable(true);
++    box.setCompleter(completer);
++    auto *listModel = new QStringListModel({ "one", "two" }, completer);
++    completer->setModel(listModel);
++    QCOMPARE(listModel->rowCount(), 2); // make sure it wasn't deleted
++    box.setModel(listModel);
++    QCOMPARE(listModel->rowCount(), 2); // make sure it wasn't deleted
+ }
+ 
+ void tst_QComboBox::setCustomModelAndView()
+@@ -3632,5 +3643,24 @@ void tst_QComboBox::propagateStyleChanges()
+     QVERIFY(frameStyle.inquired);
+ }
+ 
++void tst_QComboBox::buttonPressKeys()
++{
++    QComboBox comboBox;
++    comboBox.setEditable(false);
++    comboBox.addItem(QString::number(1));
++    comboBox.addItem(QString::number(2));
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(&comboBox, buttonPressKeys[i]);
++        // On some platforms, a window will not be immediately visible,
++        // but take some event-loop iterations to complete.
++        // Using QTRY_VERIFY to deal with that.
++        QTRY_VERIFY(comboBox.view()->isVisible());
++        comboBox.hidePopup();
++    }
++}
++
+ QTEST_MAIN(tst_QComboBox)
+ #include "tst_qcombobox.moc"
+diff --git a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
+index be3cfcd104..c228fdfcca 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
++++ b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qcommandlinkbutton
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qcommandlinkbutton.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
+index 0044d33c66..4cf06296e4 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
+@@ -40,6 +40,9 @@
+ #include <QGridLayout>
+ #include <QPainter>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ class tst_QCommandLinkButton : public QObject
+ {
+     Q_OBJECT
+@@ -223,6 +226,13 @@ void tst_QCommandLinkButton::setAutoRepeat()
+     // check that pressing ENTER has no effect
+     resetCounters();
+     testWidget->setDown( false );
++    // Skip after reset if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
+     testWidget->setAutoRepeat( false );
+     QTest::keyPress( testWidget, Qt::Key_Enter );
+ 
+@@ -255,6 +265,14 @@ void tst_QCommandLinkButton::pressed()
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+ 
++    // Skip if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
++
+     QTest::keyPress( testWidget,Qt::Key_Enter );
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+diff --git a/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro b/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
+index 4a5e76ff65..a235fa1fac 100644
+--- a/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
++++ b/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qgroupbox
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qgroupbox.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp b/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
+index 4fb5d262ca..d8d7562b73 100644
+--- a/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
+@@ -35,6 +35,9 @@
+ #include <QRadioButton>
+ #include <QDialog>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ #include "qgroupbox.h"
+ 
+ class tst_QGroupBox : public QObject
+@@ -69,6 +72,7 @@ private slots:
+     void propagateFocus();
+     void task_QTBUG_19170_ignoreMouseReleaseEvent();
+     void task_QTBUG_15519_propagateMouseEvents();
++    void buttonPressKeys();
+ 
+ private:
+     bool checked;
+@@ -610,6 +614,20 @@ void tst_QGroupBox::task_QTBUG_15519_propagateMouseEvents()
+     QCOMPARE(parent.mouseMoved, true);
+ }
+ 
++void tst_QGroupBox::buttonPressKeys()
++{
++    QGroupBox groupBox;
++    groupBox.setCheckable(true);
++    QSignalSpy clickedSpy(&groupBox, &QGroupBox::clicked);
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(&groupBox, buttonPressKeys[i]);
++        QCOMPARE(clickedSpy.length(), i + 1);
++    }
++}
++
+ void tst_QGroupBox::sendMouseMoveEvent(QWidget *widget, const QPoint &localPos)
+ {
+     // Send a MouseMove event without actually moving the pointer
+diff --git a/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro b/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
+index 353ad06ca2..e55f6148f2 100644
+--- a/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
++++ b/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qpushbutton
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qpushbutton.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp b/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
+index e818514a79..4043e9326a 100644
+--- a/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
+@@ -41,6 +41,9 @@
+ #include <QStyleFactory>
+ #include <QTabWidget>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ class tst_QPushButton : public QObject
+ {
+ Q_OBJECT
+@@ -212,6 +215,13 @@ void tst_QPushButton::autoRepeat()
+     // check that pressing ENTER has no effect
+     resetCounters();
+     testWidget->setDown( false );
++    // Skip after reset if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
+     testWidget->setAutoRepeat( false );
+     QTest::keyPress( testWidget, Qt::Key_Enter );
+ 
+@@ -247,6 +257,14 @@ void tst_QPushButton::pressed()
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+ 
++    // Skip if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
++
+     QTest::keyPress( testWidget,Qt::Key_Enter );
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+diff --git a/qtbase/tests/manual/rhi/cubemap_render/buildshader.bat b/qtbase/tests/manual/rhi/cubemap_render/buildshader.bat
+old mode 100755
+new mode 100644
+Submodule qtconnectivity e957d481..056294c0:
+diff --git a/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp b/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
+index e2635fae..a8b8e3b9 100644
+--- a/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
++++ b/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
+@@ -563,9 +563,11 @@ void HciManager::handleHciAclPacket(const quint8 *data, int size)
+ 
+ void HciManager::handleLeMetaEvent(const quint8 *data)
+ {
+-    // Spec v4.2, Vol 2, part E, 7.7.65ff
++    // Spec v5.3, Vol 4, part E, 7.7.65.*
+     switch (*data) {
+-    case 0x1: {
++    case 0x1: // HCI_LE_Connection_Complete
++    case 0xA: // HCI_LE_Enhanced_Connection_Complete
++    {
+         const quint16 handle = bt_get_le16(data + 2);
+         emit connectionComplete(handle);
+         break;
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp b/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
+index 6a93143b..4a18cfc7 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
+@@ -320,7 +320,10 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_finishSdpScan(QBluetoothServiceD
+             for (const QBluetoothUuid &id : serviceClassUuids) {
+                 if (id.minimumSize() == 16) {
+                     serviceInfo.setServiceUuid(id);
+-                    serviceInfo.setServiceName(QBluetoothServiceDiscoveryAgent::tr("Custom Service"));
++                    if (serviceInfo.serviceName().isEmpty()) {
++                        serviceInfo.setServiceName(
++                                    QBluetoothServiceDiscoveryAgent::tr("Custom Service"));
++                    }
+                     QBluetoothServiceInfo::Sequence modSeq =
+                             serviceInfo.attribute(QBluetoothServiceInfo::ServiceClassIds).value<QBluetoothServiceInfo::Sequence>();
+                     modSeq.removeOne(QVariant::fromValue(id));
+@@ -334,8 +337,10 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_finishSdpScan(QBluetoothServiceD
+                 qCDebug(QT_BT_BLUEZ) << "Discovered services" << discoveredDevices.at(0).address().toString()
+                                      << serviceInfo.serviceName() << serviceInfo.serviceUuid()
+                                      << ">>>" << serviceInfo.serviceClassUuids();
+-
+-                emit q->serviceDiscovered(serviceInfo);
++                // Use queued connection to allow us finish the service looping; the application
++                // might call stop() when it has detected the service-of-interest.
++                QMetaObject::invokeMethod(q, "serviceDiscovered", Qt::QueuedConnection,
++                                          Q_ARG(QBluetoothServiceInfo, serviceInfo));
+             }
+         }
+     }
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp b/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
+index e4d85447..aadd4755 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
+@@ -593,7 +593,7 @@ void QBluetoothSocket::setSocketState(QBluetoothSocket::SocketState state)
+ bool QBluetoothSocket::canReadLine() const
+ {
+     Q_D(const QBluetoothSocketBase);
+-    return d->canReadLine();
++    return d->canReadLine() || QIODevice::canReadLine();
+ }
+ 
+ /*!
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp b/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
+index 084aa958..d6aa17a7 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
+@@ -284,6 +284,10 @@ void QBluetoothSocketPrivateBluezDBus::connectToService(
+         return;
+     }
+ 
++    if (service.socketProtocol() != QBluetoothServiceInfo::Protocol::UnknownProtocol)
++        socketType = service.socketProtocol();
++    qCDebug(QT_BT_BLUEZ) << "Socket protocol used:" << socketType;
++
+     connectToService(service.device().address(), targetService, openMode);
+ }
+ 
+diff --git a/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp b/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
+index 05bc1a0f..a7b5ef1f 100644
+--- a/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
++++ b/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
+@@ -142,7 +142,7 @@ void tst_QBluetoothSocket::initTestCase()
+     qDebug() << "Starting discovery";
+ 
+     sda->setUuidFilter(QBluetoothUuid(QString(TEST_SERVICE_UUID)));
+-    sda->start(QBluetoothServiceDiscoveryAgent::MinimalDiscovery);
++    sda->start(QBluetoothServiceDiscoveryAgent::FullDiscovery);
+ 
+     for (int connectTime = MaxConnectTime; !done_discovery && connectTime > 0; connectTime -= 1000)
+         QTest::qWait(1000);
+Submodule qtdeclarative f5701f0d..8defe7bf:
+diff --git a/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h b/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
+index b65b994d6c..15a8cd6878 100644
+--- a/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
++++ b/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
+@@ -86,7 +86,7 @@ public:
+         if (QTypeInfo<T>::isComplex) {
+             for (int i = 0; i < count; ++i)
+                 new (data + i) T(vector.at(i));
+-        } else {
++        } else if (count) {
+             memcpy(data, static_cast<const void*>(vector.constData()), count * sizeof(T));
+         }
+     }
+diff --git a/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp b/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
+index e57cdd8278..94613598af 100644
+--- a/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
++++ b/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
+@@ -1145,8 +1145,7 @@ void Heap::QObjectWrapper::markObjects(Heap::Base *that, QV4::MarkStack *markSta
+ void QObjectWrapper::destroyObject(bool lastCall)
+ {
+     Heap::QObjectWrapper *h = d();
+-    if (!h->internalClass)
+-        return; // destroyObject already got called
++    Q_ASSERT(h->internalClass);
+ 
+     if (h->object()) {
+         QQmlData *ddata = QQmlData::get(h->object(), false);
+@@ -1176,7 +1175,7 @@ void QObjectWrapper::destroyObject(bool lastCall)
+         }
+     }
+ 
+-    h->~Data();
++    h->destroy();
+ }
+ 
+ 
+diff --git a/qtdeclarative/src/qml/memory/qv4mm.cpp b/qtdeclarative/src/qml/memory/qv4mm.cpp
+index 06caf04e5a..da149a67c4 100644
+--- a/qtdeclarative/src/qml/memory/qv4mm.cpp
++++ b/qtdeclarative/src/qml/memory/qv4mm.cpp
+@@ -981,7 +981,7 @@ void MemoryManager::sweep(bool lastSweep, ClassDestroyStatsCallback classCountPt
+ 
+     if (MultiplyWrappedQObjectMap *multiplyWrappedQObjects = engine->m_multiplyWrappedQObjects) {
+         for (MultiplyWrappedQObjectMap::Iterator it = multiplyWrappedQObjects->begin(); it != multiplyWrappedQObjects->end();) {
+-            if (!it.value().isNullOrUndefined())
++            if (it.value().isNullOrUndefined())
+                 it = multiplyWrappedQObjects->erase(it);
+             else
+                 ++it;
+diff --git a/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp b/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
+index 2079a8ed04..a577cb2351 100644
+--- a/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
++++ b/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
+@@ -389,6 +389,12 @@ void QQmlDelegateModelPrivate::connectToAbstractItemModel()
+                       q,  QQmlDelegateModel, SLOT(_q_rowsRemoved(QModelIndex,int,int)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
+                       q,  QQmlDelegateModel, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsInserted(QModelIndex,int,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsInserted(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsRemoved(QModelIndex,int,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsRemoved(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsMoved(QModelIndex,int,int,QModelIndex,int)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
+                       q, QQmlDelegateModel, SLOT(_q_dataChanged(QModelIndex,QModelIndex,QVector<int>)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
+@@ -413,6 +419,12 @@ void QQmlDelegateModelPrivate::disconnectFromAbstractItemModel()
+                         q, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int)));
+     QObject::disconnect(aim, SIGNAL(rowsRemoved(QModelIndex,int,int)),
+                         q, SLOT(_q_rowsRemoved(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsInserted(QModelIndex,int,int)), q,
++                        SLOT(_q_columnsInserted(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsRemoved(QModelIndex,int,int)), q,
++                        SLOT(_q_columnsRemoved(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)), q,
++                        SLOT(_q_columnsMoved(QModelIndex,int,int,QModelIndex,int)));
+     QObject::disconnect(aim, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
+                         q, SLOT(_q_dataChanged(QModelIndex,QModelIndex,QVector<int>)));
+     QObject::disconnect(aim, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
+@@ -1973,6 +1985,38 @@ void QQmlDelegateModel::_q_rowsMoved(
+     }
+ }
+ 
++void QQmlDelegateModel::_q_columnsInserted(const QModelIndex &parent, int begin, int end)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if (parent == d->m_adaptorModel.rootIndex && begin == 0) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
++void QQmlDelegateModel::_q_columnsRemoved(const QModelIndex &parent, int begin, int end)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if (parent == d->m_adaptorModel.rootIndex && begin == 0) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
++void QQmlDelegateModel::_q_columnsMoved(const QModelIndex &parent, int start, int end,
++                                        const QModelIndex &destination, int column)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if ((parent == d->m_adaptorModel.rootIndex && start == 0)
++        || (destination == d->m_adaptorModel.rootIndex && column == 0)) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
+ void QQmlDelegateModel::_q_dataChanged(const QModelIndex &begin, const QModelIndex &end, const QVector<int> &roles)
+ {
+     Q_D(QQmlDelegateModel);
+diff --git a/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h b/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
+index 8aab4badca..d140bfbaaf 100644
+--- a/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
++++ b/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
+@@ -152,6 +152,9 @@ private Q_SLOTS:
+     void _q_itemsMoved(int from, int to, int count);
+     void _q_modelReset();
+     void _q_rowsInserted(const QModelIndex &,int,int);
++    void _q_columnsInserted(const QModelIndex &, int, int);
++    void _q_columnsRemoved(const QModelIndex &, int, int);
++    void _q_columnsMoved(const QModelIndex &, int, int, const QModelIndex &, int);
+     void _q_rowsAboutToBeRemoved(const QModelIndex &parent, int begin, int end);
+     void _q_rowsRemoved(const QModelIndex &,int,int);
+     void _q_rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int);
+diff --git a/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp b/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
+index 85719fdc80..78e2ab302c 100644
+--- a/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
++++ b/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
+@@ -46,6 +46,7 @@
+ #include "QtQuick/private/qquicktextinput_p.h"
+ #include "QtQuick/private/qquickaccessibleattached_p.h"
+ #include "QtQuick/qquicktextdocument.h"
++#include "QtQuick/qquickrendercontrol.h"
+ QT_BEGIN_NAMESPACE
+ 
+ #if QT_CONFIG(accessibility)
+@@ -57,7 +58,19 @@ QAccessibleQuickItem::QAccessibleQuickItem(QQuickItem *item)
+ 
+ QWindow *QAccessibleQuickItem::window() const
+ {
+-    return item()->window();
++    QQuickWindow *window = item()->window();
++
++    // For QQuickWidget the above window will be the offscreen QQuickWindow,
++    // which is not a part of the accessibility tree. Detect this case and
++    // return the window for the QQuickWidget instead.
++    if (window && !window->handle()) {
++        if (QQuickRenderControl *renderControl = QQuickWindowPrivate::get(window)->renderControl) {
++            if (QWindow *renderWindow = renderControl->renderWindow(nullptr))
++                return renderWindow;
++        }
++    }
++
++    return window;
+ }
+ 
+ int QAccessibleQuickItem::childCount() const
+@@ -113,19 +126,15 @@ QAccessibleInterface *QAccessibleQuickItem::childAt(int x, int y) const
+ QAccessibleInterface *QAccessibleQuickItem::parent() const
+ {
+     QQuickItem *parent = item()->parentItem();
+-    QQuickWindow *window = item()->window();
+-    QQuickItem *ci = window ? window->contentItem() : nullptr;
++    QQuickWindow *itemWindow = item()->window();
++    QQuickItem *ci = itemWindow ? itemWindow->contentItem() : nullptr;
+     while (parent && !QQuickItemPrivate::get(parent)->isAccessible && parent != ci)
+         parent = parent->parentItem();
+ 
+     if (parent) {
+         if (parent == ci) {
+-            // Jump out to the scene widget if the parent is the root item.
+-            // There are two root items, QQuickWindow::rootItem and
+-            // QQuickView::declarativeRoot. The former is the true root item,
+-            // but is not a part of the accessibility tree. Check if we hit
+-            // it here and return an interface for the scene instead.
+-            return QAccessible::queryAccessibleInterface(window);
++            // Jump out to the window if the parent is the root item
++            return QAccessible::queryAccessibleInterface(window());
+         } else {
+             while (parent && !parent->d_func()->isAccessible)
+                 parent = parent->parentItem();
+@@ -188,7 +197,7 @@ QAccessible::State QAccessibleQuickItem::state() const
+     QRect viewRect_ = viewRect();
+     QRect itemRect = rect();
+ 
+-    if (viewRect_.isNull() || itemRect.isNull() || !item()->window() || !item()->window()->isVisible() ||!item()->isVisible() || qFuzzyIsNull(item()->opacity()))
++    if (viewRect_.isNull() || itemRect.isNull() || !window() || !window()->isVisible() ||!item()->isVisible() || qFuzzyIsNull(item()->opacity()))
+         state.invisible = true;
+     if (!viewRect_.intersects(itemRect))
+         state.offscreen = true;
+@@ -201,6 +210,10 @@ QAccessible::State QAccessibleQuickItem::state() const
+     if (role() == QAccessible::EditableText)
+         if (auto ti = qobject_cast<QQuickTextInput *>(item()))
+             state.passwordEdit = ti->echoMode() != QQuickTextInput::Normal;
++    if (!item()->isEnabled()) {
++        state.focusable = false;
++        state.disabled = true;
++    }
+     return state;
+ }
+ 
+diff --git a/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h b/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
+index 39ffcaf39c..8baa01330c 100644
+--- a/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
++++ b/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
+@@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE
+ 
+ #if QT_CONFIG(accessibility)
+ 
+-class QAccessibleQuickWindow : public QAccessibleObject
++class Q_QUICK_EXPORT QAccessibleQuickWindow : public QAccessibleObject
+ {
+ public:
+     QAccessibleQuickWindow(QQuickWindow *object);
+diff --git a/qtdeclarative/src/quick/items/qquickdrag.cpp b/qtdeclarative/src/quick/items/qquickdrag.cpp
+index 8321fcfeed..383078b3b9 100644
+--- a/qtdeclarative/src/quick/items/qquickdrag.cpp
++++ b/qtdeclarative/src/quick/items/qquickdrag.cpp
+@@ -481,7 +481,9 @@ void QQuickDragAttached::setKeys(const QStringList &keys)
+     \qmlattachedproperty stringlist QtQuick::Drag::mimeData
+     \since 5.2
+ 
+-    This property holds a map of mimeData that is used during startDrag.
++    This property holds a map from mime type to data that is used during startDrag.
++    The mime data needs to be a \c string, or an \c ArrayBuffer with the data encoded
++    according to the mime type.
+ */
+ 
+ QVariantMap QQuickDragAttached::mimeData() const
+@@ -766,8 +768,12 @@ Qt::DropAction QQuickDragAttachedPrivate::startDrag(Qt::DropActions supportedAct
+     QDrag *drag = new QDrag(source ? source : q);
+     QMimeData *mimeData = new QMimeData();
+ 
+-    for (auto it = externalMimeData.cbegin(), end = externalMimeData.cend(); it != end; ++it)
+-        mimeData->setData(it.key(), it.value().toString().toUtf8());
++    for (auto it = externalMimeData.cbegin(), end = externalMimeData.cend(); it != end; ++it) {
++        if (static_cast<QMetaType::Type>(it.value().type()) == QMetaType::QByteArray)
++            mimeData->setData(it.key(), it.value().toByteArray());
++        else
++            mimeData->setData(it.key(), it.value().toString().toUtf8());
++    }
+ 
+     drag->setMimeData(mimeData);
+     if (pixmapLoader.isReady()) {
+diff --git a/qtdeclarative/src/quick/items/qquickitem.cpp b/qtdeclarative/src/quick/items/qquickitem.cpp
+index 75f1457816..dec0ae19ae 100644
+--- a/qtdeclarative/src/quick/items/qquickitem.cpp
++++ b/qtdeclarative/src/quick/items/qquickitem.cpp
+@@ -59,6 +59,7 @@
+ #include <QtCore/private/qnumeric_p.h>
+ #include <QtGui/qpa/qplatformtheme.h>
+ #include <QtCore/qloggingcategory.h>
++#include <QtCore/private/qduplicatetracker_p.h>
+ 
+ #include <private/qqmlglobal_p.h>
+ #include <private/qqmlengine_p.h>
+@@ -2326,6 +2327,7 @@ QQuickItem::QQuickItem(QQuickItemPrivate &dd, QQuickItem *parent)
+ QQuickItem::~QQuickItem()
+ {
+     Q_D(QQuickItem);
++    d->inDestructor = true;
+ 
+     if (d->windowRefCount > 1)
+         d->windowRefCount = 1; // Make sure window is set to null in next call to derefWindow().
+@@ -2526,6 +2528,7 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo
+     QQuickItem *current = item;
+     qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: startItem:" << startItem;
+     qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: firstFromItem:" << firstFromItem;
++    QDuplicateTracker<QQuickItem *> cycleDetector;
+     do {
+         qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: current:" << current;
+         qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: from:" << from;
+@@ -2592,7 +2595,10 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo
+         // traversed all of the chain (by compare the [current] item with [startItem])
+         // Since the [startItem] might be promoted to its parent if it is invisible,
+         // we still have to check [current] item with original start item
+-        if ((current == startItem || current == originalStartItem) && from == firstFromItem) {
++        // We might also run into a cycle before we reach firstFromItem again
++        // but note that we have to ignore current if we are meant to skip it
++        if (((current == startItem || current == originalStartItem) && from == firstFromItem) ||
++                (!skip && cycleDetector.hasSeen(current))) {
+             // wrapped around, avoid endless loops
+             if (item == contentItem) {
+                 qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: looped, return contentItem";
+@@ -2689,9 +2695,8 @@ void QQuickItem::setParentItem(QQuickItem *parentItem)
+ 
+         const bool wasVisible = isVisible();
+         op->removeChild(this);
+-        if (wasVisible) {
++        if (wasVisible && !op->inDestructor)
+             emit oldParentItem->visibleChildrenChanged();
+-        }
+     } else if (d->window) {
+         QQuickWindowPrivate::get(d->window)->parentlessItems.remove(this);
+     }
+@@ -2768,8 +2773,9 @@ void QQuickItem::setParentItem(QQuickItem *parentItem)
+ 
+     d->itemChange(ItemParentHasChanged, d->parentItem);
+ 
+-    emit parentChanged(d->parentItem);
+-    if (isVisible() && d->parentItem)
++    if (!d->inDestructor)
++        emit parentChanged(d->parentItem);
++    if (isVisible() && d->parentItem && !QQuickItemPrivate::get(d->parentItem)->inDestructor)
+         emit d->parentItem->visibleChildrenChanged();
+ }
+ 
+@@ -2965,7 +2971,8 @@ void QQuickItemPrivate::removeChild(QQuickItem *child)
+ 
+     itemChange(QQuickItem::ItemChildRemovedChange, child);
+ 
+-    emit q->childrenChanged();
++    if (!inDestructor)
++        emit q->childrenChanged();
+ }
+ 
+ void QQuickItemPrivate::refWindow(QQuickWindow *c)
+@@ -3194,6 +3201,7 @@ QQuickItemPrivate::QQuickItemPrivate()
+     , touchEnabled(false)
+ #endif
+     , hasCursorHandler(false)
++    , inDestructor(false)
+     , dirtyAttributes(0)
+     , nextDirtyItem(nullptr)
+     , prevDirtyItem(nullptr)
+@@ -5120,6 +5128,13 @@ void QQuickItem::componentComplete()
+         d->addToDirtyList();
+         QQuickWindowPrivate::get(d->window)->dirtyItem(this);
+     }
++
++#if QT_CONFIG(accessibility)
++    if (d->isAccessible && d->effectiveVisible) {
++        QAccessibleEvent ev(this, QAccessible::ObjectShow);
++        QAccessible::updateAccessibility(&ev);
++    }
++#endif
+ }
+ 
+ QQuickStateGroup *QQuickItemPrivate::_states()
+@@ -6106,9 +6121,11 @@ bool QQuickItemPrivate::setEffectiveVisibleRecur(bool newEffectiveVisible)
+         QAccessible::updateAccessibility(&ev);
+     }
+ #endif
+-    emit q->visibleChanged();
+-    if (childVisibilityChanged)
+-        emit q->visibleChildrenChanged();
++    if (!inDestructor) {
++        emit q->visibleChanged();
++        if (childVisibilityChanged)
++            emit q->visibleChildrenChanged();
++    }
+ 
+     return true;    // effective visibility DID change
+ }
+@@ -6157,6 +6174,15 @@ void QQuickItemPrivate::setEffectiveEnableRecur(QQuickItem *scope, bool newEffec
+     }
+ 
+     itemChange(QQuickItem::ItemEnabledHasChanged, effectiveEnable);
++#if QT_CONFIG(accessibility)
++    if (isAccessible) {
++        QAccessible::State changedState;
++        changedState.disabled = true;
++        changedState.focusable = true;
++        QAccessibleStateChangeEvent ev(q, changedState);
++        QAccessible::updateAccessibility(&ev);
++    }
++#endif
+     emit q->enabledChanged();
+ }
+ 
+diff --git a/qtdeclarative/src/quick/items/qquickitem_p.h b/qtdeclarative/src/quick/items/qquickitem_p.h
+index 841d91bb40..ade8fb61f2 100644
+--- a/qtdeclarative/src/quick/items/qquickitem_p.h
++++ b/qtdeclarative/src/quick/items/qquickitem_p.h
+@@ -472,6 +472,7 @@ public:
+     bool replayingPressEvent:1;
+     bool touchEnabled:1;
+     bool hasCursorHandler:1;
++    quint32 inDestructor:1; // has entered ~QQuickItem
+ 
+     enum DirtyType {
+         TransformOrigin         = 0x00000001,
+diff --git a/qtdeclarative/src/quick/items/qquickitemview.cpp b/qtdeclarative/src/quick/items/qquickitemview.cpp
+index 010a0152e1..f8ad168a17 100644
+--- a/qtdeclarative/src/quick/items/qquickitemview.cpp
++++ b/qtdeclarative/src/quick/items/qquickitemview.cpp
+@@ -1785,7 +1785,7 @@ void QQuickItemViewPrivate::refill(qreal from, qreal to)
+ 
+     do {
+         bufferPause.stop();
+-        if (currentChanges.hasPendingChanges() || bufferedChanges.hasPendingChanges()) {
++        if (currentChanges.hasPendingChanges() || bufferedChanges.hasPendingChanges() || currentChanges.active) {
+             currentChanges.reset();
+             bufferedChanges.reset();
+             releaseVisibleItems(reusableFlag);
+diff --git a/qtdeclarative/src/quick/items/qquickmousearea_p_p.h b/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
+index fba383e268..0d63618622 100644
+--- a/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
++++ b/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
+@@ -61,7 +61,6 @@ QT_BEGIN_NAMESPACE
+ 
+ class QQuickMouseEvent;
+ class QQuickMouseArea;
+-class QQuickPointerMask;
+ class QQuickMouseAreaPrivate : public QQuickItemPrivate
+ {
+     Q_DECLARE_PUBLIC(QQuickMouseArea)
+@@ -100,7 +99,6 @@ public:
+ #if QT_CONFIG(quick_draganddrop)
+     QQuickDrag *drag;
+ #endif
+-    QPointer<QQuickPointerMask> mask;
+     QPointF startScene;
+     QPointF targetStartPos;
+     QPointF lastPos;
+diff --git a/qtdeclarative/src/quick/items/qquicktext.cpp b/qtdeclarative/src/quick/items/qquicktext.cpp
+index 6230186933..e823ca1095 100644
+--- a/qtdeclarative/src/quick/items/qquicktext.cpp
++++ b/qtdeclarative/src/quick/items/qquicktext.cpp
+@@ -2168,7 +2168,7 @@ void QQuickText::resetMaximumLineCount()
+     <img src="" align="top,middle,bottom" width="" height=""> - inline images
+     <ol type="">, <ul type=""> and <li> - ordered and unordered lists
+     <pre></pre> - preformatted
+-    &gt; &lt; &amp;
++    &gt; &lt; &amp; &quot; &nbsp; &apos;
+     \endcode
+ 
+     \c Text.StyledText parser is strict, requiring tags to be correctly nested.
+diff --git a/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp b/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
+index eb4db0f85e..2325a2665b 100644
+--- a/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
++++ b/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
+@@ -446,7 +446,7 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+         const char *textureRecord = allocatorData;
+         for (int i = 0; i < textureCount; ++i, textureRecord += Qtdf::TextureRecordSize) {
+-            if (textureRecord + Qtdf::TextureRecordSize > qtdfTableEnd) {
++            if (qtdfTableEnd - textureRecord < Qtdf::TextureRecordSize) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+@@ -462,7 +462,7 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+         const char *glyphRecord = textureRecord;
+         for (quint32 i = 0; i < glyphCount; ++i, glyphRecord += Qtdf::GlyphRecordSize) {
+-            if (glyphRecord + Qtdf::GlyphRecordSize > qtdfTableEnd) {
++            if (qtdfTableEnd - glyphRecord < Qtdf:: GlyphRecordSize) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+@@ -512,8 +512,8 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+             int width = texInfo->allocatedArea.width();
+             int height = texInfo->allocatedArea.height();
+-            qint64 size = width * height;
+-            if (reinterpret_cast<const char *>(textureData + size) > qtdfTableEnd) {
++            qint64 size = qint64(width) * height;
++            if (qtdfTableEnd - reinterpret_cast<const char *>(textureData) < size) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+diff --git a/qtdeclarative/src/quick/util/qquickstyledtext.cpp b/qtdeclarative/src/quick/util/qquickstyledtext.cpp
+index d531fc9205..a25af90414 100644
+--- a/qtdeclarative/src/quick/util/qquickstyledtext.cpp
++++ b/qtdeclarative/src/quick/util/qquickstyledtext.cpp
+@@ -564,6 +564,8 @@ void QQuickStyledTextPrivate::parseEntity(const QChar *&ch, const QString &textI
+                 textOut += QChar(60);
+             else if (entity == QLatin1String("amp"))
+                 textOut += QChar(38);
++            else if (entity == QLatin1String("apos"))
++                textOut += QChar(39);
+             else if (entity == QLatin1String("quot"))
+                 textOut += QChar(34);
+             else if (entity == QLatin1String("nbsp"))
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp
+new file mode 100644
+index 0000000000..8a1c901880
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp
+@@ -0,0 +1,110 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include "qaccessiblequickwidget_p.h"
++
++#include "qquickwidget_p.h"
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleQuickWidget::QAccessibleQuickWidget(QQuickWidget* widget)
++: QAccessibleWidget(widget)
++, m_accessibleWindow(QQuickWidgetPrivate::get(widget)->offscreenWindow)
++{
++    // NOTE: m_accessibleWindow is a QAccessibleQuickWindow, and not a
++    // QAccessibleQuickWidgetOffscreenWindow (defined below). This means
++    // it will return the Quick item child interfaces, which is what's needed here
++    // (unlike QAccessibleQuickWidgetOffscreenWindow, which will report 0 children).
++}
++
++QAccessibleInterface *QAccessibleQuickWidget::child(int index) const
++{
++    return m_accessibleWindow.child(index);
++}
++
++int QAccessibleQuickWidget::childCount() const
++{
++    return m_accessibleWindow.childCount();
++}
++
++int QAccessibleQuickWidget::indexOfChild(const QAccessibleInterface *iface) const
++{
++    return m_accessibleWindow.indexOfChild(iface);
++}
++
++QAccessibleInterface *QAccessibleQuickWidget::childAt(int x, int y) const
++{
++    return m_accessibleWindow.childAt(x, y);
++}
++
++QAccessibleQuickWidgetOffscreenWindow::QAccessibleQuickWidgetOffscreenWindow(QQuickWindow *window)
++:QAccessibleQuickWindow(window)
++{
++
++}
++
++QAccessibleInterface *QAccessibleQuickWidgetOffscreenWindow::child(int index) const
++{
++    Q_UNUSED(index);
++    return nullptr;
++}
++
++int QAccessibleQuickWidgetOffscreenWindow::childCount() const
++{
++    return 0;
++}
++
++int QAccessibleQuickWidgetOffscreenWindow::indexOfChild(const QAccessibleInterface *iface) const
++{
++    Q_UNUSED(iface);
++    return -1;
++}
++
++QAccessibleInterface *QAccessibleQuickWidgetOffscreenWindow::QAccessibleQuickWidgetOffscreenWindow::childAt(int x, int y) const
++{
++    Q_UNUSED(x);
++    Q_UNUSED(y);
++    return nullptr;
++}
++
++#endif // accessibility
++
++QT_END_NAMESPACE
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h
+new file mode 100644
+index 0000000000..7c2ab930e0
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h
+@@ -0,0 +1,95 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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 QACCESSIBLEQUICKWIDGET_H
++#define QACCESSIBLEQUICKWIDGET_H
++
++//
++//  W A R N I N G
++//  -------------
++//
++// This file is not part of the Qt API.  It exists purely as an
++// implementation detail.  This header file may change from version to
++// version without notice, or even be removed.
++//
++// We mean it.
++//
++
++#include "qquickwidget.h"
++#include <QtWidgets/qaccessiblewidget.h>
++
++#include <private/qaccessiblequickview_p.h>
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++// These classes implement the QQuickWiget accessibility switcharoo,
++// where the child items of the QQuickWidgetOffscreenWindow are reported
++// as child accessible interfaces of the QAccessibleQuickWidget.
++class QAccessibleQuickWidget: public QAccessibleWidget
++{
++public:
++    QAccessibleQuickWidget(QQuickWidget* widget);
++
++    QAccessibleInterface *child(int index) const override;
++    int childCount() const override;
++    int indexOfChild(const QAccessibleInterface *iface) const override;
++    QAccessibleInterface *childAt(int x, int y) const override;
++
++private:
++    QAccessibleQuickWindow m_accessibleWindow;
++    Q_DISABLE_COPY(QAccessibleQuickWidget)
++};
++
++class QAccessibleQuickWidgetOffscreenWindow: public QAccessibleQuickWindow
++{
++public:
++    QAccessibleQuickWidgetOffscreenWindow(QQuickWindow *window);
++    QAccessibleInterface *child(int index) const override;
++    int childCount() const override;
++    int indexOfChild(const QAccessibleInterface *iface) const override;
++    QAccessibleInterface *childAt(int x, int y) const override;
++};
++
++#endif // accessibility
++
++QT_END_NAMESPACE
++
++#endif
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp
+new file mode 100644
+index 0000000000..7ba88a1769
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp
+@@ -0,0 +1,60 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include "qaccessiblequickwidgetfactory_p.h"
++#include "qaccessiblequickwidget_p.h"
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleInterface *qAccessibleQuickWidgetFactory(const QString &classname, QObject *object)
++{
++    if (classname == QLatin1String("QQuickWidget")) {
++        return new QAccessibleQuickWidget(qobject_cast<QQuickWidget *>(object));
++    } else if (classname == QLatin1String("QQuickWidgetOffscreenWindow")) {
++        return new QAccessibleQuickWidgetOffscreenWindow(qobject_cast<QQuickWindow *>(object));
++    }
++    return 0;
++}
++
++#endif // accessibility
++
++QT_END_NAMESPACE
++
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h
+new file mode 100644
+index 0000000000..8c63b09f81
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h
+@@ -0,0 +1,66 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include <QtGui/qaccessible.h>
++
++#ifndef QACCESSIBLEQUICKWIDGETFACTORY_H
++#define QACCESSIBLEQUICKWIDGETFACTORY_H
++
++//
++//  W A R N I N G
++//  -------------
++//
++// This file is not part of the Qt API.  It exists purely as an
++// implementation detail.  This header file may change from version to
++// version without notice, or even be removed.
++//
++// We mean it.
++//
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleInterface *qAccessibleQuickWidgetFactory(const QString &classname, QObject *object);
++
++#endif
++
++QT_END_NAMESPACE
++
++#endif
+diff --git a/qtdeclarative/src/quickwidgets/qquickwidget.cpp b/qtdeclarative/src/quickwidgets/qquickwidget.cpp
+index 39780f8de3..9c97b43518 100644
+--- a/qtdeclarative/src/quickwidgets/qquickwidget.cpp
++++ b/qtdeclarative/src/quickwidgets/qquickwidget.cpp
+@@ -39,6 +39,7 @@
+ 
+ #include "qquickwidget.h"
+ #include "qquickwidget_p.h"
++#include "qaccessiblequickwidgetfactory_p.h"
+ 
+ #include "private/qquickwindow_p.h"
+ #include "private/qquickitem_p.h"
+@@ -75,9 +76,16 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++QQuickWidgetOffscreenWindow::QQuickWidgetOffscreenWindow(QQuickWindowPrivate &dd, QQuickRenderControl *control)
++:QQuickWindow(dd, control)
++{
++    setTitle(QString::fromLatin1("Offscreen"));
++    setObjectName(QString::fromLatin1("QQuickOffScreenWindow"));
++}
++
+ // override setVisble to prevent accidental offscreen window being created
+ // by base class.
+-class QQuickOffcreenWindowPrivate: public QQuickWindowPrivate {
++class QQuickWidgetOffscreenWindowPrivate: public QQuickWindowPrivate {
+ public:
+     void setVisible(bool visible) override {
+         Q_Q(QWindow);
+@@ -105,9 +113,8 @@ void QQuickWidgetPrivate::init(QQmlEngine* e)
+     Q_Q(QQuickWidget);
+ 
+     renderControl = new QQuickWidgetRenderControl(q);
+-    offscreenWindow = new QQuickWindow(*new QQuickOffcreenWindowPrivate(),renderControl);
+-    offscreenWindow->setTitle(QString::fromLatin1("Offscreen"));
+-    offscreenWindow->setObjectName(QString::fromLatin1("QQuickOffScreenWindow"));
++    offscreenWindow = new QQuickWidgetOffscreenWindow(*new QQuickWidgetOffscreenWindowPrivate(), renderControl);
++    offscreenWindow->setScreen(q->screen());
+     // Do not call create() on offscreenWindow.
+ 
+     // Check if the Software Adaptation is being used
+@@ -138,6 +145,10 @@ void QQuickWidgetPrivate::init(QQmlEngine* e)
+     QWidget::connect(offscreenWindow, &QQuickWindow::focusObjectChanged, q, &QQuickWidget::propagateFocusObjectChanged);
+     QObject::connect(renderControl, SIGNAL(renderRequested()), q, SLOT(triggerUpdate()));
+     QObject::connect(renderControl, SIGNAL(sceneChanged()), q, SLOT(triggerUpdate()));
++
++#if QT_CONFIG(accessibility)
++    QAccessible::installFactory(&qAccessibleQuickWidgetFactory);
++#endif
+ }
+ 
+ void QQuickWidgetPrivate::ensureEngine() const
+@@ -901,9 +912,7 @@ void QQuickWidgetPrivate::createContext()
+ 
+         context = new QOpenGLContext;
+         context->setFormat(offscreenWindow->requestedFormat());
+-        const QWindow *win = q->window()->windowHandle();
+-        if (win && win->screen())
+-            context->setScreen(win->screen());
++        context->setScreen(q->screen());
+         QOpenGLContext *shareContext = qt_gl_global_share_context();
+         if (!shareContext)
+             shareContext = QWidgetPrivate::get(q->window())->shareContext();
+@@ -1520,19 +1529,16 @@ bool QQuickWidget::event(QEvent *e)
+         d->handleWindowChange();
+         break;
+ 
+-    case QEvent::ScreenChangeInternal:
+-        if (QWindow *window = this->window()->windowHandle()) {
+-            QScreen *newScreen = window->screen();
+-
+-            if (d->offscreenWindow)
+-                d->offscreenWindow->setScreen(newScreen);
+-            if (d->offscreenSurface)
+-                d->offscreenSurface->setScreen(newScreen);
++    case QEvent::ScreenChangeInternal: {
++        QScreen *newScreen = screen();
++        if (d->offscreenWindow)
++            d->offscreenWindow->setScreen(newScreen);
++        if (d->offscreenSurface)
++            d->offscreenSurface->setScreen(newScreen);
+ #if QT_CONFIG(opengl)
+-            if (d->context)
+-                d->context->setScreen(newScreen);
++        if (d->context)
++            d->context->setScreen(newScreen);
+ #endif
+-        }
+ 
+         if (d->useSoftwareRenderer
+ #if QT_CONFIG(opengl)
+@@ -1545,7 +1551,7 @@ bool QQuickWidget::event(QEvent *e)
+             d->render(true);
+         }
+         break;
+-
++    }
+     case QEvent::Show:
+     case QEvent::Move:
+         d->updatePosition();
+diff --git a/qtdeclarative/src/quickwidgets/qquickwidget_p.h b/qtdeclarative/src/quickwidgets/qquickwidget_p.h
+index 881f7f9220..1a946bcc71 100644
+--- a/qtdeclarative/src/quickwidgets/qquickwidget_p.h
++++ b/qtdeclarative/src/quickwidgets/qquickwidget_p.h
+@@ -148,6 +148,14 @@ public:
+     bool forceFullUpdate;
+ };
+ 
++class QQuickWidgetOffscreenWindow: public QQuickWindow
++{
++    Q_OBJECT
++
++public:
++    QQuickWidgetOffscreenWindow(QQuickWindowPrivate &dd, QQuickRenderControl *control);
++};
++
+ QT_END_NAMESPACE
+ 
+ #endif // QQuickWidget_P_H
+diff --git a/qtdeclarative/src/quickwidgets/quickwidgets.pro b/qtdeclarative/src/quickwidgets/quickwidgets.pro
+index 2438e577ae..85d156b8a3 100644
+--- a/qtdeclarative/src/quickwidgets/quickwidgets.pro
++++ b/qtdeclarative/src/quickwidgets/quickwidgets.pro
+@@ -7,9 +7,13 @@ DEFINES   += QT_NO_URL_CAST_FROM_STRING QT_NO_INTEGER_EVENT_COORDINATES QT_NO_FO
+ HEADERS += \
+     qquickwidget.h \
+     qquickwidget_p.h \
+-    qtquickwidgetsglobal.h
++    qtquickwidgetsglobal.h \
++    qaccessiblequickwidget_p.h \
++    qaccessiblequickwidgetfactory_p.h
+ 
+ SOURCES += \
+-    qquickwidget.cpp
++    qquickwidget.cpp \
++    qaccessiblequickwidget.cpp \
++    qaccessiblequickwidgetfactory.cpp
+ 
+ load(qt_module)
+diff --git a/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+index 3b7d74df63..b75bf820d5 100644
+--- a/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
++++ b/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+@@ -102,6 +102,7 @@ private slots:
+     void valueConversion_RegularExpression();
+     void castWithMultipleInheritance();
+     void collectGarbage();
++    void collectGarbageNestedWrappersTwoEngines();
+     void gcWithNestedDataStructure();
+     void stacktrace();
+     void numberParsing_data();
+@@ -1809,6 +1810,44 @@ void tst_QJSEngine::collectGarbage()
+     QVERIFY(ptr.isNull());
+ }
+ 
++class TestObjectContainer : public QObject
++{
++    Q_OBJECT
++    Q_PROPERTY(QObject *dummy MEMBER m_dummy CONSTANT)
++
++public:
++    TestObjectContainer() : m_dummy(new QObject(this)) {}
++
++private:
++    QObject *m_dummy;
++};
++
++void tst_QJSEngine::collectGarbageNestedWrappersTwoEngines()
++{
++    QJSEngine engine1;
++    QJSEngine engine2;
++
++    TestObjectContainer container;
++    QQmlEngine::setObjectOwnership(&container, QQmlEngine::CppOwnership);
++
++    engine1.globalObject().setProperty("foobar", engine1.newQObject(&container));
++    engine2.globalObject().setProperty("foobar", engine2.newQObject(&container));
++
++    engine1.evaluate("foobar.dummy.baz = 42");
++    engine2.evaluate("foobar.dummy.baz = 43");
++
++    QCOMPARE(engine1.evaluate("foobar.dummy.baz").toInt(), 42);
++    QCOMPARE(engine2.evaluate("foobar.dummy.baz").toInt(), 43);
++
++    engine1.collectGarbage();
++    engine2.collectGarbage();
++
++    // The GC should not collect dummy object wrappers neither in engine1 nor engine2, we
++    // verify that by checking whether the baz property still has its previous value.
++    QCOMPARE(engine1.evaluate("foobar.dummy.baz").toInt(), 42);
++    QCOMPARE(engine2.evaluate("foobar.dummy.baz").toInt(), 43);
++}
++
+ void tst_QJSEngine::gcWithNestedDataStructure()
+ {
+     // The GC must be able to traverse deeply nested objects, otherwise this
+diff --git a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml
+new file mode 100644
+index 0000000000..206133bb39
+--- /dev/null
++++ b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml
+@@ -0,0 +1,11 @@
++import QtQuick 2.8
++
++ListView {
++    id: root
++    width: 200
++    height: 200
++
++    delegate: Text {
++        text: display
++    }
++}
+diff --git a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
+index 35f1e2c94d..1722447830 100644
+--- a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
++++ b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
+@@ -27,6 +27,8 @@
+ ****************************************************************************/
+ 
+ #include <QtTest/qtest.h>
++#include <QtCore/QConcatenateTablesProxyModel>
++#include <QtGui/QStandardItemModel>
+ #include <QtQml/qqmlcomponent.h>
+ #include <QtQmlModels/private/qqmldelegatemodel_p.h>
+ #include <QtQuick/qquickview.h>
+@@ -47,6 +49,7 @@ private slots:
+     void filterOnGroup_removeWhenCompleted();
+     void qtbug_86017();
+     void contextAccessedByHandler();
++    void redrawUponColumnChange();
+ };
+ 
+ class AbstractItemModel : public QAbstractItemModel
+@@ -186,6 +189,30 @@ void tst_QQmlDelegateModel::contextAccessedByHandler()
+     QVERIFY(root->property("works").toBool());
+ }
+ 
++void tst_QQmlDelegateModel::redrawUponColumnChange()
++{
++    QStandardItemModel m1;
++    m1.appendRow({
++            new QStandardItem("Banana"),
++            new QStandardItem("Coconut"),
++    });
++
++    QQuickView view(testFileUrl("redrawUponColumnChange.qml"));
++    QCOMPARE(view.status(), QQuickView::Ready);
++    view.show();
++    QQuickItem *root = view.rootObject();
++    root->setProperty("model", QVariant::fromValue<QObject *>(&m1));
++
++    QObject *item = root->property("currentItem").value<QObject *>();
++    QVERIFY(item);
++    QCOMPARE(item->property("text").toString(), "Banana");
++
++    QVERIFY(root);
++    m1.removeColumn(0);
++
++    QCOMPARE(item->property("text").toString(), "Coconut");
++}
++
+ QTEST_MAIN(tst_QQmlDelegateModel)
+ 
+ #include "tst_qqmldelegatemodel.moc"
+diff --git a/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp b/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
+index 5d635aa63b..824fd89e5b 100644
+--- a/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
++++ b/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
+@@ -76,10 +76,10 @@ void tst_qv4mm::multiWrappedQObjects()
+         QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 1);
+         QCOMPARE(engine2.memoryManager->m_pendingFreedObjectWrapperValue.size(), 0);
+ 
+-        // Moves the additional WeakValue from m_multiplyWrappedQObjects to
+-        // m_pendingFreedObjectWrapperValue. It's still alive after all.
++        // The additional WeakValue from m_multiplyWrappedQObjects hasn't been moved
++        // to m_pendingFreedObjectWrapperValue yet. It's still alive after all.
+         engine1.memoryManager->runGC();
+-        QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 2);
++        QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 1);
+ 
+         // engine2 doesn't own the object as engine1 was the first to wrap it above.
+         // Therefore, no effect here.
+diff --git a/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml b/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml
+new file mode 100644
+index 0000000000..889e480f3b
+--- /dev/null
++++ b/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml
+@@ -0,0 +1,13 @@
++import QtQuick 2.6
++
++Item {
++    visible: true
++    Item {
++        visible: false
++        Item {
++            objectName: "hiddenChild"
++            activeFocusOnTab: true
++            focus: true
++        }
++    }
++}
+diff --git a/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp b/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+index c8f251dbe1..c8ef36ee68 100644
+--- a/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
++++ b/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+@@ -67,6 +67,7 @@ private slots:
+     void activeFocusOnTab10();
+     void activeFocusOnTab_infiniteLoop_data();
+     void activeFocusOnTab_infiniteLoop();
++    void activeFocusOnTab_infiniteLoopControls();
+ 
+     void nextItemInFocusChain();
+     void nextItemInFocusChain2();
+@@ -1057,6 +1058,17 @@ void tst_QQuickItem::activeFocusOnTab_infiniteLoop()
+     QCOMPARE(item, window->rootObject());
+ }
+ 
++
++void tst_QQuickItem::activeFocusOnTab_infiniteLoopControls()
++{
++    auto source = testFileUrl("activeFocusOnTab_infiniteLoop3.qml");
++    QScopedPointer<QQuickView>window(new QQuickView());
++    window->setSource(source);
++    window->show();
++    QVERIFY(window->errors().isEmpty());
++    QTest::keyClick(window.get(), Qt::Key_Tab); // should not hang
++}
++
+ void tst_QQuickItem::nextItemInFocusChain()
+ {
+     if (!qt_tab_all_widgets())
+Submodule qtdoc c0c7bf07...79d6ef69:
+Submodule qtimageformats 2dcf2899..abe44c0f:
+diff --git a/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp b/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
+index dde783c..1bf9074 100644
+--- a/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
+@@ -462,8 +462,12 @@ static bool parseIconEntryInfo(ICNSEntry &icon)
+     if (isIconCompressed(icon))
+         return true;
+     // Icon depth:
+-    if (!depth.isEmpty())
+-        icon.depth = ICNSEntry::Depth(depth.toUInt());
++    if (!depth.isEmpty()) {
++        const uint depthUInt = depth.toUInt();
++        if (depthUInt > 32)
++            return false;
++        icon.depth = ICNSEntry::Depth(depthUInt);
++    }
+     // Try mono if depth not found
+     if (icon.depth == ICNSEntry::DepthUnknown)
+         icon.depth = ICNSEntry::DepthMono;
+@@ -515,6 +519,9 @@ static bool parseIconEntryInfo(ICNSEntry &icon)
+         }
+         icon.height = icon.width;
+     }
++    // Sanity check
++    if (icon.width == 0 || icon.width > 4096)
++        return false;
+     return true;
+ }
+ 
+@@ -685,7 +692,7 @@ bool QICNSHandler::canRead() const
+ bool QICNSHandler::read(QImage *outImage)
+ {
+     QImage img;
+-    if (!ensureScanned()) {
++    if (!ensureScanned() || m_currentIconIndex >= m_icons.size()) {
+         qWarning("QICNSHandler::read(): The device wasn't parsed properly!");
+         return false;
+     }
+@@ -892,7 +899,7 @@ bool QICNSHandler::scanDevice()
+             return false;
+ 
+         const qint64 blockDataOffset = device()->pos();
+-        if (!isBlockHeaderValid(blockHeader)) {
++        if (!isBlockHeaderValid(blockHeader, ICNSBlockHeaderSize + filelength - blockDataOffset)) {
+             qWarning("QICNSHandler::scanDevice(): Failed, bad header at pos %s. OSType \"%s\", length %u",
+                      QByteArray::number(blockDataOffset).constData(),
+                      nameFromOSType(blockHeader.ostype).constData(), blockHeader.length);
+@@ -927,11 +934,14 @@ bool QICNSHandler::scanDevice()
+         case ICNSBlockHeader::TypeOdrp:
+             // Icns container seems to have an embedded icon variant container
+             // Let's start a scan for entries
+-            while (device()->pos() < nextBlockOffset) {
++            while (!stream.atEnd() && device()->pos() < nextBlockOffset) {
+                 ICNSBlockHeader icon;
+                 stream >> icon;
++                if (stream.status() != QDataStream::Ok)
++                    return false;
+                 // Check for incorrect variant entry header and stop scan
+-                if (!isBlockHeaderValid(icon, blockDataLength))
++                quint64 remaining = blockDataLength - (device()->pos() - blockDataOffset);
++                if (!isBlockHeaderValid(icon, ICNSBlockHeaderSize + remaining))
+                     break;
+                 if (!addEntry(icon, device()->pos(), blockHeader.ostype))
+                     return false;
+@@ -1003,7 +1013,7 @@ bool QICNSHandler::scanDevice()
+             break;
+         }
+     }
+-    return true;
++    return (m_icons.size() > 0);
+ }
+ 
+ const ICNSEntry &QICNSHandler::getIconMask(const ICNSEntry &icon) const
+diff --git a/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp b/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
+index 5082023..cb34374 100644
+--- a/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
++++ b/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
+@@ -43,6 +43,7 @@
+ #include "qimage.h"
+ #include "qvariant.h"
+ #include "qcolor.h"
++#include "qimagereader.h"
+ 
+ #include <jasper/jasper.h>
+ #include <math.h> // for pow
+@@ -333,16 +334,46 @@ private:
+ Jpeg2000JasperReader::Jpeg2000JasperReader(QIODevice *iod, SubFormat format)
+     : jasperOk(true), ioDevice(iod), format(format), hasAlpha(false)
+ {
++#if JAS_VERSION_MAJOR < 3
+     if (jas_init()) {
+         jasperOk = false;
+         qDebug("Jasper Library initialization failed");
+     }
++#else
++    jas_conf_clear();
++#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
++    jas_conf_set_max_mem_usage(QImageReader::allocationLimit() * 1024 * 1024);
++#else
++    // 128MB seems to be enough.
++    jas_conf_set_max_mem_usage(128 * 1024 * 1024);
++#endif
++    if (jas_init_library()) {
++        jasperOk = false;
++        qDebug("Jasper library initialization failed");
++    }
++    if (jas_init_thread()) {
++        jas_cleanup_library();
++        jasperOk = false;
++        qDebug("Jasper thread initialization failed");
++    }
++#endif
+ }
+ 
+ Jpeg2000JasperReader::~Jpeg2000JasperReader()
+ {
++#if JAS_VERSION_MAJOR < 3
+     if (jasperOk)
+         jas_cleanup();
++#else
++    if (jasperOk) {
++        if (jas_cleanup_thread()) {
++            qDebug("Jasper thread cleanup failed");
++        }
++        if (jas_cleanup_library()) {
++            qDebug("Jasper library cleanup failed");
++        }
++    }
++#endif
+ }
+ 
+ /*! \internal
+@@ -857,7 +888,7 @@ bool Jpeg2000JasperReader::write(const QImage &image, int quality)
+     }
+ 
+     // Open an empty jasper stream that grows automatically
+-    jas_stream_t * memory_stream = jas_stream_memopen(0, -1);
++    jas_stream_t * memory_stream = jas_stream_memopen(0, 0);
+ 
+     // Jasper wants a non-const string.
+     char *str = qstrdup(jasperFormatString.toLatin1().constData());
+diff --git a/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp b/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
+index 1386750..ac8956c 100644
+--- a/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
+@@ -361,6 +361,8 @@ bool QTiffHandler::read(QImage *image)
+     }
+ 
+     TIFF *const tiff = d->tiff;
++    if (TIFFIsTiled(tiff) && TIFFTileSize64(tiff) > uint64_t(image->sizeInBytes())) // Corrupt image
++        return false;
+     const quint32 width = d->size.width();
+     const quint32 height = d->size.height();
+ 
+diff --git a/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp b/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
+index 82d38cb..d02eb05 100644
+--- a/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
+@@ -45,6 +45,7 @@
+ #include <qdebug.h>
+ #include <qpainter.h>
+ #include <qvariant.h>
++#include <QtEndian>
+ 
+ static const int riffHeaderSize = 12; // RIFF_HEADER_SIZE from webp/format_constants.h
+ 
+@@ -102,21 +103,23 @@ bool QWebpHandler::ensureScanned() const
+ 
+     m_scanState = ScanError;
+ 
+-    if (device()->isSequential()) {
+-        qWarning() << "Sequential devices are not supported";
++    QWebpHandler *that = const_cast<QWebpHandler *>(this);
++    const int headerBytesNeeded = sizeof(WebPBitstreamFeatures);
++    QByteArray header = device()->peek(headerBytesNeeded);
++    if (header.size() < headerBytesNeeded)
+         return false;
+-    }
+ 
+-    qint64 oldPos = device()->pos();
+-    device()->seek(0);
+-
+-    QWebpHandler *that = const_cast<QWebpHandler *>(this);
+-    QByteArray header = device()->peek(sizeof(WebPBitstreamFeatures));
++    // We do no random access during decoding, just a readAll() of the whole image file. So if
++    // if it is all available already, we can accept a sequential device. The riff header contains
++    // the file size minus 8 bytes header
++    qint64 byteSize = qFromLittleEndian<quint32>(header.constData() + 4);
++    if (device()->isSequential() && device()->bytesAvailable() < byteSize + 8) {
++        qWarning() << "QWebpHandler: Insufficient data available in sequential device";
++        return false;
++    }
+     if (WebPGetFeatures((const uint8_t*)header.constData(), header.size(), &(that->m_features)) == VP8_STATUS_OK) {
+         if (m_features.has_animation) {
+             // For animation, we have to read and scan whole file to determine loop count and images count
+-            device()->seek(oldPos);
+-
+             if (that->ensureDemuxer()) {
+                 that->m_loop = WebPDemuxGetI(m_demuxer, WEBP_FF_LOOP_COUNT);
+                 that->m_frameCount = WebPDemuxGetI(m_demuxer, WEBP_FF_FRAME_COUNT);
+@@ -126,17 +129,13 @@ bool QWebpHandler::ensureScanned() const
+                 if (that->m_features.has_alpha)
+                     that->m_composited->fill(Qt::transparent);
+ 
+-                // We do not reset device position since we have read in all data
+                 m_scanState = ScanSuccess;
+-                return true;
+             }
+         } else {
+             m_scanState = ScanSuccess;
+         }
+     }
+ 
+-    device()->seek(oldPos);
+-
+     return m_scanState == ScanSuccess;
+ }
+ 
+@@ -159,7 +158,7 @@ bool QWebpHandler::ensureDemuxer()
+ 
+ bool QWebpHandler::read(QImage *image)
+ {
+-    if (!ensureScanned() || device()->isSequential() || !ensureDemuxer())
++    if (!ensureScanned() || !ensureDemuxer())
+         return false;
+ 
+     QRect prevFrameRect;
+Submodule qtlocation 98a5c511..f991e28c:
+diff --git a/qtlocation/src/location/configure.json b/qtlocation/src/location/configure.json
+index 6d01a9a3..d1e623a1 100644
+--- a/qtlocation/src/location/configure.json
++++ b/qtlocation/src/location/configure.json
+@@ -9,7 +9,7 @@
+             "label": "Qt.labs.location experimental QML plugin",
+             "purpose": "Provides experimental QtLocation QML types",
+             "section": "Location",
+-            "condition": "config.opengl",
++            "condition": "features.opengl",
+             "output": [ "privateFeature" ]
+         },
+         "geoservices_osm": {
+diff --git a/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp b/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
+index a978573d..11e1466f 100644
+--- a/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
++++ b/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
+@@ -158,7 +158,7 @@ void QGeoMapObjectQSGSupport::updateMapObjects(QSGNode *root, QQuickWindow *wind
+     if (!root)
+         return;
+ 
+-    if (m_mapObjectsRootNode && m_mapObjectsRootNode->parent())
++    if (m_mapObjectsRootNode && !m_mapObjectsRootNode->parent())
+         root->appendChildNode(m_mapObjectsRootNode.get());
+ 
+     if (!m_mapObjectsRootNode) {
+diff --git a/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
+index 5a40467e..d123c6a8 100644
+--- a/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
+@@ -59,8 +59,10 @@ QT_BEGIN_NAMESPACE
+ static const QString kPrefixEsri(QStringLiteral("esri."));
+ static const QString kParamUserAgent(kPrefixEsri + QStringLiteral("useragent"));
+ 
+-static const QString kUrlGeocode(QStringLiteral("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates"));
+-static const QString kUrlReverseGeocode(QStringLiteral("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode"));
++static const QString kUrlGeocode(QStringLiteral("https://geocode.arcgis.com/arcgis/rest/services/"
++                                                "World/GeocodeServer/findAddressCandidates"));
++static const QString kUrlReverseGeocode(QStringLiteral(
++        "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode"));
+ 
+ static QString addressToQuery(const QGeoAddress &address)
+ {
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
+index 17492d94..96c12b1b 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
+@@ -46,7 +46,8 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-// JSON reference: http://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
++// JSON reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
+ 
+ static const QString kErrorMessage(QStringLiteral("Error %1: %2."));
+ static const QString kErrorJson(QStringLiteral("Error: invalide JSON document."));
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
+index 8cadfb29..92b6bb13 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
+@@ -44,7 +44,8 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-// JSON reference: http://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
++// JSON reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
+ 
+ GeoRouteReplyEsri::GeoRouteReplyEsri(QNetworkReply *reply, const QGeoRouteRequest &request,
+                                      QObject *parent) :
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
+index 0e6bc2c7..ed613f4b 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
+@@ -48,7 +48,8 @@ static const QString kPrefixEsri(QStringLiteral("esri."));
+ static const QString kParamUserAgent(kPrefixEsri + QStringLiteral("useragent"));
+ static const QString kParamToken(kPrefixEsri + QStringLiteral("token"));
+ 
+-static const QString kUrlRouting(QStringLiteral("http://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve"));
++static const QString kUrlRouting(QStringLiteral(
++        "https://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve"));
+ 
+ GeoRoutingManagerEngineEsri::GeoRoutingManagerEngineEsri(const QVariantMap &parameters,
+                                                          QGeoServiceProvider::Error *error,
+@@ -70,7 +71,8 @@ GeoRoutingManagerEngineEsri::~GeoRoutingManagerEngineEsri()
+ {
+ }
+ 
+-// REST reference: http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
++// REST reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
+ 
+ QGeoRouteReply *GeoRoutingManagerEngineEsri::calculateRoute(const QGeoRouteRequest &request)
+ {
+@@ -125,7 +127,7 @@ void GeoRoutingManagerEngineEsri::replyError(QGeoRouteReply::Error errorCode, co
+ QString GeoRoutingManagerEngineEsri::preferedDirectionLangage()
+ {
+     // list of supported langages is defined in:
+-    // http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
++    // https://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
+     const QStringList supportedLanguages = {
+         "ar", // Generate directions in Arabic
+         "cs", // Generate directions in Czech
+diff --git a/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
+index 5d15835d..24148f95 100644
+--- a/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
+@@ -230,7 +230,8 @@ QGeoMap *GeoTiledMappingManagerEngineEsri::createMap()
+ // ${y} = Y
+ // ${token} = Token
+ 
+-// template = 'http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{{z}}/{{y}}/{{x}}.png'
++// template =
++// 'https://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{{z}}/{{y}}/{{x}}.png'
+ 
+ bool GeoTiledMappingManagerEngineEsri::initializeMapSources(QGeoServiceProvider::Error *error,
+                                                             QString *errorString,
+diff --git a/qtlocation/src/plugins/geoservices/esri/maps.json b/qtlocation/src/plugins/geoservices/esri/maps.json
+index 8167ae7d..862e087d 100644
+--- a/qtlocation/src/plugins/geoservices/esri/maps.json
++++ b/qtlocation/src/plugins/geoservices/esri/maps.json
+@@ -6,8 +6,8 @@
+             "description": "ArcGIS Online World Street Map",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=3b93337983e9436f8db950e38a8629af'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=3b93337983e9436f8db950e38a8629af'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -16,8 +16,8 @@
+             "": "ArcGIS Online World Imagery",
+             "mobile": true,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -26,8 +26,8 @@
+             "description": "ArcGIS Online World Terrain Base",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=c61ad8ab017d49e1a82f580ee1298931'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=c61ad8ab017d49e1a82f580ee1298931'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -36,8 +36,8 @@
+             "description": "ArcGIS Online World Topography",
+             "mobile": true,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=30e5fe3149c34df1ba922e6f5bbf808f'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=30e5fe3149c34df1ba922e6f5bbf808f'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -46,8 +46,8 @@
+             "description": "This map presents land cover and detailed topographic maps for the United States.",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=99cd5fbd98934028802b4f797c4b1732'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=99cd5fbd98934028802b4f797c4b1732'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -56,8 +56,8 @@
+             "description": "National Geographic World Map",
+             "mobile": false,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=b9b1b422198944fbbd5250b3241691b6'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=b9b1b422198944fbbd5250b3241691b6'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -66,8 +66,8 @@
+             "description": "Thematic content providing a neutral background with minimal colors",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=ed712cb1db3e4bae9e85329040fb9a49'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=ed712cb1db3e4bae9e85329040fb9a49'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -76,8 +76,8 @@
+             "description": "Natural Earth physical map for the world",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=c4ec722a1cd34cf0a23904aadf8923a0'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=c4ec722a1cd34cf0a23904aadf8923a0'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -86,8 +86,8 @@
+             "description": "Portrays surface elevation as shaded relief",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=9c5370d0b54f4de1b48a3792d7377ff2'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=9c5370d0b54f4de1b48a3792d7377ff2'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -96,8 +96,8 @@
+             "description": "This map is designed to be used as a basemap by marine GIS professionals and as a reference map by anyone interested in ocean data",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=1e126e7520f9466c9ca28b8f28b5e500'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=1e126e7520f9466c9ca28b8f28b5e500'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -106,8 +106,8 @@
+             "description": "Thematic content providing a neutral background with minimal colors",
+             "mobile": false,
+             "night": true,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=a284a9b99b3446a3910d4144a50990f6'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=a284a9b99b3446a3910d4144a50990f6'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -116,8 +116,8 @@
+             "description": "DeLorme’s topographic basemap is a seamless global data set that portrays transportation, hydrography, jurisdiction boundaries, and major geographic features",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/Specialty/DeLorme_World_Base_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=b165c3df453e4be6b5ac4fdb241effbe'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/Specialty/DeLorme_World_Base_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=b165c3df453e4be6b5ac4fdb241effbe'>Esri</a> contributors"
+         }
+     ]
+ }
+diff --git a/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
+index 3858ddf5..af66f28e 100644
+--- a/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
+@@ -63,8 +63,10 @@ static const QString kCountriesKey(QStringLiteral("detailedCountries"));
+ static const QString kLocalizedNamesKey(QStringLiteral("localizedNames"));
+ static const QString kMaxLocationsKey(QStringLiteral("maxLocations"));
+ 
+-static const QUrl kUrlGeocodeServer("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer?f=pjson");
+-static const QUrl kUrlFindAddressCandidates("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates");
++static const QUrl kUrlGeocodeServer(
++        "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer?f=pjson");
++static const QUrl kUrlFindAddressCandidates("https://geocode.arcgis.com/arcgis/rest/services/World/"
++                                            "GeocodeServer/findAddressCandidates");
+ 
+ PlaceManagerEngineEsri::PlaceManagerEngineEsri(const QVariantMap &parameters, QGeoServiceProvider::Error *error,
+                                                QString *errorString) :
+Submodule qtmultimedia f0344079..0d7cc33a:
+diff --git a/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp b/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
+index 2b5325132..b68b4af1b 100644
+--- a/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
++++ b/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
+@@ -402,6 +402,8 @@ int QPulseAudioInput::bytesReady() const
+ 
+ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ {
++    Q_ASSERT(data != nullptr || len == 0);
++
+     m_bytesAvailable = checkBytesReady();
+ 
+     setError(QAudio::NoError);
+@@ -411,7 +413,8 @@ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ 
+     if (!m_pullMode && !m_tempBuffer.isEmpty()) {
+         readBytes = qMin(static_cast<int>(len), m_tempBuffer.size());
+-        memcpy(data, m_tempBuffer.constData(), readBytes);
++        if (readBytes)
++            memcpy(data, m_tempBuffer.constData(), readBytes);
+         m_totalTimeValue += readBytes;
+ 
+         if (readBytes < m_tempBuffer.size()) {
+@@ -502,9 +505,10 @@ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ 
+ void QPulseAudioInput::applyVolume(const void *src, void *dest, int len)
+ {
++    Q_ASSERT((src && dest) || len == 0);
+     if (m_volume < 1.f)
+         QAudioHelperInternal::qMultiplySamples(m_volume, m_format, src, dest, len);
+-    else
++    else if (len)
+         memcpy(dest, src, len);
+ }
+ 
+Submodule qtpim 02efef5e...f9a8f0fc (commits not present)
+Submodule qtquick3d b85cf622..47defc8b:
+diff --git a/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro b/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
+index ca5c499e..174a075b 100644
+--- a/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
++++ b/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
+@@ -10,7 +10,7 @@ QT_FOR_CONFIG += assetimporters-private
+ include($$OUT_PWD/../qtassetimporters-config.pri)
+ 
+ qtConfig(system-assimp):!if(cross_compile:host_build) {
+-    QMAKE_USE_PRIVATE += assimp
++    QMAKE_USE_PRIVATE += quick3d-assimp
+ } else {
+     include(../../../3rdparty/assimp/assimp.pri)
+ }
+Submodule qtquickcontrols2 3a657dc0..56ce8233:
+diff --git a/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp b/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
+index e5fe734f7..e36922775 100644
+--- a/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
++++ b/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
+@@ -38,6 +38,7 @@
+ #include "qwidgetplatformmenuitem_p.h"
+ 
+ #include <QtGui/qwindow.h>
++#include <QtGui/private/qhighdpiscaling_p.h>
+ #include <QtWidgets/qmenu.h>
+ #include <QtWidgets/qaction.h>
+ 
+@@ -145,7 +146,7 @@ void QWidgetPlatformMenu::showPopup(const QWindow *window, const QRect &targetRe
+ 
+     QPoint targetPos = targetRect.bottomLeft();
+     if (window)
+-        targetPos = window->mapToGlobal(targetPos);
++        targetPos = window->mapToGlobal(QHighDpi::fromNativeLocalPosition(targetPos, window));
+ 
+     const QWidgetPlatformMenuItem *widgetItem = qobject_cast<const QWidgetPlatformMenuItem *>(item);
+     m_menu->popup(targetPos, widgetItem ? widgetItem->action() : nullptr);
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
+index 950e4e099..b81fbea0b 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
+@@ -387,6 +387,17 @@ void QQuickAbstractButtonPrivate::itemImplicitHeightChanged(QQuickItem *item)
+         emit q->implicitIndicatorHeightChanged();
+ }
+ 
++void QQuickAbstractButtonPrivate::itemDestroyed(QQuickItem *item)
++{
++    Q_Q(QQuickAbstractButton);
++    QQuickControlPrivate::itemDestroyed(item);
++    if (item == indicator) {
++        indicator = nullptr;
++        emit q->implicitIndicatorWidthChanged();
++        emit q->implicitIndicatorHeightChanged();
++    }
++}
++
+ QQuickAbstractButton *QQuickAbstractButtonPrivate::findCheckedButton() const
+ {
+     Q_Q(const QQuickAbstractButton);
+@@ -1176,6 +1187,12 @@ QAccessible::Role QQuickAbstractButton::accessibleRole() const
+     }
+     return QAccessible::Button;
+ }
++
++void QQuickAbstractButton::accessiblePressAction()
++{
++    Q_D(QQuickAbstractButton);
++    d->trigger();
++}
+ #endif
+ 
+ QT_END_NAMESPACE
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
+index 0fa48980e..ab66220d0 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
+@@ -209,6 +209,7 @@ protected:
+ #if QT_CONFIG(accessibility)
+     void accessibilityActiveChanged(bool active) override;
+     QAccessible::Role accessibleRole() const override;
++    Q_INVOKABLE void accessiblePressAction();
+ #endif
+ 
+ private:
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
+index 9291c1a87..b729720f2 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
+@@ -109,6 +109,7 @@ public:
+ 
+     void itemImplicitWidthChanged(QQuickItem *item) override;
+     void itemImplicitHeightChanged(QQuickItem *item) override;
++    void itemDestroyed(QQuickItem *item) override;
+ 
+     // copied from qabstractbutton.cpp
+     static const int AUTO_REPEAT_DELAY = 300;
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp b/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
+index 2041e7741..8610cdfae 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
+@@ -145,7 +145,7 @@ int QQuickActionPrivate::ShortcutEntry::shortcutId() const
+ 
+ void QQuickActionPrivate::ShortcutEntry::grab(const QKeySequence &shortcut, bool enabled)
+ {
+-    if (shortcut.isEmpty())
++    if (shortcut.isEmpty() || m_shortcutId)
+         return;
+ 
+     Qt::ShortcutContext context = Qt::WindowShortcut; // TODO
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp b/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
+index f38c2b09c..6eed2a024 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
+@@ -225,6 +225,7 @@ void QQuickContainerPrivate::cleanup()
+     QObject::disconnect(contentModel, &QQmlObjectModel::countChanged, q, &QQuickContainer::countChanged);
+     QObject::disconnect(contentModel, &QQmlObjectModel::childrenChanged, q, &QQuickContainer::contentChildrenChanged);
+     delete contentModel;
++    contentModel = nullptr;
+ }
+ 
+ QQuickItem *QQuickContainerPrivate::itemAt(int index) const
+@@ -436,7 +437,7 @@ void QQuickContainerPrivate::contentChildren_clear(QQmlListProperty<QQuickItem>
+ void QQuickContainerPrivate::updateContentWidth()
+ {
+     Q_Q(QQuickContainer);
+-    if (hasContentWidth || qFuzzyCompare(contentWidth, implicitContentWidth))
++    if (hasContentWidth || qFuzzyCompare(contentWidth, implicitContentWidth) || !contentModel)
+         return;
+ 
+     contentWidth = implicitContentWidth;
+@@ -446,7 +447,7 @@ void QQuickContainerPrivate::updateContentWidth()
+ void QQuickContainerPrivate::updateContentHeight()
+ {
+     Q_Q(QQuickContainer);
+-    if (hasContentHeight || qFuzzyCompare(contentHeight, implicitContentHeight))
++    if (hasContentHeight || qFuzzyCompare(contentHeight, implicitContentHeight) || !contentModel)
+         return;
+ 
+     contentHeight = implicitContentHeight;
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp b/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
+index bbbd0e622..1f4b47343 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
+@@ -845,6 +845,13 @@ void QQuickControlPrivate::executeBackground(bool complete)
+         quickCompleteDeferred(q, backgroundName(), background);
+ }
+ 
++/*
++    \internal
++
++    Hides an item that was replaced by a newer one, rather than
++    deleting it, as the item is typically created in QML and hence
++    we don't own it.
++*/
+ void QQuickControlPrivate::hideOldItem(QQuickItem *item)
+ {
+     if (!item)
+@@ -863,6 +870,29 @@ void QQuickControlPrivate::hideOldItem(QQuickItem *item)
+ #endif
+ }
+ 
++/*
++    \internal
++
++    Named "unhide" because it's used for cases where an item
++    that was previously hidden by \l hideOldItem() wants to be
++    shown by a control again, such as a ScrollBar in ScrollView.
++*/
++void QQuickControlPrivate::unhideOldItem(QQuickControl *control, QQuickItem *item)
++{
++    Q_ASSERT(item);
++    qCDebug(lcItemManagement) << "unhiding old item" << item;
++
++    item->setVisible(true);
++    item->setParentItem(control);
++
++#if QT_CONFIG(accessibility)
++    // Add the item back in to the accessibility tree.
++    QQuickAccessibleAttached *accessible = accessibleAttached(item);
++    if (accessible)
++        accessible->setIgnored(false);
++#endif
++}
++
+ void QQuickControlPrivate::updateBaselineOffset()
+ {
+     Q_Q(QQuickControl);
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h b/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
+index 8e979079e..a6e624c91 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
+@@ -173,6 +173,7 @@ public:
+     virtual void executeBackground(bool complete = false);
+ 
+     static void hideOldItem(QQuickItem *item);
++    static void unhideOldItem(QQuickControl *control, QQuickItem *item);
+ 
+     void updateBaselineOffset();
+ 
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp b/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
+index e6db14eb5..6197d1547 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
+@@ -237,7 +237,7 @@ static QRectF alignedRect(Qt::LayoutDirection direction, Qt::Alignment alignment
+ void QQuickDialogButtonBoxPrivate::resizeContent()
+ {
+     Q_Q(QQuickDialogButtonBox);
+-    if (!contentItem)
++    if (!contentItem || !contentModel)
+         return;
+ 
+     QRectF geometry = q->boundingRect().adjusted(q->leftPadding(), q->topPadding(), -q->rightPadding(), -q->bottomPadding());
+@@ -322,6 +322,9 @@ void QQuickDialogButtonBoxPrivate::updateLayout()
+ qreal QQuickDialogButtonBoxPrivate::getContentWidth() const
+ {
+     Q_Q(const QQuickDialogButtonBox);
++    if (!contentModel)
++        return 0;
++
+     const int count = contentModel->count();
+     const qreal totalSpacing = qMax(0, count - 1) * spacing;
+     qreal totalWidth = totalSpacing;
+@@ -341,6 +344,9 @@ qreal QQuickDialogButtonBoxPrivate::getContentWidth() const
+ qreal QQuickDialogButtonBoxPrivate::getContentHeight() const
+ {
+     Q_Q(const QQuickDialogButtonBox);
++    if (!contentModel)
++        return 0;
++
+     const int count = contentModel->count();
+     qreal maxHeight = 0;
+     for (int i = 0; i < count; ++i) {
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp b/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
+index 91bd59184..0ce518f84 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
+@@ -399,8 +399,11 @@ void QQuickOverlay::itemChange(ItemChange change, const ItemChangeData &data)
+     Q_D(QQuickOverlay);
+     QQuickItem::itemChange(change, data);
+ 
+-    if (change == ItemChildAddedChange || change == ItemChildRemovedChange)
++    if (change == ItemChildAddedChange || change == ItemChildRemovedChange) {
+         setVisible(!d->allDrawers.isEmpty() || !childItems().isEmpty());
++        if (data.item->parent() == d->mouseGrabberPopup)
++            d->setMouseGrabberPopup(nullptr);
++    }
+ }
+ 
+ void QQuickOverlay::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp b/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
+index 4e2f509db..1c4b308cd 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
+@@ -797,6 +797,14 @@ void QQuickScrollBarAttachedPrivate::initHorizontal()
+     if (parent && parent == flickable->parentItem())
+         horizontal->stackAfter(flickable);
+ 
++    // If a scroll bar was previously hidden (due to e.g. setting a new contentItem
++    // on a ScrollView), we need to make sure that we un-hide it.
++    // We don't bother checking if the item is actually the old one, because
++    // if it's not, all of the things the function does (setting parent, visibility, etc.)
++    // should be no-ops anyway.
++    if (auto control = qobject_cast<QQuickControl*>(q_ptr->parent()))
++        QQuickControlPrivate::unhideOldItem(control, horizontal);
++
+     layoutHorizontal();
+     horizontal->setSize(area->property("widthRatio").toReal());
+     horizontal->setPosition(area->property("xPosition").toReal());
+@@ -818,6 +826,9 @@ void QQuickScrollBarAttachedPrivate::initVertical()
+     if (parent && parent == flickable->parentItem())
+         vertical->stackAfter(flickable);
+ 
++    if (auto control = qobject_cast<QQuickControl*>(q_ptr->parent()))
++        QQuickControlPrivate::unhideOldItem(control, vertical);
++
+     layoutVertical();
+     vertical->setSize(area->property("heightRatio").toReal());
+     vertical->setPosition(area->property("yPosition").toReal());
+diff --git a/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml b/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
+index 0e8b08352..cd4931184 100644
+--- a/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
++++ b/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
+@@ -576,4 +576,51 @@ TestCase {
+         verify(newHorizontalScrollBar.visible)
+         verify(!oldHorizontalScrollBar.visible)
+     }
++
++    Component {
++        id: bindingToContentItemAndStandaloneFlickable
++
++        Item {
++            width: 200
++            height: 200
++
++            property alias scrollView: scrollView
++
++            ScrollView {
++                id: scrollView
++                anchors.fill: parent
++                contentItem: listView
++
++                property Item someBinding: contentItem
++            }
++            ListView {
++                id: listView
++                model: 10
++                delegate: ItemDelegate {
++                    text: modelData
++                    width: listView.width
++                }
++            }
++        }
++    }
++
++    // Tests that scroll bars show up for a ScrollView where
++    // - its contentItem is declared as a standalone, separate item
++    // - there is a binding to contentItem (which causes a default Flickable to be created)
++    function test_bindingToContentItemAndStandaloneFlickable() {
++        let root = createTemporaryObject(bindingToContentItemAndStandaloneFlickable, testCase)
++        verify(root)
++
++        let control = root.scrollView
++        let verticalScrollBar = control.ScrollBar.vertical
++        let horizontalScrollBar = control.ScrollBar.horizontal
++        compare(verticalScrollBar.parent, control)
++        compare(horizontalScrollBar.parent, control)
++        verify(verticalScrollBar.visible)
++        verify(horizontalScrollBar.visible)
++
++        mouseDrag(verticalScrollBar, verticalScrollBar.width / 2, verticalScrollBar.height / 2, 0, 50)
++        verify(verticalScrollBar.active)
++        verify(horizontalScrollBar.active)
++    }
+ }
+diff --git a/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml b/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
+index b3fab41ca..10b6baa02 100644
+--- a/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
++++ b/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
+@@ -608,4 +608,27 @@ TestCase {
+         mouseClick(control.indicator)
+         verify(control.activeFocus)
+     }
++
++    Component {
++        id: deletionOrder1
++        Item {
++            Image { id: innerImage }
++            Switch { indicator: innerImage }
++        }
++    }
++
++    Component {
++        id: deletionOrder2
++        Item {
++            Switch { indicator: innerImage }
++            Image { id: innerImage }
++        }
++    }
++
++    function test_deletionOrder() {
++        var control1 = createTemporaryObject(deletionOrder1, testCase)
++        verify(control1)
++        var control2 = createTemporaryObject(deletionOrder2, testCase)
++        verify(control2)
++    }
+ }
+diff --git a/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml b/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml
+new file mode 100644
+index 000000000..9e4598b9f
+--- /dev/null
++++ b/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml
+@@ -0,0 +1,78 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the test suite of the Qt Toolkit.
++**
++** $QT_BEGIN_LICENSE:BSD$
++** Commercial License Usage
++** Licensees holding valid commercial Qt licenses may use this file in
++** accordance with the commercial license agreement provided with the
++** Software or, alternatively, in accordance with the terms contained in
++** a written agreement between you and The Qt Company. For licensing terms
++** and conditions see https://www.qt.io/terms-conditions. For further
++** information use the contact form at https://www.qt.io/contact-us.
++**
++** BSD License Usage
++** Alternatively, you may use this file under the terms of the BSD license
++** as follows:
++**
++** "Redistribution and use in source and binary forms, with or without
++** modification, are permitted provided that the following conditions are
++** met:
++**   * Redistributions of source code must retain the above copyright
++**     notice, this list of conditions and the following disclaimer.
++**   * Redistributions in binary form must reproduce the above copyright
++**     notice, this list of conditions and the following disclaimer in
++**     the documentation and/or other materials provided with the
++**     distribution.
++**   * Neither the name of The Qt Company Ltd nor the names of its
++**     contributors may be used to endorse or promote products derived
++**     from this software without specific prior written permission.
++**
++**
++** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
++** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
++** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
++** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
++** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
++** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
++** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
++** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
++** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
++** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
++** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
++**
++** $QT_END_LICENSE$
++**
++****************************************************************************/
++
++import QtQuick 2.15
++import QtQuick.Controls 2.15
++
++ApplicationWindow {
++    id: window
++    width: 400
++    height: 400
++    title: "releaseAfterExitTransition"
++
++    property alias popup: popup
++    property alias modalPopup: modalPopup
++
++    Popup {
++        id: popup
++        y: parent.height - height
++        width: 50
++        height: 50
++    }
++
++    Popup {
++        id: modalPopup
++        modal: true
++        y: parent.height - height
++        width: 50
++        height: 50
++        exit:  Transition { PauseAnimation { duration: 100 } }
++    }
++}
+diff --git a/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp b/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
+index 54952d128..3d50e2dd4 100644
+--- a/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
++++ b/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
+@@ -100,6 +100,7 @@ private slots:
+     void invisibleToolTipOpen();
+     void centerInOverlayWithinStackViewItem();
+     void destroyDuringExitTransition();
++    void releaseAfterExitTransition();
+ };
+ 
+ void tst_QQuickPopup::initTestCase()
+@@ -1575,6 +1576,34 @@ void tst_QQuickPopup::destroyDuringExitTransition()
+     QVERIFY(!button->isDown());
+ }
+ 
++void tst_QQuickPopup::releaseAfterExitTransition()
++{
++    QQuickApplicationHelper helper(this, "releaseAfterExitTransition.qml");
++    QVERIFY2(helper.ready, helper.failureMessage());
++
++    QQuickWindow *window = helper.window;
++    window->show();
++    QVERIFY(QTest::qWaitForWindowActive(window));
++
++    QQuickOverlay *overlay = QQuickOverlay::overlay(window);
++    QQuickPopup *modalPopup = window->property("modalPopup").value<QQuickPopup *>();
++    QQuickPopup *popup = window->property("popup").value<QQuickPopup *>();
++
++    modalPopup->open();
++    QTRY_VERIFY(modalPopup->isOpened());
++
++    QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++    // wait until the transition is finished and the overlay hides itself
++    QTRY_VERIFY(!overlay->isVisible());
++    QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++
++    popup->open();
++    QTRY_VERIFY(popup->isOpened());
++    QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++    QTRY_VERIFY(!popup->isOpened());
++}
++
++
+ QTEST_QUICKCONTROLS_MAIN(tst_QQuickPopup)
+ 
+ #include "tst_qquickpopup.moc"
+Submodule qtscript 5be95f96...4d8e4bd2 (commits not present)
+Submodule qtspeech 17fc9fde..255845e2:
+diff --git a/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp b/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
+index 6eb74b8..bcc7dd1 100644
+--- a/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
++++ b/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
+@@ -357,7 +357,9 @@ QVector<QLocale> QTextToSpeechEngineSpeechd::availableLocales() const
+ 
+ QVector<QVoice> QTextToSpeechEngineSpeechd::availableVoices() const
+ {
+-    return m_voices.values(m_currentLocale.name()).toVector();
++    QList<QVoice> resultList = m_voices.values(m_currentLocale.name());
++    std::reverse(resultList.begin(), resultList.end());
++    return resultList.toVector();
+ }
+ 
+ // We have no way of knowing our own client_id since speech-dispatcher seems to be incomplete
+Submodule qtsvg 0c05780e..a7a0f249:
+diff --git a/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp b/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
+index 561e77e..12e0574 100644
+--- a/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
++++ b/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
+@@ -191,6 +191,8 @@ bool QSvgIOHandler::read(QImage *image)
+             }
+         }
+         if (!finalSize.isEmpty()) {
++            if (qMax(finalSize.width(), finalSize.height()) > 0xffff)
++                return false; // Assume corrupted file
+             image->fill(d->backColor.rgba());
+             QPainter p(image);
+             d->r.render(&p, bounds);
+diff --git a/qtsvg/src/svg/qsvghandler.cpp b/qtsvg/src/svg/qsvghandler.cpp
+index a5f877f..8dda563 100644
+--- a/qtsvg/src/svg/qsvghandler.cpp
++++ b/qtsvg/src/svg/qsvghandler.cpp
+@@ -1393,9 +1393,10 @@ static void parseFont(QSvgNode *node,
+         case FontSizeNone:
+             break;
+         case FontSizeValue: {
+-            QSvgHandler::LengthType dummy; // should always be pixel size
+-            fontStyle->setSize(qMin(parseLength(attributes.fontSize, dummy, handler),
+-                                    qreal(0xffff)));
++            QSvgHandler::LengthType type;
++            qreal fs = parseLength(attributes.fontSize, type, handler);
++            fs = convertToPixels(fs, true, type);
++            fontStyle->setSize(qMin(fs, qreal(0xffff)));
+         }
+             break;
+         default:
+@@ -2513,6 +2514,8 @@ static bool parseAnimateTransformNode(QSvgNode *parent,
+             ++s;
+         }
+     }
++    if (vals.count() % 3 != 0)
++        return false;
+ 
+     bool ok = true;
+     int begin = parseClockValue(beginStr, &ok);
+@@ -2576,6 +2579,8 @@ static QSvgNode *createCircleNode(QSvgNode *parent,
+     qreal ncx = toDouble(cx);
+     qreal ncy = toDouble(cy);
+     qreal nr  = toDouble(r);
++    if (nr < 0.0)
++        return nullptr;
+ 
+     QRectF rect(ncx-nr, ncy-nr, nr*2, nr*2);
+     QSvgNode *circle = new QSvgCircle(parent, rect);
+@@ -3046,15 +3051,16 @@ static QSvgStyleProperty *createRadialGradientNode(QSvgNode *node,
+ 
+     qreal ncx = 0.5;
+     qreal ncy = 0.5;
+-    qreal nr  = 0.5;
+     if (!cx.isEmpty())
+         ncx = toDouble(cx);
+     if (!cy.isEmpty())
+         ncy = toDouble(cy);
++
++    qreal nr = 0.0;
+     if (!r.isEmpty())
+         nr = toDouble(r);
+-    if (nr < 0.5)
+-        nr = 0.5;
++    if (nr <= 0.0)
++        return nullptr;
+ 
+     qreal nfx = ncx;
+     if (!fx.isEmpty())
+@@ -3350,7 +3356,9 @@ static QSvgNode *createTextNode(QSvgNode *parent,
+     //### editable and rotate not handled
+     QSvgHandler::LengthType type;
+     qreal nx = parseLength(x, type, handler);
++    nx = convertToPixels(nx, true, type);
+     qreal ny = parseLength(y, type, handler);
++    ny = convertToPixels(ny, true, type);
+ 
+     QSvgNode *text = new QSvgText(parent, QPointF(nx, ny));
+     return text;
+@@ -3691,9 +3699,7 @@ void QSvgHandler::parse()
+         case QXmlStreamReader::EndElement:
+             endElement(xml->name());
+             ++remainingUnfinishedElements;
+-            // if we are using somebody else's qxmlstreamreader
+-            // we should not read until the end of the stream
+-            done = !m_ownsReader && (xml->name() == QLatin1String("svg"));
++            done = (xml->name() == QLatin1String("svg"));
+             break;
+         case QXmlStreamReader::Characters:
+             characters(xml->text());
+diff --git a/qtsvg/src/svg/qsvgstructure.cpp b/qtsvg/src/svg/qsvgstructure.cpp
+index b89608b..89c9e4e 100644
+--- a/qtsvg/src/svg/qsvgstructure.cpp
++++ b/qtsvg/src/svg/qsvgstructure.cpp
+@@ -255,9 +255,13 @@ inline static bool isSupportedSvgFeature(const QString &str)
+     };
+ 
+     if (str.length() <= MAX_WORD_LENGTH && str.length() >= MIN_WORD_LENGTH) {
++        const char16_t unicode44 = str.at(44).unicode();
++        const char16_t unicode45 = str.at(45).unicode();
++        if (unicode44 >= sizeof(asso_values) || unicode45 >= sizeof(asso_values))
++            return false;
+         const int key = str.length()
+-                        + asso_values[str.at(45).unicode()]
+-                        + asso_values[str.at(44).unicode()];
++                        + asso_values[unicode45]
++                        + asso_values[unicode44];
+         if (key <= MAX_HASH_VALUE && key >= 0)
+             return str == QLatin1String(wordlist[key]);
+     }
+diff --git a/qtsvg/src/svg/qsvgtinydocument.cpp b/qtsvg/src/svg/qsvgtinydocument.cpp
+index 63d0797..19e7154 100644
+--- a/qtsvg/src/svg/qsvgtinydocument.cpp
++++ b/qtsvg/src/svg/qsvgtinydocument.cpp
+@@ -433,8 +433,16 @@ void QSvgTinyDocument::draw(QPainter *p, QSvgExtraStates &)
+     draw(p);
+ }
+ 
++static bool isValidMatrix(const QTransform &transform)
++{
++    qreal determinant = transform.determinant();
++    return qIsFinite(determinant);
++}
++
+ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect, const QRectF &sourceRect)
+ {
++    QTransform oldTransform = p->worldTransform();
++
+     QRectF target = targetRect;
+     if (target.isEmpty()) {
+         QPaintDevice *dev = p->device();
+@@ -487,6 +495,9 @@ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect,
+         }
+ #endif
+     }
++
++    if (!isValidMatrix(p->worldTransform()))
++        p->setWorldTransform(oldTransform);
+ }
+ 
+ QRectF QSvgTinyDocument::boundsOnElement(const QString &id) const
+diff --git a/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp b/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
+index 36c76ec..db71e02 100644
+--- a/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
++++ b/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
+@@ -86,6 +86,8 @@ private slots:
+     void oss_fuzz_23731();
+     void oss_fuzz_24131();
+     void oss_fuzz_24738();
++    void illegalAnimateTransform_data();
++    void illegalAnimateTransform();
+ 
+ #ifndef QT_NO_COMPRESS
+     void testGzLoading();
+@@ -1646,5 +1648,22 @@ void tst_QSvgRenderer::oss_fuzz_24738()
+     QSvgRenderer().load(QByteArray("<svg><path d=\"a 2 1e-212.....\">"));
+ }
+ 
++void tst_QSvgRenderer::illegalAnimateTransform_data()
++{
++    QTest::addColumn<QByteArray>("svg");
++
++    QTest::newRow("case1") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" values=\"8,0,5,0\">");
++    QTest::newRow("case2") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" values=\"1,2\">");
++    QTest::newRow("case3") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" from=\".. 5 2\" to=\"f\">");
++    QTest::newRow("case4") << QByteArray("<svg><animateTransform type=\"scale\" begin=\"1\" dur=\"2\" by=\"--,..\">");
++}
++
++void tst_QSvgRenderer::illegalAnimateTransform()
++{
++    QFETCH(QByteArray, svg);
++    QSvgRenderer renderer;
++    QVERIFY(!renderer.load(svg)); // also shouldn't assert
++}
++
+ QTEST_MAIN(tst_QSvgRenderer)
+ #include "tst_qsvgrenderer.moc"
+Submodule qttools 6914f7c8..090e526e:
+diff --git a/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp b/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
+index feab1e2d5..cbfb82507 100644
+--- a/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
++++ b/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
+@@ -445,7 +445,9 @@ bool HelpGeneratorPrivate::insertFiles(const QStringList &files, const QString &
+     if (filterSetId < 0)
+         return false;
+     ++filterSetId;
+-    for (int attId : qAsConst(filterAtts)) {
++    QList<int> attValues = filterAtts.values();
++    std::sort(attValues.begin(), attValues.end());
++    for (int attId : qAsConst(attValues)) {
+         m_query->prepare(QLatin1String("INSERT INTO FileAttributeSetTable "
+             "VALUES(?, ?)"));
+         m_query->bindValue(0, filterSetId);
+Submodule qtwayland dfb0129c..2904e1b3:
+diff --git a/qtwayland/src/client/configure.json b/qtwayland/src/client/configure.json
+index 2f424580..29222357 100644
+--- a/qtwayland/src/client/configure.json
++++ b/qtwayland/src/client/configure.json
+@@ -149,8 +149,7 @@
+                     "#endif"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "vulkan-server-buffer": {
+             "label": "Vulkan Buffer Sharing",
+@@ -168,7 +167,8 @@
+                     "exportAllocInfo.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR;",
+                     "return 0;"
+                 ]
+-            }
++            },
++            "use": "wayland-client"
+         },
+         "egl_1_5-wayland": {
+             "label": "EGL 1.5 with Wayland Platform",
+@@ -183,7 +183,7 @@
+                     "eglGetPlatformDisplay(EGL_PLATFORM_WAYLAND_EXT, (struct wl_display *)(nullptr), nullptr);"
+                 ]
+             },
+-            "use": "egl"
++            "use": "egl wayland-client"
+         }
+     },
+ 
+diff --git a/qtwayland/src/client/global/qwaylandclientextension.cpp b/qtwayland/src/client/global/qwaylandclientextension.cpp
+index 125b1e19..edccfe63 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension.cpp
++++ b/qtwayland/src/client/global/qwaylandclientextension.cpp
+@@ -74,7 +74,10 @@ void QWaylandClientExtensionPrivate::handleRegistryGlobal(void *data, ::wl_regis
+ void QWaylandClientExtension::addRegistryListener()
+ {
+     Q_D(QWaylandClientExtension);
+-    d->waylandIntegration->display()->addRegistryListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++    if (!d->registered) {
++        d->waylandIntegration->display()->addRegistryListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++        d->registered = true;
++    }
+ }
+ 
+ QWaylandClientExtension::QWaylandClientExtension(const int ver)
+@@ -88,6 +91,13 @@ QWaylandClientExtension::QWaylandClientExtension(const int ver)
+     QMetaObject::invokeMethod(this, "addRegistryListener", Qt::QueuedConnection);
+ }
+ 
++QWaylandClientExtension::~QWaylandClientExtension()
++{
++    Q_D(QWaylandClientExtension);
++    if (d->registered && !QCoreApplication::closingDown())
++        d->waylandIntegration->display()->removeListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++}
++
+ QtWaylandClient::QWaylandIntegration *QWaylandClientExtension::integration() const
+ {
+     Q_D(const QWaylandClientExtension);
+diff --git a/qtwayland/src/client/global/qwaylandclientextension.h b/qtwayland/src/client/global/qwaylandclientextension.h
+index 98272e57..5bd28398 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension.h
++++ b/qtwayland/src/client/global/qwaylandclientextension.h
+@@ -63,6 +63,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandClientExtension : public QObject
+     Q_PROPERTY(bool active READ isActive NOTIFY activeChanged)
+ public:
+     QWaylandClientExtension(const int version);
++    ~QWaylandClientExtension();
+ 
+     QtWaylandClient::QWaylandIntegration *integration() const;
+     int version() const;
+diff --git a/qtwayland/src/client/global/qwaylandclientextension_p.h b/qtwayland/src/client/global/qwaylandclientextension_p.h
+index 69cc46a0..9091efbe 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension_p.h
++++ b/qtwayland/src/client/global/qwaylandclientextension_p.h
+@@ -68,6 +68,7 @@ public:
+     QtWaylandClient::QWaylandIntegration *waylandIntegration = nullptr;
+     int version = -1;
+     bool active = false;
++    bool registered = false;
+ };
+ 
+ class Q_WAYLAND_CLIENT_EXPORT QWaylandClientExtensionTemplatePrivate : public QWaylandClientExtensionPrivate
+diff --git a/qtwayland/src/client/qwaylanddatadevice.cpp b/qtwayland/src/client/qwaylanddatadevice.cpp
+index 7e2e3308..e3e60ed5 100644
+--- a/qtwayland/src/client/qwaylanddatadevice.cpp
++++ b/qtwayland/src/client/qwaylanddatadevice.cpp
+@@ -72,6 +72,8 @@ QWaylandDataDevice::QWaylandDataDevice(QWaylandDataDeviceManager *manager, QWayl
+ 
+ QWaylandDataDevice::~QWaylandDataDevice()
+ {
++    if (wl_data_device_get_version(object()) >= WL_DATA_DEVICE_RELEASE_SINCE_VERSION)
++        release();
+ }
+ 
+ QWaylandDataOffer *QWaylandDataDevice::selectionOffer() const
+@@ -110,7 +112,7 @@ QWaylandDataOffer *QWaylandDataDevice::dragOffer() const
+     return m_dragOffer.data();
+ }
+ 
+-bool QWaylandDataDevice::startDrag(QMimeData *mimeData, QWaylandWindow *icon)
++bool QWaylandDataDevice::startDrag(QMimeData *mimeData, Qt::DropActions supportedActions, QWaylandWindow *icon)
+ {
+     auto *seat = m_display->currentInputDevice();
+     auto *origin = seat->pointerFocus();
+@@ -123,7 +125,28 @@ bool QWaylandDataDevice::startDrag(QMimeData *mimeData, QWaylandWindow *icon)
+     }
+ 
+     m_dragSource.reset(new QWaylandDataSource(m_display->dndSelectionHandler(), mimeData));
++
++    if (wl_data_device_get_version(object()) >= 3)
++        m_dragSource->set_actions(dropActionsToWl(supportedActions));
++
+     connect(m_dragSource.data(), &QWaylandDataSource::cancelled, this, &QWaylandDataDevice::dragSourceCancelled);
++    connect(m_dragSource.data(), &QWaylandDataSource::dndResponseUpdated, this, [this](bool accepted, Qt::DropAction action) {
++            auto drag = static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag());
++            // in old versions drop action is not set, so we guess
++            if (wl_data_source_get_version(m_dragSource->object()) < 3) {
++                drag->setResponse(accepted);
++            } else {
++                QPlatformDropQtResponse response(accepted, action);
++                drag->setResponse(response);
++            }
++    });
++    connect(m_dragSource.data(), &QWaylandDataSource::dndDropped, this, [](bool accepted, Qt::DropAction action) {
++        QPlatformDropQtResponse response(accepted, action);
++        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setDropResponse(response);
++    });
++    connect(m_dragSource.data(), &QWaylandDataSource::finished, this, []() {
++        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag();
++    });
+ 
+     start_drag(m_dragSource->object(), origin->wlSurface(), icon->wlSurface(), m_display->currentInputDevice()->serial());
+     return true;
+@@ -152,7 +175,7 @@ void QWaylandDataDevice::data_device_drop()
+         supportedActions = drag->supportedActions();
+     } else if (m_dragOffer) {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     } else {
+         return;
+     }
+@@ -162,7 +185,11 @@ void QWaylandDataDevice::data_device_drop()
+                                                                           QGuiApplication::keyboardModifiers());
+ 
+     if (drag) {
+-        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag(response);
++        auto drag =  static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag());
++        drag->setDropResponse(response);
++        drag->finishDrag();
++    } else if (m_dragOffer) {
++        m_dragOffer->finish();
+     }
+ }
+ 
+@@ -186,7 +213,7 @@ void QWaylandDataDevice::data_device_enter(uint32_t serial, wl_surface *surface,
+         supportedActions = drag->supportedActions();
+     } else if (m_dragOffer) {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     }
+ 
+     const QPlatformDragQtResponse &response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
+@@ -197,11 +224,7 @@ void QWaylandDataDevice::data_device_enter(uint32_t serial, wl_surface *surface,
+         static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setResponse(response);
+     }
+ 
+-    if (response.isAccepted()) {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, m_dragOffer->firstFormat().toUtf8().constData());
+-    } else {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, nullptr);
+-    }
++    sendResponse(supportedActions, response);
+ }
+ 
+ void QWaylandDataDevice::data_device_leave()
+@@ -235,10 +258,10 @@ void QWaylandDataDevice::data_device_motion(uint32_t time, wl_fixed_t x, wl_fixe
+         supportedActions = drag->supportedActions();
+     } else {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     }
+ 
+-    QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
++    const QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
+                                                                           QGuiApplication::mouseButtons(),
+                                                                           QGuiApplication::keyboardModifiers());
+ 
+@@ -246,11 +269,7 @@ void QWaylandDataDevice::data_device_motion(uint32_t time, wl_fixed_t x, wl_fixe
+         static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setResponse(response);
+     }
+ 
+-    if (response.isAccepted()) {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, m_dragOffer->firstFormat().toUtf8().constData());
+-    } else {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, nullptr);
+-    }
++    sendResponse(supportedActions, response);
+ }
+ #endif // QT_CONFIG(draganddrop)
+ 
+@@ -277,14 +296,10 @@ void QWaylandDataDevice::selectionSourceCancelled()
+ #if QT_CONFIG(draganddrop)
+ void QWaylandDataDevice::dragSourceCancelled()
+ {
++    static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag();
+     m_dragSource.reset();
+ }
+ 
+-void QWaylandDataDevice::dragSourceTargetChanged(const QString &mimeType)
+-{
+-    static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->updateTarget(mimeType);
+-}
+-
+ QPoint QWaylandDataDevice::calculateDragPosition(int x, int y, QWindow *wnd) const
+ {
+     QPoint pnt(wl_fixed_to_int(x), wl_fixed_to_int(y));
+@@ -297,6 +312,33 @@ QPoint QWaylandDataDevice::calculateDragPosition(int x, int y, QWindow *wnd) con
+     }
+     return pnt;
+ }
++
++void QWaylandDataDevice::sendResponse(Qt::DropActions supportedActions, const QPlatformDragQtResponse &response)
++{
++    if (response.isAccepted()) {
++        if (wl_data_device_get_version(object()) >= 3)
++            m_dragOffer->set_actions(dropActionsToWl(supportedActions), dropActionsToWl(response.acceptedAction()));
++
++        m_dragOffer->accept(m_enterSerial, m_dragOffer->firstFormat());
++    } else {
++        m_dragOffer->accept(m_enterSerial, QString());
++    }
++}
++
++int QWaylandDataDevice::dropActionsToWl(Qt::DropActions actions)
++{
++
++    int wlActions = WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE;
++    if (actions & Qt::CopyAction)
++        wlActions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY;
++    if (actions & (Qt::MoveAction | Qt::TargetMoveAction))
++        wlActions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE;
++
++    // wayland does not support LinkAction at the time of writing
++    return wlActions;
++}
++
++
+ #endif // QT_CONFIG(draganddrop)
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddatadevice_p.h b/qtwayland/src/client/qwaylanddatadevice_p.h
+index 16c3ad28..801dcc2c 100644
+--- a/qtwayland/src/client/qwaylanddatadevice_p.h
++++ b/qtwayland/src/client/qwaylanddatadevice_p.h
+@@ -64,6 +64,7 @@ QT_REQUIRE_CONFIG(wayland_datadevice);
+ QT_BEGIN_NAMESPACE
+ 
+ class QMimeData;
++class QPlatformDragQtResponse;
+ class QWindow;
+ 
+ namespace QtWaylandClient {
+@@ -89,7 +90,7 @@ public:
+ 
+ #if QT_CONFIG(draganddrop)
+     QWaylandDataOffer *dragOffer() const;
+-    bool startDrag(QMimeData *mimeData, QWaylandWindow *icon);
++    bool startDrag(QMimeData *mimeData, Qt::DropActions supportedActions, QWaylandWindow *icon);
+     void cancelDrag();
+ #endif
+ 
+@@ -109,13 +110,16 @@ private Q_SLOTS:
+ 
+ #if QT_CONFIG(draganddrop)
+     void dragSourceCancelled();
+-    void dragSourceTargetChanged(const QString &mimeType);
+ #endif
+ 
+ private:
+ #if QT_CONFIG(draganddrop)
+     QPoint calculateDragPosition(int x, int y, QWindow *wnd) const;
+ #endif
++    void sendResponse(Qt::DropActions supportedActions, const QPlatformDragQtResponse &response);
++
++    static int dropActionsToWl(Qt::DropActions dropActions);
++
+ 
+     QWaylandDisplay *m_display = nullptr;
+     QWaylandInputDevice *m_inputDevice = nullptr;
+diff --git a/qtwayland/src/client/qwaylanddatadevicemanager.cpp b/qtwayland/src/client/qwaylanddatadevicemanager.cpp
+index 35d67307..6dc4f77f 100644
+--- a/qtwayland/src/client/qwaylanddatadevicemanager.cpp
++++ b/qtwayland/src/client/qwaylanddatadevicemanager.cpp
+@@ -50,8 +50,8 @@ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
+-QWaylandDataDeviceManager::QWaylandDataDeviceManager(QWaylandDisplay *display, uint32_t id)
+-    : wl_data_device_manager(display->wl_registry(), id, 1)
++QWaylandDataDeviceManager::QWaylandDataDeviceManager(QWaylandDisplay *display, int version, uint32_t id)
++    : wl_data_device_manager(display->wl_registry(), id, qMin(version, 3))
+     , m_display(display)
+ {
+     // Create transfer devices for all input devices.
+diff --git a/qtwayland/src/client/qwaylanddatadevicemanager_p.h b/qtwayland/src/client/qwaylanddatadevicemanager_p.h
+index bd05c0fb..510d9be4 100644
+--- a/qtwayland/src/client/qwaylanddatadevicemanager_p.h
++++ b/qtwayland/src/client/qwaylanddatadevicemanager_p.h
+@@ -68,7 +68,7 @@ class QWaylandInputDevice;
+ class Q_WAYLAND_CLIENT_EXPORT QWaylandDataDeviceManager : public QtWayland::wl_data_device_manager
+ {
+ public:
+-    QWaylandDataDeviceManager(QWaylandDisplay *display, uint32_t id);
++    QWaylandDataDeviceManager(QWaylandDisplay *display, int version, uint32_t id);
+     ~QWaylandDataDeviceManager() override;
+ 
+     QWaylandDataDevice *getDataDevice(QWaylandInputDevice *inputDevice);
+diff --git a/qtwayland/src/client/qwaylanddataoffer.cpp b/qtwayland/src/client/qwaylanddataoffer.cpp
+index 2297e8a1..fe0ea8c9 100644
+--- a/qtwayland/src/client/qwaylanddataoffer.cpp
++++ b/qtwayland/src/client/qwaylanddataoffer.cpp
+@@ -82,6 +82,15 @@ QMimeData *QWaylandDataOffer::mimeData()
+     return m_mimeData.data();
+ }
+ 
++Qt::DropActions QWaylandDataOffer::supportedActions() const
++{
++    if (wl_data_offer_get_version(const_cast<::wl_data_offer*>(object())) < 3) {
++        return Qt::MoveAction | Qt::CopyAction;
++    }
++
++    return m_supportedActions;
++}
++
+ void QWaylandDataOffer::startReceiving(const QString &mimeType, int fd)
+ {
+     receive(mimeType, fd);
+@@ -93,6 +102,22 @@ void QWaylandDataOffer::data_offer_offer(const QString &mime_type)
+     m_mimeData->appendFormat(mime_type);
+ }
+ 
++void QWaylandDataOffer::data_offer_action(uint32_t dnd_action)
++{
++    Q_UNUSED(dnd_action);
++    // This is the compositor telling the drag target what action it should perform
++    // It does not map nicely into Qt final drop semantics, other than pretending there is only one supported action?
++}
++
++void QWaylandDataOffer::data_offer_source_actions(uint32_t source_actions)
++{
++    m_supportedActions = Qt::DropActions();
++    if (source_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
++        m_supportedActions |= Qt::MoveAction;
++    if (source_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
++        m_supportedActions |= Qt::CopyAction;
++}
++
+ QWaylandMimeData::QWaylandMimeData(QWaylandAbstractDataOffer *dataOffer)
+     : m_dataOffer(dataOffer)
+ {
+@@ -163,17 +188,18 @@ QVariant QWaylandMimeData::retrieveData_sys(const QString &mimeType, QVariant::T
+ 
+ int QWaylandMimeData::readData(int fd, QByteArray &data) const
+ {
+-    fd_set readset;
+-    FD_ZERO(&readset);
+-    FD_SET(fd, &readset);
+-    struct timeval timeout;
++    struct pollfd readset;
++    readset.fd = fd;
++    readset.events = POLLIN;
++    struct timespec timeout;
+     timeout.tv_sec = 1;
+-    timeout.tv_usec = 0;
++    timeout.tv_nsec = 0;
++
+ 
+     Q_FOREVER {
+-        int ready = select(FD_SETSIZE, &readset, nullptr, nullptr, &timeout);
++        int ready = qt_safe_poll(&readset, 1, &timeout);
+         if (ready < 0) {
+-            qWarning() << "QWaylandDataOffer: select() failed";
++            qWarning() << "QWaylandDataOffer: qt_safe_poll() failed";
+             return -1;
+         } else if (ready == 0) {
+             qWarning("QWaylandDataOffer: timeout reading from pipe");
+diff --git a/qtwayland/src/client/qwaylanddataoffer_p.h b/qtwayland/src/client/qwaylanddataoffer_p.h
+index 9cf1483c..6f667398 100644
+--- a/qtwayland/src/client/qwaylanddataoffer_p.h
++++ b/qtwayland/src/client/qwaylanddataoffer_p.h
+@@ -82,6 +82,7 @@ public:
+     explicit QWaylandDataOffer(QWaylandDisplay *display, struct ::wl_data_offer *offer);
+     ~QWaylandDataOffer() override;
+     QMimeData *mimeData() override;
++    Qt::DropActions supportedActions() const;
+ 
+     QString firstFormat() const;
+ 
+@@ -89,10 +90,13 @@ public:
+ 
+ protected:
+     void data_offer_offer(const QString &mime_type) override;
++    void data_offer_source_actions(uint32_t source_actions) override;
++    void data_offer_action(uint32_t dnd_action) override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+     QScopedPointer<QWaylandMimeData> m_mimeData;
++    Qt::DropActions m_supportedActions;
+ };
+ 
+ 
+diff --git a/qtwayland/src/client/qwaylanddatasource.cpp b/qtwayland/src/client/qwaylanddatasource.cpp
+index f45122fb..5599cbd4 100644
+--- a/qtwayland/src/client/qwaylanddatasource.cpp
++++ b/qtwayland/src/client/qwaylanddatasource.cpp
+@@ -101,7 +101,32 @@ void QWaylandDataSource::data_source_send(const QString &mime_type, int32_t fd)
+ 
+ void QWaylandDataSource::data_source_target(const QString &mime_type)
+ {
+-    Q_EMIT targetChanged(mime_type);
++    m_accepted = !mime_type.isEmpty();
++    Q_EMIT dndResponseUpdated(m_accepted, m_dropAction);
++}
++
++void QWaylandDataSource::data_source_action(uint32_t action)
++{
++    Qt::DropAction qtAction = Qt::IgnoreAction;
++
++    if (action == WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
++        qtAction = Qt::MoveAction;
++    else if (action == WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
++        qtAction = Qt::CopyAction;
++
++    m_dropAction = qtAction;
++    Q_EMIT dndResponseUpdated(m_accepted, m_dropAction);
++}
++
++void QWaylandDataSource::data_source_dnd_finished()
++{
++    Q_EMIT finished();
++}
++
++void QWaylandDataSource::data_source_dnd_drop_performed()
++{
++
++    Q_EMIT dndDropped(m_accepted, m_dropAction);
+ }
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddatasource_p.h b/qtwayland/src/client/qwaylanddatasource_p.h
+index 25afff79..96f07bc3 100644
+--- a/qtwayland/src/client/qwaylanddatasource_p.h
++++ b/qtwayland/src/client/qwaylanddatasource_p.h
+@@ -77,17 +77,25 @@ public:
+     QMimeData *mimeData() const;
+ 
+ Q_SIGNALS:
+-    void targetChanged(const QString &mime_type);
+     void cancelled();
++    void finished();
++
++    void dndResponseUpdated(bool accepted, Qt::DropAction action);
++    void dndDropped(bool accepted, Qt::DropAction action);
+ 
+ protected:
+     void data_source_cancelled() override;
+     void data_source_send(const QString &mime_type, int32_t fd) override;
+     void data_source_target(const QString &mime_type) override;
++    void data_source_dnd_drop_performed() override;
++    void data_source_dnd_finished() override;
++    void data_source_action(uint32_t action) override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+     QMimeData *m_mime_data = nullptr;
++    bool m_accepted = false;
++    Qt::DropAction m_dropAction = Qt::IgnoreAction;
+ };
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddisplay.cpp b/qtwayland/src/client/qwaylanddisplay.cpp
+index f10c1f79..c01e238b 100644
+--- a/qtwayland/src/client/qwaylanddisplay.cpp
++++ b/qtwayland/src/client/qwaylanddisplay.cpp
+@@ -85,10 +85,203 @@
+ 
+ #include <errno.h>
+ 
++#include <tuple> // for std::tie
++
++static void checkWaylandError(struct wl_display *display)
++{
++    int ecode = wl_display_get_error(display);
++    if ((ecode == EPIPE || ecode == ECONNRESET)) {
++        // special case this to provide a nicer error
++        qWarning("The Wayland connection broke. Did the Wayland compositor die?");
++    } else {
++        qWarning("The Wayland connection experienced a fatal error: %s", strerror(ecode));
++    }
++    _exit(1);
++}
++
+ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
++class EventThread : public QThread
++{
++    Q_OBJECT
++public:
++    enum OperatingMode {
++        EmitToDispatch, // Emit the signal, allow dispatching in a differnt thread.
++        SelfDispatch, // Dispatch the events inside this thread.
++    };
++
++    EventThread(struct wl_display * wl, struct wl_event_queue * ev_queue,
++                OperatingMode mode)
++        : m_fd(wl_display_get_fd(wl))
++        , m_pipefd{ -1, -1 }
++        , m_wldisplay(wl)
++        , m_wlevqueue(ev_queue)
++        , m_mode(mode)
++        , m_reading(true)
++        , m_quitting(false)
++    {
++        setObjectName(QStringLiteral("WaylandEventThread"));
++    }
++
++    void readAndDispatchEvents()
++    {
++        /*
++         * Dispatch pending events and flush the requests at least once. If the event thread
++         * is not reading, try to call _prepare_read() to allow the event thread to poll().
++         * If that fails, re-try dispatch & flush again until _prepare_read() is successful.
++         *
++         * This allow any call to readAndDispatchEvents() to start event thread's polling,
++         * not only the one issued from event thread's waitForReading(), which means functions
++         * called from dispatch_pending() can safely spin an event loop.
++         */
++        for (;;) {
++            if (dispatchQueuePending() < 0) {
++                checkWaylandError(m_wldisplay);
++                return;
++            }
++
++            wl_display_flush(m_wldisplay);
++
++            // We have to check if event thread is reading every time we dispatch
++            // something, as that may recursively call this function.
++            if (m_reading.loadAcquire())
++                break;
++
++            if (prepareReadQueue() == 0) {
++                QMutexLocker l(&m_mutex);
++                m_reading.storeRelease(true);
++                m_cond.wakeOne();
++                break;
++            }
++        }
++    }
++
++    void stop()
++    {
++        // We have to both write to the pipe and set the flag, as the thread may be
++        // either in the poll() or waiting for _prepare_read().
++        if (m_pipefd[1] != -1 && write(m_pipefd[1], "\0", 1) == -1)
++            qWarning("Failed to write to the pipe: %s.", strerror(errno));
++
++        {
++            QMutexLocker l(&m_mutex);
++            m_quitting = true;
++            m_cond.wakeOne();
++        }
++
++        wait();
++    }
++
++Q_SIGNALS:
++    void needReadAndDispatch();
++
++protected:
++    void run() override
++    {
++        // we use this pipe to make the loop exit otherwise if we simply used a flag on the loop condition, if stop() gets
++        // called while poll() is blocking the thread will never quit since there are no wayland messages coming anymore.
++        struct Pipe
++        {
++            Pipe(int *fds)
++                : fds(fds)
++            {
++                if (qt_safe_pipe(fds) != 0)
++                    qWarning("Pipe creation failed. Quitting may hang.");
++            }
++            ~Pipe()
++            {
++                if (fds[0] != -1) {
++                    close(fds[0]);
++                    close(fds[1]);
++                }
++            }
++
++            int *fds;
++        } pipe(m_pipefd);
++
++        // Make the main thread call wl_prepare_read(), dispatch the pending messages and flush the
++        // outbound ones. Wait until it's done before proceeding, unless we're told to quit.
++        while (waitForReading()) {
++            pollfd fds[2] = { { m_fd, POLLIN, 0 }, { m_pipefd[0], POLLIN, 0 } };
++            poll(fds, 2, -1);
++
++            if (fds[1].revents & POLLIN) {
++                // we don't really care to read the byte that was written here since we're closing down
++                wl_display_cancel_read(m_wldisplay);
++                break;
++            }
++
++            if (fds[0].revents & POLLIN)
++                wl_display_read_events(m_wldisplay);
++                // The polll was succesfull and the event thread did the wl_display_read_events(). On the next iteration of the loop
++                // the event sent to the main thread will cause it to dispatch the messages just read, unless the loop exits in which
++                // case we don't care anymore about them.
++            else
++                wl_display_cancel_read(m_wldisplay);
++        }
++    }
++
++private:
++    bool waitForReading()
++    {
++        Q_ASSERT(QThread::currentThread() == this);
++
++        m_reading.storeRelease(false);
++
++        if (m_mode == SelfDispatch) {
++            readAndDispatchEvents();
++        } else {
++            Q_EMIT needReadAndDispatch();
++
++            QMutexLocker lock(&m_mutex);
++            // m_reading might be set from our emit or some other invocation of
++            // readAndDispatchEvents().
++            while (!m_reading.loadRelaxed() && !m_quitting)
++                m_cond.wait(&m_mutex);
++        }
++
++        return !m_quitting;
++    }
++
++    int dispatchQueuePending()
++    {
++        if (m_wlevqueue)
++            return wl_display_dispatch_queue_pending(m_wldisplay, m_wlevqueue);
++        else
++            return wl_display_dispatch_pending(m_wldisplay);
++    }
++
++    int prepareReadQueue()
++    {
++        if (m_wlevqueue)
++            return wl_display_prepare_read_queue(m_wldisplay, m_wlevqueue);
++        else
++            return wl_display_prepare_read(m_wldisplay);
++    }
++
++    int m_fd;
++    int m_pipefd[2];
++    wl_display *m_wldisplay;
++    wl_event_queue *m_wlevqueue;
++    OperatingMode m_mode;
++
++    /* Concurrency note when operating in EmitToDispatch mode:
++     * m_reading is set to false inside event thread's waitForReading(), and is
++     * set to true inside main thread's readAndDispatchEvents().
++     * The lock is not taken when setting m_reading to false, as the main thread
++     * is not actively waiting for it to turn false. However, the lock is taken
++     * inside readAndDispatchEvents() before setting m_reading to true,
++     * as the event thread is actively waiting for it under the wait condition.
++     */
++
++    QAtomicInteger<bool> m_reading;
++    bool m_quitting;
++    QMutex m_mutex;
++    QWaitCondition m_cond;
++};
++
+ Q_LOGGING_CATEGORY(lcQpaWayland, "qt.qpa.wayland"); // for general (uncategorized) Wayland platform logging
+ 
+ struct wl_surface *QWaylandDisplay::createSurface(void *handle)
+@@ -158,17 +351,16 @@ QWaylandDisplay::QWaylandDisplay(QWaylandIntegration *waylandIntegration)
+     if (!mXkbContext)
+         qCWarning(lcQpaWayland, "failed to create xkb context");
+ #endif
+-
+-    forceRoundTrip();
+-
+-    if (!mWaitingScreens.isEmpty()) {
+-        // Give wl_output.done and zxdg_output_v1.done events a chance to arrive
+-        forceRoundTrip();
+-    }
+ }
+ 
+ QWaylandDisplay::~QWaylandDisplay(void)
+ {
++    if (m_eventThread)
++        m_eventThread->stop();
++
++    if (m_frameEventQueueThread)
++        m_frameEventQueueThread->stop();
++
+     if (mSyncCallback)
+         wl_callback_destroy(mSyncCallback);
+ 
+@@ -187,6 +379,21 @@ QWaylandDisplay::~QWaylandDisplay(void)
+ #endif
+     if (mDisplay)
+         wl_display_disconnect(mDisplay);
++
++    if (m_frameEventQueue)
++        wl_event_queue_destroy(m_frameEventQueue);
++}
++
++// Steps which is called just after constructor. This separates registry_global() out of the constructor
++// so that factory functions in integration can be overridden.
++void QWaylandDisplay::initialize()
++{
++    forceRoundTrip();
++
++    if (!mWaitingScreens.isEmpty()) {
++        // Give wl_output.done and zxdg_output_v1.done events a chance to arrive
++        forceRoundTrip();
++    }
+ }
+ 
+ void QWaylandDisplay::ensureScreen()
+@@ -203,98 +410,37 @@ void QWaylandDisplay::ensureScreen()
+ 
+ void QWaylandDisplay::checkError() const
+ {
+-    int ecode = wl_display_get_error(mDisplay);
+-    if ((ecode == EPIPE || ecode == ECONNRESET)) {
+-        // special case this to provide a nicer error
+-        qWarning("The Wayland connection broke. Did the Wayland compositor die?");
+-    } else {
+-        qWarning("The Wayland connection experienced a fatal error: %s", strerror(ecode));
+-    }
+-    _exit(1);
++    checkWaylandError(mDisplay);
+ }
+ 
++// Called in main thread, either from queued signal or directly.
+ void QWaylandDisplay::flushRequests()
+ {
+-    if (wl_display_prepare_read(mDisplay) == 0) {
+-        wl_display_read_events(mDisplay);
+-    }
+-
+-    if (wl_display_dispatch_pending(mDisplay) < 0)
+-        checkError();
+-
+-    {
+-        QReadLocker locker(&m_frameQueueLock);
+-        for (const FrameQueue &q : mExternalQueues) {
+-            QMutexLocker locker(q.mutex);
+-            while (wl_display_prepare_read_queue(mDisplay, q.queue) != 0)
+-                wl_display_dispatch_queue_pending(mDisplay, q.queue);
+-            wl_display_read_events(mDisplay);
+-            wl_display_dispatch_queue_pending(mDisplay, q.queue);
+-        }
+-    }
+-
+-    wl_display_flush(mDisplay);
+-}
+-
+-void QWaylandDisplay::blockingReadEvents()
+-{
+-    if (wl_display_dispatch(mDisplay) < 0)
+-        checkError();
+-}
+-
+-void QWaylandDisplay::destroyFrameQueue(const QWaylandDisplay::FrameQueue &q)
+-{
+-    QWriteLocker locker(&m_frameQueueLock);
+-    auto it = std::find_if(mExternalQueues.begin(),
+-                           mExternalQueues.end(),
+-                           [&q] (const QWaylandDisplay::FrameQueue &other){ return other.queue == q.queue; });
+-    Q_ASSERT(it != mExternalQueues.end());
+-    mExternalQueues.erase(it);
+-    if (q.queue != nullptr)
+-        wl_event_queue_destroy(q.queue);
+-    delete q.mutex;
++    m_eventThread->readAndDispatchEvents();
+ }
+ 
+-QWaylandDisplay::FrameQueue QWaylandDisplay::createFrameQueue()
++// We have to wait until we have an eventDispatcher before creating the eventThread,
++// otherwise forceRoundTrip() may block inside _events_read() because eventThread is
++// polling.
++void QWaylandDisplay::initEventThread()
+ {
+-    QWriteLocker locker(&m_frameQueueLock);
+-    FrameQueue q{createEventQueue()};
+-    mExternalQueues.append(q);
+-    return q;
+-}
++    m_eventThread.reset(
++            new EventThread(mDisplay, /* default queue */ nullptr, EventThread::EmitToDispatch));
++    connect(m_eventThread.get(), &EventThread::needReadAndDispatch, this,
++            &QWaylandDisplay::flushRequests, Qt::QueuedConnection);
++    m_eventThread->start();
+ 
+-wl_event_queue *QWaylandDisplay::createEventQueue()
+-{
+-    return wl_display_create_queue(mDisplay);
++    // wl_display_disconnect() free this.
++    m_frameEventQueue = wl_display_create_queue(mDisplay);
++    m_frameEventQueueThread.reset(
++            new EventThread(mDisplay, m_frameEventQueue, EventThread::SelfDispatch));
++    m_frameEventQueueThread->start();
+ }
+ 
+-void QWaylandDisplay::dispatchQueueWhile(wl_event_queue *queue, std::function<bool ()> condition, int timeout)
++void QWaylandDisplay::blockingReadEvents()
+ {
+-    if (!condition())
+-        return;
+-
+-    QElapsedTimer timer;
+-    timer.start();
+-    struct pollfd pFd = qt_make_pollfd(wl_display_get_fd(mDisplay), POLLIN);
+-    while (timeout == -1 || timer.elapsed() < timeout) {
+-        while (wl_display_prepare_read_queue(mDisplay, queue) != 0)
+-            wl_display_dispatch_queue_pending(mDisplay, queue);
+-
+-        wl_display_flush(mDisplay);
+-
+-        const int remaining = qMax(timeout - timer.elapsed(), 0ll);
+-        const int pollTimeout = timeout == -1 ? -1 : remaining;
+-        if (qt_poll_msecs(&pFd, 1, pollTimeout) > 0)
+-            wl_display_read_events(mDisplay);
+-        else
+-            wl_display_cancel_read(mDisplay);
+-
+-        if (wl_display_dispatch_queue_pending(mDisplay, queue) < 0)
+-            checkError();
+-
+-        if (!condition())
+-            break;
+-    }
++    if (wl_display_dispatch(mDisplay) < 0)
++        checkWaylandError(mDisplay);
+ }
+ 
+ QWaylandScreen *QWaylandDisplay::screenForOutput(struct wl_output *output) const
+@@ -345,7 +491,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+     if (interface == QStringLiteral("wl_output")) {
+         mWaitingScreens << new QWaylandScreen(this, version, id);
+     } else if (interface == QStringLiteral("wl_compositor")) {
+-        mCompositorVersion = qMin((int)version, 3);
++        mCompositorVersion = qMin((int)version, 4);
+         mCompositor.init(registry, id, mCompositorVersion);
+     } else if (interface == QStringLiteral("wl_shm")) {
+         mShm.reset(new QWaylandShm(this, version, id));
+@@ -354,7 +500,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+         mInputDevices.append(inputDevice);
+ #if QT_CONFIG(wayland_datadevice)
+     } else if (interface == QStringLiteral("wl_data_device_manager")) {
+-        mDndSelectionHandler.reset(new QWaylandDataDeviceManager(this, id));
++        mDndSelectionHandler.reset(new QWaylandDataDeviceManager(this, version, id));
+ #endif
+     } else if (interface == QStringLiteral("qt_surface_extension")) {
+         mWindowExtension.reset(new QtWayland::qt_surface_extension(registry, id, 1));
+@@ -369,6 +515,8 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+ #if QT_CONFIG(wayland_client_primary_selection)
+     } else if (interface == QStringLiteral("zwp_primary_selection_device_manager_v1")) {
+         mPrimarySelectionManager.reset(new QWaylandPrimarySelectionDeviceManagerV1(this, id, 1));
++        for (QWaylandInputDevice *inputDevice : qAsConst(mInputDevices))
++            inputDevice->setPrimarySelectionDevice(mPrimarySelectionManager->createDevice(inputDevice));
+ #endif
+     } else if (interface == QStringLiteral("zwp_text_input_manager_v2") && !mClientSideInputContextRequested) {
+         mTextInputManager.reset(new QtWayland::zwp_text_input_manager_v2(registry, id, 1));
+@@ -427,6 +575,13 @@ void QWaylandDisplay::registry_global_remove(uint32_t id)
+                     inputDevice->setTextInput(nullptr);
+                 mWaylandIntegration->reconfigureInputContext();
+             }
++#if QT_CONFIG(wayland_client_primary_selection)
++            if (global.interface == QStringLiteral("zwp_primary_selection_device_manager_v1")) {
++                mPrimarySelectionManager.reset();
++                for (QWaylandInputDevice *inputDevice : qAsConst(mInputDevices))
++                    inputDevice->setPrimarySelectionDevice(nullptr);
++            }
++#endif
+             mGlobals.removeAt(i);
+             break;
+         }
+@@ -452,9 +607,10 @@ void QWaylandDisplay::addRegistryListener(RegistryListener listener, void *data)
+ 
+ void QWaylandDisplay::removeListener(RegistryListener listener, void *data)
+ {
+-    std::remove_if(mRegistryListeners.begin(), mRegistryListeners.end(), [=](Listener l){
++    auto iter = std::remove_if(mRegistryListeners.begin(), mRegistryListeners.end(), [=](Listener l){
+         return (l.listener == listener && l.data == data);
+     });
++    mRegistryListeners.erase(iter, mRegistryListeners.end());
+ }
+ 
+ uint32_t QWaylandDisplay::currentTimeMillisec()
+@@ -467,50 +623,9 @@ uint32_t QWaylandDisplay::currentTimeMillisec()
+     return 0;
+ }
+ 
+-static void
+-sync_callback(void *data, struct wl_callback *callback, uint32_t serial)
+-{
+-    Q_UNUSED(serial)
+-    bool *done = static_cast<bool *>(data);
+-
+-    *done = true;
+-
+-    // If the wl_callback done event is received after the condition check in the while loop in
+-    // forceRoundTrip(), but before the call to processEvents, the call to processEvents may block
+-    // forever if no more events are posted (eventhough the callback is handled in response to the
+-    // aboutToBlock signal). Hence, we wake up the event dispatcher so forceRoundTrip may return.
+-    // (QTBUG-64696)
+-    if (auto *dispatcher = QThread::currentThread()->eventDispatcher())
+-        dispatcher->wakeUp();
+-
+-    wl_callback_destroy(callback);
+-}
+-
+-static const struct wl_callback_listener sync_listener = {
+-    sync_callback
+-};
+-
+ void QWaylandDisplay::forceRoundTrip()
+ {
+-    // wl_display_roundtrip() works on the main queue only,
+-    // but we use a separate one, so basically reimplement it here
+-    int ret = 0;
+-    bool done = false;
+-    wl_callback *callback = wl_display_sync(mDisplay);
+-    wl_callback_add_listener(callback, &sync_listener, &done);
+-    flushRequests();
+-    if (QThread::currentThread()->eventDispatcher()) {
+-        while (!done && ret >= 0) {
+-            QThread::currentThread()->eventDispatcher()->processEvents(QEventLoop::WaitForMoreEvents);
+-            ret = wl_display_dispatch_pending(mDisplay);
+-        }
+-    } else {
+-        while (!done && ret >= 0)
+-            ret = wl_display_dispatch(mDisplay);
+-    }
+-
+-    if (ret == -1 && !done)
+-        wl_callback_destroy(callback);
++     wl_display_roundtrip(mDisplay);
+ }
+ 
+ bool QWaylandDisplay::supportsWindowDecoration() const
+@@ -574,14 +689,10 @@ void QWaylandDisplay::handleKeyboardFocusChanged(QWaylandInputDevice *inputDevic
+     if (mLastKeyboardFocus == keyboardFocus)
+         return;
+ 
+-    if (mWaylandIntegration->mShellIntegration) {
+-        mWaylandIntegration->mShellIntegration->handleKeyboardFocusChanged(keyboardFocus, mLastKeyboardFocus);
+-    } else {
+-        if (keyboardFocus)
+-            handleWindowActivated(keyboardFocus);
+-        if (mLastKeyboardFocus)
+-            handleWindowDeactivated(mLastKeyboardFocus);
+-    }
++    if (keyboardFocus)
++        handleWindowActivated(keyboardFocus);
++    if (mLastKeyboardFocus)
++        handleWindowDeactivated(mLastKeyboardFocus);
+ 
+     mLastKeyboardFocus = keyboardFocus;
+ }
+@@ -600,6 +711,19 @@ void QWaylandDisplay::handleWaylandSync()
+     QWindow *activeWindow = mActiveWindows.empty() ? nullptr : mActiveWindows.last()->window();
+     if (activeWindow != QGuiApplication::focusWindow())
+         QWindowSystemInterface::handleWindowActivated(activeWindow);
++
++    if (!activeWindow) {
++        if (lastInputDevice()) {
++#if QT_CONFIG(clipboard)
++            if (auto *dataDevice = lastInputDevice()->dataDevice())
++                dataDevice->invalidateSelectionOffer();
++#endif
++#if QT_CONFIG(wayland_client_primary_selection)
++            if (auto *device = lastInputDevice()->primarySelectionDevice())
++                device->invalidateSelectionOffer();
++#endif
++        }
++    }
+ }
+ 
+ const wl_callback_listener QWaylandDisplay::syncCallbackListener = {
+@@ -626,6 +750,13 @@ QWaylandInputDevice *QWaylandDisplay::defaultInputDevice() const
+     return mInputDevices.isEmpty() ? 0 : mInputDevices.first();
+ }
+ 
++bool QWaylandDisplay::isKeyboardAvailable() const
++{
++    return std::any_of(
++            mInputDevices.constBegin(), mInputDevices.constEnd(),
++            [this](const QWaylandInputDevice *device) { return device->keyboard() != nullptr; });
++}
++
+ #if QT_CONFIG(cursor)
+ 
+ QWaylandCursor *QWaylandDisplay::waylandCursor()
+@@ -652,4 +783,6 @@ QWaylandCursorTheme *QWaylandDisplay::loadCursorTheme(const QString &name, int p
+ 
+ } // namespace QtWaylandClient
+ 
++#include "qwaylanddisplay.moc"
++
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/client/qwaylanddisplay_p.h b/qtwayland/src/client/qwaylanddisplay_p.h
+index 3b092bc8..42bc661d 100644
+--- a/qtwayland/src/client/qwaylanddisplay_p.h
++++ b/qtwayland/src/client/qwaylanddisplay_p.h
+@@ -109,6 +109,7 @@ class QWaylandSurface;
+ class QWaylandShellIntegration;
+ class QWaylandCursor;
+ class QWaylandCursorTheme;
++class EventThread;
+ 
+ typedef void (*RegistryListener)(void *data,
+                                  struct wl_registry *registry,
+@@ -120,15 +121,11 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandDisplay : public QObject, public QtWayland
+     Q_OBJECT
+ 
+ public:
+-    struct FrameQueue {
+-        FrameQueue(wl_event_queue *q = nullptr) : queue(q), mutex(new QMutex) {}
+-        wl_event_queue *queue;
+-        QMutex *mutex;
+-    };
+-
+     QWaylandDisplay(QWaylandIntegration *waylandIntegration);
+     ~QWaylandDisplay(void) override;
+ 
++    void initialize();
++
+ #if QT_CONFIG(xkbcommon)
+     struct xkb_context *xkbContext() const { return mXkbContext.get(); }
+ #endif
+@@ -210,11 +207,11 @@ public:
+     void handleKeyboardFocusChanged(QWaylandInputDevice *inputDevice);
+     void handleWindowDestroyed(QWaylandWindow *window);
+ 
+-    wl_event_queue *createEventQueue();
+-    FrameQueue createFrameQueue();
+-    void destroyFrameQueue(const FrameQueue &q);
+-    void dispatchQueueWhile(wl_event_queue *queue, std::function<bool()> condition, int timeout = -1);
++    wl_event_queue *frameEventQueue() { return m_frameEventQueue; };
++
++    bool isKeyboardAvailable() const;
+ 
++    void initEventThread();
+ public slots:
+     void blockingReadEvents();
+     void flushRequests();
+@@ -237,6 +234,9 @@ private:
+     };
+ 
+     struct wl_display *mDisplay = nullptr;
++    QScopedPointer<EventThread> m_eventThread;
++    wl_event_queue *m_frameEventQueue = nullptr;
++    QScopedPointer<EventThread> m_frameEventQueueThread;
+     QtWayland::wl_compositor mCompositor;
+     QScopedPointer<QWaylandShm> mShm;
+     QList<QWaylandScreen *> mWaitingScreens;
+@@ -273,11 +273,9 @@ private:
+     QWaylandInputDevice *mLastInputDevice = nullptr;
+     QPointer<QWaylandWindow> mLastInputWindow;
+     QPointer<QWaylandWindow> mLastKeyboardFocus;
+-    QVector<QWaylandWindow *> mActiveWindows;
+-    QVector<FrameQueue> mExternalQueues;
++    QList<QWaylandWindow *> mActiveWindows;
+     struct wl_callback *mSyncCallback = nullptr;
+     static const wl_callback_listener syncCallbackListener;
+-    QReadWriteLock m_frameQueueLock;
+ 
+     bool mClientSideInputContextRequested = !QPlatformInputContextFactory::requested().isNull();
+ 
+diff --git a/qtwayland/src/client/qwaylanddnd.cpp b/qtwayland/src/client/qwaylanddnd.cpp
+index 6535aa16..7c53f5fa 100644
+--- a/qtwayland/src/client/qwaylanddnd.cpp
++++ b/qtwayland/src/client/qwaylanddnd.cpp
+@@ -66,7 +66,7 @@ void QWaylandDrag::startDrag()
+ {
+     QBasicDrag::startDrag();
+     QWaylandWindow *icon = static_cast<QWaylandWindow *>(shapedPixmapWindow()->handle());
+-    if (m_display->currentInputDevice()->dataDevice()->startDrag(drag()->mimeData(), icon)) {
++    if (m_display->currentInputDevice()->dataDevice()->startDrag(drag()->mimeData(), drag()->supportedActions(), icon)) {
+         icon->addAttachOffset(-drag()->hotSpot());
+     } else {
+         // Cancelling immediately does not work, since the event loop for QDrag::exec is started
+@@ -80,6 +80,9 @@ void QWaylandDrag::cancel()
+     QBasicDrag::cancel();
+ 
+     m_display->currentInputDevice()->dataDevice()->cancelDrag();
++
++    if (drag())
++        drag()->deleteLater();
+ }
+ 
+ void QWaylandDrag::move(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods)
+@@ -103,33 +106,41 @@ void QWaylandDrag::endDrag()
+     m_display->currentInputDevice()->handleEndDrag();
+ }
+ 
+-void QWaylandDrag::updateTarget(const QString &mimeType)
++void QWaylandDrag::setResponse(bool accepted)
+ {
+-    setCanDrop(!mimeType.isEmpty());
+-
+-    if (canDrop()) {
+-        updateCursor(defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers()));
+-    } else {
+-        updateCursor(Qt::IgnoreAction);
+-    }
++    // This method is used for old DataDevices where the drag action is not communicated
++    Qt::DropAction action = defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers());
++    setResponse(QPlatformDropQtResponse(accepted, action));
+ }
+ 
+-void QWaylandDrag::setResponse(const QPlatformDragQtResponse &response)
++void QWaylandDrag::setResponse(const QPlatformDropQtResponse &response)
+ {
+     setCanDrop(response.isAccepted());
+ 
+     if (canDrop()) {
+-        updateCursor(defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers()));
++        updateCursor(response.acceptedAction());
+     } else {
+         updateCursor(Qt::IgnoreAction);
+     }
+ }
+ 
+-void QWaylandDrag::finishDrag(const QPlatformDropQtResponse &response)
++void QWaylandDrag::setDropResponse(const QPlatformDropQtResponse &response)
+ {
+     setExecutedDropAction(response.acceptedAction());
++}
++
++void QWaylandDrag::finishDrag()
++{
+     QKeyEvent event(QEvent::KeyPress, Qt::Key_Escape, Qt::NoModifier);
+     eventFilter(shapedPixmapWindow(), &event);
++
++    if (drag())
++        drag()->deleteLater();
++}
++
++bool QWaylandDrag::ownsDragObject() const
++{
++    return true;
+ }
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddnd_p.h b/qtwayland/src/client/qwaylanddnd_p.h
+index 474fe2ab..46f629ac 100644
+--- a/qtwayland/src/client/qwaylanddnd_p.h
++++ b/qtwayland/src/client/qwaylanddnd_p.h
+@@ -71,9 +71,10 @@ public:
+     QWaylandDrag(QWaylandDisplay *display);
+     ~QWaylandDrag() override;
+ 
+-    void updateTarget(const QString &mimeType);
+-    void setResponse(const QPlatformDragQtResponse &response);
+-    void finishDrag(const QPlatformDropQtResponse &response);
++    void setResponse(bool accepted);
++    void setResponse(const QPlatformDropQtResponse &response);
++    void setDropResponse(const QPlatformDropQtResponse &response);
++    void finishDrag();
+ 
+ protected:
+     void startDrag() override;
+@@ -82,6 +83,7 @@ protected:
+     void drop(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods) override;
+     void endDrag() override;
+ 
++    bool ownsDragObject() const override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+diff --git a/qtwayland/src/client/qwaylandinputdevice.cpp b/qtwayland/src/client/qwaylandinputdevice.cpp
+index 613fe862..4b90de84 100644
+--- a/qtwayland/src/client/qwaylandinputdevice.cpp
++++ b/qtwayland/src/client/qwaylandinputdevice.cpp
+@@ -685,6 +685,11 @@ public:
+ 
+ void QWaylandInputDevice::Pointer::pointer_leave(uint32_t time, struct wl_surface *surface)
+ {
++    invalidateFocus();
++    mButtons = Qt::NoButton;
++
++    mParent->mTime = time;
++
+     // The event may arrive after destroying the window, indicated by
+     // a null surface.
+     if (!surface)
+@@ -696,11 +701,6 @@ void QWaylandInputDevice::Pointer::pointer_leave(uint32_t time, struct wl_surfac
+ 
+     if (!QWaylandWindow::mouseGrab())
+         setFrameEvent(new LeaveEvent(window, mSurfacePos, mGlobalPos));
+-
+-    invalidateFocus();
+-    mButtons = Qt::NoButton;
+-
+-    mParent->mTime = time;
+ }
+ 
+ class MotionEvent : public QWaylandPointerEvent
+@@ -1300,14 +1300,6 @@ void QWaylandInputDevice::Keyboard::handleFocusDestroyed()
+ void QWaylandInputDevice::Keyboard::handleFocusLost()
+ {
+     mFocus = nullptr;
+-#if QT_CONFIG(clipboard)
+-    if (auto *dataDevice = mParent->dataDevice())
+-        dataDevice->invalidateSelectionOffer();
+-#endif
+-#if QT_CONFIG(wayland_client_primary_selection)
+-    if (auto *device = mParent->primarySelectionDevice())
+-        device->invalidateSelectionOffer();
+-#endif
+     mParent->mQDisplay->handleKeyboardFocusChanged(mParent);
+     mRepeatTimer.stop();
+ }
+@@ -1396,6 +1388,7 @@ void QWaylandInputDevice::Touch::touch_cancel()
+     if (touchExt)
+         touchExt->touchCanceled();
+ 
++    mFocus = nullptr;
+     QWindowSystemInterface::handleTouchCancelEvent(nullptr, mParent->mTouchDevice);
+ }
+ 
+diff --git a/qtwayland/src/client/qwaylandintegration.cpp b/qtwayland/src/client/qwaylandintegration.cpp
+index c53ccb78..54861600 100644
+--- a/qtwayland/src/client/qwaylandintegration.cpp
++++ b/qtwayland/src/client/qwaylandintegration.cpp
+@@ -125,6 +125,9 @@ QWaylandIntegration::QWaylandIntegration()
+ #endif
+ 
+     reconfigureInputContext();
++
++    QWaylandWindow::fixedToplevelPositions =
++            !qEnvironmentVariableIsSet("QT_WAYLAND_DISABLE_FIXED_POSITIONS");
+ }
+ 
+ QWaylandIntegration::~QWaylandIntegration()
+@@ -192,14 +195,18 @@ QAbstractEventDispatcher *QWaylandIntegration::createEventDispatcher() const
+ 
+ void QWaylandIntegration::initialize()
+ {
++    mDisplay->initEventThread();
++
++    // Call after eventDispatcher is fully connected, for QWaylandDisplay::forceRoundTrip()
++    mDisplay->initialize();
++
++    // But the aboutToBlock() and awake() should be connected after initializePlatform().
++    // Otherwise the connected flushRequests() may consumes up all events before processEvents starts to wait,
++    // so that processEvents(QEventLoop::WaitForMoreEvents) may be blocked in the forceRoundTrip().
+     QAbstractEventDispatcher *dispatcher = QGuiApplicationPrivate::eventDispatcher;
+     QObject::connect(dispatcher, SIGNAL(aboutToBlock()), mDisplay.data(), SLOT(flushRequests()));
+     QObject::connect(dispatcher, SIGNAL(awake()), mDisplay.data(), SLOT(flushRequests()));
+ 
+-    int fd = wl_display_get_fd(mDisplay->wl_display());
+-    QSocketNotifier *sn = new QSocketNotifier(fd, QSocketNotifier::Read, mDisplay.data());
+-    QObject::connect(sn, SIGNAL(activated(QSocketDescriptor)), mDisplay.data(), SLOT(flushRequests()));
+-
+     // Qt does not support running with no screens
+     mDisplay->ensureScreen();
+ }
+@@ -262,6 +269,14 @@ QWaylandDisplay *QWaylandIntegration::display() const
+     return mDisplay.data();
+ }
+ 
++Qt::KeyboardModifiers QWaylandIntegration::queryKeyboardModifiers() const
++{
++    if (auto *seat = mDisplay->currentInputDevice()) {
++        return seat->modifiers();
++    }
++    return Qt::NoModifier;
++}
++
+ QList<int> QWaylandIntegration::possibleKeys(const QKeyEvent *event) const
+ {
+     if (auto *seat = mDisplay->currentInputDevice())
+@@ -479,7 +494,7 @@ void QWaylandIntegration::reconfigureInputContext()
+     }
+ #endif
+ 
+-    qCDebug(lcQpaWayland) << "using input method:" << inputContext()->metaObject()->className();
++    qCDebug(lcQpaWayland) << "using input method:" << (inputContext() ? inputContext()->metaObject()->className() : "<none>");
+ }
+ 
+ QWaylandShellIntegration *QWaylandIntegration::createShellIntegration(const QString &integrationName)
+diff --git a/qtwayland/src/client/qwaylandintegration_p.h b/qtwayland/src/client/qwaylandintegration_p.h
+index ff70ae25..73b80658 100644
+--- a/qtwayland/src/client/qwaylandintegration_p.h
++++ b/qtwayland/src/client/qwaylandintegration_p.h
+@@ -107,6 +107,8 @@ public:
+ 
+     QWaylandDisplay *display() const;
+ 
++    Qt::KeyboardModifiers queryKeyboardModifiers() const override;
++
+     QList<int> possibleKeys(const QKeyEvent *event) const override;
+ 
+     QStringList themeNames() const override;
+diff --git a/qtwayland/src/client/qwaylandprimaryselectionv1.cpp b/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
+index 832f9678..ea508771 100644
+--- a/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
++++ b/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
+@@ -54,11 +54,6 @@ QWaylandPrimarySelectionDeviceManagerV1::QWaylandPrimarySelectionDeviceManagerV1
+     : zwp_primary_selection_device_manager_v1(display->wl_registry(), id, qMin(version, uint(1)))
+     , m_display(display)
+ {
+-    // Create devices for all seats.
+-    // This only works if we get the global before all devices
+-    const auto seats = m_display->inputDevices();
+-    for (auto *seat : seats)
+-        seat->setPrimarySelectionDevice(createDevice(seat));
+ }
+ 
+ QWaylandPrimarySelectionDeviceV1 *QWaylandPrimarySelectionDeviceManagerV1::createDevice(QWaylandInputDevice *seat)
+diff --git a/qtwayland/src/client/qwaylandscreen.cpp b/qtwayland/src/client/qwaylandscreen.cpp
+index 6cb337de..5537dafd 100644
+--- a/qtwayland/src/client/qwaylandscreen.cpp
++++ b/qtwayland/src/client/qwaylandscreen.cpp
+@@ -60,7 +60,7 @@ QWaylandXdgOutputManagerV1::QWaylandXdgOutputManagerV1(QWaylandDisplay* display,
+ }
+ 
+ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uint32_t id)
+-    : QtWayland::wl_output(waylandDisplay->wl_registry(), id, qMin(version, 2))
++    : QtWayland::wl_output(waylandDisplay->wl_registry(), id, qMin(version, 3))
+     , m_outputId(id)
+     , mWaylandDisplay(waylandDisplay)
+     , mOutputName(QStringLiteral("Screen%1").arg(id))
+@@ -72,7 +72,7 @@ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uin
+         qCWarning(lcQpaWayland) << "wl_output done event not supported by compositor,"
+                                 << "QScreen may not work correctly";
+         mWaylandDisplay->forceRoundTrip(); // Give the compositor a chance to send geometry etc.
+-        mOutputDone = true; // Fake the done event
++        mProcessedEvents |= OutputDoneEvent; // Fake the done event
+         maybeInitialize();
+     }
+ }
+@@ -81,16 +81,29 @@ QWaylandScreen::~QWaylandScreen()
+ {
+     if (zxdg_output_v1::isInitialized())
+         zxdg_output_v1::destroy();
++    if (wl_output::isInitialized() && wl_output_get_version(wl_output::object()) >= WL_OUTPUT_RELEASE_SINCE_VERSION)
++        wl_output::release();
++}
++
++uint QWaylandScreen::requiredEvents() const
++{
++    uint ret = OutputDoneEvent;
++
++    if (mWaylandDisplay->xdgOutputManager()) {
++        ret |= XdgOutputNameEvent;
++
++        if (mWaylandDisplay->xdgOutputManager()->version() < 3)
++            ret |= XdgOutputDoneEvent;
++    }
++    return ret;
+ }
+ 
+ void QWaylandScreen::maybeInitialize()
+ {
+     Q_ASSERT(!mInitialized);
+ 
+-    if (!mOutputDone)
+-        return;
+-
+-    if (mWaylandDisplay->xdgOutputManager() && !mXdgOutputDone)
++    const uint requiredEvents = this->requiredEvents();
++    if ((mProcessedEvents & requiredEvents) != requiredEvents)
+         return;
+ 
+     mInitialized = true;
+@@ -276,9 +289,8 @@ void QWaylandScreen::output_scale(int32_t factor)
+ 
+ void QWaylandScreen::output_done()
+ {
+-    mOutputDone = true;
+-    if (zxdg_output_v1::isInitialized() && mWaylandDisplay->xdgOutputManager()->version() >= 3)
+-        mXdgOutputDone = true;
++    mProcessedEvents |= OutputDoneEvent;
++
+     if (mInitialized) {
+         updateOutputProperties();
+         if (zxdg_output_v1::isInitialized())
+@@ -339,7 +351,7 @@ void QWaylandScreen::zxdg_output_v1_done()
+     if (Q_UNLIKELY(mWaylandDisplay->xdgOutputManager()->version() >= 3))
+         qWarning(lcQpaWayland) << "zxdg_output_v1.done received on version 3 or newer, this is most likely a bug in the compositor";
+ 
+-    mXdgOutputDone = true;
++    mProcessedEvents |= XdgOutputDoneEvent;
+     if (mInitialized)
+         updateXdgOutputProperties();
+     else
+@@ -348,7 +360,11 @@ void QWaylandScreen::zxdg_output_v1_done()
+ 
+ void QWaylandScreen::zxdg_output_v1_name(const QString &name)
+ {
++    if (Q_UNLIKELY(mInitialized))
++        qWarning(lcQpaWayland) << "zxdg_output_v1.name received after output has been initialized, this is most likely a bug in the compositor";
++
+     mOutputName = name;
++    mProcessedEvents |= XdgOutputNameEvent;
+ }
+ 
+ void QWaylandScreen::updateXdgOutputProperties()
+diff --git a/qtwayland/src/client/qwaylandscreen_p.h b/qtwayland/src/client/qwaylandscreen_p.h
+index df1c94f2..050cfdc0 100644
+--- a/qtwayland/src/client/qwaylandscreen_p.h
++++ b/qtwayland/src/client/qwaylandscreen_p.h
+@@ -116,6 +116,13 @@ public:
+     static QWaylandScreen *fromWlOutput(::wl_output *output);
+ 
+ private:
++    enum Event : uint {
++        XdgOutputDoneEvent = 0x1,
++        OutputDoneEvent = 0x2,
++        XdgOutputNameEvent = 0x4,
++    };
++    uint requiredEvents() const;
++
+     void output_mode(uint32_t flags, int width, int height, int refresh) override;
+     void output_geometry(int32_t x, int32_t y,
+                          int32_t width, int32_t height,
+@@ -148,8 +155,7 @@ private:
+     QSize mPhysicalSize;
+     QString mOutputName;
+     Qt::ScreenOrientation m_orientation = Qt::PrimaryOrientation;
+-    bool mOutputDone = false;
+-    bool mXdgOutputDone = false;
++    uint mProcessedEvents = 0;
+     bool mInitialized = false;
+ 
+ #if QT_CONFIG(cursor)
+diff --git a/qtwayland/src/client/qwaylandshmbackingstore.cpp b/qtwayland/src/client/qwaylandshmbackingstore.cpp
+index dc7ff670..41cffdf7 100644
+--- a/qtwayland/src/client/qwaylandshmbackingstore.cpp
++++ b/qtwayland/src/client/qwaylandshmbackingstore.cpp
+@@ -52,6 +52,7 @@
+ 
+ #include <QtWaylandClient/private/wayland-wayland-client-protocol.h>
+ 
++#include <fcntl.h>
+ #include <unistd.h>
+ #include <sys/mman.h>
+ 
+@@ -61,6 +62,9 @@
+ #  ifndef MFD_CLOEXEC
+ #    define MFD_CLOEXEC     0x0001U
+ #  endif
++#  ifndef MFD_ALLOW_SEALING
++#    define MFD_ALLOW_SEALING 0x0002U
++#  endif
+ #endif
+ 
+ QT_BEGIN_NAMESPACE
+@@ -74,8 +78,10 @@ QWaylandShmBuffer::QWaylandShmBuffer(QWaylandDisplay *display,
+     int alloc = stride * size.height();
+     int fd = -1;
+ 
+-#ifdef SYS_memfd_create
+-    fd = syscall(SYS_memfd_create, "wayland-shm", MFD_CLOEXEC);
++#if defined(SYS_memfd_create) && defined(F_SEAL_SEAL)
++    fd = syscall(SYS_memfd_create, "wayland-shm", MFD_CLOEXEC | MFD_ALLOW_SEALING);
++    if (fd >= 0)
++        fcntl(fd, F_ADD_SEALS, F_SEAL_SHRINK | F_SEAL_SEAL);
+ #endif
+ 
+     QScopedPointer<QFile> filePointer;
+diff --git a/qtwayland/src/client/qwaylandwindow.cpp b/qtwayland/src/client/qwaylandwindow.cpp
+index cb82857a..fb2c59dc 100644
+--- a/qtwayland/src/client/qwaylandwindow.cpp
++++ b/qtwayland/src/client/qwaylandwindow.cpp
+@@ -76,7 +76,6 @@ QWaylandWindow *QWaylandWindow::mMouseGrab = nullptr;
+ QWaylandWindow::QWaylandWindow(QWindow *window, QWaylandDisplay *display)
+     : QPlatformWindow(window)
+     , mDisplay(display)
+-    , mFrameQueue(mDisplay->createFrameQueue())
+     , mResizeAfterSwap(qEnvironmentVariableIsSet("QT_WAYLAND_RESIZE_AFTER_SWAP"))
+ {
+     {
+@@ -95,9 +94,6 @@ QWaylandWindow::QWaylandWindow(QWindow *window, QWaylandDisplay *display)
+ 
+ QWaylandWindow::~QWaylandWindow()
+ {
+-    mDisplay->destroyFrameQueue(mFrameQueue);
+-    mDisplay->handleWindowDestroyed(this);
+-
+     delete mWindowDecoration;
+ 
+     if (mSurface)
+@@ -243,6 +239,7 @@ bool QWaylandWindow::shouldCreateSubSurface() const
+ 
+ void QWaylandWindow::reset()
+ {
++    closeChildPopups();
+     delete mShellSurface;
+     mShellSurface = nullptr;
+     delete mSubSurfaceWindow;
+@@ -255,17 +252,22 @@ void QWaylandWindow::reset()
+         mSurface.reset();
+     }
+ 
+-    if (mFrameCallback) {
+-        wl_callback_destroy(mFrameCallback);
+-        mFrameCallback = nullptr;
+-    }
++    {
++        QMutexLocker lock(&mFrameSyncMutex);
++        if (mFrameCallback) {
++            wl_callback_destroy(mFrameCallback);
++            mFrameCallback = nullptr;
++        }
+ 
+-    mFrameCallbackElapsedTimer.invalidate();
+-    mWaitingForFrameCallback = false;
++        mFrameCallbackElapsedTimer.invalidate();
++        mWaitingForFrameCallback = false;
++    }
+     mFrameCallbackTimedOut = false;
+ 
+     mMask = QRegion();
+     mQueuedBuffer = nullptr;
++
++    mDisplay->handleWindowDestroyed(this);
+ }
+ 
+ QWaylandWindow *QWaylandWindow::fromWlSurface(::wl_surface *surface)
+@@ -351,19 +353,25 @@ void QWaylandWindow::setGeometry_helper(const QRect &rect)
+     }
+ }
+ 
+-void QWaylandWindow::setGeometry(const QRect &rect)
++void QWaylandWindow::setGeometry(const QRect &r)
+ {
++    auto rect = r;
++    if (fixedToplevelPositions && !QPlatformWindow::parent() && window()->type() != Qt::Popup
++        && window()->type() != Qt::ToolTip) {
++        rect.moveTo(screen()->geometry().topLeft());
++    }
+     setGeometry_helper(rect);
+ 
+     if (window()->isVisible() && rect.isValid()) {
+         if (mWindowDecoration)
+             mWindowDecoration->update();
+ 
+-        if (mResizeAfterSwap && windowType() == Egl && mSentInitialResize)
++        if (mResizeAfterSwap && windowType() == Egl && mSentInitialResize) {
++            QMutexLocker lock(&mResizeLock);
+             mResizeDirty = true;
+-        else
++        } else {
+             QWindowSystemInterface::handleGeometryChange(window(), geometry());
+-
++        }
+         mSentInitialResize = true;
+     }
+     QRect exposeGeometry(QPoint(), geometry().size());
+@@ -374,7 +382,7 @@ void QWaylandWindow::setGeometry(const QRect &rect)
+         mShellSurface->setWindowGeometry(windowContentGeometry());
+ 
+     if (isOpaque() && mMask.isEmpty())
+-        setOpaqueArea(rect);
++        setOpaqueArea(QRect(QPoint(0, 0), rect.size()));
+ }
+ 
+ void QWaylandWindow::resizeFromApplyConfigure(const QSize &sizeWithMargins, const QPoint &offset)
+@@ -399,21 +407,6 @@ void QWaylandWindow::sendExposeEvent(const QRect &rect)
+     mLastExposeGeometry = rect;
+ }
+ 
+-
+-static QVector<QPointer<QWaylandWindow>> activePopups;
+-
+-void QWaylandWindow::closePopups(QWaylandWindow *parent)
+-{
+-    while (!activePopups.isEmpty()) {
+-        auto popup = activePopups.takeLast();
+-        if (popup.isNull())
+-            continue;
+-        if (popup.data() == parent)
+-            return;
+-        popup->reset();
+-    }
+-}
+-
+ QPlatformScreen *QWaylandWindow::calculateScreenFromSurfaceEvents() const
+ {
+     QReadLocker lock(&mSurfaceLock);
+@@ -433,10 +426,7 @@ void QWaylandWindow::setVisible(bool visible)
+     lastVisible = visible;
+ 
+     if (visible) {
+-        if (window()->type() == Qt::Popup || window()->type() == Qt::ToolTip)
+-            activePopups << this;
+         initWindow();
+-        mDisplay->flushRequests();
+ 
+         setGeometry(windowGeometry());
+         // Don't flush the events here, or else the newly visible window may start drawing, but since
+@@ -444,7 +434,6 @@ void QWaylandWindow::setVisible(bool visible)
+         // QWaylandShmBackingStore::beginPaint().
+     } else {
+         sendExposeEvent(QRect());
+-        closePopups(this);
+         reset();
+     }
+ }
+@@ -556,12 +545,12 @@ void QWaylandWindow::sendRecursiveExposeEvent()
+ 
+ void QWaylandWindow::attach(QWaylandBuffer *buffer, int x, int y)
+ {
+-    Q_ASSERT(!buffer->committed());
+     QReadLocker locker(&mSurfaceLock);
+     if (mSurface == nullptr)
+         return;
+ 
+     if (buffer) {
++        Q_ASSERT(!buffer->committed());
+         handleUpdate();
+         buffer->setBusy();
+ 
+@@ -583,7 +572,11 @@ void QWaylandWindow::damage(const QRect &rect)
+     if (mSurface == nullptr)
+         return;
+ 
+-    mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    const int s = scale();
++    if (mDisplay->compositorVersion() >= 4)
++        mSurface->damage_buffer(s * rect.x(), s * rect.y(), s * rect.width(), s * rect.height());
++    else
++        mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
+ }
+ 
+ void QWaylandWindow::safeCommit(QWaylandBuffer *buffer, const QRegion &damage)
+@@ -619,8 +612,14 @@ void QWaylandWindow::commit(QWaylandBuffer *buffer, const QRegion &damage)
+         return;
+ 
+     attachOffset(buffer);
+-    for (const QRect &rect: damage)
+-        mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    if (mDisplay->compositorVersion() >= 4) {
++        const int s = scale();
++        for (const QRect &rect: damage)
++            mSurface->damage_buffer(s * rect.x(), s * rect.y(), s * rect.width(), s * rect.height());
++    } else {
++        for (const QRect &rect: damage)
++            mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    }
+     Q_ASSERT(!buffer->committed());
+     buffer->setCommitted();
+     mSurface->commit();
+@@ -635,42 +634,53 @@ void QWaylandWindow::commit()
+ 
+ const wl_callback_listener QWaylandWindow::callbackListener = {
+     [](void *data, wl_callback *callback, uint32_t time) {
+-        Q_UNUSED(callback);
+         Q_UNUSED(time);
+         auto *window = static_cast<QWaylandWindow*>(data);
+-        window->handleFrameCallback();
++        window->handleFrameCallback(callback);
+     }
+ };
+ 
+-void QWaylandWindow::handleFrameCallback()
++void QWaylandWindow::handleFrameCallback(wl_callback* callback)
+ {
++    QMutexLocker locker(&mFrameSyncMutex);
++    if (!mFrameCallback) {
++        // This means the callback is already unset by QWaylandWindow::reset.
++        // The wl_callback object will be destroyed there too.
++        return;
++    }
++    Q_ASSERT(callback == mFrameCallback);
++    wl_callback_destroy(callback);
++    mFrameCallback = nullptr;
++
+     mWaitingForFrameCallback = false;
+     mFrameCallbackElapsedTimer.invalidate();
+ 
+     // The rest can wait until we can run it on the correct thread
+-    if (!mWaitingForUpdateDelivery) {
+-        auto doHandleExpose = [this]() {
+-            bool wasExposed = isExposed();
+-            mFrameCallbackTimedOut = false;
+-            if (!wasExposed && isExposed()) // Did setting mFrameCallbackTimedOut make the window exposed?
+-                sendExposeEvent(QRect(QPoint(), geometry().size()));
+-            if (wasExposed && hasPendingUpdateRequest())
+-                deliverUpdateRequest();
+-
+-            mWaitingForUpdateDelivery = false;
+-        };
++    auto doHandleExpose = [this]() {
++        mWaitingForUpdateDelivery.storeRelease(false);
++        bool wasExposed = isExposed();
++        mFrameCallbackTimedOut = false;
++        if (!wasExposed && isExposed()) // Did setting mFrameCallbackTimedOut make the window exposed?
++            sendExposeEvent(QRect(QPoint(), geometry().size()));
++        if (wasExposed && hasPendingUpdateRequest())
++            deliverUpdateRequest();
++    };
+ 
++    if (mWaitingForUpdateDelivery.testAndSetAcquire(false, true)) {
+         // Queued connection, to make sure we don't call handleUpdate() from inside waitForFrameSync()
+         // in the single-threaded case.
+-        mWaitingForUpdateDelivery = true;
+         QMetaObject::invokeMethod(this, doHandleExpose, Qt::QueuedConnection);
+     }
++
++    mFrameSyncWait.notify_all();
+ }
+ 
+ bool QWaylandWindow::waitForFrameSync(int timeout)
+ {
+-    QMutexLocker locker(mFrameQueue.mutex);
+-    mDisplay->dispatchQueueWhile(mFrameQueue.queue, [&]() { return mWaitingForFrameCallback; }, timeout);
++    QMutexLocker locker(&mFrameSyncMutex);
++
++    QDeadlineTimer deadline(timeout);
++    while (mWaitingForFrameCallback && mFrameSyncWait.wait(&mFrameSyncMutex, deadline)) { }
+ 
+     if (mWaitingForFrameCallback) {
+         qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
+@@ -868,6 +878,17 @@ bool QWaylandWindow::createDecoration()
+             subsurf->set_position(pos.x() + m.left(), pos.y() + m.top());
+         }
+         sendExposeEvent(QRect(QPoint(), geometry().size()));
++
++        // This is a special case where the buffer is recreated, but since
++        // the content rect remains the same, the widgets remain the same
++        // size and are not redrawn, leaving the new buffer empty. As a simple
++        // work-around, we trigger a full extra update whenever the client-side
++        // window decorations are toggled while the window is showing.
++        // Note: createDecoration() is sometimes called from the render thread
++        // of Qt Quick. This is essentially wrong and could potentially cause problems,
++        // but until the underlying issue has been fixed, we have to use invokeMethod()
++        // here to avoid asserts.
++        QMetaObject::invokeMethod(window(), &QWindow::requestUpdate);
+     }
+ 
+     return mWindowDecoration;
+@@ -1023,6 +1044,13 @@ void QWaylandWindow::handleScreensChanged()
+ 
+     QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->QPlatformScreen::screen());
+     mLastReportedScreen = newScreen;
++    if (fixedToplevelPositions && !QPlatformWindow::parent() && window()->type() != Qt::Popup
++        && window()->type() != Qt::ToolTip
++        && geometry().topLeft() != newScreen->geometry().topLeft()) {
++        auto geometry = this->geometry();
++        geometry.moveTo(newScreen->geometry().topLeft());
++        setGeometry(geometry);
++    }
+ 
+     int scale = newScreen->isPlaceholder() ? 1 : static_cast<QWaylandScreen *>(newScreen)->scale();
+     if (scale != mScale) {
+@@ -1094,10 +1122,18 @@ bool QWaylandWindow::setMouseGrabEnabled(bool grab)
+     return true;
+ }
+ 
++Qt::WindowStates QWaylandWindow::windowStates() const
++{
++    return mLastReportedWindowStates;
++}
++
+ void QWaylandWindow::handleWindowStatesChanged(Qt::WindowStates states)
+ {
+     createDecoration();
+-    QWindowSystemInterface::handleWindowStateChanged(window(), states, mLastReportedWindowStates);
++    Qt::WindowStates statesWithoutActive = states & ~Qt::WindowActive;
++    Qt::WindowStates lastStatesWithoutActive = mLastReportedWindowStates & ~Qt::WindowActive;
++    QWindowSystemInterface::handleWindowStateChanged(window(), statesWithoutActive,
++                                                     lastStatesWithoutActive);
+     mLastReportedWindowStates = states;
+ }
+ 
+@@ -1139,19 +1175,24 @@ void QWaylandWindow::timerEvent(QTimerEvent *event)
+     if (event->timerId() != mFrameCallbackCheckIntervalTimerId)
+         return;
+ 
+-    bool callbackTimerExpired = mFrameCallbackElapsedTimer.hasExpired(mFrameCallbackTimeout);
+-    if (!mFrameCallbackElapsedTimer.isValid() || callbackTimerExpired ) {
+-        killTimer(mFrameCallbackCheckIntervalTimerId);
+-        mFrameCallbackCheckIntervalTimerId = -1;
+-    }
+-    if (mFrameCallbackElapsedTimer.isValid() && callbackTimerExpired) {
+-        mFrameCallbackElapsedTimer.invalidate();
++    {
++        QMutexLocker lock(&mFrameSyncMutex);
+ 
+-        qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
+-        mFrameCallbackTimedOut = true;
+-        mWaitingForUpdate = false;
+-        sendExposeEvent(QRect());
++        bool callbackTimerExpired = mFrameCallbackElapsedTimer.hasExpired(mFrameCallbackTimeout);
++        if (!mFrameCallbackElapsedTimer.isValid() || callbackTimerExpired ) {
++            killTimer(mFrameCallbackCheckIntervalTimerId);
++            mFrameCallbackCheckIntervalTimerId = -1;
++        }
++        if (!mFrameCallbackElapsedTimer.isValid() || !callbackTimerExpired) {
++            return;
++        }
++        mFrameCallbackElapsedTimer.invalidate();
+     }
++
++    qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
++    mFrameCallbackTimedOut = true;
++    mWaitingForUpdate = false;
++    sendExposeEvent(QRect());
+ }
+ 
+ void QWaylandWindow::requestUpdate()
+@@ -1160,8 +1201,11 @@ void QWaylandWindow::requestUpdate()
+     Q_ASSERT(hasPendingUpdateRequest()); // should be set by QPA
+ 
+     // If we have a frame callback all is good and will be taken care of there
+-    if (mWaitingForFrameCallback)
+-        return;
++    {
++        QMutexLocker locker(&mFrameSyncMutex);
++        if (mWaitingForFrameCallback)
++            return;
++    }
+ 
+     // If we've already called deliverUpdateRequest(), but haven't seen any attach+commit/swap yet
+     // This is a somewhat redundant behavior and might indicate a bug in the calling code, so log
+@@ -1174,7 +1218,12 @@ void QWaylandWindow::requestUpdate()
+     // so use invokeMethod to delay the delivery a bit.
+     QMetaObject::invokeMethod(this, [this] {
+         // Things might have changed in the meantime
+-        if (hasPendingUpdateRequest() && !mWaitingForFrameCallback)
++        {
++            QMutexLocker locker(&mFrameSyncMutex);
++            if (mWaitingForFrameCallback)
++                return;
++        }
++        if (hasPendingUpdateRequest())
+             deliverUpdateRequest();
+     }, Qt::QueuedConnection);
+ }
+@@ -1185,19 +1234,18 @@ void QWaylandWindow::requestUpdate()
+ void QWaylandWindow::handleUpdate()
+ {
+     qCDebug(lcWaylandBackingstore) << "handleUpdate" << QThread::currentThread();
++
+     // TODO: Should sync subsurfaces avoid requesting frame callbacks?
+     QReadLocker lock(&mSurfaceLock);
+     if (!mSurface)
+         return;
+ 
+-    if (mFrameCallback) {
+-        wl_callback_destroy(mFrameCallback);
+-        mFrameCallback = nullptr;
+-    }
++    QMutexLocker locker(&mFrameSyncMutex);
++    if (mWaitingForFrameCallback)
++        return;
+ 
+-    QMutexLocker locker(mFrameQueue.mutex);
+     struct ::wl_surface *wrappedSurface = reinterpret_cast<struct ::wl_surface *>(wl_proxy_create_wrapper(mSurface->object()));
+-    wl_proxy_set_queue(reinterpret_cast<wl_proxy *>(wrappedSurface), mFrameQueue.queue);
++    wl_proxy_set_queue(reinterpret_cast<wl_proxy *>(wrappedSurface), mDisplay->frameEventQueue());
+     mFrameCallback = wl_surface_frame(wrappedSurface);
+     wl_proxy_wrapper_destroy(wrappedSurface);
+     wl_callback_add_listener(mFrameCallback, &QWaylandWindow::callbackListener, this);
+@@ -1207,6 +1255,8 @@ void QWaylandWindow::handleUpdate()
+     // Start a timer for handling the case when the compositor stops sending frame callbacks.
+     if (mFrameCallbackTimeout > 0) {
+         QMetaObject::invokeMethod(this, [this] {
++            QMutexLocker locker(&mFrameSyncMutex);
++
+             if (mWaitingForFrameCallback) {
+                 if (mFrameCallbackCheckIntervalTimerId < 0)
+                     mFrameCallbackCheckIntervalTimerId = startTimer(mFrameCallbackTimeout);
+@@ -1267,6 +1317,20 @@ void QWaylandWindow::setOpaqueArea(const QRegion &opaqueArea)
+     wl_region_destroy(region);
+ }
+ 
++void QWaylandWindow::addChildPopup(QWaylandWindow *surface) {
++    mChildPopups.append(surface);
++}
++
++void QWaylandWindow::removeChildPopup(QWaylandWindow *surface) {
++    mChildPopups.removeAll(surface);
++}
++
++void QWaylandWindow::closeChildPopups() {
++    while (!mChildPopups.isEmpty()) {
++        auto popup = mChildPopups.takeLast();
++        popup->reset();
++    }
++}
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/client/qwaylandwindow_p.h b/qtwayland/src/client/qwaylandwindow_p.h
+index 01337cff..2f219d8c 100644
+--- a/qtwayland/src/client/qwaylandwindow_p.h
++++ b/qtwayland/src/client/qwaylandwindow_p.h
+@@ -98,6 +98,9 @@ public:
+     QWaylandWindow(QWindow *window, QWaylandDisplay *display);
+     ~QWaylandWindow() override;
+ 
++    // Keep Toplevels position on the top left corner of their screen
++    static inline bool fixedToplevelPositions = true;
++
+     virtual WindowType windowType() const = 0;
+     virtual void ensureSize();
+     WId winId() const override;
+@@ -148,6 +151,7 @@ public:
+     void setWindowState(Qt::WindowStates states) override;
+     void setWindowFlags(Qt::WindowFlags flags) override;
+     void handleWindowStatesChanged(Qt::WindowStates states);
++    Qt::WindowStates windowStates() const;
+ 
+     void raise() override;
+     void lower() override;
+@@ -206,6 +210,10 @@ public:
+     void handleUpdate();
+     void deliverUpdateRequest() override;
+ 
++    void addChildPopup(QWaylandWindow* child);
++    void removeChildPopup(QWaylandWindow* child);
++    void closeChildPopups();
++
+ public slots:
+     void applyConfigure();
+ 
+@@ -215,7 +223,11 @@ signals:
+ 
+ protected:
+     QWaylandDisplay *mDisplay = nullptr;
++
++    // mSurface can be written by the main thread. Other threads should claim a read lock for access
++    mutable QReadWriteLock mSurfaceLock;
+     QScopedPointer<QWaylandSurface> mSurface;
++
+     QWaylandShellSurface *mShellSurface = nullptr;
+     QWaylandSubSurface *mSubSurfaceWindow = nullptr;
+     QVector<QWaylandSubSurface *> mChildren;
+@@ -225,13 +237,14 @@ protected:
+     Qt::MouseButtons mMousePressedInContentArea = Qt::NoButton;
+ 
+     WId mWindowId;
+-    bool mWaitingForFrameCallback = false;
+     bool mFrameCallbackTimedOut = false; // Whether the frame callback has timed out
+-    bool mWaitingForUpdateDelivery = false;
+     int mFrameCallbackCheckIntervalTimerId = -1;
+-    QElapsedTimer mFrameCallbackElapsedTimer;
+-    struct ::wl_callback *mFrameCallback = nullptr;
+-    QWaylandDisplay::FrameQueue mFrameQueue;
++    QAtomicInt mWaitingForUpdateDelivery = false;
++
++    bool mWaitingForFrameCallback = false; // Protected by mFrameSyncMutex
++    QElapsedTimer mFrameCallbackElapsedTimer; // Protected by mFrameSyncMutex
++    struct ::wl_callback *mFrameCallback = nullptr; // Protected by mFrameSyncMutex
++    QMutex mFrameSyncMutex;
+     QWaitCondition mFrameSyncWait;
+ 
+     // True when we have called deliverRequestUpdate, but the client has not yet attached a new buffer
+@@ -261,6 +274,8 @@ protected:
+     QWaylandBuffer *mQueuedBuffer = nullptr;
+     QRegion mQueuedBufferDamage;
+ 
++    QList<QPointer<QWaylandWindow>> mChildPopups;
++
+ private:
+     void setGeometry_helper(const QRect &rect);
+     void initWindow();
+@@ -283,12 +298,10 @@ private:
+     QRect mLastExposeGeometry;
+ 
+     static const wl_callback_listener callbackListener;
+-    void handleFrameCallback();
++    void handleFrameCallback(struct ::wl_callback* callback);
+ 
+     static QWaylandWindow *mMouseGrab;
+ 
+-    mutable QReadWriteLock mSurfaceLock;
+-
+     friend class QWaylandSubSurface;
+ };
+ 
+diff --git a/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h b/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
+index ccad0048..4cc9b3b8 100644
+--- a/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
++++ b/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
+@@ -73,11 +73,10 @@ public:
+         return true;
+     }
+     virtual QWaylandShellSurface *createShellSurface(QWaylandWindow *window) = 0;
++    // kept for binary compat with layer-shell-qt
+     virtual void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) {
+-        if (newFocus)
+-            m_display->handleWindowActivated(newFocus);
+-        if (oldFocus)
+-            m_display->handleWindowDeactivated(oldFocus);
++        Q_UNUSED(newFocus);
++        Q_UNUSED(oldFocus);
+     }
+     virtual void *nativeResourceForWindow(const QByteArray &resource, QWindow *window) {
+         Q_UNUSED(resource);
+diff --git a/qtwayland/src/compositor/configure.json b/qtwayland/src/compositor/configure.json
+index bcfd5215..da95d07b 100644
+--- a/qtwayland/src/compositor/configure.json
++++ b/qtwayland/src/compositor/configure.json
+@@ -7,6 +7,31 @@
+     "testDir": "../../config.tests",
+ 
+     "libraries": {
++        "wayland-client": {
++            "label": "Wayland client library",
++            "headers": "wayland-version.h",
++            "test": {
++                "main": [
++                    "#if WAYLAND_VERSION_MAJOR < 1",
++                    "# error Wayland 1.8.0 or higher required",
++                    "#endif",
++                    "#if WAYLAND_VERSION_MAJOR == 1",
++                    "# if WAYLAND_VERSION_MINOR < 8",
++                    "#  error Wayland 1.8.0 or higher required",
++                    "# endif",
++                    "# if WAYLAND_VERSION_MINOR == 8",
++                    "#  if WAYLAND_VERSION_MICRO < 0",
++                    "#   error Wayland 1.8.0 or higher required",
++                    "#  endif",
++                    "# endif",
++                    "#endif"
++                 ]
++            },
++            "sources": [
++                { "type": "pkgConfig", "args": "wayland-client" },
++                "-lwayland-client"
++            ]
++        },
+         "wayland-server": {
+             "label": "wayland-server",
+             "headers": "wayland-version.h",
+@@ -151,8 +176,7 @@
+                     "#endif"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "dmabuf-client-buffer": {
+             "label": "Linux Client dma-buf Buffer Sharing",
+@@ -176,8 +200,7 @@
+                     "return 0;"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "vulkan-server-buffer": {
+             "label": "Vulkan Buffer Sharing",
+@@ -195,7 +218,8 @@
+                     "exportAllocInfo.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR;",
+                     "return 0;"
+                 ]
+-            }
++            },
++            "use": "wayland-client"
+         }
+     },
+ 
+diff --git a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
+index 7889f575..64140672 100644
+--- a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
++++ b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
+@@ -40,6 +40,7 @@
+ #include "qwaylandeglwindow.h"
+ 
+ #include <QtWaylandClient/private/qwaylandscreen_p.h>
++#include <QtWaylandClient/private/qwaylandsurface_p.h>
+ #include "qwaylandglcontext.h"
+ 
+ #include <QtEglSupport/private/qeglconvenience_p.h>
+@@ -124,6 +125,7 @@ void QWaylandEglWindow::updateSurface(bool create)
+         }
+         mOffset = QPoint();
+     } else {
++        QReadLocker locker(&mSurfaceLock);
+         if (m_waylandEglWindow) {
+             int current_width, current_height;
+             static bool disableResizeCheck = qgetenv("QT_WAYLAND_DISABLE_RESIZECHECK").toInt();
+@@ -131,14 +133,16 @@ void QWaylandEglWindow::updateSurface(bool create)
+             if (!disableResizeCheck) {
+                 wl_egl_window_get_attached_size(m_waylandEglWindow, &current_width, &current_height);
+             }
+-            if (disableResizeCheck || (current_width != sizeWithMargins.width() || current_height != sizeWithMargins.height())) {
++            if (disableResizeCheck || (current_width != sizeWithMargins.width() || current_height != sizeWithMargins.height()) || m_requestedSize != sizeWithMargins) {
+                 wl_egl_window_resize(m_waylandEglWindow, sizeWithMargins.width(), sizeWithMargins.height(), mOffset.x(), mOffset.y());
++                m_requestedSize = sizeWithMargins;
+                 mOffset = QPoint();
+ 
+                 m_resize = true;
+             }
+-        } else if (create && wlSurface()) {
+-            m_waylandEglWindow = wl_egl_window_create(wlSurface(), sizeWithMargins.width(), sizeWithMargins.height());
++        } else if (create && mSurface) {
++            m_waylandEglWindow = wl_egl_window_create(mSurface->object(), sizeWithMargins.width(), sizeWithMargins.height());
++            m_requestedSize = sizeWithMargins;
+         }
+ 
+         if (!m_eglSurface && m_waylandEglWindow && create) {
+diff --git a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
+index 5b1f4d56..0079dfef 100644
+--- a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
++++ b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
+@@ -88,6 +88,7 @@ private:
+     mutable QOpenGLFramebufferObject *m_contentFBO = nullptr;
+ 
+     QSurfaceFormat m_format;
++    QSize m_requestedSize;
+ };
+ 
+ }
+diff --git a/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h b/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
+index 56a710c3..c6a8b6c6 100644
+--- a/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
++++ b/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
+@@ -41,6 +41,8 @@
+ #include <QtCore/QTextStream>
+ #include <QtGui/QOpenGLTexture>
+ 
++#include <array>
++
+ #include <EGL/egl.h>
+ #include <EGL/eglext.h>
+ 
+diff --git a/qtwayland/src/plugins/decorations/bradient/main.cpp b/qtwayland/src/plugins/decorations/bradient/main.cpp
+index e75fda3c..fa885143 100644
+--- a/qtwayland/src/plugins/decorations/bradient/main.cpp
++++ b/qtwayland/src/plugins/decorations/bradient/main.cpp
+@@ -164,13 +164,10 @@ void QWaylandBradientDecoration::paint(QPaintDevice *device)
+     // Window icon
+     QIcon icon = waylandWindow()->windowIcon();
+     if (!icon.isNull()) {
+-        QPixmap pixmap = icon.pixmap(QSize(128, 128));
+-        QPixmap scaled = pixmap.scaled(22, 22, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+-
+         QRectF iconRect(0, 0, 22, 22);
+-        p.drawPixmap(iconRect.adjusted(margins().left() + BUTTON_SPACING, 4,
+-                                       margins().left() + BUTTON_SPACING, 4),
+-                     scaled, iconRect);
++        iconRect.adjust(margins().left() + BUTTON_SPACING, 4,
++                        margins().left() + BUTTON_SPACING, 4),
++        icon.paint(&p, iconRect.toRect());
+     }
+ 
+     // Window title
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
+index 85d25e3c..60bdd491 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
+@@ -47,18 +47,21 @@ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
+-QWaylandXdgPopupV5::QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow *window)
++QWaylandXdgPopupV5::QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow* parent, QWaylandWindow *window)
+     : QWaylandShellSurface(window)
+     , QtWayland::xdg_popup_v5(popup)
++    , m_parent(parent)
+     , m_window(window)
+ {
+     if (window->display()->windowExtension())
+         m_extendedWindow = new QWaylandExtendedSurface(window);
++    m_parent->addChildPopup(m_window);
+ }
+ 
+ QWaylandXdgPopupV5::~QWaylandXdgPopupV5()
+ {
+     xdg_popup_destroy(object());
++    m_parent->removeChildPopup(m_window);
+     delete m_extendedWindow;
+ }
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
+index 7494f6a6..d85f130b 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
+@@ -70,7 +70,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgPopupV5 : public QWaylandShellSurface
+ {
+     Q_OBJECT
+ public:
+-    QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow *window);
++    QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow* parent, QWaylandWindow *window);
+     ~QWaylandXdgPopupV5() override;
+ 
+ protected:
+@@ -78,6 +78,7 @@ protected:
+ 
+ private:
+     QWaylandExtendedSurface *m_extendedWindow = nullptr;
++    QWaylandWindow *m_parent = nullptr;
+     QWaylandWindow *m_window = nullptr;
+ };
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
+index 7e242c4a..def8452a 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
+@@ -84,7 +84,7 @@ QWaylandXdgPopupV5 *QWaylandXdgShellV5::createXdgPopup(QWaylandWindow *window, Q
+     int x = position.x() + parentWindow->frameMargins().left();
+     int y = position.y() + parentWindow->frameMargins().top();
+ 
+-    auto popup = new QWaylandXdgPopupV5(get_xdg_popup(window->wlSurface(), parentSurface, seat, m_popupSerial, x, y), window);
++    auto popup = new QWaylandXdgPopupV5(get_xdg_popup(window->wlSurface(), parentSurface, seat, m_popupSerial, x, y), parentWindow, window);
+     m_popups.append(window);
+     QObject::connect(popup, &QWaylandXdgPopupV5::destroyed, [this, window](){
+         m_popups.removeOne(window);
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
+index 4e25949f..cfc60939 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
+@@ -85,13 +85,6 @@ QWaylandShellSurface *QWaylandXdgShellV5Integration::createShellSurface(QWayland
+     return m_xdgShell->createXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellV5Integration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) {
+-    if (newFocus && qobject_cast<QWaylandXdgPopupV5 *>(newFocus->shellSurface()))
+-        m_display->handleWindowActivated(newFocus);
+-    if (oldFocus && qobject_cast<QWaylandXdgPopupV5 *>(oldFocus->shellSurface()))
+-        m_display->handleWindowDeactivated(oldFocus);
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
+index ce6bdb9e..aed88670 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
+@@ -67,7 +67,6 @@ public:
+     QWaylandXdgShellV5Integration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShellV5> m_xdgShell;
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
+index 8c371661..151c78e3 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
+@@ -174,6 +174,7 @@ QWaylandXdgSurfaceV6::Popup::Popup(QWaylandXdgSurfaceV6 *xdgSurface, QWaylandXdg
+     , m_xdgSurface(xdgSurface)
+     , m_parent(parent)
+ {
++    m_parent->window()->addChildPopup(m_xdgSurface->window());
+ }
+ 
+ QWaylandXdgSurfaceV6::Popup::~Popup()
+@@ -181,6 +182,8 @@ QWaylandXdgSurfaceV6::Popup::~Popup()
+     if (isInitialized())
+         destroy();
+ 
++    m_parent->window()->removeChildPopup(m_xdgSurface->window());
++
+     if (m_grabbing) {
+         auto *shell = m_xdgSurface->m_shell;
+         Q_ASSERT(shell->m_topmostGrabbingPopup == this);
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
+index 03164316..e8da8ba1 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
+@@ -68,20 +68,6 @@ QWaylandShellSurface *QWaylandXdgShellV6Integration::createShellSurface(QWayland
+     return m_xdgShell->getXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellV6Integration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus)
+-{
+-    if (newFocus) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurfaceV6 *>(newFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowActivated(newFocus);
+-    }
+-    if (oldFocus && qobject_cast<QWaylandXdgSurfaceV6 *>(oldFocus->shellSurface())) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurfaceV6 *>(oldFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowDeactivated(oldFocus);
+-    }
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
+index 261f8cbb..c1bcd5c6 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
+@@ -65,7 +65,6 @@ public:
+     QWaylandXdgShellV6Integration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShellV6> m_xdgShell;
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
+index f3e3c330..fa6d5808 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
+@@ -67,11 +67,6 @@ QWaylandXdgSurface::Toplevel::Toplevel(QWaylandXdgSurface *xdgSurface)
+ 
+ QWaylandXdgSurface::Toplevel::~Toplevel()
+ {
+-    if (m_applied.states & Qt::WindowActive) {
+-        QWaylandWindow *window = m_xdgSurface->window();
+-        window->display()->handleWindowDeactivated(window);
+-    }
+-
+     // The protocol spec requires that the decoration object is deleted before xdg_toplevel.
+     delete m_decoration;
+     m_decoration = nullptr;
+@@ -85,16 +80,15 @@ void QWaylandXdgSurface::Toplevel::applyConfigure()
+     if (!(m_applied.states & (Qt::WindowMaximized|Qt::WindowFullScreen)))
+         m_normalSize = m_xdgSurface->m_window->windowFrameGeometry().size();
+ 
+-    if ((m_pending.states & Qt::WindowActive) && !(m_applied.states & Qt::WindowActive))
++    if ((m_pending.states & Qt::WindowActive) && !(m_applied.states & Qt::WindowActive)
++        && !m_xdgSurface->m_window->display()->isKeyboardAvailable())
+         m_xdgSurface->m_window->display()->handleWindowActivated(m_xdgSurface->m_window);
+ 
+-    if (!(m_pending.states & Qt::WindowActive) && (m_applied.states & Qt::WindowActive))
++    if (!(m_pending.states & Qt::WindowActive) && (m_applied.states & Qt::WindowActive)
++        && !m_xdgSurface->m_window->display()->isKeyboardAvailable())
+         m_xdgSurface->m_window->display()->handleWindowDeactivated(m_xdgSurface->m_window);
+ 
+-    // TODO: none of the other plugins send WindowActive either, but is it on purpose?
+-    Qt::WindowStates statesWithoutActive = m_pending.states & ~Qt::WindowActive;
+-
+-    m_xdgSurface->m_window->handleWindowStatesChanged(statesWithoutActive);
++    m_xdgSurface->m_window->handleWindowStatesChanged(m_pending.states);
+ 
+     if (m_pending.size.isEmpty()) {
+         // An empty size in the configure means it's up to the client to choose the size
+@@ -105,8 +99,6 @@ void QWaylandXdgSurface::Toplevel::applyConfigure()
+         m_xdgSurface->m_window->resizeFromApplyConfigure(m_pending.size);
+     }
+ 
+-    m_xdgSurface->setSizeHints();
+-
+     m_applied = m_pending;
+     qCDebug(lcQpaWayland) << "Applied pending xdg_toplevel configure event:" << m_applied.size << m_applied.states;
+ }
+@@ -203,12 +195,17 @@ QtWayland::xdg_toplevel::resize_edge QWaylandXdgSurface::Toplevel::convertToResi
+                 | ((edges & Qt::RightEdge) ? resize_edge_right : 0));
+ }
+ 
+-QWaylandXdgSurface::Popup::Popup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parent,
++QWaylandXdgSurface::Popup::Popup(QWaylandXdgSurface *xdgSurface, QWaylandWindow *parent,
+                                  QtWayland::xdg_positioner *positioner)
+-    : xdg_popup(xdgSurface->get_popup(parent->object(), positioner->object()))
+-    , m_xdgSurface(xdgSurface)
++    : m_xdgSurface(xdgSurface)
++    , m_parentXdgSurface(qobject_cast<QWaylandXdgSurface *>(parent->shellSurface()))
+     , m_parent(parent)
+ {
++
++    init(xdgSurface->get_popup(m_parentXdgSurface ? m_parentXdgSurface->object() : nullptr, positioner->object()));
++    if (m_parent) {
++        m_parent->addChildPopup(m_xdgSurface->window());
++    }
+ }
+ 
+ QWaylandXdgSurface::Popup::~Popup()
+@@ -216,10 +213,24 @@ QWaylandXdgSurface::Popup::~Popup()
+     if (isInitialized())
+         destroy();
+ 
++    if (m_parent) {
++        m_parent->removeChildPopup(m_xdgSurface->window());
++    }
++
+     if (m_grabbing) {
+         auto *shell = m_xdgSurface->m_shell;
+         Q_ASSERT(shell->m_topmostGrabbingPopup == this);
+-        shell->m_topmostGrabbingPopup = m_parent->m_popup;
++        shell->m_topmostGrabbingPopup = m_parentXdgSurface ? m_parentXdgSurface->m_popup : nullptr;
++        m_grabbing = false;
++
++        // Synthesize Qt enter/leave events for popup
++        QWindow *leave = nullptr;
++        if (m_xdgSurface && m_xdgSurface->window())
++            leave = m_xdgSurface->window()->window();
++        QWindowSystemInterface::handleLeaveEvent(leave);
++
++        if (QWindow *enter = QGuiApplication::topLevelAt(QCursor::pos()))
++            QWindowSystemInterface::handleEnterEvent(enter, enter->mapFromGlobal(QCursor::pos()), QCursor::pos());
+     }
+ }
+ 
+@@ -257,6 +268,7 @@ QWaylandXdgSurface::QWaylandXdgSurface(QWaylandXdgShell *shell, ::xdg_surface *s
+                 m_toplevel->set_parent(parentXdgSurface->m_toplevel->object());
+         }
+     }
++    setSizeHints();
+ }
+ 
+ QWaylandXdgSurface::~QWaylandXdgSurface()
+@@ -400,8 +412,6 @@ void QWaylandXdgSurface::setPopup(QWaylandWindow *parent)
+ {
+     Q_ASSERT(!m_toplevel && !m_popup);
+ 
+-    auto parentXdgSurface = static_cast<QWaylandXdgSurface *>(parent->shellSurface());
+-
+     auto positioner = new QtWayland::xdg_positioner(m_shell->create_positioner());
+     // set_popup expects a position relative to the parent
+     QPoint transientPos = m_window->geometry().topLeft(); // this is absolute
+@@ -414,8 +424,9 @@ void QWaylandXdgSurface::setPopup(QWaylandWindow *parent)
+     positioner->set_anchor(QtWayland::xdg_positioner::anchor_top_left);
+     positioner->set_gravity(QtWayland::xdg_positioner::gravity_bottom_right);
+     positioner->set_size(m_window->geometry().width(), m_window->geometry().height());
+-    m_popup = new Popup(this, parentXdgSurface, positioner);
++    m_popup = new Popup(this, parent, positioner);
+     positioner->destroy();
++
+     delete positioner;
+ }
+ 
+@@ -437,6 +448,23 @@ void QWaylandXdgSurface::setGrabPopup(QWaylandWindow *parent, QWaylandInputDevic
+     }
+     setPopup(parent);
+     m_popup->grab(device, serial);
++
++    // Synthesize Qt enter/leave events for popup
++    if (!parent)
++        return;
++    QWindow *current = QGuiApplication::topLevelAt(QCursor::pos());
++    QWindow *leave = parent->window();
++    if (current != leave)
++        return;
++
++    QWindowSystemInterface::handleLeaveEvent(leave);
++
++    QWindow *enter = nullptr;
++    if (m_popup && m_popup->m_xdgSurface && m_popup->m_xdgSurface->window())
++        enter = m_popup->m_xdgSurface->window()->window();
++
++    if (enter)
++        QWindowSystemInterface::handleEnterEvent(enter, enter->mapFromGlobal(QCursor::pos()), QCursor::pos());
+ }
+ 
+ void QWaylandXdgSurface::xdg_surface_configure(uint32_t serial)
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
+index 96785205..4b518f0a 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
+@@ -131,14 +131,15 @@ private:
+ 
+     class Popup : public QtWayland::xdg_popup {
+     public:
+-        Popup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parent, QtWayland::xdg_positioner *positioner);
++        Popup(QWaylandXdgSurface *xdgSurface, QWaylandWindow *parent, QtWayland::xdg_positioner *positioner);
+         ~Popup() override;
+ 
+         void grab(QWaylandInputDevice *seat, uint serial);
+         void xdg_popup_popup_done() override;
+ 
+         QWaylandXdgSurface *m_xdgSurface = nullptr;
+-        QWaylandXdgSurface *m_parent = nullptr;
++        QWaylandXdgSurface *m_parentXdgSurface = nullptr;
++        QWaylandWindow *m_parent = nullptr;
+         bool m_grabbing = false;
+     };
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
+index 8769d971..da0dd6a7 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
+@@ -69,20 +69,6 @@ QWaylandShellSurface *QWaylandXdgShellIntegration::createShellSurface(QWaylandWi
+     return m_xdgShell->getXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellIntegration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus)
+-{
+-    if (newFocus) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurface *>(newFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowActivated(newFocus);
+-    }
+-    if (oldFocus && qobject_cast<QWaylandXdgSurface *>(oldFocus->shellSurface())) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurface *>(oldFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowDeactivated(oldFocus);
+-    }
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
+index b6caa6c9..2f929f98 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
+@@ -65,7 +65,6 @@ public:
+     QWaylandXdgShellIntegration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShell> m_xdgShell;
+diff --git a/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp b/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
+index 526d0ef4..f50ccf30 100644
+--- a/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
++++ b/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
+@@ -39,7 +39,10 @@
+ 
+ #include "qwaylandinputmethodeventbuilder_p.h"
+ 
++#include <QBrush>
++#include <QGuiApplication>
+ #include <QInputMethod>
++#include <QPalette>
+ #include <QTextCharFormat>
+ 
+ #ifdef QT_BUILD_WAYLANDCOMPOSITOR_LIB
+@@ -81,32 +84,38 @@ void QWaylandInputMethodEventBuilder::addPreeditStyling(uint32_t index, uint32_t
+     QTextCharFormat format;
+ 
+     switch (style) {
+-    case 0:
+-    case 1:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_NONE:
++        break;
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_DEFAULT:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_UNDERLINE:
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-    case 2:
+-    case 3:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_ACTIVE:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_INACTIVE:
+         format.setFontWeight(QFont::Bold);
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-    case 4:
+-        format.setFontUnderline(true);
+-        format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+-        m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_HIGHLIGHT:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_SELECTION:
++        {
++            format.setFontUnderline(true);
++            format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
++            QPalette palette = qApp->palette();
++            format.setBackground(QBrush(palette.color(QPalette::Active, QPalette::Highlight)));
++            format.setForeground(QBrush(palette.color(QPalette::Active, QPalette::HighlightedText)));
++            m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
++        }
+         break;
+-    case 5:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_INCORRECT:
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::WaveUnderline);
+         format.setUnderlineColor(QColor(Qt::red));
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-//    case QtWayland::wl_text_input::preedit_style_selection:
+-//    case QtWayland::wl_text_input::preedit_style_none:
+     default:
+         break;
+     }
+@@ -153,7 +162,7 @@ QInputMethodEvent QWaylandInputMethodEventBuilder::buildPreedit(const QString &t
+ 
+     if (m_preeditCursor < 0) {
+         attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, 0, QVariant()));
+-    } else if (m_preeditCursor > 0) {
++    } else {
+         attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, indexFromWayland(text, m_preeditCursor), 1, QVariant()));
+     }
+ 
+diff --git a/qtwayland/src/shared/qwaylandmimehelper.cpp b/qtwayland/src/shared/qwaylandmimehelper.cpp
+index a5fdd34d..e2fe1928 100644
+--- a/qtwayland/src/shared/qwaylandmimehelper.cpp
++++ b/qtwayland/src/shared/qwaylandmimehelper.cpp
+@@ -60,7 +60,7 @@ QByteArray QWaylandMimeHelper::getByteArray(QMimeData *mimeData, const QString &
+             buf.open(QIODevice::ReadWrite);
+             QByteArray fmt = "BMP";
+             if (mimeType.startsWith(QLatin1String("image/"))) {
+-                QByteArray imgFmt = mimeType.mid(6).toUpper().toLatin1();
++                QByteArray imgFmt = mimeType.mid(6).toLower().toLatin1();
+                 if (QImageWriter::supportedImageFormats().contains(imgFmt))
+                     fmt = imgFmt;
+             }
+@@ -74,7 +74,7 @@ QByteArray QWaylandMimeHelper::getByteArray(QMimeData *mimeData, const QString &
+         QList<QUrl> urls = mimeData->urls();
+         for (int i = 0; i < urls.count(); ++i) {
+             content.append(urls.at(i).toEncoded());
+-            content.append('\n');
++            content.append("\r\n");
+         }
+     } else {
+         content = mimeData->data(mimeType);
+diff --git a/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp b/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
+index 1568b3b9..067410d0 100644
+--- a/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
++++ b/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
+@@ -35,7 +35,7 @@
+ 
+ using namespace MockCompositor;
+ 
+-constexpr int dataDeviceVersion = 1;
++constexpr int dataDeviceVersion = 3;
+ 
+ class DataDeviceCompositor : public DefaultCompositor {
+ public:
+diff --git a/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp b/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
+index 9312c2e5..2ea382f1 100644
+--- a/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
++++ b/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
+@@ -73,6 +73,7 @@ private slots:
+     void multiTouch();
+     void multiTouchUpAndMotionFrame();
+     void tapAndMoveInSameFrame();
++    void cancelTouch();
+ };
+ 
+ void tst_seatv5::bindsToSeat()
+@@ -646,5 +647,34 @@ void tst_seatv5::tapAndMoveInSameFrame()
+     QTRY_COMPARE(window.m_events.last().touchPoints.first().state(), Qt::TouchPointState::TouchPointReleased);
+ }
+ 
++void tst_seatv5::cancelTouch()
++{
++    TouchWindow window;
++    QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
++
++    exec([=] {
++        auto *t = touch();
++        auto *c = client();
++        t->sendDown(xdgToplevel()->surface(), {32, 32}, 1);
++        t->sendFrame(c);
++        t->sendCancel(c);
++        t->sendFrame(c);
++    });
++
++    QTRY_VERIFY(!window.m_events.empty());
++    {
++        auto e = window.m_events.takeFirst();
++        QCOMPARE(e.type, QEvent::TouchBegin);
++        QCOMPARE(e.touchPointStates, Qt::TouchPointPressed);
++        QCOMPARE(e.touchPoints.length(), 1);
++        QCOMPARE(e.touchPoints.first().pos(), QPointF(32-window.frameMargins().left(), 32-window.frameMargins().top()));
++    }
++    {
++        auto e = window.m_events.takeFirst();
++        QCOMPARE(e.type, QEvent::TouchCancel);
++        QCOMPARE(e.touchPoints.length(), 0);
++    }
++}
++
+ QCOMPOSITOR_TEST_MAIN(tst_seatv5)
+ #include "tst_seatv5.moc"
+diff --git a/qtwayland/tests/auto/client/shared/corecompositor.cpp b/qtwayland/tests/auto/client/shared/corecompositor.cpp
+index 5c6c83ba..fa9b7662 100644
+--- a/qtwayland/tests/auto/client/shared/corecompositor.cpp
++++ b/qtwayland/tests/auto/client/shared/corecompositor.cpp
+@@ -27,6 +27,7 @@
+ ****************************************************************************/
+ 
+ #include "corecompositor.h"
++#include <thread>
+ 
+ namespace MockCompositor {
+ 
+diff --git a/qtwayland/tests/auto/client/shared/coreprotocol.cpp b/qtwayland/tests/auto/client/shared/coreprotocol.cpp
+index 0d988521..d1a2e7cb 100644
+--- a/qtwayland/tests/auto/client/shared/coreprotocol.cpp
++++ b/qtwayland/tests/auto/client/shared/coreprotocol.cpp
+@@ -451,6 +451,13 @@ void Touch::sendFrame(wl_client *client)
+         send_frame(r->handle);
+ }
+ 
++void Touch::sendCancel(wl_client *client)
++{
++    const auto touchResources = resourceMap().values(client);
++    for (auto *r : touchResources)
++        send_cancel(r->handle);
++}
++
+ uint Keyboard::sendEnter(Surface *surface)
+ {
+     auto serial = m_seat->m_compositor->nextSerial();
+diff --git a/qtwayland/tests/auto/client/shared/coreprotocol.h b/qtwayland/tests/auto/client/shared/coreprotocol.h
+index a1af137a..210d8ddb 100644
+--- a/qtwayland/tests/auto/client/shared/coreprotocol.h
++++ b/qtwayland/tests/auto/client/shared/coreprotocol.h
+@@ -158,7 +158,7 @@ class WlCompositor : public Global, public QtWaylandServer::wl_compositor
+ {
+     Q_OBJECT
+ public:
+-    explicit WlCompositor(CoreCompositor *compositor, int version = 3)
++    explicit WlCompositor(CoreCompositor *compositor, int version = 4)
+         : QtWaylandServer::wl_compositor(compositor->m_display, version)
+         , m_compositor(compositor)
+     {}
+@@ -364,6 +364,7 @@ public:
+     uint sendUp(wl_client *client, int id);
+     void sendMotion(wl_client *client, const QPointF &position, int id);
+     void sendFrame(wl_client *client);
++    void sendCancel(wl_client *client);
+ 
+     Seat *m_seat = nullptr;
+ };
+diff --git a/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp b/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
+index a415cbf5..b1d3d07d 100644
+--- a/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
++++ b/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
+@@ -342,7 +342,7 @@ Compositor::Compositor(MockCompositor *mockCompositor)
+         exit(EXIT_FAILURE);
+     }
+ 
+-    wl_global_create(m_display, &wl_compositor_interface, 1, this, bindCompositor);
++    wl_global_create(m_display, &wl_compositor_interface, 4, this, bindCompositor);
+ 
+     m_data_device_manager.reset(new DataDeviceManager(this, m_display));
+ 
+diff --git a/qtwayland/tests/auto/client/shared_old/mocksurface.cpp b/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
+index e9df5f90..c3246e4a 100644
+--- a/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
++++ b/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
+@@ -125,6 +125,16 @@ void Surface::surface_damage(Resource *resource,
+     Q_UNUSED(height);
+ }
+ 
++void Surface::surface_damage_buffer(Resource *resource,
++                                    int32_t x, int32_t y, int32_t width, int32_t height)
++{
++    Q_UNUSED(resource);
++    Q_UNUSED(x);
++    Q_UNUSED(y);
++    Q_UNUSED(width);
++    Q_UNUSED(height);
++}
++
+ void Surface::surface_frame(Resource *resource,
+                             uint32_t callback)
+ {
+diff --git a/qtwayland/tests/auto/client/shared_old/mocksurface.h b/qtwayland/tests/auto/client/shared_old/mocksurface.h
+index 949dc23d..d176837e 100644
+--- a/qtwayland/tests/auto/client/shared_old/mocksurface.h
++++ b/qtwayland/tests/auto/client/shared_old/mocksurface.h
+@@ -65,6 +65,8 @@ protected:
+                         struct wl_resource *buffer, int x, int y) override;
+     void surface_damage(Resource *resource,
+                         int32_t x, int32_t y, int32_t width, int32_t height) override;
++    void surface_damage_buffer(Resource *resource,
++                               int32_t x, int32_t y, int32_t width, int32_t height) override;
+     void surface_frame(Resource *resource,
+                        uint32_t callback) override;
+     void surface_commit(Resource *resource) override;
+diff --git a/qtwayland/tests/auto/client/surface/tst_surface.cpp b/qtwayland/tests/auto/client/surface/tst_surface.cpp
+index 95e4e609..60c672ce 100644
+--- a/qtwayland/tests/auto/client/surface/tst_surface.cpp
++++ b/qtwayland/tests/auto/client/surface/tst_surface.cpp
+@@ -129,6 +129,10 @@ void tst_surface::waitForFrameCallbackGl()
+     // Make sure we follow frame callbacks for some frames
+     for (int i = 0; i < 5; ++i) {
+         xdgPingAndWaitForPong(); // Make sure things have happened on the client
++        if (!qEnvironmentVariableIntValue("QT_WAYLAND_DISABLE_WINDOWDECORATION") && i == 0) {
++            QCOMPARE(bufferSpy.count(), 1);
++            bufferSpy.removeFirst();
++        }
+         exec([&] {
+             QVERIFY(bufferSpy.empty()); // Make sure no extra buffers have arrived
+             QVERIFY(!xdgToplevel()->surface()->m_waitingFrameCallbacks.empty());
+diff --git a/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp b/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
+index 2277bbb8..747875b4 100644
+--- a/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
++++ b/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
+@@ -31,6 +31,7 @@
+ #include <QtGui/QOpenGLWindow>
+ #include <QtGui/qpa/qplatformnativeinterface.h>
+ #include <QtWaylandClient/private/wayland-wayland-client-protocol.h>
++#include <QtWaylandClient/private/qwaylandwindow_p.h>
+ 
+ using namespace MockCompositor;
+ 
+@@ -45,6 +46,7 @@ private slots:
+     void configureStates();
+     void popup();
+     void tooltipOnPopup();
++    void tooltipAndSiblingPopup();
+     void switchPopups();
+     void hidePopupParent();
+     void pongs();
+@@ -138,6 +140,7 @@ void tst_xdgshell::configureSize()
+ 
+ void tst_xdgshell::configureStates()
+ {
++    QVERIFY(qputenv("QT_WAYLAND_FRAME_CALLBACK_TIMEOUT", "0"));
+     QRasterWindow window;
+     window.resize(64, 48);
+     window.show();
+@@ -154,9 +157,12 @@ void tst_xdgshell::configureStates()
+     // Toplevel windows don't know their position on xdg-shell
+ //    QCOMPARE(window.frameGeometry().topLeft(), QPoint()); // TODO: this doesn't currently work when window decorations are enabled
+ 
+-//    QEXPECT_FAIL("", "configure has already been acked, we shouldn't have to wait for isActive", Continue);
+-//    QVERIFY(window.isActive());
+-    QTRY_VERIFY(window.isActive()); // Just make sure it eventually get's set correctly
++    // window.windowstate() is driven by keyboard focus, however for decorations we want to follow
++    // XDGShell this is internal to QtWayland so it is queried directly
++    auto waylandWindow = static_cast<QtWaylandClient::QWaylandWindow *>(window.handle());
++    Q_ASSERT(waylandWindow);
++    QTRY_VERIFY(waylandWindow->windowStates().testFlag(
++            Qt::WindowActive)); // Just make sure it eventually get's set correctly
+ 
+     const QSize screenSize(640, 480);
+     const uint maximizedSerial = exec([=] {
+@@ -186,6 +192,7 @@ void tst_xdgshell::configureStates()
+     QCOMPARE(window.windowStates(), Qt::WindowNoState);
+     QCOMPARE(window.frameGeometry().size(), windowedSize);
+ //    QCOMPARE(window.frameGeometry().topLeft(), QPoint()); // TODO: this doesn't currently work when window decorations are enabled
++    QVERIFY(qunsetenv("QT_WAYLAND_FRAME_CALLBACK_TIMEOUT"));
+ }
+ 
+ void tst_xdgshell::popup()
+@@ -340,6 +347,92 @@ void tst_xdgshell::tooltipOnPopup()
+     QCOMPOSITOR_TRY_COMPARE(xdgPopup(0), nullptr);
+ }
+ 
++void tst_xdgshell::tooltipAndSiblingPopup()
++{
++    class ToolTip : public QRasterWindow {
++    public:
++        explicit ToolTip(QWindow *parent) {
++            setTransientParent(parent);
++            setFlags(Qt::ToolTip);
++            resize(100, 100);
++            show();
++        }
++        void mousePressEvent(QMouseEvent *event) override {
++            QRasterWindow::mousePressEvent(event);
++            m_popup = new QRasterWindow;
++            m_popup->setTransientParent(transientParent());
++            m_popup->setFlags(Qt::Popup);
++            m_popup->resize(100, 100);
++            m_popup->show();
++        }
++
++        QRasterWindow *m_popup = nullptr;
++    };
++
++    class Window : public QRasterWindow {
++    public:
++        void mousePressEvent(QMouseEvent *event) override {
++            QRasterWindow::mousePressEvent(event);
++            m_tooltip = new ToolTip(this);
++        }
++        ToolTip *m_tooltip = nullptr;
++    };
++
++    Window window;
++    window.resize(200, 200);
++    window.show();
++
++    QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
++    exec([=] { xdgToplevel()->sendCompleteConfigure(); });
++    QCOMPOSITOR_TRY_VERIFY(xdgToplevel()->m_xdgSurface->m_committedConfigureSerial);
++
++    exec([=] {
++        auto *surface = xdgToplevel()->surface();
++        auto *p = pointer();
++        auto *c = client();
++        p->sendEnter(surface, {100, 100});
++        p->sendFrame(c);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_pressed);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_released);
++        p->sendFrame(c);
++        p->sendLeave(surface);
++        p->sendFrame(c);
++    });
++
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup());
++    exec([=] { xdgPopup()->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup()->m_xdgSurface->m_committedConfigureSerial);
++    QCOMPOSITOR_TRY_VERIFY(!xdgPopup()->m_grabbed);
++
++    exec([=] {
++        auto *surface = xdgPopup()->surface();
++        auto *p = pointer();
++        auto *c = client();
++        p->sendEnter(surface, {100, 100});
++        p->sendFrame(c);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_pressed);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_released);
++        p->sendFrame(c);
++    });
++
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1));
++    exec([=] { xdgPopup(1)->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1)->m_xdgSurface->m_committedConfigureSerial);
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1)->m_grabbed);
++
++    // Close the middle tooltip (it should not close the sibling popup)
++    window.m_tooltip->close();
++
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(1), nullptr);
++    // Verify the remaining xdg surface is a grab popup..
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(0));
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(0)->m_grabbed);
++
++    window.m_tooltip->m_popup->close();
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(1), nullptr);
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(0), nullptr);
++}
++
+ // QTBUG-65680
+ void tst_xdgshell::switchPopups()
+ {
+@@ -505,7 +598,7 @@ void tst_xdgshell::minMaxSize()
+     window.show();
+     QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
+ 
+-    exec([=] { xdgToplevel()->sendCompleteConfigure(); });
++    // we don't roundtrip with our configuration the initial commit should be correct
+ 
+     QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.minSize, QSize(100, 100));
+     QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.maxSize, QSize(1000, 1000));
+Submodule qtwebchannel 618422ee..f8949655:
+diff --git a/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp b/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
+index 536eb5c..898d769 100644
+--- a/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
++++ b/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
+@@ -186,8 +186,6 @@ Q_DECLARE_TYPEINFO(OverloadResolutionCandidate, Q_MOVABLE_TYPE);
+ QMetaObjectPublisher::QMetaObjectPublisher(QWebChannel *webChannel)
+     : QObject(webChannel)
+     , webChannel(webChannel)
+-    , signalHandler(this)
+-    , clientIsIdle(false)
+     , blockUpdates(false)
+     , propertyUpdatesInitialized(false)
+ {
+@@ -301,17 +299,17 @@ QJsonObject QMetaObjectPublisher::classInfoForObject(const QObject *object, QWeb
+     return data;
+ }
+ 
+-void QMetaObjectPublisher::setClientIsIdle(bool isIdle)
++void QMetaObjectPublisher::setClientIsIdle(bool isIdle, QWebChannelAbstractTransport *transport)
+ {
+-    if (clientIsIdle == isIdle) {
+-        return;
+-    }
+-    clientIsIdle = isIdle;
+-    if (!isIdle && timer.isActive()) {
+-        timer.stop();
+-    } else if (isIdle && !timer.isActive()) {
+-        timer.start(PROPERTY_UPDATE_INTERVAL, this);
+-    }
++    transportState[transport].clientIsIdle = isIdle;
++    if (isIdle)
++        sendEnqueuedPropertyUpdates(transport);
++}
++
++bool QMetaObjectPublisher::isClientIdle(QWebChannelAbstractTransport *transport)
++{
++    auto found = transportState.find(transport);
++    return found != transportState.end() && found.value().clientIsIdle;
+ }
+ 
+ QJsonObject QMetaObjectPublisher::initializeClient(QWebChannelAbstractTransport *transport)
+@@ -333,6 +331,7 @@ QJsonObject QMetaObjectPublisher::initializeClient(QWebChannelAbstractTransport
+ 
+ void QMetaObjectPublisher::initializePropertyUpdates(const QObject *const object, const QJsonObject &objectInfo)
+ {
++    auto *signalHandler = signalHandlerFor(object);
+     foreach (const QJsonValue &propertyInfoVar, objectInfo[KEY_PROPERTIES].toArray()) {
+         const QJsonArray &propertyInfo = propertyInfoVar.toArray();
+         if (propertyInfo.size() < 2) {
+@@ -353,19 +352,19 @@ void QMetaObjectPublisher::initializePropertyUpdates(const QObject *const object
+ 
+         // Only connect for a property update once
+         if (connectedProperties.isEmpty()) {
+-            signalHandler.connectTo(object, signalIndex);
++            signalHandler->connectTo(object, signalIndex);
+         }
+ 
+         connectedProperties.insert(propertyIndex);
+     }
+ 
+     // also always connect to destroyed signal
+-    signalHandler.connectTo(object, s_destroyedSignalIndex);
++    signalHandler->connectTo(object, s_destroyedSignalIndex);
+ }
+ 
+ void QMetaObjectPublisher::sendPendingPropertyUpdates()
+ {
+-    if (blockUpdates || !clientIsIdle || pendingPropertyUpdates.isEmpty()) {
++    if (blockUpdates) {
+         return;
+     }
+ 
+@@ -415,18 +414,19 @@ void QMetaObjectPublisher::sendPendingPropertyUpdates()
+ 
+     // data does not contain specific updates
+     if (!data.isEmpty()) {
+-        setClientIsIdle(false);
+-
+         message[KEY_DATA] = data;
+-        broadcastMessage(message);
++        enqueueBroadcastMessage(message);
+     }
+ 
+     // send every property update which is not supposed to be broadcasted
+     const QHash<QWebChannelAbstractTransport*, QJsonArray>::const_iterator suend = specificUpdates.constEnd();
+     for (QHash<QWebChannelAbstractTransport*, QJsonArray>::const_iterator it = specificUpdates.constBegin(); it != suend; ++it) {
+         message[KEY_DATA] = it.value();
+-        it.key()->sendMessage(message);
++        enqueueMessage(message, it.key());
+     }
++
++    for (auto state = transportState.begin(); state != transportState.end(); ++state)
++        sendEnqueuedPropertyUpdates(state.key());
+ }
+ 
+ QVariant QMetaObjectPublisher::invokeMethod(QObject *const object, const QMetaMethod &method,
+@@ -572,7 +572,7 @@ void QMetaObjectPublisher::signalEmitted(const QObject *object, const int signal
+         }
+     } else {
+         pendingPropertyUpdates[object][signalIndex] = arguments;
+-        if (clientIsIdle && !blockUpdates && !timer.isActive()) {
++        if (!blockUpdates && !timer.isActive()) {
+             timer.start(PROPERTY_UPDATE_INTERVAL, this);
+         }
+     }
+@@ -590,7 +590,7 @@ void QMetaObjectPublisher::objectDestroyed(const QObject *object)
+     // only remove from handler when we initialized the property updates
+     // cf: https://bugreports.qt.io/browse/QTBUG-60250
+     if (propertyUpdatesInitialized) {
+-        signalHandler.remove(object);
++        signalHandlerFor(object)->remove(object);
+         signalToPropertyMap.remove(object);
+     }
+     pendingPropertyUpdates.remove(object);
+@@ -852,6 +852,52 @@ void QMetaObjectPublisher::broadcastMessage(const QJsonObject &message) const
+     }
+ }
+ 
++void QMetaObjectPublisher::enqueueBroadcastMessage(const QJsonObject &message)
++{
++    if (webChannel->d_func()->transports.isEmpty()) {
++        qWarning("QWebChannel is not connected to any transports, cannot send message: %s",
++                 QJsonDocument(message).toJson().constData());
++        return;
++    }
++
++    for (auto *transport : webChannel->d_func()->transports) {
++        auto &state = transportState[transport];
++        state.queuedMessages.append(message);
++    }
++}
++
++void QMetaObjectPublisher::enqueueMessage(const QJsonObject &message,
++                                          QWebChannelAbstractTransport *transport)
++{
++    auto &state = transportState[transport];
++    state.queuedMessages.append(message);
++}
++
++void QMetaObjectPublisher::sendEnqueuedPropertyUpdates(QWebChannelAbstractTransport *transport)
++{
++    auto found = transportState.find(transport);
++    if (found != transportState.end() && found.value().clientIsIdle
++        && !found.value().queuedMessages.isEmpty()) {
++
++        // If the client is connected with an in-process transport, it can
++        // happen that a message triggers a subsequent property change. In
++        // that case, we need to ensure that the queued messages have already
++        // been cleared; otherwise the recursive call will send everythig again.
++        // Case in point: The qmlwebchannel tests fail if we don't clear the
++        // queued messages before sending them out.
++        // For that same reason set the client to "busy" (aka non-idle) just
++        // right before sending out the messages; otherwise a potential
++        // "Idle" type message will not correctly restore the Idle state.
++        const auto messages = std::move(found.value().queuedMessages);
++        Q_ASSERT(found.value().queuedMessages.isEmpty());
++        found.value().clientIsIdle = false;
++
++        for (const auto &message : messages) {
++            transport->sendMessage(message);
++        }
++    }
++}
++
+ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannelAbstractTransport *transport)
+ {
+     if (!webChannel->d_func()->transports.contains(transport)) {
+@@ -866,7 +912,7 @@ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannel
+ 
+     const MessageType type = toType(message.value(KEY_TYPE));
+     if (type == TypeIdle) {
+-        setClientIsIdle(true);
++        setClientIsIdle(true, transport);
+     } else if (type == TypeInit) {
+         if (!message.contains(KEY_ID)) {
+             qWarning("JSON message object is missing the id property: %s",
+@@ -913,9 +959,9 @@ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannel
+                 return;
+             transport->sendMessage(createResponse(message.value(KEY_ID), wrapResult(result, transport)));
+         } else if (type == TypeConnectToSignal) {
+-            signalHandler.connectTo(object, message.value(KEY_SIGNAL).toInt(-1));
++            signalHandlerFor(object)->connectTo(object, message.value(KEY_SIGNAL).toInt(-1));
+         } else if (type == TypeDisconnectFromSignal) {
+-            signalHandler.disconnectFrom(object, message.value(KEY_SIGNAL).toInt(-1));
++            signalHandlerFor(object)->disconnectFrom(object, message.value(KEY_SIGNAL).toInt(-1));
+         } else if (type == TypeSetProperty) {
+             setProperty(object, message.value(KEY_PROPERTY).toInt(-1),
+                         message.value(KEY_VALUE));
+@@ -931,6 +977,7 @@ void QMetaObjectPublisher::setBlockUpdates(bool block)
+     blockUpdates = block;
+ 
+     if (!blockUpdates) {
++        timer.start(PROPERTY_UPDATE_INTERVAL, this);
+         sendPendingPropertyUpdates();
+     } else if (timer.isActive()) {
+         timer.stop();
+@@ -948,4 +995,15 @@ void QMetaObjectPublisher::timerEvent(QTimerEvent *event)
+     }
+ }
+ 
++SignalHandler<QMetaObjectPublisher> *QMetaObjectPublisher::signalHandlerFor(const QObject *object)
++{
++    auto thread = object->thread();
++    auto it = signalHandlers.find(thread);
++    if (it == signalHandlers.end()) {
++        it = signalHandlers.emplace(thread, this).first;
++        it->second.moveToThread(thread);
++    }
++    return &it->second;
++}
++
+ QT_END_NAMESPACE
+diff --git a/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h b/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
+index bbd9875..4713ef1 100644
+--- a/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
++++ b/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
+@@ -59,6 +59,9 @@
+ #include <QBasicTimer>
+ #include <QPointer>
+ #include <QJsonObject>
++#include <QQueue>
++
++#include <unordered_map>
+ 
+ #include "qwebchannelglobal.h"
+ 
+@@ -109,17 +112,36 @@ public:
+      */
+     void broadcastMessage(const QJsonObject &message) const;
+ 
++    /**
++     * Enqueue the given @p message to all known transports.
++     */
++    void enqueueBroadcastMessage(const QJsonObject &message);
++
++    /**
++     * Enqueue the given @p message to @p transport.
++     */
++    void enqueueMessage(const QJsonObject &message, QWebChannelAbstractTransport *transport);
++
++    /**
++     * If client for given @p transport is idle, send queued messaged to @p transport and then mark
++     * the client as not idle.
++     */
++    void sendEnqueuedPropertyUpdates(QWebChannelAbstractTransport *transport);
++
+     /**
+      * Serialize the QMetaObject of @p object and return it in JSON form.
+      */
+     QJsonObject classInfoForObject(const QObject *object, QWebChannelAbstractTransport *transport);
+ 
+     /**
+-     * Set the client to idle or busy, based on the value of @p isIdle.
+-     *
+-     * When the value changed, start/stop the property update timer accordingly.
++     * Set the client to idle or busy for a single @p transport, based on the value of @p isIdle.
++     */
++    void setClientIsIdle(bool isIdle, QWebChannelAbstractTransport *transport);
++
++    /**
++     * Check that client is idle for @p transport.
+      */
+-    void setClientIsIdle(bool isIdle);
++    bool isClientIdle(QWebChannelAbstractTransport *transport);
+ 
+     /**
+      * Initialize clients by sending them the class information of the registered objects.
+@@ -272,10 +294,18 @@ private:
+     friend class TestWebChannel;
+ 
+     QWebChannel *webChannel;
+-    SignalHandler<QMetaObjectPublisher> signalHandler;
++    std::unordered_map<const QThread*, SignalHandler<QMetaObjectPublisher>> signalHandlers;
++    SignalHandler<QMetaObjectPublisher> *signalHandlerFor(const QObject *object);
+ 
+-    // true when the client is idle, false otherwise
+-    bool clientIsIdle;
++    struct TransportState
++    {
++        TransportState() : clientIsIdle(false) { }
++        // true when the client is idle, false otherwise
++        bool clientIsIdle;
++        // messages to send
++        QQueue<QJsonObject> queuedMessages;
++    };
++    QHash<QWebChannelAbstractTransport *, TransportState> transportState;
+ 
+     // true when no property updates should be sent, false otherwise
+     bool blockUpdates;
+diff --git a/qtwebchannel/src/webchannel/signalhandler_p.h b/qtwebchannel/src/webchannel/signalhandler_p.h
+index 27afadb..d77373c 100644
+--- a/qtwebchannel/src/webchannel/signalhandler_p.h
++++ b/qtwebchannel/src/webchannel/signalhandler_p.h
+@@ -56,6 +56,7 @@
+ #include <QVector>
+ #include <QMetaMethod>
+ #include <QDebug>
++#include <QThread>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -71,6 +72,7 @@ static const int s_destroyedSignalIndex = QObject::staticMetaObject.indexOfMetho
+ template<class Receiver>
+ class SignalHandler : public QObject
+ {
++    Q_DISABLE_COPY(SignalHandler)
+ public:
+     SignalHandler(Receiver *receiver, QObject *parent = 0);
+ 
+@@ -268,6 +270,7 @@ int SignalHandler<Receiver>::qt_metacall(QMetaObject::Call call, int methodId, v
+     if (call == QMetaObject::InvokeMetaMethod) {
+         const QObject *object = sender();
+         Q_ASSERT(object);
++        Q_ASSERT(QThread::currentThread() == object->thread());
+         Q_ASSERT(senderSignalIndex() == methodId);
+         Q_ASSERT(m_connectionsCounter.contains(object));
+         Q_ASSERT(m_connectionsCounter.value(object).contains(methodId));
+diff --git a/qtwebchannel/tests/auto/qml/testwebchannel.cpp b/qtwebchannel/tests/auto/qml/testwebchannel.cpp
+index 9891687..3ca81c2 100644
+--- a/qtwebchannel/tests/auto/qml/testwebchannel.cpp
++++ b/qtwebchannel/tests/auto/qml/testwebchannel.cpp
+@@ -46,7 +46,11 @@ TestWebChannel::~TestWebChannel()
+ 
+ bool TestWebChannel::clientIsIdle() const
+ {
+-    return QWebChannel::d_func()->publisher->clientIsIdle;
++    for (auto *transport : QWebChannel::d_func()->transports) {
++        if (QWebChannel::d_func()->publisher->isClientIdle(transport))
++            return true;
++    }
++    return false;
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp b/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
+index 181da9e..37f989a 100644
+--- a/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
++++ b/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
+@@ -785,7 +785,7 @@ void TestWebChannel::testTransportWrapObjectProperties()
+     DummyTransport *dummyTransport = new DummyTransport(this);
+     channel.connectTo(dummyTransport);
+     channel.d_func()->publisher->initializeClient(dummyTransport);
+-    channel.d_func()->publisher->setClientIsIdle(true);
++    channel.d_func()->publisher->setClientIsIdle(true, dummyTransport);
+ 
+     QCOMPARE(channel.d_func()->publisher->transportedWrappedObjects.size(), 0);
+ 
+@@ -943,8 +943,6 @@ void TestWebChannel::testInfiniteRecursion()
+ 
+ void TestWebChannel::testAsyncObject()
+ {
+-    QSKIP("This test is broken. See QTBUG-80729");
+-
+     QWebChannel channel;
+     channel.connectTo(m_dummyTransport);
+ 
+@@ -990,6 +988,50 @@ void TestWebChannel::testAsyncObject()
+     thread.wait();
+ }
+ 
++void TestWebChannel::testPropertyMultipleTransports()
++{
++    DummyTransport transport1;
++    DummyTransport transport2;
++
++    QWebChannel channel;
++    QMetaObjectPublisher *publisher = channel.d_func()->publisher;
++
++    TestObject testObj;
++    testObj.setObjectName("testObject");
++    channel.registerObject(testObj.objectName(), &testObj);
++    channel.connectTo(&transport1);
++    channel.connectTo(&transport2);
++
++    testObj.setProp("Hello");
++
++    publisher->initializeClient(&transport1);
++    publisher->initializeClient(&transport2);
++    publisher->setClientIsIdle(true, &transport1);
++    QCOMPARE(publisher->isClientIdle(&transport1), true);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++    QVERIFY(transport1.messagesSent().isEmpty());
++    QVERIFY(transport2.messagesSent().isEmpty());
++
++    testObj.setProp("World");
++    QTRY_COMPARE_WITH_TIMEOUT(transport1.messagesSent().size(), 1u, 2000);
++    QCOMPARE(transport2.messagesSent().size(), 0u);
++    publisher->setClientIsIdle(true, &transport2);
++    QTRY_COMPARE_WITH_TIMEOUT(transport2.messagesSent().size(), 1u, 2000);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++
++    testObj.setProp("!!!");
++    publisher->setClientIsIdle(true, &transport2);
++    QCOMPARE(publisher->isClientIdle(&transport2), true);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QTRY_COMPARE_WITH_TIMEOUT(transport2.messagesSent().size(), 2u, 2000);
++    QCOMPARE(transport1.messagesSent().size(), 1u);
++    publisher->setClientIsIdle(true, &transport1);
++    QTRY_COMPARE_WITH_TIMEOUT(transport1.messagesSent().size(), 2u, 2000);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++}
++
+ class FunctionWrapper : public QObject
+ {
+     Q_OBJECT
+@@ -1082,7 +1124,7 @@ void TestWebChannel::benchInitializeClients()
+ 
+         publisher->propertyUpdatesInitialized = false;
+         publisher->signalToPropertyMap.clear();
+-        publisher->signalHandler.clear();
++        publisher->signalHandlers.clear();
+     }
+ }
+ 
+@@ -1107,7 +1149,7 @@ void TestWebChannel::benchPropertyUpdates()
+             obj->change();
+         }
+ 
+-        channel.d_func()->publisher->clientIsIdle = true;
++        channel.d_func()->publisher->setClientIsIdle(true, m_dummyTransport);
+         channel.d_func()->publisher->sendPendingPropertyUpdates();
+     }
+ }
+diff --git a/qtwebchannel/tests/auto/webchannel/tst_webchannel.h b/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
+index eae21f4..dd4e690 100644
+--- a/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
++++ b/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
+@@ -348,6 +348,7 @@ private slots:
+     void testJsonToVariant();
+     void testInfiniteRecursion();
+     void testAsyncObject();
++    void testPropertyMultipleTransports();
+     void testDeletionDuringMethodInvocation_data();
+     void testDeletionDuringMethodInvocation();
+ 
+Submodule qtwebengine f328054d...38e0df6c (commits not present)
+Submodule qtwebsockets 65850954..63fb8da1:
+diff --git a/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp b/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
+index 2affdd5..95f1194 100644
+--- a/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
++++ b/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
+@@ -273,6 +273,7 @@ void QWebSocketDataProcessor::clear()
+     if (!m_pConverterState)
+         m_pConverterState = new QTextCodec::ConverterState(QTextCodec::ConvertInvalidToNull |
+                                                            QTextCodec::IgnoreHeader);
++    frame.clear();
+ }
+ 
+ /*!
+diff --git a/qtwebsockets/src/websockets/qwebsocketprotocol.cpp b/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
+index df87a93..d0465f1 100644
+--- a/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
++++ b/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
+@@ -210,7 +210,7 @@ void QWebSocketProtocol::mask(char *payload, quint64 size, quint32 maskingKey)
+                             quint8((maskingKey & 0x0000FF00u) >> 8),
+                             quint8((maskingKey & 0x000000FFu))
+                           };
+-    int i = 0;
++    quint64 i = 0;
+     while (size-- > 0)
+         *payload++ ^= mask[i++ % 4];
+ }
diff --git a/srcpkgs/qt5/template b/srcpkgs/qt5/template
index 86ea3ec2c11b9..414b5e532f904 100644
--- a/srcpkgs/qt5/template
+++ b/srcpkgs/qt5/template
@@ -2,11 +2,11 @@
 #
 # revbump libqtxdg after bumping patch version
 pkgname=qt5
-version=5.15.7+20221119
+version=5.15.8
+revision=1
+build_style=meta
 # commit f8c9fb304bc3e53b3aa07f962cd74e9160decccc
 # base repo: https://invent.kde.org/qt/qt/qt5
-revision=6
-build_style=meta
 hostmakedepends="cmake clang flex perl glib-devel pkg-config
  python re2c ruby which"
 makedepends="SDL2-devel Vulkan-Headers alsa-lib-devel double-conversion-devel
@@ -29,8 +29,9 @@ homepage="https://qt.io/"
 # tarball is generated with `git archive-all qt5-$version.tar.gz`
 # to keep the size smaller qtwebengine, qtwebview, qtdocgallery, qtactiveqt and qtpim
 # can be marked with the export-ignore attribute
-distfiles="https://void.johnnynator.dev/distfiles/qt5-${version}.tar.gz"
-checksum=9d57af471c78029a362276b7c99108ea009f511bb9ba6ff6cb884f6ddd255e9f
+#distfiles="https://void.johnnynator.dev/distfiles/qt5-${version}.tar.gz"
+distfiles="https://download.qt.io/archive/qt/5.15/${version}/single/qt-everywhere-opensource-src-${version}.tar.xz"
+checksum=776a9302c336671f9406a53bd30b8e36f825742b2ec44a57c08217bff0fa86b9
 python_version=2 #unverified
 replaces="qt5-doc<5.6.0 qt5-quick1<5.6.0 qt5-quick1-devel<5.6.0 qt5-webkit<5.6.0 qt5-webkit-devel<5.6.0
  qt5-enginio<5.7.1 qt5-enginio-devel<5.7.1 qt5-plugin-gtk<5.7.1 qt5-canvas3d<5.13.0"
@@ -246,7 +247,6 @@ do_configure() {
 	# opts+=" -v"
 	opts+=" -skip qtwebengine"
 	opts+=" -skip qtwebview"
-	opts+=" -skip qtdocgallery"
 	opts+=" -skip qtpim"
 	opts+=" -skip qtsystems"
 	opts+=" -skip qtspeech"

From b7f3a800c96a890729f8d3bd7e034517708e4d9f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 069/115] qtav: revbump for ffmpeg4-4.4.3

---
 srcpkgs/qtav/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtav/template b/srcpkgs/qtav/template
index 34c30b2c0c78f..2d00ad104355e 100644
--- a/srcpkgs/qtav/template
+++ b/srcpkgs/qtav/template
@@ -1,10 +1,10 @@
 # Template file for 'qtav'
 pkgname=qtav
 version=1.13.0
-revision=1
+revision=2
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel libass-devel libopenal-devel
+makedepends="ffmpeg4-devel libass-devel libopenal-devel
  libva-glx-devel libXv-devel pulseaudio-devel
  qt5-declarative-devel qt5-svg-devel
  qt5-quickcontrols"

From 0db52271f68781c1eeb1d8de80a482d257d7f398 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 070/115] qtox: revbump for ffmpeg-6.0

---
 srcpkgs/qtox/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qtox/template b/srcpkgs/qtox/template
index 39c643fecdb5a..bb70e7f51240a 100644
--- a/srcpkgs/qtox/template
+++ b/srcpkgs/qtox/template
@@ -1,7 +1,7 @@
 # Template file for 'qtox'
 pkgname=qtox
 version=1.17.6
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DUPDATE_CHECK=OFF
  -DGIT_DESCRIBE=${version}

From 130f2a0e5a061191e3aa625ab002ac56740dbe5e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 071/115] retroarch: revbump for ffmpeg-6.0

---
 srcpkgs/retroarch/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroarch/template b/srcpkgs/retroarch/template
index 28016aa0129e6..20a1415913be5 100644
--- a/srcpkgs/retroarch/template
+++ b/srcpkgs/retroarch/template
@@ -1,7 +1,7 @@
 # Template file for 'retroarch'
 pkgname=retroarch
 version=1.15.0
-revision=1
+revision=2
 build_style=configure
 configure_args="--prefix=/usr --sysconfdir=/etc --enable-networking
  --enable-udev --disable-builtinflac --disable-builtinglslang

From 99fb8a2e20d85f0a9666e74fcd4a649b64ca9eba Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 072/115] scrcpy: revbump for ffmpeg-6.0

---
 srcpkgs/scrcpy/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/scrcpy/template b/srcpkgs/scrcpy/template
index ac18bc03418ce..f39a7f678ab35 100644
--- a/srcpkgs/scrcpy/template
+++ b/srcpkgs/scrcpy/template
@@ -1,7 +1,7 @@
 # Template file for 'scrcpy'
 pkgname=scrcpy
 version=2.1.1
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcompile_server=false
  -Dprebuilt_server=/usr/share/scrcpy/scrcpy-server-v${version}"

From 45c196961924b3d113f116a66c18a0192177726e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 073/115] spek-alternative: revbump for ffmpeg4-4.4.3

---
 srcpkgs/spek-alternative/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/spek-alternative/template b/srcpkgs/spek-alternative/template
index d65086b8f008c..05246f1b8d0c8 100644
--- a/srcpkgs/spek-alternative/template
+++ b/srcpkgs/spek-alternative/template
@@ -1,11 +1,11 @@
 # Template file for 'spek-alternative'
 pkgname=spek-alternative
 version=0.8.2.3
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake gettext-devel intltool libtool pkg-config wxWidgets-common"
-makedepends="ffmpeg-devel wxWidgets-gtk3-devel"
-depends="ffmpeg"
+makedepends="ffmpeg4-devel wxWidgets-gtk3-devel"
+depends="ffmpeg4"
 short_desc="Acoustic spectrum analyser"
 maintainer="Kartik Singh <kartik.ynwa@gmail.com>"
 license="GPL-3.0-or-later"

From 7c83697dceb18c472e389c0fd23c91517109fee8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 074/115] ssr: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ssr/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/ssr/template b/srcpkgs/ssr/template
index b055b9ec0774a..3448ca110eb0c 100644
--- a/srcpkgs/ssr/template
+++ b/srcpkgs/ssr/template
@@ -1,11 +1,11 @@
 # Template file for 'ssr'
 pkgname=ssr
 version=0.4.4
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_QT5=ON"
 hostmakedepends="pkg-config"
-makedepends="alsa-lib-devel ffmpeg-devel glu-devel jack-devel pulseaudio-devel
+makedepends="alsa-lib-devel ffmpeg4-devel glu-devel jack-devel pulseaudio-devel
  qt5-tools-devel qt5-x11extras-devel libXinerama-devel v4l-utils-devel"
 depends="desktop-file-utils hicolor-icon-theme"
 short_desc="Simple Screen Recorder for programs and games"

From 6823a4a054cf8318228ff6a5243ac9f4623ac0df Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 075/115] sumo: revbump for ffmpeg-6.0

---
 srcpkgs/sumo/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/sumo/template b/srcpkgs/sumo/template
index 0f9b9ec815f56..a3fe134aa5acc 100644
--- a/srcpkgs/sumo/template
+++ b/srcpkgs/sumo/template
@@ -1,7 +1,7 @@
 # Template file for 'sumo'
 pkgname=sumo
 version=1.12.0
-revision=5
+revision=6
 build_style=cmake
 hostmakedepends="libgdal-tools pkg-config swig python3-setuptools"
 makedepends="python3-devel ffmpeg-devel fox-devel gl2ps-devel libgdal-devel

From e2d447ae11b3d424a6e81ed6af802cc887cfc535 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 076/115] synfig: revbump for ffmpeg-6.0 and mlt7

---
 srcpkgs/synfig/patches/ffmpeg6.patch | 71 ++++++++++++++++++++++++++++
 srcpkgs/synfig/template              |  6 +--
 2 files changed, 74 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/synfig/patches/ffmpeg6.patch

diff --git a/srcpkgs/synfig/patches/ffmpeg6.patch b/srcpkgs/synfig/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..10780b42782f4
--- /dev/null
+++ b/srcpkgs/synfig/patches/ffmpeg6.patch
@@ -0,0 +1,71 @@
+--- a/src/modules/mod_libavcodec/trgt_av.cpp	2022-10-25 09:14:12.000000000 -0400
++++ b/src/modules/mod_libavcodec/trgt_av.cpp	2023-05-05 21:34:17.899194559 -0400
+@@ -38,6 +41,7 @@
+ extern "C"
+ {
+ #ifdef HAVE_LIBAVFORMAT_AVFORMAT_H
++#	include <libavcodec/avcodec.h>
+ #	include <libavformat/avformat.h>
+ #elif defined(HAVE_AVFORMAT_H)
+ #	include <avformat.h>
+@@ -155,11 +156,11 @@
+     }
+ 
+ 	bool open_video_stream() {
+-		if (avcodec_open2(video_context, NULL, NULL) < 0) {
++		if (avcodec_open2(video_context, nullptr, nullptr) < 0) {
+ 			synfig::error("Target_LibAVCodec: could not open video codec");
+ 			// seems the calling of avcodec_free_context after error will cause crash
+ 			// so just forget about this context
+-			video_context = NULL;
++			video_context = nullptr;
+ 			close();
+ 			return false;
+         }
+@@ -234,15 +235,21 @@
+ 		close();
+ 
+ 		if (!av_registered) {
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 			av_register_all();
++#endif
+ 			av_registered = true;
+ 		}
+ 
+ 		// guess format
+-		AVOutputFormat *format = av_guess_format(NULL, filename.c_str(), NULL);
++#if LIBAVCODEC_VERSION_MAJOR < 59 // FFMPEG < 5.0
++		AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#else
++		const AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#endif
+ 		if (!format) {
+ 			synfig::warning("Target_LibAVCodec: unable to guess the output format, defaulting to MPEG");
+-			format = av_guess_format("mpeg", NULL, NULL);
++			format = av_guess_format("mpeg", nullptr, nullptr);
+ 		}
+ 		if (!format) {
+ 			synfig::error("Target_LibAVCodec: unable to find 'mpeg' output format");
+@@ -254,6 +261,7 @@
+ 		context = avformat_alloc_context();
+ 		assert(context);
+ 		context->oformat = format;
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 		if (filename.size() + 1 > sizeof(context->filename)) {
+ 			synfig::error(
+ 				"Target_LibAVCodec: filename too long, max length is %d, filename is '%s'",
+@@ -263,6 +271,14 @@
+ 			return false;
+ 		}
+ 		memcpy(context->filename, filename.c_str(), filename.size() + 1);
++#else
++		context->url = av_strndup(filename.c_str(), filename.size());
++		if (!context->url) {
++			synfig::error("Target_LibAVCodec: cannot allocate space for filename");
++			close();
++			return false;
++		}
++#endif
+ 
+ 		packet = av_packet_alloc();
+ 		assert(packet);
diff --git a/srcpkgs/synfig/template b/srcpkgs/synfig/template
index 30109541ec4fc..703cfd7ebac84 100644
--- a/srcpkgs/synfig/template
+++ b/srcpkgs/synfig/template
@@ -2,11 +2,11 @@
 # Should be kept in sync with 'synfigstudio' and 'ETL'
 pkgname=synfig
 version=1.4.4
-revision=3
+revision=4
 build_style=gnu-configure
 configure_args="--with-boost-libdir=${XBPS_CROSS_BASE}/usr/lib"
 hostmakedepends="boost-build ImageMagick pkg-config intltool"
-makedepends="ETL gettext-devel libxml++-devel mlt-devel libmagick-devel
+makedepends="ETL gettext-devel libxml++-devel mlt7-devel libmagick-devel
  libmng-devel boost-build boost-devel libopenexr-devel ffmpeg-devel"
 depends="ImageMagick"
 short_desc="CLI 2D vector and timeline-based animation software"
@@ -20,7 +20,7 @@ CXXFLAGS="-std=c++11 -DHAVE_LOCALE_H=1"
 
 synfig-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision}
-	 libopenexr-devel libxml++-devel mlt-devel"
+	 libopenexr-devel libxml++-devel mlt7-devel"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/bin/synfig-config

From 0666f89edd5dfbe2f0909c32e8b6e496c3054277 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 077/115] tg_owt: revbump for ffmpeg-6.0

---
 srcpkgs/tg_owt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tg_owt/template b/srcpkgs/tg_owt/template
index 9ebb6f57a83f4..3e52d1fb553f7 100644
--- a/srcpkgs/tg_owt/template
+++ b/srcpkgs/tg_owt/template
@@ -1,7 +1,7 @@
 # Template file for 'tg_owt'
 pkgname=tg_owt
 version=0.0.0.20230610
-revision=1
+revision=2
 _commit=dcb5069ff76bd293e86928804208737e6cee2ccc
 _libyuv_commit=77c2121f7e6b8e694d6e908bbbe9be24214097da
 _abseil_commit=8c0b94e793a66495e0b1f34a5eb26bd7dc672db0

From 3345e43108dd884c8d1a9038962faed2ee9b4c55 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 078/115] timg: revbump for ffmpeg-6.0

---
 srcpkgs/timg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/timg/template b/srcpkgs/timg/template
index 2a2ab763d2fdd..8fb4327535ef9 100644
--- a/srcpkgs/timg/template
+++ b/srcpkgs/timg/template
@@ -1,7 +1,7 @@
 # Template file for 'timg'
 pkgname=timg
 version=1.4.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_OPENSLIDE_SUPPORT=off -Wno-dev"
 hostmakedepends="pkg-config git"

From a542239c002b320a96a5381241643574955fcc16 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 079/115] tvheadend: revbump for ffmpeg4-4.4.3

---
 srcpkgs/tvheadend/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/tvheadend/template b/srcpkgs/tvheadend/template
index e6b16d7ccf3bd..46b52b6fb7f94 100644
--- a/srcpkgs/tvheadend/template
+++ b/srcpkgs/tvheadend/template
@@ -1,14 +1,14 @@
 # Template file for 'tvheadend'
 pkgname=tvheadend
 version=4.2.8
-revision=6
+revision=7
 build_style=gnu-configure
 configure_args="--enable-dvbscan --disable-ffmpeg_static
 --disable-hdhomerun_static --disable-bintray_cache --disable-libx264_static
 --disable-libx265_static --disable-libvpx_static --disable-libtheora_static
 --disable-libvorbis_static --disable-libfdkaac_static"
 hostmakedepends="gettext pkg-config python git which"
-makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg-devel"
+makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg4-devel"
 short_desc="TV streaming server"
 maintainer="lemmi <lemmi@nerd2nerd.org>"
 license="GPL-3.0-only"

From e6b97ee9de6f6f0ecfd29838c5d7b04a01442c5e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 080/115] unpaper: update to 7.0.0.

---
 srcpkgs/unpaper/template | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/srcpkgs/unpaper/template b/srcpkgs/unpaper/template
index 38ed47a584016..1ff910e722afc 100644
--- a/srcpkgs/unpaper/template
+++ b/srcpkgs/unpaper/template
@@ -1,13 +1,13 @@
 # Template file for 'unpaper'
 pkgname=unpaper
-version=6.1
-revision=3
-build_style=gnu-configure
+version=7.0.0
+revision=1
+build_style=meson
+hostmakedepends="pkg-config meson libxslt"
+makedepends="ffmpeg-devel python3-Sphinx"
+short_desc="Post-processing tool for scanned sheets of paper"
 maintainer="Orphaned <orphan@voidlinux.org>"
-hostmakedepends="pkg-config libxslt"
-makedepends="ffmpeg-devel"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://www.flameeyes.eu/projects/unpaper"
-short_desc="A post-processing tool for scanned sheets of paper"
 distfiles="https://www.flameeyes.eu/files/${pkgname}-${version}.tar.xz"
-checksum=237c84f5da544b3f7709827f9f12c37c346cdf029b1128fb4633f9bafa5cb930
+checksum=2575fbbf26c22719d1cb882b59602c9900c7f747118ac130883f63419be46a80

From 3104fbdb912dec40e847c394095a1c9918a14c51 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 081/115] vba-m: revbump for ffmpeg-6.0

---
 srcpkgs/vba-m/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vba-m/template b/srcpkgs/vba-m/template
index 809343f465f24..e3f7785de0d23 100644
--- a/srcpkgs/vba-m/template
+++ b/srcpkgs/vba-m/template
@@ -2,7 +2,7 @@
 pkgname=vba-m
 reverts=1292_2
 version=2.1.6
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_GTK=TRUE -DENABLE_FFMPEG=TRUE -DENABLE_LINK=TRUE -DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="gettext pkg-config unzip zip yasm wxWidgets-gtk3-devel"

From 0036739f98c39bac5243f979403558a34541b17b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 082/115] vice: revbump for ffmpeg4-4.4.3

---
 srcpkgs/vice/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/vice/template b/srcpkgs/vice/template
index fe9d33a811947..4beab2c5f9ebd 100644
--- a/srcpkgs/vice/template
+++ b/srcpkgs/vice/template
@@ -1,7 +1,7 @@
 # Template file for 'vice'
 pkgname=vice
 version=3.7.1
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="
 	$(vopt_enable sdl2 sdlui2)
@@ -26,7 +26,7 @@ makedepends="
 	$(vopt_if gtk3 gtk+3-devel)
 	$(vopt_if gtk3 pulseaudio-devel)
 	$(vopt_if gtk3 pango-devel)
-	$(vopt_if ffmpeg ffmpeg-devel)"
+	$(vopt_if ffmpeg ffmpeg4-devel)"
 short_desc="Emulator for C64, C128, CBM-II, PET, VIC20, Plus4 and C16"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"

From a6b6cb2b234b41602c24881f5c14877f4b3538ac Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 083/115] waypipe: revbump for ffmpeg-6.0

---
 srcpkgs/waypipe/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waypipe/template b/srcpkgs/waypipe/template
index 5c4161900060a..1a46fe27f7d83 100644
--- a/srcpkgs/waypipe/template
+++ b/srcpkgs/waypipe/template
@@ -1,7 +1,7 @@
 # Template file for 'waypipe'
 pkgname=waypipe
 version=0.8.4
-revision=1
+revision=2
 build_style=meson
 # lto is off because it causes linking errors in armv6l and armv7l (due to NEON)
 configure_args="-Dwerror=false -Dwith_dmabuf=enabled -Dwith_lz4=enabled

From 78723b264f80c9ea3f6e858a53c1493286cea836 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 084/115] wf-recorder: revbump for ffmpeg-6.0

---
 srcpkgs/wf-recorder/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/wf-recorder/template b/srcpkgs/wf-recorder/template
index e278eb001600f..5d014a5f28afb 100644
--- a/srcpkgs/wf-recorder/template
+++ b/srcpkgs/wf-recorder/template
@@ -1,7 +1,7 @@
 # Template file for 'wf-recorder'
 pkgname=wf-recorder
 version=0.3.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config scdoc wayland-devel"
 makedepends="wayland-protocols wayland-devel ffmpeg-devel x264-devel

From 0fe3c7cc8654e642d7eb3f45918717e8b9e8adbe Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 085/115] xpra: revbump for ffmpeg-6.0

---
 srcpkgs/xpra/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xpra/template b/srcpkgs/xpra/template
index 0a63fdb6c7437..d5acc1981c5f6 100644
--- a/srcpkgs/xpra/template
+++ b/srcpkgs/xpra/template
@@ -1,7 +1,7 @@
 # Template file for 'xpra'
 pkgname=xpra
 version=4.4.6
-revision=1
+revision=2
 build_style=python3-module
 make_build_args="--without-cuda_kernels --without-cuda_rebuild"
 make_install_args="$(vopt_with docs) ${make_build_args}"

From 76c5aa26dcc3d4533395d8515e28676e18506211 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:07:40 -0400
Subject: [PATCH 086/115] nv-codec-headers: update to 12.0.16.0

---
 srcpkgs/nv-codec-headers/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/nv-codec-headers/template b/srcpkgs/nv-codec-headers/template
index 3d422a61e4891..251e057f826fb 100644
--- a/srcpkgs/nv-codec-headers/template
+++ b/srcpkgs/nv-codec-headers/template
@@ -1,6 +1,6 @@
 # Template file for 'nv-codec-headers'
 pkgname=nv-codec-headers
-version=11.1.5.1
+version=12.0.16.0
 revision=1
 build_style=gnu-makefile
 short_desc="FFmpeg version of headers required to interface with Nvidias codec APIs"
@@ -8,7 +8,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="MIT"
 homepage="http://git.videolan.org/?p=ffmpeg/nv-codec-headers.git"
 distfiles="https://github.com/FFmpeg/nv-codec-headers/archive/n${version}.tar.gz"
-checksum=d095fbd56aa93772471a323be0ebe65504a0f43f06c76a30b6d25da77b06ae9c
+checksum=2a1533b65f55f9da52956faf0627ed3b74868ac0c7f269990edd21369113b48f
 
 post_install() {
 	sed -n '4,25p' include/ffnvcodec/nvEncodeAPI.h > LICENSE

From 666eb469aca2eb24f8779bb86130c8c0523ab4bb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:08:40 -0400
Subject: [PATCH 087/115] openimagedenoise: revbump for ffmpeg-6.0

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index db5ccdb055cc9..cb90045afb634 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,7 +1,7 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
 version=1.4.3
-revision=1
+revision=2
 archs="x86_64*"
 build_style=cmake
 hostmakedepends="ispc python3"

From 52e85e50fa1e499a82acc7994f657f081b4f5052 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:31:45 -0400
Subject: [PATCH 088/115] shotcut: revbump for ffmpeg-6.0

---
 srcpkgs/shotcut/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/shotcut/template b/srcpkgs/shotcut/template
index 7d2af7b0470b5..c416c906ff734 100644
--- a/srcpkgs/shotcut/template
+++ b/srcpkgs/shotcut/template
@@ -1,7 +1,7 @@
 # Template file for 'shotcut'
 pkgname=shotcut
 version=23.05.14
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSHOTCUT_VERSION=${version}"
 hostmakedepends="pkg-config qt6-tools-devel"

From e9c2e07e23cd18ebd2f06dd8b87e9cc55c585c87 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:30 -0400
Subject: [PATCH 089/115] shiboken2: revbump for qt5-5.15.8

---
 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch | 1 +
 srcpkgs/shiboken2/template                                 | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
 create mode 120000 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
new file mode 120000
index 0000000000000..efcf3249bd885
--- /dev/null
+++ b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1 @@
+../../python3-pyside2/patches/importlib-machinery-bypass.patch
\ No newline at end of file
diff --git a/srcpkgs/shiboken2/template b/srcpkgs/shiboken2/template
index 084ecc3ba1e1c..2a21998997eb1 100644
--- a/srcpkgs/shiboken2/template
+++ b/srcpkgs/shiboken2/template
@@ -1,7 +1,7 @@
 # Template file for 'shiboken2'
 pkgname=shiboken2
 version=5.15.7
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/shiboken2"
 build_style=cmake

From ea145f0eba2c3fa4cb045f8ce8f04560630e7bcd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:53 -0400
Subject: [PATCH 090/115] python3-pyside2: update to 5.15.8

---
 .../patches/importlib-machinery-bypass.patch      | 15 +++++++++++++++
 srcpkgs/python3-pyside2/template                  |  9 +++++----
 2 files changed, 20 insertions(+), 4 deletions(-)
 create mode 100644 srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
new file mode 100644
index 0000000000000..64c429584776b
--- /dev/null
+++ b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1,15 @@
+Using this prevents an error around line 220 below it.
+"AttributeError: module 'importlib' has no attribute 'machinery'"
+The old backup logic is in place and compiles without issues.
+--- a/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:09:34.688912402 -0400
++++ b/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:10:03.395529582 -0400
+@@ -170,9 +170,6 @@
+
+     # 'zipstring_sequence' comes from signature.cpp
+     zipbytes = base64.b64decode(''.join(zipstring_sequence))
+-    if sys.version_info[0] >= 3:
+-        vzip = zipfile.ZipFile(io.BytesIO(zipbytes))
+-        return sys.meta_path, EmbeddableZipImporter(vzip)
+
+     # Old version for Python 2.7, only.
+     import os
diff --git a/srcpkgs/python3-pyside2/template b/srcpkgs/python3-pyside2/template
index 50e6ff260d3b5..b50e62bd215d4 100644
--- a/srcpkgs/python3-pyside2/template
+++ b/srcpkgs/python3-pyside2/template
@@ -1,11 +1,12 @@
 # Template file for 'python3-pyside2'
 pkgname=python3-pyside2
-version=5.15.5
-revision=2
+version=5.15.8
+revision=1
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/pyside2"
 build_style=cmake
-configure_args="-DPYTHON_EXECUTABLE=/usr/bin/python"
+configure_args="-DPYTHON_EXECUTABLE=/usr/bin/python -DCMAKE_BUILD_TYPE=None
+ -DBUILD_TESTS=OFF"
 hostmakedepends="cmake python3 shiboken2"
 makedepends="python3-devel libshiboken2-devel qt5-devel
  qt5-multimedia-devel qt5-tools-devel qt5-plugin-mysql qt5-plugin-odbc
@@ -23,7 +24,7 @@ maintainer="yopito <pierre.bourgin@free.fr>"
 license="LGPL-3.0-or-later"
 homepage="https://wiki.qt.io/Qt_for_Python"
 distfiles="https://download.qt.io/official_releases/QtForPython/pyside2/PySide2-${version}-src/${_pkgname}.tar.xz"
-checksum=3920a4fb353300260c9bc46ff70f1fb975c5e7efa22e9d51222588928ce19b33
+checksum=23436302c8deb5b4cbc769b205d09604e38ba83b40708efccb7bd8c9af6f6b5d
 
 build_options="webengine"
 desc_option_webengine="Build Qt5 WebEngine bindings"

From 18927f56a29b1924b226e863f207d3e3da16172a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:35 -0400
Subject: [PATCH 091/115] konqueror: revbump for ffmpeg-6.0

---
 srcpkgs/konqueror/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/konqueror/template b/srcpkgs/konqueror/template
index d8d0e73a78ab2..c5bdba601d3c3 100644
--- a/srcpkgs/konqueror/template
+++ b/srcpkgs/konqueror/template
@@ -1,11 +1,11 @@
 # Template file for 'konqueror'
 pkgname=konqueror
 version=23.04.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DDESKTOPTOJSON_EXECUTABLE=/usr/bin/desktoptojson"
 hostmakedepends="extra-cmake-modules python3 qt5-host-tools qt5-qmake kdoctools
-kcoreaddons kconfig gettext"
+ kcoreaddons kconfig gettext"
 makedepends="qt5-devel qt5-webengine-devel qt5-declarative-devel
  qt5-webchannel-devel qt5-location-devel kcmutils-devel kdelibs4support-devel
  karchive-devel khtml-devel kdesu-devel kactivities5-devel"

From 244c9701bc21af232bdeb1889bd81f5ebd13549a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:58 -0400
Subject: [PATCH 092/115] qt5-speech: revbump for qt5-5.15.8

---
 srcpkgs/qt5-speech/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-speech/template b/srcpkgs/qt5-speech/template
index 3ecd10d50650c..2d7d4d4d24535 100644
--- a/srcpkgs/qt5-speech/template
+++ b/srcpkgs/qt5-speech/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-speech'
 pkgname=qt5-speech
 version=5.15.7
-revision=2
+revision=3
 _commit=d32f4a479d38a11f547598004b975f4356424a16
 build_style=qmake
 configure_args="-- -flite -flite-alsa -speechd"

From c66ddfd47c6116ed1fc5c89dfc21d74aa5edab9b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 18:38:50 -0400
Subject: [PATCH 093/115] qt5-styleplugins: revbump for qt5-5.15.8

---
 srcpkgs/qt5-styleplugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-styleplugins/template b/srcpkgs/qt5-styleplugins/template
index 96ed97d12cd24..30d93660a2a4e 100644
--- a/srcpkgs/qt5-styleplugins/template
+++ b/srcpkgs/qt5-styleplugins/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-styleplugins'
 pkgname=qt5-styleplugins
 version=5.0.0
-revision=20
+revision=21
 _gitrev=335dbece103e2cbf6c7cf819ab6672c2956b17b3
 build_style=qmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From 8d9dee2d61dffe07c90f0fe6b173325406c30228 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 7 May 2023 20:14:14 -0400
Subject: [PATCH 094/115] mlt7: revbump for ffmpeg-6.0

---
 srcpkgs/gst-libav/template | 2 +-
 srcpkgs/mlt7/template      | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index 04c39bff14896..8c72fc3e97eee 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.22.2
-revision=2
+revision=1
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"
diff --git a/srcpkgs/mlt7/template b/srcpkgs/mlt7/template
index df3e2c559ad6c..77579fbf6b634 100644
--- a/srcpkgs/mlt7/template
+++ b/srcpkgs/mlt7/template
@@ -1,7 +1,7 @@
 # Template file for 'mlt7'
 pkgname=mlt7
 version=7.14.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSWIG_PYTHON=ON"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which

From 03ab5fab548bc0a340c51374770f4a00367a6ecc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 7 May 2023 20:15:03 -0400
Subject: [PATCH 095/115] qt6-webengine: revbump for ffmpeg-6.0

---
 srcpkgs/qt6-webengine/template | 1 +
 1 file changed, 1 insertion(+)

diff --git a/srcpkgs/qt6-webengine/template b/srcpkgs/qt6-webengine/template
index f948dc919a15e..43778b568d3f0 100644
--- a/srcpkgs/qt6-webengine/template
+++ b/srcpkgs/qt6-webengine/template
@@ -145,6 +145,7 @@ pre_install() {
 }
 
 post_install() {
+	vlicense LICENSES/BSD-3-Clause.txt
 	local _file
 	find "${DESTDIR}"/usr/lib/qt6/examples \
 		-path '*/lib/qt6/**/lib/qt6/*' -type f |

From 63e495d9e4c9b9dfec7f89ee8891184f93002d9a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 11 May 2023 14:05:14 -0400
Subject: [PATCH 096/115] openmw: revbump for ffmpeg-6.0

---
 srcpkgs/openmw/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openmw/template b/srcpkgs/openmw/template
index 3462591ec174f..93780ada551f0 100644
--- a/srcpkgs/openmw/template
+++ b/srcpkgs/openmw/template
@@ -1,7 +1,7 @@
 # Template file for 'openmw'
 pkgname=openmw
 version=0.48.0
-revision=1
+revision=2
 build_style=cmake
 _recast_commit=e75adf86f91eb3082220085e42dda62679f9a3ea
 _bullet_tag=3.17

From 6e619faa291fd509f2069b98ba2856ddec3f415a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 21 May 2023 12:44:11 -0400
Subject: [PATCH 097/115] electron24: revbump for ffmpeg-6.0

---
 srcpkgs/electron24/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron24/template b/srcpkgs/electron24/template
index 431ba6b0f8301..e67525b318d33 100644
--- a/srcpkgs/electron24/template
+++ b/srcpkgs/electron24/template
@@ -1,7 +1,7 @@
 # Template file for 'electron24'
 pkgname=electron24
 version=24.3.0
-revision=1
+revision=2
 _nodever=18.14.0
 _chromiumver=112.0.5615.165
 archs="x86_64* aarch64*"

From 62efe7dab0871c5ad09c42b26263f088d3bb8373 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Jun 2023 08:20:22 -0400
Subject: [PATCH 098/115] gtk4: revbump for ffmpeg-6.0

---
 srcpkgs/gtk4/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gtk4/template b/srcpkgs/gtk4/template
index 856d29a3d5dc3..512824e6894e4 100644
--- a/srcpkgs/gtk4/template
+++ b/srcpkgs/gtk4/template
@@ -1,7 +1,7 @@
 # Template file for 'gtk4'
 pkgname=gtk4
 version=4.10.4
-revision=1
+revision=2
 build_style=meson
 build_helper="gir"
 configure_args="-Dman-pages=true -Dgtk_doc=true -Dbuild-tests=false

From 930e546d61cf55a680fcd71f42e79e6a9e51b865 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:25:50 -0400
Subject: [PATCH 099/115] electron19: revbump for ffmpeg-6.0

---
 srcpkgs/electron19/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron19/template b/srcpkgs/electron19/template
index 3093248588438..1f6b7fb13769b 100644
--- a/srcpkgs/electron19/template
+++ b/srcpkgs/electron19/template
@@ -1,7 +1,7 @@
 # Template file for 'electron19'
 pkgname=electron19
 version=19.0.8
-revision=3
+revision=4
 _nodever=16.14.2
 _chromiumver=102.0.5005.125
 archs="x86_64* aarch64* ppc64le*"

From f0f0497ef89a1986698a37614e1245ae1c3e0223 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:28:26 -0400
Subject: [PATCH 100/115] siril: revbump for ffmpeg-6.0

---
 srcpkgs/siril/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/siril/template b/srcpkgs/siril/template
index 84332f79d060d..62750dd247548 100644
--- a/srcpkgs/siril/template
+++ b/srcpkgs/siril/template
@@ -1,7 +1,7 @@
 # Template file for 'siril'
 pkgname=siril
 version=0.9.12
-revision=10
+revision=11
 build_style=gnu-configure
 hostmakedepends="pkg-config intltool autoconf automake gettext-devel"
 makedepends="fftw-devel libconfig-devel libopencv-devel libffms2-devel

From eb5375a89bf223fef484a27fcd00870dfbb45094 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 10 Jun 2023 00:40:39 -0400
Subject: [PATCH 101/115] freecad: revbump for qt5-webengine-5.15.13

---
 srcpkgs/freecad/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/freecad/template b/srcpkgs/freecad/template
index a4a3f5f76b29a..8608d1670c87f 100644
--- a/srcpkgs/freecad/template
+++ b/srcpkgs/freecad/template
@@ -1,7 +1,7 @@
 # Template file for 'freecad'
 pkgname=freecad
 version=0.20.2
-revision=5
+revision=6
 build_style=cmake
 
 _inst_prefix=/usr/lib/${pkgname}

From 20d52fed2b1d0a705a7fca2ad8b07a0833c93e38 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 10 Jun 2023 00:57:09 -0400
Subject: [PATCH 102/115] qt6-multimedia: revbump for ffmpeg-6.0

---
 srcpkgs/qt6-multimedia/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-multimedia/template b/srcpkgs/qt6-multimedia/template
index a6832fdd69bfe..c9ffac914ab8f 100644
--- a/srcpkgs/qt6-multimedia/template
+++ b/srcpkgs/qt6-multimedia/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-multimedia'
 pkgname=qt6-multimedia
 version=6.5.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DQT_FEATURE_gstreamer=ON"
 hostmakedepends="perl qt6-declarative-host-tools pkg-config qt6-shadertools"

From 4f123aa4e439338fb9fbc33d51992b049f7859aa Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 22 Jun 2023 10:25:02 -0400
Subject: [PATCH 103/115] kdenlive: revbump for ffmpeg-6.0

---
 srcpkgs/kdenlive/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kdenlive/template b/srcpkgs/kdenlive/template
index 89c0dcfb8577f..75495b3a35869 100644
--- a/srcpkgs/kdenlive/template
+++ b/srcpkgs/kdenlive/template
@@ -1,7 +1,7 @@
 # Template file for 'kdenlive'
 pkgname=kdenlive
 version=23.04.2
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="
  extra-cmake-modules kconfig kcoreaddons kdoctools pkg-config python3

From 69b1cb41b664a9540a684be137dded82e9e4af22 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Jul 2023 09:18:23 -0400
Subject: [PATCH 104/115] gmic: revbump for opencv-4.7.0

---
 srcpkgs/gmic/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gmic/template b/srcpkgs/gmic/template
index 0bb4034d5cc86..808953e9b543c 100644
--- a/srcpkgs/gmic/template
+++ b/srcpkgs/gmic/template
@@ -1,7 +1,7 @@
 # Template file for 'gmic'
 pkgname=gmic
 version=3.1.6
-revision=4
+revision=5
 _zart_hash=34ebf6cce0bafb98abe57cec83c4a02cd1abeca0
 create_wrksrc=yes
 build_wrksrc="src"

From 8fa68e629367a3dbdca47b7984cde04e32aff76e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Jul 2023 09:29:52 -0400
Subject: [PATCH 105/115] synfigstudio: revbump for synfig mlt7

---
 srcpkgs/synfigstudio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/synfigstudio/template b/srcpkgs/synfigstudio/template
index af1c5a296ef0f..09e442da9a680 100644
--- a/srcpkgs/synfigstudio/template
+++ b/srcpkgs/synfigstudio/template
@@ -2,7 +2,7 @@
 # Should be kept in sync with 'synfig' and 'ETL'
 pkgname=synfigstudio
 version=1.4.4
-revision=3
+revision=4
 build_style=gnu-configure
 configure_args="--disable-update-mimedb"
 hostmakedepends="pkg-config intltool gettext synfig"

From 99b63dbdf53a3420f37d9bc14d9ef3dbe41665e4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Jul 2023 10:19:17 -0400
Subject: [PATCH 106/115] openimageio: revbump for ffmpeg6.0

---
 srcpkgs/openimageio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimageio/template b/srcpkgs/openimageio/template
index 69a9e23786942..d8a6ba56efd11 100644
--- a/srcpkgs/openimageio/template
+++ b/srcpkgs/openimageio/template
@@ -1,7 +1,7 @@
 # Template file for 'openimageio'
 pkgname=openimageio
 version=2.4.9.0
-revision=5
+revision=6
 build_style=cmake
 build_helper=qemu
 configure_args="-DUSE_QT=0 -DUSE_PYTHON=0 -DOIIO_BUILD_TESTS=0

From dcd3701f1ee23b4d10181338a5e0e81d5480a435 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Jul 2023 11:17:37 -0400
Subject: [PATCH 107/115] DELETE: intel_packages

---
 common/shlibs                                 |   2 +
 srcpkgs/intel-gmmlib/template                 |   6 +-
 ...mmon-Enable-MMC-in-free-kernel-build.patch | 125 ++++++++++++++++++
 srcpkgs/intel-media-driver/template           |   6 +-
 srcpkgs/intel-media-sdk/patches/musl.patch    |  14 ++
 srcpkgs/intel-media-sdk/template              |  37 ++++++
 srcpkgs/intel-media-sdk/update                |   1 +
 srcpkgs/onevpl-devel                          |   1 +
 srcpkgs/onevpl-intel-gpu-devel                |   1 +
 srcpkgs/onevpl-intel-gpu/template             |  27 ++++
 srcpkgs/onevpl/template                       |  34 +++++
 11 files changed, 248 insertions(+), 6 deletions(-)
 create mode 100644 srcpkgs/intel-media-driver/patches/0001-Media-Common-Enable-MMC-in-free-kernel-build.patch
 create mode 100644 srcpkgs/intel-media-sdk/patches/musl.patch
 create mode 100644 srcpkgs/intel-media-sdk/template
 create mode 100644 srcpkgs/intel-media-sdk/update
 create mode 120000 srcpkgs/onevpl-devel
 create mode 120000 srcpkgs/onevpl-intel-gpu-devel
 create mode 100644 srcpkgs/onevpl-intel-gpu/template
 create mode 100644 srcpkgs/onevpl/template

diff --git a/common/shlibs b/common/shlibs
index b73cd277054fb..b0fe573221472 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4330,6 +4330,8 @@ libgsoapssl++-2.8.124.so gsoap-2.8.124_1
 libjxl.so.0.8 libjxl-0.8.2_1
 libjxl_dec.so.0.8 libjxl-0.8.2_1
 libjxl_threads.so.0.8 libjxl-0.8.2_1
+libmfx.so.1 libmfx-22.6.4_1
+libvpl.so.2 onevpl-2023.1.2_1
 libtext-engine-0.1.so.0 text-engine-0.1.1_1
 libvmaf.so.1 vmaf-2.3.1_1
 liblc3.so.1 liblc3-1.0.3_1
diff --git a/srcpkgs/intel-gmmlib/template b/srcpkgs/intel-gmmlib/template
index 04e407b1de4d3..2605226152e5d 100644
--- a/srcpkgs/intel-gmmlib/template
+++ b/srcpkgs/intel-gmmlib/template
@@ -1,6 +1,6 @@
 # Template file for 'intel-gmmlib'
 pkgname=intel-gmmlib
-version=22.2.0
+version=22.3.3
 revision=1
 archs="i686* x86_64*"
 build_style=cmake
@@ -14,11 +14,11 @@ build_style=cmake
 # compilers flag in use.
 configure_args="-Wno-dev"
 short_desc="Intel Graphics Memory Management Library"
-maintainer="Orphaned <orphan@voidlinux.org>"
+maintainer="Stefano Ragni <st3r4g@protonmail.com>"
 license="MIT"
 homepage="https://github.com/intel/gmmlib"
 distfiles="https://github.com/intel/gmmlib/archive/intel-gmmlib-${version}.tar.gz"
-checksum=0b2253894c6fc8455b6d7c5e87e6504a76d6f60ea192e1445c2f93164bf529c0
+checksum=86651bd2803c9f0afd82471bec784e65d2b418dee315a053d22215eb2a679be7
 
 lib32disabled=yes
 
diff --git a/srcpkgs/intel-media-driver/patches/0001-Media-Common-Enable-MMC-in-free-kernel-build.patch b/srcpkgs/intel-media-driver/patches/0001-Media-Common-Enable-MMC-in-free-kernel-build.patch
new file mode 100644
index 0000000000000..525fb688722c8
--- /dev/null
+++ b/srcpkgs/intel-media-driver/patches/0001-Media-Common-Enable-MMC-in-free-kernel-build.patch
@@ -0,0 +1,125 @@
+From e68feab7db036838d9521ba3b9f00717c37c024c Mon Sep 17 00:00:00 2001
+From: JayYang <jay.yang@intel.com>
+Date: Tue, 21 Mar 2023 17:17:55 +0800
+Subject: [PATCH] [Media Common] Enable MMC in free kernel build
+
+Add mmc build definition in free kernel build
+---
+ media_driver/agnostic/gen9/codec/hal/media_srcs.cmake          | 2 +-
+ media_driver/cmake/linux/media_feature_flags_linux.cmake       | 3 +--
+ .../media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp        | 2 +-
+ .../media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp        | 2 +-
+ .../media_interfaces_m9_glk/media_interfaces_g9_glk.cpp        | 2 +-
+ .../media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp        | 2 +-
+ .../media_interfaces_m9_skl/media_interfaces_g9_skl.cpp        | 2 +-
+ 7 files changed, 7 insertions(+), 8 deletions(-)
+
+diff --git a/media_driver/agnostic/gen9/codec/hal/media_srcs.cmake b/media_driver/agnostic/gen9/codec/hal/media_srcs.cmake
+index 8bb36bafe..78902a22d 100644
+--- a/media_driver/agnostic/gen9/codec/hal/media_srcs.cmake
++++ b/media_driver/agnostic/gen9/codec/hal/media_srcs.cmake
+@@ -27,7 +27,7 @@ set(TMP_1_HEADERS_
+     ${CMAKE_CURRENT_LIST_DIR}/codechal_hw_g9_X.h
+ )
+ 
+-if(${MMC_Supported} STREQUAL "yes")
++if(${MMC_Supported} STREQUAL "yes" AND ENABLE_NONFREE_KERNELS AND ENABLE_KERNELS)
+     set(TMP_1_SOURCES_
+         ${TMP_1_SOURCES_}
+         ${CMAKE_CURRENT_LIST_DIR}/codechal_memdecomp_g9.cpp
+diff --git a/media_driver/cmake/linux/media_feature_flags_linux.cmake b/media_driver/cmake/linux/media_feature_flags_linux.cmake
+index de0ca853f..8121ea60c 100644
+--- a/media_driver/cmake/linux/media_feature_flags_linux.cmake
++++ b/media_driver/cmake/linux/media_feature_flags_linux.cmake
+@@ -35,7 +35,6 @@ if(NOT ENABLE_KERNELS OR NOT ENABLE_NONFREE_KERNELS)
+     bs_set_if_undefined(HEVC_Encode_VME_Supported "no")
+     bs_set_if_undefined(MPEG2_Encode_VME_Supported "no")
+     bs_set_if_undefined(CMRT_HEVC_ENC_FEI_Supported "no")
+-    bs_set_if_undefined(MMC_Supported "no")
+     bs_set_if_undefined(VC1_Decode_Supported "no")
+     bs_set_if_undefined(Decode_Processing_Supported "no")
+     bs_set_if_undefined(Kernel_Auto_Denoise_Supported "no")
+@@ -46,7 +45,6 @@ else()
+     bs_set_if_undefined(HEVC_Encode_VME_Supported "${Encode_VME_Supported}")
+     bs_set_if_undefined(MPEG2_Encode_VME_Supported "${Encode_VME_Supported}")
+     bs_set_if_undefined(CMRT_HEVC_ENC_FEI_Supported "yes")
+-    bs_set_if_undefined(MMC_Supported "yes")
+     bs_set_if_undefined(VC1_Decode_Supported "yes")
+     bs_set_if_undefined(Decode_Processing_Supported "yes")
+     bs_set_if_undefined(Kernel_Auto_Denoise_Supported "yes")
+@@ -64,6 +62,7 @@ bs_set_if_undefined(VP9_Decode_Supported "yes")
+ bs_set_if_undefined(VP_SFC_Supported "yes")
+ bs_set_if_undefined(Common_Encode_Supported "yes")
+ bs_set_if_undefined(Media_Scalability_Supported "yes")
++bs_set_if_undefined(MMC_Supported "yes")
+ 
+ # features controlled by global flag Encode_VDEnc_Supported
+ bs_set_if_undefined(AVC_Encode_VDEnc_Supported "${Encode_VDEnc_Supported}")
+diff --git a/media_driver/media_interface/media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp b/media_driver/media_interface/media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp
+index 3f306ee2a..8e4c0f532 100644
+--- a/media_driver/media_interface/media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp
+@@ -135,7 +135,7 @@ MOS_STATUS MhwInterfacesG9Bxt::Initialize(
+ 
+     return MOS_STATUS_SUCCESS;
+ }
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool bxtRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Bxt>((uint32_t)IGFX_BROXTON);
+diff --git a/media_driver/media_interface/media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp b/media_driver/media_interface/media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp
+index b8fa1eec0..84e0fad1d 100644
+--- a/media_driver/media_interface/media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp
+@@ -44,7 +44,7 @@ static bool cflRegisteredMhw =
+     MediaFactory<uint32_t, MhwInterfaces>::
+     Register<MhwInterfacesG9Kbl>((uint32_t)IGFX_COFFEELAKE);
+ 
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool cflRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Kbl>((uint32_t)IGFX_COFFEELAKE);
+diff --git a/media_driver/media_interface/media_interfaces_m9_glk/media_interfaces_g9_glk.cpp b/media_driver/media_interface/media_interfaces_m9_glk/media_interfaces_g9_glk.cpp
+index de81e6091..2638cb3a6 100644
+--- a/media_driver/media_interface/media_interfaces_m9_glk/media_interfaces_g9_glk.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_glk/media_interfaces_g9_glk.cpp
+@@ -65,7 +65,7 @@ static bool glkRegisteredMhw =
+     MediaFactory<uint32_t, MhwInterfaces>::
+     Register<MhwInterfacesG9Kbl>((uint32_t)IGFX_GEMINILAKE);
+ 
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool glkRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Kbl>((uint32_t)IGFX_GEMINILAKE);
+diff --git a/media_driver/media_interface/media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp b/media_driver/media_interface/media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp
+index 99d786185..4e9c6e7f1 100644
+--- a/media_driver/media_interface/media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp
+@@ -131,7 +131,7 @@ MOS_STATUS MhwInterfacesG9Kbl::Initialize(
+ 
+     return MOS_STATUS_SUCCESS;
+ }
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool kblRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Kbl>((uint32_t)IGFX_KABYLAKE);
+diff --git a/media_driver/media_interface/media_interfaces_m9_skl/media_interfaces_g9_skl.cpp b/media_driver/media_interface/media_interfaces_m9_skl/media_interfaces_g9_skl.cpp
+index e2520edf7..4b0012c64 100644
+--- a/media_driver/media_interface/media_interfaces_m9_skl/media_interfaces_g9_skl.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_skl/media_interfaces_g9_skl.cpp
+@@ -139,7 +139,7 @@ MOS_STATUS MhwInterfacesG9Skl::Initialize(
+ 
+     return MOS_STATUS_SUCCESS;
+ }
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool sklRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Skl>((uint32_t)IGFX_SKYLAKE);
+-- 
+2.40.0
+
diff --git a/srcpkgs/intel-media-driver/template b/srcpkgs/intel-media-driver/template
index a5bab06ac9476..1735b90c65ce5 100644
--- a/srcpkgs/intel-media-driver/template
+++ b/srcpkgs/intel-media-driver/template
@@ -1,6 +1,6 @@
 # Template file for 'intel-media-driver'
 pkgname=intel-media-driver
-version=22.5.3
+version=22.6.4
 revision=1
 archs="x86_64*"
 build_style=cmake
@@ -8,11 +8,11 @@ configure_args="-Wno-dev -DENABLE_NONFREE_KERNELS=$(vopt_if nonfree ON OFF)"
 hostmakedepends="pkg-config"
 makedepends="libva-devel libX11-devel intel-gmmlib-devel libpciaccess-devel"
 short_desc="Intel Media Driver for VAAPI (Broadwell+)"
-maintainer="Orphaned <orphan@voidlinux.org>"
+maintainer="Stefano Ragni <st3r4g@protonmail.com>"
 license="MIT, BSD-3-Clause"
 homepage="https://github.com/intel/media-driver"
 distfiles="https://github.com/intel/media-driver/archive/intel-media-${version}.tar.gz"
-checksum=65652b365d48be3c9f0b3c561502952b92ee5fcc587520b88d0d752cf2a6a3b5
+checksum=0c04b9d74b92de41fd409b62913ce4afd799236c0b6bc1983a496990764e5d90
 
 build_options="nonfree"
 desc_option_nonfree="Enable nonfree kernels"
diff --git a/srcpkgs/intel-media-sdk/patches/musl.patch b/srcpkgs/intel-media-sdk/patches/musl.patch
new file mode 100644
index 0000000000000..4ae70924b744f
--- /dev/null
+++ b/srcpkgs/intel-media-sdk/patches/musl.patch
@@ -0,0 +1,14 @@
+--- a/tools/tracer/tracer/tracer_linux.cpp	2022-11-18 03:02:59.000000000 -0500
++++ b/tools/tracer/tracer/tracer_linux.cpp	2022-12-18 01:44:51.341542572 -0500
+@@ -32,6 +32,11 @@
+ #include <dlfcn.h>
+ #include "tracer.h"
+
++#ifndef RTLD_DEEPBIND
++// musl neither defines nor can use RTLD_DEEPBIND
++#define RTLD_DEEPBIND 0
++#endif
++
+ #if defined(__i386__)
+     #define LIBMFXHW "libmfxhw32.so.1"
+ #elif defined(__x86_64__)
diff --git a/srcpkgs/intel-media-sdk/template b/srcpkgs/intel-media-sdk/template
new file mode 100644
index 0000000000000..7aeab51802f8e
--- /dev/null
+++ b/srcpkgs/intel-media-sdk/template
@@ -0,0 +1,37 @@
+# Template file for 'intel-media-sdk'
+pkgname=intel-media-sdk
+version=22.6.4
+revision=1
+archs="x86_64*"
+build_style=cmake
+configure_args="-Wno-dev -DBUILD_SAMPLES=OFF -DBUILD_TESTS=ON"
+hostmakedepends="pkg-config"
+makedepends="libva-devel libdrm-devel intel-gmmlib-devel"
+short_desc="Intel Media SDK"
+maintainer="Stefano Ragni <st3r4g@protonmail.com>"
+license="MIT, BSD-3-Clause"
+homepage="https://github.com/Intel-Media-SDK/MediaSDK"
+distfiles="https://github.com/Intel-Media-SDK/MediaSDK/archive/refs/tags/intel-mediasdk-${version}.tar.gz"
+checksum=197acd056f81e9ff1c27068d50e8c84c2014d94c7ac17cad69d5c2d61e445fd3
+
+post_install() {
+	vlicense LICENSE
+}
+
+libmfx_package() {
+	depends="${makedepends} ${sourcepkg}-${version}_${revision}"
+	short_desc="Intel MediaSDK mfx lib"
+	pkg_install() {
+		vmove usr/lib/mfx
+		vmove "usr/lib/libmfx*.so*"
+	}
+}
+
+libmfx-devel_package() {
+	depends="${makedepends} ${sourcepkg}-${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+	}
+}
diff --git a/srcpkgs/intel-media-sdk/update b/srcpkgs/intel-media-sdk/update
new file mode 100644
index 0000000000000..434a2bc67f7a1
--- /dev/null
+++ b/srcpkgs/intel-media-sdk/update
@@ -0,0 +1 @@
+pkgname=intel-media
diff --git a/srcpkgs/onevpl-devel b/srcpkgs/onevpl-devel
new file mode 120000
index 0000000000000..e2306500b4871
--- /dev/null
+++ b/srcpkgs/onevpl-devel
@@ -0,0 +1 @@
+onevpl
\ No newline at end of file
diff --git a/srcpkgs/onevpl-intel-gpu-devel b/srcpkgs/onevpl-intel-gpu-devel
new file mode 120000
index 0000000000000..47920ceecf919
--- /dev/null
+++ b/srcpkgs/onevpl-intel-gpu-devel
@@ -0,0 +1 @@
+onevpl-intel-gpu
\ No newline at end of file
diff --git a/srcpkgs/onevpl-intel-gpu/template b/srcpkgs/onevpl-intel-gpu/template
new file mode 100644
index 0000000000000..f14acb728a54d
--- /dev/null
+++ b/srcpkgs/onevpl-intel-gpu/template
@@ -0,0 +1,27 @@
+# Template file for 'onevpl-intel-gpu'
+pkgname=onevpl-intel-gpu
+version=22.6.4
+revision=1
+archs="x86_64*"
+build_style=cmake
+configure_args="-Wno-dev -DCMAKE_BUILD_TYPE=Release"
+hostmakedepends="cmake pkg-config"
+makedepends="libdrm-devel libva-devel onevpl-devel"
+short_desc="Runtime implementation of oneVPL API for Intel Gen GPUs"
+maintainer="zlice <zlice555@gmail.com>"
+license="MIT"
+homepage="https://github.com/oneapi-src/oneVPL-intel-gpu"
+changelog="https://github.com/oneapi-src/oneVPL-intel-gpu/blob/main/CHANGELOG.md"
+distfiles="https://github.com/oneapi-src/oneVPL-intel-gpu/archive/refs/tags/intel-onevpl-${version}.tar.gz"
+checksum=74b0979dcb2af1b7c68edb8cbcb02d539de511090b12fac50652cbacd707c4e6
+
+post_install() {
+	vlicense LICENSE
+}
+
+onevpl-intel-gpu-devel_package() {
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/lib/pkgconfig
+	}
+}
diff --git a/srcpkgs/onevpl/template b/srcpkgs/onevpl/template
new file mode 100644
index 0000000000000..85c7c2da85ce9
--- /dev/null
+++ b/srcpkgs/onevpl/template
@@ -0,0 +1,34 @@
+# Template file for 'onevpl'
+pkgname=onevpl
+version=2023.1.2
+revision=1
+archs="x86_64*"
+build_style=cmake
+configure_args="
+	-DCMAKE_BUILD_TYPE=Release -Wno-dev
+	-DBUILD_PYTHON_BINDING:BOOL='OFF'
+	-DBUILD_EXAMPLES:BOOL='OFF'
+	-DBUILD_TESTS:BOOL='ON'
+	-DINSTALL_EXAMPLE_CODE:BOOL='OFF'"
+hostmakedepends="cmake libX11 python wayland-protocols pkg-config"
+makedepends="libva-devel libX11-devel wayland-devel"
+short_desc="Intel oneAPI Video Processing library"
+maintainer="zlice <zlice555@gmail.com>"
+license="MIT"
+homepage="https://www.intel.com/content/www/us/en/developer/tools/oneapi/onevpl.html"
+distfiles="https://github.com/oneapi-src/oneVPL/archive/v${version}/${pkgname}-${version}.tar.gz"
+checksum=b2261cca174ce1815f3d47c647921ab17f68267c69c1e2444ff27aab7d199cbb
+
+post_install() {
+	vlicense LICENSE
+}
+
+onevpl-devel_package() {
+	depends="${makedepends} ${sourcepkg}-${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.so"
+	}
+}

From e3fea326a466e65be16ee2613e866d34b2cb0c51 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:20:59 -0400
Subject: [PATCH 108/115] tracker-miners: revbump for ffmpeg-6.0

---
 srcpkgs/tracker-miners/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tracker-miners/template b/srcpkgs/tracker-miners/template
index a6e5aa5777024..aa0f443927cdb 100644
--- a/srcpkgs/tracker-miners/template
+++ b/srcpkgs/tracker-miners/template
@@ -1,7 +1,7 @@
 # Template file for 'tracker-miners'
 pkgname=tracker-miners
 version=3.5.0
-revision=4
+revision=5
 build_style=meson
 build_helper=qemu
 # missing libgrss for miner_rss

From a42a7c8ff1f255ae607f3d788cd0eff8f014e624 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:21:21 -0400
Subject: [PATCH 109/115] mpd: revbump for ffmpeg-6.0

---
 srcpkgs/mpd/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpd/template b/srcpkgs/mpd/template
index b916d655709aa..05fa0f7927e2e 100644
--- a/srcpkgs/mpd/template
+++ b/srcpkgs/mpd/template
@@ -1,7 +1,7 @@
 # Template file for 'mpd'
 pkgname=mpd
 version=0.23.13
-revision=2
+revision=3
 build_style=meson
 configure_args="-Dopus=enabled -Dmikmod=enabled -Dneighbor=true
  -Dsoundcloud=enabled -Dpipe=true -Dtwolame=enabled -Dbzip2=enabled

From 00facb3eb01a87a1873b4c47841be5bdaf85ea6c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:27:17 -0400
Subject: [PATCH 110/115] lms: revbump for ffmpeg-6.0

---
 srcpkgs/lms/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/lms/template b/srcpkgs/lms/template
index 2df52c51dbfe6..cb3ea5e58c80f 100644
--- a/srcpkgs/lms/template
+++ b/srcpkgs/lms/template
@@ -1,7 +1,7 @@
 # Template file for 'lms'
 pkgname=lms
 version=3.40.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="wt-devel ffmpeg-devel boost-devel libconfig++-devel taglib-devel pam-devel libgraphicsmagick-devel gtest-devel libarchive-devel"

From 945377b404dc2e144329dbf968f3cc1f674e62b8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 17 Jul 2023 15:37:44 -0400
Subject: [PATCH 111/115] mixxx: revbump for ffmpeg-6.0

---
 srcpkgs/mixxx/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mixxx/template b/srcpkgs/mixxx/template
index 4b9ea00d3fb3d..a861d11a48726 100644
--- a/srcpkgs/mixxx/template
+++ b/srcpkgs/mixxx/template
@@ -1,7 +1,7 @@
 # Template file for 'mixxx'
 pkgname=mixxx
 version=2.3.3
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="extra-cmake-modules pkg-config protobuf qt5-host-tools qt5-devel"

From 85219039c5c1f117c291f181b9ccad82a014ee80 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 17 Jul 2023 15:38:14 -0400
Subject: [PATCH 112/115] telegram-desktop: revbump for ffmpeg-6.0

---
 srcpkgs/telegram-desktop/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/telegram-desktop/template b/srcpkgs/telegram-desktop/template
index 19a6722f4697b..a9412425bf1a1 100644
--- a/srcpkgs/telegram-desktop/template
+++ b/srcpkgs/telegram-desktop/template
@@ -1,7 +1,7 @@
 # Template file for 'telegram-desktop'
 pkgname=telegram-desktop
 version=4.8.4
-revision=1
+revision=2
 build_style=cmake
 build_helper="qemu gir"
 configure_args="-DTDESKTOP_API_ID=209235

From 36caae11b9c0e588831edc0afb5eda8479b98a17 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 2 Aug 2023 10:13:17 -0400
Subject: [PATCH 113/115] mpv: revbump for ffmpeg-6.0

---
 srcpkgs/mpv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpv/template b/srcpkgs/mpv/template
index 1f7108e162d07..c340bec4aec4c 100644
--- a/srcpkgs/mpv/template
+++ b/srcpkgs/mpv/template
@@ -1,7 +1,7 @@
 # Template file for 'mpv'
 pkgname=mpv
 version=0.35.1
-revision=3
+revision=4
 build_style=meson
 configure_args="-Dcdda=enabled -Ddvbin=enabled -Ddvdnav=enabled
  -Dlibmpv=true -Dcplugins=enabled

From bac9b2e2d5809e3458fdb6d921ce9c6d5ed9ae9f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 2 Aug 2023 10:14:13 -0400
Subject: [PATCH 114/115] gst-plugins-bad1: revbump for ffmpeg-6.0

---
 srcpkgs/gst-plugins-bad1/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index 3267a97094a2a..4189f3686ee32 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-plugins-bad1'
 pkgname=gst-plugins-bad1
 version=1.22.2
-revision=2
+revision=3
 build_helper="gir"
 build_style=meson
 configure_args="-Dpackage-origin=https://voidlinux.org -Ddoc=disabled

From 78b36f7e47267c17f4627f1fef64348915ea26f5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 2 Aug 2023 10:17:33 -0400
Subject: [PATCH 115/115] libopenshot: revbump for ffmpeg-6.0

---
 srcpkgs/libopenshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenshot/template b/srcpkgs/libopenshot/template
index e9926e3111495..23c81266a8850 100644
--- a/srcpkgs/libopenshot/template
+++ b/srcpkgs/libopenshot/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenshot'
 pkgname=libopenshot
 version=0.3.0
-revision=2
+revision=3
 build_style=cmake
 # Builds fail with Ruby-2.4.1
 configure_args="-DENABLE_RUBY=OFF -DUSE_SYSTEM_JSONCPP=ON"

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (21 preceding siblings ...)
  2023-08-02 14:18 ` zlice
@ 2023-08-30 13:18 ` zlice
  2023-10-02  0:04 ` yoshiyoshyosh
                   ` (74 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2023-08-30 13:18 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 3573 bytes --]

There is an updated pull request by zlice against master on the void-packages repository

https://github.com/zlice/void-packages ffmpeg6-split
https://github.com/void-linux/void-packages/pull/43761

ffmpeg6 split
[ci skip]


#### Testing the changes

- I tested the changes in this PR: **YES**

main testing has been vaapi in Firefox Nightly and enc/dec in Shotcut on Intel A770

#### New package

- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**

#### Local build testing

- I built this PR locally for my native architecture, **x86_64**

#### Discussion

Continuation of https://github.com/void-linux/void-packages/pull/36315

`libavresample` is deprecated, but marked as a dependency when trying to build other packages and install `ffmpeg`(6). I think the right way to handle this is make a meta package and the add to removals?


##### Commit naming / misc

~~Commits are 'dirty' right now, running with [gstreamer 1.22.1 updates](https://github.com/void-linux/void-packages/pull/42861) and [Intel OpenCL](https://github.com/void-linux/void-packages/pull/43084). This will also make [intel packages pr](https://github.com/void-linux/void-packages/pull/41132) obsolete.~~ (see Requirements below)

Maintainer for previous ffmpeg(4) was orphaned, I can put my name in there if that matters, though I don't exactly see myself keeping up on ffmpeg.

This updates QT5 which looks like it is usually hosted by Johnny. Not sure if there's any reason to stay there or these sources are fine.

##### STILL FFMPEG4

These are a mix of emulators, games and/or older packages.

- attract (multiple patches in master)
- audacity (https://github.com/audacity/audacity/issues/2305 and https://sourceforge.net/p/portmedia/wiki/portsmf/ is 'beta')
- ccextractor (master patches? no release)
- vice
- kodi
- mlt (only dep left is flowblade)
- ~~synfig (mlt)~~ (work with mlt7, bump synfigstudio)
- tvheadend
- ssr
- spek-alternative
- ppsspp
- olive
- moc
- mediastreamer
- libextractor
- idjc
- hedgewars
- ~~ffmpegthumbnailer~~ (patches for moviedecoder.xxx files)
- ~~ffmpegthumbs~~ (latest compiles)
- deadbeef
- omxplayer
- qtav (fork has ffmpeg 5 patch - https://github.com/cmguo/QtAV)
- `vlc` (vlc4 will support ffmpeg5, there's a patch to build 3.x with ffmpeg5 but it will lack vaapi)
- `osg` (OpenSceneGraph plus `xine-lib`)


##### HAVE NOT BUILT YET

- omxplayer (rpi only? ffmpeg4)
- kodi (big, but ffmpeg4)


##### UPDATED (for ffmpeg6)

- ~~blender: update to 3.5.1~~ ~~will be revbump with~~ https://github.com/void-linux/void-packages/pull/43992
- unpaper: update to 7.0.0.
- guvcview: update to 2.0.8.
- qt5: update to 5.15.8
- qt5-webengine: update to 5.18.13
- shiboken2: revbump for qt5.15.8 (patch)
- python3-pyside2: update to 5.15.8 (patch)


##### Requirements

- ~~[gstreamer 1.22.2](https://github.com/void-linux/void-packages/pull/42861)~~ - a few packages use ffmpeg-devel and require a revbump

- [Intel Packages](https://github.com/void-linux/void-packages/pull/41132) - ffmpeg4 uses different libraries than 6 (libmfx / Intel-MediaSDK vs only oneVPL that Intel is moving to), both are included here

- ~~[shotcut 23.05.14](https://github.com/void-linux/void-packages/pull/44260)~~

- https://github.com/void-linux/void-packages/pull/44781 will remove from this PR

A patch file from https://github.com/void-linux/void-packages/pull/43761.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ffmpeg6-split-43761.patch --]
[-- Type: text/x-diff, Size: 788337 bytes --]

From 0a3a9e633cbe7df1b3eb01db2841bec1ab0723c2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:55:46 -0400
Subject: [PATCH 001/115] ffmpeg: update to 6.0.

---
 common/shlibs                                 | 26 +++++---
 srcpkgs/ffmpeg/files/altivec.patch            | 60 -------------------
 .../patches/armv5tel-floating-point.patch     | 18 ------
 ...h-libavcodec-libsvtav1-ten_bit_format.diff | 40 -------------
 .../workaround-mesa-readeon-vaapi-bug.patch   | 28 ---------
 srcpkgs/ffmpeg/template                       | 38 ++++++------
 6 files changed, 37 insertions(+), 173 deletions(-)
 delete mode 100644 srcpkgs/ffmpeg/files/altivec.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 delete mode 100644 srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch

diff --git a/common/shlibs b/common/shlibs
index 616785bdb4778..e149667138cbd 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -386,15 +386,23 @@ libid3tag.so.0 libid3tag-0.15.1b_1
 libgif.so.7 giflib-5.1.0_1
 libImlib2.so.1 imlib2-1.4.2_1
 libmp3lame.so.0 lame-3.98.2_1
-libavdevice.so.58 libavdevice-4.0_1
-libavformat.so.58 libavformat-4.0_1
-libswscale.so.5 libswscale-4.0_1
-libswresample.so.3 libswresample-4.0_1
-libavresample.so.4 libavresample-4.0_1
-libpostproc.so.55 libpostproc-4.0_1
-libavcodec.so.58 libavcodec-4.0_1
-libavutil.so.56 libavutil-4.0_1
-libavfilter.so.7 libavfilter-4.0_1
+libavdevice.so.60 libavdevice-6.0_1
+libavformat.so.60 libavformat-6.0_1
+libswscale.so.7 libswscale-6.0_1
+libswresample.so.4 libswresample-6.0_1
+libpostproc.so.57 libpostproc-6.0_1
+libavcodec.so.60 libavcodec-6.0_1
+libavutil.so.58 libavutil-6.0_1
+libavfilter.so.9 libavfilter-6.0_1
+libavdevice.so.58 libavdevice4-4.0_1
+libavformat.so.58 libavformat4-4.0_1
+libswscale.so.5 libswscale4-4.0_1
+libswresample.so.3 libswresample4-4.0_1
+libavresample.so.4 libavresample4-4.0_1
+libpostproc.so.55 libpostproc4-4.0_1
+libavcodec.so.58 libavcodec4-4.0_1
+libavutil.so.56 libavutil4-4.0_1
+libavfilter.so.7 libavfilter4-4.0_1
 libSDL-1.2.so.0 SDL-1.2.14_1
 libSDL_image-1.2.so.0 SDL_image-1.2.10_1
 libx264.so.157 x264-20190507.2245_1
diff --git a/srcpkgs/ffmpeg/files/altivec.patch b/srcpkgs/ffmpeg/files/altivec.patch
deleted file mode 100644
index 9c57200463320..0000000000000
--- a/srcpkgs/ffmpeg/files/altivec.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-revert some altivec specific change on all ppc* except ppc64le*
-
-q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
-conditionally, for ppc* but not ppc64le* (the new code is valid for
-POWER8 VSX which LE targets as a baseline but not BE)"
-
-
-This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
----
- libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
- 1 file changed, 20 insertions(+), 4 deletions(-)
-
-diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
-index 536545293d..c1e2852adb 100644
---- a/libswscale/ppc/yuv2rgb_altivec.c
-+++ b/libswscale/ppc/yuv2rgb_altivec.c
-@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-     vector signed short R1, G1, B1;                                           \
-     vector unsigned char R, G, B;                                             \
-                                                                               \
-+    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
-+    vector unsigned char align_perm;                                          \
-+                                                                              \
-     vector signed short lCY       = c->CY;                                    \
-     vector signed short lOY       = c->OY;                                    \
-     vector signed short lCRV      = c->CRV;                                   \
-@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
-                                                                               \
-         for (j = 0; j < w / 16; j++) {                                        \
--            y0 = vec_xl(0, y1i);                                              \
-+            y1ivP = (const vector unsigned char *) y1i;                       \
-+            y2ivP = (const vector unsigned char *) y2i;                       \
-+            uivP  = (const vector unsigned char *) ui;                        \
-+            vivP  = (const vector unsigned char *) vi;                        \
-+                                                                              \
-+            align_perm = vec_lvsl(0, y1i);                                    \
-+            y0 = (vector unsigned char)                                       \
-+                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
-                                                                               \
--            y1 = vec_xl(0, y2i);                                              \
-+            align_perm = vec_lvsl(0, y2i);                                    \
-+            y1 = (vector unsigned char)                                       \
-+                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
-                                                                               \
--            u = (vector signed char) vec_xl(0, ui);                           \
-+            align_perm = vec_lvsl(0, ui);                                     \
-+            u = (vector signed char)                                          \
-+                    vec_perm(uivP[0], uivP[1], align_perm);                   \
-                                                                               \
--            v = (vector signed char) vec_xl(0, vi);                           \
-+            align_perm = vec_lvsl(0, vi);                                     \
-+            v = (vector signed char)                                          \
-+                    vec_perm(vivP[0], vivP[1], align_perm);                   \
-                                                                               \
-             u = (vector signed char)                                          \
-                     vec_sub(u,                                                \
--- 
-2.27.0
-
diff --git a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
deleted file mode 100644
index 9a55178c74f0f..0000000000000
--- a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
-+++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
-@@ -39,6 +39,15 @@
- #endif
- #include <fenv.h>
- 
-+#if (FE_ALL_EXCEPT == 0)
-+/* E.g. ARM soft float does not define these */
-+#define FE_INVALID    0
-+#define FE_DIVBYZERO  0
-+#define FE_OVERFLOW   0
-+#define FE_UNDERFLOW  0
-+#define FE_INEXACT    0
-+#endif
-+
- #if CONFIG_LIBFONTCONFIG
- #include <fontconfig/fontconfig.h>
- #endif
diff --git a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
deleted file mode 100644
index aa948f7a8a2df..0000000000000
--- a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
+++ /dev/null
@@ -1,40 +0,0 @@
-#==================================================================================================
-# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
-# From: Christopher Degawa <christopher.degawa@intel.com>
-# Date: Thu, 20 Oct 2022 22:55:27 -0500
-# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
-#
-# compressed_ten_bit_format has been deprecated upstream and has no effect
-# and can be removed. Plus, technically it was never used in the first place
-# since it would require the app (ffmpeg) to set it and do additional
-# processing of the input frames.
-#
-# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
-#
-# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
-#==================================================================================================
---- a/libavcodec/libsvtav1.c
-+++ b/libavcodec/libsvtav1.c
-@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
- 
- static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
- {
--    const int    pack_mode_10bit =
--        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
--    const size_t luma_size_8bit  =
--        config->source_width * config->source_height * (1 << pack_mode_10bit);
--    const size_t luma_size_10bit =
--        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
-+    const size_t luma_size = config->source_width * config->source_height *
-+        (config->encoder_bit_depth > 8 ? 2 : 1);
- 
-     EbSvtIOFormat *in_data;
- 
--    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
-+    svt_enc->raw_size = luma_size * 3 / 2;
- 
-     // allocate buffer for in and out
-     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
--- 
-GitLab
-
diff --git a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
deleted file mode 100644
index 00e3f68a415b8..0000000000000
--- a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
-From: Rainer Hochecker <fernetmenta@online.de>
-Date: Sat, 26 Jan 2019 19:48:35 +0100
-Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
-
-This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
-It was hit frequently when watching h264 channels received via DVB-X.
-Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
----
- libavcodec/vaapi_h264.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
-index 5854587a255..f12fdc457a4 100644
---- a/libavcodec/vaapi_h264.c
-+++ b/libavcodec/vaapi_h264.c
-@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
-     H264SliceContext *sl = &h->slice_ctx[0];
-     int ret;
- 
-+    if (pic->nb_slices == 0) {
-+        ret = AVERROR_INVALIDDATA;
-+        goto finish;
-+    }
-+
-     ret = ff_vaapi_decode_issue(avctx, pic);
-     if (ret < 0)
-         goto finish;
diff --git a/srcpkgs/ffmpeg/template b/srcpkgs/ffmpeg/template
index ae26496e79293..c1f9b7efe40e3 100644
--- a/srcpkgs/ffmpeg/template
+++ b/srcpkgs/ffmpeg/template
@@ -1,15 +1,15 @@
 # Template file for 'ffmpeg'
 # audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
 pkgname=ffmpeg
-version=4.4.4
-revision=2
+version=6.0
+revision=1
 short_desc="Decoding, encoding and streaming software"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="https://www.ffmpeg.org"
 changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
 distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
-checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+checksum=57be87c22d9b49c112b6d24bc67d42508660e6b718b3db89c44e47e289137082
 
 hostmakedepends="pkg-config perl"
 makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
@@ -26,12 +26,13 @@ makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-deve
  $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
  $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
  $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
- $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers Vulkan-Tools Vulkan-ValidationLayers')
+ $(vopt_if onevpl 'onevpl onevpl-devel')
  $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
 depends="ffplay>=${version}_${revision}"
 
 build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
- dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec onevpl"
 build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
 desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
 desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
@@ -39,9 +40,13 @@ desc_option_sofa="Enable support for AES SOFA"
 desc_option_webp="Enable support for WebP"
 
 case "$XBPS_TARGET_MACHINE" in
-	i686*|x86_64*)
-		hostmakedepends+=" nasm"
+	i686*)
 		build_options_default+=" vaapi vdpau nvenc nvdec"
+		hostmakedepends+=" nasm"
+		;;
+	x86_64*)
+		hostmakedepends+=" nasm"
+		build_options_default+=" vaapi vdpau nvenc nvdec onevpl"
 		;;
 	ppc64*) build_options_default+=" vaapi vdpau";;
 	mips*) CFLAGS="-mnan=legacy";;
@@ -115,18 +120,19 @@ do_configure() {
 		$(vopt_enable x265 libx265) \
 		$(vopt_enable v4l2 libv4l2) \
 		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
-		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		--enable-libbs2b --enable-libvidstab \
 		$(vopt_enable dav1d libdav1d) \
 		$(vopt_enable zimg libzimg) \
 		$(vopt_enable webp libwebp) \
 		$(vopt_enable sofa libmysofa) \
 		$(vopt_enable vulkan) \
+		$(vopt_enable onevpl libvpl) \
 		$(vopt_enable drm libdrm) \
 		$(vopt_enable svtav1 libsvtav1) \
 		$(vopt_enable srt libsrt) \
 		$(vopt_enable rist librist) \
-		$(vopt_if nvenc '--enable-nvenc') \
-		$(vopt_if nvdec '--enable-nvdec')
+		$(vopt_enable nvenc nvenc) \
+		$(vopt_enable nvdec nvdec)
 }
 
 do_build() {
@@ -153,10 +159,8 @@ libavdevice_package() {
 }
 
 libavresample_package() {
-	short_desc="FFmpeg audio resampling library"
-	pkg_install() {
-		vmove "usr/lib/libavresample.so.*"
-	}
+	short_desc="Package deprecated, removal needed"
+	build_style=meta
 }
 
 libavformat_package() {
@@ -210,15 +214,13 @@ ffmpeg-devel_package() {
 		libavfilter>=${version}_${revision}
 		libpostproc>=${version}_${revision}
 		libswscale>=${version}_${revision}
-		libswresample>=${version}_${revision}
-		libavresample>=${version}_${revision}"
+		libswresample>=${version}_${revision}"
 	short_desc+=" - development files"
-
+	conflicts="ffmpeg4-devel"
 	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
 		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
 		nostrip_files="/usr/lib/libavfilter.a"
 	fi
-
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig

From 53d96d752b63a9bdb58e6ed3efb667ab179d7444 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:56:22 -0400
Subject: [PATCH 002/115] New package: ffmpeg4-4.4.4.

---
 srcpkgs/ffmpeg4-devel                         |   1 +
 srcpkgs/ffmpeg4/files/altivec.patch           |  60 +++++
 .../patches/armv5tel-floating-point.patch     |  18 ++
 ...h-libavcodec-libsvtav1-ten_bit_format.diff |  40 +++
 .../workaround-mesa-readeon-vaapi-bug.patch   |  28 ++
 srcpkgs/ffmpeg4/template                      | 240 ++++++++++++++++++
 srcpkgs/libavcodec4                           |   1 +
 srcpkgs/libavdevice4                          |   1 +
 srcpkgs/libavfilter4                          |   1 +
 srcpkgs/libavformat4                          |   1 +
 srcpkgs/libavresample4                        |   1 +
 srcpkgs/libavutil4                            |   1 +
 srcpkgs/libpostproc4                          |   1 +
 srcpkgs/libswresample4                        |   1 +
 srcpkgs/libswscale4                           |   1 +
 15 files changed, 396 insertions(+)
 create mode 120000 srcpkgs/ffmpeg4-devel
 create mode 100644 srcpkgs/ffmpeg4/files/altivec.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 create mode 100644 srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
 create mode 100644 srcpkgs/ffmpeg4/template
 create mode 120000 srcpkgs/libavcodec4
 create mode 120000 srcpkgs/libavdevice4
 create mode 120000 srcpkgs/libavfilter4
 create mode 120000 srcpkgs/libavformat4
 create mode 120000 srcpkgs/libavresample4
 create mode 120000 srcpkgs/libavutil4
 create mode 120000 srcpkgs/libpostproc4
 create mode 120000 srcpkgs/libswresample4
 create mode 120000 srcpkgs/libswscale4

diff --git a/srcpkgs/ffmpeg4-devel b/srcpkgs/ffmpeg4-devel
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/ffmpeg4-devel
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/ffmpeg4/files/altivec.patch b/srcpkgs/ffmpeg4/files/altivec.patch
new file mode 100644
index 0000000000000..9c57200463320
--- /dev/null
+++ b/srcpkgs/ffmpeg4/files/altivec.patch
@@ -0,0 +1,60 @@
+revert some altivec specific change on all ppc* except ppc64le*
+
+q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
+conditionally, for ppc* but not ppc64le* (the new code is valid for
+POWER8 VSX which LE targets as a baseline but not BE)"
+
+
+This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
+---
+ libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
+ 1 file changed, 20 insertions(+), 4 deletions(-)
+
+diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
+index 536545293d..c1e2852adb 100644
+--- a/libswscale/ppc/yuv2rgb_altivec.c
++++ b/libswscale/ppc/yuv2rgb_altivec.c
+@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+     vector signed short R1, G1, B1;                                           \
+     vector unsigned char R, G, B;                                             \
+                                                                               \
++    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
++    vector unsigned char align_perm;                                          \
++                                                                              \
+     vector signed short lCY       = c->CY;                                    \
+     vector signed short lOY       = c->OY;                                    \
+     vector signed short lCRV      = c->CRV;                                   \
+@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
+                                                                               \
+         for (j = 0; j < w / 16; j++) {                                        \
+-            y0 = vec_xl(0, y1i);                                              \
++            y1ivP = (const vector unsigned char *) y1i;                       \
++            y2ivP = (const vector unsigned char *) y2i;                       \
++            uivP  = (const vector unsigned char *) ui;                        \
++            vivP  = (const vector unsigned char *) vi;                        \
++                                                                              \
++            align_perm = vec_lvsl(0, y1i);                                    \
++            y0 = (vector unsigned char)                                       \
++                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
+                                                                               \
+-            y1 = vec_xl(0, y2i);                                              \
++            align_perm = vec_lvsl(0, y2i);                                    \
++            y1 = (vector unsigned char)                                       \
++                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
+                                                                               \
+-            u = (vector signed char) vec_xl(0, ui);                           \
++            align_perm = vec_lvsl(0, ui);                                     \
++            u = (vector signed char)                                          \
++                    vec_perm(uivP[0], uivP[1], align_perm);                   \
+                                                                               \
+-            v = (vector signed char) vec_xl(0, vi);                           \
++            align_perm = vec_lvsl(0, vi);                                     \
++            v = (vector signed char)                                          \
++                    vec_perm(vivP[0], vivP[1], align_perm);                   \
+                                                                               \
+             u = (vector signed char)                                          \
+                     vec_sub(u,                                                \
+-- 
+2.27.0
+
diff --git a/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
new file mode 100644
index 0000000000000..9a55178c74f0f
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
@@ -0,0 +1,18 @@
+--- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
++++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
+@@ -39,6 +39,15 @@
+ #endif
+ #include <fenv.h>
+ 
++#if (FE_ALL_EXCEPT == 0)
++/* E.g. ARM soft float does not define these */
++#define FE_INVALID    0
++#define FE_DIVBYZERO  0
++#define FE_OVERFLOW   0
++#define FE_UNDERFLOW  0
++#define FE_INEXACT    0
++#endif
++
+ #if CONFIG_LIBFONTCONFIG
+ #include <fontconfig/fontconfig.h>
+ #endif
diff --git a/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
new file mode 100644
index 0000000000000..aa948f7a8a2df
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
@@ -0,0 +1,40 @@
+#==================================================================================================
+# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
+# From: Christopher Degawa <christopher.degawa@intel.com>
+# Date: Thu, 20 Oct 2022 22:55:27 -0500
+# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
+#
+# compressed_ten_bit_format has been deprecated upstream and has no effect
+# and can be removed. Plus, technically it was never used in the first place
+# since it would require the app (ffmpeg) to set it and do additional
+# processing of the input frames.
+#
+# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
+#
+# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
+#==================================================================================================
+--- a/libavcodec/libsvtav1.c
++++ b/libavcodec/libsvtav1.c
+@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
+ 
+ static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
+ {
+-    const int    pack_mode_10bit =
+-        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
+-    const size_t luma_size_8bit  =
+-        config->source_width * config->source_height * (1 << pack_mode_10bit);
+-    const size_t luma_size_10bit =
+-        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
++    const size_t luma_size = config->source_width * config->source_height *
++        (config->encoder_bit_depth > 8 ? 2 : 1);
+ 
+     EbSvtIOFormat *in_data;
+ 
+-    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
++    svt_enc->raw_size = luma_size * 3 / 2;
+ 
+     // allocate buffer for in and out
+     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
+-- 
+GitLab
+
diff --git a/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
new file mode 100644
index 0000000000000..00e3f68a415b8
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
@@ -0,0 +1,28 @@
+From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
+From: Rainer Hochecker <fernetmenta@online.de>
+Date: Sat, 26 Jan 2019 19:48:35 +0100
+Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
+
+This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
+It was hit frequently when watching h264 channels received via DVB-X.
+Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
+---
+ libavcodec/vaapi_h264.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
+index 5854587a255..f12fdc457a4 100644
+--- a/libavcodec/vaapi_h264.c
++++ b/libavcodec/vaapi_h264.c
+@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
+     H264SliceContext *sl = &h->slice_ctx[0];
+     int ret;
+ 
++    if (pic->nb_slices == 0) {
++        ret = AVERROR_INVALIDDATA;
++        goto finish;
++    }
++
+     ret = ff_vaapi_decode_issue(avctx, pic);
+     if (ret < 0)
+         goto finish;
diff --git a/srcpkgs/ffmpeg4/template b/srcpkgs/ffmpeg4/template
new file mode 100644
index 0000000000000..f2c851693d367
--- /dev/null
+++ b/srcpkgs/ffmpeg4/template
@@ -0,0 +1,240 @@
+# Template file for 'ffmpeg4'
+# audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
+pkgname=ffmpeg4
+version=4.4.4
+revision=1
+short_desc="Decoding, encoding and streaming software - ffmpeg4 libraries only"
+maintainer="Orphaned <orphan@voidlinux.org>"
+license="GPL-3.0-or-later"
+homepage="https://www.ffmpeg.org"
+changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
+distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
+checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+
+hostmakedepends="pkg-config perl"
+makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
+ libXext-devel libXvMC-devel libxcb-devel lame-devel libtheora-devel
+ libvorbis-devel x264-devel xvidcore-devel jack-devel SDL2-devel
+ libcdio-paranoia-devel librtmp-devel libmodplug-devel gnutls-devel
+ speex-devel celt-devel harfbuzz-devel libass-devel opus-devel ocl-icd-devel
+ libbs2b-devel libvidstab-devel vmaf-devel $(vopt_if pulseaudio pulseaudio-devel)
+ $(vopt_if vaapi libva-devel) $(vopt_if vdpau libvdpau-devel)
+ $(vopt_if x265 x265-devel) $(vopt_if v4l2 v4l-utils-devel)
+ $(vopt_if fdk_aac fdk-aac-devel) $(vopt_if vpx libvpx-devel)
+ $(vopt_if aom libaom-devel) $(vopt_if sndio sndio-devel)
+ $(vopt_if dav1d libdav1d-devel) $(vopt_if zimg zimg-devel)
+ $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
+ $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
+ $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if mfx 'libmfx libmfx-devel')
+ $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
+
+build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec mfx"
+build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
+
+desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
+desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
+desc_option_sofa="Enable support for AES SOFA"
+desc_option_webp="Enable support for WebP"
+
+case "$XBPS_TARGET_MACHINE" in
+	i686*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau nvenc nvdec"
+			;;
+	x86_64*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau mfx nvenc nvdec"
+			;;
+	ppc64*) build_options_default+=" vaapi vdpau";;
+	mips*) CFLAGS="-mnan=legacy";;
+esac
+
+if [ "$XBPS_TARGET_WORDSIZE" != "32" ]; then
+	build_options_default+=" svtav1"
+fi
+
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+fi
+
+_apply_patch() {
+	local args="$1" pname="$(basename $2)"
+
+	if [ ! -f ".${pname}_done" ]; then
+		patch -N $args -i $2
+		touch .${pname}_done
+	fi
+}
+
+post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64le*) ;;
+		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
+	esac
+
+	vsed -i libavfilter/vf_libvmaf.c -e 's!/usr/local/share/model/\(vmaf_v0.6.1\).pkl!/usr/share/vmaf/\1.json!'
+}
+
+do_configure() {
+	# Fix gcc on x86_64-musl only
+	if [ "$XBPS_TARGET_MACHINE" = "x86_64-musl" ]; then
+		vsed -i configure -e "s;_cflags_speed='-O3';_cflags_speed='-O2';"
+	fi
+
+	if [ "$CROSS_BUILD" ]; then
+		case "$XBPS_TARGET_MACHINE" in
+			arm*) _arch="arm";;
+			aarch64*) _arch="aarch64";;
+			mips*) _arch="mips";;
+			ppc64*) _arch="ppc64";;
+			ppc*) _arch="ppc";;
+			*) _arch="${XBPS_TARGET_MACHINE%%-musl}";;
+		esac
+
+		_args+=" --enable-cross-compile
+			--sysroot=$XBPS_CROSS_BASE
+			--cross-prefix=${XBPS_CROSS_TRIPLET}-
+			--target-os=linux --arch=${_arch}"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc|ppc-musl) _args+=" --disable-altivec";;
+	esac
+
+	if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+		_args+=" --extra-libs=-latomic"
+	fi
+
+	./configure --prefix=/usr --disable-debug --enable-gpl --enable-gnutls \
+		--disable-stripping \
+		--enable-libcdio --enable-version3 --enable-runtime-cpudetect \
+		--enable-libmp3lame --enable-libvorbis --enable-libxvid \
+		--enable-libx264 $(vopt_enable vpx libvpx) --enable-libtheora \
+		--enable-shared --enable-static --enable-libxcb \
+		$(vopt_enable pulseaudio libpulse) --enable-libfreetype --enable-libmodplug \
+		--enable-libspeex --enable-libcelt --enable-libass \
+		--enable-libopus --enable-librtmp --enable-libjack \
+		$(vopt_if fdk_aac '--enable-nonfree --enable-libfdk-aac') \
+		--disable-libopencore_amrnb --disable-libopencore_amrwb \
+		--disable-libopenjpeg \
+		--enable-postproc --enable-opencl ${_args} --enable-libvmaf ${_args} \
+		$(vopt_enable x265 libx265) \
+		$(vopt_enable v4l2 libv4l2) \
+		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
+		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		$(vopt_enable dav1d libdav1d) \
+		$(vopt_enable zimg libzimg) \
+		$(vopt_enable webp libwebp) \
+		$(vopt_enable sofa libmysofa) \
+		$(vopt_enable vulkan) \
+		$(vopt_enable drm libdrm) \
+		$(vopt_enable svtav1 libsvtav1) \
+		$(vopt_enable srt libsrt) \
+		$(vopt_enable rist librist) \
+		$(vopt_enable mfx libmfx) \
+		$(vopt_if nvenc '--enable-nvenc') \
+		$(vopt_if nvdec '--enable-nvdec')
+}
+
+do_build() {
+	make ${makejobs}
+	make doc/ff{mpeg,play}.1
+}
+
+do_install() {
+	make DESTDIR=${DESTDIR} install install-man
+	rm -rf ${DESTDIR}/usr/bin
+}
+
+libavcodec4_package() {
+	short_desc="FFmpeg codec library"
+	pkg_install() {
+		vmove "usr/lib/libavcodec.so.*"
+	}
+}
+
+libavdevice4_package() {
+	short_desc="FFmpeg device handling library"
+	pkg_install() {
+		vmove "usr/lib/libavdevice.so.*"
+	}
+}
+
+libavresample4_package() {
+	short_desc="FFmpeg audio resampling library"
+	pkg_install() {
+		vmove "usr/lib/libavresample.so.*"
+	}
+}
+
+libavformat4_package() {
+	short_desc="FFmpeg file format library"
+	pkg_install() {
+		vmove "usr/lib/libavformat.so.*"
+	}
+}
+
+libavutil4_package() {
+	short_desc="FFmpeg utility library"
+	pkg_install() {
+		vmove "usr/lib/libavutil.so.*"
+	}
+}
+
+libavfilter4_package() {
+	short_desc="FFmpeg audio/video filter library"
+	pkg_install() {
+		vmove "usr/lib/libavfilter.so.*"
+	}
+}
+
+libpostproc4_package() {
+	short_desc="FFmpeg video postprocessing library"
+	pkg_install() {
+		vmove "usr/lib/libpostproc.so.*"
+	}
+}
+
+libswscale4_package() {
+	short_desc="FFmpeg video scaling library"
+	pkg_install() {
+		vmove "usr/lib/libswscale.so.*"
+	}
+}
+
+libswresample4_package() {
+	short_desc="FFmpeg video resampling library"
+	pkg_install() {
+		vmove "usr/lib/libswresample.so.*"
+	}
+}
+
+ffmpeg4-devel_package() {
+	depends="
+		libavcodec4>=${version}_${revision}
+		libavdevice4>=${version}_${revision}
+		libavformat4>=${version}_${revision}
+		libavutil4>=${version}_${revision}
+		libavfilter4>=${version}_${revision}
+		libpostproc4>=${version}_${revision}
+		libswscale4>=${version}_${revision}
+		libswresample4>=${version}_${revision}
+		libavresample4>=${version}_${revision}"
+	short_desc+=" - development files"
+	conflicts="ffmpeg-devel"
+	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
+		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
+		nostrip_files="/usr/lib/libavfilter.a"
+	fi
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.a"
+		vmove "usr/lib/*.so"
+		vmove usr/share/ffmpeg/examples
+		vmove usr/share/man/man3
+	}
+}
diff --git a/srcpkgs/libavcodec4 b/srcpkgs/libavcodec4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavcodec4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavdevice4 b/srcpkgs/libavdevice4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavdevice4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavfilter4 b/srcpkgs/libavfilter4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavfilter4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavformat4 b/srcpkgs/libavformat4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavformat4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavresample4 b/srcpkgs/libavresample4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavutil4 b/srcpkgs/libavutil4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavutil4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libpostproc4 b/srcpkgs/libpostproc4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libpostproc4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswresample4 b/srcpkgs/libswresample4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libswresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswscale4 b/srcpkgs/libswscale4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libswscale4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file

From 7ffa6078bf65af606eee752ab0efd48fafb14b2d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:04 -0400
Subject: [PATCH 003/115] opencv: update to 4.7.0.

---
 common/shlibs           | 104 ++++++++++++++++++++--------------------
 srcpkgs/opencv/template |   8 ++--
 2 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index e149667138cbd..2c3d99f7595c1 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2112,58 +2112,58 @@ libcapstone.so.4 capstone-4.0_1
 libhavege.so.2 libhaveged-1.9.11_1
 libnih.so.1 libnih-1.0.3_1
 libnih-dbus.so.1 libnih-1.0.3_1
-libopencv_quality.so.406 libopencv-4.6.0_1
-libopencv_reg.so.406 libopencv-4.6.0_1
-libopencv_surface_matching.so.406 libopencv-4.6.0_1
-libopencv_xphoto.so.406 libopencv-4.6.0_1
-libopencv_freetype.so.406 libopencv-4.6.0_1
-libopencv_fuzzy.so.406 libopencv-4.6.0_1
-libopencv_hfs.so.406 libopencv-4.6.0_1
-libopencv_img_hash.so.406 libopencv-4.6.0_1
-libopencv_line_descriptor.so.406 libopencv-4.6.0_1
-libopencv_saliency.so.406 libopencv-4.6.0_1
-libopencv_structured_light.so.406 libopencv-4.6.0_1
-libopencv_aruco.so.406 libopencv-4.6.0_1
-libopencv_bgsegm.so.406 libopencv-4.6.0_1
-libopencv_bioinspired.so.406 libopencv-4.6.0_1
-libopencv_ccalib.so.406 libopencv-4.6.0_1
-libopencv_face.so.406 libopencv-4.6.0_1
-libopencv_tracking.so.406 libopencv-4.6.0_1
-libopencv_xfeatures2d.so.406 libopencv-4.6.0_1
-libopencv_optflow.so.406 libopencv-4.6.0_1
-libopencv_ximgproc.so.406 libopencv-4.6.0_1
-libopencv_plot.so.406 libopencv-4.6.0_1
-libopencv_text.so.406 libopencv-4.6.0_1
-libopencv_ml.so.406 libopencv-4.6.0_1
-libopencv_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn.so.406 libopencv-4.6.0_1
-libopencv_shape.so.406 libopencv-4.6.0_1
-libopencv_stitching.so.406 libopencv-4.6.0_1
-libopencv_photo.so.406 libopencv-4.6.0_1
-libopencv_video.so.406 libopencv-4.6.0_1
-libopencv_calib3d.so.406 libopencv-4.6.0_1
-libopencv_features2d.so.406 libopencv-4.6.0_1
-libopencv_flann.so.406 libopencv-4.6.0_1
-libopencv_highgui.so.406 libopencv-4.6.0_1
-libopencv_videoio.so.406 libopencv-4.6.0_1
-libopencv_imgcodecs.so.406 libopencv-4.6.0_1
-libopencv_imgproc.so.406 libopencv-4.6.0_1
-libopencv_core.so.406 libopencv-4.6.0_1
-libopencv_superres.so.406 libopencv-4.6.0_1
-libopencv_videostab.so.406 libopencv-4.6.0_1
-libopencv_gapi.so.406 libopencv-4.6.0_1
-libopencv_xobjdetect.so.406 libopencv-4.6.0_1
-libopencv_datasets.so.406 libopencv-4.6.0_1
-libopencv_dnn_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn_superres.so.406 libopencv-4.6.0_1
-libopencv_dpm.so.406 libopencv-4.6.0_1
-libopencv_phase_unwrapping.so.406 libopencv-4.6.0_1
-libopencv_stereo.so.406 libopencv-4.6.0_1
-libopencv_rapid.so.406 libopencv-4.6.0_1
-libopencv_intensity_transform.so.406 libopencv-4.6.0_1
-libopencv_alphamat.so.406 libopencv-4.6.0_1
-libopencv_barcode.so.406 libopencv-4.6.0_1
-libopencv_mcc.so.406 libopencv-4.6.0_1
+libopencv_quality.so.407 libopencv-4.7.0_1
+libopencv_reg.so.407 libopencv-4.7.0_1
+libopencv_surface_matching.so.407 libopencv-4.7.0_1
+libopencv_xphoto.so.407 libopencv-4.7.0_1
+libopencv_freetype.so.407 libopencv-4.7.0_1
+libopencv_fuzzy.so.407 libopencv-4.7.0_1
+libopencv_hfs.so.407 libopencv-4.7.0_1
+libopencv_img_hash.so.407 libopencv-4.7.0_1
+libopencv_line_descriptor.so.407 libopencv-4.7.0_1
+libopencv_saliency.so.407 libopencv-4.7.0_1
+libopencv_structured_light.so.407 libopencv-4.7.0_1
+libopencv_aruco.so.407 libopencv-4.7.0_1
+libopencv_bgsegm.so.407 libopencv-4.7.0_1
+libopencv_bioinspired.so.407 libopencv-4.7.0_1
+libopencv_ccalib.so.407 libopencv-4.7.0_1
+libopencv_face.so.407 libopencv-4.7.0_1
+libopencv_tracking.so.407 libopencv-4.7.0_1
+libopencv_xfeatures2d.so.407 libopencv-4.7.0_1
+libopencv_optflow.so.407 libopencv-4.7.0_1
+libopencv_ximgproc.so.407 libopencv-4.7.0_1
+libopencv_plot.so.407 libopencv-4.7.0_1
+libopencv_text.so.407 libopencv-4.7.0_1
+libopencv_ml.so.407 libopencv-4.7.0_1
+libopencv_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn.so.407 libopencv-4.7.0_1
+libopencv_shape.so.407 libopencv-4.7.0_1
+libopencv_stitching.so.407 libopencv-4.7.0_1
+libopencv_photo.so.407 libopencv-4.7.0_1
+libopencv_video.so.407 libopencv-4.7.0_1
+libopencv_calib3d.so.407 libopencv-4.7.0_1
+libopencv_features2d.so.407 libopencv-4.7.0_1
+libopencv_flann.so.407 libopencv-4.7.0_1
+libopencv_highgui.so.407 libopencv-4.7.0_1
+libopencv_videoio.so.407 libopencv-4.7.0_1
+libopencv_imgcodecs.so.407 libopencv-4.7.0_1
+libopencv_imgproc.so.407 libopencv-4.7.0_1
+libopencv_core.so.407 libopencv-4.7.0_1
+libopencv_superres.so.407 libopencv-4.7.0_1
+libopencv_videostab.so.407 libopencv-4.7.0_1
+libopencv_gapi.so.407 libopencv-4.7.0_1
+libopencv_xobjdetect.so.407 libopencv-4.7.0_1
+libopencv_datasets.so.407 libopencv-4.7.0_1
+libopencv_dnn_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn_superres.so.407 libopencv-4.7.0_1
+libopencv_dpm.so.407 libopencv-4.7.0_1
+libopencv_phase_unwrapping.so.407 libopencv-4.7.0_1
+libopencv_stereo.so.407 libopencv-4.7.0_1
+libopencv_rapid.so.407 libopencv-4.7.0_1
+libopencv_intensity_transform.so.407 libopencv-4.7.0_1
+libopencv_alphamat.so.407 libopencv-4.7.0_1
+libopencv_barcode.so.407 libopencv-4.7.0_1
+libopencv_mcc.so.407 libopencv-4.7.0_1
 libuniconf.so.4.6 wvstreams-4.6.1_20
 libwvbase.so.4.6 wvstreams-4.6.1_20
 libwvutils.so.4.6 wvstreams-4.6.1_20
diff --git a/srcpkgs/opencv/template b/srcpkgs/opencv/template
index 62226978fa3e0..93b58cb6af146 100644
--- a/srcpkgs/opencv/template
+++ b/srcpkgs/opencv/template
@@ -1,7 +1,7 @@
 # Template file for 'opencv'
 pkgname=opencv
-version=4.6.0
-revision=4
+version=4.7.0
+revision=1
 create_wrksrc=yes
 build_wrksrc=${pkgname}-${version}
 build_style=cmake
@@ -24,8 +24,8 @@ homepage="https://opencv.org"
 changelog="https://github.com/opencv/opencv/wiki/ChangeLog"
 distfiles="https://github.com/opencv/opencv/archive/${version}.tar.gz
  https://github.com/opencv/opencv_contrib/archive/${version}.tar.gz>contrib.tar.gz"
-checksum="1ec1cba65f9f20fe5a41fda1586e01c70ea0c9a6d7b67c9e13edf0cfe2239277
- 1777d5fd2b59029cf537e5fd6f8aa68d707075822f90bde683fcde086f85f7a7"
+checksum="8df0079cdbe179748a18d44731af62a245a45ebf5085223dc03133954c662973
+ 42df840cf9055e59d0e22c249cfb19f04743e1bdad113d31b1573d3934d62584"
 patch_args="-Np1 -d ${build_wrksrc}"
 # tests hang indenfinitely, even with test data included
 make_check=no

From 83a3ab21ca8263e24bbfcbd0536a9308bb6b17d6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 004/115] actiona: revbump for opencv-4.7.0

---
 srcpkgs/actiona/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/actiona/template b/srcpkgs/actiona/template
index cf5f0b7a2ae61..0d899311e6df7 100644
--- a/srcpkgs/actiona/template
+++ b/srcpkgs/actiona/template
@@ -1,7 +1,7 @@
 # Template file for 'actiona'
 pkgname=actiona
 version=3.10.1
-revision=2
+revision=3
 build_style=qmake
 configure_args="PKGCONFIG_OPENCV=opencv4"
 hostmakedepends="pkg-config qt5-plugin-mysql qt5-qmake qt5-host-tools"

From 7dd8ee6ea5cc149bf22e70e35fb593faa8f309f4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 005/115] qimgv: revbump for opencv-4.7.0

---
 srcpkgs/qimgv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qimgv/template b/srcpkgs/qimgv/template
index 7eb30db33992c..dd341dfe1bfce 100644
--- a/srcpkgs/qimgv/template
+++ b/srcpkgs/qimgv/template
@@ -1,7 +1,7 @@
 # Template file for 'qimgv'
 pkgname=qimgv
 version=1.0.2
-revision=2
+revision=3
 build_style=cmake
 configure_args="$(vopt_if video -DVIDEO_SUPPORT=ON -DVIDEO_SUPPORT=OFF)
  $(vopt_if scale -DOPENCV_SUPPORT=ON -DOPENCV_SUPPORT=OFF)

From 6006f7cae664b9930f8b55e9e31e825f03e99ad5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 006/115] retroshare: revbump for opencv-4.7.0

---
 srcpkgs/retroshare/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroshare/template b/srcpkgs/retroshare/template
index bb17569277a7f..49e2c1cbe8a53 100644
--- a/srcpkgs/retroshare/template
+++ b/srcpkgs/retroshare/template
@@ -1,7 +1,7 @@
 # Template file for 'retroshare'
 pkgname=retroshare
 version=0.6.6
-revision=3
+revision=4
 build_style=qmake
 #XXX broadcast feature requires an ancient udp-discovery-cpp which either needs
 # to be fetched+patched (FTBFS) here or packaged :/

From b8eaabc5e220c56e54919d1dca3b31b52e723eff Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 007/115] waifu2x-converter-cpp: revbump for opencv-4.7.0

---
 srcpkgs/waifu2x-converter-cpp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waifu2x-converter-cpp/template b/srcpkgs/waifu2x-converter-cpp/template
index 8c095d0d7baba..aa52d8c981a84 100644
--- a/srcpkgs/waifu2x-converter-cpp/template
+++ b/srcpkgs/waifu2x-converter-cpp/template
@@ -1,7 +1,7 @@
 # Template file for 'waifu2x-converter-cpp'
 pkgname=waifu2x-converter-cpp
 version=5.2.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DINSTALL_MODELS=ON"
 hostmakedepends="pkg-config"

From 009d10f607a2768915f5e830692e078cf5b8c252 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:38 -0400
Subject: [PATCH 008/115] vlc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/vlc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vlc/template b/srcpkgs/vlc/template
index be579ce38fe37..3974289947401 100644
--- a/srcpkgs/vlc/template
+++ b/srcpkgs/vlc/template
@@ -25,7 +25,7 @@ lib32disabled=yes
 hostmakedepends="automake libtool pkg-config flex gettext libgcrypt-devel
  live555-devel gettext-devel $(vopt_if lua lua52) $(vopt_if chromecast protobuf)"
 makedepends="
- avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg-devel freefont-ttf
+ avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg4-devel freefont-ttf
  gnutls-devel jack-devel liba52-devel libass-devel libbluray-devel
  libcdio-devel libdca-devel libdvbpsi-devel libdvdnav-devel libmad-devel
  libmatroska-devel libmodplug-devel libmpcdec-devel libmpeg2-devel

From 91845f5ff2f4e63cb5efc4cc4ebcd1c599231b4d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:55 -0400
Subject: [PATCH 009/115] osg: revbump for ffmpeg4-4.4.3

---
 srcpkgs/osg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/osg/template b/srcpkgs/osg/template
index a9ebbd287933b..755793f7e11bf 100644
--- a/srcpkgs/osg/template
+++ b/srcpkgs/osg/template
@@ -8,7 +8,7 @@ build_helper="qemu"
 configure_args="-DLIB_POSTFIX="
 hostmakedepends="pkg-config xrandr"
 makedepends="MesaLib-devel gtkglext-devel libcurl-devel giflib-devel librsvg-devel
- jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg-devel xine-lib-devel
+ jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg4-devel xine-lib-devel
  SDL2-devel gst-plugins-base1-devel
  $(vopt_if openexr libopenexr-devel)
  $(vopt_if poppler poppler-glib-devel)

From fa3388d6a565504e3f88142ecb39419f52608d58 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:13 -0400
Subject: [PATCH 010/115] xine-lib: revbump for ffmpeg4-4.4.3

---
 srcpkgs/xine-lib/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/xine-lib/template b/srcpkgs/xine-lib/template
index f713eff49b07c..ed6194c17d11e 100644
--- a/srcpkgs/xine-lib/template
+++ b/srcpkgs/xine-lib/template
@@ -1,6 +1,6 @@
 # Template file for 'xine-lib'
 pkgname=xine-lib
-version=1.2.12
+version=1.2.13
 revision=1
 build_style=gnu-configure
 configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
@@ -8,7 +8,7 @@ configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
 hostmakedepends="automake gettext-devel libtool pkg-config perl"
 makedepends="
  zlib-devel alsa-lib-devel libxcb-devel libSM-devel libXext-devel libXv-devel
- libXvMC-devel liba52-devel libmad-devel ffmpeg-devel pulseaudio-devel
+ libXvMC-devel liba52-devel libmad-devel ffmpeg4-devel pulseaudio-devel
  jack-devel samba-devel libflac-devel libmodplug-devel libmpcdec-devel
  speex-devel libtheora-devel libvorbis-devel libdca-devel faad2-devel
  libcdio-devel libbluray-devel aalib-devel libcaca-devel libXinerama-devel
@@ -19,7 +19,7 @@ license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="http://www.xine-project.org"
 changelog="https://sourceforge.net/projects/xine/files/xine-lib/${version}/README.txt/view"
 distfiles="${SOURCEFORGE_SITE}/xine/${pkgname}-${version}.tar.xz"
-checksum=d606270468e1540c2a89c0d7f5fdf11e17ecc0c2698cc0bcb1065ff26abee098
+checksum=5f10d6d718a4a51c17ed1b32b031d4f9b80b061e8276535b2be31e5ac4b75e6f
 
 case "$XBPS_TARGET_MACHINE" in
 	i686-musl)

From cab38bf28c6d8e601de2cf4a387eeefc19af4c98 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 011/115] QMPlay2: revbump for ffmpeg-6.0

---
 srcpkgs/QMPlay2/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/QMPlay2/template b/srcpkgs/QMPlay2/template
index 63ec2b5b53d04..f276ebd672ac7 100644
--- a/srcpkgs/QMPlay2/template
+++ b/srcpkgs/QMPlay2/template
@@ -1,7 +1,7 @@
 # Template file for 'QMPlay2'
 pkgname=QMPlay2
 version=23.08.08
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools"
 makedepends="alsa-lib-devel ffmpeg-devel libass-devel libcdio-devel libgme-devel

From dc737de3fd591832774d2507aab720b968cb64c5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 012/115] alsa-plugins: revbump for ffmpeg-6.0

---
 srcpkgs/alsa-plugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/alsa-plugins/template b/srcpkgs/alsa-plugins/template
index 0bfa6d9fd2643..a5708a7d82a8f 100644
--- a/srcpkgs/alsa-plugins/template
+++ b/srcpkgs/alsa-plugins/template
@@ -1,7 +1,7 @@
 # Template file for 'alsa-plugins'
 pkgname=alsa-plugins
 version=1.2.7.1
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--disable-maemo-plugin"
 hostmakedepends="pkg-config"

From b9f9182e9a619399bd4d2b270a9c732b976f9f27 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 013/115] arcan: revbump for ffmpeg-6.0

---
 srcpkgs/arcan/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/arcan/template b/srcpkgs/arcan/template
index 853e16fcad391..6b2da6fa6e62e 100644
--- a/srcpkgs/arcan/template
+++ b/srcpkgs/arcan/template
@@ -2,7 +2,7 @@
 # !! keep synced with: acfgfs aclip aloadimage
 pkgname=arcan
 version=0.6.2.1
-revision=1
+revision=2
 create_wrksrc=yes
 build_wrksrc=arcan/src
 build_style=cmake

From 1fcb078494b4b25cfa8037b4dab643da9a5916fa Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 014/115] attract: revbump for ffmpeg4-4.4.3

---
 srcpkgs/attract/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/attract/template b/srcpkgs/attract/template
index 26144e931a3c7..e760bf0d18aec 100644
--- a/srcpkgs/attract/template
+++ b/srcpkgs/attract/template
@@ -1,12 +1,12 @@
 # Template file for 'attract'
 pkgname=attract
 version=2.6.2
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="VERBOSE=1"
 make_use_env=yes
 hostmakedepends="pkg-config"
-makedepends="SFML-devel ffmpeg-devel fontconfig-devel glu-devel libarchive-devel
+makedepends="SFML-devel ffmpeg4-devel fontconfig-devel glu-devel libarchive-devel
  libcurl-devel libjpeg-turbo-devel xine-lib rapidjson libXrandr-devel"
 depends="git"
 short_desc="Attract-Mode is a graphical frontend for emulators"

From d013187521979abc9b911980a865ee7529e0b271 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 015/115] aubio: revbump for ffmpeg-6.0

---
 srcpkgs/aubio/patches/ffmpeg5.patch | 25 +++++++++++++++++++++++++
 srcpkgs/aubio/template              |  2 +-
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/aubio/patches/ffmpeg5.patch

diff --git a/srcpkgs/aubio/patches/ffmpeg5.patch b/srcpkgs/aubio/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..aace41a6e6d9a
--- /dev/null
+++ b/srcpkgs/aubio/patches/ffmpeg5.patch
@@ -0,0 +1,25 @@
+From 8a05420e5dd8c7b8b2447f82dc919765876511b3 Mon Sep 17 00:00:00 2001
+From: Paul Brossier <piem@piem.org>
+Date: Tue, 25 Jan 2022 18:30:27 +0100
+Subject: [PATCH] [source_avcodec] define FF_API_LAVF_AVCTX for libavcodec >
+ 59, thx @berolinux (closes gh-353)
+
+---
+ src/io/source_avcodec.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/io/source_avcodec.c b/src/io/source_avcodec.c
+index e0ae93b5..1421bd9a 100644
+--- a/src/io/source_avcodec.c
++++ b/src/io/source_avcodec.c
+@@ -68,6 +68,10 @@
+ #define AUBIO_AVCODEC_MAX_BUFFER_SIZE AV_INPUT_BUFFER_MIN_SIZE
+ #endif
+ 
++#if LIBAVCODEC_VERSION_MAJOR >= 59
++#define FF_API_LAVF_AVCTX 1
++#endif
++
+ struct _aubio_source_avcodec_t {
+   uint_t hop_size;
+   uint_t samplerate;
diff --git a/srcpkgs/aubio/template b/srcpkgs/aubio/template
index ad1c4b2569917..7d875cc02541a 100644
--- a/srcpkgs/aubio/template
+++ b/srcpkgs/aubio/template
@@ -1,7 +1,7 @@
 # Template file for 'aubio'
 pkgname=aubio
 version=0.4.9
-revision=1
+revision=2
 build_style=waf3
 # XXX lash, pure and swig support.
 hostmakedepends="pkg-config txt2man"

From e77f0d4bf45d375882e32aa42dbf709a58847e99 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 016/115] audacious-plugins: revbump for ffmpeg-6.0

---
 .../audacious-plugins/patches/ffmpeg5.patch   | 43 +++++++++++++++++++
 srcpkgs/audacious-plugins/template            |  2 +-
 2 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/audacious-plugins/patches/ffmpeg5.patch

diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg5.patch b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..4e5e34099d71c
--- /dev/null
+++ b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
@@ -0,0 +1,43 @@
+commit 298aa371c56c2f52c25a33d9bdec4918b11cebdc
+Author: tibequadorian <tibequadorian@posteo.de>
+Date:   Sat Mar 19 18:40:12 2022 +0100
+
+    audacious-plugins: rebuild against ffmpeg-5.0
+
+diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+new file mode 100644
+index 0000000000..617c11215b
+--- /dev/null
++++ b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+@@ -0,0 +1,31 @@
++From f60beb400eeb1e4778bbfd738bc4a4ccef3de539 Mon Sep 17 00:00:00 2001
++From: John Lindgren <john@jlindgren.net>
++Date: Sat, 5 Mar 2022 12:05:34 -0500
++Subject: [PATCH] Fix build with FFmpeg 5.0
++
++---
++ src/ffaudio/ffaudio-core.cc | 4 ++--
++ 1 file changed, 2 insertions(+), 2 deletions(-)
++
++diff --git a/src/ffaudio/ffaudio-core.cc b/src/ffaudio/ffaudio-core.cc
++index 16dc63e3a..a2b95fd6c 100644
++--- a/src/ffaudio/ffaudio-core.cc
+++++ b/src/ffaudio/ffaudio-core.cc
++@@ -274,7 +274,7 @@ static AVInputFormat * get_format_by_content (const char * name, VFSFile & file)
++         AVProbeData d = {name, buf, filled};
++         score = target;
++ 
++-        f = av_probe_input_format2 (& d, true, & score);
+++        f = (AVInputFormat *) av_probe_input_format2 (& d, true, & score);
++         if (f)
++             break;
++ 
++@@ -347,7 +347,7 @@ static bool find_codec (AVFormatContext * c, CodecInfo * cinfo)
++ #endif
++         if (stream && stream->codecpar && stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
++         {
++-            AVCodec * codec = avcodec_find_decoder (stream->codecpar->codec_id);
+++            AVCodec * codec = (AVCodec *) avcodec_find_decoder (stream->codecpar->codec_id);
++ 
++             if (codec)
++             {
diff --git a/srcpkgs/audacious-plugins/template b/srcpkgs/audacious-plugins/template
index 88cbc1671fc6a..beebfae59ed44 100644
--- a/srcpkgs/audacious-plugins/template
+++ b/srcpkgs/audacious-plugins/template
@@ -2,7 +2,7 @@
 #Keep in sync with audacious!
 pkgname=audacious-plugins
 version=4.3.1
-revision=1
+revision=2
 build_style=meson
 configure_args="$(vopt_bool gtk3 gtk) $(vopt_bool gtk3)
  $(vopt_bool qt) $(vopt_bool qt qt6)"

From 7220e3a6de47f81b5ed468282c2f478242f1e1c5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 017/115] audacity: revbump for ffmpeg4-4.4.3

---
 srcpkgs/audacity/template | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/audacity/template b/srcpkgs/audacity/template
index 28e9c4a3528f1..4e5125bae03b9 100644
--- a/srcpkgs/audacity/template
+++ b/srcpkgs/audacity/template
@@ -1,7 +1,7 @@
 # Template file for 'audacity'
 pkgname=audacity
 version=2.4.1
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--with-ffmpeg=system --with-libsndfile=system --with-expat=system
  --with-libsoxr=system --with-lame=system --with-lv2=system ac_cv_path_WX_CONFIG=wx-config-gtk3"
@@ -9,7 +9,7 @@ hostmakedepends="pkg-config cmake gettext libtool m4 which"
 makedepends="jack-devel wxWidgets-gtk3-devel gtk+3-devel
  libmad-devel soundtouch-devel libsoxr-devel
  vamp-plugin-sdk-devel lame-devel libid3tag-devel libflac-devel
- ffmpeg-devel twolame-devel serd-devel lv2 lilv-devel suil-devel"
+ ffmpeg4-devel twolame-devel serd-devel lv2 lilv-devel suil-devel"
 depends="desktop-file-utils hicolor-icon-theme"
 short_desc="Graphical cross-platform audio editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
@@ -32,5 +32,4 @@ post_install() {
 	vcopy plug-ins /usr/share/audacity
 
 	rm ${DESTDIR}/usr/share/doc/audacity/LICENSE.txt
-	vlicense LICENSE.txt LICENSE
 }

From a1d335219e7032141f12e322b761cd51f2cc12bb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 018/115] avidemux: revbump for ffmpeg-6.0

---
 srcpkgs/avidemux/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/avidemux/template b/srcpkgs/avidemux/template
index 253a0243e2259..557285982d2b8 100644
--- a/srcpkgs/avidemux/template
+++ b/srcpkgs/avidemux/template
@@ -1,7 +1,7 @@
 # Template file for 'avidemux'
 pkgname=avidemux
 version=2.8.0
-revision=2
+revision=3
 # Can't be compiled for aarch64, arm* or mips*
 archs="x86_64* i686*"
 hostmakedepends="cmake pkg-config qt5-host-tools qt5-devel tar yasm"

From 3d07654aa478475f16f3a17bff894058accaef24 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 019/115] baresip: revbump for ffmpeg-6.0

---
 srcpkgs/baresip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/baresip/template b/srcpkgs/baresip/template
index f1bd1817048b5..b21e22334316e 100644
--- a/srcpkgs/baresip/template
+++ b/srcpkgs/baresip/template
@@ -1,7 +1,7 @@
 # Template file for 'baresip'
 pkgname=baresip
 version=2.10.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config glib-devel"
 makedepends="libgsm-devel libpng-devel openssl-devel libsndfile-devel

From bc079b6d40a2ea521b4ca7ce0769b5619607b120 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 020/115] blender: revbump for ffmpeg-6.0

---
 srcpkgs/blender/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index 55edc84eb1108..3500ad95ad98b 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -9,8 +9,8 @@ configure_args="-DWITH_INSTALL_PORTABLE=OFF -DWITH_PYTHON_INSTALL=OFF
  -DWITH_JACK=ON -DWITH_CODEC_FFMPEG=ON -DWITH_CODEC_SNDFILE=ON -DWITH_OPENMP=ON
  -DWITH_FFTW3=ON -DWITH_MOD_OCEANSIM=ON -DWITH_CYCLES_EMBREE=OFF -DWITH_OPENCOLORIO=ON
  -DWITH_IMAGE_OPENEXR=ON -DWITH_IMAGE_OPENJPEG=ON -DWITH_OPENSUBDIV=ON
- -DWITH_OPENCOLLADA=ON -DWITH_SYSTEM_GLEW=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
- -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_LIBDECOR=ON
+ -DWITH_OPENCOLLADA=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
+ -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_WAYLAND_LIBDECOR=ON
  -DWITH_BUILDINFO=OFF -DPYTHON_VERSION=${py3_ver} -DPYTHON_LIBPATH=/usr/lib
  -DPYTHON_LIBRARY=python${py3_ver}${py3_abiver} -DPYTHON_INCLUDE_DIRS=/${py3_inc}
  -DWITH_SYSTEM_LZO=ON -DWITH_SYSTEM_EIGEN3=ON -DWITH_SYSTEM_FREETYPE=ON"

From 892e49e6831f8f3f80c550bc879cbd0efe4c7cfc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 021/115] cantata: revbump for ffmpeg-6.0

---
 srcpkgs/cantata/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cantata/template b/srcpkgs/cantata/template
index 4b417d80d5c2d..8a90aaa4c07a2 100644
--- a/srcpkgs/cantata/template
+++ b/srcpkgs/cantata/template
@@ -1,7 +1,7 @@
 # Template file for 'cantata'
 pkgname=cantata
 version=2.5.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools qt5-tools"
 makedepends="qt5-devel qt5-tools-devel qt5-svg-devel qt5-xmlpatterns-devel

From 67378ef7d82476721e0e6f0f46aeb4e42df7cd66 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 022/115] ccextractor: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ccextractor/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/ccextractor/template b/srcpkgs/ccextractor/template
index 9abcd82852b27..6eccad5885af9 100644
--- a/srcpkgs/ccextractor/template
+++ b/srcpkgs/ccextractor/template
@@ -1,12 +1,12 @@
 # Template file for 'ccextractor'
 pkgname=ccextractor
 version=0.93
-revision=1
+revision=2
 build_wrksrc="linux"
 build_style=gnu-configure
 configure_args="--enable-ocr --enable-hardsubx"
 hostmakedepends="automake pkg-config"
-makedepends="leptonica-devel tesseract-ocr-devel ffmpeg-devel"
+makedepends="leptonica-devel tesseract-ocr-devel ffmpeg4-devel"
 short_desc="Extract subtitles from video streams"
 maintainer="newbluemoon <blaumolch@mailbox.org>"
 license="GPL-2.0-or-later"

From 555ca48eec3e08a5dc14d70df43ea909feef8c9f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 023/115] chromaprint: revbump for ffmpeg-6.0

---
 srcpkgs/chromaprint/patches/ffmpeg5.patch | 569 ++++++++++++++++++++++
 srcpkgs/chromaprint/template              |   2 +-
 2 files changed, 570 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromaprint/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromaprint/patches/ffmpeg5.patch b/srcpkgs/chromaprint/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..a9fd307a23c8a
--- /dev/null
+++ b/srcpkgs/chromaprint/patches/ffmpeg5.patch
@@ -0,0 +1,569 @@
+From 8ccad6937177b1b92e40ab8f4447ea27bac009a7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= <lalinsky@gmail.com>
+Date: Fri, 4 Nov 2022 21:47:38 +0100
+Subject: [PATCH] Use FFmpeg 5.x (#120)
+
+* Use FFmpeg 5.1.2 for CI builds
+
+* Build on Ubuntu 20.04
+
+* Upgrade code to FFmpeg 5.x APIs
+
+* Only set FFmpeg include dirs if building tools
+
+* No longer needed
+
+* Use ubuntu 20.04
+---
+ .github/workflows/build.yml                   |   6 +-
+ CMakeLists.txt                                |  16 --
+ package/build.sh                              |   4 +-
+ src/audio/ffmpeg_audio_processor.h            |   2 -
+ src/audio/ffmpeg_audio_processor_avresample.h |  72 -------
+ src/audio/ffmpeg_audio_processor_swresample.h |  18 +-
+ src/audio/ffmpeg_audio_reader.h               | 197 +++++++++---------
+ tests/CMakeLists.txt                          |   6 +
+ 8 files changed, 122 insertions(+), 199 deletions(-)
+ delete mode 100644 src/audio/ffmpeg_audio_processor_avresample.h
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index f8d6a32..4da2405 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -84,9 +84,6 @@ find_package(FFmpeg)
+ if(FFMPEG_LIBRARIES)
+ 	cmake_push_check_state(RESET)
+ 	set(CMAKE_REQUIRED_LIBRARIES ${FFMPEG_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -lm)
+-	check_function_exists(av_packet_unref HAVE_AV_PACKET_UNREF)
+-	check_function_exists(av_frame_alloc HAVE_AV_FRAME_ALLOC)
+-	check_function_exists(av_frame_free HAVE_AV_FRAME_FREE)
+ 	cmake_pop_check_state()
+ endif()
+
+@@ -163,14 +160,11 @@ message(STATUS "Using ${FFT_LIB} for FFT calculations")
+ if(NOT AUDIO_PROCESSOR_LIB)
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+ 		set(AUDIO_PROCESSOR_LIB "swresample")
+-	elseif(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(AUDIO_PROCESSOR_LIB "avresample")
+ 	endif()
+ endif()
+
+ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE OFF)
+ 		set(USE_SWRESAMPLE ON)
+ 		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBSWRESAMPLE_LIBRARIES})
+ 		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBSWRESAMPLE_INCLUDE_DIRS})
+@@ -178,16 +172,6 @@ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+ 	endif()
+ 	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+-elseif(AUDIO_PROCESSOR_LIB STREQUAL "avresample")
+-	if(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE ON)
+-		set(USE_SWRESAMPLE OFF)
+-		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBAVRESAMPLE_LIBRARIES})
+-		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBAVRESAMPLE_INCLUDE_DIRS})
+-	else()
+-		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+-	endif()
+-	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+ else()
+ 	message(STATUS "Building without audio conversion support, please install FFmpeg with libswresample")
+ endif()
+diff --git a/package/build.sh b/package/build.sh
+index da631ae..b41d36e 100755
+--- a/package/build.sh
++++ b/package/build.sh
+@@ -7,8 +7,8 @@ set -eux
+
+ BASE_DIR=$(cd $(dirname $0)/.. && pwd)
+
+-FFMPEG_VERSION=4.4.1
+-FFMPEG_BUILD_TAG=v4.4.1-1
++FFMPEG_VERSION=5.1.2
++FFMPEG_BUILD_TAG=v${FFMPEG_VERSION}-1
+
+ TMP_BUILD_DIR=$BASE_DIR/$(mktemp -d build.XXXXXXXX)
+ trap 'rm -rf $TMP_BUILD_DIR' EXIT
+diff --git a/src/audio/ffmpeg_audio_processor.h b/src/audio/ffmpeg_audio_processor.h
+index 7628fc7..39f4f6d 100644
+--- a/src/audio/ffmpeg_audio_processor.h
++++ b/src/audio/ffmpeg_audio_processor.h
+@@ -10,8 +10,6 @@
+
+ #if defined(USE_SWRESAMPLE)
+ #include "audio/ffmpeg_audio_processor_swresample.h"
+-#elif defined(USE_AVRESAMPLE)
+-#include "audio/ffmpeg_audio_processor_avresample.h"
+ #else
+ #error "no audio processing library"
+ #endif
+diff --git a/src/audio/ffmpeg_audio_processor_avresample.h b/src/audio/ffmpeg_audio_processor_avresample.h
+deleted file mode 100644
+index bd85f92..0000000
+--- a/src/audio/ffmpeg_audio_processor_avresample.h
++++ /dev/null
+@@ -1,72 +0,0 @@
+-// Copyright (C) 2016  Lukas Lalinsky
+-// Distributed under the MIT license, see the LICENSE file for details.
+-
+-#ifndef CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-#define CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-
+-extern "C" {
+-#include <libavresample/avresample.h>
+-}
+-
+-namespace chromaprint {
+-
+-class FFmpegAudioProcessor {
+-public:
+-	FFmpegAudioProcessor() {
+-		m_resample_ctx = avresample_alloc_context();
+-	}
+-
+-	~FFmpegAudioProcessor() {
+-		avresample_free(&m_resample_ctx);
+-	}
+-
+-	void SetCompatibleMode() {
+-		av_opt_set_int(m_resample_ctx, "filter_size", 16, 0);
+-		av_opt_set_int(m_resample_ctx, "phase_shift", 8, 0);
+-		av_opt_set_int(m_resample_ctx, "linear_interp", 1, 0);
+-		av_opt_set_double(m_resample_ctx, "cutoff", 0.8, 0);
+-	}
+-
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "in_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_rate", sample_rate, 0);
+-	}
+-
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "out_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_rate, 0);
+-	}
+-
+-	int Init() {
+-		return avresample_open(m_resample_ctx);
+-	}
+-
+-	int Convert(uint8_t **out, int out_count, const uint8_t **in, int in_count) {
+-		return avresample_convert(m_resample_ctx, out, 0, out_count, (uint8_t **) in, 0, in_count);
+-	}
+-
+-	int Flush(uint8_t **out, int out_count) {
+-		return avresample_read(m_resample_ctx, out, out_count);
+-	}
+-
+-private:
+-	AVAudioResampleContext *m_resample_ctx = nullptr;
+-};
+-
+-}; // namespace chromaprint
+-
+-#endif
+diff --git a/src/audio/ffmpeg_audio_processor_swresample.h b/src/audio/ffmpeg_audio_processor_swresample.h
+index b86266b..b1d4bea 100644
+--- a/src/audio/ffmpeg_audio_processor_swresample.h
++++ b/src/audio/ffmpeg_audio_processor_swresample.h
+@@ -28,30 +28,28 @@ public:
+ 		av_opt_set_double(m_swr_ctx, "cutoff", 0.8, 0);
+ 	}
+
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "icl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "ich", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetInputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "in_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "isf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "in_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "isr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "in_sample_rate", sample_rate, 0);
+ 	}
+
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "ocl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "och", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetOutputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "out_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "osf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "out_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "osr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "out_sample_rate", sample_rate, 0);
+ 	}
+
+ 	int Init() {
+diff --git a/src/audio/ffmpeg_audio_reader.h b/src/audio/ffmpeg_audio_reader.h
+index 5550164..1c6b346 100644
+--- a/src/audio/ffmpeg_audio_reader.h
++++ b/src/audio/ffmpeg_audio_reader.h
+@@ -62,7 +62,7 @@ public:
+ 	bool Read(const int16_t **data, size_t *size);
+
+ 	bool IsOpen() const { return m_opened; }
+-	bool IsFinished() const { return m_finished && !m_got_frame; }
++	bool IsFinished() const { return !m_has_more_packets && !m_has_more_frames; }
+
+ 	std::string GetError() const { return m_error; }
+ 	int GetErrorCode() const { return m_error_code; }
+@@ -74,20 +74,19 @@ private:
+ 	uint8_t *m_convert_buffer[1] = { nullptr };
+ 	int m_convert_buffer_nb_samples = 0;
+
+-	AVInputFormat *m_input_fmt = nullptr;
++	const AVInputFormat *m_input_fmt = nullptr;
+ 	AVDictionary *m_input_opts = nullptr;
+
+ 	AVFormatContext *m_format_ctx = nullptr;
+ 	AVCodecContext *m_codec_ctx = nullptr;
+-	AVFrame *m_frame = nullptr;
+ 	int m_stream_index = -1;
+ 	std::string m_error;
+ 	int m_error_code = 0;
+-	bool m_finished = false;
+ 	bool m_opened = false;
+-	int m_got_frame = 0;
+-	AVPacket m_packet;
+-	AVPacket m_packet0;
++	bool m_has_more_packets = true;
++	bool m_has_more_frames = true;
++	AVPacket *m_packet = nullptr;
++	AVFrame *m_frame = nullptr;
+
+ 	int m_output_sample_rate = 0;
+ 	int m_output_channels = 0;
+@@ -98,19 +97,12 @@ private:
+
+ inline FFmpegAudioReader::FFmpegAudioReader() {
+ 	av_log_set_level(AV_LOG_QUIET);
+-
+-	av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
+ }
+
+ inline FFmpegAudioReader::~FFmpegAudioReader() {
+ 	Close();
+ 	av_dict_free(&m_input_opts);
+ 	av_freep(&m_convert_buffer[0]);
+-	av_packet_unref(&m_packet0);
+ }
+
+ inline bool FFmpegAudioReader::SetInputFormat(const char *name) {
+@@ -135,11 +127,10 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ 	Close();
+
+-    av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
++	m_packet = av_packet_alloc();
++	if (!m_packet) {
++		return false;
++	}
+
+ 	ret = avformat_open_input(&m_format_ctx, file_name.c_str(), m_input_fmt, &m_input_opts);
+ 	if (ret < 0) {
+@@ -153,26 +144,31 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		return false;
+ 	}
+
+-	AVCodec *codec;
++	const AVCodec *codec;
+ 	ret = av_find_best_stream(m_format_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &codec, 0);
+ 	if (ret < 0) {
+ 		SetError("Could not find any audio stream in the file", ret);
+ 		return false;
+ 	}
+ 	m_stream_index = ret;
++	auto stream = m_format_ctx->streams[m_stream_index];
+
+-	m_codec_ctx = m_format_ctx->streams[m_stream_index]->codec;
++	m_codec_ctx = avcodec_alloc_context3(codec);
+ 	m_codec_ctx->request_sample_fmt = AV_SAMPLE_FMT_S16;
+
++	ret = avcodec_parameters_to_context(m_codec_ctx, stream->codecpar);
++	if (ret < 0) {
++		SetError("Could not copy the stream parameters", ret);
++		return false;
++	}
++
+ 	ret = avcodec_open2(m_codec_ctx, codec, nullptr);
+ 	if (ret < 0) {
+ 		SetError("Could not open the codec", ret);
+ 		return false;
+ 	}
+
+-	if (!m_codec_ctx->channel_layout) {
+-		m_codec_ctx->channel_layout = av_get_default_channel_layout(m_codec_ctx->channels);
+-	}
++	av_dump_format(m_format_ctx, 0, "foo", 0);
+
+ 	m_frame = av_frame_alloc();
+ 	if (!m_frame) {
+@@ -183,19 +179,23 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		m_output_sample_rate = m_codec_ctx->sample_rate;
+ 	}
+
+-	if (!m_output_channels) {
+-		m_output_channels = m_codec_ctx->channels;
++	AVChannelLayout output_channel_layout;
++	if (m_output_channels) {
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
++	} else {
++		m_output_channels = m_codec_ctx->ch_layout.nb_channels;
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
+ 	}
+
+-	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
++	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->ch_layout.nb_channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
+ 		m_converter.reset(new FFmpegAudioProcessor());
+ 		m_converter->SetCompatibleMode();
+ 		m_converter->SetInputSampleFormat(m_codec_ctx->sample_fmt);
+ 		m_converter->SetInputSampleRate(m_codec_ctx->sample_rate);
+-		m_converter->SetInputChannelLayout(m_codec_ctx->channel_layout);
++		m_converter->SetInputChannelLayout(&(m_codec_ctx->ch_layout));
+ 		m_converter->SetOutputSampleFormat(AV_SAMPLE_FMT_S16);
+ 		m_converter->SetOutputSampleRate(m_output_sample_rate);
+-		m_converter->SetOutputChannelLayout(av_get_default_channel_layout(m_output_channels));
++		m_converter->SetOutputChannelLayout(&output_channel_layout);
+ 		auto ret = m_converter->Init();
+ 		if (ret != 0) {
+ 			SetError("Could not create an audio converter instance", ret);
+@@ -203,10 +203,11 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		}
+ 	}
+
++	av_channel_layout_uninit(&output_channel_layout);
++
+ 	m_opened = true;
+-	m_finished = false;
+-	m_got_frame = 0;
+-	m_nb_packets = 0;
++	m_has_more_packets = true;
++	m_has_more_frames = true;
+ 	m_decode_error = 0;
+
+ 	return true;
+@@ -214,6 +215,7 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ inline void FFmpegAudioReader::Close() {
+ 	av_frame_free(&m_frame);
++	av_packet_free(&m_packet);
+
+ 	m_stream_index = -1;
+
+@@ -252,91 +254,98 @@ inline bool FFmpegAudioReader::Read(const int16_t **data, size_t *size) {
+ 		return false;
+ 	}
+
++	*data = nullptr;
++	*size = 0;
++
+ 	int ret;
++	bool needs_packet = false;
+ 	while (true) {
+-		while (m_packet.size <= 0) {
+-			av_packet_unref(&m_packet0);
+-			av_init_packet(&m_packet);
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			ret = av_read_frame(m_format_ctx, &m_packet);
++		while (needs_packet && m_packet->size == 0) {
++			ret = av_read_frame(m_format_ctx, m_packet);
+ 			if (ret < 0) {
+ 				if (ret == AVERROR_EOF) {
+-					m_finished = true;
++					needs_packet = false;
++					m_has_more_packets = false;
+ 					break;
+-				} else {
++				}
++				SetError("Error reading from the audio source", ret);
++				return false;
++			}
++			if (m_packet->stream_index == m_stream_index) {
++				needs_packet = false;
++			} else {
++				av_packet_unref(m_packet);
++			}
++		}
++
++		if (m_packet->size != 0) {
++			ret = avcodec_send_packet(m_codec_ctx, m_packet);
++			if (ret < 0) {
++				if (ret != AVERROR(EAGAIN)) {
+ 					SetError("Error reading from the audio source", ret);
+ 					return false;
+ 				}
+-			}
+-			m_packet0 = m_packet;
+-			if (m_packet.stream_index != m_stream_index) {
+-				m_packet.data = nullptr;
+-				m_packet.size = 0;
+ 			} else {
+-				m_nb_packets++;
++				av_packet_unref(m_packet);
+ 			}
+ 		}
+
+-		ret = avcodec_decode_audio4(m_codec_ctx, m_frame, &m_got_frame, &m_packet);
++		ret = avcodec_receive_frame(m_codec_ctx, m_frame);
+ 		if (ret < 0) {
+-			if (m_decode_error) {
+-				SetError("Error decoding audio frame", m_decode_error);
+-				return false;
++			if (ret == AVERROR_EOF) {
++				m_has_more_frames = false;
++			} else if (ret == AVERROR(EAGAIN)) {
++				if (m_has_more_packets) {
++					needs_packet = true;
++					continue;
++				} else {
++					m_has_more_frames = false;
++				}
+ 			}
+-			m_decode_error = ret;
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			continue;
++			SetError("Error decoding the audio source", ret);
++			return false;
+ 		}
+
+-		break;
+-	}
+-
+-	m_decode_error = 0;
+-
+-	const int decoded = std::min(ret, m_packet.size);
+-	m_packet.data += decoded;
+-	m_packet.size -= decoded;
+-
+-	if (m_got_frame) {
+-		if (m_converter) {
+-			if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
+-				int linsize;
+-				av_freep(&m_convert_buffer[0]);
+-				m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
+-				ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
+-				if (ret < 0) {
+-					SetError("Couldn't allocate audio converter buffer", ret);
++		if (m_frame->nb_samples > 0) {
++			if (m_converter) {
++				if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
++					int linsize;
++					av_freep(&m_convert_buffer[0]);
++					m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
++					ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->ch_layout.nb_channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
++					if (ret < 0) {
++						SetError("Couldn't allocate audio converter buffer", ret);
++						return false;
++					}
++				}
++				auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
++				if (nb_samples < 0) {
++					SetError("Couldn't convert audio", ret);
+ 					return false;
+ 				}
+-			}
+-			auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			}
+-			*data = (const int16_t *) m_convert_buffer[0];
+-			*size = nb_samples;
+-		} else {
+-			*data = (const int16_t *) m_frame->data[0];
+-			*size = m_frame->nb_samples;
+-		}
+-	} else {
+-		if (m_finished && m_converter) {
+-			auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			} else if (nb_samples > 0) {
+-				m_got_frame = 1;
+ 				*data = (const int16_t *) m_convert_buffer[0];
+ 				*size = nb_samples;
++			} else {
++				*data = (const int16_t *) m_frame->data[0];
++				*size = m_frame->nb_samples;
++			}
++		} else {
++			if (m_converter) {
++				if (IsFinished()) {
++					auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
++					if (nb_samples < 0) {
++						SetError("Couldn't convert audio", ret);
++						return false;
++					} else if (nb_samples > 0) {
++						*data = (const int16_t *) m_convert_buffer[0];
++						*size = nb_samples;
++					}
++				}
+ 			}
+ 		}
+-	}
+
+-	return true;
++		return true;
++	}
+ }
+
+ inline void FFmpegAudioReader::SetError(const char *message, int errnum) {
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index a2b517b..123e643 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -38,6 +38,12 @@ set(SRCS
+
+ if(BUILD_TOOLS)
+ 	set(SRCS ${SRCS} ../src/audio/ffmpeg_audio_reader_test.cpp)
++    include_directories(
++        ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}
++        ${AUDIO_PROCESSOR_INCLUDE_DIRS}
++    )
+ 	link_libraries(fpcalc_libs)
+ endif()
+
+-- 
+2.38.1
+
+
diff --git a/srcpkgs/chromaprint/template b/srcpkgs/chromaprint/template
index 7ef7838949f3a..1f7bbc70a22c8 100644
--- a/srcpkgs/chromaprint/template
+++ b/srcpkgs/chromaprint/template
@@ -1,7 +1,7 @@
 # Template file for 'chromaprint'
 pkgname=chromaprint
 version=1.5.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DBUILD_TOOLS=ON"
 make_check_target="check"

From e3231be9c82bf37458b84478b2623224fdbfc296 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 024/115] chromium: revbump for ffmpeg-6.0

---
 .../patches/chromium-93-ffmpeg-4.4.patch      | 36 --------------
 srcpkgs/chromium/patches/ffmpeg5.patch        | 47 +++++++++++++++++++
 srcpkgs/chromium/template                     |  2 +-
 3 files changed, 48 insertions(+), 37 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch
 create mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch b/srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch
deleted file mode 100644
index f0ec736f98bc7..0000000000000
--- a/srcpkgs/chromium/patches/chromium-93-ffmpeg-4.4.patch
+++ /dev/null
@@ -1,36 +0,0 @@
-diff --git a/media/filters/ffmpeg_demuxer.cc b/media/filters/ffmpeg_demuxer.cc
-index ac4713b07268..492a9a37d096 100644
---- a/media/filters/ffmpeg_demuxer.cc
-+++ b/media/filters/ffmpeg_demuxer.cc
-@@ -427,11 +427,11 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
-   scoped_refptr<DecoderBuffer> buffer;
- 
-   if (type() == DemuxerStream::TEXT) {
--    size_t id_size = 0;
-+    int id_size = 0;
-     uint8_t* id_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
- 
--    size_t settings_size = 0;
-+    int settings_size = 0;
-     uint8_t* settings_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
- 
-@@ -443,7 +443,7 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
-     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
-                                      side_data.data(), side_data.size());
-   } else {
--    size_t side_data_size = 0;
-+    int side_data_size = 0;
-     uint8_t* side_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
- 
-@@ -504,7 +504,7 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
-                                        packet->size - data_offset);
-     }
- 
--    size_t skip_samples_size = 0;
-+    int skip_samples_size = 0;
-     const uint32_t* skip_samples_ptr =
-         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
-             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..24e2da38e34ca
--- /dev/null
+++ b/srcpkgs/chromium/patches/ffmpeg5.patch
@@ -0,0 +1,47 @@
+--- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
++++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
+@@ -92,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+-  if (stream->start_time != kNoFFmpegTimestamp)
++  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -1597,7 +1585,7 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+@@ -1618,7 +1606,7 @@
+     if (stream->type() != DemuxerStream::VIDEO)
+       continue;
+ 
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+ 
+     if (!stream->IsEnabled())
diff --git a/srcpkgs/chromium/template b/srcpkgs/chromium/template
index 7fd0f94fa7b5e..cd15619338313 100644
--- a/srcpkgs/chromium/template
+++ b/srcpkgs/chromium/template
@@ -2,7 +2,7 @@
 pkgname=chromium
 # See https://chromiumdash.appspot.com/releases?platform=Linux for the latest version
 version=116.0.5845.96
-revision=1
+revision=2
 archs="i686* x86_64* aarch64* armv7l*"
 hostmakedepends="
  $(vopt_if clang "clang lld llvm15")

From cbbd2568eabaed7d5bf70b714420a823fb27896b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 025/115] cmus: revbump for ffmpeg-6.0

---
 srcpkgs/cmus/patches/ffmpeg6.patch | 12 ++++++++++++
 srcpkgs/cmus/template              |  2 +-
 2 files changed, 13 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/cmus/patches/ffmpeg6.patch

diff --git a/srcpkgs/cmus/patches/ffmpeg6.patch b/srcpkgs/cmus/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..ffa95ab811101
--- /dev/null
+++ b/srcpkgs/cmus/patches/ffmpeg6.patch
@@ -0,0 +1,12 @@
+--- a/ip/ffmpeg.c
++++ b/ip/ffmpeg.c
+@@ -202,9 +202,6 @@ static int ffmpeg_open(struct input_plugin_data *ip_data)
+ 			break;
+ 		}
+ 
+-		if (codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+-			cc->flags |= AV_CODEC_FLAG_TRUNCATED;
+-
+ 		if (avcodec_open2(cc, codec, NULL) < 0) {
+ 			d_print("could not open codec: %d, %s\n", cc->codec_id, avcodec_get_name(cc->codec_id));
+ 			err = -IP_ERROR_UNSUPPORTED_FILE_TYPE;
diff --git a/srcpkgs/cmus/template b/srcpkgs/cmus/template
index 0fdcec461c217..6c07e25e6d727 100644
--- a/srcpkgs/cmus/template
+++ b/srcpkgs/cmus/template
@@ -1,7 +1,7 @@
 # Template file for 'cmus'
 pkgname=cmus
 version=2.10.0
-revision=1
+revision=2
 build_style=configure
 configure_args="prefix=/usr LD=$CC"
 hostmakedepends="pkg-config"

From 8bbe4f277cab79416ea6faaf6b8d2685382e8715 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 026/115] cyanrip: revbump for ffmpeg-6.0

---
 srcpkgs/cyanrip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cyanrip/template b/srcpkgs/cyanrip/template
index 9796e3461601a..5db30e020d17e 100644
--- a/srcpkgs/cyanrip/template
+++ b/srcpkgs/cyanrip/template
@@ -1,7 +1,7 @@
 # Template file for 'cyanrip'
 pkgname=cyanrip
 version=0.9.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config"
 makedepends="ffmpeg-devel libcdio-devel libcdio-paranoia-devel libcurl-devel libmusicbrainz5-devel"

From 573aede79658a43dc36618f6150274b48ed4d14b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 027/115] deadbeef: revbump for ffmpeg4-4.4.3

---
 srcpkgs/deadbeef/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/deadbeef/template b/srcpkgs/deadbeef/template
index b664bb1b9bd9f..165b3c7b9cad8 100644
--- a/srcpkgs/deadbeef/template
+++ b/srcpkgs/deadbeef/template
@@ -1,14 +1,14 @@
 # Template file for 'deadbeef'
 pkgname=deadbeef
 version=1.8.8
-revision=1
+revision=2
 create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-oss --disable-lfm --disable-notify --disable-gtk2"
 hostmakedepends="automake libtool gettext gettext-devel intltool pkg-config
  yasm clang glib-devel"
 makedepends="
- alsa-lib-devel dbus-devel faad2-devel ffmpeg-devel gtk+3-devel imlib2-devel
+ alsa-lib-devel dbus-devel faad2-devel ffmpeg4-devel gtk+3-devel imlib2-devel
  jansson-devel libcddb-devel libcdio-devel libcurl-devel libflac-devel
  libmad-devel libpng-devel libsamplerate-devel libsndfile-devel libvorbis-devel
  libzip-devel mpg123-devel opusfile-devel pulseaudio-devel wavpack-devel"

From f8e6c696042832b906058d5c35c1a4db7e891328 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 028/115] dolphin-emu: revbump for ffmpeg-6.0

---
 srcpkgs/dolphin-emu/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/dolphin-emu/template b/srcpkgs/dolphin-emu/template
index b4c8b64368a4b..070993aac31d2 100644
--- a/srcpkgs/dolphin-emu/template
+++ b/srcpkgs/dolphin-emu/template
@@ -1,7 +1,7 @@
 # Template file for 'dolphin-emu'
 pkgname=dolphin-emu
 version=5.0.19368
-revision=1
+revision=2
 _dolphin_commit=dadbeb4bae7e7fa23af2b46e0add4143094dc107
 _mgba_commit=44e074a15e9651481f7f652ac006a7c9d58cbeb9
 _googletest_commit=be03d00f5f0cc3a997d1a368bee8a1fe93651f48

From 679c750e48bb83e81ca5dbcdf367992a4424a728 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 029/115] droidcam-obs-plugin: revbump for ffmpeg-6.0

---
 srcpkgs/droidcam-obs-plugin/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam-obs-plugin/template b/srcpkgs/droidcam-obs-plugin/template
index fc9c9bf6b9d54..fb0480754df4d 100644
--- a/srcpkgs/droidcam-obs-plugin/template
+++ b/srcpkgs/droidcam-obs-plugin/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam-obs-plugin'
 pkgname=droidcam-obs-plugin
 version=2.0.1
-revision=1
+revision=2
 build_style=gnu-makefile
 make_use_env=yes
 make_build_args="ALLOW_STATIC=no"

From 001d34938d3c6cad1062df56bc23b032cbab72ae Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 030/115] droidcam: revbump for ffmpeg-6.0

---
 srcpkgs/droidcam/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam/template b/srcpkgs/droidcam/template
index 1c3f1b8b1fc67..32a9220b79a4d 100644
--- a/srcpkgs/droidcam/template
+++ b/srcpkgs/droidcam/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam'
 pkgname=droidcam
 version=1.8.2
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="USBMUXD=-lusbmuxd-2.0 JPEG=-lturbojpeg"
 hostmakedepends="pkg-config"

From 75fc6737331a58beff06d98790d405cac04bc56f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 031/115] ffmpegthumbnailer: revbump for ffmpeg-6.0

---
 .../ffmpegthumbnailer/patches/ffmpeg6.patch   | 202 ++++++++++++++++++
 srcpkgs/ffmpegthumbnailer/template            |   6 +-
 2 files changed, 205 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch

diff --git a/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..363ff35a28419
--- /dev/null
+++ b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
@@ -0,0 +1,202 @@
+--- a/libffmpegthumbnailer/moviedecoder.cpp	2017-11-21 14:06:57.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.cpp	2023-05-05 13:14:47.946560668 -0400
+@@ -41,11 +41,6 @@
+ namespace ffmpegthumbnailer
+ {
+ 
+-struct SilenceLogLevel
+-{
+-    SilenceLogLevel() { av_log_set_level(AV_LOG_QUIET); }
+-};
+-
+ MovieDecoder::MovieDecoder(AVFormatContext* pavContext)
+ : m_VideoStream(-1)
+ , m_pFormatContext(pavContext)
+@@ -70,8 +65,6 @@
+ 
+ void MovieDecoder::initialize(const string& filename, bool preferEmbeddedMetadata)
+ {
+-    av_register_all();
+-    avcodec_register_all();
+     avformat_network_init();
+ 
+     string inputFile = filename == "-" ? "pipe:" : filename;
+@@ -97,8 +90,7 @@
+ {
+     if (m_pVideoCodecContext)
+     {
+-        avcodec_close(m_pVideoCodecContext);
+-        m_pVideoCodecContext = nullptr;
++        avcodec_free_context(&m_pVideoCodecContext);
+     }
+ 
+     if ((!m_FormatContextWasGiven) && m_pFormatContext)
+@@ -152,10 +144,10 @@
+     for (unsigned int i = 0; i < m_pFormatContext->nb_streams; ++i)
+     {
+         AVStream *stream = m_pFormatContext->streams[i];
+-        auto ctx = m_pFormatContext->streams[i]->codec;
+-        if (ctx->codec_type == AVMEDIA_TYPE_VIDEO)
++        auto par = m_pFormatContext->streams[i]->codecpar;
++        if (par->codec_type == AVMEDIA_TYPE_VIDEO)
+         {
+-            if (!preferEmbeddedMetadata || !isStillImageCodec(ctx->codec_id))
++            if (!preferEmbeddedMetadata || !isStillImageCodec(par->codec_id))
+             {
+                 videoStreams.push_back(i);
+                 continue;
+@@ -203,8 +195,7 @@
+     }
+ 
+     m_pVideoStream = m_pFormatContext->streams[m_VideoStream];
+-    m_pVideoCodecContext = m_pVideoStream->codec;
+-    m_pVideoCodec = avcodec_find_decoder(m_pVideoCodecContext->codec_id);
++    m_pVideoCodec = avcodec_find_decoder(m_pVideoStream->codecpar->codec_id);
+ 
+     if (m_pVideoCodec == nullptr)
+     {
+@@ -214,6 +205,20 @@
+         throw logic_error("Video Codec not found");
+     }
+ 
++    m_pVideoCodecContext = avcodec_alloc_context3(m_pVideoCodec);
++
++    if (m_pVideoCodecContext == nullptr)
++    {
++        destroy();
++        throw logic_error("Could not allocate video codec context");
++    }
++
++    if (avcodec_parameters_to_context(m_pVideoCodecContext, m_pVideoStream->codecpar) < 0)
++    {
++        destroy();
++        throw logic_error("Could not configure video codec context");
++    }
++
+     m_pVideoCodecContext->workaround_bugs = 1;
+ 
+     if (avcodec_open2(m_pVideoCodecContext, m_pVideoCodec, nullptr) < 0)
+@@ -386,13 +391,6 @@
+ 
+ void MovieDecoder::initializeFilterGraph(const AVRational& timeBase, const std::string& size, bool maintainAspectRatio)
+ {
+-    static const AVPixelFormat pixelFormats[] = { AV_PIX_FMT_RGB24, AV_PIX_FMT_NONE };
+-
+-    auto del = [] (AVBufferSinkParams* p) { av_freep(p); };
+-    std::unique_ptr<AVBufferSinkParams, decltype(del)> buffersinkParams(av_buffersink_params_alloc(), del);
+-
+-    avfilter_register_all();
+-
+     m_pFilterGraph = avfilter_graph_alloc();
+     assert(m_pFilterGraph);
+ 
+@@ -404,10 +402,8 @@
+ 
+     checkRc(avfilter_graph_create_filter(&m_pFilterSource, avfilter_get_by_name("buffer"), "thumb_buffer", ss.str().c_str(), nullptr, m_pFilterGraph),
+             "Failed to create filter source");
+-    buffersinkParams->pixel_fmts = pixelFormats;
+-    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, buffersinkParams.get(), m_pFilterGraph),
++    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, nullptr, m_pFilterGraph),
+             "Failed to create filter sink");
+-    buffersinkParams.release();
+ 
+     AVFilterContext* yadifFilter = nullptr;
+     if (m_pFrame->interlaced_frame != 0)
+@@ -500,15 +496,15 @@
+     }
+ 
+     checkRc(av_seek_frame(m_pFormatContext, -1, timestamp, 0), "Seeking in video failed");
+-    avcodec_flush_buffers(m_pFormatContext->streams[m_VideoStream]->codec);
++    avcodec_flush_buffers(m_pVideoCodecContext);
+ 
+     int keyFrameAttempts = 0;
+-    bool gotFrame = 0;
++    bool gotFrame;
+ 
+     do
+     {
+         int count = 0;
+-        gotFrame = 0;
++        gotFrame = false;
+ 
+         while (!gotFrame && count < 20)
+         {
+@@ -552,17 +548,33 @@
+         return false;
+     }
+ 
+-    av_frame_unref(m_pFrame);
+-
+-    int frameFinished;
++    int rc = avcodec_send_packet(m_pVideoCodecContext, m_pPacket);
++    if(rc == AVERROR(EAGAIN))
++    {
++        rc = 0;
++    }
+ 
+-    int bytesDecoded = avcodec_decode_video2(m_pVideoCodecContext, m_pFrame, &frameFinished, m_pPacket);
+-    if (bytesDecoded < 0)
++    if(rc == AVERROR_EOF)
++    {
++        return false;
++    }
++    else if(rc < 0)
+     {
+-        throw logic_error("Failed to decode video frame: bytesDecoded < 0");
++        throw logic_error("Failed to decode video frame: avcodec_send_packet() < 0");
+     }
+ 
+-    return frameFinished > 0;
++    rc = avcodec_receive_frame(m_pVideoCodecContext, m_pFrame);
++    switch(rc)
++    {
++        case 0:
++            return true;
++
++        case AVERROR(EAGAIN):
++            return false;
++
++        default:
++            throw logic_error("Failed to decode video frame: avcodec_receive_frame() < 0");
++    }
+ }
+ 
+ bool MovieDecoder::getVideoPacket()
+@@ -570,8 +582,6 @@
+     bool framesAvailable = true;
+     bool frameDecoded = false;
+ 
+-    int attempts = 0;
+-
+     if (m_pPacket)
+     {
+         av_packet_unref(m_pPacket);
+@@ -580,6 +590,7 @@
+ 
+     m_pPacket = new AVPacket();
+ 
++
+     while (framesAvailable && !frameDecoded)
+     {
+         framesAvailable = av_read_frame(m_pFormatContext, m_pPacket) >= 0;
+@@ -644,7 +655,7 @@
+ 
+ int32_t MovieDecoder::getStreamRotation()
+ {
+-    int32_t* matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
++    auto matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
+     if (matrix)
+     {
+         auto angle = lround(av_display_rotation_get(matrix));
+
+--- a/libffmpegthumbnailer/moviedecoder.h	2017-11-12 04:23:38.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.h	2023-05-05 13:26:07.095529911 -0400
+@@ -78,7 +78,7 @@
+     int                     m_VideoStream;
+     AVFormatContext*        m_pFormatContext;
+     AVCodecContext*         m_pVideoCodecContext;
+-    AVCodec*                m_pVideoCodec;
++    const AVCodec*          m_pVideoCodec;
+     AVFilterGraph*          m_pFilterGraph;
+     AVFilterContext*        m_pFilterSource;
+     AVFilterContext*        m_pFilterSink;
diff --git a/srcpkgs/ffmpegthumbnailer/template b/srcpkgs/ffmpegthumbnailer/template
index 039eea7622b39..35d546018d12a 100644
--- a/srcpkgs/ffmpegthumbnailer/template
+++ b/srcpkgs/ffmpegthumbnailer/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbnailer'
 pkgname=ffmpegthumbnailer
 version=2.2.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libpng-devel libjpeg-turbo-devel ffmpeg-devel"
@@ -9,8 +9,8 @@ depends="ffmpeg"
 short_desc="Lightweight video thumbnailer"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
-homepage="https://github.com/dirkvdb/${pkgname}"
-distfiles="${homepage}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
+homepage="https://github.com/dirkvdb"
+distfiles="${homepage}/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
 checksum=1cb24059c38223f657b300c84dd80491b7040d4b69471c4fea69be862bc99b5b
 
 post_install() {

From d598c6a6987c325929753e2a69cefdd4459659e9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 032/115] ffmpegthumbs: revbump for ffmpeg-6.0

---
 srcpkgs/ffmpegthumbs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ffmpegthumbs/template b/srcpkgs/ffmpegthumbs/template
index 5f0b9414dadaf..11b88193528f4 100644
--- a/srcpkgs/ffmpegthumbs/template
+++ b/srcpkgs/ffmpegthumbs/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbs'
 pkgname=ffmpegthumbs
 version=22.12.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules kcoreaddons kconfig-devel
  pkg-config qt5-host-tools qt5-qmake gettext"

From 5b81b42ad1c870bb7a26f59346d9be2715b24bea Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 033/115] ffms2: revbump for ffmpeg-6.0

---
 srcpkgs/ffms2/patches/ffmpeg5.patch | 424 ++++++++++++++++++++++++++++
 srcpkgs/ffms2/template              |   2 +-
 2 files changed, 425 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ffms2/patches/ffmpeg5.patch

diff --git a/srcpkgs/ffms2/patches/ffmpeg5.patch b/srcpkgs/ffms2/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..1479fabcafcb4
--- /dev/null
+++ b/srcpkgs/ffms2/patches/ffmpeg5.patch
@@ -0,0 +1,424 @@
+From 45673149e9a2f5586855ad472e3059084eaa36b1 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:41:21 +0100
+Subject: [PATCH] Use auto for AVCodec
+
+The geniuses over at FFmpeg decided to constify this API, so old
+versions of the library will return AVCodec *, while new versions
+of the libary will return const AVCodec *, which, in C++, are not
+OK to convert between.
+
+Rather than use some macro hell in ffmscompat.h, we can work around
+this by using auto.
+
+Gross.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 2 +-
+ src/core/indexing.cpp    | 6 +++---
+ src/core/videosource.cpp | 2 +-
+ 3 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index e4ce97c..ac09666 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -469,7 +469,7 @@ void FFMS_AudioSource::OpenFile() {
+ 
+     LAVFOpenFile(SourceFile.c_str(), FormatContext, TrackNumber);
+ 
+-    AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
++    auto *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
+     if (Codec == nullptr)
+         throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+             "Audio codec not found");
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index e547c5a..59fb4e8 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -384,7 +384,7 @@ FFMS_TrackType FFMS_Indexer::GetTrackType(int Track) {
+ }
+ 
+ const char *FFMS_Indexer::GetTrackCodec(int Track) {
+-    AVCodec *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
++    auto *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
+     return codec ? codec->name : nullptr;
+ }
+ 
+@@ -402,7 +402,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             UseDTS);
+ 
+         if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            AVCodec *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (!VideoCodec) {
+                 FormatContext->streams[i]->discard = AVDISCARD_ALL;
+                 IndexMask.erase(i);
+@@ -433,7 +433,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 IndexMask.insert(i);
+             }
+         } else if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+-            AVCodec *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (AudioCodec == nullptr)
+                 throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_UNSUPPORTED,
+                     "Audio codec not found");
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index b889970..8956c22 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -171,7 +171,7 @@ FFMS_VideoSource::FFMS_VideoSource(const char *SourceFile, FFMS_Index &Index, in
+ 
+         LAVFOpenFile(SourceFile, FormatContext, VideoTrack);
+ 
+-        AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
++        auto *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
+         if (Codec == nullptr)
+             throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+                 "Video codec not found");
+-- 
+2.40.0
+
+From 96cbf38ea9381829a1314f432a2c60495dcefaad Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:12:41 +0100
+Subject: [PATCH] all: Update AVPacket API usage
+
+AVPackets must all be on the heap now, since it is no longer
+part of the libav* ABI.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 16 ++++++----
+ src/core/indexing.cpp    | 63 ++++++++++++++++++++++------------------
+ src/core/indexing.h      |  4 +--
+ src/core/utils.cpp       |  6 ----
+ src/core/utils.h         |  1 -
+ src/core/videosource.cpp | 30 ++++++++++---------
+ 6 files changed, 64 insertions(+), 56 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index 37cf9ae..e4ce97c 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -285,10 +285,15 @@ FFMS_AudioSource::AudioBlock *FFMS_AudioSource::CacheBlock(CacheIterator &pos) {
+ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     CurrentFrame = &Frames[PacketNumber];
+ 
+-    AVPacket Packet;
+-    if (!ReadPacket(&Packet))
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++    if (!ReadPacket(Packet)) {
++        av_packet_free(&Packet);
+         throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_UNKNOWN,
+             "ReadPacket unexpectedly failed to read a packet");
++    }
+ 
+     // ReadPacket may have changed the packet number
+     CurrentFrame = &Frames[PacketNumber];
+@@ -297,8 +302,9 @@ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     int NumberOfSamples = 0;
+     AudioBlock *CachedBlock = nullptr;
+     
+-    int Ret = avcodec_send_packet(CodecContext, &Packet);
+-    av_packet_unref(&Packet);
++    int Ret = avcodec_send_packet(CodecContext, Packet);
++    av_packet_unref(Packet);
++    av_packet_free(&Packet);
+ 
+     av_frame_unref(DecodeFrame);
+     Ret = avcodec_receive_frame(CodecContext, DecodeFrame);
+@@ -513,8 +519,6 @@ void FFMS_AudioSource::Seek() {
+ }
+ 
+ bool FFMS_AudioSource::ReadPacket(AVPacket *Packet) {
+-    InitNullPacket(*Packet);
+-
+     while (av_read_frame(FormatContext, Packet) >= 0) {
+         if (Packet->stream_index == TrackNumber) {
+             // Required because not all audio packets, especially in ogg, have a pts. Use the previous valid packet's pts instead.
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index 23fb95b..e547c5a 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -320,7 +320,7 @@ void FFMS_Indexer::CheckAudioProperties(int Track, AVCodecContext *Context) {
+     }
+ }
+ 
+-void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict,
++void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict,
+                                     int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct) {
+     if (VideoContext.Parser) {
+         uint8_t *OB;
+@@ -330,8 +330,8 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+         av_parser_parse2(VideoContext.Parser,
+             VideoContext.CodecContext,
+             &OB, &OBSize,
+-            pkt.data, pkt.size,
+-            pkt.pts, pkt.dts, pkt.pos);
++            pkt->data, pkt->size,
++            pkt->pts, pkt->dts, pkt->pos);
+ 
+         // H.264 (PAFF) and HEVC may have one field per packet, so we need to track
+         // when we have a full or half frame available, and mark one of them as
+@@ -351,15 +351,15 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+ 
+         *RepeatPict = VideoContext.Parser->repeat_pict;
+         *FrameType = VideoContext.Parser->pict_type;
+-        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt.flags & AV_PKT_FLAG_DISCARD));
++        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt->flags & AV_PKT_FLAG_DISCARD));
+     } else {
+-        *Invisible = !!(pkt.flags & AV_PKT_FLAG_DISCARD);
++        *Invisible = !!(pkt->flags & AV_PKT_FLAG_DISCARD);
+     }
+ 
+     if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP8)
+-        ParseVP8(pkt.data[0], Invisible, FrameType);
++        ParseVP8(pkt->data[0], Invisible, FrameType);
+     else if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP9)
+-        ParseVP9(pkt.data[0], Invisible, FrameType);
++        ParseVP9(pkt->data[0], Invisible, FrameType);
+ }
+ 
+ void FFMS_Indexer::Free() {
+@@ -458,32 +458,36 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+         }
+     }
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
+     std::vector<int64_t> LastValidTS(FormatContext->nb_streams, AV_NOPTS_VALUE);
+ 
+     int64_t filesize = avio_size(FormatContext->pb);
+     enum AVPictureStructure LastPicStruct = AV_PICTURE_STRUCTURE_UNKNOWN;
+-    while (av_read_frame(FormatContext, &Packet) >= 0) {
++    while (av_read_frame(FormatContext, Packet) >= 0) {
+         // Update progress
+         // FormatContext->pb can apparently be NULL when opening images.
+         if (IC && FormatContext->pb) {
+-            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate))
++            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate)) {
++                av_packet_free(&Packet);
+                 throw FFMS_Exception(FFMS_ERROR_CANCELLED, FFMS_ERROR_USER,
+                     "Cancelled by user");
++            }
+         }
+-        if (!IndexMask.count(Packet.stream_index)) {
+-            av_packet_unref(&Packet);
++        if (!IndexMask.count(Packet->stream_index)) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+-        int Track = Packet.stream_index;
++        int Track = Packet->stream_index;
+         FFMS_Track &TrackInfo = (*TrackIndices)[Track];
+-        bool KeyFrame = !!(Packet.flags & AV_PKT_FLAG_KEY);
++        bool KeyFrame = !!(Packet->flags & AV_PKT_FLAG_KEY);
+         ReadTS(Packet, LastValidTS[Track], (*TrackIndices)[Track].UseDTS);
+ 
+         if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            int64_t PTS = TrackInfo.UseDTS ? Packet.dts : Packet.pts;
++            int64_t PTS = TrackInfo.UseDTS ? Packet->dts : Packet->pts;
+             if (PTS == AV_NOPTS_VALUE) {
+                 // VPx alt-refs are output as packets which lack timestmps or durations, since
+                 // they are invisible. Currently, the timestamp mangling code in libavformat
+@@ -495,9 +499,11 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 // FFMS2 currently sorts packets by PTS, which will break decoding, otherwise.
+                 bool HasAltRefs = (FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP8 ||
+                                    FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP9);
+-                if (Packet.duration == 0 && !HasAltRefs)
++                if (Packet->duration == 0 && !HasAltRefs) {
++                    av_packet_free(&Packet);
+                     throw FFMS_Exception(FFMS_ERROR_INDEXING, FFMS_ERROR_PARSER,
+                         "Invalid packet pts, dts, and duration");
++                }
+ 
+                 if (TrackInfo.empty())
+                     PTS = 0;
+@@ -513,7 +519,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             ParseVideoPacket(AVContexts[Track], Packet, &RepeatPict, &FrameType, &Invisible, &LastPicStruct);
+ 
+             TrackInfo.AddVideoFrame(PTS, RepeatPict, KeyFrame,
+-                FrameType, Packet.pos, Invisible);
++                FrameType, Packet->pos, Invisible);
+         } else if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+             // For video seeking timestamps are used only if all packets have
+             // timestamps, while for audio they're used if any have timestamps,
+@@ -522,28 +528,29 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 TrackInfo.HasTS = true;
+ 
+             int64_t StartSample = AVContexts[Track].CurrentSample;
+-            uint32_t SampleCount = IndexAudioPacket(Track, &Packet, AVContexts[Track], *TrackIndices);
++            uint32_t SampleCount = IndexAudioPacket(Track, Packet, AVContexts[Track], *TrackIndices);
+             TrackInfo.SampleRate = AVContexts[Track].CodecContext->sample_rate;
+ 
+             TrackInfo.AddAudioFrame(LastValidTS[Track],
+-                StartSample, SampleCount, KeyFrame, Packet.pos, Packet.flags & AV_PKT_FLAG_DISCARD);
++                StartSample, SampleCount, KeyFrame, Packet->pos, Packet->flags & AV_PKT_FLAG_DISCARD);
+         }
+ 
+-        if (!(Packet.flags & AV_PKT_FLAG_DISCARD))
+-            TrackInfo.LastDuration = Packet.duration;
++        if (!(Packet->flags & AV_PKT_FLAG_DISCARD))
++            TrackInfo.LastDuration = Packet->duration;
+ 
+-        av_packet_unref(&Packet);
++        av_packet_unref(Packet);
+     }
++    av_packet_free(&Packet);
+ 
+     TrackIndices->Finalize(AVContexts, FormatContext->iformat->name);
+     return TrackIndices.release();
+ }
+ 
+-void FFMS_Indexer::ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS) {
+-    if (!UseDTS && Packet.pts != AV_NOPTS_VALUE)
+-        TS = Packet.pts;
++void FFMS_Indexer::ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS) {
++    if (!UseDTS && Packet->pts != AV_NOPTS_VALUE)
++        TS = Packet->pts;
+     if (TS == AV_NOPTS_VALUE)
+         UseDTS = true;
+-    if (UseDTS && Packet.dts != AV_NOPTS_VALUE)
+-        TS = Packet.dts;
++    if (UseDTS && Packet->dts != AV_NOPTS_VALUE)
++        TS = Packet->dts;
+ }
+diff --git a/src/core/indexing.h b/src/core/indexing.h
+index 3cfc3c3..5c06868 100644
+--- a/src/core/indexing.h
++++ b/src/core/indexing.h
+@@ -80,10 +80,10 @@ private:
+     int64_t Filesize;
+     uint8_t Digest[20];
+ 
+-    void ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS);
++    void ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS);
+     void CheckAudioProperties(int Track, AVCodecContext *Context);
+     uint32_t IndexAudioPacket(int Track, AVPacket *Packet, SharedAVContext &Context, FFMS_Index &TrackIndices);
+-    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
++    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
+     void Free();
+ public:
+     FFMS_Indexer(const char *Filename);
+diff --git a/src/core/utils.cpp b/src/core/utils.cpp
+index ce67533..8a2e997 100644
+--- a/src/core/utils.cpp
++++ b/src/core/utils.cpp
+@@ -62,12 +62,6 @@ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo) {
+     }
+ }
+ 
+-void InitNullPacket(AVPacket &pkt) {
+-    av_init_packet(&pkt);
+-    pkt.data = nullptr;
+-    pkt.size = 0;
+-}
+-
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames) {
+     AP.SampleFormat = static_cast<FFMS_SampleFormat>(av_get_packed_sample_fmt(CTX->sample_fmt));
+     AP.BitsPerSample = av_get_bytes_per_sample(CTX->sample_fmt) * 8;
+diff --git a/src/core/utils.h b/src/core/utils.h
+index 9819dc7..003ab79 100644
+--- a/src/core/utils.h
++++ b/src/core/utils.h
+@@ -58,7 +58,6 @@ std::unique_ptr<T> make_unique(Args&&... args) {
+ }
+ 
+ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo);
+-void InitNullPacket(AVPacket &pkt);
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames);
+ 
+ void LAVFOpenFile(const char *SourceFile, AVFormatContext *&FormatContext, int Track);
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index 06bd161..b889970 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -673,30 +673,34 @@ void FFMS_VideoSource::DecodeNextFrame(int64_t &AStartTime, int64_t &Pos) {
+     if (HasPendingDelayedFrames())
+         return;
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
+-
+-    while (ReadFrame(&Packet) >= 0) {
+-        if (Packet.stream_index != VideoTrack) {
+-            av_packet_unref(&Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++
++    while (ReadFrame(Packet) >= 0) {
++        if (Packet->stream_index != VideoTrack) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+         if (AStartTime < 0)
+-            AStartTime = Frames.UseDTS ? Packet.dts : Packet.pts;
++            AStartTime = Frames.UseDTS ? Packet->dts : Packet->pts;
+ 
+         if (Pos < 0)
+-            Pos = Packet.pos;
++            Pos = Packet->pos;
+ 
+-        bool FrameFinished = DecodePacket(&Packet);
+-        av_packet_unref(&Packet);
+-        if (FrameFinished)
++        bool FrameFinished = DecodePacket(Packet);
++        av_packet_unref(Packet);
++        if (FrameFinished) {
++            av_packet_free(&Packet);
+             return;
++        }
+     }
+ 
+     // Flush final frames
+-    InitNullPacket(Packet);
+-    DecodePacket(&Packet);
++    DecodePacket(Packet);
++    av_packet_free(&Packet);
+ }
+ 
+ bool FFMS_VideoSource::SeekTo(int n, int SeekOffset) {
+-- 
+2.40.0
+
+From bf9e03e9e08534c024e5a744a6437c4aac160201 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:20:47 +0100
+Subject: [PATCH 2/3] configure: Remove deprecated API use
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ configure.ac | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index b35ef80bc..d19714d0f 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -102,10 +102,10 @@ CFLAGS="$_CFLAGS $FFMPEG_CFLAGS"
+
+ AC_DEFUN([TEST_FFMPEG],
+          [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+-            #include <libavcodec/avcodec.h>
++            #include <libavformat/avformat.h>
+             #include <libswscale/swscale.h>
+             ]],[[
+-                avcodec_register_all();
++                avformat_network_init();
+                 swscale_version();
+             ]])], [eval $1=yes], [eval $1=no])
+         ])
+
diff --git a/srcpkgs/ffms2/template b/srcpkgs/ffms2/template
index 83482123111fc..e24a8a098e445 100644
--- a/srcpkgs/ffms2/template
+++ b/srcpkgs/ffms2/template
@@ -1,7 +1,7 @@
 # Template file for 'ffms2'
 pkgname=ffms2
 version=2.40
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-shared --disable-static"
 hostmakedepends="pkg-config autoconf automake libtool"

From 227822b65125d1015421c718d3446a40a8a49bbc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 034/115] freerdp: revbump for ffmpeg-6.0

---
 .../freerdp/patches/ffmpeg6_aa2cb9aa.patch    | 42 +++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100644 srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch

diff --git a/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
new file mode 100644
index 0000000000000..a4324da3a8822
--- /dev/null
+++ b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
@@ -0,0 +1,42 @@
+From aa2cb9aa5ff5562433598ba168a466e0752bca0e Mon Sep 17 00:00:00 2001
+From: akallabeth <akallabeth@posteo.net>
+Date: Tue, 14 Feb 2023 07:48:54 +0100
+Subject: [PATCH] Fixed #8686: Update h264 to use new FFMPEG API
+
+---
+ channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c | 2 ++
+ libfreerdp/codec/h264_ffmpeg.c            | 2 ++
+ 2 files changed, 4 insertions(+)
+
+diff --git a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+index 339462d865f..beea80b7a1e 100644
+--- a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
++++ b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+@@ -239,8 +239,10 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYP
+ 		}
+ 	}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 	if (mdecoder->codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		mdecoder->codec_context->flags |= AV_CODEC_FLAG_TRUNCATED;
++#endif
+ 
+ 	return TRUE;
+ }
+diff --git a/libfreerdp/codec/h264_ffmpeg.c b/libfreerdp/codec/h264_ffmpeg.c
+index 8a23db2473c..896a333019b 100644
+--- a/libfreerdp/codec/h264_ffmpeg.c
++++ b/libfreerdp/codec/h264_ffmpeg.c
+@@ -615,10 +615,12 @@ static BOOL libavcodec_init(H264_CONTEXT* h264)
+ 			goto EXCEPTION;
+ 		}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 		if (sys->codecDecoder->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		{
+ 			sys->codecDecoderContext->flags |= AV_CODEC_FLAG_TRUNCATED;
+ 		}
++#endif
+ 
+ #ifdef WITH_VAAPI
+ 

From d6de47caa455b35a21b870279b0d24728660bce7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 035/115] gerbera: revbump for ffmpeg-6.0

---
 srcpkgs/gerbera/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gerbera/template b/srcpkgs/gerbera/template
index ae14f35c767c0..2dc0ac0ce03b5 100644
--- a/srcpkgs/gerbera/template
+++ b/srcpkgs/gerbera/template
@@ -1,7 +1,7 @@
 # Template file for 'gerbera'
 pkgname=gerbera
 version=1.12.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_SYSTEMD=0 -DWITH_AVCODEC=1"
 hostmakedepends="pkg-config"

From 1a4aa05c27168275ffaf19bab849ff30db93bc68 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 036/115] goldendict: revbump for ffmpeg-6.0

---
 srcpkgs/goldendict/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/goldendict/template b/srcpkgs/goldendict/template
index f4a05759f693d..97f44347b03a6 100644
--- a/srcpkgs/goldendict/template
+++ b/srcpkgs/goldendict/template
@@ -1,7 +1,7 @@
 # Template file for 'goldendict'
 pkgname=goldendict
 version=1.5.0
-revision=1
+revision=2
 build_style=qmake
 configure_args="CONFIG+=zim_support goldendict.pro"
 hostmakedepends="qt5-qmake pkg-config qt5-host-tools"
@@ -10,7 +10,7 @@ makedepends="tiff-devel qt5-devel libvorbis-devel zlib-devel
  qt5-webkit-devel lzo-devel bzip2-devel libao-devel qt5-svg-devel
  libeb-devel qt5-x11extras-devel ffmpeg-devel liblzma-devel
  qt5-multimedia-devel"
-short_desc="A feature-rich dictionary lookup program"
+short_desc="Feature-rich dictionary lookup program"
 maintainer="John <me@johnnynator.dev>"
 license="GPL-3.0-or-later"
 homepage="http://goldendict.org/"

From dd3d599aac187abd642d2fed51328285b3e18cbf Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 037/115] gst-libav: revbump for ffmpeg-6.0

---
 srcpkgs/gst-libav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index 8c72fc3e97eee..04c39bff14896 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.22.2
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"

From 5b75a66b3f5dcea9ed2155f31887c4b7c4d6ed5e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 038/115] gst-rtsp-server: revbump for ffmpeg-6.0

---
 srcpkgs/gst-rtsp-server/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index 2f0c0c45ff820..980fd72cdd4c5 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
 version=1.22.2
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="glib-devel gst-plugins-bad1-devel gobject-introspection

From b336ca2f3b8c38b66455ef64223efce235673103 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 039/115] guvcview: update to 2.0.8.

---
 srcpkgs/guvcview/patches/fix-include.patch | 10 ++++++++++
 srcpkgs/guvcview/template                  |  5 ++---
 2 files changed, 12 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/guvcview/patches/fix-include.patch

diff --git a/srcpkgs/guvcview/patches/fix-include.patch b/srcpkgs/guvcview/patches/fix-include.patch
new file mode 100644
index 0000000000000..503c2af3b78c1
--- /dev/null
+++ b/srcpkgs/guvcview/patches/fix-include.patch
@@ -0,0 +1,10 @@
+--- a/guvcview/guvcview.c
++++ b/guvcview/guvcview.c
+@@ -28,6 +28,7 @@
+ #include <sys/stat.h>
+ #include <sys/resource.h>
+ #include <errno.h>
++#include <locale.h>
+ 
+ #include "gview.h"
+ #include "gviewv4l2core.h"
diff --git a/srcpkgs/guvcview/template b/srcpkgs/guvcview/template
index 345cf6006f246..86a7fd619612c 100644
--- a/srcpkgs/guvcview/template
+++ b/srcpkgs/guvcview/template
@@ -1,8 +1,7 @@
 # Template file for 'guvcview'
 pkgname=guvcview
-version=2.0.7
+version=2.0.8
 revision=1
-create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-static --disable-debian-menu"
 hostmakedepends="pkg-config intltool autoconf automake libtool glib-devel"
@@ -14,7 +13,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="http://guvcview.sourceforge.net/"
 distfiles="${SOURCEFORGE_SITE}/${pkgname}/${pkgname}-src-${version}.tar.bz2"
-checksum=f47d51fbd06e44eeaa1a82f4a153c927527c90d94514197a70b2956028cc8ad4
+checksum=a21f4e448286666cf27bafef5290cc953a0a1796b752e5bbe521266dc1230c81
 
 post_patch() {
 	sed '31a#include <locale.h>' -i  guvcview/guvcview.c

From cbd5d3206017f514b7e2ebbddd596525f9ef2a84 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 040/115] handbrake: update to 1.6.1

---
 .../patches/fix-missing-x265-link-flag.patch    | 11 ++++++-----
 .../handbrake/patches/libhb-vpl-include.patch   | 15 +++++++++++++++
 srcpkgs/handbrake/template                      | 17 ++++++++++-------
 3 files changed, 31 insertions(+), 12 deletions(-)
 create mode 100644 srcpkgs/handbrake/patches/libhb-vpl-include.patch

diff --git a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
index 26db03867a0c8..d6bb2eda627a3 100644
--- a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
+++ b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
@@ -1,14 +1,15 @@
 --- a/gtk/configure.ac
 +++ b/gtk/configure.ac
 @@ -203,7 +203,7 @@
- 
+
  AM_CONDITIONAL([MINGW], [test "x$mingw_flag" = "xyes"])
- 
--HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg"
-+HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -ldl"
+
+-HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc"
++HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc -ldl"
  HB_CPPFLAGS="$HB_CPPFLAGS $HBINC"
- 
+
  PKG_CHECK_MODULES([x264], [x264], sys_x264=yes, sys_x264=no)
+
 --- a/test/module.defs
 +++ b/test/module.defs
 @@ -69,6 +69,9 @@
diff --git a/srcpkgs/handbrake/patches/libhb-vpl-include.patch b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
new file mode 100644
index 0000000000000..298f9f4ab28f2
--- /dev/null
+++ b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
@@ -0,0 +1,15 @@
+--- a/libhb/module.defs	2023-01-22 11:36:49.000000000 -0500
++++ b/libhb/module.defs	2023-04-03 22:37:52.395467010 -0400
+@@ -46,11 +46,7 @@
+ LIBHB.GCC.I += $(LIBHB.build/) $(CONTRIB.build/)include
+ 
+ ifeq (1,$(FEATURE.qsv))
+-    ifeq ($(HOST.system),freebsd))
+-        LIBHB.GCC.I += $(LOCALBASE)/include/vpl
+-    else
+-        LIBHB.GCC.I += $(CONTRIB.build/)include/vpl
+-    endif
++    LIBHB.GCC.I += /usr/include/vpl
+ endif
+ 
+ ifneq (,$(filter $(HOST.system),freebsd netbsd openbsd))
diff --git a/srcpkgs/handbrake/template b/srcpkgs/handbrake/template
index ca5e4571e49c3..c32cb1bfa31f4 100644
--- a/srcpkgs/handbrake/template
+++ b/srcpkgs/handbrake/template
@@ -1,10 +1,10 @@
 # Template file for 'handbrake'
 pkgname=handbrake
-version=1.5.1
+version=1.6.1
 revision=1
 build_style=gnu-configure
 configure_args="--force --disable-gtk-update-checks --disable-df-fetch --harden
- $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc)"
+ $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc) $(vopt_enable qsv)"
 make_build_args="-C ${XBPS_TRIPLET}"
 make_install_args="-C ${XBPS_TRIPLET}"
 hostmakedepends="automake cmake gettext-devel glib-devel intltool libtool m4 meson nasm pkg-config python3"
@@ -12,8 +12,11 @@ makedepends="bzip2-devel ffmpeg-devel gst-plugins-base1-devel gtk+3-devel
  jansson-devel lame-devel libass-devel libbluray-devel libdav1d-devel
  libdvdnav-devel libdvdread-devel libgudev-devel libnuma-devel
  libsamplerate-devel libtheora-devel libvorbis-devel libvpx-devel libxml2-devel
- opus-devel speex-devel x264-devel x265-devel zimg-devel
+ opus-devel speex-devel x264-devel x265-devel zimg-devel libsvt-av1-devel
  $(vopt_if fdk_aac fdk-aac-devel)
+ $(vopt_if qsv libva-devel)
+ $(vopt_if qsv libdrm-devel)
+ $(vopt_if qsv onevpl-devel)
  $(vopt_if nvenc nv-codec-headers)"
 depends="desktop-file-utils gst-plugins-good1 hicolor-icon-theme"
 short_desc="Multithreaded video transcoder"
@@ -21,15 +24,15 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-2.0-only"
 homepage="https://handbrake.fr/"
 distfiles="https://github.com/HandBrake/HandBrake/releases/download/${version}/HandBrake-${version}-source.tar.bz2"
-checksum=3999fe06d5309c819799a73a968a8ec3840e7840c2b64af8f5cdb7fd8c9430f0
+checksum=94ccfe03db917a91650000c510f7fd53f844da19f19ad4b4be1b8f6bc31a8d4c
 nocross=yes
 
-build_options="fdk_aac nvenc"
+build_options="fdk_aac nvenc qsv"
 
 case "$XBPS_TARGET_MACHINE" in
 	x86_64*|i686*)
 		CFLAGS="-msse"
-		build_options_default="nvenc"
+		build_options_default="nvenc qsv"
 		;;
 esac
 
@@ -37,7 +40,7 @@ pre_configure() {
 	# use system libraries, don't download them
 	rm -rf contrib/
 	for module in fdk-aac ffmpeg libbluray libdav1d libdvdnav libdvdread nvenc \
-		x265 zimg; do
+		x265 zimg svt-av1 libvpl; do
 	    vsed -i "/MODULES += contrib\/${module}/d" make/include/main.defs
 	done
 }

From ceadce900dc6a26fd80006898680be840030ebda Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 041/115] hedgewars: revbump for ffmpeg4-4.4.3

---
 srcpkgs/hedgewars/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/hedgewars/template b/srcpkgs/hedgewars/template
index 15a1df6d8861d..d1b7290bfdc19 100644
--- a/srcpkgs/hedgewars/template
+++ b/srcpkgs/hedgewars/template
@@ -1,13 +1,13 @@
 # Template file for 'hedgewars'
 pkgname=hedgewars
 version=1.0.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DNOSERVER=1 -DDATA_INSTALL_DIR=/usr/share/${pkgname}
  -DPHYSFS_SYSTEM=1 -DMINIMAL_FLAGS=1"
 make_cmd=make
 hostmakedepends="lua51 pkg-config qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
+makedepends="ffmpeg4-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
  SDL2_mixer-devel SDL2_net-devel SDL2_ttf-devel"
 depends="libfreeglut"
 short_desc="Funny turn-based artillery game, featuring fighting Hedgehogs!"

From d88eb4b2d0609b3e6d9854230f72be1b6543b34e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 042/115] idjc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/idjc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/idjc/template b/srcpkgs/idjc/template
index df60318b3db96..36a75baf597c5 100644
--- a/srcpkgs/idjc/template
+++ b/srcpkgs/idjc/template
@@ -1,11 +1,11 @@
 # Template file for 'idjc'
 pkgname=idjc
 version=0.9.1
-revision=3
+revision=4
 build_style=gnu-configure
 hostmakedepends="pkg-config git python3 automake gettext-devel libtool"
 makedepends="libvorbis-devel libogg-devel jack-devel libsamplerate-devel
- libflac-devel libsndfile-devel mpg123-devel ffmpeg-devel speex-devel
+ libflac-devel libsndfile-devel mpg123-devel ffmpeg4-devel speex-devel
  glib-devel pixman-devel lame-devel python3-gobject-devel libshout-idjc-devel
  opus-devel twolame-devel python3-mutagen python3-devel"
 depends="python3-gobject python3-mutagen desktop-file-utils shared-mime-info python3-dbus jack"

From 4b238223d6a0a5262ae969b90cedefe9ecf5225c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 043/115] kfilemetadata5: revbump for ffmpeg-6.0

---
 srcpkgs/kfilemetadata5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kfilemetadata5/template b/srcpkgs/kfilemetadata5/template
index c3e3eb116a67b..30ffc31b1cb6b 100644
--- a/srcpkgs/kfilemetadata5/template
+++ b/srcpkgs/kfilemetadata5/template
@@ -1,7 +1,7 @@
 # Template file for 'kfilemetadata5'
 pkgname=kfilemetadata5
 version=5.108.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="kcoreaddons extra-cmake-modules pkg-config qt5-host-tools qt5-qmake
  gettext kcoreaddons python3"

From 0f6ff1955de0a7e26f7c4fb5e8364e2c9fcc9b23 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 044/115] kid3: revbump for ffmpeg-6.0

---
 srcpkgs/kid3/patches/ffmpeg5.patch | 17 +++++++++++++++++
 srcpkgs/kid3/template              |  2 +-
 2 files changed, 18 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/kid3/patches/ffmpeg5.patch

diff --git a/srcpkgs/kid3/patches/ffmpeg5.patch b/srcpkgs/kid3/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..135fc50e07c9b
--- /dev/null
+++ b/srcpkgs/kid3/patches/ffmpeg5.patch
@@ -0,0 +1,17 @@
+# https://aur.archlinux.org/cgit/aur.git/diff/ffmpeg5.patch?h=kid3-cli&id=12410a74906612e7efc0ec8fbce739b4a0fef7e7
+diff --git a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+index e156d424..e12b9abd 100644
+--- a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
++++ b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+@@ -232,7 +232,11 @@ private:
+   friend class Format;
+   friend class Converter;
+   AVCodecContext* m_ptr;
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 0, 0)
+   AVCodec* m_impl;
++#else
++  const AVCodec* m_impl;
++#endif
+   AVFrame* m_frame;
+   bool m_opened;
+ };
diff --git a/srcpkgs/kid3/template b/srcpkgs/kid3/template
index 456206d90e16a..f32f9decb0e7f 100644
--- a/srcpkgs/kid3/template
+++ b/srcpkgs/kid3/template
@@ -1,7 +1,7 @@
 # Template file for 'kid3'
 pkgname=kid3
 version=3.9.1
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DWITH_APPS='CLI;$(vopt_if KDE KDE Qt)'
  -DWITH_DOCBOOKDIR=/usr/share/xsl/docbook -DWITH_FLAC=$(vopt_if flac ON OFF)

From b1267da74186b02dc3ebb133acb415e1af91db7c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 045/115] kodi: revbump for ffmpeg4-4.4.3

---
 srcpkgs/kodi/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kodi/template b/srcpkgs/kodi/template
index e862f48a39f48..25744f69107f4 100644
--- a/srcpkgs/kodi/template
+++ b/srcpkgs/kodi/template
@@ -54,7 +54,7 @@ makedepends="
  libmad-devel fontconfig-devel libXinerama-devel libsamplerate-devel libmms-devel
  enca-devel boost-devel libcurl-devel libva-devel libvdpau-devel libass-devel
  libbluetooth-devel yajl-devel libplist-devel librtmp-devel tinyxml-devel
- taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg-devel
+ taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg4-devel
  giflib-devel libxslt-devel gnutls-devel libssh-devel libmicrohttpd-devel
  libcec-devel dcadec-devel flatbuffers-devel fmt-devel lcms2-devel
  libfstrcmp-devel rapidjson libcdio-paranoia spdlog libwaylandpp-devel

From 471cf2b4fdc40fa3ce5830788eddf261280a963a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 046/115] kpipewire: revbump for ffmpeg-6.0

---
 srcpkgs/kpipewire/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kpipewire/template b/srcpkgs/kpipewire/template
index db4e42f0d456a..2334bf8678062 100644
--- a/srcpkgs/kpipewire/template
+++ b/srcpkgs/kpipewire/template
@@ -1,7 +1,7 @@
 # Template file for 'kpipewire'
 pkgname=kpipewire
 version=5.27.6
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules plasma-wayland-protocols gettext
  qt5-qmake qt5-host-tools pkg-config wayland-devel kcoreaddons

From 22acd90fb1226ee987f6062d8af0efcd4143017b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 047/115] libextractor: revbump for ffmpeg4-4.4.3

---
 srcpkgs/libextractor/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libextractor/template b/srcpkgs/libextractor/template
index ddd4790f93e88..1fb9ca56a96ae 100644
--- a/srcpkgs/libextractor/template
+++ b/srcpkgs/libextractor/template
@@ -7,7 +7,7 @@ configure_args="--disable-static"
 hostmakedepends="pkg-config"
 makedepends="zlib-devel bzip2-devel exiv2-devel tiff-devel libpng-devel
  libjpeg-turbo-devel libvorbis-devel libflac-devel giflib-devel libmpeg2-devel
- ffmpeg-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
+ ffmpeg4-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
 short_desc="Library used to extract meta data from files"
 maintainer="Martin Riese <grauehaare@gmx.de>"
 license="GPL-3.0-or-later"

From c36e6fad0ebd37e1618a3ac79689f733a39d8c7c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 048/115] libopenal: revbump for ffmpeg-6.0

---
 srcpkgs/libopenal/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenal/template b/srcpkgs/libopenal/template
index 77218f9e539df..3f49ed75a1fdc 100644
--- a/srcpkgs/libopenal/template
+++ b/srcpkgs/libopenal/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenal'
 pkgname=libopenal
 version=1.22.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DALSOFT_EXAMPLES=OFF"
 hostmakedepends="pkg-config"

From 04cc4da47e2f418b3686a29d423b7cbdf3a35fca Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 049/115] loudgain: revbump for ffmpeg-6.0

---
 srcpkgs/loudgain/patches/ffmpeg5.patch | 11 +++++++++++
 srcpkgs/loudgain/template              |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/loudgain/patches/ffmpeg5.patch

diff --git a/srcpkgs/loudgain/patches/ffmpeg5.patch b/srcpkgs/loudgain/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..16d4510ee98fa
--- /dev/null
+++ b/srcpkgs/loudgain/patches/ffmpeg5.patch
@@ -0,0 +1,11 @@
+--- a/src/scan.c	2019-09-06 11:31:19.000000000 -0400
++++ b/src/scan.c	2023-03-23 11:15:40.867968521 -0400
+@@ -69,8 +69,6 @@
+ 	 * It is now useless
+ 	 * https://github.com/FFmpeg/FFmpeg/blob/70d25268c21cbee5f08304da95be1f647c630c15/doc/APIchanges#L86
+ 	 */
+-  if (avformat_version() < AV_VERSION_INT(58,9,100))
+-    av_register_all();
+ 
+ 	av_log_set_callback(scan_av_log);
+ 
diff --git a/srcpkgs/loudgain/template b/srcpkgs/loudgain/template
index da4f2d56e94c3..4d6bf29efb4fd 100644
--- a/srcpkgs/loudgain/template
+++ b/srcpkgs/loudgain/template
@@ -1,7 +1,7 @@
 # Template file for 'loudgain'
 pkgname=loudgain
 version=0.6.8
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libebur128-devel taglib-devel ffmpeg-devel"

From 161219d0203bc3c0cb3d9501540d125914018af9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 050/115] mediastreamer: revbump for ffmpeg4-4.4.3

---
 srcpkgs/mediastreamer/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mediastreamer/template b/srcpkgs/mediastreamer/template
index d0e97e858e29a..1bde031443a59 100644
--- a/srcpkgs/mediastreamer/template
+++ b/srcpkgs/mediastreamer/template
@@ -1,11 +1,11 @@
 # Template file for 'mediastreamer'
 pkgname=mediastreamer
 version=5.2.6
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_STRICT=0 -DENABLE_UNIT_TESTS=0"
 hostmakedepends="python3"
-makedepends="bzrtp-devel ffmpeg-devel glew-devel libXv-devel libsrtp-devel
+makedepends="bzrtp-devel ffmpeg4-devel glew-devel libXv-devel libsrtp-devel
  libupnp-devel libvpx-devel mbedtls-devel opus-devel ortp-devel pulseaudio-devel
  libtheora-devel speex-devel v4l-utils-devel bcg729-devel bcmatroska2-devel libgsm-devel"
 # zxing-cpp-devel (1.2.0 probably not compatible, check again after updaing xzing)

From d27347cc8fa0bf745d1810977a06077551e74cc9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 051/115] mgba: revbump for ffmpeg-6.0

---
 srcpkgs/mgba/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mgba/template b/srcpkgs/mgba/template
index 4af085188bf44..01ec4176bd602 100644
--- a/srcpkgs/mgba/template
+++ b/srcpkgs/mgba/template
@@ -1,7 +1,7 @@
 # Template file for 'mgba'
 pkgname=mgba
 version=0.10.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake desktop-file-utils"
 makedepends="SDL2-devel ffmpeg-devel libedit-devel libepoxy-devel libmagick-devel

From 90c30ee60e8b57c8269e37b14f480051e89d5f23 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 052/115] minidlna: revbump for ffmpeg-6.0

---
 srcpkgs/minidlna/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/minidlna/template b/srcpkgs/minidlna/template
index d551e49ed4653..5fa929f3a0c12 100644
--- a/srcpkgs/minidlna/template
+++ b/srcpkgs/minidlna/template
@@ -1,7 +1,7 @@
 # Template file for 'minidlna'
 pkgname=minidlna
 version=1.3.3
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="
  --sbindir=/usr/bin

From 5599eaf06de13bfda1a12997157f5aeb2d53932e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 053/115] mlt: revbump for ffmpeg4-4.4.3

---
 srcpkgs/mlt/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mlt/template b/srcpkgs/mlt/template
index 5ad199461e694..f0b3af193db2c 100644
--- a/srcpkgs/mlt/template
+++ b/srcpkgs/mlt/template
@@ -1,14 +1,14 @@
 # Template file for 'mlt'
 pkgname=mlt
 version=6.26.1
-revision=1
+revision=2
 build_style=configure
 configure_args="--prefix=/usr --libdir=/usr/lib$XBPS_TARGET_WORDSIZE
  --enable-gpl --enable-gpl3 --disable-swfdec --without-kde
  --swig-languages=python"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which"
 # XXX: movit vid.stab
-makedepends="alsa-lib-devel ffmpeg-devel gtk+-devel jack-devel ladspa-sdk
+makedepends="alsa-lib-devel ffmpeg4-devel gtk+-devel jack-devel ladspa-sdk
  libexif-devel libsamplerate-devel libxml2-devel sox-devel SDL_image-devel
  fftw-devel frei0r-plugins python3-devel pulseaudio-devel movit-devel
  libvidstab-devel"

From 8f7d4dd8a152d146e1ad09e08deb72972e38e59c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 054/115] moc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/moc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/moc/template b/srcpkgs/moc/template
index 5aed5d36558d3..d8de816026b64 100644
--- a/srcpkgs/moc/template
+++ b/srcpkgs/moc/template
@@ -1,10 +1,10 @@
 # Template file for 'moc'
 pkgname=moc
 version=2.5.2
-revision=6
+revision=7
 build_style=gnu-configure
 hostmakedepends="pkg-config"
-makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg-devel
+makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg4-devel
  jack-devel alsa-lib-devel libltdl-devel libflac-devel libvorbis-devel
  libmad-devel libmpcdec-devel libmodplug-devel libid3tag-devel faad2-devel
  taglib-devel libsndfile-devel wavpack-devel speex-devel libsamplerate-devel

From d575344b36195e84446b3c9ec5ddba0acea3060d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 055/115] motion: revbump for ffmpeg-6.0

---
 srcpkgs/motion/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/motion/template b/srcpkgs/motion/template
index 3cf3c3035c5b7..7dca12d851e33 100644
--- a/srcpkgs/motion/template
+++ b/srcpkgs/motion/template
@@ -1,7 +1,7 @@
 # Template file for 'motion'
 pkgname=motion
 version=4.5.1
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake pkg-config gettext-devel tar"
 makedepends="ffmpeg-devel libmicrohttpd-devel v4l-utils-devel gettext-devel"

From ac628554737353a6f22cbf8c828e74b5547fd0ac Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 056/115] notcurses: revbump for ffmpeg-6.0

---
 srcpkgs/notcurses/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/notcurses/template b/srcpkgs/notcurses/template
index 6dd8a091319f7..3110c30c9aff2 100644
--- a/srcpkgs/notcurses/template
+++ b/srcpkgs/notcurses/template
@@ -1,7 +1,7 @@
 # Template file for 'notcurses'
 pkgname=notcurses
 version=3.0.9
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DUSE_STATIC=ON $(vopt_bool man USE_PANDOC)"
 hostmakedepends="pkg-config $(vopt_if man pandoc)"

From e6dd43c1237e74c9685be536888d530d38a74f16 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 057/115] obs: revbump for ffmpeg-6.0

---
 srcpkgs/obs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/obs/template b/srcpkgs/obs/template
index 7b69c630d30d4..2c8d68d71f3a1 100644
--- a/srcpkgs/obs/template
+++ b/srcpkgs/obs/template
@@ -1,7 +1,7 @@
 # Template file for 'obs'
 pkgname=obs
 version=29.1.2
-revision=1
+revision=2
 archs="i686* x86_64* ppc64le* aarch64*"
 build_style=cmake
 configure_args="-DOBS_VERSION_OVERRIDE=${version} -DENABLE_JACK=ON

From 7e1c2e8fa36331f2f5ab89d7fea8c85acc4a0ab4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 058/115] olive: revbump for ffmpeg4-4.4.3

---
 srcpkgs/olive/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/olive/template b/srcpkgs/olive/template
index 12a46936c9900..5c2917b9c5124 100644
--- a/srcpkgs/olive/template
+++ b/srcpkgs/olive/template
@@ -1,10 +1,10 @@
 # Template file for 'olive'
 pkgname=olive
 version=0.1.2
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools pkg-config"
-makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg-devel frei0r-plugins"
+makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg4-devel frei0r-plugins"
 short_desc="Non-linear video editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"

From f0baf4c86a3ab85c6116ed857c905c7dcd53d1d6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 059/115] omxplayer: revbump for ffmpeg4-4.4.3

---
 srcpkgs/omxplayer/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/omxplayer/template b/srcpkgs/omxplayer/template
index 9a66690c83ebb..a21b878878037 100644
--- a/srcpkgs/omxplayer/template
+++ b/srcpkgs/omxplayer/template
@@ -1,7 +1,7 @@
 # Template file for 'omxplayer'
 pkgname=omxplayer
 version=20190102
-revision=2
+revision=3
 short_desc="Commandline OMX player for the Raspberry Pi"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
@@ -15,7 +15,7 @@ checksum=af2d9450f8947842ea8c401fe9f71eec444013ebbdee29f2ac828c9c493c1329
 archs="armv6l* armv7l*"
 build_style=gnu-makefile
 hostmakedepends="ruby-ronn pkg-config"
-makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg-devel dbus-devel"
+makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg4-devel dbus-devel"
 depends="freefont-ttf"
 
 do_build() {

From 536e52e0383465603c518d9e432657746b76bf29 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 060/115] openshot: revbump for ffmpeg-6.0

---
 srcpkgs/openshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openshot/template b/srcpkgs/openshot/template
index 5d2adeba269fd..8f47851eef354 100644
--- a/srcpkgs/openshot/template
+++ b/srcpkgs/openshot/template
@@ -1,7 +1,7 @@
 # Template file for 'openshot'
 pkgname=openshot
 version=3.0.0
-revision=1
+revision=2
 build_style=python3-module
 hostmakedepends="python3 python3-setuptools"
 makedepends="ffmpeg-devel python3-PyQt5"

From 46711e36ca6f49863fee61084c666f4f9beb3df9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 061/115] opentoonz: revbump for ffmpeg-6.0

---
 srcpkgs/opentoonz/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/opentoonz/template b/srcpkgs/opentoonz/template
index ee9f7603f55fd..3e81834ca0edd 100644
--- a/srcpkgs/opentoonz/template
+++ b/srcpkgs/opentoonz/template
@@ -1,7 +1,7 @@
 # Template file for 'opentoonz'
 pkgname=opentoonz
 version=1.6.0
-revision=2
+revision=3
 build_wrksrc="toonz/sources"
 build_style=cmake
 make_cmd=make

From d9cdf28844dba344535f1e4a061487665255b6ff Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 062/115] pianobar: revbump for ffmpeg-6.0

---
 srcpkgs/pianobar/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pianobar/template b/srcpkgs/pianobar/template
index e3febb821a451..1e3dc1bf9308e 100644
--- a/srcpkgs/pianobar/template
+++ b/srcpkgs/pianobar/template
@@ -1,7 +1,7 @@
 # Template file for 'pianobar'
 pkgname=pianobar
 version=2022.04.01
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="V=1"
 hostmakedepends="pkg-config"

From 40671b762a6ccc53886594e9dfd73635ff1cf534 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 063/115] ppsspp: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ppsspp/template | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/ppsspp/template b/srcpkgs/ppsspp/template
index 86511ef515dea..d56d5c37d5848 100644
--- a/srcpkgs/ppsspp/template
+++ b/srcpkgs/ppsspp/template
@@ -1,7 +1,7 @@
 # Template file for 'ppsspp'
 pkgname=ppsspp
 version=1.15.4
-revision=1
+revision=2
 _glslang_commit=b34f619e1c85810dcb3c578107d2e48ba4ee2b37
 _SPIRV_Cross_commit=4212eef67ed0ca048cb726a6767185504e7695e5
 _armips_commit=7bd1ec93d4586985ba1ef420b43b5e620f68695e
@@ -14,7 +14,7 @@ configure_args="-DHEADLESS=1 -DUSE_SYSTEM_FFMPEG=1 -DUNITTEST=ON
  -DUSING_QT_UI=$(vopt_if qt ON OFF) -DUSE_SYSTEM_ZSTD=ON
  -DARMIPS_USE_STD_FILESYSTEM=ON"
 hostmakedepends="pkg-config python3 $(vopt_if qt qt5-host-tools)"
-makedepends="zlib-devel glew-devel ffmpeg-devel libzip-devel
+makedepends="zlib-devel glew-devel ffmpeg4-devel libzip-devel
  snappy-devel rapidjson libpng-devel libzstd-devel
  $(vopt_if sdl2 SDL2-devel) $(vopt_if wayland wayland-devel)
  $(vopt_if qt 'qt5-devel qt5-multimedia-devel')"
@@ -68,13 +68,12 @@ post_extract() {
 
 }
 
-post_patch(){
+post_patch() {
 	# disable git versioning
 	vsed -e 's|find_package(Git)|# &|' -i git-version.cmake
 }
 
 do_install() {
-	vlicense LICENSE.TXT
 	vinstall icons/icon.svg 644 usr/share/pixmaps ppsspp.svg
 	vinstall Qt/PPSSPP.desktop 644 usr/share/applications
 	vbin build/PPSSPPHeadless ppsspp-headless

From 636039d29bfccd3953023015d07ad54ff83bff19 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 064/115] pqiv: revbump for ffmpeg-6.0

---
 srcpkgs/pqiv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pqiv/template b/srcpkgs/pqiv/template
index 542fc27a2d32a..9308d949b6a1c 100644
--- a/srcpkgs/pqiv/template
+++ b/srcpkgs/pqiv/template
@@ -1,7 +1,7 @@
 # Template file for 'pqiv'
 pkgname=pqiv
 version=2.12
-revision=1
+revision=2
 build_style=gnu-makefile
 hostmakedepends="pkg-config"
 makedepends="glib-devel gtk+3-devel $(vopt_if ffmpeg ffmpeg-devel)

From 82c42d9339acfcc2f1ef0b1f2ae450bd55ff5fbc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 065/115] qmmp: revbump for ffmpeg-6.0

---
 srcpkgs/qmmp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qmmp/template b/srcpkgs/qmmp/template
index 26c661ed16bea..a150d7441c7a6 100644
--- a/srcpkgs/qmmp/template
+++ b/srcpkgs/qmmp/template
@@ -1,7 +1,7 @@
 # Template file for 'qmmp'
 pkgname=qmmp
 version=1.6.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DUSE_HAL:BOOL=FALSE -DQMMP_DEFAULT_UI:STRING=simple"
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From 42eacfc22f89a14bfc8c6d052e8e4e4e5e5b1730 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 066/115] qt5-webengine: update to 5.15.13

---
 .../chromium-media-filters-cpp14.patch        |  11 ++
 srcpkgs/qt5-webengine/patches/ffmpeg5.patch   | 179 ++++++++++++++++++
 srcpkgs/qt5-webengine/template                |  10 +-
 3 files changed, 195 insertions(+), 5 deletions(-)
 create mode 100644 srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/ffmpeg5.patch

diff --git a/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
new file mode 100644
index 0000000000000..04adc540f2cbc
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
@@ -0,0 +1,11 @@
+--- a/src/3rdparty/chromium/media/filters/BUILD.gn	2023-02-27 13:32:59.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/BUILD.gn	2023-04-02 17:21:39.204066384 -0400
+@@ -96,6 +96,8 @@
+     "//ui/gfx/geometry:geometry",
+   ]
+ 
++  cflags_cc = [ "-std=c++14" ]
++
+   libs = []
+ 
+   if (proprietary_codecs) {
diff --git a/srcpkgs/qt5-webengine/patches/ffmpeg5.patch b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..ac55e1634423a
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
@@ -0,0 +1,179 @@
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:57.732547446 -0400
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:09.486478995 -0400
+@@ -57,6 +57,8 @@
+ 
+ namespace {
+ 
++constexpr int64_t kRelativeTsBase = static_cast<int64_t>(0x7ffeffffffffffff);
++
+ void SetAVStreamDiscard(AVStream* stream, AVDiscard discard) {
+   DCHECK(stream);
+   stream->discard = discard;
+@@ -90,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+   if (stream->start_time != kNoFFmpegTimestamp)
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (stream->first_dts != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, stream->first_dts);
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -408,11 +398,11 @@
+   scoped_refptr<DecoderBuffer> buffer;
+ 
+   if (type() == DemuxerStream::TEXT) {
+-    int id_size = 0;
++    size_t id_size = 0;
+     uint8_t* id_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
+ 
+-    int settings_size = 0;
++    size_t settings_size = 0;
+     uint8_t* settings_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
+ 
+@@ -424,7 +414,7 @@
+     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
+                                      side_data.data(), side_data.size());
+   } else {
+-    int side_data_size = 0;
++    size_t side_data_size = 0;
+     uint8_t* side_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
+ 
+@@ -485,7 +475,7 @@
+                                        packet->size - data_offset);
+     }
+ 
+-    int skip_samples_size = 0;
++    size_t skip_samples_size = 0;
+     const uint32_t* skip_samples_ptr =
+         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
+             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
+@@ -1587,6 +1577,8 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++      continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+       lowest_start_time_stream = stream.get();
+@@ -1604,6 +1596,8 @@
+     if (stream && stream->type() == DemuxerStream::VIDEO &&
+         stream->IsEnabled()) {
+       video_stream = stream.get();
++      if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++        continue;
+       if (video_stream->start_time() <= seek_time) {
+         return video_stream;
+       }
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h qtwebengine-5.15.10/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h
+--- a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-07-11 22:12:47.917192788 -0500
+@@ -29,6 +29,7 @@ extern "C" {
+ #include <libavformat/avformat.h>
+ #include <libavformat/avio.h>
+ #include <libavutil/avutil.h>
++#include <libavutil/channel_layout.h>
+ #include <libavutil/imgutils.h>
+ #include <libavutil/log.h>
+ #include <libavutil/mastering_display_metadata.h>
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/audio_file_reader.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/audio_file_reader.cc
+--- a/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -85,7 +85,7 @@ bool AudioFileReader::OpenDemuxer() {
+ }
+ 
+ bool AudioFileReader::OpenDecoder() {
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (codec) {
+     // MP3 decodes to S16P which we don't support, tell it to use S16 instead.
+     if (codec_context_->sample_fmt == AV_SAMPLE_FMT_S16P)
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -329,7 +329,7 @@ bool FFmpegAudioDecoder::ConfigureDecode
+     }
+   }
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec ||
+       avcodec_open2(codec_context_.get(), codec, &codec_options) < 0) {
+     DLOG(ERROR) << "Could not initialize audio decoder: "
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -59,7 +59,6 @@ static int64_t AVIOSeekOperation(void* o
+ }
+ 
+ void FFmpegGlue::InitializeFFmpeg() {
+-  av_register_all();
+ }
+ 
+ static void LogContainer(bool is_local_file,
+@@ -95,9 +94,6 @@ FFmpegGlue::FFmpegGlue(FFmpegURLProtocol
+   // Enable fast, but inaccurate seeks for MP3.
+   format_context_->flags |= AVFMT_FLAG_FAST_SEEK;
+ 
+-  // Ensures we can read out various metadata bits like vp8 alpha.
+-  format_context_->flags |= AVFMT_FLAG_KEEP_SIDE_DATA;
+-
+   // Ensures format parsing errors will bail out. From an audit on 11/2017, all
+   // instances were real failures. Solves bugs like http://crbug.com/710791.
+   format_context_->error_recognition |= AV_EF_EXPLODE;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -391,7 +391,7 @@ bool FFmpegVideoDecoder::ConfigureDecode
+   if (decode_nalus_)
+     codec_context_->flags2 |= AV_CODEC_FLAG2_CHUNKS;
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
+     ReleaseFFmpegResources();
+     return false;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/media_file_checker.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/media_file_checker.cc
+--- a/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -68,7 +68,7 @@ bool MediaFileChecker::Start(base::TimeD
+       auto context = AVStreamToAVCodecContext(format_context->streams[i]);
+       if (!context)
+         continue;
+-      AVCodec* codec = avcodec_find_decoder(cp->codec_id);
++      const AVCodec* codec = avcodec_find_decoder(cp->codec_id);
+       if (codec && avcodec_open2(context.get(), codec, nullptr) >= 0) {
+         auto loop = std::make_unique<FFmpegDecodingLoop>(context.get());
+         stream_contexts[i] = {std::move(context), std::move(loop)};
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc qtwebengine-5.15.10/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc
+--- a/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -203,7 +203,7 @@ int32_t H264DecoderImpl::InitDecode(cons
+   // a pointer |this|.
+   av_context_->opaque = this;
+ 
+-  AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
+   if (!codec) {
+     // This is an indication that FFmpeg has not been initialized or it has not
+     // been compiled/initialized with the correct set of codecs.
diff --git a/srcpkgs/qt5-webengine/template b/srcpkgs/qt5-webengine/template
index 679d0fa2ad84b..b89fe4c1ad50a 100644
--- a/srcpkgs/qt5-webengine/template
+++ b/srcpkgs/qt5-webengine/template
@@ -1,9 +1,9 @@
 # Template file for 'qt5-webengine'
 pkgname=qt5-webengine
-version=5.15.11
-revision=4
+version=5.15.13
+revision=1
 _version="${version}-lts"
-_chromium_commit=be349eaf62e77955791d7bf29f893f1e8a37daf4
+_chromium_commit=e48df7803c7c98b0b2471c94057d32e44a301ad5
 archs="x86_64* i686* armv[67]* ppc64* aarch64*"
 create_wrksrc=yes
 build_style=qmake
@@ -32,8 +32,8 @@ license="GPL-3.0-or-later, LGPL-3.0-or-later"
 homepage="https://qt.io/"
 distfiles="https://github.com/qt/qtwebengine/archive/v${_version}.tar.gz
  https://github.com/qt/qtwebengine-chromium/archive/${_chromium_commit}.tar.gz"
-checksum="aa7466356c450c5f5870f979b93cd7e7e62da1165c328ffcab1a9928db18ad67
- 6f47ed8ab8cc062411f6f206da6353bc8263d6ed6d6290c689a05c01d91f646b"
+checksum="4b59838ed75ef788b59e1e412535a0e42dd9d311661fdeadb191b581ba815c63
+ a91686562b1d4e8b220e0bbcbab5feb64630e2de974b35ac034bf388af771a6c"
 
 no_generic_pkgconfig_link=yes
 build_options="sndio pipewire"

From e2a03b224ef19578ea026fb63beebeef81b44b1c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 067/115] qt5: update to 5.15.8

---
 ...erywhere-opensource-src-5.15.8-kf5-1.patch | 12913 ++++++++++++++++
 srcpkgs/qt5/template                          |    12 +-
 2 files changed, 12919 insertions(+), 6 deletions(-)
 create mode 100644 srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch

diff --git a/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch b/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch
new file mode 100644
index 0000000000000..966c98bcd3bb1
--- /dev/null
+++ b/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch
@@ -0,0 +1,12913 @@
+Submitted By:            Pierre Labastie <pierre_dot_labastie_at_neuf_dot_fr>
+Date:                    2023-01-05
+Initial Package Version: 5.15.8
+Upstream Status:         Applied (according to KDE)
+Origin:                  KDE patch set
+Description:             Patch set maintained by the KDE folks
+see https://dot.kde.org/2021/04/06/announcing-kdes-qt-5-patch-collection
+Patch generated using the procedure in
+https://wiki.linuxfromscratch.org/blfs/ticket/17476#comment:3
+
+Submodule qtbase 4ee4fc18..9cf586d6:
+diff --git a/qtbase/mkspecs/common/android/qplatformdefs.h b/qtbase/mkspecs/common/android/qplatformdefs.h
+index f75bc4093b..2bd59410d4 100644
+--- a/qtbase/mkspecs/common/android/qplatformdefs.h
++++ b/qtbase/mkspecs/common/android/qplatformdefs.h
+@@ -144,11 +144,7 @@
+ #define QT_SIGNAL_ARGS          int
+ #define QT_SIGNAL_IGNORE        SIG_IGN
+ 
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+ #define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+ 
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+diff --git a/qtbase/mkspecs/features/mac/sdk.mk b/qtbase/mkspecs/features/mac/sdk.mk
+index f30b5830b4..a32ceacb6c 100644
+--- a/qtbase/mkspecs/features/mac/sdk.mk
++++ b/qtbase/mkspecs/features/mac/sdk.mk
+@@ -1,6 +1,6 @@
+ 
+ ifeq ($(QT_MAC_SDK_NO_VERSION_CHECK),)
+-    CHECK_SDK_COMMAND = /usr/bin/xcrun --sdk $(EXPORT_QMAKE_MAC_SDK) -show-sdk-version 2>&1
++    CHECK_SDK_COMMAND = /usr/bin/xcrun --sdk $(EXPORT_QMAKE_MAC_SDK) -show-sdk-version 2>/dev/null
+     CURRENT_MAC_SDK_VERSION := $(shell DEVELOPER_DIR=$(EXPORT_QMAKE_XCODE_DEVELOPER_PATH) $(CHECK_SDK_COMMAND))
+     ifneq ($(CURRENT_MAC_SDK_VERSION),$(EXPORT_QMAKE_MAC_SDK_VERSION))
+         # We don't want to complain about out of date SDK unless the target needs to be remade.
+diff --git a/qtbase/mkspecs/linux-clang/qplatformdefs.h b/qtbase/mkspecs/linux-clang/qplatformdefs.h
+index a818d973f0..c1ab72fbc6 100644
+--- a/qtbase/mkspecs/linux-clang/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-clang/qplatformdefs.h
+@@ -79,14 +79,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-g++/qplatformdefs.h b/qtbase/mkspecs/linux-g++/qplatformdefs.h
+index 13523f0702..4d2750d9ec 100644
+--- a/qtbase/mkspecs/linux-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-g++/qplatformdefs.h
+@@ -79,14 +79,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ < 2)
+-#define QT_SOCKLEN_T            int
+-#else
+-#define QT_SOCKLEN_T            socklen_t
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-llvm/qplatformdefs.h b/qtbase/mkspecs/linux-llvm/qplatformdefs.h
+index dc750ab1ef..d3cc39b47f 100644
+--- a/qtbase/mkspecs/linux-llvm/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-llvm/qplatformdefs.h
+@@ -80,14 +80,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h b/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
+index 4c4e53da2a..83baffb3e3 100644
+--- a/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
+@@ -85,16 +85,9 @@
+ #include "../common/posix/qplatformdefs.h"
+ 
+ #undef QT_OPEN_LARGEFILE
+-#undef QT_SOCKLEN_T
+ 
+ #define QT_OPEN_LARGEFILE       0
+ 
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #ifndef SIOCGIFBRDADDR
+ #  define SIOCGIFBRDADDR 0x8919
+ #endif
+diff --git a/qtbase/mkspecs/lynxos-g++/qplatformdefs.h b/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
+index 4339ea2b23..6007af0055 100644
+--- a/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
+@@ -72,14 +72,6 @@
+ 
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp b/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
+index c3c184258f..32af3f8f29 100644
+--- a/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
++++ b/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
+@@ -10,6 +10,7 @@
+ #include "libANGLE/HandleAllocator.h"
+ 
+ #include <algorithm>
++#include <limits>
+ 
+ #include "common/debug.h"
+ 
+diff --git a/qtbase/src/3rdparty/forkfd/forkfd_linux.c b/qtbase/src/3rdparty/forkfd/forkfd_linux.c
+index ffe0e9a5e2..b1f5408d11 100644
+--- a/qtbase/src/3rdparty/forkfd/forkfd_linux.c
++++ b/qtbase/src/3rdparty/forkfd/forkfd_linux.c
+@@ -82,7 +82,8 @@ static int sys_clone(unsigned long cloneflags, int *ptid)
+     return syscall(__NR_clone, cloneflags, child_stack, stack_size, ptid, newtls, ctid);
+ #elif defined(__arc__) || defined(__arm__) || defined(__aarch64__) || defined(__mips__) || \
+     defined(__nds32__) || defined(__hppa__) || defined(__powerpc__) || defined(__i386__) || \
+-    defined(__x86_64__) || defined(__xtensa__) || defined(__alpha__) || defined(__riscv)
++    defined(__x86_64__) || defined(__xtensa__) || defined(__alpha__) || defined(__riscv) || \
++    defined(__loongarch__)
+     /* ctid and newtls are inverted on CONFIG_CLONE_BACKWARDS architectures,
+      * but since both values are 0, there's no harm. */
+     return syscall(__NR_clone, cloneflags, child_stack, ptid, ctid, newtls);
+diff --git a/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java b/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
+index 5792b5b2f5..2f74750fcf 100644
+--- a/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
++++ b/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
+@@ -116,6 +116,7 @@ public class QtNative
+     public static QtThread m_qtThread = new QtThread();
+     private static HashMap<String, Uri> m_cachedUris = new HashMap<String, Uri>();
+     private static ArrayList<String> m_knownDirs = new ArrayList<String>();
++    private static final String NoPermissionErrorMessage = "No permissions to open Uri";
+ 
+     private static final Runnable runPendingCppRunnablesRunnable = new Runnable() {
+         @Override
+@@ -193,11 +194,10 @@ public class QtNative
+                     return iterUri;
+             }
+ 
+-            // Android 6 and earlier could still manage to open the file so we can return the
+-            // parsed uri here
+-            if (Build.VERSION.SDK_INT < 24)
+-                return parsedUri;
+-            return null;
++            // if we only have transient permissions on uri all the above will fail,
++            // but we will be able to read the file anyway, so continue with uri here anyway
++            // and check for SecurityExceptions later
++            return parsedUri;
+         } catch (SecurityException e) {
+             e.printStackTrace();
+             return null;
+@@ -244,7 +244,7 @@ public class QtNative
+         int error = -1;
+ 
+         if (uri == null) {
+-            Log.e(QtTAG, "openFdForContentUrl(): No permissions to open Uri");
++            Log.e(QtTAG, "openFdForContentUrl(): " + NoPermissionErrorMessage);
+             return error;
+         }
+ 
+@@ -254,12 +254,13 @@ public class QtNative
+             return fdDesc.detachFd();
+         } catch (FileNotFoundException e) {
+             e.printStackTrace();
+-            return error;
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "openFdForContentUrl(): Invalid Uri");
+             e.printStackTrace();
+-            return error;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return error;
+     }
+ 
+     public static long getSize(Context context, String contentUrl)
+@@ -270,7 +271,7 @@ public class QtNative
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+ 
+         if (uri == null) {
+-            Log.e(QtTAG, "getSize(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return size;
+         } else if (!m_cachedUris.containsKey(contentUrl)) {
+             m_cachedUris.put(contentUrl, uri);
+@@ -288,12 +289,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "getSize(): Invalid Uri");
+             e.printStackTrace();
+-            return size;
+         }  catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "getSize(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return size;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return size;
+     }
+ 
+     public static boolean checkFileExists(Context context, String contentUrl)
+@@ -303,7 +305,7 @@ public class QtNative
+         if (uri == null)
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+         if (uri == null) {
+-            Log.e(QtTAG, "checkFileExists(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return exists;
+         } else {
+             if (!m_cachedUris.containsKey(contentUrl))
+@@ -321,12 +323,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "checkFileExists(): Invalid Uri");
+             e.printStackTrace();
+-            return exists;
+         } catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "checkFileExists(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return false;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return exists;
+     }
+ 
+     public static boolean checkIfWritable(Context context, String contentUrl)
+@@ -344,7 +347,7 @@ public class QtNative
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+         }
+         if (uri == null) {
+-            Log.e(QtTAG, "isDir(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return isDir;
+         } else {
+             if (!m_cachedUris.containsKey(contentUrl))
+@@ -374,12 +377,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "checkIfDir(): Invalid Uri");
+             e.printStackTrace();
+-            return false;
+         } catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "checkIfDir(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return false;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return false;
+     }
+     public static String[] listContentsFromTreeUri(Context context, String contentUrl)
+     {
+diff --git a/qtbase/src/concurrent/qtconcurrentreducekernel.h b/qtbase/src/concurrent/qtconcurrentreducekernel.h
+index 8f9a938952..a98dedef2e 100644
+--- a/qtbase/src/concurrent/qtconcurrentreducekernel.h
++++ b/qtbase/src/concurrent/qtconcurrentreducekernel.h
+@@ -212,11 +212,13 @@ public:
+ 
+     inline bool shouldThrottle()
+     {
++        std::lock_guard<QMutex> locker(mutex);
+         return (resultsMapSize > (ReduceQueueThrottleLimit * threadCount));
+     }
+ 
+     inline bool shouldStartThread()
+     {
++        std::lock_guard<QMutex> locker(mutex);
+         return (resultsMapSize <= (ReduceQueueStartLimit * threadCount));
+     }
+ };
+diff --git a/qtbase/src/concurrent/qtconcurrentthreadengine.cpp b/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
+index ea6ce3ac42..7f91a2ba68 100644
+--- a/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
++++ b/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
+@@ -176,6 +176,39 @@ void ThreadEngineBase::startSingleThreaded()
+     finish();
+ }
+ 
++void ThreadEngineBase::startBlocking()
++{
++    start();
++    barrier.acquire();
++    startThreads();
++
++    bool throttled = false;
++#ifndef QT_NO_EXCEPTIONS
++    try {
++#endif
++        while (threadFunction() == ThrottleThread) {
++            if (threadThrottleExit()) {
++                throttled = true;
++                break;
++            }
++        }
++#ifndef QT_NO_EXCEPTIONS
++    } catch (QException &e) {
++        handleException(e);
++    } catch (...) {
++        handleException(QUnhandledException());
++    }
++#endif
++
++    if (throttled == false) {
++        barrier.release();
++    }
++
++    barrier.wait();
++    finish();
++    exceptionStore.throwPossibleException();
++}
++
+ void ThreadEngineBase::startThread()
+ {
+     startThreadInternal();
+diff --git a/qtbase/src/concurrent/qtconcurrentthreadengine.h b/qtbase/src/concurrent/qtconcurrentthreadengine.h
+index 7c30cebdbc..a4c8548cc4 100644
+--- a/qtbase/src/concurrent/qtconcurrentthreadengine.h
++++ b/qtbase/src/concurrent/qtconcurrentthreadengine.h
+@@ -91,6 +91,7 @@ public:
+     ThreadEngineBase();
+     virtual ~ThreadEngineBase();
+     void startSingleThreaded();
++    void startBlocking();
+     void startThread();
+     bool isCanceled();
+     void waitForResume();
+@@ -143,6 +144,15 @@ public:
+         return result();
+     }
+ 
++    // Runs the user algorithm using multiple threads.
++    // This function blocks until the algorithm is finished,
++    // and then returns the result.
++    T *startBlocking()
++    {
++        ThreadEngineBase::startBlocking();
++        return result();
++    }
++
+     // Runs the user algorithm using multiple threads.
+     // Does not block, returns a future.
+     QFuture<T> startAsynchronously()
+@@ -223,6 +233,13 @@ class ThreadEngineStarter : public ThreadEngineStarterBase<T>
+ public:
+     ThreadEngineStarter(TypedThreadEngine *eng)
+         : Base(eng) { }
++
++    T startBlocking()
++    {
++        T t = *this->threadEngine->startBlocking();
++        delete this->threadEngine;
++        return t;
++    }
+ };
+ 
+ // Full template specialization where T is void.
+@@ -232,6 +249,12 @@ class ThreadEngineStarter<void> : public ThreadEngineStarterBase<void>
+ public:
+     ThreadEngineStarter(ThreadEngine<void> *_threadEngine)
+         : ThreadEngineStarterBase<void>(_threadEngine) {}
++
++    void startBlocking()
++    {
++        this->threadEngine->startBlocking();
++        delete this->threadEngine;
++    }
+ };
+ 
+ //! [qtconcurrentthreadengine-1]
+diff --git a/qtbase/src/corelib/animation/qvariantanimation.cpp b/qtbase/src/corelib/animation/qvariantanimation.cpp
+index 98b02f0202..eac1524107 100644
+--- a/qtbase/src/corelib/animation/qvariantanimation.cpp
++++ b/qtbase/src/corelib/animation/qvariantanimation.cpp
+@@ -276,7 +276,9 @@ void QVariantAnimationPrivate::setCurrentValueForProgress(const qreal progress)
+ 
+     const qreal startProgress = currentInterval.start.first;
+     const qreal endProgress = currentInterval.end.first;
+-    const qreal localProgress = (progress - startProgress) / (endProgress - startProgress);
++    const qreal localProgress =
++            qIsNull(progress - startProgress) ? 0.0 // avoid 0/0 below
++            /* else */                        : (progress - startProgress) / (endProgress - startProgress);
+ 
+     QVariant ret = q->interpolated(currentInterval.start.second,
+                                    currentInterval.end.second,
+diff --git a/qtbase/src/corelib/global/qnamespace.h b/qtbase/src/corelib/global/qnamespace.h
+index ad4150b317..bf19b1627b 100644
+--- a/qtbase/src/corelib/global/qnamespace.h
++++ b/qtbase/src/corelib/global/qnamespace.h
+@@ -1864,7 +1864,7 @@ public:
+     QT_Q_ENUM(TimerType)
+     QT_Q_ENUM(ScrollPhase)
+     QT_Q_ENUM(MouseEventSource)
+-    QT_Q_FLAG(MouseEventFlag)
++    QT_Q_FLAG(MouseEventFlags)
+     QT_Q_ENUM(ChecksumType)
+     QT_Q_ENUM(HighDpiScaleFactorRoundingPolicy)
+     QT_Q_ENUM(TabFocusBehavior)
+diff --git a/qtbase/src/corelib/global/qrandom.cpp b/qtbase/src/corelib/global/qrandom.cpp
+index 10672c1f92..25f87c7e6a 100644
+--- a/qtbase/src/corelib/global/qrandom.cpp
++++ b/qtbase/src/corelib/global/qrandom.cpp
+@@ -383,7 +383,6 @@ struct QRandomGenerator::SystemAndGlobalGenerators
+ 
+         constexpr SystemAndGlobalGenerators g = {};
+         Q_UNUSED(g);
+-        Q_STATIC_ASSERT(std::is_literal_type<SystemAndGlobalGenerators>::value);
+ #endif
+     }
+ 
+diff --git a/qtbase/src/corelib/io/qbuffer.cpp b/qtbase/src/corelib/io/qbuffer.cpp
+index 595fcd2724..032c0ddd4b 100644
+--- a/qtbase/src/corelib/io/qbuffer.cpp
++++ b/qtbase/src/corelib/io/qbuffer.cpp
+@@ -41,6 +41,8 @@
+ #include <QtCore/qmetaobject.h>
+ #include "private/qiodevice_p.h"
+ 
++#include <limits>
++
+ QT_BEGIN_NAMESPACE
+ 
+ /** QBufferPrivate **/
+@@ -366,7 +368,9 @@ qint64 QBuffer::size() const
+ bool QBuffer::seek(qint64 pos)
+ {
+     Q_D(QBuffer);
+-    if (pos > d->buf->size() && isWritable()) {
++    const auto oldBufSize = d->buf->size();
++    constexpr qint64 MaxSeekPos = (std::numeric_limits<decltype(oldBufSize)>::max)();
++    if (pos <= MaxSeekPos && pos > oldBufSize && isWritable()) {
+         if (seek(d->buf->size())) {
+             const qint64 gapSize = pos - d->buf->size();
+             if (write(QByteArray(gapSize, 0)) != gapSize) {
+@@ -377,7 +381,7 @@ bool QBuffer::seek(qint64 pos)
+             return false;
+         }
+     } else if (pos > d->buf->size() || pos < 0) {
+-        qWarning("QBuffer::seek: Invalid pos: %d", int(pos));
++        qWarning("QBuffer::seek: Invalid pos: %lld", pos);
+         return false;
+     }
+     return QIODevice::seek(pos);
+diff --git a/qtbase/src/corelib/io/qfilesystemengine_win.cpp b/qtbase/src/corelib/io/qfilesystemengine_win.cpp
+index 81d3a71986..c86ed1f9b0 100644
+--- a/qtbase/src/corelib/io/qfilesystemengine_win.cpp
++++ b/qtbase/src/corelib/io/qfilesystemengine_win.cpp
+@@ -664,14 +664,14 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry)
+     return QFileSystemEntry(ret, QFileSystemEntry::FromInternalPath());
+ }
+ 
+-#if defined(Q_CC_MINGW) && WINVER < 0x0602 //  Windows 8 onwards
++#if defined(Q_CC_MINGW) && WINVER < 0x0602 && _WIN32_WINNT < _WIN32_WINNT_WIN8 //  Windows 8 onwards
+ 
+ typedef struct _FILE_ID_INFO {
+     ULONGLONG VolumeSerialNumber;
+     FILE_ID_128 FileId;
+ } FILE_ID_INFO, *PFILE_ID_INFO;
+ 
+-#endif // if defined (Q_CC_MINGW) && WINVER < 0x0602
++#endif // if defined(Q_CC_MINGW) && WINVER < 0x0602 && _WIN32_WINNT < _WIN32_WINNT_WIN8
+ 
+ // File ID for Windows up to version 7 and FAT32 drives
+ static inline QByteArray fileId(HANDLE handle)
+diff --git a/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp b/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
+index 94d9d06bcb..27e0b13b0b 100644
+--- a/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
++++ b/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
+@@ -366,7 +366,9 @@ void QInotifyFileSystemWatcherEngine::readFromInotify()
+     // qDebug("QInotifyFileSystemWatcherEngine::readFromInotify");
+ 
+     int buffSize = 0;
+-    ioctl(inotifyFd, FIONREAD, (char *) &buffSize);
++    if (ioctl(inotifyFd, FIONREAD, (char *) &buffSize) == -1 || buffSize == 0)
++        return;
++
+     QVarLengthArray<char, 4096> buffer(buffSize);
+     buffSize = read(inotifyFd, buffer.data(), buffSize);
+     char *at = buffer.data();
+diff --git a/qtbase/src/corelib/io/qlockfile_win.cpp b/qtbase/src/corelib/io/qlockfile_win.cpp
+index 277f8d4230..38ecef5550 100644
+--- a/qtbase/src/corelib/io/qlockfile_win.cpp
++++ b/qtbase/src/corelib/io/qlockfile_win.cpp
+@@ -48,6 +48,8 @@
+ #include "QtCore/qdebug.h"
+ #include "QtCore/qthread.h"
+ 
++#include "private/qsystemlibrary_p.h"
++
+ QT_BEGIN_NAMESPACE
+ 
+ static inline bool fileExists(const wchar_t *fileName)
+@@ -150,7 +152,7 @@ QString QLockFilePrivate::processNameByPid(qint64 pid)
+ #if !defined(Q_OS_WINRT)
+     typedef DWORD (WINAPI *GetModuleFileNameExFunc)(HANDLE, HMODULE, LPTSTR, DWORD);
+ 
+-    HMODULE hPsapi = LoadLibraryA("psapi");
++    HMODULE hPsapi = QSystemLibrary::load(L"psapi");
+     if (!hPsapi)
+         return QString();
+     GetModuleFileNameExFunc qGetModuleFileNameEx = reinterpret_cast<GetModuleFileNameExFunc>(
+diff --git a/qtbase/src/corelib/io/qprocess_unix.cpp b/qtbase/src/corelib/io/qprocess_unix.cpp
+index 50390e57f5..15c8f30745 100644
+--- a/qtbase/src/corelib/io/qprocess_unix.cpp
++++ b/qtbase/src/corelib/io/qprocess_unix.cpp
+@@ -1,7 +1,7 @@
+ /****************************************************************************
+ **
+ ** Copyright (C) 2016 The Qt Company Ltd.
+-** Copyright (C) 2016 Intel Corporation.
++** Copyright (C) 2022 Intel Corporation.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtCore module of the Qt Toolkit.
+@@ -422,14 +422,15 @@ void QProcessPrivate::startProcess()
+     // Add the program name to the argument list.
+     argv[0] = nullptr;
+     if (!program.contains(QLatin1Char('/'))) {
++        // findExecutable() returns its argument if it's an absolute path,
++        // otherwise it searches $PATH; returns empty if not found (we handle
++        // that case much later)
+         const QString &exeFilePath = QStandardPaths::findExecutable(program);
+-        if (!exeFilePath.isEmpty()) {
+-            const QByteArray &tmp = QFile::encodeName(exeFilePath);
+-            argv[0] = ::strdup(tmp.constData());
+-        }
+-    }
+-    if (!argv[0])
++        const QByteArray &tmp = QFile::encodeName(exeFilePath);
++        argv[0] = ::strdup(tmp.constData());
++    } else {
+         argv[0] = ::strdup(encodedProgramName.constData());
++    }
+ 
+     // Add every argument to the list
+     for (int i = 0; i < arguments.count(); ++i)
+@@ -983,15 +984,16 @@ bool QProcessPrivate::startDetached(qint64 *pid)
+                 envp = _q_dupEnvironment(environment.d.constData()->vars, &envc);
+             }
+ 
+-            QByteArray tmp;
+             if (!program.contains(QLatin1Char('/'))) {
++                // findExecutable() returns its argument if it's an absolute path,
++                // otherwise it searches $PATH; returns empty if not found (we handle
++                // that case much later)
+                 const QString &exeFilePath = QStandardPaths::findExecutable(program);
+-                if (!exeFilePath.isEmpty())
+-                    tmp = QFile::encodeName(exeFilePath);
++                const QByteArray &tmp = QFile::encodeName(exeFilePath);
++                argv[0] = ::strdup(tmp.constData());
++            } else {
++                argv[0] = ::strdup(QFile::encodeName(program));
+             }
+-            if (tmp.isEmpty())
+-                tmp = QFile::encodeName(program);
+-            argv[0] = tmp.data();
+ 
+             if (envp)
+                 qt_safe_execve(argv[0], argv, envp);
+diff --git a/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp b/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
+index 3a79c502af..997a634e76 100644
+--- a/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
++++ b/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
+@@ -3196,9 +3196,8 @@ bool QAbstractItemModel::beginMoveColumns(const QModelIndex &sourceParent, int s
+     destinationChange.needsAdjust = destinationParent.isValid() && destinationParent.row() >= sourceLast && destinationParent.parent() == sourceParent;
+     d->changes.push(destinationChange);
+ 
+-    d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Horizontal);
+-
+     emit columnsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, QPrivateSignal());
++    d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Horizontal);
+     return true;
+ }
+ 
+@@ -3231,7 +3230,6 @@ void QAbstractItemModel::endMoveColumns()
+       adjustedSource = createIndex(adjustedSource.row(), adjustedSource.column() + numMoved, adjustedSource.internalPointer());
+ 
+     d->itemsMoved(adjustedSource, removeChange.first, removeChange.last, adjustedDestination, insertChange.first, Qt::Horizontal);
+-
+     emit columnsMoved(adjustedSource, removeChange.first, removeChange.last, adjustedDestination, insertChange.first, QPrivateSignal());
+ }
+ 
+diff --git a/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+index dc6379d9fb..c5e287ee84 100644
+--- a/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
++++ b/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+@@ -939,8 +939,9 @@ void QSortFilterProxyModelPrivate::insert_source_items(
+                 q->beginInsertColumns(proxy_parent, proxy_start, proxy_end);
+         }
+ 
+-        for (int i = 0; i < source_items.size(); ++i)
+-            proxy_to_source.insert(proxy_start + i, source_items.at(i));
++        // TODO: use the range QList::insert() overload once it is implemented (QTBUG-58633).
++        proxy_to_source.insert(proxy_start, source_items.size(), 0);
++        std::copy(source_items.cbegin(), source_items.cend(), proxy_to_source.begin() + proxy_start);
+ 
+         build_source_to_proxy_mapping(proxy_to_source, source_to_proxy);
+ 
+@@ -3123,8 +3124,9 @@ bool QSortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex &
+ 
+     if (d->filter_data.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();
+@@ -3133,9 +3135,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.hasMatch(key);
+ }
+diff --git a/qtbase/src/corelib/kernel/qcoreapplication.cpp b/qtbase/src/corelib/kernel/qcoreapplication.cpp
+index ca2864df83..132b2eae52 100644
+--- a/qtbase/src/corelib/kernel/qcoreapplication.cpp
++++ b/qtbase/src/corelib/kernel/qcoreapplication.cpp
+@@ -1157,7 +1157,7 @@ static bool doNotify(QObject *receiver, QEvent *event)
+ bool QCoreApplicationPrivate::sendThroughApplicationEventFilters(QObject *receiver, QEvent *event)
+ {
+     // We can't access the application event filters outside of the main thread (race conditions)
+-    Q_ASSERT(receiver->d_func()->threadData.loadRelaxed()->thread.loadAcquire() == mainThread());
++    Q_ASSERT(receiver->d_func()->threadData.loadAcquire()->thread.loadRelaxed() == mainThread());
+ 
+     if (extraData) {
+         // application event filters are only called for objects in the GUI thread
+diff --git a/qtbase/src/corelib/kernel/qobject.cpp b/qtbase/src/corelib/kernel/qobject.cpp
+index 1eb79138d9..36cd780ee1 100644
+--- a/qtbase/src/corelib/kernel/qobject.cpp
++++ b/qtbase/src/corelib/kernel/qobject.cpp
+@@ -1010,7 +1010,7 @@ QObject::~QObject()
+         emit destroyed(this);
+     }
+ 
+-    if (d->declarativeData) {
++    if (!d->isDeletingChildren && d->declarativeData) {
+         if (static_cast<QAbstractDeclarativeDataImpl*>(d->declarativeData)->ownedByQml1) {
+             if (QAbstractDeclarativeData::destroyed_qml1)
+                 QAbstractDeclarativeData::destroyed_qml1(d->declarativeData, this);
+@@ -1580,7 +1580,7 @@ void QObject::moveToThread(QThread *targetThread)
+ 
+     QThreadData *currentData = QThreadData::current();
+     QThreadData *targetData = targetThread ? QThreadData::get2(targetThread) : nullptr;
+-    QThreadData *thisThreadData = d->threadData.loadRelaxed();
++    QThreadData *thisThreadData = d->threadData.loadAcquire();
+     if (!thisThreadData->thread.loadAcquire() && currentData == targetData) {
+         // one exception to the rule: we allow moving objects with no thread affinity to the current thread
+         currentData = d->threadData;
+@@ -2620,7 +2620,7 @@ int QObject::receivers(const char *signal) const
+         if (!d->isSignalConnected(signal_index))
+             return receivers;
+ 
+-        if (d->declarativeData && QAbstractDeclarativeData::receivers) {
++        if (!d->isDeletingChildren && d->declarativeData && QAbstractDeclarativeData::receivers) {
+             receivers += QAbstractDeclarativeData::receivers(d->declarativeData, this,
+                                                              signal_index);
+         }
+diff --git a/qtbase/src/corelib/kernel/qobject_p.h b/qtbase/src/corelib/kernel/qobject_p.h
+index 0b827a52ca..13ffb88999 100644
+--- a/qtbase/src/corelib/kernel/qobject_p.h
++++ b/qtbase/src/corelib/kernel/qobject_p.h
+@@ -444,7 +444,7 @@ inline void QObjectPrivate::checkForIncompatibleLibraryVersion(int version) cons
+ 
+ inline bool QObjectPrivate::isDeclarativeSignalConnected(uint signal_index) const
+ {
+-    return declarativeData && QAbstractDeclarativeData::isSignalConnected
++    return !isDeletingChildren && declarativeData && QAbstractDeclarativeData::isSignalConnected
+             && QAbstractDeclarativeData::isSignalConnected(declarativeData, q_func(), signal_index);
+ }
+ 
+diff --git a/qtbase/src/corelib/kernel/qtranslator.cpp b/qtbase/src/corelib/kernel/qtranslator.cpp
+index 2812ffb7ea..bc0177c5ec 100644
+--- a/qtbase/src/corelib/kernel/qtranslator.cpp
++++ b/qtbase/src/corelib/kernel/qtranslator.cpp
+@@ -902,7 +902,7 @@ static QString getMessage(const uchar *m, const uchar *end, const char *context,
+             goto end;
+         case Tag_Translation: {
+             int len = read32(m);
+-            if (len % 1)
++            if (len & 1)
+                 return QString();
+             m += 4;
+             if (!numerus--) {
+diff --git a/qtbase/src/corelib/mimetypes/qmimedatabase.cpp b/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
+index 9de22cef33..ff868a3268 100644
+--- a/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
+@@ -389,20 +389,23 @@ QMimeType QMimeDatabasePrivate::mimeTypeForFileNameAndData(const QString &fileNa
+         // Disambiguate conflicting extensions (if magic matching found something)
+         if (candidateByData.isValid() && magicAccuracy > 0) {
+             const QString sniffedMime = candidateByData.name();
+-            // If the sniffedMime matches a glob match, use it
++            // If the sniffedMime matches a highest-weight glob match, use it
+             if (candidatesByName.m_matchingMimeTypes.contains(sniffedMime)) {
+                 *accuracyPtr = 100;
+                 return candidateByData;
+             }
+-            for (const QString &m : qAsConst(candidatesByName.m_matchingMimeTypes)) {
++            for (const QString &m : qAsConst(candidatesByName.m_allMatchingMimeTypes)) {
+                 if (inherits(m, sniffedMime)) {
+                     // We have magic + pattern pointing to this, so it's a pretty good match
+                     *accuracyPtr = 100;
+                     return mimeTypeForName(m);
+                 }
+             }
+-            *accuracyPtr = magicAccuracy;
+-            return candidateByData;
++            if (candidatesByName.m_allMatchingMimeTypes.isEmpty()) {
++                // No glob, use magic
++                *accuracyPtr = magicAccuracy;
++                return candidateByData;
++            }
+         }
+     }
+ 
+diff --git a/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp b/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
+index a81112d227..fa8f4c545d 100644
+--- a/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
+@@ -83,7 +83,10 @@ void QMimeGlobMatchResult::addMatch(const QString &mimeType, int weight, const Q
+     }
+     if (!m_matchingMimeTypes.contains(mimeType)) {
+         m_matchingMimeTypes.append(mimeType);
+-        m_allMatchingMimeTypes.append(mimeType);
++        if (replace)
++            m_allMatchingMimeTypes.prepend(mimeType); // highest-weight first
++        else
++            m_allMatchingMimeTypes.append(mimeType);
+         m_knownSuffixLength = knownSuffixLength;
+     }
+ }
+@@ -94,7 +97,7 @@ QMimeGlobPattern::PatternType QMimeGlobPattern::detectPatternType(const QString
+     if (!patternLength)
+         return OtherPattern;
+ 
+-    const bool starCount = pattern.count(QLatin1Char('*')) == 1;
++    const int starCount = pattern.count(QLatin1Char('*'));
+     const bool hasSquareBracket = pattern.indexOf(QLatin1Char('[')) != -1;
+     const bool hasQuestionMark = pattern.indexOf(QLatin1Char('?')) != -1;
+ 
+@@ -106,10 +109,10 @@ QMimeGlobPattern::PatternType QMimeGlobPattern::detectPatternType(const QString
+             // Patterns like "README*" (well this is currently the only one like that...)
+             if (pattern.at(patternLength - 1) == QLatin1Char('*'))
+                 return PrefixPattern;
+-        }
+-        // Names without any wildcards like "README"
+-        if (starCount == 0)
++        } else if (starCount == 0) {
++            // Names without any wildcards like "README"
+             return LiteralPattern;
++        }
+     }
+ 
+     if (pattern == QLatin1String("[0-9][0-9][0-9].vdr"))
+diff --git a/qtbase/src/corelib/mimetypes/qmimeprovider.cpp b/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
+index 258dddf8cb..4642d0f2d0 100644
+--- a/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
+@@ -244,15 +244,18 @@ void QMimeBinaryProvider::addFileNameMatches(const QString &fileName, QMimeGlobM
+     const QString lowerFileName = fileName.toLower();
+     // Check literals (e.g. "Makefile")
+     matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosLiteralListOffset), fileName);
+-    // Check complex globs (e.g. "callgrind.out[0-9]*")
+-    matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosGlobListOffset), fileName);
+     // Check the very common *.txt cases with the suffix tree
+-    const int reverseSuffixTreeOffset = m_cacheFile->getUint32(PosReverseSuffixTreeOffset);
+-    const int numRoots = m_cacheFile->getUint32(reverseSuffixTreeOffset);
+-    const int firstRootOffset = m_cacheFile->getUint32(reverseSuffixTreeOffset + 4);
+-    matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, lowerFileName, lowerFileName.length() - 1, false);
++    if (result.m_matchingMimeTypes.isEmpty()) {
++        const int reverseSuffixTreeOffset = m_cacheFile->getUint32(PosReverseSuffixTreeOffset);
++        const int numRoots = m_cacheFile->getUint32(reverseSuffixTreeOffset);
++        const int firstRootOffset = m_cacheFile->getUint32(reverseSuffixTreeOffset + 4);
++        matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, lowerFileName, lowerFileName.length() - 1, false);
++        if (result.m_matchingMimeTypes.isEmpty())
++            matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, fileName, fileName.length() - 1, true);
++    }
++    // Check complex globs (e.g. "callgrind.out[0-9]*" or "README*")
+     if (result.m_matchingMimeTypes.isEmpty())
+-        matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, fileName, fileName.length() - 1, true);
++        matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosGlobListOffset), fileName);
+ }
+ 
+ void QMimeBinaryProvider::matchGlobList(QMimeGlobMatchResult &result, CacheFile *cacheFile, int off, const QString &fileName)
+diff --git a/qtbase/src/corelib/serialization/qjsonparser.cpp b/qtbase/src/corelib/serialization/qjsonparser.cpp
+index 17e6f111ab..2e40b6c8fb 100644
+--- a/qtbase/src/corelib/serialization/qjsonparser.cpp
++++ b/qtbase/src/corelib/serialization/qjsonparser.cpp
+@@ -379,10 +379,30 @@ error:
+     return QCborValue();
+ }
+ 
++// We need to retain the _last_ value for any duplicate keys and we need to deref containers.
++// Therefore the manual implementation of std::unique().
++template<typename Iterator, typename Compare, typename Assign>
++static Iterator customAssigningUniqueLast(Iterator first, Iterator last,
++                                          Compare compare, Assign assign)
++{
++    first = std::adjacent_find(first, last, compare);
++    if (first == last)
++        return last;
++
++    Iterator result = first;
++    while (++first != last) {
++        if (!compare(*result, *first))
++            ++result;
++        if (result != first)
++            assign(*result, *first);
++    }
++
++    return ++result;
++}
++
+ static void sortContainer(QCborContainerPrivate *container)
+ {
+     using Forward = QJsonPrivate::KeyIterator;
+-    using Reverse = std::reverse_iterator<Forward>;
+     using Value = Forward::value_type;
+ 
+     auto compare = [container](const Value &a, const Value &b)
+@@ -420,17 +440,31 @@ static void sortContainer(QCborContainerPrivate *container)
+         }
+     };
+ 
+-    std::sort(Forward(container->elements.begin()), Forward(container->elements.end()),
+-              [&compare](const Value &a, const Value &b) { return compare(a, b) < 0; });
++    // The elements' containers are owned by the outer container, not by the elements themselves.
++    auto move = [](Forward::reference target, Forward::reference source)
++    {
++        QtCbor::Element &targetValue = target.value();
++
++        // If the target has a container, deref it before overwriting, so that we don't leak.
++        if (targetValue.flags & QtCbor::Element::IsContainer)
++            targetValue.container->deref();
++
++        // Do not move, so that we can clear the value afterwards.
++        target = source;
++
++        // Clear the source value, so that we don't store the same container twice.
++        source.value() = QtCbor::Element();
++    };
++
++    std::stable_sort(
++                Forward(container->elements.begin()), Forward(container->elements.end()),
++                [&compare](const Value &a, const Value &b) { return compare(a, b) < 0; });
+ 
+-    // We need to retain the _last_ value for any duplicate keys. Therefore the reverse dance here.
+-    auto it = std::unique(Reverse(container->elements.end()), Reverse(container->elements.begin()),
+-                          [&compare](const Value &a, const Value &b) {
+-        return compare(a, b) == 0;
+-    }).base().elementsIterator();
++    Forward result = customAssigningUniqueLast(
++                Forward(container->elements.begin()),  Forward(container->elements.end()),
++                [&compare](const Value &a, const Value &b) { return compare(a, b) == 0; }, move);
+ 
+-    // The erase from beginning is expensive but hopefully rare.
+-    container->elements.erase(container->elements.begin(), it);
++    container->elements.erase(result.elementsIterator(), container->elements.end());
+ }
+ 
+ 
+diff --git a/qtbase/src/corelib/serialization/qxmlstream.cpp b/qtbase/src/corelib/serialization/qxmlstream.cpp
+index b2f846544d..7cd457ba3a 100644
+--- a/qtbase/src/corelib/serialization/qxmlstream.cpp
++++ b/qtbase/src/corelib/serialization/qxmlstream.cpp
+@@ -980,7 +980,7 @@ inline uint QXmlStreamReaderPrivate::peekChar()
+ bool QXmlStreamReaderPrivate::scanUntil(const char *str, short tokenToInject)
+ {
+     int pos = textBuffer.size();
+-    int oldLineNumber = lineNumber;
++    const auto oldLineNumber = lineNumber;
+ 
+     uint c;
+     while ((c = getChar()) != StreamEOF) {
+diff --git a/qtbase/src/corelib/text/qstring.cpp b/qtbase/src/corelib/text/qstring.cpp
+index 3e88ab4859..8deeae47bb 100644
+--- a/qtbase/src/corelib/text/qstring.cpp
++++ b/qtbase/src/corelib/text/qstring.cpp
+@@ -12312,7 +12312,7 @@ static qsizetype qLastIndexOf(Haystack haystack0, qsizetype from,
+     const auto needle = needle0.data();
+     const auto *end = haystack;
+     haystack += from;
+-    const std::size_t sl_minus_1 = sl - 1;
++    const std::size_t sl_minus_1 = sl ? sl - 1 : 0;
+     const auto *n = needle + sl_minus_1;
+     const auto *h = haystack + sl_minus_1;
+     std::size_t hashNeedle = 0, hashHaystack = 0;
+diff --git a/qtbase/src/corelib/text/qstringiterator_p.h b/qtbase/src/corelib/text/qstringiterator_p.h
+index 219589b6e4..1d0c66cc78 100644
+--- a/qtbase/src/corelib/text/qstringiterator_p.h
++++ b/qtbase/src/corelib/text/qstringiterator_p.h
+@@ -61,6 +61,8 @@ class QStringIterator
+ {
+     QString::const_iterator i, pos, e;
+     Q_STATIC_ASSERT((std::is_same<QString::const_iterator, const QChar *>::value));
++    static bool less(const QChar *lhs, const QChar *rhs) noexcept
++    { return std::less<QString::const_iterator>{}(lhs, rhs); }
+ public:
+     explicit QStringIterator(QStringView string, qsizetype idx = 0)
+         : i(string.begin()),
+@@ -95,7 +97,8 @@ public:
+ 
+     inline void setPosition(QString::const_iterator position)
+     {
+-        Q_ASSERT_X(i <= position && position <= e, Q_FUNC_INFO, "position out of bounds");
++        Q_ASSERT_X(!less(position, i) && !less(e, position),
++                   Q_FUNC_INFO, "position out of bounds");
+         pos = position;
+     }
+ 
+@@ -103,7 +106,7 @@ public:
+ 
+     inline bool hasNext() const
+     {
+-        return pos < e;
++        return less(pos, e);
+     }
+ 
+     inline void advance()
+@@ -120,16 +123,20 @@ public:
+     {
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+-        if (Q_UNLIKELY((pos++)->isHighSurrogate()))
++        if (Q_UNLIKELY((pos++)->isHighSurrogate())) {
++            Q_ASSERT(hasNext() && pos->isLowSurrogate());
+             ++pos;
++        }
+     }
+ 
+     inline uint peekNextUnchecked() const
+     {
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+-        if (Q_UNLIKELY(pos->isHighSurrogate()))
++        if (Q_UNLIKELY(pos->isHighSurrogate())) {
++            Q_ASSERT(less(pos + 1, e) && pos[1].isLowSurrogate());
+             return QChar::surrogateToUcs4(pos[0], pos[1]);
++        }
+ 
+         return pos->unicode();
+     }
+@@ -155,8 +162,10 @@ public:
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+         const QChar cur = *pos++;
+-        if (Q_UNLIKELY(cur.isHighSurrogate()))
++        if (Q_UNLIKELY(cur.isHighSurrogate())) {
++            Q_ASSERT(hasNext() && pos->isLowSurrogate());
+             return QChar::surrogateToUcs4(cur, *pos++);
++        }
+         return cur.unicode();
+     }
+ 
+@@ -166,7 +175,7 @@ public:
+ 
+         const QChar uc = *pos++;
+         if (Q_UNLIKELY(uc.isSurrogate())) {
+-            if (Q_LIKELY(uc.isHighSurrogate() && pos < e && pos->isLowSurrogate()))
++            if (Q_LIKELY(uc.isHighSurrogate() && hasNext() && pos->isLowSurrogate()))
+                 return QChar::surrogateToUcs4(uc, *pos++);
+             return invalidAs;
+         }
+@@ -178,7 +187,7 @@ public:
+ 
+     inline bool hasPrevious() const
+     {
+-        return pos > i;
++        return less(i, pos);
+     }
+ 
+     inline void recede()
+@@ -196,16 +205,20 @@ public:
+     {
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+-        if (Q_UNLIKELY((--pos)->isLowSurrogate()))
++        if (Q_UNLIKELY((--pos)->isLowSurrogate())) {
++            Q_ASSERT(hasPrevious() && pos[-1].isHighSurrogate());
+             --pos;
++        }
+     }
+ 
+     inline uint peekPreviousUnchecked() const
+     {
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+-        if (Q_UNLIKELY(pos[-1].isLowSurrogate()))
++        if (Q_UNLIKELY(pos[-1].isLowSurrogate())) {
++            Q_ASSERT(less(i + 1, pos) && pos[-2].isHighSurrogate());
+             return QChar::surrogateToUcs4(pos[-2], pos[-1]);
++        }
+         return pos[-1].unicode();
+     }
+ 
+@@ -230,8 +243,10 @@ public:
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+         const QChar cur = *--pos;
+-        if (Q_UNLIKELY(cur.isLowSurrogate()))
++        if (Q_UNLIKELY(cur.isLowSurrogate())) {
++            Q_ASSERT(hasPrevious() && pos[-1].isHighSurrogate());
+             return QChar::surrogateToUcs4(*--pos, cur);
++        }
+         return cur.unicode();
+     }
+ 
+@@ -241,7 +256,7 @@ public:
+ 
+         const QChar uc = *--pos;
+         if (Q_UNLIKELY(uc.isSurrogate())) {
+-            if (Q_LIKELY(uc.isLowSurrogate() && pos > i && pos[-1].isHighSurrogate()))
++            if (Q_LIKELY(uc.isLowSurrogate() && hasPrevious() && pos[-1].isHighSurrogate()))
+                 return QChar::surrogateToUcs4(*--pos, uc);
+             return invalidAs;
+         }
+diff --git a/qtbase/src/corelib/thread/qfutex_p.h b/qtbase/src/corelib/thread/qfutex_p.h
+index f287b752d7..e294537787 100644
+--- a/qtbase/src/corelib/thread/qfutex_p.h
++++ b/qtbase/src/corelib/thread/qfutex_p.h
+@@ -52,6 +52,7 @@
+ //
+ 
+ #include <qglobal.h>
++#include <QtCore/qtsan_impl.h>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -106,16 +107,13 @@ namespace QtLinuxFutex {
+     inline int _q_futex(int *addr, int op, int val, quintptr val2 = 0,
+                         int *addr2 = nullptr, int val3 = 0) noexcept
+     {
+-        // A futex call ensures total ordering on the futex words
+-        // (in either success or failure of the call). Instruct TSAN accordingly,
+-        // as TSAN does not understand the futex(2) syscall.
+-        _q_tsan_release(addr, addr2);
++        QtTsan::futexRelease(addr, addr2);
+ 
+         // we use __NR_futex because some libcs (like Android's bionic) don't
+         // provide SYS_futex etc.
+         int result = syscall(__NR_futex, addr, op | FUTEX_PRIVATE_FLAG, val, val2, addr2, val3);
+ 
+-        _q_tsan_acquire(addr, addr2);
++        QtTsan::futexAcquire(addr, addr2);
+ 
+         return result;
+     }
+diff --git a/qtbase/src/corelib/thread/qmutex.cpp b/qtbase/src/corelib/thread/qmutex.cpp
+index 310d1cb14f..7097122d8e 100644
+--- a/qtbase/src/corelib/thread/qmutex.cpp
++++ b/qtbase/src/corelib/thread/qmutex.cpp
+@@ -152,6 +152,7 @@ public:
+ 
+ /*!
+     \enum QMutex::RecursionMode
++    \obsolete Use QRecursiveMutex to create a recursive mutex.
+ 
+     \value Recursive  In this mode, a thread can lock the same mutex
+                       multiple times and the mutex won't be unlocked
+@@ -173,6 +174,7 @@ public:
+ 
+ /*!
+     Constructs a new mutex. The mutex is created in an unlocked state.
++    \obsolete Use QRecursiveMutex to create a recursive mutex.
+ 
+     If \a mode is QMutex::Recursive, a thread can lock the same mutex
+     multiple times and the mutex won't be unlocked until a
+@@ -197,7 +199,7 @@ QMutex::QMutex(RecursionMode mode)
+ QMutex::~QMutex()
+ {
+     QMutexData *d = d_ptr.loadRelaxed();
+-    if (isRecursive()) {
++    if (QBasicMutex::isRecursive()) {
+         delete static_cast<QRecursiveMutexPrivate *>(d);
+     } else if (d) {
+ #ifndef QT_LINUX_FUTEX
+diff --git a/qtbase/src/corelib/thread/qmutex.h b/qtbase/src/corelib/thread/qmutex.h
+index 73c9e00663..1bae573a03 100644
+--- a/qtbase/src/corelib/thread/qmutex.h
++++ b/qtbase/src/corelib/thread/qmutex.h
+@@ -42,6 +42,7 @@
+ 
+ #include <QtCore/qglobal.h>
+ #include <QtCore/qatomic.h>
++#include <QtCore/qtsan_impl.h>
+ #include <new>
+ 
+ #if __has_include(<chrono>)
+@@ -77,19 +78,37 @@ public:
+ 
+     // BasicLockable concept
+     inline void lock() QT_MUTEX_LOCK_NOEXCEPT {
++        QtTsan::mutexPreLock(this, 0u);
++
+         if (!fastTryLock())
+             lockInternal();
++
++        QtTsan::mutexPostLock(this, 0u, 0);
+     }
+ 
+     // BasicLockable concept
+     inline void unlock() noexcept {
+         Q_ASSERT(d_ptr.loadRelaxed()); //mutex must be locked
++
++        QtTsan::mutexPreUnlock(this, 0u);
++
+         if (!fastTryUnlock())
+             unlockInternal();
++
++        QtTsan::mutexPostUnlock(this, 0u);
+     }
+ 
+     bool tryLock() noexcept {
+-        return fastTryLock();
++        unsigned tsanFlags = QtTsan::TryLock;
++        QtTsan::mutexPreLock(this, tsanFlags);
++
++        const bool success = fastTryLock();
++
++        if (!success)
++            tsanFlags |= QtTsan::TryLockFailed;
++        QtTsan::mutexPostLock(this, tsanFlags, 0);
++
++        return success;
+     }
+ 
+     // Lockable concept
+@@ -134,8 +153,16 @@ public:
+ #else
+     QMutex() { d_ptr.storeRelaxed(nullptr); }
+ #endif
++#if QT_DEPRECATED_SINCE(5,15)
+     enum RecursionMode { NonRecursive, Recursive };
++    QT_DEPRECATED_VERSION_X(5, 15, "Use QRecursiveMutex instead of a recursive QMutex")
+     explicit QMutex(RecursionMode mode);
++
++    QT_DEPRECATED_VERSION_X(5, 15, "Use QRecursiveMutex instead of a recursive QMutex")
++    bool isRecursive() const noexcept
++    { return QBasicMutex::isRecursive(); }
++#endif
++
+     ~QMutex();
+ 
+     // BasicLockable concept
+@@ -166,9 +193,6 @@ public:
+     }
+ #endif
+ 
+-    bool isRecursive() const noexcept
+-    { return QBasicMutex::isRecursive(); }
+-
+ private:
+     Q_DISABLE_COPY(QMutex)
+     friend class QMutexLocker;
+diff --git a/qtbase/src/corelib/thread/qreadwritelock.cpp b/qtbase/src/corelib/thread/qreadwritelock.cpp
+index 8c28507d5a..9dd8503116 100644
+--- a/qtbase/src/corelib/thread/qreadwritelock.cpp
++++ b/qtbase/src/corelib/thread/qreadwritelock.cpp
+@@ -155,7 +155,7 @@ QReadWriteLock::QReadWriteLock(RecursionMode recursionMode)
+ */
+ QReadWriteLock::~QReadWriteLock()
+ {
+-    auto d = d_ptr.loadRelaxed();
++    auto d = d_ptr.loadAcquire();
+     if (isUncontendedLocked(d)) {
+         qWarning("QReadWriteLock: destroying locked QReadWriteLock");
+         return;
+@@ -445,7 +445,7 @@ void QReadWriteLock::unlock()
+ /*! \internal  Helper for QWaitCondition::wait */
+ QReadWriteLock::StateForWaitCondition QReadWriteLock::stateForWaitCondition() const
+ {
+-    QReadWriteLockPrivate *d = d_ptr.loadRelaxed();
++    QReadWriteLockPrivate *d = d_ptr.loadAcquire();
+     switch (quintptr(d) & StateMask) {
+     case StateLockedForRead: return LockedForRead;
+     case StateLockedForWrite: return LockedForWrite;
+@@ -453,6 +453,7 @@ QReadWriteLock::StateForWaitCondition QReadWriteLock::stateForWaitCondition() co
+ 
+     if (!d)
+         return Unlocked;
++    const auto lock = qt_scoped_lock(d->mutex);
+     if (d->writerCount > 1)
+         return RecursivelyLocked;
+     else if (d->writerCount == 1)
+diff --git a/qtbase/src/corelib/thread/qsemaphore.cpp b/qtbase/src/corelib/thread/qsemaphore.cpp
+index 1d01fc1b28..3ecdee3747 100644
+--- a/qtbase/src/corelib/thread/qsemaphore.cpp
++++ b/qtbase/src/corelib/thread/qsemaphore.cpp
+@@ -354,7 +354,12 @@ void QSemaphore::release(int n)
+         quintptr nn = unsigned(n);
+         if (futexHasWaiterCount)
+             nn |= quint64(nn) << 32;    // token count replicated in high word
+-        quintptr prevValue = u.fetchAndAddRelease(nn);
++        quintptr prevValue = u.loadRelaxed();
++        quintptr newValue;
++        do { // loop just to ensure the operations are done atomically
++            newValue = prevValue + nn;
++            newValue &= (futexNeedsWakeAllBit - 1);
++        } while (!u.testAndSetRelease(prevValue, newValue, prevValue));
+         if (futexNeedsWake(prevValue)) {
+ #ifdef FUTEX_OP
+             if (futexHasWaiterCount) {
+@@ -376,7 +381,6 @@ void QSemaphore::release(int n)
+                 quint32 oparg = 0;
+                 quint32 cmp = FUTEX_OP_CMP_NE;
+                 quint32 cmparg = 0;
+-                u.fetchAndAndRelease(futexNeedsWakeAllBit - 1);
+                 futexWakeOp(*futexLow32(&u), n, INT_MAX, *futexHigh32(&u), FUTEX_OP(op, oparg, cmp, cmparg));
+                 return;
+             }
+@@ -388,7 +392,6 @@ 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(futexNeedsWakeAllBit - 1);
+             if (futexHasWaiterCount) {
+                 futexWakeAll(*futexLow32(&u));
+                 futexWakeAll(*futexHigh32(&u));
+diff --git a/qtbase/src/corelib/thread/qthread_p.h b/qtbase/src/corelib/thread/qthread_p.h
+index b2d1628e6e..f32f6f0460 100644
+--- a/qtbase/src/corelib/thread/qthread_p.h
++++ b/qtbase/src/corelib/thread/qthread_p.h
+@@ -174,7 +174,7 @@ public:
+     int returnCode;
+ 
+     uint stackSize;
+-    QThread::Priority priority;
++    std::underlying_type<QThread::Priority>::type priority;
+ 
+     static QThread *threadForId(int id);
+ 
+@@ -213,6 +213,13 @@ public:
+             QCoreApplication::instance()->postEvent(q_ptr, new QEvent(QEvent::Quit));
+         }
+     }
++
++#ifndef Q_OS_INTEGRITY
++private:
++    // Used in QThread(Private)::start to avoid racy access to QObject::objectName,
++    // unset afterwards. On INTEGRITY we set the thread name before starting it.
++    QString objectName;
++#endif
+ };
+ 
+ #else // QT_CONFIG(thread)
+diff --git a/qtbase/src/corelib/thread/qthread_unix.cpp b/qtbase/src/corelib/thread/qthread_unix.cpp
+index 56a8e0a038..610117a640 100644
+--- a/qtbase/src/corelib/thread/qthread_unix.cpp
++++ b/qtbase/src/corelib/thread/qthread_unix.cpp
+@@ -169,8 +169,7 @@ static void set_thread_data(QThreadData *data)
+ 
+ static void clear_thread_data()
+ {
+-    currentThreadData = nullptr;
+-    pthread_setspecific(current_thread_data_key, nullptr);
++    set_thread_data(nullptr);
+ }
+ 
+ template <typename T>
+@@ -296,7 +295,7 @@ void *QThreadPrivate::start(void *arg)
+             QMutexLocker locker(&thr->d_func()->mutex);
+ 
+             // do we need to reset the thread priority?
+-            if (int(thr->d_func()->priority) & ThreadPriorityResetFlag) {
++            if (thr->d_func()->priority & ThreadPriorityResetFlag) {
+                 thr->d_func()->setPriority(QThread::Priority(thr->d_func()->priority & ~ThreadPriorityResetFlag));
+             }
+ 
+@@ -316,10 +315,10 @@ void *QThreadPrivate::start(void *arg)
+             // Sets the name of the current thread. We can only do this
+             // when the thread is starting, as we don't have a cross
+             // platform way of setting the name of an arbitrary thread.
+-            if (Q_LIKELY(thr->objectName().isEmpty()))
++            if (Q_LIKELY(thr->d_func()->objectName.isEmpty()))
+                 setCurrentThreadName(thr->metaObject()->className());
+             else
+-                setCurrentThreadName(thr->objectName().toLocal8Bit());
++                setCurrentThreadName(std::exchange(thr->d_func()->objectName, {}).toLocal8Bit());
+         }
+ #endif
+ 
+@@ -671,7 +670,7 @@ void QThread::start(Priority priority)
+                 // could not set scheduling hints, fallback to inheriting them
+                 // we'll try again from inside the thread
+                 pthread_attr_setinheritsched(&attr, PTHREAD_INHERIT_SCHED);
+-                d->priority = Priority(priority | ThreadPriorityResetFlag);
++                d->priority = static_cast<std::underlying_type<QThread::Priority>::type>(priority) | ThreadPriorityResetFlag;
+             }
+             break;
+         }
+@@ -702,7 +701,10 @@ void QThread::start(Priority priority)
+         pthread_attr_setthreadname(&attr, metaObject()->className());
+     else
+         pthread_attr_setthreadname(&attr, objectName().toLocal8Bit());
++#else
++    d->objectName = objectName();
+ #endif
++
+     pthread_t threadId;
+     int code = pthread_create(&threadId, &attr, QThreadPrivate::start, this);
+     if (code == EPERM) {
+diff --git a/qtbase/src/corelib/thread/qthread_win.cpp b/qtbase/src/corelib/thread/qthread_win.cpp
+index bc70e3178a..4e76972498 100644
+--- a/qtbase/src/corelib/thread/qthread_win.cpp
++++ b/qtbase/src/corelib/thread/qthread_win.cpp
+@@ -394,10 +394,9 @@ unsigned int __stdcall QT_ENSURE_STACK_ALIGNED_FOR_SSE QThreadPrivate::start(voi
+ 
+ #if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) && !defined(Q_OS_WINRT)
+     // sets the name of the current thread.
+-    QByteArray objectName = thr->objectName().toLocal8Bit();
+-    qt_set_thread_name(HANDLE(-1),
+-                       objectName.isEmpty() ?
+-                       thr->metaObject()->className() : objectName.constData());
++    qt_set_thread_name(HANDLE(-1), thr->d_func()->objectName.isEmpty()
++                        ? thr->metaObject()->className()
++                        : std::exchange(thr->d_func()->objectName, {}).toLocal8Bit().constData());
+ #endif
+ 
+     emit thr->started(QThread::QPrivateSignal());
+@@ -503,6 +502,7 @@ void QThread::start(Priority priority)
+     if (d->running)
+         return;
+ 
++    d->objectName = objectName();
+     d->running = true;
+     d->finished = false;
+     d->exited = false;
+@@ -548,7 +548,7 @@ void QThread::start(Priority priority)
+ 
+     int prio;
+     d->priority = priority;
+-    switch (d->priority) {
++    switch (priority) {
+     case IdlePriority:
+         prio = THREAD_PRIORITY_IDLE;
+         break;
+@@ -686,7 +686,7 @@ void QThreadPrivate::setPriority(QThread::Priority threadPriority)
+ 
+     int prio;
+     priority = threadPriority;
+-    switch (priority) {
++    switch (threadPriority) {
+     case QThread::IdlePriority:
+         prio = THREAD_PRIORITY_IDLE;
+         break;
+diff --git a/qtbase/src/corelib/thread/qtsan_impl.h b/qtbase/src/corelib/thread/qtsan_impl.h
+new file mode 100644
+index 0000000000..580a738b91
+--- /dev/null
++++ b/qtbase/src/corelib/thread/qtsan_impl.h
+@@ -0,0 +1,115 @@
++/****************************************************************************
++**
++** Copyright (C) 2017 Intel Corporation.
++** Copyright (C) 2022 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
++** 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 QTSAN_IMPL_H
++#define QTSAN_IMPL_H
++
++#include <QtCore/qglobal.h>
++
++#if (__has_feature(thread_sanitizer) || defined(__SANITIZE_THREAD__)) && __has_include(<sanitizer/tsan_interface.h>)
++#  define QT_BUILDING_UNDER_TSAN
++#  include <sanitizer/tsan_interface.h>
++#endif
++
++QT_BEGIN_NAMESPACE
++
++namespace QtTsan {
++#ifdef QT_BUILDING_UNDER_TSAN
++inline void futexAcquire(void *addr, void *addr2 = nullptr)
++{
++    // A futex call ensures total ordering on the futex words
++    // (in either success or failure of the call). Instruct TSAN accordingly,
++    // as TSAN does not understand the futex(2) syscall (or equivalent).
++    ::__tsan_acquire(addr);
++    if (addr2)
++        ::__tsan_acquire(addr2);
++}
++
++inline void futexRelease(void *addr, void *addr2 = nullptr)
++{
++    if (addr2)
++        ::__tsan_release(addr2);
++    ::__tsan_release(addr);
++}
++
++inline void mutexPreLock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_pre_lock(addr, flags);
++}
++
++inline void mutexPostLock(void *addr, unsigned flags, int recursion)
++{
++    ::__tsan_mutex_post_lock(addr, flags, recursion);
++}
++
++inline void mutexPreUnlock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_pre_unlock(addr, flags);
++}
++
++inline void mutexPostUnlock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_post_unlock(addr, flags);
++}
++
++enum : unsigned {
++    MutexWriteReentrant = ::__tsan_mutex_write_reentrant,
++    TryLock = ::__tsan_mutex_try_lock,
++    TryLockFailed = ::__tsan_mutex_try_lock_failed,
++};
++#else
++inline void futexAcquire(void *, void * = nullptr) {}
++inline void futexRelease(void *, void * = nullptr) {}
++
++enum : unsigned {
++    MutexWriteReentrant,
++    TryLock,
++    TryLockFailed,
++};
++inline void mutexPreLock(void *, unsigned) {}
++inline void mutexPostLock(void *, unsigned, int) {}
++inline void mutexPreUnlock(void *, unsigned) {}
++inline void mutexPostUnlock(void *, unsigned) {}
++#endif // QT_BUILDING_UNDER_TSAN
++} // namespace QtTsan
++
++QT_END_NAMESPACE
++
++#endif // QTSAN_IMPL_H
+diff --git a/qtbase/src/corelib/thread/qwaitcondition_unix.cpp b/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
+index 88b058f410..0f1da4dc9b 100644
+--- a/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
++++ b/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
+@@ -213,7 +213,7 @@ bool QWaitCondition::wait(QMutex *mutex, QDeadlineTimer deadline)
+ {
+     if (! mutex)
+         return false;
+-    if (mutex->isRecursive()) {
++    if (static_cast<QBasicMutex *>(mutex)->isRecursive()) {
+         qWarning("QWaitCondition: cannot wait on recursive mutexes");
+         return false;
+     }
+diff --git a/qtbase/src/corelib/time/qdatetime.cpp b/qtbase/src/corelib/time/qdatetime.cpp
+index ec12569e3f..2c0b098079 100644
+--- a/qtbase/src/corelib/time/qdatetime.cpp
++++ b/qtbase/src/corelib/time/qdatetime.cpp
+@@ -43,6 +43,7 @@
+ #if QT_CONFIG(datetimeparser)
+ #include "private/qdatetimeparser_p.h"
+ #endif
++#include <private/qnumeric_p.h>
+ 
+ #include "qdatastream.h"
+ #include "qset.h"
+@@ -1429,9 +1430,11 @@ QDate QDate::addDays(qint64 ndays) const
+     if (isNull())
+         return QDate();
+ 
+-    // Due to limits on minJd() and maxJd() we know that any overflow
+-    // will be invalid and caught by fromJulianDay().
+-    return fromJulianDay(jd + ndays);
++    qint64 r;
++    if (Q_UNLIKELY(add_overflow(jd, ndays, &r)))
++        return QDate();
++    else
++        return fromJulianDay(r);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/corelib/time/qtimezone.cpp b/qtbase/src/corelib/time/qtimezone.cpp
+index 0309e43e52..3d451696a1 100644
+--- a/qtbase/src/corelib/time/qtimezone.cpp
++++ b/qtbase/src/corelib/time/qtimezone.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2013 John Layt <jlayt@kde.org>
++** Copyright (C) 2020 John Layt <jlayt@kde.org>
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtCore module of the Qt Toolkit.
+@@ -975,9 +975,15 @@ QList<QByteArray> QTimeZone::windowsIdToIanaIds(const QByteArray &windowsId,
+ }
+ 
+ #ifndef QT_NO_DATASTREAM
++// Invalid, as an IANA ID: too long, starts with - and has other invalid characters in it
++static inline QString invalidId() { return QStringLiteral("-No Time Zone Specified!"); }
++
+ QDataStream &operator<<(QDataStream &ds, const QTimeZone &tz)
+ {
+-    tz.d->serialize(ds);
++    if (tz.isValid())
++        tz.d->serialize(ds);
++    else
++        ds << invalidId();
+     return ds;
+ }
+ 
+@@ -985,7 +991,9 @@ QDataStream &operator>>(QDataStream &ds, QTimeZone &tz)
+ {
+     QString ianaId;
+     ds >> ianaId;
+-    if (ianaId == QLatin1String("OffsetFromUtc")) {
++    if (ianaId == invalidId()) {
++        tz = QTimeZone();
++    } else if (ianaId == QLatin1String("OffsetFromUtc")) {
+         int utcOffset;
+         QString name;
+         QString abbreviation;
+diff --git a/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp b/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
+index b1611d7ddb..a7a6a72ccf 100644
+--- a/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
++++ b/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
+@@ -42,6 +42,7 @@
+ #include "qtimezone.h"
+ #include "qtimezoneprivate_p.h"
+ #include "private/qlocale_tools_p.h"
++#include "private/qlocking_p.h"
+ 
+ #include <QtCore/QDataStream>
+ #include <QtCore/QDateTime>
+@@ -62,6 +63,10 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++#if QT_CONFIG(icu)
++static QBasicMutex s_icu_mutex;
++#endif
++
+ /*
+     Private
+ 
+@@ -670,6 +675,9 @@ QTzTimeZonePrivate::~QTzTimeZonePrivate()
+ 
+ QTzTimeZonePrivate *QTzTimeZonePrivate::clone() const
+ {
++#if QT_CONFIG(icu)
++    const auto lock = qt_scoped_lock(s_icu_mutex);
++#endif
+     return new QTzTimeZonePrivate(*this);
+ }
+ 
+@@ -913,12 +921,14 @@ QString QTzTimeZonePrivate::displayName(qint64 atMSecsSinceEpoch,
+                                         const QLocale &locale) const
+ {
+ #if QT_CONFIG(icu)
++    auto lock = qt_unique_lock(s_icu_mutex);
+     if (!m_icu)
+         m_icu = new QIcuTimeZonePrivate(m_id);
+     // TODO small risk may not match if tran times differ due to outdated files
+     // TODO Some valid TZ names are not valid ICU names, use translation table?
+     if (m_icu->isValid())
+         return m_icu->displayName(atMSecsSinceEpoch, nameType, locale);
++    lock.unlock();
+ #else
+     Q_UNUSED(nameType)
+     Q_UNUSED(locale)
+@@ -932,12 +942,14 @@ QString QTzTimeZonePrivate::displayName(QTimeZone::TimeType timeType,
+                                         const QLocale &locale) const
+ {
+ #if QT_CONFIG(icu)
++    auto lock = qt_unique_lock(s_icu_mutex);
+     if (!m_icu)
+         m_icu = new QIcuTimeZonePrivate(m_id);
+     // TODO small risk may not match if tran times differ due to outdated files
+     // TODO Some valid TZ names are not valid ICU names, use translation table?
+     if (m_icu->isValid())
+         return m_icu->displayName(timeType, nameType, locale);
++    lock.unlock();
+ #else
+     Q_UNUSED(timeType)
+     Q_UNUSED(nameType)
+diff --git a/qtbase/src/corelib/tools/qarraydata.h b/qtbase/src/corelib/tools/qarraydata.h
+index dcd95924c1..d01739e7e6 100644
+--- a/qtbase/src/corelib/tools/qarraydata.h
++++ b/qtbase/src/corelib/tools/qarraydata.h
+@@ -42,6 +42,7 @@
+ 
+ #include <QtCore/qrefcount.h>
+ #include <string.h>
++#include <cstdint>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -58,14 +59,14 @@ struct Q_CORE_EXPORT QArrayData
+     {
+         Q_ASSERT(size == 0
+                 || offset < 0 || size_t(offset) >= sizeof(QArrayData));
+-        return reinterpret_cast<char *>(this) + offset;
++        return reinterpret_cast<void *> (reinterpret_cast<uintptr_t>(this) + offset);
+     }
+ 
+     const void *data() const
+     {
+         Q_ASSERT(size == 0
+                 || offset < 0 || size_t(offset) >= sizeof(QArrayData));
+-        return reinterpret_cast<const char *>(this) + offset;
++        return reinterpret_cast<void *> (reinterpret_cast<uintptr_t>(this) + offset);
+     }
+ 
+     // This refers to array data mutability, not "header data" represented by
+diff --git a/qtbase/src/corelib/tools/qfreelist_p.h b/qtbase/src/corelib/tools/qfreelist_p.h
+index 5ba23b344b..9974102136 100644
+--- a/qtbase/src/corelib/tools/qfreelist_p.h
++++ b/qtbase/src/corelib/tools/qfreelist_p.h
+@@ -161,7 +161,7 @@ class QFreeList
+                 return i;
+             x -= size;
+         }
+-        Q_ASSERT(false);
++        Q_UNREACHABLE();
+         return -1;
+     }
+ 
+diff --git a/qtbase/src/corelib/tools/qversionnumber.h b/qtbase/src/corelib/tools/qversionnumber.h
+index d43b86ba51..2843f2b043 100644
+--- a/qtbase/src/corelib/tools/qversionnumber.h
++++ b/qtbase/src/corelib/tools/qversionnumber.h
+@@ -273,10 +273,10 @@ public:
+ 
+     Q_REQUIRED_RESULT Q_CORE_EXPORT QString toString() const;
+ #if QT_STRINGVIEW_LEVEL < 2
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(const QString &string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(const QString &string, int *suffixIndex = nullptr);
+ #endif
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QLatin1String string, int *suffixIndex = nullptr);
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QStringView string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(QLatin1String string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(QStringView string, int *suffixIndex = nullptr);
+ 
+ private:
+ #ifndef QT_NO_DATASTREAM
+diff --git a/qtbase/src/dbus/qdbusintegrator.cpp b/qtbase/src/dbus/qdbusintegrator.cpp
+index 5b66ce971b..28a3b0ffea 100644
+--- a/qtbase/src/dbus/qdbusintegrator.cpp
++++ b/qtbase/src/dbus/qdbusintegrator.cpp
+@@ -1135,7 +1135,13 @@ void QDBusConnectionPrivate::closeConnection()
+         }
+     }
+ 
+-    qDeleteAll(pendingCalls);
++    for (auto it = pendingCalls.begin(); it != pendingCalls.end(); ++it) {
++        auto call = *it;
++        if (!call->ref.deref()) {
++            delete call;
++        }
++    }
++    pendingCalls.clear();
+ 
+     // Disconnect all signals from signal hooks and from the object tree to
+     // avoid QObject::destroyed being sent to dbus daemon thread which has
+@@ -2584,6 +2590,11 @@ QDBusConnectionPrivate::findMetaObject(const QString &service, const QString &pa
+         if (mo)
+             return mo;
+     }
++    if (path.isEmpty()) {
++        error = QDBusError(QDBusError::InvalidObjectPath, QLatin1String("Object path cannot be empty"));
++        lastError = error;
++        return nullptr;
++    }
+ 
+     // introspect the target object
+     QDBusMessage msg = QDBusMessage::createMethodCall(service, path,
+diff --git a/qtbase/src/dbus/qdbusmetaobject.cpp b/qtbase/src/dbus/qdbusmetaobject.cpp
+index 5265568f42..7e9f0f1acc 100644
+--- a/qtbase/src/dbus/qdbusmetaobject.cpp
++++ b/qtbase/src/dbus/qdbusmetaobject.cpp
+@@ -210,6 +210,9 @@ QDBusMetaObjectGenerator::findType(const QByteArray &signature,
+         } else if (signature == "a{ss}") {
+             result.name = "QMap<QString,QString>";
+             type = qMetaTypeId<QMap<QString, QString> >();
++        } else if (signature == "aay") {
++            result.name = "QByteArrayList";
++            type = qMetaTypeId<QByteArrayList>();
+         } else {
+             result.name = "{D-Bus type \"" + signature + "\"}";
+             type = registerComplexDBusType(result.name);
+diff --git a/qtbase/src/gui/accessible/qaccessible.cpp b/qtbase/src/gui/accessible/qaccessible.cpp
+index d705bfccb5..0caf3c808c 100644
+--- a/qtbase/src/gui/accessible/qaccessible.cpp
++++ b/qtbase/src/gui/accessible/qaccessible.cpp
+@@ -54,6 +54,7 @@
+ #include <QtCore/qdebug.h>
+ #include <QtCore/qloggingcategory.h>
+ #include <QtCore/qmetaobject.h>
++#include <QtCore/private/qmetaobject_p.h>
+ #include <QtCore/qhash.h>
+ #include <private/qfactoryloader_p.h>
+ 
+@@ -681,6 +682,25 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
+     // Create a QAccessibleInterface for the object class. Start by the most
+     // derived class and walk up the class hierarchy.
+     const QMetaObject *mo = object->metaObject();
++    const auto *objectPriv = QObjectPrivate::get(object);
++    /*
++     We do not want to cache each and every QML metaobject (Button_QMLTYPE_124,
++     Button_QMLTYPE_125, etc.). Those dynamic metaobjects shouldn't have an
++     accessible interface in any case. Instead, we start the whole checking
++     with the first non-dynamic meta-object. To avoid potential regressions
++     in other areas of Qt that also use dynamic metaobjects, we only do this
++     for objects that are QML-related (approximated by checking whether they
++     have ddata set).
++    */
++    const bool qmlRelated = !objectPriv->isDeletingChildren &&
++                            objectPriv->declarativeData;
++    while (qmlRelated && mo) {
++        auto mop = QMetaObjectPrivate::get(mo);
++        if (!mop || !(mop->flags & DynamicMetaObject))
++            break;
++
++        mo = mo->superClass();
++    };
+     while (mo) {
+         const QString cn = QLatin1String(mo->className());
+ 
+@@ -696,14 +716,15 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
+         // Find a QAccessiblePlugin (factory) for the class name. If there's
+         // no entry in the cache try to create it using the plugin loader.
+         if (!qAccessiblePlugins()->contains(cn)) {
++            QAccessiblePlugin *factory = nullptr; // 0 means "no plugin found". This is cached as well.
+             const int index = loader()->indexOf(cn);
+-            if (index != -1) {
+-                QAccessiblePlugin *factory = qobject_cast<QAccessiblePlugin *>(loader()->instance(index));
+-                qAccessiblePlugins()->insert(cn, factory);
+-            }
++            if (index != -1)
++                factory = qobject_cast<QAccessiblePlugin *>(loader()->instance(index));
++            qAccessiblePlugins()->insert(cn, factory);
+         }
+ 
+         // At this point the cache should contain a valid factory pointer or 0:
++        Q_ASSERT(qAccessiblePlugins()->contains(cn));
+         QAccessiblePlugin *factory = qAccessiblePlugins()->value(cn);
+         if (factory) {
+             QAccessibleInterface *result = factory->create(cn, object);
+diff --git a/qtbase/src/gui/configure.json b/qtbase/src/gui/configure.json
+index 1f08795c57..12c95742d2 100644
+--- a/qtbase/src/gui/configure.json
++++ b/qtbase/src/gui/configure.json
+@@ -834,7 +834,8 @@
+                     "// embedded devices, are not intended to be used together with X. EGL support",
+                     "// has to be disabled in plugins like xcb in this case since the native display,",
+                     "// window and pixmap types will be different than what an X-based platform",
+-                    "// plugin would expect."
++                    "// plugin would expect.",
++                    "#define USE_X11"
+                 ],
+                 "include": [ "EGL/egl.h", "X11/Xlib.h" ],
+                 "main": [
+diff --git a/qtbase/src/gui/image/qbmphandler.cpp b/qtbase/src/gui/image/qbmphandler.cpp
+index 96f1e8cb1d..0e73bbbdb0 100644
+--- a/qtbase/src/gui/image/qbmphandler.cpp
++++ b/qtbase/src/gui/image/qbmphandler.cpp
+@@ -150,16 +150,42 @@ static QDataStream &operator<<(QDataStream &s, const BMP_INFOHDR &bi)
+     return s;
+ }
+ 
+-static int calc_shift(uint mask)
++static uint calc_shift(uint mask)
+ {
+-    int result = 0;
+-    while (mask && !(mask & 1)) {
++    uint result = 0;
++    while ((mask >= 0x100) || (!(mask & 1) && mask)) {
+         result++;
+         mask >>= 1;
+     }
+     return result;
+ }
+ 
++static uint calc_scale(uint low_mask)
++{
++    uint result = 8;
++    while (low_mask && result) {
++        result--;
++        low_mask >>= 1;
++    }
++    return result;
++}
++
++static inline uint apply_scale(uint value, uint scale)
++{
++    if (!(scale & 0x07)) // return immediately if scale == 8 or 0
++        return value;
++
++    uint filled = 8 - scale;
++    uint result = value << scale;
++
++    do {
++        result |= result >> filled;
++        filled <<= 1;
++    } while (filled < 8);
++
++    return result;
++}
++
+ static bool read_dib_fileheader(QDataStream &s, BMP_FILEHDR &bf)
+ {
+     // read BMP file header
+@@ -222,14 +248,14 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+     uint green_mask = 0;
+     uint blue_mask = 0;
+     uint alpha_mask = 0;
+-    int red_shift = 0;
+-    int green_shift = 0;
+-    int blue_shift = 0;
+-    int alpha_shift = 0;
+-    int red_scale = 0;
+-    int green_scale = 0;
+-    int blue_scale = 0;
+-    int alpha_scale = 0;
++    uint red_shift = 0;
++    uint green_shift = 0;
++    uint blue_shift = 0;
++    uint alpha_shift = 0;
++    uint red_scale = 0;
++    uint green_scale = 0;
++    uint blue_scale = 0;
++    uint alpha_scale = 0;
+ 
+     if (!d->isSequential())
+         d->seek(startpos + BMP_FILEHDR_SIZE + bi.biSize); // goto start of colormap or masks
+@@ -308,19 +334,19 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+         red_shift = calc_shift(red_mask);
+         if (((red_mask >> red_shift) + 1) == 0)
+             return false;
+-        red_scale = 256 / ((red_mask >> red_shift) + 1);
++        red_scale = calc_scale(red_mask >> red_shift);
+         green_shift = calc_shift(green_mask);
+         if (((green_mask >> green_shift) + 1) == 0)
+             return false;
+-        green_scale = 256 / ((green_mask >> green_shift) + 1);
++        green_scale = calc_scale(green_mask >> green_shift);
+         blue_shift = calc_shift(blue_mask);
+         if (((blue_mask >> blue_shift) + 1) == 0)
+             return false;
+-        blue_scale = 256 / ((blue_mask >> blue_shift) + 1);
++        blue_scale = calc_scale(blue_mask >> blue_shift);
+         alpha_shift = calc_shift(alpha_mask);
+         if (((alpha_mask >> alpha_shift) + 1) == 0)
+             return false;
+-        alpha_scale = 256 / ((alpha_mask >> alpha_shift) + 1);
++        alpha_scale = calc_scale(alpha_mask >> alpha_shift);
+     } else if (comp == BMP_RGB && (nbits == 24 || nbits == 32)) {
+         blue_mask = 0x000000ff;
+         green_mask = 0x0000ff00;
+@@ -328,17 +354,15 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+         blue_shift = 0;
+         green_shift = 8;
+         red_shift = 16;
+-        blue_scale = green_scale = red_scale = 1;
++        blue_scale = green_scale = red_scale = 0;
+     } else if (comp == BMP_RGB && nbits == 16) {
+         blue_mask = 0x001f;
+         green_mask = 0x03e0;
+         red_mask = 0x7c00;
+         blue_shift = 0;
+-        green_shift = 2;
+-        red_shift = 7;
+-        red_scale = 1;
+-        green_scale = 1;
+-        blue_scale = 8;
++        green_shift = 5;
++        red_shift = 10;
++        blue_scale = green_scale = red_scale = 3;
+     }
+ 
+ #if 0
+@@ -544,10 +568,10 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+                     c |= *(uchar*)(b+2)<<16;
+                 if (nbits > 24)
+                     c |= *(uchar*)(b+3)<<24;
+-                *p++ = qRgba(((c & red_mask) >> red_shift) * red_scale,
+-                                        ((c & green_mask) >> green_shift) * green_scale,
+-                                        ((c & blue_mask) >> blue_shift) * blue_scale,
+-                                        transp ? ((c & alpha_mask) >> alpha_shift) * alpha_scale : 0xff);
++                *p++ = qRgba(apply_scale((c & red_mask) >> red_shift, red_scale),
++                             apply_scale((c & green_mask) >> green_shift, green_scale),
++                             apply_scale((c & blue_mask) >> blue_shift, blue_scale),
++                             transp ? apply_scale((c & alpha_mask) >> alpha_shift, alpha_scale) : 0xff);
+                 b += nbits/8;
+             }
+         }
+diff --git a/qtbase/src/gui/image/qimage.cpp b/qtbase/src/gui/image/qimage.cpp
+index 7152ac1607..0df772564c 100644
+--- a/qtbase/src/gui/image/qimage.cpp
++++ b/qtbase/src/gui/image/qimage.cpp
+@@ -4694,6 +4694,8 @@ QImage QImage::smoothScaled(int w, int h) const {
+ static QImage rotated90(const QImage &image)
+ {
+     QImage out(image.height(), image.width(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+@@ -4722,6 +4724,8 @@ static QImage rotated180(const QImage &image)
+         return image.mirrored(true, true);
+ 
+     QImage out(image.width(), image.height(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+@@ -4734,6 +4738,8 @@ static QImage rotated180(const QImage &image)
+ static QImage rotated270(const QImage &image)
+ {
+     QImage out(image.height(), image.width(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+diff --git a/qtbase/src/gui/kernel/qcursor.cpp b/qtbase/src/gui/kernel/qcursor.cpp
+index d6ccaff8ed..455088241c 100644
+--- a/qtbase/src/gui/kernel/qcursor.cpp
++++ b/qtbase/src/gui/kernel/qcursor.cpp
+@@ -251,7 +251,8 @@ void QCursor::setPos(QScreen *screen, int x, int y)
+ {
+     if (screen) {
+         if (QPlatformCursor *cursor = screen->handle()->cursor()) {
+-            const QPoint devicePos = QHighDpi::toNativePixels(QPoint(x, y), screen);
++            const QPoint pos(x, y);
++            const QPoint devicePos = QHighDpi::toNativePixels(pos, screen->virtualSiblingAt(pos));
+             // Need to check, since some X servers generate null mouse move
+             // events, causing looping in applications which call setPos() on
+             // every mouse move event.
+diff --git a/qtbase/src/gui/kernel/qhighdpiscaling.cpp b/qtbase/src/gui/kernel/qhighdpiscaling.cpp
+index 9bbf2773a9..3ac4a4d8b6 100644
+--- a/qtbase/src/gui/kernel/qhighdpiscaling.cpp
++++ b/qtbase/src/gui/kernel/qhighdpiscaling.cpp
+@@ -580,9 +580,8 @@ void QHighDpiScaling::setScreenFactor(QScreen *screen, qreal factor)
+     else
+         qNamedScreenScaleFactors()->insert(name, factor);
+ 
+-    // hack to force re-evaluation of screen geometry
+     if (screen->handle())
+-        screen->d_func()->setPlatformScreen(screen->handle()); // updates geometries based on scale factor
++        screen->d_func()->updateLogicalDpi();
+ }
+ 
+ QPoint QHighDpiScaling::mapPositionToNative(const QPoint &pos, const QPlatformScreen *platformScreen)
+diff --git a/qtbase/src/gui/kernel/qkeysequence.cpp b/qtbase/src/gui/kernel/qkeysequence.cpp
+index a75b8ef920..4f2d294739 100644
+--- a/qtbase/src/gui/kernel/qkeysequence.cpp
++++ b/qtbase/src/gui/kernel/qkeysequence.cpp
+@@ -701,6 +701,10 @@ static const struct {
+     { Qt::Key_TouchpadToggle,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad Toggle") },
+     { Qt::Key_TouchpadOn,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad On") },
+     { Qt::Key_TouchpadOff,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad Off") },
++    { Qt::Key_Shift,  QT_TRANSLATE_NOOP("QShortcut", "Shift") },
++    { Qt::Key_Control,  QT_TRANSLATE_NOOP("QShortcut", "Control") },
++    { Qt::Key_Alt,  QT_TRANSLATE_NOOP("QShortcut", "Alt") },
++    { Qt::Key_Meta,  QT_TRANSLATE_NOOP("QShortcut", "Meta") },
+ 
+ };
+ static Q_CONSTEXPR int numKeyNames = sizeof keyname / sizeof *keyname;
+diff --git a/qtbase/src/gui/kernel/qplatformservices.cpp b/qtbase/src/gui/kernel/qplatformservices.cpp
+index fdc6a6c4aa..ac47f98c5d 100644
+--- a/qtbase/src/gui/kernel/qplatformservices.cpp
++++ b/qtbase/src/gui/kernel/qplatformservices.cpp
+@@ -55,6 +55,19 @@ QT_BEGIN_NAMESPACE
+     \brief The QPlatformServices provides the backend for desktop-related functionality.
+ */
+ 
++/*!
++    \enum QPlatformServices::Capability
++
++    Capabilities are used to determine a specific platform service's availability.
++
++    \value ColorPickingFromScreen The platform natively supports color picking from screen.
++    This capability indicates that the platform supports "opaque" color picking, where the
++    platform implements a complete user experience for color picking and outputs a color.
++    This is in contrast to the application implementing the color picking user experience
++    (taking care of showing a cross hair, instructing the platform integration to obtain
++    the color at a given pixel, etc.). The related service function is pickColor().
++ */
++
+ QPlatformServices::QPlatformServices()
+ { }
+ 
+@@ -85,5 +98,16 @@ QByteArray QPlatformServices::desktopEnvironment() const
+     return QByteArray("UNKNOWN");
+ }
+ 
++QPlatformServiceColorPicker *QPlatformServices::colorPicker(QWindow *parent)
++{
++    Q_UNUSED(parent);
++    return nullptr;
++}
++
++bool QPlatformServices::hasCapability(Capability capability) const
++{
++    Q_UNUSED(capability)
++    return false;
++}
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/gui/kernel/qplatformservices.h b/qtbase/src/gui/kernel/qplatformservices.h
+index 5de96cfa7d..a8b2a4ce71 100644
+--- a/qtbase/src/gui/kernel/qplatformservices.h
++++ b/qtbase/src/gui/kernel/qplatformservices.h
+@@ -50,16 +50,32 @@
+ //
+ 
+ #include <QtGui/qtguiglobal.h>
++#include <QtCore/qobject.h>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+ class QUrl;
++class QWindow;
++
++class Q_GUI_EXPORT QPlatformServiceColorPicker : public QObject
++{
++    Q_OBJECT
++public:
++    using QObject::QObject;
++    virtual void pickColor() = 0;
++Q_SIGNALS:
++    void colorPicked(const QColor &color);
++};
+ 
+ class Q_GUI_EXPORT QPlatformServices
+ {
+ public:
+     Q_DISABLE_COPY_MOVE(QPlatformServices)
+ 
++    enum Capability {
++        ColorPicking,
++    };
++
+     QPlatformServices();
+     virtual ~QPlatformServices() { }
+ 
+@@ -67,6 +83,10 @@ public:
+     virtual bool openDocument(const QUrl &url);
+ 
+     virtual QByteArray desktopEnvironment() const;
++
++    virtual bool hasCapability(Capability capability) const;
++
++    virtual QPlatformServiceColorPicker *colorPicker(QWindow *parent = nullptr);
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/gui/kernel/qplatformtheme.cpp b/qtbase/src/gui/kernel/qplatformtheme.cpp
+index 71521c0339..2325873245 100644
+--- a/qtbase/src/gui/kernel/qplatformtheme.cpp
++++ b/qtbase/src/gui/kernel/qplatformtheme.cpp
+@@ -163,6 +163,8 @@ QT_BEGIN_NAMESPACE
+ 
+     \value ShowShortcutsInContextMenus (bool) Whether to display shortcut key sequences in context menus.
+ 
++    \value ButtonPressKeys (QList<Qt::Key>) A list of keys that can be used to press buttons via keyboard input.
++
+     \sa themeHint(), QStyle::pixelMetric()
+ */
+ 
+@@ -563,6 +565,8 @@ QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint)
+         }
+     case MouseQuickSelectionThreshold:
+         return QVariant(10);
++    case ButtonPressKeys:
++        return QVariant::fromValue(QList<Qt::Key>({ Qt::Key_Space, Qt::Key_Select }));
+     }
+     return QVariant();
+ }
+diff --git a/qtbase/src/gui/kernel/qplatformtheme.h b/qtbase/src/gui/kernel/qplatformtheme.h
+index 3185fc4541..7e6c9d5740 100644
+--- a/qtbase/src/gui/kernel/qplatformtheme.h
++++ b/qtbase/src/gui/kernel/qplatformtheme.h
+@@ -120,7 +120,8 @@ public:
+         TouchDoubleTapDistance,
+         ShowShortcutsInContextMenus,
+         IconFallbackSearchPaths,
+-        MouseQuickSelectionThreshold
++        MouseQuickSelectionThreshold,
++        ButtonPressKeys
+     };
+ 
+     enum DialogType {
+diff --git a/qtbase/src/gui/kernel/qscreen.cpp b/qtbase/src/gui/kernel/qscreen.cpp
+index 8e0eb35116..5d172a58dd 100644
+--- a/qtbase/src/gui/kernel/qscreen.cpp
++++ b/qtbase/src/gui/kernel/qscreen.cpp
+@@ -77,6 +77,12 @@ QScreen::QScreen(QPlatformScreen *screen)
+     d->setPlatformScreen(screen);
+ }
+ 
++void QScreenPrivate::updateLogicalDpi()
++{
++    logicalDpi = QPlatformScreen::overrideDpi(platformScreen->logicalDpi());
++    updateGeometriesWithSignals(); // updates geometries based on scale factor
++}
++
+ void QScreenPrivate::updateGeometriesWithSignals()
+ {
+     const QRect oldGeometry = geometry;
+diff --git a/qtbase/src/gui/kernel/qscreen_p.h b/qtbase/src/gui/kernel/qscreen_p.h
+index 7da542c25e..e50fc3190b 100644
+--- a/qtbase/src/gui/kernel/qscreen_p.h
++++ b/qtbase/src/gui/kernel/qscreen_p.h
+@@ -70,6 +70,7 @@ public:
+         geometry = platformScreen->deviceIndependentGeometry();
+         availableGeometry = QHighDpi::fromNative(platformScreen->availableGeometry(), QHighDpiScaling::factor(platformScreen), geometry.topLeft());
+     }
++    void updateLogicalDpi();
+ 
+     void updatePrimaryOrientation();
+     void updateGeometriesWithSignals();
+diff --git a/qtbase/src/gui/painting/qblendfunctions_p.h b/qtbase/src/gui/painting/qblendfunctions_p.h
+index 080da98ec4..6997d62b3c 100644
+--- a/qtbase/src/gui/painting/qblendfunctions_p.h
++++ b/qtbase/src/gui/painting/qblendfunctions_p.h
+@@ -246,25 +246,32 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+                                   int dudx, int dvdx, int dudy, int dvdy, int u0, int v0,
+                                   Blender blender)
+ {
+-    int fromY = qMax(qRound(topY), clip.top());
+-    int toY = qMin(qRound(bottomY), clip.top() + clip.height());
++    qint64 fromY = qMax(qRound(topY), clip.top());
++    qint64 toY = qMin(qRound(bottomY), clip.top() + clip.height());
+     if (fromY >= toY)
+         return;
+ 
+     qreal leftSlope = (bottomLeft.x - topLeft.x) / (bottomLeft.y - topLeft.y);
+     qreal rightSlope = (bottomRight.x - topRight.x) / (bottomRight.y - topRight.y);
+-    int dx_l = int(leftSlope * 0x10000);
+-    int dx_r = int(rightSlope * 0x10000);
+-    int x_l = int((topLeft.x + (qreal(0.5) + fromY - topLeft.y) * leftSlope + qreal(0.5)) * 0x10000);
+-    int x_r = int((topRight.x + (qreal(0.5) + fromY - topRight.y) * rightSlope + qreal(0.5)) * 0x10000);
+-
+-    int fromX, toX, x1, x2, u, v, i, ii;
++    qint64 dx_l = qint64(leftSlope * 0x10000);
++    qint64 dx_r = qint64(rightSlope * 0x10000);
++    qint64 x_l = qint64((topLeft.x + (qreal(0.5) + fromY - topLeft.y) * leftSlope + qreal(0.5)) * 0x10000);
++    qint64 x_r = qint64((topRight.x + (qreal(0.5) + fromY - topRight.y) * rightSlope + qreal(0.5)) * 0x10000);
++
++    qint64 sourceRectTop = qint64(sourceRect.top());
++    qint64 sourceRectLeft = qint64(sourceRect.left());
++    qint64 sourceRectWidth = qint64(sourceRect.width());
++    qint64 sourceRectHeight = qint64(sourceRect.height());
++    qint64 clipLeft = qint64(clip.left());
++    qint64 clipWidth = qint64(clip.width());
++
++    qint64 fromX, toX, x1, x2, u, v, i, ii;
+     DestT *line;
+-    for (int y = fromY; y < toY; ++y) {
++    for (qint64 y = fromY; y < toY; ++y) {
+         line = reinterpret_cast<DestT *>(reinterpret_cast<uchar *>(destPixels) + y * dbpl);
+ 
+-        fromX = qMax(x_l >> 16, clip.left());
+-        toX = qMin(x_r >> 16, clip.left() + clip.width());
++        fromX = qMax(x_l >> 16, clipLeft);
++        toX = qMin(x_r >> 16, clipLeft + clipWidth);
+         if (fromX < toX) {
+             // Because of rounding, we can get source coordinates outside the source image.
+             // Clamp these coordinates to the source rect to avoid segmentation fault and
+@@ -275,10 +282,10 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             u = x1 * dudx + y * dudy + u0;
+             v = x1 * dvdx + y * dvdy + v0;
+             for (; x1 < toX; ++x1) {
+-                int uu = u >> 16;
+-                int vv = v >> 16;
+-                if (uu >= sourceRect.left() && uu < sourceRect.left() + sourceRect.width()
+-                    && vv >= sourceRect.top() && vv < sourceRect.top() + sourceRect.height()) {
++                qint64 uu = u >> 16;
++                qint64 vv = v >> 16;
++                if (uu >= sourceRectLeft && uu < sourceRectLeft + sourceRectWidth
++                    && vv >= sourceRectTop && vv < sourceRectTop + sourceRectHeight) {
+                     break;
+                 }
+                 u += dudx;
+@@ -290,10 +297,10 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             u = (x2 - 1) * dudx + y * dudy + u0;
+             v = (x2 - 1) * dvdx + y * dvdy + v0;
+             for (; x2 > x1; --x2) {
+-                int uu = u >> 16;
+-                int vv = v >> 16;
+-                if (uu >= sourceRect.left() && uu < sourceRect.left() + sourceRect.width()
+-                    && vv >= sourceRect.top() && vv < sourceRect.top() + sourceRect.height()) {
++                qint64 uu = u >> 16;
++                qint64 vv = v >> 16;
++                if (uu >= sourceRectLeft && uu < sourceRectLeft + sourceRectWidth
++                    && vv >= sourceRectTop && vv < sourceRectTop + sourceRectHeight) {
+                     break;
+                 }
+                 u -= dudx;
+@@ -308,8 +315,8 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             // Beginning of the scan line, with per-pixel checks.
+             i = x1 - fromX;
+             while (i) {
+-                int uu = qBound(sourceRect.left(), u >> 16, sourceRect.left() + sourceRect.width() - 1);
+-                int vv = qBound(sourceRect.top(), v >> 16, sourceRect.top() + sourceRect.height() - 1);
++                qint64 uu = qBound(sourceRectLeft, u >> 16, sourceRectLeft + sourceRectWidth - 1);
++                qint64 vv = qBound(sourceRectTop, v >> 16, sourceRectTop + sourceRectHeight - 1);
+                 blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + vv * sbpl)[uu]);
+                 u += dudx;
+                 v += dvdx;
+@@ -348,8 +355,8 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             // End of the scan line, with per-pixel checks.
+             i = toX - x2;
+             while (i) {
+-                int uu = qBound(sourceRect.left(), u >> 16, sourceRect.left() + sourceRect.width() - 1);
+-                int vv = qBound(sourceRect.top(), v >> 16, sourceRect.top() + sourceRect.height() - 1);
++                qint64 uu = qBound(sourceRectLeft, u >> 16, sourceRectLeft + sourceRectWidth - 1);
++                qint64 vv = qBound(sourceRectTop, v >> 16, sourceRectTop + sourceRectHeight - 1);
+                 blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + vv * sbpl)[uu]);
+                 u += dudx;
+                 v += dvdx;
+diff --git a/qtbase/src/gui/painting/qcolortrclut_p.h b/qtbase/src/gui/painting/qcolortrclut_p.h
+index 76a6a60803..24fd522e6c 100644
+--- a/qtbase/src/gui/painting/qcolortrclut_p.h
++++ b/qtbase/src/gui/painting/qcolortrclut_p.h
+@@ -118,6 +118,7 @@ public:
+         return QRgba64::fromRgba64(r, g, b, qAlpha(rgb32) * 257);
+ #endif
+     }
++    QRgba64 toLinear64(QRgba64) const = delete;
+ 
+     QRgb toLinear(QRgb rgb32) const
+     {
+diff --git a/qtbase/src/gui/painting/qdrawhelper.cpp b/qtbase/src/gui/painting/qdrawhelper.cpp
+index a61793508a..5ba2d277b7 100644
+--- a/qtbase/src/gui/painting/qdrawhelper.cpp
++++ b/qtbase/src/gui/painting/qdrawhelper.cpp
+@@ -6091,7 +6091,7 @@ static inline void alphargbblend_argb32(quint32 *dst, uint coverage, const QRgba
+ static inline void rgbBlendPixel(QRgba64 &dst, int coverage, QRgba64 slinear, const QColorTrcLut *colorProfile)
+ {
+     // Do a gammacorrected RGB alphablend...
+-    const QRgba64 dlinear = colorProfile ? colorProfile->toLinear64(dst) : dst;
++    const QRgba64 dlinear = colorProfile ? colorProfile->toLinear(dst) : dst;
+ 
+     QRgba64 blend = rgbBlend(dlinear, slinear, coverage);
+ 
+diff --git a/qtbase/src/gui/painting/qpaintengine_raster.cpp b/qtbase/src/gui/painting/qpaintengine_raster.cpp
+index 283923de52..f08eb9cbee 100644
+--- a/qtbase/src/gui/painting/qpaintengine_raster.cpp
++++ b/qtbase/src/gui/painting/qpaintengine_raster.cpp
+@@ -560,31 +560,6 @@ void QRasterPaintEngine::updateMatrix(const QTransform &matrix)
+     QRasterPaintEngineState *s = state();
+     // FALCON: get rid of this line, see drawImage call below.
+     s->matrix = matrix;
+-    QTransform::TransformationType txop = s->matrix.type();
+-
+-    switch (txop) {
+-
+-    case QTransform::TxNone:
+-        s->flags.int_xform = true;
+-        break;
+-
+-    case QTransform::TxTranslate:
+-        s->flags.int_xform = qreal(int(s->matrix.dx())) == s->matrix.dx()
+-                            && qreal(int(s->matrix.dy())) == s->matrix.dy();
+-        break;
+-
+-    case QTransform::TxScale:
+-        s->flags.int_xform = qreal(int(s->matrix.dx())) == s->matrix.dx()
+-                            && qreal(int(s->matrix.dy())) == s->matrix.dy()
+-                            && qreal(int(s->matrix.m11())) == s->matrix.m11()
+-                            && qreal(int(s->matrix.m22())) == s->matrix.m22();
+-        break;
+-
+-    default: // shear / perspective...
+-        s->flags.int_xform = false;
+-        break;
+-    }
+-
+     s->flags.tx_noshear = qt_scaleForTransform(s->matrix, &s->txscale);
+ 
+     ensureOutlineMapper();
+@@ -617,7 +592,6 @@ QRasterPaintEngineState::QRasterPaintEngineState()
+     flags.bilinear = false;
+     flags.legacy_rounding = false;
+     flags.fast_text = true;
+-    flags.int_xform = true;
+     flags.tx_noshear = true;
+     flags.fast_images = true;
+ 
+@@ -1793,7 +1767,7 @@ void QRasterPaintEngine::fill(const QVectorPath &path, const QBrush &brush)
+     QRectF cpRect = path.controlPointRect();
+     const QRectF pathDeviceRect = s->matrix.mapRect(cpRect);
+     // Skip paths that by conservative estimates are completely outside the paint device.
+-    if (!pathDeviceRect.intersects(QRectF(d->deviceRect)))
++    if (!pathDeviceRect.intersects(QRectF(d->deviceRect)) || !pathDeviceRect.isValid())
+         return;
+ 
+     ProcessSpans blend = d->getBrushFunc(pathDeviceRect, &s->brushData);
+diff --git a/qtbase/src/gui/painting/qpaintengine_raster_p.h b/qtbase/src/gui/painting/qpaintengine_raster_p.h
+index 089aadc3f7..bf7363d5aa 100644
+--- a/qtbase/src/gui/painting/qpaintengine_raster_p.h
++++ b/qtbase/src/gui/painting/qpaintengine_raster_p.h
+@@ -111,7 +111,6 @@ public:
+         uint bilinear : 1;
+         uint legacy_rounding : 1;
+         uint fast_text : 1;
+-        uint int_xform : 1;
+         uint tx_noshear : 1;
+         uint fast_images : 1;
+     };
+diff --git a/qtbase/src/gui/painting/qpainterpath.cpp b/qtbase/src/gui/painting/qpainterpath.cpp
+index f9544a3241..d80fafeaf1 100644
+--- a/qtbase/src/gui/painting/qpainterpath.cpp
++++ b/qtbase/src/gui/painting/qpainterpath.cpp
+@@ -1253,7 +1253,7 @@ void QPainterPath::addText(const QPointF &point, const QFont &f, const QString &
+ 
+         if (si.analysis.flags < QScriptAnalysis::TabOrObject) {
+             QGlyphLayout glyphs = eng->shapedGlyphs(&si);
+-            QFontEngine *fe = f.d->engineForScript(si.analysis.script);
++            QFontEngine *fe = eng->fontEngine(si);
+             Q_ASSERT(fe);
+             fe->addOutlineToPath(x, y, glyphs, this,
+                                  si.analysis.bidiLevel % 2
+diff --git a/qtbase/src/gui/painting/qpathclipper_p.h b/qtbase/src/gui/painting/qpathclipper_p.h
+index 9444a87b71..18f64c5e8c 100644
+--- a/qtbase/src/gui/painting/qpathclipper_p.h
++++ b/qtbase/src/gui/painting/qpathclipper_p.h
+@@ -156,7 +156,7 @@ public:
+     int vertex(Direction direction) const;
+ 
+ private:
+-    int m_next[2][2];
++    int m_next[2][2] = { { -1, -1 }, { -1, -1 } };
+ };
+ 
+ class QPathSegments
+@@ -296,10 +296,6 @@ inline QPathEdge::QPathEdge(int a, int b)
+     , angle(0)
+     , invAngle(0)
+ {
+-    m_next[0][0] = -1;
+-    m_next[1][0] = -1;
+-    m_next[0][0] = -1;
+-    m_next[1][0] = -1;
+ }
+ 
+ inline int QPathEdge::next(Traversal traversal, Direction direction) const
+diff --git a/qtbase/src/gui/painting/qpdf.cpp b/qtbase/src/gui/painting/qpdf.cpp
+index 3066744f1b..2c8d3c3b53 100644
+--- a/qtbase/src/gui/painting/qpdf.cpp
++++ b/qtbase/src/gui/painting/qpdf.cpp
+@@ -2760,6 +2760,8 @@ int QPdfEnginePrivate::addBrushPattern(const QTransform &m, bool *specifyColor,
+         return gradientBrush(brush, matrix, gStateObject);
+     }
+ 
++    matrix = brush.transform() * matrix;
++
+     if ((!brush.isOpaque() && brush.style() < Qt::LinearGradientPattern) || opacity != 1.0)
+         *gStateObject = addConstantAlphaObject(qRound(brush.color().alpha() * opacity),
+                                                qRound(pen.color().alpha() * opacity));
+diff --git a/qtbase/src/gui/painting/qstroker.cpp b/qtbase/src/gui/painting/qstroker.cpp
+index cb5d395e80..3b6357a893 100644
+--- a/qtbase/src/gui/painting/qstroker.cpp
++++ b/qtbase/src/gui/painting/qstroker.cpp
+@@ -1182,6 +1182,7 @@ void QDashStroker::processCurrentSubpath()
+         // Check if the entire line should be clipped away or simplified
+         bool clipIt = clipping && !lineIntersectsRect(prev, e, clip_tl, clip_br);
+         bool skipDashing = elen * invSumLength > repetitionLimit();
++        int maxDashes = dashCount;
+         if (skipDashing || clipIt) {
+             // Cut away full dash sequences.
+             elen -= std::floor(elen * invSumLength) * sumLength;
+@@ -1196,7 +1197,7 @@ void QDashStroker::processCurrentSubpath()
+                     pos = estop; // move pos to next path element
+                     done = true;
+                 } else { // Dash is on this line
+-                    pos = dpos + estart;
++                    pos = --maxDashes > 0 ? dpos + estart : estop;
+                     done = pos >= estop;
+                     if (++idash >= dashCount)
+                         idash = 0;
+diff --git a/qtbase/src/gui/painting/qt_attribution.json b/qtbase/src/gui/painting/qt_attribution.json
+index 7b16e8c211..0e87d30aa2 100644
+--- a/qtbase/src/gui/painting/qt_attribution.json
++++ b/qtbase/src/gui/painting/qt_attribution.json
+@@ -10,7 +10,7 @@
+         "Homepage": "http://www.freetype.org",
+         "License": "Freetype Project License or GNU General Public License v2.0 only",
+         "LicenseId": "FTL or GPL-2.0",
+-        "LicenseFile": "../../3rdparty/freetype/docs/LICENSE.TXT",
++        "LicenseFile": "../../3rdparty/freetype/LICENSE.TXT",
+         "Copyright": "Copyright 2000-2016 by David Turner, Robert Wilhelm, and Werner Lemberg."
+     },
+     {
+diff --git a/qtbase/src/gui/rhi/qshader_p_p.h b/qtbase/src/gui/rhi/qshader_p_p.h
+index ec9d25971f..4a5a7a6d51 100644
+--- a/qtbase/src/gui/rhi/qshader_p_p.h
++++ b/qtbase/src/gui/rhi/qshader_p_p.h
+@@ -68,13 +68,13 @@ struct Q_GUI_EXPORT QShaderPrivate
+     {
+     }
+ 
+-    QShaderPrivate(const QShaderPrivate *other)
++    QShaderPrivate(const QShaderPrivate &other)
+         : ref(1),
+-          qsbVersion(other->qsbVersion),
+-          stage(other->stage),
+-          desc(other->desc),
+-          shaders(other->shaders),
+-          bindings(other->bindings)
++          qsbVersion(other.qsbVersion),
++          stage(other.stage),
++          desc(other.desc),
++          shaders(other.shaders),
++          bindings(other.bindings)
+     {
+     }
+ 
+diff --git a/qtbase/src/gui/rhi/qshaderdescription_p_p.h b/qtbase/src/gui/rhi/qshaderdescription_p_p.h
+index ec2b0b6b4c..3da33a8a2b 100644
+--- a/qtbase/src/gui/rhi/qshaderdescription_p_p.h
++++ b/qtbase/src/gui/rhi/qshaderdescription_p_p.h
+@@ -63,16 +63,16 @@ struct Q_GUI_EXPORT QShaderDescriptionPrivate
+         localSize[0] = localSize[1] = localSize[2] = 0;
+     }
+ 
+-    QShaderDescriptionPrivate(const QShaderDescriptionPrivate *other)
++    QShaderDescriptionPrivate(const QShaderDescriptionPrivate &other)
+         : ref(1),
+-          inVars(other->inVars),
+-          outVars(other->outVars),
+-          uniformBlocks(other->uniformBlocks),
+-          pushConstantBlocks(other->pushConstantBlocks),
+-          storageBlocks(other->storageBlocks),
+-          combinedImageSamplers(other->combinedImageSamplers),
+-          storageImages(other->storageImages),
+-          localSize(other->localSize)
++          inVars(other.inVars),
++          outVars(other.outVars),
++          uniformBlocks(other.uniformBlocks),
++          pushConstantBlocks(other.pushConstantBlocks),
++          storageBlocks(other.storageBlocks),
++          combinedImageSamplers(other.combinedImageSamplers),
++          storageImages(other.storageImages),
++          localSize(other.localSize)
+     {
+     }
+ 
+diff --git a/qtbase/src/gui/text/qfontdatabase.cpp b/qtbase/src/gui/text/qfontdatabase.cpp
+index a657a8c516..4fc0100958 100644
+--- a/qtbase/src/gui/text/qfontdatabase.cpp
++++ b/qtbase/src/gui/text/qfontdatabase.cpp
+@@ -983,7 +983,7 @@ QFontEngine *loadSingleEngine(int script,
+         if (style->key.stretch != 0 && request.stretch != 0
+             && (request.styleName.isEmpty() || request.styleName != style->styleName)) {
+             def.stretch = (request.stretch * 100 + style->key.stretch / 2) / style->key.stretch;
+-        } else {
++        } else if (request.stretch == QFont::AnyStretch) {
+             def.stretch = 100;
+         }
+ 
+diff --git a/qtbase/src/gui/text/qtextdocumentlayout.cpp b/qtbase/src/gui/text/qtextdocumentlayout.cpp
+index f3e6ea2100..72267e9380 100644
+--- a/qtbase/src/gui/text/qtextdocumentlayout.cpp
++++ b/qtbase/src/gui/text/qtextdocumentlayout.cpp
+@@ -2123,7 +2123,7 @@ void QTextDocumentLayoutPrivate::drawListItem(const QPointF &offset, QPainter *p
+ {
+     Q_Q(const QTextDocumentLayout);
+     const QTextBlockFormat blockFormat = bl.blockFormat();
+-    const QTextCharFormat charFormat = QTextCursor(bl).charFormat();
++    const QTextCharFormat charFormat = bl.charFormat();
+     QFont font(charFormat.font());
+     if (q->paintDevice())
+         font = QFont(font, q->paintDevice());
+diff --git a/qtbase/src/gui/text/qtextengine.cpp b/qtbase/src/gui/text/qtextengine.cpp
+index ce4abac472..a6c66e5d2d 100644
+--- a/qtbase/src/gui/text/qtextengine.cpp
++++ b/qtbase/src/gui/text/qtextengine.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2021 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtGui module of the Qt Toolkit.
+@@ -1565,6 +1565,12 @@ void QTextEngine::shapeText(int item) const
+         // Overwrite with 0 token to indicate failure
+         QGlyphLayout g = availableGlyphs(&si);
+         g.glyphs[0] = 0;
++        g.attributes[0].clusterStart = true;
++
++        ushort *log_clusters = logClusters(&si);
++        for (int i = 0; i < itemLength; ++i)
++            log_clusters[i] = 0;
++
+         return;
+     }
+ 
+diff --git a/qtbase/src/gui/util/qdesktopservices.cpp b/qtbase/src/gui/util/qdesktopservices.cpp
+index fbb63a9408..4d5fafaaa7 100644
+--- a/qtbase/src/gui/util/qdesktopservices.cpp
++++ b/qtbase/src/gui/util/qdesktopservices.cpp
+@@ -54,6 +54,8 @@
+ #include <qpa/qplatformintegration.h>
+ #include <qdir.h>
+ 
++#include <QtCore/private/qlocking_p.h>
++
+ QT_BEGIN_NAMESPACE
+ 
+ class QOpenUrlHandlerRegistry : public QObject
+@@ -81,6 +83,7 @@ Q_GLOBAL_STATIC(QOpenUrlHandlerRegistry, handlerRegistry)
+ 
+ void QOpenUrlHandlerRegistry::handlerDestroyed(QObject *handler)
+ {
++    const auto lock = qt_scoped_lock(mutex);
+     HandlerHash::Iterator it = handlers.begin();
+     while (it != handlers.end()) {
+         if (it->receiver == handler) {
+@@ -294,7 +297,8 @@ void QDesktopServices::setUrlHandler(const QString &scheme, QObject *receiver, c
+     h.name = method;
+     registry->handlers.insert(scheme.toLower(), h);
+     QObject::connect(receiver, SIGNAL(destroyed(QObject*)),
+-                     registry, SLOT(handlerDestroyed(QObject*)));
++                     registry, SLOT(handlerDestroyed(QObject*)),
++                     Qt::DirectConnection);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/gui/util/qpkmhandler.cpp b/qtbase/src/gui/util/qpkmhandler.cpp
+index e0c3b75efe..3414f9d8ba 100644
+--- a/qtbase/src/gui/util/qpkmhandler.cpp
++++ b/qtbase/src/gui/util/qpkmhandler.cpp
+@@ -57,7 +57,7 @@ struct PkmType
+     quint32 bytesPerBlock;
+ };
+ 
+-static PkmType typeMap[5] = {
++static constexpr PkmType typeMap[5] = {
+     { 0x8D64,  8 },   // GL_ETC1_RGB8_OES
+     { 0x9274,  8 },   // GL_COMPRESSED_RGB8_ETC2
+     { 0, 0 },         // unused (obsolete)
+diff --git a/qtbase/src/network/access/qnetworkreplyfileimpl.cpp b/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
+index b6be93147a..6e69b4c4d3 100644
+--- a/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
++++ b/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
+@@ -89,9 +89,10 @@ QNetworkReplyFileImpl::QNetworkReplyFileImpl(QNetworkAccessManager *manager, con
+         // we handle only local files
+         QString msg = QCoreApplication::translate("QNetworkAccessFileBackend", "Request for opening non-local file %1").arg(url.toString());
+         setError(QNetworkReply::ProtocolInvalidOperationError, msg);
++        setFinished(true); // We're finished, will emit finished() after ctor is done.
+         QMetaObject::invokeMethod(this, "errorOccurred", Qt::QueuedConnection,
+             Q_ARG(QNetworkReply::NetworkError, QNetworkReply::ProtocolInvalidOperationError));
+-        fileOpenFinished(false);
++        QMetaObject::invokeMethod(this, [this](){ fileOpenFinished(false); }, Qt::QueuedConnection);
+         return;
+     }
+ #endif
+diff --git a/qtbase/src/network/access/qnetworkreplyimpl.cpp b/qtbase/src/network/access/qnetworkreplyimpl.cpp
+index bcdf6ee2f1..3b6deb82bd 100644
+--- a/qtbase/src/network/access/qnetworkreplyimpl.cpp
++++ b/qtbase/src/network/access/qnetworkreplyimpl.cpp
+@@ -680,7 +680,7 @@ void QNetworkReplyImplPrivate::appendDownstreamData(QIODevice *data)
+     // read until EOF from data
+     if (Q_UNLIKELY(copyDevice)) {
+         qCritical("QNetworkReplyImpl: copy from QIODevice already in progress -- "
+-                  "backend probly needs to be fixed");
++                  "backend probably needs to be fixed");
+         return;
+     }
+ 
+diff --git a/qtbase/src/network/kernel/qauthenticator.cpp b/qtbase/src/network/kernel/qauthenticator.cpp
+index d9fe7bc47b..ccd04b294a 100644
+--- a/qtbase/src/network/kernel/qauthenticator.cpp
++++ b/qtbase/src/network/kernel/qauthenticator.cpp
+@@ -50,6 +50,7 @@
+ #include <qstring.h>
+ #include <qdatetime.h>
+ #include <qrandom.h>
++#include "private/qsystemlibrary_p.h"
+ 
+ #ifdef Q_OS_WIN
+ #include <qmutex.h>
+@@ -1563,7 +1564,7 @@ static bool q_SSPI_library_load()
+ 
+     // Initialize security interface
+     if (pSecurityFunctionTable == nullptr) {
+-        securityDLLHandle = LoadLibrary(L"secur32.dll");
++        securityDLLHandle = QSystemLibrary::load(L"secur32");
+         if (securityDLLHandle != nullptr) {
+             INIT_SECURITY_INTERFACE pInitSecurityInterface =
+                 reinterpret_cast<INIT_SECURITY_INTERFACE>(
+diff --git a/qtbase/src/network/kernel/qhostinfo_unix.cpp b/qtbase/src/network/kernel/qhostinfo_unix.cpp
+index 9b0a2ee669..73679c9ef1 100644
+--- a/qtbase/src/network/kernel/qhostinfo_unix.cpp
++++ b/qtbase/src/network/kernel/qhostinfo_unix.cpp
+@@ -122,7 +122,6 @@ static QFunctionPointer resolveSymbol(QLibrary &lib, const char *sym)
+ 
+ LibResolv::LibResolv()
+ {
+-    QLibrary lib;
+ #ifdef LIBRESOLV_SO
+     lib.setFileName(QStringLiteral(LIBRESOLV_SO));
+     if (!lib.load())
+diff --git a/qtbase/src/network/socket/qsocks5socketengine.cpp b/qtbase/src/network/socket/qsocks5socketengine.cpp
+index 3a046fd116..97fadca0b3 100644
+--- a/qtbase/src/network/socket/qsocks5socketengine.cpp
++++ b/qtbase/src/network/socket/qsocks5socketengine.cpp
+@@ -1296,7 +1296,7 @@ void QSocks5SocketEnginePrivate::_q_udpSocketReadNotification()
+         int pos = 0;
+         const char *buf = inBuf.constData();
+         if (inBuf.size() < 4) {
+-            QSOCKS5_D_DEBUG << "bugus udp data, discarding";
++            QSOCKS5_D_DEBUG << "bogus udp data, discarding";
+             return;
+         }
+         QSocks5RevivedDatagram datagram;
+diff --git a/qtbase/src/network/ssl/qsslcontext_openssl.cpp b/qtbase/src/network/ssl/qsslcontext_openssl.cpp
+index c9f202f573..c992da9d8e 100644
+--- a/qtbase/src/network/ssl/qsslcontext_openssl.cpp
++++ b/qtbase/src/network/ssl/qsslcontext_openssl.cpp
+@@ -409,7 +409,7 @@ init_context:
+         break;
+     case QSsl::DtlsV1_0OrLater:
+         minVersion = DTLS1_VERSION;
+-        maxVersion = DTLS_MAX_VERSION;
++        maxVersion = 0;
+         break;
+     case QSsl::DtlsV1_2:
+         minVersion = DTLS1_2_VERSION;
+@@ -417,7 +417,7 @@ init_context:
+         break;
+     case QSsl::DtlsV1_2OrLater:
+         minVersion = DTLS1_2_VERSION;
+-        maxVersion = DTLS_MAX_VERSION;
++        maxVersion = 0;
+         break;
+     case QSsl::TlsV1_3OrLater:
+ #ifdef TLS1_3_VERSION
+@@ -455,7 +455,7 @@ init_context:
+     }
+ 
+     // Enable bug workarounds.
+-    long options = QSslSocketBackendPrivate::setupOpenSslOptions(configuration.protocol(), configuration.d->sslOptions);
++    qssloptions options = QSslSocketBackendPrivate::setupOpenSslOptions(configuration.protocol(), configuration.d->sslOptions);
+     q_SSL_CTX_set_options(sslContext->ctx, options);
+ 
+     // Tell OpenSSL to release memory early
+diff --git a/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp b/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
+index aaf8741130..b58935372c 100644
+--- a/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
++++ b/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
+@@ -59,57 +59,6 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-#ifdef OPENSSL_NO_DEPRECATED_3_0
+-
+-static int q_DH_check(DH *dh, int *status)
+-{
+-    // DH_check was first deprecated in OpenSSL 3.0.0, as low-level
+-    // API; the EVP_PKEY family of functions was advised as an alternative.
+-    // As of now EVP_PKEY_params_check ends up calling ... DH_check,
+-    // which is good enough.
+-
+-    Q_ASSERT(dh);
+-    Q_ASSERT(status);
+-
+-    EVP_PKEY *key = q_EVP_PKEY_new();
+-    if (!key) {
+-        qCWarning(lcSsl, "EVP_PKEY_new failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-    const auto keyDeleter = qScopeGuard([key](){
+-        q_EVP_PKEY_free(key);
+-    });
+-    if (!q_EVP_PKEY_set1_DH(key, dh)) {
+-        qCWarning(lcSsl, "EVP_PKEY_set1_DH failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-
+-    EVP_PKEY_CTX *keyCtx = q_EVP_PKEY_CTX_new(key, nullptr);
+-    if (!keyCtx) {
+-        qCWarning(lcSsl, "EVP_PKEY_CTX_new failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-    const auto ctxDeleter = qScopeGuard([keyCtx]{
+-        q_EVP_PKEY_CTX_free(keyCtx);
+-    });
+-
+-    const int result = q_EVP_PKEY_param_check(keyCtx);
+-    QSslSocketBackendPrivate::logAndClearErrorQueue();
+-    // Note: unlike DH_check, we cannot obtain the 'status',
+-    // if the 'result' is 0 (actually the result is 1 only
+-    // if this 'status' was 0). We could probably check the
+-    // errors from the error queue, but it's not needed anyway
+-    // - see the 'isSafeDH' below, how it returns immediately
+-    // on 0.
+-    Q_UNUSED(status)
+-
+-    return result;
+-}
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+-
+ static bool isSafeDH(DH *dh)
+ {
+     int status = 0;
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl.cpp b/qtbase/src/network/ssl/qsslsocket_openssl.cpp
+index 37fad2a68f..8f6858c867 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl.cpp
++++ b/qtbase/src/network/ssl/qsslsocket_openssl.cpp
+@@ -550,9 +550,9 @@ static void q_loadCiphersForConnection(SSL *connection, QList<QSslCipher> &ciphe
+ // Defined in qsslsocket.cpp
+ void q_setDefaultDtlsCiphers(const QList<QSslCipher> &ciphers);
+ 
+-long QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions)
++qssloptions QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions)
+ {
+-    long options;
++    qssloptions options;
+     if (protocol == QSsl::TlsV1SslV3)
+         options = SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3;
+     else if (protocol == QSsl::SecureProtocols)
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_p.h b/qtbase/src/network/ssl/qsslsocket_openssl_p.h
+index 4103de23e8..5547589256 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_p.h
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_p.h
+@@ -107,6 +107,12 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++typedef uint64_t qssloptions;
++#else
++typedef unsigned long qssloptions;
++#endif
++
+ struct QSslErrorEntry {
+     int code;
+     int depth;
+@@ -171,7 +177,7 @@ public:
+     QVector<QSslError> ocspErrors;
+     QByteArray ocspResponseDer;
+ 
+-    Q_AUTOTEST_EXPORT static long setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions);
++    Q_AUTOTEST_EXPORT static qssloptions setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions);
+     static QSslCipher QSslCipher_from_SSL_CIPHER(const SSL_CIPHER *cipher);
+     static QList<QSslCertificate> STACKOFX509_to_QSslCertificates(STACK_OF(X509) *x509);
+     static QList<QSslError> verify(const QList<QSslCertificate> &certificateChain, const QString &hostName);
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp b/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
+index e53fb279f0..459ccd0b19 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
+@@ -148,7 +148,6 @@ DEFINEFUNC(int, EVP_PKEY_up_ref, EVP_PKEY *a, a, return 0, return)
+ DEFINEFUNC2(EVP_PKEY_CTX *, EVP_PKEY_CTX_new, EVP_PKEY *pkey, pkey, ENGINE *e, e, return nullptr, return)
+ DEFINEFUNC(int, EVP_PKEY_param_check, EVP_PKEY_CTX *ctx, ctx, return 0, return)
+ DEFINEFUNC(void, EVP_PKEY_CTX_free, EVP_PKEY_CTX *ctx, ctx, return, return)
+-DEFINEFUNC(int, EVP_PKEY_base_id, EVP_PKEY *a, a, return NID_undef, return)
+ DEFINEFUNC(int, RSA_bits, RSA *a, a, return 0, return)
+ DEFINEFUNC(int, DSA_bits, DSA *a, a, return 0, return)
+ DEFINEFUNC(int, OPENSSL_sk_num, OPENSSL_STACK *a, a, return -1, return)
+@@ -158,7 +157,7 @@ DEFINEFUNC2(void, OPENSSL_sk_push, OPENSSL_STACK *a, a, void *b, b, return, DUMM
+ DEFINEFUNC(void, OPENSSL_sk_free, OPENSSL_STACK *a, a, return, DUMMYARG)
+ DEFINEFUNC2(void *, OPENSSL_sk_value, OPENSSL_STACK *a, a, int b, b, return nullptr, return)
+ DEFINEFUNC(int, SSL_session_reused, SSL *a, a, return 0, return)
+-DEFINEFUNC2(unsigned long, SSL_CTX_set_options, SSL_CTX *ctx, ctx, unsigned long op, op, return 0, return)
++DEFINEFUNC2(qssloptions, SSL_CTX_set_options, SSL_CTX *ctx, ctx, qssloptions op, op, return 0, return)
+ DEFINEFUNC(int, SSL_CTX_get_security_level, const SSL_CTX *ctx, ctx, return -1, return)
+ DEFINEFUNC2(void, SSL_CTX_set_security_level, SSL_CTX *ctx, ctx, int level, level, return, return)
+ #ifdef TLS1_3_VERSION
+@@ -371,7 +370,15 @@ DEFINEFUNC(const SSL_CIPHER *, SSL_get_current_cipher, SSL *a, a, return nullptr
+ DEFINEFUNC(int, SSL_version, const SSL *a, a, return 0, return)
+ DEFINEFUNC2(int, SSL_get_error, SSL *a, a, int b, b, return -1, return)
+ DEFINEFUNC(STACK_OF(X509) *, SSL_get_peer_cert_chain, SSL *a, a, return nullptr, return)
++
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++DEFINEFUNC(X509 *, SSL_get1_peer_certificate, SSL *a, a, return nullptr, return)
++DEFINEFUNC(int, EVP_PKEY_get_base_id, const EVP_PKEY *pkey, pkey, return -1, return)
++#else
+ DEFINEFUNC(X509 *, SSL_get_peer_certificate, SSL *a, a, return nullptr, return)
++DEFINEFUNC(int, EVP_PKEY_base_id, EVP_PKEY *a, a, return NID_undef, return)
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+ DEFINEFUNC(long, SSL_get_verify_result, const SSL *a, a, return -1, return)
+ DEFINEFUNC(SSL *, SSL_new, SSL_CTX *a, a, return nullptr, return)
+ DEFINEFUNC(SSL_CTX *, SSL_get_SSL_CTX, SSL *a, a, return nullptr, return)
+@@ -492,9 +499,7 @@ DEFINEFUNC(DH *, DH_new, DUMMYARG, DUMMYARG, return nullptr, return)
+ DEFINEFUNC(void, DH_free, DH *dh, dh, return, DUMMYARG)
+ DEFINEFUNC3(DH *, d2i_DHparams, DH**a, a, const unsigned char **pp, pp, long length, length, return nullptr, return)
+ DEFINEFUNC2(int, i2d_DHparams, DH *a, a, unsigned char **p, p, return -1, return)
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+ DEFINEFUNC2(int, DH_check, DH *dh, dh, int *codes, codes, return 0, return)
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+ DEFINEFUNC3(BIGNUM *, BN_bin2bn, const unsigned char *s, s, int len, len, BIGNUM *ret, ret, return nullptr, return)
+ 
+ #ifndef OPENSSL_NO_EC
+@@ -868,7 +873,6 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(EVP_PKEY_CTX_new)
+     RESOLVEFUNC(EVP_PKEY_param_check)
+     RESOLVEFUNC(EVP_PKEY_CTX_free)
+-    RESOLVEFUNC(EVP_PKEY_base_id)
+     RESOLVEFUNC(RSA_bits)
+     RESOLVEFUNC(OPENSSL_sk_new_null)
+     RESOLVEFUNC(OPENSSL_sk_push)
+@@ -1107,7 +1111,15 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(SSL_version)
+     RESOLVEFUNC(SSL_get_error)
+     RESOLVEFUNC(SSL_get_peer_cert_chain)
++
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++    RESOLVEFUNC(SSL_get1_peer_certificate)
++    RESOLVEFUNC(EVP_PKEY_get_base_id)
++#else
+     RESOLVEFUNC(SSL_get_peer_certificate)
++    RESOLVEFUNC(EVP_PKEY_base_id)
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+     RESOLVEFUNC(SSL_get_verify_result)
+     RESOLVEFUNC(SSL_new)
+     RESOLVEFUNC(SSL_get_SSL_CTX)
+@@ -1206,9 +1218,7 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(DH_free)
+     RESOLVEFUNC(d2i_DHparams)
+     RESOLVEFUNC(i2d_DHparams)
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+     RESOLVEFUNC(DH_check)
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+     RESOLVEFUNC(BN_bin2bn)
+ 
+ #ifndef OPENSSL_NO_EC
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h b/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
+index 95e8897a3b..27aeffa18a 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
+@@ -237,7 +237,6 @@ Q_AUTOTEST_EXPORT int q_EVP_PKEY_up_ref(EVP_PKEY *a);
+ EVP_PKEY_CTX *q_EVP_PKEY_CTX_new(EVP_PKEY *pkey, ENGINE *e);
+ void q_EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx);
+ int q_EVP_PKEY_param_check(EVP_PKEY_CTX *ctx);
+-int q_EVP_PKEY_base_id(EVP_PKEY *a);
+ int q_RSA_bits(RSA *a);
+ Q_AUTOTEST_EXPORT int q_OPENSSL_sk_num(OPENSSL_STACK *a);
+ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_pop_free(OPENSSL_STACK *a, void (*b)(void *));
+@@ -246,7 +245,7 @@ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_push(OPENSSL_STACK *st, void *data);
+ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_free(OPENSSL_STACK *a);
+ Q_AUTOTEST_EXPORT void * q_OPENSSL_sk_value(OPENSSL_STACK *a, int b);
+ int q_SSL_session_reused(SSL *a);
+-unsigned long q_SSL_CTX_set_options(SSL_CTX *ctx, unsigned long op);
++qssloptions q_SSL_CTX_set_options(SSL_CTX *ctx, qssloptions op);
+ int q_OPENSSL_init_ssl(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings);
+ size_t q_SSL_get_client_random(SSL *a, unsigned char *out, size_t outlen);
+ size_t q_SSL_SESSION_get_master_key(const SSL_SESSION *session, unsigned char *out, size_t outlen);
+@@ -510,7 +509,6 @@ const SSL_CIPHER *q_SSL_get_current_cipher(SSL *a);
+ int q_SSL_version(const SSL *a);
+ int q_SSL_get_error(SSL *a, int b);
+ STACK_OF(X509) *q_SSL_get_peer_cert_chain(SSL *a);
+-X509 *q_SSL_get_peer_certificate(SSL *a);
+ long q_SSL_get_verify_result(const SSL *a);
+ SSL *q_SSL_new(SSL_CTX *a);
+ SSL_CTX *q_SSL_get_SSL_CTX(SSL *a);
+@@ -582,10 +580,7 @@ DH *q_DH_new();
+ void q_DH_free(DH *dh);
+ DH *q_d2i_DHparams(DH **a, const unsigned char **pp, long length);
+ int q_i2d_DHparams(DH *a, unsigned char **p);
+-
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+ int q_DH_check(DH *dh, int *codes);
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+ 
+ BIGNUM *q_BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret);
+ #define q_SSL_CTX_set_tmp_dh(ctx, dh) q_SSL_CTX_ctrl((ctx), SSL_CTRL_SET_TMP_DH, 0, (char *)dh)
+@@ -754,6 +749,17 @@ void q_CRYPTO_free(void *str, const char *file, int line);
+ int q_SSL_CTX_get_security_level(const SSL_CTX *ctx);
+ void q_SSL_CTX_set_security_level(SSL_CTX *ctx, int level);
+ 
++// Here we have the ones that make difference between OpenSSL pre/post v3:
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++X509 *q_SSL_get1_peer_certificate(SSL *a);
++#define q_SSL_get_peer_certificate q_SSL_get1_peer_certificate
++int q_EVP_PKEY_get_base_id(const EVP_PKEY *pkey);
++#define q_EVP_PKEY_base_id q_EVP_PKEY_get_base_id
++#else
++X509 *q_SSL_get_peer_certificate(SSL *a);
++int q_EVP_PKEY_base_id(EVP_PKEY *a);
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+ QT_END_NAMESPACE
+ 
+ #endif
+diff --git a/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h b/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
+index bf37d07fd8..dbd42fb799 100644
+--- a/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
++++ b/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
+@@ -61,7 +61,11 @@
+ # if !defined(Q_OS_INTEGRITY)
+ #  define WIN_INTERFACE_CUSTOM   // NV
+ # endif // Q_OS_INTEGRITY
+-#endif  // QT_EGL_NO_X11
++#else // QT_EGL_NO_X11
++// If one has an eglplatform.h with https://github.com/KhronosGroup/EGL-Registry/pull/130
++// that needs USE_X11 to be defined.
++# define USE_X11
++#endif
+ 
+ #ifdef QT_EGL_WAYLAND
+ # define WAYLAND // NV
+diff --git a/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+index 159b490ce0..00aa80cd58 100644
+--- a/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
++++ b/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+@@ -567,6 +567,8 @@ void QFontconfigDatabase::populateFontDatabase()
+         fonts = FcFontList(nullptr, pattern, os);
+         FcObjectSetDestroy(os);
+         FcPatternDestroy(pattern);
++        if (!fonts)
++            return;
+     }
+ 
+     for (int i = 0; i < fonts->nfont; i++)
+diff --git a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
+index b713c19447..7cb9a8c79a 100644
+--- a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
++++ b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
+@@ -95,6 +95,7 @@ static constexpr const auto KeyTbl = qMakeArray(
+         Xkb2Qt<XKB_KEY_Clear,                   Qt::Key_Delete>,
+         Xkb2Qt<XKB_KEY_Pause,                   Qt::Key_Pause>,
+         Xkb2Qt<XKB_KEY_Print,                   Qt::Key_Print>,
++        Xkb2Qt<XKB_KEY_Sys_Req,                 Qt::Key_SysReq>,
+         Xkb2Qt<0x1005FF60,                      Qt::Key_SysReq>,         // hardcoded Sun SysReq
+         Xkb2Qt<0x1007ff00,                      Qt::Key_SysReq>,         // hardcoded X386 SysReq
+ 
+@@ -471,7 +472,7 @@ QVector<xkb_keysym_t> QXkbCommon::toKeysym(QKeyEvent *event)
+     } else if (event->modifiers() & Qt::KeypadModifier) {
+         if (qtKey >= Qt::Key_0 && qtKey <= Qt::Key_9)
+             keysyms.append(XKB_KEY_KP_0 + (qtKey - Qt::Key_0));
+-    } else if (isLatin(qtKey) && event->text().isUpper()) {
++    } else if (isLatin1(qtKey) && event->text().isUpper()) {
+         keysyms.append(qtKey);
+     }
+ 
+@@ -523,7 +524,7 @@ int QXkbCommon::keysymToQtKey(xkb_keysym_t keysym, Qt::KeyboardModifiers modifie
+         // With standard shortcuts we should prefer a latin character, this is
+         // for checks like "some qkeyevent == QKeySequence::Copy" to work even
+         // when using for example 'russian' keyboard layout.
+-        if (!QXkbCommon::isLatin(keysym)) {
++        if (!QXkbCommon::isLatin1(keysym)) {
+             xkb_keysym_t latinKeysym = QXkbCommon::lookupLatinKeysym(state, code);
+             if (latinKeysym != XKB_KEY_NoSymbol)
+                 keysym = latinKeysym;
+@@ -546,7 +547,7 @@ static int keysymToQtKey_internal(xkb_keysym_t keysym, Qt::KeyboardModifiers mod
+     } else if (keysym >= XKB_KEY_KP_0 && keysym <= XKB_KEY_KP_9) {
+         // numeric keypad keys
+         qtKey = Qt::Key_0 + (keysym - XKB_KEY_KP_0);
+-    } else if (QXkbCommon::isLatin(keysym)) {
++    } else if (QXkbCommon::isLatin1(keysym)) {
+         qtKey = QXkbCommon::qxkbcommon_xkb_keysym_to_upper(keysym);
+     } else {
+         // check if we have a direct mapping
+@@ -678,7 +679,7 @@ QList<int> QXkbCommon::possibleKeys(xkb_state *state, const QKeyEvent *event,
+         Qt::KeyboardModifiers neededMods = ModsTbl[i];
+         if ((modifiers & neededMods) == neededMods) {
+             if (i == 8) {
+-                if (isLatin(baseQtKey))
++                if (isLatin1(baseQtKey))
+                     continue;
+                 // add a latin key as a fall back key
+                 sym = lookupLatinKeysym(state, keycode);
+@@ -733,7 +734,7 @@ void QXkbCommon::verifyHasLatinLayout(xkb_keymap *keymap)
+     for (xkb_layout_index_t layout = 0; layout < layoutCount; ++layout) {
+         for (xkb_keycode_t code = minKeycode; code < maxKeycode; ++code) {
+             xkb_keymap_key_get_syms_by_level(keymap, code, layout, 0, &keysyms);
+-            if (keysyms && isLatin(keysyms[0]))
++            if (keysyms && isLatin1(keysyms[0]))
+                 nrLatinKeys++;
+             if (nrLatinKeys > 10) // arbitrarily chosen threshold
+                 return;
+@@ -766,7 +767,7 @@ xkb_keysym_t QXkbCommon::lookupLatinKeysym(xkb_state *state, xkb_keycode_t keyco
+         xkb_level_index_t level = xkb_state_key_get_level(state, keycode, layout);
+         if (xkb_keymap_key_get_syms_by_level(keymap, keycode, layout, level, &syms) != 1)
+             continue;
+-        if (isLatin(syms[0])) {
++        if (isLatin1(syms[0])) {
+             sym = syms[0];
+             break;
+         }
+diff --git a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
+index 561eae03db..8389bd8f5a 100644
+--- a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
++++ b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
+@@ -94,8 +94,8 @@ public:
+     static void verifyHasLatinLayout(xkb_keymap *keymap);
+     static xkb_keysym_t lookupLatinKeysym(xkb_state *state, xkb_keycode_t keycode);
+ 
+-    static bool isLatin(xkb_keysym_t sym) {
+-        return ((sym >= 'a' && sym <= 'z') || (sym >= 'A' && sym <= 'Z'));
++    static bool isLatin1(xkb_keysym_t sym) {
++        return sym <= 0xff;
+     }
+     static bool isKeypad(xkb_keysym_t sym) {
+         return sym >= XKB_KEY_KP_Space && sym <= XKB_KEY_KP_9;
+diff --git a/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp b/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
+index 8cd7f9b368..406f84663f 100644
+--- a/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
++++ b/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
+@@ -318,7 +318,7 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources,
+ 
+     if (current < 0 && crtc_mode.clock != 0) {
+         modes << crtc_mode;
+-        current = mode.size() - 1;
++        current = modes.size() - 1;
+     }
+ 
+     if (configuration == OutputConfigCurrent)
+diff --git a/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp b/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
+index 9153fd20bb..255ea5e33e 100644
+--- a/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
++++ b/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
+@@ -194,6 +194,9 @@ QString AtSpiAdaptor::introspect(const QString &path) const
+                 "      <arg direction=\"out\" type=\"(so)\"/>\n"
+                 "      <annotation value=\"QSpiObjectReference\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n"
+                 "    </method>\n"
++                "    <method name=\"GetAccessibleId\">\n"
++                "      <arg direction=\"out\" type=\"s\"/>\n"
++                "    </method>\n"
+                 "  </interface>\n"
+                 );
+ 
+@@ -913,8 +916,17 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+     }
+     case QAccessible::NameChanged: {
+         if (sendObject || sendObject_property_change || sendObject_property_change_accessible_name) {
+-            QString path = pathForInterface(event->accessibleInterface());
+-            QVariantList args = packDBusSignalArguments(QLatin1String("accessible-name"), 0, 0, variantForPath(path));
++            QAccessibleInterface *iface = event->accessibleInterface();
++            if (!iface) {
++                qCDebug(lcAccessibilityAtspi,
++                        "NameChanged event from invalid accessible.");
++                return;
++            }
++
++            QString path = pathForInterface(iface);
++            QVariantList args = packDBusSignalArguments(
++                QLatin1String("accessible-name"), 0, 0,
++                QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Name))));
+             sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                            QLatin1String("PropertyChange"), args);
+         }
+@@ -922,8 +934,17 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+     }
+     case QAccessible::DescriptionChanged: {
+         if (sendObject || sendObject_property_change || sendObject_property_change_accessible_description) {
+-            QString path = pathForInterface(event->accessibleInterface());
+-            QVariantList args = packDBusSignalArguments(QLatin1String("accessible-description"), 0, 0, variantForPath(path));
++            QAccessibleInterface *iface = event->accessibleInterface();
++            if (!iface) {
++                qCDebug(lcAccessibilityAtspi,
++                        "DescriptionChanged event from invalid accessible.");
++                return;
++            }
++
++            QString path = pathForInterface(iface);
++            QVariantList args = packDBusSignalArguments(
++                QLatin1String("accessible-description"), 0, 0,
++                QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Description))));
+             sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                            QLatin1String("PropertyChange"), args);
+         }
+@@ -1038,7 +1059,9 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+                 // Combo Box with AT-SPI likes to be special
+                 // It requires a name-change to update caches and then selection-changed
+                 QString path = pathForInterface(iface);
+-                QVariantList args1 = packDBusSignalArguments(QLatin1String("accessible-name"), 0, 0, variantForPath(path));
++                QVariantList args1 = packDBusSignalArguments(
++                    QLatin1String("accessible-name"), 0, 0,
++                    QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Name))));
+                 sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                                QLatin1String("PropertyChange"), args1);
+                 QVariantList args2 = packDBusSignalArguments(QString(), 0, 0, QVariant::fromValue(QDBusVariant(QVariant(0))));
+@@ -1358,6 +1381,26 @@ void AtSpiAdaptor::registerApplication()
+     delete registry;
+ }
+ 
++namespace {
++QString accessibleIdForAccessible(QAccessibleInterface *accessible)
++{
++    QString result;
++    while (accessible) {
++        if (!result.isEmpty())
++            result.prepend(QLatin1Char('.'));
++        if (auto obj = accessible->object()) {
++            const QString name = obj->objectName();
++            if (!name.isEmpty())
++                result.prepend(name);
++            else
++                result.prepend(QString::fromUtf8(obj->metaObject()->className()));
++        }
++        accessible = accessible->parent();
++    }
++    return result;
++}
++} // namespace
++
+ // Accessible
+ bool AtSpiAdaptor::accessibleInterface(QAccessibleInterface *interface, const QString &function, const QDBusMessage &message, const QDBusConnection &connection)
+ {
+@@ -1441,6 +1484,9 @@ bool AtSpiAdaptor::accessibleInterface(QAccessibleInterface *interface, const QS
+             children << ref;
+         }
+         connection.send(message.createReply(QVariant::fromValue(children)));
++    } else if (function == QLatin1String("GetAccessibleId")) {
++        sendReply(connection, message,
++                  QVariant::fromValue(QDBusVariant(accessibleIdForAccessible(interface))));
+     } else {
+         qCDebug(lcAccessibilityAtspi) << "WARNING: AtSpiAdaptor::accessibleInterface does not implement " << function << message.path();
+         return false;
+diff --git a/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp b/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
+index 45ddc8e496..cc734abc63 100644
+--- a/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
++++ b/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
+@@ -69,6 +69,21 @@ QT_BEGIN_NAMESPACE
+ DBusConnection::DBusConnection(QObject *parent)
+     : QObject(parent), m_a11yConnection(QString()), m_enabled(false)
+ {
++    // If the bus is explicitly set via env var it overrides everything else.
++    QByteArray addressEnv = qgetenv("AT_SPI_BUS_ADDRESS");
++    if (!addressEnv.isEmpty()) {
++        // Only connect on next loop run, connections to our enabled signal are
++        // only established after the ctor returns.
++        QMetaObject::invokeMethod(
++                this,
++                [this, addressEnv] {
++                    m_enabled = true;
++                    connectA11yBus(QString::fromLocal8Bit(addressEnv));
++                },
++                Qt::QueuedConnection);
++        return;
++    }
++
+     // Start monitoring if "org.a11y.Bus" is registered as DBus service.
+     QDBusConnection c = QDBusConnection::sessionBus();
+     if (!c.isConnected()) {
+diff --git a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
+index 1a3cab275d..2abe039126 100644
+--- a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
++++ b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
+@@ -51,6 +51,9 @@
+ #include <QtCore/QStandardPaths>
+ #include <QtCore/QUrl>
+ 
++#include <QtGui/QGuiApplication>
++#include <QtGui/QWindow>
++
+ #if QT_CONFIG(dbus)
+ // These QtCore includes are needed for xdg-desktop-portal support
+ #include <QtCore/private/qcore_unix_p.h>
+@@ -58,6 +61,8 @@
+ #include <QtCore/QFileInfo>
+ #include <QtCore/QUrlQuery>
+ 
++#include <QtGui/QColor>
++
+ #include <QtDBus/QDBusConnection>
+ #include <QtDBus/QDBusMessage>
+ #include <QtDBus/QDBusPendingCall>
+@@ -142,6 +147,8 @@ static inline bool detectWebBrowser(const QByteArray &desktop,
+     }
+ 
+     if (desktop == QByteArray("KDE")) {
++        if (checkExecutable(QStringLiteral("kde-open5"), browser))
++            return true;
+         // Konqueror launcher
+         if (checkExecutable(QStringLiteral("kfmclient"), browser)) {
+             browser->append(QLatin1String(" exec"));
+@@ -296,8 +303,135 @@ static inline QDBusMessage xdgDesktopPortalSendEmail(const QUrl &url)
+ 
+     return QDBusConnection::sessionBus().call(message);
+ }
++
++namespace {
++struct XDGDesktopColor
++{
++    double r = 0;
++    double g = 0;
++    double b = 0;
++
++    QColor toQColor() const
++    {
++        constexpr auto rgbMax = 255;
++        return { static_cast<int>(r * rgbMax), static_cast<int>(g * rgbMax),
++                 static_cast<int>(b * rgbMax) };
++    }
++};
++
++const QDBusArgument &operator>>(const QDBusArgument &argument, XDGDesktopColor &myStruct)
++{
++    argument.beginStructure();
++    argument >> myStruct.r >> myStruct.g >> myStruct.b;
++    argument.endStructure();
++    return argument;
++}
++
++class XdgDesktopPortalColorPicker : public QPlatformServiceColorPicker
++{
++    Q_OBJECT
++public:
++    XdgDesktopPortalColorPicker(const QString &parentWindowId, QWindow *parent)
++        : QPlatformServiceColorPicker(parent), m_parentWindowId(parentWindowId)
++    {
++    }
++
++    void pickColor() override
++    {
++        // DBus signature:
++        // PickColor (IN   s      parent_window,
++        //            IN   a{sv}  options
++        //            OUT  o      handle)
++        // Options:
++        // handle_token (s) -  A string that will be used as the last element of the @handle.
++
++        QDBusMessage message = QDBusMessage::createMethodCall(
++                QStringLiteral("org.freedesktop.portal.Desktop"), QStringLiteral("/org/freedesktop/portal/desktop"),
++                QStringLiteral("org.freedesktop.portal.Screenshot"), QStringLiteral("PickColor"));
++        message << m_parentWindowId << QVariantMap();
++
++        QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
++        auto watcher = new QDBusPendingCallWatcher(pendingCall, this);
++        connect(watcher, &QDBusPendingCallWatcher::finished, this,
++                [this](QDBusPendingCallWatcher *watcher) {
++                    watcher->deleteLater();
++                    QDBusPendingReply<QDBusObjectPath> reply = *watcher;
++                    if (reply.isError()) {
++                        qWarning("DBus call to pick color failed: %s",
++                                 qPrintable(reply.error().message()));
++                        Q_EMIT colorPicked({});
++                    } else {
++                        QDBusConnection::sessionBus().connect(
++                                QStringLiteral("org.freedesktop.portal.Desktop"), reply.value().path(),
++                                QStringLiteral("org.freedesktop.portal.Request"), QStringLiteral("Response"), this,
++                                // clang-format off
++                                SLOT(gotColorResponse(uint,QVariantMap))
++                                // clang-format on
++                        );
++                    }
++                });
++    }
++
++private Q_SLOTS:
++    void gotColorResponse(uint result, const QVariantMap &map)
++    {
++        if (result != 0)
++            return;
++        XDGDesktopColor color{};
++        map.value(QStringLiteral("color")).value<QDBusArgument>() >> color;
++        Q_EMIT colorPicked(color.toQColor());
++        deleteLater();
++    }
++
++private:
++    const QString m_parentWindowId;
++};
++} // namespace
++
+ #endif // QT_CONFIG(dbus)
+ 
++QGenericUnixServices::QGenericUnixServices()
++{
++#if QT_CONFIG(dbus)
++    if (qEnvironmentVariableIntValue("QT_NO_XDG_DESKTOP_PORTAL") > 0) {
++        return;
++    }
++    QDBusMessage message = QDBusMessage::createMethodCall(
++            QStringLiteral("org.freedesktop.portal.Desktop"), QStringLiteral("/org/freedesktop/portal/desktop"),
++            QStringLiteral("org.freedesktop.DBus.Properties"), QStringLiteral("Get"));
++    message << QStringLiteral("org.freedesktop.portal.Screenshot")
++            << QStringLiteral("version");
++
++    QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
++    auto watcher = new QDBusPendingCallWatcher(pendingCall);
++    QObject::connect(watcher, &QDBusPendingCallWatcher::finished, watcher,
++                     [this](QDBusPendingCallWatcher *watcher) {
++                         watcher->deleteLater();
++                         QDBusPendingReply<QVariant> reply = *watcher;
++                         if (!reply.isError() && reply.value().toUInt() >= 2)
++                             m_hasScreenshotPortalWithColorPicking = true;
++                     });
++
++#endif
++}
++
++QPlatformServiceColorPicker *QGenericUnixServices::colorPicker(QWindow *parent)
++{
++#if QT_CONFIG(dbus)
++    // Make double sure that we are in a wayland environment. In particular check
++    // WAYLAND_DISPLAY so also XWayland apps benefit from portal-based color picking.
++    // Outside wayland we'll rather rely on other means than the XDG desktop portal.
++    if (!qEnvironmentVariableIsEmpty("WAYLAND_DISPLAY")
++        || QGuiApplication::platformName().startsWith(QLatin1String("wayland"))) {
++        return new XdgDesktopPortalColorPicker(portalWindowIdentifier(parent), parent);
++    }
++    return nullptr;
++#else
++    Q_UNUSED(parent);
++    return nullptr;
++#endif
++}
++
+ QByteArray QGenericUnixServices::desktopEnvironment() const
+ {
+     static const QByteArray result = detectDesktopEnvironment();
+@@ -352,6 +486,8 @@ bool QGenericUnixServices::openDocument(const QUrl &url)
+ }
+ 
+ #else
++QGenericUnixServices::QGenericUnixServices() = default;
++
+ QByteArray QGenericUnixServices::desktopEnvironment() const
+ {
+     return QByteArrayLiteral("UNKNOWN");
+@@ -371,6 +507,30 @@ bool QGenericUnixServices::openDocument(const QUrl &url)
+     return false;
+ }
+ 
++QPlatformServiceColorPicker *QGenericUnixServices::colorPicker(QWindow *parent)
++{
++    Q_UNUSED(parent);
++    return nullptr;
++}
++
+ #endif // QT_NO_MULTIPROCESS
+ 
++QString QGenericUnixServices::portalWindowIdentifier(QWindow *window)
++{
++    if (QGuiApplication::platformName() == QLatin1String("xcb"))
++        return QStringLiteral("x11:") + QString::number(window->winId(), 16);
++    return QString();
++}
++
++bool QGenericUnixServices::hasCapability(Capability capability) const
++{
++    switch (capability) {
++    case Capability::ColorPicking:
++        return m_hasScreenshotPortalWithColorPicking;
++    }
++    return false;
++}
++
+ QT_END_NAMESPACE
++
++#include "qgenericunixservices.moc"
+diff --git a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
+index 8ac3de6f03..30924e64bd 100644
+--- a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
++++ b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
+@@ -59,16 +59,21 @@ QT_BEGIN_NAMESPACE
+ class QGenericUnixServices : public QPlatformServices
+ {
+ public:
+-    QGenericUnixServices() {}
++    QGenericUnixServices();
+ 
+     QByteArray desktopEnvironment() const override;
+ 
++    bool hasCapability(Capability capability) const override;
+     bool openUrl(const QUrl &url) override;
+     bool openDocument(const QUrl &url) override;
++    QPlatformServiceColorPicker *colorPicker(QWindow *parent = nullptr) override;
++
++    virtual QString portalWindowIdentifier(QWindow *window);
+ 
+ private:
+     QString m_webBrowser;
+     QString m_documentLauncher;
++    bool m_hasScreenshotPortalWithColorPicking = false;
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
+index 09470bccc6..cc7c7d4d8a 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
+@@ -69,6 +69,7 @@ const QString MenuBarPath = QLatin1String("/MenuBar");
+ */
+ QDBusMenuConnection::QDBusMenuConnection(QObject *parent, const QString &serviceName)
+     : QObject(parent)
++    , m_serviceName(serviceName)
+     , m_connection(serviceName.isNull() ? QDBusConnection::sessionBus()
+                                         : QDBusConnection::connectToBus(QDBusConnection::SessionBus, serviceName))
+     , m_dbusWatcher(new QDBusServiceWatcher(StatusNotifierWatcherService, m_connection, QDBusServiceWatcher::WatchForRegistration, this))
+@@ -83,6 +84,12 @@ QDBusMenuConnection::QDBusMenuConnection(QObject *parent, const QString &service
+ #endif
+ }
+ 
++QDBusMenuConnection::~QDBusMenuConnection()
++{
++  if (!m_serviceName.isEmpty() && m_connection.isConnected())
++      QDBusConnection::disconnectFromBus(m_serviceName);
++}
++
+ void QDBusMenuConnection::dbusError(const QDBusError &error)
+ {
+     qWarning() << "QDBusTrayIcon encountered a D-Bus error:" << error;
+@@ -105,13 +112,7 @@ void QDBusMenuConnection::unregisterTrayIconMenu(QDBusTrayIcon *item)
+ 
+ bool QDBusMenuConnection::registerTrayIcon(QDBusTrayIcon *item)
+ {
+-    bool success = connection().registerService(item->instanceId());
+-    if (!success) {
+-        qWarning() << "failed to register service" << item->instanceId();
+-        return false;
+-    }
+-
+-    success = connection().registerObject(StatusNotifierItemPath, item);
++    bool success = connection().registerObject(StatusNotifierItemPath, item);
+     if (!success) {
+         unregisterTrayIcon(item);
+         qWarning() << "failed to register" << item->instanceId() << StatusNotifierItemPath;
+@@ -126,21 +127,18 @@ bool QDBusMenuConnection::registerTrayIcon(QDBusTrayIcon *item)
+ 
+ bool QDBusMenuConnection::registerTrayIconWithWatcher(QDBusTrayIcon *item)
+ {
++    Q_UNUSED(item);
+     QDBusMessage registerMethod = QDBusMessage::createMethodCall(
+                 StatusNotifierWatcherService, StatusNotifierWatcherPath, StatusNotifierWatcherService,
+                 QLatin1String("RegisterStatusNotifierItem"));
+-    registerMethod.setArguments(QVariantList() << item->instanceId());
++    registerMethod.setArguments(QVariantList() << m_connection.baseService());
+     return m_connection.callWithCallback(registerMethod, this, SIGNAL(trayIconRegistered()), SLOT(dbusError(QDBusError)));
+ }
+ 
+-bool QDBusMenuConnection::unregisterTrayIcon(QDBusTrayIcon *item)
++void QDBusMenuConnection::unregisterTrayIcon(QDBusTrayIcon *item)
+ {
+     unregisterTrayIconMenu(item);
+     connection().unregisterObject(StatusNotifierItemPath);
+-    bool success = connection().unregisterService(item->instanceId());
+-    if (!success)
+-        qWarning() << "failed to unregister service" << item->instanceId();
+-    return success;
+ }
+ #endif // QT_NO_SYSTEMTRAYICON
+ 
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
+index f484795fbb..97bdfabb85 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
++++ b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
+@@ -70,6 +70,7 @@ class QDBusMenuConnection : public QObject
+ 
+ public:
+     QDBusMenuConnection(QObject *parent = nullptr, const QString &serviceName = QString());
++    ~QDBusMenuConnection();
+     QDBusConnection connection() const { return m_connection; }
+     QDBusServiceWatcher *dbusWatcher() const { return m_dbusWatcher; }
+     bool isStatusNotifierHostRegistered() const { return m_statusNotifierHostRegistered; }
+@@ -78,7 +79,7 @@ public:
+     void unregisterTrayIconMenu(QDBusTrayIcon *item);
+     bool registerTrayIcon(QDBusTrayIcon *item);
+     bool registerTrayIconWithWatcher(QDBusTrayIcon *item);
+-    bool unregisterTrayIcon(QDBusTrayIcon *item);
++    void unregisterTrayIcon(QDBusTrayIcon *item);
+ #endif // QT_NO_SYSTEMTRAYICON
+ 
+ Q_SIGNALS:
+@@ -90,6 +91,7 @@ private Q_SLOTS:
+     void dbusError(const QDBusError &error);
+ 
+ private:
++    QString m_serviceName;
+     QDBusConnection m_connection;
+     QDBusServiceWatcher *m_dbusWatcher;
+     bool m_statusNotifierHostRegistered;
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp b/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
+index bede70975a..76bfec5e5a 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
+@@ -71,8 +71,12 @@ Q_LOGGING_CATEGORY(qLcTray, "qt.qpa.tray")
+ static QString iconTempPath()
+ {
+     QString tempPath = QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation);
+-    if (!tempPath.isEmpty())
++    if (!tempPath.isEmpty()) {
++        QString flatpakId = qEnvironmentVariable("FLATPAK_ID");
++        if (!flatpakId.isEmpty() && QFileInfo::exists(QLatin1String("/.flatpak-info")))
++            tempPath += QLatin1String("/app/") + flatpakId;
+         return tempPath;
++    }
+ 
+     tempPath = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation);
+ 
+diff --git a/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+index cb1b39db64..6e01af052c 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+@@ -755,6 +755,9 @@ QVariant QGnomeTheme::themeHint(QPlatformTheme::ThemeHint hint) const
+         return QVariant(QChar(0x2022));
+     case QPlatformTheme::UiEffects:
+         return QVariant(int(HoverEffect));
++    case QPlatformTheme::ButtonPressKeys:
++        return QVariant::fromValue(
++                QList<Qt::Key>({ Qt::Key_Space, Qt::Key_Return, Qt::Key_Enter, Qt::Key_Select }));
+     default:
+         break;
+     }
+diff --git a/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp b/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
+index 98e05195ee..1e92f43dec 100644
+--- a/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
++++ b/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
+@@ -343,8 +343,7 @@ void QEglFSCursor::paintOnScreen()
+     // screens are siblings of each other. When not enabled, the sibling list
+     // only contains m_screen itself.
+     for (QPlatformScreen *screen : m_screen->virtualSiblings()) {
+-        if (screen->geometry().contains(cr.topLeft().toPoint() + m_cursor.hotSpot)
+-            && QOpenGLContext::currentContext()->screen() == screen->screen())
++        if (screen->geometry().contains(cr.topLeft().toPoint() + m_cursor.hotSpot))
+         {
+             cr.translate(-screen->geometry().topLeft());
+             const QSize screenSize = screen->geometry().size();
+@@ -468,11 +467,12 @@ void QEglFSCursor::draw(const QRectF &r)
+ {
+     StateSaver stateSaver;
+ 
+-    QEglFSCursorData &gfx = static_cast<QEglFSContext*>(QOpenGLContext::currentContext()->handle())->cursorData;
+-    if (!gfx.program) {
+-        // one time initialization
++    // one time initialization
++    if (!QOpenGLFunctions::d_ptr)
+         initializeOpenGLFunctions();
+ 
++    QEglFSCursorData &gfx = static_cast<QEglFSContext*>(QOpenGLContext::currentContext()->handle())->cursorData;
++    if (!gfx.program) {
+         createShaderPrograms();
+ 
+         if (!gfx.atlasTexture) {
+diff --git a/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp b/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
+index 645a0ae2e9..3e0e406f1a 100644
+--- a/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
++++ b/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
+@@ -179,7 +179,7 @@ void QEglFSKmsEventReader::create(QEglFSKmsDevice *device)
+ 
+     m_device = device;
+ 
+-    qCDebug(qLcEglfsKmsDebug, "Initalizing event reader for device %p fd %d",
++    qCDebug(qLcEglfsKmsDebug, "Initializing event reader for device %p fd %d",
+             m_device, m_device->fd());
+ 
+     m_thread = new QEglFSKmsEventReaderThread(m_device->fd());
+diff --git a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
+index 141fb68a23..d4294d425a 100644
+--- a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
++++ b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
+@@ -122,11 +122,13 @@ QOffscreenIntegration::QOffscreenIntegration()
+ #endif
+     m_services.reset(new QPlatformServices);
+ 
+-    QWindowSystemInterface::handleScreenAdded(new QOffscreenScreen);
++    m_screen = new QOffscreenScreen;
++    QWindowSystemInterface::handleScreenAdded(m_screen);
+ }
+ 
+ QOffscreenIntegration::~QOffscreenIntegration()
+ {
++    QWindowSystemInterface::handleScreenRemoved(m_screen);
+ }
+ 
+ void QOffscreenIntegration::initialize()
+diff --git a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
+index 0ea90f6c2f..fe00fde07c 100644
+--- a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
++++ b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
+@@ -84,6 +84,7 @@ protected:
+ #endif
+     QScopedPointer<QPlatformInputContext> m_inputContext;
+     QScopedPointer<QPlatformServices> m_services;
++    QPlatformScreen *m_screen;
+     mutable QScopedPointer<QPlatformNativeInterface> m_nativeInterface;
+ };
+ 
+diff --git a/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp b/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
+index 6fa5a8a2b3..1f49f0aefd 100644
+--- a/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
++++ b/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
+@@ -48,6 +48,7 @@
+ #include <qpa/qplatformnativeinterface.h>
+ #include <QtPlatformHeaders/qwglnativecontext.h>
+ 
++#include <private/qsystemlibrary_p.h>
+ #include <algorithm>
+ 
+ #include <wingdi.h>
+@@ -162,19 +163,25 @@ QFunctionPointer QWindowsOpengl32DLL::resolve(const char *name)
+ 
+ bool QWindowsOpengl32DLL::init(bool softwareRendering)
+ {
+-    const QByteArray opengl32 = QByteArrayLiteral("opengl32.dll");
+-    const QByteArray swopengl = QByteArrayLiteral("opengl32sw.dll");
++    const QByteArray opengl32 = QByteArrayLiteral("opengl32");
++    const QByteArray swopengl = QByteArrayLiteral("opengl32sw");
++    bool useSystemLib = false;
+ 
+     QByteArray openglDll = qgetenv("QT_OPENGL_DLL");
+-    if (openglDll.isEmpty())
++    if (openglDll.isEmpty()) {
+         openglDll = softwareRendering ? swopengl : opengl32;
++        useSystemLib = !softwareRendering;
++    }
+ 
+     openglDll = openglDll.toLower();
+     m_nonOpengl32 = openglDll != opengl32;
+ 
+     qCDebug(lcQpaGl) << "Qt: Using WGL and OpenGL from" << openglDll;
+ 
+-    m_lib = ::LoadLibraryA(openglDll.constData());
++    if (useSystemLib)
++        m_lib = QSystemLibrary::load((wchar_t*)(QString::fromLatin1(openglDll).utf16()));
++    else
++        m_lib = LoadLibraryA(openglDll.constData());
+     if (!m_lib) {
+         qErrnoWarning(::GetLastError(), "Failed to load %s", openglDll.constData());
+         return false;
+@@ -184,7 +191,7 @@ bool QWindowsOpengl32DLL::init(bool softwareRendering)
+         // Load opengl32.dll always. GDI functions like ChoosePixelFormat do
+         // GetModuleHandle for opengl32.dll and behave differently (and call back into
+         // opengl32) when the module is present. This is fine for dummy contexts and windows.
+-        ::LoadLibraryA("opengl32.dll");
++        QSystemLibrary::load(L"opengl32");
+     }
+ 
+     wglCreateContext = reinterpret_cast<HGLRC (WINAPI *)(HDC)>(resolve("wglCreateContext"));
+diff --git a/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp b/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
+index d7d186e804..9eb4011bf2 100644
+--- a/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
++++ b/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
+@@ -49,6 +49,7 @@
+ #include <QtCore/qstandardpaths.h>
+ #include <QtCore/qlibraryinfo.h>
+ #include <QtCore/qhash.h>
++#include <private/qsystemlibrary_p.h>
+ 
+ #ifndef QT_NO_OPENGL
+ #include <private/qopengl_p.h>
+@@ -396,7 +397,7 @@ bool QWindowsOpenGLTester::testDesktopGL()
+ 
+     // Test #1: Load opengl32.dll and try to resolve an OpenGL 2 function.
+     // This will typically fail on systems that do not have a real OpenGL driver.
+-    lib = LoadLibraryA("opengl32.dll");
++    lib = QSystemLibrary::load(L"opengl32");
+     if (lib) {
+         CreateContext = reinterpret_cast<CreateContextType>(
+             reinterpret_cast<QFunctionPointer>(::GetProcAddress(lib, "wglCreateContext")));
+diff --git a/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp b/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
+index 1afa00cfc9..118af6ce73 100644
+--- a/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
++++ b/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
+@@ -41,6 +41,7 @@
+ 
+ #include <QRect>
+ #include <QList>
++#include <QMap>
+ #include <QDebug>
+ 
+ #include <qmath.h>
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp b/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
+index 9e2a37a6a1..e6e175a118 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
+@@ -488,12 +488,12 @@ void QXcbConnection::printXcbError(const char *message, xcb_generic_error_t *err
+     uint clamped_error_code = qMin<uint>(error->error_code, (sizeof(xcb_errors) / sizeof(xcb_errors[0])) - 1);
+     uint clamped_major_code = qMin<uint>(error->major_code, (sizeof(xcb_protocol_request_codes) / sizeof(xcb_protocol_request_codes[0])) - 1);
+ 
+-    qCWarning(lcQpaXcb, "%s: %d (%s), sequence: %d, resource id: %d, major code: %d (%s), minor code: %d",
+-             message,
+-             int(error->error_code), xcb_errors[clamped_error_code],
+-             int(error->sequence), int(error->resource_id),
+-             int(error->major_code), xcb_protocol_request_codes[clamped_major_code],
+-             int(error->minor_code));
++    qCDebug(lcQpaXcb, "%s: %d (%s), sequence: %d, resource id: %d, major code: %d (%s), minor code: %d",
++            message,
++            int(error->error_code), xcb_errors[clamped_error_code],
++            int(error->sequence), int(error->resource_id),
++            int(error->major_code), xcb_protocol_request_codes[clamped_major_code],
++            int(error->minor_code));
+ }
+ 
+ static Qt::MouseButtons translateMouseButtons(int s)
+@@ -702,6 +702,8 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
+             QXcbVirtualDesktop *virtualDesktop = virtualDesktopForRootWindow(propertyNotify->window);
+             if (virtualDesktop)
+                 virtualDesktop->updateWorkArea();
++        } else if (propertyNotify->atom == atom(QXcbAtom::_NET_SUPPORTED)) {
++            m_wmSupport->updateNetWMAtoms();
+         } else {
+             HANDLE_PLATFORM_WINDOW_EVENT(xcb_property_notify_event_t, window, handlePropertyNotifyEvent);
+         }
+@@ -750,7 +752,7 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
+                 case XCB_XKB_NEW_KEYBOARD_NOTIFY: {
+                     xcb_xkb_new_keyboard_notify_event_t *ev = &xkb_event->new_keyboard_notify;
+                     if (ev->changed & XCB_XKB_NKN_DETAIL_KEYCODES)
+-                        m_keyboard->updateKeymap(ev);
++                        m_keyboard->updateKeymap();
+                     break;
+                 }
+                 default:
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp b/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
+index 76869ced60..02d2eebb56 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
+@@ -274,8 +274,7 @@ QPlatformWindow *QXcbIntegration::createForeignWindow(QWindow *window, WId nativ
+ #ifndef QT_NO_OPENGL
+ QPlatformOpenGLContext *QXcbIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
+ {
+-    QXcbScreen *screen = static_cast<QXcbScreen *>(context->screen()->handle());
+-    QXcbGlIntegration *glIntegration = screen->connection()->glIntegration();
++    QXcbGlIntegration *glIntegration = defaultConnection()->glIntegration();
+     if (!glIntegration) {
+         qWarning("QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled");
+         return nullptr;
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+index efecd7e2d1..e8286381a2 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+@@ -365,17 +365,6 @@ void QXcbKeyboard::updateKeymap(xcb_mapping_notify_event_t *event)
+     updateKeymap();
+ }
+ 
+-void QXcbKeyboard::updateKeymap(xcb_xkb_new_keyboard_notify_event_t *event)
+-{
+-    if (!event)
+-        return;
+-
+-    if (event->deviceID != event->oldDeviceID)
+-        m_config = false;
+-
+-    updateKeymap();
+-}
+-
+ void QXcbKeyboard::updateKeymap()
+ {
+     KeysymModifierMap keysymMods;
+@@ -383,6 +372,8 @@ void QXcbKeyboard::updateKeymap()
+         keysymMods = keysymsToModifiers();
+     updateModifiers(keysymMods);
+ 
++    m_config = true;
++
+     if (!m_xkbContext) {
+         m_xkbContext.reset(xkb_context_new(XKB_CONTEXT_NO_DEFAULT_INCLUDES));
+         if (!m_xkbContext) {
+@@ -398,13 +389,8 @@ void QXcbKeyboard::updateKeymap()
+     if (connection()->hasXKB()) {
+         m_xkbKeymap.reset(xkb_x11_keymap_new_from_device(m_xkbContext.get(), xcb_connection(),
+                                                          core_device_id, XKB_KEYMAP_COMPILE_NO_FLAGS));
+-        if (m_xkbKeymap) {
+-            if (m_config)
+-                m_xkbState.reset(xkb_state_new(m_xkbKeymap.get()));
+-            else
+-                m_xkbState.reset(xkb_x11_state_new_from_device(m_xkbKeymap.get(), xcb_connection(), core_device_id));
+-
+-        }
++        if (m_xkbKeymap)
++            m_xkbState.reset(xkb_x11_state_new_from_device(m_xkbKeymap.get(), xcb_connection(), core_device_id));
+     } else {
+         m_xkbKeymap.reset(keymapFromCore(keysymMods));
+         if (m_xkbKeymap)
+@@ -425,8 +411,6 @@ void QXcbKeyboard::updateKeymap()
+     updateXKBMods();
+ 
+     QXkbCommon::verifyHasLatinLayout(m_xkbKeymap.get());
+-
+-    m_config = true;
+ }
+ 
+ QList<int> QXcbKeyboard::possibleKeys(const QKeyEvent *event) const
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
+index b652c85fe3..0ee08aeff2 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
++++ b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
+@@ -69,7 +69,6 @@ public:
+ 
+     Qt::KeyboardModifiers translateModifiers(int s) const;
+     void updateKeymap(xcb_mapping_notify_event_t *event);
+-    void updateKeymap(xcb_xkb_new_keyboard_notify_event_t *event);
+     void updateKeymap();
+     QList<int> possibleKeys(const QKeyEvent *event) const;
+ 
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp b/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
+index ffda7b6a57..863e961f4c 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
+@@ -564,11 +564,6 @@ void QXcbWindow::setGeometry(const QRect &rect)
+ {
+     QPlatformWindow::setGeometry(rect);
+ 
+-    if (shouldDeferTask(Task::SetGeometry)) {
+-        m_deferredGeometry = rect;
+-        return;
+-    }
+-
+     propagateSizeHints();
+ 
+     QXcbScreen *currentScreen = xcbScreen();
+@@ -693,9 +688,6 @@ void QXcbWindow::setVisible(bool visible)
+ 
+ void QXcbWindow::show()
+ {
+-    if (shouldDeferTask(Task::Map))
+-        return;
+-
+     if (window()->isTopLevel()) {
+ 
+         // update WM_NORMAL_HINTS
+@@ -706,7 +698,7 @@ void QXcbWindow::show()
+         if (isTransient(window())) {
+             const QWindow *tp = window()->transientParent();
+             if (tp && tp->handle())
+-                transientXcbParent = static_cast<const QXcbWindow *>(tp->handle())->winId();
++                transientXcbParent = tp->handle()->winId();
+             // Default to client leader if there is no transient parent, else modal dialogs can
+             // be hidden by their parents.
+             if (!transientXcbParent)
+@@ -746,10 +738,6 @@ void QXcbWindow::show()
+ 
+ void QXcbWindow::hide()
+ {
+-    if (shouldDeferTask(Task::Unmap))
+-        return;
+-
+-    m_wmStateValid = false;
+     xcb_unmap_window(xcb_connection(), m_window);
+ 
+     // send synthetic UnmapNotify event according to icccm 4.1.4
+@@ -909,9 +897,6 @@ QXcbWindow::NetWmStates QXcbWindow::netWmStates()
+ 
+ void QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
+ {
+-    if (shouldDeferTask(Task::SetWindowFlags))
+-        return;
+-
+     Qt::WindowType type = static_cast<Qt::WindowType>(int(flags & Qt::WindowType_Mask));
+ 
+     if (type == Qt::ToolTip)
+@@ -941,8 +926,6 @@ void QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
+ 
+     setTransparentForMouseEvents(flags & Qt::WindowTransparentForInput);
+     updateDoesNotAcceptFocus(flags & Qt::WindowDoesNotAcceptFocus);
+-
+-    m_isWmManagedWindow = !(flags & Qt::X11BypassWindowManagerHint);
+ }
+ 
+ void QXcbWindow::setMotifWmHints(Qt::WindowFlags flags)
+@@ -1142,9 +1125,6 @@ void QXcbWindow::setWindowState(Qt::WindowStates state)
+     if (state == m_windowState)
+         return;
+ 
+-    if (shouldDeferTask(Task::SetWindowState))
+-        return;
+-
+     // unset old state
+     if (m_windowState & Qt::WindowMinimized)
+         xcb_map_window(xcb_connection(), m_window);
+@@ -1350,6 +1330,12 @@ void QXcbWindow::setWindowIcon(const QIcon &icon)
+     }
+ 
+     if (!icon_data.isEmpty()) {
++        // Ignore icon exceeding maximum xcb request length
++        if (icon_data.size() > xcb_get_maximum_request_length(xcb_connection())) {
++            qWarning("Ignoring window icon: Size %llu exceeds maximum xcb request length %u.",
++                     icon_data.size(), xcb_get_maximum_request_length(xcb_connection()));
++            return;
++        }
+         xcb_change_property(xcb_connection(),
+                             XCB_PROP_MODE_REPLACE,
+                             m_window,
+@@ -1639,7 +1625,7 @@ void QXcbWindow::setWmWindowType(QXcbWindowFunctions::WmWindowTypes types, Qt::W
+         break;
+     }
+ 
+-    if ((flags & Qt::FramelessWindowHint) && !(type & QXcbWindowFunctions::KdeOverride)) {
++    if ((flags & Qt::FramelessWindowHint) && !(types & QXcbWindowFunctions::KdeOverride)) {
+         // override netwm type - quick and easy for KDE noborder
+         atoms.append(atom(QXcbAtom::_KDE_NET_WM_WINDOW_TYPE_OVERRIDE));
+     }
+@@ -1894,10 +1880,6 @@ void QXcbWindow::handleUnmapNotifyEvent(const xcb_unmap_notify_event_t *event)
+     if (event->window == m_window) {
+         m_mapped = false;
+         QWindowSystemInterface::handleExposeEvent(window(), QRegion());
+-        if (!m_isWmManagedWindow || parent()) {
+-            m_wmStateValid = true;
+-            handleDeferredTasks();
+-        }
+     }
+ }
+ 
+@@ -2212,98 +2194,30 @@ void QXcbWindow::handleLeaveNotifyEvent(const xcb_leave_notify_event_t *event)
+     handleLeaveNotifyEvent(event->root_x, event->root_y, event->mode, event->detail, event->time);
+ }
+ 
+-bool QXcbWindow::shouldDeferTask(Task task)
+-{
+-    if (m_wmStateValid)
+-        return false;
+-
+-    m_deferredTasks.append(task);
+-    return true;
+-}
+-
+-void QXcbWindow::handleDeferredTasks()
+-{
+-    Q_ASSERT(m_wmStateValid == true);
+-    if (m_deferredTasks.isEmpty())
+-        return;
+-
+-    bool map = false;
+-    bool unmap = false;
+-
+-    QVector<Task> tasks;
+-    for (auto taskIt = m_deferredTasks.rbegin(); taskIt != m_deferredTasks.rend(); ++taskIt) {
+-        if (!tasks.contains(*taskIt))
+-            tasks.prepend(*taskIt);
+-    }
+-
+-    for (Task task : tasks) {
+-        switch (task) {
+-        case Task::Map:
+-            map = true;
+-            unmap = false;
+-            break;
+-        case Task::Unmap:
+-            unmap = true;
+-            map = false;
+-            break;
+-        case Task::SetGeometry:
+-            setGeometry(m_deferredGeometry);
+-            break;
+-        case Task::SetWindowFlags:
+-            setWindowFlags(window()->flags());
+-            break;
+-        case Task::SetWindowState:
+-            setWindowState(window()->windowState());
+-            break;
+-        }
+-    }
+-    m_deferredTasks.clear();
+-
+-    if (map) {
+-        Q_ASSERT(unmap == false);
+-        show();
+-    }
+-    if (unmap) {
+-        Q_ASSERT(map == false);
+-        hide();
+-    }
+-}
+-
+ void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *event)
+ {
+     connection()->setTime(event->time);
+ 
+-    const bool wmStateChanged = event->atom == atom(QXcbAtom::WM_STATE);
+-    const bool netWmStateChanged = event->atom == atom(QXcbAtom::_NET_WM_STATE);
+-    if (netWmStateChanged || wmStateChanged) {
+-        if (wmStateChanged && !m_wmStateValid && m_isWmManagedWindow) {
+-            // ICCCM 4.1.4
+-            // Clients that want to re-use a client window (e.g. by mapping it again)
+-            // after withdrawing it must wait for the withdrawal to be complete before
+-            // proceeding. The preferred method for doing this is for clients to wait for
+-            // a window manager to update or remove the WM_STATE property.
+-            m_wmStateValid = true;
+-            handleDeferredTasks();
+-        }
+-        if (event->state == XCB_PROPERTY_DELETE)
++    const bool propertyDeleted = event->state == XCB_PROPERTY_DELETE;
++
++    if (event->atom == atom(QXcbAtom::_NET_WM_STATE) || event->atom == atom(QXcbAtom::WM_STATE)) {
++        if (propertyDeleted)
+             return;
+ 
+-        if (wmStateChanged) {
++        Qt::WindowStates newState = Qt::WindowNoState;
++
++        if (event->atom == atom(QXcbAtom::WM_STATE)) { // WM_STATE: Quick check for 'Minimize'.
+             auto reply = Q_XCB_REPLY(xcb_get_property, xcb_connection(),
+                                      0, m_window, atom(QXcbAtom::WM_STATE),
+                                      XCB_ATOM_ANY, 0, 1024);
+             if (reply && reply->format == 32 && reply->type == atom(QXcbAtom::WM_STATE)) {
+-                auto data = static_cast<const quint32 *>(xcb_get_property_value(reply.get()));
+-                if (reply->length != 0) {
+-                    const bool changedToWithdrawn = data[0] == XCB_ICCCM_WM_STATE_WITHDRAWN;
+-                    const bool changedToIconic = data[0] == XCB_ICCCM_WM_STATE_ICONIC;
+-                    m_minimized = changedToIconic || (changedToWithdrawn && m_minimized);
+-                }
++                const quint32 *data = (const quint32 *)xcb_get_property_value(reply.get());
++                if (reply->length != 0)
++                    m_minimized = (data[0] == XCB_ICCCM_WM_STATE_ICONIC
++                                   || (data[0] == XCB_ICCCM_WM_STATE_WITHDRAWN && m_minimized));
+             }
+         }
+ 
+-        // _NET_WM_STATE handling
+-        Qt::WindowStates newState = Qt::WindowNoState;
+         const NetWmStates states = netWmStates();
+         // _NET_WM_STATE_HIDDEN should be set by the Window Manager to indicate that a window would
+         // not be visible on the screen if its desktop/viewport were active and its coordinates were
+@@ -2325,6 +2239,7 @@ void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *ev
+             if ((m_windowState & Qt::WindowMinimized) && connection()->mouseGrabber() == this)
+                 connection()->setMouseGrabber(nullptr);
+         }
++        return;
+     } else if (event->atom == atom(QXcbAtom::_NET_FRAME_EXTENTS)) {
+         m_dirtyFrameMargins = true;
+     }
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbwindow.h b/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
+index 55af9279b1..6f5c1f5ed9 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
++++ b/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
+@@ -74,14 +74,6 @@ public:
+ 
+     Q_DECLARE_FLAGS(NetWmStates, NetWmState)
+ 
+-    enum Task {
+-        Map,
+-        Unmap,
+-        SetGeometry,
+-        SetWindowFlags,
+-        SetWindowState
+-    };
+-
+     QXcbWindow(QWindow *window);
+     ~QXcbWindow();
+ 
+@@ -151,9 +143,6 @@ public:
+ 
+     QXcbWindow *toWindow() override;
+ 
+-    bool shouldDeferTask(Task task);
+-    void handleDeferredTasks();
+-
+     void handleMouseEvent(xcb_timestamp_t time, const QPoint &local, const QPoint &global,
+                           Qt::KeyboardModifiers modifiers, QEvent::Type type, Qt::MouseEventSource source);
+ 
+@@ -292,11 +281,6 @@ protected:
+     int m_swapInterval = -1;
+ 
+     qreal m_sizeHintsScaleFactor = 1.0;
+-
+-    bool m_wmStateValid = true;
+-    QVector<Task> m_deferredTasks;
+-    bool m_isWmManagedWindow = true;
+-    QRect m_deferredGeometry;
+ };
+ 
+ class QXcbForeignWindow : public QXcbWindow
+diff --git a/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp b/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
+index d9d117faeb..640b49daa0 100644
+--- a/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
++++ b/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
+@@ -85,6 +85,7 @@ QGtk3MenuItem::QGtk3MenuItem()
+       m_checkable(false),
+       m_checked(false),
+       m_enabled(true),
++      m_exclusive(false),
+       m_underline(false),
+       m_invalid(true),
+       m_menu(nullptr),
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
+index 0048bbc1e6..396e7f6d1c 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
+@@ -102,15 +102,12 @@ const QDBusArgument &operator >>(const QDBusArgument &arg, QXdgDesktopPortalFile
+ class QXdgDesktopPortalFileDialogPrivate
+ {
+ public:
+-    QXdgDesktopPortalFileDialogPrivate(QPlatformFileDialogHelper *nativeFileDialog)
++    QXdgDesktopPortalFileDialogPrivate(QPlatformFileDialogHelper *nativeFileDialog, uint fileChooserPortalVersion)
+         : nativeFileDialog(nativeFileDialog)
++        , fileChooserPortalVersion(fileChooserPortalVersion)
+     { }
+ 
+-    WId winId = 0;
+-    bool directoryMode = false;
+-    bool modal = false;
+-    bool multipleFiles = false;
+-    bool saveFile = false;
++    QEventLoop loop;
+     QString acceptLabel;
+     QString directory;
+     QString title;
+@@ -121,19 +118,27 @@ public:
+     QString selectedMimeTypeFilter;
+     QString selectedNameFilter;
+     QStringList selectedFiles;
+-    QPlatformFileDialogHelper *nativeFileDialog = nullptr;
++    std::unique_ptr<QPlatformFileDialogHelper> nativeFileDialog;
++    uint fileChooserPortalVersion = 0;
++    bool failedToOpen = false;
++    bool directoryMode = false;
++    bool multipleFiles = false;
++    bool saveFile = false;
+ };
+ 
+-QXdgDesktopPortalFileDialog::QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog)
++QXdgDesktopPortalFileDialog::QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog, uint fileChooserPortalVersion)
+     : QPlatformFileDialogHelper()
+-    , d_ptr(new QXdgDesktopPortalFileDialogPrivate(nativeFileDialog))
++    , d_ptr(new QXdgDesktopPortalFileDialogPrivate(nativeFileDialog, fileChooserPortalVersion))
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+     if (d->nativeFileDialog) {
+-        connect(d->nativeFileDialog, SIGNAL(accept()), this, SIGNAL(accept()));
+-        connect(d->nativeFileDialog, SIGNAL(reject()), this, SIGNAL(reject()));
++        connect(d->nativeFileDialog.get(), SIGNAL(accept()), this, SIGNAL(accept()));
++        connect(d->nativeFileDialog.get(), SIGNAL(reject()), this, SIGNAL(reject()));
+     }
++
++    d->loop.connect(this, SIGNAL(accept()), SLOT(quit()));
++    d->loop.connect(this, SIGNAL(reject()), SLOT(quit()));
+ }
+ 
+ QXdgDesktopPortalFileDialog::~QXdgDesktopPortalFileDialog()
+@@ -177,7 +182,7 @@ void QXdgDesktopPortalFileDialog::initializeDialog()
+     setDirectory(options()->initialDirectory());
+ }
+ 
+-void QXdgDesktopPortalFileDialog::openPortal()
++void QXdgDesktopPortalFileDialog::openPortal(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent)
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+@@ -185,13 +190,13 @@ void QXdgDesktopPortalFileDialog::openPortal()
+                                                           QLatin1String("/org/freedesktop/portal/desktop"),
+                                                           QLatin1String("org.freedesktop.portal.FileChooser"),
+                                                           d->saveFile ? QLatin1String("SaveFile") : QLatin1String("OpenFile"));
+-    QString parentWindowId = QLatin1String("x11:") + QString::number(d->winId, 16);
++    QString parentWindowId = QLatin1String("x11:") + QString::number(parent ? parent->winId() : 0, 16);
+ 
+     QVariantMap options;
+     if (!d->acceptLabel.isEmpty())
+         options.insert(QLatin1String("accept_label"), d->acceptLabel);
+ 
+-    options.insert(QLatin1String("modal"), d->modal);
++    options.insert(QLatin1String("modal"), windowModality != Qt::NonModal);
+     options.insert(QLatin1String("multiple"), d->multipleFiles);
+     options.insert(QLatin1String("directory"), d->directoryMode);
+ 
+@@ -290,10 +295,18 @@ void QXdgDesktopPortalFileDialog::openPortal()
+ 
+     QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
+     QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingCall);
+-    connect(watcher, &QDBusPendingCallWatcher::finished, this, [this] (QDBusPendingCallWatcher *watcher) {
++    connect(watcher, &QDBusPendingCallWatcher::finished, this, [=] (QDBusPendingCallWatcher *watcher) {
+         QDBusPendingReply<QDBusObjectPath> reply = *watcher;
+-        if (reply.isError()) {
+-            Q_EMIT reject();
++        // Any error means the dialog is not shown and we need to fallback
++        d->failedToOpen = reply.isError();
++        if (d->failedToOpen) {
++            if (d->nativeFileDialog) {
++                d->nativeFileDialog->show(windowFlags, windowModality, parent);
++                if (d->loop.isRunning())
++                    d->nativeFileDialog->exec();
++            } else {
++                Q_EMIT reject();
++            }
+         } else {
+             QDBusConnection::sessionBus().connect(nullptr,
+                                                   reply.value().path(),
+@@ -302,6 +315,7 @@ void QXdgDesktopPortalFileDialog::openPortal()
+                                                   this,
+                                                   SLOT(gotResponse(uint,QVariantMap)));
+         }
++        watcher->deleteLater();
+     });
+ }
+ 
+@@ -326,7 +340,7 @@ QUrl QXdgDesktopPortalFileDialog::directory() const
+ {
+     Q_D(const QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog())
+         return d->nativeFileDialog->directory();
+ 
+     return d->directory;
+@@ -348,7 +362,7 @@ QList<QUrl> QXdgDesktopPortalFileDialog::selectedFiles() const
+ {
+     Q_D(const QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog())
+         return d->nativeFileDialog->selectedFiles();
+ 
+     QList<QUrl> files;
+@@ -403,16 +417,13 @@ void QXdgDesktopPortalFileDialog::exec()
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly)) {
++    if (d->nativeFileDialog && useNativeFileDialog()) {
+         d->nativeFileDialog->exec();
+         return;
+     }
+ 
+     // HACK we have to avoid returning until we emit that the dialog was accepted or rejected
+-    QEventLoop loop;
+-    loop.connect(this, SIGNAL(accept()), SLOT(quit()));
+-    loop.connect(this, SIGNAL(reject()), SLOT(quit()));
+-    loop.exec();
++    d->loop.exec();
+ }
+ 
+ void QXdgDesktopPortalFileDialog::hide()
+@@ -429,13 +440,10 @@ bool QXdgDesktopPortalFileDialog::show(Qt::WindowFlags windowFlags, Qt::WindowMo
+ 
+     initializeDialog();
+ 
+-    d->modal = windowModality != Qt::NonModal;
+-    d->winId = parent ? parent->winId() : 0;
+-
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog(OpenFallback))
+         return d->nativeFileDialog->show(windowFlags, windowModality, parent);
+ 
+-    openPortal();
++    openPortal(windowFlags, windowModality, parent);
+ 
+     return true;
+ }
+@@ -465,4 +473,21 @@ void QXdgDesktopPortalFileDialog::gotResponse(uint response, const QVariantMap &
+     }
+ }
+ 
++bool QXdgDesktopPortalFileDialog::useNativeFileDialog(QXdgDesktopPortalFileDialog::FallbackType fallbackType) const
++{
++    Q_D(const QXdgDesktopPortalFileDialog);
++
++    if (d->failedToOpen && fallbackType != OpenFallback)
++        return true;
++
++    if (d->fileChooserPortalVersion < 3) {
++        if (options()->fileMode() == QFileDialogOptions::Directory)
++            return true;
++        else if (options()->fileMode() == QFileDialogOptions::DirectoryOnly)
++            return true;
++    }
++
++    return false;
++}
++
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
+index 4f4de96ecf..65e22a5cf2 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
+@@ -51,6 +51,11 @@ class QXdgDesktopPortalFileDialog : public QPlatformFileDialogHelper
+     Q_OBJECT
+     Q_DECLARE_PRIVATE(QXdgDesktopPortalFileDialog)
+ public:
++    enum FallbackType {
++        GenericFallback,
++        OpenFallback
++    };
++
+     enum ConditionType : uint {
+         GlobalPattern = 0,
+         MimeType = 1
+@@ -69,7 +74,7 @@ public:
+     };
+     typedef QVector<Filter> FilterList;
+ 
+-    QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog = nullptr);
++    QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog = nullptr, uint fileChooserPortalVersion = 0);
+     ~QXdgDesktopPortalFileDialog();
+ 
+     bool defaultNameFilterDisables() const override;
+@@ -92,7 +97,8 @@ private Q_SLOTS:
+ 
+ private:
+     void initializeDialog();
+-    void openPortal();
++    void openPortal(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent);
++    bool useNativeFileDialog(FallbackType fallbackType = GenericFallback) const;
+ 
+     QScopedPointer<QXdgDesktopPortalFileDialogPrivate> d_ptr;
+ };
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
+index fb324afbd8..b809503122 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
+@@ -111,6 +111,7 @@ QXdgDesktopPortalTheme::QXdgDesktopPortalTheme()
+         if (reply.isValid()) {
+             d->fileChooserPortalVersion = reply.value().toUInt();
+         }
++        watcher->deleteLater();
+     });
+ }
+ 
+@@ -152,11 +153,12 @@ QPlatformDialogHelper* QXdgDesktopPortalTheme::createPlatformDialogHelper(Dialog
+ {
+     Q_D(const QXdgDesktopPortalTheme);
+ 
+-    if (type == FileDialog) {
++    if (type == FileDialog && d->fileChooserPortalVersion) {
+         // Older versions of FileChooser portal don't support opening directories, therefore we fallback
+         // to native file dialog opened inside the sandbox to open a directory.
+-        if (d->fileChooserPortalVersion < 3 && d->baseTheme->usePlatformNativeDialog(type))
+-            return new QXdgDesktopPortalFileDialog(static_cast<QPlatformFileDialogHelper*>(d->baseTheme->createPlatformDialogHelper(type)));
++        if (d->baseTheme->usePlatformNativeDialog(type))
++            return new QXdgDesktopPortalFileDialog(static_cast<QPlatformFileDialogHelper*>(d->baseTheme->createPlatformDialogHelper(type)),
++                                                   d->fileChooserPortalVersion);
+ 
+         return new QXdgDesktopPortalFileDialog;
+     }
+diff --git a/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp b/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
+index 43d5e119ad..1f9cbc4565 100644
+--- a/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
++++ b/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
+@@ -89,8 +89,10 @@ void QCupsPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &v
+         break;
+     case PPK_Duplex: {
+         QPrint::DuplexMode mode = QPrint::DuplexMode(value.toInt());
+-        if (mode != d->duplex && d->m_printDevice.supportedDuplexModes().contains(mode))
++        if (d->m_printDevice.supportedDuplexModes().contains(mode)) {
+             d->duplex = mode;
++            d->duplexRequestedExplicitly = true;
++        }
+         break;
+     }
+     case PPK_PrinterName:
+@@ -277,9 +279,12 @@ void QCupsPrintEnginePrivate::changePrinter(const QString &newPrinter)
+     m_printDevice.swap(printDevice);
+     printerName = m_printDevice.id();
+ 
+-    // Check if new printer supports current settings, otherwise us defaults
+-    if (duplex != QPrint::DuplexAuto && !m_printDevice.supportedDuplexModes().contains(duplex))
++    // in case a duplex value was explicitly set, check if new printer supports current value,
++    // otherwise use device default
++    if (!duplexRequestedExplicitly || !m_printDevice.supportedDuplexModes().contains(duplex)) {
+         duplex = m_printDevice.defaultDuplexMode();
++        duplexRequestedExplicitly = false;
++    }
+     QPrint::ColorMode colorMode = grayscale ? QPrint::GrayScale : QPrint::Color;
+     if (!m_printDevice.supportedColorModes().contains(colorMode))
+         grayscale = m_printDevice.defaultColorMode() == QPrint::GrayScale;
+diff --git a/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h b/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
+index c021b0c643..8f81fe478d 100644
+--- a/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
++++ b/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
+@@ -100,6 +100,7 @@ private:
+     QStringList cupsOptions;
+     QString cupsTempFile;
+     QPrint::DuplexMode duplex;
++    bool duplexRequestedExplicitly = false;
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp b/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
+index 67e7154fa6..40876152e5 100644
+--- a/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
++++ b/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
+@@ -817,7 +817,7 @@ bool QIBaseResultPrivate::writeArray(int column, const QList<QVariant> &list)
+     ba.resize(int(bufLen));
+ 
+     if (list.size() > arraySize) {
+-        error = QLatin1String("Array size missmatch: size of %1 is %2, size of provided list is %3");
++        error = QLatin1String("Array size mismatch: size of %1 is %2, size of provided list is %3");
+         error = error.arg(QLatin1String(sqlname)).arg(arraySize).arg(list.size());
+         q->setLastError(QSqlError(error, QLatin1String(""), QSqlError::StatementError));
+         return false;
+diff --git a/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp b/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
+index 7ca055eea2..6bc9d46755 100644
+--- a/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
++++ b/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
+@@ -223,7 +223,7 @@ public:
+     struct QMyField
+     {
+         char *outField = nullptr;
+-        MYSQL_FIELD *myField = nullptr;
++        const MYSQL_FIELD *myField = nullptr;
+         QMetaType::Type type = QMetaType::UnknownType;
+         my_bool nullIndicator = false;
+         ulong bufLength = 0ul;
+@@ -361,7 +361,7 @@ static bool qIsInteger(int t)
+ void QMYSQLResultPrivate::bindBlobs()
+ {
+     int i;
+-    MYSQL_FIELD *fieldInfo;
++    const MYSQL_FIELD *fieldInfo;
+     MYSQL_BIND *bind;
+ 
+     for(i = 0; i < fields.count(); ++i) {
+@@ -379,7 +379,6 @@ void QMYSQLResultPrivate::bindBlobs()
+ bool QMYSQLResultPrivate::bindInValues()
+ {
+     MYSQL_BIND *bind;
+-    char *field;
+     int i = 0;
+ 
+     if (!meta)
+@@ -392,35 +391,34 @@ bool QMYSQLResultPrivate::bindInValues()
+     inBinds = new MYSQL_BIND[fields.size()];
+     memset(inBinds, 0, fields.size() * sizeof(MYSQL_BIND));
+ 
+-    MYSQL_FIELD *fieldInfo;
++    const MYSQL_FIELD *fieldInfo;
+ 
+     while((fieldInfo = mysql_fetch_field(meta))) {
++        bind = &inBinds[i];
++
+         QMyField &f = fields[i];
+         f.myField = fieldInfo;
+-
++        bind->buffer_length = f.bufLength = fieldInfo->length + 1;
++        bind->buffer_type = fieldInfo->type;
+         f.type = qDecodeMYSQLType(fieldInfo->type, fieldInfo->flags);
+         if (qIsBlob(fieldInfo->type)) {
+             // the size of a blob-field is available as soon as we call
+             // mysql_stmt_store_result()
+             // after mysql_stmt_exec() in QMYSQLResult::exec()
+-            fieldInfo->length = 0;
++            bind->buffer_length = f.bufLength = 0;
+             hasBlobs = true;
+         } else if (qIsInteger(f.type)) {
+-            fieldInfo->length = 8;
++            bind->buffer_length = f.bufLength = 8;
+         } else {
+-            fieldInfo->type = MYSQL_TYPE_STRING;
++            bind->buffer_type = MYSQL_TYPE_STRING;
+         }
+-        bind = &inBinds[i];
+-        field = new char[fieldInfo->length + 1];
+-        memset(field, 0, fieldInfo->length + 1);
+ 
+-        bind->buffer_type = fieldInfo->type;
+-        bind->buffer = field;
+-        bind->buffer_length = f.bufLength = fieldInfo->length + 1;
+         bind->is_null = &f.nullIndicator;
+         bind->length = &f.bufLength;
+         bind->is_unsigned = fieldInfo->flags & UNSIGNED_FLAG ? 1 : 0;
+-        f.outField=field;
++
++        char *field = new char[bind->buffer_length + 1]{};
++        bind->buffer = f.outField = field;
+ 
+         ++i;
+     }
+@@ -1369,20 +1367,20 @@ bool QMYSQLDriver::open(const QString& db,
+     }
+ 
+ #if MYSQL_VERSION_ID >= 50007
+-    if (mysql_get_client_version() >= 50503 && mysql_get_server_version(d->mysql) >= 50503) {
+-        // force the communication to be utf8mb4 (only utf8mb4 supports 4-byte characters)
+-        mysql_set_character_set(d->mysql, "utf8mb4");
++    // force the communication to be utf8mb4 (only utf8mb4 supports 4-byte characters)
++    if (mysql_set_character_set(d->mysql, "utf8mb4")) {
++        // this failed, try forcing it to utf (BMP only)
++        if (mysql_set_character_set(d->mysql, "utf8"))
++            qWarning() << "MySQL: Unable to set the client character set to utf8.";
+ #if QT_CONFIG(textcodec)
+-        d->tc = QTextCodec::codecForName("UTF-8");
++        else
++            d->tc = codec(d->mysql);
+ #endif
+-    } else
+-    {
+-        // force the communication to be utf8
+-        mysql_set_character_set(d->mysql, "utf8");
++    }
+ #if QT_CONFIG(textcodec)
+-        d->tc = codec(d->mysql);
++    else
++        d->tc = QTextCodec::codecForName("UTF-8");
+ #endif
+-    }
+ #endif  // MYSQL_VERSION_ID >= 50007
+ 
+     d->preparedQuerysEnabled = checkPreparedQueries(d->mysql);
+diff --git a/qtbase/src/printsupport/dialogs/images/print-24.png b/qtbase/src/printsupport/dialogs/images/printer-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/print-24.png
+rename to src/printsupport/dialogs/images/printer-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/print-32.png b/qtbase/src/printsupport/dialogs/images/printer-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/print-32.png
+rename to src/printsupport/dialogs/images/printer-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-sided-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-facing-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-sided-24.png
+rename to src/printsupport/dialogs/images/view-pages-facing-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-sided-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-facing-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-sided-32.png
+rename to src/printsupport/dialogs/images/view-pages-facing-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-multi-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-overview-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-multi-24.png
+rename to src/printsupport/dialogs/images/view-pages-overview-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-multi-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-overview-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-multi-32.png
+rename to src/printsupport/dialogs/images/view-pages-overview-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-one-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-single-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-one-24.png
+rename to src/printsupport/dialogs/images/view-pages-single-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-one-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-single-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-one-32.png
+rename to src/printsupport/dialogs/images/view-pages-single-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-page-24.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-page-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-page-24.png
+rename to src/printsupport/dialogs/images/zoom-fit-page-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-page-32.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-page-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-page-32.png
+rename to src/printsupport/dialogs/images/zoom-fit-page-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-width-24.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-width-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-width-24.png
+rename to src/printsupport/dialogs/images/zoom-fit-width-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-width-32.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-width-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-width-32.png
+rename to src/printsupport/dialogs/images/zoom-fit-width-32.png
+diff --git a/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp b/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
+index 78e5b8d1ef..2a28516719 100644
+--- a/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
++++ b/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
+@@ -532,6 +532,7 @@ void QPageSetupWidget::updateWidget()
+ void QPageSetupWidget::setupPrinter() const
+ {
+     m_printer->setPageLayout(m_pageLayout);
++    m_printer->setPageOrientation(m_pageLayout.orientation());
+ #if QT_CONFIG(cups)
+     QCUPSSupport::PagesPerSheet pagesPerSheet = qvariant_cast<QCUPSSupport::PagesPerSheet>(m_ui.pagesPerSheetCombo->currentData()
+ );
+diff --git a/qtbase/src/printsupport/dialogs/qprintdialog.qrc b/qtbase/src/printsupport/dialogs/qprintdialog.qrc
+index 5a579baa55..10b8e1d341 100644
+--- a/qtbase/src/printsupport/dialogs/qprintdialog.qrc
++++ b/qtbase/src/printsupport/dialogs/qprintdialog.qrc
+@@ -1,9 +1,9 @@
+ <!DOCTYPE RCC><RCC version="1.0">
+ <qresource prefix="/qt-project.org/dialogs/qprintpreviewdialog">
+-<file>images/fit-page-24.png</file>
+-<file>images/fit-page-32.png</file>
+-<file>images/fit-width-24.png</file>
+-<file>images/fit-width-32.png</file>
++<file>images/zoom-fit-page-24.png</file>
++<file>images/zoom-fit-page-32.png</file>
++<file>images/zoom-fit-width-24.png</file>
++<file>images/zoom-fit-width-32.png</file>
+ <file>images/go-first-24.png</file>
+ <file>images/go-first-32.png</file>
+ <file>images/go-last-24.png</file>
+@@ -18,14 +18,14 @@
+ <file>images/layout-portrait-32.png</file>
+ <file>images/page-setup-24.png</file>
+ <file>images/page-setup-32.png</file>
+-<file>images/print-24.png</file>
+-<file>images/print-32.png</file>
+-<file>images/view-page-multi-24.png</file>
+-<file>images/view-page-multi-32.png</file>
+-<file>images/view-page-one-24.png</file>
+-<file>images/view-page-one-32.png</file>
+-<file>images/view-page-sided-24.png</file>
+-<file>images/view-page-sided-32.png</file>
++<file>images/printer-24.png</file>
++<file>images/printer-32.png</file>
++<file>images/view-pages-overview-24.png</file>
++<file>images/view-pages-overview-32.png</file>
++<file>images/view-pages-single-24.png</file>
++<file>images/view-pages-single-32.png</file>
++<file>images/view-pages-facing-24.png</file>
++<file>images/view-pages-facing-32.png</file>
+ <file>images/zoom-in-24.png</file>
+ <file>images/zoom-in-32.png</file>
+ <file>images/zoom-out-24.png</file>
+diff --git a/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp b/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
+index c5b845f4ec..5a5ba1d0a8 100644
+--- a/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
++++ b/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
+@@ -702,13 +702,14 @@ void QPrintDialogPrivate::selectPrinter(const QPrinter::OutputFormat outputForma
+         else
+             options.grayscale->setChecked(true);
+ 
+-        // keep duplex value explicitly set by user, if any, and selected printer supports it;
+-        // use device default otherwise
++        // duplex priorities to be as follows:
++        // 1) a user-selected duplex value in the dialog has highest prority
++        // 2) duplex value set in the QPrinter
+         QPrint::DuplexMode duplex;
+         if (explicitDuplexMode != QPrint::DuplexAuto && supportedDuplexMode.contains(explicitDuplexMode))
+             duplex = explicitDuplexMode;
+         else
+-            duplex = top->d->m_currentPrintDevice.defaultDuplexMode();
++            duplex = static_cast<QPrint::DuplexMode>(p->duplex());
+         switch (duplex) {
+         case QPrint::DuplexNone:
+             options.noDuplex->setChecked(true); break;
+@@ -1242,10 +1243,10 @@ void QUnixPrintWidgetPrivate::_q_printerChanged(int index)
+             QString filename = widget.filename->text();
+             widget.filename->setText(filename);
+             widget.lOutput->setEnabled(true);
+-            if (optionsPane)
+-                optionsPane->selectPrinter(QPrinter::PdfFormat);
+             printer->setOutputFormat(QPrinter::PdfFormat);
+             m_currentPrintDevice = QPrintDevice();
++            if (optionsPane)
++                optionsPane->selectPrinter(QPrinter::PdfFormat);
+             return;
+         }
+     }
+diff --git a/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp b/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
+index 39575d5f57..23b7e89538 100644
+--- a/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
++++ b/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
+@@ -352,7 +352,7 @@ void QPrintPreviewDialogPrivate::init(QPrinter *_printer)
+ static inline void qt_setupActionIcon(QAction *action, QLatin1String name)
+ {
+     QLatin1String imagePrefix(":/qt-project.org/dialogs/qprintpreviewdialog/images/");
+-    QIcon icon;
++    QIcon icon = QIcon::fromTheme(name);
+     icon.addFile(imagePrefix + name + QLatin1String("-24.png"), QSize(24, 24));
+     icon.addFile(imagePrefix + name + QLatin1String("-32.png"), QSize(32, 32));
+     action->setIcon(icon);
+@@ -383,8 +383,8 @@ void QPrintPreviewDialogPrivate::setupActions()
+     fitPageAction->setObjectName(QLatin1String("fitPageAction"));
+     fitWidthAction->setCheckable(true);
+     fitPageAction->setCheckable(true);
+-    qt_setupActionIcon(fitWidthAction, QLatin1String("fit-width"));
+-    qt_setupActionIcon(fitPageAction, QLatin1String("fit-page"));
++    qt_setupActionIcon(fitWidthAction, QLatin1String("zoom-fit-width"));
++    qt_setupActionIcon(fitPageAction, QLatin1String("zoom-fit-page"));
+     QObject::connect(fitGroup, SIGNAL(triggered(QAction*)), q, SLOT(_q_fit(QAction*)));
+ 
+     // Zoom
+@@ -410,9 +410,9 @@ void QPrintPreviewDialogPrivate::setupActions()
+     singleModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show single page"));
+     facingModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show facing pages"));
+     overviewModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show overview of all pages"));
+-    qt_setupActionIcon(singleModeAction, QLatin1String("view-page-one"));
+-    qt_setupActionIcon(facingModeAction, QLatin1String("view-page-sided"));
+-    qt_setupActionIcon(overviewModeAction, QLatin1String("view-page-multi"));
++    qt_setupActionIcon(singleModeAction, QLatin1String("view-pages-single"));
++    qt_setupActionIcon(facingModeAction, QLatin1String("view-pages-facing"));
++    qt_setupActionIcon(overviewModeAction, QLatin1String("view-pages-overview"));
+     singleModeAction->setObjectName(QLatin1String("singleModeAction"));
+     facingModeAction->setObjectName(QLatin1String("facingModeAction"));
+     overviewModeAction->setObjectName(QLatin1String("overviewModeAction"));
+@@ -426,7 +426,7 @@ void QPrintPreviewDialogPrivate::setupActions()
+     printerGroup = new QActionGroup(q);
+     printAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Print"));
+     pageSetupAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Page setup"));
+-    qt_setupActionIcon(printAction, QLatin1String("print"));
++    qt_setupActionIcon(printAction, QLatin1String("printer"));
+     qt_setupActionIcon(pageSetupAction, QLatin1String("page-setup"));
+     QObject::connect(printAction, SIGNAL(triggered(bool)), q, SLOT(_q_print()));
+     QObject::connect(pageSetupAction, SIGNAL(triggered(bool)), q, SLOT(_q_pageSetup()));
+diff --git a/qtbase/src/sql/kernel/qsqlquery.cpp b/qtbase/src/sql/kernel/qsqlquery.cpp
+index 32c6166c79..60afef10c3 100644
+--- a/qtbase/src/sql/kernel/qsqlquery.cpp
++++ b/qtbase/src/sql/kernel/qsqlquery.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2022 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtSql module of the Qt Toolkit.
+@@ -377,6 +377,10 @@ bool QSqlQuery::exec(const QString& query)
+     QElapsedTimer t;
+     t.start();
+ #endif
++    if (!driver()) {
++        qWarning("QSqlQuery::exec: called before driver has been set up");
++        return false;
++    }
+     if (d->ref.loadRelaxed() != 1) {
+         bool fo = isForwardOnly();
+         *this = QSqlQuery(driver()->createResult());
+diff --git a/qtbase/src/testlib/qabstractitemmodeltester.cpp b/qtbase/src/testlib/qabstractitemmodeltester.cpp
+index 8efb9c53d4..ce062f66d7 100644
+--- a/qtbase/src/testlib/qabstractitemmodeltester.cpp
++++ b/qtbase/src/testlib/qabstractitemmodeltester.cpp
+@@ -454,7 +454,7 @@ void QAbstractItemModelTesterPrivate::parent()
+ 
+     // Common error test #2, make sure that a second level index has a parent
+     // that is the first level index.
+-    if (model->rowCount(topIndex) > 0) {
++    if (model->rowCount(topIndex) > 0 && model->columnCount(topIndex) > 0) {
+         QModelIndex childIndex = model->index(0, 0, topIndex);
+         MODELTESTER_VERIFY(childIndex.isValid());
+         MODELTESTER_COMPARE(model->parent(childIndex), topIndex);
+diff --git a/qtbase/src/testlib/qasciikey.cpp b/qtbase/src/testlib/qasciikey.cpp
+index 9a308da2bc..93498b256f 100644
+--- a/qtbase/src/testlib/qasciikey.cpp
++++ b/qtbase/src/testlib/qasciikey.cpp
+@@ -498,6 +498,11 @@ char QTest::keyToAscii(Qt::Key key)
+     case Qt::Key_LaunchE : return 0; // = 0x10b0,
+     case Qt::Key_LaunchF : return 0; // = 0x10b1,
+ 
++    // Keypad navigation keys
++    case Qt::Key_Select : return 0; // = 0x01010000
++    case Qt::Key_Yes : return 0; // = 0x01010001
++    case Qt::Key_No : return 0; // = 0x01010002
++
+     default: QTEST_ASSERT(false); return 0;
+     }
+ }
+diff --git a/qtbase/src/testlib/qtestresult.cpp b/qtbase/src/testlib/qtestresult.cpp
+index 88028aac6e..2e89930776 100644
+--- a/qtbase/src/testlib/qtestresult.cpp
++++ b/qtbase/src/testlib/qtestresult.cpp
+@@ -251,7 +251,8 @@ bool QTestResult::verify(bool statement, const char *statementStr,
+ {
+     QTEST_ASSERT(statementStr);
+ 
+-    char msg[1024] = {'\0'};
++    char msg[1024];
++    msg[0] = '\0';
+ 
+     if (QTestLog::verboseLevel() >= 2) {
+         qsnprintf(msg, 1024, "QVERIFY(%s)", statementStr);
+@@ -309,7 +310,8 @@ static bool compareHelper(bool success, const char *failureMsg,
+                           bool hasValues = true)
+ {
+     const size_t maxMsgLen = 1024;
+-    char msg[maxMsgLen] = {'\0'};
++    char msg[maxMsgLen];
++    msg[0] = '\0';
+ 
+     QTEST_ASSERT(expected);
+     QTEST_ASSERT(actual);
+diff --git a/qtbase/src/widgets/dialogs/qcolordialog.cpp b/qtbase/src/widgets/dialogs/qcolordialog.cpp
+index 4247731275..cb325be85c 100644
+--- a/qtbase/src/widgets/dialogs/qcolordialog.cpp
++++ b/qtbase/src/widgets/dialogs/qcolordialog.cpp
+@@ -78,7 +78,10 @@
+ #include "qwindow.h"
+ 
+ #include "private/qdialog_p.h"
++#include "private/qguiapplication_p.h"
+ 
++#include <qpa/qplatformservices.h>
++#include <qpa/qplatformintegration.h>
+ #include <algorithm>
+ 
+ QT_BEGIN_NAMESPACE
+@@ -1611,6 +1614,20 @@ void QColorDialogPrivate::_q_newStandard(int r, int c)
+ void QColorDialogPrivate::_q_pickScreenColor()
+ {
+     Q_Q(QColorDialog);
++
++    auto *platformServices = QGuiApplicationPrivate::platformIntegration()->services();
++    if (platformServices->hasCapability(QPlatformServices::Capability::ColorPicking)) {
++        if (auto *colorPicker = platformServices->colorPicker(q->windowHandle())) {
++            q->connect(colorPicker, &QPlatformServiceColorPicker::colorPicked, q,
++                       [q, colorPicker](const QColor &color) {
++                           colorPicker->deleteLater();
++                           q->setCurrentColor(color);
++                       });
++            colorPicker->pickColor();
++            return;
++        }
++    }
++
+     if (!colorPickingEventFilter)
+         colorPickingEventFilter = new QColorPickingEventFilter(this, q);
+     q->installEventFilter(colorPickingEventFilter);
+diff --git a/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp b/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
+index e120817edc..8ea36b5427 100644
+--- a/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
++++ b/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
+@@ -400,12 +400,7 @@ bool QAbstractItemDelegate::helpEvent(QHelpEvent *event,
+         const QString tooltip = index.isValid() ?
+               d->textForRole(Qt::ToolTipRole, index.data(Qt::ToolTipRole), option.locale, precision) :
+               QString();
+-        QRect rect;
+-        if (index.isValid()) {
+-            const QRect r = view->visualRect(index);
+-            rect = QRect(view->mapToGlobal(r.topLeft()), r.size());
+-        }
+-        QToolTip::showText(he->globalPos(), tooltip, view, rect);
++        QToolTip::showText(he->globalPos(), tooltip, view->viewport(), option.rect);
+         event->setAccepted(!tooltip.isEmpty());
+         break;
+         }
+diff --git a/qtbase/src/widgets/itemviews/qlistview.cpp b/qtbase/src/widgets/itemviews/qlistview.cpp
+index 2b34476642..eebfaa030e 100644
+--- a/qtbase/src/widgets/itemviews/qlistview.cpp
++++ b/qtbase/src/widgets/itemviews/qlistview.cpp
+@@ -3386,6 +3386,7 @@ void QIconModeViewBase::updateContentsSize()
+ */
+ void QListView::currentChanged(const QModelIndex &current, const QModelIndex &previous)
+ {
++    QAbstractItemView::currentChanged(current, previous);
+ #ifndef QT_NO_ACCESSIBILITY
+     if (QAccessible::isActive()) {
+         if (current.isValid()) {
+@@ -3396,7 +3397,6 @@ void QListView::currentChanged(const QModelIndex &current, const QModelIndex &pr
+         }
+     }
+ #endif
+-    QAbstractItemView::currentChanged(current, previous);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/widgets/itemviews/qtableview.cpp b/qtbase/src/widgets/itemviews/qtableview.cpp
+index 934ac581b2..f79bb24249 100644
+--- a/qtbase/src/widgets/itemviews/qtableview.cpp
++++ b/qtbase/src/widgets/itemviews/qtableview.cpp
+@@ -1013,6 +1013,7 @@ void QTableViewPrivate::drawCell(QPainter *painter, const QStyleOptionViewItem &
+ int QTableViewPrivate::widthHintForIndex(const QModelIndex &index, int hint, const QStyleOptionViewItem &option) const
+ {
+     Q_Q(const QTableView);
++    const int oldHint = hint;
+     QWidget *editor = editorForIndex(index).widget.data();
+     if (editor && persistent.contains(editor)) {
+         hint = qMax(hint, editor->sizeHint().width());
+@@ -1021,6 +1022,17 @@ int QTableViewPrivate::widthHintForIndex(const QModelIndex &index, int hint, con
+         hint = qBound(min, hint, max);
+     }
+     hint = qMax(hint, q->itemDelegate(index)->sizeHint(option, index).width());
++
++    if (hasSpans()) {
++        auto span = spans.spanAt(index.column(), index.row());
++        if (span && span->m_left == index.column() && span->m_top == index.row()) {
++            // spans are screwed up when sections are moved
++            const auto left = logicalColumn(span->m_left);
++            for (int i = 1; i <= span->width(); ++i)
++               hint -= q->columnWidth(visualColumn(left + i));
++        }
++        hint = std::max(hint, oldHint);
++    }
+     return hint;
+ }
+ 
+@@ -1053,6 +1065,11 @@ int QTableViewPrivate::heightHintForIndex(const QModelIndex &index, int hint, QS
+         option.rect.setHeight(height);
+         option.rect.setX(q->columnViewportPosition(index.column()));
+         option.rect.setWidth(q->columnWidth(index.column()));
++        if (hasSpans()) {
++            auto span = spans.spanAt(index.column(), index.row());
++            if (span && span->m_left == index.column() && span->m_top == index.row())
++                option.rect.setWidth(std::max(option.rect.width(), visualSpanRect(*span).width()));
++        }
+         // 1px less space when grid is shown (see drawCell)
+         if (showGrid)
+             option.rect.setWidth(option.rect.width() - 1);
+diff --git a/qtbase/src/widgets/kernel/qaction.h b/qtbase/src/widgets/kernel/qaction.h
+index 258a1ea0a0..737c1e8285 100644
+--- a/qtbase/src/widgets/kernel/qaction.h
++++ b/qtbase/src/widgets/kernel/qaction.h
+@@ -81,7 +81,7 @@ class Q_WIDGETS_EXPORT QAction : public QObject
+     Q_PROPERTY(MenuRole menuRole READ menuRole WRITE setMenuRole NOTIFY changed)
+     Q_PROPERTY(bool iconVisibleInMenu READ isIconVisibleInMenu WRITE setIconVisibleInMenu NOTIFY changed)
+     Q_PROPERTY(bool shortcutVisibleInContextMenu READ isShortcutVisibleInContextMenu WRITE setShortcutVisibleInContextMenu NOTIFY changed)
+-    Q_PROPERTY(Priority priority READ priority WRITE setPriority)
++    Q_PROPERTY(Priority priority READ priority WRITE setPriority NOTIFY changed)
+ 
+ public:
+     // note this is copied into qplatformmenu.h, which must stay in sync
+diff --git a/qtbase/src/widgets/kernel/qwidget.cpp b/qtbase/src/widgets/kernel/qwidget.cpp
+index 9eba1e001e..26f6d27e18 100644
+--- a/qtbase/src/widgets/kernel/qwidget.cpp
++++ b/qtbase/src/widgets/kernel/qwidget.cpp
+@@ -5296,7 +5296,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
+         QWidgetEffectSourcePrivate *sourced = static_cast<QWidgetEffectSourcePrivate *>
+                                                          (source->d_func());
+         if (!sourced->context) {
+-            const QRegion effectRgn(rgn.boundingRect());
++            const QRegion effectRgn((flags & UseEffectRegionBounds) ? rgn.boundingRect() : rgn);
+             QWidgetPaintContext context(pdev, effectRgn, offset, flags, sharedPainter, repaintManager);
+             sourced->context = &context;
+             if (!sharedPainter) {
+@@ -5328,6 +5328,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
+         }
+     }
+ #endif // QT_CONFIG(graphicseffect)
++    flags = flags & ~UseEffectRegionBounds;
+ 
+     const bool alsoOnScreen = flags & DrawPaintOnScreen;
+     const bool recursive = flags & DrawRecursive;
+diff --git a/qtbase/src/widgets/kernel/qwidget_p.h b/qtbase/src/widgets/kernel/qwidget_p.h
+index eef6b8fa2c..c432f4b5d5 100644
+--- a/qtbase/src/widgets/kernel/qwidget_p.h
++++ b/qtbase/src/widgets/kernel/qwidget_p.h
+@@ -229,7 +229,8 @@ public:
+         DontSubtractOpaqueChildren = 0x10,
+         DontDrawOpaqueChildren = 0x20,
+         DontDrawNativeChildren = 0x40,
+-        DontSetCompositionMode = 0x80
++        DontSetCompositionMode = 0x80,
++        UseEffectRegionBounds = 0x100
+     };
+     Q_DECLARE_FLAGS(DrawWidgetFlags, DrawWidgetFlag)
+     Q_FLAG(DrawWidgetFlags)
+diff --git a/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp b/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
+index 02880b34da..0d44e1326d 100644
+--- a/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
++++ b/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
+@@ -1018,7 +1018,8 @@ void QWidgetRepaintManager::paintAndFlush()
+ 
+     // Paint the rest with composition.
+     if (repaintAllWidgets || !dirtyCopy.isEmpty()) {
+-        QWidgetPrivate::DrawWidgetFlags flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive;
++        QWidgetPrivate::DrawWidgetFlags flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive
++                | QWidgetPrivate::UseEffectRegionBounds;
+         tlw->d_func()->drawWidget(store->paintDevice(), dirtyCopy, QPoint(), flags, nullptr, this);
+     }
+ 
+diff --git a/qtbase/src/widgets/styles/qfusionstyle.cpp b/qtbase/src/widgets/styles/qfusionstyle.cpp
+index f4345d97c4..962912c838 100644
+--- a/qtbase/src/widgets/styles/qfusionstyle.cpp
++++ b/qtbase/src/widgets/styles/qfusionstyle.cpp
+@@ -1772,14 +1772,6 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio
+             proxy()->drawControl(CE_PushButtonLabel, &subopt, painter, widget);
+         }
+         break;
+-    case CE_PushButtonLabel:
+-        if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
+-            QStyleOptionButton b(*button);
+-            // no PM_ButtonShiftHorizontal and PM_ButtonShiftVertical for fusion style
+-            b.state &= ~(State_On | State_Sunken);
+-            QCommonStyle::drawControl(element, &b, painter, widget);
+-        }
+-        break;
+     case CE_MenuBarEmptyArea:
+         painter->save();
+     {
+diff --git a/qtbase/src/widgets/util/qcompleter.cpp b/qtbase/src/widgets/util/qcompleter.cpp
+index 18b24063d8..ef7207a8a3 100644
+--- a/qtbase/src/widgets/util/qcompleter.cpp
++++ b/qtbase/src/widgets/util/qcompleter.cpp
+@@ -1120,6 +1120,8 @@ void QCompleter::setModel(QAbstractItemModel *model)
+ {
+     Q_D(QCompleter);
+     QAbstractItemModel *oldModel = d->proxy->sourceModel();
++    if (oldModel == model)
++        return;
+ #if QT_CONFIG(filesystemmodel)
+     if (qobject_cast<const QFileSystemModel *>(oldModel))
+         setCompletionRole(Qt::EditRole); // QTBUG-54642, clear FileNameRole set by QFileSystemModel
+diff --git a/qtbase/src/widgets/widgets/qabstractbutton.cpp b/qtbase/src/widgets/widgets/qabstractbutton.cpp
+index a128b23950..dc40bf62fb 100644
+--- a/qtbase/src/widgets/widgets/qabstractbutton.cpp
++++ b/qtbase/src/widgets/widgets/qabstractbutton.cpp
+@@ -56,6 +56,7 @@
+ #ifndef QT_NO_ACCESSIBILITY
+ #include "qaccessible.h"
+ #endif
++#include <qpa/qplatformtheme.h>
+ 
+ #include <algorithm>
+ 
+@@ -1076,19 +1077,19 @@ void QAbstractButton::keyPressEvent(QKeyEvent *e)
+ {
+     Q_D(QAbstractButton);
+     bool next = true;
+-    switch (e->key()) {
+-    case Qt::Key_Enter:
+-    case Qt::Key_Return:
+-        e->ignore();
+-        break;
+-    case Qt::Key_Select:
+-    case Qt::Key_Space:
+-        if (!e->isAutoRepeat()) {
+-            setDown(true);
+-            repaint();
+-            d->emitPressed();
+-        }
+-        break;
++
++    const auto key = static_cast<Qt::Key>(e->key());
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(key) && !e->isAutoRepeat()) {
++        setDown(true);
++        repaint();
++        d->emitPressed();
++        return;
++    }
++
++    switch (key) {
+     case Qt::Key_Up:
+         next = false;
+         Q_FALLTHROUGH();
+@@ -1153,15 +1154,15 @@ void QAbstractButton::keyReleaseEvent(QKeyEvent *e)
+     if (!e->isAutoRepeat())
+         d->repeatTimer.stop();
+ 
+-    switch (e->key()) {
+-    case Qt::Key_Select:
+-    case Qt::Key_Space:
+-        if (!e->isAutoRepeat() && d->down)
+-            d->click();
+-        break;
+-    default:
+-        e->ignore();
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(static_cast<Qt::Key>(e->key())) && !e->isAutoRepeat() && d->down) {
++        d->click();
++        return;
+     }
++
++    e->ignore();
+ }
+ 
+ /*!\reimp
+diff --git a/qtbase/src/widgets/widgets/qcombobox.cpp b/qtbase/src/widgets/widgets/qcombobox.cpp
+index 7a496c27e0..0a3d96647b 100644
+--- a/qtbase/src/widgets/widgets/qcombobox.cpp
++++ b/qtbase/src/widgets/widgets/qcombobox.cpp
+@@ -3352,7 +3352,23 @@ void QComboBox::keyPressEvent(QKeyEvent *e)
+ 
+     Move move = NoMove;
+     int newIndex = currentIndex();
+-    switch (e->key()) {
++
++    bool pressLikeButton = !d->lineEdit;
++#ifdef QT_KEYPAD_NAVIGATION
++    pressLikeButton |= QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus();
++#endif
++    auto key = static_cast<Qt::Key>(e->key());
++    if (pressLikeButton) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(key)) {
++            showPopup();
++            return;
++        }
++    }
++
++    switch (key) {
+     case Qt::Key_Up:
+         if (e->modifiers() & Qt::ControlModifier)
+             break; // pass to line edit for auto completion
+@@ -3394,26 +3410,11 @@ void QComboBox::keyPressEvent(QKeyEvent *e)
+             return;
+         }
+         break;
+-    case Qt::Key_Space:
+-        if (!d->lineEdit) {
+-            showPopup();
+-            return;
+-        }
+-        break;
+-    case Qt::Key_Enter:
+-    case Qt::Key_Return:
+     case Qt::Key_Escape:
+         if (!d->lineEdit)
+             e->ignore();
+         break;
+ #ifdef QT_KEYPAD_NAVIGATION
+-    case Qt::Key_Select:
+-        if (QApplicationPrivate::keypadNavigationEnabled()
+-                && (!hasEditFocus() || !d->lineEdit)) {
+-            showPopup();
+-            return;
+-        }
+-        break;
+     case Qt::Key_Left:
+     case Qt::Key_Right:
+         if (QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus())
+diff --git a/qtbase/src/widgets/widgets/qdatetimeedit_p.h b/qtbase/src/widgets/widgets/qdatetimeedit_p.h
+index d36b6f8f9a..e0df5b5158 100644
+--- a/qtbase/src/widgets/widgets/qdatetimeedit_p.h
++++ b/qtbase/src/widgets/widgets/qdatetimeedit_p.h
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2018 The Qt Company Ltd.
++** Copyright (C) 2021 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtWidgets module of the Qt Toolkit.
+diff --git a/qtbase/src/widgets/widgets/qgroupbox.cpp b/qtbase/src/widgets/widgets/qgroupbox.cpp
+index 02a0bed325..3f3eccc370 100644
+--- a/qtbase/src/widgets/widgets/qgroupbox.cpp
++++ b/qtbase/src/widgets/widgets/qgroupbox.cpp
+@@ -54,6 +54,8 @@
+ #include "qaccessible.h"
+ #endif
+ #include <private/qwidget_p.h>
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
+ 
+ #include "qdebug.h"
+ 
+@@ -360,7 +362,10 @@ bool QGroupBox::event(QEvent *e)
+         return true;
+     case QEvent::KeyPress: {
+         QKeyEvent *k = static_cast<QKeyEvent*>(e);
+-        if (!k->isAutoRepeat() && (k->key() == Qt::Key_Select || k->key() == Qt::Key_Space)) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (!k->isAutoRepeat() && buttonPressKeys.contains(static_cast<Qt::Key>(k->key()))) {
+             d->pressedControl = QStyle::SC_GroupBoxCheckBox;
+             update(style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxCheckBox, this));
+             return true;
+@@ -369,7 +374,10 @@ bool QGroupBox::event(QEvent *e)
+     }
+     case QEvent::KeyRelease: {
+         QKeyEvent *k = static_cast<QKeyEvent*>(e);
+-        if (!k->isAutoRepeat() && (k->key() == Qt::Key_Select || k->key() == Qt::Key_Space)) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (!k->isAutoRepeat() && buttonPressKeys.contains(static_cast<Qt::Key>(k->key()))) {
+             bool toggle = (d->pressedControl == QStyle::SC_GroupBoxLabel
+                            || d->pressedControl == QStyle::SC_GroupBoxCheckBox);
+             d->pressedControl = QStyle::SC_None;
+diff --git a/qtbase/src/widgets/widgets/qlabel.cpp b/qtbase/src/widgets/widgets/qlabel.cpp
+index 30ff80cbb0..cf2605c17c 100644
+--- a/qtbase/src/widgets/widgets/qlabel.cpp
++++ b/qtbase/src/widgets/widgets/qlabel.cpp
+@@ -421,9 +421,6 @@ void QLabel::setPixmap(const QPixmap &pixmap)
+         d->pixmap = new QPixmap(pixmap);
+     }
+ 
+-    if (d->pixmap->depth() == 1 && !d->pixmap->mask())
+-        d->pixmap->setMask(*((QBitmap *)d->pixmap));
+-
+     d->updateLabel();
+ }
+ 
+diff --git a/qtbase/src/widgets/widgets/qtoolbararealayout.cpp b/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
+index 493c094cc1..d5f4b59017 100644
+--- a/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
++++ b/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
+@@ -1367,7 +1367,7 @@ bool QToolBarAreaLayout::restoreState(QDataStream &stream, const QList<QToolBar*
+                 item.widgetItem = new QWidgetItemV2(toolBar);
+                 toolBar->setOrientation(floating ? ((shown & 2) ? Qt::Vertical : Qt::Horizontal) : dock.o);
+                 toolBar->setVisible(shown & 1);
+-                toolBar->d_func()->setWindowState(floating, true, rect);
++                toolBar->d_func()->setWindowState(floating, false, rect);
+ 
+                 item.preferredSize = item.size;
+                 line.toolBarItems.append(item);
+diff --git a/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp b/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
+index 212c0a2e13..3c77b1ba0b 100644
+--- a/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
++++ b/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
+@@ -126,8 +126,7 @@ public:
+ 
+ void tst_QtConcurrentIterateKernel::instantiate()
+ {
+-    auto future = startThreadEngine(new PrintFor(0, 40)).startAsynchronously();
+-    future.waitForFinished();
++    startThreadEngine(new PrintFor(0, 40)).startBlocking();
+     QCOMPARE(iterations.loadRelaxed(), 40);
+ }
+ 
+@@ -166,10 +165,8 @@ void tst_QtConcurrentIterateKernel::stresstest()
+     const int times = 50;
+     for (int i = 0; i < times; ++i) {
+         counter.storeRelaxed(0);
+-        // ThreadEngine will delete f when it finishes
+-        auto f = new CountFor(0, iterations);
+-        auto future = f->startAsynchronously();
+-        future.waitForFinished();
++        CountFor f(0, iterations);
++        f.startBlocking();
+         QCOMPARE(counter.loadRelaxed(), iterations);
+     }
+ }
+@@ -177,11 +174,8 @@ void tst_QtConcurrentIterateKernel::stresstest()
+ void tst_QtConcurrentIterateKernel::noIterations()
+ {
+     const int times = 20000;
+-    for (int i = 0; i < times; ++i) {
+-        auto future = startThreadEngine(new IterateKernel<TestIterator, void>(0, 0))
+-                              .startAsynchronously();
+-        future.waitForFinished();
+-    }
++    for (int i = 0; i < times; ++i)
++        startThreadEngine(new IterateKernel<TestIterator, void>(0, 0)).startBlocking();
+ }
+ 
+ QMutex threadsMutex;
+@@ -236,10 +230,8 @@ void tst_QtConcurrentIterateKernel::throttling()
+ 
+     threads.clear();
+ 
+-    // ThreadEngine will delete f when it finishes
+-    auto f = new ThrottleFor(0, totalIterations);
+-    auto future = f->startAsynchronously();
+-    future.waitForFinished();
++    ThrottleFor f(0, totalIterations);
++    f.startBlocking();
+ 
+     QCOMPARE(iterations.loadRelaxed(), totalIterations);
+ 
+diff --git a/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp b/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
+index ac7be7acdd..81bc64c8d9 100644
+--- a/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
++++ b/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
+@@ -65,9 +65,16 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::runDirectly()
+ {
+-    PrintUser *engine = new PrintUser();
+-    QFuture<void> f = engine->startAsynchronously();
+-    f.waitForFinished();
++    {
++        PrintUser engine;
++        engine.startSingleThreaded();
++        engine.startBlocking();
++    }
++    {
++        PrintUser *engine = new PrintUser();
++        QFuture<void> f = engine->startAsynchronously();
++        f.waitForFinished();
++    }
+ }
+ 
+ class StringResultUser : public ThreadEngine<QString>
+@@ -99,10 +106,8 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::result()
+ {
+-    // ThreadEngine will delete 'engine' when it finishes
+-    auto engine = new StringResultUser();
+-    auto future = engine->startAsynchronously();
+-    QCOMPARE(future.result(), QString("Foo"));
++    StringResultUser engine;
++    QCOMPARE(*engine.startBlocking(), QString("Foo"));
+ }
+ 
+ class VoidResultUser : public ThreadEngine<void>
+@@ -128,9 +133,17 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::runThroughStarter()
+ {
+-    ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
+-    QFuture<QString> f = starter.startAsynchronously();
+-    QCOMPARE(f.result(), QString("Foo"));
++    {
++        ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
++        QFuture<QString>  f = starter.startAsynchronously();
++        QCOMPARE(f.result(), QString("Foo"));
++    }
++
++    {
++        ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
++        QString str = starter.startBlocking();
++        QCOMPARE(str, QString("Foo"));
++    }
+ }
+ 
+ class CancelUser : public ThreadEngine<void>
+@@ -213,6 +226,12 @@ void tst_QtConcurrentThreadEngine::throttle()
+         f.waitForFinished();
+         QCOMPARE(count.loadRelaxed(), 0);
+     }
++
++    for (int i = 0; i < repeats; ++i) {
++        ThrottleAlwaysUser t;
++        t.startBlocking();
++        QCOMPARE(count.loadRelaxed(), 0);
++    }
+ }
+ 
+ QSet<QThread *> threads;
+@@ -249,17 +268,35 @@ void tst_QtConcurrentThreadEngine::threadCount()
+ {
+     const int repeats = 10;
+     for (int i = 0; i < repeats; ++i) {
++        ThreadCountUser t;
++        t.startBlocking();
++        int count = threads.count();
++        int count_expected = QThreadPool::globalInstance()->maxThreadCount() + 1; // +1 for the main thread.
++        if (count != count_expected)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, count_expected);
++
+         (new ThreadCountUser())->startAsynchronously().waitForFinished();
+-        const auto count = threads.count();
+-        const auto maxThreadCount = QThreadPool::globalInstance()->maxThreadCount();
+-        QVERIFY(count <= maxThreadCount);
+-        QVERIFY(!threads.contains(QThread::currentThread()));
++        count = threads.count();
++        count_expected = QThreadPool::globalInstance()->maxThreadCount();
++        if (count != count_expected)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, count_expected);
+     }
+ 
+     // Set the finish flag immediately, this should give us one thread only.
+     for (int i = 0; i < repeats; ++i) {
++        ThreadCountUser t(true /*finishImmediately*/);
++        t.startBlocking();
++        int count = threads.count();
++        if (count != 1)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, 1);
++
+         (new ThreadCountUser(true /*finishImmediately*/))->startAsynchronously().waitForFinished();
+-        const auto count = threads.count();
++        count = threads.count();
++        if (count != 1)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
+         QCOMPARE(count, 1);
+         QVERIFY(!threads.contains(QThread::currentThread()));
+     }
+@@ -400,6 +437,7 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::exceptions()
+ {
++    // Asynchronous mode:
+     {
+         bool caught = false;
+         try  {
+@@ -412,6 +450,32 @@ void tst_QtConcurrentThreadEngine::exceptions()
+         QVERIFY2(caught, "did not get exception");
+     }
+ 
++    // Blocking mode:
++    // test throwing the exception from a worker thread.
++    {
++        bool caught = false;
++        try  {
++            QtConcurrentExceptionThrower e(QThread::currentThread());
++            e.startBlocking();
++        } catch (const QException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // test throwing the exception from the main thread (different code path)
++    {
++        bool caught = false;
++        try  {
++            QtConcurrentExceptionThrower e(0);
++            e.startBlocking();
++        } catch (const QException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // Asynchronous mode:
+     {
+         bool caught = false;
+         try  {
+@@ -423,6 +487,31 @@ void tst_QtConcurrentThreadEngine::exceptions()
+         }
+         QVERIFY2(caught, "did not get exception");
+     }
++
++    // Blocking mode:
++    // test throwing the exception from a worker thread.
++    {
++        bool caught = false;
++        try  {
++            UnrelatedExceptionThrower e(QThread::currentThread());
++            e.startBlocking();
++        } catch (const QUnhandledException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // test throwing the exception from the main thread (different code path)
++    {
++        bool caught = false;
++        try  {
++            UnrelatedExceptionThrower e(0);
++            e.startBlocking();
++        } catch (const QUnhandledException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
+ }
+ 
+ #endif
+diff --git a/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp b/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
+index 4968742110..f4c3fb711d 100644
+--- a/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
++++ b/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
+@@ -42,6 +42,7 @@ private slots:
+     void writeBlock_data();
+     void writeBlock();
+     void seek();
++    void invalidSeeks();
+     void seekTest_data();
+     void seekTest();
+     void read_rawdata();
+@@ -286,6 +287,29 @@ void tst_QBuffer::seek()
+     QCOMPARE(buffer.size(), pos);
+ }
+ 
++void tst_QBuffer::invalidSeeks()
++{
++    if constexpr (sizeof(qsizetype) == sizeof(qint64)) {
++        // sizeof(qsizetype) == sizeof(qint64), so +1 would overflow
++        QSKIP("This is a 32-bit-only test.");
++    } else {
++        QBuffer buffer;
++        buffer.open(QIODevice::WriteOnly);
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++        constexpr qint64 MaxQByteArrayCapacity = (std::numeric_limits<qsizetype>::max)();
++        // this should fail fast, not after trying to allocate nearly 2 GiB of data,
++        // potentially crashing in the process:
++        QVERIFY(!buffer.seek(2 * MaxQByteArrayCapacity - 1));
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++        // ditto:
++        QVERIFY(!buffer.seek(MaxQByteArrayCapacity + 1));
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++    }
++}
++
+ void tst_QBuffer::seekTest_data()
+ {
+     writeBlock_data();
+diff --git a/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp b/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
+index da5327594c..4a04e0f7c6 100644
+--- a/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
++++ b/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
+@@ -561,7 +561,8 @@ protected:
+     qint64 readData(char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf->size() - offset));
+-        memcpy(data, buf->constData() + offset, maxSize);
++        if (maxSize > 0)
++            memcpy(data, buf->constData() + offset, maxSize);
+         offset += maxSize;
+         return maxSize;
+     }
+@@ -604,13 +605,15 @@ protected:
+     qint64 readData(char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf.size() - pos()));
+-        memcpy(data, buf.constData() + pos(), maxSize);
++        if (maxSize > 0)
++            memcpy(data, buf.constData() + pos(), maxSize);
+         return maxSize;
+     }
+     qint64 writeData(const char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf.size() - pos()));
+-        memcpy(buf.data() + pos(), data, maxSize);
++        if (maxSize > 0)
++            memcpy(buf.data() + pos(), data, maxSize);
+         return maxSize;
+     }
+ 
+diff --git a/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+index db60bead64..f345a44414 100644
+--- a/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
++++ b/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+@@ -1,7 +1,8 @@
+ /****************************************************************************
+ **
+ ** Copyright (C) 2021 The Qt Company Ltd.
+-** Copyright (C) 2020 Intel Corporation.
++** Copyright (C) 2020 The Qt Company Ltd.
++** Copyright (C) 2022 Intel Corporation.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the test suite of the Qt Toolkit.
+@@ -150,6 +151,8 @@ private slots:
+     void startStopStartStopBuffers();
+     void processEventsInAReadyReadSlot_data();
+     void processEventsInAReadyReadSlot();
++    void startFromCurrentWorkingDir_data();
++    void startFromCurrentWorkingDir();
+ 
+     // keep these at the end, since they use lots of processes and sometimes
+     // caused obscure failures to occur in tests that followed them (esp. on the Mac)
+@@ -2731,5 +2734,94 @@ void tst_QProcess::finishProcessBeforeReadingDone_deprecated()
+ 
+ #endif
+ 
++enum class ChdirMode {
++    None = 0,
++    InParent,
++    InChild
++};
++Q_DECLARE_METATYPE(ChdirMode)
++
++void tst_QProcess::startFromCurrentWorkingDir_data()
++{
++    qRegisterMetaType<ChdirMode>();
++    QTest::addColumn<QString>("programPrefix");
++    QTest::addColumn<ChdirMode>("chdirMode");
++    QTest::addColumn<bool>("success");
++
++    constexpr bool IsWindows = true
++#ifdef Q_OS_UNIX
++            && false
++#endif
++            ;
++
++    // baseline: trying to execute the directory, this can't possibly succeed!
++    QTest::newRow("plain-same-cwd") << QString() << ChdirMode::None << false;
++
++    // cross-platform behavior: neither OS searches the setWorkingDirectory()
++    // dir without "./"
++    QTest::newRow("plain-child-chdir") << QString() << ChdirMode::InChild << false;
++
++    // cross-platform behavior: both OSes search the parent's CWD with "./"
++    QTest::newRow("prefixed-parent-chdir") << "./" << ChdirMode::InParent << true;
++
++    // opposite behaviors: Windows searches the parent's CWD and Unix searches
++    // the child's with "./"
++    QTest::newRow("prefixed-child-chdir") << "./" << ChdirMode::InChild << !IsWindows;
++
++    // Windows searches the parent's CWD without "./"
++    QTest::newRow("plain-parent-chdir") << QString() << ChdirMode::InParent << IsWindows;
++}
++
++void tst_QProcess::startFromCurrentWorkingDir()
++{
++    QFETCH(QString, programPrefix);
++    QFETCH(ChdirMode, chdirMode);
++    QFETCH(bool, success);
++
++    QProcess process;
++    qRegisterMetaType<QProcess::ProcessError>();
++    QSignalSpy errorSpy(&process, &QProcess::errorOccurred);
++    QVERIFY(errorSpy.isValid());
++
++    // both the dir name and the executable name
++    const QString target = QStringLiteral("testProcessNormal");
++    process.setProgram(programPrefix + target);
++
++#ifdef Q_OS_UNIX
++    // Reset PATH, to be sure it doesn't contain . or the empty path.
++    // We can't do this on Windows because DLLs are searched in PATH
++    // and Windows always searches "." anyway.
++    auto restoreEnv = qScopeGuard([old = qgetenv("PATH")] {
++        qputenv("PATH", old);
++    });
++    qputenv("PATH", "/");
++#endif
++
++    switch (chdirMode) {
++    case ChdirMode::InParent: {
++        auto restoreCwd = qScopeGuard([old = QDir::currentPath()] {
++            QDir::setCurrent(old);
++        });
++        QVERIFY(QDir::setCurrent(target));
++        process.start();
++        break;
++    }
++    case ChdirMode::InChild:
++        process.setWorkingDirectory(target);
++        Q_FALLTHROUGH();
++    case ChdirMode::None:
++        process.start();
++        break;
++    }
++
++    QCOMPARE(process.waitForStarted(), success);
++    QCOMPARE(errorSpy.count(), int(!success));
++    if (success) {
++        QVERIFY(process.waitForFinished());
++    } else {
++        QCOMPARE(process.error(), QProcess::FailedToStart);
++    }
++}
++
+ QTEST_MAIN(tst_QProcess)
+ #include "tst_qprocess.moc"
+diff --git a/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp b/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp
+index e1ea7a4552..90972caa57 100644
+--- a/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp
++++ b/qtbase/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"
+diff --git a/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+index 9bd66c0835..ed4a0bae5d 100644
+--- a/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
++++ b/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+@@ -158,6 +158,7 @@ private slots:
+     void nullReceiver();
+     void functorReferencesConnection();
+     void disconnectDisconnects();
++    void declarativeData();
+ };
+ 
+ struct QObjectCreatedOnShutdown
+@@ -7679,5 +7680,81 @@ void tst_QObject::disconnectDisconnects()
+ Q_STATIC_ASSERT(QtPrivate::HasQ_OBJECT_Macro<tst_QObject>::Value);
+ Q_STATIC_ASSERT(!QtPrivate::HasQ_OBJECT_Macro<SiblingDeleter>::Value);
+ 
++#ifdef QT_BUILD_INTERNAL
++/*
++    Since QObjectPrivate stores the declarativeData pointer in a union with the pointer
++    to the currently destroyed child, calls to the QtDeclarative handlers need to be
++    correctly guarded. QTBUG-105286
++*/
++namespace QtDeclarative {
++static QAbstractDeclarativeData *theData;
++
++static void destroyed(QAbstractDeclarativeData *data, QObject *)
++{
++    QCOMPARE(data, theData);
++}
++static void signalEmitted(QAbstractDeclarativeData *data, QObject *, int, void **)
++{
++    QCOMPARE(data, theData);
++}
++// we can't use QCOMPARE in the next two functions, as they don't return void
++static int receivers(QAbstractDeclarativeData *data, const QObject *, int)
++{
++    QTest::qCompare(data, theData, "data", "theData", __FILE__, __LINE__);
++    return 0;
++}
++static bool isSignalConnected(QAbstractDeclarativeData *data, const QObject *, int)
++{
++    QTest::qCompare(data, theData, "data", "theData", __FILE__, __LINE__);
++    return true;
++}
++
++class Object : public QObject
++{
++    Q_OBJECT
++public:
++    using QObject::QObject;
++    ~Object()
++    {
++        if (Object *p = static_cast<Object *>(parent()))
++            p->emitSignal();
++    }
++
++    void emitSignal()
++    {
++        emit theSignal();
++    }
++
++signals:
++    void theSignal();
++};
++
++}
++#endif
++
++void tst_QObject::declarativeData()
++{
++#ifdef QT_BUILD_INTERNAL
++    QScopedValueRollback destroyed(QAbstractDeclarativeData::destroyed,
++                                   QtDeclarative::destroyed);
++    QScopedValueRollback signalEmitted(QAbstractDeclarativeData::signalEmitted,
++                                       QtDeclarative::signalEmitted);
++    QScopedValueRollback receivers(QAbstractDeclarativeData::receivers,
++                                   QtDeclarative::receivers);
++    QScopedValueRollback isSignalConnected(QAbstractDeclarativeData::isSignalConnected,
++                                           QtDeclarative::isSignalConnected);
++
++    QtDeclarative::Object p;
++    QObjectPrivate *priv = QObjectPrivate::get(&p);
++    priv->declarativeData = QtDeclarative::theData = new QAbstractDeclarativeData;
++
++    connect(&p, &QtDeclarative::Object::theSignal, &p, []{
++    });
++
++    QtDeclarative::Object *child = new QtDeclarative::Object;
++    child->setParent(&p);
++#endif
++}
++
+ QTEST_MAIN(tst_QObject)
+ #include "tst_qobject.moc"
+diff --git a/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp b/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
+index 0ea422ecbc..1a3256534b 100644
+--- a/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
++++ b/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
+@@ -70,15 +70,15 @@ static inline QString testSuiteWarning()
+ 
+     QString result;
+     QTextStream str(&result);
+-    str << "\nCannot find the shared-mime-info test suite\nstarting from: "
++    str << "\nCannot find the shared-mime-info test suite\nin the parent of: "
+         << QDir::toNativeSeparators(QDir::currentPath()) << "\n"
+            "cd " << QDir::toNativeSeparators(QStringLiteral("tests/auto/corelib/mimetypes/qmimedatabase")) << "\n"
+-           "wget http://cgit.freedesktop.org/xdg/shared-mime-info/snapshot/Release-1-10.zip\n"
+-           "unzip Release-1-10.zip\n";
++           "wget https://gitlab.freedesktop.org/xdg/shared-mime-info/-/archive/2.1/shared-mime-info-2.1.zip\n"
++           "unzip shared-mime-info-2.1.zip\n";
+ #ifdef Q_OS_WIN
+-    str << "mkdir testfiles\nxcopy /s Release-1-10 s-m-i\n";
++    str << "mkdir testfiles\nxcopy /s shared-mime-info-2.1 s-m-i\n";
+ #else
+-    str << "ln -s Release-1-10 s-m-i\n";
++    str << "ln -s shared-mime-info-2.1 s-m-i\n";
+ #endif
+     return result;
+ }
+@@ -154,7 +154,7 @@ void tst_QMimeDatabase::initTestCase()
+     QVERIFY2(copyResourceFile(xmlFileName, xmlTargetFileName, &errorMessage), qPrintable(errorMessage));
+ #endif
+ 
+-    m_testSuite = QFINDTESTDATA("s-m-i/tests");
++    m_testSuite = QFINDTESTDATA("s-m-i/tests/mime-detection");
+     if (m_testSuite.isEmpty())
+         qWarning("%s", qPrintable(testSuiteWarning()));
+ 
+@@ -611,7 +611,7 @@ void tst_QMimeDatabase::allMimeTypes()
+     QVERIFY(!lst.isEmpty());
+ 
+     // Hardcoding this is the only way to check both providers find the same number of mimetypes.
+-    QCOMPARE(lst.count(), 779);
++    QCOMPARE(lst.count(), 811);
+ 
+     foreach (const QMimeType &mime, lst) {
+         const QString name = mime.name();
+@@ -631,10 +631,9 @@ void tst_QMimeDatabase::suffixes_data()
+ 
+     QTest::newRow("mimetype with a single pattern") << "application/pdf" << "*.pdf" << "pdf";
+     QTest::newRow("mimetype with multiple patterns") << "application/x-kpresenter" << "*.kpr;*.kpt" << "kpr";
+-    QTest::newRow("jpeg") << "image/jpeg" << "*.jpe;*.jpg;*.jpeg" << "jpeg";
+-    //if (KMimeType::sharedMimeInfoVersion() > KDE_MAKE_VERSION(0, 60, 0)) {
+-        QTest::newRow("mimetype with many patterns") << "application/vnd.wordperfect" << "*.wp;*.wp4;*.wp5;*.wp6;*.wpd;*.wpp" << "wp";
+-    //}
++    // The preferred suffix for image/jpeg is *.jpg, as per https://bugs.kde.org/show_bug.cgi?id=176737
++    QTest::newRow("jpeg") << "image/jpeg" << "*.jpe;*.jpg;*.jpeg" << "jpg";
++    QTest::newRow("mimetype with many patterns") << "application/vnd.wordperfect" << "*.wp;*.wp4;*.wp5;*.wp6;*.wpd;*.wpp" << "wp";
+     QTest::newRow("oasis text mimetype") << "application/vnd.oasis.opendocument.text" << "*.odt" << "odt";
+     QTest::newRow("oasis presentation mimetype") << "application/vnd.oasis.opendocument.presentation" << "*.odp" << "odp";
+     QTest::newRow("mimetype with multiple patterns") << "text/plain" << "*.asc;*.txt;*,v" << "txt";
+diff --git a/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp b/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
+index 3e58dd03cc..c8f82ef5d5 100644
+--- a/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
++++ b/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
+@@ -176,6 +176,8 @@ private Q_SLOTS:
+     void fromToVariantConversions_data();
+     void fromToVariantConversions();
+ 
++    void noLeakOnNameClash();
++
+ private:
+     QString testDataDir;
+ };
+@@ -3685,5 +3687,23 @@ void tst_QtJson::fromToVariantConversions()
+     }
+ }
+ 
++void tst_QtJson::noLeakOnNameClash()
++{
++    QJsonDocument doc = QJsonDocument::fromJson("{\"\":{\"\":0},\"\":0}");
++    QVERIFY(!doc.isNull());
++    const QJsonObject obj = doc.object();
++
++    // Removed the duplicate key.
++    QCOMPARE(obj.length(), 1);
++
++    // Retained the last of the duplicates.
++    const QJsonValue val = obj.begin().value();
++    QVERIFY(val.isDouble());
++    QCOMPARE(val.toDouble(), 0.0);
++
++    // It should not leak.
++    // In particular it should not forget to deref the container for the inner object.
++}
++
+ QTEST_MAIN(tst_QtJson)
+ #include "tst_qtjson.moc"
+diff --git a/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp b/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
+index a59b58d57f..241c3e84ac 100644
+--- a/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
++++ b/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
+@@ -63,6 +63,7 @@ private slots:
+     void isValidId_data();
+     void isValidId();
+     void malformed();
++    void serialize();
+     // Backend tests
+     void utcTest();
+     void icuTest();
+@@ -947,6 +948,33 @@ void tst_QTimeZone::malformed()
+         barf.offsetFromUtc(now);
+ }
+ 
++void tst_QTimeZone::serialize()
++{
++    int parts = 0;
++#ifndef QT_NO_DEBUG_STREAM
++    qDebug() << QTimeZone(); // to verify no crash
++    parts++;
++#endif
++#ifndef QT_NO_DATASTREAM
++    QByteArray blob;
++    {
++        QDataStream stream(&blob, QIODevice::WriteOnly);
++        stream << QTimeZone("Europe/Oslo") << QTimeZone(420) << QTimeZone() << qint64(-1);
++    }
++    QDataStream stream(&blob, QIODevice::ReadOnly);
++    QTimeZone invalid, offset, oslo;
++    qint64 minusone;
++    stream >> oslo >> offset >> invalid >> minusone;
++    QCOMPARE(oslo, QTimeZone("Europe/Oslo"));
++    QCOMPARE(offset, QTimeZone(420));
++    QVERIFY(!invalid.isValid());
++    QCOMPARE(minusone, qint64(-1));
++    parts++;
++#endif
++    if (!parts)
++        QSKIP("No serialization enabled");
++}
++
+ void tst_QTimeZone::utcTest()
+ {
+ #ifdef QT_BUILD_INTERNAL
+diff --git a/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp b/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
+index 05480c6dd2..70f4c75756 100644
+--- a/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
++++ b/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
+@@ -324,6 +324,13 @@ void tst_QDBusInterface::notValid()
+ 
+     QVERIFY(!interface.isValid());
+     QVERIFY(!QMetaObject::invokeMethod(&interface, "ListNames", Qt::DirectConnection));
++
++    // With a connection, but empty/null service and path specified
++    QDBusConnection con = QDBusConnection::sessionBus();
++    QVERIFY(con.isConnected());
++    QDBusInterface iface({}, {}, {}, con);
++    QVERIFY(!iface.isValid());
++    QVERIFY(!QMetaObject::invokeMethod(&interface, "ListNames", Qt::DirectConnection));
+ }
+ 
+ void tst_QDBusInterface::notValidDerived()
+diff --git a/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp b/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
+index 874468c954..04ceb4ab65 100644
+--- a/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
++++ b/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
+@@ -507,6 +507,10 @@ void tst_QKeySequence::toStringFromKeycode_data()
+     QTest::newRow("Ctrl+Alt+Num+Del") << QKeySequence(Qt::ControlModifier | Qt::AltModifier | Qt::KeypadModifier | Qt::Key_Delete) << "Ctrl+Alt+Num+Del";
+     QTest::newRow("Ctrl+Ins") << QKeySequence(Qt::ControlModifier | Qt::Key_Insert) << "Ctrl+Ins";
+     QTest::newRow("Ctrl+Num+Ins(1)") << QKeySequence(Qt::Key_Insert | Qt::KeypadModifier | Qt::ControlModifier) << "Ctrl+Num+Ins";
++    QTest::newRow("Ctrl") << QKeySequence(Qt::Key_Control) << "Control";
++    QTest::newRow("Alt") << QKeySequence(Qt::Key_Alt) << "Alt";
++    QTest::newRow("Shift") << QKeySequence(Qt::Key_Shift) << "Shift";
++    QTest::newRow("Meta") << QKeySequence(Qt::Key_Meta) << "Meta";
+ }
+ 
+ void tst_QKeySequence::toStringFromKeycode()
+diff --git a/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp b/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+index 15e0ecadaa..b4eca74283 100644
+--- a/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
++++ b/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+@@ -81,6 +81,8 @@ private slots:
+     void registerOpenTypePreferredNamesSystem();
+     void registerOpenTypePreferredNamesApplication();
+ 
++    void stretchRespected();
++
+ private:
+     QString m_ledFont;
+     QString m_testFont;
+@@ -355,6 +357,28 @@ static QString testString()
+     return QStringLiteral("foo bar");
+ }
+ 
++void tst_QFontDatabase::stretchRespected()
++{
++    int italicId = QFontDatabase::addApplicationFont(m_testFontItalic);
++    QVERIFY(italicId != -1);
++
++    QVERIFY(!QFontDatabase::applicationFontFamilies(italicId).isEmpty());
++
++    QString italicFontName = QFontDatabase::applicationFontFamilies(italicId).first();
++
++    QFont italicFont = QFontDatabase().font(italicFontName,
++                                            QString::fromLatin1("Italic"), 14);
++    QVERIFY(italicFont.italic());
++
++    QFont italicStretchedFont = italicFont;
++    italicStretchedFont.setStretch( 400 );
++
++    QVERIFY(QFontMetricsF(italicFont).horizontalAdvance(QStringLiteral("foobar")) <
++            QFontMetricsF(italicStretchedFont).horizontalAdvance(QStringLiteral("foobar")));
++
++    QFontDatabase::removeApplicationFont(italicId);
++}
++
+ void tst_QFontDatabase::condensedFontWidthNoFontMerging()
+ {
+     int regularFontId = QFontDatabase::addApplicationFont(m_testFont);
+diff --git a/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+index 3d4a094c43..b423e11a99 100644
+--- a/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
++++ b/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+@@ -281,6 +281,7 @@ private Q_SLOTS:
+     void ioGetFromFileSpecial();
+     void ioGetFromFile_data();
+     void ioGetFromFile();
++    void ioGetFromFileUrl();
+     void ioGetFromFtp_data();
+     void ioGetFromFtp();
+     void ioGetFromFtpWithReuse();
+@@ -3300,6 +3301,18 @@ void tst_QNetworkReply::ioGetFromFile()
+     QCOMPARE(reader.data, data);
+ }
+ 
++void tst_QNetworkReply::ioGetFromFileUrl()
++{
++    // This immediately fails on non-windows platforms:
++    QNetworkRequest request(QUrl("file://unc-server/some/path"));
++    QNetworkReplyPtr reply(manager.get(request));
++    QSignalSpy finishedSpy(reply.get(), &QNetworkReply::finished);
++    // QTBUG-105618: This would, on non-Windows platforms, never happen because the signal
++    // was emitted before the constructor finished, leaving no chance at all to connect to the
++    // signal
++    QVERIFY(finishedSpy.wait());
++}
++
+ void tst_QNetworkReply::ioGetFromFtp_data()
+ {
+     QTest::addColumn<QString>("fileName");
+diff --git a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
+index 069fa6b341..4cc4d9a5ea 100644
+--- a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
++++ b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
+@@ -1,75 +1,34 @@
+-Certificate:
+-    Data:
+-        Version: 3 (0x2)
+-        Serial Number: 0 (0x0)
+-        Signature Algorithm: sha1WithRSAEncryption
+-        Issuer: C=NO, ST=Oslo, L=Nydalen, O=Nokia Corporation and/or its subsidiary(-ies), OU=Development, CN=fluke.troll.no/emailAddress=ahanssen@trolltech.com
+-        Validity
+-            Not Before: Dec  4 01:10:32 2007 GMT
+-            Not After : Apr 21 01:10:32 2035 GMT
+-        Subject: C=NO, ST=Oslo, O=Nokia Corporation and/or its subsidiary(-ies), OU=Development, CN=fluke.troll.no
+-        Subject Public Key Info:
+-            Public Key Algorithm: rsaEncryption
+-            RSA Public Key: (1024 bit)
+-                Modulus (1024 bit):
+-                    00:a7:c8:a0:4a:c4:19:05:1b:66:ba:32:e2:d2:f1:
+-                    1c:6f:17:82:e4:39:2e:01:51:90:db:04:34:32:11:
+-                    21:c2:0d:6f:59:d8:53:90:54:3f:83:8f:a9:d3:b3:
+-                    d5:ee:1a:9b:80:ae:c3:25:c9:5e:a5:af:4b:60:05:
+-                    aa:a0:d1:91:01:1f:ca:04:83:e3:58:1c:99:32:45:
+-                    84:70:72:58:03:98:4a:63:8b:41:f5:08:49:d2:91:
+-                    02:60:6b:e4:64:fe:dd:a0:aa:74:08:e9:34:4c:91:
+-                    5f:12:3d:37:4d:54:2c:ad:7f:5b:98:60:36:02:8c:
+-                    3b:f6:45:f3:27:6a:9b:94:9d
+-                Exponent: 65537 (0x10001)
+-        X509v3 extensions:
+-            X509v3 Basic Constraints: 
+-                CA:FALSE
+-            Netscape Comment: 
+-                OpenSSL Generated Certificate
+-            X509v3 Subject Key Identifier: 
+-                21:85:04:3D:23:01:66:E5:F7:9F:1A:84:24:8A:AF:0A:79:F4:E5:AC
+-            X509v3 Authority Key Identifier: 
+-                DirName:/C=NO/ST=Oslo/L=Nydalen/O=Nokia Corporation and/or its subsidiary(-ies)/OU=Development/CN=fluke.troll.no/emailAddress=ahanssen@trolltech.com
+-                serial:8E:A8:B4:E8:91:B7:54:2E
+-
+-    Signature Algorithm: sha1WithRSAEncryption
+-        6d:57:5f:d1:05:43:f0:62:05:ec:2a:71:a5:dc:19:08:f2:c4:
+-        a6:bd:bb:25:d9:ca:89:01:0e:e4:cf:1f:c1:8c:c8:24:18:35:
+-        53:59:7b:c0:43:b4:32:e6:98:b2:a6:ef:15:05:0b:48:5f:e1:
+-        a0:0c:97:a9:a1:77:d8:35:18:30:bc:a9:8f:d3:b7:54:c7:f1:
+-        a9:9e:5d:e6:19:bf:f6:3c:5b:2b:d8:e4:3e:62:18:88:8b:d3:
+-        24:e1:40:9b:0c:e6:29:16:62:ab:ea:05:24:70:36:aa:55:93:
+-        ef:02:81:1b:23:10:a2:04:eb:56:95:75:fc:f8:94:b1:5d:42:
+-        c5:3f:36:44:85:5d:3a:2e:90:46:8a:a2:b9:6f:87:ae:0c:15:
+-        40:19:31:90:fc:3b:25:bb:ae:f1:66:13:0d:85:90:d9:49:34:
+-        8f:f2:5d:f9:7a:db:4d:5d:27:f6:76:9d:35:8c:06:a6:4c:a3:
+-        b1:b2:b6:6f:1d:d7:a3:00:fd:72:eb:9e:ea:44:a1:af:21:34:
+-        7d:c7:42:e2:49:91:19:8b:c0:ad:ba:82:80:a8:71:70:f4:35:
+-        31:91:63:84:20:95:e9:60:af:64:8b:cc:ff:3d:8a:76:74:3d:
+-        c8:55:6d:e4:8e:c3:2b:1c:e8:42:18:ae:9f:e6:6b:9c:34:06:
+-        ec:6a:f2:c3
+ -----BEGIN CERTIFICATE-----
+-MIIEEzCCAvugAwIBAgIBADANBgkqhkiG9w0BAQUFADCBnDELMAkGA1UEBhMCTk8x
+-DTALBgNVBAgTBE9zbG8xEDAOBgNVBAcTB055ZGFsZW4xFjAUBgNVBAoTDVRyb2xs
+-dGVjaCBBU0ExFDASBgNVBAsTC0RldmVsb3BtZW50MRcwFQYDVQQDEw5mbHVrZS50
+-cm9sbC5ubzElMCMGCSqGSIb3DQEJARYWYWhhbnNzZW5AdHJvbGx0ZWNoLmNvbTAe
+-Fw0wNzEyMDQwMTEwMzJaFw0zNTA0MjEwMTEwMzJaMGMxCzAJBgNVBAYTAk5PMQ0w
+-CwYDVQQIEwRPc2xvMRYwFAYDVQQKEw1Ucm9sbHRlY2ggQVNBMRQwEgYDVQQLEwtE
+-ZXZlbG9wbWVudDEXMBUGA1UEAxMOZmx1a2UudHJvbGwubm8wgZ8wDQYJKoZIhvcN
+-AQEBBQADgY0AMIGJAoGBAKfIoErEGQUbZroy4tLxHG8XguQ5LgFRkNsENDIRIcIN
+-b1nYU5BUP4OPqdOz1e4am4CuwyXJXqWvS2AFqqDRkQEfygSD41gcmTJFhHByWAOY
+-SmOLQfUISdKRAmBr5GT+3aCqdAjpNEyRXxI9N01ULK1/W5hgNgKMO/ZF8ydqm5Sd
+-AgMBAAGjggEaMIIBFjAJBgNVHRMEAjAAMCwGCWCGSAGG+EIBDQQfFh1PcGVuU1NM
+-IEdlbmVyYXRlZCBDZXJ0aWZpY2F0ZTAdBgNVHQ4EFgQUIYUEPSMBZuX3nxqEJIqv
+-Cnn05awwgbsGA1UdIwSBszCBsKGBoqSBnzCBnDELMAkGA1UEBhMCTk8xDTALBgNV
+-BAgTBE9zbG8xEDAOBgNVBAcTB055ZGFsZW4xFjAUBgNVBAoTDVRyb2xsdGVjaCBB
+-U0ExFDASBgNVBAsTC0RldmVsb3BtZW50MRcwFQYDVQQDEw5mbHVrZS50cm9sbC5u
+-bzElMCMGCSqGSIb3DQEJARYWYWhhbnNzZW5AdHJvbGx0ZWNoLmNvbYIJAI6otOiR
+-t1QuMA0GCSqGSIb3DQEBBQUAA4IBAQBtV1/RBUPwYgXsKnGl3BkI8sSmvbsl2cqJ
+-AQ7kzx/BjMgkGDVTWXvAQ7Qy5piypu8VBQtIX+GgDJepoXfYNRgwvKmP07dUx/Gp
+-nl3mGb/2PFsr2OQ+YhiIi9Mk4UCbDOYpFmKr6gUkcDaqVZPvAoEbIxCiBOtWlXX8
+-+JSxXULFPzZEhV06LpBGiqK5b4euDBVAGTGQ/Dslu67xZhMNhZDZSTSP8l35ettN
+-XSf2dp01jAamTKOxsrZvHdejAP1y657qRKGvITR9x0LiSZEZi8CtuoKAqHFw9DUx
+-kWOEIJXpYK9ki8z/PYp2dD3IVW3kjsMrHOhCGK6f5mucNAbsavLD
++MIIF6zCCA9OgAwIBAgIUfo9amJtJGWqWE6f+SkAO85zkGr4wDQYJKoZIhvcNAQEL
++BQAwgYMxCzAJBgNVBAYTAk5PMQ0wCwYDVQQIDARPc2xvMQ0wCwYDVQQHDARPc2xv
++MRcwFQYDVQQKDA5UaGUgUXQgQ29tcGFueTEMMAoGA1UECwwDUiZEMRIwEAYDVQQD
++DAlIMiBUZXN0ZXIxGzAZBgkqhkiG9w0BCQEWDG1pbmltaUBxdC5pbzAgFw0yMDEw
++MjYxMjAxMzFaGA8yMTIwMTAwMjEyMDEzMVowgYMxCzAJBgNVBAYTAk5PMQ0wCwYD
++VQQIDARPc2xvMQ0wCwYDVQQHDARPc2xvMRcwFQYDVQQKDA5UaGUgUXQgQ29tcGFu
++eTEMMAoGA1UECwwDUiZEMRIwEAYDVQQDDAlIMiBUZXN0ZXIxGzAZBgkqhkiG9w0B
++CQEWDG1pbmltaUBxdC5pbzCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIB
++AOiUp5+E4blouKH7q+rVNR8NoYX2XkBW+q+rpy1zu5ssRSzbqxAjDx9dkht7Qlnf
++VlDT00JvpOWdeuPon5915edQRsY4Unl6mKH29ra3OtUa1/yCJXsGVJTKCj7k4Bxb
++5mZzb/fTlZntMLdTIBMfUbw62FKir1WjKIcJ9fCoG8JaGeKVO4Rh5p0ezd4UUUId
++r1BXl5Nqdqy2vTMsEDnjOsD3egkv8I2SKN4O6n/C3wWYpMOWYZkGoZiKz7rJs/i/
++ez7bsV7JlwdzTlhpJzkcOSVFBP6JlEOxTNNxZ1wtKy7PtZGmsSSATq2e6+bw38Ae
++Op0XnzzqcGjtDDofBmT7OFzZWjS9VZS6+DOOe2QHWle1nCHcHyH4ku6IRlsr9xkR
++NAIlOfnvHHxqJUenoeaZ4oQDjCBKS1KXygJO/tL7BLTQVn/xK1EmPvKNnjzWk4tR
++PnibUhhs5635qpOU/YPqFBh1JjVruZbsWcDAhRcew0uxONXOa9E+4lttQ9ySYa1A
++LvWqJuAX7gu2BsBMLyqfm811YnA7CIFMyO+HlqmkLFfv5L/xIRAXR7l26YGO0VwX
++CGjMfz4NVPMMke4nB7qa9NkpXQBQKMms3Qzd5JW0Hy9Ruj5O8GPcFZmV0twjd1uJ
++PD/cAjkWLaXjdNsJ16QWc2nghQRS6HYqKRX6j+CXOxupAgMBAAGjUzBRMB0GA1Ud
++DgQWBBRSCOU58j9NJZkMamt623qyCrhN3TAfBgNVHSMEGDAWgBRSCOU58j9NJZkM
++amt623qyCrhN3TAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4ICAQCq
++q4jxsWeNDv5Nq14hJtF9HB+ZL64zcZtRjJP1YgNs0QppKICmjPOL2nIMGmI/jKrs
++0eGAL/9XXNVHPxm1OPOncvimMMmU6emZfpMdEtTfKP43+Pg9HgKRjLoQp406vGeQ
++8ki/mbBhrItVPgEm3tu2AFA02XTYi+YxCI9kRZLGkM3FbgtOuTLPl0Z9y+kiPc9F
++uCSC03anBEqv+vDSI8+wODymQ/IJ3Jyz1lxIRDfp4qAekmy0jU2c91VOHHEmOmqq
++kqygGFRdwbe99m9yP63r6q0b5K3X2UnJ6bns0hmTwThYwpVPXLU8jdaTddbMukN2
++/Ef96Tsw8nWOEOPMySHOTIPgwyZRp26b0kA9EmhLwOP401SxXVQCmSRmtwNagmtg
++jJKmZoYBN+//D45ibK8z6Q0oOm9P+Whf/uUXehcRxBxyV3xz7k0wKGQbHj/ddwcy
++IUoIN4lrAlib+lK170kTKN352PDmrpo2gmIzPEsfurKAIMSelDl6H+kih16BtZ8y
++Nz6fh9Soqrg3OSAware8pxV7k51crBMoPLN78KoRV8MFCK4K7Fddq4rRISq6hiXq
++r1nsjoEPuKM9huprmZVZe9t5YcDa2I+wb3IiE3uwpZbAdaLDyQ5n6F/qpsiIkZXn
++gtcF7oqpG5oYrwCcZ53y/ezUgUg7PlSz2XwAGvQtgg==
+ -----END CERTIFICATE-----
+diff --git a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
+index 9d1664d609..337ce541a6 100644
+--- a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
++++ b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
+@@ -1,15 +1,52 @@
+------BEGIN RSA PRIVATE KEY-----
+-MIICXAIBAAKBgQCnyKBKxBkFG2a6MuLS8RxvF4LkOS4BUZDbBDQyESHCDW9Z2FOQ
+-VD+Dj6nTs9XuGpuArsMlyV6lr0tgBaqg0ZEBH8oEg+NYHJkyRYRwclgDmEpji0H1
+-CEnSkQJga+Rk/t2gqnQI6TRMkV8SPTdNVCytf1uYYDYCjDv2RfMnapuUnQIDAQAB
+-AoGANFzLkanTeSGNFM0uttBipFT9F4a00dqHz6JnO7zXAT26I5r8sU1pqQBb6uLz
+-/+Qz5Zwk8RUAQcsMRgJetuPQUb0JZjF6Duv24hNazqXBCu7AZzUenjafwmKC/8ri
+-KpX3fTwqzfzi//FKGgbXQ80yykSSliDL3kn/drATxsLCgQECQQDXhEFWLJ0vVZ1s
+-1Ekf+3NITE+DR16X+LQ4W6vyEHAjTbaNWtcTKdAWLA2l6N4WAAPYSi6awm+zMxx4
+-VomVTsjdAkEAx0z+e7natLeFcrrq8pbU+wa6SAP1VfhQWKitxL1e7u/QO90NCpxE
+-oQYKzMkmmpOOFjQwEMAy1dvFMbm4LHlewQJAC/ksDBaUcQHHqjktCtrUb8rVjAyW
+-A8lscckeB2fEYyG5J6dJVaY4ClNOOs5yMDS2Afk1F6H/xKvtQ/5CzInA/QJATDub
+-K+BPU8jO9q+gpuIi3VIZdupssVGmCgObVCHLakG4uO04y9IyPhV9lA9tALtoIf4c
+-VIvv5fWGXBrZ48kZAQJBAJmVCdzQxd9LZI5vxijUCj5EI4e+x5DRqVUvyP8KCZrC
+-AiNyoDP85T+hBZaSXK3aYGpVwelyj3bvo1GrTNwNWLw=
+------END RSA PRIVATE KEY-----
++-----BEGIN PRIVATE KEY-----
++MIIJQgIBADANBgkqhkiG9w0BAQEFAASCCSwwggkoAgEAAoICAQDolKefhOG5aLih
+++6vq1TUfDaGF9l5AVvqvq6ctc7ubLEUs26sQIw8fXZIbe0JZ31ZQ09NCb6TlnXrj
++6J+fdeXnUEbGOFJ5epih9va2tzrVGtf8giV7BlSUygo+5OAcW+Zmc2/305WZ7TC3
++UyATH1G8OthSoq9VoyiHCfXwqBvCWhnilTuEYeadHs3eFFFCHa9QV5eTanastr0z
++LBA54zrA93oJL/CNkijeDup/wt8FmKTDlmGZBqGYis+6ybP4v3s+27FeyZcHc05Y
++aSc5HDklRQT+iZRDsUzTcWdcLSsuz7WRprEkgE6tnuvm8N/AHjqdF5886nBo7Qw6
++HwZk+zhc2Vo0vVWUuvgzjntkB1pXtZwh3B8h+JLuiEZbK/cZETQCJTn57xx8aiVH
++p6HmmeKEA4wgSktSl8oCTv7S+wS00FZ/8StRJj7yjZ481pOLUT54m1IYbOet+aqT
++lP2D6hQYdSY1a7mW7FnAwIUXHsNLsTjVzmvRPuJbbUPckmGtQC71qibgF+4LtgbA
++TC8qn5vNdWJwOwiBTMjvh5appCxX7+S/8SEQF0e5dumBjtFcFwhozH8+DVTzDJHu
++Jwe6mvTZKV0AUCjJrN0M3eSVtB8vUbo+TvBj3BWZldLcI3dbiTw/3AI5Fi2l43Tb
++CdekFnNp4IUEUuh2KikV+o/glzsbqQIDAQABAoICAFw1q6tr5I48vY7DF+rXsuLn
++5ZUWE1IQ6fzB4lr72nJv/9EEGnMgYzt9PpMUsD6vdCpBgS2C0+6RHArFzJtNA+RM
++iHLIG7K7702veyr/xBx/MwiSlMeMv/XpkFxVI6E6skMGG2s3AMXxKvJTy5CpRx+I
++eQFyLG+Ya1X2lgJes/q+/CpAHkOjCOpcLySQC5NZ74q734V7nSdmn+Zs3tYEh+O/
++eiuwTP/j5b38Te5vVTqDxTciJPmljmXLCwa0N100lWlbcpvw8qbqiTI2Jm3XCbUE
++AzHjW9vmrF3cRS1fXxKFGShw3SRqlkbxjfeWoi8qDPUBS4m8LOr8qG9Wo5Nfon0z
++zLP4bci3zHDvVcaaZrrsUBs/yZbg+Dgka1DmX7ekmeccr2yTdKDFgPupYUyxVbTl
++a9ZLJysjFD7rgBv1ZclHonLp6Vbm+ZoTqvteo4ikAy6L9RtBWJ23XEK34PkP/+c5
++2vWZaOrnjSeBHbFce8cdJSxqWpP+eSCI5I9XbDrYFIsQ/gqKgtzDKy2ihJ2Y8STL
++yO4hyFPFjxc+Gg4/P2PpmT5CY2ty44M0BWs+JGW96CJPrrplf2lmQUQJj5LZY66X
++Z/4C9L7ZYtKZ+bs5SvU46yWugAvQZX22Xm9xLXWyVXRdx3bj+3M3fDnF9di/zdbh
++CgLx7oWPNrXc7FCajnn9AoIBAQD5FMYwRpw9NWT9WDxQwx+cSI4Icbd88ByTW63S
++LzeRwZA0J9/SfwO+aBRupzc9GkGXCiZcGMw3AGsCtig8yFlw8E5KnzN7KlftDMnM
++9NUxxzlR8VwKyLnZfG7sDTl057ZlUujnqhmt/F8F7dIy7FVO1dE/8nngA+FYTCOG
++UZdGjwyBDlDM0JJdUWGY3xslutcpCDN5mzSTKjy9drMvImAshRawxRF6WBpn7vr2
++nC6vciqfx1Mzx1vyk0Jm0ilaydDdLMADjt/iL4Nkr0BEs4k+UzQiKDwp8gu7abQ1
++eBfxd9Iar4htQa2I1Ewl6P01G/q+ZYwgHhJ9RVn4AxQXefILAoIBAQDvCouORdQX
++C8wsyp7MwXlF/3NQeNN5/+B2mhbxrBOf7PmMCXLnkRWcjwJtzypWFqJ0sqai/2+0
++bqbMcjX5maT8stT2shl3zXe/Ejt2e3TBYpc1tyuses8Kb5BMU8hu6tTd3G2CMXpD
++dT6DVemJZCTtwj9aBNIxSizvlgMolJnCpzhPnlfHSI6E+g3m/LTTo3HwbjMSw/Uq
++irgjOpI2wSBB6LZPSgjvfcYPRyWUk16L4A5uSX0cADnovDFLa5/h0wJvN/OoCSQg
++rLCXG5E18EyL5Wc58BCY1ZvxmjG3lQtgPxYu2Jwc36R/y/JKlxW5suER5ZNpbbD4
++uOyTt2VxMQ2bAoIBAQC5+MzRFqdo/AjfL5Y5JrbfVTzXCTDa09xCGd16ZU60QTWN
+++4ed/r+o1sUKqUcRFB2MzEM/2DQBjQpZB/CbEWvWa1XJWXxypXbowveZU+QqOnmN
++uQvj8WLyA3o+PNF9e9QvauwCrHpn8VpxbtPWuaYoKnUFreFZZQxHhPGxRBIS2JOZ
++eDrT8ZaWnkCkh1AZp5smQ71LOprSlmKrg4jd1GjCVMxQR5N5KXbtyv0OTCZ/UFqK
++2aRBsMPyJgkaBChkZPLRcKwc+/wlQRx1fHQb14DNTApMxoXFO7eOwqmOkpAt9iyl
++SBIwoS0UUI5ab88+bBmXNvKcuFdNuQ4nowTJUn9pAoIBADMNkILBXSvS5DeIyuO2
++Sp1tkoZUV+5NfPY3sMDK3KIibaW/+t+EOBZo4L7tKQCb8vRzl21mmsfxfgRaPDbj
++3r3tv9g0b4YLxxBy52pFscj/soXRai17SS7UZwA2QK+XzgDYbDcLNC6mIsTQG4Gx
++dsWk3/zs3KuUSQaehmwrWK+fIUK38c1pLK8v7LoxrLkqxlHwZ04RthHw8KTthH7X
++Pnl1J0LF8CSeOyfWLSuPUfkT0GEzptnNHpEbaHfQM6R6eaGhVJPF6AZme4y6YYgg
++m2ihhSt1n0XVEWpHYWjxFy3mK2mz75unFC4LM+NEY2p2zuUQoCw7NjnY3QYrfCnx
++rRMCggEAXeXsMSLFjjyuoL7iKbAxo52HD/P0fBoy58LyRcwfNVr0lvYan4pYEx+o
++KijIh9K16PqXZXKMA9v003B+ulmF8bJ7SddCZ5NGvnFhUTDe4DdTKgp2RuwQ3Bsc
++3skPIDbhVETyOLCtys34USHrq8U/0DlGY3eLRfxw9GnbKxSBGa/KEu/qQLPNUo50
++7xHZDg7GKeC3kqNJeqKM9rkp0VzIGkEnaD9127LeNDmERDfftxJzFoC/THvUBLfU
++6Sus2ZYwRE8VFvKC30Q45t/c54X3IuhYvAuiCuTmyfE4ruyzyOwKzhUkeeLq1APX
++g0veFbyfzlJ0q8qzD/iffqqIa2ZSmQ==
++-----END PRIVATE KEY-----
+diff --git a/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp b/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
+index 7ba3715e13..752aa122f6 100644
+--- a/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
++++ b/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
+@@ -179,6 +179,7 @@ void tst_QAccessibilityLinux::initTestCase()
+     QVERIFY(!address.isEmpty());
+ 
+     m_window = new AccessibleTestWindow();
++    m_window->setObjectName("mainWindow"_L1);
+     m_window->show();
+ 
+     QVERIFY(QTest::qWaitForWindowExposed(m_window));
+@@ -236,8 +237,11 @@ bool hasState(QDBusInterface *interface, AtspiStateType state)
+ void tst_QAccessibilityLinux::testLabel()
+ {
+     QLabel *l = new QLabel(m_window);
++    l->setObjectName("theObjectName"_L1);
+     l->setText("Hello A11y");
+     m_window->addWidget(l);
++    auto a11yEmpty = new QLabel(m_window);
++    m_window->addWidget(l);
+ 
+     // Application
+     QCOMPARE(getParent(mainWindow), QLatin1String(ATSPI_DBUS_PATH_ROOT));
+@@ -249,6 +253,8 @@ void tst_QAccessibilityLinux::testLabel()
+     QCOMPARE(getChildren(labelInterface).count(), 0);
+     QCOMPARE(labelInterface->call(QDBus::Block, "GetRoleName").arguments().first().toString(), QLatin1String("label"));
+     QCOMPARE(labelInterface->call(QDBus::Block, "GetRole").arguments().first().toUInt(), 29u);
++    QCOMPARE(labelInterface->call(QDBus::Block, "GetAccessibleId").arguments().first().toString(),
++             QLatin1String("mainWindow.theObjectName"));
+     QCOMPARE(getParent(labelInterface), mainWindow->path());
+     QVERIFY(!hasState(labelInterface, ATSPI_STATE_EDITABLE));
+     QVERIFY(hasState(labelInterface, ATSPI_STATE_READ_ONLY));
+@@ -256,7 +262,12 @@ void tst_QAccessibilityLinux::testLabel()
+     l->setText("New text");
+     QCOMPARE(labelInterface->property("Name").toString(), l->text());
+ 
++    auto *a11yEmptyInterface = getInterface(children.at(1), "org.a11y.atspi.Accessible");
++    QCOMPARE(a11yEmptyInterface->call(QDBus::Block, "GetAccessibleId").arguments().first().toString(),
++             QLatin1String("mainWindow.QLabel"));
++
+     m_window->clearChildren();
++    delete a11yEmptyInterface;
+     delete labelInterface;
+ }
+ 
+diff --git a/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+index 76df61c892..6d6d65b791 100644
+--- a/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
++++ b/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2022 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the test suite of the Qt Toolkit.
+@@ -68,6 +68,8 @@ private slots:
+     void query_exec();
+     void execErrorRecovery_data() { generic_data(); }
+     void execErrorRecovery();
++    void prematureExec_data() { generic_data(); }
++    void prematureExec();
+     void first_data() { generic_data(); }
+     void first();
+     void next_data() { generic_data(); }
+@@ -2770,6 +2772,35 @@ void tst_QSqlQuery::execErrorRecovery()
+     QVERIFY_SQL( q, exec() );
+ }
+ 
++void tst_QSqlQuery::prematureExec()
++{
++    QFETCH(QString, dbName);
++    // We only want the engine name, for addDatabase():
++    int cut = dbName.indexOf(QChar('@'));
++    if (cut < 0)
++        QSKIP("Failed to parse database type out of name");
++    dbName.truncate(cut);
++    cut = dbName.indexOf(QChar('_'));
++    if (cut >= 0)
++        dbName = dbName.mid(cut + 1);
++
++    auto db = QSqlDatabase::addDatabase(dbName);
++    QSqlQuery q(db);
++
++    QTest::ignoreMessage(QtWarningMsg,
++                         "QSqlDatabasePrivate::removeDatabase: connection "
++                         "'qt_sql_default_connection' is still in use, all "
++                         "queries will cease to work.");
++    QTest::ignoreMessage(QtWarningMsg,
++                         "QSqlDatabasePrivate::addDatabase: duplicate connection name "
++                         "'qt_sql_default_connection', old connection removed.");
++    auto otherDb = QSqlDatabase::addDatabase(dbName);
++
++    QTest::ignoreMessage(QtWarningMsg, "QSqlQuery::exec: called before driver has been set up");
++    // QTBUG-100037: shouldn't crash !
++    QVERIFY(!q.exec("select stuff from TheVoid"));
++}
++
+ void tst_QSqlQuery::lastInsertId()
+ {
+     QFETCH( QString, dbName );
+diff --git a/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp b/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
+index 4aa3f8d60b..d2050a61aa 100644
+--- a/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
++++ b/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
+@@ -115,6 +115,10 @@ void tst_QAbstractItemModelTester::standardItemModelZeroColumns()
+     // QTBUG-92886
+     model.insertRows(0, 5);
+     model.removeRows(1, 2);
++
++    const QModelIndex parentIndex = model.index(0, 0);
++    model.insertRows(0, 5, parentIndex);
++    model.removeRows(1, 2, parentIndex);
+ }
+ 
+ void tst_QAbstractItemModelTester::testInsertThroughProxy()
+diff --git a/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json b/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
+index 12a4a22a19..ce518e78fb 100644
+--- a/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
++++ b/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
+@@ -668,50 +668,6 @@
+         "inputFile": "task192552.h",
+         "outputRevision": 67
+     },
+-    {
+-        "classes": [
+-            {
+-                "className": "InlineSlotsWithThrowDeclaration",
+-                "object": true,
+-                "qualifiedClassName": "InlineSlotsWithThrowDeclaration",
+-                "slots": [
+-                    {
+-                        "access": "public",
+-                        "name": "a",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "b",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "c",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "d",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "e",
+-                        "returnType": "void"
+-                    }
+-                ],
+-                "superClasses": [
+-                    {
+-                        "access": "public",
+-                        "name": "QObject"
+-                    }
+-                ]
+-            }
+-        ],
+-        "inputFile": "task189996.h",
+-        "outputRevision": 67
+-    },
+     {
+         "classes": [
+             {
+diff --git a/qtbase/tests/auto/tools/moc/moc.pro b/qtbase/tests/auto/tools/moc/moc.pro
+index c324b3a8cd..4aceb78dc0 100644
+--- a/qtbase/tests/auto/tools/moc/moc.pro
++++ b/qtbase/tests/auto/tools/moc/moc.pro
+@@ -15,7 +15,7 @@ cross_compile: DEFINES += MOC_CROSS_COMPILED
+ HEADERS += using-namespaces.h no-keywords.h task87883.h c-comments.h backslash-newlines.h oldstyle-casts.h \
+            slots-with-void-template.h qinvokable.h namespaced-flags.h trigraphs.h \
+            escapes-in-string-literals.h cstyle-enums.h qprivateslots.h gadgetwithnoenums.h \
+-           dir-in-include-path.h single_function_keyword.h task192552.h task189996.h \
++           dir-in-include-path.h single_function_keyword.h task192552.h \
+            task234909.h task240368.h pure-virtual-signals.h cxx11-enums.h \
+            cxx11-final-classes.h \
+            cxx11-explicit-override-control.h \
+diff --git a/qtbase/tests/auto/tools/moc/task189996.h b/qtbase/tests/auto/tools/moc/task189996.h
+deleted file mode 100644
+index f94a051b3a..0000000000
+--- a/qtbase/tests/auto/tools/moc/task189996.h
++++ /dev/null
+@@ -1,47 +0,0 @@
+-/****************************************************************************
+-**
+-** Copyright (C) 2016 The Qt Company Ltd.
+-** Contact: https://www.qt.io/licensing/
+-**
+-** This file is part of the test suite of the Qt Toolkit.
+-**
+-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+-** 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 General Public License Usage
+-** Alternatively, this file may be used under the terms of the GNU
+-** General Public License version 3 as published by the Free Software
+-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+-** 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-3.0.html.
+-**
+-** $QT_END_LICENSE$
+-**
+-****************************************************************************/
+-// inline functions can have throw declarations
+-
+-#ifndef TASK189996_H
+-#define TASK189996_H
+-
+-#include <QObject>
+-
+-class InlineSlotsWithThrowDeclaration : public QObject
+-{
+-    Q_OBJECT
+-
+-public slots:
+-    void a() throw() { }
+-    void b() const throw() { }
+-    void c() throw();
+-    void d() throw(int) { }
+-    void e() const throw(int,double) { }
+-};
+-
+-#endif
+diff --git a/qtbase/tests/auto/tools/moc/tst_moc.cpp b/qtbase/tests/auto/tools/moc/tst_moc.cpp
+index c716aead21..15dd9e41e5 100644
+--- a/qtbase/tests/auto/tools/moc/tst_moc.cpp
++++ b/qtbase/tests/auto/tools/moc/tst_moc.cpp
+@@ -631,7 +631,6 @@ public:
+ private slots:
+     void initTestCase();
+ 
+-    void slotWithException() throw(MyStruct);
+     void dontStripNamespaces();
+     void oldStyleCasts();
+     void warnOnExtraSignalSlotQualifiaction();
+@@ -673,7 +672,6 @@ private slots:
+     void templateGtGt();
+     void qprivateslots();
+     void qprivateproperties();
+-    void inlineSlotsWithThrowDeclaration();
+     void warnOnPropertyWithoutREAD();
+     void constructors();
+     void typenameWithUnsigned();
+@@ -784,12 +782,6 @@ void tst_Moc::initTestCase()
+ #endif
+ }
+ 
+-void tst_Moc::slotWithException() throw(MyStruct)
+-{
+-    // be happy
+-    QVERIFY(true);
+-}
+-
+ void tst_Moc::dontStripNamespaces()
+ {
+     Sender sender;
+@@ -824,7 +816,7 @@ void tst_Moc::oldStyleCasts()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-Wold-style-cast" << "-I" << "."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -894,7 +886,7 @@ void tst_Moc::inputFileNameWithDotsButNoExtension()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-I" << ".."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -1174,7 +1166,7 @@ void tst_Moc::ignoreOptionClashes()
+     QStringList gccArgs;
+     gccArgs << "-c" << "-x" << "c++" << "-I" << ".."
+          << "-I" << qtIncludePath << "-I" << includeDir << "-o" << "/dev/null"
+-         << "-fPIC" << "-std=c++11" <<  "-";
++         << "-fPIC" << "-std=c++1z" <<  "-";
+     proc.start("gcc", gccArgs);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -1593,21 +1585,6 @@ void tst_Moc::qprivateproperties()
+ 
+ }
+ 
+-#include "task189996.h"
+-
+-void InlineSlotsWithThrowDeclaration::c() throw() {}
+-
+-void tst_Moc::inlineSlotsWithThrowDeclaration()
+-{
+-    InlineSlotsWithThrowDeclaration tst;
+-    const QMetaObject *mobj = tst.metaObject();
+-    QVERIFY(mobj->indexOfSlot("a()") != -1);
+-    QVERIFY(mobj->indexOfSlot("b()") != -1);
+-    QVERIFY(mobj->indexOfSlot("c()") != -1);
+-    QVERIFY(mobj->indexOfSlot("d()") != -1);
+-    QVERIFY(mobj->indexOfSlot("e()") != -1);
+-}
+-
+ void tst_Moc::warnOnPropertyWithoutREAD()
+ {
+ #ifdef MOC_CROSS_COMPILED
+@@ -1869,7 +1846,7 @@ void tst_Moc::notifyError()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-I" << "."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+diff --git a/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+index c355ee9665..88c09de8e0 100644
+--- a/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
++++ b/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+@@ -251,6 +251,7 @@ private slots:
+     void testResetCachedSizeHint();
+     void statusTips();
+     void testRemovingColumnsViaLayoutChanged();
++    void testModelMovingColumns();
+ 
+ protected:
+     void setupTestData(bool use_reset_model = false);
+@@ -360,6 +361,12 @@ public:
+         endRemoveColumns();
+     }
+ 
++    void moveColumn(int from, int to)
++    {
++        beginMoveColumns(QModelIndex(), from, from, QModelIndex(), to);
++        endMoveColumns();
++    }
++
+     void cleanup()
+     {
+         emit layoutAboutToBeChanged();
+@@ -3627,5 +3634,18 @@ void tst_QHeaderView::testRemovingColumnsViaLayoutChanged()
+     // The main point of this test is that the section-size restoring code didn't go out of bounds.
+ }
+ 
++void tst_QHeaderView::testModelMovingColumns()
++{
++    QtTestModel model(10, 10);
++    QHeaderView hv(Qt::Horizontal);
++    hv.setModel(&model);
++    hv.resizeSections(QHeaderView::ResizeToContents);
++    hv.show();
++
++    QPersistentModelIndex index3 = model.index(0, 3);
++    model.moveColumn(3, 1);
++    QCOMPARE(index3.column(), 1);
++}
++
+ QTEST_MAIN(tst_QHeaderView)
+ #include "tst_qheaderview.moc"
+diff --git a/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+index 761357b252..06bb706074 100644
+--- a/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
++++ b/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+@@ -397,6 +397,7 @@ private slots:
+     void checkHeaderMinSize();
+ 
+     void resizeToContents();
++    void resizeToContentsSpans();
+ 
+     void tabFocus();
+     void bigModel();
+@@ -3721,6 +3722,70 @@ void tst_QTableView::resizeToContents()
+ 
+ }
+ 
++
++class SpanModel : public QAbstractTableModel
++{
++public:
++    SpanModel(bool sectionsMoved)
++        : _sectionsMoved(sectionsMoved)
++    {}
++    int columnCount(const QModelIndex & = {}) const override { return 2; }
++    int rowCount(const QModelIndex & = {}) const override { return 1; }
++    QVariant data(const QModelIndex &idx, int role = Qt::DisplayRole) const override
++    {
++        if (role != Qt::DisplayRole)
++            return QVariant();
++        const int col = _sectionsMoved ? 1 - idx.column() : idx.column();
++        if (col == 0)
++            return "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.";
++        return QVariant();
++    }
++private:
++    bool _sectionsMoved;
++};
++
++
++void tst_QTableView::resizeToContentsSpans()
++{
++    SpanModel model1(false);
++    SpanModel model2(true);
++    QTableView view1, view2, view3;
++    view1.setModel(&model1);
++    view2.setModel(&model2);
++    view2.horizontalHeader()->moveSection(0, 1);
++    view3.setModel(&model1);
++
++    view1.setSpan(0, 0, 1, 2);
++    view2.setSpan(0, 1, 1, 2);
++    view1.show();
++    view2.show();
++    view3.show();
++    QVERIFY(QTest::qWaitForWindowExposed(&view1));
++    QVERIFY(QTest::qWaitForWindowExposed(&view2));
++    QVERIFY(QTest::qWaitForWindowExposed(&view3));
++    view1.setColumnWidth(0, 100);
++    view1.setColumnWidth(1, 100);
++    view2.setColumnWidth(0, 100);
++    view2.setColumnWidth(1, 100);
++    view3.setColumnWidth(0, 200);
++
++    view1.resizeRowToContents(0);
++    view2.resizeRowToContents(0);
++    view3.resizeRowToContents(0);
++    QCOMPARE(view1.rowHeight(0), view3.rowHeight(0));
++    QCOMPARE(view2.rowHeight(0), view3.rowHeight(0));
++
++    view3.resizeColumnToContents(0);
++    view3.resizeRowToContents(0);
++    // height should be only 1 text line for easy testing
++    view1.setRowHeight(0, view3.verticalHeader()->sectionSize(0));
++    view2.setRowHeight(0, view3.verticalHeader()->sectionSize(0));
++    view1.resizeColumnToContents(0);
++    view2.resizeColumnToContents(1);
++    QCOMPARE(view1.columnWidth(0), view3.columnWidth(0) - view1.columnWidth(1));
++    QCOMPARE(view2.columnWidth(0), view3.columnWidth(0) - view2.columnWidth(1));
++}
++
+ QT_BEGIN_NAMESPACE
+ extern bool Q_WIDGETS_EXPORT qt_tab_all_widgets(); // qapplication.cpp
+ QT_END_NAMESPACE
+diff --git a/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+index a3b8ef78d8..4955cebd5d 100644
+--- a/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
++++ b/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+@@ -1498,7 +1498,7 @@ void tst_QApplication::desktopSettingsAware()
+     environment += QLatin1String("QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM=1");
+     testProcess.setEnvironment(environment);
+ #endif
+-    testProcess.start("desktopsettingsaware_helper");
++    testProcess.start("./desktopsettingsaware_helper");
+     QVERIFY2(testProcess.waitForStarted(),
+              qPrintable(QString::fromLatin1("Cannot start 'desktopsettingsaware_helper': %1").arg(testProcess.errorString())));
+     QVERIFY(testProcess.waitForFinished(10000));
+@@ -2452,7 +2452,7 @@ void tst_QApplication::qtbug_12673()
+ #if QT_CONFIG(process)
+     QProcess testProcess;
+     QStringList arguments;
+-    testProcess.start("modal_helper", arguments);
++    testProcess.start("./modal_helper", arguments);
+     QVERIFY2(testProcess.waitForStarted(),
+              qPrintable(QString::fromLatin1("Cannot start 'modal_helper': %1").arg(testProcess.errorString())));
+     QVERIFY(testProcess.waitForFinished(20000));
+diff --git a/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp b/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
+index eb108a40de..dca5528c1b 100644
+--- a/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
+@@ -41,6 +41,7 @@
+ 
+ #include <private/qguiapplication_p.h>
+ #include <qpa/qplatformintegration.h>
++#include <qpa/qplatformtheme.h>
+ 
+ class tst_QAbstractButton : public QObject
+ {
+@@ -76,6 +77,8 @@ private slots:
+     void keyNavigation();
+ #endif
+ 
++    void buttonPressKeys();
++
+ protected slots:
+     void onClicked();
+     void onToggled( bool on );
+@@ -269,7 +272,13 @@ void tst_QAbstractButton::setAutoRepeat()
+         QCOMPARE(press_count, click_count);
+         QVERIFY(click_count > 1);
+         break;
+-    case 4:
++    case 4: {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(Qt::Key_Enter)) {
++            QSKIP("platform theme has Key_Enter in ButtonPressKeys");
++        }
+         // check that pressing ENTER has no effect when autorepeat is false
+         testWidget->setDown( false );
+         testWidget->setAutoRepeat( false );
+@@ -286,7 +295,14 @@ void tst_QAbstractButton::setAutoRepeat()
+ 
+         QVERIFY( click_count == 0 );
+         break;
+-    case 5:
++    }
++    case 5: {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(Qt::Key_Enter)) {
++            QSKIP("platform theme has Key_Enter in ButtonPressKeys");
++        }
+         // check that pressing ENTER has no effect when autorepeat is true
+         testWidget->setDown( false );
+         testWidget->setAutoRepeat( true );
+@@ -304,6 +320,7 @@ void tst_QAbstractButton::setAutoRepeat()
+ 
+         QVERIFY( click_count == 0 );
+         break;
++    }
+     case 6:
+         // verify autorepeat is off by default.
+         MyButton tmp( 0);
+@@ -651,5 +668,16 @@ void tst_QAbstractButton::keyNavigation()
+ }
+ #endif
+ 
++void tst_QAbstractButton::buttonPressKeys()
++{
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(testWidget, buttonPressKeys[i]);
++        QCOMPARE(click_count, i + 1);
++    }
++}
++
+ QTEST_MAIN(tst_QAbstractButton)
+ #include "tst_qabstractbutton.moc"
+diff --git a/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+index 32437050f5..46b5af6d63 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+@@ -168,6 +168,7 @@ private slots:
+     void checkMenuItemPosWhenStyleSheetIsSet();
+     void checkEmbeddedLineEditWhenStyleSheetIsSet();
+     void propagateStyleChanges();
++    void buttonPressKeys();
+ 
+ private:
+     PlatformInputContext m_platformInputContext;
+@@ -1682,6 +1683,16 @@ void tst_QComboBox::setModel()
+     QCOMPARE(box.rootModelIndex(), rootModelIndex);
+     box.setModel(box.model());
+     QCOMPARE(box.rootModelIndex(), rootModelIndex);
++
++    // check that setting the same model as the completer's doesn't crash
++    QCompleter *completer = new QCompleter(&box);
++    box.setEditable(true);
++    box.setCompleter(completer);
++    auto *listModel = new QStringListModel({ "one", "two" }, completer);
++    completer->setModel(listModel);
++    QCOMPARE(listModel->rowCount(), 2); // make sure it wasn't deleted
++    box.setModel(listModel);
++    QCOMPARE(listModel->rowCount(), 2); // make sure it wasn't deleted
+ }
+ 
+ void tst_QComboBox::setCustomModelAndView()
+@@ -3632,5 +3643,24 @@ void tst_QComboBox::propagateStyleChanges()
+     QVERIFY(frameStyle.inquired);
+ }
+ 
++void tst_QComboBox::buttonPressKeys()
++{
++    QComboBox comboBox;
++    comboBox.setEditable(false);
++    comboBox.addItem(QString::number(1));
++    comboBox.addItem(QString::number(2));
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(&comboBox, buttonPressKeys[i]);
++        // On some platforms, a window will not be immediately visible,
++        // but take some event-loop iterations to complete.
++        // Using QTRY_VERIFY to deal with that.
++        QTRY_VERIFY(comboBox.view()->isVisible());
++        comboBox.hidePopup();
++    }
++}
++
+ QTEST_MAIN(tst_QComboBox)
+ #include "tst_qcombobox.moc"
+diff --git a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
+index be3cfcd104..c228fdfcca 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
++++ b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qcommandlinkbutton
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qcommandlinkbutton.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
+index 0044d33c66..4cf06296e4 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
+@@ -40,6 +40,9 @@
+ #include <QGridLayout>
+ #include <QPainter>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ class tst_QCommandLinkButton : public QObject
+ {
+     Q_OBJECT
+@@ -223,6 +226,13 @@ void tst_QCommandLinkButton::setAutoRepeat()
+     // check that pressing ENTER has no effect
+     resetCounters();
+     testWidget->setDown( false );
++    // Skip after reset if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
+     testWidget->setAutoRepeat( false );
+     QTest::keyPress( testWidget, Qt::Key_Enter );
+ 
+@@ -255,6 +265,14 @@ void tst_QCommandLinkButton::pressed()
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+ 
++    // Skip if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
++
+     QTest::keyPress( testWidget,Qt::Key_Enter );
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+diff --git a/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro b/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
+index 4a5e76ff65..a235fa1fac 100644
+--- a/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
++++ b/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qgroupbox
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qgroupbox.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp b/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
+index 4fb5d262ca..d8d7562b73 100644
+--- a/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
+@@ -35,6 +35,9 @@
+ #include <QRadioButton>
+ #include <QDialog>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ #include "qgroupbox.h"
+ 
+ class tst_QGroupBox : public QObject
+@@ -69,6 +72,7 @@ private slots:
+     void propagateFocus();
+     void task_QTBUG_19170_ignoreMouseReleaseEvent();
+     void task_QTBUG_15519_propagateMouseEvents();
++    void buttonPressKeys();
+ 
+ private:
+     bool checked;
+@@ -610,6 +614,20 @@ void tst_QGroupBox::task_QTBUG_15519_propagateMouseEvents()
+     QCOMPARE(parent.mouseMoved, true);
+ }
+ 
++void tst_QGroupBox::buttonPressKeys()
++{
++    QGroupBox groupBox;
++    groupBox.setCheckable(true);
++    QSignalSpy clickedSpy(&groupBox, &QGroupBox::clicked);
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(&groupBox, buttonPressKeys[i]);
++        QCOMPARE(clickedSpy.length(), i + 1);
++    }
++}
++
+ void tst_QGroupBox::sendMouseMoveEvent(QWidget *widget, const QPoint &localPos)
+ {
+     // Send a MouseMove event without actually moving the pointer
+diff --git a/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro b/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
+index 353ad06ca2..e55f6148f2 100644
+--- a/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
++++ b/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qpushbutton
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qpushbutton.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp b/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
+index e818514a79..4043e9326a 100644
+--- a/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
+@@ -41,6 +41,9 @@
+ #include <QStyleFactory>
+ #include <QTabWidget>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ class tst_QPushButton : public QObject
+ {
+ Q_OBJECT
+@@ -212,6 +215,13 @@ void tst_QPushButton::autoRepeat()
+     // check that pressing ENTER has no effect
+     resetCounters();
+     testWidget->setDown( false );
++    // Skip after reset if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
+     testWidget->setAutoRepeat( false );
+     QTest::keyPress( testWidget, Qt::Key_Enter );
+ 
+@@ -247,6 +257,14 @@ void tst_QPushButton::pressed()
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+ 
++    // Skip if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
++
+     QTest::keyPress( testWidget,Qt::Key_Enter );
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+diff --git a/qtbase/tests/manual/rhi/cubemap_render/buildshader.bat b/qtbase/tests/manual/rhi/cubemap_render/buildshader.bat
+old mode 100755
+new mode 100644
+Submodule qtconnectivity e957d481..056294c0:
+diff --git a/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp b/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
+index e2635fae..a8b8e3b9 100644
+--- a/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
++++ b/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
+@@ -563,9 +563,11 @@ void HciManager::handleHciAclPacket(const quint8 *data, int size)
+ 
+ void HciManager::handleLeMetaEvent(const quint8 *data)
+ {
+-    // Spec v4.2, Vol 2, part E, 7.7.65ff
++    // Spec v5.3, Vol 4, part E, 7.7.65.*
+     switch (*data) {
+-    case 0x1: {
++    case 0x1: // HCI_LE_Connection_Complete
++    case 0xA: // HCI_LE_Enhanced_Connection_Complete
++    {
+         const quint16 handle = bt_get_le16(data + 2);
+         emit connectionComplete(handle);
+         break;
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp b/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
+index 6a93143b..4a18cfc7 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
+@@ -320,7 +320,10 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_finishSdpScan(QBluetoothServiceD
+             for (const QBluetoothUuid &id : serviceClassUuids) {
+                 if (id.minimumSize() == 16) {
+                     serviceInfo.setServiceUuid(id);
+-                    serviceInfo.setServiceName(QBluetoothServiceDiscoveryAgent::tr("Custom Service"));
++                    if (serviceInfo.serviceName().isEmpty()) {
++                        serviceInfo.setServiceName(
++                                    QBluetoothServiceDiscoveryAgent::tr("Custom Service"));
++                    }
+                     QBluetoothServiceInfo::Sequence modSeq =
+                             serviceInfo.attribute(QBluetoothServiceInfo::ServiceClassIds).value<QBluetoothServiceInfo::Sequence>();
+                     modSeq.removeOne(QVariant::fromValue(id));
+@@ -334,8 +337,10 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_finishSdpScan(QBluetoothServiceD
+                 qCDebug(QT_BT_BLUEZ) << "Discovered services" << discoveredDevices.at(0).address().toString()
+                                      << serviceInfo.serviceName() << serviceInfo.serviceUuid()
+                                      << ">>>" << serviceInfo.serviceClassUuids();
+-
+-                emit q->serviceDiscovered(serviceInfo);
++                // Use queued connection to allow us finish the service looping; the application
++                // might call stop() when it has detected the service-of-interest.
++                QMetaObject::invokeMethod(q, "serviceDiscovered", Qt::QueuedConnection,
++                                          Q_ARG(QBluetoothServiceInfo, serviceInfo));
+             }
+         }
+     }
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp b/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
+index e4d85447..aadd4755 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
+@@ -593,7 +593,7 @@ void QBluetoothSocket::setSocketState(QBluetoothSocket::SocketState state)
+ bool QBluetoothSocket::canReadLine() const
+ {
+     Q_D(const QBluetoothSocketBase);
+-    return d->canReadLine();
++    return d->canReadLine() || QIODevice::canReadLine();
+ }
+ 
+ /*!
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp b/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
+index 084aa958..d6aa17a7 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
+@@ -284,6 +284,10 @@ void QBluetoothSocketPrivateBluezDBus::connectToService(
+         return;
+     }
+ 
++    if (service.socketProtocol() != QBluetoothServiceInfo::Protocol::UnknownProtocol)
++        socketType = service.socketProtocol();
++    qCDebug(QT_BT_BLUEZ) << "Socket protocol used:" << socketType;
++
+     connectToService(service.device().address(), targetService, openMode);
+ }
+ 
+diff --git a/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp b/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
+index 05bc1a0f..a7b5ef1f 100644
+--- a/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
++++ b/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
+@@ -142,7 +142,7 @@ void tst_QBluetoothSocket::initTestCase()
+     qDebug() << "Starting discovery";
+ 
+     sda->setUuidFilter(QBluetoothUuid(QString(TEST_SERVICE_UUID)));
+-    sda->start(QBluetoothServiceDiscoveryAgent::MinimalDiscovery);
++    sda->start(QBluetoothServiceDiscoveryAgent::FullDiscovery);
+ 
+     for (int connectTime = MaxConnectTime; !done_discovery && connectTime > 0; connectTime -= 1000)
+         QTest::qWait(1000);
+Submodule qtdeclarative f5701f0d..8defe7bf:
+diff --git a/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h b/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
+index b65b994d6c..15a8cd6878 100644
+--- a/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
++++ b/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
+@@ -86,7 +86,7 @@ public:
+         if (QTypeInfo<T>::isComplex) {
+             for (int i = 0; i < count; ++i)
+                 new (data + i) T(vector.at(i));
+-        } else {
++        } else if (count) {
+             memcpy(data, static_cast<const void*>(vector.constData()), count * sizeof(T));
+         }
+     }
+diff --git a/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp b/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
+index e57cdd8278..94613598af 100644
+--- a/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
++++ b/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
+@@ -1145,8 +1145,7 @@ void Heap::QObjectWrapper::markObjects(Heap::Base *that, QV4::MarkStack *markSta
+ void QObjectWrapper::destroyObject(bool lastCall)
+ {
+     Heap::QObjectWrapper *h = d();
+-    if (!h->internalClass)
+-        return; // destroyObject already got called
++    Q_ASSERT(h->internalClass);
+ 
+     if (h->object()) {
+         QQmlData *ddata = QQmlData::get(h->object(), false);
+@@ -1176,7 +1175,7 @@ void QObjectWrapper::destroyObject(bool lastCall)
+         }
+     }
+ 
+-    h->~Data();
++    h->destroy();
+ }
+ 
+ 
+diff --git a/qtdeclarative/src/qml/memory/qv4mm.cpp b/qtdeclarative/src/qml/memory/qv4mm.cpp
+index 06caf04e5a..da149a67c4 100644
+--- a/qtdeclarative/src/qml/memory/qv4mm.cpp
++++ b/qtdeclarative/src/qml/memory/qv4mm.cpp
+@@ -981,7 +981,7 @@ void MemoryManager::sweep(bool lastSweep, ClassDestroyStatsCallback classCountPt
+ 
+     if (MultiplyWrappedQObjectMap *multiplyWrappedQObjects = engine->m_multiplyWrappedQObjects) {
+         for (MultiplyWrappedQObjectMap::Iterator it = multiplyWrappedQObjects->begin(); it != multiplyWrappedQObjects->end();) {
+-            if (!it.value().isNullOrUndefined())
++            if (it.value().isNullOrUndefined())
+                 it = multiplyWrappedQObjects->erase(it);
+             else
+                 ++it;
+diff --git a/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp b/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
+index 2079a8ed04..a577cb2351 100644
+--- a/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
++++ b/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
+@@ -389,6 +389,12 @@ void QQmlDelegateModelPrivate::connectToAbstractItemModel()
+                       q,  QQmlDelegateModel, SLOT(_q_rowsRemoved(QModelIndex,int,int)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
+                       q,  QQmlDelegateModel, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsInserted(QModelIndex,int,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsInserted(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsRemoved(QModelIndex,int,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsRemoved(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsMoved(QModelIndex,int,int,QModelIndex,int)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
+                       q, QQmlDelegateModel, SLOT(_q_dataChanged(QModelIndex,QModelIndex,QVector<int>)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
+@@ -413,6 +419,12 @@ void QQmlDelegateModelPrivate::disconnectFromAbstractItemModel()
+                         q, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int)));
+     QObject::disconnect(aim, SIGNAL(rowsRemoved(QModelIndex,int,int)),
+                         q, SLOT(_q_rowsRemoved(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsInserted(QModelIndex,int,int)), q,
++                        SLOT(_q_columnsInserted(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsRemoved(QModelIndex,int,int)), q,
++                        SLOT(_q_columnsRemoved(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)), q,
++                        SLOT(_q_columnsMoved(QModelIndex,int,int,QModelIndex,int)));
+     QObject::disconnect(aim, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
+                         q, SLOT(_q_dataChanged(QModelIndex,QModelIndex,QVector<int>)));
+     QObject::disconnect(aim, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
+@@ -1973,6 +1985,38 @@ void QQmlDelegateModel::_q_rowsMoved(
+     }
+ }
+ 
++void QQmlDelegateModel::_q_columnsInserted(const QModelIndex &parent, int begin, int end)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if (parent == d->m_adaptorModel.rootIndex && begin == 0) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
++void QQmlDelegateModel::_q_columnsRemoved(const QModelIndex &parent, int begin, int end)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if (parent == d->m_adaptorModel.rootIndex && begin == 0) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
++void QQmlDelegateModel::_q_columnsMoved(const QModelIndex &parent, int start, int end,
++                                        const QModelIndex &destination, int column)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if ((parent == d->m_adaptorModel.rootIndex && start == 0)
++        || (destination == d->m_adaptorModel.rootIndex && column == 0)) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
+ void QQmlDelegateModel::_q_dataChanged(const QModelIndex &begin, const QModelIndex &end, const QVector<int> &roles)
+ {
+     Q_D(QQmlDelegateModel);
+diff --git a/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h b/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
+index 8aab4badca..d140bfbaaf 100644
+--- a/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
++++ b/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
+@@ -152,6 +152,9 @@ private Q_SLOTS:
+     void _q_itemsMoved(int from, int to, int count);
+     void _q_modelReset();
+     void _q_rowsInserted(const QModelIndex &,int,int);
++    void _q_columnsInserted(const QModelIndex &, int, int);
++    void _q_columnsRemoved(const QModelIndex &, int, int);
++    void _q_columnsMoved(const QModelIndex &, int, int, const QModelIndex &, int);
+     void _q_rowsAboutToBeRemoved(const QModelIndex &parent, int begin, int end);
+     void _q_rowsRemoved(const QModelIndex &,int,int);
+     void _q_rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int);
+diff --git a/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp b/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
+index 85719fdc80..78e2ab302c 100644
+--- a/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
++++ b/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
+@@ -46,6 +46,7 @@
+ #include "QtQuick/private/qquicktextinput_p.h"
+ #include "QtQuick/private/qquickaccessibleattached_p.h"
+ #include "QtQuick/qquicktextdocument.h"
++#include "QtQuick/qquickrendercontrol.h"
+ QT_BEGIN_NAMESPACE
+ 
+ #if QT_CONFIG(accessibility)
+@@ -57,7 +58,19 @@ QAccessibleQuickItem::QAccessibleQuickItem(QQuickItem *item)
+ 
+ QWindow *QAccessibleQuickItem::window() const
+ {
+-    return item()->window();
++    QQuickWindow *window = item()->window();
++
++    // For QQuickWidget the above window will be the offscreen QQuickWindow,
++    // which is not a part of the accessibility tree. Detect this case and
++    // return the window for the QQuickWidget instead.
++    if (window && !window->handle()) {
++        if (QQuickRenderControl *renderControl = QQuickWindowPrivate::get(window)->renderControl) {
++            if (QWindow *renderWindow = renderControl->renderWindow(nullptr))
++                return renderWindow;
++        }
++    }
++
++    return window;
+ }
+ 
+ int QAccessibleQuickItem::childCount() const
+@@ -113,19 +126,15 @@ QAccessibleInterface *QAccessibleQuickItem::childAt(int x, int y) const
+ QAccessibleInterface *QAccessibleQuickItem::parent() const
+ {
+     QQuickItem *parent = item()->parentItem();
+-    QQuickWindow *window = item()->window();
+-    QQuickItem *ci = window ? window->contentItem() : nullptr;
++    QQuickWindow *itemWindow = item()->window();
++    QQuickItem *ci = itemWindow ? itemWindow->contentItem() : nullptr;
+     while (parent && !QQuickItemPrivate::get(parent)->isAccessible && parent != ci)
+         parent = parent->parentItem();
+ 
+     if (parent) {
+         if (parent == ci) {
+-            // Jump out to the scene widget if the parent is the root item.
+-            // There are two root items, QQuickWindow::rootItem and
+-            // QQuickView::declarativeRoot. The former is the true root item,
+-            // but is not a part of the accessibility tree. Check if we hit
+-            // it here and return an interface for the scene instead.
+-            return QAccessible::queryAccessibleInterface(window);
++            // Jump out to the window if the parent is the root item
++            return QAccessible::queryAccessibleInterface(window());
+         } else {
+             while (parent && !parent->d_func()->isAccessible)
+                 parent = parent->parentItem();
+@@ -188,7 +197,7 @@ QAccessible::State QAccessibleQuickItem::state() const
+     QRect viewRect_ = viewRect();
+     QRect itemRect = rect();
+ 
+-    if (viewRect_.isNull() || itemRect.isNull() || !item()->window() || !item()->window()->isVisible() ||!item()->isVisible() || qFuzzyIsNull(item()->opacity()))
++    if (viewRect_.isNull() || itemRect.isNull() || !window() || !window()->isVisible() ||!item()->isVisible() || qFuzzyIsNull(item()->opacity()))
+         state.invisible = true;
+     if (!viewRect_.intersects(itemRect))
+         state.offscreen = true;
+@@ -201,6 +210,10 @@ QAccessible::State QAccessibleQuickItem::state() const
+     if (role() == QAccessible::EditableText)
+         if (auto ti = qobject_cast<QQuickTextInput *>(item()))
+             state.passwordEdit = ti->echoMode() != QQuickTextInput::Normal;
++    if (!item()->isEnabled()) {
++        state.focusable = false;
++        state.disabled = true;
++    }
+     return state;
+ }
+ 
+diff --git a/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h b/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
+index 39ffcaf39c..8baa01330c 100644
+--- a/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
++++ b/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
+@@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE
+ 
+ #if QT_CONFIG(accessibility)
+ 
+-class QAccessibleQuickWindow : public QAccessibleObject
++class Q_QUICK_EXPORT QAccessibleQuickWindow : public QAccessibleObject
+ {
+ public:
+     QAccessibleQuickWindow(QQuickWindow *object);
+diff --git a/qtdeclarative/src/quick/items/qquickdrag.cpp b/qtdeclarative/src/quick/items/qquickdrag.cpp
+index 8321fcfeed..383078b3b9 100644
+--- a/qtdeclarative/src/quick/items/qquickdrag.cpp
++++ b/qtdeclarative/src/quick/items/qquickdrag.cpp
+@@ -481,7 +481,9 @@ void QQuickDragAttached::setKeys(const QStringList &keys)
+     \qmlattachedproperty stringlist QtQuick::Drag::mimeData
+     \since 5.2
+ 
+-    This property holds a map of mimeData that is used during startDrag.
++    This property holds a map from mime type to data that is used during startDrag.
++    The mime data needs to be a \c string, or an \c ArrayBuffer with the data encoded
++    according to the mime type.
+ */
+ 
+ QVariantMap QQuickDragAttached::mimeData() const
+@@ -766,8 +768,12 @@ Qt::DropAction QQuickDragAttachedPrivate::startDrag(Qt::DropActions supportedAct
+     QDrag *drag = new QDrag(source ? source : q);
+     QMimeData *mimeData = new QMimeData();
+ 
+-    for (auto it = externalMimeData.cbegin(), end = externalMimeData.cend(); it != end; ++it)
+-        mimeData->setData(it.key(), it.value().toString().toUtf8());
++    for (auto it = externalMimeData.cbegin(), end = externalMimeData.cend(); it != end; ++it) {
++        if (static_cast<QMetaType::Type>(it.value().type()) == QMetaType::QByteArray)
++            mimeData->setData(it.key(), it.value().toByteArray());
++        else
++            mimeData->setData(it.key(), it.value().toString().toUtf8());
++    }
+ 
+     drag->setMimeData(mimeData);
+     if (pixmapLoader.isReady()) {
+diff --git a/qtdeclarative/src/quick/items/qquickitem.cpp b/qtdeclarative/src/quick/items/qquickitem.cpp
+index 75f1457816..dec0ae19ae 100644
+--- a/qtdeclarative/src/quick/items/qquickitem.cpp
++++ b/qtdeclarative/src/quick/items/qquickitem.cpp
+@@ -59,6 +59,7 @@
+ #include <QtCore/private/qnumeric_p.h>
+ #include <QtGui/qpa/qplatformtheme.h>
+ #include <QtCore/qloggingcategory.h>
++#include <QtCore/private/qduplicatetracker_p.h>
+ 
+ #include <private/qqmlglobal_p.h>
+ #include <private/qqmlengine_p.h>
+@@ -2326,6 +2327,7 @@ QQuickItem::QQuickItem(QQuickItemPrivate &dd, QQuickItem *parent)
+ QQuickItem::~QQuickItem()
+ {
+     Q_D(QQuickItem);
++    d->inDestructor = true;
+ 
+     if (d->windowRefCount > 1)
+         d->windowRefCount = 1; // Make sure window is set to null in next call to derefWindow().
+@@ -2526,6 +2528,7 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo
+     QQuickItem *current = item;
+     qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: startItem:" << startItem;
+     qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: firstFromItem:" << firstFromItem;
++    QDuplicateTracker<QQuickItem *> cycleDetector;
+     do {
+         qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: current:" << current;
+         qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: from:" << from;
+@@ -2592,7 +2595,10 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo
+         // traversed all of the chain (by compare the [current] item with [startItem])
+         // Since the [startItem] might be promoted to its parent if it is invisible,
+         // we still have to check [current] item with original start item
+-        if ((current == startItem || current == originalStartItem) && from == firstFromItem) {
++        // We might also run into a cycle before we reach firstFromItem again
++        // but note that we have to ignore current if we are meant to skip it
++        if (((current == startItem || current == originalStartItem) && from == firstFromItem) ||
++                (!skip && cycleDetector.hasSeen(current))) {
+             // wrapped around, avoid endless loops
+             if (item == contentItem) {
+                 qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: looped, return contentItem";
+@@ -2689,9 +2695,8 @@ void QQuickItem::setParentItem(QQuickItem *parentItem)
+ 
+         const bool wasVisible = isVisible();
+         op->removeChild(this);
+-        if (wasVisible) {
++        if (wasVisible && !op->inDestructor)
+             emit oldParentItem->visibleChildrenChanged();
+-        }
+     } else if (d->window) {
+         QQuickWindowPrivate::get(d->window)->parentlessItems.remove(this);
+     }
+@@ -2768,8 +2773,9 @@ void QQuickItem::setParentItem(QQuickItem *parentItem)
+ 
+     d->itemChange(ItemParentHasChanged, d->parentItem);
+ 
+-    emit parentChanged(d->parentItem);
+-    if (isVisible() && d->parentItem)
++    if (!d->inDestructor)
++        emit parentChanged(d->parentItem);
++    if (isVisible() && d->parentItem && !QQuickItemPrivate::get(d->parentItem)->inDestructor)
+         emit d->parentItem->visibleChildrenChanged();
+ }
+ 
+@@ -2965,7 +2971,8 @@ void QQuickItemPrivate::removeChild(QQuickItem *child)
+ 
+     itemChange(QQuickItem::ItemChildRemovedChange, child);
+ 
+-    emit q->childrenChanged();
++    if (!inDestructor)
++        emit q->childrenChanged();
+ }
+ 
+ void QQuickItemPrivate::refWindow(QQuickWindow *c)
+@@ -3194,6 +3201,7 @@ QQuickItemPrivate::QQuickItemPrivate()
+     , touchEnabled(false)
+ #endif
+     , hasCursorHandler(false)
++    , inDestructor(false)
+     , dirtyAttributes(0)
+     , nextDirtyItem(nullptr)
+     , prevDirtyItem(nullptr)
+@@ -5120,6 +5128,13 @@ void QQuickItem::componentComplete()
+         d->addToDirtyList();
+         QQuickWindowPrivate::get(d->window)->dirtyItem(this);
+     }
++
++#if QT_CONFIG(accessibility)
++    if (d->isAccessible && d->effectiveVisible) {
++        QAccessibleEvent ev(this, QAccessible::ObjectShow);
++        QAccessible::updateAccessibility(&ev);
++    }
++#endif
+ }
+ 
+ QQuickStateGroup *QQuickItemPrivate::_states()
+@@ -6106,9 +6121,11 @@ bool QQuickItemPrivate::setEffectiveVisibleRecur(bool newEffectiveVisible)
+         QAccessible::updateAccessibility(&ev);
+     }
+ #endif
+-    emit q->visibleChanged();
+-    if (childVisibilityChanged)
+-        emit q->visibleChildrenChanged();
++    if (!inDestructor) {
++        emit q->visibleChanged();
++        if (childVisibilityChanged)
++            emit q->visibleChildrenChanged();
++    }
+ 
+     return true;    // effective visibility DID change
+ }
+@@ -6157,6 +6174,15 @@ void QQuickItemPrivate::setEffectiveEnableRecur(QQuickItem *scope, bool newEffec
+     }
+ 
+     itemChange(QQuickItem::ItemEnabledHasChanged, effectiveEnable);
++#if QT_CONFIG(accessibility)
++    if (isAccessible) {
++        QAccessible::State changedState;
++        changedState.disabled = true;
++        changedState.focusable = true;
++        QAccessibleStateChangeEvent ev(q, changedState);
++        QAccessible::updateAccessibility(&ev);
++    }
++#endif
+     emit q->enabledChanged();
+ }
+ 
+diff --git a/qtdeclarative/src/quick/items/qquickitem_p.h b/qtdeclarative/src/quick/items/qquickitem_p.h
+index 841d91bb40..ade8fb61f2 100644
+--- a/qtdeclarative/src/quick/items/qquickitem_p.h
++++ b/qtdeclarative/src/quick/items/qquickitem_p.h
+@@ -472,6 +472,7 @@ public:
+     bool replayingPressEvent:1;
+     bool touchEnabled:1;
+     bool hasCursorHandler:1;
++    quint32 inDestructor:1; // has entered ~QQuickItem
+ 
+     enum DirtyType {
+         TransformOrigin         = 0x00000001,
+diff --git a/qtdeclarative/src/quick/items/qquickitemview.cpp b/qtdeclarative/src/quick/items/qquickitemview.cpp
+index 010a0152e1..f8ad168a17 100644
+--- a/qtdeclarative/src/quick/items/qquickitemview.cpp
++++ b/qtdeclarative/src/quick/items/qquickitemview.cpp
+@@ -1785,7 +1785,7 @@ void QQuickItemViewPrivate::refill(qreal from, qreal to)
+ 
+     do {
+         bufferPause.stop();
+-        if (currentChanges.hasPendingChanges() || bufferedChanges.hasPendingChanges()) {
++        if (currentChanges.hasPendingChanges() || bufferedChanges.hasPendingChanges() || currentChanges.active) {
+             currentChanges.reset();
+             bufferedChanges.reset();
+             releaseVisibleItems(reusableFlag);
+diff --git a/qtdeclarative/src/quick/items/qquickmousearea_p_p.h b/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
+index fba383e268..0d63618622 100644
+--- a/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
++++ b/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
+@@ -61,7 +61,6 @@ QT_BEGIN_NAMESPACE
+ 
+ class QQuickMouseEvent;
+ class QQuickMouseArea;
+-class QQuickPointerMask;
+ class QQuickMouseAreaPrivate : public QQuickItemPrivate
+ {
+     Q_DECLARE_PUBLIC(QQuickMouseArea)
+@@ -100,7 +99,6 @@ public:
+ #if QT_CONFIG(quick_draganddrop)
+     QQuickDrag *drag;
+ #endif
+-    QPointer<QQuickPointerMask> mask;
+     QPointF startScene;
+     QPointF targetStartPos;
+     QPointF lastPos;
+diff --git a/qtdeclarative/src/quick/items/qquicktext.cpp b/qtdeclarative/src/quick/items/qquicktext.cpp
+index 6230186933..e823ca1095 100644
+--- a/qtdeclarative/src/quick/items/qquicktext.cpp
++++ b/qtdeclarative/src/quick/items/qquicktext.cpp
+@@ -2168,7 +2168,7 @@ void QQuickText::resetMaximumLineCount()
+     <img src="" align="top,middle,bottom" width="" height=""> - inline images
+     <ol type="">, <ul type=""> and <li> - ordered and unordered lists
+     <pre></pre> - preformatted
+-    &gt; &lt; &amp;
++    &gt; &lt; &amp; &quot; &nbsp; &apos;
+     \endcode
+ 
+     \c Text.StyledText parser is strict, requiring tags to be correctly nested.
+diff --git a/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp b/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
+index eb4db0f85e..2325a2665b 100644
+--- a/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
++++ b/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
+@@ -446,7 +446,7 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+         const char *textureRecord = allocatorData;
+         for (int i = 0; i < textureCount; ++i, textureRecord += Qtdf::TextureRecordSize) {
+-            if (textureRecord + Qtdf::TextureRecordSize > qtdfTableEnd) {
++            if (qtdfTableEnd - textureRecord < Qtdf::TextureRecordSize) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+@@ -462,7 +462,7 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+         const char *glyphRecord = textureRecord;
+         for (quint32 i = 0; i < glyphCount; ++i, glyphRecord += Qtdf::GlyphRecordSize) {
+-            if (glyphRecord + Qtdf::GlyphRecordSize > qtdfTableEnd) {
++            if (qtdfTableEnd - glyphRecord < Qtdf:: GlyphRecordSize) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+@@ -512,8 +512,8 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+             int width = texInfo->allocatedArea.width();
+             int height = texInfo->allocatedArea.height();
+-            qint64 size = width * height;
+-            if (reinterpret_cast<const char *>(textureData + size) > qtdfTableEnd) {
++            qint64 size = qint64(width) * height;
++            if (qtdfTableEnd - reinterpret_cast<const char *>(textureData) < size) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+diff --git a/qtdeclarative/src/quick/util/qquickstyledtext.cpp b/qtdeclarative/src/quick/util/qquickstyledtext.cpp
+index d531fc9205..a25af90414 100644
+--- a/qtdeclarative/src/quick/util/qquickstyledtext.cpp
++++ b/qtdeclarative/src/quick/util/qquickstyledtext.cpp
+@@ -564,6 +564,8 @@ void QQuickStyledTextPrivate::parseEntity(const QChar *&ch, const QString &textI
+                 textOut += QChar(60);
+             else if (entity == QLatin1String("amp"))
+                 textOut += QChar(38);
++            else if (entity == QLatin1String("apos"))
++                textOut += QChar(39);
+             else if (entity == QLatin1String("quot"))
+                 textOut += QChar(34);
+             else if (entity == QLatin1String("nbsp"))
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp
+new file mode 100644
+index 0000000000..8a1c901880
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp
+@@ -0,0 +1,110 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include "qaccessiblequickwidget_p.h"
++
++#include "qquickwidget_p.h"
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleQuickWidget::QAccessibleQuickWidget(QQuickWidget* widget)
++: QAccessibleWidget(widget)
++, m_accessibleWindow(QQuickWidgetPrivate::get(widget)->offscreenWindow)
++{
++    // NOTE: m_accessibleWindow is a QAccessibleQuickWindow, and not a
++    // QAccessibleQuickWidgetOffscreenWindow (defined below). This means
++    // it will return the Quick item child interfaces, which is what's needed here
++    // (unlike QAccessibleQuickWidgetOffscreenWindow, which will report 0 children).
++}
++
++QAccessibleInterface *QAccessibleQuickWidget::child(int index) const
++{
++    return m_accessibleWindow.child(index);
++}
++
++int QAccessibleQuickWidget::childCount() const
++{
++    return m_accessibleWindow.childCount();
++}
++
++int QAccessibleQuickWidget::indexOfChild(const QAccessibleInterface *iface) const
++{
++    return m_accessibleWindow.indexOfChild(iface);
++}
++
++QAccessibleInterface *QAccessibleQuickWidget::childAt(int x, int y) const
++{
++    return m_accessibleWindow.childAt(x, y);
++}
++
++QAccessibleQuickWidgetOffscreenWindow::QAccessibleQuickWidgetOffscreenWindow(QQuickWindow *window)
++:QAccessibleQuickWindow(window)
++{
++
++}
++
++QAccessibleInterface *QAccessibleQuickWidgetOffscreenWindow::child(int index) const
++{
++    Q_UNUSED(index);
++    return nullptr;
++}
++
++int QAccessibleQuickWidgetOffscreenWindow::childCount() const
++{
++    return 0;
++}
++
++int QAccessibleQuickWidgetOffscreenWindow::indexOfChild(const QAccessibleInterface *iface) const
++{
++    Q_UNUSED(iface);
++    return -1;
++}
++
++QAccessibleInterface *QAccessibleQuickWidgetOffscreenWindow::QAccessibleQuickWidgetOffscreenWindow::childAt(int x, int y) const
++{
++    Q_UNUSED(x);
++    Q_UNUSED(y);
++    return nullptr;
++}
++
++#endif // accessibility
++
++QT_END_NAMESPACE
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h
+new file mode 100644
+index 0000000000..7c2ab930e0
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h
+@@ -0,0 +1,95 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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 QACCESSIBLEQUICKWIDGET_H
++#define QACCESSIBLEQUICKWIDGET_H
++
++//
++//  W A R N I N G
++//  -------------
++//
++// This file is not part of the Qt API.  It exists purely as an
++// implementation detail.  This header file may change from version to
++// version without notice, or even be removed.
++//
++// We mean it.
++//
++
++#include "qquickwidget.h"
++#include <QtWidgets/qaccessiblewidget.h>
++
++#include <private/qaccessiblequickview_p.h>
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++// These classes implement the QQuickWiget accessibility switcharoo,
++// where the child items of the QQuickWidgetOffscreenWindow are reported
++// as child accessible interfaces of the QAccessibleQuickWidget.
++class QAccessibleQuickWidget: public QAccessibleWidget
++{
++public:
++    QAccessibleQuickWidget(QQuickWidget* widget);
++
++    QAccessibleInterface *child(int index) const override;
++    int childCount() const override;
++    int indexOfChild(const QAccessibleInterface *iface) const override;
++    QAccessibleInterface *childAt(int x, int y) const override;
++
++private:
++    QAccessibleQuickWindow m_accessibleWindow;
++    Q_DISABLE_COPY(QAccessibleQuickWidget)
++};
++
++class QAccessibleQuickWidgetOffscreenWindow: public QAccessibleQuickWindow
++{
++public:
++    QAccessibleQuickWidgetOffscreenWindow(QQuickWindow *window);
++    QAccessibleInterface *child(int index) const override;
++    int childCount() const override;
++    int indexOfChild(const QAccessibleInterface *iface) const override;
++    QAccessibleInterface *childAt(int x, int y) const override;
++};
++
++#endif // accessibility
++
++QT_END_NAMESPACE
++
++#endif
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp
+new file mode 100644
+index 0000000000..7ba88a1769
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp
+@@ -0,0 +1,60 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include "qaccessiblequickwidgetfactory_p.h"
++#include "qaccessiblequickwidget_p.h"
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleInterface *qAccessibleQuickWidgetFactory(const QString &classname, QObject *object)
++{
++    if (classname == QLatin1String("QQuickWidget")) {
++        return new QAccessibleQuickWidget(qobject_cast<QQuickWidget *>(object));
++    } else if (classname == QLatin1String("QQuickWidgetOffscreenWindow")) {
++        return new QAccessibleQuickWidgetOffscreenWindow(qobject_cast<QQuickWindow *>(object));
++    }
++    return 0;
++}
++
++#endif // accessibility
++
++QT_END_NAMESPACE
++
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h
+new file mode 100644
+index 0000000000..8c63b09f81
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h
+@@ -0,0 +1,66 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include <QtGui/qaccessible.h>
++
++#ifndef QACCESSIBLEQUICKWIDGETFACTORY_H
++#define QACCESSIBLEQUICKWIDGETFACTORY_H
++
++//
++//  W A R N I N G
++//  -------------
++//
++// This file is not part of the Qt API.  It exists purely as an
++// implementation detail.  This header file may change from version to
++// version without notice, or even be removed.
++//
++// We mean it.
++//
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleInterface *qAccessibleQuickWidgetFactory(const QString &classname, QObject *object);
++
++#endif
++
++QT_END_NAMESPACE
++
++#endif
+diff --git a/qtdeclarative/src/quickwidgets/qquickwidget.cpp b/qtdeclarative/src/quickwidgets/qquickwidget.cpp
+index 39780f8de3..9c97b43518 100644
+--- a/qtdeclarative/src/quickwidgets/qquickwidget.cpp
++++ b/qtdeclarative/src/quickwidgets/qquickwidget.cpp
+@@ -39,6 +39,7 @@
+ 
+ #include "qquickwidget.h"
+ #include "qquickwidget_p.h"
++#include "qaccessiblequickwidgetfactory_p.h"
+ 
+ #include "private/qquickwindow_p.h"
+ #include "private/qquickitem_p.h"
+@@ -75,9 +76,16 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++QQuickWidgetOffscreenWindow::QQuickWidgetOffscreenWindow(QQuickWindowPrivate &dd, QQuickRenderControl *control)
++:QQuickWindow(dd, control)
++{
++    setTitle(QString::fromLatin1("Offscreen"));
++    setObjectName(QString::fromLatin1("QQuickOffScreenWindow"));
++}
++
+ // override setVisble to prevent accidental offscreen window being created
+ // by base class.
+-class QQuickOffcreenWindowPrivate: public QQuickWindowPrivate {
++class QQuickWidgetOffscreenWindowPrivate: public QQuickWindowPrivate {
+ public:
+     void setVisible(bool visible) override {
+         Q_Q(QWindow);
+@@ -105,9 +113,8 @@ void QQuickWidgetPrivate::init(QQmlEngine* e)
+     Q_Q(QQuickWidget);
+ 
+     renderControl = new QQuickWidgetRenderControl(q);
+-    offscreenWindow = new QQuickWindow(*new QQuickOffcreenWindowPrivate(),renderControl);
+-    offscreenWindow->setTitle(QString::fromLatin1("Offscreen"));
+-    offscreenWindow->setObjectName(QString::fromLatin1("QQuickOffScreenWindow"));
++    offscreenWindow = new QQuickWidgetOffscreenWindow(*new QQuickWidgetOffscreenWindowPrivate(), renderControl);
++    offscreenWindow->setScreen(q->screen());
+     // Do not call create() on offscreenWindow.
+ 
+     // Check if the Software Adaptation is being used
+@@ -138,6 +145,10 @@ void QQuickWidgetPrivate::init(QQmlEngine* e)
+     QWidget::connect(offscreenWindow, &QQuickWindow::focusObjectChanged, q, &QQuickWidget::propagateFocusObjectChanged);
+     QObject::connect(renderControl, SIGNAL(renderRequested()), q, SLOT(triggerUpdate()));
+     QObject::connect(renderControl, SIGNAL(sceneChanged()), q, SLOT(triggerUpdate()));
++
++#if QT_CONFIG(accessibility)
++    QAccessible::installFactory(&qAccessibleQuickWidgetFactory);
++#endif
+ }
+ 
+ void QQuickWidgetPrivate::ensureEngine() const
+@@ -901,9 +912,7 @@ void QQuickWidgetPrivate::createContext()
+ 
+         context = new QOpenGLContext;
+         context->setFormat(offscreenWindow->requestedFormat());
+-        const QWindow *win = q->window()->windowHandle();
+-        if (win && win->screen())
+-            context->setScreen(win->screen());
++        context->setScreen(q->screen());
+         QOpenGLContext *shareContext = qt_gl_global_share_context();
+         if (!shareContext)
+             shareContext = QWidgetPrivate::get(q->window())->shareContext();
+@@ -1520,19 +1529,16 @@ bool QQuickWidget::event(QEvent *e)
+         d->handleWindowChange();
+         break;
+ 
+-    case QEvent::ScreenChangeInternal:
+-        if (QWindow *window = this->window()->windowHandle()) {
+-            QScreen *newScreen = window->screen();
+-
+-            if (d->offscreenWindow)
+-                d->offscreenWindow->setScreen(newScreen);
+-            if (d->offscreenSurface)
+-                d->offscreenSurface->setScreen(newScreen);
++    case QEvent::ScreenChangeInternal: {
++        QScreen *newScreen = screen();
++        if (d->offscreenWindow)
++            d->offscreenWindow->setScreen(newScreen);
++        if (d->offscreenSurface)
++            d->offscreenSurface->setScreen(newScreen);
+ #if QT_CONFIG(opengl)
+-            if (d->context)
+-                d->context->setScreen(newScreen);
++        if (d->context)
++            d->context->setScreen(newScreen);
+ #endif
+-        }
+ 
+         if (d->useSoftwareRenderer
+ #if QT_CONFIG(opengl)
+@@ -1545,7 +1551,7 @@ bool QQuickWidget::event(QEvent *e)
+             d->render(true);
+         }
+         break;
+-
++    }
+     case QEvent::Show:
+     case QEvent::Move:
+         d->updatePosition();
+diff --git a/qtdeclarative/src/quickwidgets/qquickwidget_p.h b/qtdeclarative/src/quickwidgets/qquickwidget_p.h
+index 881f7f9220..1a946bcc71 100644
+--- a/qtdeclarative/src/quickwidgets/qquickwidget_p.h
++++ b/qtdeclarative/src/quickwidgets/qquickwidget_p.h
+@@ -148,6 +148,14 @@ public:
+     bool forceFullUpdate;
+ };
+ 
++class QQuickWidgetOffscreenWindow: public QQuickWindow
++{
++    Q_OBJECT
++
++public:
++    QQuickWidgetOffscreenWindow(QQuickWindowPrivate &dd, QQuickRenderControl *control);
++};
++
+ QT_END_NAMESPACE
+ 
+ #endif // QQuickWidget_P_H
+diff --git a/qtdeclarative/src/quickwidgets/quickwidgets.pro b/qtdeclarative/src/quickwidgets/quickwidgets.pro
+index 2438e577ae..85d156b8a3 100644
+--- a/qtdeclarative/src/quickwidgets/quickwidgets.pro
++++ b/qtdeclarative/src/quickwidgets/quickwidgets.pro
+@@ -7,9 +7,13 @@ DEFINES   += QT_NO_URL_CAST_FROM_STRING QT_NO_INTEGER_EVENT_COORDINATES QT_NO_FO
+ HEADERS += \
+     qquickwidget.h \
+     qquickwidget_p.h \
+-    qtquickwidgetsglobal.h
++    qtquickwidgetsglobal.h \
++    qaccessiblequickwidget_p.h \
++    qaccessiblequickwidgetfactory_p.h
+ 
+ SOURCES += \
+-    qquickwidget.cpp
++    qquickwidget.cpp \
++    qaccessiblequickwidget.cpp \
++    qaccessiblequickwidgetfactory.cpp
+ 
+ load(qt_module)
+diff --git a/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+index 3b7d74df63..b75bf820d5 100644
+--- a/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
++++ b/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+@@ -102,6 +102,7 @@ private slots:
+     void valueConversion_RegularExpression();
+     void castWithMultipleInheritance();
+     void collectGarbage();
++    void collectGarbageNestedWrappersTwoEngines();
+     void gcWithNestedDataStructure();
+     void stacktrace();
+     void numberParsing_data();
+@@ -1809,6 +1810,44 @@ void tst_QJSEngine::collectGarbage()
+     QVERIFY(ptr.isNull());
+ }
+ 
++class TestObjectContainer : public QObject
++{
++    Q_OBJECT
++    Q_PROPERTY(QObject *dummy MEMBER m_dummy CONSTANT)
++
++public:
++    TestObjectContainer() : m_dummy(new QObject(this)) {}
++
++private:
++    QObject *m_dummy;
++};
++
++void tst_QJSEngine::collectGarbageNestedWrappersTwoEngines()
++{
++    QJSEngine engine1;
++    QJSEngine engine2;
++
++    TestObjectContainer container;
++    QQmlEngine::setObjectOwnership(&container, QQmlEngine::CppOwnership);
++
++    engine1.globalObject().setProperty("foobar", engine1.newQObject(&container));
++    engine2.globalObject().setProperty("foobar", engine2.newQObject(&container));
++
++    engine1.evaluate("foobar.dummy.baz = 42");
++    engine2.evaluate("foobar.dummy.baz = 43");
++
++    QCOMPARE(engine1.evaluate("foobar.dummy.baz").toInt(), 42);
++    QCOMPARE(engine2.evaluate("foobar.dummy.baz").toInt(), 43);
++
++    engine1.collectGarbage();
++    engine2.collectGarbage();
++
++    // The GC should not collect dummy object wrappers neither in engine1 nor engine2, we
++    // verify that by checking whether the baz property still has its previous value.
++    QCOMPARE(engine1.evaluate("foobar.dummy.baz").toInt(), 42);
++    QCOMPARE(engine2.evaluate("foobar.dummy.baz").toInt(), 43);
++}
++
+ void tst_QJSEngine::gcWithNestedDataStructure()
+ {
+     // The GC must be able to traverse deeply nested objects, otherwise this
+diff --git a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml
+new file mode 100644
+index 0000000000..206133bb39
+--- /dev/null
++++ b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml
+@@ -0,0 +1,11 @@
++import QtQuick 2.8
++
++ListView {
++    id: root
++    width: 200
++    height: 200
++
++    delegate: Text {
++        text: display
++    }
++}
+diff --git a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
+index 35f1e2c94d..1722447830 100644
+--- a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
++++ b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
+@@ -27,6 +27,8 @@
+ ****************************************************************************/
+ 
+ #include <QtTest/qtest.h>
++#include <QtCore/QConcatenateTablesProxyModel>
++#include <QtGui/QStandardItemModel>
+ #include <QtQml/qqmlcomponent.h>
+ #include <QtQmlModels/private/qqmldelegatemodel_p.h>
+ #include <QtQuick/qquickview.h>
+@@ -47,6 +49,7 @@ private slots:
+     void filterOnGroup_removeWhenCompleted();
+     void qtbug_86017();
+     void contextAccessedByHandler();
++    void redrawUponColumnChange();
+ };
+ 
+ class AbstractItemModel : public QAbstractItemModel
+@@ -186,6 +189,30 @@ void tst_QQmlDelegateModel::contextAccessedByHandler()
+     QVERIFY(root->property("works").toBool());
+ }
+ 
++void tst_QQmlDelegateModel::redrawUponColumnChange()
++{
++    QStandardItemModel m1;
++    m1.appendRow({
++            new QStandardItem("Banana"),
++            new QStandardItem("Coconut"),
++    });
++
++    QQuickView view(testFileUrl("redrawUponColumnChange.qml"));
++    QCOMPARE(view.status(), QQuickView::Ready);
++    view.show();
++    QQuickItem *root = view.rootObject();
++    root->setProperty("model", QVariant::fromValue<QObject *>(&m1));
++
++    QObject *item = root->property("currentItem").value<QObject *>();
++    QVERIFY(item);
++    QCOMPARE(item->property("text").toString(), "Banana");
++
++    QVERIFY(root);
++    m1.removeColumn(0);
++
++    QCOMPARE(item->property("text").toString(), "Coconut");
++}
++
+ QTEST_MAIN(tst_QQmlDelegateModel)
+ 
+ #include "tst_qqmldelegatemodel.moc"
+diff --git a/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp b/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
+index 5d635aa63b..824fd89e5b 100644
+--- a/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
++++ b/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
+@@ -76,10 +76,10 @@ void tst_qv4mm::multiWrappedQObjects()
+         QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 1);
+         QCOMPARE(engine2.memoryManager->m_pendingFreedObjectWrapperValue.size(), 0);
+ 
+-        // Moves the additional WeakValue from m_multiplyWrappedQObjects to
+-        // m_pendingFreedObjectWrapperValue. It's still alive after all.
++        // The additional WeakValue from m_multiplyWrappedQObjects hasn't been moved
++        // to m_pendingFreedObjectWrapperValue yet. It's still alive after all.
+         engine1.memoryManager->runGC();
+-        QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 2);
++        QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 1);
+ 
+         // engine2 doesn't own the object as engine1 was the first to wrap it above.
+         // Therefore, no effect here.
+diff --git a/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml b/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml
+new file mode 100644
+index 0000000000..889e480f3b
+--- /dev/null
++++ b/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml
+@@ -0,0 +1,13 @@
++import QtQuick 2.6
++
++Item {
++    visible: true
++    Item {
++        visible: false
++        Item {
++            objectName: "hiddenChild"
++            activeFocusOnTab: true
++            focus: true
++        }
++    }
++}
+diff --git a/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp b/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+index c8f251dbe1..c8ef36ee68 100644
+--- a/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
++++ b/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+@@ -67,6 +67,7 @@ private slots:
+     void activeFocusOnTab10();
+     void activeFocusOnTab_infiniteLoop_data();
+     void activeFocusOnTab_infiniteLoop();
++    void activeFocusOnTab_infiniteLoopControls();
+ 
+     void nextItemInFocusChain();
+     void nextItemInFocusChain2();
+@@ -1057,6 +1058,17 @@ void tst_QQuickItem::activeFocusOnTab_infiniteLoop()
+     QCOMPARE(item, window->rootObject());
+ }
+ 
++
++void tst_QQuickItem::activeFocusOnTab_infiniteLoopControls()
++{
++    auto source = testFileUrl("activeFocusOnTab_infiniteLoop3.qml");
++    QScopedPointer<QQuickView>window(new QQuickView());
++    window->setSource(source);
++    window->show();
++    QVERIFY(window->errors().isEmpty());
++    QTest::keyClick(window.get(), Qt::Key_Tab); // should not hang
++}
++
+ void tst_QQuickItem::nextItemInFocusChain()
+ {
+     if (!qt_tab_all_widgets())
+Submodule qtdoc c0c7bf07...79d6ef69:
+Submodule qtimageformats 2dcf2899..abe44c0f:
+diff --git a/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp b/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
+index dde783c..1bf9074 100644
+--- a/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
+@@ -462,8 +462,12 @@ static bool parseIconEntryInfo(ICNSEntry &icon)
+     if (isIconCompressed(icon))
+         return true;
+     // Icon depth:
+-    if (!depth.isEmpty())
+-        icon.depth = ICNSEntry::Depth(depth.toUInt());
++    if (!depth.isEmpty()) {
++        const uint depthUInt = depth.toUInt();
++        if (depthUInt > 32)
++            return false;
++        icon.depth = ICNSEntry::Depth(depthUInt);
++    }
+     // Try mono if depth not found
+     if (icon.depth == ICNSEntry::DepthUnknown)
+         icon.depth = ICNSEntry::DepthMono;
+@@ -515,6 +519,9 @@ static bool parseIconEntryInfo(ICNSEntry &icon)
+         }
+         icon.height = icon.width;
+     }
++    // Sanity check
++    if (icon.width == 0 || icon.width > 4096)
++        return false;
+     return true;
+ }
+ 
+@@ -685,7 +692,7 @@ bool QICNSHandler::canRead() const
+ bool QICNSHandler::read(QImage *outImage)
+ {
+     QImage img;
+-    if (!ensureScanned()) {
++    if (!ensureScanned() || m_currentIconIndex >= m_icons.size()) {
+         qWarning("QICNSHandler::read(): The device wasn't parsed properly!");
+         return false;
+     }
+@@ -892,7 +899,7 @@ bool QICNSHandler::scanDevice()
+             return false;
+ 
+         const qint64 blockDataOffset = device()->pos();
+-        if (!isBlockHeaderValid(blockHeader)) {
++        if (!isBlockHeaderValid(blockHeader, ICNSBlockHeaderSize + filelength - blockDataOffset)) {
+             qWarning("QICNSHandler::scanDevice(): Failed, bad header at pos %s. OSType \"%s\", length %u",
+                      QByteArray::number(blockDataOffset).constData(),
+                      nameFromOSType(blockHeader.ostype).constData(), blockHeader.length);
+@@ -927,11 +934,14 @@ bool QICNSHandler::scanDevice()
+         case ICNSBlockHeader::TypeOdrp:
+             // Icns container seems to have an embedded icon variant container
+             // Let's start a scan for entries
+-            while (device()->pos() < nextBlockOffset) {
++            while (!stream.atEnd() && device()->pos() < nextBlockOffset) {
+                 ICNSBlockHeader icon;
+                 stream >> icon;
++                if (stream.status() != QDataStream::Ok)
++                    return false;
+                 // Check for incorrect variant entry header and stop scan
+-                if (!isBlockHeaderValid(icon, blockDataLength))
++                quint64 remaining = blockDataLength - (device()->pos() - blockDataOffset);
++                if (!isBlockHeaderValid(icon, ICNSBlockHeaderSize + remaining))
+                     break;
+                 if (!addEntry(icon, device()->pos(), blockHeader.ostype))
+                     return false;
+@@ -1003,7 +1013,7 @@ bool QICNSHandler::scanDevice()
+             break;
+         }
+     }
+-    return true;
++    return (m_icons.size() > 0);
+ }
+ 
+ const ICNSEntry &QICNSHandler::getIconMask(const ICNSEntry &icon) const
+diff --git a/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp b/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
+index 5082023..cb34374 100644
+--- a/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
++++ b/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
+@@ -43,6 +43,7 @@
+ #include "qimage.h"
+ #include "qvariant.h"
+ #include "qcolor.h"
++#include "qimagereader.h"
+ 
+ #include <jasper/jasper.h>
+ #include <math.h> // for pow
+@@ -333,16 +334,46 @@ private:
+ Jpeg2000JasperReader::Jpeg2000JasperReader(QIODevice *iod, SubFormat format)
+     : jasperOk(true), ioDevice(iod), format(format), hasAlpha(false)
+ {
++#if JAS_VERSION_MAJOR < 3
+     if (jas_init()) {
+         jasperOk = false;
+         qDebug("Jasper Library initialization failed");
+     }
++#else
++    jas_conf_clear();
++#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
++    jas_conf_set_max_mem_usage(QImageReader::allocationLimit() * 1024 * 1024);
++#else
++    // 128MB seems to be enough.
++    jas_conf_set_max_mem_usage(128 * 1024 * 1024);
++#endif
++    if (jas_init_library()) {
++        jasperOk = false;
++        qDebug("Jasper library initialization failed");
++    }
++    if (jas_init_thread()) {
++        jas_cleanup_library();
++        jasperOk = false;
++        qDebug("Jasper thread initialization failed");
++    }
++#endif
+ }
+ 
+ Jpeg2000JasperReader::~Jpeg2000JasperReader()
+ {
++#if JAS_VERSION_MAJOR < 3
+     if (jasperOk)
+         jas_cleanup();
++#else
++    if (jasperOk) {
++        if (jas_cleanup_thread()) {
++            qDebug("Jasper thread cleanup failed");
++        }
++        if (jas_cleanup_library()) {
++            qDebug("Jasper library cleanup failed");
++        }
++    }
++#endif
+ }
+ 
+ /*! \internal
+@@ -857,7 +888,7 @@ bool Jpeg2000JasperReader::write(const QImage &image, int quality)
+     }
+ 
+     // Open an empty jasper stream that grows automatically
+-    jas_stream_t * memory_stream = jas_stream_memopen(0, -1);
++    jas_stream_t * memory_stream = jas_stream_memopen(0, 0);
+ 
+     // Jasper wants a non-const string.
+     char *str = qstrdup(jasperFormatString.toLatin1().constData());
+diff --git a/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp b/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
+index 1386750..ac8956c 100644
+--- a/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
+@@ -361,6 +361,8 @@ bool QTiffHandler::read(QImage *image)
+     }
+ 
+     TIFF *const tiff = d->tiff;
++    if (TIFFIsTiled(tiff) && TIFFTileSize64(tiff) > uint64_t(image->sizeInBytes())) // Corrupt image
++        return false;
+     const quint32 width = d->size.width();
+     const quint32 height = d->size.height();
+ 
+diff --git a/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp b/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
+index 82d38cb..d02eb05 100644
+--- a/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
+@@ -45,6 +45,7 @@
+ #include <qdebug.h>
+ #include <qpainter.h>
+ #include <qvariant.h>
++#include <QtEndian>
+ 
+ static const int riffHeaderSize = 12; // RIFF_HEADER_SIZE from webp/format_constants.h
+ 
+@@ -102,21 +103,23 @@ bool QWebpHandler::ensureScanned() const
+ 
+     m_scanState = ScanError;
+ 
+-    if (device()->isSequential()) {
+-        qWarning() << "Sequential devices are not supported";
++    QWebpHandler *that = const_cast<QWebpHandler *>(this);
++    const int headerBytesNeeded = sizeof(WebPBitstreamFeatures);
++    QByteArray header = device()->peek(headerBytesNeeded);
++    if (header.size() < headerBytesNeeded)
+         return false;
+-    }
+ 
+-    qint64 oldPos = device()->pos();
+-    device()->seek(0);
+-
+-    QWebpHandler *that = const_cast<QWebpHandler *>(this);
+-    QByteArray header = device()->peek(sizeof(WebPBitstreamFeatures));
++    // We do no random access during decoding, just a readAll() of the whole image file. So if
++    // if it is all available already, we can accept a sequential device. The riff header contains
++    // the file size minus 8 bytes header
++    qint64 byteSize = qFromLittleEndian<quint32>(header.constData() + 4);
++    if (device()->isSequential() && device()->bytesAvailable() < byteSize + 8) {
++        qWarning() << "QWebpHandler: Insufficient data available in sequential device";
++        return false;
++    }
+     if (WebPGetFeatures((const uint8_t*)header.constData(), header.size(), &(that->m_features)) == VP8_STATUS_OK) {
+         if (m_features.has_animation) {
+             // For animation, we have to read and scan whole file to determine loop count and images count
+-            device()->seek(oldPos);
+-
+             if (that->ensureDemuxer()) {
+                 that->m_loop = WebPDemuxGetI(m_demuxer, WEBP_FF_LOOP_COUNT);
+                 that->m_frameCount = WebPDemuxGetI(m_demuxer, WEBP_FF_FRAME_COUNT);
+@@ -126,17 +129,13 @@ bool QWebpHandler::ensureScanned() const
+                 if (that->m_features.has_alpha)
+                     that->m_composited->fill(Qt::transparent);
+ 
+-                // We do not reset device position since we have read in all data
+                 m_scanState = ScanSuccess;
+-                return true;
+             }
+         } else {
+             m_scanState = ScanSuccess;
+         }
+     }
+ 
+-    device()->seek(oldPos);
+-
+     return m_scanState == ScanSuccess;
+ }
+ 
+@@ -159,7 +158,7 @@ bool QWebpHandler::ensureDemuxer()
+ 
+ bool QWebpHandler::read(QImage *image)
+ {
+-    if (!ensureScanned() || device()->isSequential() || !ensureDemuxer())
++    if (!ensureScanned() || !ensureDemuxer())
+         return false;
+ 
+     QRect prevFrameRect;
+Submodule qtlocation 98a5c511..f991e28c:
+diff --git a/qtlocation/src/location/configure.json b/qtlocation/src/location/configure.json
+index 6d01a9a3..d1e623a1 100644
+--- a/qtlocation/src/location/configure.json
++++ b/qtlocation/src/location/configure.json
+@@ -9,7 +9,7 @@
+             "label": "Qt.labs.location experimental QML plugin",
+             "purpose": "Provides experimental QtLocation QML types",
+             "section": "Location",
+-            "condition": "config.opengl",
++            "condition": "features.opengl",
+             "output": [ "privateFeature" ]
+         },
+         "geoservices_osm": {
+diff --git a/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp b/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
+index a978573d..11e1466f 100644
+--- a/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
++++ b/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
+@@ -158,7 +158,7 @@ void QGeoMapObjectQSGSupport::updateMapObjects(QSGNode *root, QQuickWindow *wind
+     if (!root)
+         return;
+ 
+-    if (m_mapObjectsRootNode && m_mapObjectsRootNode->parent())
++    if (m_mapObjectsRootNode && !m_mapObjectsRootNode->parent())
+         root->appendChildNode(m_mapObjectsRootNode.get());
+ 
+     if (!m_mapObjectsRootNode) {
+diff --git a/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
+index 5a40467e..d123c6a8 100644
+--- a/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
+@@ -59,8 +59,10 @@ QT_BEGIN_NAMESPACE
+ static const QString kPrefixEsri(QStringLiteral("esri."));
+ static const QString kParamUserAgent(kPrefixEsri + QStringLiteral("useragent"));
+ 
+-static const QString kUrlGeocode(QStringLiteral("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates"));
+-static const QString kUrlReverseGeocode(QStringLiteral("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode"));
++static const QString kUrlGeocode(QStringLiteral("https://geocode.arcgis.com/arcgis/rest/services/"
++                                                "World/GeocodeServer/findAddressCandidates"));
++static const QString kUrlReverseGeocode(QStringLiteral(
++        "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode"));
+ 
+ static QString addressToQuery(const QGeoAddress &address)
+ {
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
+index 17492d94..96c12b1b 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
+@@ -46,7 +46,8 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-// JSON reference: http://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
++// JSON reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
+ 
+ static const QString kErrorMessage(QStringLiteral("Error %1: %2."));
+ static const QString kErrorJson(QStringLiteral("Error: invalide JSON document."));
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
+index 8cadfb29..92b6bb13 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
+@@ -44,7 +44,8 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-// JSON reference: http://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
++// JSON reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
+ 
+ GeoRouteReplyEsri::GeoRouteReplyEsri(QNetworkReply *reply, const QGeoRouteRequest &request,
+                                      QObject *parent) :
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
+index 0e6bc2c7..ed613f4b 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
+@@ -48,7 +48,8 @@ static const QString kPrefixEsri(QStringLiteral("esri."));
+ static const QString kParamUserAgent(kPrefixEsri + QStringLiteral("useragent"));
+ static const QString kParamToken(kPrefixEsri + QStringLiteral("token"));
+ 
+-static const QString kUrlRouting(QStringLiteral("http://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve"));
++static const QString kUrlRouting(QStringLiteral(
++        "https://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve"));
+ 
+ GeoRoutingManagerEngineEsri::GeoRoutingManagerEngineEsri(const QVariantMap &parameters,
+                                                          QGeoServiceProvider::Error *error,
+@@ -70,7 +71,8 @@ GeoRoutingManagerEngineEsri::~GeoRoutingManagerEngineEsri()
+ {
+ }
+ 
+-// REST reference: http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
++// REST reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
+ 
+ QGeoRouteReply *GeoRoutingManagerEngineEsri::calculateRoute(const QGeoRouteRequest &request)
+ {
+@@ -125,7 +127,7 @@ void GeoRoutingManagerEngineEsri::replyError(QGeoRouteReply::Error errorCode, co
+ QString GeoRoutingManagerEngineEsri::preferedDirectionLangage()
+ {
+     // list of supported langages is defined in:
+-    // http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
++    // https://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
+     const QStringList supportedLanguages = {
+         "ar", // Generate directions in Arabic
+         "cs", // Generate directions in Czech
+diff --git a/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
+index 5d15835d..24148f95 100644
+--- a/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
+@@ -230,7 +230,8 @@ QGeoMap *GeoTiledMappingManagerEngineEsri::createMap()
+ // ${y} = Y
+ // ${token} = Token
+ 
+-// template = 'http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{{z}}/{{y}}/{{x}}.png'
++// template =
++// 'https://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{{z}}/{{y}}/{{x}}.png'
+ 
+ bool GeoTiledMappingManagerEngineEsri::initializeMapSources(QGeoServiceProvider::Error *error,
+                                                             QString *errorString,
+diff --git a/qtlocation/src/plugins/geoservices/esri/maps.json b/qtlocation/src/plugins/geoservices/esri/maps.json
+index 8167ae7d..862e087d 100644
+--- a/qtlocation/src/plugins/geoservices/esri/maps.json
++++ b/qtlocation/src/plugins/geoservices/esri/maps.json
+@@ -6,8 +6,8 @@
+             "description": "ArcGIS Online World Street Map",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=3b93337983e9436f8db950e38a8629af'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=3b93337983e9436f8db950e38a8629af'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -16,8 +16,8 @@
+             "": "ArcGIS Online World Imagery",
+             "mobile": true,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -26,8 +26,8 @@
+             "description": "ArcGIS Online World Terrain Base",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=c61ad8ab017d49e1a82f580ee1298931'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=c61ad8ab017d49e1a82f580ee1298931'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -36,8 +36,8 @@
+             "description": "ArcGIS Online World Topography",
+             "mobile": true,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=30e5fe3149c34df1ba922e6f5bbf808f'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=30e5fe3149c34df1ba922e6f5bbf808f'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -46,8 +46,8 @@
+             "description": "This map presents land cover and detailed topographic maps for the United States.",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=99cd5fbd98934028802b4f797c4b1732'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=99cd5fbd98934028802b4f797c4b1732'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -56,8 +56,8 @@
+             "description": "National Geographic World Map",
+             "mobile": false,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=b9b1b422198944fbbd5250b3241691b6'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=b9b1b422198944fbbd5250b3241691b6'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -66,8 +66,8 @@
+             "description": "Thematic content providing a neutral background with minimal colors",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=ed712cb1db3e4bae9e85329040fb9a49'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=ed712cb1db3e4bae9e85329040fb9a49'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -76,8 +76,8 @@
+             "description": "Natural Earth physical map for the world",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=c4ec722a1cd34cf0a23904aadf8923a0'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=c4ec722a1cd34cf0a23904aadf8923a0'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -86,8 +86,8 @@
+             "description": "Portrays surface elevation as shaded relief",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=9c5370d0b54f4de1b48a3792d7377ff2'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=9c5370d0b54f4de1b48a3792d7377ff2'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -96,8 +96,8 @@
+             "description": "This map is designed to be used as a basemap by marine GIS professionals and as a reference map by anyone interested in ocean data",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=1e126e7520f9466c9ca28b8f28b5e500'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=1e126e7520f9466c9ca28b8f28b5e500'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -106,8 +106,8 @@
+             "description": "Thematic content providing a neutral background with minimal colors",
+             "mobile": false,
+             "night": true,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=a284a9b99b3446a3910d4144a50990f6'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=a284a9b99b3446a3910d4144a50990f6'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -116,8 +116,8 @@
+             "description": "DeLorme’s topographic basemap is a seamless global data set that portrays transportation, hydrography, jurisdiction boundaries, and major geographic features",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/Specialty/DeLorme_World_Base_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=b165c3df453e4be6b5ac4fdb241effbe'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/Specialty/DeLorme_World_Base_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=b165c3df453e4be6b5ac4fdb241effbe'>Esri</a> contributors"
+         }
+     ]
+ }
+diff --git a/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
+index 3858ddf5..af66f28e 100644
+--- a/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
+@@ -63,8 +63,10 @@ static const QString kCountriesKey(QStringLiteral("detailedCountries"));
+ static const QString kLocalizedNamesKey(QStringLiteral("localizedNames"));
+ static const QString kMaxLocationsKey(QStringLiteral("maxLocations"));
+ 
+-static const QUrl kUrlGeocodeServer("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer?f=pjson");
+-static const QUrl kUrlFindAddressCandidates("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates");
++static const QUrl kUrlGeocodeServer(
++        "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer?f=pjson");
++static const QUrl kUrlFindAddressCandidates("https://geocode.arcgis.com/arcgis/rest/services/World/"
++                                            "GeocodeServer/findAddressCandidates");
+ 
+ PlaceManagerEngineEsri::PlaceManagerEngineEsri(const QVariantMap &parameters, QGeoServiceProvider::Error *error,
+                                                QString *errorString) :
+Submodule qtmultimedia f0344079..0d7cc33a:
+diff --git a/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp b/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
+index 2b5325132..b68b4af1b 100644
+--- a/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
++++ b/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
+@@ -402,6 +402,8 @@ int QPulseAudioInput::bytesReady() const
+ 
+ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ {
++    Q_ASSERT(data != nullptr || len == 0);
++
+     m_bytesAvailable = checkBytesReady();
+ 
+     setError(QAudio::NoError);
+@@ -411,7 +413,8 @@ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ 
+     if (!m_pullMode && !m_tempBuffer.isEmpty()) {
+         readBytes = qMin(static_cast<int>(len), m_tempBuffer.size());
+-        memcpy(data, m_tempBuffer.constData(), readBytes);
++        if (readBytes)
++            memcpy(data, m_tempBuffer.constData(), readBytes);
+         m_totalTimeValue += readBytes;
+ 
+         if (readBytes < m_tempBuffer.size()) {
+@@ -502,9 +505,10 @@ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ 
+ void QPulseAudioInput::applyVolume(const void *src, void *dest, int len)
+ {
++    Q_ASSERT((src && dest) || len == 0);
+     if (m_volume < 1.f)
+         QAudioHelperInternal::qMultiplySamples(m_volume, m_format, src, dest, len);
+-    else
++    else if (len)
+         memcpy(dest, src, len);
+ }
+ 
+Submodule qtpim 02efef5e...f9a8f0fc (commits not present)
+Submodule qtquick3d b85cf622..47defc8b:
+diff --git a/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro b/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
+index ca5c499e..174a075b 100644
+--- a/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
++++ b/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
+@@ -10,7 +10,7 @@ QT_FOR_CONFIG += assetimporters-private
+ include($$OUT_PWD/../qtassetimporters-config.pri)
+ 
+ qtConfig(system-assimp):!if(cross_compile:host_build) {
+-    QMAKE_USE_PRIVATE += assimp
++    QMAKE_USE_PRIVATE += quick3d-assimp
+ } else {
+     include(../../../3rdparty/assimp/assimp.pri)
+ }
+Submodule qtquickcontrols2 3a657dc0..56ce8233:
+diff --git a/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp b/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
+index e5fe734f7..e36922775 100644
+--- a/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
++++ b/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
+@@ -38,6 +38,7 @@
+ #include "qwidgetplatformmenuitem_p.h"
+ 
+ #include <QtGui/qwindow.h>
++#include <QtGui/private/qhighdpiscaling_p.h>
+ #include <QtWidgets/qmenu.h>
+ #include <QtWidgets/qaction.h>
+ 
+@@ -145,7 +146,7 @@ void QWidgetPlatformMenu::showPopup(const QWindow *window, const QRect &targetRe
+ 
+     QPoint targetPos = targetRect.bottomLeft();
+     if (window)
+-        targetPos = window->mapToGlobal(targetPos);
++        targetPos = window->mapToGlobal(QHighDpi::fromNativeLocalPosition(targetPos, window));
+ 
+     const QWidgetPlatformMenuItem *widgetItem = qobject_cast<const QWidgetPlatformMenuItem *>(item);
+     m_menu->popup(targetPos, widgetItem ? widgetItem->action() : nullptr);
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
+index 950e4e099..b81fbea0b 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
+@@ -387,6 +387,17 @@ void QQuickAbstractButtonPrivate::itemImplicitHeightChanged(QQuickItem *item)
+         emit q->implicitIndicatorHeightChanged();
+ }
+ 
++void QQuickAbstractButtonPrivate::itemDestroyed(QQuickItem *item)
++{
++    Q_Q(QQuickAbstractButton);
++    QQuickControlPrivate::itemDestroyed(item);
++    if (item == indicator) {
++        indicator = nullptr;
++        emit q->implicitIndicatorWidthChanged();
++        emit q->implicitIndicatorHeightChanged();
++    }
++}
++
+ QQuickAbstractButton *QQuickAbstractButtonPrivate::findCheckedButton() const
+ {
+     Q_Q(const QQuickAbstractButton);
+@@ -1176,6 +1187,12 @@ QAccessible::Role QQuickAbstractButton::accessibleRole() const
+     }
+     return QAccessible::Button;
+ }
++
++void QQuickAbstractButton::accessiblePressAction()
++{
++    Q_D(QQuickAbstractButton);
++    d->trigger();
++}
+ #endif
+ 
+ QT_END_NAMESPACE
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
+index 0fa48980e..ab66220d0 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
+@@ -209,6 +209,7 @@ protected:
+ #if QT_CONFIG(accessibility)
+     void accessibilityActiveChanged(bool active) override;
+     QAccessible::Role accessibleRole() const override;
++    Q_INVOKABLE void accessiblePressAction();
+ #endif
+ 
+ private:
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
+index 9291c1a87..b729720f2 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
+@@ -109,6 +109,7 @@ public:
+ 
+     void itemImplicitWidthChanged(QQuickItem *item) override;
+     void itemImplicitHeightChanged(QQuickItem *item) override;
++    void itemDestroyed(QQuickItem *item) override;
+ 
+     // copied from qabstractbutton.cpp
+     static const int AUTO_REPEAT_DELAY = 300;
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp b/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
+index 2041e7741..8610cdfae 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
+@@ -145,7 +145,7 @@ int QQuickActionPrivate::ShortcutEntry::shortcutId() const
+ 
+ void QQuickActionPrivate::ShortcutEntry::grab(const QKeySequence &shortcut, bool enabled)
+ {
+-    if (shortcut.isEmpty())
++    if (shortcut.isEmpty() || m_shortcutId)
+         return;
+ 
+     Qt::ShortcutContext context = Qt::WindowShortcut; // TODO
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp b/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
+index f38c2b09c..6eed2a024 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
+@@ -225,6 +225,7 @@ void QQuickContainerPrivate::cleanup()
+     QObject::disconnect(contentModel, &QQmlObjectModel::countChanged, q, &QQuickContainer::countChanged);
+     QObject::disconnect(contentModel, &QQmlObjectModel::childrenChanged, q, &QQuickContainer::contentChildrenChanged);
+     delete contentModel;
++    contentModel = nullptr;
+ }
+ 
+ QQuickItem *QQuickContainerPrivate::itemAt(int index) const
+@@ -436,7 +437,7 @@ void QQuickContainerPrivate::contentChildren_clear(QQmlListProperty<QQuickItem>
+ void QQuickContainerPrivate::updateContentWidth()
+ {
+     Q_Q(QQuickContainer);
+-    if (hasContentWidth || qFuzzyCompare(contentWidth, implicitContentWidth))
++    if (hasContentWidth || qFuzzyCompare(contentWidth, implicitContentWidth) || !contentModel)
+         return;
+ 
+     contentWidth = implicitContentWidth;
+@@ -446,7 +447,7 @@ void QQuickContainerPrivate::updateContentWidth()
+ void QQuickContainerPrivate::updateContentHeight()
+ {
+     Q_Q(QQuickContainer);
+-    if (hasContentHeight || qFuzzyCompare(contentHeight, implicitContentHeight))
++    if (hasContentHeight || qFuzzyCompare(contentHeight, implicitContentHeight) || !contentModel)
+         return;
+ 
+     contentHeight = implicitContentHeight;
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp b/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
+index bbbd0e622..1f4b47343 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
+@@ -845,6 +845,13 @@ void QQuickControlPrivate::executeBackground(bool complete)
+         quickCompleteDeferred(q, backgroundName(), background);
+ }
+ 
++/*
++    \internal
++
++    Hides an item that was replaced by a newer one, rather than
++    deleting it, as the item is typically created in QML and hence
++    we don't own it.
++*/
+ void QQuickControlPrivate::hideOldItem(QQuickItem *item)
+ {
+     if (!item)
+@@ -863,6 +870,29 @@ void QQuickControlPrivate::hideOldItem(QQuickItem *item)
+ #endif
+ }
+ 
++/*
++    \internal
++
++    Named "unhide" because it's used for cases where an item
++    that was previously hidden by \l hideOldItem() wants to be
++    shown by a control again, such as a ScrollBar in ScrollView.
++*/
++void QQuickControlPrivate::unhideOldItem(QQuickControl *control, QQuickItem *item)
++{
++    Q_ASSERT(item);
++    qCDebug(lcItemManagement) << "unhiding old item" << item;
++
++    item->setVisible(true);
++    item->setParentItem(control);
++
++#if QT_CONFIG(accessibility)
++    // Add the item back in to the accessibility tree.
++    QQuickAccessibleAttached *accessible = accessibleAttached(item);
++    if (accessible)
++        accessible->setIgnored(false);
++#endif
++}
++
+ void QQuickControlPrivate::updateBaselineOffset()
+ {
+     Q_Q(QQuickControl);
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h b/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
+index 8e979079e..a6e624c91 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
+@@ -173,6 +173,7 @@ public:
+     virtual void executeBackground(bool complete = false);
+ 
+     static void hideOldItem(QQuickItem *item);
++    static void unhideOldItem(QQuickControl *control, QQuickItem *item);
+ 
+     void updateBaselineOffset();
+ 
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp b/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
+index e6db14eb5..6197d1547 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
+@@ -237,7 +237,7 @@ static QRectF alignedRect(Qt::LayoutDirection direction, Qt::Alignment alignment
+ void QQuickDialogButtonBoxPrivate::resizeContent()
+ {
+     Q_Q(QQuickDialogButtonBox);
+-    if (!contentItem)
++    if (!contentItem || !contentModel)
+         return;
+ 
+     QRectF geometry = q->boundingRect().adjusted(q->leftPadding(), q->topPadding(), -q->rightPadding(), -q->bottomPadding());
+@@ -322,6 +322,9 @@ void QQuickDialogButtonBoxPrivate::updateLayout()
+ qreal QQuickDialogButtonBoxPrivate::getContentWidth() const
+ {
+     Q_Q(const QQuickDialogButtonBox);
++    if (!contentModel)
++        return 0;
++
+     const int count = contentModel->count();
+     const qreal totalSpacing = qMax(0, count - 1) * spacing;
+     qreal totalWidth = totalSpacing;
+@@ -341,6 +344,9 @@ qreal QQuickDialogButtonBoxPrivate::getContentWidth() const
+ qreal QQuickDialogButtonBoxPrivate::getContentHeight() const
+ {
+     Q_Q(const QQuickDialogButtonBox);
++    if (!contentModel)
++        return 0;
++
+     const int count = contentModel->count();
+     qreal maxHeight = 0;
+     for (int i = 0; i < count; ++i) {
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp b/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
+index 91bd59184..0ce518f84 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
+@@ -399,8 +399,11 @@ void QQuickOverlay::itemChange(ItemChange change, const ItemChangeData &data)
+     Q_D(QQuickOverlay);
+     QQuickItem::itemChange(change, data);
+ 
+-    if (change == ItemChildAddedChange || change == ItemChildRemovedChange)
++    if (change == ItemChildAddedChange || change == ItemChildRemovedChange) {
+         setVisible(!d->allDrawers.isEmpty() || !childItems().isEmpty());
++        if (data.item->parent() == d->mouseGrabberPopup)
++            d->setMouseGrabberPopup(nullptr);
++    }
+ }
+ 
+ void QQuickOverlay::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp b/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
+index 4e2f509db..1c4b308cd 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
+@@ -797,6 +797,14 @@ void QQuickScrollBarAttachedPrivate::initHorizontal()
+     if (parent && parent == flickable->parentItem())
+         horizontal->stackAfter(flickable);
+ 
++    // If a scroll bar was previously hidden (due to e.g. setting a new contentItem
++    // on a ScrollView), we need to make sure that we un-hide it.
++    // We don't bother checking if the item is actually the old one, because
++    // if it's not, all of the things the function does (setting parent, visibility, etc.)
++    // should be no-ops anyway.
++    if (auto control = qobject_cast<QQuickControl*>(q_ptr->parent()))
++        QQuickControlPrivate::unhideOldItem(control, horizontal);
++
+     layoutHorizontal();
+     horizontal->setSize(area->property("widthRatio").toReal());
+     horizontal->setPosition(area->property("xPosition").toReal());
+@@ -818,6 +826,9 @@ void QQuickScrollBarAttachedPrivate::initVertical()
+     if (parent && parent == flickable->parentItem())
+         vertical->stackAfter(flickable);
+ 
++    if (auto control = qobject_cast<QQuickControl*>(q_ptr->parent()))
++        QQuickControlPrivate::unhideOldItem(control, vertical);
++
+     layoutVertical();
+     vertical->setSize(area->property("heightRatio").toReal());
+     vertical->setPosition(area->property("yPosition").toReal());
+diff --git a/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml b/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
+index 0e8b08352..cd4931184 100644
+--- a/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
++++ b/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
+@@ -576,4 +576,51 @@ TestCase {
+         verify(newHorizontalScrollBar.visible)
+         verify(!oldHorizontalScrollBar.visible)
+     }
++
++    Component {
++        id: bindingToContentItemAndStandaloneFlickable
++
++        Item {
++            width: 200
++            height: 200
++
++            property alias scrollView: scrollView
++
++            ScrollView {
++                id: scrollView
++                anchors.fill: parent
++                contentItem: listView
++
++                property Item someBinding: contentItem
++            }
++            ListView {
++                id: listView
++                model: 10
++                delegate: ItemDelegate {
++                    text: modelData
++                    width: listView.width
++                }
++            }
++        }
++    }
++
++    // Tests that scroll bars show up for a ScrollView where
++    // - its contentItem is declared as a standalone, separate item
++    // - there is a binding to contentItem (which causes a default Flickable to be created)
++    function test_bindingToContentItemAndStandaloneFlickable() {
++        let root = createTemporaryObject(bindingToContentItemAndStandaloneFlickable, testCase)
++        verify(root)
++
++        let control = root.scrollView
++        let verticalScrollBar = control.ScrollBar.vertical
++        let horizontalScrollBar = control.ScrollBar.horizontal
++        compare(verticalScrollBar.parent, control)
++        compare(horizontalScrollBar.parent, control)
++        verify(verticalScrollBar.visible)
++        verify(horizontalScrollBar.visible)
++
++        mouseDrag(verticalScrollBar, verticalScrollBar.width / 2, verticalScrollBar.height / 2, 0, 50)
++        verify(verticalScrollBar.active)
++        verify(horizontalScrollBar.active)
++    }
+ }
+diff --git a/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml b/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
+index b3fab41ca..10b6baa02 100644
+--- a/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
++++ b/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
+@@ -608,4 +608,27 @@ TestCase {
+         mouseClick(control.indicator)
+         verify(control.activeFocus)
+     }
++
++    Component {
++        id: deletionOrder1
++        Item {
++            Image { id: innerImage }
++            Switch { indicator: innerImage }
++        }
++    }
++
++    Component {
++        id: deletionOrder2
++        Item {
++            Switch { indicator: innerImage }
++            Image { id: innerImage }
++        }
++    }
++
++    function test_deletionOrder() {
++        var control1 = createTemporaryObject(deletionOrder1, testCase)
++        verify(control1)
++        var control2 = createTemporaryObject(deletionOrder2, testCase)
++        verify(control2)
++    }
+ }
+diff --git a/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml b/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml
+new file mode 100644
+index 000000000..9e4598b9f
+--- /dev/null
++++ b/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml
+@@ -0,0 +1,78 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the test suite of the Qt Toolkit.
++**
++** $QT_BEGIN_LICENSE:BSD$
++** Commercial License Usage
++** Licensees holding valid commercial Qt licenses may use this file in
++** accordance with the commercial license agreement provided with the
++** Software or, alternatively, in accordance with the terms contained in
++** a written agreement between you and The Qt Company. For licensing terms
++** and conditions see https://www.qt.io/terms-conditions. For further
++** information use the contact form at https://www.qt.io/contact-us.
++**
++** BSD License Usage
++** Alternatively, you may use this file under the terms of the BSD license
++** as follows:
++**
++** "Redistribution and use in source and binary forms, with or without
++** modification, are permitted provided that the following conditions are
++** met:
++**   * Redistributions of source code must retain the above copyright
++**     notice, this list of conditions and the following disclaimer.
++**   * Redistributions in binary form must reproduce the above copyright
++**     notice, this list of conditions and the following disclaimer in
++**     the documentation and/or other materials provided with the
++**     distribution.
++**   * Neither the name of The Qt Company Ltd nor the names of its
++**     contributors may be used to endorse or promote products derived
++**     from this software without specific prior written permission.
++**
++**
++** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
++** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
++** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
++** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
++** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
++** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
++** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
++** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
++** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
++** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
++** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
++**
++** $QT_END_LICENSE$
++**
++****************************************************************************/
++
++import QtQuick 2.15
++import QtQuick.Controls 2.15
++
++ApplicationWindow {
++    id: window
++    width: 400
++    height: 400
++    title: "releaseAfterExitTransition"
++
++    property alias popup: popup
++    property alias modalPopup: modalPopup
++
++    Popup {
++        id: popup
++        y: parent.height - height
++        width: 50
++        height: 50
++    }
++
++    Popup {
++        id: modalPopup
++        modal: true
++        y: parent.height - height
++        width: 50
++        height: 50
++        exit:  Transition { PauseAnimation { duration: 100 } }
++    }
++}
+diff --git a/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp b/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
+index 54952d128..3d50e2dd4 100644
+--- a/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
++++ b/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
+@@ -100,6 +100,7 @@ private slots:
+     void invisibleToolTipOpen();
+     void centerInOverlayWithinStackViewItem();
+     void destroyDuringExitTransition();
++    void releaseAfterExitTransition();
+ };
+ 
+ void tst_QQuickPopup::initTestCase()
+@@ -1575,6 +1576,34 @@ void tst_QQuickPopup::destroyDuringExitTransition()
+     QVERIFY(!button->isDown());
+ }
+ 
++void tst_QQuickPopup::releaseAfterExitTransition()
++{
++    QQuickApplicationHelper helper(this, "releaseAfterExitTransition.qml");
++    QVERIFY2(helper.ready, helper.failureMessage());
++
++    QQuickWindow *window = helper.window;
++    window->show();
++    QVERIFY(QTest::qWaitForWindowActive(window));
++
++    QQuickOverlay *overlay = QQuickOverlay::overlay(window);
++    QQuickPopup *modalPopup = window->property("modalPopup").value<QQuickPopup *>();
++    QQuickPopup *popup = window->property("popup").value<QQuickPopup *>();
++
++    modalPopup->open();
++    QTRY_VERIFY(modalPopup->isOpened());
++
++    QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++    // wait until the transition is finished and the overlay hides itself
++    QTRY_VERIFY(!overlay->isVisible());
++    QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++
++    popup->open();
++    QTRY_VERIFY(popup->isOpened());
++    QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++    QTRY_VERIFY(!popup->isOpened());
++}
++
++
+ QTEST_QUICKCONTROLS_MAIN(tst_QQuickPopup)
+ 
+ #include "tst_qquickpopup.moc"
+Submodule qtscript 5be95f96...4d8e4bd2 (commits not present)
+Submodule qtspeech 17fc9fde..255845e2:
+diff --git a/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp b/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
+index 6eb74b8..bcc7dd1 100644
+--- a/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
++++ b/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
+@@ -357,7 +357,9 @@ QVector<QLocale> QTextToSpeechEngineSpeechd::availableLocales() const
+ 
+ QVector<QVoice> QTextToSpeechEngineSpeechd::availableVoices() const
+ {
+-    return m_voices.values(m_currentLocale.name()).toVector();
++    QList<QVoice> resultList = m_voices.values(m_currentLocale.name());
++    std::reverse(resultList.begin(), resultList.end());
++    return resultList.toVector();
+ }
+ 
+ // We have no way of knowing our own client_id since speech-dispatcher seems to be incomplete
+Submodule qtsvg 0c05780e..a7a0f249:
+diff --git a/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp b/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
+index 561e77e..12e0574 100644
+--- a/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
++++ b/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
+@@ -191,6 +191,8 @@ bool QSvgIOHandler::read(QImage *image)
+             }
+         }
+         if (!finalSize.isEmpty()) {
++            if (qMax(finalSize.width(), finalSize.height()) > 0xffff)
++                return false; // Assume corrupted file
+             image->fill(d->backColor.rgba());
+             QPainter p(image);
+             d->r.render(&p, bounds);
+diff --git a/qtsvg/src/svg/qsvghandler.cpp b/qtsvg/src/svg/qsvghandler.cpp
+index a5f877f..8dda563 100644
+--- a/qtsvg/src/svg/qsvghandler.cpp
++++ b/qtsvg/src/svg/qsvghandler.cpp
+@@ -1393,9 +1393,10 @@ static void parseFont(QSvgNode *node,
+         case FontSizeNone:
+             break;
+         case FontSizeValue: {
+-            QSvgHandler::LengthType dummy; // should always be pixel size
+-            fontStyle->setSize(qMin(parseLength(attributes.fontSize, dummy, handler),
+-                                    qreal(0xffff)));
++            QSvgHandler::LengthType type;
++            qreal fs = parseLength(attributes.fontSize, type, handler);
++            fs = convertToPixels(fs, true, type);
++            fontStyle->setSize(qMin(fs, qreal(0xffff)));
+         }
+             break;
+         default:
+@@ -2513,6 +2514,8 @@ static bool parseAnimateTransformNode(QSvgNode *parent,
+             ++s;
+         }
+     }
++    if (vals.count() % 3 != 0)
++        return false;
+ 
+     bool ok = true;
+     int begin = parseClockValue(beginStr, &ok);
+@@ -2576,6 +2579,8 @@ static QSvgNode *createCircleNode(QSvgNode *parent,
+     qreal ncx = toDouble(cx);
+     qreal ncy = toDouble(cy);
+     qreal nr  = toDouble(r);
++    if (nr < 0.0)
++        return nullptr;
+ 
+     QRectF rect(ncx-nr, ncy-nr, nr*2, nr*2);
+     QSvgNode *circle = new QSvgCircle(parent, rect);
+@@ -3046,15 +3051,16 @@ static QSvgStyleProperty *createRadialGradientNode(QSvgNode *node,
+ 
+     qreal ncx = 0.5;
+     qreal ncy = 0.5;
+-    qreal nr  = 0.5;
+     if (!cx.isEmpty())
+         ncx = toDouble(cx);
+     if (!cy.isEmpty())
+         ncy = toDouble(cy);
++
++    qreal nr = 0.0;
+     if (!r.isEmpty())
+         nr = toDouble(r);
+-    if (nr < 0.5)
+-        nr = 0.5;
++    if (nr <= 0.0)
++        return nullptr;
+ 
+     qreal nfx = ncx;
+     if (!fx.isEmpty())
+@@ -3350,7 +3356,9 @@ static QSvgNode *createTextNode(QSvgNode *parent,
+     //### editable and rotate not handled
+     QSvgHandler::LengthType type;
+     qreal nx = parseLength(x, type, handler);
++    nx = convertToPixels(nx, true, type);
+     qreal ny = parseLength(y, type, handler);
++    ny = convertToPixels(ny, true, type);
+ 
+     QSvgNode *text = new QSvgText(parent, QPointF(nx, ny));
+     return text;
+@@ -3691,9 +3699,7 @@ void QSvgHandler::parse()
+         case QXmlStreamReader::EndElement:
+             endElement(xml->name());
+             ++remainingUnfinishedElements;
+-            // if we are using somebody else's qxmlstreamreader
+-            // we should not read until the end of the stream
+-            done = !m_ownsReader && (xml->name() == QLatin1String("svg"));
++            done = (xml->name() == QLatin1String("svg"));
+             break;
+         case QXmlStreamReader::Characters:
+             characters(xml->text());
+diff --git a/qtsvg/src/svg/qsvgstructure.cpp b/qtsvg/src/svg/qsvgstructure.cpp
+index b89608b..89c9e4e 100644
+--- a/qtsvg/src/svg/qsvgstructure.cpp
++++ b/qtsvg/src/svg/qsvgstructure.cpp
+@@ -255,9 +255,13 @@ inline static bool isSupportedSvgFeature(const QString &str)
+     };
+ 
+     if (str.length() <= MAX_WORD_LENGTH && str.length() >= MIN_WORD_LENGTH) {
++        const char16_t unicode44 = str.at(44).unicode();
++        const char16_t unicode45 = str.at(45).unicode();
++        if (unicode44 >= sizeof(asso_values) || unicode45 >= sizeof(asso_values))
++            return false;
+         const int key = str.length()
+-                        + asso_values[str.at(45).unicode()]
+-                        + asso_values[str.at(44).unicode()];
++                        + asso_values[unicode45]
++                        + asso_values[unicode44];
+         if (key <= MAX_HASH_VALUE && key >= 0)
+             return str == QLatin1String(wordlist[key]);
+     }
+diff --git a/qtsvg/src/svg/qsvgtinydocument.cpp b/qtsvg/src/svg/qsvgtinydocument.cpp
+index 63d0797..19e7154 100644
+--- a/qtsvg/src/svg/qsvgtinydocument.cpp
++++ b/qtsvg/src/svg/qsvgtinydocument.cpp
+@@ -433,8 +433,16 @@ void QSvgTinyDocument::draw(QPainter *p, QSvgExtraStates &)
+     draw(p);
+ }
+ 
++static bool isValidMatrix(const QTransform &transform)
++{
++    qreal determinant = transform.determinant();
++    return qIsFinite(determinant);
++}
++
+ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect, const QRectF &sourceRect)
+ {
++    QTransform oldTransform = p->worldTransform();
++
+     QRectF target = targetRect;
+     if (target.isEmpty()) {
+         QPaintDevice *dev = p->device();
+@@ -487,6 +495,9 @@ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect,
+         }
+ #endif
+     }
++
++    if (!isValidMatrix(p->worldTransform()))
++        p->setWorldTransform(oldTransform);
+ }
+ 
+ QRectF QSvgTinyDocument::boundsOnElement(const QString &id) const
+diff --git a/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp b/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
+index 36c76ec..db71e02 100644
+--- a/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
++++ b/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
+@@ -86,6 +86,8 @@ private slots:
+     void oss_fuzz_23731();
+     void oss_fuzz_24131();
+     void oss_fuzz_24738();
++    void illegalAnimateTransform_data();
++    void illegalAnimateTransform();
+ 
+ #ifndef QT_NO_COMPRESS
+     void testGzLoading();
+@@ -1646,5 +1648,22 @@ void tst_QSvgRenderer::oss_fuzz_24738()
+     QSvgRenderer().load(QByteArray("<svg><path d=\"a 2 1e-212.....\">"));
+ }
+ 
++void tst_QSvgRenderer::illegalAnimateTransform_data()
++{
++    QTest::addColumn<QByteArray>("svg");
++
++    QTest::newRow("case1") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" values=\"8,0,5,0\">");
++    QTest::newRow("case2") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" values=\"1,2\">");
++    QTest::newRow("case3") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" from=\".. 5 2\" to=\"f\">");
++    QTest::newRow("case4") << QByteArray("<svg><animateTransform type=\"scale\" begin=\"1\" dur=\"2\" by=\"--,..\">");
++}
++
++void tst_QSvgRenderer::illegalAnimateTransform()
++{
++    QFETCH(QByteArray, svg);
++    QSvgRenderer renderer;
++    QVERIFY(!renderer.load(svg)); // also shouldn't assert
++}
++
+ QTEST_MAIN(tst_QSvgRenderer)
+ #include "tst_qsvgrenderer.moc"
+Submodule qttools 6914f7c8..090e526e:
+diff --git a/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp b/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
+index feab1e2d5..cbfb82507 100644
+--- a/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
++++ b/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
+@@ -445,7 +445,9 @@ bool HelpGeneratorPrivate::insertFiles(const QStringList &files, const QString &
+     if (filterSetId < 0)
+         return false;
+     ++filterSetId;
+-    for (int attId : qAsConst(filterAtts)) {
++    QList<int> attValues = filterAtts.values();
++    std::sort(attValues.begin(), attValues.end());
++    for (int attId : qAsConst(attValues)) {
+         m_query->prepare(QLatin1String("INSERT INTO FileAttributeSetTable "
+             "VALUES(?, ?)"));
+         m_query->bindValue(0, filterSetId);
+Submodule qtwayland dfb0129c..2904e1b3:
+diff --git a/qtwayland/src/client/configure.json b/qtwayland/src/client/configure.json
+index 2f424580..29222357 100644
+--- a/qtwayland/src/client/configure.json
++++ b/qtwayland/src/client/configure.json
+@@ -149,8 +149,7 @@
+                     "#endif"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "vulkan-server-buffer": {
+             "label": "Vulkan Buffer Sharing",
+@@ -168,7 +167,8 @@
+                     "exportAllocInfo.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR;",
+                     "return 0;"
+                 ]
+-            }
++            },
++            "use": "wayland-client"
+         },
+         "egl_1_5-wayland": {
+             "label": "EGL 1.5 with Wayland Platform",
+@@ -183,7 +183,7 @@
+                     "eglGetPlatformDisplay(EGL_PLATFORM_WAYLAND_EXT, (struct wl_display *)(nullptr), nullptr);"
+                 ]
+             },
+-            "use": "egl"
++            "use": "egl wayland-client"
+         }
+     },
+ 
+diff --git a/qtwayland/src/client/global/qwaylandclientextension.cpp b/qtwayland/src/client/global/qwaylandclientextension.cpp
+index 125b1e19..edccfe63 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension.cpp
++++ b/qtwayland/src/client/global/qwaylandclientextension.cpp
+@@ -74,7 +74,10 @@ void QWaylandClientExtensionPrivate::handleRegistryGlobal(void *data, ::wl_regis
+ void QWaylandClientExtension::addRegistryListener()
+ {
+     Q_D(QWaylandClientExtension);
+-    d->waylandIntegration->display()->addRegistryListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++    if (!d->registered) {
++        d->waylandIntegration->display()->addRegistryListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++        d->registered = true;
++    }
+ }
+ 
+ QWaylandClientExtension::QWaylandClientExtension(const int ver)
+@@ -88,6 +91,13 @@ QWaylandClientExtension::QWaylandClientExtension(const int ver)
+     QMetaObject::invokeMethod(this, "addRegistryListener", Qt::QueuedConnection);
+ }
+ 
++QWaylandClientExtension::~QWaylandClientExtension()
++{
++    Q_D(QWaylandClientExtension);
++    if (d->registered && !QCoreApplication::closingDown())
++        d->waylandIntegration->display()->removeListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++}
++
+ QtWaylandClient::QWaylandIntegration *QWaylandClientExtension::integration() const
+ {
+     Q_D(const QWaylandClientExtension);
+diff --git a/qtwayland/src/client/global/qwaylandclientextension.h b/qtwayland/src/client/global/qwaylandclientextension.h
+index 98272e57..5bd28398 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension.h
++++ b/qtwayland/src/client/global/qwaylandclientextension.h
+@@ -63,6 +63,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandClientExtension : public QObject
+     Q_PROPERTY(bool active READ isActive NOTIFY activeChanged)
+ public:
+     QWaylandClientExtension(const int version);
++    ~QWaylandClientExtension();
+ 
+     QtWaylandClient::QWaylandIntegration *integration() const;
+     int version() const;
+diff --git a/qtwayland/src/client/global/qwaylandclientextension_p.h b/qtwayland/src/client/global/qwaylandclientextension_p.h
+index 69cc46a0..9091efbe 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension_p.h
++++ b/qtwayland/src/client/global/qwaylandclientextension_p.h
+@@ -68,6 +68,7 @@ public:
+     QtWaylandClient::QWaylandIntegration *waylandIntegration = nullptr;
+     int version = -1;
+     bool active = false;
++    bool registered = false;
+ };
+ 
+ class Q_WAYLAND_CLIENT_EXPORT QWaylandClientExtensionTemplatePrivate : public QWaylandClientExtensionPrivate
+diff --git a/qtwayland/src/client/qwaylanddatadevice.cpp b/qtwayland/src/client/qwaylanddatadevice.cpp
+index 7e2e3308..e3e60ed5 100644
+--- a/qtwayland/src/client/qwaylanddatadevice.cpp
++++ b/qtwayland/src/client/qwaylanddatadevice.cpp
+@@ -72,6 +72,8 @@ QWaylandDataDevice::QWaylandDataDevice(QWaylandDataDeviceManager *manager, QWayl
+ 
+ QWaylandDataDevice::~QWaylandDataDevice()
+ {
++    if (wl_data_device_get_version(object()) >= WL_DATA_DEVICE_RELEASE_SINCE_VERSION)
++        release();
+ }
+ 
+ QWaylandDataOffer *QWaylandDataDevice::selectionOffer() const
+@@ -110,7 +112,7 @@ QWaylandDataOffer *QWaylandDataDevice::dragOffer() const
+     return m_dragOffer.data();
+ }
+ 
+-bool QWaylandDataDevice::startDrag(QMimeData *mimeData, QWaylandWindow *icon)
++bool QWaylandDataDevice::startDrag(QMimeData *mimeData, Qt::DropActions supportedActions, QWaylandWindow *icon)
+ {
+     auto *seat = m_display->currentInputDevice();
+     auto *origin = seat->pointerFocus();
+@@ -123,7 +125,28 @@ bool QWaylandDataDevice::startDrag(QMimeData *mimeData, QWaylandWindow *icon)
+     }
+ 
+     m_dragSource.reset(new QWaylandDataSource(m_display->dndSelectionHandler(), mimeData));
++
++    if (wl_data_device_get_version(object()) >= 3)
++        m_dragSource->set_actions(dropActionsToWl(supportedActions));
++
+     connect(m_dragSource.data(), &QWaylandDataSource::cancelled, this, &QWaylandDataDevice::dragSourceCancelled);
++    connect(m_dragSource.data(), &QWaylandDataSource::dndResponseUpdated, this, [this](bool accepted, Qt::DropAction action) {
++            auto drag = static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag());
++            // in old versions drop action is not set, so we guess
++            if (wl_data_source_get_version(m_dragSource->object()) < 3) {
++                drag->setResponse(accepted);
++            } else {
++                QPlatformDropQtResponse response(accepted, action);
++                drag->setResponse(response);
++            }
++    });
++    connect(m_dragSource.data(), &QWaylandDataSource::dndDropped, this, [](bool accepted, Qt::DropAction action) {
++        QPlatformDropQtResponse response(accepted, action);
++        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setDropResponse(response);
++    });
++    connect(m_dragSource.data(), &QWaylandDataSource::finished, this, []() {
++        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag();
++    });
+ 
+     start_drag(m_dragSource->object(), origin->wlSurface(), icon->wlSurface(), m_display->currentInputDevice()->serial());
+     return true;
+@@ -152,7 +175,7 @@ void QWaylandDataDevice::data_device_drop()
+         supportedActions = drag->supportedActions();
+     } else if (m_dragOffer) {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     } else {
+         return;
+     }
+@@ -162,7 +185,11 @@ void QWaylandDataDevice::data_device_drop()
+                                                                           QGuiApplication::keyboardModifiers());
+ 
+     if (drag) {
+-        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag(response);
++        auto drag =  static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag());
++        drag->setDropResponse(response);
++        drag->finishDrag();
++    } else if (m_dragOffer) {
++        m_dragOffer->finish();
+     }
+ }
+ 
+@@ -186,7 +213,7 @@ void QWaylandDataDevice::data_device_enter(uint32_t serial, wl_surface *surface,
+         supportedActions = drag->supportedActions();
+     } else if (m_dragOffer) {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     }
+ 
+     const QPlatformDragQtResponse &response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
+@@ -197,11 +224,7 @@ void QWaylandDataDevice::data_device_enter(uint32_t serial, wl_surface *surface,
+         static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setResponse(response);
+     }
+ 
+-    if (response.isAccepted()) {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, m_dragOffer->firstFormat().toUtf8().constData());
+-    } else {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, nullptr);
+-    }
++    sendResponse(supportedActions, response);
+ }
+ 
+ void QWaylandDataDevice::data_device_leave()
+@@ -235,10 +258,10 @@ void QWaylandDataDevice::data_device_motion(uint32_t time, wl_fixed_t x, wl_fixe
+         supportedActions = drag->supportedActions();
+     } else {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     }
+ 
+-    QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
++    const QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
+                                                                           QGuiApplication::mouseButtons(),
+                                                                           QGuiApplication::keyboardModifiers());
+ 
+@@ -246,11 +269,7 @@ void QWaylandDataDevice::data_device_motion(uint32_t time, wl_fixed_t x, wl_fixe
+         static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setResponse(response);
+     }
+ 
+-    if (response.isAccepted()) {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, m_dragOffer->firstFormat().toUtf8().constData());
+-    } else {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, nullptr);
+-    }
++    sendResponse(supportedActions, response);
+ }
+ #endif // QT_CONFIG(draganddrop)
+ 
+@@ -277,14 +296,10 @@ void QWaylandDataDevice::selectionSourceCancelled()
+ #if QT_CONFIG(draganddrop)
+ void QWaylandDataDevice::dragSourceCancelled()
+ {
++    static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag();
+     m_dragSource.reset();
+ }
+ 
+-void QWaylandDataDevice::dragSourceTargetChanged(const QString &mimeType)
+-{
+-    static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->updateTarget(mimeType);
+-}
+-
+ QPoint QWaylandDataDevice::calculateDragPosition(int x, int y, QWindow *wnd) const
+ {
+     QPoint pnt(wl_fixed_to_int(x), wl_fixed_to_int(y));
+@@ -297,6 +312,33 @@ QPoint QWaylandDataDevice::calculateDragPosition(int x, int y, QWindow *wnd) con
+     }
+     return pnt;
+ }
++
++void QWaylandDataDevice::sendResponse(Qt::DropActions supportedActions, const QPlatformDragQtResponse &response)
++{
++    if (response.isAccepted()) {
++        if (wl_data_device_get_version(object()) >= 3)
++            m_dragOffer->set_actions(dropActionsToWl(supportedActions), dropActionsToWl(response.acceptedAction()));
++
++        m_dragOffer->accept(m_enterSerial, m_dragOffer->firstFormat());
++    } else {
++        m_dragOffer->accept(m_enterSerial, QString());
++    }
++}
++
++int QWaylandDataDevice::dropActionsToWl(Qt::DropActions actions)
++{
++
++    int wlActions = WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE;
++    if (actions & Qt::CopyAction)
++        wlActions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY;
++    if (actions & (Qt::MoveAction | Qt::TargetMoveAction))
++        wlActions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE;
++
++    // wayland does not support LinkAction at the time of writing
++    return wlActions;
++}
++
++
+ #endif // QT_CONFIG(draganddrop)
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddatadevice_p.h b/qtwayland/src/client/qwaylanddatadevice_p.h
+index 16c3ad28..801dcc2c 100644
+--- a/qtwayland/src/client/qwaylanddatadevice_p.h
++++ b/qtwayland/src/client/qwaylanddatadevice_p.h
+@@ -64,6 +64,7 @@ QT_REQUIRE_CONFIG(wayland_datadevice);
+ QT_BEGIN_NAMESPACE
+ 
+ class QMimeData;
++class QPlatformDragQtResponse;
+ class QWindow;
+ 
+ namespace QtWaylandClient {
+@@ -89,7 +90,7 @@ public:
+ 
+ #if QT_CONFIG(draganddrop)
+     QWaylandDataOffer *dragOffer() const;
+-    bool startDrag(QMimeData *mimeData, QWaylandWindow *icon);
++    bool startDrag(QMimeData *mimeData, Qt::DropActions supportedActions, QWaylandWindow *icon);
+     void cancelDrag();
+ #endif
+ 
+@@ -109,13 +110,16 @@ private Q_SLOTS:
+ 
+ #if QT_CONFIG(draganddrop)
+     void dragSourceCancelled();
+-    void dragSourceTargetChanged(const QString &mimeType);
+ #endif
+ 
+ private:
+ #if QT_CONFIG(draganddrop)
+     QPoint calculateDragPosition(int x, int y, QWindow *wnd) const;
+ #endif
++    void sendResponse(Qt::DropActions supportedActions, const QPlatformDragQtResponse &response);
++
++    static int dropActionsToWl(Qt::DropActions dropActions);
++
+ 
+     QWaylandDisplay *m_display = nullptr;
+     QWaylandInputDevice *m_inputDevice = nullptr;
+diff --git a/qtwayland/src/client/qwaylanddatadevicemanager.cpp b/qtwayland/src/client/qwaylanddatadevicemanager.cpp
+index 35d67307..6dc4f77f 100644
+--- a/qtwayland/src/client/qwaylanddatadevicemanager.cpp
++++ b/qtwayland/src/client/qwaylanddatadevicemanager.cpp
+@@ -50,8 +50,8 @@ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
+-QWaylandDataDeviceManager::QWaylandDataDeviceManager(QWaylandDisplay *display, uint32_t id)
+-    : wl_data_device_manager(display->wl_registry(), id, 1)
++QWaylandDataDeviceManager::QWaylandDataDeviceManager(QWaylandDisplay *display, int version, uint32_t id)
++    : wl_data_device_manager(display->wl_registry(), id, qMin(version, 3))
+     , m_display(display)
+ {
+     // Create transfer devices for all input devices.
+diff --git a/qtwayland/src/client/qwaylanddatadevicemanager_p.h b/qtwayland/src/client/qwaylanddatadevicemanager_p.h
+index bd05c0fb..510d9be4 100644
+--- a/qtwayland/src/client/qwaylanddatadevicemanager_p.h
++++ b/qtwayland/src/client/qwaylanddatadevicemanager_p.h
+@@ -68,7 +68,7 @@ class QWaylandInputDevice;
+ class Q_WAYLAND_CLIENT_EXPORT QWaylandDataDeviceManager : public QtWayland::wl_data_device_manager
+ {
+ public:
+-    QWaylandDataDeviceManager(QWaylandDisplay *display, uint32_t id);
++    QWaylandDataDeviceManager(QWaylandDisplay *display, int version, uint32_t id);
+     ~QWaylandDataDeviceManager() override;
+ 
+     QWaylandDataDevice *getDataDevice(QWaylandInputDevice *inputDevice);
+diff --git a/qtwayland/src/client/qwaylanddataoffer.cpp b/qtwayland/src/client/qwaylanddataoffer.cpp
+index 2297e8a1..fe0ea8c9 100644
+--- a/qtwayland/src/client/qwaylanddataoffer.cpp
++++ b/qtwayland/src/client/qwaylanddataoffer.cpp
+@@ -82,6 +82,15 @@ QMimeData *QWaylandDataOffer::mimeData()
+     return m_mimeData.data();
+ }
+ 
++Qt::DropActions QWaylandDataOffer::supportedActions() const
++{
++    if (wl_data_offer_get_version(const_cast<::wl_data_offer*>(object())) < 3) {
++        return Qt::MoveAction | Qt::CopyAction;
++    }
++
++    return m_supportedActions;
++}
++
+ void QWaylandDataOffer::startReceiving(const QString &mimeType, int fd)
+ {
+     receive(mimeType, fd);
+@@ -93,6 +102,22 @@ void QWaylandDataOffer::data_offer_offer(const QString &mime_type)
+     m_mimeData->appendFormat(mime_type);
+ }
+ 
++void QWaylandDataOffer::data_offer_action(uint32_t dnd_action)
++{
++    Q_UNUSED(dnd_action);
++    // This is the compositor telling the drag target what action it should perform
++    // It does not map nicely into Qt final drop semantics, other than pretending there is only one supported action?
++}
++
++void QWaylandDataOffer::data_offer_source_actions(uint32_t source_actions)
++{
++    m_supportedActions = Qt::DropActions();
++    if (source_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
++        m_supportedActions |= Qt::MoveAction;
++    if (source_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
++        m_supportedActions |= Qt::CopyAction;
++}
++
+ QWaylandMimeData::QWaylandMimeData(QWaylandAbstractDataOffer *dataOffer)
+     : m_dataOffer(dataOffer)
+ {
+@@ -163,17 +188,18 @@ QVariant QWaylandMimeData::retrieveData_sys(const QString &mimeType, QVariant::T
+ 
+ int QWaylandMimeData::readData(int fd, QByteArray &data) const
+ {
+-    fd_set readset;
+-    FD_ZERO(&readset);
+-    FD_SET(fd, &readset);
+-    struct timeval timeout;
++    struct pollfd readset;
++    readset.fd = fd;
++    readset.events = POLLIN;
++    struct timespec timeout;
+     timeout.tv_sec = 1;
+-    timeout.tv_usec = 0;
++    timeout.tv_nsec = 0;
++
+ 
+     Q_FOREVER {
+-        int ready = select(FD_SETSIZE, &readset, nullptr, nullptr, &timeout);
++        int ready = qt_safe_poll(&readset, 1, &timeout);
+         if (ready < 0) {
+-            qWarning() << "QWaylandDataOffer: select() failed";
++            qWarning() << "QWaylandDataOffer: qt_safe_poll() failed";
+             return -1;
+         } else if (ready == 0) {
+             qWarning("QWaylandDataOffer: timeout reading from pipe");
+diff --git a/qtwayland/src/client/qwaylanddataoffer_p.h b/qtwayland/src/client/qwaylanddataoffer_p.h
+index 9cf1483c..6f667398 100644
+--- a/qtwayland/src/client/qwaylanddataoffer_p.h
++++ b/qtwayland/src/client/qwaylanddataoffer_p.h
+@@ -82,6 +82,7 @@ public:
+     explicit QWaylandDataOffer(QWaylandDisplay *display, struct ::wl_data_offer *offer);
+     ~QWaylandDataOffer() override;
+     QMimeData *mimeData() override;
++    Qt::DropActions supportedActions() const;
+ 
+     QString firstFormat() const;
+ 
+@@ -89,10 +90,13 @@ public:
+ 
+ protected:
+     void data_offer_offer(const QString &mime_type) override;
++    void data_offer_source_actions(uint32_t source_actions) override;
++    void data_offer_action(uint32_t dnd_action) override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+     QScopedPointer<QWaylandMimeData> m_mimeData;
++    Qt::DropActions m_supportedActions;
+ };
+ 
+ 
+diff --git a/qtwayland/src/client/qwaylanddatasource.cpp b/qtwayland/src/client/qwaylanddatasource.cpp
+index f45122fb..5599cbd4 100644
+--- a/qtwayland/src/client/qwaylanddatasource.cpp
++++ b/qtwayland/src/client/qwaylanddatasource.cpp
+@@ -101,7 +101,32 @@ void QWaylandDataSource::data_source_send(const QString &mime_type, int32_t fd)
+ 
+ void QWaylandDataSource::data_source_target(const QString &mime_type)
+ {
+-    Q_EMIT targetChanged(mime_type);
++    m_accepted = !mime_type.isEmpty();
++    Q_EMIT dndResponseUpdated(m_accepted, m_dropAction);
++}
++
++void QWaylandDataSource::data_source_action(uint32_t action)
++{
++    Qt::DropAction qtAction = Qt::IgnoreAction;
++
++    if (action == WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
++        qtAction = Qt::MoveAction;
++    else if (action == WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
++        qtAction = Qt::CopyAction;
++
++    m_dropAction = qtAction;
++    Q_EMIT dndResponseUpdated(m_accepted, m_dropAction);
++}
++
++void QWaylandDataSource::data_source_dnd_finished()
++{
++    Q_EMIT finished();
++}
++
++void QWaylandDataSource::data_source_dnd_drop_performed()
++{
++
++    Q_EMIT dndDropped(m_accepted, m_dropAction);
+ }
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddatasource_p.h b/qtwayland/src/client/qwaylanddatasource_p.h
+index 25afff79..96f07bc3 100644
+--- a/qtwayland/src/client/qwaylanddatasource_p.h
++++ b/qtwayland/src/client/qwaylanddatasource_p.h
+@@ -77,17 +77,25 @@ public:
+     QMimeData *mimeData() const;
+ 
+ Q_SIGNALS:
+-    void targetChanged(const QString &mime_type);
+     void cancelled();
++    void finished();
++
++    void dndResponseUpdated(bool accepted, Qt::DropAction action);
++    void dndDropped(bool accepted, Qt::DropAction action);
+ 
+ protected:
+     void data_source_cancelled() override;
+     void data_source_send(const QString &mime_type, int32_t fd) override;
+     void data_source_target(const QString &mime_type) override;
++    void data_source_dnd_drop_performed() override;
++    void data_source_dnd_finished() override;
++    void data_source_action(uint32_t action) override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+     QMimeData *m_mime_data = nullptr;
++    bool m_accepted = false;
++    Qt::DropAction m_dropAction = Qt::IgnoreAction;
+ };
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddisplay.cpp b/qtwayland/src/client/qwaylanddisplay.cpp
+index f10c1f79..c01e238b 100644
+--- a/qtwayland/src/client/qwaylanddisplay.cpp
++++ b/qtwayland/src/client/qwaylanddisplay.cpp
+@@ -85,10 +85,203 @@
+ 
+ #include <errno.h>
+ 
++#include <tuple> // for std::tie
++
++static void checkWaylandError(struct wl_display *display)
++{
++    int ecode = wl_display_get_error(display);
++    if ((ecode == EPIPE || ecode == ECONNRESET)) {
++        // special case this to provide a nicer error
++        qWarning("The Wayland connection broke. Did the Wayland compositor die?");
++    } else {
++        qWarning("The Wayland connection experienced a fatal error: %s", strerror(ecode));
++    }
++    _exit(1);
++}
++
+ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
++class EventThread : public QThread
++{
++    Q_OBJECT
++public:
++    enum OperatingMode {
++        EmitToDispatch, // Emit the signal, allow dispatching in a differnt thread.
++        SelfDispatch, // Dispatch the events inside this thread.
++    };
++
++    EventThread(struct wl_display * wl, struct wl_event_queue * ev_queue,
++                OperatingMode mode)
++        : m_fd(wl_display_get_fd(wl))
++        , m_pipefd{ -1, -1 }
++        , m_wldisplay(wl)
++        , m_wlevqueue(ev_queue)
++        , m_mode(mode)
++        , m_reading(true)
++        , m_quitting(false)
++    {
++        setObjectName(QStringLiteral("WaylandEventThread"));
++    }
++
++    void readAndDispatchEvents()
++    {
++        /*
++         * Dispatch pending events and flush the requests at least once. If the event thread
++         * is not reading, try to call _prepare_read() to allow the event thread to poll().
++         * If that fails, re-try dispatch & flush again until _prepare_read() is successful.
++         *
++         * This allow any call to readAndDispatchEvents() to start event thread's polling,
++         * not only the one issued from event thread's waitForReading(), which means functions
++         * called from dispatch_pending() can safely spin an event loop.
++         */
++        for (;;) {
++            if (dispatchQueuePending() < 0) {
++                checkWaylandError(m_wldisplay);
++                return;
++            }
++
++            wl_display_flush(m_wldisplay);
++
++            // We have to check if event thread is reading every time we dispatch
++            // something, as that may recursively call this function.
++            if (m_reading.loadAcquire())
++                break;
++
++            if (prepareReadQueue() == 0) {
++                QMutexLocker l(&m_mutex);
++                m_reading.storeRelease(true);
++                m_cond.wakeOne();
++                break;
++            }
++        }
++    }
++
++    void stop()
++    {
++        // We have to both write to the pipe and set the flag, as the thread may be
++        // either in the poll() or waiting for _prepare_read().
++        if (m_pipefd[1] != -1 && write(m_pipefd[1], "\0", 1) == -1)
++            qWarning("Failed to write to the pipe: %s.", strerror(errno));
++
++        {
++            QMutexLocker l(&m_mutex);
++            m_quitting = true;
++            m_cond.wakeOne();
++        }
++
++        wait();
++    }
++
++Q_SIGNALS:
++    void needReadAndDispatch();
++
++protected:
++    void run() override
++    {
++        // we use this pipe to make the loop exit otherwise if we simply used a flag on the loop condition, if stop() gets
++        // called while poll() is blocking the thread will never quit since there are no wayland messages coming anymore.
++        struct Pipe
++        {
++            Pipe(int *fds)
++                : fds(fds)
++            {
++                if (qt_safe_pipe(fds) != 0)
++                    qWarning("Pipe creation failed. Quitting may hang.");
++            }
++            ~Pipe()
++            {
++                if (fds[0] != -1) {
++                    close(fds[0]);
++                    close(fds[1]);
++                }
++            }
++
++            int *fds;
++        } pipe(m_pipefd);
++
++        // Make the main thread call wl_prepare_read(), dispatch the pending messages and flush the
++        // outbound ones. Wait until it's done before proceeding, unless we're told to quit.
++        while (waitForReading()) {
++            pollfd fds[2] = { { m_fd, POLLIN, 0 }, { m_pipefd[0], POLLIN, 0 } };
++            poll(fds, 2, -1);
++
++            if (fds[1].revents & POLLIN) {
++                // we don't really care to read the byte that was written here since we're closing down
++                wl_display_cancel_read(m_wldisplay);
++                break;
++            }
++
++            if (fds[0].revents & POLLIN)
++                wl_display_read_events(m_wldisplay);
++                // The polll was succesfull and the event thread did the wl_display_read_events(). On the next iteration of the loop
++                // the event sent to the main thread will cause it to dispatch the messages just read, unless the loop exits in which
++                // case we don't care anymore about them.
++            else
++                wl_display_cancel_read(m_wldisplay);
++        }
++    }
++
++private:
++    bool waitForReading()
++    {
++        Q_ASSERT(QThread::currentThread() == this);
++
++        m_reading.storeRelease(false);
++
++        if (m_mode == SelfDispatch) {
++            readAndDispatchEvents();
++        } else {
++            Q_EMIT needReadAndDispatch();
++
++            QMutexLocker lock(&m_mutex);
++            // m_reading might be set from our emit or some other invocation of
++            // readAndDispatchEvents().
++            while (!m_reading.loadRelaxed() && !m_quitting)
++                m_cond.wait(&m_mutex);
++        }
++
++        return !m_quitting;
++    }
++
++    int dispatchQueuePending()
++    {
++        if (m_wlevqueue)
++            return wl_display_dispatch_queue_pending(m_wldisplay, m_wlevqueue);
++        else
++            return wl_display_dispatch_pending(m_wldisplay);
++    }
++
++    int prepareReadQueue()
++    {
++        if (m_wlevqueue)
++            return wl_display_prepare_read_queue(m_wldisplay, m_wlevqueue);
++        else
++            return wl_display_prepare_read(m_wldisplay);
++    }
++
++    int m_fd;
++    int m_pipefd[2];
++    wl_display *m_wldisplay;
++    wl_event_queue *m_wlevqueue;
++    OperatingMode m_mode;
++
++    /* Concurrency note when operating in EmitToDispatch mode:
++     * m_reading is set to false inside event thread's waitForReading(), and is
++     * set to true inside main thread's readAndDispatchEvents().
++     * The lock is not taken when setting m_reading to false, as the main thread
++     * is not actively waiting for it to turn false. However, the lock is taken
++     * inside readAndDispatchEvents() before setting m_reading to true,
++     * as the event thread is actively waiting for it under the wait condition.
++     */
++
++    QAtomicInteger<bool> m_reading;
++    bool m_quitting;
++    QMutex m_mutex;
++    QWaitCondition m_cond;
++};
++
+ Q_LOGGING_CATEGORY(lcQpaWayland, "qt.qpa.wayland"); // for general (uncategorized) Wayland platform logging
+ 
+ struct wl_surface *QWaylandDisplay::createSurface(void *handle)
+@@ -158,17 +351,16 @@ QWaylandDisplay::QWaylandDisplay(QWaylandIntegration *waylandIntegration)
+     if (!mXkbContext)
+         qCWarning(lcQpaWayland, "failed to create xkb context");
+ #endif
+-
+-    forceRoundTrip();
+-
+-    if (!mWaitingScreens.isEmpty()) {
+-        // Give wl_output.done and zxdg_output_v1.done events a chance to arrive
+-        forceRoundTrip();
+-    }
+ }
+ 
+ QWaylandDisplay::~QWaylandDisplay(void)
+ {
++    if (m_eventThread)
++        m_eventThread->stop();
++
++    if (m_frameEventQueueThread)
++        m_frameEventQueueThread->stop();
++
+     if (mSyncCallback)
+         wl_callback_destroy(mSyncCallback);
+ 
+@@ -187,6 +379,21 @@ QWaylandDisplay::~QWaylandDisplay(void)
+ #endif
+     if (mDisplay)
+         wl_display_disconnect(mDisplay);
++
++    if (m_frameEventQueue)
++        wl_event_queue_destroy(m_frameEventQueue);
++}
++
++// Steps which is called just after constructor. This separates registry_global() out of the constructor
++// so that factory functions in integration can be overridden.
++void QWaylandDisplay::initialize()
++{
++    forceRoundTrip();
++
++    if (!mWaitingScreens.isEmpty()) {
++        // Give wl_output.done and zxdg_output_v1.done events a chance to arrive
++        forceRoundTrip();
++    }
+ }
+ 
+ void QWaylandDisplay::ensureScreen()
+@@ -203,98 +410,37 @@ void QWaylandDisplay::ensureScreen()
+ 
+ void QWaylandDisplay::checkError() const
+ {
+-    int ecode = wl_display_get_error(mDisplay);
+-    if ((ecode == EPIPE || ecode == ECONNRESET)) {
+-        // special case this to provide a nicer error
+-        qWarning("The Wayland connection broke. Did the Wayland compositor die?");
+-    } else {
+-        qWarning("The Wayland connection experienced a fatal error: %s", strerror(ecode));
+-    }
+-    _exit(1);
++    checkWaylandError(mDisplay);
+ }
+ 
++// Called in main thread, either from queued signal or directly.
+ void QWaylandDisplay::flushRequests()
+ {
+-    if (wl_display_prepare_read(mDisplay) == 0) {
+-        wl_display_read_events(mDisplay);
+-    }
+-
+-    if (wl_display_dispatch_pending(mDisplay) < 0)
+-        checkError();
+-
+-    {
+-        QReadLocker locker(&m_frameQueueLock);
+-        for (const FrameQueue &q : mExternalQueues) {
+-            QMutexLocker locker(q.mutex);
+-            while (wl_display_prepare_read_queue(mDisplay, q.queue) != 0)
+-                wl_display_dispatch_queue_pending(mDisplay, q.queue);
+-            wl_display_read_events(mDisplay);
+-            wl_display_dispatch_queue_pending(mDisplay, q.queue);
+-        }
+-    }
+-
+-    wl_display_flush(mDisplay);
+-}
+-
+-void QWaylandDisplay::blockingReadEvents()
+-{
+-    if (wl_display_dispatch(mDisplay) < 0)
+-        checkError();
+-}
+-
+-void QWaylandDisplay::destroyFrameQueue(const QWaylandDisplay::FrameQueue &q)
+-{
+-    QWriteLocker locker(&m_frameQueueLock);
+-    auto it = std::find_if(mExternalQueues.begin(),
+-                           mExternalQueues.end(),
+-                           [&q] (const QWaylandDisplay::FrameQueue &other){ return other.queue == q.queue; });
+-    Q_ASSERT(it != mExternalQueues.end());
+-    mExternalQueues.erase(it);
+-    if (q.queue != nullptr)
+-        wl_event_queue_destroy(q.queue);
+-    delete q.mutex;
++    m_eventThread->readAndDispatchEvents();
+ }
+ 
+-QWaylandDisplay::FrameQueue QWaylandDisplay::createFrameQueue()
++// We have to wait until we have an eventDispatcher before creating the eventThread,
++// otherwise forceRoundTrip() may block inside _events_read() because eventThread is
++// polling.
++void QWaylandDisplay::initEventThread()
+ {
+-    QWriteLocker locker(&m_frameQueueLock);
+-    FrameQueue q{createEventQueue()};
+-    mExternalQueues.append(q);
+-    return q;
+-}
++    m_eventThread.reset(
++            new EventThread(mDisplay, /* default queue */ nullptr, EventThread::EmitToDispatch));
++    connect(m_eventThread.get(), &EventThread::needReadAndDispatch, this,
++            &QWaylandDisplay::flushRequests, Qt::QueuedConnection);
++    m_eventThread->start();
+ 
+-wl_event_queue *QWaylandDisplay::createEventQueue()
+-{
+-    return wl_display_create_queue(mDisplay);
++    // wl_display_disconnect() free this.
++    m_frameEventQueue = wl_display_create_queue(mDisplay);
++    m_frameEventQueueThread.reset(
++            new EventThread(mDisplay, m_frameEventQueue, EventThread::SelfDispatch));
++    m_frameEventQueueThread->start();
+ }
+ 
+-void QWaylandDisplay::dispatchQueueWhile(wl_event_queue *queue, std::function<bool ()> condition, int timeout)
++void QWaylandDisplay::blockingReadEvents()
+ {
+-    if (!condition())
+-        return;
+-
+-    QElapsedTimer timer;
+-    timer.start();
+-    struct pollfd pFd = qt_make_pollfd(wl_display_get_fd(mDisplay), POLLIN);
+-    while (timeout == -1 || timer.elapsed() < timeout) {
+-        while (wl_display_prepare_read_queue(mDisplay, queue) != 0)
+-            wl_display_dispatch_queue_pending(mDisplay, queue);
+-
+-        wl_display_flush(mDisplay);
+-
+-        const int remaining = qMax(timeout - timer.elapsed(), 0ll);
+-        const int pollTimeout = timeout == -1 ? -1 : remaining;
+-        if (qt_poll_msecs(&pFd, 1, pollTimeout) > 0)
+-            wl_display_read_events(mDisplay);
+-        else
+-            wl_display_cancel_read(mDisplay);
+-
+-        if (wl_display_dispatch_queue_pending(mDisplay, queue) < 0)
+-            checkError();
+-
+-        if (!condition())
+-            break;
+-    }
++    if (wl_display_dispatch(mDisplay) < 0)
++        checkWaylandError(mDisplay);
+ }
+ 
+ QWaylandScreen *QWaylandDisplay::screenForOutput(struct wl_output *output) const
+@@ -345,7 +491,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+     if (interface == QStringLiteral("wl_output")) {
+         mWaitingScreens << new QWaylandScreen(this, version, id);
+     } else if (interface == QStringLiteral("wl_compositor")) {
+-        mCompositorVersion = qMin((int)version, 3);
++        mCompositorVersion = qMin((int)version, 4);
+         mCompositor.init(registry, id, mCompositorVersion);
+     } else if (interface == QStringLiteral("wl_shm")) {
+         mShm.reset(new QWaylandShm(this, version, id));
+@@ -354,7 +500,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+         mInputDevices.append(inputDevice);
+ #if QT_CONFIG(wayland_datadevice)
+     } else if (interface == QStringLiteral("wl_data_device_manager")) {
+-        mDndSelectionHandler.reset(new QWaylandDataDeviceManager(this, id));
++        mDndSelectionHandler.reset(new QWaylandDataDeviceManager(this, version, id));
+ #endif
+     } else if (interface == QStringLiteral("qt_surface_extension")) {
+         mWindowExtension.reset(new QtWayland::qt_surface_extension(registry, id, 1));
+@@ -369,6 +515,8 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+ #if QT_CONFIG(wayland_client_primary_selection)
+     } else if (interface == QStringLiteral("zwp_primary_selection_device_manager_v1")) {
+         mPrimarySelectionManager.reset(new QWaylandPrimarySelectionDeviceManagerV1(this, id, 1));
++        for (QWaylandInputDevice *inputDevice : qAsConst(mInputDevices))
++            inputDevice->setPrimarySelectionDevice(mPrimarySelectionManager->createDevice(inputDevice));
+ #endif
+     } else if (interface == QStringLiteral("zwp_text_input_manager_v2") && !mClientSideInputContextRequested) {
+         mTextInputManager.reset(new QtWayland::zwp_text_input_manager_v2(registry, id, 1));
+@@ -427,6 +575,13 @@ void QWaylandDisplay::registry_global_remove(uint32_t id)
+                     inputDevice->setTextInput(nullptr);
+                 mWaylandIntegration->reconfigureInputContext();
+             }
++#if QT_CONFIG(wayland_client_primary_selection)
++            if (global.interface == QStringLiteral("zwp_primary_selection_device_manager_v1")) {
++                mPrimarySelectionManager.reset();
++                for (QWaylandInputDevice *inputDevice : qAsConst(mInputDevices))
++                    inputDevice->setPrimarySelectionDevice(nullptr);
++            }
++#endif
+             mGlobals.removeAt(i);
+             break;
+         }
+@@ -452,9 +607,10 @@ void QWaylandDisplay::addRegistryListener(RegistryListener listener, void *data)
+ 
+ void QWaylandDisplay::removeListener(RegistryListener listener, void *data)
+ {
+-    std::remove_if(mRegistryListeners.begin(), mRegistryListeners.end(), [=](Listener l){
++    auto iter = std::remove_if(mRegistryListeners.begin(), mRegistryListeners.end(), [=](Listener l){
+         return (l.listener == listener && l.data == data);
+     });
++    mRegistryListeners.erase(iter, mRegistryListeners.end());
+ }
+ 
+ uint32_t QWaylandDisplay::currentTimeMillisec()
+@@ -467,50 +623,9 @@ uint32_t QWaylandDisplay::currentTimeMillisec()
+     return 0;
+ }
+ 
+-static void
+-sync_callback(void *data, struct wl_callback *callback, uint32_t serial)
+-{
+-    Q_UNUSED(serial)
+-    bool *done = static_cast<bool *>(data);
+-
+-    *done = true;
+-
+-    // If the wl_callback done event is received after the condition check in the while loop in
+-    // forceRoundTrip(), but before the call to processEvents, the call to processEvents may block
+-    // forever if no more events are posted (eventhough the callback is handled in response to the
+-    // aboutToBlock signal). Hence, we wake up the event dispatcher so forceRoundTrip may return.
+-    // (QTBUG-64696)
+-    if (auto *dispatcher = QThread::currentThread()->eventDispatcher())
+-        dispatcher->wakeUp();
+-
+-    wl_callback_destroy(callback);
+-}
+-
+-static const struct wl_callback_listener sync_listener = {
+-    sync_callback
+-};
+-
+ void QWaylandDisplay::forceRoundTrip()
+ {
+-    // wl_display_roundtrip() works on the main queue only,
+-    // but we use a separate one, so basically reimplement it here
+-    int ret = 0;
+-    bool done = false;
+-    wl_callback *callback = wl_display_sync(mDisplay);
+-    wl_callback_add_listener(callback, &sync_listener, &done);
+-    flushRequests();
+-    if (QThread::currentThread()->eventDispatcher()) {
+-        while (!done && ret >= 0) {
+-            QThread::currentThread()->eventDispatcher()->processEvents(QEventLoop::WaitForMoreEvents);
+-            ret = wl_display_dispatch_pending(mDisplay);
+-        }
+-    } else {
+-        while (!done && ret >= 0)
+-            ret = wl_display_dispatch(mDisplay);
+-    }
+-
+-    if (ret == -1 && !done)
+-        wl_callback_destroy(callback);
++     wl_display_roundtrip(mDisplay);
+ }
+ 
+ bool QWaylandDisplay::supportsWindowDecoration() const
+@@ -574,14 +689,10 @@ void QWaylandDisplay::handleKeyboardFocusChanged(QWaylandInputDevice *inputDevic
+     if (mLastKeyboardFocus == keyboardFocus)
+         return;
+ 
+-    if (mWaylandIntegration->mShellIntegration) {
+-        mWaylandIntegration->mShellIntegration->handleKeyboardFocusChanged(keyboardFocus, mLastKeyboardFocus);
+-    } else {
+-        if (keyboardFocus)
+-            handleWindowActivated(keyboardFocus);
+-        if (mLastKeyboardFocus)
+-            handleWindowDeactivated(mLastKeyboardFocus);
+-    }
++    if (keyboardFocus)
++        handleWindowActivated(keyboardFocus);
++    if (mLastKeyboardFocus)
++        handleWindowDeactivated(mLastKeyboardFocus);
+ 
+     mLastKeyboardFocus = keyboardFocus;
+ }
+@@ -600,6 +711,19 @@ void QWaylandDisplay::handleWaylandSync()
+     QWindow *activeWindow = mActiveWindows.empty() ? nullptr : mActiveWindows.last()->window();
+     if (activeWindow != QGuiApplication::focusWindow())
+         QWindowSystemInterface::handleWindowActivated(activeWindow);
++
++    if (!activeWindow) {
++        if (lastInputDevice()) {
++#if QT_CONFIG(clipboard)
++            if (auto *dataDevice = lastInputDevice()->dataDevice())
++                dataDevice->invalidateSelectionOffer();
++#endif
++#if QT_CONFIG(wayland_client_primary_selection)
++            if (auto *device = lastInputDevice()->primarySelectionDevice())
++                device->invalidateSelectionOffer();
++#endif
++        }
++    }
+ }
+ 
+ const wl_callback_listener QWaylandDisplay::syncCallbackListener = {
+@@ -626,6 +750,13 @@ QWaylandInputDevice *QWaylandDisplay::defaultInputDevice() const
+     return mInputDevices.isEmpty() ? 0 : mInputDevices.first();
+ }
+ 
++bool QWaylandDisplay::isKeyboardAvailable() const
++{
++    return std::any_of(
++            mInputDevices.constBegin(), mInputDevices.constEnd(),
++            [this](const QWaylandInputDevice *device) { return device->keyboard() != nullptr; });
++}
++
+ #if QT_CONFIG(cursor)
+ 
+ QWaylandCursor *QWaylandDisplay::waylandCursor()
+@@ -652,4 +783,6 @@ QWaylandCursorTheme *QWaylandDisplay::loadCursorTheme(const QString &name, int p
+ 
+ } // namespace QtWaylandClient
+ 
++#include "qwaylanddisplay.moc"
++
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/client/qwaylanddisplay_p.h b/qtwayland/src/client/qwaylanddisplay_p.h
+index 3b092bc8..42bc661d 100644
+--- a/qtwayland/src/client/qwaylanddisplay_p.h
++++ b/qtwayland/src/client/qwaylanddisplay_p.h
+@@ -109,6 +109,7 @@ class QWaylandSurface;
+ class QWaylandShellIntegration;
+ class QWaylandCursor;
+ class QWaylandCursorTheme;
++class EventThread;
+ 
+ typedef void (*RegistryListener)(void *data,
+                                  struct wl_registry *registry,
+@@ -120,15 +121,11 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandDisplay : public QObject, public QtWayland
+     Q_OBJECT
+ 
+ public:
+-    struct FrameQueue {
+-        FrameQueue(wl_event_queue *q = nullptr) : queue(q), mutex(new QMutex) {}
+-        wl_event_queue *queue;
+-        QMutex *mutex;
+-    };
+-
+     QWaylandDisplay(QWaylandIntegration *waylandIntegration);
+     ~QWaylandDisplay(void) override;
+ 
++    void initialize();
++
+ #if QT_CONFIG(xkbcommon)
+     struct xkb_context *xkbContext() const { return mXkbContext.get(); }
+ #endif
+@@ -210,11 +207,11 @@ public:
+     void handleKeyboardFocusChanged(QWaylandInputDevice *inputDevice);
+     void handleWindowDestroyed(QWaylandWindow *window);
+ 
+-    wl_event_queue *createEventQueue();
+-    FrameQueue createFrameQueue();
+-    void destroyFrameQueue(const FrameQueue &q);
+-    void dispatchQueueWhile(wl_event_queue *queue, std::function<bool()> condition, int timeout = -1);
++    wl_event_queue *frameEventQueue() { return m_frameEventQueue; };
++
++    bool isKeyboardAvailable() const;
+ 
++    void initEventThread();
+ public slots:
+     void blockingReadEvents();
+     void flushRequests();
+@@ -237,6 +234,9 @@ private:
+     };
+ 
+     struct wl_display *mDisplay = nullptr;
++    QScopedPointer<EventThread> m_eventThread;
++    wl_event_queue *m_frameEventQueue = nullptr;
++    QScopedPointer<EventThread> m_frameEventQueueThread;
+     QtWayland::wl_compositor mCompositor;
+     QScopedPointer<QWaylandShm> mShm;
+     QList<QWaylandScreen *> mWaitingScreens;
+@@ -273,11 +273,9 @@ private:
+     QWaylandInputDevice *mLastInputDevice = nullptr;
+     QPointer<QWaylandWindow> mLastInputWindow;
+     QPointer<QWaylandWindow> mLastKeyboardFocus;
+-    QVector<QWaylandWindow *> mActiveWindows;
+-    QVector<FrameQueue> mExternalQueues;
++    QList<QWaylandWindow *> mActiveWindows;
+     struct wl_callback *mSyncCallback = nullptr;
+     static const wl_callback_listener syncCallbackListener;
+-    QReadWriteLock m_frameQueueLock;
+ 
+     bool mClientSideInputContextRequested = !QPlatformInputContextFactory::requested().isNull();
+ 
+diff --git a/qtwayland/src/client/qwaylanddnd.cpp b/qtwayland/src/client/qwaylanddnd.cpp
+index 6535aa16..7c53f5fa 100644
+--- a/qtwayland/src/client/qwaylanddnd.cpp
++++ b/qtwayland/src/client/qwaylanddnd.cpp
+@@ -66,7 +66,7 @@ void QWaylandDrag::startDrag()
+ {
+     QBasicDrag::startDrag();
+     QWaylandWindow *icon = static_cast<QWaylandWindow *>(shapedPixmapWindow()->handle());
+-    if (m_display->currentInputDevice()->dataDevice()->startDrag(drag()->mimeData(), icon)) {
++    if (m_display->currentInputDevice()->dataDevice()->startDrag(drag()->mimeData(), drag()->supportedActions(), icon)) {
+         icon->addAttachOffset(-drag()->hotSpot());
+     } else {
+         // Cancelling immediately does not work, since the event loop for QDrag::exec is started
+@@ -80,6 +80,9 @@ void QWaylandDrag::cancel()
+     QBasicDrag::cancel();
+ 
+     m_display->currentInputDevice()->dataDevice()->cancelDrag();
++
++    if (drag())
++        drag()->deleteLater();
+ }
+ 
+ void QWaylandDrag::move(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods)
+@@ -103,33 +106,41 @@ void QWaylandDrag::endDrag()
+     m_display->currentInputDevice()->handleEndDrag();
+ }
+ 
+-void QWaylandDrag::updateTarget(const QString &mimeType)
++void QWaylandDrag::setResponse(bool accepted)
+ {
+-    setCanDrop(!mimeType.isEmpty());
+-
+-    if (canDrop()) {
+-        updateCursor(defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers()));
+-    } else {
+-        updateCursor(Qt::IgnoreAction);
+-    }
++    // This method is used for old DataDevices where the drag action is not communicated
++    Qt::DropAction action = defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers());
++    setResponse(QPlatformDropQtResponse(accepted, action));
+ }
+ 
+-void QWaylandDrag::setResponse(const QPlatformDragQtResponse &response)
++void QWaylandDrag::setResponse(const QPlatformDropQtResponse &response)
+ {
+     setCanDrop(response.isAccepted());
+ 
+     if (canDrop()) {
+-        updateCursor(defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers()));
++        updateCursor(response.acceptedAction());
+     } else {
+         updateCursor(Qt::IgnoreAction);
+     }
+ }
+ 
+-void QWaylandDrag::finishDrag(const QPlatformDropQtResponse &response)
++void QWaylandDrag::setDropResponse(const QPlatformDropQtResponse &response)
+ {
+     setExecutedDropAction(response.acceptedAction());
++}
++
++void QWaylandDrag::finishDrag()
++{
+     QKeyEvent event(QEvent::KeyPress, Qt::Key_Escape, Qt::NoModifier);
+     eventFilter(shapedPixmapWindow(), &event);
++
++    if (drag())
++        drag()->deleteLater();
++}
++
++bool QWaylandDrag::ownsDragObject() const
++{
++    return true;
+ }
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddnd_p.h b/qtwayland/src/client/qwaylanddnd_p.h
+index 474fe2ab..46f629ac 100644
+--- a/qtwayland/src/client/qwaylanddnd_p.h
++++ b/qtwayland/src/client/qwaylanddnd_p.h
+@@ -71,9 +71,10 @@ public:
+     QWaylandDrag(QWaylandDisplay *display);
+     ~QWaylandDrag() override;
+ 
+-    void updateTarget(const QString &mimeType);
+-    void setResponse(const QPlatformDragQtResponse &response);
+-    void finishDrag(const QPlatformDropQtResponse &response);
++    void setResponse(bool accepted);
++    void setResponse(const QPlatformDropQtResponse &response);
++    void setDropResponse(const QPlatformDropQtResponse &response);
++    void finishDrag();
+ 
+ protected:
+     void startDrag() override;
+@@ -82,6 +83,7 @@ protected:
+     void drop(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods) override;
+     void endDrag() override;
+ 
++    bool ownsDragObject() const override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+diff --git a/qtwayland/src/client/qwaylandinputdevice.cpp b/qtwayland/src/client/qwaylandinputdevice.cpp
+index 613fe862..4b90de84 100644
+--- a/qtwayland/src/client/qwaylandinputdevice.cpp
++++ b/qtwayland/src/client/qwaylandinputdevice.cpp
+@@ -685,6 +685,11 @@ public:
+ 
+ void QWaylandInputDevice::Pointer::pointer_leave(uint32_t time, struct wl_surface *surface)
+ {
++    invalidateFocus();
++    mButtons = Qt::NoButton;
++
++    mParent->mTime = time;
++
+     // The event may arrive after destroying the window, indicated by
+     // a null surface.
+     if (!surface)
+@@ -696,11 +701,6 @@ void QWaylandInputDevice::Pointer::pointer_leave(uint32_t time, struct wl_surfac
+ 
+     if (!QWaylandWindow::mouseGrab())
+         setFrameEvent(new LeaveEvent(window, mSurfacePos, mGlobalPos));
+-
+-    invalidateFocus();
+-    mButtons = Qt::NoButton;
+-
+-    mParent->mTime = time;
+ }
+ 
+ class MotionEvent : public QWaylandPointerEvent
+@@ -1300,14 +1300,6 @@ void QWaylandInputDevice::Keyboard::handleFocusDestroyed()
+ void QWaylandInputDevice::Keyboard::handleFocusLost()
+ {
+     mFocus = nullptr;
+-#if QT_CONFIG(clipboard)
+-    if (auto *dataDevice = mParent->dataDevice())
+-        dataDevice->invalidateSelectionOffer();
+-#endif
+-#if QT_CONFIG(wayland_client_primary_selection)
+-    if (auto *device = mParent->primarySelectionDevice())
+-        device->invalidateSelectionOffer();
+-#endif
+     mParent->mQDisplay->handleKeyboardFocusChanged(mParent);
+     mRepeatTimer.stop();
+ }
+@@ -1396,6 +1388,7 @@ void QWaylandInputDevice::Touch::touch_cancel()
+     if (touchExt)
+         touchExt->touchCanceled();
+ 
++    mFocus = nullptr;
+     QWindowSystemInterface::handleTouchCancelEvent(nullptr, mParent->mTouchDevice);
+ }
+ 
+diff --git a/qtwayland/src/client/qwaylandintegration.cpp b/qtwayland/src/client/qwaylandintegration.cpp
+index c53ccb78..54861600 100644
+--- a/qtwayland/src/client/qwaylandintegration.cpp
++++ b/qtwayland/src/client/qwaylandintegration.cpp
+@@ -125,6 +125,9 @@ QWaylandIntegration::QWaylandIntegration()
+ #endif
+ 
+     reconfigureInputContext();
++
++    QWaylandWindow::fixedToplevelPositions =
++            !qEnvironmentVariableIsSet("QT_WAYLAND_DISABLE_FIXED_POSITIONS");
+ }
+ 
+ QWaylandIntegration::~QWaylandIntegration()
+@@ -192,14 +195,18 @@ QAbstractEventDispatcher *QWaylandIntegration::createEventDispatcher() const
+ 
+ void QWaylandIntegration::initialize()
+ {
++    mDisplay->initEventThread();
++
++    // Call after eventDispatcher is fully connected, for QWaylandDisplay::forceRoundTrip()
++    mDisplay->initialize();
++
++    // But the aboutToBlock() and awake() should be connected after initializePlatform().
++    // Otherwise the connected flushRequests() may consumes up all events before processEvents starts to wait,
++    // so that processEvents(QEventLoop::WaitForMoreEvents) may be blocked in the forceRoundTrip().
+     QAbstractEventDispatcher *dispatcher = QGuiApplicationPrivate::eventDispatcher;
+     QObject::connect(dispatcher, SIGNAL(aboutToBlock()), mDisplay.data(), SLOT(flushRequests()));
+     QObject::connect(dispatcher, SIGNAL(awake()), mDisplay.data(), SLOT(flushRequests()));
+ 
+-    int fd = wl_display_get_fd(mDisplay->wl_display());
+-    QSocketNotifier *sn = new QSocketNotifier(fd, QSocketNotifier::Read, mDisplay.data());
+-    QObject::connect(sn, SIGNAL(activated(QSocketDescriptor)), mDisplay.data(), SLOT(flushRequests()));
+-
+     // Qt does not support running with no screens
+     mDisplay->ensureScreen();
+ }
+@@ -262,6 +269,14 @@ QWaylandDisplay *QWaylandIntegration::display() const
+     return mDisplay.data();
+ }
+ 
++Qt::KeyboardModifiers QWaylandIntegration::queryKeyboardModifiers() const
++{
++    if (auto *seat = mDisplay->currentInputDevice()) {
++        return seat->modifiers();
++    }
++    return Qt::NoModifier;
++}
++
+ QList<int> QWaylandIntegration::possibleKeys(const QKeyEvent *event) const
+ {
+     if (auto *seat = mDisplay->currentInputDevice())
+@@ -479,7 +494,7 @@ void QWaylandIntegration::reconfigureInputContext()
+     }
+ #endif
+ 
+-    qCDebug(lcQpaWayland) << "using input method:" << inputContext()->metaObject()->className();
++    qCDebug(lcQpaWayland) << "using input method:" << (inputContext() ? inputContext()->metaObject()->className() : "<none>");
+ }
+ 
+ QWaylandShellIntegration *QWaylandIntegration::createShellIntegration(const QString &integrationName)
+diff --git a/qtwayland/src/client/qwaylandintegration_p.h b/qtwayland/src/client/qwaylandintegration_p.h
+index ff70ae25..73b80658 100644
+--- a/qtwayland/src/client/qwaylandintegration_p.h
++++ b/qtwayland/src/client/qwaylandintegration_p.h
+@@ -107,6 +107,8 @@ public:
+ 
+     QWaylandDisplay *display() const;
+ 
++    Qt::KeyboardModifiers queryKeyboardModifiers() const override;
++
+     QList<int> possibleKeys(const QKeyEvent *event) const override;
+ 
+     QStringList themeNames() const override;
+diff --git a/qtwayland/src/client/qwaylandprimaryselectionv1.cpp b/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
+index 832f9678..ea508771 100644
+--- a/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
++++ b/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
+@@ -54,11 +54,6 @@ QWaylandPrimarySelectionDeviceManagerV1::QWaylandPrimarySelectionDeviceManagerV1
+     : zwp_primary_selection_device_manager_v1(display->wl_registry(), id, qMin(version, uint(1)))
+     , m_display(display)
+ {
+-    // Create devices for all seats.
+-    // This only works if we get the global before all devices
+-    const auto seats = m_display->inputDevices();
+-    for (auto *seat : seats)
+-        seat->setPrimarySelectionDevice(createDevice(seat));
+ }
+ 
+ QWaylandPrimarySelectionDeviceV1 *QWaylandPrimarySelectionDeviceManagerV1::createDevice(QWaylandInputDevice *seat)
+diff --git a/qtwayland/src/client/qwaylandscreen.cpp b/qtwayland/src/client/qwaylandscreen.cpp
+index 6cb337de..5537dafd 100644
+--- a/qtwayland/src/client/qwaylandscreen.cpp
++++ b/qtwayland/src/client/qwaylandscreen.cpp
+@@ -60,7 +60,7 @@ QWaylandXdgOutputManagerV1::QWaylandXdgOutputManagerV1(QWaylandDisplay* display,
+ }
+ 
+ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uint32_t id)
+-    : QtWayland::wl_output(waylandDisplay->wl_registry(), id, qMin(version, 2))
++    : QtWayland::wl_output(waylandDisplay->wl_registry(), id, qMin(version, 3))
+     , m_outputId(id)
+     , mWaylandDisplay(waylandDisplay)
+     , mOutputName(QStringLiteral("Screen%1").arg(id))
+@@ -72,7 +72,7 @@ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uin
+         qCWarning(lcQpaWayland) << "wl_output done event not supported by compositor,"
+                                 << "QScreen may not work correctly";
+         mWaylandDisplay->forceRoundTrip(); // Give the compositor a chance to send geometry etc.
+-        mOutputDone = true; // Fake the done event
++        mProcessedEvents |= OutputDoneEvent; // Fake the done event
+         maybeInitialize();
+     }
+ }
+@@ -81,16 +81,29 @@ QWaylandScreen::~QWaylandScreen()
+ {
+     if (zxdg_output_v1::isInitialized())
+         zxdg_output_v1::destroy();
++    if (wl_output::isInitialized() && wl_output_get_version(wl_output::object()) >= WL_OUTPUT_RELEASE_SINCE_VERSION)
++        wl_output::release();
++}
++
++uint QWaylandScreen::requiredEvents() const
++{
++    uint ret = OutputDoneEvent;
++
++    if (mWaylandDisplay->xdgOutputManager()) {
++        ret |= XdgOutputNameEvent;
++
++        if (mWaylandDisplay->xdgOutputManager()->version() < 3)
++            ret |= XdgOutputDoneEvent;
++    }
++    return ret;
+ }
+ 
+ void QWaylandScreen::maybeInitialize()
+ {
+     Q_ASSERT(!mInitialized);
+ 
+-    if (!mOutputDone)
+-        return;
+-
+-    if (mWaylandDisplay->xdgOutputManager() && !mXdgOutputDone)
++    const uint requiredEvents = this->requiredEvents();
++    if ((mProcessedEvents & requiredEvents) != requiredEvents)
+         return;
+ 
+     mInitialized = true;
+@@ -276,9 +289,8 @@ void QWaylandScreen::output_scale(int32_t factor)
+ 
+ void QWaylandScreen::output_done()
+ {
+-    mOutputDone = true;
+-    if (zxdg_output_v1::isInitialized() && mWaylandDisplay->xdgOutputManager()->version() >= 3)
+-        mXdgOutputDone = true;
++    mProcessedEvents |= OutputDoneEvent;
++
+     if (mInitialized) {
+         updateOutputProperties();
+         if (zxdg_output_v1::isInitialized())
+@@ -339,7 +351,7 @@ void QWaylandScreen::zxdg_output_v1_done()
+     if (Q_UNLIKELY(mWaylandDisplay->xdgOutputManager()->version() >= 3))
+         qWarning(lcQpaWayland) << "zxdg_output_v1.done received on version 3 or newer, this is most likely a bug in the compositor";
+ 
+-    mXdgOutputDone = true;
++    mProcessedEvents |= XdgOutputDoneEvent;
+     if (mInitialized)
+         updateXdgOutputProperties();
+     else
+@@ -348,7 +360,11 @@ void QWaylandScreen::zxdg_output_v1_done()
+ 
+ void QWaylandScreen::zxdg_output_v1_name(const QString &name)
+ {
++    if (Q_UNLIKELY(mInitialized))
++        qWarning(lcQpaWayland) << "zxdg_output_v1.name received after output has been initialized, this is most likely a bug in the compositor";
++
+     mOutputName = name;
++    mProcessedEvents |= XdgOutputNameEvent;
+ }
+ 
+ void QWaylandScreen::updateXdgOutputProperties()
+diff --git a/qtwayland/src/client/qwaylandscreen_p.h b/qtwayland/src/client/qwaylandscreen_p.h
+index df1c94f2..050cfdc0 100644
+--- a/qtwayland/src/client/qwaylandscreen_p.h
++++ b/qtwayland/src/client/qwaylandscreen_p.h
+@@ -116,6 +116,13 @@ public:
+     static QWaylandScreen *fromWlOutput(::wl_output *output);
+ 
+ private:
++    enum Event : uint {
++        XdgOutputDoneEvent = 0x1,
++        OutputDoneEvent = 0x2,
++        XdgOutputNameEvent = 0x4,
++    };
++    uint requiredEvents() const;
++
+     void output_mode(uint32_t flags, int width, int height, int refresh) override;
+     void output_geometry(int32_t x, int32_t y,
+                          int32_t width, int32_t height,
+@@ -148,8 +155,7 @@ private:
+     QSize mPhysicalSize;
+     QString mOutputName;
+     Qt::ScreenOrientation m_orientation = Qt::PrimaryOrientation;
+-    bool mOutputDone = false;
+-    bool mXdgOutputDone = false;
++    uint mProcessedEvents = 0;
+     bool mInitialized = false;
+ 
+ #if QT_CONFIG(cursor)
+diff --git a/qtwayland/src/client/qwaylandshmbackingstore.cpp b/qtwayland/src/client/qwaylandshmbackingstore.cpp
+index dc7ff670..41cffdf7 100644
+--- a/qtwayland/src/client/qwaylandshmbackingstore.cpp
++++ b/qtwayland/src/client/qwaylandshmbackingstore.cpp
+@@ -52,6 +52,7 @@
+ 
+ #include <QtWaylandClient/private/wayland-wayland-client-protocol.h>
+ 
++#include <fcntl.h>
+ #include <unistd.h>
+ #include <sys/mman.h>
+ 
+@@ -61,6 +62,9 @@
+ #  ifndef MFD_CLOEXEC
+ #    define MFD_CLOEXEC     0x0001U
+ #  endif
++#  ifndef MFD_ALLOW_SEALING
++#    define MFD_ALLOW_SEALING 0x0002U
++#  endif
+ #endif
+ 
+ QT_BEGIN_NAMESPACE
+@@ -74,8 +78,10 @@ QWaylandShmBuffer::QWaylandShmBuffer(QWaylandDisplay *display,
+     int alloc = stride * size.height();
+     int fd = -1;
+ 
+-#ifdef SYS_memfd_create
+-    fd = syscall(SYS_memfd_create, "wayland-shm", MFD_CLOEXEC);
++#if defined(SYS_memfd_create) && defined(F_SEAL_SEAL)
++    fd = syscall(SYS_memfd_create, "wayland-shm", MFD_CLOEXEC | MFD_ALLOW_SEALING);
++    if (fd >= 0)
++        fcntl(fd, F_ADD_SEALS, F_SEAL_SHRINK | F_SEAL_SEAL);
+ #endif
+ 
+     QScopedPointer<QFile> filePointer;
+diff --git a/qtwayland/src/client/qwaylandwindow.cpp b/qtwayland/src/client/qwaylandwindow.cpp
+index cb82857a..fb2c59dc 100644
+--- a/qtwayland/src/client/qwaylandwindow.cpp
++++ b/qtwayland/src/client/qwaylandwindow.cpp
+@@ -76,7 +76,6 @@ QWaylandWindow *QWaylandWindow::mMouseGrab = nullptr;
+ QWaylandWindow::QWaylandWindow(QWindow *window, QWaylandDisplay *display)
+     : QPlatformWindow(window)
+     , mDisplay(display)
+-    , mFrameQueue(mDisplay->createFrameQueue())
+     , mResizeAfterSwap(qEnvironmentVariableIsSet("QT_WAYLAND_RESIZE_AFTER_SWAP"))
+ {
+     {
+@@ -95,9 +94,6 @@ QWaylandWindow::QWaylandWindow(QWindow *window, QWaylandDisplay *display)
+ 
+ QWaylandWindow::~QWaylandWindow()
+ {
+-    mDisplay->destroyFrameQueue(mFrameQueue);
+-    mDisplay->handleWindowDestroyed(this);
+-
+     delete mWindowDecoration;
+ 
+     if (mSurface)
+@@ -243,6 +239,7 @@ bool QWaylandWindow::shouldCreateSubSurface() const
+ 
+ void QWaylandWindow::reset()
+ {
++    closeChildPopups();
+     delete mShellSurface;
+     mShellSurface = nullptr;
+     delete mSubSurfaceWindow;
+@@ -255,17 +252,22 @@ void QWaylandWindow::reset()
+         mSurface.reset();
+     }
+ 
+-    if (mFrameCallback) {
+-        wl_callback_destroy(mFrameCallback);
+-        mFrameCallback = nullptr;
+-    }
++    {
++        QMutexLocker lock(&mFrameSyncMutex);
++        if (mFrameCallback) {
++            wl_callback_destroy(mFrameCallback);
++            mFrameCallback = nullptr;
++        }
+ 
+-    mFrameCallbackElapsedTimer.invalidate();
+-    mWaitingForFrameCallback = false;
++        mFrameCallbackElapsedTimer.invalidate();
++        mWaitingForFrameCallback = false;
++    }
+     mFrameCallbackTimedOut = false;
+ 
+     mMask = QRegion();
+     mQueuedBuffer = nullptr;
++
++    mDisplay->handleWindowDestroyed(this);
+ }
+ 
+ QWaylandWindow *QWaylandWindow::fromWlSurface(::wl_surface *surface)
+@@ -351,19 +353,25 @@ void QWaylandWindow::setGeometry_helper(const QRect &rect)
+     }
+ }
+ 
+-void QWaylandWindow::setGeometry(const QRect &rect)
++void QWaylandWindow::setGeometry(const QRect &r)
+ {
++    auto rect = r;
++    if (fixedToplevelPositions && !QPlatformWindow::parent() && window()->type() != Qt::Popup
++        && window()->type() != Qt::ToolTip) {
++        rect.moveTo(screen()->geometry().topLeft());
++    }
+     setGeometry_helper(rect);
+ 
+     if (window()->isVisible() && rect.isValid()) {
+         if (mWindowDecoration)
+             mWindowDecoration->update();
+ 
+-        if (mResizeAfterSwap && windowType() == Egl && mSentInitialResize)
++        if (mResizeAfterSwap && windowType() == Egl && mSentInitialResize) {
++            QMutexLocker lock(&mResizeLock);
+             mResizeDirty = true;
+-        else
++        } else {
+             QWindowSystemInterface::handleGeometryChange(window(), geometry());
+-
++        }
+         mSentInitialResize = true;
+     }
+     QRect exposeGeometry(QPoint(), geometry().size());
+@@ -374,7 +382,7 @@ void QWaylandWindow::setGeometry(const QRect &rect)
+         mShellSurface->setWindowGeometry(windowContentGeometry());
+ 
+     if (isOpaque() && mMask.isEmpty())
+-        setOpaqueArea(rect);
++        setOpaqueArea(QRect(QPoint(0, 0), rect.size()));
+ }
+ 
+ void QWaylandWindow::resizeFromApplyConfigure(const QSize &sizeWithMargins, const QPoint &offset)
+@@ -399,21 +407,6 @@ void QWaylandWindow::sendExposeEvent(const QRect &rect)
+     mLastExposeGeometry = rect;
+ }
+ 
+-
+-static QVector<QPointer<QWaylandWindow>> activePopups;
+-
+-void QWaylandWindow::closePopups(QWaylandWindow *parent)
+-{
+-    while (!activePopups.isEmpty()) {
+-        auto popup = activePopups.takeLast();
+-        if (popup.isNull())
+-            continue;
+-        if (popup.data() == parent)
+-            return;
+-        popup->reset();
+-    }
+-}
+-
+ QPlatformScreen *QWaylandWindow::calculateScreenFromSurfaceEvents() const
+ {
+     QReadLocker lock(&mSurfaceLock);
+@@ -433,10 +426,7 @@ void QWaylandWindow::setVisible(bool visible)
+     lastVisible = visible;
+ 
+     if (visible) {
+-        if (window()->type() == Qt::Popup || window()->type() == Qt::ToolTip)
+-            activePopups << this;
+         initWindow();
+-        mDisplay->flushRequests();
+ 
+         setGeometry(windowGeometry());
+         // Don't flush the events here, or else the newly visible window may start drawing, but since
+@@ -444,7 +434,6 @@ void QWaylandWindow::setVisible(bool visible)
+         // QWaylandShmBackingStore::beginPaint().
+     } else {
+         sendExposeEvent(QRect());
+-        closePopups(this);
+         reset();
+     }
+ }
+@@ -556,12 +545,12 @@ void QWaylandWindow::sendRecursiveExposeEvent()
+ 
+ void QWaylandWindow::attach(QWaylandBuffer *buffer, int x, int y)
+ {
+-    Q_ASSERT(!buffer->committed());
+     QReadLocker locker(&mSurfaceLock);
+     if (mSurface == nullptr)
+         return;
+ 
+     if (buffer) {
++        Q_ASSERT(!buffer->committed());
+         handleUpdate();
+         buffer->setBusy();
+ 
+@@ -583,7 +572,11 @@ void QWaylandWindow::damage(const QRect &rect)
+     if (mSurface == nullptr)
+         return;
+ 
+-    mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    const int s = scale();
++    if (mDisplay->compositorVersion() >= 4)
++        mSurface->damage_buffer(s * rect.x(), s * rect.y(), s * rect.width(), s * rect.height());
++    else
++        mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
+ }
+ 
+ void QWaylandWindow::safeCommit(QWaylandBuffer *buffer, const QRegion &damage)
+@@ -619,8 +612,14 @@ void QWaylandWindow::commit(QWaylandBuffer *buffer, const QRegion &damage)
+         return;
+ 
+     attachOffset(buffer);
+-    for (const QRect &rect: damage)
+-        mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    if (mDisplay->compositorVersion() >= 4) {
++        const int s = scale();
++        for (const QRect &rect: damage)
++            mSurface->damage_buffer(s * rect.x(), s * rect.y(), s * rect.width(), s * rect.height());
++    } else {
++        for (const QRect &rect: damage)
++            mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    }
+     Q_ASSERT(!buffer->committed());
+     buffer->setCommitted();
+     mSurface->commit();
+@@ -635,42 +634,53 @@ void QWaylandWindow::commit()
+ 
+ const wl_callback_listener QWaylandWindow::callbackListener = {
+     [](void *data, wl_callback *callback, uint32_t time) {
+-        Q_UNUSED(callback);
+         Q_UNUSED(time);
+         auto *window = static_cast<QWaylandWindow*>(data);
+-        window->handleFrameCallback();
++        window->handleFrameCallback(callback);
+     }
+ };
+ 
+-void QWaylandWindow::handleFrameCallback()
++void QWaylandWindow::handleFrameCallback(wl_callback* callback)
+ {
++    QMutexLocker locker(&mFrameSyncMutex);
++    if (!mFrameCallback) {
++        // This means the callback is already unset by QWaylandWindow::reset.
++        // The wl_callback object will be destroyed there too.
++        return;
++    }
++    Q_ASSERT(callback == mFrameCallback);
++    wl_callback_destroy(callback);
++    mFrameCallback = nullptr;
++
+     mWaitingForFrameCallback = false;
+     mFrameCallbackElapsedTimer.invalidate();
+ 
+     // The rest can wait until we can run it on the correct thread
+-    if (!mWaitingForUpdateDelivery) {
+-        auto doHandleExpose = [this]() {
+-            bool wasExposed = isExposed();
+-            mFrameCallbackTimedOut = false;
+-            if (!wasExposed && isExposed()) // Did setting mFrameCallbackTimedOut make the window exposed?
+-                sendExposeEvent(QRect(QPoint(), geometry().size()));
+-            if (wasExposed && hasPendingUpdateRequest())
+-                deliverUpdateRequest();
+-
+-            mWaitingForUpdateDelivery = false;
+-        };
++    auto doHandleExpose = [this]() {
++        mWaitingForUpdateDelivery.storeRelease(false);
++        bool wasExposed = isExposed();
++        mFrameCallbackTimedOut = false;
++        if (!wasExposed && isExposed()) // Did setting mFrameCallbackTimedOut make the window exposed?
++            sendExposeEvent(QRect(QPoint(), geometry().size()));
++        if (wasExposed && hasPendingUpdateRequest())
++            deliverUpdateRequest();
++    };
+ 
++    if (mWaitingForUpdateDelivery.testAndSetAcquire(false, true)) {
+         // Queued connection, to make sure we don't call handleUpdate() from inside waitForFrameSync()
+         // in the single-threaded case.
+-        mWaitingForUpdateDelivery = true;
+         QMetaObject::invokeMethod(this, doHandleExpose, Qt::QueuedConnection);
+     }
++
++    mFrameSyncWait.notify_all();
+ }
+ 
+ bool QWaylandWindow::waitForFrameSync(int timeout)
+ {
+-    QMutexLocker locker(mFrameQueue.mutex);
+-    mDisplay->dispatchQueueWhile(mFrameQueue.queue, [&]() { return mWaitingForFrameCallback; }, timeout);
++    QMutexLocker locker(&mFrameSyncMutex);
++
++    QDeadlineTimer deadline(timeout);
++    while (mWaitingForFrameCallback && mFrameSyncWait.wait(&mFrameSyncMutex, deadline)) { }
+ 
+     if (mWaitingForFrameCallback) {
+         qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
+@@ -868,6 +878,17 @@ bool QWaylandWindow::createDecoration()
+             subsurf->set_position(pos.x() + m.left(), pos.y() + m.top());
+         }
+         sendExposeEvent(QRect(QPoint(), geometry().size()));
++
++        // This is a special case where the buffer is recreated, but since
++        // the content rect remains the same, the widgets remain the same
++        // size and are not redrawn, leaving the new buffer empty. As a simple
++        // work-around, we trigger a full extra update whenever the client-side
++        // window decorations are toggled while the window is showing.
++        // Note: createDecoration() is sometimes called from the render thread
++        // of Qt Quick. This is essentially wrong and could potentially cause problems,
++        // but until the underlying issue has been fixed, we have to use invokeMethod()
++        // here to avoid asserts.
++        QMetaObject::invokeMethod(window(), &QWindow::requestUpdate);
+     }
+ 
+     return mWindowDecoration;
+@@ -1023,6 +1044,13 @@ void QWaylandWindow::handleScreensChanged()
+ 
+     QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->QPlatformScreen::screen());
+     mLastReportedScreen = newScreen;
++    if (fixedToplevelPositions && !QPlatformWindow::parent() && window()->type() != Qt::Popup
++        && window()->type() != Qt::ToolTip
++        && geometry().topLeft() != newScreen->geometry().topLeft()) {
++        auto geometry = this->geometry();
++        geometry.moveTo(newScreen->geometry().topLeft());
++        setGeometry(geometry);
++    }
+ 
+     int scale = newScreen->isPlaceholder() ? 1 : static_cast<QWaylandScreen *>(newScreen)->scale();
+     if (scale != mScale) {
+@@ -1094,10 +1122,18 @@ bool QWaylandWindow::setMouseGrabEnabled(bool grab)
+     return true;
+ }
+ 
++Qt::WindowStates QWaylandWindow::windowStates() const
++{
++    return mLastReportedWindowStates;
++}
++
+ void QWaylandWindow::handleWindowStatesChanged(Qt::WindowStates states)
+ {
+     createDecoration();
+-    QWindowSystemInterface::handleWindowStateChanged(window(), states, mLastReportedWindowStates);
++    Qt::WindowStates statesWithoutActive = states & ~Qt::WindowActive;
++    Qt::WindowStates lastStatesWithoutActive = mLastReportedWindowStates & ~Qt::WindowActive;
++    QWindowSystemInterface::handleWindowStateChanged(window(), statesWithoutActive,
++                                                     lastStatesWithoutActive);
+     mLastReportedWindowStates = states;
+ }
+ 
+@@ -1139,19 +1175,24 @@ void QWaylandWindow::timerEvent(QTimerEvent *event)
+     if (event->timerId() != mFrameCallbackCheckIntervalTimerId)
+         return;
+ 
+-    bool callbackTimerExpired = mFrameCallbackElapsedTimer.hasExpired(mFrameCallbackTimeout);
+-    if (!mFrameCallbackElapsedTimer.isValid() || callbackTimerExpired ) {
+-        killTimer(mFrameCallbackCheckIntervalTimerId);
+-        mFrameCallbackCheckIntervalTimerId = -1;
+-    }
+-    if (mFrameCallbackElapsedTimer.isValid() && callbackTimerExpired) {
+-        mFrameCallbackElapsedTimer.invalidate();
++    {
++        QMutexLocker lock(&mFrameSyncMutex);
+ 
+-        qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
+-        mFrameCallbackTimedOut = true;
+-        mWaitingForUpdate = false;
+-        sendExposeEvent(QRect());
++        bool callbackTimerExpired = mFrameCallbackElapsedTimer.hasExpired(mFrameCallbackTimeout);
++        if (!mFrameCallbackElapsedTimer.isValid() || callbackTimerExpired ) {
++            killTimer(mFrameCallbackCheckIntervalTimerId);
++            mFrameCallbackCheckIntervalTimerId = -1;
++        }
++        if (!mFrameCallbackElapsedTimer.isValid() || !callbackTimerExpired) {
++            return;
++        }
++        mFrameCallbackElapsedTimer.invalidate();
+     }
++
++    qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
++    mFrameCallbackTimedOut = true;
++    mWaitingForUpdate = false;
++    sendExposeEvent(QRect());
+ }
+ 
+ void QWaylandWindow::requestUpdate()
+@@ -1160,8 +1201,11 @@ void QWaylandWindow::requestUpdate()
+     Q_ASSERT(hasPendingUpdateRequest()); // should be set by QPA
+ 
+     // If we have a frame callback all is good and will be taken care of there
+-    if (mWaitingForFrameCallback)
+-        return;
++    {
++        QMutexLocker locker(&mFrameSyncMutex);
++        if (mWaitingForFrameCallback)
++            return;
++    }
+ 
+     // If we've already called deliverUpdateRequest(), but haven't seen any attach+commit/swap yet
+     // This is a somewhat redundant behavior and might indicate a bug in the calling code, so log
+@@ -1174,7 +1218,12 @@ void QWaylandWindow::requestUpdate()
+     // so use invokeMethod to delay the delivery a bit.
+     QMetaObject::invokeMethod(this, [this] {
+         // Things might have changed in the meantime
+-        if (hasPendingUpdateRequest() && !mWaitingForFrameCallback)
++        {
++            QMutexLocker locker(&mFrameSyncMutex);
++            if (mWaitingForFrameCallback)
++                return;
++        }
++        if (hasPendingUpdateRequest())
+             deliverUpdateRequest();
+     }, Qt::QueuedConnection);
+ }
+@@ -1185,19 +1234,18 @@ void QWaylandWindow::requestUpdate()
+ void QWaylandWindow::handleUpdate()
+ {
+     qCDebug(lcWaylandBackingstore) << "handleUpdate" << QThread::currentThread();
++
+     // TODO: Should sync subsurfaces avoid requesting frame callbacks?
+     QReadLocker lock(&mSurfaceLock);
+     if (!mSurface)
+         return;
+ 
+-    if (mFrameCallback) {
+-        wl_callback_destroy(mFrameCallback);
+-        mFrameCallback = nullptr;
+-    }
++    QMutexLocker locker(&mFrameSyncMutex);
++    if (mWaitingForFrameCallback)
++        return;
+ 
+-    QMutexLocker locker(mFrameQueue.mutex);
+     struct ::wl_surface *wrappedSurface = reinterpret_cast<struct ::wl_surface *>(wl_proxy_create_wrapper(mSurface->object()));
+-    wl_proxy_set_queue(reinterpret_cast<wl_proxy *>(wrappedSurface), mFrameQueue.queue);
++    wl_proxy_set_queue(reinterpret_cast<wl_proxy *>(wrappedSurface), mDisplay->frameEventQueue());
+     mFrameCallback = wl_surface_frame(wrappedSurface);
+     wl_proxy_wrapper_destroy(wrappedSurface);
+     wl_callback_add_listener(mFrameCallback, &QWaylandWindow::callbackListener, this);
+@@ -1207,6 +1255,8 @@ void QWaylandWindow::handleUpdate()
+     // Start a timer for handling the case when the compositor stops sending frame callbacks.
+     if (mFrameCallbackTimeout > 0) {
+         QMetaObject::invokeMethod(this, [this] {
++            QMutexLocker locker(&mFrameSyncMutex);
++
+             if (mWaitingForFrameCallback) {
+                 if (mFrameCallbackCheckIntervalTimerId < 0)
+                     mFrameCallbackCheckIntervalTimerId = startTimer(mFrameCallbackTimeout);
+@@ -1267,6 +1317,20 @@ void QWaylandWindow::setOpaqueArea(const QRegion &opaqueArea)
+     wl_region_destroy(region);
+ }
+ 
++void QWaylandWindow::addChildPopup(QWaylandWindow *surface) {
++    mChildPopups.append(surface);
++}
++
++void QWaylandWindow::removeChildPopup(QWaylandWindow *surface) {
++    mChildPopups.removeAll(surface);
++}
++
++void QWaylandWindow::closeChildPopups() {
++    while (!mChildPopups.isEmpty()) {
++        auto popup = mChildPopups.takeLast();
++        popup->reset();
++    }
++}
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/client/qwaylandwindow_p.h b/qtwayland/src/client/qwaylandwindow_p.h
+index 01337cff..2f219d8c 100644
+--- a/qtwayland/src/client/qwaylandwindow_p.h
++++ b/qtwayland/src/client/qwaylandwindow_p.h
+@@ -98,6 +98,9 @@ public:
+     QWaylandWindow(QWindow *window, QWaylandDisplay *display);
+     ~QWaylandWindow() override;
+ 
++    // Keep Toplevels position on the top left corner of their screen
++    static inline bool fixedToplevelPositions = true;
++
+     virtual WindowType windowType() const = 0;
+     virtual void ensureSize();
+     WId winId() const override;
+@@ -148,6 +151,7 @@ public:
+     void setWindowState(Qt::WindowStates states) override;
+     void setWindowFlags(Qt::WindowFlags flags) override;
+     void handleWindowStatesChanged(Qt::WindowStates states);
++    Qt::WindowStates windowStates() const;
+ 
+     void raise() override;
+     void lower() override;
+@@ -206,6 +210,10 @@ public:
+     void handleUpdate();
+     void deliverUpdateRequest() override;
+ 
++    void addChildPopup(QWaylandWindow* child);
++    void removeChildPopup(QWaylandWindow* child);
++    void closeChildPopups();
++
+ public slots:
+     void applyConfigure();
+ 
+@@ -215,7 +223,11 @@ signals:
+ 
+ protected:
+     QWaylandDisplay *mDisplay = nullptr;
++
++    // mSurface can be written by the main thread. Other threads should claim a read lock for access
++    mutable QReadWriteLock mSurfaceLock;
+     QScopedPointer<QWaylandSurface> mSurface;
++
+     QWaylandShellSurface *mShellSurface = nullptr;
+     QWaylandSubSurface *mSubSurfaceWindow = nullptr;
+     QVector<QWaylandSubSurface *> mChildren;
+@@ -225,13 +237,14 @@ protected:
+     Qt::MouseButtons mMousePressedInContentArea = Qt::NoButton;
+ 
+     WId mWindowId;
+-    bool mWaitingForFrameCallback = false;
+     bool mFrameCallbackTimedOut = false; // Whether the frame callback has timed out
+-    bool mWaitingForUpdateDelivery = false;
+     int mFrameCallbackCheckIntervalTimerId = -1;
+-    QElapsedTimer mFrameCallbackElapsedTimer;
+-    struct ::wl_callback *mFrameCallback = nullptr;
+-    QWaylandDisplay::FrameQueue mFrameQueue;
++    QAtomicInt mWaitingForUpdateDelivery = false;
++
++    bool mWaitingForFrameCallback = false; // Protected by mFrameSyncMutex
++    QElapsedTimer mFrameCallbackElapsedTimer; // Protected by mFrameSyncMutex
++    struct ::wl_callback *mFrameCallback = nullptr; // Protected by mFrameSyncMutex
++    QMutex mFrameSyncMutex;
+     QWaitCondition mFrameSyncWait;
+ 
+     // True when we have called deliverRequestUpdate, but the client has not yet attached a new buffer
+@@ -261,6 +274,8 @@ protected:
+     QWaylandBuffer *mQueuedBuffer = nullptr;
+     QRegion mQueuedBufferDamage;
+ 
++    QList<QPointer<QWaylandWindow>> mChildPopups;
++
+ private:
+     void setGeometry_helper(const QRect &rect);
+     void initWindow();
+@@ -283,12 +298,10 @@ private:
+     QRect mLastExposeGeometry;
+ 
+     static const wl_callback_listener callbackListener;
+-    void handleFrameCallback();
++    void handleFrameCallback(struct ::wl_callback* callback);
+ 
+     static QWaylandWindow *mMouseGrab;
+ 
+-    mutable QReadWriteLock mSurfaceLock;
+-
+     friend class QWaylandSubSurface;
+ };
+ 
+diff --git a/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h b/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
+index ccad0048..4cc9b3b8 100644
+--- a/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
++++ b/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
+@@ -73,11 +73,10 @@ public:
+         return true;
+     }
+     virtual QWaylandShellSurface *createShellSurface(QWaylandWindow *window) = 0;
++    // kept for binary compat with layer-shell-qt
+     virtual void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) {
+-        if (newFocus)
+-            m_display->handleWindowActivated(newFocus);
+-        if (oldFocus)
+-            m_display->handleWindowDeactivated(oldFocus);
++        Q_UNUSED(newFocus);
++        Q_UNUSED(oldFocus);
+     }
+     virtual void *nativeResourceForWindow(const QByteArray &resource, QWindow *window) {
+         Q_UNUSED(resource);
+diff --git a/qtwayland/src/compositor/configure.json b/qtwayland/src/compositor/configure.json
+index bcfd5215..da95d07b 100644
+--- a/qtwayland/src/compositor/configure.json
++++ b/qtwayland/src/compositor/configure.json
+@@ -7,6 +7,31 @@
+     "testDir": "../../config.tests",
+ 
+     "libraries": {
++        "wayland-client": {
++            "label": "Wayland client library",
++            "headers": "wayland-version.h",
++            "test": {
++                "main": [
++                    "#if WAYLAND_VERSION_MAJOR < 1",
++                    "# error Wayland 1.8.0 or higher required",
++                    "#endif",
++                    "#if WAYLAND_VERSION_MAJOR == 1",
++                    "# if WAYLAND_VERSION_MINOR < 8",
++                    "#  error Wayland 1.8.0 or higher required",
++                    "# endif",
++                    "# if WAYLAND_VERSION_MINOR == 8",
++                    "#  if WAYLAND_VERSION_MICRO < 0",
++                    "#   error Wayland 1.8.0 or higher required",
++                    "#  endif",
++                    "# endif",
++                    "#endif"
++                 ]
++            },
++            "sources": [
++                { "type": "pkgConfig", "args": "wayland-client" },
++                "-lwayland-client"
++            ]
++        },
+         "wayland-server": {
+             "label": "wayland-server",
+             "headers": "wayland-version.h",
+@@ -151,8 +176,7 @@
+                     "#endif"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "dmabuf-client-buffer": {
+             "label": "Linux Client dma-buf Buffer Sharing",
+@@ -176,8 +200,7 @@
+                     "return 0;"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "vulkan-server-buffer": {
+             "label": "Vulkan Buffer Sharing",
+@@ -195,7 +218,8 @@
+                     "exportAllocInfo.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR;",
+                     "return 0;"
+                 ]
+-            }
++            },
++            "use": "wayland-client"
+         }
+     },
+ 
+diff --git a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
+index 7889f575..64140672 100644
+--- a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
++++ b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
+@@ -40,6 +40,7 @@
+ #include "qwaylandeglwindow.h"
+ 
+ #include <QtWaylandClient/private/qwaylandscreen_p.h>
++#include <QtWaylandClient/private/qwaylandsurface_p.h>
+ #include "qwaylandglcontext.h"
+ 
+ #include <QtEglSupport/private/qeglconvenience_p.h>
+@@ -124,6 +125,7 @@ void QWaylandEglWindow::updateSurface(bool create)
+         }
+         mOffset = QPoint();
+     } else {
++        QReadLocker locker(&mSurfaceLock);
+         if (m_waylandEglWindow) {
+             int current_width, current_height;
+             static bool disableResizeCheck = qgetenv("QT_WAYLAND_DISABLE_RESIZECHECK").toInt();
+@@ -131,14 +133,16 @@ void QWaylandEglWindow::updateSurface(bool create)
+             if (!disableResizeCheck) {
+                 wl_egl_window_get_attached_size(m_waylandEglWindow, &current_width, &current_height);
+             }
+-            if (disableResizeCheck || (current_width != sizeWithMargins.width() || current_height != sizeWithMargins.height())) {
++            if (disableResizeCheck || (current_width != sizeWithMargins.width() || current_height != sizeWithMargins.height()) || m_requestedSize != sizeWithMargins) {
+                 wl_egl_window_resize(m_waylandEglWindow, sizeWithMargins.width(), sizeWithMargins.height(), mOffset.x(), mOffset.y());
++                m_requestedSize = sizeWithMargins;
+                 mOffset = QPoint();
+ 
+                 m_resize = true;
+             }
+-        } else if (create && wlSurface()) {
+-            m_waylandEglWindow = wl_egl_window_create(wlSurface(), sizeWithMargins.width(), sizeWithMargins.height());
++        } else if (create && mSurface) {
++            m_waylandEglWindow = wl_egl_window_create(mSurface->object(), sizeWithMargins.width(), sizeWithMargins.height());
++            m_requestedSize = sizeWithMargins;
+         }
+ 
+         if (!m_eglSurface && m_waylandEglWindow && create) {
+diff --git a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
+index 5b1f4d56..0079dfef 100644
+--- a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
++++ b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
+@@ -88,6 +88,7 @@ private:
+     mutable QOpenGLFramebufferObject *m_contentFBO = nullptr;
+ 
+     QSurfaceFormat m_format;
++    QSize m_requestedSize;
+ };
+ 
+ }
+diff --git a/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h b/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
+index 56a710c3..c6a8b6c6 100644
+--- a/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
++++ b/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
+@@ -41,6 +41,8 @@
+ #include <QtCore/QTextStream>
+ #include <QtGui/QOpenGLTexture>
+ 
++#include <array>
++
+ #include <EGL/egl.h>
+ #include <EGL/eglext.h>
+ 
+diff --git a/qtwayland/src/plugins/decorations/bradient/main.cpp b/qtwayland/src/plugins/decorations/bradient/main.cpp
+index e75fda3c..fa885143 100644
+--- a/qtwayland/src/plugins/decorations/bradient/main.cpp
++++ b/qtwayland/src/plugins/decorations/bradient/main.cpp
+@@ -164,13 +164,10 @@ void QWaylandBradientDecoration::paint(QPaintDevice *device)
+     // Window icon
+     QIcon icon = waylandWindow()->windowIcon();
+     if (!icon.isNull()) {
+-        QPixmap pixmap = icon.pixmap(QSize(128, 128));
+-        QPixmap scaled = pixmap.scaled(22, 22, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+-
+         QRectF iconRect(0, 0, 22, 22);
+-        p.drawPixmap(iconRect.adjusted(margins().left() + BUTTON_SPACING, 4,
+-                                       margins().left() + BUTTON_SPACING, 4),
+-                     scaled, iconRect);
++        iconRect.adjust(margins().left() + BUTTON_SPACING, 4,
++                        margins().left() + BUTTON_SPACING, 4),
++        icon.paint(&p, iconRect.toRect());
+     }
+ 
+     // Window title
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
+index 85d25e3c..60bdd491 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
+@@ -47,18 +47,21 @@ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
+-QWaylandXdgPopupV5::QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow *window)
++QWaylandXdgPopupV5::QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow* parent, QWaylandWindow *window)
+     : QWaylandShellSurface(window)
+     , QtWayland::xdg_popup_v5(popup)
++    , m_parent(parent)
+     , m_window(window)
+ {
+     if (window->display()->windowExtension())
+         m_extendedWindow = new QWaylandExtendedSurface(window);
++    m_parent->addChildPopup(m_window);
+ }
+ 
+ QWaylandXdgPopupV5::~QWaylandXdgPopupV5()
+ {
+     xdg_popup_destroy(object());
++    m_parent->removeChildPopup(m_window);
+     delete m_extendedWindow;
+ }
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
+index 7494f6a6..d85f130b 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
+@@ -70,7 +70,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgPopupV5 : public QWaylandShellSurface
+ {
+     Q_OBJECT
+ public:
+-    QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow *window);
++    QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow* parent, QWaylandWindow *window);
+     ~QWaylandXdgPopupV5() override;
+ 
+ protected:
+@@ -78,6 +78,7 @@ protected:
+ 
+ private:
+     QWaylandExtendedSurface *m_extendedWindow = nullptr;
++    QWaylandWindow *m_parent = nullptr;
+     QWaylandWindow *m_window = nullptr;
+ };
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
+index 7e242c4a..def8452a 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
+@@ -84,7 +84,7 @@ QWaylandXdgPopupV5 *QWaylandXdgShellV5::createXdgPopup(QWaylandWindow *window, Q
+     int x = position.x() + parentWindow->frameMargins().left();
+     int y = position.y() + parentWindow->frameMargins().top();
+ 
+-    auto popup = new QWaylandXdgPopupV5(get_xdg_popup(window->wlSurface(), parentSurface, seat, m_popupSerial, x, y), window);
++    auto popup = new QWaylandXdgPopupV5(get_xdg_popup(window->wlSurface(), parentSurface, seat, m_popupSerial, x, y), parentWindow, window);
+     m_popups.append(window);
+     QObject::connect(popup, &QWaylandXdgPopupV5::destroyed, [this, window](){
+         m_popups.removeOne(window);
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
+index 4e25949f..cfc60939 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
+@@ -85,13 +85,6 @@ QWaylandShellSurface *QWaylandXdgShellV5Integration::createShellSurface(QWayland
+     return m_xdgShell->createXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellV5Integration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) {
+-    if (newFocus && qobject_cast<QWaylandXdgPopupV5 *>(newFocus->shellSurface()))
+-        m_display->handleWindowActivated(newFocus);
+-    if (oldFocus && qobject_cast<QWaylandXdgPopupV5 *>(oldFocus->shellSurface()))
+-        m_display->handleWindowDeactivated(oldFocus);
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
+index ce6bdb9e..aed88670 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
+@@ -67,7 +67,6 @@ public:
+     QWaylandXdgShellV5Integration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShellV5> m_xdgShell;
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
+index 8c371661..151c78e3 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
+@@ -174,6 +174,7 @@ QWaylandXdgSurfaceV6::Popup::Popup(QWaylandXdgSurfaceV6 *xdgSurface, QWaylandXdg
+     , m_xdgSurface(xdgSurface)
+     , m_parent(parent)
+ {
++    m_parent->window()->addChildPopup(m_xdgSurface->window());
+ }
+ 
+ QWaylandXdgSurfaceV6::Popup::~Popup()
+@@ -181,6 +182,8 @@ QWaylandXdgSurfaceV6::Popup::~Popup()
+     if (isInitialized())
+         destroy();
+ 
++    m_parent->window()->removeChildPopup(m_xdgSurface->window());
++
+     if (m_grabbing) {
+         auto *shell = m_xdgSurface->m_shell;
+         Q_ASSERT(shell->m_topmostGrabbingPopup == this);
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
+index 03164316..e8da8ba1 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
+@@ -68,20 +68,6 @@ QWaylandShellSurface *QWaylandXdgShellV6Integration::createShellSurface(QWayland
+     return m_xdgShell->getXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellV6Integration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus)
+-{
+-    if (newFocus) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurfaceV6 *>(newFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowActivated(newFocus);
+-    }
+-    if (oldFocus && qobject_cast<QWaylandXdgSurfaceV6 *>(oldFocus->shellSurface())) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurfaceV6 *>(oldFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowDeactivated(oldFocus);
+-    }
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
+index 261f8cbb..c1bcd5c6 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
+@@ -65,7 +65,6 @@ public:
+     QWaylandXdgShellV6Integration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShellV6> m_xdgShell;
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
+index f3e3c330..fa6d5808 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
+@@ -67,11 +67,6 @@ QWaylandXdgSurface::Toplevel::Toplevel(QWaylandXdgSurface *xdgSurface)
+ 
+ QWaylandXdgSurface::Toplevel::~Toplevel()
+ {
+-    if (m_applied.states & Qt::WindowActive) {
+-        QWaylandWindow *window = m_xdgSurface->window();
+-        window->display()->handleWindowDeactivated(window);
+-    }
+-
+     // The protocol spec requires that the decoration object is deleted before xdg_toplevel.
+     delete m_decoration;
+     m_decoration = nullptr;
+@@ -85,16 +80,15 @@ void QWaylandXdgSurface::Toplevel::applyConfigure()
+     if (!(m_applied.states & (Qt::WindowMaximized|Qt::WindowFullScreen)))
+         m_normalSize = m_xdgSurface->m_window->windowFrameGeometry().size();
+ 
+-    if ((m_pending.states & Qt::WindowActive) && !(m_applied.states & Qt::WindowActive))
++    if ((m_pending.states & Qt::WindowActive) && !(m_applied.states & Qt::WindowActive)
++        && !m_xdgSurface->m_window->display()->isKeyboardAvailable())
+         m_xdgSurface->m_window->display()->handleWindowActivated(m_xdgSurface->m_window);
+ 
+-    if (!(m_pending.states & Qt::WindowActive) && (m_applied.states & Qt::WindowActive))
++    if (!(m_pending.states & Qt::WindowActive) && (m_applied.states & Qt::WindowActive)
++        && !m_xdgSurface->m_window->display()->isKeyboardAvailable())
+         m_xdgSurface->m_window->display()->handleWindowDeactivated(m_xdgSurface->m_window);
+ 
+-    // TODO: none of the other plugins send WindowActive either, but is it on purpose?
+-    Qt::WindowStates statesWithoutActive = m_pending.states & ~Qt::WindowActive;
+-
+-    m_xdgSurface->m_window->handleWindowStatesChanged(statesWithoutActive);
++    m_xdgSurface->m_window->handleWindowStatesChanged(m_pending.states);
+ 
+     if (m_pending.size.isEmpty()) {
+         // An empty size in the configure means it's up to the client to choose the size
+@@ -105,8 +99,6 @@ void QWaylandXdgSurface::Toplevel::applyConfigure()
+         m_xdgSurface->m_window->resizeFromApplyConfigure(m_pending.size);
+     }
+ 
+-    m_xdgSurface->setSizeHints();
+-
+     m_applied = m_pending;
+     qCDebug(lcQpaWayland) << "Applied pending xdg_toplevel configure event:" << m_applied.size << m_applied.states;
+ }
+@@ -203,12 +195,17 @@ QtWayland::xdg_toplevel::resize_edge QWaylandXdgSurface::Toplevel::convertToResi
+                 | ((edges & Qt::RightEdge) ? resize_edge_right : 0));
+ }
+ 
+-QWaylandXdgSurface::Popup::Popup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parent,
++QWaylandXdgSurface::Popup::Popup(QWaylandXdgSurface *xdgSurface, QWaylandWindow *parent,
+                                  QtWayland::xdg_positioner *positioner)
+-    : xdg_popup(xdgSurface->get_popup(parent->object(), positioner->object()))
+-    , m_xdgSurface(xdgSurface)
++    : m_xdgSurface(xdgSurface)
++    , m_parentXdgSurface(qobject_cast<QWaylandXdgSurface *>(parent->shellSurface()))
+     , m_parent(parent)
+ {
++
++    init(xdgSurface->get_popup(m_parentXdgSurface ? m_parentXdgSurface->object() : nullptr, positioner->object()));
++    if (m_parent) {
++        m_parent->addChildPopup(m_xdgSurface->window());
++    }
+ }
+ 
+ QWaylandXdgSurface::Popup::~Popup()
+@@ -216,10 +213,24 @@ QWaylandXdgSurface::Popup::~Popup()
+     if (isInitialized())
+         destroy();
+ 
++    if (m_parent) {
++        m_parent->removeChildPopup(m_xdgSurface->window());
++    }
++
+     if (m_grabbing) {
+         auto *shell = m_xdgSurface->m_shell;
+         Q_ASSERT(shell->m_topmostGrabbingPopup == this);
+-        shell->m_topmostGrabbingPopup = m_parent->m_popup;
++        shell->m_topmostGrabbingPopup = m_parentXdgSurface ? m_parentXdgSurface->m_popup : nullptr;
++        m_grabbing = false;
++
++        // Synthesize Qt enter/leave events for popup
++        QWindow *leave = nullptr;
++        if (m_xdgSurface && m_xdgSurface->window())
++            leave = m_xdgSurface->window()->window();
++        QWindowSystemInterface::handleLeaveEvent(leave);
++
++        if (QWindow *enter = QGuiApplication::topLevelAt(QCursor::pos()))
++            QWindowSystemInterface::handleEnterEvent(enter, enter->mapFromGlobal(QCursor::pos()), QCursor::pos());
+     }
+ }
+ 
+@@ -257,6 +268,7 @@ QWaylandXdgSurface::QWaylandXdgSurface(QWaylandXdgShell *shell, ::xdg_surface *s
+                 m_toplevel->set_parent(parentXdgSurface->m_toplevel->object());
+         }
+     }
++    setSizeHints();
+ }
+ 
+ QWaylandXdgSurface::~QWaylandXdgSurface()
+@@ -400,8 +412,6 @@ void QWaylandXdgSurface::setPopup(QWaylandWindow *parent)
+ {
+     Q_ASSERT(!m_toplevel && !m_popup);
+ 
+-    auto parentXdgSurface = static_cast<QWaylandXdgSurface *>(parent->shellSurface());
+-
+     auto positioner = new QtWayland::xdg_positioner(m_shell->create_positioner());
+     // set_popup expects a position relative to the parent
+     QPoint transientPos = m_window->geometry().topLeft(); // this is absolute
+@@ -414,8 +424,9 @@ void QWaylandXdgSurface::setPopup(QWaylandWindow *parent)
+     positioner->set_anchor(QtWayland::xdg_positioner::anchor_top_left);
+     positioner->set_gravity(QtWayland::xdg_positioner::gravity_bottom_right);
+     positioner->set_size(m_window->geometry().width(), m_window->geometry().height());
+-    m_popup = new Popup(this, parentXdgSurface, positioner);
++    m_popup = new Popup(this, parent, positioner);
+     positioner->destroy();
++
+     delete positioner;
+ }
+ 
+@@ -437,6 +448,23 @@ void QWaylandXdgSurface::setGrabPopup(QWaylandWindow *parent, QWaylandInputDevic
+     }
+     setPopup(parent);
+     m_popup->grab(device, serial);
++
++    // Synthesize Qt enter/leave events for popup
++    if (!parent)
++        return;
++    QWindow *current = QGuiApplication::topLevelAt(QCursor::pos());
++    QWindow *leave = parent->window();
++    if (current != leave)
++        return;
++
++    QWindowSystemInterface::handleLeaveEvent(leave);
++
++    QWindow *enter = nullptr;
++    if (m_popup && m_popup->m_xdgSurface && m_popup->m_xdgSurface->window())
++        enter = m_popup->m_xdgSurface->window()->window();
++
++    if (enter)
++        QWindowSystemInterface::handleEnterEvent(enter, enter->mapFromGlobal(QCursor::pos()), QCursor::pos());
+ }
+ 
+ void QWaylandXdgSurface::xdg_surface_configure(uint32_t serial)
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
+index 96785205..4b518f0a 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
+@@ -131,14 +131,15 @@ private:
+ 
+     class Popup : public QtWayland::xdg_popup {
+     public:
+-        Popup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parent, QtWayland::xdg_positioner *positioner);
++        Popup(QWaylandXdgSurface *xdgSurface, QWaylandWindow *parent, QtWayland::xdg_positioner *positioner);
+         ~Popup() override;
+ 
+         void grab(QWaylandInputDevice *seat, uint serial);
+         void xdg_popup_popup_done() override;
+ 
+         QWaylandXdgSurface *m_xdgSurface = nullptr;
+-        QWaylandXdgSurface *m_parent = nullptr;
++        QWaylandXdgSurface *m_parentXdgSurface = nullptr;
++        QWaylandWindow *m_parent = nullptr;
+         bool m_grabbing = false;
+     };
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
+index 8769d971..da0dd6a7 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
+@@ -69,20 +69,6 @@ QWaylandShellSurface *QWaylandXdgShellIntegration::createShellSurface(QWaylandWi
+     return m_xdgShell->getXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellIntegration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus)
+-{
+-    if (newFocus) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurface *>(newFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowActivated(newFocus);
+-    }
+-    if (oldFocus && qobject_cast<QWaylandXdgSurface *>(oldFocus->shellSurface())) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurface *>(oldFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowDeactivated(oldFocus);
+-    }
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
+index b6caa6c9..2f929f98 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
+@@ -65,7 +65,6 @@ public:
+     QWaylandXdgShellIntegration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShell> m_xdgShell;
+diff --git a/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp b/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
+index 526d0ef4..f50ccf30 100644
+--- a/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
++++ b/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
+@@ -39,7 +39,10 @@
+ 
+ #include "qwaylandinputmethodeventbuilder_p.h"
+ 
++#include <QBrush>
++#include <QGuiApplication>
+ #include <QInputMethod>
++#include <QPalette>
+ #include <QTextCharFormat>
+ 
+ #ifdef QT_BUILD_WAYLANDCOMPOSITOR_LIB
+@@ -81,32 +84,38 @@ void QWaylandInputMethodEventBuilder::addPreeditStyling(uint32_t index, uint32_t
+     QTextCharFormat format;
+ 
+     switch (style) {
+-    case 0:
+-    case 1:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_NONE:
++        break;
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_DEFAULT:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_UNDERLINE:
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-    case 2:
+-    case 3:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_ACTIVE:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_INACTIVE:
+         format.setFontWeight(QFont::Bold);
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-    case 4:
+-        format.setFontUnderline(true);
+-        format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+-        m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_HIGHLIGHT:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_SELECTION:
++        {
++            format.setFontUnderline(true);
++            format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
++            QPalette palette = qApp->palette();
++            format.setBackground(QBrush(palette.color(QPalette::Active, QPalette::Highlight)));
++            format.setForeground(QBrush(palette.color(QPalette::Active, QPalette::HighlightedText)));
++            m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
++        }
+         break;
+-    case 5:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_INCORRECT:
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::WaveUnderline);
+         format.setUnderlineColor(QColor(Qt::red));
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-//    case QtWayland::wl_text_input::preedit_style_selection:
+-//    case QtWayland::wl_text_input::preedit_style_none:
+     default:
+         break;
+     }
+@@ -153,7 +162,7 @@ QInputMethodEvent QWaylandInputMethodEventBuilder::buildPreedit(const QString &t
+ 
+     if (m_preeditCursor < 0) {
+         attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, 0, QVariant()));
+-    } else if (m_preeditCursor > 0) {
++    } else {
+         attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, indexFromWayland(text, m_preeditCursor), 1, QVariant()));
+     }
+ 
+diff --git a/qtwayland/src/shared/qwaylandmimehelper.cpp b/qtwayland/src/shared/qwaylandmimehelper.cpp
+index a5fdd34d..e2fe1928 100644
+--- a/qtwayland/src/shared/qwaylandmimehelper.cpp
++++ b/qtwayland/src/shared/qwaylandmimehelper.cpp
+@@ -60,7 +60,7 @@ QByteArray QWaylandMimeHelper::getByteArray(QMimeData *mimeData, const QString &
+             buf.open(QIODevice::ReadWrite);
+             QByteArray fmt = "BMP";
+             if (mimeType.startsWith(QLatin1String("image/"))) {
+-                QByteArray imgFmt = mimeType.mid(6).toUpper().toLatin1();
++                QByteArray imgFmt = mimeType.mid(6).toLower().toLatin1();
+                 if (QImageWriter::supportedImageFormats().contains(imgFmt))
+                     fmt = imgFmt;
+             }
+@@ -74,7 +74,7 @@ QByteArray QWaylandMimeHelper::getByteArray(QMimeData *mimeData, const QString &
+         QList<QUrl> urls = mimeData->urls();
+         for (int i = 0; i < urls.count(); ++i) {
+             content.append(urls.at(i).toEncoded());
+-            content.append('\n');
++            content.append("\r\n");
+         }
+     } else {
+         content = mimeData->data(mimeType);
+diff --git a/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp b/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
+index 1568b3b9..067410d0 100644
+--- a/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
++++ b/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
+@@ -35,7 +35,7 @@
+ 
+ using namespace MockCompositor;
+ 
+-constexpr int dataDeviceVersion = 1;
++constexpr int dataDeviceVersion = 3;
+ 
+ class DataDeviceCompositor : public DefaultCompositor {
+ public:
+diff --git a/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp b/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
+index 9312c2e5..2ea382f1 100644
+--- a/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
++++ b/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
+@@ -73,6 +73,7 @@ private slots:
+     void multiTouch();
+     void multiTouchUpAndMotionFrame();
+     void tapAndMoveInSameFrame();
++    void cancelTouch();
+ };
+ 
+ void tst_seatv5::bindsToSeat()
+@@ -646,5 +647,34 @@ void tst_seatv5::tapAndMoveInSameFrame()
+     QTRY_COMPARE(window.m_events.last().touchPoints.first().state(), Qt::TouchPointState::TouchPointReleased);
+ }
+ 
++void tst_seatv5::cancelTouch()
++{
++    TouchWindow window;
++    QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
++
++    exec([=] {
++        auto *t = touch();
++        auto *c = client();
++        t->sendDown(xdgToplevel()->surface(), {32, 32}, 1);
++        t->sendFrame(c);
++        t->sendCancel(c);
++        t->sendFrame(c);
++    });
++
++    QTRY_VERIFY(!window.m_events.empty());
++    {
++        auto e = window.m_events.takeFirst();
++        QCOMPARE(e.type, QEvent::TouchBegin);
++        QCOMPARE(e.touchPointStates, Qt::TouchPointPressed);
++        QCOMPARE(e.touchPoints.length(), 1);
++        QCOMPARE(e.touchPoints.first().pos(), QPointF(32-window.frameMargins().left(), 32-window.frameMargins().top()));
++    }
++    {
++        auto e = window.m_events.takeFirst();
++        QCOMPARE(e.type, QEvent::TouchCancel);
++        QCOMPARE(e.touchPoints.length(), 0);
++    }
++}
++
+ QCOMPOSITOR_TEST_MAIN(tst_seatv5)
+ #include "tst_seatv5.moc"
+diff --git a/qtwayland/tests/auto/client/shared/corecompositor.cpp b/qtwayland/tests/auto/client/shared/corecompositor.cpp
+index 5c6c83ba..fa9b7662 100644
+--- a/qtwayland/tests/auto/client/shared/corecompositor.cpp
++++ b/qtwayland/tests/auto/client/shared/corecompositor.cpp
+@@ -27,6 +27,7 @@
+ ****************************************************************************/
+ 
+ #include "corecompositor.h"
++#include <thread>
+ 
+ namespace MockCompositor {
+ 
+diff --git a/qtwayland/tests/auto/client/shared/coreprotocol.cpp b/qtwayland/tests/auto/client/shared/coreprotocol.cpp
+index 0d988521..d1a2e7cb 100644
+--- a/qtwayland/tests/auto/client/shared/coreprotocol.cpp
++++ b/qtwayland/tests/auto/client/shared/coreprotocol.cpp
+@@ -451,6 +451,13 @@ void Touch::sendFrame(wl_client *client)
+         send_frame(r->handle);
+ }
+ 
++void Touch::sendCancel(wl_client *client)
++{
++    const auto touchResources = resourceMap().values(client);
++    for (auto *r : touchResources)
++        send_cancel(r->handle);
++}
++
+ uint Keyboard::sendEnter(Surface *surface)
+ {
+     auto serial = m_seat->m_compositor->nextSerial();
+diff --git a/qtwayland/tests/auto/client/shared/coreprotocol.h b/qtwayland/tests/auto/client/shared/coreprotocol.h
+index a1af137a..210d8ddb 100644
+--- a/qtwayland/tests/auto/client/shared/coreprotocol.h
++++ b/qtwayland/tests/auto/client/shared/coreprotocol.h
+@@ -158,7 +158,7 @@ class WlCompositor : public Global, public QtWaylandServer::wl_compositor
+ {
+     Q_OBJECT
+ public:
+-    explicit WlCompositor(CoreCompositor *compositor, int version = 3)
++    explicit WlCompositor(CoreCompositor *compositor, int version = 4)
+         : QtWaylandServer::wl_compositor(compositor->m_display, version)
+         , m_compositor(compositor)
+     {}
+@@ -364,6 +364,7 @@ public:
+     uint sendUp(wl_client *client, int id);
+     void sendMotion(wl_client *client, const QPointF &position, int id);
+     void sendFrame(wl_client *client);
++    void sendCancel(wl_client *client);
+ 
+     Seat *m_seat = nullptr;
+ };
+diff --git a/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp b/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
+index a415cbf5..b1d3d07d 100644
+--- a/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
++++ b/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
+@@ -342,7 +342,7 @@ Compositor::Compositor(MockCompositor *mockCompositor)
+         exit(EXIT_FAILURE);
+     }
+ 
+-    wl_global_create(m_display, &wl_compositor_interface, 1, this, bindCompositor);
++    wl_global_create(m_display, &wl_compositor_interface, 4, this, bindCompositor);
+ 
+     m_data_device_manager.reset(new DataDeviceManager(this, m_display));
+ 
+diff --git a/qtwayland/tests/auto/client/shared_old/mocksurface.cpp b/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
+index e9df5f90..c3246e4a 100644
+--- a/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
++++ b/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
+@@ -125,6 +125,16 @@ void Surface::surface_damage(Resource *resource,
+     Q_UNUSED(height);
+ }
+ 
++void Surface::surface_damage_buffer(Resource *resource,
++                                    int32_t x, int32_t y, int32_t width, int32_t height)
++{
++    Q_UNUSED(resource);
++    Q_UNUSED(x);
++    Q_UNUSED(y);
++    Q_UNUSED(width);
++    Q_UNUSED(height);
++}
++
+ void Surface::surface_frame(Resource *resource,
+                             uint32_t callback)
+ {
+diff --git a/qtwayland/tests/auto/client/shared_old/mocksurface.h b/qtwayland/tests/auto/client/shared_old/mocksurface.h
+index 949dc23d..d176837e 100644
+--- a/qtwayland/tests/auto/client/shared_old/mocksurface.h
++++ b/qtwayland/tests/auto/client/shared_old/mocksurface.h
+@@ -65,6 +65,8 @@ protected:
+                         struct wl_resource *buffer, int x, int y) override;
+     void surface_damage(Resource *resource,
+                         int32_t x, int32_t y, int32_t width, int32_t height) override;
++    void surface_damage_buffer(Resource *resource,
++                               int32_t x, int32_t y, int32_t width, int32_t height) override;
+     void surface_frame(Resource *resource,
+                        uint32_t callback) override;
+     void surface_commit(Resource *resource) override;
+diff --git a/qtwayland/tests/auto/client/surface/tst_surface.cpp b/qtwayland/tests/auto/client/surface/tst_surface.cpp
+index 95e4e609..60c672ce 100644
+--- a/qtwayland/tests/auto/client/surface/tst_surface.cpp
++++ b/qtwayland/tests/auto/client/surface/tst_surface.cpp
+@@ -129,6 +129,10 @@ void tst_surface::waitForFrameCallbackGl()
+     // Make sure we follow frame callbacks for some frames
+     for (int i = 0; i < 5; ++i) {
+         xdgPingAndWaitForPong(); // Make sure things have happened on the client
++        if (!qEnvironmentVariableIntValue("QT_WAYLAND_DISABLE_WINDOWDECORATION") && i == 0) {
++            QCOMPARE(bufferSpy.count(), 1);
++            bufferSpy.removeFirst();
++        }
+         exec([&] {
+             QVERIFY(bufferSpy.empty()); // Make sure no extra buffers have arrived
+             QVERIFY(!xdgToplevel()->surface()->m_waitingFrameCallbacks.empty());
+diff --git a/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp b/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
+index 2277bbb8..747875b4 100644
+--- a/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
++++ b/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
+@@ -31,6 +31,7 @@
+ #include <QtGui/QOpenGLWindow>
+ #include <QtGui/qpa/qplatformnativeinterface.h>
+ #include <QtWaylandClient/private/wayland-wayland-client-protocol.h>
++#include <QtWaylandClient/private/qwaylandwindow_p.h>
+ 
+ using namespace MockCompositor;
+ 
+@@ -45,6 +46,7 @@ private slots:
+     void configureStates();
+     void popup();
+     void tooltipOnPopup();
++    void tooltipAndSiblingPopup();
+     void switchPopups();
+     void hidePopupParent();
+     void pongs();
+@@ -138,6 +140,7 @@ void tst_xdgshell::configureSize()
+ 
+ void tst_xdgshell::configureStates()
+ {
++    QVERIFY(qputenv("QT_WAYLAND_FRAME_CALLBACK_TIMEOUT", "0"));
+     QRasterWindow window;
+     window.resize(64, 48);
+     window.show();
+@@ -154,9 +157,12 @@ void tst_xdgshell::configureStates()
+     // Toplevel windows don't know their position on xdg-shell
+ //    QCOMPARE(window.frameGeometry().topLeft(), QPoint()); // TODO: this doesn't currently work when window decorations are enabled
+ 
+-//    QEXPECT_FAIL("", "configure has already been acked, we shouldn't have to wait for isActive", Continue);
+-//    QVERIFY(window.isActive());
+-    QTRY_VERIFY(window.isActive()); // Just make sure it eventually get's set correctly
++    // window.windowstate() is driven by keyboard focus, however for decorations we want to follow
++    // XDGShell this is internal to QtWayland so it is queried directly
++    auto waylandWindow = static_cast<QtWaylandClient::QWaylandWindow *>(window.handle());
++    Q_ASSERT(waylandWindow);
++    QTRY_VERIFY(waylandWindow->windowStates().testFlag(
++            Qt::WindowActive)); // Just make sure it eventually get's set correctly
+ 
+     const QSize screenSize(640, 480);
+     const uint maximizedSerial = exec([=] {
+@@ -186,6 +192,7 @@ void tst_xdgshell::configureStates()
+     QCOMPARE(window.windowStates(), Qt::WindowNoState);
+     QCOMPARE(window.frameGeometry().size(), windowedSize);
+ //    QCOMPARE(window.frameGeometry().topLeft(), QPoint()); // TODO: this doesn't currently work when window decorations are enabled
++    QVERIFY(qunsetenv("QT_WAYLAND_FRAME_CALLBACK_TIMEOUT"));
+ }
+ 
+ void tst_xdgshell::popup()
+@@ -340,6 +347,92 @@ void tst_xdgshell::tooltipOnPopup()
+     QCOMPOSITOR_TRY_COMPARE(xdgPopup(0), nullptr);
+ }
+ 
++void tst_xdgshell::tooltipAndSiblingPopup()
++{
++    class ToolTip : public QRasterWindow {
++    public:
++        explicit ToolTip(QWindow *parent) {
++            setTransientParent(parent);
++            setFlags(Qt::ToolTip);
++            resize(100, 100);
++            show();
++        }
++        void mousePressEvent(QMouseEvent *event) override {
++            QRasterWindow::mousePressEvent(event);
++            m_popup = new QRasterWindow;
++            m_popup->setTransientParent(transientParent());
++            m_popup->setFlags(Qt::Popup);
++            m_popup->resize(100, 100);
++            m_popup->show();
++        }
++
++        QRasterWindow *m_popup = nullptr;
++    };
++
++    class Window : public QRasterWindow {
++    public:
++        void mousePressEvent(QMouseEvent *event) override {
++            QRasterWindow::mousePressEvent(event);
++            m_tooltip = new ToolTip(this);
++        }
++        ToolTip *m_tooltip = nullptr;
++    };
++
++    Window window;
++    window.resize(200, 200);
++    window.show();
++
++    QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
++    exec([=] { xdgToplevel()->sendCompleteConfigure(); });
++    QCOMPOSITOR_TRY_VERIFY(xdgToplevel()->m_xdgSurface->m_committedConfigureSerial);
++
++    exec([=] {
++        auto *surface = xdgToplevel()->surface();
++        auto *p = pointer();
++        auto *c = client();
++        p->sendEnter(surface, {100, 100});
++        p->sendFrame(c);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_pressed);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_released);
++        p->sendFrame(c);
++        p->sendLeave(surface);
++        p->sendFrame(c);
++    });
++
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup());
++    exec([=] { xdgPopup()->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup()->m_xdgSurface->m_committedConfigureSerial);
++    QCOMPOSITOR_TRY_VERIFY(!xdgPopup()->m_grabbed);
++
++    exec([=] {
++        auto *surface = xdgPopup()->surface();
++        auto *p = pointer();
++        auto *c = client();
++        p->sendEnter(surface, {100, 100});
++        p->sendFrame(c);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_pressed);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_released);
++        p->sendFrame(c);
++    });
++
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1));
++    exec([=] { xdgPopup(1)->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1)->m_xdgSurface->m_committedConfigureSerial);
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1)->m_grabbed);
++
++    // Close the middle tooltip (it should not close the sibling popup)
++    window.m_tooltip->close();
++
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(1), nullptr);
++    // Verify the remaining xdg surface is a grab popup..
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(0));
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(0)->m_grabbed);
++
++    window.m_tooltip->m_popup->close();
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(1), nullptr);
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(0), nullptr);
++}
++
+ // QTBUG-65680
+ void tst_xdgshell::switchPopups()
+ {
+@@ -505,7 +598,7 @@ void tst_xdgshell::minMaxSize()
+     window.show();
+     QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
+ 
+-    exec([=] { xdgToplevel()->sendCompleteConfigure(); });
++    // we don't roundtrip with our configuration the initial commit should be correct
+ 
+     QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.minSize, QSize(100, 100));
+     QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.maxSize, QSize(1000, 1000));
+Submodule qtwebchannel 618422ee..f8949655:
+diff --git a/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp b/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
+index 536eb5c..898d769 100644
+--- a/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
++++ b/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
+@@ -186,8 +186,6 @@ Q_DECLARE_TYPEINFO(OverloadResolutionCandidate, Q_MOVABLE_TYPE);
+ QMetaObjectPublisher::QMetaObjectPublisher(QWebChannel *webChannel)
+     : QObject(webChannel)
+     , webChannel(webChannel)
+-    , signalHandler(this)
+-    , clientIsIdle(false)
+     , blockUpdates(false)
+     , propertyUpdatesInitialized(false)
+ {
+@@ -301,17 +299,17 @@ QJsonObject QMetaObjectPublisher::classInfoForObject(const QObject *object, QWeb
+     return data;
+ }
+ 
+-void QMetaObjectPublisher::setClientIsIdle(bool isIdle)
++void QMetaObjectPublisher::setClientIsIdle(bool isIdle, QWebChannelAbstractTransport *transport)
+ {
+-    if (clientIsIdle == isIdle) {
+-        return;
+-    }
+-    clientIsIdle = isIdle;
+-    if (!isIdle && timer.isActive()) {
+-        timer.stop();
+-    } else if (isIdle && !timer.isActive()) {
+-        timer.start(PROPERTY_UPDATE_INTERVAL, this);
+-    }
++    transportState[transport].clientIsIdle = isIdle;
++    if (isIdle)
++        sendEnqueuedPropertyUpdates(transport);
++}
++
++bool QMetaObjectPublisher::isClientIdle(QWebChannelAbstractTransport *transport)
++{
++    auto found = transportState.find(transport);
++    return found != transportState.end() && found.value().clientIsIdle;
+ }
+ 
+ QJsonObject QMetaObjectPublisher::initializeClient(QWebChannelAbstractTransport *transport)
+@@ -333,6 +331,7 @@ QJsonObject QMetaObjectPublisher::initializeClient(QWebChannelAbstractTransport
+ 
+ void QMetaObjectPublisher::initializePropertyUpdates(const QObject *const object, const QJsonObject &objectInfo)
+ {
++    auto *signalHandler = signalHandlerFor(object);
+     foreach (const QJsonValue &propertyInfoVar, objectInfo[KEY_PROPERTIES].toArray()) {
+         const QJsonArray &propertyInfo = propertyInfoVar.toArray();
+         if (propertyInfo.size() < 2) {
+@@ -353,19 +352,19 @@ void QMetaObjectPublisher::initializePropertyUpdates(const QObject *const object
+ 
+         // Only connect for a property update once
+         if (connectedProperties.isEmpty()) {
+-            signalHandler.connectTo(object, signalIndex);
++            signalHandler->connectTo(object, signalIndex);
+         }
+ 
+         connectedProperties.insert(propertyIndex);
+     }
+ 
+     // also always connect to destroyed signal
+-    signalHandler.connectTo(object, s_destroyedSignalIndex);
++    signalHandler->connectTo(object, s_destroyedSignalIndex);
+ }
+ 
+ void QMetaObjectPublisher::sendPendingPropertyUpdates()
+ {
+-    if (blockUpdates || !clientIsIdle || pendingPropertyUpdates.isEmpty()) {
++    if (blockUpdates) {
+         return;
+     }
+ 
+@@ -415,18 +414,19 @@ void QMetaObjectPublisher::sendPendingPropertyUpdates()
+ 
+     // data does not contain specific updates
+     if (!data.isEmpty()) {
+-        setClientIsIdle(false);
+-
+         message[KEY_DATA] = data;
+-        broadcastMessage(message);
++        enqueueBroadcastMessage(message);
+     }
+ 
+     // send every property update which is not supposed to be broadcasted
+     const QHash<QWebChannelAbstractTransport*, QJsonArray>::const_iterator suend = specificUpdates.constEnd();
+     for (QHash<QWebChannelAbstractTransport*, QJsonArray>::const_iterator it = specificUpdates.constBegin(); it != suend; ++it) {
+         message[KEY_DATA] = it.value();
+-        it.key()->sendMessage(message);
++        enqueueMessage(message, it.key());
+     }
++
++    for (auto state = transportState.begin(); state != transportState.end(); ++state)
++        sendEnqueuedPropertyUpdates(state.key());
+ }
+ 
+ QVariant QMetaObjectPublisher::invokeMethod(QObject *const object, const QMetaMethod &method,
+@@ -572,7 +572,7 @@ void QMetaObjectPublisher::signalEmitted(const QObject *object, const int signal
+         }
+     } else {
+         pendingPropertyUpdates[object][signalIndex] = arguments;
+-        if (clientIsIdle && !blockUpdates && !timer.isActive()) {
++        if (!blockUpdates && !timer.isActive()) {
+             timer.start(PROPERTY_UPDATE_INTERVAL, this);
+         }
+     }
+@@ -590,7 +590,7 @@ void QMetaObjectPublisher::objectDestroyed(const QObject *object)
+     // only remove from handler when we initialized the property updates
+     // cf: https://bugreports.qt.io/browse/QTBUG-60250
+     if (propertyUpdatesInitialized) {
+-        signalHandler.remove(object);
++        signalHandlerFor(object)->remove(object);
+         signalToPropertyMap.remove(object);
+     }
+     pendingPropertyUpdates.remove(object);
+@@ -852,6 +852,52 @@ void QMetaObjectPublisher::broadcastMessage(const QJsonObject &message) const
+     }
+ }
+ 
++void QMetaObjectPublisher::enqueueBroadcastMessage(const QJsonObject &message)
++{
++    if (webChannel->d_func()->transports.isEmpty()) {
++        qWarning("QWebChannel is not connected to any transports, cannot send message: %s",
++                 QJsonDocument(message).toJson().constData());
++        return;
++    }
++
++    for (auto *transport : webChannel->d_func()->transports) {
++        auto &state = transportState[transport];
++        state.queuedMessages.append(message);
++    }
++}
++
++void QMetaObjectPublisher::enqueueMessage(const QJsonObject &message,
++                                          QWebChannelAbstractTransport *transport)
++{
++    auto &state = transportState[transport];
++    state.queuedMessages.append(message);
++}
++
++void QMetaObjectPublisher::sendEnqueuedPropertyUpdates(QWebChannelAbstractTransport *transport)
++{
++    auto found = transportState.find(transport);
++    if (found != transportState.end() && found.value().clientIsIdle
++        && !found.value().queuedMessages.isEmpty()) {
++
++        // If the client is connected with an in-process transport, it can
++        // happen that a message triggers a subsequent property change. In
++        // that case, we need to ensure that the queued messages have already
++        // been cleared; otherwise the recursive call will send everythig again.
++        // Case in point: The qmlwebchannel tests fail if we don't clear the
++        // queued messages before sending them out.
++        // For that same reason set the client to "busy" (aka non-idle) just
++        // right before sending out the messages; otherwise a potential
++        // "Idle" type message will not correctly restore the Idle state.
++        const auto messages = std::move(found.value().queuedMessages);
++        Q_ASSERT(found.value().queuedMessages.isEmpty());
++        found.value().clientIsIdle = false;
++
++        for (const auto &message : messages) {
++            transport->sendMessage(message);
++        }
++    }
++}
++
+ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannelAbstractTransport *transport)
+ {
+     if (!webChannel->d_func()->transports.contains(transport)) {
+@@ -866,7 +912,7 @@ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannel
+ 
+     const MessageType type = toType(message.value(KEY_TYPE));
+     if (type == TypeIdle) {
+-        setClientIsIdle(true);
++        setClientIsIdle(true, transport);
+     } else if (type == TypeInit) {
+         if (!message.contains(KEY_ID)) {
+             qWarning("JSON message object is missing the id property: %s",
+@@ -913,9 +959,9 @@ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannel
+                 return;
+             transport->sendMessage(createResponse(message.value(KEY_ID), wrapResult(result, transport)));
+         } else if (type == TypeConnectToSignal) {
+-            signalHandler.connectTo(object, message.value(KEY_SIGNAL).toInt(-1));
++            signalHandlerFor(object)->connectTo(object, message.value(KEY_SIGNAL).toInt(-1));
+         } else if (type == TypeDisconnectFromSignal) {
+-            signalHandler.disconnectFrom(object, message.value(KEY_SIGNAL).toInt(-1));
++            signalHandlerFor(object)->disconnectFrom(object, message.value(KEY_SIGNAL).toInt(-1));
+         } else if (type == TypeSetProperty) {
+             setProperty(object, message.value(KEY_PROPERTY).toInt(-1),
+                         message.value(KEY_VALUE));
+@@ -931,6 +977,7 @@ void QMetaObjectPublisher::setBlockUpdates(bool block)
+     blockUpdates = block;
+ 
+     if (!blockUpdates) {
++        timer.start(PROPERTY_UPDATE_INTERVAL, this);
+         sendPendingPropertyUpdates();
+     } else if (timer.isActive()) {
+         timer.stop();
+@@ -948,4 +995,15 @@ void QMetaObjectPublisher::timerEvent(QTimerEvent *event)
+     }
+ }
+ 
++SignalHandler<QMetaObjectPublisher> *QMetaObjectPublisher::signalHandlerFor(const QObject *object)
++{
++    auto thread = object->thread();
++    auto it = signalHandlers.find(thread);
++    if (it == signalHandlers.end()) {
++        it = signalHandlers.emplace(thread, this).first;
++        it->second.moveToThread(thread);
++    }
++    return &it->second;
++}
++
+ QT_END_NAMESPACE
+diff --git a/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h b/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
+index bbd9875..4713ef1 100644
+--- a/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
++++ b/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
+@@ -59,6 +59,9 @@
+ #include <QBasicTimer>
+ #include <QPointer>
+ #include <QJsonObject>
++#include <QQueue>
++
++#include <unordered_map>
+ 
+ #include "qwebchannelglobal.h"
+ 
+@@ -109,17 +112,36 @@ public:
+      */
+     void broadcastMessage(const QJsonObject &message) const;
+ 
++    /**
++     * Enqueue the given @p message to all known transports.
++     */
++    void enqueueBroadcastMessage(const QJsonObject &message);
++
++    /**
++     * Enqueue the given @p message to @p transport.
++     */
++    void enqueueMessage(const QJsonObject &message, QWebChannelAbstractTransport *transport);
++
++    /**
++     * If client for given @p transport is idle, send queued messaged to @p transport and then mark
++     * the client as not idle.
++     */
++    void sendEnqueuedPropertyUpdates(QWebChannelAbstractTransport *transport);
++
+     /**
+      * Serialize the QMetaObject of @p object and return it in JSON form.
+      */
+     QJsonObject classInfoForObject(const QObject *object, QWebChannelAbstractTransport *transport);
+ 
+     /**
+-     * Set the client to idle or busy, based on the value of @p isIdle.
+-     *
+-     * When the value changed, start/stop the property update timer accordingly.
++     * Set the client to idle or busy for a single @p transport, based on the value of @p isIdle.
++     */
++    void setClientIsIdle(bool isIdle, QWebChannelAbstractTransport *transport);
++
++    /**
++     * Check that client is idle for @p transport.
+      */
+-    void setClientIsIdle(bool isIdle);
++    bool isClientIdle(QWebChannelAbstractTransport *transport);
+ 
+     /**
+      * Initialize clients by sending them the class information of the registered objects.
+@@ -272,10 +294,18 @@ private:
+     friend class TestWebChannel;
+ 
+     QWebChannel *webChannel;
+-    SignalHandler<QMetaObjectPublisher> signalHandler;
++    std::unordered_map<const QThread*, SignalHandler<QMetaObjectPublisher>> signalHandlers;
++    SignalHandler<QMetaObjectPublisher> *signalHandlerFor(const QObject *object);
+ 
+-    // true when the client is idle, false otherwise
+-    bool clientIsIdle;
++    struct TransportState
++    {
++        TransportState() : clientIsIdle(false) { }
++        // true when the client is idle, false otherwise
++        bool clientIsIdle;
++        // messages to send
++        QQueue<QJsonObject> queuedMessages;
++    };
++    QHash<QWebChannelAbstractTransport *, TransportState> transportState;
+ 
+     // true when no property updates should be sent, false otherwise
+     bool blockUpdates;
+diff --git a/qtwebchannel/src/webchannel/signalhandler_p.h b/qtwebchannel/src/webchannel/signalhandler_p.h
+index 27afadb..d77373c 100644
+--- a/qtwebchannel/src/webchannel/signalhandler_p.h
++++ b/qtwebchannel/src/webchannel/signalhandler_p.h
+@@ -56,6 +56,7 @@
+ #include <QVector>
+ #include <QMetaMethod>
+ #include <QDebug>
++#include <QThread>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -71,6 +72,7 @@ static const int s_destroyedSignalIndex = QObject::staticMetaObject.indexOfMetho
+ template<class Receiver>
+ class SignalHandler : public QObject
+ {
++    Q_DISABLE_COPY(SignalHandler)
+ public:
+     SignalHandler(Receiver *receiver, QObject *parent = 0);
+ 
+@@ -268,6 +270,7 @@ int SignalHandler<Receiver>::qt_metacall(QMetaObject::Call call, int methodId, v
+     if (call == QMetaObject::InvokeMetaMethod) {
+         const QObject *object = sender();
+         Q_ASSERT(object);
++        Q_ASSERT(QThread::currentThread() == object->thread());
+         Q_ASSERT(senderSignalIndex() == methodId);
+         Q_ASSERT(m_connectionsCounter.contains(object));
+         Q_ASSERT(m_connectionsCounter.value(object).contains(methodId));
+diff --git a/qtwebchannel/tests/auto/qml/testwebchannel.cpp b/qtwebchannel/tests/auto/qml/testwebchannel.cpp
+index 9891687..3ca81c2 100644
+--- a/qtwebchannel/tests/auto/qml/testwebchannel.cpp
++++ b/qtwebchannel/tests/auto/qml/testwebchannel.cpp
+@@ -46,7 +46,11 @@ TestWebChannel::~TestWebChannel()
+ 
+ bool TestWebChannel::clientIsIdle() const
+ {
+-    return QWebChannel::d_func()->publisher->clientIsIdle;
++    for (auto *transport : QWebChannel::d_func()->transports) {
++        if (QWebChannel::d_func()->publisher->isClientIdle(transport))
++            return true;
++    }
++    return false;
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp b/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
+index 181da9e..37f989a 100644
+--- a/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
++++ b/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
+@@ -785,7 +785,7 @@ void TestWebChannel::testTransportWrapObjectProperties()
+     DummyTransport *dummyTransport = new DummyTransport(this);
+     channel.connectTo(dummyTransport);
+     channel.d_func()->publisher->initializeClient(dummyTransport);
+-    channel.d_func()->publisher->setClientIsIdle(true);
++    channel.d_func()->publisher->setClientIsIdle(true, dummyTransport);
+ 
+     QCOMPARE(channel.d_func()->publisher->transportedWrappedObjects.size(), 0);
+ 
+@@ -943,8 +943,6 @@ void TestWebChannel::testInfiniteRecursion()
+ 
+ void TestWebChannel::testAsyncObject()
+ {
+-    QSKIP("This test is broken. See QTBUG-80729");
+-
+     QWebChannel channel;
+     channel.connectTo(m_dummyTransport);
+ 
+@@ -990,6 +988,50 @@ void TestWebChannel::testAsyncObject()
+     thread.wait();
+ }
+ 
++void TestWebChannel::testPropertyMultipleTransports()
++{
++    DummyTransport transport1;
++    DummyTransport transport2;
++
++    QWebChannel channel;
++    QMetaObjectPublisher *publisher = channel.d_func()->publisher;
++
++    TestObject testObj;
++    testObj.setObjectName("testObject");
++    channel.registerObject(testObj.objectName(), &testObj);
++    channel.connectTo(&transport1);
++    channel.connectTo(&transport2);
++
++    testObj.setProp("Hello");
++
++    publisher->initializeClient(&transport1);
++    publisher->initializeClient(&transport2);
++    publisher->setClientIsIdle(true, &transport1);
++    QCOMPARE(publisher->isClientIdle(&transport1), true);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++    QVERIFY(transport1.messagesSent().isEmpty());
++    QVERIFY(transport2.messagesSent().isEmpty());
++
++    testObj.setProp("World");
++    QTRY_COMPARE_WITH_TIMEOUT(transport1.messagesSent().size(), 1u, 2000);
++    QCOMPARE(transport2.messagesSent().size(), 0u);
++    publisher->setClientIsIdle(true, &transport2);
++    QTRY_COMPARE_WITH_TIMEOUT(transport2.messagesSent().size(), 1u, 2000);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++
++    testObj.setProp("!!!");
++    publisher->setClientIsIdle(true, &transport2);
++    QCOMPARE(publisher->isClientIdle(&transport2), true);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QTRY_COMPARE_WITH_TIMEOUT(transport2.messagesSent().size(), 2u, 2000);
++    QCOMPARE(transport1.messagesSent().size(), 1u);
++    publisher->setClientIsIdle(true, &transport1);
++    QTRY_COMPARE_WITH_TIMEOUT(transport1.messagesSent().size(), 2u, 2000);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++}
++
+ class FunctionWrapper : public QObject
+ {
+     Q_OBJECT
+@@ -1082,7 +1124,7 @@ void TestWebChannel::benchInitializeClients()
+ 
+         publisher->propertyUpdatesInitialized = false;
+         publisher->signalToPropertyMap.clear();
+-        publisher->signalHandler.clear();
++        publisher->signalHandlers.clear();
+     }
+ }
+ 
+@@ -1107,7 +1149,7 @@ void TestWebChannel::benchPropertyUpdates()
+             obj->change();
+         }
+ 
+-        channel.d_func()->publisher->clientIsIdle = true;
++        channel.d_func()->publisher->setClientIsIdle(true, m_dummyTransport);
+         channel.d_func()->publisher->sendPendingPropertyUpdates();
+     }
+ }
+diff --git a/qtwebchannel/tests/auto/webchannel/tst_webchannel.h b/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
+index eae21f4..dd4e690 100644
+--- a/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
++++ b/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
+@@ -348,6 +348,7 @@ private slots:
+     void testJsonToVariant();
+     void testInfiniteRecursion();
+     void testAsyncObject();
++    void testPropertyMultipleTransports();
+     void testDeletionDuringMethodInvocation_data();
+     void testDeletionDuringMethodInvocation();
+ 
+Submodule qtwebengine f328054d...38e0df6c (commits not present)
+Submodule qtwebsockets 65850954..63fb8da1:
+diff --git a/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp b/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
+index 2affdd5..95f1194 100644
+--- a/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
++++ b/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
+@@ -273,6 +273,7 @@ void QWebSocketDataProcessor::clear()
+     if (!m_pConverterState)
+         m_pConverterState = new QTextCodec::ConverterState(QTextCodec::ConvertInvalidToNull |
+                                                            QTextCodec::IgnoreHeader);
++    frame.clear();
+ }
+ 
+ /*!
+diff --git a/qtwebsockets/src/websockets/qwebsocketprotocol.cpp b/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
+index df87a93..d0465f1 100644
+--- a/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
++++ b/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
+@@ -210,7 +210,7 @@ void QWebSocketProtocol::mask(char *payload, quint64 size, quint32 maskingKey)
+                             quint8((maskingKey & 0x0000FF00u) >> 8),
+                             quint8((maskingKey & 0x000000FFu))
+                           };
+-    int i = 0;
++    quint64 i = 0;
+     while (size-- > 0)
+         *payload++ ^= mask[i++ % 4];
+ }
diff --git a/srcpkgs/qt5/template b/srcpkgs/qt5/template
index 39a02979ee669..414b5e532f904 100644
--- a/srcpkgs/qt5/template
+++ b/srcpkgs/qt5/template
@@ -2,11 +2,11 @@
 #
 # revbump libqtxdg after bumping patch version
 pkgname=qt5
-version=5.15.7+20221119
+version=5.15.8
+revision=1
+build_style=meta
 # commit f8c9fb304bc3e53b3aa07f962cd74e9160decccc
 # base repo: https://invent.kde.org/qt/qt/qt5
-revision=7
-build_style=meta
 hostmakedepends="cmake clang flex perl glib-devel pkg-config
  python re2c ruby which"
 makedepends="SDL2-devel Vulkan-Headers alsa-lib-devel double-conversion-devel
@@ -29,8 +29,9 @@ homepage="https://qt.io/"
 # tarball is generated with `git archive-all qt5-$version.tar.gz`
 # to keep the size smaller qtwebengine, qtwebview, qtdocgallery, qtactiveqt and qtpim
 # can be marked with the export-ignore attribute
-distfiles="https://void.johnnynator.dev/distfiles/qt5-${version}.tar.gz"
-checksum=9d57af471c78029a362276b7c99108ea009f511bb9ba6ff6cb884f6ddd255e9f
+#distfiles="https://void.johnnynator.dev/distfiles/qt5-${version}.tar.gz"
+distfiles="https://download.qt.io/archive/qt/5.15/${version}/single/qt-everywhere-opensource-src-${version}.tar.xz"
+checksum=776a9302c336671f9406a53bd30b8e36f825742b2ec44a57c08217bff0fa86b9
 python_version=2 #unverified
 replaces="qt5-doc<5.6.0 qt5-quick1<5.6.0 qt5-quick1-devel<5.6.0 qt5-webkit<5.6.0 qt5-webkit-devel<5.6.0
  qt5-enginio<5.7.1 qt5-enginio-devel<5.7.1 qt5-plugin-gtk<5.7.1 qt5-canvas3d<5.13.0"
@@ -246,7 +247,6 @@ do_configure() {
 	# opts+=" -v"
 	opts+=" -skip qtwebengine"
 	opts+=" -skip qtwebview"
-	opts+=" -skip qtdocgallery"
 	opts+=" -skip qtpim"
 	opts+=" -skip qtsystems"
 	opts+=" -skip qtspeech"

From d850bfbd899de2446c8d6725bef9fd63fd37a899 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 068/115] qtav: revbump for ffmpeg4-4.4.3

---
 srcpkgs/qtav/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtav/template b/srcpkgs/qtav/template
index 34c30b2c0c78f..2d00ad104355e 100644
--- a/srcpkgs/qtav/template
+++ b/srcpkgs/qtav/template
@@ -1,10 +1,10 @@
 # Template file for 'qtav'
 pkgname=qtav
 version=1.13.0
-revision=1
+revision=2
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel libass-devel libopenal-devel
+makedepends="ffmpeg4-devel libass-devel libopenal-devel
  libva-glx-devel libXv-devel pulseaudio-devel
  qt5-declarative-devel qt5-svg-devel
  qt5-quickcontrols"

From 6a3f292067cceef07a2a66855a407767fc8d501c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 069/115] qtox: revbump for ffmpeg-6.0

---
 srcpkgs/qtox/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qtox/template b/srcpkgs/qtox/template
index 39c643fecdb5a..bb70e7f51240a 100644
--- a/srcpkgs/qtox/template
+++ b/srcpkgs/qtox/template
@@ -1,7 +1,7 @@
 # Template file for 'qtox'
 pkgname=qtox
 version=1.17.6
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DUPDATE_CHECK=OFF
  -DGIT_DESCRIBE=${version}

From 36ca48499beb7b0f8b4e29927761dbd0e865e5e3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 070/115] retroarch: revbump for ffmpeg-6.0

---
 srcpkgs/retroarch/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroarch/template b/srcpkgs/retroarch/template
index 28016aa0129e6..20a1415913be5 100644
--- a/srcpkgs/retroarch/template
+++ b/srcpkgs/retroarch/template
@@ -1,7 +1,7 @@
 # Template file for 'retroarch'
 pkgname=retroarch
 version=1.15.0
-revision=1
+revision=2
 build_style=configure
 configure_args="--prefix=/usr --sysconfdir=/etc --enable-networking
  --enable-udev --disable-builtinflac --disable-builtinglslang

From 41a8b42b78635ab6ea6a3408bc67b55c242ae81f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 071/115] scrcpy: revbump for ffmpeg-6.0

---
 srcpkgs/scrcpy/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/scrcpy/template b/srcpkgs/scrcpy/template
index ac18bc03418ce..f39a7f678ab35 100644
--- a/srcpkgs/scrcpy/template
+++ b/srcpkgs/scrcpy/template
@@ -1,7 +1,7 @@
 # Template file for 'scrcpy'
 pkgname=scrcpy
 version=2.1.1
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcompile_server=false
  -Dprebuilt_server=/usr/share/scrcpy/scrcpy-server-v${version}"

From 457797b5f24a7d248cbcd4c0902979d4ad014ac1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 072/115] spek-alternative: revbump for ffmpeg4-4.4.3

---
 srcpkgs/spek-alternative/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/spek-alternative/template b/srcpkgs/spek-alternative/template
index d65086b8f008c..05246f1b8d0c8 100644
--- a/srcpkgs/spek-alternative/template
+++ b/srcpkgs/spek-alternative/template
@@ -1,11 +1,11 @@
 # Template file for 'spek-alternative'
 pkgname=spek-alternative
 version=0.8.2.3
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake gettext-devel intltool libtool pkg-config wxWidgets-common"
-makedepends="ffmpeg-devel wxWidgets-gtk3-devel"
-depends="ffmpeg"
+makedepends="ffmpeg4-devel wxWidgets-gtk3-devel"
+depends="ffmpeg4"
 short_desc="Acoustic spectrum analyser"
 maintainer="Kartik Singh <kartik.ynwa@gmail.com>"
 license="GPL-3.0-or-later"

From ac70d6b6e91a5487af32bde40a40d4c55a6fa611 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 073/115] ssr: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ssr/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/ssr/template b/srcpkgs/ssr/template
index b055b9ec0774a..3448ca110eb0c 100644
--- a/srcpkgs/ssr/template
+++ b/srcpkgs/ssr/template
@@ -1,11 +1,11 @@
 # Template file for 'ssr'
 pkgname=ssr
 version=0.4.4
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_QT5=ON"
 hostmakedepends="pkg-config"
-makedepends="alsa-lib-devel ffmpeg-devel glu-devel jack-devel pulseaudio-devel
+makedepends="alsa-lib-devel ffmpeg4-devel glu-devel jack-devel pulseaudio-devel
  qt5-tools-devel qt5-x11extras-devel libXinerama-devel v4l-utils-devel"
 depends="desktop-file-utils hicolor-icon-theme"
 short_desc="Simple Screen Recorder for programs and games"

From 5b07b24f7184f74d7d5e7b288d50fa4da1a89e65 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 074/115] sumo: revbump for ffmpeg-6.0

---
 srcpkgs/sumo/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/sumo/template b/srcpkgs/sumo/template
index 0f9b9ec815f56..a3fe134aa5acc 100644
--- a/srcpkgs/sumo/template
+++ b/srcpkgs/sumo/template
@@ -1,7 +1,7 @@
 # Template file for 'sumo'
 pkgname=sumo
 version=1.12.0
-revision=5
+revision=6
 build_style=cmake
 hostmakedepends="libgdal-tools pkg-config swig python3-setuptools"
 makedepends="python3-devel ffmpeg-devel fox-devel gl2ps-devel libgdal-devel

From f2e38a9b4d826ef245a060568b3e5ecbebfb9b96 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 075/115] synfig: revbump for ffmpeg-6.0 and mlt7

---
 srcpkgs/synfig/patches/ffmpeg6.patch | 71 ++++++++++++++++++++++++++++
 srcpkgs/synfig/template              |  6 +--
 2 files changed, 74 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/synfig/patches/ffmpeg6.patch

diff --git a/srcpkgs/synfig/patches/ffmpeg6.patch b/srcpkgs/synfig/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..10780b42782f4
--- /dev/null
+++ b/srcpkgs/synfig/patches/ffmpeg6.patch
@@ -0,0 +1,71 @@
+--- a/src/modules/mod_libavcodec/trgt_av.cpp	2022-10-25 09:14:12.000000000 -0400
++++ b/src/modules/mod_libavcodec/trgt_av.cpp	2023-05-05 21:34:17.899194559 -0400
+@@ -38,6 +41,7 @@
+ extern "C"
+ {
+ #ifdef HAVE_LIBAVFORMAT_AVFORMAT_H
++#	include <libavcodec/avcodec.h>
+ #	include <libavformat/avformat.h>
+ #elif defined(HAVE_AVFORMAT_H)
+ #	include <avformat.h>
+@@ -155,11 +156,11 @@
+     }
+ 
+ 	bool open_video_stream() {
+-		if (avcodec_open2(video_context, NULL, NULL) < 0) {
++		if (avcodec_open2(video_context, nullptr, nullptr) < 0) {
+ 			synfig::error("Target_LibAVCodec: could not open video codec");
+ 			// seems the calling of avcodec_free_context after error will cause crash
+ 			// so just forget about this context
+-			video_context = NULL;
++			video_context = nullptr;
+ 			close();
+ 			return false;
+         }
+@@ -234,15 +235,21 @@
+ 		close();
+ 
+ 		if (!av_registered) {
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 			av_register_all();
++#endif
+ 			av_registered = true;
+ 		}
+ 
+ 		// guess format
+-		AVOutputFormat *format = av_guess_format(NULL, filename.c_str(), NULL);
++#if LIBAVCODEC_VERSION_MAJOR < 59 // FFMPEG < 5.0
++		AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#else
++		const AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#endif
+ 		if (!format) {
+ 			synfig::warning("Target_LibAVCodec: unable to guess the output format, defaulting to MPEG");
+-			format = av_guess_format("mpeg", NULL, NULL);
++			format = av_guess_format("mpeg", nullptr, nullptr);
+ 		}
+ 		if (!format) {
+ 			synfig::error("Target_LibAVCodec: unable to find 'mpeg' output format");
+@@ -254,6 +261,7 @@
+ 		context = avformat_alloc_context();
+ 		assert(context);
+ 		context->oformat = format;
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 		if (filename.size() + 1 > sizeof(context->filename)) {
+ 			synfig::error(
+ 				"Target_LibAVCodec: filename too long, max length is %d, filename is '%s'",
+@@ -263,6 +271,14 @@
+ 			return false;
+ 		}
+ 		memcpy(context->filename, filename.c_str(), filename.size() + 1);
++#else
++		context->url = av_strndup(filename.c_str(), filename.size());
++		if (!context->url) {
++			synfig::error("Target_LibAVCodec: cannot allocate space for filename");
++			close();
++			return false;
++		}
++#endif
+ 
+ 		packet = av_packet_alloc();
+ 		assert(packet);
diff --git a/srcpkgs/synfig/template b/srcpkgs/synfig/template
index 30109541ec4fc..703cfd7ebac84 100644
--- a/srcpkgs/synfig/template
+++ b/srcpkgs/synfig/template
@@ -2,11 +2,11 @@
 # Should be kept in sync with 'synfigstudio' and 'ETL'
 pkgname=synfig
 version=1.4.4
-revision=3
+revision=4
 build_style=gnu-configure
 configure_args="--with-boost-libdir=${XBPS_CROSS_BASE}/usr/lib"
 hostmakedepends="boost-build ImageMagick pkg-config intltool"
-makedepends="ETL gettext-devel libxml++-devel mlt-devel libmagick-devel
+makedepends="ETL gettext-devel libxml++-devel mlt7-devel libmagick-devel
  libmng-devel boost-build boost-devel libopenexr-devel ffmpeg-devel"
 depends="ImageMagick"
 short_desc="CLI 2D vector and timeline-based animation software"
@@ -20,7 +20,7 @@ CXXFLAGS="-std=c++11 -DHAVE_LOCALE_H=1"
 
 synfig-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision}
-	 libopenexr-devel libxml++-devel mlt-devel"
+	 libopenexr-devel libxml++-devel mlt7-devel"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/bin/synfig-config

From 8c372a62a59775c92b1395999657c085223977f8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 076/115] timg: revbump for ffmpeg-6.0

---
 srcpkgs/timg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/timg/template b/srcpkgs/timg/template
index 2a2ab763d2fdd..8fb4327535ef9 100644
--- a/srcpkgs/timg/template
+++ b/srcpkgs/timg/template
@@ -1,7 +1,7 @@
 # Template file for 'timg'
 pkgname=timg
 version=1.4.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_OPENSLIDE_SUPPORT=off -Wno-dev"
 hostmakedepends="pkg-config git"

From 1de02376af8c09c26c3feb02958169ff0b4578e2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 077/115] tvheadend: revbump for ffmpeg4-4.4.3

---
 srcpkgs/tvheadend/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tvheadend/template b/srcpkgs/tvheadend/template
index a2004480332b2..46b52b6fb7f94 100644
--- a/srcpkgs/tvheadend/template
+++ b/srcpkgs/tvheadend/template
@@ -8,7 +8,7 @@ configure_args="--enable-dvbscan --disable-ffmpeg_static
 --disable-libx265_static --disable-libvpx_static --disable-libtheora_static
 --disable-libvorbis_static --disable-libfdkaac_static"
 hostmakedepends="gettext pkg-config python git which"
-makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg-devel"
+makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg4-devel"
 short_desc="TV streaming server"
 maintainer="lemmi <lemmi@nerd2nerd.org>"
 license="GPL-3.0-only"

From 2719f45366f3198bd172e853ef53733f15dabe31 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 078/115] unpaper: update to 7.0.0.

---
 srcpkgs/unpaper/template | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/srcpkgs/unpaper/template b/srcpkgs/unpaper/template
index 38ed47a584016..1ff910e722afc 100644
--- a/srcpkgs/unpaper/template
+++ b/srcpkgs/unpaper/template
@@ -1,13 +1,13 @@
 # Template file for 'unpaper'
 pkgname=unpaper
-version=6.1
-revision=3
-build_style=gnu-configure
+version=7.0.0
+revision=1
+build_style=meson
+hostmakedepends="pkg-config meson libxslt"
+makedepends="ffmpeg-devel python3-Sphinx"
+short_desc="Post-processing tool for scanned sheets of paper"
 maintainer="Orphaned <orphan@voidlinux.org>"
-hostmakedepends="pkg-config libxslt"
-makedepends="ffmpeg-devel"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://www.flameeyes.eu/projects/unpaper"
-short_desc="A post-processing tool for scanned sheets of paper"
 distfiles="https://www.flameeyes.eu/files/${pkgname}-${version}.tar.xz"
-checksum=237c84f5da544b3f7709827f9f12c37c346cdf029b1128fb4633f9bafa5cb930
+checksum=2575fbbf26c22719d1cb882b59602c9900c7f747118ac130883f63419be46a80

From df528d6483993f137f313529f04ce938b86fbbcb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 079/115] vba-m: revbump for ffmpeg-6.0

---
 srcpkgs/vba-m/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vba-m/template b/srcpkgs/vba-m/template
index 809343f465f24..e3f7785de0d23 100644
--- a/srcpkgs/vba-m/template
+++ b/srcpkgs/vba-m/template
@@ -2,7 +2,7 @@
 pkgname=vba-m
 reverts=1292_2
 version=2.1.6
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_GTK=TRUE -DENABLE_FFMPEG=TRUE -DENABLE_LINK=TRUE -DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="gettext pkg-config unzip zip yasm wxWidgets-gtk3-devel"

From 97be13c627e75aea0d59559512063b32d8c19d01 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 080/115] vice: revbump for ffmpeg4-4.4.3

---
 srcpkgs/vice/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/vice/template b/srcpkgs/vice/template
index fe9d33a811947..4beab2c5f9ebd 100644
--- a/srcpkgs/vice/template
+++ b/srcpkgs/vice/template
@@ -1,7 +1,7 @@
 # Template file for 'vice'
 pkgname=vice
 version=3.7.1
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="
 	$(vopt_enable sdl2 sdlui2)
@@ -26,7 +26,7 @@ makedepends="
 	$(vopt_if gtk3 gtk+3-devel)
 	$(vopt_if gtk3 pulseaudio-devel)
 	$(vopt_if gtk3 pango-devel)
-	$(vopt_if ffmpeg ffmpeg-devel)"
+	$(vopt_if ffmpeg ffmpeg4-devel)"
 short_desc="Emulator for C64, C128, CBM-II, PET, VIC20, Plus4 and C16"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"

From 456a5da95f94ba7b8a76e17c8b2a5f05f97477dd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 081/115] waypipe: revbump for ffmpeg-6.0

---
 srcpkgs/waypipe/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waypipe/template b/srcpkgs/waypipe/template
index 6da88b21bf2a1..4da8058400b58 100644
--- a/srcpkgs/waypipe/template
+++ b/srcpkgs/waypipe/template
@@ -1,7 +1,7 @@
 # Template file for 'waypipe'
 pkgname=waypipe
 version=0.8.6
-revision=1
+revision=2
 build_style=meson
 # lto is off because it causes linking errors in armv6l and armv7l (due to NEON)
 configure_args="-Dwerror=false -Dwith_dmabuf=enabled -Dwith_lz4=enabled

From 3c75b7e2073b311108f1b7aa68e3191e25bc22c1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 082/115] wf-recorder: revbump for ffmpeg-6.0

---
 srcpkgs/wf-recorder/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/wf-recorder/template b/srcpkgs/wf-recorder/template
index e278eb001600f..5d014a5f28afb 100644
--- a/srcpkgs/wf-recorder/template
+++ b/srcpkgs/wf-recorder/template
@@ -1,7 +1,7 @@
 # Template file for 'wf-recorder'
 pkgname=wf-recorder
 version=0.3.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config scdoc wayland-devel"
 makedepends="wayland-protocols wayland-devel ffmpeg-devel x264-devel

From 2c45e14e4f6d24250dd1e8773cc471e6085e2843 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 083/115] xpra: revbump for ffmpeg-6.0

---
 srcpkgs/xpra/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xpra/template b/srcpkgs/xpra/template
index 0a63fdb6c7437..d5acc1981c5f6 100644
--- a/srcpkgs/xpra/template
+++ b/srcpkgs/xpra/template
@@ -1,7 +1,7 @@
 # Template file for 'xpra'
 pkgname=xpra
 version=4.4.6
-revision=1
+revision=2
 build_style=python3-module
 make_build_args="--without-cuda_kernels --without-cuda_rebuild"
 make_install_args="$(vopt_with docs) ${make_build_args}"

From 14ad20657106673c96c65b148c757780243d7690 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:07:40 -0400
Subject: [PATCH 084/115] nv-codec-headers: update to 12.0.16.0

---
 srcpkgs/nv-codec-headers/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/nv-codec-headers/template b/srcpkgs/nv-codec-headers/template
index 3d422a61e4891..251e057f826fb 100644
--- a/srcpkgs/nv-codec-headers/template
+++ b/srcpkgs/nv-codec-headers/template
@@ -1,6 +1,6 @@
 # Template file for 'nv-codec-headers'
 pkgname=nv-codec-headers
-version=11.1.5.1
+version=12.0.16.0
 revision=1
 build_style=gnu-makefile
 short_desc="FFmpeg version of headers required to interface with Nvidias codec APIs"
@@ -8,7 +8,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="MIT"
 homepage="http://git.videolan.org/?p=ffmpeg/nv-codec-headers.git"
 distfiles="https://github.com/FFmpeg/nv-codec-headers/archive/n${version}.tar.gz"
-checksum=d095fbd56aa93772471a323be0ebe65504a0f43f06c76a30b6d25da77b06ae9c
+checksum=2a1533b65f55f9da52956faf0627ed3b74868ac0c7f269990edd21369113b48f
 
 post_install() {
 	sed -n '4,25p' include/ffnvcodec/nvEncodeAPI.h > LICENSE

From 76e14b45ded0611b38420dbf8bb27b87eaeaefa2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:08:40 -0400
Subject: [PATCH 085/115] openimagedenoise: revbump for ffmpeg-6.0

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index db5ccdb055cc9..cb90045afb634 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,7 +1,7 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
 version=1.4.3
-revision=1
+revision=2
 archs="x86_64*"
 build_style=cmake
 hostmakedepends="ispc python3"

From c4f5c5df7809cb447459e98d35ca4aacf13955ac Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:31:45 -0400
Subject: [PATCH 086/115] shotcut: revbump for ffmpeg-6.0

---
 srcpkgs/shotcut/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/shotcut/template b/srcpkgs/shotcut/template
index 7d2af7b0470b5..c416c906ff734 100644
--- a/srcpkgs/shotcut/template
+++ b/srcpkgs/shotcut/template
@@ -1,7 +1,7 @@
 # Template file for 'shotcut'
 pkgname=shotcut
 version=23.05.14
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSHOTCUT_VERSION=${version}"
 hostmakedepends="pkg-config qt6-tools-devel"

From 00cb5a88cd86ced74a1bfd5ae0775012883b04e9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:30 -0400
Subject: [PATCH 087/115] shiboken2: revbump for qt5-5.15.8

---
 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch | 1 +
 srcpkgs/shiboken2/template                                 | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
 create mode 120000 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
new file mode 120000
index 0000000000000..efcf3249bd885
--- /dev/null
+++ b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1 @@
+../../python3-pyside2/patches/importlib-machinery-bypass.patch
\ No newline at end of file
diff --git a/srcpkgs/shiboken2/template b/srcpkgs/shiboken2/template
index 084ecc3ba1e1c..2a21998997eb1 100644
--- a/srcpkgs/shiboken2/template
+++ b/srcpkgs/shiboken2/template
@@ -1,7 +1,7 @@
 # Template file for 'shiboken2'
 pkgname=shiboken2
 version=5.15.7
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/shiboken2"
 build_style=cmake

From bbd8c8807b7dfb896edf21f3f7fddb54742112ff Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:53 -0400
Subject: [PATCH 088/115] python3-pyside2: update to 5.15.8

---
 .../patches/importlib-machinery-bypass.patch      | 15 +++++++++++++++
 srcpkgs/python3-pyside2/template                  |  9 +++++----
 2 files changed, 20 insertions(+), 4 deletions(-)
 create mode 100644 srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
new file mode 100644
index 0000000000000..64c429584776b
--- /dev/null
+++ b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1,15 @@
+Using this prevents an error around line 220 below it.
+"AttributeError: module 'importlib' has no attribute 'machinery'"
+The old backup logic is in place and compiles without issues.
+--- a/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:09:34.688912402 -0400
++++ b/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:10:03.395529582 -0400
+@@ -170,9 +170,6 @@
+
+     # 'zipstring_sequence' comes from signature.cpp
+     zipbytes = base64.b64decode(''.join(zipstring_sequence))
+-    if sys.version_info[0] >= 3:
+-        vzip = zipfile.ZipFile(io.BytesIO(zipbytes))
+-        return sys.meta_path, EmbeddableZipImporter(vzip)
+
+     # Old version for Python 2.7, only.
+     import os
diff --git a/srcpkgs/python3-pyside2/template b/srcpkgs/python3-pyside2/template
index 50e6ff260d3b5..b50e62bd215d4 100644
--- a/srcpkgs/python3-pyside2/template
+++ b/srcpkgs/python3-pyside2/template
@@ -1,11 +1,12 @@
 # Template file for 'python3-pyside2'
 pkgname=python3-pyside2
-version=5.15.5
-revision=2
+version=5.15.8
+revision=1
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/pyside2"
 build_style=cmake
-configure_args="-DPYTHON_EXECUTABLE=/usr/bin/python"
+configure_args="-DPYTHON_EXECUTABLE=/usr/bin/python -DCMAKE_BUILD_TYPE=None
+ -DBUILD_TESTS=OFF"
 hostmakedepends="cmake python3 shiboken2"
 makedepends="python3-devel libshiboken2-devel qt5-devel
  qt5-multimedia-devel qt5-tools-devel qt5-plugin-mysql qt5-plugin-odbc
@@ -23,7 +24,7 @@ maintainer="yopito <pierre.bourgin@free.fr>"
 license="LGPL-3.0-or-later"
 homepage="https://wiki.qt.io/Qt_for_Python"
 distfiles="https://download.qt.io/official_releases/QtForPython/pyside2/PySide2-${version}-src/${_pkgname}.tar.xz"
-checksum=3920a4fb353300260c9bc46ff70f1fb975c5e7efa22e9d51222588928ce19b33
+checksum=23436302c8deb5b4cbc769b205d09604e38ba83b40708efccb7bd8c9af6f6b5d
 
 build_options="webengine"
 desc_option_webengine="Build Qt5 WebEngine bindings"

From 9b1ddf874864cd4900dac71d241f08600787b675 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:35 -0400
Subject: [PATCH 089/115] konqueror: revbump for ffmpeg-6.0

---
 srcpkgs/konqueror/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/konqueror/template b/srcpkgs/konqueror/template
index d8d0e73a78ab2..c5bdba601d3c3 100644
--- a/srcpkgs/konqueror/template
+++ b/srcpkgs/konqueror/template
@@ -1,11 +1,11 @@
 # Template file for 'konqueror'
 pkgname=konqueror
 version=23.04.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DDESKTOPTOJSON_EXECUTABLE=/usr/bin/desktoptojson"
 hostmakedepends="extra-cmake-modules python3 qt5-host-tools qt5-qmake kdoctools
-kcoreaddons kconfig gettext"
+ kcoreaddons kconfig gettext"
 makedepends="qt5-devel qt5-webengine-devel qt5-declarative-devel
  qt5-webchannel-devel qt5-location-devel kcmutils-devel kdelibs4support-devel
  karchive-devel khtml-devel kdesu-devel kactivities5-devel"

From afa1819752ab7dbb7b65ba7f11af51e02f8e6525 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:58 -0400
Subject: [PATCH 090/115] qt5-speech: revbump for qt5-5.15.8

---
 srcpkgs/qt5-speech/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-speech/template b/srcpkgs/qt5-speech/template
index 3ecd10d50650c..2d7d4d4d24535 100644
--- a/srcpkgs/qt5-speech/template
+++ b/srcpkgs/qt5-speech/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-speech'
 pkgname=qt5-speech
 version=5.15.7
-revision=2
+revision=3
 _commit=d32f4a479d38a11f547598004b975f4356424a16
 build_style=qmake
 configure_args="-- -flite -flite-alsa -speechd"

From 6db553accdf2914e6dad76a9d42b3da5f3e90707 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 18:38:50 -0400
Subject: [PATCH 091/115] qt5-styleplugins: revbump for qt5-5.15.8

---
 srcpkgs/qt5-styleplugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-styleplugins/template b/srcpkgs/qt5-styleplugins/template
index 96ed97d12cd24..30d93660a2a4e 100644
--- a/srcpkgs/qt5-styleplugins/template
+++ b/srcpkgs/qt5-styleplugins/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-styleplugins'
 pkgname=qt5-styleplugins
 version=5.0.0
-revision=20
+revision=21
 _gitrev=335dbece103e2cbf6c7cf819ab6672c2956b17b3
 build_style=qmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From e772fcd15abf193fcd5fa25d30488607a1dc5598 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 7 May 2023 20:14:14 -0400
Subject: [PATCH 092/115] mlt7: revbump for ffmpeg-6.0

---
 srcpkgs/gst-libav/template | 2 +-
 srcpkgs/mlt7/template      | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index 04c39bff14896..8c72fc3e97eee 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.22.2
-revision=2
+revision=1
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"
diff --git a/srcpkgs/mlt7/template b/srcpkgs/mlt7/template
index df3e2c559ad6c..77579fbf6b634 100644
--- a/srcpkgs/mlt7/template
+++ b/srcpkgs/mlt7/template
@@ -1,7 +1,7 @@
 # Template file for 'mlt7'
 pkgname=mlt7
 version=7.14.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSWIG_PYTHON=ON"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which

From ca1559469b7b5f471257482a0d8e0aa9c3dd8a25 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 7 May 2023 20:15:03 -0400
Subject: [PATCH 093/115] qt6-webengine: revbump for ffmpeg-6.0

---
 srcpkgs/qt6-webengine/template | 1 +
 1 file changed, 1 insertion(+)

diff --git a/srcpkgs/qt6-webengine/template b/srcpkgs/qt6-webengine/template
index 22fa2d2b9b619..8c0b2bcc92c13 100644
--- a/srcpkgs/qt6-webengine/template
+++ b/srcpkgs/qt6-webengine/template
@@ -145,6 +145,7 @@ pre_install() {
 }
 
 post_install() {
+	vlicense LICENSES/BSD-3-Clause.txt
 	local _file
 	find "${DESTDIR}"/usr/lib/qt6/examples \
 		-path '*/lib/qt6/**/lib/qt6/*' -type f |

From ccdc7b7d26ea4e504527662bbe70709ea9acd223 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 21 May 2023 12:44:11 -0400
Subject: [PATCH 094/115] electron24: revbump for ffmpeg-6.0

---
 srcpkgs/electron24/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron24/template b/srcpkgs/electron24/template
index 431ba6b0f8301..e67525b318d33 100644
--- a/srcpkgs/electron24/template
+++ b/srcpkgs/electron24/template
@@ -1,7 +1,7 @@
 # Template file for 'electron24'
 pkgname=electron24
 version=24.3.0
-revision=1
+revision=2
 _nodever=18.14.0
 _chromiumver=112.0.5615.165
 archs="x86_64* aarch64*"

From a01c8de6fa07966a0aa154ea3321a0ea2c73728e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Jun 2023 08:20:22 -0400
Subject: [PATCH 095/115] gtk4: revbump for ffmpeg-6.0

---
 srcpkgs/gtk4/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gtk4/template b/srcpkgs/gtk4/template
index b40d51d432537..d6ca6698fa808 100644
--- a/srcpkgs/gtk4/template
+++ b/srcpkgs/gtk4/template
@@ -1,7 +1,7 @@
 # Template file for 'gtk4'
 pkgname=gtk4
 version=4.10.4
-revision=1
+revision=2
 build_style=meson
 build_helper="gir"
 configure_args="-Dman-pages=true -Dgtk_doc=true -Dbuild-tests=false

From 46f96c0f33911e7c196a0827aec56624d140d035 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:25:50 -0400
Subject: [PATCH 096/115] electron19: revbump for ffmpeg-6.0

---
 srcpkgs/electron19/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron19/template b/srcpkgs/electron19/template
index 3093248588438..1f6b7fb13769b 100644
--- a/srcpkgs/electron19/template
+++ b/srcpkgs/electron19/template
@@ -1,7 +1,7 @@
 # Template file for 'electron19'
 pkgname=electron19
 version=19.0.8
-revision=3
+revision=4
 _nodever=16.14.2
 _chromiumver=102.0.5005.125
 archs="x86_64* aarch64* ppc64le*"

From 6e36660af984c959714a19f4a63571e5a88d3c9e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:28:26 -0400
Subject: [PATCH 097/115] siril: revbump for ffmpeg-6.0

---
 srcpkgs/siril/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/siril/template b/srcpkgs/siril/template
index 84332f79d060d..62750dd247548 100644
--- a/srcpkgs/siril/template
+++ b/srcpkgs/siril/template
@@ -1,7 +1,7 @@
 # Template file for 'siril'
 pkgname=siril
 version=0.9.12
-revision=10
+revision=11
 build_style=gnu-configure
 hostmakedepends="pkg-config intltool autoconf automake gettext-devel"
 makedepends="fftw-devel libconfig-devel libopencv-devel libffms2-devel

From 38ca1fd54df4f14fadf8cb197b3080241529817d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 10 Jun 2023 00:57:09 -0400
Subject: [PATCH 098/115] qt6-multimedia: revbump for ffmpeg-6.0

---
 srcpkgs/qt6-multimedia/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-multimedia/template b/srcpkgs/qt6-multimedia/template
index 2cf997b227a45..ca39534afb7f3 100644
--- a/srcpkgs/qt6-multimedia/template
+++ b/srcpkgs/qt6-multimedia/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-multimedia'
 pkgname=qt6-multimedia
 version=6.5.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DQT_FEATURE_gstreamer=ON"
 hostmakedepends="perl qt6-declarative-host-tools pkg-config qt6-shadertools"

From db405d96f42a2cefba43b8494cb19fcadfaedc57 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 22 Jun 2023 10:25:02 -0400
Subject: [PATCH 099/115] kdenlive: revbump for ffmpeg-6.0

---
 srcpkgs/kdenlive/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kdenlive/template b/srcpkgs/kdenlive/template
index 89c0dcfb8577f..75495b3a35869 100644
--- a/srcpkgs/kdenlive/template
+++ b/srcpkgs/kdenlive/template
@@ -1,7 +1,7 @@
 # Template file for 'kdenlive'
 pkgname=kdenlive
 version=23.04.2
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="
  extra-cmake-modules kconfig kcoreaddons kdoctools pkg-config python3

From b0ca5ed752bc43f3e343feecf56ea5ce4d967770 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Jul 2023 09:18:23 -0400
Subject: [PATCH 100/115] gmic: revbump for opencv-4.7.0

---
 srcpkgs/gmic/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gmic/template b/srcpkgs/gmic/template
index 0bb4034d5cc86..808953e9b543c 100644
--- a/srcpkgs/gmic/template
+++ b/srcpkgs/gmic/template
@@ -1,7 +1,7 @@
 # Template file for 'gmic'
 pkgname=gmic
 version=3.1.6
-revision=4
+revision=5
 _zart_hash=34ebf6cce0bafb98abe57cec83c4a02cd1abeca0
 create_wrksrc=yes
 build_wrksrc="src"

From f256f17147197a4f075216ea23489dcdb88e7fc2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Jul 2023 09:29:52 -0400
Subject: [PATCH 101/115] synfigstudio: revbump for synfig mlt7

---
 srcpkgs/synfigstudio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/synfigstudio/template b/srcpkgs/synfigstudio/template
index af1c5a296ef0f..09e442da9a680 100644
--- a/srcpkgs/synfigstudio/template
+++ b/srcpkgs/synfigstudio/template
@@ -2,7 +2,7 @@
 # Should be kept in sync with 'synfig' and 'ETL'
 pkgname=synfigstudio
 version=1.4.4
-revision=3
+revision=4
 build_style=gnu-configure
 configure_args="--disable-update-mimedb"
 hostmakedepends="pkg-config intltool gettext synfig"

From 103e71469effa27d77354f5e737cd43a04f63b4d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Jul 2023 11:17:37 -0400
Subject: [PATCH 102/115] DELETE: intel_packages

---
 common/shlibs                                 |   2 +
 srcpkgs/intel-gmmlib/template                 |   6 +-
 ...mmon-Enable-MMC-in-free-kernel-build.patch | 125 ++++++++++++++++++
 srcpkgs/intel-media-driver/template           |   6 +-
 srcpkgs/intel-media-sdk/patches/musl.patch    |  14 ++
 srcpkgs/intel-media-sdk/template              |  37 ++++++
 srcpkgs/intel-media-sdk/update                |   1 +
 srcpkgs/onevpl-devel                          |   1 +
 srcpkgs/onevpl-intel-gpu-devel                |   1 +
 srcpkgs/onevpl-intel-gpu/template             |  27 ++++
 srcpkgs/onevpl/template                       |  34 +++++
 11 files changed, 248 insertions(+), 6 deletions(-)
 create mode 100644 srcpkgs/intel-media-driver/patches/0001-Media-Common-Enable-MMC-in-free-kernel-build.patch
 create mode 100644 srcpkgs/intel-media-sdk/patches/musl.patch
 create mode 100644 srcpkgs/intel-media-sdk/template
 create mode 100644 srcpkgs/intel-media-sdk/update
 create mode 120000 srcpkgs/onevpl-devel
 create mode 120000 srcpkgs/onevpl-intel-gpu-devel
 create mode 100644 srcpkgs/onevpl-intel-gpu/template
 create mode 100644 srcpkgs/onevpl/template

diff --git a/common/shlibs b/common/shlibs
index 2c3d99f7595c1..b9fa4b22b7cd8 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4281,6 +4281,8 @@ libgsoapssl++-2.8.124.so gsoap-2.8.124_1
 libjxl.so.0.8 libjxl-0.8.2_1
 libjxl_dec.so.0.8 libjxl-0.8.2_1
 libjxl_threads.so.0.8 libjxl-0.8.2_1
+libmfx.so.1 libmfx-22.6.4_1
+libvpl.so.2 onevpl-2023.1.2_1
 libtext-engine-0.1.so.0 text-engine-0.1.1_1
 libvmaf.so.1 vmaf-2.3.1_1
 liblc3.so.1 liblc3-1.0.3_1
diff --git a/srcpkgs/intel-gmmlib/template b/srcpkgs/intel-gmmlib/template
index 04e407b1de4d3..2605226152e5d 100644
--- a/srcpkgs/intel-gmmlib/template
+++ b/srcpkgs/intel-gmmlib/template
@@ -1,6 +1,6 @@
 # Template file for 'intel-gmmlib'
 pkgname=intel-gmmlib
-version=22.2.0
+version=22.3.3
 revision=1
 archs="i686* x86_64*"
 build_style=cmake
@@ -14,11 +14,11 @@ build_style=cmake
 # compilers flag in use.
 configure_args="-Wno-dev"
 short_desc="Intel Graphics Memory Management Library"
-maintainer="Orphaned <orphan@voidlinux.org>"
+maintainer="Stefano Ragni <st3r4g@protonmail.com>"
 license="MIT"
 homepage="https://github.com/intel/gmmlib"
 distfiles="https://github.com/intel/gmmlib/archive/intel-gmmlib-${version}.tar.gz"
-checksum=0b2253894c6fc8455b6d7c5e87e6504a76d6f60ea192e1445c2f93164bf529c0
+checksum=86651bd2803c9f0afd82471bec784e65d2b418dee315a053d22215eb2a679be7
 
 lib32disabled=yes
 
diff --git a/srcpkgs/intel-media-driver/patches/0001-Media-Common-Enable-MMC-in-free-kernel-build.patch b/srcpkgs/intel-media-driver/patches/0001-Media-Common-Enable-MMC-in-free-kernel-build.patch
new file mode 100644
index 0000000000000..525fb688722c8
--- /dev/null
+++ b/srcpkgs/intel-media-driver/patches/0001-Media-Common-Enable-MMC-in-free-kernel-build.patch
@@ -0,0 +1,125 @@
+From e68feab7db036838d9521ba3b9f00717c37c024c Mon Sep 17 00:00:00 2001
+From: JayYang <jay.yang@intel.com>
+Date: Tue, 21 Mar 2023 17:17:55 +0800
+Subject: [PATCH] [Media Common] Enable MMC in free kernel build
+
+Add mmc build definition in free kernel build
+---
+ media_driver/agnostic/gen9/codec/hal/media_srcs.cmake          | 2 +-
+ media_driver/cmake/linux/media_feature_flags_linux.cmake       | 3 +--
+ .../media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp        | 2 +-
+ .../media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp        | 2 +-
+ .../media_interfaces_m9_glk/media_interfaces_g9_glk.cpp        | 2 +-
+ .../media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp        | 2 +-
+ .../media_interfaces_m9_skl/media_interfaces_g9_skl.cpp        | 2 +-
+ 7 files changed, 7 insertions(+), 8 deletions(-)
+
+diff --git a/media_driver/agnostic/gen9/codec/hal/media_srcs.cmake b/media_driver/agnostic/gen9/codec/hal/media_srcs.cmake
+index 8bb36bafe..78902a22d 100644
+--- a/media_driver/agnostic/gen9/codec/hal/media_srcs.cmake
++++ b/media_driver/agnostic/gen9/codec/hal/media_srcs.cmake
+@@ -27,7 +27,7 @@ set(TMP_1_HEADERS_
+     ${CMAKE_CURRENT_LIST_DIR}/codechal_hw_g9_X.h
+ )
+ 
+-if(${MMC_Supported} STREQUAL "yes")
++if(${MMC_Supported} STREQUAL "yes" AND ENABLE_NONFREE_KERNELS AND ENABLE_KERNELS)
+     set(TMP_1_SOURCES_
+         ${TMP_1_SOURCES_}
+         ${CMAKE_CURRENT_LIST_DIR}/codechal_memdecomp_g9.cpp
+diff --git a/media_driver/cmake/linux/media_feature_flags_linux.cmake b/media_driver/cmake/linux/media_feature_flags_linux.cmake
+index de0ca853f..8121ea60c 100644
+--- a/media_driver/cmake/linux/media_feature_flags_linux.cmake
++++ b/media_driver/cmake/linux/media_feature_flags_linux.cmake
+@@ -35,7 +35,6 @@ if(NOT ENABLE_KERNELS OR NOT ENABLE_NONFREE_KERNELS)
+     bs_set_if_undefined(HEVC_Encode_VME_Supported "no")
+     bs_set_if_undefined(MPEG2_Encode_VME_Supported "no")
+     bs_set_if_undefined(CMRT_HEVC_ENC_FEI_Supported "no")
+-    bs_set_if_undefined(MMC_Supported "no")
+     bs_set_if_undefined(VC1_Decode_Supported "no")
+     bs_set_if_undefined(Decode_Processing_Supported "no")
+     bs_set_if_undefined(Kernel_Auto_Denoise_Supported "no")
+@@ -46,7 +45,6 @@ else()
+     bs_set_if_undefined(HEVC_Encode_VME_Supported "${Encode_VME_Supported}")
+     bs_set_if_undefined(MPEG2_Encode_VME_Supported "${Encode_VME_Supported}")
+     bs_set_if_undefined(CMRT_HEVC_ENC_FEI_Supported "yes")
+-    bs_set_if_undefined(MMC_Supported "yes")
+     bs_set_if_undefined(VC1_Decode_Supported "yes")
+     bs_set_if_undefined(Decode_Processing_Supported "yes")
+     bs_set_if_undefined(Kernel_Auto_Denoise_Supported "yes")
+@@ -64,6 +62,7 @@ bs_set_if_undefined(VP9_Decode_Supported "yes")
+ bs_set_if_undefined(VP_SFC_Supported "yes")
+ bs_set_if_undefined(Common_Encode_Supported "yes")
+ bs_set_if_undefined(Media_Scalability_Supported "yes")
++bs_set_if_undefined(MMC_Supported "yes")
+ 
+ # features controlled by global flag Encode_VDEnc_Supported
+ bs_set_if_undefined(AVC_Encode_VDEnc_Supported "${Encode_VDEnc_Supported}")
+diff --git a/media_driver/media_interface/media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp b/media_driver/media_interface/media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp
+index 3f306ee2a..8e4c0f532 100644
+--- a/media_driver/media_interface/media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp
+@@ -135,7 +135,7 @@ MOS_STATUS MhwInterfacesG9Bxt::Initialize(
+ 
+     return MOS_STATUS_SUCCESS;
+ }
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool bxtRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Bxt>((uint32_t)IGFX_BROXTON);
+diff --git a/media_driver/media_interface/media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp b/media_driver/media_interface/media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp
+index b8fa1eec0..84e0fad1d 100644
+--- a/media_driver/media_interface/media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp
+@@ -44,7 +44,7 @@ static bool cflRegisteredMhw =
+     MediaFactory<uint32_t, MhwInterfaces>::
+     Register<MhwInterfacesG9Kbl>((uint32_t)IGFX_COFFEELAKE);
+ 
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool cflRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Kbl>((uint32_t)IGFX_COFFEELAKE);
+diff --git a/media_driver/media_interface/media_interfaces_m9_glk/media_interfaces_g9_glk.cpp b/media_driver/media_interface/media_interfaces_m9_glk/media_interfaces_g9_glk.cpp
+index de81e6091..2638cb3a6 100644
+--- a/media_driver/media_interface/media_interfaces_m9_glk/media_interfaces_g9_glk.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_glk/media_interfaces_g9_glk.cpp
+@@ -65,7 +65,7 @@ static bool glkRegisteredMhw =
+     MediaFactory<uint32_t, MhwInterfaces>::
+     Register<MhwInterfacesG9Kbl>((uint32_t)IGFX_GEMINILAKE);
+ 
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool glkRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Kbl>((uint32_t)IGFX_GEMINILAKE);
+diff --git a/media_driver/media_interface/media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp b/media_driver/media_interface/media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp
+index 99d786185..4e9c6e7f1 100644
+--- a/media_driver/media_interface/media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp
+@@ -131,7 +131,7 @@ MOS_STATUS MhwInterfacesG9Kbl::Initialize(
+ 
+     return MOS_STATUS_SUCCESS;
+ }
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool kblRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Kbl>((uint32_t)IGFX_KABYLAKE);
+diff --git a/media_driver/media_interface/media_interfaces_m9_skl/media_interfaces_g9_skl.cpp b/media_driver/media_interface/media_interfaces_m9_skl/media_interfaces_g9_skl.cpp
+index e2520edf7..4b0012c64 100644
+--- a/media_driver/media_interface/media_interfaces_m9_skl/media_interfaces_g9_skl.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_skl/media_interfaces_g9_skl.cpp
+@@ -139,7 +139,7 @@ MOS_STATUS MhwInterfacesG9Skl::Initialize(
+ 
+     return MOS_STATUS_SUCCESS;
+ }
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool sklRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Skl>((uint32_t)IGFX_SKYLAKE);
+-- 
+2.40.0
+
diff --git a/srcpkgs/intel-media-driver/template b/srcpkgs/intel-media-driver/template
index a5bab06ac9476..1735b90c65ce5 100644
--- a/srcpkgs/intel-media-driver/template
+++ b/srcpkgs/intel-media-driver/template
@@ -1,6 +1,6 @@
 # Template file for 'intel-media-driver'
 pkgname=intel-media-driver
-version=22.5.3
+version=22.6.4
 revision=1
 archs="x86_64*"
 build_style=cmake
@@ -8,11 +8,11 @@ configure_args="-Wno-dev -DENABLE_NONFREE_KERNELS=$(vopt_if nonfree ON OFF)"
 hostmakedepends="pkg-config"
 makedepends="libva-devel libX11-devel intel-gmmlib-devel libpciaccess-devel"
 short_desc="Intel Media Driver for VAAPI (Broadwell+)"
-maintainer="Orphaned <orphan@voidlinux.org>"
+maintainer="Stefano Ragni <st3r4g@protonmail.com>"
 license="MIT, BSD-3-Clause"
 homepage="https://github.com/intel/media-driver"
 distfiles="https://github.com/intel/media-driver/archive/intel-media-${version}.tar.gz"
-checksum=65652b365d48be3c9f0b3c561502952b92ee5fcc587520b88d0d752cf2a6a3b5
+checksum=0c04b9d74b92de41fd409b62913ce4afd799236c0b6bc1983a496990764e5d90
 
 build_options="nonfree"
 desc_option_nonfree="Enable nonfree kernels"
diff --git a/srcpkgs/intel-media-sdk/patches/musl.patch b/srcpkgs/intel-media-sdk/patches/musl.patch
new file mode 100644
index 0000000000000..4ae70924b744f
--- /dev/null
+++ b/srcpkgs/intel-media-sdk/patches/musl.patch
@@ -0,0 +1,14 @@
+--- a/tools/tracer/tracer/tracer_linux.cpp	2022-11-18 03:02:59.000000000 -0500
++++ b/tools/tracer/tracer/tracer_linux.cpp	2022-12-18 01:44:51.341542572 -0500
+@@ -32,6 +32,11 @@
+ #include <dlfcn.h>
+ #include "tracer.h"
+
++#ifndef RTLD_DEEPBIND
++// musl neither defines nor can use RTLD_DEEPBIND
++#define RTLD_DEEPBIND 0
++#endif
++
+ #if defined(__i386__)
+     #define LIBMFXHW "libmfxhw32.so.1"
+ #elif defined(__x86_64__)
diff --git a/srcpkgs/intel-media-sdk/template b/srcpkgs/intel-media-sdk/template
new file mode 100644
index 0000000000000..7aeab51802f8e
--- /dev/null
+++ b/srcpkgs/intel-media-sdk/template
@@ -0,0 +1,37 @@
+# Template file for 'intel-media-sdk'
+pkgname=intel-media-sdk
+version=22.6.4
+revision=1
+archs="x86_64*"
+build_style=cmake
+configure_args="-Wno-dev -DBUILD_SAMPLES=OFF -DBUILD_TESTS=ON"
+hostmakedepends="pkg-config"
+makedepends="libva-devel libdrm-devel intel-gmmlib-devel"
+short_desc="Intel Media SDK"
+maintainer="Stefano Ragni <st3r4g@protonmail.com>"
+license="MIT, BSD-3-Clause"
+homepage="https://github.com/Intel-Media-SDK/MediaSDK"
+distfiles="https://github.com/Intel-Media-SDK/MediaSDK/archive/refs/tags/intel-mediasdk-${version}.tar.gz"
+checksum=197acd056f81e9ff1c27068d50e8c84c2014d94c7ac17cad69d5c2d61e445fd3
+
+post_install() {
+	vlicense LICENSE
+}
+
+libmfx_package() {
+	depends="${makedepends} ${sourcepkg}-${version}_${revision}"
+	short_desc="Intel MediaSDK mfx lib"
+	pkg_install() {
+		vmove usr/lib/mfx
+		vmove "usr/lib/libmfx*.so*"
+	}
+}
+
+libmfx-devel_package() {
+	depends="${makedepends} ${sourcepkg}-${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+	}
+}
diff --git a/srcpkgs/intel-media-sdk/update b/srcpkgs/intel-media-sdk/update
new file mode 100644
index 0000000000000..434a2bc67f7a1
--- /dev/null
+++ b/srcpkgs/intel-media-sdk/update
@@ -0,0 +1 @@
+pkgname=intel-media
diff --git a/srcpkgs/onevpl-devel b/srcpkgs/onevpl-devel
new file mode 120000
index 0000000000000..e2306500b4871
--- /dev/null
+++ b/srcpkgs/onevpl-devel
@@ -0,0 +1 @@
+onevpl
\ No newline at end of file
diff --git a/srcpkgs/onevpl-intel-gpu-devel b/srcpkgs/onevpl-intel-gpu-devel
new file mode 120000
index 0000000000000..47920ceecf919
--- /dev/null
+++ b/srcpkgs/onevpl-intel-gpu-devel
@@ -0,0 +1 @@
+onevpl-intel-gpu
\ No newline at end of file
diff --git a/srcpkgs/onevpl-intel-gpu/template b/srcpkgs/onevpl-intel-gpu/template
new file mode 100644
index 0000000000000..f14acb728a54d
--- /dev/null
+++ b/srcpkgs/onevpl-intel-gpu/template
@@ -0,0 +1,27 @@
+# Template file for 'onevpl-intel-gpu'
+pkgname=onevpl-intel-gpu
+version=22.6.4
+revision=1
+archs="x86_64*"
+build_style=cmake
+configure_args="-Wno-dev -DCMAKE_BUILD_TYPE=Release"
+hostmakedepends="cmake pkg-config"
+makedepends="libdrm-devel libva-devel onevpl-devel"
+short_desc="Runtime implementation of oneVPL API for Intel Gen GPUs"
+maintainer="zlice <zlice555@gmail.com>"
+license="MIT"
+homepage="https://github.com/oneapi-src/oneVPL-intel-gpu"
+changelog="https://github.com/oneapi-src/oneVPL-intel-gpu/blob/main/CHANGELOG.md"
+distfiles="https://github.com/oneapi-src/oneVPL-intel-gpu/archive/refs/tags/intel-onevpl-${version}.tar.gz"
+checksum=74b0979dcb2af1b7c68edb8cbcb02d539de511090b12fac50652cbacd707c4e6
+
+post_install() {
+	vlicense LICENSE
+}
+
+onevpl-intel-gpu-devel_package() {
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/lib/pkgconfig
+	}
+}
diff --git a/srcpkgs/onevpl/template b/srcpkgs/onevpl/template
new file mode 100644
index 0000000000000..85c7c2da85ce9
--- /dev/null
+++ b/srcpkgs/onevpl/template
@@ -0,0 +1,34 @@
+# Template file for 'onevpl'
+pkgname=onevpl
+version=2023.1.2
+revision=1
+archs="x86_64*"
+build_style=cmake
+configure_args="
+	-DCMAKE_BUILD_TYPE=Release -Wno-dev
+	-DBUILD_PYTHON_BINDING:BOOL='OFF'
+	-DBUILD_EXAMPLES:BOOL='OFF'
+	-DBUILD_TESTS:BOOL='ON'
+	-DINSTALL_EXAMPLE_CODE:BOOL='OFF'"
+hostmakedepends="cmake libX11 python wayland-protocols pkg-config"
+makedepends="libva-devel libX11-devel wayland-devel"
+short_desc="Intel oneAPI Video Processing library"
+maintainer="zlice <zlice555@gmail.com>"
+license="MIT"
+homepage="https://www.intel.com/content/www/us/en/developer/tools/oneapi/onevpl.html"
+distfiles="https://github.com/oneapi-src/oneVPL/archive/v${version}/${pkgname}-${version}.tar.gz"
+checksum=b2261cca174ce1815f3d47c647921ab17f68267c69c1e2444ff27aab7d199cbb
+
+post_install() {
+	vlicense LICENSE
+}
+
+onevpl-devel_package() {
+	depends="${makedepends} ${sourcepkg}-${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.so"
+	}
+}

From 697ab0a5d22cdc1a56863932e87617b0f5a3de0f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:20:59 -0400
Subject: [PATCH 103/115] tracker-miners: revbump for ffmpeg-6.0

---
 srcpkgs/tracker-miners/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tracker-miners/template b/srcpkgs/tracker-miners/template
index a6e5aa5777024..aa0f443927cdb 100644
--- a/srcpkgs/tracker-miners/template
+++ b/srcpkgs/tracker-miners/template
@@ -1,7 +1,7 @@
 # Template file for 'tracker-miners'
 pkgname=tracker-miners
 version=3.5.0
-revision=4
+revision=5
 build_style=meson
 build_helper=qemu
 # missing libgrss for miner_rss

From 76249479e4e48959106d601f0a5d5c8f625aa4a7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:21:21 -0400
Subject: [PATCH 104/115] mpd: revbump for ffmpeg-6.0

---
 srcpkgs/mpd/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpd/template b/srcpkgs/mpd/template
index b916d655709aa..05fa0f7927e2e 100644
--- a/srcpkgs/mpd/template
+++ b/srcpkgs/mpd/template
@@ -1,7 +1,7 @@
 # Template file for 'mpd'
 pkgname=mpd
 version=0.23.13
-revision=2
+revision=3
 build_style=meson
 configure_args="-Dopus=enabled -Dmikmod=enabled -Dneighbor=true
  -Dsoundcloud=enabled -Dpipe=true -Dtwolame=enabled -Dbzip2=enabled

From bcd0c0567c722bcd4147ce9f1fae091a260888a3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 17 Jul 2023 15:37:44 -0400
Subject: [PATCH 105/115] mixxx: revbump for ffmpeg-6.0

---
 srcpkgs/mixxx/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mixxx/template b/srcpkgs/mixxx/template
index 23800676bfd09..6921996e4e77b 100644
--- a/srcpkgs/mixxx/template
+++ b/srcpkgs/mixxx/template
@@ -1,7 +1,7 @@
 # Template file for 'mixxx'
 pkgname=mixxx
 version=2.3.3
-revision=5
+revision=6
 build_style=cmake
 configure_args="-DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="extra-cmake-modules pkg-config protobuf qt5-host-tools qt5-qmake"

From cc868754e0dfeeef25476cd151421dce8cc19603 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 2 Aug 2023 10:17:33 -0400
Subject: [PATCH 106/115] libopenshot: revbump for ffmpeg-6.0

---
 srcpkgs/libopenshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenshot/template b/srcpkgs/libopenshot/template
index e9926e3111495..23c81266a8850 100644
--- a/srcpkgs/libopenshot/template
+++ b/srcpkgs/libopenshot/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenshot'
 pkgname=libopenshot
 version=0.3.0
-revision=2
+revision=3
 build_style=cmake
 # Builds fail with Ruby-2.4.1
 configure_args="-DENABLE_RUBY=OFF -DUSE_SYSTEM_JSONCPP=ON"

From 13cc835edf781bea3c114ed0c73c0923119a01f4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:09:36 -0400
Subject: [PATCH 107/115] musikcube: revbump for ffmpeg-6.0

---
 srcpkgs/musikcube/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/musikcube/template b/srcpkgs/musikcube/template
index 1f78ada1451b6..d9e6186e6697b 100644
--- a/srcpkgs/musikcube/template
+++ b/srcpkgs/musikcube/template
@@ -1,7 +1,7 @@
 # Template file for 'musikcube'
 pkgname=musikcube
 version=3.0.0
-revision=2
+revision=3
 build_style=cmake
 make_cmd=make
 configure_args="-DNO_NCURSESW=1"

From 447651e4f101cb1725b1efdc0c08e3315fbb589e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:02 -0400
Subject: [PATCH 108/115] tg_owt: revbump for ffmpeg-6.0

---
 srcpkgs/tg_owt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tg_owt/template b/srcpkgs/tg_owt/template
index 1dd0f25e84c94..8e1e3bbffd575 100644
--- a/srcpkgs/tg_owt/template
+++ b/srcpkgs/tg_owt/template
@@ -1,7 +1,7 @@
 # Template file for 'tg_owt'
 pkgname=tg_owt
 version=0.0.0.20230610
-revision=3
+revision=4
 _commit=dcb5069ff76bd293e86928804208737e6cee2ccc
 _libyuv_commit=77c2121f7e6b8e694d6e908bbbe9be24214097da
 _abseil_commit=8c0b94e793a66495e0b1f34a5eb26bd7dc672db0

From cade0ac41783a82487f3597435ffca3e16d42073 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:44 -0400
Subject: [PATCH 109/115] telegram-desktop: revbump for ffmpeg-6.0

---
 srcpkgs/telegram-desktop/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/telegram-desktop/template b/srcpkgs/telegram-desktop/template
index 621630887e878..98506336a5b44 100644
--- a/srcpkgs/telegram-desktop/template
+++ b/srcpkgs/telegram-desktop/template
@@ -1,7 +1,7 @@
 # Template file for 'telegram-desktop'
 pkgname=telegram-desktop
 version=4.8.4
-revision=4
+revision=5
 build_style=cmake
 build_helper="qemu gir"
 configure_args="-DTDESKTOP_API_ID=209235

From 67321f26da49bc90096278e013a3306186a536fa Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:11:13 -0400
Subject: [PATCH 110/115] mpv: revbump for ffmpeg-6.0

---
 srcpkgs/mpv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpv/template b/srcpkgs/mpv/template
index 933c22bae2ed2..301a77ad22971 100644
--- a/srcpkgs/mpv/template
+++ b/srcpkgs/mpv/template
@@ -1,7 +1,7 @@
 # Template file for 'mpv'
 pkgname=mpv
 version=0.36.0
-revision=2
+revision=3
 build_style=meson
 configure_args="-Dcdda=enabled -Ddvbin=enabled -Ddvdnav=enabled
  -Dlibmpv=true -Dcplugins=enabled

From 2ce4a0f1135e9729347d6ec551a9fe899db388e4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:11:45 -0400
Subject: [PATCH 111/115] gst-plugins-bad1: revbump for ffmpeg-6.0

---
 srcpkgs/gst-plugins-bad1/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index 4189f3686ee32..e1bfe79eca991 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-plugins-bad1'
 pkgname=gst-plugins-bad1
 version=1.22.2
-revision=3
+revision=4
 build_helper="gir"
 build_style=meson
 configure_args="-Dpackage-origin=https://voidlinux.org -Ddoc=disabled

From a8047e2593517873069f17eff19148b95e1932cb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:12:09 -0400
Subject: [PATCH 112/115] openmw: revbump for ffmpeg-6.0

---
 srcpkgs/openmw/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openmw/template b/srcpkgs/openmw/template
index 0abf5ff7cdbec..b57180f1a4446 100644
--- a/srcpkgs/openmw/template
+++ b/srcpkgs/openmw/template
@@ -1,7 +1,7 @@
 # Template file for 'openmw'
 pkgname=openmw
 version=0.48.0
-revision=2
+revision=3
 build_style=cmake
 _recast_commit=e75adf86f91eb3082220085e42dda62679f9a3ea
 _bullet_tag=3.17

From 397b92cd135c669d2d530cbefe871f51dc43079b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:14:53 -0400
Subject: [PATCH 113/115] lms: revbump for ffmpeg-6.0

---
 srcpkgs/lms/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/lms/template b/srcpkgs/lms/template
index cb3ea5e58c80f..b1c9b6120e5db 100644
--- a/srcpkgs/lms/template
+++ b/srcpkgs/lms/template
@@ -1,7 +1,7 @@
 # Template file for 'lms'
 pkgname=lms
 version=3.40.0
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="wt-devel ffmpeg-devel boost-devel libconfig++-devel taglib-devel pam-devel libgraphicsmagick-devel gtest-devel libarchive-devel"

From be8966c8ab74bd9f6699232269fdfca947ea5397 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:15:14 -0400
Subject: [PATCH 114/115] openimageio: revbump for ffmpeg-6.0

---
 srcpkgs/openimageio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimageio/template b/srcpkgs/openimageio/template
index d8a6ba56efd11..d7ad79563a2af 100644
--- a/srcpkgs/openimageio/template
+++ b/srcpkgs/openimageio/template
@@ -1,7 +1,7 @@
 # Template file for 'openimageio'
 pkgname=openimageio
 version=2.4.9.0
-revision=6
+revision=7
 build_style=cmake
 build_helper=qemu
 configure_args="-DUSE_QT=0 -DUSE_PYTHON=0 -DOIIO_BUILD_TESTS=0

From 8495695139874d959d9bd36691ff8b56bea08043 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:18:18 -0400
Subject: [PATCH 115/115] freecad: revbump for ffmpeg-6.0

---
 srcpkgs/freecad/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/freecad/template b/srcpkgs/freecad/template
index 8608d1670c87f..12ddf75e25f26 100644
--- a/srcpkgs/freecad/template
+++ b/srcpkgs/freecad/template
@@ -1,7 +1,7 @@
 # Template file for 'freecad'
 pkgname=freecad
 version=0.20.2
-revision=6
+revision=7
 build_style=cmake
 
 _inst_prefix=/usr/lib/${pkgname}

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (22 preceding siblings ...)
  2023-08-30 13:18 ` zlice
@ 2023-10-02  0:04 ` yoshiyoshyosh
  2023-10-11 12:27 ` zlice
                   ` (73 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: yoshiyoshyosh @ 2023-10-02  0:04 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 433 bytes --]

New comment by yoshiyoshyosh on void-packages repository

https://github.com/void-linux/void-packages/pull/43761#issuecomment-1742247835

Comment:
we can replace `spek-alternative` with [`spek-x`](https://github.com/MikeWang000000/spek-X ), a more actively maintained fork that supports ffmpeg6. [the original `spek`](https://github.com/alexkay/spek) has also become maintained again, but it claims to only support up to ffmpeg 5.1.

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (23 preceding siblings ...)
  2023-10-02  0:04 ` yoshiyoshyosh
@ 2023-10-11 12:27 ` zlice
  2023-10-11 17:06 ` SpidFightFR
                   ` (72 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2023-10-11 12:27 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 320 bytes --]

New comment by zlice on void-packages repository

https://github.com/void-linux/void-packages/pull/43761#issuecomment-1757578954

Comment:
Blocked by https://github.com/void-linux/void-packages/pull/46172

Already quite a few updates to sift through and I don't feel comfortable trying until I know I can update mesa.

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (24 preceding siblings ...)
  2023-10-11 12:27 ` zlice
@ 2023-10-11 17:06 ` SpidFightFR
  2023-10-11 17:07 ` SpidFightFR
                   ` (71 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: SpidFightFR @ 2023-10-11 17:06 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 412 bytes --]

New comment by SpidFightFR on void-packages repository

https://github.com/void-linux/void-packages/pull/43761#issuecomment-1758125823

Comment:
> Blocked by #46172
> 
> Already quite a few updates to sift through and I don't feel comfortable trying until I know I can update mesa.

Sup, 23.1.8 should build, but it doesn't work because 32-bit subpackage problem. i still don't know how to solve this issue.

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (25 preceding siblings ...)
  2023-10-11 17:06 ` SpidFightFR
@ 2023-10-11 17:07 ` SpidFightFR
  2023-10-16 12:11 ` [PR PATCH] [Updated] " zlice
                   ` (70 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: SpidFightFR @ 2023-10-11 17:07 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 515 bytes --]

New comment by SpidFightFR on void-packages repository

https://github.com/void-linux/void-packages/pull/43761#issuecomment-1758125823

Comment:
> Blocked by #46172
> 
> Already quite a few updates to sift through and I don't feel comfortable trying until I know I can update mesa.

Sup, 23.1.8 should build, but it doesn't work because 32-bit subpackage problem. i still don't know how to solve this issue.
EDIT: on my personal way, i'm currently running mesa 23.2.1 on my void-install, no issues whatsoever.

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (26 preceding siblings ...)
  2023-10-11 17:07 ` SpidFightFR
@ 2023-10-16 12:11 ` zlice
  2023-10-16 12:12 ` zlice
                   ` (69 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2023-10-16 12:11 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 3573 bytes --]

There is an updated pull request by zlice against master on the void-packages repository

https://github.com/zlice/void-packages ffmpeg6-split
https://github.com/void-linux/void-packages/pull/43761

ffmpeg6 split
[ci skip]


#### Testing the changes

- I tested the changes in this PR: **YES**

main testing has been vaapi in Firefox Nightly and enc/dec in Shotcut on Intel A770

#### New package

- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**

#### Local build testing

- I built this PR locally for my native architecture, **x86_64**

#### Discussion

Continuation of https://github.com/void-linux/void-packages/pull/36315

`libavresample` is deprecated, but marked as a dependency when trying to build other packages and install `ffmpeg`(6). I think the right way to handle this is make a meta package and the add to removals?


##### Commit naming / misc

~~Commits are 'dirty' right now, running with [gstreamer 1.22.1 updates](https://github.com/void-linux/void-packages/pull/42861) and [Intel OpenCL](https://github.com/void-linux/void-packages/pull/43084). This will also make [intel packages pr](https://github.com/void-linux/void-packages/pull/41132) obsolete.~~ (see Requirements below)

Maintainer for previous ffmpeg(4) was orphaned, I can put my name in there if that matters, though I don't exactly see myself keeping up on ffmpeg.

This updates QT5 which looks like it is usually hosted by Johnny. Not sure if there's any reason to stay there or these sources are fine.

##### STILL FFMPEG4

These are a mix of emulators, games and/or older packages.

- attract (multiple patches in master)
- audacity (https://github.com/audacity/audacity/issues/2305 and https://sourceforge.net/p/portmedia/wiki/portsmf/ is 'beta')
- ccextractor (master patches? no release)
- vice
- kodi
- mlt (only dep left is flowblade)
- ~~synfig (mlt)~~ (work with mlt7, bump synfigstudio)
- tvheadend
- ssr
- spek-alternative
- ppsspp
- olive
- moc
- mediastreamer
- libextractor
- idjc
- hedgewars
- ~~ffmpegthumbnailer~~ (patches for moviedecoder.xxx files)
- ~~ffmpegthumbs~~ (latest compiles)
- deadbeef
- omxplayer
- qtav (fork has ffmpeg 5 patch - https://github.com/cmguo/QtAV)
- `vlc` (vlc4 will support ffmpeg5, there's a patch to build 3.x with ffmpeg5 but it will lack vaapi)
- `osg` (OpenSceneGraph plus `xine-lib`)


##### HAVE NOT BUILT YET

- omxplayer (rpi only? ffmpeg4)
- kodi (big, but ffmpeg4)


##### UPDATED (for ffmpeg6)

- ~~blender: update to 3.5.1~~ ~~will be revbump with~~ https://github.com/void-linux/void-packages/pull/43992
- unpaper: update to 7.0.0.
- guvcview: update to 2.0.8.
- qt5: update to 5.15.8
- qt5-webengine: update to 5.18.13
- shiboken2: revbump for qt5.15.8 (patch)
- python3-pyside2: update to 5.15.8 (patch)


##### Requirements

- ~~[gstreamer 1.22.2](https://github.com/void-linux/void-packages/pull/42861)~~ - a few packages use ffmpeg-devel and require a revbump

- [Intel Packages](https://github.com/void-linux/void-packages/pull/41132) - ffmpeg4 uses different libraries than 6 (libmfx / Intel-MediaSDK vs only oneVPL that Intel is moving to), both are included here

- ~~[shotcut 23.05.14](https://github.com/void-linux/void-packages/pull/44260)~~

- https://github.com/void-linux/void-packages/pull/44781 will remove from this PR

A patch file from https://github.com/void-linux/void-packages/pull/43761.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ffmpeg6-split-43761.patch --]
[-- Type: text/x-diff, Size: 786795 bytes --]

From d53fcba4d81ce2e2307239d368dfa7a6409e33d9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:16:56 -0400
Subject: [PATCH 001/115] ffmpeg: update to 6.0.

---
 common/shlibs                                 | 26 +++++---
 srcpkgs/ffmpeg/files/altivec.patch            | 60 -------------------
 .../patches/armv5tel-floating-point.patch     | 18 ------
 ...h-libavcodec-libsvtav1-ten_bit_format.diff | 40 -------------
 .../workaround-mesa-readeon-vaapi-bug.patch   | 28 ---------
 srcpkgs/ffmpeg/template                       | 38 ++++++------
 6 files changed, 37 insertions(+), 173 deletions(-)
 delete mode 100644 srcpkgs/ffmpeg/files/altivec.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 delete mode 100644 srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch

diff --git a/common/shlibs b/common/shlibs
index 67ecffb1effa3..2fecdb6e90491 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -385,15 +385,23 @@ libid3tag.so.0 libid3tag-0.15.1b_1
 libgif.so.7 giflib-5.1.0_1
 libImlib2.so.1 imlib2-1.4.2_1
 libmp3lame.so.0 lame-3.98.2_1
-libavdevice.so.58 libavdevice-4.0_1
-libavformat.so.58 libavformat-4.0_1
-libswscale.so.5 libswscale-4.0_1
-libswresample.so.3 libswresample-4.0_1
-libavresample.so.4 libavresample-4.0_1
-libpostproc.so.55 libpostproc-4.0_1
-libavcodec.so.58 libavcodec-4.0_1
-libavutil.so.56 libavutil-4.0_1
-libavfilter.so.7 libavfilter-4.0_1
+libavdevice.so.60 libavdevice-6.0_1
+libavformat.so.60 libavformat-6.0_1
+libswscale.so.7 libswscale-6.0_1
+libswresample.so.4 libswresample-6.0_1
+libpostproc.so.57 libpostproc-6.0_1
+libavcodec.so.60 libavcodec-6.0_1
+libavutil.so.58 libavutil-6.0_1
+libavfilter.so.9 libavfilter-6.0_1
+libavdevice.so.58 libavdevice4-4.0_1
+libavformat.so.58 libavformat4-4.0_1
+libswscale.so.5 libswscale4-4.0_1
+libswresample.so.3 libswresample4-4.0_1
+libavresample.so.4 libavresample4-4.0_1
+libpostproc.so.55 libpostproc4-4.0_1
+libavcodec.so.58 libavcodec4-4.0_1
+libavutil.so.56 libavutil4-4.0_1
+libavfilter.so.7 libavfilter4-4.0_1
 libSDL-1.2.so.0 SDL-1.2.14_1
 libSDL_image-1.2.so.0 SDL_image-1.2.10_1
 libx264.so.157 x264-20190507.2245_1
diff --git a/srcpkgs/ffmpeg/files/altivec.patch b/srcpkgs/ffmpeg/files/altivec.patch
deleted file mode 100644
index 9c57200463320..0000000000000
--- a/srcpkgs/ffmpeg/files/altivec.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-revert some altivec specific change on all ppc* except ppc64le*
-
-q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
-conditionally, for ppc* but not ppc64le* (the new code is valid for
-POWER8 VSX which LE targets as a baseline but not BE)"
-
-
-This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
----
- libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
- 1 file changed, 20 insertions(+), 4 deletions(-)
-
-diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
-index 536545293d..c1e2852adb 100644
---- a/libswscale/ppc/yuv2rgb_altivec.c
-+++ b/libswscale/ppc/yuv2rgb_altivec.c
-@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-     vector signed short R1, G1, B1;                                           \
-     vector unsigned char R, G, B;                                             \
-                                                                               \
-+    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
-+    vector unsigned char align_perm;                                          \
-+                                                                              \
-     vector signed short lCY       = c->CY;                                    \
-     vector signed short lOY       = c->OY;                                    \
-     vector signed short lCRV      = c->CRV;                                   \
-@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
-                                                                               \
-         for (j = 0; j < w / 16; j++) {                                        \
--            y0 = vec_xl(0, y1i);                                              \
-+            y1ivP = (const vector unsigned char *) y1i;                       \
-+            y2ivP = (const vector unsigned char *) y2i;                       \
-+            uivP  = (const vector unsigned char *) ui;                        \
-+            vivP  = (const vector unsigned char *) vi;                        \
-+                                                                              \
-+            align_perm = vec_lvsl(0, y1i);                                    \
-+            y0 = (vector unsigned char)                                       \
-+                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
-                                                                               \
--            y1 = vec_xl(0, y2i);                                              \
-+            align_perm = vec_lvsl(0, y2i);                                    \
-+            y1 = (vector unsigned char)                                       \
-+                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
-                                                                               \
--            u = (vector signed char) vec_xl(0, ui);                           \
-+            align_perm = vec_lvsl(0, ui);                                     \
-+            u = (vector signed char)                                          \
-+                    vec_perm(uivP[0], uivP[1], align_perm);                   \
-                                                                               \
--            v = (vector signed char) vec_xl(0, vi);                           \
-+            align_perm = vec_lvsl(0, vi);                                     \
-+            v = (vector signed char)                                          \
-+                    vec_perm(vivP[0], vivP[1], align_perm);                   \
-                                                                               \
-             u = (vector signed char)                                          \
-                     vec_sub(u,                                                \
--- 
-2.27.0
-
diff --git a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
deleted file mode 100644
index 9a55178c74f0f..0000000000000
--- a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
-+++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
-@@ -39,6 +39,15 @@
- #endif
- #include <fenv.h>
- 
-+#if (FE_ALL_EXCEPT == 0)
-+/* E.g. ARM soft float does not define these */
-+#define FE_INVALID    0
-+#define FE_DIVBYZERO  0
-+#define FE_OVERFLOW   0
-+#define FE_UNDERFLOW  0
-+#define FE_INEXACT    0
-+#endif
-+
- #if CONFIG_LIBFONTCONFIG
- #include <fontconfig/fontconfig.h>
- #endif
diff --git a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
deleted file mode 100644
index aa948f7a8a2df..0000000000000
--- a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
+++ /dev/null
@@ -1,40 +0,0 @@
-#==================================================================================================
-# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
-# From: Christopher Degawa <christopher.degawa@intel.com>
-# Date: Thu, 20 Oct 2022 22:55:27 -0500
-# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
-#
-# compressed_ten_bit_format has been deprecated upstream and has no effect
-# and can be removed. Plus, technically it was never used in the first place
-# since it would require the app (ffmpeg) to set it and do additional
-# processing of the input frames.
-#
-# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
-#
-# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
-#==================================================================================================
---- a/libavcodec/libsvtav1.c
-+++ b/libavcodec/libsvtav1.c
-@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
- 
- static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
- {
--    const int    pack_mode_10bit =
--        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
--    const size_t luma_size_8bit  =
--        config->source_width * config->source_height * (1 << pack_mode_10bit);
--    const size_t luma_size_10bit =
--        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
-+    const size_t luma_size = config->source_width * config->source_height *
-+        (config->encoder_bit_depth > 8 ? 2 : 1);
- 
-     EbSvtIOFormat *in_data;
- 
--    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
-+    svt_enc->raw_size = luma_size * 3 / 2;
- 
-     // allocate buffer for in and out
-     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
--- 
-GitLab
-
diff --git a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
deleted file mode 100644
index 00e3f68a415b8..0000000000000
--- a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
-From: Rainer Hochecker <fernetmenta@online.de>
-Date: Sat, 26 Jan 2019 19:48:35 +0100
-Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
-
-This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
-It was hit frequently when watching h264 channels received via DVB-X.
-Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
----
- libavcodec/vaapi_h264.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
-index 5854587a255..f12fdc457a4 100644
---- a/libavcodec/vaapi_h264.c
-+++ b/libavcodec/vaapi_h264.c
-@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
-     H264SliceContext *sl = &h->slice_ctx[0];
-     int ret;
- 
-+    if (pic->nb_slices == 0) {
-+        ret = AVERROR_INVALIDDATA;
-+        goto finish;
-+    }
-+
-     ret = ff_vaapi_decode_issue(avctx, pic);
-     if (ret < 0)
-         goto finish;
diff --git a/srcpkgs/ffmpeg/template b/srcpkgs/ffmpeg/template
index d2f8def0e25f7..c1f9b7efe40e3 100644
--- a/srcpkgs/ffmpeg/template
+++ b/srcpkgs/ffmpeg/template
@@ -1,15 +1,15 @@
 # Template file for 'ffmpeg'
 # audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
 pkgname=ffmpeg
-version=4.4.4
-revision=3
+version=6.0
+revision=1
 short_desc="Decoding, encoding and streaming software"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="https://www.ffmpeg.org"
 changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
 distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
-checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+checksum=57be87c22d9b49c112b6d24bc67d42508660e6b718b3db89c44e47e289137082
 
 hostmakedepends="pkg-config perl"
 makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
@@ -26,12 +26,13 @@ makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-deve
  $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
  $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
  $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
- $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers Vulkan-Tools Vulkan-ValidationLayers')
+ $(vopt_if onevpl 'onevpl onevpl-devel')
  $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
 depends="ffplay>=${version}_${revision}"
 
 build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
- dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec onevpl"
 build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
 desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
 desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
@@ -39,9 +40,13 @@ desc_option_sofa="Enable support for AES SOFA"
 desc_option_webp="Enable support for WebP"
 
 case "$XBPS_TARGET_MACHINE" in
-	i686*|x86_64*)
-		hostmakedepends+=" nasm"
+	i686*)
 		build_options_default+=" vaapi vdpau nvenc nvdec"
+		hostmakedepends+=" nasm"
+		;;
+	x86_64*)
+		hostmakedepends+=" nasm"
+		build_options_default+=" vaapi vdpau nvenc nvdec onevpl"
 		;;
 	ppc64*) build_options_default+=" vaapi vdpau";;
 	mips*) CFLAGS="-mnan=legacy";;
@@ -115,18 +120,19 @@ do_configure() {
 		$(vopt_enable x265 libx265) \
 		$(vopt_enable v4l2 libv4l2) \
 		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
-		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		--enable-libbs2b --enable-libvidstab \
 		$(vopt_enable dav1d libdav1d) \
 		$(vopt_enable zimg libzimg) \
 		$(vopt_enable webp libwebp) \
 		$(vopt_enable sofa libmysofa) \
 		$(vopt_enable vulkan) \
+		$(vopt_enable onevpl libvpl) \
 		$(vopt_enable drm libdrm) \
 		$(vopt_enable svtav1 libsvtav1) \
 		$(vopt_enable srt libsrt) \
 		$(vopt_enable rist librist) \
-		$(vopt_if nvenc '--enable-nvenc') \
-		$(vopt_if nvdec '--enable-nvdec')
+		$(vopt_enable nvenc nvenc) \
+		$(vopt_enable nvdec nvdec)
 }
 
 do_build() {
@@ -153,10 +159,8 @@ libavdevice_package() {
 }
 
 libavresample_package() {
-	short_desc="FFmpeg audio resampling library"
-	pkg_install() {
-		vmove "usr/lib/libavresample.so.*"
-	}
+	short_desc="Package deprecated, removal needed"
+	build_style=meta
 }
 
 libavformat_package() {
@@ -210,15 +214,13 @@ ffmpeg-devel_package() {
 		libavfilter>=${version}_${revision}
 		libpostproc>=${version}_${revision}
 		libswscale>=${version}_${revision}
-		libswresample>=${version}_${revision}
-		libavresample>=${version}_${revision}"
+		libswresample>=${version}_${revision}"
 	short_desc+=" - development files"
-
+	conflicts="ffmpeg4-devel"
 	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
 		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
 		nostrip_files="/usr/lib/libavfilter.a"
 	fi
-
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig

From 37c79d63c7917df4d4617a5182c1ed0c4773f201 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:17:26 -0400
Subject: [PATCH 002/115] baresip: revbump for ffmpeg-6.0

---
 srcpkgs/baresip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/baresip/template b/srcpkgs/baresip/template
index b21e22334316e..16a1b98304790 100644
--- a/srcpkgs/baresip/template
+++ b/srcpkgs/baresip/template
@@ -1,7 +1,7 @@
 # Template file for 'baresip'
 pkgname=baresip
 version=2.10.0
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config glib-devel"
 makedepends="libgsm-devel libpng-devel openssl-devel libsndfile-devel

From e02dd4faa0016f9133c76571dbd2f4119bed28e6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:14 -0400
Subject: [PATCH 003/115] openshot: revbump for ffmpeg6.0

---
 srcpkgs/openshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openshot/template b/srcpkgs/openshot/template
index 8f47851eef354..affb652a9d500 100644
--- a/srcpkgs/openshot/template
+++ b/srcpkgs/openshot/template
@@ -1,7 +1,7 @@
 # Template file for 'openshot'
 pkgname=openshot
 version=3.0.0
-revision=2
+revision=3
 build_style=python3-module
 hostmakedepends="python3 python3-setuptools"
 makedepends="ffmpeg-devel python3-PyQt5"

From efe3c0a660b5d683065b3cd065c2c9e03f09bf8b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:36 -0400
Subject: [PATCH 004/115] sumo: revbump for ffmpeg6.0

---
 srcpkgs/sumo/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/sumo/template b/srcpkgs/sumo/template
index a3fe134aa5acc..a730afa9fafa9 100644
--- a/srcpkgs/sumo/template
+++ b/srcpkgs/sumo/template
@@ -1,7 +1,7 @@
 # Template file for 'sumo'
 pkgname=sumo
 version=1.12.0
-revision=6
+revision=7
 build_style=cmake
 hostmakedepends="libgdal-tools pkg-config swig python3-setuptools"
 makedepends="python3-devel ffmpeg-devel fox-devel gl2ps-devel libgdal-devel

From f91e0432c4740e832834b6870aac4e6d3446c9fa Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:56:22 -0400
Subject: [PATCH 005/115] New package: ffmpeg4-4.4.4.

---
 srcpkgs/ffmpeg4-devel                         |   1 +
 srcpkgs/ffmpeg4/files/altivec.patch           |  60 +++++
 .../patches/armv5tel-floating-point.patch     |  18 ++
 ...h-libavcodec-libsvtav1-ten_bit_format.diff |  40 +++
 .../workaround-mesa-readeon-vaapi-bug.patch   |  28 ++
 srcpkgs/ffmpeg4/template                      | 240 ++++++++++++++++++
 srcpkgs/libavcodec4                           |   1 +
 srcpkgs/libavdevice4                          |   1 +
 srcpkgs/libavfilter4                          |   1 +
 srcpkgs/libavformat4                          |   1 +
 srcpkgs/libavresample4                        |   1 +
 srcpkgs/libavutil4                            |   1 +
 srcpkgs/libpostproc4                          |   1 +
 srcpkgs/libswresample4                        |   1 +
 srcpkgs/libswscale4                           |   1 +
 15 files changed, 396 insertions(+)
 create mode 120000 srcpkgs/ffmpeg4-devel
 create mode 100644 srcpkgs/ffmpeg4/files/altivec.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 create mode 100644 srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
 create mode 100644 srcpkgs/ffmpeg4/template
 create mode 120000 srcpkgs/libavcodec4
 create mode 120000 srcpkgs/libavdevice4
 create mode 120000 srcpkgs/libavfilter4
 create mode 120000 srcpkgs/libavformat4
 create mode 120000 srcpkgs/libavresample4
 create mode 120000 srcpkgs/libavutil4
 create mode 120000 srcpkgs/libpostproc4
 create mode 120000 srcpkgs/libswresample4
 create mode 120000 srcpkgs/libswscale4

diff --git a/srcpkgs/ffmpeg4-devel b/srcpkgs/ffmpeg4-devel
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/ffmpeg4-devel
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/ffmpeg4/files/altivec.patch b/srcpkgs/ffmpeg4/files/altivec.patch
new file mode 100644
index 0000000000000..9c57200463320
--- /dev/null
+++ b/srcpkgs/ffmpeg4/files/altivec.patch
@@ -0,0 +1,60 @@
+revert some altivec specific change on all ppc* except ppc64le*
+
+q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
+conditionally, for ppc* but not ppc64le* (the new code is valid for
+POWER8 VSX which LE targets as a baseline but not BE)"
+
+
+This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
+---
+ libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
+ 1 file changed, 20 insertions(+), 4 deletions(-)
+
+diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
+index 536545293d..c1e2852adb 100644
+--- a/libswscale/ppc/yuv2rgb_altivec.c
++++ b/libswscale/ppc/yuv2rgb_altivec.c
+@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+     vector signed short R1, G1, B1;                                           \
+     vector unsigned char R, G, B;                                             \
+                                                                               \
++    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
++    vector unsigned char align_perm;                                          \
++                                                                              \
+     vector signed short lCY       = c->CY;                                    \
+     vector signed short lOY       = c->OY;                                    \
+     vector signed short lCRV      = c->CRV;                                   \
+@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
+                                                                               \
+         for (j = 0; j < w / 16; j++) {                                        \
+-            y0 = vec_xl(0, y1i);                                              \
++            y1ivP = (const vector unsigned char *) y1i;                       \
++            y2ivP = (const vector unsigned char *) y2i;                       \
++            uivP  = (const vector unsigned char *) ui;                        \
++            vivP  = (const vector unsigned char *) vi;                        \
++                                                                              \
++            align_perm = vec_lvsl(0, y1i);                                    \
++            y0 = (vector unsigned char)                                       \
++                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
+                                                                               \
+-            y1 = vec_xl(0, y2i);                                              \
++            align_perm = vec_lvsl(0, y2i);                                    \
++            y1 = (vector unsigned char)                                       \
++                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
+                                                                               \
+-            u = (vector signed char) vec_xl(0, ui);                           \
++            align_perm = vec_lvsl(0, ui);                                     \
++            u = (vector signed char)                                          \
++                    vec_perm(uivP[0], uivP[1], align_perm);                   \
+                                                                               \
+-            v = (vector signed char) vec_xl(0, vi);                           \
++            align_perm = vec_lvsl(0, vi);                                     \
++            v = (vector signed char)                                          \
++                    vec_perm(vivP[0], vivP[1], align_perm);                   \
+                                                                               \
+             u = (vector signed char)                                          \
+                     vec_sub(u,                                                \
+-- 
+2.27.0
+
diff --git a/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
new file mode 100644
index 0000000000000..9a55178c74f0f
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
@@ -0,0 +1,18 @@
+--- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
++++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
+@@ -39,6 +39,15 @@
+ #endif
+ #include <fenv.h>
+ 
++#if (FE_ALL_EXCEPT == 0)
++/* E.g. ARM soft float does not define these */
++#define FE_INVALID    0
++#define FE_DIVBYZERO  0
++#define FE_OVERFLOW   0
++#define FE_UNDERFLOW  0
++#define FE_INEXACT    0
++#endif
++
+ #if CONFIG_LIBFONTCONFIG
+ #include <fontconfig/fontconfig.h>
+ #endif
diff --git a/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
new file mode 100644
index 0000000000000..aa948f7a8a2df
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
@@ -0,0 +1,40 @@
+#==================================================================================================
+# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
+# From: Christopher Degawa <christopher.degawa@intel.com>
+# Date: Thu, 20 Oct 2022 22:55:27 -0500
+# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
+#
+# compressed_ten_bit_format has been deprecated upstream and has no effect
+# and can be removed. Plus, technically it was never used in the first place
+# since it would require the app (ffmpeg) to set it and do additional
+# processing of the input frames.
+#
+# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
+#
+# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
+#==================================================================================================
+--- a/libavcodec/libsvtav1.c
++++ b/libavcodec/libsvtav1.c
+@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
+ 
+ static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
+ {
+-    const int    pack_mode_10bit =
+-        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
+-    const size_t luma_size_8bit  =
+-        config->source_width * config->source_height * (1 << pack_mode_10bit);
+-    const size_t luma_size_10bit =
+-        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
++    const size_t luma_size = config->source_width * config->source_height *
++        (config->encoder_bit_depth > 8 ? 2 : 1);
+ 
+     EbSvtIOFormat *in_data;
+ 
+-    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
++    svt_enc->raw_size = luma_size * 3 / 2;
+ 
+     // allocate buffer for in and out
+     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
+-- 
+GitLab
+
diff --git a/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
new file mode 100644
index 0000000000000..00e3f68a415b8
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
@@ -0,0 +1,28 @@
+From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
+From: Rainer Hochecker <fernetmenta@online.de>
+Date: Sat, 26 Jan 2019 19:48:35 +0100
+Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
+
+This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
+It was hit frequently when watching h264 channels received via DVB-X.
+Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
+---
+ libavcodec/vaapi_h264.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
+index 5854587a255..f12fdc457a4 100644
+--- a/libavcodec/vaapi_h264.c
++++ b/libavcodec/vaapi_h264.c
+@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
+     H264SliceContext *sl = &h->slice_ctx[0];
+     int ret;
+ 
++    if (pic->nb_slices == 0) {
++        ret = AVERROR_INVALIDDATA;
++        goto finish;
++    }
++
+     ret = ff_vaapi_decode_issue(avctx, pic);
+     if (ret < 0)
+         goto finish;
diff --git a/srcpkgs/ffmpeg4/template b/srcpkgs/ffmpeg4/template
new file mode 100644
index 0000000000000..f2c851693d367
--- /dev/null
+++ b/srcpkgs/ffmpeg4/template
@@ -0,0 +1,240 @@
+# Template file for 'ffmpeg4'
+# audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
+pkgname=ffmpeg4
+version=4.4.4
+revision=1
+short_desc="Decoding, encoding and streaming software - ffmpeg4 libraries only"
+maintainer="Orphaned <orphan@voidlinux.org>"
+license="GPL-3.0-or-later"
+homepage="https://www.ffmpeg.org"
+changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
+distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
+checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+
+hostmakedepends="pkg-config perl"
+makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
+ libXext-devel libXvMC-devel libxcb-devel lame-devel libtheora-devel
+ libvorbis-devel x264-devel xvidcore-devel jack-devel SDL2-devel
+ libcdio-paranoia-devel librtmp-devel libmodplug-devel gnutls-devel
+ speex-devel celt-devel harfbuzz-devel libass-devel opus-devel ocl-icd-devel
+ libbs2b-devel libvidstab-devel vmaf-devel $(vopt_if pulseaudio pulseaudio-devel)
+ $(vopt_if vaapi libva-devel) $(vopt_if vdpau libvdpau-devel)
+ $(vopt_if x265 x265-devel) $(vopt_if v4l2 v4l-utils-devel)
+ $(vopt_if fdk_aac fdk-aac-devel) $(vopt_if vpx libvpx-devel)
+ $(vopt_if aom libaom-devel) $(vopt_if sndio sndio-devel)
+ $(vopt_if dav1d libdav1d-devel) $(vopt_if zimg zimg-devel)
+ $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
+ $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
+ $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if mfx 'libmfx libmfx-devel')
+ $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
+
+build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec mfx"
+build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
+
+desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
+desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
+desc_option_sofa="Enable support for AES SOFA"
+desc_option_webp="Enable support for WebP"
+
+case "$XBPS_TARGET_MACHINE" in
+	i686*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau nvenc nvdec"
+			;;
+	x86_64*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau mfx nvenc nvdec"
+			;;
+	ppc64*) build_options_default+=" vaapi vdpau";;
+	mips*) CFLAGS="-mnan=legacy";;
+esac
+
+if [ "$XBPS_TARGET_WORDSIZE" != "32" ]; then
+	build_options_default+=" svtav1"
+fi
+
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+fi
+
+_apply_patch() {
+	local args="$1" pname="$(basename $2)"
+
+	if [ ! -f ".${pname}_done" ]; then
+		patch -N $args -i $2
+		touch .${pname}_done
+	fi
+}
+
+post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64le*) ;;
+		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
+	esac
+
+	vsed -i libavfilter/vf_libvmaf.c -e 's!/usr/local/share/model/\(vmaf_v0.6.1\).pkl!/usr/share/vmaf/\1.json!'
+}
+
+do_configure() {
+	# Fix gcc on x86_64-musl only
+	if [ "$XBPS_TARGET_MACHINE" = "x86_64-musl" ]; then
+		vsed -i configure -e "s;_cflags_speed='-O3';_cflags_speed='-O2';"
+	fi
+
+	if [ "$CROSS_BUILD" ]; then
+		case "$XBPS_TARGET_MACHINE" in
+			arm*) _arch="arm";;
+			aarch64*) _arch="aarch64";;
+			mips*) _arch="mips";;
+			ppc64*) _arch="ppc64";;
+			ppc*) _arch="ppc";;
+			*) _arch="${XBPS_TARGET_MACHINE%%-musl}";;
+		esac
+
+		_args+=" --enable-cross-compile
+			--sysroot=$XBPS_CROSS_BASE
+			--cross-prefix=${XBPS_CROSS_TRIPLET}-
+			--target-os=linux --arch=${_arch}"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc|ppc-musl) _args+=" --disable-altivec";;
+	esac
+
+	if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+		_args+=" --extra-libs=-latomic"
+	fi
+
+	./configure --prefix=/usr --disable-debug --enable-gpl --enable-gnutls \
+		--disable-stripping \
+		--enable-libcdio --enable-version3 --enable-runtime-cpudetect \
+		--enable-libmp3lame --enable-libvorbis --enable-libxvid \
+		--enable-libx264 $(vopt_enable vpx libvpx) --enable-libtheora \
+		--enable-shared --enable-static --enable-libxcb \
+		$(vopt_enable pulseaudio libpulse) --enable-libfreetype --enable-libmodplug \
+		--enable-libspeex --enable-libcelt --enable-libass \
+		--enable-libopus --enable-librtmp --enable-libjack \
+		$(vopt_if fdk_aac '--enable-nonfree --enable-libfdk-aac') \
+		--disable-libopencore_amrnb --disable-libopencore_amrwb \
+		--disable-libopenjpeg \
+		--enable-postproc --enable-opencl ${_args} --enable-libvmaf ${_args} \
+		$(vopt_enable x265 libx265) \
+		$(vopt_enable v4l2 libv4l2) \
+		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
+		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		$(vopt_enable dav1d libdav1d) \
+		$(vopt_enable zimg libzimg) \
+		$(vopt_enable webp libwebp) \
+		$(vopt_enable sofa libmysofa) \
+		$(vopt_enable vulkan) \
+		$(vopt_enable drm libdrm) \
+		$(vopt_enable svtav1 libsvtav1) \
+		$(vopt_enable srt libsrt) \
+		$(vopt_enable rist librist) \
+		$(vopt_enable mfx libmfx) \
+		$(vopt_if nvenc '--enable-nvenc') \
+		$(vopt_if nvdec '--enable-nvdec')
+}
+
+do_build() {
+	make ${makejobs}
+	make doc/ff{mpeg,play}.1
+}
+
+do_install() {
+	make DESTDIR=${DESTDIR} install install-man
+	rm -rf ${DESTDIR}/usr/bin
+}
+
+libavcodec4_package() {
+	short_desc="FFmpeg codec library"
+	pkg_install() {
+		vmove "usr/lib/libavcodec.so.*"
+	}
+}
+
+libavdevice4_package() {
+	short_desc="FFmpeg device handling library"
+	pkg_install() {
+		vmove "usr/lib/libavdevice.so.*"
+	}
+}
+
+libavresample4_package() {
+	short_desc="FFmpeg audio resampling library"
+	pkg_install() {
+		vmove "usr/lib/libavresample.so.*"
+	}
+}
+
+libavformat4_package() {
+	short_desc="FFmpeg file format library"
+	pkg_install() {
+		vmove "usr/lib/libavformat.so.*"
+	}
+}
+
+libavutil4_package() {
+	short_desc="FFmpeg utility library"
+	pkg_install() {
+		vmove "usr/lib/libavutil.so.*"
+	}
+}
+
+libavfilter4_package() {
+	short_desc="FFmpeg audio/video filter library"
+	pkg_install() {
+		vmove "usr/lib/libavfilter.so.*"
+	}
+}
+
+libpostproc4_package() {
+	short_desc="FFmpeg video postprocessing library"
+	pkg_install() {
+		vmove "usr/lib/libpostproc.so.*"
+	}
+}
+
+libswscale4_package() {
+	short_desc="FFmpeg video scaling library"
+	pkg_install() {
+		vmove "usr/lib/libswscale.so.*"
+	}
+}
+
+libswresample4_package() {
+	short_desc="FFmpeg video resampling library"
+	pkg_install() {
+		vmove "usr/lib/libswresample.so.*"
+	}
+}
+
+ffmpeg4-devel_package() {
+	depends="
+		libavcodec4>=${version}_${revision}
+		libavdevice4>=${version}_${revision}
+		libavformat4>=${version}_${revision}
+		libavutil4>=${version}_${revision}
+		libavfilter4>=${version}_${revision}
+		libpostproc4>=${version}_${revision}
+		libswscale4>=${version}_${revision}
+		libswresample4>=${version}_${revision}
+		libavresample4>=${version}_${revision}"
+	short_desc+=" - development files"
+	conflicts="ffmpeg-devel"
+	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
+		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
+		nostrip_files="/usr/lib/libavfilter.a"
+	fi
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.a"
+		vmove "usr/lib/*.so"
+		vmove usr/share/ffmpeg/examples
+		vmove usr/share/man/man3
+	}
+}
diff --git a/srcpkgs/libavcodec4 b/srcpkgs/libavcodec4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavcodec4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavdevice4 b/srcpkgs/libavdevice4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavdevice4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavfilter4 b/srcpkgs/libavfilter4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavfilter4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavformat4 b/srcpkgs/libavformat4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavformat4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavresample4 b/srcpkgs/libavresample4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavutil4 b/srcpkgs/libavutil4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavutil4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libpostproc4 b/srcpkgs/libpostproc4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libpostproc4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswresample4 b/srcpkgs/libswresample4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libswresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswscale4 b/srcpkgs/libswscale4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libswscale4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file

From b896e1df66314ee976de8cc9f55708e242c7d4b1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:04 -0400
Subject: [PATCH 006/115] opencv: update to 4.7.0.

---
 common/shlibs           | 104 ++++++++++++++++++++--------------------
 srcpkgs/opencv/template |   8 ++--
 2 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index 2fecdb6e90491..b1ba1497c8295 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2085,58 +2085,58 @@ libcapstone.so.5 capstone-5.0.1_1
 libhavege.so.2 libhaveged-1.9.11_1
 libnih.so.1 libnih-1.0.3_1
 libnih-dbus.so.1 libnih-1.0.3_1
-libopencv_quality.so.406 libopencv-4.6.0_1
-libopencv_reg.so.406 libopencv-4.6.0_1
-libopencv_surface_matching.so.406 libopencv-4.6.0_1
-libopencv_xphoto.so.406 libopencv-4.6.0_1
-libopencv_freetype.so.406 libopencv-4.6.0_1
-libopencv_fuzzy.so.406 libopencv-4.6.0_1
-libopencv_hfs.so.406 libopencv-4.6.0_1
-libopencv_img_hash.so.406 libopencv-4.6.0_1
-libopencv_line_descriptor.so.406 libopencv-4.6.0_1
-libopencv_saliency.so.406 libopencv-4.6.0_1
-libopencv_structured_light.so.406 libopencv-4.6.0_1
-libopencv_aruco.so.406 libopencv-4.6.0_1
-libopencv_bgsegm.so.406 libopencv-4.6.0_1
-libopencv_bioinspired.so.406 libopencv-4.6.0_1
-libopencv_ccalib.so.406 libopencv-4.6.0_1
-libopencv_face.so.406 libopencv-4.6.0_1
-libopencv_tracking.so.406 libopencv-4.6.0_1
-libopencv_xfeatures2d.so.406 libopencv-4.6.0_1
-libopencv_optflow.so.406 libopencv-4.6.0_1
-libopencv_ximgproc.so.406 libopencv-4.6.0_1
-libopencv_plot.so.406 libopencv-4.6.0_1
-libopencv_text.so.406 libopencv-4.6.0_1
-libopencv_ml.so.406 libopencv-4.6.0_1
-libopencv_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn.so.406 libopencv-4.6.0_1
-libopencv_shape.so.406 libopencv-4.6.0_1
-libopencv_stitching.so.406 libopencv-4.6.0_1
-libopencv_photo.so.406 libopencv-4.6.0_1
-libopencv_video.so.406 libopencv-4.6.0_1
-libopencv_calib3d.so.406 libopencv-4.6.0_1
-libopencv_features2d.so.406 libopencv-4.6.0_1
-libopencv_flann.so.406 libopencv-4.6.0_1
-libopencv_highgui.so.406 libopencv-4.6.0_1
-libopencv_videoio.so.406 libopencv-4.6.0_1
-libopencv_imgcodecs.so.406 libopencv-4.6.0_1
-libopencv_imgproc.so.406 libopencv-4.6.0_1
-libopencv_core.so.406 libopencv-4.6.0_1
-libopencv_superres.so.406 libopencv-4.6.0_1
-libopencv_videostab.so.406 libopencv-4.6.0_1
-libopencv_gapi.so.406 libopencv-4.6.0_1
-libopencv_xobjdetect.so.406 libopencv-4.6.0_1
-libopencv_datasets.so.406 libopencv-4.6.0_1
-libopencv_dnn_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn_superres.so.406 libopencv-4.6.0_1
-libopencv_dpm.so.406 libopencv-4.6.0_1
-libopencv_phase_unwrapping.so.406 libopencv-4.6.0_1
-libopencv_stereo.so.406 libopencv-4.6.0_1
-libopencv_rapid.so.406 libopencv-4.6.0_1
-libopencv_intensity_transform.so.406 libopencv-4.6.0_1
-libopencv_alphamat.so.406 libopencv-4.6.0_1
-libopencv_barcode.so.406 libopencv-4.6.0_1
-libopencv_mcc.so.406 libopencv-4.6.0_1
+libopencv_quality.so.407 libopencv-4.7.0_1
+libopencv_reg.so.407 libopencv-4.7.0_1
+libopencv_surface_matching.so.407 libopencv-4.7.0_1
+libopencv_xphoto.so.407 libopencv-4.7.0_1
+libopencv_freetype.so.407 libopencv-4.7.0_1
+libopencv_fuzzy.so.407 libopencv-4.7.0_1
+libopencv_hfs.so.407 libopencv-4.7.0_1
+libopencv_img_hash.so.407 libopencv-4.7.0_1
+libopencv_line_descriptor.so.407 libopencv-4.7.0_1
+libopencv_saliency.so.407 libopencv-4.7.0_1
+libopencv_structured_light.so.407 libopencv-4.7.0_1
+libopencv_aruco.so.407 libopencv-4.7.0_1
+libopencv_bgsegm.so.407 libopencv-4.7.0_1
+libopencv_bioinspired.so.407 libopencv-4.7.0_1
+libopencv_ccalib.so.407 libopencv-4.7.0_1
+libopencv_face.so.407 libopencv-4.7.0_1
+libopencv_tracking.so.407 libopencv-4.7.0_1
+libopencv_xfeatures2d.so.407 libopencv-4.7.0_1
+libopencv_optflow.so.407 libopencv-4.7.0_1
+libopencv_ximgproc.so.407 libopencv-4.7.0_1
+libopencv_plot.so.407 libopencv-4.7.0_1
+libopencv_text.so.407 libopencv-4.7.0_1
+libopencv_ml.so.407 libopencv-4.7.0_1
+libopencv_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn.so.407 libopencv-4.7.0_1
+libopencv_shape.so.407 libopencv-4.7.0_1
+libopencv_stitching.so.407 libopencv-4.7.0_1
+libopencv_photo.so.407 libopencv-4.7.0_1
+libopencv_video.so.407 libopencv-4.7.0_1
+libopencv_calib3d.so.407 libopencv-4.7.0_1
+libopencv_features2d.so.407 libopencv-4.7.0_1
+libopencv_flann.so.407 libopencv-4.7.0_1
+libopencv_highgui.so.407 libopencv-4.7.0_1
+libopencv_videoio.so.407 libopencv-4.7.0_1
+libopencv_imgcodecs.so.407 libopencv-4.7.0_1
+libopencv_imgproc.so.407 libopencv-4.7.0_1
+libopencv_core.so.407 libopencv-4.7.0_1
+libopencv_superres.so.407 libopencv-4.7.0_1
+libopencv_videostab.so.407 libopencv-4.7.0_1
+libopencv_gapi.so.407 libopencv-4.7.0_1
+libopencv_xobjdetect.so.407 libopencv-4.7.0_1
+libopencv_datasets.so.407 libopencv-4.7.0_1
+libopencv_dnn_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn_superres.so.407 libopencv-4.7.0_1
+libopencv_dpm.so.407 libopencv-4.7.0_1
+libopencv_phase_unwrapping.so.407 libopencv-4.7.0_1
+libopencv_stereo.so.407 libopencv-4.7.0_1
+libopencv_rapid.so.407 libopencv-4.7.0_1
+libopencv_intensity_transform.so.407 libopencv-4.7.0_1
+libopencv_alphamat.so.407 libopencv-4.7.0_1
+libopencv_barcode.so.407 libopencv-4.7.0_1
+libopencv_mcc.so.407 libopencv-4.7.0_1
 libuniconf.so.4.6 wvstreams-4.6.1_20
 libwvbase.so.4.6 wvstreams-4.6.1_20
 libwvutils.so.4.6 wvstreams-4.6.1_20
diff --git a/srcpkgs/opencv/template b/srcpkgs/opencv/template
index 8a7eb6a5ddc5b..ce94de9424d18 100644
--- a/srcpkgs/opencv/template
+++ b/srcpkgs/opencv/template
@@ -1,7 +1,7 @@
 # Template file for 'opencv'
 pkgname=opencv
-version=4.6.0
-revision=5
+version=4.7.0
+revision=1
 create_wrksrc=yes
 build_wrksrc=${pkgname}-${version}
 build_style=cmake
@@ -24,8 +24,8 @@ homepage="https://opencv.org"
 changelog="https://github.com/opencv/opencv/wiki/ChangeLog"
 distfiles="https://github.com/opencv/opencv/archive/${version}.tar.gz
  https://github.com/opencv/opencv_contrib/archive/${version}.tar.gz>contrib.tar.gz"
-checksum="1ec1cba65f9f20fe5a41fda1586e01c70ea0c9a6d7b67c9e13edf0cfe2239277
- 1777d5fd2b59029cf537e5fd6f8aa68d707075822f90bde683fcde086f85f7a7"
+checksum="8df0079cdbe179748a18d44731af62a245a45ebf5085223dc03133954c662973
+ 42df840cf9055e59d0e22c249cfb19f04743e1bdad113d31b1573d3934d62584"
 patch_args="-Np1 -d ${build_wrksrc}"
 # tests hang indenfinitely, even with test data included
 make_check=no

From 5f039a88bc5da494fd7345a7c704a8abbf804b61 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 007/115] actiona: revbump for opencv-4.7.0

---
 srcpkgs/actiona/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/actiona/template b/srcpkgs/actiona/template
index cf5f0b7a2ae61..0d899311e6df7 100644
--- a/srcpkgs/actiona/template
+++ b/srcpkgs/actiona/template
@@ -1,7 +1,7 @@
 # Template file for 'actiona'
 pkgname=actiona
 version=3.10.1
-revision=2
+revision=3
 build_style=qmake
 configure_args="PKGCONFIG_OPENCV=opencv4"
 hostmakedepends="pkg-config qt5-plugin-mysql qt5-qmake qt5-host-tools"

From c91e62e44852b35fec8757efc9a0033fcf8b657d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 008/115] qimgv: revbump for opencv-4.7.0

---
 srcpkgs/qimgv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qimgv/template b/srcpkgs/qimgv/template
index 7eb30db33992c..dd341dfe1bfce 100644
--- a/srcpkgs/qimgv/template
+++ b/srcpkgs/qimgv/template
@@ -1,7 +1,7 @@
 # Template file for 'qimgv'
 pkgname=qimgv
 version=1.0.2
-revision=2
+revision=3
 build_style=cmake
 configure_args="$(vopt_if video -DVIDEO_SUPPORT=ON -DVIDEO_SUPPORT=OFF)
  $(vopt_if scale -DOPENCV_SUPPORT=ON -DOPENCV_SUPPORT=OFF)

From 91f888f1da625ed0405be41066a2bb99a75cd176 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 009/115] retroshare: revbump for opencv-4.7.0

---
 srcpkgs/retroshare/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroshare/template b/srcpkgs/retroshare/template
index bb17569277a7f..49e2c1cbe8a53 100644
--- a/srcpkgs/retroshare/template
+++ b/srcpkgs/retroshare/template
@@ -1,7 +1,7 @@
 # Template file for 'retroshare'
 pkgname=retroshare
 version=0.6.6
-revision=3
+revision=4
 build_style=qmake
 #XXX broadcast feature requires an ancient udp-discovery-cpp which either needs
 # to be fetched+patched (FTBFS) here or packaged :/

From 6ba839e9baa461f1b68706b1fdede502cc1c2db1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 010/115] waifu2x-converter-cpp: revbump for opencv-4.7.0

---
 srcpkgs/waifu2x-converter-cpp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waifu2x-converter-cpp/template b/srcpkgs/waifu2x-converter-cpp/template
index 361b8a23b9497..c5ac17eb54ea4 100644
--- a/srcpkgs/waifu2x-converter-cpp/template
+++ b/srcpkgs/waifu2x-converter-cpp/template
@@ -1,7 +1,7 @@
 # Template file for 'waifu2x-converter-cpp'
 pkgname=waifu2x-converter-cpp
 version=5.2.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DINSTALL_MODELS=ON"
 hostmakedepends="pkg-config"

From 61e309ab61950e494075ccc506307bd4e4e43a87 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:38 -0400
Subject: [PATCH 011/115] vlc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/vlc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vlc/template b/srcpkgs/vlc/template
index be579ce38fe37..3974289947401 100644
--- a/srcpkgs/vlc/template
+++ b/srcpkgs/vlc/template
@@ -25,7 +25,7 @@ lib32disabled=yes
 hostmakedepends="automake libtool pkg-config flex gettext libgcrypt-devel
  live555-devel gettext-devel $(vopt_if lua lua52) $(vopt_if chromecast protobuf)"
 makedepends="
- avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg-devel freefont-ttf
+ avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg4-devel freefont-ttf
  gnutls-devel jack-devel liba52-devel libass-devel libbluray-devel
  libcdio-devel libdca-devel libdvbpsi-devel libdvdnav-devel libmad-devel
  libmatroska-devel libmodplug-devel libmpcdec-devel libmpeg2-devel

From c5b7dabae01e04aab6f693c66d4bf85f377418e5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:55 -0400
Subject: [PATCH 012/115] osg: revbump for ffmpeg4-4.4.3

---
 srcpkgs/osg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/osg/template b/srcpkgs/osg/template
index a9ebbd287933b..755793f7e11bf 100644
--- a/srcpkgs/osg/template
+++ b/srcpkgs/osg/template
@@ -8,7 +8,7 @@ build_helper="qemu"
 configure_args="-DLIB_POSTFIX="
 hostmakedepends="pkg-config xrandr"
 makedepends="MesaLib-devel gtkglext-devel libcurl-devel giflib-devel librsvg-devel
- jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg-devel xine-lib-devel
+ jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg4-devel xine-lib-devel
  SDL2-devel gst-plugins-base1-devel
  $(vopt_if openexr libopenexr-devel)
  $(vopt_if poppler poppler-glib-devel)

From 723f6b9c795f11e30f0a45261e01b070e20ee996 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:13 -0400
Subject: [PATCH 013/115] xine-lib: revbump for ffmpeg4-4.4.3

---
 srcpkgs/xine-lib/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/xine-lib/template b/srcpkgs/xine-lib/template
index f713eff49b07c..ed6194c17d11e 100644
--- a/srcpkgs/xine-lib/template
+++ b/srcpkgs/xine-lib/template
@@ -1,6 +1,6 @@
 # Template file for 'xine-lib'
 pkgname=xine-lib
-version=1.2.12
+version=1.2.13
 revision=1
 build_style=gnu-configure
 configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
@@ -8,7 +8,7 @@ configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
 hostmakedepends="automake gettext-devel libtool pkg-config perl"
 makedepends="
  zlib-devel alsa-lib-devel libxcb-devel libSM-devel libXext-devel libXv-devel
- libXvMC-devel liba52-devel libmad-devel ffmpeg-devel pulseaudio-devel
+ libXvMC-devel liba52-devel libmad-devel ffmpeg4-devel pulseaudio-devel
  jack-devel samba-devel libflac-devel libmodplug-devel libmpcdec-devel
  speex-devel libtheora-devel libvorbis-devel libdca-devel faad2-devel
  libcdio-devel libbluray-devel aalib-devel libcaca-devel libXinerama-devel
@@ -19,7 +19,7 @@ license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="http://www.xine-project.org"
 changelog="https://sourceforge.net/projects/xine/files/xine-lib/${version}/README.txt/view"
 distfiles="${SOURCEFORGE_SITE}/xine/${pkgname}-${version}.tar.xz"
-checksum=d606270468e1540c2a89c0d7f5fdf11e17ecc0c2698cc0bcb1065ff26abee098
+checksum=5f10d6d718a4a51c17ed1b32b031d4f9b80b061e8276535b2be31e5ac4b75e6f
 
 case "$XBPS_TARGET_MACHINE" in
 	i686-musl)

From ef0361f3422eb690460ed799488f9b853adf1945 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 014/115] QMPlay2: revbump for ffmpeg-6.0

---
 srcpkgs/QMPlay2/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/QMPlay2/template b/srcpkgs/QMPlay2/template
index a63e271ef83b8..5ee04171b51e8 100644
--- a/srcpkgs/QMPlay2/template
+++ b/srcpkgs/QMPlay2/template
@@ -1,7 +1,7 @@
 # Template file for 'QMPlay2'
 pkgname=QMPlay2
 version=23.09.05
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools"
 makedepends="alsa-lib-devel ffmpeg-devel libass-devel libcdio-devel libgme-devel

From bdbf350fa4fef137198b349143e2af188ee6b9e3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 015/115] alsa-plugins: revbump for ffmpeg-6.0

---
 srcpkgs/alsa-plugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/alsa-plugins/template b/srcpkgs/alsa-plugins/template
index 0bfa6d9fd2643..a5708a7d82a8f 100644
--- a/srcpkgs/alsa-plugins/template
+++ b/srcpkgs/alsa-plugins/template
@@ -1,7 +1,7 @@
 # Template file for 'alsa-plugins'
 pkgname=alsa-plugins
 version=1.2.7.1
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--disable-maemo-plugin"
 hostmakedepends="pkg-config"

From 7a9fba0d569ba886191d1af4df48b14f95d6bc34 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 016/115] arcan: revbump for ffmpeg-6.0

---
 srcpkgs/arcan/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/arcan/template b/srcpkgs/arcan/template
index efd0afe10576d..b91e6900d42a1 100644
--- a/srcpkgs/arcan/template
+++ b/srcpkgs/arcan/template
@@ -2,7 +2,7 @@
 # !! keep synced with: acfgfs aclip aloadimage
 pkgname=arcan
 version=0.6.2.1
-revision=1
+revision=2
 create_wrksrc=yes
 build_wrksrc=arcan/src
 build_style=cmake

From 6fd54f8b9b882790201a5d68e712e712a809542f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 017/115] attract: revbump for ffmpeg4-4.4.3

---
 srcpkgs/attract/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/attract/template b/srcpkgs/attract/template
index 26144e931a3c7..e760bf0d18aec 100644
--- a/srcpkgs/attract/template
+++ b/srcpkgs/attract/template
@@ -1,12 +1,12 @@
 # Template file for 'attract'
 pkgname=attract
 version=2.6.2
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="VERBOSE=1"
 make_use_env=yes
 hostmakedepends="pkg-config"
-makedepends="SFML-devel ffmpeg-devel fontconfig-devel glu-devel libarchive-devel
+makedepends="SFML-devel ffmpeg4-devel fontconfig-devel glu-devel libarchive-devel
  libcurl-devel libjpeg-turbo-devel xine-lib rapidjson libXrandr-devel"
 depends="git"
 short_desc="Attract-Mode is a graphical frontend for emulators"

From 21cb0ccb0243a92db89405eb1c8151d294b28089 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 018/115] aubio: revbump for ffmpeg-6.0

---
 srcpkgs/aubio/patches/ffmpeg5.patch | 25 +++++++++++++++++++++++++
 srcpkgs/aubio/template              |  2 +-
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/aubio/patches/ffmpeg5.patch

diff --git a/srcpkgs/aubio/patches/ffmpeg5.patch b/srcpkgs/aubio/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..aace41a6e6d9a
--- /dev/null
+++ b/srcpkgs/aubio/patches/ffmpeg5.patch
@@ -0,0 +1,25 @@
+From 8a05420e5dd8c7b8b2447f82dc919765876511b3 Mon Sep 17 00:00:00 2001
+From: Paul Brossier <piem@piem.org>
+Date: Tue, 25 Jan 2022 18:30:27 +0100
+Subject: [PATCH] [source_avcodec] define FF_API_LAVF_AVCTX for libavcodec >
+ 59, thx @berolinux (closes gh-353)
+
+---
+ src/io/source_avcodec.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/io/source_avcodec.c b/src/io/source_avcodec.c
+index e0ae93b5..1421bd9a 100644
+--- a/src/io/source_avcodec.c
++++ b/src/io/source_avcodec.c
+@@ -68,6 +68,10 @@
+ #define AUBIO_AVCODEC_MAX_BUFFER_SIZE AV_INPUT_BUFFER_MIN_SIZE
+ #endif
+ 
++#if LIBAVCODEC_VERSION_MAJOR >= 59
++#define FF_API_LAVF_AVCTX 1
++#endif
++
+ struct _aubio_source_avcodec_t {
+   uint_t hop_size;
+   uint_t samplerate;
diff --git a/srcpkgs/aubio/template b/srcpkgs/aubio/template
index ad1c4b2569917..7d875cc02541a 100644
--- a/srcpkgs/aubio/template
+++ b/srcpkgs/aubio/template
@@ -1,7 +1,7 @@
 # Template file for 'aubio'
 pkgname=aubio
 version=0.4.9
-revision=1
+revision=2
 build_style=waf3
 # XXX lash, pure and swig support.
 hostmakedepends="pkg-config txt2man"

From ce16e016368ecd5475ef9deff174b3eb1c6db80e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 019/115] audacious-plugins: revbump for ffmpeg-6.0

---
 .../audacious-plugins/patches/ffmpeg5.patch   | 43 +++++++++++++++++++
 srcpkgs/audacious-plugins/template            |  2 +-
 2 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/audacious-plugins/patches/ffmpeg5.patch

diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg5.patch b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..4e5e34099d71c
--- /dev/null
+++ b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
@@ -0,0 +1,43 @@
+commit 298aa371c56c2f52c25a33d9bdec4918b11cebdc
+Author: tibequadorian <tibequadorian@posteo.de>
+Date:   Sat Mar 19 18:40:12 2022 +0100
+
+    audacious-plugins: rebuild against ffmpeg-5.0
+
+diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+new file mode 100644
+index 0000000000..617c11215b
+--- /dev/null
++++ b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+@@ -0,0 +1,31 @@
++From f60beb400eeb1e4778bbfd738bc4a4ccef3de539 Mon Sep 17 00:00:00 2001
++From: John Lindgren <john@jlindgren.net>
++Date: Sat, 5 Mar 2022 12:05:34 -0500
++Subject: [PATCH] Fix build with FFmpeg 5.0
++
++---
++ src/ffaudio/ffaudio-core.cc | 4 ++--
++ 1 file changed, 2 insertions(+), 2 deletions(-)
++
++diff --git a/src/ffaudio/ffaudio-core.cc b/src/ffaudio/ffaudio-core.cc
++index 16dc63e3a..a2b95fd6c 100644
++--- a/src/ffaudio/ffaudio-core.cc
+++++ b/src/ffaudio/ffaudio-core.cc
++@@ -274,7 +274,7 @@ static AVInputFormat * get_format_by_content (const char * name, VFSFile & file)
++         AVProbeData d = {name, buf, filled};
++         score = target;
++ 
++-        f = av_probe_input_format2 (& d, true, & score);
+++        f = (AVInputFormat *) av_probe_input_format2 (& d, true, & score);
++         if (f)
++             break;
++ 
++@@ -347,7 +347,7 @@ static bool find_codec (AVFormatContext * c, CodecInfo * cinfo)
++ #endif
++         if (stream && stream->codecpar && stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
++         {
++-            AVCodec * codec = avcodec_find_decoder (stream->codecpar->codec_id);
+++            AVCodec * codec = (AVCodec *) avcodec_find_decoder (stream->codecpar->codec_id);
++ 
++             if (codec)
++             {
diff --git a/srcpkgs/audacious-plugins/template b/srcpkgs/audacious-plugins/template
index 88cbc1671fc6a..beebfae59ed44 100644
--- a/srcpkgs/audacious-plugins/template
+++ b/srcpkgs/audacious-plugins/template
@@ -2,7 +2,7 @@
 #Keep in sync with audacious!
 pkgname=audacious-plugins
 version=4.3.1
-revision=1
+revision=2
 build_style=meson
 configure_args="$(vopt_bool gtk3 gtk) $(vopt_bool gtk3)
  $(vopt_bool qt) $(vopt_bool qt qt6)"

From c0af7fa8b3f760b32c2c28cc5d242c651578af66 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 020/115] audacity: revbump for ffmpeg4-4.4.3

---
 srcpkgs/audacity/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/audacity/template b/srcpkgs/audacity/template
index 73314e6232bd6..df26db1c15873 100644
--- a/srcpkgs/audacity/template
+++ b/srcpkgs/audacity/template
@@ -1,7 +1,7 @@
 # Template file for 'audacity'
 pkgname=audacity
 version=3.3.3
-revision=1
+revision=2
 build_style=cmake
 build_helper="cmake-wxWidgets-gtk3 qemu"
 configure_args="-Daudacity_use_ffmpeg=loaded -Daudacity_lib_preference=system
@@ -10,7 +10,7 @@ configure_args="-Daudacity_use_ffmpeg=loaded -Daudacity_lib_preference=system
  -Daudacity_has_vst3=no"
 hostmakedepends="pkg-config gettext python3"
 makedepends="wxWidgets-gtk3-devel gtk+3-devel expat-devel lame-devel
- libsoxr-devel portaudio-devel sqlite-devel libcurl-devel ffmpeg-devel
+ libsoxr-devel portaudio-devel sqlite-devel libcurl-devel ffmpeg4-devel
  libid3tag-devel libmad-devel vamp-plugin-sdk-devel libogg-devel
  libvorbis-devel libflac-devel lilv-devel lv2 serd-devel sord-devel
  sratom-devel suil-devel portmidi-devel soundtouch-devel twolame-devel

From 3b27debf07c8ccd1256b44b32ca45500cacf66c8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 021/115] avidemux: revbump for ffmpeg-6.0

---
 srcpkgs/avidemux/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/avidemux/template b/srcpkgs/avidemux/template
index 253a0243e2259..557285982d2b8 100644
--- a/srcpkgs/avidemux/template
+++ b/srcpkgs/avidemux/template
@@ -1,7 +1,7 @@
 # Template file for 'avidemux'
 pkgname=avidemux
 version=2.8.0
-revision=2
+revision=3
 # Can't be compiled for aarch64, arm* or mips*
 archs="x86_64* i686*"
 hostmakedepends="cmake pkg-config qt5-host-tools qt5-devel tar yasm"

From 8e2e081bc0bd54db21c56051b9bf5f4753c42654 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 022/115] blender: revbump for ffmpeg-6.0

---
 srcpkgs/blender/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index fc6bd5fe25ce0..eea897d828a74 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -9,8 +9,8 @@ configure_args="-DWITH_INSTALL_PORTABLE=OFF -DWITH_PYTHON_INSTALL=OFF
  -DWITH_JACK=ON -DWITH_CODEC_FFMPEG=ON -DWITH_CODEC_SNDFILE=ON -DWITH_OPENMP=ON
  -DWITH_FFTW3=ON -DWITH_MOD_OCEANSIM=ON -DWITH_CYCLES_EMBREE=OFF -DWITH_OPENCOLORIO=ON
  -DWITH_IMAGE_OPENEXR=ON -DWITH_IMAGE_OPENJPEG=ON -DWITH_OPENSUBDIV=ON
- -DWITH_OPENCOLLADA=ON -DWITH_SYSTEM_GLEW=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
- -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_LIBDECOR=ON
+ -DWITH_OPENCOLLADA=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
+ -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_WAYLAND_LIBDECOR=ON
  -DWITH_BUILDINFO=OFF -DPYTHON_VERSION=${py3_ver} -DPYTHON_LIBPATH=/usr/lib
  -DPYTHON_LIBRARY=python${py3_ver}${py3_abiver} -DPYTHON_INCLUDE_DIRS=/${py3_inc}
  -DWITH_SYSTEM_LZO=ON -DWITH_SYSTEM_EIGEN3=ON -DWITH_SYSTEM_FREETYPE=ON"

From 4e81923f906c176c507d50e06d077765f883385a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 023/115] cantata: revbump for ffmpeg-6.0

---
 srcpkgs/cantata/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cantata/template b/srcpkgs/cantata/template
index 4b417d80d5c2d..8a90aaa4c07a2 100644
--- a/srcpkgs/cantata/template
+++ b/srcpkgs/cantata/template
@@ -1,7 +1,7 @@
 # Template file for 'cantata'
 pkgname=cantata
 version=2.5.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools qt5-tools"
 makedepends="qt5-devel qt5-tools-devel qt5-svg-devel qt5-xmlpatterns-devel

From f449f8e4a8bb929c75edea467307b879ac0f932f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 024/115] ccextractor: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ccextractor/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/ccextractor/template b/srcpkgs/ccextractor/template
index 9abcd82852b27..6eccad5885af9 100644
--- a/srcpkgs/ccextractor/template
+++ b/srcpkgs/ccextractor/template
@@ -1,12 +1,12 @@
 # Template file for 'ccextractor'
 pkgname=ccextractor
 version=0.93
-revision=1
+revision=2
 build_wrksrc="linux"
 build_style=gnu-configure
 configure_args="--enable-ocr --enable-hardsubx"
 hostmakedepends="automake pkg-config"
-makedepends="leptonica-devel tesseract-ocr-devel ffmpeg-devel"
+makedepends="leptonica-devel tesseract-ocr-devel ffmpeg4-devel"
 short_desc="Extract subtitles from video streams"
 maintainer="newbluemoon <blaumolch@mailbox.org>"
 license="GPL-2.0-or-later"

From e21cf854719b5730d4b9ba2a0d1964b068345d45 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 025/115] chromaprint: revbump for ffmpeg-6.0

---
 srcpkgs/chromaprint/patches/ffmpeg5.patch | 569 ++++++++++++++++++++++
 srcpkgs/chromaprint/template              |   2 +-
 2 files changed, 570 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromaprint/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromaprint/patches/ffmpeg5.patch b/srcpkgs/chromaprint/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..a9fd307a23c8a
--- /dev/null
+++ b/srcpkgs/chromaprint/patches/ffmpeg5.patch
@@ -0,0 +1,569 @@
+From 8ccad6937177b1b92e40ab8f4447ea27bac009a7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= <lalinsky@gmail.com>
+Date: Fri, 4 Nov 2022 21:47:38 +0100
+Subject: [PATCH] Use FFmpeg 5.x (#120)
+
+* Use FFmpeg 5.1.2 for CI builds
+
+* Build on Ubuntu 20.04
+
+* Upgrade code to FFmpeg 5.x APIs
+
+* Only set FFmpeg include dirs if building tools
+
+* No longer needed
+
+* Use ubuntu 20.04
+---
+ .github/workflows/build.yml                   |   6 +-
+ CMakeLists.txt                                |  16 --
+ package/build.sh                              |   4 +-
+ src/audio/ffmpeg_audio_processor.h            |   2 -
+ src/audio/ffmpeg_audio_processor_avresample.h |  72 -------
+ src/audio/ffmpeg_audio_processor_swresample.h |  18 +-
+ src/audio/ffmpeg_audio_reader.h               | 197 +++++++++---------
+ tests/CMakeLists.txt                          |   6 +
+ 8 files changed, 122 insertions(+), 199 deletions(-)
+ delete mode 100644 src/audio/ffmpeg_audio_processor_avresample.h
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index f8d6a32..4da2405 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -84,9 +84,6 @@ find_package(FFmpeg)
+ if(FFMPEG_LIBRARIES)
+ 	cmake_push_check_state(RESET)
+ 	set(CMAKE_REQUIRED_LIBRARIES ${FFMPEG_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -lm)
+-	check_function_exists(av_packet_unref HAVE_AV_PACKET_UNREF)
+-	check_function_exists(av_frame_alloc HAVE_AV_FRAME_ALLOC)
+-	check_function_exists(av_frame_free HAVE_AV_FRAME_FREE)
+ 	cmake_pop_check_state()
+ endif()
+
+@@ -163,14 +160,11 @@ message(STATUS "Using ${FFT_LIB} for FFT calculations")
+ if(NOT AUDIO_PROCESSOR_LIB)
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+ 		set(AUDIO_PROCESSOR_LIB "swresample")
+-	elseif(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(AUDIO_PROCESSOR_LIB "avresample")
+ 	endif()
+ endif()
+
+ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE OFF)
+ 		set(USE_SWRESAMPLE ON)
+ 		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBSWRESAMPLE_LIBRARIES})
+ 		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBSWRESAMPLE_INCLUDE_DIRS})
+@@ -178,16 +172,6 @@ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+ 	endif()
+ 	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+-elseif(AUDIO_PROCESSOR_LIB STREQUAL "avresample")
+-	if(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE ON)
+-		set(USE_SWRESAMPLE OFF)
+-		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBAVRESAMPLE_LIBRARIES})
+-		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBAVRESAMPLE_INCLUDE_DIRS})
+-	else()
+-		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+-	endif()
+-	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+ else()
+ 	message(STATUS "Building without audio conversion support, please install FFmpeg with libswresample")
+ endif()
+diff --git a/package/build.sh b/package/build.sh
+index da631ae..b41d36e 100755
+--- a/package/build.sh
++++ b/package/build.sh
+@@ -7,8 +7,8 @@ set -eux
+
+ BASE_DIR=$(cd $(dirname $0)/.. && pwd)
+
+-FFMPEG_VERSION=4.4.1
+-FFMPEG_BUILD_TAG=v4.4.1-1
++FFMPEG_VERSION=5.1.2
++FFMPEG_BUILD_TAG=v${FFMPEG_VERSION}-1
+
+ TMP_BUILD_DIR=$BASE_DIR/$(mktemp -d build.XXXXXXXX)
+ trap 'rm -rf $TMP_BUILD_DIR' EXIT
+diff --git a/src/audio/ffmpeg_audio_processor.h b/src/audio/ffmpeg_audio_processor.h
+index 7628fc7..39f4f6d 100644
+--- a/src/audio/ffmpeg_audio_processor.h
++++ b/src/audio/ffmpeg_audio_processor.h
+@@ -10,8 +10,6 @@
+
+ #if defined(USE_SWRESAMPLE)
+ #include "audio/ffmpeg_audio_processor_swresample.h"
+-#elif defined(USE_AVRESAMPLE)
+-#include "audio/ffmpeg_audio_processor_avresample.h"
+ #else
+ #error "no audio processing library"
+ #endif
+diff --git a/src/audio/ffmpeg_audio_processor_avresample.h b/src/audio/ffmpeg_audio_processor_avresample.h
+deleted file mode 100644
+index bd85f92..0000000
+--- a/src/audio/ffmpeg_audio_processor_avresample.h
++++ /dev/null
+@@ -1,72 +0,0 @@
+-// Copyright (C) 2016  Lukas Lalinsky
+-// Distributed under the MIT license, see the LICENSE file for details.
+-
+-#ifndef CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-#define CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-
+-extern "C" {
+-#include <libavresample/avresample.h>
+-}
+-
+-namespace chromaprint {
+-
+-class FFmpegAudioProcessor {
+-public:
+-	FFmpegAudioProcessor() {
+-		m_resample_ctx = avresample_alloc_context();
+-	}
+-
+-	~FFmpegAudioProcessor() {
+-		avresample_free(&m_resample_ctx);
+-	}
+-
+-	void SetCompatibleMode() {
+-		av_opt_set_int(m_resample_ctx, "filter_size", 16, 0);
+-		av_opt_set_int(m_resample_ctx, "phase_shift", 8, 0);
+-		av_opt_set_int(m_resample_ctx, "linear_interp", 1, 0);
+-		av_opt_set_double(m_resample_ctx, "cutoff", 0.8, 0);
+-	}
+-
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "in_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_rate", sample_rate, 0);
+-	}
+-
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "out_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_rate, 0);
+-	}
+-
+-	int Init() {
+-		return avresample_open(m_resample_ctx);
+-	}
+-
+-	int Convert(uint8_t **out, int out_count, const uint8_t **in, int in_count) {
+-		return avresample_convert(m_resample_ctx, out, 0, out_count, (uint8_t **) in, 0, in_count);
+-	}
+-
+-	int Flush(uint8_t **out, int out_count) {
+-		return avresample_read(m_resample_ctx, out, out_count);
+-	}
+-
+-private:
+-	AVAudioResampleContext *m_resample_ctx = nullptr;
+-};
+-
+-}; // namespace chromaprint
+-
+-#endif
+diff --git a/src/audio/ffmpeg_audio_processor_swresample.h b/src/audio/ffmpeg_audio_processor_swresample.h
+index b86266b..b1d4bea 100644
+--- a/src/audio/ffmpeg_audio_processor_swresample.h
++++ b/src/audio/ffmpeg_audio_processor_swresample.h
+@@ -28,30 +28,28 @@ public:
+ 		av_opt_set_double(m_swr_ctx, "cutoff", 0.8, 0);
+ 	}
+
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "icl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "ich", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetInputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "in_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "isf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "in_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "isr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "in_sample_rate", sample_rate, 0);
+ 	}
+
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "ocl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "och", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetOutputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "out_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "osf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "out_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "osr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "out_sample_rate", sample_rate, 0);
+ 	}
+
+ 	int Init() {
+diff --git a/src/audio/ffmpeg_audio_reader.h b/src/audio/ffmpeg_audio_reader.h
+index 5550164..1c6b346 100644
+--- a/src/audio/ffmpeg_audio_reader.h
++++ b/src/audio/ffmpeg_audio_reader.h
+@@ -62,7 +62,7 @@ public:
+ 	bool Read(const int16_t **data, size_t *size);
+
+ 	bool IsOpen() const { return m_opened; }
+-	bool IsFinished() const { return m_finished && !m_got_frame; }
++	bool IsFinished() const { return !m_has_more_packets && !m_has_more_frames; }
+
+ 	std::string GetError() const { return m_error; }
+ 	int GetErrorCode() const { return m_error_code; }
+@@ -74,20 +74,19 @@ private:
+ 	uint8_t *m_convert_buffer[1] = { nullptr };
+ 	int m_convert_buffer_nb_samples = 0;
+
+-	AVInputFormat *m_input_fmt = nullptr;
++	const AVInputFormat *m_input_fmt = nullptr;
+ 	AVDictionary *m_input_opts = nullptr;
+
+ 	AVFormatContext *m_format_ctx = nullptr;
+ 	AVCodecContext *m_codec_ctx = nullptr;
+-	AVFrame *m_frame = nullptr;
+ 	int m_stream_index = -1;
+ 	std::string m_error;
+ 	int m_error_code = 0;
+-	bool m_finished = false;
+ 	bool m_opened = false;
+-	int m_got_frame = 0;
+-	AVPacket m_packet;
+-	AVPacket m_packet0;
++	bool m_has_more_packets = true;
++	bool m_has_more_frames = true;
++	AVPacket *m_packet = nullptr;
++	AVFrame *m_frame = nullptr;
+
+ 	int m_output_sample_rate = 0;
+ 	int m_output_channels = 0;
+@@ -98,19 +97,12 @@ private:
+
+ inline FFmpegAudioReader::FFmpegAudioReader() {
+ 	av_log_set_level(AV_LOG_QUIET);
+-
+-	av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
+ }
+
+ inline FFmpegAudioReader::~FFmpegAudioReader() {
+ 	Close();
+ 	av_dict_free(&m_input_opts);
+ 	av_freep(&m_convert_buffer[0]);
+-	av_packet_unref(&m_packet0);
+ }
+
+ inline bool FFmpegAudioReader::SetInputFormat(const char *name) {
+@@ -135,11 +127,10 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ 	Close();
+
+-    av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
++	m_packet = av_packet_alloc();
++	if (!m_packet) {
++		return false;
++	}
+
+ 	ret = avformat_open_input(&m_format_ctx, file_name.c_str(), m_input_fmt, &m_input_opts);
+ 	if (ret < 0) {
+@@ -153,26 +144,31 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		return false;
+ 	}
+
+-	AVCodec *codec;
++	const AVCodec *codec;
+ 	ret = av_find_best_stream(m_format_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &codec, 0);
+ 	if (ret < 0) {
+ 		SetError("Could not find any audio stream in the file", ret);
+ 		return false;
+ 	}
+ 	m_stream_index = ret;
++	auto stream = m_format_ctx->streams[m_stream_index];
+
+-	m_codec_ctx = m_format_ctx->streams[m_stream_index]->codec;
++	m_codec_ctx = avcodec_alloc_context3(codec);
+ 	m_codec_ctx->request_sample_fmt = AV_SAMPLE_FMT_S16;
+
++	ret = avcodec_parameters_to_context(m_codec_ctx, stream->codecpar);
++	if (ret < 0) {
++		SetError("Could not copy the stream parameters", ret);
++		return false;
++	}
++
+ 	ret = avcodec_open2(m_codec_ctx, codec, nullptr);
+ 	if (ret < 0) {
+ 		SetError("Could not open the codec", ret);
+ 		return false;
+ 	}
+
+-	if (!m_codec_ctx->channel_layout) {
+-		m_codec_ctx->channel_layout = av_get_default_channel_layout(m_codec_ctx->channels);
+-	}
++	av_dump_format(m_format_ctx, 0, "foo", 0);
+
+ 	m_frame = av_frame_alloc();
+ 	if (!m_frame) {
+@@ -183,19 +179,23 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		m_output_sample_rate = m_codec_ctx->sample_rate;
+ 	}
+
+-	if (!m_output_channels) {
+-		m_output_channels = m_codec_ctx->channels;
++	AVChannelLayout output_channel_layout;
++	if (m_output_channels) {
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
++	} else {
++		m_output_channels = m_codec_ctx->ch_layout.nb_channels;
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
+ 	}
+
+-	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
++	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->ch_layout.nb_channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
+ 		m_converter.reset(new FFmpegAudioProcessor());
+ 		m_converter->SetCompatibleMode();
+ 		m_converter->SetInputSampleFormat(m_codec_ctx->sample_fmt);
+ 		m_converter->SetInputSampleRate(m_codec_ctx->sample_rate);
+-		m_converter->SetInputChannelLayout(m_codec_ctx->channel_layout);
++		m_converter->SetInputChannelLayout(&(m_codec_ctx->ch_layout));
+ 		m_converter->SetOutputSampleFormat(AV_SAMPLE_FMT_S16);
+ 		m_converter->SetOutputSampleRate(m_output_sample_rate);
+-		m_converter->SetOutputChannelLayout(av_get_default_channel_layout(m_output_channels));
++		m_converter->SetOutputChannelLayout(&output_channel_layout);
+ 		auto ret = m_converter->Init();
+ 		if (ret != 0) {
+ 			SetError("Could not create an audio converter instance", ret);
+@@ -203,10 +203,11 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		}
+ 	}
+
++	av_channel_layout_uninit(&output_channel_layout);
++
+ 	m_opened = true;
+-	m_finished = false;
+-	m_got_frame = 0;
+-	m_nb_packets = 0;
++	m_has_more_packets = true;
++	m_has_more_frames = true;
+ 	m_decode_error = 0;
+
+ 	return true;
+@@ -214,6 +215,7 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ inline void FFmpegAudioReader::Close() {
+ 	av_frame_free(&m_frame);
++	av_packet_free(&m_packet);
+
+ 	m_stream_index = -1;
+
+@@ -252,91 +254,98 @@ inline bool FFmpegAudioReader::Read(const int16_t **data, size_t *size) {
+ 		return false;
+ 	}
+
++	*data = nullptr;
++	*size = 0;
++
+ 	int ret;
++	bool needs_packet = false;
+ 	while (true) {
+-		while (m_packet.size <= 0) {
+-			av_packet_unref(&m_packet0);
+-			av_init_packet(&m_packet);
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			ret = av_read_frame(m_format_ctx, &m_packet);
++		while (needs_packet && m_packet->size == 0) {
++			ret = av_read_frame(m_format_ctx, m_packet);
+ 			if (ret < 0) {
+ 				if (ret == AVERROR_EOF) {
+-					m_finished = true;
++					needs_packet = false;
++					m_has_more_packets = false;
+ 					break;
+-				} else {
++				}
++				SetError("Error reading from the audio source", ret);
++				return false;
++			}
++			if (m_packet->stream_index == m_stream_index) {
++				needs_packet = false;
++			} else {
++				av_packet_unref(m_packet);
++			}
++		}
++
++		if (m_packet->size != 0) {
++			ret = avcodec_send_packet(m_codec_ctx, m_packet);
++			if (ret < 0) {
++				if (ret != AVERROR(EAGAIN)) {
+ 					SetError("Error reading from the audio source", ret);
+ 					return false;
+ 				}
+-			}
+-			m_packet0 = m_packet;
+-			if (m_packet.stream_index != m_stream_index) {
+-				m_packet.data = nullptr;
+-				m_packet.size = 0;
+ 			} else {
+-				m_nb_packets++;
++				av_packet_unref(m_packet);
+ 			}
+ 		}
+
+-		ret = avcodec_decode_audio4(m_codec_ctx, m_frame, &m_got_frame, &m_packet);
++		ret = avcodec_receive_frame(m_codec_ctx, m_frame);
+ 		if (ret < 0) {
+-			if (m_decode_error) {
+-				SetError("Error decoding audio frame", m_decode_error);
+-				return false;
++			if (ret == AVERROR_EOF) {
++				m_has_more_frames = false;
++			} else if (ret == AVERROR(EAGAIN)) {
++				if (m_has_more_packets) {
++					needs_packet = true;
++					continue;
++				} else {
++					m_has_more_frames = false;
++				}
+ 			}
+-			m_decode_error = ret;
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			continue;
++			SetError("Error decoding the audio source", ret);
++			return false;
+ 		}
+
+-		break;
+-	}
+-
+-	m_decode_error = 0;
+-
+-	const int decoded = std::min(ret, m_packet.size);
+-	m_packet.data += decoded;
+-	m_packet.size -= decoded;
+-
+-	if (m_got_frame) {
+-		if (m_converter) {
+-			if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
+-				int linsize;
+-				av_freep(&m_convert_buffer[0]);
+-				m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
+-				ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
+-				if (ret < 0) {
+-					SetError("Couldn't allocate audio converter buffer", ret);
++		if (m_frame->nb_samples > 0) {
++			if (m_converter) {
++				if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
++					int linsize;
++					av_freep(&m_convert_buffer[0]);
++					m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
++					ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->ch_layout.nb_channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
++					if (ret < 0) {
++						SetError("Couldn't allocate audio converter buffer", ret);
++						return false;
++					}
++				}
++				auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
++				if (nb_samples < 0) {
++					SetError("Couldn't convert audio", ret);
+ 					return false;
+ 				}
+-			}
+-			auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			}
+-			*data = (const int16_t *) m_convert_buffer[0];
+-			*size = nb_samples;
+-		} else {
+-			*data = (const int16_t *) m_frame->data[0];
+-			*size = m_frame->nb_samples;
+-		}
+-	} else {
+-		if (m_finished && m_converter) {
+-			auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			} else if (nb_samples > 0) {
+-				m_got_frame = 1;
+ 				*data = (const int16_t *) m_convert_buffer[0];
+ 				*size = nb_samples;
++			} else {
++				*data = (const int16_t *) m_frame->data[0];
++				*size = m_frame->nb_samples;
++			}
++		} else {
++			if (m_converter) {
++				if (IsFinished()) {
++					auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
++					if (nb_samples < 0) {
++						SetError("Couldn't convert audio", ret);
++						return false;
++					} else if (nb_samples > 0) {
++						*data = (const int16_t *) m_convert_buffer[0];
++						*size = nb_samples;
++					}
++				}
+ 			}
+ 		}
+-	}
+
+-	return true;
++		return true;
++	}
+ }
+
+ inline void FFmpegAudioReader::SetError(const char *message, int errnum) {
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index a2b517b..123e643 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -38,6 +38,12 @@ set(SRCS
+
+ if(BUILD_TOOLS)
+ 	set(SRCS ${SRCS} ../src/audio/ffmpeg_audio_reader_test.cpp)
++    include_directories(
++        ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}
++        ${AUDIO_PROCESSOR_INCLUDE_DIRS}
++    )
+ 	link_libraries(fpcalc_libs)
+ endif()
+
+-- 
+2.38.1
+
+
diff --git a/srcpkgs/chromaprint/template b/srcpkgs/chromaprint/template
index 7ef7838949f3a..1f7bbc70a22c8 100644
--- a/srcpkgs/chromaprint/template
+++ b/srcpkgs/chromaprint/template
@@ -1,7 +1,7 @@
 # Template file for 'chromaprint'
 pkgname=chromaprint
 version=1.5.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DBUILD_TOOLS=ON"
 make_check_target="check"

From c0f991a530435bc8e90dcbf403a90db8f3c5c281 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 026/115] chromium: revbump for ffmpeg-6.0

---
 .../patches/chromium-118-ffmpeg-4.4.patch     | 22 ---------
 srcpkgs/chromium/patches/ffmpeg5.patch        | 47 +++++++++++++++++++
 srcpkgs/chromium/template                     |  2 +-
 3 files changed, 48 insertions(+), 23 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/chromium-118-ffmpeg-4.4.patch
 create mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromium/patches/chromium-118-ffmpeg-4.4.patch b/srcpkgs/chromium/patches/chromium-118-ffmpeg-4.4.patch
deleted file mode 100644
index 556c734d4e02e..0000000000000
--- a/srcpkgs/chromium/patches/chromium-118-ffmpeg-4.4.patch
+++ /dev/null
@@ -1,22 +0,0 @@
-diff --git a/media/filters/ffmpeg_demuxer.cc b/media/filters/ffmpeg_demuxer.cc
-index ac4713b07268..492a9a37d096 100644
---- a/media/filters/ffmpeg_demuxer.cc
-+++ b/media/filters/ffmpeg_demuxer.cc
-@@ -443,7 +443,7 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
-     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
-                                      side_data.data(), side_data.size());
-   } else {
--    size_t side_data_size = 0;
-+    int side_data_size = 0;
-     uint8_t* side_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
- 
-@@ -504,7 +504,7 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
-                                        packet->size - data_offset);
-     }
- 
--    size_t skip_samples_size = 0;
-+    int skip_samples_size = 0;
-     const uint32_t* skip_samples_ptr =
-         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
-             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..24e2da38e34ca
--- /dev/null
+++ b/srcpkgs/chromium/patches/ffmpeg5.patch
@@ -0,0 +1,47 @@
+--- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
++++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
+@@ -92,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+-  if (stream->start_time != kNoFFmpegTimestamp)
++  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -1597,7 +1585,7 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+@@ -1618,7 +1606,7 @@
+     if (stream->type() != DemuxerStream::VIDEO)
+       continue;
+ 
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+ 
+     if (!stream->IsEnabled())
diff --git a/srcpkgs/chromium/template b/srcpkgs/chromium/template
index cc36911cd338d..c63eb330d1da8 100644
--- a/srcpkgs/chromium/template
+++ b/srcpkgs/chromium/template
@@ -2,7 +2,7 @@
 pkgname=chromium
 # See https://chromiumdash.appspot.com/releases?platform=Linux for the latest version
 version=118.0.5993.70
-revision=1
+revision=2
 archs="i686* x86_64* aarch64* armv7l*"
 hostmakedepends="
  $(vopt_if clang "clang lld llvm15")

From 9b996af29d9f26278e6e675ab1b8f3b3bae6c6ef Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 027/115] cmus: revbump for ffmpeg-6.0

---
 srcpkgs/cmus/patches/ffmpeg6.patch | 12 ++++++++++++
 srcpkgs/cmus/template              |  2 +-
 2 files changed, 13 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/cmus/patches/ffmpeg6.patch

diff --git a/srcpkgs/cmus/patches/ffmpeg6.patch b/srcpkgs/cmus/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..ffa95ab811101
--- /dev/null
+++ b/srcpkgs/cmus/patches/ffmpeg6.patch
@@ -0,0 +1,12 @@
+--- a/ip/ffmpeg.c
++++ b/ip/ffmpeg.c
+@@ -202,9 +202,6 @@ static int ffmpeg_open(struct input_plugin_data *ip_data)
+ 			break;
+ 		}
+ 
+-		if (codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+-			cc->flags |= AV_CODEC_FLAG_TRUNCATED;
+-
+ 		if (avcodec_open2(cc, codec, NULL) < 0) {
+ 			d_print("could not open codec: %d, %s\n", cc->codec_id, avcodec_get_name(cc->codec_id));
+ 			err = -IP_ERROR_UNSUPPORTED_FILE_TYPE;
diff --git a/srcpkgs/cmus/template b/srcpkgs/cmus/template
index dc8a5e5d434cd..f664076170960 100644
--- a/srcpkgs/cmus/template
+++ b/srcpkgs/cmus/template
@@ -1,7 +1,7 @@
 # Template file for 'cmus'
 pkgname=cmus
 version=2.10.0
-revision=1
+revision=2
 build_style=configure
 configure_args="prefix=/usr LD=$CC"
 hostmakedepends="pkg-config"

From c80688941318f5afa3df64b9e35f6bf071c5788b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 028/115] cyanrip: revbump for ffmpeg-6.0

---
 srcpkgs/cyanrip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cyanrip/template b/srcpkgs/cyanrip/template
index 9796e3461601a..5db30e020d17e 100644
--- a/srcpkgs/cyanrip/template
+++ b/srcpkgs/cyanrip/template
@@ -1,7 +1,7 @@
 # Template file for 'cyanrip'
 pkgname=cyanrip
 version=0.9.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config"
 makedepends="ffmpeg-devel libcdio-devel libcdio-paranoia-devel libcurl-devel libmusicbrainz5-devel"

From 9b9dcbdcd59e0c509e8cec75fad7d5866e169ddd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 029/115] deadbeef: revbump for ffmpeg4-4.4.3

---
 srcpkgs/deadbeef/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/deadbeef/template b/srcpkgs/deadbeef/template
index b664bb1b9bd9f..165b3c7b9cad8 100644
--- a/srcpkgs/deadbeef/template
+++ b/srcpkgs/deadbeef/template
@@ -1,14 +1,14 @@
 # Template file for 'deadbeef'
 pkgname=deadbeef
 version=1.8.8
-revision=1
+revision=2
 create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-oss --disable-lfm --disable-notify --disable-gtk2"
 hostmakedepends="automake libtool gettext gettext-devel intltool pkg-config
  yasm clang glib-devel"
 makedepends="
- alsa-lib-devel dbus-devel faad2-devel ffmpeg-devel gtk+3-devel imlib2-devel
+ alsa-lib-devel dbus-devel faad2-devel ffmpeg4-devel gtk+3-devel imlib2-devel
  jansson-devel libcddb-devel libcdio-devel libcurl-devel libflac-devel
  libmad-devel libpng-devel libsamplerate-devel libsndfile-devel libvorbis-devel
  libzip-devel mpg123-devel opusfile-devel pulseaudio-devel wavpack-devel"

From ed4b3b637ede448ed32b889193e4e85c1e22003a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 030/115] dolphin-emu: revbump for ffmpeg-6.0

---
 srcpkgs/dolphin-emu/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/dolphin-emu/template b/srcpkgs/dolphin-emu/template
index b4c8b64368a4b..070993aac31d2 100644
--- a/srcpkgs/dolphin-emu/template
+++ b/srcpkgs/dolphin-emu/template
@@ -1,7 +1,7 @@
 # Template file for 'dolphin-emu'
 pkgname=dolphin-emu
 version=5.0.19368
-revision=1
+revision=2
 _dolphin_commit=dadbeb4bae7e7fa23af2b46e0add4143094dc107
 _mgba_commit=44e074a15e9651481f7f652ac006a7c9d58cbeb9
 _googletest_commit=be03d00f5f0cc3a997d1a368bee8a1fe93651f48

From 14df81c4c082e9ca3c8ad3f1ee8d6fe05c10a681 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 031/115] droidcam-obs-plugin: revbump for ffmpeg-6.0

---
 srcpkgs/droidcam-obs-plugin/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam-obs-plugin/template b/srcpkgs/droidcam-obs-plugin/template
index fc9c9bf6b9d54..fb0480754df4d 100644
--- a/srcpkgs/droidcam-obs-plugin/template
+++ b/srcpkgs/droidcam-obs-plugin/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam-obs-plugin'
 pkgname=droidcam-obs-plugin
 version=2.0.1
-revision=1
+revision=2
 build_style=gnu-makefile
 make_use_env=yes
 make_build_args="ALLOW_STATIC=no"

From f7204230a66be2c21d09ad87d0364a965520d0f7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 032/115] droidcam: revbump for ffmpeg-6.0

---
 srcpkgs/droidcam/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam/template b/srcpkgs/droidcam/template
index 1c3f1b8b1fc67..32a9220b79a4d 100644
--- a/srcpkgs/droidcam/template
+++ b/srcpkgs/droidcam/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam'
 pkgname=droidcam
 version=1.8.2
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="USBMUXD=-lusbmuxd-2.0 JPEG=-lturbojpeg"
 hostmakedepends="pkg-config"

From 6096a42403c63e64c85b9ba1f5babc845003ef45 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 033/115] ffmpegthumbnailer: revbump for ffmpeg-6.0

---
 .../ffmpegthumbnailer/patches/ffmpeg6.patch   | 202 ++++++++++++++++++
 srcpkgs/ffmpegthumbnailer/template            |   6 +-
 2 files changed, 205 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch

diff --git a/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..363ff35a28419
--- /dev/null
+++ b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
@@ -0,0 +1,202 @@
+--- a/libffmpegthumbnailer/moviedecoder.cpp	2017-11-21 14:06:57.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.cpp	2023-05-05 13:14:47.946560668 -0400
+@@ -41,11 +41,6 @@
+ namespace ffmpegthumbnailer
+ {
+ 
+-struct SilenceLogLevel
+-{
+-    SilenceLogLevel() { av_log_set_level(AV_LOG_QUIET); }
+-};
+-
+ MovieDecoder::MovieDecoder(AVFormatContext* pavContext)
+ : m_VideoStream(-1)
+ , m_pFormatContext(pavContext)
+@@ -70,8 +65,6 @@
+ 
+ void MovieDecoder::initialize(const string& filename, bool preferEmbeddedMetadata)
+ {
+-    av_register_all();
+-    avcodec_register_all();
+     avformat_network_init();
+ 
+     string inputFile = filename == "-" ? "pipe:" : filename;
+@@ -97,8 +90,7 @@
+ {
+     if (m_pVideoCodecContext)
+     {
+-        avcodec_close(m_pVideoCodecContext);
+-        m_pVideoCodecContext = nullptr;
++        avcodec_free_context(&m_pVideoCodecContext);
+     }
+ 
+     if ((!m_FormatContextWasGiven) && m_pFormatContext)
+@@ -152,10 +144,10 @@
+     for (unsigned int i = 0; i < m_pFormatContext->nb_streams; ++i)
+     {
+         AVStream *stream = m_pFormatContext->streams[i];
+-        auto ctx = m_pFormatContext->streams[i]->codec;
+-        if (ctx->codec_type == AVMEDIA_TYPE_VIDEO)
++        auto par = m_pFormatContext->streams[i]->codecpar;
++        if (par->codec_type == AVMEDIA_TYPE_VIDEO)
+         {
+-            if (!preferEmbeddedMetadata || !isStillImageCodec(ctx->codec_id))
++            if (!preferEmbeddedMetadata || !isStillImageCodec(par->codec_id))
+             {
+                 videoStreams.push_back(i);
+                 continue;
+@@ -203,8 +195,7 @@
+     }
+ 
+     m_pVideoStream = m_pFormatContext->streams[m_VideoStream];
+-    m_pVideoCodecContext = m_pVideoStream->codec;
+-    m_pVideoCodec = avcodec_find_decoder(m_pVideoCodecContext->codec_id);
++    m_pVideoCodec = avcodec_find_decoder(m_pVideoStream->codecpar->codec_id);
+ 
+     if (m_pVideoCodec == nullptr)
+     {
+@@ -214,6 +205,20 @@
+         throw logic_error("Video Codec not found");
+     }
+ 
++    m_pVideoCodecContext = avcodec_alloc_context3(m_pVideoCodec);
++
++    if (m_pVideoCodecContext == nullptr)
++    {
++        destroy();
++        throw logic_error("Could not allocate video codec context");
++    }
++
++    if (avcodec_parameters_to_context(m_pVideoCodecContext, m_pVideoStream->codecpar) < 0)
++    {
++        destroy();
++        throw logic_error("Could not configure video codec context");
++    }
++
+     m_pVideoCodecContext->workaround_bugs = 1;
+ 
+     if (avcodec_open2(m_pVideoCodecContext, m_pVideoCodec, nullptr) < 0)
+@@ -386,13 +391,6 @@
+ 
+ void MovieDecoder::initializeFilterGraph(const AVRational& timeBase, const std::string& size, bool maintainAspectRatio)
+ {
+-    static const AVPixelFormat pixelFormats[] = { AV_PIX_FMT_RGB24, AV_PIX_FMT_NONE };
+-
+-    auto del = [] (AVBufferSinkParams* p) { av_freep(p); };
+-    std::unique_ptr<AVBufferSinkParams, decltype(del)> buffersinkParams(av_buffersink_params_alloc(), del);
+-
+-    avfilter_register_all();
+-
+     m_pFilterGraph = avfilter_graph_alloc();
+     assert(m_pFilterGraph);
+ 
+@@ -404,10 +402,8 @@
+ 
+     checkRc(avfilter_graph_create_filter(&m_pFilterSource, avfilter_get_by_name("buffer"), "thumb_buffer", ss.str().c_str(), nullptr, m_pFilterGraph),
+             "Failed to create filter source");
+-    buffersinkParams->pixel_fmts = pixelFormats;
+-    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, buffersinkParams.get(), m_pFilterGraph),
++    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, nullptr, m_pFilterGraph),
+             "Failed to create filter sink");
+-    buffersinkParams.release();
+ 
+     AVFilterContext* yadifFilter = nullptr;
+     if (m_pFrame->interlaced_frame != 0)
+@@ -500,15 +496,15 @@
+     }
+ 
+     checkRc(av_seek_frame(m_pFormatContext, -1, timestamp, 0), "Seeking in video failed");
+-    avcodec_flush_buffers(m_pFormatContext->streams[m_VideoStream]->codec);
++    avcodec_flush_buffers(m_pVideoCodecContext);
+ 
+     int keyFrameAttempts = 0;
+-    bool gotFrame = 0;
++    bool gotFrame;
+ 
+     do
+     {
+         int count = 0;
+-        gotFrame = 0;
++        gotFrame = false;
+ 
+         while (!gotFrame && count < 20)
+         {
+@@ -552,17 +548,33 @@
+         return false;
+     }
+ 
+-    av_frame_unref(m_pFrame);
+-
+-    int frameFinished;
++    int rc = avcodec_send_packet(m_pVideoCodecContext, m_pPacket);
++    if(rc == AVERROR(EAGAIN))
++    {
++        rc = 0;
++    }
+ 
+-    int bytesDecoded = avcodec_decode_video2(m_pVideoCodecContext, m_pFrame, &frameFinished, m_pPacket);
+-    if (bytesDecoded < 0)
++    if(rc == AVERROR_EOF)
++    {
++        return false;
++    }
++    else if(rc < 0)
+     {
+-        throw logic_error("Failed to decode video frame: bytesDecoded < 0");
++        throw logic_error("Failed to decode video frame: avcodec_send_packet() < 0");
+     }
+ 
+-    return frameFinished > 0;
++    rc = avcodec_receive_frame(m_pVideoCodecContext, m_pFrame);
++    switch(rc)
++    {
++        case 0:
++            return true;
++
++        case AVERROR(EAGAIN):
++            return false;
++
++        default:
++            throw logic_error("Failed to decode video frame: avcodec_receive_frame() < 0");
++    }
+ }
+ 
+ bool MovieDecoder::getVideoPacket()
+@@ -570,8 +582,6 @@
+     bool framesAvailable = true;
+     bool frameDecoded = false;
+ 
+-    int attempts = 0;
+-
+     if (m_pPacket)
+     {
+         av_packet_unref(m_pPacket);
+@@ -580,6 +590,7 @@
+ 
+     m_pPacket = new AVPacket();
+ 
++
+     while (framesAvailable && !frameDecoded)
+     {
+         framesAvailable = av_read_frame(m_pFormatContext, m_pPacket) >= 0;
+@@ -644,7 +655,7 @@
+ 
+ int32_t MovieDecoder::getStreamRotation()
+ {
+-    int32_t* matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
++    auto matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
+     if (matrix)
+     {
+         auto angle = lround(av_display_rotation_get(matrix));
+
+--- a/libffmpegthumbnailer/moviedecoder.h	2017-11-12 04:23:38.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.h	2023-05-05 13:26:07.095529911 -0400
+@@ -78,7 +78,7 @@
+     int                     m_VideoStream;
+     AVFormatContext*        m_pFormatContext;
+     AVCodecContext*         m_pVideoCodecContext;
+-    AVCodec*                m_pVideoCodec;
++    const AVCodec*          m_pVideoCodec;
+     AVFilterGraph*          m_pFilterGraph;
+     AVFilterContext*        m_pFilterSource;
+     AVFilterContext*        m_pFilterSink;
diff --git a/srcpkgs/ffmpegthumbnailer/template b/srcpkgs/ffmpegthumbnailer/template
index 039eea7622b39..35d546018d12a 100644
--- a/srcpkgs/ffmpegthumbnailer/template
+++ b/srcpkgs/ffmpegthumbnailer/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbnailer'
 pkgname=ffmpegthumbnailer
 version=2.2.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libpng-devel libjpeg-turbo-devel ffmpeg-devel"
@@ -9,8 +9,8 @@ depends="ffmpeg"
 short_desc="Lightweight video thumbnailer"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
-homepage="https://github.com/dirkvdb/${pkgname}"
-distfiles="${homepage}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
+homepage="https://github.com/dirkvdb"
+distfiles="${homepage}/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
 checksum=1cb24059c38223f657b300c84dd80491b7040d4b69471c4fea69be862bc99b5b
 
 post_install() {

From d6f86412193fc77fb0d903abf0800e71b267fe0b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 034/115] ffmpegthumbs: revbump for ffmpeg-6.0

---
 srcpkgs/ffmpegthumbs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ffmpegthumbs/template b/srcpkgs/ffmpegthumbs/template
index 5f0b9414dadaf..11b88193528f4 100644
--- a/srcpkgs/ffmpegthumbs/template
+++ b/srcpkgs/ffmpegthumbs/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbs'
 pkgname=ffmpegthumbs
 version=22.12.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules kcoreaddons kconfig-devel
  pkg-config qt5-host-tools qt5-qmake gettext"

From 30237404afd515d32b1ead3407bf9d7e511ba598 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 035/115] ffms2: revbump for ffmpeg-6.0

---
 srcpkgs/ffms2/patches/ffmpeg5.patch | 424 ++++++++++++++++++++++++++++
 srcpkgs/ffms2/template              |   2 +-
 2 files changed, 425 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ffms2/patches/ffmpeg5.patch

diff --git a/srcpkgs/ffms2/patches/ffmpeg5.patch b/srcpkgs/ffms2/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..1479fabcafcb4
--- /dev/null
+++ b/srcpkgs/ffms2/patches/ffmpeg5.patch
@@ -0,0 +1,424 @@
+From 45673149e9a2f5586855ad472e3059084eaa36b1 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:41:21 +0100
+Subject: [PATCH] Use auto for AVCodec
+
+The geniuses over at FFmpeg decided to constify this API, so old
+versions of the library will return AVCodec *, while new versions
+of the libary will return const AVCodec *, which, in C++, are not
+OK to convert between.
+
+Rather than use some macro hell in ffmscompat.h, we can work around
+this by using auto.
+
+Gross.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 2 +-
+ src/core/indexing.cpp    | 6 +++---
+ src/core/videosource.cpp | 2 +-
+ 3 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index e4ce97c..ac09666 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -469,7 +469,7 @@ void FFMS_AudioSource::OpenFile() {
+ 
+     LAVFOpenFile(SourceFile.c_str(), FormatContext, TrackNumber);
+ 
+-    AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
++    auto *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
+     if (Codec == nullptr)
+         throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+             "Audio codec not found");
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index e547c5a..59fb4e8 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -384,7 +384,7 @@ FFMS_TrackType FFMS_Indexer::GetTrackType(int Track) {
+ }
+ 
+ const char *FFMS_Indexer::GetTrackCodec(int Track) {
+-    AVCodec *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
++    auto *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
+     return codec ? codec->name : nullptr;
+ }
+ 
+@@ -402,7 +402,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             UseDTS);
+ 
+         if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            AVCodec *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (!VideoCodec) {
+                 FormatContext->streams[i]->discard = AVDISCARD_ALL;
+                 IndexMask.erase(i);
+@@ -433,7 +433,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 IndexMask.insert(i);
+             }
+         } else if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+-            AVCodec *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (AudioCodec == nullptr)
+                 throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_UNSUPPORTED,
+                     "Audio codec not found");
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index b889970..8956c22 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -171,7 +171,7 @@ FFMS_VideoSource::FFMS_VideoSource(const char *SourceFile, FFMS_Index &Index, in
+ 
+         LAVFOpenFile(SourceFile, FormatContext, VideoTrack);
+ 
+-        AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
++        auto *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
+         if (Codec == nullptr)
+             throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+                 "Video codec not found");
+-- 
+2.40.0
+
+From 96cbf38ea9381829a1314f432a2c60495dcefaad Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:12:41 +0100
+Subject: [PATCH] all: Update AVPacket API usage
+
+AVPackets must all be on the heap now, since it is no longer
+part of the libav* ABI.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 16 ++++++----
+ src/core/indexing.cpp    | 63 ++++++++++++++++++++++------------------
+ src/core/indexing.h      |  4 +--
+ src/core/utils.cpp       |  6 ----
+ src/core/utils.h         |  1 -
+ src/core/videosource.cpp | 30 ++++++++++---------
+ 6 files changed, 64 insertions(+), 56 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index 37cf9ae..e4ce97c 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -285,10 +285,15 @@ FFMS_AudioSource::AudioBlock *FFMS_AudioSource::CacheBlock(CacheIterator &pos) {
+ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     CurrentFrame = &Frames[PacketNumber];
+ 
+-    AVPacket Packet;
+-    if (!ReadPacket(&Packet))
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++    if (!ReadPacket(Packet)) {
++        av_packet_free(&Packet);
+         throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_UNKNOWN,
+             "ReadPacket unexpectedly failed to read a packet");
++    }
+ 
+     // ReadPacket may have changed the packet number
+     CurrentFrame = &Frames[PacketNumber];
+@@ -297,8 +302,9 @@ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     int NumberOfSamples = 0;
+     AudioBlock *CachedBlock = nullptr;
+     
+-    int Ret = avcodec_send_packet(CodecContext, &Packet);
+-    av_packet_unref(&Packet);
++    int Ret = avcodec_send_packet(CodecContext, Packet);
++    av_packet_unref(Packet);
++    av_packet_free(&Packet);
+ 
+     av_frame_unref(DecodeFrame);
+     Ret = avcodec_receive_frame(CodecContext, DecodeFrame);
+@@ -513,8 +519,6 @@ void FFMS_AudioSource::Seek() {
+ }
+ 
+ bool FFMS_AudioSource::ReadPacket(AVPacket *Packet) {
+-    InitNullPacket(*Packet);
+-
+     while (av_read_frame(FormatContext, Packet) >= 0) {
+         if (Packet->stream_index == TrackNumber) {
+             // Required because not all audio packets, especially in ogg, have a pts. Use the previous valid packet's pts instead.
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index 23fb95b..e547c5a 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -320,7 +320,7 @@ void FFMS_Indexer::CheckAudioProperties(int Track, AVCodecContext *Context) {
+     }
+ }
+ 
+-void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict,
++void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict,
+                                     int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct) {
+     if (VideoContext.Parser) {
+         uint8_t *OB;
+@@ -330,8 +330,8 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+         av_parser_parse2(VideoContext.Parser,
+             VideoContext.CodecContext,
+             &OB, &OBSize,
+-            pkt.data, pkt.size,
+-            pkt.pts, pkt.dts, pkt.pos);
++            pkt->data, pkt->size,
++            pkt->pts, pkt->dts, pkt->pos);
+ 
+         // H.264 (PAFF) and HEVC may have one field per packet, so we need to track
+         // when we have a full or half frame available, and mark one of them as
+@@ -351,15 +351,15 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+ 
+         *RepeatPict = VideoContext.Parser->repeat_pict;
+         *FrameType = VideoContext.Parser->pict_type;
+-        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt.flags & AV_PKT_FLAG_DISCARD));
++        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt->flags & AV_PKT_FLAG_DISCARD));
+     } else {
+-        *Invisible = !!(pkt.flags & AV_PKT_FLAG_DISCARD);
++        *Invisible = !!(pkt->flags & AV_PKT_FLAG_DISCARD);
+     }
+ 
+     if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP8)
+-        ParseVP8(pkt.data[0], Invisible, FrameType);
++        ParseVP8(pkt->data[0], Invisible, FrameType);
+     else if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP9)
+-        ParseVP9(pkt.data[0], Invisible, FrameType);
++        ParseVP9(pkt->data[0], Invisible, FrameType);
+ }
+ 
+ void FFMS_Indexer::Free() {
+@@ -458,32 +458,36 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+         }
+     }
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
+     std::vector<int64_t> LastValidTS(FormatContext->nb_streams, AV_NOPTS_VALUE);
+ 
+     int64_t filesize = avio_size(FormatContext->pb);
+     enum AVPictureStructure LastPicStruct = AV_PICTURE_STRUCTURE_UNKNOWN;
+-    while (av_read_frame(FormatContext, &Packet) >= 0) {
++    while (av_read_frame(FormatContext, Packet) >= 0) {
+         // Update progress
+         // FormatContext->pb can apparently be NULL when opening images.
+         if (IC && FormatContext->pb) {
+-            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate))
++            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate)) {
++                av_packet_free(&Packet);
+                 throw FFMS_Exception(FFMS_ERROR_CANCELLED, FFMS_ERROR_USER,
+                     "Cancelled by user");
++            }
+         }
+-        if (!IndexMask.count(Packet.stream_index)) {
+-            av_packet_unref(&Packet);
++        if (!IndexMask.count(Packet->stream_index)) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+-        int Track = Packet.stream_index;
++        int Track = Packet->stream_index;
+         FFMS_Track &TrackInfo = (*TrackIndices)[Track];
+-        bool KeyFrame = !!(Packet.flags & AV_PKT_FLAG_KEY);
++        bool KeyFrame = !!(Packet->flags & AV_PKT_FLAG_KEY);
+         ReadTS(Packet, LastValidTS[Track], (*TrackIndices)[Track].UseDTS);
+ 
+         if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            int64_t PTS = TrackInfo.UseDTS ? Packet.dts : Packet.pts;
++            int64_t PTS = TrackInfo.UseDTS ? Packet->dts : Packet->pts;
+             if (PTS == AV_NOPTS_VALUE) {
+                 // VPx alt-refs are output as packets which lack timestmps or durations, since
+                 // they are invisible. Currently, the timestamp mangling code in libavformat
+@@ -495,9 +499,11 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 // FFMS2 currently sorts packets by PTS, which will break decoding, otherwise.
+                 bool HasAltRefs = (FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP8 ||
+                                    FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP9);
+-                if (Packet.duration == 0 && !HasAltRefs)
++                if (Packet->duration == 0 && !HasAltRefs) {
++                    av_packet_free(&Packet);
+                     throw FFMS_Exception(FFMS_ERROR_INDEXING, FFMS_ERROR_PARSER,
+                         "Invalid packet pts, dts, and duration");
++                }
+ 
+                 if (TrackInfo.empty())
+                     PTS = 0;
+@@ -513,7 +519,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             ParseVideoPacket(AVContexts[Track], Packet, &RepeatPict, &FrameType, &Invisible, &LastPicStruct);
+ 
+             TrackInfo.AddVideoFrame(PTS, RepeatPict, KeyFrame,
+-                FrameType, Packet.pos, Invisible);
++                FrameType, Packet->pos, Invisible);
+         } else if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+             // For video seeking timestamps are used only if all packets have
+             // timestamps, while for audio they're used if any have timestamps,
+@@ -522,28 +528,29 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 TrackInfo.HasTS = true;
+ 
+             int64_t StartSample = AVContexts[Track].CurrentSample;
+-            uint32_t SampleCount = IndexAudioPacket(Track, &Packet, AVContexts[Track], *TrackIndices);
++            uint32_t SampleCount = IndexAudioPacket(Track, Packet, AVContexts[Track], *TrackIndices);
+             TrackInfo.SampleRate = AVContexts[Track].CodecContext->sample_rate;
+ 
+             TrackInfo.AddAudioFrame(LastValidTS[Track],
+-                StartSample, SampleCount, KeyFrame, Packet.pos, Packet.flags & AV_PKT_FLAG_DISCARD);
++                StartSample, SampleCount, KeyFrame, Packet->pos, Packet->flags & AV_PKT_FLAG_DISCARD);
+         }
+ 
+-        if (!(Packet.flags & AV_PKT_FLAG_DISCARD))
+-            TrackInfo.LastDuration = Packet.duration;
++        if (!(Packet->flags & AV_PKT_FLAG_DISCARD))
++            TrackInfo.LastDuration = Packet->duration;
+ 
+-        av_packet_unref(&Packet);
++        av_packet_unref(Packet);
+     }
++    av_packet_free(&Packet);
+ 
+     TrackIndices->Finalize(AVContexts, FormatContext->iformat->name);
+     return TrackIndices.release();
+ }
+ 
+-void FFMS_Indexer::ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS) {
+-    if (!UseDTS && Packet.pts != AV_NOPTS_VALUE)
+-        TS = Packet.pts;
++void FFMS_Indexer::ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS) {
++    if (!UseDTS && Packet->pts != AV_NOPTS_VALUE)
++        TS = Packet->pts;
+     if (TS == AV_NOPTS_VALUE)
+         UseDTS = true;
+-    if (UseDTS && Packet.dts != AV_NOPTS_VALUE)
+-        TS = Packet.dts;
++    if (UseDTS && Packet->dts != AV_NOPTS_VALUE)
++        TS = Packet->dts;
+ }
+diff --git a/src/core/indexing.h b/src/core/indexing.h
+index 3cfc3c3..5c06868 100644
+--- a/src/core/indexing.h
++++ b/src/core/indexing.h
+@@ -80,10 +80,10 @@ private:
+     int64_t Filesize;
+     uint8_t Digest[20];
+ 
+-    void ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS);
++    void ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS);
+     void CheckAudioProperties(int Track, AVCodecContext *Context);
+     uint32_t IndexAudioPacket(int Track, AVPacket *Packet, SharedAVContext &Context, FFMS_Index &TrackIndices);
+-    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
++    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
+     void Free();
+ public:
+     FFMS_Indexer(const char *Filename);
+diff --git a/src/core/utils.cpp b/src/core/utils.cpp
+index ce67533..8a2e997 100644
+--- a/src/core/utils.cpp
++++ b/src/core/utils.cpp
+@@ -62,12 +62,6 @@ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo) {
+     }
+ }
+ 
+-void InitNullPacket(AVPacket &pkt) {
+-    av_init_packet(&pkt);
+-    pkt.data = nullptr;
+-    pkt.size = 0;
+-}
+-
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames) {
+     AP.SampleFormat = static_cast<FFMS_SampleFormat>(av_get_packed_sample_fmt(CTX->sample_fmt));
+     AP.BitsPerSample = av_get_bytes_per_sample(CTX->sample_fmt) * 8;
+diff --git a/src/core/utils.h b/src/core/utils.h
+index 9819dc7..003ab79 100644
+--- a/src/core/utils.h
++++ b/src/core/utils.h
+@@ -58,7 +58,6 @@ std::unique_ptr<T> make_unique(Args&&... args) {
+ }
+ 
+ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo);
+-void InitNullPacket(AVPacket &pkt);
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames);
+ 
+ void LAVFOpenFile(const char *SourceFile, AVFormatContext *&FormatContext, int Track);
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index 06bd161..b889970 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -673,30 +673,34 @@ void FFMS_VideoSource::DecodeNextFrame(int64_t &AStartTime, int64_t &Pos) {
+     if (HasPendingDelayedFrames())
+         return;
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
+-
+-    while (ReadFrame(&Packet) >= 0) {
+-        if (Packet.stream_index != VideoTrack) {
+-            av_packet_unref(&Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++
++    while (ReadFrame(Packet) >= 0) {
++        if (Packet->stream_index != VideoTrack) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+         if (AStartTime < 0)
+-            AStartTime = Frames.UseDTS ? Packet.dts : Packet.pts;
++            AStartTime = Frames.UseDTS ? Packet->dts : Packet->pts;
+ 
+         if (Pos < 0)
+-            Pos = Packet.pos;
++            Pos = Packet->pos;
+ 
+-        bool FrameFinished = DecodePacket(&Packet);
+-        av_packet_unref(&Packet);
+-        if (FrameFinished)
++        bool FrameFinished = DecodePacket(Packet);
++        av_packet_unref(Packet);
++        if (FrameFinished) {
++            av_packet_free(&Packet);
+             return;
++        }
+     }
+ 
+     // Flush final frames
+-    InitNullPacket(Packet);
+-    DecodePacket(&Packet);
++    DecodePacket(Packet);
++    av_packet_free(&Packet);
+ }
+ 
+ bool FFMS_VideoSource::SeekTo(int n, int SeekOffset) {
+-- 
+2.40.0
+
+From bf9e03e9e08534c024e5a744a6437c4aac160201 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:20:47 +0100
+Subject: [PATCH 2/3] configure: Remove deprecated API use
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ configure.ac | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index b35ef80bc..d19714d0f 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -102,10 +102,10 @@ CFLAGS="$_CFLAGS $FFMPEG_CFLAGS"
+
+ AC_DEFUN([TEST_FFMPEG],
+          [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+-            #include <libavcodec/avcodec.h>
++            #include <libavformat/avformat.h>
+             #include <libswscale/swscale.h>
+             ]],[[
+-                avcodec_register_all();
++                avformat_network_init();
+                 swscale_version();
+             ]])], [eval $1=yes], [eval $1=no])
+         ])
+
diff --git a/srcpkgs/ffms2/template b/srcpkgs/ffms2/template
index 365f64d10cbab..1641ecf43be5b 100644
--- a/srcpkgs/ffms2/template
+++ b/srcpkgs/ffms2/template
@@ -1,7 +1,7 @@
 # Template file for 'ffms2'
 pkgname=ffms2
 version=2.40
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-shared --disable-static"
 hostmakedepends="pkg-config autoconf automake libtool"

From bacc68f36559a9615846ec3e9acaa44fe27a653c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 036/115] freerdp: revbump for ffmpeg-6.0

---
 .../freerdp/patches/ffmpeg6_aa2cb9aa.patch    | 42 +++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100644 srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch

diff --git a/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
new file mode 100644
index 0000000000000..a4324da3a8822
--- /dev/null
+++ b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
@@ -0,0 +1,42 @@
+From aa2cb9aa5ff5562433598ba168a466e0752bca0e Mon Sep 17 00:00:00 2001
+From: akallabeth <akallabeth@posteo.net>
+Date: Tue, 14 Feb 2023 07:48:54 +0100
+Subject: [PATCH] Fixed #8686: Update h264 to use new FFMPEG API
+
+---
+ channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c | 2 ++
+ libfreerdp/codec/h264_ffmpeg.c            | 2 ++
+ 2 files changed, 4 insertions(+)
+
+diff --git a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+index 339462d865f..beea80b7a1e 100644
+--- a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
++++ b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+@@ -239,8 +239,10 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYP
+ 		}
+ 	}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 	if (mdecoder->codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		mdecoder->codec_context->flags |= AV_CODEC_FLAG_TRUNCATED;
++#endif
+ 
+ 	return TRUE;
+ }
+diff --git a/libfreerdp/codec/h264_ffmpeg.c b/libfreerdp/codec/h264_ffmpeg.c
+index 8a23db2473c..896a333019b 100644
+--- a/libfreerdp/codec/h264_ffmpeg.c
++++ b/libfreerdp/codec/h264_ffmpeg.c
+@@ -615,10 +615,12 @@ static BOOL libavcodec_init(H264_CONTEXT* h264)
+ 			goto EXCEPTION;
+ 		}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 		if (sys->codecDecoder->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		{
+ 			sys->codecDecoderContext->flags |= AV_CODEC_FLAG_TRUNCATED;
+ 		}
++#endif
+ 
+ #ifdef WITH_VAAPI
+ 

From 9e81ddf892b36580ad52f262fb49d77bd200cbe0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 037/115] gerbera: revbump for ffmpeg-6.0

---
 srcpkgs/gerbera/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gerbera/template b/srcpkgs/gerbera/template
index ae14f35c767c0..2dc0ac0ce03b5 100644
--- a/srcpkgs/gerbera/template
+++ b/srcpkgs/gerbera/template
@@ -1,7 +1,7 @@
 # Template file for 'gerbera'
 pkgname=gerbera
 version=1.12.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_SYSTEMD=0 -DWITH_AVCODEC=1"
 hostmakedepends="pkg-config"

From 5a6860acdece0385661759bf0c3b219c0b78da8c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 038/115] goldendict: revbump for ffmpeg-6.0

---
 srcpkgs/goldendict/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/goldendict/template b/srcpkgs/goldendict/template
index f4a05759f693d..97f44347b03a6 100644
--- a/srcpkgs/goldendict/template
+++ b/srcpkgs/goldendict/template
@@ -1,7 +1,7 @@
 # Template file for 'goldendict'
 pkgname=goldendict
 version=1.5.0
-revision=1
+revision=2
 build_style=qmake
 configure_args="CONFIG+=zim_support goldendict.pro"
 hostmakedepends="qt5-qmake pkg-config qt5-host-tools"
@@ -10,7 +10,7 @@ makedepends="tiff-devel qt5-devel libvorbis-devel zlib-devel
  qt5-webkit-devel lzo-devel bzip2-devel libao-devel qt5-svg-devel
  libeb-devel qt5-x11extras-devel ffmpeg-devel liblzma-devel
  qt5-multimedia-devel"
-short_desc="A feature-rich dictionary lookup program"
+short_desc="Feature-rich dictionary lookup program"
 maintainer="John <me@johnnynator.dev>"
 license="GPL-3.0-or-later"
 homepage="http://goldendict.org/"

From d4a282ad3526e89522f459887bf50cc996142f38 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 039/115] gst-libav: revbump for ffmpeg-6.0

---
 srcpkgs/gst-libav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index 37485f6f6a9e8..f610e966f23cd 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.22.5
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"

From 2f3f560b1f86926c1d31b7a273130551a5f25303 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 040/115] gst-rtsp-server: revbump for ffmpeg-6.0

---
 srcpkgs/gst-rtsp-server/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index f266f4777b3ea..011444eb26739 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
 version=1.22.5
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="glib-devel gst-plugins-bad1-devel gobject-introspection

From 7b2faa111e092ab295cae8211a78c769abe02057 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 041/115] guvcview: update to 2.0.8.

---
 srcpkgs/guvcview/patches/fix-include.patch | 10 ++++++++++
 srcpkgs/guvcview/template                  |  5 ++---
 2 files changed, 12 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/guvcview/patches/fix-include.patch

diff --git a/srcpkgs/guvcview/patches/fix-include.patch b/srcpkgs/guvcview/patches/fix-include.patch
new file mode 100644
index 0000000000000..503c2af3b78c1
--- /dev/null
+++ b/srcpkgs/guvcview/patches/fix-include.patch
@@ -0,0 +1,10 @@
+--- a/guvcview/guvcview.c
++++ b/guvcview/guvcview.c
+@@ -28,6 +28,7 @@
+ #include <sys/stat.h>
+ #include <sys/resource.h>
+ #include <errno.h>
++#include <locale.h>
+ 
+ #include "gview.h"
+ #include "gviewv4l2core.h"
diff --git a/srcpkgs/guvcview/template b/srcpkgs/guvcview/template
index 345cf6006f246..86a7fd619612c 100644
--- a/srcpkgs/guvcview/template
+++ b/srcpkgs/guvcview/template
@@ -1,8 +1,7 @@
 # Template file for 'guvcview'
 pkgname=guvcview
-version=2.0.7
+version=2.0.8
 revision=1
-create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-static --disable-debian-menu"
 hostmakedepends="pkg-config intltool autoconf automake libtool glib-devel"
@@ -14,7 +13,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="http://guvcview.sourceforge.net/"
 distfiles="${SOURCEFORGE_SITE}/${pkgname}/${pkgname}-src-${version}.tar.bz2"
-checksum=f47d51fbd06e44eeaa1a82f4a153c927527c90d94514197a70b2956028cc8ad4
+checksum=a21f4e448286666cf27bafef5290cc953a0a1796b752e5bbe521266dc1230c81
 
 post_patch() {
 	sed '31a#include <locale.h>' -i  guvcview/guvcview.c

From 918285c628fbdde8f3c82ab8cfbdf9eb0ca6381a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 042/115] handbrake: update to 1.6.1

---
 .../patches/fix-missing-x265-link-flag.patch    | 11 ++++++-----
 .../handbrake/patches/libhb-vpl-include.patch   | 15 +++++++++++++++
 srcpkgs/handbrake/template                      | 17 ++++++++++-------
 3 files changed, 31 insertions(+), 12 deletions(-)
 create mode 100644 srcpkgs/handbrake/patches/libhb-vpl-include.patch

diff --git a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
index 26db03867a0c8..d6bb2eda627a3 100644
--- a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
+++ b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
@@ -1,14 +1,15 @@
 --- a/gtk/configure.ac
 +++ b/gtk/configure.ac
 @@ -203,7 +203,7 @@
- 
+
  AM_CONDITIONAL([MINGW], [test "x$mingw_flag" = "xyes"])
- 
--HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg"
-+HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -ldl"
+
+-HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc"
++HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc -ldl"
  HB_CPPFLAGS="$HB_CPPFLAGS $HBINC"
- 
+
  PKG_CHECK_MODULES([x264], [x264], sys_x264=yes, sys_x264=no)
+
 --- a/test/module.defs
 +++ b/test/module.defs
 @@ -69,6 +69,9 @@
diff --git a/srcpkgs/handbrake/patches/libhb-vpl-include.patch b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
new file mode 100644
index 0000000000000..298f9f4ab28f2
--- /dev/null
+++ b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
@@ -0,0 +1,15 @@
+--- a/libhb/module.defs	2023-01-22 11:36:49.000000000 -0500
++++ b/libhb/module.defs	2023-04-03 22:37:52.395467010 -0400
+@@ -46,11 +46,7 @@
+ LIBHB.GCC.I += $(LIBHB.build/) $(CONTRIB.build/)include
+ 
+ ifeq (1,$(FEATURE.qsv))
+-    ifeq ($(HOST.system),freebsd))
+-        LIBHB.GCC.I += $(LOCALBASE)/include/vpl
+-    else
+-        LIBHB.GCC.I += $(CONTRIB.build/)include/vpl
+-    endif
++    LIBHB.GCC.I += /usr/include/vpl
+ endif
+ 
+ ifneq (,$(filter $(HOST.system),freebsd netbsd openbsd))
diff --git a/srcpkgs/handbrake/template b/srcpkgs/handbrake/template
index ca5e4571e49c3..c32cb1bfa31f4 100644
--- a/srcpkgs/handbrake/template
+++ b/srcpkgs/handbrake/template
@@ -1,10 +1,10 @@
 # Template file for 'handbrake'
 pkgname=handbrake
-version=1.5.1
+version=1.6.1
 revision=1
 build_style=gnu-configure
 configure_args="--force --disable-gtk-update-checks --disable-df-fetch --harden
- $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc)"
+ $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc) $(vopt_enable qsv)"
 make_build_args="-C ${XBPS_TRIPLET}"
 make_install_args="-C ${XBPS_TRIPLET}"
 hostmakedepends="automake cmake gettext-devel glib-devel intltool libtool m4 meson nasm pkg-config python3"
@@ -12,8 +12,11 @@ makedepends="bzip2-devel ffmpeg-devel gst-plugins-base1-devel gtk+3-devel
  jansson-devel lame-devel libass-devel libbluray-devel libdav1d-devel
  libdvdnav-devel libdvdread-devel libgudev-devel libnuma-devel
  libsamplerate-devel libtheora-devel libvorbis-devel libvpx-devel libxml2-devel
- opus-devel speex-devel x264-devel x265-devel zimg-devel
+ opus-devel speex-devel x264-devel x265-devel zimg-devel libsvt-av1-devel
  $(vopt_if fdk_aac fdk-aac-devel)
+ $(vopt_if qsv libva-devel)
+ $(vopt_if qsv libdrm-devel)
+ $(vopt_if qsv onevpl-devel)
  $(vopt_if nvenc nv-codec-headers)"
 depends="desktop-file-utils gst-plugins-good1 hicolor-icon-theme"
 short_desc="Multithreaded video transcoder"
@@ -21,15 +24,15 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-2.0-only"
 homepage="https://handbrake.fr/"
 distfiles="https://github.com/HandBrake/HandBrake/releases/download/${version}/HandBrake-${version}-source.tar.bz2"
-checksum=3999fe06d5309c819799a73a968a8ec3840e7840c2b64af8f5cdb7fd8c9430f0
+checksum=94ccfe03db917a91650000c510f7fd53f844da19f19ad4b4be1b8f6bc31a8d4c
 nocross=yes
 
-build_options="fdk_aac nvenc"
+build_options="fdk_aac nvenc qsv"
 
 case "$XBPS_TARGET_MACHINE" in
 	x86_64*|i686*)
 		CFLAGS="-msse"
-		build_options_default="nvenc"
+		build_options_default="nvenc qsv"
 		;;
 esac
 
@@ -37,7 +40,7 @@ pre_configure() {
 	# use system libraries, don't download them
 	rm -rf contrib/
 	for module in fdk-aac ffmpeg libbluray libdav1d libdvdnav libdvdread nvenc \
-		x265 zimg; do
+		x265 zimg svt-av1 libvpl; do
 	    vsed -i "/MODULES += contrib\/${module}/d" make/include/main.defs
 	done
 }

From 56354a5d26b7911071a91bcf5ce0c94460d7ea99 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 043/115] hedgewars: revbump for ffmpeg4-4.4.3

---
 srcpkgs/hedgewars/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/hedgewars/template b/srcpkgs/hedgewars/template
index 15a1df6d8861d..d1b7290bfdc19 100644
--- a/srcpkgs/hedgewars/template
+++ b/srcpkgs/hedgewars/template
@@ -1,13 +1,13 @@
 # Template file for 'hedgewars'
 pkgname=hedgewars
 version=1.0.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DNOSERVER=1 -DDATA_INSTALL_DIR=/usr/share/${pkgname}
  -DPHYSFS_SYSTEM=1 -DMINIMAL_FLAGS=1"
 make_cmd=make
 hostmakedepends="lua51 pkg-config qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
+makedepends="ffmpeg4-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
  SDL2_mixer-devel SDL2_net-devel SDL2_ttf-devel"
 depends="libfreeglut"
 short_desc="Funny turn-based artillery game, featuring fighting Hedgehogs!"

From 07165e7a0f34e0e55d4cfd2c02162ed911275571 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 044/115] idjc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/idjc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/idjc/template b/srcpkgs/idjc/template
index b205e74745fe1..36a75baf597c5 100644
--- a/srcpkgs/idjc/template
+++ b/srcpkgs/idjc/template
@@ -5,7 +5,7 @@ revision=4
 build_style=gnu-configure
 hostmakedepends="pkg-config git python3 automake gettext-devel libtool"
 makedepends="libvorbis-devel libogg-devel jack-devel libsamplerate-devel
- libflac-devel libsndfile-devel mpg123-devel ffmpeg-devel speex-devel
+ libflac-devel libsndfile-devel mpg123-devel ffmpeg4-devel speex-devel
  glib-devel pixman-devel lame-devel python3-gobject-devel libshout-idjc-devel
  opus-devel twolame-devel python3-mutagen python3-devel"
 depends="python3-gobject python3-mutagen desktop-file-utils shared-mime-info python3-dbus jack"

From 8abab904f9885ad09815af9830059a7dab44d400 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 045/115] kfilemetadata5: revbump for ffmpeg-6.0

---
 srcpkgs/kfilemetadata5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kfilemetadata5/template b/srcpkgs/kfilemetadata5/template
index c034d62deec8f..e6e9fe11aa55d 100644
--- a/srcpkgs/kfilemetadata5/template
+++ b/srcpkgs/kfilemetadata5/template
@@ -1,7 +1,7 @@
 # Template file for 'kfilemetadata5'
 pkgname=kfilemetadata5
 version=5.110.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="kcoreaddons extra-cmake-modules pkg-config qt5-host-tools qt5-qmake
  gettext kcoreaddons python3"

From 9748bed85e2f48330b84196f139b819498331d45 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 046/115] kid3: revbump for ffmpeg-6.0

---
 srcpkgs/kid3/patches/ffmpeg5.patch | 17 +++++++++++++++++
 srcpkgs/kid3/template              |  2 +-
 2 files changed, 18 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/kid3/patches/ffmpeg5.patch

diff --git a/srcpkgs/kid3/patches/ffmpeg5.patch b/srcpkgs/kid3/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..135fc50e07c9b
--- /dev/null
+++ b/srcpkgs/kid3/patches/ffmpeg5.patch
@@ -0,0 +1,17 @@
+# https://aur.archlinux.org/cgit/aur.git/diff/ffmpeg5.patch?h=kid3-cli&id=12410a74906612e7efc0ec8fbce739b4a0fef7e7
+diff --git a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+index e156d424..e12b9abd 100644
+--- a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
++++ b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+@@ -232,7 +232,11 @@ private:
+   friend class Format;
+   friend class Converter;
+   AVCodecContext* m_ptr;
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 0, 0)
+   AVCodec* m_impl;
++#else
++  const AVCodec* m_impl;
++#endif
+   AVFrame* m_frame;
+   bool m_opened;
+ };
diff --git a/srcpkgs/kid3/template b/srcpkgs/kid3/template
index 456206d90e16a..f32f9decb0e7f 100644
--- a/srcpkgs/kid3/template
+++ b/srcpkgs/kid3/template
@@ -1,7 +1,7 @@
 # Template file for 'kid3'
 pkgname=kid3
 version=3.9.1
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DWITH_APPS='CLI;$(vopt_if KDE KDE Qt)'
  -DWITH_DOCBOOKDIR=/usr/share/xsl/docbook -DWITH_FLAC=$(vopt_if flac ON OFF)

From df70d7bb526e09ad9a17e71190913b1f895de788 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 047/115] kodi: revbump for ffmpeg4-4.4.3

---
 srcpkgs/kodi/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kodi/template b/srcpkgs/kodi/template
index 8ef6bc85ed3b4..788a0ac978af8 100644
--- a/srcpkgs/kodi/template
+++ b/srcpkgs/kodi/template
@@ -54,7 +54,7 @@ makedepends="
  libmad-devel fontconfig-devel libXinerama-devel libsamplerate-devel libmms-devel
  enca-devel boost-devel libcurl-devel libva-devel libvdpau-devel libass-devel
  libbluetooth-devel yajl-devel libplist-devel librtmp-devel tinyxml-devel
- taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg-devel
+ taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg4-devel
  giflib-devel libxslt-devel gnutls-devel libssh-devel libmicrohttpd-devel
  libcec-devel dcadec-devel flatbuffers-devel fmt-devel lcms2-devel
  libfstrcmp-devel rapidjson libcdio-paranoia spdlog libwaylandpp-devel

From b20bce24d76dcaa47660952b12b2388b1e635fe5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 048/115] kpipewire: revbump for ffmpeg-6.0

---
 srcpkgs/kpipewire/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kpipewire/template b/srcpkgs/kpipewire/template
index 216069507f54b..1173d36348d16 100644
--- a/srcpkgs/kpipewire/template
+++ b/srcpkgs/kpipewire/template
@@ -1,7 +1,7 @@
 # Template file for 'kpipewire'
 pkgname=kpipewire
 version=5.27.8
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules plasma-wayland-protocols gettext
  qt5-qmake qt5-host-tools pkg-config wayland-devel kcoreaddons

From 91d06bdf5b92c9be35ca8c62673ad0488ef3f108 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 049/115] libextractor: revbump for ffmpeg4-4.4.3

---
 srcpkgs/libextractor/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libextractor/template b/srcpkgs/libextractor/template
index ddd4790f93e88..1fb9ca56a96ae 100644
--- a/srcpkgs/libextractor/template
+++ b/srcpkgs/libextractor/template
@@ -7,7 +7,7 @@ configure_args="--disable-static"
 hostmakedepends="pkg-config"
 makedepends="zlib-devel bzip2-devel exiv2-devel tiff-devel libpng-devel
  libjpeg-turbo-devel libvorbis-devel libflac-devel giflib-devel libmpeg2-devel
- ffmpeg-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
+ ffmpeg4-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
 short_desc="Library used to extract meta data from files"
 maintainer="Martin Riese <grauehaare@gmx.de>"
 license="GPL-3.0-or-later"

From ff7e84fb25c72b6fd8afb14a842be4e8fa3d66a4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 050/115] libopenal: revbump for ffmpeg-6.0

---
 srcpkgs/libopenal/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenal/template b/srcpkgs/libopenal/template
index 77218f9e539df..3f49ed75a1fdc 100644
--- a/srcpkgs/libopenal/template
+++ b/srcpkgs/libopenal/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenal'
 pkgname=libopenal
 version=1.22.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DALSOFT_EXAMPLES=OFF"
 hostmakedepends="pkg-config"

From 617ab06c528b9b1b7989e21c1f0b9b8bfcc4b2b5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 051/115] loudgain: revbump for ffmpeg-6.0

---
 srcpkgs/loudgain/patches/ffmpeg5.patch | 11 +++++++++++
 srcpkgs/loudgain/template              |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/loudgain/patches/ffmpeg5.patch

diff --git a/srcpkgs/loudgain/patches/ffmpeg5.patch b/srcpkgs/loudgain/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..16d4510ee98fa
--- /dev/null
+++ b/srcpkgs/loudgain/patches/ffmpeg5.patch
@@ -0,0 +1,11 @@
+--- a/src/scan.c	2019-09-06 11:31:19.000000000 -0400
++++ b/src/scan.c	2023-03-23 11:15:40.867968521 -0400
+@@ -69,8 +69,6 @@
+ 	 * It is now useless
+ 	 * https://github.com/FFmpeg/FFmpeg/blob/70d25268c21cbee5f08304da95be1f647c630c15/doc/APIchanges#L86
+ 	 */
+-  if (avformat_version() < AV_VERSION_INT(58,9,100))
+-    av_register_all();
+ 
+ 	av_log_set_callback(scan_av_log);
+ 
diff --git a/srcpkgs/loudgain/template b/srcpkgs/loudgain/template
index da4f2d56e94c3..4d6bf29efb4fd 100644
--- a/srcpkgs/loudgain/template
+++ b/srcpkgs/loudgain/template
@@ -1,7 +1,7 @@
 # Template file for 'loudgain'
 pkgname=loudgain
 version=0.6.8
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libebur128-devel taglib-devel ffmpeg-devel"

From bb27161c43bfa4d6cb858478b4830b280d0c1bb5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 052/115] mediastreamer: revbump for ffmpeg4-4.4.3

---
 srcpkgs/mediastreamer/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mediastreamer/template b/srcpkgs/mediastreamer/template
index d29210c1bf9c7..1bde031443a59 100644
--- a/srcpkgs/mediastreamer/template
+++ b/srcpkgs/mediastreamer/template
@@ -5,7 +5,7 @@ revision=2
 build_style=cmake
 configure_args="-DENABLE_STRICT=0 -DENABLE_UNIT_TESTS=0"
 hostmakedepends="python3"
-makedepends="bzrtp-devel ffmpeg-devel glew-devel libXv-devel libsrtp-devel
+makedepends="bzrtp-devel ffmpeg4-devel glew-devel libXv-devel libsrtp-devel
  libupnp-devel libvpx-devel mbedtls-devel opus-devel ortp-devel pulseaudio-devel
  libtheora-devel speex-devel v4l-utils-devel bcg729-devel bcmatroska2-devel libgsm-devel"
 # zxing-cpp-devel (1.2.0 probably not compatible, check again after updaing xzing)

From 63ad7de5608575c159d0e5052315432d6debcf98 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 053/115] mgba: revbump for ffmpeg-6.0

---
 srcpkgs/mgba/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mgba/template b/srcpkgs/mgba/template
index 5513e3fd16f3f..f5c87a4893002 100644
--- a/srcpkgs/mgba/template
+++ b/srcpkgs/mgba/template
@@ -1,7 +1,7 @@
 # Template file for 'mgba'
 pkgname=mgba
 version=0.10.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake desktop-file-utils"
 makedepends="SDL2-devel ffmpeg-devel libedit-devel libepoxy-devel libmagick-devel

From 0eb2554775e47ff4d020e2075f680972f5fc507e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 054/115] minidlna: revbump for ffmpeg-6.0

---
 srcpkgs/minidlna/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/minidlna/template b/srcpkgs/minidlna/template
index d551e49ed4653..5fa929f3a0c12 100644
--- a/srcpkgs/minidlna/template
+++ b/srcpkgs/minidlna/template
@@ -1,7 +1,7 @@
 # Template file for 'minidlna'
 pkgname=minidlna
 version=1.3.3
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="
  --sbindir=/usr/bin

From 0c65929fb525392859ddabe1944645920c3712a3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 055/115] mlt: revbump for ffmpeg4-4.4.3

---
 srcpkgs/mlt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mlt/template b/srcpkgs/mlt/template
index f14dd85d1c9dc..f0b3af193db2c 100644
--- a/srcpkgs/mlt/template
+++ b/srcpkgs/mlt/template
@@ -8,7 +8,7 @@ configure_args="--prefix=/usr --libdir=/usr/lib$XBPS_TARGET_WORDSIZE
  --swig-languages=python"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which"
 # XXX: movit vid.stab
-makedepends="alsa-lib-devel ffmpeg-devel gtk+-devel jack-devel ladspa-sdk
+makedepends="alsa-lib-devel ffmpeg4-devel gtk+-devel jack-devel ladspa-sdk
  libexif-devel libsamplerate-devel libxml2-devel sox-devel SDL_image-devel
  fftw-devel frei0r-plugins python3-devel pulseaudio-devel movit-devel
  libvidstab-devel"

From e3b58f1b0c028736cc23f2375ccab347130c2387 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 056/115] moc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/moc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/moc/template b/srcpkgs/moc/template
index 5aed5d36558d3..d8de816026b64 100644
--- a/srcpkgs/moc/template
+++ b/srcpkgs/moc/template
@@ -1,10 +1,10 @@
 # Template file for 'moc'
 pkgname=moc
 version=2.5.2
-revision=6
+revision=7
 build_style=gnu-configure
 hostmakedepends="pkg-config"
-makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg-devel
+makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg4-devel
  jack-devel alsa-lib-devel libltdl-devel libflac-devel libvorbis-devel
  libmad-devel libmpcdec-devel libmodplug-devel libid3tag-devel faad2-devel
  taglib-devel libsndfile-devel wavpack-devel speex-devel libsamplerate-devel

From 98f72d5d8da5affe65902cc977b5ecc96b2f45d5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 057/115] motion: revbump for ffmpeg-6.0

---
 srcpkgs/motion/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/motion/template b/srcpkgs/motion/template
index 3cf3c3035c5b7..7dca12d851e33 100644
--- a/srcpkgs/motion/template
+++ b/srcpkgs/motion/template
@@ -1,7 +1,7 @@
 # Template file for 'motion'
 pkgname=motion
 version=4.5.1
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake pkg-config gettext-devel tar"
 makedepends="ffmpeg-devel libmicrohttpd-devel v4l-utils-devel gettext-devel"

From d7e56995741bbab17f31633fdfc1965f02f07a8a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 058/115] notcurses: revbump for ffmpeg-6.0

---
 srcpkgs/notcurses/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/notcurses/template b/srcpkgs/notcurses/template
index 6dd8a091319f7..3110c30c9aff2 100644
--- a/srcpkgs/notcurses/template
+++ b/srcpkgs/notcurses/template
@@ -1,7 +1,7 @@
 # Template file for 'notcurses'
 pkgname=notcurses
 version=3.0.9
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DUSE_STATIC=ON $(vopt_bool man USE_PANDOC)"
 hostmakedepends="pkg-config $(vopt_if man pandoc)"

From 0b2146edc88d730d7ef25875aa4683938ab0f493 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 059/115] olive: revbump for ffmpeg4-4.4.3

---
 srcpkgs/olive/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/olive/template b/srcpkgs/olive/template
index 12a46936c9900..5c2917b9c5124 100644
--- a/srcpkgs/olive/template
+++ b/srcpkgs/olive/template
@@ -1,10 +1,10 @@
 # Template file for 'olive'
 pkgname=olive
 version=0.1.2
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools pkg-config"
-makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg-devel frei0r-plugins"
+makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg4-devel frei0r-plugins"
 short_desc="Non-linear video editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"

From 8ba7b9e753e6f39117512d7d36cb178a994c2fa4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 060/115] omxplayer: revbump for ffmpeg4-4.4.3

---
 srcpkgs/omxplayer/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/omxplayer/template b/srcpkgs/omxplayer/template
index 9a66690c83ebb..a21b878878037 100644
--- a/srcpkgs/omxplayer/template
+++ b/srcpkgs/omxplayer/template
@@ -1,7 +1,7 @@
 # Template file for 'omxplayer'
 pkgname=omxplayer
 version=20190102
-revision=2
+revision=3
 short_desc="Commandline OMX player for the Raspberry Pi"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
@@ -15,7 +15,7 @@ checksum=af2d9450f8947842ea8c401fe9f71eec444013ebbdee29f2ac828c9c493c1329
 archs="armv6l* armv7l*"
 build_style=gnu-makefile
 hostmakedepends="ruby-ronn pkg-config"
-makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg-devel dbus-devel"
+makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg4-devel dbus-devel"
 depends="freefont-ttf"
 
 do_build() {

From 2ad23eca9d18e0410ce6e382e59e1e21e1ebc290 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 061/115] opentoonz: revbump for ffmpeg-6.0

---
 srcpkgs/opentoonz/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/opentoonz/template b/srcpkgs/opentoonz/template
index ee9f7603f55fd..3e81834ca0edd 100644
--- a/srcpkgs/opentoonz/template
+++ b/srcpkgs/opentoonz/template
@@ -1,7 +1,7 @@
 # Template file for 'opentoonz'
 pkgname=opentoonz
 version=1.6.0
-revision=2
+revision=3
 build_wrksrc="toonz/sources"
 build_style=cmake
 make_cmd=make

From b6aaad8ec650f4fc5a764a8d5e371d8dae8a1bdf Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 062/115] pianobar: revbump for ffmpeg-6.0

---
 srcpkgs/pianobar/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pianobar/template b/srcpkgs/pianobar/template
index e3febb821a451..1e3dc1bf9308e 100644
--- a/srcpkgs/pianobar/template
+++ b/srcpkgs/pianobar/template
@@ -1,7 +1,7 @@
 # Template file for 'pianobar'
 pkgname=pianobar
 version=2022.04.01
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="V=1"
 hostmakedepends="pkg-config"

From 5859831dcce8510d5652f5478d26c0bd6f3b19dd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 063/115] ppsspp: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ppsspp/template | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/ppsspp/template b/srcpkgs/ppsspp/template
index 2c0ded496eb98..1294ef3ae669c 100644
--- a/srcpkgs/ppsspp/template
+++ b/srcpkgs/ppsspp/template
@@ -1,7 +1,7 @@
 # Template file for 'ppsspp'
 pkgname=ppsspp
 version=1.16.6
-revision=1
+revision=2
 _glslang_commit=b34f619e1c85810dcb3c578107d2e48ba4ee2b37
 _SPIRV_Cross_commit=4212eef67ed0ca048cb726a6767185504e7695e5
 _armips_commit=7bd1ec93d4586985ba1ef420b43b5e620f68695e
@@ -15,7 +15,7 @@ configure_args="-DHEADLESS=1 -DUSE_SYSTEM_FFMPEG=1 -DUNITTEST=ON
  -DUSING_QT_UI=$(vopt_if qt ON OFF) -DUSE_SYSTEM_ZSTD=ON
  -DARMIPS_USE_STD_FILESYSTEM=ON"
 hostmakedepends="pkg-config python3 $(vopt_if qt qt5-host-tools)"
-makedepends="zlib-devel glew-devel ffmpeg-devel libzip-devel
+makedepends="zlib-devel glew-devel ffmpeg4-devel libzip-devel
  snappy-devel rapidjson libpng-devel libzstd-devel
  $(vopt_if sdl2 'SDL2_ttf-devel SDL2-devel') $(vopt_if wayland wayland-devel)
  $(vopt_if qt 'qt5-devel qt5-multimedia-devel')"
@@ -72,7 +72,7 @@ post_extract() {
         mv ${wrksrc}/rcheevos-${_rcheevos_commit} ${wrksrc}/ext/rcheevos
 }
 
-post_patch(){
+post_patch() {
 	# disable git versioning
 	vsed -e 's|find_package(Git)|# &|' -i git-version.cmake
 }
@@ -85,7 +85,6 @@ post_configure() {
 }
 
 do_install() {
-	vlicense LICENSE.TXT
 	vinstall icons/icon.svg 644 usr/share/pixmaps ppsspp.svg
 	vinstall Qt/PPSSPP.desktop 644 usr/share/applications
 	vbin build/PPSSPPHeadless ppsspp-headless

From a5fa98bbdf7ff868b620a3216d59e942a9e19809 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 064/115] pqiv: revbump for ffmpeg-6.0

---
 srcpkgs/pqiv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pqiv/template b/srcpkgs/pqiv/template
index 542fc27a2d32a..9308d949b6a1c 100644
--- a/srcpkgs/pqiv/template
+++ b/srcpkgs/pqiv/template
@@ -1,7 +1,7 @@
 # Template file for 'pqiv'
 pkgname=pqiv
 version=2.12
-revision=1
+revision=2
 build_style=gnu-makefile
 hostmakedepends="pkg-config"
 makedepends="glib-devel gtk+3-devel $(vopt_if ffmpeg ffmpeg-devel)

From bc96c4a63ba99a64a9a087521593476992d45e38 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 065/115] qmmp: revbump for ffmpeg-6.0

---
 srcpkgs/qmmp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qmmp/template b/srcpkgs/qmmp/template
index 26c661ed16bea..a150d7441c7a6 100644
--- a/srcpkgs/qmmp/template
+++ b/srcpkgs/qmmp/template
@@ -1,7 +1,7 @@
 # Template file for 'qmmp'
 pkgname=qmmp
 version=1.6.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DUSE_HAL:BOOL=FALSE -DQMMP_DEFAULT_UI:STRING=simple"
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From 3147b81c128573fbdc348f0e841e318fa2d0b003 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 066/115] qt5-webengine: update to 5.15.13

---
 .../chromium-media-filters-cpp14.patch        |  11 ++
 srcpkgs/qt5-webengine/patches/ffmpeg5.patch   | 179 ++++++++++++++++++
 srcpkgs/qt5-webengine/template                |  10 +-
 3 files changed, 195 insertions(+), 5 deletions(-)
 create mode 100644 srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/ffmpeg5.patch

diff --git a/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
new file mode 100644
index 0000000000000..04adc540f2cbc
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
@@ -0,0 +1,11 @@
+--- a/src/3rdparty/chromium/media/filters/BUILD.gn	2023-02-27 13:32:59.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/BUILD.gn	2023-04-02 17:21:39.204066384 -0400
+@@ -96,6 +96,8 @@
+     "//ui/gfx/geometry:geometry",
+   ]
+ 
++  cflags_cc = [ "-std=c++14" ]
++
+   libs = []
+ 
+   if (proprietary_codecs) {
diff --git a/srcpkgs/qt5-webengine/patches/ffmpeg5.patch b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..ac55e1634423a
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
@@ -0,0 +1,179 @@
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:57.732547446 -0400
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:09.486478995 -0400
+@@ -57,6 +57,8 @@
+ 
+ namespace {
+ 
++constexpr int64_t kRelativeTsBase = static_cast<int64_t>(0x7ffeffffffffffff);
++
+ void SetAVStreamDiscard(AVStream* stream, AVDiscard discard) {
+   DCHECK(stream);
+   stream->discard = discard;
+@@ -90,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+   if (stream->start_time != kNoFFmpegTimestamp)
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (stream->first_dts != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, stream->first_dts);
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -408,11 +398,11 @@
+   scoped_refptr<DecoderBuffer> buffer;
+ 
+   if (type() == DemuxerStream::TEXT) {
+-    int id_size = 0;
++    size_t id_size = 0;
+     uint8_t* id_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
+ 
+-    int settings_size = 0;
++    size_t settings_size = 0;
+     uint8_t* settings_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
+ 
+@@ -424,7 +414,7 @@
+     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
+                                      side_data.data(), side_data.size());
+   } else {
+-    int side_data_size = 0;
++    size_t side_data_size = 0;
+     uint8_t* side_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
+ 
+@@ -485,7 +475,7 @@
+                                        packet->size - data_offset);
+     }
+ 
+-    int skip_samples_size = 0;
++    size_t skip_samples_size = 0;
+     const uint32_t* skip_samples_ptr =
+         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
+             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
+@@ -1587,6 +1577,8 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++      continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+       lowest_start_time_stream = stream.get();
+@@ -1604,6 +1596,8 @@
+     if (stream && stream->type() == DemuxerStream::VIDEO &&
+         stream->IsEnabled()) {
+       video_stream = stream.get();
++      if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++        continue;
+       if (video_stream->start_time() <= seek_time) {
+         return video_stream;
+       }
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h qtwebengine-5.15.10/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h
+--- a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-07-11 22:12:47.917192788 -0500
+@@ -29,6 +29,7 @@ extern "C" {
+ #include <libavformat/avformat.h>
+ #include <libavformat/avio.h>
+ #include <libavutil/avutil.h>
++#include <libavutil/channel_layout.h>
+ #include <libavutil/imgutils.h>
+ #include <libavutil/log.h>
+ #include <libavutil/mastering_display_metadata.h>
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/audio_file_reader.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/audio_file_reader.cc
+--- a/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -85,7 +85,7 @@ bool AudioFileReader::OpenDemuxer() {
+ }
+ 
+ bool AudioFileReader::OpenDecoder() {
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (codec) {
+     // MP3 decodes to S16P which we don't support, tell it to use S16 instead.
+     if (codec_context_->sample_fmt == AV_SAMPLE_FMT_S16P)
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -329,7 +329,7 @@ bool FFmpegAudioDecoder::ConfigureDecode
+     }
+   }
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec ||
+       avcodec_open2(codec_context_.get(), codec, &codec_options) < 0) {
+     DLOG(ERROR) << "Could not initialize audio decoder: "
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -59,7 +59,6 @@ static int64_t AVIOSeekOperation(void* o
+ }
+ 
+ void FFmpegGlue::InitializeFFmpeg() {
+-  av_register_all();
+ }
+ 
+ static void LogContainer(bool is_local_file,
+@@ -95,9 +94,6 @@ FFmpegGlue::FFmpegGlue(FFmpegURLProtocol
+   // Enable fast, but inaccurate seeks for MP3.
+   format_context_->flags |= AVFMT_FLAG_FAST_SEEK;
+ 
+-  // Ensures we can read out various metadata bits like vp8 alpha.
+-  format_context_->flags |= AVFMT_FLAG_KEEP_SIDE_DATA;
+-
+   // Ensures format parsing errors will bail out. From an audit on 11/2017, all
+   // instances were real failures. Solves bugs like http://crbug.com/710791.
+   format_context_->error_recognition |= AV_EF_EXPLODE;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -391,7 +391,7 @@ bool FFmpegVideoDecoder::ConfigureDecode
+   if (decode_nalus_)
+     codec_context_->flags2 |= AV_CODEC_FLAG2_CHUNKS;
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
+     ReleaseFFmpegResources();
+     return false;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/media_file_checker.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/media_file_checker.cc
+--- a/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -68,7 +68,7 @@ bool MediaFileChecker::Start(base::TimeD
+       auto context = AVStreamToAVCodecContext(format_context->streams[i]);
+       if (!context)
+         continue;
+-      AVCodec* codec = avcodec_find_decoder(cp->codec_id);
++      const AVCodec* codec = avcodec_find_decoder(cp->codec_id);
+       if (codec && avcodec_open2(context.get(), codec, nullptr) >= 0) {
+         auto loop = std::make_unique<FFmpegDecodingLoop>(context.get());
+         stream_contexts[i] = {std::move(context), std::move(loop)};
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc qtwebengine-5.15.10/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc
+--- a/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -203,7 +203,7 @@ int32_t H264DecoderImpl::InitDecode(cons
+   // a pointer |this|.
+   av_context_->opaque = this;
+ 
+-  AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
+   if (!codec) {
+     // This is an indication that FFmpeg has not been initialized or it has not
+     // been compiled/initialized with the correct set of codecs.
diff --git a/srcpkgs/qt5-webengine/template b/srcpkgs/qt5-webengine/template
index 84de5b12ecdda..b89fe4c1ad50a 100644
--- a/srcpkgs/qt5-webengine/template
+++ b/srcpkgs/qt5-webengine/template
@@ -1,9 +1,9 @@
 # Template file for 'qt5-webengine'
 pkgname=qt5-webengine
-version=5.15.11
-revision=5
+version=5.15.13
+revision=1
 _version="${version}-lts"
-_chromium_commit=be349eaf62e77955791d7bf29f893f1e8a37daf4
+_chromium_commit=e48df7803c7c98b0b2471c94057d32e44a301ad5
 archs="x86_64* i686* armv[67]* ppc64* aarch64*"
 create_wrksrc=yes
 build_style=qmake
@@ -32,8 +32,8 @@ license="GPL-3.0-or-later, LGPL-3.0-or-later"
 homepage="https://qt.io/"
 distfiles="https://github.com/qt/qtwebengine/archive/v${_version}.tar.gz
  https://github.com/qt/qtwebengine-chromium/archive/${_chromium_commit}.tar.gz"
-checksum="aa7466356c450c5f5870f979b93cd7e7e62da1165c328ffcab1a9928db18ad67
- 6f47ed8ab8cc062411f6f206da6353bc8263d6ed6d6290c689a05c01d91f646b"
+checksum="4b59838ed75ef788b59e1e412535a0e42dd9d311661fdeadb191b581ba815c63
+ a91686562b1d4e8b220e0bbcbab5feb64630e2de974b35ac034bf388af771a6c"
 
 no_generic_pkgconfig_link=yes
 build_options="sndio pipewire"

From 9553e3558f70e9c904602b1c1b96c7fc9d930c1f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 067/115] qt5: update to 5.15.8

---
 ...erywhere-opensource-src-5.15.8-kf5-1.patch | 12913 ++++++++++++++++
 srcpkgs/qt5/template                          |    13 +-
 2 files changed, 12919 insertions(+), 7 deletions(-)
 create mode 100644 srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch

diff --git a/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch b/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch
new file mode 100644
index 0000000000000..966c98bcd3bb1
--- /dev/null
+++ b/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch
@@ -0,0 +1,12913 @@
+Submitted By:            Pierre Labastie <pierre_dot_labastie_at_neuf_dot_fr>
+Date:                    2023-01-05
+Initial Package Version: 5.15.8
+Upstream Status:         Applied (according to KDE)
+Origin:                  KDE patch set
+Description:             Patch set maintained by the KDE folks
+see https://dot.kde.org/2021/04/06/announcing-kdes-qt-5-patch-collection
+Patch generated using the procedure in
+https://wiki.linuxfromscratch.org/blfs/ticket/17476#comment:3
+
+Submodule qtbase 4ee4fc18..9cf586d6:
+diff --git a/qtbase/mkspecs/common/android/qplatformdefs.h b/qtbase/mkspecs/common/android/qplatformdefs.h
+index f75bc4093b..2bd59410d4 100644
+--- a/qtbase/mkspecs/common/android/qplatformdefs.h
++++ b/qtbase/mkspecs/common/android/qplatformdefs.h
+@@ -144,11 +144,7 @@
+ #define QT_SIGNAL_ARGS          int
+ #define QT_SIGNAL_IGNORE        SIG_IGN
+ 
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+ #define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+ 
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+diff --git a/qtbase/mkspecs/features/mac/sdk.mk b/qtbase/mkspecs/features/mac/sdk.mk
+index f30b5830b4..a32ceacb6c 100644
+--- a/qtbase/mkspecs/features/mac/sdk.mk
++++ b/qtbase/mkspecs/features/mac/sdk.mk
+@@ -1,6 +1,6 @@
+ 
+ ifeq ($(QT_MAC_SDK_NO_VERSION_CHECK),)
+-    CHECK_SDK_COMMAND = /usr/bin/xcrun --sdk $(EXPORT_QMAKE_MAC_SDK) -show-sdk-version 2>&1
++    CHECK_SDK_COMMAND = /usr/bin/xcrun --sdk $(EXPORT_QMAKE_MAC_SDK) -show-sdk-version 2>/dev/null
+     CURRENT_MAC_SDK_VERSION := $(shell DEVELOPER_DIR=$(EXPORT_QMAKE_XCODE_DEVELOPER_PATH) $(CHECK_SDK_COMMAND))
+     ifneq ($(CURRENT_MAC_SDK_VERSION),$(EXPORT_QMAKE_MAC_SDK_VERSION))
+         # We don't want to complain about out of date SDK unless the target needs to be remade.
+diff --git a/qtbase/mkspecs/linux-clang/qplatformdefs.h b/qtbase/mkspecs/linux-clang/qplatformdefs.h
+index a818d973f0..c1ab72fbc6 100644
+--- a/qtbase/mkspecs/linux-clang/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-clang/qplatformdefs.h
+@@ -79,14 +79,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-g++/qplatformdefs.h b/qtbase/mkspecs/linux-g++/qplatformdefs.h
+index 13523f0702..4d2750d9ec 100644
+--- a/qtbase/mkspecs/linux-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-g++/qplatformdefs.h
+@@ -79,14 +79,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ < 2)
+-#define QT_SOCKLEN_T            int
+-#else
+-#define QT_SOCKLEN_T            socklen_t
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-llvm/qplatformdefs.h b/qtbase/mkspecs/linux-llvm/qplatformdefs.h
+index dc750ab1ef..d3cc39b47f 100644
+--- a/qtbase/mkspecs/linux-llvm/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-llvm/qplatformdefs.h
+@@ -80,14 +80,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h b/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
+index 4c4e53da2a..83baffb3e3 100644
+--- a/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
+@@ -85,16 +85,9 @@
+ #include "../common/posix/qplatformdefs.h"
+ 
+ #undef QT_OPEN_LARGEFILE
+-#undef QT_SOCKLEN_T
+ 
+ #define QT_OPEN_LARGEFILE       0
+ 
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #ifndef SIOCGIFBRDADDR
+ #  define SIOCGIFBRDADDR 0x8919
+ #endif
+diff --git a/qtbase/mkspecs/lynxos-g++/qplatformdefs.h b/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
+index 4339ea2b23..6007af0055 100644
+--- a/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
+@@ -72,14 +72,6 @@
+ 
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp b/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
+index c3c184258f..32af3f8f29 100644
+--- a/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
++++ b/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
+@@ -10,6 +10,7 @@
+ #include "libANGLE/HandleAllocator.h"
+ 
+ #include <algorithm>
++#include <limits>
+ 
+ #include "common/debug.h"
+ 
+diff --git a/qtbase/src/3rdparty/forkfd/forkfd_linux.c b/qtbase/src/3rdparty/forkfd/forkfd_linux.c
+index ffe0e9a5e2..b1f5408d11 100644
+--- a/qtbase/src/3rdparty/forkfd/forkfd_linux.c
++++ b/qtbase/src/3rdparty/forkfd/forkfd_linux.c
+@@ -82,7 +82,8 @@ static int sys_clone(unsigned long cloneflags, int *ptid)
+     return syscall(__NR_clone, cloneflags, child_stack, stack_size, ptid, newtls, ctid);
+ #elif defined(__arc__) || defined(__arm__) || defined(__aarch64__) || defined(__mips__) || \
+     defined(__nds32__) || defined(__hppa__) || defined(__powerpc__) || defined(__i386__) || \
+-    defined(__x86_64__) || defined(__xtensa__) || defined(__alpha__) || defined(__riscv)
++    defined(__x86_64__) || defined(__xtensa__) || defined(__alpha__) || defined(__riscv) || \
++    defined(__loongarch__)
+     /* ctid and newtls are inverted on CONFIG_CLONE_BACKWARDS architectures,
+      * but since both values are 0, there's no harm. */
+     return syscall(__NR_clone, cloneflags, child_stack, ptid, ctid, newtls);
+diff --git a/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java b/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
+index 5792b5b2f5..2f74750fcf 100644
+--- a/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
++++ b/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
+@@ -116,6 +116,7 @@ public class QtNative
+     public static QtThread m_qtThread = new QtThread();
+     private static HashMap<String, Uri> m_cachedUris = new HashMap<String, Uri>();
+     private static ArrayList<String> m_knownDirs = new ArrayList<String>();
++    private static final String NoPermissionErrorMessage = "No permissions to open Uri";
+ 
+     private static final Runnable runPendingCppRunnablesRunnable = new Runnable() {
+         @Override
+@@ -193,11 +194,10 @@ public class QtNative
+                     return iterUri;
+             }
+ 
+-            // Android 6 and earlier could still manage to open the file so we can return the
+-            // parsed uri here
+-            if (Build.VERSION.SDK_INT < 24)
+-                return parsedUri;
+-            return null;
++            // if we only have transient permissions on uri all the above will fail,
++            // but we will be able to read the file anyway, so continue with uri here anyway
++            // and check for SecurityExceptions later
++            return parsedUri;
+         } catch (SecurityException e) {
+             e.printStackTrace();
+             return null;
+@@ -244,7 +244,7 @@ public class QtNative
+         int error = -1;
+ 
+         if (uri == null) {
+-            Log.e(QtTAG, "openFdForContentUrl(): No permissions to open Uri");
++            Log.e(QtTAG, "openFdForContentUrl(): " + NoPermissionErrorMessage);
+             return error;
+         }
+ 
+@@ -254,12 +254,13 @@ public class QtNative
+             return fdDesc.detachFd();
+         } catch (FileNotFoundException e) {
+             e.printStackTrace();
+-            return error;
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "openFdForContentUrl(): Invalid Uri");
+             e.printStackTrace();
+-            return error;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return error;
+     }
+ 
+     public static long getSize(Context context, String contentUrl)
+@@ -270,7 +271,7 @@ public class QtNative
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+ 
+         if (uri == null) {
+-            Log.e(QtTAG, "getSize(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return size;
+         } else if (!m_cachedUris.containsKey(contentUrl)) {
+             m_cachedUris.put(contentUrl, uri);
+@@ -288,12 +289,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "getSize(): Invalid Uri");
+             e.printStackTrace();
+-            return size;
+         }  catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "getSize(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return size;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return size;
+     }
+ 
+     public static boolean checkFileExists(Context context, String contentUrl)
+@@ -303,7 +305,7 @@ public class QtNative
+         if (uri == null)
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+         if (uri == null) {
+-            Log.e(QtTAG, "checkFileExists(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return exists;
+         } else {
+             if (!m_cachedUris.containsKey(contentUrl))
+@@ -321,12 +323,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "checkFileExists(): Invalid Uri");
+             e.printStackTrace();
+-            return exists;
+         } catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "checkFileExists(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return false;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return exists;
+     }
+ 
+     public static boolean checkIfWritable(Context context, String contentUrl)
+@@ -344,7 +347,7 @@ public class QtNative
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+         }
+         if (uri == null) {
+-            Log.e(QtTAG, "isDir(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return isDir;
+         } else {
+             if (!m_cachedUris.containsKey(contentUrl))
+@@ -374,12 +377,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "checkIfDir(): Invalid Uri");
+             e.printStackTrace();
+-            return false;
+         } catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "checkIfDir(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return false;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return false;
+     }
+     public static String[] listContentsFromTreeUri(Context context, String contentUrl)
+     {
+diff --git a/qtbase/src/concurrent/qtconcurrentreducekernel.h b/qtbase/src/concurrent/qtconcurrentreducekernel.h
+index 8f9a938952..a98dedef2e 100644
+--- a/qtbase/src/concurrent/qtconcurrentreducekernel.h
++++ b/qtbase/src/concurrent/qtconcurrentreducekernel.h
+@@ -212,11 +212,13 @@ public:
+ 
+     inline bool shouldThrottle()
+     {
++        std::lock_guard<QMutex> locker(mutex);
+         return (resultsMapSize > (ReduceQueueThrottleLimit * threadCount));
+     }
+ 
+     inline bool shouldStartThread()
+     {
++        std::lock_guard<QMutex> locker(mutex);
+         return (resultsMapSize <= (ReduceQueueStartLimit * threadCount));
+     }
+ };
+diff --git a/qtbase/src/concurrent/qtconcurrentthreadengine.cpp b/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
+index ea6ce3ac42..7f91a2ba68 100644
+--- a/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
++++ b/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
+@@ -176,6 +176,39 @@ void ThreadEngineBase::startSingleThreaded()
+     finish();
+ }
+ 
++void ThreadEngineBase::startBlocking()
++{
++    start();
++    barrier.acquire();
++    startThreads();
++
++    bool throttled = false;
++#ifndef QT_NO_EXCEPTIONS
++    try {
++#endif
++        while (threadFunction() == ThrottleThread) {
++            if (threadThrottleExit()) {
++                throttled = true;
++                break;
++            }
++        }
++#ifndef QT_NO_EXCEPTIONS
++    } catch (QException &e) {
++        handleException(e);
++    } catch (...) {
++        handleException(QUnhandledException());
++    }
++#endif
++
++    if (throttled == false) {
++        barrier.release();
++    }
++
++    barrier.wait();
++    finish();
++    exceptionStore.throwPossibleException();
++}
++
+ void ThreadEngineBase::startThread()
+ {
+     startThreadInternal();
+diff --git a/qtbase/src/concurrent/qtconcurrentthreadengine.h b/qtbase/src/concurrent/qtconcurrentthreadengine.h
+index 7c30cebdbc..a4c8548cc4 100644
+--- a/qtbase/src/concurrent/qtconcurrentthreadengine.h
++++ b/qtbase/src/concurrent/qtconcurrentthreadengine.h
+@@ -91,6 +91,7 @@ public:
+     ThreadEngineBase();
+     virtual ~ThreadEngineBase();
+     void startSingleThreaded();
++    void startBlocking();
+     void startThread();
+     bool isCanceled();
+     void waitForResume();
+@@ -143,6 +144,15 @@ public:
+         return result();
+     }
+ 
++    // Runs the user algorithm using multiple threads.
++    // This function blocks until the algorithm is finished,
++    // and then returns the result.
++    T *startBlocking()
++    {
++        ThreadEngineBase::startBlocking();
++        return result();
++    }
++
+     // Runs the user algorithm using multiple threads.
+     // Does not block, returns a future.
+     QFuture<T> startAsynchronously()
+@@ -223,6 +233,13 @@ class ThreadEngineStarter : public ThreadEngineStarterBase<T>
+ public:
+     ThreadEngineStarter(TypedThreadEngine *eng)
+         : Base(eng) { }
++
++    T startBlocking()
++    {
++        T t = *this->threadEngine->startBlocking();
++        delete this->threadEngine;
++        return t;
++    }
+ };
+ 
+ // Full template specialization where T is void.
+@@ -232,6 +249,12 @@ class ThreadEngineStarter<void> : public ThreadEngineStarterBase<void>
+ public:
+     ThreadEngineStarter(ThreadEngine<void> *_threadEngine)
+         : ThreadEngineStarterBase<void>(_threadEngine) {}
++
++    void startBlocking()
++    {
++        this->threadEngine->startBlocking();
++        delete this->threadEngine;
++    }
+ };
+ 
+ //! [qtconcurrentthreadengine-1]
+diff --git a/qtbase/src/corelib/animation/qvariantanimation.cpp b/qtbase/src/corelib/animation/qvariantanimation.cpp
+index 98b02f0202..eac1524107 100644
+--- a/qtbase/src/corelib/animation/qvariantanimation.cpp
++++ b/qtbase/src/corelib/animation/qvariantanimation.cpp
+@@ -276,7 +276,9 @@ void QVariantAnimationPrivate::setCurrentValueForProgress(const qreal progress)
+ 
+     const qreal startProgress = currentInterval.start.first;
+     const qreal endProgress = currentInterval.end.first;
+-    const qreal localProgress = (progress - startProgress) / (endProgress - startProgress);
++    const qreal localProgress =
++            qIsNull(progress - startProgress) ? 0.0 // avoid 0/0 below
++            /* else */                        : (progress - startProgress) / (endProgress - startProgress);
+ 
+     QVariant ret = q->interpolated(currentInterval.start.second,
+                                    currentInterval.end.second,
+diff --git a/qtbase/src/corelib/global/qnamespace.h b/qtbase/src/corelib/global/qnamespace.h
+index ad4150b317..bf19b1627b 100644
+--- a/qtbase/src/corelib/global/qnamespace.h
++++ b/qtbase/src/corelib/global/qnamespace.h
+@@ -1864,7 +1864,7 @@ public:
+     QT_Q_ENUM(TimerType)
+     QT_Q_ENUM(ScrollPhase)
+     QT_Q_ENUM(MouseEventSource)
+-    QT_Q_FLAG(MouseEventFlag)
++    QT_Q_FLAG(MouseEventFlags)
+     QT_Q_ENUM(ChecksumType)
+     QT_Q_ENUM(HighDpiScaleFactorRoundingPolicy)
+     QT_Q_ENUM(TabFocusBehavior)
+diff --git a/qtbase/src/corelib/global/qrandom.cpp b/qtbase/src/corelib/global/qrandom.cpp
+index 10672c1f92..25f87c7e6a 100644
+--- a/qtbase/src/corelib/global/qrandom.cpp
++++ b/qtbase/src/corelib/global/qrandom.cpp
+@@ -383,7 +383,6 @@ struct QRandomGenerator::SystemAndGlobalGenerators
+ 
+         constexpr SystemAndGlobalGenerators g = {};
+         Q_UNUSED(g);
+-        Q_STATIC_ASSERT(std::is_literal_type<SystemAndGlobalGenerators>::value);
+ #endif
+     }
+ 
+diff --git a/qtbase/src/corelib/io/qbuffer.cpp b/qtbase/src/corelib/io/qbuffer.cpp
+index 595fcd2724..032c0ddd4b 100644
+--- a/qtbase/src/corelib/io/qbuffer.cpp
++++ b/qtbase/src/corelib/io/qbuffer.cpp
+@@ -41,6 +41,8 @@
+ #include <QtCore/qmetaobject.h>
+ #include "private/qiodevice_p.h"
+ 
++#include <limits>
++
+ QT_BEGIN_NAMESPACE
+ 
+ /** QBufferPrivate **/
+@@ -366,7 +368,9 @@ qint64 QBuffer::size() const
+ bool QBuffer::seek(qint64 pos)
+ {
+     Q_D(QBuffer);
+-    if (pos > d->buf->size() && isWritable()) {
++    const auto oldBufSize = d->buf->size();
++    constexpr qint64 MaxSeekPos = (std::numeric_limits<decltype(oldBufSize)>::max)();
++    if (pos <= MaxSeekPos && pos > oldBufSize && isWritable()) {
+         if (seek(d->buf->size())) {
+             const qint64 gapSize = pos - d->buf->size();
+             if (write(QByteArray(gapSize, 0)) != gapSize) {
+@@ -377,7 +381,7 @@ bool QBuffer::seek(qint64 pos)
+             return false;
+         }
+     } else if (pos > d->buf->size() || pos < 0) {
+-        qWarning("QBuffer::seek: Invalid pos: %d", int(pos));
++        qWarning("QBuffer::seek: Invalid pos: %lld", pos);
+         return false;
+     }
+     return QIODevice::seek(pos);
+diff --git a/qtbase/src/corelib/io/qfilesystemengine_win.cpp b/qtbase/src/corelib/io/qfilesystemengine_win.cpp
+index 81d3a71986..c86ed1f9b0 100644
+--- a/qtbase/src/corelib/io/qfilesystemengine_win.cpp
++++ b/qtbase/src/corelib/io/qfilesystemengine_win.cpp
+@@ -664,14 +664,14 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry)
+     return QFileSystemEntry(ret, QFileSystemEntry::FromInternalPath());
+ }
+ 
+-#if defined(Q_CC_MINGW) && WINVER < 0x0602 //  Windows 8 onwards
++#if defined(Q_CC_MINGW) && WINVER < 0x0602 && _WIN32_WINNT < _WIN32_WINNT_WIN8 //  Windows 8 onwards
+ 
+ typedef struct _FILE_ID_INFO {
+     ULONGLONG VolumeSerialNumber;
+     FILE_ID_128 FileId;
+ } FILE_ID_INFO, *PFILE_ID_INFO;
+ 
+-#endif // if defined (Q_CC_MINGW) && WINVER < 0x0602
++#endif // if defined(Q_CC_MINGW) && WINVER < 0x0602 && _WIN32_WINNT < _WIN32_WINNT_WIN8
+ 
+ // File ID for Windows up to version 7 and FAT32 drives
+ static inline QByteArray fileId(HANDLE handle)
+diff --git a/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp b/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
+index 94d9d06bcb..27e0b13b0b 100644
+--- a/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
++++ b/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
+@@ -366,7 +366,9 @@ void QInotifyFileSystemWatcherEngine::readFromInotify()
+     // qDebug("QInotifyFileSystemWatcherEngine::readFromInotify");
+ 
+     int buffSize = 0;
+-    ioctl(inotifyFd, FIONREAD, (char *) &buffSize);
++    if (ioctl(inotifyFd, FIONREAD, (char *) &buffSize) == -1 || buffSize == 0)
++        return;
++
+     QVarLengthArray<char, 4096> buffer(buffSize);
+     buffSize = read(inotifyFd, buffer.data(), buffSize);
+     char *at = buffer.data();
+diff --git a/qtbase/src/corelib/io/qlockfile_win.cpp b/qtbase/src/corelib/io/qlockfile_win.cpp
+index 277f8d4230..38ecef5550 100644
+--- a/qtbase/src/corelib/io/qlockfile_win.cpp
++++ b/qtbase/src/corelib/io/qlockfile_win.cpp
+@@ -48,6 +48,8 @@
+ #include "QtCore/qdebug.h"
+ #include "QtCore/qthread.h"
+ 
++#include "private/qsystemlibrary_p.h"
++
+ QT_BEGIN_NAMESPACE
+ 
+ static inline bool fileExists(const wchar_t *fileName)
+@@ -150,7 +152,7 @@ QString QLockFilePrivate::processNameByPid(qint64 pid)
+ #if !defined(Q_OS_WINRT)
+     typedef DWORD (WINAPI *GetModuleFileNameExFunc)(HANDLE, HMODULE, LPTSTR, DWORD);
+ 
+-    HMODULE hPsapi = LoadLibraryA("psapi");
++    HMODULE hPsapi = QSystemLibrary::load(L"psapi");
+     if (!hPsapi)
+         return QString();
+     GetModuleFileNameExFunc qGetModuleFileNameEx = reinterpret_cast<GetModuleFileNameExFunc>(
+diff --git a/qtbase/src/corelib/io/qprocess_unix.cpp b/qtbase/src/corelib/io/qprocess_unix.cpp
+index 50390e57f5..15c8f30745 100644
+--- a/qtbase/src/corelib/io/qprocess_unix.cpp
++++ b/qtbase/src/corelib/io/qprocess_unix.cpp
+@@ -1,7 +1,7 @@
+ /****************************************************************************
+ **
+ ** Copyright (C) 2016 The Qt Company Ltd.
+-** Copyright (C) 2016 Intel Corporation.
++** Copyright (C) 2022 Intel Corporation.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtCore module of the Qt Toolkit.
+@@ -422,14 +422,15 @@ void QProcessPrivate::startProcess()
+     // Add the program name to the argument list.
+     argv[0] = nullptr;
+     if (!program.contains(QLatin1Char('/'))) {
++        // findExecutable() returns its argument if it's an absolute path,
++        // otherwise it searches $PATH; returns empty if not found (we handle
++        // that case much later)
+         const QString &exeFilePath = QStandardPaths::findExecutable(program);
+-        if (!exeFilePath.isEmpty()) {
+-            const QByteArray &tmp = QFile::encodeName(exeFilePath);
+-            argv[0] = ::strdup(tmp.constData());
+-        }
+-    }
+-    if (!argv[0])
++        const QByteArray &tmp = QFile::encodeName(exeFilePath);
++        argv[0] = ::strdup(tmp.constData());
++    } else {
+         argv[0] = ::strdup(encodedProgramName.constData());
++    }
+ 
+     // Add every argument to the list
+     for (int i = 0; i < arguments.count(); ++i)
+@@ -983,15 +984,16 @@ bool QProcessPrivate::startDetached(qint64 *pid)
+                 envp = _q_dupEnvironment(environment.d.constData()->vars, &envc);
+             }
+ 
+-            QByteArray tmp;
+             if (!program.contains(QLatin1Char('/'))) {
++                // findExecutable() returns its argument if it's an absolute path,
++                // otherwise it searches $PATH; returns empty if not found (we handle
++                // that case much later)
+                 const QString &exeFilePath = QStandardPaths::findExecutable(program);
+-                if (!exeFilePath.isEmpty())
+-                    tmp = QFile::encodeName(exeFilePath);
++                const QByteArray &tmp = QFile::encodeName(exeFilePath);
++                argv[0] = ::strdup(tmp.constData());
++            } else {
++                argv[0] = ::strdup(QFile::encodeName(program));
+             }
+-            if (tmp.isEmpty())
+-                tmp = QFile::encodeName(program);
+-            argv[0] = tmp.data();
+ 
+             if (envp)
+                 qt_safe_execve(argv[0], argv, envp);
+diff --git a/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp b/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
+index 3a79c502af..997a634e76 100644
+--- a/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
++++ b/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
+@@ -3196,9 +3196,8 @@ bool QAbstractItemModel::beginMoveColumns(const QModelIndex &sourceParent, int s
+     destinationChange.needsAdjust = destinationParent.isValid() && destinationParent.row() >= sourceLast && destinationParent.parent() == sourceParent;
+     d->changes.push(destinationChange);
+ 
+-    d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Horizontal);
+-
+     emit columnsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, QPrivateSignal());
++    d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Horizontal);
+     return true;
+ }
+ 
+@@ -3231,7 +3230,6 @@ void QAbstractItemModel::endMoveColumns()
+       adjustedSource = createIndex(adjustedSource.row(), adjustedSource.column() + numMoved, adjustedSource.internalPointer());
+ 
+     d->itemsMoved(adjustedSource, removeChange.first, removeChange.last, adjustedDestination, insertChange.first, Qt::Horizontal);
+-
+     emit columnsMoved(adjustedSource, removeChange.first, removeChange.last, adjustedDestination, insertChange.first, QPrivateSignal());
+ }
+ 
+diff --git a/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+index dc6379d9fb..c5e287ee84 100644
+--- a/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
++++ b/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+@@ -939,8 +939,9 @@ void QSortFilterProxyModelPrivate::insert_source_items(
+                 q->beginInsertColumns(proxy_parent, proxy_start, proxy_end);
+         }
+ 
+-        for (int i = 0; i < source_items.size(); ++i)
+-            proxy_to_source.insert(proxy_start + i, source_items.at(i));
++        // TODO: use the range QList::insert() overload once it is implemented (QTBUG-58633).
++        proxy_to_source.insert(proxy_start, source_items.size(), 0);
++        std::copy(source_items.cbegin(), source_items.cend(), proxy_to_source.begin() + proxy_start);
+ 
+         build_source_to_proxy_mapping(proxy_to_source, source_to_proxy);
+ 
+@@ -3123,8 +3124,9 @@ bool QSortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex &
+ 
+     if (d->filter_data.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();
+@@ -3133,9 +3135,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.hasMatch(key);
+ }
+diff --git a/qtbase/src/corelib/kernel/qcoreapplication.cpp b/qtbase/src/corelib/kernel/qcoreapplication.cpp
+index ca2864df83..132b2eae52 100644
+--- a/qtbase/src/corelib/kernel/qcoreapplication.cpp
++++ b/qtbase/src/corelib/kernel/qcoreapplication.cpp
+@@ -1157,7 +1157,7 @@ static bool doNotify(QObject *receiver, QEvent *event)
+ bool QCoreApplicationPrivate::sendThroughApplicationEventFilters(QObject *receiver, QEvent *event)
+ {
+     // We can't access the application event filters outside of the main thread (race conditions)
+-    Q_ASSERT(receiver->d_func()->threadData.loadRelaxed()->thread.loadAcquire() == mainThread());
++    Q_ASSERT(receiver->d_func()->threadData.loadAcquire()->thread.loadRelaxed() == mainThread());
+ 
+     if (extraData) {
+         // application event filters are only called for objects in the GUI thread
+diff --git a/qtbase/src/corelib/kernel/qobject.cpp b/qtbase/src/corelib/kernel/qobject.cpp
+index 1eb79138d9..36cd780ee1 100644
+--- a/qtbase/src/corelib/kernel/qobject.cpp
++++ b/qtbase/src/corelib/kernel/qobject.cpp
+@@ -1010,7 +1010,7 @@ QObject::~QObject()
+         emit destroyed(this);
+     }
+ 
+-    if (d->declarativeData) {
++    if (!d->isDeletingChildren && d->declarativeData) {
+         if (static_cast<QAbstractDeclarativeDataImpl*>(d->declarativeData)->ownedByQml1) {
+             if (QAbstractDeclarativeData::destroyed_qml1)
+                 QAbstractDeclarativeData::destroyed_qml1(d->declarativeData, this);
+@@ -1580,7 +1580,7 @@ void QObject::moveToThread(QThread *targetThread)
+ 
+     QThreadData *currentData = QThreadData::current();
+     QThreadData *targetData = targetThread ? QThreadData::get2(targetThread) : nullptr;
+-    QThreadData *thisThreadData = d->threadData.loadRelaxed();
++    QThreadData *thisThreadData = d->threadData.loadAcquire();
+     if (!thisThreadData->thread.loadAcquire() && currentData == targetData) {
+         // one exception to the rule: we allow moving objects with no thread affinity to the current thread
+         currentData = d->threadData;
+@@ -2620,7 +2620,7 @@ int QObject::receivers(const char *signal) const
+         if (!d->isSignalConnected(signal_index))
+             return receivers;
+ 
+-        if (d->declarativeData && QAbstractDeclarativeData::receivers) {
++        if (!d->isDeletingChildren && d->declarativeData && QAbstractDeclarativeData::receivers) {
+             receivers += QAbstractDeclarativeData::receivers(d->declarativeData, this,
+                                                              signal_index);
+         }
+diff --git a/qtbase/src/corelib/kernel/qobject_p.h b/qtbase/src/corelib/kernel/qobject_p.h
+index 0b827a52ca..13ffb88999 100644
+--- a/qtbase/src/corelib/kernel/qobject_p.h
++++ b/qtbase/src/corelib/kernel/qobject_p.h
+@@ -444,7 +444,7 @@ inline void QObjectPrivate::checkForIncompatibleLibraryVersion(int version) cons
+ 
+ inline bool QObjectPrivate::isDeclarativeSignalConnected(uint signal_index) const
+ {
+-    return declarativeData && QAbstractDeclarativeData::isSignalConnected
++    return !isDeletingChildren && declarativeData && QAbstractDeclarativeData::isSignalConnected
+             && QAbstractDeclarativeData::isSignalConnected(declarativeData, q_func(), signal_index);
+ }
+ 
+diff --git a/qtbase/src/corelib/kernel/qtranslator.cpp b/qtbase/src/corelib/kernel/qtranslator.cpp
+index 2812ffb7ea..bc0177c5ec 100644
+--- a/qtbase/src/corelib/kernel/qtranslator.cpp
++++ b/qtbase/src/corelib/kernel/qtranslator.cpp
+@@ -902,7 +902,7 @@ static QString getMessage(const uchar *m, const uchar *end, const char *context,
+             goto end;
+         case Tag_Translation: {
+             int len = read32(m);
+-            if (len % 1)
++            if (len & 1)
+                 return QString();
+             m += 4;
+             if (!numerus--) {
+diff --git a/qtbase/src/corelib/mimetypes/qmimedatabase.cpp b/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
+index 9de22cef33..ff868a3268 100644
+--- a/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
+@@ -389,20 +389,23 @@ QMimeType QMimeDatabasePrivate::mimeTypeForFileNameAndData(const QString &fileNa
+         // Disambiguate conflicting extensions (if magic matching found something)
+         if (candidateByData.isValid() && magicAccuracy > 0) {
+             const QString sniffedMime = candidateByData.name();
+-            // If the sniffedMime matches a glob match, use it
++            // If the sniffedMime matches a highest-weight glob match, use it
+             if (candidatesByName.m_matchingMimeTypes.contains(sniffedMime)) {
+                 *accuracyPtr = 100;
+                 return candidateByData;
+             }
+-            for (const QString &m : qAsConst(candidatesByName.m_matchingMimeTypes)) {
++            for (const QString &m : qAsConst(candidatesByName.m_allMatchingMimeTypes)) {
+                 if (inherits(m, sniffedMime)) {
+                     // We have magic + pattern pointing to this, so it's a pretty good match
+                     *accuracyPtr = 100;
+                     return mimeTypeForName(m);
+                 }
+             }
+-            *accuracyPtr = magicAccuracy;
+-            return candidateByData;
++            if (candidatesByName.m_allMatchingMimeTypes.isEmpty()) {
++                // No glob, use magic
++                *accuracyPtr = magicAccuracy;
++                return candidateByData;
++            }
+         }
+     }
+ 
+diff --git a/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp b/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
+index a81112d227..fa8f4c545d 100644
+--- a/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
+@@ -83,7 +83,10 @@ void QMimeGlobMatchResult::addMatch(const QString &mimeType, int weight, const Q
+     }
+     if (!m_matchingMimeTypes.contains(mimeType)) {
+         m_matchingMimeTypes.append(mimeType);
+-        m_allMatchingMimeTypes.append(mimeType);
++        if (replace)
++            m_allMatchingMimeTypes.prepend(mimeType); // highest-weight first
++        else
++            m_allMatchingMimeTypes.append(mimeType);
+         m_knownSuffixLength = knownSuffixLength;
+     }
+ }
+@@ -94,7 +97,7 @@ QMimeGlobPattern::PatternType QMimeGlobPattern::detectPatternType(const QString
+     if (!patternLength)
+         return OtherPattern;
+ 
+-    const bool starCount = pattern.count(QLatin1Char('*')) == 1;
++    const int starCount = pattern.count(QLatin1Char('*'));
+     const bool hasSquareBracket = pattern.indexOf(QLatin1Char('[')) != -1;
+     const bool hasQuestionMark = pattern.indexOf(QLatin1Char('?')) != -1;
+ 
+@@ -106,10 +109,10 @@ QMimeGlobPattern::PatternType QMimeGlobPattern::detectPatternType(const QString
+             // Patterns like "README*" (well this is currently the only one like that...)
+             if (pattern.at(patternLength - 1) == QLatin1Char('*'))
+                 return PrefixPattern;
+-        }
+-        // Names without any wildcards like "README"
+-        if (starCount == 0)
++        } else if (starCount == 0) {
++            // Names without any wildcards like "README"
+             return LiteralPattern;
++        }
+     }
+ 
+     if (pattern == QLatin1String("[0-9][0-9][0-9].vdr"))
+diff --git a/qtbase/src/corelib/mimetypes/qmimeprovider.cpp b/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
+index 258dddf8cb..4642d0f2d0 100644
+--- a/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
+@@ -244,15 +244,18 @@ void QMimeBinaryProvider::addFileNameMatches(const QString &fileName, QMimeGlobM
+     const QString lowerFileName = fileName.toLower();
+     // Check literals (e.g. "Makefile")
+     matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosLiteralListOffset), fileName);
+-    // Check complex globs (e.g. "callgrind.out[0-9]*")
+-    matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosGlobListOffset), fileName);
+     // Check the very common *.txt cases with the suffix tree
+-    const int reverseSuffixTreeOffset = m_cacheFile->getUint32(PosReverseSuffixTreeOffset);
+-    const int numRoots = m_cacheFile->getUint32(reverseSuffixTreeOffset);
+-    const int firstRootOffset = m_cacheFile->getUint32(reverseSuffixTreeOffset + 4);
+-    matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, lowerFileName, lowerFileName.length() - 1, false);
++    if (result.m_matchingMimeTypes.isEmpty()) {
++        const int reverseSuffixTreeOffset = m_cacheFile->getUint32(PosReverseSuffixTreeOffset);
++        const int numRoots = m_cacheFile->getUint32(reverseSuffixTreeOffset);
++        const int firstRootOffset = m_cacheFile->getUint32(reverseSuffixTreeOffset + 4);
++        matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, lowerFileName, lowerFileName.length() - 1, false);
++        if (result.m_matchingMimeTypes.isEmpty())
++            matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, fileName, fileName.length() - 1, true);
++    }
++    // Check complex globs (e.g. "callgrind.out[0-9]*" or "README*")
+     if (result.m_matchingMimeTypes.isEmpty())
+-        matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, fileName, fileName.length() - 1, true);
++        matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosGlobListOffset), fileName);
+ }
+ 
+ void QMimeBinaryProvider::matchGlobList(QMimeGlobMatchResult &result, CacheFile *cacheFile, int off, const QString &fileName)
+diff --git a/qtbase/src/corelib/serialization/qjsonparser.cpp b/qtbase/src/corelib/serialization/qjsonparser.cpp
+index 17e6f111ab..2e40b6c8fb 100644
+--- a/qtbase/src/corelib/serialization/qjsonparser.cpp
++++ b/qtbase/src/corelib/serialization/qjsonparser.cpp
+@@ -379,10 +379,30 @@ error:
+     return QCborValue();
+ }
+ 
++// We need to retain the _last_ value for any duplicate keys and we need to deref containers.
++// Therefore the manual implementation of std::unique().
++template<typename Iterator, typename Compare, typename Assign>
++static Iterator customAssigningUniqueLast(Iterator first, Iterator last,
++                                          Compare compare, Assign assign)
++{
++    first = std::adjacent_find(first, last, compare);
++    if (first == last)
++        return last;
++
++    Iterator result = first;
++    while (++first != last) {
++        if (!compare(*result, *first))
++            ++result;
++        if (result != first)
++            assign(*result, *first);
++    }
++
++    return ++result;
++}
++
+ static void sortContainer(QCborContainerPrivate *container)
+ {
+     using Forward = QJsonPrivate::KeyIterator;
+-    using Reverse = std::reverse_iterator<Forward>;
+     using Value = Forward::value_type;
+ 
+     auto compare = [container](const Value &a, const Value &b)
+@@ -420,17 +440,31 @@ static void sortContainer(QCborContainerPrivate *container)
+         }
+     };
+ 
+-    std::sort(Forward(container->elements.begin()), Forward(container->elements.end()),
+-              [&compare](const Value &a, const Value &b) { return compare(a, b) < 0; });
++    // The elements' containers are owned by the outer container, not by the elements themselves.
++    auto move = [](Forward::reference target, Forward::reference source)
++    {
++        QtCbor::Element &targetValue = target.value();
++
++        // If the target has a container, deref it before overwriting, so that we don't leak.
++        if (targetValue.flags & QtCbor::Element::IsContainer)
++            targetValue.container->deref();
++
++        // Do not move, so that we can clear the value afterwards.
++        target = source;
++
++        // Clear the source value, so that we don't store the same container twice.
++        source.value() = QtCbor::Element();
++    };
++
++    std::stable_sort(
++                Forward(container->elements.begin()), Forward(container->elements.end()),
++                [&compare](const Value &a, const Value &b) { return compare(a, b) < 0; });
+ 
+-    // We need to retain the _last_ value for any duplicate keys. Therefore the reverse dance here.
+-    auto it = std::unique(Reverse(container->elements.end()), Reverse(container->elements.begin()),
+-                          [&compare](const Value &a, const Value &b) {
+-        return compare(a, b) == 0;
+-    }).base().elementsIterator();
++    Forward result = customAssigningUniqueLast(
++                Forward(container->elements.begin()),  Forward(container->elements.end()),
++                [&compare](const Value &a, const Value &b) { return compare(a, b) == 0; }, move);
+ 
+-    // The erase from beginning is expensive but hopefully rare.
+-    container->elements.erase(container->elements.begin(), it);
++    container->elements.erase(result.elementsIterator(), container->elements.end());
+ }
+ 
+ 
+diff --git a/qtbase/src/corelib/serialization/qxmlstream.cpp b/qtbase/src/corelib/serialization/qxmlstream.cpp
+index b2f846544d..7cd457ba3a 100644
+--- a/qtbase/src/corelib/serialization/qxmlstream.cpp
++++ b/qtbase/src/corelib/serialization/qxmlstream.cpp
+@@ -980,7 +980,7 @@ inline uint QXmlStreamReaderPrivate::peekChar()
+ bool QXmlStreamReaderPrivate::scanUntil(const char *str, short tokenToInject)
+ {
+     int pos = textBuffer.size();
+-    int oldLineNumber = lineNumber;
++    const auto oldLineNumber = lineNumber;
+ 
+     uint c;
+     while ((c = getChar()) != StreamEOF) {
+diff --git a/qtbase/src/corelib/text/qstring.cpp b/qtbase/src/corelib/text/qstring.cpp
+index 3e88ab4859..8deeae47bb 100644
+--- a/qtbase/src/corelib/text/qstring.cpp
++++ b/qtbase/src/corelib/text/qstring.cpp
+@@ -12312,7 +12312,7 @@ static qsizetype qLastIndexOf(Haystack haystack0, qsizetype from,
+     const auto needle = needle0.data();
+     const auto *end = haystack;
+     haystack += from;
+-    const std::size_t sl_minus_1 = sl - 1;
++    const std::size_t sl_minus_1 = sl ? sl - 1 : 0;
+     const auto *n = needle + sl_minus_1;
+     const auto *h = haystack + sl_minus_1;
+     std::size_t hashNeedle = 0, hashHaystack = 0;
+diff --git a/qtbase/src/corelib/text/qstringiterator_p.h b/qtbase/src/corelib/text/qstringiterator_p.h
+index 219589b6e4..1d0c66cc78 100644
+--- a/qtbase/src/corelib/text/qstringiterator_p.h
++++ b/qtbase/src/corelib/text/qstringiterator_p.h
+@@ -61,6 +61,8 @@ class QStringIterator
+ {
+     QString::const_iterator i, pos, e;
+     Q_STATIC_ASSERT((std::is_same<QString::const_iterator, const QChar *>::value));
++    static bool less(const QChar *lhs, const QChar *rhs) noexcept
++    { return std::less<QString::const_iterator>{}(lhs, rhs); }
+ public:
+     explicit QStringIterator(QStringView string, qsizetype idx = 0)
+         : i(string.begin()),
+@@ -95,7 +97,8 @@ public:
+ 
+     inline void setPosition(QString::const_iterator position)
+     {
+-        Q_ASSERT_X(i <= position && position <= e, Q_FUNC_INFO, "position out of bounds");
++        Q_ASSERT_X(!less(position, i) && !less(e, position),
++                   Q_FUNC_INFO, "position out of bounds");
+         pos = position;
+     }
+ 
+@@ -103,7 +106,7 @@ public:
+ 
+     inline bool hasNext() const
+     {
+-        return pos < e;
++        return less(pos, e);
+     }
+ 
+     inline void advance()
+@@ -120,16 +123,20 @@ public:
+     {
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+-        if (Q_UNLIKELY((pos++)->isHighSurrogate()))
++        if (Q_UNLIKELY((pos++)->isHighSurrogate())) {
++            Q_ASSERT(hasNext() && pos->isLowSurrogate());
+             ++pos;
++        }
+     }
+ 
+     inline uint peekNextUnchecked() const
+     {
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+-        if (Q_UNLIKELY(pos->isHighSurrogate()))
++        if (Q_UNLIKELY(pos->isHighSurrogate())) {
++            Q_ASSERT(less(pos + 1, e) && pos[1].isLowSurrogate());
+             return QChar::surrogateToUcs4(pos[0], pos[1]);
++        }
+ 
+         return pos->unicode();
+     }
+@@ -155,8 +162,10 @@ public:
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+         const QChar cur = *pos++;
+-        if (Q_UNLIKELY(cur.isHighSurrogate()))
++        if (Q_UNLIKELY(cur.isHighSurrogate())) {
++            Q_ASSERT(hasNext() && pos->isLowSurrogate());
+             return QChar::surrogateToUcs4(cur, *pos++);
++        }
+         return cur.unicode();
+     }
+ 
+@@ -166,7 +175,7 @@ public:
+ 
+         const QChar uc = *pos++;
+         if (Q_UNLIKELY(uc.isSurrogate())) {
+-            if (Q_LIKELY(uc.isHighSurrogate() && pos < e && pos->isLowSurrogate()))
++            if (Q_LIKELY(uc.isHighSurrogate() && hasNext() && pos->isLowSurrogate()))
+                 return QChar::surrogateToUcs4(uc, *pos++);
+             return invalidAs;
+         }
+@@ -178,7 +187,7 @@ public:
+ 
+     inline bool hasPrevious() const
+     {
+-        return pos > i;
++        return less(i, pos);
+     }
+ 
+     inline void recede()
+@@ -196,16 +205,20 @@ public:
+     {
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+-        if (Q_UNLIKELY((--pos)->isLowSurrogate()))
++        if (Q_UNLIKELY((--pos)->isLowSurrogate())) {
++            Q_ASSERT(hasPrevious() && pos[-1].isHighSurrogate());
+             --pos;
++        }
+     }
+ 
+     inline uint peekPreviousUnchecked() const
+     {
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+-        if (Q_UNLIKELY(pos[-1].isLowSurrogate()))
++        if (Q_UNLIKELY(pos[-1].isLowSurrogate())) {
++            Q_ASSERT(less(i + 1, pos) && pos[-2].isHighSurrogate());
+             return QChar::surrogateToUcs4(pos[-2], pos[-1]);
++        }
+         return pos[-1].unicode();
+     }
+ 
+@@ -230,8 +243,10 @@ public:
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+         const QChar cur = *--pos;
+-        if (Q_UNLIKELY(cur.isLowSurrogate()))
++        if (Q_UNLIKELY(cur.isLowSurrogate())) {
++            Q_ASSERT(hasPrevious() && pos[-1].isHighSurrogate());
+             return QChar::surrogateToUcs4(*--pos, cur);
++        }
+         return cur.unicode();
+     }
+ 
+@@ -241,7 +256,7 @@ public:
+ 
+         const QChar uc = *--pos;
+         if (Q_UNLIKELY(uc.isSurrogate())) {
+-            if (Q_LIKELY(uc.isLowSurrogate() && pos > i && pos[-1].isHighSurrogate()))
++            if (Q_LIKELY(uc.isLowSurrogate() && hasPrevious() && pos[-1].isHighSurrogate()))
+                 return QChar::surrogateToUcs4(*--pos, uc);
+             return invalidAs;
+         }
+diff --git a/qtbase/src/corelib/thread/qfutex_p.h b/qtbase/src/corelib/thread/qfutex_p.h
+index f287b752d7..e294537787 100644
+--- a/qtbase/src/corelib/thread/qfutex_p.h
++++ b/qtbase/src/corelib/thread/qfutex_p.h
+@@ -52,6 +52,7 @@
+ //
+ 
+ #include <qglobal.h>
++#include <QtCore/qtsan_impl.h>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -106,16 +107,13 @@ namespace QtLinuxFutex {
+     inline int _q_futex(int *addr, int op, int val, quintptr val2 = 0,
+                         int *addr2 = nullptr, int val3 = 0) noexcept
+     {
+-        // A futex call ensures total ordering on the futex words
+-        // (in either success or failure of the call). Instruct TSAN accordingly,
+-        // as TSAN does not understand the futex(2) syscall.
+-        _q_tsan_release(addr, addr2);
++        QtTsan::futexRelease(addr, addr2);
+ 
+         // we use __NR_futex because some libcs (like Android's bionic) don't
+         // provide SYS_futex etc.
+         int result = syscall(__NR_futex, addr, op | FUTEX_PRIVATE_FLAG, val, val2, addr2, val3);
+ 
+-        _q_tsan_acquire(addr, addr2);
++        QtTsan::futexAcquire(addr, addr2);
+ 
+         return result;
+     }
+diff --git a/qtbase/src/corelib/thread/qmutex.cpp b/qtbase/src/corelib/thread/qmutex.cpp
+index 310d1cb14f..7097122d8e 100644
+--- a/qtbase/src/corelib/thread/qmutex.cpp
++++ b/qtbase/src/corelib/thread/qmutex.cpp
+@@ -152,6 +152,7 @@ public:
+ 
+ /*!
+     \enum QMutex::RecursionMode
++    \obsolete Use QRecursiveMutex to create a recursive mutex.
+ 
+     \value Recursive  In this mode, a thread can lock the same mutex
+                       multiple times and the mutex won't be unlocked
+@@ -173,6 +174,7 @@ public:
+ 
+ /*!
+     Constructs a new mutex. The mutex is created in an unlocked state.
++    \obsolete Use QRecursiveMutex to create a recursive mutex.
+ 
+     If \a mode is QMutex::Recursive, a thread can lock the same mutex
+     multiple times and the mutex won't be unlocked until a
+@@ -197,7 +199,7 @@ QMutex::QMutex(RecursionMode mode)
+ QMutex::~QMutex()
+ {
+     QMutexData *d = d_ptr.loadRelaxed();
+-    if (isRecursive()) {
++    if (QBasicMutex::isRecursive()) {
+         delete static_cast<QRecursiveMutexPrivate *>(d);
+     } else if (d) {
+ #ifndef QT_LINUX_FUTEX
+diff --git a/qtbase/src/corelib/thread/qmutex.h b/qtbase/src/corelib/thread/qmutex.h
+index 73c9e00663..1bae573a03 100644
+--- a/qtbase/src/corelib/thread/qmutex.h
++++ b/qtbase/src/corelib/thread/qmutex.h
+@@ -42,6 +42,7 @@
+ 
+ #include <QtCore/qglobal.h>
+ #include <QtCore/qatomic.h>
++#include <QtCore/qtsan_impl.h>
+ #include <new>
+ 
+ #if __has_include(<chrono>)
+@@ -77,19 +78,37 @@ public:
+ 
+     // BasicLockable concept
+     inline void lock() QT_MUTEX_LOCK_NOEXCEPT {
++        QtTsan::mutexPreLock(this, 0u);
++
+         if (!fastTryLock())
+             lockInternal();
++
++        QtTsan::mutexPostLock(this, 0u, 0);
+     }
+ 
+     // BasicLockable concept
+     inline void unlock() noexcept {
+         Q_ASSERT(d_ptr.loadRelaxed()); //mutex must be locked
++
++        QtTsan::mutexPreUnlock(this, 0u);
++
+         if (!fastTryUnlock())
+             unlockInternal();
++
++        QtTsan::mutexPostUnlock(this, 0u);
+     }
+ 
+     bool tryLock() noexcept {
+-        return fastTryLock();
++        unsigned tsanFlags = QtTsan::TryLock;
++        QtTsan::mutexPreLock(this, tsanFlags);
++
++        const bool success = fastTryLock();
++
++        if (!success)
++            tsanFlags |= QtTsan::TryLockFailed;
++        QtTsan::mutexPostLock(this, tsanFlags, 0);
++
++        return success;
+     }
+ 
+     // Lockable concept
+@@ -134,8 +153,16 @@ public:
+ #else
+     QMutex() { d_ptr.storeRelaxed(nullptr); }
+ #endif
++#if QT_DEPRECATED_SINCE(5,15)
+     enum RecursionMode { NonRecursive, Recursive };
++    QT_DEPRECATED_VERSION_X(5, 15, "Use QRecursiveMutex instead of a recursive QMutex")
+     explicit QMutex(RecursionMode mode);
++
++    QT_DEPRECATED_VERSION_X(5, 15, "Use QRecursiveMutex instead of a recursive QMutex")
++    bool isRecursive() const noexcept
++    { return QBasicMutex::isRecursive(); }
++#endif
++
+     ~QMutex();
+ 
+     // BasicLockable concept
+@@ -166,9 +193,6 @@ public:
+     }
+ #endif
+ 
+-    bool isRecursive() const noexcept
+-    { return QBasicMutex::isRecursive(); }
+-
+ private:
+     Q_DISABLE_COPY(QMutex)
+     friend class QMutexLocker;
+diff --git a/qtbase/src/corelib/thread/qreadwritelock.cpp b/qtbase/src/corelib/thread/qreadwritelock.cpp
+index 8c28507d5a..9dd8503116 100644
+--- a/qtbase/src/corelib/thread/qreadwritelock.cpp
++++ b/qtbase/src/corelib/thread/qreadwritelock.cpp
+@@ -155,7 +155,7 @@ QReadWriteLock::QReadWriteLock(RecursionMode recursionMode)
+ */
+ QReadWriteLock::~QReadWriteLock()
+ {
+-    auto d = d_ptr.loadRelaxed();
++    auto d = d_ptr.loadAcquire();
+     if (isUncontendedLocked(d)) {
+         qWarning("QReadWriteLock: destroying locked QReadWriteLock");
+         return;
+@@ -445,7 +445,7 @@ void QReadWriteLock::unlock()
+ /*! \internal  Helper for QWaitCondition::wait */
+ QReadWriteLock::StateForWaitCondition QReadWriteLock::stateForWaitCondition() const
+ {
+-    QReadWriteLockPrivate *d = d_ptr.loadRelaxed();
++    QReadWriteLockPrivate *d = d_ptr.loadAcquire();
+     switch (quintptr(d) & StateMask) {
+     case StateLockedForRead: return LockedForRead;
+     case StateLockedForWrite: return LockedForWrite;
+@@ -453,6 +453,7 @@ QReadWriteLock::StateForWaitCondition QReadWriteLock::stateForWaitCondition() co
+ 
+     if (!d)
+         return Unlocked;
++    const auto lock = qt_scoped_lock(d->mutex);
+     if (d->writerCount > 1)
+         return RecursivelyLocked;
+     else if (d->writerCount == 1)
+diff --git a/qtbase/src/corelib/thread/qsemaphore.cpp b/qtbase/src/corelib/thread/qsemaphore.cpp
+index 1d01fc1b28..3ecdee3747 100644
+--- a/qtbase/src/corelib/thread/qsemaphore.cpp
++++ b/qtbase/src/corelib/thread/qsemaphore.cpp
+@@ -354,7 +354,12 @@ void QSemaphore::release(int n)
+         quintptr nn = unsigned(n);
+         if (futexHasWaiterCount)
+             nn |= quint64(nn) << 32;    // token count replicated in high word
+-        quintptr prevValue = u.fetchAndAddRelease(nn);
++        quintptr prevValue = u.loadRelaxed();
++        quintptr newValue;
++        do { // loop just to ensure the operations are done atomically
++            newValue = prevValue + nn;
++            newValue &= (futexNeedsWakeAllBit - 1);
++        } while (!u.testAndSetRelease(prevValue, newValue, prevValue));
+         if (futexNeedsWake(prevValue)) {
+ #ifdef FUTEX_OP
+             if (futexHasWaiterCount) {
+@@ -376,7 +381,6 @@ void QSemaphore::release(int n)
+                 quint32 oparg = 0;
+                 quint32 cmp = FUTEX_OP_CMP_NE;
+                 quint32 cmparg = 0;
+-                u.fetchAndAndRelease(futexNeedsWakeAllBit - 1);
+                 futexWakeOp(*futexLow32(&u), n, INT_MAX, *futexHigh32(&u), FUTEX_OP(op, oparg, cmp, cmparg));
+                 return;
+             }
+@@ -388,7 +392,6 @@ 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(futexNeedsWakeAllBit - 1);
+             if (futexHasWaiterCount) {
+                 futexWakeAll(*futexLow32(&u));
+                 futexWakeAll(*futexHigh32(&u));
+diff --git a/qtbase/src/corelib/thread/qthread_p.h b/qtbase/src/corelib/thread/qthread_p.h
+index b2d1628e6e..f32f6f0460 100644
+--- a/qtbase/src/corelib/thread/qthread_p.h
++++ b/qtbase/src/corelib/thread/qthread_p.h
+@@ -174,7 +174,7 @@ public:
+     int returnCode;
+ 
+     uint stackSize;
+-    QThread::Priority priority;
++    std::underlying_type<QThread::Priority>::type priority;
+ 
+     static QThread *threadForId(int id);
+ 
+@@ -213,6 +213,13 @@ public:
+             QCoreApplication::instance()->postEvent(q_ptr, new QEvent(QEvent::Quit));
+         }
+     }
++
++#ifndef Q_OS_INTEGRITY
++private:
++    // Used in QThread(Private)::start to avoid racy access to QObject::objectName,
++    // unset afterwards. On INTEGRITY we set the thread name before starting it.
++    QString objectName;
++#endif
+ };
+ 
+ #else // QT_CONFIG(thread)
+diff --git a/qtbase/src/corelib/thread/qthread_unix.cpp b/qtbase/src/corelib/thread/qthread_unix.cpp
+index 56a8e0a038..610117a640 100644
+--- a/qtbase/src/corelib/thread/qthread_unix.cpp
++++ b/qtbase/src/corelib/thread/qthread_unix.cpp
+@@ -169,8 +169,7 @@ static void set_thread_data(QThreadData *data)
+ 
+ static void clear_thread_data()
+ {
+-    currentThreadData = nullptr;
+-    pthread_setspecific(current_thread_data_key, nullptr);
++    set_thread_data(nullptr);
+ }
+ 
+ template <typename T>
+@@ -296,7 +295,7 @@ void *QThreadPrivate::start(void *arg)
+             QMutexLocker locker(&thr->d_func()->mutex);
+ 
+             // do we need to reset the thread priority?
+-            if (int(thr->d_func()->priority) & ThreadPriorityResetFlag) {
++            if (thr->d_func()->priority & ThreadPriorityResetFlag) {
+                 thr->d_func()->setPriority(QThread::Priority(thr->d_func()->priority & ~ThreadPriorityResetFlag));
+             }
+ 
+@@ -316,10 +315,10 @@ void *QThreadPrivate::start(void *arg)
+             // Sets the name of the current thread. We can only do this
+             // when the thread is starting, as we don't have a cross
+             // platform way of setting the name of an arbitrary thread.
+-            if (Q_LIKELY(thr->objectName().isEmpty()))
++            if (Q_LIKELY(thr->d_func()->objectName.isEmpty()))
+                 setCurrentThreadName(thr->metaObject()->className());
+             else
+-                setCurrentThreadName(thr->objectName().toLocal8Bit());
++                setCurrentThreadName(std::exchange(thr->d_func()->objectName, {}).toLocal8Bit());
+         }
+ #endif
+ 
+@@ -671,7 +670,7 @@ void QThread::start(Priority priority)
+                 // could not set scheduling hints, fallback to inheriting them
+                 // we'll try again from inside the thread
+                 pthread_attr_setinheritsched(&attr, PTHREAD_INHERIT_SCHED);
+-                d->priority = Priority(priority | ThreadPriorityResetFlag);
++                d->priority = static_cast<std::underlying_type<QThread::Priority>::type>(priority) | ThreadPriorityResetFlag;
+             }
+             break;
+         }
+@@ -702,7 +701,10 @@ void QThread::start(Priority priority)
+         pthread_attr_setthreadname(&attr, metaObject()->className());
+     else
+         pthread_attr_setthreadname(&attr, objectName().toLocal8Bit());
++#else
++    d->objectName = objectName();
+ #endif
++
+     pthread_t threadId;
+     int code = pthread_create(&threadId, &attr, QThreadPrivate::start, this);
+     if (code == EPERM) {
+diff --git a/qtbase/src/corelib/thread/qthread_win.cpp b/qtbase/src/corelib/thread/qthread_win.cpp
+index bc70e3178a..4e76972498 100644
+--- a/qtbase/src/corelib/thread/qthread_win.cpp
++++ b/qtbase/src/corelib/thread/qthread_win.cpp
+@@ -394,10 +394,9 @@ unsigned int __stdcall QT_ENSURE_STACK_ALIGNED_FOR_SSE QThreadPrivate::start(voi
+ 
+ #if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) && !defined(Q_OS_WINRT)
+     // sets the name of the current thread.
+-    QByteArray objectName = thr->objectName().toLocal8Bit();
+-    qt_set_thread_name(HANDLE(-1),
+-                       objectName.isEmpty() ?
+-                       thr->metaObject()->className() : objectName.constData());
++    qt_set_thread_name(HANDLE(-1), thr->d_func()->objectName.isEmpty()
++                        ? thr->metaObject()->className()
++                        : std::exchange(thr->d_func()->objectName, {}).toLocal8Bit().constData());
+ #endif
+ 
+     emit thr->started(QThread::QPrivateSignal());
+@@ -503,6 +502,7 @@ void QThread::start(Priority priority)
+     if (d->running)
+         return;
+ 
++    d->objectName = objectName();
+     d->running = true;
+     d->finished = false;
+     d->exited = false;
+@@ -548,7 +548,7 @@ void QThread::start(Priority priority)
+ 
+     int prio;
+     d->priority = priority;
+-    switch (d->priority) {
++    switch (priority) {
+     case IdlePriority:
+         prio = THREAD_PRIORITY_IDLE;
+         break;
+@@ -686,7 +686,7 @@ void QThreadPrivate::setPriority(QThread::Priority threadPriority)
+ 
+     int prio;
+     priority = threadPriority;
+-    switch (priority) {
++    switch (threadPriority) {
+     case QThread::IdlePriority:
+         prio = THREAD_PRIORITY_IDLE;
+         break;
+diff --git a/qtbase/src/corelib/thread/qtsan_impl.h b/qtbase/src/corelib/thread/qtsan_impl.h
+new file mode 100644
+index 0000000000..580a738b91
+--- /dev/null
++++ b/qtbase/src/corelib/thread/qtsan_impl.h
+@@ -0,0 +1,115 @@
++/****************************************************************************
++**
++** Copyright (C) 2017 Intel Corporation.
++** Copyright (C) 2022 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
++** 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 QTSAN_IMPL_H
++#define QTSAN_IMPL_H
++
++#include <QtCore/qglobal.h>
++
++#if (__has_feature(thread_sanitizer) || defined(__SANITIZE_THREAD__)) && __has_include(<sanitizer/tsan_interface.h>)
++#  define QT_BUILDING_UNDER_TSAN
++#  include <sanitizer/tsan_interface.h>
++#endif
++
++QT_BEGIN_NAMESPACE
++
++namespace QtTsan {
++#ifdef QT_BUILDING_UNDER_TSAN
++inline void futexAcquire(void *addr, void *addr2 = nullptr)
++{
++    // A futex call ensures total ordering on the futex words
++    // (in either success or failure of the call). Instruct TSAN accordingly,
++    // as TSAN does not understand the futex(2) syscall (or equivalent).
++    ::__tsan_acquire(addr);
++    if (addr2)
++        ::__tsan_acquire(addr2);
++}
++
++inline void futexRelease(void *addr, void *addr2 = nullptr)
++{
++    if (addr2)
++        ::__tsan_release(addr2);
++    ::__tsan_release(addr);
++}
++
++inline void mutexPreLock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_pre_lock(addr, flags);
++}
++
++inline void mutexPostLock(void *addr, unsigned flags, int recursion)
++{
++    ::__tsan_mutex_post_lock(addr, flags, recursion);
++}
++
++inline void mutexPreUnlock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_pre_unlock(addr, flags);
++}
++
++inline void mutexPostUnlock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_post_unlock(addr, flags);
++}
++
++enum : unsigned {
++    MutexWriteReentrant = ::__tsan_mutex_write_reentrant,
++    TryLock = ::__tsan_mutex_try_lock,
++    TryLockFailed = ::__tsan_mutex_try_lock_failed,
++};
++#else
++inline void futexAcquire(void *, void * = nullptr) {}
++inline void futexRelease(void *, void * = nullptr) {}
++
++enum : unsigned {
++    MutexWriteReentrant,
++    TryLock,
++    TryLockFailed,
++};
++inline void mutexPreLock(void *, unsigned) {}
++inline void mutexPostLock(void *, unsigned, int) {}
++inline void mutexPreUnlock(void *, unsigned) {}
++inline void mutexPostUnlock(void *, unsigned) {}
++#endif // QT_BUILDING_UNDER_TSAN
++} // namespace QtTsan
++
++QT_END_NAMESPACE
++
++#endif // QTSAN_IMPL_H
+diff --git a/qtbase/src/corelib/thread/qwaitcondition_unix.cpp b/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
+index 88b058f410..0f1da4dc9b 100644
+--- a/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
++++ b/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
+@@ -213,7 +213,7 @@ bool QWaitCondition::wait(QMutex *mutex, QDeadlineTimer deadline)
+ {
+     if (! mutex)
+         return false;
+-    if (mutex->isRecursive()) {
++    if (static_cast<QBasicMutex *>(mutex)->isRecursive()) {
+         qWarning("QWaitCondition: cannot wait on recursive mutexes");
+         return false;
+     }
+diff --git a/qtbase/src/corelib/time/qdatetime.cpp b/qtbase/src/corelib/time/qdatetime.cpp
+index ec12569e3f..2c0b098079 100644
+--- a/qtbase/src/corelib/time/qdatetime.cpp
++++ b/qtbase/src/corelib/time/qdatetime.cpp
+@@ -43,6 +43,7 @@
+ #if QT_CONFIG(datetimeparser)
+ #include "private/qdatetimeparser_p.h"
+ #endif
++#include <private/qnumeric_p.h>
+ 
+ #include "qdatastream.h"
+ #include "qset.h"
+@@ -1429,9 +1430,11 @@ QDate QDate::addDays(qint64 ndays) const
+     if (isNull())
+         return QDate();
+ 
+-    // Due to limits on minJd() and maxJd() we know that any overflow
+-    // will be invalid and caught by fromJulianDay().
+-    return fromJulianDay(jd + ndays);
++    qint64 r;
++    if (Q_UNLIKELY(add_overflow(jd, ndays, &r)))
++        return QDate();
++    else
++        return fromJulianDay(r);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/corelib/time/qtimezone.cpp b/qtbase/src/corelib/time/qtimezone.cpp
+index 0309e43e52..3d451696a1 100644
+--- a/qtbase/src/corelib/time/qtimezone.cpp
++++ b/qtbase/src/corelib/time/qtimezone.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2013 John Layt <jlayt@kde.org>
++** Copyright (C) 2020 John Layt <jlayt@kde.org>
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtCore module of the Qt Toolkit.
+@@ -975,9 +975,15 @@ QList<QByteArray> QTimeZone::windowsIdToIanaIds(const QByteArray &windowsId,
+ }
+ 
+ #ifndef QT_NO_DATASTREAM
++// Invalid, as an IANA ID: too long, starts with - and has other invalid characters in it
++static inline QString invalidId() { return QStringLiteral("-No Time Zone Specified!"); }
++
+ QDataStream &operator<<(QDataStream &ds, const QTimeZone &tz)
+ {
+-    tz.d->serialize(ds);
++    if (tz.isValid())
++        tz.d->serialize(ds);
++    else
++        ds << invalidId();
+     return ds;
+ }
+ 
+@@ -985,7 +991,9 @@ QDataStream &operator>>(QDataStream &ds, QTimeZone &tz)
+ {
+     QString ianaId;
+     ds >> ianaId;
+-    if (ianaId == QLatin1String("OffsetFromUtc")) {
++    if (ianaId == invalidId()) {
++        tz = QTimeZone();
++    } else if (ianaId == QLatin1String("OffsetFromUtc")) {
+         int utcOffset;
+         QString name;
+         QString abbreviation;
+diff --git a/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp b/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
+index b1611d7ddb..a7a6a72ccf 100644
+--- a/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
++++ b/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
+@@ -42,6 +42,7 @@
+ #include "qtimezone.h"
+ #include "qtimezoneprivate_p.h"
+ #include "private/qlocale_tools_p.h"
++#include "private/qlocking_p.h"
+ 
+ #include <QtCore/QDataStream>
+ #include <QtCore/QDateTime>
+@@ -62,6 +63,10 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++#if QT_CONFIG(icu)
++static QBasicMutex s_icu_mutex;
++#endif
++
+ /*
+     Private
+ 
+@@ -670,6 +675,9 @@ QTzTimeZonePrivate::~QTzTimeZonePrivate()
+ 
+ QTzTimeZonePrivate *QTzTimeZonePrivate::clone() const
+ {
++#if QT_CONFIG(icu)
++    const auto lock = qt_scoped_lock(s_icu_mutex);
++#endif
+     return new QTzTimeZonePrivate(*this);
+ }
+ 
+@@ -913,12 +921,14 @@ QString QTzTimeZonePrivate::displayName(qint64 atMSecsSinceEpoch,
+                                         const QLocale &locale) const
+ {
+ #if QT_CONFIG(icu)
++    auto lock = qt_unique_lock(s_icu_mutex);
+     if (!m_icu)
+         m_icu = new QIcuTimeZonePrivate(m_id);
+     // TODO small risk may not match if tran times differ due to outdated files
+     // TODO Some valid TZ names are not valid ICU names, use translation table?
+     if (m_icu->isValid())
+         return m_icu->displayName(atMSecsSinceEpoch, nameType, locale);
++    lock.unlock();
+ #else
+     Q_UNUSED(nameType)
+     Q_UNUSED(locale)
+@@ -932,12 +942,14 @@ QString QTzTimeZonePrivate::displayName(QTimeZone::TimeType timeType,
+                                         const QLocale &locale) const
+ {
+ #if QT_CONFIG(icu)
++    auto lock = qt_unique_lock(s_icu_mutex);
+     if (!m_icu)
+         m_icu = new QIcuTimeZonePrivate(m_id);
+     // TODO small risk may not match if tran times differ due to outdated files
+     // TODO Some valid TZ names are not valid ICU names, use translation table?
+     if (m_icu->isValid())
+         return m_icu->displayName(timeType, nameType, locale);
++    lock.unlock();
+ #else
+     Q_UNUSED(timeType)
+     Q_UNUSED(nameType)
+diff --git a/qtbase/src/corelib/tools/qarraydata.h b/qtbase/src/corelib/tools/qarraydata.h
+index dcd95924c1..d01739e7e6 100644
+--- a/qtbase/src/corelib/tools/qarraydata.h
++++ b/qtbase/src/corelib/tools/qarraydata.h
+@@ -42,6 +42,7 @@
+ 
+ #include <QtCore/qrefcount.h>
+ #include <string.h>
++#include <cstdint>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -58,14 +59,14 @@ struct Q_CORE_EXPORT QArrayData
+     {
+         Q_ASSERT(size == 0
+                 || offset < 0 || size_t(offset) >= sizeof(QArrayData));
+-        return reinterpret_cast<char *>(this) + offset;
++        return reinterpret_cast<void *> (reinterpret_cast<uintptr_t>(this) + offset);
+     }
+ 
+     const void *data() const
+     {
+         Q_ASSERT(size == 0
+                 || offset < 0 || size_t(offset) >= sizeof(QArrayData));
+-        return reinterpret_cast<const char *>(this) + offset;
++        return reinterpret_cast<void *> (reinterpret_cast<uintptr_t>(this) + offset);
+     }
+ 
+     // This refers to array data mutability, not "header data" represented by
+diff --git a/qtbase/src/corelib/tools/qfreelist_p.h b/qtbase/src/corelib/tools/qfreelist_p.h
+index 5ba23b344b..9974102136 100644
+--- a/qtbase/src/corelib/tools/qfreelist_p.h
++++ b/qtbase/src/corelib/tools/qfreelist_p.h
+@@ -161,7 +161,7 @@ class QFreeList
+                 return i;
+             x -= size;
+         }
+-        Q_ASSERT(false);
++        Q_UNREACHABLE();
+         return -1;
+     }
+ 
+diff --git a/qtbase/src/corelib/tools/qversionnumber.h b/qtbase/src/corelib/tools/qversionnumber.h
+index d43b86ba51..2843f2b043 100644
+--- a/qtbase/src/corelib/tools/qversionnumber.h
++++ b/qtbase/src/corelib/tools/qversionnumber.h
+@@ -273,10 +273,10 @@ public:
+ 
+     Q_REQUIRED_RESULT Q_CORE_EXPORT QString toString() const;
+ #if QT_STRINGVIEW_LEVEL < 2
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(const QString &string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(const QString &string, int *suffixIndex = nullptr);
+ #endif
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QLatin1String string, int *suffixIndex = nullptr);
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QStringView string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(QLatin1String string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(QStringView string, int *suffixIndex = nullptr);
+ 
+ private:
+ #ifndef QT_NO_DATASTREAM
+diff --git a/qtbase/src/dbus/qdbusintegrator.cpp b/qtbase/src/dbus/qdbusintegrator.cpp
+index 5b66ce971b..28a3b0ffea 100644
+--- a/qtbase/src/dbus/qdbusintegrator.cpp
++++ b/qtbase/src/dbus/qdbusintegrator.cpp
+@@ -1135,7 +1135,13 @@ void QDBusConnectionPrivate::closeConnection()
+         }
+     }
+ 
+-    qDeleteAll(pendingCalls);
++    for (auto it = pendingCalls.begin(); it != pendingCalls.end(); ++it) {
++        auto call = *it;
++        if (!call->ref.deref()) {
++            delete call;
++        }
++    }
++    pendingCalls.clear();
+ 
+     // Disconnect all signals from signal hooks and from the object tree to
+     // avoid QObject::destroyed being sent to dbus daemon thread which has
+@@ -2584,6 +2590,11 @@ QDBusConnectionPrivate::findMetaObject(const QString &service, const QString &pa
+         if (mo)
+             return mo;
+     }
++    if (path.isEmpty()) {
++        error = QDBusError(QDBusError::InvalidObjectPath, QLatin1String("Object path cannot be empty"));
++        lastError = error;
++        return nullptr;
++    }
+ 
+     // introspect the target object
+     QDBusMessage msg = QDBusMessage::createMethodCall(service, path,
+diff --git a/qtbase/src/dbus/qdbusmetaobject.cpp b/qtbase/src/dbus/qdbusmetaobject.cpp
+index 5265568f42..7e9f0f1acc 100644
+--- a/qtbase/src/dbus/qdbusmetaobject.cpp
++++ b/qtbase/src/dbus/qdbusmetaobject.cpp
+@@ -210,6 +210,9 @@ QDBusMetaObjectGenerator::findType(const QByteArray &signature,
+         } else if (signature == "a{ss}") {
+             result.name = "QMap<QString,QString>";
+             type = qMetaTypeId<QMap<QString, QString> >();
++        } else if (signature == "aay") {
++            result.name = "QByteArrayList";
++            type = qMetaTypeId<QByteArrayList>();
+         } else {
+             result.name = "{D-Bus type \"" + signature + "\"}";
+             type = registerComplexDBusType(result.name);
+diff --git a/qtbase/src/gui/accessible/qaccessible.cpp b/qtbase/src/gui/accessible/qaccessible.cpp
+index d705bfccb5..0caf3c808c 100644
+--- a/qtbase/src/gui/accessible/qaccessible.cpp
++++ b/qtbase/src/gui/accessible/qaccessible.cpp
+@@ -54,6 +54,7 @@
+ #include <QtCore/qdebug.h>
+ #include <QtCore/qloggingcategory.h>
+ #include <QtCore/qmetaobject.h>
++#include <QtCore/private/qmetaobject_p.h>
+ #include <QtCore/qhash.h>
+ #include <private/qfactoryloader_p.h>
+ 
+@@ -681,6 +682,25 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
+     // Create a QAccessibleInterface for the object class. Start by the most
+     // derived class and walk up the class hierarchy.
+     const QMetaObject *mo = object->metaObject();
++    const auto *objectPriv = QObjectPrivate::get(object);
++    /*
++     We do not want to cache each and every QML metaobject (Button_QMLTYPE_124,
++     Button_QMLTYPE_125, etc.). Those dynamic metaobjects shouldn't have an
++     accessible interface in any case. Instead, we start the whole checking
++     with the first non-dynamic meta-object. To avoid potential regressions
++     in other areas of Qt that also use dynamic metaobjects, we only do this
++     for objects that are QML-related (approximated by checking whether they
++     have ddata set).
++    */
++    const bool qmlRelated = !objectPriv->isDeletingChildren &&
++                            objectPriv->declarativeData;
++    while (qmlRelated && mo) {
++        auto mop = QMetaObjectPrivate::get(mo);
++        if (!mop || !(mop->flags & DynamicMetaObject))
++            break;
++
++        mo = mo->superClass();
++    };
+     while (mo) {
+         const QString cn = QLatin1String(mo->className());
+ 
+@@ -696,14 +716,15 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
+         // Find a QAccessiblePlugin (factory) for the class name. If there's
+         // no entry in the cache try to create it using the plugin loader.
+         if (!qAccessiblePlugins()->contains(cn)) {
++            QAccessiblePlugin *factory = nullptr; // 0 means "no plugin found". This is cached as well.
+             const int index = loader()->indexOf(cn);
+-            if (index != -1) {
+-                QAccessiblePlugin *factory = qobject_cast<QAccessiblePlugin *>(loader()->instance(index));
+-                qAccessiblePlugins()->insert(cn, factory);
+-            }
++            if (index != -1)
++                factory = qobject_cast<QAccessiblePlugin *>(loader()->instance(index));
++            qAccessiblePlugins()->insert(cn, factory);
+         }
+ 
+         // At this point the cache should contain a valid factory pointer or 0:
++        Q_ASSERT(qAccessiblePlugins()->contains(cn));
+         QAccessiblePlugin *factory = qAccessiblePlugins()->value(cn);
+         if (factory) {
+             QAccessibleInterface *result = factory->create(cn, object);
+diff --git a/qtbase/src/gui/configure.json b/qtbase/src/gui/configure.json
+index 1f08795c57..12c95742d2 100644
+--- a/qtbase/src/gui/configure.json
++++ b/qtbase/src/gui/configure.json
+@@ -834,7 +834,8 @@
+                     "// embedded devices, are not intended to be used together with X. EGL support",
+                     "// has to be disabled in plugins like xcb in this case since the native display,",
+                     "// window and pixmap types will be different than what an X-based platform",
+-                    "// plugin would expect."
++                    "// plugin would expect.",
++                    "#define USE_X11"
+                 ],
+                 "include": [ "EGL/egl.h", "X11/Xlib.h" ],
+                 "main": [
+diff --git a/qtbase/src/gui/image/qbmphandler.cpp b/qtbase/src/gui/image/qbmphandler.cpp
+index 96f1e8cb1d..0e73bbbdb0 100644
+--- a/qtbase/src/gui/image/qbmphandler.cpp
++++ b/qtbase/src/gui/image/qbmphandler.cpp
+@@ -150,16 +150,42 @@ static QDataStream &operator<<(QDataStream &s, const BMP_INFOHDR &bi)
+     return s;
+ }
+ 
+-static int calc_shift(uint mask)
++static uint calc_shift(uint mask)
+ {
+-    int result = 0;
+-    while (mask && !(mask & 1)) {
++    uint result = 0;
++    while ((mask >= 0x100) || (!(mask & 1) && mask)) {
+         result++;
+         mask >>= 1;
+     }
+     return result;
+ }
+ 
++static uint calc_scale(uint low_mask)
++{
++    uint result = 8;
++    while (low_mask && result) {
++        result--;
++        low_mask >>= 1;
++    }
++    return result;
++}
++
++static inline uint apply_scale(uint value, uint scale)
++{
++    if (!(scale & 0x07)) // return immediately if scale == 8 or 0
++        return value;
++
++    uint filled = 8 - scale;
++    uint result = value << scale;
++
++    do {
++        result |= result >> filled;
++        filled <<= 1;
++    } while (filled < 8);
++
++    return result;
++}
++
+ static bool read_dib_fileheader(QDataStream &s, BMP_FILEHDR &bf)
+ {
+     // read BMP file header
+@@ -222,14 +248,14 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+     uint green_mask = 0;
+     uint blue_mask = 0;
+     uint alpha_mask = 0;
+-    int red_shift = 0;
+-    int green_shift = 0;
+-    int blue_shift = 0;
+-    int alpha_shift = 0;
+-    int red_scale = 0;
+-    int green_scale = 0;
+-    int blue_scale = 0;
+-    int alpha_scale = 0;
++    uint red_shift = 0;
++    uint green_shift = 0;
++    uint blue_shift = 0;
++    uint alpha_shift = 0;
++    uint red_scale = 0;
++    uint green_scale = 0;
++    uint blue_scale = 0;
++    uint alpha_scale = 0;
+ 
+     if (!d->isSequential())
+         d->seek(startpos + BMP_FILEHDR_SIZE + bi.biSize); // goto start of colormap or masks
+@@ -308,19 +334,19 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+         red_shift = calc_shift(red_mask);
+         if (((red_mask >> red_shift) + 1) == 0)
+             return false;
+-        red_scale = 256 / ((red_mask >> red_shift) + 1);
++        red_scale = calc_scale(red_mask >> red_shift);
+         green_shift = calc_shift(green_mask);
+         if (((green_mask >> green_shift) + 1) == 0)
+             return false;
+-        green_scale = 256 / ((green_mask >> green_shift) + 1);
++        green_scale = calc_scale(green_mask >> green_shift);
+         blue_shift = calc_shift(blue_mask);
+         if (((blue_mask >> blue_shift) + 1) == 0)
+             return false;
+-        blue_scale = 256 / ((blue_mask >> blue_shift) + 1);
++        blue_scale = calc_scale(blue_mask >> blue_shift);
+         alpha_shift = calc_shift(alpha_mask);
+         if (((alpha_mask >> alpha_shift) + 1) == 0)
+             return false;
+-        alpha_scale = 256 / ((alpha_mask >> alpha_shift) + 1);
++        alpha_scale = calc_scale(alpha_mask >> alpha_shift);
+     } else if (comp == BMP_RGB && (nbits == 24 || nbits == 32)) {
+         blue_mask = 0x000000ff;
+         green_mask = 0x0000ff00;
+@@ -328,17 +354,15 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+         blue_shift = 0;
+         green_shift = 8;
+         red_shift = 16;
+-        blue_scale = green_scale = red_scale = 1;
++        blue_scale = green_scale = red_scale = 0;
+     } else if (comp == BMP_RGB && nbits == 16) {
+         blue_mask = 0x001f;
+         green_mask = 0x03e0;
+         red_mask = 0x7c00;
+         blue_shift = 0;
+-        green_shift = 2;
+-        red_shift = 7;
+-        red_scale = 1;
+-        green_scale = 1;
+-        blue_scale = 8;
++        green_shift = 5;
++        red_shift = 10;
++        blue_scale = green_scale = red_scale = 3;
+     }
+ 
+ #if 0
+@@ -544,10 +568,10 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+                     c |= *(uchar*)(b+2)<<16;
+                 if (nbits > 24)
+                     c |= *(uchar*)(b+3)<<24;
+-                *p++ = qRgba(((c & red_mask) >> red_shift) * red_scale,
+-                                        ((c & green_mask) >> green_shift) * green_scale,
+-                                        ((c & blue_mask) >> blue_shift) * blue_scale,
+-                                        transp ? ((c & alpha_mask) >> alpha_shift) * alpha_scale : 0xff);
++                *p++ = qRgba(apply_scale((c & red_mask) >> red_shift, red_scale),
++                             apply_scale((c & green_mask) >> green_shift, green_scale),
++                             apply_scale((c & blue_mask) >> blue_shift, blue_scale),
++                             transp ? apply_scale((c & alpha_mask) >> alpha_shift, alpha_scale) : 0xff);
+                 b += nbits/8;
+             }
+         }
+diff --git a/qtbase/src/gui/image/qimage.cpp b/qtbase/src/gui/image/qimage.cpp
+index 7152ac1607..0df772564c 100644
+--- a/qtbase/src/gui/image/qimage.cpp
++++ b/qtbase/src/gui/image/qimage.cpp
+@@ -4694,6 +4694,8 @@ QImage QImage::smoothScaled(int w, int h) const {
+ static QImage rotated90(const QImage &image)
+ {
+     QImage out(image.height(), image.width(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+@@ -4722,6 +4724,8 @@ static QImage rotated180(const QImage &image)
+         return image.mirrored(true, true);
+ 
+     QImage out(image.width(), image.height(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+@@ -4734,6 +4738,8 @@ static QImage rotated180(const QImage &image)
+ static QImage rotated270(const QImage &image)
+ {
+     QImage out(image.height(), image.width(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+diff --git a/qtbase/src/gui/kernel/qcursor.cpp b/qtbase/src/gui/kernel/qcursor.cpp
+index d6ccaff8ed..455088241c 100644
+--- a/qtbase/src/gui/kernel/qcursor.cpp
++++ b/qtbase/src/gui/kernel/qcursor.cpp
+@@ -251,7 +251,8 @@ void QCursor::setPos(QScreen *screen, int x, int y)
+ {
+     if (screen) {
+         if (QPlatformCursor *cursor = screen->handle()->cursor()) {
+-            const QPoint devicePos = QHighDpi::toNativePixels(QPoint(x, y), screen);
++            const QPoint pos(x, y);
++            const QPoint devicePos = QHighDpi::toNativePixels(pos, screen->virtualSiblingAt(pos));
+             // Need to check, since some X servers generate null mouse move
+             // events, causing looping in applications which call setPos() on
+             // every mouse move event.
+diff --git a/qtbase/src/gui/kernel/qhighdpiscaling.cpp b/qtbase/src/gui/kernel/qhighdpiscaling.cpp
+index 9bbf2773a9..3ac4a4d8b6 100644
+--- a/qtbase/src/gui/kernel/qhighdpiscaling.cpp
++++ b/qtbase/src/gui/kernel/qhighdpiscaling.cpp
+@@ -580,9 +580,8 @@ void QHighDpiScaling::setScreenFactor(QScreen *screen, qreal factor)
+     else
+         qNamedScreenScaleFactors()->insert(name, factor);
+ 
+-    // hack to force re-evaluation of screen geometry
+     if (screen->handle())
+-        screen->d_func()->setPlatformScreen(screen->handle()); // updates geometries based on scale factor
++        screen->d_func()->updateLogicalDpi();
+ }
+ 
+ QPoint QHighDpiScaling::mapPositionToNative(const QPoint &pos, const QPlatformScreen *platformScreen)
+diff --git a/qtbase/src/gui/kernel/qkeysequence.cpp b/qtbase/src/gui/kernel/qkeysequence.cpp
+index a75b8ef920..4f2d294739 100644
+--- a/qtbase/src/gui/kernel/qkeysequence.cpp
++++ b/qtbase/src/gui/kernel/qkeysequence.cpp
+@@ -701,6 +701,10 @@ static const struct {
+     { Qt::Key_TouchpadToggle,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad Toggle") },
+     { Qt::Key_TouchpadOn,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad On") },
+     { Qt::Key_TouchpadOff,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad Off") },
++    { Qt::Key_Shift,  QT_TRANSLATE_NOOP("QShortcut", "Shift") },
++    { Qt::Key_Control,  QT_TRANSLATE_NOOP("QShortcut", "Control") },
++    { Qt::Key_Alt,  QT_TRANSLATE_NOOP("QShortcut", "Alt") },
++    { Qt::Key_Meta,  QT_TRANSLATE_NOOP("QShortcut", "Meta") },
+ 
+ };
+ static Q_CONSTEXPR int numKeyNames = sizeof keyname / sizeof *keyname;
+diff --git a/qtbase/src/gui/kernel/qplatformservices.cpp b/qtbase/src/gui/kernel/qplatformservices.cpp
+index fdc6a6c4aa..ac47f98c5d 100644
+--- a/qtbase/src/gui/kernel/qplatformservices.cpp
++++ b/qtbase/src/gui/kernel/qplatformservices.cpp
+@@ -55,6 +55,19 @@ QT_BEGIN_NAMESPACE
+     \brief The QPlatformServices provides the backend for desktop-related functionality.
+ */
+ 
++/*!
++    \enum QPlatformServices::Capability
++
++    Capabilities are used to determine a specific platform service's availability.
++
++    \value ColorPickingFromScreen The platform natively supports color picking from screen.
++    This capability indicates that the platform supports "opaque" color picking, where the
++    platform implements a complete user experience for color picking and outputs a color.
++    This is in contrast to the application implementing the color picking user experience
++    (taking care of showing a cross hair, instructing the platform integration to obtain
++    the color at a given pixel, etc.). The related service function is pickColor().
++ */
++
+ QPlatformServices::QPlatformServices()
+ { }
+ 
+@@ -85,5 +98,16 @@ QByteArray QPlatformServices::desktopEnvironment() const
+     return QByteArray("UNKNOWN");
+ }
+ 
++QPlatformServiceColorPicker *QPlatformServices::colorPicker(QWindow *parent)
++{
++    Q_UNUSED(parent);
++    return nullptr;
++}
++
++bool QPlatformServices::hasCapability(Capability capability) const
++{
++    Q_UNUSED(capability)
++    return false;
++}
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/gui/kernel/qplatformservices.h b/qtbase/src/gui/kernel/qplatformservices.h
+index 5de96cfa7d..a8b2a4ce71 100644
+--- a/qtbase/src/gui/kernel/qplatformservices.h
++++ b/qtbase/src/gui/kernel/qplatformservices.h
+@@ -50,16 +50,32 @@
+ //
+ 
+ #include <QtGui/qtguiglobal.h>
++#include <QtCore/qobject.h>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+ class QUrl;
++class QWindow;
++
++class Q_GUI_EXPORT QPlatformServiceColorPicker : public QObject
++{
++    Q_OBJECT
++public:
++    using QObject::QObject;
++    virtual void pickColor() = 0;
++Q_SIGNALS:
++    void colorPicked(const QColor &color);
++};
+ 
+ class Q_GUI_EXPORT QPlatformServices
+ {
+ public:
+     Q_DISABLE_COPY_MOVE(QPlatformServices)
+ 
++    enum Capability {
++        ColorPicking,
++    };
++
+     QPlatformServices();
+     virtual ~QPlatformServices() { }
+ 
+@@ -67,6 +83,10 @@ public:
+     virtual bool openDocument(const QUrl &url);
+ 
+     virtual QByteArray desktopEnvironment() const;
++
++    virtual bool hasCapability(Capability capability) const;
++
++    virtual QPlatformServiceColorPicker *colorPicker(QWindow *parent = nullptr);
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/gui/kernel/qplatformtheme.cpp b/qtbase/src/gui/kernel/qplatformtheme.cpp
+index 71521c0339..2325873245 100644
+--- a/qtbase/src/gui/kernel/qplatformtheme.cpp
++++ b/qtbase/src/gui/kernel/qplatformtheme.cpp
+@@ -163,6 +163,8 @@ QT_BEGIN_NAMESPACE
+ 
+     \value ShowShortcutsInContextMenus (bool) Whether to display shortcut key sequences in context menus.
+ 
++    \value ButtonPressKeys (QList<Qt::Key>) A list of keys that can be used to press buttons via keyboard input.
++
+     \sa themeHint(), QStyle::pixelMetric()
+ */
+ 
+@@ -563,6 +565,8 @@ QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint)
+         }
+     case MouseQuickSelectionThreshold:
+         return QVariant(10);
++    case ButtonPressKeys:
++        return QVariant::fromValue(QList<Qt::Key>({ Qt::Key_Space, Qt::Key_Select }));
+     }
+     return QVariant();
+ }
+diff --git a/qtbase/src/gui/kernel/qplatformtheme.h b/qtbase/src/gui/kernel/qplatformtheme.h
+index 3185fc4541..7e6c9d5740 100644
+--- a/qtbase/src/gui/kernel/qplatformtheme.h
++++ b/qtbase/src/gui/kernel/qplatformtheme.h
+@@ -120,7 +120,8 @@ public:
+         TouchDoubleTapDistance,
+         ShowShortcutsInContextMenus,
+         IconFallbackSearchPaths,
+-        MouseQuickSelectionThreshold
++        MouseQuickSelectionThreshold,
++        ButtonPressKeys
+     };
+ 
+     enum DialogType {
+diff --git a/qtbase/src/gui/kernel/qscreen.cpp b/qtbase/src/gui/kernel/qscreen.cpp
+index 8e0eb35116..5d172a58dd 100644
+--- a/qtbase/src/gui/kernel/qscreen.cpp
++++ b/qtbase/src/gui/kernel/qscreen.cpp
+@@ -77,6 +77,12 @@ QScreen::QScreen(QPlatformScreen *screen)
+     d->setPlatformScreen(screen);
+ }
+ 
++void QScreenPrivate::updateLogicalDpi()
++{
++    logicalDpi = QPlatformScreen::overrideDpi(platformScreen->logicalDpi());
++    updateGeometriesWithSignals(); // updates geometries based on scale factor
++}
++
+ void QScreenPrivate::updateGeometriesWithSignals()
+ {
+     const QRect oldGeometry = geometry;
+diff --git a/qtbase/src/gui/kernel/qscreen_p.h b/qtbase/src/gui/kernel/qscreen_p.h
+index 7da542c25e..e50fc3190b 100644
+--- a/qtbase/src/gui/kernel/qscreen_p.h
++++ b/qtbase/src/gui/kernel/qscreen_p.h
+@@ -70,6 +70,7 @@ public:
+         geometry = platformScreen->deviceIndependentGeometry();
+         availableGeometry = QHighDpi::fromNative(platformScreen->availableGeometry(), QHighDpiScaling::factor(platformScreen), geometry.topLeft());
+     }
++    void updateLogicalDpi();
+ 
+     void updatePrimaryOrientation();
+     void updateGeometriesWithSignals();
+diff --git a/qtbase/src/gui/painting/qblendfunctions_p.h b/qtbase/src/gui/painting/qblendfunctions_p.h
+index 080da98ec4..6997d62b3c 100644
+--- a/qtbase/src/gui/painting/qblendfunctions_p.h
++++ b/qtbase/src/gui/painting/qblendfunctions_p.h
+@@ -246,25 +246,32 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+                                   int dudx, int dvdx, int dudy, int dvdy, int u0, int v0,
+                                   Blender blender)
+ {
+-    int fromY = qMax(qRound(topY), clip.top());
+-    int toY = qMin(qRound(bottomY), clip.top() + clip.height());
++    qint64 fromY = qMax(qRound(topY), clip.top());
++    qint64 toY = qMin(qRound(bottomY), clip.top() + clip.height());
+     if (fromY >= toY)
+         return;
+ 
+     qreal leftSlope = (bottomLeft.x - topLeft.x) / (bottomLeft.y - topLeft.y);
+     qreal rightSlope = (bottomRight.x - topRight.x) / (bottomRight.y - topRight.y);
+-    int dx_l = int(leftSlope * 0x10000);
+-    int dx_r = int(rightSlope * 0x10000);
+-    int x_l = int((topLeft.x + (qreal(0.5) + fromY - topLeft.y) * leftSlope + qreal(0.5)) * 0x10000);
+-    int x_r = int((topRight.x + (qreal(0.5) + fromY - topRight.y) * rightSlope + qreal(0.5)) * 0x10000);
+-
+-    int fromX, toX, x1, x2, u, v, i, ii;
++    qint64 dx_l = qint64(leftSlope * 0x10000);
++    qint64 dx_r = qint64(rightSlope * 0x10000);
++    qint64 x_l = qint64((topLeft.x + (qreal(0.5) + fromY - topLeft.y) * leftSlope + qreal(0.5)) * 0x10000);
++    qint64 x_r = qint64((topRight.x + (qreal(0.5) + fromY - topRight.y) * rightSlope + qreal(0.5)) * 0x10000);
++
++    qint64 sourceRectTop = qint64(sourceRect.top());
++    qint64 sourceRectLeft = qint64(sourceRect.left());
++    qint64 sourceRectWidth = qint64(sourceRect.width());
++    qint64 sourceRectHeight = qint64(sourceRect.height());
++    qint64 clipLeft = qint64(clip.left());
++    qint64 clipWidth = qint64(clip.width());
++
++    qint64 fromX, toX, x1, x2, u, v, i, ii;
+     DestT *line;
+-    for (int y = fromY; y < toY; ++y) {
++    for (qint64 y = fromY; y < toY; ++y) {
+         line = reinterpret_cast<DestT *>(reinterpret_cast<uchar *>(destPixels) + y * dbpl);
+ 
+-        fromX = qMax(x_l >> 16, clip.left());
+-        toX = qMin(x_r >> 16, clip.left() + clip.width());
++        fromX = qMax(x_l >> 16, clipLeft);
++        toX = qMin(x_r >> 16, clipLeft + clipWidth);
+         if (fromX < toX) {
+             // Because of rounding, we can get source coordinates outside the source image.
+             // Clamp these coordinates to the source rect to avoid segmentation fault and
+@@ -275,10 +282,10 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             u = x1 * dudx + y * dudy + u0;
+             v = x1 * dvdx + y * dvdy + v0;
+             for (; x1 < toX; ++x1) {
+-                int uu = u >> 16;
+-                int vv = v >> 16;
+-                if (uu >= sourceRect.left() && uu < sourceRect.left() + sourceRect.width()
+-                    && vv >= sourceRect.top() && vv < sourceRect.top() + sourceRect.height()) {
++                qint64 uu = u >> 16;
++                qint64 vv = v >> 16;
++                if (uu >= sourceRectLeft && uu < sourceRectLeft + sourceRectWidth
++                    && vv >= sourceRectTop && vv < sourceRectTop + sourceRectHeight) {
+                     break;
+                 }
+                 u += dudx;
+@@ -290,10 +297,10 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             u = (x2 - 1) * dudx + y * dudy + u0;
+             v = (x2 - 1) * dvdx + y * dvdy + v0;
+             for (; x2 > x1; --x2) {
+-                int uu = u >> 16;
+-                int vv = v >> 16;
+-                if (uu >= sourceRect.left() && uu < sourceRect.left() + sourceRect.width()
+-                    && vv >= sourceRect.top() && vv < sourceRect.top() + sourceRect.height()) {
++                qint64 uu = u >> 16;
++                qint64 vv = v >> 16;
++                if (uu >= sourceRectLeft && uu < sourceRectLeft + sourceRectWidth
++                    && vv >= sourceRectTop && vv < sourceRectTop + sourceRectHeight) {
+                     break;
+                 }
+                 u -= dudx;
+@@ -308,8 +315,8 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             // Beginning of the scan line, with per-pixel checks.
+             i = x1 - fromX;
+             while (i) {
+-                int uu = qBound(sourceRect.left(), u >> 16, sourceRect.left() + sourceRect.width() - 1);
+-                int vv = qBound(sourceRect.top(), v >> 16, sourceRect.top() + sourceRect.height() - 1);
++                qint64 uu = qBound(sourceRectLeft, u >> 16, sourceRectLeft + sourceRectWidth - 1);
++                qint64 vv = qBound(sourceRectTop, v >> 16, sourceRectTop + sourceRectHeight - 1);
+                 blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + vv * sbpl)[uu]);
+                 u += dudx;
+                 v += dvdx;
+@@ -348,8 +355,8 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             // End of the scan line, with per-pixel checks.
+             i = toX - x2;
+             while (i) {
+-                int uu = qBound(sourceRect.left(), u >> 16, sourceRect.left() + sourceRect.width() - 1);
+-                int vv = qBound(sourceRect.top(), v >> 16, sourceRect.top() + sourceRect.height() - 1);
++                qint64 uu = qBound(sourceRectLeft, u >> 16, sourceRectLeft + sourceRectWidth - 1);
++                qint64 vv = qBound(sourceRectTop, v >> 16, sourceRectTop + sourceRectHeight - 1);
+                 blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + vv * sbpl)[uu]);
+                 u += dudx;
+                 v += dvdx;
+diff --git a/qtbase/src/gui/painting/qcolortrclut_p.h b/qtbase/src/gui/painting/qcolortrclut_p.h
+index 76a6a60803..24fd522e6c 100644
+--- a/qtbase/src/gui/painting/qcolortrclut_p.h
++++ b/qtbase/src/gui/painting/qcolortrclut_p.h
+@@ -118,6 +118,7 @@ public:
+         return QRgba64::fromRgba64(r, g, b, qAlpha(rgb32) * 257);
+ #endif
+     }
++    QRgba64 toLinear64(QRgba64) const = delete;
+ 
+     QRgb toLinear(QRgb rgb32) const
+     {
+diff --git a/qtbase/src/gui/painting/qdrawhelper.cpp b/qtbase/src/gui/painting/qdrawhelper.cpp
+index a61793508a..5ba2d277b7 100644
+--- a/qtbase/src/gui/painting/qdrawhelper.cpp
++++ b/qtbase/src/gui/painting/qdrawhelper.cpp
+@@ -6091,7 +6091,7 @@ static inline void alphargbblend_argb32(quint32 *dst, uint coverage, const QRgba
+ static inline void rgbBlendPixel(QRgba64 &dst, int coverage, QRgba64 slinear, const QColorTrcLut *colorProfile)
+ {
+     // Do a gammacorrected RGB alphablend...
+-    const QRgba64 dlinear = colorProfile ? colorProfile->toLinear64(dst) : dst;
++    const QRgba64 dlinear = colorProfile ? colorProfile->toLinear(dst) : dst;
+ 
+     QRgba64 blend = rgbBlend(dlinear, slinear, coverage);
+ 
+diff --git a/qtbase/src/gui/painting/qpaintengine_raster.cpp b/qtbase/src/gui/painting/qpaintengine_raster.cpp
+index 283923de52..f08eb9cbee 100644
+--- a/qtbase/src/gui/painting/qpaintengine_raster.cpp
++++ b/qtbase/src/gui/painting/qpaintengine_raster.cpp
+@@ -560,31 +560,6 @@ void QRasterPaintEngine::updateMatrix(const QTransform &matrix)
+     QRasterPaintEngineState *s = state();
+     // FALCON: get rid of this line, see drawImage call below.
+     s->matrix = matrix;
+-    QTransform::TransformationType txop = s->matrix.type();
+-
+-    switch (txop) {
+-
+-    case QTransform::TxNone:
+-        s->flags.int_xform = true;
+-        break;
+-
+-    case QTransform::TxTranslate:
+-        s->flags.int_xform = qreal(int(s->matrix.dx())) == s->matrix.dx()
+-                            && qreal(int(s->matrix.dy())) == s->matrix.dy();
+-        break;
+-
+-    case QTransform::TxScale:
+-        s->flags.int_xform = qreal(int(s->matrix.dx())) == s->matrix.dx()
+-                            && qreal(int(s->matrix.dy())) == s->matrix.dy()
+-                            && qreal(int(s->matrix.m11())) == s->matrix.m11()
+-                            && qreal(int(s->matrix.m22())) == s->matrix.m22();
+-        break;
+-
+-    default: // shear / perspective...
+-        s->flags.int_xform = false;
+-        break;
+-    }
+-
+     s->flags.tx_noshear = qt_scaleForTransform(s->matrix, &s->txscale);
+ 
+     ensureOutlineMapper();
+@@ -617,7 +592,6 @@ QRasterPaintEngineState::QRasterPaintEngineState()
+     flags.bilinear = false;
+     flags.legacy_rounding = false;
+     flags.fast_text = true;
+-    flags.int_xform = true;
+     flags.tx_noshear = true;
+     flags.fast_images = true;
+ 
+@@ -1793,7 +1767,7 @@ void QRasterPaintEngine::fill(const QVectorPath &path, const QBrush &brush)
+     QRectF cpRect = path.controlPointRect();
+     const QRectF pathDeviceRect = s->matrix.mapRect(cpRect);
+     // Skip paths that by conservative estimates are completely outside the paint device.
+-    if (!pathDeviceRect.intersects(QRectF(d->deviceRect)))
++    if (!pathDeviceRect.intersects(QRectF(d->deviceRect)) || !pathDeviceRect.isValid())
+         return;
+ 
+     ProcessSpans blend = d->getBrushFunc(pathDeviceRect, &s->brushData);
+diff --git a/qtbase/src/gui/painting/qpaintengine_raster_p.h b/qtbase/src/gui/painting/qpaintengine_raster_p.h
+index 089aadc3f7..bf7363d5aa 100644
+--- a/qtbase/src/gui/painting/qpaintengine_raster_p.h
++++ b/qtbase/src/gui/painting/qpaintengine_raster_p.h
+@@ -111,7 +111,6 @@ public:
+         uint bilinear : 1;
+         uint legacy_rounding : 1;
+         uint fast_text : 1;
+-        uint int_xform : 1;
+         uint tx_noshear : 1;
+         uint fast_images : 1;
+     };
+diff --git a/qtbase/src/gui/painting/qpainterpath.cpp b/qtbase/src/gui/painting/qpainterpath.cpp
+index f9544a3241..d80fafeaf1 100644
+--- a/qtbase/src/gui/painting/qpainterpath.cpp
++++ b/qtbase/src/gui/painting/qpainterpath.cpp
+@@ -1253,7 +1253,7 @@ void QPainterPath::addText(const QPointF &point, const QFont &f, const QString &
+ 
+         if (si.analysis.flags < QScriptAnalysis::TabOrObject) {
+             QGlyphLayout glyphs = eng->shapedGlyphs(&si);
+-            QFontEngine *fe = f.d->engineForScript(si.analysis.script);
++            QFontEngine *fe = eng->fontEngine(si);
+             Q_ASSERT(fe);
+             fe->addOutlineToPath(x, y, glyphs, this,
+                                  si.analysis.bidiLevel % 2
+diff --git a/qtbase/src/gui/painting/qpathclipper_p.h b/qtbase/src/gui/painting/qpathclipper_p.h
+index 9444a87b71..18f64c5e8c 100644
+--- a/qtbase/src/gui/painting/qpathclipper_p.h
++++ b/qtbase/src/gui/painting/qpathclipper_p.h
+@@ -156,7 +156,7 @@ public:
+     int vertex(Direction direction) const;
+ 
+ private:
+-    int m_next[2][2];
++    int m_next[2][2] = { { -1, -1 }, { -1, -1 } };
+ };
+ 
+ class QPathSegments
+@@ -296,10 +296,6 @@ inline QPathEdge::QPathEdge(int a, int b)
+     , angle(0)
+     , invAngle(0)
+ {
+-    m_next[0][0] = -1;
+-    m_next[1][0] = -1;
+-    m_next[0][0] = -1;
+-    m_next[1][0] = -1;
+ }
+ 
+ inline int QPathEdge::next(Traversal traversal, Direction direction) const
+diff --git a/qtbase/src/gui/painting/qpdf.cpp b/qtbase/src/gui/painting/qpdf.cpp
+index 3066744f1b..2c8d3c3b53 100644
+--- a/qtbase/src/gui/painting/qpdf.cpp
++++ b/qtbase/src/gui/painting/qpdf.cpp
+@@ -2760,6 +2760,8 @@ int QPdfEnginePrivate::addBrushPattern(const QTransform &m, bool *specifyColor,
+         return gradientBrush(brush, matrix, gStateObject);
+     }
+ 
++    matrix = brush.transform() * matrix;
++
+     if ((!brush.isOpaque() && brush.style() < Qt::LinearGradientPattern) || opacity != 1.0)
+         *gStateObject = addConstantAlphaObject(qRound(brush.color().alpha() * opacity),
+                                                qRound(pen.color().alpha() * opacity));
+diff --git a/qtbase/src/gui/painting/qstroker.cpp b/qtbase/src/gui/painting/qstroker.cpp
+index cb5d395e80..3b6357a893 100644
+--- a/qtbase/src/gui/painting/qstroker.cpp
++++ b/qtbase/src/gui/painting/qstroker.cpp
+@@ -1182,6 +1182,7 @@ void QDashStroker::processCurrentSubpath()
+         // Check if the entire line should be clipped away or simplified
+         bool clipIt = clipping && !lineIntersectsRect(prev, e, clip_tl, clip_br);
+         bool skipDashing = elen * invSumLength > repetitionLimit();
++        int maxDashes = dashCount;
+         if (skipDashing || clipIt) {
+             // Cut away full dash sequences.
+             elen -= std::floor(elen * invSumLength) * sumLength;
+@@ -1196,7 +1197,7 @@ void QDashStroker::processCurrentSubpath()
+                     pos = estop; // move pos to next path element
+                     done = true;
+                 } else { // Dash is on this line
+-                    pos = dpos + estart;
++                    pos = --maxDashes > 0 ? dpos + estart : estop;
+                     done = pos >= estop;
+                     if (++idash >= dashCount)
+                         idash = 0;
+diff --git a/qtbase/src/gui/painting/qt_attribution.json b/qtbase/src/gui/painting/qt_attribution.json
+index 7b16e8c211..0e87d30aa2 100644
+--- a/qtbase/src/gui/painting/qt_attribution.json
++++ b/qtbase/src/gui/painting/qt_attribution.json
+@@ -10,7 +10,7 @@
+         "Homepage": "http://www.freetype.org",
+         "License": "Freetype Project License or GNU General Public License v2.0 only",
+         "LicenseId": "FTL or GPL-2.0",
+-        "LicenseFile": "../../3rdparty/freetype/docs/LICENSE.TXT",
++        "LicenseFile": "../../3rdparty/freetype/LICENSE.TXT",
+         "Copyright": "Copyright 2000-2016 by David Turner, Robert Wilhelm, and Werner Lemberg."
+     },
+     {
+diff --git a/qtbase/src/gui/rhi/qshader_p_p.h b/qtbase/src/gui/rhi/qshader_p_p.h
+index ec9d25971f..4a5a7a6d51 100644
+--- a/qtbase/src/gui/rhi/qshader_p_p.h
++++ b/qtbase/src/gui/rhi/qshader_p_p.h
+@@ -68,13 +68,13 @@ struct Q_GUI_EXPORT QShaderPrivate
+     {
+     }
+ 
+-    QShaderPrivate(const QShaderPrivate *other)
++    QShaderPrivate(const QShaderPrivate &other)
+         : ref(1),
+-          qsbVersion(other->qsbVersion),
+-          stage(other->stage),
+-          desc(other->desc),
+-          shaders(other->shaders),
+-          bindings(other->bindings)
++          qsbVersion(other.qsbVersion),
++          stage(other.stage),
++          desc(other.desc),
++          shaders(other.shaders),
++          bindings(other.bindings)
+     {
+     }
+ 
+diff --git a/qtbase/src/gui/rhi/qshaderdescription_p_p.h b/qtbase/src/gui/rhi/qshaderdescription_p_p.h
+index ec2b0b6b4c..3da33a8a2b 100644
+--- a/qtbase/src/gui/rhi/qshaderdescription_p_p.h
++++ b/qtbase/src/gui/rhi/qshaderdescription_p_p.h
+@@ -63,16 +63,16 @@ struct Q_GUI_EXPORT QShaderDescriptionPrivate
+         localSize[0] = localSize[1] = localSize[2] = 0;
+     }
+ 
+-    QShaderDescriptionPrivate(const QShaderDescriptionPrivate *other)
++    QShaderDescriptionPrivate(const QShaderDescriptionPrivate &other)
+         : ref(1),
+-          inVars(other->inVars),
+-          outVars(other->outVars),
+-          uniformBlocks(other->uniformBlocks),
+-          pushConstantBlocks(other->pushConstantBlocks),
+-          storageBlocks(other->storageBlocks),
+-          combinedImageSamplers(other->combinedImageSamplers),
+-          storageImages(other->storageImages),
+-          localSize(other->localSize)
++          inVars(other.inVars),
++          outVars(other.outVars),
++          uniformBlocks(other.uniformBlocks),
++          pushConstantBlocks(other.pushConstantBlocks),
++          storageBlocks(other.storageBlocks),
++          combinedImageSamplers(other.combinedImageSamplers),
++          storageImages(other.storageImages),
++          localSize(other.localSize)
+     {
+     }
+ 
+diff --git a/qtbase/src/gui/text/qfontdatabase.cpp b/qtbase/src/gui/text/qfontdatabase.cpp
+index a657a8c516..4fc0100958 100644
+--- a/qtbase/src/gui/text/qfontdatabase.cpp
++++ b/qtbase/src/gui/text/qfontdatabase.cpp
+@@ -983,7 +983,7 @@ QFontEngine *loadSingleEngine(int script,
+         if (style->key.stretch != 0 && request.stretch != 0
+             && (request.styleName.isEmpty() || request.styleName != style->styleName)) {
+             def.stretch = (request.stretch * 100 + style->key.stretch / 2) / style->key.stretch;
+-        } else {
++        } else if (request.stretch == QFont::AnyStretch) {
+             def.stretch = 100;
+         }
+ 
+diff --git a/qtbase/src/gui/text/qtextdocumentlayout.cpp b/qtbase/src/gui/text/qtextdocumentlayout.cpp
+index f3e6ea2100..72267e9380 100644
+--- a/qtbase/src/gui/text/qtextdocumentlayout.cpp
++++ b/qtbase/src/gui/text/qtextdocumentlayout.cpp
+@@ -2123,7 +2123,7 @@ void QTextDocumentLayoutPrivate::drawListItem(const QPointF &offset, QPainter *p
+ {
+     Q_Q(const QTextDocumentLayout);
+     const QTextBlockFormat blockFormat = bl.blockFormat();
+-    const QTextCharFormat charFormat = QTextCursor(bl).charFormat();
++    const QTextCharFormat charFormat = bl.charFormat();
+     QFont font(charFormat.font());
+     if (q->paintDevice())
+         font = QFont(font, q->paintDevice());
+diff --git a/qtbase/src/gui/text/qtextengine.cpp b/qtbase/src/gui/text/qtextengine.cpp
+index ce4abac472..a6c66e5d2d 100644
+--- a/qtbase/src/gui/text/qtextengine.cpp
++++ b/qtbase/src/gui/text/qtextengine.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2021 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtGui module of the Qt Toolkit.
+@@ -1565,6 +1565,12 @@ void QTextEngine::shapeText(int item) const
+         // Overwrite with 0 token to indicate failure
+         QGlyphLayout g = availableGlyphs(&si);
+         g.glyphs[0] = 0;
++        g.attributes[0].clusterStart = true;
++
++        ushort *log_clusters = logClusters(&si);
++        for (int i = 0; i < itemLength; ++i)
++            log_clusters[i] = 0;
++
+         return;
+     }
+ 
+diff --git a/qtbase/src/gui/util/qdesktopservices.cpp b/qtbase/src/gui/util/qdesktopservices.cpp
+index fbb63a9408..4d5fafaaa7 100644
+--- a/qtbase/src/gui/util/qdesktopservices.cpp
++++ b/qtbase/src/gui/util/qdesktopservices.cpp
+@@ -54,6 +54,8 @@
+ #include <qpa/qplatformintegration.h>
+ #include <qdir.h>
+ 
++#include <QtCore/private/qlocking_p.h>
++
+ QT_BEGIN_NAMESPACE
+ 
+ class QOpenUrlHandlerRegistry : public QObject
+@@ -81,6 +83,7 @@ Q_GLOBAL_STATIC(QOpenUrlHandlerRegistry, handlerRegistry)
+ 
+ void QOpenUrlHandlerRegistry::handlerDestroyed(QObject *handler)
+ {
++    const auto lock = qt_scoped_lock(mutex);
+     HandlerHash::Iterator it = handlers.begin();
+     while (it != handlers.end()) {
+         if (it->receiver == handler) {
+@@ -294,7 +297,8 @@ void QDesktopServices::setUrlHandler(const QString &scheme, QObject *receiver, c
+     h.name = method;
+     registry->handlers.insert(scheme.toLower(), h);
+     QObject::connect(receiver, SIGNAL(destroyed(QObject*)),
+-                     registry, SLOT(handlerDestroyed(QObject*)));
++                     registry, SLOT(handlerDestroyed(QObject*)),
++                     Qt::DirectConnection);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/gui/util/qpkmhandler.cpp b/qtbase/src/gui/util/qpkmhandler.cpp
+index e0c3b75efe..3414f9d8ba 100644
+--- a/qtbase/src/gui/util/qpkmhandler.cpp
++++ b/qtbase/src/gui/util/qpkmhandler.cpp
+@@ -57,7 +57,7 @@ struct PkmType
+     quint32 bytesPerBlock;
+ };
+ 
+-static PkmType typeMap[5] = {
++static constexpr PkmType typeMap[5] = {
+     { 0x8D64,  8 },   // GL_ETC1_RGB8_OES
+     { 0x9274,  8 },   // GL_COMPRESSED_RGB8_ETC2
+     { 0, 0 },         // unused (obsolete)
+diff --git a/qtbase/src/network/access/qnetworkreplyfileimpl.cpp b/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
+index b6be93147a..6e69b4c4d3 100644
+--- a/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
++++ b/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
+@@ -89,9 +89,10 @@ QNetworkReplyFileImpl::QNetworkReplyFileImpl(QNetworkAccessManager *manager, con
+         // we handle only local files
+         QString msg = QCoreApplication::translate("QNetworkAccessFileBackend", "Request for opening non-local file %1").arg(url.toString());
+         setError(QNetworkReply::ProtocolInvalidOperationError, msg);
++        setFinished(true); // We're finished, will emit finished() after ctor is done.
+         QMetaObject::invokeMethod(this, "errorOccurred", Qt::QueuedConnection,
+             Q_ARG(QNetworkReply::NetworkError, QNetworkReply::ProtocolInvalidOperationError));
+-        fileOpenFinished(false);
++        QMetaObject::invokeMethod(this, [this](){ fileOpenFinished(false); }, Qt::QueuedConnection);
+         return;
+     }
+ #endif
+diff --git a/qtbase/src/network/access/qnetworkreplyimpl.cpp b/qtbase/src/network/access/qnetworkreplyimpl.cpp
+index bcdf6ee2f1..3b6deb82bd 100644
+--- a/qtbase/src/network/access/qnetworkreplyimpl.cpp
++++ b/qtbase/src/network/access/qnetworkreplyimpl.cpp
+@@ -680,7 +680,7 @@ void QNetworkReplyImplPrivate::appendDownstreamData(QIODevice *data)
+     // read until EOF from data
+     if (Q_UNLIKELY(copyDevice)) {
+         qCritical("QNetworkReplyImpl: copy from QIODevice already in progress -- "
+-                  "backend probly needs to be fixed");
++                  "backend probably needs to be fixed");
+         return;
+     }
+ 
+diff --git a/qtbase/src/network/kernel/qauthenticator.cpp b/qtbase/src/network/kernel/qauthenticator.cpp
+index d9fe7bc47b..ccd04b294a 100644
+--- a/qtbase/src/network/kernel/qauthenticator.cpp
++++ b/qtbase/src/network/kernel/qauthenticator.cpp
+@@ -50,6 +50,7 @@
+ #include <qstring.h>
+ #include <qdatetime.h>
+ #include <qrandom.h>
++#include "private/qsystemlibrary_p.h"
+ 
+ #ifdef Q_OS_WIN
+ #include <qmutex.h>
+@@ -1563,7 +1564,7 @@ static bool q_SSPI_library_load()
+ 
+     // Initialize security interface
+     if (pSecurityFunctionTable == nullptr) {
+-        securityDLLHandle = LoadLibrary(L"secur32.dll");
++        securityDLLHandle = QSystemLibrary::load(L"secur32");
+         if (securityDLLHandle != nullptr) {
+             INIT_SECURITY_INTERFACE pInitSecurityInterface =
+                 reinterpret_cast<INIT_SECURITY_INTERFACE>(
+diff --git a/qtbase/src/network/kernel/qhostinfo_unix.cpp b/qtbase/src/network/kernel/qhostinfo_unix.cpp
+index 9b0a2ee669..73679c9ef1 100644
+--- a/qtbase/src/network/kernel/qhostinfo_unix.cpp
++++ b/qtbase/src/network/kernel/qhostinfo_unix.cpp
+@@ -122,7 +122,6 @@ static QFunctionPointer resolveSymbol(QLibrary &lib, const char *sym)
+ 
+ LibResolv::LibResolv()
+ {
+-    QLibrary lib;
+ #ifdef LIBRESOLV_SO
+     lib.setFileName(QStringLiteral(LIBRESOLV_SO));
+     if (!lib.load())
+diff --git a/qtbase/src/network/socket/qsocks5socketengine.cpp b/qtbase/src/network/socket/qsocks5socketengine.cpp
+index 3a046fd116..97fadca0b3 100644
+--- a/qtbase/src/network/socket/qsocks5socketengine.cpp
++++ b/qtbase/src/network/socket/qsocks5socketengine.cpp
+@@ -1296,7 +1296,7 @@ void QSocks5SocketEnginePrivate::_q_udpSocketReadNotification()
+         int pos = 0;
+         const char *buf = inBuf.constData();
+         if (inBuf.size() < 4) {
+-            QSOCKS5_D_DEBUG << "bugus udp data, discarding";
++            QSOCKS5_D_DEBUG << "bogus udp data, discarding";
+             return;
+         }
+         QSocks5RevivedDatagram datagram;
+diff --git a/qtbase/src/network/ssl/qsslcontext_openssl.cpp b/qtbase/src/network/ssl/qsslcontext_openssl.cpp
+index c9f202f573..c992da9d8e 100644
+--- a/qtbase/src/network/ssl/qsslcontext_openssl.cpp
++++ b/qtbase/src/network/ssl/qsslcontext_openssl.cpp
+@@ -409,7 +409,7 @@ init_context:
+         break;
+     case QSsl::DtlsV1_0OrLater:
+         minVersion = DTLS1_VERSION;
+-        maxVersion = DTLS_MAX_VERSION;
++        maxVersion = 0;
+         break;
+     case QSsl::DtlsV1_2:
+         minVersion = DTLS1_2_VERSION;
+@@ -417,7 +417,7 @@ init_context:
+         break;
+     case QSsl::DtlsV1_2OrLater:
+         minVersion = DTLS1_2_VERSION;
+-        maxVersion = DTLS_MAX_VERSION;
++        maxVersion = 0;
+         break;
+     case QSsl::TlsV1_3OrLater:
+ #ifdef TLS1_3_VERSION
+@@ -455,7 +455,7 @@ init_context:
+     }
+ 
+     // Enable bug workarounds.
+-    long options = QSslSocketBackendPrivate::setupOpenSslOptions(configuration.protocol(), configuration.d->sslOptions);
++    qssloptions options = QSslSocketBackendPrivate::setupOpenSslOptions(configuration.protocol(), configuration.d->sslOptions);
+     q_SSL_CTX_set_options(sslContext->ctx, options);
+ 
+     // Tell OpenSSL to release memory early
+diff --git a/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp b/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
+index aaf8741130..b58935372c 100644
+--- a/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
++++ b/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
+@@ -59,57 +59,6 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-#ifdef OPENSSL_NO_DEPRECATED_3_0
+-
+-static int q_DH_check(DH *dh, int *status)
+-{
+-    // DH_check was first deprecated in OpenSSL 3.0.0, as low-level
+-    // API; the EVP_PKEY family of functions was advised as an alternative.
+-    // As of now EVP_PKEY_params_check ends up calling ... DH_check,
+-    // which is good enough.
+-
+-    Q_ASSERT(dh);
+-    Q_ASSERT(status);
+-
+-    EVP_PKEY *key = q_EVP_PKEY_new();
+-    if (!key) {
+-        qCWarning(lcSsl, "EVP_PKEY_new failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-    const auto keyDeleter = qScopeGuard([key](){
+-        q_EVP_PKEY_free(key);
+-    });
+-    if (!q_EVP_PKEY_set1_DH(key, dh)) {
+-        qCWarning(lcSsl, "EVP_PKEY_set1_DH failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-
+-    EVP_PKEY_CTX *keyCtx = q_EVP_PKEY_CTX_new(key, nullptr);
+-    if (!keyCtx) {
+-        qCWarning(lcSsl, "EVP_PKEY_CTX_new failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-    const auto ctxDeleter = qScopeGuard([keyCtx]{
+-        q_EVP_PKEY_CTX_free(keyCtx);
+-    });
+-
+-    const int result = q_EVP_PKEY_param_check(keyCtx);
+-    QSslSocketBackendPrivate::logAndClearErrorQueue();
+-    // Note: unlike DH_check, we cannot obtain the 'status',
+-    // if the 'result' is 0 (actually the result is 1 only
+-    // if this 'status' was 0). We could probably check the
+-    // errors from the error queue, but it's not needed anyway
+-    // - see the 'isSafeDH' below, how it returns immediately
+-    // on 0.
+-    Q_UNUSED(status)
+-
+-    return result;
+-}
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+-
+ static bool isSafeDH(DH *dh)
+ {
+     int status = 0;
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl.cpp b/qtbase/src/network/ssl/qsslsocket_openssl.cpp
+index 37fad2a68f..8f6858c867 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl.cpp
++++ b/qtbase/src/network/ssl/qsslsocket_openssl.cpp
+@@ -550,9 +550,9 @@ static void q_loadCiphersForConnection(SSL *connection, QList<QSslCipher> &ciphe
+ // Defined in qsslsocket.cpp
+ void q_setDefaultDtlsCiphers(const QList<QSslCipher> &ciphers);
+ 
+-long QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions)
++qssloptions QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions)
+ {
+-    long options;
++    qssloptions options;
+     if (protocol == QSsl::TlsV1SslV3)
+         options = SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3;
+     else if (protocol == QSsl::SecureProtocols)
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_p.h b/qtbase/src/network/ssl/qsslsocket_openssl_p.h
+index 4103de23e8..5547589256 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_p.h
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_p.h
+@@ -107,6 +107,12 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++typedef uint64_t qssloptions;
++#else
++typedef unsigned long qssloptions;
++#endif
++
+ struct QSslErrorEntry {
+     int code;
+     int depth;
+@@ -171,7 +177,7 @@ public:
+     QVector<QSslError> ocspErrors;
+     QByteArray ocspResponseDer;
+ 
+-    Q_AUTOTEST_EXPORT static long setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions);
++    Q_AUTOTEST_EXPORT static qssloptions setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions);
+     static QSslCipher QSslCipher_from_SSL_CIPHER(const SSL_CIPHER *cipher);
+     static QList<QSslCertificate> STACKOFX509_to_QSslCertificates(STACK_OF(X509) *x509);
+     static QList<QSslError> verify(const QList<QSslCertificate> &certificateChain, const QString &hostName);
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp b/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
+index e53fb279f0..459ccd0b19 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
+@@ -148,7 +148,6 @@ DEFINEFUNC(int, EVP_PKEY_up_ref, EVP_PKEY *a, a, return 0, return)
+ DEFINEFUNC2(EVP_PKEY_CTX *, EVP_PKEY_CTX_new, EVP_PKEY *pkey, pkey, ENGINE *e, e, return nullptr, return)
+ DEFINEFUNC(int, EVP_PKEY_param_check, EVP_PKEY_CTX *ctx, ctx, return 0, return)
+ DEFINEFUNC(void, EVP_PKEY_CTX_free, EVP_PKEY_CTX *ctx, ctx, return, return)
+-DEFINEFUNC(int, EVP_PKEY_base_id, EVP_PKEY *a, a, return NID_undef, return)
+ DEFINEFUNC(int, RSA_bits, RSA *a, a, return 0, return)
+ DEFINEFUNC(int, DSA_bits, DSA *a, a, return 0, return)
+ DEFINEFUNC(int, OPENSSL_sk_num, OPENSSL_STACK *a, a, return -1, return)
+@@ -158,7 +157,7 @@ DEFINEFUNC2(void, OPENSSL_sk_push, OPENSSL_STACK *a, a, void *b, b, return, DUMM
+ DEFINEFUNC(void, OPENSSL_sk_free, OPENSSL_STACK *a, a, return, DUMMYARG)
+ DEFINEFUNC2(void *, OPENSSL_sk_value, OPENSSL_STACK *a, a, int b, b, return nullptr, return)
+ DEFINEFUNC(int, SSL_session_reused, SSL *a, a, return 0, return)
+-DEFINEFUNC2(unsigned long, SSL_CTX_set_options, SSL_CTX *ctx, ctx, unsigned long op, op, return 0, return)
++DEFINEFUNC2(qssloptions, SSL_CTX_set_options, SSL_CTX *ctx, ctx, qssloptions op, op, return 0, return)
+ DEFINEFUNC(int, SSL_CTX_get_security_level, const SSL_CTX *ctx, ctx, return -1, return)
+ DEFINEFUNC2(void, SSL_CTX_set_security_level, SSL_CTX *ctx, ctx, int level, level, return, return)
+ #ifdef TLS1_3_VERSION
+@@ -371,7 +370,15 @@ DEFINEFUNC(const SSL_CIPHER *, SSL_get_current_cipher, SSL *a, a, return nullptr
+ DEFINEFUNC(int, SSL_version, const SSL *a, a, return 0, return)
+ DEFINEFUNC2(int, SSL_get_error, SSL *a, a, int b, b, return -1, return)
+ DEFINEFUNC(STACK_OF(X509) *, SSL_get_peer_cert_chain, SSL *a, a, return nullptr, return)
++
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++DEFINEFUNC(X509 *, SSL_get1_peer_certificate, SSL *a, a, return nullptr, return)
++DEFINEFUNC(int, EVP_PKEY_get_base_id, const EVP_PKEY *pkey, pkey, return -1, return)
++#else
+ DEFINEFUNC(X509 *, SSL_get_peer_certificate, SSL *a, a, return nullptr, return)
++DEFINEFUNC(int, EVP_PKEY_base_id, EVP_PKEY *a, a, return NID_undef, return)
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+ DEFINEFUNC(long, SSL_get_verify_result, const SSL *a, a, return -1, return)
+ DEFINEFUNC(SSL *, SSL_new, SSL_CTX *a, a, return nullptr, return)
+ DEFINEFUNC(SSL_CTX *, SSL_get_SSL_CTX, SSL *a, a, return nullptr, return)
+@@ -492,9 +499,7 @@ DEFINEFUNC(DH *, DH_new, DUMMYARG, DUMMYARG, return nullptr, return)
+ DEFINEFUNC(void, DH_free, DH *dh, dh, return, DUMMYARG)
+ DEFINEFUNC3(DH *, d2i_DHparams, DH**a, a, const unsigned char **pp, pp, long length, length, return nullptr, return)
+ DEFINEFUNC2(int, i2d_DHparams, DH *a, a, unsigned char **p, p, return -1, return)
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+ DEFINEFUNC2(int, DH_check, DH *dh, dh, int *codes, codes, return 0, return)
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+ DEFINEFUNC3(BIGNUM *, BN_bin2bn, const unsigned char *s, s, int len, len, BIGNUM *ret, ret, return nullptr, return)
+ 
+ #ifndef OPENSSL_NO_EC
+@@ -868,7 +873,6 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(EVP_PKEY_CTX_new)
+     RESOLVEFUNC(EVP_PKEY_param_check)
+     RESOLVEFUNC(EVP_PKEY_CTX_free)
+-    RESOLVEFUNC(EVP_PKEY_base_id)
+     RESOLVEFUNC(RSA_bits)
+     RESOLVEFUNC(OPENSSL_sk_new_null)
+     RESOLVEFUNC(OPENSSL_sk_push)
+@@ -1107,7 +1111,15 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(SSL_version)
+     RESOLVEFUNC(SSL_get_error)
+     RESOLVEFUNC(SSL_get_peer_cert_chain)
++
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++    RESOLVEFUNC(SSL_get1_peer_certificate)
++    RESOLVEFUNC(EVP_PKEY_get_base_id)
++#else
+     RESOLVEFUNC(SSL_get_peer_certificate)
++    RESOLVEFUNC(EVP_PKEY_base_id)
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+     RESOLVEFUNC(SSL_get_verify_result)
+     RESOLVEFUNC(SSL_new)
+     RESOLVEFUNC(SSL_get_SSL_CTX)
+@@ -1206,9 +1218,7 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(DH_free)
+     RESOLVEFUNC(d2i_DHparams)
+     RESOLVEFUNC(i2d_DHparams)
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+     RESOLVEFUNC(DH_check)
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+     RESOLVEFUNC(BN_bin2bn)
+ 
+ #ifndef OPENSSL_NO_EC
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h b/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
+index 95e8897a3b..27aeffa18a 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
+@@ -237,7 +237,6 @@ Q_AUTOTEST_EXPORT int q_EVP_PKEY_up_ref(EVP_PKEY *a);
+ EVP_PKEY_CTX *q_EVP_PKEY_CTX_new(EVP_PKEY *pkey, ENGINE *e);
+ void q_EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx);
+ int q_EVP_PKEY_param_check(EVP_PKEY_CTX *ctx);
+-int q_EVP_PKEY_base_id(EVP_PKEY *a);
+ int q_RSA_bits(RSA *a);
+ Q_AUTOTEST_EXPORT int q_OPENSSL_sk_num(OPENSSL_STACK *a);
+ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_pop_free(OPENSSL_STACK *a, void (*b)(void *));
+@@ -246,7 +245,7 @@ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_push(OPENSSL_STACK *st, void *data);
+ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_free(OPENSSL_STACK *a);
+ Q_AUTOTEST_EXPORT void * q_OPENSSL_sk_value(OPENSSL_STACK *a, int b);
+ int q_SSL_session_reused(SSL *a);
+-unsigned long q_SSL_CTX_set_options(SSL_CTX *ctx, unsigned long op);
++qssloptions q_SSL_CTX_set_options(SSL_CTX *ctx, qssloptions op);
+ int q_OPENSSL_init_ssl(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings);
+ size_t q_SSL_get_client_random(SSL *a, unsigned char *out, size_t outlen);
+ size_t q_SSL_SESSION_get_master_key(const SSL_SESSION *session, unsigned char *out, size_t outlen);
+@@ -510,7 +509,6 @@ const SSL_CIPHER *q_SSL_get_current_cipher(SSL *a);
+ int q_SSL_version(const SSL *a);
+ int q_SSL_get_error(SSL *a, int b);
+ STACK_OF(X509) *q_SSL_get_peer_cert_chain(SSL *a);
+-X509 *q_SSL_get_peer_certificate(SSL *a);
+ long q_SSL_get_verify_result(const SSL *a);
+ SSL *q_SSL_new(SSL_CTX *a);
+ SSL_CTX *q_SSL_get_SSL_CTX(SSL *a);
+@@ -582,10 +580,7 @@ DH *q_DH_new();
+ void q_DH_free(DH *dh);
+ DH *q_d2i_DHparams(DH **a, const unsigned char **pp, long length);
+ int q_i2d_DHparams(DH *a, unsigned char **p);
+-
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+ int q_DH_check(DH *dh, int *codes);
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+ 
+ BIGNUM *q_BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret);
+ #define q_SSL_CTX_set_tmp_dh(ctx, dh) q_SSL_CTX_ctrl((ctx), SSL_CTRL_SET_TMP_DH, 0, (char *)dh)
+@@ -754,6 +749,17 @@ void q_CRYPTO_free(void *str, const char *file, int line);
+ int q_SSL_CTX_get_security_level(const SSL_CTX *ctx);
+ void q_SSL_CTX_set_security_level(SSL_CTX *ctx, int level);
+ 
++// Here we have the ones that make difference between OpenSSL pre/post v3:
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++X509 *q_SSL_get1_peer_certificate(SSL *a);
++#define q_SSL_get_peer_certificate q_SSL_get1_peer_certificate
++int q_EVP_PKEY_get_base_id(const EVP_PKEY *pkey);
++#define q_EVP_PKEY_base_id q_EVP_PKEY_get_base_id
++#else
++X509 *q_SSL_get_peer_certificate(SSL *a);
++int q_EVP_PKEY_base_id(EVP_PKEY *a);
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+ QT_END_NAMESPACE
+ 
+ #endif
+diff --git a/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h b/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
+index bf37d07fd8..dbd42fb799 100644
+--- a/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
++++ b/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
+@@ -61,7 +61,11 @@
+ # if !defined(Q_OS_INTEGRITY)
+ #  define WIN_INTERFACE_CUSTOM   // NV
+ # endif // Q_OS_INTEGRITY
+-#endif  // QT_EGL_NO_X11
++#else // QT_EGL_NO_X11
++// If one has an eglplatform.h with https://github.com/KhronosGroup/EGL-Registry/pull/130
++// that needs USE_X11 to be defined.
++# define USE_X11
++#endif
+ 
+ #ifdef QT_EGL_WAYLAND
+ # define WAYLAND // NV
+diff --git a/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+index 159b490ce0..00aa80cd58 100644
+--- a/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
++++ b/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+@@ -567,6 +567,8 @@ void QFontconfigDatabase::populateFontDatabase()
+         fonts = FcFontList(nullptr, pattern, os);
+         FcObjectSetDestroy(os);
+         FcPatternDestroy(pattern);
++        if (!fonts)
++            return;
+     }
+ 
+     for (int i = 0; i < fonts->nfont; i++)
+diff --git a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
+index b713c19447..7cb9a8c79a 100644
+--- a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
++++ b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
+@@ -95,6 +95,7 @@ static constexpr const auto KeyTbl = qMakeArray(
+         Xkb2Qt<XKB_KEY_Clear,                   Qt::Key_Delete>,
+         Xkb2Qt<XKB_KEY_Pause,                   Qt::Key_Pause>,
+         Xkb2Qt<XKB_KEY_Print,                   Qt::Key_Print>,
++        Xkb2Qt<XKB_KEY_Sys_Req,                 Qt::Key_SysReq>,
+         Xkb2Qt<0x1005FF60,                      Qt::Key_SysReq>,         // hardcoded Sun SysReq
+         Xkb2Qt<0x1007ff00,                      Qt::Key_SysReq>,         // hardcoded X386 SysReq
+ 
+@@ -471,7 +472,7 @@ QVector<xkb_keysym_t> QXkbCommon::toKeysym(QKeyEvent *event)
+     } else if (event->modifiers() & Qt::KeypadModifier) {
+         if (qtKey >= Qt::Key_0 && qtKey <= Qt::Key_9)
+             keysyms.append(XKB_KEY_KP_0 + (qtKey - Qt::Key_0));
+-    } else if (isLatin(qtKey) && event->text().isUpper()) {
++    } else if (isLatin1(qtKey) && event->text().isUpper()) {
+         keysyms.append(qtKey);
+     }
+ 
+@@ -523,7 +524,7 @@ int QXkbCommon::keysymToQtKey(xkb_keysym_t keysym, Qt::KeyboardModifiers modifie
+         // With standard shortcuts we should prefer a latin character, this is
+         // for checks like "some qkeyevent == QKeySequence::Copy" to work even
+         // when using for example 'russian' keyboard layout.
+-        if (!QXkbCommon::isLatin(keysym)) {
++        if (!QXkbCommon::isLatin1(keysym)) {
+             xkb_keysym_t latinKeysym = QXkbCommon::lookupLatinKeysym(state, code);
+             if (latinKeysym != XKB_KEY_NoSymbol)
+                 keysym = latinKeysym;
+@@ -546,7 +547,7 @@ static int keysymToQtKey_internal(xkb_keysym_t keysym, Qt::KeyboardModifiers mod
+     } else if (keysym >= XKB_KEY_KP_0 && keysym <= XKB_KEY_KP_9) {
+         // numeric keypad keys
+         qtKey = Qt::Key_0 + (keysym - XKB_KEY_KP_0);
+-    } else if (QXkbCommon::isLatin(keysym)) {
++    } else if (QXkbCommon::isLatin1(keysym)) {
+         qtKey = QXkbCommon::qxkbcommon_xkb_keysym_to_upper(keysym);
+     } else {
+         // check if we have a direct mapping
+@@ -678,7 +679,7 @@ QList<int> QXkbCommon::possibleKeys(xkb_state *state, const QKeyEvent *event,
+         Qt::KeyboardModifiers neededMods = ModsTbl[i];
+         if ((modifiers & neededMods) == neededMods) {
+             if (i == 8) {
+-                if (isLatin(baseQtKey))
++                if (isLatin1(baseQtKey))
+                     continue;
+                 // add a latin key as a fall back key
+                 sym = lookupLatinKeysym(state, keycode);
+@@ -733,7 +734,7 @@ void QXkbCommon::verifyHasLatinLayout(xkb_keymap *keymap)
+     for (xkb_layout_index_t layout = 0; layout < layoutCount; ++layout) {
+         for (xkb_keycode_t code = minKeycode; code < maxKeycode; ++code) {
+             xkb_keymap_key_get_syms_by_level(keymap, code, layout, 0, &keysyms);
+-            if (keysyms && isLatin(keysyms[0]))
++            if (keysyms && isLatin1(keysyms[0]))
+                 nrLatinKeys++;
+             if (nrLatinKeys > 10) // arbitrarily chosen threshold
+                 return;
+@@ -766,7 +767,7 @@ xkb_keysym_t QXkbCommon::lookupLatinKeysym(xkb_state *state, xkb_keycode_t keyco
+         xkb_level_index_t level = xkb_state_key_get_level(state, keycode, layout);
+         if (xkb_keymap_key_get_syms_by_level(keymap, keycode, layout, level, &syms) != 1)
+             continue;
+-        if (isLatin(syms[0])) {
++        if (isLatin1(syms[0])) {
+             sym = syms[0];
+             break;
+         }
+diff --git a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
+index 561eae03db..8389bd8f5a 100644
+--- a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
++++ b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
+@@ -94,8 +94,8 @@ public:
+     static void verifyHasLatinLayout(xkb_keymap *keymap);
+     static xkb_keysym_t lookupLatinKeysym(xkb_state *state, xkb_keycode_t keycode);
+ 
+-    static bool isLatin(xkb_keysym_t sym) {
+-        return ((sym >= 'a' && sym <= 'z') || (sym >= 'A' && sym <= 'Z'));
++    static bool isLatin1(xkb_keysym_t sym) {
++        return sym <= 0xff;
+     }
+     static bool isKeypad(xkb_keysym_t sym) {
+         return sym >= XKB_KEY_KP_Space && sym <= XKB_KEY_KP_9;
+diff --git a/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp b/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
+index 8cd7f9b368..406f84663f 100644
+--- a/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
++++ b/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
+@@ -318,7 +318,7 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources,
+ 
+     if (current < 0 && crtc_mode.clock != 0) {
+         modes << crtc_mode;
+-        current = mode.size() - 1;
++        current = modes.size() - 1;
+     }
+ 
+     if (configuration == OutputConfigCurrent)
+diff --git a/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp b/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
+index 9153fd20bb..255ea5e33e 100644
+--- a/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
++++ b/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
+@@ -194,6 +194,9 @@ QString AtSpiAdaptor::introspect(const QString &path) const
+                 "      <arg direction=\"out\" type=\"(so)\"/>\n"
+                 "      <annotation value=\"QSpiObjectReference\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n"
+                 "    </method>\n"
++                "    <method name=\"GetAccessibleId\">\n"
++                "      <arg direction=\"out\" type=\"s\"/>\n"
++                "    </method>\n"
+                 "  </interface>\n"
+                 );
+ 
+@@ -913,8 +916,17 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+     }
+     case QAccessible::NameChanged: {
+         if (sendObject || sendObject_property_change || sendObject_property_change_accessible_name) {
+-            QString path = pathForInterface(event->accessibleInterface());
+-            QVariantList args = packDBusSignalArguments(QLatin1String("accessible-name"), 0, 0, variantForPath(path));
++            QAccessibleInterface *iface = event->accessibleInterface();
++            if (!iface) {
++                qCDebug(lcAccessibilityAtspi,
++                        "NameChanged event from invalid accessible.");
++                return;
++            }
++
++            QString path = pathForInterface(iface);
++            QVariantList args = packDBusSignalArguments(
++                QLatin1String("accessible-name"), 0, 0,
++                QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Name))));
+             sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                            QLatin1String("PropertyChange"), args);
+         }
+@@ -922,8 +934,17 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+     }
+     case QAccessible::DescriptionChanged: {
+         if (sendObject || sendObject_property_change || sendObject_property_change_accessible_description) {
+-            QString path = pathForInterface(event->accessibleInterface());
+-            QVariantList args = packDBusSignalArguments(QLatin1String("accessible-description"), 0, 0, variantForPath(path));
++            QAccessibleInterface *iface = event->accessibleInterface();
++            if (!iface) {
++                qCDebug(lcAccessibilityAtspi,
++                        "DescriptionChanged event from invalid accessible.");
++                return;
++            }
++
++            QString path = pathForInterface(iface);
++            QVariantList args = packDBusSignalArguments(
++                QLatin1String("accessible-description"), 0, 0,
++                QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Description))));
+             sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                            QLatin1String("PropertyChange"), args);
+         }
+@@ -1038,7 +1059,9 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+                 // Combo Box with AT-SPI likes to be special
+                 // It requires a name-change to update caches and then selection-changed
+                 QString path = pathForInterface(iface);
+-                QVariantList args1 = packDBusSignalArguments(QLatin1String("accessible-name"), 0, 0, variantForPath(path));
++                QVariantList args1 = packDBusSignalArguments(
++                    QLatin1String("accessible-name"), 0, 0,
++                    QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Name))));
+                 sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                                QLatin1String("PropertyChange"), args1);
+                 QVariantList args2 = packDBusSignalArguments(QString(), 0, 0, QVariant::fromValue(QDBusVariant(QVariant(0))));
+@@ -1358,6 +1381,26 @@ void AtSpiAdaptor::registerApplication()
+     delete registry;
+ }
+ 
++namespace {
++QString accessibleIdForAccessible(QAccessibleInterface *accessible)
++{
++    QString result;
++    while (accessible) {
++        if (!result.isEmpty())
++            result.prepend(QLatin1Char('.'));
++        if (auto obj = accessible->object()) {
++            const QString name = obj->objectName();
++            if (!name.isEmpty())
++                result.prepend(name);
++            else
++                result.prepend(QString::fromUtf8(obj->metaObject()->className()));
++        }
++        accessible = accessible->parent();
++    }
++    return result;
++}
++} // namespace
++
+ // Accessible
+ bool AtSpiAdaptor::accessibleInterface(QAccessibleInterface *interface, const QString &function, const QDBusMessage &message, const QDBusConnection &connection)
+ {
+@@ -1441,6 +1484,9 @@ bool AtSpiAdaptor::accessibleInterface(QAccessibleInterface *interface, const QS
+             children << ref;
+         }
+         connection.send(message.createReply(QVariant::fromValue(children)));
++    } else if (function == QLatin1String("GetAccessibleId")) {
++        sendReply(connection, message,
++                  QVariant::fromValue(QDBusVariant(accessibleIdForAccessible(interface))));
+     } else {
+         qCDebug(lcAccessibilityAtspi) << "WARNING: AtSpiAdaptor::accessibleInterface does not implement " << function << message.path();
+         return false;
+diff --git a/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp b/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
+index 45ddc8e496..cc734abc63 100644
+--- a/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
++++ b/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
+@@ -69,6 +69,21 @@ QT_BEGIN_NAMESPACE
+ DBusConnection::DBusConnection(QObject *parent)
+     : QObject(parent), m_a11yConnection(QString()), m_enabled(false)
+ {
++    // If the bus is explicitly set via env var it overrides everything else.
++    QByteArray addressEnv = qgetenv("AT_SPI_BUS_ADDRESS");
++    if (!addressEnv.isEmpty()) {
++        // Only connect on next loop run, connections to our enabled signal are
++        // only established after the ctor returns.
++        QMetaObject::invokeMethod(
++                this,
++                [this, addressEnv] {
++                    m_enabled = true;
++                    connectA11yBus(QString::fromLocal8Bit(addressEnv));
++                },
++                Qt::QueuedConnection);
++        return;
++    }
++
+     // Start monitoring if "org.a11y.Bus" is registered as DBus service.
+     QDBusConnection c = QDBusConnection::sessionBus();
+     if (!c.isConnected()) {
+diff --git a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
+index 1a3cab275d..2abe039126 100644
+--- a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
++++ b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
+@@ -51,6 +51,9 @@
+ #include <QtCore/QStandardPaths>
+ #include <QtCore/QUrl>
+ 
++#include <QtGui/QGuiApplication>
++#include <QtGui/QWindow>
++
+ #if QT_CONFIG(dbus)
+ // These QtCore includes are needed for xdg-desktop-portal support
+ #include <QtCore/private/qcore_unix_p.h>
+@@ -58,6 +61,8 @@
+ #include <QtCore/QFileInfo>
+ #include <QtCore/QUrlQuery>
+ 
++#include <QtGui/QColor>
++
+ #include <QtDBus/QDBusConnection>
+ #include <QtDBus/QDBusMessage>
+ #include <QtDBus/QDBusPendingCall>
+@@ -142,6 +147,8 @@ static inline bool detectWebBrowser(const QByteArray &desktop,
+     }
+ 
+     if (desktop == QByteArray("KDE")) {
++        if (checkExecutable(QStringLiteral("kde-open5"), browser))
++            return true;
+         // Konqueror launcher
+         if (checkExecutable(QStringLiteral("kfmclient"), browser)) {
+             browser->append(QLatin1String(" exec"));
+@@ -296,8 +303,135 @@ static inline QDBusMessage xdgDesktopPortalSendEmail(const QUrl &url)
+ 
+     return QDBusConnection::sessionBus().call(message);
+ }
++
++namespace {
++struct XDGDesktopColor
++{
++    double r = 0;
++    double g = 0;
++    double b = 0;
++
++    QColor toQColor() const
++    {
++        constexpr auto rgbMax = 255;
++        return { static_cast<int>(r * rgbMax), static_cast<int>(g * rgbMax),
++                 static_cast<int>(b * rgbMax) };
++    }
++};
++
++const QDBusArgument &operator>>(const QDBusArgument &argument, XDGDesktopColor &myStruct)
++{
++    argument.beginStructure();
++    argument >> myStruct.r >> myStruct.g >> myStruct.b;
++    argument.endStructure();
++    return argument;
++}
++
++class XdgDesktopPortalColorPicker : public QPlatformServiceColorPicker
++{
++    Q_OBJECT
++public:
++    XdgDesktopPortalColorPicker(const QString &parentWindowId, QWindow *parent)
++        : QPlatformServiceColorPicker(parent), m_parentWindowId(parentWindowId)
++    {
++    }
++
++    void pickColor() override
++    {
++        // DBus signature:
++        // PickColor (IN   s      parent_window,
++        //            IN   a{sv}  options
++        //            OUT  o      handle)
++        // Options:
++        // handle_token (s) -  A string that will be used as the last element of the @handle.
++
++        QDBusMessage message = QDBusMessage::createMethodCall(
++                QStringLiteral("org.freedesktop.portal.Desktop"), QStringLiteral("/org/freedesktop/portal/desktop"),
++                QStringLiteral("org.freedesktop.portal.Screenshot"), QStringLiteral("PickColor"));
++        message << m_parentWindowId << QVariantMap();
++
++        QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
++        auto watcher = new QDBusPendingCallWatcher(pendingCall, this);
++        connect(watcher, &QDBusPendingCallWatcher::finished, this,
++                [this](QDBusPendingCallWatcher *watcher) {
++                    watcher->deleteLater();
++                    QDBusPendingReply<QDBusObjectPath> reply = *watcher;
++                    if (reply.isError()) {
++                        qWarning("DBus call to pick color failed: %s",
++                                 qPrintable(reply.error().message()));
++                        Q_EMIT colorPicked({});
++                    } else {
++                        QDBusConnection::sessionBus().connect(
++                                QStringLiteral("org.freedesktop.portal.Desktop"), reply.value().path(),
++                                QStringLiteral("org.freedesktop.portal.Request"), QStringLiteral("Response"), this,
++                                // clang-format off
++                                SLOT(gotColorResponse(uint,QVariantMap))
++                                // clang-format on
++                        );
++                    }
++                });
++    }
++
++private Q_SLOTS:
++    void gotColorResponse(uint result, const QVariantMap &map)
++    {
++        if (result != 0)
++            return;
++        XDGDesktopColor color{};
++        map.value(QStringLiteral("color")).value<QDBusArgument>() >> color;
++        Q_EMIT colorPicked(color.toQColor());
++        deleteLater();
++    }
++
++private:
++    const QString m_parentWindowId;
++};
++} // namespace
++
+ #endif // QT_CONFIG(dbus)
+ 
++QGenericUnixServices::QGenericUnixServices()
++{
++#if QT_CONFIG(dbus)
++    if (qEnvironmentVariableIntValue("QT_NO_XDG_DESKTOP_PORTAL") > 0) {
++        return;
++    }
++    QDBusMessage message = QDBusMessage::createMethodCall(
++            QStringLiteral("org.freedesktop.portal.Desktop"), QStringLiteral("/org/freedesktop/portal/desktop"),
++            QStringLiteral("org.freedesktop.DBus.Properties"), QStringLiteral("Get"));
++    message << QStringLiteral("org.freedesktop.portal.Screenshot")
++            << QStringLiteral("version");
++
++    QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
++    auto watcher = new QDBusPendingCallWatcher(pendingCall);
++    QObject::connect(watcher, &QDBusPendingCallWatcher::finished, watcher,
++                     [this](QDBusPendingCallWatcher *watcher) {
++                         watcher->deleteLater();
++                         QDBusPendingReply<QVariant> reply = *watcher;
++                         if (!reply.isError() && reply.value().toUInt() >= 2)
++                             m_hasScreenshotPortalWithColorPicking = true;
++                     });
++
++#endif
++}
++
++QPlatformServiceColorPicker *QGenericUnixServices::colorPicker(QWindow *parent)
++{
++#if QT_CONFIG(dbus)
++    // Make double sure that we are in a wayland environment. In particular check
++    // WAYLAND_DISPLAY so also XWayland apps benefit from portal-based color picking.
++    // Outside wayland we'll rather rely on other means than the XDG desktop portal.
++    if (!qEnvironmentVariableIsEmpty("WAYLAND_DISPLAY")
++        || QGuiApplication::platformName().startsWith(QLatin1String("wayland"))) {
++        return new XdgDesktopPortalColorPicker(portalWindowIdentifier(parent), parent);
++    }
++    return nullptr;
++#else
++    Q_UNUSED(parent);
++    return nullptr;
++#endif
++}
++
+ QByteArray QGenericUnixServices::desktopEnvironment() const
+ {
+     static const QByteArray result = detectDesktopEnvironment();
+@@ -352,6 +486,8 @@ bool QGenericUnixServices::openDocument(const QUrl &url)
+ }
+ 
+ #else
++QGenericUnixServices::QGenericUnixServices() = default;
++
+ QByteArray QGenericUnixServices::desktopEnvironment() const
+ {
+     return QByteArrayLiteral("UNKNOWN");
+@@ -371,6 +507,30 @@ bool QGenericUnixServices::openDocument(const QUrl &url)
+     return false;
+ }
+ 
++QPlatformServiceColorPicker *QGenericUnixServices::colorPicker(QWindow *parent)
++{
++    Q_UNUSED(parent);
++    return nullptr;
++}
++
+ #endif // QT_NO_MULTIPROCESS
+ 
++QString QGenericUnixServices::portalWindowIdentifier(QWindow *window)
++{
++    if (QGuiApplication::platformName() == QLatin1String("xcb"))
++        return QStringLiteral("x11:") + QString::number(window->winId(), 16);
++    return QString();
++}
++
++bool QGenericUnixServices::hasCapability(Capability capability) const
++{
++    switch (capability) {
++    case Capability::ColorPicking:
++        return m_hasScreenshotPortalWithColorPicking;
++    }
++    return false;
++}
++
+ QT_END_NAMESPACE
++
++#include "qgenericunixservices.moc"
+diff --git a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
+index 8ac3de6f03..30924e64bd 100644
+--- a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
++++ b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
+@@ -59,16 +59,21 @@ QT_BEGIN_NAMESPACE
+ class QGenericUnixServices : public QPlatformServices
+ {
+ public:
+-    QGenericUnixServices() {}
++    QGenericUnixServices();
+ 
+     QByteArray desktopEnvironment() const override;
+ 
++    bool hasCapability(Capability capability) const override;
+     bool openUrl(const QUrl &url) override;
+     bool openDocument(const QUrl &url) override;
++    QPlatformServiceColorPicker *colorPicker(QWindow *parent = nullptr) override;
++
++    virtual QString portalWindowIdentifier(QWindow *window);
+ 
+ private:
+     QString m_webBrowser;
+     QString m_documentLauncher;
++    bool m_hasScreenshotPortalWithColorPicking = false;
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
+index 09470bccc6..cc7c7d4d8a 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
+@@ -69,6 +69,7 @@ const QString MenuBarPath = QLatin1String("/MenuBar");
+ */
+ QDBusMenuConnection::QDBusMenuConnection(QObject *parent, const QString &serviceName)
+     : QObject(parent)
++    , m_serviceName(serviceName)
+     , m_connection(serviceName.isNull() ? QDBusConnection::sessionBus()
+                                         : QDBusConnection::connectToBus(QDBusConnection::SessionBus, serviceName))
+     , m_dbusWatcher(new QDBusServiceWatcher(StatusNotifierWatcherService, m_connection, QDBusServiceWatcher::WatchForRegistration, this))
+@@ -83,6 +84,12 @@ QDBusMenuConnection::QDBusMenuConnection(QObject *parent, const QString &service
+ #endif
+ }
+ 
++QDBusMenuConnection::~QDBusMenuConnection()
++{
++  if (!m_serviceName.isEmpty() && m_connection.isConnected())
++      QDBusConnection::disconnectFromBus(m_serviceName);
++}
++
+ void QDBusMenuConnection::dbusError(const QDBusError &error)
+ {
+     qWarning() << "QDBusTrayIcon encountered a D-Bus error:" << error;
+@@ -105,13 +112,7 @@ void QDBusMenuConnection::unregisterTrayIconMenu(QDBusTrayIcon *item)
+ 
+ bool QDBusMenuConnection::registerTrayIcon(QDBusTrayIcon *item)
+ {
+-    bool success = connection().registerService(item->instanceId());
+-    if (!success) {
+-        qWarning() << "failed to register service" << item->instanceId();
+-        return false;
+-    }
+-
+-    success = connection().registerObject(StatusNotifierItemPath, item);
++    bool success = connection().registerObject(StatusNotifierItemPath, item);
+     if (!success) {
+         unregisterTrayIcon(item);
+         qWarning() << "failed to register" << item->instanceId() << StatusNotifierItemPath;
+@@ -126,21 +127,18 @@ bool QDBusMenuConnection::registerTrayIcon(QDBusTrayIcon *item)
+ 
+ bool QDBusMenuConnection::registerTrayIconWithWatcher(QDBusTrayIcon *item)
+ {
++    Q_UNUSED(item);
+     QDBusMessage registerMethod = QDBusMessage::createMethodCall(
+                 StatusNotifierWatcherService, StatusNotifierWatcherPath, StatusNotifierWatcherService,
+                 QLatin1String("RegisterStatusNotifierItem"));
+-    registerMethod.setArguments(QVariantList() << item->instanceId());
++    registerMethod.setArguments(QVariantList() << m_connection.baseService());
+     return m_connection.callWithCallback(registerMethod, this, SIGNAL(trayIconRegistered()), SLOT(dbusError(QDBusError)));
+ }
+ 
+-bool QDBusMenuConnection::unregisterTrayIcon(QDBusTrayIcon *item)
++void QDBusMenuConnection::unregisterTrayIcon(QDBusTrayIcon *item)
+ {
+     unregisterTrayIconMenu(item);
+     connection().unregisterObject(StatusNotifierItemPath);
+-    bool success = connection().unregisterService(item->instanceId());
+-    if (!success)
+-        qWarning() << "failed to unregister service" << item->instanceId();
+-    return success;
+ }
+ #endif // QT_NO_SYSTEMTRAYICON
+ 
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
+index f484795fbb..97bdfabb85 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
++++ b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
+@@ -70,6 +70,7 @@ class QDBusMenuConnection : public QObject
+ 
+ public:
+     QDBusMenuConnection(QObject *parent = nullptr, const QString &serviceName = QString());
++    ~QDBusMenuConnection();
+     QDBusConnection connection() const { return m_connection; }
+     QDBusServiceWatcher *dbusWatcher() const { return m_dbusWatcher; }
+     bool isStatusNotifierHostRegistered() const { return m_statusNotifierHostRegistered; }
+@@ -78,7 +79,7 @@ public:
+     void unregisterTrayIconMenu(QDBusTrayIcon *item);
+     bool registerTrayIcon(QDBusTrayIcon *item);
+     bool registerTrayIconWithWatcher(QDBusTrayIcon *item);
+-    bool unregisterTrayIcon(QDBusTrayIcon *item);
++    void unregisterTrayIcon(QDBusTrayIcon *item);
+ #endif // QT_NO_SYSTEMTRAYICON
+ 
+ Q_SIGNALS:
+@@ -90,6 +91,7 @@ private Q_SLOTS:
+     void dbusError(const QDBusError &error);
+ 
+ private:
++    QString m_serviceName;
+     QDBusConnection m_connection;
+     QDBusServiceWatcher *m_dbusWatcher;
+     bool m_statusNotifierHostRegistered;
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp b/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
+index bede70975a..76bfec5e5a 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
+@@ -71,8 +71,12 @@ Q_LOGGING_CATEGORY(qLcTray, "qt.qpa.tray")
+ static QString iconTempPath()
+ {
+     QString tempPath = QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation);
+-    if (!tempPath.isEmpty())
++    if (!tempPath.isEmpty()) {
++        QString flatpakId = qEnvironmentVariable("FLATPAK_ID");
++        if (!flatpakId.isEmpty() && QFileInfo::exists(QLatin1String("/.flatpak-info")))
++            tempPath += QLatin1String("/app/") + flatpakId;
+         return tempPath;
++    }
+ 
+     tempPath = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation);
+ 
+diff --git a/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+index cb1b39db64..6e01af052c 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+@@ -755,6 +755,9 @@ QVariant QGnomeTheme::themeHint(QPlatformTheme::ThemeHint hint) const
+         return QVariant(QChar(0x2022));
+     case QPlatformTheme::UiEffects:
+         return QVariant(int(HoverEffect));
++    case QPlatformTheme::ButtonPressKeys:
++        return QVariant::fromValue(
++                QList<Qt::Key>({ Qt::Key_Space, Qt::Key_Return, Qt::Key_Enter, Qt::Key_Select }));
+     default:
+         break;
+     }
+diff --git a/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp b/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
+index 98e05195ee..1e92f43dec 100644
+--- a/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
++++ b/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
+@@ -343,8 +343,7 @@ void QEglFSCursor::paintOnScreen()
+     // screens are siblings of each other. When not enabled, the sibling list
+     // only contains m_screen itself.
+     for (QPlatformScreen *screen : m_screen->virtualSiblings()) {
+-        if (screen->geometry().contains(cr.topLeft().toPoint() + m_cursor.hotSpot)
+-            && QOpenGLContext::currentContext()->screen() == screen->screen())
++        if (screen->geometry().contains(cr.topLeft().toPoint() + m_cursor.hotSpot))
+         {
+             cr.translate(-screen->geometry().topLeft());
+             const QSize screenSize = screen->geometry().size();
+@@ -468,11 +467,12 @@ void QEglFSCursor::draw(const QRectF &r)
+ {
+     StateSaver stateSaver;
+ 
+-    QEglFSCursorData &gfx = static_cast<QEglFSContext*>(QOpenGLContext::currentContext()->handle())->cursorData;
+-    if (!gfx.program) {
+-        // one time initialization
++    // one time initialization
++    if (!QOpenGLFunctions::d_ptr)
+         initializeOpenGLFunctions();
+ 
++    QEglFSCursorData &gfx = static_cast<QEglFSContext*>(QOpenGLContext::currentContext()->handle())->cursorData;
++    if (!gfx.program) {
+         createShaderPrograms();
+ 
+         if (!gfx.atlasTexture) {
+diff --git a/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp b/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
+index 645a0ae2e9..3e0e406f1a 100644
+--- a/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
++++ b/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
+@@ -179,7 +179,7 @@ void QEglFSKmsEventReader::create(QEglFSKmsDevice *device)
+ 
+     m_device = device;
+ 
+-    qCDebug(qLcEglfsKmsDebug, "Initalizing event reader for device %p fd %d",
++    qCDebug(qLcEglfsKmsDebug, "Initializing event reader for device %p fd %d",
+             m_device, m_device->fd());
+ 
+     m_thread = new QEglFSKmsEventReaderThread(m_device->fd());
+diff --git a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
+index 141fb68a23..d4294d425a 100644
+--- a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
++++ b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
+@@ -122,11 +122,13 @@ QOffscreenIntegration::QOffscreenIntegration()
+ #endif
+     m_services.reset(new QPlatformServices);
+ 
+-    QWindowSystemInterface::handleScreenAdded(new QOffscreenScreen);
++    m_screen = new QOffscreenScreen;
++    QWindowSystemInterface::handleScreenAdded(m_screen);
+ }
+ 
+ QOffscreenIntegration::~QOffscreenIntegration()
+ {
++    QWindowSystemInterface::handleScreenRemoved(m_screen);
+ }
+ 
+ void QOffscreenIntegration::initialize()
+diff --git a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
+index 0ea90f6c2f..fe00fde07c 100644
+--- a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
++++ b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
+@@ -84,6 +84,7 @@ protected:
+ #endif
+     QScopedPointer<QPlatformInputContext> m_inputContext;
+     QScopedPointer<QPlatformServices> m_services;
++    QPlatformScreen *m_screen;
+     mutable QScopedPointer<QPlatformNativeInterface> m_nativeInterface;
+ };
+ 
+diff --git a/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp b/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
+index 6fa5a8a2b3..1f49f0aefd 100644
+--- a/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
++++ b/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
+@@ -48,6 +48,7 @@
+ #include <qpa/qplatformnativeinterface.h>
+ #include <QtPlatformHeaders/qwglnativecontext.h>
+ 
++#include <private/qsystemlibrary_p.h>
+ #include <algorithm>
+ 
+ #include <wingdi.h>
+@@ -162,19 +163,25 @@ QFunctionPointer QWindowsOpengl32DLL::resolve(const char *name)
+ 
+ bool QWindowsOpengl32DLL::init(bool softwareRendering)
+ {
+-    const QByteArray opengl32 = QByteArrayLiteral("opengl32.dll");
+-    const QByteArray swopengl = QByteArrayLiteral("opengl32sw.dll");
++    const QByteArray opengl32 = QByteArrayLiteral("opengl32");
++    const QByteArray swopengl = QByteArrayLiteral("opengl32sw");
++    bool useSystemLib = false;
+ 
+     QByteArray openglDll = qgetenv("QT_OPENGL_DLL");
+-    if (openglDll.isEmpty())
++    if (openglDll.isEmpty()) {
+         openglDll = softwareRendering ? swopengl : opengl32;
++        useSystemLib = !softwareRendering;
++    }
+ 
+     openglDll = openglDll.toLower();
+     m_nonOpengl32 = openglDll != opengl32;
+ 
+     qCDebug(lcQpaGl) << "Qt: Using WGL and OpenGL from" << openglDll;
+ 
+-    m_lib = ::LoadLibraryA(openglDll.constData());
++    if (useSystemLib)
++        m_lib = QSystemLibrary::load((wchar_t*)(QString::fromLatin1(openglDll).utf16()));
++    else
++        m_lib = LoadLibraryA(openglDll.constData());
+     if (!m_lib) {
+         qErrnoWarning(::GetLastError(), "Failed to load %s", openglDll.constData());
+         return false;
+@@ -184,7 +191,7 @@ bool QWindowsOpengl32DLL::init(bool softwareRendering)
+         // Load opengl32.dll always. GDI functions like ChoosePixelFormat do
+         // GetModuleHandle for opengl32.dll and behave differently (and call back into
+         // opengl32) when the module is present. This is fine for dummy contexts and windows.
+-        ::LoadLibraryA("opengl32.dll");
++        QSystemLibrary::load(L"opengl32");
+     }
+ 
+     wglCreateContext = reinterpret_cast<HGLRC (WINAPI *)(HDC)>(resolve("wglCreateContext"));
+diff --git a/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp b/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
+index d7d186e804..9eb4011bf2 100644
+--- a/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
++++ b/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
+@@ -49,6 +49,7 @@
+ #include <QtCore/qstandardpaths.h>
+ #include <QtCore/qlibraryinfo.h>
+ #include <QtCore/qhash.h>
++#include <private/qsystemlibrary_p.h>
+ 
+ #ifndef QT_NO_OPENGL
+ #include <private/qopengl_p.h>
+@@ -396,7 +397,7 @@ bool QWindowsOpenGLTester::testDesktopGL()
+ 
+     // Test #1: Load opengl32.dll and try to resolve an OpenGL 2 function.
+     // This will typically fail on systems that do not have a real OpenGL driver.
+-    lib = LoadLibraryA("opengl32.dll");
++    lib = QSystemLibrary::load(L"opengl32");
+     if (lib) {
+         CreateContext = reinterpret_cast<CreateContextType>(
+             reinterpret_cast<QFunctionPointer>(::GetProcAddress(lib, "wglCreateContext")));
+diff --git a/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp b/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
+index 1afa00cfc9..118af6ce73 100644
+--- a/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
++++ b/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
+@@ -41,6 +41,7 @@
+ 
+ #include <QRect>
+ #include <QList>
++#include <QMap>
+ #include <QDebug>
+ 
+ #include <qmath.h>
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp b/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
+index 9e2a37a6a1..e6e175a118 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
+@@ -488,12 +488,12 @@ void QXcbConnection::printXcbError(const char *message, xcb_generic_error_t *err
+     uint clamped_error_code = qMin<uint>(error->error_code, (sizeof(xcb_errors) / sizeof(xcb_errors[0])) - 1);
+     uint clamped_major_code = qMin<uint>(error->major_code, (sizeof(xcb_protocol_request_codes) / sizeof(xcb_protocol_request_codes[0])) - 1);
+ 
+-    qCWarning(lcQpaXcb, "%s: %d (%s), sequence: %d, resource id: %d, major code: %d (%s), minor code: %d",
+-             message,
+-             int(error->error_code), xcb_errors[clamped_error_code],
+-             int(error->sequence), int(error->resource_id),
+-             int(error->major_code), xcb_protocol_request_codes[clamped_major_code],
+-             int(error->minor_code));
++    qCDebug(lcQpaXcb, "%s: %d (%s), sequence: %d, resource id: %d, major code: %d (%s), minor code: %d",
++            message,
++            int(error->error_code), xcb_errors[clamped_error_code],
++            int(error->sequence), int(error->resource_id),
++            int(error->major_code), xcb_protocol_request_codes[clamped_major_code],
++            int(error->minor_code));
+ }
+ 
+ static Qt::MouseButtons translateMouseButtons(int s)
+@@ -702,6 +702,8 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
+             QXcbVirtualDesktop *virtualDesktop = virtualDesktopForRootWindow(propertyNotify->window);
+             if (virtualDesktop)
+                 virtualDesktop->updateWorkArea();
++        } else if (propertyNotify->atom == atom(QXcbAtom::_NET_SUPPORTED)) {
++            m_wmSupport->updateNetWMAtoms();
+         } else {
+             HANDLE_PLATFORM_WINDOW_EVENT(xcb_property_notify_event_t, window, handlePropertyNotifyEvent);
+         }
+@@ -750,7 +752,7 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
+                 case XCB_XKB_NEW_KEYBOARD_NOTIFY: {
+                     xcb_xkb_new_keyboard_notify_event_t *ev = &xkb_event->new_keyboard_notify;
+                     if (ev->changed & XCB_XKB_NKN_DETAIL_KEYCODES)
+-                        m_keyboard->updateKeymap(ev);
++                        m_keyboard->updateKeymap();
+                     break;
+                 }
+                 default:
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp b/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
+index 76869ced60..02d2eebb56 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
+@@ -274,8 +274,7 @@ QPlatformWindow *QXcbIntegration::createForeignWindow(QWindow *window, WId nativ
+ #ifndef QT_NO_OPENGL
+ QPlatformOpenGLContext *QXcbIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
+ {
+-    QXcbScreen *screen = static_cast<QXcbScreen *>(context->screen()->handle());
+-    QXcbGlIntegration *glIntegration = screen->connection()->glIntegration();
++    QXcbGlIntegration *glIntegration = defaultConnection()->glIntegration();
+     if (!glIntegration) {
+         qWarning("QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled");
+         return nullptr;
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+index efecd7e2d1..e8286381a2 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+@@ -365,17 +365,6 @@ void QXcbKeyboard::updateKeymap(xcb_mapping_notify_event_t *event)
+     updateKeymap();
+ }
+ 
+-void QXcbKeyboard::updateKeymap(xcb_xkb_new_keyboard_notify_event_t *event)
+-{
+-    if (!event)
+-        return;
+-
+-    if (event->deviceID != event->oldDeviceID)
+-        m_config = false;
+-
+-    updateKeymap();
+-}
+-
+ void QXcbKeyboard::updateKeymap()
+ {
+     KeysymModifierMap keysymMods;
+@@ -383,6 +372,8 @@ void QXcbKeyboard::updateKeymap()
+         keysymMods = keysymsToModifiers();
+     updateModifiers(keysymMods);
+ 
++    m_config = true;
++
+     if (!m_xkbContext) {
+         m_xkbContext.reset(xkb_context_new(XKB_CONTEXT_NO_DEFAULT_INCLUDES));
+         if (!m_xkbContext) {
+@@ -398,13 +389,8 @@ void QXcbKeyboard::updateKeymap()
+     if (connection()->hasXKB()) {
+         m_xkbKeymap.reset(xkb_x11_keymap_new_from_device(m_xkbContext.get(), xcb_connection(),
+                                                          core_device_id, XKB_KEYMAP_COMPILE_NO_FLAGS));
+-        if (m_xkbKeymap) {
+-            if (m_config)
+-                m_xkbState.reset(xkb_state_new(m_xkbKeymap.get()));
+-            else
+-                m_xkbState.reset(xkb_x11_state_new_from_device(m_xkbKeymap.get(), xcb_connection(), core_device_id));
+-
+-        }
++        if (m_xkbKeymap)
++            m_xkbState.reset(xkb_x11_state_new_from_device(m_xkbKeymap.get(), xcb_connection(), core_device_id));
+     } else {
+         m_xkbKeymap.reset(keymapFromCore(keysymMods));
+         if (m_xkbKeymap)
+@@ -425,8 +411,6 @@ void QXcbKeyboard::updateKeymap()
+     updateXKBMods();
+ 
+     QXkbCommon::verifyHasLatinLayout(m_xkbKeymap.get());
+-
+-    m_config = true;
+ }
+ 
+ QList<int> QXcbKeyboard::possibleKeys(const QKeyEvent *event) const
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
+index b652c85fe3..0ee08aeff2 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
++++ b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
+@@ -69,7 +69,6 @@ public:
+ 
+     Qt::KeyboardModifiers translateModifiers(int s) const;
+     void updateKeymap(xcb_mapping_notify_event_t *event);
+-    void updateKeymap(xcb_xkb_new_keyboard_notify_event_t *event);
+     void updateKeymap();
+     QList<int> possibleKeys(const QKeyEvent *event) const;
+ 
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp b/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
+index ffda7b6a57..863e961f4c 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
+@@ -564,11 +564,6 @@ void QXcbWindow::setGeometry(const QRect &rect)
+ {
+     QPlatformWindow::setGeometry(rect);
+ 
+-    if (shouldDeferTask(Task::SetGeometry)) {
+-        m_deferredGeometry = rect;
+-        return;
+-    }
+-
+     propagateSizeHints();
+ 
+     QXcbScreen *currentScreen = xcbScreen();
+@@ -693,9 +688,6 @@ void QXcbWindow::setVisible(bool visible)
+ 
+ void QXcbWindow::show()
+ {
+-    if (shouldDeferTask(Task::Map))
+-        return;
+-
+     if (window()->isTopLevel()) {
+ 
+         // update WM_NORMAL_HINTS
+@@ -706,7 +698,7 @@ void QXcbWindow::show()
+         if (isTransient(window())) {
+             const QWindow *tp = window()->transientParent();
+             if (tp && tp->handle())
+-                transientXcbParent = static_cast<const QXcbWindow *>(tp->handle())->winId();
++                transientXcbParent = tp->handle()->winId();
+             // Default to client leader if there is no transient parent, else modal dialogs can
+             // be hidden by their parents.
+             if (!transientXcbParent)
+@@ -746,10 +738,6 @@ void QXcbWindow::show()
+ 
+ void QXcbWindow::hide()
+ {
+-    if (shouldDeferTask(Task::Unmap))
+-        return;
+-
+-    m_wmStateValid = false;
+     xcb_unmap_window(xcb_connection(), m_window);
+ 
+     // send synthetic UnmapNotify event according to icccm 4.1.4
+@@ -909,9 +897,6 @@ QXcbWindow::NetWmStates QXcbWindow::netWmStates()
+ 
+ void QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
+ {
+-    if (shouldDeferTask(Task::SetWindowFlags))
+-        return;
+-
+     Qt::WindowType type = static_cast<Qt::WindowType>(int(flags & Qt::WindowType_Mask));
+ 
+     if (type == Qt::ToolTip)
+@@ -941,8 +926,6 @@ void QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
+ 
+     setTransparentForMouseEvents(flags & Qt::WindowTransparentForInput);
+     updateDoesNotAcceptFocus(flags & Qt::WindowDoesNotAcceptFocus);
+-
+-    m_isWmManagedWindow = !(flags & Qt::X11BypassWindowManagerHint);
+ }
+ 
+ void QXcbWindow::setMotifWmHints(Qt::WindowFlags flags)
+@@ -1142,9 +1125,6 @@ void QXcbWindow::setWindowState(Qt::WindowStates state)
+     if (state == m_windowState)
+         return;
+ 
+-    if (shouldDeferTask(Task::SetWindowState))
+-        return;
+-
+     // unset old state
+     if (m_windowState & Qt::WindowMinimized)
+         xcb_map_window(xcb_connection(), m_window);
+@@ -1350,6 +1330,12 @@ void QXcbWindow::setWindowIcon(const QIcon &icon)
+     }
+ 
+     if (!icon_data.isEmpty()) {
++        // Ignore icon exceeding maximum xcb request length
++        if (icon_data.size() > xcb_get_maximum_request_length(xcb_connection())) {
++            qWarning("Ignoring window icon: Size %llu exceeds maximum xcb request length %u.",
++                     icon_data.size(), xcb_get_maximum_request_length(xcb_connection()));
++            return;
++        }
+         xcb_change_property(xcb_connection(),
+                             XCB_PROP_MODE_REPLACE,
+                             m_window,
+@@ -1639,7 +1625,7 @@ void QXcbWindow::setWmWindowType(QXcbWindowFunctions::WmWindowTypes types, Qt::W
+         break;
+     }
+ 
+-    if ((flags & Qt::FramelessWindowHint) && !(type & QXcbWindowFunctions::KdeOverride)) {
++    if ((flags & Qt::FramelessWindowHint) && !(types & QXcbWindowFunctions::KdeOverride)) {
+         // override netwm type - quick and easy for KDE noborder
+         atoms.append(atom(QXcbAtom::_KDE_NET_WM_WINDOW_TYPE_OVERRIDE));
+     }
+@@ -1894,10 +1880,6 @@ void QXcbWindow::handleUnmapNotifyEvent(const xcb_unmap_notify_event_t *event)
+     if (event->window == m_window) {
+         m_mapped = false;
+         QWindowSystemInterface::handleExposeEvent(window(), QRegion());
+-        if (!m_isWmManagedWindow || parent()) {
+-            m_wmStateValid = true;
+-            handleDeferredTasks();
+-        }
+     }
+ }
+ 
+@@ -2212,98 +2194,30 @@ void QXcbWindow::handleLeaveNotifyEvent(const xcb_leave_notify_event_t *event)
+     handleLeaveNotifyEvent(event->root_x, event->root_y, event->mode, event->detail, event->time);
+ }
+ 
+-bool QXcbWindow::shouldDeferTask(Task task)
+-{
+-    if (m_wmStateValid)
+-        return false;
+-
+-    m_deferredTasks.append(task);
+-    return true;
+-}
+-
+-void QXcbWindow::handleDeferredTasks()
+-{
+-    Q_ASSERT(m_wmStateValid == true);
+-    if (m_deferredTasks.isEmpty())
+-        return;
+-
+-    bool map = false;
+-    bool unmap = false;
+-
+-    QVector<Task> tasks;
+-    for (auto taskIt = m_deferredTasks.rbegin(); taskIt != m_deferredTasks.rend(); ++taskIt) {
+-        if (!tasks.contains(*taskIt))
+-            tasks.prepend(*taskIt);
+-    }
+-
+-    for (Task task : tasks) {
+-        switch (task) {
+-        case Task::Map:
+-            map = true;
+-            unmap = false;
+-            break;
+-        case Task::Unmap:
+-            unmap = true;
+-            map = false;
+-            break;
+-        case Task::SetGeometry:
+-            setGeometry(m_deferredGeometry);
+-            break;
+-        case Task::SetWindowFlags:
+-            setWindowFlags(window()->flags());
+-            break;
+-        case Task::SetWindowState:
+-            setWindowState(window()->windowState());
+-            break;
+-        }
+-    }
+-    m_deferredTasks.clear();
+-
+-    if (map) {
+-        Q_ASSERT(unmap == false);
+-        show();
+-    }
+-    if (unmap) {
+-        Q_ASSERT(map == false);
+-        hide();
+-    }
+-}
+-
+ void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *event)
+ {
+     connection()->setTime(event->time);
+ 
+-    const bool wmStateChanged = event->atom == atom(QXcbAtom::WM_STATE);
+-    const bool netWmStateChanged = event->atom == atom(QXcbAtom::_NET_WM_STATE);
+-    if (netWmStateChanged || wmStateChanged) {
+-        if (wmStateChanged && !m_wmStateValid && m_isWmManagedWindow) {
+-            // ICCCM 4.1.4
+-            // Clients that want to re-use a client window (e.g. by mapping it again)
+-            // after withdrawing it must wait for the withdrawal to be complete before
+-            // proceeding. The preferred method for doing this is for clients to wait for
+-            // a window manager to update or remove the WM_STATE property.
+-            m_wmStateValid = true;
+-            handleDeferredTasks();
+-        }
+-        if (event->state == XCB_PROPERTY_DELETE)
++    const bool propertyDeleted = event->state == XCB_PROPERTY_DELETE;
++
++    if (event->atom == atom(QXcbAtom::_NET_WM_STATE) || event->atom == atom(QXcbAtom::WM_STATE)) {
++        if (propertyDeleted)
+             return;
+ 
+-        if (wmStateChanged) {
++        Qt::WindowStates newState = Qt::WindowNoState;
++
++        if (event->atom == atom(QXcbAtom::WM_STATE)) { // WM_STATE: Quick check for 'Minimize'.
+             auto reply = Q_XCB_REPLY(xcb_get_property, xcb_connection(),
+                                      0, m_window, atom(QXcbAtom::WM_STATE),
+                                      XCB_ATOM_ANY, 0, 1024);
+             if (reply && reply->format == 32 && reply->type == atom(QXcbAtom::WM_STATE)) {
+-                auto data = static_cast<const quint32 *>(xcb_get_property_value(reply.get()));
+-                if (reply->length != 0) {
+-                    const bool changedToWithdrawn = data[0] == XCB_ICCCM_WM_STATE_WITHDRAWN;
+-                    const bool changedToIconic = data[0] == XCB_ICCCM_WM_STATE_ICONIC;
+-                    m_minimized = changedToIconic || (changedToWithdrawn && m_minimized);
+-                }
++                const quint32 *data = (const quint32 *)xcb_get_property_value(reply.get());
++                if (reply->length != 0)
++                    m_minimized = (data[0] == XCB_ICCCM_WM_STATE_ICONIC
++                                   || (data[0] == XCB_ICCCM_WM_STATE_WITHDRAWN && m_minimized));
+             }
+         }
+ 
+-        // _NET_WM_STATE handling
+-        Qt::WindowStates newState = Qt::WindowNoState;
+         const NetWmStates states = netWmStates();
+         // _NET_WM_STATE_HIDDEN should be set by the Window Manager to indicate that a window would
+         // not be visible on the screen if its desktop/viewport were active and its coordinates were
+@@ -2325,6 +2239,7 @@ void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *ev
+             if ((m_windowState & Qt::WindowMinimized) && connection()->mouseGrabber() == this)
+                 connection()->setMouseGrabber(nullptr);
+         }
++        return;
+     } else if (event->atom == atom(QXcbAtom::_NET_FRAME_EXTENTS)) {
+         m_dirtyFrameMargins = true;
+     }
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbwindow.h b/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
+index 55af9279b1..6f5c1f5ed9 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
++++ b/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
+@@ -74,14 +74,6 @@ public:
+ 
+     Q_DECLARE_FLAGS(NetWmStates, NetWmState)
+ 
+-    enum Task {
+-        Map,
+-        Unmap,
+-        SetGeometry,
+-        SetWindowFlags,
+-        SetWindowState
+-    };
+-
+     QXcbWindow(QWindow *window);
+     ~QXcbWindow();
+ 
+@@ -151,9 +143,6 @@ public:
+ 
+     QXcbWindow *toWindow() override;
+ 
+-    bool shouldDeferTask(Task task);
+-    void handleDeferredTasks();
+-
+     void handleMouseEvent(xcb_timestamp_t time, const QPoint &local, const QPoint &global,
+                           Qt::KeyboardModifiers modifiers, QEvent::Type type, Qt::MouseEventSource source);
+ 
+@@ -292,11 +281,6 @@ protected:
+     int m_swapInterval = -1;
+ 
+     qreal m_sizeHintsScaleFactor = 1.0;
+-
+-    bool m_wmStateValid = true;
+-    QVector<Task> m_deferredTasks;
+-    bool m_isWmManagedWindow = true;
+-    QRect m_deferredGeometry;
+ };
+ 
+ class QXcbForeignWindow : public QXcbWindow
+diff --git a/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp b/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
+index d9d117faeb..640b49daa0 100644
+--- a/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
++++ b/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
+@@ -85,6 +85,7 @@ QGtk3MenuItem::QGtk3MenuItem()
+       m_checkable(false),
+       m_checked(false),
+       m_enabled(true),
++      m_exclusive(false),
+       m_underline(false),
+       m_invalid(true),
+       m_menu(nullptr),
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
+index 0048bbc1e6..396e7f6d1c 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
+@@ -102,15 +102,12 @@ const QDBusArgument &operator >>(const QDBusArgument &arg, QXdgDesktopPortalFile
+ class QXdgDesktopPortalFileDialogPrivate
+ {
+ public:
+-    QXdgDesktopPortalFileDialogPrivate(QPlatformFileDialogHelper *nativeFileDialog)
++    QXdgDesktopPortalFileDialogPrivate(QPlatformFileDialogHelper *nativeFileDialog, uint fileChooserPortalVersion)
+         : nativeFileDialog(nativeFileDialog)
++        , fileChooserPortalVersion(fileChooserPortalVersion)
+     { }
+ 
+-    WId winId = 0;
+-    bool directoryMode = false;
+-    bool modal = false;
+-    bool multipleFiles = false;
+-    bool saveFile = false;
++    QEventLoop loop;
+     QString acceptLabel;
+     QString directory;
+     QString title;
+@@ -121,19 +118,27 @@ public:
+     QString selectedMimeTypeFilter;
+     QString selectedNameFilter;
+     QStringList selectedFiles;
+-    QPlatformFileDialogHelper *nativeFileDialog = nullptr;
++    std::unique_ptr<QPlatformFileDialogHelper> nativeFileDialog;
++    uint fileChooserPortalVersion = 0;
++    bool failedToOpen = false;
++    bool directoryMode = false;
++    bool multipleFiles = false;
++    bool saveFile = false;
+ };
+ 
+-QXdgDesktopPortalFileDialog::QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog)
++QXdgDesktopPortalFileDialog::QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog, uint fileChooserPortalVersion)
+     : QPlatformFileDialogHelper()
+-    , d_ptr(new QXdgDesktopPortalFileDialogPrivate(nativeFileDialog))
++    , d_ptr(new QXdgDesktopPortalFileDialogPrivate(nativeFileDialog, fileChooserPortalVersion))
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+     if (d->nativeFileDialog) {
+-        connect(d->nativeFileDialog, SIGNAL(accept()), this, SIGNAL(accept()));
+-        connect(d->nativeFileDialog, SIGNAL(reject()), this, SIGNAL(reject()));
++        connect(d->nativeFileDialog.get(), SIGNAL(accept()), this, SIGNAL(accept()));
++        connect(d->nativeFileDialog.get(), SIGNAL(reject()), this, SIGNAL(reject()));
+     }
++
++    d->loop.connect(this, SIGNAL(accept()), SLOT(quit()));
++    d->loop.connect(this, SIGNAL(reject()), SLOT(quit()));
+ }
+ 
+ QXdgDesktopPortalFileDialog::~QXdgDesktopPortalFileDialog()
+@@ -177,7 +182,7 @@ void QXdgDesktopPortalFileDialog::initializeDialog()
+     setDirectory(options()->initialDirectory());
+ }
+ 
+-void QXdgDesktopPortalFileDialog::openPortal()
++void QXdgDesktopPortalFileDialog::openPortal(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent)
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+@@ -185,13 +190,13 @@ void QXdgDesktopPortalFileDialog::openPortal()
+                                                           QLatin1String("/org/freedesktop/portal/desktop"),
+                                                           QLatin1String("org.freedesktop.portal.FileChooser"),
+                                                           d->saveFile ? QLatin1String("SaveFile") : QLatin1String("OpenFile"));
+-    QString parentWindowId = QLatin1String("x11:") + QString::number(d->winId, 16);
++    QString parentWindowId = QLatin1String("x11:") + QString::number(parent ? parent->winId() : 0, 16);
+ 
+     QVariantMap options;
+     if (!d->acceptLabel.isEmpty())
+         options.insert(QLatin1String("accept_label"), d->acceptLabel);
+ 
+-    options.insert(QLatin1String("modal"), d->modal);
++    options.insert(QLatin1String("modal"), windowModality != Qt::NonModal);
+     options.insert(QLatin1String("multiple"), d->multipleFiles);
+     options.insert(QLatin1String("directory"), d->directoryMode);
+ 
+@@ -290,10 +295,18 @@ void QXdgDesktopPortalFileDialog::openPortal()
+ 
+     QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
+     QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingCall);
+-    connect(watcher, &QDBusPendingCallWatcher::finished, this, [this] (QDBusPendingCallWatcher *watcher) {
++    connect(watcher, &QDBusPendingCallWatcher::finished, this, [=] (QDBusPendingCallWatcher *watcher) {
+         QDBusPendingReply<QDBusObjectPath> reply = *watcher;
+-        if (reply.isError()) {
+-            Q_EMIT reject();
++        // Any error means the dialog is not shown and we need to fallback
++        d->failedToOpen = reply.isError();
++        if (d->failedToOpen) {
++            if (d->nativeFileDialog) {
++                d->nativeFileDialog->show(windowFlags, windowModality, parent);
++                if (d->loop.isRunning())
++                    d->nativeFileDialog->exec();
++            } else {
++                Q_EMIT reject();
++            }
+         } else {
+             QDBusConnection::sessionBus().connect(nullptr,
+                                                   reply.value().path(),
+@@ -302,6 +315,7 @@ void QXdgDesktopPortalFileDialog::openPortal()
+                                                   this,
+                                                   SLOT(gotResponse(uint,QVariantMap)));
+         }
++        watcher->deleteLater();
+     });
+ }
+ 
+@@ -326,7 +340,7 @@ QUrl QXdgDesktopPortalFileDialog::directory() const
+ {
+     Q_D(const QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog())
+         return d->nativeFileDialog->directory();
+ 
+     return d->directory;
+@@ -348,7 +362,7 @@ QList<QUrl> QXdgDesktopPortalFileDialog::selectedFiles() const
+ {
+     Q_D(const QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog())
+         return d->nativeFileDialog->selectedFiles();
+ 
+     QList<QUrl> files;
+@@ -403,16 +417,13 @@ void QXdgDesktopPortalFileDialog::exec()
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly)) {
++    if (d->nativeFileDialog && useNativeFileDialog()) {
+         d->nativeFileDialog->exec();
+         return;
+     }
+ 
+     // HACK we have to avoid returning until we emit that the dialog was accepted or rejected
+-    QEventLoop loop;
+-    loop.connect(this, SIGNAL(accept()), SLOT(quit()));
+-    loop.connect(this, SIGNAL(reject()), SLOT(quit()));
+-    loop.exec();
++    d->loop.exec();
+ }
+ 
+ void QXdgDesktopPortalFileDialog::hide()
+@@ -429,13 +440,10 @@ bool QXdgDesktopPortalFileDialog::show(Qt::WindowFlags windowFlags, Qt::WindowMo
+ 
+     initializeDialog();
+ 
+-    d->modal = windowModality != Qt::NonModal;
+-    d->winId = parent ? parent->winId() : 0;
+-
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog(OpenFallback))
+         return d->nativeFileDialog->show(windowFlags, windowModality, parent);
+ 
+-    openPortal();
++    openPortal(windowFlags, windowModality, parent);
+ 
+     return true;
+ }
+@@ -465,4 +473,21 @@ void QXdgDesktopPortalFileDialog::gotResponse(uint response, const QVariantMap &
+     }
+ }
+ 
++bool QXdgDesktopPortalFileDialog::useNativeFileDialog(QXdgDesktopPortalFileDialog::FallbackType fallbackType) const
++{
++    Q_D(const QXdgDesktopPortalFileDialog);
++
++    if (d->failedToOpen && fallbackType != OpenFallback)
++        return true;
++
++    if (d->fileChooserPortalVersion < 3) {
++        if (options()->fileMode() == QFileDialogOptions::Directory)
++            return true;
++        else if (options()->fileMode() == QFileDialogOptions::DirectoryOnly)
++            return true;
++    }
++
++    return false;
++}
++
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
+index 4f4de96ecf..65e22a5cf2 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
+@@ -51,6 +51,11 @@ class QXdgDesktopPortalFileDialog : public QPlatformFileDialogHelper
+     Q_OBJECT
+     Q_DECLARE_PRIVATE(QXdgDesktopPortalFileDialog)
+ public:
++    enum FallbackType {
++        GenericFallback,
++        OpenFallback
++    };
++
+     enum ConditionType : uint {
+         GlobalPattern = 0,
+         MimeType = 1
+@@ -69,7 +74,7 @@ public:
+     };
+     typedef QVector<Filter> FilterList;
+ 
+-    QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog = nullptr);
++    QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog = nullptr, uint fileChooserPortalVersion = 0);
+     ~QXdgDesktopPortalFileDialog();
+ 
+     bool defaultNameFilterDisables() const override;
+@@ -92,7 +97,8 @@ private Q_SLOTS:
+ 
+ private:
+     void initializeDialog();
+-    void openPortal();
++    void openPortal(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent);
++    bool useNativeFileDialog(FallbackType fallbackType = GenericFallback) const;
+ 
+     QScopedPointer<QXdgDesktopPortalFileDialogPrivate> d_ptr;
+ };
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
+index fb324afbd8..b809503122 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
+@@ -111,6 +111,7 @@ QXdgDesktopPortalTheme::QXdgDesktopPortalTheme()
+         if (reply.isValid()) {
+             d->fileChooserPortalVersion = reply.value().toUInt();
+         }
++        watcher->deleteLater();
+     });
+ }
+ 
+@@ -152,11 +153,12 @@ QPlatformDialogHelper* QXdgDesktopPortalTheme::createPlatformDialogHelper(Dialog
+ {
+     Q_D(const QXdgDesktopPortalTheme);
+ 
+-    if (type == FileDialog) {
++    if (type == FileDialog && d->fileChooserPortalVersion) {
+         // Older versions of FileChooser portal don't support opening directories, therefore we fallback
+         // to native file dialog opened inside the sandbox to open a directory.
+-        if (d->fileChooserPortalVersion < 3 && d->baseTheme->usePlatformNativeDialog(type))
+-            return new QXdgDesktopPortalFileDialog(static_cast<QPlatformFileDialogHelper*>(d->baseTheme->createPlatformDialogHelper(type)));
++        if (d->baseTheme->usePlatformNativeDialog(type))
++            return new QXdgDesktopPortalFileDialog(static_cast<QPlatformFileDialogHelper*>(d->baseTheme->createPlatformDialogHelper(type)),
++                                                   d->fileChooserPortalVersion);
+ 
+         return new QXdgDesktopPortalFileDialog;
+     }
+diff --git a/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp b/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
+index 43d5e119ad..1f9cbc4565 100644
+--- a/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
++++ b/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
+@@ -89,8 +89,10 @@ void QCupsPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &v
+         break;
+     case PPK_Duplex: {
+         QPrint::DuplexMode mode = QPrint::DuplexMode(value.toInt());
+-        if (mode != d->duplex && d->m_printDevice.supportedDuplexModes().contains(mode))
++        if (d->m_printDevice.supportedDuplexModes().contains(mode)) {
+             d->duplex = mode;
++            d->duplexRequestedExplicitly = true;
++        }
+         break;
+     }
+     case PPK_PrinterName:
+@@ -277,9 +279,12 @@ void QCupsPrintEnginePrivate::changePrinter(const QString &newPrinter)
+     m_printDevice.swap(printDevice);
+     printerName = m_printDevice.id();
+ 
+-    // Check if new printer supports current settings, otherwise us defaults
+-    if (duplex != QPrint::DuplexAuto && !m_printDevice.supportedDuplexModes().contains(duplex))
++    // in case a duplex value was explicitly set, check if new printer supports current value,
++    // otherwise use device default
++    if (!duplexRequestedExplicitly || !m_printDevice.supportedDuplexModes().contains(duplex)) {
+         duplex = m_printDevice.defaultDuplexMode();
++        duplexRequestedExplicitly = false;
++    }
+     QPrint::ColorMode colorMode = grayscale ? QPrint::GrayScale : QPrint::Color;
+     if (!m_printDevice.supportedColorModes().contains(colorMode))
+         grayscale = m_printDevice.defaultColorMode() == QPrint::GrayScale;
+diff --git a/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h b/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
+index c021b0c643..8f81fe478d 100644
+--- a/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
++++ b/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
+@@ -100,6 +100,7 @@ private:
+     QStringList cupsOptions;
+     QString cupsTempFile;
+     QPrint::DuplexMode duplex;
++    bool duplexRequestedExplicitly = false;
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp b/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
+index 67e7154fa6..40876152e5 100644
+--- a/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
++++ b/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
+@@ -817,7 +817,7 @@ bool QIBaseResultPrivate::writeArray(int column, const QList<QVariant> &list)
+     ba.resize(int(bufLen));
+ 
+     if (list.size() > arraySize) {
+-        error = QLatin1String("Array size missmatch: size of %1 is %2, size of provided list is %3");
++        error = QLatin1String("Array size mismatch: size of %1 is %2, size of provided list is %3");
+         error = error.arg(QLatin1String(sqlname)).arg(arraySize).arg(list.size());
+         q->setLastError(QSqlError(error, QLatin1String(""), QSqlError::StatementError));
+         return false;
+diff --git a/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp b/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
+index 7ca055eea2..6bc9d46755 100644
+--- a/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
++++ b/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
+@@ -223,7 +223,7 @@ public:
+     struct QMyField
+     {
+         char *outField = nullptr;
+-        MYSQL_FIELD *myField = nullptr;
++        const MYSQL_FIELD *myField = nullptr;
+         QMetaType::Type type = QMetaType::UnknownType;
+         my_bool nullIndicator = false;
+         ulong bufLength = 0ul;
+@@ -361,7 +361,7 @@ static bool qIsInteger(int t)
+ void QMYSQLResultPrivate::bindBlobs()
+ {
+     int i;
+-    MYSQL_FIELD *fieldInfo;
++    const MYSQL_FIELD *fieldInfo;
+     MYSQL_BIND *bind;
+ 
+     for(i = 0; i < fields.count(); ++i) {
+@@ -379,7 +379,6 @@ void QMYSQLResultPrivate::bindBlobs()
+ bool QMYSQLResultPrivate::bindInValues()
+ {
+     MYSQL_BIND *bind;
+-    char *field;
+     int i = 0;
+ 
+     if (!meta)
+@@ -392,35 +391,34 @@ bool QMYSQLResultPrivate::bindInValues()
+     inBinds = new MYSQL_BIND[fields.size()];
+     memset(inBinds, 0, fields.size() * sizeof(MYSQL_BIND));
+ 
+-    MYSQL_FIELD *fieldInfo;
++    const MYSQL_FIELD *fieldInfo;
+ 
+     while((fieldInfo = mysql_fetch_field(meta))) {
++        bind = &inBinds[i];
++
+         QMyField &f = fields[i];
+         f.myField = fieldInfo;
+-
++        bind->buffer_length = f.bufLength = fieldInfo->length + 1;
++        bind->buffer_type = fieldInfo->type;
+         f.type = qDecodeMYSQLType(fieldInfo->type, fieldInfo->flags);
+         if (qIsBlob(fieldInfo->type)) {
+             // the size of a blob-field is available as soon as we call
+             // mysql_stmt_store_result()
+             // after mysql_stmt_exec() in QMYSQLResult::exec()
+-            fieldInfo->length = 0;
++            bind->buffer_length = f.bufLength = 0;
+             hasBlobs = true;
+         } else if (qIsInteger(f.type)) {
+-            fieldInfo->length = 8;
++            bind->buffer_length = f.bufLength = 8;
+         } else {
+-            fieldInfo->type = MYSQL_TYPE_STRING;
++            bind->buffer_type = MYSQL_TYPE_STRING;
+         }
+-        bind = &inBinds[i];
+-        field = new char[fieldInfo->length + 1];
+-        memset(field, 0, fieldInfo->length + 1);
+ 
+-        bind->buffer_type = fieldInfo->type;
+-        bind->buffer = field;
+-        bind->buffer_length = f.bufLength = fieldInfo->length + 1;
+         bind->is_null = &f.nullIndicator;
+         bind->length = &f.bufLength;
+         bind->is_unsigned = fieldInfo->flags & UNSIGNED_FLAG ? 1 : 0;
+-        f.outField=field;
++
++        char *field = new char[bind->buffer_length + 1]{};
++        bind->buffer = f.outField = field;
+ 
+         ++i;
+     }
+@@ -1369,20 +1367,20 @@ bool QMYSQLDriver::open(const QString& db,
+     }
+ 
+ #if MYSQL_VERSION_ID >= 50007
+-    if (mysql_get_client_version() >= 50503 && mysql_get_server_version(d->mysql) >= 50503) {
+-        // force the communication to be utf8mb4 (only utf8mb4 supports 4-byte characters)
+-        mysql_set_character_set(d->mysql, "utf8mb4");
++    // force the communication to be utf8mb4 (only utf8mb4 supports 4-byte characters)
++    if (mysql_set_character_set(d->mysql, "utf8mb4")) {
++        // this failed, try forcing it to utf (BMP only)
++        if (mysql_set_character_set(d->mysql, "utf8"))
++            qWarning() << "MySQL: Unable to set the client character set to utf8.";
+ #if QT_CONFIG(textcodec)
+-        d->tc = QTextCodec::codecForName("UTF-8");
++        else
++            d->tc = codec(d->mysql);
+ #endif
+-    } else
+-    {
+-        // force the communication to be utf8
+-        mysql_set_character_set(d->mysql, "utf8");
++    }
+ #if QT_CONFIG(textcodec)
+-        d->tc = codec(d->mysql);
++    else
++        d->tc = QTextCodec::codecForName("UTF-8");
+ #endif
+-    }
+ #endif  // MYSQL_VERSION_ID >= 50007
+ 
+     d->preparedQuerysEnabled = checkPreparedQueries(d->mysql);
+diff --git a/qtbase/src/printsupport/dialogs/images/print-24.png b/qtbase/src/printsupport/dialogs/images/printer-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/print-24.png
+rename to src/printsupport/dialogs/images/printer-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/print-32.png b/qtbase/src/printsupport/dialogs/images/printer-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/print-32.png
+rename to src/printsupport/dialogs/images/printer-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-sided-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-facing-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-sided-24.png
+rename to src/printsupport/dialogs/images/view-pages-facing-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-sided-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-facing-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-sided-32.png
+rename to src/printsupport/dialogs/images/view-pages-facing-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-multi-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-overview-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-multi-24.png
+rename to src/printsupport/dialogs/images/view-pages-overview-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-multi-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-overview-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-multi-32.png
+rename to src/printsupport/dialogs/images/view-pages-overview-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-one-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-single-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-one-24.png
+rename to src/printsupport/dialogs/images/view-pages-single-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-one-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-single-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-one-32.png
+rename to src/printsupport/dialogs/images/view-pages-single-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-page-24.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-page-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-page-24.png
+rename to src/printsupport/dialogs/images/zoom-fit-page-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-page-32.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-page-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-page-32.png
+rename to src/printsupport/dialogs/images/zoom-fit-page-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-width-24.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-width-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-width-24.png
+rename to src/printsupport/dialogs/images/zoom-fit-width-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-width-32.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-width-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-width-32.png
+rename to src/printsupport/dialogs/images/zoom-fit-width-32.png
+diff --git a/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp b/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
+index 78e5b8d1ef..2a28516719 100644
+--- a/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
++++ b/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
+@@ -532,6 +532,7 @@ void QPageSetupWidget::updateWidget()
+ void QPageSetupWidget::setupPrinter() const
+ {
+     m_printer->setPageLayout(m_pageLayout);
++    m_printer->setPageOrientation(m_pageLayout.orientation());
+ #if QT_CONFIG(cups)
+     QCUPSSupport::PagesPerSheet pagesPerSheet = qvariant_cast<QCUPSSupport::PagesPerSheet>(m_ui.pagesPerSheetCombo->currentData()
+ );
+diff --git a/qtbase/src/printsupport/dialogs/qprintdialog.qrc b/qtbase/src/printsupport/dialogs/qprintdialog.qrc
+index 5a579baa55..10b8e1d341 100644
+--- a/qtbase/src/printsupport/dialogs/qprintdialog.qrc
++++ b/qtbase/src/printsupport/dialogs/qprintdialog.qrc
+@@ -1,9 +1,9 @@
+ <!DOCTYPE RCC><RCC version="1.0">
+ <qresource prefix="/qt-project.org/dialogs/qprintpreviewdialog">
+-<file>images/fit-page-24.png</file>
+-<file>images/fit-page-32.png</file>
+-<file>images/fit-width-24.png</file>
+-<file>images/fit-width-32.png</file>
++<file>images/zoom-fit-page-24.png</file>
++<file>images/zoom-fit-page-32.png</file>
++<file>images/zoom-fit-width-24.png</file>
++<file>images/zoom-fit-width-32.png</file>
+ <file>images/go-first-24.png</file>
+ <file>images/go-first-32.png</file>
+ <file>images/go-last-24.png</file>
+@@ -18,14 +18,14 @@
+ <file>images/layout-portrait-32.png</file>
+ <file>images/page-setup-24.png</file>
+ <file>images/page-setup-32.png</file>
+-<file>images/print-24.png</file>
+-<file>images/print-32.png</file>
+-<file>images/view-page-multi-24.png</file>
+-<file>images/view-page-multi-32.png</file>
+-<file>images/view-page-one-24.png</file>
+-<file>images/view-page-one-32.png</file>
+-<file>images/view-page-sided-24.png</file>
+-<file>images/view-page-sided-32.png</file>
++<file>images/printer-24.png</file>
++<file>images/printer-32.png</file>
++<file>images/view-pages-overview-24.png</file>
++<file>images/view-pages-overview-32.png</file>
++<file>images/view-pages-single-24.png</file>
++<file>images/view-pages-single-32.png</file>
++<file>images/view-pages-facing-24.png</file>
++<file>images/view-pages-facing-32.png</file>
+ <file>images/zoom-in-24.png</file>
+ <file>images/zoom-in-32.png</file>
+ <file>images/zoom-out-24.png</file>
+diff --git a/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp b/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
+index c5b845f4ec..5a5ba1d0a8 100644
+--- a/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
++++ b/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
+@@ -702,13 +702,14 @@ void QPrintDialogPrivate::selectPrinter(const QPrinter::OutputFormat outputForma
+         else
+             options.grayscale->setChecked(true);
+ 
+-        // keep duplex value explicitly set by user, if any, and selected printer supports it;
+-        // use device default otherwise
++        // duplex priorities to be as follows:
++        // 1) a user-selected duplex value in the dialog has highest prority
++        // 2) duplex value set in the QPrinter
+         QPrint::DuplexMode duplex;
+         if (explicitDuplexMode != QPrint::DuplexAuto && supportedDuplexMode.contains(explicitDuplexMode))
+             duplex = explicitDuplexMode;
+         else
+-            duplex = top->d->m_currentPrintDevice.defaultDuplexMode();
++            duplex = static_cast<QPrint::DuplexMode>(p->duplex());
+         switch (duplex) {
+         case QPrint::DuplexNone:
+             options.noDuplex->setChecked(true); break;
+@@ -1242,10 +1243,10 @@ void QUnixPrintWidgetPrivate::_q_printerChanged(int index)
+             QString filename = widget.filename->text();
+             widget.filename->setText(filename);
+             widget.lOutput->setEnabled(true);
+-            if (optionsPane)
+-                optionsPane->selectPrinter(QPrinter::PdfFormat);
+             printer->setOutputFormat(QPrinter::PdfFormat);
+             m_currentPrintDevice = QPrintDevice();
++            if (optionsPane)
++                optionsPane->selectPrinter(QPrinter::PdfFormat);
+             return;
+         }
+     }
+diff --git a/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp b/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
+index 39575d5f57..23b7e89538 100644
+--- a/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
++++ b/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
+@@ -352,7 +352,7 @@ void QPrintPreviewDialogPrivate::init(QPrinter *_printer)
+ static inline void qt_setupActionIcon(QAction *action, QLatin1String name)
+ {
+     QLatin1String imagePrefix(":/qt-project.org/dialogs/qprintpreviewdialog/images/");
+-    QIcon icon;
++    QIcon icon = QIcon::fromTheme(name);
+     icon.addFile(imagePrefix + name + QLatin1String("-24.png"), QSize(24, 24));
+     icon.addFile(imagePrefix + name + QLatin1String("-32.png"), QSize(32, 32));
+     action->setIcon(icon);
+@@ -383,8 +383,8 @@ void QPrintPreviewDialogPrivate::setupActions()
+     fitPageAction->setObjectName(QLatin1String("fitPageAction"));
+     fitWidthAction->setCheckable(true);
+     fitPageAction->setCheckable(true);
+-    qt_setupActionIcon(fitWidthAction, QLatin1String("fit-width"));
+-    qt_setupActionIcon(fitPageAction, QLatin1String("fit-page"));
++    qt_setupActionIcon(fitWidthAction, QLatin1String("zoom-fit-width"));
++    qt_setupActionIcon(fitPageAction, QLatin1String("zoom-fit-page"));
+     QObject::connect(fitGroup, SIGNAL(triggered(QAction*)), q, SLOT(_q_fit(QAction*)));
+ 
+     // Zoom
+@@ -410,9 +410,9 @@ void QPrintPreviewDialogPrivate::setupActions()
+     singleModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show single page"));
+     facingModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show facing pages"));
+     overviewModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show overview of all pages"));
+-    qt_setupActionIcon(singleModeAction, QLatin1String("view-page-one"));
+-    qt_setupActionIcon(facingModeAction, QLatin1String("view-page-sided"));
+-    qt_setupActionIcon(overviewModeAction, QLatin1String("view-page-multi"));
++    qt_setupActionIcon(singleModeAction, QLatin1String("view-pages-single"));
++    qt_setupActionIcon(facingModeAction, QLatin1String("view-pages-facing"));
++    qt_setupActionIcon(overviewModeAction, QLatin1String("view-pages-overview"));
+     singleModeAction->setObjectName(QLatin1String("singleModeAction"));
+     facingModeAction->setObjectName(QLatin1String("facingModeAction"));
+     overviewModeAction->setObjectName(QLatin1String("overviewModeAction"));
+@@ -426,7 +426,7 @@ void QPrintPreviewDialogPrivate::setupActions()
+     printerGroup = new QActionGroup(q);
+     printAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Print"));
+     pageSetupAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Page setup"));
+-    qt_setupActionIcon(printAction, QLatin1String("print"));
++    qt_setupActionIcon(printAction, QLatin1String("printer"));
+     qt_setupActionIcon(pageSetupAction, QLatin1String("page-setup"));
+     QObject::connect(printAction, SIGNAL(triggered(bool)), q, SLOT(_q_print()));
+     QObject::connect(pageSetupAction, SIGNAL(triggered(bool)), q, SLOT(_q_pageSetup()));
+diff --git a/qtbase/src/sql/kernel/qsqlquery.cpp b/qtbase/src/sql/kernel/qsqlquery.cpp
+index 32c6166c79..60afef10c3 100644
+--- a/qtbase/src/sql/kernel/qsqlquery.cpp
++++ b/qtbase/src/sql/kernel/qsqlquery.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2022 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtSql module of the Qt Toolkit.
+@@ -377,6 +377,10 @@ bool QSqlQuery::exec(const QString& query)
+     QElapsedTimer t;
+     t.start();
+ #endif
++    if (!driver()) {
++        qWarning("QSqlQuery::exec: called before driver has been set up");
++        return false;
++    }
+     if (d->ref.loadRelaxed() != 1) {
+         bool fo = isForwardOnly();
+         *this = QSqlQuery(driver()->createResult());
+diff --git a/qtbase/src/testlib/qabstractitemmodeltester.cpp b/qtbase/src/testlib/qabstractitemmodeltester.cpp
+index 8efb9c53d4..ce062f66d7 100644
+--- a/qtbase/src/testlib/qabstractitemmodeltester.cpp
++++ b/qtbase/src/testlib/qabstractitemmodeltester.cpp
+@@ -454,7 +454,7 @@ void QAbstractItemModelTesterPrivate::parent()
+ 
+     // Common error test #2, make sure that a second level index has a parent
+     // that is the first level index.
+-    if (model->rowCount(topIndex) > 0) {
++    if (model->rowCount(topIndex) > 0 && model->columnCount(topIndex) > 0) {
+         QModelIndex childIndex = model->index(0, 0, topIndex);
+         MODELTESTER_VERIFY(childIndex.isValid());
+         MODELTESTER_COMPARE(model->parent(childIndex), topIndex);
+diff --git a/qtbase/src/testlib/qasciikey.cpp b/qtbase/src/testlib/qasciikey.cpp
+index 9a308da2bc..93498b256f 100644
+--- a/qtbase/src/testlib/qasciikey.cpp
++++ b/qtbase/src/testlib/qasciikey.cpp
+@@ -498,6 +498,11 @@ char QTest::keyToAscii(Qt::Key key)
+     case Qt::Key_LaunchE : return 0; // = 0x10b0,
+     case Qt::Key_LaunchF : return 0; // = 0x10b1,
+ 
++    // Keypad navigation keys
++    case Qt::Key_Select : return 0; // = 0x01010000
++    case Qt::Key_Yes : return 0; // = 0x01010001
++    case Qt::Key_No : return 0; // = 0x01010002
++
+     default: QTEST_ASSERT(false); return 0;
+     }
+ }
+diff --git a/qtbase/src/testlib/qtestresult.cpp b/qtbase/src/testlib/qtestresult.cpp
+index 88028aac6e..2e89930776 100644
+--- a/qtbase/src/testlib/qtestresult.cpp
++++ b/qtbase/src/testlib/qtestresult.cpp
+@@ -251,7 +251,8 @@ bool QTestResult::verify(bool statement, const char *statementStr,
+ {
+     QTEST_ASSERT(statementStr);
+ 
+-    char msg[1024] = {'\0'};
++    char msg[1024];
++    msg[0] = '\0';
+ 
+     if (QTestLog::verboseLevel() >= 2) {
+         qsnprintf(msg, 1024, "QVERIFY(%s)", statementStr);
+@@ -309,7 +310,8 @@ static bool compareHelper(bool success, const char *failureMsg,
+                           bool hasValues = true)
+ {
+     const size_t maxMsgLen = 1024;
+-    char msg[maxMsgLen] = {'\0'};
++    char msg[maxMsgLen];
++    msg[0] = '\0';
+ 
+     QTEST_ASSERT(expected);
+     QTEST_ASSERT(actual);
+diff --git a/qtbase/src/widgets/dialogs/qcolordialog.cpp b/qtbase/src/widgets/dialogs/qcolordialog.cpp
+index 4247731275..cb325be85c 100644
+--- a/qtbase/src/widgets/dialogs/qcolordialog.cpp
++++ b/qtbase/src/widgets/dialogs/qcolordialog.cpp
+@@ -78,7 +78,10 @@
+ #include "qwindow.h"
+ 
+ #include "private/qdialog_p.h"
++#include "private/qguiapplication_p.h"
+ 
++#include <qpa/qplatformservices.h>
++#include <qpa/qplatformintegration.h>
+ #include <algorithm>
+ 
+ QT_BEGIN_NAMESPACE
+@@ -1611,6 +1614,20 @@ void QColorDialogPrivate::_q_newStandard(int r, int c)
+ void QColorDialogPrivate::_q_pickScreenColor()
+ {
+     Q_Q(QColorDialog);
++
++    auto *platformServices = QGuiApplicationPrivate::platformIntegration()->services();
++    if (platformServices->hasCapability(QPlatformServices::Capability::ColorPicking)) {
++        if (auto *colorPicker = platformServices->colorPicker(q->windowHandle())) {
++            q->connect(colorPicker, &QPlatformServiceColorPicker::colorPicked, q,
++                       [q, colorPicker](const QColor &color) {
++                           colorPicker->deleteLater();
++                           q->setCurrentColor(color);
++                       });
++            colorPicker->pickColor();
++            return;
++        }
++    }
++
+     if (!colorPickingEventFilter)
+         colorPickingEventFilter = new QColorPickingEventFilter(this, q);
+     q->installEventFilter(colorPickingEventFilter);
+diff --git a/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp b/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
+index e120817edc..8ea36b5427 100644
+--- a/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
++++ b/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
+@@ -400,12 +400,7 @@ bool QAbstractItemDelegate::helpEvent(QHelpEvent *event,
+         const QString tooltip = index.isValid() ?
+               d->textForRole(Qt::ToolTipRole, index.data(Qt::ToolTipRole), option.locale, precision) :
+               QString();
+-        QRect rect;
+-        if (index.isValid()) {
+-            const QRect r = view->visualRect(index);
+-            rect = QRect(view->mapToGlobal(r.topLeft()), r.size());
+-        }
+-        QToolTip::showText(he->globalPos(), tooltip, view, rect);
++        QToolTip::showText(he->globalPos(), tooltip, view->viewport(), option.rect);
+         event->setAccepted(!tooltip.isEmpty());
+         break;
+         }
+diff --git a/qtbase/src/widgets/itemviews/qlistview.cpp b/qtbase/src/widgets/itemviews/qlistview.cpp
+index 2b34476642..eebfaa030e 100644
+--- a/qtbase/src/widgets/itemviews/qlistview.cpp
++++ b/qtbase/src/widgets/itemviews/qlistview.cpp
+@@ -3386,6 +3386,7 @@ void QIconModeViewBase::updateContentsSize()
+ */
+ void QListView::currentChanged(const QModelIndex &current, const QModelIndex &previous)
+ {
++    QAbstractItemView::currentChanged(current, previous);
+ #ifndef QT_NO_ACCESSIBILITY
+     if (QAccessible::isActive()) {
+         if (current.isValid()) {
+@@ -3396,7 +3397,6 @@ void QListView::currentChanged(const QModelIndex &current, const QModelIndex &pr
+         }
+     }
+ #endif
+-    QAbstractItemView::currentChanged(current, previous);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/widgets/itemviews/qtableview.cpp b/qtbase/src/widgets/itemviews/qtableview.cpp
+index 934ac581b2..f79bb24249 100644
+--- a/qtbase/src/widgets/itemviews/qtableview.cpp
++++ b/qtbase/src/widgets/itemviews/qtableview.cpp
+@@ -1013,6 +1013,7 @@ void QTableViewPrivate::drawCell(QPainter *painter, const QStyleOptionViewItem &
+ int QTableViewPrivate::widthHintForIndex(const QModelIndex &index, int hint, const QStyleOptionViewItem &option) const
+ {
+     Q_Q(const QTableView);
++    const int oldHint = hint;
+     QWidget *editor = editorForIndex(index).widget.data();
+     if (editor && persistent.contains(editor)) {
+         hint = qMax(hint, editor->sizeHint().width());
+@@ -1021,6 +1022,17 @@ int QTableViewPrivate::widthHintForIndex(const QModelIndex &index, int hint, con
+         hint = qBound(min, hint, max);
+     }
+     hint = qMax(hint, q->itemDelegate(index)->sizeHint(option, index).width());
++
++    if (hasSpans()) {
++        auto span = spans.spanAt(index.column(), index.row());
++        if (span && span->m_left == index.column() && span->m_top == index.row()) {
++            // spans are screwed up when sections are moved
++            const auto left = logicalColumn(span->m_left);
++            for (int i = 1; i <= span->width(); ++i)
++               hint -= q->columnWidth(visualColumn(left + i));
++        }
++        hint = std::max(hint, oldHint);
++    }
+     return hint;
+ }
+ 
+@@ -1053,6 +1065,11 @@ int QTableViewPrivate::heightHintForIndex(const QModelIndex &index, int hint, QS
+         option.rect.setHeight(height);
+         option.rect.setX(q->columnViewportPosition(index.column()));
+         option.rect.setWidth(q->columnWidth(index.column()));
++        if (hasSpans()) {
++            auto span = spans.spanAt(index.column(), index.row());
++            if (span && span->m_left == index.column() && span->m_top == index.row())
++                option.rect.setWidth(std::max(option.rect.width(), visualSpanRect(*span).width()));
++        }
+         // 1px less space when grid is shown (see drawCell)
+         if (showGrid)
+             option.rect.setWidth(option.rect.width() - 1);
+diff --git a/qtbase/src/widgets/kernel/qaction.h b/qtbase/src/widgets/kernel/qaction.h
+index 258a1ea0a0..737c1e8285 100644
+--- a/qtbase/src/widgets/kernel/qaction.h
++++ b/qtbase/src/widgets/kernel/qaction.h
+@@ -81,7 +81,7 @@ class Q_WIDGETS_EXPORT QAction : public QObject
+     Q_PROPERTY(MenuRole menuRole READ menuRole WRITE setMenuRole NOTIFY changed)
+     Q_PROPERTY(bool iconVisibleInMenu READ isIconVisibleInMenu WRITE setIconVisibleInMenu NOTIFY changed)
+     Q_PROPERTY(bool shortcutVisibleInContextMenu READ isShortcutVisibleInContextMenu WRITE setShortcutVisibleInContextMenu NOTIFY changed)
+-    Q_PROPERTY(Priority priority READ priority WRITE setPriority)
++    Q_PROPERTY(Priority priority READ priority WRITE setPriority NOTIFY changed)
+ 
+ public:
+     // note this is copied into qplatformmenu.h, which must stay in sync
+diff --git a/qtbase/src/widgets/kernel/qwidget.cpp b/qtbase/src/widgets/kernel/qwidget.cpp
+index 9eba1e001e..26f6d27e18 100644
+--- a/qtbase/src/widgets/kernel/qwidget.cpp
++++ b/qtbase/src/widgets/kernel/qwidget.cpp
+@@ -5296,7 +5296,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
+         QWidgetEffectSourcePrivate *sourced = static_cast<QWidgetEffectSourcePrivate *>
+                                                          (source->d_func());
+         if (!sourced->context) {
+-            const QRegion effectRgn(rgn.boundingRect());
++            const QRegion effectRgn((flags & UseEffectRegionBounds) ? rgn.boundingRect() : rgn);
+             QWidgetPaintContext context(pdev, effectRgn, offset, flags, sharedPainter, repaintManager);
+             sourced->context = &context;
+             if (!sharedPainter) {
+@@ -5328,6 +5328,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
+         }
+     }
+ #endif // QT_CONFIG(graphicseffect)
++    flags = flags & ~UseEffectRegionBounds;
+ 
+     const bool alsoOnScreen = flags & DrawPaintOnScreen;
+     const bool recursive = flags & DrawRecursive;
+diff --git a/qtbase/src/widgets/kernel/qwidget_p.h b/qtbase/src/widgets/kernel/qwidget_p.h
+index eef6b8fa2c..c432f4b5d5 100644
+--- a/qtbase/src/widgets/kernel/qwidget_p.h
++++ b/qtbase/src/widgets/kernel/qwidget_p.h
+@@ -229,7 +229,8 @@ public:
+         DontSubtractOpaqueChildren = 0x10,
+         DontDrawOpaqueChildren = 0x20,
+         DontDrawNativeChildren = 0x40,
+-        DontSetCompositionMode = 0x80
++        DontSetCompositionMode = 0x80,
++        UseEffectRegionBounds = 0x100
+     };
+     Q_DECLARE_FLAGS(DrawWidgetFlags, DrawWidgetFlag)
+     Q_FLAG(DrawWidgetFlags)
+diff --git a/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp b/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
+index 02880b34da..0d44e1326d 100644
+--- a/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
++++ b/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
+@@ -1018,7 +1018,8 @@ void QWidgetRepaintManager::paintAndFlush()
+ 
+     // Paint the rest with composition.
+     if (repaintAllWidgets || !dirtyCopy.isEmpty()) {
+-        QWidgetPrivate::DrawWidgetFlags flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive;
++        QWidgetPrivate::DrawWidgetFlags flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive
++                | QWidgetPrivate::UseEffectRegionBounds;
+         tlw->d_func()->drawWidget(store->paintDevice(), dirtyCopy, QPoint(), flags, nullptr, this);
+     }
+ 
+diff --git a/qtbase/src/widgets/styles/qfusionstyle.cpp b/qtbase/src/widgets/styles/qfusionstyle.cpp
+index f4345d97c4..962912c838 100644
+--- a/qtbase/src/widgets/styles/qfusionstyle.cpp
++++ b/qtbase/src/widgets/styles/qfusionstyle.cpp
+@@ -1772,14 +1772,6 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio
+             proxy()->drawControl(CE_PushButtonLabel, &subopt, painter, widget);
+         }
+         break;
+-    case CE_PushButtonLabel:
+-        if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
+-            QStyleOptionButton b(*button);
+-            // no PM_ButtonShiftHorizontal and PM_ButtonShiftVertical for fusion style
+-            b.state &= ~(State_On | State_Sunken);
+-            QCommonStyle::drawControl(element, &b, painter, widget);
+-        }
+-        break;
+     case CE_MenuBarEmptyArea:
+         painter->save();
+     {
+diff --git a/qtbase/src/widgets/util/qcompleter.cpp b/qtbase/src/widgets/util/qcompleter.cpp
+index 18b24063d8..ef7207a8a3 100644
+--- a/qtbase/src/widgets/util/qcompleter.cpp
++++ b/qtbase/src/widgets/util/qcompleter.cpp
+@@ -1120,6 +1120,8 @@ void QCompleter::setModel(QAbstractItemModel *model)
+ {
+     Q_D(QCompleter);
+     QAbstractItemModel *oldModel = d->proxy->sourceModel();
++    if (oldModel == model)
++        return;
+ #if QT_CONFIG(filesystemmodel)
+     if (qobject_cast<const QFileSystemModel *>(oldModel))
+         setCompletionRole(Qt::EditRole); // QTBUG-54642, clear FileNameRole set by QFileSystemModel
+diff --git a/qtbase/src/widgets/widgets/qabstractbutton.cpp b/qtbase/src/widgets/widgets/qabstractbutton.cpp
+index a128b23950..dc40bf62fb 100644
+--- a/qtbase/src/widgets/widgets/qabstractbutton.cpp
++++ b/qtbase/src/widgets/widgets/qabstractbutton.cpp
+@@ -56,6 +56,7 @@
+ #ifndef QT_NO_ACCESSIBILITY
+ #include "qaccessible.h"
+ #endif
++#include <qpa/qplatformtheme.h>
+ 
+ #include <algorithm>
+ 
+@@ -1076,19 +1077,19 @@ void QAbstractButton::keyPressEvent(QKeyEvent *e)
+ {
+     Q_D(QAbstractButton);
+     bool next = true;
+-    switch (e->key()) {
+-    case Qt::Key_Enter:
+-    case Qt::Key_Return:
+-        e->ignore();
+-        break;
+-    case Qt::Key_Select:
+-    case Qt::Key_Space:
+-        if (!e->isAutoRepeat()) {
+-            setDown(true);
+-            repaint();
+-            d->emitPressed();
+-        }
+-        break;
++
++    const auto key = static_cast<Qt::Key>(e->key());
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(key) && !e->isAutoRepeat()) {
++        setDown(true);
++        repaint();
++        d->emitPressed();
++        return;
++    }
++
++    switch (key) {
+     case Qt::Key_Up:
+         next = false;
+         Q_FALLTHROUGH();
+@@ -1153,15 +1154,15 @@ void QAbstractButton::keyReleaseEvent(QKeyEvent *e)
+     if (!e->isAutoRepeat())
+         d->repeatTimer.stop();
+ 
+-    switch (e->key()) {
+-    case Qt::Key_Select:
+-    case Qt::Key_Space:
+-        if (!e->isAutoRepeat() && d->down)
+-            d->click();
+-        break;
+-    default:
+-        e->ignore();
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(static_cast<Qt::Key>(e->key())) && !e->isAutoRepeat() && d->down) {
++        d->click();
++        return;
+     }
++
++    e->ignore();
+ }
+ 
+ /*!\reimp
+diff --git a/qtbase/src/widgets/widgets/qcombobox.cpp b/qtbase/src/widgets/widgets/qcombobox.cpp
+index 7a496c27e0..0a3d96647b 100644
+--- a/qtbase/src/widgets/widgets/qcombobox.cpp
++++ b/qtbase/src/widgets/widgets/qcombobox.cpp
+@@ -3352,7 +3352,23 @@ void QComboBox::keyPressEvent(QKeyEvent *e)
+ 
+     Move move = NoMove;
+     int newIndex = currentIndex();
+-    switch (e->key()) {
++
++    bool pressLikeButton = !d->lineEdit;
++#ifdef QT_KEYPAD_NAVIGATION
++    pressLikeButton |= QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus();
++#endif
++    auto key = static_cast<Qt::Key>(e->key());
++    if (pressLikeButton) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(key)) {
++            showPopup();
++            return;
++        }
++    }
++
++    switch (key) {
+     case Qt::Key_Up:
+         if (e->modifiers() & Qt::ControlModifier)
+             break; // pass to line edit for auto completion
+@@ -3394,26 +3410,11 @@ void QComboBox::keyPressEvent(QKeyEvent *e)
+             return;
+         }
+         break;
+-    case Qt::Key_Space:
+-        if (!d->lineEdit) {
+-            showPopup();
+-            return;
+-        }
+-        break;
+-    case Qt::Key_Enter:
+-    case Qt::Key_Return:
+     case Qt::Key_Escape:
+         if (!d->lineEdit)
+             e->ignore();
+         break;
+ #ifdef QT_KEYPAD_NAVIGATION
+-    case Qt::Key_Select:
+-        if (QApplicationPrivate::keypadNavigationEnabled()
+-                && (!hasEditFocus() || !d->lineEdit)) {
+-            showPopup();
+-            return;
+-        }
+-        break;
+     case Qt::Key_Left:
+     case Qt::Key_Right:
+         if (QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus())
+diff --git a/qtbase/src/widgets/widgets/qdatetimeedit_p.h b/qtbase/src/widgets/widgets/qdatetimeedit_p.h
+index d36b6f8f9a..e0df5b5158 100644
+--- a/qtbase/src/widgets/widgets/qdatetimeedit_p.h
++++ b/qtbase/src/widgets/widgets/qdatetimeedit_p.h
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2018 The Qt Company Ltd.
++** Copyright (C) 2021 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtWidgets module of the Qt Toolkit.
+diff --git a/qtbase/src/widgets/widgets/qgroupbox.cpp b/qtbase/src/widgets/widgets/qgroupbox.cpp
+index 02a0bed325..3f3eccc370 100644
+--- a/qtbase/src/widgets/widgets/qgroupbox.cpp
++++ b/qtbase/src/widgets/widgets/qgroupbox.cpp
+@@ -54,6 +54,8 @@
+ #include "qaccessible.h"
+ #endif
+ #include <private/qwidget_p.h>
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
+ 
+ #include "qdebug.h"
+ 
+@@ -360,7 +362,10 @@ bool QGroupBox::event(QEvent *e)
+         return true;
+     case QEvent::KeyPress: {
+         QKeyEvent *k = static_cast<QKeyEvent*>(e);
+-        if (!k->isAutoRepeat() && (k->key() == Qt::Key_Select || k->key() == Qt::Key_Space)) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (!k->isAutoRepeat() && buttonPressKeys.contains(static_cast<Qt::Key>(k->key()))) {
+             d->pressedControl = QStyle::SC_GroupBoxCheckBox;
+             update(style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxCheckBox, this));
+             return true;
+@@ -369,7 +374,10 @@ bool QGroupBox::event(QEvent *e)
+     }
+     case QEvent::KeyRelease: {
+         QKeyEvent *k = static_cast<QKeyEvent*>(e);
+-        if (!k->isAutoRepeat() && (k->key() == Qt::Key_Select || k->key() == Qt::Key_Space)) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (!k->isAutoRepeat() && buttonPressKeys.contains(static_cast<Qt::Key>(k->key()))) {
+             bool toggle = (d->pressedControl == QStyle::SC_GroupBoxLabel
+                            || d->pressedControl == QStyle::SC_GroupBoxCheckBox);
+             d->pressedControl = QStyle::SC_None;
+diff --git a/qtbase/src/widgets/widgets/qlabel.cpp b/qtbase/src/widgets/widgets/qlabel.cpp
+index 30ff80cbb0..cf2605c17c 100644
+--- a/qtbase/src/widgets/widgets/qlabel.cpp
++++ b/qtbase/src/widgets/widgets/qlabel.cpp
+@@ -421,9 +421,6 @@ void QLabel::setPixmap(const QPixmap &pixmap)
+         d->pixmap = new QPixmap(pixmap);
+     }
+ 
+-    if (d->pixmap->depth() == 1 && !d->pixmap->mask())
+-        d->pixmap->setMask(*((QBitmap *)d->pixmap));
+-
+     d->updateLabel();
+ }
+ 
+diff --git a/qtbase/src/widgets/widgets/qtoolbararealayout.cpp b/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
+index 493c094cc1..d5f4b59017 100644
+--- a/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
++++ b/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
+@@ -1367,7 +1367,7 @@ bool QToolBarAreaLayout::restoreState(QDataStream &stream, const QList<QToolBar*
+                 item.widgetItem = new QWidgetItemV2(toolBar);
+                 toolBar->setOrientation(floating ? ((shown & 2) ? Qt::Vertical : Qt::Horizontal) : dock.o);
+                 toolBar->setVisible(shown & 1);
+-                toolBar->d_func()->setWindowState(floating, true, rect);
++                toolBar->d_func()->setWindowState(floating, false, rect);
+ 
+                 item.preferredSize = item.size;
+                 line.toolBarItems.append(item);
+diff --git a/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp b/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
+index 212c0a2e13..3c77b1ba0b 100644
+--- a/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
++++ b/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
+@@ -126,8 +126,7 @@ public:
+ 
+ void tst_QtConcurrentIterateKernel::instantiate()
+ {
+-    auto future = startThreadEngine(new PrintFor(0, 40)).startAsynchronously();
+-    future.waitForFinished();
++    startThreadEngine(new PrintFor(0, 40)).startBlocking();
+     QCOMPARE(iterations.loadRelaxed(), 40);
+ }
+ 
+@@ -166,10 +165,8 @@ void tst_QtConcurrentIterateKernel::stresstest()
+     const int times = 50;
+     for (int i = 0; i < times; ++i) {
+         counter.storeRelaxed(0);
+-        // ThreadEngine will delete f when it finishes
+-        auto f = new CountFor(0, iterations);
+-        auto future = f->startAsynchronously();
+-        future.waitForFinished();
++        CountFor f(0, iterations);
++        f.startBlocking();
+         QCOMPARE(counter.loadRelaxed(), iterations);
+     }
+ }
+@@ -177,11 +174,8 @@ void tst_QtConcurrentIterateKernel::stresstest()
+ void tst_QtConcurrentIterateKernel::noIterations()
+ {
+     const int times = 20000;
+-    for (int i = 0; i < times; ++i) {
+-        auto future = startThreadEngine(new IterateKernel<TestIterator, void>(0, 0))
+-                              .startAsynchronously();
+-        future.waitForFinished();
+-    }
++    for (int i = 0; i < times; ++i)
++        startThreadEngine(new IterateKernel<TestIterator, void>(0, 0)).startBlocking();
+ }
+ 
+ QMutex threadsMutex;
+@@ -236,10 +230,8 @@ void tst_QtConcurrentIterateKernel::throttling()
+ 
+     threads.clear();
+ 
+-    // ThreadEngine will delete f when it finishes
+-    auto f = new ThrottleFor(0, totalIterations);
+-    auto future = f->startAsynchronously();
+-    future.waitForFinished();
++    ThrottleFor f(0, totalIterations);
++    f.startBlocking();
+ 
+     QCOMPARE(iterations.loadRelaxed(), totalIterations);
+ 
+diff --git a/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp b/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
+index ac7be7acdd..81bc64c8d9 100644
+--- a/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
++++ b/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
+@@ -65,9 +65,16 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::runDirectly()
+ {
+-    PrintUser *engine = new PrintUser();
+-    QFuture<void> f = engine->startAsynchronously();
+-    f.waitForFinished();
++    {
++        PrintUser engine;
++        engine.startSingleThreaded();
++        engine.startBlocking();
++    }
++    {
++        PrintUser *engine = new PrintUser();
++        QFuture<void> f = engine->startAsynchronously();
++        f.waitForFinished();
++    }
+ }
+ 
+ class StringResultUser : public ThreadEngine<QString>
+@@ -99,10 +106,8 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::result()
+ {
+-    // ThreadEngine will delete 'engine' when it finishes
+-    auto engine = new StringResultUser();
+-    auto future = engine->startAsynchronously();
+-    QCOMPARE(future.result(), QString("Foo"));
++    StringResultUser engine;
++    QCOMPARE(*engine.startBlocking(), QString("Foo"));
+ }
+ 
+ class VoidResultUser : public ThreadEngine<void>
+@@ -128,9 +133,17 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::runThroughStarter()
+ {
+-    ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
+-    QFuture<QString> f = starter.startAsynchronously();
+-    QCOMPARE(f.result(), QString("Foo"));
++    {
++        ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
++        QFuture<QString>  f = starter.startAsynchronously();
++        QCOMPARE(f.result(), QString("Foo"));
++    }
++
++    {
++        ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
++        QString str = starter.startBlocking();
++        QCOMPARE(str, QString("Foo"));
++    }
+ }
+ 
+ class CancelUser : public ThreadEngine<void>
+@@ -213,6 +226,12 @@ void tst_QtConcurrentThreadEngine::throttle()
+         f.waitForFinished();
+         QCOMPARE(count.loadRelaxed(), 0);
+     }
++
++    for (int i = 0; i < repeats; ++i) {
++        ThrottleAlwaysUser t;
++        t.startBlocking();
++        QCOMPARE(count.loadRelaxed(), 0);
++    }
+ }
+ 
+ QSet<QThread *> threads;
+@@ -249,17 +268,35 @@ void tst_QtConcurrentThreadEngine::threadCount()
+ {
+     const int repeats = 10;
+     for (int i = 0; i < repeats; ++i) {
++        ThreadCountUser t;
++        t.startBlocking();
++        int count = threads.count();
++        int count_expected = QThreadPool::globalInstance()->maxThreadCount() + 1; // +1 for the main thread.
++        if (count != count_expected)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, count_expected);
++
+         (new ThreadCountUser())->startAsynchronously().waitForFinished();
+-        const auto count = threads.count();
+-        const auto maxThreadCount = QThreadPool::globalInstance()->maxThreadCount();
+-        QVERIFY(count <= maxThreadCount);
+-        QVERIFY(!threads.contains(QThread::currentThread()));
++        count = threads.count();
++        count_expected = QThreadPool::globalInstance()->maxThreadCount();
++        if (count != count_expected)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, count_expected);
+     }
+ 
+     // Set the finish flag immediately, this should give us one thread only.
+     for (int i = 0; i < repeats; ++i) {
++        ThreadCountUser t(true /*finishImmediately*/);
++        t.startBlocking();
++        int count = threads.count();
++        if (count != 1)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, 1);
++
+         (new ThreadCountUser(true /*finishImmediately*/))->startAsynchronously().waitForFinished();
+-        const auto count = threads.count();
++        count = threads.count();
++        if (count != 1)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
+         QCOMPARE(count, 1);
+         QVERIFY(!threads.contains(QThread::currentThread()));
+     }
+@@ -400,6 +437,7 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::exceptions()
+ {
++    // Asynchronous mode:
+     {
+         bool caught = false;
+         try  {
+@@ -412,6 +450,32 @@ void tst_QtConcurrentThreadEngine::exceptions()
+         QVERIFY2(caught, "did not get exception");
+     }
+ 
++    // Blocking mode:
++    // test throwing the exception from a worker thread.
++    {
++        bool caught = false;
++        try  {
++            QtConcurrentExceptionThrower e(QThread::currentThread());
++            e.startBlocking();
++        } catch (const QException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // test throwing the exception from the main thread (different code path)
++    {
++        bool caught = false;
++        try  {
++            QtConcurrentExceptionThrower e(0);
++            e.startBlocking();
++        } catch (const QException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // Asynchronous mode:
+     {
+         bool caught = false;
+         try  {
+@@ -423,6 +487,31 @@ void tst_QtConcurrentThreadEngine::exceptions()
+         }
+         QVERIFY2(caught, "did not get exception");
+     }
++
++    // Blocking mode:
++    // test throwing the exception from a worker thread.
++    {
++        bool caught = false;
++        try  {
++            UnrelatedExceptionThrower e(QThread::currentThread());
++            e.startBlocking();
++        } catch (const QUnhandledException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // test throwing the exception from the main thread (different code path)
++    {
++        bool caught = false;
++        try  {
++            UnrelatedExceptionThrower e(0);
++            e.startBlocking();
++        } catch (const QUnhandledException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
+ }
+ 
+ #endif
+diff --git a/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp b/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
+index 4968742110..f4c3fb711d 100644
+--- a/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
++++ b/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
+@@ -42,6 +42,7 @@ private slots:
+     void writeBlock_data();
+     void writeBlock();
+     void seek();
++    void invalidSeeks();
+     void seekTest_data();
+     void seekTest();
+     void read_rawdata();
+@@ -286,6 +287,29 @@ void tst_QBuffer::seek()
+     QCOMPARE(buffer.size(), pos);
+ }
+ 
++void tst_QBuffer::invalidSeeks()
++{
++    if constexpr (sizeof(qsizetype) == sizeof(qint64)) {
++        // sizeof(qsizetype) == sizeof(qint64), so +1 would overflow
++        QSKIP("This is a 32-bit-only test.");
++    } else {
++        QBuffer buffer;
++        buffer.open(QIODevice::WriteOnly);
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++        constexpr qint64 MaxQByteArrayCapacity = (std::numeric_limits<qsizetype>::max)();
++        // this should fail fast, not after trying to allocate nearly 2 GiB of data,
++        // potentially crashing in the process:
++        QVERIFY(!buffer.seek(2 * MaxQByteArrayCapacity - 1));
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++        // ditto:
++        QVERIFY(!buffer.seek(MaxQByteArrayCapacity + 1));
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++    }
++}
++
+ void tst_QBuffer::seekTest_data()
+ {
+     writeBlock_data();
+diff --git a/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp b/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
+index da5327594c..4a04e0f7c6 100644
+--- a/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
++++ b/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
+@@ -561,7 +561,8 @@ protected:
+     qint64 readData(char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf->size() - offset));
+-        memcpy(data, buf->constData() + offset, maxSize);
++        if (maxSize > 0)
++            memcpy(data, buf->constData() + offset, maxSize);
+         offset += maxSize;
+         return maxSize;
+     }
+@@ -604,13 +605,15 @@ protected:
+     qint64 readData(char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf.size() - pos()));
+-        memcpy(data, buf.constData() + pos(), maxSize);
++        if (maxSize > 0)
++            memcpy(data, buf.constData() + pos(), maxSize);
+         return maxSize;
+     }
+     qint64 writeData(const char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf.size() - pos()));
+-        memcpy(buf.data() + pos(), data, maxSize);
++        if (maxSize > 0)
++            memcpy(buf.data() + pos(), data, maxSize);
+         return maxSize;
+     }
+ 
+diff --git a/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+index db60bead64..f345a44414 100644
+--- a/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
++++ b/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+@@ -1,7 +1,8 @@
+ /****************************************************************************
+ **
+ ** Copyright (C) 2021 The Qt Company Ltd.
+-** Copyright (C) 2020 Intel Corporation.
++** Copyright (C) 2020 The Qt Company Ltd.
++** Copyright (C) 2022 Intel Corporation.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the test suite of the Qt Toolkit.
+@@ -150,6 +151,8 @@ private slots:
+     void startStopStartStopBuffers();
+     void processEventsInAReadyReadSlot_data();
+     void processEventsInAReadyReadSlot();
++    void startFromCurrentWorkingDir_data();
++    void startFromCurrentWorkingDir();
+ 
+     // keep these at the end, since they use lots of processes and sometimes
+     // caused obscure failures to occur in tests that followed them (esp. on the Mac)
+@@ -2731,5 +2734,94 @@ void tst_QProcess::finishProcessBeforeReadingDone_deprecated()
+ 
+ #endif
+ 
++enum class ChdirMode {
++    None = 0,
++    InParent,
++    InChild
++};
++Q_DECLARE_METATYPE(ChdirMode)
++
++void tst_QProcess::startFromCurrentWorkingDir_data()
++{
++    qRegisterMetaType<ChdirMode>();
++    QTest::addColumn<QString>("programPrefix");
++    QTest::addColumn<ChdirMode>("chdirMode");
++    QTest::addColumn<bool>("success");
++
++    constexpr bool IsWindows = true
++#ifdef Q_OS_UNIX
++            && false
++#endif
++            ;
++
++    // baseline: trying to execute the directory, this can't possibly succeed!
++    QTest::newRow("plain-same-cwd") << QString() << ChdirMode::None << false;
++
++    // cross-platform behavior: neither OS searches the setWorkingDirectory()
++    // dir without "./"
++    QTest::newRow("plain-child-chdir") << QString() << ChdirMode::InChild << false;
++
++    // cross-platform behavior: both OSes search the parent's CWD with "./"
++    QTest::newRow("prefixed-parent-chdir") << "./" << ChdirMode::InParent << true;
++
++    // opposite behaviors: Windows searches the parent's CWD and Unix searches
++    // the child's with "./"
++    QTest::newRow("prefixed-child-chdir") << "./" << ChdirMode::InChild << !IsWindows;
++
++    // Windows searches the parent's CWD without "./"
++    QTest::newRow("plain-parent-chdir") << QString() << ChdirMode::InParent << IsWindows;
++}
++
++void tst_QProcess::startFromCurrentWorkingDir()
++{
++    QFETCH(QString, programPrefix);
++    QFETCH(ChdirMode, chdirMode);
++    QFETCH(bool, success);
++
++    QProcess process;
++    qRegisterMetaType<QProcess::ProcessError>();
++    QSignalSpy errorSpy(&process, &QProcess::errorOccurred);
++    QVERIFY(errorSpy.isValid());
++
++    // both the dir name and the executable name
++    const QString target = QStringLiteral("testProcessNormal");
++    process.setProgram(programPrefix + target);
++
++#ifdef Q_OS_UNIX
++    // Reset PATH, to be sure it doesn't contain . or the empty path.
++    // We can't do this on Windows because DLLs are searched in PATH
++    // and Windows always searches "." anyway.
++    auto restoreEnv = qScopeGuard([old = qgetenv("PATH")] {
++        qputenv("PATH", old);
++    });
++    qputenv("PATH", "/");
++#endif
++
++    switch (chdirMode) {
++    case ChdirMode::InParent: {
++        auto restoreCwd = qScopeGuard([old = QDir::currentPath()] {
++            QDir::setCurrent(old);
++        });
++        QVERIFY(QDir::setCurrent(target));
++        process.start();
++        break;
++    }
++    case ChdirMode::InChild:
++        process.setWorkingDirectory(target);
++        Q_FALLTHROUGH();
++    case ChdirMode::None:
++        process.start();
++        break;
++    }
++
++    QCOMPARE(process.waitForStarted(), success);
++    QCOMPARE(errorSpy.count(), int(!success));
++    if (success) {
++        QVERIFY(process.waitForFinished());
++    } else {
++        QCOMPARE(process.error(), QProcess::FailedToStart);
++    }
++}
++
+ QTEST_MAIN(tst_QProcess)
+ #include "tst_qprocess.moc"
+diff --git a/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp b/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp
+index e1ea7a4552..90972caa57 100644
+--- a/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp
++++ b/qtbase/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"
+diff --git a/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+index 9bd66c0835..ed4a0bae5d 100644
+--- a/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
++++ b/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+@@ -158,6 +158,7 @@ private slots:
+     void nullReceiver();
+     void functorReferencesConnection();
+     void disconnectDisconnects();
++    void declarativeData();
+ };
+ 
+ struct QObjectCreatedOnShutdown
+@@ -7679,5 +7680,81 @@ void tst_QObject::disconnectDisconnects()
+ Q_STATIC_ASSERT(QtPrivate::HasQ_OBJECT_Macro<tst_QObject>::Value);
+ Q_STATIC_ASSERT(!QtPrivate::HasQ_OBJECT_Macro<SiblingDeleter>::Value);
+ 
++#ifdef QT_BUILD_INTERNAL
++/*
++    Since QObjectPrivate stores the declarativeData pointer in a union with the pointer
++    to the currently destroyed child, calls to the QtDeclarative handlers need to be
++    correctly guarded. QTBUG-105286
++*/
++namespace QtDeclarative {
++static QAbstractDeclarativeData *theData;
++
++static void destroyed(QAbstractDeclarativeData *data, QObject *)
++{
++    QCOMPARE(data, theData);
++}
++static void signalEmitted(QAbstractDeclarativeData *data, QObject *, int, void **)
++{
++    QCOMPARE(data, theData);
++}
++// we can't use QCOMPARE in the next two functions, as they don't return void
++static int receivers(QAbstractDeclarativeData *data, const QObject *, int)
++{
++    QTest::qCompare(data, theData, "data", "theData", __FILE__, __LINE__);
++    return 0;
++}
++static bool isSignalConnected(QAbstractDeclarativeData *data, const QObject *, int)
++{
++    QTest::qCompare(data, theData, "data", "theData", __FILE__, __LINE__);
++    return true;
++}
++
++class Object : public QObject
++{
++    Q_OBJECT
++public:
++    using QObject::QObject;
++    ~Object()
++    {
++        if (Object *p = static_cast<Object *>(parent()))
++            p->emitSignal();
++    }
++
++    void emitSignal()
++    {
++        emit theSignal();
++    }
++
++signals:
++    void theSignal();
++};
++
++}
++#endif
++
++void tst_QObject::declarativeData()
++{
++#ifdef QT_BUILD_INTERNAL
++    QScopedValueRollback destroyed(QAbstractDeclarativeData::destroyed,
++                                   QtDeclarative::destroyed);
++    QScopedValueRollback signalEmitted(QAbstractDeclarativeData::signalEmitted,
++                                       QtDeclarative::signalEmitted);
++    QScopedValueRollback receivers(QAbstractDeclarativeData::receivers,
++                                   QtDeclarative::receivers);
++    QScopedValueRollback isSignalConnected(QAbstractDeclarativeData::isSignalConnected,
++                                           QtDeclarative::isSignalConnected);
++
++    QtDeclarative::Object p;
++    QObjectPrivate *priv = QObjectPrivate::get(&p);
++    priv->declarativeData = QtDeclarative::theData = new QAbstractDeclarativeData;
++
++    connect(&p, &QtDeclarative::Object::theSignal, &p, []{
++    });
++
++    QtDeclarative::Object *child = new QtDeclarative::Object;
++    child->setParent(&p);
++#endif
++}
++
+ QTEST_MAIN(tst_QObject)
+ #include "tst_qobject.moc"
+diff --git a/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp b/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
+index 0ea422ecbc..1a3256534b 100644
+--- a/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
++++ b/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
+@@ -70,15 +70,15 @@ static inline QString testSuiteWarning()
+ 
+     QString result;
+     QTextStream str(&result);
+-    str << "\nCannot find the shared-mime-info test suite\nstarting from: "
++    str << "\nCannot find the shared-mime-info test suite\nin the parent of: "
+         << QDir::toNativeSeparators(QDir::currentPath()) << "\n"
+            "cd " << QDir::toNativeSeparators(QStringLiteral("tests/auto/corelib/mimetypes/qmimedatabase")) << "\n"
+-           "wget http://cgit.freedesktop.org/xdg/shared-mime-info/snapshot/Release-1-10.zip\n"
+-           "unzip Release-1-10.zip\n";
++           "wget https://gitlab.freedesktop.org/xdg/shared-mime-info/-/archive/2.1/shared-mime-info-2.1.zip\n"
++           "unzip shared-mime-info-2.1.zip\n";
+ #ifdef Q_OS_WIN
+-    str << "mkdir testfiles\nxcopy /s Release-1-10 s-m-i\n";
++    str << "mkdir testfiles\nxcopy /s shared-mime-info-2.1 s-m-i\n";
+ #else
+-    str << "ln -s Release-1-10 s-m-i\n";
++    str << "ln -s shared-mime-info-2.1 s-m-i\n";
+ #endif
+     return result;
+ }
+@@ -154,7 +154,7 @@ void tst_QMimeDatabase::initTestCase()
+     QVERIFY2(copyResourceFile(xmlFileName, xmlTargetFileName, &errorMessage), qPrintable(errorMessage));
+ #endif
+ 
+-    m_testSuite = QFINDTESTDATA("s-m-i/tests");
++    m_testSuite = QFINDTESTDATA("s-m-i/tests/mime-detection");
+     if (m_testSuite.isEmpty())
+         qWarning("%s", qPrintable(testSuiteWarning()));
+ 
+@@ -611,7 +611,7 @@ void tst_QMimeDatabase::allMimeTypes()
+     QVERIFY(!lst.isEmpty());
+ 
+     // Hardcoding this is the only way to check both providers find the same number of mimetypes.
+-    QCOMPARE(lst.count(), 779);
++    QCOMPARE(lst.count(), 811);
+ 
+     foreach (const QMimeType &mime, lst) {
+         const QString name = mime.name();
+@@ -631,10 +631,9 @@ void tst_QMimeDatabase::suffixes_data()
+ 
+     QTest::newRow("mimetype with a single pattern") << "application/pdf" << "*.pdf" << "pdf";
+     QTest::newRow("mimetype with multiple patterns") << "application/x-kpresenter" << "*.kpr;*.kpt" << "kpr";
+-    QTest::newRow("jpeg") << "image/jpeg" << "*.jpe;*.jpg;*.jpeg" << "jpeg";
+-    //if (KMimeType::sharedMimeInfoVersion() > KDE_MAKE_VERSION(0, 60, 0)) {
+-        QTest::newRow("mimetype with many patterns") << "application/vnd.wordperfect" << "*.wp;*.wp4;*.wp5;*.wp6;*.wpd;*.wpp" << "wp";
+-    //}
++    // The preferred suffix for image/jpeg is *.jpg, as per https://bugs.kde.org/show_bug.cgi?id=176737
++    QTest::newRow("jpeg") << "image/jpeg" << "*.jpe;*.jpg;*.jpeg" << "jpg";
++    QTest::newRow("mimetype with many patterns") << "application/vnd.wordperfect" << "*.wp;*.wp4;*.wp5;*.wp6;*.wpd;*.wpp" << "wp";
+     QTest::newRow("oasis text mimetype") << "application/vnd.oasis.opendocument.text" << "*.odt" << "odt";
+     QTest::newRow("oasis presentation mimetype") << "application/vnd.oasis.opendocument.presentation" << "*.odp" << "odp";
+     QTest::newRow("mimetype with multiple patterns") << "text/plain" << "*.asc;*.txt;*,v" << "txt";
+diff --git a/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp b/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
+index 3e58dd03cc..c8f82ef5d5 100644
+--- a/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
++++ b/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
+@@ -176,6 +176,8 @@ private Q_SLOTS:
+     void fromToVariantConversions_data();
+     void fromToVariantConversions();
+ 
++    void noLeakOnNameClash();
++
+ private:
+     QString testDataDir;
+ };
+@@ -3685,5 +3687,23 @@ void tst_QtJson::fromToVariantConversions()
+     }
+ }
+ 
++void tst_QtJson::noLeakOnNameClash()
++{
++    QJsonDocument doc = QJsonDocument::fromJson("{\"\":{\"\":0},\"\":0}");
++    QVERIFY(!doc.isNull());
++    const QJsonObject obj = doc.object();
++
++    // Removed the duplicate key.
++    QCOMPARE(obj.length(), 1);
++
++    // Retained the last of the duplicates.
++    const QJsonValue val = obj.begin().value();
++    QVERIFY(val.isDouble());
++    QCOMPARE(val.toDouble(), 0.0);
++
++    // It should not leak.
++    // In particular it should not forget to deref the container for the inner object.
++}
++
+ QTEST_MAIN(tst_QtJson)
+ #include "tst_qtjson.moc"
+diff --git a/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp b/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
+index a59b58d57f..241c3e84ac 100644
+--- a/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
++++ b/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
+@@ -63,6 +63,7 @@ private slots:
+     void isValidId_data();
+     void isValidId();
+     void malformed();
++    void serialize();
+     // Backend tests
+     void utcTest();
+     void icuTest();
+@@ -947,6 +948,33 @@ void tst_QTimeZone::malformed()
+         barf.offsetFromUtc(now);
+ }
+ 
++void tst_QTimeZone::serialize()
++{
++    int parts = 0;
++#ifndef QT_NO_DEBUG_STREAM
++    qDebug() << QTimeZone(); // to verify no crash
++    parts++;
++#endif
++#ifndef QT_NO_DATASTREAM
++    QByteArray blob;
++    {
++        QDataStream stream(&blob, QIODevice::WriteOnly);
++        stream << QTimeZone("Europe/Oslo") << QTimeZone(420) << QTimeZone() << qint64(-1);
++    }
++    QDataStream stream(&blob, QIODevice::ReadOnly);
++    QTimeZone invalid, offset, oslo;
++    qint64 minusone;
++    stream >> oslo >> offset >> invalid >> minusone;
++    QCOMPARE(oslo, QTimeZone("Europe/Oslo"));
++    QCOMPARE(offset, QTimeZone(420));
++    QVERIFY(!invalid.isValid());
++    QCOMPARE(minusone, qint64(-1));
++    parts++;
++#endif
++    if (!parts)
++        QSKIP("No serialization enabled");
++}
++
+ void tst_QTimeZone::utcTest()
+ {
+ #ifdef QT_BUILD_INTERNAL
+diff --git a/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp b/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
+index 05480c6dd2..70f4c75756 100644
+--- a/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
++++ b/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
+@@ -324,6 +324,13 @@ void tst_QDBusInterface::notValid()
+ 
+     QVERIFY(!interface.isValid());
+     QVERIFY(!QMetaObject::invokeMethod(&interface, "ListNames", Qt::DirectConnection));
++
++    // With a connection, but empty/null service and path specified
++    QDBusConnection con = QDBusConnection::sessionBus();
++    QVERIFY(con.isConnected());
++    QDBusInterface iface({}, {}, {}, con);
++    QVERIFY(!iface.isValid());
++    QVERIFY(!QMetaObject::invokeMethod(&interface, "ListNames", Qt::DirectConnection));
+ }
+ 
+ void tst_QDBusInterface::notValidDerived()
+diff --git a/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp b/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
+index 874468c954..04ceb4ab65 100644
+--- a/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
++++ b/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
+@@ -507,6 +507,10 @@ void tst_QKeySequence::toStringFromKeycode_data()
+     QTest::newRow("Ctrl+Alt+Num+Del") << QKeySequence(Qt::ControlModifier | Qt::AltModifier | Qt::KeypadModifier | Qt::Key_Delete) << "Ctrl+Alt+Num+Del";
+     QTest::newRow("Ctrl+Ins") << QKeySequence(Qt::ControlModifier | Qt::Key_Insert) << "Ctrl+Ins";
+     QTest::newRow("Ctrl+Num+Ins(1)") << QKeySequence(Qt::Key_Insert | Qt::KeypadModifier | Qt::ControlModifier) << "Ctrl+Num+Ins";
++    QTest::newRow("Ctrl") << QKeySequence(Qt::Key_Control) << "Control";
++    QTest::newRow("Alt") << QKeySequence(Qt::Key_Alt) << "Alt";
++    QTest::newRow("Shift") << QKeySequence(Qt::Key_Shift) << "Shift";
++    QTest::newRow("Meta") << QKeySequence(Qt::Key_Meta) << "Meta";
+ }
+ 
+ void tst_QKeySequence::toStringFromKeycode()
+diff --git a/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp b/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+index 15e0ecadaa..b4eca74283 100644
+--- a/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
++++ b/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+@@ -81,6 +81,8 @@ private slots:
+     void registerOpenTypePreferredNamesSystem();
+     void registerOpenTypePreferredNamesApplication();
+ 
++    void stretchRespected();
++
+ private:
+     QString m_ledFont;
+     QString m_testFont;
+@@ -355,6 +357,28 @@ static QString testString()
+     return QStringLiteral("foo bar");
+ }
+ 
++void tst_QFontDatabase::stretchRespected()
++{
++    int italicId = QFontDatabase::addApplicationFont(m_testFontItalic);
++    QVERIFY(italicId != -1);
++
++    QVERIFY(!QFontDatabase::applicationFontFamilies(italicId).isEmpty());
++
++    QString italicFontName = QFontDatabase::applicationFontFamilies(italicId).first();
++
++    QFont italicFont = QFontDatabase().font(italicFontName,
++                                            QString::fromLatin1("Italic"), 14);
++    QVERIFY(italicFont.italic());
++
++    QFont italicStretchedFont = italicFont;
++    italicStretchedFont.setStretch( 400 );
++
++    QVERIFY(QFontMetricsF(italicFont).horizontalAdvance(QStringLiteral("foobar")) <
++            QFontMetricsF(italicStretchedFont).horizontalAdvance(QStringLiteral("foobar")));
++
++    QFontDatabase::removeApplicationFont(italicId);
++}
++
+ void tst_QFontDatabase::condensedFontWidthNoFontMerging()
+ {
+     int regularFontId = QFontDatabase::addApplicationFont(m_testFont);
+diff --git a/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+index 3d4a094c43..b423e11a99 100644
+--- a/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
++++ b/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+@@ -281,6 +281,7 @@ private Q_SLOTS:
+     void ioGetFromFileSpecial();
+     void ioGetFromFile_data();
+     void ioGetFromFile();
++    void ioGetFromFileUrl();
+     void ioGetFromFtp_data();
+     void ioGetFromFtp();
+     void ioGetFromFtpWithReuse();
+@@ -3300,6 +3301,18 @@ void tst_QNetworkReply::ioGetFromFile()
+     QCOMPARE(reader.data, data);
+ }
+ 
++void tst_QNetworkReply::ioGetFromFileUrl()
++{
++    // This immediately fails on non-windows platforms:
++    QNetworkRequest request(QUrl("file://unc-server/some/path"));
++    QNetworkReplyPtr reply(manager.get(request));
++    QSignalSpy finishedSpy(reply.get(), &QNetworkReply::finished);
++    // QTBUG-105618: This would, on non-Windows platforms, never happen because the signal
++    // was emitted before the constructor finished, leaving no chance at all to connect to the
++    // signal
++    QVERIFY(finishedSpy.wait());
++}
++
+ void tst_QNetworkReply::ioGetFromFtp_data()
+ {
+     QTest::addColumn<QString>("fileName");
+diff --git a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
+index 069fa6b341..4cc4d9a5ea 100644
+--- a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
++++ b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
+@@ -1,75 +1,34 @@
+-Certificate:
+-    Data:
+-        Version: 3 (0x2)
+-        Serial Number: 0 (0x0)
+-        Signature Algorithm: sha1WithRSAEncryption
+-        Issuer: C=NO, ST=Oslo, L=Nydalen, O=Nokia Corporation and/or its subsidiary(-ies), OU=Development, CN=fluke.troll.no/emailAddress=ahanssen@trolltech.com
+-        Validity
+-            Not Before: Dec  4 01:10:32 2007 GMT
+-            Not After : Apr 21 01:10:32 2035 GMT
+-        Subject: C=NO, ST=Oslo, O=Nokia Corporation and/or its subsidiary(-ies), OU=Development, CN=fluke.troll.no
+-        Subject Public Key Info:
+-            Public Key Algorithm: rsaEncryption
+-            RSA Public Key: (1024 bit)
+-                Modulus (1024 bit):
+-                    00:a7:c8:a0:4a:c4:19:05:1b:66:ba:32:e2:d2:f1:
+-                    1c:6f:17:82:e4:39:2e:01:51:90:db:04:34:32:11:
+-                    21:c2:0d:6f:59:d8:53:90:54:3f:83:8f:a9:d3:b3:
+-                    d5:ee:1a:9b:80:ae:c3:25:c9:5e:a5:af:4b:60:05:
+-                    aa:a0:d1:91:01:1f:ca:04:83:e3:58:1c:99:32:45:
+-                    84:70:72:58:03:98:4a:63:8b:41:f5:08:49:d2:91:
+-                    02:60:6b:e4:64:fe:dd:a0:aa:74:08:e9:34:4c:91:
+-                    5f:12:3d:37:4d:54:2c:ad:7f:5b:98:60:36:02:8c:
+-                    3b:f6:45:f3:27:6a:9b:94:9d
+-                Exponent: 65537 (0x10001)
+-        X509v3 extensions:
+-            X509v3 Basic Constraints: 
+-                CA:FALSE
+-            Netscape Comment: 
+-                OpenSSL Generated Certificate
+-            X509v3 Subject Key Identifier: 
+-                21:85:04:3D:23:01:66:E5:F7:9F:1A:84:24:8A:AF:0A:79:F4:E5:AC
+-            X509v3 Authority Key Identifier: 
+-                DirName:/C=NO/ST=Oslo/L=Nydalen/O=Nokia Corporation and/or its subsidiary(-ies)/OU=Development/CN=fluke.troll.no/emailAddress=ahanssen@trolltech.com
+-                serial:8E:A8:B4:E8:91:B7:54:2E
+-
+-    Signature Algorithm: sha1WithRSAEncryption
+-        6d:57:5f:d1:05:43:f0:62:05:ec:2a:71:a5:dc:19:08:f2:c4:
+-        a6:bd:bb:25:d9:ca:89:01:0e:e4:cf:1f:c1:8c:c8:24:18:35:
+-        53:59:7b:c0:43:b4:32:e6:98:b2:a6:ef:15:05:0b:48:5f:e1:
+-        a0:0c:97:a9:a1:77:d8:35:18:30:bc:a9:8f:d3:b7:54:c7:f1:
+-        a9:9e:5d:e6:19:bf:f6:3c:5b:2b:d8:e4:3e:62:18:88:8b:d3:
+-        24:e1:40:9b:0c:e6:29:16:62:ab:ea:05:24:70:36:aa:55:93:
+-        ef:02:81:1b:23:10:a2:04:eb:56:95:75:fc:f8:94:b1:5d:42:
+-        c5:3f:36:44:85:5d:3a:2e:90:46:8a:a2:b9:6f:87:ae:0c:15:
+-        40:19:31:90:fc:3b:25:bb:ae:f1:66:13:0d:85:90:d9:49:34:
+-        8f:f2:5d:f9:7a:db:4d:5d:27:f6:76:9d:35:8c:06:a6:4c:a3:
+-        b1:b2:b6:6f:1d:d7:a3:00:fd:72:eb:9e:ea:44:a1:af:21:34:
+-        7d:c7:42:e2:49:91:19:8b:c0:ad:ba:82:80:a8:71:70:f4:35:
+-        31:91:63:84:20:95:e9:60:af:64:8b:cc:ff:3d:8a:76:74:3d:
+-        c8:55:6d:e4:8e:c3:2b:1c:e8:42:18:ae:9f:e6:6b:9c:34:06:
+-        ec:6a:f2:c3
+ -----BEGIN CERTIFICATE-----
+-MIIEEzCCAvugAwIBAgIBADANBgkqhkiG9w0BAQUFADCBnDELMAkGA1UEBhMCTk8x
+-DTALBgNVBAgTBE9zbG8xEDAOBgNVBAcTB055ZGFsZW4xFjAUBgNVBAoTDVRyb2xs
+-dGVjaCBBU0ExFDASBgNVBAsTC0RldmVsb3BtZW50MRcwFQYDVQQDEw5mbHVrZS50
+-cm9sbC5ubzElMCMGCSqGSIb3DQEJARYWYWhhbnNzZW5AdHJvbGx0ZWNoLmNvbTAe
+-Fw0wNzEyMDQwMTEwMzJaFw0zNTA0MjEwMTEwMzJaMGMxCzAJBgNVBAYTAk5PMQ0w
+-CwYDVQQIEwRPc2xvMRYwFAYDVQQKEw1Ucm9sbHRlY2ggQVNBMRQwEgYDVQQLEwtE
+-ZXZlbG9wbWVudDEXMBUGA1UEAxMOZmx1a2UudHJvbGwubm8wgZ8wDQYJKoZIhvcN
+-AQEBBQADgY0AMIGJAoGBAKfIoErEGQUbZroy4tLxHG8XguQ5LgFRkNsENDIRIcIN
+-b1nYU5BUP4OPqdOz1e4am4CuwyXJXqWvS2AFqqDRkQEfygSD41gcmTJFhHByWAOY
+-SmOLQfUISdKRAmBr5GT+3aCqdAjpNEyRXxI9N01ULK1/W5hgNgKMO/ZF8ydqm5Sd
+-AgMBAAGjggEaMIIBFjAJBgNVHRMEAjAAMCwGCWCGSAGG+EIBDQQfFh1PcGVuU1NM
+-IEdlbmVyYXRlZCBDZXJ0aWZpY2F0ZTAdBgNVHQ4EFgQUIYUEPSMBZuX3nxqEJIqv
+-Cnn05awwgbsGA1UdIwSBszCBsKGBoqSBnzCBnDELMAkGA1UEBhMCTk8xDTALBgNV
+-BAgTBE9zbG8xEDAOBgNVBAcTB055ZGFsZW4xFjAUBgNVBAoTDVRyb2xsdGVjaCBB
+-U0ExFDASBgNVBAsTC0RldmVsb3BtZW50MRcwFQYDVQQDEw5mbHVrZS50cm9sbC5u
+-bzElMCMGCSqGSIb3DQEJARYWYWhhbnNzZW5AdHJvbGx0ZWNoLmNvbYIJAI6otOiR
+-t1QuMA0GCSqGSIb3DQEBBQUAA4IBAQBtV1/RBUPwYgXsKnGl3BkI8sSmvbsl2cqJ
+-AQ7kzx/BjMgkGDVTWXvAQ7Qy5piypu8VBQtIX+GgDJepoXfYNRgwvKmP07dUx/Gp
+-nl3mGb/2PFsr2OQ+YhiIi9Mk4UCbDOYpFmKr6gUkcDaqVZPvAoEbIxCiBOtWlXX8
+-+JSxXULFPzZEhV06LpBGiqK5b4euDBVAGTGQ/Dslu67xZhMNhZDZSTSP8l35ettN
+-XSf2dp01jAamTKOxsrZvHdejAP1y657qRKGvITR9x0LiSZEZi8CtuoKAqHFw9DUx
+-kWOEIJXpYK9ki8z/PYp2dD3IVW3kjsMrHOhCGK6f5mucNAbsavLD
++MIIF6zCCA9OgAwIBAgIUfo9amJtJGWqWE6f+SkAO85zkGr4wDQYJKoZIhvcNAQEL
++BQAwgYMxCzAJBgNVBAYTAk5PMQ0wCwYDVQQIDARPc2xvMQ0wCwYDVQQHDARPc2xv
++MRcwFQYDVQQKDA5UaGUgUXQgQ29tcGFueTEMMAoGA1UECwwDUiZEMRIwEAYDVQQD
++DAlIMiBUZXN0ZXIxGzAZBgkqhkiG9w0BCQEWDG1pbmltaUBxdC5pbzAgFw0yMDEw
++MjYxMjAxMzFaGA8yMTIwMTAwMjEyMDEzMVowgYMxCzAJBgNVBAYTAk5PMQ0wCwYD
++VQQIDARPc2xvMQ0wCwYDVQQHDARPc2xvMRcwFQYDVQQKDA5UaGUgUXQgQ29tcGFu
++eTEMMAoGA1UECwwDUiZEMRIwEAYDVQQDDAlIMiBUZXN0ZXIxGzAZBgkqhkiG9w0B
++CQEWDG1pbmltaUBxdC5pbzCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIB
++AOiUp5+E4blouKH7q+rVNR8NoYX2XkBW+q+rpy1zu5ssRSzbqxAjDx9dkht7Qlnf
++VlDT00JvpOWdeuPon5915edQRsY4Unl6mKH29ra3OtUa1/yCJXsGVJTKCj7k4Bxb
++5mZzb/fTlZntMLdTIBMfUbw62FKir1WjKIcJ9fCoG8JaGeKVO4Rh5p0ezd4UUUId
++r1BXl5Nqdqy2vTMsEDnjOsD3egkv8I2SKN4O6n/C3wWYpMOWYZkGoZiKz7rJs/i/
++ez7bsV7JlwdzTlhpJzkcOSVFBP6JlEOxTNNxZ1wtKy7PtZGmsSSATq2e6+bw38Ae
++Op0XnzzqcGjtDDofBmT7OFzZWjS9VZS6+DOOe2QHWle1nCHcHyH4ku6IRlsr9xkR
++NAIlOfnvHHxqJUenoeaZ4oQDjCBKS1KXygJO/tL7BLTQVn/xK1EmPvKNnjzWk4tR
++PnibUhhs5635qpOU/YPqFBh1JjVruZbsWcDAhRcew0uxONXOa9E+4lttQ9ySYa1A
++LvWqJuAX7gu2BsBMLyqfm811YnA7CIFMyO+HlqmkLFfv5L/xIRAXR7l26YGO0VwX
++CGjMfz4NVPMMke4nB7qa9NkpXQBQKMms3Qzd5JW0Hy9Ruj5O8GPcFZmV0twjd1uJ
++PD/cAjkWLaXjdNsJ16QWc2nghQRS6HYqKRX6j+CXOxupAgMBAAGjUzBRMB0GA1Ud
++DgQWBBRSCOU58j9NJZkMamt623qyCrhN3TAfBgNVHSMEGDAWgBRSCOU58j9NJZkM
++amt623qyCrhN3TAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4ICAQCq
++q4jxsWeNDv5Nq14hJtF9HB+ZL64zcZtRjJP1YgNs0QppKICmjPOL2nIMGmI/jKrs
++0eGAL/9XXNVHPxm1OPOncvimMMmU6emZfpMdEtTfKP43+Pg9HgKRjLoQp406vGeQ
++8ki/mbBhrItVPgEm3tu2AFA02XTYi+YxCI9kRZLGkM3FbgtOuTLPl0Z9y+kiPc9F
++uCSC03anBEqv+vDSI8+wODymQ/IJ3Jyz1lxIRDfp4qAekmy0jU2c91VOHHEmOmqq
++kqygGFRdwbe99m9yP63r6q0b5K3X2UnJ6bns0hmTwThYwpVPXLU8jdaTddbMukN2
++/Ef96Tsw8nWOEOPMySHOTIPgwyZRp26b0kA9EmhLwOP401SxXVQCmSRmtwNagmtg
++jJKmZoYBN+//D45ibK8z6Q0oOm9P+Whf/uUXehcRxBxyV3xz7k0wKGQbHj/ddwcy
++IUoIN4lrAlib+lK170kTKN352PDmrpo2gmIzPEsfurKAIMSelDl6H+kih16BtZ8y
++Nz6fh9Soqrg3OSAware8pxV7k51crBMoPLN78KoRV8MFCK4K7Fddq4rRISq6hiXq
++r1nsjoEPuKM9huprmZVZe9t5YcDa2I+wb3IiE3uwpZbAdaLDyQ5n6F/qpsiIkZXn
++gtcF7oqpG5oYrwCcZ53y/ezUgUg7PlSz2XwAGvQtgg==
+ -----END CERTIFICATE-----
+diff --git a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
+index 9d1664d609..337ce541a6 100644
+--- a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
++++ b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
+@@ -1,15 +1,52 @@
+------BEGIN RSA PRIVATE KEY-----
+-MIICXAIBAAKBgQCnyKBKxBkFG2a6MuLS8RxvF4LkOS4BUZDbBDQyESHCDW9Z2FOQ
+-VD+Dj6nTs9XuGpuArsMlyV6lr0tgBaqg0ZEBH8oEg+NYHJkyRYRwclgDmEpji0H1
+-CEnSkQJga+Rk/t2gqnQI6TRMkV8SPTdNVCytf1uYYDYCjDv2RfMnapuUnQIDAQAB
+-AoGANFzLkanTeSGNFM0uttBipFT9F4a00dqHz6JnO7zXAT26I5r8sU1pqQBb6uLz
+-/+Qz5Zwk8RUAQcsMRgJetuPQUb0JZjF6Duv24hNazqXBCu7AZzUenjafwmKC/8ri
+-KpX3fTwqzfzi//FKGgbXQ80yykSSliDL3kn/drATxsLCgQECQQDXhEFWLJ0vVZ1s
+-1Ekf+3NITE+DR16X+LQ4W6vyEHAjTbaNWtcTKdAWLA2l6N4WAAPYSi6awm+zMxx4
+-VomVTsjdAkEAx0z+e7natLeFcrrq8pbU+wa6SAP1VfhQWKitxL1e7u/QO90NCpxE
+-oQYKzMkmmpOOFjQwEMAy1dvFMbm4LHlewQJAC/ksDBaUcQHHqjktCtrUb8rVjAyW
+-A8lscckeB2fEYyG5J6dJVaY4ClNOOs5yMDS2Afk1F6H/xKvtQ/5CzInA/QJATDub
+-K+BPU8jO9q+gpuIi3VIZdupssVGmCgObVCHLakG4uO04y9IyPhV9lA9tALtoIf4c
+-VIvv5fWGXBrZ48kZAQJBAJmVCdzQxd9LZI5vxijUCj5EI4e+x5DRqVUvyP8KCZrC
+-AiNyoDP85T+hBZaSXK3aYGpVwelyj3bvo1GrTNwNWLw=
+------END RSA PRIVATE KEY-----
++-----BEGIN PRIVATE KEY-----
++MIIJQgIBADANBgkqhkiG9w0BAQEFAASCCSwwggkoAgEAAoICAQDolKefhOG5aLih
+++6vq1TUfDaGF9l5AVvqvq6ctc7ubLEUs26sQIw8fXZIbe0JZ31ZQ09NCb6TlnXrj
++6J+fdeXnUEbGOFJ5epih9va2tzrVGtf8giV7BlSUygo+5OAcW+Zmc2/305WZ7TC3
++UyATH1G8OthSoq9VoyiHCfXwqBvCWhnilTuEYeadHs3eFFFCHa9QV5eTanastr0z
++LBA54zrA93oJL/CNkijeDup/wt8FmKTDlmGZBqGYis+6ybP4v3s+27FeyZcHc05Y
++aSc5HDklRQT+iZRDsUzTcWdcLSsuz7WRprEkgE6tnuvm8N/AHjqdF5886nBo7Qw6
++HwZk+zhc2Vo0vVWUuvgzjntkB1pXtZwh3B8h+JLuiEZbK/cZETQCJTn57xx8aiVH
++p6HmmeKEA4wgSktSl8oCTv7S+wS00FZ/8StRJj7yjZ481pOLUT54m1IYbOet+aqT
++lP2D6hQYdSY1a7mW7FnAwIUXHsNLsTjVzmvRPuJbbUPckmGtQC71qibgF+4LtgbA
++TC8qn5vNdWJwOwiBTMjvh5appCxX7+S/8SEQF0e5dumBjtFcFwhozH8+DVTzDJHu
++Jwe6mvTZKV0AUCjJrN0M3eSVtB8vUbo+TvBj3BWZldLcI3dbiTw/3AI5Fi2l43Tb
++CdekFnNp4IUEUuh2KikV+o/glzsbqQIDAQABAoICAFw1q6tr5I48vY7DF+rXsuLn
++5ZUWE1IQ6fzB4lr72nJv/9EEGnMgYzt9PpMUsD6vdCpBgS2C0+6RHArFzJtNA+RM
++iHLIG7K7702veyr/xBx/MwiSlMeMv/XpkFxVI6E6skMGG2s3AMXxKvJTy5CpRx+I
++eQFyLG+Ya1X2lgJes/q+/CpAHkOjCOpcLySQC5NZ74q734V7nSdmn+Zs3tYEh+O/
++eiuwTP/j5b38Te5vVTqDxTciJPmljmXLCwa0N100lWlbcpvw8qbqiTI2Jm3XCbUE
++AzHjW9vmrF3cRS1fXxKFGShw3SRqlkbxjfeWoi8qDPUBS4m8LOr8qG9Wo5Nfon0z
++zLP4bci3zHDvVcaaZrrsUBs/yZbg+Dgka1DmX7ekmeccr2yTdKDFgPupYUyxVbTl
++a9ZLJysjFD7rgBv1ZclHonLp6Vbm+ZoTqvteo4ikAy6L9RtBWJ23XEK34PkP/+c5
++2vWZaOrnjSeBHbFce8cdJSxqWpP+eSCI5I9XbDrYFIsQ/gqKgtzDKy2ihJ2Y8STL
++yO4hyFPFjxc+Gg4/P2PpmT5CY2ty44M0BWs+JGW96CJPrrplf2lmQUQJj5LZY66X
++Z/4C9L7ZYtKZ+bs5SvU46yWugAvQZX22Xm9xLXWyVXRdx3bj+3M3fDnF9di/zdbh
++CgLx7oWPNrXc7FCajnn9AoIBAQD5FMYwRpw9NWT9WDxQwx+cSI4Icbd88ByTW63S
++LzeRwZA0J9/SfwO+aBRupzc9GkGXCiZcGMw3AGsCtig8yFlw8E5KnzN7KlftDMnM
++9NUxxzlR8VwKyLnZfG7sDTl057ZlUujnqhmt/F8F7dIy7FVO1dE/8nngA+FYTCOG
++UZdGjwyBDlDM0JJdUWGY3xslutcpCDN5mzSTKjy9drMvImAshRawxRF6WBpn7vr2
++nC6vciqfx1Mzx1vyk0Jm0ilaydDdLMADjt/iL4Nkr0BEs4k+UzQiKDwp8gu7abQ1
++eBfxd9Iar4htQa2I1Ewl6P01G/q+ZYwgHhJ9RVn4AxQXefILAoIBAQDvCouORdQX
++C8wsyp7MwXlF/3NQeNN5/+B2mhbxrBOf7PmMCXLnkRWcjwJtzypWFqJ0sqai/2+0
++bqbMcjX5maT8stT2shl3zXe/Ejt2e3TBYpc1tyuses8Kb5BMU8hu6tTd3G2CMXpD
++dT6DVemJZCTtwj9aBNIxSizvlgMolJnCpzhPnlfHSI6E+g3m/LTTo3HwbjMSw/Uq
++irgjOpI2wSBB6LZPSgjvfcYPRyWUk16L4A5uSX0cADnovDFLa5/h0wJvN/OoCSQg
++rLCXG5E18EyL5Wc58BCY1ZvxmjG3lQtgPxYu2Jwc36R/y/JKlxW5suER5ZNpbbD4
++uOyTt2VxMQ2bAoIBAQC5+MzRFqdo/AjfL5Y5JrbfVTzXCTDa09xCGd16ZU60QTWN
+++4ed/r+o1sUKqUcRFB2MzEM/2DQBjQpZB/CbEWvWa1XJWXxypXbowveZU+QqOnmN
++uQvj8WLyA3o+PNF9e9QvauwCrHpn8VpxbtPWuaYoKnUFreFZZQxHhPGxRBIS2JOZ
++eDrT8ZaWnkCkh1AZp5smQ71LOprSlmKrg4jd1GjCVMxQR5N5KXbtyv0OTCZ/UFqK
++2aRBsMPyJgkaBChkZPLRcKwc+/wlQRx1fHQb14DNTApMxoXFO7eOwqmOkpAt9iyl
++SBIwoS0UUI5ab88+bBmXNvKcuFdNuQ4nowTJUn9pAoIBADMNkILBXSvS5DeIyuO2
++Sp1tkoZUV+5NfPY3sMDK3KIibaW/+t+EOBZo4L7tKQCb8vRzl21mmsfxfgRaPDbj
++3r3tv9g0b4YLxxBy52pFscj/soXRai17SS7UZwA2QK+XzgDYbDcLNC6mIsTQG4Gx
++dsWk3/zs3KuUSQaehmwrWK+fIUK38c1pLK8v7LoxrLkqxlHwZ04RthHw8KTthH7X
++Pnl1J0LF8CSeOyfWLSuPUfkT0GEzptnNHpEbaHfQM6R6eaGhVJPF6AZme4y6YYgg
++m2ihhSt1n0XVEWpHYWjxFy3mK2mz75unFC4LM+NEY2p2zuUQoCw7NjnY3QYrfCnx
++rRMCggEAXeXsMSLFjjyuoL7iKbAxo52HD/P0fBoy58LyRcwfNVr0lvYan4pYEx+o
++KijIh9K16PqXZXKMA9v003B+ulmF8bJ7SddCZ5NGvnFhUTDe4DdTKgp2RuwQ3Bsc
++3skPIDbhVETyOLCtys34USHrq8U/0DlGY3eLRfxw9GnbKxSBGa/KEu/qQLPNUo50
++7xHZDg7GKeC3kqNJeqKM9rkp0VzIGkEnaD9127LeNDmERDfftxJzFoC/THvUBLfU
++6Sus2ZYwRE8VFvKC30Q45t/c54X3IuhYvAuiCuTmyfE4ruyzyOwKzhUkeeLq1APX
++g0veFbyfzlJ0q8qzD/iffqqIa2ZSmQ==
++-----END PRIVATE KEY-----
+diff --git a/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp b/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
+index 7ba3715e13..752aa122f6 100644
+--- a/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
++++ b/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
+@@ -179,6 +179,7 @@ void tst_QAccessibilityLinux::initTestCase()
+     QVERIFY(!address.isEmpty());
+ 
+     m_window = new AccessibleTestWindow();
++    m_window->setObjectName("mainWindow"_L1);
+     m_window->show();
+ 
+     QVERIFY(QTest::qWaitForWindowExposed(m_window));
+@@ -236,8 +237,11 @@ bool hasState(QDBusInterface *interface, AtspiStateType state)
+ void tst_QAccessibilityLinux::testLabel()
+ {
+     QLabel *l = new QLabel(m_window);
++    l->setObjectName("theObjectName"_L1);
+     l->setText("Hello A11y");
+     m_window->addWidget(l);
++    auto a11yEmpty = new QLabel(m_window);
++    m_window->addWidget(l);
+ 
+     // Application
+     QCOMPARE(getParent(mainWindow), QLatin1String(ATSPI_DBUS_PATH_ROOT));
+@@ -249,6 +253,8 @@ void tst_QAccessibilityLinux::testLabel()
+     QCOMPARE(getChildren(labelInterface).count(), 0);
+     QCOMPARE(labelInterface->call(QDBus::Block, "GetRoleName").arguments().first().toString(), QLatin1String("label"));
+     QCOMPARE(labelInterface->call(QDBus::Block, "GetRole").arguments().first().toUInt(), 29u);
++    QCOMPARE(labelInterface->call(QDBus::Block, "GetAccessibleId").arguments().first().toString(),
++             QLatin1String("mainWindow.theObjectName"));
+     QCOMPARE(getParent(labelInterface), mainWindow->path());
+     QVERIFY(!hasState(labelInterface, ATSPI_STATE_EDITABLE));
+     QVERIFY(hasState(labelInterface, ATSPI_STATE_READ_ONLY));
+@@ -256,7 +262,12 @@ void tst_QAccessibilityLinux::testLabel()
+     l->setText("New text");
+     QCOMPARE(labelInterface->property("Name").toString(), l->text());
+ 
++    auto *a11yEmptyInterface = getInterface(children.at(1), "org.a11y.atspi.Accessible");
++    QCOMPARE(a11yEmptyInterface->call(QDBus::Block, "GetAccessibleId").arguments().first().toString(),
++             QLatin1String("mainWindow.QLabel"));
++
+     m_window->clearChildren();
++    delete a11yEmptyInterface;
+     delete labelInterface;
+ }
+ 
+diff --git a/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+index 76df61c892..6d6d65b791 100644
+--- a/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
++++ b/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2022 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the test suite of the Qt Toolkit.
+@@ -68,6 +68,8 @@ private slots:
+     void query_exec();
+     void execErrorRecovery_data() { generic_data(); }
+     void execErrorRecovery();
++    void prematureExec_data() { generic_data(); }
++    void prematureExec();
+     void first_data() { generic_data(); }
+     void first();
+     void next_data() { generic_data(); }
+@@ -2770,6 +2772,35 @@ void tst_QSqlQuery::execErrorRecovery()
+     QVERIFY_SQL( q, exec() );
+ }
+ 
++void tst_QSqlQuery::prematureExec()
++{
++    QFETCH(QString, dbName);
++    // We only want the engine name, for addDatabase():
++    int cut = dbName.indexOf(QChar('@'));
++    if (cut < 0)
++        QSKIP("Failed to parse database type out of name");
++    dbName.truncate(cut);
++    cut = dbName.indexOf(QChar('_'));
++    if (cut >= 0)
++        dbName = dbName.mid(cut + 1);
++
++    auto db = QSqlDatabase::addDatabase(dbName);
++    QSqlQuery q(db);
++
++    QTest::ignoreMessage(QtWarningMsg,
++                         "QSqlDatabasePrivate::removeDatabase: connection "
++                         "'qt_sql_default_connection' is still in use, all "
++                         "queries will cease to work.");
++    QTest::ignoreMessage(QtWarningMsg,
++                         "QSqlDatabasePrivate::addDatabase: duplicate connection name "
++                         "'qt_sql_default_connection', old connection removed.");
++    auto otherDb = QSqlDatabase::addDatabase(dbName);
++
++    QTest::ignoreMessage(QtWarningMsg, "QSqlQuery::exec: called before driver has been set up");
++    // QTBUG-100037: shouldn't crash !
++    QVERIFY(!q.exec("select stuff from TheVoid"));
++}
++
+ void tst_QSqlQuery::lastInsertId()
+ {
+     QFETCH( QString, dbName );
+diff --git a/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp b/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
+index 4aa3f8d60b..d2050a61aa 100644
+--- a/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
++++ b/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
+@@ -115,6 +115,10 @@ void tst_QAbstractItemModelTester::standardItemModelZeroColumns()
+     // QTBUG-92886
+     model.insertRows(0, 5);
+     model.removeRows(1, 2);
++
++    const QModelIndex parentIndex = model.index(0, 0);
++    model.insertRows(0, 5, parentIndex);
++    model.removeRows(1, 2, parentIndex);
+ }
+ 
+ void tst_QAbstractItemModelTester::testInsertThroughProxy()
+diff --git a/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json b/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
+index 12a4a22a19..ce518e78fb 100644
+--- a/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
++++ b/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
+@@ -668,50 +668,6 @@
+         "inputFile": "task192552.h",
+         "outputRevision": 67
+     },
+-    {
+-        "classes": [
+-            {
+-                "className": "InlineSlotsWithThrowDeclaration",
+-                "object": true,
+-                "qualifiedClassName": "InlineSlotsWithThrowDeclaration",
+-                "slots": [
+-                    {
+-                        "access": "public",
+-                        "name": "a",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "b",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "c",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "d",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "e",
+-                        "returnType": "void"
+-                    }
+-                ],
+-                "superClasses": [
+-                    {
+-                        "access": "public",
+-                        "name": "QObject"
+-                    }
+-                ]
+-            }
+-        ],
+-        "inputFile": "task189996.h",
+-        "outputRevision": 67
+-    },
+     {
+         "classes": [
+             {
+diff --git a/qtbase/tests/auto/tools/moc/moc.pro b/qtbase/tests/auto/tools/moc/moc.pro
+index c324b3a8cd..4aceb78dc0 100644
+--- a/qtbase/tests/auto/tools/moc/moc.pro
++++ b/qtbase/tests/auto/tools/moc/moc.pro
+@@ -15,7 +15,7 @@ cross_compile: DEFINES += MOC_CROSS_COMPILED
+ HEADERS += using-namespaces.h no-keywords.h task87883.h c-comments.h backslash-newlines.h oldstyle-casts.h \
+            slots-with-void-template.h qinvokable.h namespaced-flags.h trigraphs.h \
+            escapes-in-string-literals.h cstyle-enums.h qprivateslots.h gadgetwithnoenums.h \
+-           dir-in-include-path.h single_function_keyword.h task192552.h task189996.h \
++           dir-in-include-path.h single_function_keyword.h task192552.h \
+            task234909.h task240368.h pure-virtual-signals.h cxx11-enums.h \
+            cxx11-final-classes.h \
+            cxx11-explicit-override-control.h \
+diff --git a/qtbase/tests/auto/tools/moc/task189996.h b/qtbase/tests/auto/tools/moc/task189996.h
+deleted file mode 100644
+index f94a051b3a..0000000000
+--- a/qtbase/tests/auto/tools/moc/task189996.h
++++ /dev/null
+@@ -1,47 +0,0 @@
+-/****************************************************************************
+-**
+-** Copyright (C) 2016 The Qt Company Ltd.
+-** Contact: https://www.qt.io/licensing/
+-**
+-** This file is part of the test suite of the Qt Toolkit.
+-**
+-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+-** 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 General Public License Usage
+-** Alternatively, this file may be used under the terms of the GNU
+-** General Public License version 3 as published by the Free Software
+-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+-** 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-3.0.html.
+-**
+-** $QT_END_LICENSE$
+-**
+-****************************************************************************/
+-// inline functions can have throw declarations
+-
+-#ifndef TASK189996_H
+-#define TASK189996_H
+-
+-#include <QObject>
+-
+-class InlineSlotsWithThrowDeclaration : public QObject
+-{
+-    Q_OBJECT
+-
+-public slots:
+-    void a() throw() { }
+-    void b() const throw() { }
+-    void c() throw();
+-    void d() throw(int) { }
+-    void e() const throw(int,double) { }
+-};
+-
+-#endif
+diff --git a/qtbase/tests/auto/tools/moc/tst_moc.cpp b/qtbase/tests/auto/tools/moc/tst_moc.cpp
+index c716aead21..15dd9e41e5 100644
+--- a/qtbase/tests/auto/tools/moc/tst_moc.cpp
++++ b/qtbase/tests/auto/tools/moc/tst_moc.cpp
+@@ -631,7 +631,6 @@ public:
+ private slots:
+     void initTestCase();
+ 
+-    void slotWithException() throw(MyStruct);
+     void dontStripNamespaces();
+     void oldStyleCasts();
+     void warnOnExtraSignalSlotQualifiaction();
+@@ -673,7 +672,6 @@ private slots:
+     void templateGtGt();
+     void qprivateslots();
+     void qprivateproperties();
+-    void inlineSlotsWithThrowDeclaration();
+     void warnOnPropertyWithoutREAD();
+     void constructors();
+     void typenameWithUnsigned();
+@@ -784,12 +782,6 @@ void tst_Moc::initTestCase()
+ #endif
+ }
+ 
+-void tst_Moc::slotWithException() throw(MyStruct)
+-{
+-    // be happy
+-    QVERIFY(true);
+-}
+-
+ void tst_Moc::dontStripNamespaces()
+ {
+     Sender sender;
+@@ -824,7 +816,7 @@ void tst_Moc::oldStyleCasts()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-Wold-style-cast" << "-I" << "."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -894,7 +886,7 @@ void tst_Moc::inputFileNameWithDotsButNoExtension()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-I" << ".."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -1174,7 +1166,7 @@ void tst_Moc::ignoreOptionClashes()
+     QStringList gccArgs;
+     gccArgs << "-c" << "-x" << "c++" << "-I" << ".."
+          << "-I" << qtIncludePath << "-I" << includeDir << "-o" << "/dev/null"
+-         << "-fPIC" << "-std=c++11" <<  "-";
++         << "-fPIC" << "-std=c++1z" <<  "-";
+     proc.start("gcc", gccArgs);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -1593,21 +1585,6 @@ void tst_Moc::qprivateproperties()
+ 
+ }
+ 
+-#include "task189996.h"
+-
+-void InlineSlotsWithThrowDeclaration::c() throw() {}
+-
+-void tst_Moc::inlineSlotsWithThrowDeclaration()
+-{
+-    InlineSlotsWithThrowDeclaration tst;
+-    const QMetaObject *mobj = tst.metaObject();
+-    QVERIFY(mobj->indexOfSlot("a()") != -1);
+-    QVERIFY(mobj->indexOfSlot("b()") != -1);
+-    QVERIFY(mobj->indexOfSlot("c()") != -1);
+-    QVERIFY(mobj->indexOfSlot("d()") != -1);
+-    QVERIFY(mobj->indexOfSlot("e()") != -1);
+-}
+-
+ void tst_Moc::warnOnPropertyWithoutREAD()
+ {
+ #ifdef MOC_CROSS_COMPILED
+@@ -1869,7 +1846,7 @@ void tst_Moc::notifyError()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-I" << "."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+diff --git a/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+index c355ee9665..88c09de8e0 100644
+--- a/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
++++ b/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+@@ -251,6 +251,7 @@ private slots:
+     void testResetCachedSizeHint();
+     void statusTips();
+     void testRemovingColumnsViaLayoutChanged();
++    void testModelMovingColumns();
+ 
+ protected:
+     void setupTestData(bool use_reset_model = false);
+@@ -360,6 +361,12 @@ public:
+         endRemoveColumns();
+     }
+ 
++    void moveColumn(int from, int to)
++    {
++        beginMoveColumns(QModelIndex(), from, from, QModelIndex(), to);
++        endMoveColumns();
++    }
++
+     void cleanup()
+     {
+         emit layoutAboutToBeChanged();
+@@ -3627,5 +3634,18 @@ void tst_QHeaderView::testRemovingColumnsViaLayoutChanged()
+     // The main point of this test is that the section-size restoring code didn't go out of bounds.
+ }
+ 
++void tst_QHeaderView::testModelMovingColumns()
++{
++    QtTestModel model(10, 10);
++    QHeaderView hv(Qt::Horizontal);
++    hv.setModel(&model);
++    hv.resizeSections(QHeaderView::ResizeToContents);
++    hv.show();
++
++    QPersistentModelIndex index3 = model.index(0, 3);
++    model.moveColumn(3, 1);
++    QCOMPARE(index3.column(), 1);
++}
++
+ QTEST_MAIN(tst_QHeaderView)
+ #include "tst_qheaderview.moc"
+diff --git a/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+index 761357b252..06bb706074 100644
+--- a/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
++++ b/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+@@ -397,6 +397,7 @@ private slots:
+     void checkHeaderMinSize();
+ 
+     void resizeToContents();
++    void resizeToContentsSpans();
+ 
+     void tabFocus();
+     void bigModel();
+@@ -3721,6 +3722,70 @@ void tst_QTableView::resizeToContents()
+ 
+ }
+ 
++
++class SpanModel : public QAbstractTableModel
++{
++public:
++    SpanModel(bool sectionsMoved)
++        : _sectionsMoved(sectionsMoved)
++    {}
++    int columnCount(const QModelIndex & = {}) const override { return 2; }
++    int rowCount(const QModelIndex & = {}) const override { return 1; }
++    QVariant data(const QModelIndex &idx, int role = Qt::DisplayRole) const override
++    {
++        if (role != Qt::DisplayRole)
++            return QVariant();
++        const int col = _sectionsMoved ? 1 - idx.column() : idx.column();
++        if (col == 0)
++            return "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.";
++        return QVariant();
++    }
++private:
++    bool _sectionsMoved;
++};
++
++
++void tst_QTableView::resizeToContentsSpans()
++{
++    SpanModel model1(false);
++    SpanModel model2(true);
++    QTableView view1, view2, view3;
++    view1.setModel(&model1);
++    view2.setModel(&model2);
++    view2.horizontalHeader()->moveSection(0, 1);
++    view3.setModel(&model1);
++
++    view1.setSpan(0, 0, 1, 2);
++    view2.setSpan(0, 1, 1, 2);
++    view1.show();
++    view2.show();
++    view3.show();
++    QVERIFY(QTest::qWaitForWindowExposed(&view1));
++    QVERIFY(QTest::qWaitForWindowExposed(&view2));
++    QVERIFY(QTest::qWaitForWindowExposed(&view3));
++    view1.setColumnWidth(0, 100);
++    view1.setColumnWidth(1, 100);
++    view2.setColumnWidth(0, 100);
++    view2.setColumnWidth(1, 100);
++    view3.setColumnWidth(0, 200);
++
++    view1.resizeRowToContents(0);
++    view2.resizeRowToContents(0);
++    view3.resizeRowToContents(0);
++    QCOMPARE(view1.rowHeight(0), view3.rowHeight(0));
++    QCOMPARE(view2.rowHeight(0), view3.rowHeight(0));
++
++    view3.resizeColumnToContents(0);
++    view3.resizeRowToContents(0);
++    // height should be only 1 text line for easy testing
++    view1.setRowHeight(0, view3.verticalHeader()->sectionSize(0));
++    view2.setRowHeight(0, view3.verticalHeader()->sectionSize(0));
++    view1.resizeColumnToContents(0);
++    view2.resizeColumnToContents(1);
++    QCOMPARE(view1.columnWidth(0), view3.columnWidth(0) - view1.columnWidth(1));
++    QCOMPARE(view2.columnWidth(0), view3.columnWidth(0) - view2.columnWidth(1));
++}
++
+ QT_BEGIN_NAMESPACE
+ extern bool Q_WIDGETS_EXPORT qt_tab_all_widgets(); // qapplication.cpp
+ QT_END_NAMESPACE
+diff --git a/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+index a3b8ef78d8..4955cebd5d 100644
+--- a/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
++++ b/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+@@ -1498,7 +1498,7 @@ void tst_QApplication::desktopSettingsAware()
+     environment += QLatin1String("QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM=1");
+     testProcess.setEnvironment(environment);
+ #endif
+-    testProcess.start("desktopsettingsaware_helper");
++    testProcess.start("./desktopsettingsaware_helper");
+     QVERIFY2(testProcess.waitForStarted(),
+              qPrintable(QString::fromLatin1("Cannot start 'desktopsettingsaware_helper': %1").arg(testProcess.errorString())));
+     QVERIFY(testProcess.waitForFinished(10000));
+@@ -2452,7 +2452,7 @@ void tst_QApplication::qtbug_12673()
+ #if QT_CONFIG(process)
+     QProcess testProcess;
+     QStringList arguments;
+-    testProcess.start("modal_helper", arguments);
++    testProcess.start("./modal_helper", arguments);
+     QVERIFY2(testProcess.waitForStarted(),
+              qPrintable(QString::fromLatin1("Cannot start 'modal_helper': %1").arg(testProcess.errorString())));
+     QVERIFY(testProcess.waitForFinished(20000));
+diff --git a/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp b/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
+index eb108a40de..dca5528c1b 100644
+--- a/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
+@@ -41,6 +41,7 @@
+ 
+ #include <private/qguiapplication_p.h>
+ #include <qpa/qplatformintegration.h>
++#include <qpa/qplatformtheme.h>
+ 
+ class tst_QAbstractButton : public QObject
+ {
+@@ -76,6 +77,8 @@ private slots:
+     void keyNavigation();
+ #endif
+ 
++    void buttonPressKeys();
++
+ protected slots:
+     void onClicked();
+     void onToggled( bool on );
+@@ -269,7 +272,13 @@ void tst_QAbstractButton::setAutoRepeat()
+         QCOMPARE(press_count, click_count);
+         QVERIFY(click_count > 1);
+         break;
+-    case 4:
++    case 4: {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(Qt::Key_Enter)) {
++            QSKIP("platform theme has Key_Enter in ButtonPressKeys");
++        }
+         // check that pressing ENTER has no effect when autorepeat is false
+         testWidget->setDown( false );
+         testWidget->setAutoRepeat( false );
+@@ -286,7 +295,14 @@ void tst_QAbstractButton::setAutoRepeat()
+ 
+         QVERIFY( click_count == 0 );
+         break;
+-    case 5:
++    }
++    case 5: {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(Qt::Key_Enter)) {
++            QSKIP("platform theme has Key_Enter in ButtonPressKeys");
++        }
+         // check that pressing ENTER has no effect when autorepeat is true
+         testWidget->setDown( false );
+         testWidget->setAutoRepeat( true );
+@@ -304,6 +320,7 @@ void tst_QAbstractButton::setAutoRepeat()
+ 
+         QVERIFY( click_count == 0 );
+         break;
++    }
+     case 6:
+         // verify autorepeat is off by default.
+         MyButton tmp( 0);
+@@ -651,5 +668,16 @@ void tst_QAbstractButton::keyNavigation()
+ }
+ #endif
+ 
++void tst_QAbstractButton::buttonPressKeys()
++{
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(testWidget, buttonPressKeys[i]);
++        QCOMPARE(click_count, i + 1);
++    }
++}
++
+ QTEST_MAIN(tst_QAbstractButton)
+ #include "tst_qabstractbutton.moc"
+diff --git a/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+index 32437050f5..46b5af6d63 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+@@ -168,6 +168,7 @@ private slots:
+     void checkMenuItemPosWhenStyleSheetIsSet();
+     void checkEmbeddedLineEditWhenStyleSheetIsSet();
+     void propagateStyleChanges();
++    void buttonPressKeys();
+ 
+ private:
+     PlatformInputContext m_platformInputContext;
+@@ -1682,6 +1683,16 @@ void tst_QComboBox::setModel()
+     QCOMPARE(box.rootModelIndex(), rootModelIndex);
+     box.setModel(box.model());
+     QCOMPARE(box.rootModelIndex(), rootModelIndex);
++
++    // check that setting the same model as the completer's doesn't crash
++    QCompleter *completer = new QCompleter(&box);
++    box.setEditable(true);
++    box.setCompleter(completer);
++    auto *listModel = new QStringListModel({ "one", "two" }, completer);
++    completer->setModel(listModel);
++    QCOMPARE(listModel->rowCount(), 2); // make sure it wasn't deleted
++    box.setModel(listModel);
++    QCOMPARE(listModel->rowCount(), 2); // make sure it wasn't deleted
+ }
+ 
+ void tst_QComboBox::setCustomModelAndView()
+@@ -3632,5 +3643,24 @@ void tst_QComboBox::propagateStyleChanges()
+     QVERIFY(frameStyle.inquired);
+ }
+ 
++void tst_QComboBox::buttonPressKeys()
++{
++    QComboBox comboBox;
++    comboBox.setEditable(false);
++    comboBox.addItem(QString::number(1));
++    comboBox.addItem(QString::number(2));
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(&comboBox, buttonPressKeys[i]);
++        // On some platforms, a window will not be immediately visible,
++        // but take some event-loop iterations to complete.
++        // Using QTRY_VERIFY to deal with that.
++        QTRY_VERIFY(comboBox.view()->isVisible());
++        comboBox.hidePopup();
++    }
++}
++
+ QTEST_MAIN(tst_QComboBox)
+ #include "tst_qcombobox.moc"
+diff --git a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
+index be3cfcd104..c228fdfcca 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
++++ b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qcommandlinkbutton
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qcommandlinkbutton.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
+index 0044d33c66..4cf06296e4 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
+@@ -40,6 +40,9 @@
+ #include <QGridLayout>
+ #include <QPainter>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ class tst_QCommandLinkButton : public QObject
+ {
+     Q_OBJECT
+@@ -223,6 +226,13 @@ void tst_QCommandLinkButton::setAutoRepeat()
+     // check that pressing ENTER has no effect
+     resetCounters();
+     testWidget->setDown( false );
++    // Skip after reset if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
+     testWidget->setAutoRepeat( false );
+     QTest::keyPress( testWidget, Qt::Key_Enter );
+ 
+@@ -255,6 +265,14 @@ void tst_QCommandLinkButton::pressed()
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+ 
++    // Skip if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
++
+     QTest::keyPress( testWidget,Qt::Key_Enter );
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+diff --git a/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro b/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
+index 4a5e76ff65..a235fa1fac 100644
+--- a/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
++++ b/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qgroupbox
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qgroupbox.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp b/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
+index 4fb5d262ca..d8d7562b73 100644
+--- a/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
+@@ -35,6 +35,9 @@
+ #include <QRadioButton>
+ #include <QDialog>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ #include "qgroupbox.h"
+ 
+ class tst_QGroupBox : public QObject
+@@ -69,6 +72,7 @@ private slots:
+     void propagateFocus();
+     void task_QTBUG_19170_ignoreMouseReleaseEvent();
+     void task_QTBUG_15519_propagateMouseEvents();
++    void buttonPressKeys();
+ 
+ private:
+     bool checked;
+@@ -610,6 +614,20 @@ void tst_QGroupBox::task_QTBUG_15519_propagateMouseEvents()
+     QCOMPARE(parent.mouseMoved, true);
+ }
+ 
++void tst_QGroupBox::buttonPressKeys()
++{
++    QGroupBox groupBox;
++    groupBox.setCheckable(true);
++    QSignalSpy clickedSpy(&groupBox, &QGroupBox::clicked);
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(&groupBox, buttonPressKeys[i]);
++        QCOMPARE(clickedSpy.length(), i + 1);
++    }
++}
++
+ void tst_QGroupBox::sendMouseMoveEvent(QWidget *widget, const QPoint &localPos)
+ {
+     // Send a MouseMove event without actually moving the pointer
+diff --git a/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro b/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
+index 353ad06ca2..e55f6148f2 100644
+--- a/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
++++ b/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qpushbutton
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qpushbutton.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp b/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
+index e818514a79..4043e9326a 100644
+--- a/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
+@@ -41,6 +41,9 @@
+ #include <QStyleFactory>
+ #include <QTabWidget>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ class tst_QPushButton : public QObject
+ {
+ Q_OBJECT
+@@ -212,6 +215,13 @@ void tst_QPushButton::autoRepeat()
+     // check that pressing ENTER has no effect
+     resetCounters();
+     testWidget->setDown( false );
++    // Skip after reset if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
+     testWidget->setAutoRepeat( false );
+     QTest::keyPress( testWidget, Qt::Key_Enter );
+ 
+@@ -247,6 +257,14 @@ void tst_QPushButton::pressed()
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+ 
++    // Skip if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
++
+     QTest::keyPress( testWidget,Qt::Key_Enter );
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+diff --git a/qtbase/tests/manual/rhi/cubemap_render/buildshader.bat b/qtbase/tests/manual/rhi/cubemap_render/buildshader.bat
+old mode 100755
+new mode 100644
+Submodule qtconnectivity e957d481..056294c0:
+diff --git a/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp b/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
+index e2635fae..a8b8e3b9 100644
+--- a/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
++++ b/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
+@@ -563,9 +563,11 @@ void HciManager::handleHciAclPacket(const quint8 *data, int size)
+ 
+ void HciManager::handleLeMetaEvent(const quint8 *data)
+ {
+-    // Spec v4.2, Vol 2, part E, 7.7.65ff
++    // Spec v5.3, Vol 4, part E, 7.7.65.*
+     switch (*data) {
+-    case 0x1: {
++    case 0x1: // HCI_LE_Connection_Complete
++    case 0xA: // HCI_LE_Enhanced_Connection_Complete
++    {
+         const quint16 handle = bt_get_le16(data + 2);
+         emit connectionComplete(handle);
+         break;
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp b/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
+index 6a93143b..4a18cfc7 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
+@@ -320,7 +320,10 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_finishSdpScan(QBluetoothServiceD
+             for (const QBluetoothUuid &id : serviceClassUuids) {
+                 if (id.minimumSize() == 16) {
+                     serviceInfo.setServiceUuid(id);
+-                    serviceInfo.setServiceName(QBluetoothServiceDiscoveryAgent::tr("Custom Service"));
++                    if (serviceInfo.serviceName().isEmpty()) {
++                        serviceInfo.setServiceName(
++                                    QBluetoothServiceDiscoveryAgent::tr("Custom Service"));
++                    }
+                     QBluetoothServiceInfo::Sequence modSeq =
+                             serviceInfo.attribute(QBluetoothServiceInfo::ServiceClassIds).value<QBluetoothServiceInfo::Sequence>();
+                     modSeq.removeOne(QVariant::fromValue(id));
+@@ -334,8 +337,10 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_finishSdpScan(QBluetoothServiceD
+                 qCDebug(QT_BT_BLUEZ) << "Discovered services" << discoveredDevices.at(0).address().toString()
+                                      << serviceInfo.serviceName() << serviceInfo.serviceUuid()
+                                      << ">>>" << serviceInfo.serviceClassUuids();
+-
+-                emit q->serviceDiscovered(serviceInfo);
++                // Use queued connection to allow us finish the service looping; the application
++                // might call stop() when it has detected the service-of-interest.
++                QMetaObject::invokeMethod(q, "serviceDiscovered", Qt::QueuedConnection,
++                                          Q_ARG(QBluetoothServiceInfo, serviceInfo));
+             }
+         }
+     }
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp b/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
+index e4d85447..aadd4755 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
+@@ -593,7 +593,7 @@ void QBluetoothSocket::setSocketState(QBluetoothSocket::SocketState state)
+ bool QBluetoothSocket::canReadLine() const
+ {
+     Q_D(const QBluetoothSocketBase);
+-    return d->canReadLine();
++    return d->canReadLine() || QIODevice::canReadLine();
+ }
+ 
+ /*!
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp b/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
+index 084aa958..d6aa17a7 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
+@@ -284,6 +284,10 @@ void QBluetoothSocketPrivateBluezDBus::connectToService(
+         return;
+     }
+ 
++    if (service.socketProtocol() != QBluetoothServiceInfo::Protocol::UnknownProtocol)
++        socketType = service.socketProtocol();
++    qCDebug(QT_BT_BLUEZ) << "Socket protocol used:" << socketType;
++
+     connectToService(service.device().address(), targetService, openMode);
+ }
+ 
+diff --git a/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp b/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
+index 05bc1a0f..a7b5ef1f 100644
+--- a/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
++++ b/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
+@@ -142,7 +142,7 @@ void tst_QBluetoothSocket::initTestCase()
+     qDebug() << "Starting discovery";
+ 
+     sda->setUuidFilter(QBluetoothUuid(QString(TEST_SERVICE_UUID)));
+-    sda->start(QBluetoothServiceDiscoveryAgent::MinimalDiscovery);
++    sda->start(QBluetoothServiceDiscoveryAgent::FullDiscovery);
+ 
+     for (int connectTime = MaxConnectTime; !done_discovery && connectTime > 0; connectTime -= 1000)
+         QTest::qWait(1000);
+Submodule qtdeclarative f5701f0d..8defe7bf:
+diff --git a/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h b/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
+index b65b994d6c..15a8cd6878 100644
+--- a/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
++++ b/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
+@@ -86,7 +86,7 @@ public:
+         if (QTypeInfo<T>::isComplex) {
+             for (int i = 0; i < count; ++i)
+                 new (data + i) T(vector.at(i));
+-        } else {
++        } else if (count) {
+             memcpy(data, static_cast<const void*>(vector.constData()), count * sizeof(T));
+         }
+     }
+diff --git a/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp b/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
+index e57cdd8278..94613598af 100644
+--- a/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
++++ b/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
+@@ -1145,8 +1145,7 @@ void Heap::QObjectWrapper::markObjects(Heap::Base *that, QV4::MarkStack *markSta
+ void QObjectWrapper::destroyObject(bool lastCall)
+ {
+     Heap::QObjectWrapper *h = d();
+-    if (!h->internalClass)
+-        return; // destroyObject already got called
++    Q_ASSERT(h->internalClass);
+ 
+     if (h->object()) {
+         QQmlData *ddata = QQmlData::get(h->object(), false);
+@@ -1176,7 +1175,7 @@ void QObjectWrapper::destroyObject(bool lastCall)
+         }
+     }
+ 
+-    h->~Data();
++    h->destroy();
+ }
+ 
+ 
+diff --git a/qtdeclarative/src/qml/memory/qv4mm.cpp b/qtdeclarative/src/qml/memory/qv4mm.cpp
+index 06caf04e5a..da149a67c4 100644
+--- a/qtdeclarative/src/qml/memory/qv4mm.cpp
++++ b/qtdeclarative/src/qml/memory/qv4mm.cpp
+@@ -981,7 +981,7 @@ void MemoryManager::sweep(bool lastSweep, ClassDestroyStatsCallback classCountPt
+ 
+     if (MultiplyWrappedQObjectMap *multiplyWrappedQObjects = engine->m_multiplyWrappedQObjects) {
+         for (MultiplyWrappedQObjectMap::Iterator it = multiplyWrappedQObjects->begin(); it != multiplyWrappedQObjects->end();) {
+-            if (!it.value().isNullOrUndefined())
++            if (it.value().isNullOrUndefined())
+                 it = multiplyWrappedQObjects->erase(it);
+             else
+                 ++it;
+diff --git a/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp b/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
+index 2079a8ed04..a577cb2351 100644
+--- a/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
++++ b/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
+@@ -389,6 +389,12 @@ void QQmlDelegateModelPrivate::connectToAbstractItemModel()
+                       q,  QQmlDelegateModel, SLOT(_q_rowsRemoved(QModelIndex,int,int)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
+                       q,  QQmlDelegateModel, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsInserted(QModelIndex,int,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsInserted(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsRemoved(QModelIndex,int,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsRemoved(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsMoved(QModelIndex,int,int,QModelIndex,int)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
+                       q, QQmlDelegateModel, SLOT(_q_dataChanged(QModelIndex,QModelIndex,QVector<int>)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
+@@ -413,6 +419,12 @@ void QQmlDelegateModelPrivate::disconnectFromAbstractItemModel()
+                         q, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int)));
+     QObject::disconnect(aim, SIGNAL(rowsRemoved(QModelIndex,int,int)),
+                         q, SLOT(_q_rowsRemoved(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsInserted(QModelIndex,int,int)), q,
++                        SLOT(_q_columnsInserted(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsRemoved(QModelIndex,int,int)), q,
++                        SLOT(_q_columnsRemoved(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)), q,
++                        SLOT(_q_columnsMoved(QModelIndex,int,int,QModelIndex,int)));
+     QObject::disconnect(aim, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
+                         q, SLOT(_q_dataChanged(QModelIndex,QModelIndex,QVector<int>)));
+     QObject::disconnect(aim, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
+@@ -1973,6 +1985,38 @@ void QQmlDelegateModel::_q_rowsMoved(
+     }
+ }
+ 
++void QQmlDelegateModel::_q_columnsInserted(const QModelIndex &parent, int begin, int end)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if (parent == d->m_adaptorModel.rootIndex && begin == 0) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
++void QQmlDelegateModel::_q_columnsRemoved(const QModelIndex &parent, int begin, int end)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if (parent == d->m_adaptorModel.rootIndex && begin == 0) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
++void QQmlDelegateModel::_q_columnsMoved(const QModelIndex &parent, int start, int end,
++                                        const QModelIndex &destination, int column)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if ((parent == d->m_adaptorModel.rootIndex && start == 0)
++        || (destination == d->m_adaptorModel.rootIndex && column == 0)) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
+ void QQmlDelegateModel::_q_dataChanged(const QModelIndex &begin, const QModelIndex &end, const QVector<int> &roles)
+ {
+     Q_D(QQmlDelegateModel);
+diff --git a/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h b/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
+index 8aab4badca..d140bfbaaf 100644
+--- a/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
++++ b/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
+@@ -152,6 +152,9 @@ private Q_SLOTS:
+     void _q_itemsMoved(int from, int to, int count);
+     void _q_modelReset();
+     void _q_rowsInserted(const QModelIndex &,int,int);
++    void _q_columnsInserted(const QModelIndex &, int, int);
++    void _q_columnsRemoved(const QModelIndex &, int, int);
++    void _q_columnsMoved(const QModelIndex &, int, int, const QModelIndex &, int);
+     void _q_rowsAboutToBeRemoved(const QModelIndex &parent, int begin, int end);
+     void _q_rowsRemoved(const QModelIndex &,int,int);
+     void _q_rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int);
+diff --git a/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp b/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
+index 85719fdc80..78e2ab302c 100644
+--- a/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
++++ b/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
+@@ -46,6 +46,7 @@
+ #include "QtQuick/private/qquicktextinput_p.h"
+ #include "QtQuick/private/qquickaccessibleattached_p.h"
+ #include "QtQuick/qquicktextdocument.h"
++#include "QtQuick/qquickrendercontrol.h"
+ QT_BEGIN_NAMESPACE
+ 
+ #if QT_CONFIG(accessibility)
+@@ -57,7 +58,19 @@ QAccessibleQuickItem::QAccessibleQuickItem(QQuickItem *item)
+ 
+ QWindow *QAccessibleQuickItem::window() const
+ {
+-    return item()->window();
++    QQuickWindow *window = item()->window();
++
++    // For QQuickWidget the above window will be the offscreen QQuickWindow,
++    // which is not a part of the accessibility tree. Detect this case and
++    // return the window for the QQuickWidget instead.
++    if (window && !window->handle()) {
++        if (QQuickRenderControl *renderControl = QQuickWindowPrivate::get(window)->renderControl) {
++            if (QWindow *renderWindow = renderControl->renderWindow(nullptr))
++                return renderWindow;
++        }
++    }
++
++    return window;
+ }
+ 
+ int QAccessibleQuickItem::childCount() const
+@@ -113,19 +126,15 @@ QAccessibleInterface *QAccessibleQuickItem::childAt(int x, int y) const
+ QAccessibleInterface *QAccessibleQuickItem::parent() const
+ {
+     QQuickItem *parent = item()->parentItem();
+-    QQuickWindow *window = item()->window();
+-    QQuickItem *ci = window ? window->contentItem() : nullptr;
++    QQuickWindow *itemWindow = item()->window();
++    QQuickItem *ci = itemWindow ? itemWindow->contentItem() : nullptr;
+     while (parent && !QQuickItemPrivate::get(parent)->isAccessible && parent != ci)
+         parent = parent->parentItem();
+ 
+     if (parent) {
+         if (parent == ci) {
+-            // Jump out to the scene widget if the parent is the root item.
+-            // There are two root items, QQuickWindow::rootItem and
+-            // QQuickView::declarativeRoot. The former is the true root item,
+-            // but is not a part of the accessibility tree. Check if we hit
+-            // it here and return an interface for the scene instead.
+-            return QAccessible::queryAccessibleInterface(window);
++            // Jump out to the window if the parent is the root item
++            return QAccessible::queryAccessibleInterface(window());
+         } else {
+             while (parent && !parent->d_func()->isAccessible)
+                 parent = parent->parentItem();
+@@ -188,7 +197,7 @@ QAccessible::State QAccessibleQuickItem::state() const
+     QRect viewRect_ = viewRect();
+     QRect itemRect = rect();
+ 
+-    if (viewRect_.isNull() || itemRect.isNull() || !item()->window() || !item()->window()->isVisible() ||!item()->isVisible() || qFuzzyIsNull(item()->opacity()))
++    if (viewRect_.isNull() || itemRect.isNull() || !window() || !window()->isVisible() ||!item()->isVisible() || qFuzzyIsNull(item()->opacity()))
+         state.invisible = true;
+     if (!viewRect_.intersects(itemRect))
+         state.offscreen = true;
+@@ -201,6 +210,10 @@ QAccessible::State QAccessibleQuickItem::state() const
+     if (role() == QAccessible::EditableText)
+         if (auto ti = qobject_cast<QQuickTextInput *>(item()))
+             state.passwordEdit = ti->echoMode() != QQuickTextInput::Normal;
++    if (!item()->isEnabled()) {
++        state.focusable = false;
++        state.disabled = true;
++    }
+     return state;
+ }
+ 
+diff --git a/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h b/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
+index 39ffcaf39c..8baa01330c 100644
+--- a/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
++++ b/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
+@@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE
+ 
+ #if QT_CONFIG(accessibility)
+ 
+-class QAccessibleQuickWindow : public QAccessibleObject
++class Q_QUICK_EXPORT QAccessibleQuickWindow : public QAccessibleObject
+ {
+ public:
+     QAccessibleQuickWindow(QQuickWindow *object);
+diff --git a/qtdeclarative/src/quick/items/qquickdrag.cpp b/qtdeclarative/src/quick/items/qquickdrag.cpp
+index 8321fcfeed..383078b3b9 100644
+--- a/qtdeclarative/src/quick/items/qquickdrag.cpp
++++ b/qtdeclarative/src/quick/items/qquickdrag.cpp
+@@ -481,7 +481,9 @@ void QQuickDragAttached::setKeys(const QStringList &keys)
+     \qmlattachedproperty stringlist QtQuick::Drag::mimeData
+     \since 5.2
+ 
+-    This property holds a map of mimeData that is used during startDrag.
++    This property holds a map from mime type to data that is used during startDrag.
++    The mime data needs to be a \c string, or an \c ArrayBuffer with the data encoded
++    according to the mime type.
+ */
+ 
+ QVariantMap QQuickDragAttached::mimeData() const
+@@ -766,8 +768,12 @@ Qt::DropAction QQuickDragAttachedPrivate::startDrag(Qt::DropActions supportedAct
+     QDrag *drag = new QDrag(source ? source : q);
+     QMimeData *mimeData = new QMimeData();
+ 
+-    for (auto it = externalMimeData.cbegin(), end = externalMimeData.cend(); it != end; ++it)
+-        mimeData->setData(it.key(), it.value().toString().toUtf8());
++    for (auto it = externalMimeData.cbegin(), end = externalMimeData.cend(); it != end; ++it) {
++        if (static_cast<QMetaType::Type>(it.value().type()) == QMetaType::QByteArray)
++            mimeData->setData(it.key(), it.value().toByteArray());
++        else
++            mimeData->setData(it.key(), it.value().toString().toUtf8());
++    }
+ 
+     drag->setMimeData(mimeData);
+     if (pixmapLoader.isReady()) {
+diff --git a/qtdeclarative/src/quick/items/qquickitem.cpp b/qtdeclarative/src/quick/items/qquickitem.cpp
+index 75f1457816..dec0ae19ae 100644
+--- a/qtdeclarative/src/quick/items/qquickitem.cpp
++++ b/qtdeclarative/src/quick/items/qquickitem.cpp
+@@ -59,6 +59,7 @@
+ #include <QtCore/private/qnumeric_p.h>
+ #include <QtGui/qpa/qplatformtheme.h>
+ #include <QtCore/qloggingcategory.h>
++#include <QtCore/private/qduplicatetracker_p.h>
+ 
+ #include <private/qqmlglobal_p.h>
+ #include <private/qqmlengine_p.h>
+@@ -2326,6 +2327,7 @@ QQuickItem::QQuickItem(QQuickItemPrivate &dd, QQuickItem *parent)
+ QQuickItem::~QQuickItem()
+ {
+     Q_D(QQuickItem);
++    d->inDestructor = true;
+ 
+     if (d->windowRefCount > 1)
+         d->windowRefCount = 1; // Make sure window is set to null in next call to derefWindow().
+@@ -2526,6 +2528,7 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo
+     QQuickItem *current = item;
+     qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: startItem:" << startItem;
+     qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: firstFromItem:" << firstFromItem;
++    QDuplicateTracker<QQuickItem *> cycleDetector;
+     do {
+         qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: current:" << current;
+         qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: from:" << from;
+@@ -2592,7 +2595,10 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo
+         // traversed all of the chain (by compare the [current] item with [startItem])
+         // Since the [startItem] might be promoted to its parent if it is invisible,
+         // we still have to check [current] item with original start item
+-        if ((current == startItem || current == originalStartItem) && from == firstFromItem) {
++        // We might also run into a cycle before we reach firstFromItem again
++        // but note that we have to ignore current if we are meant to skip it
++        if (((current == startItem || current == originalStartItem) && from == firstFromItem) ||
++                (!skip && cycleDetector.hasSeen(current))) {
+             // wrapped around, avoid endless loops
+             if (item == contentItem) {
+                 qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: looped, return contentItem";
+@@ -2689,9 +2695,8 @@ void QQuickItem::setParentItem(QQuickItem *parentItem)
+ 
+         const bool wasVisible = isVisible();
+         op->removeChild(this);
+-        if (wasVisible) {
++        if (wasVisible && !op->inDestructor)
+             emit oldParentItem->visibleChildrenChanged();
+-        }
+     } else if (d->window) {
+         QQuickWindowPrivate::get(d->window)->parentlessItems.remove(this);
+     }
+@@ -2768,8 +2773,9 @@ void QQuickItem::setParentItem(QQuickItem *parentItem)
+ 
+     d->itemChange(ItemParentHasChanged, d->parentItem);
+ 
+-    emit parentChanged(d->parentItem);
+-    if (isVisible() && d->parentItem)
++    if (!d->inDestructor)
++        emit parentChanged(d->parentItem);
++    if (isVisible() && d->parentItem && !QQuickItemPrivate::get(d->parentItem)->inDestructor)
+         emit d->parentItem->visibleChildrenChanged();
+ }
+ 
+@@ -2965,7 +2971,8 @@ void QQuickItemPrivate::removeChild(QQuickItem *child)
+ 
+     itemChange(QQuickItem::ItemChildRemovedChange, child);
+ 
+-    emit q->childrenChanged();
++    if (!inDestructor)
++        emit q->childrenChanged();
+ }
+ 
+ void QQuickItemPrivate::refWindow(QQuickWindow *c)
+@@ -3194,6 +3201,7 @@ QQuickItemPrivate::QQuickItemPrivate()
+     , touchEnabled(false)
+ #endif
+     , hasCursorHandler(false)
++    , inDestructor(false)
+     , dirtyAttributes(0)
+     , nextDirtyItem(nullptr)
+     , prevDirtyItem(nullptr)
+@@ -5120,6 +5128,13 @@ void QQuickItem::componentComplete()
+         d->addToDirtyList();
+         QQuickWindowPrivate::get(d->window)->dirtyItem(this);
+     }
++
++#if QT_CONFIG(accessibility)
++    if (d->isAccessible && d->effectiveVisible) {
++        QAccessibleEvent ev(this, QAccessible::ObjectShow);
++        QAccessible::updateAccessibility(&ev);
++    }
++#endif
+ }
+ 
+ QQuickStateGroup *QQuickItemPrivate::_states()
+@@ -6106,9 +6121,11 @@ bool QQuickItemPrivate::setEffectiveVisibleRecur(bool newEffectiveVisible)
+         QAccessible::updateAccessibility(&ev);
+     }
+ #endif
+-    emit q->visibleChanged();
+-    if (childVisibilityChanged)
+-        emit q->visibleChildrenChanged();
++    if (!inDestructor) {
++        emit q->visibleChanged();
++        if (childVisibilityChanged)
++            emit q->visibleChildrenChanged();
++    }
+ 
+     return true;    // effective visibility DID change
+ }
+@@ -6157,6 +6174,15 @@ void QQuickItemPrivate::setEffectiveEnableRecur(QQuickItem *scope, bool newEffec
+     }
+ 
+     itemChange(QQuickItem::ItemEnabledHasChanged, effectiveEnable);
++#if QT_CONFIG(accessibility)
++    if (isAccessible) {
++        QAccessible::State changedState;
++        changedState.disabled = true;
++        changedState.focusable = true;
++        QAccessibleStateChangeEvent ev(q, changedState);
++        QAccessible::updateAccessibility(&ev);
++    }
++#endif
+     emit q->enabledChanged();
+ }
+ 
+diff --git a/qtdeclarative/src/quick/items/qquickitem_p.h b/qtdeclarative/src/quick/items/qquickitem_p.h
+index 841d91bb40..ade8fb61f2 100644
+--- a/qtdeclarative/src/quick/items/qquickitem_p.h
++++ b/qtdeclarative/src/quick/items/qquickitem_p.h
+@@ -472,6 +472,7 @@ public:
+     bool replayingPressEvent:1;
+     bool touchEnabled:1;
+     bool hasCursorHandler:1;
++    quint32 inDestructor:1; // has entered ~QQuickItem
+ 
+     enum DirtyType {
+         TransformOrigin         = 0x00000001,
+diff --git a/qtdeclarative/src/quick/items/qquickitemview.cpp b/qtdeclarative/src/quick/items/qquickitemview.cpp
+index 010a0152e1..f8ad168a17 100644
+--- a/qtdeclarative/src/quick/items/qquickitemview.cpp
++++ b/qtdeclarative/src/quick/items/qquickitemview.cpp
+@@ -1785,7 +1785,7 @@ void QQuickItemViewPrivate::refill(qreal from, qreal to)
+ 
+     do {
+         bufferPause.stop();
+-        if (currentChanges.hasPendingChanges() || bufferedChanges.hasPendingChanges()) {
++        if (currentChanges.hasPendingChanges() || bufferedChanges.hasPendingChanges() || currentChanges.active) {
+             currentChanges.reset();
+             bufferedChanges.reset();
+             releaseVisibleItems(reusableFlag);
+diff --git a/qtdeclarative/src/quick/items/qquickmousearea_p_p.h b/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
+index fba383e268..0d63618622 100644
+--- a/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
++++ b/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
+@@ -61,7 +61,6 @@ QT_BEGIN_NAMESPACE
+ 
+ class QQuickMouseEvent;
+ class QQuickMouseArea;
+-class QQuickPointerMask;
+ class QQuickMouseAreaPrivate : public QQuickItemPrivate
+ {
+     Q_DECLARE_PUBLIC(QQuickMouseArea)
+@@ -100,7 +99,6 @@ public:
+ #if QT_CONFIG(quick_draganddrop)
+     QQuickDrag *drag;
+ #endif
+-    QPointer<QQuickPointerMask> mask;
+     QPointF startScene;
+     QPointF targetStartPos;
+     QPointF lastPos;
+diff --git a/qtdeclarative/src/quick/items/qquicktext.cpp b/qtdeclarative/src/quick/items/qquicktext.cpp
+index 6230186933..e823ca1095 100644
+--- a/qtdeclarative/src/quick/items/qquicktext.cpp
++++ b/qtdeclarative/src/quick/items/qquicktext.cpp
+@@ -2168,7 +2168,7 @@ void QQuickText::resetMaximumLineCount()
+     <img src="" align="top,middle,bottom" width="" height=""> - inline images
+     <ol type="">, <ul type=""> and <li> - ordered and unordered lists
+     <pre></pre> - preformatted
+-    &gt; &lt; &amp;
++    &gt; &lt; &amp; &quot; &nbsp; &apos;
+     \endcode
+ 
+     \c Text.StyledText parser is strict, requiring tags to be correctly nested.
+diff --git a/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp b/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
+index eb4db0f85e..2325a2665b 100644
+--- a/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
++++ b/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
+@@ -446,7 +446,7 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+         const char *textureRecord = allocatorData;
+         for (int i = 0; i < textureCount; ++i, textureRecord += Qtdf::TextureRecordSize) {
+-            if (textureRecord + Qtdf::TextureRecordSize > qtdfTableEnd) {
++            if (qtdfTableEnd - textureRecord < Qtdf::TextureRecordSize) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+@@ -462,7 +462,7 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+         const char *glyphRecord = textureRecord;
+         for (quint32 i = 0; i < glyphCount; ++i, glyphRecord += Qtdf::GlyphRecordSize) {
+-            if (glyphRecord + Qtdf::GlyphRecordSize > qtdfTableEnd) {
++            if (qtdfTableEnd - glyphRecord < Qtdf:: GlyphRecordSize) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+@@ -512,8 +512,8 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+             int width = texInfo->allocatedArea.width();
+             int height = texInfo->allocatedArea.height();
+-            qint64 size = width * height;
+-            if (reinterpret_cast<const char *>(textureData + size) > qtdfTableEnd) {
++            qint64 size = qint64(width) * height;
++            if (qtdfTableEnd - reinterpret_cast<const char *>(textureData) < size) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+diff --git a/qtdeclarative/src/quick/util/qquickstyledtext.cpp b/qtdeclarative/src/quick/util/qquickstyledtext.cpp
+index d531fc9205..a25af90414 100644
+--- a/qtdeclarative/src/quick/util/qquickstyledtext.cpp
++++ b/qtdeclarative/src/quick/util/qquickstyledtext.cpp
+@@ -564,6 +564,8 @@ void QQuickStyledTextPrivate::parseEntity(const QChar *&ch, const QString &textI
+                 textOut += QChar(60);
+             else if (entity == QLatin1String("amp"))
+                 textOut += QChar(38);
++            else if (entity == QLatin1String("apos"))
++                textOut += QChar(39);
+             else if (entity == QLatin1String("quot"))
+                 textOut += QChar(34);
+             else if (entity == QLatin1String("nbsp"))
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp
+new file mode 100644
+index 0000000000..8a1c901880
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp
+@@ -0,0 +1,110 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include "qaccessiblequickwidget_p.h"
++
++#include "qquickwidget_p.h"
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleQuickWidget::QAccessibleQuickWidget(QQuickWidget* widget)
++: QAccessibleWidget(widget)
++, m_accessibleWindow(QQuickWidgetPrivate::get(widget)->offscreenWindow)
++{
++    // NOTE: m_accessibleWindow is a QAccessibleQuickWindow, and not a
++    // QAccessibleQuickWidgetOffscreenWindow (defined below). This means
++    // it will return the Quick item child interfaces, which is what's needed here
++    // (unlike QAccessibleQuickWidgetOffscreenWindow, which will report 0 children).
++}
++
++QAccessibleInterface *QAccessibleQuickWidget::child(int index) const
++{
++    return m_accessibleWindow.child(index);
++}
++
++int QAccessibleQuickWidget::childCount() const
++{
++    return m_accessibleWindow.childCount();
++}
++
++int QAccessibleQuickWidget::indexOfChild(const QAccessibleInterface *iface) const
++{
++    return m_accessibleWindow.indexOfChild(iface);
++}
++
++QAccessibleInterface *QAccessibleQuickWidget::childAt(int x, int y) const
++{
++    return m_accessibleWindow.childAt(x, y);
++}
++
++QAccessibleQuickWidgetOffscreenWindow::QAccessibleQuickWidgetOffscreenWindow(QQuickWindow *window)
++:QAccessibleQuickWindow(window)
++{
++
++}
++
++QAccessibleInterface *QAccessibleQuickWidgetOffscreenWindow::child(int index) const
++{
++    Q_UNUSED(index);
++    return nullptr;
++}
++
++int QAccessibleQuickWidgetOffscreenWindow::childCount() const
++{
++    return 0;
++}
++
++int QAccessibleQuickWidgetOffscreenWindow::indexOfChild(const QAccessibleInterface *iface) const
++{
++    Q_UNUSED(iface);
++    return -1;
++}
++
++QAccessibleInterface *QAccessibleQuickWidgetOffscreenWindow::QAccessibleQuickWidgetOffscreenWindow::childAt(int x, int y) const
++{
++    Q_UNUSED(x);
++    Q_UNUSED(y);
++    return nullptr;
++}
++
++#endif // accessibility
++
++QT_END_NAMESPACE
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h
+new file mode 100644
+index 0000000000..7c2ab930e0
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h
+@@ -0,0 +1,95 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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 QACCESSIBLEQUICKWIDGET_H
++#define QACCESSIBLEQUICKWIDGET_H
++
++//
++//  W A R N I N G
++//  -------------
++//
++// This file is not part of the Qt API.  It exists purely as an
++// implementation detail.  This header file may change from version to
++// version without notice, or even be removed.
++//
++// We mean it.
++//
++
++#include "qquickwidget.h"
++#include <QtWidgets/qaccessiblewidget.h>
++
++#include <private/qaccessiblequickview_p.h>
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++// These classes implement the QQuickWiget accessibility switcharoo,
++// where the child items of the QQuickWidgetOffscreenWindow are reported
++// as child accessible interfaces of the QAccessibleQuickWidget.
++class QAccessibleQuickWidget: public QAccessibleWidget
++{
++public:
++    QAccessibleQuickWidget(QQuickWidget* widget);
++
++    QAccessibleInterface *child(int index) const override;
++    int childCount() const override;
++    int indexOfChild(const QAccessibleInterface *iface) const override;
++    QAccessibleInterface *childAt(int x, int y) const override;
++
++private:
++    QAccessibleQuickWindow m_accessibleWindow;
++    Q_DISABLE_COPY(QAccessibleQuickWidget)
++};
++
++class QAccessibleQuickWidgetOffscreenWindow: public QAccessibleQuickWindow
++{
++public:
++    QAccessibleQuickWidgetOffscreenWindow(QQuickWindow *window);
++    QAccessibleInterface *child(int index) const override;
++    int childCount() const override;
++    int indexOfChild(const QAccessibleInterface *iface) const override;
++    QAccessibleInterface *childAt(int x, int y) const override;
++};
++
++#endif // accessibility
++
++QT_END_NAMESPACE
++
++#endif
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp
+new file mode 100644
+index 0000000000..7ba88a1769
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp
+@@ -0,0 +1,60 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include "qaccessiblequickwidgetfactory_p.h"
++#include "qaccessiblequickwidget_p.h"
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleInterface *qAccessibleQuickWidgetFactory(const QString &classname, QObject *object)
++{
++    if (classname == QLatin1String("QQuickWidget")) {
++        return new QAccessibleQuickWidget(qobject_cast<QQuickWidget *>(object));
++    } else if (classname == QLatin1String("QQuickWidgetOffscreenWindow")) {
++        return new QAccessibleQuickWidgetOffscreenWindow(qobject_cast<QQuickWindow *>(object));
++    }
++    return 0;
++}
++
++#endif // accessibility
++
++QT_END_NAMESPACE
++
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h
+new file mode 100644
+index 0000000000..8c63b09f81
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h
+@@ -0,0 +1,66 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include <QtGui/qaccessible.h>
++
++#ifndef QACCESSIBLEQUICKWIDGETFACTORY_H
++#define QACCESSIBLEQUICKWIDGETFACTORY_H
++
++//
++//  W A R N I N G
++//  -------------
++//
++// This file is not part of the Qt API.  It exists purely as an
++// implementation detail.  This header file may change from version to
++// version without notice, or even be removed.
++//
++// We mean it.
++//
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleInterface *qAccessibleQuickWidgetFactory(const QString &classname, QObject *object);
++
++#endif
++
++QT_END_NAMESPACE
++
++#endif
+diff --git a/qtdeclarative/src/quickwidgets/qquickwidget.cpp b/qtdeclarative/src/quickwidgets/qquickwidget.cpp
+index 39780f8de3..9c97b43518 100644
+--- a/qtdeclarative/src/quickwidgets/qquickwidget.cpp
++++ b/qtdeclarative/src/quickwidgets/qquickwidget.cpp
+@@ -39,6 +39,7 @@
+ 
+ #include "qquickwidget.h"
+ #include "qquickwidget_p.h"
++#include "qaccessiblequickwidgetfactory_p.h"
+ 
+ #include "private/qquickwindow_p.h"
+ #include "private/qquickitem_p.h"
+@@ -75,9 +76,16 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++QQuickWidgetOffscreenWindow::QQuickWidgetOffscreenWindow(QQuickWindowPrivate &dd, QQuickRenderControl *control)
++:QQuickWindow(dd, control)
++{
++    setTitle(QString::fromLatin1("Offscreen"));
++    setObjectName(QString::fromLatin1("QQuickOffScreenWindow"));
++}
++
+ // override setVisble to prevent accidental offscreen window being created
+ // by base class.
+-class QQuickOffcreenWindowPrivate: public QQuickWindowPrivate {
++class QQuickWidgetOffscreenWindowPrivate: public QQuickWindowPrivate {
+ public:
+     void setVisible(bool visible) override {
+         Q_Q(QWindow);
+@@ -105,9 +113,8 @@ void QQuickWidgetPrivate::init(QQmlEngine* e)
+     Q_Q(QQuickWidget);
+ 
+     renderControl = new QQuickWidgetRenderControl(q);
+-    offscreenWindow = new QQuickWindow(*new QQuickOffcreenWindowPrivate(),renderControl);
+-    offscreenWindow->setTitle(QString::fromLatin1("Offscreen"));
+-    offscreenWindow->setObjectName(QString::fromLatin1("QQuickOffScreenWindow"));
++    offscreenWindow = new QQuickWidgetOffscreenWindow(*new QQuickWidgetOffscreenWindowPrivate(), renderControl);
++    offscreenWindow->setScreen(q->screen());
+     // Do not call create() on offscreenWindow.
+ 
+     // Check if the Software Adaptation is being used
+@@ -138,6 +145,10 @@ void QQuickWidgetPrivate::init(QQmlEngine* e)
+     QWidget::connect(offscreenWindow, &QQuickWindow::focusObjectChanged, q, &QQuickWidget::propagateFocusObjectChanged);
+     QObject::connect(renderControl, SIGNAL(renderRequested()), q, SLOT(triggerUpdate()));
+     QObject::connect(renderControl, SIGNAL(sceneChanged()), q, SLOT(triggerUpdate()));
++
++#if QT_CONFIG(accessibility)
++    QAccessible::installFactory(&qAccessibleQuickWidgetFactory);
++#endif
+ }
+ 
+ void QQuickWidgetPrivate::ensureEngine() const
+@@ -901,9 +912,7 @@ void QQuickWidgetPrivate::createContext()
+ 
+         context = new QOpenGLContext;
+         context->setFormat(offscreenWindow->requestedFormat());
+-        const QWindow *win = q->window()->windowHandle();
+-        if (win && win->screen())
+-            context->setScreen(win->screen());
++        context->setScreen(q->screen());
+         QOpenGLContext *shareContext = qt_gl_global_share_context();
+         if (!shareContext)
+             shareContext = QWidgetPrivate::get(q->window())->shareContext();
+@@ -1520,19 +1529,16 @@ bool QQuickWidget::event(QEvent *e)
+         d->handleWindowChange();
+         break;
+ 
+-    case QEvent::ScreenChangeInternal:
+-        if (QWindow *window = this->window()->windowHandle()) {
+-            QScreen *newScreen = window->screen();
+-
+-            if (d->offscreenWindow)
+-                d->offscreenWindow->setScreen(newScreen);
+-            if (d->offscreenSurface)
+-                d->offscreenSurface->setScreen(newScreen);
++    case QEvent::ScreenChangeInternal: {
++        QScreen *newScreen = screen();
++        if (d->offscreenWindow)
++            d->offscreenWindow->setScreen(newScreen);
++        if (d->offscreenSurface)
++            d->offscreenSurface->setScreen(newScreen);
+ #if QT_CONFIG(opengl)
+-            if (d->context)
+-                d->context->setScreen(newScreen);
++        if (d->context)
++            d->context->setScreen(newScreen);
+ #endif
+-        }
+ 
+         if (d->useSoftwareRenderer
+ #if QT_CONFIG(opengl)
+@@ -1545,7 +1551,7 @@ bool QQuickWidget::event(QEvent *e)
+             d->render(true);
+         }
+         break;
+-
++    }
+     case QEvent::Show:
+     case QEvent::Move:
+         d->updatePosition();
+diff --git a/qtdeclarative/src/quickwidgets/qquickwidget_p.h b/qtdeclarative/src/quickwidgets/qquickwidget_p.h
+index 881f7f9220..1a946bcc71 100644
+--- a/qtdeclarative/src/quickwidgets/qquickwidget_p.h
++++ b/qtdeclarative/src/quickwidgets/qquickwidget_p.h
+@@ -148,6 +148,14 @@ public:
+     bool forceFullUpdate;
+ };
+ 
++class QQuickWidgetOffscreenWindow: public QQuickWindow
++{
++    Q_OBJECT
++
++public:
++    QQuickWidgetOffscreenWindow(QQuickWindowPrivate &dd, QQuickRenderControl *control);
++};
++
+ QT_END_NAMESPACE
+ 
+ #endif // QQuickWidget_P_H
+diff --git a/qtdeclarative/src/quickwidgets/quickwidgets.pro b/qtdeclarative/src/quickwidgets/quickwidgets.pro
+index 2438e577ae..85d156b8a3 100644
+--- a/qtdeclarative/src/quickwidgets/quickwidgets.pro
++++ b/qtdeclarative/src/quickwidgets/quickwidgets.pro
+@@ -7,9 +7,13 @@ DEFINES   += QT_NO_URL_CAST_FROM_STRING QT_NO_INTEGER_EVENT_COORDINATES QT_NO_FO
+ HEADERS += \
+     qquickwidget.h \
+     qquickwidget_p.h \
+-    qtquickwidgetsglobal.h
++    qtquickwidgetsglobal.h \
++    qaccessiblequickwidget_p.h \
++    qaccessiblequickwidgetfactory_p.h
+ 
+ SOURCES += \
+-    qquickwidget.cpp
++    qquickwidget.cpp \
++    qaccessiblequickwidget.cpp \
++    qaccessiblequickwidgetfactory.cpp
+ 
+ load(qt_module)
+diff --git a/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+index 3b7d74df63..b75bf820d5 100644
+--- a/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
++++ b/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+@@ -102,6 +102,7 @@ private slots:
+     void valueConversion_RegularExpression();
+     void castWithMultipleInheritance();
+     void collectGarbage();
++    void collectGarbageNestedWrappersTwoEngines();
+     void gcWithNestedDataStructure();
+     void stacktrace();
+     void numberParsing_data();
+@@ -1809,6 +1810,44 @@ void tst_QJSEngine::collectGarbage()
+     QVERIFY(ptr.isNull());
+ }
+ 
++class TestObjectContainer : public QObject
++{
++    Q_OBJECT
++    Q_PROPERTY(QObject *dummy MEMBER m_dummy CONSTANT)
++
++public:
++    TestObjectContainer() : m_dummy(new QObject(this)) {}
++
++private:
++    QObject *m_dummy;
++};
++
++void tst_QJSEngine::collectGarbageNestedWrappersTwoEngines()
++{
++    QJSEngine engine1;
++    QJSEngine engine2;
++
++    TestObjectContainer container;
++    QQmlEngine::setObjectOwnership(&container, QQmlEngine::CppOwnership);
++
++    engine1.globalObject().setProperty("foobar", engine1.newQObject(&container));
++    engine2.globalObject().setProperty("foobar", engine2.newQObject(&container));
++
++    engine1.evaluate("foobar.dummy.baz = 42");
++    engine2.evaluate("foobar.dummy.baz = 43");
++
++    QCOMPARE(engine1.evaluate("foobar.dummy.baz").toInt(), 42);
++    QCOMPARE(engine2.evaluate("foobar.dummy.baz").toInt(), 43);
++
++    engine1.collectGarbage();
++    engine2.collectGarbage();
++
++    // The GC should not collect dummy object wrappers neither in engine1 nor engine2, we
++    // verify that by checking whether the baz property still has its previous value.
++    QCOMPARE(engine1.evaluate("foobar.dummy.baz").toInt(), 42);
++    QCOMPARE(engine2.evaluate("foobar.dummy.baz").toInt(), 43);
++}
++
+ void tst_QJSEngine::gcWithNestedDataStructure()
+ {
+     // The GC must be able to traverse deeply nested objects, otherwise this
+diff --git a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml
+new file mode 100644
+index 0000000000..206133bb39
+--- /dev/null
++++ b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml
+@@ -0,0 +1,11 @@
++import QtQuick 2.8
++
++ListView {
++    id: root
++    width: 200
++    height: 200
++
++    delegate: Text {
++        text: display
++    }
++}
+diff --git a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
+index 35f1e2c94d..1722447830 100644
+--- a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
++++ b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
+@@ -27,6 +27,8 @@
+ ****************************************************************************/
+ 
+ #include <QtTest/qtest.h>
++#include <QtCore/QConcatenateTablesProxyModel>
++#include <QtGui/QStandardItemModel>
+ #include <QtQml/qqmlcomponent.h>
+ #include <QtQmlModels/private/qqmldelegatemodel_p.h>
+ #include <QtQuick/qquickview.h>
+@@ -47,6 +49,7 @@ private slots:
+     void filterOnGroup_removeWhenCompleted();
+     void qtbug_86017();
+     void contextAccessedByHandler();
++    void redrawUponColumnChange();
+ };
+ 
+ class AbstractItemModel : public QAbstractItemModel
+@@ -186,6 +189,30 @@ void tst_QQmlDelegateModel::contextAccessedByHandler()
+     QVERIFY(root->property("works").toBool());
+ }
+ 
++void tst_QQmlDelegateModel::redrawUponColumnChange()
++{
++    QStandardItemModel m1;
++    m1.appendRow({
++            new QStandardItem("Banana"),
++            new QStandardItem("Coconut"),
++    });
++
++    QQuickView view(testFileUrl("redrawUponColumnChange.qml"));
++    QCOMPARE(view.status(), QQuickView::Ready);
++    view.show();
++    QQuickItem *root = view.rootObject();
++    root->setProperty("model", QVariant::fromValue<QObject *>(&m1));
++
++    QObject *item = root->property("currentItem").value<QObject *>();
++    QVERIFY(item);
++    QCOMPARE(item->property("text").toString(), "Banana");
++
++    QVERIFY(root);
++    m1.removeColumn(0);
++
++    QCOMPARE(item->property("text").toString(), "Coconut");
++}
++
+ QTEST_MAIN(tst_QQmlDelegateModel)
+ 
+ #include "tst_qqmldelegatemodel.moc"
+diff --git a/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp b/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
+index 5d635aa63b..824fd89e5b 100644
+--- a/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
++++ b/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
+@@ -76,10 +76,10 @@ void tst_qv4mm::multiWrappedQObjects()
+         QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 1);
+         QCOMPARE(engine2.memoryManager->m_pendingFreedObjectWrapperValue.size(), 0);
+ 
+-        // Moves the additional WeakValue from m_multiplyWrappedQObjects to
+-        // m_pendingFreedObjectWrapperValue. It's still alive after all.
++        // The additional WeakValue from m_multiplyWrappedQObjects hasn't been moved
++        // to m_pendingFreedObjectWrapperValue yet. It's still alive after all.
+         engine1.memoryManager->runGC();
+-        QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 2);
++        QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 1);
+ 
+         // engine2 doesn't own the object as engine1 was the first to wrap it above.
+         // Therefore, no effect here.
+diff --git a/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml b/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml
+new file mode 100644
+index 0000000000..889e480f3b
+--- /dev/null
++++ b/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml
+@@ -0,0 +1,13 @@
++import QtQuick 2.6
++
++Item {
++    visible: true
++    Item {
++        visible: false
++        Item {
++            objectName: "hiddenChild"
++            activeFocusOnTab: true
++            focus: true
++        }
++    }
++}
+diff --git a/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp b/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+index c8f251dbe1..c8ef36ee68 100644
+--- a/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
++++ b/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+@@ -67,6 +67,7 @@ private slots:
+     void activeFocusOnTab10();
+     void activeFocusOnTab_infiniteLoop_data();
+     void activeFocusOnTab_infiniteLoop();
++    void activeFocusOnTab_infiniteLoopControls();
+ 
+     void nextItemInFocusChain();
+     void nextItemInFocusChain2();
+@@ -1057,6 +1058,17 @@ void tst_QQuickItem::activeFocusOnTab_infiniteLoop()
+     QCOMPARE(item, window->rootObject());
+ }
+ 
++
++void tst_QQuickItem::activeFocusOnTab_infiniteLoopControls()
++{
++    auto source = testFileUrl("activeFocusOnTab_infiniteLoop3.qml");
++    QScopedPointer<QQuickView>window(new QQuickView());
++    window->setSource(source);
++    window->show();
++    QVERIFY(window->errors().isEmpty());
++    QTest::keyClick(window.get(), Qt::Key_Tab); // should not hang
++}
++
+ void tst_QQuickItem::nextItemInFocusChain()
+ {
+     if (!qt_tab_all_widgets())
+Submodule qtdoc c0c7bf07...79d6ef69:
+Submodule qtimageformats 2dcf2899..abe44c0f:
+diff --git a/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp b/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
+index dde783c..1bf9074 100644
+--- a/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
+@@ -462,8 +462,12 @@ static bool parseIconEntryInfo(ICNSEntry &icon)
+     if (isIconCompressed(icon))
+         return true;
+     // Icon depth:
+-    if (!depth.isEmpty())
+-        icon.depth = ICNSEntry::Depth(depth.toUInt());
++    if (!depth.isEmpty()) {
++        const uint depthUInt = depth.toUInt();
++        if (depthUInt > 32)
++            return false;
++        icon.depth = ICNSEntry::Depth(depthUInt);
++    }
+     // Try mono if depth not found
+     if (icon.depth == ICNSEntry::DepthUnknown)
+         icon.depth = ICNSEntry::DepthMono;
+@@ -515,6 +519,9 @@ static bool parseIconEntryInfo(ICNSEntry &icon)
+         }
+         icon.height = icon.width;
+     }
++    // Sanity check
++    if (icon.width == 0 || icon.width > 4096)
++        return false;
+     return true;
+ }
+ 
+@@ -685,7 +692,7 @@ bool QICNSHandler::canRead() const
+ bool QICNSHandler::read(QImage *outImage)
+ {
+     QImage img;
+-    if (!ensureScanned()) {
++    if (!ensureScanned() || m_currentIconIndex >= m_icons.size()) {
+         qWarning("QICNSHandler::read(): The device wasn't parsed properly!");
+         return false;
+     }
+@@ -892,7 +899,7 @@ bool QICNSHandler::scanDevice()
+             return false;
+ 
+         const qint64 blockDataOffset = device()->pos();
+-        if (!isBlockHeaderValid(blockHeader)) {
++        if (!isBlockHeaderValid(blockHeader, ICNSBlockHeaderSize + filelength - blockDataOffset)) {
+             qWarning("QICNSHandler::scanDevice(): Failed, bad header at pos %s. OSType \"%s\", length %u",
+                      QByteArray::number(blockDataOffset).constData(),
+                      nameFromOSType(blockHeader.ostype).constData(), blockHeader.length);
+@@ -927,11 +934,14 @@ bool QICNSHandler::scanDevice()
+         case ICNSBlockHeader::TypeOdrp:
+             // Icns container seems to have an embedded icon variant container
+             // Let's start a scan for entries
+-            while (device()->pos() < nextBlockOffset) {
++            while (!stream.atEnd() && device()->pos() < nextBlockOffset) {
+                 ICNSBlockHeader icon;
+                 stream >> icon;
++                if (stream.status() != QDataStream::Ok)
++                    return false;
+                 // Check for incorrect variant entry header and stop scan
+-                if (!isBlockHeaderValid(icon, blockDataLength))
++                quint64 remaining = blockDataLength - (device()->pos() - blockDataOffset);
++                if (!isBlockHeaderValid(icon, ICNSBlockHeaderSize + remaining))
+                     break;
+                 if (!addEntry(icon, device()->pos(), blockHeader.ostype))
+                     return false;
+@@ -1003,7 +1013,7 @@ bool QICNSHandler::scanDevice()
+             break;
+         }
+     }
+-    return true;
++    return (m_icons.size() > 0);
+ }
+ 
+ const ICNSEntry &QICNSHandler::getIconMask(const ICNSEntry &icon) const
+diff --git a/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp b/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
+index 5082023..cb34374 100644
+--- a/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
++++ b/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
+@@ -43,6 +43,7 @@
+ #include "qimage.h"
+ #include "qvariant.h"
+ #include "qcolor.h"
++#include "qimagereader.h"
+ 
+ #include <jasper/jasper.h>
+ #include <math.h> // for pow
+@@ -333,16 +334,46 @@ private:
+ Jpeg2000JasperReader::Jpeg2000JasperReader(QIODevice *iod, SubFormat format)
+     : jasperOk(true), ioDevice(iod), format(format), hasAlpha(false)
+ {
++#if JAS_VERSION_MAJOR < 3
+     if (jas_init()) {
+         jasperOk = false;
+         qDebug("Jasper Library initialization failed");
+     }
++#else
++    jas_conf_clear();
++#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
++    jas_conf_set_max_mem_usage(QImageReader::allocationLimit() * 1024 * 1024);
++#else
++    // 128MB seems to be enough.
++    jas_conf_set_max_mem_usage(128 * 1024 * 1024);
++#endif
++    if (jas_init_library()) {
++        jasperOk = false;
++        qDebug("Jasper library initialization failed");
++    }
++    if (jas_init_thread()) {
++        jas_cleanup_library();
++        jasperOk = false;
++        qDebug("Jasper thread initialization failed");
++    }
++#endif
+ }
+ 
+ Jpeg2000JasperReader::~Jpeg2000JasperReader()
+ {
++#if JAS_VERSION_MAJOR < 3
+     if (jasperOk)
+         jas_cleanup();
++#else
++    if (jasperOk) {
++        if (jas_cleanup_thread()) {
++            qDebug("Jasper thread cleanup failed");
++        }
++        if (jas_cleanup_library()) {
++            qDebug("Jasper library cleanup failed");
++        }
++    }
++#endif
+ }
+ 
+ /*! \internal
+@@ -857,7 +888,7 @@ bool Jpeg2000JasperReader::write(const QImage &image, int quality)
+     }
+ 
+     // Open an empty jasper stream that grows automatically
+-    jas_stream_t * memory_stream = jas_stream_memopen(0, -1);
++    jas_stream_t * memory_stream = jas_stream_memopen(0, 0);
+ 
+     // Jasper wants a non-const string.
+     char *str = qstrdup(jasperFormatString.toLatin1().constData());
+diff --git a/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp b/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
+index 1386750..ac8956c 100644
+--- a/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
+@@ -361,6 +361,8 @@ bool QTiffHandler::read(QImage *image)
+     }
+ 
+     TIFF *const tiff = d->tiff;
++    if (TIFFIsTiled(tiff) && TIFFTileSize64(tiff) > uint64_t(image->sizeInBytes())) // Corrupt image
++        return false;
+     const quint32 width = d->size.width();
+     const quint32 height = d->size.height();
+ 
+diff --git a/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp b/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
+index 82d38cb..d02eb05 100644
+--- a/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
+@@ -45,6 +45,7 @@
+ #include <qdebug.h>
+ #include <qpainter.h>
+ #include <qvariant.h>
++#include <QtEndian>
+ 
+ static const int riffHeaderSize = 12; // RIFF_HEADER_SIZE from webp/format_constants.h
+ 
+@@ -102,21 +103,23 @@ bool QWebpHandler::ensureScanned() const
+ 
+     m_scanState = ScanError;
+ 
+-    if (device()->isSequential()) {
+-        qWarning() << "Sequential devices are not supported";
++    QWebpHandler *that = const_cast<QWebpHandler *>(this);
++    const int headerBytesNeeded = sizeof(WebPBitstreamFeatures);
++    QByteArray header = device()->peek(headerBytesNeeded);
++    if (header.size() < headerBytesNeeded)
+         return false;
+-    }
+ 
+-    qint64 oldPos = device()->pos();
+-    device()->seek(0);
+-
+-    QWebpHandler *that = const_cast<QWebpHandler *>(this);
+-    QByteArray header = device()->peek(sizeof(WebPBitstreamFeatures));
++    // We do no random access during decoding, just a readAll() of the whole image file. So if
++    // if it is all available already, we can accept a sequential device. The riff header contains
++    // the file size minus 8 bytes header
++    qint64 byteSize = qFromLittleEndian<quint32>(header.constData() + 4);
++    if (device()->isSequential() && device()->bytesAvailable() < byteSize + 8) {
++        qWarning() << "QWebpHandler: Insufficient data available in sequential device";
++        return false;
++    }
+     if (WebPGetFeatures((const uint8_t*)header.constData(), header.size(), &(that->m_features)) == VP8_STATUS_OK) {
+         if (m_features.has_animation) {
+             // For animation, we have to read and scan whole file to determine loop count and images count
+-            device()->seek(oldPos);
+-
+             if (that->ensureDemuxer()) {
+                 that->m_loop = WebPDemuxGetI(m_demuxer, WEBP_FF_LOOP_COUNT);
+                 that->m_frameCount = WebPDemuxGetI(m_demuxer, WEBP_FF_FRAME_COUNT);
+@@ -126,17 +129,13 @@ bool QWebpHandler::ensureScanned() const
+                 if (that->m_features.has_alpha)
+                     that->m_composited->fill(Qt::transparent);
+ 
+-                // We do not reset device position since we have read in all data
+                 m_scanState = ScanSuccess;
+-                return true;
+             }
+         } else {
+             m_scanState = ScanSuccess;
+         }
+     }
+ 
+-    device()->seek(oldPos);
+-
+     return m_scanState == ScanSuccess;
+ }
+ 
+@@ -159,7 +158,7 @@ bool QWebpHandler::ensureDemuxer()
+ 
+ bool QWebpHandler::read(QImage *image)
+ {
+-    if (!ensureScanned() || device()->isSequential() || !ensureDemuxer())
++    if (!ensureScanned() || !ensureDemuxer())
+         return false;
+ 
+     QRect prevFrameRect;
+Submodule qtlocation 98a5c511..f991e28c:
+diff --git a/qtlocation/src/location/configure.json b/qtlocation/src/location/configure.json
+index 6d01a9a3..d1e623a1 100644
+--- a/qtlocation/src/location/configure.json
++++ b/qtlocation/src/location/configure.json
+@@ -9,7 +9,7 @@
+             "label": "Qt.labs.location experimental QML plugin",
+             "purpose": "Provides experimental QtLocation QML types",
+             "section": "Location",
+-            "condition": "config.opengl",
++            "condition": "features.opengl",
+             "output": [ "privateFeature" ]
+         },
+         "geoservices_osm": {
+diff --git a/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp b/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
+index a978573d..11e1466f 100644
+--- a/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
++++ b/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
+@@ -158,7 +158,7 @@ void QGeoMapObjectQSGSupport::updateMapObjects(QSGNode *root, QQuickWindow *wind
+     if (!root)
+         return;
+ 
+-    if (m_mapObjectsRootNode && m_mapObjectsRootNode->parent())
++    if (m_mapObjectsRootNode && !m_mapObjectsRootNode->parent())
+         root->appendChildNode(m_mapObjectsRootNode.get());
+ 
+     if (!m_mapObjectsRootNode) {
+diff --git a/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
+index 5a40467e..d123c6a8 100644
+--- a/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
+@@ -59,8 +59,10 @@ QT_BEGIN_NAMESPACE
+ static const QString kPrefixEsri(QStringLiteral("esri."));
+ static const QString kParamUserAgent(kPrefixEsri + QStringLiteral("useragent"));
+ 
+-static const QString kUrlGeocode(QStringLiteral("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates"));
+-static const QString kUrlReverseGeocode(QStringLiteral("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode"));
++static const QString kUrlGeocode(QStringLiteral("https://geocode.arcgis.com/arcgis/rest/services/"
++                                                "World/GeocodeServer/findAddressCandidates"));
++static const QString kUrlReverseGeocode(QStringLiteral(
++        "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode"));
+ 
+ static QString addressToQuery(const QGeoAddress &address)
+ {
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
+index 17492d94..96c12b1b 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
+@@ -46,7 +46,8 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-// JSON reference: http://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
++// JSON reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
+ 
+ static const QString kErrorMessage(QStringLiteral("Error %1: %2."));
+ static const QString kErrorJson(QStringLiteral("Error: invalide JSON document."));
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
+index 8cadfb29..92b6bb13 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
+@@ -44,7 +44,8 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-// JSON reference: http://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
++// JSON reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
+ 
+ GeoRouteReplyEsri::GeoRouteReplyEsri(QNetworkReply *reply, const QGeoRouteRequest &request,
+                                      QObject *parent) :
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
+index 0e6bc2c7..ed613f4b 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
+@@ -48,7 +48,8 @@ static const QString kPrefixEsri(QStringLiteral("esri."));
+ static const QString kParamUserAgent(kPrefixEsri + QStringLiteral("useragent"));
+ static const QString kParamToken(kPrefixEsri + QStringLiteral("token"));
+ 
+-static const QString kUrlRouting(QStringLiteral("http://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve"));
++static const QString kUrlRouting(QStringLiteral(
++        "https://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve"));
+ 
+ GeoRoutingManagerEngineEsri::GeoRoutingManagerEngineEsri(const QVariantMap &parameters,
+                                                          QGeoServiceProvider::Error *error,
+@@ -70,7 +71,8 @@ GeoRoutingManagerEngineEsri::~GeoRoutingManagerEngineEsri()
+ {
+ }
+ 
+-// REST reference: http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
++// REST reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
+ 
+ QGeoRouteReply *GeoRoutingManagerEngineEsri::calculateRoute(const QGeoRouteRequest &request)
+ {
+@@ -125,7 +127,7 @@ void GeoRoutingManagerEngineEsri::replyError(QGeoRouteReply::Error errorCode, co
+ QString GeoRoutingManagerEngineEsri::preferedDirectionLangage()
+ {
+     // list of supported langages is defined in:
+-    // http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
++    // https://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
+     const QStringList supportedLanguages = {
+         "ar", // Generate directions in Arabic
+         "cs", // Generate directions in Czech
+diff --git a/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
+index 5d15835d..24148f95 100644
+--- a/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
+@@ -230,7 +230,8 @@ QGeoMap *GeoTiledMappingManagerEngineEsri::createMap()
+ // ${y} = Y
+ // ${token} = Token
+ 
+-// template = 'http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{{z}}/{{y}}/{{x}}.png'
++// template =
++// 'https://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{{z}}/{{y}}/{{x}}.png'
+ 
+ bool GeoTiledMappingManagerEngineEsri::initializeMapSources(QGeoServiceProvider::Error *error,
+                                                             QString *errorString,
+diff --git a/qtlocation/src/plugins/geoservices/esri/maps.json b/qtlocation/src/plugins/geoservices/esri/maps.json
+index 8167ae7d..862e087d 100644
+--- a/qtlocation/src/plugins/geoservices/esri/maps.json
++++ b/qtlocation/src/plugins/geoservices/esri/maps.json
+@@ -6,8 +6,8 @@
+             "description": "ArcGIS Online World Street Map",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=3b93337983e9436f8db950e38a8629af'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=3b93337983e9436f8db950e38a8629af'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -16,8 +16,8 @@
+             "": "ArcGIS Online World Imagery",
+             "mobile": true,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -26,8 +26,8 @@
+             "description": "ArcGIS Online World Terrain Base",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=c61ad8ab017d49e1a82f580ee1298931'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=c61ad8ab017d49e1a82f580ee1298931'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -36,8 +36,8 @@
+             "description": "ArcGIS Online World Topography",
+             "mobile": true,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=30e5fe3149c34df1ba922e6f5bbf808f'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=30e5fe3149c34df1ba922e6f5bbf808f'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -46,8 +46,8 @@
+             "description": "This map presents land cover and detailed topographic maps for the United States.",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=99cd5fbd98934028802b4f797c4b1732'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=99cd5fbd98934028802b4f797c4b1732'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -56,8 +56,8 @@
+             "description": "National Geographic World Map",
+             "mobile": false,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=b9b1b422198944fbbd5250b3241691b6'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=b9b1b422198944fbbd5250b3241691b6'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -66,8 +66,8 @@
+             "description": "Thematic content providing a neutral background with minimal colors",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=ed712cb1db3e4bae9e85329040fb9a49'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=ed712cb1db3e4bae9e85329040fb9a49'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -76,8 +76,8 @@
+             "description": "Natural Earth physical map for the world",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=c4ec722a1cd34cf0a23904aadf8923a0'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=c4ec722a1cd34cf0a23904aadf8923a0'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -86,8 +86,8 @@
+             "description": "Portrays surface elevation as shaded relief",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=9c5370d0b54f4de1b48a3792d7377ff2'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=9c5370d0b54f4de1b48a3792d7377ff2'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -96,8 +96,8 @@
+             "description": "This map is designed to be used as a basemap by marine GIS professionals and as a reference map by anyone interested in ocean data",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=1e126e7520f9466c9ca28b8f28b5e500'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=1e126e7520f9466c9ca28b8f28b5e500'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -106,8 +106,8 @@
+             "description": "Thematic content providing a neutral background with minimal colors",
+             "mobile": false,
+             "night": true,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=a284a9b99b3446a3910d4144a50990f6'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=a284a9b99b3446a3910d4144a50990f6'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -116,8 +116,8 @@
+             "description": "DeLorme’s topographic basemap is a seamless global data set that portrays transportation, hydrography, jurisdiction boundaries, and major geographic features",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/Specialty/DeLorme_World_Base_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=b165c3df453e4be6b5ac4fdb241effbe'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/Specialty/DeLorme_World_Base_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=b165c3df453e4be6b5ac4fdb241effbe'>Esri</a> contributors"
+         }
+     ]
+ }
+diff --git a/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
+index 3858ddf5..af66f28e 100644
+--- a/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
+@@ -63,8 +63,10 @@ static const QString kCountriesKey(QStringLiteral("detailedCountries"));
+ static const QString kLocalizedNamesKey(QStringLiteral("localizedNames"));
+ static const QString kMaxLocationsKey(QStringLiteral("maxLocations"));
+ 
+-static const QUrl kUrlGeocodeServer("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer?f=pjson");
+-static const QUrl kUrlFindAddressCandidates("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates");
++static const QUrl kUrlGeocodeServer(
++        "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer?f=pjson");
++static const QUrl kUrlFindAddressCandidates("https://geocode.arcgis.com/arcgis/rest/services/World/"
++                                            "GeocodeServer/findAddressCandidates");
+ 
+ PlaceManagerEngineEsri::PlaceManagerEngineEsri(const QVariantMap &parameters, QGeoServiceProvider::Error *error,
+                                                QString *errorString) :
+Submodule qtmultimedia f0344079..0d7cc33a:
+diff --git a/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp b/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
+index 2b5325132..b68b4af1b 100644
+--- a/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
++++ b/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
+@@ -402,6 +402,8 @@ int QPulseAudioInput::bytesReady() const
+ 
+ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ {
++    Q_ASSERT(data != nullptr || len == 0);
++
+     m_bytesAvailable = checkBytesReady();
+ 
+     setError(QAudio::NoError);
+@@ -411,7 +413,8 @@ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ 
+     if (!m_pullMode && !m_tempBuffer.isEmpty()) {
+         readBytes = qMin(static_cast<int>(len), m_tempBuffer.size());
+-        memcpy(data, m_tempBuffer.constData(), readBytes);
++        if (readBytes)
++            memcpy(data, m_tempBuffer.constData(), readBytes);
+         m_totalTimeValue += readBytes;
+ 
+         if (readBytes < m_tempBuffer.size()) {
+@@ -502,9 +505,10 @@ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ 
+ void QPulseAudioInput::applyVolume(const void *src, void *dest, int len)
+ {
++    Q_ASSERT((src && dest) || len == 0);
+     if (m_volume < 1.f)
+         QAudioHelperInternal::qMultiplySamples(m_volume, m_format, src, dest, len);
+-    else
++    else if (len)
+         memcpy(dest, src, len);
+ }
+ 
+Submodule qtpim 02efef5e...f9a8f0fc (commits not present)
+Submodule qtquick3d b85cf622..47defc8b:
+diff --git a/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro b/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
+index ca5c499e..174a075b 100644
+--- a/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
++++ b/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
+@@ -10,7 +10,7 @@ QT_FOR_CONFIG += assetimporters-private
+ include($$OUT_PWD/../qtassetimporters-config.pri)
+ 
+ qtConfig(system-assimp):!if(cross_compile:host_build) {
+-    QMAKE_USE_PRIVATE += assimp
++    QMAKE_USE_PRIVATE += quick3d-assimp
+ } else {
+     include(../../../3rdparty/assimp/assimp.pri)
+ }
+Submodule qtquickcontrols2 3a657dc0..56ce8233:
+diff --git a/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp b/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
+index e5fe734f7..e36922775 100644
+--- a/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
++++ b/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
+@@ -38,6 +38,7 @@
+ #include "qwidgetplatformmenuitem_p.h"
+ 
+ #include <QtGui/qwindow.h>
++#include <QtGui/private/qhighdpiscaling_p.h>
+ #include <QtWidgets/qmenu.h>
+ #include <QtWidgets/qaction.h>
+ 
+@@ -145,7 +146,7 @@ void QWidgetPlatformMenu::showPopup(const QWindow *window, const QRect &targetRe
+ 
+     QPoint targetPos = targetRect.bottomLeft();
+     if (window)
+-        targetPos = window->mapToGlobal(targetPos);
++        targetPos = window->mapToGlobal(QHighDpi::fromNativeLocalPosition(targetPos, window));
+ 
+     const QWidgetPlatformMenuItem *widgetItem = qobject_cast<const QWidgetPlatformMenuItem *>(item);
+     m_menu->popup(targetPos, widgetItem ? widgetItem->action() : nullptr);
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
+index 950e4e099..b81fbea0b 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
+@@ -387,6 +387,17 @@ void QQuickAbstractButtonPrivate::itemImplicitHeightChanged(QQuickItem *item)
+         emit q->implicitIndicatorHeightChanged();
+ }
+ 
++void QQuickAbstractButtonPrivate::itemDestroyed(QQuickItem *item)
++{
++    Q_Q(QQuickAbstractButton);
++    QQuickControlPrivate::itemDestroyed(item);
++    if (item == indicator) {
++        indicator = nullptr;
++        emit q->implicitIndicatorWidthChanged();
++        emit q->implicitIndicatorHeightChanged();
++    }
++}
++
+ QQuickAbstractButton *QQuickAbstractButtonPrivate::findCheckedButton() const
+ {
+     Q_Q(const QQuickAbstractButton);
+@@ -1176,6 +1187,12 @@ QAccessible::Role QQuickAbstractButton::accessibleRole() const
+     }
+     return QAccessible::Button;
+ }
++
++void QQuickAbstractButton::accessiblePressAction()
++{
++    Q_D(QQuickAbstractButton);
++    d->trigger();
++}
+ #endif
+ 
+ QT_END_NAMESPACE
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
+index 0fa48980e..ab66220d0 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
+@@ -209,6 +209,7 @@ protected:
+ #if QT_CONFIG(accessibility)
+     void accessibilityActiveChanged(bool active) override;
+     QAccessible::Role accessibleRole() const override;
++    Q_INVOKABLE void accessiblePressAction();
+ #endif
+ 
+ private:
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
+index 9291c1a87..b729720f2 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
+@@ -109,6 +109,7 @@ public:
+ 
+     void itemImplicitWidthChanged(QQuickItem *item) override;
+     void itemImplicitHeightChanged(QQuickItem *item) override;
++    void itemDestroyed(QQuickItem *item) override;
+ 
+     // copied from qabstractbutton.cpp
+     static const int AUTO_REPEAT_DELAY = 300;
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp b/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
+index 2041e7741..8610cdfae 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
+@@ -145,7 +145,7 @@ int QQuickActionPrivate::ShortcutEntry::shortcutId() const
+ 
+ void QQuickActionPrivate::ShortcutEntry::grab(const QKeySequence &shortcut, bool enabled)
+ {
+-    if (shortcut.isEmpty())
++    if (shortcut.isEmpty() || m_shortcutId)
+         return;
+ 
+     Qt::ShortcutContext context = Qt::WindowShortcut; // TODO
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp b/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
+index f38c2b09c..6eed2a024 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
+@@ -225,6 +225,7 @@ void QQuickContainerPrivate::cleanup()
+     QObject::disconnect(contentModel, &QQmlObjectModel::countChanged, q, &QQuickContainer::countChanged);
+     QObject::disconnect(contentModel, &QQmlObjectModel::childrenChanged, q, &QQuickContainer::contentChildrenChanged);
+     delete contentModel;
++    contentModel = nullptr;
+ }
+ 
+ QQuickItem *QQuickContainerPrivate::itemAt(int index) const
+@@ -436,7 +437,7 @@ void QQuickContainerPrivate::contentChildren_clear(QQmlListProperty<QQuickItem>
+ void QQuickContainerPrivate::updateContentWidth()
+ {
+     Q_Q(QQuickContainer);
+-    if (hasContentWidth || qFuzzyCompare(contentWidth, implicitContentWidth))
++    if (hasContentWidth || qFuzzyCompare(contentWidth, implicitContentWidth) || !contentModel)
+         return;
+ 
+     contentWidth = implicitContentWidth;
+@@ -446,7 +447,7 @@ void QQuickContainerPrivate::updateContentWidth()
+ void QQuickContainerPrivate::updateContentHeight()
+ {
+     Q_Q(QQuickContainer);
+-    if (hasContentHeight || qFuzzyCompare(contentHeight, implicitContentHeight))
++    if (hasContentHeight || qFuzzyCompare(contentHeight, implicitContentHeight) || !contentModel)
+         return;
+ 
+     contentHeight = implicitContentHeight;
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp b/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
+index bbbd0e622..1f4b47343 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
+@@ -845,6 +845,13 @@ void QQuickControlPrivate::executeBackground(bool complete)
+         quickCompleteDeferred(q, backgroundName(), background);
+ }
+ 
++/*
++    \internal
++
++    Hides an item that was replaced by a newer one, rather than
++    deleting it, as the item is typically created in QML and hence
++    we don't own it.
++*/
+ void QQuickControlPrivate::hideOldItem(QQuickItem *item)
+ {
+     if (!item)
+@@ -863,6 +870,29 @@ void QQuickControlPrivate::hideOldItem(QQuickItem *item)
+ #endif
+ }
+ 
++/*
++    \internal
++
++    Named "unhide" because it's used for cases where an item
++    that was previously hidden by \l hideOldItem() wants to be
++    shown by a control again, such as a ScrollBar in ScrollView.
++*/
++void QQuickControlPrivate::unhideOldItem(QQuickControl *control, QQuickItem *item)
++{
++    Q_ASSERT(item);
++    qCDebug(lcItemManagement) << "unhiding old item" << item;
++
++    item->setVisible(true);
++    item->setParentItem(control);
++
++#if QT_CONFIG(accessibility)
++    // Add the item back in to the accessibility tree.
++    QQuickAccessibleAttached *accessible = accessibleAttached(item);
++    if (accessible)
++        accessible->setIgnored(false);
++#endif
++}
++
+ void QQuickControlPrivate::updateBaselineOffset()
+ {
+     Q_Q(QQuickControl);
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h b/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
+index 8e979079e..a6e624c91 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
+@@ -173,6 +173,7 @@ public:
+     virtual void executeBackground(bool complete = false);
+ 
+     static void hideOldItem(QQuickItem *item);
++    static void unhideOldItem(QQuickControl *control, QQuickItem *item);
+ 
+     void updateBaselineOffset();
+ 
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp b/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
+index e6db14eb5..6197d1547 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
+@@ -237,7 +237,7 @@ static QRectF alignedRect(Qt::LayoutDirection direction, Qt::Alignment alignment
+ void QQuickDialogButtonBoxPrivate::resizeContent()
+ {
+     Q_Q(QQuickDialogButtonBox);
+-    if (!contentItem)
++    if (!contentItem || !contentModel)
+         return;
+ 
+     QRectF geometry = q->boundingRect().adjusted(q->leftPadding(), q->topPadding(), -q->rightPadding(), -q->bottomPadding());
+@@ -322,6 +322,9 @@ void QQuickDialogButtonBoxPrivate::updateLayout()
+ qreal QQuickDialogButtonBoxPrivate::getContentWidth() const
+ {
+     Q_Q(const QQuickDialogButtonBox);
++    if (!contentModel)
++        return 0;
++
+     const int count = contentModel->count();
+     const qreal totalSpacing = qMax(0, count - 1) * spacing;
+     qreal totalWidth = totalSpacing;
+@@ -341,6 +344,9 @@ qreal QQuickDialogButtonBoxPrivate::getContentWidth() const
+ qreal QQuickDialogButtonBoxPrivate::getContentHeight() const
+ {
+     Q_Q(const QQuickDialogButtonBox);
++    if (!contentModel)
++        return 0;
++
+     const int count = contentModel->count();
+     qreal maxHeight = 0;
+     for (int i = 0; i < count; ++i) {
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp b/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
+index 91bd59184..0ce518f84 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
+@@ -399,8 +399,11 @@ void QQuickOverlay::itemChange(ItemChange change, const ItemChangeData &data)
+     Q_D(QQuickOverlay);
+     QQuickItem::itemChange(change, data);
+ 
+-    if (change == ItemChildAddedChange || change == ItemChildRemovedChange)
++    if (change == ItemChildAddedChange || change == ItemChildRemovedChange) {
+         setVisible(!d->allDrawers.isEmpty() || !childItems().isEmpty());
++        if (data.item->parent() == d->mouseGrabberPopup)
++            d->setMouseGrabberPopup(nullptr);
++    }
+ }
+ 
+ void QQuickOverlay::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp b/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
+index 4e2f509db..1c4b308cd 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
+@@ -797,6 +797,14 @@ void QQuickScrollBarAttachedPrivate::initHorizontal()
+     if (parent && parent == flickable->parentItem())
+         horizontal->stackAfter(flickable);
+ 
++    // If a scroll bar was previously hidden (due to e.g. setting a new contentItem
++    // on a ScrollView), we need to make sure that we un-hide it.
++    // We don't bother checking if the item is actually the old one, because
++    // if it's not, all of the things the function does (setting parent, visibility, etc.)
++    // should be no-ops anyway.
++    if (auto control = qobject_cast<QQuickControl*>(q_ptr->parent()))
++        QQuickControlPrivate::unhideOldItem(control, horizontal);
++
+     layoutHorizontal();
+     horizontal->setSize(area->property("widthRatio").toReal());
+     horizontal->setPosition(area->property("xPosition").toReal());
+@@ -818,6 +826,9 @@ void QQuickScrollBarAttachedPrivate::initVertical()
+     if (parent && parent == flickable->parentItem())
+         vertical->stackAfter(flickable);
+ 
++    if (auto control = qobject_cast<QQuickControl*>(q_ptr->parent()))
++        QQuickControlPrivate::unhideOldItem(control, vertical);
++
+     layoutVertical();
+     vertical->setSize(area->property("heightRatio").toReal());
+     vertical->setPosition(area->property("yPosition").toReal());
+diff --git a/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml b/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
+index 0e8b08352..cd4931184 100644
+--- a/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
++++ b/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
+@@ -576,4 +576,51 @@ TestCase {
+         verify(newHorizontalScrollBar.visible)
+         verify(!oldHorizontalScrollBar.visible)
+     }
++
++    Component {
++        id: bindingToContentItemAndStandaloneFlickable
++
++        Item {
++            width: 200
++            height: 200
++
++            property alias scrollView: scrollView
++
++            ScrollView {
++                id: scrollView
++                anchors.fill: parent
++                contentItem: listView
++
++                property Item someBinding: contentItem
++            }
++            ListView {
++                id: listView
++                model: 10
++                delegate: ItemDelegate {
++                    text: modelData
++                    width: listView.width
++                }
++            }
++        }
++    }
++
++    // Tests that scroll bars show up for a ScrollView where
++    // - its contentItem is declared as a standalone, separate item
++    // - there is a binding to contentItem (which causes a default Flickable to be created)
++    function test_bindingToContentItemAndStandaloneFlickable() {
++        let root = createTemporaryObject(bindingToContentItemAndStandaloneFlickable, testCase)
++        verify(root)
++
++        let control = root.scrollView
++        let verticalScrollBar = control.ScrollBar.vertical
++        let horizontalScrollBar = control.ScrollBar.horizontal
++        compare(verticalScrollBar.parent, control)
++        compare(horizontalScrollBar.parent, control)
++        verify(verticalScrollBar.visible)
++        verify(horizontalScrollBar.visible)
++
++        mouseDrag(verticalScrollBar, verticalScrollBar.width / 2, verticalScrollBar.height / 2, 0, 50)
++        verify(verticalScrollBar.active)
++        verify(horizontalScrollBar.active)
++    }
+ }
+diff --git a/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml b/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
+index b3fab41ca..10b6baa02 100644
+--- a/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
++++ b/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
+@@ -608,4 +608,27 @@ TestCase {
+         mouseClick(control.indicator)
+         verify(control.activeFocus)
+     }
++
++    Component {
++        id: deletionOrder1
++        Item {
++            Image { id: innerImage }
++            Switch { indicator: innerImage }
++        }
++    }
++
++    Component {
++        id: deletionOrder2
++        Item {
++            Switch { indicator: innerImage }
++            Image { id: innerImage }
++        }
++    }
++
++    function test_deletionOrder() {
++        var control1 = createTemporaryObject(deletionOrder1, testCase)
++        verify(control1)
++        var control2 = createTemporaryObject(deletionOrder2, testCase)
++        verify(control2)
++    }
+ }
+diff --git a/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml b/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml
+new file mode 100644
+index 000000000..9e4598b9f
+--- /dev/null
++++ b/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml
+@@ -0,0 +1,78 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the test suite of the Qt Toolkit.
++**
++** $QT_BEGIN_LICENSE:BSD$
++** Commercial License Usage
++** Licensees holding valid commercial Qt licenses may use this file in
++** accordance with the commercial license agreement provided with the
++** Software or, alternatively, in accordance with the terms contained in
++** a written agreement between you and The Qt Company. For licensing terms
++** and conditions see https://www.qt.io/terms-conditions. For further
++** information use the contact form at https://www.qt.io/contact-us.
++**
++** BSD License Usage
++** Alternatively, you may use this file under the terms of the BSD license
++** as follows:
++**
++** "Redistribution and use in source and binary forms, with or without
++** modification, are permitted provided that the following conditions are
++** met:
++**   * Redistributions of source code must retain the above copyright
++**     notice, this list of conditions and the following disclaimer.
++**   * Redistributions in binary form must reproduce the above copyright
++**     notice, this list of conditions and the following disclaimer in
++**     the documentation and/or other materials provided with the
++**     distribution.
++**   * Neither the name of The Qt Company Ltd nor the names of its
++**     contributors may be used to endorse or promote products derived
++**     from this software without specific prior written permission.
++**
++**
++** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
++** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
++** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
++** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
++** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
++** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
++** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
++** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
++** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
++** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
++** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
++**
++** $QT_END_LICENSE$
++**
++****************************************************************************/
++
++import QtQuick 2.15
++import QtQuick.Controls 2.15
++
++ApplicationWindow {
++    id: window
++    width: 400
++    height: 400
++    title: "releaseAfterExitTransition"
++
++    property alias popup: popup
++    property alias modalPopup: modalPopup
++
++    Popup {
++        id: popup
++        y: parent.height - height
++        width: 50
++        height: 50
++    }
++
++    Popup {
++        id: modalPopup
++        modal: true
++        y: parent.height - height
++        width: 50
++        height: 50
++        exit:  Transition { PauseAnimation { duration: 100 } }
++    }
++}
+diff --git a/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp b/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
+index 54952d128..3d50e2dd4 100644
+--- a/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
++++ b/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
+@@ -100,6 +100,7 @@ private slots:
+     void invisibleToolTipOpen();
+     void centerInOverlayWithinStackViewItem();
+     void destroyDuringExitTransition();
++    void releaseAfterExitTransition();
+ };
+ 
+ void tst_QQuickPopup::initTestCase()
+@@ -1575,6 +1576,34 @@ void tst_QQuickPopup::destroyDuringExitTransition()
+     QVERIFY(!button->isDown());
+ }
+ 
++void tst_QQuickPopup::releaseAfterExitTransition()
++{
++    QQuickApplicationHelper helper(this, "releaseAfterExitTransition.qml");
++    QVERIFY2(helper.ready, helper.failureMessage());
++
++    QQuickWindow *window = helper.window;
++    window->show();
++    QVERIFY(QTest::qWaitForWindowActive(window));
++
++    QQuickOverlay *overlay = QQuickOverlay::overlay(window);
++    QQuickPopup *modalPopup = window->property("modalPopup").value<QQuickPopup *>();
++    QQuickPopup *popup = window->property("popup").value<QQuickPopup *>();
++
++    modalPopup->open();
++    QTRY_VERIFY(modalPopup->isOpened());
++
++    QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++    // wait until the transition is finished and the overlay hides itself
++    QTRY_VERIFY(!overlay->isVisible());
++    QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++
++    popup->open();
++    QTRY_VERIFY(popup->isOpened());
++    QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++    QTRY_VERIFY(!popup->isOpened());
++}
++
++
+ QTEST_QUICKCONTROLS_MAIN(tst_QQuickPopup)
+ 
+ #include "tst_qquickpopup.moc"
+Submodule qtscript 5be95f96...4d8e4bd2 (commits not present)
+Submodule qtspeech 17fc9fde..255845e2:
+diff --git a/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp b/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
+index 6eb74b8..bcc7dd1 100644
+--- a/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
++++ b/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
+@@ -357,7 +357,9 @@ QVector<QLocale> QTextToSpeechEngineSpeechd::availableLocales() const
+ 
+ QVector<QVoice> QTextToSpeechEngineSpeechd::availableVoices() const
+ {
+-    return m_voices.values(m_currentLocale.name()).toVector();
++    QList<QVoice> resultList = m_voices.values(m_currentLocale.name());
++    std::reverse(resultList.begin(), resultList.end());
++    return resultList.toVector();
+ }
+ 
+ // We have no way of knowing our own client_id since speech-dispatcher seems to be incomplete
+Submodule qtsvg 0c05780e..a7a0f249:
+diff --git a/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp b/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
+index 561e77e..12e0574 100644
+--- a/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
++++ b/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
+@@ -191,6 +191,8 @@ bool QSvgIOHandler::read(QImage *image)
+             }
+         }
+         if (!finalSize.isEmpty()) {
++            if (qMax(finalSize.width(), finalSize.height()) > 0xffff)
++                return false; // Assume corrupted file
+             image->fill(d->backColor.rgba());
+             QPainter p(image);
+             d->r.render(&p, bounds);
+diff --git a/qtsvg/src/svg/qsvghandler.cpp b/qtsvg/src/svg/qsvghandler.cpp
+index a5f877f..8dda563 100644
+--- a/qtsvg/src/svg/qsvghandler.cpp
++++ b/qtsvg/src/svg/qsvghandler.cpp
+@@ -1393,9 +1393,10 @@ static void parseFont(QSvgNode *node,
+         case FontSizeNone:
+             break;
+         case FontSizeValue: {
+-            QSvgHandler::LengthType dummy; // should always be pixel size
+-            fontStyle->setSize(qMin(parseLength(attributes.fontSize, dummy, handler),
+-                                    qreal(0xffff)));
++            QSvgHandler::LengthType type;
++            qreal fs = parseLength(attributes.fontSize, type, handler);
++            fs = convertToPixels(fs, true, type);
++            fontStyle->setSize(qMin(fs, qreal(0xffff)));
+         }
+             break;
+         default:
+@@ -2513,6 +2514,8 @@ static bool parseAnimateTransformNode(QSvgNode *parent,
+             ++s;
+         }
+     }
++    if (vals.count() % 3 != 0)
++        return false;
+ 
+     bool ok = true;
+     int begin = parseClockValue(beginStr, &ok);
+@@ -2576,6 +2579,8 @@ static QSvgNode *createCircleNode(QSvgNode *parent,
+     qreal ncx = toDouble(cx);
+     qreal ncy = toDouble(cy);
+     qreal nr  = toDouble(r);
++    if (nr < 0.0)
++        return nullptr;
+ 
+     QRectF rect(ncx-nr, ncy-nr, nr*2, nr*2);
+     QSvgNode *circle = new QSvgCircle(parent, rect);
+@@ -3046,15 +3051,16 @@ static QSvgStyleProperty *createRadialGradientNode(QSvgNode *node,
+ 
+     qreal ncx = 0.5;
+     qreal ncy = 0.5;
+-    qreal nr  = 0.5;
+     if (!cx.isEmpty())
+         ncx = toDouble(cx);
+     if (!cy.isEmpty())
+         ncy = toDouble(cy);
++
++    qreal nr = 0.0;
+     if (!r.isEmpty())
+         nr = toDouble(r);
+-    if (nr < 0.5)
+-        nr = 0.5;
++    if (nr <= 0.0)
++        return nullptr;
+ 
+     qreal nfx = ncx;
+     if (!fx.isEmpty())
+@@ -3350,7 +3356,9 @@ static QSvgNode *createTextNode(QSvgNode *parent,
+     //### editable and rotate not handled
+     QSvgHandler::LengthType type;
+     qreal nx = parseLength(x, type, handler);
++    nx = convertToPixels(nx, true, type);
+     qreal ny = parseLength(y, type, handler);
++    ny = convertToPixels(ny, true, type);
+ 
+     QSvgNode *text = new QSvgText(parent, QPointF(nx, ny));
+     return text;
+@@ -3691,9 +3699,7 @@ void QSvgHandler::parse()
+         case QXmlStreamReader::EndElement:
+             endElement(xml->name());
+             ++remainingUnfinishedElements;
+-            // if we are using somebody else's qxmlstreamreader
+-            // we should not read until the end of the stream
+-            done = !m_ownsReader && (xml->name() == QLatin1String("svg"));
++            done = (xml->name() == QLatin1String("svg"));
+             break;
+         case QXmlStreamReader::Characters:
+             characters(xml->text());
+diff --git a/qtsvg/src/svg/qsvgstructure.cpp b/qtsvg/src/svg/qsvgstructure.cpp
+index b89608b..89c9e4e 100644
+--- a/qtsvg/src/svg/qsvgstructure.cpp
++++ b/qtsvg/src/svg/qsvgstructure.cpp
+@@ -255,9 +255,13 @@ inline static bool isSupportedSvgFeature(const QString &str)
+     };
+ 
+     if (str.length() <= MAX_WORD_LENGTH && str.length() >= MIN_WORD_LENGTH) {
++        const char16_t unicode44 = str.at(44).unicode();
++        const char16_t unicode45 = str.at(45).unicode();
++        if (unicode44 >= sizeof(asso_values) || unicode45 >= sizeof(asso_values))
++            return false;
+         const int key = str.length()
+-                        + asso_values[str.at(45).unicode()]
+-                        + asso_values[str.at(44).unicode()];
++                        + asso_values[unicode45]
++                        + asso_values[unicode44];
+         if (key <= MAX_HASH_VALUE && key >= 0)
+             return str == QLatin1String(wordlist[key]);
+     }
+diff --git a/qtsvg/src/svg/qsvgtinydocument.cpp b/qtsvg/src/svg/qsvgtinydocument.cpp
+index 63d0797..19e7154 100644
+--- a/qtsvg/src/svg/qsvgtinydocument.cpp
++++ b/qtsvg/src/svg/qsvgtinydocument.cpp
+@@ -433,8 +433,16 @@ void QSvgTinyDocument::draw(QPainter *p, QSvgExtraStates &)
+     draw(p);
+ }
+ 
++static bool isValidMatrix(const QTransform &transform)
++{
++    qreal determinant = transform.determinant();
++    return qIsFinite(determinant);
++}
++
+ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect, const QRectF &sourceRect)
+ {
++    QTransform oldTransform = p->worldTransform();
++
+     QRectF target = targetRect;
+     if (target.isEmpty()) {
+         QPaintDevice *dev = p->device();
+@@ -487,6 +495,9 @@ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect,
+         }
+ #endif
+     }
++
++    if (!isValidMatrix(p->worldTransform()))
++        p->setWorldTransform(oldTransform);
+ }
+ 
+ QRectF QSvgTinyDocument::boundsOnElement(const QString &id) const
+diff --git a/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp b/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
+index 36c76ec..db71e02 100644
+--- a/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
++++ b/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
+@@ -86,6 +86,8 @@ private slots:
+     void oss_fuzz_23731();
+     void oss_fuzz_24131();
+     void oss_fuzz_24738();
++    void illegalAnimateTransform_data();
++    void illegalAnimateTransform();
+ 
+ #ifndef QT_NO_COMPRESS
+     void testGzLoading();
+@@ -1646,5 +1648,22 @@ void tst_QSvgRenderer::oss_fuzz_24738()
+     QSvgRenderer().load(QByteArray("<svg><path d=\"a 2 1e-212.....\">"));
+ }
+ 
++void tst_QSvgRenderer::illegalAnimateTransform_data()
++{
++    QTest::addColumn<QByteArray>("svg");
++
++    QTest::newRow("case1") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" values=\"8,0,5,0\">");
++    QTest::newRow("case2") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" values=\"1,2\">");
++    QTest::newRow("case3") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" from=\".. 5 2\" to=\"f\">");
++    QTest::newRow("case4") << QByteArray("<svg><animateTransform type=\"scale\" begin=\"1\" dur=\"2\" by=\"--,..\">");
++}
++
++void tst_QSvgRenderer::illegalAnimateTransform()
++{
++    QFETCH(QByteArray, svg);
++    QSvgRenderer renderer;
++    QVERIFY(!renderer.load(svg)); // also shouldn't assert
++}
++
+ QTEST_MAIN(tst_QSvgRenderer)
+ #include "tst_qsvgrenderer.moc"
+Submodule qttools 6914f7c8..090e526e:
+diff --git a/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp b/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
+index feab1e2d5..cbfb82507 100644
+--- a/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
++++ b/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
+@@ -445,7 +445,9 @@ bool HelpGeneratorPrivate::insertFiles(const QStringList &files, const QString &
+     if (filterSetId < 0)
+         return false;
+     ++filterSetId;
+-    for (int attId : qAsConst(filterAtts)) {
++    QList<int> attValues = filterAtts.values();
++    std::sort(attValues.begin(), attValues.end());
++    for (int attId : qAsConst(attValues)) {
+         m_query->prepare(QLatin1String("INSERT INTO FileAttributeSetTable "
+             "VALUES(?, ?)"));
+         m_query->bindValue(0, filterSetId);
+Submodule qtwayland dfb0129c..2904e1b3:
+diff --git a/qtwayland/src/client/configure.json b/qtwayland/src/client/configure.json
+index 2f424580..29222357 100644
+--- a/qtwayland/src/client/configure.json
++++ b/qtwayland/src/client/configure.json
+@@ -149,8 +149,7 @@
+                     "#endif"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "vulkan-server-buffer": {
+             "label": "Vulkan Buffer Sharing",
+@@ -168,7 +167,8 @@
+                     "exportAllocInfo.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR;",
+                     "return 0;"
+                 ]
+-            }
++            },
++            "use": "wayland-client"
+         },
+         "egl_1_5-wayland": {
+             "label": "EGL 1.5 with Wayland Platform",
+@@ -183,7 +183,7 @@
+                     "eglGetPlatformDisplay(EGL_PLATFORM_WAYLAND_EXT, (struct wl_display *)(nullptr), nullptr);"
+                 ]
+             },
+-            "use": "egl"
++            "use": "egl wayland-client"
+         }
+     },
+ 
+diff --git a/qtwayland/src/client/global/qwaylandclientextension.cpp b/qtwayland/src/client/global/qwaylandclientextension.cpp
+index 125b1e19..edccfe63 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension.cpp
++++ b/qtwayland/src/client/global/qwaylandclientextension.cpp
+@@ -74,7 +74,10 @@ void QWaylandClientExtensionPrivate::handleRegistryGlobal(void *data, ::wl_regis
+ void QWaylandClientExtension::addRegistryListener()
+ {
+     Q_D(QWaylandClientExtension);
+-    d->waylandIntegration->display()->addRegistryListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++    if (!d->registered) {
++        d->waylandIntegration->display()->addRegistryListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++        d->registered = true;
++    }
+ }
+ 
+ QWaylandClientExtension::QWaylandClientExtension(const int ver)
+@@ -88,6 +91,13 @@ QWaylandClientExtension::QWaylandClientExtension(const int ver)
+     QMetaObject::invokeMethod(this, "addRegistryListener", Qt::QueuedConnection);
+ }
+ 
++QWaylandClientExtension::~QWaylandClientExtension()
++{
++    Q_D(QWaylandClientExtension);
++    if (d->registered && !QCoreApplication::closingDown())
++        d->waylandIntegration->display()->removeListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++}
++
+ QtWaylandClient::QWaylandIntegration *QWaylandClientExtension::integration() const
+ {
+     Q_D(const QWaylandClientExtension);
+diff --git a/qtwayland/src/client/global/qwaylandclientextension.h b/qtwayland/src/client/global/qwaylandclientextension.h
+index 98272e57..5bd28398 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension.h
++++ b/qtwayland/src/client/global/qwaylandclientextension.h
+@@ -63,6 +63,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandClientExtension : public QObject
+     Q_PROPERTY(bool active READ isActive NOTIFY activeChanged)
+ public:
+     QWaylandClientExtension(const int version);
++    ~QWaylandClientExtension();
+ 
+     QtWaylandClient::QWaylandIntegration *integration() const;
+     int version() const;
+diff --git a/qtwayland/src/client/global/qwaylandclientextension_p.h b/qtwayland/src/client/global/qwaylandclientextension_p.h
+index 69cc46a0..9091efbe 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension_p.h
++++ b/qtwayland/src/client/global/qwaylandclientextension_p.h
+@@ -68,6 +68,7 @@ public:
+     QtWaylandClient::QWaylandIntegration *waylandIntegration = nullptr;
+     int version = -1;
+     bool active = false;
++    bool registered = false;
+ };
+ 
+ class Q_WAYLAND_CLIENT_EXPORT QWaylandClientExtensionTemplatePrivate : public QWaylandClientExtensionPrivate
+diff --git a/qtwayland/src/client/qwaylanddatadevice.cpp b/qtwayland/src/client/qwaylanddatadevice.cpp
+index 7e2e3308..e3e60ed5 100644
+--- a/qtwayland/src/client/qwaylanddatadevice.cpp
++++ b/qtwayland/src/client/qwaylanddatadevice.cpp
+@@ -72,6 +72,8 @@ QWaylandDataDevice::QWaylandDataDevice(QWaylandDataDeviceManager *manager, QWayl
+ 
+ QWaylandDataDevice::~QWaylandDataDevice()
+ {
++    if (wl_data_device_get_version(object()) >= WL_DATA_DEVICE_RELEASE_SINCE_VERSION)
++        release();
+ }
+ 
+ QWaylandDataOffer *QWaylandDataDevice::selectionOffer() const
+@@ -110,7 +112,7 @@ QWaylandDataOffer *QWaylandDataDevice::dragOffer() const
+     return m_dragOffer.data();
+ }
+ 
+-bool QWaylandDataDevice::startDrag(QMimeData *mimeData, QWaylandWindow *icon)
++bool QWaylandDataDevice::startDrag(QMimeData *mimeData, Qt::DropActions supportedActions, QWaylandWindow *icon)
+ {
+     auto *seat = m_display->currentInputDevice();
+     auto *origin = seat->pointerFocus();
+@@ -123,7 +125,28 @@ bool QWaylandDataDevice::startDrag(QMimeData *mimeData, QWaylandWindow *icon)
+     }
+ 
+     m_dragSource.reset(new QWaylandDataSource(m_display->dndSelectionHandler(), mimeData));
++
++    if (wl_data_device_get_version(object()) >= 3)
++        m_dragSource->set_actions(dropActionsToWl(supportedActions));
++
+     connect(m_dragSource.data(), &QWaylandDataSource::cancelled, this, &QWaylandDataDevice::dragSourceCancelled);
++    connect(m_dragSource.data(), &QWaylandDataSource::dndResponseUpdated, this, [this](bool accepted, Qt::DropAction action) {
++            auto drag = static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag());
++            // in old versions drop action is not set, so we guess
++            if (wl_data_source_get_version(m_dragSource->object()) < 3) {
++                drag->setResponse(accepted);
++            } else {
++                QPlatformDropQtResponse response(accepted, action);
++                drag->setResponse(response);
++            }
++    });
++    connect(m_dragSource.data(), &QWaylandDataSource::dndDropped, this, [](bool accepted, Qt::DropAction action) {
++        QPlatformDropQtResponse response(accepted, action);
++        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setDropResponse(response);
++    });
++    connect(m_dragSource.data(), &QWaylandDataSource::finished, this, []() {
++        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag();
++    });
+ 
+     start_drag(m_dragSource->object(), origin->wlSurface(), icon->wlSurface(), m_display->currentInputDevice()->serial());
+     return true;
+@@ -152,7 +175,7 @@ void QWaylandDataDevice::data_device_drop()
+         supportedActions = drag->supportedActions();
+     } else if (m_dragOffer) {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     } else {
+         return;
+     }
+@@ -162,7 +185,11 @@ void QWaylandDataDevice::data_device_drop()
+                                                                           QGuiApplication::keyboardModifiers());
+ 
+     if (drag) {
+-        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag(response);
++        auto drag =  static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag());
++        drag->setDropResponse(response);
++        drag->finishDrag();
++    } else if (m_dragOffer) {
++        m_dragOffer->finish();
+     }
+ }
+ 
+@@ -186,7 +213,7 @@ void QWaylandDataDevice::data_device_enter(uint32_t serial, wl_surface *surface,
+         supportedActions = drag->supportedActions();
+     } else if (m_dragOffer) {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     }
+ 
+     const QPlatformDragQtResponse &response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
+@@ -197,11 +224,7 @@ void QWaylandDataDevice::data_device_enter(uint32_t serial, wl_surface *surface,
+         static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setResponse(response);
+     }
+ 
+-    if (response.isAccepted()) {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, m_dragOffer->firstFormat().toUtf8().constData());
+-    } else {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, nullptr);
+-    }
++    sendResponse(supportedActions, response);
+ }
+ 
+ void QWaylandDataDevice::data_device_leave()
+@@ -235,10 +258,10 @@ void QWaylandDataDevice::data_device_motion(uint32_t time, wl_fixed_t x, wl_fixe
+         supportedActions = drag->supportedActions();
+     } else {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     }
+ 
+-    QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
++    const QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
+                                                                           QGuiApplication::mouseButtons(),
+                                                                           QGuiApplication::keyboardModifiers());
+ 
+@@ -246,11 +269,7 @@ void QWaylandDataDevice::data_device_motion(uint32_t time, wl_fixed_t x, wl_fixe
+         static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setResponse(response);
+     }
+ 
+-    if (response.isAccepted()) {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, m_dragOffer->firstFormat().toUtf8().constData());
+-    } else {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, nullptr);
+-    }
++    sendResponse(supportedActions, response);
+ }
+ #endif // QT_CONFIG(draganddrop)
+ 
+@@ -277,14 +296,10 @@ void QWaylandDataDevice::selectionSourceCancelled()
+ #if QT_CONFIG(draganddrop)
+ void QWaylandDataDevice::dragSourceCancelled()
+ {
++    static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag();
+     m_dragSource.reset();
+ }
+ 
+-void QWaylandDataDevice::dragSourceTargetChanged(const QString &mimeType)
+-{
+-    static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->updateTarget(mimeType);
+-}
+-
+ QPoint QWaylandDataDevice::calculateDragPosition(int x, int y, QWindow *wnd) const
+ {
+     QPoint pnt(wl_fixed_to_int(x), wl_fixed_to_int(y));
+@@ -297,6 +312,33 @@ QPoint QWaylandDataDevice::calculateDragPosition(int x, int y, QWindow *wnd) con
+     }
+     return pnt;
+ }
++
++void QWaylandDataDevice::sendResponse(Qt::DropActions supportedActions, const QPlatformDragQtResponse &response)
++{
++    if (response.isAccepted()) {
++        if (wl_data_device_get_version(object()) >= 3)
++            m_dragOffer->set_actions(dropActionsToWl(supportedActions), dropActionsToWl(response.acceptedAction()));
++
++        m_dragOffer->accept(m_enterSerial, m_dragOffer->firstFormat());
++    } else {
++        m_dragOffer->accept(m_enterSerial, QString());
++    }
++}
++
++int QWaylandDataDevice::dropActionsToWl(Qt::DropActions actions)
++{
++
++    int wlActions = WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE;
++    if (actions & Qt::CopyAction)
++        wlActions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY;
++    if (actions & (Qt::MoveAction | Qt::TargetMoveAction))
++        wlActions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE;
++
++    // wayland does not support LinkAction at the time of writing
++    return wlActions;
++}
++
++
+ #endif // QT_CONFIG(draganddrop)
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddatadevice_p.h b/qtwayland/src/client/qwaylanddatadevice_p.h
+index 16c3ad28..801dcc2c 100644
+--- a/qtwayland/src/client/qwaylanddatadevice_p.h
++++ b/qtwayland/src/client/qwaylanddatadevice_p.h
+@@ -64,6 +64,7 @@ QT_REQUIRE_CONFIG(wayland_datadevice);
+ QT_BEGIN_NAMESPACE
+ 
+ class QMimeData;
++class QPlatformDragQtResponse;
+ class QWindow;
+ 
+ namespace QtWaylandClient {
+@@ -89,7 +90,7 @@ public:
+ 
+ #if QT_CONFIG(draganddrop)
+     QWaylandDataOffer *dragOffer() const;
+-    bool startDrag(QMimeData *mimeData, QWaylandWindow *icon);
++    bool startDrag(QMimeData *mimeData, Qt::DropActions supportedActions, QWaylandWindow *icon);
+     void cancelDrag();
+ #endif
+ 
+@@ -109,13 +110,16 @@ private Q_SLOTS:
+ 
+ #if QT_CONFIG(draganddrop)
+     void dragSourceCancelled();
+-    void dragSourceTargetChanged(const QString &mimeType);
+ #endif
+ 
+ private:
+ #if QT_CONFIG(draganddrop)
+     QPoint calculateDragPosition(int x, int y, QWindow *wnd) const;
+ #endif
++    void sendResponse(Qt::DropActions supportedActions, const QPlatformDragQtResponse &response);
++
++    static int dropActionsToWl(Qt::DropActions dropActions);
++
+ 
+     QWaylandDisplay *m_display = nullptr;
+     QWaylandInputDevice *m_inputDevice = nullptr;
+diff --git a/qtwayland/src/client/qwaylanddatadevicemanager.cpp b/qtwayland/src/client/qwaylanddatadevicemanager.cpp
+index 35d67307..6dc4f77f 100644
+--- a/qtwayland/src/client/qwaylanddatadevicemanager.cpp
++++ b/qtwayland/src/client/qwaylanddatadevicemanager.cpp
+@@ -50,8 +50,8 @@ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
+-QWaylandDataDeviceManager::QWaylandDataDeviceManager(QWaylandDisplay *display, uint32_t id)
+-    : wl_data_device_manager(display->wl_registry(), id, 1)
++QWaylandDataDeviceManager::QWaylandDataDeviceManager(QWaylandDisplay *display, int version, uint32_t id)
++    : wl_data_device_manager(display->wl_registry(), id, qMin(version, 3))
+     , m_display(display)
+ {
+     // Create transfer devices for all input devices.
+diff --git a/qtwayland/src/client/qwaylanddatadevicemanager_p.h b/qtwayland/src/client/qwaylanddatadevicemanager_p.h
+index bd05c0fb..510d9be4 100644
+--- a/qtwayland/src/client/qwaylanddatadevicemanager_p.h
++++ b/qtwayland/src/client/qwaylanddatadevicemanager_p.h
+@@ -68,7 +68,7 @@ class QWaylandInputDevice;
+ class Q_WAYLAND_CLIENT_EXPORT QWaylandDataDeviceManager : public QtWayland::wl_data_device_manager
+ {
+ public:
+-    QWaylandDataDeviceManager(QWaylandDisplay *display, uint32_t id);
++    QWaylandDataDeviceManager(QWaylandDisplay *display, int version, uint32_t id);
+     ~QWaylandDataDeviceManager() override;
+ 
+     QWaylandDataDevice *getDataDevice(QWaylandInputDevice *inputDevice);
+diff --git a/qtwayland/src/client/qwaylanddataoffer.cpp b/qtwayland/src/client/qwaylanddataoffer.cpp
+index 2297e8a1..fe0ea8c9 100644
+--- a/qtwayland/src/client/qwaylanddataoffer.cpp
++++ b/qtwayland/src/client/qwaylanddataoffer.cpp
+@@ -82,6 +82,15 @@ QMimeData *QWaylandDataOffer::mimeData()
+     return m_mimeData.data();
+ }
+ 
++Qt::DropActions QWaylandDataOffer::supportedActions() const
++{
++    if (wl_data_offer_get_version(const_cast<::wl_data_offer*>(object())) < 3) {
++        return Qt::MoveAction | Qt::CopyAction;
++    }
++
++    return m_supportedActions;
++}
++
+ void QWaylandDataOffer::startReceiving(const QString &mimeType, int fd)
+ {
+     receive(mimeType, fd);
+@@ -93,6 +102,22 @@ void QWaylandDataOffer::data_offer_offer(const QString &mime_type)
+     m_mimeData->appendFormat(mime_type);
+ }
+ 
++void QWaylandDataOffer::data_offer_action(uint32_t dnd_action)
++{
++    Q_UNUSED(dnd_action);
++    // This is the compositor telling the drag target what action it should perform
++    // It does not map nicely into Qt final drop semantics, other than pretending there is only one supported action?
++}
++
++void QWaylandDataOffer::data_offer_source_actions(uint32_t source_actions)
++{
++    m_supportedActions = Qt::DropActions();
++    if (source_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
++        m_supportedActions |= Qt::MoveAction;
++    if (source_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
++        m_supportedActions |= Qt::CopyAction;
++}
++
+ QWaylandMimeData::QWaylandMimeData(QWaylandAbstractDataOffer *dataOffer)
+     : m_dataOffer(dataOffer)
+ {
+@@ -163,17 +188,18 @@ QVariant QWaylandMimeData::retrieveData_sys(const QString &mimeType, QVariant::T
+ 
+ int QWaylandMimeData::readData(int fd, QByteArray &data) const
+ {
+-    fd_set readset;
+-    FD_ZERO(&readset);
+-    FD_SET(fd, &readset);
+-    struct timeval timeout;
++    struct pollfd readset;
++    readset.fd = fd;
++    readset.events = POLLIN;
++    struct timespec timeout;
+     timeout.tv_sec = 1;
+-    timeout.tv_usec = 0;
++    timeout.tv_nsec = 0;
++
+ 
+     Q_FOREVER {
+-        int ready = select(FD_SETSIZE, &readset, nullptr, nullptr, &timeout);
++        int ready = qt_safe_poll(&readset, 1, &timeout);
+         if (ready < 0) {
+-            qWarning() << "QWaylandDataOffer: select() failed";
++            qWarning() << "QWaylandDataOffer: qt_safe_poll() failed";
+             return -1;
+         } else if (ready == 0) {
+             qWarning("QWaylandDataOffer: timeout reading from pipe");
+diff --git a/qtwayland/src/client/qwaylanddataoffer_p.h b/qtwayland/src/client/qwaylanddataoffer_p.h
+index 9cf1483c..6f667398 100644
+--- a/qtwayland/src/client/qwaylanddataoffer_p.h
++++ b/qtwayland/src/client/qwaylanddataoffer_p.h
+@@ -82,6 +82,7 @@ public:
+     explicit QWaylandDataOffer(QWaylandDisplay *display, struct ::wl_data_offer *offer);
+     ~QWaylandDataOffer() override;
+     QMimeData *mimeData() override;
++    Qt::DropActions supportedActions() const;
+ 
+     QString firstFormat() const;
+ 
+@@ -89,10 +90,13 @@ public:
+ 
+ protected:
+     void data_offer_offer(const QString &mime_type) override;
++    void data_offer_source_actions(uint32_t source_actions) override;
++    void data_offer_action(uint32_t dnd_action) override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+     QScopedPointer<QWaylandMimeData> m_mimeData;
++    Qt::DropActions m_supportedActions;
+ };
+ 
+ 
+diff --git a/qtwayland/src/client/qwaylanddatasource.cpp b/qtwayland/src/client/qwaylanddatasource.cpp
+index f45122fb..5599cbd4 100644
+--- a/qtwayland/src/client/qwaylanddatasource.cpp
++++ b/qtwayland/src/client/qwaylanddatasource.cpp
+@@ -101,7 +101,32 @@ void QWaylandDataSource::data_source_send(const QString &mime_type, int32_t fd)
+ 
+ void QWaylandDataSource::data_source_target(const QString &mime_type)
+ {
+-    Q_EMIT targetChanged(mime_type);
++    m_accepted = !mime_type.isEmpty();
++    Q_EMIT dndResponseUpdated(m_accepted, m_dropAction);
++}
++
++void QWaylandDataSource::data_source_action(uint32_t action)
++{
++    Qt::DropAction qtAction = Qt::IgnoreAction;
++
++    if (action == WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
++        qtAction = Qt::MoveAction;
++    else if (action == WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
++        qtAction = Qt::CopyAction;
++
++    m_dropAction = qtAction;
++    Q_EMIT dndResponseUpdated(m_accepted, m_dropAction);
++}
++
++void QWaylandDataSource::data_source_dnd_finished()
++{
++    Q_EMIT finished();
++}
++
++void QWaylandDataSource::data_source_dnd_drop_performed()
++{
++
++    Q_EMIT dndDropped(m_accepted, m_dropAction);
+ }
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddatasource_p.h b/qtwayland/src/client/qwaylanddatasource_p.h
+index 25afff79..96f07bc3 100644
+--- a/qtwayland/src/client/qwaylanddatasource_p.h
++++ b/qtwayland/src/client/qwaylanddatasource_p.h
+@@ -77,17 +77,25 @@ public:
+     QMimeData *mimeData() const;
+ 
+ Q_SIGNALS:
+-    void targetChanged(const QString &mime_type);
+     void cancelled();
++    void finished();
++
++    void dndResponseUpdated(bool accepted, Qt::DropAction action);
++    void dndDropped(bool accepted, Qt::DropAction action);
+ 
+ protected:
+     void data_source_cancelled() override;
+     void data_source_send(const QString &mime_type, int32_t fd) override;
+     void data_source_target(const QString &mime_type) override;
++    void data_source_dnd_drop_performed() override;
++    void data_source_dnd_finished() override;
++    void data_source_action(uint32_t action) override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+     QMimeData *m_mime_data = nullptr;
++    bool m_accepted = false;
++    Qt::DropAction m_dropAction = Qt::IgnoreAction;
+ };
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddisplay.cpp b/qtwayland/src/client/qwaylanddisplay.cpp
+index f10c1f79..c01e238b 100644
+--- a/qtwayland/src/client/qwaylanddisplay.cpp
++++ b/qtwayland/src/client/qwaylanddisplay.cpp
+@@ -85,10 +85,203 @@
+ 
+ #include <errno.h>
+ 
++#include <tuple> // for std::tie
++
++static void checkWaylandError(struct wl_display *display)
++{
++    int ecode = wl_display_get_error(display);
++    if ((ecode == EPIPE || ecode == ECONNRESET)) {
++        // special case this to provide a nicer error
++        qWarning("The Wayland connection broke. Did the Wayland compositor die?");
++    } else {
++        qWarning("The Wayland connection experienced a fatal error: %s", strerror(ecode));
++    }
++    _exit(1);
++}
++
+ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
++class EventThread : public QThread
++{
++    Q_OBJECT
++public:
++    enum OperatingMode {
++        EmitToDispatch, // Emit the signal, allow dispatching in a differnt thread.
++        SelfDispatch, // Dispatch the events inside this thread.
++    };
++
++    EventThread(struct wl_display * wl, struct wl_event_queue * ev_queue,
++                OperatingMode mode)
++        : m_fd(wl_display_get_fd(wl))
++        , m_pipefd{ -1, -1 }
++        , m_wldisplay(wl)
++        , m_wlevqueue(ev_queue)
++        , m_mode(mode)
++        , m_reading(true)
++        , m_quitting(false)
++    {
++        setObjectName(QStringLiteral("WaylandEventThread"));
++    }
++
++    void readAndDispatchEvents()
++    {
++        /*
++         * Dispatch pending events and flush the requests at least once. If the event thread
++         * is not reading, try to call _prepare_read() to allow the event thread to poll().
++         * If that fails, re-try dispatch & flush again until _prepare_read() is successful.
++         *
++         * This allow any call to readAndDispatchEvents() to start event thread's polling,
++         * not only the one issued from event thread's waitForReading(), which means functions
++         * called from dispatch_pending() can safely spin an event loop.
++         */
++        for (;;) {
++            if (dispatchQueuePending() < 0) {
++                checkWaylandError(m_wldisplay);
++                return;
++            }
++
++            wl_display_flush(m_wldisplay);
++
++            // We have to check if event thread is reading every time we dispatch
++            // something, as that may recursively call this function.
++            if (m_reading.loadAcquire())
++                break;
++
++            if (prepareReadQueue() == 0) {
++                QMutexLocker l(&m_mutex);
++                m_reading.storeRelease(true);
++                m_cond.wakeOne();
++                break;
++            }
++        }
++    }
++
++    void stop()
++    {
++        // We have to both write to the pipe and set the flag, as the thread may be
++        // either in the poll() or waiting for _prepare_read().
++        if (m_pipefd[1] != -1 && write(m_pipefd[1], "\0", 1) == -1)
++            qWarning("Failed to write to the pipe: %s.", strerror(errno));
++
++        {
++            QMutexLocker l(&m_mutex);
++            m_quitting = true;
++            m_cond.wakeOne();
++        }
++
++        wait();
++    }
++
++Q_SIGNALS:
++    void needReadAndDispatch();
++
++protected:
++    void run() override
++    {
++        // we use this pipe to make the loop exit otherwise if we simply used a flag on the loop condition, if stop() gets
++        // called while poll() is blocking the thread will never quit since there are no wayland messages coming anymore.
++        struct Pipe
++        {
++            Pipe(int *fds)
++                : fds(fds)
++            {
++                if (qt_safe_pipe(fds) != 0)
++                    qWarning("Pipe creation failed. Quitting may hang.");
++            }
++            ~Pipe()
++            {
++                if (fds[0] != -1) {
++                    close(fds[0]);
++                    close(fds[1]);
++                }
++            }
++
++            int *fds;
++        } pipe(m_pipefd);
++
++        // Make the main thread call wl_prepare_read(), dispatch the pending messages and flush the
++        // outbound ones. Wait until it's done before proceeding, unless we're told to quit.
++        while (waitForReading()) {
++            pollfd fds[2] = { { m_fd, POLLIN, 0 }, { m_pipefd[0], POLLIN, 0 } };
++            poll(fds, 2, -1);
++
++            if (fds[1].revents & POLLIN) {
++                // we don't really care to read the byte that was written here since we're closing down
++                wl_display_cancel_read(m_wldisplay);
++                break;
++            }
++
++            if (fds[0].revents & POLLIN)
++                wl_display_read_events(m_wldisplay);
++                // The polll was succesfull and the event thread did the wl_display_read_events(). On the next iteration of the loop
++                // the event sent to the main thread will cause it to dispatch the messages just read, unless the loop exits in which
++                // case we don't care anymore about them.
++            else
++                wl_display_cancel_read(m_wldisplay);
++        }
++    }
++
++private:
++    bool waitForReading()
++    {
++        Q_ASSERT(QThread::currentThread() == this);
++
++        m_reading.storeRelease(false);
++
++        if (m_mode == SelfDispatch) {
++            readAndDispatchEvents();
++        } else {
++            Q_EMIT needReadAndDispatch();
++
++            QMutexLocker lock(&m_mutex);
++            // m_reading might be set from our emit or some other invocation of
++            // readAndDispatchEvents().
++            while (!m_reading.loadRelaxed() && !m_quitting)
++                m_cond.wait(&m_mutex);
++        }
++
++        return !m_quitting;
++    }
++
++    int dispatchQueuePending()
++    {
++        if (m_wlevqueue)
++            return wl_display_dispatch_queue_pending(m_wldisplay, m_wlevqueue);
++        else
++            return wl_display_dispatch_pending(m_wldisplay);
++    }
++
++    int prepareReadQueue()
++    {
++        if (m_wlevqueue)
++            return wl_display_prepare_read_queue(m_wldisplay, m_wlevqueue);
++        else
++            return wl_display_prepare_read(m_wldisplay);
++    }
++
++    int m_fd;
++    int m_pipefd[2];
++    wl_display *m_wldisplay;
++    wl_event_queue *m_wlevqueue;
++    OperatingMode m_mode;
++
++    /* Concurrency note when operating in EmitToDispatch mode:
++     * m_reading is set to false inside event thread's waitForReading(), and is
++     * set to true inside main thread's readAndDispatchEvents().
++     * The lock is not taken when setting m_reading to false, as the main thread
++     * is not actively waiting for it to turn false. However, the lock is taken
++     * inside readAndDispatchEvents() before setting m_reading to true,
++     * as the event thread is actively waiting for it under the wait condition.
++     */
++
++    QAtomicInteger<bool> m_reading;
++    bool m_quitting;
++    QMutex m_mutex;
++    QWaitCondition m_cond;
++};
++
+ Q_LOGGING_CATEGORY(lcQpaWayland, "qt.qpa.wayland"); // for general (uncategorized) Wayland platform logging
+ 
+ struct wl_surface *QWaylandDisplay::createSurface(void *handle)
+@@ -158,17 +351,16 @@ QWaylandDisplay::QWaylandDisplay(QWaylandIntegration *waylandIntegration)
+     if (!mXkbContext)
+         qCWarning(lcQpaWayland, "failed to create xkb context");
+ #endif
+-
+-    forceRoundTrip();
+-
+-    if (!mWaitingScreens.isEmpty()) {
+-        // Give wl_output.done and zxdg_output_v1.done events a chance to arrive
+-        forceRoundTrip();
+-    }
+ }
+ 
+ QWaylandDisplay::~QWaylandDisplay(void)
+ {
++    if (m_eventThread)
++        m_eventThread->stop();
++
++    if (m_frameEventQueueThread)
++        m_frameEventQueueThread->stop();
++
+     if (mSyncCallback)
+         wl_callback_destroy(mSyncCallback);
+ 
+@@ -187,6 +379,21 @@ QWaylandDisplay::~QWaylandDisplay(void)
+ #endif
+     if (mDisplay)
+         wl_display_disconnect(mDisplay);
++
++    if (m_frameEventQueue)
++        wl_event_queue_destroy(m_frameEventQueue);
++}
++
++// Steps which is called just after constructor. This separates registry_global() out of the constructor
++// so that factory functions in integration can be overridden.
++void QWaylandDisplay::initialize()
++{
++    forceRoundTrip();
++
++    if (!mWaitingScreens.isEmpty()) {
++        // Give wl_output.done and zxdg_output_v1.done events a chance to arrive
++        forceRoundTrip();
++    }
+ }
+ 
+ void QWaylandDisplay::ensureScreen()
+@@ -203,98 +410,37 @@ void QWaylandDisplay::ensureScreen()
+ 
+ void QWaylandDisplay::checkError() const
+ {
+-    int ecode = wl_display_get_error(mDisplay);
+-    if ((ecode == EPIPE || ecode == ECONNRESET)) {
+-        // special case this to provide a nicer error
+-        qWarning("The Wayland connection broke. Did the Wayland compositor die?");
+-    } else {
+-        qWarning("The Wayland connection experienced a fatal error: %s", strerror(ecode));
+-    }
+-    _exit(1);
++    checkWaylandError(mDisplay);
+ }
+ 
++// Called in main thread, either from queued signal or directly.
+ void QWaylandDisplay::flushRequests()
+ {
+-    if (wl_display_prepare_read(mDisplay) == 0) {
+-        wl_display_read_events(mDisplay);
+-    }
+-
+-    if (wl_display_dispatch_pending(mDisplay) < 0)
+-        checkError();
+-
+-    {
+-        QReadLocker locker(&m_frameQueueLock);
+-        for (const FrameQueue &q : mExternalQueues) {
+-            QMutexLocker locker(q.mutex);
+-            while (wl_display_prepare_read_queue(mDisplay, q.queue) != 0)
+-                wl_display_dispatch_queue_pending(mDisplay, q.queue);
+-            wl_display_read_events(mDisplay);
+-            wl_display_dispatch_queue_pending(mDisplay, q.queue);
+-        }
+-    }
+-
+-    wl_display_flush(mDisplay);
+-}
+-
+-void QWaylandDisplay::blockingReadEvents()
+-{
+-    if (wl_display_dispatch(mDisplay) < 0)
+-        checkError();
+-}
+-
+-void QWaylandDisplay::destroyFrameQueue(const QWaylandDisplay::FrameQueue &q)
+-{
+-    QWriteLocker locker(&m_frameQueueLock);
+-    auto it = std::find_if(mExternalQueues.begin(),
+-                           mExternalQueues.end(),
+-                           [&q] (const QWaylandDisplay::FrameQueue &other){ return other.queue == q.queue; });
+-    Q_ASSERT(it != mExternalQueues.end());
+-    mExternalQueues.erase(it);
+-    if (q.queue != nullptr)
+-        wl_event_queue_destroy(q.queue);
+-    delete q.mutex;
++    m_eventThread->readAndDispatchEvents();
+ }
+ 
+-QWaylandDisplay::FrameQueue QWaylandDisplay::createFrameQueue()
++// We have to wait until we have an eventDispatcher before creating the eventThread,
++// otherwise forceRoundTrip() may block inside _events_read() because eventThread is
++// polling.
++void QWaylandDisplay::initEventThread()
+ {
+-    QWriteLocker locker(&m_frameQueueLock);
+-    FrameQueue q{createEventQueue()};
+-    mExternalQueues.append(q);
+-    return q;
+-}
++    m_eventThread.reset(
++            new EventThread(mDisplay, /* default queue */ nullptr, EventThread::EmitToDispatch));
++    connect(m_eventThread.get(), &EventThread::needReadAndDispatch, this,
++            &QWaylandDisplay::flushRequests, Qt::QueuedConnection);
++    m_eventThread->start();
+ 
+-wl_event_queue *QWaylandDisplay::createEventQueue()
+-{
+-    return wl_display_create_queue(mDisplay);
++    // wl_display_disconnect() free this.
++    m_frameEventQueue = wl_display_create_queue(mDisplay);
++    m_frameEventQueueThread.reset(
++            new EventThread(mDisplay, m_frameEventQueue, EventThread::SelfDispatch));
++    m_frameEventQueueThread->start();
+ }
+ 
+-void QWaylandDisplay::dispatchQueueWhile(wl_event_queue *queue, std::function<bool ()> condition, int timeout)
++void QWaylandDisplay::blockingReadEvents()
+ {
+-    if (!condition())
+-        return;
+-
+-    QElapsedTimer timer;
+-    timer.start();
+-    struct pollfd pFd = qt_make_pollfd(wl_display_get_fd(mDisplay), POLLIN);
+-    while (timeout == -1 || timer.elapsed() < timeout) {
+-        while (wl_display_prepare_read_queue(mDisplay, queue) != 0)
+-            wl_display_dispatch_queue_pending(mDisplay, queue);
+-
+-        wl_display_flush(mDisplay);
+-
+-        const int remaining = qMax(timeout - timer.elapsed(), 0ll);
+-        const int pollTimeout = timeout == -1 ? -1 : remaining;
+-        if (qt_poll_msecs(&pFd, 1, pollTimeout) > 0)
+-            wl_display_read_events(mDisplay);
+-        else
+-            wl_display_cancel_read(mDisplay);
+-
+-        if (wl_display_dispatch_queue_pending(mDisplay, queue) < 0)
+-            checkError();
+-
+-        if (!condition())
+-            break;
+-    }
++    if (wl_display_dispatch(mDisplay) < 0)
++        checkWaylandError(mDisplay);
+ }
+ 
+ QWaylandScreen *QWaylandDisplay::screenForOutput(struct wl_output *output) const
+@@ -345,7 +491,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+     if (interface == QStringLiteral("wl_output")) {
+         mWaitingScreens << new QWaylandScreen(this, version, id);
+     } else if (interface == QStringLiteral("wl_compositor")) {
+-        mCompositorVersion = qMin((int)version, 3);
++        mCompositorVersion = qMin((int)version, 4);
+         mCompositor.init(registry, id, mCompositorVersion);
+     } else if (interface == QStringLiteral("wl_shm")) {
+         mShm.reset(new QWaylandShm(this, version, id));
+@@ -354,7 +500,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+         mInputDevices.append(inputDevice);
+ #if QT_CONFIG(wayland_datadevice)
+     } else if (interface == QStringLiteral("wl_data_device_manager")) {
+-        mDndSelectionHandler.reset(new QWaylandDataDeviceManager(this, id));
++        mDndSelectionHandler.reset(new QWaylandDataDeviceManager(this, version, id));
+ #endif
+     } else if (interface == QStringLiteral("qt_surface_extension")) {
+         mWindowExtension.reset(new QtWayland::qt_surface_extension(registry, id, 1));
+@@ -369,6 +515,8 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+ #if QT_CONFIG(wayland_client_primary_selection)
+     } else if (interface == QStringLiteral("zwp_primary_selection_device_manager_v1")) {
+         mPrimarySelectionManager.reset(new QWaylandPrimarySelectionDeviceManagerV1(this, id, 1));
++        for (QWaylandInputDevice *inputDevice : qAsConst(mInputDevices))
++            inputDevice->setPrimarySelectionDevice(mPrimarySelectionManager->createDevice(inputDevice));
+ #endif
+     } else if (interface == QStringLiteral("zwp_text_input_manager_v2") && !mClientSideInputContextRequested) {
+         mTextInputManager.reset(new QtWayland::zwp_text_input_manager_v2(registry, id, 1));
+@@ -427,6 +575,13 @@ void QWaylandDisplay::registry_global_remove(uint32_t id)
+                     inputDevice->setTextInput(nullptr);
+                 mWaylandIntegration->reconfigureInputContext();
+             }
++#if QT_CONFIG(wayland_client_primary_selection)
++            if (global.interface == QStringLiteral("zwp_primary_selection_device_manager_v1")) {
++                mPrimarySelectionManager.reset();
++                for (QWaylandInputDevice *inputDevice : qAsConst(mInputDevices))
++                    inputDevice->setPrimarySelectionDevice(nullptr);
++            }
++#endif
+             mGlobals.removeAt(i);
+             break;
+         }
+@@ -452,9 +607,10 @@ void QWaylandDisplay::addRegistryListener(RegistryListener listener, void *data)
+ 
+ void QWaylandDisplay::removeListener(RegistryListener listener, void *data)
+ {
+-    std::remove_if(mRegistryListeners.begin(), mRegistryListeners.end(), [=](Listener l){
++    auto iter = std::remove_if(mRegistryListeners.begin(), mRegistryListeners.end(), [=](Listener l){
+         return (l.listener == listener && l.data == data);
+     });
++    mRegistryListeners.erase(iter, mRegistryListeners.end());
+ }
+ 
+ uint32_t QWaylandDisplay::currentTimeMillisec()
+@@ -467,50 +623,9 @@ uint32_t QWaylandDisplay::currentTimeMillisec()
+     return 0;
+ }
+ 
+-static void
+-sync_callback(void *data, struct wl_callback *callback, uint32_t serial)
+-{
+-    Q_UNUSED(serial)
+-    bool *done = static_cast<bool *>(data);
+-
+-    *done = true;
+-
+-    // If the wl_callback done event is received after the condition check in the while loop in
+-    // forceRoundTrip(), but before the call to processEvents, the call to processEvents may block
+-    // forever if no more events are posted (eventhough the callback is handled in response to the
+-    // aboutToBlock signal). Hence, we wake up the event dispatcher so forceRoundTrip may return.
+-    // (QTBUG-64696)
+-    if (auto *dispatcher = QThread::currentThread()->eventDispatcher())
+-        dispatcher->wakeUp();
+-
+-    wl_callback_destroy(callback);
+-}
+-
+-static const struct wl_callback_listener sync_listener = {
+-    sync_callback
+-};
+-
+ void QWaylandDisplay::forceRoundTrip()
+ {
+-    // wl_display_roundtrip() works on the main queue only,
+-    // but we use a separate one, so basically reimplement it here
+-    int ret = 0;
+-    bool done = false;
+-    wl_callback *callback = wl_display_sync(mDisplay);
+-    wl_callback_add_listener(callback, &sync_listener, &done);
+-    flushRequests();
+-    if (QThread::currentThread()->eventDispatcher()) {
+-        while (!done && ret >= 0) {
+-            QThread::currentThread()->eventDispatcher()->processEvents(QEventLoop::WaitForMoreEvents);
+-            ret = wl_display_dispatch_pending(mDisplay);
+-        }
+-    } else {
+-        while (!done && ret >= 0)
+-            ret = wl_display_dispatch(mDisplay);
+-    }
+-
+-    if (ret == -1 && !done)
+-        wl_callback_destroy(callback);
++     wl_display_roundtrip(mDisplay);
+ }
+ 
+ bool QWaylandDisplay::supportsWindowDecoration() const
+@@ -574,14 +689,10 @@ void QWaylandDisplay::handleKeyboardFocusChanged(QWaylandInputDevice *inputDevic
+     if (mLastKeyboardFocus == keyboardFocus)
+         return;
+ 
+-    if (mWaylandIntegration->mShellIntegration) {
+-        mWaylandIntegration->mShellIntegration->handleKeyboardFocusChanged(keyboardFocus, mLastKeyboardFocus);
+-    } else {
+-        if (keyboardFocus)
+-            handleWindowActivated(keyboardFocus);
+-        if (mLastKeyboardFocus)
+-            handleWindowDeactivated(mLastKeyboardFocus);
+-    }
++    if (keyboardFocus)
++        handleWindowActivated(keyboardFocus);
++    if (mLastKeyboardFocus)
++        handleWindowDeactivated(mLastKeyboardFocus);
+ 
+     mLastKeyboardFocus = keyboardFocus;
+ }
+@@ -600,6 +711,19 @@ void QWaylandDisplay::handleWaylandSync()
+     QWindow *activeWindow = mActiveWindows.empty() ? nullptr : mActiveWindows.last()->window();
+     if (activeWindow != QGuiApplication::focusWindow())
+         QWindowSystemInterface::handleWindowActivated(activeWindow);
++
++    if (!activeWindow) {
++        if (lastInputDevice()) {
++#if QT_CONFIG(clipboard)
++            if (auto *dataDevice = lastInputDevice()->dataDevice())
++                dataDevice->invalidateSelectionOffer();
++#endif
++#if QT_CONFIG(wayland_client_primary_selection)
++            if (auto *device = lastInputDevice()->primarySelectionDevice())
++                device->invalidateSelectionOffer();
++#endif
++        }
++    }
+ }
+ 
+ const wl_callback_listener QWaylandDisplay::syncCallbackListener = {
+@@ -626,6 +750,13 @@ QWaylandInputDevice *QWaylandDisplay::defaultInputDevice() const
+     return mInputDevices.isEmpty() ? 0 : mInputDevices.first();
+ }
+ 
++bool QWaylandDisplay::isKeyboardAvailable() const
++{
++    return std::any_of(
++            mInputDevices.constBegin(), mInputDevices.constEnd(),
++            [this](const QWaylandInputDevice *device) { return device->keyboard() != nullptr; });
++}
++
+ #if QT_CONFIG(cursor)
+ 
+ QWaylandCursor *QWaylandDisplay::waylandCursor()
+@@ -652,4 +783,6 @@ QWaylandCursorTheme *QWaylandDisplay::loadCursorTheme(const QString &name, int p
+ 
+ } // namespace QtWaylandClient
+ 
++#include "qwaylanddisplay.moc"
++
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/client/qwaylanddisplay_p.h b/qtwayland/src/client/qwaylanddisplay_p.h
+index 3b092bc8..42bc661d 100644
+--- a/qtwayland/src/client/qwaylanddisplay_p.h
++++ b/qtwayland/src/client/qwaylanddisplay_p.h
+@@ -109,6 +109,7 @@ class QWaylandSurface;
+ class QWaylandShellIntegration;
+ class QWaylandCursor;
+ class QWaylandCursorTheme;
++class EventThread;
+ 
+ typedef void (*RegistryListener)(void *data,
+                                  struct wl_registry *registry,
+@@ -120,15 +121,11 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandDisplay : public QObject, public QtWayland
+     Q_OBJECT
+ 
+ public:
+-    struct FrameQueue {
+-        FrameQueue(wl_event_queue *q = nullptr) : queue(q), mutex(new QMutex) {}
+-        wl_event_queue *queue;
+-        QMutex *mutex;
+-    };
+-
+     QWaylandDisplay(QWaylandIntegration *waylandIntegration);
+     ~QWaylandDisplay(void) override;
+ 
++    void initialize();
++
+ #if QT_CONFIG(xkbcommon)
+     struct xkb_context *xkbContext() const { return mXkbContext.get(); }
+ #endif
+@@ -210,11 +207,11 @@ public:
+     void handleKeyboardFocusChanged(QWaylandInputDevice *inputDevice);
+     void handleWindowDestroyed(QWaylandWindow *window);
+ 
+-    wl_event_queue *createEventQueue();
+-    FrameQueue createFrameQueue();
+-    void destroyFrameQueue(const FrameQueue &q);
+-    void dispatchQueueWhile(wl_event_queue *queue, std::function<bool()> condition, int timeout = -1);
++    wl_event_queue *frameEventQueue() { return m_frameEventQueue; };
++
++    bool isKeyboardAvailable() const;
+ 
++    void initEventThread();
+ public slots:
+     void blockingReadEvents();
+     void flushRequests();
+@@ -237,6 +234,9 @@ private:
+     };
+ 
+     struct wl_display *mDisplay = nullptr;
++    QScopedPointer<EventThread> m_eventThread;
++    wl_event_queue *m_frameEventQueue = nullptr;
++    QScopedPointer<EventThread> m_frameEventQueueThread;
+     QtWayland::wl_compositor mCompositor;
+     QScopedPointer<QWaylandShm> mShm;
+     QList<QWaylandScreen *> mWaitingScreens;
+@@ -273,11 +273,9 @@ private:
+     QWaylandInputDevice *mLastInputDevice = nullptr;
+     QPointer<QWaylandWindow> mLastInputWindow;
+     QPointer<QWaylandWindow> mLastKeyboardFocus;
+-    QVector<QWaylandWindow *> mActiveWindows;
+-    QVector<FrameQueue> mExternalQueues;
++    QList<QWaylandWindow *> mActiveWindows;
+     struct wl_callback *mSyncCallback = nullptr;
+     static const wl_callback_listener syncCallbackListener;
+-    QReadWriteLock m_frameQueueLock;
+ 
+     bool mClientSideInputContextRequested = !QPlatformInputContextFactory::requested().isNull();
+ 
+diff --git a/qtwayland/src/client/qwaylanddnd.cpp b/qtwayland/src/client/qwaylanddnd.cpp
+index 6535aa16..7c53f5fa 100644
+--- a/qtwayland/src/client/qwaylanddnd.cpp
++++ b/qtwayland/src/client/qwaylanddnd.cpp
+@@ -66,7 +66,7 @@ void QWaylandDrag::startDrag()
+ {
+     QBasicDrag::startDrag();
+     QWaylandWindow *icon = static_cast<QWaylandWindow *>(shapedPixmapWindow()->handle());
+-    if (m_display->currentInputDevice()->dataDevice()->startDrag(drag()->mimeData(), icon)) {
++    if (m_display->currentInputDevice()->dataDevice()->startDrag(drag()->mimeData(), drag()->supportedActions(), icon)) {
+         icon->addAttachOffset(-drag()->hotSpot());
+     } else {
+         // Cancelling immediately does not work, since the event loop for QDrag::exec is started
+@@ -80,6 +80,9 @@ void QWaylandDrag::cancel()
+     QBasicDrag::cancel();
+ 
+     m_display->currentInputDevice()->dataDevice()->cancelDrag();
++
++    if (drag())
++        drag()->deleteLater();
+ }
+ 
+ void QWaylandDrag::move(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods)
+@@ -103,33 +106,41 @@ void QWaylandDrag::endDrag()
+     m_display->currentInputDevice()->handleEndDrag();
+ }
+ 
+-void QWaylandDrag::updateTarget(const QString &mimeType)
++void QWaylandDrag::setResponse(bool accepted)
+ {
+-    setCanDrop(!mimeType.isEmpty());
+-
+-    if (canDrop()) {
+-        updateCursor(defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers()));
+-    } else {
+-        updateCursor(Qt::IgnoreAction);
+-    }
++    // This method is used for old DataDevices where the drag action is not communicated
++    Qt::DropAction action = defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers());
++    setResponse(QPlatformDropQtResponse(accepted, action));
+ }
+ 
+-void QWaylandDrag::setResponse(const QPlatformDragQtResponse &response)
++void QWaylandDrag::setResponse(const QPlatformDropQtResponse &response)
+ {
+     setCanDrop(response.isAccepted());
+ 
+     if (canDrop()) {
+-        updateCursor(defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers()));
++        updateCursor(response.acceptedAction());
+     } else {
+         updateCursor(Qt::IgnoreAction);
+     }
+ }
+ 
+-void QWaylandDrag::finishDrag(const QPlatformDropQtResponse &response)
++void QWaylandDrag::setDropResponse(const QPlatformDropQtResponse &response)
+ {
+     setExecutedDropAction(response.acceptedAction());
++}
++
++void QWaylandDrag::finishDrag()
++{
+     QKeyEvent event(QEvent::KeyPress, Qt::Key_Escape, Qt::NoModifier);
+     eventFilter(shapedPixmapWindow(), &event);
++
++    if (drag())
++        drag()->deleteLater();
++}
++
++bool QWaylandDrag::ownsDragObject() const
++{
++    return true;
+ }
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddnd_p.h b/qtwayland/src/client/qwaylanddnd_p.h
+index 474fe2ab..46f629ac 100644
+--- a/qtwayland/src/client/qwaylanddnd_p.h
++++ b/qtwayland/src/client/qwaylanddnd_p.h
+@@ -71,9 +71,10 @@ public:
+     QWaylandDrag(QWaylandDisplay *display);
+     ~QWaylandDrag() override;
+ 
+-    void updateTarget(const QString &mimeType);
+-    void setResponse(const QPlatformDragQtResponse &response);
+-    void finishDrag(const QPlatformDropQtResponse &response);
++    void setResponse(bool accepted);
++    void setResponse(const QPlatformDropQtResponse &response);
++    void setDropResponse(const QPlatformDropQtResponse &response);
++    void finishDrag();
+ 
+ protected:
+     void startDrag() override;
+@@ -82,6 +83,7 @@ protected:
+     void drop(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods) override;
+     void endDrag() override;
+ 
++    bool ownsDragObject() const override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+diff --git a/qtwayland/src/client/qwaylandinputdevice.cpp b/qtwayland/src/client/qwaylandinputdevice.cpp
+index 613fe862..4b90de84 100644
+--- a/qtwayland/src/client/qwaylandinputdevice.cpp
++++ b/qtwayland/src/client/qwaylandinputdevice.cpp
+@@ -685,6 +685,11 @@ public:
+ 
+ void QWaylandInputDevice::Pointer::pointer_leave(uint32_t time, struct wl_surface *surface)
+ {
++    invalidateFocus();
++    mButtons = Qt::NoButton;
++
++    mParent->mTime = time;
++
+     // The event may arrive after destroying the window, indicated by
+     // a null surface.
+     if (!surface)
+@@ -696,11 +701,6 @@ void QWaylandInputDevice::Pointer::pointer_leave(uint32_t time, struct wl_surfac
+ 
+     if (!QWaylandWindow::mouseGrab())
+         setFrameEvent(new LeaveEvent(window, mSurfacePos, mGlobalPos));
+-
+-    invalidateFocus();
+-    mButtons = Qt::NoButton;
+-
+-    mParent->mTime = time;
+ }
+ 
+ class MotionEvent : public QWaylandPointerEvent
+@@ -1300,14 +1300,6 @@ void QWaylandInputDevice::Keyboard::handleFocusDestroyed()
+ void QWaylandInputDevice::Keyboard::handleFocusLost()
+ {
+     mFocus = nullptr;
+-#if QT_CONFIG(clipboard)
+-    if (auto *dataDevice = mParent->dataDevice())
+-        dataDevice->invalidateSelectionOffer();
+-#endif
+-#if QT_CONFIG(wayland_client_primary_selection)
+-    if (auto *device = mParent->primarySelectionDevice())
+-        device->invalidateSelectionOffer();
+-#endif
+     mParent->mQDisplay->handleKeyboardFocusChanged(mParent);
+     mRepeatTimer.stop();
+ }
+@@ -1396,6 +1388,7 @@ void QWaylandInputDevice::Touch::touch_cancel()
+     if (touchExt)
+         touchExt->touchCanceled();
+ 
++    mFocus = nullptr;
+     QWindowSystemInterface::handleTouchCancelEvent(nullptr, mParent->mTouchDevice);
+ }
+ 
+diff --git a/qtwayland/src/client/qwaylandintegration.cpp b/qtwayland/src/client/qwaylandintegration.cpp
+index c53ccb78..54861600 100644
+--- a/qtwayland/src/client/qwaylandintegration.cpp
++++ b/qtwayland/src/client/qwaylandintegration.cpp
+@@ -125,6 +125,9 @@ QWaylandIntegration::QWaylandIntegration()
+ #endif
+ 
+     reconfigureInputContext();
++
++    QWaylandWindow::fixedToplevelPositions =
++            !qEnvironmentVariableIsSet("QT_WAYLAND_DISABLE_FIXED_POSITIONS");
+ }
+ 
+ QWaylandIntegration::~QWaylandIntegration()
+@@ -192,14 +195,18 @@ QAbstractEventDispatcher *QWaylandIntegration::createEventDispatcher() const
+ 
+ void QWaylandIntegration::initialize()
+ {
++    mDisplay->initEventThread();
++
++    // Call after eventDispatcher is fully connected, for QWaylandDisplay::forceRoundTrip()
++    mDisplay->initialize();
++
++    // But the aboutToBlock() and awake() should be connected after initializePlatform().
++    // Otherwise the connected flushRequests() may consumes up all events before processEvents starts to wait,
++    // so that processEvents(QEventLoop::WaitForMoreEvents) may be blocked in the forceRoundTrip().
+     QAbstractEventDispatcher *dispatcher = QGuiApplicationPrivate::eventDispatcher;
+     QObject::connect(dispatcher, SIGNAL(aboutToBlock()), mDisplay.data(), SLOT(flushRequests()));
+     QObject::connect(dispatcher, SIGNAL(awake()), mDisplay.data(), SLOT(flushRequests()));
+ 
+-    int fd = wl_display_get_fd(mDisplay->wl_display());
+-    QSocketNotifier *sn = new QSocketNotifier(fd, QSocketNotifier::Read, mDisplay.data());
+-    QObject::connect(sn, SIGNAL(activated(QSocketDescriptor)), mDisplay.data(), SLOT(flushRequests()));
+-
+     // Qt does not support running with no screens
+     mDisplay->ensureScreen();
+ }
+@@ -262,6 +269,14 @@ QWaylandDisplay *QWaylandIntegration::display() const
+     return mDisplay.data();
+ }
+ 
++Qt::KeyboardModifiers QWaylandIntegration::queryKeyboardModifiers() const
++{
++    if (auto *seat = mDisplay->currentInputDevice()) {
++        return seat->modifiers();
++    }
++    return Qt::NoModifier;
++}
++
+ QList<int> QWaylandIntegration::possibleKeys(const QKeyEvent *event) const
+ {
+     if (auto *seat = mDisplay->currentInputDevice())
+@@ -479,7 +494,7 @@ void QWaylandIntegration::reconfigureInputContext()
+     }
+ #endif
+ 
+-    qCDebug(lcQpaWayland) << "using input method:" << inputContext()->metaObject()->className();
++    qCDebug(lcQpaWayland) << "using input method:" << (inputContext() ? inputContext()->metaObject()->className() : "<none>");
+ }
+ 
+ QWaylandShellIntegration *QWaylandIntegration::createShellIntegration(const QString &integrationName)
+diff --git a/qtwayland/src/client/qwaylandintegration_p.h b/qtwayland/src/client/qwaylandintegration_p.h
+index ff70ae25..73b80658 100644
+--- a/qtwayland/src/client/qwaylandintegration_p.h
++++ b/qtwayland/src/client/qwaylandintegration_p.h
+@@ -107,6 +107,8 @@ public:
+ 
+     QWaylandDisplay *display() const;
+ 
++    Qt::KeyboardModifiers queryKeyboardModifiers() const override;
++
+     QList<int> possibleKeys(const QKeyEvent *event) const override;
+ 
+     QStringList themeNames() const override;
+diff --git a/qtwayland/src/client/qwaylandprimaryselectionv1.cpp b/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
+index 832f9678..ea508771 100644
+--- a/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
++++ b/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
+@@ -54,11 +54,6 @@ QWaylandPrimarySelectionDeviceManagerV1::QWaylandPrimarySelectionDeviceManagerV1
+     : zwp_primary_selection_device_manager_v1(display->wl_registry(), id, qMin(version, uint(1)))
+     , m_display(display)
+ {
+-    // Create devices for all seats.
+-    // This only works if we get the global before all devices
+-    const auto seats = m_display->inputDevices();
+-    for (auto *seat : seats)
+-        seat->setPrimarySelectionDevice(createDevice(seat));
+ }
+ 
+ QWaylandPrimarySelectionDeviceV1 *QWaylandPrimarySelectionDeviceManagerV1::createDevice(QWaylandInputDevice *seat)
+diff --git a/qtwayland/src/client/qwaylandscreen.cpp b/qtwayland/src/client/qwaylandscreen.cpp
+index 6cb337de..5537dafd 100644
+--- a/qtwayland/src/client/qwaylandscreen.cpp
++++ b/qtwayland/src/client/qwaylandscreen.cpp
+@@ -60,7 +60,7 @@ QWaylandXdgOutputManagerV1::QWaylandXdgOutputManagerV1(QWaylandDisplay* display,
+ }
+ 
+ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uint32_t id)
+-    : QtWayland::wl_output(waylandDisplay->wl_registry(), id, qMin(version, 2))
++    : QtWayland::wl_output(waylandDisplay->wl_registry(), id, qMin(version, 3))
+     , m_outputId(id)
+     , mWaylandDisplay(waylandDisplay)
+     , mOutputName(QStringLiteral("Screen%1").arg(id))
+@@ -72,7 +72,7 @@ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uin
+         qCWarning(lcQpaWayland) << "wl_output done event not supported by compositor,"
+                                 << "QScreen may not work correctly";
+         mWaylandDisplay->forceRoundTrip(); // Give the compositor a chance to send geometry etc.
+-        mOutputDone = true; // Fake the done event
++        mProcessedEvents |= OutputDoneEvent; // Fake the done event
+         maybeInitialize();
+     }
+ }
+@@ -81,16 +81,29 @@ QWaylandScreen::~QWaylandScreen()
+ {
+     if (zxdg_output_v1::isInitialized())
+         zxdg_output_v1::destroy();
++    if (wl_output::isInitialized() && wl_output_get_version(wl_output::object()) >= WL_OUTPUT_RELEASE_SINCE_VERSION)
++        wl_output::release();
++}
++
++uint QWaylandScreen::requiredEvents() const
++{
++    uint ret = OutputDoneEvent;
++
++    if (mWaylandDisplay->xdgOutputManager()) {
++        ret |= XdgOutputNameEvent;
++
++        if (mWaylandDisplay->xdgOutputManager()->version() < 3)
++            ret |= XdgOutputDoneEvent;
++    }
++    return ret;
+ }
+ 
+ void QWaylandScreen::maybeInitialize()
+ {
+     Q_ASSERT(!mInitialized);
+ 
+-    if (!mOutputDone)
+-        return;
+-
+-    if (mWaylandDisplay->xdgOutputManager() && !mXdgOutputDone)
++    const uint requiredEvents = this->requiredEvents();
++    if ((mProcessedEvents & requiredEvents) != requiredEvents)
+         return;
+ 
+     mInitialized = true;
+@@ -276,9 +289,8 @@ void QWaylandScreen::output_scale(int32_t factor)
+ 
+ void QWaylandScreen::output_done()
+ {
+-    mOutputDone = true;
+-    if (zxdg_output_v1::isInitialized() && mWaylandDisplay->xdgOutputManager()->version() >= 3)
+-        mXdgOutputDone = true;
++    mProcessedEvents |= OutputDoneEvent;
++
+     if (mInitialized) {
+         updateOutputProperties();
+         if (zxdg_output_v1::isInitialized())
+@@ -339,7 +351,7 @@ void QWaylandScreen::zxdg_output_v1_done()
+     if (Q_UNLIKELY(mWaylandDisplay->xdgOutputManager()->version() >= 3))
+         qWarning(lcQpaWayland) << "zxdg_output_v1.done received on version 3 or newer, this is most likely a bug in the compositor";
+ 
+-    mXdgOutputDone = true;
++    mProcessedEvents |= XdgOutputDoneEvent;
+     if (mInitialized)
+         updateXdgOutputProperties();
+     else
+@@ -348,7 +360,11 @@ void QWaylandScreen::zxdg_output_v1_done()
+ 
+ void QWaylandScreen::zxdg_output_v1_name(const QString &name)
+ {
++    if (Q_UNLIKELY(mInitialized))
++        qWarning(lcQpaWayland) << "zxdg_output_v1.name received after output has been initialized, this is most likely a bug in the compositor";
++
+     mOutputName = name;
++    mProcessedEvents |= XdgOutputNameEvent;
+ }
+ 
+ void QWaylandScreen::updateXdgOutputProperties()
+diff --git a/qtwayland/src/client/qwaylandscreen_p.h b/qtwayland/src/client/qwaylandscreen_p.h
+index df1c94f2..050cfdc0 100644
+--- a/qtwayland/src/client/qwaylandscreen_p.h
++++ b/qtwayland/src/client/qwaylandscreen_p.h
+@@ -116,6 +116,13 @@ public:
+     static QWaylandScreen *fromWlOutput(::wl_output *output);
+ 
+ private:
++    enum Event : uint {
++        XdgOutputDoneEvent = 0x1,
++        OutputDoneEvent = 0x2,
++        XdgOutputNameEvent = 0x4,
++    };
++    uint requiredEvents() const;
++
+     void output_mode(uint32_t flags, int width, int height, int refresh) override;
+     void output_geometry(int32_t x, int32_t y,
+                          int32_t width, int32_t height,
+@@ -148,8 +155,7 @@ private:
+     QSize mPhysicalSize;
+     QString mOutputName;
+     Qt::ScreenOrientation m_orientation = Qt::PrimaryOrientation;
+-    bool mOutputDone = false;
+-    bool mXdgOutputDone = false;
++    uint mProcessedEvents = 0;
+     bool mInitialized = false;
+ 
+ #if QT_CONFIG(cursor)
+diff --git a/qtwayland/src/client/qwaylandshmbackingstore.cpp b/qtwayland/src/client/qwaylandshmbackingstore.cpp
+index dc7ff670..41cffdf7 100644
+--- a/qtwayland/src/client/qwaylandshmbackingstore.cpp
++++ b/qtwayland/src/client/qwaylandshmbackingstore.cpp
+@@ -52,6 +52,7 @@
+ 
+ #include <QtWaylandClient/private/wayland-wayland-client-protocol.h>
+ 
++#include <fcntl.h>
+ #include <unistd.h>
+ #include <sys/mman.h>
+ 
+@@ -61,6 +62,9 @@
+ #  ifndef MFD_CLOEXEC
+ #    define MFD_CLOEXEC     0x0001U
+ #  endif
++#  ifndef MFD_ALLOW_SEALING
++#    define MFD_ALLOW_SEALING 0x0002U
++#  endif
+ #endif
+ 
+ QT_BEGIN_NAMESPACE
+@@ -74,8 +78,10 @@ QWaylandShmBuffer::QWaylandShmBuffer(QWaylandDisplay *display,
+     int alloc = stride * size.height();
+     int fd = -1;
+ 
+-#ifdef SYS_memfd_create
+-    fd = syscall(SYS_memfd_create, "wayland-shm", MFD_CLOEXEC);
++#if defined(SYS_memfd_create) && defined(F_SEAL_SEAL)
++    fd = syscall(SYS_memfd_create, "wayland-shm", MFD_CLOEXEC | MFD_ALLOW_SEALING);
++    if (fd >= 0)
++        fcntl(fd, F_ADD_SEALS, F_SEAL_SHRINK | F_SEAL_SEAL);
+ #endif
+ 
+     QScopedPointer<QFile> filePointer;
+diff --git a/qtwayland/src/client/qwaylandwindow.cpp b/qtwayland/src/client/qwaylandwindow.cpp
+index cb82857a..fb2c59dc 100644
+--- a/qtwayland/src/client/qwaylandwindow.cpp
++++ b/qtwayland/src/client/qwaylandwindow.cpp
+@@ -76,7 +76,6 @@ QWaylandWindow *QWaylandWindow::mMouseGrab = nullptr;
+ QWaylandWindow::QWaylandWindow(QWindow *window, QWaylandDisplay *display)
+     : QPlatformWindow(window)
+     , mDisplay(display)
+-    , mFrameQueue(mDisplay->createFrameQueue())
+     , mResizeAfterSwap(qEnvironmentVariableIsSet("QT_WAYLAND_RESIZE_AFTER_SWAP"))
+ {
+     {
+@@ -95,9 +94,6 @@ QWaylandWindow::QWaylandWindow(QWindow *window, QWaylandDisplay *display)
+ 
+ QWaylandWindow::~QWaylandWindow()
+ {
+-    mDisplay->destroyFrameQueue(mFrameQueue);
+-    mDisplay->handleWindowDestroyed(this);
+-
+     delete mWindowDecoration;
+ 
+     if (mSurface)
+@@ -243,6 +239,7 @@ bool QWaylandWindow::shouldCreateSubSurface() const
+ 
+ void QWaylandWindow::reset()
+ {
++    closeChildPopups();
+     delete mShellSurface;
+     mShellSurface = nullptr;
+     delete mSubSurfaceWindow;
+@@ -255,17 +252,22 @@ void QWaylandWindow::reset()
+         mSurface.reset();
+     }
+ 
+-    if (mFrameCallback) {
+-        wl_callback_destroy(mFrameCallback);
+-        mFrameCallback = nullptr;
+-    }
++    {
++        QMutexLocker lock(&mFrameSyncMutex);
++        if (mFrameCallback) {
++            wl_callback_destroy(mFrameCallback);
++            mFrameCallback = nullptr;
++        }
+ 
+-    mFrameCallbackElapsedTimer.invalidate();
+-    mWaitingForFrameCallback = false;
++        mFrameCallbackElapsedTimer.invalidate();
++        mWaitingForFrameCallback = false;
++    }
+     mFrameCallbackTimedOut = false;
+ 
+     mMask = QRegion();
+     mQueuedBuffer = nullptr;
++
++    mDisplay->handleWindowDestroyed(this);
+ }
+ 
+ QWaylandWindow *QWaylandWindow::fromWlSurface(::wl_surface *surface)
+@@ -351,19 +353,25 @@ void QWaylandWindow::setGeometry_helper(const QRect &rect)
+     }
+ }
+ 
+-void QWaylandWindow::setGeometry(const QRect &rect)
++void QWaylandWindow::setGeometry(const QRect &r)
+ {
++    auto rect = r;
++    if (fixedToplevelPositions && !QPlatformWindow::parent() && window()->type() != Qt::Popup
++        && window()->type() != Qt::ToolTip) {
++        rect.moveTo(screen()->geometry().topLeft());
++    }
+     setGeometry_helper(rect);
+ 
+     if (window()->isVisible() && rect.isValid()) {
+         if (mWindowDecoration)
+             mWindowDecoration->update();
+ 
+-        if (mResizeAfterSwap && windowType() == Egl && mSentInitialResize)
++        if (mResizeAfterSwap && windowType() == Egl && mSentInitialResize) {
++            QMutexLocker lock(&mResizeLock);
+             mResizeDirty = true;
+-        else
++        } else {
+             QWindowSystemInterface::handleGeometryChange(window(), geometry());
+-
++        }
+         mSentInitialResize = true;
+     }
+     QRect exposeGeometry(QPoint(), geometry().size());
+@@ -374,7 +382,7 @@ void QWaylandWindow::setGeometry(const QRect &rect)
+         mShellSurface->setWindowGeometry(windowContentGeometry());
+ 
+     if (isOpaque() && mMask.isEmpty())
+-        setOpaqueArea(rect);
++        setOpaqueArea(QRect(QPoint(0, 0), rect.size()));
+ }
+ 
+ void QWaylandWindow::resizeFromApplyConfigure(const QSize &sizeWithMargins, const QPoint &offset)
+@@ -399,21 +407,6 @@ void QWaylandWindow::sendExposeEvent(const QRect &rect)
+     mLastExposeGeometry = rect;
+ }
+ 
+-
+-static QVector<QPointer<QWaylandWindow>> activePopups;
+-
+-void QWaylandWindow::closePopups(QWaylandWindow *parent)
+-{
+-    while (!activePopups.isEmpty()) {
+-        auto popup = activePopups.takeLast();
+-        if (popup.isNull())
+-            continue;
+-        if (popup.data() == parent)
+-            return;
+-        popup->reset();
+-    }
+-}
+-
+ QPlatformScreen *QWaylandWindow::calculateScreenFromSurfaceEvents() const
+ {
+     QReadLocker lock(&mSurfaceLock);
+@@ -433,10 +426,7 @@ void QWaylandWindow::setVisible(bool visible)
+     lastVisible = visible;
+ 
+     if (visible) {
+-        if (window()->type() == Qt::Popup || window()->type() == Qt::ToolTip)
+-            activePopups << this;
+         initWindow();
+-        mDisplay->flushRequests();
+ 
+         setGeometry(windowGeometry());
+         // Don't flush the events here, or else the newly visible window may start drawing, but since
+@@ -444,7 +434,6 @@ void QWaylandWindow::setVisible(bool visible)
+         // QWaylandShmBackingStore::beginPaint().
+     } else {
+         sendExposeEvent(QRect());
+-        closePopups(this);
+         reset();
+     }
+ }
+@@ -556,12 +545,12 @@ void QWaylandWindow::sendRecursiveExposeEvent()
+ 
+ void QWaylandWindow::attach(QWaylandBuffer *buffer, int x, int y)
+ {
+-    Q_ASSERT(!buffer->committed());
+     QReadLocker locker(&mSurfaceLock);
+     if (mSurface == nullptr)
+         return;
+ 
+     if (buffer) {
++        Q_ASSERT(!buffer->committed());
+         handleUpdate();
+         buffer->setBusy();
+ 
+@@ -583,7 +572,11 @@ void QWaylandWindow::damage(const QRect &rect)
+     if (mSurface == nullptr)
+         return;
+ 
+-    mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    const int s = scale();
++    if (mDisplay->compositorVersion() >= 4)
++        mSurface->damage_buffer(s * rect.x(), s * rect.y(), s * rect.width(), s * rect.height());
++    else
++        mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
+ }
+ 
+ void QWaylandWindow::safeCommit(QWaylandBuffer *buffer, const QRegion &damage)
+@@ -619,8 +612,14 @@ void QWaylandWindow::commit(QWaylandBuffer *buffer, const QRegion &damage)
+         return;
+ 
+     attachOffset(buffer);
+-    for (const QRect &rect: damage)
+-        mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    if (mDisplay->compositorVersion() >= 4) {
++        const int s = scale();
++        for (const QRect &rect: damage)
++            mSurface->damage_buffer(s * rect.x(), s * rect.y(), s * rect.width(), s * rect.height());
++    } else {
++        for (const QRect &rect: damage)
++            mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    }
+     Q_ASSERT(!buffer->committed());
+     buffer->setCommitted();
+     mSurface->commit();
+@@ -635,42 +634,53 @@ void QWaylandWindow::commit()
+ 
+ const wl_callback_listener QWaylandWindow::callbackListener = {
+     [](void *data, wl_callback *callback, uint32_t time) {
+-        Q_UNUSED(callback);
+         Q_UNUSED(time);
+         auto *window = static_cast<QWaylandWindow*>(data);
+-        window->handleFrameCallback();
++        window->handleFrameCallback(callback);
+     }
+ };
+ 
+-void QWaylandWindow::handleFrameCallback()
++void QWaylandWindow::handleFrameCallback(wl_callback* callback)
+ {
++    QMutexLocker locker(&mFrameSyncMutex);
++    if (!mFrameCallback) {
++        // This means the callback is already unset by QWaylandWindow::reset.
++        // The wl_callback object will be destroyed there too.
++        return;
++    }
++    Q_ASSERT(callback == mFrameCallback);
++    wl_callback_destroy(callback);
++    mFrameCallback = nullptr;
++
+     mWaitingForFrameCallback = false;
+     mFrameCallbackElapsedTimer.invalidate();
+ 
+     // The rest can wait until we can run it on the correct thread
+-    if (!mWaitingForUpdateDelivery) {
+-        auto doHandleExpose = [this]() {
+-            bool wasExposed = isExposed();
+-            mFrameCallbackTimedOut = false;
+-            if (!wasExposed && isExposed()) // Did setting mFrameCallbackTimedOut make the window exposed?
+-                sendExposeEvent(QRect(QPoint(), geometry().size()));
+-            if (wasExposed && hasPendingUpdateRequest())
+-                deliverUpdateRequest();
+-
+-            mWaitingForUpdateDelivery = false;
+-        };
++    auto doHandleExpose = [this]() {
++        mWaitingForUpdateDelivery.storeRelease(false);
++        bool wasExposed = isExposed();
++        mFrameCallbackTimedOut = false;
++        if (!wasExposed && isExposed()) // Did setting mFrameCallbackTimedOut make the window exposed?
++            sendExposeEvent(QRect(QPoint(), geometry().size()));
++        if (wasExposed && hasPendingUpdateRequest())
++            deliverUpdateRequest();
++    };
+ 
++    if (mWaitingForUpdateDelivery.testAndSetAcquire(false, true)) {
+         // Queued connection, to make sure we don't call handleUpdate() from inside waitForFrameSync()
+         // in the single-threaded case.
+-        mWaitingForUpdateDelivery = true;
+         QMetaObject::invokeMethod(this, doHandleExpose, Qt::QueuedConnection);
+     }
++
++    mFrameSyncWait.notify_all();
+ }
+ 
+ bool QWaylandWindow::waitForFrameSync(int timeout)
+ {
+-    QMutexLocker locker(mFrameQueue.mutex);
+-    mDisplay->dispatchQueueWhile(mFrameQueue.queue, [&]() { return mWaitingForFrameCallback; }, timeout);
++    QMutexLocker locker(&mFrameSyncMutex);
++
++    QDeadlineTimer deadline(timeout);
++    while (mWaitingForFrameCallback && mFrameSyncWait.wait(&mFrameSyncMutex, deadline)) { }
+ 
+     if (mWaitingForFrameCallback) {
+         qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
+@@ -868,6 +878,17 @@ bool QWaylandWindow::createDecoration()
+             subsurf->set_position(pos.x() + m.left(), pos.y() + m.top());
+         }
+         sendExposeEvent(QRect(QPoint(), geometry().size()));
++
++        // This is a special case where the buffer is recreated, but since
++        // the content rect remains the same, the widgets remain the same
++        // size and are not redrawn, leaving the new buffer empty. As a simple
++        // work-around, we trigger a full extra update whenever the client-side
++        // window decorations are toggled while the window is showing.
++        // Note: createDecoration() is sometimes called from the render thread
++        // of Qt Quick. This is essentially wrong and could potentially cause problems,
++        // but until the underlying issue has been fixed, we have to use invokeMethod()
++        // here to avoid asserts.
++        QMetaObject::invokeMethod(window(), &QWindow::requestUpdate);
+     }
+ 
+     return mWindowDecoration;
+@@ -1023,6 +1044,13 @@ void QWaylandWindow::handleScreensChanged()
+ 
+     QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->QPlatformScreen::screen());
+     mLastReportedScreen = newScreen;
++    if (fixedToplevelPositions && !QPlatformWindow::parent() && window()->type() != Qt::Popup
++        && window()->type() != Qt::ToolTip
++        && geometry().topLeft() != newScreen->geometry().topLeft()) {
++        auto geometry = this->geometry();
++        geometry.moveTo(newScreen->geometry().topLeft());
++        setGeometry(geometry);
++    }
+ 
+     int scale = newScreen->isPlaceholder() ? 1 : static_cast<QWaylandScreen *>(newScreen)->scale();
+     if (scale != mScale) {
+@@ -1094,10 +1122,18 @@ bool QWaylandWindow::setMouseGrabEnabled(bool grab)
+     return true;
+ }
+ 
++Qt::WindowStates QWaylandWindow::windowStates() const
++{
++    return mLastReportedWindowStates;
++}
++
+ void QWaylandWindow::handleWindowStatesChanged(Qt::WindowStates states)
+ {
+     createDecoration();
+-    QWindowSystemInterface::handleWindowStateChanged(window(), states, mLastReportedWindowStates);
++    Qt::WindowStates statesWithoutActive = states & ~Qt::WindowActive;
++    Qt::WindowStates lastStatesWithoutActive = mLastReportedWindowStates & ~Qt::WindowActive;
++    QWindowSystemInterface::handleWindowStateChanged(window(), statesWithoutActive,
++                                                     lastStatesWithoutActive);
+     mLastReportedWindowStates = states;
+ }
+ 
+@@ -1139,19 +1175,24 @@ void QWaylandWindow::timerEvent(QTimerEvent *event)
+     if (event->timerId() != mFrameCallbackCheckIntervalTimerId)
+         return;
+ 
+-    bool callbackTimerExpired = mFrameCallbackElapsedTimer.hasExpired(mFrameCallbackTimeout);
+-    if (!mFrameCallbackElapsedTimer.isValid() || callbackTimerExpired ) {
+-        killTimer(mFrameCallbackCheckIntervalTimerId);
+-        mFrameCallbackCheckIntervalTimerId = -1;
+-    }
+-    if (mFrameCallbackElapsedTimer.isValid() && callbackTimerExpired) {
+-        mFrameCallbackElapsedTimer.invalidate();
++    {
++        QMutexLocker lock(&mFrameSyncMutex);
+ 
+-        qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
+-        mFrameCallbackTimedOut = true;
+-        mWaitingForUpdate = false;
+-        sendExposeEvent(QRect());
++        bool callbackTimerExpired = mFrameCallbackElapsedTimer.hasExpired(mFrameCallbackTimeout);
++        if (!mFrameCallbackElapsedTimer.isValid() || callbackTimerExpired ) {
++            killTimer(mFrameCallbackCheckIntervalTimerId);
++            mFrameCallbackCheckIntervalTimerId = -1;
++        }
++        if (!mFrameCallbackElapsedTimer.isValid() || !callbackTimerExpired) {
++            return;
++        }
++        mFrameCallbackElapsedTimer.invalidate();
+     }
++
++    qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
++    mFrameCallbackTimedOut = true;
++    mWaitingForUpdate = false;
++    sendExposeEvent(QRect());
+ }
+ 
+ void QWaylandWindow::requestUpdate()
+@@ -1160,8 +1201,11 @@ void QWaylandWindow::requestUpdate()
+     Q_ASSERT(hasPendingUpdateRequest()); // should be set by QPA
+ 
+     // If we have a frame callback all is good and will be taken care of there
+-    if (mWaitingForFrameCallback)
+-        return;
++    {
++        QMutexLocker locker(&mFrameSyncMutex);
++        if (mWaitingForFrameCallback)
++            return;
++    }
+ 
+     // If we've already called deliverUpdateRequest(), but haven't seen any attach+commit/swap yet
+     // This is a somewhat redundant behavior and might indicate a bug in the calling code, so log
+@@ -1174,7 +1218,12 @@ void QWaylandWindow::requestUpdate()
+     // so use invokeMethod to delay the delivery a bit.
+     QMetaObject::invokeMethod(this, [this] {
+         // Things might have changed in the meantime
+-        if (hasPendingUpdateRequest() && !mWaitingForFrameCallback)
++        {
++            QMutexLocker locker(&mFrameSyncMutex);
++            if (mWaitingForFrameCallback)
++                return;
++        }
++        if (hasPendingUpdateRequest())
+             deliverUpdateRequest();
+     }, Qt::QueuedConnection);
+ }
+@@ -1185,19 +1234,18 @@ void QWaylandWindow::requestUpdate()
+ void QWaylandWindow::handleUpdate()
+ {
+     qCDebug(lcWaylandBackingstore) << "handleUpdate" << QThread::currentThread();
++
+     // TODO: Should sync subsurfaces avoid requesting frame callbacks?
+     QReadLocker lock(&mSurfaceLock);
+     if (!mSurface)
+         return;
+ 
+-    if (mFrameCallback) {
+-        wl_callback_destroy(mFrameCallback);
+-        mFrameCallback = nullptr;
+-    }
++    QMutexLocker locker(&mFrameSyncMutex);
++    if (mWaitingForFrameCallback)
++        return;
+ 
+-    QMutexLocker locker(mFrameQueue.mutex);
+     struct ::wl_surface *wrappedSurface = reinterpret_cast<struct ::wl_surface *>(wl_proxy_create_wrapper(mSurface->object()));
+-    wl_proxy_set_queue(reinterpret_cast<wl_proxy *>(wrappedSurface), mFrameQueue.queue);
++    wl_proxy_set_queue(reinterpret_cast<wl_proxy *>(wrappedSurface), mDisplay->frameEventQueue());
+     mFrameCallback = wl_surface_frame(wrappedSurface);
+     wl_proxy_wrapper_destroy(wrappedSurface);
+     wl_callback_add_listener(mFrameCallback, &QWaylandWindow::callbackListener, this);
+@@ -1207,6 +1255,8 @@ void QWaylandWindow::handleUpdate()
+     // Start a timer for handling the case when the compositor stops sending frame callbacks.
+     if (mFrameCallbackTimeout > 0) {
+         QMetaObject::invokeMethod(this, [this] {
++            QMutexLocker locker(&mFrameSyncMutex);
++
+             if (mWaitingForFrameCallback) {
+                 if (mFrameCallbackCheckIntervalTimerId < 0)
+                     mFrameCallbackCheckIntervalTimerId = startTimer(mFrameCallbackTimeout);
+@@ -1267,6 +1317,20 @@ void QWaylandWindow::setOpaqueArea(const QRegion &opaqueArea)
+     wl_region_destroy(region);
+ }
+ 
++void QWaylandWindow::addChildPopup(QWaylandWindow *surface) {
++    mChildPopups.append(surface);
++}
++
++void QWaylandWindow::removeChildPopup(QWaylandWindow *surface) {
++    mChildPopups.removeAll(surface);
++}
++
++void QWaylandWindow::closeChildPopups() {
++    while (!mChildPopups.isEmpty()) {
++        auto popup = mChildPopups.takeLast();
++        popup->reset();
++    }
++}
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/client/qwaylandwindow_p.h b/qtwayland/src/client/qwaylandwindow_p.h
+index 01337cff..2f219d8c 100644
+--- a/qtwayland/src/client/qwaylandwindow_p.h
++++ b/qtwayland/src/client/qwaylandwindow_p.h
+@@ -98,6 +98,9 @@ public:
+     QWaylandWindow(QWindow *window, QWaylandDisplay *display);
+     ~QWaylandWindow() override;
+ 
++    // Keep Toplevels position on the top left corner of their screen
++    static inline bool fixedToplevelPositions = true;
++
+     virtual WindowType windowType() const = 0;
+     virtual void ensureSize();
+     WId winId() const override;
+@@ -148,6 +151,7 @@ public:
+     void setWindowState(Qt::WindowStates states) override;
+     void setWindowFlags(Qt::WindowFlags flags) override;
+     void handleWindowStatesChanged(Qt::WindowStates states);
++    Qt::WindowStates windowStates() const;
+ 
+     void raise() override;
+     void lower() override;
+@@ -206,6 +210,10 @@ public:
+     void handleUpdate();
+     void deliverUpdateRequest() override;
+ 
++    void addChildPopup(QWaylandWindow* child);
++    void removeChildPopup(QWaylandWindow* child);
++    void closeChildPopups();
++
+ public slots:
+     void applyConfigure();
+ 
+@@ -215,7 +223,11 @@ signals:
+ 
+ protected:
+     QWaylandDisplay *mDisplay = nullptr;
++
++    // mSurface can be written by the main thread. Other threads should claim a read lock for access
++    mutable QReadWriteLock mSurfaceLock;
+     QScopedPointer<QWaylandSurface> mSurface;
++
+     QWaylandShellSurface *mShellSurface = nullptr;
+     QWaylandSubSurface *mSubSurfaceWindow = nullptr;
+     QVector<QWaylandSubSurface *> mChildren;
+@@ -225,13 +237,14 @@ protected:
+     Qt::MouseButtons mMousePressedInContentArea = Qt::NoButton;
+ 
+     WId mWindowId;
+-    bool mWaitingForFrameCallback = false;
+     bool mFrameCallbackTimedOut = false; // Whether the frame callback has timed out
+-    bool mWaitingForUpdateDelivery = false;
+     int mFrameCallbackCheckIntervalTimerId = -1;
+-    QElapsedTimer mFrameCallbackElapsedTimer;
+-    struct ::wl_callback *mFrameCallback = nullptr;
+-    QWaylandDisplay::FrameQueue mFrameQueue;
++    QAtomicInt mWaitingForUpdateDelivery = false;
++
++    bool mWaitingForFrameCallback = false; // Protected by mFrameSyncMutex
++    QElapsedTimer mFrameCallbackElapsedTimer; // Protected by mFrameSyncMutex
++    struct ::wl_callback *mFrameCallback = nullptr; // Protected by mFrameSyncMutex
++    QMutex mFrameSyncMutex;
+     QWaitCondition mFrameSyncWait;
+ 
+     // True when we have called deliverRequestUpdate, but the client has not yet attached a new buffer
+@@ -261,6 +274,8 @@ protected:
+     QWaylandBuffer *mQueuedBuffer = nullptr;
+     QRegion mQueuedBufferDamage;
+ 
++    QList<QPointer<QWaylandWindow>> mChildPopups;
++
+ private:
+     void setGeometry_helper(const QRect &rect);
+     void initWindow();
+@@ -283,12 +298,10 @@ private:
+     QRect mLastExposeGeometry;
+ 
+     static const wl_callback_listener callbackListener;
+-    void handleFrameCallback();
++    void handleFrameCallback(struct ::wl_callback* callback);
+ 
+     static QWaylandWindow *mMouseGrab;
+ 
+-    mutable QReadWriteLock mSurfaceLock;
+-
+     friend class QWaylandSubSurface;
+ };
+ 
+diff --git a/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h b/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
+index ccad0048..4cc9b3b8 100644
+--- a/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
++++ b/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
+@@ -73,11 +73,10 @@ public:
+         return true;
+     }
+     virtual QWaylandShellSurface *createShellSurface(QWaylandWindow *window) = 0;
++    // kept for binary compat with layer-shell-qt
+     virtual void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) {
+-        if (newFocus)
+-            m_display->handleWindowActivated(newFocus);
+-        if (oldFocus)
+-            m_display->handleWindowDeactivated(oldFocus);
++        Q_UNUSED(newFocus);
++        Q_UNUSED(oldFocus);
+     }
+     virtual void *nativeResourceForWindow(const QByteArray &resource, QWindow *window) {
+         Q_UNUSED(resource);
+diff --git a/qtwayland/src/compositor/configure.json b/qtwayland/src/compositor/configure.json
+index bcfd5215..da95d07b 100644
+--- a/qtwayland/src/compositor/configure.json
++++ b/qtwayland/src/compositor/configure.json
+@@ -7,6 +7,31 @@
+     "testDir": "../../config.tests",
+ 
+     "libraries": {
++        "wayland-client": {
++            "label": "Wayland client library",
++            "headers": "wayland-version.h",
++            "test": {
++                "main": [
++                    "#if WAYLAND_VERSION_MAJOR < 1",
++                    "# error Wayland 1.8.0 or higher required",
++                    "#endif",
++                    "#if WAYLAND_VERSION_MAJOR == 1",
++                    "# if WAYLAND_VERSION_MINOR < 8",
++                    "#  error Wayland 1.8.0 or higher required",
++                    "# endif",
++                    "# if WAYLAND_VERSION_MINOR == 8",
++                    "#  if WAYLAND_VERSION_MICRO < 0",
++                    "#   error Wayland 1.8.0 or higher required",
++                    "#  endif",
++                    "# endif",
++                    "#endif"
++                 ]
++            },
++            "sources": [
++                { "type": "pkgConfig", "args": "wayland-client" },
++                "-lwayland-client"
++            ]
++        },
+         "wayland-server": {
+             "label": "wayland-server",
+             "headers": "wayland-version.h",
+@@ -151,8 +176,7 @@
+                     "#endif"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "dmabuf-client-buffer": {
+             "label": "Linux Client dma-buf Buffer Sharing",
+@@ -176,8 +200,7 @@
+                     "return 0;"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "vulkan-server-buffer": {
+             "label": "Vulkan Buffer Sharing",
+@@ -195,7 +218,8 @@
+                     "exportAllocInfo.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR;",
+                     "return 0;"
+                 ]
+-            }
++            },
++            "use": "wayland-client"
+         }
+     },
+ 
+diff --git a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
+index 7889f575..64140672 100644
+--- a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
++++ b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
+@@ -40,6 +40,7 @@
+ #include "qwaylandeglwindow.h"
+ 
+ #include <QtWaylandClient/private/qwaylandscreen_p.h>
++#include <QtWaylandClient/private/qwaylandsurface_p.h>
+ #include "qwaylandglcontext.h"
+ 
+ #include <QtEglSupport/private/qeglconvenience_p.h>
+@@ -124,6 +125,7 @@ void QWaylandEglWindow::updateSurface(bool create)
+         }
+         mOffset = QPoint();
+     } else {
++        QReadLocker locker(&mSurfaceLock);
+         if (m_waylandEglWindow) {
+             int current_width, current_height;
+             static bool disableResizeCheck = qgetenv("QT_WAYLAND_DISABLE_RESIZECHECK").toInt();
+@@ -131,14 +133,16 @@ void QWaylandEglWindow::updateSurface(bool create)
+             if (!disableResizeCheck) {
+                 wl_egl_window_get_attached_size(m_waylandEglWindow, &current_width, &current_height);
+             }
+-            if (disableResizeCheck || (current_width != sizeWithMargins.width() || current_height != sizeWithMargins.height())) {
++            if (disableResizeCheck || (current_width != sizeWithMargins.width() || current_height != sizeWithMargins.height()) || m_requestedSize != sizeWithMargins) {
+                 wl_egl_window_resize(m_waylandEglWindow, sizeWithMargins.width(), sizeWithMargins.height(), mOffset.x(), mOffset.y());
++                m_requestedSize = sizeWithMargins;
+                 mOffset = QPoint();
+ 
+                 m_resize = true;
+             }
+-        } else if (create && wlSurface()) {
+-            m_waylandEglWindow = wl_egl_window_create(wlSurface(), sizeWithMargins.width(), sizeWithMargins.height());
++        } else if (create && mSurface) {
++            m_waylandEglWindow = wl_egl_window_create(mSurface->object(), sizeWithMargins.width(), sizeWithMargins.height());
++            m_requestedSize = sizeWithMargins;
+         }
+ 
+         if (!m_eglSurface && m_waylandEglWindow && create) {
+diff --git a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
+index 5b1f4d56..0079dfef 100644
+--- a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
++++ b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
+@@ -88,6 +88,7 @@ private:
+     mutable QOpenGLFramebufferObject *m_contentFBO = nullptr;
+ 
+     QSurfaceFormat m_format;
++    QSize m_requestedSize;
+ };
+ 
+ }
+diff --git a/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h b/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
+index 56a710c3..c6a8b6c6 100644
+--- a/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
++++ b/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
+@@ -41,6 +41,8 @@
+ #include <QtCore/QTextStream>
+ #include <QtGui/QOpenGLTexture>
+ 
++#include <array>
++
+ #include <EGL/egl.h>
+ #include <EGL/eglext.h>
+ 
+diff --git a/qtwayland/src/plugins/decorations/bradient/main.cpp b/qtwayland/src/plugins/decorations/bradient/main.cpp
+index e75fda3c..fa885143 100644
+--- a/qtwayland/src/plugins/decorations/bradient/main.cpp
++++ b/qtwayland/src/plugins/decorations/bradient/main.cpp
+@@ -164,13 +164,10 @@ void QWaylandBradientDecoration::paint(QPaintDevice *device)
+     // Window icon
+     QIcon icon = waylandWindow()->windowIcon();
+     if (!icon.isNull()) {
+-        QPixmap pixmap = icon.pixmap(QSize(128, 128));
+-        QPixmap scaled = pixmap.scaled(22, 22, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+-
+         QRectF iconRect(0, 0, 22, 22);
+-        p.drawPixmap(iconRect.adjusted(margins().left() + BUTTON_SPACING, 4,
+-                                       margins().left() + BUTTON_SPACING, 4),
+-                     scaled, iconRect);
++        iconRect.adjust(margins().left() + BUTTON_SPACING, 4,
++                        margins().left() + BUTTON_SPACING, 4),
++        icon.paint(&p, iconRect.toRect());
+     }
+ 
+     // Window title
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
+index 85d25e3c..60bdd491 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
+@@ -47,18 +47,21 @@ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
+-QWaylandXdgPopupV5::QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow *window)
++QWaylandXdgPopupV5::QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow* parent, QWaylandWindow *window)
+     : QWaylandShellSurface(window)
+     , QtWayland::xdg_popup_v5(popup)
++    , m_parent(parent)
+     , m_window(window)
+ {
+     if (window->display()->windowExtension())
+         m_extendedWindow = new QWaylandExtendedSurface(window);
++    m_parent->addChildPopup(m_window);
+ }
+ 
+ QWaylandXdgPopupV5::~QWaylandXdgPopupV5()
+ {
+     xdg_popup_destroy(object());
++    m_parent->removeChildPopup(m_window);
+     delete m_extendedWindow;
+ }
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
+index 7494f6a6..d85f130b 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
+@@ -70,7 +70,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgPopupV5 : public QWaylandShellSurface
+ {
+     Q_OBJECT
+ public:
+-    QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow *window);
++    QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow* parent, QWaylandWindow *window);
+     ~QWaylandXdgPopupV5() override;
+ 
+ protected:
+@@ -78,6 +78,7 @@ protected:
+ 
+ private:
+     QWaylandExtendedSurface *m_extendedWindow = nullptr;
++    QWaylandWindow *m_parent = nullptr;
+     QWaylandWindow *m_window = nullptr;
+ };
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
+index 7e242c4a..def8452a 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
+@@ -84,7 +84,7 @@ QWaylandXdgPopupV5 *QWaylandXdgShellV5::createXdgPopup(QWaylandWindow *window, Q
+     int x = position.x() + parentWindow->frameMargins().left();
+     int y = position.y() + parentWindow->frameMargins().top();
+ 
+-    auto popup = new QWaylandXdgPopupV5(get_xdg_popup(window->wlSurface(), parentSurface, seat, m_popupSerial, x, y), window);
++    auto popup = new QWaylandXdgPopupV5(get_xdg_popup(window->wlSurface(), parentSurface, seat, m_popupSerial, x, y), parentWindow, window);
+     m_popups.append(window);
+     QObject::connect(popup, &QWaylandXdgPopupV5::destroyed, [this, window](){
+         m_popups.removeOne(window);
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
+index 4e25949f..cfc60939 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
+@@ -85,13 +85,6 @@ QWaylandShellSurface *QWaylandXdgShellV5Integration::createShellSurface(QWayland
+     return m_xdgShell->createXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellV5Integration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) {
+-    if (newFocus && qobject_cast<QWaylandXdgPopupV5 *>(newFocus->shellSurface()))
+-        m_display->handleWindowActivated(newFocus);
+-    if (oldFocus && qobject_cast<QWaylandXdgPopupV5 *>(oldFocus->shellSurface()))
+-        m_display->handleWindowDeactivated(oldFocus);
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
+index ce6bdb9e..aed88670 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
+@@ -67,7 +67,6 @@ public:
+     QWaylandXdgShellV5Integration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShellV5> m_xdgShell;
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
+index 8c371661..151c78e3 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
+@@ -174,6 +174,7 @@ QWaylandXdgSurfaceV6::Popup::Popup(QWaylandXdgSurfaceV6 *xdgSurface, QWaylandXdg
+     , m_xdgSurface(xdgSurface)
+     , m_parent(parent)
+ {
++    m_parent->window()->addChildPopup(m_xdgSurface->window());
+ }
+ 
+ QWaylandXdgSurfaceV6::Popup::~Popup()
+@@ -181,6 +182,8 @@ QWaylandXdgSurfaceV6::Popup::~Popup()
+     if (isInitialized())
+         destroy();
+ 
++    m_parent->window()->removeChildPopup(m_xdgSurface->window());
++
+     if (m_grabbing) {
+         auto *shell = m_xdgSurface->m_shell;
+         Q_ASSERT(shell->m_topmostGrabbingPopup == this);
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
+index 03164316..e8da8ba1 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
+@@ -68,20 +68,6 @@ QWaylandShellSurface *QWaylandXdgShellV6Integration::createShellSurface(QWayland
+     return m_xdgShell->getXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellV6Integration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus)
+-{
+-    if (newFocus) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurfaceV6 *>(newFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowActivated(newFocus);
+-    }
+-    if (oldFocus && qobject_cast<QWaylandXdgSurfaceV6 *>(oldFocus->shellSurface())) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurfaceV6 *>(oldFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowDeactivated(oldFocus);
+-    }
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
+index 261f8cbb..c1bcd5c6 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
+@@ -65,7 +65,6 @@ public:
+     QWaylandXdgShellV6Integration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShellV6> m_xdgShell;
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
+index f3e3c330..fa6d5808 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
+@@ -67,11 +67,6 @@ QWaylandXdgSurface::Toplevel::Toplevel(QWaylandXdgSurface *xdgSurface)
+ 
+ QWaylandXdgSurface::Toplevel::~Toplevel()
+ {
+-    if (m_applied.states & Qt::WindowActive) {
+-        QWaylandWindow *window = m_xdgSurface->window();
+-        window->display()->handleWindowDeactivated(window);
+-    }
+-
+     // The protocol spec requires that the decoration object is deleted before xdg_toplevel.
+     delete m_decoration;
+     m_decoration = nullptr;
+@@ -85,16 +80,15 @@ void QWaylandXdgSurface::Toplevel::applyConfigure()
+     if (!(m_applied.states & (Qt::WindowMaximized|Qt::WindowFullScreen)))
+         m_normalSize = m_xdgSurface->m_window->windowFrameGeometry().size();
+ 
+-    if ((m_pending.states & Qt::WindowActive) && !(m_applied.states & Qt::WindowActive))
++    if ((m_pending.states & Qt::WindowActive) && !(m_applied.states & Qt::WindowActive)
++        && !m_xdgSurface->m_window->display()->isKeyboardAvailable())
+         m_xdgSurface->m_window->display()->handleWindowActivated(m_xdgSurface->m_window);
+ 
+-    if (!(m_pending.states & Qt::WindowActive) && (m_applied.states & Qt::WindowActive))
++    if (!(m_pending.states & Qt::WindowActive) && (m_applied.states & Qt::WindowActive)
++        && !m_xdgSurface->m_window->display()->isKeyboardAvailable())
+         m_xdgSurface->m_window->display()->handleWindowDeactivated(m_xdgSurface->m_window);
+ 
+-    // TODO: none of the other plugins send WindowActive either, but is it on purpose?
+-    Qt::WindowStates statesWithoutActive = m_pending.states & ~Qt::WindowActive;
+-
+-    m_xdgSurface->m_window->handleWindowStatesChanged(statesWithoutActive);
++    m_xdgSurface->m_window->handleWindowStatesChanged(m_pending.states);
+ 
+     if (m_pending.size.isEmpty()) {
+         // An empty size in the configure means it's up to the client to choose the size
+@@ -105,8 +99,6 @@ void QWaylandXdgSurface::Toplevel::applyConfigure()
+         m_xdgSurface->m_window->resizeFromApplyConfigure(m_pending.size);
+     }
+ 
+-    m_xdgSurface->setSizeHints();
+-
+     m_applied = m_pending;
+     qCDebug(lcQpaWayland) << "Applied pending xdg_toplevel configure event:" << m_applied.size << m_applied.states;
+ }
+@@ -203,12 +195,17 @@ QtWayland::xdg_toplevel::resize_edge QWaylandXdgSurface::Toplevel::convertToResi
+                 | ((edges & Qt::RightEdge) ? resize_edge_right : 0));
+ }
+ 
+-QWaylandXdgSurface::Popup::Popup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parent,
++QWaylandXdgSurface::Popup::Popup(QWaylandXdgSurface *xdgSurface, QWaylandWindow *parent,
+                                  QtWayland::xdg_positioner *positioner)
+-    : xdg_popup(xdgSurface->get_popup(parent->object(), positioner->object()))
+-    , m_xdgSurface(xdgSurface)
++    : m_xdgSurface(xdgSurface)
++    , m_parentXdgSurface(qobject_cast<QWaylandXdgSurface *>(parent->shellSurface()))
+     , m_parent(parent)
+ {
++
++    init(xdgSurface->get_popup(m_parentXdgSurface ? m_parentXdgSurface->object() : nullptr, positioner->object()));
++    if (m_parent) {
++        m_parent->addChildPopup(m_xdgSurface->window());
++    }
+ }
+ 
+ QWaylandXdgSurface::Popup::~Popup()
+@@ -216,10 +213,24 @@ QWaylandXdgSurface::Popup::~Popup()
+     if (isInitialized())
+         destroy();
+ 
++    if (m_parent) {
++        m_parent->removeChildPopup(m_xdgSurface->window());
++    }
++
+     if (m_grabbing) {
+         auto *shell = m_xdgSurface->m_shell;
+         Q_ASSERT(shell->m_topmostGrabbingPopup == this);
+-        shell->m_topmostGrabbingPopup = m_parent->m_popup;
++        shell->m_topmostGrabbingPopup = m_parentXdgSurface ? m_parentXdgSurface->m_popup : nullptr;
++        m_grabbing = false;
++
++        // Synthesize Qt enter/leave events for popup
++        QWindow *leave = nullptr;
++        if (m_xdgSurface && m_xdgSurface->window())
++            leave = m_xdgSurface->window()->window();
++        QWindowSystemInterface::handleLeaveEvent(leave);
++
++        if (QWindow *enter = QGuiApplication::topLevelAt(QCursor::pos()))
++            QWindowSystemInterface::handleEnterEvent(enter, enter->mapFromGlobal(QCursor::pos()), QCursor::pos());
+     }
+ }
+ 
+@@ -257,6 +268,7 @@ QWaylandXdgSurface::QWaylandXdgSurface(QWaylandXdgShell *shell, ::xdg_surface *s
+                 m_toplevel->set_parent(parentXdgSurface->m_toplevel->object());
+         }
+     }
++    setSizeHints();
+ }
+ 
+ QWaylandXdgSurface::~QWaylandXdgSurface()
+@@ -400,8 +412,6 @@ void QWaylandXdgSurface::setPopup(QWaylandWindow *parent)
+ {
+     Q_ASSERT(!m_toplevel && !m_popup);
+ 
+-    auto parentXdgSurface = static_cast<QWaylandXdgSurface *>(parent->shellSurface());
+-
+     auto positioner = new QtWayland::xdg_positioner(m_shell->create_positioner());
+     // set_popup expects a position relative to the parent
+     QPoint transientPos = m_window->geometry().topLeft(); // this is absolute
+@@ -414,8 +424,9 @@ void QWaylandXdgSurface::setPopup(QWaylandWindow *parent)
+     positioner->set_anchor(QtWayland::xdg_positioner::anchor_top_left);
+     positioner->set_gravity(QtWayland::xdg_positioner::gravity_bottom_right);
+     positioner->set_size(m_window->geometry().width(), m_window->geometry().height());
+-    m_popup = new Popup(this, parentXdgSurface, positioner);
++    m_popup = new Popup(this, parent, positioner);
+     positioner->destroy();
++
+     delete positioner;
+ }
+ 
+@@ -437,6 +448,23 @@ void QWaylandXdgSurface::setGrabPopup(QWaylandWindow *parent, QWaylandInputDevic
+     }
+     setPopup(parent);
+     m_popup->grab(device, serial);
++
++    // Synthesize Qt enter/leave events for popup
++    if (!parent)
++        return;
++    QWindow *current = QGuiApplication::topLevelAt(QCursor::pos());
++    QWindow *leave = parent->window();
++    if (current != leave)
++        return;
++
++    QWindowSystemInterface::handleLeaveEvent(leave);
++
++    QWindow *enter = nullptr;
++    if (m_popup && m_popup->m_xdgSurface && m_popup->m_xdgSurface->window())
++        enter = m_popup->m_xdgSurface->window()->window();
++
++    if (enter)
++        QWindowSystemInterface::handleEnterEvent(enter, enter->mapFromGlobal(QCursor::pos()), QCursor::pos());
+ }
+ 
+ void QWaylandXdgSurface::xdg_surface_configure(uint32_t serial)
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
+index 96785205..4b518f0a 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
+@@ -131,14 +131,15 @@ private:
+ 
+     class Popup : public QtWayland::xdg_popup {
+     public:
+-        Popup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parent, QtWayland::xdg_positioner *positioner);
++        Popup(QWaylandXdgSurface *xdgSurface, QWaylandWindow *parent, QtWayland::xdg_positioner *positioner);
+         ~Popup() override;
+ 
+         void grab(QWaylandInputDevice *seat, uint serial);
+         void xdg_popup_popup_done() override;
+ 
+         QWaylandXdgSurface *m_xdgSurface = nullptr;
+-        QWaylandXdgSurface *m_parent = nullptr;
++        QWaylandXdgSurface *m_parentXdgSurface = nullptr;
++        QWaylandWindow *m_parent = nullptr;
+         bool m_grabbing = false;
+     };
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
+index 8769d971..da0dd6a7 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
+@@ -69,20 +69,6 @@ QWaylandShellSurface *QWaylandXdgShellIntegration::createShellSurface(QWaylandWi
+     return m_xdgShell->getXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellIntegration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus)
+-{
+-    if (newFocus) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurface *>(newFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowActivated(newFocus);
+-    }
+-    if (oldFocus && qobject_cast<QWaylandXdgSurface *>(oldFocus->shellSurface())) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurface *>(oldFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowDeactivated(oldFocus);
+-    }
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
+index b6caa6c9..2f929f98 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
+@@ -65,7 +65,6 @@ public:
+     QWaylandXdgShellIntegration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShell> m_xdgShell;
+diff --git a/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp b/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
+index 526d0ef4..f50ccf30 100644
+--- a/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
++++ b/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
+@@ -39,7 +39,10 @@
+ 
+ #include "qwaylandinputmethodeventbuilder_p.h"
+ 
++#include <QBrush>
++#include <QGuiApplication>
+ #include <QInputMethod>
++#include <QPalette>
+ #include <QTextCharFormat>
+ 
+ #ifdef QT_BUILD_WAYLANDCOMPOSITOR_LIB
+@@ -81,32 +84,38 @@ void QWaylandInputMethodEventBuilder::addPreeditStyling(uint32_t index, uint32_t
+     QTextCharFormat format;
+ 
+     switch (style) {
+-    case 0:
+-    case 1:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_NONE:
++        break;
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_DEFAULT:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_UNDERLINE:
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-    case 2:
+-    case 3:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_ACTIVE:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_INACTIVE:
+         format.setFontWeight(QFont::Bold);
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-    case 4:
+-        format.setFontUnderline(true);
+-        format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+-        m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_HIGHLIGHT:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_SELECTION:
++        {
++            format.setFontUnderline(true);
++            format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
++            QPalette palette = qApp->palette();
++            format.setBackground(QBrush(palette.color(QPalette::Active, QPalette::Highlight)));
++            format.setForeground(QBrush(palette.color(QPalette::Active, QPalette::HighlightedText)));
++            m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
++        }
+         break;
+-    case 5:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_INCORRECT:
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::WaveUnderline);
+         format.setUnderlineColor(QColor(Qt::red));
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-//    case QtWayland::wl_text_input::preedit_style_selection:
+-//    case QtWayland::wl_text_input::preedit_style_none:
+     default:
+         break;
+     }
+@@ -153,7 +162,7 @@ QInputMethodEvent QWaylandInputMethodEventBuilder::buildPreedit(const QString &t
+ 
+     if (m_preeditCursor < 0) {
+         attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, 0, QVariant()));
+-    } else if (m_preeditCursor > 0) {
++    } else {
+         attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, indexFromWayland(text, m_preeditCursor), 1, QVariant()));
+     }
+ 
+diff --git a/qtwayland/src/shared/qwaylandmimehelper.cpp b/qtwayland/src/shared/qwaylandmimehelper.cpp
+index a5fdd34d..e2fe1928 100644
+--- a/qtwayland/src/shared/qwaylandmimehelper.cpp
++++ b/qtwayland/src/shared/qwaylandmimehelper.cpp
+@@ -60,7 +60,7 @@ QByteArray QWaylandMimeHelper::getByteArray(QMimeData *mimeData, const QString &
+             buf.open(QIODevice::ReadWrite);
+             QByteArray fmt = "BMP";
+             if (mimeType.startsWith(QLatin1String("image/"))) {
+-                QByteArray imgFmt = mimeType.mid(6).toUpper().toLatin1();
++                QByteArray imgFmt = mimeType.mid(6).toLower().toLatin1();
+                 if (QImageWriter::supportedImageFormats().contains(imgFmt))
+                     fmt = imgFmt;
+             }
+@@ -74,7 +74,7 @@ QByteArray QWaylandMimeHelper::getByteArray(QMimeData *mimeData, const QString &
+         QList<QUrl> urls = mimeData->urls();
+         for (int i = 0; i < urls.count(); ++i) {
+             content.append(urls.at(i).toEncoded());
+-            content.append('\n');
++            content.append("\r\n");
+         }
+     } else {
+         content = mimeData->data(mimeType);
+diff --git a/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp b/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
+index 1568b3b9..067410d0 100644
+--- a/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
++++ b/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
+@@ -35,7 +35,7 @@
+ 
+ using namespace MockCompositor;
+ 
+-constexpr int dataDeviceVersion = 1;
++constexpr int dataDeviceVersion = 3;
+ 
+ class DataDeviceCompositor : public DefaultCompositor {
+ public:
+diff --git a/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp b/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
+index 9312c2e5..2ea382f1 100644
+--- a/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
++++ b/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
+@@ -73,6 +73,7 @@ private slots:
+     void multiTouch();
+     void multiTouchUpAndMotionFrame();
+     void tapAndMoveInSameFrame();
++    void cancelTouch();
+ };
+ 
+ void tst_seatv5::bindsToSeat()
+@@ -646,5 +647,34 @@ void tst_seatv5::tapAndMoveInSameFrame()
+     QTRY_COMPARE(window.m_events.last().touchPoints.first().state(), Qt::TouchPointState::TouchPointReleased);
+ }
+ 
++void tst_seatv5::cancelTouch()
++{
++    TouchWindow window;
++    QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
++
++    exec([=] {
++        auto *t = touch();
++        auto *c = client();
++        t->sendDown(xdgToplevel()->surface(), {32, 32}, 1);
++        t->sendFrame(c);
++        t->sendCancel(c);
++        t->sendFrame(c);
++    });
++
++    QTRY_VERIFY(!window.m_events.empty());
++    {
++        auto e = window.m_events.takeFirst();
++        QCOMPARE(e.type, QEvent::TouchBegin);
++        QCOMPARE(e.touchPointStates, Qt::TouchPointPressed);
++        QCOMPARE(e.touchPoints.length(), 1);
++        QCOMPARE(e.touchPoints.first().pos(), QPointF(32-window.frameMargins().left(), 32-window.frameMargins().top()));
++    }
++    {
++        auto e = window.m_events.takeFirst();
++        QCOMPARE(e.type, QEvent::TouchCancel);
++        QCOMPARE(e.touchPoints.length(), 0);
++    }
++}
++
+ QCOMPOSITOR_TEST_MAIN(tst_seatv5)
+ #include "tst_seatv5.moc"
+diff --git a/qtwayland/tests/auto/client/shared/corecompositor.cpp b/qtwayland/tests/auto/client/shared/corecompositor.cpp
+index 5c6c83ba..fa9b7662 100644
+--- a/qtwayland/tests/auto/client/shared/corecompositor.cpp
++++ b/qtwayland/tests/auto/client/shared/corecompositor.cpp
+@@ -27,6 +27,7 @@
+ ****************************************************************************/
+ 
+ #include "corecompositor.h"
++#include <thread>
+ 
+ namespace MockCompositor {
+ 
+diff --git a/qtwayland/tests/auto/client/shared/coreprotocol.cpp b/qtwayland/tests/auto/client/shared/coreprotocol.cpp
+index 0d988521..d1a2e7cb 100644
+--- a/qtwayland/tests/auto/client/shared/coreprotocol.cpp
++++ b/qtwayland/tests/auto/client/shared/coreprotocol.cpp
+@@ -451,6 +451,13 @@ void Touch::sendFrame(wl_client *client)
+         send_frame(r->handle);
+ }
+ 
++void Touch::sendCancel(wl_client *client)
++{
++    const auto touchResources = resourceMap().values(client);
++    for (auto *r : touchResources)
++        send_cancel(r->handle);
++}
++
+ uint Keyboard::sendEnter(Surface *surface)
+ {
+     auto serial = m_seat->m_compositor->nextSerial();
+diff --git a/qtwayland/tests/auto/client/shared/coreprotocol.h b/qtwayland/tests/auto/client/shared/coreprotocol.h
+index a1af137a..210d8ddb 100644
+--- a/qtwayland/tests/auto/client/shared/coreprotocol.h
++++ b/qtwayland/tests/auto/client/shared/coreprotocol.h
+@@ -158,7 +158,7 @@ class WlCompositor : public Global, public QtWaylandServer::wl_compositor
+ {
+     Q_OBJECT
+ public:
+-    explicit WlCompositor(CoreCompositor *compositor, int version = 3)
++    explicit WlCompositor(CoreCompositor *compositor, int version = 4)
+         : QtWaylandServer::wl_compositor(compositor->m_display, version)
+         , m_compositor(compositor)
+     {}
+@@ -364,6 +364,7 @@ public:
+     uint sendUp(wl_client *client, int id);
+     void sendMotion(wl_client *client, const QPointF &position, int id);
+     void sendFrame(wl_client *client);
++    void sendCancel(wl_client *client);
+ 
+     Seat *m_seat = nullptr;
+ };
+diff --git a/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp b/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
+index a415cbf5..b1d3d07d 100644
+--- a/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
++++ b/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
+@@ -342,7 +342,7 @@ Compositor::Compositor(MockCompositor *mockCompositor)
+         exit(EXIT_FAILURE);
+     }
+ 
+-    wl_global_create(m_display, &wl_compositor_interface, 1, this, bindCompositor);
++    wl_global_create(m_display, &wl_compositor_interface, 4, this, bindCompositor);
+ 
+     m_data_device_manager.reset(new DataDeviceManager(this, m_display));
+ 
+diff --git a/qtwayland/tests/auto/client/shared_old/mocksurface.cpp b/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
+index e9df5f90..c3246e4a 100644
+--- a/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
++++ b/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
+@@ -125,6 +125,16 @@ void Surface::surface_damage(Resource *resource,
+     Q_UNUSED(height);
+ }
+ 
++void Surface::surface_damage_buffer(Resource *resource,
++                                    int32_t x, int32_t y, int32_t width, int32_t height)
++{
++    Q_UNUSED(resource);
++    Q_UNUSED(x);
++    Q_UNUSED(y);
++    Q_UNUSED(width);
++    Q_UNUSED(height);
++}
++
+ void Surface::surface_frame(Resource *resource,
+                             uint32_t callback)
+ {
+diff --git a/qtwayland/tests/auto/client/shared_old/mocksurface.h b/qtwayland/tests/auto/client/shared_old/mocksurface.h
+index 949dc23d..d176837e 100644
+--- a/qtwayland/tests/auto/client/shared_old/mocksurface.h
++++ b/qtwayland/tests/auto/client/shared_old/mocksurface.h
+@@ -65,6 +65,8 @@ protected:
+                         struct wl_resource *buffer, int x, int y) override;
+     void surface_damage(Resource *resource,
+                         int32_t x, int32_t y, int32_t width, int32_t height) override;
++    void surface_damage_buffer(Resource *resource,
++                               int32_t x, int32_t y, int32_t width, int32_t height) override;
+     void surface_frame(Resource *resource,
+                        uint32_t callback) override;
+     void surface_commit(Resource *resource) override;
+diff --git a/qtwayland/tests/auto/client/surface/tst_surface.cpp b/qtwayland/tests/auto/client/surface/tst_surface.cpp
+index 95e4e609..60c672ce 100644
+--- a/qtwayland/tests/auto/client/surface/tst_surface.cpp
++++ b/qtwayland/tests/auto/client/surface/tst_surface.cpp
+@@ -129,6 +129,10 @@ void tst_surface::waitForFrameCallbackGl()
+     // Make sure we follow frame callbacks for some frames
+     for (int i = 0; i < 5; ++i) {
+         xdgPingAndWaitForPong(); // Make sure things have happened on the client
++        if (!qEnvironmentVariableIntValue("QT_WAYLAND_DISABLE_WINDOWDECORATION") && i == 0) {
++            QCOMPARE(bufferSpy.count(), 1);
++            bufferSpy.removeFirst();
++        }
+         exec([&] {
+             QVERIFY(bufferSpy.empty()); // Make sure no extra buffers have arrived
+             QVERIFY(!xdgToplevel()->surface()->m_waitingFrameCallbacks.empty());
+diff --git a/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp b/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
+index 2277bbb8..747875b4 100644
+--- a/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
++++ b/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
+@@ -31,6 +31,7 @@
+ #include <QtGui/QOpenGLWindow>
+ #include <QtGui/qpa/qplatformnativeinterface.h>
+ #include <QtWaylandClient/private/wayland-wayland-client-protocol.h>
++#include <QtWaylandClient/private/qwaylandwindow_p.h>
+ 
+ using namespace MockCompositor;
+ 
+@@ -45,6 +46,7 @@ private slots:
+     void configureStates();
+     void popup();
+     void tooltipOnPopup();
++    void tooltipAndSiblingPopup();
+     void switchPopups();
+     void hidePopupParent();
+     void pongs();
+@@ -138,6 +140,7 @@ void tst_xdgshell::configureSize()
+ 
+ void tst_xdgshell::configureStates()
+ {
++    QVERIFY(qputenv("QT_WAYLAND_FRAME_CALLBACK_TIMEOUT", "0"));
+     QRasterWindow window;
+     window.resize(64, 48);
+     window.show();
+@@ -154,9 +157,12 @@ void tst_xdgshell::configureStates()
+     // Toplevel windows don't know their position on xdg-shell
+ //    QCOMPARE(window.frameGeometry().topLeft(), QPoint()); // TODO: this doesn't currently work when window decorations are enabled
+ 
+-//    QEXPECT_FAIL("", "configure has already been acked, we shouldn't have to wait for isActive", Continue);
+-//    QVERIFY(window.isActive());
+-    QTRY_VERIFY(window.isActive()); // Just make sure it eventually get's set correctly
++    // window.windowstate() is driven by keyboard focus, however for decorations we want to follow
++    // XDGShell this is internal to QtWayland so it is queried directly
++    auto waylandWindow = static_cast<QtWaylandClient::QWaylandWindow *>(window.handle());
++    Q_ASSERT(waylandWindow);
++    QTRY_VERIFY(waylandWindow->windowStates().testFlag(
++            Qt::WindowActive)); // Just make sure it eventually get's set correctly
+ 
+     const QSize screenSize(640, 480);
+     const uint maximizedSerial = exec([=] {
+@@ -186,6 +192,7 @@ void tst_xdgshell::configureStates()
+     QCOMPARE(window.windowStates(), Qt::WindowNoState);
+     QCOMPARE(window.frameGeometry().size(), windowedSize);
+ //    QCOMPARE(window.frameGeometry().topLeft(), QPoint()); // TODO: this doesn't currently work when window decorations are enabled
++    QVERIFY(qunsetenv("QT_WAYLAND_FRAME_CALLBACK_TIMEOUT"));
+ }
+ 
+ void tst_xdgshell::popup()
+@@ -340,6 +347,92 @@ void tst_xdgshell::tooltipOnPopup()
+     QCOMPOSITOR_TRY_COMPARE(xdgPopup(0), nullptr);
+ }
+ 
++void tst_xdgshell::tooltipAndSiblingPopup()
++{
++    class ToolTip : public QRasterWindow {
++    public:
++        explicit ToolTip(QWindow *parent) {
++            setTransientParent(parent);
++            setFlags(Qt::ToolTip);
++            resize(100, 100);
++            show();
++        }
++        void mousePressEvent(QMouseEvent *event) override {
++            QRasterWindow::mousePressEvent(event);
++            m_popup = new QRasterWindow;
++            m_popup->setTransientParent(transientParent());
++            m_popup->setFlags(Qt::Popup);
++            m_popup->resize(100, 100);
++            m_popup->show();
++        }
++
++        QRasterWindow *m_popup = nullptr;
++    };
++
++    class Window : public QRasterWindow {
++    public:
++        void mousePressEvent(QMouseEvent *event) override {
++            QRasterWindow::mousePressEvent(event);
++            m_tooltip = new ToolTip(this);
++        }
++        ToolTip *m_tooltip = nullptr;
++    };
++
++    Window window;
++    window.resize(200, 200);
++    window.show();
++
++    QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
++    exec([=] { xdgToplevel()->sendCompleteConfigure(); });
++    QCOMPOSITOR_TRY_VERIFY(xdgToplevel()->m_xdgSurface->m_committedConfigureSerial);
++
++    exec([=] {
++        auto *surface = xdgToplevel()->surface();
++        auto *p = pointer();
++        auto *c = client();
++        p->sendEnter(surface, {100, 100});
++        p->sendFrame(c);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_pressed);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_released);
++        p->sendFrame(c);
++        p->sendLeave(surface);
++        p->sendFrame(c);
++    });
++
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup());
++    exec([=] { xdgPopup()->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup()->m_xdgSurface->m_committedConfigureSerial);
++    QCOMPOSITOR_TRY_VERIFY(!xdgPopup()->m_grabbed);
++
++    exec([=] {
++        auto *surface = xdgPopup()->surface();
++        auto *p = pointer();
++        auto *c = client();
++        p->sendEnter(surface, {100, 100});
++        p->sendFrame(c);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_pressed);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_released);
++        p->sendFrame(c);
++    });
++
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1));
++    exec([=] { xdgPopup(1)->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1)->m_xdgSurface->m_committedConfigureSerial);
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1)->m_grabbed);
++
++    // Close the middle tooltip (it should not close the sibling popup)
++    window.m_tooltip->close();
++
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(1), nullptr);
++    // Verify the remaining xdg surface is a grab popup..
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(0));
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(0)->m_grabbed);
++
++    window.m_tooltip->m_popup->close();
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(1), nullptr);
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(0), nullptr);
++}
++
+ // QTBUG-65680
+ void tst_xdgshell::switchPopups()
+ {
+@@ -505,7 +598,7 @@ void tst_xdgshell::minMaxSize()
+     window.show();
+     QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
+ 
+-    exec([=] { xdgToplevel()->sendCompleteConfigure(); });
++    // we don't roundtrip with our configuration the initial commit should be correct
+ 
+     QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.minSize, QSize(100, 100));
+     QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.maxSize, QSize(1000, 1000));
+Submodule qtwebchannel 618422ee..f8949655:
+diff --git a/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp b/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
+index 536eb5c..898d769 100644
+--- a/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
++++ b/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
+@@ -186,8 +186,6 @@ Q_DECLARE_TYPEINFO(OverloadResolutionCandidate, Q_MOVABLE_TYPE);
+ QMetaObjectPublisher::QMetaObjectPublisher(QWebChannel *webChannel)
+     : QObject(webChannel)
+     , webChannel(webChannel)
+-    , signalHandler(this)
+-    , clientIsIdle(false)
+     , blockUpdates(false)
+     , propertyUpdatesInitialized(false)
+ {
+@@ -301,17 +299,17 @@ QJsonObject QMetaObjectPublisher::classInfoForObject(const QObject *object, QWeb
+     return data;
+ }
+ 
+-void QMetaObjectPublisher::setClientIsIdle(bool isIdle)
++void QMetaObjectPublisher::setClientIsIdle(bool isIdle, QWebChannelAbstractTransport *transport)
+ {
+-    if (clientIsIdle == isIdle) {
+-        return;
+-    }
+-    clientIsIdle = isIdle;
+-    if (!isIdle && timer.isActive()) {
+-        timer.stop();
+-    } else if (isIdle && !timer.isActive()) {
+-        timer.start(PROPERTY_UPDATE_INTERVAL, this);
+-    }
++    transportState[transport].clientIsIdle = isIdle;
++    if (isIdle)
++        sendEnqueuedPropertyUpdates(transport);
++}
++
++bool QMetaObjectPublisher::isClientIdle(QWebChannelAbstractTransport *transport)
++{
++    auto found = transportState.find(transport);
++    return found != transportState.end() && found.value().clientIsIdle;
+ }
+ 
+ QJsonObject QMetaObjectPublisher::initializeClient(QWebChannelAbstractTransport *transport)
+@@ -333,6 +331,7 @@ QJsonObject QMetaObjectPublisher::initializeClient(QWebChannelAbstractTransport
+ 
+ void QMetaObjectPublisher::initializePropertyUpdates(const QObject *const object, const QJsonObject &objectInfo)
+ {
++    auto *signalHandler = signalHandlerFor(object);
+     foreach (const QJsonValue &propertyInfoVar, objectInfo[KEY_PROPERTIES].toArray()) {
+         const QJsonArray &propertyInfo = propertyInfoVar.toArray();
+         if (propertyInfo.size() < 2) {
+@@ -353,19 +352,19 @@ void QMetaObjectPublisher::initializePropertyUpdates(const QObject *const object
+ 
+         // Only connect for a property update once
+         if (connectedProperties.isEmpty()) {
+-            signalHandler.connectTo(object, signalIndex);
++            signalHandler->connectTo(object, signalIndex);
+         }
+ 
+         connectedProperties.insert(propertyIndex);
+     }
+ 
+     // also always connect to destroyed signal
+-    signalHandler.connectTo(object, s_destroyedSignalIndex);
++    signalHandler->connectTo(object, s_destroyedSignalIndex);
+ }
+ 
+ void QMetaObjectPublisher::sendPendingPropertyUpdates()
+ {
+-    if (blockUpdates || !clientIsIdle || pendingPropertyUpdates.isEmpty()) {
++    if (blockUpdates) {
+         return;
+     }
+ 
+@@ -415,18 +414,19 @@ void QMetaObjectPublisher::sendPendingPropertyUpdates()
+ 
+     // data does not contain specific updates
+     if (!data.isEmpty()) {
+-        setClientIsIdle(false);
+-
+         message[KEY_DATA] = data;
+-        broadcastMessage(message);
++        enqueueBroadcastMessage(message);
+     }
+ 
+     // send every property update which is not supposed to be broadcasted
+     const QHash<QWebChannelAbstractTransport*, QJsonArray>::const_iterator suend = specificUpdates.constEnd();
+     for (QHash<QWebChannelAbstractTransport*, QJsonArray>::const_iterator it = specificUpdates.constBegin(); it != suend; ++it) {
+         message[KEY_DATA] = it.value();
+-        it.key()->sendMessage(message);
++        enqueueMessage(message, it.key());
+     }
++
++    for (auto state = transportState.begin(); state != transportState.end(); ++state)
++        sendEnqueuedPropertyUpdates(state.key());
+ }
+ 
+ QVariant QMetaObjectPublisher::invokeMethod(QObject *const object, const QMetaMethod &method,
+@@ -572,7 +572,7 @@ void QMetaObjectPublisher::signalEmitted(const QObject *object, const int signal
+         }
+     } else {
+         pendingPropertyUpdates[object][signalIndex] = arguments;
+-        if (clientIsIdle && !blockUpdates && !timer.isActive()) {
++        if (!blockUpdates && !timer.isActive()) {
+             timer.start(PROPERTY_UPDATE_INTERVAL, this);
+         }
+     }
+@@ -590,7 +590,7 @@ void QMetaObjectPublisher::objectDestroyed(const QObject *object)
+     // only remove from handler when we initialized the property updates
+     // cf: https://bugreports.qt.io/browse/QTBUG-60250
+     if (propertyUpdatesInitialized) {
+-        signalHandler.remove(object);
++        signalHandlerFor(object)->remove(object);
+         signalToPropertyMap.remove(object);
+     }
+     pendingPropertyUpdates.remove(object);
+@@ -852,6 +852,52 @@ void QMetaObjectPublisher::broadcastMessage(const QJsonObject &message) const
+     }
+ }
+ 
++void QMetaObjectPublisher::enqueueBroadcastMessage(const QJsonObject &message)
++{
++    if (webChannel->d_func()->transports.isEmpty()) {
++        qWarning("QWebChannel is not connected to any transports, cannot send message: %s",
++                 QJsonDocument(message).toJson().constData());
++        return;
++    }
++
++    for (auto *transport : webChannel->d_func()->transports) {
++        auto &state = transportState[transport];
++        state.queuedMessages.append(message);
++    }
++}
++
++void QMetaObjectPublisher::enqueueMessage(const QJsonObject &message,
++                                          QWebChannelAbstractTransport *transport)
++{
++    auto &state = transportState[transport];
++    state.queuedMessages.append(message);
++}
++
++void QMetaObjectPublisher::sendEnqueuedPropertyUpdates(QWebChannelAbstractTransport *transport)
++{
++    auto found = transportState.find(transport);
++    if (found != transportState.end() && found.value().clientIsIdle
++        && !found.value().queuedMessages.isEmpty()) {
++
++        // If the client is connected with an in-process transport, it can
++        // happen that a message triggers a subsequent property change. In
++        // that case, we need to ensure that the queued messages have already
++        // been cleared; otherwise the recursive call will send everythig again.
++        // Case in point: The qmlwebchannel tests fail if we don't clear the
++        // queued messages before sending them out.
++        // For that same reason set the client to "busy" (aka non-idle) just
++        // right before sending out the messages; otherwise a potential
++        // "Idle" type message will not correctly restore the Idle state.
++        const auto messages = std::move(found.value().queuedMessages);
++        Q_ASSERT(found.value().queuedMessages.isEmpty());
++        found.value().clientIsIdle = false;
++
++        for (const auto &message : messages) {
++            transport->sendMessage(message);
++        }
++    }
++}
++
+ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannelAbstractTransport *transport)
+ {
+     if (!webChannel->d_func()->transports.contains(transport)) {
+@@ -866,7 +912,7 @@ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannel
+ 
+     const MessageType type = toType(message.value(KEY_TYPE));
+     if (type == TypeIdle) {
+-        setClientIsIdle(true);
++        setClientIsIdle(true, transport);
+     } else if (type == TypeInit) {
+         if (!message.contains(KEY_ID)) {
+             qWarning("JSON message object is missing the id property: %s",
+@@ -913,9 +959,9 @@ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannel
+                 return;
+             transport->sendMessage(createResponse(message.value(KEY_ID), wrapResult(result, transport)));
+         } else if (type == TypeConnectToSignal) {
+-            signalHandler.connectTo(object, message.value(KEY_SIGNAL).toInt(-1));
++            signalHandlerFor(object)->connectTo(object, message.value(KEY_SIGNAL).toInt(-1));
+         } else if (type == TypeDisconnectFromSignal) {
+-            signalHandler.disconnectFrom(object, message.value(KEY_SIGNAL).toInt(-1));
++            signalHandlerFor(object)->disconnectFrom(object, message.value(KEY_SIGNAL).toInt(-1));
+         } else if (type == TypeSetProperty) {
+             setProperty(object, message.value(KEY_PROPERTY).toInt(-1),
+                         message.value(KEY_VALUE));
+@@ -931,6 +977,7 @@ void QMetaObjectPublisher::setBlockUpdates(bool block)
+     blockUpdates = block;
+ 
+     if (!blockUpdates) {
++        timer.start(PROPERTY_UPDATE_INTERVAL, this);
+         sendPendingPropertyUpdates();
+     } else if (timer.isActive()) {
+         timer.stop();
+@@ -948,4 +995,15 @@ void QMetaObjectPublisher::timerEvent(QTimerEvent *event)
+     }
+ }
+ 
++SignalHandler<QMetaObjectPublisher> *QMetaObjectPublisher::signalHandlerFor(const QObject *object)
++{
++    auto thread = object->thread();
++    auto it = signalHandlers.find(thread);
++    if (it == signalHandlers.end()) {
++        it = signalHandlers.emplace(thread, this).first;
++        it->second.moveToThread(thread);
++    }
++    return &it->second;
++}
++
+ QT_END_NAMESPACE
+diff --git a/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h b/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
+index bbd9875..4713ef1 100644
+--- a/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
++++ b/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
+@@ -59,6 +59,9 @@
+ #include <QBasicTimer>
+ #include <QPointer>
+ #include <QJsonObject>
++#include <QQueue>
++
++#include <unordered_map>
+ 
+ #include "qwebchannelglobal.h"
+ 
+@@ -109,17 +112,36 @@ public:
+      */
+     void broadcastMessage(const QJsonObject &message) const;
+ 
++    /**
++     * Enqueue the given @p message to all known transports.
++     */
++    void enqueueBroadcastMessage(const QJsonObject &message);
++
++    /**
++     * Enqueue the given @p message to @p transport.
++     */
++    void enqueueMessage(const QJsonObject &message, QWebChannelAbstractTransport *transport);
++
++    /**
++     * If client for given @p transport is idle, send queued messaged to @p transport and then mark
++     * the client as not idle.
++     */
++    void sendEnqueuedPropertyUpdates(QWebChannelAbstractTransport *transport);
++
+     /**
+      * Serialize the QMetaObject of @p object and return it in JSON form.
+      */
+     QJsonObject classInfoForObject(const QObject *object, QWebChannelAbstractTransport *transport);
+ 
+     /**
+-     * Set the client to idle or busy, based on the value of @p isIdle.
+-     *
+-     * When the value changed, start/stop the property update timer accordingly.
++     * Set the client to idle or busy for a single @p transport, based on the value of @p isIdle.
++     */
++    void setClientIsIdle(bool isIdle, QWebChannelAbstractTransport *transport);
++
++    /**
++     * Check that client is idle for @p transport.
+      */
+-    void setClientIsIdle(bool isIdle);
++    bool isClientIdle(QWebChannelAbstractTransport *transport);
+ 
+     /**
+      * Initialize clients by sending them the class information of the registered objects.
+@@ -272,10 +294,18 @@ private:
+     friend class TestWebChannel;
+ 
+     QWebChannel *webChannel;
+-    SignalHandler<QMetaObjectPublisher> signalHandler;
++    std::unordered_map<const QThread*, SignalHandler<QMetaObjectPublisher>> signalHandlers;
++    SignalHandler<QMetaObjectPublisher> *signalHandlerFor(const QObject *object);
+ 
+-    // true when the client is idle, false otherwise
+-    bool clientIsIdle;
++    struct TransportState
++    {
++        TransportState() : clientIsIdle(false) { }
++        // true when the client is idle, false otherwise
++        bool clientIsIdle;
++        // messages to send
++        QQueue<QJsonObject> queuedMessages;
++    };
++    QHash<QWebChannelAbstractTransport *, TransportState> transportState;
+ 
+     // true when no property updates should be sent, false otherwise
+     bool blockUpdates;
+diff --git a/qtwebchannel/src/webchannel/signalhandler_p.h b/qtwebchannel/src/webchannel/signalhandler_p.h
+index 27afadb..d77373c 100644
+--- a/qtwebchannel/src/webchannel/signalhandler_p.h
++++ b/qtwebchannel/src/webchannel/signalhandler_p.h
+@@ -56,6 +56,7 @@
+ #include <QVector>
+ #include <QMetaMethod>
+ #include <QDebug>
++#include <QThread>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -71,6 +72,7 @@ static const int s_destroyedSignalIndex = QObject::staticMetaObject.indexOfMetho
+ template<class Receiver>
+ class SignalHandler : public QObject
+ {
++    Q_DISABLE_COPY(SignalHandler)
+ public:
+     SignalHandler(Receiver *receiver, QObject *parent = 0);
+ 
+@@ -268,6 +270,7 @@ int SignalHandler<Receiver>::qt_metacall(QMetaObject::Call call, int methodId, v
+     if (call == QMetaObject::InvokeMetaMethod) {
+         const QObject *object = sender();
+         Q_ASSERT(object);
++        Q_ASSERT(QThread::currentThread() == object->thread());
+         Q_ASSERT(senderSignalIndex() == methodId);
+         Q_ASSERT(m_connectionsCounter.contains(object));
+         Q_ASSERT(m_connectionsCounter.value(object).contains(methodId));
+diff --git a/qtwebchannel/tests/auto/qml/testwebchannel.cpp b/qtwebchannel/tests/auto/qml/testwebchannel.cpp
+index 9891687..3ca81c2 100644
+--- a/qtwebchannel/tests/auto/qml/testwebchannel.cpp
++++ b/qtwebchannel/tests/auto/qml/testwebchannel.cpp
+@@ -46,7 +46,11 @@ TestWebChannel::~TestWebChannel()
+ 
+ bool TestWebChannel::clientIsIdle() const
+ {
+-    return QWebChannel::d_func()->publisher->clientIsIdle;
++    for (auto *transport : QWebChannel::d_func()->transports) {
++        if (QWebChannel::d_func()->publisher->isClientIdle(transport))
++            return true;
++    }
++    return false;
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp b/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
+index 181da9e..37f989a 100644
+--- a/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
++++ b/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
+@@ -785,7 +785,7 @@ void TestWebChannel::testTransportWrapObjectProperties()
+     DummyTransport *dummyTransport = new DummyTransport(this);
+     channel.connectTo(dummyTransport);
+     channel.d_func()->publisher->initializeClient(dummyTransport);
+-    channel.d_func()->publisher->setClientIsIdle(true);
++    channel.d_func()->publisher->setClientIsIdle(true, dummyTransport);
+ 
+     QCOMPARE(channel.d_func()->publisher->transportedWrappedObjects.size(), 0);
+ 
+@@ -943,8 +943,6 @@ void TestWebChannel::testInfiniteRecursion()
+ 
+ void TestWebChannel::testAsyncObject()
+ {
+-    QSKIP("This test is broken. See QTBUG-80729");
+-
+     QWebChannel channel;
+     channel.connectTo(m_dummyTransport);
+ 
+@@ -990,6 +988,50 @@ void TestWebChannel::testAsyncObject()
+     thread.wait();
+ }
+ 
++void TestWebChannel::testPropertyMultipleTransports()
++{
++    DummyTransport transport1;
++    DummyTransport transport2;
++
++    QWebChannel channel;
++    QMetaObjectPublisher *publisher = channel.d_func()->publisher;
++
++    TestObject testObj;
++    testObj.setObjectName("testObject");
++    channel.registerObject(testObj.objectName(), &testObj);
++    channel.connectTo(&transport1);
++    channel.connectTo(&transport2);
++
++    testObj.setProp("Hello");
++
++    publisher->initializeClient(&transport1);
++    publisher->initializeClient(&transport2);
++    publisher->setClientIsIdle(true, &transport1);
++    QCOMPARE(publisher->isClientIdle(&transport1), true);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++    QVERIFY(transport1.messagesSent().isEmpty());
++    QVERIFY(transport2.messagesSent().isEmpty());
++
++    testObj.setProp("World");
++    QTRY_COMPARE_WITH_TIMEOUT(transport1.messagesSent().size(), 1u, 2000);
++    QCOMPARE(transport2.messagesSent().size(), 0u);
++    publisher->setClientIsIdle(true, &transport2);
++    QTRY_COMPARE_WITH_TIMEOUT(transport2.messagesSent().size(), 1u, 2000);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++
++    testObj.setProp("!!!");
++    publisher->setClientIsIdle(true, &transport2);
++    QCOMPARE(publisher->isClientIdle(&transport2), true);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QTRY_COMPARE_WITH_TIMEOUT(transport2.messagesSent().size(), 2u, 2000);
++    QCOMPARE(transport1.messagesSent().size(), 1u);
++    publisher->setClientIsIdle(true, &transport1);
++    QTRY_COMPARE_WITH_TIMEOUT(transport1.messagesSent().size(), 2u, 2000);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++}
++
+ class FunctionWrapper : public QObject
+ {
+     Q_OBJECT
+@@ -1082,7 +1124,7 @@ void TestWebChannel::benchInitializeClients()
+ 
+         publisher->propertyUpdatesInitialized = false;
+         publisher->signalToPropertyMap.clear();
+-        publisher->signalHandler.clear();
++        publisher->signalHandlers.clear();
+     }
+ }
+ 
+@@ -1107,7 +1149,7 @@ void TestWebChannel::benchPropertyUpdates()
+             obj->change();
+         }
+ 
+-        channel.d_func()->publisher->clientIsIdle = true;
++        channel.d_func()->publisher->setClientIsIdle(true, m_dummyTransport);
+         channel.d_func()->publisher->sendPendingPropertyUpdates();
+     }
+ }
+diff --git a/qtwebchannel/tests/auto/webchannel/tst_webchannel.h b/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
+index eae21f4..dd4e690 100644
+--- a/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
++++ b/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
+@@ -348,6 +348,7 @@ private slots:
+     void testJsonToVariant();
+     void testInfiniteRecursion();
+     void testAsyncObject();
++    void testPropertyMultipleTransports();
+     void testDeletionDuringMethodInvocation_data();
+     void testDeletionDuringMethodInvocation();
+ 
+Submodule qtwebengine f328054d...38e0df6c (commits not present)
+Submodule qtwebsockets 65850954..63fb8da1:
+diff --git a/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp b/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
+index 2affdd5..95f1194 100644
+--- a/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
++++ b/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
+@@ -273,6 +273,7 @@ void QWebSocketDataProcessor::clear()
+     if (!m_pConverterState)
+         m_pConverterState = new QTextCodec::ConverterState(QTextCodec::ConvertInvalidToNull |
+                                                            QTextCodec::IgnoreHeader);
++    frame.clear();
+ }
+ 
+ /*!
+diff --git a/qtwebsockets/src/websockets/qwebsocketprotocol.cpp b/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
+index df87a93..d0465f1 100644
+--- a/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
++++ b/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
+@@ -210,7 +210,7 @@ void QWebSocketProtocol::mask(char *payload, quint64 size, quint32 maskingKey)
+                             quint8((maskingKey & 0x0000FF00u) >> 8),
+                             quint8((maskingKey & 0x000000FFu))
+                           };
+-    int i = 0;
++    quint64 i = 0;
+     while (size-- > 0)
+         *payload++ ^= mask[i++ % 4];
+ }
diff --git a/srcpkgs/qt5/template b/srcpkgs/qt5/template
index b6612dffeb1b9..a0d3036af79a4 100644
--- a/srcpkgs/qt5/template
+++ b/srcpkgs/qt5/template
@@ -2,11 +2,11 @@
 #
 # revbump libqtxdg after bumping patch version
 pkgname=qt5
-version=5.15.7+20221119
+version=5.15.8
+revision=1
+build_style=meta
 # commit f8c9fb304bc3e53b3aa07f962cd74e9160decccc
 # base repo: https://invent.kde.org/qt/qt/qt5
-revision=7
-build_style=meta
 hostmakedepends="cmake clang flex perl glib-devel pkg-config
  python3 re2c ruby which"
 makedepends="SDL2-devel Vulkan-Headers alsa-lib-devel double-conversion-devel
@@ -29,9 +29,9 @@ homepage="https://qt.io/"
 # tarball is generated with `git archive-all qt5-$version.tar.gz`
 # to keep the size smaller qtwebengine, qtwebview, qtdocgallery, qtactiveqt and qtpim
 # can be marked with the export-ignore attribute
-distfiles="https://void.johnnynator.dev/distfiles/qt5-${version}.tar.gz"
-checksum=9d57af471c78029a362276b7c99108ea009f511bb9ba6ff6cb884f6ddd255e9f
-python_version=3
+distfiles="https://download.qt.io/archive/qt/5.15/${version}/single/qt-everywhere-opensource-src-${version}.tar.xz"
+checksum=776a9302c336671f9406a53bd30b8e36f825742b2ec44a57c08217bff0fa86b9
+python_version=2 #unverified
 replaces="qt5-doc<5.6.0 qt5-quick1<5.6.0 qt5-quick1-devel<5.6.0 qt5-webkit<5.6.0 qt5-webkit-devel<5.6.0
  qt5-enginio<5.7.1 qt5-enginio-devel<5.7.1 qt5-plugin-gtk<5.7.1 qt5-canvas3d<5.13.0"
 lib32mode=full
@@ -246,7 +246,6 @@ do_configure() {
 	# opts+=" -v"
 	opts+=" -skip qtwebengine"
 	opts+=" -skip qtwebview"
-	opts+=" -skip qtdocgallery"
 	opts+=" -skip qtpim"
 	opts+=" -skip qtsystems"
 	opts+=" -skip qtspeech"

From 813523f4f427234e928ab159536b54ae26162896 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 068/115] qtav: revbump for ffmpeg4-4.4.3

---
 srcpkgs/qtav/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtav/template b/srcpkgs/qtav/template
index 34c30b2c0c78f..2d00ad104355e 100644
--- a/srcpkgs/qtav/template
+++ b/srcpkgs/qtav/template
@@ -1,10 +1,10 @@
 # Template file for 'qtav'
 pkgname=qtav
 version=1.13.0
-revision=1
+revision=2
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel libass-devel libopenal-devel
+makedepends="ffmpeg4-devel libass-devel libopenal-devel
  libva-glx-devel libXv-devel pulseaudio-devel
  qt5-declarative-devel qt5-svg-devel
  qt5-quickcontrols"

From 8d38789a81f513ed1c6f5a897e981dc7f9f7fa8b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 069/115] qtox: revbump for ffmpeg-6.0

---
 srcpkgs/qtox/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qtox/template b/srcpkgs/qtox/template
index 39c643fecdb5a..bb70e7f51240a 100644
--- a/srcpkgs/qtox/template
+++ b/srcpkgs/qtox/template
@@ -1,7 +1,7 @@
 # Template file for 'qtox'
 pkgname=qtox
 version=1.17.6
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DUPDATE_CHECK=OFF
  -DGIT_DESCRIBE=${version}

From 596c2c68b9a30ee1babe181580819d76b053cf8e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 070/115] retroarch: revbump for ffmpeg-6.0

---
 srcpkgs/retroarch/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroarch/template b/srcpkgs/retroarch/template
index 45b02597de41a..507805ea8d819 100644
--- a/srcpkgs/retroarch/template
+++ b/srcpkgs/retroarch/template
@@ -1,7 +1,7 @@
 # Template file for 'retroarch'
 pkgname=retroarch
 version=1.15.0
-revision=4
+revision=5
 build_style=configure
 configure_args="--prefix=/usr --sysconfdir=/etc --enable-networking
  --enable-udev --disable-builtinflac --disable-builtinglslang

From 48221032201993aef9694cac3df2bd2105c6ad2d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 071/115] scrcpy: revbump for ffmpeg-6.0

---
 srcpkgs/scrcpy/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/scrcpy/template b/srcpkgs/scrcpy/template
index ac18bc03418ce..f39a7f678ab35 100644
--- a/srcpkgs/scrcpy/template
+++ b/srcpkgs/scrcpy/template
@@ -1,7 +1,7 @@
 # Template file for 'scrcpy'
 pkgname=scrcpy
 version=2.1.1
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcompile_server=false
  -Dprebuilt_server=/usr/share/scrcpy/scrcpy-server-v${version}"

From 2235619ddbd0af3583473d44cca689b1b4886568 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 072/115] spek-alternative: revbump for ffmpeg4-4.4.3

---
 srcpkgs/spek-alternative/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/spek-alternative/template b/srcpkgs/spek-alternative/template
index d7b55c776b1d4..0c9424abc3a9b 100644
--- a/srcpkgs/spek-alternative/template
+++ b/srcpkgs/spek-alternative/template
@@ -1,12 +1,12 @@
 # Template file for 'spek-alternative'
 pkgname=spek-alternative
 version=0.8.2.3
-revision=2
+revision=3
 build_style=gnu-configure
 hostmakedepends="automake gettext-devel intltool libtool pkg-config
  wxWidgets-common wxWidgets-gtk3-devel"
-makedepends="ffmpeg-devel wxWidgets-gtk3-devel"
-depends="ffmpeg"
+makedepends="ffmpeg4-devel wxWidgets-gtk3-devel"
+depends="ffmpeg4"
 short_desc="Acoustic spectrum analyser"
 maintainer="Kartik Singh <kartik.ynwa@gmail.com>"
 license="GPL-3.0-or-later"

From 8b7135974666d15ca26b316b60791c6a9a20f96f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 073/115] ssr: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ssr/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/ssr/template b/srcpkgs/ssr/template
index b055b9ec0774a..3448ca110eb0c 100644
--- a/srcpkgs/ssr/template
+++ b/srcpkgs/ssr/template
@@ -1,11 +1,11 @@
 # Template file for 'ssr'
 pkgname=ssr
 version=0.4.4
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_QT5=ON"
 hostmakedepends="pkg-config"
-makedepends="alsa-lib-devel ffmpeg-devel glu-devel jack-devel pulseaudio-devel
+makedepends="alsa-lib-devel ffmpeg4-devel glu-devel jack-devel pulseaudio-devel
  qt5-tools-devel qt5-x11extras-devel libXinerama-devel v4l-utils-devel"
 depends="desktop-file-utils hicolor-icon-theme"
 short_desc="Simple Screen Recorder for programs and games"

From 8d9a1636ba1cd5073a6e7826ee3002479a82fb21 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 074/115] synfig: revbump for ffmpeg-6.0 and mlt7

---
 srcpkgs/synfig/patches/ffmpeg6.patch | 71 ++++++++++++++++++++++++++++
 srcpkgs/synfig/template              |  6 +--
 2 files changed, 74 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/synfig/patches/ffmpeg6.patch

diff --git a/srcpkgs/synfig/patches/ffmpeg6.patch b/srcpkgs/synfig/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..10780b42782f4
--- /dev/null
+++ b/srcpkgs/synfig/patches/ffmpeg6.patch
@@ -0,0 +1,71 @@
+--- a/src/modules/mod_libavcodec/trgt_av.cpp	2022-10-25 09:14:12.000000000 -0400
++++ b/src/modules/mod_libavcodec/trgt_av.cpp	2023-05-05 21:34:17.899194559 -0400
+@@ -38,6 +41,7 @@
+ extern "C"
+ {
+ #ifdef HAVE_LIBAVFORMAT_AVFORMAT_H
++#	include <libavcodec/avcodec.h>
+ #	include <libavformat/avformat.h>
+ #elif defined(HAVE_AVFORMAT_H)
+ #	include <avformat.h>
+@@ -155,11 +156,11 @@
+     }
+ 
+ 	bool open_video_stream() {
+-		if (avcodec_open2(video_context, NULL, NULL) < 0) {
++		if (avcodec_open2(video_context, nullptr, nullptr) < 0) {
+ 			synfig::error("Target_LibAVCodec: could not open video codec");
+ 			// seems the calling of avcodec_free_context after error will cause crash
+ 			// so just forget about this context
+-			video_context = NULL;
++			video_context = nullptr;
+ 			close();
+ 			return false;
+         }
+@@ -234,15 +235,21 @@
+ 		close();
+ 
+ 		if (!av_registered) {
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 			av_register_all();
++#endif
+ 			av_registered = true;
+ 		}
+ 
+ 		// guess format
+-		AVOutputFormat *format = av_guess_format(NULL, filename.c_str(), NULL);
++#if LIBAVCODEC_VERSION_MAJOR < 59 // FFMPEG < 5.0
++		AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#else
++		const AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#endif
+ 		if (!format) {
+ 			synfig::warning("Target_LibAVCodec: unable to guess the output format, defaulting to MPEG");
+-			format = av_guess_format("mpeg", NULL, NULL);
++			format = av_guess_format("mpeg", nullptr, nullptr);
+ 		}
+ 		if (!format) {
+ 			synfig::error("Target_LibAVCodec: unable to find 'mpeg' output format");
+@@ -254,6 +261,7 @@
+ 		context = avformat_alloc_context();
+ 		assert(context);
+ 		context->oformat = format;
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 		if (filename.size() + 1 > sizeof(context->filename)) {
+ 			synfig::error(
+ 				"Target_LibAVCodec: filename too long, max length is %d, filename is '%s'",
+@@ -263,6 +271,14 @@
+ 			return false;
+ 		}
+ 		memcpy(context->filename, filename.c_str(), filename.size() + 1);
++#else
++		context->url = av_strndup(filename.c_str(), filename.size());
++		if (!context->url) {
++			synfig::error("Target_LibAVCodec: cannot allocate space for filename");
++			close();
++			return false;
++		}
++#endif
+ 
+ 		packet = av_packet_alloc();
+ 		assert(packet);
diff --git a/srcpkgs/synfig/template b/srcpkgs/synfig/template
index 30109541ec4fc..703cfd7ebac84 100644
--- a/srcpkgs/synfig/template
+++ b/srcpkgs/synfig/template
@@ -2,11 +2,11 @@
 # Should be kept in sync with 'synfigstudio' and 'ETL'
 pkgname=synfig
 version=1.4.4
-revision=3
+revision=4
 build_style=gnu-configure
 configure_args="--with-boost-libdir=${XBPS_CROSS_BASE}/usr/lib"
 hostmakedepends="boost-build ImageMagick pkg-config intltool"
-makedepends="ETL gettext-devel libxml++-devel mlt-devel libmagick-devel
+makedepends="ETL gettext-devel libxml++-devel mlt7-devel libmagick-devel
  libmng-devel boost-build boost-devel libopenexr-devel ffmpeg-devel"
 depends="ImageMagick"
 short_desc="CLI 2D vector and timeline-based animation software"
@@ -20,7 +20,7 @@ CXXFLAGS="-std=c++11 -DHAVE_LOCALE_H=1"
 
 synfig-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision}
-	 libopenexr-devel libxml++-devel mlt-devel"
+	 libopenexr-devel libxml++-devel mlt7-devel"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/bin/synfig-config

From 97a4e5f2e9c8be3ccfd84fe1dfaf8f24e10bdc9e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 075/115] timg: revbump for ffmpeg-6.0

---
 srcpkgs/timg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/timg/template b/srcpkgs/timg/template
index 2a2ab763d2fdd..8fb4327535ef9 100644
--- a/srcpkgs/timg/template
+++ b/srcpkgs/timg/template
@@ -1,7 +1,7 @@
 # Template file for 'timg'
 pkgname=timg
 version=1.4.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_OPENSLIDE_SUPPORT=off -Wno-dev"
 hostmakedepends="pkg-config git"

From 9f5034ecc5001f2b8f77dcd7c18db93df22d1579 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 076/115] tvheadend: revbump for ffmpeg4-4.4.3

---
 srcpkgs/tvheadend/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tvheadend/template b/srcpkgs/tvheadend/template
index 9aea7de4ec705..012d31c4879ff 100644
--- a/srcpkgs/tvheadend/template
+++ b/srcpkgs/tvheadend/template
@@ -8,7 +8,7 @@ configure_args="--enable-dvbscan --disable-ffmpeg_static
 --disable-libx265_static --disable-libvpx_static --disable-libtheora_static
 --disable-libvorbis_static --disable-libfdkaac_static"
 hostmakedepends="gettext pkg-config python3 git which"
-makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg-devel"
+makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg4-devel"
 short_desc="TV streaming server"
 maintainer="lemmi <lemmi@nerd2nerd.org>"
 license="GPL-3.0-only"

From 686d3da3ee41ff4e839069caea2715f2f1205da0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 077/115] unpaper: update to 7.0.0.

---
 srcpkgs/unpaper/template | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/srcpkgs/unpaper/template b/srcpkgs/unpaper/template
index 38ed47a584016..1ff910e722afc 100644
--- a/srcpkgs/unpaper/template
+++ b/srcpkgs/unpaper/template
@@ -1,13 +1,13 @@
 # Template file for 'unpaper'
 pkgname=unpaper
-version=6.1
-revision=3
-build_style=gnu-configure
+version=7.0.0
+revision=1
+build_style=meson
+hostmakedepends="pkg-config meson libxslt"
+makedepends="ffmpeg-devel python3-Sphinx"
+short_desc="Post-processing tool for scanned sheets of paper"
 maintainer="Orphaned <orphan@voidlinux.org>"
-hostmakedepends="pkg-config libxslt"
-makedepends="ffmpeg-devel"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://www.flameeyes.eu/projects/unpaper"
-short_desc="A post-processing tool for scanned sheets of paper"
 distfiles="https://www.flameeyes.eu/files/${pkgname}-${version}.tar.xz"
-checksum=237c84f5da544b3f7709827f9f12c37c346cdf029b1128fb4633f9bafa5cb930
+checksum=2575fbbf26c22719d1cb882b59602c9900c7f747118ac130883f63419be46a80

From cfac1a8dd5c428a01955ab83fb17ef5f618c3335 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 078/115] vba-m: revbump for ffmpeg-6.0

---
 srcpkgs/vba-m/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vba-m/template b/srcpkgs/vba-m/template
index 9c71cefe3f8dd..2223d297c31f5 100644
--- a/srcpkgs/vba-m/template
+++ b/srcpkgs/vba-m/template
@@ -2,7 +2,7 @@
 pkgname=vba-m
 reverts=1292_2
 version=2.1.7
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DENABLE_GTK=TRUE -DENABLE_FFMPEG=TRUE -DENABLE_LINK=TRUE -DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="gettext pkg-config unzip zip yasm wxWidgets-gtk3-devel"

From e895c11f17b7930f558d306ce2dd5b41b3082db0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 079/115] vice: revbump for ffmpeg4-4.4.3

---
 srcpkgs/vice/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/vice/template b/srcpkgs/vice/template
index fe9d33a811947..4beab2c5f9ebd 100644
--- a/srcpkgs/vice/template
+++ b/srcpkgs/vice/template
@@ -1,7 +1,7 @@
 # Template file for 'vice'
 pkgname=vice
 version=3.7.1
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="
 	$(vopt_enable sdl2 sdlui2)
@@ -26,7 +26,7 @@ makedepends="
 	$(vopt_if gtk3 gtk+3-devel)
 	$(vopt_if gtk3 pulseaudio-devel)
 	$(vopt_if gtk3 pango-devel)
-	$(vopt_if ffmpeg ffmpeg-devel)"
+	$(vopt_if ffmpeg ffmpeg4-devel)"
 short_desc="Emulator for C64, C128, CBM-II, PET, VIC20, Plus4 and C16"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"

From d8aa36f2c8923a6458af7e2c8bdc34da55c9a7bc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 080/115] waypipe: revbump for ffmpeg-6.0

---
 srcpkgs/waypipe/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waypipe/template b/srcpkgs/waypipe/template
index 6da88b21bf2a1..4da8058400b58 100644
--- a/srcpkgs/waypipe/template
+++ b/srcpkgs/waypipe/template
@@ -1,7 +1,7 @@
 # Template file for 'waypipe'
 pkgname=waypipe
 version=0.8.6
-revision=1
+revision=2
 build_style=meson
 # lto is off because it causes linking errors in armv6l and armv7l (due to NEON)
 configure_args="-Dwerror=false -Dwith_dmabuf=enabled -Dwith_lz4=enabled

From 526db9771b6be2c661b4dd6137638a16d257ee53 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 081/115] wf-recorder: revbump for ffmpeg-6.0

---
 srcpkgs/wf-recorder/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/wf-recorder/template b/srcpkgs/wf-recorder/template
index cdf8d26dcb8e1..08f986b031006 100644
--- a/srcpkgs/wf-recorder/template
+++ b/srcpkgs/wf-recorder/template
@@ -1,7 +1,7 @@
 # Template file for 'wf-recorder'
 pkgname=wf-recorder
 version=0.4.1
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config scdoc wayland-devel"
 makedepends="wayland-protocols wayland-devel ffmpeg-devel libgbm-devel x264-devel

From a2e5f54e3d68382f23bc87086cfbf2ef962a3ba6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 082/115] xpra: revbump for ffmpeg-6.0

---
 srcpkgs/xpra/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xpra/template b/srcpkgs/xpra/template
index aec0bd57392b1..e97ea631b7f33 100644
--- a/srcpkgs/xpra/template
+++ b/srcpkgs/xpra/template
@@ -1,7 +1,7 @@
 # Template file for 'xpra'
 pkgname=xpra
 version=5.0.2
-revision=3
+revision=4
 build_style=python3-module
 make_build_args="--without-cuda_kernels --without-cuda_rebuild"
 make_install_args="$(vopt_with docs) ${make_build_args}"

From 89aa6f61ec65529015004fc1bdfb2f4a563a039c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:07:40 -0400
Subject: [PATCH 083/115] nv-codec-headers: update to 12.0.16.0

---
 srcpkgs/nv-codec-headers/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/nv-codec-headers/template b/srcpkgs/nv-codec-headers/template
index 3d422a61e4891..251e057f826fb 100644
--- a/srcpkgs/nv-codec-headers/template
+++ b/srcpkgs/nv-codec-headers/template
@@ -1,6 +1,6 @@
 # Template file for 'nv-codec-headers'
 pkgname=nv-codec-headers
-version=11.1.5.1
+version=12.0.16.0
 revision=1
 build_style=gnu-makefile
 short_desc="FFmpeg version of headers required to interface with Nvidias codec APIs"
@@ -8,7 +8,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="MIT"
 homepage="http://git.videolan.org/?p=ffmpeg/nv-codec-headers.git"
 distfiles="https://github.com/FFmpeg/nv-codec-headers/archive/n${version}.tar.gz"
-checksum=d095fbd56aa93772471a323be0ebe65504a0f43f06c76a30b6d25da77b06ae9c
+checksum=2a1533b65f55f9da52956faf0627ed3b74868ac0c7f269990edd21369113b48f
 
 post_install() {
 	sed -n '4,25p' include/ffnvcodec/nvEncodeAPI.h > LICENSE

From 74026328258beae9662805b9b253644c9ebc8c73 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:08:40 -0400
Subject: [PATCH 084/115] openimagedenoise: revbump for ffmpeg-6.0

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index b792813dba7c2..109deb171c3f7 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,7 +1,7 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
 version=1.4.3
-revision=1
+revision=2
 archs="x86_64*"
 build_style=cmake
 hostmakedepends="ispc python3"

From d32be8d8a879f5bdfaa82886dbc15888c97d11dc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:31:45 -0400
Subject: [PATCH 085/115] shotcut: revbump for ffmpeg-6.0

---
 srcpkgs/shotcut/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/shotcut/template b/srcpkgs/shotcut/template
index 7d2af7b0470b5..c416c906ff734 100644
--- a/srcpkgs/shotcut/template
+++ b/srcpkgs/shotcut/template
@@ -1,7 +1,7 @@
 # Template file for 'shotcut'
 pkgname=shotcut
 version=23.05.14
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSHOTCUT_VERSION=${version}"
 hostmakedepends="pkg-config qt6-tools-devel"

From 7e60c346847a0c3ac84d5e1888c15076267e56d4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:30 -0400
Subject: [PATCH 086/115] shiboken2: revbump for qt5-5.15.8

---
 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch | 1 +
 srcpkgs/shiboken2/template                                 | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
 create mode 120000 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
new file mode 120000
index 0000000000000..efcf3249bd885
--- /dev/null
+++ b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1 @@
+../../python3-pyside2/patches/importlib-machinery-bypass.patch
\ No newline at end of file
diff --git a/srcpkgs/shiboken2/template b/srcpkgs/shiboken2/template
index 883d6a084d868..f3c06ec245a1f 100644
--- a/srcpkgs/shiboken2/template
+++ b/srcpkgs/shiboken2/template
@@ -1,7 +1,7 @@
 # Template file for 'shiboken2'
 pkgname=shiboken2
 version=5.15.10
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/shiboken2"
 build_style=cmake

From 383a1a2c72059ee217f830cc519c8fa24a592fa9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:53 -0400
Subject: [PATCH 087/115] python3-pyside2: revbump for qt5-5.15.8

---
 .../patches/importlib-machinery-bypass.patch      | 15 +++++++++++++++
 srcpkgs/python3-pyside2/template                  |  2 +-
 2 files changed, 16 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
new file mode 100644
index 0000000000000..64c429584776b
--- /dev/null
+++ b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1,15 @@
+Using this prevents an error around line 220 below it.
+"AttributeError: module 'importlib' has no attribute 'machinery'"
+The old backup logic is in place and compiles without issues.
+--- a/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:09:34.688912402 -0400
++++ b/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:10:03.395529582 -0400
+@@ -170,9 +170,6 @@
+
+     # 'zipstring_sequence' comes from signature.cpp
+     zipbytes = base64.b64decode(''.join(zipstring_sequence))
+-    if sys.version_info[0] >= 3:
+-        vzip = zipfile.ZipFile(io.BytesIO(zipbytes))
+-        return sys.meta_path, EmbeddableZipImporter(vzip)
+
+     # Old version for Python 2.7, only.
+     import os
diff --git a/srcpkgs/python3-pyside2/template b/srcpkgs/python3-pyside2/template
index 249efa9098842..52626436ce75f 100644
--- a/srcpkgs/python3-pyside2/template
+++ b/srcpkgs/python3-pyside2/template
@@ -1,7 +1,7 @@
 # Template file for 'python3-pyside2'
 pkgname=python3-pyside2
 version=5.15.10
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/pyside2"
 build_style=cmake

From fa92b9c41a22ebc23dd34cbe8a0144c698cdb3c5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:35 -0400
Subject: [PATCH 088/115] konqueror: revbump for ffmpeg-6.0

---
 srcpkgs/konqueror/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/konqueror/template b/srcpkgs/konqueror/template
index abfa59e6b7ded..3cc29c12dc1db 100644
--- a/srcpkgs/konqueror/template
+++ b/srcpkgs/konqueror/template
@@ -1,11 +1,11 @@
 # Template file for 'konqueror'
 pkgname=konqueror
 version=23.08.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DDESKTOPTOJSON_EXECUTABLE=/usr/bin/desktoptojson"
 hostmakedepends="extra-cmake-modules python3 qt5-host-tools qt5-qmake kdoctools
-kcoreaddons kconfig gettext"
+ kcoreaddons kconfig gettext"
 makedepends="qt5-devel qt5-webengine-devel qt5-declarative-devel
  qt5-webchannel-devel qt5-location-devel kcmutils-devel kdelibs4support-devel
  karchive-devel khtml-devel kdesu-devel kactivities5-devel"

From f4810f2f10c840f4dc1cd68025596a1a46b6c004 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:58 -0400
Subject: [PATCH 089/115] qt5-speech: revbump for qt5-5.15.8

---
 srcpkgs/qt5-speech/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-speech/template b/srcpkgs/qt5-speech/template
index 3ecd10d50650c..2d7d4d4d24535 100644
--- a/srcpkgs/qt5-speech/template
+++ b/srcpkgs/qt5-speech/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-speech'
 pkgname=qt5-speech
 version=5.15.7
-revision=2
+revision=3
 _commit=d32f4a479d38a11f547598004b975f4356424a16
 build_style=qmake
 configure_args="-- -flite -flite-alsa -speechd"

From 7aeb0551e1ac08a91232339d633a1af57688cb86 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 18:38:50 -0400
Subject: [PATCH 090/115] qt5-styleplugins: revbump for qt5-5.15.8

---
 srcpkgs/qt5-styleplugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-styleplugins/template b/srcpkgs/qt5-styleplugins/template
index 96ed97d12cd24..30d93660a2a4e 100644
--- a/srcpkgs/qt5-styleplugins/template
+++ b/srcpkgs/qt5-styleplugins/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-styleplugins'
 pkgname=qt5-styleplugins
 version=5.0.0
-revision=20
+revision=21
 _gitrev=335dbece103e2cbf6c7cf819ab6672c2956b17b3
 build_style=qmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From 2b92bc273b0560a7c4dde4d04c6ec05bc8c5b3cb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 7 May 2023 20:15:03 -0400
Subject: [PATCH 091/115] qt6-webengine: revbump for ffmpeg-6.0

---
 srcpkgs/qt6-webengine/template | 1 +
 1 file changed, 1 insertion(+)

diff --git a/srcpkgs/qt6-webengine/template b/srcpkgs/qt6-webengine/template
index a92b06c6f0cca..14a9bfc082935 100644
--- a/srcpkgs/qt6-webengine/template
+++ b/srcpkgs/qt6-webengine/template
@@ -146,6 +146,7 @@ pre_install() {
 }
 
 post_install() {
+	vlicense LICENSES/BSD-3-Clause.txt
 	local _file
 	find "${DESTDIR}"/usr/lib/qt6/examples \
 		-path '*/lib/qt6/**/lib/qt6/*' -type f |

From 0335cb7e2921df86d5d73292cdebf00b00ab4fd9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 21 May 2023 12:44:11 -0400
Subject: [PATCH 092/115] electron24: revbump for ffmpeg-6.0

---
 srcpkgs/electron24/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron24/template b/srcpkgs/electron24/template
index 59e078a7b47cb..a9c865c19c989 100644
--- a/srcpkgs/electron24/template
+++ b/srcpkgs/electron24/template
@@ -1,7 +1,7 @@
 # Template file for 'electron24'
 pkgname=electron24
 version=24.3.0
-revision=1
+revision=2
 _nodever=18.14.0
 _chromiumver=112.0.5615.165
 archs="x86_64* aarch64*"

From f51c54411fbe1ba463d3c37569c1d67b6e6e3338 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Jun 2023 08:20:22 -0400
Subject: [PATCH 093/115] gtk4: revbump for ffmpeg-6.0

---
 srcpkgs/gtk4/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gtk4/template b/srcpkgs/gtk4/template
index 6a4e20357a86f..ec0c13d2cc5b0 100644
--- a/srcpkgs/gtk4/template
+++ b/srcpkgs/gtk4/template
@@ -1,7 +1,7 @@
 # Template file for 'gtk4'
 pkgname=gtk4
 version=4.12.3
-revision=1
+revision=2
 build_style=meson
 build_helper="gir"
 configure_args="-Dman-pages=true -Ddocumentation=true -Dbuild-tests=false

From dc78b69943aa6560619567e535b1358bf3a07534 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:25:50 -0400
Subject: [PATCH 094/115] electron19: revbump for ffmpeg-6.0

---
 srcpkgs/electron19/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron19/template b/srcpkgs/electron19/template
index 4b40de20a3fe2..b18bc792c8221 100644
--- a/srcpkgs/electron19/template
+++ b/srcpkgs/electron19/template
@@ -1,7 +1,7 @@
 # Template file for 'electron19'
 pkgname=electron19
 version=19.0.8
-revision=3
+revision=4
 _nodever=16.14.2
 _chromiumver=102.0.5005.125
 archs="x86_64* aarch64* ppc64le*"

From d0db1ae0b3dba6773bc92667d2a8f29608fadc3a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:28:26 -0400
Subject: [PATCH 095/115] siril: revbump for ffmpeg-6.0

---
 srcpkgs/siril/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/siril/template b/srcpkgs/siril/template
index 84332f79d060d..62750dd247548 100644
--- a/srcpkgs/siril/template
+++ b/srcpkgs/siril/template
@@ -1,7 +1,7 @@
 # Template file for 'siril'
 pkgname=siril
 version=0.9.12
-revision=10
+revision=11
 build_style=gnu-configure
 hostmakedepends="pkg-config intltool autoconf automake gettext-devel"
 makedepends="fftw-devel libconfig-devel libopencv-devel libffms2-devel

From d4159e162a20d3e278a4268fc6d65806ead6d177 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 10 Jun 2023 00:57:09 -0400
Subject: [PATCH 096/115] qt6-multimedia: revbump for ffmpeg-6.0

---
 srcpkgs/qt6-multimedia/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-multimedia/template b/srcpkgs/qt6-multimedia/template
index 2cf997b227a45..ca39534afb7f3 100644
--- a/srcpkgs/qt6-multimedia/template
+++ b/srcpkgs/qt6-multimedia/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-multimedia'
 pkgname=qt6-multimedia
 version=6.5.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DQT_FEATURE_gstreamer=ON"
 hostmakedepends="perl qt6-declarative-host-tools pkg-config qt6-shadertools"

From 7558eb69d89e9cb99a561928c756c2f901c0e740 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 22 Jun 2023 10:25:02 -0400
Subject: [PATCH 097/115] kdenlive: revbump for ffmpeg-6.0

---
 srcpkgs/kdenlive/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kdenlive/template b/srcpkgs/kdenlive/template
index ec5fe75860948..e69ecff31f272 100644
--- a/srcpkgs/kdenlive/template
+++ b/srcpkgs/kdenlive/template
@@ -1,7 +1,7 @@
 # Template file for 'kdenlive'
 pkgname=kdenlive
 version=23.08.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="
  extra-cmake-modules kconfig kcoreaddons kdoctools pkg-config python3

From 674af843a63fdb74f974cc547aa746357e4c845a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Jul 2023 09:18:23 -0400
Subject: [PATCH 098/115] gmic: revbump for opencv-4.7.0

---
 srcpkgs/gmic/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gmic/template b/srcpkgs/gmic/template
index 0bb4034d5cc86..808953e9b543c 100644
--- a/srcpkgs/gmic/template
+++ b/srcpkgs/gmic/template
@@ -1,7 +1,7 @@
 # Template file for 'gmic'
 pkgname=gmic
 version=3.1.6
-revision=4
+revision=5
 _zart_hash=34ebf6cce0bafb98abe57cec83c4a02cd1abeca0
 create_wrksrc=yes
 build_wrksrc="src"

From 3568fd485266901847924d169580b868a43c72e6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Jul 2023 09:29:52 -0400
Subject: [PATCH 099/115] synfigstudio: revbump for synfig mlt7

---
 srcpkgs/synfigstudio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/synfigstudio/template b/srcpkgs/synfigstudio/template
index af1c5a296ef0f..09e442da9a680 100644
--- a/srcpkgs/synfigstudio/template
+++ b/srcpkgs/synfigstudio/template
@@ -2,7 +2,7 @@
 # Should be kept in sync with 'synfig' and 'ETL'
 pkgname=synfigstudio
 version=1.4.4
-revision=3
+revision=4
 build_style=gnu-configure
 configure_args="--disable-update-mimedb"
 hostmakedepends="pkg-config intltool gettext synfig"

From 7382407ee863d1a2d0c036e4f29b840f9b95fa7b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Jul 2023 11:17:37 -0400
Subject: [PATCH 100/115] DELETE: intel_packages

---
 common/shlibs                                 |   2 +
 srcpkgs/intel-gmmlib/template                 |   6 +-
 ...mmon-Enable-MMC-in-free-kernel-build.patch | 125 ++++++++++++++++++
 srcpkgs/intel-media-driver/template           |   6 +-
 srcpkgs/intel-media-sdk/patches/musl.patch    |  14 ++
 srcpkgs/intel-media-sdk/template              |  37 ++++++
 srcpkgs/intel-media-sdk/update                |   1 +
 srcpkgs/libmfx                                |   1 +
 srcpkgs/libmfx-devel                          |   1 +
 srcpkgs/onevpl-devel                          |   1 +
 srcpkgs/onevpl-intel-gpu-devel                |   1 +
 srcpkgs/onevpl-intel-gpu/template             |  27 ++++
 srcpkgs/onevpl/template                       |  34 +++++
 13 files changed, 250 insertions(+), 6 deletions(-)
 create mode 100644 srcpkgs/intel-media-driver/patches/0001-Media-Common-Enable-MMC-in-free-kernel-build.patch
 create mode 100644 srcpkgs/intel-media-sdk/patches/musl.patch
 create mode 100644 srcpkgs/intel-media-sdk/template
 create mode 100644 srcpkgs/intel-media-sdk/update
 create mode 120000 srcpkgs/libmfx
 create mode 120000 srcpkgs/libmfx-devel
 create mode 120000 srcpkgs/onevpl-devel
 create mode 120000 srcpkgs/onevpl-intel-gpu-devel
 create mode 100644 srcpkgs/onevpl-intel-gpu/template
 create mode 100644 srcpkgs/onevpl/template

diff --git a/common/shlibs b/common/shlibs
index b1ba1497c8295..24c8dc4b2354d 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4253,6 +4253,8 @@ libgsoapssl++-2.8.124.so gsoap-2.8.124_1
 libjxl.so.0.8 libjxl-0.8.2_1
 libjxl_dec.so.0.8 libjxl-0.8.2_1
 libjxl_threads.so.0.8 libjxl-0.8.2_1
+libmfx.so.1 libmfx-22.6.4_1
+libvpl.so.2 onevpl-2023.1.2_1
 libtext-engine-0.1.so.0 text-engine-0.1.1_1
 libvmaf.so.1 vmaf-2.3.1_1
 liblc3.so.1 liblc3-1.0.3_1
diff --git a/srcpkgs/intel-gmmlib/template b/srcpkgs/intel-gmmlib/template
index 04e407b1de4d3..2605226152e5d 100644
--- a/srcpkgs/intel-gmmlib/template
+++ b/srcpkgs/intel-gmmlib/template
@@ -1,6 +1,6 @@
 # Template file for 'intel-gmmlib'
 pkgname=intel-gmmlib
-version=22.2.0
+version=22.3.3
 revision=1
 archs="i686* x86_64*"
 build_style=cmake
@@ -14,11 +14,11 @@ build_style=cmake
 # compilers flag in use.
 configure_args="-Wno-dev"
 short_desc="Intel Graphics Memory Management Library"
-maintainer="Orphaned <orphan@voidlinux.org>"
+maintainer="Stefano Ragni <st3r4g@protonmail.com>"
 license="MIT"
 homepage="https://github.com/intel/gmmlib"
 distfiles="https://github.com/intel/gmmlib/archive/intel-gmmlib-${version}.tar.gz"
-checksum=0b2253894c6fc8455b6d7c5e87e6504a76d6f60ea192e1445c2f93164bf529c0
+checksum=86651bd2803c9f0afd82471bec784e65d2b418dee315a053d22215eb2a679be7
 
 lib32disabled=yes
 
diff --git a/srcpkgs/intel-media-driver/patches/0001-Media-Common-Enable-MMC-in-free-kernel-build.patch b/srcpkgs/intel-media-driver/patches/0001-Media-Common-Enable-MMC-in-free-kernel-build.patch
new file mode 100644
index 0000000000000..525fb688722c8
--- /dev/null
+++ b/srcpkgs/intel-media-driver/patches/0001-Media-Common-Enable-MMC-in-free-kernel-build.patch
@@ -0,0 +1,125 @@
+From e68feab7db036838d9521ba3b9f00717c37c024c Mon Sep 17 00:00:00 2001
+From: JayYang <jay.yang@intel.com>
+Date: Tue, 21 Mar 2023 17:17:55 +0800
+Subject: [PATCH] [Media Common] Enable MMC in free kernel build
+
+Add mmc build definition in free kernel build
+---
+ media_driver/agnostic/gen9/codec/hal/media_srcs.cmake          | 2 +-
+ media_driver/cmake/linux/media_feature_flags_linux.cmake       | 3 +--
+ .../media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp        | 2 +-
+ .../media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp        | 2 +-
+ .../media_interfaces_m9_glk/media_interfaces_g9_glk.cpp        | 2 +-
+ .../media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp        | 2 +-
+ .../media_interfaces_m9_skl/media_interfaces_g9_skl.cpp        | 2 +-
+ 7 files changed, 7 insertions(+), 8 deletions(-)
+
+diff --git a/media_driver/agnostic/gen9/codec/hal/media_srcs.cmake b/media_driver/agnostic/gen9/codec/hal/media_srcs.cmake
+index 8bb36bafe..78902a22d 100644
+--- a/media_driver/agnostic/gen9/codec/hal/media_srcs.cmake
++++ b/media_driver/agnostic/gen9/codec/hal/media_srcs.cmake
+@@ -27,7 +27,7 @@ set(TMP_1_HEADERS_
+     ${CMAKE_CURRENT_LIST_DIR}/codechal_hw_g9_X.h
+ )
+ 
+-if(${MMC_Supported} STREQUAL "yes")
++if(${MMC_Supported} STREQUAL "yes" AND ENABLE_NONFREE_KERNELS AND ENABLE_KERNELS)
+     set(TMP_1_SOURCES_
+         ${TMP_1_SOURCES_}
+         ${CMAKE_CURRENT_LIST_DIR}/codechal_memdecomp_g9.cpp
+diff --git a/media_driver/cmake/linux/media_feature_flags_linux.cmake b/media_driver/cmake/linux/media_feature_flags_linux.cmake
+index de0ca853f..8121ea60c 100644
+--- a/media_driver/cmake/linux/media_feature_flags_linux.cmake
++++ b/media_driver/cmake/linux/media_feature_flags_linux.cmake
+@@ -35,7 +35,6 @@ if(NOT ENABLE_KERNELS OR NOT ENABLE_NONFREE_KERNELS)
+     bs_set_if_undefined(HEVC_Encode_VME_Supported "no")
+     bs_set_if_undefined(MPEG2_Encode_VME_Supported "no")
+     bs_set_if_undefined(CMRT_HEVC_ENC_FEI_Supported "no")
+-    bs_set_if_undefined(MMC_Supported "no")
+     bs_set_if_undefined(VC1_Decode_Supported "no")
+     bs_set_if_undefined(Decode_Processing_Supported "no")
+     bs_set_if_undefined(Kernel_Auto_Denoise_Supported "no")
+@@ -46,7 +45,6 @@ else()
+     bs_set_if_undefined(HEVC_Encode_VME_Supported "${Encode_VME_Supported}")
+     bs_set_if_undefined(MPEG2_Encode_VME_Supported "${Encode_VME_Supported}")
+     bs_set_if_undefined(CMRT_HEVC_ENC_FEI_Supported "yes")
+-    bs_set_if_undefined(MMC_Supported "yes")
+     bs_set_if_undefined(VC1_Decode_Supported "yes")
+     bs_set_if_undefined(Decode_Processing_Supported "yes")
+     bs_set_if_undefined(Kernel_Auto_Denoise_Supported "yes")
+@@ -64,6 +62,7 @@ bs_set_if_undefined(VP9_Decode_Supported "yes")
+ bs_set_if_undefined(VP_SFC_Supported "yes")
+ bs_set_if_undefined(Common_Encode_Supported "yes")
+ bs_set_if_undefined(Media_Scalability_Supported "yes")
++bs_set_if_undefined(MMC_Supported "yes")
+ 
+ # features controlled by global flag Encode_VDEnc_Supported
+ bs_set_if_undefined(AVC_Encode_VDEnc_Supported "${Encode_VDEnc_Supported}")
+diff --git a/media_driver/media_interface/media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp b/media_driver/media_interface/media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp
+index 3f306ee2a..8e4c0f532 100644
+--- a/media_driver/media_interface/media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp
+@@ -135,7 +135,7 @@ MOS_STATUS MhwInterfacesG9Bxt::Initialize(
+ 
+     return MOS_STATUS_SUCCESS;
+ }
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool bxtRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Bxt>((uint32_t)IGFX_BROXTON);
+diff --git a/media_driver/media_interface/media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp b/media_driver/media_interface/media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp
+index b8fa1eec0..84e0fad1d 100644
+--- a/media_driver/media_interface/media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp
+@@ -44,7 +44,7 @@ static bool cflRegisteredMhw =
+     MediaFactory<uint32_t, MhwInterfaces>::
+     Register<MhwInterfacesG9Kbl>((uint32_t)IGFX_COFFEELAKE);
+ 
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool cflRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Kbl>((uint32_t)IGFX_COFFEELAKE);
+diff --git a/media_driver/media_interface/media_interfaces_m9_glk/media_interfaces_g9_glk.cpp b/media_driver/media_interface/media_interfaces_m9_glk/media_interfaces_g9_glk.cpp
+index de81e6091..2638cb3a6 100644
+--- a/media_driver/media_interface/media_interfaces_m9_glk/media_interfaces_g9_glk.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_glk/media_interfaces_g9_glk.cpp
+@@ -65,7 +65,7 @@ static bool glkRegisteredMhw =
+     MediaFactory<uint32_t, MhwInterfaces>::
+     Register<MhwInterfacesG9Kbl>((uint32_t)IGFX_GEMINILAKE);
+ 
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool glkRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Kbl>((uint32_t)IGFX_GEMINILAKE);
+diff --git a/media_driver/media_interface/media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp b/media_driver/media_interface/media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp
+index 99d786185..4e9c6e7f1 100644
+--- a/media_driver/media_interface/media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp
+@@ -131,7 +131,7 @@ MOS_STATUS MhwInterfacesG9Kbl::Initialize(
+ 
+     return MOS_STATUS_SUCCESS;
+ }
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool kblRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Kbl>((uint32_t)IGFX_KABYLAKE);
+diff --git a/media_driver/media_interface/media_interfaces_m9_skl/media_interfaces_g9_skl.cpp b/media_driver/media_interface/media_interfaces_m9_skl/media_interfaces_g9_skl.cpp
+index e2520edf7..4b0012c64 100644
+--- a/media_driver/media_interface/media_interfaces_m9_skl/media_interfaces_g9_skl.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_skl/media_interfaces_g9_skl.cpp
+@@ -139,7 +139,7 @@ MOS_STATUS MhwInterfacesG9Skl::Initialize(
+ 
+     return MOS_STATUS_SUCCESS;
+ }
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool sklRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Skl>((uint32_t)IGFX_SKYLAKE);
+-- 
+2.40.0
+
diff --git a/srcpkgs/intel-media-driver/template b/srcpkgs/intel-media-driver/template
index a5bab06ac9476..1735b90c65ce5 100644
--- a/srcpkgs/intel-media-driver/template
+++ b/srcpkgs/intel-media-driver/template
@@ -1,6 +1,6 @@
 # Template file for 'intel-media-driver'
 pkgname=intel-media-driver
-version=22.5.3
+version=22.6.4
 revision=1
 archs="x86_64*"
 build_style=cmake
@@ -8,11 +8,11 @@ configure_args="-Wno-dev -DENABLE_NONFREE_KERNELS=$(vopt_if nonfree ON OFF)"
 hostmakedepends="pkg-config"
 makedepends="libva-devel libX11-devel intel-gmmlib-devel libpciaccess-devel"
 short_desc="Intel Media Driver for VAAPI (Broadwell+)"
-maintainer="Orphaned <orphan@voidlinux.org>"
+maintainer="Stefano Ragni <st3r4g@protonmail.com>"
 license="MIT, BSD-3-Clause"
 homepage="https://github.com/intel/media-driver"
 distfiles="https://github.com/intel/media-driver/archive/intel-media-${version}.tar.gz"
-checksum=65652b365d48be3c9f0b3c561502952b92ee5fcc587520b88d0d752cf2a6a3b5
+checksum=0c04b9d74b92de41fd409b62913ce4afd799236c0b6bc1983a496990764e5d90
 
 build_options="nonfree"
 desc_option_nonfree="Enable nonfree kernels"
diff --git a/srcpkgs/intel-media-sdk/patches/musl.patch b/srcpkgs/intel-media-sdk/patches/musl.patch
new file mode 100644
index 0000000000000..4ae70924b744f
--- /dev/null
+++ b/srcpkgs/intel-media-sdk/patches/musl.patch
@@ -0,0 +1,14 @@
+--- a/tools/tracer/tracer/tracer_linux.cpp	2022-11-18 03:02:59.000000000 -0500
++++ b/tools/tracer/tracer/tracer_linux.cpp	2022-12-18 01:44:51.341542572 -0500
+@@ -32,6 +32,11 @@
+ #include <dlfcn.h>
+ #include "tracer.h"
+
++#ifndef RTLD_DEEPBIND
++// musl neither defines nor can use RTLD_DEEPBIND
++#define RTLD_DEEPBIND 0
++#endif
++
+ #if defined(__i386__)
+     #define LIBMFXHW "libmfxhw32.so.1"
+ #elif defined(__x86_64__)
diff --git a/srcpkgs/intel-media-sdk/template b/srcpkgs/intel-media-sdk/template
new file mode 100644
index 0000000000000..7aeab51802f8e
--- /dev/null
+++ b/srcpkgs/intel-media-sdk/template
@@ -0,0 +1,37 @@
+# Template file for 'intel-media-sdk'
+pkgname=intel-media-sdk
+version=22.6.4
+revision=1
+archs="x86_64*"
+build_style=cmake
+configure_args="-Wno-dev -DBUILD_SAMPLES=OFF -DBUILD_TESTS=ON"
+hostmakedepends="pkg-config"
+makedepends="libva-devel libdrm-devel intel-gmmlib-devel"
+short_desc="Intel Media SDK"
+maintainer="Stefano Ragni <st3r4g@protonmail.com>"
+license="MIT, BSD-3-Clause"
+homepage="https://github.com/Intel-Media-SDK/MediaSDK"
+distfiles="https://github.com/Intel-Media-SDK/MediaSDK/archive/refs/tags/intel-mediasdk-${version}.tar.gz"
+checksum=197acd056f81e9ff1c27068d50e8c84c2014d94c7ac17cad69d5c2d61e445fd3
+
+post_install() {
+	vlicense LICENSE
+}
+
+libmfx_package() {
+	depends="${makedepends} ${sourcepkg}-${version}_${revision}"
+	short_desc="Intel MediaSDK mfx lib"
+	pkg_install() {
+		vmove usr/lib/mfx
+		vmove "usr/lib/libmfx*.so*"
+	}
+}
+
+libmfx-devel_package() {
+	depends="${makedepends} ${sourcepkg}-${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+	}
+}
diff --git a/srcpkgs/intel-media-sdk/update b/srcpkgs/intel-media-sdk/update
new file mode 100644
index 0000000000000..434a2bc67f7a1
--- /dev/null
+++ b/srcpkgs/intel-media-sdk/update
@@ -0,0 +1 @@
+pkgname=intel-media
diff --git a/srcpkgs/libmfx b/srcpkgs/libmfx
new file mode 120000
index 0000000000000..8ffc7099c2272
--- /dev/null
+++ b/srcpkgs/libmfx
@@ -0,0 +1 @@
+intel-media-sdk
\ No newline at end of file
diff --git a/srcpkgs/libmfx-devel b/srcpkgs/libmfx-devel
new file mode 120000
index 0000000000000..8ffc7099c2272
--- /dev/null
+++ b/srcpkgs/libmfx-devel
@@ -0,0 +1 @@
+intel-media-sdk
\ No newline at end of file
diff --git a/srcpkgs/onevpl-devel b/srcpkgs/onevpl-devel
new file mode 120000
index 0000000000000..e2306500b4871
--- /dev/null
+++ b/srcpkgs/onevpl-devel
@@ -0,0 +1 @@
+onevpl
\ No newline at end of file
diff --git a/srcpkgs/onevpl-intel-gpu-devel b/srcpkgs/onevpl-intel-gpu-devel
new file mode 120000
index 0000000000000..47920ceecf919
--- /dev/null
+++ b/srcpkgs/onevpl-intel-gpu-devel
@@ -0,0 +1 @@
+onevpl-intel-gpu
\ No newline at end of file
diff --git a/srcpkgs/onevpl-intel-gpu/template b/srcpkgs/onevpl-intel-gpu/template
new file mode 100644
index 0000000000000..f14acb728a54d
--- /dev/null
+++ b/srcpkgs/onevpl-intel-gpu/template
@@ -0,0 +1,27 @@
+# Template file for 'onevpl-intel-gpu'
+pkgname=onevpl-intel-gpu
+version=22.6.4
+revision=1
+archs="x86_64*"
+build_style=cmake
+configure_args="-Wno-dev -DCMAKE_BUILD_TYPE=Release"
+hostmakedepends="cmake pkg-config"
+makedepends="libdrm-devel libva-devel onevpl-devel"
+short_desc="Runtime implementation of oneVPL API for Intel Gen GPUs"
+maintainer="zlice <zlice555@gmail.com>"
+license="MIT"
+homepage="https://github.com/oneapi-src/oneVPL-intel-gpu"
+changelog="https://github.com/oneapi-src/oneVPL-intel-gpu/blob/main/CHANGELOG.md"
+distfiles="https://github.com/oneapi-src/oneVPL-intel-gpu/archive/refs/tags/intel-onevpl-${version}.tar.gz"
+checksum=74b0979dcb2af1b7c68edb8cbcb02d539de511090b12fac50652cbacd707c4e6
+
+post_install() {
+	vlicense LICENSE
+}
+
+onevpl-intel-gpu-devel_package() {
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/lib/pkgconfig
+	}
+}
diff --git a/srcpkgs/onevpl/template b/srcpkgs/onevpl/template
new file mode 100644
index 0000000000000..85c7c2da85ce9
--- /dev/null
+++ b/srcpkgs/onevpl/template
@@ -0,0 +1,34 @@
+# Template file for 'onevpl'
+pkgname=onevpl
+version=2023.1.2
+revision=1
+archs="x86_64*"
+build_style=cmake
+configure_args="
+	-DCMAKE_BUILD_TYPE=Release -Wno-dev
+	-DBUILD_PYTHON_BINDING:BOOL='OFF'
+	-DBUILD_EXAMPLES:BOOL='OFF'
+	-DBUILD_TESTS:BOOL='ON'
+	-DINSTALL_EXAMPLE_CODE:BOOL='OFF'"
+hostmakedepends="cmake libX11 python wayland-protocols pkg-config"
+makedepends="libva-devel libX11-devel wayland-devel"
+short_desc="Intel oneAPI Video Processing library"
+maintainer="zlice <zlice555@gmail.com>"
+license="MIT"
+homepage="https://www.intel.com/content/www/us/en/developer/tools/oneapi/onevpl.html"
+distfiles="https://github.com/oneapi-src/oneVPL/archive/v${version}/${pkgname}-${version}.tar.gz"
+checksum=b2261cca174ce1815f3d47c647921ab17f68267c69c1e2444ff27aab7d199cbb
+
+post_install() {
+	vlicense LICENSE
+}
+
+onevpl-devel_package() {
+	depends="${makedepends} ${sourcepkg}-${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.so"
+	}
+}

From 5192cc241fb7e1f2eb333142fab6986279e332f1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:20:59 -0400
Subject: [PATCH 101/115] tracker-miners: revbump for ffmpeg-6.0

---
 srcpkgs/tracker-miners/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tracker-miners/template b/srcpkgs/tracker-miners/template
index 0b97f47489f81..f196d2bf9e4a4 100644
--- a/srcpkgs/tracker-miners/template
+++ b/srcpkgs/tracker-miners/template
@@ -1,7 +1,7 @@
 # Template file for 'tracker-miners'
 pkgname=tracker-miners
 version=3.6.1
-revision=1
+revision=2
 build_style=meson
 build_helper=qemu
 # missing libgrss for miner_rss

From 044dab0aba45959bf8dd7255fe6aa461c0658c5d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:21:21 -0400
Subject: [PATCH 102/115] mpd: revbump for ffmpeg-6.0

---
 srcpkgs/mpd/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpd/template b/srcpkgs/mpd/template
index abbeb423a1002..1bca2e877a380 100644
--- a/srcpkgs/mpd/template
+++ b/srcpkgs/mpd/template
@@ -1,7 +1,7 @@
 # Template file for 'mpd'
 pkgname=mpd
 version=0.23.14
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dopus=enabled -Dmikmod=enabled -Dneighbor=true
  -Dsoundcloud=enabled -Dpipe=true -Dtwolame=enabled -Dbzip2=enabled

From 1e0a2ae35121a031df4f8a827a481f7563eee7ab Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 17 Jul 2023 15:37:44 -0400
Subject: [PATCH 103/115] mixxx: revbump for ffmpeg-6.0

---
 srcpkgs/mixxx/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mixxx/template b/srcpkgs/mixxx/template
index 23800676bfd09..6921996e4e77b 100644
--- a/srcpkgs/mixxx/template
+++ b/srcpkgs/mixxx/template
@@ -1,7 +1,7 @@
 # Template file for 'mixxx'
 pkgname=mixxx
 version=2.3.3
-revision=5
+revision=6
 build_style=cmake
 configure_args="-DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="extra-cmake-modules pkg-config protobuf qt5-host-tools qt5-qmake"

From f04dd62c14d533e0d04c4dd675d893b63ba3f6a5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:09:36 -0400
Subject: [PATCH 104/115] musikcube: revbump for ffmpeg-6.0

---
 srcpkgs/musikcube/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/musikcube/template b/srcpkgs/musikcube/template
index 1f78ada1451b6..d9e6186e6697b 100644
--- a/srcpkgs/musikcube/template
+++ b/srcpkgs/musikcube/template
@@ -1,7 +1,7 @@
 # Template file for 'musikcube'
 pkgname=musikcube
 version=3.0.0
-revision=2
+revision=3
 build_style=cmake
 make_cmd=make
 configure_args="-DNO_NCURSESW=1"

From 923ab708d3300253f3bc8a3938b392c8b6c0f55f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:02 -0400
Subject: [PATCH 105/115] tg_owt: revbump for ffmpeg-6.0

---
 srcpkgs/tg_owt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tg_owt/template b/srcpkgs/tg_owt/template
index 50bc8310b8859..c93262d5c5de6 100644
--- a/srcpkgs/tg_owt/template
+++ b/srcpkgs/tg_owt/template
@@ -1,7 +1,7 @@
 # Template file for 'tg_owt'
 pkgname=tg_owt
 version=0.0.0.20230921
-revision=1
+revision=2
 _commit=3bb3d757681e6cc5135aec6529a753dc3dcdcfb9
 _libyuv_commit=04821d1e7d60845525e8db55c7bcd41ef5be9406
 _abseil_commit=8c0b94e793a66495e0b1f34a5eb26bd7dc672db0

From b030bbc0f60510e8ff9fac8b4091b383533b34b2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:44 -0400
Subject: [PATCH 106/115] telegram-desktop: revbump for ffmpeg-6.0

---
 srcpkgs/telegram-desktop/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/telegram-desktop/template b/srcpkgs/telegram-desktop/template
index 26a167befd980..5b093861e96e8 100644
--- a/srcpkgs/telegram-desktop/template
+++ b/srcpkgs/telegram-desktop/template
@@ -1,7 +1,7 @@
 # Template file for 'telegram-desktop'
 pkgname=telegram-desktop
 version=4.10.1
-revision=2
+revision=3
 build_style=cmake
 build_helper="qemu gir"
 configure_args="-DTDESKTOP_API_ID=209235

From 7c372cacade69c4066881259ae66c41adc5d3f6d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:11:13 -0400
Subject: [PATCH 107/115] mpv: revbump for ffmpeg-6.0

---
 srcpkgs/mpv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpv/template b/srcpkgs/mpv/template
index 933c22bae2ed2..301a77ad22971 100644
--- a/srcpkgs/mpv/template
+++ b/srcpkgs/mpv/template
@@ -1,7 +1,7 @@
 # Template file for 'mpv'
 pkgname=mpv
 version=0.36.0
-revision=2
+revision=3
 build_style=meson
 configure_args="-Dcdda=enabled -Ddvbin=enabled -Ddvdnav=enabled
  -Dlibmpv=true -Dcplugins=enabled

From 27659f2500766a2b1e30324f9342b89714367b8b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:11:45 -0400
Subject: [PATCH 108/115] gst-plugins-bad1: revbump for ffmpeg-6.0

---
 srcpkgs/gst-plugins-bad1/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index 2bf2f4b0642fe..0fafcb6555395 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-plugins-bad1'
 pkgname=gst-plugins-bad1
 version=1.22.5
-revision=1
+revision=2
 build_helper="gir"
 build_style=meson
 configure_args="-Dpackage-origin=https://voidlinux.org -Ddoc=disabled

From e17edc9f3a14a42c300f50396edfc984a4a43dd7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:12:09 -0400
Subject: [PATCH 109/115] openmw: revbump for ffmpeg-6.0

---
 srcpkgs/openmw/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openmw/template b/srcpkgs/openmw/template
index 0abf5ff7cdbec..b57180f1a4446 100644
--- a/srcpkgs/openmw/template
+++ b/srcpkgs/openmw/template
@@ -1,7 +1,7 @@
 # Template file for 'openmw'
 pkgname=openmw
 version=0.48.0
-revision=2
+revision=3
 build_style=cmake
 _recast_commit=e75adf86f91eb3082220085e42dda62679f9a3ea
 _bullet_tag=3.17

From 0ddd3c4bd1dcfc81807f64232ffa663ed365c643 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:14:53 -0400
Subject: [PATCH 110/115] lms: revbump for ffmpeg-6.0

---
 srcpkgs/lms/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/lms/template b/srcpkgs/lms/template
index 39d34f62965c8..eb91d2ca275f3 100644
--- a/srcpkgs/lms/template
+++ b/srcpkgs/lms/template
@@ -1,7 +1,7 @@
 # Template file for 'lms'
 pkgname=lms
 version=3.40.0
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="wt-devel ffmpeg-devel boost-devel libconfig++-devel taglib-devel pam-devel libgraphicsmagick-devel gtest-devel libarchive-devel"

From 32bdc5e0fbb60d0a1ac24b3b7f239b88d56c2f15 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:15:14 -0400
Subject: [PATCH 111/115] openimageio: revbump for ffmpeg-6.0

---
 srcpkgs/openimageio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimageio/template b/srcpkgs/openimageio/template
index d8a6ba56efd11..d7ad79563a2af 100644
--- a/srcpkgs/openimageio/template
+++ b/srcpkgs/openimageio/template
@@ -1,7 +1,7 @@
 # Template file for 'openimageio'
 pkgname=openimageio
 version=2.4.9.0
-revision=6
+revision=7
 build_style=cmake
 build_helper=qemu
 configure_args="-DUSE_QT=0 -DUSE_PYTHON=0 -DOIIO_BUILD_TESTS=0

From e640f8433a347e03a7d96509712f9d7faf707145 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:18:18 -0400
Subject: [PATCH 112/115] freecad: revbump for ffmpeg-6.0

---
 srcpkgs/freecad/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/freecad/template b/srcpkgs/freecad/template
index c135701e38b9a..705499e9972a6 100644
--- a/srcpkgs/freecad/template
+++ b/srcpkgs/freecad/template
@@ -1,7 +1,7 @@
 # Template file for 'freecad'
 pkgname=freecad
 version=0.20.2
-revision=7
+revision=8
 build_wrksrc="FreeCAD-${version}"
 build_style=cmake
 pycompile_dirs="usr/lib/${pkgname}/Mod"

From d6faaeb2c0ab00e6cabb7ab2f168728f27c8560e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:40:39 -0400
Subject: [PATCH 113/115] obs: revbump for ffmpeg-6.0

---
 srcpkgs/obs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/obs/template b/srcpkgs/obs/template
index b43b10ef935e9..5d1d5e887409e 100644
--- a/srcpkgs/obs/template
+++ b/srcpkgs/obs/template
@@ -1,7 +1,7 @@
 # Template file for 'obs'
 pkgname=obs
 version=29.1.3
-revision=2
+revision=3
 archs="i686* x86_64* ppc64le* aarch64*"
 build_style=cmake
 configure_args="-DOBS_VERSION_OVERRIDE=${version} -DENABLE_JACK=ON

From 81436d2b9015688d018d8fec54fd9ad9f6357fac Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:46:47 -0400
Subject: [PATCH 114/115] mlt7: revbump for ffmpeg-6.0

---
 srcpkgs/mlt7/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mlt7/template b/srcpkgs/mlt7/template
index 77579fbf6b634..0a2a2702544fe 100644
--- a/srcpkgs/mlt7/template
+++ b/srcpkgs/mlt7/template
@@ -1,7 +1,7 @@
 # Template file for 'mlt7'
 pkgname=mlt7
 version=7.14.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DSWIG_PYTHON=ON"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which

From a6ab397b64c0ac347c37b39a880f4a36c5d1ae20 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:47:18 -0400
Subject: [PATCH 115/115] libopenshot: revbump for ffmpeg-6.0

---
 srcpkgs/libopenshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenshot/template b/srcpkgs/libopenshot/template
index 8e57c5f592169..7a8f4520e7892 100644
--- a/srcpkgs/libopenshot/template
+++ b/srcpkgs/libopenshot/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenshot'
 pkgname=libopenshot
 version=0.3.0
-revision=3
+revision=4
 build_style=cmake
 # Builds fail with Ruby-2.4.1
 configure_args="-DENABLE_RUBY=OFF -DUSE_SYSTEM_JSONCPP=ON"

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (27 preceding siblings ...)
  2023-10-16 12:11 ` [PR PATCH] [Updated] " zlice
@ 2023-10-16 12:12 ` zlice
  2023-10-16 12:19 ` SpidFightFR
                   ` (68 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2023-10-16 12:12 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 182 bytes --]

New comment by zlice on void-packages repository

https://github.com/void-linux/void-packages/pull/43761#issuecomment-1764341884

Comment:
Got 64/32bit x86 building again. tyvm spid

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (28 preceding siblings ...)
  2023-10-16 12:12 ` zlice
@ 2023-10-16 12:19 ` SpidFightFR
  2023-10-16 12:19 ` SpidFightFR
                   ` (67 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: SpidFightFR @ 2023-10-16 12:19 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 303 bytes --]

New comment by SpidFightFR on void-packages repository

https://github.com/void-linux/void-packages/pull/43761#issuecomment-1764353648

Comment:
> Got 64/32bit x86 building again. tyvm spid

it's not ready yet, i believe there is an issue with arm and aarch64 archs.
Mesa still can't be updated atm.

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (29 preceding siblings ...)
  2023-10-16 12:19 ` SpidFightFR
@ 2023-10-16 12:19 ` SpidFightFR
  2023-10-16 12:26 ` SpidFightFR
                   ` (66 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: SpidFightFR @ 2023-10-16 12:19 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 212 bytes --]

New comment by SpidFightFR on void-packages repository

https://github.com/void-linux/void-packages/pull/43761#issuecomment-1764354752

Comment:
see here: https://github.com/void-linux/void-packages/issues/46674

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (30 preceding siblings ...)
  2023-10-16 12:19 ` SpidFightFR
@ 2023-10-16 12:26 ` SpidFightFR
  2023-10-16 12:27 ` SpidFightFR
                   ` (65 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: SpidFightFR @ 2023-10-16 12:26 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 389 bytes --]

New comment by SpidFightFR on void-packages repository

https://github.com/void-linux/void-packages/pull/43761#issuecomment-1764353648

Comment:
> Got 64/32bit x86 building again. tyvm spid

it's not ready yet, i believe there is an issue with arm and aarch64 archs.
Mesa still can't be updated atm.

Edit, if i'm luck, i can get it ready for tonight, but nothing's set in the stone.

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (31 preceding siblings ...)
  2023-10-16 12:26 ` SpidFightFR
@ 2023-10-16 12:27 ` SpidFightFR
  2023-10-16 12:27 ` SpidFightFR
                   ` (64 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: SpidFightFR @ 2023-10-16 12:27 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 390 bytes --]

New comment by SpidFightFR on void-packages repository

https://github.com/void-linux/void-packages/pull/43761#issuecomment-1764353648

Comment:
> Got 64/32bit x86 building again. tyvm spid

it's not ready yet, i believe there is an issue with arm and aarch64 archs.
Mesa still can't be updated atm.

Edit, if i'm lucky, i can get it ready for tonight, but nothing's set in the stone.

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (32 preceding siblings ...)
  2023-10-16 12:27 ` SpidFightFR
@ 2023-10-16 12:27 ` SpidFightFR
  2023-10-17 12:58 ` [PR PATCH] [Updated] " zlice
                   ` (63 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: SpidFightFR @ 2023-10-16 12:27 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 392 bytes --]

New comment by SpidFightFR on void-packages repository

https://github.com/void-linux/void-packages/pull/43761#issuecomment-1764353648

Comment:
> Got 64/32bit x86 building again. tyvm spid

it's not ready yet, i believe there is an issue with arm and aarch64 archs.
Mesa still can't be updated atm.

Edit, if i'm lucky, i might get it ready for tonight, but nothing's set in the stone.

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (33 preceding siblings ...)
  2023-10-16 12:27 ` SpidFightFR
@ 2023-10-17 12:58 ` zlice
  2023-10-17 12:59 ` zlice
                   ` (62 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2023-10-17 12:58 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 3573 bytes --]

There is an updated pull request by zlice against master on the void-packages repository

https://github.com/zlice/void-packages ffmpeg6-split
https://github.com/void-linux/void-packages/pull/43761

ffmpeg6 split
[ci skip]


#### Testing the changes

- I tested the changes in this PR: **YES**

main testing has been vaapi in Firefox Nightly and enc/dec in Shotcut on Intel A770

#### New package

- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**

#### Local build testing

- I built this PR locally for my native architecture, **x86_64**

#### Discussion

Continuation of https://github.com/void-linux/void-packages/pull/36315

`libavresample` is deprecated, but marked as a dependency when trying to build other packages and install `ffmpeg`(6). I think the right way to handle this is make a meta package and the add to removals?


##### Commit naming / misc

~~Commits are 'dirty' right now, running with [gstreamer 1.22.1 updates](https://github.com/void-linux/void-packages/pull/42861) and [Intel OpenCL](https://github.com/void-linux/void-packages/pull/43084). This will also make [intel packages pr](https://github.com/void-linux/void-packages/pull/41132) obsolete.~~ (see Requirements below)

Maintainer for previous ffmpeg(4) was orphaned, I can put my name in there if that matters, though I don't exactly see myself keeping up on ffmpeg.

This updates QT5 which looks like it is usually hosted by Johnny. Not sure if there's any reason to stay there or these sources are fine.

##### STILL FFMPEG4

These are a mix of emulators, games and/or older packages.

- attract (multiple patches in master)
- audacity (https://github.com/audacity/audacity/issues/2305 and https://sourceforge.net/p/portmedia/wiki/portsmf/ is 'beta')
- ccextractor (master patches? no release)
- vice
- kodi
- mlt (only dep left is flowblade)
- ~~synfig (mlt)~~ (work with mlt7, bump synfigstudio)
- tvheadend
- ssr
- spek-alternative
- ppsspp
- olive
- moc
- mediastreamer
- libextractor
- idjc
- hedgewars
- ~~ffmpegthumbnailer~~ (patches for moviedecoder.xxx files)
- ~~ffmpegthumbs~~ (latest compiles)
- deadbeef
- omxplayer
- qtav (fork has ffmpeg 5 patch - https://github.com/cmguo/QtAV)
- `vlc` (vlc4 will support ffmpeg5, there's a patch to build 3.x with ffmpeg5 but it will lack vaapi)
- `osg` (OpenSceneGraph plus `xine-lib`)


##### HAVE NOT BUILT YET

- omxplayer (rpi only? ffmpeg4)
- kodi (big, but ffmpeg4)


##### UPDATED (for ffmpeg6)

- ~~blender: update to 3.5.1~~ ~~will be revbump with~~ https://github.com/void-linux/void-packages/pull/43992
- unpaper: update to 7.0.0.
- guvcview: update to 2.0.8.
- qt5: update to 5.15.8
- qt5-webengine: update to 5.18.13
- shiboken2: revbump for qt5.15.8 (patch)
- python3-pyside2: update to 5.15.8 (patch)


##### Requirements

- ~~[gstreamer 1.22.2](https://github.com/void-linux/void-packages/pull/42861)~~ - a few packages use ffmpeg-devel and require a revbump

- [Intel Packages](https://github.com/void-linux/void-packages/pull/41132) - ffmpeg4 uses different libraries than 6 (libmfx / Intel-MediaSDK vs only oneVPL that Intel is moving to), both are included here

- ~~[shotcut 23.05.14](https://github.com/void-linux/void-packages/pull/44260)~~

- https://github.com/void-linux/void-packages/pull/44781 will remove from this PR

A patch file from https://github.com/void-linux/void-packages/pull/43761.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ffmpeg6-split-43761.patch --]
[-- Type: text/x-diff, Size: 788049 bytes --]

From ed3ee32214a7527d2050841a1befc63390738e1b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:16:56 -0400
Subject: [PATCH 001/115] ffmpeg: update to 6.0.

---
 common/shlibs                                 | 26 +++++---
 srcpkgs/ffmpeg/files/altivec.patch            | 60 -------------------
 .../patches/armv5tel-floating-point.patch     | 18 ------
 ...h-libavcodec-libsvtav1-ten_bit_format.diff | 40 -------------
 .../workaround-mesa-readeon-vaapi-bug.patch   | 28 ---------
 srcpkgs/ffmpeg/template                       | 38 ++++++------
 6 files changed, 37 insertions(+), 173 deletions(-)
 delete mode 100644 srcpkgs/ffmpeg/files/altivec.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 delete mode 100644 srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch

diff --git a/common/shlibs b/common/shlibs
index 67ecffb1effa3..2fecdb6e90491 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -385,15 +385,23 @@ libid3tag.so.0 libid3tag-0.15.1b_1
 libgif.so.7 giflib-5.1.0_1
 libImlib2.so.1 imlib2-1.4.2_1
 libmp3lame.so.0 lame-3.98.2_1
-libavdevice.so.58 libavdevice-4.0_1
-libavformat.so.58 libavformat-4.0_1
-libswscale.so.5 libswscale-4.0_1
-libswresample.so.3 libswresample-4.0_1
-libavresample.so.4 libavresample-4.0_1
-libpostproc.so.55 libpostproc-4.0_1
-libavcodec.so.58 libavcodec-4.0_1
-libavutil.so.56 libavutil-4.0_1
-libavfilter.so.7 libavfilter-4.0_1
+libavdevice.so.60 libavdevice-6.0_1
+libavformat.so.60 libavformat-6.0_1
+libswscale.so.7 libswscale-6.0_1
+libswresample.so.4 libswresample-6.0_1
+libpostproc.so.57 libpostproc-6.0_1
+libavcodec.so.60 libavcodec-6.0_1
+libavutil.so.58 libavutil-6.0_1
+libavfilter.so.9 libavfilter-6.0_1
+libavdevice.so.58 libavdevice4-4.0_1
+libavformat.so.58 libavformat4-4.0_1
+libswscale.so.5 libswscale4-4.0_1
+libswresample.so.3 libswresample4-4.0_1
+libavresample.so.4 libavresample4-4.0_1
+libpostproc.so.55 libpostproc4-4.0_1
+libavcodec.so.58 libavcodec4-4.0_1
+libavutil.so.56 libavutil4-4.0_1
+libavfilter.so.7 libavfilter4-4.0_1
 libSDL-1.2.so.0 SDL-1.2.14_1
 libSDL_image-1.2.so.0 SDL_image-1.2.10_1
 libx264.so.157 x264-20190507.2245_1
diff --git a/srcpkgs/ffmpeg/files/altivec.patch b/srcpkgs/ffmpeg/files/altivec.patch
deleted file mode 100644
index 9c57200463320..0000000000000
--- a/srcpkgs/ffmpeg/files/altivec.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-revert some altivec specific change on all ppc* except ppc64le*
-
-q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
-conditionally, for ppc* but not ppc64le* (the new code is valid for
-POWER8 VSX which LE targets as a baseline but not BE)"
-
-
-This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
----
- libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
- 1 file changed, 20 insertions(+), 4 deletions(-)
-
-diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
-index 536545293d..c1e2852adb 100644
---- a/libswscale/ppc/yuv2rgb_altivec.c
-+++ b/libswscale/ppc/yuv2rgb_altivec.c
-@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-     vector signed short R1, G1, B1;                                           \
-     vector unsigned char R, G, B;                                             \
-                                                                               \
-+    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
-+    vector unsigned char align_perm;                                          \
-+                                                                              \
-     vector signed short lCY       = c->CY;                                    \
-     vector signed short lOY       = c->OY;                                    \
-     vector signed short lCRV      = c->CRV;                                   \
-@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
-                                                                               \
-         for (j = 0; j < w / 16; j++) {                                        \
--            y0 = vec_xl(0, y1i);                                              \
-+            y1ivP = (const vector unsigned char *) y1i;                       \
-+            y2ivP = (const vector unsigned char *) y2i;                       \
-+            uivP  = (const vector unsigned char *) ui;                        \
-+            vivP  = (const vector unsigned char *) vi;                        \
-+                                                                              \
-+            align_perm = vec_lvsl(0, y1i);                                    \
-+            y0 = (vector unsigned char)                                       \
-+                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
-                                                                               \
--            y1 = vec_xl(0, y2i);                                              \
-+            align_perm = vec_lvsl(0, y2i);                                    \
-+            y1 = (vector unsigned char)                                       \
-+                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
-                                                                               \
--            u = (vector signed char) vec_xl(0, ui);                           \
-+            align_perm = vec_lvsl(0, ui);                                     \
-+            u = (vector signed char)                                          \
-+                    vec_perm(uivP[0], uivP[1], align_perm);                   \
-                                                                               \
--            v = (vector signed char) vec_xl(0, vi);                           \
-+            align_perm = vec_lvsl(0, vi);                                     \
-+            v = (vector signed char)                                          \
-+                    vec_perm(vivP[0], vivP[1], align_perm);                   \
-                                                                               \
-             u = (vector signed char)                                          \
-                     vec_sub(u,                                                \
--- 
-2.27.0
-
diff --git a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
deleted file mode 100644
index 9a55178c74f0f..0000000000000
--- a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
-+++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
-@@ -39,6 +39,15 @@
- #endif
- #include <fenv.h>
- 
-+#if (FE_ALL_EXCEPT == 0)
-+/* E.g. ARM soft float does not define these */
-+#define FE_INVALID    0
-+#define FE_DIVBYZERO  0
-+#define FE_OVERFLOW   0
-+#define FE_UNDERFLOW  0
-+#define FE_INEXACT    0
-+#endif
-+
- #if CONFIG_LIBFONTCONFIG
- #include <fontconfig/fontconfig.h>
- #endif
diff --git a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
deleted file mode 100644
index aa948f7a8a2df..0000000000000
--- a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
+++ /dev/null
@@ -1,40 +0,0 @@
-#==================================================================================================
-# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
-# From: Christopher Degawa <christopher.degawa@intel.com>
-# Date: Thu, 20 Oct 2022 22:55:27 -0500
-# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
-#
-# compressed_ten_bit_format has been deprecated upstream and has no effect
-# and can be removed. Plus, technically it was never used in the first place
-# since it would require the app (ffmpeg) to set it and do additional
-# processing of the input frames.
-#
-# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
-#
-# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
-#==================================================================================================
---- a/libavcodec/libsvtav1.c
-+++ b/libavcodec/libsvtav1.c
-@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
- 
- static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
- {
--    const int    pack_mode_10bit =
--        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
--    const size_t luma_size_8bit  =
--        config->source_width * config->source_height * (1 << pack_mode_10bit);
--    const size_t luma_size_10bit =
--        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
-+    const size_t luma_size = config->source_width * config->source_height *
-+        (config->encoder_bit_depth > 8 ? 2 : 1);
- 
-     EbSvtIOFormat *in_data;
- 
--    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
-+    svt_enc->raw_size = luma_size * 3 / 2;
- 
-     // allocate buffer for in and out
-     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
--- 
-GitLab
-
diff --git a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
deleted file mode 100644
index 00e3f68a415b8..0000000000000
--- a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
-From: Rainer Hochecker <fernetmenta@online.de>
-Date: Sat, 26 Jan 2019 19:48:35 +0100
-Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
-
-This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
-It was hit frequently when watching h264 channels received via DVB-X.
-Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
----
- libavcodec/vaapi_h264.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
-index 5854587a255..f12fdc457a4 100644
---- a/libavcodec/vaapi_h264.c
-+++ b/libavcodec/vaapi_h264.c
-@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
-     H264SliceContext *sl = &h->slice_ctx[0];
-     int ret;
- 
-+    if (pic->nb_slices == 0) {
-+        ret = AVERROR_INVALIDDATA;
-+        goto finish;
-+    }
-+
-     ret = ff_vaapi_decode_issue(avctx, pic);
-     if (ret < 0)
-         goto finish;
diff --git a/srcpkgs/ffmpeg/template b/srcpkgs/ffmpeg/template
index d2f8def0e25f7..c1f9b7efe40e3 100644
--- a/srcpkgs/ffmpeg/template
+++ b/srcpkgs/ffmpeg/template
@@ -1,15 +1,15 @@
 # Template file for 'ffmpeg'
 # audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
 pkgname=ffmpeg
-version=4.4.4
-revision=3
+version=6.0
+revision=1
 short_desc="Decoding, encoding and streaming software"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="https://www.ffmpeg.org"
 changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
 distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
-checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+checksum=57be87c22d9b49c112b6d24bc67d42508660e6b718b3db89c44e47e289137082
 
 hostmakedepends="pkg-config perl"
 makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
@@ -26,12 +26,13 @@ makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-deve
  $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
  $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
  $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
- $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers Vulkan-Tools Vulkan-ValidationLayers')
+ $(vopt_if onevpl 'onevpl onevpl-devel')
  $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
 depends="ffplay>=${version}_${revision}"
 
 build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
- dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec onevpl"
 build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
 desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
 desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
@@ -39,9 +40,13 @@ desc_option_sofa="Enable support for AES SOFA"
 desc_option_webp="Enable support for WebP"
 
 case "$XBPS_TARGET_MACHINE" in
-	i686*|x86_64*)
-		hostmakedepends+=" nasm"
+	i686*)
 		build_options_default+=" vaapi vdpau nvenc nvdec"
+		hostmakedepends+=" nasm"
+		;;
+	x86_64*)
+		hostmakedepends+=" nasm"
+		build_options_default+=" vaapi vdpau nvenc nvdec onevpl"
 		;;
 	ppc64*) build_options_default+=" vaapi vdpau";;
 	mips*) CFLAGS="-mnan=legacy";;
@@ -115,18 +120,19 @@ do_configure() {
 		$(vopt_enable x265 libx265) \
 		$(vopt_enable v4l2 libv4l2) \
 		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
-		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		--enable-libbs2b --enable-libvidstab \
 		$(vopt_enable dav1d libdav1d) \
 		$(vopt_enable zimg libzimg) \
 		$(vopt_enable webp libwebp) \
 		$(vopt_enable sofa libmysofa) \
 		$(vopt_enable vulkan) \
+		$(vopt_enable onevpl libvpl) \
 		$(vopt_enable drm libdrm) \
 		$(vopt_enable svtav1 libsvtav1) \
 		$(vopt_enable srt libsrt) \
 		$(vopt_enable rist librist) \
-		$(vopt_if nvenc '--enable-nvenc') \
-		$(vopt_if nvdec '--enable-nvdec')
+		$(vopt_enable nvenc nvenc) \
+		$(vopt_enable nvdec nvdec)
 }
 
 do_build() {
@@ -153,10 +159,8 @@ libavdevice_package() {
 }
 
 libavresample_package() {
-	short_desc="FFmpeg audio resampling library"
-	pkg_install() {
-		vmove "usr/lib/libavresample.so.*"
-	}
+	short_desc="Package deprecated, removal needed"
+	build_style=meta
 }
 
 libavformat_package() {
@@ -210,15 +214,13 @@ ffmpeg-devel_package() {
 		libavfilter>=${version}_${revision}
 		libpostproc>=${version}_${revision}
 		libswscale>=${version}_${revision}
-		libswresample>=${version}_${revision}
-		libavresample>=${version}_${revision}"
+		libswresample>=${version}_${revision}"
 	short_desc+=" - development files"
-
+	conflicts="ffmpeg4-devel"
 	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
 		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
 		nostrip_files="/usr/lib/libavfilter.a"
 	fi
-
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig

From 834c394f3fecc46e4916b38fff8edfe700b20c4b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:17:26 -0400
Subject: [PATCH 002/115] baresip: revbump for ffmpeg-6.0

---
 srcpkgs/baresip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/baresip/template b/srcpkgs/baresip/template
index b21e22334316e..16a1b98304790 100644
--- a/srcpkgs/baresip/template
+++ b/srcpkgs/baresip/template
@@ -1,7 +1,7 @@
 # Template file for 'baresip'
 pkgname=baresip
 version=2.10.0
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config glib-devel"
 makedepends="libgsm-devel libpng-devel openssl-devel libsndfile-devel

From e98a68f35e5fd9b9528926850645413b5c3d3aa0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:14 -0400
Subject: [PATCH 003/115] openshot: revbump for ffmpeg6.0

---
 srcpkgs/openshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openshot/template b/srcpkgs/openshot/template
index 8f47851eef354..affb652a9d500 100644
--- a/srcpkgs/openshot/template
+++ b/srcpkgs/openshot/template
@@ -1,7 +1,7 @@
 # Template file for 'openshot'
 pkgname=openshot
 version=3.0.0
-revision=2
+revision=3
 build_style=python3-module
 hostmakedepends="python3 python3-setuptools"
 makedepends="ffmpeg-devel python3-PyQt5"

From 59ac1f84dc81330ceea08b6c6fe0c155f3806c18 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:36 -0400
Subject: [PATCH 004/115] sumo: revbump for ffmpeg6.0

---
 srcpkgs/sumo/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/sumo/template b/srcpkgs/sumo/template
index a3fe134aa5acc..a730afa9fafa9 100644
--- a/srcpkgs/sumo/template
+++ b/srcpkgs/sumo/template
@@ -1,7 +1,7 @@
 # Template file for 'sumo'
 pkgname=sumo
 version=1.12.0
-revision=6
+revision=7
 build_style=cmake
 hostmakedepends="libgdal-tools pkg-config swig python3-setuptools"
 makedepends="python3-devel ffmpeg-devel fox-devel gl2ps-devel libgdal-devel

From 53204644690a3947a6405b3a353c69d657cf048e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:56:22 -0400
Subject: [PATCH 005/115] New package: ffmpeg4-4.4.4.

---
 srcpkgs/ffmpeg4-devel                         |   1 +
 srcpkgs/ffmpeg4/files/altivec.patch           |  60 +++++
 .../patches/armv5tel-floating-point.patch     |  18 ++
 ...h-libavcodec-libsvtav1-ten_bit_format.diff |  40 +++
 .../workaround-mesa-readeon-vaapi-bug.patch   |  28 ++
 srcpkgs/ffmpeg4/template                      | 240 ++++++++++++++++++
 srcpkgs/libavcodec4                           |   1 +
 srcpkgs/libavdevice4                          |   1 +
 srcpkgs/libavfilter4                          |   1 +
 srcpkgs/libavformat4                          |   1 +
 srcpkgs/libavresample4                        |   1 +
 srcpkgs/libavutil4                            |   1 +
 srcpkgs/libpostproc4                          |   1 +
 srcpkgs/libswresample4                        |   1 +
 srcpkgs/libswscale4                           |   1 +
 15 files changed, 396 insertions(+)
 create mode 120000 srcpkgs/ffmpeg4-devel
 create mode 100644 srcpkgs/ffmpeg4/files/altivec.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 create mode 100644 srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
 create mode 100644 srcpkgs/ffmpeg4/template
 create mode 120000 srcpkgs/libavcodec4
 create mode 120000 srcpkgs/libavdevice4
 create mode 120000 srcpkgs/libavfilter4
 create mode 120000 srcpkgs/libavformat4
 create mode 120000 srcpkgs/libavresample4
 create mode 120000 srcpkgs/libavutil4
 create mode 120000 srcpkgs/libpostproc4
 create mode 120000 srcpkgs/libswresample4
 create mode 120000 srcpkgs/libswscale4

diff --git a/srcpkgs/ffmpeg4-devel b/srcpkgs/ffmpeg4-devel
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/ffmpeg4-devel
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/ffmpeg4/files/altivec.patch b/srcpkgs/ffmpeg4/files/altivec.patch
new file mode 100644
index 0000000000000..9c57200463320
--- /dev/null
+++ b/srcpkgs/ffmpeg4/files/altivec.patch
@@ -0,0 +1,60 @@
+revert some altivec specific change on all ppc* except ppc64le*
+
+q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
+conditionally, for ppc* but not ppc64le* (the new code is valid for
+POWER8 VSX which LE targets as a baseline but not BE)"
+
+
+This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
+---
+ libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
+ 1 file changed, 20 insertions(+), 4 deletions(-)
+
+diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
+index 536545293d..c1e2852adb 100644
+--- a/libswscale/ppc/yuv2rgb_altivec.c
++++ b/libswscale/ppc/yuv2rgb_altivec.c
+@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+     vector signed short R1, G1, B1;                                           \
+     vector unsigned char R, G, B;                                             \
+                                                                               \
++    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
++    vector unsigned char align_perm;                                          \
++                                                                              \
+     vector signed short lCY       = c->CY;                                    \
+     vector signed short lOY       = c->OY;                                    \
+     vector signed short lCRV      = c->CRV;                                   \
+@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
+                                                                               \
+         for (j = 0; j < w / 16; j++) {                                        \
+-            y0 = vec_xl(0, y1i);                                              \
++            y1ivP = (const vector unsigned char *) y1i;                       \
++            y2ivP = (const vector unsigned char *) y2i;                       \
++            uivP  = (const vector unsigned char *) ui;                        \
++            vivP  = (const vector unsigned char *) vi;                        \
++                                                                              \
++            align_perm = vec_lvsl(0, y1i);                                    \
++            y0 = (vector unsigned char)                                       \
++                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
+                                                                               \
+-            y1 = vec_xl(0, y2i);                                              \
++            align_perm = vec_lvsl(0, y2i);                                    \
++            y1 = (vector unsigned char)                                       \
++                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
+                                                                               \
+-            u = (vector signed char) vec_xl(0, ui);                           \
++            align_perm = vec_lvsl(0, ui);                                     \
++            u = (vector signed char)                                          \
++                    vec_perm(uivP[0], uivP[1], align_perm);                   \
+                                                                               \
+-            v = (vector signed char) vec_xl(0, vi);                           \
++            align_perm = vec_lvsl(0, vi);                                     \
++            v = (vector signed char)                                          \
++                    vec_perm(vivP[0], vivP[1], align_perm);                   \
+                                                                               \
+             u = (vector signed char)                                          \
+                     vec_sub(u,                                                \
+-- 
+2.27.0
+
diff --git a/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
new file mode 100644
index 0000000000000..9a55178c74f0f
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
@@ -0,0 +1,18 @@
+--- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
++++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
+@@ -39,6 +39,15 @@
+ #endif
+ #include <fenv.h>
+ 
++#if (FE_ALL_EXCEPT == 0)
++/* E.g. ARM soft float does not define these */
++#define FE_INVALID    0
++#define FE_DIVBYZERO  0
++#define FE_OVERFLOW   0
++#define FE_UNDERFLOW  0
++#define FE_INEXACT    0
++#endif
++
+ #if CONFIG_LIBFONTCONFIG
+ #include <fontconfig/fontconfig.h>
+ #endif
diff --git a/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
new file mode 100644
index 0000000000000..aa948f7a8a2df
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
@@ -0,0 +1,40 @@
+#==================================================================================================
+# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
+# From: Christopher Degawa <christopher.degawa@intel.com>
+# Date: Thu, 20 Oct 2022 22:55:27 -0500
+# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
+#
+# compressed_ten_bit_format has been deprecated upstream and has no effect
+# and can be removed. Plus, technically it was never used in the first place
+# since it would require the app (ffmpeg) to set it and do additional
+# processing of the input frames.
+#
+# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
+#
+# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
+#==================================================================================================
+--- a/libavcodec/libsvtav1.c
++++ b/libavcodec/libsvtav1.c
+@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
+ 
+ static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
+ {
+-    const int    pack_mode_10bit =
+-        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
+-    const size_t luma_size_8bit  =
+-        config->source_width * config->source_height * (1 << pack_mode_10bit);
+-    const size_t luma_size_10bit =
+-        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
++    const size_t luma_size = config->source_width * config->source_height *
++        (config->encoder_bit_depth > 8 ? 2 : 1);
+ 
+     EbSvtIOFormat *in_data;
+ 
+-    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
++    svt_enc->raw_size = luma_size * 3 / 2;
+ 
+     // allocate buffer for in and out
+     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
+-- 
+GitLab
+
diff --git a/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
new file mode 100644
index 0000000000000..00e3f68a415b8
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
@@ -0,0 +1,28 @@
+From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
+From: Rainer Hochecker <fernetmenta@online.de>
+Date: Sat, 26 Jan 2019 19:48:35 +0100
+Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
+
+This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
+It was hit frequently when watching h264 channels received via DVB-X.
+Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
+---
+ libavcodec/vaapi_h264.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
+index 5854587a255..f12fdc457a4 100644
+--- a/libavcodec/vaapi_h264.c
++++ b/libavcodec/vaapi_h264.c
+@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
+     H264SliceContext *sl = &h->slice_ctx[0];
+     int ret;
+ 
++    if (pic->nb_slices == 0) {
++        ret = AVERROR_INVALIDDATA;
++        goto finish;
++    }
++
+     ret = ff_vaapi_decode_issue(avctx, pic);
+     if (ret < 0)
+         goto finish;
diff --git a/srcpkgs/ffmpeg4/template b/srcpkgs/ffmpeg4/template
new file mode 100644
index 0000000000000..f2c851693d367
--- /dev/null
+++ b/srcpkgs/ffmpeg4/template
@@ -0,0 +1,240 @@
+# Template file for 'ffmpeg4'
+# audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
+pkgname=ffmpeg4
+version=4.4.4
+revision=1
+short_desc="Decoding, encoding and streaming software - ffmpeg4 libraries only"
+maintainer="Orphaned <orphan@voidlinux.org>"
+license="GPL-3.0-or-later"
+homepage="https://www.ffmpeg.org"
+changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
+distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
+checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+
+hostmakedepends="pkg-config perl"
+makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
+ libXext-devel libXvMC-devel libxcb-devel lame-devel libtheora-devel
+ libvorbis-devel x264-devel xvidcore-devel jack-devel SDL2-devel
+ libcdio-paranoia-devel librtmp-devel libmodplug-devel gnutls-devel
+ speex-devel celt-devel harfbuzz-devel libass-devel opus-devel ocl-icd-devel
+ libbs2b-devel libvidstab-devel vmaf-devel $(vopt_if pulseaudio pulseaudio-devel)
+ $(vopt_if vaapi libva-devel) $(vopt_if vdpau libvdpau-devel)
+ $(vopt_if x265 x265-devel) $(vopt_if v4l2 v4l-utils-devel)
+ $(vopt_if fdk_aac fdk-aac-devel) $(vopt_if vpx libvpx-devel)
+ $(vopt_if aom libaom-devel) $(vopt_if sndio sndio-devel)
+ $(vopt_if dav1d libdav1d-devel) $(vopt_if zimg zimg-devel)
+ $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
+ $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
+ $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if mfx 'libmfx libmfx-devel')
+ $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
+
+build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec mfx"
+build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
+
+desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
+desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
+desc_option_sofa="Enable support for AES SOFA"
+desc_option_webp="Enable support for WebP"
+
+case "$XBPS_TARGET_MACHINE" in
+	i686*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau nvenc nvdec"
+			;;
+	x86_64*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau mfx nvenc nvdec"
+			;;
+	ppc64*) build_options_default+=" vaapi vdpau";;
+	mips*) CFLAGS="-mnan=legacy";;
+esac
+
+if [ "$XBPS_TARGET_WORDSIZE" != "32" ]; then
+	build_options_default+=" svtav1"
+fi
+
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+fi
+
+_apply_patch() {
+	local args="$1" pname="$(basename $2)"
+
+	if [ ! -f ".${pname}_done" ]; then
+		patch -N $args -i $2
+		touch .${pname}_done
+	fi
+}
+
+post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64le*) ;;
+		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
+	esac
+
+	vsed -i libavfilter/vf_libvmaf.c -e 's!/usr/local/share/model/\(vmaf_v0.6.1\).pkl!/usr/share/vmaf/\1.json!'
+}
+
+do_configure() {
+	# Fix gcc on x86_64-musl only
+	if [ "$XBPS_TARGET_MACHINE" = "x86_64-musl" ]; then
+		vsed -i configure -e "s;_cflags_speed='-O3';_cflags_speed='-O2';"
+	fi
+
+	if [ "$CROSS_BUILD" ]; then
+		case "$XBPS_TARGET_MACHINE" in
+			arm*) _arch="arm";;
+			aarch64*) _arch="aarch64";;
+			mips*) _arch="mips";;
+			ppc64*) _arch="ppc64";;
+			ppc*) _arch="ppc";;
+			*) _arch="${XBPS_TARGET_MACHINE%%-musl}";;
+		esac
+
+		_args+=" --enable-cross-compile
+			--sysroot=$XBPS_CROSS_BASE
+			--cross-prefix=${XBPS_CROSS_TRIPLET}-
+			--target-os=linux --arch=${_arch}"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc|ppc-musl) _args+=" --disable-altivec";;
+	esac
+
+	if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+		_args+=" --extra-libs=-latomic"
+	fi
+
+	./configure --prefix=/usr --disable-debug --enable-gpl --enable-gnutls \
+		--disable-stripping \
+		--enable-libcdio --enable-version3 --enable-runtime-cpudetect \
+		--enable-libmp3lame --enable-libvorbis --enable-libxvid \
+		--enable-libx264 $(vopt_enable vpx libvpx) --enable-libtheora \
+		--enable-shared --enable-static --enable-libxcb \
+		$(vopt_enable pulseaudio libpulse) --enable-libfreetype --enable-libmodplug \
+		--enable-libspeex --enable-libcelt --enable-libass \
+		--enable-libopus --enable-librtmp --enable-libjack \
+		$(vopt_if fdk_aac '--enable-nonfree --enable-libfdk-aac') \
+		--disable-libopencore_amrnb --disable-libopencore_amrwb \
+		--disable-libopenjpeg \
+		--enable-postproc --enable-opencl ${_args} --enable-libvmaf ${_args} \
+		$(vopt_enable x265 libx265) \
+		$(vopt_enable v4l2 libv4l2) \
+		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
+		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		$(vopt_enable dav1d libdav1d) \
+		$(vopt_enable zimg libzimg) \
+		$(vopt_enable webp libwebp) \
+		$(vopt_enable sofa libmysofa) \
+		$(vopt_enable vulkan) \
+		$(vopt_enable drm libdrm) \
+		$(vopt_enable svtav1 libsvtav1) \
+		$(vopt_enable srt libsrt) \
+		$(vopt_enable rist librist) \
+		$(vopt_enable mfx libmfx) \
+		$(vopt_if nvenc '--enable-nvenc') \
+		$(vopt_if nvdec '--enable-nvdec')
+}
+
+do_build() {
+	make ${makejobs}
+	make doc/ff{mpeg,play}.1
+}
+
+do_install() {
+	make DESTDIR=${DESTDIR} install install-man
+	rm -rf ${DESTDIR}/usr/bin
+}
+
+libavcodec4_package() {
+	short_desc="FFmpeg codec library"
+	pkg_install() {
+		vmove "usr/lib/libavcodec.so.*"
+	}
+}
+
+libavdevice4_package() {
+	short_desc="FFmpeg device handling library"
+	pkg_install() {
+		vmove "usr/lib/libavdevice.so.*"
+	}
+}
+
+libavresample4_package() {
+	short_desc="FFmpeg audio resampling library"
+	pkg_install() {
+		vmove "usr/lib/libavresample.so.*"
+	}
+}
+
+libavformat4_package() {
+	short_desc="FFmpeg file format library"
+	pkg_install() {
+		vmove "usr/lib/libavformat.so.*"
+	}
+}
+
+libavutil4_package() {
+	short_desc="FFmpeg utility library"
+	pkg_install() {
+		vmove "usr/lib/libavutil.so.*"
+	}
+}
+
+libavfilter4_package() {
+	short_desc="FFmpeg audio/video filter library"
+	pkg_install() {
+		vmove "usr/lib/libavfilter.so.*"
+	}
+}
+
+libpostproc4_package() {
+	short_desc="FFmpeg video postprocessing library"
+	pkg_install() {
+		vmove "usr/lib/libpostproc.so.*"
+	}
+}
+
+libswscale4_package() {
+	short_desc="FFmpeg video scaling library"
+	pkg_install() {
+		vmove "usr/lib/libswscale.so.*"
+	}
+}
+
+libswresample4_package() {
+	short_desc="FFmpeg video resampling library"
+	pkg_install() {
+		vmove "usr/lib/libswresample.so.*"
+	}
+}
+
+ffmpeg4-devel_package() {
+	depends="
+		libavcodec4>=${version}_${revision}
+		libavdevice4>=${version}_${revision}
+		libavformat4>=${version}_${revision}
+		libavutil4>=${version}_${revision}
+		libavfilter4>=${version}_${revision}
+		libpostproc4>=${version}_${revision}
+		libswscale4>=${version}_${revision}
+		libswresample4>=${version}_${revision}
+		libavresample4>=${version}_${revision}"
+	short_desc+=" - development files"
+	conflicts="ffmpeg-devel"
+	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
+		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
+		nostrip_files="/usr/lib/libavfilter.a"
+	fi
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.a"
+		vmove "usr/lib/*.so"
+		vmove usr/share/ffmpeg/examples
+		vmove usr/share/man/man3
+	}
+}
diff --git a/srcpkgs/libavcodec4 b/srcpkgs/libavcodec4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavcodec4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavdevice4 b/srcpkgs/libavdevice4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavdevice4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavfilter4 b/srcpkgs/libavfilter4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavfilter4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavformat4 b/srcpkgs/libavformat4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavformat4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavresample4 b/srcpkgs/libavresample4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavutil4 b/srcpkgs/libavutil4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavutil4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libpostproc4 b/srcpkgs/libpostproc4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libpostproc4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswresample4 b/srcpkgs/libswresample4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libswresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswscale4 b/srcpkgs/libswscale4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libswscale4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file

From 42dd38b3a6d675cd2a2347fd8daa228574f7bbca Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:04 -0400
Subject: [PATCH 006/115] opencv: update to 4.7.0.

---
 common/shlibs           | 104 ++++++++++++++++++++--------------------
 srcpkgs/opencv/template |   8 ++--
 2 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index 2fecdb6e90491..b1ba1497c8295 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2085,58 +2085,58 @@ libcapstone.so.5 capstone-5.0.1_1
 libhavege.so.2 libhaveged-1.9.11_1
 libnih.so.1 libnih-1.0.3_1
 libnih-dbus.so.1 libnih-1.0.3_1
-libopencv_quality.so.406 libopencv-4.6.0_1
-libopencv_reg.so.406 libopencv-4.6.0_1
-libopencv_surface_matching.so.406 libopencv-4.6.0_1
-libopencv_xphoto.so.406 libopencv-4.6.0_1
-libopencv_freetype.so.406 libopencv-4.6.0_1
-libopencv_fuzzy.so.406 libopencv-4.6.0_1
-libopencv_hfs.so.406 libopencv-4.6.0_1
-libopencv_img_hash.so.406 libopencv-4.6.0_1
-libopencv_line_descriptor.so.406 libopencv-4.6.0_1
-libopencv_saliency.so.406 libopencv-4.6.0_1
-libopencv_structured_light.so.406 libopencv-4.6.0_1
-libopencv_aruco.so.406 libopencv-4.6.0_1
-libopencv_bgsegm.so.406 libopencv-4.6.0_1
-libopencv_bioinspired.so.406 libopencv-4.6.0_1
-libopencv_ccalib.so.406 libopencv-4.6.0_1
-libopencv_face.so.406 libopencv-4.6.0_1
-libopencv_tracking.so.406 libopencv-4.6.0_1
-libopencv_xfeatures2d.so.406 libopencv-4.6.0_1
-libopencv_optflow.so.406 libopencv-4.6.0_1
-libopencv_ximgproc.so.406 libopencv-4.6.0_1
-libopencv_plot.so.406 libopencv-4.6.0_1
-libopencv_text.so.406 libopencv-4.6.0_1
-libopencv_ml.so.406 libopencv-4.6.0_1
-libopencv_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn.so.406 libopencv-4.6.0_1
-libopencv_shape.so.406 libopencv-4.6.0_1
-libopencv_stitching.so.406 libopencv-4.6.0_1
-libopencv_photo.so.406 libopencv-4.6.0_1
-libopencv_video.so.406 libopencv-4.6.0_1
-libopencv_calib3d.so.406 libopencv-4.6.0_1
-libopencv_features2d.so.406 libopencv-4.6.0_1
-libopencv_flann.so.406 libopencv-4.6.0_1
-libopencv_highgui.so.406 libopencv-4.6.0_1
-libopencv_videoio.so.406 libopencv-4.6.0_1
-libopencv_imgcodecs.so.406 libopencv-4.6.0_1
-libopencv_imgproc.so.406 libopencv-4.6.0_1
-libopencv_core.so.406 libopencv-4.6.0_1
-libopencv_superres.so.406 libopencv-4.6.0_1
-libopencv_videostab.so.406 libopencv-4.6.0_1
-libopencv_gapi.so.406 libopencv-4.6.0_1
-libopencv_xobjdetect.so.406 libopencv-4.6.0_1
-libopencv_datasets.so.406 libopencv-4.6.0_1
-libopencv_dnn_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn_superres.so.406 libopencv-4.6.0_1
-libopencv_dpm.so.406 libopencv-4.6.0_1
-libopencv_phase_unwrapping.so.406 libopencv-4.6.0_1
-libopencv_stereo.so.406 libopencv-4.6.0_1
-libopencv_rapid.so.406 libopencv-4.6.0_1
-libopencv_intensity_transform.so.406 libopencv-4.6.0_1
-libopencv_alphamat.so.406 libopencv-4.6.0_1
-libopencv_barcode.so.406 libopencv-4.6.0_1
-libopencv_mcc.so.406 libopencv-4.6.0_1
+libopencv_quality.so.407 libopencv-4.7.0_1
+libopencv_reg.so.407 libopencv-4.7.0_1
+libopencv_surface_matching.so.407 libopencv-4.7.0_1
+libopencv_xphoto.so.407 libopencv-4.7.0_1
+libopencv_freetype.so.407 libopencv-4.7.0_1
+libopencv_fuzzy.so.407 libopencv-4.7.0_1
+libopencv_hfs.so.407 libopencv-4.7.0_1
+libopencv_img_hash.so.407 libopencv-4.7.0_1
+libopencv_line_descriptor.so.407 libopencv-4.7.0_1
+libopencv_saliency.so.407 libopencv-4.7.0_1
+libopencv_structured_light.so.407 libopencv-4.7.0_1
+libopencv_aruco.so.407 libopencv-4.7.0_1
+libopencv_bgsegm.so.407 libopencv-4.7.0_1
+libopencv_bioinspired.so.407 libopencv-4.7.0_1
+libopencv_ccalib.so.407 libopencv-4.7.0_1
+libopencv_face.so.407 libopencv-4.7.0_1
+libopencv_tracking.so.407 libopencv-4.7.0_1
+libopencv_xfeatures2d.so.407 libopencv-4.7.0_1
+libopencv_optflow.so.407 libopencv-4.7.0_1
+libopencv_ximgproc.so.407 libopencv-4.7.0_1
+libopencv_plot.so.407 libopencv-4.7.0_1
+libopencv_text.so.407 libopencv-4.7.0_1
+libopencv_ml.so.407 libopencv-4.7.0_1
+libopencv_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn.so.407 libopencv-4.7.0_1
+libopencv_shape.so.407 libopencv-4.7.0_1
+libopencv_stitching.so.407 libopencv-4.7.0_1
+libopencv_photo.so.407 libopencv-4.7.0_1
+libopencv_video.so.407 libopencv-4.7.0_1
+libopencv_calib3d.so.407 libopencv-4.7.0_1
+libopencv_features2d.so.407 libopencv-4.7.0_1
+libopencv_flann.so.407 libopencv-4.7.0_1
+libopencv_highgui.so.407 libopencv-4.7.0_1
+libopencv_videoio.so.407 libopencv-4.7.0_1
+libopencv_imgcodecs.so.407 libopencv-4.7.0_1
+libopencv_imgproc.so.407 libopencv-4.7.0_1
+libopencv_core.so.407 libopencv-4.7.0_1
+libopencv_superres.so.407 libopencv-4.7.0_1
+libopencv_videostab.so.407 libopencv-4.7.0_1
+libopencv_gapi.so.407 libopencv-4.7.0_1
+libopencv_xobjdetect.so.407 libopencv-4.7.0_1
+libopencv_datasets.so.407 libopencv-4.7.0_1
+libopencv_dnn_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn_superres.so.407 libopencv-4.7.0_1
+libopencv_dpm.so.407 libopencv-4.7.0_1
+libopencv_phase_unwrapping.so.407 libopencv-4.7.0_1
+libopencv_stereo.so.407 libopencv-4.7.0_1
+libopencv_rapid.so.407 libopencv-4.7.0_1
+libopencv_intensity_transform.so.407 libopencv-4.7.0_1
+libopencv_alphamat.so.407 libopencv-4.7.0_1
+libopencv_barcode.so.407 libopencv-4.7.0_1
+libopencv_mcc.so.407 libopencv-4.7.0_1
 libuniconf.so.4.6 wvstreams-4.6.1_20
 libwvbase.so.4.6 wvstreams-4.6.1_20
 libwvutils.so.4.6 wvstreams-4.6.1_20
diff --git a/srcpkgs/opencv/template b/srcpkgs/opencv/template
index 8a7eb6a5ddc5b..ce94de9424d18 100644
--- a/srcpkgs/opencv/template
+++ b/srcpkgs/opencv/template
@@ -1,7 +1,7 @@
 # Template file for 'opencv'
 pkgname=opencv
-version=4.6.0
-revision=5
+version=4.7.0
+revision=1
 create_wrksrc=yes
 build_wrksrc=${pkgname}-${version}
 build_style=cmake
@@ -24,8 +24,8 @@ homepage="https://opencv.org"
 changelog="https://github.com/opencv/opencv/wiki/ChangeLog"
 distfiles="https://github.com/opencv/opencv/archive/${version}.tar.gz
  https://github.com/opencv/opencv_contrib/archive/${version}.tar.gz>contrib.tar.gz"
-checksum="1ec1cba65f9f20fe5a41fda1586e01c70ea0c9a6d7b67c9e13edf0cfe2239277
- 1777d5fd2b59029cf537e5fd6f8aa68d707075822f90bde683fcde086f85f7a7"
+checksum="8df0079cdbe179748a18d44731af62a245a45ebf5085223dc03133954c662973
+ 42df840cf9055e59d0e22c249cfb19f04743e1bdad113d31b1573d3934d62584"
 patch_args="-Np1 -d ${build_wrksrc}"
 # tests hang indenfinitely, even with test data included
 make_check=no

From 41c7c9bbe6807562561012951eea22f6a19ee367 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 007/115] actiona: revbump for opencv-4.7.0

---
 srcpkgs/actiona/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/actiona/template b/srcpkgs/actiona/template
index cf5f0b7a2ae61..0d899311e6df7 100644
--- a/srcpkgs/actiona/template
+++ b/srcpkgs/actiona/template
@@ -1,7 +1,7 @@
 # Template file for 'actiona'
 pkgname=actiona
 version=3.10.1
-revision=2
+revision=3
 build_style=qmake
 configure_args="PKGCONFIG_OPENCV=opencv4"
 hostmakedepends="pkg-config qt5-plugin-mysql qt5-qmake qt5-host-tools"

From f28db043f12a9565b568045ac29a382ca104735d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 008/115] qimgv: revbump for opencv-4.7.0

---
 srcpkgs/qimgv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qimgv/template b/srcpkgs/qimgv/template
index 7eb30db33992c..dd341dfe1bfce 100644
--- a/srcpkgs/qimgv/template
+++ b/srcpkgs/qimgv/template
@@ -1,7 +1,7 @@
 # Template file for 'qimgv'
 pkgname=qimgv
 version=1.0.2
-revision=2
+revision=3
 build_style=cmake
 configure_args="$(vopt_if video -DVIDEO_SUPPORT=ON -DVIDEO_SUPPORT=OFF)
  $(vopt_if scale -DOPENCV_SUPPORT=ON -DOPENCV_SUPPORT=OFF)

From a9da5030f2716284f4dfdb4b686e8b67916b22fe Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 009/115] retroshare: revbump for opencv-4.7.0

---
 srcpkgs/retroshare/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroshare/template b/srcpkgs/retroshare/template
index bb17569277a7f..49e2c1cbe8a53 100644
--- a/srcpkgs/retroshare/template
+++ b/srcpkgs/retroshare/template
@@ -1,7 +1,7 @@
 # Template file for 'retroshare'
 pkgname=retroshare
 version=0.6.6
-revision=3
+revision=4
 build_style=qmake
 #XXX broadcast feature requires an ancient udp-discovery-cpp which either needs
 # to be fetched+patched (FTBFS) here or packaged :/

From 39ba2f409885c895cb55d3c86d653de86eb58f3c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 010/115] waifu2x-converter-cpp: revbump for opencv-4.7.0

---
 srcpkgs/waifu2x-converter-cpp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waifu2x-converter-cpp/template b/srcpkgs/waifu2x-converter-cpp/template
index 361b8a23b9497..c5ac17eb54ea4 100644
--- a/srcpkgs/waifu2x-converter-cpp/template
+++ b/srcpkgs/waifu2x-converter-cpp/template
@@ -1,7 +1,7 @@
 # Template file for 'waifu2x-converter-cpp'
 pkgname=waifu2x-converter-cpp
 version=5.2.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DINSTALL_MODELS=ON"
 hostmakedepends="pkg-config"

From 87300e7d4c4be3eb5468c86123dad5a16b28bb5b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:38 -0400
Subject: [PATCH 011/115] vlc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/vlc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vlc/template b/srcpkgs/vlc/template
index be579ce38fe37..3974289947401 100644
--- a/srcpkgs/vlc/template
+++ b/srcpkgs/vlc/template
@@ -25,7 +25,7 @@ lib32disabled=yes
 hostmakedepends="automake libtool pkg-config flex gettext libgcrypt-devel
  live555-devel gettext-devel $(vopt_if lua lua52) $(vopt_if chromecast protobuf)"
 makedepends="
- avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg-devel freefont-ttf
+ avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg4-devel freefont-ttf
  gnutls-devel jack-devel liba52-devel libass-devel libbluray-devel
  libcdio-devel libdca-devel libdvbpsi-devel libdvdnav-devel libmad-devel
  libmatroska-devel libmodplug-devel libmpcdec-devel libmpeg2-devel

From 660e31eb40c2d97a77b743a34bc81f6daebd283e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:55 -0400
Subject: [PATCH 012/115] osg: revbump for ffmpeg4-4.4.3

---
 srcpkgs/osg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/osg/template b/srcpkgs/osg/template
index a9ebbd287933b..755793f7e11bf 100644
--- a/srcpkgs/osg/template
+++ b/srcpkgs/osg/template
@@ -8,7 +8,7 @@ build_helper="qemu"
 configure_args="-DLIB_POSTFIX="
 hostmakedepends="pkg-config xrandr"
 makedepends="MesaLib-devel gtkglext-devel libcurl-devel giflib-devel librsvg-devel
- jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg-devel xine-lib-devel
+ jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg4-devel xine-lib-devel
  SDL2-devel gst-plugins-base1-devel
  $(vopt_if openexr libopenexr-devel)
  $(vopt_if poppler poppler-glib-devel)

From 8c1e4eae456d1a0ffc9c249f57da237669063aa2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:13 -0400
Subject: [PATCH 013/115] xine-lib: revbump for ffmpeg4-4.4.3

---
 srcpkgs/xine-lib/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/xine-lib/template b/srcpkgs/xine-lib/template
index f713eff49b07c..ed6194c17d11e 100644
--- a/srcpkgs/xine-lib/template
+++ b/srcpkgs/xine-lib/template
@@ -1,6 +1,6 @@
 # Template file for 'xine-lib'
 pkgname=xine-lib
-version=1.2.12
+version=1.2.13
 revision=1
 build_style=gnu-configure
 configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
@@ -8,7 +8,7 @@ configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
 hostmakedepends="automake gettext-devel libtool pkg-config perl"
 makedepends="
  zlib-devel alsa-lib-devel libxcb-devel libSM-devel libXext-devel libXv-devel
- libXvMC-devel liba52-devel libmad-devel ffmpeg-devel pulseaudio-devel
+ libXvMC-devel liba52-devel libmad-devel ffmpeg4-devel pulseaudio-devel
  jack-devel samba-devel libflac-devel libmodplug-devel libmpcdec-devel
  speex-devel libtheora-devel libvorbis-devel libdca-devel faad2-devel
  libcdio-devel libbluray-devel aalib-devel libcaca-devel libXinerama-devel
@@ -19,7 +19,7 @@ license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="http://www.xine-project.org"
 changelog="https://sourceforge.net/projects/xine/files/xine-lib/${version}/README.txt/view"
 distfiles="${SOURCEFORGE_SITE}/xine/${pkgname}-${version}.tar.xz"
-checksum=d606270468e1540c2a89c0d7f5fdf11e17ecc0c2698cc0bcb1065ff26abee098
+checksum=5f10d6d718a4a51c17ed1b32b031d4f9b80b061e8276535b2be31e5ac4b75e6f
 
 case "$XBPS_TARGET_MACHINE" in
 	i686-musl)

From caab744d220142b187e333753320a009d4f9e3ae Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 014/115] QMPlay2: revbump for ffmpeg-6.0

---
 srcpkgs/QMPlay2/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/QMPlay2/template b/srcpkgs/QMPlay2/template
index a63e271ef83b8..5ee04171b51e8 100644
--- a/srcpkgs/QMPlay2/template
+++ b/srcpkgs/QMPlay2/template
@@ -1,7 +1,7 @@
 # Template file for 'QMPlay2'
 pkgname=QMPlay2
 version=23.09.05
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools"
 makedepends="alsa-lib-devel ffmpeg-devel libass-devel libcdio-devel libgme-devel

From d718b662bfa37c8c4befd6a76fc1fd9f5fd23b75 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 015/115] alsa-plugins: revbump for ffmpeg-6.0

---
 srcpkgs/alsa-plugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/alsa-plugins/template b/srcpkgs/alsa-plugins/template
index 0bfa6d9fd2643..a5708a7d82a8f 100644
--- a/srcpkgs/alsa-plugins/template
+++ b/srcpkgs/alsa-plugins/template
@@ -1,7 +1,7 @@
 # Template file for 'alsa-plugins'
 pkgname=alsa-plugins
 version=1.2.7.1
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--disable-maemo-plugin"
 hostmakedepends="pkg-config"

From c3b9c60b3c69745acc077b4245fba86c599b8013 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 016/115] arcan: revbump for ffmpeg-6.0

---
 srcpkgs/arcan/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/arcan/template b/srcpkgs/arcan/template
index efd0afe10576d..b91e6900d42a1 100644
--- a/srcpkgs/arcan/template
+++ b/srcpkgs/arcan/template
@@ -2,7 +2,7 @@
 # !! keep synced with: acfgfs aclip aloadimage
 pkgname=arcan
 version=0.6.2.1
-revision=1
+revision=2
 create_wrksrc=yes
 build_wrksrc=arcan/src
 build_style=cmake

From 91505beaf9c1f000e0c73d718266dfd02f873be1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 017/115] attract: revbump for ffmpeg4-4.4.3

---
 srcpkgs/attract/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/attract/template b/srcpkgs/attract/template
index 26144e931a3c7..e760bf0d18aec 100644
--- a/srcpkgs/attract/template
+++ b/srcpkgs/attract/template
@@ -1,12 +1,12 @@
 # Template file for 'attract'
 pkgname=attract
 version=2.6.2
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="VERBOSE=1"
 make_use_env=yes
 hostmakedepends="pkg-config"
-makedepends="SFML-devel ffmpeg-devel fontconfig-devel glu-devel libarchive-devel
+makedepends="SFML-devel ffmpeg4-devel fontconfig-devel glu-devel libarchive-devel
  libcurl-devel libjpeg-turbo-devel xine-lib rapidjson libXrandr-devel"
 depends="git"
 short_desc="Attract-Mode is a graphical frontend for emulators"

From b3b622e55d8724157b2aea332e226fdcf7e8d55b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 018/115] aubio: revbump for ffmpeg-6.0

---
 srcpkgs/aubio/patches/ffmpeg5.patch | 25 +++++++++++++++++++++++++
 srcpkgs/aubio/template              |  2 +-
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/aubio/patches/ffmpeg5.patch

diff --git a/srcpkgs/aubio/patches/ffmpeg5.patch b/srcpkgs/aubio/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..aace41a6e6d9a
--- /dev/null
+++ b/srcpkgs/aubio/patches/ffmpeg5.patch
@@ -0,0 +1,25 @@
+From 8a05420e5dd8c7b8b2447f82dc919765876511b3 Mon Sep 17 00:00:00 2001
+From: Paul Brossier <piem@piem.org>
+Date: Tue, 25 Jan 2022 18:30:27 +0100
+Subject: [PATCH] [source_avcodec] define FF_API_LAVF_AVCTX for libavcodec >
+ 59, thx @berolinux (closes gh-353)
+
+---
+ src/io/source_avcodec.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/io/source_avcodec.c b/src/io/source_avcodec.c
+index e0ae93b5..1421bd9a 100644
+--- a/src/io/source_avcodec.c
++++ b/src/io/source_avcodec.c
+@@ -68,6 +68,10 @@
+ #define AUBIO_AVCODEC_MAX_BUFFER_SIZE AV_INPUT_BUFFER_MIN_SIZE
+ #endif
+ 
++#if LIBAVCODEC_VERSION_MAJOR >= 59
++#define FF_API_LAVF_AVCTX 1
++#endif
++
+ struct _aubio_source_avcodec_t {
+   uint_t hop_size;
+   uint_t samplerate;
diff --git a/srcpkgs/aubio/template b/srcpkgs/aubio/template
index ad1c4b2569917..7d875cc02541a 100644
--- a/srcpkgs/aubio/template
+++ b/srcpkgs/aubio/template
@@ -1,7 +1,7 @@
 # Template file for 'aubio'
 pkgname=aubio
 version=0.4.9
-revision=1
+revision=2
 build_style=waf3
 # XXX lash, pure and swig support.
 hostmakedepends="pkg-config txt2man"

From 38131cbbe30cdd9e8e025ceb1dc6e8ba01b7a0d9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 019/115] audacious-plugins: revbump for ffmpeg-6.0

---
 .../audacious-plugins/patches/ffmpeg5.patch   | 43 +++++++++++++++++++
 srcpkgs/audacious-plugins/template            |  2 +-
 2 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/audacious-plugins/patches/ffmpeg5.patch

diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg5.patch b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..4e5e34099d71c
--- /dev/null
+++ b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
@@ -0,0 +1,43 @@
+commit 298aa371c56c2f52c25a33d9bdec4918b11cebdc
+Author: tibequadorian <tibequadorian@posteo.de>
+Date:   Sat Mar 19 18:40:12 2022 +0100
+
+    audacious-plugins: rebuild against ffmpeg-5.0
+
+diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+new file mode 100644
+index 0000000000..617c11215b
+--- /dev/null
++++ b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+@@ -0,0 +1,31 @@
++From f60beb400eeb1e4778bbfd738bc4a4ccef3de539 Mon Sep 17 00:00:00 2001
++From: John Lindgren <john@jlindgren.net>
++Date: Sat, 5 Mar 2022 12:05:34 -0500
++Subject: [PATCH] Fix build with FFmpeg 5.0
++
++---
++ src/ffaudio/ffaudio-core.cc | 4 ++--
++ 1 file changed, 2 insertions(+), 2 deletions(-)
++
++diff --git a/src/ffaudio/ffaudio-core.cc b/src/ffaudio/ffaudio-core.cc
++index 16dc63e3a..a2b95fd6c 100644
++--- a/src/ffaudio/ffaudio-core.cc
+++++ b/src/ffaudio/ffaudio-core.cc
++@@ -274,7 +274,7 @@ static AVInputFormat * get_format_by_content (const char * name, VFSFile & file)
++         AVProbeData d = {name, buf, filled};
++         score = target;
++ 
++-        f = av_probe_input_format2 (& d, true, & score);
+++        f = (AVInputFormat *) av_probe_input_format2 (& d, true, & score);
++         if (f)
++             break;
++ 
++@@ -347,7 +347,7 @@ static bool find_codec (AVFormatContext * c, CodecInfo * cinfo)
++ #endif
++         if (stream && stream->codecpar && stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
++         {
++-            AVCodec * codec = avcodec_find_decoder (stream->codecpar->codec_id);
+++            AVCodec * codec = (AVCodec *) avcodec_find_decoder (stream->codecpar->codec_id);
++ 
++             if (codec)
++             {
diff --git a/srcpkgs/audacious-plugins/template b/srcpkgs/audacious-plugins/template
index 88cbc1671fc6a..beebfae59ed44 100644
--- a/srcpkgs/audacious-plugins/template
+++ b/srcpkgs/audacious-plugins/template
@@ -2,7 +2,7 @@
 #Keep in sync with audacious!
 pkgname=audacious-plugins
 version=4.3.1
-revision=1
+revision=2
 build_style=meson
 configure_args="$(vopt_bool gtk3 gtk) $(vopt_bool gtk3)
  $(vopt_bool qt) $(vopt_bool qt qt6)"

From 16fa6d09bee3865b9b4ea03b7715b7ba1d5763ac Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 020/115] audacity: revbump for ffmpeg4-4.4.3

---
 srcpkgs/audacity/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/audacity/template b/srcpkgs/audacity/template
index 73314e6232bd6..df26db1c15873 100644
--- a/srcpkgs/audacity/template
+++ b/srcpkgs/audacity/template
@@ -1,7 +1,7 @@
 # Template file for 'audacity'
 pkgname=audacity
 version=3.3.3
-revision=1
+revision=2
 build_style=cmake
 build_helper="cmake-wxWidgets-gtk3 qemu"
 configure_args="-Daudacity_use_ffmpeg=loaded -Daudacity_lib_preference=system
@@ -10,7 +10,7 @@ configure_args="-Daudacity_use_ffmpeg=loaded -Daudacity_lib_preference=system
  -Daudacity_has_vst3=no"
 hostmakedepends="pkg-config gettext python3"
 makedepends="wxWidgets-gtk3-devel gtk+3-devel expat-devel lame-devel
- libsoxr-devel portaudio-devel sqlite-devel libcurl-devel ffmpeg-devel
+ libsoxr-devel portaudio-devel sqlite-devel libcurl-devel ffmpeg4-devel
  libid3tag-devel libmad-devel vamp-plugin-sdk-devel libogg-devel
  libvorbis-devel libflac-devel lilv-devel lv2 serd-devel sord-devel
  sratom-devel suil-devel portmidi-devel soundtouch-devel twolame-devel

From ce998bb6f3f08d8dd8c43e5b1555c56e43218190 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 021/115] avidemux: revbump for ffmpeg-6.0

---
 srcpkgs/avidemux/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/avidemux/template b/srcpkgs/avidemux/template
index 253a0243e2259..557285982d2b8 100644
--- a/srcpkgs/avidemux/template
+++ b/srcpkgs/avidemux/template
@@ -1,7 +1,7 @@
 # Template file for 'avidemux'
 pkgname=avidemux
 version=2.8.0
-revision=2
+revision=3
 # Can't be compiled for aarch64, arm* or mips*
 archs="x86_64* i686*"
 hostmakedepends="cmake pkg-config qt5-host-tools qt5-devel tar yasm"

From 75ad5f359879a752012caa99f6a46c44f386e787 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 022/115] blender: revbump for ffmpeg-6.0

---
 srcpkgs/blender/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index fc6bd5fe25ce0..eea897d828a74 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -9,8 +9,8 @@ configure_args="-DWITH_INSTALL_PORTABLE=OFF -DWITH_PYTHON_INSTALL=OFF
  -DWITH_JACK=ON -DWITH_CODEC_FFMPEG=ON -DWITH_CODEC_SNDFILE=ON -DWITH_OPENMP=ON
  -DWITH_FFTW3=ON -DWITH_MOD_OCEANSIM=ON -DWITH_CYCLES_EMBREE=OFF -DWITH_OPENCOLORIO=ON
  -DWITH_IMAGE_OPENEXR=ON -DWITH_IMAGE_OPENJPEG=ON -DWITH_OPENSUBDIV=ON
- -DWITH_OPENCOLLADA=ON -DWITH_SYSTEM_GLEW=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
- -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_LIBDECOR=ON
+ -DWITH_OPENCOLLADA=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
+ -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_WAYLAND_LIBDECOR=ON
  -DWITH_BUILDINFO=OFF -DPYTHON_VERSION=${py3_ver} -DPYTHON_LIBPATH=/usr/lib
  -DPYTHON_LIBRARY=python${py3_ver}${py3_abiver} -DPYTHON_INCLUDE_DIRS=/${py3_inc}
  -DWITH_SYSTEM_LZO=ON -DWITH_SYSTEM_EIGEN3=ON -DWITH_SYSTEM_FREETYPE=ON"

From 7254f69d992cb0a3c1dd593f8a19b6407298af5b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 023/115] cantata: revbump for ffmpeg-6.0

---
 srcpkgs/cantata/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cantata/template b/srcpkgs/cantata/template
index 4b417d80d5c2d..8a90aaa4c07a2 100644
--- a/srcpkgs/cantata/template
+++ b/srcpkgs/cantata/template
@@ -1,7 +1,7 @@
 # Template file for 'cantata'
 pkgname=cantata
 version=2.5.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools qt5-tools"
 makedepends="qt5-devel qt5-tools-devel qt5-svg-devel qt5-xmlpatterns-devel

From 85cf437e4bb04a97eb0eafe47dba76272508997a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 024/115] ccextractor: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ccextractor/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/ccextractor/template b/srcpkgs/ccextractor/template
index 9abcd82852b27..6eccad5885af9 100644
--- a/srcpkgs/ccextractor/template
+++ b/srcpkgs/ccextractor/template
@@ -1,12 +1,12 @@
 # Template file for 'ccextractor'
 pkgname=ccextractor
 version=0.93
-revision=1
+revision=2
 build_wrksrc="linux"
 build_style=gnu-configure
 configure_args="--enable-ocr --enable-hardsubx"
 hostmakedepends="automake pkg-config"
-makedepends="leptonica-devel tesseract-ocr-devel ffmpeg-devel"
+makedepends="leptonica-devel tesseract-ocr-devel ffmpeg4-devel"
 short_desc="Extract subtitles from video streams"
 maintainer="newbluemoon <blaumolch@mailbox.org>"
 license="GPL-2.0-or-later"

From b6ebe1d35cdf91cf63af6c17ae8fd6a44451f67f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 025/115] chromaprint: revbump for ffmpeg-6.0

---
 srcpkgs/chromaprint/patches/ffmpeg5.patch | 569 ++++++++++++++++++++++
 srcpkgs/chromaprint/template              |   2 +-
 2 files changed, 570 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromaprint/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromaprint/patches/ffmpeg5.patch b/srcpkgs/chromaprint/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..a9fd307a23c8a
--- /dev/null
+++ b/srcpkgs/chromaprint/patches/ffmpeg5.patch
@@ -0,0 +1,569 @@
+From 8ccad6937177b1b92e40ab8f4447ea27bac009a7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= <lalinsky@gmail.com>
+Date: Fri, 4 Nov 2022 21:47:38 +0100
+Subject: [PATCH] Use FFmpeg 5.x (#120)
+
+* Use FFmpeg 5.1.2 for CI builds
+
+* Build on Ubuntu 20.04
+
+* Upgrade code to FFmpeg 5.x APIs
+
+* Only set FFmpeg include dirs if building tools
+
+* No longer needed
+
+* Use ubuntu 20.04
+---
+ .github/workflows/build.yml                   |   6 +-
+ CMakeLists.txt                                |  16 --
+ package/build.sh                              |   4 +-
+ src/audio/ffmpeg_audio_processor.h            |   2 -
+ src/audio/ffmpeg_audio_processor_avresample.h |  72 -------
+ src/audio/ffmpeg_audio_processor_swresample.h |  18 +-
+ src/audio/ffmpeg_audio_reader.h               | 197 +++++++++---------
+ tests/CMakeLists.txt                          |   6 +
+ 8 files changed, 122 insertions(+), 199 deletions(-)
+ delete mode 100644 src/audio/ffmpeg_audio_processor_avresample.h
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index f8d6a32..4da2405 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -84,9 +84,6 @@ find_package(FFmpeg)
+ if(FFMPEG_LIBRARIES)
+ 	cmake_push_check_state(RESET)
+ 	set(CMAKE_REQUIRED_LIBRARIES ${FFMPEG_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -lm)
+-	check_function_exists(av_packet_unref HAVE_AV_PACKET_UNREF)
+-	check_function_exists(av_frame_alloc HAVE_AV_FRAME_ALLOC)
+-	check_function_exists(av_frame_free HAVE_AV_FRAME_FREE)
+ 	cmake_pop_check_state()
+ endif()
+
+@@ -163,14 +160,11 @@ message(STATUS "Using ${FFT_LIB} for FFT calculations")
+ if(NOT AUDIO_PROCESSOR_LIB)
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+ 		set(AUDIO_PROCESSOR_LIB "swresample")
+-	elseif(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(AUDIO_PROCESSOR_LIB "avresample")
+ 	endif()
+ endif()
+
+ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE OFF)
+ 		set(USE_SWRESAMPLE ON)
+ 		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBSWRESAMPLE_LIBRARIES})
+ 		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBSWRESAMPLE_INCLUDE_DIRS})
+@@ -178,16 +172,6 @@ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+ 	endif()
+ 	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+-elseif(AUDIO_PROCESSOR_LIB STREQUAL "avresample")
+-	if(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE ON)
+-		set(USE_SWRESAMPLE OFF)
+-		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBAVRESAMPLE_LIBRARIES})
+-		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBAVRESAMPLE_INCLUDE_DIRS})
+-	else()
+-		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+-	endif()
+-	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+ else()
+ 	message(STATUS "Building without audio conversion support, please install FFmpeg with libswresample")
+ endif()
+diff --git a/package/build.sh b/package/build.sh
+index da631ae..b41d36e 100755
+--- a/package/build.sh
++++ b/package/build.sh
+@@ -7,8 +7,8 @@ set -eux
+
+ BASE_DIR=$(cd $(dirname $0)/.. && pwd)
+
+-FFMPEG_VERSION=4.4.1
+-FFMPEG_BUILD_TAG=v4.4.1-1
++FFMPEG_VERSION=5.1.2
++FFMPEG_BUILD_TAG=v${FFMPEG_VERSION}-1
+
+ TMP_BUILD_DIR=$BASE_DIR/$(mktemp -d build.XXXXXXXX)
+ trap 'rm -rf $TMP_BUILD_DIR' EXIT
+diff --git a/src/audio/ffmpeg_audio_processor.h b/src/audio/ffmpeg_audio_processor.h
+index 7628fc7..39f4f6d 100644
+--- a/src/audio/ffmpeg_audio_processor.h
++++ b/src/audio/ffmpeg_audio_processor.h
+@@ -10,8 +10,6 @@
+
+ #if defined(USE_SWRESAMPLE)
+ #include "audio/ffmpeg_audio_processor_swresample.h"
+-#elif defined(USE_AVRESAMPLE)
+-#include "audio/ffmpeg_audio_processor_avresample.h"
+ #else
+ #error "no audio processing library"
+ #endif
+diff --git a/src/audio/ffmpeg_audio_processor_avresample.h b/src/audio/ffmpeg_audio_processor_avresample.h
+deleted file mode 100644
+index bd85f92..0000000
+--- a/src/audio/ffmpeg_audio_processor_avresample.h
++++ /dev/null
+@@ -1,72 +0,0 @@
+-// Copyright (C) 2016  Lukas Lalinsky
+-// Distributed under the MIT license, see the LICENSE file for details.
+-
+-#ifndef CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-#define CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-
+-extern "C" {
+-#include <libavresample/avresample.h>
+-}
+-
+-namespace chromaprint {
+-
+-class FFmpegAudioProcessor {
+-public:
+-	FFmpegAudioProcessor() {
+-		m_resample_ctx = avresample_alloc_context();
+-	}
+-
+-	~FFmpegAudioProcessor() {
+-		avresample_free(&m_resample_ctx);
+-	}
+-
+-	void SetCompatibleMode() {
+-		av_opt_set_int(m_resample_ctx, "filter_size", 16, 0);
+-		av_opt_set_int(m_resample_ctx, "phase_shift", 8, 0);
+-		av_opt_set_int(m_resample_ctx, "linear_interp", 1, 0);
+-		av_opt_set_double(m_resample_ctx, "cutoff", 0.8, 0);
+-	}
+-
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "in_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_rate", sample_rate, 0);
+-	}
+-
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "out_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_rate, 0);
+-	}
+-
+-	int Init() {
+-		return avresample_open(m_resample_ctx);
+-	}
+-
+-	int Convert(uint8_t **out, int out_count, const uint8_t **in, int in_count) {
+-		return avresample_convert(m_resample_ctx, out, 0, out_count, (uint8_t **) in, 0, in_count);
+-	}
+-
+-	int Flush(uint8_t **out, int out_count) {
+-		return avresample_read(m_resample_ctx, out, out_count);
+-	}
+-
+-private:
+-	AVAudioResampleContext *m_resample_ctx = nullptr;
+-};
+-
+-}; // namespace chromaprint
+-
+-#endif
+diff --git a/src/audio/ffmpeg_audio_processor_swresample.h b/src/audio/ffmpeg_audio_processor_swresample.h
+index b86266b..b1d4bea 100644
+--- a/src/audio/ffmpeg_audio_processor_swresample.h
++++ b/src/audio/ffmpeg_audio_processor_swresample.h
+@@ -28,30 +28,28 @@ public:
+ 		av_opt_set_double(m_swr_ctx, "cutoff", 0.8, 0);
+ 	}
+
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "icl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "ich", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetInputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "in_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "isf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "in_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "isr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "in_sample_rate", sample_rate, 0);
+ 	}
+
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "ocl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "och", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetOutputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "out_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "osf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "out_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "osr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "out_sample_rate", sample_rate, 0);
+ 	}
+
+ 	int Init() {
+diff --git a/src/audio/ffmpeg_audio_reader.h b/src/audio/ffmpeg_audio_reader.h
+index 5550164..1c6b346 100644
+--- a/src/audio/ffmpeg_audio_reader.h
++++ b/src/audio/ffmpeg_audio_reader.h
+@@ -62,7 +62,7 @@ public:
+ 	bool Read(const int16_t **data, size_t *size);
+
+ 	bool IsOpen() const { return m_opened; }
+-	bool IsFinished() const { return m_finished && !m_got_frame; }
++	bool IsFinished() const { return !m_has_more_packets && !m_has_more_frames; }
+
+ 	std::string GetError() const { return m_error; }
+ 	int GetErrorCode() const { return m_error_code; }
+@@ -74,20 +74,19 @@ private:
+ 	uint8_t *m_convert_buffer[1] = { nullptr };
+ 	int m_convert_buffer_nb_samples = 0;
+
+-	AVInputFormat *m_input_fmt = nullptr;
++	const AVInputFormat *m_input_fmt = nullptr;
+ 	AVDictionary *m_input_opts = nullptr;
+
+ 	AVFormatContext *m_format_ctx = nullptr;
+ 	AVCodecContext *m_codec_ctx = nullptr;
+-	AVFrame *m_frame = nullptr;
+ 	int m_stream_index = -1;
+ 	std::string m_error;
+ 	int m_error_code = 0;
+-	bool m_finished = false;
+ 	bool m_opened = false;
+-	int m_got_frame = 0;
+-	AVPacket m_packet;
+-	AVPacket m_packet0;
++	bool m_has_more_packets = true;
++	bool m_has_more_frames = true;
++	AVPacket *m_packet = nullptr;
++	AVFrame *m_frame = nullptr;
+
+ 	int m_output_sample_rate = 0;
+ 	int m_output_channels = 0;
+@@ -98,19 +97,12 @@ private:
+
+ inline FFmpegAudioReader::FFmpegAudioReader() {
+ 	av_log_set_level(AV_LOG_QUIET);
+-
+-	av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
+ }
+
+ inline FFmpegAudioReader::~FFmpegAudioReader() {
+ 	Close();
+ 	av_dict_free(&m_input_opts);
+ 	av_freep(&m_convert_buffer[0]);
+-	av_packet_unref(&m_packet0);
+ }
+
+ inline bool FFmpegAudioReader::SetInputFormat(const char *name) {
+@@ -135,11 +127,10 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ 	Close();
+
+-    av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
++	m_packet = av_packet_alloc();
++	if (!m_packet) {
++		return false;
++	}
+
+ 	ret = avformat_open_input(&m_format_ctx, file_name.c_str(), m_input_fmt, &m_input_opts);
+ 	if (ret < 0) {
+@@ -153,26 +144,31 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		return false;
+ 	}
+
+-	AVCodec *codec;
++	const AVCodec *codec;
+ 	ret = av_find_best_stream(m_format_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &codec, 0);
+ 	if (ret < 0) {
+ 		SetError("Could not find any audio stream in the file", ret);
+ 		return false;
+ 	}
+ 	m_stream_index = ret;
++	auto stream = m_format_ctx->streams[m_stream_index];
+
+-	m_codec_ctx = m_format_ctx->streams[m_stream_index]->codec;
++	m_codec_ctx = avcodec_alloc_context3(codec);
+ 	m_codec_ctx->request_sample_fmt = AV_SAMPLE_FMT_S16;
+
++	ret = avcodec_parameters_to_context(m_codec_ctx, stream->codecpar);
++	if (ret < 0) {
++		SetError("Could not copy the stream parameters", ret);
++		return false;
++	}
++
+ 	ret = avcodec_open2(m_codec_ctx, codec, nullptr);
+ 	if (ret < 0) {
+ 		SetError("Could not open the codec", ret);
+ 		return false;
+ 	}
+
+-	if (!m_codec_ctx->channel_layout) {
+-		m_codec_ctx->channel_layout = av_get_default_channel_layout(m_codec_ctx->channels);
+-	}
++	av_dump_format(m_format_ctx, 0, "foo", 0);
+
+ 	m_frame = av_frame_alloc();
+ 	if (!m_frame) {
+@@ -183,19 +179,23 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		m_output_sample_rate = m_codec_ctx->sample_rate;
+ 	}
+
+-	if (!m_output_channels) {
+-		m_output_channels = m_codec_ctx->channels;
++	AVChannelLayout output_channel_layout;
++	if (m_output_channels) {
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
++	} else {
++		m_output_channels = m_codec_ctx->ch_layout.nb_channels;
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
+ 	}
+
+-	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
++	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->ch_layout.nb_channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
+ 		m_converter.reset(new FFmpegAudioProcessor());
+ 		m_converter->SetCompatibleMode();
+ 		m_converter->SetInputSampleFormat(m_codec_ctx->sample_fmt);
+ 		m_converter->SetInputSampleRate(m_codec_ctx->sample_rate);
+-		m_converter->SetInputChannelLayout(m_codec_ctx->channel_layout);
++		m_converter->SetInputChannelLayout(&(m_codec_ctx->ch_layout));
+ 		m_converter->SetOutputSampleFormat(AV_SAMPLE_FMT_S16);
+ 		m_converter->SetOutputSampleRate(m_output_sample_rate);
+-		m_converter->SetOutputChannelLayout(av_get_default_channel_layout(m_output_channels));
++		m_converter->SetOutputChannelLayout(&output_channel_layout);
+ 		auto ret = m_converter->Init();
+ 		if (ret != 0) {
+ 			SetError("Could not create an audio converter instance", ret);
+@@ -203,10 +203,11 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		}
+ 	}
+
++	av_channel_layout_uninit(&output_channel_layout);
++
+ 	m_opened = true;
+-	m_finished = false;
+-	m_got_frame = 0;
+-	m_nb_packets = 0;
++	m_has_more_packets = true;
++	m_has_more_frames = true;
+ 	m_decode_error = 0;
+
+ 	return true;
+@@ -214,6 +215,7 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ inline void FFmpegAudioReader::Close() {
+ 	av_frame_free(&m_frame);
++	av_packet_free(&m_packet);
+
+ 	m_stream_index = -1;
+
+@@ -252,91 +254,98 @@ inline bool FFmpegAudioReader::Read(const int16_t **data, size_t *size) {
+ 		return false;
+ 	}
+
++	*data = nullptr;
++	*size = 0;
++
+ 	int ret;
++	bool needs_packet = false;
+ 	while (true) {
+-		while (m_packet.size <= 0) {
+-			av_packet_unref(&m_packet0);
+-			av_init_packet(&m_packet);
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			ret = av_read_frame(m_format_ctx, &m_packet);
++		while (needs_packet && m_packet->size == 0) {
++			ret = av_read_frame(m_format_ctx, m_packet);
+ 			if (ret < 0) {
+ 				if (ret == AVERROR_EOF) {
+-					m_finished = true;
++					needs_packet = false;
++					m_has_more_packets = false;
+ 					break;
+-				} else {
++				}
++				SetError("Error reading from the audio source", ret);
++				return false;
++			}
++			if (m_packet->stream_index == m_stream_index) {
++				needs_packet = false;
++			} else {
++				av_packet_unref(m_packet);
++			}
++		}
++
++		if (m_packet->size != 0) {
++			ret = avcodec_send_packet(m_codec_ctx, m_packet);
++			if (ret < 0) {
++				if (ret != AVERROR(EAGAIN)) {
+ 					SetError("Error reading from the audio source", ret);
+ 					return false;
+ 				}
+-			}
+-			m_packet0 = m_packet;
+-			if (m_packet.stream_index != m_stream_index) {
+-				m_packet.data = nullptr;
+-				m_packet.size = 0;
+ 			} else {
+-				m_nb_packets++;
++				av_packet_unref(m_packet);
+ 			}
+ 		}
+
+-		ret = avcodec_decode_audio4(m_codec_ctx, m_frame, &m_got_frame, &m_packet);
++		ret = avcodec_receive_frame(m_codec_ctx, m_frame);
+ 		if (ret < 0) {
+-			if (m_decode_error) {
+-				SetError("Error decoding audio frame", m_decode_error);
+-				return false;
++			if (ret == AVERROR_EOF) {
++				m_has_more_frames = false;
++			} else if (ret == AVERROR(EAGAIN)) {
++				if (m_has_more_packets) {
++					needs_packet = true;
++					continue;
++				} else {
++					m_has_more_frames = false;
++				}
+ 			}
+-			m_decode_error = ret;
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			continue;
++			SetError("Error decoding the audio source", ret);
++			return false;
+ 		}
+
+-		break;
+-	}
+-
+-	m_decode_error = 0;
+-
+-	const int decoded = std::min(ret, m_packet.size);
+-	m_packet.data += decoded;
+-	m_packet.size -= decoded;
+-
+-	if (m_got_frame) {
+-		if (m_converter) {
+-			if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
+-				int linsize;
+-				av_freep(&m_convert_buffer[0]);
+-				m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
+-				ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
+-				if (ret < 0) {
+-					SetError("Couldn't allocate audio converter buffer", ret);
++		if (m_frame->nb_samples > 0) {
++			if (m_converter) {
++				if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
++					int linsize;
++					av_freep(&m_convert_buffer[0]);
++					m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
++					ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->ch_layout.nb_channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
++					if (ret < 0) {
++						SetError("Couldn't allocate audio converter buffer", ret);
++						return false;
++					}
++				}
++				auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
++				if (nb_samples < 0) {
++					SetError("Couldn't convert audio", ret);
+ 					return false;
+ 				}
+-			}
+-			auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			}
+-			*data = (const int16_t *) m_convert_buffer[0];
+-			*size = nb_samples;
+-		} else {
+-			*data = (const int16_t *) m_frame->data[0];
+-			*size = m_frame->nb_samples;
+-		}
+-	} else {
+-		if (m_finished && m_converter) {
+-			auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			} else if (nb_samples > 0) {
+-				m_got_frame = 1;
+ 				*data = (const int16_t *) m_convert_buffer[0];
+ 				*size = nb_samples;
++			} else {
++				*data = (const int16_t *) m_frame->data[0];
++				*size = m_frame->nb_samples;
++			}
++		} else {
++			if (m_converter) {
++				if (IsFinished()) {
++					auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
++					if (nb_samples < 0) {
++						SetError("Couldn't convert audio", ret);
++						return false;
++					} else if (nb_samples > 0) {
++						*data = (const int16_t *) m_convert_buffer[0];
++						*size = nb_samples;
++					}
++				}
+ 			}
+ 		}
+-	}
+
+-	return true;
++		return true;
++	}
+ }
+
+ inline void FFmpegAudioReader::SetError(const char *message, int errnum) {
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index a2b517b..123e643 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -38,6 +38,12 @@ set(SRCS
+
+ if(BUILD_TOOLS)
+ 	set(SRCS ${SRCS} ../src/audio/ffmpeg_audio_reader_test.cpp)
++    include_directories(
++        ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}
++        ${AUDIO_PROCESSOR_INCLUDE_DIRS}
++    )
+ 	link_libraries(fpcalc_libs)
+ endif()
+
+-- 
+2.38.1
+
+
diff --git a/srcpkgs/chromaprint/template b/srcpkgs/chromaprint/template
index 7ef7838949f3a..1f7bbc70a22c8 100644
--- a/srcpkgs/chromaprint/template
+++ b/srcpkgs/chromaprint/template
@@ -1,7 +1,7 @@
 # Template file for 'chromaprint'
 pkgname=chromaprint
 version=1.5.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DBUILD_TOOLS=ON"
 make_check_target="check"

From 0cc399cf9c7d10c2072dcb21ef3131d344d129c5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 026/115] chromium: revbump for ffmpeg-6.0

---
 .../patches/chromium-118-ffmpeg-4.4.patch     | 22 ---------
 srcpkgs/chromium/patches/ffmpeg5.patch        | 47 +++++++++++++++++++
 srcpkgs/chromium/template                     |  2 +-
 3 files changed, 48 insertions(+), 23 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/chromium-118-ffmpeg-4.4.patch
 create mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromium/patches/chromium-118-ffmpeg-4.4.patch b/srcpkgs/chromium/patches/chromium-118-ffmpeg-4.4.patch
deleted file mode 100644
index 556c734d4e02e..0000000000000
--- a/srcpkgs/chromium/patches/chromium-118-ffmpeg-4.4.patch
+++ /dev/null
@@ -1,22 +0,0 @@
-diff --git a/media/filters/ffmpeg_demuxer.cc b/media/filters/ffmpeg_demuxer.cc
-index ac4713b07268..492a9a37d096 100644
---- a/media/filters/ffmpeg_demuxer.cc
-+++ b/media/filters/ffmpeg_demuxer.cc
-@@ -443,7 +443,7 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
-     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
-                                      side_data.data(), side_data.size());
-   } else {
--    size_t side_data_size = 0;
-+    int side_data_size = 0;
-     uint8_t* side_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
- 
-@@ -504,7 +504,7 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
-                                        packet->size - data_offset);
-     }
- 
--    size_t skip_samples_size = 0;
-+    int skip_samples_size = 0;
-     const uint32_t* skip_samples_ptr =
-         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
-             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..24e2da38e34ca
--- /dev/null
+++ b/srcpkgs/chromium/patches/ffmpeg5.patch
@@ -0,0 +1,47 @@
+--- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
++++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
+@@ -92,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+-  if (stream->start_time != kNoFFmpegTimestamp)
++  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -1597,7 +1585,7 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+@@ -1618,7 +1606,7 @@
+     if (stream->type() != DemuxerStream::VIDEO)
+       continue;
+ 
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+ 
+     if (!stream->IsEnabled())
diff --git a/srcpkgs/chromium/template b/srcpkgs/chromium/template
index cc36911cd338d..c63eb330d1da8 100644
--- a/srcpkgs/chromium/template
+++ b/srcpkgs/chromium/template
@@ -2,7 +2,7 @@
 pkgname=chromium
 # See https://chromiumdash.appspot.com/releases?platform=Linux for the latest version
 version=118.0.5993.70
-revision=1
+revision=2
 archs="i686* x86_64* aarch64* armv7l*"
 hostmakedepends="
  $(vopt_if clang "clang lld llvm15")

From fcf5777fbdd19b6d4b59ffb6c93f94170d04699a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 027/115] cmus: revbump for ffmpeg-6.0

---
 srcpkgs/cmus/patches/ffmpeg6.patch | 12 ++++++++++++
 srcpkgs/cmus/template              |  2 +-
 2 files changed, 13 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/cmus/patches/ffmpeg6.patch

diff --git a/srcpkgs/cmus/patches/ffmpeg6.patch b/srcpkgs/cmus/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..ffa95ab811101
--- /dev/null
+++ b/srcpkgs/cmus/patches/ffmpeg6.patch
@@ -0,0 +1,12 @@
+--- a/ip/ffmpeg.c
++++ b/ip/ffmpeg.c
+@@ -202,9 +202,6 @@ static int ffmpeg_open(struct input_plugin_data *ip_data)
+ 			break;
+ 		}
+ 
+-		if (codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+-			cc->flags |= AV_CODEC_FLAG_TRUNCATED;
+-
+ 		if (avcodec_open2(cc, codec, NULL) < 0) {
+ 			d_print("could not open codec: %d, %s\n", cc->codec_id, avcodec_get_name(cc->codec_id));
+ 			err = -IP_ERROR_UNSUPPORTED_FILE_TYPE;
diff --git a/srcpkgs/cmus/template b/srcpkgs/cmus/template
index dc8a5e5d434cd..f664076170960 100644
--- a/srcpkgs/cmus/template
+++ b/srcpkgs/cmus/template
@@ -1,7 +1,7 @@
 # Template file for 'cmus'
 pkgname=cmus
 version=2.10.0
-revision=1
+revision=2
 build_style=configure
 configure_args="prefix=/usr LD=$CC"
 hostmakedepends="pkg-config"

From 2e856fc70a555867f00de489106c799a05ab28dc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 028/115] cyanrip: revbump for ffmpeg-6.0

---
 srcpkgs/cyanrip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cyanrip/template b/srcpkgs/cyanrip/template
index 9796e3461601a..5db30e020d17e 100644
--- a/srcpkgs/cyanrip/template
+++ b/srcpkgs/cyanrip/template
@@ -1,7 +1,7 @@
 # Template file for 'cyanrip'
 pkgname=cyanrip
 version=0.9.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config"
 makedepends="ffmpeg-devel libcdio-devel libcdio-paranoia-devel libcurl-devel libmusicbrainz5-devel"

From 146c11b9e5d0800f8dafcebdd1f67767d3d415ec Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 029/115] deadbeef: revbump for ffmpeg4-4.4.3

---
 srcpkgs/deadbeef/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/deadbeef/template b/srcpkgs/deadbeef/template
index b664bb1b9bd9f..165b3c7b9cad8 100644
--- a/srcpkgs/deadbeef/template
+++ b/srcpkgs/deadbeef/template
@@ -1,14 +1,14 @@
 # Template file for 'deadbeef'
 pkgname=deadbeef
 version=1.8.8
-revision=1
+revision=2
 create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-oss --disable-lfm --disable-notify --disable-gtk2"
 hostmakedepends="automake libtool gettext gettext-devel intltool pkg-config
  yasm clang glib-devel"
 makedepends="
- alsa-lib-devel dbus-devel faad2-devel ffmpeg-devel gtk+3-devel imlib2-devel
+ alsa-lib-devel dbus-devel faad2-devel ffmpeg4-devel gtk+3-devel imlib2-devel
  jansson-devel libcddb-devel libcdio-devel libcurl-devel libflac-devel
  libmad-devel libpng-devel libsamplerate-devel libsndfile-devel libvorbis-devel
  libzip-devel mpg123-devel opusfile-devel pulseaudio-devel wavpack-devel"

From 442c0b5441e6787059ea76477f55c7812e86ba00 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 030/115] dolphin-emu: revbump for ffmpeg-6.0

---
 srcpkgs/dolphin-emu/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/dolphin-emu/template b/srcpkgs/dolphin-emu/template
index b4c8b64368a4b..070993aac31d2 100644
--- a/srcpkgs/dolphin-emu/template
+++ b/srcpkgs/dolphin-emu/template
@@ -1,7 +1,7 @@
 # Template file for 'dolphin-emu'
 pkgname=dolphin-emu
 version=5.0.19368
-revision=1
+revision=2
 _dolphin_commit=dadbeb4bae7e7fa23af2b46e0add4143094dc107
 _mgba_commit=44e074a15e9651481f7f652ac006a7c9d58cbeb9
 _googletest_commit=be03d00f5f0cc3a997d1a368bee8a1fe93651f48

From b7c2d2f5fbe24b79dc701b3d8d0e17b2f05120a0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 031/115] droidcam-obs-plugin: revbump for ffmpeg-6.0

---
 srcpkgs/droidcam-obs-plugin/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam-obs-plugin/template b/srcpkgs/droidcam-obs-plugin/template
index fc9c9bf6b9d54..fb0480754df4d 100644
--- a/srcpkgs/droidcam-obs-plugin/template
+++ b/srcpkgs/droidcam-obs-plugin/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam-obs-plugin'
 pkgname=droidcam-obs-plugin
 version=2.0.1
-revision=1
+revision=2
 build_style=gnu-makefile
 make_use_env=yes
 make_build_args="ALLOW_STATIC=no"

From 116d3ae7ef1d551dae6d21c4b82c1cc56a512f30 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 032/115] droidcam: revbump for ffmpeg-6.0

---
 srcpkgs/droidcam/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam/template b/srcpkgs/droidcam/template
index 1c3f1b8b1fc67..32a9220b79a4d 100644
--- a/srcpkgs/droidcam/template
+++ b/srcpkgs/droidcam/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam'
 pkgname=droidcam
 version=1.8.2
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="USBMUXD=-lusbmuxd-2.0 JPEG=-lturbojpeg"
 hostmakedepends="pkg-config"

From ef4bedf70c5f64ae02a0d161be69cf5e576b56e7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 033/115] ffmpegthumbnailer: revbump for ffmpeg-6.0

---
 .../ffmpegthumbnailer/patches/ffmpeg6.patch   | 202 ++++++++++++++++++
 srcpkgs/ffmpegthumbnailer/template            |   6 +-
 2 files changed, 205 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch

diff --git a/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..363ff35a28419
--- /dev/null
+++ b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
@@ -0,0 +1,202 @@
+--- a/libffmpegthumbnailer/moviedecoder.cpp	2017-11-21 14:06:57.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.cpp	2023-05-05 13:14:47.946560668 -0400
+@@ -41,11 +41,6 @@
+ namespace ffmpegthumbnailer
+ {
+ 
+-struct SilenceLogLevel
+-{
+-    SilenceLogLevel() { av_log_set_level(AV_LOG_QUIET); }
+-};
+-
+ MovieDecoder::MovieDecoder(AVFormatContext* pavContext)
+ : m_VideoStream(-1)
+ , m_pFormatContext(pavContext)
+@@ -70,8 +65,6 @@
+ 
+ void MovieDecoder::initialize(const string& filename, bool preferEmbeddedMetadata)
+ {
+-    av_register_all();
+-    avcodec_register_all();
+     avformat_network_init();
+ 
+     string inputFile = filename == "-" ? "pipe:" : filename;
+@@ -97,8 +90,7 @@
+ {
+     if (m_pVideoCodecContext)
+     {
+-        avcodec_close(m_pVideoCodecContext);
+-        m_pVideoCodecContext = nullptr;
++        avcodec_free_context(&m_pVideoCodecContext);
+     }
+ 
+     if ((!m_FormatContextWasGiven) && m_pFormatContext)
+@@ -152,10 +144,10 @@
+     for (unsigned int i = 0; i < m_pFormatContext->nb_streams; ++i)
+     {
+         AVStream *stream = m_pFormatContext->streams[i];
+-        auto ctx = m_pFormatContext->streams[i]->codec;
+-        if (ctx->codec_type == AVMEDIA_TYPE_VIDEO)
++        auto par = m_pFormatContext->streams[i]->codecpar;
++        if (par->codec_type == AVMEDIA_TYPE_VIDEO)
+         {
+-            if (!preferEmbeddedMetadata || !isStillImageCodec(ctx->codec_id))
++            if (!preferEmbeddedMetadata || !isStillImageCodec(par->codec_id))
+             {
+                 videoStreams.push_back(i);
+                 continue;
+@@ -203,8 +195,7 @@
+     }
+ 
+     m_pVideoStream = m_pFormatContext->streams[m_VideoStream];
+-    m_pVideoCodecContext = m_pVideoStream->codec;
+-    m_pVideoCodec = avcodec_find_decoder(m_pVideoCodecContext->codec_id);
++    m_pVideoCodec = avcodec_find_decoder(m_pVideoStream->codecpar->codec_id);
+ 
+     if (m_pVideoCodec == nullptr)
+     {
+@@ -214,6 +205,20 @@
+         throw logic_error("Video Codec not found");
+     }
+ 
++    m_pVideoCodecContext = avcodec_alloc_context3(m_pVideoCodec);
++
++    if (m_pVideoCodecContext == nullptr)
++    {
++        destroy();
++        throw logic_error("Could not allocate video codec context");
++    }
++
++    if (avcodec_parameters_to_context(m_pVideoCodecContext, m_pVideoStream->codecpar) < 0)
++    {
++        destroy();
++        throw logic_error("Could not configure video codec context");
++    }
++
+     m_pVideoCodecContext->workaround_bugs = 1;
+ 
+     if (avcodec_open2(m_pVideoCodecContext, m_pVideoCodec, nullptr) < 0)
+@@ -386,13 +391,6 @@
+ 
+ void MovieDecoder::initializeFilterGraph(const AVRational& timeBase, const std::string& size, bool maintainAspectRatio)
+ {
+-    static const AVPixelFormat pixelFormats[] = { AV_PIX_FMT_RGB24, AV_PIX_FMT_NONE };
+-
+-    auto del = [] (AVBufferSinkParams* p) { av_freep(p); };
+-    std::unique_ptr<AVBufferSinkParams, decltype(del)> buffersinkParams(av_buffersink_params_alloc(), del);
+-
+-    avfilter_register_all();
+-
+     m_pFilterGraph = avfilter_graph_alloc();
+     assert(m_pFilterGraph);
+ 
+@@ -404,10 +402,8 @@
+ 
+     checkRc(avfilter_graph_create_filter(&m_pFilterSource, avfilter_get_by_name("buffer"), "thumb_buffer", ss.str().c_str(), nullptr, m_pFilterGraph),
+             "Failed to create filter source");
+-    buffersinkParams->pixel_fmts = pixelFormats;
+-    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, buffersinkParams.get(), m_pFilterGraph),
++    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, nullptr, m_pFilterGraph),
+             "Failed to create filter sink");
+-    buffersinkParams.release();
+ 
+     AVFilterContext* yadifFilter = nullptr;
+     if (m_pFrame->interlaced_frame != 0)
+@@ -500,15 +496,15 @@
+     }
+ 
+     checkRc(av_seek_frame(m_pFormatContext, -1, timestamp, 0), "Seeking in video failed");
+-    avcodec_flush_buffers(m_pFormatContext->streams[m_VideoStream]->codec);
++    avcodec_flush_buffers(m_pVideoCodecContext);
+ 
+     int keyFrameAttempts = 0;
+-    bool gotFrame = 0;
++    bool gotFrame;
+ 
+     do
+     {
+         int count = 0;
+-        gotFrame = 0;
++        gotFrame = false;
+ 
+         while (!gotFrame && count < 20)
+         {
+@@ -552,17 +548,33 @@
+         return false;
+     }
+ 
+-    av_frame_unref(m_pFrame);
+-
+-    int frameFinished;
++    int rc = avcodec_send_packet(m_pVideoCodecContext, m_pPacket);
++    if(rc == AVERROR(EAGAIN))
++    {
++        rc = 0;
++    }
+ 
+-    int bytesDecoded = avcodec_decode_video2(m_pVideoCodecContext, m_pFrame, &frameFinished, m_pPacket);
+-    if (bytesDecoded < 0)
++    if(rc == AVERROR_EOF)
++    {
++        return false;
++    }
++    else if(rc < 0)
+     {
+-        throw logic_error("Failed to decode video frame: bytesDecoded < 0");
++        throw logic_error("Failed to decode video frame: avcodec_send_packet() < 0");
+     }
+ 
+-    return frameFinished > 0;
++    rc = avcodec_receive_frame(m_pVideoCodecContext, m_pFrame);
++    switch(rc)
++    {
++        case 0:
++            return true;
++
++        case AVERROR(EAGAIN):
++            return false;
++
++        default:
++            throw logic_error("Failed to decode video frame: avcodec_receive_frame() < 0");
++    }
+ }
+ 
+ bool MovieDecoder::getVideoPacket()
+@@ -570,8 +582,6 @@
+     bool framesAvailable = true;
+     bool frameDecoded = false;
+ 
+-    int attempts = 0;
+-
+     if (m_pPacket)
+     {
+         av_packet_unref(m_pPacket);
+@@ -580,6 +590,7 @@
+ 
+     m_pPacket = new AVPacket();
+ 
++
+     while (framesAvailable && !frameDecoded)
+     {
+         framesAvailable = av_read_frame(m_pFormatContext, m_pPacket) >= 0;
+@@ -644,7 +655,7 @@
+ 
+ int32_t MovieDecoder::getStreamRotation()
+ {
+-    int32_t* matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
++    auto matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
+     if (matrix)
+     {
+         auto angle = lround(av_display_rotation_get(matrix));
+
+--- a/libffmpegthumbnailer/moviedecoder.h	2017-11-12 04:23:38.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.h	2023-05-05 13:26:07.095529911 -0400
+@@ -78,7 +78,7 @@
+     int                     m_VideoStream;
+     AVFormatContext*        m_pFormatContext;
+     AVCodecContext*         m_pVideoCodecContext;
+-    AVCodec*                m_pVideoCodec;
++    const AVCodec*          m_pVideoCodec;
+     AVFilterGraph*          m_pFilterGraph;
+     AVFilterContext*        m_pFilterSource;
+     AVFilterContext*        m_pFilterSink;
diff --git a/srcpkgs/ffmpegthumbnailer/template b/srcpkgs/ffmpegthumbnailer/template
index 039eea7622b39..35d546018d12a 100644
--- a/srcpkgs/ffmpegthumbnailer/template
+++ b/srcpkgs/ffmpegthumbnailer/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbnailer'
 pkgname=ffmpegthumbnailer
 version=2.2.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libpng-devel libjpeg-turbo-devel ffmpeg-devel"
@@ -9,8 +9,8 @@ depends="ffmpeg"
 short_desc="Lightweight video thumbnailer"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
-homepage="https://github.com/dirkvdb/${pkgname}"
-distfiles="${homepage}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
+homepage="https://github.com/dirkvdb"
+distfiles="${homepage}/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
 checksum=1cb24059c38223f657b300c84dd80491b7040d4b69471c4fea69be862bc99b5b
 
 post_install() {

From bea2a911cf13d01c6250edf60cf802f8f3e427eb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 034/115] ffmpegthumbs: revbump for ffmpeg-6.0

---
 srcpkgs/ffmpegthumbs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ffmpegthumbs/template b/srcpkgs/ffmpegthumbs/template
index 5f0b9414dadaf..11b88193528f4 100644
--- a/srcpkgs/ffmpegthumbs/template
+++ b/srcpkgs/ffmpegthumbs/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbs'
 pkgname=ffmpegthumbs
 version=22.12.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules kcoreaddons kconfig-devel
  pkg-config qt5-host-tools qt5-qmake gettext"

From bb3e0b1237fc53a8624ff8b91af4f45d780a7cee Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 035/115] ffms2: revbump for ffmpeg-6.0

---
 srcpkgs/ffms2/patches/ffmpeg5.patch | 424 ++++++++++++++++++++++++++++
 srcpkgs/ffms2/template              |   2 +-
 2 files changed, 425 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ffms2/patches/ffmpeg5.patch

diff --git a/srcpkgs/ffms2/patches/ffmpeg5.patch b/srcpkgs/ffms2/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..1479fabcafcb4
--- /dev/null
+++ b/srcpkgs/ffms2/patches/ffmpeg5.patch
@@ -0,0 +1,424 @@
+From 45673149e9a2f5586855ad472e3059084eaa36b1 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:41:21 +0100
+Subject: [PATCH] Use auto for AVCodec
+
+The geniuses over at FFmpeg decided to constify this API, so old
+versions of the library will return AVCodec *, while new versions
+of the libary will return const AVCodec *, which, in C++, are not
+OK to convert between.
+
+Rather than use some macro hell in ffmscompat.h, we can work around
+this by using auto.
+
+Gross.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 2 +-
+ src/core/indexing.cpp    | 6 +++---
+ src/core/videosource.cpp | 2 +-
+ 3 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index e4ce97c..ac09666 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -469,7 +469,7 @@ void FFMS_AudioSource::OpenFile() {
+ 
+     LAVFOpenFile(SourceFile.c_str(), FormatContext, TrackNumber);
+ 
+-    AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
++    auto *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
+     if (Codec == nullptr)
+         throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+             "Audio codec not found");
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index e547c5a..59fb4e8 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -384,7 +384,7 @@ FFMS_TrackType FFMS_Indexer::GetTrackType(int Track) {
+ }
+ 
+ const char *FFMS_Indexer::GetTrackCodec(int Track) {
+-    AVCodec *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
++    auto *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
+     return codec ? codec->name : nullptr;
+ }
+ 
+@@ -402,7 +402,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             UseDTS);
+ 
+         if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            AVCodec *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (!VideoCodec) {
+                 FormatContext->streams[i]->discard = AVDISCARD_ALL;
+                 IndexMask.erase(i);
+@@ -433,7 +433,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 IndexMask.insert(i);
+             }
+         } else if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+-            AVCodec *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (AudioCodec == nullptr)
+                 throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_UNSUPPORTED,
+                     "Audio codec not found");
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index b889970..8956c22 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -171,7 +171,7 @@ FFMS_VideoSource::FFMS_VideoSource(const char *SourceFile, FFMS_Index &Index, in
+ 
+         LAVFOpenFile(SourceFile, FormatContext, VideoTrack);
+ 
+-        AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
++        auto *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
+         if (Codec == nullptr)
+             throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+                 "Video codec not found");
+-- 
+2.40.0
+
+From 96cbf38ea9381829a1314f432a2c60495dcefaad Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:12:41 +0100
+Subject: [PATCH] all: Update AVPacket API usage
+
+AVPackets must all be on the heap now, since it is no longer
+part of the libav* ABI.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 16 ++++++----
+ src/core/indexing.cpp    | 63 ++++++++++++++++++++++------------------
+ src/core/indexing.h      |  4 +--
+ src/core/utils.cpp       |  6 ----
+ src/core/utils.h         |  1 -
+ src/core/videosource.cpp | 30 ++++++++++---------
+ 6 files changed, 64 insertions(+), 56 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index 37cf9ae..e4ce97c 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -285,10 +285,15 @@ FFMS_AudioSource::AudioBlock *FFMS_AudioSource::CacheBlock(CacheIterator &pos) {
+ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     CurrentFrame = &Frames[PacketNumber];
+ 
+-    AVPacket Packet;
+-    if (!ReadPacket(&Packet))
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++    if (!ReadPacket(Packet)) {
++        av_packet_free(&Packet);
+         throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_UNKNOWN,
+             "ReadPacket unexpectedly failed to read a packet");
++    }
+ 
+     // ReadPacket may have changed the packet number
+     CurrentFrame = &Frames[PacketNumber];
+@@ -297,8 +302,9 @@ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     int NumberOfSamples = 0;
+     AudioBlock *CachedBlock = nullptr;
+     
+-    int Ret = avcodec_send_packet(CodecContext, &Packet);
+-    av_packet_unref(&Packet);
++    int Ret = avcodec_send_packet(CodecContext, Packet);
++    av_packet_unref(Packet);
++    av_packet_free(&Packet);
+ 
+     av_frame_unref(DecodeFrame);
+     Ret = avcodec_receive_frame(CodecContext, DecodeFrame);
+@@ -513,8 +519,6 @@ void FFMS_AudioSource::Seek() {
+ }
+ 
+ bool FFMS_AudioSource::ReadPacket(AVPacket *Packet) {
+-    InitNullPacket(*Packet);
+-
+     while (av_read_frame(FormatContext, Packet) >= 0) {
+         if (Packet->stream_index == TrackNumber) {
+             // Required because not all audio packets, especially in ogg, have a pts. Use the previous valid packet's pts instead.
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index 23fb95b..e547c5a 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -320,7 +320,7 @@ void FFMS_Indexer::CheckAudioProperties(int Track, AVCodecContext *Context) {
+     }
+ }
+ 
+-void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict,
++void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict,
+                                     int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct) {
+     if (VideoContext.Parser) {
+         uint8_t *OB;
+@@ -330,8 +330,8 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+         av_parser_parse2(VideoContext.Parser,
+             VideoContext.CodecContext,
+             &OB, &OBSize,
+-            pkt.data, pkt.size,
+-            pkt.pts, pkt.dts, pkt.pos);
++            pkt->data, pkt->size,
++            pkt->pts, pkt->dts, pkt->pos);
+ 
+         // H.264 (PAFF) and HEVC may have one field per packet, so we need to track
+         // when we have a full or half frame available, and mark one of them as
+@@ -351,15 +351,15 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+ 
+         *RepeatPict = VideoContext.Parser->repeat_pict;
+         *FrameType = VideoContext.Parser->pict_type;
+-        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt.flags & AV_PKT_FLAG_DISCARD));
++        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt->flags & AV_PKT_FLAG_DISCARD));
+     } else {
+-        *Invisible = !!(pkt.flags & AV_PKT_FLAG_DISCARD);
++        *Invisible = !!(pkt->flags & AV_PKT_FLAG_DISCARD);
+     }
+ 
+     if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP8)
+-        ParseVP8(pkt.data[0], Invisible, FrameType);
++        ParseVP8(pkt->data[0], Invisible, FrameType);
+     else if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP9)
+-        ParseVP9(pkt.data[0], Invisible, FrameType);
++        ParseVP9(pkt->data[0], Invisible, FrameType);
+ }
+ 
+ void FFMS_Indexer::Free() {
+@@ -458,32 +458,36 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+         }
+     }
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
+     std::vector<int64_t> LastValidTS(FormatContext->nb_streams, AV_NOPTS_VALUE);
+ 
+     int64_t filesize = avio_size(FormatContext->pb);
+     enum AVPictureStructure LastPicStruct = AV_PICTURE_STRUCTURE_UNKNOWN;
+-    while (av_read_frame(FormatContext, &Packet) >= 0) {
++    while (av_read_frame(FormatContext, Packet) >= 0) {
+         // Update progress
+         // FormatContext->pb can apparently be NULL when opening images.
+         if (IC && FormatContext->pb) {
+-            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate))
++            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate)) {
++                av_packet_free(&Packet);
+                 throw FFMS_Exception(FFMS_ERROR_CANCELLED, FFMS_ERROR_USER,
+                     "Cancelled by user");
++            }
+         }
+-        if (!IndexMask.count(Packet.stream_index)) {
+-            av_packet_unref(&Packet);
++        if (!IndexMask.count(Packet->stream_index)) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+-        int Track = Packet.stream_index;
++        int Track = Packet->stream_index;
+         FFMS_Track &TrackInfo = (*TrackIndices)[Track];
+-        bool KeyFrame = !!(Packet.flags & AV_PKT_FLAG_KEY);
++        bool KeyFrame = !!(Packet->flags & AV_PKT_FLAG_KEY);
+         ReadTS(Packet, LastValidTS[Track], (*TrackIndices)[Track].UseDTS);
+ 
+         if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            int64_t PTS = TrackInfo.UseDTS ? Packet.dts : Packet.pts;
++            int64_t PTS = TrackInfo.UseDTS ? Packet->dts : Packet->pts;
+             if (PTS == AV_NOPTS_VALUE) {
+                 // VPx alt-refs are output as packets which lack timestmps or durations, since
+                 // they are invisible. Currently, the timestamp mangling code in libavformat
+@@ -495,9 +499,11 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 // FFMS2 currently sorts packets by PTS, which will break decoding, otherwise.
+                 bool HasAltRefs = (FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP8 ||
+                                    FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP9);
+-                if (Packet.duration == 0 && !HasAltRefs)
++                if (Packet->duration == 0 && !HasAltRefs) {
++                    av_packet_free(&Packet);
+                     throw FFMS_Exception(FFMS_ERROR_INDEXING, FFMS_ERROR_PARSER,
+                         "Invalid packet pts, dts, and duration");
++                }
+ 
+                 if (TrackInfo.empty())
+                     PTS = 0;
+@@ -513,7 +519,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             ParseVideoPacket(AVContexts[Track], Packet, &RepeatPict, &FrameType, &Invisible, &LastPicStruct);
+ 
+             TrackInfo.AddVideoFrame(PTS, RepeatPict, KeyFrame,
+-                FrameType, Packet.pos, Invisible);
++                FrameType, Packet->pos, Invisible);
+         } else if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+             // For video seeking timestamps are used only if all packets have
+             // timestamps, while for audio they're used if any have timestamps,
+@@ -522,28 +528,29 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 TrackInfo.HasTS = true;
+ 
+             int64_t StartSample = AVContexts[Track].CurrentSample;
+-            uint32_t SampleCount = IndexAudioPacket(Track, &Packet, AVContexts[Track], *TrackIndices);
++            uint32_t SampleCount = IndexAudioPacket(Track, Packet, AVContexts[Track], *TrackIndices);
+             TrackInfo.SampleRate = AVContexts[Track].CodecContext->sample_rate;
+ 
+             TrackInfo.AddAudioFrame(LastValidTS[Track],
+-                StartSample, SampleCount, KeyFrame, Packet.pos, Packet.flags & AV_PKT_FLAG_DISCARD);
++                StartSample, SampleCount, KeyFrame, Packet->pos, Packet->flags & AV_PKT_FLAG_DISCARD);
+         }
+ 
+-        if (!(Packet.flags & AV_PKT_FLAG_DISCARD))
+-            TrackInfo.LastDuration = Packet.duration;
++        if (!(Packet->flags & AV_PKT_FLAG_DISCARD))
++            TrackInfo.LastDuration = Packet->duration;
+ 
+-        av_packet_unref(&Packet);
++        av_packet_unref(Packet);
+     }
++    av_packet_free(&Packet);
+ 
+     TrackIndices->Finalize(AVContexts, FormatContext->iformat->name);
+     return TrackIndices.release();
+ }
+ 
+-void FFMS_Indexer::ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS) {
+-    if (!UseDTS && Packet.pts != AV_NOPTS_VALUE)
+-        TS = Packet.pts;
++void FFMS_Indexer::ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS) {
++    if (!UseDTS && Packet->pts != AV_NOPTS_VALUE)
++        TS = Packet->pts;
+     if (TS == AV_NOPTS_VALUE)
+         UseDTS = true;
+-    if (UseDTS && Packet.dts != AV_NOPTS_VALUE)
+-        TS = Packet.dts;
++    if (UseDTS && Packet->dts != AV_NOPTS_VALUE)
++        TS = Packet->dts;
+ }
+diff --git a/src/core/indexing.h b/src/core/indexing.h
+index 3cfc3c3..5c06868 100644
+--- a/src/core/indexing.h
++++ b/src/core/indexing.h
+@@ -80,10 +80,10 @@ private:
+     int64_t Filesize;
+     uint8_t Digest[20];
+ 
+-    void ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS);
++    void ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS);
+     void CheckAudioProperties(int Track, AVCodecContext *Context);
+     uint32_t IndexAudioPacket(int Track, AVPacket *Packet, SharedAVContext &Context, FFMS_Index &TrackIndices);
+-    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
++    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
+     void Free();
+ public:
+     FFMS_Indexer(const char *Filename);
+diff --git a/src/core/utils.cpp b/src/core/utils.cpp
+index ce67533..8a2e997 100644
+--- a/src/core/utils.cpp
++++ b/src/core/utils.cpp
+@@ -62,12 +62,6 @@ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo) {
+     }
+ }
+ 
+-void InitNullPacket(AVPacket &pkt) {
+-    av_init_packet(&pkt);
+-    pkt.data = nullptr;
+-    pkt.size = 0;
+-}
+-
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames) {
+     AP.SampleFormat = static_cast<FFMS_SampleFormat>(av_get_packed_sample_fmt(CTX->sample_fmt));
+     AP.BitsPerSample = av_get_bytes_per_sample(CTX->sample_fmt) * 8;
+diff --git a/src/core/utils.h b/src/core/utils.h
+index 9819dc7..003ab79 100644
+--- a/src/core/utils.h
++++ b/src/core/utils.h
+@@ -58,7 +58,6 @@ std::unique_ptr<T> make_unique(Args&&... args) {
+ }
+ 
+ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo);
+-void InitNullPacket(AVPacket &pkt);
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames);
+ 
+ void LAVFOpenFile(const char *SourceFile, AVFormatContext *&FormatContext, int Track);
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index 06bd161..b889970 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -673,30 +673,34 @@ void FFMS_VideoSource::DecodeNextFrame(int64_t &AStartTime, int64_t &Pos) {
+     if (HasPendingDelayedFrames())
+         return;
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
+-
+-    while (ReadFrame(&Packet) >= 0) {
+-        if (Packet.stream_index != VideoTrack) {
+-            av_packet_unref(&Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++
++    while (ReadFrame(Packet) >= 0) {
++        if (Packet->stream_index != VideoTrack) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+         if (AStartTime < 0)
+-            AStartTime = Frames.UseDTS ? Packet.dts : Packet.pts;
++            AStartTime = Frames.UseDTS ? Packet->dts : Packet->pts;
+ 
+         if (Pos < 0)
+-            Pos = Packet.pos;
++            Pos = Packet->pos;
+ 
+-        bool FrameFinished = DecodePacket(&Packet);
+-        av_packet_unref(&Packet);
+-        if (FrameFinished)
++        bool FrameFinished = DecodePacket(Packet);
++        av_packet_unref(Packet);
++        if (FrameFinished) {
++            av_packet_free(&Packet);
+             return;
++        }
+     }
+ 
+     // Flush final frames
+-    InitNullPacket(Packet);
+-    DecodePacket(&Packet);
++    DecodePacket(Packet);
++    av_packet_free(&Packet);
+ }
+ 
+ bool FFMS_VideoSource::SeekTo(int n, int SeekOffset) {
+-- 
+2.40.0
+
+From bf9e03e9e08534c024e5a744a6437c4aac160201 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:20:47 +0100
+Subject: [PATCH 2/3] configure: Remove deprecated API use
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ configure.ac | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index b35ef80bc..d19714d0f 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -102,10 +102,10 @@ CFLAGS="$_CFLAGS $FFMPEG_CFLAGS"
+
+ AC_DEFUN([TEST_FFMPEG],
+          [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+-            #include <libavcodec/avcodec.h>
++            #include <libavformat/avformat.h>
+             #include <libswscale/swscale.h>
+             ]],[[
+-                avcodec_register_all();
++                avformat_network_init();
+                 swscale_version();
+             ]])], [eval $1=yes], [eval $1=no])
+         ])
+
diff --git a/srcpkgs/ffms2/template b/srcpkgs/ffms2/template
index 365f64d10cbab..1641ecf43be5b 100644
--- a/srcpkgs/ffms2/template
+++ b/srcpkgs/ffms2/template
@@ -1,7 +1,7 @@
 # Template file for 'ffms2'
 pkgname=ffms2
 version=2.40
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-shared --disable-static"
 hostmakedepends="pkg-config autoconf automake libtool"

From 77532a95c17cef5e8e9e88545cbd4d33b93daa7b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 036/115] freerdp: revbump for ffmpeg-6.0

---
 .../freerdp/patches/ffmpeg6_aa2cb9aa.patch    | 42 +++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100644 srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch

diff --git a/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
new file mode 100644
index 0000000000000..a4324da3a8822
--- /dev/null
+++ b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
@@ -0,0 +1,42 @@
+From aa2cb9aa5ff5562433598ba168a466e0752bca0e Mon Sep 17 00:00:00 2001
+From: akallabeth <akallabeth@posteo.net>
+Date: Tue, 14 Feb 2023 07:48:54 +0100
+Subject: [PATCH] Fixed #8686: Update h264 to use new FFMPEG API
+
+---
+ channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c | 2 ++
+ libfreerdp/codec/h264_ffmpeg.c            | 2 ++
+ 2 files changed, 4 insertions(+)
+
+diff --git a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+index 339462d865f..beea80b7a1e 100644
+--- a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
++++ b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+@@ -239,8 +239,10 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYP
+ 		}
+ 	}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 	if (mdecoder->codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		mdecoder->codec_context->flags |= AV_CODEC_FLAG_TRUNCATED;
++#endif
+ 
+ 	return TRUE;
+ }
+diff --git a/libfreerdp/codec/h264_ffmpeg.c b/libfreerdp/codec/h264_ffmpeg.c
+index 8a23db2473c..896a333019b 100644
+--- a/libfreerdp/codec/h264_ffmpeg.c
++++ b/libfreerdp/codec/h264_ffmpeg.c
+@@ -615,10 +615,12 @@ static BOOL libavcodec_init(H264_CONTEXT* h264)
+ 			goto EXCEPTION;
+ 		}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 		if (sys->codecDecoder->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		{
+ 			sys->codecDecoderContext->flags |= AV_CODEC_FLAG_TRUNCATED;
+ 		}
++#endif
+ 
+ #ifdef WITH_VAAPI
+ 

From c0079489eea9d97e2acbcf95a8003a2289a7f049 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 037/115] gerbera: revbump for ffmpeg-6.0

---
 srcpkgs/gerbera/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gerbera/template b/srcpkgs/gerbera/template
index ae14f35c767c0..2dc0ac0ce03b5 100644
--- a/srcpkgs/gerbera/template
+++ b/srcpkgs/gerbera/template
@@ -1,7 +1,7 @@
 # Template file for 'gerbera'
 pkgname=gerbera
 version=1.12.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_SYSTEMD=0 -DWITH_AVCODEC=1"
 hostmakedepends="pkg-config"

From e08e7866b7f3def5d5e40b37e3a6df9a15fc6358 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 038/115] goldendict: revbump for ffmpeg-6.0

---
 srcpkgs/goldendict/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/goldendict/template b/srcpkgs/goldendict/template
index f4a05759f693d..97f44347b03a6 100644
--- a/srcpkgs/goldendict/template
+++ b/srcpkgs/goldendict/template
@@ -1,7 +1,7 @@
 # Template file for 'goldendict'
 pkgname=goldendict
 version=1.5.0
-revision=1
+revision=2
 build_style=qmake
 configure_args="CONFIG+=zim_support goldendict.pro"
 hostmakedepends="qt5-qmake pkg-config qt5-host-tools"
@@ -10,7 +10,7 @@ makedepends="tiff-devel qt5-devel libvorbis-devel zlib-devel
  qt5-webkit-devel lzo-devel bzip2-devel libao-devel qt5-svg-devel
  libeb-devel qt5-x11extras-devel ffmpeg-devel liblzma-devel
  qt5-multimedia-devel"
-short_desc="A feature-rich dictionary lookup program"
+short_desc="Feature-rich dictionary lookup program"
 maintainer="John <me@johnnynator.dev>"
 license="GPL-3.0-or-later"
 homepage="http://goldendict.org/"

From 93620d833621b895bc7a833201fa5532e9a9cd28 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 039/115] gst-libav: revbump for ffmpeg-6.0

---
 srcpkgs/gst-libav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index 37485f6f6a9e8..f610e966f23cd 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.22.5
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"

From 6193a5120a20e693627384f8ff5ad031f019edc8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 040/115] gst-rtsp-server: revbump for ffmpeg-6.0

---
 srcpkgs/gst-rtsp-server/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index f266f4777b3ea..011444eb26739 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
 version=1.22.5
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="glib-devel gst-plugins-bad1-devel gobject-introspection

From a913441ac44e7c934bea488a9998bbc7aa0f86e7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 041/115] guvcview: update to 2.0.8.

---
 srcpkgs/guvcview/patches/fix-include.patch | 10 ++++++++++
 srcpkgs/guvcview/template                  |  5 ++---
 2 files changed, 12 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/guvcview/patches/fix-include.patch

diff --git a/srcpkgs/guvcview/patches/fix-include.patch b/srcpkgs/guvcview/patches/fix-include.patch
new file mode 100644
index 0000000000000..503c2af3b78c1
--- /dev/null
+++ b/srcpkgs/guvcview/patches/fix-include.patch
@@ -0,0 +1,10 @@
+--- a/guvcview/guvcview.c
++++ b/guvcview/guvcview.c
+@@ -28,6 +28,7 @@
+ #include <sys/stat.h>
+ #include <sys/resource.h>
+ #include <errno.h>
++#include <locale.h>
+ 
+ #include "gview.h"
+ #include "gviewv4l2core.h"
diff --git a/srcpkgs/guvcview/template b/srcpkgs/guvcview/template
index 345cf6006f246..86a7fd619612c 100644
--- a/srcpkgs/guvcview/template
+++ b/srcpkgs/guvcview/template
@@ -1,8 +1,7 @@
 # Template file for 'guvcview'
 pkgname=guvcview
-version=2.0.7
+version=2.0.8
 revision=1
-create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-static --disable-debian-menu"
 hostmakedepends="pkg-config intltool autoconf automake libtool glib-devel"
@@ -14,7 +13,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="http://guvcview.sourceforge.net/"
 distfiles="${SOURCEFORGE_SITE}/${pkgname}/${pkgname}-src-${version}.tar.bz2"
-checksum=f47d51fbd06e44eeaa1a82f4a153c927527c90d94514197a70b2956028cc8ad4
+checksum=a21f4e448286666cf27bafef5290cc953a0a1796b752e5bbe521266dc1230c81
 
 post_patch() {
 	sed '31a#include <locale.h>' -i  guvcview/guvcview.c

From c9c9189fa25f5b33aaa1113d1e0d02d6709d9a2f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 042/115] handbrake: update to 1.6.1

---
 .../patches/fix-missing-x265-link-flag.patch    | 11 ++++++-----
 .../handbrake/patches/libhb-vpl-include.patch   | 15 +++++++++++++++
 srcpkgs/handbrake/template                      | 17 ++++++++++-------
 3 files changed, 31 insertions(+), 12 deletions(-)
 create mode 100644 srcpkgs/handbrake/patches/libhb-vpl-include.patch

diff --git a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
index 26db03867a0c8..d6bb2eda627a3 100644
--- a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
+++ b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
@@ -1,14 +1,15 @@
 --- a/gtk/configure.ac
 +++ b/gtk/configure.ac
 @@ -203,7 +203,7 @@
- 
+
  AM_CONDITIONAL([MINGW], [test "x$mingw_flag" = "xyes"])
- 
--HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg"
-+HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -ldl"
+
+-HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc"
++HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc -ldl"
  HB_CPPFLAGS="$HB_CPPFLAGS $HBINC"
- 
+
  PKG_CHECK_MODULES([x264], [x264], sys_x264=yes, sys_x264=no)
+
 --- a/test/module.defs
 +++ b/test/module.defs
 @@ -69,6 +69,9 @@
diff --git a/srcpkgs/handbrake/patches/libhb-vpl-include.patch b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
new file mode 100644
index 0000000000000..298f9f4ab28f2
--- /dev/null
+++ b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
@@ -0,0 +1,15 @@
+--- a/libhb/module.defs	2023-01-22 11:36:49.000000000 -0500
++++ b/libhb/module.defs	2023-04-03 22:37:52.395467010 -0400
+@@ -46,11 +46,7 @@
+ LIBHB.GCC.I += $(LIBHB.build/) $(CONTRIB.build/)include
+ 
+ ifeq (1,$(FEATURE.qsv))
+-    ifeq ($(HOST.system),freebsd))
+-        LIBHB.GCC.I += $(LOCALBASE)/include/vpl
+-    else
+-        LIBHB.GCC.I += $(CONTRIB.build/)include/vpl
+-    endif
++    LIBHB.GCC.I += /usr/include/vpl
+ endif
+ 
+ ifneq (,$(filter $(HOST.system),freebsd netbsd openbsd))
diff --git a/srcpkgs/handbrake/template b/srcpkgs/handbrake/template
index ca5e4571e49c3..c32cb1bfa31f4 100644
--- a/srcpkgs/handbrake/template
+++ b/srcpkgs/handbrake/template
@@ -1,10 +1,10 @@
 # Template file for 'handbrake'
 pkgname=handbrake
-version=1.5.1
+version=1.6.1
 revision=1
 build_style=gnu-configure
 configure_args="--force --disable-gtk-update-checks --disable-df-fetch --harden
- $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc)"
+ $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc) $(vopt_enable qsv)"
 make_build_args="-C ${XBPS_TRIPLET}"
 make_install_args="-C ${XBPS_TRIPLET}"
 hostmakedepends="automake cmake gettext-devel glib-devel intltool libtool m4 meson nasm pkg-config python3"
@@ -12,8 +12,11 @@ makedepends="bzip2-devel ffmpeg-devel gst-plugins-base1-devel gtk+3-devel
  jansson-devel lame-devel libass-devel libbluray-devel libdav1d-devel
  libdvdnav-devel libdvdread-devel libgudev-devel libnuma-devel
  libsamplerate-devel libtheora-devel libvorbis-devel libvpx-devel libxml2-devel
- opus-devel speex-devel x264-devel x265-devel zimg-devel
+ opus-devel speex-devel x264-devel x265-devel zimg-devel libsvt-av1-devel
  $(vopt_if fdk_aac fdk-aac-devel)
+ $(vopt_if qsv libva-devel)
+ $(vopt_if qsv libdrm-devel)
+ $(vopt_if qsv onevpl-devel)
  $(vopt_if nvenc nv-codec-headers)"
 depends="desktop-file-utils gst-plugins-good1 hicolor-icon-theme"
 short_desc="Multithreaded video transcoder"
@@ -21,15 +24,15 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-2.0-only"
 homepage="https://handbrake.fr/"
 distfiles="https://github.com/HandBrake/HandBrake/releases/download/${version}/HandBrake-${version}-source.tar.bz2"
-checksum=3999fe06d5309c819799a73a968a8ec3840e7840c2b64af8f5cdb7fd8c9430f0
+checksum=94ccfe03db917a91650000c510f7fd53f844da19f19ad4b4be1b8f6bc31a8d4c
 nocross=yes
 
-build_options="fdk_aac nvenc"
+build_options="fdk_aac nvenc qsv"
 
 case "$XBPS_TARGET_MACHINE" in
 	x86_64*|i686*)
 		CFLAGS="-msse"
-		build_options_default="nvenc"
+		build_options_default="nvenc qsv"
 		;;
 esac
 
@@ -37,7 +40,7 @@ pre_configure() {
 	# use system libraries, don't download them
 	rm -rf contrib/
 	for module in fdk-aac ffmpeg libbluray libdav1d libdvdnav libdvdread nvenc \
-		x265 zimg; do
+		x265 zimg svt-av1 libvpl; do
 	    vsed -i "/MODULES += contrib\/${module}/d" make/include/main.defs
 	done
 }

From 8da3ada09f919d81a857b797ed79cfdaef873c3d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 043/115] hedgewars: revbump for ffmpeg4-4.4.3

---
 srcpkgs/hedgewars/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/hedgewars/template b/srcpkgs/hedgewars/template
index 15a1df6d8861d..d1b7290bfdc19 100644
--- a/srcpkgs/hedgewars/template
+++ b/srcpkgs/hedgewars/template
@@ -1,13 +1,13 @@
 # Template file for 'hedgewars'
 pkgname=hedgewars
 version=1.0.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DNOSERVER=1 -DDATA_INSTALL_DIR=/usr/share/${pkgname}
  -DPHYSFS_SYSTEM=1 -DMINIMAL_FLAGS=1"
 make_cmd=make
 hostmakedepends="lua51 pkg-config qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
+makedepends="ffmpeg4-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
  SDL2_mixer-devel SDL2_net-devel SDL2_ttf-devel"
 depends="libfreeglut"
 short_desc="Funny turn-based artillery game, featuring fighting Hedgehogs!"

From aefabb8a5c33c4f839b2c0f54dda0546ac4a0c32 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 044/115] idjc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/idjc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/idjc/template b/srcpkgs/idjc/template
index b205e74745fe1..36a75baf597c5 100644
--- a/srcpkgs/idjc/template
+++ b/srcpkgs/idjc/template
@@ -5,7 +5,7 @@ revision=4
 build_style=gnu-configure
 hostmakedepends="pkg-config git python3 automake gettext-devel libtool"
 makedepends="libvorbis-devel libogg-devel jack-devel libsamplerate-devel
- libflac-devel libsndfile-devel mpg123-devel ffmpeg-devel speex-devel
+ libflac-devel libsndfile-devel mpg123-devel ffmpeg4-devel speex-devel
  glib-devel pixman-devel lame-devel python3-gobject-devel libshout-idjc-devel
  opus-devel twolame-devel python3-mutagen python3-devel"
 depends="python3-gobject python3-mutagen desktop-file-utils shared-mime-info python3-dbus jack"

From 1d867e5ccc5d5d6d0875f3e82e5a78178a8e0122 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 045/115] kfilemetadata5: revbump for ffmpeg-6.0

---
 srcpkgs/kfilemetadata5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kfilemetadata5/template b/srcpkgs/kfilemetadata5/template
index c034d62deec8f..e6e9fe11aa55d 100644
--- a/srcpkgs/kfilemetadata5/template
+++ b/srcpkgs/kfilemetadata5/template
@@ -1,7 +1,7 @@
 # Template file for 'kfilemetadata5'
 pkgname=kfilemetadata5
 version=5.110.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="kcoreaddons extra-cmake-modules pkg-config qt5-host-tools qt5-qmake
  gettext kcoreaddons python3"

From db091b5866d46f17351c987cbfcc512e6469ad7f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 046/115] kid3: revbump for ffmpeg-6.0

---
 srcpkgs/kid3/patches/ffmpeg5.patch | 17 +++++++++++++++++
 srcpkgs/kid3/template              |  2 +-
 2 files changed, 18 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/kid3/patches/ffmpeg5.patch

diff --git a/srcpkgs/kid3/patches/ffmpeg5.patch b/srcpkgs/kid3/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..135fc50e07c9b
--- /dev/null
+++ b/srcpkgs/kid3/patches/ffmpeg5.patch
@@ -0,0 +1,17 @@
+# https://aur.archlinux.org/cgit/aur.git/diff/ffmpeg5.patch?h=kid3-cli&id=12410a74906612e7efc0ec8fbce739b4a0fef7e7
+diff --git a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+index e156d424..e12b9abd 100644
+--- a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
++++ b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+@@ -232,7 +232,11 @@ private:
+   friend class Format;
+   friend class Converter;
+   AVCodecContext* m_ptr;
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 0, 0)
+   AVCodec* m_impl;
++#else
++  const AVCodec* m_impl;
++#endif
+   AVFrame* m_frame;
+   bool m_opened;
+ };
diff --git a/srcpkgs/kid3/template b/srcpkgs/kid3/template
index 456206d90e16a..f32f9decb0e7f 100644
--- a/srcpkgs/kid3/template
+++ b/srcpkgs/kid3/template
@@ -1,7 +1,7 @@
 # Template file for 'kid3'
 pkgname=kid3
 version=3.9.1
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DWITH_APPS='CLI;$(vopt_if KDE KDE Qt)'
  -DWITH_DOCBOOKDIR=/usr/share/xsl/docbook -DWITH_FLAC=$(vopt_if flac ON OFF)

From c88d709b62f36601bda42395a2c4a2fbcfc83e38 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 047/115] kodi: revbump for ffmpeg4-4.4.3

---
 srcpkgs/kodi/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kodi/template b/srcpkgs/kodi/template
index 8ef6bc85ed3b4..788a0ac978af8 100644
--- a/srcpkgs/kodi/template
+++ b/srcpkgs/kodi/template
@@ -54,7 +54,7 @@ makedepends="
  libmad-devel fontconfig-devel libXinerama-devel libsamplerate-devel libmms-devel
  enca-devel boost-devel libcurl-devel libva-devel libvdpau-devel libass-devel
  libbluetooth-devel yajl-devel libplist-devel librtmp-devel tinyxml-devel
- taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg-devel
+ taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg4-devel
  giflib-devel libxslt-devel gnutls-devel libssh-devel libmicrohttpd-devel
  libcec-devel dcadec-devel flatbuffers-devel fmt-devel lcms2-devel
  libfstrcmp-devel rapidjson libcdio-paranoia spdlog libwaylandpp-devel

From 1a0e9d75eaa6074d3ac88f0678a8a469b0ffe669 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 048/115] kpipewire: revbump for ffmpeg-6.0

---
 srcpkgs/kpipewire/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kpipewire/template b/srcpkgs/kpipewire/template
index 216069507f54b..1173d36348d16 100644
--- a/srcpkgs/kpipewire/template
+++ b/srcpkgs/kpipewire/template
@@ -1,7 +1,7 @@
 # Template file for 'kpipewire'
 pkgname=kpipewire
 version=5.27.8
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules plasma-wayland-protocols gettext
  qt5-qmake qt5-host-tools pkg-config wayland-devel kcoreaddons

From ce76c1d5b0ab2a63233176fde0f1fa15e3a5c03d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 049/115] libextractor: revbump for ffmpeg4-4.4.3

---
 srcpkgs/libextractor/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libextractor/template b/srcpkgs/libextractor/template
index ddd4790f93e88..1fb9ca56a96ae 100644
--- a/srcpkgs/libextractor/template
+++ b/srcpkgs/libextractor/template
@@ -7,7 +7,7 @@ configure_args="--disable-static"
 hostmakedepends="pkg-config"
 makedepends="zlib-devel bzip2-devel exiv2-devel tiff-devel libpng-devel
  libjpeg-turbo-devel libvorbis-devel libflac-devel giflib-devel libmpeg2-devel
- ffmpeg-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
+ ffmpeg4-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
 short_desc="Library used to extract meta data from files"
 maintainer="Martin Riese <grauehaare@gmx.de>"
 license="GPL-3.0-or-later"

From 0f191f3e47b894a60c78ae92f18184276ee4d924 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 050/115] libopenal: revbump for ffmpeg-6.0

---
 srcpkgs/libopenal/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenal/template b/srcpkgs/libopenal/template
index 77218f9e539df..3f49ed75a1fdc 100644
--- a/srcpkgs/libopenal/template
+++ b/srcpkgs/libopenal/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenal'
 pkgname=libopenal
 version=1.22.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DALSOFT_EXAMPLES=OFF"
 hostmakedepends="pkg-config"

From 4730a179a4362839afd1ac6e1607027e196d3b95 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 051/115] loudgain: revbump for ffmpeg-6.0

---
 srcpkgs/loudgain/patches/ffmpeg5.patch | 11 +++++++++++
 srcpkgs/loudgain/template              |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/loudgain/patches/ffmpeg5.patch

diff --git a/srcpkgs/loudgain/patches/ffmpeg5.patch b/srcpkgs/loudgain/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..16d4510ee98fa
--- /dev/null
+++ b/srcpkgs/loudgain/patches/ffmpeg5.patch
@@ -0,0 +1,11 @@
+--- a/src/scan.c	2019-09-06 11:31:19.000000000 -0400
++++ b/src/scan.c	2023-03-23 11:15:40.867968521 -0400
+@@ -69,8 +69,6 @@
+ 	 * It is now useless
+ 	 * https://github.com/FFmpeg/FFmpeg/blob/70d25268c21cbee5f08304da95be1f647c630c15/doc/APIchanges#L86
+ 	 */
+-  if (avformat_version() < AV_VERSION_INT(58,9,100))
+-    av_register_all();
+ 
+ 	av_log_set_callback(scan_av_log);
+ 
diff --git a/srcpkgs/loudgain/template b/srcpkgs/loudgain/template
index da4f2d56e94c3..4d6bf29efb4fd 100644
--- a/srcpkgs/loudgain/template
+++ b/srcpkgs/loudgain/template
@@ -1,7 +1,7 @@
 # Template file for 'loudgain'
 pkgname=loudgain
 version=0.6.8
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libebur128-devel taglib-devel ffmpeg-devel"

From 7db538c2d7a27c2e3551f658d268c67b7600408e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 052/115] mediastreamer: revbump for ffmpeg4-4.4.3

---
 srcpkgs/mediastreamer/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mediastreamer/template b/srcpkgs/mediastreamer/template
index d29210c1bf9c7..1bde031443a59 100644
--- a/srcpkgs/mediastreamer/template
+++ b/srcpkgs/mediastreamer/template
@@ -5,7 +5,7 @@ revision=2
 build_style=cmake
 configure_args="-DENABLE_STRICT=0 -DENABLE_UNIT_TESTS=0"
 hostmakedepends="python3"
-makedepends="bzrtp-devel ffmpeg-devel glew-devel libXv-devel libsrtp-devel
+makedepends="bzrtp-devel ffmpeg4-devel glew-devel libXv-devel libsrtp-devel
  libupnp-devel libvpx-devel mbedtls-devel opus-devel ortp-devel pulseaudio-devel
  libtheora-devel speex-devel v4l-utils-devel bcg729-devel bcmatroska2-devel libgsm-devel"
 # zxing-cpp-devel (1.2.0 probably not compatible, check again after updaing xzing)

From 5f911de852675eb68c1a926625fc1f3ec3e4828f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 053/115] mgba: revbump for ffmpeg-6.0

---
 srcpkgs/mgba/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mgba/template b/srcpkgs/mgba/template
index 5513e3fd16f3f..f5c87a4893002 100644
--- a/srcpkgs/mgba/template
+++ b/srcpkgs/mgba/template
@@ -1,7 +1,7 @@
 # Template file for 'mgba'
 pkgname=mgba
 version=0.10.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake desktop-file-utils"
 makedepends="SDL2-devel ffmpeg-devel libedit-devel libepoxy-devel libmagick-devel

From c28ac3180d19b2ccbe980b10d702c91f7e912bfb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 054/115] minidlna: revbump for ffmpeg-6.0

---
 srcpkgs/minidlna/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/minidlna/template b/srcpkgs/minidlna/template
index d551e49ed4653..5fa929f3a0c12 100644
--- a/srcpkgs/minidlna/template
+++ b/srcpkgs/minidlna/template
@@ -1,7 +1,7 @@
 # Template file for 'minidlna'
 pkgname=minidlna
 version=1.3.3
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="
  --sbindir=/usr/bin

From 86942d94c9ccaec7cbe7dbe79ef570d39f79307d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 055/115] mlt: revbump for ffmpeg4-4.4.3

---
 srcpkgs/mlt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mlt/template b/srcpkgs/mlt/template
index f14dd85d1c9dc..f0b3af193db2c 100644
--- a/srcpkgs/mlt/template
+++ b/srcpkgs/mlt/template
@@ -8,7 +8,7 @@ configure_args="--prefix=/usr --libdir=/usr/lib$XBPS_TARGET_WORDSIZE
  --swig-languages=python"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which"
 # XXX: movit vid.stab
-makedepends="alsa-lib-devel ffmpeg-devel gtk+-devel jack-devel ladspa-sdk
+makedepends="alsa-lib-devel ffmpeg4-devel gtk+-devel jack-devel ladspa-sdk
  libexif-devel libsamplerate-devel libxml2-devel sox-devel SDL_image-devel
  fftw-devel frei0r-plugins python3-devel pulseaudio-devel movit-devel
  libvidstab-devel"

From aae43732ec52321baf775252329cd2539e0d0804 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 056/115] moc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/moc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/moc/template b/srcpkgs/moc/template
index 5aed5d36558d3..d8de816026b64 100644
--- a/srcpkgs/moc/template
+++ b/srcpkgs/moc/template
@@ -1,10 +1,10 @@
 # Template file for 'moc'
 pkgname=moc
 version=2.5.2
-revision=6
+revision=7
 build_style=gnu-configure
 hostmakedepends="pkg-config"
-makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg-devel
+makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg4-devel
  jack-devel alsa-lib-devel libltdl-devel libflac-devel libvorbis-devel
  libmad-devel libmpcdec-devel libmodplug-devel libid3tag-devel faad2-devel
  taglib-devel libsndfile-devel wavpack-devel speex-devel libsamplerate-devel

From 911caa49f693495f08a8c646138f22bc2fc9761e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 057/115] motion: revbump for ffmpeg-6.0

---
 srcpkgs/motion/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/motion/template b/srcpkgs/motion/template
index 3cf3c3035c5b7..7dca12d851e33 100644
--- a/srcpkgs/motion/template
+++ b/srcpkgs/motion/template
@@ -1,7 +1,7 @@
 # Template file for 'motion'
 pkgname=motion
 version=4.5.1
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake pkg-config gettext-devel tar"
 makedepends="ffmpeg-devel libmicrohttpd-devel v4l-utils-devel gettext-devel"

From 93872105690a713d87109ab3eb935583d0641275 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 058/115] notcurses: revbump for ffmpeg-6.0

---
 srcpkgs/notcurses/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/notcurses/template b/srcpkgs/notcurses/template
index 6dd8a091319f7..3110c30c9aff2 100644
--- a/srcpkgs/notcurses/template
+++ b/srcpkgs/notcurses/template
@@ -1,7 +1,7 @@
 # Template file for 'notcurses'
 pkgname=notcurses
 version=3.0.9
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DUSE_STATIC=ON $(vopt_bool man USE_PANDOC)"
 hostmakedepends="pkg-config $(vopt_if man pandoc)"

From 1543174e871324dde5b23ff48a9701973dbe21ae Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 059/115] olive: revbump for ffmpeg4-4.4.3

---
 srcpkgs/olive/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/olive/template b/srcpkgs/olive/template
index 12a46936c9900..5c2917b9c5124 100644
--- a/srcpkgs/olive/template
+++ b/srcpkgs/olive/template
@@ -1,10 +1,10 @@
 # Template file for 'olive'
 pkgname=olive
 version=0.1.2
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools pkg-config"
-makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg-devel frei0r-plugins"
+makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg4-devel frei0r-plugins"
 short_desc="Non-linear video editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"

From 5f779f0d9593c1a64084049067c70b1f6b10bcab Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 060/115] omxplayer: revbump for ffmpeg4-4.4.3

---
 srcpkgs/omxplayer/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/omxplayer/template b/srcpkgs/omxplayer/template
index 9a66690c83ebb..a21b878878037 100644
--- a/srcpkgs/omxplayer/template
+++ b/srcpkgs/omxplayer/template
@@ -1,7 +1,7 @@
 # Template file for 'omxplayer'
 pkgname=omxplayer
 version=20190102
-revision=2
+revision=3
 short_desc="Commandline OMX player for the Raspberry Pi"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
@@ -15,7 +15,7 @@ checksum=af2d9450f8947842ea8c401fe9f71eec444013ebbdee29f2ac828c9c493c1329
 archs="armv6l* armv7l*"
 build_style=gnu-makefile
 hostmakedepends="ruby-ronn pkg-config"
-makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg-devel dbus-devel"
+makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg4-devel dbus-devel"
 depends="freefont-ttf"
 
 do_build() {

From d90b5802546404d4b1b14cdeeeb6391cf3564738 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 061/115] opentoonz: revbump for ffmpeg-6.0

---
 srcpkgs/opentoonz/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/opentoonz/template b/srcpkgs/opentoonz/template
index ee9f7603f55fd..3e81834ca0edd 100644
--- a/srcpkgs/opentoonz/template
+++ b/srcpkgs/opentoonz/template
@@ -1,7 +1,7 @@
 # Template file for 'opentoonz'
 pkgname=opentoonz
 version=1.6.0
-revision=2
+revision=3
 build_wrksrc="toonz/sources"
 build_style=cmake
 make_cmd=make

From 4fdb202b2d03b37921de5857b6954be0f3ccb33e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 062/115] pianobar: revbump for ffmpeg-6.0

---
 srcpkgs/pianobar/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pianobar/template b/srcpkgs/pianobar/template
index e3febb821a451..1e3dc1bf9308e 100644
--- a/srcpkgs/pianobar/template
+++ b/srcpkgs/pianobar/template
@@ -1,7 +1,7 @@
 # Template file for 'pianobar'
 pkgname=pianobar
 version=2022.04.01
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="V=1"
 hostmakedepends="pkg-config"

From 097a91011b27e75c62b2659d2621f9b0e1e9b35f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 063/115] ppsspp: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ppsspp/template | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/ppsspp/template b/srcpkgs/ppsspp/template
index 2c0ded496eb98..1294ef3ae669c 100644
--- a/srcpkgs/ppsspp/template
+++ b/srcpkgs/ppsspp/template
@@ -1,7 +1,7 @@
 # Template file for 'ppsspp'
 pkgname=ppsspp
 version=1.16.6
-revision=1
+revision=2
 _glslang_commit=b34f619e1c85810dcb3c578107d2e48ba4ee2b37
 _SPIRV_Cross_commit=4212eef67ed0ca048cb726a6767185504e7695e5
 _armips_commit=7bd1ec93d4586985ba1ef420b43b5e620f68695e
@@ -15,7 +15,7 @@ configure_args="-DHEADLESS=1 -DUSE_SYSTEM_FFMPEG=1 -DUNITTEST=ON
  -DUSING_QT_UI=$(vopt_if qt ON OFF) -DUSE_SYSTEM_ZSTD=ON
  -DARMIPS_USE_STD_FILESYSTEM=ON"
 hostmakedepends="pkg-config python3 $(vopt_if qt qt5-host-tools)"
-makedepends="zlib-devel glew-devel ffmpeg-devel libzip-devel
+makedepends="zlib-devel glew-devel ffmpeg4-devel libzip-devel
  snappy-devel rapidjson libpng-devel libzstd-devel
  $(vopt_if sdl2 'SDL2_ttf-devel SDL2-devel') $(vopt_if wayland wayland-devel)
  $(vopt_if qt 'qt5-devel qt5-multimedia-devel')"
@@ -72,7 +72,7 @@ post_extract() {
         mv ${wrksrc}/rcheevos-${_rcheevos_commit} ${wrksrc}/ext/rcheevos
 }
 
-post_patch(){
+post_patch() {
 	# disable git versioning
 	vsed -e 's|find_package(Git)|# &|' -i git-version.cmake
 }
@@ -85,7 +85,6 @@ post_configure() {
 }
 
 do_install() {
-	vlicense LICENSE.TXT
 	vinstall icons/icon.svg 644 usr/share/pixmaps ppsspp.svg
 	vinstall Qt/PPSSPP.desktop 644 usr/share/applications
 	vbin build/PPSSPPHeadless ppsspp-headless

From 3cdb7568197278b468535e655ad73e1d415c3cb9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 064/115] pqiv: revbump for ffmpeg-6.0

---
 srcpkgs/pqiv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pqiv/template b/srcpkgs/pqiv/template
index 542fc27a2d32a..9308d949b6a1c 100644
--- a/srcpkgs/pqiv/template
+++ b/srcpkgs/pqiv/template
@@ -1,7 +1,7 @@
 # Template file for 'pqiv'
 pkgname=pqiv
 version=2.12
-revision=1
+revision=2
 build_style=gnu-makefile
 hostmakedepends="pkg-config"
 makedepends="glib-devel gtk+3-devel $(vopt_if ffmpeg ffmpeg-devel)

From 2b6ef237ad50ffc51e9e7985f568149979a4da64 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 065/115] qmmp: revbump for ffmpeg-6.0

---
 srcpkgs/qmmp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qmmp/template b/srcpkgs/qmmp/template
index 26c661ed16bea..a150d7441c7a6 100644
--- a/srcpkgs/qmmp/template
+++ b/srcpkgs/qmmp/template
@@ -1,7 +1,7 @@
 # Template file for 'qmmp'
 pkgname=qmmp
 version=1.6.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DUSE_HAL:BOOL=FALSE -DQMMP_DEFAULT_UI:STRING=simple"
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From a5c4585cb4f5800e4c6c9e29fcb91a0e603ce606 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 066/115] qt5-webengine: update to 5.15.13

---
 .../chromium-media-filters-cpp14.patch        |  11 ++
 srcpkgs/qt5-webengine/patches/ffmpeg5.patch   | 179 ++++++++++++++++++
 srcpkgs/qt5-webengine/template                |  10 +-
 3 files changed, 195 insertions(+), 5 deletions(-)
 create mode 100644 srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/ffmpeg5.patch

diff --git a/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
new file mode 100644
index 0000000000000..04adc540f2cbc
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
@@ -0,0 +1,11 @@
+--- a/src/3rdparty/chromium/media/filters/BUILD.gn	2023-02-27 13:32:59.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/BUILD.gn	2023-04-02 17:21:39.204066384 -0400
+@@ -96,6 +96,8 @@
+     "//ui/gfx/geometry:geometry",
+   ]
+ 
++  cflags_cc = [ "-std=c++14" ]
++
+   libs = []
+ 
+   if (proprietary_codecs) {
diff --git a/srcpkgs/qt5-webengine/patches/ffmpeg5.patch b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..ac55e1634423a
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
@@ -0,0 +1,179 @@
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:57.732547446 -0400
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:09.486478995 -0400
+@@ -57,6 +57,8 @@
+ 
+ namespace {
+ 
++constexpr int64_t kRelativeTsBase = static_cast<int64_t>(0x7ffeffffffffffff);
++
+ void SetAVStreamDiscard(AVStream* stream, AVDiscard discard) {
+   DCHECK(stream);
+   stream->discard = discard;
+@@ -90,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+   if (stream->start_time != kNoFFmpegTimestamp)
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (stream->first_dts != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, stream->first_dts);
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -408,11 +398,11 @@
+   scoped_refptr<DecoderBuffer> buffer;
+ 
+   if (type() == DemuxerStream::TEXT) {
+-    int id_size = 0;
++    size_t id_size = 0;
+     uint8_t* id_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
+ 
+-    int settings_size = 0;
++    size_t settings_size = 0;
+     uint8_t* settings_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
+ 
+@@ -424,7 +414,7 @@
+     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
+                                      side_data.data(), side_data.size());
+   } else {
+-    int side_data_size = 0;
++    size_t side_data_size = 0;
+     uint8_t* side_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
+ 
+@@ -485,7 +475,7 @@
+                                        packet->size - data_offset);
+     }
+ 
+-    int skip_samples_size = 0;
++    size_t skip_samples_size = 0;
+     const uint32_t* skip_samples_ptr =
+         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
+             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
+@@ -1587,6 +1577,8 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++      continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+       lowest_start_time_stream = stream.get();
+@@ -1604,6 +1596,8 @@
+     if (stream && stream->type() == DemuxerStream::VIDEO &&
+         stream->IsEnabled()) {
+       video_stream = stream.get();
++      if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++        continue;
+       if (video_stream->start_time() <= seek_time) {
+         return video_stream;
+       }
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h qtwebengine-5.15.10/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h
+--- a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-07-11 22:12:47.917192788 -0500
+@@ -29,6 +29,7 @@ extern "C" {
+ #include <libavformat/avformat.h>
+ #include <libavformat/avio.h>
+ #include <libavutil/avutil.h>
++#include <libavutil/channel_layout.h>
+ #include <libavutil/imgutils.h>
+ #include <libavutil/log.h>
+ #include <libavutil/mastering_display_metadata.h>
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/audio_file_reader.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/audio_file_reader.cc
+--- a/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -85,7 +85,7 @@ bool AudioFileReader::OpenDemuxer() {
+ }
+ 
+ bool AudioFileReader::OpenDecoder() {
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (codec) {
+     // MP3 decodes to S16P which we don't support, tell it to use S16 instead.
+     if (codec_context_->sample_fmt == AV_SAMPLE_FMT_S16P)
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -329,7 +329,7 @@ bool FFmpegAudioDecoder::ConfigureDecode
+     }
+   }
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec ||
+       avcodec_open2(codec_context_.get(), codec, &codec_options) < 0) {
+     DLOG(ERROR) << "Could not initialize audio decoder: "
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -59,7 +59,6 @@ static int64_t AVIOSeekOperation(void* o
+ }
+ 
+ void FFmpegGlue::InitializeFFmpeg() {
+-  av_register_all();
+ }
+ 
+ static void LogContainer(bool is_local_file,
+@@ -95,9 +94,6 @@ FFmpegGlue::FFmpegGlue(FFmpegURLProtocol
+   // Enable fast, but inaccurate seeks for MP3.
+   format_context_->flags |= AVFMT_FLAG_FAST_SEEK;
+ 
+-  // Ensures we can read out various metadata bits like vp8 alpha.
+-  format_context_->flags |= AVFMT_FLAG_KEEP_SIDE_DATA;
+-
+   // Ensures format parsing errors will bail out. From an audit on 11/2017, all
+   // instances were real failures. Solves bugs like http://crbug.com/710791.
+   format_context_->error_recognition |= AV_EF_EXPLODE;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -391,7 +391,7 @@ bool FFmpegVideoDecoder::ConfigureDecode
+   if (decode_nalus_)
+     codec_context_->flags2 |= AV_CODEC_FLAG2_CHUNKS;
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
+     ReleaseFFmpegResources();
+     return false;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/media_file_checker.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/media_file_checker.cc
+--- a/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -68,7 +68,7 @@ bool MediaFileChecker::Start(base::TimeD
+       auto context = AVStreamToAVCodecContext(format_context->streams[i]);
+       if (!context)
+         continue;
+-      AVCodec* codec = avcodec_find_decoder(cp->codec_id);
++      const AVCodec* codec = avcodec_find_decoder(cp->codec_id);
+       if (codec && avcodec_open2(context.get(), codec, nullptr) >= 0) {
+         auto loop = std::make_unique<FFmpegDecodingLoop>(context.get());
+         stream_contexts[i] = {std::move(context), std::move(loop)};
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc qtwebengine-5.15.10/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc
+--- a/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -203,7 +203,7 @@ int32_t H264DecoderImpl::InitDecode(cons
+   // a pointer |this|.
+   av_context_->opaque = this;
+ 
+-  AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
+   if (!codec) {
+     // This is an indication that FFmpeg has not been initialized or it has not
+     // been compiled/initialized with the correct set of codecs.
diff --git a/srcpkgs/qt5-webengine/template b/srcpkgs/qt5-webengine/template
index 84de5b12ecdda..b89fe4c1ad50a 100644
--- a/srcpkgs/qt5-webengine/template
+++ b/srcpkgs/qt5-webengine/template
@@ -1,9 +1,9 @@
 # Template file for 'qt5-webengine'
 pkgname=qt5-webengine
-version=5.15.11
-revision=5
+version=5.15.13
+revision=1
 _version="${version}-lts"
-_chromium_commit=be349eaf62e77955791d7bf29f893f1e8a37daf4
+_chromium_commit=e48df7803c7c98b0b2471c94057d32e44a301ad5
 archs="x86_64* i686* armv[67]* ppc64* aarch64*"
 create_wrksrc=yes
 build_style=qmake
@@ -32,8 +32,8 @@ license="GPL-3.0-or-later, LGPL-3.0-or-later"
 homepage="https://qt.io/"
 distfiles="https://github.com/qt/qtwebengine/archive/v${_version}.tar.gz
  https://github.com/qt/qtwebengine-chromium/archive/${_chromium_commit}.tar.gz"
-checksum="aa7466356c450c5f5870f979b93cd7e7e62da1165c328ffcab1a9928db18ad67
- 6f47ed8ab8cc062411f6f206da6353bc8263d6ed6d6290c689a05c01d91f646b"
+checksum="4b59838ed75ef788b59e1e412535a0e42dd9d311661fdeadb191b581ba815c63
+ a91686562b1d4e8b220e0bbcbab5feb64630e2de974b35ac034bf388af771a6c"
 
 no_generic_pkgconfig_link=yes
 build_options="sndio pipewire"

From e1efeea029f95d3d92cddb4a2932321823fc2437 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 067/115] qt5: update to 5.15.8

---
 ...erywhere-opensource-src-5.15.8-kf5-1.patch | 12913 ++++++++++++++++
 srcpkgs/qt5/template                          |    13 +-
 2 files changed, 12919 insertions(+), 7 deletions(-)
 create mode 100644 srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch

diff --git a/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch b/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch
new file mode 100644
index 0000000000000..966c98bcd3bb1
--- /dev/null
+++ b/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch
@@ -0,0 +1,12913 @@
+Submitted By:            Pierre Labastie <pierre_dot_labastie_at_neuf_dot_fr>
+Date:                    2023-01-05
+Initial Package Version: 5.15.8
+Upstream Status:         Applied (according to KDE)
+Origin:                  KDE patch set
+Description:             Patch set maintained by the KDE folks
+see https://dot.kde.org/2021/04/06/announcing-kdes-qt-5-patch-collection
+Patch generated using the procedure in
+https://wiki.linuxfromscratch.org/blfs/ticket/17476#comment:3
+
+Submodule qtbase 4ee4fc18..9cf586d6:
+diff --git a/qtbase/mkspecs/common/android/qplatformdefs.h b/qtbase/mkspecs/common/android/qplatformdefs.h
+index f75bc4093b..2bd59410d4 100644
+--- a/qtbase/mkspecs/common/android/qplatformdefs.h
++++ b/qtbase/mkspecs/common/android/qplatformdefs.h
+@@ -144,11 +144,7 @@
+ #define QT_SIGNAL_ARGS          int
+ #define QT_SIGNAL_IGNORE        SIG_IGN
+ 
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+ #define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+ 
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+diff --git a/qtbase/mkspecs/features/mac/sdk.mk b/qtbase/mkspecs/features/mac/sdk.mk
+index f30b5830b4..a32ceacb6c 100644
+--- a/qtbase/mkspecs/features/mac/sdk.mk
++++ b/qtbase/mkspecs/features/mac/sdk.mk
+@@ -1,6 +1,6 @@
+ 
+ ifeq ($(QT_MAC_SDK_NO_VERSION_CHECK),)
+-    CHECK_SDK_COMMAND = /usr/bin/xcrun --sdk $(EXPORT_QMAKE_MAC_SDK) -show-sdk-version 2>&1
++    CHECK_SDK_COMMAND = /usr/bin/xcrun --sdk $(EXPORT_QMAKE_MAC_SDK) -show-sdk-version 2>/dev/null
+     CURRENT_MAC_SDK_VERSION := $(shell DEVELOPER_DIR=$(EXPORT_QMAKE_XCODE_DEVELOPER_PATH) $(CHECK_SDK_COMMAND))
+     ifneq ($(CURRENT_MAC_SDK_VERSION),$(EXPORT_QMAKE_MAC_SDK_VERSION))
+         # We don't want to complain about out of date SDK unless the target needs to be remade.
+diff --git a/qtbase/mkspecs/linux-clang/qplatformdefs.h b/qtbase/mkspecs/linux-clang/qplatformdefs.h
+index a818d973f0..c1ab72fbc6 100644
+--- a/qtbase/mkspecs/linux-clang/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-clang/qplatformdefs.h
+@@ -79,14 +79,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-g++/qplatformdefs.h b/qtbase/mkspecs/linux-g++/qplatformdefs.h
+index 13523f0702..4d2750d9ec 100644
+--- a/qtbase/mkspecs/linux-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-g++/qplatformdefs.h
+@@ -79,14 +79,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ < 2)
+-#define QT_SOCKLEN_T            int
+-#else
+-#define QT_SOCKLEN_T            socklen_t
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-llvm/qplatformdefs.h b/qtbase/mkspecs/linux-llvm/qplatformdefs.h
+index dc750ab1ef..d3cc39b47f 100644
+--- a/qtbase/mkspecs/linux-llvm/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-llvm/qplatformdefs.h
+@@ -80,14 +80,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h b/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
+index 4c4e53da2a..83baffb3e3 100644
+--- a/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
+@@ -85,16 +85,9 @@
+ #include "../common/posix/qplatformdefs.h"
+ 
+ #undef QT_OPEN_LARGEFILE
+-#undef QT_SOCKLEN_T
+ 
+ #define QT_OPEN_LARGEFILE       0
+ 
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #ifndef SIOCGIFBRDADDR
+ #  define SIOCGIFBRDADDR 0x8919
+ #endif
+diff --git a/qtbase/mkspecs/lynxos-g++/qplatformdefs.h b/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
+index 4339ea2b23..6007af0055 100644
+--- a/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
+@@ -72,14 +72,6 @@
+ 
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp b/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
+index c3c184258f..32af3f8f29 100644
+--- a/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
++++ b/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
+@@ -10,6 +10,7 @@
+ #include "libANGLE/HandleAllocator.h"
+ 
+ #include <algorithm>
++#include <limits>
+ 
+ #include "common/debug.h"
+ 
+diff --git a/qtbase/src/3rdparty/forkfd/forkfd_linux.c b/qtbase/src/3rdparty/forkfd/forkfd_linux.c
+index ffe0e9a5e2..b1f5408d11 100644
+--- a/qtbase/src/3rdparty/forkfd/forkfd_linux.c
++++ b/qtbase/src/3rdparty/forkfd/forkfd_linux.c
+@@ -82,7 +82,8 @@ static int sys_clone(unsigned long cloneflags, int *ptid)
+     return syscall(__NR_clone, cloneflags, child_stack, stack_size, ptid, newtls, ctid);
+ #elif defined(__arc__) || defined(__arm__) || defined(__aarch64__) || defined(__mips__) || \
+     defined(__nds32__) || defined(__hppa__) || defined(__powerpc__) || defined(__i386__) || \
+-    defined(__x86_64__) || defined(__xtensa__) || defined(__alpha__) || defined(__riscv)
++    defined(__x86_64__) || defined(__xtensa__) || defined(__alpha__) || defined(__riscv) || \
++    defined(__loongarch__)
+     /* ctid and newtls are inverted on CONFIG_CLONE_BACKWARDS architectures,
+      * but since both values are 0, there's no harm. */
+     return syscall(__NR_clone, cloneflags, child_stack, ptid, ctid, newtls);
+diff --git a/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java b/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
+index 5792b5b2f5..2f74750fcf 100644
+--- a/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
++++ b/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
+@@ -116,6 +116,7 @@ public class QtNative
+     public static QtThread m_qtThread = new QtThread();
+     private static HashMap<String, Uri> m_cachedUris = new HashMap<String, Uri>();
+     private static ArrayList<String> m_knownDirs = new ArrayList<String>();
++    private static final String NoPermissionErrorMessage = "No permissions to open Uri";
+ 
+     private static final Runnable runPendingCppRunnablesRunnable = new Runnable() {
+         @Override
+@@ -193,11 +194,10 @@ public class QtNative
+                     return iterUri;
+             }
+ 
+-            // Android 6 and earlier could still manage to open the file so we can return the
+-            // parsed uri here
+-            if (Build.VERSION.SDK_INT < 24)
+-                return parsedUri;
+-            return null;
++            // if we only have transient permissions on uri all the above will fail,
++            // but we will be able to read the file anyway, so continue with uri here anyway
++            // and check for SecurityExceptions later
++            return parsedUri;
+         } catch (SecurityException e) {
+             e.printStackTrace();
+             return null;
+@@ -244,7 +244,7 @@ public class QtNative
+         int error = -1;
+ 
+         if (uri == null) {
+-            Log.e(QtTAG, "openFdForContentUrl(): No permissions to open Uri");
++            Log.e(QtTAG, "openFdForContentUrl(): " + NoPermissionErrorMessage);
+             return error;
+         }
+ 
+@@ -254,12 +254,13 @@ public class QtNative
+             return fdDesc.detachFd();
+         } catch (FileNotFoundException e) {
+             e.printStackTrace();
+-            return error;
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "openFdForContentUrl(): Invalid Uri");
+             e.printStackTrace();
+-            return error;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return error;
+     }
+ 
+     public static long getSize(Context context, String contentUrl)
+@@ -270,7 +271,7 @@ public class QtNative
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+ 
+         if (uri == null) {
+-            Log.e(QtTAG, "getSize(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return size;
+         } else if (!m_cachedUris.containsKey(contentUrl)) {
+             m_cachedUris.put(contentUrl, uri);
+@@ -288,12 +289,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "getSize(): Invalid Uri");
+             e.printStackTrace();
+-            return size;
+         }  catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "getSize(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return size;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return size;
+     }
+ 
+     public static boolean checkFileExists(Context context, String contentUrl)
+@@ -303,7 +305,7 @@ public class QtNative
+         if (uri == null)
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+         if (uri == null) {
+-            Log.e(QtTAG, "checkFileExists(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return exists;
+         } else {
+             if (!m_cachedUris.containsKey(contentUrl))
+@@ -321,12 +323,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "checkFileExists(): Invalid Uri");
+             e.printStackTrace();
+-            return exists;
+         } catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "checkFileExists(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return false;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return exists;
+     }
+ 
+     public static boolean checkIfWritable(Context context, String contentUrl)
+@@ -344,7 +347,7 @@ public class QtNative
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+         }
+         if (uri == null) {
+-            Log.e(QtTAG, "isDir(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return isDir;
+         } else {
+             if (!m_cachedUris.containsKey(contentUrl))
+@@ -374,12 +377,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "checkIfDir(): Invalid Uri");
+             e.printStackTrace();
+-            return false;
+         } catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "checkIfDir(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return false;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return false;
+     }
+     public static String[] listContentsFromTreeUri(Context context, String contentUrl)
+     {
+diff --git a/qtbase/src/concurrent/qtconcurrentreducekernel.h b/qtbase/src/concurrent/qtconcurrentreducekernel.h
+index 8f9a938952..a98dedef2e 100644
+--- a/qtbase/src/concurrent/qtconcurrentreducekernel.h
++++ b/qtbase/src/concurrent/qtconcurrentreducekernel.h
+@@ -212,11 +212,13 @@ public:
+ 
+     inline bool shouldThrottle()
+     {
++        std::lock_guard<QMutex> locker(mutex);
+         return (resultsMapSize > (ReduceQueueThrottleLimit * threadCount));
+     }
+ 
+     inline bool shouldStartThread()
+     {
++        std::lock_guard<QMutex> locker(mutex);
+         return (resultsMapSize <= (ReduceQueueStartLimit * threadCount));
+     }
+ };
+diff --git a/qtbase/src/concurrent/qtconcurrentthreadengine.cpp b/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
+index ea6ce3ac42..7f91a2ba68 100644
+--- a/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
++++ b/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
+@@ -176,6 +176,39 @@ void ThreadEngineBase::startSingleThreaded()
+     finish();
+ }
+ 
++void ThreadEngineBase::startBlocking()
++{
++    start();
++    barrier.acquire();
++    startThreads();
++
++    bool throttled = false;
++#ifndef QT_NO_EXCEPTIONS
++    try {
++#endif
++        while (threadFunction() == ThrottleThread) {
++            if (threadThrottleExit()) {
++                throttled = true;
++                break;
++            }
++        }
++#ifndef QT_NO_EXCEPTIONS
++    } catch (QException &e) {
++        handleException(e);
++    } catch (...) {
++        handleException(QUnhandledException());
++    }
++#endif
++
++    if (throttled == false) {
++        barrier.release();
++    }
++
++    barrier.wait();
++    finish();
++    exceptionStore.throwPossibleException();
++}
++
+ void ThreadEngineBase::startThread()
+ {
+     startThreadInternal();
+diff --git a/qtbase/src/concurrent/qtconcurrentthreadengine.h b/qtbase/src/concurrent/qtconcurrentthreadengine.h
+index 7c30cebdbc..a4c8548cc4 100644
+--- a/qtbase/src/concurrent/qtconcurrentthreadengine.h
++++ b/qtbase/src/concurrent/qtconcurrentthreadengine.h
+@@ -91,6 +91,7 @@ public:
+     ThreadEngineBase();
+     virtual ~ThreadEngineBase();
+     void startSingleThreaded();
++    void startBlocking();
+     void startThread();
+     bool isCanceled();
+     void waitForResume();
+@@ -143,6 +144,15 @@ public:
+         return result();
+     }
+ 
++    // Runs the user algorithm using multiple threads.
++    // This function blocks until the algorithm is finished,
++    // and then returns the result.
++    T *startBlocking()
++    {
++        ThreadEngineBase::startBlocking();
++        return result();
++    }
++
+     // Runs the user algorithm using multiple threads.
+     // Does not block, returns a future.
+     QFuture<T> startAsynchronously()
+@@ -223,6 +233,13 @@ class ThreadEngineStarter : public ThreadEngineStarterBase<T>
+ public:
+     ThreadEngineStarter(TypedThreadEngine *eng)
+         : Base(eng) { }
++
++    T startBlocking()
++    {
++        T t = *this->threadEngine->startBlocking();
++        delete this->threadEngine;
++        return t;
++    }
+ };
+ 
+ // Full template specialization where T is void.
+@@ -232,6 +249,12 @@ class ThreadEngineStarter<void> : public ThreadEngineStarterBase<void>
+ public:
+     ThreadEngineStarter(ThreadEngine<void> *_threadEngine)
+         : ThreadEngineStarterBase<void>(_threadEngine) {}
++
++    void startBlocking()
++    {
++        this->threadEngine->startBlocking();
++        delete this->threadEngine;
++    }
+ };
+ 
+ //! [qtconcurrentthreadengine-1]
+diff --git a/qtbase/src/corelib/animation/qvariantanimation.cpp b/qtbase/src/corelib/animation/qvariantanimation.cpp
+index 98b02f0202..eac1524107 100644
+--- a/qtbase/src/corelib/animation/qvariantanimation.cpp
++++ b/qtbase/src/corelib/animation/qvariantanimation.cpp
+@@ -276,7 +276,9 @@ void QVariantAnimationPrivate::setCurrentValueForProgress(const qreal progress)
+ 
+     const qreal startProgress = currentInterval.start.first;
+     const qreal endProgress = currentInterval.end.first;
+-    const qreal localProgress = (progress - startProgress) / (endProgress - startProgress);
++    const qreal localProgress =
++            qIsNull(progress - startProgress) ? 0.0 // avoid 0/0 below
++            /* else */                        : (progress - startProgress) / (endProgress - startProgress);
+ 
+     QVariant ret = q->interpolated(currentInterval.start.second,
+                                    currentInterval.end.second,
+diff --git a/qtbase/src/corelib/global/qnamespace.h b/qtbase/src/corelib/global/qnamespace.h
+index ad4150b317..bf19b1627b 100644
+--- a/qtbase/src/corelib/global/qnamespace.h
++++ b/qtbase/src/corelib/global/qnamespace.h
+@@ -1864,7 +1864,7 @@ public:
+     QT_Q_ENUM(TimerType)
+     QT_Q_ENUM(ScrollPhase)
+     QT_Q_ENUM(MouseEventSource)
+-    QT_Q_FLAG(MouseEventFlag)
++    QT_Q_FLAG(MouseEventFlags)
+     QT_Q_ENUM(ChecksumType)
+     QT_Q_ENUM(HighDpiScaleFactorRoundingPolicy)
+     QT_Q_ENUM(TabFocusBehavior)
+diff --git a/qtbase/src/corelib/global/qrandom.cpp b/qtbase/src/corelib/global/qrandom.cpp
+index 10672c1f92..25f87c7e6a 100644
+--- a/qtbase/src/corelib/global/qrandom.cpp
++++ b/qtbase/src/corelib/global/qrandom.cpp
+@@ -383,7 +383,6 @@ struct QRandomGenerator::SystemAndGlobalGenerators
+ 
+         constexpr SystemAndGlobalGenerators g = {};
+         Q_UNUSED(g);
+-        Q_STATIC_ASSERT(std::is_literal_type<SystemAndGlobalGenerators>::value);
+ #endif
+     }
+ 
+diff --git a/qtbase/src/corelib/io/qbuffer.cpp b/qtbase/src/corelib/io/qbuffer.cpp
+index 595fcd2724..032c0ddd4b 100644
+--- a/qtbase/src/corelib/io/qbuffer.cpp
++++ b/qtbase/src/corelib/io/qbuffer.cpp
+@@ -41,6 +41,8 @@
+ #include <QtCore/qmetaobject.h>
+ #include "private/qiodevice_p.h"
+ 
++#include <limits>
++
+ QT_BEGIN_NAMESPACE
+ 
+ /** QBufferPrivate **/
+@@ -366,7 +368,9 @@ qint64 QBuffer::size() const
+ bool QBuffer::seek(qint64 pos)
+ {
+     Q_D(QBuffer);
+-    if (pos > d->buf->size() && isWritable()) {
++    const auto oldBufSize = d->buf->size();
++    constexpr qint64 MaxSeekPos = (std::numeric_limits<decltype(oldBufSize)>::max)();
++    if (pos <= MaxSeekPos && pos > oldBufSize && isWritable()) {
+         if (seek(d->buf->size())) {
+             const qint64 gapSize = pos - d->buf->size();
+             if (write(QByteArray(gapSize, 0)) != gapSize) {
+@@ -377,7 +381,7 @@ bool QBuffer::seek(qint64 pos)
+             return false;
+         }
+     } else if (pos > d->buf->size() || pos < 0) {
+-        qWarning("QBuffer::seek: Invalid pos: %d", int(pos));
++        qWarning("QBuffer::seek: Invalid pos: %lld", pos);
+         return false;
+     }
+     return QIODevice::seek(pos);
+diff --git a/qtbase/src/corelib/io/qfilesystemengine_win.cpp b/qtbase/src/corelib/io/qfilesystemengine_win.cpp
+index 81d3a71986..c86ed1f9b0 100644
+--- a/qtbase/src/corelib/io/qfilesystemengine_win.cpp
++++ b/qtbase/src/corelib/io/qfilesystemengine_win.cpp
+@@ -664,14 +664,14 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry)
+     return QFileSystemEntry(ret, QFileSystemEntry::FromInternalPath());
+ }
+ 
+-#if defined(Q_CC_MINGW) && WINVER < 0x0602 //  Windows 8 onwards
++#if defined(Q_CC_MINGW) && WINVER < 0x0602 && _WIN32_WINNT < _WIN32_WINNT_WIN8 //  Windows 8 onwards
+ 
+ typedef struct _FILE_ID_INFO {
+     ULONGLONG VolumeSerialNumber;
+     FILE_ID_128 FileId;
+ } FILE_ID_INFO, *PFILE_ID_INFO;
+ 
+-#endif // if defined (Q_CC_MINGW) && WINVER < 0x0602
++#endif // if defined(Q_CC_MINGW) && WINVER < 0x0602 && _WIN32_WINNT < _WIN32_WINNT_WIN8
+ 
+ // File ID for Windows up to version 7 and FAT32 drives
+ static inline QByteArray fileId(HANDLE handle)
+diff --git a/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp b/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
+index 94d9d06bcb..27e0b13b0b 100644
+--- a/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
++++ b/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
+@@ -366,7 +366,9 @@ void QInotifyFileSystemWatcherEngine::readFromInotify()
+     // qDebug("QInotifyFileSystemWatcherEngine::readFromInotify");
+ 
+     int buffSize = 0;
+-    ioctl(inotifyFd, FIONREAD, (char *) &buffSize);
++    if (ioctl(inotifyFd, FIONREAD, (char *) &buffSize) == -1 || buffSize == 0)
++        return;
++
+     QVarLengthArray<char, 4096> buffer(buffSize);
+     buffSize = read(inotifyFd, buffer.data(), buffSize);
+     char *at = buffer.data();
+diff --git a/qtbase/src/corelib/io/qlockfile_win.cpp b/qtbase/src/corelib/io/qlockfile_win.cpp
+index 277f8d4230..38ecef5550 100644
+--- a/qtbase/src/corelib/io/qlockfile_win.cpp
++++ b/qtbase/src/corelib/io/qlockfile_win.cpp
+@@ -48,6 +48,8 @@
+ #include "QtCore/qdebug.h"
+ #include "QtCore/qthread.h"
+ 
++#include "private/qsystemlibrary_p.h"
++
+ QT_BEGIN_NAMESPACE
+ 
+ static inline bool fileExists(const wchar_t *fileName)
+@@ -150,7 +152,7 @@ QString QLockFilePrivate::processNameByPid(qint64 pid)
+ #if !defined(Q_OS_WINRT)
+     typedef DWORD (WINAPI *GetModuleFileNameExFunc)(HANDLE, HMODULE, LPTSTR, DWORD);
+ 
+-    HMODULE hPsapi = LoadLibraryA("psapi");
++    HMODULE hPsapi = QSystemLibrary::load(L"psapi");
+     if (!hPsapi)
+         return QString();
+     GetModuleFileNameExFunc qGetModuleFileNameEx = reinterpret_cast<GetModuleFileNameExFunc>(
+diff --git a/qtbase/src/corelib/io/qprocess_unix.cpp b/qtbase/src/corelib/io/qprocess_unix.cpp
+index 50390e57f5..15c8f30745 100644
+--- a/qtbase/src/corelib/io/qprocess_unix.cpp
++++ b/qtbase/src/corelib/io/qprocess_unix.cpp
+@@ -1,7 +1,7 @@
+ /****************************************************************************
+ **
+ ** Copyright (C) 2016 The Qt Company Ltd.
+-** Copyright (C) 2016 Intel Corporation.
++** Copyright (C) 2022 Intel Corporation.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtCore module of the Qt Toolkit.
+@@ -422,14 +422,15 @@ void QProcessPrivate::startProcess()
+     // Add the program name to the argument list.
+     argv[0] = nullptr;
+     if (!program.contains(QLatin1Char('/'))) {
++        // findExecutable() returns its argument if it's an absolute path,
++        // otherwise it searches $PATH; returns empty if not found (we handle
++        // that case much later)
+         const QString &exeFilePath = QStandardPaths::findExecutable(program);
+-        if (!exeFilePath.isEmpty()) {
+-            const QByteArray &tmp = QFile::encodeName(exeFilePath);
+-            argv[0] = ::strdup(tmp.constData());
+-        }
+-    }
+-    if (!argv[0])
++        const QByteArray &tmp = QFile::encodeName(exeFilePath);
++        argv[0] = ::strdup(tmp.constData());
++    } else {
+         argv[0] = ::strdup(encodedProgramName.constData());
++    }
+ 
+     // Add every argument to the list
+     for (int i = 0; i < arguments.count(); ++i)
+@@ -983,15 +984,16 @@ bool QProcessPrivate::startDetached(qint64 *pid)
+                 envp = _q_dupEnvironment(environment.d.constData()->vars, &envc);
+             }
+ 
+-            QByteArray tmp;
+             if (!program.contains(QLatin1Char('/'))) {
++                // findExecutable() returns its argument if it's an absolute path,
++                // otherwise it searches $PATH; returns empty if not found (we handle
++                // that case much later)
+                 const QString &exeFilePath = QStandardPaths::findExecutable(program);
+-                if (!exeFilePath.isEmpty())
+-                    tmp = QFile::encodeName(exeFilePath);
++                const QByteArray &tmp = QFile::encodeName(exeFilePath);
++                argv[0] = ::strdup(tmp.constData());
++            } else {
++                argv[0] = ::strdup(QFile::encodeName(program));
+             }
+-            if (tmp.isEmpty())
+-                tmp = QFile::encodeName(program);
+-            argv[0] = tmp.data();
+ 
+             if (envp)
+                 qt_safe_execve(argv[0], argv, envp);
+diff --git a/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp b/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
+index 3a79c502af..997a634e76 100644
+--- a/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
++++ b/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
+@@ -3196,9 +3196,8 @@ bool QAbstractItemModel::beginMoveColumns(const QModelIndex &sourceParent, int s
+     destinationChange.needsAdjust = destinationParent.isValid() && destinationParent.row() >= sourceLast && destinationParent.parent() == sourceParent;
+     d->changes.push(destinationChange);
+ 
+-    d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Horizontal);
+-
+     emit columnsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, QPrivateSignal());
++    d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Horizontal);
+     return true;
+ }
+ 
+@@ -3231,7 +3230,6 @@ void QAbstractItemModel::endMoveColumns()
+       adjustedSource = createIndex(adjustedSource.row(), adjustedSource.column() + numMoved, adjustedSource.internalPointer());
+ 
+     d->itemsMoved(adjustedSource, removeChange.first, removeChange.last, adjustedDestination, insertChange.first, Qt::Horizontal);
+-
+     emit columnsMoved(adjustedSource, removeChange.first, removeChange.last, adjustedDestination, insertChange.first, QPrivateSignal());
+ }
+ 
+diff --git a/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+index dc6379d9fb..c5e287ee84 100644
+--- a/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
++++ b/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+@@ -939,8 +939,9 @@ void QSortFilterProxyModelPrivate::insert_source_items(
+                 q->beginInsertColumns(proxy_parent, proxy_start, proxy_end);
+         }
+ 
+-        for (int i = 0; i < source_items.size(); ++i)
+-            proxy_to_source.insert(proxy_start + i, source_items.at(i));
++        // TODO: use the range QList::insert() overload once it is implemented (QTBUG-58633).
++        proxy_to_source.insert(proxy_start, source_items.size(), 0);
++        std::copy(source_items.cbegin(), source_items.cend(), proxy_to_source.begin() + proxy_start);
+ 
+         build_source_to_proxy_mapping(proxy_to_source, source_to_proxy);
+ 
+@@ -3123,8 +3124,9 @@ bool QSortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex &
+ 
+     if (d->filter_data.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();
+@@ -3133,9 +3135,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.hasMatch(key);
+ }
+diff --git a/qtbase/src/corelib/kernel/qcoreapplication.cpp b/qtbase/src/corelib/kernel/qcoreapplication.cpp
+index ca2864df83..132b2eae52 100644
+--- a/qtbase/src/corelib/kernel/qcoreapplication.cpp
++++ b/qtbase/src/corelib/kernel/qcoreapplication.cpp
+@@ -1157,7 +1157,7 @@ static bool doNotify(QObject *receiver, QEvent *event)
+ bool QCoreApplicationPrivate::sendThroughApplicationEventFilters(QObject *receiver, QEvent *event)
+ {
+     // We can't access the application event filters outside of the main thread (race conditions)
+-    Q_ASSERT(receiver->d_func()->threadData.loadRelaxed()->thread.loadAcquire() == mainThread());
++    Q_ASSERT(receiver->d_func()->threadData.loadAcquire()->thread.loadRelaxed() == mainThread());
+ 
+     if (extraData) {
+         // application event filters are only called for objects in the GUI thread
+diff --git a/qtbase/src/corelib/kernel/qobject.cpp b/qtbase/src/corelib/kernel/qobject.cpp
+index 1eb79138d9..36cd780ee1 100644
+--- a/qtbase/src/corelib/kernel/qobject.cpp
++++ b/qtbase/src/corelib/kernel/qobject.cpp
+@@ -1010,7 +1010,7 @@ QObject::~QObject()
+         emit destroyed(this);
+     }
+ 
+-    if (d->declarativeData) {
++    if (!d->isDeletingChildren && d->declarativeData) {
+         if (static_cast<QAbstractDeclarativeDataImpl*>(d->declarativeData)->ownedByQml1) {
+             if (QAbstractDeclarativeData::destroyed_qml1)
+                 QAbstractDeclarativeData::destroyed_qml1(d->declarativeData, this);
+@@ -1580,7 +1580,7 @@ void QObject::moveToThread(QThread *targetThread)
+ 
+     QThreadData *currentData = QThreadData::current();
+     QThreadData *targetData = targetThread ? QThreadData::get2(targetThread) : nullptr;
+-    QThreadData *thisThreadData = d->threadData.loadRelaxed();
++    QThreadData *thisThreadData = d->threadData.loadAcquire();
+     if (!thisThreadData->thread.loadAcquire() && currentData == targetData) {
+         // one exception to the rule: we allow moving objects with no thread affinity to the current thread
+         currentData = d->threadData;
+@@ -2620,7 +2620,7 @@ int QObject::receivers(const char *signal) const
+         if (!d->isSignalConnected(signal_index))
+             return receivers;
+ 
+-        if (d->declarativeData && QAbstractDeclarativeData::receivers) {
++        if (!d->isDeletingChildren && d->declarativeData && QAbstractDeclarativeData::receivers) {
+             receivers += QAbstractDeclarativeData::receivers(d->declarativeData, this,
+                                                              signal_index);
+         }
+diff --git a/qtbase/src/corelib/kernel/qobject_p.h b/qtbase/src/corelib/kernel/qobject_p.h
+index 0b827a52ca..13ffb88999 100644
+--- a/qtbase/src/corelib/kernel/qobject_p.h
++++ b/qtbase/src/corelib/kernel/qobject_p.h
+@@ -444,7 +444,7 @@ inline void QObjectPrivate::checkForIncompatibleLibraryVersion(int version) cons
+ 
+ inline bool QObjectPrivate::isDeclarativeSignalConnected(uint signal_index) const
+ {
+-    return declarativeData && QAbstractDeclarativeData::isSignalConnected
++    return !isDeletingChildren && declarativeData && QAbstractDeclarativeData::isSignalConnected
+             && QAbstractDeclarativeData::isSignalConnected(declarativeData, q_func(), signal_index);
+ }
+ 
+diff --git a/qtbase/src/corelib/kernel/qtranslator.cpp b/qtbase/src/corelib/kernel/qtranslator.cpp
+index 2812ffb7ea..bc0177c5ec 100644
+--- a/qtbase/src/corelib/kernel/qtranslator.cpp
++++ b/qtbase/src/corelib/kernel/qtranslator.cpp
+@@ -902,7 +902,7 @@ static QString getMessage(const uchar *m, const uchar *end, const char *context,
+             goto end;
+         case Tag_Translation: {
+             int len = read32(m);
+-            if (len % 1)
++            if (len & 1)
+                 return QString();
+             m += 4;
+             if (!numerus--) {
+diff --git a/qtbase/src/corelib/mimetypes/qmimedatabase.cpp b/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
+index 9de22cef33..ff868a3268 100644
+--- a/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
+@@ -389,20 +389,23 @@ QMimeType QMimeDatabasePrivate::mimeTypeForFileNameAndData(const QString &fileNa
+         // Disambiguate conflicting extensions (if magic matching found something)
+         if (candidateByData.isValid() && magicAccuracy > 0) {
+             const QString sniffedMime = candidateByData.name();
+-            // If the sniffedMime matches a glob match, use it
++            // If the sniffedMime matches a highest-weight glob match, use it
+             if (candidatesByName.m_matchingMimeTypes.contains(sniffedMime)) {
+                 *accuracyPtr = 100;
+                 return candidateByData;
+             }
+-            for (const QString &m : qAsConst(candidatesByName.m_matchingMimeTypes)) {
++            for (const QString &m : qAsConst(candidatesByName.m_allMatchingMimeTypes)) {
+                 if (inherits(m, sniffedMime)) {
+                     // We have magic + pattern pointing to this, so it's a pretty good match
+                     *accuracyPtr = 100;
+                     return mimeTypeForName(m);
+                 }
+             }
+-            *accuracyPtr = magicAccuracy;
+-            return candidateByData;
++            if (candidatesByName.m_allMatchingMimeTypes.isEmpty()) {
++                // No glob, use magic
++                *accuracyPtr = magicAccuracy;
++                return candidateByData;
++            }
+         }
+     }
+ 
+diff --git a/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp b/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
+index a81112d227..fa8f4c545d 100644
+--- a/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
+@@ -83,7 +83,10 @@ void QMimeGlobMatchResult::addMatch(const QString &mimeType, int weight, const Q
+     }
+     if (!m_matchingMimeTypes.contains(mimeType)) {
+         m_matchingMimeTypes.append(mimeType);
+-        m_allMatchingMimeTypes.append(mimeType);
++        if (replace)
++            m_allMatchingMimeTypes.prepend(mimeType); // highest-weight first
++        else
++            m_allMatchingMimeTypes.append(mimeType);
+         m_knownSuffixLength = knownSuffixLength;
+     }
+ }
+@@ -94,7 +97,7 @@ QMimeGlobPattern::PatternType QMimeGlobPattern::detectPatternType(const QString
+     if (!patternLength)
+         return OtherPattern;
+ 
+-    const bool starCount = pattern.count(QLatin1Char('*')) == 1;
++    const int starCount = pattern.count(QLatin1Char('*'));
+     const bool hasSquareBracket = pattern.indexOf(QLatin1Char('[')) != -1;
+     const bool hasQuestionMark = pattern.indexOf(QLatin1Char('?')) != -1;
+ 
+@@ -106,10 +109,10 @@ QMimeGlobPattern::PatternType QMimeGlobPattern::detectPatternType(const QString
+             // Patterns like "README*" (well this is currently the only one like that...)
+             if (pattern.at(patternLength - 1) == QLatin1Char('*'))
+                 return PrefixPattern;
+-        }
+-        // Names without any wildcards like "README"
+-        if (starCount == 0)
++        } else if (starCount == 0) {
++            // Names without any wildcards like "README"
+             return LiteralPattern;
++        }
+     }
+ 
+     if (pattern == QLatin1String("[0-9][0-9][0-9].vdr"))
+diff --git a/qtbase/src/corelib/mimetypes/qmimeprovider.cpp b/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
+index 258dddf8cb..4642d0f2d0 100644
+--- a/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
+@@ -244,15 +244,18 @@ void QMimeBinaryProvider::addFileNameMatches(const QString &fileName, QMimeGlobM
+     const QString lowerFileName = fileName.toLower();
+     // Check literals (e.g. "Makefile")
+     matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosLiteralListOffset), fileName);
+-    // Check complex globs (e.g. "callgrind.out[0-9]*")
+-    matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosGlobListOffset), fileName);
+     // Check the very common *.txt cases with the suffix tree
+-    const int reverseSuffixTreeOffset = m_cacheFile->getUint32(PosReverseSuffixTreeOffset);
+-    const int numRoots = m_cacheFile->getUint32(reverseSuffixTreeOffset);
+-    const int firstRootOffset = m_cacheFile->getUint32(reverseSuffixTreeOffset + 4);
+-    matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, lowerFileName, lowerFileName.length() - 1, false);
++    if (result.m_matchingMimeTypes.isEmpty()) {
++        const int reverseSuffixTreeOffset = m_cacheFile->getUint32(PosReverseSuffixTreeOffset);
++        const int numRoots = m_cacheFile->getUint32(reverseSuffixTreeOffset);
++        const int firstRootOffset = m_cacheFile->getUint32(reverseSuffixTreeOffset + 4);
++        matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, lowerFileName, lowerFileName.length() - 1, false);
++        if (result.m_matchingMimeTypes.isEmpty())
++            matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, fileName, fileName.length() - 1, true);
++    }
++    // Check complex globs (e.g. "callgrind.out[0-9]*" or "README*")
+     if (result.m_matchingMimeTypes.isEmpty())
+-        matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, fileName, fileName.length() - 1, true);
++        matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosGlobListOffset), fileName);
+ }
+ 
+ void QMimeBinaryProvider::matchGlobList(QMimeGlobMatchResult &result, CacheFile *cacheFile, int off, const QString &fileName)
+diff --git a/qtbase/src/corelib/serialization/qjsonparser.cpp b/qtbase/src/corelib/serialization/qjsonparser.cpp
+index 17e6f111ab..2e40b6c8fb 100644
+--- a/qtbase/src/corelib/serialization/qjsonparser.cpp
++++ b/qtbase/src/corelib/serialization/qjsonparser.cpp
+@@ -379,10 +379,30 @@ error:
+     return QCborValue();
+ }
+ 
++// We need to retain the _last_ value for any duplicate keys and we need to deref containers.
++// Therefore the manual implementation of std::unique().
++template<typename Iterator, typename Compare, typename Assign>
++static Iterator customAssigningUniqueLast(Iterator first, Iterator last,
++                                          Compare compare, Assign assign)
++{
++    first = std::adjacent_find(first, last, compare);
++    if (first == last)
++        return last;
++
++    Iterator result = first;
++    while (++first != last) {
++        if (!compare(*result, *first))
++            ++result;
++        if (result != first)
++            assign(*result, *first);
++    }
++
++    return ++result;
++}
++
+ static void sortContainer(QCborContainerPrivate *container)
+ {
+     using Forward = QJsonPrivate::KeyIterator;
+-    using Reverse = std::reverse_iterator<Forward>;
+     using Value = Forward::value_type;
+ 
+     auto compare = [container](const Value &a, const Value &b)
+@@ -420,17 +440,31 @@ static void sortContainer(QCborContainerPrivate *container)
+         }
+     };
+ 
+-    std::sort(Forward(container->elements.begin()), Forward(container->elements.end()),
+-              [&compare](const Value &a, const Value &b) { return compare(a, b) < 0; });
++    // The elements' containers are owned by the outer container, not by the elements themselves.
++    auto move = [](Forward::reference target, Forward::reference source)
++    {
++        QtCbor::Element &targetValue = target.value();
++
++        // If the target has a container, deref it before overwriting, so that we don't leak.
++        if (targetValue.flags & QtCbor::Element::IsContainer)
++            targetValue.container->deref();
++
++        // Do not move, so that we can clear the value afterwards.
++        target = source;
++
++        // Clear the source value, so that we don't store the same container twice.
++        source.value() = QtCbor::Element();
++    };
++
++    std::stable_sort(
++                Forward(container->elements.begin()), Forward(container->elements.end()),
++                [&compare](const Value &a, const Value &b) { return compare(a, b) < 0; });
+ 
+-    // We need to retain the _last_ value for any duplicate keys. Therefore the reverse dance here.
+-    auto it = std::unique(Reverse(container->elements.end()), Reverse(container->elements.begin()),
+-                          [&compare](const Value &a, const Value &b) {
+-        return compare(a, b) == 0;
+-    }).base().elementsIterator();
++    Forward result = customAssigningUniqueLast(
++                Forward(container->elements.begin()),  Forward(container->elements.end()),
++                [&compare](const Value &a, const Value &b) { return compare(a, b) == 0; }, move);
+ 
+-    // The erase from beginning is expensive but hopefully rare.
+-    container->elements.erase(container->elements.begin(), it);
++    container->elements.erase(result.elementsIterator(), container->elements.end());
+ }
+ 
+ 
+diff --git a/qtbase/src/corelib/serialization/qxmlstream.cpp b/qtbase/src/corelib/serialization/qxmlstream.cpp
+index b2f846544d..7cd457ba3a 100644
+--- a/qtbase/src/corelib/serialization/qxmlstream.cpp
++++ b/qtbase/src/corelib/serialization/qxmlstream.cpp
+@@ -980,7 +980,7 @@ inline uint QXmlStreamReaderPrivate::peekChar()
+ bool QXmlStreamReaderPrivate::scanUntil(const char *str, short tokenToInject)
+ {
+     int pos = textBuffer.size();
+-    int oldLineNumber = lineNumber;
++    const auto oldLineNumber = lineNumber;
+ 
+     uint c;
+     while ((c = getChar()) != StreamEOF) {
+diff --git a/qtbase/src/corelib/text/qstring.cpp b/qtbase/src/corelib/text/qstring.cpp
+index 3e88ab4859..8deeae47bb 100644
+--- a/qtbase/src/corelib/text/qstring.cpp
++++ b/qtbase/src/corelib/text/qstring.cpp
+@@ -12312,7 +12312,7 @@ static qsizetype qLastIndexOf(Haystack haystack0, qsizetype from,
+     const auto needle = needle0.data();
+     const auto *end = haystack;
+     haystack += from;
+-    const std::size_t sl_minus_1 = sl - 1;
++    const std::size_t sl_minus_1 = sl ? sl - 1 : 0;
+     const auto *n = needle + sl_minus_1;
+     const auto *h = haystack + sl_minus_1;
+     std::size_t hashNeedle = 0, hashHaystack = 0;
+diff --git a/qtbase/src/corelib/text/qstringiterator_p.h b/qtbase/src/corelib/text/qstringiterator_p.h
+index 219589b6e4..1d0c66cc78 100644
+--- a/qtbase/src/corelib/text/qstringiterator_p.h
++++ b/qtbase/src/corelib/text/qstringiterator_p.h
+@@ -61,6 +61,8 @@ class QStringIterator
+ {
+     QString::const_iterator i, pos, e;
+     Q_STATIC_ASSERT((std::is_same<QString::const_iterator, const QChar *>::value));
++    static bool less(const QChar *lhs, const QChar *rhs) noexcept
++    { return std::less<QString::const_iterator>{}(lhs, rhs); }
+ public:
+     explicit QStringIterator(QStringView string, qsizetype idx = 0)
+         : i(string.begin()),
+@@ -95,7 +97,8 @@ public:
+ 
+     inline void setPosition(QString::const_iterator position)
+     {
+-        Q_ASSERT_X(i <= position && position <= e, Q_FUNC_INFO, "position out of bounds");
++        Q_ASSERT_X(!less(position, i) && !less(e, position),
++                   Q_FUNC_INFO, "position out of bounds");
+         pos = position;
+     }
+ 
+@@ -103,7 +106,7 @@ public:
+ 
+     inline bool hasNext() const
+     {
+-        return pos < e;
++        return less(pos, e);
+     }
+ 
+     inline void advance()
+@@ -120,16 +123,20 @@ public:
+     {
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+-        if (Q_UNLIKELY((pos++)->isHighSurrogate()))
++        if (Q_UNLIKELY((pos++)->isHighSurrogate())) {
++            Q_ASSERT(hasNext() && pos->isLowSurrogate());
+             ++pos;
++        }
+     }
+ 
+     inline uint peekNextUnchecked() const
+     {
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+-        if (Q_UNLIKELY(pos->isHighSurrogate()))
++        if (Q_UNLIKELY(pos->isHighSurrogate())) {
++            Q_ASSERT(less(pos + 1, e) && pos[1].isLowSurrogate());
+             return QChar::surrogateToUcs4(pos[0], pos[1]);
++        }
+ 
+         return pos->unicode();
+     }
+@@ -155,8 +162,10 @@ public:
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+         const QChar cur = *pos++;
+-        if (Q_UNLIKELY(cur.isHighSurrogate()))
++        if (Q_UNLIKELY(cur.isHighSurrogate())) {
++            Q_ASSERT(hasNext() && pos->isLowSurrogate());
+             return QChar::surrogateToUcs4(cur, *pos++);
++        }
+         return cur.unicode();
+     }
+ 
+@@ -166,7 +175,7 @@ public:
+ 
+         const QChar uc = *pos++;
+         if (Q_UNLIKELY(uc.isSurrogate())) {
+-            if (Q_LIKELY(uc.isHighSurrogate() && pos < e && pos->isLowSurrogate()))
++            if (Q_LIKELY(uc.isHighSurrogate() && hasNext() && pos->isLowSurrogate()))
+                 return QChar::surrogateToUcs4(uc, *pos++);
+             return invalidAs;
+         }
+@@ -178,7 +187,7 @@ public:
+ 
+     inline bool hasPrevious() const
+     {
+-        return pos > i;
++        return less(i, pos);
+     }
+ 
+     inline void recede()
+@@ -196,16 +205,20 @@ public:
+     {
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+-        if (Q_UNLIKELY((--pos)->isLowSurrogate()))
++        if (Q_UNLIKELY((--pos)->isLowSurrogate())) {
++            Q_ASSERT(hasPrevious() && pos[-1].isHighSurrogate());
+             --pos;
++        }
+     }
+ 
+     inline uint peekPreviousUnchecked() const
+     {
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+-        if (Q_UNLIKELY(pos[-1].isLowSurrogate()))
++        if (Q_UNLIKELY(pos[-1].isLowSurrogate())) {
++            Q_ASSERT(less(i + 1, pos) && pos[-2].isHighSurrogate());
+             return QChar::surrogateToUcs4(pos[-2], pos[-1]);
++        }
+         return pos[-1].unicode();
+     }
+ 
+@@ -230,8 +243,10 @@ public:
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+         const QChar cur = *--pos;
+-        if (Q_UNLIKELY(cur.isLowSurrogate()))
++        if (Q_UNLIKELY(cur.isLowSurrogate())) {
++            Q_ASSERT(hasPrevious() && pos[-1].isHighSurrogate());
+             return QChar::surrogateToUcs4(*--pos, cur);
++        }
+         return cur.unicode();
+     }
+ 
+@@ -241,7 +256,7 @@ public:
+ 
+         const QChar uc = *--pos;
+         if (Q_UNLIKELY(uc.isSurrogate())) {
+-            if (Q_LIKELY(uc.isLowSurrogate() && pos > i && pos[-1].isHighSurrogate()))
++            if (Q_LIKELY(uc.isLowSurrogate() && hasPrevious() && pos[-1].isHighSurrogate()))
+                 return QChar::surrogateToUcs4(*--pos, uc);
+             return invalidAs;
+         }
+diff --git a/qtbase/src/corelib/thread/qfutex_p.h b/qtbase/src/corelib/thread/qfutex_p.h
+index f287b752d7..e294537787 100644
+--- a/qtbase/src/corelib/thread/qfutex_p.h
++++ b/qtbase/src/corelib/thread/qfutex_p.h
+@@ -52,6 +52,7 @@
+ //
+ 
+ #include <qglobal.h>
++#include <QtCore/qtsan_impl.h>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -106,16 +107,13 @@ namespace QtLinuxFutex {
+     inline int _q_futex(int *addr, int op, int val, quintptr val2 = 0,
+                         int *addr2 = nullptr, int val3 = 0) noexcept
+     {
+-        // A futex call ensures total ordering on the futex words
+-        // (in either success or failure of the call). Instruct TSAN accordingly,
+-        // as TSAN does not understand the futex(2) syscall.
+-        _q_tsan_release(addr, addr2);
++        QtTsan::futexRelease(addr, addr2);
+ 
+         // we use __NR_futex because some libcs (like Android's bionic) don't
+         // provide SYS_futex etc.
+         int result = syscall(__NR_futex, addr, op | FUTEX_PRIVATE_FLAG, val, val2, addr2, val3);
+ 
+-        _q_tsan_acquire(addr, addr2);
++        QtTsan::futexAcquire(addr, addr2);
+ 
+         return result;
+     }
+diff --git a/qtbase/src/corelib/thread/qmutex.cpp b/qtbase/src/corelib/thread/qmutex.cpp
+index 310d1cb14f..7097122d8e 100644
+--- a/qtbase/src/corelib/thread/qmutex.cpp
++++ b/qtbase/src/corelib/thread/qmutex.cpp
+@@ -152,6 +152,7 @@ public:
+ 
+ /*!
+     \enum QMutex::RecursionMode
++    \obsolete Use QRecursiveMutex to create a recursive mutex.
+ 
+     \value Recursive  In this mode, a thread can lock the same mutex
+                       multiple times and the mutex won't be unlocked
+@@ -173,6 +174,7 @@ public:
+ 
+ /*!
+     Constructs a new mutex. The mutex is created in an unlocked state.
++    \obsolete Use QRecursiveMutex to create a recursive mutex.
+ 
+     If \a mode is QMutex::Recursive, a thread can lock the same mutex
+     multiple times and the mutex won't be unlocked until a
+@@ -197,7 +199,7 @@ QMutex::QMutex(RecursionMode mode)
+ QMutex::~QMutex()
+ {
+     QMutexData *d = d_ptr.loadRelaxed();
+-    if (isRecursive()) {
++    if (QBasicMutex::isRecursive()) {
+         delete static_cast<QRecursiveMutexPrivate *>(d);
+     } else if (d) {
+ #ifndef QT_LINUX_FUTEX
+diff --git a/qtbase/src/corelib/thread/qmutex.h b/qtbase/src/corelib/thread/qmutex.h
+index 73c9e00663..1bae573a03 100644
+--- a/qtbase/src/corelib/thread/qmutex.h
++++ b/qtbase/src/corelib/thread/qmutex.h
+@@ -42,6 +42,7 @@
+ 
+ #include <QtCore/qglobal.h>
+ #include <QtCore/qatomic.h>
++#include <QtCore/qtsan_impl.h>
+ #include <new>
+ 
+ #if __has_include(<chrono>)
+@@ -77,19 +78,37 @@ public:
+ 
+     // BasicLockable concept
+     inline void lock() QT_MUTEX_LOCK_NOEXCEPT {
++        QtTsan::mutexPreLock(this, 0u);
++
+         if (!fastTryLock())
+             lockInternal();
++
++        QtTsan::mutexPostLock(this, 0u, 0);
+     }
+ 
+     // BasicLockable concept
+     inline void unlock() noexcept {
+         Q_ASSERT(d_ptr.loadRelaxed()); //mutex must be locked
++
++        QtTsan::mutexPreUnlock(this, 0u);
++
+         if (!fastTryUnlock())
+             unlockInternal();
++
++        QtTsan::mutexPostUnlock(this, 0u);
+     }
+ 
+     bool tryLock() noexcept {
+-        return fastTryLock();
++        unsigned tsanFlags = QtTsan::TryLock;
++        QtTsan::mutexPreLock(this, tsanFlags);
++
++        const bool success = fastTryLock();
++
++        if (!success)
++            tsanFlags |= QtTsan::TryLockFailed;
++        QtTsan::mutexPostLock(this, tsanFlags, 0);
++
++        return success;
+     }
+ 
+     // Lockable concept
+@@ -134,8 +153,16 @@ public:
+ #else
+     QMutex() { d_ptr.storeRelaxed(nullptr); }
+ #endif
++#if QT_DEPRECATED_SINCE(5,15)
+     enum RecursionMode { NonRecursive, Recursive };
++    QT_DEPRECATED_VERSION_X(5, 15, "Use QRecursiveMutex instead of a recursive QMutex")
+     explicit QMutex(RecursionMode mode);
++
++    QT_DEPRECATED_VERSION_X(5, 15, "Use QRecursiveMutex instead of a recursive QMutex")
++    bool isRecursive() const noexcept
++    { return QBasicMutex::isRecursive(); }
++#endif
++
+     ~QMutex();
+ 
+     // BasicLockable concept
+@@ -166,9 +193,6 @@ public:
+     }
+ #endif
+ 
+-    bool isRecursive() const noexcept
+-    { return QBasicMutex::isRecursive(); }
+-
+ private:
+     Q_DISABLE_COPY(QMutex)
+     friend class QMutexLocker;
+diff --git a/qtbase/src/corelib/thread/qreadwritelock.cpp b/qtbase/src/corelib/thread/qreadwritelock.cpp
+index 8c28507d5a..9dd8503116 100644
+--- a/qtbase/src/corelib/thread/qreadwritelock.cpp
++++ b/qtbase/src/corelib/thread/qreadwritelock.cpp
+@@ -155,7 +155,7 @@ QReadWriteLock::QReadWriteLock(RecursionMode recursionMode)
+ */
+ QReadWriteLock::~QReadWriteLock()
+ {
+-    auto d = d_ptr.loadRelaxed();
++    auto d = d_ptr.loadAcquire();
+     if (isUncontendedLocked(d)) {
+         qWarning("QReadWriteLock: destroying locked QReadWriteLock");
+         return;
+@@ -445,7 +445,7 @@ void QReadWriteLock::unlock()
+ /*! \internal  Helper for QWaitCondition::wait */
+ QReadWriteLock::StateForWaitCondition QReadWriteLock::stateForWaitCondition() const
+ {
+-    QReadWriteLockPrivate *d = d_ptr.loadRelaxed();
++    QReadWriteLockPrivate *d = d_ptr.loadAcquire();
+     switch (quintptr(d) & StateMask) {
+     case StateLockedForRead: return LockedForRead;
+     case StateLockedForWrite: return LockedForWrite;
+@@ -453,6 +453,7 @@ QReadWriteLock::StateForWaitCondition QReadWriteLock::stateForWaitCondition() co
+ 
+     if (!d)
+         return Unlocked;
++    const auto lock = qt_scoped_lock(d->mutex);
+     if (d->writerCount > 1)
+         return RecursivelyLocked;
+     else if (d->writerCount == 1)
+diff --git a/qtbase/src/corelib/thread/qsemaphore.cpp b/qtbase/src/corelib/thread/qsemaphore.cpp
+index 1d01fc1b28..3ecdee3747 100644
+--- a/qtbase/src/corelib/thread/qsemaphore.cpp
++++ b/qtbase/src/corelib/thread/qsemaphore.cpp
+@@ -354,7 +354,12 @@ void QSemaphore::release(int n)
+         quintptr nn = unsigned(n);
+         if (futexHasWaiterCount)
+             nn |= quint64(nn) << 32;    // token count replicated in high word
+-        quintptr prevValue = u.fetchAndAddRelease(nn);
++        quintptr prevValue = u.loadRelaxed();
++        quintptr newValue;
++        do { // loop just to ensure the operations are done atomically
++            newValue = prevValue + nn;
++            newValue &= (futexNeedsWakeAllBit - 1);
++        } while (!u.testAndSetRelease(prevValue, newValue, prevValue));
+         if (futexNeedsWake(prevValue)) {
+ #ifdef FUTEX_OP
+             if (futexHasWaiterCount) {
+@@ -376,7 +381,6 @@ void QSemaphore::release(int n)
+                 quint32 oparg = 0;
+                 quint32 cmp = FUTEX_OP_CMP_NE;
+                 quint32 cmparg = 0;
+-                u.fetchAndAndRelease(futexNeedsWakeAllBit - 1);
+                 futexWakeOp(*futexLow32(&u), n, INT_MAX, *futexHigh32(&u), FUTEX_OP(op, oparg, cmp, cmparg));
+                 return;
+             }
+@@ -388,7 +392,6 @@ 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(futexNeedsWakeAllBit - 1);
+             if (futexHasWaiterCount) {
+                 futexWakeAll(*futexLow32(&u));
+                 futexWakeAll(*futexHigh32(&u));
+diff --git a/qtbase/src/corelib/thread/qthread_p.h b/qtbase/src/corelib/thread/qthread_p.h
+index b2d1628e6e..f32f6f0460 100644
+--- a/qtbase/src/corelib/thread/qthread_p.h
++++ b/qtbase/src/corelib/thread/qthread_p.h
+@@ -174,7 +174,7 @@ public:
+     int returnCode;
+ 
+     uint stackSize;
+-    QThread::Priority priority;
++    std::underlying_type<QThread::Priority>::type priority;
+ 
+     static QThread *threadForId(int id);
+ 
+@@ -213,6 +213,13 @@ public:
+             QCoreApplication::instance()->postEvent(q_ptr, new QEvent(QEvent::Quit));
+         }
+     }
++
++#ifndef Q_OS_INTEGRITY
++private:
++    // Used in QThread(Private)::start to avoid racy access to QObject::objectName,
++    // unset afterwards. On INTEGRITY we set the thread name before starting it.
++    QString objectName;
++#endif
+ };
+ 
+ #else // QT_CONFIG(thread)
+diff --git a/qtbase/src/corelib/thread/qthread_unix.cpp b/qtbase/src/corelib/thread/qthread_unix.cpp
+index 56a8e0a038..610117a640 100644
+--- a/qtbase/src/corelib/thread/qthread_unix.cpp
++++ b/qtbase/src/corelib/thread/qthread_unix.cpp
+@@ -169,8 +169,7 @@ static void set_thread_data(QThreadData *data)
+ 
+ static void clear_thread_data()
+ {
+-    currentThreadData = nullptr;
+-    pthread_setspecific(current_thread_data_key, nullptr);
++    set_thread_data(nullptr);
+ }
+ 
+ template <typename T>
+@@ -296,7 +295,7 @@ void *QThreadPrivate::start(void *arg)
+             QMutexLocker locker(&thr->d_func()->mutex);
+ 
+             // do we need to reset the thread priority?
+-            if (int(thr->d_func()->priority) & ThreadPriorityResetFlag) {
++            if (thr->d_func()->priority & ThreadPriorityResetFlag) {
+                 thr->d_func()->setPriority(QThread::Priority(thr->d_func()->priority & ~ThreadPriorityResetFlag));
+             }
+ 
+@@ -316,10 +315,10 @@ void *QThreadPrivate::start(void *arg)
+             // Sets the name of the current thread. We can only do this
+             // when the thread is starting, as we don't have a cross
+             // platform way of setting the name of an arbitrary thread.
+-            if (Q_LIKELY(thr->objectName().isEmpty()))
++            if (Q_LIKELY(thr->d_func()->objectName.isEmpty()))
+                 setCurrentThreadName(thr->metaObject()->className());
+             else
+-                setCurrentThreadName(thr->objectName().toLocal8Bit());
++                setCurrentThreadName(std::exchange(thr->d_func()->objectName, {}).toLocal8Bit());
+         }
+ #endif
+ 
+@@ -671,7 +670,7 @@ void QThread::start(Priority priority)
+                 // could not set scheduling hints, fallback to inheriting them
+                 // we'll try again from inside the thread
+                 pthread_attr_setinheritsched(&attr, PTHREAD_INHERIT_SCHED);
+-                d->priority = Priority(priority | ThreadPriorityResetFlag);
++                d->priority = static_cast<std::underlying_type<QThread::Priority>::type>(priority) | ThreadPriorityResetFlag;
+             }
+             break;
+         }
+@@ -702,7 +701,10 @@ void QThread::start(Priority priority)
+         pthread_attr_setthreadname(&attr, metaObject()->className());
+     else
+         pthread_attr_setthreadname(&attr, objectName().toLocal8Bit());
++#else
++    d->objectName = objectName();
+ #endif
++
+     pthread_t threadId;
+     int code = pthread_create(&threadId, &attr, QThreadPrivate::start, this);
+     if (code == EPERM) {
+diff --git a/qtbase/src/corelib/thread/qthread_win.cpp b/qtbase/src/corelib/thread/qthread_win.cpp
+index bc70e3178a..4e76972498 100644
+--- a/qtbase/src/corelib/thread/qthread_win.cpp
++++ b/qtbase/src/corelib/thread/qthread_win.cpp
+@@ -394,10 +394,9 @@ unsigned int __stdcall QT_ENSURE_STACK_ALIGNED_FOR_SSE QThreadPrivate::start(voi
+ 
+ #if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) && !defined(Q_OS_WINRT)
+     // sets the name of the current thread.
+-    QByteArray objectName = thr->objectName().toLocal8Bit();
+-    qt_set_thread_name(HANDLE(-1),
+-                       objectName.isEmpty() ?
+-                       thr->metaObject()->className() : objectName.constData());
++    qt_set_thread_name(HANDLE(-1), thr->d_func()->objectName.isEmpty()
++                        ? thr->metaObject()->className()
++                        : std::exchange(thr->d_func()->objectName, {}).toLocal8Bit().constData());
+ #endif
+ 
+     emit thr->started(QThread::QPrivateSignal());
+@@ -503,6 +502,7 @@ void QThread::start(Priority priority)
+     if (d->running)
+         return;
+ 
++    d->objectName = objectName();
+     d->running = true;
+     d->finished = false;
+     d->exited = false;
+@@ -548,7 +548,7 @@ void QThread::start(Priority priority)
+ 
+     int prio;
+     d->priority = priority;
+-    switch (d->priority) {
++    switch (priority) {
+     case IdlePriority:
+         prio = THREAD_PRIORITY_IDLE;
+         break;
+@@ -686,7 +686,7 @@ void QThreadPrivate::setPriority(QThread::Priority threadPriority)
+ 
+     int prio;
+     priority = threadPriority;
+-    switch (priority) {
++    switch (threadPriority) {
+     case QThread::IdlePriority:
+         prio = THREAD_PRIORITY_IDLE;
+         break;
+diff --git a/qtbase/src/corelib/thread/qtsan_impl.h b/qtbase/src/corelib/thread/qtsan_impl.h
+new file mode 100644
+index 0000000000..580a738b91
+--- /dev/null
++++ b/qtbase/src/corelib/thread/qtsan_impl.h
+@@ -0,0 +1,115 @@
++/****************************************************************************
++**
++** Copyright (C) 2017 Intel Corporation.
++** Copyright (C) 2022 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
++** 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 QTSAN_IMPL_H
++#define QTSAN_IMPL_H
++
++#include <QtCore/qglobal.h>
++
++#if (__has_feature(thread_sanitizer) || defined(__SANITIZE_THREAD__)) && __has_include(<sanitizer/tsan_interface.h>)
++#  define QT_BUILDING_UNDER_TSAN
++#  include <sanitizer/tsan_interface.h>
++#endif
++
++QT_BEGIN_NAMESPACE
++
++namespace QtTsan {
++#ifdef QT_BUILDING_UNDER_TSAN
++inline void futexAcquire(void *addr, void *addr2 = nullptr)
++{
++    // A futex call ensures total ordering on the futex words
++    // (in either success or failure of the call). Instruct TSAN accordingly,
++    // as TSAN does not understand the futex(2) syscall (or equivalent).
++    ::__tsan_acquire(addr);
++    if (addr2)
++        ::__tsan_acquire(addr2);
++}
++
++inline void futexRelease(void *addr, void *addr2 = nullptr)
++{
++    if (addr2)
++        ::__tsan_release(addr2);
++    ::__tsan_release(addr);
++}
++
++inline void mutexPreLock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_pre_lock(addr, flags);
++}
++
++inline void mutexPostLock(void *addr, unsigned flags, int recursion)
++{
++    ::__tsan_mutex_post_lock(addr, flags, recursion);
++}
++
++inline void mutexPreUnlock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_pre_unlock(addr, flags);
++}
++
++inline void mutexPostUnlock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_post_unlock(addr, flags);
++}
++
++enum : unsigned {
++    MutexWriteReentrant = ::__tsan_mutex_write_reentrant,
++    TryLock = ::__tsan_mutex_try_lock,
++    TryLockFailed = ::__tsan_mutex_try_lock_failed,
++};
++#else
++inline void futexAcquire(void *, void * = nullptr) {}
++inline void futexRelease(void *, void * = nullptr) {}
++
++enum : unsigned {
++    MutexWriteReentrant,
++    TryLock,
++    TryLockFailed,
++};
++inline void mutexPreLock(void *, unsigned) {}
++inline void mutexPostLock(void *, unsigned, int) {}
++inline void mutexPreUnlock(void *, unsigned) {}
++inline void mutexPostUnlock(void *, unsigned) {}
++#endif // QT_BUILDING_UNDER_TSAN
++} // namespace QtTsan
++
++QT_END_NAMESPACE
++
++#endif // QTSAN_IMPL_H
+diff --git a/qtbase/src/corelib/thread/qwaitcondition_unix.cpp b/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
+index 88b058f410..0f1da4dc9b 100644
+--- a/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
++++ b/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
+@@ -213,7 +213,7 @@ bool QWaitCondition::wait(QMutex *mutex, QDeadlineTimer deadline)
+ {
+     if (! mutex)
+         return false;
+-    if (mutex->isRecursive()) {
++    if (static_cast<QBasicMutex *>(mutex)->isRecursive()) {
+         qWarning("QWaitCondition: cannot wait on recursive mutexes");
+         return false;
+     }
+diff --git a/qtbase/src/corelib/time/qdatetime.cpp b/qtbase/src/corelib/time/qdatetime.cpp
+index ec12569e3f..2c0b098079 100644
+--- a/qtbase/src/corelib/time/qdatetime.cpp
++++ b/qtbase/src/corelib/time/qdatetime.cpp
+@@ -43,6 +43,7 @@
+ #if QT_CONFIG(datetimeparser)
+ #include "private/qdatetimeparser_p.h"
+ #endif
++#include <private/qnumeric_p.h>
+ 
+ #include "qdatastream.h"
+ #include "qset.h"
+@@ -1429,9 +1430,11 @@ QDate QDate::addDays(qint64 ndays) const
+     if (isNull())
+         return QDate();
+ 
+-    // Due to limits on minJd() and maxJd() we know that any overflow
+-    // will be invalid and caught by fromJulianDay().
+-    return fromJulianDay(jd + ndays);
++    qint64 r;
++    if (Q_UNLIKELY(add_overflow(jd, ndays, &r)))
++        return QDate();
++    else
++        return fromJulianDay(r);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/corelib/time/qtimezone.cpp b/qtbase/src/corelib/time/qtimezone.cpp
+index 0309e43e52..3d451696a1 100644
+--- a/qtbase/src/corelib/time/qtimezone.cpp
++++ b/qtbase/src/corelib/time/qtimezone.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2013 John Layt <jlayt@kde.org>
++** Copyright (C) 2020 John Layt <jlayt@kde.org>
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtCore module of the Qt Toolkit.
+@@ -975,9 +975,15 @@ QList<QByteArray> QTimeZone::windowsIdToIanaIds(const QByteArray &windowsId,
+ }
+ 
+ #ifndef QT_NO_DATASTREAM
++// Invalid, as an IANA ID: too long, starts with - and has other invalid characters in it
++static inline QString invalidId() { return QStringLiteral("-No Time Zone Specified!"); }
++
+ QDataStream &operator<<(QDataStream &ds, const QTimeZone &tz)
+ {
+-    tz.d->serialize(ds);
++    if (tz.isValid())
++        tz.d->serialize(ds);
++    else
++        ds << invalidId();
+     return ds;
+ }
+ 
+@@ -985,7 +991,9 @@ QDataStream &operator>>(QDataStream &ds, QTimeZone &tz)
+ {
+     QString ianaId;
+     ds >> ianaId;
+-    if (ianaId == QLatin1String("OffsetFromUtc")) {
++    if (ianaId == invalidId()) {
++        tz = QTimeZone();
++    } else if (ianaId == QLatin1String("OffsetFromUtc")) {
+         int utcOffset;
+         QString name;
+         QString abbreviation;
+diff --git a/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp b/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
+index b1611d7ddb..a7a6a72ccf 100644
+--- a/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
++++ b/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
+@@ -42,6 +42,7 @@
+ #include "qtimezone.h"
+ #include "qtimezoneprivate_p.h"
+ #include "private/qlocale_tools_p.h"
++#include "private/qlocking_p.h"
+ 
+ #include <QtCore/QDataStream>
+ #include <QtCore/QDateTime>
+@@ -62,6 +63,10 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++#if QT_CONFIG(icu)
++static QBasicMutex s_icu_mutex;
++#endif
++
+ /*
+     Private
+ 
+@@ -670,6 +675,9 @@ QTzTimeZonePrivate::~QTzTimeZonePrivate()
+ 
+ QTzTimeZonePrivate *QTzTimeZonePrivate::clone() const
+ {
++#if QT_CONFIG(icu)
++    const auto lock = qt_scoped_lock(s_icu_mutex);
++#endif
+     return new QTzTimeZonePrivate(*this);
+ }
+ 
+@@ -913,12 +921,14 @@ QString QTzTimeZonePrivate::displayName(qint64 atMSecsSinceEpoch,
+                                         const QLocale &locale) const
+ {
+ #if QT_CONFIG(icu)
++    auto lock = qt_unique_lock(s_icu_mutex);
+     if (!m_icu)
+         m_icu = new QIcuTimeZonePrivate(m_id);
+     // TODO small risk may not match if tran times differ due to outdated files
+     // TODO Some valid TZ names are not valid ICU names, use translation table?
+     if (m_icu->isValid())
+         return m_icu->displayName(atMSecsSinceEpoch, nameType, locale);
++    lock.unlock();
+ #else
+     Q_UNUSED(nameType)
+     Q_UNUSED(locale)
+@@ -932,12 +942,14 @@ QString QTzTimeZonePrivate::displayName(QTimeZone::TimeType timeType,
+                                         const QLocale &locale) const
+ {
+ #if QT_CONFIG(icu)
++    auto lock = qt_unique_lock(s_icu_mutex);
+     if (!m_icu)
+         m_icu = new QIcuTimeZonePrivate(m_id);
+     // TODO small risk may not match if tran times differ due to outdated files
+     // TODO Some valid TZ names are not valid ICU names, use translation table?
+     if (m_icu->isValid())
+         return m_icu->displayName(timeType, nameType, locale);
++    lock.unlock();
+ #else
+     Q_UNUSED(timeType)
+     Q_UNUSED(nameType)
+diff --git a/qtbase/src/corelib/tools/qarraydata.h b/qtbase/src/corelib/tools/qarraydata.h
+index dcd95924c1..d01739e7e6 100644
+--- a/qtbase/src/corelib/tools/qarraydata.h
++++ b/qtbase/src/corelib/tools/qarraydata.h
+@@ -42,6 +42,7 @@
+ 
+ #include <QtCore/qrefcount.h>
+ #include <string.h>
++#include <cstdint>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -58,14 +59,14 @@ struct Q_CORE_EXPORT QArrayData
+     {
+         Q_ASSERT(size == 0
+                 || offset < 0 || size_t(offset) >= sizeof(QArrayData));
+-        return reinterpret_cast<char *>(this) + offset;
++        return reinterpret_cast<void *> (reinterpret_cast<uintptr_t>(this) + offset);
+     }
+ 
+     const void *data() const
+     {
+         Q_ASSERT(size == 0
+                 || offset < 0 || size_t(offset) >= sizeof(QArrayData));
+-        return reinterpret_cast<const char *>(this) + offset;
++        return reinterpret_cast<void *> (reinterpret_cast<uintptr_t>(this) + offset);
+     }
+ 
+     // This refers to array data mutability, not "header data" represented by
+diff --git a/qtbase/src/corelib/tools/qfreelist_p.h b/qtbase/src/corelib/tools/qfreelist_p.h
+index 5ba23b344b..9974102136 100644
+--- a/qtbase/src/corelib/tools/qfreelist_p.h
++++ b/qtbase/src/corelib/tools/qfreelist_p.h
+@@ -161,7 +161,7 @@ class QFreeList
+                 return i;
+             x -= size;
+         }
+-        Q_ASSERT(false);
++        Q_UNREACHABLE();
+         return -1;
+     }
+ 
+diff --git a/qtbase/src/corelib/tools/qversionnumber.h b/qtbase/src/corelib/tools/qversionnumber.h
+index d43b86ba51..2843f2b043 100644
+--- a/qtbase/src/corelib/tools/qversionnumber.h
++++ b/qtbase/src/corelib/tools/qversionnumber.h
+@@ -273,10 +273,10 @@ public:
+ 
+     Q_REQUIRED_RESULT Q_CORE_EXPORT QString toString() const;
+ #if QT_STRINGVIEW_LEVEL < 2
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(const QString &string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(const QString &string, int *suffixIndex = nullptr);
+ #endif
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QLatin1String string, int *suffixIndex = nullptr);
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QStringView string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(QLatin1String string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(QStringView string, int *suffixIndex = nullptr);
+ 
+ private:
+ #ifndef QT_NO_DATASTREAM
+diff --git a/qtbase/src/dbus/qdbusintegrator.cpp b/qtbase/src/dbus/qdbusintegrator.cpp
+index 5b66ce971b..28a3b0ffea 100644
+--- a/qtbase/src/dbus/qdbusintegrator.cpp
++++ b/qtbase/src/dbus/qdbusintegrator.cpp
+@@ -1135,7 +1135,13 @@ void QDBusConnectionPrivate::closeConnection()
+         }
+     }
+ 
+-    qDeleteAll(pendingCalls);
++    for (auto it = pendingCalls.begin(); it != pendingCalls.end(); ++it) {
++        auto call = *it;
++        if (!call->ref.deref()) {
++            delete call;
++        }
++    }
++    pendingCalls.clear();
+ 
+     // Disconnect all signals from signal hooks and from the object tree to
+     // avoid QObject::destroyed being sent to dbus daemon thread which has
+@@ -2584,6 +2590,11 @@ QDBusConnectionPrivate::findMetaObject(const QString &service, const QString &pa
+         if (mo)
+             return mo;
+     }
++    if (path.isEmpty()) {
++        error = QDBusError(QDBusError::InvalidObjectPath, QLatin1String("Object path cannot be empty"));
++        lastError = error;
++        return nullptr;
++    }
+ 
+     // introspect the target object
+     QDBusMessage msg = QDBusMessage::createMethodCall(service, path,
+diff --git a/qtbase/src/dbus/qdbusmetaobject.cpp b/qtbase/src/dbus/qdbusmetaobject.cpp
+index 5265568f42..7e9f0f1acc 100644
+--- a/qtbase/src/dbus/qdbusmetaobject.cpp
++++ b/qtbase/src/dbus/qdbusmetaobject.cpp
+@@ -210,6 +210,9 @@ QDBusMetaObjectGenerator::findType(const QByteArray &signature,
+         } else if (signature == "a{ss}") {
+             result.name = "QMap<QString,QString>";
+             type = qMetaTypeId<QMap<QString, QString> >();
++        } else if (signature == "aay") {
++            result.name = "QByteArrayList";
++            type = qMetaTypeId<QByteArrayList>();
+         } else {
+             result.name = "{D-Bus type \"" + signature + "\"}";
+             type = registerComplexDBusType(result.name);
+diff --git a/qtbase/src/gui/accessible/qaccessible.cpp b/qtbase/src/gui/accessible/qaccessible.cpp
+index d705bfccb5..0caf3c808c 100644
+--- a/qtbase/src/gui/accessible/qaccessible.cpp
++++ b/qtbase/src/gui/accessible/qaccessible.cpp
+@@ -54,6 +54,7 @@
+ #include <QtCore/qdebug.h>
+ #include <QtCore/qloggingcategory.h>
+ #include <QtCore/qmetaobject.h>
++#include <QtCore/private/qmetaobject_p.h>
+ #include <QtCore/qhash.h>
+ #include <private/qfactoryloader_p.h>
+ 
+@@ -681,6 +682,25 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
+     // Create a QAccessibleInterface for the object class. Start by the most
+     // derived class and walk up the class hierarchy.
+     const QMetaObject *mo = object->metaObject();
++    const auto *objectPriv = QObjectPrivate::get(object);
++    /*
++     We do not want to cache each and every QML metaobject (Button_QMLTYPE_124,
++     Button_QMLTYPE_125, etc.). Those dynamic metaobjects shouldn't have an
++     accessible interface in any case. Instead, we start the whole checking
++     with the first non-dynamic meta-object. To avoid potential regressions
++     in other areas of Qt that also use dynamic metaobjects, we only do this
++     for objects that are QML-related (approximated by checking whether they
++     have ddata set).
++    */
++    const bool qmlRelated = !objectPriv->isDeletingChildren &&
++                            objectPriv->declarativeData;
++    while (qmlRelated && mo) {
++        auto mop = QMetaObjectPrivate::get(mo);
++        if (!mop || !(mop->flags & DynamicMetaObject))
++            break;
++
++        mo = mo->superClass();
++    };
+     while (mo) {
+         const QString cn = QLatin1String(mo->className());
+ 
+@@ -696,14 +716,15 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
+         // Find a QAccessiblePlugin (factory) for the class name. If there's
+         // no entry in the cache try to create it using the plugin loader.
+         if (!qAccessiblePlugins()->contains(cn)) {
++            QAccessiblePlugin *factory = nullptr; // 0 means "no plugin found". This is cached as well.
+             const int index = loader()->indexOf(cn);
+-            if (index != -1) {
+-                QAccessiblePlugin *factory = qobject_cast<QAccessiblePlugin *>(loader()->instance(index));
+-                qAccessiblePlugins()->insert(cn, factory);
+-            }
++            if (index != -1)
++                factory = qobject_cast<QAccessiblePlugin *>(loader()->instance(index));
++            qAccessiblePlugins()->insert(cn, factory);
+         }
+ 
+         // At this point the cache should contain a valid factory pointer or 0:
++        Q_ASSERT(qAccessiblePlugins()->contains(cn));
+         QAccessiblePlugin *factory = qAccessiblePlugins()->value(cn);
+         if (factory) {
+             QAccessibleInterface *result = factory->create(cn, object);
+diff --git a/qtbase/src/gui/configure.json b/qtbase/src/gui/configure.json
+index 1f08795c57..12c95742d2 100644
+--- a/qtbase/src/gui/configure.json
++++ b/qtbase/src/gui/configure.json
+@@ -834,7 +834,8 @@
+                     "// embedded devices, are not intended to be used together with X. EGL support",
+                     "// has to be disabled in plugins like xcb in this case since the native display,",
+                     "// window and pixmap types will be different than what an X-based platform",
+-                    "// plugin would expect."
++                    "// plugin would expect.",
++                    "#define USE_X11"
+                 ],
+                 "include": [ "EGL/egl.h", "X11/Xlib.h" ],
+                 "main": [
+diff --git a/qtbase/src/gui/image/qbmphandler.cpp b/qtbase/src/gui/image/qbmphandler.cpp
+index 96f1e8cb1d..0e73bbbdb0 100644
+--- a/qtbase/src/gui/image/qbmphandler.cpp
++++ b/qtbase/src/gui/image/qbmphandler.cpp
+@@ -150,16 +150,42 @@ static QDataStream &operator<<(QDataStream &s, const BMP_INFOHDR &bi)
+     return s;
+ }
+ 
+-static int calc_shift(uint mask)
++static uint calc_shift(uint mask)
+ {
+-    int result = 0;
+-    while (mask && !(mask & 1)) {
++    uint result = 0;
++    while ((mask >= 0x100) || (!(mask & 1) && mask)) {
+         result++;
+         mask >>= 1;
+     }
+     return result;
+ }
+ 
++static uint calc_scale(uint low_mask)
++{
++    uint result = 8;
++    while (low_mask && result) {
++        result--;
++        low_mask >>= 1;
++    }
++    return result;
++}
++
++static inline uint apply_scale(uint value, uint scale)
++{
++    if (!(scale & 0x07)) // return immediately if scale == 8 or 0
++        return value;
++
++    uint filled = 8 - scale;
++    uint result = value << scale;
++
++    do {
++        result |= result >> filled;
++        filled <<= 1;
++    } while (filled < 8);
++
++    return result;
++}
++
+ static bool read_dib_fileheader(QDataStream &s, BMP_FILEHDR &bf)
+ {
+     // read BMP file header
+@@ -222,14 +248,14 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+     uint green_mask = 0;
+     uint blue_mask = 0;
+     uint alpha_mask = 0;
+-    int red_shift = 0;
+-    int green_shift = 0;
+-    int blue_shift = 0;
+-    int alpha_shift = 0;
+-    int red_scale = 0;
+-    int green_scale = 0;
+-    int blue_scale = 0;
+-    int alpha_scale = 0;
++    uint red_shift = 0;
++    uint green_shift = 0;
++    uint blue_shift = 0;
++    uint alpha_shift = 0;
++    uint red_scale = 0;
++    uint green_scale = 0;
++    uint blue_scale = 0;
++    uint alpha_scale = 0;
+ 
+     if (!d->isSequential())
+         d->seek(startpos + BMP_FILEHDR_SIZE + bi.biSize); // goto start of colormap or masks
+@@ -308,19 +334,19 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+         red_shift = calc_shift(red_mask);
+         if (((red_mask >> red_shift) + 1) == 0)
+             return false;
+-        red_scale = 256 / ((red_mask >> red_shift) + 1);
++        red_scale = calc_scale(red_mask >> red_shift);
+         green_shift = calc_shift(green_mask);
+         if (((green_mask >> green_shift) + 1) == 0)
+             return false;
+-        green_scale = 256 / ((green_mask >> green_shift) + 1);
++        green_scale = calc_scale(green_mask >> green_shift);
+         blue_shift = calc_shift(blue_mask);
+         if (((blue_mask >> blue_shift) + 1) == 0)
+             return false;
+-        blue_scale = 256 / ((blue_mask >> blue_shift) + 1);
++        blue_scale = calc_scale(blue_mask >> blue_shift);
+         alpha_shift = calc_shift(alpha_mask);
+         if (((alpha_mask >> alpha_shift) + 1) == 0)
+             return false;
+-        alpha_scale = 256 / ((alpha_mask >> alpha_shift) + 1);
++        alpha_scale = calc_scale(alpha_mask >> alpha_shift);
+     } else if (comp == BMP_RGB && (nbits == 24 || nbits == 32)) {
+         blue_mask = 0x000000ff;
+         green_mask = 0x0000ff00;
+@@ -328,17 +354,15 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+         blue_shift = 0;
+         green_shift = 8;
+         red_shift = 16;
+-        blue_scale = green_scale = red_scale = 1;
++        blue_scale = green_scale = red_scale = 0;
+     } else if (comp == BMP_RGB && nbits == 16) {
+         blue_mask = 0x001f;
+         green_mask = 0x03e0;
+         red_mask = 0x7c00;
+         blue_shift = 0;
+-        green_shift = 2;
+-        red_shift = 7;
+-        red_scale = 1;
+-        green_scale = 1;
+-        blue_scale = 8;
++        green_shift = 5;
++        red_shift = 10;
++        blue_scale = green_scale = red_scale = 3;
+     }
+ 
+ #if 0
+@@ -544,10 +568,10 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+                     c |= *(uchar*)(b+2)<<16;
+                 if (nbits > 24)
+                     c |= *(uchar*)(b+3)<<24;
+-                *p++ = qRgba(((c & red_mask) >> red_shift) * red_scale,
+-                                        ((c & green_mask) >> green_shift) * green_scale,
+-                                        ((c & blue_mask) >> blue_shift) * blue_scale,
+-                                        transp ? ((c & alpha_mask) >> alpha_shift) * alpha_scale : 0xff);
++                *p++ = qRgba(apply_scale((c & red_mask) >> red_shift, red_scale),
++                             apply_scale((c & green_mask) >> green_shift, green_scale),
++                             apply_scale((c & blue_mask) >> blue_shift, blue_scale),
++                             transp ? apply_scale((c & alpha_mask) >> alpha_shift, alpha_scale) : 0xff);
+                 b += nbits/8;
+             }
+         }
+diff --git a/qtbase/src/gui/image/qimage.cpp b/qtbase/src/gui/image/qimage.cpp
+index 7152ac1607..0df772564c 100644
+--- a/qtbase/src/gui/image/qimage.cpp
++++ b/qtbase/src/gui/image/qimage.cpp
+@@ -4694,6 +4694,8 @@ QImage QImage::smoothScaled(int w, int h) const {
+ static QImage rotated90(const QImage &image)
+ {
+     QImage out(image.height(), image.width(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+@@ -4722,6 +4724,8 @@ static QImage rotated180(const QImage &image)
+         return image.mirrored(true, true);
+ 
+     QImage out(image.width(), image.height(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+@@ -4734,6 +4738,8 @@ static QImage rotated180(const QImage &image)
+ static QImage rotated270(const QImage &image)
+ {
+     QImage out(image.height(), image.width(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+diff --git a/qtbase/src/gui/kernel/qcursor.cpp b/qtbase/src/gui/kernel/qcursor.cpp
+index d6ccaff8ed..455088241c 100644
+--- a/qtbase/src/gui/kernel/qcursor.cpp
++++ b/qtbase/src/gui/kernel/qcursor.cpp
+@@ -251,7 +251,8 @@ void QCursor::setPos(QScreen *screen, int x, int y)
+ {
+     if (screen) {
+         if (QPlatformCursor *cursor = screen->handle()->cursor()) {
+-            const QPoint devicePos = QHighDpi::toNativePixels(QPoint(x, y), screen);
++            const QPoint pos(x, y);
++            const QPoint devicePos = QHighDpi::toNativePixels(pos, screen->virtualSiblingAt(pos));
+             // Need to check, since some X servers generate null mouse move
+             // events, causing looping in applications which call setPos() on
+             // every mouse move event.
+diff --git a/qtbase/src/gui/kernel/qhighdpiscaling.cpp b/qtbase/src/gui/kernel/qhighdpiscaling.cpp
+index 9bbf2773a9..3ac4a4d8b6 100644
+--- a/qtbase/src/gui/kernel/qhighdpiscaling.cpp
++++ b/qtbase/src/gui/kernel/qhighdpiscaling.cpp
+@@ -580,9 +580,8 @@ void QHighDpiScaling::setScreenFactor(QScreen *screen, qreal factor)
+     else
+         qNamedScreenScaleFactors()->insert(name, factor);
+ 
+-    // hack to force re-evaluation of screen geometry
+     if (screen->handle())
+-        screen->d_func()->setPlatformScreen(screen->handle()); // updates geometries based on scale factor
++        screen->d_func()->updateLogicalDpi();
+ }
+ 
+ QPoint QHighDpiScaling::mapPositionToNative(const QPoint &pos, const QPlatformScreen *platformScreen)
+diff --git a/qtbase/src/gui/kernel/qkeysequence.cpp b/qtbase/src/gui/kernel/qkeysequence.cpp
+index a75b8ef920..4f2d294739 100644
+--- a/qtbase/src/gui/kernel/qkeysequence.cpp
++++ b/qtbase/src/gui/kernel/qkeysequence.cpp
+@@ -701,6 +701,10 @@ static const struct {
+     { Qt::Key_TouchpadToggle,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad Toggle") },
+     { Qt::Key_TouchpadOn,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad On") },
+     { Qt::Key_TouchpadOff,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad Off") },
++    { Qt::Key_Shift,  QT_TRANSLATE_NOOP("QShortcut", "Shift") },
++    { Qt::Key_Control,  QT_TRANSLATE_NOOP("QShortcut", "Control") },
++    { Qt::Key_Alt,  QT_TRANSLATE_NOOP("QShortcut", "Alt") },
++    { Qt::Key_Meta,  QT_TRANSLATE_NOOP("QShortcut", "Meta") },
+ 
+ };
+ static Q_CONSTEXPR int numKeyNames = sizeof keyname / sizeof *keyname;
+diff --git a/qtbase/src/gui/kernel/qplatformservices.cpp b/qtbase/src/gui/kernel/qplatformservices.cpp
+index fdc6a6c4aa..ac47f98c5d 100644
+--- a/qtbase/src/gui/kernel/qplatformservices.cpp
++++ b/qtbase/src/gui/kernel/qplatformservices.cpp
+@@ -55,6 +55,19 @@ QT_BEGIN_NAMESPACE
+     \brief The QPlatformServices provides the backend for desktop-related functionality.
+ */
+ 
++/*!
++    \enum QPlatformServices::Capability
++
++    Capabilities are used to determine a specific platform service's availability.
++
++    \value ColorPickingFromScreen The platform natively supports color picking from screen.
++    This capability indicates that the platform supports "opaque" color picking, where the
++    platform implements a complete user experience for color picking and outputs a color.
++    This is in contrast to the application implementing the color picking user experience
++    (taking care of showing a cross hair, instructing the platform integration to obtain
++    the color at a given pixel, etc.). The related service function is pickColor().
++ */
++
+ QPlatformServices::QPlatformServices()
+ { }
+ 
+@@ -85,5 +98,16 @@ QByteArray QPlatformServices::desktopEnvironment() const
+     return QByteArray("UNKNOWN");
+ }
+ 
++QPlatformServiceColorPicker *QPlatformServices::colorPicker(QWindow *parent)
++{
++    Q_UNUSED(parent);
++    return nullptr;
++}
++
++bool QPlatformServices::hasCapability(Capability capability) const
++{
++    Q_UNUSED(capability)
++    return false;
++}
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/gui/kernel/qplatformservices.h b/qtbase/src/gui/kernel/qplatformservices.h
+index 5de96cfa7d..a8b2a4ce71 100644
+--- a/qtbase/src/gui/kernel/qplatformservices.h
++++ b/qtbase/src/gui/kernel/qplatformservices.h
+@@ -50,16 +50,32 @@
+ //
+ 
+ #include <QtGui/qtguiglobal.h>
++#include <QtCore/qobject.h>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+ class QUrl;
++class QWindow;
++
++class Q_GUI_EXPORT QPlatformServiceColorPicker : public QObject
++{
++    Q_OBJECT
++public:
++    using QObject::QObject;
++    virtual void pickColor() = 0;
++Q_SIGNALS:
++    void colorPicked(const QColor &color);
++};
+ 
+ class Q_GUI_EXPORT QPlatformServices
+ {
+ public:
+     Q_DISABLE_COPY_MOVE(QPlatformServices)
+ 
++    enum Capability {
++        ColorPicking,
++    };
++
+     QPlatformServices();
+     virtual ~QPlatformServices() { }
+ 
+@@ -67,6 +83,10 @@ public:
+     virtual bool openDocument(const QUrl &url);
+ 
+     virtual QByteArray desktopEnvironment() const;
++
++    virtual bool hasCapability(Capability capability) const;
++
++    virtual QPlatformServiceColorPicker *colorPicker(QWindow *parent = nullptr);
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/gui/kernel/qplatformtheme.cpp b/qtbase/src/gui/kernel/qplatformtheme.cpp
+index 71521c0339..2325873245 100644
+--- a/qtbase/src/gui/kernel/qplatformtheme.cpp
++++ b/qtbase/src/gui/kernel/qplatformtheme.cpp
+@@ -163,6 +163,8 @@ QT_BEGIN_NAMESPACE
+ 
+     \value ShowShortcutsInContextMenus (bool) Whether to display shortcut key sequences in context menus.
+ 
++    \value ButtonPressKeys (QList<Qt::Key>) A list of keys that can be used to press buttons via keyboard input.
++
+     \sa themeHint(), QStyle::pixelMetric()
+ */
+ 
+@@ -563,6 +565,8 @@ QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint)
+         }
+     case MouseQuickSelectionThreshold:
+         return QVariant(10);
++    case ButtonPressKeys:
++        return QVariant::fromValue(QList<Qt::Key>({ Qt::Key_Space, Qt::Key_Select }));
+     }
+     return QVariant();
+ }
+diff --git a/qtbase/src/gui/kernel/qplatformtheme.h b/qtbase/src/gui/kernel/qplatformtheme.h
+index 3185fc4541..7e6c9d5740 100644
+--- a/qtbase/src/gui/kernel/qplatformtheme.h
++++ b/qtbase/src/gui/kernel/qplatformtheme.h
+@@ -120,7 +120,8 @@ public:
+         TouchDoubleTapDistance,
+         ShowShortcutsInContextMenus,
+         IconFallbackSearchPaths,
+-        MouseQuickSelectionThreshold
++        MouseQuickSelectionThreshold,
++        ButtonPressKeys
+     };
+ 
+     enum DialogType {
+diff --git a/qtbase/src/gui/kernel/qscreen.cpp b/qtbase/src/gui/kernel/qscreen.cpp
+index 8e0eb35116..5d172a58dd 100644
+--- a/qtbase/src/gui/kernel/qscreen.cpp
++++ b/qtbase/src/gui/kernel/qscreen.cpp
+@@ -77,6 +77,12 @@ QScreen::QScreen(QPlatformScreen *screen)
+     d->setPlatformScreen(screen);
+ }
+ 
++void QScreenPrivate::updateLogicalDpi()
++{
++    logicalDpi = QPlatformScreen::overrideDpi(platformScreen->logicalDpi());
++    updateGeometriesWithSignals(); // updates geometries based on scale factor
++}
++
+ void QScreenPrivate::updateGeometriesWithSignals()
+ {
+     const QRect oldGeometry = geometry;
+diff --git a/qtbase/src/gui/kernel/qscreen_p.h b/qtbase/src/gui/kernel/qscreen_p.h
+index 7da542c25e..e50fc3190b 100644
+--- a/qtbase/src/gui/kernel/qscreen_p.h
++++ b/qtbase/src/gui/kernel/qscreen_p.h
+@@ -70,6 +70,7 @@ public:
+         geometry = platformScreen->deviceIndependentGeometry();
+         availableGeometry = QHighDpi::fromNative(platformScreen->availableGeometry(), QHighDpiScaling::factor(platformScreen), geometry.topLeft());
+     }
++    void updateLogicalDpi();
+ 
+     void updatePrimaryOrientation();
+     void updateGeometriesWithSignals();
+diff --git a/qtbase/src/gui/painting/qblendfunctions_p.h b/qtbase/src/gui/painting/qblendfunctions_p.h
+index 080da98ec4..6997d62b3c 100644
+--- a/qtbase/src/gui/painting/qblendfunctions_p.h
++++ b/qtbase/src/gui/painting/qblendfunctions_p.h
+@@ -246,25 +246,32 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+                                   int dudx, int dvdx, int dudy, int dvdy, int u0, int v0,
+                                   Blender blender)
+ {
+-    int fromY = qMax(qRound(topY), clip.top());
+-    int toY = qMin(qRound(bottomY), clip.top() + clip.height());
++    qint64 fromY = qMax(qRound(topY), clip.top());
++    qint64 toY = qMin(qRound(bottomY), clip.top() + clip.height());
+     if (fromY >= toY)
+         return;
+ 
+     qreal leftSlope = (bottomLeft.x - topLeft.x) / (bottomLeft.y - topLeft.y);
+     qreal rightSlope = (bottomRight.x - topRight.x) / (bottomRight.y - topRight.y);
+-    int dx_l = int(leftSlope * 0x10000);
+-    int dx_r = int(rightSlope * 0x10000);
+-    int x_l = int((topLeft.x + (qreal(0.5) + fromY - topLeft.y) * leftSlope + qreal(0.5)) * 0x10000);
+-    int x_r = int((topRight.x + (qreal(0.5) + fromY - topRight.y) * rightSlope + qreal(0.5)) * 0x10000);
+-
+-    int fromX, toX, x1, x2, u, v, i, ii;
++    qint64 dx_l = qint64(leftSlope * 0x10000);
++    qint64 dx_r = qint64(rightSlope * 0x10000);
++    qint64 x_l = qint64((topLeft.x + (qreal(0.5) + fromY - topLeft.y) * leftSlope + qreal(0.5)) * 0x10000);
++    qint64 x_r = qint64((topRight.x + (qreal(0.5) + fromY - topRight.y) * rightSlope + qreal(0.5)) * 0x10000);
++
++    qint64 sourceRectTop = qint64(sourceRect.top());
++    qint64 sourceRectLeft = qint64(sourceRect.left());
++    qint64 sourceRectWidth = qint64(sourceRect.width());
++    qint64 sourceRectHeight = qint64(sourceRect.height());
++    qint64 clipLeft = qint64(clip.left());
++    qint64 clipWidth = qint64(clip.width());
++
++    qint64 fromX, toX, x1, x2, u, v, i, ii;
+     DestT *line;
+-    for (int y = fromY; y < toY; ++y) {
++    for (qint64 y = fromY; y < toY; ++y) {
+         line = reinterpret_cast<DestT *>(reinterpret_cast<uchar *>(destPixels) + y * dbpl);
+ 
+-        fromX = qMax(x_l >> 16, clip.left());
+-        toX = qMin(x_r >> 16, clip.left() + clip.width());
++        fromX = qMax(x_l >> 16, clipLeft);
++        toX = qMin(x_r >> 16, clipLeft + clipWidth);
+         if (fromX < toX) {
+             // Because of rounding, we can get source coordinates outside the source image.
+             // Clamp these coordinates to the source rect to avoid segmentation fault and
+@@ -275,10 +282,10 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             u = x1 * dudx + y * dudy + u0;
+             v = x1 * dvdx + y * dvdy + v0;
+             for (; x1 < toX; ++x1) {
+-                int uu = u >> 16;
+-                int vv = v >> 16;
+-                if (uu >= sourceRect.left() && uu < sourceRect.left() + sourceRect.width()
+-                    && vv >= sourceRect.top() && vv < sourceRect.top() + sourceRect.height()) {
++                qint64 uu = u >> 16;
++                qint64 vv = v >> 16;
++                if (uu >= sourceRectLeft && uu < sourceRectLeft + sourceRectWidth
++                    && vv >= sourceRectTop && vv < sourceRectTop + sourceRectHeight) {
+                     break;
+                 }
+                 u += dudx;
+@@ -290,10 +297,10 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             u = (x2 - 1) * dudx + y * dudy + u0;
+             v = (x2 - 1) * dvdx + y * dvdy + v0;
+             for (; x2 > x1; --x2) {
+-                int uu = u >> 16;
+-                int vv = v >> 16;
+-                if (uu >= sourceRect.left() && uu < sourceRect.left() + sourceRect.width()
+-                    && vv >= sourceRect.top() && vv < sourceRect.top() + sourceRect.height()) {
++                qint64 uu = u >> 16;
++                qint64 vv = v >> 16;
++                if (uu >= sourceRectLeft && uu < sourceRectLeft + sourceRectWidth
++                    && vv >= sourceRectTop && vv < sourceRectTop + sourceRectHeight) {
+                     break;
+                 }
+                 u -= dudx;
+@@ -308,8 +315,8 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             // Beginning of the scan line, with per-pixel checks.
+             i = x1 - fromX;
+             while (i) {
+-                int uu = qBound(sourceRect.left(), u >> 16, sourceRect.left() + sourceRect.width() - 1);
+-                int vv = qBound(sourceRect.top(), v >> 16, sourceRect.top() + sourceRect.height() - 1);
++                qint64 uu = qBound(sourceRectLeft, u >> 16, sourceRectLeft + sourceRectWidth - 1);
++                qint64 vv = qBound(sourceRectTop, v >> 16, sourceRectTop + sourceRectHeight - 1);
+                 blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + vv * sbpl)[uu]);
+                 u += dudx;
+                 v += dvdx;
+@@ -348,8 +355,8 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             // End of the scan line, with per-pixel checks.
+             i = toX - x2;
+             while (i) {
+-                int uu = qBound(sourceRect.left(), u >> 16, sourceRect.left() + sourceRect.width() - 1);
+-                int vv = qBound(sourceRect.top(), v >> 16, sourceRect.top() + sourceRect.height() - 1);
++                qint64 uu = qBound(sourceRectLeft, u >> 16, sourceRectLeft + sourceRectWidth - 1);
++                qint64 vv = qBound(sourceRectTop, v >> 16, sourceRectTop + sourceRectHeight - 1);
+                 blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + vv * sbpl)[uu]);
+                 u += dudx;
+                 v += dvdx;
+diff --git a/qtbase/src/gui/painting/qcolortrclut_p.h b/qtbase/src/gui/painting/qcolortrclut_p.h
+index 76a6a60803..24fd522e6c 100644
+--- a/qtbase/src/gui/painting/qcolortrclut_p.h
++++ b/qtbase/src/gui/painting/qcolortrclut_p.h
+@@ -118,6 +118,7 @@ public:
+         return QRgba64::fromRgba64(r, g, b, qAlpha(rgb32) * 257);
+ #endif
+     }
++    QRgba64 toLinear64(QRgba64) const = delete;
+ 
+     QRgb toLinear(QRgb rgb32) const
+     {
+diff --git a/qtbase/src/gui/painting/qdrawhelper.cpp b/qtbase/src/gui/painting/qdrawhelper.cpp
+index a61793508a..5ba2d277b7 100644
+--- a/qtbase/src/gui/painting/qdrawhelper.cpp
++++ b/qtbase/src/gui/painting/qdrawhelper.cpp
+@@ -6091,7 +6091,7 @@ static inline void alphargbblend_argb32(quint32 *dst, uint coverage, const QRgba
+ static inline void rgbBlendPixel(QRgba64 &dst, int coverage, QRgba64 slinear, const QColorTrcLut *colorProfile)
+ {
+     // Do a gammacorrected RGB alphablend...
+-    const QRgba64 dlinear = colorProfile ? colorProfile->toLinear64(dst) : dst;
++    const QRgba64 dlinear = colorProfile ? colorProfile->toLinear(dst) : dst;
+ 
+     QRgba64 blend = rgbBlend(dlinear, slinear, coverage);
+ 
+diff --git a/qtbase/src/gui/painting/qpaintengine_raster.cpp b/qtbase/src/gui/painting/qpaintengine_raster.cpp
+index 283923de52..f08eb9cbee 100644
+--- a/qtbase/src/gui/painting/qpaintengine_raster.cpp
++++ b/qtbase/src/gui/painting/qpaintengine_raster.cpp
+@@ -560,31 +560,6 @@ void QRasterPaintEngine::updateMatrix(const QTransform &matrix)
+     QRasterPaintEngineState *s = state();
+     // FALCON: get rid of this line, see drawImage call below.
+     s->matrix = matrix;
+-    QTransform::TransformationType txop = s->matrix.type();
+-
+-    switch (txop) {
+-
+-    case QTransform::TxNone:
+-        s->flags.int_xform = true;
+-        break;
+-
+-    case QTransform::TxTranslate:
+-        s->flags.int_xform = qreal(int(s->matrix.dx())) == s->matrix.dx()
+-                            && qreal(int(s->matrix.dy())) == s->matrix.dy();
+-        break;
+-
+-    case QTransform::TxScale:
+-        s->flags.int_xform = qreal(int(s->matrix.dx())) == s->matrix.dx()
+-                            && qreal(int(s->matrix.dy())) == s->matrix.dy()
+-                            && qreal(int(s->matrix.m11())) == s->matrix.m11()
+-                            && qreal(int(s->matrix.m22())) == s->matrix.m22();
+-        break;
+-
+-    default: // shear / perspective...
+-        s->flags.int_xform = false;
+-        break;
+-    }
+-
+     s->flags.tx_noshear = qt_scaleForTransform(s->matrix, &s->txscale);
+ 
+     ensureOutlineMapper();
+@@ -617,7 +592,6 @@ QRasterPaintEngineState::QRasterPaintEngineState()
+     flags.bilinear = false;
+     flags.legacy_rounding = false;
+     flags.fast_text = true;
+-    flags.int_xform = true;
+     flags.tx_noshear = true;
+     flags.fast_images = true;
+ 
+@@ -1793,7 +1767,7 @@ void QRasterPaintEngine::fill(const QVectorPath &path, const QBrush &brush)
+     QRectF cpRect = path.controlPointRect();
+     const QRectF pathDeviceRect = s->matrix.mapRect(cpRect);
+     // Skip paths that by conservative estimates are completely outside the paint device.
+-    if (!pathDeviceRect.intersects(QRectF(d->deviceRect)))
++    if (!pathDeviceRect.intersects(QRectF(d->deviceRect)) || !pathDeviceRect.isValid())
+         return;
+ 
+     ProcessSpans blend = d->getBrushFunc(pathDeviceRect, &s->brushData);
+diff --git a/qtbase/src/gui/painting/qpaintengine_raster_p.h b/qtbase/src/gui/painting/qpaintengine_raster_p.h
+index 089aadc3f7..bf7363d5aa 100644
+--- a/qtbase/src/gui/painting/qpaintengine_raster_p.h
++++ b/qtbase/src/gui/painting/qpaintengine_raster_p.h
+@@ -111,7 +111,6 @@ public:
+         uint bilinear : 1;
+         uint legacy_rounding : 1;
+         uint fast_text : 1;
+-        uint int_xform : 1;
+         uint tx_noshear : 1;
+         uint fast_images : 1;
+     };
+diff --git a/qtbase/src/gui/painting/qpainterpath.cpp b/qtbase/src/gui/painting/qpainterpath.cpp
+index f9544a3241..d80fafeaf1 100644
+--- a/qtbase/src/gui/painting/qpainterpath.cpp
++++ b/qtbase/src/gui/painting/qpainterpath.cpp
+@@ -1253,7 +1253,7 @@ void QPainterPath::addText(const QPointF &point, const QFont &f, const QString &
+ 
+         if (si.analysis.flags < QScriptAnalysis::TabOrObject) {
+             QGlyphLayout glyphs = eng->shapedGlyphs(&si);
+-            QFontEngine *fe = f.d->engineForScript(si.analysis.script);
++            QFontEngine *fe = eng->fontEngine(si);
+             Q_ASSERT(fe);
+             fe->addOutlineToPath(x, y, glyphs, this,
+                                  si.analysis.bidiLevel % 2
+diff --git a/qtbase/src/gui/painting/qpathclipper_p.h b/qtbase/src/gui/painting/qpathclipper_p.h
+index 9444a87b71..18f64c5e8c 100644
+--- a/qtbase/src/gui/painting/qpathclipper_p.h
++++ b/qtbase/src/gui/painting/qpathclipper_p.h
+@@ -156,7 +156,7 @@ public:
+     int vertex(Direction direction) const;
+ 
+ private:
+-    int m_next[2][2];
++    int m_next[2][2] = { { -1, -1 }, { -1, -1 } };
+ };
+ 
+ class QPathSegments
+@@ -296,10 +296,6 @@ inline QPathEdge::QPathEdge(int a, int b)
+     , angle(0)
+     , invAngle(0)
+ {
+-    m_next[0][0] = -1;
+-    m_next[1][0] = -1;
+-    m_next[0][0] = -1;
+-    m_next[1][0] = -1;
+ }
+ 
+ inline int QPathEdge::next(Traversal traversal, Direction direction) const
+diff --git a/qtbase/src/gui/painting/qpdf.cpp b/qtbase/src/gui/painting/qpdf.cpp
+index 3066744f1b..2c8d3c3b53 100644
+--- a/qtbase/src/gui/painting/qpdf.cpp
++++ b/qtbase/src/gui/painting/qpdf.cpp
+@@ -2760,6 +2760,8 @@ int QPdfEnginePrivate::addBrushPattern(const QTransform &m, bool *specifyColor,
+         return gradientBrush(brush, matrix, gStateObject);
+     }
+ 
++    matrix = brush.transform() * matrix;
++
+     if ((!brush.isOpaque() && brush.style() < Qt::LinearGradientPattern) || opacity != 1.0)
+         *gStateObject = addConstantAlphaObject(qRound(brush.color().alpha() * opacity),
+                                                qRound(pen.color().alpha() * opacity));
+diff --git a/qtbase/src/gui/painting/qstroker.cpp b/qtbase/src/gui/painting/qstroker.cpp
+index cb5d395e80..3b6357a893 100644
+--- a/qtbase/src/gui/painting/qstroker.cpp
++++ b/qtbase/src/gui/painting/qstroker.cpp
+@@ -1182,6 +1182,7 @@ void QDashStroker::processCurrentSubpath()
+         // Check if the entire line should be clipped away or simplified
+         bool clipIt = clipping && !lineIntersectsRect(prev, e, clip_tl, clip_br);
+         bool skipDashing = elen * invSumLength > repetitionLimit();
++        int maxDashes = dashCount;
+         if (skipDashing || clipIt) {
+             // Cut away full dash sequences.
+             elen -= std::floor(elen * invSumLength) * sumLength;
+@@ -1196,7 +1197,7 @@ void QDashStroker::processCurrentSubpath()
+                     pos = estop; // move pos to next path element
+                     done = true;
+                 } else { // Dash is on this line
+-                    pos = dpos + estart;
++                    pos = --maxDashes > 0 ? dpos + estart : estop;
+                     done = pos >= estop;
+                     if (++idash >= dashCount)
+                         idash = 0;
+diff --git a/qtbase/src/gui/painting/qt_attribution.json b/qtbase/src/gui/painting/qt_attribution.json
+index 7b16e8c211..0e87d30aa2 100644
+--- a/qtbase/src/gui/painting/qt_attribution.json
++++ b/qtbase/src/gui/painting/qt_attribution.json
+@@ -10,7 +10,7 @@
+         "Homepage": "http://www.freetype.org",
+         "License": "Freetype Project License or GNU General Public License v2.0 only",
+         "LicenseId": "FTL or GPL-2.0",
+-        "LicenseFile": "../../3rdparty/freetype/docs/LICENSE.TXT",
++        "LicenseFile": "../../3rdparty/freetype/LICENSE.TXT",
+         "Copyright": "Copyright 2000-2016 by David Turner, Robert Wilhelm, and Werner Lemberg."
+     },
+     {
+diff --git a/qtbase/src/gui/rhi/qshader_p_p.h b/qtbase/src/gui/rhi/qshader_p_p.h
+index ec9d25971f..4a5a7a6d51 100644
+--- a/qtbase/src/gui/rhi/qshader_p_p.h
++++ b/qtbase/src/gui/rhi/qshader_p_p.h
+@@ -68,13 +68,13 @@ struct Q_GUI_EXPORT QShaderPrivate
+     {
+     }
+ 
+-    QShaderPrivate(const QShaderPrivate *other)
++    QShaderPrivate(const QShaderPrivate &other)
+         : ref(1),
+-          qsbVersion(other->qsbVersion),
+-          stage(other->stage),
+-          desc(other->desc),
+-          shaders(other->shaders),
+-          bindings(other->bindings)
++          qsbVersion(other.qsbVersion),
++          stage(other.stage),
++          desc(other.desc),
++          shaders(other.shaders),
++          bindings(other.bindings)
+     {
+     }
+ 
+diff --git a/qtbase/src/gui/rhi/qshaderdescription_p_p.h b/qtbase/src/gui/rhi/qshaderdescription_p_p.h
+index ec2b0b6b4c..3da33a8a2b 100644
+--- a/qtbase/src/gui/rhi/qshaderdescription_p_p.h
++++ b/qtbase/src/gui/rhi/qshaderdescription_p_p.h
+@@ -63,16 +63,16 @@ struct Q_GUI_EXPORT QShaderDescriptionPrivate
+         localSize[0] = localSize[1] = localSize[2] = 0;
+     }
+ 
+-    QShaderDescriptionPrivate(const QShaderDescriptionPrivate *other)
++    QShaderDescriptionPrivate(const QShaderDescriptionPrivate &other)
+         : ref(1),
+-          inVars(other->inVars),
+-          outVars(other->outVars),
+-          uniformBlocks(other->uniformBlocks),
+-          pushConstantBlocks(other->pushConstantBlocks),
+-          storageBlocks(other->storageBlocks),
+-          combinedImageSamplers(other->combinedImageSamplers),
+-          storageImages(other->storageImages),
+-          localSize(other->localSize)
++          inVars(other.inVars),
++          outVars(other.outVars),
++          uniformBlocks(other.uniformBlocks),
++          pushConstantBlocks(other.pushConstantBlocks),
++          storageBlocks(other.storageBlocks),
++          combinedImageSamplers(other.combinedImageSamplers),
++          storageImages(other.storageImages),
++          localSize(other.localSize)
+     {
+     }
+ 
+diff --git a/qtbase/src/gui/text/qfontdatabase.cpp b/qtbase/src/gui/text/qfontdatabase.cpp
+index a657a8c516..4fc0100958 100644
+--- a/qtbase/src/gui/text/qfontdatabase.cpp
++++ b/qtbase/src/gui/text/qfontdatabase.cpp
+@@ -983,7 +983,7 @@ QFontEngine *loadSingleEngine(int script,
+         if (style->key.stretch != 0 && request.stretch != 0
+             && (request.styleName.isEmpty() || request.styleName != style->styleName)) {
+             def.stretch = (request.stretch * 100 + style->key.stretch / 2) / style->key.stretch;
+-        } else {
++        } else if (request.stretch == QFont::AnyStretch) {
+             def.stretch = 100;
+         }
+ 
+diff --git a/qtbase/src/gui/text/qtextdocumentlayout.cpp b/qtbase/src/gui/text/qtextdocumentlayout.cpp
+index f3e6ea2100..72267e9380 100644
+--- a/qtbase/src/gui/text/qtextdocumentlayout.cpp
++++ b/qtbase/src/gui/text/qtextdocumentlayout.cpp
+@@ -2123,7 +2123,7 @@ void QTextDocumentLayoutPrivate::drawListItem(const QPointF &offset, QPainter *p
+ {
+     Q_Q(const QTextDocumentLayout);
+     const QTextBlockFormat blockFormat = bl.blockFormat();
+-    const QTextCharFormat charFormat = QTextCursor(bl).charFormat();
++    const QTextCharFormat charFormat = bl.charFormat();
+     QFont font(charFormat.font());
+     if (q->paintDevice())
+         font = QFont(font, q->paintDevice());
+diff --git a/qtbase/src/gui/text/qtextengine.cpp b/qtbase/src/gui/text/qtextengine.cpp
+index ce4abac472..a6c66e5d2d 100644
+--- a/qtbase/src/gui/text/qtextengine.cpp
++++ b/qtbase/src/gui/text/qtextengine.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2021 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtGui module of the Qt Toolkit.
+@@ -1565,6 +1565,12 @@ void QTextEngine::shapeText(int item) const
+         // Overwrite with 0 token to indicate failure
+         QGlyphLayout g = availableGlyphs(&si);
+         g.glyphs[0] = 0;
++        g.attributes[0].clusterStart = true;
++
++        ushort *log_clusters = logClusters(&si);
++        for (int i = 0; i < itemLength; ++i)
++            log_clusters[i] = 0;
++
+         return;
+     }
+ 
+diff --git a/qtbase/src/gui/util/qdesktopservices.cpp b/qtbase/src/gui/util/qdesktopservices.cpp
+index fbb63a9408..4d5fafaaa7 100644
+--- a/qtbase/src/gui/util/qdesktopservices.cpp
++++ b/qtbase/src/gui/util/qdesktopservices.cpp
+@@ -54,6 +54,8 @@
+ #include <qpa/qplatformintegration.h>
+ #include <qdir.h>
+ 
++#include <QtCore/private/qlocking_p.h>
++
+ QT_BEGIN_NAMESPACE
+ 
+ class QOpenUrlHandlerRegistry : public QObject
+@@ -81,6 +83,7 @@ Q_GLOBAL_STATIC(QOpenUrlHandlerRegistry, handlerRegistry)
+ 
+ void QOpenUrlHandlerRegistry::handlerDestroyed(QObject *handler)
+ {
++    const auto lock = qt_scoped_lock(mutex);
+     HandlerHash::Iterator it = handlers.begin();
+     while (it != handlers.end()) {
+         if (it->receiver == handler) {
+@@ -294,7 +297,8 @@ void QDesktopServices::setUrlHandler(const QString &scheme, QObject *receiver, c
+     h.name = method;
+     registry->handlers.insert(scheme.toLower(), h);
+     QObject::connect(receiver, SIGNAL(destroyed(QObject*)),
+-                     registry, SLOT(handlerDestroyed(QObject*)));
++                     registry, SLOT(handlerDestroyed(QObject*)),
++                     Qt::DirectConnection);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/gui/util/qpkmhandler.cpp b/qtbase/src/gui/util/qpkmhandler.cpp
+index e0c3b75efe..3414f9d8ba 100644
+--- a/qtbase/src/gui/util/qpkmhandler.cpp
++++ b/qtbase/src/gui/util/qpkmhandler.cpp
+@@ -57,7 +57,7 @@ struct PkmType
+     quint32 bytesPerBlock;
+ };
+ 
+-static PkmType typeMap[5] = {
++static constexpr PkmType typeMap[5] = {
+     { 0x8D64,  8 },   // GL_ETC1_RGB8_OES
+     { 0x9274,  8 },   // GL_COMPRESSED_RGB8_ETC2
+     { 0, 0 },         // unused (obsolete)
+diff --git a/qtbase/src/network/access/qnetworkreplyfileimpl.cpp b/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
+index b6be93147a..6e69b4c4d3 100644
+--- a/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
++++ b/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
+@@ -89,9 +89,10 @@ QNetworkReplyFileImpl::QNetworkReplyFileImpl(QNetworkAccessManager *manager, con
+         // we handle only local files
+         QString msg = QCoreApplication::translate("QNetworkAccessFileBackend", "Request for opening non-local file %1").arg(url.toString());
+         setError(QNetworkReply::ProtocolInvalidOperationError, msg);
++        setFinished(true); // We're finished, will emit finished() after ctor is done.
+         QMetaObject::invokeMethod(this, "errorOccurred", Qt::QueuedConnection,
+             Q_ARG(QNetworkReply::NetworkError, QNetworkReply::ProtocolInvalidOperationError));
+-        fileOpenFinished(false);
++        QMetaObject::invokeMethod(this, [this](){ fileOpenFinished(false); }, Qt::QueuedConnection);
+         return;
+     }
+ #endif
+diff --git a/qtbase/src/network/access/qnetworkreplyimpl.cpp b/qtbase/src/network/access/qnetworkreplyimpl.cpp
+index bcdf6ee2f1..3b6deb82bd 100644
+--- a/qtbase/src/network/access/qnetworkreplyimpl.cpp
++++ b/qtbase/src/network/access/qnetworkreplyimpl.cpp
+@@ -680,7 +680,7 @@ void QNetworkReplyImplPrivate::appendDownstreamData(QIODevice *data)
+     // read until EOF from data
+     if (Q_UNLIKELY(copyDevice)) {
+         qCritical("QNetworkReplyImpl: copy from QIODevice already in progress -- "
+-                  "backend probly needs to be fixed");
++                  "backend probably needs to be fixed");
+         return;
+     }
+ 
+diff --git a/qtbase/src/network/kernel/qauthenticator.cpp b/qtbase/src/network/kernel/qauthenticator.cpp
+index d9fe7bc47b..ccd04b294a 100644
+--- a/qtbase/src/network/kernel/qauthenticator.cpp
++++ b/qtbase/src/network/kernel/qauthenticator.cpp
+@@ -50,6 +50,7 @@
+ #include <qstring.h>
+ #include <qdatetime.h>
+ #include <qrandom.h>
++#include "private/qsystemlibrary_p.h"
+ 
+ #ifdef Q_OS_WIN
+ #include <qmutex.h>
+@@ -1563,7 +1564,7 @@ static bool q_SSPI_library_load()
+ 
+     // Initialize security interface
+     if (pSecurityFunctionTable == nullptr) {
+-        securityDLLHandle = LoadLibrary(L"secur32.dll");
++        securityDLLHandle = QSystemLibrary::load(L"secur32");
+         if (securityDLLHandle != nullptr) {
+             INIT_SECURITY_INTERFACE pInitSecurityInterface =
+                 reinterpret_cast<INIT_SECURITY_INTERFACE>(
+diff --git a/qtbase/src/network/kernel/qhostinfo_unix.cpp b/qtbase/src/network/kernel/qhostinfo_unix.cpp
+index 9b0a2ee669..73679c9ef1 100644
+--- a/qtbase/src/network/kernel/qhostinfo_unix.cpp
++++ b/qtbase/src/network/kernel/qhostinfo_unix.cpp
+@@ -122,7 +122,6 @@ static QFunctionPointer resolveSymbol(QLibrary &lib, const char *sym)
+ 
+ LibResolv::LibResolv()
+ {
+-    QLibrary lib;
+ #ifdef LIBRESOLV_SO
+     lib.setFileName(QStringLiteral(LIBRESOLV_SO));
+     if (!lib.load())
+diff --git a/qtbase/src/network/socket/qsocks5socketengine.cpp b/qtbase/src/network/socket/qsocks5socketengine.cpp
+index 3a046fd116..97fadca0b3 100644
+--- a/qtbase/src/network/socket/qsocks5socketengine.cpp
++++ b/qtbase/src/network/socket/qsocks5socketengine.cpp
+@@ -1296,7 +1296,7 @@ void QSocks5SocketEnginePrivate::_q_udpSocketReadNotification()
+         int pos = 0;
+         const char *buf = inBuf.constData();
+         if (inBuf.size() < 4) {
+-            QSOCKS5_D_DEBUG << "bugus udp data, discarding";
++            QSOCKS5_D_DEBUG << "bogus udp data, discarding";
+             return;
+         }
+         QSocks5RevivedDatagram datagram;
+diff --git a/qtbase/src/network/ssl/qsslcontext_openssl.cpp b/qtbase/src/network/ssl/qsslcontext_openssl.cpp
+index c9f202f573..c992da9d8e 100644
+--- a/qtbase/src/network/ssl/qsslcontext_openssl.cpp
++++ b/qtbase/src/network/ssl/qsslcontext_openssl.cpp
+@@ -409,7 +409,7 @@ init_context:
+         break;
+     case QSsl::DtlsV1_0OrLater:
+         minVersion = DTLS1_VERSION;
+-        maxVersion = DTLS_MAX_VERSION;
++        maxVersion = 0;
+         break;
+     case QSsl::DtlsV1_2:
+         minVersion = DTLS1_2_VERSION;
+@@ -417,7 +417,7 @@ init_context:
+         break;
+     case QSsl::DtlsV1_2OrLater:
+         minVersion = DTLS1_2_VERSION;
+-        maxVersion = DTLS_MAX_VERSION;
++        maxVersion = 0;
+         break;
+     case QSsl::TlsV1_3OrLater:
+ #ifdef TLS1_3_VERSION
+@@ -455,7 +455,7 @@ init_context:
+     }
+ 
+     // Enable bug workarounds.
+-    long options = QSslSocketBackendPrivate::setupOpenSslOptions(configuration.protocol(), configuration.d->sslOptions);
++    qssloptions options = QSslSocketBackendPrivate::setupOpenSslOptions(configuration.protocol(), configuration.d->sslOptions);
+     q_SSL_CTX_set_options(sslContext->ctx, options);
+ 
+     // Tell OpenSSL to release memory early
+diff --git a/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp b/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
+index aaf8741130..b58935372c 100644
+--- a/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
++++ b/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
+@@ -59,57 +59,6 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-#ifdef OPENSSL_NO_DEPRECATED_3_0
+-
+-static int q_DH_check(DH *dh, int *status)
+-{
+-    // DH_check was first deprecated in OpenSSL 3.0.0, as low-level
+-    // API; the EVP_PKEY family of functions was advised as an alternative.
+-    // As of now EVP_PKEY_params_check ends up calling ... DH_check,
+-    // which is good enough.
+-
+-    Q_ASSERT(dh);
+-    Q_ASSERT(status);
+-
+-    EVP_PKEY *key = q_EVP_PKEY_new();
+-    if (!key) {
+-        qCWarning(lcSsl, "EVP_PKEY_new failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-    const auto keyDeleter = qScopeGuard([key](){
+-        q_EVP_PKEY_free(key);
+-    });
+-    if (!q_EVP_PKEY_set1_DH(key, dh)) {
+-        qCWarning(lcSsl, "EVP_PKEY_set1_DH failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-
+-    EVP_PKEY_CTX *keyCtx = q_EVP_PKEY_CTX_new(key, nullptr);
+-    if (!keyCtx) {
+-        qCWarning(lcSsl, "EVP_PKEY_CTX_new failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-    const auto ctxDeleter = qScopeGuard([keyCtx]{
+-        q_EVP_PKEY_CTX_free(keyCtx);
+-    });
+-
+-    const int result = q_EVP_PKEY_param_check(keyCtx);
+-    QSslSocketBackendPrivate::logAndClearErrorQueue();
+-    // Note: unlike DH_check, we cannot obtain the 'status',
+-    // if the 'result' is 0 (actually the result is 1 only
+-    // if this 'status' was 0). We could probably check the
+-    // errors from the error queue, but it's not needed anyway
+-    // - see the 'isSafeDH' below, how it returns immediately
+-    // on 0.
+-    Q_UNUSED(status)
+-
+-    return result;
+-}
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+-
+ static bool isSafeDH(DH *dh)
+ {
+     int status = 0;
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl.cpp b/qtbase/src/network/ssl/qsslsocket_openssl.cpp
+index 37fad2a68f..8f6858c867 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl.cpp
++++ b/qtbase/src/network/ssl/qsslsocket_openssl.cpp
+@@ -550,9 +550,9 @@ static void q_loadCiphersForConnection(SSL *connection, QList<QSslCipher> &ciphe
+ // Defined in qsslsocket.cpp
+ void q_setDefaultDtlsCiphers(const QList<QSslCipher> &ciphers);
+ 
+-long QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions)
++qssloptions QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions)
+ {
+-    long options;
++    qssloptions options;
+     if (protocol == QSsl::TlsV1SslV3)
+         options = SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3;
+     else if (protocol == QSsl::SecureProtocols)
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_p.h b/qtbase/src/network/ssl/qsslsocket_openssl_p.h
+index 4103de23e8..5547589256 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_p.h
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_p.h
+@@ -107,6 +107,12 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++typedef uint64_t qssloptions;
++#else
++typedef unsigned long qssloptions;
++#endif
++
+ struct QSslErrorEntry {
+     int code;
+     int depth;
+@@ -171,7 +177,7 @@ public:
+     QVector<QSslError> ocspErrors;
+     QByteArray ocspResponseDer;
+ 
+-    Q_AUTOTEST_EXPORT static long setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions);
++    Q_AUTOTEST_EXPORT static qssloptions setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions);
+     static QSslCipher QSslCipher_from_SSL_CIPHER(const SSL_CIPHER *cipher);
+     static QList<QSslCertificate> STACKOFX509_to_QSslCertificates(STACK_OF(X509) *x509);
+     static QList<QSslError> verify(const QList<QSslCertificate> &certificateChain, const QString &hostName);
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp b/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
+index e53fb279f0..459ccd0b19 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
+@@ -148,7 +148,6 @@ DEFINEFUNC(int, EVP_PKEY_up_ref, EVP_PKEY *a, a, return 0, return)
+ DEFINEFUNC2(EVP_PKEY_CTX *, EVP_PKEY_CTX_new, EVP_PKEY *pkey, pkey, ENGINE *e, e, return nullptr, return)
+ DEFINEFUNC(int, EVP_PKEY_param_check, EVP_PKEY_CTX *ctx, ctx, return 0, return)
+ DEFINEFUNC(void, EVP_PKEY_CTX_free, EVP_PKEY_CTX *ctx, ctx, return, return)
+-DEFINEFUNC(int, EVP_PKEY_base_id, EVP_PKEY *a, a, return NID_undef, return)
+ DEFINEFUNC(int, RSA_bits, RSA *a, a, return 0, return)
+ DEFINEFUNC(int, DSA_bits, DSA *a, a, return 0, return)
+ DEFINEFUNC(int, OPENSSL_sk_num, OPENSSL_STACK *a, a, return -1, return)
+@@ -158,7 +157,7 @@ DEFINEFUNC2(void, OPENSSL_sk_push, OPENSSL_STACK *a, a, void *b, b, return, DUMM
+ DEFINEFUNC(void, OPENSSL_sk_free, OPENSSL_STACK *a, a, return, DUMMYARG)
+ DEFINEFUNC2(void *, OPENSSL_sk_value, OPENSSL_STACK *a, a, int b, b, return nullptr, return)
+ DEFINEFUNC(int, SSL_session_reused, SSL *a, a, return 0, return)
+-DEFINEFUNC2(unsigned long, SSL_CTX_set_options, SSL_CTX *ctx, ctx, unsigned long op, op, return 0, return)
++DEFINEFUNC2(qssloptions, SSL_CTX_set_options, SSL_CTX *ctx, ctx, qssloptions op, op, return 0, return)
+ DEFINEFUNC(int, SSL_CTX_get_security_level, const SSL_CTX *ctx, ctx, return -1, return)
+ DEFINEFUNC2(void, SSL_CTX_set_security_level, SSL_CTX *ctx, ctx, int level, level, return, return)
+ #ifdef TLS1_3_VERSION
+@@ -371,7 +370,15 @@ DEFINEFUNC(const SSL_CIPHER *, SSL_get_current_cipher, SSL *a, a, return nullptr
+ DEFINEFUNC(int, SSL_version, const SSL *a, a, return 0, return)
+ DEFINEFUNC2(int, SSL_get_error, SSL *a, a, int b, b, return -1, return)
+ DEFINEFUNC(STACK_OF(X509) *, SSL_get_peer_cert_chain, SSL *a, a, return nullptr, return)
++
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++DEFINEFUNC(X509 *, SSL_get1_peer_certificate, SSL *a, a, return nullptr, return)
++DEFINEFUNC(int, EVP_PKEY_get_base_id, const EVP_PKEY *pkey, pkey, return -1, return)
++#else
+ DEFINEFUNC(X509 *, SSL_get_peer_certificate, SSL *a, a, return nullptr, return)
++DEFINEFUNC(int, EVP_PKEY_base_id, EVP_PKEY *a, a, return NID_undef, return)
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+ DEFINEFUNC(long, SSL_get_verify_result, const SSL *a, a, return -1, return)
+ DEFINEFUNC(SSL *, SSL_new, SSL_CTX *a, a, return nullptr, return)
+ DEFINEFUNC(SSL_CTX *, SSL_get_SSL_CTX, SSL *a, a, return nullptr, return)
+@@ -492,9 +499,7 @@ DEFINEFUNC(DH *, DH_new, DUMMYARG, DUMMYARG, return nullptr, return)
+ DEFINEFUNC(void, DH_free, DH *dh, dh, return, DUMMYARG)
+ DEFINEFUNC3(DH *, d2i_DHparams, DH**a, a, const unsigned char **pp, pp, long length, length, return nullptr, return)
+ DEFINEFUNC2(int, i2d_DHparams, DH *a, a, unsigned char **p, p, return -1, return)
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+ DEFINEFUNC2(int, DH_check, DH *dh, dh, int *codes, codes, return 0, return)
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+ DEFINEFUNC3(BIGNUM *, BN_bin2bn, const unsigned char *s, s, int len, len, BIGNUM *ret, ret, return nullptr, return)
+ 
+ #ifndef OPENSSL_NO_EC
+@@ -868,7 +873,6 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(EVP_PKEY_CTX_new)
+     RESOLVEFUNC(EVP_PKEY_param_check)
+     RESOLVEFUNC(EVP_PKEY_CTX_free)
+-    RESOLVEFUNC(EVP_PKEY_base_id)
+     RESOLVEFUNC(RSA_bits)
+     RESOLVEFUNC(OPENSSL_sk_new_null)
+     RESOLVEFUNC(OPENSSL_sk_push)
+@@ -1107,7 +1111,15 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(SSL_version)
+     RESOLVEFUNC(SSL_get_error)
+     RESOLVEFUNC(SSL_get_peer_cert_chain)
++
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++    RESOLVEFUNC(SSL_get1_peer_certificate)
++    RESOLVEFUNC(EVP_PKEY_get_base_id)
++#else
+     RESOLVEFUNC(SSL_get_peer_certificate)
++    RESOLVEFUNC(EVP_PKEY_base_id)
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+     RESOLVEFUNC(SSL_get_verify_result)
+     RESOLVEFUNC(SSL_new)
+     RESOLVEFUNC(SSL_get_SSL_CTX)
+@@ -1206,9 +1218,7 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(DH_free)
+     RESOLVEFUNC(d2i_DHparams)
+     RESOLVEFUNC(i2d_DHparams)
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+     RESOLVEFUNC(DH_check)
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+     RESOLVEFUNC(BN_bin2bn)
+ 
+ #ifndef OPENSSL_NO_EC
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h b/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
+index 95e8897a3b..27aeffa18a 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
+@@ -237,7 +237,6 @@ Q_AUTOTEST_EXPORT int q_EVP_PKEY_up_ref(EVP_PKEY *a);
+ EVP_PKEY_CTX *q_EVP_PKEY_CTX_new(EVP_PKEY *pkey, ENGINE *e);
+ void q_EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx);
+ int q_EVP_PKEY_param_check(EVP_PKEY_CTX *ctx);
+-int q_EVP_PKEY_base_id(EVP_PKEY *a);
+ int q_RSA_bits(RSA *a);
+ Q_AUTOTEST_EXPORT int q_OPENSSL_sk_num(OPENSSL_STACK *a);
+ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_pop_free(OPENSSL_STACK *a, void (*b)(void *));
+@@ -246,7 +245,7 @@ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_push(OPENSSL_STACK *st, void *data);
+ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_free(OPENSSL_STACK *a);
+ Q_AUTOTEST_EXPORT void * q_OPENSSL_sk_value(OPENSSL_STACK *a, int b);
+ int q_SSL_session_reused(SSL *a);
+-unsigned long q_SSL_CTX_set_options(SSL_CTX *ctx, unsigned long op);
++qssloptions q_SSL_CTX_set_options(SSL_CTX *ctx, qssloptions op);
+ int q_OPENSSL_init_ssl(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings);
+ size_t q_SSL_get_client_random(SSL *a, unsigned char *out, size_t outlen);
+ size_t q_SSL_SESSION_get_master_key(const SSL_SESSION *session, unsigned char *out, size_t outlen);
+@@ -510,7 +509,6 @@ const SSL_CIPHER *q_SSL_get_current_cipher(SSL *a);
+ int q_SSL_version(const SSL *a);
+ int q_SSL_get_error(SSL *a, int b);
+ STACK_OF(X509) *q_SSL_get_peer_cert_chain(SSL *a);
+-X509 *q_SSL_get_peer_certificate(SSL *a);
+ long q_SSL_get_verify_result(const SSL *a);
+ SSL *q_SSL_new(SSL_CTX *a);
+ SSL_CTX *q_SSL_get_SSL_CTX(SSL *a);
+@@ -582,10 +580,7 @@ DH *q_DH_new();
+ void q_DH_free(DH *dh);
+ DH *q_d2i_DHparams(DH **a, const unsigned char **pp, long length);
+ int q_i2d_DHparams(DH *a, unsigned char **p);
+-
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+ int q_DH_check(DH *dh, int *codes);
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+ 
+ BIGNUM *q_BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret);
+ #define q_SSL_CTX_set_tmp_dh(ctx, dh) q_SSL_CTX_ctrl((ctx), SSL_CTRL_SET_TMP_DH, 0, (char *)dh)
+@@ -754,6 +749,17 @@ void q_CRYPTO_free(void *str, const char *file, int line);
+ int q_SSL_CTX_get_security_level(const SSL_CTX *ctx);
+ void q_SSL_CTX_set_security_level(SSL_CTX *ctx, int level);
+ 
++// Here we have the ones that make difference between OpenSSL pre/post v3:
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++X509 *q_SSL_get1_peer_certificate(SSL *a);
++#define q_SSL_get_peer_certificate q_SSL_get1_peer_certificate
++int q_EVP_PKEY_get_base_id(const EVP_PKEY *pkey);
++#define q_EVP_PKEY_base_id q_EVP_PKEY_get_base_id
++#else
++X509 *q_SSL_get_peer_certificate(SSL *a);
++int q_EVP_PKEY_base_id(EVP_PKEY *a);
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+ QT_END_NAMESPACE
+ 
+ #endif
+diff --git a/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h b/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
+index bf37d07fd8..dbd42fb799 100644
+--- a/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
++++ b/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
+@@ -61,7 +61,11 @@
+ # if !defined(Q_OS_INTEGRITY)
+ #  define WIN_INTERFACE_CUSTOM   // NV
+ # endif // Q_OS_INTEGRITY
+-#endif  // QT_EGL_NO_X11
++#else // QT_EGL_NO_X11
++// If one has an eglplatform.h with https://github.com/KhronosGroup/EGL-Registry/pull/130
++// that needs USE_X11 to be defined.
++# define USE_X11
++#endif
+ 
+ #ifdef QT_EGL_WAYLAND
+ # define WAYLAND // NV
+diff --git a/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+index 159b490ce0..00aa80cd58 100644
+--- a/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
++++ b/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+@@ -567,6 +567,8 @@ void QFontconfigDatabase::populateFontDatabase()
+         fonts = FcFontList(nullptr, pattern, os);
+         FcObjectSetDestroy(os);
+         FcPatternDestroy(pattern);
++        if (!fonts)
++            return;
+     }
+ 
+     for (int i = 0; i < fonts->nfont; i++)
+diff --git a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
+index b713c19447..7cb9a8c79a 100644
+--- a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
++++ b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
+@@ -95,6 +95,7 @@ static constexpr const auto KeyTbl = qMakeArray(
+         Xkb2Qt<XKB_KEY_Clear,                   Qt::Key_Delete>,
+         Xkb2Qt<XKB_KEY_Pause,                   Qt::Key_Pause>,
+         Xkb2Qt<XKB_KEY_Print,                   Qt::Key_Print>,
++        Xkb2Qt<XKB_KEY_Sys_Req,                 Qt::Key_SysReq>,
+         Xkb2Qt<0x1005FF60,                      Qt::Key_SysReq>,         // hardcoded Sun SysReq
+         Xkb2Qt<0x1007ff00,                      Qt::Key_SysReq>,         // hardcoded X386 SysReq
+ 
+@@ -471,7 +472,7 @@ QVector<xkb_keysym_t> QXkbCommon::toKeysym(QKeyEvent *event)
+     } else if (event->modifiers() & Qt::KeypadModifier) {
+         if (qtKey >= Qt::Key_0 && qtKey <= Qt::Key_9)
+             keysyms.append(XKB_KEY_KP_0 + (qtKey - Qt::Key_0));
+-    } else if (isLatin(qtKey) && event->text().isUpper()) {
++    } else if (isLatin1(qtKey) && event->text().isUpper()) {
+         keysyms.append(qtKey);
+     }
+ 
+@@ -523,7 +524,7 @@ int QXkbCommon::keysymToQtKey(xkb_keysym_t keysym, Qt::KeyboardModifiers modifie
+         // With standard shortcuts we should prefer a latin character, this is
+         // for checks like "some qkeyevent == QKeySequence::Copy" to work even
+         // when using for example 'russian' keyboard layout.
+-        if (!QXkbCommon::isLatin(keysym)) {
++        if (!QXkbCommon::isLatin1(keysym)) {
+             xkb_keysym_t latinKeysym = QXkbCommon::lookupLatinKeysym(state, code);
+             if (latinKeysym != XKB_KEY_NoSymbol)
+                 keysym = latinKeysym;
+@@ -546,7 +547,7 @@ static int keysymToQtKey_internal(xkb_keysym_t keysym, Qt::KeyboardModifiers mod
+     } else if (keysym >= XKB_KEY_KP_0 && keysym <= XKB_KEY_KP_9) {
+         // numeric keypad keys
+         qtKey = Qt::Key_0 + (keysym - XKB_KEY_KP_0);
+-    } else if (QXkbCommon::isLatin(keysym)) {
++    } else if (QXkbCommon::isLatin1(keysym)) {
+         qtKey = QXkbCommon::qxkbcommon_xkb_keysym_to_upper(keysym);
+     } else {
+         // check if we have a direct mapping
+@@ -678,7 +679,7 @@ QList<int> QXkbCommon::possibleKeys(xkb_state *state, const QKeyEvent *event,
+         Qt::KeyboardModifiers neededMods = ModsTbl[i];
+         if ((modifiers & neededMods) == neededMods) {
+             if (i == 8) {
+-                if (isLatin(baseQtKey))
++                if (isLatin1(baseQtKey))
+                     continue;
+                 // add a latin key as a fall back key
+                 sym = lookupLatinKeysym(state, keycode);
+@@ -733,7 +734,7 @@ void QXkbCommon::verifyHasLatinLayout(xkb_keymap *keymap)
+     for (xkb_layout_index_t layout = 0; layout < layoutCount; ++layout) {
+         for (xkb_keycode_t code = minKeycode; code < maxKeycode; ++code) {
+             xkb_keymap_key_get_syms_by_level(keymap, code, layout, 0, &keysyms);
+-            if (keysyms && isLatin(keysyms[0]))
++            if (keysyms && isLatin1(keysyms[0]))
+                 nrLatinKeys++;
+             if (nrLatinKeys > 10) // arbitrarily chosen threshold
+                 return;
+@@ -766,7 +767,7 @@ xkb_keysym_t QXkbCommon::lookupLatinKeysym(xkb_state *state, xkb_keycode_t keyco
+         xkb_level_index_t level = xkb_state_key_get_level(state, keycode, layout);
+         if (xkb_keymap_key_get_syms_by_level(keymap, keycode, layout, level, &syms) != 1)
+             continue;
+-        if (isLatin(syms[0])) {
++        if (isLatin1(syms[0])) {
+             sym = syms[0];
+             break;
+         }
+diff --git a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
+index 561eae03db..8389bd8f5a 100644
+--- a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
++++ b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
+@@ -94,8 +94,8 @@ public:
+     static void verifyHasLatinLayout(xkb_keymap *keymap);
+     static xkb_keysym_t lookupLatinKeysym(xkb_state *state, xkb_keycode_t keycode);
+ 
+-    static bool isLatin(xkb_keysym_t sym) {
+-        return ((sym >= 'a' && sym <= 'z') || (sym >= 'A' && sym <= 'Z'));
++    static bool isLatin1(xkb_keysym_t sym) {
++        return sym <= 0xff;
+     }
+     static bool isKeypad(xkb_keysym_t sym) {
+         return sym >= XKB_KEY_KP_Space && sym <= XKB_KEY_KP_9;
+diff --git a/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp b/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
+index 8cd7f9b368..406f84663f 100644
+--- a/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
++++ b/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
+@@ -318,7 +318,7 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources,
+ 
+     if (current < 0 && crtc_mode.clock != 0) {
+         modes << crtc_mode;
+-        current = mode.size() - 1;
++        current = modes.size() - 1;
+     }
+ 
+     if (configuration == OutputConfigCurrent)
+diff --git a/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp b/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
+index 9153fd20bb..255ea5e33e 100644
+--- a/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
++++ b/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
+@@ -194,6 +194,9 @@ QString AtSpiAdaptor::introspect(const QString &path) const
+                 "      <arg direction=\"out\" type=\"(so)\"/>\n"
+                 "      <annotation value=\"QSpiObjectReference\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n"
+                 "    </method>\n"
++                "    <method name=\"GetAccessibleId\">\n"
++                "      <arg direction=\"out\" type=\"s\"/>\n"
++                "    </method>\n"
+                 "  </interface>\n"
+                 );
+ 
+@@ -913,8 +916,17 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+     }
+     case QAccessible::NameChanged: {
+         if (sendObject || sendObject_property_change || sendObject_property_change_accessible_name) {
+-            QString path = pathForInterface(event->accessibleInterface());
+-            QVariantList args = packDBusSignalArguments(QLatin1String("accessible-name"), 0, 0, variantForPath(path));
++            QAccessibleInterface *iface = event->accessibleInterface();
++            if (!iface) {
++                qCDebug(lcAccessibilityAtspi,
++                        "NameChanged event from invalid accessible.");
++                return;
++            }
++
++            QString path = pathForInterface(iface);
++            QVariantList args = packDBusSignalArguments(
++                QLatin1String("accessible-name"), 0, 0,
++                QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Name))));
+             sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                            QLatin1String("PropertyChange"), args);
+         }
+@@ -922,8 +934,17 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+     }
+     case QAccessible::DescriptionChanged: {
+         if (sendObject || sendObject_property_change || sendObject_property_change_accessible_description) {
+-            QString path = pathForInterface(event->accessibleInterface());
+-            QVariantList args = packDBusSignalArguments(QLatin1String("accessible-description"), 0, 0, variantForPath(path));
++            QAccessibleInterface *iface = event->accessibleInterface();
++            if (!iface) {
++                qCDebug(lcAccessibilityAtspi,
++                        "DescriptionChanged event from invalid accessible.");
++                return;
++            }
++
++            QString path = pathForInterface(iface);
++            QVariantList args = packDBusSignalArguments(
++                QLatin1String("accessible-description"), 0, 0,
++                QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Description))));
+             sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                            QLatin1String("PropertyChange"), args);
+         }
+@@ -1038,7 +1059,9 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+                 // Combo Box with AT-SPI likes to be special
+                 // It requires a name-change to update caches and then selection-changed
+                 QString path = pathForInterface(iface);
+-                QVariantList args1 = packDBusSignalArguments(QLatin1String("accessible-name"), 0, 0, variantForPath(path));
++                QVariantList args1 = packDBusSignalArguments(
++                    QLatin1String("accessible-name"), 0, 0,
++                    QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Name))));
+                 sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                                QLatin1String("PropertyChange"), args1);
+                 QVariantList args2 = packDBusSignalArguments(QString(), 0, 0, QVariant::fromValue(QDBusVariant(QVariant(0))));
+@@ -1358,6 +1381,26 @@ void AtSpiAdaptor::registerApplication()
+     delete registry;
+ }
+ 
++namespace {
++QString accessibleIdForAccessible(QAccessibleInterface *accessible)
++{
++    QString result;
++    while (accessible) {
++        if (!result.isEmpty())
++            result.prepend(QLatin1Char('.'));
++        if (auto obj = accessible->object()) {
++            const QString name = obj->objectName();
++            if (!name.isEmpty())
++                result.prepend(name);
++            else
++                result.prepend(QString::fromUtf8(obj->metaObject()->className()));
++        }
++        accessible = accessible->parent();
++    }
++    return result;
++}
++} // namespace
++
+ // Accessible
+ bool AtSpiAdaptor::accessibleInterface(QAccessibleInterface *interface, const QString &function, const QDBusMessage &message, const QDBusConnection &connection)
+ {
+@@ -1441,6 +1484,9 @@ bool AtSpiAdaptor::accessibleInterface(QAccessibleInterface *interface, const QS
+             children << ref;
+         }
+         connection.send(message.createReply(QVariant::fromValue(children)));
++    } else if (function == QLatin1String("GetAccessibleId")) {
++        sendReply(connection, message,
++                  QVariant::fromValue(QDBusVariant(accessibleIdForAccessible(interface))));
+     } else {
+         qCDebug(lcAccessibilityAtspi) << "WARNING: AtSpiAdaptor::accessibleInterface does not implement " << function << message.path();
+         return false;
+diff --git a/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp b/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
+index 45ddc8e496..cc734abc63 100644
+--- a/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
++++ b/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
+@@ -69,6 +69,21 @@ QT_BEGIN_NAMESPACE
+ DBusConnection::DBusConnection(QObject *parent)
+     : QObject(parent), m_a11yConnection(QString()), m_enabled(false)
+ {
++    // If the bus is explicitly set via env var it overrides everything else.
++    QByteArray addressEnv = qgetenv("AT_SPI_BUS_ADDRESS");
++    if (!addressEnv.isEmpty()) {
++        // Only connect on next loop run, connections to our enabled signal are
++        // only established after the ctor returns.
++        QMetaObject::invokeMethod(
++                this,
++                [this, addressEnv] {
++                    m_enabled = true;
++                    connectA11yBus(QString::fromLocal8Bit(addressEnv));
++                },
++                Qt::QueuedConnection);
++        return;
++    }
++
+     // Start monitoring if "org.a11y.Bus" is registered as DBus service.
+     QDBusConnection c = QDBusConnection::sessionBus();
+     if (!c.isConnected()) {
+diff --git a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
+index 1a3cab275d..2abe039126 100644
+--- a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
++++ b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
+@@ -51,6 +51,9 @@
+ #include <QtCore/QStandardPaths>
+ #include <QtCore/QUrl>
+ 
++#include <QtGui/QGuiApplication>
++#include <QtGui/QWindow>
++
+ #if QT_CONFIG(dbus)
+ // These QtCore includes are needed for xdg-desktop-portal support
+ #include <QtCore/private/qcore_unix_p.h>
+@@ -58,6 +61,8 @@
+ #include <QtCore/QFileInfo>
+ #include <QtCore/QUrlQuery>
+ 
++#include <QtGui/QColor>
++
+ #include <QtDBus/QDBusConnection>
+ #include <QtDBus/QDBusMessage>
+ #include <QtDBus/QDBusPendingCall>
+@@ -142,6 +147,8 @@ static inline bool detectWebBrowser(const QByteArray &desktop,
+     }
+ 
+     if (desktop == QByteArray("KDE")) {
++        if (checkExecutable(QStringLiteral("kde-open5"), browser))
++            return true;
+         // Konqueror launcher
+         if (checkExecutable(QStringLiteral("kfmclient"), browser)) {
+             browser->append(QLatin1String(" exec"));
+@@ -296,8 +303,135 @@ static inline QDBusMessage xdgDesktopPortalSendEmail(const QUrl &url)
+ 
+     return QDBusConnection::sessionBus().call(message);
+ }
++
++namespace {
++struct XDGDesktopColor
++{
++    double r = 0;
++    double g = 0;
++    double b = 0;
++
++    QColor toQColor() const
++    {
++        constexpr auto rgbMax = 255;
++        return { static_cast<int>(r * rgbMax), static_cast<int>(g * rgbMax),
++                 static_cast<int>(b * rgbMax) };
++    }
++};
++
++const QDBusArgument &operator>>(const QDBusArgument &argument, XDGDesktopColor &myStruct)
++{
++    argument.beginStructure();
++    argument >> myStruct.r >> myStruct.g >> myStruct.b;
++    argument.endStructure();
++    return argument;
++}
++
++class XdgDesktopPortalColorPicker : public QPlatformServiceColorPicker
++{
++    Q_OBJECT
++public:
++    XdgDesktopPortalColorPicker(const QString &parentWindowId, QWindow *parent)
++        : QPlatformServiceColorPicker(parent), m_parentWindowId(parentWindowId)
++    {
++    }
++
++    void pickColor() override
++    {
++        // DBus signature:
++        // PickColor (IN   s      parent_window,
++        //            IN   a{sv}  options
++        //            OUT  o      handle)
++        // Options:
++        // handle_token (s) -  A string that will be used as the last element of the @handle.
++
++        QDBusMessage message = QDBusMessage::createMethodCall(
++                QStringLiteral("org.freedesktop.portal.Desktop"), QStringLiteral("/org/freedesktop/portal/desktop"),
++                QStringLiteral("org.freedesktop.portal.Screenshot"), QStringLiteral("PickColor"));
++        message << m_parentWindowId << QVariantMap();
++
++        QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
++        auto watcher = new QDBusPendingCallWatcher(pendingCall, this);
++        connect(watcher, &QDBusPendingCallWatcher::finished, this,
++                [this](QDBusPendingCallWatcher *watcher) {
++                    watcher->deleteLater();
++                    QDBusPendingReply<QDBusObjectPath> reply = *watcher;
++                    if (reply.isError()) {
++                        qWarning("DBus call to pick color failed: %s",
++                                 qPrintable(reply.error().message()));
++                        Q_EMIT colorPicked({});
++                    } else {
++                        QDBusConnection::sessionBus().connect(
++                                QStringLiteral("org.freedesktop.portal.Desktop"), reply.value().path(),
++                                QStringLiteral("org.freedesktop.portal.Request"), QStringLiteral("Response"), this,
++                                // clang-format off
++                                SLOT(gotColorResponse(uint,QVariantMap))
++                                // clang-format on
++                        );
++                    }
++                });
++    }
++
++private Q_SLOTS:
++    void gotColorResponse(uint result, const QVariantMap &map)
++    {
++        if (result != 0)
++            return;
++        XDGDesktopColor color{};
++        map.value(QStringLiteral("color")).value<QDBusArgument>() >> color;
++        Q_EMIT colorPicked(color.toQColor());
++        deleteLater();
++    }
++
++private:
++    const QString m_parentWindowId;
++};
++} // namespace
++
+ #endif // QT_CONFIG(dbus)
+ 
++QGenericUnixServices::QGenericUnixServices()
++{
++#if QT_CONFIG(dbus)
++    if (qEnvironmentVariableIntValue("QT_NO_XDG_DESKTOP_PORTAL") > 0) {
++        return;
++    }
++    QDBusMessage message = QDBusMessage::createMethodCall(
++            QStringLiteral("org.freedesktop.portal.Desktop"), QStringLiteral("/org/freedesktop/portal/desktop"),
++            QStringLiteral("org.freedesktop.DBus.Properties"), QStringLiteral("Get"));
++    message << QStringLiteral("org.freedesktop.portal.Screenshot")
++            << QStringLiteral("version");
++
++    QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
++    auto watcher = new QDBusPendingCallWatcher(pendingCall);
++    QObject::connect(watcher, &QDBusPendingCallWatcher::finished, watcher,
++                     [this](QDBusPendingCallWatcher *watcher) {
++                         watcher->deleteLater();
++                         QDBusPendingReply<QVariant> reply = *watcher;
++                         if (!reply.isError() && reply.value().toUInt() >= 2)
++                             m_hasScreenshotPortalWithColorPicking = true;
++                     });
++
++#endif
++}
++
++QPlatformServiceColorPicker *QGenericUnixServices::colorPicker(QWindow *parent)
++{
++#if QT_CONFIG(dbus)
++    // Make double sure that we are in a wayland environment. In particular check
++    // WAYLAND_DISPLAY so also XWayland apps benefit from portal-based color picking.
++    // Outside wayland we'll rather rely on other means than the XDG desktop portal.
++    if (!qEnvironmentVariableIsEmpty("WAYLAND_DISPLAY")
++        || QGuiApplication::platformName().startsWith(QLatin1String("wayland"))) {
++        return new XdgDesktopPortalColorPicker(portalWindowIdentifier(parent), parent);
++    }
++    return nullptr;
++#else
++    Q_UNUSED(parent);
++    return nullptr;
++#endif
++}
++
+ QByteArray QGenericUnixServices::desktopEnvironment() const
+ {
+     static const QByteArray result = detectDesktopEnvironment();
+@@ -352,6 +486,8 @@ bool QGenericUnixServices::openDocument(const QUrl &url)
+ }
+ 
+ #else
++QGenericUnixServices::QGenericUnixServices() = default;
++
+ QByteArray QGenericUnixServices::desktopEnvironment() const
+ {
+     return QByteArrayLiteral("UNKNOWN");
+@@ -371,6 +507,30 @@ bool QGenericUnixServices::openDocument(const QUrl &url)
+     return false;
+ }
+ 
++QPlatformServiceColorPicker *QGenericUnixServices::colorPicker(QWindow *parent)
++{
++    Q_UNUSED(parent);
++    return nullptr;
++}
++
+ #endif // QT_NO_MULTIPROCESS
+ 
++QString QGenericUnixServices::portalWindowIdentifier(QWindow *window)
++{
++    if (QGuiApplication::platformName() == QLatin1String("xcb"))
++        return QStringLiteral("x11:") + QString::number(window->winId(), 16);
++    return QString();
++}
++
++bool QGenericUnixServices::hasCapability(Capability capability) const
++{
++    switch (capability) {
++    case Capability::ColorPicking:
++        return m_hasScreenshotPortalWithColorPicking;
++    }
++    return false;
++}
++
+ QT_END_NAMESPACE
++
++#include "qgenericunixservices.moc"
+diff --git a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
+index 8ac3de6f03..30924e64bd 100644
+--- a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
++++ b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
+@@ -59,16 +59,21 @@ QT_BEGIN_NAMESPACE
+ class QGenericUnixServices : public QPlatformServices
+ {
+ public:
+-    QGenericUnixServices() {}
++    QGenericUnixServices();
+ 
+     QByteArray desktopEnvironment() const override;
+ 
++    bool hasCapability(Capability capability) const override;
+     bool openUrl(const QUrl &url) override;
+     bool openDocument(const QUrl &url) override;
++    QPlatformServiceColorPicker *colorPicker(QWindow *parent = nullptr) override;
++
++    virtual QString portalWindowIdentifier(QWindow *window);
+ 
+ private:
+     QString m_webBrowser;
+     QString m_documentLauncher;
++    bool m_hasScreenshotPortalWithColorPicking = false;
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
+index 09470bccc6..cc7c7d4d8a 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
+@@ -69,6 +69,7 @@ const QString MenuBarPath = QLatin1String("/MenuBar");
+ */
+ QDBusMenuConnection::QDBusMenuConnection(QObject *parent, const QString &serviceName)
+     : QObject(parent)
++    , m_serviceName(serviceName)
+     , m_connection(serviceName.isNull() ? QDBusConnection::sessionBus()
+                                         : QDBusConnection::connectToBus(QDBusConnection::SessionBus, serviceName))
+     , m_dbusWatcher(new QDBusServiceWatcher(StatusNotifierWatcherService, m_connection, QDBusServiceWatcher::WatchForRegistration, this))
+@@ -83,6 +84,12 @@ QDBusMenuConnection::QDBusMenuConnection(QObject *parent, const QString &service
+ #endif
+ }
+ 
++QDBusMenuConnection::~QDBusMenuConnection()
++{
++  if (!m_serviceName.isEmpty() && m_connection.isConnected())
++      QDBusConnection::disconnectFromBus(m_serviceName);
++}
++
+ void QDBusMenuConnection::dbusError(const QDBusError &error)
+ {
+     qWarning() << "QDBusTrayIcon encountered a D-Bus error:" << error;
+@@ -105,13 +112,7 @@ void QDBusMenuConnection::unregisterTrayIconMenu(QDBusTrayIcon *item)
+ 
+ bool QDBusMenuConnection::registerTrayIcon(QDBusTrayIcon *item)
+ {
+-    bool success = connection().registerService(item->instanceId());
+-    if (!success) {
+-        qWarning() << "failed to register service" << item->instanceId();
+-        return false;
+-    }
+-
+-    success = connection().registerObject(StatusNotifierItemPath, item);
++    bool success = connection().registerObject(StatusNotifierItemPath, item);
+     if (!success) {
+         unregisterTrayIcon(item);
+         qWarning() << "failed to register" << item->instanceId() << StatusNotifierItemPath;
+@@ -126,21 +127,18 @@ bool QDBusMenuConnection::registerTrayIcon(QDBusTrayIcon *item)
+ 
+ bool QDBusMenuConnection::registerTrayIconWithWatcher(QDBusTrayIcon *item)
+ {
++    Q_UNUSED(item);
+     QDBusMessage registerMethod = QDBusMessage::createMethodCall(
+                 StatusNotifierWatcherService, StatusNotifierWatcherPath, StatusNotifierWatcherService,
+                 QLatin1String("RegisterStatusNotifierItem"));
+-    registerMethod.setArguments(QVariantList() << item->instanceId());
++    registerMethod.setArguments(QVariantList() << m_connection.baseService());
+     return m_connection.callWithCallback(registerMethod, this, SIGNAL(trayIconRegistered()), SLOT(dbusError(QDBusError)));
+ }
+ 
+-bool QDBusMenuConnection::unregisterTrayIcon(QDBusTrayIcon *item)
++void QDBusMenuConnection::unregisterTrayIcon(QDBusTrayIcon *item)
+ {
+     unregisterTrayIconMenu(item);
+     connection().unregisterObject(StatusNotifierItemPath);
+-    bool success = connection().unregisterService(item->instanceId());
+-    if (!success)
+-        qWarning() << "failed to unregister service" << item->instanceId();
+-    return success;
+ }
+ #endif // QT_NO_SYSTEMTRAYICON
+ 
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
+index f484795fbb..97bdfabb85 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
++++ b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
+@@ -70,6 +70,7 @@ class QDBusMenuConnection : public QObject
+ 
+ public:
+     QDBusMenuConnection(QObject *parent = nullptr, const QString &serviceName = QString());
++    ~QDBusMenuConnection();
+     QDBusConnection connection() const { return m_connection; }
+     QDBusServiceWatcher *dbusWatcher() const { return m_dbusWatcher; }
+     bool isStatusNotifierHostRegistered() const { return m_statusNotifierHostRegistered; }
+@@ -78,7 +79,7 @@ public:
+     void unregisterTrayIconMenu(QDBusTrayIcon *item);
+     bool registerTrayIcon(QDBusTrayIcon *item);
+     bool registerTrayIconWithWatcher(QDBusTrayIcon *item);
+-    bool unregisterTrayIcon(QDBusTrayIcon *item);
++    void unregisterTrayIcon(QDBusTrayIcon *item);
+ #endif // QT_NO_SYSTEMTRAYICON
+ 
+ Q_SIGNALS:
+@@ -90,6 +91,7 @@ private Q_SLOTS:
+     void dbusError(const QDBusError &error);
+ 
+ private:
++    QString m_serviceName;
+     QDBusConnection m_connection;
+     QDBusServiceWatcher *m_dbusWatcher;
+     bool m_statusNotifierHostRegistered;
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp b/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
+index bede70975a..76bfec5e5a 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
+@@ -71,8 +71,12 @@ Q_LOGGING_CATEGORY(qLcTray, "qt.qpa.tray")
+ static QString iconTempPath()
+ {
+     QString tempPath = QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation);
+-    if (!tempPath.isEmpty())
++    if (!tempPath.isEmpty()) {
++        QString flatpakId = qEnvironmentVariable("FLATPAK_ID");
++        if (!flatpakId.isEmpty() && QFileInfo::exists(QLatin1String("/.flatpak-info")))
++            tempPath += QLatin1String("/app/") + flatpakId;
+         return tempPath;
++    }
+ 
+     tempPath = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation);
+ 
+diff --git a/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+index cb1b39db64..6e01af052c 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+@@ -755,6 +755,9 @@ QVariant QGnomeTheme::themeHint(QPlatformTheme::ThemeHint hint) const
+         return QVariant(QChar(0x2022));
+     case QPlatformTheme::UiEffects:
+         return QVariant(int(HoverEffect));
++    case QPlatformTheme::ButtonPressKeys:
++        return QVariant::fromValue(
++                QList<Qt::Key>({ Qt::Key_Space, Qt::Key_Return, Qt::Key_Enter, Qt::Key_Select }));
+     default:
+         break;
+     }
+diff --git a/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp b/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
+index 98e05195ee..1e92f43dec 100644
+--- a/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
++++ b/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
+@@ -343,8 +343,7 @@ void QEglFSCursor::paintOnScreen()
+     // screens are siblings of each other. When not enabled, the sibling list
+     // only contains m_screen itself.
+     for (QPlatformScreen *screen : m_screen->virtualSiblings()) {
+-        if (screen->geometry().contains(cr.topLeft().toPoint() + m_cursor.hotSpot)
+-            && QOpenGLContext::currentContext()->screen() == screen->screen())
++        if (screen->geometry().contains(cr.topLeft().toPoint() + m_cursor.hotSpot))
+         {
+             cr.translate(-screen->geometry().topLeft());
+             const QSize screenSize = screen->geometry().size();
+@@ -468,11 +467,12 @@ void QEglFSCursor::draw(const QRectF &r)
+ {
+     StateSaver stateSaver;
+ 
+-    QEglFSCursorData &gfx = static_cast<QEglFSContext*>(QOpenGLContext::currentContext()->handle())->cursorData;
+-    if (!gfx.program) {
+-        // one time initialization
++    // one time initialization
++    if (!QOpenGLFunctions::d_ptr)
+         initializeOpenGLFunctions();
+ 
++    QEglFSCursorData &gfx = static_cast<QEglFSContext*>(QOpenGLContext::currentContext()->handle())->cursorData;
++    if (!gfx.program) {
+         createShaderPrograms();
+ 
+         if (!gfx.atlasTexture) {
+diff --git a/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp b/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
+index 645a0ae2e9..3e0e406f1a 100644
+--- a/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
++++ b/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
+@@ -179,7 +179,7 @@ void QEglFSKmsEventReader::create(QEglFSKmsDevice *device)
+ 
+     m_device = device;
+ 
+-    qCDebug(qLcEglfsKmsDebug, "Initalizing event reader for device %p fd %d",
++    qCDebug(qLcEglfsKmsDebug, "Initializing event reader for device %p fd %d",
+             m_device, m_device->fd());
+ 
+     m_thread = new QEglFSKmsEventReaderThread(m_device->fd());
+diff --git a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
+index 141fb68a23..d4294d425a 100644
+--- a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
++++ b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
+@@ -122,11 +122,13 @@ QOffscreenIntegration::QOffscreenIntegration()
+ #endif
+     m_services.reset(new QPlatformServices);
+ 
+-    QWindowSystemInterface::handleScreenAdded(new QOffscreenScreen);
++    m_screen = new QOffscreenScreen;
++    QWindowSystemInterface::handleScreenAdded(m_screen);
+ }
+ 
+ QOffscreenIntegration::~QOffscreenIntegration()
+ {
++    QWindowSystemInterface::handleScreenRemoved(m_screen);
+ }
+ 
+ void QOffscreenIntegration::initialize()
+diff --git a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
+index 0ea90f6c2f..fe00fde07c 100644
+--- a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
++++ b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
+@@ -84,6 +84,7 @@ protected:
+ #endif
+     QScopedPointer<QPlatformInputContext> m_inputContext;
+     QScopedPointer<QPlatformServices> m_services;
++    QPlatformScreen *m_screen;
+     mutable QScopedPointer<QPlatformNativeInterface> m_nativeInterface;
+ };
+ 
+diff --git a/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp b/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
+index 6fa5a8a2b3..1f49f0aefd 100644
+--- a/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
++++ b/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
+@@ -48,6 +48,7 @@
+ #include <qpa/qplatformnativeinterface.h>
+ #include <QtPlatformHeaders/qwglnativecontext.h>
+ 
++#include <private/qsystemlibrary_p.h>
+ #include <algorithm>
+ 
+ #include <wingdi.h>
+@@ -162,19 +163,25 @@ QFunctionPointer QWindowsOpengl32DLL::resolve(const char *name)
+ 
+ bool QWindowsOpengl32DLL::init(bool softwareRendering)
+ {
+-    const QByteArray opengl32 = QByteArrayLiteral("opengl32.dll");
+-    const QByteArray swopengl = QByteArrayLiteral("opengl32sw.dll");
++    const QByteArray opengl32 = QByteArrayLiteral("opengl32");
++    const QByteArray swopengl = QByteArrayLiteral("opengl32sw");
++    bool useSystemLib = false;
+ 
+     QByteArray openglDll = qgetenv("QT_OPENGL_DLL");
+-    if (openglDll.isEmpty())
++    if (openglDll.isEmpty()) {
+         openglDll = softwareRendering ? swopengl : opengl32;
++        useSystemLib = !softwareRendering;
++    }
+ 
+     openglDll = openglDll.toLower();
+     m_nonOpengl32 = openglDll != opengl32;
+ 
+     qCDebug(lcQpaGl) << "Qt: Using WGL and OpenGL from" << openglDll;
+ 
+-    m_lib = ::LoadLibraryA(openglDll.constData());
++    if (useSystemLib)
++        m_lib = QSystemLibrary::load((wchar_t*)(QString::fromLatin1(openglDll).utf16()));
++    else
++        m_lib = LoadLibraryA(openglDll.constData());
+     if (!m_lib) {
+         qErrnoWarning(::GetLastError(), "Failed to load %s", openglDll.constData());
+         return false;
+@@ -184,7 +191,7 @@ bool QWindowsOpengl32DLL::init(bool softwareRendering)
+         // Load opengl32.dll always. GDI functions like ChoosePixelFormat do
+         // GetModuleHandle for opengl32.dll and behave differently (and call back into
+         // opengl32) when the module is present. This is fine for dummy contexts and windows.
+-        ::LoadLibraryA("opengl32.dll");
++        QSystemLibrary::load(L"opengl32");
+     }
+ 
+     wglCreateContext = reinterpret_cast<HGLRC (WINAPI *)(HDC)>(resolve("wglCreateContext"));
+diff --git a/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp b/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
+index d7d186e804..9eb4011bf2 100644
+--- a/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
++++ b/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
+@@ -49,6 +49,7 @@
+ #include <QtCore/qstandardpaths.h>
+ #include <QtCore/qlibraryinfo.h>
+ #include <QtCore/qhash.h>
++#include <private/qsystemlibrary_p.h>
+ 
+ #ifndef QT_NO_OPENGL
+ #include <private/qopengl_p.h>
+@@ -396,7 +397,7 @@ bool QWindowsOpenGLTester::testDesktopGL()
+ 
+     // Test #1: Load opengl32.dll and try to resolve an OpenGL 2 function.
+     // This will typically fail on systems that do not have a real OpenGL driver.
+-    lib = LoadLibraryA("opengl32.dll");
++    lib = QSystemLibrary::load(L"opengl32");
+     if (lib) {
+         CreateContext = reinterpret_cast<CreateContextType>(
+             reinterpret_cast<QFunctionPointer>(::GetProcAddress(lib, "wglCreateContext")));
+diff --git a/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp b/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
+index 1afa00cfc9..118af6ce73 100644
+--- a/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
++++ b/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
+@@ -41,6 +41,7 @@
+ 
+ #include <QRect>
+ #include <QList>
++#include <QMap>
+ #include <QDebug>
+ 
+ #include <qmath.h>
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp b/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
+index 9e2a37a6a1..e6e175a118 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
+@@ -488,12 +488,12 @@ void QXcbConnection::printXcbError(const char *message, xcb_generic_error_t *err
+     uint clamped_error_code = qMin<uint>(error->error_code, (sizeof(xcb_errors) / sizeof(xcb_errors[0])) - 1);
+     uint clamped_major_code = qMin<uint>(error->major_code, (sizeof(xcb_protocol_request_codes) / sizeof(xcb_protocol_request_codes[0])) - 1);
+ 
+-    qCWarning(lcQpaXcb, "%s: %d (%s), sequence: %d, resource id: %d, major code: %d (%s), minor code: %d",
+-             message,
+-             int(error->error_code), xcb_errors[clamped_error_code],
+-             int(error->sequence), int(error->resource_id),
+-             int(error->major_code), xcb_protocol_request_codes[clamped_major_code],
+-             int(error->minor_code));
++    qCDebug(lcQpaXcb, "%s: %d (%s), sequence: %d, resource id: %d, major code: %d (%s), minor code: %d",
++            message,
++            int(error->error_code), xcb_errors[clamped_error_code],
++            int(error->sequence), int(error->resource_id),
++            int(error->major_code), xcb_protocol_request_codes[clamped_major_code],
++            int(error->minor_code));
+ }
+ 
+ static Qt::MouseButtons translateMouseButtons(int s)
+@@ -702,6 +702,8 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
+             QXcbVirtualDesktop *virtualDesktop = virtualDesktopForRootWindow(propertyNotify->window);
+             if (virtualDesktop)
+                 virtualDesktop->updateWorkArea();
++        } else if (propertyNotify->atom == atom(QXcbAtom::_NET_SUPPORTED)) {
++            m_wmSupport->updateNetWMAtoms();
+         } else {
+             HANDLE_PLATFORM_WINDOW_EVENT(xcb_property_notify_event_t, window, handlePropertyNotifyEvent);
+         }
+@@ -750,7 +752,7 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
+                 case XCB_XKB_NEW_KEYBOARD_NOTIFY: {
+                     xcb_xkb_new_keyboard_notify_event_t *ev = &xkb_event->new_keyboard_notify;
+                     if (ev->changed & XCB_XKB_NKN_DETAIL_KEYCODES)
+-                        m_keyboard->updateKeymap(ev);
++                        m_keyboard->updateKeymap();
+                     break;
+                 }
+                 default:
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp b/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
+index 76869ced60..02d2eebb56 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
+@@ -274,8 +274,7 @@ QPlatformWindow *QXcbIntegration::createForeignWindow(QWindow *window, WId nativ
+ #ifndef QT_NO_OPENGL
+ QPlatformOpenGLContext *QXcbIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
+ {
+-    QXcbScreen *screen = static_cast<QXcbScreen *>(context->screen()->handle());
+-    QXcbGlIntegration *glIntegration = screen->connection()->glIntegration();
++    QXcbGlIntegration *glIntegration = defaultConnection()->glIntegration();
+     if (!glIntegration) {
+         qWarning("QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled");
+         return nullptr;
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+index efecd7e2d1..e8286381a2 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+@@ -365,17 +365,6 @@ void QXcbKeyboard::updateKeymap(xcb_mapping_notify_event_t *event)
+     updateKeymap();
+ }
+ 
+-void QXcbKeyboard::updateKeymap(xcb_xkb_new_keyboard_notify_event_t *event)
+-{
+-    if (!event)
+-        return;
+-
+-    if (event->deviceID != event->oldDeviceID)
+-        m_config = false;
+-
+-    updateKeymap();
+-}
+-
+ void QXcbKeyboard::updateKeymap()
+ {
+     KeysymModifierMap keysymMods;
+@@ -383,6 +372,8 @@ void QXcbKeyboard::updateKeymap()
+         keysymMods = keysymsToModifiers();
+     updateModifiers(keysymMods);
+ 
++    m_config = true;
++
+     if (!m_xkbContext) {
+         m_xkbContext.reset(xkb_context_new(XKB_CONTEXT_NO_DEFAULT_INCLUDES));
+         if (!m_xkbContext) {
+@@ -398,13 +389,8 @@ void QXcbKeyboard::updateKeymap()
+     if (connection()->hasXKB()) {
+         m_xkbKeymap.reset(xkb_x11_keymap_new_from_device(m_xkbContext.get(), xcb_connection(),
+                                                          core_device_id, XKB_KEYMAP_COMPILE_NO_FLAGS));
+-        if (m_xkbKeymap) {
+-            if (m_config)
+-                m_xkbState.reset(xkb_state_new(m_xkbKeymap.get()));
+-            else
+-                m_xkbState.reset(xkb_x11_state_new_from_device(m_xkbKeymap.get(), xcb_connection(), core_device_id));
+-
+-        }
++        if (m_xkbKeymap)
++            m_xkbState.reset(xkb_x11_state_new_from_device(m_xkbKeymap.get(), xcb_connection(), core_device_id));
+     } else {
+         m_xkbKeymap.reset(keymapFromCore(keysymMods));
+         if (m_xkbKeymap)
+@@ -425,8 +411,6 @@ void QXcbKeyboard::updateKeymap()
+     updateXKBMods();
+ 
+     QXkbCommon::verifyHasLatinLayout(m_xkbKeymap.get());
+-
+-    m_config = true;
+ }
+ 
+ QList<int> QXcbKeyboard::possibleKeys(const QKeyEvent *event) const
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
+index b652c85fe3..0ee08aeff2 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
++++ b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
+@@ -69,7 +69,6 @@ public:
+ 
+     Qt::KeyboardModifiers translateModifiers(int s) const;
+     void updateKeymap(xcb_mapping_notify_event_t *event);
+-    void updateKeymap(xcb_xkb_new_keyboard_notify_event_t *event);
+     void updateKeymap();
+     QList<int> possibleKeys(const QKeyEvent *event) const;
+ 
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp b/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
+index ffda7b6a57..863e961f4c 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
+@@ -564,11 +564,6 @@ void QXcbWindow::setGeometry(const QRect &rect)
+ {
+     QPlatformWindow::setGeometry(rect);
+ 
+-    if (shouldDeferTask(Task::SetGeometry)) {
+-        m_deferredGeometry = rect;
+-        return;
+-    }
+-
+     propagateSizeHints();
+ 
+     QXcbScreen *currentScreen = xcbScreen();
+@@ -693,9 +688,6 @@ void QXcbWindow::setVisible(bool visible)
+ 
+ void QXcbWindow::show()
+ {
+-    if (shouldDeferTask(Task::Map))
+-        return;
+-
+     if (window()->isTopLevel()) {
+ 
+         // update WM_NORMAL_HINTS
+@@ -706,7 +698,7 @@ void QXcbWindow::show()
+         if (isTransient(window())) {
+             const QWindow *tp = window()->transientParent();
+             if (tp && tp->handle())
+-                transientXcbParent = static_cast<const QXcbWindow *>(tp->handle())->winId();
++                transientXcbParent = tp->handle()->winId();
+             // Default to client leader if there is no transient parent, else modal dialogs can
+             // be hidden by their parents.
+             if (!transientXcbParent)
+@@ -746,10 +738,6 @@ void QXcbWindow::show()
+ 
+ void QXcbWindow::hide()
+ {
+-    if (shouldDeferTask(Task::Unmap))
+-        return;
+-
+-    m_wmStateValid = false;
+     xcb_unmap_window(xcb_connection(), m_window);
+ 
+     // send synthetic UnmapNotify event according to icccm 4.1.4
+@@ -909,9 +897,6 @@ QXcbWindow::NetWmStates QXcbWindow::netWmStates()
+ 
+ void QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
+ {
+-    if (shouldDeferTask(Task::SetWindowFlags))
+-        return;
+-
+     Qt::WindowType type = static_cast<Qt::WindowType>(int(flags & Qt::WindowType_Mask));
+ 
+     if (type == Qt::ToolTip)
+@@ -941,8 +926,6 @@ void QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
+ 
+     setTransparentForMouseEvents(flags & Qt::WindowTransparentForInput);
+     updateDoesNotAcceptFocus(flags & Qt::WindowDoesNotAcceptFocus);
+-
+-    m_isWmManagedWindow = !(flags & Qt::X11BypassWindowManagerHint);
+ }
+ 
+ void QXcbWindow::setMotifWmHints(Qt::WindowFlags flags)
+@@ -1142,9 +1125,6 @@ void QXcbWindow::setWindowState(Qt::WindowStates state)
+     if (state == m_windowState)
+         return;
+ 
+-    if (shouldDeferTask(Task::SetWindowState))
+-        return;
+-
+     // unset old state
+     if (m_windowState & Qt::WindowMinimized)
+         xcb_map_window(xcb_connection(), m_window);
+@@ -1350,6 +1330,12 @@ void QXcbWindow::setWindowIcon(const QIcon &icon)
+     }
+ 
+     if (!icon_data.isEmpty()) {
++        // Ignore icon exceeding maximum xcb request length
++        if (icon_data.size() > xcb_get_maximum_request_length(xcb_connection())) {
++            qWarning("Ignoring window icon: Size %llu exceeds maximum xcb request length %u.",
++                     icon_data.size(), xcb_get_maximum_request_length(xcb_connection()));
++            return;
++        }
+         xcb_change_property(xcb_connection(),
+                             XCB_PROP_MODE_REPLACE,
+                             m_window,
+@@ -1639,7 +1625,7 @@ void QXcbWindow::setWmWindowType(QXcbWindowFunctions::WmWindowTypes types, Qt::W
+         break;
+     }
+ 
+-    if ((flags & Qt::FramelessWindowHint) && !(type & QXcbWindowFunctions::KdeOverride)) {
++    if ((flags & Qt::FramelessWindowHint) && !(types & QXcbWindowFunctions::KdeOverride)) {
+         // override netwm type - quick and easy for KDE noborder
+         atoms.append(atom(QXcbAtom::_KDE_NET_WM_WINDOW_TYPE_OVERRIDE));
+     }
+@@ -1894,10 +1880,6 @@ void QXcbWindow::handleUnmapNotifyEvent(const xcb_unmap_notify_event_t *event)
+     if (event->window == m_window) {
+         m_mapped = false;
+         QWindowSystemInterface::handleExposeEvent(window(), QRegion());
+-        if (!m_isWmManagedWindow || parent()) {
+-            m_wmStateValid = true;
+-            handleDeferredTasks();
+-        }
+     }
+ }
+ 
+@@ -2212,98 +2194,30 @@ void QXcbWindow::handleLeaveNotifyEvent(const xcb_leave_notify_event_t *event)
+     handleLeaveNotifyEvent(event->root_x, event->root_y, event->mode, event->detail, event->time);
+ }
+ 
+-bool QXcbWindow::shouldDeferTask(Task task)
+-{
+-    if (m_wmStateValid)
+-        return false;
+-
+-    m_deferredTasks.append(task);
+-    return true;
+-}
+-
+-void QXcbWindow::handleDeferredTasks()
+-{
+-    Q_ASSERT(m_wmStateValid == true);
+-    if (m_deferredTasks.isEmpty())
+-        return;
+-
+-    bool map = false;
+-    bool unmap = false;
+-
+-    QVector<Task> tasks;
+-    for (auto taskIt = m_deferredTasks.rbegin(); taskIt != m_deferredTasks.rend(); ++taskIt) {
+-        if (!tasks.contains(*taskIt))
+-            tasks.prepend(*taskIt);
+-    }
+-
+-    for (Task task : tasks) {
+-        switch (task) {
+-        case Task::Map:
+-            map = true;
+-            unmap = false;
+-            break;
+-        case Task::Unmap:
+-            unmap = true;
+-            map = false;
+-            break;
+-        case Task::SetGeometry:
+-            setGeometry(m_deferredGeometry);
+-            break;
+-        case Task::SetWindowFlags:
+-            setWindowFlags(window()->flags());
+-            break;
+-        case Task::SetWindowState:
+-            setWindowState(window()->windowState());
+-            break;
+-        }
+-    }
+-    m_deferredTasks.clear();
+-
+-    if (map) {
+-        Q_ASSERT(unmap == false);
+-        show();
+-    }
+-    if (unmap) {
+-        Q_ASSERT(map == false);
+-        hide();
+-    }
+-}
+-
+ void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *event)
+ {
+     connection()->setTime(event->time);
+ 
+-    const bool wmStateChanged = event->atom == atom(QXcbAtom::WM_STATE);
+-    const bool netWmStateChanged = event->atom == atom(QXcbAtom::_NET_WM_STATE);
+-    if (netWmStateChanged || wmStateChanged) {
+-        if (wmStateChanged && !m_wmStateValid && m_isWmManagedWindow) {
+-            // ICCCM 4.1.4
+-            // Clients that want to re-use a client window (e.g. by mapping it again)
+-            // after withdrawing it must wait for the withdrawal to be complete before
+-            // proceeding. The preferred method for doing this is for clients to wait for
+-            // a window manager to update or remove the WM_STATE property.
+-            m_wmStateValid = true;
+-            handleDeferredTasks();
+-        }
+-        if (event->state == XCB_PROPERTY_DELETE)
++    const bool propertyDeleted = event->state == XCB_PROPERTY_DELETE;
++
++    if (event->atom == atom(QXcbAtom::_NET_WM_STATE) || event->atom == atom(QXcbAtom::WM_STATE)) {
++        if (propertyDeleted)
+             return;
+ 
+-        if (wmStateChanged) {
++        Qt::WindowStates newState = Qt::WindowNoState;
++
++        if (event->atom == atom(QXcbAtom::WM_STATE)) { // WM_STATE: Quick check for 'Minimize'.
+             auto reply = Q_XCB_REPLY(xcb_get_property, xcb_connection(),
+                                      0, m_window, atom(QXcbAtom::WM_STATE),
+                                      XCB_ATOM_ANY, 0, 1024);
+             if (reply && reply->format == 32 && reply->type == atom(QXcbAtom::WM_STATE)) {
+-                auto data = static_cast<const quint32 *>(xcb_get_property_value(reply.get()));
+-                if (reply->length != 0) {
+-                    const bool changedToWithdrawn = data[0] == XCB_ICCCM_WM_STATE_WITHDRAWN;
+-                    const bool changedToIconic = data[0] == XCB_ICCCM_WM_STATE_ICONIC;
+-                    m_minimized = changedToIconic || (changedToWithdrawn && m_minimized);
+-                }
++                const quint32 *data = (const quint32 *)xcb_get_property_value(reply.get());
++                if (reply->length != 0)
++                    m_minimized = (data[0] == XCB_ICCCM_WM_STATE_ICONIC
++                                   || (data[0] == XCB_ICCCM_WM_STATE_WITHDRAWN && m_minimized));
+             }
+         }
+ 
+-        // _NET_WM_STATE handling
+-        Qt::WindowStates newState = Qt::WindowNoState;
+         const NetWmStates states = netWmStates();
+         // _NET_WM_STATE_HIDDEN should be set by the Window Manager to indicate that a window would
+         // not be visible on the screen if its desktop/viewport were active and its coordinates were
+@@ -2325,6 +2239,7 @@ void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *ev
+             if ((m_windowState & Qt::WindowMinimized) && connection()->mouseGrabber() == this)
+                 connection()->setMouseGrabber(nullptr);
+         }
++        return;
+     } else if (event->atom == atom(QXcbAtom::_NET_FRAME_EXTENTS)) {
+         m_dirtyFrameMargins = true;
+     }
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbwindow.h b/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
+index 55af9279b1..6f5c1f5ed9 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
++++ b/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
+@@ -74,14 +74,6 @@ public:
+ 
+     Q_DECLARE_FLAGS(NetWmStates, NetWmState)
+ 
+-    enum Task {
+-        Map,
+-        Unmap,
+-        SetGeometry,
+-        SetWindowFlags,
+-        SetWindowState
+-    };
+-
+     QXcbWindow(QWindow *window);
+     ~QXcbWindow();
+ 
+@@ -151,9 +143,6 @@ public:
+ 
+     QXcbWindow *toWindow() override;
+ 
+-    bool shouldDeferTask(Task task);
+-    void handleDeferredTasks();
+-
+     void handleMouseEvent(xcb_timestamp_t time, const QPoint &local, const QPoint &global,
+                           Qt::KeyboardModifiers modifiers, QEvent::Type type, Qt::MouseEventSource source);
+ 
+@@ -292,11 +281,6 @@ protected:
+     int m_swapInterval = -1;
+ 
+     qreal m_sizeHintsScaleFactor = 1.0;
+-
+-    bool m_wmStateValid = true;
+-    QVector<Task> m_deferredTasks;
+-    bool m_isWmManagedWindow = true;
+-    QRect m_deferredGeometry;
+ };
+ 
+ class QXcbForeignWindow : public QXcbWindow
+diff --git a/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp b/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
+index d9d117faeb..640b49daa0 100644
+--- a/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
++++ b/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
+@@ -85,6 +85,7 @@ QGtk3MenuItem::QGtk3MenuItem()
+       m_checkable(false),
+       m_checked(false),
+       m_enabled(true),
++      m_exclusive(false),
+       m_underline(false),
+       m_invalid(true),
+       m_menu(nullptr),
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
+index 0048bbc1e6..396e7f6d1c 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
+@@ -102,15 +102,12 @@ const QDBusArgument &operator >>(const QDBusArgument &arg, QXdgDesktopPortalFile
+ class QXdgDesktopPortalFileDialogPrivate
+ {
+ public:
+-    QXdgDesktopPortalFileDialogPrivate(QPlatformFileDialogHelper *nativeFileDialog)
++    QXdgDesktopPortalFileDialogPrivate(QPlatformFileDialogHelper *nativeFileDialog, uint fileChooserPortalVersion)
+         : nativeFileDialog(nativeFileDialog)
++        , fileChooserPortalVersion(fileChooserPortalVersion)
+     { }
+ 
+-    WId winId = 0;
+-    bool directoryMode = false;
+-    bool modal = false;
+-    bool multipleFiles = false;
+-    bool saveFile = false;
++    QEventLoop loop;
+     QString acceptLabel;
+     QString directory;
+     QString title;
+@@ -121,19 +118,27 @@ public:
+     QString selectedMimeTypeFilter;
+     QString selectedNameFilter;
+     QStringList selectedFiles;
+-    QPlatformFileDialogHelper *nativeFileDialog = nullptr;
++    std::unique_ptr<QPlatformFileDialogHelper> nativeFileDialog;
++    uint fileChooserPortalVersion = 0;
++    bool failedToOpen = false;
++    bool directoryMode = false;
++    bool multipleFiles = false;
++    bool saveFile = false;
+ };
+ 
+-QXdgDesktopPortalFileDialog::QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog)
++QXdgDesktopPortalFileDialog::QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog, uint fileChooserPortalVersion)
+     : QPlatformFileDialogHelper()
+-    , d_ptr(new QXdgDesktopPortalFileDialogPrivate(nativeFileDialog))
++    , d_ptr(new QXdgDesktopPortalFileDialogPrivate(nativeFileDialog, fileChooserPortalVersion))
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+     if (d->nativeFileDialog) {
+-        connect(d->nativeFileDialog, SIGNAL(accept()), this, SIGNAL(accept()));
+-        connect(d->nativeFileDialog, SIGNAL(reject()), this, SIGNAL(reject()));
++        connect(d->nativeFileDialog.get(), SIGNAL(accept()), this, SIGNAL(accept()));
++        connect(d->nativeFileDialog.get(), SIGNAL(reject()), this, SIGNAL(reject()));
+     }
++
++    d->loop.connect(this, SIGNAL(accept()), SLOT(quit()));
++    d->loop.connect(this, SIGNAL(reject()), SLOT(quit()));
+ }
+ 
+ QXdgDesktopPortalFileDialog::~QXdgDesktopPortalFileDialog()
+@@ -177,7 +182,7 @@ void QXdgDesktopPortalFileDialog::initializeDialog()
+     setDirectory(options()->initialDirectory());
+ }
+ 
+-void QXdgDesktopPortalFileDialog::openPortal()
++void QXdgDesktopPortalFileDialog::openPortal(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent)
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+@@ -185,13 +190,13 @@ void QXdgDesktopPortalFileDialog::openPortal()
+                                                           QLatin1String("/org/freedesktop/portal/desktop"),
+                                                           QLatin1String("org.freedesktop.portal.FileChooser"),
+                                                           d->saveFile ? QLatin1String("SaveFile") : QLatin1String("OpenFile"));
+-    QString parentWindowId = QLatin1String("x11:") + QString::number(d->winId, 16);
++    QString parentWindowId = QLatin1String("x11:") + QString::number(parent ? parent->winId() : 0, 16);
+ 
+     QVariantMap options;
+     if (!d->acceptLabel.isEmpty())
+         options.insert(QLatin1String("accept_label"), d->acceptLabel);
+ 
+-    options.insert(QLatin1String("modal"), d->modal);
++    options.insert(QLatin1String("modal"), windowModality != Qt::NonModal);
+     options.insert(QLatin1String("multiple"), d->multipleFiles);
+     options.insert(QLatin1String("directory"), d->directoryMode);
+ 
+@@ -290,10 +295,18 @@ void QXdgDesktopPortalFileDialog::openPortal()
+ 
+     QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
+     QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingCall);
+-    connect(watcher, &QDBusPendingCallWatcher::finished, this, [this] (QDBusPendingCallWatcher *watcher) {
++    connect(watcher, &QDBusPendingCallWatcher::finished, this, [=] (QDBusPendingCallWatcher *watcher) {
+         QDBusPendingReply<QDBusObjectPath> reply = *watcher;
+-        if (reply.isError()) {
+-            Q_EMIT reject();
++        // Any error means the dialog is not shown and we need to fallback
++        d->failedToOpen = reply.isError();
++        if (d->failedToOpen) {
++            if (d->nativeFileDialog) {
++                d->nativeFileDialog->show(windowFlags, windowModality, parent);
++                if (d->loop.isRunning())
++                    d->nativeFileDialog->exec();
++            } else {
++                Q_EMIT reject();
++            }
+         } else {
+             QDBusConnection::sessionBus().connect(nullptr,
+                                                   reply.value().path(),
+@@ -302,6 +315,7 @@ void QXdgDesktopPortalFileDialog::openPortal()
+                                                   this,
+                                                   SLOT(gotResponse(uint,QVariantMap)));
+         }
++        watcher->deleteLater();
+     });
+ }
+ 
+@@ -326,7 +340,7 @@ QUrl QXdgDesktopPortalFileDialog::directory() const
+ {
+     Q_D(const QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog())
+         return d->nativeFileDialog->directory();
+ 
+     return d->directory;
+@@ -348,7 +362,7 @@ QList<QUrl> QXdgDesktopPortalFileDialog::selectedFiles() const
+ {
+     Q_D(const QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog())
+         return d->nativeFileDialog->selectedFiles();
+ 
+     QList<QUrl> files;
+@@ -403,16 +417,13 @@ void QXdgDesktopPortalFileDialog::exec()
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly)) {
++    if (d->nativeFileDialog && useNativeFileDialog()) {
+         d->nativeFileDialog->exec();
+         return;
+     }
+ 
+     // HACK we have to avoid returning until we emit that the dialog was accepted or rejected
+-    QEventLoop loop;
+-    loop.connect(this, SIGNAL(accept()), SLOT(quit()));
+-    loop.connect(this, SIGNAL(reject()), SLOT(quit()));
+-    loop.exec();
++    d->loop.exec();
+ }
+ 
+ void QXdgDesktopPortalFileDialog::hide()
+@@ -429,13 +440,10 @@ bool QXdgDesktopPortalFileDialog::show(Qt::WindowFlags windowFlags, Qt::WindowMo
+ 
+     initializeDialog();
+ 
+-    d->modal = windowModality != Qt::NonModal;
+-    d->winId = parent ? parent->winId() : 0;
+-
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog(OpenFallback))
+         return d->nativeFileDialog->show(windowFlags, windowModality, parent);
+ 
+-    openPortal();
++    openPortal(windowFlags, windowModality, parent);
+ 
+     return true;
+ }
+@@ -465,4 +473,21 @@ void QXdgDesktopPortalFileDialog::gotResponse(uint response, const QVariantMap &
+     }
+ }
+ 
++bool QXdgDesktopPortalFileDialog::useNativeFileDialog(QXdgDesktopPortalFileDialog::FallbackType fallbackType) const
++{
++    Q_D(const QXdgDesktopPortalFileDialog);
++
++    if (d->failedToOpen && fallbackType != OpenFallback)
++        return true;
++
++    if (d->fileChooserPortalVersion < 3) {
++        if (options()->fileMode() == QFileDialogOptions::Directory)
++            return true;
++        else if (options()->fileMode() == QFileDialogOptions::DirectoryOnly)
++            return true;
++    }
++
++    return false;
++}
++
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
+index 4f4de96ecf..65e22a5cf2 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
+@@ -51,6 +51,11 @@ class QXdgDesktopPortalFileDialog : public QPlatformFileDialogHelper
+     Q_OBJECT
+     Q_DECLARE_PRIVATE(QXdgDesktopPortalFileDialog)
+ public:
++    enum FallbackType {
++        GenericFallback,
++        OpenFallback
++    };
++
+     enum ConditionType : uint {
+         GlobalPattern = 0,
+         MimeType = 1
+@@ -69,7 +74,7 @@ public:
+     };
+     typedef QVector<Filter> FilterList;
+ 
+-    QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog = nullptr);
++    QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog = nullptr, uint fileChooserPortalVersion = 0);
+     ~QXdgDesktopPortalFileDialog();
+ 
+     bool defaultNameFilterDisables() const override;
+@@ -92,7 +97,8 @@ private Q_SLOTS:
+ 
+ private:
+     void initializeDialog();
+-    void openPortal();
++    void openPortal(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent);
++    bool useNativeFileDialog(FallbackType fallbackType = GenericFallback) const;
+ 
+     QScopedPointer<QXdgDesktopPortalFileDialogPrivate> d_ptr;
+ };
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
+index fb324afbd8..b809503122 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
+@@ -111,6 +111,7 @@ QXdgDesktopPortalTheme::QXdgDesktopPortalTheme()
+         if (reply.isValid()) {
+             d->fileChooserPortalVersion = reply.value().toUInt();
+         }
++        watcher->deleteLater();
+     });
+ }
+ 
+@@ -152,11 +153,12 @@ QPlatformDialogHelper* QXdgDesktopPortalTheme::createPlatformDialogHelper(Dialog
+ {
+     Q_D(const QXdgDesktopPortalTheme);
+ 
+-    if (type == FileDialog) {
++    if (type == FileDialog && d->fileChooserPortalVersion) {
+         // Older versions of FileChooser portal don't support opening directories, therefore we fallback
+         // to native file dialog opened inside the sandbox to open a directory.
+-        if (d->fileChooserPortalVersion < 3 && d->baseTheme->usePlatformNativeDialog(type))
+-            return new QXdgDesktopPortalFileDialog(static_cast<QPlatformFileDialogHelper*>(d->baseTheme->createPlatformDialogHelper(type)));
++        if (d->baseTheme->usePlatformNativeDialog(type))
++            return new QXdgDesktopPortalFileDialog(static_cast<QPlatformFileDialogHelper*>(d->baseTheme->createPlatformDialogHelper(type)),
++                                                   d->fileChooserPortalVersion);
+ 
+         return new QXdgDesktopPortalFileDialog;
+     }
+diff --git a/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp b/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
+index 43d5e119ad..1f9cbc4565 100644
+--- a/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
++++ b/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
+@@ -89,8 +89,10 @@ void QCupsPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &v
+         break;
+     case PPK_Duplex: {
+         QPrint::DuplexMode mode = QPrint::DuplexMode(value.toInt());
+-        if (mode != d->duplex && d->m_printDevice.supportedDuplexModes().contains(mode))
++        if (d->m_printDevice.supportedDuplexModes().contains(mode)) {
+             d->duplex = mode;
++            d->duplexRequestedExplicitly = true;
++        }
+         break;
+     }
+     case PPK_PrinterName:
+@@ -277,9 +279,12 @@ void QCupsPrintEnginePrivate::changePrinter(const QString &newPrinter)
+     m_printDevice.swap(printDevice);
+     printerName = m_printDevice.id();
+ 
+-    // Check if new printer supports current settings, otherwise us defaults
+-    if (duplex != QPrint::DuplexAuto && !m_printDevice.supportedDuplexModes().contains(duplex))
++    // in case a duplex value was explicitly set, check if new printer supports current value,
++    // otherwise use device default
++    if (!duplexRequestedExplicitly || !m_printDevice.supportedDuplexModes().contains(duplex)) {
+         duplex = m_printDevice.defaultDuplexMode();
++        duplexRequestedExplicitly = false;
++    }
+     QPrint::ColorMode colorMode = grayscale ? QPrint::GrayScale : QPrint::Color;
+     if (!m_printDevice.supportedColorModes().contains(colorMode))
+         grayscale = m_printDevice.defaultColorMode() == QPrint::GrayScale;
+diff --git a/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h b/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
+index c021b0c643..8f81fe478d 100644
+--- a/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
++++ b/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
+@@ -100,6 +100,7 @@ private:
+     QStringList cupsOptions;
+     QString cupsTempFile;
+     QPrint::DuplexMode duplex;
++    bool duplexRequestedExplicitly = false;
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp b/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
+index 67e7154fa6..40876152e5 100644
+--- a/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
++++ b/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
+@@ -817,7 +817,7 @@ bool QIBaseResultPrivate::writeArray(int column, const QList<QVariant> &list)
+     ba.resize(int(bufLen));
+ 
+     if (list.size() > arraySize) {
+-        error = QLatin1String("Array size missmatch: size of %1 is %2, size of provided list is %3");
++        error = QLatin1String("Array size mismatch: size of %1 is %2, size of provided list is %3");
+         error = error.arg(QLatin1String(sqlname)).arg(arraySize).arg(list.size());
+         q->setLastError(QSqlError(error, QLatin1String(""), QSqlError::StatementError));
+         return false;
+diff --git a/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp b/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
+index 7ca055eea2..6bc9d46755 100644
+--- a/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
++++ b/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
+@@ -223,7 +223,7 @@ public:
+     struct QMyField
+     {
+         char *outField = nullptr;
+-        MYSQL_FIELD *myField = nullptr;
++        const MYSQL_FIELD *myField = nullptr;
+         QMetaType::Type type = QMetaType::UnknownType;
+         my_bool nullIndicator = false;
+         ulong bufLength = 0ul;
+@@ -361,7 +361,7 @@ static bool qIsInteger(int t)
+ void QMYSQLResultPrivate::bindBlobs()
+ {
+     int i;
+-    MYSQL_FIELD *fieldInfo;
++    const MYSQL_FIELD *fieldInfo;
+     MYSQL_BIND *bind;
+ 
+     for(i = 0; i < fields.count(); ++i) {
+@@ -379,7 +379,6 @@ void QMYSQLResultPrivate::bindBlobs()
+ bool QMYSQLResultPrivate::bindInValues()
+ {
+     MYSQL_BIND *bind;
+-    char *field;
+     int i = 0;
+ 
+     if (!meta)
+@@ -392,35 +391,34 @@ bool QMYSQLResultPrivate::bindInValues()
+     inBinds = new MYSQL_BIND[fields.size()];
+     memset(inBinds, 0, fields.size() * sizeof(MYSQL_BIND));
+ 
+-    MYSQL_FIELD *fieldInfo;
++    const MYSQL_FIELD *fieldInfo;
+ 
+     while((fieldInfo = mysql_fetch_field(meta))) {
++        bind = &inBinds[i];
++
+         QMyField &f = fields[i];
+         f.myField = fieldInfo;
+-
++        bind->buffer_length = f.bufLength = fieldInfo->length + 1;
++        bind->buffer_type = fieldInfo->type;
+         f.type = qDecodeMYSQLType(fieldInfo->type, fieldInfo->flags);
+         if (qIsBlob(fieldInfo->type)) {
+             // the size of a blob-field is available as soon as we call
+             // mysql_stmt_store_result()
+             // after mysql_stmt_exec() in QMYSQLResult::exec()
+-            fieldInfo->length = 0;
++            bind->buffer_length = f.bufLength = 0;
+             hasBlobs = true;
+         } else if (qIsInteger(f.type)) {
+-            fieldInfo->length = 8;
++            bind->buffer_length = f.bufLength = 8;
+         } else {
+-            fieldInfo->type = MYSQL_TYPE_STRING;
++            bind->buffer_type = MYSQL_TYPE_STRING;
+         }
+-        bind = &inBinds[i];
+-        field = new char[fieldInfo->length + 1];
+-        memset(field, 0, fieldInfo->length + 1);
+ 
+-        bind->buffer_type = fieldInfo->type;
+-        bind->buffer = field;
+-        bind->buffer_length = f.bufLength = fieldInfo->length + 1;
+         bind->is_null = &f.nullIndicator;
+         bind->length = &f.bufLength;
+         bind->is_unsigned = fieldInfo->flags & UNSIGNED_FLAG ? 1 : 0;
+-        f.outField=field;
++
++        char *field = new char[bind->buffer_length + 1]{};
++        bind->buffer = f.outField = field;
+ 
+         ++i;
+     }
+@@ -1369,20 +1367,20 @@ bool QMYSQLDriver::open(const QString& db,
+     }
+ 
+ #if MYSQL_VERSION_ID >= 50007
+-    if (mysql_get_client_version() >= 50503 && mysql_get_server_version(d->mysql) >= 50503) {
+-        // force the communication to be utf8mb4 (only utf8mb4 supports 4-byte characters)
+-        mysql_set_character_set(d->mysql, "utf8mb4");
++    // force the communication to be utf8mb4 (only utf8mb4 supports 4-byte characters)
++    if (mysql_set_character_set(d->mysql, "utf8mb4")) {
++        // this failed, try forcing it to utf (BMP only)
++        if (mysql_set_character_set(d->mysql, "utf8"))
++            qWarning() << "MySQL: Unable to set the client character set to utf8.";
+ #if QT_CONFIG(textcodec)
+-        d->tc = QTextCodec::codecForName("UTF-8");
++        else
++            d->tc = codec(d->mysql);
+ #endif
+-    } else
+-    {
+-        // force the communication to be utf8
+-        mysql_set_character_set(d->mysql, "utf8");
++    }
+ #if QT_CONFIG(textcodec)
+-        d->tc = codec(d->mysql);
++    else
++        d->tc = QTextCodec::codecForName("UTF-8");
+ #endif
+-    }
+ #endif  // MYSQL_VERSION_ID >= 50007
+ 
+     d->preparedQuerysEnabled = checkPreparedQueries(d->mysql);
+diff --git a/qtbase/src/printsupport/dialogs/images/print-24.png b/qtbase/src/printsupport/dialogs/images/printer-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/print-24.png
+rename to src/printsupport/dialogs/images/printer-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/print-32.png b/qtbase/src/printsupport/dialogs/images/printer-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/print-32.png
+rename to src/printsupport/dialogs/images/printer-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-sided-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-facing-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-sided-24.png
+rename to src/printsupport/dialogs/images/view-pages-facing-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-sided-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-facing-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-sided-32.png
+rename to src/printsupport/dialogs/images/view-pages-facing-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-multi-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-overview-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-multi-24.png
+rename to src/printsupport/dialogs/images/view-pages-overview-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-multi-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-overview-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-multi-32.png
+rename to src/printsupport/dialogs/images/view-pages-overview-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-one-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-single-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-one-24.png
+rename to src/printsupport/dialogs/images/view-pages-single-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-one-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-single-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-one-32.png
+rename to src/printsupport/dialogs/images/view-pages-single-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-page-24.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-page-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-page-24.png
+rename to src/printsupport/dialogs/images/zoom-fit-page-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-page-32.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-page-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-page-32.png
+rename to src/printsupport/dialogs/images/zoom-fit-page-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-width-24.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-width-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-width-24.png
+rename to src/printsupport/dialogs/images/zoom-fit-width-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-width-32.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-width-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-width-32.png
+rename to src/printsupport/dialogs/images/zoom-fit-width-32.png
+diff --git a/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp b/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
+index 78e5b8d1ef..2a28516719 100644
+--- a/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
++++ b/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
+@@ -532,6 +532,7 @@ void QPageSetupWidget::updateWidget()
+ void QPageSetupWidget::setupPrinter() const
+ {
+     m_printer->setPageLayout(m_pageLayout);
++    m_printer->setPageOrientation(m_pageLayout.orientation());
+ #if QT_CONFIG(cups)
+     QCUPSSupport::PagesPerSheet pagesPerSheet = qvariant_cast<QCUPSSupport::PagesPerSheet>(m_ui.pagesPerSheetCombo->currentData()
+ );
+diff --git a/qtbase/src/printsupport/dialogs/qprintdialog.qrc b/qtbase/src/printsupport/dialogs/qprintdialog.qrc
+index 5a579baa55..10b8e1d341 100644
+--- a/qtbase/src/printsupport/dialogs/qprintdialog.qrc
++++ b/qtbase/src/printsupport/dialogs/qprintdialog.qrc
+@@ -1,9 +1,9 @@
+ <!DOCTYPE RCC><RCC version="1.0">
+ <qresource prefix="/qt-project.org/dialogs/qprintpreviewdialog">
+-<file>images/fit-page-24.png</file>
+-<file>images/fit-page-32.png</file>
+-<file>images/fit-width-24.png</file>
+-<file>images/fit-width-32.png</file>
++<file>images/zoom-fit-page-24.png</file>
++<file>images/zoom-fit-page-32.png</file>
++<file>images/zoom-fit-width-24.png</file>
++<file>images/zoom-fit-width-32.png</file>
+ <file>images/go-first-24.png</file>
+ <file>images/go-first-32.png</file>
+ <file>images/go-last-24.png</file>
+@@ -18,14 +18,14 @@
+ <file>images/layout-portrait-32.png</file>
+ <file>images/page-setup-24.png</file>
+ <file>images/page-setup-32.png</file>
+-<file>images/print-24.png</file>
+-<file>images/print-32.png</file>
+-<file>images/view-page-multi-24.png</file>
+-<file>images/view-page-multi-32.png</file>
+-<file>images/view-page-one-24.png</file>
+-<file>images/view-page-one-32.png</file>
+-<file>images/view-page-sided-24.png</file>
+-<file>images/view-page-sided-32.png</file>
++<file>images/printer-24.png</file>
++<file>images/printer-32.png</file>
++<file>images/view-pages-overview-24.png</file>
++<file>images/view-pages-overview-32.png</file>
++<file>images/view-pages-single-24.png</file>
++<file>images/view-pages-single-32.png</file>
++<file>images/view-pages-facing-24.png</file>
++<file>images/view-pages-facing-32.png</file>
+ <file>images/zoom-in-24.png</file>
+ <file>images/zoom-in-32.png</file>
+ <file>images/zoom-out-24.png</file>
+diff --git a/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp b/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
+index c5b845f4ec..5a5ba1d0a8 100644
+--- a/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
++++ b/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
+@@ -702,13 +702,14 @@ void QPrintDialogPrivate::selectPrinter(const QPrinter::OutputFormat outputForma
+         else
+             options.grayscale->setChecked(true);
+ 
+-        // keep duplex value explicitly set by user, if any, and selected printer supports it;
+-        // use device default otherwise
++        // duplex priorities to be as follows:
++        // 1) a user-selected duplex value in the dialog has highest prority
++        // 2) duplex value set in the QPrinter
+         QPrint::DuplexMode duplex;
+         if (explicitDuplexMode != QPrint::DuplexAuto && supportedDuplexMode.contains(explicitDuplexMode))
+             duplex = explicitDuplexMode;
+         else
+-            duplex = top->d->m_currentPrintDevice.defaultDuplexMode();
++            duplex = static_cast<QPrint::DuplexMode>(p->duplex());
+         switch (duplex) {
+         case QPrint::DuplexNone:
+             options.noDuplex->setChecked(true); break;
+@@ -1242,10 +1243,10 @@ void QUnixPrintWidgetPrivate::_q_printerChanged(int index)
+             QString filename = widget.filename->text();
+             widget.filename->setText(filename);
+             widget.lOutput->setEnabled(true);
+-            if (optionsPane)
+-                optionsPane->selectPrinter(QPrinter::PdfFormat);
+             printer->setOutputFormat(QPrinter::PdfFormat);
+             m_currentPrintDevice = QPrintDevice();
++            if (optionsPane)
++                optionsPane->selectPrinter(QPrinter::PdfFormat);
+             return;
+         }
+     }
+diff --git a/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp b/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
+index 39575d5f57..23b7e89538 100644
+--- a/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
++++ b/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
+@@ -352,7 +352,7 @@ void QPrintPreviewDialogPrivate::init(QPrinter *_printer)
+ static inline void qt_setupActionIcon(QAction *action, QLatin1String name)
+ {
+     QLatin1String imagePrefix(":/qt-project.org/dialogs/qprintpreviewdialog/images/");
+-    QIcon icon;
++    QIcon icon = QIcon::fromTheme(name);
+     icon.addFile(imagePrefix + name + QLatin1String("-24.png"), QSize(24, 24));
+     icon.addFile(imagePrefix + name + QLatin1String("-32.png"), QSize(32, 32));
+     action->setIcon(icon);
+@@ -383,8 +383,8 @@ void QPrintPreviewDialogPrivate::setupActions()
+     fitPageAction->setObjectName(QLatin1String("fitPageAction"));
+     fitWidthAction->setCheckable(true);
+     fitPageAction->setCheckable(true);
+-    qt_setupActionIcon(fitWidthAction, QLatin1String("fit-width"));
+-    qt_setupActionIcon(fitPageAction, QLatin1String("fit-page"));
++    qt_setupActionIcon(fitWidthAction, QLatin1String("zoom-fit-width"));
++    qt_setupActionIcon(fitPageAction, QLatin1String("zoom-fit-page"));
+     QObject::connect(fitGroup, SIGNAL(triggered(QAction*)), q, SLOT(_q_fit(QAction*)));
+ 
+     // Zoom
+@@ -410,9 +410,9 @@ void QPrintPreviewDialogPrivate::setupActions()
+     singleModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show single page"));
+     facingModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show facing pages"));
+     overviewModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show overview of all pages"));
+-    qt_setupActionIcon(singleModeAction, QLatin1String("view-page-one"));
+-    qt_setupActionIcon(facingModeAction, QLatin1String("view-page-sided"));
+-    qt_setupActionIcon(overviewModeAction, QLatin1String("view-page-multi"));
++    qt_setupActionIcon(singleModeAction, QLatin1String("view-pages-single"));
++    qt_setupActionIcon(facingModeAction, QLatin1String("view-pages-facing"));
++    qt_setupActionIcon(overviewModeAction, QLatin1String("view-pages-overview"));
+     singleModeAction->setObjectName(QLatin1String("singleModeAction"));
+     facingModeAction->setObjectName(QLatin1String("facingModeAction"));
+     overviewModeAction->setObjectName(QLatin1String("overviewModeAction"));
+@@ -426,7 +426,7 @@ void QPrintPreviewDialogPrivate::setupActions()
+     printerGroup = new QActionGroup(q);
+     printAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Print"));
+     pageSetupAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Page setup"));
+-    qt_setupActionIcon(printAction, QLatin1String("print"));
++    qt_setupActionIcon(printAction, QLatin1String("printer"));
+     qt_setupActionIcon(pageSetupAction, QLatin1String("page-setup"));
+     QObject::connect(printAction, SIGNAL(triggered(bool)), q, SLOT(_q_print()));
+     QObject::connect(pageSetupAction, SIGNAL(triggered(bool)), q, SLOT(_q_pageSetup()));
+diff --git a/qtbase/src/sql/kernel/qsqlquery.cpp b/qtbase/src/sql/kernel/qsqlquery.cpp
+index 32c6166c79..60afef10c3 100644
+--- a/qtbase/src/sql/kernel/qsqlquery.cpp
++++ b/qtbase/src/sql/kernel/qsqlquery.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2022 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtSql module of the Qt Toolkit.
+@@ -377,6 +377,10 @@ bool QSqlQuery::exec(const QString& query)
+     QElapsedTimer t;
+     t.start();
+ #endif
++    if (!driver()) {
++        qWarning("QSqlQuery::exec: called before driver has been set up");
++        return false;
++    }
+     if (d->ref.loadRelaxed() != 1) {
+         bool fo = isForwardOnly();
+         *this = QSqlQuery(driver()->createResult());
+diff --git a/qtbase/src/testlib/qabstractitemmodeltester.cpp b/qtbase/src/testlib/qabstractitemmodeltester.cpp
+index 8efb9c53d4..ce062f66d7 100644
+--- a/qtbase/src/testlib/qabstractitemmodeltester.cpp
++++ b/qtbase/src/testlib/qabstractitemmodeltester.cpp
+@@ -454,7 +454,7 @@ void QAbstractItemModelTesterPrivate::parent()
+ 
+     // Common error test #2, make sure that a second level index has a parent
+     // that is the first level index.
+-    if (model->rowCount(topIndex) > 0) {
++    if (model->rowCount(topIndex) > 0 && model->columnCount(topIndex) > 0) {
+         QModelIndex childIndex = model->index(0, 0, topIndex);
+         MODELTESTER_VERIFY(childIndex.isValid());
+         MODELTESTER_COMPARE(model->parent(childIndex), topIndex);
+diff --git a/qtbase/src/testlib/qasciikey.cpp b/qtbase/src/testlib/qasciikey.cpp
+index 9a308da2bc..93498b256f 100644
+--- a/qtbase/src/testlib/qasciikey.cpp
++++ b/qtbase/src/testlib/qasciikey.cpp
+@@ -498,6 +498,11 @@ char QTest::keyToAscii(Qt::Key key)
+     case Qt::Key_LaunchE : return 0; // = 0x10b0,
+     case Qt::Key_LaunchF : return 0; // = 0x10b1,
+ 
++    // Keypad navigation keys
++    case Qt::Key_Select : return 0; // = 0x01010000
++    case Qt::Key_Yes : return 0; // = 0x01010001
++    case Qt::Key_No : return 0; // = 0x01010002
++
+     default: QTEST_ASSERT(false); return 0;
+     }
+ }
+diff --git a/qtbase/src/testlib/qtestresult.cpp b/qtbase/src/testlib/qtestresult.cpp
+index 88028aac6e..2e89930776 100644
+--- a/qtbase/src/testlib/qtestresult.cpp
++++ b/qtbase/src/testlib/qtestresult.cpp
+@@ -251,7 +251,8 @@ bool QTestResult::verify(bool statement, const char *statementStr,
+ {
+     QTEST_ASSERT(statementStr);
+ 
+-    char msg[1024] = {'\0'};
++    char msg[1024];
++    msg[0] = '\0';
+ 
+     if (QTestLog::verboseLevel() >= 2) {
+         qsnprintf(msg, 1024, "QVERIFY(%s)", statementStr);
+@@ -309,7 +310,8 @@ static bool compareHelper(bool success, const char *failureMsg,
+                           bool hasValues = true)
+ {
+     const size_t maxMsgLen = 1024;
+-    char msg[maxMsgLen] = {'\0'};
++    char msg[maxMsgLen];
++    msg[0] = '\0';
+ 
+     QTEST_ASSERT(expected);
+     QTEST_ASSERT(actual);
+diff --git a/qtbase/src/widgets/dialogs/qcolordialog.cpp b/qtbase/src/widgets/dialogs/qcolordialog.cpp
+index 4247731275..cb325be85c 100644
+--- a/qtbase/src/widgets/dialogs/qcolordialog.cpp
++++ b/qtbase/src/widgets/dialogs/qcolordialog.cpp
+@@ -78,7 +78,10 @@
+ #include "qwindow.h"
+ 
+ #include "private/qdialog_p.h"
++#include "private/qguiapplication_p.h"
+ 
++#include <qpa/qplatformservices.h>
++#include <qpa/qplatformintegration.h>
+ #include <algorithm>
+ 
+ QT_BEGIN_NAMESPACE
+@@ -1611,6 +1614,20 @@ void QColorDialogPrivate::_q_newStandard(int r, int c)
+ void QColorDialogPrivate::_q_pickScreenColor()
+ {
+     Q_Q(QColorDialog);
++
++    auto *platformServices = QGuiApplicationPrivate::platformIntegration()->services();
++    if (platformServices->hasCapability(QPlatformServices::Capability::ColorPicking)) {
++        if (auto *colorPicker = platformServices->colorPicker(q->windowHandle())) {
++            q->connect(colorPicker, &QPlatformServiceColorPicker::colorPicked, q,
++                       [q, colorPicker](const QColor &color) {
++                           colorPicker->deleteLater();
++                           q->setCurrentColor(color);
++                       });
++            colorPicker->pickColor();
++            return;
++        }
++    }
++
+     if (!colorPickingEventFilter)
+         colorPickingEventFilter = new QColorPickingEventFilter(this, q);
+     q->installEventFilter(colorPickingEventFilter);
+diff --git a/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp b/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
+index e120817edc..8ea36b5427 100644
+--- a/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
++++ b/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
+@@ -400,12 +400,7 @@ bool QAbstractItemDelegate::helpEvent(QHelpEvent *event,
+         const QString tooltip = index.isValid() ?
+               d->textForRole(Qt::ToolTipRole, index.data(Qt::ToolTipRole), option.locale, precision) :
+               QString();
+-        QRect rect;
+-        if (index.isValid()) {
+-            const QRect r = view->visualRect(index);
+-            rect = QRect(view->mapToGlobal(r.topLeft()), r.size());
+-        }
+-        QToolTip::showText(he->globalPos(), tooltip, view, rect);
++        QToolTip::showText(he->globalPos(), tooltip, view->viewport(), option.rect);
+         event->setAccepted(!tooltip.isEmpty());
+         break;
+         }
+diff --git a/qtbase/src/widgets/itemviews/qlistview.cpp b/qtbase/src/widgets/itemviews/qlistview.cpp
+index 2b34476642..eebfaa030e 100644
+--- a/qtbase/src/widgets/itemviews/qlistview.cpp
++++ b/qtbase/src/widgets/itemviews/qlistview.cpp
+@@ -3386,6 +3386,7 @@ void QIconModeViewBase::updateContentsSize()
+ */
+ void QListView::currentChanged(const QModelIndex &current, const QModelIndex &previous)
+ {
++    QAbstractItemView::currentChanged(current, previous);
+ #ifndef QT_NO_ACCESSIBILITY
+     if (QAccessible::isActive()) {
+         if (current.isValid()) {
+@@ -3396,7 +3397,6 @@ void QListView::currentChanged(const QModelIndex &current, const QModelIndex &pr
+         }
+     }
+ #endif
+-    QAbstractItemView::currentChanged(current, previous);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/widgets/itemviews/qtableview.cpp b/qtbase/src/widgets/itemviews/qtableview.cpp
+index 934ac581b2..f79bb24249 100644
+--- a/qtbase/src/widgets/itemviews/qtableview.cpp
++++ b/qtbase/src/widgets/itemviews/qtableview.cpp
+@@ -1013,6 +1013,7 @@ void QTableViewPrivate::drawCell(QPainter *painter, const QStyleOptionViewItem &
+ int QTableViewPrivate::widthHintForIndex(const QModelIndex &index, int hint, const QStyleOptionViewItem &option) const
+ {
+     Q_Q(const QTableView);
++    const int oldHint = hint;
+     QWidget *editor = editorForIndex(index).widget.data();
+     if (editor && persistent.contains(editor)) {
+         hint = qMax(hint, editor->sizeHint().width());
+@@ -1021,6 +1022,17 @@ int QTableViewPrivate::widthHintForIndex(const QModelIndex &index, int hint, con
+         hint = qBound(min, hint, max);
+     }
+     hint = qMax(hint, q->itemDelegate(index)->sizeHint(option, index).width());
++
++    if (hasSpans()) {
++        auto span = spans.spanAt(index.column(), index.row());
++        if (span && span->m_left == index.column() && span->m_top == index.row()) {
++            // spans are screwed up when sections are moved
++            const auto left = logicalColumn(span->m_left);
++            for (int i = 1; i <= span->width(); ++i)
++               hint -= q->columnWidth(visualColumn(left + i));
++        }
++        hint = std::max(hint, oldHint);
++    }
+     return hint;
+ }
+ 
+@@ -1053,6 +1065,11 @@ int QTableViewPrivate::heightHintForIndex(const QModelIndex &index, int hint, QS
+         option.rect.setHeight(height);
+         option.rect.setX(q->columnViewportPosition(index.column()));
+         option.rect.setWidth(q->columnWidth(index.column()));
++        if (hasSpans()) {
++            auto span = spans.spanAt(index.column(), index.row());
++            if (span && span->m_left == index.column() && span->m_top == index.row())
++                option.rect.setWidth(std::max(option.rect.width(), visualSpanRect(*span).width()));
++        }
+         // 1px less space when grid is shown (see drawCell)
+         if (showGrid)
+             option.rect.setWidth(option.rect.width() - 1);
+diff --git a/qtbase/src/widgets/kernel/qaction.h b/qtbase/src/widgets/kernel/qaction.h
+index 258a1ea0a0..737c1e8285 100644
+--- a/qtbase/src/widgets/kernel/qaction.h
++++ b/qtbase/src/widgets/kernel/qaction.h
+@@ -81,7 +81,7 @@ class Q_WIDGETS_EXPORT QAction : public QObject
+     Q_PROPERTY(MenuRole menuRole READ menuRole WRITE setMenuRole NOTIFY changed)
+     Q_PROPERTY(bool iconVisibleInMenu READ isIconVisibleInMenu WRITE setIconVisibleInMenu NOTIFY changed)
+     Q_PROPERTY(bool shortcutVisibleInContextMenu READ isShortcutVisibleInContextMenu WRITE setShortcutVisibleInContextMenu NOTIFY changed)
+-    Q_PROPERTY(Priority priority READ priority WRITE setPriority)
++    Q_PROPERTY(Priority priority READ priority WRITE setPriority NOTIFY changed)
+ 
+ public:
+     // note this is copied into qplatformmenu.h, which must stay in sync
+diff --git a/qtbase/src/widgets/kernel/qwidget.cpp b/qtbase/src/widgets/kernel/qwidget.cpp
+index 9eba1e001e..26f6d27e18 100644
+--- a/qtbase/src/widgets/kernel/qwidget.cpp
++++ b/qtbase/src/widgets/kernel/qwidget.cpp
+@@ -5296,7 +5296,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
+         QWidgetEffectSourcePrivate *sourced = static_cast<QWidgetEffectSourcePrivate *>
+                                                          (source->d_func());
+         if (!sourced->context) {
+-            const QRegion effectRgn(rgn.boundingRect());
++            const QRegion effectRgn((flags & UseEffectRegionBounds) ? rgn.boundingRect() : rgn);
+             QWidgetPaintContext context(pdev, effectRgn, offset, flags, sharedPainter, repaintManager);
+             sourced->context = &context;
+             if (!sharedPainter) {
+@@ -5328,6 +5328,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
+         }
+     }
+ #endif // QT_CONFIG(graphicseffect)
++    flags = flags & ~UseEffectRegionBounds;
+ 
+     const bool alsoOnScreen = flags & DrawPaintOnScreen;
+     const bool recursive = flags & DrawRecursive;
+diff --git a/qtbase/src/widgets/kernel/qwidget_p.h b/qtbase/src/widgets/kernel/qwidget_p.h
+index eef6b8fa2c..c432f4b5d5 100644
+--- a/qtbase/src/widgets/kernel/qwidget_p.h
++++ b/qtbase/src/widgets/kernel/qwidget_p.h
+@@ -229,7 +229,8 @@ public:
+         DontSubtractOpaqueChildren = 0x10,
+         DontDrawOpaqueChildren = 0x20,
+         DontDrawNativeChildren = 0x40,
+-        DontSetCompositionMode = 0x80
++        DontSetCompositionMode = 0x80,
++        UseEffectRegionBounds = 0x100
+     };
+     Q_DECLARE_FLAGS(DrawWidgetFlags, DrawWidgetFlag)
+     Q_FLAG(DrawWidgetFlags)
+diff --git a/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp b/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
+index 02880b34da..0d44e1326d 100644
+--- a/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
++++ b/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
+@@ -1018,7 +1018,8 @@ void QWidgetRepaintManager::paintAndFlush()
+ 
+     // Paint the rest with composition.
+     if (repaintAllWidgets || !dirtyCopy.isEmpty()) {
+-        QWidgetPrivate::DrawWidgetFlags flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive;
++        QWidgetPrivate::DrawWidgetFlags flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive
++                | QWidgetPrivate::UseEffectRegionBounds;
+         tlw->d_func()->drawWidget(store->paintDevice(), dirtyCopy, QPoint(), flags, nullptr, this);
+     }
+ 
+diff --git a/qtbase/src/widgets/styles/qfusionstyle.cpp b/qtbase/src/widgets/styles/qfusionstyle.cpp
+index f4345d97c4..962912c838 100644
+--- a/qtbase/src/widgets/styles/qfusionstyle.cpp
++++ b/qtbase/src/widgets/styles/qfusionstyle.cpp
+@@ -1772,14 +1772,6 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio
+             proxy()->drawControl(CE_PushButtonLabel, &subopt, painter, widget);
+         }
+         break;
+-    case CE_PushButtonLabel:
+-        if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
+-            QStyleOptionButton b(*button);
+-            // no PM_ButtonShiftHorizontal and PM_ButtonShiftVertical for fusion style
+-            b.state &= ~(State_On | State_Sunken);
+-            QCommonStyle::drawControl(element, &b, painter, widget);
+-        }
+-        break;
+     case CE_MenuBarEmptyArea:
+         painter->save();
+     {
+diff --git a/qtbase/src/widgets/util/qcompleter.cpp b/qtbase/src/widgets/util/qcompleter.cpp
+index 18b24063d8..ef7207a8a3 100644
+--- a/qtbase/src/widgets/util/qcompleter.cpp
++++ b/qtbase/src/widgets/util/qcompleter.cpp
+@@ -1120,6 +1120,8 @@ void QCompleter::setModel(QAbstractItemModel *model)
+ {
+     Q_D(QCompleter);
+     QAbstractItemModel *oldModel = d->proxy->sourceModel();
++    if (oldModel == model)
++        return;
+ #if QT_CONFIG(filesystemmodel)
+     if (qobject_cast<const QFileSystemModel *>(oldModel))
+         setCompletionRole(Qt::EditRole); // QTBUG-54642, clear FileNameRole set by QFileSystemModel
+diff --git a/qtbase/src/widgets/widgets/qabstractbutton.cpp b/qtbase/src/widgets/widgets/qabstractbutton.cpp
+index a128b23950..dc40bf62fb 100644
+--- a/qtbase/src/widgets/widgets/qabstractbutton.cpp
++++ b/qtbase/src/widgets/widgets/qabstractbutton.cpp
+@@ -56,6 +56,7 @@
+ #ifndef QT_NO_ACCESSIBILITY
+ #include "qaccessible.h"
+ #endif
++#include <qpa/qplatformtheme.h>
+ 
+ #include <algorithm>
+ 
+@@ -1076,19 +1077,19 @@ void QAbstractButton::keyPressEvent(QKeyEvent *e)
+ {
+     Q_D(QAbstractButton);
+     bool next = true;
+-    switch (e->key()) {
+-    case Qt::Key_Enter:
+-    case Qt::Key_Return:
+-        e->ignore();
+-        break;
+-    case Qt::Key_Select:
+-    case Qt::Key_Space:
+-        if (!e->isAutoRepeat()) {
+-            setDown(true);
+-            repaint();
+-            d->emitPressed();
+-        }
+-        break;
++
++    const auto key = static_cast<Qt::Key>(e->key());
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(key) && !e->isAutoRepeat()) {
++        setDown(true);
++        repaint();
++        d->emitPressed();
++        return;
++    }
++
++    switch (key) {
+     case Qt::Key_Up:
+         next = false;
+         Q_FALLTHROUGH();
+@@ -1153,15 +1154,15 @@ void QAbstractButton::keyReleaseEvent(QKeyEvent *e)
+     if (!e->isAutoRepeat())
+         d->repeatTimer.stop();
+ 
+-    switch (e->key()) {
+-    case Qt::Key_Select:
+-    case Qt::Key_Space:
+-        if (!e->isAutoRepeat() && d->down)
+-            d->click();
+-        break;
+-    default:
+-        e->ignore();
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(static_cast<Qt::Key>(e->key())) && !e->isAutoRepeat() && d->down) {
++        d->click();
++        return;
+     }
++
++    e->ignore();
+ }
+ 
+ /*!\reimp
+diff --git a/qtbase/src/widgets/widgets/qcombobox.cpp b/qtbase/src/widgets/widgets/qcombobox.cpp
+index 7a496c27e0..0a3d96647b 100644
+--- a/qtbase/src/widgets/widgets/qcombobox.cpp
++++ b/qtbase/src/widgets/widgets/qcombobox.cpp
+@@ -3352,7 +3352,23 @@ void QComboBox::keyPressEvent(QKeyEvent *e)
+ 
+     Move move = NoMove;
+     int newIndex = currentIndex();
+-    switch (e->key()) {
++
++    bool pressLikeButton = !d->lineEdit;
++#ifdef QT_KEYPAD_NAVIGATION
++    pressLikeButton |= QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus();
++#endif
++    auto key = static_cast<Qt::Key>(e->key());
++    if (pressLikeButton) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(key)) {
++            showPopup();
++            return;
++        }
++    }
++
++    switch (key) {
+     case Qt::Key_Up:
+         if (e->modifiers() & Qt::ControlModifier)
+             break; // pass to line edit for auto completion
+@@ -3394,26 +3410,11 @@ void QComboBox::keyPressEvent(QKeyEvent *e)
+             return;
+         }
+         break;
+-    case Qt::Key_Space:
+-        if (!d->lineEdit) {
+-            showPopup();
+-            return;
+-        }
+-        break;
+-    case Qt::Key_Enter:
+-    case Qt::Key_Return:
+     case Qt::Key_Escape:
+         if (!d->lineEdit)
+             e->ignore();
+         break;
+ #ifdef QT_KEYPAD_NAVIGATION
+-    case Qt::Key_Select:
+-        if (QApplicationPrivate::keypadNavigationEnabled()
+-                && (!hasEditFocus() || !d->lineEdit)) {
+-            showPopup();
+-            return;
+-        }
+-        break;
+     case Qt::Key_Left:
+     case Qt::Key_Right:
+         if (QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus())
+diff --git a/qtbase/src/widgets/widgets/qdatetimeedit_p.h b/qtbase/src/widgets/widgets/qdatetimeedit_p.h
+index d36b6f8f9a..e0df5b5158 100644
+--- a/qtbase/src/widgets/widgets/qdatetimeedit_p.h
++++ b/qtbase/src/widgets/widgets/qdatetimeedit_p.h
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2018 The Qt Company Ltd.
++** Copyright (C) 2021 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtWidgets module of the Qt Toolkit.
+diff --git a/qtbase/src/widgets/widgets/qgroupbox.cpp b/qtbase/src/widgets/widgets/qgroupbox.cpp
+index 02a0bed325..3f3eccc370 100644
+--- a/qtbase/src/widgets/widgets/qgroupbox.cpp
++++ b/qtbase/src/widgets/widgets/qgroupbox.cpp
+@@ -54,6 +54,8 @@
+ #include "qaccessible.h"
+ #endif
+ #include <private/qwidget_p.h>
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
+ 
+ #include "qdebug.h"
+ 
+@@ -360,7 +362,10 @@ bool QGroupBox::event(QEvent *e)
+         return true;
+     case QEvent::KeyPress: {
+         QKeyEvent *k = static_cast<QKeyEvent*>(e);
+-        if (!k->isAutoRepeat() && (k->key() == Qt::Key_Select || k->key() == Qt::Key_Space)) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (!k->isAutoRepeat() && buttonPressKeys.contains(static_cast<Qt::Key>(k->key()))) {
+             d->pressedControl = QStyle::SC_GroupBoxCheckBox;
+             update(style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxCheckBox, this));
+             return true;
+@@ -369,7 +374,10 @@ bool QGroupBox::event(QEvent *e)
+     }
+     case QEvent::KeyRelease: {
+         QKeyEvent *k = static_cast<QKeyEvent*>(e);
+-        if (!k->isAutoRepeat() && (k->key() == Qt::Key_Select || k->key() == Qt::Key_Space)) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (!k->isAutoRepeat() && buttonPressKeys.contains(static_cast<Qt::Key>(k->key()))) {
+             bool toggle = (d->pressedControl == QStyle::SC_GroupBoxLabel
+                            || d->pressedControl == QStyle::SC_GroupBoxCheckBox);
+             d->pressedControl = QStyle::SC_None;
+diff --git a/qtbase/src/widgets/widgets/qlabel.cpp b/qtbase/src/widgets/widgets/qlabel.cpp
+index 30ff80cbb0..cf2605c17c 100644
+--- a/qtbase/src/widgets/widgets/qlabel.cpp
++++ b/qtbase/src/widgets/widgets/qlabel.cpp
+@@ -421,9 +421,6 @@ void QLabel::setPixmap(const QPixmap &pixmap)
+         d->pixmap = new QPixmap(pixmap);
+     }
+ 
+-    if (d->pixmap->depth() == 1 && !d->pixmap->mask())
+-        d->pixmap->setMask(*((QBitmap *)d->pixmap));
+-
+     d->updateLabel();
+ }
+ 
+diff --git a/qtbase/src/widgets/widgets/qtoolbararealayout.cpp b/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
+index 493c094cc1..d5f4b59017 100644
+--- a/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
++++ b/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
+@@ -1367,7 +1367,7 @@ bool QToolBarAreaLayout::restoreState(QDataStream &stream, const QList<QToolBar*
+                 item.widgetItem = new QWidgetItemV2(toolBar);
+                 toolBar->setOrientation(floating ? ((shown & 2) ? Qt::Vertical : Qt::Horizontal) : dock.o);
+                 toolBar->setVisible(shown & 1);
+-                toolBar->d_func()->setWindowState(floating, true, rect);
++                toolBar->d_func()->setWindowState(floating, false, rect);
+ 
+                 item.preferredSize = item.size;
+                 line.toolBarItems.append(item);
+diff --git a/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp b/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
+index 212c0a2e13..3c77b1ba0b 100644
+--- a/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
++++ b/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
+@@ -126,8 +126,7 @@ public:
+ 
+ void tst_QtConcurrentIterateKernel::instantiate()
+ {
+-    auto future = startThreadEngine(new PrintFor(0, 40)).startAsynchronously();
+-    future.waitForFinished();
++    startThreadEngine(new PrintFor(0, 40)).startBlocking();
+     QCOMPARE(iterations.loadRelaxed(), 40);
+ }
+ 
+@@ -166,10 +165,8 @@ void tst_QtConcurrentIterateKernel::stresstest()
+     const int times = 50;
+     for (int i = 0; i < times; ++i) {
+         counter.storeRelaxed(0);
+-        // ThreadEngine will delete f when it finishes
+-        auto f = new CountFor(0, iterations);
+-        auto future = f->startAsynchronously();
+-        future.waitForFinished();
++        CountFor f(0, iterations);
++        f.startBlocking();
+         QCOMPARE(counter.loadRelaxed(), iterations);
+     }
+ }
+@@ -177,11 +174,8 @@ void tst_QtConcurrentIterateKernel::stresstest()
+ void tst_QtConcurrentIterateKernel::noIterations()
+ {
+     const int times = 20000;
+-    for (int i = 0; i < times; ++i) {
+-        auto future = startThreadEngine(new IterateKernel<TestIterator, void>(0, 0))
+-                              .startAsynchronously();
+-        future.waitForFinished();
+-    }
++    for (int i = 0; i < times; ++i)
++        startThreadEngine(new IterateKernel<TestIterator, void>(0, 0)).startBlocking();
+ }
+ 
+ QMutex threadsMutex;
+@@ -236,10 +230,8 @@ void tst_QtConcurrentIterateKernel::throttling()
+ 
+     threads.clear();
+ 
+-    // ThreadEngine will delete f when it finishes
+-    auto f = new ThrottleFor(0, totalIterations);
+-    auto future = f->startAsynchronously();
+-    future.waitForFinished();
++    ThrottleFor f(0, totalIterations);
++    f.startBlocking();
+ 
+     QCOMPARE(iterations.loadRelaxed(), totalIterations);
+ 
+diff --git a/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp b/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
+index ac7be7acdd..81bc64c8d9 100644
+--- a/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
++++ b/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
+@@ -65,9 +65,16 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::runDirectly()
+ {
+-    PrintUser *engine = new PrintUser();
+-    QFuture<void> f = engine->startAsynchronously();
+-    f.waitForFinished();
++    {
++        PrintUser engine;
++        engine.startSingleThreaded();
++        engine.startBlocking();
++    }
++    {
++        PrintUser *engine = new PrintUser();
++        QFuture<void> f = engine->startAsynchronously();
++        f.waitForFinished();
++    }
+ }
+ 
+ class StringResultUser : public ThreadEngine<QString>
+@@ -99,10 +106,8 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::result()
+ {
+-    // ThreadEngine will delete 'engine' when it finishes
+-    auto engine = new StringResultUser();
+-    auto future = engine->startAsynchronously();
+-    QCOMPARE(future.result(), QString("Foo"));
++    StringResultUser engine;
++    QCOMPARE(*engine.startBlocking(), QString("Foo"));
+ }
+ 
+ class VoidResultUser : public ThreadEngine<void>
+@@ -128,9 +133,17 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::runThroughStarter()
+ {
+-    ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
+-    QFuture<QString> f = starter.startAsynchronously();
+-    QCOMPARE(f.result(), QString("Foo"));
++    {
++        ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
++        QFuture<QString>  f = starter.startAsynchronously();
++        QCOMPARE(f.result(), QString("Foo"));
++    }
++
++    {
++        ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
++        QString str = starter.startBlocking();
++        QCOMPARE(str, QString("Foo"));
++    }
+ }
+ 
+ class CancelUser : public ThreadEngine<void>
+@@ -213,6 +226,12 @@ void tst_QtConcurrentThreadEngine::throttle()
+         f.waitForFinished();
+         QCOMPARE(count.loadRelaxed(), 0);
+     }
++
++    for (int i = 0; i < repeats; ++i) {
++        ThrottleAlwaysUser t;
++        t.startBlocking();
++        QCOMPARE(count.loadRelaxed(), 0);
++    }
+ }
+ 
+ QSet<QThread *> threads;
+@@ -249,17 +268,35 @@ void tst_QtConcurrentThreadEngine::threadCount()
+ {
+     const int repeats = 10;
+     for (int i = 0; i < repeats; ++i) {
++        ThreadCountUser t;
++        t.startBlocking();
++        int count = threads.count();
++        int count_expected = QThreadPool::globalInstance()->maxThreadCount() + 1; // +1 for the main thread.
++        if (count != count_expected)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, count_expected);
++
+         (new ThreadCountUser())->startAsynchronously().waitForFinished();
+-        const auto count = threads.count();
+-        const auto maxThreadCount = QThreadPool::globalInstance()->maxThreadCount();
+-        QVERIFY(count <= maxThreadCount);
+-        QVERIFY(!threads.contains(QThread::currentThread()));
++        count = threads.count();
++        count_expected = QThreadPool::globalInstance()->maxThreadCount();
++        if (count != count_expected)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, count_expected);
+     }
+ 
+     // Set the finish flag immediately, this should give us one thread only.
+     for (int i = 0; i < repeats; ++i) {
++        ThreadCountUser t(true /*finishImmediately*/);
++        t.startBlocking();
++        int count = threads.count();
++        if (count != 1)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, 1);
++
+         (new ThreadCountUser(true /*finishImmediately*/))->startAsynchronously().waitForFinished();
+-        const auto count = threads.count();
++        count = threads.count();
++        if (count != 1)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
+         QCOMPARE(count, 1);
+         QVERIFY(!threads.contains(QThread::currentThread()));
+     }
+@@ -400,6 +437,7 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::exceptions()
+ {
++    // Asynchronous mode:
+     {
+         bool caught = false;
+         try  {
+@@ -412,6 +450,32 @@ void tst_QtConcurrentThreadEngine::exceptions()
+         QVERIFY2(caught, "did not get exception");
+     }
+ 
++    // Blocking mode:
++    // test throwing the exception from a worker thread.
++    {
++        bool caught = false;
++        try  {
++            QtConcurrentExceptionThrower e(QThread::currentThread());
++            e.startBlocking();
++        } catch (const QException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // test throwing the exception from the main thread (different code path)
++    {
++        bool caught = false;
++        try  {
++            QtConcurrentExceptionThrower e(0);
++            e.startBlocking();
++        } catch (const QException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // Asynchronous mode:
+     {
+         bool caught = false;
+         try  {
+@@ -423,6 +487,31 @@ void tst_QtConcurrentThreadEngine::exceptions()
+         }
+         QVERIFY2(caught, "did not get exception");
+     }
++
++    // Blocking mode:
++    // test throwing the exception from a worker thread.
++    {
++        bool caught = false;
++        try  {
++            UnrelatedExceptionThrower e(QThread::currentThread());
++            e.startBlocking();
++        } catch (const QUnhandledException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // test throwing the exception from the main thread (different code path)
++    {
++        bool caught = false;
++        try  {
++            UnrelatedExceptionThrower e(0);
++            e.startBlocking();
++        } catch (const QUnhandledException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
+ }
+ 
+ #endif
+diff --git a/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp b/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
+index 4968742110..f4c3fb711d 100644
+--- a/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
++++ b/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
+@@ -42,6 +42,7 @@ private slots:
+     void writeBlock_data();
+     void writeBlock();
+     void seek();
++    void invalidSeeks();
+     void seekTest_data();
+     void seekTest();
+     void read_rawdata();
+@@ -286,6 +287,29 @@ void tst_QBuffer::seek()
+     QCOMPARE(buffer.size(), pos);
+ }
+ 
++void tst_QBuffer::invalidSeeks()
++{
++    if constexpr (sizeof(qsizetype) == sizeof(qint64)) {
++        // sizeof(qsizetype) == sizeof(qint64), so +1 would overflow
++        QSKIP("This is a 32-bit-only test.");
++    } else {
++        QBuffer buffer;
++        buffer.open(QIODevice::WriteOnly);
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++        constexpr qint64 MaxQByteArrayCapacity = (std::numeric_limits<qsizetype>::max)();
++        // this should fail fast, not after trying to allocate nearly 2 GiB of data,
++        // potentially crashing in the process:
++        QVERIFY(!buffer.seek(2 * MaxQByteArrayCapacity - 1));
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++        // ditto:
++        QVERIFY(!buffer.seek(MaxQByteArrayCapacity + 1));
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++    }
++}
++
+ void tst_QBuffer::seekTest_data()
+ {
+     writeBlock_data();
+diff --git a/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp b/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
+index da5327594c..4a04e0f7c6 100644
+--- a/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
++++ b/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
+@@ -561,7 +561,8 @@ protected:
+     qint64 readData(char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf->size() - offset));
+-        memcpy(data, buf->constData() + offset, maxSize);
++        if (maxSize > 0)
++            memcpy(data, buf->constData() + offset, maxSize);
+         offset += maxSize;
+         return maxSize;
+     }
+@@ -604,13 +605,15 @@ protected:
+     qint64 readData(char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf.size() - pos()));
+-        memcpy(data, buf.constData() + pos(), maxSize);
++        if (maxSize > 0)
++            memcpy(data, buf.constData() + pos(), maxSize);
+         return maxSize;
+     }
+     qint64 writeData(const char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf.size() - pos()));
+-        memcpy(buf.data() + pos(), data, maxSize);
++        if (maxSize > 0)
++            memcpy(buf.data() + pos(), data, maxSize);
+         return maxSize;
+     }
+ 
+diff --git a/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+index db60bead64..f345a44414 100644
+--- a/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
++++ b/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+@@ -1,7 +1,8 @@
+ /****************************************************************************
+ **
+ ** Copyright (C) 2021 The Qt Company Ltd.
+-** Copyright (C) 2020 Intel Corporation.
++** Copyright (C) 2020 The Qt Company Ltd.
++** Copyright (C) 2022 Intel Corporation.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the test suite of the Qt Toolkit.
+@@ -150,6 +151,8 @@ private slots:
+     void startStopStartStopBuffers();
+     void processEventsInAReadyReadSlot_data();
+     void processEventsInAReadyReadSlot();
++    void startFromCurrentWorkingDir_data();
++    void startFromCurrentWorkingDir();
+ 
+     // keep these at the end, since they use lots of processes and sometimes
+     // caused obscure failures to occur in tests that followed them (esp. on the Mac)
+@@ -2731,5 +2734,94 @@ void tst_QProcess::finishProcessBeforeReadingDone_deprecated()
+ 
+ #endif
+ 
++enum class ChdirMode {
++    None = 0,
++    InParent,
++    InChild
++};
++Q_DECLARE_METATYPE(ChdirMode)
++
++void tst_QProcess::startFromCurrentWorkingDir_data()
++{
++    qRegisterMetaType<ChdirMode>();
++    QTest::addColumn<QString>("programPrefix");
++    QTest::addColumn<ChdirMode>("chdirMode");
++    QTest::addColumn<bool>("success");
++
++    constexpr bool IsWindows = true
++#ifdef Q_OS_UNIX
++            && false
++#endif
++            ;
++
++    // baseline: trying to execute the directory, this can't possibly succeed!
++    QTest::newRow("plain-same-cwd") << QString() << ChdirMode::None << false;
++
++    // cross-platform behavior: neither OS searches the setWorkingDirectory()
++    // dir without "./"
++    QTest::newRow("plain-child-chdir") << QString() << ChdirMode::InChild << false;
++
++    // cross-platform behavior: both OSes search the parent's CWD with "./"
++    QTest::newRow("prefixed-parent-chdir") << "./" << ChdirMode::InParent << true;
++
++    // opposite behaviors: Windows searches the parent's CWD and Unix searches
++    // the child's with "./"
++    QTest::newRow("prefixed-child-chdir") << "./" << ChdirMode::InChild << !IsWindows;
++
++    // Windows searches the parent's CWD without "./"
++    QTest::newRow("plain-parent-chdir") << QString() << ChdirMode::InParent << IsWindows;
++}
++
++void tst_QProcess::startFromCurrentWorkingDir()
++{
++    QFETCH(QString, programPrefix);
++    QFETCH(ChdirMode, chdirMode);
++    QFETCH(bool, success);
++
++    QProcess process;
++    qRegisterMetaType<QProcess::ProcessError>();
++    QSignalSpy errorSpy(&process, &QProcess::errorOccurred);
++    QVERIFY(errorSpy.isValid());
++
++    // both the dir name and the executable name
++    const QString target = QStringLiteral("testProcessNormal");
++    process.setProgram(programPrefix + target);
++
++#ifdef Q_OS_UNIX
++    // Reset PATH, to be sure it doesn't contain . or the empty path.
++    // We can't do this on Windows because DLLs are searched in PATH
++    // and Windows always searches "." anyway.
++    auto restoreEnv = qScopeGuard([old = qgetenv("PATH")] {
++        qputenv("PATH", old);
++    });
++    qputenv("PATH", "/");
++#endif
++
++    switch (chdirMode) {
++    case ChdirMode::InParent: {
++        auto restoreCwd = qScopeGuard([old = QDir::currentPath()] {
++            QDir::setCurrent(old);
++        });
++        QVERIFY(QDir::setCurrent(target));
++        process.start();
++        break;
++    }
++    case ChdirMode::InChild:
++        process.setWorkingDirectory(target);
++        Q_FALLTHROUGH();
++    case ChdirMode::None:
++        process.start();
++        break;
++    }
++
++    QCOMPARE(process.waitForStarted(), success);
++    QCOMPARE(errorSpy.count(), int(!success));
++    if (success) {
++        QVERIFY(process.waitForFinished());
++    } else {
++        QCOMPARE(process.error(), QProcess::FailedToStart);
++    }
++}
++
+ QTEST_MAIN(tst_QProcess)
+ #include "tst_qprocess.moc"
+diff --git a/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp b/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp
+index e1ea7a4552..90972caa57 100644
+--- a/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp
++++ b/qtbase/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"
+diff --git a/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+index 9bd66c0835..ed4a0bae5d 100644
+--- a/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
++++ b/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+@@ -158,6 +158,7 @@ private slots:
+     void nullReceiver();
+     void functorReferencesConnection();
+     void disconnectDisconnects();
++    void declarativeData();
+ };
+ 
+ struct QObjectCreatedOnShutdown
+@@ -7679,5 +7680,81 @@ void tst_QObject::disconnectDisconnects()
+ Q_STATIC_ASSERT(QtPrivate::HasQ_OBJECT_Macro<tst_QObject>::Value);
+ Q_STATIC_ASSERT(!QtPrivate::HasQ_OBJECT_Macro<SiblingDeleter>::Value);
+ 
++#ifdef QT_BUILD_INTERNAL
++/*
++    Since QObjectPrivate stores the declarativeData pointer in a union with the pointer
++    to the currently destroyed child, calls to the QtDeclarative handlers need to be
++    correctly guarded. QTBUG-105286
++*/
++namespace QtDeclarative {
++static QAbstractDeclarativeData *theData;
++
++static void destroyed(QAbstractDeclarativeData *data, QObject *)
++{
++    QCOMPARE(data, theData);
++}
++static void signalEmitted(QAbstractDeclarativeData *data, QObject *, int, void **)
++{
++    QCOMPARE(data, theData);
++}
++// we can't use QCOMPARE in the next two functions, as they don't return void
++static int receivers(QAbstractDeclarativeData *data, const QObject *, int)
++{
++    QTest::qCompare(data, theData, "data", "theData", __FILE__, __LINE__);
++    return 0;
++}
++static bool isSignalConnected(QAbstractDeclarativeData *data, const QObject *, int)
++{
++    QTest::qCompare(data, theData, "data", "theData", __FILE__, __LINE__);
++    return true;
++}
++
++class Object : public QObject
++{
++    Q_OBJECT
++public:
++    using QObject::QObject;
++    ~Object()
++    {
++        if (Object *p = static_cast<Object *>(parent()))
++            p->emitSignal();
++    }
++
++    void emitSignal()
++    {
++        emit theSignal();
++    }
++
++signals:
++    void theSignal();
++};
++
++}
++#endif
++
++void tst_QObject::declarativeData()
++{
++#ifdef QT_BUILD_INTERNAL
++    QScopedValueRollback destroyed(QAbstractDeclarativeData::destroyed,
++                                   QtDeclarative::destroyed);
++    QScopedValueRollback signalEmitted(QAbstractDeclarativeData::signalEmitted,
++                                       QtDeclarative::signalEmitted);
++    QScopedValueRollback receivers(QAbstractDeclarativeData::receivers,
++                                   QtDeclarative::receivers);
++    QScopedValueRollback isSignalConnected(QAbstractDeclarativeData::isSignalConnected,
++                                           QtDeclarative::isSignalConnected);
++
++    QtDeclarative::Object p;
++    QObjectPrivate *priv = QObjectPrivate::get(&p);
++    priv->declarativeData = QtDeclarative::theData = new QAbstractDeclarativeData;
++
++    connect(&p, &QtDeclarative::Object::theSignal, &p, []{
++    });
++
++    QtDeclarative::Object *child = new QtDeclarative::Object;
++    child->setParent(&p);
++#endif
++}
++
+ QTEST_MAIN(tst_QObject)
+ #include "tst_qobject.moc"
+diff --git a/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp b/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
+index 0ea422ecbc..1a3256534b 100644
+--- a/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
++++ b/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
+@@ -70,15 +70,15 @@ static inline QString testSuiteWarning()
+ 
+     QString result;
+     QTextStream str(&result);
+-    str << "\nCannot find the shared-mime-info test suite\nstarting from: "
++    str << "\nCannot find the shared-mime-info test suite\nin the parent of: "
+         << QDir::toNativeSeparators(QDir::currentPath()) << "\n"
+            "cd " << QDir::toNativeSeparators(QStringLiteral("tests/auto/corelib/mimetypes/qmimedatabase")) << "\n"
+-           "wget http://cgit.freedesktop.org/xdg/shared-mime-info/snapshot/Release-1-10.zip\n"
+-           "unzip Release-1-10.zip\n";
++           "wget https://gitlab.freedesktop.org/xdg/shared-mime-info/-/archive/2.1/shared-mime-info-2.1.zip\n"
++           "unzip shared-mime-info-2.1.zip\n";
+ #ifdef Q_OS_WIN
+-    str << "mkdir testfiles\nxcopy /s Release-1-10 s-m-i\n";
++    str << "mkdir testfiles\nxcopy /s shared-mime-info-2.1 s-m-i\n";
+ #else
+-    str << "ln -s Release-1-10 s-m-i\n";
++    str << "ln -s shared-mime-info-2.1 s-m-i\n";
+ #endif
+     return result;
+ }
+@@ -154,7 +154,7 @@ void tst_QMimeDatabase::initTestCase()
+     QVERIFY2(copyResourceFile(xmlFileName, xmlTargetFileName, &errorMessage), qPrintable(errorMessage));
+ #endif
+ 
+-    m_testSuite = QFINDTESTDATA("s-m-i/tests");
++    m_testSuite = QFINDTESTDATA("s-m-i/tests/mime-detection");
+     if (m_testSuite.isEmpty())
+         qWarning("%s", qPrintable(testSuiteWarning()));
+ 
+@@ -611,7 +611,7 @@ void tst_QMimeDatabase::allMimeTypes()
+     QVERIFY(!lst.isEmpty());
+ 
+     // Hardcoding this is the only way to check both providers find the same number of mimetypes.
+-    QCOMPARE(lst.count(), 779);
++    QCOMPARE(lst.count(), 811);
+ 
+     foreach (const QMimeType &mime, lst) {
+         const QString name = mime.name();
+@@ -631,10 +631,9 @@ void tst_QMimeDatabase::suffixes_data()
+ 
+     QTest::newRow("mimetype with a single pattern") << "application/pdf" << "*.pdf" << "pdf";
+     QTest::newRow("mimetype with multiple patterns") << "application/x-kpresenter" << "*.kpr;*.kpt" << "kpr";
+-    QTest::newRow("jpeg") << "image/jpeg" << "*.jpe;*.jpg;*.jpeg" << "jpeg";
+-    //if (KMimeType::sharedMimeInfoVersion() > KDE_MAKE_VERSION(0, 60, 0)) {
+-        QTest::newRow("mimetype with many patterns") << "application/vnd.wordperfect" << "*.wp;*.wp4;*.wp5;*.wp6;*.wpd;*.wpp" << "wp";
+-    //}
++    // The preferred suffix for image/jpeg is *.jpg, as per https://bugs.kde.org/show_bug.cgi?id=176737
++    QTest::newRow("jpeg") << "image/jpeg" << "*.jpe;*.jpg;*.jpeg" << "jpg";
++    QTest::newRow("mimetype with many patterns") << "application/vnd.wordperfect" << "*.wp;*.wp4;*.wp5;*.wp6;*.wpd;*.wpp" << "wp";
+     QTest::newRow("oasis text mimetype") << "application/vnd.oasis.opendocument.text" << "*.odt" << "odt";
+     QTest::newRow("oasis presentation mimetype") << "application/vnd.oasis.opendocument.presentation" << "*.odp" << "odp";
+     QTest::newRow("mimetype with multiple patterns") << "text/plain" << "*.asc;*.txt;*,v" << "txt";
+diff --git a/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp b/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
+index 3e58dd03cc..c8f82ef5d5 100644
+--- a/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
++++ b/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
+@@ -176,6 +176,8 @@ private Q_SLOTS:
+     void fromToVariantConversions_data();
+     void fromToVariantConversions();
+ 
++    void noLeakOnNameClash();
++
+ private:
+     QString testDataDir;
+ };
+@@ -3685,5 +3687,23 @@ void tst_QtJson::fromToVariantConversions()
+     }
+ }
+ 
++void tst_QtJson::noLeakOnNameClash()
++{
++    QJsonDocument doc = QJsonDocument::fromJson("{\"\":{\"\":0},\"\":0}");
++    QVERIFY(!doc.isNull());
++    const QJsonObject obj = doc.object();
++
++    // Removed the duplicate key.
++    QCOMPARE(obj.length(), 1);
++
++    // Retained the last of the duplicates.
++    const QJsonValue val = obj.begin().value();
++    QVERIFY(val.isDouble());
++    QCOMPARE(val.toDouble(), 0.0);
++
++    // It should not leak.
++    // In particular it should not forget to deref the container for the inner object.
++}
++
+ QTEST_MAIN(tst_QtJson)
+ #include "tst_qtjson.moc"
+diff --git a/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp b/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
+index a59b58d57f..241c3e84ac 100644
+--- a/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
++++ b/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
+@@ -63,6 +63,7 @@ private slots:
+     void isValidId_data();
+     void isValidId();
+     void malformed();
++    void serialize();
+     // Backend tests
+     void utcTest();
+     void icuTest();
+@@ -947,6 +948,33 @@ void tst_QTimeZone::malformed()
+         barf.offsetFromUtc(now);
+ }
+ 
++void tst_QTimeZone::serialize()
++{
++    int parts = 0;
++#ifndef QT_NO_DEBUG_STREAM
++    qDebug() << QTimeZone(); // to verify no crash
++    parts++;
++#endif
++#ifndef QT_NO_DATASTREAM
++    QByteArray blob;
++    {
++        QDataStream stream(&blob, QIODevice::WriteOnly);
++        stream << QTimeZone("Europe/Oslo") << QTimeZone(420) << QTimeZone() << qint64(-1);
++    }
++    QDataStream stream(&blob, QIODevice::ReadOnly);
++    QTimeZone invalid, offset, oslo;
++    qint64 minusone;
++    stream >> oslo >> offset >> invalid >> minusone;
++    QCOMPARE(oslo, QTimeZone("Europe/Oslo"));
++    QCOMPARE(offset, QTimeZone(420));
++    QVERIFY(!invalid.isValid());
++    QCOMPARE(minusone, qint64(-1));
++    parts++;
++#endif
++    if (!parts)
++        QSKIP("No serialization enabled");
++}
++
+ void tst_QTimeZone::utcTest()
+ {
+ #ifdef QT_BUILD_INTERNAL
+diff --git a/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp b/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
+index 05480c6dd2..70f4c75756 100644
+--- a/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
++++ b/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
+@@ -324,6 +324,13 @@ void tst_QDBusInterface::notValid()
+ 
+     QVERIFY(!interface.isValid());
+     QVERIFY(!QMetaObject::invokeMethod(&interface, "ListNames", Qt::DirectConnection));
++
++    // With a connection, but empty/null service and path specified
++    QDBusConnection con = QDBusConnection::sessionBus();
++    QVERIFY(con.isConnected());
++    QDBusInterface iface({}, {}, {}, con);
++    QVERIFY(!iface.isValid());
++    QVERIFY(!QMetaObject::invokeMethod(&interface, "ListNames", Qt::DirectConnection));
+ }
+ 
+ void tst_QDBusInterface::notValidDerived()
+diff --git a/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp b/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
+index 874468c954..04ceb4ab65 100644
+--- a/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
++++ b/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
+@@ -507,6 +507,10 @@ void tst_QKeySequence::toStringFromKeycode_data()
+     QTest::newRow("Ctrl+Alt+Num+Del") << QKeySequence(Qt::ControlModifier | Qt::AltModifier | Qt::KeypadModifier | Qt::Key_Delete) << "Ctrl+Alt+Num+Del";
+     QTest::newRow("Ctrl+Ins") << QKeySequence(Qt::ControlModifier | Qt::Key_Insert) << "Ctrl+Ins";
+     QTest::newRow("Ctrl+Num+Ins(1)") << QKeySequence(Qt::Key_Insert | Qt::KeypadModifier | Qt::ControlModifier) << "Ctrl+Num+Ins";
++    QTest::newRow("Ctrl") << QKeySequence(Qt::Key_Control) << "Control";
++    QTest::newRow("Alt") << QKeySequence(Qt::Key_Alt) << "Alt";
++    QTest::newRow("Shift") << QKeySequence(Qt::Key_Shift) << "Shift";
++    QTest::newRow("Meta") << QKeySequence(Qt::Key_Meta) << "Meta";
+ }
+ 
+ void tst_QKeySequence::toStringFromKeycode()
+diff --git a/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp b/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+index 15e0ecadaa..b4eca74283 100644
+--- a/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
++++ b/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+@@ -81,6 +81,8 @@ private slots:
+     void registerOpenTypePreferredNamesSystem();
+     void registerOpenTypePreferredNamesApplication();
+ 
++    void stretchRespected();
++
+ private:
+     QString m_ledFont;
+     QString m_testFont;
+@@ -355,6 +357,28 @@ static QString testString()
+     return QStringLiteral("foo bar");
+ }
+ 
++void tst_QFontDatabase::stretchRespected()
++{
++    int italicId = QFontDatabase::addApplicationFont(m_testFontItalic);
++    QVERIFY(italicId != -1);
++
++    QVERIFY(!QFontDatabase::applicationFontFamilies(italicId).isEmpty());
++
++    QString italicFontName = QFontDatabase::applicationFontFamilies(italicId).first();
++
++    QFont italicFont = QFontDatabase().font(italicFontName,
++                                            QString::fromLatin1("Italic"), 14);
++    QVERIFY(italicFont.italic());
++
++    QFont italicStretchedFont = italicFont;
++    italicStretchedFont.setStretch( 400 );
++
++    QVERIFY(QFontMetricsF(italicFont).horizontalAdvance(QStringLiteral("foobar")) <
++            QFontMetricsF(italicStretchedFont).horizontalAdvance(QStringLiteral("foobar")));
++
++    QFontDatabase::removeApplicationFont(italicId);
++}
++
+ void tst_QFontDatabase::condensedFontWidthNoFontMerging()
+ {
+     int regularFontId = QFontDatabase::addApplicationFont(m_testFont);
+diff --git a/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+index 3d4a094c43..b423e11a99 100644
+--- a/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
++++ b/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+@@ -281,6 +281,7 @@ private Q_SLOTS:
+     void ioGetFromFileSpecial();
+     void ioGetFromFile_data();
+     void ioGetFromFile();
++    void ioGetFromFileUrl();
+     void ioGetFromFtp_data();
+     void ioGetFromFtp();
+     void ioGetFromFtpWithReuse();
+@@ -3300,6 +3301,18 @@ void tst_QNetworkReply::ioGetFromFile()
+     QCOMPARE(reader.data, data);
+ }
+ 
++void tst_QNetworkReply::ioGetFromFileUrl()
++{
++    // This immediately fails on non-windows platforms:
++    QNetworkRequest request(QUrl("file://unc-server/some/path"));
++    QNetworkReplyPtr reply(manager.get(request));
++    QSignalSpy finishedSpy(reply.get(), &QNetworkReply::finished);
++    // QTBUG-105618: This would, on non-Windows platforms, never happen because the signal
++    // was emitted before the constructor finished, leaving no chance at all to connect to the
++    // signal
++    QVERIFY(finishedSpy.wait());
++}
++
+ void tst_QNetworkReply::ioGetFromFtp_data()
+ {
+     QTest::addColumn<QString>("fileName");
+diff --git a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
+index 069fa6b341..4cc4d9a5ea 100644
+--- a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
++++ b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
+@@ -1,75 +1,34 @@
+-Certificate:
+-    Data:
+-        Version: 3 (0x2)
+-        Serial Number: 0 (0x0)
+-        Signature Algorithm: sha1WithRSAEncryption
+-        Issuer: C=NO, ST=Oslo, L=Nydalen, O=Nokia Corporation and/or its subsidiary(-ies), OU=Development, CN=fluke.troll.no/emailAddress=ahanssen@trolltech.com
+-        Validity
+-            Not Before: Dec  4 01:10:32 2007 GMT
+-            Not After : Apr 21 01:10:32 2035 GMT
+-        Subject: C=NO, ST=Oslo, O=Nokia Corporation and/or its subsidiary(-ies), OU=Development, CN=fluke.troll.no
+-        Subject Public Key Info:
+-            Public Key Algorithm: rsaEncryption
+-            RSA Public Key: (1024 bit)
+-                Modulus (1024 bit):
+-                    00:a7:c8:a0:4a:c4:19:05:1b:66:ba:32:e2:d2:f1:
+-                    1c:6f:17:82:e4:39:2e:01:51:90:db:04:34:32:11:
+-                    21:c2:0d:6f:59:d8:53:90:54:3f:83:8f:a9:d3:b3:
+-                    d5:ee:1a:9b:80:ae:c3:25:c9:5e:a5:af:4b:60:05:
+-                    aa:a0:d1:91:01:1f:ca:04:83:e3:58:1c:99:32:45:
+-                    84:70:72:58:03:98:4a:63:8b:41:f5:08:49:d2:91:
+-                    02:60:6b:e4:64:fe:dd:a0:aa:74:08:e9:34:4c:91:
+-                    5f:12:3d:37:4d:54:2c:ad:7f:5b:98:60:36:02:8c:
+-                    3b:f6:45:f3:27:6a:9b:94:9d
+-                Exponent: 65537 (0x10001)
+-        X509v3 extensions:
+-            X509v3 Basic Constraints: 
+-                CA:FALSE
+-            Netscape Comment: 
+-                OpenSSL Generated Certificate
+-            X509v3 Subject Key Identifier: 
+-                21:85:04:3D:23:01:66:E5:F7:9F:1A:84:24:8A:AF:0A:79:F4:E5:AC
+-            X509v3 Authority Key Identifier: 
+-                DirName:/C=NO/ST=Oslo/L=Nydalen/O=Nokia Corporation and/or its subsidiary(-ies)/OU=Development/CN=fluke.troll.no/emailAddress=ahanssen@trolltech.com
+-                serial:8E:A8:B4:E8:91:B7:54:2E
+-
+-    Signature Algorithm: sha1WithRSAEncryption
+-        6d:57:5f:d1:05:43:f0:62:05:ec:2a:71:a5:dc:19:08:f2:c4:
+-        a6:bd:bb:25:d9:ca:89:01:0e:e4:cf:1f:c1:8c:c8:24:18:35:
+-        53:59:7b:c0:43:b4:32:e6:98:b2:a6:ef:15:05:0b:48:5f:e1:
+-        a0:0c:97:a9:a1:77:d8:35:18:30:bc:a9:8f:d3:b7:54:c7:f1:
+-        a9:9e:5d:e6:19:bf:f6:3c:5b:2b:d8:e4:3e:62:18:88:8b:d3:
+-        24:e1:40:9b:0c:e6:29:16:62:ab:ea:05:24:70:36:aa:55:93:
+-        ef:02:81:1b:23:10:a2:04:eb:56:95:75:fc:f8:94:b1:5d:42:
+-        c5:3f:36:44:85:5d:3a:2e:90:46:8a:a2:b9:6f:87:ae:0c:15:
+-        40:19:31:90:fc:3b:25:bb:ae:f1:66:13:0d:85:90:d9:49:34:
+-        8f:f2:5d:f9:7a:db:4d:5d:27:f6:76:9d:35:8c:06:a6:4c:a3:
+-        b1:b2:b6:6f:1d:d7:a3:00:fd:72:eb:9e:ea:44:a1:af:21:34:
+-        7d:c7:42:e2:49:91:19:8b:c0:ad:ba:82:80:a8:71:70:f4:35:
+-        31:91:63:84:20:95:e9:60:af:64:8b:cc:ff:3d:8a:76:74:3d:
+-        c8:55:6d:e4:8e:c3:2b:1c:e8:42:18:ae:9f:e6:6b:9c:34:06:
+-        ec:6a:f2:c3
+ -----BEGIN CERTIFICATE-----
+-MIIEEzCCAvugAwIBAgIBADANBgkqhkiG9w0BAQUFADCBnDELMAkGA1UEBhMCTk8x
+-DTALBgNVBAgTBE9zbG8xEDAOBgNVBAcTB055ZGFsZW4xFjAUBgNVBAoTDVRyb2xs
+-dGVjaCBBU0ExFDASBgNVBAsTC0RldmVsb3BtZW50MRcwFQYDVQQDEw5mbHVrZS50
+-cm9sbC5ubzElMCMGCSqGSIb3DQEJARYWYWhhbnNzZW5AdHJvbGx0ZWNoLmNvbTAe
+-Fw0wNzEyMDQwMTEwMzJaFw0zNTA0MjEwMTEwMzJaMGMxCzAJBgNVBAYTAk5PMQ0w
+-CwYDVQQIEwRPc2xvMRYwFAYDVQQKEw1Ucm9sbHRlY2ggQVNBMRQwEgYDVQQLEwtE
+-ZXZlbG9wbWVudDEXMBUGA1UEAxMOZmx1a2UudHJvbGwubm8wgZ8wDQYJKoZIhvcN
+-AQEBBQADgY0AMIGJAoGBAKfIoErEGQUbZroy4tLxHG8XguQ5LgFRkNsENDIRIcIN
+-b1nYU5BUP4OPqdOz1e4am4CuwyXJXqWvS2AFqqDRkQEfygSD41gcmTJFhHByWAOY
+-SmOLQfUISdKRAmBr5GT+3aCqdAjpNEyRXxI9N01ULK1/W5hgNgKMO/ZF8ydqm5Sd
+-AgMBAAGjggEaMIIBFjAJBgNVHRMEAjAAMCwGCWCGSAGG+EIBDQQfFh1PcGVuU1NM
+-IEdlbmVyYXRlZCBDZXJ0aWZpY2F0ZTAdBgNVHQ4EFgQUIYUEPSMBZuX3nxqEJIqv
+-Cnn05awwgbsGA1UdIwSBszCBsKGBoqSBnzCBnDELMAkGA1UEBhMCTk8xDTALBgNV
+-BAgTBE9zbG8xEDAOBgNVBAcTB055ZGFsZW4xFjAUBgNVBAoTDVRyb2xsdGVjaCBB
+-U0ExFDASBgNVBAsTC0RldmVsb3BtZW50MRcwFQYDVQQDEw5mbHVrZS50cm9sbC5u
+-bzElMCMGCSqGSIb3DQEJARYWYWhhbnNzZW5AdHJvbGx0ZWNoLmNvbYIJAI6otOiR
+-t1QuMA0GCSqGSIb3DQEBBQUAA4IBAQBtV1/RBUPwYgXsKnGl3BkI8sSmvbsl2cqJ
+-AQ7kzx/BjMgkGDVTWXvAQ7Qy5piypu8VBQtIX+GgDJepoXfYNRgwvKmP07dUx/Gp
+-nl3mGb/2PFsr2OQ+YhiIi9Mk4UCbDOYpFmKr6gUkcDaqVZPvAoEbIxCiBOtWlXX8
+-+JSxXULFPzZEhV06LpBGiqK5b4euDBVAGTGQ/Dslu67xZhMNhZDZSTSP8l35ettN
+-XSf2dp01jAamTKOxsrZvHdejAP1y657qRKGvITR9x0LiSZEZi8CtuoKAqHFw9DUx
+-kWOEIJXpYK9ki8z/PYp2dD3IVW3kjsMrHOhCGK6f5mucNAbsavLD
++MIIF6zCCA9OgAwIBAgIUfo9amJtJGWqWE6f+SkAO85zkGr4wDQYJKoZIhvcNAQEL
++BQAwgYMxCzAJBgNVBAYTAk5PMQ0wCwYDVQQIDARPc2xvMQ0wCwYDVQQHDARPc2xv
++MRcwFQYDVQQKDA5UaGUgUXQgQ29tcGFueTEMMAoGA1UECwwDUiZEMRIwEAYDVQQD
++DAlIMiBUZXN0ZXIxGzAZBgkqhkiG9w0BCQEWDG1pbmltaUBxdC5pbzAgFw0yMDEw
++MjYxMjAxMzFaGA8yMTIwMTAwMjEyMDEzMVowgYMxCzAJBgNVBAYTAk5PMQ0wCwYD
++VQQIDARPc2xvMQ0wCwYDVQQHDARPc2xvMRcwFQYDVQQKDA5UaGUgUXQgQ29tcGFu
++eTEMMAoGA1UECwwDUiZEMRIwEAYDVQQDDAlIMiBUZXN0ZXIxGzAZBgkqhkiG9w0B
++CQEWDG1pbmltaUBxdC5pbzCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIB
++AOiUp5+E4blouKH7q+rVNR8NoYX2XkBW+q+rpy1zu5ssRSzbqxAjDx9dkht7Qlnf
++VlDT00JvpOWdeuPon5915edQRsY4Unl6mKH29ra3OtUa1/yCJXsGVJTKCj7k4Bxb
++5mZzb/fTlZntMLdTIBMfUbw62FKir1WjKIcJ9fCoG8JaGeKVO4Rh5p0ezd4UUUId
++r1BXl5Nqdqy2vTMsEDnjOsD3egkv8I2SKN4O6n/C3wWYpMOWYZkGoZiKz7rJs/i/
++ez7bsV7JlwdzTlhpJzkcOSVFBP6JlEOxTNNxZ1wtKy7PtZGmsSSATq2e6+bw38Ae
++Op0XnzzqcGjtDDofBmT7OFzZWjS9VZS6+DOOe2QHWle1nCHcHyH4ku6IRlsr9xkR
++NAIlOfnvHHxqJUenoeaZ4oQDjCBKS1KXygJO/tL7BLTQVn/xK1EmPvKNnjzWk4tR
++PnibUhhs5635qpOU/YPqFBh1JjVruZbsWcDAhRcew0uxONXOa9E+4lttQ9ySYa1A
++LvWqJuAX7gu2BsBMLyqfm811YnA7CIFMyO+HlqmkLFfv5L/xIRAXR7l26YGO0VwX
++CGjMfz4NVPMMke4nB7qa9NkpXQBQKMms3Qzd5JW0Hy9Ruj5O8GPcFZmV0twjd1uJ
++PD/cAjkWLaXjdNsJ16QWc2nghQRS6HYqKRX6j+CXOxupAgMBAAGjUzBRMB0GA1Ud
++DgQWBBRSCOU58j9NJZkMamt623qyCrhN3TAfBgNVHSMEGDAWgBRSCOU58j9NJZkM
++amt623qyCrhN3TAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4ICAQCq
++q4jxsWeNDv5Nq14hJtF9HB+ZL64zcZtRjJP1YgNs0QppKICmjPOL2nIMGmI/jKrs
++0eGAL/9XXNVHPxm1OPOncvimMMmU6emZfpMdEtTfKP43+Pg9HgKRjLoQp406vGeQ
++8ki/mbBhrItVPgEm3tu2AFA02XTYi+YxCI9kRZLGkM3FbgtOuTLPl0Z9y+kiPc9F
++uCSC03anBEqv+vDSI8+wODymQ/IJ3Jyz1lxIRDfp4qAekmy0jU2c91VOHHEmOmqq
++kqygGFRdwbe99m9yP63r6q0b5K3X2UnJ6bns0hmTwThYwpVPXLU8jdaTddbMukN2
++/Ef96Tsw8nWOEOPMySHOTIPgwyZRp26b0kA9EmhLwOP401SxXVQCmSRmtwNagmtg
++jJKmZoYBN+//D45ibK8z6Q0oOm9P+Whf/uUXehcRxBxyV3xz7k0wKGQbHj/ddwcy
++IUoIN4lrAlib+lK170kTKN352PDmrpo2gmIzPEsfurKAIMSelDl6H+kih16BtZ8y
++Nz6fh9Soqrg3OSAware8pxV7k51crBMoPLN78KoRV8MFCK4K7Fddq4rRISq6hiXq
++r1nsjoEPuKM9huprmZVZe9t5YcDa2I+wb3IiE3uwpZbAdaLDyQ5n6F/qpsiIkZXn
++gtcF7oqpG5oYrwCcZ53y/ezUgUg7PlSz2XwAGvQtgg==
+ -----END CERTIFICATE-----
+diff --git a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
+index 9d1664d609..337ce541a6 100644
+--- a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
++++ b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
+@@ -1,15 +1,52 @@
+------BEGIN RSA PRIVATE KEY-----
+-MIICXAIBAAKBgQCnyKBKxBkFG2a6MuLS8RxvF4LkOS4BUZDbBDQyESHCDW9Z2FOQ
+-VD+Dj6nTs9XuGpuArsMlyV6lr0tgBaqg0ZEBH8oEg+NYHJkyRYRwclgDmEpji0H1
+-CEnSkQJga+Rk/t2gqnQI6TRMkV8SPTdNVCytf1uYYDYCjDv2RfMnapuUnQIDAQAB
+-AoGANFzLkanTeSGNFM0uttBipFT9F4a00dqHz6JnO7zXAT26I5r8sU1pqQBb6uLz
+-/+Qz5Zwk8RUAQcsMRgJetuPQUb0JZjF6Duv24hNazqXBCu7AZzUenjafwmKC/8ri
+-KpX3fTwqzfzi//FKGgbXQ80yykSSliDL3kn/drATxsLCgQECQQDXhEFWLJ0vVZ1s
+-1Ekf+3NITE+DR16X+LQ4W6vyEHAjTbaNWtcTKdAWLA2l6N4WAAPYSi6awm+zMxx4
+-VomVTsjdAkEAx0z+e7natLeFcrrq8pbU+wa6SAP1VfhQWKitxL1e7u/QO90NCpxE
+-oQYKzMkmmpOOFjQwEMAy1dvFMbm4LHlewQJAC/ksDBaUcQHHqjktCtrUb8rVjAyW
+-A8lscckeB2fEYyG5J6dJVaY4ClNOOs5yMDS2Afk1F6H/xKvtQ/5CzInA/QJATDub
+-K+BPU8jO9q+gpuIi3VIZdupssVGmCgObVCHLakG4uO04y9IyPhV9lA9tALtoIf4c
+-VIvv5fWGXBrZ48kZAQJBAJmVCdzQxd9LZI5vxijUCj5EI4e+x5DRqVUvyP8KCZrC
+-AiNyoDP85T+hBZaSXK3aYGpVwelyj3bvo1GrTNwNWLw=
+------END RSA PRIVATE KEY-----
++-----BEGIN PRIVATE KEY-----
++MIIJQgIBADANBgkqhkiG9w0BAQEFAASCCSwwggkoAgEAAoICAQDolKefhOG5aLih
+++6vq1TUfDaGF9l5AVvqvq6ctc7ubLEUs26sQIw8fXZIbe0JZ31ZQ09NCb6TlnXrj
++6J+fdeXnUEbGOFJ5epih9va2tzrVGtf8giV7BlSUygo+5OAcW+Zmc2/305WZ7TC3
++UyATH1G8OthSoq9VoyiHCfXwqBvCWhnilTuEYeadHs3eFFFCHa9QV5eTanastr0z
++LBA54zrA93oJL/CNkijeDup/wt8FmKTDlmGZBqGYis+6ybP4v3s+27FeyZcHc05Y
++aSc5HDklRQT+iZRDsUzTcWdcLSsuz7WRprEkgE6tnuvm8N/AHjqdF5886nBo7Qw6
++HwZk+zhc2Vo0vVWUuvgzjntkB1pXtZwh3B8h+JLuiEZbK/cZETQCJTn57xx8aiVH
++p6HmmeKEA4wgSktSl8oCTv7S+wS00FZ/8StRJj7yjZ481pOLUT54m1IYbOet+aqT
++lP2D6hQYdSY1a7mW7FnAwIUXHsNLsTjVzmvRPuJbbUPckmGtQC71qibgF+4LtgbA
++TC8qn5vNdWJwOwiBTMjvh5appCxX7+S/8SEQF0e5dumBjtFcFwhozH8+DVTzDJHu
++Jwe6mvTZKV0AUCjJrN0M3eSVtB8vUbo+TvBj3BWZldLcI3dbiTw/3AI5Fi2l43Tb
++CdekFnNp4IUEUuh2KikV+o/glzsbqQIDAQABAoICAFw1q6tr5I48vY7DF+rXsuLn
++5ZUWE1IQ6fzB4lr72nJv/9EEGnMgYzt9PpMUsD6vdCpBgS2C0+6RHArFzJtNA+RM
++iHLIG7K7702veyr/xBx/MwiSlMeMv/XpkFxVI6E6skMGG2s3AMXxKvJTy5CpRx+I
++eQFyLG+Ya1X2lgJes/q+/CpAHkOjCOpcLySQC5NZ74q734V7nSdmn+Zs3tYEh+O/
++eiuwTP/j5b38Te5vVTqDxTciJPmljmXLCwa0N100lWlbcpvw8qbqiTI2Jm3XCbUE
++AzHjW9vmrF3cRS1fXxKFGShw3SRqlkbxjfeWoi8qDPUBS4m8LOr8qG9Wo5Nfon0z
++zLP4bci3zHDvVcaaZrrsUBs/yZbg+Dgka1DmX7ekmeccr2yTdKDFgPupYUyxVbTl
++a9ZLJysjFD7rgBv1ZclHonLp6Vbm+ZoTqvteo4ikAy6L9RtBWJ23XEK34PkP/+c5
++2vWZaOrnjSeBHbFce8cdJSxqWpP+eSCI5I9XbDrYFIsQ/gqKgtzDKy2ihJ2Y8STL
++yO4hyFPFjxc+Gg4/P2PpmT5CY2ty44M0BWs+JGW96CJPrrplf2lmQUQJj5LZY66X
++Z/4C9L7ZYtKZ+bs5SvU46yWugAvQZX22Xm9xLXWyVXRdx3bj+3M3fDnF9di/zdbh
++CgLx7oWPNrXc7FCajnn9AoIBAQD5FMYwRpw9NWT9WDxQwx+cSI4Icbd88ByTW63S
++LzeRwZA0J9/SfwO+aBRupzc9GkGXCiZcGMw3AGsCtig8yFlw8E5KnzN7KlftDMnM
++9NUxxzlR8VwKyLnZfG7sDTl057ZlUujnqhmt/F8F7dIy7FVO1dE/8nngA+FYTCOG
++UZdGjwyBDlDM0JJdUWGY3xslutcpCDN5mzSTKjy9drMvImAshRawxRF6WBpn7vr2
++nC6vciqfx1Mzx1vyk0Jm0ilaydDdLMADjt/iL4Nkr0BEs4k+UzQiKDwp8gu7abQ1
++eBfxd9Iar4htQa2I1Ewl6P01G/q+ZYwgHhJ9RVn4AxQXefILAoIBAQDvCouORdQX
++C8wsyp7MwXlF/3NQeNN5/+B2mhbxrBOf7PmMCXLnkRWcjwJtzypWFqJ0sqai/2+0
++bqbMcjX5maT8stT2shl3zXe/Ejt2e3TBYpc1tyuses8Kb5BMU8hu6tTd3G2CMXpD
++dT6DVemJZCTtwj9aBNIxSizvlgMolJnCpzhPnlfHSI6E+g3m/LTTo3HwbjMSw/Uq
++irgjOpI2wSBB6LZPSgjvfcYPRyWUk16L4A5uSX0cADnovDFLa5/h0wJvN/OoCSQg
++rLCXG5E18EyL5Wc58BCY1ZvxmjG3lQtgPxYu2Jwc36R/y/JKlxW5suER5ZNpbbD4
++uOyTt2VxMQ2bAoIBAQC5+MzRFqdo/AjfL5Y5JrbfVTzXCTDa09xCGd16ZU60QTWN
+++4ed/r+o1sUKqUcRFB2MzEM/2DQBjQpZB/CbEWvWa1XJWXxypXbowveZU+QqOnmN
++uQvj8WLyA3o+PNF9e9QvauwCrHpn8VpxbtPWuaYoKnUFreFZZQxHhPGxRBIS2JOZ
++eDrT8ZaWnkCkh1AZp5smQ71LOprSlmKrg4jd1GjCVMxQR5N5KXbtyv0OTCZ/UFqK
++2aRBsMPyJgkaBChkZPLRcKwc+/wlQRx1fHQb14DNTApMxoXFO7eOwqmOkpAt9iyl
++SBIwoS0UUI5ab88+bBmXNvKcuFdNuQ4nowTJUn9pAoIBADMNkILBXSvS5DeIyuO2
++Sp1tkoZUV+5NfPY3sMDK3KIibaW/+t+EOBZo4L7tKQCb8vRzl21mmsfxfgRaPDbj
++3r3tv9g0b4YLxxBy52pFscj/soXRai17SS7UZwA2QK+XzgDYbDcLNC6mIsTQG4Gx
++dsWk3/zs3KuUSQaehmwrWK+fIUK38c1pLK8v7LoxrLkqxlHwZ04RthHw8KTthH7X
++Pnl1J0LF8CSeOyfWLSuPUfkT0GEzptnNHpEbaHfQM6R6eaGhVJPF6AZme4y6YYgg
++m2ihhSt1n0XVEWpHYWjxFy3mK2mz75unFC4LM+NEY2p2zuUQoCw7NjnY3QYrfCnx
++rRMCggEAXeXsMSLFjjyuoL7iKbAxo52HD/P0fBoy58LyRcwfNVr0lvYan4pYEx+o
++KijIh9K16PqXZXKMA9v003B+ulmF8bJ7SddCZ5NGvnFhUTDe4DdTKgp2RuwQ3Bsc
++3skPIDbhVETyOLCtys34USHrq8U/0DlGY3eLRfxw9GnbKxSBGa/KEu/qQLPNUo50
++7xHZDg7GKeC3kqNJeqKM9rkp0VzIGkEnaD9127LeNDmERDfftxJzFoC/THvUBLfU
++6Sus2ZYwRE8VFvKC30Q45t/c54X3IuhYvAuiCuTmyfE4ruyzyOwKzhUkeeLq1APX
++g0veFbyfzlJ0q8qzD/iffqqIa2ZSmQ==
++-----END PRIVATE KEY-----
+diff --git a/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp b/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
+index 7ba3715e13..752aa122f6 100644
+--- a/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
++++ b/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
+@@ -179,6 +179,7 @@ void tst_QAccessibilityLinux::initTestCase()
+     QVERIFY(!address.isEmpty());
+ 
+     m_window = new AccessibleTestWindow();
++    m_window->setObjectName("mainWindow"_L1);
+     m_window->show();
+ 
+     QVERIFY(QTest::qWaitForWindowExposed(m_window));
+@@ -236,8 +237,11 @@ bool hasState(QDBusInterface *interface, AtspiStateType state)
+ void tst_QAccessibilityLinux::testLabel()
+ {
+     QLabel *l = new QLabel(m_window);
++    l->setObjectName("theObjectName"_L1);
+     l->setText("Hello A11y");
+     m_window->addWidget(l);
++    auto a11yEmpty = new QLabel(m_window);
++    m_window->addWidget(l);
+ 
+     // Application
+     QCOMPARE(getParent(mainWindow), QLatin1String(ATSPI_DBUS_PATH_ROOT));
+@@ -249,6 +253,8 @@ void tst_QAccessibilityLinux::testLabel()
+     QCOMPARE(getChildren(labelInterface).count(), 0);
+     QCOMPARE(labelInterface->call(QDBus::Block, "GetRoleName").arguments().first().toString(), QLatin1String("label"));
+     QCOMPARE(labelInterface->call(QDBus::Block, "GetRole").arguments().first().toUInt(), 29u);
++    QCOMPARE(labelInterface->call(QDBus::Block, "GetAccessibleId").arguments().first().toString(),
++             QLatin1String("mainWindow.theObjectName"));
+     QCOMPARE(getParent(labelInterface), mainWindow->path());
+     QVERIFY(!hasState(labelInterface, ATSPI_STATE_EDITABLE));
+     QVERIFY(hasState(labelInterface, ATSPI_STATE_READ_ONLY));
+@@ -256,7 +262,12 @@ void tst_QAccessibilityLinux::testLabel()
+     l->setText("New text");
+     QCOMPARE(labelInterface->property("Name").toString(), l->text());
+ 
++    auto *a11yEmptyInterface = getInterface(children.at(1), "org.a11y.atspi.Accessible");
++    QCOMPARE(a11yEmptyInterface->call(QDBus::Block, "GetAccessibleId").arguments().first().toString(),
++             QLatin1String("mainWindow.QLabel"));
++
+     m_window->clearChildren();
++    delete a11yEmptyInterface;
+     delete labelInterface;
+ }
+ 
+diff --git a/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+index 76df61c892..6d6d65b791 100644
+--- a/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
++++ b/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2022 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the test suite of the Qt Toolkit.
+@@ -68,6 +68,8 @@ private slots:
+     void query_exec();
+     void execErrorRecovery_data() { generic_data(); }
+     void execErrorRecovery();
++    void prematureExec_data() { generic_data(); }
++    void prematureExec();
+     void first_data() { generic_data(); }
+     void first();
+     void next_data() { generic_data(); }
+@@ -2770,6 +2772,35 @@ void tst_QSqlQuery::execErrorRecovery()
+     QVERIFY_SQL( q, exec() );
+ }
+ 
++void tst_QSqlQuery::prematureExec()
++{
++    QFETCH(QString, dbName);
++    // We only want the engine name, for addDatabase():
++    int cut = dbName.indexOf(QChar('@'));
++    if (cut < 0)
++        QSKIP("Failed to parse database type out of name");
++    dbName.truncate(cut);
++    cut = dbName.indexOf(QChar('_'));
++    if (cut >= 0)
++        dbName = dbName.mid(cut + 1);
++
++    auto db = QSqlDatabase::addDatabase(dbName);
++    QSqlQuery q(db);
++
++    QTest::ignoreMessage(QtWarningMsg,
++                         "QSqlDatabasePrivate::removeDatabase: connection "
++                         "'qt_sql_default_connection' is still in use, all "
++                         "queries will cease to work.");
++    QTest::ignoreMessage(QtWarningMsg,
++                         "QSqlDatabasePrivate::addDatabase: duplicate connection name "
++                         "'qt_sql_default_connection', old connection removed.");
++    auto otherDb = QSqlDatabase::addDatabase(dbName);
++
++    QTest::ignoreMessage(QtWarningMsg, "QSqlQuery::exec: called before driver has been set up");
++    // QTBUG-100037: shouldn't crash !
++    QVERIFY(!q.exec("select stuff from TheVoid"));
++}
++
+ void tst_QSqlQuery::lastInsertId()
+ {
+     QFETCH( QString, dbName );
+diff --git a/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp b/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
+index 4aa3f8d60b..d2050a61aa 100644
+--- a/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
++++ b/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
+@@ -115,6 +115,10 @@ void tst_QAbstractItemModelTester::standardItemModelZeroColumns()
+     // QTBUG-92886
+     model.insertRows(0, 5);
+     model.removeRows(1, 2);
++
++    const QModelIndex parentIndex = model.index(0, 0);
++    model.insertRows(0, 5, parentIndex);
++    model.removeRows(1, 2, parentIndex);
+ }
+ 
+ void tst_QAbstractItemModelTester::testInsertThroughProxy()
+diff --git a/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json b/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
+index 12a4a22a19..ce518e78fb 100644
+--- a/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
++++ b/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
+@@ -668,50 +668,6 @@
+         "inputFile": "task192552.h",
+         "outputRevision": 67
+     },
+-    {
+-        "classes": [
+-            {
+-                "className": "InlineSlotsWithThrowDeclaration",
+-                "object": true,
+-                "qualifiedClassName": "InlineSlotsWithThrowDeclaration",
+-                "slots": [
+-                    {
+-                        "access": "public",
+-                        "name": "a",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "b",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "c",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "d",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "e",
+-                        "returnType": "void"
+-                    }
+-                ],
+-                "superClasses": [
+-                    {
+-                        "access": "public",
+-                        "name": "QObject"
+-                    }
+-                ]
+-            }
+-        ],
+-        "inputFile": "task189996.h",
+-        "outputRevision": 67
+-    },
+     {
+         "classes": [
+             {
+diff --git a/qtbase/tests/auto/tools/moc/moc.pro b/qtbase/tests/auto/tools/moc/moc.pro
+index c324b3a8cd..4aceb78dc0 100644
+--- a/qtbase/tests/auto/tools/moc/moc.pro
++++ b/qtbase/tests/auto/tools/moc/moc.pro
+@@ -15,7 +15,7 @@ cross_compile: DEFINES += MOC_CROSS_COMPILED
+ HEADERS += using-namespaces.h no-keywords.h task87883.h c-comments.h backslash-newlines.h oldstyle-casts.h \
+            slots-with-void-template.h qinvokable.h namespaced-flags.h trigraphs.h \
+            escapes-in-string-literals.h cstyle-enums.h qprivateslots.h gadgetwithnoenums.h \
+-           dir-in-include-path.h single_function_keyword.h task192552.h task189996.h \
++           dir-in-include-path.h single_function_keyword.h task192552.h \
+            task234909.h task240368.h pure-virtual-signals.h cxx11-enums.h \
+            cxx11-final-classes.h \
+            cxx11-explicit-override-control.h \
+diff --git a/qtbase/tests/auto/tools/moc/task189996.h b/qtbase/tests/auto/tools/moc/task189996.h
+deleted file mode 100644
+index f94a051b3a..0000000000
+--- a/qtbase/tests/auto/tools/moc/task189996.h
++++ /dev/null
+@@ -1,47 +0,0 @@
+-/****************************************************************************
+-**
+-** Copyright (C) 2016 The Qt Company Ltd.
+-** Contact: https://www.qt.io/licensing/
+-**
+-** This file is part of the test suite of the Qt Toolkit.
+-**
+-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+-** 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 General Public License Usage
+-** Alternatively, this file may be used under the terms of the GNU
+-** General Public License version 3 as published by the Free Software
+-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+-** 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-3.0.html.
+-**
+-** $QT_END_LICENSE$
+-**
+-****************************************************************************/
+-// inline functions can have throw declarations
+-
+-#ifndef TASK189996_H
+-#define TASK189996_H
+-
+-#include <QObject>
+-
+-class InlineSlotsWithThrowDeclaration : public QObject
+-{
+-    Q_OBJECT
+-
+-public slots:
+-    void a() throw() { }
+-    void b() const throw() { }
+-    void c() throw();
+-    void d() throw(int) { }
+-    void e() const throw(int,double) { }
+-};
+-
+-#endif
+diff --git a/qtbase/tests/auto/tools/moc/tst_moc.cpp b/qtbase/tests/auto/tools/moc/tst_moc.cpp
+index c716aead21..15dd9e41e5 100644
+--- a/qtbase/tests/auto/tools/moc/tst_moc.cpp
++++ b/qtbase/tests/auto/tools/moc/tst_moc.cpp
+@@ -631,7 +631,6 @@ public:
+ private slots:
+     void initTestCase();
+ 
+-    void slotWithException() throw(MyStruct);
+     void dontStripNamespaces();
+     void oldStyleCasts();
+     void warnOnExtraSignalSlotQualifiaction();
+@@ -673,7 +672,6 @@ private slots:
+     void templateGtGt();
+     void qprivateslots();
+     void qprivateproperties();
+-    void inlineSlotsWithThrowDeclaration();
+     void warnOnPropertyWithoutREAD();
+     void constructors();
+     void typenameWithUnsigned();
+@@ -784,12 +782,6 @@ void tst_Moc::initTestCase()
+ #endif
+ }
+ 
+-void tst_Moc::slotWithException() throw(MyStruct)
+-{
+-    // be happy
+-    QVERIFY(true);
+-}
+-
+ void tst_Moc::dontStripNamespaces()
+ {
+     Sender sender;
+@@ -824,7 +816,7 @@ void tst_Moc::oldStyleCasts()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-Wold-style-cast" << "-I" << "."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -894,7 +886,7 @@ void tst_Moc::inputFileNameWithDotsButNoExtension()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-I" << ".."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -1174,7 +1166,7 @@ void tst_Moc::ignoreOptionClashes()
+     QStringList gccArgs;
+     gccArgs << "-c" << "-x" << "c++" << "-I" << ".."
+          << "-I" << qtIncludePath << "-I" << includeDir << "-o" << "/dev/null"
+-         << "-fPIC" << "-std=c++11" <<  "-";
++         << "-fPIC" << "-std=c++1z" <<  "-";
+     proc.start("gcc", gccArgs);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -1593,21 +1585,6 @@ void tst_Moc::qprivateproperties()
+ 
+ }
+ 
+-#include "task189996.h"
+-
+-void InlineSlotsWithThrowDeclaration::c() throw() {}
+-
+-void tst_Moc::inlineSlotsWithThrowDeclaration()
+-{
+-    InlineSlotsWithThrowDeclaration tst;
+-    const QMetaObject *mobj = tst.metaObject();
+-    QVERIFY(mobj->indexOfSlot("a()") != -1);
+-    QVERIFY(mobj->indexOfSlot("b()") != -1);
+-    QVERIFY(mobj->indexOfSlot("c()") != -1);
+-    QVERIFY(mobj->indexOfSlot("d()") != -1);
+-    QVERIFY(mobj->indexOfSlot("e()") != -1);
+-}
+-
+ void tst_Moc::warnOnPropertyWithoutREAD()
+ {
+ #ifdef MOC_CROSS_COMPILED
+@@ -1869,7 +1846,7 @@ void tst_Moc::notifyError()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-I" << "."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+diff --git a/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+index c355ee9665..88c09de8e0 100644
+--- a/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
++++ b/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+@@ -251,6 +251,7 @@ private slots:
+     void testResetCachedSizeHint();
+     void statusTips();
+     void testRemovingColumnsViaLayoutChanged();
++    void testModelMovingColumns();
+ 
+ protected:
+     void setupTestData(bool use_reset_model = false);
+@@ -360,6 +361,12 @@ public:
+         endRemoveColumns();
+     }
+ 
++    void moveColumn(int from, int to)
++    {
++        beginMoveColumns(QModelIndex(), from, from, QModelIndex(), to);
++        endMoveColumns();
++    }
++
+     void cleanup()
+     {
+         emit layoutAboutToBeChanged();
+@@ -3627,5 +3634,18 @@ void tst_QHeaderView::testRemovingColumnsViaLayoutChanged()
+     // The main point of this test is that the section-size restoring code didn't go out of bounds.
+ }
+ 
++void tst_QHeaderView::testModelMovingColumns()
++{
++    QtTestModel model(10, 10);
++    QHeaderView hv(Qt::Horizontal);
++    hv.setModel(&model);
++    hv.resizeSections(QHeaderView::ResizeToContents);
++    hv.show();
++
++    QPersistentModelIndex index3 = model.index(0, 3);
++    model.moveColumn(3, 1);
++    QCOMPARE(index3.column(), 1);
++}
++
+ QTEST_MAIN(tst_QHeaderView)
+ #include "tst_qheaderview.moc"
+diff --git a/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+index 761357b252..06bb706074 100644
+--- a/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
++++ b/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+@@ -397,6 +397,7 @@ private slots:
+     void checkHeaderMinSize();
+ 
+     void resizeToContents();
++    void resizeToContentsSpans();
+ 
+     void tabFocus();
+     void bigModel();
+@@ -3721,6 +3722,70 @@ void tst_QTableView::resizeToContents()
+ 
+ }
+ 
++
++class SpanModel : public QAbstractTableModel
++{
++public:
++    SpanModel(bool sectionsMoved)
++        : _sectionsMoved(sectionsMoved)
++    {}
++    int columnCount(const QModelIndex & = {}) const override { return 2; }
++    int rowCount(const QModelIndex & = {}) const override { return 1; }
++    QVariant data(const QModelIndex &idx, int role = Qt::DisplayRole) const override
++    {
++        if (role != Qt::DisplayRole)
++            return QVariant();
++        const int col = _sectionsMoved ? 1 - idx.column() : idx.column();
++        if (col == 0)
++            return "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.";
++        return QVariant();
++    }
++private:
++    bool _sectionsMoved;
++};
++
++
++void tst_QTableView::resizeToContentsSpans()
++{
++    SpanModel model1(false);
++    SpanModel model2(true);
++    QTableView view1, view2, view3;
++    view1.setModel(&model1);
++    view2.setModel(&model2);
++    view2.horizontalHeader()->moveSection(0, 1);
++    view3.setModel(&model1);
++
++    view1.setSpan(0, 0, 1, 2);
++    view2.setSpan(0, 1, 1, 2);
++    view1.show();
++    view2.show();
++    view3.show();
++    QVERIFY(QTest::qWaitForWindowExposed(&view1));
++    QVERIFY(QTest::qWaitForWindowExposed(&view2));
++    QVERIFY(QTest::qWaitForWindowExposed(&view3));
++    view1.setColumnWidth(0, 100);
++    view1.setColumnWidth(1, 100);
++    view2.setColumnWidth(0, 100);
++    view2.setColumnWidth(1, 100);
++    view3.setColumnWidth(0, 200);
++
++    view1.resizeRowToContents(0);
++    view2.resizeRowToContents(0);
++    view3.resizeRowToContents(0);
++    QCOMPARE(view1.rowHeight(0), view3.rowHeight(0));
++    QCOMPARE(view2.rowHeight(0), view3.rowHeight(0));
++
++    view3.resizeColumnToContents(0);
++    view3.resizeRowToContents(0);
++    // height should be only 1 text line for easy testing
++    view1.setRowHeight(0, view3.verticalHeader()->sectionSize(0));
++    view2.setRowHeight(0, view3.verticalHeader()->sectionSize(0));
++    view1.resizeColumnToContents(0);
++    view2.resizeColumnToContents(1);
++    QCOMPARE(view1.columnWidth(0), view3.columnWidth(0) - view1.columnWidth(1));
++    QCOMPARE(view2.columnWidth(0), view3.columnWidth(0) - view2.columnWidth(1));
++}
++
+ QT_BEGIN_NAMESPACE
+ extern bool Q_WIDGETS_EXPORT qt_tab_all_widgets(); // qapplication.cpp
+ QT_END_NAMESPACE
+diff --git a/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+index a3b8ef78d8..4955cebd5d 100644
+--- a/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
++++ b/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+@@ -1498,7 +1498,7 @@ void tst_QApplication::desktopSettingsAware()
+     environment += QLatin1String("QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM=1");
+     testProcess.setEnvironment(environment);
+ #endif
+-    testProcess.start("desktopsettingsaware_helper");
++    testProcess.start("./desktopsettingsaware_helper");
+     QVERIFY2(testProcess.waitForStarted(),
+              qPrintable(QString::fromLatin1("Cannot start 'desktopsettingsaware_helper': %1").arg(testProcess.errorString())));
+     QVERIFY(testProcess.waitForFinished(10000));
+@@ -2452,7 +2452,7 @@ void tst_QApplication::qtbug_12673()
+ #if QT_CONFIG(process)
+     QProcess testProcess;
+     QStringList arguments;
+-    testProcess.start("modal_helper", arguments);
++    testProcess.start("./modal_helper", arguments);
+     QVERIFY2(testProcess.waitForStarted(),
+              qPrintable(QString::fromLatin1("Cannot start 'modal_helper': %1").arg(testProcess.errorString())));
+     QVERIFY(testProcess.waitForFinished(20000));
+diff --git a/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp b/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
+index eb108a40de..dca5528c1b 100644
+--- a/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
+@@ -41,6 +41,7 @@
+ 
+ #include <private/qguiapplication_p.h>
+ #include <qpa/qplatformintegration.h>
++#include <qpa/qplatformtheme.h>
+ 
+ class tst_QAbstractButton : public QObject
+ {
+@@ -76,6 +77,8 @@ private slots:
+     void keyNavigation();
+ #endif
+ 
++    void buttonPressKeys();
++
+ protected slots:
+     void onClicked();
+     void onToggled( bool on );
+@@ -269,7 +272,13 @@ void tst_QAbstractButton::setAutoRepeat()
+         QCOMPARE(press_count, click_count);
+         QVERIFY(click_count > 1);
+         break;
+-    case 4:
++    case 4: {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(Qt::Key_Enter)) {
++            QSKIP("platform theme has Key_Enter in ButtonPressKeys");
++        }
+         // check that pressing ENTER has no effect when autorepeat is false
+         testWidget->setDown( false );
+         testWidget->setAutoRepeat( false );
+@@ -286,7 +295,14 @@ void tst_QAbstractButton::setAutoRepeat()
+ 
+         QVERIFY( click_count == 0 );
+         break;
+-    case 5:
++    }
++    case 5: {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(Qt::Key_Enter)) {
++            QSKIP("platform theme has Key_Enter in ButtonPressKeys");
++        }
+         // check that pressing ENTER has no effect when autorepeat is true
+         testWidget->setDown( false );
+         testWidget->setAutoRepeat( true );
+@@ -304,6 +320,7 @@ void tst_QAbstractButton::setAutoRepeat()
+ 
+         QVERIFY( click_count == 0 );
+         break;
++    }
+     case 6:
+         // verify autorepeat is off by default.
+         MyButton tmp( 0);
+@@ -651,5 +668,16 @@ void tst_QAbstractButton::keyNavigation()
+ }
+ #endif
+ 
++void tst_QAbstractButton::buttonPressKeys()
++{
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(testWidget, buttonPressKeys[i]);
++        QCOMPARE(click_count, i + 1);
++    }
++}
++
+ QTEST_MAIN(tst_QAbstractButton)
+ #include "tst_qabstractbutton.moc"
+diff --git a/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+index 32437050f5..46b5af6d63 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+@@ -168,6 +168,7 @@ private slots:
+     void checkMenuItemPosWhenStyleSheetIsSet();
+     void checkEmbeddedLineEditWhenStyleSheetIsSet();
+     void propagateStyleChanges();
++    void buttonPressKeys();
+ 
+ private:
+     PlatformInputContext m_platformInputContext;
+@@ -1682,6 +1683,16 @@ void tst_QComboBox::setModel()
+     QCOMPARE(box.rootModelIndex(), rootModelIndex);
+     box.setModel(box.model());
+     QCOMPARE(box.rootModelIndex(), rootModelIndex);
++
++    // check that setting the same model as the completer's doesn't crash
++    QCompleter *completer = new QCompleter(&box);
++    box.setEditable(true);
++    box.setCompleter(completer);
++    auto *listModel = new QStringListModel({ "one", "two" }, completer);
++    completer->setModel(listModel);
++    QCOMPARE(listModel->rowCount(), 2); // make sure it wasn't deleted
++    box.setModel(listModel);
++    QCOMPARE(listModel->rowCount(), 2); // make sure it wasn't deleted
+ }
+ 
+ void tst_QComboBox::setCustomModelAndView()
+@@ -3632,5 +3643,24 @@ void tst_QComboBox::propagateStyleChanges()
+     QVERIFY(frameStyle.inquired);
+ }
+ 
++void tst_QComboBox::buttonPressKeys()
++{
++    QComboBox comboBox;
++    comboBox.setEditable(false);
++    comboBox.addItem(QString::number(1));
++    comboBox.addItem(QString::number(2));
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(&comboBox, buttonPressKeys[i]);
++        // On some platforms, a window will not be immediately visible,
++        // but take some event-loop iterations to complete.
++        // Using QTRY_VERIFY to deal with that.
++        QTRY_VERIFY(comboBox.view()->isVisible());
++        comboBox.hidePopup();
++    }
++}
++
+ QTEST_MAIN(tst_QComboBox)
+ #include "tst_qcombobox.moc"
+diff --git a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
+index be3cfcd104..c228fdfcca 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
++++ b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qcommandlinkbutton
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qcommandlinkbutton.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
+index 0044d33c66..4cf06296e4 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
+@@ -40,6 +40,9 @@
+ #include <QGridLayout>
+ #include <QPainter>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ class tst_QCommandLinkButton : public QObject
+ {
+     Q_OBJECT
+@@ -223,6 +226,13 @@ void tst_QCommandLinkButton::setAutoRepeat()
+     // check that pressing ENTER has no effect
+     resetCounters();
+     testWidget->setDown( false );
++    // Skip after reset if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
+     testWidget->setAutoRepeat( false );
+     QTest::keyPress( testWidget, Qt::Key_Enter );
+ 
+@@ -255,6 +265,14 @@ void tst_QCommandLinkButton::pressed()
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+ 
++    // Skip if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
++
+     QTest::keyPress( testWidget,Qt::Key_Enter );
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+diff --git a/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro b/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
+index 4a5e76ff65..a235fa1fac 100644
+--- a/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
++++ b/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qgroupbox
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qgroupbox.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp b/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
+index 4fb5d262ca..d8d7562b73 100644
+--- a/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
+@@ -35,6 +35,9 @@
+ #include <QRadioButton>
+ #include <QDialog>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ #include "qgroupbox.h"
+ 
+ class tst_QGroupBox : public QObject
+@@ -69,6 +72,7 @@ private slots:
+     void propagateFocus();
+     void task_QTBUG_19170_ignoreMouseReleaseEvent();
+     void task_QTBUG_15519_propagateMouseEvents();
++    void buttonPressKeys();
+ 
+ private:
+     bool checked;
+@@ -610,6 +614,20 @@ void tst_QGroupBox::task_QTBUG_15519_propagateMouseEvents()
+     QCOMPARE(parent.mouseMoved, true);
+ }
+ 
++void tst_QGroupBox::buttonPressKeys()
++{
++    QGroupBox groupBox;
++    groupBox.setCheckable(true);
++    QSignalSpy clickedSpy(&groupBox, &QGroupBox::clicked);
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(&groupBox, buttonPressKeys[i]);
++        QCOMPARE(clickedSpy.length(), i + 1);
++    }
++}
++
+ void tst_QGroupBox::sendMouseMoveEvent(QWidget *widget, const QPoint &localPos)
+ {
+     // Send a MouseMove event without actually moving the pointer
+diff --git a/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro b/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
+index 353ad06ca2..e55f6148f2 100644
+--- a/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
++++ b/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qpushbutton
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qpushbutton.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp b/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
+index e818514a79..4043e9326a 100644
+--- a/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
+@@ -41,6 +41,9 @@
+ #include <QStyleFactory>
+ #include <QTabWidget>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ class tst_QPushButton : public QObject
+ {
+ Q_OBJECT
+@@ -212,6 +215,13 @@ void tst_QPushButton::autoRepeat()
+     // check that pressing ENTER has no effect
+     resetCounters();
+     testWidget->setDown( false );
++    // Skip after reset if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
+     testWidget->setAutoRepeat( false );
+     QTest::keyPress( testWidget, Qt::Key_Enter );
+ 
+@@ -247,6 +257,14 @@ void tst_QPushButton::pressed()
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+ 
++    // Skip if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
++
+     QTest::keyPress( testWidget,Qt::Key_Enter );
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+diff --git a/qtbase/tests/manual/rhi/cubemap_render/buildshader.bat b/qtbase/tests/manual/rhi/cubemap_render/buildshader.bat
+old mode 100755
+new mode 100644
+Submodule qtconnectivity e957d481..056294c0:
+diff --git a/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp b/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
+index e2635fae..a8b8e3b9 100644
+--- a/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
++++ b/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
+@@ -563,9 +563,11 @@ void HciManager::handleHciAclPacket(const quint8 *data, int size)
+ 
+ void HciManager::handleLeMetaEvent(const quint8 *data)
+ {
+-    // Spec v4.2, Vol 2, part E, 7.7.65ff
++    // Spec v5.3, Vol 4, part E, 7.7.65.*
+     switch (*data) {
+-    case 0x1: {
++    case 0x1: // HCI_LE_Connection_Complete
++    case 0xA: // HCI_LE_Enhanced_Connection_Complete
++    {
+         const quint16 handle = bt_get_le16(data + 2);
+         emit connectionComplete(handle);
+         break;
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp b/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
+index 6a93143b..4a18cfc7 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
+@@ -320,7 +320,10 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_finishSdpScan(QBluetoothServiceD
+             for (const QBluetoothUuid &id : serviceClassUuids) {
+                 if (id.minimumSize() == 16) {
+                     serviceInfo.setServiceUuid(id);
+-                    serviceInfo.setServiceName(QBluetoothServiceDiscoveryAgent::tr("Custom Service"));
++                    if (serviceInfo.serviceName().isEmpty()) {
++                        serviceInfo.setServiceName(
++                                    QBluetoothServiceDiscoveryAgent::tr("Custom Service"));
++                    }
+                     QBluetoothServiceInfo::Sequence modSeq =
+                             serviceInfo.attribute(QBluetoothServiceInfo::ServiceClassIds).value<QBluetoothServiceInfo::Sequence>();
+                     modSeq.removeOne(QVariant::fromValue(id));
+@@ -334,8 +337,10 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_finishSdpScan(QBluetoothServiceD
+                 qCDebug(QT_BT_BLUEZ) << "Discovered services" << discoveredDevices.at(0).address().toString()
+                                      << serviceInfo.serviceName() << serviceInfo.serviceUuid()
+                                      << ">>>" << serviceInfo.serviceClassUuids();
+-
+-                emit q->serviceDiscovered(serviceInfo);
++                // Use queued connection to allow us finish the service looping; the application
++                // might call stop() when it has detected the service-of-interest.
++                QMetaObject::invokeMethod(q, "serviceDiscovered", Qt::QueuedConnection,
++                                          Q_ARG(QBluetoothServiceInfo, serviceInfo));
+             }
+         }
+     }
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp b/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
+index e4d85447..aadd4755 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
+@@ -593,7 +593,7 @@ void QBluetoothSocket::setSocketState(QBluetoothSocket::SocketState state)
+ bool QBluetoothSocket::canReadLine() const
+ {
+     Q_D(const QBluetoothSocketBase);
+-    return d->canReadLine();
++    return d->canReadLine() || QIODevice::canReadLine();
+ }
+ 
+ /*!
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp b/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
+index 084aa958..d6aa17a7 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
+@@ -284,6 +284,10 @@ void QBluetoothSocketPrivateBluezDBus::connectToService(
+         return;
+     }
+ 
++    if (service.socketProtocol() != QBluetoothServiceInfo::Protocol::UnknownProtocol)
++        socketType = service.socketProtocol();
++    qCDebug(QT_BT_BLUEZ) << "Socket protocol used:" << socketType;
++
+     connectToService(service.device().address(), targetService, openMode);
+ }
+ 
+diff --git a/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp b/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
+index 05bc1a0f..a7b5ef1f 100644
+--- a/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
++++ b/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
+@@ -142,7 +142,7 @@ void tst_QBluetoothSocket::initTestCase()
+     qDebug() << "Starting discovery";
+ 
+     sda->setUuidFilter(QBluetoothUuid(QString(TEST_SERVICE_UUID)));
+-    sda->start(QBluetoothServiceDiscoveryAgent::MinimalDiscovery);
++    sda->start(QBluetoothServiceDiscoveryAgent::FullDiscovery);
+ 
+     for (int connectTime = MaxConnectTime; !done_discovery && connectTime > 0; connectTime -= 1000)
+         QTest::qWait(1000);
+Submodule qtdeclarative f5701f0d..8defe7bf:
+diff --git a/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h b/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
+index b65b994d6c..15a8cd6878 100644
+--- a/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
++++ b/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
+@@ -86,7 +86,7 @@ public:
+         if (QTypeInfo<T>::isComplex) {
+             for (int i = 0; i < count; ++i)
+                 new (data + i) T(vector.at(i));
+-        } else {
++        } else if (count) {
+             memcpy(data, static_cast<const void*>(vector.constData()), count * sizeof(T));
+         }
+     }
+diff --git a/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp b/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
+index e57cdd8278..94613598af 100644
+--- a/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
++++ b/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
+@@ -1145,8 +1145,7 @@ void Heap::QObjectWrapper::markObjects(Heap::Base *that, QV4::MarkStack *markSta
+ void QObjectWrapper::destroyObject(bool lastCall)
+ {
+     Heap::QObjectWrapper *h = d();
+-    if (!h->internalClass)
+-        return; // destroyObject already got called
++    Q_ASSERT(h->internalClass);
+ 
+     if (h->object()) {
+         QQmlData *ddata = QQmlData::get(h->object(), false);
+@@ -1176,7 +1175,7 @@ void QObjectWrapper::destroyObject(bool lastCall)
+         }
+     }
+ 
+-    h->~Data();
++    h->destroy();
+ }
+ 
+ 
+diff --git a/qtdeclarative/src/qml/memory/qv4mm.cpp b/qtdeclarative/src/qml/memory/qv4mm.cpp
+index 06caf04e5a..da149a67c4 100644
+--- a/qtdeclarative/src/qml/memory/qv4mm.cpp
++++ b/qtdeclarative/src/qml/memory/qv4mm.cpp
+@@ -981,7 +981,7 @@ void MemoryManager::sweep(bool lastSweep, ClassDestroyStatsCallback classCountPt
+ 
+     if (MultiplyWrappedQObjectMap *multiplyWrappedQObjects = engine->m_multiplyWrappedQObjects) {
+         for (MultiplyWrappedQObjectMap::Iterator it = multiplyWrappedQObjects->begin(); it != multiplyWrappedQObjects->end();) {
+-            if (!it.value().isNullOrUndefined())
++            if (it.value().isNullOrUndefined())
+                 it = multiplyWrappedQObjects->erase(it);
+             else
+                 ++it;
+diff --git a/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp b/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
+index 2079a8ed04..a577cb2351 100644
+--- a/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
++++ b/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
+@@ -389,6 +389,12 @@ void QQmlDelegateModelPrivate::connectToAbstractItemModel()
+                       q,  QQmlDelegateModel, SLOT(_q_rowsRemoved(QModelIndex,int,int)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
+                       q,  QQmlDelegateModel, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsInserted(QModelIndex,int,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsInserted(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsRemoved(QModelIndex,int,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsRemoved(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsMoved(QModelIndex,int,int,QModelIndex,int)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
+                       q, QQmlDelegateModel, SLOT(_q_dataChanged(QModelIndex,QModelIndex,QVector<int>)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
+@@ -413,6 +419,12 @@ void QQmlDelegateModelPrivate::disconnectFromAbstractItemModel()
+                         q, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int)));
+     QObject::disconnect(aim, SIGNAL(rowsRemoved(QModelIndex,int,int)),
+                         q, SLOT(_q_rowsRemoved(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsInserted(QModelIndex,int,int)), q,
++                        SLOT(_q_columnsInserted(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsRemoved(QModelIndex,int,int)), q,
++                        SLOT(_q_columnsRemoved(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)), q,
++                        SLOT(_q_columnsMoved(QModelIndex,int,int,QModelIndex,int)));
+     QObject::disconnect(aim, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
+                         q, SLOT(_q_dataChanged(QModelIndex,QModelIndex,QVector<int>)));
+     QObject::disconnect(aim, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
+@@ -1973,6 +1985,38 @@ void QQmlDelegateModel::_q_rowsMoved(
+     }
+ }
+ 
++void QQmlDelegateModel::_q_columnsInserted(const QModelIndex &parent, int begin, int end)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if (parent == d->m_adaptorModel.rootIndex && begin == 0) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
++void QQmlDelegateModel::_q_columnsRemoved(const QModelIndex &parent, int begin, int end)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if (parent == d->m_adaptorModel.rootIndex && begin == 0) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
++void QQmlDelegateModel::_q_columnsMoved(const QModelIndex &parent, int start, int end,
++                                        const QModelIndex &destination, int column)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if ((parent == d->m_adaptorModel.rootIndex && start == 0)
++        || (destination == d->m_adaptorModel.rootIndex && column == 0)) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
+ void QQmlDelegateModel::_q_dataChanged(const QModelIndex &begin, const QModelIndex &end, const QVector<int> &roles)
+ {
+     Q_D(QQmlDelegateModel);
+diff --git a/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h b/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
+index 8aab4badca..d140bfbaaf 100644
+--- a/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
++++ b/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
+@@ -152,6 +152,9 @@ private Q_SLOTS:
+     void _q_itemsMoved(int from, int to, int count);
+     void _q_modelReset();
+     void _q_rowsInserted(const QModelIndex &,int,int);
++    void _q_columnsInserted(const QModelIndex &, int, int);
++    void _q_columnsRemoved(const QModelIndex &, int, int);
++    void _q_columnsMoved(const QModelIndex &, int, int, const QModelIndex &, int);
+     void _q_rowsAboutToBeRemoved(const QModelIndex &parent, int begin, int end);
+     void _q_rowsRemoved(const QModelIndex &,int,int);
+     void _q_rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int);
+diff --git a/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp b/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
+index 85719fdc80..78e2ab302c 100644
+--- a/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
++++ b/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
+@@ -46,6 +46,7 @@
+ #include "QtQuick/private/qquicktextinput_p.h"
+ #include "QtQuick/private/qquickaccessibleattached_p.h"
+ #include "QtQuick/qquicktextdocument.h"
++#include "QtQuick/qquickrendercontrol.h"
+ QT_BEGIN_NAMESPACE
+ 
+ #if QT_CONFIG(accessibility)
+@@ -57,7 +58,19 @@ QAccessibleQuickItem::QAccessibleQuickItem(QQuickItem *item)
+ 
+ QWindow *QAccessibleQuickItem::window() const
+ {
+-    return item()->window();
++    QQuickWindow *window = item()->window();
++
++    // For QQuickWidget the above window will be the offscreen QQuickWindow,
++    // which is not a part of the accessibility tree. Detect this case and
++    // return the window for the QQuickWidget instead.
++    if (window && !window->handle()) {
++        if (QQuickRenderControl *renderControl = QQuickWindowPrivate::get(window)->renderControl) {
++            if (QWindow *renderWindow = renderControl->renderWindow(nullptr))
++                return renderWindow;
++        }
++    }
++
++    return window;
+ }
+ 
+ int QAccessibleQuickItem::childCount() const
+@@ -113,19 +126,15 @@ QAccessibleInterface *QAccessibleQuickItem::childAt(int x, int y) const
+ QAccessibleInterface *QAccessibleQuickItem::parent() const
+ {
+     QQuickItem *parent = item()->parentItem();
+-    QQuickWindow *window = item()->window();
+-    QQuickItem *ci = window ? window->contentItem() : nullptr;
++    QQuickWindow *itemWindow = item()->window();
++    QQuickItem *ci = itemWindow ? itemWindow->contentItem() : nullptr;
+     while (parent && !QQuickItemPrivate::get(parent)->isAccessible && parent != ci)
+         parent = parent->parentItem();
+ 
+     if (parent) {
+         if (parent == ci) {
+-            // Jump out to the scene widget if the parent is the root item.
+-            // There are two root items, QQuickWindow::rootItem and
+-            // QQuickView::declarativeRoot. The former is the true root item,
+-            // but is not a part of the accessibility tree. Check if we hit
+-            // it here and return an interface for the scene instead.
+-            return QAccessible::queryAccessibleInterface(window);
++            // Jump out to the window if the parent is the root item
++            return QAccessible::queryAccessibleInterface(window());
+         } else {
+             while (parent && !parent->d_func()->isAccessible)
+                 parent = parent->parentItem();
+@@ -188,7 +197,7 @@ QAccessible::State QAccessibleQuickItem::state() const
+     QRect viewRect_ = viewRect();
+     QRect itemRect = rect();
+ 
+-    if (viewRect_.isNull() || itemRect.isNull() || !item()->window() || !item()->window()->isVisible() ||!item()->isVisible() || qFuzzyIsNull(item()->opacity()))
++    if (viewRect_.isNull() || itemRect.isNull() || !window() || !window()->isVisible() ||!item()->isVisible() || qFuzzyIsNull(item()->opacity()))
+         state.invisible = true;
+     if (!viewRect_.intersects(itemRect))
+         state.offscreen = true;
+@@ -201,6 +210,10 @@ QAccessible::State QAccessibleQuickItem::state() const
+     if (role() == QAccessible::EditableText)
+         if (auto ti = qobject_cast<QQuickTextInput *>(item()))
+             state.passwordEdit = ti->echoMode() != QQuickTextInput::Normal;
++    if (!item()->isEnabled()) {
++        state.focusable = false;
++        state.disabled = true;
++    }
+     return state;
+ }
+ 
+diff --git a/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h b/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
+index 39ffcaf39c..8baa01330c 100644
+--- a/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
++++ b/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
+@@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE
+ 
+ #if QT_CONFIG(accessibility)
+ 
+-class QAccessibleQuickWindow : public QAccessibleObject
++class Q_QUICK_EXPORT QAccessibleQuickWindow : public QAccessibleObject
+ {
+ public:
+     QAccessibleQuickWindow(QQuickWindow *object);
+diff --git a/qtdeclarative/src/quick/items/qquickdrag.cpp b/qtdeclarative/src/quick/items/qquickdrag.cpp
+index 8321fcfeed..383078b3b9 100644
+--- a/qtdeclarative/src/quick/items/qquickdrag.cpp
++++ b/qtdeclarative/src/quick/items/qquickdrag.cpp
+@@ -481,7 +481,9 @@ void QQuickDragAttached::setKeys(const QStringList &keys)
+     \qmlattachedproperty stringlist QtQuick::Drag::mimeData
+     \since 5.2
+ 
+-    This property holds a map of mimeData that is used during startDrag.
++    This property holds a map from mime type to data that is used during startDrag.
++    The mime data needs to be a \c string, or an \c ArrayBuffer with the data encoded
++    according to the mime type.
+ */
+ 
+ QVariantMap QQuickDragAttached::mimeData() const
+@@ -766,8 +768,12 @@ Qt::DropAction QQuickDragAttachedPrivate::startDrag(Qt::DropActions supportedAct
+     QDrag *drag = new QDrag(source ? source : q);
+     QMimeData *mimeData = new QMimeData();
+ 
+-    for (auto it = externalMimeData.cbegin(), end = externalMimeData.cend(); it != end; ++it)
+-        mimeData->setData(it.key(), it.value().toString().toUtf8());
++    for (auto it = externalMimeData.cbegin(), end = externalMimeData.cend(); it != end; ++it) {
++        if (static_cast<QMetaType::Type>(it.value().type()) == QMetaType::QByteArray)
++            mimeData->setData(it.key(), it.value().toByteArray());
++        else
++            mimeData->setData(it.key(), it.value().toString().toUtf8());
++    }
+ 
+     drag->setMimeData(mimeData);
+     if (pixmapLoader.isReady()) {
+diff --git a/qtdeclarative/src/quick/items/qquickitem.cpp b/qtdeclarative/src/quick/items/qquickitem.cpp
+index 75f1457816..dec0ae19ae 100644
+--- a/qtdeclarative/src/quick/items/qquickitem.cpp
++++ b/qtdeclarative/src/quick/items/qquickitem.cpp
+@@ -59,6 +59,7 @@
+ #include <QtCore/private/qnumeric_p.h>
+ #include <QtGui/qpa/qplatformtheme.h>
+ #include <QtCore/qloggingcategory.h>
++#include <QtCore/private/qduplicatetracker_p.h>
+ 
+ #include <private/qqmlglobal_p.h>
+ #include <private/qqmlengine_p.h>
+@@ -2326,6 +2327,7 @@ QQuickItem::QQuickItem(QQuickItemPrivate &dd, QQuickItem *parent)
+ QQuickItem::~QQuickItem()
+ {
+     Q_D(QQuickItem);
++    d->inDestructor = true;
+ 
+     if (d->windowRefCount > 1)
+         d->windowRefCount = 1; // Make sure window is set to null in next call to derefWindow().
+@@ -2526,6 +2528,7 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo
+     QQuickItem *current = item;
+     qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: startItem:" << startItem;
+     qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: firstFromItem:" << firstFromItem;
++    QDuplicateTracker<QQuickItem *> cycleDetector;
+     do {
+         qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: current:" << current;
+         qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: from:" << from;
+@@ -2592,7 +2595,10 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo
+         // traversed all of the chain (by compare the [current] item with [startItem])
+         // Since the [startItem] might be promoted to its parent if it is invisible,
+         // we still have to check [current] item with original start item
+-        if ((current == startItem || current == originalStartItem) && from == firstFromItem) {
++        // We might also run into a cycle before we reach firstFromItem again
++        // but note that we have to ignore current if we are meant to skip it
++        if (((current == startItem || current == originalStartItem) && from == firstFromItem) ||
++                (!skip && cycleDetector.hasSeen(current))) {
+             // wrapped around, avoid endless loops
+             if (item == contentItem) {
+                 qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: looped, return contentItem";
+@@ -2689,9 +2695,8 @@ void QQuickItem::setParentItem(QQuickItem *parentItem)
+ 
+         const bool wasVisible = isVisible();
+         op->removeChild(this);
+-        if (wasVisible) {
++        if (wasVisible && !op->inDestructor)
+             emit oldParentItem->visibleChildrenChanged();
+-        }
+     } else if (d->window) {
+         QQuickWindowPrivate::get(d->window)->parentlessItems.remove(this);
+     }
+@@ -2768,8 +2773,9 @@ void QQuickItem::setParentItem(QQuickItem *parentItem)
+ 
+     d->itemChange(ItemParentHasChanged, d->parentItem);
+ 
+-    emit parentChanged(d->parentItem);
+-    if (isVisible() && d->parentItem)
++    if (!d->inDestructor)
++        emit parentChanged(d->parentItem);
++    if (isVisible() && d->parentItem && !QQuickItemPrivate::get(d->parentItem)->inDestructor)
+         emit d->parentItem->visibleChildrenChanged();
+ }
+ 
+@@ -2965,7 +2971,8 @@ void QQuickItemPrivate::removeChild(QQuickItem *child)
+ 
+     itemChange(QQuickItem::ItemChildRemovedChange, child);
+ 
+-    emit q->childrenChanged();
++    if (!inDestructor)
++        emit q->childrenChanged();
+ }
+ 
+ void QQuickItemPrivate::refWindow(QQuickWindow *c)
+@@ -3194,6 +3201,7 @@ QQuickItemPrivate::QQuickItemPrivate()
+     , touchEnabled(false)
+ #endif
+     , hasCursorHandler(false)
++    , inDestructor(false)
+     , dirtyAttributes(0)
+     , nextDirtyItem(nullptr)
+     , prevDirtyItem(nullptr)
+@@ -5120,6 +5128,13 @@ void QQuickItem::componentComplete()
+         d->addToDirtyList();
+         QQuickWindowPrivate::get(d->window)->dirtyItem(this);
+     }
++
++#if QT_CONFIG(accessibility)
++    if (d->isAccessible && d->effectiveVisible) {
++        QAccessibleEvent ev(this, QAccessible::ObjectShow);
++        QAccessible::updateAccessibility(&ev);
++    }
++#endif
+ }
+ 
+ QQuickStateGroup *QQuickItemPrivate::_states()
+@@ -6106,9 +6121,11 @@ bool QQuickItemPrivate::setEffectiveVisibleRecur(bool newEffectiveVisible)
+         QAccessible::updateAccessibility(&ev);
+     }
+ #endif
+-    emit q->visibleChanged();
+-    if (childVisibilityChanged)
+-        emit q->visibleChildrenChanged();
++    if (!inDestructor) {
++        emit q->visibleChanged();
++        if (childVisibilityChanged)
++            emit q->visibleChildrenChanged();
++    }
+ 
+     return true;    // effective visibility DID change
+ }
+@@ -6157,6 +6174,15 @@ void QQuickItemPrivate::setEffectiveEnableRecur(QQuickItem *scope, bool newEffec
+     }
+ 
+     itemChange(QQuickItem::ItemEnabledHasChanged, effectiveEnable);
++#if QT_CONFIG(accessibility)
++    if (isAccessible) {
++        QAccessible::State changedState;
++        changedState.disabled = true;
++        changedState.focusable = true;
++        QAccessibleStateChangeEvent ev(q, changedState);
++        QAccessible::updateAccessibility(&ev);
++    }
++#endif
+     emit q->enabledChanged();
+ }
+ 
+diff --git a/qtdeclarative/src/quick/items/qquickitem_p.h b/qtdeclarative/src/quick/items/qquickitem_p.h
+index 841d91bb40..ade8fb61f2 100644
+--- a/qtdeclarative/src/quick/items/qquickitem_p.h
++++ b/qtdeclarative/src/quick/items/qquickitem_p.h
+@@ -472,6 +472,7 @@ public:
+     bool replayingPressEvent:1;
+     bool touchEnabled:1;
+     bool hasCursorHandler:1;
++    quint32 inDestructor:1; // has entered ~QQuickItem
+ 
+     enum DirtyType {
+         TransformOrigin         = 0x00000001,
+diff --git a/qtdeclarative/src/quick/items/qquickitemview.cpp b/qtdeclarative/src/quick/items/qquickitemview.cpp
+index 010a0152e1..f8ad168a17 100644
+--- a/qtdeclarative/src/quick/items/qquickitemview.cpp
++++ b/qtdeclarative/src/quick/items/qquickitemview.cpp
+@@ -1785,7 +1785,7 @@ void QQuickItemViewPrivate::refill(qreal from, qreal to)
+ 
+     do {
+         bufferPause.stop();
+-        if (currentChanges.hasPendingChanges() || bufferedChanges.hasPendingChanges()) {
++        if (currentChanges.hasPendingChanges() || bufferedChanges.hasPendingChanges() || currentChanges.active) {
+             currentChanges.reset();
+             bufferedChanges.reset();
+             releaseVisibleItems(reusableFlag);
+diff --git a/qtdeclarative/src/quick/items/qquickmousearea_p_p.h b/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
+index fba383e268..0d63618622 100644
+--- a/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
++++ b/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
+@@ -61,7 +61,6 @@ QT_BEGIN_NAMESPACE
+ 
+ class QQuickMouseEvent;
+ class QQuickMouseArea;
+-class QQuickPointerMask;
+ class QQuickMouseAreaPrivate : public QQuickItemPrivate
+ {
+     Q_DECLARE_PUBLIC(QQuickMouseArea)
+@@ -100,7 +99,6 @@ public:
+ #if QT_CONFIG(quick_draganddrop)
+     QQuickDrag *drag;
+ #endif
+-    QPointer<QQuickPointerMask> mask;
+     QPointF startScene;
+     QPointF targetStartPos;
+     QPointF lastPos;
+diff --git a/qtdeclarative/src/quick/items/qquicktext.cpp b/qtdeclarative/src/quick/items/qquicktext.cpp
+index 6230186933..e823ca1095 100644
+--- a/qtdeclarative/src/quick/items/qquicktext.cpp
++++ b/qtdeclarative/src/quick/items/qquicktext.cpp
+@@ -2168,7 +2168,7 @@ void QQuickText::resetMaximumLineCount()
+     <img src="" align="top,middle,bottom" width="" height=""> - inline images
+     <ol type="">, <ul type=""> and <li> - ordered and unordered lists
+     <pre></pre> - preformatted
+-    &gt; &lt; &amp;
++    &gt; &lt; &amp; &quot; &nbsp; &apos;
+     \endcode
+ 
+     \c Text.StyledText parser is strict, requiring tags to be correctly nested.
+diff --git a/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp b/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
+index eb4db0f85e..2325a2665b 100644
+--- a/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
++++ b/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
+@@ -446,7 +446,7 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+         const char *textureRecord = allocatorData;
+         for (int i = 0; i < textureCount; ++i, textureRecord += Qtdf::TextureRecordSize) {
+-            if (textureRecord + Qtdf::TextureRecordSize > qtdfTableEnd) {
++            if (qtdfTableEnd - textureRecord < Qtdf::TextureRecordSize) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+@@ -462,7 +462,7 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+         const char *glyphRecord = textureRecord;
+         for (quint32 i = 0; i < glyphCount; ++i, glyphRecord += Qtdf::GlyphRecordSize) {
+-            if (glyphRecord + Qtdf::GlyphRecordSize > qtdfTableEnd) {
++            if (qtdfTableEnd - glyphRecord < Qtdf:: GlyphRecordSize) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+@@ -512,8 +512,8 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+             int width = texInfo->allocatedArea.width();
+             int height = texInfo->allocatedArea.height();
+-            qint64 size = width * height;
+-            if (reinterpret_cast<const char *>(textureData + size) > qtdfTableEnd) {
++            qint64 size = qint64(width) * height;
++            if (qtdfTableEnd - reinterpret_cast<const char *>(textureData) < size) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+diff --git a/qtdeclarative/src/quick/util/qquickstyledtext.cpp b/qtdeclarative/src/quick/util/qquickstyledtext.cpp
+index d531fc9205..a25af90414 100644
+--- a/qtdeclarative/src/quick/util/qquickstyledtext.cpp
++++ b/qtdeclarative/src/quick/util/qquickstyledtext.cpp
+@@ -564,6 +564,8 @@ void QQuickStyledTextPrivate::parseEntity(const QChar *&ch, const QString &textI
+                 textOut += QChar(60);
+             else if (entity == QLatin1String("amp"))
+                 textOut += QChar(38);
++            else if (entity == QLatin1String("apos"))
++                textOut += QChar(39);
+             else if (entity == QLatin1String("quot"))
+                 textOut += QChar(34);
+             else if (entity == QLatin1String("nbsp"))
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp
+new file mode 100644
+index 0000000000..8a1c901880
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp
+@@ -0,0 +1,110 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include "qaccessiblequickwidget_p.h"
++
++#include "qquickwidget_p.h"
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleQuickWidget::QAccessibleQuickWidget(QQuickWidget* widget)
++: QAccessibleWidget(widget)
++, m_accessibleWindow(QQuickWidgetPrivate::get(widget)->offscreenWindow)
++{
++    // NOTE: m_accessibleWindow is a QAccessibleQuickWindow, and not a
++    // QAccessibleQuickWidgetOffscreenWindow (defined below). This means
++    // it will return the Quick item child interfaces, which is what's needed here
++    // (unlike QAccessibleQuickWidgetOffscreenWindow, which will report 0 children).
++}
++
++QAccessibleInterface *QAccessibleQuickWidget::child(int index) const
++{
++    return m_accessibleWindow.child(index);
++}
++
++int QAccessibleQuickWidget::childCount() const
++{
++    return m_accessibleWindow.childCount();
++}
++
++int QAccessibleQuickWidget::indexOfChild(const QAccessibleInterface *iface) const
++{
++    return m_accessibleWindow.indexOfChild(iface);
++}
++
++QAccessibleInterface *QAccessibleQuickWidget::childAt(int x, int y) const
++{
++    return m_accessibleWindow.childAt(x, y);
++}
++
++QAccessibleQuickWidgetOffscreenWindow::QAccessibleQuickWidgetOffscreenWindow(QQuickWindow *window)
++:QAccessibleQuickWindow(window)
++{
++
++}
++
++QAccessibleInterface *QAccessibleQuickWidgetOffscreenWindow::child(int index) const
++{
++    Q_UNUSED(index);
++    return nullptr;
++}
++
++int QAccessibleQuickWidgetOffscreenWindow::childCount() const
++{
++    return 0;
++}
++
++int QAccessibleQuickWidgetOffscreenWindow::indexOfChild(const QAccessibleInterface *iface) const
++{
++    Q_UNUSED(iface);
++    return -1;
++}
++
++QAccessibleInterface *QAccessibleQuickWidgetOffscreenWindow::QAccessibleQuickWidgetOffscreenWindow::childAt(int x, int y) const
++{
++    Q_UNUSED(x);
++    Q_UNUSED(y);
++    return nullptr;
++}
++
++#endif // accessibility
++
++QT_END_NAMESPACE
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h
+new file mode 100644
+index 0000000000..7c2ab930e0
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h
+@@ -0,0 +1,95 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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 QACCESSIBLEQUICKWIDGET_H
++#define QACCESSIBLEQUICKWIDGET_H
++
++//
++//  W A R N I N G
++//  -------------
++//
++// This file is not part of the Qt API.  It exists purely as an
++// implementation detail.  This header file may change from version to
++// version without notice, or even be removed.
++//
++// We mean it.
++//
++
++#include "qquickwidget.h"
++#include <QtWidgets/qaccessiblewidget.h>
++
++#include <private/qaccessiblequickview_p.h>
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++// These classes implement the QQuickWiget accessibility switcharoo,
++// where the child items of the QQuickWidgetOffscreenWindow are reported
++// as child accessible interfaces of the QAccessibleQuickWidget.
++class QAccessibleQuickWidget: public QAccessibleWidget
++{
++public:
++    QAccessibleQuickWidget(QQuickWidget* widget);
++
++    QAccessibleInterface *child(int index) const override;
++    int childCount() const override;
++    int indexOfChild(const QAccessibleInterface *iface) const override;
++    QAccessibleInterface *childAt(int x, int y) const override;
++
++private:
++    QAccessibleQuickWindow m_accessibleWindow;
++    Q_DISABLE_COPY(QAccessibleQuickWidget)
++};
++
++class QAccessibleQuickWidgetOffscreenWindow: public QAccessibleQuickWindow
++{
++public:
++    QAccessibleQuickWidgetOffscreenWindow(QQuickWindow *window);
++    QAccessibleInterface *child(int index) const override;
++    int childCount() const override;
++    int indexOfChild(const QAccessibleInterface *iface) const override;
++    QAccessibleInterface *childAt(int x, int y) const override;
++};
++
++#endif // accessibility
++
++QT_END_NAMESPACE
++
++#endif
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp
+new file mode 100644
+index 0000000000..7ba88a1769
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp
+@@ -0,0 +1,60 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include "qaccessiblequickwidgetfactory_p.h"
++#include "qaccessiblequickwidget_p.h"
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleInterface *qAccessibleQuickWidgetFactory(const QString &classname, QObject *object)
++{
++    if (classname == QLatin1String("QQuickWidget")) {
++        return new QAccessibleQuickWidget(qobject_cast<QQuickWidget *>(object));
++    } else if (classname == QLatin1String("QQuickWidgetOffscreenWindow")) {
++        return new QAccessibleQuickWidgetOffscreenWindow(qobject_cast<QQuickWindow *>(object));
++    }
++    return 0;
++}
++
++#endif // accessibility
++
++QT_END_NAMESPACE
++
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h
+new file mode 100644
+index 0000000000..8c63b09f81
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h
+@@ -0,0 +1,66 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include <QtGui/qaccessible.h>
++
++#ifndef QACCESSIBLEQUICKWIDGETFACTORY_H
++#define QACCESSIBLEQUICKWIDGETFACTORY_H
++
++//
++//  W A R N I N G
++//  -------------
++//
++// This file is not part of the Qt API.  It exists purely as an
++// implementation detail.  This header file may change from version to
++// version without notice, or even be removed.
++//
++// We mean it.
++//
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleInterface *qAccessibleQuickWidgetFactory(const QString &classname, QObject *object);
++
++#endif
++
++QT_END_NAMESPACE
++
++#endif
+diff --git a/qtdeclarative/src/quickwidgets/qquickwidget.cpp b/qtdeclarative/src/quickwidgets/qquickwidget.cpp
+index 39780f8de3..9c97b43518 100644
+--- a/qtdeclarative/src/quickwidgets/qquickwidget.cpp
++++ b/qtdeclarative/src/quickwidgets/qquickwidget.cpp
+@@ -39,6 +39,7 @@
+ 
+ #include "qquickwidget.h"
+ #include "qquickwidget_p.h"
++#include "qaccessiblequickwidgetfactory_p.h"
+ 
+ #include "private/qquickwindow_p.h"
+ #include "private/qquickitem_p.h"
+@@ -75,9 +76,16 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++QQuickWidgetOffscreenWindow::QQuickWidgetOffscreenWindow(QQuickWindowPrivate &dd, QQuickRenderControl *control)
++:QQuickWindow(dd, control)
++{
++    setTitle(QString::fromLatin1("Offscreen"));
++    setObjectName(QString::fromLatin1("QQuickOffScreenWindow"));
++}
++
+ // override setVisble to prevent accidental offscreen window being created
+ // by base class.
+-class QQuickOffcreenWindowPrivate: public QQuickWindowPrivate {
++class QQuickWidgetOffscreenWindowPrivate: public QQuickWindowPrivate {
+ public:
+     void setVisible(bool visible) override {
+         Q_Q(QWindow);
+@@ -105,9 +113,8 @@ void QQuickWidgetPrivate::init(QQmlEngine* e)
+     Q_Q(QQuickWidget);
+ 
+     renderControl = new QQuickWidgetRenderControl(q);
+-    offscreenWindow = new QQuickWindow(*new QQuickOffcreenWindowPrivate(),renderControl);
+-    offscreenWindow->setTitle(QString::fromLatin1("Offscreen"));
+-    offscreenWindow->setObjectName(QString::fromLatin1("QQuickOffScreenWindow"));
++    offscreenWindow = new QQuickWidgetOffscreenWindow(*new QQuickWidgetOffscreenWindowPrivate(), renderControl);
++    offscreenWindow->setScreen(q->screen());
+     // Do not call create() on offscreenWindow.
+ 
+     // Check if the Software Adaptation is being used
+@@ -138,6 +145,10 @@ void QQuickWidgetPrivate::init(QQmlEngine* e)
+     QWidget::connect(offscreenWindow, &QQuickWindow::focusObjectChanged, q, &QQuickWidget::propagateFocusObjectChanged);
+     QObject::connect(renderControl, SIGNAL(renderRequested()), q, SLOT(triggerUpdate()));
+     QObject::connect(renderControl, SIGNAL(sceneChanged()), q, SLOT(triggerUpdate()));
++
++#if QT_CONFIG(accessibility)
++    QAccessible::installFactory(&qAccessibleQuickWidgetFactory);
++#endif
+ }
+ 
+ void QQuickWidgetPrivate::ensureEngine() const
+@@ -901,9 +912,7 @@ void QQuickWidgetPrivate::createContext()
+ 
+         context = new QOpenGLContext;
+         context->setFormat(offscreenWindow->requestedFormat());
+-        const QWindow *win = q->window()->windowHandle();
+-        if (win && win->screen())
+-            context->setScreen(win->screen());
++        context->setScreen(q->screen());
+         QOpenGLContext *shareContext = qt_gl_global_share_context();
+         if (!shareContext)
+             shareContext = QWidgetPrivate::get(q->window())->shareContext();
+@@ -1520,19 +1529,16 @@ bool QQuickWidget::event(QEvent *e)
+         d->handleWindowChange();
+         break;
+ 
+-    case QEvent::ScreenChangeInternal:
+-        if (QWindow *window = this->window()->windowHandle()) {
+-            QScreen *newScreen = window->screen();
+-
+-            if (d->offscreenWindow)
+-                d->offscreenWindow->setScreen(newScreen);
+-            if (d->offscreenSurface)
+-                d->offscreenSurface->setScreen(newScreen);
++    case QEvent::ScreenChangeInternal: {
++        QScreen *newScreen = screen();
++        if (d->offscreenWindow)
++            d->offscreenWindow->setScreen(newScreen);
++        if (d->offscreenSurface)
++            d->offscreenSurface->setScreen(newScreen);
+ #if QT_CONFIG(opengl)
+-            if (d->context)
+-                d->context->setScreen(newScreen);
++        if (d->context)
++            d->context->setScreen(newScreen);
+ #endif
+-        }
+ 
+         if (d->useSoftwareRenderer
+ #if QT_CONFIG(opengl)
+@@ -1545,7 +1551,7 @@ bool QQuickWidget::event(QEvent *e)
+             d->render(true);
+         }
+         break;
+-
++    }
+     case QEvent::Show:
+     case QEvent::Move:
+         d->updatePosition();
+diff --git a/qtdeclarative/src/quickwidgets/qquickwidget_p.h b/qtdeclarative/src/quickwidgets/qquickwidget_p.h
+index 881f7f9220..1a946bcc71 100644
+--- a/qtdeclarative/src/quickwidgets/qquickwidget_p.h
++++ b/qtdeclarative/src/quickwidgets/qquickwidget_p.h
+@@ -148,6 +148,14 @@ public:
+     bool forceFullUpdate;
+ };
+ 
++class QQuickWidgetOffscreenWindow: public QQuickWindow
++{
++    Q_OBJECT
++
++public:
++    QQuickWidgetOffscreenWindow(QQuickWindowPrivate &dd, QQuickRenderControl *control);
++};
++
+ QT_END_NAMESPACE
+ 
+ #endif // QQuickWidget_P_H
+diff --git a/qtdeclarative/src/quickwidgets/quickwidgets.pro b/qtdeclarative/src/quickwidgets/quickwidgets.pro
+index 2438e577ae..85d156b8a3 100644
+--- a/qtdeclarative/src/quickwidgets/quickwidgets.pro
++++ b/qtdeclarative/src/quickwidgets/quickwidgets.pro
+@@ -7,9 +7,13 @@ DEFINES   += QT_NO_URL_CAST_FROM_STRING QT_NO_INTEGER_EVENT_COORDINATES QT_NO_FO
+ HEADERS += \
+     qquickwidget.h \
+     qquickwidget_p.h \
+-    qtquickwidgetsglobal.h
++    qtquickwidgetsglobal.h \
++    qaccessiblequickwidget_p.h \
++    qaccessiblequickwidgetfactory_p.h
+ 
+ SOURCES += \
+-    qquickwidget.cpp
++    qquickwidget.cpp \
++    qaccessiblequickwidget.cpp \
++    qaccessiblequickwidgetfactory.cpp
+ 
+ load(qt_module)
+diff --git a/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+index 3b7d74df63..b75bf820d5 100644
+--- a/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
++++ b/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+@@ -102,6 +102,7 @@ private slots:
+     void valueConversion_RegularExpression();
+     void castWithMultipleInheritance();
+     void collectGarbage();
++    void collectGarbageNestedWrappersTwoEngines();
+     void gcWithNestedDataStructure();
+     void stacktrace();
+     void numberParsing_data();
+@@ -1809,6 +1810,44 @@ void tst_QJSEngine::collectGarbage()
+     QVERIFY(ptr.isNull());
+ }
+ 
++class TestObjectContainer : public QObject
++{
++    Q_OBJECT
++    Q_PROPERTY(QObject *dummy MEMBER m_dummy CONSTANT)
++
++public:
++    TestObjectContainer() : m_dummy(new QObject(this)) {}
++
++private:
++    QObject *m_dummy;
++};
++
++void tst_QJSEngine::collectGarbageNestedWrappersTwoEngines()
++{
++    QJSEngine engine1;
++    QJSEngine engine2;
++
++    TestObjectContainer container;
++    QQmlEngine::setObjectOwnership(&container, QQmlEngine::CppOwnership);
++
++    engine1.globalObject().setProperty("foobar", engine1.newQObject(&container));
++    engine2.globalObject().setProperty("foobar", engine2.newQObject(&container));
++
++    engine1.evaluate("foobar.dummy.baz = 42");
++    engine2.evaluate("foobar.dummy.baz = 43");
++
++    QCOMPARE(engine1.evaluate("foobar.dummy.baz").toInt(), 42);
++    QCOMPARE(engine2.evaluate("foobar.dummy.baz").toInt(), 43);
++
++    engine1.collectGarbage();
++    engine2.collectGarbage();
++
++    // The GC should not collect dummy object wrappers neither in engine1 nor engine2, we
++    // verify that by checking whether the baz property still has its previous value.
++    QCOMPARE(engine1.evaluate("foobar.dummy.baz").toInt(), 42);
++    QCOMPARE(engine2.evaluate("foobar.dummy.baz").toInt(), 43);
++}
++
+ void tst_QJSEngine::gcWithNestedDataStructure()
+ {
+     // The GC must be able to traverse deeply nested objects, otherwise this
+diff --git a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml
+new file mode 100644
+index 0000000000..206133bb39
+--- /dev/null
++++ b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml
+@@ -0,0 +1,11 @@
++import QtQuick 2.8
++
++ListView {
++    id: root
++    width: 200
++    height: 200
++
++    delegate: Text {
++        text: display
++    }
++}
+diff --git a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
+index 35f1e2c94d..1722447830 100644
+--- a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
++++ b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
+@@ -27,6 +27,8 @@
+ ****************************************************************************/
+ 
+ #include <QtTest/qtest.h>
++#include <QtCore/QConcatenateTablesProxyModel>
++#include <QtGui/QStandardItemModel>
+ #include <QtQml/qqmlcomponent.h>
+ #include <QtQmlModels/private/qqmldelegatemodel_p.h>
+ #include <QtQuick/qquickview.h>
+@@ -47,6 +49,7 @@ private slots:
+     void filterOnGroup_removeWhenCompleted();
+     void qtbug_86017();
+     void contextAccessedByHandler();
++    void redrawUponColumnChange();
+ };
+ 
+ class AbstractItemModel : public QAbstractItemModel
+@@ -186,6 +189,30 @@ void tst_QQmlDelegateModel::contextAccessedByHandler()
+     QVERIFY(root->property("works").toBool());
+ }
+ 
++void tst_QQmlDelegateModel::redrawUponColumnChange()
++{
++    QStandardItemModel m1;
++    m1.appendRow({
++            new QStandardItem("Banana"),
++            new QStandardItem("Coconut"),
++    });
++
++    QQuickView view(testFileUrl("redrawUponColumnChange.qml"));
++    QCOMPARE(view.status(), QQuickView::Ready);
++    view.show();
++    QQuickItem *root = view.rootObject();
++    root->setProperty("model", QVariant::fromValue<QObject *>(&m1));
++
++    QObject *item = root->property("currentItem").value<QObject *>();
++    QVERIFY(item);
++    QCOMPARE(item->property("text").toString(), "Banana");
++
++    QVERIFY(root);
++    m1.removeColumn(0);
++
++    QCOMPARE(item->property("text").toString(), "Coconut");
++}
++
+ QTEST_MAIN(tst_QQmlDelegateModel)
+ 
+ #include "tst_qqmldelegatemodel.moc"
+diff --git a/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp b/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
+index 5d635aa63b..824fd89e5b 100644
+--- a/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
++++ b/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
+@@ -76,10 +76,10 @@ void tst_qv4mm::multiWrappedQObjects()
+         QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 1);
+         QCOMPARE(engine2.memoryManager->m_pendingFreedObjectWrapperValue.size(), 0);
+ 
+-        // Moves the additional WeakValue from m_multiplyWrappedQObjects to
+-        // m_pendingFreedObjectWrapperValue. It's still alive after all.
++        // The additional WeakValue from m_multiplyWrappedQObjects hasn't been moved
++        // to m_pendingFreedObjectWrapperValue yet. It's still alive after all.
+         engine1.memoryManager->runGC();
+-        QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 2);
++        QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 1);
+ 
+         // engine2 doesn't own the object as engine1 was the first to wrap it above.
+         // Therefore, no effect here.
+diff --git a/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml b/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml
+new file mode 100644
+index 0000000000..889e480f3b
+--- /dev/null
++++ b/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml
+@@ -0,0 +1,13 @@
++import QtQuick 2.6
++
++Item {
++    visible: true
++    Item {
++        visible: false
++        Item {
++            objectName: "hiddenChild"
++            activeFocusOnTab: true
++            focus: true
++        }
++    }
++}
+diff --git a/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp b/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+index c8f251dbe1..c8ef36ee68 100644
+--- a/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
++++ b/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+@@ -67,6 +67,7 @@ private slots:
+     void activeFocusOnTab10();
+     void activeFocusOnTab_infiniteLoop_data();
+     void activeFocusOnTab_infiniteLoop();
++    void activeFocusOnTab_infiniteLoopControls();
+ 
+     void nextItemInFocusChain();
+     void nextItemInFocusChain2();
+@@ -1057,6 +1058,17 @@ void tst_QQuickItem::activeFocusOnTab_infiniteLoop()
+     QCOMPARE(item, window->rootObject());
+ }
+ 
++
++void tst_QQuickItem::activeFocusOnTab_infiniteLoopControls()
++{
++    auto source = testFileUrl("activeFocusOnTab_infiniteLoop3.qml");
++    QScopedPointer<QQuickView>window(new QQuickView());
++    window->setSource(source);
++    window->show();
++    QVERIFY(window->errors().isEmpty());
++    QTest::keyClick(window.get(), Qt::Key_Tab); // should not hang
++}
++
+ void tst_QQuickItem::nextItemInFocusChain()
+ {
+     if (!qt_tab_all_widgets())
+Submodule qtdoc c0c7bf07...79d6ef69:
+Submodule qtimageformats 2dcf2899..abe44c0f:
+diff --git a/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp b/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
+index dde783c..1bf9074 100644
+--- a/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
+@@ -462,8 +462,12 @@ static bool parseIconEntryInfo(ICNSEntry &icon)
+     if (isIconCompressed(icon))
+         return true;
+     // Icon depth:
+-    if (!depth.isEmpty())
+-        icon.depth = ICNSEntry::Depth(depth.toUInt());
++    if (!depth.isEmpty()) {
++        const uint depthUInt = depth.toUInt();
++        if (depthUInt > 32)
++            return false;
++        icon.depth = ICNSEntry::Depth(depthUInt);
++    }
+     // Try mono if depth not found
+     if (icon.depth == ICNSEntry::DepthUnknown)
+         icon.depth = ICNSEntry::DepthMono;
+@@ -515,6 +519,9 @@ static bool parseIconEntryInfo(ICNSEntry &icon)
+         }
+         icon.height = icon.width;
+     }
++    // Sanity check
++    if (icon.width == 0 || icon.width > 4096)
++        return false;
+     return true;
+ }
+ 
+@@ -685,7 +692,7 @@ bool QICNSHandler::canRead() const
+ bool QICNSHandler::read(QImage *outImage)
+ {
+     QImage img;
+-    if (!ensureScanned()) {
++    if (!ensureScanned() || m_currentIconIndex >= m_icons.size()) {
+         qWarning("QICNSHandler::read(): The device wasn't parsed properly!");
+         return false;
+     }
+@@ -892,7 +899,7 @@ bool QICNSHandler::scanDevice()
+             return false;
+ 
+         const qint64 blockDataOffset = device()->pos();
+-        if (!isBlockHeaderValid(blockHeader)) {
++        if (!isBlockHeaderValid(blockHeader, ICNSBlockHeaderSize + filelength - blockDataOffset)) {
+             qWarning("QICNSHandler::scanDevice(): Failed, bad header at pos %s. OSType \"%s\", length %u",
+                      QByteArray::number(blockDataOffset).constData(),
+                      nameFromOSType(blockHeader.ostype).constData(), blockHeader.length);
+@@ -927,11 +934,14 @@ bool QICNSHandler::scanDevice()
+         case ICNSBlockHeader::TypeOdrp:
+             // Icns container seems to have an embedded icon variant container
+             // Let's start a scan for entries
+-            while (device()->pos() < nextBlockOffset) {
++            while (!stream.atEnd() && device()->pos() < nextBlockOffset) {
+                 ICNSBlockHeader icon;
+                 stream >> icon;
++                if (stream.status() != QDataStream::Ok)
++                    return false;
+                 // Check for incorrect variant entry header and stop scan
+-                if (!isBlockHeaderValid(icon, blockDataLength))
++                quint64 remaining = blockDataLength - (device()->pos() - blockDataOffset);
++                if (!isBlockHeaderValid(icon, ICNSBlockHeaderSize + remaining))
+                     break;
+                 if (!addEntry(icon, device()->pos(), blockHeader.ostype))
+                     return false;
+@@ -1003,7 +1013,7 @@ bool QICNSHandler::scanDevice()
+             break;
+         }
+     }
+-    return true;
++    return (m_icons.size() > 0);
+ }
+ 
+ const ICNSEntry &QICNSHandler::getIconMask(const ICNSEntry &icon) const
+diff --git a/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp b/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
+index 5082023..cb34374 100644
+--- a/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
++++ b/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
+@@ -43,6 +43,7 @@
+ #include "qimage.h"
+ #include "qvariant.h"
+ #include "qcolor.h"
++#include "qimagereader.h"
+ 
+ #include <jasper/jasper.h>
+ #include <math.h> // for pow
+@@ -333,16 +334,46 @@ private:
+ Jpeg2000JasperReader::Jpeg2000JasperReader(QIODevice *iod, SubFormat format)
+     : jasperOk(true), ioDevice(iod), format(format), hasAlpha(false)
+ {
++#if JAS_VERSION_MAJOR < 3
+     if (jas_init()) {
+         jasperOk = false;
+         qDebug("Jasper Library initialization failed");
+     }
++#else
++    jas_conf_clear();
++#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
++    jas_conf_set_max_mem_usage(QImageReader::allocationLimit() * 1024 * 1024);
++#else
++    // 128MB seems to be enough.
++    jas_conf_set_max_mem_usage(128 * 1024 * 1024);
++#endif
++    if (jas_init_library()) {
++        jasperOk = false;
++        qDebug("Jasper library initialization failed");
++    }
++    if (jas_init_thread()) {
++        jas_cleanup_library();
++        jasperOk = false;
++        qDebug("Jasper thread initialization failed");
++    }
++#endif
+ }
+ 
+ Jpeg2000JasperReader::~Jpeg2000JasperReader()
+ {
++#if JAS_VERSION_MAJOR < 3
+     if (jasperOk)
+         jas_cleanup();
++#else
++    if (jasperOk) {
++        if (jas_cleanup_thread()) {
++            qDebug("Jasper thread cleanup failed");
++        }
++        if (jas_cleanup_library()) {
++            qDebug("Jasper library cleanup failed");
++        }
++    }
++#endif
+ }
+ 
+ /*! \internal
+@@ -857,7 +888,7 @@ bool Jpeg2000JasperReader::write(const QImage &image, int quality)
+     }
+ 
+     // Open an empty jasper stream that grows automatically
+-    jas_stream_t * memory_stream = jas_stream_memopen(0, -1);
++    jas_stream_t * memory_stream = jas_stream_memopen(0, 0);
+ 
+     // Jasper wants a non-const string.
+     char *str = qstrdup(jasperFormatString.toLatin1().constData());
+diff --git a/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp b/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
+index 1386750..ac8956c 100644
+--- a/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
+@@ -361,6 +361,8 @@ bool QTiffHandler::read(QImage *image)
+     }
+ 
+     TIFF *const tiff = d->tiff;
++    if (TIFFIsTiled(tiff) && TIFFTileSize64(tiff) > uint64_t(image->sizeInBytes())) // Corrupt image
++        return false;
+     const quint32 width = d->size.width();
+     const quint32 height = d->size.height();
+ 
+diff --git a/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp b/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
+index 82d38cb..d02eb05 100644
+--- a/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
+@@ -45,6 +45,7 @@
+ #include <qdebug.h>
+ #include <qpainter.h>
+ #include <qvariant.h>
++#include <QtEndian>
+ 
+ static const int riffHeaderSize = 12; // RIFF_HEADER_SIZE from webp/format_constants.h
+ 
+@@ -102,21 +103,23 @@ bool QWebpHandler::ensureScanned() const
+ 
+     m_scanState = ScanError;
+ 
+-    if (device()->isSequential()) {
+-        qWarning() << "Sequential devices are not supported";
++    QWebpHandler *that = const_cast<QWebpHandler *>(this);
++    const int headerBytesNeeded = sizeof(WebPBitstreamFeatures);
++    QByteArray header = device()->peek(headerBytesNeeded);
++    if (header.size() < headerBytesNeeded)
+         return false;
+-    }
+ 
+-    qint64 oldPos = device()->pos();
+-    device()->seek(0);
+-
+-    QWebpHandler *that = const_cast<QWebpHandler *>(this);
+-    QByteArray header = device()->peek(sizeof(WebPBitstreamFeatures));
++    // We do no random access during decoding, just a readAll() of the whole image file. So if
++    // if it is all available already, we can accept a sequential device. The riff header contains
++    // the file size minus 8 bytes header
++    qint64 byteSize = qFromLittleEndian<quint32>(header.constData() + 4);
++    if (device()->isSequential() && device()->bytesAvailable() < byteSize + 8) {
++        qWarning() << "QWebpHandler: Insufficient data available in sequential device";
++        return false;
++    }
+     if (WebPGetFeatures((const uint8_t*)header.constData(), header.size(), &(that->m_features)) == VP8_STATUS_OK) {
+         if (m_features.has_animation) {
+             // For animation, we have to read and scan whole file to determine loop count and images count
+-            device()->seek(oldPos);
+-
+             if (that->ensureDemuxer()) {
+                 that->m_loop = WebPDemuxGetI(m_demuxer, WEBP_FF_LOOP_COUNT);
+                 that->m_frameCount = WebPDemuxGetI(m_demuxer, WEBP_FF_FRAME_COUNT);
+@@ -126,17 +129,13 @@ bool QWebpHandler::ensureScanned() const
+                 if (that->m_features.has_alpha)
+                     that->m_composited->fill(Qt::transparent);
+ 
+-                // We do not reset device position since we have read in all data
+                 m_scanState = ScanSuccess;
+-                return true;
+             }
+         } else {
+             m_scanState = ScanSuccess;
+         }
+     }
+ 
+-    device()->seek(oldPos);
+-
+     return m_scanState == ScanSuccess;
+ }
+ 
+@@ -159,7 +158,7 @@ bool QWebpHandler::ensureDemuxer()
+ 
+ bool QWebpHandler::read(QImage *image)
+ {
+-    if (!ensureScanned() || device()->isSequential() || !ensureDemuxer())
++    if (!ensureScanned() || !ensureDemuxer())
+         return false;
+ 
+     QRect prevFrameRect;
+Submodule qtlocation 98a5c511..f991e28c:
+diff --git a/qtlocation/src/location/configure.json b/qtlocation/src/location/configure.json
+index 6d01a9a3..d1e623a1 100644
+--- a/qtlocation/src/location/configure.json
++++ b/qtlocation/src/location/configure.json
+@@ -9,7 +9,7 @@
+             "label": "Qt.labs.location experimental QML plugin",
+             "purpose": "Provides experimental QtLocation QML types",
+             "section": "Location",
+-            "condition": "config.opengl",
++            "condition": "features.opengl",
+             "output": [ "privateFeature" ]
+         },
+         "geoservices_osm": {
+diff --git a/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp b/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
+index a978573d..11e1466f 100644
+--- a/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
++++ b/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
+@@ -158,7 +158,7 @@ void QGeoMapObjectQSGSupport::updateMapObjects(QSGNode *root, QQuickWindow *wind
+     if (!root)
+         return;
+ 
+-    if (m_mapObjectsRootNode && m_mapObjectsRootNode->parent())
++    if (m_mapObjectsRootNode && !m_mapObjectsRootNode->parent())
+         root->appendChildNode(m_mapObjectsRootNode.get());
+ 
+     if (!m_mapObjectsRootNode) {
+diff --git a/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
+index 5a40467e..d123c6a8 100644
+--- a/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
+@@ -59,8 +59,10 @@ QT_BEGIN_NAMESPACE
+ static const QString kPrefixEsri(QStringLiteral("esri."));
+ static const QString kParamUserAgent(kPrefixEsri + QStringLiteral("useragent"));
+ 
+-static const QString kUrlGeocode(QStringLiteral("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates"));
+-static const QString kUrlReverseGeocode(QStringLiteral("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode"));
++static const QString kUrlGeocode(QStringLiteral("https://geocode.arcgis.com/arcgis/rest/services/"
++                                                "World/GeocodeServer/findAddressCandidates"));
++static const QString kUrlReverseGeocode(QStringLiteral(
++        "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode"));
+ 
+ static QString addressToQuery(const QGeoAddress &address)
+ {
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
+index 17492d94..96c12b1b 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
+@@ -46,7 +46,8 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-// JSON reference: http://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
++// JSON reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
+ 
+ static const QString kErrorMessage(QStringLiteral("Error %1: %2."));
+ static const QString kErrorJson(QStringLiteral("Error: invalide JSON document."));
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
+index 8cadfb29..92b6bb13 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
+@@ -44,7 +44,8 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-// JSON reference: http://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
++// JSON reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
+ 
+ GeoRouteReplyEsri::GeoRouteReplyEsri(QNetworkReply *reply, const QGeoRouteRequest &request,
+                                      QObject *parent) :
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
+index 0e6bc2c7..ed613f4b 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
+@@ -48,7 +48,8 @@ static const QString kPrefixEsri(QStringLiteral("esri."));
+ static const QString kParamUserAgent(kPrefixEsri + QStringLiteral("useragent"));
+ static const QString kParamToken(kPrefixEsri + QStringLiteral("token"));
+ 
+-static const QString kUrlRouting(QStringLiteral("http://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve"));
++static const QString kUrlRouting(QStringLiteral(
++        "https://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve"));
+ 
+ GeoRoutingManagerEngineEsri::GeoRoutingManagerEngineEsri(const QVariantMap &parameters,
+                                                          QGeoServiceProvider::Error *error,
+@@ -70,7 +71,8 @@ GeoRoutingManagerEngineEsri::~GeoRoutingManagerEngineEsri()
+ {
+ }
+ 
+-// REST reference: http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
++// REST reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
+ 
+ QGeoRouteReply *GeoRoutingManagerEngineEsri::calculateRoute(const QGeoRouteRequest &request)
+ {
+@@ -125,7 +127,7 @@ void GeoRoutingManagerEngineEsri::replyError(QGeoRouteReply::Error errorCode, co
+ QString GeoRoutingManagerEngineEsri::preferedDirectionLangage()
+ {
+     // list of supported langages is defined in:
+-    // http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
++    // https://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
+     const QStringList supportedLanguages = {
+         "ar", // Generate directions in Arabic
+         "cs", // Generate directions in Czech
+diff --git a/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
+index 5d15835d..24148f95 100644
+--- a/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
+@@ -230,7 +230,8 @@ QGeoMap *GeoTiledMappingManagerEngineEsri::createMap()
+ // ${y} = Y
+ // ${token} = Token
+ 
+-// template = 'http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{{z}}/{{y}}/{{x}}.png'
++// template =
++// 'https://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{{z}}/{{y}}/{{x}}.png'
+ 
+ bool GeoTiledMappingManagerEngineEsri::initializeMapSources(QGeoServiceProvider::Error *error,
+                                                             QString *errorString,
+diff --git a/qtlocation/src/plugins/geoservices/esri/maps.json b/qtlocation/src/plugins/geoservices/esri/maps.json
+index 8167ae7d..862e087d 100644
+--- a/qtlocation/src/plugins/geoservices/esri/maps.json
++++ b/qtlocation/src/plugins/geoservices/esri/maps.json
+@@ -6,8 +6,8 @@
+             "description": "ArcGIS Online World Street Map",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=3b93337983e9436f8db950e38a8629af'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=3b93337983e9436f8db950e38a8629af'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -16,8 +16,8 @@
+             "": "ArcGIS Online World Imagery",
+             "mobile": true,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -26,8 +26,8 @@
+             "description": "ArcGIS Online World Terrain Base",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=c61ad8ab017d49e1a82f580ee1298931'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=c61ad8ab017d49e1a82f580ee1298931'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -36,8 +36,8 @@
+             "description": "ArcGIS Online World Topography",
+             "mobile": true,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=30e5fe3149c34df1ba922e6f5bbf808f'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=30e5fe3149c34df1ba922e6f5bbf808f'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -46,8 +46,8 @@
+             "description": "This map presents land cover and detailed topographic maps for the United States.",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=99cd5fbd98934028802b4f797c4b1732'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=99cd5fbd98934028802b4f797c4b1732'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -56,8 +56,8 @@
+             "description": "National Geographic World Map",
+             "mobile": false,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=b9b1b422198944fbbd5250b3241691b6'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=b9b1b422198944fbbd5250b3241691b6'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -66,8 +66,8 @@
+             "description": "Thematic content providing a neutral background with minimal colors",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=ed712cb1db3e4bae9e85329040fb9a49'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=ed712cb1db3e4bae9e85329040fb9a49'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -76,8 +76,8 @@
+             "description": "Natural Earth physical map for the world",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=c4ec722a1cd34cf0a23904aadf8923a0'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=c4ec722a1cd34cf0a23904aadf8923a0'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -86,8 +86,8 @@
+             "description": "Portrays surface elevation as shaded relief",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=9c5370d0b54f4de1b48a3792d7377ff2'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=9c5370d0b54f4de1b48a3792d7377ff2'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -96,8 +96,8 @@
+             "description": "This map is designed to be used as a basemap by marine GIS professionals and as a reference map by anyone interested in ocean data",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=1e126e7520f9466c9ca28b8f28b5e500'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=1e126e7520f9466c9ca28b8f28b5e500'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -106,8 +106,8 @@
+             "description": "Thematic content providing a neutral background with minimal colors",
+             "mobile": false,
+             "night": true,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=a284a9b99b3446a3910d4144a50990f6'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=a284a9b99b3446a3910d4144a50990f6'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -116,8 +116,8 @@
+             "description": "DeLorme’s topographic basemap is a seamless global data set that portrays transportation, hydrography, jurisdiction boundaries, and major geographic features",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/Specialty/DeLorme_World_Base_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=b165c3df453e4be6b5ac4fdb241effbe'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/Specialty/DeLorme_World_Base_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=b165c3df453e4be6b5ac4fdb241effbe'>Esri</a> contributors"
+         }
+     ]
+ }
+diff --git a/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
+index 3858ddf5..af66f28e 100644
+--- a/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
+@@ -63,8 +63,10 @@ static const QString kCountriesKey(QStringLiteral("detailedCountries"));
+ static const QString kLocalizedNamesKey(QStringLiteral("localizedNames"));
+ static const QString kMaxLocationsKey(QStringLiteral("maxLocations"));
+ 
+-static const QUrl kUrlGeocodeServer("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer?f=pjson");
+-static const QUrl kUrlFindAddressCandidates("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates");
++static const QUrl kUrlGeocodeServer(
++        "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer?f=pjson");
++static const QUrl kUrlFindAddressCandidates("https://geocode.arcgis.com/arcgis/rest/services/World/"
++                                            "GeocodeServer/findAddressCandidates");
+ 
+ PlaceManagerEngineEsri::PlaceManagerEngineEsri(const QVariantMap &parameters, QGeoServiceProvider::Error *error,
+                                                QString *errorString) :
+Submodule qtmultimedia f0344079..0d7cc33a:
+diff --git a/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp b/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
+index 2b5325132..b68b4af1b 100644
+--- a/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
++++ b/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
+@@ -402,6 +402,8 @@ int QPulseAudioInput::bytesReady() const
+ 
+ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ {
++    Q_ASSERT(data != nullptr || len == 0);
++
+     m_bytesAvailable = checkBytesReady();
+ 
+     setError(QAudio::NoError);
+@@ -411,7 +413,8 @@ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ 
+     if (!m_pullMode && !m_tempBuffer.isEmpty()) {
+         readBytes = qMin(static_cast<int>(len), m_tempBuffer.size());
+-        memcpy(data, m_tempBuffer.constData(), readBytes);
++        if (readBytes)
++            memcpy(data, m_tempBuffer.constData(), readBytes);
+         m_totalTimeValue += readBytes;
+ 
+         if (readBytes < m_tempBuffer.size()) {
+@@ -502,9 +505,10 @@ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ 
+ void QPulseAudioInput::applyVolume(const void *src, void *dest, int len)
+ {
++    Q_ASSERT((src && dest) || len == 0);
+     if (m_volume < 1.f)
+         QAudioHelperInternal::qMultiplySamples(m_volume, m_format, src, dest, len);
+-    else
++    else if (len)
+         memcpy(dest, src, len);
+ }
+ 
+Submodule qtpim 02efef5e...f9a8f0fc (commits not present)
+Submodule qtquick3d b85cf622..47defc8b:
+diff --git a/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro b/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
+index ca5c499e..174a075b 100644
+--- a/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
++++ b/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
+@@ -10,7 +10,7 @@ QT_FOR_CONFIG += assetimporters-private
+ include($$OUT_PWD/../qtassetimporters-config.pri)
+ 
+ qtConfig(system-assimp):!if(cross_compile:host_build) {
+-    QMAKE_USE_PRIVATE += assimp
++    QMAKE_USE_PRIVATE += quick3d-assimp
+ } else {
+     include(../../../3rdparty/assimp/assimp.pri)
+ }
+Submodule qtquickcontrols2 3a657dc0..56ce8233:
+diff --git a/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp b/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
+index e5fe734f7..e36922775 100644
+--- a/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
++++ b/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
+@@ -38,6 +38,7 @@
+ #include "qwidgetplatformmenuitem_p.h"
+ 
+ #include <QtGui/qwindow.h>
++#include <QtGui/private/qhighdpiscaling_p.h>
+ #include <QtWidgets/qmenu.h>
+ #include <QtWidgets/qaction.h>
+ 
+@@ -145,7 +146,7 @@ void QWidgetPlatformMenu::showPopup(const QWindow *window, const QRect &targetRe
+ 
+     QPoint targetPos = targetRect.bottomLeft();
+     if (window)
+-        targetPos = window->mapToGlobal(targetPos);
++        targetPos = window->mapToGlobal(QHighDpi::fromNativeLocalPosition(targetPos, window));
+ 
+     const QWidgetPlatformMenuItem *widgetItem = qobject_cast<const QWidgetPlatformMenuItem *>(item);
+     m_menu->popup(targetPos, widgetItem ? widgetItem->action() : nullptr);
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
+index 950e4e099..b81fbea0b 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
+@@ -387,6 +387,17 @@ void QQuickAbstractButtonPrivate::itemImplicitHeightChanged(QQuickItem *item)
+         emit q->implicitIndicatorHeightChanged();
+ }
+ 
++void QQuickAbstractButtonPrivate::itemDestroyed(QQuickItem *item)
++{
++    Q_Q(QQuickAbstractButton);
++    QQuickControlPrivate::itemDestroyed(item);
++    if (item == indicator) {
++        indicator = nullptr;
++        emit q->implicitIndicatorWidthChanged();
++        emit q->implicitIndicatorHeightChanged();
++    }
++}
++
+ QQuickAbstractButton *QQuickAbstractButtonPrivate::findCheckedButton() const
+ {
+     Q_Q(const QQuickAbstractButton);
+@@ -1176,6 +1187,12 @@ QAccessible::Role QQuickAbstractButton::accessibleRole() const
+     }
+     return QAccessible::Button;
+ }
++
++void QQuickAbstractButton::accessiblePressAction()
++{
++    Q_D(QQuickAbstractButton);
++    d->trigger();
++}
+ #endif
+ 
+ QT_END_NAMESPACE
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
+index 0fa48980e..ab66220d0 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
+@@ -209,6 +209,7 @@ protected:
+ #if QT_CONFIG(accessibility)
+     void accessibilityActiveChanged(bool active) override;
+     QAccessible::Role accessibleRole() const override;
++    Q_INVOKABLE void accessiblePressAction();
+ #endif
+ 
+ private:
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
+index 9291c1a87..b729720f2 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
+@@ -109,6 +109,7 @@ public:
+ 
+     void itemImplicitWidthChanged(QQuickItem *item) override;
+     void itemImplicitHeightChanged(QQuickItem *item) override;
++    void itemDestroyed(QQuickItem *item) override;
+ 
+     // copied from qabstractbutton.cpp
+     static const int AUTO_REPEAT_DELAY = 300;
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp b/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
+index 2041e7741..8610cdfae 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
+@@ -145,7 +145,7 @@ int QQuickActionPrivate::ShortcutEntry::shortcutId() const
+ 
+ void QQuickActionPrivate::ShortcutEntry::grab(const QKeySequence &shortcut, bool enabled)
+ {
+-    if (shortcut.isEmpty())
++    if (shortcut.isEmpty() || m_shortcutId)
+         return;
+ 
+     Qt::ShortcutContext context = Qt::WindowShortcut; // TODO
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp b/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
+index f38c2b09c..6eed2a024 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
+@@ -225,6 +225,7 @@ void QQuickContainerPrivate::cleanup()
+     QObject::disconnect(contentModel, &QQmlObjectModel::countChanged, q, &QQuickContainer::countChanged);
+     QObject::disconnect(contentModel, &QQmlObjectModel::childrenChanged, q, &QQuickContainer::contentChildrenChanged);
+     delete contentModel;
++    contentModel = nullptr;
+ }
+ 
+ QQuickItem *QQuickContainerPrivate::itemAt(int index) const
+@@ -436,7 +437,7 @@ void QQuickContainerPrivate::contentChildren_clear(QQmlListProperty<QQuickItem>
+ void QQuickContainerPrivate::updateContentWidth()
+ {
+     Q_Q(QQuickContainer);
+-    if (hasContentWidth || qFuzzyCompare(contentWidth, implicitContentWidth))
++    if (hasContentWidth || qFuzzyCompare(contentWidth, implicitContentWidth) || !contentModel)
+         return;
+ 
+     contentWidth = implicitContentWidth;
+@@ -446,7 +447,7 @@ void QQuickContainerPrivate::updateContentWidth()
+ void QQuickContainerPrivate::updateContentHeight()
+ {
+     Q_Q(QQuickContainer);
+-    if (hasContentHeight || qFuzzyCompare(contentHeight, implicitContentHeight))
++    if (hasContentHeight || qFuzzyCompare(contentHeight, implicitContentHeight) || !contentModel)
+         return;
+ 
+     contentHeight = implicitContentHeight;
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp b/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
+index bbbd0e622..1f4b47343 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
+@@ -845,6 +845,13 @@ void QQuickControlPrivate::executeBackground(bool complete)
+         quickCompleteDeferred(q, backgroundName(), background);
+ }
+ 
++/*
++    \internal
++
++    Hides an item that was replaced by a newer one, rather than
++    deleting it, as the item is typically created in QML and hence
++    we don't own it.
++*/
+ void QQuickControlPrivate::hideOldItem(QQuickItem *item)
+ {
+     if (!item)
+@@ -863,6 +870,29 @@ void QQuickControlPrivate::hideOldItem(QQuickItem *item)
+ #endif
+ }
+ 
++/*
++    \internal
++
++    Named "unhide" because it's used for cases where an item
++    that was previously hidden by \l hideOldItem() wants to be
++    shown by a control again, such as a ScrollBar in ScrollView.
++*/
++void QQuickControlPrivate::unhideOldItem(QQuickControl *control, QQuickItem *item)
++{
++    Q_ASSERT(item);
++    qCDebug(lcItemManagement) << "unhiding old item" << item;
++
++    item->setVisible(true);
++    item->setParentItem(control);
++
++#if QT_CONFIG(accessibility)
++    // Add the item back in to the accessibility tree.
++    QQuickAccessibleAttached *accessible = accessibleAttached(item);
++    if (accessible)
++        accessible->setIgnored(false);
++#endif
++}
++
+ void QQuickControlPrivate::updateBaselineOffset()
+ {
+     Q_Q(QQuickControl);
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h b/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
+index 8e979079e..a6e624c91 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
+@@ -173,6 +173,7 @@ public:
+     virtual void executeBackground(bool complete = false);
+ 
+     static void hideOldItem(QQuickItem *item);
++    static void unhideOldItem(QQuickControl *control, QQuickItem *item);
+ 
+     void updateBaselineOffset();
+ 
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp b/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
+index e6db14eb5..6197d1547 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
+@@ -237,7 +237,7 @@ static QRectF alignedRect(Qt::LayoutDirection direction, Qt::Alignment alignment
+ void QQuickDialogButtonBoxPrivate::resizeContent()
+ {
+     Q_Q(QQuickDialogButtonBox);
+-    if (!contentItem)
++    if (!contentItem || !contentModel)
+         return;
+ 
+     QRectF geometry = q->boundingRect().adjusted(q->leftPadding(), q->topPadding(), -q->rightPadding(), -q->bottomPadding());
+@@ -322,6 +322,9 @@ void QQuickDialogButtonBoxPrivate::updateLayout()
+ qreal QQuickDialogButtonBoxPrivate::getContentWidth() const
+ {
+     Q_Q(const QQuickDialogButtonBox);
++    if (!contentModel)
++        return 0;
++
+     const int count = contentModel->count();
+     const qreal totalSpacing = qMax(0, count - 1) * spacing;
+     qreal totalWidth = totalSpacing;
+@@ -341,6 +344,9 @@ qreal QQuickDialogButtonBoxPrivate::getContentWidth() const
+ qreal QQuickDialogButtonBoxPrivate::getContentHeight() const
+ {
+     Q_Q(const QQuickDialogButtonBox);
++    if (!contentModel)
++        return 0;
++
+     const int count = contentModel->count();
+     qreal maxHeight = 0;
+     for (int i = 0; i < count; ++i) {
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp b/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
+index 91bd59184..0ce518f84 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
+@@ -399,8 +399,11 @@ void QQuickOverlay::itemChange(ItemChange change, const ItemChangeData &data)
+     Q_D(QQuickOverlay);
+     QQuickItem::itemChange(change, data);
+ 
+-    if (change == ItemChildAddedChange || change == ItemChildRemovedChange)
++    if (change == ItemChildAddedChange || change == ItemChildRemovedChange) {
+         setVisible(!d->allDrawers.isEmpty() || !childItems().isEmpty());
++        if (data.item->parent() == d->mouseGrabberPopup)
++            d->setMouseGrabberPopup(nullptr);
++    }
+ }
+ 
+ void QQuickOverlay::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp b/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
+index 4e2f509db..1c4b308cd 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
+@@ -797,6 +797,14 @@ void QQuickScrollBarAttachedPrivate::initHorizontal()
+     if (parent && parent == flickable->parentItem())
+         horizontal->stackAfter(flickable);
+ 
++    // If a scroll bar was previously hidden (due to e.g. setting a new contentItem
++    // on a ScrollView), we need to make sure that we un-hide it.
++    // We don't bother checking if the item is actually the old one, because
++    // if it's not, all of the things the function does (setting parent, visibility, etc.)
++    // should be no-ops anyway.
++    if (auto control = qobject_cast<QQuickControl*>(q_ptr->parent()))
++        QQuickControlPrivate::unhideOldItem(control, horizontal);
++
+     layoutHorizontal();
+     horizontal->setSize(area->property("widthRatio").toReal());
+     horizontal->setPosition(area->property("xPosition").toReal());
+@@ -818,6 +826,9 @@ void QQuickScrollBarAttachedPrivate::initVertical()
+     if (parent && parent == flickable->parentItem())
+         vertical->stackAfter(flickable);
+ 
++    if (auto control = qobject_cast<QQuickControl*>(q_ptr->parent()))
++        QQuickControlPrivate::unhideOldItem(control, vertical);
++
+     layoutVertical();
+     vertical->setSize(area->property("heightRatio").toReal());
+     vertical->setPosition(area->property("yPosition").toReal());
+diff --git a/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml b/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
+index 0e8b08352..cd4931184 100644
+--- a/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
++++ b/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
+@@ -576,4 +576,51 @@ TestCase {
+         verify(newHorizontalScrollBar.visible)
+         verify(!oldHorizontalScrollBar.visible)
+     }
++
++    Component {
++        id: bindingToContentItemAndStandaloneFlickable
++
++        Item {
++            width: 200
++            height: 200
++
++            property alias scrollView: scrollView
++
++            ScrollView {
++                id: scrollView
++                anchors.fill: parent
++                contentItem: listView
++
++                property Item someBinding: contentItem
++            }
++            ListView {
++                id: listView
++                model: 10
++                delegate: ItemDelegate {
++                    text: modelData
++                    width: listView.width
++                }
++            }
++        }
++    }
++
++    // Tests that scroll bars show up for a ScrollView where
++    // - its contentItem is declared as a standalone, separate item
++    // - there is a binding to contentItem (which causes a default Flickable to be created)
++    function test_bindingToContentItemAndStandaloneFlickable() {
++        let root = createTemporaryObject(bindingToContentItemAndStandaloneFlickable, testCase)
++        verify(root)
++
++        let control = root.scrollView
++        let verticalScrollBar = control.ScrollBar.vertical
++        let horizontalScrollBar = control.ScrollBar.horizontal
++        compare(verticalScrollBar.parent, control)
++        compare(horizontalScrollBar.parent, control)
++        verify(verticalScrollBar.visible)
++        verify(horizontalScrollBar.visible)
++
++        mouseDrag(verticalScrollBar, verticalScrollBar.width / 2, verticalScrollBar.height / 2, 0, 50)
++        verify(verticalScrollBar.active)
++        verify(horizontalScrollBar.active)
++    }
+ }
+diff --git a/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml b/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
+index b3fab41ca..10b6baa02 100644
+--- a/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
++++ b/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
+@@ -608,4 +608,27 @@ TestCase {
+         mouseClick(control.indicator)
+         verify(control.activeFocus)
+     }
++
++    Component {
++        id: deletionOrder1
++        Item {
++            Image { id: innerImage }
++            Switch { indicator: innerImage }
++        }
++    }
++
++    Component {
++        id: deletionOrder2
++        Item {
++            Switch { indicator: innerImage }
++            Image { id: innerImage }
++        }
++    }
++
++    function test_deletionOrder() {
++        var control1 = createTemporaryObject(deletionOrder1, testCase)
++        verify(control1)
++        var control2 = createTemporaryObject(deletionOrder2, testCase)
++        verify(control2)
++    }
+ }
+diff --git a/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml b/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml
+new file mode 100644
+index 000000000..9e4598b9f
+--- /dev/null
++++ b/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml
+@@ -0,0 +1,78 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the test suite of the Qt Toolkit.
++**
++** $QT_BEGIN_LICENSE:BSD$
++** Commercial License Usage
++** Licensees holding valid commercial Qt licenses may use this file in
++** accordance with the commercial license agreement provided with the
++** Software or, alternatively, in accordance with the terms contained in
++** a written agreement between you and The Qt Company. For licensing terms
++** and conditions see https://www.qt.io/terms-conditions. For further
++** information use the contact form at https://www.qt.io/contact-us.
++**
++** BSD License Usage
++** Alternatively, you may use this file under the terms of the BSD license
++** as follows:
++**
++** "Redistribution and use in source and binary forms, with or without
++** modification, are permitted provided that the following conditions are
++** met:
++**   * Redistributions of source code must retain the above copyright
++**     notice, this list of conditions and the following disclaimer.
++**   * Redistributions in binary form must reproduce the above copyright
++**     notice, this list of conditions and the following disclaimer in
++**     the documentation and/or other materials provided with the
++**     distribution.
++**   * Neither the name of The Qt Company Ltd nor the names of its
++**     contributors may be used to endorse or promote products derived
++**     from this software without specific prior written permission.
++**
++**
++** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
++** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
++** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
++** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
++** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
++** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
++** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
++** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
++** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
++** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
++** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
++**
++** $QT_END_LICENSE$
++**
++****************************************************************************/
++
++import QtQuick 2.15
++import QtQuick.Controls 2.15
++
++ApplicationWindow {
++    id: window
++    width: 400
++    height: 400
++    title: "releaseAfterExitTransition"
++
++    property alias popup: popup
++    property alias modalPopup: modalPopup
++
++    Popup {
++        id: popup
++        y: parent.height - height
++        width: 50
++        height: 50
++    }
++
++    Popup {
++        id: modalPopup
++        modal: true
++        y: parent.height - height
++        width: 50
++        height: 50
++        exit:  Transition { PauseAnimation { duration: 100 } }
++    }
++}
+diff --git a/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp b/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
+index 54952d128..3d50e2dd4 100644
+--- a/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
++++ b/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
+@@ -100,6 +100,7 @@ private slots:
+     void invisibleToolTipOpen();
+     void centerInOverlayWithinStackViewItem();
+     void destroyDuringExitTransition();
++    void releaseAfterExitTransition();
+ };
+ 
+ void tst_QQuickPopup::initTestCase()
+@@ -1575,6 +1576,34 @@ void tst_QQuickPopup::destroyDuringExitTransition()
+     QVERIFY(!button->isDown());
+ }
+ 
++void tst_QQuickPopup::releaseAfterExitTransition()
++{
++    QQuickApplicationHelper helper(this, "releaseAfterExitTransition.qml");
++    QVERIFY2(helper.ready, helper.failureMessage());
++
++    QQuickWindow *window = helper.window;
++    window->show();
++    QVERIFY(QTest::qWaitForWindowActive(window));
++
++    QQuickOverlay *overlay = QQuickOverlay::overlay(window);
++    QQuickPopup *modalPopup = window->property("modalPopup").value<QQuickPopup *>();
++    QQuickPopup *popup = window->property("popup").value<QQuickPopup *>();
++
++    modalPopup->open();
++    QTRY_VERIFY(modalPopup->isOpened());
++
++    QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++    // wait until the transition is finished and the overlay hides itself
++    QTRY_VERIFY(!overlay->isVisible());
++    QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++
++    popup->open();
++    QTRY_VERIFY(popup->isOpened());
++    QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++    QTRY_VERIFY(!popup->isOpened());
++}
++
++
+ QTEST_QUICKCONTROLS_MAIN(tst_QQuickPopup)
+ 
+ #include "tst_qquickpopup.moc"
+Submodule qtscript 5be95f96...4d8e4bd2 (commits not present)
+Submodule qtspeech 17fc9fde..255845e2:
+diff --git a/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp b/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
+index 6eb74b8..bcc7dd1 100644
+--- a/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
++++ b/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
+@@ -357,7 +357,9 @@ QVector<QLocale> QTextToSpeechEngineSpeechd::availableLocales() const
+ 
+ QVector<QVoice> QTextToSpeechEngineSpeechd::availableVoices() const
+ {
+-    return m_voices.values(m_currentLocale.name()).toVector();
++    QList<QVoice> resultList = m_voices.values(m_currentLocale.name());
++    std::reverse(resultList.begin(), resultList.end());
++    return resultList.toVector();
+ }
+ 
+ // We have no way of knowing our own client_id since speech-dispatcher seems to be incomplete
+Submodule qtsvg 0c05780e..a7a0f249:
+diff --git a/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp b/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
+index 561e77e..12e0574 100644
+--- a/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
++++ b/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
+@@ -191,6 +191,8 @@ bool QSvgIOHandler::read(QImage *image)
+             }
+         }
+         if (!finalSize.isEmpty()) {
++            if (qMax(finalSize.width(), finalSize.height()) > 0xffff)
++                return false; // Assume corrupted file
+             image->fill(d->backColor.rgba());
+             QPainter p(image);
+             d->r.render(&p, bounds);
+diff --git a/qtsvg/src/svg/qsvghandler.cpp b/qtsvg/src/svg/qsvghandler.cpp
+index a5f877f..8dda563 100644
+--- a/qtsvg/src/svg/qsvghandler.cpp
++++ b/qtsvg/src/svg/qsvghandler.cpp
+@@ -1393,9 +1393,10 @@ static void parseFont(QSvgNode *node,
+         case FontSizeNone:
+             break;
+         case FontSizeValue: {
+-            QSvgHandler::LengthType dummy; // should always be pixel size
+-            fontStyle->setSize(qMin(parseLength(attributes.fontSize, dummy, handler),
+-                                    qreal(0xffff)));
++            QSvgHandler::LengthType type;
++            qreal fs = parseLength(attributes.fontSize, type, handler);
++            fs = convertToPixels(fs, true, type);
++            fontStyle->setSize(qMin(fs, qreal(0xffff)));
+         }
+             break;
+         default:
+@@ -2513,6 +2514,8 @@ static bool parseAnimateTransformNode(QSvgNode *parent,
+             ++s;
+         }
+     }
++    if (vals.count() % 3 != 0)
++        return false;
+ 
+     bool ok = true;
+     int begin = parseClockValue(beginStr, &ok);
+@@ -2576,6 +2579,8 @@ static QSvgNode *createCircleNode(QSvgNode *parent,
+     qreal ncx = toDouble(cx);
+     qreal ncy = toDouble(cy);
+     qreal nr  = toDouble(r);
++    if (nr < 0.0)
++        return nullptr;
+ 
+     QRectF rect(ncx-nr, ncy-nr, nr*2, nr*2);
+     QSvgNode *circle = new QSvgCircle(parent, rect);
+@@ -3046,15 +3051,16 @@ static QSvgStyleProperty *createRadialGradientNode(QSvgNode *node,
+ 
+     qreal ncx = 0.5;
+     qreal ncy = 0.5;
+-    qreal nr  = 0.5;
+     if (!cx.isEmpty())
+         ncx = toDouble(cx);
+     if (!cy.isEmpty())
+         ncy = toDouble(cy);
++
++    qreal nr = 0.0;
+     if (!r.isEmpty())
+         nr = toDouble(r);
+-    if (nr < 0.5)
+-        nr = 0.5;
++    if (nr <= 0.0)
++        return nullptr;
+ 
+     qreal nfx = ncx;
+     if (!fx.isEmpty())
+@@ -3350,7 +3356,9 @@ static QSvgNode *createTextNode(QSvgNode *parent,
+     //### editable and rotate not handled
+     QSvgHandler::LengthType type;
+     qreal nx = parseLength(x, type, handler);
++    nx = convertToPixels(nx, true, type);
+     qreal ny = parseLength(y, type, handler);
++    ny = convertToPixels(ny, true, type);
+ 
+     QSvgNode *text = new QSvgText(parent, QPointF(nx, ny));
+     return text;
+@@ -3691,9 +3699,7 @@ void QSvgHandler::parse()
+         case QXmlStreamReader::EndElement:
+             endElement(xml->name());
+             ++remainingUnfinishedElements;
+-            // if we are using somebody else's qxmlstreamreader
+-            // we should not read until the end of the stream
+-            done = !m_ownsReader && (xml->name() == QLatin1String("svg"));
++            done = (xml->name() == QLatin1String("svg"));
+             break;
+         case QXmlStreamReader::Characters:
+             characters(xml->text());
+diff --git a/qtsvg/src/svg/qsvgstructure.cpp b/qtsvg/src/svg/qsvgstructure.cpp
+index b89608b..89c9e4e 100644
+--- a/qtsvg/src/svg/qsvgstructure.cpp
++++ b/qtsvg/src/svg/qsvgstructure.cpp
+@@ -255,9 +255,13 @@ inline static bool isSupportedSvgFeature(const QString &str)
+     };
+ 
+     if (str.length() <= MAX_WORD_LENGTH && str.length() >= MIN_WORD_LENGTH) {
++        const char16_t unicode44 = str.at(44).unicode();
++        const char16_t unicode45 = str.at(45).unicode();
++        if (unicode44 >= sizeof(asso_values) || unicode45 >= sizeof(asso_values))
++            return false;
+         const int key = str.length()
+-                        + asso_values[str.at(45).unicode()]
+-                        + asso_values[str.at(44).unicode()];
++                        + asso_values[unicode45]
++                        + asso_values[unicode44];
+         if (key <= MAX_HASH_VALUE && key >= 0)
+             return str == QLatin1String(wordlist[key]);
+     }
+diff --git a/qtsvg/src/svg/qsvgtinydocument.cpp b/qtsvg/src/svg/qsvgtinydocument.cpp
+index 63d0797..19e7154 100644
+--- a/qtsvg/src/svg/qsvgtinydocument.cpp
++++ b/qtsvg/src/svg/qsvgtinydocument.cpp
+@@ -433,8 +433,16 @@ void QSvgTinyDocument::draw(QPainter *p, QSvgExtraStates &)
+     draw(p);
+ }
+ 
++static bool isValidMatrix(const QTransform &transform)
++{
++    qreal determinant = transform.determinant();
++    return qIsFinite(determinant);
++}
++
+ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect, const QRectF &sourceRect)
+ {
++    QTransform oldTransform = p->worldTransform();
++
+     QRectF target = targetRect;
+     if (target.isEmpty()) {
+         QPaintDevice *dev = p->device();
+@@ -487,6 +495,9 @@ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect,
+         }
+ #endif
+     }
++
++    if (!isValidMatrix(p->worldTransform()))
++        p->setWorldTransform(oldTransform);
+ }
+ 
+ QRectF QSvgTinyDocument::boundsOnElement(const QString &id) const
+diff --git a/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp b/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
+index 36c76ec..db71e02 100644
+--- a/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
++++ b/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
+@@ -86,6 +86,8 @@ private slots:
+     void oss_fuzz_23731();
+     void oss_fuzz_24131();
+     void oss_fuzz_24738();
++    void illegalAnimateTransform_data();
++    void illegalAnimateTransform();
+ 
+ #ifndef QT_NO_COMPRESS
+     void testGzLoading();
+@@ -1646,5 +1648,22 @@ void tst_QSvgRenderer::oss_fuzz_24738()
+     QSvgRenderer().load(QByteArray("<svg><path d=\"a 2 1e-212.....\">"));
+ }
+ 
++void tst_QSvgRenderer::illegalAnimateTransform_data()
++{
++    QTest::addColumn<QByteArray>("svg");
++
++    QTest::newRow("case1") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" values=\"8,0,5,0\">");
++    QTest::newRow("case2") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" values=\"1,2\">");
++    QTest::newRow("case3") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" from=\".. 5 2\" to=\"f\">");
++    QTest::newRow("case4") << QByteArray("<svg><animateTransform type=\"scale\" begin=\"1\" dur=\"2\" by=\"--,..\">");
++}
++
++void tst_QSvgRenderer::illegalAnimateTransform()
++{
++    QFETCH(QByteArray, svg);
++    QSvgRenderer renderer;
++    QVERIFY(!renderer.load(svg)); // also shouldn't assert
++}
++
+ QTEST_MAIN(tst_QSvgRenderer)
+ #include "tst_qsvgrenderer.moc"
+Submodule qttools 6914f7c8..090e526e:
+diff --git a/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp b/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
+index feab1e2d5..cbfb82507 100644
+--- a/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
++++ b/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
+@@ -445,7 +445,9 @@ bool HelpGeneratorPrivate::insertFiles(const QStringList &files, const QString &
+     if (filterSetId < 0)
+         return false;
+     ++filterSetId;
+-    for (int attId : qAsConst(filterAtts)) {
++    QList<int> attValues = filterAtts.values();
++    std::sort(attValues.begin(), attValues.end());
++    for (int attId : qAsConst(attValues)) {
+         m_query->prepare(QLatin1String("INSERT INTO FileAttributeSetTable "
+             "VALUES(?, ?)"));
+         m_query->bindValue(0, filterSetId);
+Submodule qtwayland dfb0129c..2904e1b3:
+diff --git a/qtwayland/src/client/configure.json b/qtwayland/src/client/configure.json
+index 2f424580..29222357 100644
+--- a/qtwayland/src/client/configure.json
++++ b/qtwayland/src/client/configure.json
+@@ -149,8 +149,7 @@
+                     "#endif"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "vulkan-server-buffer": {
+             "label": "Vulkan Buffer Sharing",
+@@ -168,7 +167,8 @@
+                     "exportAllocInfo.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR;",
+                     "return 0;"
+                 ]
+-            }
++            },
++            "use": "wayland-client"
+         },
+         "egl_1_5-wayland": {
+             "label": "EGL 1.5 with Wayland Platform",
+@@ -183,7 +183,7 @@
+                     "eglGetPlatformDisplay(EGL_PLATFORM_WAYLAND_EXT, (struct wl_display *)(nullptr), nullptr);"
+                 ]
+             },
+-            "use": "egl"
++            "use": "egl wayland-client"
+         }
+     },
+ 
+diff --git a/qtwayland/src/client/global/qwaylandclientextension.cpp b/qtwayland/src/client/global/qwaylandclientextension.cpp
+index 125b1e19..edccfe63 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension.cpp
++++ b/qtwayland/src/client/global/qwaylandclientextension.cpp
+@@ -74,7 +74,10 @@ void QWaylandClientExtensionPrivate::handleRegistryGlobal(void *data, ::wl_regis
+ void QWaylandClientExtension::addRegistryListener()
+ {
+     Q_D(QWaylandClientExtension);
+-    d->waylandIntegration->display()->addRegistryListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++    if (!d->registered) {
++        d->waylandIntegration->display()->addRegistryListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++        d->registered = true;
++    }
+ }
+ 
+ QWaylandClientExtension::QWaylandClientExtension(const int ver)
+@@ -88,6 +91,13 @@ QWaylandClientExtension::QWaylandClientExtension(const int ver)
+     QMetaObject::invokeMethod(this, "addRegistryListener", Qt::QueuedConnection);
+ }
+ 
++QWaylandClientExtension::~QWaylandClientExtension()
++{
++    Q_D(QWaylandClientExtension);
++    if (d->registered && !QCoreApplication::closingDown())
++        d->waylandIntegration->display()->removeListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++}
++
+ QtWaylandClient::QWaylandIntegration *QWaylandClientExtension::integration() const
+ {
+     Q_D(const QWaylandClientExtension);
+diff --git a/qtwayland/src/client/global/qwaylandclientextension.h b/qtwayland/src/client/global/qwaylandclientextension.h
+index 98272e57..5bd28398 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension.h
++++ b/qtwayland/src/client/global/qwaylandclientextension.h
+@@ -63,6 +63,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandClientExtension : public QObject
+     Q_PROPERTY(bool active READ isActive NOTIFY activeChanged)
+ public:
+     QWaylandClientExtension(const int version);
++    ~QWaylandClientExtension();
+ 
+     QtWaylandClient::QWaylandIntegration *integration() const;
+     int version() const;
+diff --git a/qtwayland/src/client/global/qwaylandclientextension_p.h b/qtwayland/src/client/global/qwaylandclientextension_p.h
+index 69cc46a0..9091efbe 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension_p.h
++++ b/qtwayland/src/client/global/qwaylandclientextension_p.h
+@@ -68,6 +68,7 @@ public:
+     QtWaylandClient::QWaylandIntegration *waylandIntegration = nullptr;
+     int version = -1;
+     bool active = false;
++    bool registered = false;
+ };
+ 
+ class Q_WAYLAND_CLIENT_EXPORT QWaylandClientExtensionTemplatePrivate : public QWaylandClientExtensionPrivate
+diff --git a/qtwayland/src/client/qwaylanddatadevice.cpp b/qtwayland/src/client/qwaylanddatadevice.cpp
+index 7e2e3308..e3e60ed5 100644
+--- a/qtwayland/src/client/qwaylanddatadevice.cpp
++++ b/qtwayland/src/client/qwaylanddatadevice.cpp
+@@ -72,6 +72,8 @@ QWaylandDataDevice::QWaylandDataDevice(QWaylandDataDeviceManager *manager, QWayl
+ 
+ QWaylandDataDevice::~QWaylandDataDevice()
+ {
++    if (wl_data_device_get_version(object()) >= WL_DATA_DEVICE_RELEASE_SINCE_VERSION)
++        release();
+ }
+ 
+ QWaylandDataOffer *QWaylandDataDevice::selectionOffer() const
+@@ -110,7 +112,7 @@ QWaylandDataOffer *QWaylandDataDevice::dragOffer() const
+     return m_dragOffer.data();
+ }
+ 
+-bool QWaylandDataDevice::startDrag(QMimeData *mimeData, QWaylandWindow *icon)
++bool QWaylandDataDevice::startDrag(QMimeData *mimeData, Qt::DropActions supportedActions, QWaylandWindow *icon)
+ {
+     auto *seat = m_display->currentInputDevice();
+     auto *origin = seat->pointerFocus();
+@@ -123,7 +125,28 @@ bool QWaylandDataDevice::startDrag(QMimeData *mimeData, QWaylandWindow *icon)
+     }
+ 
+     m_dragSource.reset(new QWaylandDataSource(m_display->dndSelectionHandler(), mimeData));
++
++    if (wl_data_device_get_version(object()) >= 3)
++        m_dragSource->set_actions(dropActionsToWl(supportedActions));
++
+     connect(m_dragSource.data(), &QWaylandDataSource::cancelled, this, &QWaylandDataDevice::dragSourceCancelled);
++    connect(m_dragSource.data(), &QWaylandDataSource::dndResponseUpdated, this, [this](bool accepted, Qt::DropAction action) {
++            auto drag = static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag());
++            // in old versions drop action is not set, so we guess
++            if (wl_data_source_get_version(m_dragSource->object()) < 3) {
++                drag->setResponse(accepted);
++            } else {
++                QPlatformDropQtResponse response(accepted, action);
++                drag->setResponse(response);
++            }
++    });
++    connect(m_dragSource.data(), &QWaylandDataSource::dndDropped, this, [](bool accepted, Qt::DropAction action) {
++        QPlatformDropQtResponse response(accepted, action);
++        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setDropResponse(response);
++    });
++    connect(m_dragSource.data(), &QWaylandDataSource::finished, this, []() {
++        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag();
++    });
+ 
+     start_drag(m_dragSource->object(), origin->wlSurface(), icon->wlSurface(), m_display->currentInputDevice()->serial());
+     return true;
+@@ -152,7 +175,7 @@ void QWaylandDataDevice::data_device_drop()
+         supportedActions = drag->supportedActions();
+     } else if (m_dragOffer) {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     } else {
+         return;
+     }
+@@ -162,7 +185,11 @@ void QWaylandDataDevice::data_device_drop()
+                                                                           QGuiApplication::keyboardModifiers());
+ 
+     if (drag) {
+-        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag(response);
++        auto drag =  static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag());
++        drag->setDropResponse(response);
++        drag->finishDrag();
++    } else if (m_dragOffer) {
++        m_dragOffer->finish();
+     }
+ }
+ 
+@@ -186,7 +213,7 @@ void QWaylandDataDevice::data_device_enter(uint32_t serial, wl_surface *surface,
+         supportedActions = drag->supportedActions();
+     } else if (m_dragOffer) {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     }
+ 
+     const QPlatformDragQtResponse &response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
+@@ -197,11 +224,7 @@ void QWaylandDataDevice::data_device_enter(uint32_t serial, wl_surface *surface,
+         static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setResponse(response);
+     }
+ 
+-    if (response.isAccepted()) {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, m_dragOffer->firstFormat().toUtf8().constData());
+-    } else {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, nullptr);
+-    }
++    sendResponse(supportedActions, response);
+ }
+ 
+ void QWaylandDataDevice::data_device_leave()
+@@ -235,10 +258,10 @@ void QWaylandDataDevice::data_device_motion(uint32_t time, wl_fixed_t x, wl_fixe
+         supportedActions = drag->supportedActions();
+     } else {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     }
+ 
+-    QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
++    const QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
+                                                                           QGuiApplication::mouseButtons(),
+                                                                           QGuiApplication::keyboardModifiers());
+ 
+@@ -246,11 +269,7 @@ void QWaylandDataDevice::data_device_motion(uint32_t time, wl_fixed_t x, wl_fixe
+         static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setResponse(response);
+     }
+ 
+-    if (response.isAccepted()) {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, m_dragOffer->firstFormat().toUtf8().constData());
+-    } else {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, nullptr);
+-    }
++    sendResponse(supportedActions, response);
+ }
+ #endif // QT_CONFIG(draganddrop)
+ 
+@@ -277,14 +296,10 @@ void QWaylandDataDevice::selectionSourceCancelled()
+ #if QT_CONFIG(draganddrop)
+ void QWaylandDataDevice::dragSourceCancelled()
+ {
++    static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag();
+     m_dragSource.reset();
+ }
+ 
+-void QWaylandDataDevice::dragSourceTargetChanged(const QString &mimeType)
+-{
+-    static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->updateTarget(mimeType);
+-}
+-
+ QPoint QWaylandDataDevice::calculateDragPosition(int x, int y, QWindow *wnd) const
+ {
+     QPoint pnt(wl_fixed_to_int(x), wl_fixed_to_int(y));
+@@ -297,6 +312,33 @@ QPoint QWaylandDataDevice::calculateDragPosition(int x, int y, QWindow *wnd) con
+     }
+     return pnt;
+ }
++
++void QWaylandDataDevice::sendResponse(Qt::DropActions supportedActions, const QPlatformDragQtResponse &response)
++{
++    if (response.isAccepted()) {
++        if (wl_data_device_get_version(object()) >= 3)
++            m_dragOffer->set_actions(dropActionsToWl(supportedActions), dropActionsToWl(response.acceptedAction()));
++
++        m_dragOffer->accept(m_enterSerial, m_dragOffer->firstFormat());
++    } else {
++        m_dragOffer->accept(m_enterSerial, QString());
++    }
++}
++
++int QWaylandDataDevice::dropActionsToWl(Qt::DropActions actions)
++{
++
++    int wlActions = WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE;
++    if (actions & Qt::CopyAction)
++        wlActions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY;
++    if (actions & (Qt::MoveAction | Qt::TargetMoveAction))
++        wlActions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE;
++
++    // wayland does not support LinkAction at the time of writing
++    return wlActions;
++}
++
++
+ #endif // QT_CONFIG(draganddrop)
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddatadevice_p.h b/qtwayland/src/client/qwaylanddatadevice_p.h
+index 16c3ad28..801dcc2c 100644
+--- a/qtwayland/src/client/qwaylanddatadevice_p.h
++++ b/qtwayland/src/client/qwaylanddatadevice_p.h
+@@ -64,6 +64,7 @@ QT_REQUIRE_CONFIG(wayland_datadevice);
+ QT_BEGIN_NAMESPACE
+ 
+ class QMimeData;
++class QPlatformDragQtResponse;
+ class QWindow;
+ 
+ namespace QtWaylandClient {
+@@ -89,7 +90,7 @@ public:
+ 
+ #if QT_CONFIG(draganddrop)
+     QWaylandDataOffer *dragOffer() const;
+-    bool startDrag(QMimeData *mimeData, QWaylandWindow *icon);
++    bool startDrag(QMimeData *mimeData, Qt::DropActions supportedActions, QWaylandWindow *icon);
+     void cancelDrag();
+ #endif
+ 
+@@ -109,13 +110,16 @@ private Q_SLOTS:
+ 
+ #if QT_CONFIG(draganddrop)
+     void dragSourceCancelled();
+-    void dragSourceTargetChanged(const QString &mimeType);
+ #endif
+ 
+ private:
+ #if QT_CONFIG(draganddrop)
+     QPoint calculateDragPosition(int x, int y, QWindow *wnd) const;
+ #endif
++    void sendResponse(Qt::DropActions supportedActions, const QPlatformDragQtResponse &response);
++
++    static int dropActionsToWl(Qt::DropActions dropActions);
++
+ 
+     QWaylandDisplay *m_display = nullptr;
+     QWaylandInputDevice *m_inputDevice = nullptr;
+diff --git a/qtwayland/src/client/qwaylanddatadevicemanager.cpp b/qtwayland/src/client/qwaylanddatadevicemanager.cpp
+index 35d67307..6dc4f77f 100644
+--- a/qtwayland/src/client/qwaylanddatadevicemanager.cpp
++++ b/qtwayland/src/client/qwaylanddatadevicemanager.cpp
+@@ -50,8 +50,8 @@ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
+-QWaylandDataDeviceManager::QWaylandDataDeviceManager(QWaylandDisplay *display, uint32_t id)
+-    : wl_data_device_manager(display->wl_registry(), id, 1)
++QWaylandDataDeviceManager::QWaylandDataDeviceManager(QWaylandDisplay *display, int version, uint32_t id)
++    : wl_data_device_manager(display->wl_registry(), id, qMin(version, 3))
+     , m_display(display)
+ {
+     // Create transfer devices for all input devices.
+diff --git a/qtwayland/src/client/qwaylanddatadevicemanager_p.h b/qtwayland/src/client/qwaylanddatadevicemanager_p.h
+index bd05c0fb..510d9be4 100644
+--- a/qtwayland/src/client/qwaylanddatadevicemanager_p.h
++++ b/qtwayland/src/client/qwaylanddatadevicemanager_p.h
+@@ -68,7 +68,7 @@ class QWaylandInputDevice;
+ class Q_WAYLAND_CLIENT_EXPORT QWaylandDataDeviceManager : public QtWayland::wl_data_device_manager
+ {
+ public:
+-    QWaylandDataDeviceManager(QWaylandDisplay *display, uint32_t id);
++    QWaylandDataDeviceManager(QWaylandDisplay *display, int version, uint32_t id);
+     ~QWaylandDataDeviceManager() override;
+ 
+     QWaylandDataDevice *getDataDevice(QWaylandInputDevice *inputDevice);
+diff --git a/qtwayland/src/client/qwaylanddataoffer.cpp b/qtwayland/src/client/qwaylanddataoffer.cpp
+index 2297e8a1..fe0ea8c9 100644
+--- a/qtwayland/src/client/qwaylanddataoffer.cpp
++++ b/qtwayland/src/client/qwaylanddataoffer.cpp
+@@ -82,6 +82,15 @@ QMimeData *QWaylandDataOffer::mimeData()
+     return m_mimeData.data();
+ }
+ 
++Qt::DropActions QWaylandDataOffer::supportedActions() const
++{
++    if (wl_data_offer_get_version(const_cast<::wl_data_offer*>(object())) < 3) {
++        return Qt::MoveAction | Qt::CopyAction;
++    }
++
++    return m_supportedActions;
++}
++
+ void QWaylandDataOffer::startReceiving(const QString &mimeType, int fd)
+ {
+     receive(mimeType, fd);
+@@ -93,6 +102,22 @@ void QWaylandDataOffer::data_offer_offer(const QString &mime_type)
+     m_mimeData->appendFormat(mime_type);
+ }
+ 
++void QWaylandDataOffer::data_offer_action(uint32_t dnd_action)
++{
++    Q_UNUSED(dnd_action);
++    // This is the compositor telling the drag target what action it should perform
++    // It does not map nicely into Qt final drop semantics, other than pretending there is only one supported action?
++}
++
++void QWaylandDataOffer::data_offer_source_actions(uint32_t source_actions)
++{
++    m_supportedActions = Qt::DropActions();
++    if (source_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
++        m_supportedActions |= Qt::MoveAction;
++    if (source_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
++        m_supportedActions |= Qt::CopyAction;
++}
++
+ QWaylandMimeData::QWaylandMimeData(QWaylandAbstractDataOffer *dataOffer)
+     : m_dataOffer(dataOffer)
+ {
+@@ -163,17 +188,18 @@ QVariant QWaylandMimeData::retrieveData_sys(const QString &mimeType, QVariant::T
+ 
+ int QWaylandMimeData::readData(int fd, QByteArray &data) const
+ {
+-    fd_set readset;
+-    FD_ZERO(&readset);
+-    FD_SET(fd, &readset);
+-    struct timeval timeout;
++    struct pollfd readset;
++    readset.fd = fd;
++    readset.events = POLLIN;
++    struct timespec timeout;
+     timeout.tv_sec = 1;
+-    timeout.tv_usec = 0;
++    timeout.tv_nsec = 0;
++
+ 
+     Q_FOREVER {
+-        int ready = select(FD_SETSIZE, &readset, nullptr, nullptr, &timeout);
++        int ready = qt_safe_poll(&readset, 1, &timeout);
+         if (ready < 0) {
+-            qWarning() << "QWaylandDataOffer: select() failed";
++            qWarning() << "QWaylandDataOffer: qt_safe_poll() failed";
+             return -1;
+         } else if (ready == 0) {
+             qWarning("QWaylandDataOffer: timeout reading from pipe");
+diff --git a/qtwayland/src/client/qwaylanddataoffer_p.h b/qtwayland/src/client/qwaylanddataoffer_p.h
+index 9cf1483c..6f667398 100644
+--- a/qtwayland/src/client/qwaylanddataoffer_p.h
++++ b/qtwayland/src/client/qwaylanddataoffer_p.h
+@@ -82,6 +82,7 @@ public:
+     explicit QWaylandDataOffer(QWaylandDisplay *display, struct ::wl_data_offer *offer);
+     ~QWaylandDataOffer() override;
+     QMimeData *mimeData() override;
++    Qt::DropActions supportedActions() const;
+ 
+     QString firstFormat() const;
+ 
+@@ -89,10 +90,13 @@ public:
+ 
+ protected:
+     void data_offer_offer(const QString &mime_type) override;
++    void data_offer_source_actions(uint32_t source_actions) override;
++    void data_offer_action(uint32_t dnd_action) override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+     QScopedPointer<QWaylandMimeData> m_mimeData;
++    Qt::DropActions m_supportedActions;
+ };
+ 
+ 
+diff --git a/qtwayland/src/client/qwaylanddatasource.cpp b/qtwayland/src/client/qwaylanddatasource.cpp
+index f45122fb..5599cbd4 100644
+--- a/qtwayland/src/client/qwaylanddatasource.cpp
++++ b/qtwayland/src/client/qwaylanddatasource.cpp
+@@ -101,7 +101,32 @@ void QWaylandDataSource::data_source_send(const QString &mime_type, int32_t fd)
+ 
+ void QWaylandDataSource::data_source_target(const QString &mime_type)
+ {
+-    Q_EMIT targetChanged(mime_type);
++    m_accepted = !mime_type.isEmpty();
++    Q_EMIT dndResponseUpdated(m_accepted, m_dropAction);
++}
++
++void QWaylandDataSource::data_source_action(uint32_t action)
++{
++    Qt::DropAction qtAction = Qt::IgnoreAction;
++
++    if (action == WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
++        qtAction = Qt::MoveAction;
++    else if (action == WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
++        qtAction = Qt::CopyAction;
++
++    m_dropAction = qtAction;
++    Q_EMIT dndResponseUpdated(m_accepted, m_dropAction);
++}
++
++void QWaylandDataSource::data_source_dnd_finished()
++{
++    Q_EMIT finished();
++}
++
++void QWaylandDataSource::data_source_dnd_drop_performed()
++{
++
++    Q_EMIT dndDropped(m_accepted, m_dropAction);
+ }
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddatasource_p.h b/qtwayland/src/client/qwaylanddatasource_p.h
+index 25afff79..96f07bc3 100644
+--- a/qtwayland/src/client/qwaylanddatasource_p.h
++++ b/qtwayland/src/client/qwaylanddatasource_p.h
+@@ -77,17 +77,25 @@ public:
+     QMimeData *mimeData() const;
+ 
+ Q_SIGNALS:
+-    void targetChanged(const QString &mime_type);
+     void cancelled();
++    void finished();
++
++    void dndResponseUpdated(bool accepted, Qt::DropAction action);
++    void dndDropped(bool accepted, Qt::DropAction action);
+ 
+ protected:
+     void data_source_cancelled() override;
+     void data_source_send(const QString &mime_type, int32_t fd) override;
+     void data_source_target(const QString &mime_type) override;
++    void data_source_dnd_drop_performed() override;
++    void data_source_dnd_finished() override;
++    void data_source_action(uint32_t action) override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+     QMimeData *m_mime_data = nullptr;
++    bool m_accepted = false;
++    Qt::DropAction m_dropAction = Qt::IgnoreAction;
+ };
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddisplay.cpp b/qtwayland/src/client/qwaylanddisplay.cpp
+index f10c1f79..c01e238b 100644
+--- a/qtwayland/src/client/qwaylanddisplay.cpp
++++ b/qtwayland/src/client/qwaylanddisplay.cpp
+@@ -85,10 +85,203 @@
+ 
+ #include <errno.h>
+ 
++#include <tuple> // for std::tie
++
++static void checkWaylandError(struct wl_display *display)
++{
++    int ecode = wl_display_get_error(display);
++    if ((ecode == EPIPE || ecode == ECONNRESET)) {
++        // special case this to provide a nicer error
++        qWarning("The Wayland connection broke. Did the Wayland compositor die?");
++    } else {
++        qWarning("The Wayland connection experienced a fatal error: %s", strerror(ecode));
++    }
++    _exit(1);
++}
++
+ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
++class EventThread : public QThread
++{
++    Q_OBJECT
++public:
++    enum OperatingMode {
++        EmitToDispatch, // Emit the signal, allow dispatching in a differnt thread.
++        SelfDispatch, // Dispatch the events inside this thread.
++    };
++
++    EventThread(struct wl_display * wl, struct wl_event_queue * ev_queue,
++                OperatingMode mode)
++        : m_fd(wl_display_get_fd(wl))
++        , m_pipefd{ -1, -1 }
++        , m_wldisplay(wl)
++        , m_wlevqueue(ev_queue)
++        , m_mode(mode)
++        , m_reading(true)
++        , m_quitting(false)
++    {
++        setObjectName(QStringLiteral("WaylandEventThread"));
++    }
++
++    void readAndDispatchEvents()
++    {
++        /*
++         * Dispatch pending events and flush the requests at least once. If the event thread
++         * is not reading, try to call _prepare_read() to allow the event thread to poll().
++         * If that fails, re-try dispatch & flush again until _prepare_read() is successful.
++         *
++         * This allow any call to readAndDispatchEvents() to start event thread's polling,
++         * not only the one issued from event thread's waitForReading(), which means functions
++         * called from dispatch_pending() can safely spin an event loop.
++         */
++        for (;;) {
++            if (dispatchQueuePending() < 0) {
++                checkWaylandError(m_wldisplay);
++                return;
++            }
++
++            wl_display_flush(m_wldisplay);
++
++            // We have to check if event thread is reading every time we dispatch
++            // something, as that may recursively call this function.
++            if (m_reading.loadAcquire())
++                break;
++
++            if (prepareReadQueue() == 0) {
++                QMutexLocker l(&m_mutex);
++                m_reading.storeRelease(true);
++                m_cond.wakeOne();
++                break;
++            }
++        }
++    }
++
++    void stop()
++    {
++        // We have to both write to the pipe and set the flag, as the thread may be
++        // either in the poll() or waiting for _prepare_read().
++        if (m_pipefd[1] != -1 && write(m_pipefd[1], "\0", 1) == -1)
++            qWarning("Failed to write to the pipe: %s.", strerror(errno));
++
++        {
++            QMutexLocker l(&m_mutex);
++            m_quitting = true;
++            m_cond.wakeOne();
++        }
++
++        wait();
++    }
++
++Q_SIGNALS:
++    void needReadAndDispatch();
++
++protected:
++    void run() override
++    {
++        // we use this pipe to make the loop exit otherwise if we simply used a flag on the loop condition, if stop() gets
++        // called while poll() is blocking the thread will never quit since there are no wayland messages coming anymore.
++        struct Pipe
++        {
++            Pipe(int *fds)
++                : fds(fds)
++            {
++                if (qt_safe_pipe(fds) != 0)
++                    qWarning("Pipe creation failed. Quitting may hang.");
++            }
++            ~Pipe()
++            {
++                if (fds[0] != -1) {
++                    close(fds[0]);
++                    close(fds[1]);
++                }
++            }
++
++            int *fds;
++        } pipe(m_pipefd);
++
++        // Make the main thread call wl_prepare_read(), dispatch the pending messages and flush the
++        // outbound ones. Wait until it's done before proceeding, unless we're told to quit.
++        while (waitForReading()) {
++            pollfd fds[2] = { { m_fd, POLLIN, 0 }, { m_pipefd[0], POLLIN, 0 } };
++            poll(fds, 2, -1);
++
++            if (fds[1].revents & POLLIN) {
++                // we don't really care to read the byte that was written here since we're closing down
++                wl_display_cancel_read(m_wldisplay);
++                break;
++            }
++
++            if (fds[0].revents & POLLIN)
++                wl_display_read_events(m_wldisplay);
++                // The polll was succesfull and the event thread did the wl_display_read_events(). On the next iteration of the loop
++                // the event sent to the main thread will cause it to dispatch the messages just read, unless the loop exits in which
++                // case we don't care anymore about them.
++            else
++                wl_display_cancel_read(m_wldisplay);
++        }
++    }
++
++private:
++    bool waitForReading()
++    {
++        Q_ASSERT(QThread::currentThread() == this);
++
++        m_reading.storeRelease(false);
++
++        if (m_mode == SelfDispatch) {
++            readAndDispatchEvents();
++        } else {
++            Q_EMIT needReadAndDispatch();
++
++            QMutexLocker lock(&m_mutex);
++            // m_reading might be set from our emit or some other invocation of
++            // readAndDispatchEvents().
++            while (!m_reading.loadRelaxed() && !m_quitting)
++                m_cond.wait(&m_mutex);
++        }
++
++        return !m_quitting;
++    }
++
++    int dispatchQueuePending()
++    {
++        if (m_wlevqueue)
++            return wl_display_dispatch_queue_pending(m_wldisplay, m_wlevqueue);
++        else
++            return wl_display_dispatch_pending(m_wldisplay);
++    }
++
++    int prepareReadQueue()
++    {
++        if (m_wlevqueue)
++            return wl_display_prepare_read_queue(m_wldisplay, m_wlevqueue);
++        else
++            return wl_display_prepare_read(m_wldisplay);
++    }
++
++    int m_fd;
++    int m_pipefd[2];
++    wl_display *m_wldisplay;
++    wl_event_queue *m_wlevqueue;
++    OperatingMode m_mode;
++
++    /* Concurrency note when operating in EmitToDispatch mode:
++     * m_reading is set to false inside event thread's waitForReading(), and is
++     * set to true inside main thread's readAndDispatchEvents().
++     * The lock is not taken when setting m_reading to false, as the main thread
++     * is not actively waiting for it to turn false. However, the lock is taken
++     * inside readAndDispatchEvents() before setting m_reading to true,
++     * as the event thread is actively waiting for it under the wait condition.
++     */
++
++    QAtomicInteger<bool> m_reading;
++    bool m_quitting;
++    QMutex m_mutex;
++    QWaitCondition m_cond;
++};
++
+ Q_LOGGING_CATEGORY(lcQpaWayland, "qt.qpa.wayland"); // for general (uncategorized) Wayland platform logging
+ 
+ struct wl_surface *QWaylandDisplay::createSurface(void *handle)
+@@ -158,17 +351,16 @@ QWaylandDisplay::QWaylandDisplay(QWaylandIntegration *waylandIntegration)
+     if (!mXkbContext)
+         qCWarning(lcQpaWayland, "failed to create xkb context");
+ #endif
+-
+-    forceRoundTrip();
+-
+-    if (!mWaitingScreens.isEmpty()) {
+-        // Give wl_output.done and zxdg_output_v1.done events a chance to arrive
+-        forceRoundTrip();
+-    }
+ }
+ 
+ QWaylandDisplay::~QWaylandDisplay(void)
+ {
++    if (m_eventThread)
++        m_eventThread->stop();
++
++    if (m_frameEventQueueThread)
++        m_frameEventQueueThread->stop();
++
+     if (mSyncCallback)
+         wl_callback_destroy(mSyncCallback);
+ 
+@@ -187,6 +379,21 @@ QWaylandDisplay::~QWaylandDisplay(void)
+ #endif
+     if (mDisplay)
+         wl_display_disconnect(mDisplay);
++
++    if (m_frameEventQueue)
++        wl_event_queue_destroy(m_frameEventQueue);
++}
++
++// Steps which is called just after constructor. This separates registry_global() out of the constructor
++// so that factory functions in integration can be overridden.
++void QWaylandDisplay::initialize()
++{
++    forceRoundTrip();
++
++    if (!mWaitingScreens.isEmpty()) {
++        // Give wl_output.done and zxdg_output_v1.done events a chance to arrive
++        forceRoundTrip();
++    }
+ }
+ 
+ void QWaylandDisplay::ensureScreen()
+@@ -203,98 +410,37 @@ void QWaylandDisplay::ensureScreen()
+ 
+ void QWaylandDisplay::checkError() const
+ {
+-    int ecode = wl_display_get_error(mDisplay);
+-    if ((ecode == EPIPE || ecode == ECONNRESET)) {
+-        // special case this to provide a nicer error
+-        qWarning("The Wayland connection broke. Did the Wayland compositor die?");
+-    } else {
+-        qWarning("The Wayland connection experienced a fatal error: %s", strerror(ecode));
+-    }
+-    _exit(1);
++    checkWaylandError(mDisplay);
+ }
+ 
++// Called in main thread, either from queued signal or directly.
+ void QWaylandDisplay::flushRequests()
+ {
+-    if (wl_display_prepare_read(mDisplay) == 0) {
+-        wl_display_read_events(mDisplay);
+-    }
+-
+-    if (wl_display_dispatch_pending(mDisplay) < 0)
+-        checkError();
+-
+-    {
+-        QReadLocker locker(&m_frameQueueLock);
+-        for (const FrameQueue &q : mExternalQueues) {
+-            QMutexLocker locker(q.mutex);
+-            while (wl_display_prepare_read_queue(mDisplay, q.queue) != 0)
+-                wl_display_dispatch_queue_pending(mDisplay, q.queue);
+-            wl_display_read_events(mDisplay);
+-            wl_display_dispatch_queue_pending(mDisplay, q.queue);
+-        }
+-    }
+-
+-    wl_display_flush(mDisplay);
+-}
+-
+-void QWaylandDisplay::blockingReadEvents()
+-{
+-    if (wl_display_dispatch(mDisplay) < 0)
+-        checkError();
+-}
+-
+-void QWaylandDisplay::destroyFrameQueue(const QWaylandDisplay::FrameQueue &q)
+-{
+-    QWriteLocker locker(&m_frameQueueLock);
+-    auto it = std::find_if(mExternalQueues.begin(),
+-                           mExternalQueues.end(),
+-                           [&q] (const QWaylandDisplay::FrameQueue &other){ return other.queue == q.queue; });
+-    Q_ASSERT(it != mExternalQueues.end());
+-    mExternalQueues.erase(it);
+-    if (q.queue != nullptr)
+-        wl_event_queue_destroy(q.queue);
+-    delete q.mutex;
++    m_eventThread->readAndDispatchEvents();
+ }
+ 
+-QWaylandDisplay::FrameQueue QWaylandDisplay::createFrameQueue()
++// We have to wait until we have an eventDispatcher before creating the eventThread,
++// otherwise forceRoundTrip() may block inside _events_read() because eventThread is
++// polling.
++void QWaylandDisplay::initEventThread()
+ {
+-    QWriteLocker locker(&m_frameQueueLock);
+-    FrameQueue q{createEventQueue()};
+-    mExternalQueues.append(q);
+-    return q;
+-}
++    m_eventThread.reset(
++            new EventThread(mDisplay, /* default queue */ nullptr, EventThread::EmitToDispatch));
++    connect(m_eventThread.get(), &EventThread::needReadAndDispatch, this,
++            &QWaylandDisplay::flushRequests, Qt::QueuedConnection);
++    m_eventThread->start();
+ 
+-wl_event_queue *QWaylandDisplay::createEventQueue()
+-{
+-    return wl_display_create_queue(mDisplay);
++    // wl_display_disconnect() free this.
++    m_frameEventQueue = wl_display_create_queue(mDisplay);
++    m_frameEventQueueThread.reset(
++            new EventThread(mDisplay, m_frameEventQueue, EventThread::SelfDispatch));
++    m_frameEventQueueThread->start();
+ }
+ 
+-void QWaylandDisplay::dispatchQueueWhile(wl_event_queue *queue, std::function<bool ()> condition, int timeout)
++void QWaylandDisplay::blockingReadEvents()
+ {
+-    if (!condition())
+-        return;
+-
+-    QElapsedTimer timer;
+-    timer.start();
+-    struct pollfd pFd = qt_make_pollfd(wl_display_get_fd(mDisplay), POLLIN);
+-    while (timeout == -1 || timer.elapsed() < timeout) {
+-        while (wl_display_prepare_read_queue(mDisplay, queue) != 0)
+-            wl_display_dispatch_queue_pending(mDisplay, queue);
+-
+-        wl_display_flush(mDisplay);
+-
+-        const int remaining = qMax(timeout - timer.elapsed(), 0ll);
+-        const int pollTimeout = timeout == -1 ? -1 : remaining;
+-        if (qt_poll_msecs(&pFd, 1, pollTimeout) > 0)
+-            wl_display_read_events(mDisplay);
+-        else
+-            wl_display_cancel_read(mDisplay);
+-
+-        if (wl_display_dispatch_queue_pending(mDisplay, queue) < 0)
+-            checkError();
+-
+-        if (!condition())
+-            break;
+-    }
++    if (wl_display_dispatch(mDisplay) < 0)
++        checkWaylandError(mDisplay);
+ }
+ 
+ QWaylandScreen *QWaylandDisplay::screenForOutput(struct wl_output *output) const
+@@ -345,7 +491,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+     if (interface == QStringLiteral("wl_output")) {
+         mWaitingScreens << new QWaylandScreen(this, version, id);
+     } else if (interface == QStringLiteral("wl_compositor")) {
+-        mCompositorVersion = qMin((int)version, 3);
++        mCompositorVersion = qMin((int)version, 4);
+         mCompositor.init(registry, id, mCompositorVersion);
+     } else if (interface == QStringLiteral("wl_shm")) {
+         mShm.reset(new QWaylandShm(this, version, id));
+@@ -354,7 +500,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+         mInputDevices.append(inputDevice);
+ #if QT_CONFIG(wayland_datadevice)
+     } else if (interface == QStringLiteral("wl_data_device_manager")) {
+-        mDndSelectionHandler.reset(new QWaylandDataDeviceManager(this, id));
++        mDndSelectionHandler.reset(new QWaylandDataDeviceManager(this, version, id));
+ #endif
+     } else if (interface == QStringLiteral("qt_surface_extension")) {
+         mWindowExtension.reset(new QtWayland::qt_surface_extension(registry, id, 1));
+@@ -369,6 +515,8 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+ #if QT_CONFIG(wayland_client_primary_selection)
+     } else if (interface == QStringLiteral("zwp_primary_selection_device_manager_v1")) {
+         mPrimarySelectionManager.reset(new QWaylandPrimarySelectionDeviceManagerV1(this, id, 1));
++        for (QWaylandInputDevice *inputDevice : qAsConst(mInputDevices))
++            inputDevice->setPrimarySelectionDevice(mPrimarySelectionManager->createDevice(inputDevice));
+ #endif
+     } else if (interface == QStringLiteral("zwp_text_input_manager_v2") && !mClientSideInputContextRequested) {
+         mTextInputManager.reset(new QtWayland::zwp_text_input_manager_v2(registry, id, 1));
+@@ -427,6 +575,13 @@ void QWaylandDisplay::registry_global_remove(uint32_t id)
+                     inputDevice->setTextInput(nullptr);
+                 mWaylandIntegration->reconfigureInputContext();
+             }
++#if QT_CONFIG(wayland_client_primary_selection)
++            if (global.interface == QStringLiteral("zwp_primary_selection_device_manager_v1")) {
++                mPrimarySelectionManager.reset();
++                for (QWaylandInputDevice *inputDevice : qAsConst(mInputDevices))
++                    inputDevice->setPrimarySelectionDevice(nullptr);
++            }
++#endif
+             mGlobals.removeAt(i);
+             break;
+         }
+@@ -452,9 +607,10 @@ void QWaylandDisplay::addRegistryListener(RegistryListener listener, void *data)
+ 
+ void QWaylandDisplay::removeListener(RegistryListener listener, void *data)
+ {
+-    std::remove_if(mRegistryListeners.begin(), mRegistryListeners.end(), [=](Listener l){
++    auto iter = std::remove_if(mRegistryListeners.begin(), mRegistryListeners.end(), [=](Listener l){
+         return (l.listener == listener && l.data == data);
+     });
++    mRegistryListeners.erase(iter, mRegistryListeners.end());
+ }
+ 
+ uint32_t QWaylandDisplay::currentTimeMillisec()
+@@ -467,50 +623,9 @@ uint32_t QWaylandDisplay::currentTimeMillisec()
+     return 0;
+ }
+ 
+-static void
+-sync_callback(void *data, struct wl_callback *callback, uint32_t serial)
+-{
+-    Q_UNUSED(serial)
+-    bool *done = static_cast<bool *>(data);
+-
+-    *done = true;
+-
+-    // If the wl_callback done event is received after the condition check in the while loop in
+-    // forceRoundTrip(), but before the call to processEvents, the call to processEvents may block
+-    // forever if no more events are posted (eventhough the callback is handled in response to the
+-    // aboutToBlock signal). Hence, we wake up the event dispatcher so forceRoundTrip may return.
+-    // (QTBUG-64696)
+-    if (auto *dispatcher = QThread::currentThread()->eventDispatcher())
+-        dispatcher->wakeUp();
+-
+-    wl_callback_destroy(callback);
+-}
+-
+-static const struct wl_callback_listener sync_listener = {
+-    sync_callback
+-};
+-
+ void QWaylandDisplay::forceRoundTrip()
+ {
+-    // wl_display_roundtrip() works on the main queue only,
+-    // but we use a separate one, so basically reimplement it here
+-    int ret = 0;
+-    bool done = false;
+-    wl_callback *callback = wl_display_sync(mDisplay);
+-    wl_callback_add_listener(callback, &sync_listener, &done);
+-    flushRequests();
+-    if (QThread::currentThread()->eventDispatcher()) {
+-        while (!done && ret >= 0) {
+-            QThread::currentThread()->eventDispatcher()->processEvents(QEventLoop::WaitForMoreEvents);
+-            ret = wl_display_dispatch_pending(mDisplay);
+-        }
+-    } else {
+-        while (!done && ret >= 0)
+-            ret = wl_display_dispatch(mDisplay);
+-    }
+-
+-    if (ret == -1 && !done)
+-        wl_callback_destroy(callback);
++     wl_display_roundtrip(mDisplay);
+ }
+ 
+ bool QWaylandDisplay::supportsWindowDecoration() const
+@@ -574,14 +689,10 @@ void QWaylandDisplay::handleKeyboardFocusChanged(QWaylandInputDevice *inputDevic
+     if (mLastKeyboardFocus == keyboardFocus)
+         return;
+ 
+-    if (mWaylandIntegration->mShellIntegration) {
+-        mWaylandIntegration->mShellIntegration->handleKeyboardFocusChanged(keyboardFocus, mLastKeyboardFocus);
+-    } else {
+-        if (keyboardFocus)
+-            handleWindowActivated(keyboardFocus);
+-        if (mLastKeyboardFocus)
+-            handleWindowDeactivated(mLastKeyboardFocus);
+-    }
++    if (keyboardFocus)
++        handleWindowActivated(keyboardFocus);
++    if (mLastKeyboardFocus)
++        handleWindowDeactivated(mLastKeyboardFocus);
+ 
+     mLastKeyboardFocus = keyboardFocus;
+ }
+@@ -600,6 +711,19 @@ void QWaylandDisplay::handleWaylandSync()
+     QWindow *activeWindow = mActiveWindows.empty() ? nullptr : mActiveWindows.last()->window();
+     if (activeWindow != QGuiApplication::focusWindow())
+         QWindowSystemInterface::handleWindowActivated(activeWindow);
++
++    if (!activeWindow) {
++        if (lastInputDevice()) {
++#if QT_CONFIG(clipboard)
++            if (auto *dataDevice = lastInputDevice()->dataDevice())
++                dataDevice->invalidateSelectionOffer();
++#endif
++#if QT_CONFIG(wayland_client_primary_selection)
++            if (auto *device = lastInputDevice()->primarySelectionDevice())
++                device->invalidateSelectionOffer();
++#endif
++        }
++    }
+ }
+ 
+ const wl_callback_listener QWaylandDisplay::syncCallbackListener = {
+@@ -626,6 +750,13 @@ QWaylandInputDevice *QWaylandDisplay::defaultInputDevice() const
+     return mInputDevices.isEmpty() ? 0 : mInputDevices.first();
+ }
+ 
++bool QWaylandDisplay::isKeyboardAvailable() const
++{
++    return std::any_of(
++            mInputDevices.constBegin(), mInputDevices.constEnd(),
++            [this](const QWaylandInputDevice *device) { return device->keyboard() != nullptr; });
++}
++
+ #if QT_CONFIG(cursor)
+ 
+ QWaylandCursor *QWaylandDisplay::waylandCursor()
+@@ -652,4 +783,6 @@ QWaylandCursorTheme *QWaylandDisplay::loadCursorTheme(const QString &name, int p
+ 
+ } // namespace QtWaylandClient
+ 
++#include "qwaylanddisplay.moc"
++
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/client/qwaylanddisplay_p.h b/qtwayland/src/client/qwaylanddisplay_p.h
+index 3b092bc8..42bc661d 100644
+--- a/qtwayland/src/client/qwaylanddisplay_p.h
++++ b/qtwayland/src/client/qwaylanddisplay_p.h
+@@ -109,6 +109,7 @@ class QWaylandSurface;
+ class QWaylandShellIntegration;
+ class QWaylandCursor;
+ class QWaylandCursorTheme;
++class EventThread;
+ 
+ typedef void (*RegistryListener)(void *data,
+                                  struct wl_registry *registry,
+@@ -120,15 +121,11 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandDisplay : public QObject, public QtWayland
+     Q_OBJECT
+ 
+ public:
+-    struct FrameQueue {
+-        FrameQueue(wl_event_queue *q = nullptr) : queue(q), mutex(new QMutex) {}
+-        wl_event_queue *queue;
+-        QMutex *mutex;
+-    };
+-
+     QWaylandDisplay(QWaylandIntegration *waylandIntegration);
+     ~QWaylandDisplay(void) override;
+ 
++    void initialize();
++
+ #if QT_CONFIG(xkbcommon)
+     struct xkb_context *xkbContext() const { return mXkbContext.get(); }
+ #endif
+@@ -210,11 +207,11 @@ public:
+     void handleKeyboardFocusChanged(QWaylandInputDevice *inputDevice);
+     void handleWindowDestroyed(QWaylandWindow *window);
+ 
+-    wl_event_queue *createEventQueue();
+-    FrameQueue createFrameQueue();
+-    void destroyFrameQueue(const FrameQueue &q);
+-    void dispatchQueueWhile(wl_event_queue *queue, std::function<bool()> condition, int timeout = -1);
++    wl_event_queue *frameEventQueue() { return m_frameEventQueue; };
++
++    bool isKeyboardAvailable() const;
+ 
++    void initEventThread();
+ public slots:
+     void blockingReadEvents();
+     void flushRequests();
+@@ -237,6 +234,9 @@ private:
+     };
+ 
+     struct wl_display *mDisplay = nullptr;
++    QScopedPointer<EventThread> m_eventThread;
++    wl_event_queue *m_frameEventQueue = nullptr;
++    QScopedPointer<EventThread> m_frameEventQueueThread;
+     QtWayland::wl_compositor mCompositor;
+     QScopedPointer<QWaylandShm> mShm;
+     QList<QWaylandScreen *> mWaitingScreens;
+@@ -273,11 +273,9 @@ private:
+     QWaylandInputDevice *mLastInputDevice = nullptr;
+     QPointer<QWaylandWindow> mLastInputWindow;
+     QPointer<QWaylandWindow> mLastKeyboardFocus;
+-    QVector<QWaylandWindow *> mActiveWindows;
+-    QVector<FrameQueue> mExternalQueues;
++    QList<QWaylandWindow *> mActiveWindows;
+     struct wl_callback *mSyncCallback = nullptr;
+     static const wl_callback_listener syncCallbackListener;
+-    QReadWriteLock m_frameQueueLock;
+ 
+     bool mClientSideInputContextRequested = !QPlatformInputContextFactory::requested().isNull();
+ 
+diff --git a/qtwayland/src/client/qwaylanddnd.cpp b/qtwayland/src/client/qwaylanddnd.cpp
+index 6535aa16..7c53f5fa 100644
+--- a/qtwayland/src/client/qwaylanddnd.cpp
++++ b/qtwayland/src/client/qwaylanddnd.cpp
+@@ -66,7 +66,7 @@ void QWaylandDrag::startDrag()
+ {
+     QBasicDrag::startDrag();
+     QWaylandWindow *icon = static_cast<QWaylandWindow *>(shapedPixmapWindow()->handle());
+-    if (m_display->currentInputDevice()->dataDevice()->startDrag(drag()->mimeData(), icon)) {
++    if (m_display->currentInputDevice()->dataDevice()->startDrag(drag()->mimeData(), drag()->supportedActions(), icon)) {
+         icon->addAttachOffset(-drag()->hotSpot());
+     } else {
+         // Cancelling immediately does not work, since the event loop for QDrag::exec is started
+@@ -80,6 +80,9 @@ void QWaylandDrag::cancel()
+     QBasicDrag::cancel();
+ 
+     m_display->currentInputDevice()->dataDevice()->cancelDrag();
++
++    if (drag())
++        drag()->deleteLater();
+ }
+ 
+ void QWaylandDrag::move(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods)
+@@ -103,33 +106,41 @@ void QWaylandDrag::endDrag()
+     m_display->currentInputDevice()->handleEndDrag();
+ }
+ 
+-void QWaylandDrag::updateTarget(const QString &mimeType)
++void QWaylandDrag::setResponse(bool accepted)
+ {
+-    setCanDrop(!mimeType.isEmpty());
+-
+-    if (canDrop()) {
+-        updateCursor(defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers()));
+-    } else {
+-        updateCursor(Qt::IgnoreAction);
+-    }
++    // This method is used for old DataDevices where the drag action is not communicated
++    Qt::DropAction action = defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers());
++    setResponse(QPlatformDropQtResponse(accepted, action));
+ }
+ 
+-void QWaylandDrag::setResponse(const QPlatformDragQtResponse &response)
++void QWaylandDrag::setResponse(const QPlatformDropQtResponse &response)
+ {
+     setCanDrop(response.isAccepted());
+ 
+     if (canDrop()) {
+-        updateCursor(defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers()));
++        updateCursor(response.acceptedAction());
+     } else {
+         updateCursor(Qt::IgnoreAction);
+     }
+ }
+ 
+-void QWaylandDrag::finishDrag(const QPlatformDropQtResponse &response)
++void QWaylandDrag::setDropResponse(const QPlatformDropQtResponse &response)
+ {
+     setExecutedDropAction(response.acceptedAction());
++}
++
++void QWaylandDrag::finishDrag()
++{
+     QKeyEvent event(QEvent::KeyPress, Qt::Key_Escape, Qt::NoModifier);
+     eventFilter(shapedPixmapWindow(), &event);
++
++    if (drag())
++        drag()->deleteLater();
++}
++
++bool QWaylandDrag::ownsDragObject() const
++{
++    return true;
+ }
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddnd_p.h b/qtwayland/src/client/qwaylanddnd_p.h
+index 474fe2ab..46f629ac 100644
+--- a/qtwayland/src/client/qwaylanddnd_p.h
++++ b/qtwayland/src/client/qwaylanddnd_p.h
+@@ -71,9 +71,10 @@ public:
+     QWaylandDrag(QWaylandDisplay *display);
+     ~QWaylandDrag() override;
+ 
+-    void updateTarget(const QString &mimeType);
+-    void setResponse(const QPlatformDragQtResponse &response);
+-    void finishDrag(const QPlatformDropQtResponse &response);
++    void setResponse(bool accepted);
++    void setResponse(const QPlatformDropQtResponse &response);
++    void setDropResponse(const QPlatformDropQtResponse &response);
++    void finishDrag();
+ 
+ protected:
+     void startDrag() override;
+@@ -82,6 +83,7 @@ protected:
+     void drop(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods) override;
+     void endDrag() override;
+ 
++    bool ownsDragObject() const override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+diff --git a/qtwayland/src/client/qwaylandinputdevice.cpp b/qtwayland/src/client/qwaylandinputdevice.cpp
+index 613fe862..4b90de84 100644
+--- a/qtwayland/src/client/qwaylandinputdevice.cpp
++++ b/qtwayland/src/client/qwaylandinputdevice.cpp
+@@ -685,6 +685,11 @@ public:
+ 
+ void QWaylandInputDevice::Pointer::pointer_leave(uint32_t time, struct wl_surface *surface)
+ {
++    invalidateFocus();
++    mButtons = Qt::NoButton;
++
++    mParent->mTime = time;
++
+     // The event may arrive after destroying the window, indicated by
+     // a null surface.
+     if (!surface)
+@@ -696,11 +701,6 @@ void QWaylandInputDevice::Pointer::pointer_leave(uint32_t time, struct wl_surfac
+ 
+     if (!QWaylandWindow::mouseGrab())
+         setFrameEvent(new LeaveEvent(window, mSurfacePos, mGlobalPos));
+-
+-    invalidateFocus();
+-    mButtons = Qt::NoButton;
+-
+-    mParent->mTime = time;
+ }
+ 
+ class MotionEvent : public QWaylandPointerEvent
+@@ -1300,14 +1300,6 @@ void QWaylandInputDevice::Keyboard::handleFocusDestroyed()
+ void QWaylandInputDevice::Keyboard::handleFocusLost()
+ {
+     mFocus = nullptr;
+-#if QT_CONFIG(clipboard)
+-    if (auto *dataDevice = mParent->dataDevice())
+-        dataDevice->invalidateSelectionOffer();
+-#endif
+-#if QT_CONFIG(wayland_client_primary_selection)
+-    if (auto *device = mParent->primarySelectionDevice())
+-        device->invalidateSelectionOffer();
+-#endif
+     mParent->mQDisplay->handleKeyboardFocusChanged(mParent);
+     mRepeatTimer.stop();
+ }
+@@ -1396,6 +1388,7 @@ void QWaylandInputDevice::Touch::touch_cancel()
+     if (touchExt)
+         touchExt->touchCanceled();
+ 
++    mFocus = nullptr;
+     QWindowSystemInterface::handleTouchCancelEvent(nullptr, mParent->mTouchDevice);
+ }
+ 
+diff --git a/qtwayland/src/client/qwaylandintegration.cpp b/qtwayland/src/client/qwaylandintegration.cpp
+index c53ccb78..54861600 100644
+--- a/qtwayland/src/client/qwaylandintegration.cpp
++++ b/qtwayland/src/client/qwaylandintegration.cpp
+@@ -125,6 +125,9 @@ QWaylandIntegration::QWaylandIntegration()
+ #endif
+ 
+     reconfigureInputContext();
++
++    QWaylandWindow::fixedToplevelPositions =
++            !qEnvironmentVariableIsSet("QT_WAYLAND_DISABLE_FIXED_POSITIONS");
+ }
+ 
+ QWaylandIntegration::~QWaylandIntegration()
+@@ -192,14 +195,18 @@ QAbstractEventDispatcher *QWaylandIntegration::createEventDispatcher() const
+ 
+ void QWaylandIntegration::initialize()
+ {
++    mDisplay->initEventThread();
++
++    // Call after eventDispatcher is fully connected, for QWaylandDisplay::forceRoundTrip()
++    mDisplay->initialize();
++
++    // But the aboutToBlock() and awake() should be connected after initializePlatform().
++    // Otherwise the connected flushRequests() may consumes up all events before processEvents starts to wait,
++    // so that processEvents(QEventLoop::WaitForMoreEvents) may be blocked in the forceRoundTrip().
+     QAbstractEventDispatcher *dispatcher = QGuiApplicationPrivate::eventDispatcher;
+     QObject::connect(dispatcher, SIGNAL(aboutToBlock()), mDisplay.data(), SLOT(flushRequests()));
+     QObject::connect(dispatcher, SIGNAL(awake()), mDisplay.data(), SLOT(flushRequests()));
+ 
+-    int fd = wl_display_get_fd(mDisplay->wl_display());
+-    QSocketNotifier *sn = new QSocketNotifier(fd, QSocketNotifier::Read, mDisplay.data());
+-    QObject::connect(sn, SIGNAL(activated(QSocketDescriptor)), mDisplay.data(), SLOT(flushRequests()));
+-
+     // Qt does not support running with no screens
+     mDisplay->ensureScreen();
+ }
+@@ -262,6 +269,14 @@ QWaylandDisplay *QWaylandIntegration::display() const
+     return mDisplay.data();
+ }
+ 
++Qt::KeyboardModifiers QWaylandIntegration::queryKeyboardModifiers() const
++{
++    if (auto *seat = mDisplay->currentInputDevice()) {
++        return seat->modifiers();
++    }
++    return Qt::NoModifier;
++}
++
+ QList<int> QWaylandIntegration::possibleKeys(const QKeyEvent *event) const
+ {
+     if (auto *seat = mDisplay->currentInputDevice())
+@@ -479,7 +494,7 @@ void QWaylandIntegration::reconfigureInputContext()
+     }
+ #endif
+ 
+-    qCDebug(lcQpaWayland) << "using input method:" << inputContext()->metaObject()->className();
++    qCDebug(lcQpaWayland) << "using input method:" << (inputContext() ? inputContext()->metaObject()->className() : "<none>");
+ }
+ 
+ QWaylandShellIntegration *QWaylandIntegration::createShellIntegration(const QString &integrationName)
+diff --git a/qtwayland/src/client/qwaylandintegration_p.h b/qtwayland/src/client/qwaylandintegration_p.h
+index ff70ae25..73b80658 100644
+--- a/qtwayland/src/client/qwaylandintegration_p.h
++++ b/qtwayland/src/client/qwaylandintegration_p.h
+@@ -107,6 +107,8 @@ public:
+ 
+     QWaylandDisplay *display() const;
+ 
++    Qt::KeyboardModifiers queryKeyboardModifiers() const override;
++
+     QList<int> possibleKeys(const QKeyEvent *event) const override;
+ 
+     QStringList themeNames() const override;
+diff --git a/qtwayland/src/client/qwaylandprimaryselectionv1.cpp b/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
+index 832f9678..ea508771 100644
+--- a/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
++++ b/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
+@@ -54,11 +54,6 @@ QWaylandPrimarySelectionDeviceManagerV1::QWaylandPrimarySelectionDeviceManagerV1
+     : zwp_primary_selection_device_manager_v1(display->wl_registry(), id, qMin(version, uint(1)))
+     , m_display(display)
+ {
+-    // Create devices for all seats.
+-    // This only works if we get the global before all devices
+-    const auto seats = m_display->inputDevices();
+-    for (auto *seat : seats)
+-        seat->setPrimarySelectionDevice(createDevice(seat));
+ }
+ 
+ QWaylandPrimarySelectionDeviceV1 *QWaylandPrimarySelectionDeviceManagerV1::createDevice(QWaylandInputDevice *seat)
+diff --git a/qtwayland/src/client/qwaylandscreen.cpp b/qtwayland/src/client/qwaylandscreen.cpp
+index 6cb337de..5537dafd 100644
+--- a/qtwayland/src/client/qwaylandscreen.cpp
++++ b/qtwayland/src/client/qwaylandscreen.cpp
+@@ -60,7 +60,7 @@ QWaylandXdgOutputManagerV1::QWaylandXdgOutputManagerV1(QWaylandDisplay* display,
+ }
+ 
+ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uint32_t id)
+-    : QtWayland::wl_output(waylandDisplay->wl_registry(), id, qMin(version, 2))
++    : QtWayland::wl_output(waylandDisplay->wl_registry(), id, qMin(version, 3))
+     , m_outputId(id)
+     , mWaylandDisplay(waylandDisplay)
+     , mOutputName(QStringLiteral("Screen%1").arg(id))
+@@ -72,7 +72,7 @@ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uin
+         qCWarning(lcQpaWayland) << "wl_output done event not supported by compositor,"
+                                 << "QScreen may not work correctly";
+         mWaylandDisplay->forceRoundTrip(); // Give the compositor a chance to send geometry etc.
+-        mOutputDone = true; // Fake the done event
++        mProcessedEvents |= OutputDoneEvent; // Fake the done event
+         maybeInitialize();
+     }
+ }
+@@ -81,16 +81,29 @@ QWaylandScreen::~QWaylandScreen()
+ {
+     if (zxdg_output_v1::isInitialized())
+         zxdg_output_v1::destroy();
++    if (wl_output::isInitialized() && wl_output_get_version(wl_output::object()) >= WL_OUTPUT_RELEASE_SINCE_VERSION)
++        wl_output::release();
++}
++
++uint QWaylandScreen::requiredEvents() const
++{
++    uint ret = OutputDoneEvent;
++
++    if (mWaylandDisplay->xdgOutputManager()) {
++        ret |= XdgOutputNameEvent;
++
++        if (mWaylandDisplay->xdgOutputManager()->version() < 3)
++            ret |= XdgOutputDoneEvent;
++    }
++    return ret;
+ }
+ 
+ void QWaylandScreen::maybeInitialize()
+ {
+     Q_ASSERT(!mInitialized);
+ 
+-    if (!mOutputDone)
+-        return;
+-
+-    if (mWaylandDisplay->xdgOutputManager() && !mXdgOutputDone)
++    const uint requiredEvents = this->requiredEvents();
++    if ((mProcessedEvents & requiredEvents) != requiredEvents)
+         return;
+ 
+     mInitialized = true;
+@@ -276,9 +289,8 @@ void QWaylandScreen::output_scale(int32_t factor)
+ 
+ void QWaylandScreen::output_done()
+ {
+-    mOutputDone = true;
+-    if (zxdg_output_v1::isInitialized() && mWaylandDisplay->xdgOutputManager()->version() >= 3)
+-        mXdgOutputDone = true;
++    mProcessedEvents |= OutputDoneEvent;
++
+     if (mInitialized) {
+         updateOutputProperties();
+         if (zxdg_output_v1::isInitialized())
+@@ -339,7 +351,7 @@ void QWaylandScreen::zxdg_output_v1_done()
+     if (Q_UNLIKELY(mWaylandDisplay->xdgOutputManager()->version() >= 3))
+         qWarning(lcQpaWayland) << "zxdg_output_v1.done received on version 3 or newer, this is most likely a bug in the compositor";
+ 
+-    mXdgOutputDone = true;
++    mProcessedEvents |= XdgOutputDoneEvent;
+     if (mInitialized)
+         updateXdgOutputProperties();
+     else
+@@ -348,7 +360,11 @@ void QWaylandScreen::zxdg_output_v1_done()
+ 
+ void QWaylandScreen::zxdg_output_v1_name(const QString &name)
+ {
++    if (Q_UNLIKELY(mInitialized))
++        qWarning(lcQpaWayland) << "zxdg_output_v1.name received after output has been initialized, this is most likely a bug in the compositor";
++
+     mOutputName = name;
++    mProcessedEvents |= XdgOutputNameEvent;
+ }
+ 
+ void QWaylandScreen::updateXdgOutputProperties()
+diff --git a/qtwayland/src/client/qwaylandscreen_p.h b/qtwayland/src/client/qwaylandscreen_p.h
+index df1c94f2..050cfdc0 100644
+--- a/qtwayland/src/client/qwaylandscreen_p.h
++++ b/qtwayland/src/client/qwaylandscreen_p.h
+@@ -116,6 +116,13 @@ public:
+     static QWaylandScreen *fromWlOutput(::wl_output *output);
+ 
+ private:
++    enum Event : uint {
++        XdgOutputDoneEvent = 0x1,
++        OutputDoneEvent = 0x2,
++        XdgOutputNameEvent = 0x4,
++    };
++    uint requiredEvents() const;
++
+     void output_mode(uint32_t flags, int width, int height, int refresh) override;
+     void output_geometry(int32_t x, int32_t y,
+                          int32_t width, int32_t height,
+@@ -148,8 +155,7 @@ private:
+     QSize mPhysicalSize;
+     QString mOutputName;
+     Qt::ScreenOrientation m_orientation = Qt::PrimaryOrientation;
+-    bool mOutputDone = false;
+-    bool mXdgOutputDone = false;
++    uint mProcessedEvents = 0;
+     bool mInitialized = false;
+ 
+ #if QT_CONFIG(cursor)
+diff --git a/qtwayland/src/client/qwaylandshmbackingstore.cpp b/qtwayland/src/client/qwaylandshmbackingstore.cpp
+index dc7ff670..41cffdf7 100644
+--- a/qtwayland/src/client/qwaylandshmbackingstore.cpp
++++ b/qtwayland/src/client/qwaylandshmbackingstore.cpp
+@@ -52,6 +52,7 @@
+ 
+ #include <QtWaylandClient/private/wayland-wayland-client-protocol.h>
+ 
++#include <fcntl.h>
+ #include <unistd.h>
+ #include <sys/mman.h>
+ 
+@@ -61,6 +62,9 @@
+ #  ifndef MFD_CLOEXEC
+ #    define MFD_CLOEXEC     0x0001U
+ #  endif
++#  ifndef MFD_ALLOW_SEALING
++#    define MFD_ALLOW_SEALING 0x0002U
++#  endif
+ #endif
+ 
+ QT_BEGIN_NAMESPACE
+@@ -74,8 +78,10 @@ QWaylandShmBuffer::QWaylandShmBuffer(QWaylandDisplay *display,
+     int alloc = stride * size.height();
+     int fd = -1;
+ 
+-#ifdef SYS_memfd_create
+-    fd = syscall(SYS_memfd_create, "wayland-shm", MFD_CLOEXEC);
++#if defined(SYS_memfd_create) && defined(F_SEAL_SEAL)
++    fd = syscall(SYS_memfd_create, "wayland-shm", MFD_CLOEXEC | MFD_ALLOW_SEALING);
++    if (fd >= 0)
++        fcntl(fd, F_ADD_SEALS, F_SEAL_SHRINK | F_SEAL_SEAL);
+ #endif
+ 
+     QScopedPointer<QFile> filePointer;
+diff --git a/qtwayland/src/client/qwaylandwindow.cpp b/qtwayland/src/client/qwaylandwindow.cpp
+index cb82857a..fb2c59dc 100644
+--- a/qtwayland/src/client/qwaylandwindow.cpp
++++ b/qtwayland/src/client/qwaylandwindow.cpp
+@@ -76,7 +76,6 @@ QWaylandWindow *QWaylandWindow::mMouseGrab = nullptr;
+ QWaylandWindow::QWaylandWindow(QWindow *window, QWaylandDisplay *display)
+     : QPlatformWindow(window)
+     , mDisplay(display)
+-    , mFrameQueue(mDisplay->createFrameQueue())
+     , mResizeAfterSwap(qEnvironmentVariableIsSet("QT_WAYLAND_RESIZE_AFTER_SWAP"))
+ {
+     {
+@@ -95,9 +94,6 @@ QWaylandWindow::QWaylandWindow(QWindow *window, QWaylandDisplay *display)
+ 
+ QWaylandWindow::~QWaylandWindow()
+ {
+-    mDisplay->destroyFrameQueue(mFrameQueue);
+-    mDisplay->handleWindowDestroyed(this);
+-
+     delete mWindowDecoration;
+ 
+     if (mSurface)
+@@ -243,6 +239,7 @@ bool QWaylandWindow::shouldCreateSubSurface() const
+ 
+ void QWaylandWindow::reset()
+ {
++    closeChildPopups();
+     delete mShellSurface;
+     mShellSurface = nullptr;
+     delete mSubSurfaceWindow;
+@@ -255,17 +252,22 @@ void QWaylandWindow::reset()
+         mSurface.reset();
+     }
+ 
+-    if (mFrameCallback) {
+-        wl_callback_destroy(mFrameCallback);
+-        mFrameCallback = nullptr;
+-    }
++    {
++        QMutexLocker lock(&mFrameSyncMutex);
++        if (mFrameCallback) {
++            wl_callback_destroy(mFrameCallback);
++            mFrameCallback = nullptr;
++        }
+ 
+-    mFrameCallbackElapsedTimer.invalidate();
+-    mWaitingForFrameCallback = false;
++        mFrameCallbackElapsedTimer.invalidate();
++        mWaitingForFrameCallback = false;
++    }
+     mFrameCallbackTimedOut = false;
+ 
+     mMask = QRegion();
+     mQueuedBuffer = nullptr;
++
++    mDisplay->handleWindowDestroyed(this);
+ }
+ 
+ QWaylandWindow *QWaylandWindow::fromWlSurface(::wl_surface *surface)
+@@ -351,19 +353,25 @@ void QWaylandWindow::setGeometry_helper(const QRect &rect)
+     }
+ }
+ 
+-void QWaylandWindow::setGeometry(const QRect &rect)
++void QWaylandWindow::setGeometry(const QRect &r)
+ {
++    auto rect = r;
++    if (fixedToplevelPositions && !QPlatformWindow::parent() && window()->type() != Qt::Popup
++        && window()->type() != Qt::ToolTip) {
++        rect.moveTo(screen()->geometry().topLeft());
++    }
+     setGeometry_helper(rect);
+ 
+     if (window()->isVisible() && rect.isValid()) {
+         if (mWindowDecoration)
+             mWindowDecoration->update();
+ 
+-        if (mResizeAfterSwap && windowType() == Egl && mSentInitialResize)
++        if (mResizeAfterSwap && windowType() == Egl && mSentInitialResize) {
++            QMutexLocker lock(&mResizeLock);
+             mResizeDirty = true;
+-        else
++        } else {
+             QWindowSystemInterface::handleGeometryChange(window(), geometry());
+-
++        }
+         mSentInitialResize = true;
+     }
+     QRect exposeGeometry(QPoint(), geometry().size());
+@@ -374,7 +382,7 @@ void QWaylandWindow::setGeometry(const QRect &rect)
+         mShellSurface->setWindowGeometry(windowContentGeometry());
+ 
+     if (isOpaque() && mMask.isEmpty())
+-        setOpaqueArea(rect);
++        setOpaqueArea(QRect(QPoint(0, 0), rect.size()));
+ }
+ 
+ void QWaylandWindow::resizeFromApplyConfigure(const QSize &sizeWithMargins, const QPoint &offset)
+@@ -399,21 +407,6 @@ void QWaylandWindow::sendExposeEvent(const QRect &rect)
+     mLastExposeGeometry = rect;
+ }
+ 
+-
+-static QVector<QPointer<QWaylandWindow>> activePopups;
+-
+-void QWaylandWindow::closePopups(QWaylandWindow *parent)
+-{
+-    while (!activePopups.isEmpty()) {
+-        auto popup = activePopups.takeLast();
+-        if (popup.isNull())
+-            continue;
+-        if (popup.data() == parent)
+-            return;
+-        popup->reset();
+-    }
+-}
+-
+ QPlatformScreen *QWaylandWindow::calculateScreenFromSurfaceEvents() const
+ {
+     QReadLocker lock(&mSurfaceLock);
+@@ -433,10 +426,7 @@ void QWaylandWindow::setVisible(bool visible)
+     lastVisible = visible;
+ 
+     if (visible) {
+-        if (window()->type() == Qt::Popup || window()->type() == Qt::ToolTip)
+-            activePopups << this;
+         initWindow();
+-        mDisplay->flushRequests();
+ 
+         setGeometry(windowGeometry());
+         // Don't flush the events here, or else the newly visible window may start drawing, but since
+@@ -444,7 +434,6 @@ void QWaylandWindow::setVisible(bool visible)
+         // QWaylandShmBackingStore::beginPaint().
+     } else {
+         sendExposeEvent(QRect());
+-        closePopups(this);
+         reset();
+     }
+ }
+@@ -556,12 +545,12 @@ void QWaylandWindow::sendRecursiveExposeEvent()
+ 
+ void QWaylandWindow::attach(QWaylandBuffer *buffer, int x, int y)
+ {
+-    Q_ASSERT(!buffer->committed());
+     QReadLocker locker(&mSurfaceLock);
+     if (mSurface == nullptr)
+         return;
+ 
+     if (buffer) {
++        Q_ASSERT(!buffer->committed());
+         handleUpdate();
+         buffer->setBusy();
+ 
+@@ -583,7 +572,11 @@ void QWaylandWindow::damage(const QRect &rect)
+     if (mSurface == nullptr)
+         return;
+ 
+-    mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    const int s = scale();
++    if (mDisplay->compositorVersion() >= 4)
++        mSurface->damage_buffer(s * rect.x(), s * rect.y(), s * rect.width(), s * rect.height());
++    else
++        mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
+ }
+ 
+ void QWaylandWindow::safeCommit(QWaylandBuffer *buffer, const QRegion &damage)
+@@ -619,8 +612,14 @@ void QWaylandWindow::commit(QWaylandBuffer *buffer, const QRegion &damage)
+         return;
+ 
+     attachOffset(buffer);
+-    for (const QRect &rect: damage)
+-        mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    if (mDisplay->compositorVersion() >= 4) {
++        const int s = scale();
++        for (const QRect &rect: damage)
++            mSurface->damage_buffer(s * rect.x(), s * rect.y(), s * rect.width(), s * rect.height());
++    } else {
++        for (const QRect &rect: damage)
++            mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    }
+     Q_ASSERT(!buffer->committed());
+     buffer->setCommitted();
+     mSurface->commit();
+@@ -635,42 +634,53 @@ void QWaylandWindow::commit()
+ 
+ const wl_callback_listener QWaylandWindow::callbackListener = {
+     [](void *data, wl_callback *callback, uint32_t time) {
+-        Q_UNUSED(callback);
+         Q_UNUSED(time);
+         auto *window = static_cast<QWaylandWindow*>(data);
+-        window->handleFrameCallback();
++        window->handleFrameCallback(callback);
+     }
+ };
+ 
+-void QWaylandWindow::handleFrameCallback()
++void QWaylandWindow::handleFrameCallback(wl_callback* callback)
+ {
++    QMutexLocker locker(&mFrameSyncMutex);
++    if (!mFrameCallback) {
++        // This means the callback is already unset by QWaylandWindow::reset.
++        // The wl_callback object will be destroyed there too.
++        return;
++    }
++    Q_ASSERT(callback == mFrameCallback);
++    wl_callback_destroy(callback);
++    mFrameCallback = nullptr;
++
+     mWaitingForFrameCallback = false;
+     mFrameCallbackElapsedTimer.invalidate();
+ 
+     // The rest can wait until we can run it on the correct thread
+-    if (!mWaitingForUpdateDelivery) {
+-        auto doHandleExpose = [this]() {
+-            bool wasExposed = isExposed();
+-            mFrameCallbackTimedOut = false;
+-            if (!wasExposed && isExposed()) // Did setting mFrameCallbackTimedOut make the window exposed?
+-                sendExposeEvent(QRect(QPoint(), geometry().size()));
+-            if (wasExposed && hasPendingUpdateRequest())
+-                deliverUpdateRequest();
+-
+-            mWaitingForUpdateDelivery = false;
+-        };
++    auto doHandleExpose = [this]() {
++        mWaitingForUpdateDelivery.storeRelease(false);
++        bool wasExposed = isExposed();
++        mFrameCallbackTimedOut = false;
++        if (!wasExposed && isExposed()) // Did setting mFrameCallbackTimedOut make the window exposed?
++            sendExposeEvent(QRect(QPoint(), geometry().size()));
++        if (wasExposed && hasPendingUpdateRequest())
++            deliverUpdateRequest();
++    };
+ 
++    if (mWaitingForUpdateDelivery.testAndSetAcquire(false, true)) {
+         // Queued connection, to make sure we don't call handleUpdate() from inside waitForFrameSync()
+         // in the single-threaded case.
+-        mWaitingForUpdateDelivery = true;
+         QMetaObject::invokeMethod(this, doHandleExpose, Qt::QueuedConnection);
+     }
++
++    mFrameSyncWait.notify_all();
+ }
+ 
+ bool QWaylandWindow::waitForFrameSync(int timeout)
+ {
+-    QMutexLocker locker(mFrameQueue.mutex);
+-    mDisplay->dispatchQueueWhile(mFrameQueue.queue, [&]() { return mWaitingForFrameCallback; }, timeout);
++    QMutexLocker locker(&mFrameSyncMutex);
++
++    QDeadlineTimer deadline(timeout);
++    while (mWaitingForFrameCallback && mFrameSyncWait.wait(&mFrameSyncMutex, deadline)) { }
+ 
+     if (mWaitingForFrameCallback) {
+         qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
+@@ -868,6 +878,17 @@ bool QWaylandWindow::createDecoration()
+             subsurf->set_position(pos.x() + m.left(), pos.y() + m.top());
+         }
+         sendExposeEvent(QRect(QPoint(), geometry().size()));
++
++        // This is a special case where the buffer is recreated, but since
++        // the content rect remains the same, the widgets remain the same
++        // size and are not redrawn, leaving the new buffer empty. As a simple
++        // work-around, we trigger a full extra update whenever the client-side
++        // window decorations are toggled while the window is showing.
++        // Note: createDecoration() is sometimes called from the render thread
++        // of Qt Quick. This is essentially wrong and could potentially cause problems,
++        // but until the underlying issue has been fixed, we have to use invokeMethod()
++        // here to avoid asserts.
++        QMetaObject::invokeMethod(window(), &QWindow::requestUpdate);
+     }
+ 
+     return mWindowDecoration;
+@@ -1023,6 +1044,13 @@ void QWaylandWindow::handleScreensChanged()
+ 
+     QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->QPlatformScreen::screen());
+     mLastReportedScreen = newScreen;
++    if (fixedToplevelPositions && !QPlatformWindow::parent() && window()->type() != Qt::Popup
++        && window()->type() != Qt::ToolTip
++        && geometry().topLeft() != newScreen->geometry().topLeft()) {
++        auto geometry = this->geometry();
++        geometry.moveTo(newScreen->geometry().topLeft());
++        setGeometry(geometry);
++    }
+ 
+     int scale = newScreen->isPlaceholder() ? 1 : static_cast<QWaylandScreen *>(newScreen)->scale();
+     if (scale != mScale) {
+@@ -1094,10 +1122,18 @@ bool QWaylandWindow::setMouseGrabEnabled(bool grab)
+     return true;
+ }
+ 
++Qt::WindowStates QWaylandWindow::windowStates() const
++{
++    return mLastReportedWindowStates;
++}
++
+ void QWaylandWindow::handleWindowStatesChanged(Qt::WindowStates states)
+ {
+     createDecoration();
+-    QWindowSystemInterface::handleWindowStateChanged(window(), states, mLastReportedWindowStates);
++    Qt::WindowStates statesWithoutActive = states & ~Qt::WindowActive;
++    Qt::WindowStates lastStatesWithoutActive = mLastReportedWindowStates & ~Qt::WindowActive;
++    QWindowSystemInterface::handleWindowStateChanged(window(), statesWithoutActive,
++                                                     lastStatesWithoutActive);
+     mLastReportedWindowStates = states;
+ }
+ 
+@@ -1139,19 +1175,24 @@ void QWaylandWindow::timerEvent(QTimerEvent *event)
+     if (event->timerId() != mFrameCallbackCheckIntervalTimerId)
+         return;
+ 
+-    bool callbackTimerExpired = mFrameCallbackElapsedTimer.hasExpired(mFrameCallbackTimeout);
+-    if (!mFrameCallbackElapsedTimer.isValid() || callbackTimerExpired ) {
+-        killTimer(mFrameCallbackCheckIntervalTimerId);
+-        mFrameCallbackCheckIntervalTimerId = -1;
+-    }
+-    if (mFrameCallbackElapsedTimer.isValid() && callbackTimerExpired) {
+-        mFrameCallbackElapsedTimer.invalidate();
++    {
++        QMutexLocker lock(&mFrameSyncMutex);
+ 
+-        qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
+-        mFrameCallbackTimedOut = true;
+-        mWaitingForUpdate = false;
+-        sendExposeEvent(QRect());
++        bool callbackTimerExpired = mFrameCallbackElapsedTimer.hasExpired(mFrameCallbackTimeout);
++        if (!mFrameCallbackElapsedTimer.isValid() || callbackTimerExpired ) {
++            killTimer(mFrameCallbackCheckIntervalTimerId);
++            mFrameCallbackCheckIntervalTimerId = -1;
++        }
++        if (!mFrameCallbackElapsedTimer.isValid() || !callbackTimerExpired) {
++            return;
++        }
++        mFrameCallbackElapsedTimer.invalidate();
+     }
++
++    qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
++    mFrameCallbackTimedOut = true;
++    mWaitingForUpdate = false;
++    sendExposeEvent(QRect());
+ }
+ 
+ void QWaylandWindow::requestUpdate()
+@@ -1160,8 +1201,11 @@ void QWaylandWindow::requestUpdate()
+     Q_ASSERT(hasPendingUpdateRequest()); // should be set by QPA
+ 
+     // If we have a frame callback all is good and will be taken care of there
+-    if (mWaitingForFrameCallback)
+-        return;
++    {
++        QMutexLocker locker(&mFrameSyncMutex);
++        if (mWaitingForFrameCallback)
++            return;
++    }
+ 
+     // If we've already called deliverUpdateRequest(), but haven't seen any attach+commit/swap yet
+     // This is a somewhat redundant behavior and might indicate a bug in the calling code, so log
+@@ -1174,7 +1218,12 @@ void QWaylandWindow::requestUpdate()
+     // so use invokeMethod to delay the delivery a bit.
+     QMetaObject::invokeMethod(this, [this] {
+         // Things might have changed in the meantime
+-        if (hasPendingUpdateRequest() && !mWaitingForFrameCallback)
++        {
++            QMutexLocker locker(&mFrameSyncMutex);
++            if (mWaitingForFrameCallback)
++                return;
++        }
++        if (hasPendingUpdateRequest())
+             deliverUpdateRequest();
+     }, Qt::QueuedConnection);
+ }
+@@ -1185,19 +1234,18 @@ void QWaylandWindow::requestUpdate()
+ void QWaylandWindow::handleUpdate()
+ {
+     qCDebug(lcWaylandBackingstore) << "handleUpdate" << QThread::currentThread();
++
+     // TODO: Should sync subsurfaces avoid requesting frame callbacks?
+     QReadLocker lock(&mSurfaceLock);
+     if (!mSurface)
+         return;
+ 
+-    if (mFrameCallback) {
+-        wl_callback_destroy(mFrameCallback);
+-        mFrameCallback = nullptr;
+-    }
++    QMutexLocker locker(&mFrameSyncMutex);
++    if (mWaitingForFrameCallback)
++        return;
+ 
+-    QMutexLocker locker(mFrameQueue.mutex);
+     struct ::wl_surface *wrappedSurface = reinterpret_cast<struct ::wl_surface *>(wl_proxy_create_wrapper(mSurface->object()));
+-    wl_proxy_set_queue(reinterpret_cast<wl_proxy *>(wrappedSurface), mFrameQueue.queue);
++    wl_proxy_set_queue(reinterpret_cast<wl_proxy *>(wrappedSurface), mDisplay->frameEventQueue());
+     mFrameCallback = wl_surface_frame(wrappedSurface);
+     wl_proxy_wrapper_destroy(wrappedSurface);
+     wl_callback_add_listener(mFrameCallback, &QWaylandWindow::callbackListener, this);
+@@ -1207,6 +1255,8 @@ void QWaylandWindow::handleUpdate()
+     // Start a timer for handling the case when the compositor stops sending frame callbacks.
+     if (mFrameCallbackTimeout > 0) {
+         QMetaObject::invokeMethod(this, [this] {
++            QMutexLocker locker(&mFrameSyncMutex);
++
+             if (mWaitingForFrameCallback) {
+                 if (mFrameCallbackCheckIntervalTimerId < 0)
+                     mFrameCallbackCheckIntervalTimerId = startTimer(mFrameCallbackTimeout);
+@@ -1267,6 +1317,20 @@ void QWaylandWindow::setOpaqueArea(const QRegion &opaqueArea)
+     wl_region_destroy(region);
+ }
+ 
++void QWaylandWindow::addChildPopup(QWaylandWindow *surface) {
++    mChildPopups.append(surface);
++}
++
++void QWaylandWindow::removeChildPopup(QWaylandWindow *surface) {
++    mChildPopups.removeAll(surface);
++}
++
++void QWaylandWindow::closeChildPopups() {
++    while (!mChildPopups.isEmpty()) {
++        auto popup = mChildPopups.takeLast();
++        popup->reset();
++    }
++}
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/client/qwaylandwindow_p.h b/qtwayland/src/client/qwaylandwindow_p.h
+index 01337cff..2f219d8c 100644
+--- a/qtwayland/src/client/qwaylandwindow_p.h
++++ b/qtwayland/src/client/qwaylandwindow_p.h
+@@ -98,6 +98,9 @@ public:
+     QWaylandWindow(QWindow *window, QWaylandDisplay *display);
+     ~QWaylandWindow() override;
+ 
++    // Keep Toplevels position on the top left corner of their screen
++    static inline bool fixedToplevelPositions = true;
++
+     virtual WindowType windowType() const = 0;
+     virtual void ensureSize();
+     WId winId() const override;
+@@ -148,6 +151,7 @@ public:
+     void setWindowState(Qt::WindowStates states) override;
+     void setWindowFlags(Qt::WindowFlags flags) override;
+     void handleWindowStatesChanged(Qt::WindowStates states);
++    Qt::WindowStates windowStates() const;
+ 
+     void raise() override;
+     void lower() override;
+@@ -206,6 +210,10 @@ public:
+     void handleUpdate();
+     void deliverUpdateRequest() override;
+ 
++    void addChildPopup(QWaylandWindow* child);
++    void removeChildPopup(QWaylandWindow* child);
++    void closeChildPopups();
++
+ public slots:
+     void applyConfigure();
+ 
+@@ -215,7 +223,11 @@ signals:
+ 
+ protected:
+     QWaylandDisplay *mDisplay = nullptr;
++
++    // mSurface can be written by the main thread. Other threads should claim a read lock for access
++    mutable QReadWriteLock mSurfaceLock;
+     QScopedPointer<QWaylandSurface> mSurface;
++
+     QWaylandShellSurface *mShellSurface = nullptr;
+     QWaylandSubSurface *mSubSurfaceWindow = nullptr;
+     QVector<QWaylandSubSurface *> mChildren;
+@@ -225,13 +237,14 @@ protected:
+     Qt::MouseButtons mMousePressedInContentArea = Qt::NoButton;
+ 
+     WId mWindowId;
+-    bool mWaitingForFrameCallback = false;
+     bool mFrameCallbackTimedOut = false; // Whether the frame callback has timed out
+-    bool mWaitingForUpdateDelivery = false;
+     int mFrameCallbackCheckIntervalTimerId = -1;
+-    QElapsedTimer mFrameCallbackElapsedTimer;
+-    struct ::wl_callback *mFrameCallback = nullptr;
+-    QWaylandDisplay::FrameQueue mFrameQueue;
++    QAtomicInt mWaitingForUpdateDelivery = false;
++
++    bool mWaitingForFrameCallback = false; // Protected by mFrameSyncMutex
++    QElapsedTimer mFrameCallbackElapsedTimer; // Protected by mFrameSyncMutex
++    struct ::wl_callback *mFrameCallback = nullptr; // Protected by mFrameSyncMutex
++    QMutex mFrameSyncMutex;
+     QWaitCondition mFrameSyncWait;
+ 
+     // True when we have called deliverRequestUpdate, but the client has not yet attached a new buffer
+@@ -261,6 +274,8 @@ protected:
+     QWaylandBuffer *mQueuedBuffer = nullptr;
+     QRegion mQueuedBufferDamage;
+ 
++    QList<QPointer<QWaylandWindow>> mChildPopups;
++
+ private:
+     void setGeometry_helper(const QRect &rect);
+     void initWindow();
+@@ -283,12 +298,10 @@ private:
+     QRect mLastExposeGeometry;
+ 
+     static const wl_callback_listener callbackListener;
+-    void handleFrameCallback();
++    void handleFrameCallback(struct ::wl_callback* callback);
+ 
+     static QWaylandWindow *mMouseGrab;
+ 
+-    mutable QReadWriteLock mSurfaceLock;
+-
+     friend class QWaylandSubSurface;
+ };
+ 
+diff --git a/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h b/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
+index ccad0048..4cc9b3b8 100644
+--- a/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
++++ b/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
+@@ -73,11 +73,10 @@ public:
+         return true;
+     }
+     virtual QWaylandShellSurface *createShellSurface(QWaylandWindow *window) = 0;
++    // kept for binary compat with layer-shell-qt
+     virtual void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) {
+-        if (newFocus)
+-            m_display->handleWindowActivated(newFocus);
+-        if (oldFocus)
+-            m_display->handleWindowDeactivated(oldFocus);
++        Q_UNUSED(newFocus);
++        Q_UNUSED(oldFocus);
+     }
+     virtual void *nativeResourceForWindow(const QByteArray &resource, QWindow *window) {
+         Q_UNUSED(resource);
+diff --git a/qtwayland/src/compositor/configure.json b/qtwayland/src/compositor/configure.json
+index bcfd5215..da95d07b 100644
+--- a/qtwayland/src/compositor/configure.json
++++ b/qtwayland/src/compositor/configure.json
+@@ -7,6 +7,31 @@
+     "testDir": "../../config.tests",
+ 
+     "libraries": {
++        "wayland-client": {
++            "label": "Wayland client library",
++            "headers": "wayland-version.h",
++            "test": {
++                "main": [
++                    "#if WAYLAND_VERSION_MAJOR < 1",
++                    "# error Wayland 1.8.0 or higher required",
++                    "#endif",
++                    "#if WAYLAND_VERSION_MAJOR == 1",
++                    "# if WAYLAND_VERSION_MINOR < 8",
++                    "#  error Wayland 1.8.0 or higher required",
++                    "# endif",
++                    "# if WAYLAND_VERSION_MINOR == 8",
++                    "#  if WAYLAND_VERSION_MICRO < 0",
++                    "#   error Wayland 1.8.0 or higher required",
++                    "#  endif",
++                    "# endif",
++                    "#endif"
++                 ]
++            },
++            "sources": [
++                { "type": "pkgConfig", "args": "wayland-client" },
++                "-lwayland-client"
++            ]
++        },
+         "wayland-server": {
+             "label": "wayland-server",
+             "headers": "wayland-version.h",
+@@ -151,8 +176,7 @@
+                     "#endif"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "dmabuf-client-buffer": {
+             "label": "Linux Client dma-buf Buffer Sharing",
+@@ -176,8 +200,7 @@
+                     "return 0;"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "vulkan-server-buffer": {
+             "label": "Vulkan Buffer Sharing",
+@@ -195,7 +218,8 @@
+                     "exportAllocInfo.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR;",
+                     "return 0;"
+                 ]
+-            }
++            },
++            "use": "wayland-client"
+         }
+     },
+ 
+diff --git a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
+index 7889f575..64140672 100644
+--- a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
++++ b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
+@@ -40,6 +40,7 @@
+ #include "qwaylandeglwindow.h"
+ 
+ #include <QtWaylandClient/private/qwaylandscreen_p.h>
++#include <QtWaylandClient/private/qwaylandsurface_p.h>
+ #include "qwaylandglcontext.h"
+ 
+ #include <QtEglSupport/private/qeglconvenience_p.h>
+@@ -124,6 +125,7 @@ void QWaylandEglWindow::updateSurface(bool create)
+         }
+         mOffset = QPoint();
+     } else {
++        QReadLocker locker(&mSurfaceLock);
+         if (m_waylandEglWindow) {
+             int current_width, current_height;
+             static bool disableResizeCheck = qgetenv("QT_WAYLAND_DISABLE_RESIZECHECK").toInt();
+@@ -131,14 +133,16 @@ void QWaylandEglWindow::updateSurface(bool create)
+             if (!disableResizeCheck) {
+                 wl_egl_window_get_attached_size(m_waylandEglWindow, &current_width, &current_height);
+             }
+-            if (disableResizeCheck || (current_width != sizeWithMargins.width() || current_height != sizeWithMargins.height())) {
++            if (disableResizeCheck || (current_width != sizeWithMargins.width() || current_height != sizeWithMargins.height()) || m_requestedSize != sizeWithMargins) {
+                 wl_egl_window_resize(m_waylandEglWindow, sizeWithMargins.width(), sizeWithMargins.height(), mOffset.x(), mOffset.y());
++                m_requestedSize = sizeWithMargins;
+                 mOffset = QPoint();
+ 
+                 m_resize = true;
+             }
+-        } else if (create && wlSurface()) {
+-            m_waylandEglWindow = wl_egl_window_create(wlSurface(), sizeWithMargins.width(), sizeWithMargins.height());
++        } else if (create && mSurface) {
++            m_waylandEglWindow = wl_egl_window_create(mSurface->object(), sizeWithMargins.width(), sizeWithMargins.height());
++            m_requestedSize = sizeWithMargins;
+         }
+ 
+         if (!m_eglSurface && m_waylandEglWindow && create) {
+diff --git a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
+index 5b1f4d56..0079dfef 100644
+--- a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
++++ b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
+@@ -88,6 +88,7 @@ private:
+     mutable QOpenGLFramebufferObject *m_contentFBO = nullptr;
+ 
+     QSurfaceFormat m_format;
++    QSize m_requestedSize;
+ };
+ 
+ }
+diff --git a/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h b/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
+index 56a710c3..c6a8b6c6 100644
+--- a/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
++++ b/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
+@@ -41,6 +41,8 @@
+ #include <QtCore/QTextStream>
+ #include <QtGui/QOpenGLTexture>
+ 
++#include <array>
++
+ #include <EGL/egl.h>
+ #include <EGL/eglext.h>
+ 
+diff --git a/qtwayland/src/plugins/decorations/bradient/main.cpp b/qtwayland/src/plugins/decorations/bradient/main.cpp
+index e75fda3c..fa885143 100644
+--- a/qtwayland/src/plugins/decorations/bradient/main.cpp
++++ b/qtwayland/src/plugins/decorations/bradient/main.cpp
+@@ -164,13 +164,10 @@ void QWaylandBradientDecoration::paint(QPaintDevice *device)
+     // Window icon
+     QIcon icon = waylandWindow()->windowIcon();
+     if (!icon.isNull()) {
+-        QPixmap pixmap = icon.pixmap(QSize(128, 128));
+-        QPixmap scaled = pixmap.scaled(22, 22, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+-
+         QRectF iconRect(0, 0, 22, 22);
+-        p.drawPixmap(iconRect.adjusted(margins().left() + BUTTON_SPACING, 4,
+-                                       margins().left() + BUTTON_SPACING, 4),
+-                     scaled, iconRect);
++        iconRect.adjust(margins().left() + BUTTON_SPACING, 4,
++                        margins().left() + BUTTON_SPACING, 4),
++        icon.paint(&p, iconRect.toRect());
+     }
+ 
+     // Window title
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
+index 85d25e3c..60bdd491 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
+@@ -47,18 +47,21 @@ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
+-QWaylandXdgPopupV5::QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow *window)
++QWaylandXdgPopupV5::QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow* parent, QWaylandWindow *window)
+     : QWaylandShellSurface(window)
+     , QtWayland::xdg_popup_v5(popup)
++    , m_parent(parent)
+     , m_window(window)
+ {
+     if (window->display()->windowExtension())
+         m_extendedWindow = new QWaylandExtendedSurface(window);
++    m_parent->addChildPopup(m_window);
+ }
+ 
+ QWaylandXdgPopupV5::~QWaylandXdgPopupV5()
+ {
+     xdg_popup_destroy(object());
++    m_parent->removeChildPopup(m_window);
+     delete m_extendedWindow;
+ }
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
+index 7494f6a6..d85f130b 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
+@@ -70,7 +70,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgPopupV5 : public QWaylandShellSurface
+ {
+     Q_OBJECT
+ public:
+-    QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow *window);
++    QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow* parent, QWaylandWindow *window);
+     ~QWaylandXdgPopupV5() override;
+ 
+ protected:
+@@ -78,6 +78,7 @@ protected:
+ 
+ private:
+     QWaylandExtendedSurface *m_extendedWindow = nullptr;
++    QWaylandWindow *m_parent = nullptr;
+     QWaylandWindow *m_window = nullptr;
+ };
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
+index 7e242c4a..def8452a 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
+@@ -84,7 +84,7 @@ QWaylandXdgPopupV5 *QWaylandXdgShellV5::createXdgPopup(QWaylandWindow *window, Q
+     int x = position.x() + parentWindow->frameMargins().left();
+     int y = position.y() + parentWindow->frameMargins().top();
+ 
+-    auto popup = new QWaylandXdgPopupV5(get_xdg_popup(window->wlSurface(), parentSurface, seat, m_popupSerial, x, y), window);
++    auto popup = new QWaylandXdgPopupV5(get_xdg_popup(window->wlSurface(), parentSurface, seat, m_popupSerial, x, y), parentWindow, window);
+     m_popups.append(window);
+     QObject::connect(popup, &QWaylandXdgPopupV5::destroyed, [this, window](){
+         m_popups.removeOne(window);
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
+index 4e25949f..cfc60939 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
+@@ -85,13 +85,6 @@ QWaylandShellSurface *QWaylandXdgShellV5Integration::createShellSurface(QWayland
+     return m_xdgShell->createXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellV5Integration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) {
+-    if (newFocus && qobject_cast<QWaylandXdgPopupV5 *>(newFocus->shellSurface()))
+-        m_display->handleWindowActivated(newFocus);
+-    if (oldFocus && qobject_cast<QWaylandXdgPopupV5 *>(oldFocus->shellSurface()))
+-        m_display->handleWindowDeactivated(oldFocus);
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
+index ce6bdb9e..aed88670 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
+@@ -67,7 +67,6 @@ public:
+     QWaylandXdgShellV5Integration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShellV5> m_xdgShell;
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
+index 8c371661..151c78e3 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
+@@ -174,6 +174,7 @@ QWaylandXdgSurfaceV6::Popup::Popup(QWaylandXdgSurfaceV6 *xdgSurface, QWaylandXdg
+     , m_xdgSurface(xdgSurface)
+     , m_parent(parent)
+ {
++    m_parent->window()->addChildPopup(m_xdgSurface->window());
+ }
+ 
+ QWaylandXdgSurfaceV6::Popup::~Popup()
+@@ -181,6 +182,8 @@ QWaylandXdgSurfaceV6::Popup::~Popup()
+     if (isInitialized())
+         destroy();
+ 
++    m_parent->window()->removeChildPopup(m_xdgSurface->window());
++
+     if (m_grabbing) {
+         auto *shell = m_xdgSurface->m_shell;
+         Q_ASSERT(shell->m_topmostGrabbingPopup == this);
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
+index 03164316..e8da8ba1 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
+@@ -68,20 +68,6 @@ QWaylandShellSurface *QWaylandXdgShellV6Integration::createShellSurface(QWayland
+     return m_xdgShell->getXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellV6Integration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus)
+-{
+-    if (newFocus) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurfaceV6 *>(newFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowActivated(newFocus);
+-    }
+-    if (oldFocus && qobject_cast<QWaylandXdgSurfaceV6 *>(oldFocus->shellSurface())) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurfaceV6 *>(oldFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowDeactivated(oldFocus);
+-    }
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
+index 261f8cbb..c1bcd5c6 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
+@@ -65,7 +65,6 @@ public:
+     QWaylandXdgShellV6Integration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShellV6> m_xdgShell;
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
+index f3e3c330..fa6d5808 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
+@@ -67,11 +67,6 @@ QWaylandXdgSurface::Toplevel::Toplevel(QWaylandXdgSurface *xdgSurface)
+ 
+ QWaylandXdgSurface::Toplevel::~Toplevel()
+ {
+-    if (m_applied.states & Qt::WindowActive) {
+-        QWaylandWindow *window = m_xdgSurface->window();
+-        window->display()->handleWindowDeactivated(window);
+-    }
+-
+     // The protocol spec requires that the decoration object is deleted before xdg_toplevel.
+     delete m_decoration;
+     m_decoration = nullptr;
+@@ -85,16 +80,15 @@ void QWaylandXdgSurface::Toplevel::applyConfigure()
+     if (!(m_applied.states & (Qt::WindowMaximized|Qt::WindowFullScreen)))
+         m_normalSize = m_xdgSurface->m_window->windowFrameGeometry().size();
+ 
+-    if ((m_pending.states & Qt::WindowActive) && !(m_applied.states & Qt::WindowActive))
++    if ((m_pending.states & Qt::WindowActive) && !(m_applied.states & Qt::WindowActive)
++        && !m_xdgSurface->m_window->display()->isKeyboardAvailable())
+         m_xdgSurface->m_window->display()->handleWindowActivated(m_xdgSurface->m_window);
+ 
+-    if (!(m_pending.states & Qt::WindowActive) && (m_applied.states & Qt::WindowActive))
++    if (!(m_pending.states & Qt::WindowActive) && (m_applied.states & Qt::WindowActive)
++        && !m_xdgSurface->m_window->display()->isKeyboardAvailable())
+         m_xdgSurface->m_window->display()->handleWindowDeactivated(m_xdgSurface->m_window);
+ 
+-    // TODO: none of the other plugins send WindowActive either, but is it on purpose?
+-    Qt::WindowStates statesWithoutActive = m_pending.states & ~Qt::WindowActive;
+-
+-    m_xdgSurface->m_window->handleWindowStatesChanged(statesWithoutActive);
++    m_xdgSurface->m_window->handleWindowStatesChanged(m_pending.states);
+ 
+     if (m_pending.size.isEmpty()) {
+         // An empty size in the configure means it's up to the client to choose the size
+@@ -105,8 +99,6 @@ void QWaylandXdgSurface::Toplevel::applyConfigure()
+         m_xdgSurface->m_window->resizeFromApplyConfigure(m_pending.size);
+     }
+ 
+-    m_xdgSurface->setSizeHints();
+-
+     m_applied = m_pending;
+     qCDebug(lcQpaWayland) << "Applied pending xdg_toplevel configure event:" << m_applied.size << m_applied.states;
+ }
+@@ -203,12 +195,17 @@ QtWayland::xdg_toplevel::resize_edge QWaylandXdgSurface::Toplevel::convertToResi
+                 | ((edges & Qt::RightEdge) ? resize_edge_right : 0));
+ }
+ 
+-QWaylandXdgSurface::Popup::Popup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parent,
++QWaylandXdgSurface::Popup::Popup(QWaylandXdgSurface *xdgSurface, QWaylandWindow *parent,
+                                  QtWayland::xdg_positioner *positioner)
+-    : xdg_popup(xdgSurface->get_popup(parent->object(), positioner->object()))
+-    , m_xdgSurface(xdgSurface)
++    : m_xdgSurface(xdgSurface)
++    , m_parentXdgSurface(qobject_cast<QWaylandXdgSurface *>(parent->shellSurface()))
+     , m_parent(parent)
+ {
++
++    init(xdgSurface->get_popup(m_parentXdgSurface ? m_parentXdgSurface->object() : nullptr, positioner->object()));
++    if (m_parent) {
++        m_parent->addChildPopup(m_xdgSurface->window());
++    }
+ }
+ 
+ QWaylandXdgSurface::Popup::~Popup()
+@@ -216,10 +213,24 @@ QWaylandXdgSurface::Popup::~Popup()
+     if (isInitialized())
+         destroy();
+ 
++    if (m_parent) {
++        m_parent->removeChildPopup(m_xdgSurface->window());
++    }
++
+     if (m_grabbing) {
+         auto *shell = m_xdgSurface->m_shell;
+         Q_ASSERT(shell->m_topmostGrabbingPopup == this);
+-        shell->m_topmostGrabbingPopup = m_parent->m_popup;
++        shell->m_topmostGrabbingPopup = m_parentXdgSurface ? m_parentXdgSurface->m_popup : nullptr;
++        m_grabbing = false;
++
++        // Synthesize Qt enter/leave events for popup
++        QWindow *leave = nullptr;
++        if (m_xdgSurface && m_xdgSurface->window())
++            leave = m_xdgSurface->window()->window();
++        QWindowSystemInterface::handleLeaveEvent(leave);
++
++        if (QWindow *enter = QGuiApplication::topLevelAt(QCursor::pos()))
++            QWindowSystemInterface::handleEnterEvent(enter, enter->mapFromGlobal(QCursor::pos()), QCursor::pos());
+     }
+ }
+ 
+@@ -257,6 +268,7 @@ QWaylandXdgSurface::QWaylandXdgSurface(QWaylandXdgShell *shell, ::xdg_surface *s
+                 m_toplevel->set_parent(parentXdgSurface->m_toplevel->object());
+         }
+     }
++    setSizeHints();
+ }
+ 
+ QWaylandXdgSurface::~QWaylandXdgSurface()
+@@ -400,8 +412,6 @@ void QWaylandXdgSurface::setPopup(QWaylandWindow *parent)
+ {
+     Q_ASSERT(!m_toplevel && !m_popup);
+ 
+-    auto parentXdgSurface = static_cast<QWaylandXdgSurface *>(parent->shellSurface());
+-
+     auto positioner = new QtWayland::xdg_positioner(m_shell->create_positioner());
+     // set_popup expects a position relative to the parent
+     QPoint transientPos = m_window->geometry().topLeft(); // this is absolute
+@@ -414,8 +424,9 @@ void QWaylandXdgSurface::setPopup(QWaylandWindow *parent)
+     positioner->set_anchor(QtWayland::xdg_positioner::anchor_top_left);
+     positioner->set_gravity(QtWayland::xdg_positioner::gravity_bottom_right);
+     positioner->set_size(m_window->geometry().width(), m_window->geometry().height());
+-    m_popup = new Popup(this, parentXdgSurface, positioner);
++    m_popup = new Popup(this, parent, positioner);
+     positioner->destroy();
++
+     delete positioner;
+ }
+ 
+@@ -437,6 +448,23 @@ void QWaylandXdgSurface::setGrabPopup(QWaylandWindow *parent, QWaylandInputDevic
+     }
+     setPopup(parent);
+     m_popup->grab(device, serial);
++
++    // Synthesize Qt enter/leave events for popup
++    if (!parent)
++        return;
++    QWindow *current = QGuiApplication::topLevelAt(QCursor::pos());
++    QWindow *leave = parent->window();
++    if (current != leave)
++        return;
++
++    QWindowSystemInterface::handleLeaveEvent(leave);
++
++    QWindow *enter = nullptr;
++    if (m_popup && m_popup->m_xdgSurface && m_popup->m_xdgSurface->window())
++        enter = m_popup->m_xdgSurface->window()->window();
++
++    if (enter)
++        QWindowSystemInterface::handleEnterEvent(enter, enter->mapFromGlobal(QCursor::pos()), QCursor::pos());
+ }
+ 
+ void QWaylandXdgSurface::xdg_surface_configure(uint32_t serial)
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
+index 96785205..4b518f0a 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
+@@ -131,14 +131,15 @@ private:
+ 
+     class Popup : public QtWayland::xdg_popup {
+     public:
+-        Popup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parent, QtWayland::xdg_positioner *positioner);
++        Popup(QWaylandXdgSurface *xdgSurface, QWaylandWindow *parent, QtWayland::xdg_positioner *positioner);
+         ~Popup() override;
+ 
+         void grab(QWaylandInputDevice *seat, uint serial);
+         void xdg_popup_popup_done() override;
+ 
+         QWaylandXdgSurface *m_xdgSurface = nullptr;
+-        QWaylandXdgSurface *m_parent = nullptr;
++        QWaylandXdgSurface *m_parentXdgSurface = nullptr;
++        QWaylandWindow *m_parent = nullptr;
+         bool m_grabbing = false;
+     };
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
+index 8769d971..da0dd6a7 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
+@@ -69,20 +69,6 @@ QWaylandShellSurface *QWaylandXdgShellIntegration::createShellSurface(QWaylandWi
+     return m_xdgShell->getXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellIntegration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus)
+-{
+-    if (newFocus) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurface *>(newFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowActivated(newFocus);
+-    }
+-    if (oldFocus && qobject_cast<QWaylandXdgSurface *>(oldFocus->shellSurface())) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurface *>(oldFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowDeactivated(oldFocus);
+-    }
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
+index b6caa6c9..2f929f98 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
+@@ -65,7 +65,6 @@ public:
+     QWaylandXdgShellIntegration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShell> m_xdgShell;
+diff --git a/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp b/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
+index 526d0ef4..f50ccf30 100644
+--- a/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
++++ b/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
+@@ -39,7 +39,10 @@
+ 
+ #include "qwaylandinputmethodeventbuilder_p.h"
+ 
++#include <QBrush>
++#include <QGuiApplication>
+ #include <QInputMethod>
++#include <QPalette>
+ #include <QTextCharFormat>
+ 
+ #ifdef QT_BUILD_WAYLANDCOMPOSITOR_LIB
+@@ -81,32 +84,38 @@ void QWaylandInputMethodEventBuilder::addPreeditStyling(uint32_t index, uint32_t
+     QTextCharFormat format;
+ 
+     switch (style) {
+-    case 0:
+-    case 1:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_NONE:
++        break;
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_DEFAULT:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_UNDERLINE:
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-    case 2:
+-    case 3:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_ACTIVE:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_INACTIVE:
+         format.setFontWeight(QFont::Bold);
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-    case 4:
+-        format.setFontUnderline(true);
+-        format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+-        m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_HIGHLIGHT:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_SELECTION:
++        {
++            format.setFontUnderline(true);
++            format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
++            QPalette palette = qApp->palette();
++            format.setBackground(QBrush(palette.color(QPalette::Active, QPalette::Highlight)));
++            format.setForeground(QBrush(palette.color(QPalette::Active, QPalette::HighlightedText)));
++            m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
++        }
+         break;
+-    case 5:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_INCORRECT:
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::WaveUnderline);
+         format.setUnderlineColor(QColor(Qt::red));
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-//    case QtWayland::wl_text_input::preedit_style_selection:
+-//    case QtWayland::wl_text_input::preedit_style_none:
+     default:
+         break;
+     }
+@@ -153,7 +162,7 @@ QInputMethodEvent QWaylandInputMethodEventBuilder::buildPreedit(const QString &t
+ 
+     if (m_preeditCursor < 0) {
+         attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, 0, QVariant()));
+-    } else if (m_preeditCursor > 0) {
++    } else {
+         attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, indexFromWayland(text, m_preeditCursor), 1, QVariant()));
+     }
+ 
+diff --git a/qtwayland/src/shared/qwaylandmimehelper.cpp b/qtwayland/src/shared/qwaylandmimehelper.cpp
+index a5fdd34d..e2fe1928 100644
+--- a/qtwayland/src/shared/qwaylandmimehelper.cpp
++++ b/qtwayland/src/shared/qwaylandmimehelper.cpp
+@@ -60,7 +60,7 @@ QByteArray QWaylandMimeHelper::getByteArray(QMimeData *mimeData, const QString &
+             buf.open(QIODevice::ReadWrite);
+             QByteArray fmt = "BMP";
+             if (mimeType.startsWith(QLatin1String("image/"))) {
+-                QByteArray imgFmt = mimeType.mid(6).toUpper().toLatin1();
++                QByteArray imgFmt = mimeType.mid(6).toLower().toLatin1();
+                 if (QImageWriter::supportedImageFormats().contains(imgFmt))
+                     fmt = imgFmt;
+             }
+@@ -74,7 +74,7 @@ QByteArray QWaylandMimeHelper::getByteArray(QMimeData *mimeData, const QString &
+         QList<QUrl> urls = mimeData->urls();
+         for (int i = 0; i < urls.count(); ++i) {
+             content.append(urls.at(i).toEncoded());
+-            content.append('\n');
++            content.append("\r\n");
+         }
+     } else {
+         content = mimeData->data(mimeType);
+diff --git a/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp b/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
+index 1568b3b9..067410d0 100644
+--- a/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
++++ b/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
+@@ -35,7 +35,7 @@
+ 
+ using namespace MockCompositor;
+ 
+-constexpr int dataDeviceVersion = 1;
++constexpr int dataDeviceVersion = 3;
+ 
+ class DataDeviceCompositor : public DefaultCompositor {
+ public:
+diff --git a/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp b/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
+index 9312c2e5..2ea382f1 100644
+--- a/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
++++ b/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
+@@ -73,6 +73,7 @@ private slots:
+     void multiTouch();
+     void multiTouchUpAndMotionFrame();
+     void tapAndMoveInSameFrame();
++    void cancelTouch();
+ };
+ 
+ void tst_seatv5::bindsToSeat()
+@@ -646,5 +647,34 @@ void tst_seatv5::tapAndMoveInSameFrame()
+     QTRY_COMPARE(window.m_events.last().touchPoints.first().state(), Qt::TouchPointState::TouchPointReleased);
+ }
+ 
++void tst_seatv5::cancelTouch()
++{
++    TouchWindow window;
++    QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
++
++    exec([=] {
++        auto *t = touch();
++        auto *c = client();
++        t->sendDown(xdgToplevel()->surface(), {32, 32}, 1);
++        t->sendFrame(c);
++        t->sendCancel(c);
++        t->sendFrame(c);
++    });
++
++    QTRY_VERIFY(!window.m_events.empty());
++    {
++        auto e = window.m_events.takeFirst();
++        QCOMPARE(e.type, QEvent::TouchBegin);
++        QCOMPARE(e.touchPointStates, Qt::TouchPointPressed);
++        QCOMPARE(e.touchPoints.length(), 1);
++        QCOMPARE(e.touchPoints.first().pos(), QPointF(32-window.frameMargins().left(), 32-window.frameMargins().top()));
++    }
++    {
++        auto e = window.m_events.takeFirst();
++        QCOMPARE(e.type, QEvent::TouchCancel);
++        QCOMPARE(e.touchPoints.length(), 0);
++    }
++}
++
+ QCOMPOSITOR_TEST_MAIN(tst_seatv5)
+ #include "tst_seatv5.moc"
+diff --git a/qtwayland/tests/auto/client/shared/corecompositor.cpp b/qtwayland/tests/auto/client/shared/corecompositor.cpp
+index 5c6c83ba..fa9b7662 100644
+--- a/qtwayland/tests/auto/client/shared/corecompositor.cpp
++++ b/qtwayland/tests/auto/client/shared/corecompositor.cpp
+@@ -27,6 +27,7 @@
+ ****************************************************************************/
+ 
+ #include "corecompositor.h"
++#include <thread>
+ 
+ namespace MockCompositor {
+ 
+diff --git a/qtwayland/tests/auto/client/shared/coreprotocol.cpp b/qtwayland/tests/auto/client/shared/coreprotocol.cpp
+index 0d988521..d1a2e7cb 100644
+--- a/qtwayland/tests/auto/client/shared/coreprotocol.cpp
++++ b/qtwayland/tests/auto/client/shared/coreprotocol.cpp
+@@ -451,6 +451,13 @@ void Touch::sendFrame(wl_client *client)
+         send_frame(r->handle);
+ }
+ 
++void Touch::sendCancel(wl_client *client)
++{
++    const auto touchResources = resourceMap().values(client);
++    for (auto *r : touchResources)
++        send_cancel(r->handle);
++}
++
+ uint Keyboard::sendEnter(Surface *surface)
+ {
+     auto serial = m_seat->m_compositor->nextSerial();
+diff --git a/qtwayland/tests/auto/client/shared/coreprotocol.h b/qtwayland/tests/auto/client/shared/coreprotocol.h
+index a1af137a..210d8ddb 100644
+--- a/qtwayland/tests/auto/client/shared/coreprotocol.h
++++ b/qtwayland/tests/auto/client/shared/coreprotocol.h
+@@ -158,7 +158,7 @@ class WlCompositor : public Global, public QtWaylandServer::wl_compositor
+ {
+     Q_OBJECT
+ public:
+-    explicit WlCompositor(CoreCompositor *compositor, int version = 3)
++    explicit WlCompositor(CoreCompositor *compositor, int version = 4)
+         : QtWaylandServer::wl_compositor(compositor->m_display, version)
+         , m_compositor(compositor)
+     {}
+@@ -364,6 +364,7 @@ public:
+     uint sendUp(wl_client *client, int id);
+     void sendMotion(wl_client *client, const QPointF &position, int id);
+     void sendFrame(wl_client *client);
++    void sendCancel(wl_client *client);
+ 
+     Seat *m_seat = nullptr;
+ };
+diff --git a/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp b/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
+index a415cbf5..b1d3d07d 100644
+--- a/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
++++ b/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
+@@ -342,7 +342,7 @@ Compositor::Compositor(MockCompositor *mockCompositor)
+         exit(EXIT_FAILURE);
+     }
+ 
+-    wl_global_create(m_display, &wl_compositor_interface, 1, this, bindCompositor);
++    wl_global_create(m_display, &wl_compositor_interface, 4, this, bindCompositor);
+ 
+     m_data_device_manager.reset(new DataDeviceManager(this, m_display));
+ 
+diff --git a/qtwayland/tests/auto/client/shared_old/mocksurface.cpp b/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
+index e9df5f90..c3246e4a 100644
+--- a/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
++++ b/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
+@@ -125,6 +125,16 @@ void Surface::surface_damage(Resource *resource,
+     Q_UNUSED(height);
+ }
+ 
++void Surface::surface_damage_buffer(Resource *resource,
++                                    int32_t x, int32_t y, int32_t width, int32_t height)
++{
++    Q_UNUSED(resource);
++    Q_UNUSED(x);
++    Q_UNUSED(y);
++    Q_UNUSED(width);
++    Q_UNUSED(height);
++}
++
+ void Surface::surface_frame(Resource *resource,
+                             uint32_t callback)
+ {
+diff --git a/qtwayland/tests/auto/client/shared_old/mocksurface.h b/qtwayland/tests/auto/client/shared_old/mocksurface.h
+index 949dc23d..d176837e 100644
+--- a/qtwayland/tests/auto/client/shared_old/mocksurface.h
++++ b/qtwayland/tests/auto/client/shared_old/mocksurface.h
+@@ -65,6 +65,8 @@ protected:
+                         struct wl_resource *buffer, int x, int y) override;
+     void surface_damage(Resource *resource,
+                         int32_t x, int32_t y, int32_t width, int32_t height) override;
++    void surface_damage_buffer(Resource *resource,
++                               int32_t x, int32_t y, int32_t width, int32_t height) override;
+     void surface_frame(Resource *resource,
+                        uint32_t callback) override;
+     void surface_commit(Resource *resource) override;
+diff --git a/qtwayland/tests/auto/client/surface/tst_surface.cpp b/qtwayland/tests/auto/client/surface/tst_surface.cpp
+index 95e4e609..60c672ce 100644
+--- a/qtwayland/tests/auto/client/surface/tst_surface.cpp
++++ b/qtwayland/tests/auto/client/surface/tst_surface.cpp
+@@ -129,6 +129,10 @@ void tst_surface::waitForFrameCallbackGl()
+     // Make sure we follow frame callbacks for some frames
+     for (int i = 0; i < 5; ++i) {
+         xdgPingAndWaitForPong(); // Make sure things have happened on the client
++        if (!qEnvironmentVariableIntValue("QT_WAYLAND_DISABLE_WINDOWDECORATION") && i == 0) {
++            QCOMPARE(bufferSpy.count(), 1);
++            bufferSpy.removeFirst();
++        }
+         exec([&] {
+             QVERIFY(bufferSpy.empty()); // Make sure no extra buffers have arrived
+             QVERIFY(!xdgToplevel()->surface()->m_waitingFrameCallbacks.empty());
+diff --git a/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp b/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
+index 2277bbb8..747875b4 100644
+--- a/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
++++ b/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
+@@ -31,6 +31,7 @@
+ #include <QtGui/QOpenGLWindow>
+ #include <QtGui/qpa/qplatformnativeinterface.h>
+ #include <QtWaylandClient/private/wayland-wayland-client-protocol.h>
++#include <QtWaylandClient/private/qwaylandwindow_p.h>
+ 
+ using namespace MockCompositor;
+ 
+@@ -45,6 +46,7 @@ private slots:
+     void configureStates();
+     void popup();
+     void tooltipOnPopup();
++    void tooltipAndSiblingPopup();
+     void switchPopups();
+     void hidePopupParent();
+     void pongs();
+@@ -138,6 +140,7 @@ void tst_xdgshell::configureSize()
+ 
+ void tst_xdgshell::configureStates()
+ {
++    QVERIFY(qputenv("QT_WAYLAND_FRAME_CALLBACK_TIMEOUT", "0"));
+     QRasterWindow window;
+     window.resize(64, 48);
+     window.show();
+@@ -154,9 +157,12 @@ void tst_xdgshell::configureStates()
+     // Toplevel windows don't know their position on xdg-shell
+ //    QCOMPARE(window.frameGeometry().topLeft(), QPoint()); // TODO: this doesn't currently work when window decorations are enabled
+ 
+-//    QEXPECT_FAIL("", "configure has already been acked, we shouldn't have to wait for isActive", Continue);
+-//    QVERIFY(window.isActive());
+-    QTRY_VERIFY(window.isActive()); // Just make sure it eventually get's set correctly
++    // window.windowstate() is driven by keyboard focus, however for decorations we want to follow
++    // XDGShell this is internal to QtWayland so it is queried directly
++    auto waylandWindow = static_cast<QtWaylandClient::QWaylandWindow *>(window.handle());
++    Q_ASSERT(waylandWindow);
++    QTRY_VERIFY(waylandWindow->windowStates().testFlag(
++            Qt::WindowActive)); // Just make sure it eventually get's set correctly
+ 
+     const QSize screenSize(640, 480);
+     const uint maximizedSerial = exec([=] {
+@@ -186,6 +192,7 @@ void tst_xdgshell::configureStates()
+     QCOMPARE(window.windowStates(), Qt::WindowNoState);
+     QCOMPARE(window.frameGeometry().size(), windowedSize);
+ //    QCOMPARE(window.frameGeometry().topLeft(), QPoint()); // TODO: this doesn't currently work when window decorations are enabled
++    QVERIFY(qunsetenv("QT_WAYLAND_FRAME_CALLBACK_TIMEOUT"));
+ }
+ 
+ void tst_xdgshell::popup()
+@@ -340,6 +347,92 @@ void tst_xdgshell::tooltipOnPopup()
+     QCOMPOSITOR_TRY_COMPARE(xdgPopup(0), nullptr);
+ }
+ 
++void tst_xdgshell::tooltipAndSiblingPopup()
++{
++    class ToolTip : public QRasterWindow {
++    public:
++        explicit ToolTip(QWindow *parent) {
++            setTransientParent(parent);
++            setFlags(Qt::ToolTip);
++            resize(100, 100);
++            show();
++        }
++        void mousePressEvent(QMouseEvent *event) override {
++            QRasterWindow::mousePressEvent(event);
++            m_popup = new QRasterWindow;
++            m_popup->setTransientParent(transientParent());
++            m_popup->setFlags(Qt::Popup);
++            m_popup->resize(100, 100);
++            m_popup->show();
++        }
++
++        QRasterWindow *m_popup = nullptr;
++    };
++
++    class Window : public QRasterWindow {
++    public:
++        void mousePressEvent(QMouseEvent *event) override {
++            QRasterWindow::mousePressEvent(event);
++            m_tooltip = new ToolTip(this);
++        }
++        ToolTip *m_tooltip = nullptr;
++    };
++
++    Window window;
++    window.resize(200, 200);
++    window.show();
++
++    QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
++    exec([=] { xdgToplevel()->sendCompleteConfigure(); });
++    QCOMPOSITOR_TRY_VERIFY(xdgToplevel()->m_xdgSurface->m_committedConfigureSerial);
++
++    exec([=] {
++        auto *surface = xdgToplevel()->surface();
++        auto *p = pointer();
++        auto *c = client();
++        p->sendEnter(surface, {100, 100});
++        p->sendFrame(c);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_pressed);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_released);
++        p->sendFrame(c);
++        p->sendLeave(surface);
++        p->sendFrame(c);
++    });
++
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup());
++    exec([=] { xdgPopup()->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup()->m_xdgSurface->m_committedConfigureSerial);
++    QCOMPOSITOR_TRY_VERIFY(!xdgPopup()->m_grabbed);
++
++    exec([=] {
++        auto *surface = xdgPopup()->surface();
++        auto *p = pointer();
++        auto *c = client();
++        p->sendEnter(surface, {100, 100});
++        p->sendFrame(c);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_pressed);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_released);
++        p->sendFrame(c);
++    });
++
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1));
++    exec([=] { xdgPopup(1)->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1)->m_xdgSurface->m_committedConfigureSerial);
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1)->m_grabbed);
++
++    // Close the middle tooltip (it should not close the sibling popup)
++    window.m_tooltip->close();
++
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(1), nullptr);
++    // Verify the remaining xdg surface is a grab popup..
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(0));
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(0)->m_grabbed);
++
++    window.m_tooltip->m_popup->close();
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(1), nullptr);
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(0), nullptr);
++}
++
+ // QTBUG-65680
+ void tst_xdgshell::switchPopups()
+ {
+@@ -505,7 +598,7 @@ void tst_xdgshell::minMaxSize()
+     window.show();
+     QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
+ 
+-    exec([=] { xdgToplevel()->sendCompleteConfigure(); });
++    // we don't roundtrip with our configuration the initial commit should be correct
+ 
+     QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.minSize, QSize(100, 100));
+     QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.maxSize, QSize(1000, 1000));
+Submodule qtwebchannel 618422ee..f8949655:
+diff --git a/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp b/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
+index 536eb5c..898d769 100644
+--- a/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
++++ b/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
+@@ -186,8 +186,6 @@ Q_DECLARE_TYPEINFO(OverloadResolutionCandidate, Q_MOVABLE_TYPE);
+ QMetaObjectPublisher::QMetaObjectPublisher(QWebChannel *webChannel)
+     : QObject(webChannel)
+     , webChannel(webChannel)
+-    , signalHandler(this)
+-    , clientIsIdle(false)
+     , blockUpdates(false)
+     , propertyUpdatesInitialized(false)
+ {
+@@ -301,17 +299,17 @@ QJsonObject QMetaObjectPublisher::classInfoForObject(const QObject *object, QWeb
+     return data;
+ }
+ 
+-void QMetaObjectPublisher::setClientIsIdle(bool isIdle)
++void QMetaObjectPublisher::setClientIsIdle(bool isIdle, QWebChannelAbstractTransport *transport)
+ {
+-    if (clientIsIdle == isIdle) {
+-        return;
+-    }
+-    clientIsIdle = isIdle;
+-    if (!isIdle && timer.isActive()) {
+-        timer.stop();
+-    } else if (isIdle && !timer.isActive()) {
+-        timer.start(PROPERTY_UPDATE_INTERVAL, this);
+-    }
++    transportState[transport].clientIsIdle = isIdle;
++    if (isIdle)
++        sendEnqueuedPropertyUpdates(transport);
++}
++
++bool QMetaObjectPublisher::isClientIdle(QWebChannelAbstractTransport *transport)
++{
++    auto found = transportState.find(transport);
++    return found != transportState.end() && found.value().clientIsIdle;
+ }
+ 
+ QJsonObject QMetaObjectPublisher::initializeClient(QWebChannelAbstractTransport *transport)
+@@ -333,6 +331,7 @@ QJsonObject QMetaObjectPublisher::initializeClient(QWebChannelAbstractTransport
+ 
+ void QMetaObjectPublisher::initializePropertyUpdates(const QObject *const object, const QJsonObject &objectInfo)
+ {
++    auto *signalHandler = signalHandlerFor(object);
+     foreach (const QJsonValue &propertyInfoVar, objectInfo[KEY_PROPERTIES].toArray()) {
+         const QJsonArray &propertyInfo = propertyInfoVar.toArray();
+         if (propertyInfo.size() < 2) {
+@@ -353,19 +352,19 @@ void QMetaObjectPublisher::initializePropertyUpdates(const QObject *const object
+ 
+         // Only connect for a property update once
+         if (connectedProperties.isEmpty()) {
+-            signalHandler.connectTo(object, signalIndex);
++            signalHandler->connectTo(object, signalIndex);
+         }
+ 
+         connectedProperties.insert(propertyIndex);
+     }
+ 
+     // also always connect to destroyed signal
+-    signalHandler.connectTo(object, s_destroyedSignalIndex);
++    signalHandler->connectTo(object, s_destroyedSignalIndex);
+ }
+ 
+ void QMetaObjectPublisher::sendPendingPropertyUpdates()
+ {
+-    if (blockUpdates || !clientIsIdle || pendingPropertyUpdates.isEmpty()) {
++    if (blockUpdates) {
+         return;
+     }
+ 
+@@ -415,18 +414,19 @@ void QMetaObjectPublisher::sendPendingPropertyUpdates()
+ 
+     // data does not contain specific updates
+     if (!data.isEmpty()) {
+-        setClientIsIdle(false);
+-
+         message[KEY_DATA] = data;
+-        broadcastMessage(message);
++        enqueueBroadcastMessage(message);
+     }
+ 
+     // send every property update which is not supposed to be broadcasted
+     const QHash<QWebChannelAbstractTransport*, QJsonArray>::const_iterator suend = specificUpdates.constEnd();
+     for (QHash<QWebChannelAbstractTransport*, QJsonArray>::const_iterator it = specificUpdates.constBegin(); it != suend; ++it) {
+         message[KEY_DATA] = it.value();
+-        it.key()->sendMessage(message);
++        enqueueMessage(message, it.key());
+     }
++
++    for (auto state = transportState.begin(); state != transportState.end(); ++state)
++        sendEnqueuedPropertyUpdates(state.key());
+ }
+ 
+ QVariant QMetaObjectPublisher::invokeMethod(QObject *const object, const QMetaMethod &method,
+@@ -572,7 +572,7 @@ void QMetaObjectPublisher::signalEmitted(const QObject *object, const int signal
+         }
+     } else {
+         pendingPropertyUpdates[object][signalIndex] = arguments;
+-        if (clientIsIdle && !blockUpdates && !timer.isActive()) {
++        if (!blockUpdates && !timer.isActive()) {
+             timer.start(PROPERTY_UPDATE_INTERVAL, this);
+         }
+     }
+@@ -590,7 +590,7 @@ void QMetaObjectPublisher::objectDestroyed(const QObject *object)
+     // only remove from handler when we initialized the property updates
+     // cf: https://bugreports.qt.io/browse/QTBUG-60250
+     if (propertyUpdatesInitialized) {
+-        signalHandler.remove(object);
++        signalHandlerFor(object)->remove(object);
+         signalToPropertyMap.remove(object);
+     }
+     pendingPropertyUpdates.remove(object);
+@@ -852,6 +852,52 @@ void QMetaObjectPublisher::broadcastMessage(const QJsonObject &message) const
+     }
+ }
+ 
++void QMetaObjectPublisher::enqueueBroadcastMessage(const QJsonObject &message)
++{
++    if (webChannel->d_func()->transports.isEmpty()) {
++        qWarning("QWebChannel is not connected to any transports, cannot send message: %s",
++                 QJsonDocument(message).toJson().constData());
++        return;
++    }
++
++    for (auto *transport : webChannel->d_func()->transports) {
++        auto &state = transportState[transport];
++        state.queuedMessages.append(message);
++    }
++}
++
++void QMetaObjectPublisher::enqueueMessage(const QJsonObject &message,
++                                          QWebChannelAbstractTransport *transport)
++{
++    auto &state = transportState[transport];
++    state.queuedMessages.append(message);
++}
++
++void QMetaObjectPublisher::sendEnqueuedPropertyUpdates(QWebChannelAbstractTransport *transport)
++{
++    auto found = transportState.find(transport);
++    if (found != transportState.end() && found.value().clientIsIdle
++        && !found.value().queuedMessages.isEmpty()) {
++
++        // If the client is connected with an in-process transport, it can
++        // happen that a message triggers a subsequent property change. In
++        // that case, we need to ensure that the queued messages have already
++        // been cleared; otherwise the recursive call will send everythig again.
++        // Case in point: The qmlwebchannel tests fail if we don't clear the
++        // queued messages before sending them out.
++        // For that same reason set the client to "busy" (aka non-idle) just
++        // right before sending out the messages; otherwise a potential
++        // "Idle" type message will not correctly restore the Idle state.
++        const auto messages = std::move(found.value().queuedMessages);
++        Q_ASSERT(found.value().queuedMessages.isEmpty());
++        found.value().clientIsIdle = false;
++
++        for (const auto &message : messages) {
++            transport->sendMessage(message);
++        }
++    }
++}
++
+ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannelAbstractTransport *transport)
+ {
+     if (!webChannel->d_func()->transports.contains(transport)) {
+@@ -866,7 +912,7 @@ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannel
+ 
+     const MessageType type = toType(message.value(KEY_TYPE));
+     if (type == TypeIdle) {
+-        setClientIsIdle(true);
++        setClientIsIdle(true, transport);
+     } else if (type == TypeInit) {
+         if (!message.contains(KEY_ID)) {
+             qWarning("JSON message object is missing the id property: %s",
+@@ -913,9 +959,9 @@ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannel
+                 return;
+             transport->sendMessage(createResponse(message.value(KEY_ID), wrapResult(result, transport)));
+         } else if (type == TypeConnectToSignal) {
+-            signalHandler.connectTo(object, message.value(KEY_SIGNAL).toInt(-1));
++            signalHandlerFor(object)->connectTo(object, message.value(KEY_SIGNAL).toInt(-1));
+         } else if (type == TypeDisconnectFromSignal) {
+-            signalHandler.disconnectFrom(object, message.value(KEY_SIGNAL).toInt(-1));
++            signalHandlerFor(object)->disconnectFrom(object, message.value(KEY_SIGNAL).toInt(-1));
+         } else if (type == TypeSetProperty) {
+             setProperty(object, message.value(KEY_PROPERTY).toInt(-1),
+                         message.value(KEY_VALUE));
+@@ -931,6 +977,7 @@ void QMetaObjectPublisher::setBlockUpdates(bool block)
+     blockUpdates = block;
+ 
+     if (!blockUpdates) {
++        timer.start(PROPERTY_UPDATE_INTERVAL, this);
+         sendPendingPropertyUpdates();
+     } else if (timer.isActive()) {
+         timer.stop();
+@@ -948,4 +995,15 @@ void QMetaObjectPublisher::timerEvent(QTimerEvent *event)
+     }
+ }
+ 
++SignalHandler<QMetaObjectPublisher> *QMetaObjectPublisher::signalHandlerFor(const QObject *object)
++{
++    auto thread = object->thread();
++    auto it = signalHandlers.find(thread);
++    if (it == signalHandlers.end()) {
++        it = signalHandlers.emplace(thread, this).first;
++        it->second.moveToThread(thread);
++    }
++    return &it->second;
++}
++
+ QT_END_NAMESPACE
+diff --git a/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h b/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
+index bbd9875..4713ef1 100644
+--- a/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
++++ b/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
+@@ -59,6 +59,9 @@
+ #include <QBasicTimer>
+ #include <QPointer>
+ #include <QJsonObject>
++#include <QQueue>
++
++#include <unordered_map>
+ 
+ #include "qwebchannelglobal.h"
+ 
+@@ -109,17 +112,36 @@ public:
+      */
+     void broadcastMessage(const QJsonObject &message) const;
+ 
++    /**
++     * Enqueue the given @p message to all known transports.
++     */
++    void enqueueBroadcastMessage(const QJsonObject &message);
++
++    /**
++     * Enqueue the given @p message to @p transport.
++     */
++    void enqueueMessage(const QJsonObject &message, QWebChannelAbstractTransport *transport);
++
++    /**
++     * If client for given @p transport is idle, send queued messaged to @p transport and then mark
++     * the client as not idle.
++     */
++    void sendEnqueuedPropertyUpdates(QWebChannelAbstractTransport *transport);
++
+     /**
+      * Serialize the QMetaObject of @p object and return it in JSON form.
+      */
+     QJsonObject classInfoForObject(const QObject *object, QWebChannelAbstractTransport *transport);
+ 
+     /**
+-     * Set the client to idle or busy, based on the value of @p isIdle.
+-     *
+-     * When the value changed, start/stop the property update timer accordingly.
++     * Set the client to idle or busy for a single @p transport, based on the value of @p isIdle.
++     */
++    void setClientIsIdle(bool isIdle, QWebChannelAbstractTransport *transport);
++
++    /**
++     * Check that client is idle for @p transport.
+      */
+-    void setClientIsIdle(bool isIdle);
++    bool isClientIdle(QWebChannelAbstractTransport *transport);
+ 
+     /**
+      * Initialize clients by sending them the class information of the registered objects.
+@@ -272,10 +294,18 @@ private:
+     friend class TestWebChannel;
+ 
+     QWebChannel *webChannel;
+-    SignalHandler<QMetaObjectPublisher> signalHandler;
++    std::unordered_map<const QThread*, SignalHandler<QMetaObjectPublisher>> signalHandlers;
++    SignalHandler<QMetaObjectPublisher> *signalHandlerFor(const QObject *object);
+ 
+-    // true when the client is idle, false otherwise
+-    bool clientIsIdle;
++    struct TransportState
++    {
++        TransportState() : clientIsIdle(false) { }
++        // true when the client is idle, false otherwise
++        bool clientIsIdle;
++        // messages to send
++        QQueue<QJsonObject> queuedMessages;
++    };
++    QHash<QWebChannelAbstractTransport *, TransportState> transportState;
+ 
+     // true when no property updates should be sent, false otherwise
+     bool blockUpdates;
+diff --git a/qtwebchannel/src/webchannel/signalhandler_p.h b/qtwebchannel/src/webchannel/signalhandler_p.h
+index 27afadb..d77373c 100644
+--- a/qtwebchannel/src/webchannel/signalhandler_p.h
++++ b/qtwebchannel/src/webchannel/signalhandler_p.h
+@@ -56,6 +56,7 @@
+ #include <QVector>
+ #include <QMetaMethod>
+ #include <QDebug>
++#include <QThread>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -71,6 +72,7 @@ static const int s_destroyedSignalIndex = QObject::staticMetaObject.indexOfMetho
+ template<class Receiver>
+ class SignalHandler : public QObject
+ {
++    Q_DISABLE_COPY(SignalHandler)
+ public:
+     SignalHandler(Receiver *receiver, QObject *parent = 0);
+ 
+@@ -268,6 +270,7 @@ int SignalHandler<Receiver>::qt_metacall(QMetaObject::Call call, int methodId, v
+     if (call == QMetaObject::InvokeMetaMethod) {
+         const QObject *object = sender();
+         Q_ASSERT(object);
++        Q_ASSERT(QThread::currentThread() == object->thread());
+         Q_ASSERT(senderSignalIndex() == methodId);
+         Q_ASSERT(m_connectionsCounter.contains(object));
+         Q_ASSERT(m_connectionsCounter.value(object).contains(methodId));
+diff --git a/qtwebchannel/tests/auto/qml/testwebchannel.cpp b/qtwebchannel/tests/auto/qml/testwebchannel.cpp
+index 9891687..3ca81c2 100644
+--- a/qtwebchannel/tests/auto/qml/testwebchannel.cpp
++++ b/qtwebchannel/tests/auto/qml/testwebchannel.cpp
+@@ -46,7 +46,11 @@ TestWebChannel::~TestWebChannel()
+ 
+ bool TestWebChannel::clientIsIdle() const
+ {
+-    return QWebChannel::d_func()->publisher->clientIsIdle;
++    for (auto *transport : QWebChannel::d_func()->transports) {
++        if (QWebChannel::d_func()->publisher->isClientIdle(transport))
++            return true;
++    }
++    return false;
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp b/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
+index 181da9e..37f989a 100644
+--- a/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
++++ b/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
+@@ -785,7 +785,7 @@ void TestWebChannel::testTransportWrapObjectProperties()
+     DummyTransport *dummyTransport = new DummyTransport(this);
+     channel.connectTo(dummyTransport);
+     channel.d_func()->publisher->initializeClient(dummyTransport);
+-    channel.d_func()->publisher->setClientIsIdle(true);
++    channel.d_func()->publisher->setClientIsIdle(true, dummyTransport);
+ 
+     QCOMPARE(channel.d_func()->publisher->transportedWrappedObjects.size(), 0);
+ 
+@@ -943,8 +943,6 @@ void TestWebChannel::testInfiniteRecursion()
+ 
+ void TestWebChannel::testAsyncObject()
+ {
+-    QSKIP("This test is broken. See QTBUG-80729");
+-
+     QWebChannel channel;
+     channel.connectTo(m_dummyTransport);
+ 
+@@ -990,6 +988,50 @@ void TestWebChannel::testAsyncObject()
+     thread.wait();
+ }
+ 
++void TestWebChannel::testPropertyMultipleTransports()
++{
++    DummyTransport transport1;
++    DummyTransport transport2;
++
++    QWebChannel channel;
++    QMetaObjectPublisher *publisher = channel.d_func()->publisher;
++
++    TestObject testObj;
++    testObj.setObjectName("testObject");
++    channel.registerObject(testObj.objectName(), &testObj);
++    channel.connectTo(&transport1);
++    channel.connectTo(&transport2);
++
++    testObj.setProp("Hello");
++
++    publisher->initializeClient(&transport1);
++    publisher->initializeClient(&transport2);
++    publisher->setClientIsIdle(true, &transport1);
++    QCOMPARE(publisher->isClientIdle(&transport1), true);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++    QVERIFY(transport1.messagesSent().isEmpty());
++    QVERIFY(transport2.messagesSent().isEmpty());
++
++    testObj.setProp("World");
++    QTRY_COMPARE_WITH_TIMEOUT(transport1.messagesSent().size(), 1u, 2000);
++    QCOMPARE(transport2.messagesSent().size(), 0u);
++    publisher->setClientIsIdle(true, &transport2);
++    QTRY_COMPARE_WITH_TIMEOUT(transport2.messagesSent().size(), 1u, 2000);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++
++    testObj.setProp("!!!");
++    publisher->setClientIsIdle(true, &transport2);
++    QCOMPARE(publisher->isClientIdle(&transport2), true);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QTRY_COMPARE_WITH_TIMEOUT(transport2.messagesSent().size(), 2u, 2000);
++    QCOMPARE(transport1.messagesSent().size(), 1u);
++    publisher->setClientIsIdle(true, &transport1);
++    QTRY_COMPARE_WITH_TIMEOUT(transport1.messagesSent().size(), 2u, 2000);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++}
++
+ class FunctionWrapper : public QObject
+ {
+     Q_OBJECT
+@@ -1082,7 +1124,7 @@ void TestWebChannel::benchInitializeClients()
+ 
+         publisher->propertyUpdatesInitialized = false;
+         publisher->signalToPropertyMap.clear();
+-        publisher->signalHandler.clear();
++        publisher->signalHandlers.clear();
+     }
+ }
+ 
+@@ -1107,7 +1149,7 @@ void TestWebChannel::benchPropertyUpdates()
+             obj->change();
+         }
+ 
+-        channel.d_func()->publisher->clientIsIdle = true;
++        channel.d_func()->publisher->setClientIsIdle(true, m_dummyTransport);
+         channel.d_func()->publisher->sendPendingPropertyUpdates();
+     }
+ }
+diff --git a/qtwebchannel/tests/auto/webchannel/tst_webchannel.h b/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
+index eae21f4..dd4e690 100644
+--- a/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
++++ b/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
+@@ -348,6 +348,7 @@ private slots:
+     void testJsonToVariant();
+     void testInfiniteRecursion();
+     void testAsyncObject();
++    void testPropertyMultipleTransports();
+     void testDeletionDuringMethodInvocation_data();
+     void testDeletionDuringMethodInvocation();
+ 
+Submodule qtwebengine f328054d...38e0df6c (commits not present)
+Submodule qtwebsockets 65850954..63fb8da1:
+diff --git a/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp b/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
+index 2affdd5..95f1194 100644
+--- a/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
++++ b/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
+@@ -273,6 +273,7 @@ void QWebSocketDataProcessor::clear()
+     if (!m_pConverterState)
+         m_pConverterState = new QTextCodec::ConverterState(QTextCodec::ConvertInvalidToNull |
+                                                            QTextCodec::IgnoreHeader);
++    frame.clear();
+ }
+ 
+ /*!
+diff --git a/qtwebsockets/src/websockets/qwebsocketprotocol.cpp b/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
+index df87a93..d0465f1 100644
+--- a/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
++++ b/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
+@@ -210,7 +210,7 @@ void QWebSocketProtocol::mask(char *payload, quint64 size, quint32 maskingKey)
+                             quint8((maskingKey & 0x0000FF00u) >> 8),
+                             quint8((maskingKey & 0x000000FFu))
+                           };
+-    int i = 0;
++    quint64 i = 0;
+     while (size-- > 0)
+         *payload++ ^= mask[i++ % 4];
+ }
diff --git a/srcpkgs/qt5/template b/srcpkgs/qt5/template
index b6612dffeb1b9..a0d3036af79a4 100644
--- a/srcpkgs/qt5/template
+++ b/srcpkgs/qt5/template
@@ -2,11 +2,11 @@
 #
 # revbump libqtxdg after bumping patch version
 pkgname=qt5
-version=5.15.7+20221119
+version=5.15.8
+revision=1
+build_style=meta
 # commit f8c9fb304bc3e53b3aa07f962cd74e9160decccc
 # base repo: https://invent.kde.org/qt/qt/qt5
-revision=7
-build_style=meta
 hostmakedepends="cmake clang flex perl glib-devel pkg-config
  python3 re2c ruby which"
 makedepends="SDL2-devel Vulkan-Headers alsa-lib-devel double-conversion-devel
@@ -29,9 +29,9 @@ homepage="https://qt.io/"
 # tarball is generated with `git archive-all qt5-$version.tar.gz`
 # to keep the size smaller qtwebengine, qtwebview, qtdocgallery, qtactiveqt and qtpim
 # can be marked with the export-ignore attribute
-distfiles="https://void.johnnynator.dev/distfiles/qt5-${version}.tar.gz"
-checksum=9d57af471c78029a362276b7c99108ea009f511bb9ba6ff6cb884f6ddd255e9f
-python_version=3
+distfiles="https://download.qt.io/archive/qt/5.15/${version}/single/qt-everywhere-opensource-src-${version}.tar.xz"
+checksum=776a9302c336671f9406a53bd30b8e36f825742b2ec44a57c08217bff0fa86b9
+python_version=2 #unverified
 replaces="qt5-doc<5.6.0 qt5-quick1<5.6.0 qt5-quick1-devel<5.6.0 qt5-webkit<5.6.0 qt5-webkit-devel<5.6.0
  qt5-enginio<5.7.1 qt5-enginio-devel<5.7.1 qt5-plugin-gtk<5.7.1 qt5-canvas3d<5.13.0"
 lib32mode=full
@@ -246,7 +246,6 @@ do_configure() {
 	# opts+=" -v"
 	opts+=" -skip qtwebengine"
 	opts+=" -skip qtwebview"
-	opts+=" -skip qtdocgallery"
 	opts+=" -skip qtpim"
 	opts+=" -skip qtsystems"
 	opts+=" -skip qtspeech"

From 2a6d6bfaf0a4fc2a22639bf9a8dfad78dde48aa4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 068/115] qtav: revbump for ffmpeg4-4.4.3

---
 srcpkgs/qtav/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtav/template b/srcpkgs/qtav/template
index 34c30b2c0c78f..2d00ad104355e 100644
--- a/srcpkgs/qtav/template
+++ b/srcpkgs/qtav/template
@@ -1,10 +1,10 @@
 # Template file for 'qtav'
 pkgname=qtav
 version=1.13.0
-revision=1
+revision=2
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel libass-devel libopenal-devel
+makedepends="ffmpeg4-devel libass-devel libopenal-devel
  libva-glx-devel libXv-devel pulseaudio-devel
  qt5-declarative-devel qt5-svg-devel
  qt5-quickcontrols"

From 54d32c6255a15f54042b3d64b3e92bcc5ccc705d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 069/115] qtox: revbump for ffmpeg-6.0

---
 srcpkgs/qtox/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qtox/template b/srcpkgs/qtox/template
index 39c643fecdb5a..bb70e7f51240a 100644
--- a/srcpkgs/qtox/template
+++ b/srcpkgs/qtox/template
@@ -1,7 +1,7 @@
 # Template file for 'qtox'
 pkgname=qtox
 version=1.17.6
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DUPDATE_CHECK=OFF
  -DGIT_DESCRIBE=${version}

From 2afbe792788a326c9638492b1b9c374cef60f3cf Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 070/115] retroarch: revbump for ffmpeg-6.0

---
 srcpkgs/retroarch/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroarch/template b/srcpkgs/retroarch/template
index 45b02597de41a..507805ea8d819 100644
--- a/srcpkgs/retroarch/template
+++ b/srcpkgs/retroarch/template
@@ -1,7 +1,7 @@
 # Template file for 'retroarch'
 pkgname=retroarch
 version=1.15.0
-revision=4
+revision=5
 build_style=configure
 configure_args="--prefix=/usr --sysconfdir=/etc --enable-networking
  --enable-udev --disable-builtinflac --disable-builtinglslang

From cdd78db632d5dccf0e8733dc2e729fa6dcc271e0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 071/115] scrcpy: revbump for ffmpeg-6.0

---
 srcpkgs/scrcpy/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/scrcpy/template b/srcpkgs/scrcpy/template
index ac18bc03418ce..f39a7f678ab35 100644
--- a/srcpkgs/scrcpy/template
+++ b/srcpkgs/scrcpy/template
@@ -1,7 +1,7 @@
 # Template file for 'scrcpy'
 pkgname=scrcpy
 version=2.1.1
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcompile_server=false
  -Dprebuilt_server=/usr/share/scrcpy/scrcpy-server-v${version}"

From e4143effa1a62f92027bfa869633eea99333788d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 17 Oct 2023 08:54:11 -0400
Subject: [PATCH 072/115] New package: spex-x replaces spek-alternative for
 ffmpeg-6.0

---
 srcpkgs/spek-alternative                      |  1 +
 srcpkgs/{spek-alternative => spek-x}/template | 22 ++++++++++++-------
 2 files changed, 15 insertions(+), 8 deletions(-)
 create mode 120000 srcpkgs/spek-alternative
 rename srcpkgs/{spek-alternative => spek-x}/template (52%)

diff --git a/srcpkgs/spek-alternative b/srcpkgs/spek-alternative
new file mode 120000
index 0000000000000..76648236da701
--- /dev/null
+++ b/srcpkgs/spek-alternative
@@ -0,0 +1 @@
+spek-x
\ No newline at end of file
diff --git a/srcpkgs/spek-alternative/template b/srcpkgs/spek-x/template
similarity index 52%
rename from srcpkgs/spek-alternative/template
rename to srcpkgs/spek-x/template
index d7b55c776b1d4..3ded6c2c323e4 100644
--- a/srcpkgs/spek-alternative/template
+++ b/srcpkgs/spek-x/template
@@ -1,18 +1,18 @@
-# Template file for 'spek-alternative'
-pkgname=spek-alternative
-version=0.8.2.3
-revision=2
+# Template file for 'spek-x'
+pkgname=spek-x
+version=0.9.3
+revision=1
 build_style=gnu-configure
 hostmakedepends="automake gettext-devel intltool libtool pkg-config
  wxWidgets-common wxWidgets-gtk3-devel"
 makedepends="ffmpeg-devel wxWidgets-gtk3-devel"
 depends="ffmpeg"
 short_desc="Acoustic spectrum analyser"
-maintainer="Kartik Singh <kartik.ynwa@gmail.com>"
+maintainer="zlice <zlice555@gmail.com>"
 license="GPL-3.0-or-later"
-homepage="https://github.com/withmorten/spek-alternative"
-distfiles="https://github.com/withmorten/spek-alternative/archive/${version}.tar.gz"
-checksum="007ba4b84a310b078e378aa84c8e80783db5821437a757a488c3ecec377e6b2a"
+homepage="https://github.com/MikeWang000000/spek-x"
+distfiles="https://github.com/MikeWang000000/spek-x/archive/v${version}.tar.gz"
+checksum="7f4b109903333cdd310ab2b9176f0dc49a565891376e281a233d342cedf90ef7"
 
 CXXFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
 
@@ -22,3 +22,9 @@ export WX_CONFIG_NAME="wx-config-gtk3"
 pre_configure() {
 	NOCONFIGURE=1 ./autogen.sh
 }
+
+spek-alternative_package() {
+	depends="spek-x"
+	short_desc+=" - transitional dummy package"
+	build_style=meta
+}

From f2c8bbfe21848329a5ac3dafd5a96c5fc4b6dd83 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 073/115] ssr: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ssr/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/ssr/template b/srcpkgs/ssr/template
index b055b9ec0774a..3448ca110eb0c 100644
--- a/srcpkgs/ssr/template
+++ b/srcpkgs/ssr/template
@@ -1,11 +1,11 @@
 # Template file for 'ssr'
 pkgname=ssr
 version=0.4.4
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_QT5=ON"
 hostmakedepends="pkg-config"
-makedepends="alsa-lib-devel ffmpeg-devel glu-devel jack-devel pulseaudio-devel
+makedepends="alsa-lib-devel ffmpeg4-devel glu-devel jack-devel pulseaudio-devel
  qt5-tools-devel qt5-x11extras-devel libXinerama-devel v4l-utils-devel"
 depends="desktop-file-utils hicolor-icon-theme"
 short_desc="Simple Screen Recorder for programs and games"

From e952f55573b2b875a0c6e1d19ec2260a262e3d9f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 074/115] synfig: revbump for ffmpeg-6.0 and mlt7

---
 srcpkgs/synfig/patches/ffmpeg6.patch | 71 ++++++++++++++++++++++++++++
 srcpkgs/synfig/template              |  6 +--
 2 files changed, 74 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/synfig/patches/ffmpeg6.patch

diff --git a/srcpkgs/synfig/patches/ffmpeg6.patch b/srcpkgs/synfig/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..10780b42782f4
--- /dev/null
+++ b/srcpkgs/synfig/patches/ffmpeg6.patch
@@ -0,0 +1,71 @@
+--- a/src/modules/mod_libavcodec/trgt_av.cpp	2022-10-25 09:14:12.000000000 -0400
++++ b/src/modules/mod_libavcodec/trgt_av.cpp	2023-05-05 21:34:17.899194559 -0400
+@@ -38,6 +41,7 @@
+ extern "C"
+ {
+ #ifdef HAVE_LIBAVFORMAT_AVFORMAT_H
++#	include <libavcodec/avcodec.h>
+ #	include <libavformat/avformat.h>
+ #elif defined(HAVE_AVFORMAT_H)
+ #	include <avformat.h>
+@@ -155,11 +156,11 @@
+     }
+ 
+ 	bool open_video_stream() {
+-		if (avcodec_open2(video_context, NULL, NULL) < 0) {
++		if (avcodec_open2(video_context, nullptr, nullptr) < 0) {
+ 			synfig::error("Target_LibAVCodec: could not open video codec");
+ 			// seems the calling of avcodec_free_context after error will cause crash
+ 			// so just forget about this context
+-			video_context = NULL;
++			video_context = nullptr;
+ 			close();
+ 			return false;
+         }
+@@ -234,15 +235,21 @@
+ 		close();
+ 
+ 		if (!av_registered) {
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 			av_register_all();
++#endif
+ 			av_registered = true;
+ 		}
+ 
+ 		// guess format
+-		AVOutputFormat *format = av_guess_format(NULL, filename.c_str(), NULL);
++#if LIBAVCODEC_VERSION_MAJOR < 59 // FFMPEG < 5.0
++		AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#else
++		const AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#endif
+ 		if (!format) {
+ 			synfig::warning("Target_LibAVCodec: unable to guess the output format, defaulting to MPEG");
+-			format = av_guess_format("mpeg", NULL, NULL);
++			format = av_guess_format("mpeg", nullptr, nullptr);
+ 		}
+ 		if (!format) {
+ 			synfig::error("Target_LibAVCodec: unable to find 'mpeg' output format");
+@@ -254,6 +261,7 @@
+ 		context = avformat_alloc_context();
+ 		assert(context);
+ 		context->oformat = format;
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 		if (filename.size() + 1 > sizeof(context->filename)) {
+ 			synfig::error(
+ 				"Target_LibAVCodec: filename too long, max length is %d, filename is '%s'",
+@@ -263,6 +271,14 @@
+ 			return false;
+ 		}
+ 		memcpy(context->filename, filename.c_str(), filename.size() + 1);
++#else
++		context->url = av_strndup(filename.c_str(), filename.size());
++		if (!context->url) {
++			synfig::error("Target_LibAVCodec: cannot allocate space for filename");
++			close();
++			return false;
++		}
++#endif
+ 
+ 		packet = av_packet_alloc();
+ 		assert(packet);
diff --git a/srcpkgs/synfig/template b/srcpkgs/synfig/template
index 30109541ec4fc..703cfd7ebac84 100644
--- a/srcpkgs/synfig/template
+++ b/srcpkgs/synfig/template
@@ -2,11 +2,11 @@
 # Should be kept in sync with 'synfigstudio' and 'ETL'
 pkgname=synfig
 version=1.4.4
-revision=3
+revision=4
 build_style=gnu-configure
 configure_args="--with-boost-libdir=${XBPS_CROSS_BASE}/usr/lib"
 hostmakedepends="boost-build ImageMagick pkg-config intltool"
-makedepends="ETL gettext-devel libxml++-devel mlt-devel libmagick-devel
+makedepends="ETL gettext-devel libxml++-devel mlt7-devel libmagick-devel
  libmng-devel boost-build boost-devel libopenexr-devel ffmpeg-devel"
 depends="ImageMagick"
 short_desc="CLI 2D vector and timeline-based animation software"
@@ -20,7 +20,7 @@ CXXFLAGS="-std=c++11 -DHAVE_LOCALE_H=1"
 
 synfig-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision}
-	 libopenexr-devel libxml++-devel mlt-devel"
+	 libopenexr-devel libxml++-devel mlt7-devel"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/bin/synfig-config

From 3a6c7eff6d7a8ca6130c411102c4e808bb7b8aab Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 075/115] timg: revbump for ffmpeg-6.0

---
 srcpkgs/timg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/timg/template b/srcpkgs/timg/template
index 2a2ab763d2fdd..8fb4327535ef9 100644
--- a/srcpkgs/timg/template
+++ b/srcpkgs/timg/template
@@ -1,7 +1,7 @@
 # Template file for 'timg'
 pkgname=timg
 version=1.4.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_OPENSLIDE_SUPPORT=off -Wno-dev"
 hostmakedepends="pkg-config git"

From eaf29fb2d77e00ad65dd1f789018aff65c514963 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 076/115] tvheadend: revbump for ffmpeg4-4.4.3

---
 srcpkgs/tvheadend/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tvheadend/template b/srcpkgs/tvheadend/template
index 9aea7de4ec705..012d31c4879ff 100644
--- a/srcpkgs/tvheadend/template
+++ b/srcpkgs/tvheadend/template
@@ -8,7 +8,7 @@ configure_args="--enable-dvbscan --disable-ffmpeg_static
 --disable-libx265_static --disable-libvpx_static --disable-libtheora_static
 --disable-libvorbis_static --disable-libfdkaac_static"
 hostmakedepends="gettext pkg-config python3 git which"
-makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg-devel"
+makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg4-devel"
 short_desc="TV streaming server"
 maintainer="lemmi <lemmi@nerd2nerd.org>"
 license="GPL-3.0-only"

From e5004758d7fb1474c034928d01aaefabaab134d0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 077/115] unpaper: update to 7.0.0.

---
 srcpkgs/unpaper/template | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/srcpkgs/unpaper/template b/srcpkgs/unpaper/template
index 38ed47a584016..1ff910e722afc 100644
--- a/srcpkgs/unpaper/template
+++ b/srcpkgs/unpaper/template
@@ -1,13 +1,13 @@
 # Template file for 'unpaper'
 pkgname=unpaper
-version=6.1
-revision=3
-build_style=gnu-configure
+version=7.0.0
+revision=1
+build_style=meson
+hostmakedepends="pkg-config meson libxslt"
+makedepends="ffmpeg-devel python3-Sphinx"
+short_desc="Post-processing tool for scanned sheets of paper"
 maintainer="Orphaned <orphan@voidlinux.org>"
-hostmakedepends="pkg-config libxslt"
-makedepends="ffmpeg-devel"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://www.flameeyes.eu/projects/unpaper"
-short_desc="A post-processing tool for scanned sheets of paper"
 distfiles="https://www.flameeyes.eu/files/${pkgname}-${version}.tar.xz"
-checksum=237c84f5da544b3f7709827f9f12c37c346cdf029b1128fb4633f9bafa5cb930
+checksum=2575fbbf26c22719d1cb882b59602c9900c7f747118ac130883f63419be46a80

From 605a167ec1531b03fadf779870d9c8ee1f655dd4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 078/115] vba-m: revbump for ffmpeg-6.0

---
 srcpkgs/vba-m/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vba-m/template b/srcpkgs/vba-m/template
index 9c71cefe3f8dd..2223d297c31f5 100644
--- a/srcpkgs/vba-m/template
+++ b/srcpkgs/vba-m/template
@@ -2,7 +2,7 @@
 pkgname=vba-m
 reverts=1292_2
 version=2.1.7
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DENABLE_GTK=TRUE -DENABLE_FFMPEG=TRUE -DENABLE_LINK=TRUE -DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="gettext pkg-config unzip zip yasm wxWidgets-gtk3-devel"

From a0188e5d69191a8e9177a2d524da92f777384322 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 079/115] vice: revbump for ffmpeg4-4.4.3

---
 srcpkgs/vice/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/vice/template b/srcpkgs/vice/template
index fe9d33a811947..4beab2c5f9ebd 100644
--- a/srcpkgs/vice/template
+++ b/srcpkgs/vice/template
@@ -1,7 +1,7 @@
 # Template file for 'vice'
 pkgname=vice
 version=3.7.1
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="
 	$(vopt_enable sdl2 sdlui2)
@@ -26,7 +26,7 @@ makedepends="
 	$(vopt_if gtk3 gtk+3-devel)
 	$(vopt_if gtk3 pulseaudio-devel)
 	$(vopt_if gtk3 pango-devel)
-	$(vopt_if ffmpeg ffmpeg-devel)"
+	$(vopt_if ffmpeg ffmpeg4-devel)"
 short_desc="Emulator for C64, C128, CBM-II, PET, VIC20, Plus4 and C16"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"

From 6636821b603e6384a2832cdf3378174d357023dc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 080/115] waypipe: revbump for ffmpeg-6.0

---
 srcpkgs/waypipe/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waypipe/template b/srcpkgs/waypipe/template
index 6da88b21bf2a1..4da8058400b58 100644
--- a/srcpkgs/waypipe/template
+++ b/srcpkgs/waypipe/template
@@ -1,7 +1,7 @@
 # Template file for 'waypipe'
 pkgname=waypipe
 version=0.8.6
-revision=1
+revision=2
 build_style=meson
 # lto is off because it causes linking errors in armv6l and armv7l (due to NEON)
 configure_args="-Dwerror=false -Dwith_dmabuf=enabled -Dwith_lz4=enabled

From b1788ffde3d5468150bf0b23053f4f560f74ba7f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 081/115] wf-recorder: revbump for ffmpeg-6.0

---
 srcpkgs/wf-recorder/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/wf-recorder/template b/srcpkgs/wf-recorder/template
index cdf8d26dcb8e1..08f986b031006 100644
--- a/srcpkgs/wf-recorder/template
+++ b/srcpkgs/wf-recorder/template
@@ -1,7 +1,7 @@
 # Template file for 'wf-recorder'
 pkgname=wf-recorder
 version=0.4.1
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config scdoc wayland-devel"
 makedepends="wayland-protocols wayland-devel ffmpeg-devel libgbm-devel x264-devel

From e41809891f3df52265083881d0c2ec35b4ea1470 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 082/115] xpra: revbump for ffmpeg-6.0

---
 srcpkgs/xpra/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xpra/template b/srcpkgs/xpra/template
index 394718b56f686..34fbff9b2f1ae 100644
--- a/srcpkgs/xpra/template
+++ b/srcpkgs/xpra/template
@@ -1,7 +1,7 @@
 # Template file for 'xpra'
 pkgname=xpra
 version=5.0.3
-revision=1
+revision=2
 build_style=python3-module
 make_build_args="--without-cuda_kernels --without-cuda_rebuild"
 make_install_args="$(vopt_with docs) ${make_build_args}"

From 71fa1e9da44285b80d9205f02c25dfba3dbb1790 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:07:40 -0400
Subject: [PATCH 083/115] nv-codec-headers: update to 12.0.16.0

---
 srcpkgs/nv-codec-headers/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/nv-codec-headers/template b/srcpkgs/nv-codec-headers/template
index 3d422a61e4891..251e057f826fb 100644
--- a/srcpkgs/nv-codec-headers/template
+++ b/srcpkgs/nv-codec-headers/template
@@ -1,6 +1,6 @@
 # Template file for 'nv-codec-headers'
 pkgname=nv-codec-headers
-version=11.1.5.1
+version=12.0.16.0
 revision=1
 build_style=gnu-makefile
 short_desc="FFmpeg version of headers required to interface with Nvidias codec APIs"
@@ -8,7 +8,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="MIT"
 homepage="http://git.videolan.org/?p=ffmpeg/nv-codec-headers.git"
 distfiles="https://github.com/FFmpeg/nv-codec-headers/archive/n${version}.tar.gz"
-checksum=d095fbd56aa93772471a323be0ebe65504a0f43f06c76a30b6d25da77b06ae9c
+checksum=2a1533b65f55f9da52956faf0627ed3b74868ac0c7f269990edd21369113b48f
 
 post_install() {
 	sed -n '4,25p' include/ffnvcodec/nvEncodeAPI.h > LICENSE

From a10d9848224850285561c0d5bdb8aa19f708897c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:08:40 -0400
Subject: [PATCH 084/115] openimagedenoise: revbump for ffmpeg-6.0

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index b792813dba7c2..109deb171c3f7 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,7 +1,7 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
 version=1.4.3
-revision=1
+revision=2
 archs="x86_64*"
 build_style=cmake
 hostmakedepends="ispc python3"

From 422329d3821e25013d48a9f4544a2b8bbdb081c3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:31:45 -0400
Subject: [PATCH 085/115] shotcut: revbump for ffmpeg-6.0

---
 srcpkgs/shotcut/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/shotcut/template b/srcpkgs/shotcut/template
index 7d2af7b0470b5..c416c906ff734 100644
--- a/srcpkgs/shotcut/template
+++ b/srcpkgs/shotcut/template
@@ -1,7 +1,7 @@
 # Template file for 'shotcut'
 pkgname=shotcut
 version=23.05.14
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSHOTCUT_VERSION=${version}"
 hostmakedepends="pkg-config qt6-tools-devel"

From 51f78db9f7e1810be3a08377fbb66c4bb3835251 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:30 -0400
Subject: [PATCH 086/115] shiboken2: revbump for qt5-5.15.8

---
 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch | 1 +
 srcpkgs/shiboken2/template                                 | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
 create mode 120000 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
new file mode 120000
index 0000000000000..efcf3249bd885
--- /dev/null
+++ b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1 @@
+../../python3-pyside2/patches/importlib-machinery-bypass.patch
\ No newline at end of file
diff --git a/srcpkgs/shiboken2/template b/srcpkgs/shiboken2/template
index 883d6a084d868..f3c06ec245a1f 100644
--- a/srcpkgs/shiboken2/template
+++ b/srcpkgs/shiboken2/template
@@ -1,7 +1,7 @@
 # Template file for 'shiboken2'
 pkgname=shiboken2
 version=5.15.10
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/shiboken2"
 build_style=cmake

From f45cea2a149c5321859ccd3bd20d0c07cbadd866 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:53 -0400
Subject: [PATCH 087/115] python3-pyside2: revbump for qt5-5.15.8

---
 .../patches/importlib-machinery-bypass.patch      | 15 +++++++++++++++
 srcpkgs/python3-pyside2/template                  |  2 +-
 2 files changed, 16 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
new file mode 100644
index 0000000000000..64c429584776b
--- /dev/null
+++ b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1,15 @@
+Using this prevents an error around line 220 below it.
+"AttributeError: module 'importlib' has no attribute 'machinery'"
+The old backup logic is in place and compiles without issues.
+--- a/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:09:34.688912402 -0400
++++ b/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:10:03.395529582 -0400
+@@ -170,9 +170,6 @@
+
+     # 'zipstring_sequence' comes from signature.cpp
+     zipbytes = base64.b64decode(''.join(zipstring_sequence))
+-    if sys.version_info[0] >= 3:
+-        vzip = zipfile.ZipFile(io.BytesIO(zipbytes))
+-        return sys.meta_path, EmbeddableZipImporter(vzip)
+
+     # Old version for Python 2.7, only.
+     import os
diff --git a/srcpkgs/python3-pyside2/template b/srcpkgs/python3-pyside2/template
index 249efa9098842..52626436ce75f 100644
--- a/srcpkgs/python3-pyside2/template
+++ b/srcpkgs/python3-pyside2/template
@@ -1,7 +1,7 @@
 # Template file for 'python3-pyside2'
 pkgname=python3-pyside2
 version=5.15.10
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/pyside2"
 build_style=cmake

From deb52dd8eac9505b9b9ae7d251f0d186687cdc21 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:35 -0400
Subject: [PATCH 088/115] konqueror: revbump for ffmpeg-6.0

---
 srcpkgs/konqueror/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/konqueror/template b/srcpkgs/konqueror/template
index abfa59e6b7ded..3cc29c12dc1db 100644
--- a/srcpkgs/konqueror/template
+++ b/srcpkgs/konqueror/template
@@ -1,11 +1,11 @@
 # Template file for 'konqueror'
 pkgname=konqueror
 version=23.08.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DDESKTOPTOJSON_EXECUTABLE=/usr/bin/desktoptojson"
 hostmakedepends="extra-cmake-modules python3 qt5-host-tools qt5-qmake kdoctools
-kcoreaddons kconfig gettext"
+ kcoreaddons kconfig gettext"
 makedepends="qt5-devel qt5-webengine-devel qt5-declarative-devel
  qt5-webchannel-devel qt5-location-devel kcmutils-devel kdelibs4support-devel
  karchive-devel khtml-devel kdesu-devel kactivities5-devel"

From e3c6d504119a51c9f0ebfca087e6ad8387bc5a7e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:58 -0400
Subject: [PATCH 089/115] qt5-speech: revbump for qt5-5.15.8

---
 srcpkgs/qt5-speech/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-speech/template b/srcpkgs/qt5-speech/template
index 3ecd10d50650c..2d7d4d4d24535 100644
--- a/srcpkgs/qt5-speech/template
+++ b/srcpkgs/qt5-speech/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-speech'
 pkgname=qt5-speech
 version=5.15.7
-revision=2
+revision=3
 _commit=d32f4a479d38a11f547598004b975f4356424a16
 build_style=qmake
 configure_args="-- -flite -flite-alsa -speechd"

From 4cd32e338ee9dd1c28f908e94b4707420ae6ea49 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 18:38:50 -0400
Subject: [PATCH 090/115] qt5-styleplugins: revbump for qt5-5.15.8

---
 srcpkgs/qt5-styleplugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-styleplugins/template b/srcpkgs/qt5-styleplugins/template
index 96ed97d12cd24..30d93660a2a4e 100644
--- a/srcpkgs/qt5-styleplugins/template
+++ b/srcpkgs/qt5-styleplugins/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-styleplugins'
 pkgname=qt5-styleplugins
 version=5.0.0
-revision=20
+revision=21
 _gitrev=335dbece103e2cbf6c7cf819ab6672c2956b17b3
 build_style=qmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From 65e9675548546971da2f8864cf96f8ace0f28cd0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 7 May 2023 20:15:03 -0400
Subject: [PATCH 091/115] qt6-webengine: revbump for ffmpeg-6.0

---
 srcpkgs/qt6-webengine/template | 1 +
 1 file changed, 1 insertion(+)

diff --git a/srcpkgs/qt6-webengine/template b/srcpkgs/qt6-webengine/template
index a92b06c6f0cca..14a9bfc082935 100644
--- a/srcpkgs/qt6-webengine/template
+++ b/srcpkgs/qt6-webengine/template
@@ -146,6 +146,7 @@ pre_install() {
 }
 
 post_install() {
+	vlicense LICENSES/BSD-3-Clause.txt
 	local _file
 	find "${DESTDIR}"/usr/lib/qt6/examples \
 		-path '*/lib/qt6/**/lib/qt6/*' -type f |

From a01d4ec81d9fae33cd68ece32d8a6138a99d1723 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 21 May 2023 12:44:11 -0400
Subject: [PATCH 092/115] electron24: revbump for ffmpeg-6.0

---
 srcpkgs/electron24/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron24/template b/srcpkgs/electron24/template
index 59e078a7b47cb..a9c865c19c989 100644
--- a/srcpkgs/electron24/template
+++ b/srcpkgs/electron24/template
@@ -1,7 +1,7 @@
 # Template file for 'electron24'
 pkgname=electron24
 version=24.3.0
-revision=1
+revision=2
 _nodever=18.14.0
 _chromiumver=112.0.5615.165
 archs="x86_64* aarch64*"

From 8e5dce12892e45e014f54fab16cba20925274161 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Jun 2023 08:20:22 -0400
Subject: [PATCH 093/115] gtk4: revbump for ffmpeg-6.0

---
 srcpkgs/gtk4/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gtk4/template b/srcpkgs/gtk4/template
index 6a4e20357a86f..ec0c13d2cc5b0 100644
--- a/srcpkgs/gtk4/template
+++ b/srcpkgs/gtk4/template
@@ -1,7 +1,7 @@
 # Template file for 'gtk4'
 pkgname=gtk4
 version=4.12.3
-revision=1
+revision=2
 build_style=meson
 build_helper="gir"
 configure_args="-Dman-pages=true -Ddocumentation=true -Dbuild-tests=false

From 1bb28c17b7756170379430731551037c45293619 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:25:50 -0400
Subject: [PATCH 094/115] electron19: revbump for ffmpeg-6.0

---
 srcpkgs/electron19/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron19/template b/srcpkgs/electron19/template
index 4b40de20a3fe2..b18bc792c8221 100644
--- a/srcpkgs/electron19/template
+++ b/srcpkgs/electron19/template
@@ -1,7 +1,7 @@
 # Template file for 'electron19'
 pkgname=electron19
 version=19.0.8
-revision=3
+revision=4
 _nodever=16.14.2
 _chromiumver=102.0.5005.125
 archs="x86_64* aarch64* ppc64le*"

From eead3c551ec013149ab3d2f990e86d8b83038bd5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:28:26 -0400
Subject: [PATCH 095/115] siril: revbump for ffmpeg-6.0

---
 srcpkgs/siril/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/siril/template b/srcpkgs/siril/template
index 84332f79d060d..62750dd247548 100644
--- a/srcpkgs/siril/template
+++ b/srcpkgs/siril/template
@@ -1,7 +1,7 @@
 # Template file for 'siril'
 pkgname=siril
 version=0.9.12
-revision=10
+revision=11
 build_style=gnu-configure
 hostmakedepends="pkg-config intltool autoconf automake gettext-devel"
 makedepends="fftw-devel libconfig-devel libopencv-devel libffms2-devel

From 60cdf27d87a994cc0a574847420df51a945e0608 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 10 Jun 2023 00:57:09 -0400
Subject: [PATCH 096/115] qt6-multimedia: revbump for ffmpeg-6.0

---
 srcpkgs/qt6-multimedia/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-multimedia/template b/srcpkgs/qt6-multimedia/template
index 2cf997b227a45..ca39534afb7f3 100644
--- a/srcpkgs/qt6-multimedia/template
+++ b/srcpkgs/qt6-multimedia/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-multimedia'
 pkgname=qt6-multimedia
 version=6.5.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DQT_FEATURE_gstreamer=ON"
 hostmakedepends="perl qt6-declarative-host-tools pkg-config qt6-shadertools"

From 5081fbe710a54a562631192ccbcddf885432e95e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 22 Jun 2023 10:25:02 -0400
Subject: [PATCH 097/115] kdenlive: revbump for ffmpeg-6.0

---
 srcpkgs/kdenlive/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kdenlive/template b/srcpkgs/kdenlive/template
index ec5fe75860948..e69ecff31f272 100644
--- a/srcpkgs/kdenlive/template
+++ b/srcpkgs/kdenlive/template
@@ -1,7 +1,7 @@
 # Template file for 'kdenlive'
 pkgname=kdenlive
 version=23.08.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="
  extra-cmake-modules kconfig kcoreaddons kdoctools pkg-config python3

From 78837a74a39b9452792ad883f637d13b3e404c31 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Jul 2023 09:18:23 -0400
Subject: [PATCH 098/115] gmic: revbump for opencv-4.7.0

---
 srcpkgs/gmic/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gmic/template b/srcpkgs/gmic/template
index 0bb4034d5cc86..808953e9b543c 100644
--- a/srcpkgs/gmic/template
+++ b/srcpkgs/gmic/template
@@ -1,7 +1,7 @@
 # Template file for 'gmic'
 pkgname=gmic
 version=3.1.6
-revision=4
+revision=5
 _zart_hash=34ebf6cce0bafb98abe57cec83c4a02cd1abeca0
 create_wrksrc=yes
 build_wrksrc="src"

From f95810837325661337b477563f0613a5bb2be15d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Jul 2023 09:29:52 -0400
Subject: [PATCH 099/115] synfigstudio: revbump for synfig mlt7

---
 srcpkgs/synfigstudio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/synfigstudio/template b/srcpkgs/synfigstudio/template
index af1c5a296ef0f..09e442da9a680 100644
--- a/srcpkgs/synfigstudio/template
+++ b/srcpkgs/synfigstudio/template
@@ -2,7 +2,7 @@
 # Should be kept in sync with 'synfig' and 'ETL'
 pkgname=synfigstudio
 version=1.4.4
-revision=3
+revision=4
 build_style=gnu-configure
 configure_args="--disable-update-mimedb"
 hostmakedepends="pkg-config intltool gettext synfig"

From 3dfb5dbc32fdc9df7f201fcbb02a529c1c2cfe48 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Jul 2023 11:17:37 -0400
Subject: [PATCH 100/115] DELETE: intel_packages

---
 common/shlibs                                 |   2 +
 srcpkgs/intel-gmmlib/template                 |   6 +-
 ...mmon-Enable-MMC-in-free-kernel-build.patch | 125 ++++++++++++++++++
 srcpkgs/intel-media-driver/template           |   6 +-
 srcpkgs/intel-media-sdk/patches/musl.patch    |  14 ++
 srcpkgs/intel-media-sdk/template              |  37 ++++++
 srcpkgs/intel-media-sdk/update                |   1 +
 srcpkgs/libmfx                                |   1 +
 srcpkgs/libmfx-devel                          |   1 +
 srcpkgs/onevpl-devel                          |   1 +
 srcpkgs/onevpl-intel-gpu-devel                |   1 +
 srcpkgs/onevpl-intel-gpu/template             |  27 ++++
 srcpkgs/onevpl/template                       |  34 +++++
 13 files changed, 250 insertions(+), 6 deletions(-)
 create mode 100644 srcpkgs/intel-media-driver/patches/0001-Media-Common-Enable-MMC-in-free-kernel-build.patch
 create mode 100644 srcpkgs/intel-media-sdk/patches/musl.patch
 create mode 100644 srcpkgs/intel-media-sdk/template
 create mode 100644 srcpkgs/intel-media-sdk/update
 create mode 120000 srcpkgs/libmfx
 create mode 120000 srcpkgs/libmfx-devel
 create mode 120000 srcpkgs/onevpl-devel
 create mode 120000 srcpkgs/onevpl-intel-gpu-devel
 create mode 100644 srcpkgs/onevpl-intel-gpu/template
 create mode 100644 srcpkgs/onevpl/template

diff --git a/common/shlibs b/common/shlibs
index b1ba1497c8295..24c8dc4b2354d 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4253,6 +4253,8 @@ libgsoapssl++-2.8.124.so gsoap-2.8.124_1
 libjxl.so.0.8 libjxl-0.8.2_1
 libjxl_dec.so.0.8 libjxl-0.8.2_1
 libjxl_threads.so.0.8 libjxl-0.8.2_1
+libmfx.so.1 libmfx-22.6.4_1
+libvpl.so.2 onevpl-2023.1.2_1
 libtext-engine-0.1.so.0 text-engine-0.1.1_1
 libvmaf.so.1 vmaf-2.3.1_1
 liblc3.so.1 liblc3-1.0.3_1
diff --git a/srcpkgs/intel-gmmlib/template b/srcpkgs/intel-gmmlib/template
index 04e407b1de4d3..2605226152e5d 100644
--- a/srcpkgs/intel-gmmlib/template
+++ b/srcpkgs/intel-gmmlib/template
@@ -1,6 +1,6 @@
 # Template file for 'intel-gmmlib'
 pkgname=intel-gmmlib
-version=22.2.0
+version=22.3.3
 revision=1
 archs="i686* x86_64*"
 build_style=cmake
@@ -14,11 +14,11 @@ build_style=cmake
 # compilers flag in use.
 configure_args="-Wno-dev"
 short_desc="Intel Graphics Memory Management Library"
-maintainer="Orphaned <orphan@voidlinux.org>"
+maintainer="Stefano Ragni <st3r4g@protonmail.com>"
 license="MIT"
 homepage="https://github.com/intel/gmmlib"
 distfiles="https://github.com/intel/gmmlib/archive/intel-gmmlib-${version}.tar.gz"
-checksum=0b2253894c6fc8455b6d7c5e87e6504a76d6f60ea192e1445c2f93164bf529c0
+checksum=86651bd2803c9f0afd82471bec784e65d2b418dee315a053d22215eb2a679be7
 
 lib32disabled=yes
 
diff --git a/srcpkgs/intel-media-driver/patches/0001-Media-Common-Enable-MMC-in-free-kernel-build.patch b/srcpkgs/intel-media-driver/patches/0001-Media-Common-Enable-MMC-in-free-kernel-build.patch
new file mode 100644
index 0000000000000..525fb688722c8
--- /dev/null
+++ b/srcpkgs/intel-media-driver/patches/0001-Media-Common-Enable-MMC-in-free-kernel-build.patch
@@ -0,0 +1,125 @@
+From e68feab7db036838d9521ba3b9f00717c37c024c Mon Sep 17 00:00:00 2001
+From: JayYang <jay.yang@intel.com>
+Date: Tue, 21 Mar 2023 17:17:55 +0800
+Subject: [PATCH] [Media Common] Enable MMC in free kernel build
+
+Add mmc build definition in free kernel build
+---
+ media_driver/agnostic/gen9/codec/hal/media_srcs.cmake          | 2 +-
+ media_driver/cmake/linux/media_feature_flags_linux.cmake       | 3 +--
+ .../media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp        | 2 +-
+ .../media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp        | 2 +-
+ .../media_interfaces_m9_glk/media_interfaces_g9_glk.cpp        | 2 +-
+ .../media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp        | 2 +-
+ .../media_interfaces_m9_skl/media_interfaces_g9_skl.cpp        | 2 +-
+ 7 files changed, 7 insertions(+), 8 deletions(-)
+
+diff --git a/media_driver/agnostic/gen9/codec/hal/media_srcs.cmake b/media_driver/agnostic/gen9/codec/hal/media_srcs.cmake
+index 8bb36bafe..78902a22d 100644
+--- a/media_driver/agnostic/gen9/codec/hal/media_srcs.cmake
++++ b/media_driver/agnostic/gen9/codec/hal/media_srcs.cmake
+@@ -27,7 +27,7 @@ set(TMP_1_HEADERS_
+     ${CMAKE_CURRENT_LIST_DIR}/codechal_hw_g9_X.h
+ )
+ 
+-if(${MMC_Supported} STREQUAL "yes")
++if(${MMC_Supported} STREQUAL "yes" AND ENABLE_NONFREE_KERNELS AND ENABLE_KERNELS)
+     set(TMP_1_SOURCES_
+         ${TMP_1_SOURCES_}
+         ${CMAKE_CURRENT_LIST_DIR}/codechal_memdecomp_g9.cpp
+diff --git a/media_driver/cmake/linux/media_feature_flags_linux.cmake b/media_driver/cmake/linux/media_feature_flags_linux.cmake
+index de0ca853f..8121ea60c 100644
+--- a/media_driver/cmake/linux/media_feature_flags_linux.cmake
++++ b/media_driver/cmake/linux/media_feature_flags_linux.cmake
+@@ -35,7 +35,6 @@ if(NOT ENABLE_KERNELS OR NOT ENABLE_NONFREE_KERNELS)
+     bs_set_if_undefined(HEVC_Encode_VME_Supported "no")
+     bs_set_if_undefined(MPEG2_Encode_VME_Supported "no")
+     bs_set_if_undefined(CMRT_HEVC_ENC_FEI_Supported "no")
+-    bs_set_if_undefined(MMC_Supported "no")
+     bs_set_if_undefined(VC1_Decode_Supported "no")
+     bs_set_if_undefined(Decode_Processing_Supported "no")
+     bs_set_if_undefined(Kernel_Auto_Denoise_Supported "no")
+@@ -46,7 +45,6 @@ else()
+     bs_set_if_undefined(HEVC_Encode_VME_Supported "${Encode_VME_Supported}")
+     bs_set_if_undefined(MPEG2_Encode_VME_Supported "${Encode_VME_Supported}")
+     bs_set_if_undefined(CMRT_HEVC_ENC_FEI_Supported "yes")
+-    bs_set_if_undefined(MMC_Supported "yes")
+     bs_set_if_undefined(VC1_Decode_Supported "yes")
+     bs_set_if_undefined(Decode_Processing_Supported "yes")
+     bs_set_if_undefined(Kernel_Auto_Denoise_Supported "yes")
+@@ -64,6 +62,7 @@ bs_set_if_undefined(VP9_Decode_Supported "yes")
+ bs_set_if_undefined(VP_SFC_Supported "yes")
+ bs_set_if_undefined(Common_Encode_Supported "yes")
+ bs_set_if_undefined(Media_Scalability_Supported "yes")
++bs_set_if_undefined(MMC_Supported "yes")
+ 
+ # features controlled by global flag Encode_VDEnc_Supported
+ bs_set_if_undefined(AVC_Encode_VDEnc_Supported "${Encode_VDEnc_Supported}")
+diff --git a/media_driver/media_interface/media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp b/media_driver/media_interface/media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp
+index 3f306ee2a..8e4c0f532 100644
+--- a/media_driver/media_interface/media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp
+@@ -135,7 +135,7 @@ MOS_STATUS MhwInterfacesG9Bxt::Initialize(
+ 
+     return MOS_STATUS_SUCCESS;
+ }
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool bxtRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Bxt>((uint32_t)IGFX_BROXTON);
+diff --git a/media_driver/media_interface/media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp b/media_driver/media_interface/media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp
+index b8fa1eec0..84e0fad1d 100644
+--- a/media_driver/media_interface/media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp
+@@ -44,7 +44,7 @@ static bool cflRegisteredMhw =
+     MediaFactory<uint32_t, MhwInterfaces>::
+     Register<MhwInterfacesG9Kbl>((uint32_t)IGFX_COFFEELAKE);
+ 
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool cflRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Kbl>((uint32_t)IGFX_COFFEELAKE);
+diff --git a/media_driver/media_interface/media_interfaces_m9_glk/media_interfaces_g9_glk.cpp b/media_driver/media_interface/media_interfaces_m9_glk/media_interfaces_g9_glk.cpp
+index de81e6091..2638cb3a6 100644
+--- a/media_driver/media_interface/media_interfaces_m9_glk/media_interfaces_g9_glk.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_glk/media_interfaces_g9_glk.cpp
+@@ -65,7 +65,7 @@ static bool glkRegisteredMhw =
+     MediaFactory<uint32_t, MhwInterfaces>::
+     Register<MhwInterfacesG9Kbl>((uint32_t)IGFX_GEMINILAKE);
+ 
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool glkRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Kbl>((uint32_t)IGFX_GEMINILAKE);
+diff --git a/media_driver/media_interface/media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp b/media_driver/media_interface/media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp
+index 99d786185..4e9c6e7f1 100644
+--- a/media_driver/media_interface/media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp
+@@ -131,7 +131,7 @@ MOS_STATUS MhwInterfacesG9Kbl::Initialize(
+ 
+     return MOS_STATUS_SUCCESS;
+ }
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool kblRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Kbl>((uint32_t)IGFX_KABYLAKE);
+diff --git a/media_driver/media_interface/media_interfaces_m9_skl/media_interfaces_g9_skl.cpp b/media_driver/media_interface/media_interfaces_m9_skl/media_interfaces_g9_skl.cpp
+index e2520edf7..4b0012c64 100644
+--- a/media_driver/media_interface/media_interfaces_m9_skl/media_interfaces_g9_skl.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_skl/media_interfaces_g9_skl.cpp
+@@ -139,7 +139,7 @@ MOS_STATUS MhwInterfacesG9Skl::Initialize(
+ 
+     return MOS_STATUS_SUCCESS;
+ }
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool sklRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Skl>((uint32_t)IGFX_SKYLAKE);
+-- 
+2.40.0
+
diff --git a/srcpkgs/intel-media-driver/template b/srcpkgs/intel-media-driver/template
index a5bab06ac9476..1735b90c65ce5 100644
--- a/srcpkgs/intel-media-driver/template
+++ b/srcpkgs/intel-media-driver/template
@@ -1,6 +1,6 @@
 # Template file for 'intel-media-driver'
 pkgname=intel-media-driver
-version=22.5.3
+version=22.6.4
 revision=1
 archs="x86_64*"
 build_style=cmake
@@ -8,11 +8,11 @@ configure_args="-Wno-dev -DENABLE_NONFREE_KERNELS=$(vopt_if nonfree ON OFF)"
 hostmakedepends="pkg-config"
 makedepends="libva-devel libX11-devel intel-gmmlib-devel libpciaccess-devel"
 short_desc="Intel Media Driver for VAAPI (Broadwell+)"
-maintainer="Orphaned <orphan@voidlinux.org>"
+maintainer="Stefano Ragni <st3r4g@protonmail.com>"
 license="MIT, BSD-3-Clause"
 homepage="https://github.com/intel/media-driver"
 distfiles="https://github.com/intel/media-driver/archive/intel-media-${version}.tar.gz"
-checksum=65652b365d48be3c9f0b3c561502952b92ee5fcc587520b88d0d752cf2a6a3b5
+checksum=0c04b9d74b92de41fd409b62913ce4afd799236c0b6bc1983a496990764e5d90
 
 build_options="nonfree"
 desc_option_nonfree="Enable nonfree kernels"
diff --git a/srcpkgs/intel-media-sdk/patches/musl.patch b/srcpkgs/intel-media-sdk/patches/musl.patch
new file mode 100644
index 0000000000000..4ae70924b744f
--- /dev/null
+++ b/srcpkgs/intel-media-sdk/patches/musl.patch
@@ -0,0 +1,14 @@
+--- a/tools/tracer/tracer/tracer_linux.cpp	2022-11-18 03:02:59.000000000 -0500
++++ b/tools/tracer/tracer/tracer_linux.cpp	2022-12-18 01:44:51.341542572 -0500
+@@ -32,6 +32,11 @@
+ #include <dlfcn.h>
+ #include "tracer.h"
+
++#ifndef RTLD_DEEPBIND
++// musl neither defines nor can use RTLD_DEEPBIND
++#define RTLD_DEEPBIND 0
++#endif
++
+ #if defined(__i386__)
+     #define LIBMFXHW "libmfxhw32.so.1"
+ #elif defined(__x86_64__)
diff --git a/srcpkgs/intel-media-sdk/template b/srcpkgs/intel-media-sdk/template
new file mode 100644
index 0000000000000..7aeab51802f8e
--- /dev/null
+++ b/srcpkgs/intel-media-sdk/template
@@ -0,0 +1,37 @@
+# Template file for 'intel-media-sdk'
+pkgname=intel-media-sdk
+version=22.6.4
+revision=1
+archs="x86_64*"
+build_style=cmake
+configure_args="-Wno-dev -DBUILD_SAMPLES=OFF -DBUILD_TESTS=ON"
+hostmakedepends="pkg-config"
+makedepends="libva-devel libdrm-devel intel-gmmlib-devel"
+short_desc="Intel Media SDK"
+maintainer="Stefano Ragni <st3r4g@protonmail.com>"
+license="MIT, BSD-3-Clause"
+homepage="https://github.com/Intel-Media-SDK/MediaSDK"
+distfiles="https://github.com/Intel-Media-SDK/MediaSDK/archive/refs/tags/intel-mediasdk-${version}.tar.gz"
+checksum=197acd056f81e9ff1c27068d50e8c84c2014d94c7ac17cad69d5c2d61e445fd3
+
+post_install() {
+	vlicense LICENSE
+}
+
+libmfx_package() {
+	depends="${makedepends} ${sourcepkg}-${version}_${revision}"
+	short_desc="Intel MediaSDK mfx lib"
+	pkg_install() {
+		vmove usr/lib/mfx
+		vmove "usr/lib/libmfx*.so*"
+	}
+}
+
+libmfx-devel_package() {
+	depends="${makedepends} ${sourcepkg}-${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+	}
+}
diff --git a/srcpkgs/intel-media-sdk/update b/srcpkgs/intel-media-sdk/update
new file mode 100644
index 0000000000000..434a2bc67f7a1
--- /dev/null
+++ b/srcpkgs/intel-media-sdk/update
@@ -0,0 +1 @@
+pkgname=intel-media
diff --git a/srcpkgs/libmfx b/srcpkgs/libmfx
new file mode 120000
index 0000000000000..8ffc7099c2272
--- /dev/null
+++ b/srcpkgs/libmfx
@@ -0,0 +1 @@
+intel-media-sdk
\ No newline at end of file
diff --git a/srcpkgs/libmfx-devel b/srcpkgs/libmfx-devel
new file mode 120000
index 0000000000000..8ffc7099c2272
--- /dev/null
+++ b/srcpkgs/libmfx-devel
@@ -0,0 +1 @@
+intel-media-sdk
\ No newline at end of file
diff --git a/srcpkgs/onevpl-devel b/srcpkgs/onevpl-devel
new file mode 120000
index 0000000000000..e2306500b4871
--- /dev/null
+++ b/srcpkgs/onevpl-devel
@@ -0,0 +1 @@
+onevpl
\ No newline at end of file
diff --git a/srcpkgs/onevpl-intel-gpu-devel b/srcpkgs/onevpl-intel-gpu-devel
new file mode 120000
index 0000000000000..47920ceecf919
--- /dev/null
+++ b/srcpkgs/onevpl-intel-gpu-devel
@@ -0,0 +1 @@
+onevpl-intel-gpu
\ No newline at end of file
diff --git a/srcpkgs/onevpl-intel-gpu/template b/srcpkgs/onevpl-intel-gpu/template
new file mode 100644
index 0000000000000..f14acb728a54d
--- /dev/null
+++ b/srcpkgs/onevpl-intel-gpu/template
@@ -0,0 +1,27 @@
+# Template file for 'onevpl-intel-gpu'
+pkgname=onevpl-intel-gpu
+version=22.6.4
+revision=1
+archs="x86_64*"
+build_style=cmake
+configure_args="-Wno-dev -DCMAKE_BUILD_TYPE=Release"
+hostmakedepends="cmake pkg-config"
+makedepends="libdrm-devel libva-devel onevpl-devel"
+short_desc="Runtime implementation of oneVPL API for Intel Gen GPUs"
+maintainer="zlice <zlice555@gmail.com>"
+license="MIT"
+homepage="https://github.com/oneapi-src/oneVPL-intel-gpu"
+changelog="https://github.com/oneapi-src/oneVPL-intel-gpu/blob/main/CHANGELOG.md"
+distfiles="https://github.com/oneapi-src/oneVPL-intel-gpu/archive/refs/tags/intel-onevpl-${version}.tar.gz"
+checksum=74b0979dcb2af1b7c68edb8cbcb02d539de511090b12fac50652cbacd707c4e6
+
+post_install() {
+	vlicense LICENSE
+}
+
+onevpl-intel-gpu-devel_package() {
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/lib/pkgconfig
+	}
+}
diff --git a/srcpkgs/onevpl/template b/srcpkgs/onevpl/template
new file mode 100644
index 0000000000000..85c7c2da85ce9
--- /dev/null
+++ b/srcpkgs/onevpl/template
@@ -0,0 +1,34 @@
+# Template file for 'onevpl'
+pkgname=onevpl
+version=2023.1.2
+revision=1
+archs="x86_64*"
+build_style=cmake
+configure_args="
+	-DCMAKE_BUILD_TYPE=Release -Wno-dev
+	-DBUILD_PYTHON_BINDING:BOOL='OFF'
+	-DBUILD_EXAMPLES:BOOL='OFF'
+	-DBUILD_TESTS:BOOL='ON'
+	-DINSTALL_EXAMPLE_CODE:BOOL='OFF'"
+hostmakedepends="cmake libX11 python wayland-protocols pkg-config"
+makedepends="libva-devel libX11-devel wayland-devel"
+short_desc="Intel oneAPI Video Processing library"
+maintainer="zlice <zlice555@gmail.com>"
+license="MIT"
+homepage="https://www.intel.com/content/www/us/en/developer/tools/oneapi/onevpl.html"
+distfiles="https://github.com/oneapi-src/oneVPL/archive/v${version}/${pkgname}-${version}.tar.gz"
+checksum=b2261cca174ce1815f3d47c647921ab17f68267c69c1e2444ff27aab7d199cbb
+
+post_install() {
+	vlicense LICENSE
+}
+
+onevpl-devel_package() {
+	depends="${makedepends} ${sourcepkg}-${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.so"
+	}
+}

From ef55538ec33a372fbf585795511cf3fd4d461ce5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:20:59 -0400
Subject: [PATCH 101/115] tracker-miners: revbump for ffmpeg-6.0

---
 srcpkgs/tracker-miners/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tracker-miners/template b/srcpkgs/tracker-miners/template
index 0b97f47489f81..f196d2bf9e4a4 100644
--- a/srcpkgs/tracker-miners/template
+++ b/srcpkgs/tracker-miners/template
@@ -1,7 +1,7 @@
 # Template file for 'tracker-miners'
 pkgname=tracker-miners
 version=3.6.1
-revision=1
+revision=2
 build_style=meson
 build_helper=qemu
 # missing libgrss for miner_rss

From 6d00709fe7f688060fe2ee45ef77d2e3cab36502 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:21:21 -0400
Subject: [PATCH 102/115] mpd: revbump for ffmpeg-6.0

---
 srcpkgs/mpd/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpd/template b/srcpkgs/mpd/template
index abbeb423a1002..1bca2e877a380 100644
--- a/srcpkgs/mpd/template
+++ b/srcpkgs/mpd/template
@@ -1,7 +1,7 @@
 # Template file for 'mpd'
 pkgname=mpd
 version=0.23.14
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dopus=enabled -Dmikmod=enabled -Dneighbor=true
  -Dsoundcloud=enabled -Dpipe=true -Dtwolame=enabled -Dbzip2=enabled

From 47b24c9575150fe4dea6398e27a3ae3e565371e3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 17 Jul 2023 15:37:44 -0400
Subject: [PATCH 103/115] mixxx: revbump for ffmpeg-6.0

---
 srcpkgs/mixxx/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mixxx/template b/srcpkgs/mixxx/template
index 23800676bfd09..6921996e4e77b 100644
--- a/srcpkgs/mixxx/template
+++ b/srcpkgs/mixxx/template
@@ -1,7 +1,7 @@
 # Template file for 'mixxx'
 pkgname=mixxx
 version=2.3.3
-revision=5
+revision=6
 build_style=cmake
 configure_args="-DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="extra-cmake-modules pkg-config protobuf qt5-host-tools qt5-qmake"

From f8d936b82dacfce66c36646b5e9bfbb6079af519 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:09:36 -0400
Subject: [PATCH 104/115] musikcube: revbump for ffmpeg-6.0

---
 srcpkgs/musikcube/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/musikcube/template b/srcpkgs/musikcube/template
index 1f78ada1451b6..d9e6186e6697b 100644
--- a/srcpkgs/musikcube/template
+++ b/srcpkgs/musikcube/template
@@ -1,7 +1,7 @@
 # Template file for 'musikcube'
 pkgname=musikcube
 version=3.0.0
-revision=2
+revision=3
 build_style=cmake
 make_cmd=make
 configure_args="-DNO_NCURSESW=1"

From 4e1f814be598a3e70906f18f0acc7fd9ddcb8e94 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:02 -0400
Subject: [PATCH 105/115] tg_owt: revbump for ffmpeg-6.0

---
 srcpkgs/tg_owt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tg_owt/template b/srcpkgs/tg_owt/template
index 50bc8310b8859..c93262d5c5de6 100644
--- a/srcpkgs/tg_owt/template
+++ b/srcpkgs/tg_owt/template
@@ -1,7 +1,7 @@
 # Template file for 'tg_owt'
 pkgname=tg_owt
 version=0.0.0.20230921
-revision=1
+revision=2
 _commit=3bb3d757681e6cc5135aec6529a753dc3dcdcfb9
 _libyuv_commit=04821d1e7d60845525e8db55c7bcd41ef5be9406
 _abseil_commit=8c0b94e793a66495e0b1f34a5eb26bd7dc672db0

From 2bea773cfa8a48715406c565cca9472ae7ef6553 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:44 -0400
Subject: [PATCH 106/115] telegram-desktop: revbump for ffmpeg-6.0

---
 srcpkgs/telegram-desktop/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/telegram-desktop/template b/srcpkgs/telegram-desktop/template
index 26a167befd980..5b093861e96e8 100644
--- a/srcpkgs/telegram-desktop/template
+++ b/srcpkgs/telegram-desktop/template
@@ -1,7 +1,7 @@
 # Template file for 'telegram-desktop'
 pkgname=telegram-desktop
 version=4.10.1
-revision=2
+revision=3
 build_style=cmake
 build_helper="qemu gir"
 configure_args="-DTDESKTOP_API_ID=209235

From 7ff29afec92056686a0c86b2ca34dfaf59bdbfc2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:11:13 -0400
Subject: [PATCH 107/115] mpv: revbump for ffmpeg-6.0

---
 srcpkgs/mpv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpv/template b/srcpkgs/mpv/template
index 933c22bae2ed2..301a77ad22971 100644
--- a/srcpkgs/mpv/template
+++ b/srcpkgs/mpv/template
@@ -1,7 +1,7 @@
 # Template file for 'mpv'
 pkgname=mpv
 version=0.36.0
-revision=2
+revision=3
 build_style=meson
 configure_args="-Dcdda=enabled -Ddvbin=enabled -Ddvdnav=enabled
  -Dlibmpv=true -Dcplugins=enabled

From cf0d22dfef9ca456e09eaa2ebd7ffa60abce6782 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:11:45 -0400
Subject: [PATCH 108/115] gst-plugins-bad1: revbump for ffmpeg-6.0

---
 srcpkgs/gst-plugins-bad1/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index 2bf2f4b0642fe..0fafcb6555395 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-plugins-bad1'
 pkgname=gst-plugins-bad1
 version=1.22.5
-revision=1
+revision=2
 build_helper="gir"
 build_style=meson
 configure_args="-Dpackage-origin=https://voidlinux.org -Ddoc=disabled

From 1a1384cd129ac5d1eb820e8d0922b08313d87a29 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:12:09 -0400
Subject: [PATCH 109/115] openmw: revbump for ffmpeg-6.0

---
 srcpkgs/openmw/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openmw/template b/srcpkgs/openmw/template
index 0abf5ff7cdbec..b57180f1a4446 100644
--- a/srcpkgs/openmw/template
+++ b/srcpkgs/openmw/template
@@ -1,7 +1,7 @@
 # Template file for 'openmw'
 pkgname=openmw
 version=0.48.0
-revision=2
+revision=3
 build_style=cmake
 _recast_commit=e75adf86f91eb3082220085e42dda62679f9a3ea
 _bullet_tag=3.17

From e38dfc3af8d4468d7f0942eb82af06a876916b70 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:14:53 -0400
Subject: [PATCH 110/115] lms: revbump for ffmpeg-6.0

---
 srcpkgs/lms/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/lms/template b/srcpkgs/lms/template
index 39d34f62965c8..eb91d2ca275f3 100644
--- a/srcpkgs/lms/template
+++ b/srcpkgs/lms/template
@@ -1,7 +1,7 @@
 # Template file for 'lms'
 pkgname=lms
 version=3.40.0
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="wt-devel ffmpeg-devel boost-devel libconfig++-devel taglib-devel pam-devel libgraphicsmagick-devel gtest-devel libarchive-devel"

From 41a5059efb952e99a410f660cc221cceca3ecf7f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:15:14 -0400
Subject: [PATCH 111/115] openimageio: revbump for ffmpeg-6.0

---
 srcpkgs/openimageio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimageio/template b/srcpkgs/openimageio/template
index d8a6ba56efd11..d7ad79563a2af 100644
--- a/srcpkgs/openimageio/template
+++ b/srcpkgs/openimageio/template
@@ -1,7 +1,7 @@
 # Template file for 'openimageio'
 pkgname=openimageio
 version=2.4.9.0
-revision=6
+revision=7
 build_style=cmake
 build_helper=qemu
 configure_args="-DUSE_QT=0 -DUSE_PYTHON=0 -DOIIO_BUILD_TESTS=0

From d18a58b63f0c03b3bbf6dd32b459566d2bd3524b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:18:18 -0400
Subject: [PATCH 112/115] freecad: revbump for ffmpeg-6.0

---
 srcpkgs/freecad/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/freecad/template b/srcpkgs/freecad/template
index c135701e38b9a..705499e9972a6 100644
--- a/srcpkgs/freecad/template
+++ b/srcpkgs/freecad/template
@@ -1,7 +1,7 @@
 # Template file for 'freecad'
 pkgname=freecad
 version=0.20.2
-revision=7
+revision=8
 build_wrksrc="FreeCAD-${version}"
 build_style=cmake
 pycompile_dirs="usr/lib/${pkgname}/Mod"

From 7abcb227e55f610be841b336729a4f1d8151158b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:40:39 -0400
Subject: [PATCH 113/115] obs: revbump for ffmpeg-6.0

---
 srcpkgs/obs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/obs/template b/srcpkgs/obs/template
index b43b10ef935e9..5d1d5e887409e 100644
--- a/srcpkgs/obs/template
+++ b/srcpkgs/obs/template
@@ -1,7 +1,7 @@
 # Template file for 'obs'
 pkgname=obs
 version=29.1.3
-revision=2
+revision=3
 archs="i686* x86_64* ppc64le* aarch64*"
 build_style=cmake
 configure_args="-DOBS_VERSION_OVERRIDE=${version} -DENABLE_JACK=ON

From b1a524c4a0a22bca87f1596b2589698e342f86cb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:46:47 -0400
Subject: [PATCH 114/115] mlt7: revbump for ffmpeg-6.0

---
 srcpkgs/mlt7/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mlt7/template b/srcpkgs/mlt7/template
index 77579fbf6b634..0a2a2702544fe 100644
--- a/srcpkgs/mlt7/template
+++ b/srcpkgs/mlt7/template
@@ -1,7 +1,7 @@
 # Template file for 'mlt7'
 pkgname=mlt7
 version=7.14.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DSWIG_PYTHON=ON"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which

From ad4988e81edce57b5364c8e8ced46c4ef4981f72 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:47:18 -0400
Subject: [PATCH 115/115] libopenshot: revbump for ffmpeg-6.0

---
 srcpkgs/libopenshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenshot/template b/srcpkgs/libopenshot/template
index 8e57c5f592169..7a8f4520e7892 100644
--- a/srcpkgs/libopenshot/template
+++ b/srcpkgs/libopenshot/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenshot'
 pkgname=libopenshot
 version=0.3.0
-revision=3
+revision=4
 build_style=cmake
 # Builds fail with Ruby-2.4.1
 configure_args="-DENABLE_RUBY=OFF -DUSE_SYSTEM_JSONCPP=ON"

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (34 preceding siblings ...)
  2023-10-17 12:58 ` [PR PATCH] [Updated] " zlice
@ 2023-10-17 12:59 ` zlice
  2023-11-08 15:12 ` [PR PATCH] [Updated] " zlice
                   ` (61 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2023-10-17 12:59 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 623 bytes --]

New comment by zlice on void-packages repository

https://github.com/void-linux/void-packages/pull/43761#issuecomment-1766369830

Comment:
> we can replace `spek-alternative` with [`spek-x`](https://github.com/MikeWang000000/spek-X), a more actively maintained fork that supports ffmpeg6. [the original `spek`](https://github.com/alexkay/spek) has also become maintained again, but it claims to only support up to ffmpeg 5.1.

added to here, separate PR was building off ffmpeg4 and looked like everything was bombing out.

not sure if i did the transitional dummy package to replace spek-alternative with spek-x right

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (35 preceding siblings ...)
  2023-10-17 12:59 ` zlice
@ 2023-11-08 15:12 ` zlice
  2023-11-10 20:08 ` zlice
                   ` (60 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2023-11-08 15:12 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 3663 bytes --]

There is an updated pull request by zlice against master on the void-packages repository

https://github.com/zlice/void-packages ffmpeg6-split
https://github.com/void-linux/void-packages/pull/43761

ffmpeg6 split
[ci skip]


#### Testing the changes

- I tested the changes in this PR: **YES**

main testing has been vaapi in Firefox Nightly and enc/dec in Shotcut on Intel A770

#### New package

- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**

#### Local build testing

- I built this PR locally for my native architecture, **x86_64**

#### Discussion

Continuation of https://github.com/void-linux/void-packages/pull/36315

`libavresample` is deprecated, but marked as a dependency when trying to build other packages and install `ffmpeg`(6). I think the right way to handle this is make a meta package and the add to removals?


##### Commit naming / misc

~~Commits are 'dirty' right now, running with [gstreamer 1.22.1 updates](https://github.com/void-linux/void-packages/pull/42861) and [Intel OpenCL](https://github.com/void-linux/void-packages/pull/43084). This will also make [intel packages pr](https://github.com/void-linux/void-packages/pull/41132) obsolete.~~ (see Requirements below)

Maintainer for previous ffmpeg(4) was orphaned, I can put my name in there if that matters, though I don't exactly see myself keeping up on ffmpeg.

This updates QT5 which looks like it is usually hosted by Johnny. Not sure if there's any reason to stay there or these sources are fine.

##### STILL FFMPEG4

These are a mix of emulators, games and/or older packages.

- attract (multiple patches in master)
- audacity (https://github.com/audacity/audacity/issues/2305 and https://sourceforge.net/p/portmedia/wiki/portsmf/ is 'beta')
- ccextractor (master patches? no release)
- vice
- kodi
- mlt (only dep left is flowblade)
- ~~synfig (mlt)~~ (work with mlt7, bump synfigstudio)
- tvheadend
- ssr
- ~~spek-alternative~~ (replace with spek-x)
- ppsspp
- olive
- moc
- mediastreamer
- libextractor
- idjc
- hedgewars
- ~~ffmpegthumbnailer~~ (patches for moviedecoder.xxx files)
- ~~ffmpegthumbs~~ (latest compiles)
- deadbeef
- omxplayer
- qtav (fork has ffmpeg 5 patch - https://github.com/cmguo/QtAV)
- `vlc` (vlc4 will support ffmpeg5, there's a patch to build 3.x with ffmpeg5 but it will lack vaapi)
- `osg` (OpenSceneGraph plus `xine-lib`)


##### HAVE NOT BUILT YET

- omxplayer (rpi only? ffmpeg4)
- kodi (big, but ffmpeg4)


##### UPDATED (for ffmpeg6)

- ~~blender: update to 3.5.1~~ ~~will be revbump with~~ https://github.com/void-linux/void-packages/pull/43992
- unpaper: update to 7.0.0.
- guvcview: update to 2.0.8.
- qt5: update to 5.15.8
- qt5-webengine: update to 5.18.13
- shiboken2: revbump for qt5.15.8 (patch)
- python3-pyside2: update to 5.15.8 (patch)
- New package: spex-x replaces spek-alternative for ffmpeg-6.0


##### Requirements

- ~~[gstreamer 1.22.2](https://github.com/void-linux/void-packages/pull/42861)~~ - a few packages use ffmpeg-devel and require a revbump

- [Intel Packages](https://github.com/void-linux/void-packages/pull/41132) - ffmpeg4 uses different libraries than 6 (libmfx / Intel-MediaSDK vs only oneVPL that Intel is moving to), both are included here

- ~~[shotcut 23.05.14](https://github.com/void-linux/void-packages/pull/44260)~~

- https://github.com/void-linux/void-packages/pull/44781 will remove from this PR

A patch file from https://github.com/void-linux/void-packages/pull/43761.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ffmpeg6-split-43761.patch --]
[-- Type: text/x-diff, Size: 787200 bytes --]

From 5bac69a37ed3eac6d6b076e797f281474bbe15b5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:16:56 -0400
Subject: [PATCH 001/115] ffmpeg: update to 6.0.

---
 common/shlibs                                 | 26 +++++---
 srcpkgs/ffmpeg/files/altivec.patch            | 60 -------------------
 .../patches/armv5tel-floating-point.patch     | 18 ------
 ...h-libavcodec-libsvtav1-ten_bit_format.diff | 40 -------------
 .../workaround-mesa-readeon-vaapi-bug.patch   | 28 ---------
 srcpkgs/ffmpeg/template                       | 38 ++++++------
 6 files changed, 37 insertions(+), 173 deletions(-)
 delete mode 100644 srcpkgs/ffmpeg/files/altivec.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 delete mode 100644 srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch

diff --git a/common/shlibs b/common/shlibs
index 7c72c68a32fe5..88e2fb0aa4955 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -385,15 +385,23 @@ libid3tag.so.0 libid3tag-0.15.1b_1
 libgif.so.7 giflib-5.1.0_1
 libImlib2.so.1 imlib2-1.4.2_1
 libmp3lame.so.0 lame-3.98.2_1
-libavdevice.so.58 libavdevice-4.0_1
-libavformat.so.58 libavformat-4.0_1
-libswscale.so.5 libswscale-4.0_1
-libswresample.so.3 libswresample-4.0_1
-libavresample.so.4 libavresample-4.0_1
-libpostproc.so.55 libpostproc-4.0_1
-libavcodec.so.58 libavcodec-4.0_1
-libavutil.so.56 libavutil-4.0_1
-libavfilter.so.7 libavfilter-4.0_1
+libavdevice.so.60 libavdevice-6.0_1
+libavformat.so.60 libavformat-6.0_1
+libswscale.so.7 libswscale-6.0_1
+libswresample.so.4 libswresample-6.0_1
+libpostproc.so.57 libpostproc-6.0_1
+libavcodec.so.60 libavcodec-6.0_1
+libavutil.so.58 libavutil-6.0_1
+libavfilter.so.9 libavfilter-6.0_1
+libavdevice.so.58 libavdevice4-4.0_1
+libavformat.so.58 libavformat4-4.0_1
+libswscale.so.5 libswscale4-4.0_1
+libswresample.so.3 libswresample4-4.0_1
+libavresample.so.4 libavresample4-4.0_1
+libpostproc.so.55 libpostproc4-4.0_1
+libavcodec.so.58 libavcodec4-4.0_1
+libavutil.so.56 libavutil4-4.0_1
+libavfilter.so.7 libavfilter4-4.0_1
 libSDL-1.2.so.0 SDL-1.2.14_1
 libSDL_image-1.2.so.0 SDL_image-1.2.10_1
 libx264.so.157 x264-20190507.2245_1
diff --git a/srcpkgs/ffmpeg/files/altivec.patch b/srcpkgs/ffmpeg/files/altivec.patch
deleted file mode 100644
index 9c57200463320..0000000000000
--- a/srcpkgs/ffmpeg/files/altivec.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-revert some altivec specific change on all ppc* except ppc64le*
-
-q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
-conditionally, for ppc* but not ppc64le* (the new code is valid for
-POWER8 VSX which LE targets as a baseline but not BE)"
-
-
-This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
----
- libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
- 1 file changed, 20 insertions(+), 4 deletions(-)
-
-diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
-index 536545293d..c1e2852adb 100644
---- a/libswscale/ppc/yuv2rgb_altivec.c
-+++ b/libswscale/ppc/yuv2rgb_altivec.c
-@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-     vector signed short R1, G1, B1;                                           \
-     vector unsigned char R, G, B;                                             \
-                                                                               \
-+    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
-+    vector unsigned char align_perm;                                          \
-+                                                                              \
-     vector signed short lCY       = c->CY;                                    \
-     vector signed short lOY       = c->OY;                                    \
-     vector signed short lCRV      = c->CRV;                                   \
-@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
-                                                                               \
-         for (j = 0; j < w / 16; j++) {                                        \
--            y0 = vec_xl(0, y1i);                                              \
-+            y1ivP = (const vector unsigned char *) y1i;                       \
-+            y2ivP = (const vector unsigned char *) y2i;                       \
-+            uivP  = (const vector unsigned char *) ui;                        \
-+            vivP  = (const vector unsigned char *) vi;                        \
-+                                                                              \
-+            align_perm = vec_lvsl(0, y1i);                                    \
-+            y0 = (vector unsigned char)                                       \
-+                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
-                                                                               \
--            y1 = vec_xl(0, y2i);                                              \
-+            align_perm = vec_lvsl(0, y2i);                                    \
-+            y1 = (vector unsigned char)                                       \
-+                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
-                                                                               \
--            u = (vector signed char) vec_xl(0, ui);                           \
-+            align_perm = vec_lvsl(0, ui);                                     \
-+            u = (vector signed char)                                          \
-+                    vec_perm(uivP[0], uivP[1], align_perm);                   \
-                                                                               \
--            v = (vector signed char) vec_xl(0, vi);                           \
-+            align_perm = vec_lvsl(0, vi);                                     \
-+            v = (vector signed char)                                          \
-+                    vec_perm(vivP[0], vivP[1], align_perm);                   \
-                                                                               \
-             u = (vector signed char)                                          \
-                     vec_sub(u,                                                \
--- 
-2.27.0
-
diff --git a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
deleted file mode 100644
index 9a55178c74f0f..0000000000000
--- a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
-+++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
-@@ -39,6 +39,15 @@
- #endif
- #include <fenv.h>
- 
-+#if (FE_ALL_EXCEPT == 0)
-+/* E.g. ARM soft float does not define these */
-+#define FE_INVALID    0
-+#define FE_DIVBYZERO  0
-+#define FE_OVERFLOW   0
-+#define FE_UNDERFLOW  0
-+#define FE_INEXACT    0
-+#endif
-+
- #if CONFIG_LIBFONTCONFIG
- #include <fontconfig/fontconfig.h>
- #endif
diff --git a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
deleted file mode 100644
index aa948f7a8a2df..0000000000000
--- a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
+++ /dev/null
@@ -1,40 +0,0 @@
-#==================================================================================================
-# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
-# From: Christopher Degawa <christopher.degawa@intel.com>
-# Date: Thu, 20 Oct 2022 22:55:27 -0500
-# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
-#
-# compressed_ten_bit_format has been deprecated upstream and has no effect
-# and can be removed. Plus, technically it was never used in the first place
-# since it would require the app (ffmpeg) to set it and do additional
-# processing of the input frames.
-#
-# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
-#
-# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
-#==================================================================================================
---- a/libavcodec/libsvtav1.c
-+++ b/libavcodec/libsvtav1.c
-@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
- 
- static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
- {
--    const int    pack_mode_10bit =
--        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
--    const size_t luma_size_8bit  =
--        config->source_width * config->source_height * (1 << pack_mode_10bit);
--    const size_t luma_size_10bit =
--        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
-+    const size_t luma_size = config->source_width * config->source_height *
-+        (config->encoder_bit_depth > 8 ? 2 : 1);
- 
-     EbSvtIOFormat *in_data;
- 
--    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
-+    svt_enc->raw_size = luma_size * 3 / 2;
- 
-     // allocate buffer for in and out
-     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
--- 
-GitLab
-
diff --git a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
deleted file mode 100644
index 00e3f68a415b8..0000000000000
--- a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
-From: Rainer Hochecker <fernetmenta@online.de>
-Date: Sat, 26 Jan 2019 19:48:35 +0100
-Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
-
-This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
-It was hit frequently when watching h264 channels received via DVB-X.
-Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
----
- libavcodec/vaapi_h264.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
-index 5854587a255..f12fdc457a4 100644
---- a/libavcodec/vaapi_h264.c
-+++ b/libavcodec/vaapi_h264.c
-@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
-     H264SliceContext *sl = &h->slice_ctx[0];
-     int ret;
- 
-+    if (pic->nb_slices == 0) {
-+        ret = AVERROR_INVALIDDATA;
-+        goto finish;
-+    }
-+
-     ret = ff_vaapi_decode_issue(avctx, pic);
-     if (ret < 0)
-         goto finish;
diff --git a/srcpkgs/ffmpeg/template b/srcpkgs/ffmpeg/template
index 3e3ab2fb8931c..c1f9b7efe40e3 100644
--- a/srcpkgs/ffmpeg/template
+++ b/srcpkgs/ffmpeg/template
@@ -1,15 +1,15 @@
 # Template file for 'ffmpeg'
 # audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
 pkgname=ffmpeg
-version=4.4.4
-revision=4
+version=6.0
+revision=1
 short_desc="Decoding, encoding and streaming software"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="https://www.ffmpeg.org"
 changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
 distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
-checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+checksum=57be87c22d9b49c112b6d24bc67d42508660e6b718b3db89c44e47e289137082
 
 hostmakedepends="pkg-config perl"
 makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
@@ -26,12 +26,13 @@ makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-deve
  $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
  $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
  $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
- $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers Vulkan-Tools Vulkan-ValidationLayers')
+ $(vopt_if onevpl 'onevpl onevpl-devel')
  $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
 depends="ffplay>=${version}_${revision}"
 
 build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
- dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec onevpl"
 build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
 desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
 desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
@@ -39,9 +40,13 @@ desc_option_sofa="Enable support for AES SOFA"
 desc_option_webp="Enable support for WebP"
 
 case "$XBPS_TARGET_MACHINE" in
-	i686*|x86_64*)
-		hostmakedepends+=" nasm"
+	i686*)
 		build_options_default+=" vaapi vdpau nvenc nvdec"
+		hostmakedepends+=" nasm"
+		;;
+	x86_64*)
+		hostmakedepends+=" nasm"
+		build_options_default+=" vaapi vdpau nvenc nvdec onevpl"
 		;;
 	ppc64*) build_options_default+=" vaapi vdpau";;
 	mips*) CFLAGS="-mnan=legacy";;
@@ -115,18 +120,19 @@ do_configure() {
 		$(vopt_enable x265 libx265) \
 		$(vopt_enable v4l2 libv4l2) \
 		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
-		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		--enable-libbs2b --enable-libvidstab \
 		$(vopt_enable dav1d libdav1d) \
 		$(vopt_enable zimg libzimg) \
 		$(vopt_enable webp libwebp) \
 		$(vopt_enable sofa libmysofa) \
 		$(vopt_enable vulkan) \
+		$(vopt_enable onevpl libvpl) \
 		$(vopt_enable drm libdrm) \
 		$(vopt_enable svtav1 libsvtav1) \
 		$(vopt_enable srt libsrt) \
 		$(vopt_enable rist librist) \
-		$(vopt_if nvenc '--enable-nvenc') \
-		$(vopt_if nvdec '--enable-nvdec')
+		$(vopt_enable nvenc nvenc) \
+		$(vopt_enable nvdec nvdec)
 }
 
 do_build() {
@@ -153,10 +159,8 @@ libavdevice_package() {
 }
 
 libavresample_package() {
-	short_desc="FFmpeg audio resampling library"
-	pkg_install() {
-		vmove "usr/lib/libavresample.so.*"
-	}
+	short_desc="Package deprecated, removal needed"
+	build_style=meta
 }
 
 libavformat_package() {
@@ -210,15 +214,13 @@ ffmpeg-devel_package() {
 		libavfilter>=${version}_${revision}
 		libpostproc>=${version}_${revision}
 		libswscale>=${version}_${revision}
-		libswresample>=${version}_${revision}
-		libavresample>=${version}_${revision}"
+		libswresample>=${version}_${revision}"
 	short_desc+=" - development files"
-
+	conflicts="ffmpeg4-devel"
 	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
 		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
 		nostrip_files="/usr/lib/libavfilter.a"
 	fi
-
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig

From 153ae988482e9731ebde9e51d3828ab88f4dcc02 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:17:26 -0400
Subject: [PATCH 002/115] baresip: revbump for ffmpeg-6.0

---
 srcpkgs/baresip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/baresip/template b/srcpkgs/baresip/template
index 512045e306dbe..12c8954ef7b9b 100644
--- a/srcpkgs/baresip/template
+++ b/srcpkgs/baresip/template
@@ -1,7 +1,7 @@
 # Template file for 'baresip'
 pkgname=baresip
 version=3.6.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config glib-devel"
 makedepends="libgsm-devel libpng-devel openssl-devel libsndfile-devel

From 6fba5633da0dd37946ce5c67ea564eeb7a61afd6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:14 -0400
Subject: [PATCH 003/115] openshot: revbump for ffmpeg6.0

---
 srcpkgs/openshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openshot/template b/srcpkgs/openshot/template
index 8f47851eef354..affb652a9d500 100644
--- a/srcpkgs/openshot/template
+++ b/srcpkgs/openshot/template
@@ -1,7 +1,7 @@
 # Template file for 'openshot'
 pkgname=openshot
 version=3.0.0
-revision=2
+revision=3
 build_style=python3-module
 hostmakedepends="python3 python3-setuptools"
 makedepends="ffmpeg-devel python3-PyQt5"

From e3e224292ca7512b007741ba0a48e9e50701c8bf Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:36 -0400
Subject: [PATCH 004/115] sumo: revbump for ffmpeg6.0

---
 srcpkgs/sumo/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/sumo/template b/srcpkgs/sumo/template
index a3fe134aa5acc..a730afa9fafa9 100644
--- a/srcpkgs/sumo/template
+++ b/srcpkgs/sumo/template
@@ -1,7 +1,7 @@
 # Template file for 'sumo'
 pkgname=sumo
 version=1.12.0
-revision=6
+revision=7
 build_style=cmake
 hostmakedepends="libgdal-tools pkg-config swig python3-setuptools"
 makedepends="python3-devel ffmpeg-devel fox-devel gl2ps-devel libgdal-devel

From ca9157b19560b9c81eac0835c783d84ccb32fb0f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:56:22 -0400
Subject: [PATCH 005/115] New package: ffmpeg4-4.4.4.

---
 srcpkgs/ffmpeg4-devel                         |   1 +
 srcpkgs/ffmpeg4/files/altivec.patch           |  60 +++++
 .../patches/armv5tel-floating-point.patch     |  18 ++
 ...h-libavcodec-libsvtav1-ten_bit_format.diff |  40 +++
 .../workaround-mesa-readeon-vaapi-bug.patch   |  28 ++
 srcpkgs/ffmpeg4/template                      | 240 ++++++++++++++++++
 srcpkgs/libavcodec4                           |   1 +
 srcpkgs/libavdevice4                          |   1 +
 srcpkgs/libavfilter4                          |   1 +
 srcpkgs/libavformat4                          |   1 +
 srcpkgs/libavresample4                        |   1 +
 srcpkgs/libavutil4                            |   1 +
 srcpkgs/libpostproc4                          |   1 +
 srcpkgs/libswresample4                        |   1 +
 srcpkgs/libswscale4                           |   1 +
 15 files changed, 396 insertions(+)
 create mode 120000 srcpkgs/ffmpeg4-devel
 create mode 100644 srcpkgs/ffmpeg4/files/altivec.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 create mode 100644 srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
 create mode 100644 srcpkgs/ffmpeg4/template
 create mode 120000 srcpkgs/libavcodec4
 create mode 120000 srcpkgs/libavdevice4
 create mode 120000 srcpkgs/libavfilter4
 create mode 120000 srcpkgs/libavformat4
 create mode 120000 srcpkgs/libavresample4
 create mode 120000 srcpkgs/libavutil4
 create mode 120000 srcpkgs/libpostproc4
 create mode 120000 srcpkgs/libswresample4
 create mode 120000 srcpkgs/libswscale4

diff --git a/srcpkgs/ffmpeg4-devel b/srcpkgs/ffmpeg4-devel
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/ffmpeg4-devel
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/ffmpeg4/files/altivec.patch b/srcpkgs/ffmpeg4/files/altivec.patch
new file mode 100644
index 0000000000000..9c57200463320
--- /dev/null
+++ b/srcpkgs/ffmpeg4/files/altivec.patch
@@ -0,0 +1,60 @@
+revert some altivec specific change on all ppc* except ppc64le*
+
+q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
+conditionally, for ppc* but not ppc64le* (the new code is valid for
+POWER8 VSX which LE targets as a baseline but not BE)"
+
+
+This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
+---
+ libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
+ 1 file changed, 20 insertions(+), 4 deletions(-)
+
+diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
+index 536545293d..c1e2852adb 100644
+--- a/libswscale/ppc/yuv2rgb_altivec.c
++++ b/libswscale/ppc/yuv2rgb_altivec.c
+@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+     vector signed short R1, G1, B1;                                           \
+     vector unsigned char R, G, B;                                             \
+                                                                               \
++    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
++    vector unsigned char align_perm;                                          \
++                                                                              \
+     vector signed short lCY       = c->CY;                                    \
+     vector signed short lOY       = c->OY;                                    \
+     vector signed short lCRV      = c->CRV;                                   \
+@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
+                                                                               \
+         for (j = 0; j < w / 16; j++) {                                        \
+-            y0 = vec_xl(0, y1i);                                              \
++            y1ivP = (const vector unsigned char *) y1i;                       \
++            y2ivP = (const vector unsigned char *) y2i;                       \
++            uivP  = (const vector unsigned char *) ui;                        \
++            vivP  = (const vector unsigned char *) vi;                        \
++                                                                              \
++            align_perm = vec_lvsl(0, y1i);                                    \
++            y0 = (vector unsigned char)                                       \
++                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
+                                                                               \
+-            y1 = vec_xl(0, y2i);                                              \
++            align_perm = vec_lvsl(0, y2i);                                    \
++            y1 = (vector unsigned char)                                       \
++                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
+                                                                               \
+-            u = (vector signed char) vec_xl(0, ui);                           \
++            align_perm = vec_lvsl(0, ui);                                     \
++            u = (vector signed char)                                          \
++                    vec_perm(uivP[0], uivP[1], align_perm);                   \
+                                                                               \
+-            v = (vector signed char) vec_xl(0, vi);                           \
++            align_perm = vec_lvsl(0, vi);                                     \
++            v = (vector signed char)                                          \
++                    vec_perm(vivP[0], vivP[1], align_perm);                   \
+                                                                               \
+             u = (vector signed char)                                          \
+                     vec_sub(u,                                                \
+-- 
+2.27.0
+
diff --git a/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
new file mode 100644
index 0000000000000..9a55178c74f0f
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
@@ -0,0 +1,18 @@
+--- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
++++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
+@@ -39,6 +39,15 @@
+ #endif
+ #include <fenv.h>
+ 
++#if (FE_ALL_EXCEPT == 0)
++/* E.g. ARM soft float does not define these */
++#define FE_INVALID    0
++#define FE_DIVBYZERO  0
++#define FE_OVERFLOW   0
++#define FE_UNDERFLOW  0
++#define FE_INEXACT    0
++#endif
++
+ #if CONFIG_LIBFONTCONFIG
+ #include <fontconfig/fontconfig.h>
+ #endif
diff --git a/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
new file mode 100644
index 0000000000000..aa948f7a8a2df
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
@@ -0,0 +1,40 @@
+#==================================================================================================
+# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
+# From: Christopher Degawa <christopher.degawa@intel.com>
+# Date: Thu, 20 Oct 2022 22:55:27 -0500
+# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
+#
+# compressed_ten_bit_format has been deprecated upstream and has no effect
+# and can be removed. Plus, technically it was never used in the first place
+# since it would require the app (ffmpeg) to set it and do additional
+# processing of the input frames.
+#
+# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
+#
+# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
+#==================================================================================================
+--- a/libavcodec/libsvtav1.c
++++ b/libavcodec/libsvtav1.c
+@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
+ 
+ static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
+ {
+-    const int    pack_mode_10bit =
+-        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
+-    const size_t luma_size_8bit  =
+-        config->source_width * config->source_height * (1 << pack_mode_10bit);
+-    const size_t luma_size_10bit =
+-        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
++    const size_t luma_size = config->source_width * config->source_height *
++        (config->encoder_bit_depth > 8 ? 2 : 1);
+ 
+     EbSvtIOFormat *in_data;
+ 
+-    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
++    svt_enc->raw_size = luma_size * 3 / 2;
+ 
+     // allocate buffer for in and out
+     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
+-- 
+GitLab
+
diff --git a/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
new file mode 100644
index 0000000000000..00e3f68a415b8
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
@@ -0,0 +1,28 @@
+From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
+From: Rainer Hochecker <fernetmenta@online.de>
+Date: Sat, 26 Jan 2019 19:48:35 +0100
+Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
+
+This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
+It was hit frequently when watching h264 channels received via DVB-X.
+Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
+---
+ libavcodec/vaapi_h264.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
+index 5854587a255..f12fdc457a4 100644
+--- a/libavcodec/vaapi_h264.c
++++ b/libavcodec/vaapi_h264.c
+@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
+     H264SliceContext *sl = &h->slice_ctx[0];
+     int ret;
+ 
++    if (pic->nb_slices == 0) {
++        ret = AVERROR_INVALIDDATA;
++        goto finish;
++    }
++
+     ret = ff_vaapi_decode_issue(avctx, pic);
+     if (ret < 0)
+         goto finish;
diff --git a/srcpkgs/ffmpeg4/template b/srcpkgs/ffmpeg4/template
new file mode 100644
index 0000000000000..f2c851693d367
--- /dev/null
+++ b/srcpkgs/ffmpeg4/template
@@ -0,0 +1,240 @@
+# Template file for 'ffmpeg4'
+# audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
+pkgname=ffmpeg4
+version=4.4.4
+revision=1
+short_desc="Decoding, encoding and streaming software - ffmpeg4 libraries only"
+maintainer="Orphaned <orphan@voidlinux.org>"
+license="GPL-3.0-or-later"
+homepage="https://www.ffmpeg.org"
+changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
+distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
+checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+
+hostmakedepends="pkg-config perl"
+makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
+ libXext-devel libXvMC-devel libxcb-devel lame-devel libtheora-devel
+ libvorbis-devel x264-devel xvidcore-devel jack-devel SDL2-devel
+ libcdio-paranoia-devel librtmp-devel libmodplug-devel gnutls-devel
+ speex-devel celt-devel harfbuzz-devel libass-devel opus-devel ocl-icd-devel
+ libbs2b-devel libvidstab-devel vmaf-devel $(vopt_if pulseaudio pulseaudio-devel)
+ $(vopt_if vaapi libva-devel) $(vopt_if vdpau libvdpau-devel)
+ $(vopt_if x265 x265-devel) $(vopt_if v4l2 v4l-utils-devel)
+ $(vopt_if fdk_aac fdk-aac-devel) $(vopt_if vpx libvpx-devel)
+ $(vopt_if aom libaom-devel) $(vopt_if sndio sndio-devel)
+ $(vopt_if dav1d libdav1d-devel) $(vopt_if zimg zimg-devel)
+ $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
+ $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
+ $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if mfx 'libmfx libmfx-devel')
+ $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
+
+build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec mfx"
+build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
+
+desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
+desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
+desc_option_sofa="Enable support for AES SOFA"
+desc_option_webp="Enable support for WebP"
+
+case "$XBPS_TARGET_MACHINE" in
+	i686*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau nvenc nvdec"
+			;;
+	x86_64*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau mfx nvenc nvdec"
+			;;
+	ppc64*) build_options_default+=" vaapi vdpau";;
+	mips*) CFLAGS="-mnan=legacy";;
+esac
+
+if [ "$XBPS_TARGET_WORDSIZE" != "32" ]; then
+	build_options_default+=" svtav1"
+fi
+
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+fi
+
+_apply_patch() {
+	local args="$1" pname="$(basename $2)"
+
+	if [ ! -f ".${pname}_done" ]; then
+		patch -N $args -i $2
+		touch .${pname}_done
+	fi
+}
+
+post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64le*) ;;
+		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
+	esac
+
+	vsed -i libavfilter/vf_libvmaf.c -e 's!/usr/local/share/model/\(vmaf_v0.6.1\).pkl!/usr/share/vmaf/\1.json!'
+}
+
+do_configure() {
+	# Fix gcc on x86_64-musl only
+	if [ "$XBPS_TARGET_MACHINE" = "x86_64-musl" ]; then
+		vsed -i configure -e "s;_cflags_speed='-O3';_cflags_speed='-O2';"
+	fi
+
+	if [ "$CROSS_BUILD" ]; then
+		case "$XBPS_TARGET_MACHINE" in
+			arm*) _arch="arm";;
+			aarch64*) _arch="aarch64";;
+			mips*) _arch="mips";;
+			ppc64*) _arch="ppc64";;
+			ppc*) _arch="ppc";;
+			*) _arch="${XBPS_TARGET_MACHINE%%-musl}";;
+		esac
+
+		_args+=" --enable-cross-compile
+			--sysroot=$XBPS_CROSS_BASE
+			--cross-prefix=${XBPS_CROSS_TRIPLET}-
+			--target-os=linux --arch=${_arch}"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc|ppc-musl) _args+=" --disable-altivec";;
+	esac
+
+	if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+		_args+=" --extra-libs=-latomic"
+	fi
+
+	./configure --prefix=/usr --disable-debug --enable-gpl --enable-gnutls \
+		--disable-stripping \
+		--enable-libcdio --enable-version3 --enable-runtime-cpudetect \
+		--enable-libmp3lame --enable-libvorbis --enable-libxvid \
+		--enable-libx264 $(vopt_enable vpx libvpx) --enable-libtheora \
+		--enable-shared --enable-static --enable-libxcb \
+		$(vopt_enable pulseaudio libpulse) --enable-libfreetype --enable-libmodplug \
+		--enable-libspeex --enable-libcelt --enable-libass \
+		--enable-libopus --enable-librtmp --enable-libjack \
+		$(vopt_if fdk_aac '--enable-nonfree --enable-libfdk-aac') \
+		--disable-libopencore_amrnb --disable-libopencore_amrwb \
+		--disable-libopenjpeg \
+		--enable-postproc --enable-opencl ${_args} --enable-libvmaf ${_args} \
+		$(vopt_enable x265 libx265) \
+		$(vopt_enable v4l2 libv4l2) \
+		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
+		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		$(vopt_enable dav1d libdav1d) \
+		$(vopt_enable zimg libzimg) \
+		$(vopt_enable webp libwebp) \
+		$(vopt_enable sofa libmysofa) \
+		$(vopt_enable vulkan) \
+		$(vopt_enable drm libdrm) \
+		$(vopt_enable svtav1 libsvtav1) \
+		$(vopt_enable srt libsrt) \
+		$(vopt_enable rist librist) \
+		$(vopt_enable mfx libmfx) \
+		$(vopt_if nvenc '--enable-nvenc') \
+		$(vopt_if nvdec '--enable-nvdec')
+}
+
+do_build() {
+	make ${makejobs}
+	make doc/ff{mpeg,play}.1
+}
+
+do_install() {
+	make DESTDIR=${DESTDIR} install install-man
+	rm -rf ${DESTDIR}/usr/bin
+}
+
+libavcodec4_package() {
+	short_desc="FFmpeg codec library"
+	pkg_install() {
+		vmove "usr/lib/libavcodec.so.*"
+	}
+}
+
+libavdevice4_package() {
+	short_desc="FFmpeg device handling library"
+	pkg_install() {
+		vmove "usr/lib/libavdevice.so.*"
+	}
+}
+
+libavresample4_package() {
+	short_desc="FFmpeg audio resampling library"
+	pkg_install() {
+		vmove "usr/lib/libavresample.so.*"
+	}
+}
+
+libavformat4_package() {
+	short_desc="FFmpeg file format library"
+	pkg_install() {
+		vmove "usr/lib/libavformat.so.*"
+	}
+}
+
+libavutil4_package() {
+	short_desc="FFmpeg utility library"
+	pkg_install() {
+		vmove "usr/lib/libavutil.so.*"
+	}
+}
+
+libavfilter4_package() {
+	short_desc="FFmpeg audio/video filter library"
+	pkg_install() {
+		vmove "usr/lib/libavfilter.so.*"
+	}
+}
+
+libpostproc4_package() {
+	short_desc="FFmpeg video postprocessing library"
+	pkg_install() {
+		vmove "usr/lib/libpostproc.so.*"
+	}
+}
+
+libswscale4_package() {
+	short_desc="FFmpeg video scaling library"
+	pkg_install() {
+		vmove "usr/lib/libswscale.so.*"
+	}
+}
+
+libswresample4_package() {
+	short_desc="FFmpeg video resampling library"
+	pkg_install() {
+		vmove "usr/lib/libswresample.so.*"
+	}
+}
+
+ffmpeg4-devel_package() {
+	depends="
+		libavcodec4>=${version}_${revision}
+		libavdevice4>=${version}_${revision}
+		libavformat4>=${version}_${revision}
+		libavutil4>=${version}_${revision}
+		libavfilter4>=${version}_${revision}
+		libpostproc4>=${version}_${revision}
+		libswscale4>=${version}_${revision}
+		libswresample4>=${version}_${revision}
+		libavresample4>=${version}_${revision}"
+	short_desc+=" - development files"
+	conflicts="ffmpeg-devel"
+	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
+		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
+		nostrip_files="/usr/lib/libavfilter.a"
+	fi
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.a"
+		vmove "usr/lib/*.so"
+		vmove usr/share/ffmpeg/examples
+		vmove usr/share/man/man3
+	}
+}
diff --git a/srcpkgs/libavcodec4 b/srcpkgs/libavcodec4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavcodec4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavdevice4 b/srcpkgs/libavdevice4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavdevice4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavfilter4 b/srcpkgs/libavfilter4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavfilter4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavformat4 b/srcpkgs/libavformat4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavformat4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavresample4 b/srcpkgs/libavresample4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavutil4 b/srcpkgs/libavutil4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavutil4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libpostproc4 b/srcpkgs/libpostproc4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libpostproc4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswresample4 b/srcpkgs/libswresample4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libswresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswscale4 b/srcpkgs/libswscale4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libswscale4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file

From 4b325b4518d1174dcb59eb309a3d86808c101ec4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:04 -0400
Subject: [PATCH 006/115] opencv: update to 4.7.0.

---
 common/shlibs           | 104 ++++++++++++++++++++--------------------
 srcpkgs/opencv/template |   8 ++--
 2 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index 88e2fb0aa4955..fecac6eed2083 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2085,58 +2085,58 @@ libcapstone.so.5 capstone-5.0.1_1
 libhavege.so.2 libhaveged-1.9.11_1
 libnih.so.1 libnih-1.0.3_1
 libnih-dbus.so.1 libnih-1.0.3_1
-libopencv_quality.so.406 libopencv-4.6.0_1
-libopencv_reg.so.406 libopencv-4.6.0_1
-libopencv_surface_matching.so.406 libopencv-4.6.0_1
-libopencv_xphoto.so.406 libopencv-4.6.0_1
-libopencv_freetype.so.406 libopencv-4.6.0_1
-libopencv_fuzzy.so.406 libopencv-4.6.0_1
-libopencv_hfs.so.406 libopencv-4.6.0_1
-libopencv_img_hash.so.406 libopencv-4.6.0_1
-libopencv_line_descriptor.so.406 libopencv-4.6.0_1
-libopencv_saliency.so.406 libopencv-4.6.0_1
-libopencv_structured_light.so.406 libopencv-4.6.0_1
-libopencv_aruco.so.406 libopencv-4.6.0_1
-libopencv_bgsegm.so.406 libopencv-4.6.0_1
-libopencv_bioinspired.so.406 libopencv-4.6.0_1
-libopencv_ccalib.so.406 libopencv-4.6.0_1
-libopencv_face.so.406 libopencv-4.6.0_1
-libopencv_tracking.so.406 libopencv-4.6.0_1
-libopencv_xfeatures2d.so.406 libopencv-4.6.0_1
-libopencv_optflow.so.406 libopencv-4.6.0_1
-libopencv_ximgproc.so.406 libopencv-4.6.0_1
-libopencv_plot.so.406 libopencv-4.6.0_1
-libopencv_text.so.406 libopencv-4.6.0_1
-libopencv_ml.so.406 libopencv-4.6.0_1
-libopencv_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn.so.406 libopencv-4.6.0_1
-libopencv_shape.so.406 libopencv-4.6.0_1
-libopencv_stitching.so.406 libopencv-4.6.0_1
-libopencv_photo.so.406 libopencv-4.6.0_1
-libopencv_video.so.406 libopencv-4.6.0_1
-libopencv_calib3d.so.406 libopencv-4.6.0_1
-libopencv_features2d.so.406 libopencv-4.6.0_1
-libopencv_flann.so.406 libopencv-4.6.0_1
-libopencv_highgui.so.406 libopencv-4.6.0_1
-libopencv_videoio.so.406 libopencv-4.6.0_1
-libopencv_imgcodecs.so.406 libopencv-4.6.0_1
-libopencv_imgproc.so.406 libopencv-4.6.0_1
-libopencv_core.so.406 libopencv-4.6.0_1
-libopencv_superres.so.406 libopencv-4.6.0_1
-libopencv_videostab.so.406 libopencv-4.6.0_1
-libopencv_gapi.so.406 libopencv-4.6.0_1
-libopencv_xobjdetect.so.406 libopencv-4.6.0_1
-libopencv_datasets.so.406 libopencv-4.6.0_1
-libopencv_dnn_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn_superres.so.406 libopencv-4.6.0_1
-libopencv_dpm.so.406 libopencv-4.6.0_1
-libopencv_phase_unwrapping.so.406 libopencv-4.6.0_1
-libopencv_stereo.so.406 libopencv-4.6.0_1
-libopencv_rapid.so.406 libopencv-4.6.0_1
-libopencv_intensity_transform.so.406 libopencv-4.6.0_1
-libopencv_alphamat.so.406 libopencv-4.6.0_1
-libopencv_barcode.so.406 libopencv-4.6.0_1
-libopencv_mcc.so.406 libopencv-4.6.0_1
+libopencv_quality.so.407 libopencv-4.7.0_1
+libopencv_reg.so.407 libopencv-4.7.0_1
+libopencv_surface_matching.so.407 libopencv-4.7.0_1
+libopencv_xphoto.so.407 libopencv-4.7.0_1
+libopencv_freetype.so.407 libopencv-4.7.0_1
+libopencv_fuzzy.so.407 libopencv-4.7.0_1
+libopencv_hfs.so.407 libopencv-4.7.0_1
+libopencv_img_hash.so.407 libopencv-4.7.0_1
+libopencv_line_descriptor.so.407 libopencv-4.7.0_1
+libopencv_saliency.so.407 libopencv-4.7.0_1
+libopencv_structured_light.so.407 libopencv-4.7.0_1
+libopencv_aruco.so.407 libopencv-4.7.0_1
+libopencv_bgsegm.so.407 libopencv-4.7.0_1
+libopencv_bioinspired.so.407 libopencv-4.7.0_1
+libopencv_ccalib.so.407 libopencv-4.7.0_1
+libopencv_face.so.407 libopencv-4.7.0_1
+libopencv_tracking.so.407 libopencv-4.7.0_1
+libopencv_xfeatures2d.so.407 libopencv-4.7.0_1
+libopencv_optflow.so.407 libopencv-4.7.0_1
+libopencv_ximgproc.so.407 libopencv-4.7.0_1
+libopencv_plot.so.407 libopencv-4.7.0_1
+libopencv_text.so.407 libopencv-4.7.0_1
+libopencv_ml.so.407 libopencv-4.7.0_1
+libopencv_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn.so.407 libopencv-4.7.0_1
+libopencv_shape.so.407 libopencv-4.7.0_1
+libopencv_stitching.so.407 libopencv-4.7.0_1
+libopencv_photo.so.407 libopencv-4.7.0_1
+libopencv_video.so.407 libopencv-4.7.0_1
+libopencv_calib3d.so.407 libopencv-4.7.0_1
+libopencv_features2d.so.407 libopencv-4.7.0_1
+libopencv_flann.so.407 libopencv-4.7.0_1
+libopencv_highgui.so.407 libopencv-4.7.0_1
+libopencv_videoio.so.407 libopencv-4.7.0_1
+libopencv_imgcodecs.so.407 libopencv-4.7.0_1
+libopencv_imgproc.so.407 libopencv-4.7.0_1
+libopencv_core.so.407 libopencv-4.7.0_1
+libopencv_superres.so.407 libopencv-4.7.0_1
+libopencv_videostab.so.407 libopencv-4.7.0_1
+libopencv_gapi.so.407 libopencv-4.7.0_1
+libopencv_xobjdetect.so.407 libopencv-4.7.0_1
+libopencv_datasets.so.407 libopencv-4.7.0_1
+libopencv_dnn_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn_superres.so.407 libopencv-4.7.0_1
+libopencv_dpm.so.407 libopencv-4.7.0_1
+libopencv_phase_unwrapping.so.407 libopencv-4.7.0_1
+libopencv_stereo.so.407 libopencv-4.7.0_1
+libopencv_rapid.so.407 libopencv-4.7.0_1
+libopencv_intensity_transform.so.407 libopencv-4.7.0_1
+libopencv_alphamat.so.407 libopencv-4.7.0_1
+libopencv_barcode.so.407 libopencv-4.7.0_1
+libopencv_mcc.so.407 libopencv-4.7.0_1
 libuniconf.so.4.6 wvstreams-4.6.1_20
 libwvbase.so.4.6 wvstreams-4.6.1_20
 libwvutils.so.4.6 wvstreams-4.6.1_20
diff --git a/srcpkgs/opencv/template b/srcpkgs/opencv/template
index aea4bfc3a265c..ce94de9424d18 100644
--- a/srcpkgs/opencv/template
+++ b/srcpkgs/opencv/template
@@ -1,7 +1,7 @@
 # Template file for 'opencv'
 pkgname=opencv
-version=4.6.0
-revision=6
+version=4.7.0
+revision=1
 create_wrksrc=yes
 build_wrksrc=${pkgname}-${version}
 build_style=cmake
@@ -24,8 +24,8 @@ homepage="https://opencv.org"
 changelog="https://github.com/opencv/opencv/wiki/ChangeLog"
 distfiles="https://github.com/opencv/opencv/archive/${version}.tar.gz
  https://github.com/opencv/opencv_contrib/archive/${version}.tar.gz>contrib.tar.gz"
-checksum="1ec1cba65f9f20fe5a41fda1586e01c70ea0c9a6d7b67c9e13edf0cfe2239277
- 1777d5fd2b59029cf537e5fd6f8aa68d707075822f90bde683fcde086f85f7a7"
+checksum="8df0079cdbe179748a18d44731af62a245a45ebf5085223dc03133954c662973
+ 42df840cf9055e59d0e22c249cfb19f04743e1bdad113d31b1573d3934d62584"
 patch_args="-Np1 -d ${build_wrksrc}"
 # tests hang indenfinitely, even with test data included
 make_check=no

From 2cfc6d163f38500382efb90164aff47009405c95 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 007/115] actiona: revbump for opencv-4.7.0

---
 srcpkgs/actiona/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/actiona/template b/srcpkgs/actiona/template
index cf5f0b7a2ae61..0d899311e6df7 100644
--- a/srcpkgs/actiona/template
+++ b/srcpkgs/actiona/template
@@ -1,7 +1,7 @@
 # Template file for 'actiona'
 pkgname=actiona
 version=3.10.1
-revision=2
+revision=3
 build_style=qmake
 configure_args="PKGCONFIG_OPENCV=opencv4"
 hostmakedepends="pkg-config qt5-plugin-mysql qt5-qmake qt5-host-tools"

From 580b4b23e03acc154af160b04bc88ec5c3a9ecf6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 008/115] qimgv: revbump for opencv-4.7.0

---
 srcpkgs/qimgv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qimgv/template b/srcpkgs/qimgv/template
index 7eb30db33992c..dd341dfe1bfce 100644
--- a/srcpkgs/qimgv/template
+++ b/srcpkgs/qimgv/template
@@ -1,7 +1,7 @@
 # Template file for 'qimgv'
 pkgname=qimgv
 version=1.0.2
-revision=2
+revision=3
 build_style=cmake
 configure_args="$(vopt_if video -DVIDEO_SUPPORT=ON -DVIDEO_SUPPORT=OFF)
  $(vopt_if scale -DOPENCV_SUPPORT=ON -DOPENCV_SUPPORT=OFF)

From 9e218ef16ae852d1fb84f1a3b4c9169d4c8e9a71 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 009/115] retroshare: revbump for opencv-4.7.0

---
 srcpkgs/retroshare/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroshare/template b/srcpkgs/retroshare/template
index bb17569277a7f..49e2c1cbe8a53 100644
--- a/srcpkgs/retroshare/template
+++ b/srcpkgs/retroshare/template
@@ -1,7 +1,7 @@
 # Template file for 'retroshare'
 pkgname=retroshare
 version=0.6.6
-revision=3
+revision=4
 build_style=qmake
 #XXX broadcast feature requires an ancient udp-discovery-cpp which either needs
 # to be fetched+patched (FTBFS) here or packaged :/

From fb646d733f62db8e5106e2e69225f6baed82f2a6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 010/115] waifu2x-converter-cpp: revbump for opencv-4.7.0

---
 srcpkgs/waifu2x-converter-cpp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waifu2x-converter-cpp/template b/srcpkgs/waifu2x-converter-cpp/template
index 361b8a23b9497..c5ac17eb54ea4 100644
--- a/srcpkgs/waifu2x-converter-cpp/template
+++ b/srcpkgs/waifu2x-converter-cpp/template
@@ -1,7 +1,7 @@
 # Template file for 'waifu2x-converter-cpp'
 pkgname=waifu2x-converter-cpp
 version=5.2.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DINSTALL_MODELS=ON"
 hostmakedepends="pkg-config"

From 5f9cc0a012e5ab86dd80976977e858abe6d43ffa Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:38 -0400
Subject: [PATCH 011/115] vlc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/vlc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vlc/template b/srcpkgs/vlc/template
index be579ce38fe37..3974289947401 100644
--- a/srcpkgs/vlc/template
+++ b/srcpkgs/vlc/template
@@ -25,7 +25,7 @@ lib32disabled=yes
 hostmakedepends="automake libtool pkg-config flex gettext libgcrypt-devel
  live555-devel gettext-devel $(vopt_if lua lua52) $(vopt_if chromecast protobuf)"
 makedepends="
- avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg-devel freefont-ttf
+ avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg4-devel freefont-ttf
  gnutls-devel jack-devel liba52-devel libass-devel libbluray-devel
  libcdio-devel libdca-devel libdvbpsi-devel libdvdnav-devel libmad-devel
  libmatroska-devel libmodplug-devel libmpcdec-devel libmpeg2-devel

From 7ab47e3e018d4503ab09178b44d6bbe43e86ea65 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:55 -0400
Subject: [PATCH 012/115] osg: revbump for ffmpeg4-4.4.3

---
 srcpkgs/osg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/osg/template b/srcpkgs/osg/template
index a9ebbd287933b..755793f7e11bf 100644
--- a/srcpkgs/osg/template
+++ b/srcpkgs/osg/template
@@ -8,7 +8,7 @@ build_helper="qemu"
 configure_args="-DLIB_POSTFIX="
 hostmakedepends="pkg-config xrandr"
 makedepends="MesaLib-devel gtkglext-devel libcurl-devel giflib-devel librsvg-devel
- jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg-devel xine-lib-devel
+ jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg4-devel xine-lib-devel
  SDL2-devel gst-plugins-base1-devel
  $(vopt_if openexr libopenexr-devel)
  $(vopt_if poppler poppler-glib-devel)

From 42caffa4205424363aba237e5ab6d094a1bfc659 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:13 -0400
Subject: [PATCH 013/115] xine-lib: revbump for ffmpeg4-4.4.3

---
 srcpkgs/xine-lib/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/xine-lib/template b/srcpkgs/xine-lib/template
index f713eff49b07c..ed6194c17d11e 100644
--- a/srcpkgs/xine-lib/template
+++ b/srcpkgs/xine-lib/template
@@ -1,6 +1,6 @@
 # Template file for 'xine-lib'
 pkgname=xine-lib
-version=1.2.12
+version=1.2.13
 revision=1
 build_style=gnu-configure
 configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
@@ -8,7 +8,7 @@ configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
 hostmakedepends="automake gettext-devel libtool pkg-config perl"
 makedepends="
  zlib-devel alsa-lib-devel libxcb-devel libSM-devel libXext-devel libXv-devel
- libXvMC-devel liba52-devel libmad-devel ffmpeg-devel pulseaudio-devel
+ libXvMC-devel liba52-devel libmad-devel ffmpeg4-devel pulseaudio-devel
  jack-devel samba-devel libflac-devel libmodplug-devel libmpcdec-devel
  speex-devel libtheora-devel libvorbis-devel libdca-devel faad2-devel
  libcdio-devel libbluray-devel aalib-devel libcaca-devel libXinerama-devel
@@ -19,7 +19,7 @@ license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="http://www.xine-project.org"
 changelog="https://sourceforge.net/projects/xine/files/xine-lib/${version}/README.txt/view"
 distfiles="${SOURCEFORGE_SITE}/xine/${pkgname}-${version}.tar.xz"
-checksum=d606270468e1540c2a89c0d7f5fdf11e17ecc0c2698cc0bcb1065ff26abee098
+checksum=5f10d6d718a4a51c17ed1b32b031d4f9b80b061e8276535b2be31e5ac4b75e6f
 
 case "$XBPS_TARGET_MACHINE" in
 	i686-musl)

From 59ec7865078d7e17a21f3bd57cb4674b4e9dabcf Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 014/115] QMPlay2: revbump for ffmpeg-6.0

---
 srcpkgs/QMPlay2/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/QMPlay2/template b/srcpkgs/QMPlay2/template
index dde29cba6d8c3..46c80f64a1349 100644
--- a/srcpkgs/QMPlay2/template
+++ b/srcpkgs/QMPlay2/template
@@ -1,7 +1,7 @@
 # Template file for 'QMPlay2'
 pkgname=QMPlay2
 version=23.10.22
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools"
 makedepends="alsa-lib-devel ffmpeg-devel libass-devel libcdio-devel libgme-devel

From fa78f9701148cb81d25c764ddc4df151d0847ef6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 015/115] alsa-plugins: revbump for ffmpeg-6.0

---
 srcpkgs/alsa-plugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/alsa-plugins/template b/srcpkgs/alsa-plugins/template
index 0bfa6d9fd2643..a5708a7d82a8f 100644
--- a/srcpkgs/alsa-plugins/template
+++ b/srcpkgs/alsa-plugins/template
@@ -1,7 +1,7 @@
 # Template file for 'alsa-plugins'
 pkgname=alsa-plugins
 version=1.2.7.1
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--disable-maemo-plugin"
 hostmakedepends="pkg-config"

From 52e6d64221dca80473b79c412d3c8142edd2a74d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 016/115] arcan: revbump for ffmpeg-6.0

---
 srcpkgs/arcan/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/arcan/template b/srcpkgs/arcan/template
index efd0afe10576d..b91e6900d42a1 100644
--- a/srcpkgs/arcan/template
+++ b/srcpkgs/arcan/template
@@ -2,7 +2,7 @@
 # !! keep synced with: acfgfs aclip aloadimage
 pkgname=arcan
 version=0.6.2.1
-revision=1
+revision=2
 create_wrksrc=yes
 build_wrksrc=arcan/src
 build_style=cmake

From 01477063a7f2700be128d8cf0988e68a0cec276d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 017/115] attract: revbump for ffmpeg4-4.4.3

---
 srcpkgs/attract/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/attract/template b/srcpkgs/attract/template
index 26144e931a3c7..e760bf0d18aec 100644
--- a/srcpkgs/attract/template
+++ b/srcpkgs/attract/template
@@ -1,12 +1,12 @@
 # Template file for 'attract'
 pkgname=attract
 version=2.6.2
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="VERBOSE=1"
 make_use_env=yes
 hostmakedepends="pkg-config"
-makedepends="SFML-devel ffmpeg-devel fontconfig-devel glu-devel libarchive-devel
+makedepends="SFML-devel ffmpeg4-devel fontconfig-devel glu-devel libarchive-devel
  libcurl-devel libjpeg-turbo-devel xine-lib rapidjson libXrandr-devel"
 depends="git"
 short_desc="Attract-Mode is a graphical frontend for emulators"

From dadbbd4e1b7fa09bcc3692ce35d03597e318cd3d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 018/115] aubio: revbump for ffmpeg-6.0

---
 srcpkgs/aubio/patches/ffmpeg5.patch | 25 +++++++++++++++++++++++++
 srcpkgs/aubio/template              |  2 +-
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/aubio/patches/ffmpeg5.patch

diff --git a/srcpkgs/aubio/patches/ffmpeg5.patch b/srcpkgs/aubio/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..aace41a6e6d9a
--- /dev/null
+++ b/srcpkgs/aubio/patches/ffmpeg5.patch
@@ -0,0 +1,25 @@
+From 8a05420e5dd8c7b8b2447f82dc919765876511b3 Mon Sep 17 00:00:00 2001
+From: Paul Brossier <piem@piem.org>
+Date: Tue, 25 Jan 2022 18:30:27 +0100
+Subject: [PATCH] [source_avcodec] define FF_API_LAVF_AVCTX for libavcodec >
+ 59, thx @berolinux (closes gh-353)
+
+---
+ src/io/source_avcodec.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/io/source_avcodec.c b/src/io/source_avcodec.c
+index e0ae93b5..1421bd9a 100644
+--- a/src/io/source_avcodec.c
++++ b/src/io/source_avcodec.c
+@@ -68,6 +68,10 @@
+ #define AUBIO_AVCODEC_MAX_BUFFER_SIZE AV_INPUT_BUFFER_MIN_SIZE
+ #endif
+ 
++#if LIBAVCODEC_VERSION_MAJOR >= 59
++#define FF_API_LAVF_AVCTX 1
++#endif
++
+ struct _aubio_source_avcodec_t {
+   uint_t hop_size;
+   uint_t samplerate;
diff --git a/srcpkgs/aubio/template b/srcpkgs/aubio/template
index ad1c4b2569917..7d875cc02541a 100644
--- a/srcpkgs/aubio/template
+++ b/srcpkgs/aubio/template
@@ -1,7 +1,7 @@
 # Template file for 'aubio'
 pkgname=aubio
 version=0.4.9
-revision=1
+revision=2
 build_style=waf3
 # XXX lash, pure and swig support.
 hostmakedepends="pkg-config txt2man"

From af5c426d0d84e1af4fd5f71a7ca63df1606dec3f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 019/115] audacious-plugins: revbump for ffmpeg-6.0

---
 .../audacious-plugins/patches/ffmpeg5.patch   | 43 +++++++++++++++++++
 srcpkgs/audacious-plugins/template            |  2 +-
 2 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/audacious-plugins/patches/ffmpeg5.patch

diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg5.patch b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..4e5e34099d71c
--- /dev/null
+++ b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
@@ -0,0 +1,43 @@
+commit 298aa371c56c2f52c25a33d9bdec4918b11cebdc
+Author: tibequadorian <tibequadorian@posteo.de>
+Date:   Sat Mar 19 18:40:12 2022 +0100
+
+    audacious-plugins: rebuild against ffmpeg-5.0
+
+diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+new file mode 100644
+index 0000000000..617c11215b
+--- /dev/null
++++ b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+@@ -0,0 +1,31 @@
++From f60beb400eeb1e4778bbfd738bc4a4ccef3de539 Mon Sep 17 00:00:00 2001
++From: John Lindgren <john@jlindgren.net>
++Date: Sat, 5 Mar 2022 12:05:34 -0500
++Subject: [PATCH] Fix build with FFmpeg 5.0
++
++---
++ src/ffaudio/ffaudio-core.cc | 4 ++--
++ 1 file changed, 2 insertions(+), 2 deletions(-)
++
++diff --git a/src/ffaudio/ffaudio-core.cc b/src/ffaudio/ffaudio-core.cc
++index 16dc63e3a..a2b95fd6c 100644
++--- a/src/ffaudio/ffaudio-core.cc
+++++ b/src/ffaudio/ffaudio-core.cc
++@@ -274,7 +274,7 @@ static AVInputFormat * get_format_by_content (const char * name, VFSFile & file)
++         AVProbeData d = {name, buf, filled};
++         score = target;
++ 
++-        f = av_probe_input_format2 (& d, true, & score);
+++        f = (AVInputFormat *) av_probe_input_format2 (& d, true, & score);
++         if (f)
++             break;
++ 
++@@ -347,7 +347,7 @@ static bool find_codec (AVFormatContext * c, CodecInfo * cinfo)
++ #endif
++         if (stream && stream->codecpar && stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
++         {
++-            AVCodec * codec = avcodec_find_decoder (stream->codecpar->codec_id);
+++            AVCodec * codec = (AVCodec *) avcodec_find_decoder (stream->codecpar->codec_id);
++ 
++             if (codec)
++             {
diff --git a/srcpkgs/audacious-plugins/template b/srcpkgs/audacious-plugins/template
index 88cbc1671fc6a..beebfae59ed44 100644
--- a/srcpkgs/audacious-plugins/template
+++ b/srcpkgs/audacious-plugins/template
@@ -2,7 +2,7 @@
 #Keep in sync with audacious!
 pkgname=audacious-plugins
 version=4.3.1
-revision=1
+revision=2
 build_style=meson
 configure_args="$(vopt_bool gtk3 gtk) $(vopt_bool gtk3)
  $(vopt_bool qt) $(vopt_bool qt qt6)"

From 0a4c10ee95c0d21d7823286bf82087e5e32fdbf0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 020/115] audacity: revbump for ffmpeg4-4.4.3

---
 srcpkgs/audacity/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/audacity/template b/srcpkgs/audacity/template
index 73314e6232bd6..df26db1c15873 100644
--- a/srcpkgs/audacity/template
+++ b/srcpkgs/audacity/template
@@ -1,7 +1,7 @@
 # Template file for 'audacity'
 pkgname=audacity
 version=3.3.3
-revision=1
+revision=2
 build_style=cmake
 build_helper="cmake-wxWidgets-gtk3 qemu"
 configure_args="-Daudacity_use_ffmpeg=loaded -Daudacity_lib_preference=system
@@ -10,7 +10,7 @@ configure_args="-Daudacity_use_ffmpeg=loaded -Daudacity_lib_preference=system
  -Daudacity_has_vst3=no"
 hostmakedepends="pkg-config gettext python3"
 makedepends="wxWidgets-gtk3-devel gtk+3-devel expat-devel lame-devel
- libsoxr-devel portaudio-devel sqlite-devel libcurl-devel ffmpeg-devel
+ libsoxr-devel portaudio-devel sqlite-devel libcurl-devel ffmpeg4-devel
  libid3tag-devel libmad-devel vamp-plugin-sdk-devel libogg-devel
  libvorbis-devel libflac-devel lilv-devel lv2 serd-devel sord-devel
  sratom-devel suil-devel portmidi-devel soundtouch-devel twolame-devel

From 5842cc6af86f2fef55fe213d478a7604c5291e6d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 021/115] avidemux: revbump for ffmpeg-6.0

---
 srcpkgs/avidemux/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/avidemux/template b/srcpkgs/avidemux/template
index 253a0243e2259..557285982d2b8 100644
--- a/srcpkgs/avidemux/template
+++ b/srcpkgs/avidemux/template
@@ -1,7 +1,7 @@
 # Template file for 'avidemux'
 pkgname=avidemux
 version=2.8.0
-revision=2
+revision=3
 # Can't be compiled for aarch64, arm* or mips*
 archs="x86_64* i686*"
 hostmakedepends="cmake pkg-config qt5-host-tools qt5-devel tar yasm"

From c3bb5470632e64280a556860e07bac72a1adaa8d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 022/115] blender: revbump for ffmpeg-6.0

---
 srcpkgs/blender/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index 05fdbf8f747e2..093d6d2004e95 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -9,8 +9,8 @@ configure_args="-DWITH_INSTALL_PORTABLE=OFF -DWITH_PYTHON_INSTALL=OFF
  -DWITH_JACK=ON -DWITH_CODEC_FFMPEG=ON -DWITH_CODEC_SNDFILE=ON -DWITH_OPENMP=ON
  -DWITH_FFTW3=ON -DWITH_MOD_OCEANSIM=ON -DWITH_CYCLES_EMBREE=OFF -DWITH_OPENCOLORIO=ON
  -DWITH_IMAGE_OPENEXR=ON -DWITH_IMAGE_OPENJPEG=ON -DWITH_OPENSUBDIV=ON
- -DWITH_OPENCOLLADA=ON -DWITH_SYSTEM_GLEW=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
- -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_LIBDECOR=ON
+ -DWITH_OPENCOLLADA=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
+ -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_WAYLAND_LIBDECOR=ON
  -DWITH_BUILDINFO=OFF -DPYTHON_VERSION=${py3_ver} -DPYTHON_LIBPATH=/usr/lib
  -DPYTHON_LIBRARY=python${py3_ver}${py3_abiver} -DPYTHON_INCLUDE_DIRS=/${py3_inc}
  -DWITH_SYSTEM_LZO=ON -DWITH_SYSTEM_EIGEN3=ON -DWITH_SYSTEM_FREETYPE=ON"

From 04d606be5af9c1694ca049b52156de62eb060d9f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 023/115] cantata: revbump for ffmpeg-6.0

---
 srcpkgs/cantata/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cantata/template b/srcpkgs/cantata/template
index 4b417d80d5c2d..8a90aaa4c07a2 100644
--- a/srcpkgs/cantata/template
+++ b/srcpkgs/cantata/template
@@ -1,7 +1,7 @@
 # Template file for 'cantata'
 pkgname=cantata
 version=2.5.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools qt5-tools"
 makedepends="qt5-devel qt5-tools-devel qt5-svg-devel qt5-xmlpatterns-devel

From e62ea1f54e952f3c72ddf7ea77030d48e998c47a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 024/115] ccextractor: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ccextractor/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/ccextractor/template b/srcpkgs/ccextractor/template
index 9abcd82852b27..6eccad5885af9 100644
--- a/srcpkgs/ccextractor/template
+++ b/srcpkgs/ccextractor/template
@@ -1,12 +1,12 @@
 # Template file for 'ccextractor'
 pkgname=ccextractor
 version=0.93
-revision=1
+revision=2
 build_wrksrc="linux"
 build_style=gnu-configure
 configure_args="--enable-ocr --enable-hardsubx"
 hostmakedepends="automake pkg-config"
-makedepends="leptonica-devel tesseract-ocr-devel ffmpeg-devel"
+makedepends="leptonica-devel tesseract-ocr-devel ffmpeg4-devel"
 short_desc="Extract subtitles from video streams"
 maintainer="newbluemoon <blaumolch@mailbox.org>"
 license="GPL-2.0-or-later"

From 25b7747682949efcb50b7a322f111a839167babd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 025/115] chromaprint: revbump for ffmpeg-6.0

---
 srcpkgs/chromaprint/patches/ffmpeg5.patch | 569 ++++++++++++++++++++++
 srcpkgs/chromaprint/template              |   2 +-
 2 files changed, 570 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromaprint/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromaprint/patches/ffmpeg5.patch b/srcpkgs/chromaprint/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..a9fd307a23c8a
--- /dev/null
+++ b/srcpkgs/chromaprint/patches/ffmpeg5.patch
@@ -0,0 +1,569 @@
+From 8ccad6937177b1b92e40ab8f4447ea27bac009a7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= <lalinsky@gmail.com>
+Date: Fri, 4 Nov 2022 21:47:38 +0100
+Subject: [PATCH] Use FFmpeg 5.x (#120)
+
+* Use FFmpeg 5.1.2 for CI builds
+
+* Build on Ubuntu 20.04
+
+* Upgrade code to FFmpeg 5.x APIs
+
+* Only set FFmpeg include dirs if building tools
+
+* No longer needed
+
+* Use ubuntu 20.04
+---
+ .github/workflows/build.yml                   |   6 +-
+ CMakeLists.txt                                |  16 --
+ package/build.sh                              |   4 +-
+ src/audio/ffmpeg_audio_processor.h            |   2 -
+ src/audio/ffmpeg_audio_processor_avresample.h |  72 -------
+ src/audio/ffmpeg_audio_processor_swresample.h |  18 +-
+ src/audio/ffmpeg_audio_reader.h               | 197 +++++++++---------
+ tests/CMakeLists.txt                          |   6 +
+ 8 files changed, 122 insertions(+), 199 deletions(-)
+ delete mode 100644 src/audio/ffmpeg_audio_processor_avresample.h
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index f8d6a32..4da2405 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -84,9 +84,6 @@ find_package(FFmpeg)
+ if(FFMPEG_LIBRARIES)
+ 	cmake_push_check_state(RESET)
+ 	set(CMAKE_REQUIRED_LIBRARIES ${FFMPEG_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -lm)
+-	check_function_exists(av_packet_unref HAVE_AV_PACKET_UNREF)
+-	check_function_exists(av_frame_alloc HAVE_AV_FRAME_ALLOC)
+-	check_function_exists(av_frame_free HAVE_AV_FRAME_FREE)
+ 	cmake_pop_check_state()
+ endif()
+
+@@ -163,14 +160,11 @@ message(STATUS "Using ${FFT_LIB} for FFT calculations")
+ if(NOT AUDIO_PROCESSOR_LIB)
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+ 		set(AUDIO_PROCESSOR_LIB "swresample")
+-	elseif(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(AUDIO_PROCESSOR_LIB "avresample")
+ 	endif()
+ endif()
+
+ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE OFF)
+ 		set(USE_SWRESAMPLE ON)
+ 		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBSWRESAMPLE_LIBRARIES})
+ 		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBSWRESAMPLE_INCLUDE_DIRS})
+@@ -178,16 +172,6 @@ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+ 	endif()
+ 	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+-elseif(AUDIO_PROCESSOR_LIB STREQUAL "avresample")
+-	if(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE ON)
+-		set(USE_SWRESAMPLE OFF)
+-		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBAVRESAMPLE_LIBRARIES})
+-		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBAVRESAMPLE_INCLUDE_DIRS})
+-	else()
+-		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+-	endif()
+-	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+ else()
+ 	message(STATUS "Building without audio conversion support, please install FFmpeg with libswresample")
+ endif()
+diff --git a/package/build.sh b/package/build.sh
+index da631ae..b41d36e 100755
+--- a/package/build.sh
++++ b/package/build.sh
+@@ -7,8 +7,8 @@ set -eux
+
+ BASE_DIR=$(cd $(dirname $0)/.. && pwd)
+
+-FFMPEG_VERSION=4.4.1
+-FFMPEG_BUILD_TAG=v4.4.1-1
++FFMPEG_VERSION=5.1.2
++FFMPEG_BUILD_TAG=v${FFMPEG_VERSION}-1
+
+ TMP_BUILD_DIR=$BASE_DIR/$(mktemp -d build.XXXXXXXX)
+ trap 'rm -rf $TMP_BUILD_DIR' EXIT
+diff --git a/src/audio/ffmpeg_audio_processor.h b/src/audio/ffmpeg_audio_processor.h
+index 7628fc7..39f4f6d 100644
+--- a/src/audio/ffmpeg_audio_processor.h
++++ b/src/audio/ffmpeg_audio_processor.h
+@@ -10,8 +10,6 @@
+
+ #if defined(USE_SWRESAMPLE)
+ #include "audio/ffmpeg_audio_processor_swresample.h"
+-#elif defined(USE_AVRESAMPLE)
+-#include "audio/ffmpeg_audio_processor_avresample.h"
+ #else
+ #error "no audio processing library"
+ #endif
+diff --git a/src/audio/ffmpeg_audio_processor_avresample.h b/src/audio/ffmpeg_audio_processor_avresample.h
+deleted file mode 100644
+index bd85f92..0000000
+--- a/src/audio/ffmpeg_audio_processor_avresample.h
++++ /dev/null
+@@ -1,72 +0,0 @@
+-// Copyright (C) 2016  Lukas Lalinsky
+-// Distributed under the MIT license, see the LICENSE file for details.
+-
+-#ifndef CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-#define CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-
+-extern "C" {
+-#include <libavresample/avresample.h>
+-}
+-
+-namespace chromaprint {
+-
+-class FFmpegAudioProcessor {
+-public:
+-	FFmpegAudioProcessor() {
+-		m_resample_ctx = avresample_alloc_context();
+-	}
+-
+-	~FFmpegAudioProcessor() {
+-		avresample_free(&m_resample_ctx);
+-	}
+-
+-	void SetCompatibleMode() {
+-		av_opt_set_int(m_resample_ctx, "filter_size", 16, 0);
+-		av_opt_set_int(m_resample_ctx, "phase_shift", 8, 0);
+-		av_opt_set_int(m_resample_ctx, "linear_interp", 1, 0);
+-		av_opt_set_double(m_resample_ctx, "cutoff", 0.8, 0);
+-	}
+-
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "in_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_rate", sample_rate, 0);
+-	}
+-
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "out_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_rate, 0);
+-	}
+-
+-	int Init() {
+-		return avresample_open(m_resample_ctx);
+-	}
+-
+-	int Convert(uint8_t **out, int out_count, const uint8_t **in, int in_count) {
+-		return avresample_convert(m_resample_ctx, out, 0, out_count, (uint8_t **) in, 0, in_count);
+-	}
+-
+-	int Flush(uint8_t **out, int out_count) {
+-		return avresample_read(m_resample_ctx, out, out_count);
+-	}
+-
+-private:
+-	AVAudioResampleContext *m_resample_ctx = nullptr;
+-};
+-
+-}; // namespace chromaprint
+-
+-#endif
+diff --git a/src/audio/ffmpeg_audio_processor_swresample.h b/src/audio/ffmpeg_audio_processor_swresample.h
+index b86266b..b1d4bea 100644
+--- a/src/audio/ffmpeg_audio_processor_swresample.h
++++ b/src/audio/ffmpeg_audio_processor_swresample.h
+@@ -28,30 +28,28 @@ public:
+ 		av_opt_set_double(m_swr_ctx, "cutoff", 0.8, 0);
+ 	}
+
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "icl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "ich", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetInputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "in_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "isf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "in_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "isr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "in_sample_rate", sample_rate, 0);
+ 	}
+
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "ocl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "och", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetOutputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "out_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "osf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "out_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "osr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "out_sample_rate", sample_rate, 0);
+ 	}
+
+ 	int Init() {
+diff --git a/src/audio/ffmpeg_audio_reader.h b/src/audio/ffmpeg_audio_reader.h
+index 5550164..1c6b346 100644
+--- a/src/audio/ffmpeg_audio_reader.h
++++ b/src/audio/ffmpeg_audio_reader.h
+@@ -62,7 +62,7 @@ public:
+ 	bool Read(const int16_t **data, size_t *size);
+
+ 	bool IsOpen() const { return m_opened; }
+-	bool IsFinished() const { return m_finished && !m_got_frame; }
++	bool IsFinished() const { return !m_has_more_packets && !m_has_more_frames; }
+
+ 	std::string GetError() const { return m_error; }
+ 	int GetErrorCode() const { return m_error_code; }
+@@ -74,20 +74,19 @@ private:
+ 	uint8_t *m_convert_buffer[1] = { nullptr };
+ 	int m_convert_buffer_nb_samples = 0;
+
+-	AVInputFormat *m_input_fmt = nullptr;
++	const AVInputFormat *m_input_fmt = nullptr;
+ 	AVDictionary *m_input_opts = nullptr;
+
+ 	AVFormatContext *m_format_ctx = nullptr;
+ 	AVCodecContext *m_codec_ctx = nullptr;
+-	AVFrame *m_frame = nullptr;
+ 	int m_stream_index = -1;
+ 	std::string m_error;
+ 	int m_error_code = 0;
+-	bool m_finished = false;
+ 	bool m_opened = false;
+-	int m_got_frame = 0;
+-	AVPacket m_packet;
+-	AVPacket m_packet0;
++	bool m_has_more_packets = true;
++	bool m_has_more_frames = true;
++	AVPacket *m_packet = nullptr;
++	AVFrame *m_frame = nullptr;
+
+ 	int m_output_sample_rate = 0;
+ 	int m_output_channels = 0;
+@@ -98,19 +97,12 @@ private:
+
+ inline FFmpegAudioReader::FFmpegAudioReader() {
+ 	av_log_set_level(AV_LOG_QUIET);
+-
+-	av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
+ }
+
+ inline FFmpegAudioReader::~FFmpegAudioReader() {
+ 	Close();
+ 	av_dict_free(&m_input_opts);
+ 	av_freep(&m_convert_buffer[0]);
+-	av_packet_unref(&m_packet0);
+ }
+
+ inline bool FFmpegAudioReader::SetInputFormat(const char *name) {
+@@ -135,11 +127,10 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ 	Close();
+
+-    av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
++	m_packet = av_packet_alloc();
++	if (!m_packet) {
++		return false;
++	}
+
+ 	ret = avformat_open_input(&m_format_ctx, file_name.c_str(), m_input_fmt, &m_input_opts);
+ 	if (ret < 0) {
+@@ -153,26 +144,31 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		return false;
+ 	}
+
+-	AVCodec *codec;
++	const AVCodec *codec;
+ 	ret = av_find_best_stream(m_format_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &codec, 0);
+ 	if (ret < 0) {
+ 		SetError("Could not find any audio stream in the file", ret);
+ 		return false;
+ 	}
+ 	m_stream_index = ret;
++	auto stream = m_format_ctx->streams[m_stream_index];
+
+-	m_codec_ctx = m_format_ctx->streams[m_stream_index]->codec;
++	m_codec_ctx = avcodec_alloc_context3(codec);
+ 	m_codec_ctx->request_sample_fmt = AV_SAMPLE_FMT_S16;
+
++	ret = avcodec_parameters_to_context(m_codec_ctx, stream->codecpar);
++	if (ret < 0) {
++		SetError("Could not copy the stream parameters", ret);
++		return false;
++	}
++
+ 	ret = avcodec_open2(m_codec_ctx, codec, nullptr);
+ 	if (ret < 0) {
+ 		SetError("Could not open the codec", ret);
+ 		return false;
+ 	}
+
+-	if (!m_codec_ctx->channel_layout) {
+-		m_codec_ctx->channel_layout = av_get_default_channel_layout(m_codec_ctx->channels);
+-	}
++	av_dump_format(m_format_ctx, 0, "foo", 0);
+
+ 	m_frame = av_frame_alloc();
+ 	if (!m_frame) {
+@@ -183,19 +179,23 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		m_output_sample_rate = m_codec_ctx->sample_rate;
+ 	}
+
+-	if (!m_output_channels) {
+-		m_output_channels = m_codec_ctx->channels;
++	AVChannelLayout output_channel_layout;
++	if (m_output_channels) {
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
++	} else {
++		m_output_channels = m_codec_ctx->ch_layout.nb_channels;
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
+ 	}
+
+-	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
++	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->ch_layout.nb_channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
+ 		m_converter.reset(new FFmpegAudioProcessor());
+ 		m_converter->SetCompatibleMode();
+ 		m_converter->SetInputSampleFormat(m_codec_ctx->sample_fmt);
+ 		m_converter->SetInputSampleRate(m_codec_ctx->sample_rate);
+-		m_converter->SetInputChannelLayout(m_codec_ctx->channel_layout);
++		m_converter->SetInputChannelLayout(&(m_codec_ctx->ch_layout));
+ 		m_converter->SetOutputSampleFormat(AV_SAMPLE_FMT_S16);
+ 		m_converter->SetOutputSampleRate(m_output_sample_rate);
+-		m_converter->SetOutputChannelLayout(av_get_default_channel_layout(m_output_channels));
++		m_converter->SetOutputChannelLayout(&output_channel_layout);
+ 		auto ret = m_converter->Init();
+ 		if (ret != 0) {
+ 			SetError("Could not create an audio converter instance", ret);
+@@ -203,10 +203,11 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		}
+ 	}
+
++	av_channel_layout_uninit(&output_channel_layout);
++
+ 	m_opened = true;
+-	m_finished = false;
+-	m_got_frame = 0;
+-	m_nb_packets = 0;
++	m_has_more_packets = true;
++	m_has_more_frames = true;
+ 	m_decode_error = 0;
+
+ 	return true;
+@@ -214,6 +215,7 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ inline void FFmpegAudioReader::Close() {
+ 	av_frame_free(&m_frame);
++	av_packet_free(&m_packet);
+
+ 	m_stream_index = -1;
+
+@@ -252,91 +254,98 @@ inline bool FFmpegAudioReader::Read(const int16_t **data, size_t *size) {
+ 		return false;
+ 	}
+
++	*data = nullptr;
++	*size = 0;
++
+ 	int ret;
++	bool needs_packet = false;
+ 	while (true) {
+-		while (m_packet.size <= 0) {
+-			av_packet_unref(&m_packet0);
+-			av_init_packet(&m_packet);
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			ret = av_read_frame(m_format_ctx, &m_packet);
++		while (needs_packet && m_packet->size == 0) {
++			ret = av_read_frame(m_format_ctx, m_packet);
+ 			if (ret < 0) {
+ 				if (ret == AVERROR_EOF) {
+-					m_finished = true;
++					needs_packet = false;
++					m_has_more_packets = false;
+ 					break;
+-				} else {
++				}
++				SetError("Error reading from the audio source", ret);
++				return false;
++			}
++			if (m_packet->stream_index == m_stream_index) {
++				needs_packet = false;
++			} else {
++				av_packet_unref(m_packet);
++			}
++		}
++
++		if (m_packet->size != 0) {
++			ret = avcodec_send_packet(m_codec_ctx, m_packet);
++			if (ret < 0) {
++				if (ret != AVERROR(EAGAIN)) {
+ 					SetError("Error reading from the audio source", ret);
+ 					return false;
+ 				}
+-			}
+-			m_packet0 = m_packet;
+-			if (m_packet.stream_index != m_stream_index) {
+-				m_packet.data = nullptr;
+-				m_packet.size = 0;
+ 			} else {
+-				m_nb_packets++;
++				av_packet_unref(m_packet);
+ 			}
+ 		}
+
+-		ret = avcodec_decode_audio4(m_codec_ctx, m_frame, &m_got_frame, &m_packet);
++		ret = avcodec_receive_frame(m_codec_ctx, m_frame);
+ 		if (ret < 0) {
+-			if (m_decode_error) {
+-				SetError("Error decoding audio frame", m_decode_error);
+-				return false;
++			if (ret == AVERROR_EOF) {
++				m_has_more_frames = false;
++			} else if (ret == AVERROR(EAGAIN)) {
++				if (m_has_more_packets) {
++					needs_packet = true;
++					continue;
++				} else {
++					m_has_more_frames = false;
++				}
+ 			}
+-			m_decode_error = ret;
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			continue;
++			SetError("Error decoding the audio source", ret);
++			return false;
+ 		}
+
+-		break;
+-	}
+-
+-	m_decode_error = 0;
+-
+-	const int decoded = std::min(ret, m_packet.size);
+-	m_packet.data += decoded;
+-	m_packet.size -= decoded;
+-
+-	if (m_got_frame) {
+-		if (m_converter) {
+-			if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
+-				int linsize;
+-				av_freep(&m_convert_buffer[0]);
+-				m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
+-				ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
+-				if (ret < 0) {
+-					SetError("Couldn't allocate audio converter buffer", ret);
++		if (m_frame->nb_samples > 0) {
++			if (m_converter) {
++				if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
++					int linsize;
++					av_freep(&m_convert_buffer[0]);
++					m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
++					ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->ch_layout.nb_channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
++					if (ret < 0) {
++						SetError("Couldn't allocate audio converter buffer", ret);
++						return false;
++					}
++				}
++				auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
++				if (nb_samples < 0) {
++					SetError("Couldn't convert audio", ret);
+ 					return false;
+ 				}
+-			}
+-			auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			}
+-			*data = (const int16_t *) m_convert_buffer[0];
+-			*size = nb_samples;
+-		} else {
+-			*data = (const int16_t *) m_frame->data[0];
+-			*size = m_frame->nb_samples;
+-		}
+-	} else {
+-		if (m_finished && m_converter) {
+-			auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			} else if (nb_samples > 0) {
+-				m_got_frame = 1;
+ 				*data = (const int16_t *) m_convert_buffer[0];
+ 				*size = nb_samples;
++			} else {
++				*data = (const int16_t *) m_frame->data[0];
++				*size = m_frame->nb_samples;
++			}
++		} else {
++			if (m_converter) {
++				if (IsFinished()) {
++					auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
++					if (nb_samples < 0) {
++						SetError("Couldn't convert audio", ret);
++						return false;
++					} else if (nb_samples > 0) {
++						*data = (const int16_t *) m_convert_buffer[0];
++						*size = nb_samples;
++					}
++				}
+ 			}
+ 		}
+-	}
+
+-	return true;
++		return true;
++	}
+ }
+
+ inline void FFmpegAudioReader::SetError(const char *message, int errnum) {
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index a2b517b..123e643 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -38,6 +38,12 @@ set(SRCS
+
+ if(BUILD_TOOLS)
+ 	set(SRCS ${SRCS} ../src/audio/ffmpeg_audio_reader_test.cpp)
++    include_directories(
++        ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}
++        ${AUDIO_PROCESSOR_INCLUDE_DIRS}
++    )
+ 	link_libraries(fpcalc_libs)
+ endif()
+
+-- 
+2.38.1
+
+
diff --git a/srcpkgs/chromaprint/template b/srcpkgs/chromaprint/template
index 7ef7838949f3a..1f7bbc70a22c8 100644
--- a/srcpkgs/chromaprint/template
+++ b/srcpkgs/chromaprint/template
@@ -1,7 +1,7 @@
 # Template file for 'chromaprint'
 pkgname=chromaprint
 version=1.5.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DBUILD_TOOLS=ON"
 make_check_target="check"

From a69887817ba065a8b4482e86ca2f58c48dc5413b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 026/115] chromium: revbump for ffmpeg-6.0

---
 .../patches/chromium-119-ffmpeg-4.4.patch     | 20 --------
 srcpkgs/chromium/patches/ffmpeg5.patch        | 47 +++++++++++++++++++
 srcpkgs/chromium/template                     |  2 +-
 3 files changed, 48 insertions(+), 21 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch
 create mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch b/srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch
deleted file mode 100644
index 04d04b166ba37..0000000000000
--- a/srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch
+++ /dev/null
@@ -1,20 +0,0 @@
---- a/media/filters/ffmpeg_demuxer.cc.orig
-+++ b/media/filters/ffmpeg_demuxer.cc
-@@ -390,7 +390,7 @@
- 
-   scoped_refptr<DecoderBuffer> buffer;
- 
--    size_t side_data_size = 0;
-+    int side_data_size = 0;
-     uint8_t* side_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
- 
-@@ -453,7 +453,7 @@
-                                        packet->size - data_offset);
-     }
- 
--    size_t skip_samples_size = 0;
-+    int skip_samples_size = 0;
-     const uint32_t* skip_samples_ptr =
-         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
-             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..24e2da38e34ca
--- /dev/null
+++ b/srcpkgs/chromium/patches/ffmpeg5.patch
@@ -0,0 +1,47 @@
+--- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
++++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
+@@ -92,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+-  if (stream->start_time != kNoFFmpegTimestamp)
++  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -1597,7 +1585,7 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+@@ -1618,7 +1606,7 @@
+     if (stream->type() != DemuxerStream::VIDEO)
+       continue;
+ 
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+ 
+     if (!stream->IsEnabled())
diff --git a/srcpkgs/chromium/template b/srcpkgs/chromium/template
index c4b76486570e2..dff94599b53d9 100644
--- a/srcpkgs/chromium/template
+++ b/srcpkgs/chromium/template
@@ -2,7 +2,7 @@
 pkgname=chromium
 # See https://chromiumdash.appspot.com/releases?platform=Linux for the latest version
 version=119.0.6045.105
-revision=1
+revision=2
 archs="i686* x86_64* aarch64* armv7l*"
 hostmakedepends="
  $(vopt_if clang "clang lld llvm15")

From 3da71f5f856ed9cd4867bc4a66a688a3b80eca5b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 027/115] cmus: revbump for ffmpeg-6.0

---
 srcpkgs/cmus/patches/ffmpeg6.patch | 12 ++++++++++++
 srcpkgs/cmus/template              |  2 +-
 2 files changed, 13 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/cmus/patches/ffmpeg6.patch

diff --git a/srcpkgs/cmus/patches/ffmpeg6.patch b/srcpkgs/cmus/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..ffa95ab811101
--- /dev/null
+++ b/srcpkgs/cmus/patches/ffmpeg6.patch
@@ -0,0 +1,12 @@
+--- a/ip/ffmpeg.c
++++ b/ip/ffmpeg.c
+@@ -202,9 +202,6 @@ static int ffmpeg_open(struct input_plugin_data *ip_data)
+ 			break;
+ 		}
+ 
+-		if (codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+-			cc->flags |= AV_CODEC_FLAG_TRUNCATED;
+-
+ 		if (avcodec_open2(cc, codec, NULL) < 0) {
+ 			d_print("could not open codec: %d, %s\n", cc->codec_id, avcodec_get_name(cc->codec_id));
+ 			err = -IP_ERROR_UNSUPPORTED_FILE_TYPE;
diff --git a/srcpkgs/cmus/template b/srcpkgs/cmus/template
index dc8a5e5d434cd..f664076170960 100644
--- a/srcpkgs/cmus/template
+++ b/srcpkgs/cmus/template
@@ -1,7 +1,7 @@
 # Template file for 'cmus'
 pkgname=cmus
 version=2.10.0
-revision=1
+revision=2
 build_style=configure
 configure_args="prefix=/usr LD=$CC"
 hostmakedepends="pkg-config"

From 7ecc4577345b5e6c898b3074e3de0d965f1aa9a1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 028/115] cyanrip: revbump for ffmpeg-6.0

---
 srcpkgs/cyanrip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cyanrip/template b/srcpkgs/cyanrip/template
index 9796e3461601a..5db30e020d17e 100644
--- a/srcpkgs/cyanrip/template
+++ b/srcpkgs/cyanrip/template
@@ -1,7 +1,7 @@
 # Template file for 'cyanrip'
 pkgname=cyanrip
 version=0.9.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config"
 makedepends="ffmpeg-devel libcdio-devel libcdio-paranoia-devel libcurl-devel libmusicbrainz5-devel"

From e025fd9b3e187336465ea0f793aa0bdc77188d85 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 029/115] deadbeef: revbump for ffmpeg4-4.4.3

---
 srcpkgs/deadbeef/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/deadbeef/template b/srcpkgs/deadbeef/template
index b664bb1b9bd9f..165b3c7b9cad8 100644
--- a/srcpkgs/deadbeef/template
+++ b/srcpkgs/deadbeef/template
@@ -1,14 +1,14 @@
 # Template file for 'deadbeef'
 pkgname=deadbeef
 version=1.8.8
-revision=1
+revision=2
 create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-oss --disable-lfm --disable-notify --disable-gtk2"
 hostmakedepends="automake libtool gettext gettext-devel intltool pkg-config
  yasm clang glib-devel"
 makedepends="
- alsa-lib-devel dbus-devel faad2-devel ffmpeg-devel gtk+3-devel imlib2-devel
+ alsa-lib-devel dbus-devel faad2-devel ffmpeg4-devel gtk+3-devel imlib2-devel
  jansson-devel libcddb-devel libcdio-devel libcurl-devel libflac-devel
  libmad-devel libpng-devel libsamplerate-devel libsndfile-devel libvorbis-devel
  libzip-devel mpg123-devel opusfile-devel pulseaudio-devel wavpack-devel"

From d544275aa826919793460f7420c400540a3e102b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 030/115] dolphin-emu: revbump for ffmpeg-6.0

---
 srcpkgs/dolphin-emu/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/dolphin-emu/template b/srcpkgs/dolphin-emu/template
index b4c8b64368a4b..070993aac31d2 100644
--- a/srcpkgs/dolphin-emu/template
+++ b/srcpkgs/dolphin-emu/template
@@ -1,7 +1,7 @@
 # Template file for 'dolphin-emu'
 pkgname=dolphin-emu
 version=5.0.19368
-revision=1
+revision=2
 _dolphin_commit=dadbeb4bae7e7fa23af2b46e0add4143094dc107
 _mgba_commit=44e074a15e9651481f7f652ac006a7c9d58cbeb9
 _googletest_commit=be03d00f5f0cc3a997d1a368bee8a1fe93651f48

From 05ba54cb16da17c2fc1b003a84bf45fc049596ba Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 031/115] droidcam-obs-plugin: revbump for ffmpeg-6.0

---
 srcpkgs/droidcam-obs-plugin/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam-obs-plugin/template b/srcpkgs/droidcam-obs-plugin/template
index fc9c9bf6b9d54..fb0480754df4d 100644
--- a/srcpkgs/droidcam-obs-plugin/template
+++ b/srcpkgs/droidcam-obs-plugin/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam-obs-plugin'
 pkgname=droidcam-obs-plugin
 version=2.0.1
-revision=1
+revision=2
 build_style=gnu-makefile
 make_use_env=yes
 make_build_args="ALLOW_STATIC=no"

From 5e68b6070a91f9fd615ccc0cc30cb4bead7a3b2e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 032/115] droidcam: revbump for ffmpeg-6.0

---
 srcpkgs/droidcam/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam/template b/srcpkgs/droidcam/template
index 1c3f1b8b1fc67..32a9220b79a4d 100644
--- a/srcpkgs/droidcam/template
+++ b/srcpkgs/droidcam/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam'
 pkgname=droidcam
 version=1.8.2
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="USBMUXD=-lusbmuxd-2.0 JPEG=-lturbojpeg"
 hostmakedepends="pkg-config"

From 66dd9396551313f69fee0b6b3778a5c8d488bbf1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 033/115] ffmpegthumbnailer: revbump for ffmpeg-6.0

---
 .../ffmpegthumbnailer/patches/ffmpeg6.patch   | 202 ++++++++++++++++++
 srcpkgs/ffmpegthumbnailer/template            |   6 +-
 2 files changed, 205 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch

diff --git a/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..363ff35a28419
--- /dev/null
+++ b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
@@ -0,0 +1,202 @@
+--- a/libffmpegthumbnailer/moviedecoder.cpp	2017-11-21 14:06:57.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.cpp	2023-05-05 13:14:47.946560668 -0400
+@@ -41,11 +41,6 @@
+ namespace ffmpegthumbnailer
+ {
+ 
+-struct SilenceLogLevel
+-{
+-    SilenceLogLevel() { av_log_set_level(AV_LOG_QUIET); }
+-};
+-
+ MovieDecoder::MovieDecoder(AVFormatContext* pavContext)
+ : m_VideoStream(-1)
+ , m_pFormatContext(pavContext)
+@@ -70,8 +65,6 @@
+ 
+ void MovieDecoder::initialize(const string& filename, bool preferEmbeddedMetadata)
+ {
+-    av_register_all();
+-    avcodec_register_all();
+     avformat_network_init();
+ 
+     string inputFile = filename == "-" ? "pipe:" : filename;
+@@ -97,8 +90,7 @@
+ {
+     if (m_pVideoCodecContext)
+     {
+-        avcodec_close(m_pVideoCodecContext);
+-        m_pVideoCodecContext = nullptr;
++        avcodec_free_context(&m_pVideoCodecContext);
+     }
+ 
+     if ((!m_FormatContextWasGiven) && m_pFormatContext)
+@@ -152,10 +144,10 @@
+     for (unsigned int i = 0; i < m_pFormatContext->nb_streams; ++i)
+     {
+         AVStream *stream = m_pFormatContext->streams[i];
+-        auto ctx = m_pFormatContext->streams[i]->codec;
+-        if (ctx->codec_type == AVMEDIA_TYPE_VIDEO)
++        auto par = m_pFormatContext->streams[i]->codecpar;
++        if (par->codec_type == AVMEDIA_TYPE_VIDEO)
+         {
+-            if (!preferEmbeddedMetadata || !isStillImageCodec(ctx->codec_id))
++            if (!preferEmbeddedMetadata || !isStillImageCodec(par->codec_id))
+             {
+                 videoStreams.push_back(i);
+                 continue;
+@@ -203,8 +195,7 @@
+     }
+ 
+     m_pVideoStream = m_pFormatContext->streams[m_VideoStream];
+-    m_pVideoCodecContext = m_pVideoStream->codec;
+-    m_pVideoCodec = avcodec_find_decoder(m_pVideoCodecContext->codec_id);
++    m_pVideoCodec = avcodec_find_decoder(m_pVideoStream->codecpar->codec_id);
+ 
+     if (m_pVideoCodec == nullptr)
+     {
+@@ -214,6 +205,20 @@
+         throw logic_error("Video Codec not found");
+     }
+ 
++    m_pVideoCodecContext = avcodec_alloc_context3(m_pVideoCodec);
++
++    if (m_pVideoCodecContext == nullptr)
++    {
++        destroy();
++        throw logic_error("Could not allocate video codec context");
++    }
++
++    if (avcodec_parameters_to_context(m_pVideoCodecContext, m_pVideoStream->codecpar) < 0)
++    {
++        destroy();
++        throw logic_error("Could not configure video codec context");
++    }
++
+     m_pVideoCodecContext->workaround_bugs = 1;
+ 
+     if (avcodec_open2(m_pVideoCodecContext, m_pVideoCodec, nullptr) < 0)
+@@ -386,13 +391,6 @@
+ 
+ void MovieDecoder::initializeFilterGraph(const AVRational& timeBase, const std::string& size, bool maintainAspectRatio)
+ {
+-    static const AVPixelFormat pixelFormats[] = { AV_PIX_FMT_RGB24, AV_PIX_FMT_NONE };
+-
+-    auto del = [] (AVBufferSinkParams* p) { av_freep(p); };
+-    std::unique_ptr<AVBufferSinkParams, decltype(del)> buffersinkParams(av_buffersink_params_alloc(), del);
+-
+-    avfilter_register_all();
+-
+     m_pFilterGraph = avfilter_graph_alloc();
+     assert(m_pFilterGraph);
+ 
+@@ -404,10 +402,8 @@
+ 
+     checkRc(avfilter_graph_create_filter(&m_pFilterSource, avfilter_get_by_name("buffer"), "thumb_buffer", ss.str().c_str(), nullptr, m_pFilterGraph),
+             "Failed to create filter source");
+-    buffersinkParams->pixel_fmts = pixelFormats;
+-    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, buffersinkParams.get(), m_pFilterGraph),
++    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, nullptr, m_pFilterGraph),
+             "Failed to create filter sink");
+-    buffersinkParams.release();
+ 
+     AVFilterContext* yadifFilter = nullptr;
+     if (m_pFrame->interlaced_frame != 0)
+@@ -500,15 +496,15 @@
+     }
+ 
+     checkRc(av_seek_frame(m_pFormatContext, -1, timestamp, 0), "Seeking in video failed");
+-    avcodec_flush_buffers(m_pFormatContext->streams[m_VideoStream]->codec);
++    avcodec_flush_buffers(m_pVideoCodecContext);
+ 
+     int keyFrameAttempts = 0;
+-    bool gotFrame = 0;
++    bool gotFrame;
+ 
+     do
+     {
+         int count = 0;
+-        gotFrame = 0;
++        gotFrame = false;
+ 
+         while (!gotFrame && count < 20)
+         {
+@@ -552,17 +548,33 @@
+         return false;
+     }
+ 
+-    av_frame_unref(m_pFrame);
+-
+-    int frameFinished;
++    int rc = avcodec_send_packet(m_pVideoCodecContext, m_pPacket);
++    if(rc == AVERROR(EAGAIN))
++    {
++        rc = 0;
++    }
+ 
+-    int bytesDecoded = avcodec_decode_video2(m_pVideoCodecContext, m_pFrame, &frameFinished, m_pPacket);
+-    if (bytesDecoded < 0)
++    if(rc == AVERROR_EOF)
++    {
++        return false;
++    }
++    else if(rc < 0)
+     {
+-        throw logic_error("Failed to decode video frame: bytesDecoded < 0");
++        throw logic_error("Failed to decode video frame: avcodec_send_packet() < 0");
+     }
+ 
+-    return frameFinished > 0;
++    rc = avcodec_receive_frame(m_pVideoCodecContext, m_pFrame);
++    switch(rc)
++    {
++        case 0:
++            return true;
++
++        case AVERROR(EAGAIN):
++            return false;
++
++        default:
++            throw logic_error("Failed to decode video frame: avcodec_receive_frame() < 0");
++    }
+ }
+ 
+ bool MovieDecoder::getVideoPacket()
+@@ -570,8 +582,6 @@
+     bool framesAvailable = true;
+     bool frameDecoded = false;
+ 
+-    int attempts = 0;
+-
+     if (m_pPacket)
+     {
+         av_packet_unref(m_pPacket);
+@@ -580,6 +590,7 @@
+ 
+     m_pPacket = new AVPacket();
+ 
++
+     while (framesAvailable && !frameDecoded)
+     {
+         framesAvailable = av_read_frame(m_pFormatContext, m_pPacket) >= 0;
+@@ -644,7 +655,7 @@
+ 
+ int32_t MovieDecoder::getStreamRotation()
+ {
+-    int32_t* matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
++    auto matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
+     if (matrix)
+     {
+         auto angle = lround(av_display_rotation_get(matrix));
+
+--- a/libffmpegthumbnailer/moviedecoder.h	2017-11-12 04:23:38.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.h	2023-05-05 13:26:07.095529911 -0400
+@@ -78,7 +78,7 @@
+     int                     m_VideoStream;
+     AVFormatContext*        m_pFormatContext;
+     AVCodecContext*         m_pVideoCodecContext;
+-    AVCodec*                m_pVideoCodec;
++    const AVCodec*          m_pVideoCodec;
+     AVFilterGraph*          m_pFilterGraph;
+     AVFilterContext*        m_pFilterSource;
+     AVFilterContext*        m_pFilterSink;
diff --git a/srcpkgs/ffmpegthumbnailer/template b/srcpkgs/ffmpegthumbnailer/template
index 039eea7622b39..35d546018d12a 100644
--- a/srcpkgs/ffmpegthumbnailer/template
+++ b/srcpkgs/ffmpegthumbnailer/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbnailer'
 pkgname=ffmpegthumbnailer
 version=2.2.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libpng-devel libjpeg-turbo-devel ffmpeg-devel"
@@ -9,8 +9,8 @@ depends="ffmpeg"
 short_desc="Lightweight video thumbnailer"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
-homepage="https://github.com/dirkvdb/${pkgname}"
-distfiles="${homepage}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
+homepage="https://github.com/dirkvdb"
+distfiles="${homepage}/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
 checksum=1cb24059c38223f657b300c84dd80491b7040d4b69471c4fea69be862bc99b5b
 
 post_install() {

From 98ac14ffe140b1c0da098378229349ec80b366a2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 034/115] ffmpegthumbs: revbump for ffmpeg-6.0

---
 srcpkgs/ffmpegthumbs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ffmpegthumbs/template b/srcpkgs/ffmpegthumbs/template
index 5f0b9414dadaf..11b88193528f4 100644
--- a/srcpkgs/ffmpegthumbs/template
+++ b/srcpkgs/ffmpegthumbs/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbs'
 pkgname=ffmpegthumbs
 version=22.12.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules kcoreaddons kconfig-devel
  pkg-config qt5-host-tools qt5-qmake gettext"

From 8d6985175f4093a3e4b2ea3dced748513bb75d88 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 035/115] ffms2: revbump for ffmpeg-6.0

---
 srcpkgs/ffms2/patches/ffmpeg5.patch | 424 ++++++++++++++++++++++++++++
 srcpkgs/ffms2/template              |   2 +-
 2 files changed, 425 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ffms2/patches/ffmpeg5.patch

diff --git a/srcpkgs/ffms2/patches/ffmpeg5.patch b/srcpkgs/ffms2/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..1479fabcafcb4
--- /dev/null
+++ b/srcpkgs/ffms2/patches/ffmpeg5.patch
@@ -0,0 +1,424 @@
+From 45673149e9a2f5586855ad472e3059084eaa36b1 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:41:21 +0100
+Subject: [PATCH] Use auto for AVCodec
+
+The geniuses over at FFmpeg decided to constify this API, so old
+versions of the library will return AVCodec *, while new versions
+of the libary will return const AVCodec *, which, in C++, are not
+OK to convert between.
+
+Rather than use some macro hell in ffmscompat.h, we can work around
+this by using auto.
+
+Gross.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 2 +-
+ src/core/indexing.cpp    | 6 +++---
+ src/core/videosource.cpp | 2 +-
+ 3 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index e4ce97c..ac09666 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -469,7 +469,7 @@ void FFMS_AudioSource::OpenFile() {
+ 
+     LAVFOpenFile(SourceFile.c_str(), FormatContext, TrackNumber);
+ 
+-    AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
++    auto *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
+     if (Codec == nullptr)
+         throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+             "Audio codec not found");
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index e547c5a..59fb4e8 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -384,7 +384,7 @@ FFMS_TrackType FFMS_Indexer::GetTrackType(int Track) {
+ }
+ 
+ const char *FFMS_Indexer::GetTrackCodec(int Track) {
+-    AVCodec *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
++    auto *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
+     return codec ? codec->name : nullptr;
+ }
+ 
+@@ -402,7 +402,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             UseDTS);
+ 
+         if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            AVCodec *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (!VideoCodec) {
+                 FormatContext->streams[i]->discard = AVDISCARD_ALL;
+                 IndexMask.erase(i);
+@@ -433,7 +433,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 IndexMask.insert(i);
+             }
+         } else if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+-            AVCodec *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (AudioCodec == nullptr)
+                 throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_UNSUPPORTED,
+                     "Audio codec not found");
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index b889970..8956c22 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -171,7 +171,7 @@ FFMS_VideoSource::FFMS_VideoSource(const char *SourceFile, FFMS_Index &Index, in
+ 
+         LAVFOpenFile(SourceFile, FormatContext, VideoTrack);
+ 
+-        AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
++        auto *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
+         if (Codec == nullptr)
+             throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+                 "Video codec not found");
+-- 
+2.40.0
+
+From 96cbf38ea9381829a1314f432a2c60495dcefaad Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:12:41 +0100
+Subject: [PATCH] all: Update AVPacket API usage
+
+AVPackets must all be on the heap now, since it is no longer
+part of the libav* ABI.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 16 ++++++----
+ src/core/indexing.cpp    | 63 ++++++++++++++++++++++------------------
+ src/core/indexing.h      |  4 +--
+ src/core/utils.cpp       |  6 ----
+ src/core/utils.h         |  1 -
+ src/core/videosource.cpp | 30 ++++++++++---------
+ 6 files changed, 64 insertions(+), 56 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index 37cf9ae..e4ce97c 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -285,10 +285,15 @@ FFMS_AudioSource::AudioBlock *FFMS_AudioSource::CacheBlock(CacheIterator &pos) {
+ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     CurrentFrame = &Frames[PacketNumber];
+ 
+-    AVPacket Packet;
+-    if (!ReadPacket(&Packet))
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++    if (!ReadPacket(Packet)) {
++        av_packet_free(&Packet);
+         throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_UNKNOWN,
+             "ReadPacket unexpectedly failed to read a packet");
++    }
+ 
+     // ReadPacket may have changed the packet number
+     CurrentFrame = &Frames[PacketNumber];
+@@ -297,8 +302,9 @@ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     int NumberOfSamples = 0;
+     AudioBlock *CachedBlock = nullptr;
+     
+-    int Ret = avcodec_send_packet(CodecContext, &Packet);
+-    av_packet_unref(&Packet);
++    int Ret = avcodec_send_packet(CodecContext, Packet);
++    av_packet_unref(Packet);
++    av_packet_free(&Packet);
+ 
+     av_frame_unref(DecodeFrame);
+     Ret = avcodec_receive_frame(CodecContext, DecodeFrame);
+@@ -513,8 +519,6 @@ void FFMS_AudioSource::Seek() {
+ }
+ 
+ bool FFMS_AudioSource::ReadPacket(AVPacket *Packet) {
+-    InitNullPacket(*Packet);
+-
+     while (av_read_frame(FormatContext, Packet) >= 0) {
+         if (Packet->stream_index == TrackNumber) {
+             // Required because not all audio packets, especially in ogg, have a pts. Use the previous valid packet's pts instead.
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index 23fb95b..e547c5a 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -320,7 +320,7 @@ void FFMS_Indexer::CheckAudioProperties(int Track, AVCodecContext *Context) {
+     }
+ }
+ 
+-void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict,
++void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict,
+                                     int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct) {
+     if (VideoContext.Parser) {
+         uint8_t *OB;
+@@ -330,8 +330,8 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+         av_parser_parse2(VideoContext.Parser,
+             VideoContext.CodecContext,
+             &OB, &OBSize,
+-            pkt.data, pkt.size,
+-            pkt.pts, pkt.dts, pkt.pos);
++            pkt->data, pkt->size,
++            pkt->pts, pkt->dts, pkt->pos);
+ 
+         // H.264 (PAFF) and HEVC may have one field per packet, so we need to track
+         // when we have a full or half frame available, and mark one of them as
+@@ -351,15 +351,15 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+ 
+         *RepeatPict = VideoContext.Parser->repeat_pict;
+         *FrameType = VideoContext.Parser->pict_type;
+-        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt.flags & AV_PKT_FLAG_DISCARD));
++        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt->flags & AV_PKT_FLAG_DISCARD));
+     } else {
+-        *Invisible = !!(pkt.flags & AV_PKT_FLAG_DISCARD);
++        *Invisible = !!(pkt->flags & AV_PKT_FLAG_DISCARD);
+     }
+ 
+     if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP8)
+-        ParseVP8(pkt.data[0], Invisible, FrameType);
++        ParseVP8(pkt->data[0], Invisible, FrameType);
+     else if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP9)
+-        ParseVP9(pkt.data[0], Invisible, FrameType);
++        ParseVP9(pkt->data[0], Invisible, FrameType);
+ }
+ 
+ void FFMS_Indexer::Free() {
+@@ -458,32 +458,36 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+         }
+     }
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
+     std::vector<int64_t> LastValidTS(FormatContext->nb_streams, AV_NOPTS_VALUE);
+ 
+     int64_t filesize = avio_size(FormatContext->pb);
+     enum AVPictureStructure LastPicStruct = AV_PICTURE_STRUCTURE_UNKNOWN;
+-    while (av_read_frame(FormatContext, &Packet) >= 0) {
++    while (av_read_frame(FormatContext, Packet) >= 0) {
+         // Update progress
+         // FormatContext->pb can apparently be NULL when opening images.
+         if (IC && FormatContext->pb) {
+-            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate))
++            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate)) {
++                av_packet_free(&Packet);
+                 throw FFMS_Exception(FFMS_ERROR_CANCELLED, FFMS_ERROR_USER,
+                     "Cancelled by user");
++            }
+         }
+-        if (!IndexMask.count(Packet.stream_index)) {
+-            av_packet_unref(&Packet);
++        if (!IndexMask.count(Packet->stream_index)) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+-        int Track = Packet.stream_index;
++        int Track = Packet->stream_index;
+         FFMS_Track &TrackInfo = (*TrackIndices)[Track];
+-        bool KeyFrame = !!(Packet.flags & AV_PKT_FLAG_KEY);
++        bool KeyFrame = !!(Packet->flags & AV_PKT_FLAG_KEY);
+         ReadTS(Packet, LastValidTS[Track], (*TrackIndices)[Track].UseDTS);
+ 
+         if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            int64_t PTS = TrackInfo.UseDTS ? Packet.dts : Packet.pts;
++            int64_t PTS = TrackInfo.UseDTS ? Packet->dts : Packet->pts;
+             if (PTS == AV_NOPTS_VALUE) {
+                 // VPx alt-refs are output as packets which lack timestmps or durations, since
+                 // they are invisible. Currently, the timestamp mangling code in libavformat
+@@ -495,9 +499,11 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 // FFMS2 currently sorts packets by PTS, which will break decoding, otherwise.
+                 bool HasAltRefs = (FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP8 ||
+                                    FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP9);
+-                if (Packet.duration == 0 && !HasAltRefs)
++                if (Packet->duration == 0 && !HasAltRefs) {
++                    av_packet_free(&Packet);
+                     throw FFMS_Exception(FFMS_ERROR_INDEXING, FFMS_ERROR_PARSER,
+                         "Invalid packet pts, dts, and duration");
++                }
+ 
+                 if (TrackInfo.empty())
+                     PTS = 0;
+@@ -513,7 +519,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             ParseVideoPacket(AVContexts[Track], Packet, &RepeatPict, &FrameType, &Invisible, &LastPicStruct);
+ 
+             TrackInfo.AddVideoFrame(PTS, RepeatPict, KeyFrame,
+-                FrameType, Packet.pos, Invisible);
++                FrameType, Packet->pos, Invisible);
+         } else if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+             // For video seeking timestamps are used only if all packets have
+             // timestamps, while for audio they're used if any have timestamps,
+@@ -522,28 +528,29 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 TrackInfo.HasTS = true;
+ 
+             int64_t StartSample = AVContexts[Track].CurrentSample;
+-            uint32_t SampleCount = IndexAudioPacket(Track, &Packet, AVContexts[Track], *TrackIndices);
++            uint32_t SampleCount = IndexAudioPacket(Track, Packet, AVContexts[Track], *TrackIndices);
+             TrackInfo.SampleRate = AVContexts[Track].CodecContext->sample_rate;
+ 
+             TrackInfo.AddAudioFrame(LastValidTS[Track],
+-                StartSample, SampleCount, KeyFrame, Packet.pos, Packet.flags & AV_PKT_FLAG_DISCARD);
++                StartSample, SampleCount, KeyFrame, Packet->pos, Packet->flags & AV_PKT_FLAG_DISCARD);
+         }
+ 
+-        if (!(Packet.flags & AV_PKT_FLAG_DISCARD))
+-            TrackInfo.LastDuration = Packet.duration;
++        if (!(Packet->flags & AV_PKT_FLAG_DISCARD))
++            TrackInfo.LastDuration = Packet->duration;
+ 
+-        av_packet_unref(&Packet);
++        av_packet_unref(Packet);
+     }
++    av_packet_free(&Packet);
+ 
+     TrackIndices->Finalize(AVContexts, FormatContext->iformat->name);
+     return TrackIndices.release();
+ }
+ 
+-void FFMS_Indexer::ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS) {
+-    if (!UseDTS && Packet.pts != AV_NOPTS_VALUE)
+-        TS = Packet.pts;
++void FFMS_Indexer::ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS) {
++    if (!UseDTS && Packet->pts != AV_NOPTS_VALUE)
++        TS = Packet->pts;
+     if (TS == AV_NOPTS_VALUE)
+         UseDTS = true;
+-    if (UseDTS && Packet.dts != AV_NOPTS_VALUE)
+-        TS = Packet.dts;
++    if (UseDTS && Packet->dts != AV_NOPTS_VALUE)
++        TS = Packet->dts;
+ }
+diff --git a/src/core/indexing.h b/src/core/indexing.h
+index 3cfc3c3..5c06868 100644
+--- a/src/core/indexing.h
++++ b/src/core/indexing.h
+@@ -80,10 +80,10 @@ private:
+     int64_t Filesize;
+     uint8_t Digest[20];
+ 
+-    void ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS);
++    void ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS);
+     void CheckAudioProperties(int Track, AVCodecContext *Context);
+     uint32_t IndexAudioPacket(int Track, AVPacket *Packet, SharedAVContext &Context, FFMS_Index &TrackIndices);
+-    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
++    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
+     void Free();
+ public:
+     FFMS_Indexer(const char *Filename);
+diff --git a/src/core/utils.cpp b/src/core/utils.cpp
+index ce67533..8a2e997 100644
+--- a/src/core/utils.cpp
++++ b/src/core/utils.cpp
+@@ -62,12 +62,6 @@ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo) {
+     }
+ }
+ 
+-void InitNullPacket(AVPacket &pkt) {
+-    av_init_packet(&pkt);
+-    pkt.data = nullptr;
+-    pkt.size = 0;
+-}
+-
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames) {
+     AP.SampleFormat = static_cast<FFMS_SampleFormat>(av_get_packed_sample_fmt(CTX->sample_fmt));
+     AP.BitsPerSample = av_get_bytes_per_sample(CTX->sample_fmt) * 8;
+diff --git a/src/core/utils.h b/src/core/utils.h
+index 9819dc7..003ab79 100644
+--- a/src/core/utils.h
++++ b/src/core/utils.h
+@@ -58,7 +58,6 @@ std::unique_ptr<T> make_unique(Args&&... args) {
+ }
+ 
+ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo);
+-void InitNullPacket(AVPacket &pkt);
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames);
+ 
+ void LAVFOpenFile(const char *SourceFile, AVFormatContext *&FormatContext, int Track);
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index 06bd161..b889970 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -673,30 +673,34 @@ void FFMS_VideoSource::DecodeNextFrame(int64_t &AStartTime, int64_t &Pos) {
+     if (HasPendingDelayedFrames())
+         return;
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
+-
+-    while (ReadFrame(&Packet) >= 0) {
+-        if (Packet.stream_index != VideoTrack) {
+-            av_packet_unref(&Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++
++    while (ReadFrame(Packet) >= 0) {
++        if (Packet->stream_index != VideoTrack) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+         if (AStartTime < 0)
+-            AStartTime = Frames.UseDTS ? Packet.dts : Packet.pts;
++            AStartTime = Frames.UseDTS ? Packet->dts : Packet->pts;
+ 
+         if (Pos < 0)
+-            Pos = Packet.pos;
++            Pos = Packet->pos;
+ 
+-        bool FrameFinished = DecodePacket(&Packet);
+-        av_packet_unref(&Packet);
+-        if (FrameFinished)
++        bool FrameFinished = DecodePacket(Packet);
++        av_packet_unref(Packet);
++        if (FrameFinished) {
++            av_packet_free(&Packet);
+             return;
++        }
+     }
+ 
+     // Flush final frames
+-    InitNullPacket(Packet);
+-    DecodePacket(&Packet);
++    DecodePacket(Packet);
++    av_packet_free(&Packet);
+ }
+ 
+ bool FFMS_VideoSource::SeekTo(int n, int SeekOffset) {
+-- 
+2.40.0
+
+From bf9e03e9e08534c024e5a744a6437c4aac160201 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:20:47 +0100
+Subject: [PATCH 2/3] configure: Remove deprecated API use
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ configure.ac | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index b35ef80bc..d19714d0f 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -102,10 +102,10 @@ CFLAGS="$_CFLAGS $FFMPEG_CFLAGS"
+
+ AC_DEFUN([TEST_FFMPEG],
+          [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+-            #include <libavcodec/avcodec.h>
++            #include <libavformat/avformat.h>
+             #include <libswscale/swscale.h>
+             ]],[[
+-                avcodec_register_all();
++                avformat_network_init();
+                 swscale_version();
+             ]])], [eval $1=yes], [eval $1=no])
+         ])
+
diff --git a/srcpkgs/ffms2/template b/srcpkgs/ffms2/template
index 365f64d10cbab..1641ecf43be5b 100644
--- a/srcpkgs/ffms2/template
+++ b/srcpkgs/ffms2/template
@@ -1,7 +1,7 @@
 # Template file for 'ffms2'
 pkgname=ffms2
 version=2.40
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-shared --disable-static"
 hostmakedepends="pkg-config autoconf automake libtool"

From 9b3b60de34cabd1187cc25a0d666838b4b6f4c5f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 036/115] freerdp: revbump for ffmpeg-6.0

---
 .../freerdp/patches/ffmpeg6_aa2cb9aa.patch    | 42 +++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100644 srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch

diff --git a/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
new file mode 100644
index 0000000000000..a4324da3a8822
--- /dev/null
+++ b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
@@ -0,0 +1,42 @@
+From aa2cb9aa5ff5562433598ba168a466e0752bca0e Mon Sep 17 00:00:00 2001
+From: akallabeth <akallabeth@posteo.net>
+Date: Tue, 14 Feb 2023 07:48:54 +0100
+Subject: [PATCH] Fixed #8686: Update h264 to use new FFMPEG API
+
+---
+ channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c | 2 ++
+ libfreerdp/codec/h264_ffmpeg.c            | 2 ++
+ 2 files changed, 4 insertions(+)
+
+diff --git a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+index 339462d865f..beea80b7a1e 100644
+--- a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
++++ b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+@@ -239,8 +239,10 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYP
+ 		}
+ 	}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 	if (mdecoder->codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		mdecoder->codec_context->flags |= AV_CODEC_FLAG_TRUNCATED;
++#endif
+ 
+ 	return TRUE;
+ }
+diff --git a/libfreerdp/codec/h264_ffmpeg.c b/libfreerdp/codec/h264_ffmpeg.c
+index 8a23db2473c..896a333019b 100644
+--- a/libfreerdp/codec/h264_ffmpeg.c
++++ b/libfreerdp/codec/h264_ffmpeg.c
+@@ -615,10 +615,12 @@ static BOOL libavcodec_init(H264_CONTEXT* h264)
+ 			goto EXCEPTION;
+ 		}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 		if (sys->codecDecoder->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		{
+ 			sys->codecDecoderContext->flags |= AV_CODEC_FLAG_TRUNCATED;
+ 		}
++#endif
+ 
+ #ifdef WITH_VAAPI
+ 

From b8bdbc073224d0f3ee8a8a676312aa0083d852e0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 037/115] gerbera: revbump for ffmpeg-6.0

---
 srcpkgs/gerbera/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gerbera/template b/srcpkgs/gerbera/template
index ae14f35c767c0..2dc0ac0ce03b5 100644
--- a/srcpkgs/gerbera/template
+++ b/srcpkgs/gerbera/template
@@ -1,7 +1,7 @@
 # Template file for 'gerbera'
 pkgname=gerbera
 version=1.12.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_SYSTEMD=0 -DWITH_AVCODEC=1"
 hostmakedepends="pkg-config"

From 6cf114d990518928cbe294563db61af45a24d071 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 038/115] goldendict: revbump for ffmpeg-6.0

---
 srcpkgs/goldendict/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/goldendict/template b/srcpkgs/goldendict/template
index f4a05759f693d..97f44347b03a6 100644
--- a/srcpkgs/goldendict/template
+++ b/srcpkgs/goldendict/template
@@ -1,7 +1,7 @@
 # Template file for 'goldendict'
 pkgname=goldendict
 version=1.5.0
-revision=1
+revision=2
 build_style=qmake
 configure_args="CONFIG+=zim_support goldendict.pro"
 hostmakedepends="qt5-qmake pkg-config qt5-host-tools"
@@ -10,7 +10,7 @@ makedepends="tiff-devel qt5-devel libvorbis-devel zlib-devel
  qt5-webkit-devel lzo-devel bzip2-devel libao-devel qt5-svg-devel
  libeb-devel qt5-x11extras-devel ffmpeg-devel liblzma-devel
  qt5-multimedia-devel"
-short_desc="A feature-rich dictionary lookup program"
+short_desc="Feature-rich dictionary lookup program"
 maintainer="John <me@johnnynator.dev>"
 license="GPL-3.0-or-later"
 homepage="http://goldendict.org/"

From be7dfb74a9e94c0b97bf6d72515e85d22573d5ad Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 039/115] gst-libav: revbump for ffmpeg-6.0

---
 srcpkgs/gst-libav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index 37485f6f6a9e8..f610e966f23cd 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.22.5
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"

From c4c47029b498c04f11253dba002150cb7c1981c5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 040/115] gst-rtsp-server: revbump for ffmpeg-6.0

---
 srcpkgs/gst-rtsp-server/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index f266f4777b3ea..011444eb26739 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
 version=1.22.5
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="glib-devel gst-plugins-bad1-devel gobject-introspection

From eb3a97f2a7dcf5152931b26d3fbf4e76997a8cc6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 041/115] guvcview: update to 2.0.8.

---
 srcpkgs/guvcview/patches/fix-include.patch | 10 ++++++++++
 srcpkgs/guvcview/template                  |  5 ++---
 2 files changed, 12 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/guvcview/patches/fix-include.patch

diff --git a/srcpkgs/guvcview/patches/fix-include.patch b/srcpkgs/guvcview/patches/fix-include.patch
new file mode 100644
index 0000000000000..503c2af3b78c1
--- /dev/null
+++ b/srcpkgs/guvcview/patches/fix-include.patch
@@ -0,0 +1,10 @@
+--- a/guvcview/guvcview.c
++++ b/guvcview/guvcview.c
+@@ -28,6 +28,7 @@
+ #include <sys/stat.h>
+ #include <sys/resource.h>
+ #include <errno.h>
++#include <locale.h>
+ 
+ #include "gview.h"
+ #include "gviewv4l2core.h"
diff --git a/srcpkgs/guvcview/template b/srcpkgs/guvcview/template
index 345cf6006f246..86a7fd619612c 100644
--- a/srcpkgs/guvcview/template
+++ b/srcpkgs/guvcview/template
@@ -1,8 +1,7 @@
 # Template file for 'guvcview'
 pkgname=guvcview
-version=2.0.7
+version=2.0.8
 revision=1
-create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-static --disable-debian-menu"
 hostmakedepends="pkg-config intltool autoconf automake libtool glib-devel"
@@ -14,7 +13,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="http://guvcview.sourceforge.net/"
 distfiles="${SOURCEFORGE_SITE}/${pkgname}/${pkgname}-src-${version}.tar.bz2"
-checksum=f47d51fbd06e44eeaa1a82f4a153c927527c90d94514197a70b2956028cc8ad4
+checksum=a21f4e448286666cf27bafef5290cc953a0a1796b752e5bbe521266dc1230c81
 
 post_patch() {
 	sed '31a#include <locale.h>' -i  guvcview/guvcview.c

From 6a6c8f53bfd657623e4634f2900429dd96a57b62 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 042/115] handbrake: update to 1.6.1

---
 .../patches/fix-missing-x265-link-flag.patch    | 11 ++++++-----
 .../handbrake/patches/libhb-vpl-include.patch   | 15 +++++++++++++++
 srcpkgs/handbrake/template                      | 17 ++++++++++-------
 3 files changed, 31 insertions(+), 12 deletions(-)
 create mode 100644 srcpkgs/handbrake/patches/libhb-vpl-include.patch

diff --git a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
index 26db03867a0c8..d6bb2eda627a3 100644
--- a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
+++ b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
@@ -1,14 +1,15 @@
 --- a/gtk/configure.ac
 +++ b/gtk/configure.ac
 @@ -203,7 +203,7 @@
- 
+
  AM_CONDITIONAL([MINGW], [test "x$mingw_flag" = "xyes"])
- 
--HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg"
-+HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -ldl"
+
+-HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc"
++HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc -ldl"
  HB_CPPFLAGS="$HB_CPPFLAGS $HBINC"
- 
+
  PKG_CHECK_MODULES([x264], [x264], sys_x264=yes, sys_x264=no)
+
 --- a/test/module.defs
 +++ b/test/module.defs
 @@ -69,6 +69,9 @@
diff --git a/srcpkgs/handbrake/patches/libhb-vpl-include.patch b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
new file mode 100644
index 0000000000000..298f9f4ab28f2
--- /dev/null
+++ b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
@@ -0,0 +1,15 @@
+--- a/libhb/module.defs	2023-01-22 11:36:49.000000000 -0500
++++ b/libhb/module.defs	2023-04-03 22:37:52.395467010 -0400
+@@ -46,11 +46,7 @@
+ LIBHB.GCC.I += $(LIBHB.build/) $(CONTRIB.build/)include
+ 
+ ifeq (1,$(FEATURE.qsv))
+-    ifeq ($(HOST.system),freebsd))
+-        LIBHB.GCC.I += $(LOCALBASE)/include/vpl
+-    else
+-        LIBHB.GCC.I += $(CONTRIB.build/)include/vpl
+-    endif
++    LIBHB.GCC.I += /usr/include/vpl
+ endif
+ 
+ ifneq (,$(filter $(HOST.system),freebsd netbsd openbsd))
diff --git a/srcpkgs/handbrake/template b/srcpkgs/handbrake/template
index ca5e4571e49c3..c32cb1bfa31f4 100644
--- a/srcpkgs/handbrake/template
+++ b/srcpkgs/handbrake/template
@@ -1,10 +1,10 @@
 # Template file for 'handbrake'
 pkgname=handbrake
-version=1.5.1
+version=1.6.1
 revision=1
 build_style=gnu-configure
 configure_args="--force --disable-gtk-update-checks --disable-df-fetch --harden
- $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc)"
+ $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc) $(vopt_enable qsv)"
 make_build_args="-C ${XBPS_TRIPLET}"
 make_install_args="-C ${XBPS_TRIPLET}"
 hostmakedepends="automake cmake gettext-devel glib-devel intltool libtool m4 meson nasm pkg-config python3"
@@ -12,8 +12,11 @@ makedepends="bzip2-devel ffmpeg-devel gst-plugins-base1-devel gtk+3-devel
  jansson-devel lame-devel libass-devel libbluray-devel libdav1d-devel
  libdvdnav-devel libdvdread-devel libgudev-devel libnuma-devel
  libsamplerate-devel libtheora-devel libvorbis-devel libvpx-devel libxml2-devel
- opus-devel speex-devel x264-devel x265-devel zimg-devel
+ opus-devel speex-devel x264-devel x265-devel zimg-devel libsvt-av1-devel
  $(vopt_if fdk_aac fdk-aac-devel)
+ $(vopt_if qsv libva-devel)
+ $(vopt_if qsv libdrm-devel)
+ $(vopt_if qsv onevpl-devel)
  $(vopt_if nvenc nv-codec-headers)"
 depends="desktop-file-utils gst-plugins-good1 hicolor-icon-theme"
 short_desc="Multithreaded video transcoder"
@@ -21,15 +24,15 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-2.0-only"
 homepage="https://handbrake.fr/"
 distfiles="https://github.com/HandBrake/HandBrake/releases/download/${version}/HandBrake-${version}-source.tar.bz2"
-checksum=3999fe06d5309c819799a73a968a8ec3840e7840c2b64af8f5cdb7fd8c9430f0
+checksum=94ccfe03db917a91650000c510f7fd53f844da19f19ad4b4be1b8f6bc31a8d4c
 nocross=yes
 
-build_options="fdk_aac nvenc"
+build_options="fdk_aac nvenc qsv"
 
 case "$XBPS_TARGET_MACHINE" in
 	x86_64*|i686*)
 		CFLAGS="-msse"
-		build_options_default="nvenc"
+		build_options_default="nvenc qsv"
 		;;
 esac
 
@@ -37,7 +40,7 @@ pre_configure() {
 	# use system libraries, don't download them
 	rm -rf contrib/
 	for module in fdk-aac ffmpeg libbluray libdav1d libdvdnav libdvdread nvenc \
-		x265 zimg; do
+		x265 zimg svt-av1 libvpl; do
 	    vsed -i "/MODULES += contrib\/${module}/d" make/include/main.defs
 	done
 }

From 0c8731810543a11f2e4b01ad5ec5651e08cd2169 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 043/115] hedgewars: revbump for ffmpeg4-4.4.3

---
 srcpkgs/hedgewars/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/hedgewars/template b/srcpkgs/hedgewars/template
index 15a1df6d8861d..d1b7290bfdc19 100644
--- a/srcpkgs/hedgewars/template
+++ b/srcpkgs/hedgewars/template
@@ -1,13 +1,13 @@
 # Template file for 'hedgewars'
 pkgname=hedgewars
 version=1.0.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DNOSERVER=1 -DDATA_INSTALL_DIR=/usr/share/${pkgname}
  -DPHYSFS_SYSTEM=1 -DMINIMAL_FLAGS=1"
 make_cmd=make
 hostmakedepends="lua51 pkg-config qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
+makedepends="ffmpeg4-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
  SDL2_mixer-devel SDL2_net-devel SDL2_ttf-devel"
 depends="libfreeglut"
 short_desc="Funny turn-based artillery game, featuring fighting Hedgehogs!"

From d39132d458bd5af58ff6f122d9492709cb713737 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 044/115] idjc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/idjc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/idjc/template b/srcpkgs/idjc/template
index b205e74745fe1..36a75baf597c5 100644
--- a/srcpkgs/idjc/template
+++ b/srcpkgs/idjc/template
@@ -5,7 +5,7 @@ revision=4
 build_style=gnu-configure
 hostmakedepends="pkg-config git python3 automake gettext-devel libtool"
 makedepends="libvorbis-devel libogg-devel jack-devel libsamplerate-devel
- libflac-devel libsndfile-devel mpg123-devel ffmpeg-devel speex-devel
+ libflac-devel libsndfile-devel mpg123-devel ffmpeg4-devel speex-devel
  glib-devel pixman-devel lame-devel python3-gobject-devel libshout-idjc-devel
  opus-devel twolame-devel python3-mutagen python3-devel"
 depends="python3-gobject python3-mutagen desktop-file-utils shared-mime-info python3-dbus jack"

From 43fdf4b987eaff7e9217c43fd4cb95993f5fde82 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 045/115] kfilemetadata5: revbump for ffmpeg-6.0

---
 srcpkgs/kfilemetadata5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kfilemetadata5/template b/srcpkgs/kfilemetadata5/template
index 00f7a98cf6399..e294ae5af947c 100644
--- a/srcpkgs/kfilemetadata5/template
+++ b/srcpkgs/kfilemetadata5/template
@@ -1,7 +1,7 @@
 # Template file for 'kfilemetadata5'
 pkgname=kfilemetadata5
 version=5.111.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="kcoreaddons extra-cmake-modules pkg-config qt5-host-tools qt5-qmake
  gettext kcoreaddons python3"

From 9d3e3b335e65ffdc3d78d31998009ab30b5b4c87 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 046/115] kid3: revbump for ffmpeg-6.0

---
 srcpkgs/kid3/patches/ffmpeg5.patch | 17 +++++++++++++++++
 srcpkgs/kid3/template              |  2 +-
 2 files changed, 18 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/kid3/patches/ffmpeg5.patch

diff --git a/srcpkgs/kid3/patches/ffmpeg5.patch b/srcpkgs/kid3/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..135fc50e07c9b
--- /dev/null
+++ b/srcpkgs/kid3/patches/ffmpeg5.patch
@@ -0,0 +1,17 @@
+# https://aur.archlinux.org/cgit/aur.git/diff/ffmpeg5.patch?h=kid3-cli&id=12410a74906612e7efc0ec8fbce739b4a0fef7e7
+diff --git a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+index e156d424..e12b9abd 100644
+--- a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
++++ b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+@@ -232,7 +232,11 @@ private:
+   friend class Format;
+   friend class Converter;
+   AVCodecContext* m_ptr;
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 0, 0)
+   AVCodec* m_impl;
++#else
++  const AVCodec* m_impl;
++#endif
+   AVFrame* m_frame;
+   bool m_opened;
+ };
diff --git a/srcpkgs/kid3/template b/srcpkgs/kid3/template
index 456206d90e16a..f32f9decb0e7f 100644
--- a/srcpkgs/kid3/template
+++ b/srcpkgs/kid3/template
@@ -1,7 +1,7 @@
 # Template file for 'kid3'
 pkgname=kid3
 version=3.9.1
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DWITH_APPS='CLI;$(vopt_if KDE KDE Qt)'
  -DWITH_DOCBOOKDIR=/usr/share/xsl/docbook -DWITH_FLAC=$(vopt_if flac ON OFF)

From 5b32653fa304f5815201484462d76272551c0a4f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 047/115] kodi: revbump for ffmpeg4-4.4.3

---
 srcpkgs/kodi/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kodi/template b/srcpkgs/kodi/template
index 8ef6bc85ed3b4..788a0ac978af8 100644
--- a/srcpkgs/kodi/template
+++ b/srcpkgs/kodi/template
@@ -54,7 +54,7 @@ makedepends="
  libmad-devel fontconfig-devel libXinerama-devel libsamplerate-devel libmms-devel
  enca-devel boost-devel libcurl-devel libva-devel libvdpau-devel libass-devel
  libbluetooth-devel yajl-devel libplist-devel librtmp-devel tinyxml-devel
- taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg-devel
+ taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg4-devel
  giflib-devel libxslt-devel gnutls-devel libssh-devel libmicrohttpd-devel
  libcec-devel dcadec-devel flatbuffers-devel fmt-devel lcms2-devel
  libfstrcmp-devel rapidjson libcdio-paranoia spdlog libwaylandpp-devel

From 1ea8ba5885a59640fad946c7b5c56b31b19b0276 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 048/115] kpipewire: revbump for ffmpeg-6.0

---
 srcpkgs/kpipewire/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kpipewire/template b/srcpkgs/kpipewire/template
index b2d3d80c1dd1a..981c7b8890ded 100644
--- a/srcpkgs/kpipewire/template
+++ b/srcpkgs/kpipewire/template
@@ -1,7 +1,7 @@
 # Template file for 'kpipewire'
 pkgname=kpipewire
 version=5.27.9
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules plasma-wayland-protocols gettext
  qt5-qmake qt5-host-tools pkg-config wayland-devel kcoreaddons

From 0c81eda3fd26fd498092a2dce91152469d41797d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 049/115] libextractor: revbump for ffmpeg4-4.4.3

---
 srcpkgs/libextractor/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libextractor/template b/srcpkgs/libextractor/template
index ddd4790f93e88..1fb9ca56a96ae 100644
--- a/srcpkgs/libextractor/template
+++ b/srcpkgs/libextractor/template
@@ -7,7 +7,7 @@ configure_args="--disable-static"
 hostmakedepends="pkg-config"
 makedepends="zlib-devel bzip2-devel exiv2-devel tiff-devel libpng-devel
  libjpeg-turbo-devel libvorbis-devel libflac-devel giflib-devel libmpeg2-devel
- ffmpeg-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
+ ffmpeg4-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
 short_desc="Library used to extract meta data from files"
 maintainer="Martin Riese <grauehaare@gmx.de>"
 license="GPL-3.0-or-later"

From e338ac48f649d2b37903d5d144b9519f28dc8eba Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 050/115] libopenal: revbump for ffmpeg-6.0

---
 srcpkgs/libopenal/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenal/template b/srcpkgs/libopenal/template
index 77218f9e539df..3f49ed75a1fdc 100644
--- a/srcpkgs/libopenal/template
+++ b/srcpkgs/libopenal/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenal'
 pkgname=libopenal
 version=1.22.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DALSOFT_EXAMPLES=OFF"
 hostmakedepends="pkg-config"

From 4cbdf3b8830a6c630bcff7ccce273ef9e029844a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 051/115] loudgain: revbump for ffmpeg-6.0

---
 srcpkgs/loudgain/patches/ffmpeg5.patch | 11 +++++++++++
 srcpkgs/loudgain/template              |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/loudgain/patches/ffmpeg5.patch

diff --git a/srcpkgs/loudgain/patches/ffmpeg5.patch b/srcpkgs/loudgain/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..16d4510ee98fa
--- /dev/null
+++ b/srcpkgs/loudgain/patches/ffmpeg5.patch
@@ -0,0 +1,11 @@
+--- a/src/scan.c	2019-09-06 11:31:19.000000000 -0400
++++ b/src/scan.c	2023-03-23 11:15:40.867968521 -0400
+@@ -69,8 +69,6 @@
+ 	 * It is now useless
+ 	 * https://github.com/FFmpeg/FFmpeg/blob/70d25268c21cbee5f08304da95be1f647c630c15/doc/APIchanges#L86
+ 	 */
+-  if (avformat_version() < AV_VERSION_INT(58,9,100))
+-    av_register_all();
+ 
+ 	av_log_set_callback(scan_av_log);
+ 
diff --git a/srcpkgs/loudgain/template b/srcpkgs/loudgain/template
index da4f2d56e94c3..4d6bf29efb4fd 100644
--- a/srcpkgs/loudgain/template
+++ b/srcpkgs/loudgain/template
@@ -1,7 +1,7 @@
 # Template file for 'loudgain'
 pkgname=loudgain
 version=0.6.8
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libebur128-devel taglib-devel ffmpeg-devel"

From 7329b43aedf3e428dbb5b71254a99f8770104d03 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 052/115] mediastreamer: revbump for ffmpeg4-4.4.3

---
 srcpkgs/mediastreamer/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mediastreamer/template b/srcpkgs/mediastreamer/template
index 133fce9945b3a..0e0fdb0e1a014 100644
--- a/srcpkgs/mediastreamer/template
+++ b/srcpkgs/mediastreamer/template
@@ -5,7 +5,7 @@ revision=1
 build_style=cmake
 configure_args="-DENABLE_STRICT=0 -DENABLE_UNIT_TESTS=0"
 hostmakedepends="python3"
-makedepends="bzrtp-devel ffmpeg-devel glew-devel libXv-devel libsrtp-devel
+makedepends="bzrtp-devel ffmpeg4-devel glew-devel libXv-devel libsrtp-devel
  libupnp-devel libvpx-devel mbedtls-devel opus-devel ortp-devel pulseaudio-devel
  libtheora-devel speex-devel v4l-utils-devel bcg729-devel bcmatroska2-devel libgsm-devel
  zxing-cpp-devel"

From 34f5f45832c5d1fc0edabb3e762d13f602fd4036 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 053/115] mgba: revbump for ffmpeg-6.0

---
 srcpkgs/mgba/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mgba/template b/srcpkgs/mgba/template
index 5513e3fd16f3f..f5c87a4893002 100644
--- a/srcpkgs/mgba/template
+++ b/srcpkgs/mgba/template
@@ -1,7 +1,7 @@
 # Template file for 'mgba'
 pkgname=mgba
 version=0.10.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake desktop-file-utils"
 makedepends="SDL2-devel ffmpeg-devel libedit-devel libepoxy-devel libmagick-devel

From b6ef58c61b4ea90c49431319c1b8e0c80923a001 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 054/115] minidlna: revbump for ffmpeg-6.0

---
 srcpkgs/minidlna/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/minidlna/template b/srcpkgs/minidlna/template
index d551e49ed4653..5fa929f3a0c12 100644
--- a/srcpkgs/minidlna/template
+++ b/srcpkgs/minidlna/template
@@ -1,7 +1,7 @@
 # Template file for 'minidlna'
 pkgname=minidlna
 version=1.3.3
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="
  --sbindir=/usr/bin

From 5d47e327858a5509fc568a4fcf99db0e16c7764d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 055/115] mlt: revbump for ffmpeg4-4.4.3

---
 srcpkgs/mlt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mlt/template b/srcpkgs/mlt/template
index f14dd85d1c9dc..f0b3af193db2c 100644
--- a/srcpkgs/mlt/template
+++ b/srcpkgs/mlt/template
@@ -8,7 +8,7 @@ configure_args="--prefix=/usr --libdir=/usr/lib$XBPS_TARGET_WORDSIZE
  --swig-languages=python"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which"
 # XXX: movit vid.stab
-makedepends="alsa-lib-devel ffmpeg-devel gtk+-devel jack-devel ladspa-sdk
+makedepends="alsa-lib-devel ffmpeg4-devel gtk+-devel jack-devel ladspa-sdk
  libexif-devel libsamplerate-devel libxml2-devel sox-devel SDL_image-devel
  fftw-devel frei0r-plugins python3-devel pulseaudio-devel movit-devel
  libvidstab-devel"

From e49d18a30f85fcd5d797f4830e2140e6bdafb609 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 056/115] moc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/moc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/moc/template b/srcpkgs/moc/template
index 5aed5d36558d3..d8de816026b64 100644
--- a/srcpkgs/moc/template
+++ b/srcpkgs/moc/template
@@ -1,10 +1,10 @@
 # Template file for 'moc'
 pkgname=moc
 version=2.5.2
-revision=6
+revision=7
 build_style=gnu-configure
 hostmakedepends="pkg-config"
-makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg-devel
+makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg4-devel
  jack-devel alsa-lib-devel libltdl-devel libflac-devel libvorbis-devel
  libmad-devel libmpcdec-devel libmodplug-devel libid3tag-devel faad2-devel
  taglib-devel libsndfile-devel wavpack-devel speex-devel libsamplerate-devel

From 27bd6f8af797e2fb7289b5006742bfac9baa68cb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 057/115] motion: revbump for ffmpeg-6.0

---
 srcpkgs/motion/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/motion/template b/srcpkgs/motion/template
index 3cf3c3035c5b7..7dca12d851e33 100644
--- a/srcpkgs/motion/template
+++ b/srcpkgs/motion/template
@@ -1,7 +1,7 @@
 # Template file for 'motion'
 pkgname=motion
 version=4.5.1
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake pkg-config gettext-devel tar"
 makedepends="ffmpeg-devel libmicrohttpd-devel v4l-utils-devel gettext-devel"

From f60decea331fdec8fe15fbd85e06a98d24427097 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 058/115] notcurses: revbump for ffmpeg-6.0

---
 srcpkgs/notcurses/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/notcurses/template b/srcpkgs/notcurses/template
index 6dd8a091319f7..3110c30c9aff2 100644
--- a/srcpkgs/notcurses/template
+++ b/srcpkgs/notcurses/template
@@ -1,7 +1,7 @@
 # Template file for 'notcurses'
 pkgname=notcurses
 version=3.0.9
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DUSE_STATIC=ON $(vopt_bool man USE_PANDOC)"
 hostmakedepends="pkg-config $(vopt_if man pandoc)"

From cae8e2d6030c03f48b0a61609c4363bbe46a81aa Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 059/115] olive: revbump for ffmpeg4-4.4.3

---
 srcpkgs/olive/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/olive/template b/srcpkgs/olive/template
index 12a46936c9900..5c2917b9c5124 100644
--- a/srcpkgs/olive/template
+++ b/srcpkgs/olive/template
@@ -1,10 +1,10 @@
 # Template file for 'olive'
 pkgname=olive
 version=0.1.2
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools pkg-config"
-makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg-devel frei0r-plugins"
+makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg4-devel frei0r-plugins"
 short_desc="Non-linear video editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"

From a2a742826169fe3705068ba25b28aa87b3e7ed62 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 060/115] omxplayer: revbump for ffmpeg4-4.4.3

---
 srcpkgs/omxplayer/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/omxplayer/template b/srcpkgs/omxplayer/template
index 9a66690c83ebb..a21b878878037 100644
--- a/srcpkgs/omxplayer/template
+++ b/srcpkgs/omxplayer/template
@@ -1,7 +1,7 @@
 # Template file for 'omxplayer'
 pkgname=omxplayer
 version=20190102
-revision=2
+revision=3
 short_desc="Commandline OMX player for the Raspberry Pi"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
@@ -15,7 +15,7 @@ checksum=af2d9450f8947842ea8c401fe9f71eec444013ebbdee29f2ac828c9c493c1329
 archs="armv6l* armv7l*"
 build_style=gnu-makefile
 hostmakedepends="ruby-ronn pkg-config"
-makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg-devel dbus-devel"
+makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg4-devel dbus-devel"
 depends="freefont-ttf"
 
 do_build() {

From fdcaf54fecd39acbef4d8de7e15dfa380d06f67c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 061/115] opentoonz: revbump for ffmpeg-6.0

---
 srcpkgs/opentoonz/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/opentoonz/template b/srcpkgs/opentoonz/template
index ee9f7603f55fd..3e81834ca0edd 100644
--- a/srcpkgs/opentoonz/template
+++ b/srcpkgs/opentoonz/template
@@ -1,7 +1,7 @@
 # Template file for 'opentoonz'
 pkgname=opentoonz
 version=1.6.0
-revision=2
+revision=3
 build_wrksrc="toonz/sources"
 build_style=cmake
 make_cmd=make

From c019a60c00f0a9b4094b99aa9efacacdfcf9c47e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 062/115] pianobar: revbump for ffmpeg-6.0

---
 srcpkgs/pianobar/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pianobar/template b/srcpkgs/pianobar/template
index e3febb821a451..1e3dc1bf9308e 100644
--- a/srcpkgs/pianobar/template
+++ b/srcpkgs/pianobar/template
@@ -1,7 +1,7 @@
 # Template file for 'pianobar'
 pkgname=pianobar
 version=2022.04.01
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="V=1"
 hostmakedepends="pkg-config"

From 315689baab72df9cf008a1381cde22908da20a88 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 063/115] ppsspp: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ppsspp/template | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/ppsspp/template b/srcpkgs/ppsspp/template
index 2c0ded496eb98..1294ef3ae669c 100644
--- a/srcpkgs/ppsspp/template
+++ b/srcpkgs/ppsspp/template
@@ -1,7 +1,7 @@
 # Template file for 'ppsspp'
 pkgname=ppsspp
 version=1.16.6
-revision=1
+revision=2
 _glslang_commit=b34f619e1c85810dcb3c578107d2e48ba4ee2b37
 _SPIRV_Cross_commit=4212eef67ed0ca048cb726a6767185504e7695e5
 _armips_commit=7bd1ec93d4586985ba1ef420b43b5e620f68695e
@@ -15,7 +15,7 @@ configure_args="-DHEADLESS=1 -DUSE_SYSTEM_FFMPEG=1 -DUNITTEST=ON
  -DUSING_QT_UI=$(vopt_if qt ON OFF) -DUSE_SYSTEM_ZSTD=ON
  -DARMIPS_USE_STD_FILESYSTEM=ON"
 hostmakedepends="pkg-config python3 $(vopt_if qt qt5-host-tools)"
-makedepends="zlib-devel glew-devel ffmpeg-devel libzip-devel
+makedepends="zlib-devel glew-devel ffmpeg4-devel libzip-devel
  snappy-devel rapidjson libpng-devel libzstd-devel
  $(vopt_if sdl2 'SDL2_ttf-devel SDL2-devel') $(vopt_if wayland wayland-devel)
  $(vopt_if qt 'qt5-devel qt5-multimedia-devel')"
@@ -72,7 +72,7 @@ post_extract() {
         mv ${wrksrc}/rcheevos-${_rcheevos_commit} ${wrksrc}/ext/rcheevos
 }
 
-post_patch(){
+post_patch() {
 	# disable git versioning
 	vsed -e 's|find_package(Git)|# &|' -i git-version.cmake
 }
@@ -85,7 +85,6 @@ post_configure() {
 }
 
 do_install() {
-	vlicense LICENSE.TXT
 	vinstall icons/icon.svg 644 usr/share/pixmaps ppsspp.svg
 	vinstall Qt/PPSSPP.desktop 644 usr/share/applications
 	vbin build/PPSSPPHeadless ppsspp-headless

From 2d2203bb5b75e928c80006de21d214f60655268d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 064/115] pqiv: revbump for ffmpeg-6.0

---
 srcpkgs/pqiv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pqiv/template b/srcpkgs/pqiv/template
index 542fc27a2d32a..9308d949b6a1c 100644
--- a/srcpkgs/pqiv/template
+++ b/srcpkgs/pqiv/template
@@ -1,7 +1,7 @@
 # Template file for 'pqiv'
 pkgname=pqiv
 version=2.12
-revision=1
+revision=2
 build_style=gnu-makefile
 hostmakedepends="pkg-config"
 makedepends="glib-devel gtk+3-devel $(vopt_if ffmpeg ffmpeg-devel)

From 12d485513da8142e56bfe7b6e07eaa91aa2570b3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 065/115] qmmp: revbump for ffmpeg-6.0

---
 srcpkgs/qmmp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qmmp/template b/srcpkgs/qmmp/template
index 26c661ed16bea..a150d7441c7a6 100644
--- a/srcpkgs/qmmp/template
+++ b/srcpkgs/qmmp/template
@@ -1,7 +1,7 @@
 # Template file for 'qmmp'
 pkgname=qmmp
 version=1.6.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DUSE_HAL:BOOL=FALSE -DQMMP_DEFAULT_UI:STRING=simple"
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From 8e9d34321353a8deb2265b8ab7f1b835aeba7047 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 066/115] qt5-webengine: update to 5.15.13

---
 .../chromium-media-filters-cpp14.patch        |  11 ++
 srcpkgs/qt5-webengine/patches/ffmpeg5.patch   | 179 ++++++++++++++++++
 srcpkgs/qt5-webengine/template                |  10 +-
 3 files changed, 195 insertions(+), 5 deletions(-)
 create mode 100644 srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/ffmpeg5.patch

diff --git a/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
new file mode 100644
index 0000000000000..04adc540f2cbc
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
@@ -0,0 +1,11 @@
+--- a/src/3rdparty/chromium/media/filters/BUILD.gn	2023-02-27 13:32:59.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/BUILD.gn	2023-04-02 17:21:39.204066384 -0400
+@@ -96,6 +96,8 @@
+     "//ui/gfx/geometry:geometry",
+   ]
+ 
++  cflags_cc = [ "-std=c++14" ]
++
+   libs = []
+ 
+   if (proprietary_codecs) {
diff --git a/srcpkgs/qt5-webengine/patches/ffmpeg5.patch b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..ac55e1634423a
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
@@ -0,0 +1,179 @@
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:57.732547446 -0400
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:09.486478995 -0400
+@@ -57,6 +57,8 @@
+ 
+ namespace {
+ 
++constexpr int64_t kRelativeTsBase = static_cast<int64_t>(0x7ffeffffffffffff);
++
+ void SetAVStreamDiscard(AVStream* stream, AVDiscard discard) {
+   DCHECK(stream);
+   stream->discard = discard;
+@@ -90,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+   if (stream->start_time != kNoFFmpegTimestamp)
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (stream->first_dts != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, stream->first_dts);
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -408,11 +398,11 @@
+   scoped_refptr<DecoderBuffer> buffer;
+ 
+   if (type() == DemuxerStream::TEXT) {
+-    int id_size = 0;
++    size_t id_size = 0;
+     uint8_t* id_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
+ 
+-    int settings_size = 0;
++    size_t settings_size = 0;
+     uint8_t* settings_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
+ 
+@@ -424,7 +414,7 @@
+     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
+                                      side_data.data(), side_data.size());
+   } else {
+-    int side_data_size = 0;
++    size_t side_data_size = 0;
+     uint8_t* side_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
+ 
+@@ -485,7 +475,7 @@
+                                        packet->size - data_offset);
+     }
+ 
+-    int skip_samples_size = 0;
++    size_t skip_samples_size = 0;
+     const uint32_t* skip_samples_ptr =
+         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
+             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
+@@ -1587,6 +1577,8 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++      continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+       lowest_start_time_stream = stream.get();
+@@ -1604,6 +1596,8 @@
+     if (stream && stream->type() == DemuxerStream::VIDEO &&
+         stream->IsEnabled()) {
+       video_stream = stream.get();
++      if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++        continue;
+       if (video_stream->start_time() <= seek_time) {
+         return video_stream;
+       }
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h qtwebengine-5.15.10/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h
+--- a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-07-11 22:12:47.917192788 -0500
+@@ -29,6 +29,7 @@ extern "C" {
+ #include <libavformat/avformat.h>
+ #include <libavformat/avio.h>
+ #include <libavutil/avutil.h>
++#include <libavutil/channel_layout.h>
+ #include <libavutil/imgutils.h>
+ #include <libavutil/log.h>
+ #include <libavutil/mastering_display_metadata.h>
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/audio_file_reader.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/audio_file_reader.cc
+--- a/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -85,7 +85,7 @@ bool AudioFileReader::OpenDemuxer() {
+ }
+ 
+ bool AudioFileReader::OpenDecoder() {
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (codec) {
+     // MP3 decodes to S16P which we don't support, tell it to use S16 instead.
+     if (codec_context_->sample_fmt == AV_SAMPLE_FMT_S16P)
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -329,7 +329,7 @@ bool FFmpegAudioDecoder::ConfigureDecode
+     }
+   }
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec ||
+       avcodec_open2(codec_context_.get(), codec, &codec_options) < 0) {
+     DLOG(ERROR) << "Could not initialize audio decoder: "
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -59,7 +59,6 @@ static int64_t AVIOSeekOperation(void* o
+ }
+ 
+ void FFmpegGlue::InitializeFFmpeg() {
+-  av_register_all();
+ }
+ 
+ static void LogContainer(bool is_local_file,
+@@ -95,9 +94,6 @@ FFmpegGlue::FFmpegGlue(FFmpegURLProtocol
+   // Enable fast, but inaccurate seeks for MP3.
+   format_context_->flags |= AVFMT_FLAG_FAST_SEEK;
+ 
+-  // Ensures we can read out various metadata bits like vp8 alpha.
+-  format_context_->flags |= AVFMT_FLAG_KEEP_SIDE_DATA;
+-
+   // Ensures format parsing errors will bail out. From an audit on 11/2017, all
+   // instances were real failures. Solves bugs like http://crbug.com/710791.
+   format_context_->error_recognition |= AV_EF_EXPLODE;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -391,7 +391,7 @@ bool FFmpegVideoDecoder::ConfigureDecode
+   if (decode_nalus_)
+     codec_context_->flags2 |= AV_CODEC_FLAG2_CHUNKS;
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
+     ReleaseFFmpegResources();
+     return false;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/media_file_checker.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/media_file_checker.cc
+--- a/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -68,7 +68,7 @@ bool MediaFileChecker::Start(base::TimeD
+       auto context = AVStreamToAVCodecContext(format_context->streams[i]);
+       if (!context)
+         continue;
+-      AVCodec* codec = avcodec_find_decoder(cp->codec_id);
++      const AVCodec* codec = avcodec_find_decoder(cp->codec_id);
+       if (codec && avcodec_open2(context.get(), codec, nullptr) >= 0) {
+         auto loop = std::make_unique<FFmpegDecodingLoop>(context.get());
+         stream_contexts[i] = {std::move(context), std::move(loop)};
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc qtwebengine-5.15.10/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc
+--- a/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -203,7 +203,7 @@ int32_t H264DecoderImpl::InitDecode(cons
+   // a pointer |this|.
+   av_context_->opaque = this;
+ 
+-  AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
+   if (!codec) {
+     // This is an indication that FFmpeg has not been initialized or it has not
+     // been compiled/initialized with the correct set of codecs.
diff --git a/srcpkgs/qt5-webengine/template b/srcpkgs/qt5-webengine/template
index 84de5b12ecdda..b89fe4c1ad50a 100644
--- a/srcpkgs/qt5-webengine/template
+++ b/srcpkgs/qt5-webengine/template
@@ -1,9 +1,9 @@
 # Template file for 'qt5-webengine'
 pkgname=qt5-webengine
-version=5.15.11
-revision=5
+version=5.15.13
+revision=1
 _version="${version}-lts"
-_chromium_commit=be349eaf62e77955791d7bf29f893f1e8a37daf4
+_chromium_commit=e48df7803c7c98b0b2471c94057d32e44a301ad5
 archs="x86_64* i686* armv[67]* ppc64* aarch64*"
 create_wrksrc=yes
 build_style=qmake
@@ -32,8 +32,8 @@ license="GPL-3.0-or-later, LGPL-3.0-or-later"
 homepage="https://qt.io/"
 distfiles="https://github.com/qt/qtwebengine/archive/v${_version}.tar.gz
  https://github.com/qt/qtwebengine-chromium/archive/${_chromium_commit}.tar.gz"
-checksum="aa7466356c450c5f5870f979b93cd7e7e62da1165c328ffcab1a9928db18ad67
- 6f47ed8ab8cc062411f6f206da6353bc8263d6ed6d6290c689a05c01d91f646b"
+checksum="4b59838ed75ef788b59e1e412535a0e42dd9d311661fdeadb191b581ba815c63
+ a91686562b1d4e8b220e0bbcbab5feb64630e2de974b35ac034bf388af771a6c"
 
 no_generic_pkgconfig_link=yes
 build_options="sndio pipewire"

From 2d835303157d6327fe65a54bed7da950b643bcfe Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 067/115] qt5: update to 5.15.8

---
 ...erywhere-opensource-src-5.15.8-kf5-1.patch | 12913 ++++++++++++++++
 srcpkgs/qt5/template                          |    13 +-
 2 files changed, 12919 insertions(+), 7 deletions(-)
 create mode 100644 srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch

diff --git a/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch b/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch
new file mode 100644
index 0000000000000..966c98bcd3bb1
--- /dev/null
+++ b/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch
@@ -0,0 +1,12913 @@
+Submitted By:            Pierre Labastie <pierre_dot_labastie_at_neuf_dot_fr>
+Date:                    2023-01-05
+Initial Package Version: 5.15.8
+Upstream Status:         Applied (according to KDE)
+Origin:                  KDE patch set
+Description:             Patch set maintained by the KDE folks
+see https://dot.kde.org/2021/04/06/announcing-kdes-qt-5-patch-collection
+Patch generated using the procedure in
+https://wiki.linuxfromscratch.org/blfs/ticket/17476#comment:3
+
+Submodule qtbase 4ee4fc18..9cf586d6:
+diff --git a/qtbase/mkspecs/common/android/qplatformdefs.h b/qtbase/mkspecs/common/android/qplatformdefs.h
+index f75bc4093b..2bd59410d4 100644
+--- a/qtbase/mkspecs/common/android/qplatformdefs.h
++++ b/qtbase/mkspecs/common/android/qplatformdefs.h
+@@ -144,11 +144,7 @@
+ #define QT_SIGNAL_ARGS          int
+ #define QT_SIGNAL_IGNORE        SIG_IGN
+ 
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+ #define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+ 
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+diff --git a/qtbase/mkspecs/features/mac/sdk.mk b/qtbase/mkspecs/features/mac/sdk.mk
+index f30b5830b4..a32ceacb6c 100644
+--- a/qtbase/mkspecs/features/mac/sdk.mk
++++ b/qtbase/mkspecs/features/mac/sdk.mk
+@@ -1,6 +1,6 @@
+ 
+ ifeq ($(QT_MAC_SDK_NO_VERSION_CHECK),)
+-    CHECK_SDK_COMMAND = /usr/bin/xcrun --sdk $(EXPORT_QMAKE_MAC_SDK) -show-sdk-version 2>&1
++    CHECK_SDK_COMMAND = /usr/bin/xcrun --sdk $(EXPORT_QMAKE_MAC_SDK) -show-sdk-version 2>/dev/null
+     CURRENT_MAC_SDK_VERSION := $(shell DEVELOPER_DIR=$(EXPORT_QMAKE_XCODE_DEVELOPER_PATH) $(CHECK_SDK_COMMAND))
+     ifneq ($(CURRENT_MAC_SDK_VERSION),$(EXPORT_QMAKE_MAC_SDK_VERSION))
+         # We don't want to complain about out of date SDK unless the target needs to be remade.
+diff --git a/qtbase/mkspecs/linux-clang/qplatformdefs.h b/qtbase/mkspecs/linux-clang/qplatformdefs.h
+index a818d973f0..c1ab72fbc6 100644
+--- a/qtbase/mkspecs/linux-clang/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-clang/qplatformdefs.h
+@@ -79,14 +79,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-g++/qplatformdefs.h b/qtbase/mkspecs/linux-g++/qplatformdefs.h
+index 13523f0702..4d2750d9ec 100644
+--- a/qtbase/mkspecs/linux-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-g++/qplatformdefs.h
+@@ -79,14 +79,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ < 2)
+-#define QT_SOCKLEN_T            int
+-#else
+-#define QT_SOCKLEN_T            socklen_t
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-llvm/qplatformdefs.h b/qtbase/mkspecs/linux-llvm/qplatformdefs.h
+index dc750ab1ef..d3cc39b47f 100644
+--- a/qtbase/mkspecs/linux-llvm/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-llvm/qplatformdefs.h
+@@ -80,14 +80,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h b/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
+index 4c4e53da2a..83baffb3e3 100644
+--- a/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
+@@ -85,16 +85,9 @@
+ #include "../common/posix/qplatformdefs.h"
+ 
+ #undef QT_OPEN_LARGEFILE
+-#undef QT_SOCKLEN_T
+ 
+ #define QT_OPEN_LARGEFILE       0
+ 
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #ifndef SIOCGIFBRDADDR
+ #  define SIOCGIFBRDADDR 0x8919
+ #endif
+diff --git a/qtbase/mkspecs/lynxos-g++/qplatformdefs.h b/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
+index 4339ea2b23..6007af0055 100644
+--- a/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
+@@ -72,14 +72,6 @@
+ 
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp b/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
+index c3c184258f..32af3f8f29 100644
+--- a/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
++++ b/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
+@@ -10,6 +10,7 @@
+ #include "libANGLE/HandleAllocator.h"
+ 
+ #include <algorithm>
++#include <limits>
+ 
+ #include "common/debug.h"
+ 
+diff --git a/qtbase/src/3rdparty/forkfd/forkfd_linux.c b/qtbase/src/3rdparty/forkfd/forkfd_linux.c
+index ffe0e9a5e2..b1f5408d11 100644
+--- a/qtbase/src/3rdparty/forkfd/forkfd_linux.c
++++ b/qtbase/src/3rdparty/forkfd/forkfd_linux.c
+@@ -82,7 +82,8 @@ static int sys_clone(unsigned long cloneflags, int *ptid)
+     return syscall(__NR_clone, cloneflags, child_stack, stack_size, ptid, newtls, ctid);
+ #elif defined(__arc__) || defined(__arm__) || defined(__aarch64__) || defined(__mips__) || \
+     defined(__nds32__) || defined(__hppa__) || defined(__powerpc__) || defined(__i386__) || \
+-    defined(__x86_64__) || defined(__xtensa__) || defined(__alpha__) || defined(__riscv)
++    defined(__x86_64__) || defined(__xtensa__) || defined(__alpha__) || defined(__riscv) || \
++    defined(__loongarch__)
+     /* ctid and newtls are inverted on CONFIG_CLONE_BACKWARDS architectures,
+      * but since both values are 0, there's no harm. */
+     return syscall(__NR_clone, cloneflags, child_stack, ptid, ctid, newtls);
+diff --git a/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java b/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
+index 5792b5b2f5..2f74750fcf 100644
+--- a/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
++++ b/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
+@@ -116,6 +116,7 @@ public class QtNative
+     public static QtThread m_qtThread = new QtThread();
+     private static HashMap<String, Uri> m_cachedUris = new HashMap<String, Uri>();
+     private static ArrayList<String> m_knownDirs = new ArrayList<String>();
++    private static final String NoPermissionErrorMessage = "No permissions to open Uri";
+ 
+     private static final Runnable runPendingCppRunnablesRunnable = new Runnable() {
+         @Override
+@@ -193,11 +194,10 @@ public class QtNative
+                     return iterUri;
+             }
+ 
+-            // Android 6 and earlier could still manage to open the file so we can return the
+-            // parsed uri here
+-            if (Build.VERSION.SDK_INT < 24)
+-                return parsedUri;
+-            return null;
++            // if we only have transient permissions on uri all the above will fail,
++            // but we will be able to read the file anyway, so continue with uri here anyway
++            // and check for SecurityExceptions later
++            return parsedUri;
+         } catch (SecurityException e) {
+             e.printStackTrace();
+             return null;
+@@ -244,7 +244,7 @@ public class QtNative
+         int error = -1;
+ 
+         if (uri == null) {
+-            Log.e(QtTAG, "openFdForContentUrl(): No permissions to open Uri");
++            Log.e(QtTAG, "openFdForContentUrl(): " + NoPermissionErrorMessage);
+             return error;
+         }
+ 
+@@ -254,12 +254,13 @@ public class QtNative
+             return fdDesc.detachFd();
+         } catch (FileNotFoundException e) {
+             e.printStackTrace();
+-            return error;
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "openFdForContentUrl(): Invalid Uri");
+             e.printStackTrace();
+-            return error;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return error;
+     }
+ 
+     public static long getSize(Context context, String contentUrl)
+@@ -270,7 +271,7 @@ public class QtNative
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+ 
+         if (uri == null) {
+-            Log.e(QtTAG, "getSize(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return size;
+         } else if (!m_cachedUris.containsKey(contentUrl)) {
+             m_cachedUris.put(contentUrl, uri);
+@@ -288,12 +289,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "getSize(): Invalid Uri");
+             e.printStackTrace();
+-            return size;
+         }  catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "getSize(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return size;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return size;
+     }
+ 
+     public static boolean checkFileExists(Context context, String contentUrl)
+@@ -303,7 +305,7 @@ public class QtNative
+         if (uri == null)
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+         if (uri == null) {
+-            Log.e(QtTAG, "checkFileExists(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return exists;
+         } else {
+             if (!m_cachedUris.containsKey(contentUrl))
+@@ -321,12 +323,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "checkFileExists(): Invalid Uri");
+             e.printStackTrace();
+-            return exists;
+         } catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "checkFileExists(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return false;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return exists;
+     }
+ 
+     public static boolean checkIfWritable(Context context, String contentUrl)
+@@ -344,7 +347,7 @@ public class QtNative
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+         }
+         if (uri == null) {
+-            Log.e(QtTAG, "isDir(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return isDir;
+         } else {
+             if (!m_cachedUris.containsKey(contentUrl))
+@@ -374,12 +377,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "checkIfDir(): Invalid Uri");
+             e.printStackTrace();
+-            return false;
+         } catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "checkIfDir(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return false;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return false;
+     }
+     public static String[] listContentsFromTreeUri(Context context, String contentUrl)
+     {
+diff --git a/qtbase/src/concurrent/qtconcurrentreducekernel.h b/qtbase/src/concurrent/qtconcurrentreducekernel.h
+index 8f9a938952..a98dedef2e 100644
+--- a/qtbase/src/concurrent/qtconcurrentreducekernel.h
++++ b/qtbase/src/concurrent/qtconcurrentreducekernel.h
+@@ -212,11 +212,13 @@ public:
+ 
+     inline bool shouldThrottle()
+     {
++        std::lock_guard<QMutex> locker(mutex);
+         return (resultsMapSize > (ReduceQueueThrottleLimit * threadCount));
+     }
+ 
+     inline bool shouldStartThread()
+     {
++        std::lock_guard<QMutex> locker(mutex);
+         return (resultsMapSize <= (ReduceQueueStartLimit * threadCount));
+     }
+ };
+diff --git a/qtbase/src/concurrent/qtconcurrentthreadengine.cpp b/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
+index ea6ce3ac42..7f91a2ba68 100644
+--- a/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
++++ b/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
+@@ -176,6 +176,39 @@ void ThreadEngineBase::startSingleThreaded()
+     finish();
+ }
+ 
++void ThreadEngineBase::startBlocking()
++{
++    start();
++    barrier.acquire();
++    startThreads();
++
++    bool throttled = false;
++#ifndef QT_NO_EXCEPTIONS
++    try {
++#endif
++        while (threadFunction() == ThrottleThread) {
++            if (threadThrottleExit()) {
++                throttled = true;
++                break;
++            }
++        }
++#ifndef QT_NO_EXCEPTIONS
++    } catch (QException &e) {
++        handleException(e);
++    } catch (...) {
++        handleException(QUnhandledException());
++    }
++#endif
++
++    if (throttled == false) {
++        barrier.release();
++    }
++
++    barrier.wait();
++    finish();
++    exceptionStore.throwPossibleException();
++}
++
+ void ThreadEngineBase::startThread()
+ {
+     startThreadInternal();
+diff --git a/qtbase/src/concurrent/qtconcurrentthreadengine.h b/qtbase/src/concurrent/qtconcurrentthreadengine.h
+index 7c30cebdbc..a4c8548cc4 100644
+--- a/qtbase/src/concurrent/qtconcurrentthreadengine.h
++++ b/qtbase/src/concurrent/qtconcurrentthreadengine.h
+@@ -91,6 +91,7 @@ public:
+     ThreadEngineBase();
+     virtual ~ThreadEngineBase();
+     void startSingleThreaded();
++    void startBlocking();
+     void startThread();
+     bool isCanceled();
+     void waitForResume();
+@@ -143,6 +144,15 @@ public:
+         return result();
+     }
+ 
++    // Runs the user algorithm using multiple threads.
++    // This function blocks until the algorithm is finished,
++    // and then returns the result.
++    T *startBlocking()
++    {
++        ThreadEngineBase::startBlocking();
++        return result();
++    }
++
+     // Runs the user algorithm using multiple threads.
+     // Does not block, returns a future.
+     QFuture<T> startAsynchronously()
+@@ -223,6 +233,13 @@ class ThreadEngineStarter : public ThreadEngineStarterBase<T>
+ public:
+     ThreadEngineStarter(TypedThreadEngine *eng)
+         : Base(eng) { }
++
++    T startBlocking()
++    {
++        T t = *this->threadEngine->startBlocking();
++        delete this->threadEngine;
++        return t;
++    }
+ };
+ 
+ // Full template specialization where T is void.
+@@ -232,6 +249,12 @@ class ThreadEngineStarter<void> : public ThreadEngineStarterBase<void>
+ public:
+     ThreadEngineStarter(ThreadEngine<void> *_threadEngine)
+         : ThreadEngineStarterBase<void>(_threadEngine) {}
++
++    void startBlocking()
++    {
++        this->threadEngine->startBlocking();
++        delete this->threadEngine;
++    }
+ };
+ 
+ //! [qtconcurrentthreadengine-1]
+diff --git a/qtbase/src/corelib/animation/qvariantanimation.cpp b/qtbase/src/corelib/animation/qvariantanimation.cpp
+index 98b02f0202..eac1524107 100644
+--- a/qtbase/src/corelib/animation/qvariantanimation.cpp
++++ b/qtbase/src/corelib/animation/qvariantanimation.cpp
+@@ -276,7 +276,9 @@ void QVariantAnimationPrivate::setCurrentValueForProgress(const qreal progress)
+ 
+     const qreal startProgress = currentInterval.start.first;
+     const qreal endProgress = currentInterval.end.first;
+-    const qreal localProgress = (progress - startProgress) / (endProgress - startProgress);
++    const qreal localProgress =
++            qIsNull(progress - startProgress) ? 0.0 // avoid 0/0 below
++            /* else */                        : (progress - startProgress) / (endProgress - startProgress);
+ 
+     QVariant ret = q->interpolated(currentInterval.start.second,
+                                    currentInterval.end.second,
+diff --git a/qtbase/src/corelib/global/qnamespace.h b/qtbase/src/corelib/global/qnamespace.h
+index ad4150b317..bf19b1627b 100644
+--- a/qtbase/src/corelib/global/qnamespace.h
++++ b/qtbase/src/corelib/global/qnamespace.h
+@@ -1864,7 +1864,7 @@ public:
+     QT_Q_ENUM(TimerType)
+     QT_Q_ENUM(ScrollPhase)
+     QT_Q_ENUM(MouseEventSource)
+-    QT_Q_FLAG(MouseEventFlag)
++    QT_Q_FLAG(MouseEventFlags)
+     QT_Q_ENUM(ChecksumType)
+     QT_Q_ENUM(HighDpiScaleFactorRoundingPolicy)
+     QT_Q_ENUM(TabFocusBehavior)
+diff --git a/qtbase/src/corelib/global/qrandom.cpp b/qtbase/src/corelib/global/qrandom.cpp
+index 10672c1f92..25f87c7e6a 100644
+--- a/qtbase/src/corelib/global/qrandom.cpp
++++ b/qtbase/src/corelib/global/qrandom.cpp
+@@ -383,7 +383,6 @@ struct QRandomGenerator::SystemAndGlobalGenerators
+ 
+         constexpr SystemAndGlobalGenerators g = {};
+         Q_UNUSED(g);
+-        Q_STATIC_ASSERT(std::is_literal_type<SystemAndGlobalGenerators>::value);
+ #endif
+     }
+ 
+diff --git a/qtbase/src/corelib/io/qbuffer.cpp b/qtbase/src/corelib/io/qbuffer.cpp
+index 595fcd2724..032c0ddd4b 100644
+--- a/qtbase/src/corelib/io/qbuffer.cpp
++++ b/qtbase/src/corelib/io/qbuffer.cpp
+@@ -41,6 +41,8 @@
+ #include <QtCore/qmetaobject.h>
+ #include "private/qiodevice_p.h"
+ 
++#include <limits>
++
+ QT_BEGIN_NAMESPACE
+ 
+ /** QBufferPrivate **/
+@@ -366,7 +368,9 @@ qint64 QBuffer::size() const
+ bool QBuffer::seek(qint64 pos)
+ {
+     Q_D(QBuffer);
+-    if (pos > d->buf->size() && isWritable()) {
++    const auto oldBufSize = d->buf->size();
++    constexpr qint64 MaxSeekPos = (std::numeric_limits<decltype(oldBufSize)>::max)();
++    if (pos <= MaxSeekPos && pos > oldBufSize && isWritable()) {
+         if (seek(d->buf->size())) {
+             const qint64 gapSize = pos - d->buf->size();
+             if (write(QByteArray(gapSize, 0)) != gapSize) {
+@@ -377,7 +381,7 @@ bool QBuffer::seek(qint64 pos)
+             return false;
+         }
+     } else if (pos > d->buf->size() || pos < 0) {
+-        qWarning("QBuffer::seek: Invalid pos: %d", int(pos));
++        qWarning("QBuffer::seek: Invalid pos: %lld", pos);
+         return false;
+     }
+     return QIODevice::seek(pos);
+diff --git a/qtbase/src/corelib/io/qfilesystemengine_win.cpp b/qtbase/src/corelib/io/qfilesystemengine_win.cpp
+index 81d3a71986..c86ed1f9b0 100644
+--- a/qtbase/src/corelib/io/qfilesystemengine_win.cpp
++++ b/qtbase/src/corelib/io/qfilesystemengine_win.cpp
+@@ -664,14 +664,14 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry)
+     return QFileSystemEntry(ret, QFileSystemEntry::FromInternalPath());
+ }
+ 
+-#if defined(Q_CC_MINGW) && WINVER < 0x0602 //  Windows 8 onwards
++#if defined(Q_CC_MINGW) && WINVER < 0x0602 && _WIN32_WINNT < _WIN32_WINNT_WIN8 //  Windows 8 onwards
+ 
+ typedef struct _FILE_ID_INFO {
+     ULONGLONG VolumeSerialNumber;
+     FILE_ID_128 FileId;
+ } FILE_ID_INFO, *PFILE_ID_INFO;
+ 
+-#endif // if defined (Q_CC_MINGW) && WINVER < 0x0602
++#endif // if defined(Q_CC_MINGW) && WINVER < 0x0602 && _WIN32_WINNT < _WIN32_WINNT_WIN8
+ 
+ // File ID for Windows up to version 7 and FAT32 drives
+ static inline QByteArray fileId(HANDLE handle)
+diff --git a/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp b/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
+index 94d9d06bcb..27e0b13b0b 100644
+--- a/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
++++ b/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
+@@ -366,7 +366,9 @@ void QInotifyFileSystemWatcherEngine::readFromInotify()
+     // qDebug("QInotifyFileSystemWatcherEngine::readFromInotify");
+ 
+     int buffSize = 0;
+-    ioctl(inotifyFd, FIONREAD, (char *) &buffSize);
++    if (ioctl(inotifyFd, FIONREAD, (char *) &buffSize) == -1 || buffSize == 0)
++        return;
++
+     QVarLengthArray<char, 4096> buffer(buffSize);
+     buffSize = read(inotifyFd, buffer.data(), buffSize);
+     char *at = buffer.data();
+diff --git a/qtbase/src/corelib/io/qlockfile_win.cpp b/qtbase/src/corelib/io/qlockfile_win.cpp
+index 277f8d4230..38ecef5550 100644
+--- a/qtbase/src/corelib/io/qlockfile_win.cpp
++++ b/qtbase/src/corelib/io/qlockfile_win.cpp
+@@ -48,6 +48,8 @@
+ #include "QtCore/qdebug.h"
+ #include "QtCore/qthread.h"
+ 
++#include "private/qsystemlibrary_p.h"
++
+ QT_BEGIN_NAMESPACE
+ 
+ static inline bool fileExists(const wchar_t *fileName)
+@@ -150,7 +152,7 @@ QString QLockFilePrivate::processNameByPid(qint64 pid)
+ #if !defined(Q_OS_WINRT)
+     typedef DWORD (WINAPI *GetModuleFileNameExFunc)(HANDLE, HMODULE, LPTSTR, DWORD);
+ 
+-    HMODULE hPsapi = LoadLibraryA("psapi");
++    HMODULE hPsapi = QSystemLibrary::load(L"psapi");
+     if (!hPsapi)
+         return QString();
+     GetModuleFileNameExFunc qGetModuleFileNameEx = reinterpret_cast<GetModuleFileNameExFunc>(
+diff --git a/qtbase/src/corelib/io/qprocess_unix.cpp b/qtbase/src/corelib/io/qprocess_unix.cpp
+index 50390e57f5..15c8f30745 100644
+--- a/qtbase/src/corelib/io/qprocess_unix.cpp
++++ b/qtbase/src/corelib/io/qprocess_unix.cpp
+@@ -1,7 +1,7 @@
+ /****************************************************************************
+ **
+ ** Copyright (C) 2016 The Qt Company Ltd.
+-** Copyright (C) 2016 Intel Corporation.
++** Copyright (C) 2022 Intel Corporation.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtCore module of the Qt Toolkit.
+@@ -422,14 +422,15 @@ void QProcessPrivate::startProcess()
+     // Add the program name to the argument list.
+     argv[0] = nullptr;
+     if (!program.contains(QLatin1Char('/'))) {
++        // findExecutable() returns its argument if it's an absolute path,
++        // otherwise it searches $PATH; returns empty if not found (we handle
++        // that case much later)
+         const QString &exeFilePath = QStandardPaths::findExecutable(program);
+-        if (!exeFilePath.isEmpty()) {
+-            const QByteArray &tmp = QFile::encodeName(exeFilePath);
+-            argv[0] = ::strdup(tmp.constData());
+-        }
+-    }
+-    if (!argv[0])
++        const QByteArray &tmp = QFile::encodeName(exeFilePath);
++        argv[0] = ::strdup(tmp.constData());
++    } else {
+         argv[0] = ::strdup(encodedProgramName.constData());
++    }
+ 
+     // Add every argument to the list
+     for (int i = 0; i < arguments.count(); ++i)
+@@ -983,15 +984,16 @@ bool QProcessPrivate::startDetached(qint64 *pid)
+                 envp = _q_dupEnvironment(environment.d.constData()->vars, &envc);
+             }
+ 
+-            QByteArray tmp;
+             if (!program.contains(QLatin1Char('/'))) {
++                // findExecutable() returns its argument if it's an absolute path,
++                // otherwise it searches $PATH; returns empty if not found (we handle
++                // that case much later)
+                 const QString &exeFilePath = QStandardPaths::findExecutable(program);
+-                if (!exeFilePath.isEmpty())
+-                    tmp = QFile::encodeName(exeFilePath);
++                const QByteArray &tmp = QFile::encodeName(exeFilePath);
++                argv[0] = ::strdup(tmp.constData());
++            } else {
++                argv[0] = ::strdup(QFile::encodeName(program));
+             }
+-            if (tmp.isEmpty())
+-                tmp = QFile::encodeName(program);
+-            argv[0] = tmp.data();
+ 
+             if (envp)
+                 qt_safe_execve(argv[0], argv, envp);
+diff --git a/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp b/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
+index 3a79c502af..997a634e76 100644
+--- a/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
++++ b/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
+@@ -3196,9 +3196,8 @@ bool QAbstractItemModel::beginMoveColumns(const QModelIndex &sourceParent, int s
+     destinationChange.needsAdjust = destinationParent.isValid() && destinationParent.row() >= sourceLast && destinationParent.parent() == sourceParent;
+     d->changes.push(destinationChange);
+ 
+-    d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Horizontal);
+-
+     emit columnsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, QPrivateSignal());
++    d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Horizontal);
+     return true;
+ }
+ 
+@@ -3231,7 +3230,6 @@ void QAbstractItemModel::endMoveColumns()
+       adjustedSource = createIndex(adjustedSource.row(), adjustedSource.column() + numMoved, adjustedSource.internalPointer());
+ 
+     d->itemsMoved(adjustedSource, removeChange.first, removeChange.last, adjustedDestination, insertChange.first, Qt::Horizontal);
+-
+     emit columnsMoved(adjustedSource, removeChange.first, removeChange.last, adjustedDestination, insertChange.first, QPrivateSignal());
+ }
+ 
+diff --git a/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+index dc6379d9fb..c5e287ee84 100644
+--- a/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
++++ b/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+@@ -939,8 +939,9 @@ void QSortFilterProxyModelPrivate::insert_source_items(
+                 q->beginInsertColumns(proxy_parent, proxy_start, proxy_end);
+         }
+ 
+-        for (int i = 0; i < source_items.size(); ++i)
+-            proxy_to_source.insert(proxy_start + i, source_items.at(i));
++        // TODO: use the range QList::insert() overload once it is implemented (QTBUG-58633).
++        proxy_to_source.insert(proxy_start, source_items.size(), 0);
++        std::copy(source_items.cbegin(), source_items.cend(), proxy_to_source.begin() + proxy_start);
+ 
+         build_source_to_proxy_mapping(proxy_to_source, source_to_proxy);
+ 
+@@ -3123,8 +3124,9 @@ bool QSortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex &
+ 
+     if (d->filter_data.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();
+@@ -3133,9 +3135,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.hasMatch(key);
+ }
+diff --git a/qtbase/src/corelib/kernel/qcoreapplication.cpp b/qtbase/src/corelib/kernel/qcoreapplication.cpp
+index ca2864df83..132b2eae52 100644
+--- a/qtbase/src/corelib/kernel/qcoreapplication.cpp
++++ b/qtbase/src/corelib/kernel/qcoreapplication.cpp
+@@ -1157,7 +1157,7 @@ static bool doNotify(QObject *receiver, QEvent *event)
+ bool QCoreApplicationPrivate::sendThroughApplicationEventFilters(QObject *receiver, QEvent *event)
+ {
+     // We can't access the application event filters outside of the main thread (race conditions)
+-    Q_ASSERT(receiver->d_func()->threadData.loadRelaxed()->thread.loadAcquire() == mainThread());
++    Q_ASSERT(receiver->d_func()->threadData.loadAcquire()->thread.loadRelaxed() == mainThread());
+ 
+     if (extraData) {
+         // application event filters are only called for objects in the GUI thread
+diff --git a/qtbase/src/corelib/kernel/qobject.cpp b/qtbase/src/corelib/kernel/qobject.cpp
+index 1eb79138d9..36cd780ee1 100644
+--- a/qtbase/src/corelib/kernel/qobject.cpp
++++ b/qtbase/src/corelib/kernel/qobject.cpp
+@@ -1010,7 +1010,7 @@ QObject::~QObject()
+         emit destroyed(this);
+     }
+ 
+-    if (d->declarativeData) {
++    if (!d->isDeletingChildren && d->declarativeData) {
+         if (static_cast<QAbstractDeclarativeDataImpl*>(d->declarativeData)->ownedByQml1) {
+             if (QAbstractDeclarativeData::destroyed_qml1)
+                 QAbstractDeclarativeData::destroyed_qml1(d->declarativeData, this);
+@@ -1580,7 +1580,7 @@ void QObject::moveToThread(QThread *targetThread)
+ 
+     QThreadData *currentData = QThreadData::current();
+     QThreadData *targetData = targetThread ? QThreadData::get2(targetThread) : nullptr;
+-    QThreadData *thisThreadData = d->threadData.loadRelaxed();
++    QThreadData *thisThreadData = d->threadData.loadAcquire();
+     if (!thisThreadData->thread.loadAcquire() && currentData == targetData) {
+         // one exception to the rule: we allow moving objects with no thread affinity to the current thread
+         currentData = d->threadData;
+@@ -2620,7 +2620,7 @@ int QObject::receivers(const char *signal) const
+         if (!d->isSignalConnected(signal_index))
+             return receivers;
+ 
+-        if (d->declarativeData && QAbstractDeclarativeData::receivers) {
++        if (!d->isDeletingChildren && d->declarativeData && QAbstractDeclarativeData::receivers) {
+             receivers += QAbstractDeclarativeData::receivers(d->declarativeData, this,
+                                                              signal_index);
+         }
+diff --git a/qtbase/src/corelib/kernel/qobject_p.h b/qtbase/src/corelib/kernel/qobject_p.h
+index 0b827a52ca..13ffb88999 100644
+--- a/qtbase/src/corelib/kernel/qobject_p.h
++++ b/qtbase/src/corelib/kernel/qobject_p.h
+@@ -444,7 +444,7 @@ inline void QObjectPrivate::checkForIncompatibleLibraryVersion(int version) cons
+ 
+ inline bool QObjectPrivate::isDeclarativeSignalConnected(uint signal_index) const
+ {
+-    return declarativeData && QAbstractDeclarativeData::isSignalConnected
++    return !isDeletingChildren && declarativeData && QAbstractDeclarativeData::isSignalConnected
+             && QAbstractDeclarativeData::isSignalConnected(declarativeData, q_func(), signal_index);
+ }
+ 
+diff --git a/qtbase/src/corelib/kernel/qtranslator.cpp b/qtbase/src/corelib/kernel/qtranslator.cpp
+index 2812ffb7ea..bc0177c5ec 100644
+--- a/qtbase/src/corelib/kernel/qtranslator.cpp
++++ b/qtbase/src/corelib/kernel/qtranslator.cpp
+@@ -902,7 +902,7 @@ static QString getMessage(const uchar *m, const uchar *end, const char *context,
+             goto end;
+         case Tag_Translation: {
+             int len = read32(m);
+-            if (len % 1)
++            if (len & 1)
+                 return QString();
+             m += 4;
+             if (!numerus--) {
+diff --git a/qtbase/src/corelib/mimetypes/qmimedatabase.cpp b/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
+index 9de22cef33..ff868a3268 100644
+--- a/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
+@@ -389,20 +389,23 @@ QMimeType QMimeDatabasePrivate::mimeTypeForFileNameAndData(const QString &fileNa
+         // Disambiguate conflicting extensions (if magic matching found something)
+         if (candidateByData.isValid() && magicAccuracy > 0) {
+             const QString sniffedMime = candidateByData.name();
+-            // If the sniffedMime matches a glob match, use it
++            // If the sniffedMime matches a highest-weight glob match, use it
+             if (candidatesByName.m_matchingMimeTypes.contains(sniffedMime)) {
+                 *accuracyPtr = 100;
+                 return candidateByData;
+             }
+-            for (const QString &m : qAsConst(candidatesByName.m_matchingMimeTypes)) {
++            for (const QString &m : qAsConst(candidatesByName.m_allMatchingMimeTypes)) {
+                 if (inherits(m, sniffedMime)) {
+                     // We have magic + pattern pointing to this, so it's a pretty good match
+                     *accuracyPtr = 100;
+                     return mimeTypeForName(m);
+                 }
+             }
+-            *accuracyPtr = magicAccuracy;
+-            return candidateByData;
++            if (candidatesByName.m_allMatchingMimeTypes.isEmpty()) {
++                // No glob, use magic
++                *accuracyPtr = magicAccuracy;
++                return candidateByData;
++            }
+         }
+     }
+ 
+diff --git a/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp b/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
+index a81112d227..fa8f4c545d 100644
+--- a/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
+@@ -83,7 +83,10 @@ void QMimeGlobMatchResult::addMatch(const QString &mimeType, int weight, const Q
+     }
+     if (!m_matchingMimeTypes.contains(mimeType)) {
+         m_matchingMimeTypes.append(mimeType);
+-        m_allMatchingMimeTypes.append(mimeType);
++        if (replace)
++            m_allMatchingMimeTypes.prepend(mimeType); // highest-weight first
++        else
++            m_allMatchingMimeTypes.append(mimeType);
+         m_knownSuffixLength = knownSuffixLength;
+     }
+ }
+@@ -94,7 +97,7 @@ QMimeGlobPattern::PatternType QMimeGlobPattern::detectPatternType(const QString
+     if (!patternLength)
+         return OtherPattern;
+ 
+-    const bool starCount = pattern.count(QLatin1Char('*')) == 1;
++    const int starCount = pattern.count(QLatin1Char('*'));
+     const bool hasSquareBracket = pattern.indexOf(QLatin1Char('[')) != -1;
+     const bool hasQuestionMark = pattern.indexOf(QLatin1Char('?')) != -1;
+ 
+@@ -106,10 +109,10 @@ QMimeGlobPattern::PatternType QMimeGlobPattern::detectPatternType(const QString
+             // Patterns like "README*" (well this is currently the only one like that...)
+             if (pattern.at(patternLength - 1) == QLatin1Char('*'))
+                 return PrefixPattern;
+-        }
+-        // Names without any wildcards like "README"
+-        if (starCount == 0)
++        } else if (starCount == 0) {
++            // Names without any wildcards like "README"
+             return LiteralPattern;
++        }
+     }
+ 
+     if (pattern == QLatin1String("[0-9][0-9][0-9].vdr"))
+diff --git a/qtbase/src/corelib/mimetypes/qmimeprovider.cpp b/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
+index 258dddf8cb..4642d0f2d0 100644
+--- a/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
+@@ -244,15 +244,18 @@ void QMimeBinaryProvider::addFileNameMatches(const QString &fileName, QMimeGlobM
+     const QString lowerFileName = fileName.toLower();
+     // Check literals (e.g. "Makefile")
+     matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosLiteralListOffset), fileName);
+-    // Check complex globs (e.g. "callgrind.out[0-9]*")
+-    matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosGlobListOffset), fileName);
+     // Check the very common *.txt cases with the suffix tree
+-    const int reverseSuffixTreeOffset = m_cacheFile->getUint32(PosReverseSuffixTreeOffset);
+-    const int numRoots = m_cacheFile->getUint32(reverseSuffixTreeOffset);
+-    const int firstRootOffset = m_cacheFile->getUint32(reverseSuffixTreeOffset + 4);
+-    matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, lowerFileName, lowerFileName.length() - 1, false);
++    if (result.m_matchingMimeTypes.isEmpty()) {
++        const int reverseSuffixTreeOffset = m_cacheFile->getUint32(PosReverseSuffixTreeOffset);
++        const int numRoots = m_cacheFile->getUint32(reverseSuffixTreeOffset);
++        const int firstRootOffset = m_cacheFile->getUint32(reverseSuffixTreeOffset + 4);
++        matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, lowerFileName, lowerFileName.length() - 1, false);
++        if (result.m_matchingMimeTypes.isEmpty())
++            matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, fileName, fileName.length() - 1, true);
++    }
++    // Check complex globs (e.g. "callgrind.out[0-9]*" or "README*")
+     if (result.m_matchingMimeTypes.isEmpty())
+-        matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, fileName, fileName.length() - 1, true);
++        matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosGlobListOffset), fileName);
+ }
+ 
+ void QMimeBinaryProvider::matchGlobList(QMimeGlobMatchResult &result, CacheFile *cacheFile, int off, const QString &fileName)
+diff --git a/qtbase/src/corelib/serialization/qjsonparser.cpp b/qtbase/src/corelib/serialization/qjsonparser.cpp
+index 17e6f111ab..2e40b6c8fb 100644
+--- a/qtbase/src/corelib/serialization/qjsonparser.cpp
++++ b/qtbase/src/corelib/serialization/qjsonparser.cpp
+@@ -379,10 +379,30 @@ error:
+     return QCborValue();
+ }
+ 
++// We need to retain the _last_ value for any duplicate keys and we need to deref containers.
++// Therefore the manual implementation of std::unique().
++template<typename Iterator, typename Compare, typename Assign>
++static Iterator customAssigningUniqueLast(Iterator first, Iterator last,
++                                          Compare compare, Assign assign)
++{
++    first = std::adjacent_find(first, last, compare);
++    if (first == last)
++        return last;
++
++    Iterator result = first;
++    while (++first != last) {
++        if (!compare(*result, *first))
++            ++result;
++        if (result != first)
++            assign(*result, *first);
++    }
++
++    return ++result;
++}
++
+ static void sortContainer(QCborContainerPrivate *container)
+ {
+     using Forward = QJsonPrivate::KeyIterator;
+-    using Reverse = std::reverse_iterator<Forward>;
+     using Value = Forward::value_type;
+ 
+     auto compare = [container](const Value &a, const Value &b)
+@@ -420,17 +440,31 @@ static void sortContainer(QCborContainerPrivate *container)
+         }
+     };
+ 
+-    std::sort(Forward(container->elements.begin()), Forward(container->elements.end()),
+-              [&compare](const Value &a, const Value &b) { return compare(a, b) < 0; });
++    // The elements' containers are owned by the outer container, not by the elements themselves.
++    auto move = [](Forward::reference target, Forward::reference source)
++    {
++        QtCbor::Element &targetValue = target.value();
++
++        // If the target has a container, deref it before overwriting, so that we don't leak.
++        if (targetValue.flags & QtCbor::Element::IsContainer)
++            targetValue.container->deref();
++
++        // Do not move, so that we can clear the value afterwards.
++        target = source;
++
++        // Clear the source value, so that we don't store the same container twice.
++        source.value() = QtCbor::Element();
++    };
++
++    std::stable_sort(
++                Forward(container->elements.begin()), Forward(container->elements.end()),
++                [&compare](const Value &a, const Value &b) { return compare(a, b) < 0; });
+ 
+-    // We need to retain the _last_ value for any duplicate keys. Therefore the reverse dance here.
+-    auto it = std::unique(Reverse(container->elements.end()), Reverse(container->elements.begin()),
+-                          [&compare](const Value &a, const Value &b) {
+-        return compare(a, b) == 0;
+-    }).base().elementsIterator();
++    Forward result = customAssigningUniqueLast(
++                Forward(container->elements.begin()),  Forward(container->elements.end()),
++                [&compare](const Value &a, const Value &b) { return compare(a, b) == 0; }, move);
+ 
+-    // The erase from beginning is expensive but hopefully rare.
+-    container->elements.erase(container->elements.begin(), it);
++    container->elements.erase(result.elementsIterator(), container->elements.end());
+ }
+ 
+ 
+diff --git a/qtbase/src/corelib/serialization/qxmlstream.cpp b/qtbase/src/corelib/serialization/qxmlstream.cpp
+index b2f846544d..7cd457ba3a 100644
+--- a/qtbase/src/corelib/serialization/qxmlstream.cpp
++++ b/qtbase/src/corelib/serialization/qxmlstream.cpp
+@@ -980,7 +980,7 @@ inline uint QXmlStreamReaderPrivate::peekChar()
+ bool QXmlStreamReaderPrivate::scanUntil(const char *str, short tokenToInject)
+ {
+     int pos = textBuffer.size();
+-    int oldLineNumber = lineNumber;
++    const auto oldLineNumber = lineNumber;
+ 
+     uint c;
+     while ((c = getChar()) != StreamEOF) {
+diff --git a/qtbase/src/corelib/text/qstring.cpp b/qtbase/src/corelib/text/qstring.cpp
+index 3e88ab4859..8deeae47bb 100644
+--- a/qtbase/src/corelib/text/qstring.cpp
++++ b/qtbase/src/corelib/text/qstring.cpp
+@@ -12312,7 +12312,7 @@ static qsizetype qLastIndexOf(Haystack haystack0, qsizetype from,
+     const auto needle = needle0.data();
+     const auto *end = haystack;
+     haystack += from;
+-    const std::size_t sl_minus_1 = sl - 1;
++    const std::size_t sl_minus_1 = sl ? sl - 1 : 0;
+     const auto *n = needle + sl_minus_1;
+     const auto *h = haystack + sl_minus_1;
+     std::size_t hashNeedle = 0, hashHaystack = 0;
+diff --git a/qtbase/src/corelib/text/qstringiterator_p.h b/qtbase/src/corelib/text/qstringiterator_p.h
+index 219589b6e4..1d0c66cc78 100644
+--- a/qtbase/src/corelib/text/qstringiterator_p.h
++++ b/qtbase/src/corelib/text/qstringiterator_p.h
+@@ -61,6 +61,8 @@ class QStringIterator
+ {
+     QString::const_iterator i, pos, e;
+     Q_STATIC_ASSERT((std::is_same<QString::const_iterator, const QChar *>::value));
++    static bool less(const QChar *lhs, const QChar *rhs) noexcept
++    { return std::less<QString::const_iterator>{}(lhs, rhs); }
+ public:
+     explicit QStringIterator(QStringView string, qsizetype idx = 0)
+         : i(string.begin()),
+@@ -95,7 +97,8 @@ public:
+ 
+     inline void setPosition(QString::const_iterator position)
+     {
+-        Q_ASSERT_X(i <= position && position <= e, Q_FUNC_INFO, "position out of bounds");
++        Q_ASSERT_X(!less(position, i) && !less(e, position),
++                   Q_FUNC_INFO, "position out of bounds");
+         pos = position;
+     }
+ 
+@@ -103,7 +106,7 @@ public:
+ 
+     inline bool hasNext() const
+     {
+-        return pos < e;
++        return less(pos, e);
+     }
+ 
+     inline void advance()
+@@ -120,16 +123,20 @@ public:
+     {
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+-        if (Q_UNLIKELY((pos++)->isHighSurrogate()))
++        if (Q_UNLIKELY((pos++)->isHighSurrogate())) {
++            Q_ASSERT(hasNext() && pos->isLowSurrogate());
+             ++pos;
++        }
+     }
+ 
+     inline uint peekNextUnchecked() const
+     {
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+-        if (Q_UNLIKELY(pos->isHighSurrogate()))
++        if (Q_UNLIKELY(pos->isHighSurrogate())) {
++            Q_ASSERT(less(pos + 1, e) && pos[1].isLowSurrogate());
+             return QChar::surrogateToUcs4(pos[0], pos[1]);
++        }
+ 
+         return pos->unicode();
+     }
+@@ -155,8 +162,10 @@ public:
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+         const QChar cur = *pos++;
+-        if (Q_UNLIKELY(cur.isHighSurrogate()))
++        if (Q_UNLIKELY(cur.isHighSurrogate())) {
++            Q_ASSERT(hasNext() && pos->isLowSurrogate());
+             return QChar::surrogateToUcs4(cur, *pos++);
++        }
+         return cur.unicode();
+     }
+ 
+@@ -166,7 +175,7 @@ public:
+ 
+         const QChar uc = *pos++;
+         if (Q_UNLIKELY(uc.isSurrogate())) {
+-            if (Q_LIKELY(uc.isHighSurrogate() && pos < e && pos->isLowSurrogate()))
++            if (Q_LIKELY(uc.isHighSurrogate() && hasNext() && pos->isLowSurrogate()))
+                 return QChar::surrogateToUcs4(uc, *pos++);
+             return invalidAs;
+         }
+@@ -178,7 +187,7 @@ public:
+ 
+     inline bool hasPrevious() const
+     {
+-        return pos > i;
++        return less(i, pos);
+     }
+ 
+     inline void recede()
+@@ -196,16 +205,20 @@ public:
+     {
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+-        if (Q_UNLIKELY((--pos)->isLowSurrogate()))
++        if (Q_UNLIKELY((--pos)->isLowSurrogate())) {
++            Q_ASSERT(hasPrevious() && pos[-1].isHighSurrogate());
+             --pos;
++        }
+     }
+ 
+     inline uint peekPreviousUnchecked() const
+     {
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+-        if (Q_UNLIKELY(pos[-1].isLowSurrogate()))
++        if (Q_UNLIKELY(pos[-1].isLowSurrogate())) {
++            Q_ASSERT(less(i + 1, pos) && pos[-2].isHighSurrogate());
+             return QChar::surrogateToUcs4(pos[-2], pos[-1]);
++        }
+         return pos[-1].unicode();
+     }
+ 
+@@ -230,8 +243,10 @@ public:
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+         const QChar cur = *--pos;
+-        if (Q_UNLIKELY(cur.isLowSurrogate()))
++        if (Q_UNLIKELY(cur.isLowSurrogate())) {
++            Q_ASSERT(hasPrevious() && pos[-1].isHighSurrogate());
+             return QChar::surrogateToUcs4(*--pos, cur);
++        }
+         return cur.unicode();
+     }
+ 
+@@ -241,7 +256,7 @@ public:
+ 
+         const QChar uc = *--pos;
+         if (Q_UNLIKELY(uc.isSurrogate())) {
+-            if (Q_LIKELY(uc.isLowSurrogate() && pos > i && pos[-1].isHighSurrogate()))
++            if (Q_LIKELY(uc.isLowSurrogate() && hasPrevious() && pos[-1].isHighSurrogate()))
+                 return QChar::surrogateToUcs4(*--pos, uc);
+             return invalidAs;
+         }
+diff --git a/qtbase/src/corelib/thread/qfutex_p.h b/qtbase/src/corelib/thread/qfutex_p.h
+index f287b752d7..e294537787 100644
+--- a/qtbase/src/corelib/thread/qfutex_p.h
++++ b/qtbase/src/corelib/thread/qfutex_p.h
+@@ -52,6 +52,7 @@
+ //
+ 
+ #include <qglobal.h>
++#include <QtCore/qtsan_impl.h>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -106,16 +107,13 @@ namespace QtLinuxFutex {
+     inline int _q_futex(int *addr, int op, int val, quintptr val2 = 0,
+                         int *addr2 = nullptr, int val3 = 0) noexcept
+     {
+-        // A futex call ensures total ordering on the futex words
+-        // (in either success or failure of the call). Instruct TSAN accordingly,
+-        // as TSAN does not understand the futex(2) syscall.
+-        _q_tsan_release(addr, addr2);
++        QtTsan::futexRelease(addr, addr2);
+ 
+         // we use __NR_futex because some libcs (like Android's bionic) don't
+         // provide SYS_futex etc.
+         int result = syscall(__NR_futex, addr, op | FUTEX_PRIVATE_FLAG, val, val2, addr2, val3);
+ 
+-        _q_tsan_acquire(addr, addr2);
++        QtTsan::futexAcquire(addr, addr2);
+ 
+         return result;
+     }
+diff --git a/qtbase/src/corelib/thread/qmutex.cpp b/qtbase/src/corelib/thread/qmutex.cpp
+index 310d1cb14f..7097122d8e 100644
+--- a/qtbase/src/corelib/thread/qmutex.cpp
++++ b/qtbase/src/corelib/thread/qmutex.cpp
+@@ -152,6 +152,7 @@ public:
+ 
+ /*!
+     \enum QMutex::RecursionMode
++    \obsolete Use QRecursiveMutex to create a recursive mutex.
+ 
+     \value Recursive  In this mode, a thread can lock the same mutex
+                       multiple times and the mutex won't be unlocked
+@@ -173,6 +174,7 @@ public:
+ 
+ /*!
+     Constructs a new mutex. The mutex is created in an unlocked state.
++    \obsolete Use QRecursiveMutex to create a recursive mutex.
+ 
+     If \a mode is QMutex::Recursive, a thread can lock the same mutex
+     multiple times and the mutex won't be unlocked until a
+@@ -197,7 +199,7 @@ QMutex::QMutex(RecursionMode mode)
+ QMutex::~QMutex()
+ {
+     QMutexData *d = d_ptr.loadRelaxed();
+-    if (isRecursive()) {
++    if (QBasicMutex::isRecursive()) {
+         delete static_cast<QRecursiveMutexPrivate *>(d);
+     } else if (d) {
+ #ifndef QT_LINUX_FUTEX
+diff --git a/qtbase/src/corelib/thread/qmutex.h b/qtbase/src/corelib/thread/qmutex.h
+index 73c9e00663..1bae573a03 100644
+--- a/qtbase/src/corelib/thread/qmutex.h
++++ b/qtbase/src/corelib/thread/qmutex.h
+@@ -42,6 +42,7 @@
+ 
+ #include <QtCore/qglobal.h>
+ #include <QtCore/qatomic.h>
++#include <QtCore/qtsan_impl.h>
+ #include <new>
+ 
+ #if __has_include(<chrono>)
+@@ -77,19 +78,37 @@ public:
+ 
+     // BasicLockable concept
+     inline void lock() QT_MUTEX_LOCK_NOEXCEPT {
++        QtTsan::mutexPreLock(this, 0u);
++
+         if (!fastTryLock())
+             lockInternal();
++
++        QtTsan::mutexPostLock(this, 0u, 0);
+     }
+ 
+     // BasicLockable concept
+     inline void unlock() noexcept {
+         Q_ASSERT(d_ptr.loadRelaxed()); //mutex must be locked
++
++        QtTsan::mutexPreUnlock(this, 0u);
++
+         if (!fastTryUnlock())
+             unlockInternal();
++
++        QtTsan::mutexPostUnlock(this, 0u);
+     }
+ 
+     bool tryLock() noexcept {
+-        return fastTryLock();
++        unsigned tsanFlags = QtTsan::TryLock;
++        QtTsan::mutexPreLock(this, tsanFlags);
++
++        const bool success = fastTryLock();
++
++        if (!success)
++            tsanFlags |= QtTsan::TryLockFailed;
++        QtTsan::mutexPostLock(this, tsanFlags, 0);
++
++        return success;
+     }
+ 
+     // Lockable concept
+@@ -134,8 +153,16 @@ public:
+ #else
+     QMutex() { d_ptr.storeRelaxed(nullptr); }
+ #endif
++#if QT_DEPRECATED_SINCE(5,15)
+     enum RecursionMode { NonRecursive, Recursive };
++    QT_DEPRECATED_VERSION_X(5, 15, "Use QRecursiveMutex instead of a recursive QMutex")
+     explicit QMutex(RecursionMode mode);
++
++    QT_DEPRECATED_VERSION_X(5, 15, "Use QRecursiveMutex instead of a recursive QMutex")
++    bool isRecursive() const noexcept
++    { return QBasicMutex::isRecursive(); }
++#endif
++
+     ~QMutex();
+ 
+     // BasicLockable concept
+@@ -166,9 +193,6 @@ public:
+     }
+ #endif
+ 
+-    bool isRecursive() const noexcept
+-    { return QBasicMutex::isRecursive(); }
+-
+ private:
+     Q_DISABLE_COPY(QMutex)
+     friend class QMutexLocker;
+diff --git a/qtbase/src/corelib/thread/qreadwritelock.cpp b/qtbase/src/corelib/thread/qreadwritelock.cpp
+index 8c28507d5a..9dd8503116 100644
+--- a/qtbase/src/corelib/thread/qreadwritelock.cpp
++++ b/qtbase/src/corelib/thread/qreadwritelock.cpp
+@@ -155,7 +155,7 @@ QReadWriteLock::QReadWriteLock(RecursionMode recursionMode)
+ */
+ QReadWriteLock::~QReadWriteLock()
+ {
+-    auto d = d_ptr.loadRelaxed();
++    auto d = d_ptr.loadAcquire();
+     if (isUncontendedLocked(d)) {
+         qWarning("QReadWriteLock: destroying locked QReadWriteLock");
+         return;
+@@ -445,7 +445,7 @@ void QReadWriteLock::unlock()
+ /*! \internal  Helper for QWaitCondition::wait */
+ QReadWriteLock::StateForWaitCondition QReadWriteLock::stateForWaitCondition() const
+ {
+-    QReadWriteLockPrivate *d = d_ptr.loadRelaxed();
++    QReadWriteLockPrivate *d = d_ptr.loadAcquire();
+     switch (quintptr(d) & StateMask) {
+     case StateLockedForRead: return LockedForRead;
+     case StateLockedForWrite: return LockedForWrite;
+@@ -453,6 +453,7 @@ QReadWriteLock::StateForWaitCondition QReadWriteLock::stateForWaitCondition() co
+ 
+     if (!d)
+         return Unlocked;
++    const auto lock = qt_scoped_lock(d->mutex);
+     if (d->writerCount > 1)
+         return RecursivelyLocked;
+     else if (d->writerCount == 1)
+diff --git a/qtbase/src/corelib/thread/qsemaphore.cpp b/qtbase/src/corelib/thread/qsemaphore.cpp
+index 1d01fc1b28..3ecdee3747 100644
+--- a/qtbase/src/corelib/thread/qsemaphore.cpp
++++ b/qtbase/src/corelib/thread/qsemaphore.cpp
+@@ -354,7 +354,12 @@ void QSemaphore::release(int n)
+         quintptr nn = unsigned(n);
+         if (futexHasWaiterCount)
+             nn |= quint64(nn) << 32;    // token count replicated in high word
+-        quintptr prevValue = u.fetchAndAddRelease(nn);
++        quintptr prevValue = u.loadRelaxed();
++        quintptr newValue;
++        do { // loop just to ensure the operations are done atomically
++            newValue = prevValue + nn;
++            newValue &= (futexNeedsWakeAllBit - 1);
++        } while (!u.testAndSetRelease(prevValue, newValue, prevValue));
+         if (futexNeedsWake(prevValue)) {
+ #ifdef FUTEX_OP
+             if (futexHasWaiterCount) {
+@@ -376,7 +381,6 @@ void QSemaphore::release(int n)
+                 quint32 oparg = 0;
+                 quint32 cmp = FUTEX_OP_CMP_NE;
+                 quint32 cmparg = 0;
+-                u.fetchAndAndRelease(futexNeedsWakeAllBit - 1);
+                 futexWakeOp(*futexLow32(&u), n, INT_MAX, *futexHigh32(&u), FUTEX_OP(op, oparg, cmp, cmparg));
+                 return;
+             }
+@@ -388,7 +392,6 @@ 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(futexNeedsWakeAllBit - 1);
+             if (futexHasWaiterCount) {
+                 futexWakeAll(*futexLow32(&u));
+                 futexWakeAll(*futexHigh32(&u));
+diff --git a/qtbase/src/corelib/thread/qthread_p.h b/qtbase/src/corelib/thread/qthread_p.h
+index b2d1628e6e..f32f6f0460 100644
+--- a/qtbase/src/corelib/thread/qthread_p.h
++++ b/qtbase/src/corelib/thread/qthread_p.h
+@@ -174,7 +174,7 @@ public:
+     int returnCode;
+ 
+     uint stackSize;
+-    QThread::Priority priority;
++    std::underlying_type<QThread::Priority>::type priority;
+ 
+     static QThread *threadForId(int id);
+ 
+@@ -213,6 +213,13 @@ public:
+             QCoreApplication::instance()->postEvent(q_ptr, new QEvent(QEvent::Quit));
+         }
+     }
++
++#ifndef Q_OS_INTEGRITY
++private:
++    // Used in QThread(Private)::start to avoid racy access to QObject::objectName,
++    // unset afterwards. On INTEGRITY we set the thread name before starting it.
++    QString objectName;
++#endif
+ };
+ 
+ #else // QT_CONFIG(thread)
+diff --git a/qtbase/src/corelib/thread/qthread_unix.cpp b/qtbase/src/corelib/thread/qthread_unix.cpp
+index 56a8e0a038..610117a640 100644
+--- a/qtbase/src/corelib/thread/qthread_unix.cpp
++++ b/qtbase/src/corelib/thread/qthread_unix.cpp
+@@ -169,8 +169,7 @@ static void set_thread_data(QThreadData *data)
+ 
+ static void clear_thread_data()
+ {
+-    currentThreadData = nullptr;
+-    pthread_setspecific(current_thread_data_key, nullptr);
++    set_thread_data(nullptr);
+ }
+ 
+ template <typename T>
+@@ -296,7 +295,7 @@ void *QThreadPrivate::start(void *arg)
+             QMutexLocker locker(&thr->d_func()->mutex);
+ 
+             // do we need to reset the thread priority?
+-            if (int(thr->d_func()->priority) & ThreadPriorityResetFlag) {
++            if (thr->d_func()->priority & ThreadPriorityResetFlag) {
+                 thr->d_func()->setPriority(QThread::Priority(thr->d_func()->priority & ~ThreadPriorityResetFlag));
+             }
+ 
+@@ -316,10 +315,10 @@ void *QThreadPrivate::start(void *arg)
+             // Sets the name of the current thread. We can only do this
+             // when the thread is starting, as we don't have a cross
+             // platform way of setting the name of an arbitrary thread.
+-            if (Q_LIKELY(thr->objectName().isEmpty()))
++            if (Q_LIKELY(thr->d_func()->objectName.isEmpty()))
+                 setCurrentThreadName(thr->metaObject()->className());
+             else
+-                setCurrentThreadName(thr->objectName().toLocal8Bit());
++                setCurrentThreadName(std::exchange(thr->d_func()->objectName, {}).toLocal8Bit());
+         }
+ #endif
+ 
+@@ -671,7 +670,7 @@ void QThread::start(Priority priority)
+                 // could not set scheduling hints, fallback to inheriting them
+                 // we'll try again from inside the thread
+                 pthread_attr_setinheritsched(&attr, PTHREAD_INHERIT_SCHED);
+-                d->priority = Priority(priority | ThreadPriorityResetFlag);
++                d->priority = static_cast<std::underlying_type<QThread::Priority>::type>(priority) | ThreadPriorityResetFlag;
+             }
+             break;
+         }
+@@ -702,7 +701,10 @@ void QThread::start(Priority priority)
+         pthread_attr_setthreadname(&attr, metaObject()->className());
+     else
+         pthread_attr_setthreadname(&attr, objectName().toLocal8Bit());
++#else
++    d->objectName = objectName();
+ #endif
++
+     pthread_t threadId;
+     int code = pthread_create(&threadId, &attr, QThreadPrivate::start, this);
+     if (code == EPERM) {
+diff --git a/qtbase/src/corelib/thread/qthread_win.cpp b/qtbase/src/corelib/thread/qthread_win.cpp
+index bc70e3178a..4e76972498 100644
+--- a/qtbase/src/corelib/thread/qthread_win.cpp
++++ b/qtbase/src/corelib/thread/qthread_win.cpp
+@@ -394,10 +394,9 @@ unsigned int __stdcall QT_ENSURE_STACK_ALIGNED_FOR_SSE QThreadPrivate::start(voi
+ 
+ #if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) && !defined(Q_OS_WINRT)
+     // sets the name of the current thread.
+-    QByteArray objectName = thr->objectName().toLocal8Bit();
+-    qt_set_thread_name(HANDLE(-1),
+-                       objectName.isEmpty() ?
+-                       thr->metaObject()->className() : objectName.constData());
++    qt_set_thread_name(HANDLE(-1), thr->d_func()->objectName.isEmpty()
++                        ? thr->metaObject()->className()
++                        : std::exchange(thr->d_func()->objectName, {}).toLocal8Bit().constData());
+ #endif
+ 
+     emit thr->started(QThread::QPrivateSignal());
+@@ -503,6 +502,7 @@ void QThread::start(Priority priority)
+     if (d->running)
+         return;
+ 
++    d->objectName = objectName();
+     d->running = true;
+     d->finished = false;
+     d->exited = false;
+@@ -548,7 +548,7 @@ void QThread::start(Priority priority)
+ 
+     int prio;
+     d->priority = priority;
+-    switch (d->priority) {
++    switch (priority) {
+     case IdlePriority:
+         prio = THREAD_PRIORITY_IDLE;
+         break;
+@@ -686,7 +686,7 @@ void QThreadPrivate::setPriority(QThread::Priority threadPriority)
+ 
+     int prio;
+     priority = threadPriority;
+-    switch (priority) {
++    switch (threadPriority) {
+     case QThread::IdlePriority:
+         prio = THREAD_PRIORITY_IDLE;
+         break;
+diff --git a/qtbase/src/corelib/thread/qtsan_impl.h b/qtbase/src/corelib/thread/qtsan_impl.h
+new file mode 100644
+index 0000000000..580a738b91
+--- /dev/null
++++ b/qtbase/src/corelib/thread/qtsan_impl.h
+@@ -0,0 +1,115 @@
++/****************************************************************************
++**
++** Copyright (C) 2017 Intel Corporation.
++** Copyright (C) 2022 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
++** 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 QTSAN_IMPL_H
++#define QTSAN_IMPL_H
++
++#include <QtCore/qglobal.h>
++
++#if (__has_feature(thread_sanitizer) || defined(__SANITIZE_THREAD__)) && __has_include(<sanitizer/tsan_interface.h>)
++#  define QT_BUILDING_UNDER_TSAN
++#  include <sanitizer/tsan_interface.h>
++#endif
++
++QT_BEGIN_NAMESPACE
++
++namespace QtTsan {
++#ifdef QT_BUILDING_UNDER_TSAN
++inline void futexAcquire(void *addr, void *addr2 = nullptr)
++{
++    // A futex call ensures total ordering on the futex words
++    // (in either success or failure of the call). Instruct TSAN accordingly,
++    // as TSAN does not understand the futex(2) syscall (or equivalent).
++    ::__tsan_acquire(addr);
++    if (addr2)
++        ::__tsan_acquire(addr2);
++}
++
++inline void futexRelease(void *addr, void *addr2 = nullptr)
++{
++    if (addr2)
++        ::__tsan_release(addr2);
++    ::__tsan_release(addr);
++}
++
++inline void mutexPreLock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_pre_lock(addr, flags);
++}
++
++inline void mutexPostLock(void *addr, unsigned flags, int recursion)
++{
++    ::__tsan_mutex_post_lock(addr, flags, recursion);
++}
++
++inline void mutexPreUnlock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_pre_unlock(addr, flags);
++}
++
++inline void mutexPostUnlock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_post_unlock(addr, flags);
++}
++
++enum : unsigned {
++    MutexWriteReentrant = ::__tsan_mutex_write_reentrant,
++    TryLock = ::__tsan_mutex_try_lock,
++    TryLockFailed = ::__tsan_mutex_try_lock_failed,
++};
++#else
++inline void futexAcquire(void *, void * = nullptr) {}
++inline void futexRelease(void *, void * = nullptr) {}
++
++enum : unsigned {
++    MutexWriteReentrant,
++    TryLock,
++    TryLockFailed,
++};
++inline void mutexPreLock(void *, unsigned) {}
++inline void mutexPostLock(void *, unsigned, int) {}
++inline void mutexPreUnlock(void *, unsigned) {}
++inline void mutexPostUnlock(void *, unsigned) {}
++#endif // QT_BUILDING_UNDER_TSAN
++} // namespace QtTsan
++
++QT_END_NAMESPACE
++
++#endif // QTSAN_IMPL_H
+diff --git a/qtbase/src/corelib/thread/qwaitcondition_unix.cpp b/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
+index 88b058f410..0f1da4dc9b 100644
+--- a/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
++++ b/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
+@@ -213,7 +213,7 @@ bool QWaitCondition::wait(QMutex *mutex, QDeadlineTimer deadline)
+ {
+     if (! mutex)
+         return false;
+-    if (mutex->isRecursive()) {
++    if (static_cast<QBasicMutex *>(mutex)->isRecursive()) {
+         qWarning("QWaitCondition: cannot wait on recursive mutexes");
+         return false;
+     }
+diff --git a/qtbase/src/corelib/time/qdatetime.cpp b/qtbase/src/corelib/time/qdatetime.cpp
+index ec12569e3f..2c0b098079 100644
+--- a/qtbase/src/corelib/time/qdatetime.cpp
++++ b/qtbase/src/corelib/time/qdatetime.cpp
+@@ -43,6 +43,7 @@
+ #if QT_CONFIG(datetimeparser)
+ #include "private/qdatetimeparser_p.h"
+ #endif
++#include <private/qnumeric_p.h>
+ 
+ #include "qdatastream.h"
+ #include "qset.h"
+@@ -1429,9 +1430,11 @@ QDate QDate::addDays(qint64 ndays) const
+     if (isNull())
+         return QDate();
+ 
+-    // Due to limits on minJd() and maxJd() we know that any overflow
+-    // will be invalid and caught by fromJulianDay().
+-    return fromJulianDay(jd + ndays);
++    qint64 r;
++    if (Q_UNLIKELY(add_overflow(jd, ndays, &r)))
++        return QDate();
++    else
++        return fromJulianDay(r);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/corelib/time/qtimezone.cpp b/qtbase/src/corelib/time/qtimezone.cpp
+index 0309e43e52..3d451696a1 100644
+--- a/qtbase/src/corelib/time/qtimezone.cpp
++++ b/qtbase/src/corelib/time/qtimezone.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2013 John Layt <jlayt@kde.org>
++** Copyright (C) 2020 John Layt <jlayt@kde.org>
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtCore module of the Qt Toolkit.
+@@ -975,9 +975,15 @@ QList<QByteArray> QTimeZone::windowsIdToIanaIds(const QByteArray &windowsId,
+ }
+ 
+ #ifndef QT_NO_DATASTREAM
++// Invalid, as an IANA ID: too long, starts with - and has other invalid characters in it
++static inline QString invalidId() { return QStringLiteral("-No Time Zone Specified!"); }
++
+ QDataStream &operator<<(QDataStream &ds, const QTimeZone &tz)
+ {
+-    tz.d->serialize(ds);
++    if (tz.isValid())
++        tz.d->serialize(ds);
++    else
++        ds << invalidId();
+     return ds;
+ }
+ 
+@@ -985,7 +991,9 @@ QDataStream &operator>>(QDataStream &ds, QTimeZone &tz)
+ {
+     QString ianaId;
+     ds >> ianaId;
+-    if (ianaId == QLatin1String("OffsetFromUtc")) {
++    if (ianaId == invalidId()) {
++        tz = QTimeZone();
++    } else if (ianaId == QLatin1String("OffsetFromUtc")) {
+         int utcOffset;
+         QString name;
+         QString abbreviation;
+diff --git a/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp b/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
+index b1611d7ddb..a7a6a72ccf 100644
+--- a/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
++++ b/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
+@@ -42,6 +42,7 @@
+ #include "qtimezone.h"
+ #include "qtimezoneprivate_p.h"
+ #include "private/qlocale_tools_p.h"
++#include "private/qlocking_p.h"
+ 
+ #include <QtCore/QDataStream>
+ #include <QtCore/QDateTime>
+@@ -62,6 +63,10 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++#if QT_CONFIG(icu)
++static QBasicMutex s_icu_mutex;
++#endif
++
+ /*
+     Private
+ 
+@@ -670,6 +675,9 @@ QTzTimeZonePrivate::~QTzTimeZonePrivate()
+ 
+ QTzTimeZonePrivate *QTzTimeZonePrivate::clone() const
+ {
++#if QT_CONFIG(icu)
++    const auto lock = qt_scoped_lock(s_icu_mutex);
++#endif
+     return new QTzTimeZonePrivate(*this);
+ }
+ 
+@@ -913,12 +921,14 @@ QString QTzTimeZonePrivate::displayName(qint64 atMSecsSinceEpoch,
+                                         const QLocale &locale) const
+ {
+ #if QT_CONFIG(icu)
++    auto lock = qt_unique_lock(s_icu_mutex);
+     if (!m_icu)
+         m_icu = new QIcuTimeZonePrivate(m_id);
+     // TODO small risk may not match if tran times differ due to outdated files
+     // TODO Some valid TZ names are not valid ICU names, use translation table?
+     if (m_icu->isValid())
+         return m_icu->displayName(atMSecsSinceEpoch, nameType, locale);
++    lock.unlock();
+ #else
+     Q_UNUSED(nameType)
+     Q_UNUSED(locale)
+@@ -932,12 +942,14 @@ QString QTzTimeZonePrivate::displayName(QTimeZone::TimeType timeType,
+                                         const QLocale &locale) const
+ {
+ #if QT_CONFIG(icu)
++    auto lock = qt_unique_lock(s_icu_mutex);
+     if (!m_icu)
+         m_icu = new QIcuTimeZonePrivate(m_id);
+     // TODO small risk may not match if tran times differ due to outdated files
+     // TODO Some valid TZ names are not valid ICU names, use translation table?
+     if (m_icu->isValid())
+         return m_icu->displayName(timeType, nameType, locale);
++    lock.unlock();
+ #else
+     Q_UNUSED(timeType)
+     Q_UNUSED(nameType)
+diff --git a/qtbase/src/corelib/tools/qarraydata.h b/qtbase/src/corelib/tools/qarraydata.h
+index dcd95924c1..d01739e7e6 100644
+--- a/qtbase/src/corelib/tools/qarraydata.h
++++ b/qtbase/src/corelib/tools/qarraydata.h
+@@ -42,6 +42,7 @@
+ 
+ #include <QtCore/qrefcount.h>
+ #include <string.h>
++#include <cstdint>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -58,14 +59,14 @@ struct Q_CORE_EXPORT QArrayData
+     {
+         Q_ASSERT(size == 0
+                 || offset < 0 || size_t(offset) >= sizeof(QArrayData));
+-        return reinterpret_cast<char *>(this) + offset;
++        return reinterpret_cast<void *> (reinterpret_cast<uintptr_t>(this) + offset);
+     }
+ 
+     const void *data() const
+     {
+         Q_ASSERT(size == 0
+                 || offset < 0 || size_t(offset) >= sizeof(QArrayData));
+-        return reinterpret_cast<const char *>(this) + offset;
++        return reinterpret_cast<void *> (reinterpret_cast<uintptr_t>(this) + offset);
+     }
+ 
+     // This refers to array data mutability, not "header data" represented by
+diff --git a/qtbase/src/corelib/tools/qfreelist_p.h b/qtbase/src/corelib/tools/qfreelist_p.h
+index 5ba23b344b..9974102136 100644
+--- a/qtbase/src/corelib/tools/qfreelist_p.h
++++ b/qtbase/src/corelib/tools/qfreelist_p.h
+@@ -161,7 +161,7 @@ class QFreeList
+                 return i;
+             x -= size;
+         }
+-        Q_ASSERT(false);
++        Q_UNREACHABLE();
+         return -1;
+     }
+ 
+diff --git a/qtbase/src/corelib/tools/qversionnumber.h b/qtbase/src/corelib/tools/qversionnumber.h
+index d43b86ba51..2843f2b043 100644
+--- a/qtbase/src/corelib/tools/qversionnumber.h
++++ b/qtbase/src/corelib/tools/qversionnumber.h
+@@ -273,10 +273,10 @@ public:
+ 
+     Q_REQUIRED_RESULT Q_CORE_EXPORT QString toString() const;
+ #if QT_STRINGVIEW_LEVEL < 2
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(const QString &string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(const QString &string, int *suffixIndex = nullptr);
+ #endif
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QLatin1String string, int *suffixIndex = nullptr);
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QStringView string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(QLatin1String string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(QStringView string, int *suffixIndex = nullptr);
+ 
+ private:
+ #ifndef QT_NO_DATASTREAM
+diff --git a/qtbase/src/dbus/qdbusintegrator.cpp b/qtbase/src/dbus/qdbusintegrator.cpp
+index 5b66ce971b..28a3b0ffea 100644
+--- a/qtbase/src/dbus/qdbusintegrator.cpp
++++ b/qtbase/src/dbus/qdbusintegrator.cpp
+@@ -1135,7 +1135,13 @@ void QDBusConnectionPrivate::closeConnection()
+         }
+     }
+ 
+-    qDeleteAll(pendingCalls);
++    for (auto it = pendingCalls.begin(); it != pendingCalls.end(); ++it) {
++        auto call = *it;
++        if (!call->ref.deref()) {
++            delete call;
++        }
++    }
++    pendingCalls.clear();
+ 
+     // Disconnect all signals from signal hooks and from the object tree to
+     // avoid QObject::destroyed being sent to dbus daemon thread which has
+@@ -2584,6 +2590,11 @@ QDBusConnectionPrivate::findMetaObject(const QString &service, const QString &pa
+         if (mo)
+             return mo;
+     }
++    if (path.isEmpty()) {
++        error = QDBusError(QDBusError::InvalidObjectPath, QLatin1String("Object path cannot be empty"));
++        lastError = error;
++        return nullptr;
++    }
+ 
+     // introspect the target object
+     QDBusMessage msg = QDBusMessage::createMethodCall(service, path,
+diff --git a/qtbase/src/dbus/qdbusmetaobject.cpp b/qtbase/src/dbus/qdbusmetaobject.cpp
+index 5265568f42..7e9f0f1acc 100644
+--- a/qtbase/src/dbus/qdbusmetaobject.cpp
++++ b/qtbase/src/dbus/qdbusmetaobject.cpp
+@@ -210,6 +210,9 @@ QDBusMetaObjectGenerator::findType(const QByteArray &signature,
+         } else if (signature == "a{ss}") {
+             result.name = "QMap<QString,QString>";
+             type = qMetaTypeId<QMap<QString, QString> >();
++        } else if (signature == "aay") {
++            result.name = "QByteArrayList";
++            type = qMetaTypeId<QByteArrayList>();
+         } else {
+             result.name = "{D-Bus type \"" + signature + "\"}";
+             type = registerComplexDBusType(result.name);
+diff --git a/qtbase/src/gui/accessible/qaccessible.cpp b/qtbase/src/gui/accessible/qaccessible.cpp
+index d705bfccb5..0caf3c808c 100644
+--- a/qtbase/src/gui/accessible/qaccessible.cpp
++++ b/qtbase/src/gui/accessible/qaccessible.cpp
+@@ -54,6 +54,7 @@
+ #include <QtCore/qdebug.h>
+ #include <QtCore/qloggingcategory.h>
+ #include <QtCore/qmetaobject.h>
++#include <QtCore/private/qmetaobject_p.h>
+ #include <QtCore/qhash.h>
+ #include <private/qfactoryloader_p.h>
+ 
+@@ -681,6 +682,25 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
+     // Create a QAccessibleInterface for the object class. Start by the most
+     // derived class and walk up the class hierarchy.
+     const QMetaObject *mo = object->metaObject();
++    const auto *objectPriv = QObjectPrivate::get(object);
++    /*
++     We do not want to cache each and every QML metaobject (Button_QMLTYPE_124,
++     Button_QMLTYPE_125, etc.). Those dynamic metaobjects shouldn't have an
++     accessible interface in any case. Instead, we start the whole checking
++     with the first non-dynamic meta-object. To avoid potential regressions
++     in other areas of Qt that also use dynamic metaobjects, we only do this
++     for objects that are QML-related (approximated by checking whether they
++     have ddata set).
++    */
++    const bool qmlRelated = !objectPriv->isDeletingChildren &&
++                            objectPriv->declarativeData;
++    while (qmlRelated && mo) {
++        auto mop = QMetaObjectPrivate::get(mo);
++        if (!mop || !(mop->flags & DynamicMetaObject))
++            break;
++
++        mo = mo->superClass();
++    };
+     while (mo) {
+         const QString cn = QLatin1String(mo->className());
+ 
+@@ -696,14 +716,15 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
+         // Find a QAccessiblePlugin (factory) for the class name. If there's
+         // no entry in the cache try to create it using the plugin loader.
+         if (!qAccessiblePlugins()->contains(cn)) {
++            QAccessiblePlugin *factory = nullptr; // 0 means "no plugin found". This is cached as well.
+             const int index = loader()->indexOf(cn);
+-            if (index != -1) {
+-                QAccessiblePlugin *factory = qobject_cast<QAccessiblePlugin *>(loader()->instance(index));
+-                qAccessiblePlugins()->insert(cn, factory);
+-            }
++            if (index != -1)
++                factory = qobject_cast<QAccessiblePlugin *>(loader()->instance(index));
++            qAccessiblePlugins()->insert(cn, factory);
+         }
+ 
+         // At this point the cache should contain a valid factory pointer or 0:
++        Q_ASSERT(qAccessiblePlugins()->contains(cn));
+         QAccessiblePlugin *factory = qAccessiblePlugins()->value(cn);
+         if (factory) {
+             QAccessibleInterface *result = factory->create(cn, object);
+diff --git a/qtbase/src/gui/configure.json b/qtbase/src/gui/configure.json
+index 1f08795c57..12c95742d2 100644
+--- a/qtbase/src/gui/configure.json
++++ b/qtbase/src/gui/configure.json
+@@ -834,7 +834,8 @@
+                     "// embedded devices, are not intended to be used together with X. EGL support",
+                     "// has to be disabled in plugins like xcb in this case since the native display,",
+                     "// window and pixmap types will be different than what an X-based platform",
+-                    "// plugin would expect."
++                    "// plugin would expect.",
++                    "#define USE_X11"
+                 ],
+                 "include": [ "EGL/egl.h", "X11/Xlib.h" ],
+                 "main": [
+diff --git a/qtbase/src/gui/image/qbmphandler.cpp b/qtbase/src/gui/image/qbmphandler.cpp
+index 96f1e8cb1d..0e73bbbdb0 100644
+--- a/qtbase/src/gui/image/qbmphandler.cpp
++++ b/qtbase/src/gui/image/qbmphandler.cpp
+@@ -150,16 +150,42 @@ static QDataStream &operator<<(QDataStream &s, const BMP_INFOHDR &bi)
+     return s;
+ }
+ 
+-static int calc_shift(uint mask)
++static uint calc_shift(uint mask)
+ {
+-    int result = 0;
+-    while (mask && !(mask & 1)) {
++    uint result = 0;
++    while ((mask >= 0x100) || (!(mask & 1) && mask)) {
+         result++;
+         mask >>= 1;
+     }
+     return result;
+ }
+ 
++static uint calc_scale(uint low_mask)
++{
++    uint result = 8;
++    while (low_mask && result) {
++        result--;
++        low_mask >>= 1;
++    }
++    return result;
++}
++
++static inline uint apply_scale(uint value, uint scale)
++{
++    if (!(scale & 0x07)) // return immediately if scale == 8 or 0
++        return value;
++
++    uint filled = 8 - scale;
++    uint result = value << scale;
++
++    do {
++        result |= result >> filled;
++        filled <<= 1;
++    } while (filled < 8);
++
++    return result;
++}
++
+ static bool read_dib_fileheader(QDataStream &s, BMP_FILEHDR &bf)
+ {
+     // read BMP file header
+@@ -222,14 +248,14 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+     uint green_mask = 0;
+     uint blue_mask = 0;
+     uint alpha_mask = 0;
+-    int red_shift = 0;
+-    int green_shift = 0;
+-    int blue_shift = 0;
+-    int alpha_shift = 0;
+-    int red_scale = 0;
+-    int green_scale = 0;
+-    int blue_scale = 0;
+-    int alpha_scale = 0;
++    uint red_shift = 0;
++    uint green_shift = 0;
++    uint blue_shift = 0;
++    uint alpha_shift = 0;
++    uint red_scale = 0;
++    uint green_scale = 0;
++    uint blue_scale = 0;
++    uint alpha_scale = 0;
+ 
+     if (!d->isSequential())
+         d->seek(startpos + BMP_FILEHDR_SIZE + bi.biSize); // goto start of colormap or masks
+@@ -308,19 +334,19 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+         red_shift = calc_shift(red_mask);
+         if (((red_mask >> red_shift) + 1) == 0)
+             return false;
+-        red_scale = 256 / ((red_mask >> red_shift) + 1);
++        red_scale = calc_scale(red_mask >> red_shift);
+         green_shift = calc_shift(green_mask);
+         if (((green_mask >> green_shift) + 1) == 0)
+             return false;
+-        green_scale = 256 / ((green_mask >> green_shift) + 1);
++        green_scale = calc_scale(green_mask >> green_shift);
+         blue_shift = calc_shift(blue_mask);
+         if (((blue_mask >> blue_shift) + 1) == 0)
+             return false;
+-        blue_scale = 256 / ((blue_mask >> blue_shift) + 1);
++        blue_scale = calc_scale(blue_mask >> blue_shift);
+         alpha_shift = calc_shift(alpha_mask);
+         if (((alpha_mask >> alpha_shift) + 1) == 0)
+             return false;
+-        alpha_scale = 256 / ((alpha_mask >> alpha_shift) + 1);
++        alpha_scale = calc_scale(alpha_mask >> alpha_shift);
+     } else if (comp == BMP_RGB && (nbits == 24 || nbits == 32)) {
+         blue_mask = 0x000000ff;
+         green_mask = 0x0000ff00;
+@@ -328,17 +354,15 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+         blue_shift = 0;
+         green_shift = 8;
+         red_shift = 16;
+-        blue_scale = green_scale = red_scale = 1;
++        blue_scale = green_scale = red_scale = 0;
+     } else if (comp == BMP_RGB && nbits == 16) {
+         blue_mask = 0x001f;
+         green_mask = 0x03e0;
+         red_mask = 0x7c00;
+         blue_shift = 0;
+-        green_shift = 2;
+-        red_shift = 7;
+-        red_scale = 1;
+-        green_scale = 1;
+-        blue_scale = 8;
++        green_shift = 5;
++        red_shift = 10;
++        blue_scale = green_scale = red_scale = 3;
+     }
+ 
+ #if 0
+@@ -544,10 +568,10 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+                     c |= *(uchar*)(b+2)<<16;
+                 if (nbits > 24)
+                     c |= *(uchar*)(b+3)<<24;
+-                *p++ = qRgba(((c & red_mask) >> red_shift) * red_scale,
+-                                        ((c & green_mask) >> green_shift) * green_scale,
+-                                        ((c & blue_mask) >> blue_shift) * blue_scale,
+-                                        transp ? ((c & alpha_mask) >> alpha_shift) * alpha_scale : 0xff);
++                *p++ = qRgba(apply_scale((c & red_mask) >> red_shift, red_scale),
++                             apply_scale((c & green_mask) >> green_shift, green_scale),
++                             apply_scale((c & blue_mask) >> blue_shift, blue_scale),
++                             transp ? apply_scale((c & alpha_mask) >> alpha_shift, alpha_scale) : 0xff);
+                 b += nbits/8;
+             }
+         }
+diff --git a/qtbase/src/gui/image/qimage.cpp b/qtbase/src/gui/image/qimage.cpp
+index 7152ac1607..0df772564c 100644
+--- a/qtbase/src/gui/image/qimage.cpp
++++ b/qtbase/src/gui/image/qimage.cpp
+@@ -4694,6 +4694,8 @@ QImage QImage::smoothScaled(int w, int h) const {
+ static QImage rotated90(const QImage &image)
+ {
+     QImage out(image.height(), image.width(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+@@ -4722,6 +4724,8 @@ static QImage rotated180(const QImage &image)
+         return image.mirrored(true, true);
+ 
+     QImage out(image.width(), image.height(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+@@ -4734,6 +4738,8 @@ static QImage rotated180(const QImage &image)
+ static QImage rotated270(const QImage &image)
+ {
+     QImage out(image.height(), image.width(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+diff --git a/qtbase/src/gui/kernel/qcursor.cpp b/qtbase/src/gui/kernel/qcursor.cpp
+index d6ccaff8ed..455088241c 100644
+--- a/qtbase/src/gui/kernel/qcursor.cpp
++++ b/qtbase/src/gui/kernel/qcursor.cpp
+@@ -251,7 +251,8 @@ void QCursor::setPos(QScreen *screen, int x, int y)
+ {
+     if (screen) {
+         if (QPlatformCursor *cursor = screen->handle()->cursor()) {
+-            const QPoint devicePos = QHighDpi::toNativePixels(QPoint(x, y), screen);
++            const QPoint pos(x, y);
++            const QPoint devicePos = QHighDpi::toNativePixels(pos, screen->virtualSiblingAt(pos));
+             // Need to check, since some X servers generate null mouse move
+             // events, causing looping in applications which call setPos() on
+             // every mouse move event.
+diff --git a/qtbase/src/gui/kernel/qhighdpiscaling.cpp b/qtbase/src/gui/kernel/qhighdpiscaling.cpp
+index 9bbf2773a9..3ac4a4d8b6 100644
+--- a/qtbase/src/gui/kernel/qhighdpiscaling.cpp
++++ b/qtbase/src/gui/kernel/qhighdpiscaling.cpp
+@@ -580,9 +580,8 @@ void QHighDpiScaling::setScreenFactor(QScreen *screen, qreal factor)
+     else
+         qNamedScreenScaleFactors()->insert(name, factor);
+ 
+-    // hack to force re-evaluation of screen geometry
+     if (screen->handle())
+-        screen->d_func()->setPlatformScreen(screen->handle()); // updates geometries based on scale factor
++        screen->d_func()->updateLogicalDpi();
+ }
+ 
+ QPoint QHighDpiScaling::mapPositionToNative(const QPoint &pos, const QPlatformScreen *platformScreen)
+diff --git a/qtbase/src/gui/kernel/qkeysequence.cpp b/qtbase/src/gui/kernel/qkeysequence.cpp
+index a75b8ef920..4f2d294739 100644
+--- a/qtbase/src/gui/kernel/qkeysequence.cpp
++++ b/qtbase/src/gui/kernel/qkeysequence.cpp
+@@ -701,6 +701,10 @@ static const struct {
+     { Qt::Key_TouchpadToggle,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad Toggle") },
+     { Qt::Key_TouchpadOn,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad On") },
+     { Qt::Key_TouchpadOff,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad Off") },
++    { Qt::Key_Shift,  QT_TRANSLATE_NOOP("QShortcut", "Shift") },
++    { Qt::Key_Control,  QT_TRANSLATE_NOOP("QShortcut", "Control") },
++    { Qt::Key_Alt,  QT_TRANSLATE_NOOP("QShortcut", "Alt") },
++    { Qt::Key_Meta,  QT_TRANSLATE_NOOP("QShortcut", "Meta") },
+ 
+ };
+ static Q_CONSTEXPR int numKeyNames = sizeof keyname / sizeof *keyname;
+diff --git a/qtbase/src/gui/kernel/qplatformservices.cpp b/qtbase/src/gui/kernel/qplatformservices.cpp
+index fdc6a6c4aa..ac47f98c5d 100644
+--- a/qtbase/src/gui/kernel/qplatformservices.cpp
++++ b/qtbase/src/gui/kernel/qplatformservices.cpp
+@@ -55,6 +55,19 @@ QT_BEGIN_NAMESPACE
+     \brief The QPlatformServices provides the backend for desktop-related functionality.
+ */
+ 
++/*!
++    \enum QPlatformServices::Capability
++
++    Capabilities are used to determine a specific platform service's availability.
++
++    \value ColorPickingFromScreen The platform natively supports color picking from screen.
++    This capability indicates that the platform supports "opaque" color picking, where the
++    platform implements a complete user experience for color picking and outputs a color.
++    This is in contrast to the application implementing the color picking user experience
++    (taking care of showing a cross hair, instructing the platform integration to obtain
++    the color at a given pixel, etc.). The related service function is pickColor().
++ */
++
+ QPlatformServices::QPlatformServices()
+ { }
+ 
+@@ -85,5 +98,16 @@ QByteArray QPlatformServices::desktopEnvironment() const
+     return QByteArray("UNKNOWN");
+ }
+ 
++QPlatformServiceColorPicker *QPlatformServices::colorPicker(QWindow *parent)
++{
++    Q_UNUSED(parent);
++    return nullptr;
++}
++
++bool QPlatformServices::hasCapability(Capability capability) const
++{
++    Q_UNUSED(capability)
++    return false;
++}
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/gui/kernel/qplatformservices.h b/qtbase/src/gui/kernel/qplatformservices.h
+index 5de96cfa7d..a8b2a4ce71 100644
+--- a/qtbase/src/gui/kernel/qplatformservices.h
++++ b/qtbase/src/gui/kernel/qplatformservices.h
+@@ -50,16 +50,32 @@
+ //
+ 
+ #include <QtGui/qtguiglobal.h>
++#include <QtCore/qobject.h>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+ class QUrl;
++class QWindow;
++
++class Q_GUI_EXPORT QPlatformServiceColorPicker : public QObject
++{
++    Q_OBJECT
++public:
++    using QObject::QObject;
++    virtual void pickColor() = 0;
++Q_SIGNALS:
++    void colorPicked(const QColor &color);
++};
+ 
+ class Q_GUI_EXPORT QPlatformServices
+ {
+ public:
+     Q_DISABLE_COPY_MOVE(QPlatformServices)
+ 
++    enum Capability {
++        ColorPicking,
++    };
++
+     QPlatformServices();
+     virtual ~QPlatformServices() { }
+ 
+@@ -67,6 +83,10 @@ public:
+     virtual bool openDocument(const QUrl &url);
+ 
+     virtual QByteArray desktopEnvironment() const;
++
++    virtual bool hasCapability(Capability capability) const;
++
++    virtual QPlatformServiceColorPicker *colorPicker(QWindow *parent = nullptr);
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/gui/kernel/qplatformtheme.cpp b/qtbase/src/gui/kernel/qplatformtheme.cpp
+index 71521c0339..2325873245 100644
+--- a/qtbase/src/gui/kernel/qplatformtheme.cpp
++++ b/qtbase/src/gui/kernel/qplatformtheme.cpp
+@@ -163,6 +163,8 @@ QT_BEGIN_NAMESPACE
+ 
+     \value ShowShortcutsInContextMenus (bool) Whether to display shortcut key sequences in context menus.
+ 
++    \value ButtonPressKeys (QList<Qt::Key>) A list of keys that can be used to press buttons via keyboard input.
++
+     \sa themeHint(), QStyle::pixelMetric()
+ */
+ 
+@@ -563,6 +565,8 @@ QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint)
+         }
+     case MouseQuickSelectionThreshold:
+         return QVariant(10);
++    case ButtonPressKeys:
++        return QVariant::fromValue(QList<Qt::Key>({ Qt::Key_Space, Qt::Key_Select }));
+     }
+     return QVariant();
+ }
+diff --git a/qtbase/src/gui/kernel/qplatformtheme.h b/qtbase/src/gui/kernel/qplatformtheme.h
+index 3185fc4541..7e6c9d5740 100644
+--- a/qtbase/src/gui/kernel/qplatformtheme.h
++++ b/qtbase/src/gui/kernel/qplatformtheme.h
+@@ -120,7 +120,8 @@ public:
+         TouchDoubleTapDistance,
+         ShowShortcutsInContextMenus,
+         IconFallbackSearchPaths,
+-        MouseQuickSelectionThreshold
++        MouseQuickSelectionThreshold,
++        ButtonPressKeys
+     };
+ 
+     enum DialogType {
+diff --git a/qtbase/src/gui/kernel/qscreen.cpp b/qtbase/src/gui/kernel/qscreen.cpp
+index 8e0eb35116..5d172a58dd 100644
+--- a/qtbase/src/gui/kernel/qscreen.cpp
++++ b/qtbase/src/gui/kernel/qscreen.cpp
+@@ -77,6 +77,12 @@ QScreen::QScreen(QPlatformScreen *screen)
+     d->setPlatformScreen(screen);
+ }
+ 
++void QScreenPrivate::updateLogicalDpi()
++{
++    logicalDpi = QPlatformScreen::overrideDpi(platformScreen->logicalDpi());
++    updateGeometriesWithSignals(); // updates geometries based on scale factor
++}
++
+ void QScreenPrivate::updateGeometriesWithSignals()
+ {
+     const QRect oldGeometry = geometry;
+diff --git a/qtbase/src/gui/kernel/qscreen_p.h b/qtbase/src/gui/kernel/qscreen_p.h
+index 7da542c25e..e50fc3190b 100644
+--- a/qtbase/src/gui/kernel/qscreen_p.h
++++ b/qtbase/src/gui/kernel/qscreen_p.h
+@@ -70,6 +70,7 @@ public:
+         geometry = platformScreen->deviceIndependentGeometry();
+         availableGeometry = QHighDpi::fromNative(platformScreen->availableGeometry(), QHighDpiScaling::factor(platformScreen), geometry.topLeft());
+     }
++    void updateLogicalDpi();
+ 
+     void updatePrimaryOrientation();
+     void updateGeometriesWithSignals();
+diff --git a/qtbase/src/gui/painting/qblendfunctions_p.h b/qtbase/src/gui/painting/qblendfunctions_p.h
+index 080da98ec4..6997d62b3c 100644
+--- a/qtbase/src/gui/painting/qblendfunctions_p.h
++++ b/qtbase/src/gui/painting/qblendfunctions_p.h
+@@ -246,25 +246,32 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+                                   int dudx, int dvdx, int dudy, int dvdy, int u0, int v0,
+                                   Blender blender)
+ {
+-    int fromY = qMax(qRound(topY), clip.top());
+-    int toY = qMin(qRound(bottomY), clip.top() + clip.height());
++    qint64 fromY = qMax(qRound(topY), clip.top());
++    qint64 toY = qMin(qRound(bottomY), clip.top() + clip.height());
+     if (fromY >= toY)
+         return;
+ 
+     qreal leftSlope = (bottomLeft.x - topLeft.x) / (bottomLeft.y - topLeft.y);
+     qreal rightSlope = (bottomRight.x - topRight.x) / (bottomRight.y - topRight.y);
+-    int dx_l = int(leftSlope * 0x10000);
+-    int dx_r = int(rightSlope * 0x10000);
+-    int x_l = int((topLeft.x + (qreal(0.5) + fromY - topLeft.y) * leftSlope + qreal(0.5)) * 0x10000);
+-    int x_r = int((topRight.x + (qreal(0.5) + fromY - topRight.y) * rightSlope + qreal(0.5)) * 0x10000);
+-
+-    int fromX, toX, x1, x2, u, v, i, ii;
++    qint64 dx_l = qint64(leftSlope * 0x10000);
++    qint64 dx_r = qint64(rightSlope * 0x10000);
++    qint64 x_l = qint64((topLeft.x + (qreal(0.5) + fromY - topLeft.y) * leftSlope + qreal(0.5)) * 0x10000);
++    qint64 x_r = qint64((topRight.x + (qreal(0.5) + fromY - topRight.y) * rightSlope + qreal(0.5)) * 0x10000);
++
++    qint64 sourceRectTop = qint64(sourceRect.top());
++    qint64 sourceRectLeft = qint64(sourceRect.left());
++    qint64 sourceRectWidth = qint64(sourceRect.width());
++    qint64 sourceRectHeight = qint64(sourceRect.height());
++    qint64 clipLeft = qint64(clip.left());
++    qint64 clipWidth = qint64(clip.width());
++
++    qint64 fromX, toX, x1, x2, u, v, i, ii;
+     DestT *line;
+-    for (int y = fromY; y < toY; ++y) {
++    for (qint64 y = fromY; y < toY; ++y) {
+         line = reinterpret_cast<DestT *>(reinterpret_cast<uchar *>(destPixels) + y * dbpl);
+ 
+-        fromX = qMax(x_l >> 16, clip.left());
+-        toX = qMin(x_r >> 16, clip.left() + clip.width());
++        fromX = qMax(x_l >> 16, clipLeft);
++        toX = qMin(x_r >> 16, clipLeft + clipWidth);
+         if (fromX < toX) {
+             // Because of rounding, we can get source coordinates outside the source image.
+             // Clamp these coordinates to the source rect to avoid segmentation fault and
+@@ -275,10 +282,10 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             u = x1 * dudx + y * dudy + u0;
+             v = x1 * dvdx + y * dvdy + v0;
+             for (; x1 < toX; ++x1) {
+-                int uu = u >> 16;
+-                int vv = v >> 16;
+-                if (uu >= sourceRect.left() && uu < sourceRect.left() + sourceRect.width()
+-                    && vv >= sourceRect.top() && vv < sourceRect.top() + sourceRect.height()) {
++                qint64 uu = u >> 16;
++                qint64 vv = v >> 16;
++                if (uu >= sourceRectLeft && uu < sourceRectLeft + sourceRectWidth
++                    && vv >= sourceRectTop && vv < sourceRectTop + sourceRectHeight) {
+                     break;
+                 }
+                 u += dudx;
+@@ -290,10 +297,10 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             u = (x2 - 1) * dudx + y * dudy + u0;
+             v = (x2 - 1) * dvdx + y * dvdy + v0;
+             for (; x2 > x1; --x2) {
+-                int uu = u >> 16;
+-                int vv = v >> 16;
+-                if (uu >= sourceRect.left() && uu < sourceRect.left() + sourceRect.width()
+-                    && vv >= sourceRect.top() && vv < sourceRect.top() + sourceRect.height()) {
++                qint64 uu = u >> 16;
++                qint64 vv = v >> 16;
++                if (uu >= sourceRectLeft && uu < sourceRectLeft + sourceRectWidth
++                    && vv >= sourceRectTop && vv < sourceRectTop + sourceRectHeight) {
+                     break;
+                 }
+                 u -= dudx;
+@@ -308,8 +315,8 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             // Beginning of the scan line, with per-pixel checks.
+             i = x1 - fromX;
+             while (i) {
+-                int uu = qBound(sourceRect.left(), u >> 16, sourceRect.left() + sourceRect.width() - 1);
+-                int vv = qBound(sourceRect.top(), v >> 16, sourceRect.top() + sourceRect.height() - 1);
++                qint64 uu = qBound(sourceRectLeft, u >> 16, sourceRectLeft + sourceRectWidth - 1);
++                qint64 vv = qBound(sourceRectTop, v >> 16, sourceRectTop + sourceRectHeight - 1);
+                 blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + vv * sbpl)[uu]);
+                 u += dudx;
+                 v += dvdx;
+@@ -348,8 +355,8 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             // End of the scan line, with per-pixel checks.
+             i = toX - x2;
+             while (i) {
+-                int uu = qBound(sourceRect.left(), u >> 16, sourceRect.left() + sourceRect.width() - 1);
+-                int vv = qBound(sourceRect.top(), v >> 16, sourceRect.top() + sourceRect.height() - 1);
++                qint64 uu = qBound(sourceRectLeft, u >> 16, sourceRectLeft + sourceRectWidth - 1);
++                qint64 vv = qBound(sourceRectTop, v >> 16, sourceRectTop + sourceRectHeight - 1);
+                 blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + vv * sbpl)[uu]);
+                 u += dudx;
+                 v += dvdx;
+diff --git a/qtbase/src/gui/painting/qcolortrclut_p.h b/qtbase/src/gui/painting/qcolortrclut_p.h
+index 76a6a60803..24fd522e6c 100644
+--- a/qtbase/src/gui/painting/qcolortrclut_p.h
++++ b/qtbase/src/gui/painting/qcolortrclut_p.h
+@@ -118,6 +118,7 @@ public:
+         return QRgba64::fromRgba64(r, g, b, qAlpha(rgb32) * 257);
+ #endif
+     }
++    QRgba64 toLinear64(QRgba64) const = delete;
+ 
+     QRgb toLinear(QRgb rgb32) const
+     {
+diff --git a/qtbase/src/gui/painting/qdrawhelper.cpp b/qtbase/src/gui/painting/qdrawhelper.cpp
+index a61793508a..5ba2d277b7 100644
+--- a/qtbase/src/gui/painting/qdrawhelper.cpp
++++ b/qtbase/src/gui/painting/qdrawhelper.cpp
+@@ -6091,7 +6091,7 @@ static inline void alphargbblend_argb32(quint32 *dst, uint coverage, const QRgba
+ static inline void rgbBlendPixel(QRgba64 &dst, int coverage, QRgba64 slinear, const QColorTrcLut *colorProfile)
+ {
+     // Do a gammacorrected RGB alphablend...
+-    const QRgba64 dlinear = colorProfile ? colorProfile->toLinear64(dst) : dst;
++    const QRgba64 dlinear = colorProfile ? colorProfile->toLinear(dst) : dst;
+ 
+     QRgba64 blend = rgbBlend(dlinear, slinear, coverage);
+ 
+diff --git a/qtbase/src/gui/painting/qpaintengine_raster.cpp b/qtbase/src/gui/painting/qpaintengine_raster.cpp
+index 283923de52..f08eb9cbee 100644
+--- a/qtbase/src/gui/painting/qpaintengine_raster.cpp
++++ b/qtbase/src/gui/painting/qpaintengine_raster.cpp
+@@ -560,31 +560,6 @@ void QRasterPaintEngine::updateMatrix(const QTransform &matrix)
+     QRasterPaintEngineState *s = state();
+     // FALCON: get rid of this line, see drawImage call below.
+     s->matrix = matrix;
+-    QTransform::TransformationType txop = s->matrix.type();
+-
+-    switch (txop) {
+-
+-    case QTransform::TxNone:
+-        s->flags.int_xform = true;
+-        break;
+-
+-    case QTransform::TxTranslate:
+-        s->flags.int_xform = qreal(int(s->matrix.dx())) == s->matrix.dx()
+-                            && qreal(int(s->matrix.dy())) == s->matrix.dy();
+-        break;
+-
+-    case QTransform::TxScale:
+-        s->flags.int_xform = qreal(int(s->matrix.dx())) == s->matrix.dx()
+-                            && qreal(int(s->matrix.dy())) == s->matrix.dy()
+-                            && qreal(int(s->matrix.m11())) == s->matrix.m11()
+-                            && qreal(int(s->matrix.m22())) == s->matrix.m22();
+-        break;
+-
+-    default: // shear / perspective...
+-        s->flags.int_xform = false;
+-        break;
+-    }
+-
+     s->flags.tx_noshear = qt_scaleForTransform(s->matrix, &s->txscale);
+ 
+     ensureOutlineMapper();
+@@ -617,7 +592,6 @@ QRasterPaintEngineState::QRasterPaintEngineState()
+     flags.bilinear = false;
+     flags.legacy_rounding = false;
+     flags.fast_text = true;
+-    flags.int_xform = true;
+     flags.tx_noshear = true;
+     flags.fast_images = true;
+ 
+@@ -1793,7 +1767,7 @@ void QRasterPaintEngine::fill(const QVectorPath &path, const QBrush &brush)
+     QRectF cpRect = path.controlPointRect();
+     const QRectF pathDeviceRect = s->matrix.mapRect(cpRect);
+     // Skip paths that by conservative estimates are completely outside the paint device.
+-    if (!pathDeviceRect.intersects(QRectF(d->deviceRect)))
++    if (!pathDeviceRect.intersects(QRectF(d->deviceRect)) || !pathDeviceRect.isValid())
+         return;
+ 
+     ProcessSpans blend = d->getBrushFunc(pathDeviceRect, &s->brushData);
+diff --git a/qtbase/src/gui/painting/qpaintengine_raster_p.h b/qtbase/src/gui/painting/qpaintengine_raster_p.h
+index 089aadc3f7..bf7363d5aa 100644
+--- a/qtbase/src/gui/painting/qpaintengine_raster_p.h
++++ b/qtbase/src/gui/painting/qpaintengine_raster_p.h
+@@ -111,7 +111,6 @@ public:
+         uint bilinear : 1;
+         uint legacy_rounding : 1;
+         uint fast_text : 1;
+-        uint int_xform : 1;
+         uint tx_noshear : 1;
+         uint fast_images : 1;
+     };
+diff --git a/qtbase/src/gui/painting/qpainterpath.cpp b/qtbase/src/gui/painting/qpainterpath.cpp
+index f9544a3241..d80fafeaf1 100644
+--- a/qtbase/src/gui/painting/qpainterpath.cpp
++++ b/qtbase/src/gui/painting/qpainterpath.cpp
+@@ -1253,7 +1253,7 @@ void QPainterPath::addText(const QPointF &point, const QFont &f, const QString &
+ 
+         if (si.analysis.flags < QScriptAnalysis::TabOrObject) {
+             QGlyphLayout glyphs = eng->shapedGlyphs(&si);
+-            QFontEngine *fe = f.d->engineForScript(si.analysis.script);
++            QFontEngine *fe = eng->fontEngine(si);
+             Q_ASSERT(fe);
+             fe->addOutlineToPath(x, y, glyphs, this,
+                                  si.analysis.bidiLevel % 2
+diff --git a/qtbase/src/gui/painting/qpathclipper_p.h b/qtbase/src/gui/painting/qpathclipper_p.h
+index 9444a87b71..18f64c5e8c 100644
+--- a/qtbase/src/gui/painting/qpathclipper_p.h
++++ b/qtbase/src/gui/painting/qpathclipper_p.h
+@@ -156,7 +156,7 @@ public:
+     int vertex(Direction direction) const;
+ 
+ private:
+-    int m_next[2][2];
++    int m_next[2][2] = { { -1, -1 }, { -1, -1 } };
+ };
+ 
+ class QPathSegments
+@@ -296,10 +296,6 @@ inline QPathEdge::QPathEdge(int a, int b)
+     , angle(0)
+     , invAngle(0)
+ {
+-    m_next[0][0] = -1;
+-    m_next[1][0] = -1;
+-    m_next[0][0] = -1;
+-    m_next[1][0] = -1;
+ }
+ 
+ inline int QPathEdge::next(Traversal traversal, Direction direction) const
+diff --git a/qtbase/src/gui/painting/qpdf.cpp b/qtbase/src/gui/painting/qpdf.cpp
+index 3066744f1b..2c8d3c3b53 100644
+--- a/qtbase/src/gui/painting/qpdf.cpp
++++ b/qtbase/src/gui/painting/qpdf.cpp
+@@ -2760,6 +2760,8 @@ int QPdfEnginePrivate::addBrushPattern(const QTransform &m, bool *specifyColor,
+         return gradientBrush(brush, matrix, gStateObject);
+     }
+ 
++    matrix = brush.transform() * matrix;
++
+     if ((!brush.isOpaque() && brush.style() < Qt::LinearGradientPattern) || opacity != 1.0)
+         *gStateObject = addConstantAlphaObject(qRound(brush.color().alpha() * opacity),
+                                                qRound(pen.color().alpha() * opacity));
+diff --git a/qtbase/src/gui/painting/qstroker.cpp b/qtbase/src/gui/painting/qstroker.cpp
+index cb5d395e80..3b6357a893 100644
+--- a/qtbase/src/gui/painting/qstroker.cpp
++++ b/qtbase/src/gui/painting/qstroker.cpp
+@@ -1182,6 +1182,7 @@ void QDashStroker::processCurrentSubpath()
+         // Check if the entire line should be clipped away or simplified
+         bool clipIt = clipping && !lineIntersectsRect(prev, e, clip_tl, clip_br);
+         bool skipDashing = elen * invSumLength > repetitionLimit();
++        int maxDashes = dashCount;
+         if (skipDashing || clipIt) {
+             // Cut away full dash sequences.
+             elen -= std::floor(elen * invSumLength) * sumLength;
+@@ -1196,7 +1197,7 @@ void QDashStroker::processCurrentSubpath()
+                     pos = estop; // move pos to next path element
+                     done = true;
+                 } else { // Dash is on this line
+-                    pos = dpos + estart;
++                    pos = --maxDashes > 0 ? dpos + estart : estop;
+                     done = pos >= estop;
+                     if (++idash >= dashCount)
+                         idash = 0;
+diff --git a/qtbase/src/gui/painting/qt_attribution.json b/qtbase/src/gui/painting/qt_attribution.json
+index 7b16e8c211..0e87d30aa2 100644
+--- a/qtbase/src/gui/painting/qt_attribution.json
++++ b/qtbase/src/gui/painting/qt_attribution.json
+@@ -10,7 +10,7 @@
+         "Homepage": "http://www.freetype.org",
+         "License": "Freetype Project License or GNU General Public License v2.0 only",
+         "LicenseId": "FTL or GPL-2.0",
+-        "LicenseFile": "../../3rdparty/freetype/docs/LICENSE.TXT",
++        "LicenseFile": "../../3rdparty/freetype/LICENSE.TXT",
+         "Copyright": "Copyright 2000-2016 by David Turner, Robert Wilhelm, and Werner Lemberg."
+     },
+     {
+diff --git a/qtbase/src/gui/rhi/qshader_p_p.h b/qtbase/src/gui/rhi/qshader_p_p.h
+index ec9d25971f..4a5a7a6d51 100644
+--- a/qtbase/src/gui/rhi/qshader_p_p.h
++++ b/qtbase/src/gui/rhi/qshader_p_p.h
+@@ -68,13 +68,13 @@ struct Q_GUI_EXPORT QShaderPrivate
+     {
+     }
+ 
+-    QShaderPrivate(const QShaderPrivate *other)
++    QShaderPrivate(const QShaderPrivate &other)
+         : ref(1),
+-          qsbVersion(other->qsbVersion),
+-          stage(other->stage),
+-          desc(other->desc),
+-          shaders(other->shaders),
+-          bindings(other->bindings)
++          qsbVersion(other.qsbVersion),
++          stage(other.stage),
++          desc(other.desc),
++          shaders(other.shaders),
++          bindings(other.bindings)
+     {
+     }
+ 
+diff --git a/qtbase/src/gui/rhi/qshaderdescription_p_p.h b/qtbase/src/gui/rhi/qshaderdescription_p_p.h
+index ec2b0b6b4c..3da33a8a2b 100644
+--- a/qtbase/src/gui/rhi/qshaderdescription_p_p.h
++++ b/qtbase/src/gui/rhi/qshaderdescription_p_p.h
+@@ -63,16 +63,16 @@ struct Q_GUI_EXPORT QShaderDescriptionPrivate
+         localSize[0] = localSize[1] = localSize[2] = 0;
+     }
+ 
+-    QShaderDescriptionPrivate(const QShaderDescriptionPrivate *other)
++    QShaderDescriptionPrivate(const QShaderDescriptionPrivate &other)
+         : ref(1),
+-          inVars(other->inVars),
+-          outVars(other->outVars),
+-          uniformBlocks(other->uniformBlocks),
+-          pushConstantBlocks(other->pushConstantBlocks),
+-          storageBlocks(other->storageBlocks),
+-          combinedImageSamplers(other->combinedImageSamplers),
+-          storageImages(other->storageImages),
+-          localSize(other->localSize)
++          inVars(other.inVars),
++          outVars(other.outVars),
++          uniformBlocks(other.uniformBlocks),
++          pushConstantBlocks(other.pushConstantBlocks),
++          storageBlocks(other.storageBlocks),
++          combinedImageSamplers(other.combinedImageSamplers),
++          storageImages(other.storageImages),
++          localSize(other.localSize)
+     {
+     }
+ 
+diff --git a/qtbase/src/gui/text/qfontdatabase.cpp b/qtbase/src/gui/text/qfontdatabase.cpp
+index a657a8c516..4fc0100958 100644
+--- a/qtbase/src/gui/text/qfontdatabase.cpp
++++ b/qtbase/src/gui/text/qfontdatabase.cpp
+@@ -983,7 +983,7 @@ QFontEngine *loadSingleEngine(int script,
+         if (style->key.stretch != 0 && request.stretch != 0
+             && (request.styleName.isEmpty() || request.styleName != style->styleName)) {
+             def.stretch = (request.stretch * 100 + style->key.stretch / 2) / style->key.stretch;
+-        } else {
++        } else if (request.stretch == QFont::AnyStretch) {
+             def.stretch = 100;
+         }
+ 
+diff --git a/qtbase/src/gui/text/qtextdocumentlayout.cpp b/qtbase/src/gui/text/qtextdocumentlayout.cpp
+index f3e6ea2100..72267e9380 100644
+--- a/qtbase/src/gui/text/qtextdocumentlayout.cpp
++++ b/qtbase/src/gui/text/qtextdocumentlayout.cpp
+@@ -2123,7 +2123,7 @@ void QTextDocumentLayoutPrivate::drawListItem(const QPointF &offset, QPainter *p
+ {
+     Q_Q(const QTextDocumentLayout);
+     const QTextBlockFormat blockFormat = bl.blockFormat();
+-    const QTextCharFormat charFormat = QTextCursor(bl).charFormat();
++    const QTextCharFormat charFormat = bl.charFormat();
+     QFont font(charFormat.font());
+     if (q->paintDevice())
+         font = QFont(font, q->paintDevice());
+diff --git a/qtbase/src/gui/text/qtextengine.cpp b/qtbase/src/gui/text/qtextengine.cpp
+index ce4abac472..a6c66e5d2d 100644
+--- a/qtbase/src/gui/text/qtextengine.cpp
++++ b/qtbase/src/gui/text/qtextengine.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2021 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtGui module of the Qt Toolkit.
+@@ -1565,6 +1565,12 @@ void QTextEngine::shapeText(int item) const
+         // Overwrite with 0 token to indicate failure
+         QGlyphLayout g = availableGlyphs(&si);
+         g.glyphs[0] = 0;
++        g.attributes[0].clusterStart = true;
++
++        ushort *log_clusters = logClusters(&si);
++        for (int i = 0; i < itemLength; ++i)
++            log_clusters[i] = 0;
++
+         return;
+     }
+ 
+diff --git a/qtbase/src/gui/util/qdesktopservices.cpp b/qtbase/src/gui/util/qdesktopservices.cpp
+index fbb63a9408..4d5fafaaa7 100644
+--- a/qtbase/src/gui/util/qdesktopservices.cpp
++++ b/qtbase/src/gui/util/qdesktopservices.cpp
+@@ -54,6 +54,8 @@
+ #include <qpa/qplatformintegration.h>
+ #include <qdir.h>
+ 
++#include <QtCore/private/qlocking_p.h>
++
+ QT_BEGIN_NAMESPACE
+ 
+ class QOpenUrlHandlerRegistry : public QObject
+@@ -81,6 +83,7 @@ Q_GLOBAL_STATIC(QOpenUrlHandlerRegistry, handlerRegistry)
+ 
+ void QOpenUrlHandlerRegistry::handlerDestroyed(QObject *handler)
+ {
++    const auto lock = qt_scoped_lock(mutex);
+     HandlerHash::Iterator it = handlers.begin();
+     while (it != handlers.end()) {
+         if (it->receiver == handler) {
+@@ -294,7 +297,8 @@ void QDesktopServices::setUrlHandler(const QString &scheme, QObject *receiver, c
+     h.name = method;
+     registry->handlers.insert(scheme.toLower(), h);
+     QObject::connect(receiver, SIGNAL(destroyed(QObject*)),
+-                     registry, SLOT(handlerDestroyed(QObject*)));
++                     registry, SLOT(handlerDestroyed(QObject*)),
++                     Qt::DirectConnection);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/gui/util/qpkmhandler.cpp b/qtbase/src/gui/util/qpkmhandler.cpp
+index e0c3b75efe..3414f9d8ba 100644
+--- a/qtbase/src/gui/util/qpkmhandler.cpp
++++ b/qtbase/src/gui/util/qpkmhandler.cpp
+@@ -57,7 +57,7 @@ struct PkmType
+     quint32 bytesPerBlock;
+ };
+ 
+-static PkmType typeMap[5] = {
++static constexpr PkmType typeMap[5] = {
+     { 0x8D64,  8 },   // GL_ETC1_RGB8_OES
+     { 0x9274,  8 },   // GL_COMPRESSED_RGB8_ETC2
+     { 0, 0 },         // unused (obsolete)
+diff --git a/qtbase/src/network/access/qnetworkreplyfileimpl.cpp b/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
+index b6be93147a..6e69b4c4d3 100644
+--- a/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
++++ b/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
+@@ -89,9 +89,10 @@ QNetworkReplyFileImpl::QNetworkReplyFileImpl(QNetworkAccessManager *manager, con
+         // we handle only local files
+         QString msg = QCoreApplication::translate("QNetworkAccessFileBackend", "Request for opening non-local file %1").arg(url.toString());
+         setError(QNetworkReply::ProtocolInvalidOperationError, msg);
++        setFinished(true); // We're finished, will emit finished() after ctor is done.
+         QMetaObject::invokeMethod(this, "errorOccurred", Qt::QueuedConnection,
+             Q_ARG(QNetworkReply::NetworkError, QNetworkReply::ProtocolInvalidOperationError));
+-        fileOpenFinished(false);
++        QMetaObject::invokeMethod(this, [this](){ fileOpenFinished(false); }, Qt::QueuedConnection);
+         return;
+     }
+ #endif
+diff --git a/qtbase/src/network/access/qnetworkreplyimpl.cpp b/qtbase/src/network/access/qnetworkreplyimpl.cpp
+index bcdf6ee2f1..3b6deb82bd 100644
+--- a/qtbase/src/network/access/qnetworkreplyimpl.cpp
++++ b/qtbase/src/network/access/qnetworkreplyimpl.cpp
+@@ -680,7 +680,7 @@ void QNetworkReplyImplPrivate::appendDownstreamData(QIODevice *data)
+     // read until EOF from data
+     if (Q_UNLIKELY(copyDevice)) {
+         qCritical("QNetworkReplyImpl: copy from QIODevice already in progress -- "
+-                  "backend probly needs to be fixed");
++                  "backend probably needs to be fixed");
+         return;
+     }
+ 
+diff --git a/qtbase/src/network/kernel/qauthenticator.cpp b/qtbase/src/network/kernel/qauthenticator.cpp
+index d9fe7bc47b..ccd04b294a 100644
+--- a/qtbase/src/network/kernel/qauthenticator.cpp
++++ b/qtbase/src/network/kernel/qauthenticator.cpp
+@@ -50,6 +50,7 @@
+ #include <qstring.h>
+ #include <qdatetime.h>
+ #include <qrandom.h>
++#include "private/qsystemlibrary_p.h"
+ 
+ #ifdef Q_OS_WIN
+ #include <qmutex.h>
+@@ -1563,7 +1564,7 @@ static bool q_SSPI_library_load()
+ 
+     // Initialize security interface
+     if (pSecurityFunctionTable == nullptr) {
+-        securityDLLHandle = LoadLibrary(L"secur32.dll");
++        securityDLLHandle = QSystemLibrary::load(L"secur32");
+         if (securityDLLHandle != nullptr) {
+             INIT_SECURITY_INTERFACE pInitSecurityInterface =
+                 reinterpret_cast<INIT_SECURITY_INTERFACE>(
+diff --git a/qtbase/src/network/kernel/qhostinfo_unix.cpp b/qtbase/src/network/kernel/qhostinfo_unix.cpp
+index 9b0a2ee669..73679c9ef1 100644
+--- a/qtbase/src/network/kernel/qhostinfo_unix.cpp
++++ b/qtbase/src/network/kernel/qhostinfo_unix.cpp
+@@ -122,7 +122,6 @@ static QFunctionPointer resolveSymbol(QLibrary &lib, const char *sym)
+ 
+ LibResolv::LibResolv()
+ {
+-    QLibrary lib;
+ #ifdef LIBRESOLV_SO
+     lib.setFileName(QStringLiteral(LIBRESOLV_SO));
+     if (!lib.load())
+diff --git a/qtbase/src/network/socket/qsocks5socketengine.cpp b/qtbase/src/network/socket/qsocks5socketengine.cpp
+index 3a046fd116..97fadca0b3 100644
+--- a/qtbase/src/network/socket/qsocks5socketengine.cpp
++++ b/qtbase/src/network/socket/qsocks5socketengine.cpp
+@@ -1296,7 +1296,7 @@ void QSocks5SocketEnginePrivate::_q_udpSocketReadNotification()
+         int pos = 0;
+         const char *buf = inBuf.constData();
+         if (inBuf.size() < 4) {
+-            QSOCKS5_D_DEBUG << "bugus udp data, discarding";
++            QSOCKS5_D_DEBUG << "bogus udp data, discarding";
+             return;
+         }
+         QSocks5RevivedDatagram datagram;
+diff --git a/qtbase/src/network/ssl/qsslcontext_openssl.cpp b/qtbase/src/network/ssl/qsslcontext_openssl.cpp
+index c9f202f573..c992da9d8e 100644
+--- a/qtbase/src/network/ssl/qsslcontext_openssl.cpp
++++ b/qtbase/src/network/ssl/qsslcontext_openssl.cpp
+@@ -409,7 +409,7 @@ init_context:
+         break;
+     case QSsl::DtlsV1_0OrLater:
+         minVersion = DTLS1_VERSION;
+-        maxVersion = DTLS_MAX_VERSION;
++        maxVersion = 0;
+         break;
+     case QSsl::DtlsV1_2:
+         minVersion = DTLS1_2_VERSION;
+@@ -417,7 +417,7 @@ init_context:
+         break;
+     case QSsl::DtlsV1_2OrLater:
+         minVersion = DTLS1_2_VERSION;
+-        maxVersion = DTLS_MAX_VERSION;
++        maxVersion = 0;
+         break;
+     case QSsl::TlsV1_3OrLater:
+ #ifdef TLS1_3_VERSION
+@@ -455,7 +455,7 @@ init_context:
+     }
+ 
+     // Enable bug workarounds.
+-    long options = QSslSocketBackendPrivate::setupOpenSslOptions(configuration.protocol(), configuration.d->sslOptions);
++    qssloptions options = QSslSocketBackendPrivate::setupOpenSslOptions(configuration.protocol(), configuration.d->sslOptions);
+     q_SSL_CTX_set_options(sslContext->ctx, options);
+ 
+     // Tell OpenSSL to release memory early
+diff --git a/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp b/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
+index aaf8741130..b58935372c 100644
+--- a/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
++++ b/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
+@@ -59,57 +59,6 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-#ifdef OPENSSL_NO_DEPRECATED_3_0
+-
+-static int q_DH_check(DH *dh, int *status)
+-{
+-    // DH_check was first deprecated in OpenSSL 3.0.0, as low-level
+-    // API; the EVP_PKEY family of functions was advised as an alternative.
+-    // As of now EVP_PKEY_params_check ends up calling ... DH_check,
+-    // which is good enough.
+-
+-    Q_ASSERT(dh);
+-    Q_ASSERT(status);
+-
+-    EVP_PKEY *key = q_EVP_PKEY_new();
+-    if (!key) {
+-        qCWarning(lcSsl, "EVP_PKEY_new failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-    const auto keyDeleter = qScopeGuard([key](){
+-        q_EVP_PKEY_free(key);
+-    });
+-    if (!q_EVP_PKEY_set1_DH(key, dh)) {
+-        qCWarning(lcSsl, "EVP_PKEY_set1_DH failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-
+-    EVP_PKEY_CTX *keyCtx = q_EVP_PKEY_CTX_new(key, nullptr);
+-    if (!keyCtx) {
+-        qCWarning(lcSsl, "EVP_PKEY_CTX_new failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-    const auto ctxDeleter = qScopeGuard([keyCtx]{
+-        q_EVP_PKEY_CTX_free(keyCtx);
+-    });
+-
+-    const int result = q_EVP_PKEY_param_check(keyCtx);
+-    QSslSocketBackendPrivate::logAndClearErrorQueue();
+-    // Note: unlike DH_check, we cannot obtain the 'status',
+-    // if the 'result' is 0 (actually the result is 1 only
+-    // if this 'status' was 0). We could probably check the
+-    // errors from the error queue, but it's not needed anyway
+-    // - see the 'isSafeDH' below, how it returns immediately
+-    // on 0.
+-    Q_UNUSED(status)
+-
+-    return result;
+-}
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+-
+ static bool isSafeDH(DH *dh)
+ {
+     int status = 0;
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl.cpp b/qtbase/src/network/ssl/qsslsocket_openssl.cpp
+index 37fad2a68f..8f6858c867 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl.cpp
++++ b/qtbase/src/network/ssl/qsslsocket_openssl.cpp
+@@ -550,9 +550,9 @@ static void q_loadCiphersForConnection(SSL *connection, QList<QSslCipher> &ciphe
+ // Defined in qsslsocket.cpp
+ void q_setDefaultDtlsCiphers(const QList<QSslCipher> &ciphers);
+ 
+-long QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions)
++qssloptions QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions)
+ {
+-    long options;
++    qssloptions options;
+     if (protocol == QSsl::TlsV1SslV3)
+         options = SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3;
+     else if (protocol == QSsl::SecureProtocols)
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_p.h b/qtbase/src/network/ssl/qsslsocket_openssl_p.h
+index 4103de23e8..5547589256 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_p.h
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_p.h
+@@ -107,6 +107,12 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++typedef uint64_t qssloptions;
++#else
++typedef unsigned long qssloptions;
++#endif
++
+ struct QSslErrorEntry {
+     int code;
+     int depth;
+@@ -171,7 +177,7 @@ public:
+     QVector<QSslError> ocspErrors;
+     QByteArray ocspResponseDer;
+ 
+-    Q_AUTOTEST_EXPORT static long setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions);
++    Q_AUTOTEST_EXPORT static qssloptions setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions);
+     static QSslCipher QSslCipher_from_SSL_CIPHER(const SSL_CIPHER *cipher);
+     static QList<QSslCertificate> STACKOFX509_to_QSslCertificates(STACK_OF(X509) *x509);
+     static QList<QSslError> verify(const QList<QSslCertificate> &certificateChain, const QString &hostName);
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp b/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
+index e53fb279f0..459ccd0b19 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
+@@ -148,7 +148,6 @@ DEFINEFUNC(int, EVP_PKEY_up_ref, EVP_PKEY *a, a, return 0, return)
+ DEFINEFUNC2(EVP_PKEY_CTX *, EVP_PKEY_CTX_new, EVP_PKEY *pkey, pkey, ENGINE *e, e, return nullptr, return)
+ DEFINEFUNC(int, EVP_PKEY_param_check, EVP_PKEY_CTX *ctx, ctx, return 0, return)
+ DEFINEFUNC(void, EVP_PKEY_CTX_free, EVP_PKEY_CTX *ctx, ctx, return, return)
+-DEFINEFUNC(int, EVP_PKEY_base_id, EVP_PKEY *a, a, return NID_undef, return)
+ DEFINEFUNC(int, RSA_bits, RSA *a, a, return 0, return)
+ DEFINEFUNC(int, DSA_bits, DSA *a, a, return 0, return)
+ DEFINEFUNC(int, OPENSSL_sk_num, OPENSSL_STACK *a, a, return -1, return)
+@@ -158,7 +157,7 @@ DEFINEFUNC2(void, OPENSSL_sk_push, OPENSSL_STACK *a, a, void *b, b, return, DUMM
+ DEFINEFUNC(void, OPENSSL_sk_free, OPENSSL_STACK *a, a, return, DUMMYARG)
+ DEFINEFUNC2(void *, OPENSSL_sk_value, OPENSSL_STACK *a, a, int b, b, return nullptr, return)
+ DEFINEFUNC(int, SSL_session_reused, SSL *a, a, return 0, return)
+-DEFINEFUNC2(unsigned long, SSL_CTX_set_options, SSL_CTX *ctx, ctx, unsigned long op, op, return 0, return)
++DEFINEFUNC2(qssloptions, SSL_CTX_set_options, SSL_CTX *ctx, ctx, qssloptions op, op, return 0, return)
+ DEFINEFUNC(int, SSL_CTX_get_security_level, const SSL_CTX *ctx, ctx, return -1, return)
+ DEFINEFUNC2(void, SSL_CTX_set_security_level, SSL_CTX *ctx, ctx, int level, level, return, return)
+ #ifdef TLS1_3_VERSION
+@@ -371,7 +370,15 @@ DEFINEFUNC(const SSL_CIPHER *, SSL_get_current_cipher, SSL *a, a, return nullptr
+ DEFINEFUNC(int, SSL_version, const SSL *a, a, return 0, return)
+ DEFINEFUNC2(int, SSL_get_error, SSL *a, a, int b, b, return -1, return)
+ DEFINEFUNC(STACK_OF(X509) *, SSL_get_peer_cert_chain, SSL *a, a, return nullptr, return)
++
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++DEFINEFUNC(X509 *, SSL_get1_peer_certificate, SSL *a, a, return nullptr, return)
++DEFINEFUNC(int, EVP_PKEY_get_base_id, const EVP_PKEY *pkey, pkey, return -1, return)
++#else
+ DEFINEFUNC(X509 *, SSL_get_peer_certificate, SSL *a, a, return nullptr, return)
++DEFINEFUNC(int, EVP_PKEY_base_id, EVP_PKEY *a, a, return NID_undef, return)
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+ DEFINEFUNC(long, SSL_get_verify_result, const SSL *a, a, return -1, return)
+ DEFINEFUNC(SSL *, SSL_new, SSL_CTX *a, a, return nullptr, return)
+ DEFINEFUNC(SSL_CTX *, SSL_get_SSL_CTX, SSL *a, a, return nullptr, return)
+@@ -492,9 +499,7 @@ DEFINEFUNC(DH *, DH_new, DUMMYARG, DUMMYARG, return nullptr, return)
+ DEFINEFUNC(void, DH_free, DH *dh, dh, return, DUMMYARG)
+ DEFINEFUNC3(DH *, d2i_DHparams, DH**a, a, const unsigned char **pp, pp, long length, length, return nullptr, return)
+ DEFINEFUNC2(int, i2d_DHparams, DH *a, a, unsigned char **p, p, return -1, return)
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+ DEFINEFUNC2(int, DH_check, DH *dh, dh, int *codes, codes, return 0, return)
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+ DEFINEFUNC3(BIGNUM *, BN_bin2bn, const unsigned char *s, s, int len, len, BIGNUM *ret, ret, return nullptr, return)
+ 
+ #ifndef OPENSSL_NO_EC
+@@ -868,7 +873,6 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(EVP_PKEY_CTX_new)
+     RESOLVEFUNC(EVP_PKEY_param_check)
+     RESOLVEFUNC(EVP_PKEY_CTX_free)
+-    RESOLVEFUNC(EVP_PKEY_base_id)
+     RESOLVEFUNC(RSA_bits)
+     RESOLVEFUNC(OPENSSL_sk_new_null)
+     RESOLVEFUNC(OPENSSL_sk_push)
+@@ -1107,7 +1111,15 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(SSL_version)
+     RESOLVEFUNC(SSL_get_error)
+     RESOLVEFUNC(SSL_get_peer_cert_chain)
++
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++    RESOLVEFUNC(SSL_get1_peer_certificate)
++    RESOLVEFUNC(EVP_PKEY_get_base_id)
++#else
+     RESOLVEFUNC(SSL_get_peer_certificate)
++    RESOLVEFUNC(EVP_PKEY_base_id)
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+     RESOLVEFUNC(SSL_get_verify_result)
+     RESOLVEFUNC(SSL_new)
+     RESOLVEFUNC(SSL_get_SSL_CTX)
+@@ -1206,9 +1218,7 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(DH_free)
+     RESOLVEFUNC(d2i_DHparams)
+     RESOLVEFUNC(i2d_DHparams)
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+     RESOLVEFUNC(DH_check)
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+     RESOLVEFUNC(BN_bin2bn)
+ 
+ #ifndef OPENSSL_NO_EC
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h b/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
+index 95e8897a3b..27aeffa18a 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
+@@ -237,7 +237,6 @@ Q_AUTOTEST_EXPORT int q_EVP_PKEY_up_ref(EVP_PKEY *a);
+ EVP_PKEY_CTX *q_EVP_PKEY_CTX_new(EVP_PKEY *pkey, ENGINE *e);
+ void q_EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx);
+ int q_EVP_PKEY_param_check(EVP_PKEY_CTX *ctx);
+-int q_EVP_PKEY_base_id(EVP_PKEY *a);
+ int q_RSA_bits(RSA *a);
+ Q_AUTOTEST_EXPORT int q_OPENSSL_sk_num(OPENSSL_STACK *a);
+ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_pop_free(OPENSSL_STACK *a, void (*b)(void *));
+@@ -246,7 +245,7 @@ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_push(OPENSSL_STACK *st, void *data);
+ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_free(OPENSSL_STACK *a);
+ Q_AUTOTEST_EXPORT void * q_OPENSSL_sk_value(OPENSSL_STACK *a, int b);
+ int q_SSL_session_reused(SSL *a);
+-unsigned long q_SSL_CTX_set_options(SSL_CTX *ctx, unsigned long op);
++qssloptions q_SSL_CTX_set_options(SSL_CTX *ctx, qssloptions op);
+ int q_OPENSSL_init_ssl(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings);
+ size_t q_SSL_get_client_random(SSL *a, unsigned char *out, size_t outlen);
+ size_t q_SSL_SESSION_get_master_key(const SSL_SESSION *session, unsigned char *out, size_t outlen);
+@@ -510,7 +509,6 @@ const SSL_CIPHER *q_SSL_get_current_cipher(SSL *a);
+ int q_SSL_version(const SSL *a);
+ int q_SSL_get_error(SSL *a, int b);
+ STACK_OF(X509) *q_SSL_get_peer_cert_chain(SSL *a);
+-X509 *q_SSL_get_peer_certificate(SSL *a);
+ long q_SSL_get_verify_result(const SSL *a);
+ SSL *q_SSL_new(SSL_CTX *a);
+ SSL_CTX *q_SSL_get_SSL_CTX(SSL *a);
+@@ -582,10 +580,7 @@ DH *q_DH_new();
+ void q_DH_free(DH *dh);
+ DH *q_d2i_DHparams(DH **a, const unsigned char **pp, long length);
+ int q_i2d_DHparams(DH *a, unsigned char **p);
+-
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+ int q_DH_check(DH *dh, int *codes);
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+ 
+ BIGNUM *q_BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret);
+ #define q_SSL_CTX_set_tmp_dh(ctx, dh) q_SSL_CTX_ctrl((ctx), SSL_CTRL_SET_TMP_DH, 0, (char *)dh)
+@@ -754,6 +749,17 @@ void q_CRYPTO_free(void *str, const char *file, int line);
+ int q_SSL_CTX_get_security_level(const SSL_CTX *ctx);
+ void q_SSL_CTX_set_security_level(SSL_CTX *ctx, int level);
+ 
++// Here we have the ones that make difference between OpenSSL pre/post v3:
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++X509 *q_SSL_get1_peer_certificate(SSL *a);
++#define q_SSL_get_peer_certificate q_SSL_get1_peer_certificate
++int q_EVP_PKEY_get_base_id(const EVP_PKEY *pkey);
++#define q_EVP_PKEY_base_id q_EVP_PKEY_get_base_id
++#else
++X509 *q_SSL_get_peer_certificate(SSL *a);
++int q_EVP_PKEY_base_id(EVP_PKEY *a);
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+ QT_END_NAMESPACE
+ 
+ #endif
+diff --git a/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h b/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
+index bf37d07fd8..dbd42fb799 100644
+--- a/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
++++ b/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
+@@ -61,7 +61,11 @@
+ # if !defined(Q_OS_INTEGRITY)
+ #  define WIN_INTERFACE_CUSTOM   // NV
+ # endif // Q_OS_INTEGRITY
+-#endif  // QT_EGL_NO_X11
++#else // QT_EGL_NO_X11
++// If one has an eglplatform.h with https://github.com/KhronosGroup/EGL-Registry/pull/130
++// that needs USE_X11 to be defined.
++# define USE_X11
++#endif
+ 
+ #ifdef QT_EGL_WAYLAND
+ # define WAYLAND // NV
+diff --git a/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+index 159b490ce0..00aa80cd58 100644
+--- a/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
++++ b/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+@@ -567,6 +567,8 @@ void QFontconfigDatabase::populateFontDatabase()
+         fonts = FcFontList(nullptr, pattern, os);
+         FcObjectSetDestroy(os);
+         FcPatternDestroy(pattern);
++        if (!fonts)
++            return;
+     }
+ 
+     for (int i = 0; i < fonts->nfont; i++)
+diff --git a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
+index b713c19447..7cb9a8c79a 100644
+--- a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
++++ b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
+@@ -95,6 +95,7 @@ static constexpr const auto KeyTbl = qMakeArray(
+         Xkb2Qt<XKB_KEY_Clear,                   Qt::Key_Delete>,
+         Xkb2Qt<XKB_KEY_Pause,                   Qt::Key_Pause>,
+         Xkb2Qt<XKB_KEY_Print,                   Qt::Key_Print>,
++        Xkb2Qt<XKB_KEY_Sys_Req,                 Qt::Key_SysReq>,
+         Xkb2Qt<0x1005FF60,                      Qt::Key_SysReq>,         // hardcoded Sun SysReq
+         Xkb2Qt<0x1007ff00,                      Qt::Key_SysReq>,         // hardcoded X386 SysReq
+ 
+@@ -471,7 +472,7 @@ QVector<xkb_keysym_t> QXkbCommon::toKeysym(QKeyEvent *event)
+     } else if (event->modifiers() & Qt::KeypadModifier) {
+         if (qtKey >= Qt::Key_0 && qtKey <= Qt::Key_9)
+             keysyms.append(XKB_KEY_KP_0 + (qtKey - Qt::Key_0));
+-    } else if (isLatin(qtKey) && event->text().isUpper()) {
++    } else if (isLatin1(qtKey) && event->text().isUpper()) {
+         keysyms.append(qtKey);
+     }
+ 
+@@ -523,7 +524,7 @@ int QXkbCommon::keysymToQtKey(xkb_keysym_t keysym, Qt::KeyboardModifiers modifie
+         // With standard shortcuts we should prefer a latin character, this is
+         // for checks like "some qkeyevent == QKeySequence::Copy" to work even
+         // when using for example 'russian' keyboard layout.
+-        if (!QXkbCommon::isLatin(keysym)) {
++        if (!QXkbCommon::isLatin1(keysym)) {
+             xkb_keysym_t latinKeysym = QXkbCommon::lookupLatinKeysym(state, code);
+             if (latinKeysym != XKB_KEY_NoSymbol)
+                 keysym = latinKeysym;
+@@ -546,7 +547,7 @@ static int keysymToQtKey_internal(xkb_keysym_t keysym, Qt::KeyboardModifiers mod
+     } else if (keysym >= XKB_KEY_KP_0 && keysym <= XKB_KEY_KP_9) {
+         // numeric keypad keys
+         qtKey = Qt::Key_0 + (keysym - XKB_KEY_KP_0);
+-    } else if (QXkbCommon::isLatin(keysym)) {
++    } else if (QXkbCommon::isLatin1(keysym)) {
+         qtKey = QXkbCommon::qxkbcommon_xkb_keysym_to_upper(keysym);
+     } else {
+         // check if we have a direct mapping
+@@ -678,7 +679,7 @@ QList<int> QXkbCommon::possibleKeys(xkb_state *state, const QKeyEvent *event,
+         Qt::KeyboardModifiers neededMods = ModsTbl[i];
+         if ((modifiers & neededMods) == neededMods) {
+             if (i == 8) {
+-                if (isLatin(baseQtKey))
++                if (isLatin1(baseQtKey))
+                     continue;
+                 // add a latin key as a fall back key
+                 sym = lookupLatinKeysym(state, keycode);
+@@ -733,7 +734,7 @@ void QXkbCommon::verifyHasLatinLayout(xkb_keymap *keymap)
+     for (xkb_layout_index_t layout = 0; layout < layoutCount; ++layout) {
+         for (xkb_keycode_t code = minKeycode; code < maxKeycode; ++code) {
+             xkb_keymap_key_get_syms_by_level(keymap, code, layout, 0, &keysyms);
+-            if (keysyms && isLatin(keysyms[0]))
++            if (keysyms && isLatin1(keysyms[0]))
+                 nrLatinKeys++;
+             if (nrLatinKeys > 10) // arbitrarily chosen threshold
+                 return;
+@@ -766,7 +767,7 @@ xkb_keysym_t QXkbCommon::lookupLatinKeysym(xkb_state *state, xkb_keycode_t keyco
+         xkb_level_index_t level = xkb_state_key_get_level(state, keycode, layout);
+         if (xkb_keymap_key_get_syms_by_level(keymap, keycode, layout, level, &syms) != 1)
+             continue;
+-        if (isLatin(syms[0])) {
++        if (isLatin1(syms[0])) {
+             sym = syms[0];
+             break;
+         }
+diff --git a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
+index 561eae03db..8389bd8f5a 100644
+--- a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
++++ b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
+@@ -94,8 +94,8 @@ public:
+     static void verifyHasLatinLayout(xkb_keymap *keymap);
+     static xkb_keysym_t lookupLatinKeysym(xkb_state *state, xkb_keycode_t keycode);
+ 
+-    static bool isLatin(xkb_keysym_t sym) {
+-        return ((sym >= 'a' && sym <= 'z') || (sym >= 'A' && sym <= 'Z'));
++    static bool isLatin1(xkb_keysym_t sym) {
++        return sym <= 0xff;
+     }
+     static bool isKeypad(xkb_keysym_t sym) {
+         return sym >= XKB_KEY_KP_Space && sym <= XKB_KEY_KP_9;
+diff --git a/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp b/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
+index 8cd7f9b368..406f84663f 100644
+--- a/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
++++ b/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
+@@ -318,7 +318,7 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources,
+ 
+     if (current < 0 && crtc_mode.clock != 0) {
+         modes << crtc_mode;
+-        current = mode.size() - 1;
++        current = modes.size() - 1;
+     }
+ 
+     if (configuration == OutputConfigCurrent)
+diff --git a/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp b/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
+index 9153fd20bb..255ea5e33e 100644
+--- a/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
++++ b/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
+@@ -194,6 +194,9 @@ QString AtSpiAdaptor::introspect(const QString &path) const
+                 "      <arg direction=\"out\" type=\"(so)\"/>\n"
+                 "      <annotation value=\"QSpiObjectReference\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n"
+                 "    </method>\n"
++                "    <method name=\"GetAccessibleId\">\n"
++                "      <arg direction=\"out\" type=\"s\"/>\n"
++                "    </method>\n"
+                 "  </interface>\n"
+                 );
+ 
+@@ -913,8 +916,17 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+     }
+     case QAccessible::NameChanged: {
+         if (sendObject || sendObject_property_change || sendObject_property_change_accessible_name) {
+-            QString path = pathForInterface(event->accessibleInterface());
+-            QVariantList args = packDBusSignalArguments(QLatin1String("accessible-name"), 0, 0, variantForPath(path));
++            QAccessibleInterface *iface = event->accessibleInterface();
++            if (!iface) {
++                qCDebug(lcAccessibilityAtspi,
++                        "NameChanged event from invalid accessible.");
++                return;
++            }
++
++            QString path = pathForInterface(iface);
++            QVariantList args = packDBusSignalArguments(
++                QLatin1String("accessible-name"), 0, 0,
++                QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Name))));
+             sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                            QLatin1String("PropertyChange"), args);
+         }
+@@ -922,8 +934,17 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+     }
+     case QAccessible::DescriptionChanged: {
+         if (sendObject || sendObject_property_change || sendObject_property_change_accessible_description) {
+-            QString path = pathForInterface(event->accessibleInterface());
+-            QVariantList args = packDBusSignalArguments(QLatin1String("accessible-description"), 0, 0, variantForPath(path));
++            QAccessibleInterface *iface = event->accessibleInterface();
++            if (!iface) {
++                qCDebug(lcAccessibilityAtspi,
++                        "DescriptionChanged event from invalid accessible.");
++                return;
++            }
++
++            QString path = pathForInterface(iface);
++            QVariantList args = packDBusSignalArguments(
++                QLatin1String("accessible-description"), 0, 0,
++                QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Description))));
+             sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                            QLatin1String("PropertyChange"), args);
+         }
+@@ -1038,7 +1059,9 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+                 // Combo Box with AT-SPI likes to be special
+                 // It requires a name-change to update caches and then selection-changed
+                 QString path = pathForInterface(iface);
+-                QVariantList args1 = packDBusSignalArguments(QLatin1String("accessible-name"), 0, 0, variantForPath(path));
++                QVariantList args1 = packDBusSignalArguments(
++                    QLatin1String("accessible-name"), 0, 0,
++                    QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Name))));
+                 sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                                QLatin1String("PropertyChange"), args1);
+                 QVariantList args2 = packDBusSignalArguments(QString(), 0, 0, QVariant::fromValue(QDBusVariant(QVariant(0))));
+@@ -1358,6 +1381,26 @@ void AtSpiAdaptor::registerApplication()
+     delete registry;
+ }
+ 
++namespace {
++QString accessibleIdForAccessible(QAccessibleInterface *accessible)
++{
++    QString result;
++    while (accessible) {
++        if (!result.isEmpty())
++            result.prepend(QLatin1Char('.'));
++        if (auto obj = accessible->object()) {
++            const QString name = obj->objectName();
++            if (!name.isEmpty())
++                result.prepend(name);
++            else
++                result.prepend(QString::fromUtf8(obj->metaObject()->className()));
++        }
++        accessible = accessible->parent();
++    }
++    return result;
++}
++} // namespace
++
+ // Accessible
+ bool AtSpiAdaptor::accessibleInterface(QAccessibleInterface *interface, const QString &function, const QDBusMessage &message, const QDBusConnection &connection)
+ {
+@@ -1441,6 +1484,9 @@ bool AtSpiAdaptor::accessibleInterface(QAccessibleInterface *interface, const QS
+             children << ref;
+         }
+         connection.send(message.createReply(QVariant::fromValue(children)));
++    } else if (function == QLatin1String("GetAccessibleId")) {
++        sendReply(connection, message,
++                  QVariant::fromValue(QDBusVariant(accessibleIdForAccessible(interface))));
+     } else {
+         qCDebug(lcAccessibilityAtspi) << "WARNING: AtSpiAdaptor::accessibleInterface does not implement " << function << message.path();
+         return false;
+diff --git a/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp b/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
+index 45ddc8e496..cc734abc63 100644
+--- a/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
++++ b/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
+@@ -69,6 +69,21 @@ QT_BEGIN_NAMESPACE
+ DBusConnection::DBusConnection(QObject *parent)
+     : QObject(parent), m_a11yConnection(QString()), m_enabled(false)
+ {
++    // If the bus is explicitly set via env var it overrides everything else.
++    QByteArray addressEnv = qgetenv("AT_SPI_BUS_ADDRESS");
++    if (!addressEnv.isEmpty()) {
++        // Only connect on next loop run, connections to our enabled signal are
++        // only established after the ctor returns.
++        QMetaObject::invokeMethod(
++                this,
++                [this, addressEnv] {
++                    m_enabled = true;
++                    connectA11yBus(QString::fromLocal8Bit(addressEnv));
++                },
++                Qt::QueuedConnection);
++        return;
++    }
++
+     // Start monitoring if "org.a11y.Bus" is registered as DBus service.
+     QDBusConnection c = QDBusConnection::sessionBus();
+     if (!c.isConnected()) {
+diff --git a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
+index 1a3cab275d..2abe039126 100644
+--- a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
++++ b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
+@@ -51,6 +51,9 @@
+ #include <QtCore/QStandardPaths>
+ #include <QtCore/QUrl>
+ 
++#include <QtGui/QGuiApplication>
++#include <QtGui/QWindow>
++
+ #if QT_CONFIG(dbus)
+ // These QtCore includes are needed for xdg-desktop-portal support
+ #include <QtCore/private/qcore_unix_p.h>
+@@ -58,6 +61,8 @@
+ #include <QtCore/QFileInfo>
+ #include <QtCore/QUrlQuery>
+ 
++#include <QtGui/QColor>
++
+ #include <QtDBus/QDBusConnection>
+ #include <QtDBus/QDBusMessage>
+ #include <QtDBus/QDBusPendingCall>
+@@ -142,6 +147,8 @@ static inline bool detectWebBrowser(const QByteArray &desktop,
+     }
+ 
+     if (desktop == QByteArray("KDE")) {
++        if (checkExecutable(QStringLiteral("kde-open5"), browser))
++            return true;
+         // Konqueror launcher
+         if (checkExecutable(QStringLiteral("kfmclient"), browser)) {
+             browser->append(QLatin1String(" exec"));
+@@ -296,8 +303,135 @@ static inline QDBusMessage xdgDesktopPortalSendEmail(const QUrl &url)
+ 
+     return QDBusConnection::sessionBus().call(message);
+ }
++
++namespace {
++struct XDGDesktopColor
++{
++    double r = 0;
++    double g = 0;
++    double b = 0;
++
++    QColor toQColor() const
++    {
++        constexpr auto rgbMax = 255;
++        return { static_cast<int>(r * rgbMax), static_cast<int>(g * rgbMax),
++                 static_cast<int>(b * rgbMax) };
++    }
++};
++
++const QDBusArgument &operator>>(const QDBusArgument &argument, XDGDesktopColor &myStruct)
++{
++    argument.beginStructure();
++    argument >> myStruct.r >> myStruct.g >> myStruct.b;
++    argument.endStructure();
++    return argument;
++}
++
++class XdgDesktopPortalColorPicker : public QPlatformServiceColorPicker
++{
++    Q_OBJECT
++public:
++    XdgDesktopPortalColorPicker(const QString &parentWindowId, QWindow *parent)
++        : QPlatformServiceColorPicker(parent), m_parentWindowId(parentWindowId)
++    {
++    }
++
++    void pickColor() override
++    {
++        // DBus signature:
++        // PickColor (IN   s      parent_window,
++        //            IN   a{sv}  options
++        //            OUT  o      handle)
++        // Options:
++        // handle_token (s) -  A string that will be used as the last element of the @handle.
++
++        QDBusMessage message = QDBusMessage::createMethodCall(
++                QStringLiteral("org.freedesktop.portal.Desktop"), QStringLiteral("/org/freedesktop/portal/desktop"),
++                QStringLiteral("org.freedesktop.portal.Screenshot"), QStringLiteral("PickColor"));
++        message << m_parentWindowId << QVariantMap();
++
++        QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
++        auto watcher = new QDBusPendingCallWatcher(pendingCall, this);
++        connect(watcher, &QDBusPendingCallWatcher::finished, this,
++                [this](QDBusPendingCallWatcher *watcher) {
++                    watcher->deleteLater();
++                    QDBusPendingReply<QDBusObjectPath> reply = *watcher;
++                    if (reply.isError()) {
++                        qWarning("DBus call to pick color failed: %s",
++                                 qPrintable(reply.error().message()));
++                        Q_EMIT colorPicked({});
++                    } else {
++                        QDBusConnection::sessionBus().connect(
++                                QStringLiteral("org.freedesktop.portal.Desktop"), reply.value().path(),
++                                QStringLiteral("org.freedesktop.portal.Request"), QStringLiteral("Response"), this,
++                                // clang-format off
++                                SLOT(gotColorResponse(uint,QVariantMap))
++                                // clang-format on
++                        );
++                    }
++                });
++    }
++
++private Q_SLOTS:
++    void gotColorResponse(uint result, const QVariantMap &map)
++    {
++        if (result != 0)
++            return;
++        XDGDesktopColor color{};
++        map.value(QStringLiteral("color")).value<QDBusArgument>() >> color;
++        Q_EMIT colorPicked(color.toQColor());
++        deleteLater();
++    }
++
++private:
++    const QString m_parentWindowId;
++};
++} // namespace
++
+ #endif // QT_CONFIG(dbus)
+ 
++QGenericUnixServices::QGenericUnixServices()
++{
++#if QT_CONFIG(dbus)
++    if (qEnvironmentVariableIntValue("QT_NO_XDG_DESKTOP_PORTAL") > 0) {
++        return;
++    }
++    QDBusMessage message = QDBusMessage::createMethodCall(
++            QStringLiteral("org.freedesktop.portal.Desktop"), QStringLiteral("/org/freedesktop/portal/desktop"),
++            QStringLiteral("org.freedesktop.DBus.Properties"), QStringLiteral("Get"));
++    message << QStringLiteral("org.freedesktop.portal.Screenshot")
++            << QStringLiteral("version");
++
++    QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
++    auto watcher = new QDBusPendingCallWatcher(pendingCall);
++    QObject::connect(watcher, &QDBusPendingCallWatcher::finished, watcher,
++                     [this](QDBusPendingCallWatcher *watcher) {
++                         watcher->deleteLater();
++                         QDBusPendingReply<QVariant> reply = *watcher;
++                         if (!reply.isError() && reply.value().toUInt() >= 2)
++                             m_hasScreenshotPortalWithColorPicking = true;
++                     });
++
++#endif
++}
++
++QPlatformServiceColorPicker *QGenericUnixServices::colorPicker(QWindow *parent)
++{
++#if QT_CONFIG(dbus)
++    // Make double sure that we are in a wayland environment. In particular check
++    // WAYLAND_DISPLAY so also XWayland apps benefit from portal-based color picking.
++    // Outside wayland we'll rather rely on other means than the XDG desktop portal.
++    if (!qEnvironmentVariableIsEmpty("WAYLAND_DISPLAY")
++        || QGuiApplication::platformName().startsWith(QLatin1String("wayland"))) {
++        return new XdgDesktopPortalColorPicker(portalWindowIdentifier(parent), parent);
++    }
++    return nullptr;
++#else
++    Q_UNUSED(parent);
++    return nullptr;
++#endif
++}
++
+ QByteArray QGenericUnixServices::desktopEnvironment() const
+ {
+     static const QByteArray result = detectDesktopEnvironment();
+@@ -352,6 +486,8 @@ bool QGenericUnixServices::openDocument(const QUrl &url)
+ }
+ 
+ #else
++QGenericUnixServices::QGenericUnixServices() = default;
++
+ QByteArray QGenericUnixServices::desktopEnvironment() const
+ {
+     return QByteArrayLiteral("UNKNOWN");
+@@ -371,6 +507,30 @@ bool QGenericUnixServices::openDocument(const QUrl &url)
+     return false;
+ }
+ 
++QPlatformServiceColorPicker *QGenericUnixServices::colorPicker(QWindow *parent)
++{
++    Q_UNUSED(parent);
++    return nullptr;
++}
++
+ #endif // QT_NO_MULTIPROCESS
+ 
++QString QGenericUnixServices::portalWindowIdentifier(QWindow *window)
++{
++    if (QGuiApplication::platformName() == QLatin1String("xcb"))
++        return QStringLiteral("x11:") + QString::number(window->winId(), 16);
++    return QString();
++}
++
++bool QGenericUnixServices::hasCapability(Capability capability) const
++{
++    switch (capability) {
++    case Capability::ColorPicking:
++        return m_hasScreenshotPortalWithColorPicking;
++    }
++    return false;
++}
++
+ QT_END_NAMESPACE
++
++#include "qgenericunixservices.moc"
+diff --git a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
+index 8ac3de6f03..30924e64bd 100644
+--- a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
++++ b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
+@@ -59,16 +59,21 @@ QT_BEGIN_NAMESPACE
+ class QGenericUnixServices : public QPlatformServices
+ {
+ public:
+-    QGenericUnixServices() {}
++    QGenericUnixServices();
+ 
+     QByteArray desktopEnvironment() const override;
+ 
++    bool hasCapability(Capability capability) const override;
+     bool openUrl(const QUrl &url) override;
+     bool openDocument(const QUrl &url) override;
++    QPlatformServiceColorPicker *colorPicker(QWindow *parent = nullptr) override;
++
++    virtual QString portalWindowIdentifier(QWindow *window);
+ 
+ private:
+     QString m_webBrowser;
+     QString m_documentLauncher;
++    bool m_hasScreenshotPortalWithColorPicking = false;
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
+index 09470bccc6..cc7c7d4d8a 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
+@@ -69,6 +69,7 @@ const QString MenuBarPath = QLatin1String("/MenuBar");
+ */
+ QDBusMenuConnection::QDBusMenuConnection(QObject *parent, const QString &serviceName)
+     : QObject(parent)
++    , m_serviceName(serviceName)
+     , m_connection(serviceName.isNull() ? QDBusConnection::sessionBus()
+                                         : QDBusConnection::connectToBus(QDBusConnection::SessionBus, serviceName))
+     , m_dbusWatcher(new QDBusServiceWatcher(StatusNotifierWatcherService, m_connection, QDBusServiceWatcher::WatchForRegistration, this))
+@@ -83,6 +84,12 @@ QDBusMenuConnection::QDBusMenuConnection(QObject *parent, const QString &service
+ #endif
+ }
+ 
++QDBusMenuConnection::~QDBusMenuConnection()
++{
++  if (!m_serviceName.isEmpty() && m_connection.isConnected())
++      QDBusConnection::disconnectFromBus(m_serviceName);
++}
++
+ void QDBusMenuConnection::dbusError(const QDBusError &error)
+ {
+     qWarning() << "QDBusTrayIcon encountered a D-Bus error:" << error;
+@@ -105,13 +112,7 @@ void QDBusMenuConnection::unregisterTrayIconMenu(QDBusTrayIcon *item)
+ 
+ bool QDBusMenuConnection::registerTrayIcon(QDBusTrayIcon *item)
+ {
+-    bool success = connection().registerService(item->instanceId());
+-    if (!success) {
+-        qWarning() << "failed to register service" << item->instanceId();
+-        return false;
+-    }
+-
+-    success = connection().registerObject(StatusNotifierItemPath, item);
++    bool success = connection().registerObject(StatusNotifierItemPath, item);
+     if (!success) {
+         unregisterTrayIcon(item);
+         qWarning() << "failed to register" << item->instanceId() << StatusNotifierItemPath;
+@@ -126,21 +127,18 @@ bool QDBusMenuConnection::registerTrayIcon(QDBusTrayIcon *item)
+ 
+ bool QDBusMenuConnection::registerTrayIconWithWatcher(QDBusTrayIcon *item)
+ {
++    Q_UNUSED(item);
+     QDBusMessage registerMethod = QDBusMessage::createMethodCall(
+                 StatusNotifierWatcherService, StatusNotifierWatcherPath, StatusNotifierWatcherService,
+                 QLatin1String("RegisterStatusNotifierItem"));
+-    registerMethod.setArguments(QVariantList() << item->instanceId());
++    registerMethod.setArguments(QVariantList() << m_connection.baseService());
+     return m_connection.callWithCallback(registerMethod, this, SIGNAL(trayIconRegistered()), SLOT(dbusError(QDBusError)));
+ }
+ 
+-bool QDBusMenuConnection::unregisterTrayIcon(QDBusTrayIcon *item)
++void QDBusMenuConnection::unregisterTrayIcon(QDBusTrayIcon *item)
+ {
+     unregisterTrayIconMenu(item);
+     connection().unregisterObject(StatusNotifierItemPath);
+-    bool success = connection().unregisterService(item->instanceId());
+-    if (!success)
+-        qWarning() << "failed to unregister service" << item->instanceId();
+-    return success;
+ }
+ #endif // QT_NO_SYSTEMTRAYICON
+ 
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
+index f484795fbb..97bdfabb85 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
++++ b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
+@@ -70,6 +70,7 @@ class QDBusMenuConnection : public QObject
+ 
+ public:
+     QDBusMenuConnection(QObject *parent = nullptr, const QString &serviceName = QString());
++    ~QDBusMenuConnection();
+     QDBusConnection connection() const { return m_connection; }
+     QDBusServiceWatcher *dbusWatcher() const { return m_dbusWatcher; }
+     bool isStatusNotifierHostRegistered() const { return m_statusNotifierHostRegistered; }
+@@ -78,7 +79,7 @@ public:
+     void unregisterTrayIconMenu(QDBusTrayIcon *item);
+     bool registerTrayIcon(QDBusTrayIcon *item);
+     bool registerTrayIconWithWatcher(QDBusTrayIcon *item);
+-    bool unregisterTrayIcon(QDBusTrayIcon *item);
++    void unregisterTrayIcon(QDBusTrayIcon *item);
+ #endif // QT_NO_SYSTEMTRAYICON
+ 
+ Q_SIGNALS:
+@@ -90,6 +91,7 @@ private Q_SLOTS:
+     void dbusError(const QDBusError &error);
+ 
+ private:
++    QString m_serviceName;
+     QDBusConnection m_connection;
+     QDBusServiceWatcher *m_dbusWatcher;
+     bool m_statusNotifierHostRegistered;
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp b/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
+index bede70975a..76bfec5e5a 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
+@@ -71,8 +71,12 @@ Q_LOGGING_CATEGORY(qLcTray, "qt.qpa.tray")
+ static QString iconTempPath()
+ {
+     QString tempPath = QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation);
+-    if (!tempPath.isEmpty())
++    if (!tempPath.isEmpty()) {
++        QString flatpakId = qEnvironmentVariable("FLATPAK_ID");
++        if (!flatpakId.isEmpty() && QFileInfo::exists(QLatin1String("/.flatpak-info")))
++            tempPath += QLatin1String("/app/") + flatpakId;
+         return tempPath;
++    }
+ 
+     tempPath = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation);
+ 
+diff --git a/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+index cb1b39db64..6e01af052c 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+@@ -755,6 +755,9 @@ QVariant QGnomeTheme::themeHint(QPlatformTheme::ThemeHint hint) const
+         return QVariant(QChar(0x2022));
+     case QPlatformTheme::UiEffects:
+         return QVariant(int(HoverEffect));
++    case QPlatformTheme::ButtonPressKeys:
++        return QVariant::fromValue(
++                QList<Qt::Key>({ Qt::Key_Space, Qt::Key_Return, Qt::Key_Enter, Qt::Key_Select }));
+     default:
+         break;
+     }
+diff --git a/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp b/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
+index 98e05195ee..1e92f43dec 100644
+--- a/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
++++ b/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
+@@ -343,8 +343,7 @@ void QEglFSCursor::paintOnScreen()
+     // screens are siblings of each other. When not enabled, the sibling list
+     // only contains m_screen itself.
+     for (QPlatformScreen *screen : m_screen->virtualSiblings()) {
+-        if (screen->geometry().contains(cr.topLeft().toPoint() + m_cursor.hotSpot)
+-            && QOpenGLContext::currentContext()->screen() == screen->screen())
++        if (screen->geometry().contains(cr.topLeft().toPoint() + m_cursor.hotSpot))
+         {
+             cr.translate(-screen->geometry().topLeft());
+             const QSize screenSize = screen->geometry().size();
+@@ -468,11 +467,12 @@ void QEglFSCursor::draw(const QRectF &r)
+ {
+     StateSaver stateSaver;
+ 
+-    QEglFSCursorData &gfx = static_cast<QEglFSContext*>(QOpenGLContext::currentContext()->handle())->cursorData;
+-    if (!gfx.program) {
+-        // one time initialization
++    // one time initialization
++    if (!QOpenGLFunctions::d_ptr)
+         initializeOpenGLFunctions();
+ 
++    QEglFSCursorData &gfx = static_cast<QEglFSContext*>(QOpenGLContext::currentContext()->handle())->cursorData;
++    if (!gfx.program) {
+         createShaderPrograms();
+ 
+         if (!gfx.atlasTexture) {
+diff --git a/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp b/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
+index 645a0ae2e9..3e0e406f1a 100644
+--- a/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
++++ b/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
+@@ -179,7 +179,7 @@ void QEglFSKmsEventReader::create(QEglFSKmsDevice *device)
+ 
+     m_device = device;
+ 
+-    qCDebug(qLcEglfsKmsDebug, "Initalizing event reader for device %p fd %d",
++    qCDebug(qLcEglfsKmsDebug, "Initializing event reader for device %p fd %d",
+             m_device, m_device->fd());
+ 
+     m_thread = new QEglFSKmsEventReaderThread(m_device->fd());
+diff --git a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
+index 141fb68a23..d4294d425a 100644
+--- a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
++++ b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
+@@ -122,11 +122,13 @@ QOffscreenIntegration::QOffscreenIntegration()
+ #endif
+     m_services.reset(new QPlatformServices);
+ 
+-    QWindowSystemInterface::handleScreenAdded(new QOffscreenScreen);
++    m_screen = new QOffscreenScreen;
++    QWindowSystemInterface::handleScreenAdded(m_screen);
+ }
+ 
+ QOffscreenIntegration::~QOffscreenIntegration()
+ {
++    QWindowSystemInterface::handleScreenRemoved(m_screen);
+ }
+ 
+ void QOffscreenIntegration::initialize()
+diff --git a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
+index 0ea90f6c2f..fe00fde07c 100644
+--- a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
++++ b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
+@@ -84,6 +84,7 @@ protected:
+ #endif
+     QScopedPointer<QPlatformInputContext> m_inputContext;
+     QScopedPointer<QPlatformServices> m_services;
++    QPlatformScreen *m_screen;
+     mutable QScopedPointer<QPlatformNativeInterface> m_nativeInterface;
+ };
+ 
+diff --git a/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp b/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
+index 6fa5a8a2b3..1f49f0aefd 100644
+--- a/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
++++ b/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
+@@ -48,6 +48,7 @@
+ #include <qpa/qplatformnativeinterface.h>
+ #include <QtPlatformHeaders/qwglnativecontext.h>
+ 
++#include <private/qsystemlibrary_p.h>
+ #include <algorithm>
+ 
+ #include <wingdi.h>
+@@ -162,19 +163,25 @@ QFunctionPointer QWindowsOpengl32DLL::resolve(const char *name)
+ 
+ bool QWindowsOpengl32DLL::init(bool softwareRendering)
+ {
+-    const QByteArray opengl32 = QByteArrayLiteral("opengl32.dll");
+-    const QByteArray swopengl = QByteArrayLiteral("opengl32sw.dll");
++    const QByteArray opengl32 = QByteArrayLiteral("opengl32");
++    const QByteArray swopengl = QByteArrayLiteral("opengl32sw");
++    bool useSystemLib = false;
+ 
+     QByteArray openglDll = qgetenv("QT_OPENGL_DLL");
+-    if (openglDll.isEmpty())
++    if (openglDll.isEmpty()) {
+         openglDll = softwareRendering ? swopengl : opengl32;
++        useSystemLib = !softwareRendering;
++    }
+ 
+     openglDll = openglDll.toLower();
+     m_nonOpengl32 = openglDll != opengl32;
+ 
+     qCDebug(lcQpaGl) << "Qt: Using WGL and OpenGL from" << openglDll;
+ 
+-    m_lib = ::LoadLibraryA(openglDll.constData());
++    if (useSystemLib)
++        m_lib = QSystemLibrary::load((wchar_t*)(QString::fromLatin1(openglDll).utf16()));
++    else
++        m_lib = LoadLibraryA(openglDll.constData());
+     if (!m_lib) {
+         qErrnoWarning(::GetLastError(), "Failed to load %s", openglDll.constData());
+         return false;
+@@ -184,7 +191,7 @@ bool QWindowsOpengl32DLL::init(bool softwareRendering)
+         // Load opengl32.dll always. GDI functions like ChoosePixelFormat do
+         // GetModuleHandle for opengl32.dll and behave differently (and call back into
+         // opengl32) when the module is present. This is fine for dummy contexts and windows.
+-        ::LoadLibraryA("opengl32.dll");
++        QSystemLibrary::load(L"opengl32");
+     }
+ 
+     wglCreateContext = reinterpret_cast<HGLRC (WINAPI *)(HDC)>(resolve("wglCreateContext"));
+diff --git a/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp b/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
+index d7d186e804..9eb4011bf2 100644
+--- a/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
++++ b/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
+@@ -49,6 +49,7 @@
+ #include <QtCore/qstandardpaths.h>
+ #include <QtCore/qlibraryinfo.h>
+ #include <QtCore/qhash.h>
++#include <private/qsystemlibrary_p.h>
+ 
+ #ifndef QT_NO_OPENGL
+ #include <private/qopengl_p.h>
+@@ -396,7 +397,7 @@ bool QWindowsOpenGLTester::testDesktopGL()
+ 
+     // Test #1: Load opengl32.dll and try to resolve an OpenGL 2 function.
+     // This will typically fail on systems that do not have a real OpenGL driver.
+-    lib = LoadLibraryA("opengl32.dll");
++    lib = QSystemLibrary::load(L"opengl32");
+     if (lib) {
+         CreateContext = reinterpret_cast<CreateContextType>(
+             reinterpret_cast<QFunctionPointer>(::GetProcAddress(lib, "wglCreateContext")));
+diff --git a/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp b/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
+index 1afa00cfc9..118af6ce73 100644
+--- a/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
++++ b/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
+@@ -41,6 +41,7 @@
+ 
+ #include <QRect>
+ #include <QList>
++#include <QMap>
+ #include <QDebug>
+ 
+ #include <qmath.h>
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp b/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
+index 9e2a37a6a1..e6e175a118 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
+@@ -488,12 +488,12 @@ void QXcbConnection::printXcbError(const char *message, xcb_generic_error_t *err
+     uint clamped_error_code = qMin<uint>(error->error_code, (sizeof(xcb_errors) / sizeof(xcb_errors[0])) - 1);
+     uint clamped_major_code = qMin<uint>(error->major_code, (sizeof(xcb_protocol_request_codes) / sizeof(xcb_protocol_request_codes[0])) - 1);
+ 
+-    qCWarning(lcQpaXcb, "%s: %d (%s), sequence: %d, resource id: %d, major code: %d (%s), minor code: %d",
+-             message,
+-             int(error->error_code), xcb_errors[clamped_error_code],
+-             int(error->sequence), int(error->resource_id),
+-             int(error->major_code), xcb_protocol_request_codes[clamped_major_code],
+-             int(error->minor_code));
++    qCDebug(lcQpaXcb, "%s: %d (%s), sequence: %d, resource id: %d, major code: %d (%s), minor code: %d",
++            message,
++            int(error->error_code), xcb_errors[clamped_error_code],
++            int(error->sequence), int(error->resource_id),
++            int(error->major_code), xcb_protocol_request_codes[clamped_major_code],
++            int(error->minor_code));
+ }
+ 
+ static Qt::MouseButtons translateMouseButtons(int s)
+@@ -702,6 +702,8 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
+             QXcbVirtualDesktop *virtualDesktop = virtualDesktopForRootWindow(propertyNotify->window);
+             if (virtualDesktop)
+                 virtualDesktop->updateWorkArea();
++        } else if (propertyNotify->atom == atom(QXcbAtom::_NET_SUPPORTED)) {
++            m_wmSupport->updateNetWMAtoms();
+         } else {
+             HANDLE_PLATFORM_WINDOW_EVENT(xcb_property_notify_event_t, window, handlePropertyNotifyEvent);
+         }
+@@ -750,7 +752,7 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
+                 case XCB_XKB_NEW_KEYBOARD_NOTIFY: {
+                     xcb_xkb_new_keyboard_notify_event_t *ev = &xkb_event->new_keyboard_notify;
+                     if (ev->changed & XCB_XKB_NKN_DETAIL_KEYCODES)
+-                        m_keyboard->updateKeymap(ev);
++                        m_keyboard->updateKeymap();
+                     break;
+                 }
+                 default:
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp b/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
+index 76869ced60..02d2eebb56 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
+@@ -274,8 +274,7 @@ QPlatformWindow *QXcbIntegration::createForeignWindow(QWindow *window, WId nativ
+ #ifndef QT_NO_OPENGL
+ QPlatformOpenGLContext *QXcbIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
+ {
+-    QXcbScreen *screen = static_cast<QXcbScreen *>(context->screen()->handle());
+-    QXcbGlIntegration *glIntegration = screen->connection()->glIntegration();
++    QXcbGlIntegration *glIntegration = defaultConnection()->glIntegration();
+     if (!glIntegration) {
+         qWarning("QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled");
+         return nullptr;
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+index efecd7e2d1..e8286381a2 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+@@ -365,17 +365,6 @@ void QXcbKeyboard::updateKeymap(xcb_mapping_notify_event_t *event)
+     updateKeymap();
+ }
+ 
+-void QXcbKeyboard::updateKeymap(xcb_xkb_new_keyboard_notify_event_t *event)
+-{
+-    if (!event)
+-        return;
+-
+-    if (event->deviceID != event->oldDeviceID)
+-        m_config = false;
+-
+-    updateKeymap();
+-}
+-
+ void QXcbKeyboard::updateKeymap()
+ {
+     KeysymModifierMap keysymMods;
+@@ -383,6 +372,8 @@ void QXcbKeyboard::updateKeymap()
+         keysymMods = keysymsToModifiers();
+     updateModifiers(keysymMods);
+ 
++    m_config = true;
++
+     if (!m_xkbContext) {
+         m_xkbContext.reset(xkb_context_new(XKB_CONTEXT_NO_DEFAULT_INCLUDES));
+         if (!m_xkbContext) {
+@@ -398,13 +389,8 @@ void QXcbKeyboard::updateKeymap()
+     if (connection()->hasXKB()) {
+         m_xkbKeymap.reset(xkb_x11_keymap_new_from_device(m_xkbContext.get(), xcb_connection(),
+                                                          core_device_id, XKB_KEYMAP_COMPILE_NO_FLAGS));
+-        if (m_xkbKeymap) {
+-            if (m_config)
+-                m_xkbState.reset(xkb_state_new(m_xkbKeymap.get()));
+-            else
+-                m_xkbState.reset(xkb_x11_state_new_from_device(m_xkbKeymap.get(), xcb_connection(), core_device_id));
+-
+-        }
++        if (m_xkbKeymap)
++            m_xkbState.reset(xkb_x11_state_new_from_device(m_xkbKeymap.get(), xcb_connection(), core_device_id));
+     } else {
+         m_xkbKeymap.reset(keymapFromCore(keysymMods));
+         if (m_xkbKeymap)
+@@ -425,8 +411,6 @@ void QXcbKeyboard::updateKeymap()
+     updateXKBMods();
+ 
+     QXkbCommon::verifyHasLatinLayout(m_xkbKeymap.get());
+-
+-    m_config = true;
+ }
+ 
+ QList<int> QXcbKeyboard::possibleKeys(const QKeyEvent *event) const
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
+index b652c85fe3..0ee08aeff2 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
++++ b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
+@@ -69,7 +69,6 @@ public:
+ 
+     Qt::KeyboardModifiers translateModifiers(int s) const;
+     void updateKeymap(xcb_mapping_notify_event_t *event);
+-    void updateKeymap(xcb_xkb_new_keyboard_notify_event_t *event);
+     void updateKeymap();
+     QList<int> possibleKeys(const QKeyEvent *event) const;
+ 
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp b/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
+index ffda7b6a57..863e961f4c 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
+@@ -564,11 +564,6 @@ void QXcbWindow::setGeometry(const QRect &rect)
+ {
+     QPlatformWindow::setGeometry(rect);
+ 
+-    if (shouldDeferTask(Task::SetGeometry)) {
+-        m_deferredGeometry = rect;
+-        return;
+-    }
+-
+     propagateSizeHints();
+ 
+     QXcbScreen *currentScreen = xcbScreen();
+@@ -693,9 +688,6 @@ void QXcbWindow::setVisible(bool visible)
+ 
+ void QXcbWindow::show()
+ {
+-    if (shouldDeferTask(Task::Map))
+-        return;
+-
+     if (window()->isTopLevel()) {
+ 
+         // update WM_NORMAL_HINTS
+@@ -706,7 +698,7 @@ void QXcbWindow::show()
+         if (isTransient(window())) {
+             const QWindow *tp = window()->transientParent();
+             if (tp && tp->handle())
+-                transientXcbParent = static_cast<const QXcbWindow *>(tp->handle())->winId();
++                transientXcbParent = tp->handle()->winId();
+             // Default to client leader if there is no transient parent, else modal dialogs can
+             // be hidden by their parents.
+             if (!transientXcbParent)
+@@ -746,10 +738,6 @@ void QXcbWindow::show()
+ 
+ void QXcbWindow::hide()
+ {
+-    if (shouldDeferTask(Task::Unmap))
+-        return;
+-
+-    m_wmStateValid = false;
+     xcb_unmap_window(xcb_connection(), m_window);
+ 
+     // send synthetic UnmapNotify event according to icccm 4.1.4
+@@ -909,9 +897,6 @@ QXcbWindow::NetWmStates QXcbWindow::netWmStates()
+ 
+ void QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
+ {
+-    if (shouldDeferTask(Task::SetWindowFlags))
+-        return;
+-
+     Qt::WindowType type = static_cast<Qt::WindowType>(int(flags & Qt::WindowType_Mask));
+ 
+     if (type == Qt::ToolTip)
+@@ -941,8 +926,6 @@ void QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
+ 
+     setTransparentForMouseEvents(flags & Qt::WindowTransparentForInput);
+     updateDoesNotAcceptFocus(flags & Qt::WindowDoesNotAcceptFocus);
+-
+-    m_isWmManagedWindow = !(flags & Qt::X11BypassWindowManagerHint);
+ }
+ 
+ void QXcbWindow::setMotifWmHints(Qt::WindowFlags flags)
+@@ -1142,9 +1125,6 @@ void QXcbWindow::setWindowState(Qt::WindowStates state)
+     if (state == m_windowState)
+         return;
+ 
+-    if (shouldDeferTask(Task::SetWindowState))
+-        return;
+-
+     // unset old state
+     if (m_windowState & Qt::WindowMinimized)
+         xcb_map_window(xcb_connection(), m_window);
+@@ -1350,6 +1330,12 @@ void QXcbWindow::setWindowIcon(const QIcon &icon)
+     }
+ 
+     if (!icon_data.isEmpty()) {
++        // Ignore icon exceeding maximum xcb request length
++        if (icon_data.size() > xcb_get_maximum_request_length(xcb_connection())) {
++            qWarning("Ignoring window icon: Size %llu exceeds maximum xcb request length %u.",
++                     icon_data.size(), xcb_get_maximum_request_length(xcb_connection()));
++            return;
++        }
+         xcb_change_property(xcb_connection(),
+                             XCB_PROP_MODE_REPLACE,
+                             m_window,
+@@ -1639,7 +1625,7 @@ void QXcbWindow::setWmWindowType(QXcbWindowFunctions::WmWindowTypes types, Qt::W
+         break;
+     }
+ 
+-    if ((flags & Qt::FramelessWindowHint) && !(type & QXcbWindowFunctions::KdeOverride)) {
++    if ((flags & Qt::FramelessWindowHint) && !(types & QXcbWindowFunctions::KdeOverride)) {
+         // override netwm type - quick and easy for KDE noborder
+         atoms.append(atom(QXcbAtom::_KDE_NET_WM_WINDOW_TYPE_OVERRIDE));
+     }
+@@ -1894,10 +1880,6 @@ void QXcbWindow::handleUnmapNotifyEvent(const xcb_unmap_notify_event_t *event)
+     if (event->window == m_window) {
+         m_mapped = false;
+         QWindowSystemInterface::handleExposeEvent(window(), QRegion());
+-        if (!m_isWmManagedWindow || parent()) {
+-            m_wmStateValid = true;
+-            handleDeferredTasks();
+-        }
+     }
+ }
+ 
+@@ -2212,98 +2194,30 @@ void QXcbWindow::handleLeaveNotifyEvent(const xcb_leave_notify_event_t *event)
+     handleLeaveNotifyEvent(event->root_x, event->root_y, event->mode, event->detail, event->time);
+ }
+ 
+-bool QXcbWindow::shouldDeferTask(Task task)
+-{
+-    if (m_wmStateValid)
+-        return false;
+-
+-    m_deferredTasks.append(task);
+-    return true;
+-}
+-
+-void QXcbWindow::handleDeferredTasks()
+-{
+-    Q_ASSERT(m_wmStateValid == true);
+-    if (m_deferredTasks.isEmpty())
+-        return;
+-
+-    bool map = false;
+-    bool unmap = false;
+-
+-    QVector<Task> tasks;
+-    for (auto taskIt = m_deferredTasks.rbegin(); taskIt != m_deferredTasks.rend(); ++taskIt) {
+-        if (!tasks.contains(*taskIt))
+-            tasks.prepend(*taskIt);
+-    }
+-
+-    for (Task task : tasks) {
+-        switch (task) {
+-        case Task::Map:
+-            map = true;
+-            unmap = false;
+-            break;
+-        case Task::Unmap:
+-            unmap = true;
+-            map = false;
+-            break;
+-        case Task::SetGeometry:
+-            setGeometry(m_deferredGeometry);
+-            break;
+-        case Task::SetWindowFlags:
+-            setWindowFlags(window()->flags());
+-            break;
+-        case Task::SetWindowState:
+-            setWindowState(window()->windowState());
+-            break;
+-        }
+-    }
+-    m_deferredTasks.clear();
+-
+-    if (map) {
+-        Q_ASSERT(unmap == false);
+-        show();
+-    }
+-    if (unmap) {
+-        Q_ASSERT(map == false);
+-        hide();
+-    }
+-}
+-
+ void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *event)
+ {
+     connection()->setTime(event->time);
+ 
+-    const bool wmStateChanged = event->atom == atom(QXcbAtom::WM_STATE);
+-    const bool netWmStateChanged = event->atom == atom(QXcbAtom::_NET_WM_STATE);
+-    if (netWmStateChanged || wmStateChanged) {
+-        if (wmStateChanged && !m_wmStateValid && m_isWmManagedWindow) {
+-            // ICCCM 4.1.4
+-            // Clients that want to re-use a client window (e.g. by mapping it again)
+-            // after withdrawing it must wait for the withdrawal to be complete before
+-            // proceeding. The preferred method for doing this is for clients to wait for
+-            // a window manager to update or remove the WM_STATE property.
+-            m_wmStateValid = true;
+-            handleDeferredTasks();
+-        }
+-        if (event->state == XCB_PROPERTY_DELETE)
++    const bool propertyDeleted = event->state == XCB_PROPERTY_DELETE;
++
++    if (event->atom == atom(QXcbAtom::_NET_WM_STATE) || event->atom == atom(QXcbAtom::WM_STATE)) {
++        if (propertyDeleted)
+             return;
+ 
+-        if (wmStateChanged) {
++        Qt::WindowStates newState = Qt::WindowNoState;
++
++        if (event->atom == atom(QXcbAtom::WM_STATE)) { // WM_STATE: Quick check for 'Minimize'.
+             auto reply = Q_XCB_REPLY(xcb_get_property, xcb_connection(),
+                                      0, m_window, atom(QXcbAtom::WM_STATE),
+                                      XCB_ATOM_ANY, 0, 1024);
+             if (reply && reply->format == 32 && reply->type == atom(QXcbAtom::WM_STATE)) {
+-                auto data = static_cast<const quint32 *>(xcb_get_property_value(reply.get()));
+-                if (reply->length != 0) {
+-                    const bool changedToWithdrawn = data[0] == XCB_ICCCM_WM_STATE_WITHDRAWN;
+-                    const bool changedToIconic = data[0] == XCB_ICCCM_WM_STATE_ICONIC;
+-                    m_minimized = changedToIconic || (changedToWithdrawn && m_minimized);
+-                }
++                const quint32 *data = (const quint32 *)xcb_get_property_value(reply.get());
++                if (reply->length != 0)
++                    m_minimized = (data[0] == XCB_ICCCM_WM_STATE_ICONIC
++                                   || (data[0] == XCB_ICCCM_WM_STATE_WITHDRAWN && m_minimized));
+             }
+         }
+ 
+-        // _NET_WM_STATE handling
+-        Qt::WindowStates newState = Qt::WindowNoState;
+         const NetWmStates states = netWmStates();
+         // _NET_WM_STATE_HIDDEN should be set by the Window Manager to indicate that a window would
+         // not be visible on the screen if its desktop/viewport were active and its coordinates were
+@@ -2325,6 +2239,7 @@ void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *ev
+             if ((m_windowState & Qt::WindowMinimized) && connection()->mouseGrabber() == this)
+                 connection()->setMouseGrabber(nullptr);
+         }
++        return;
+     } else if (event->atom == atom(QXcbAtom::_NET_FRAME_EXTENTS)) {
+         m_dirtyFrameMargins = true;
+     }
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbwindow.h b/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
+index 55af9279b1..6f5c1f5ed9 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
++++ b/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
+@@ -74,14 +74,6 @@ public:
+ 
+     Q_DECLARE_FLAGS(NetWmStates, NetWmState)
+ 
+-    enum Task {
+-        Map,
+-        Unmap,
+-        SetGeometry,
+-        SetWindowFlags,
+-        SetWindowState
+-    };
+-
+     QXcbWindow(QWindow *window);
+     ~QXcbWindow();
+ 
+@@ -151,9 +143,6 @@ public:
+ 
+     QXcbWindow *toWindow() override;
+ 
+-    bool shouldDeferTask(Task task);
+-    void handleDeferredTasks();
+-
+     void handleMouseEvent(xcb_timestamp_t time, const QPoint &local, const QPoint &global,
+                           Qt::KeyboardModifiers modifiers, QEvent::Type type, Qt::MouseEventSource source);
+ 
+@@ -292,11 +281,6 @@ protected:
+     int m_swapInterval = -1;
+ 
+     qreal m_sizeHintsScaleFactor = 1.0;
+-
+-    bool m_wmStateValid = true;
+-    QVector<Task> m_deferredTasks;
+-    bool m_isWmManagedWindow = true;
+-    QRect m_deferredGeometry;
+ };
+ 
+ class QXcbForeignWindow : public QXcbWindow
+diff --git a/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp b/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
+index d9d117faeb..640b49daa0 100644
+--- a/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
++++ b/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
+@@ -85,6 +85,7 @@ QGtk3MenuItem::QGtk3MenuItem()
+       m_checkable(false),
+       m_checked(false),
+       m_enabled(true),
++      m_exclusive(false),
+       m_underline(false),
+       m_invalid(true),
+       m_menu(nullptr),
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
+index 0048bbc1e6..396e7f6d1c 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
+@@ -102,15 +102,12 @@ const QDBusArgument &operator >>(const QDBusArgument &arg, QXdgDesktopPortalFile
+ class QXdgDesktopPortalFileDialogPrivate
+ {
+ public:
+-    QXdgDesktopPortalFileDialogPrivate(QPlatformFileDialogHelper *nativeFileDialog)
++    QXdgDesktopPortalFileDialogPrivate(QPlatformFileDialogHelper *nativeFileDialog, uint fileChooserPortalVersion)
+         : nativeFileDialog(nativeFileDialog)
++        , fileChooserPortalVersion(fileChooserPortalVersion)
+     { }
+ 
+-    WId winId = 0;
+-    bool directoryMode = false;
+-    bool modal = false;
+-    bool multipleFiles = false;
+-    bool saveFile = false;
++    QEventLoop loop;
+     QString acceptLabel;
+     QString directory;
+     QString title;
+@@ -121,19 +118,27 @@ public:
+     QString selectedMimeTypeFilter;
+     QString selectedNameFilter;
+     QStringList selectedFiles;
+-    QPlatformFileDialogHelper *nativeFileDialog = nullptr;
++    std::unique_ptr<QPlatformFileDialogHelper> nativeFileDialog;
++    uint fileChooserPortalVersion = 0;
++    bool failedToOpen = false;
++    bool directoryMode = false;
++    bool multipleFiles = false;
++    bool saveFile = false;
+ };
+ 
+-QXdgDesktopPortalFileDialog::QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog)
++QXdgDesktopPortalFileDialog::QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog, uint fileChooserPortalVersion)
+     : QPlatformFileDialogHelper()
+-    , d_ptr(new QXdgDesktopPortalFileDialogPrivate(nativeFileDialog))
++    , d_ptr(new QXdgDesktopPortalFileDialogPrivate(nativeFileDialog, fileChooserPortalVersion))
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+     if (d->nativeFileDialog) {
+-        connect(d->nativeFileDialog, SIGNAL(accept()), this, SIGNAL(accept()));
+-        connect(d->nativeFileDialog, SIGNAL(reject()), this, SIGNAL(reject()));
++        connect(d->nativeFileDialog.get(), SIGNAL(accept()), this, SIGNAL(accept()));
++        connect(d->nativeFileDialog.get(), SIGNAL(reject()), this, SIGNAL(reject()));
+     }
++
++    d->loop.connect(this, SIGNAL(accept()), SLOT(quit()));
++    d->loop.connect(this, SIGNAL(reject()), SLOT(quit()));
+ }
+ 
+ QXdgDesktopPortalFileDialog::~QXdgDesktopPortalFileDialog()
+@@ -177,7 +182,7 @@ void QXdgDesktopPortalFileDialog::initializeDialog()
+     setDirectory(options()->initialDirectory());
+ }
+ 
+-void QXdgDesktopPortalFileDialog::openPortal()
++void QXdgDesktopPortalFileDialog::openPortal(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent)
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+@@ -185,13 +190,13 @@ void QXdgDesktopPortalFileDialog::openPortal()
+                                                           QLatin1String("/org/freedesktop/portal/desktop"),
+                                                           QLatin1String("org.freedesktop.portal.FileChooser"),
+                                                           d->saveFile ? QLatin1String("SaveFile") : QLatin1String("OpenFile"));
+-    QString parentWindowId = QLatin1String("x11:") + QString::number(d->winId, 16);
++    QString parentWindowId = QLatin1String("x11:") + QString::number(parent ? parent->winId() : 0, 16);
+ 
+     QVariantMap options;
+     if (!d->acceptLabel.isEmpty())
+         options.insert(QLatin1String("accept_label"), d->acceptLabel);
+ 
+-    options.insert(QLatin1String("modal"), d->modal);
++    options.insert(QLatin1String("modal"), windowModality != Qt::NonModal);
+     options.insert(QLatin1String("multiple"), d->multipleFiles);
+     options.insert(QLatin1String("directory"), d->directoryMode);
+ 
+@@ -290,10 +295,18 @@ void QXdgDesktopPortalFileDialog::openPortal()
+ 
+     QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
+     QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingCall);
+-    connect(watcher, &QDBusPendingCallWatcher::finished, this, [this] (QDBusPendingCallWatcher *watcher) {
++    connect(watcher, &QDBusPendingCallWatcher::finished, this, [=] (QDBusPendingCallWatcher *watcher) {
+         QDBusPendingReply<QDBusObjectPath> reply = *watcher;
+-        if (reply.isError()) {
+-            Q_EMIT reject();
++        // Any error means the dialog is not shown and we need to fallback
++        d->failedToOpen = reply.isError();
++        if (d->failedToOpen) {
++            if (d->nativeFileDialog) {
++                d->nativeFileDialog->show(windowFlags, windowModality, parent);
++                if (d->loop.isRunning())
++                    d->nativeFileDialog->exec();
++            } else {
++                Q_EMIT reject();
++            }
+         } else {
+             QDBusConnection::sessionBus().connect(nullptr,
+                                                   reply.value().path(),
+@@ -302,6 +315,7 @@ void QXdgDesktopPortalFileDialog::openPortal()
+                                                   this,
+                                                   SLOT(gotResponse(uint,QVariantMap)));
+         }
++        watcher->deleteLater();
+     });
+ }
+ 
+@@ -326,7 +340,7 @@ QUrl QXdgDesktopPortalFileDialog::directory() const
+ {
+     Q_D(const QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog())
+         return d->nativeFileDialog->directory();
+ 
+     return d->directory;
+@@ -348,7 +362,7 @@ QList<QUrl> QXdgDesktopPortalFileDialog::selectedFiles() const
+ {
+     Q_D(const QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog())
+         return d->nativeFileDialog->selectedFiles();
+ 
+     QList<QUrl> files;
+@@ -403,16 +417,13 @@ void QXdgDesktopPortalFileDialog::exec()
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly)) {
++    if (d->nativeFileDialog && useNativeFileDialog()) {
+         d->nativeFileDialog->exec();
+         return;
+     }
+ 
+     // HACK we have to avoid returning until we emit that the dialog was accepted or rejected
+-    QEventLoop loop;
+-    loop.connect(this, SIGNAL(accept()), SLOT(quit()));
+-    loop.connect(this, SIGNAL(reject()), SLOT(quit()));
+-    loop.exec();
++    d->loop.exec();
+ }
+ 
+ void QXdgDesktopPortalFileDialog::hide()
+@@ -429,13 +440,10 @@ bool QXdgDesktopPortalFileDialog::show(Qt::WindowFlags windowFlags, Qt::WindowMo
+ 
+     initializeDialog();
+ 
+-    d->modal = windowModality != Qt::NonModal;
+-    d->winId = parent ? parent->winId() : 0;
+-
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog(OpenFallback))
+         return d->nativeFileDialog->show(windowFlags, windowModality, parent);
+ 
+-    openPortal();
++    openPortal(windowFlags, windowModality, parent);
+ 
+     return true;
+ }
+@@ -465,4 +473,21 @@ void QXdgDesktopPortalFileDialog::gotResponse(uint response, const QVariantMap &
+     }
+ }
+ 
++bool QXdgDesktopPortalFileDialog::useNativeFileDialog(QXdgDesktopPortalFileDialog::FallbackType fallbackType) const
++{
++    Q_D(const QXdgDesktopPortalFileDialog);
++
++    if (d->failedToOpen && fallbackType != OpenFallback)
++        return true;
++
++    if (d->fileChooserPortalVersion < 3) {
++        if (options()->fileMode() == QFileDialogOptions::Directory)
++            return true;
++        else if (options()->fileMode() == QFileDialogOptions::DirectoryOnly)
++            return true;
++    }
++
++    return false;
++}
++
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
+index 4f4de96ecf..65e22a5cf2 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
+@@ -51,6 +51,11 @@ class QXdgDesktopPortalFileDialog : public QPlatformFileDialogHelper
+     Q_OBJECT
+     Q_DECLARE_PRIVATE(QXdgDesktopPortalFileDialog)
+ public:
++    enum FallbackType {
++        GenericFallback,
++        OpenFallback
++    };
++
+     enum ConditionType : uint {
+         GlobalPattern = 0,
+         MimeType = 1
+@@ -69,7 +74,7 @@ public:
+     };
+     typedef QVector<Filter> FilterList;
+ 
+-    QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog = nullptr);
++    QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog = nullptr, uint fileChooserPortalVersion = 0);
+     ~QXdgDesktopPortalFileDialog();
+ 
+     bool defaultNameFilterDisables() const override;
+@@ -92,7 +97,8 @@ private Q_SLOTS:
+ 
+ private:
+     void initializeDialog();
+-    void openPortal();
++    void openPortal(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent);
++    bool useNativeFileDialog(FallbackType fallbackType = GenericFallback) const;
+ 
+     QScopedPointer<QXdgDesktopPortalFileDialogPrivate> d_ptr;
+ };
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
+index fb324afbd8..b809503122 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
+@@ -111,6 +111,7 @@ QXdgDesktopPortalTheme::QXdgDesktopPortalTheme()
+         if (reply.isValid()) {
+             d->fileChooserPortalVersion = reply.value().toUInt();
+         }
++        watcher->deleteLater();
+     });
+ }
+ 
+@@ -152,11 +153,12 @@ QPlatformDialogHelper* QXdgDesktopPortalTheme::createPlatformDialogHelper(Dialog
+ {
+     Q_D(const QXdgDesktopPortalTheme);
+ 
+-    if (type == FileDialog) {
++    if (type == FileDialog && d->fileChooserPortalVersion) {
+         // Older versions of FileChooser portal don't support opening directories, therefore we fallback
+         // to native file dialog opened inside the sandbox to open a directory.
+-        if (d->fileChooserPortalVersion < 3 && d->baseTheme->usePlatformNativeDialog(type))
+-            return new QXdgDesktopPortalFileDialog(static_cast<QPlatformFileDialogHelper*>(d->baseTheme->createPlatformDialogHelper(type)));
++        if (d->baseTheme->usePlatformNativeDialog(type))
++            return new QXdgDesktopPortalFileDialog(static_cast<QPlatformFileDialogHelper*>(d->baseTheme->createPlatformDialogHelper(type)),
++                                                   d->fileChooserPortalVersion);
+ 
+         return new QXdgDesktopPortalFileDialog;
+     }
+diff --git a/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp b/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
+index 43d5e119ad..1f9cbc4565 100644
+--- a/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
++++ b/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
+@@ -89,8 +89,10 @@ void QCupsPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &v
+         break;
+     case PPK_Duplex: {
+         QPrint::DuplexMode mode = QPrint::DuplexMode(value.toInt());
+-        if (mode != d->duplex && d->m_printDevice.supportedDuplexModes().contains(mode))
++        if (d->m_printDevice.supportedDuplexModes().contains(mode)) {
+             d->duplex = mode;
++            d->duplexRequestedExplicitly = true;
++        }
+         break;
+     }
+     case PPK_PrinterName:
+@@ -277,9 +279,12 @@ void QCupsPrintEnginePrivate::changePrinter(const QString &newPrinter)
+     m_printDevice.swap(printDevice);
+     printerName = m_printDevice.id();
+ 
+-    // Check if new printer supports current settings, otherwise us defaults
+-    if (duplex != QPrint::DuplexAuto && !m_printDevice.supportedDuplexModes().contains(duplex))
++    // in case a duplex value was explicitly set, check if new printer supports current value,
++    // otherwise use device default
++    if (!duplexRequestedExplicitly || !m_printDevice.supportedDuplexModes().contains(duplex)) {
+         duplex = m_printDevice.defaultDuplexMode();
++        duplexRequestedExplicitly = false;
++    }
+     QPrint::ColorMode colorMode = grayscale ? QPrint::GrayScale : QPrint::Color;
+     if (!m_printDevice.supportedColorModes().contains(colorMode))
+         grayscale = m_printDevice.defaultColorMode() == QPrint::GrayScale;
+diff --git a/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h b/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
+index c021b0c643..8f81fe478d 100644
+--- a/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
++++ b/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
+@@ -100,6 +100,7 @@ private:
+     QStringList cupsOptions;
+     QString cupsTempFile;
+     QPrint::DuplexMode duplex;
++    bool duplexRequestedExplicitly = false;
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp b/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
+index 67e7154fa6..40876152e5 100644
+--- a/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
++++ b/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
+@@ -817,7 +817,7 @@ bool QIBaseResultPrivate::writeArray(int column, const QList<QVariant> &list)
+     ba.resize(int(bufLen));
+ 
+     if (list.size() > arraySize) {
+-        error = QLatin1String("Array size missmatch: size of %1 is %2, size of provided list is %3");
++        error = QLatin1String("Array size mismatch: size of %1 is %2, size of provided list is %3");
+         error = error.arg(QLatin1String(sqlname)).arg(arraySize).arg(list.size());
+         q->setLastError(QSqlError(error, QLatin1String(""), QSqlError::StatementError));
+         return false;
+diff --git a/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp b/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
+index 7ca055eea2..6bc9d46755 100644
+--- a/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
++++ b/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
+@@ -223,7 +223,7 @@ public:
+     struct QMyField
+     {
+         char *outField = nullptr;
+-        MYSQL_FIELD *myField = nullptr;
++        const MYSQL_FIELD *myField = nullptr;
+         QMetaType::Type type = QMetaType::UnknownType;
+         my_bool nullIndicator = false;
+         ulong bufLength = 0ul;
+@@ -361,7 +361,7 @@ static bool qIsInteger(int t)
+ void QMYSQLResultPrivate::bindBlobs()
+ {
+     int i;
+-    MYSQL_FIELD *fieldInfo;
++    const MYSQL_FIELD *fieldInfo;
+     MYSQL_BIND *bind;
+ 
+     for(i = 0; i < fields.count(); ++i) {
+@@ -379,7 +379,6 @@ void QMYSQLResultPrivate::bindBlobs()
+ bool QMYSQLResultPrivate::bindInValues()
+ {
+     MYSQL_BIND *bind;
+-    char *field;
+     int i = 0;
+ 
+     if (!meta)
+@@ -392,35 +391,34 @@ bool QMYSQLResultPrivate::bindInValues()
+     inBinds = new MYSQL_BIND[fields.size()];
+     memset(inBinds, 0, fields.size() * sizeof(MYSQL_BIND));
+ 
+-    MYSQL_FIELD *fieldInfo;
++    const MYSQL_FIELD *fieldInfo;
+ 
+     while((fieldInfo = mysql_fetch_field(meta))) {
++        bind = &inBinds[i];
++
+         QMyField &f = fields[i];
+         f.myField = fieldInfo;
+-
++        bind->buffer_length = f.bufLength = fieldInfo->length + 1;
++        bind->buffer_type = fieldInfo->type;
+         f.type = qDecodeMYSQLType(fieldInfo->type, fieldInfo->flags);
+         if (qIsBlob(fieldInfo->type)) {
+             // the size of a blob-field is available as soon as we call
+             // mysql_stmt_store_result()
+             // after mysql_stmt_exec() in QMYSQLResult::exec()
+-            fieldInfo->length = 0;
++            bind->buffer_length = f.bufLength = 0;
+             hasBlobs = true;
+         } else if (qIsInteger(f.type)) {
+-            fieldInfo->length = 8;
++            bind->buffer_length = f.bufLength = 8;
+         } else {
+-            fieldInfo->type = MYSQL_TYPE_STRING;
++            bind->buffer_type = MYSQL_TYPE_STRING;
+         }
+-        bind = &inBinds[i];
+-        field = new char[fieldInfo->length + 1];
+-        memset(field, 0, fieldInfo->length + 1);
+ 
+-        bind->buffer_type = fieldInfo->type;
+-        bind->buffer = field;
+-        bind->buffer_length = f.bufLength = fieldInfo->length + 1;
+         bind->is_null = &f.nullIndicator;
+         bind->length = &f.bufLength;
+         bind->is_unsigned = fieldInfo->flags & UNSIGNED_FLAG ? 1 : 0;
+-        f.outField=field;
++
++        char *field = new char[bind->buffer_length + 1]{};
++        bind->buffer = f.outField = field;
+ 
+         ++i;
+     }
+@@ -1369,20 +1367,20 @@ bool QMYSQLDriver::open(const QString& db,
+     }
+ 
+ #if MYSQL_VERSION_ID >= 50007
+-    if (mysql_get_client_version() >= 50503 && mysql_get_server_version(d->mysql) >= 50503) {
+-        // force the communication to be utf8mb4 (only utf8mb4 supports 4-byte characters)
+-        mysql_set_character_set(d->mysql, "utf8mb4");
++    // force the communication to be utf8mb4 (only utf8mb4 supports 4-byte characters)
++    if (mysql_set_character_set(d->mysql, "utf8mb4")) {
++        // this failed, try forcing it to utf (BMP only)
++        if (mysql_set_character_set(d->mysql, "utf8"))
++            qWarning() << "MySQL: Unable to set the client character set to utf8.";
+ #if QT_CONFIG(textcodec)
+-        d->tc = QTextCodec::codecForName("UTF-8");
++        else
++            d->tc = codec(d->mysql);
+ #endif
+-    } else
+-    {
+-        // force the communication to be utf8
+-        mysql_set_character_set(d->mysql, "utf8");
++    }
+ #if QT_CONFIG(textcodec)
+-        d->tc = codec(d->mysql);
++    else
++        d->tc = QTextCodec::codecForName("UTF-8");
+ #endif
+-    }
+ #endif  // MYSQL_VERSION_ID >= 50007
+ 
+     d->preparedQuerysEnabled = checkPreparedQueries(d->mysql);
+diff --git a/qtbase/src/printsupport/dialogs/images/print-24.png b/qtbase/src/printsupport/dialogs/images/printer-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/print-24.png
+rename to src/printsupport/dialogs/images/printer-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/print-32.png b/qtbase/src/printsupport/dialogs/images/printer-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/print-32.png
+rename to src/printsupport/dialogs/images/printer-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-sided-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-facing-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-sided-24.png
+rename to src/printsupport/dialogs/images/view-pages-facing-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-sided-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-facing-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-sided-32.png
+rename to src/printsupport/dialogs/images/view-pages-facing-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-multi-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-overview-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-multi-24.png
+rename to src/printsupport/dialogs/images/view-pages-overview-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-multi-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-overview-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-multi-32.png
+rename to src/printsupport/dialogs/images/view-pages-overview-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-one-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-single-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-one-24.png
+rename to src/printsupport/dialogs/images/view-pages-single-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-one-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-single-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-one-32.png
+rename to src/printsupport/dialogs/images/view-pages-single-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-page-24.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-page-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-page-24.png
+rename to src/printsupport/dialogs/images/zoom-fit-page-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-page-32.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-page-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-page-32.png
+rename to src/printsupport/dialogs/images/zoom-fit-page-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-width-24.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-width-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-width-24.png
+rename to src/printsupport/dialogs/images/zoom-fit-width-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-width-32.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-width-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-width-32.png
+rename to src/printsupport/dialogs/images/zoom-fit-width-32.png
+diff --git a/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp b/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
+index 78e5b8d1ef..2a28516719 100644
+--- a/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
++++ b/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
+@@ -532,6 +532,7 @@ void QPageSetupWidget::updateWidget()
+ void QPageSetupWidget::setupPrinter() const
+ {
+     m_printer->setPageLayout(m_pageLayout);
++    m_printer->setPageOrientation(m_pageLayout.orientation());
+ #if QT_CONFIG(cups)
+     QCUPSSupport::PagesPerSheet pagesPerSheet = qvariant_cast<QCUPSSupport::PagesPerSheet>(m_ui.pagesPerSheetCombo->currentData()
+ );
+diff --git a/qtbase/src/printsupport/dialogs/qprintdialog.qrc b/qtbase/src/printsupport/dialogs/qprintdialog.qrc
+index 5a579baa55..10b8e1d341 100644
+--- a/qtbase/src/printsupport/dialogs/qprintdialog.qrc
++++ b/qtbase/src/printsupport/dialogs/qprintdialog.qrc
+@@ -1,9 +1,9 @@
+ <!DOCTYPE RCC><RCC version="1.0">
+ <qresource prefix="/qt-project.org/dialogs/qprintpreviewdialog">
+-<file>images/fit-page-24.png</file>
+-<file>images/fit-page-32.png</file>
+-<file>images/fit-width-24.png</file>
+-<file>images/fit-width-32.png</file>
++<file>images/zoom-fit-page-24.png</file>
++<file>images/zoom-fit-page-32.png</file>
++<file>images/zoom-fit-width-24.png</file>
++<file>images/zoom-fit-width-32.png</file>
+ <file>images/go-first-24.png</file>
+ <file>images/go-first-32.png</file>
+ <file>images/go-last-24.png</file>
+@@ -18,14 +18,14 @@
+ <file>images/layout-portrait-32.png</file>
+ <file>images/page-setup-24.png</file>
+ <file>images/page-setup-32.png</file>
+-<file>images/print-24.png</file>
+-<file>images/print-32.png</file>
+-<file>images/view-page-multi-24.png</file>
+-<file>images/view-page-multi-32.png</file>
+-<file>images/view-page-one-24.png</file>
+-<file>images/view-page-one-32.png</file>
+-<file>images/view-page-sided-24.png</file>
+-<file>images/view-page-sided-32.png</file>
++<file>images/printer-24.png</file>
++<file>images/printer-32.png</file>
++<file>images/view-pages-overview-24.png</file>
++<file>images/view-pages-overview-32.png</file>
++<file>images/view-pages-single-24.png</file>
++<file>images/view-pages-single-32.png</file>
++<file>images/view-pages-facing-24.png</file>
++<file>images/view-pages-facing-32.png</file>
+ <file>images/zoom-in-24.png</file>
+ <file>images/zoom-in-32.png</file>
+ <file>images/zoom-out-24.png</file>
+diff --git a/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp b/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
+index c5b845f4ec..5a5ba1d0a8 100644
+--- a/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
++++ b/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
+@@ -702,13 +702,14 @@ void QPrintDialogPrivate::selectPrinter(const QPrinter::OutputFormat outputForma
+         else
+             options.grayscale->setChecked(true);
+ 
+-        // keep duplex value explicitly set by user, if any, and selected printer supports it;
+-        // use device default otherwise
++        // duplex priorities to be as follows:
++        // 1) a user-selected duplex value in the dialog has highest prority
++        // 2) duplex value set in the QPrinter
+         QPrint::DuplexMode duplex;
+         if (explicitDuplexMode != QPrint::DuplexAuto && supportedDuplexMode.contains(explicitDuplexMode))
+             duplex = explicitDuplexMode;
+         else
+-            duplex = top->d->m_currentPrintDevice.defaultDuplexMode();
++            duplex = static_cast<QPrint::DuplexMode>(p->duplex());
+         switch (duplex) {
+         case QPrint::DuplexNone:
+             options.noDuplex->setChecked(true); break;
+@@ -1242,10 +1243,10 @@ void QUnixPrintWidgetPrivate::_q_printerChanged(int index)
+             QString filename = widget.filename->text();
+             widget.filename->setText(filename);
+             widget.lOutput->setEnabled(true);
+-            if (optionsPane)
+-                optionsPane->selectPrinter(QPrinter::PdfFormat);
+             printer->setOutputFormat(QPrinter::PdfFormat);
+             m_currentPrintDevice = QPrintDevice();
++            if (optionsPane)
++                optionsPane->selectPrinter(QPrinter::PdfFormat);
+             return;
+         }
+     }
+diff --git a/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp b/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
+index 39575d5f57..23b7e89538 100644
+--- a/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
++++ b/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
+@@ -352,7 +352,7 @@ void QPrintPreviewDialogPrivate::init(QPrinter *_printer)
+ static inline void qt_setupActionIcon(QAction *action, QLatin1String name)
+ {
+     QLatin1String imagePrefix(":/qt-project.org/dialogs/qprintpreviewdialog/images/");
+-    QIcon icon;
++    QIcon icon = QIcon::fromTheme(name);
+     icon.addFile(imagePrefix + name + QLatin1String("-24.png"), QSize(24, 24));
+     icon.addFile(imagePrefix + name + QLatin1String("-32.png"), QSize(32, 32));
+     action->setIcon(icon);
+@@ -383,8 +383,8 @@ void QPrintPreviewDialogPrivate::setupActions()
+     fitPageAction->setObjectName(QLatin1String("fitPageAction"));
+     fitWidthAction->setCheckable(true);
+     fitPageAction->setCheckable(true);
+-    qt_setupActionIcon(fitWidthAction, QLatin1String("fit-width"));
+-    qt_setupActionIcon(fitPageAction, QLatin1String("fit-page"));
++    qt_setupActionIcon(fitWidthAction, QLatin1String("zoom-fit-width"));
++    qt_setupActionIcon(fitPageAction, QLatin1String("zoom-fit-page"));
+     QObject::connect(fitGroup, SIGNAL(triggered(QAction*)), q, SLOT(_q_fit(QAction*)));
+ 
+     // Zoom
+@@ -410,9 +410,9 @@ void QPrintPreviewDialogPrivate::setupActions()
+     singleModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show single page"));
+     facingModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show facing pages"));
+     overviewModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show overview of all pages"));
+-    qt_setupActionIcon(singleModeAction, QLatin1String("view-page-one"));
+-    qt_setupActionIcon(facingModeAction, QLatin1String("view-page-sided"));
+-    qt_setupActionIcon(overviewModeAction, QLatin1String("view-page-multi"));
++    qt_setupActionIcon(singleModeAction, QLatin1String("view-pages-single"));
++    qt_setupActionIcon(facingModeAction, QLatin1String("view-pages-facing"));
++    qt_setupActionIcon(overviewModeAction, QLatin1String("view-pages-overview"));
+     singleModeAction->setObjectName(QLatin1String("singleModeAction"));
+     facingModeAction->setObjectName(QLatin1String("facingModeAction"));
+     overviewModeAction->setObjectName(QLatin1String("overviewModeAction"));
+@@ -426,7 +426,7 @@ void QPrintPreviewDialogPrivate::setupActions()
+     printerGroup = new QActionGroup(q);
+     printAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Print"));
+     pageSetupAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Page setup"));
+-    qt_setupActionIcon(printAction, QLatin1String("print"));
++    qt_setupActionIcon(printAction, QLatin1String("printer"));
+     qt_setupActionIcon(pageSetupAction, QLatin1String("page-setup"));
+     QObject::connect(printAction, SIGNAL(triggered(bool)), q, SLOT(_q_print()));
+     QObject::connect(pageSetupAction, SIGNAL(triggered(bool)), q, SLOT(_q_pageSetup()));
+diff --git a/qtbase/src/sql/kernel/qsqlquery.cpp b/qtbase/src/sql/kernel/qsqlquery.cpp
+index 32c6166c79..60afef10c3 100644
+--- a/qtbase/src/sql/kernel/qsqlquery.cpp
++++ b/qtbase/src/sql/kernel/qsqlquery.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2022 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtSql module of the Qt Toolkit.
+@@ -377,6 +377,10 @@ bool QSqlQuery::exec(const QString& query)
+     QElapsedTimer t;
+     t.start();
+ #endif
++    if (!driver()) {
++        qWarning("QSqlQuery::exec: called before driver has been set up");
++        return false;
++    }
+     if (d->ref.loadRelaxed() != 1) {
+         bool fo = isForwardOnly();
+         *this = QSqlQuery(driver()->createResult());
+diff --git a/qtbase/src/testlib/qabstractitemmodeltester.cpp b/qtbase/src/testlib/qabstractitemmodeltester.cpp
+index 8efb9c53d4..ce062f66d7 100644
+--- a/qtbase/src/testlib/qabstractitemmodeltester.cpp
++++ b/qtbase/src/testlib/qabstractitemmodeltester.cpp
+@@ -454,7 +454,7 @@ void QAbstractItemModelTesterPrivate::parent()
+ 
+     // Common error test #2, make sure that a second level index has a parent
+     // that is the first level index.
+-    if (model->rowCount(topIndex) > 0) {
++    if (model->rowCount(topIndex) > 0 && model->columnCount(topIndex) > 0) {
+         QModelIndex childIndex = model->index(0, 0, topIndex);
+         MODELTESTER_VERIFY(childIndex.isValid());
+         MODELTESTER_COMPARE(model->parent(childIndex), topIndex);
+diff --git a/qtbase/src/testlib/qasciikey.cpp b/qtbase/src/testlib/qasciikey.cpp
+index 9a308da2bc..93498b256f 100644
+--- a/qtbase/src/testlib/qasciikey.cpp
++++ b/qtbase/src/testlib/qasciikey.cpp
+@@ -498,6 +498,11 @@ char QTest::keyToAscii(Qt::Key key)
+     case Qt::Key_LaunchE : return 0; // = 0x10b0,
+     case Qt::Key_LaunchF : return 0; // = 0x10b1,
+ 
++    // Keypad navigation keys
++    case Qt::Key_Select : return 0; // = 0x01010000
++    case Qt::Key_Yes : return 0; // = 0x01010001
++    case Qt::Key_No : return 0; // = 0x01010002
++
+     default: QTEST_ASSERT(false); return 0;
+     }
+ }
+diff --git a/qtbase/src/testlib/qtestresult.cpp b/qtbase/src/testlib/qtestresult.cpp
+index 88028aac6e..2e89930776 100644
+--- a/qtbase/src/testlib/qtestresult.cpp
++++ b/qtbase/src/testlib/qtestresult.cpp
+@@ -251,7 +251,8 @@ bool QTestResult::verify(bool statement, const char *statementStr,
+ {
+     QTEST_ASSERT(statementStr);
+ 
+-    char msg[1024] = {'\0'};
++    char msg[1024];
++    msg[0] = '\0';
+ 
+     if (QTestLog::verboseLevel() >= 2) {
+         qsnprintf(msg, 1024, "QVERIFY(%s)", statementStr);
+@@ -309,7 +310,8 @@ static bool compareHelper(bool success, const char *failureMsg,
+                           bool hasValues = true)
+ {
+     const size_t maxMsgLen = 1024;
+-    char msg[maxMsgLen] = {'\0'};
++    char msg[maxMsgLen];
++    msg[0] = '\0';
+ 
+     QTEST_ASSERT(expected);
+     QTEST_ASSERT(actual);
+diff --git a/qtbase/src/widgets/dialogs/qcolordialog.cpp b/qtbase/src/widgets/dialogs/qcolordialog.cpp
+index 4247731275..cb325be85c 100644
+--- a/qtbase/src/widgets/dialogs/qcolordialog.cpp
++++ b/qtbase/src/widgets/dialogs/qcolordialog.cpp
+@@ -78,7 +78,10 @@
+ #include "qwindow.h"
+ 
+ #include "private/qdialog_p.h"
++#include "private/qguiapplication_p.h"
+ 
++#include <qpa/qplatformservices.h>
++#include <qpa/qplatformintegration.h>
+ #include <algorithm>
+ 
+ QT_BEGIN_NAMESPACE
+@@ -1611,6 +1614,20 @@ void QColorDialogPrivate::_q_newStandard(int r, int c)
+ void QColorDialogPrivate::_q_pickScreenColor()
+ {
+     Q_Q(QColorDialog);
++
++    auto *platformServices = QGuiApplicationPrivate::platformIntegration()->services();
++    if (platformServices->hasCapability(QPlatformServices::Capability::ColorPicking)) {
++        if (auto *colorPicker = platformServices->colorPicker(q->windowHandle())) {
++            q->connect(colorPicker, &QPlatformServiceColorPicker::colorPicked, q,
++                       [q, colorPicker](const QColor &color) {
++                           colorPicker->deleteLater();
++                           q->setCurrentColor(color);
++                       });
++            colorPicker->pickColor();
++            return;
++        }
++    }
++
+     if (!colorPickingEventFilter)
+         colorPickingEventFilter = new QColorPickingEventFilter(this, q);
+     q->installEventFilter(colorPickingEventFilter);
+diff --git a/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp b/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
+index e120817edc..8ea36b5427 100644
+--- a/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
++++ b/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
+@@ -400,12 +400,7 @@ bool QAbstractItemDelegate::helpEvent(QHelpEvent *event,
+         const QString tooltip = index.isValid() ?
+               d->textForRole(Qt::ToolTipRole, index.data(Qt::ToolTipRole), option.locale, precision) :
+               QString();
+-        QRect rect;
+-        if (index.isValid()) {
+-            const QRect r = view->visualRect(index);
+-            rect = QRect(view->mapToGlobal(r.topLeft()), r.size());
+-        }
+-        QToolTip::showText(he->globalPos(), tooltip, view, rect);
++        QToolTip::showText(he->globalPos(), tooltip, view->viewport(), option.rect);
+         event->setAccepted(!tooltip.isEmpty());
+         break;
+         }
+diff --git a/qtbase/src/widgets/itemviews/qlistview.cpp b/qtbase/src/widgets/itemviews/qlistview.cpp
+index 2b34476642..eebfaa030e 100644
+--- a/qtbase/src/widgets/itemviews/qlistview.cpp
++++ b/qtbase/src/widgets/itemviews/qlistview.cpp
+@@ -3386,6 +3386,7 @@ void QIconModeViewBase::updateContentsSize()
+ */
+ void QListView::currentChanged(const QModelIndex &current, const QModelIndex &previous)
+ {
++    QAbstractItemView::currentChanged(current, previous);
+ #ifndef QT_NO_ACCESSIBILITY
+     if (QAccessible::isActive()) {
+         if (current.isValid()) {
+@@ -3396,7 +3397,6 @@ void QListView::currentChanged(const QModelIndex &current, const QModelIndex &pr
+         }
+     }
+ #endif
+-    QAbstractItemView::currentChanged(current, previous);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/widgets/itemviews/qtableview.cpp b/qtbase/src/widgets/itemviews/qtableview.cpp
+index 934ac581b2..f79bb24249 100644
+--- a/qtbase/src/widgets/itemviews/qtableview.cpp
++++ b/qtbase/src/widgets/itemviews/qtableview.cpp
+@@ -1013,6 +1013,7 @@ void QTableViewPrivate::drawCell(QPainter *painter, const QStyleOptionViewItem &
+ int QTableViewPrivate::widthHintForIndex(const QModelIndex &index, int hint, const QStyleOptionViewItem &option) const
+ {
+     Q_Q(const QTableView);
++    const int oldHint = hint;
+     QWidget *editor = editorForIndex(index).widget.data();
+     if (editor && persistent.contains(editor)) {
+         hint = qMax(hint, editor->sizeHint().width());
+@@ -1021,6 +1022,17 @@ int QTableViewPrivate::widthHintForIndex(const QModelIndex &index, int hint, con
+         hint = qBound(min, hint, max);
+     }
+     hint = qMax(hint, q->itemDelegate(index)->sizeHint(option, index).width());
++
++    if (hasSpans()) {
++        auto span = spans.spanAt(index.column(), index.row());
++        if (span && span->m_left == index.column() && span->m_top == index.row()) {
++            // spans are screwed up when sections are moved
++            const auto left = logicalColumn(span->m_left);
++            for (int i = 1; i <= span->width(); ++i)
++               hint -= q->columnWidth(visualColumn(left + i));
++        }
++        hint = std::max(hint, oldHint);
++    }
+     return hint;
+ }
+ 
+@@ -1053,6 +1065,11 @@ int QTableViewPrivate::heightHintForIndex(const QModelIndex &index, int hint, QS
+         option.rect.setHeight(height);
+         option.rect.setX(q->columnViewportPosition(index.column()));
+         option.rect.setWidth(q->columnWidth(index.column()));
++        if (hasSpans()) {
++            auto span = spans.spanAt(index.column(), index.row());
++            if (span && span->m_left == index.column() && span->m_top == index.row())
++                option.rect.setWidth(std::max(option.rect.width(), visualSpanRect(*span).width()));
++        }
+         // 1px less space when grid is shown (see drawCell)
+         if (showGrid)
+             option.rect.setWidth(option.rect.width() - 1);
+diff --git a/qtbase/src/widgets/kernel/qaction.h b/qtbase/src/widgets/kernel/qaction.h
+index 258a1ea0a0..737c1e8285 100644
+--- a/qtbase/src/widgets/kernel/qaction.h
++++ b/qtbase/src/widgets/kernel/qaction.h
+@@ -81,7 +81,7 @@ class Q_WIDGETS_EXPORT QAction : public QObject
+     Q_PROPERTY(MenuRole menuRole READ menuRole WRITE setMenuRole NOTIFY changed)
+     Q_PROPERTY(bool iconVisibleInMenu READ isIconVisibleInMenu WRITE setIconVisibleInMenu NOTIFY changed)
+     Q_PROPERTY(bool shortcutVisibleInContextMenu READ isShortcutVisibleInContextMenu WRITE setShortcutVisibleInContextMenu NOTIFY changed)
+-    Q_PROPERTY(Priority priority READ priority WRITE setPriority)
++    Q_PROPERTY(Priority priority READ priority WRITE setPriority NOTIFY changed)
+ 
+ public:
+     // note this is copied into qplatformmenu.h, which must stay in sync
+diff --git a/qtbase/src/widgets/kernel/qwidget.cpp b/qtbase/src/widgets/kernel/qwidget.cpp
+index 9eba1e001e..26f6d27e18 100644
+--- a/qtbase/src/widgets/kernel/qwidget.cpp
++++ b/qtbase/src/widgets/kernel/qwidget.cpp
+@@ -5296,7 +5296,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
+         QWidgetEffectSourcePrivate *sourced = static_cast<QWidgetEffectSourcePrivate *>
+                                                          (source->d_func());
+         if (!sourced->context) {
+-            const QRegion effectRgn(rgn.boundingRect());
++            const QRegion effectRgn((flags & UseEffectRegionBounds) ? rgn.boundingRect() : rgn);
+             QWidgetPaintContext context(pdev, effectRgn, offset, flags, sharedPainter, repaintManager);
+             sourced->context = &context;
+             if (!sharedPainter) {
+@@ -5328,6 +5328,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
+         }
+     }
+ #endif // QT_CONFIG(graphicseffect)
++    flags = flags & ~UseEffectRegionBounds;
+ 
+     const bool alsoOnScreen = flags & DrawPaintOnScreen;
+     const bool recursive = flags & DrawRecursive;
+diff --git a/qtbase/src/widgets/kernel/qwidget_p.h b/qtbase/src/widgets/kernel/qwidget_p.h
+index eef6b8fa2c..c432f4b5d5 100644
+--- a/qtbase/src/widgets/kernel/qwidget_p.h
++++ b/qtbase/src/widgets/kernel/qwidget_p.h
+@@ -229,7 +229,8 @@ public:
+         DontSubtractOpaqueChildren = 0x10,
+         DontDrawOpaqueChildren = 0x20,
+         DontDrawNativeChildren = 0x40,
+-        DontSetCompositionMode = 0x80
++        DontSetCompositionMode = 0x80,
++        UseEffectRegionBounds = 0x100
+     };
+     Q_DECLARE_FLAGS(DrawWidgetFlags, DrawWidgetFlag)
+     Q_FLAG(DrawWidgetFlags)
+diff --git a/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp b/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
+index 02880b34da..0d44e1326d 100644
+--- a/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
++++ b/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
+@@ -1018,7 +1018,8 @@ void QWidgetRepaintManager::paintAndFlush()
+ 
+     // Paint the rest with composition.
+     if (repaintAllWidgets || !dirtyCopy.isEmpty()) {
+-        QWidgetPrivate::DrawWidgetFlags flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive;
++        QWidgetPrivate::DrawWidgetFlags flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive
++                | QWidgetPrivate::UseEffectRegionBounds;
+         tlw->d_func()->drawWidget(store->paintDevice(), dirtyCopy, QPoint(), flags, nullptr, this);
+     }
+ 
+diff --git a/qtbase/src/widgets/styles/qfusionstyle.cpp b/qtbase/src/widgets/styles/qfusionstyle.cpp
+index f4345d97c4..962912c838 100644
+--- a/qtbase/src/widgets/styles/qfusionstyle.cpp
++++ b/qtbase/src/widgets/styles/qfusionstyle.cpp
+@@ -1772,14 +1772,6 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio
+             proxy()->drawControl(CE_PushButtonLabel, &subopt, painter, widget);
+         }
+         break;
+-    case CE_PushButtonLabel:
+-        if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
+-            QStyleOptionButton b(*button);
+-            // no PM_ButtonShiftHorizontal and PM_ButtonShiftVertical for fusion style
+-            b.state &= ~(State_On | State_Sunken);
+-            QCommonStyle::drawControl(element, &b, painter, widget);
+-        }
+-        break;
+     case CE_MenuBarEmptyArea:
+         painter->save();
+     {
+diff --git a/qtbase/src/widgets/util/qcompleter.cpp b/qtbase/src/widgets/util/qcompleter.cpp
+index 18b24063d8..ef7207a8a3 100644
+--- a/qtbase/src/widgets/util/qcompleter.cpp
++++ b/qtbase/src/widgets/util/qcompleter.cpp
+@@ -1120,6 +1120,8 @@ void QCompleter::setModel(QAbstractItemModel *model)
+ {
+     Q_D(QCompleter);
+     QAbstractItemModel *oldModel = d->proxy->sourceModel();
++    if (oldModel == model)
++        return;
+ #if QT_CONFIG(filesystemmodel)
+     if (qobject_cast<const QFileSystemModel *>(oldModel))
+         setCompletionRole(Qt::EditRole); // QTBUG-54642, clear FileNameRole set by QFileSystemModel
+diff --git a/qtbase/src/widgets/widgets/qabstractbutton.cpp b/qtbase/src/widgets/widgets/qabstractbutton.cpp
+index a128b23950..dc40bf62fb 100644
+--- a/qtbase/src/widgets/widgets/qabstractbutton.cpp
++++ b/qtbase/src/widgets/widgets/qabstractbutton.cpp
+@@ -56,6 +56,7 @@
+ #ifndef QT_NO_ACCESSIBILITY
+ #include "qaccessible.h"
+ #endif
++#include <qpa/qplatformtheme.h>
+ 
+ #include <algorithm>
+ 
+@@ -1076,19 +1077,19 @@ void QAbstractButton::keyPressEvent(QKeyEvent *e)
+ {
+     Q_D(QAbstractButton);
+     bool next = true;
+-    switch (e->key()) {
+-    case Qt::Key_Enter:
+-    case Qt::Key_Return:
+-        e->ignore();
+-        break;
+-    case Qt::Key_Select:
+-    case Qt::Key_Space:
+-        if (!e->isAutoRepeat()) {
+-            setDown(true);
+-            repaint();
+-            d->emitPressed();
+-        }
+-        break;
++
++    const auto key = static_cast<Qt::Key>(e->key());
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(key) && !e->isAutoRepeat()) {
++        setDown(true);
++        repaint();
++        d->emitPressed();
++        return;
++    }
++
++    switch (key) {
+     case Qt::Key_Up:
+         next = false;
+         Q_FALLTHROUGH();
+@@ -1153,15 +1154,15 @@ void QAbstractButton::keyReleaseEvent(QKeyEvent *e)
+     if (!e->isAutoRepeat())
+         d->repeatTimer.stop();
+ 
+-    switch (e->key()) {
+-    case Qt::Key_Select:
+-    case Qt::Key_Space:
+-        if (!e->isAutoRepeat() && d->down)
+-            d->click();
+-        break;
+-    default:
+-        e->ignore();
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(static_cast<Qt::Key>(e->key())) && !e->isAutoRepeat() && d->down) {
++        d->click();
++        return;
+     }
++
++    e->ignore();
+ }
+ 
+ /*!\reimp
+diff --git a/qtbase/src/widgets/widgets/qcombobox.cpp b/qtbase/src/widgets/widgets/qcombobox.cpp
+index 7a496c27e0..0a3d96647b 100644
+--- a/qtbase/src/widgets/widgets/qcombobox.cpp
++++ b/qtbase/src/widgets/widgets/qcombobox.cpp
+@@ -3352,7 +3352,23 @@ void QComboBox::keyPressEvent(QKeyEvent *e)
+ 
+     Move move = NoMove;
+     int newIndex = currentIndex();
+-    switch (e->key()) {
++
++    bool pressLikeButton = !d->lineEdit;
++#ifdef QT_KEYPAD_NAVIGATION
++    pressLikeButton |= QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus();
++#endif
++    auto key = static_cast<Qt::Key>(e->key());
++    if (pressLikeButton) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(key)) {
++            showPopup();
++            return;
++        }
++    }
++
++    switch (key) {
+     case Qt::Key_Up:
+         if (e->modifiers() & Qt::ControlModifier)
+             break; // pass to line edit for auto completion
+@@ -3394,26 +3410,11 @@ void QComboBox::keyPressEvent(QKeyEvent *e)
+             return;
+         }
+         break;
+-    case Qt::Key_Space:
+-        if (!d->lineEdit) {
+-            showPopup();
+-            return;
+-        }
+-        break;
+-    case Qt::Key_Enter:
+-    case Qt::Key_Return:
+     case Qt::Key_Escape:
+         if (!d->lineEdit)
+             e->ignore();
+         break;
+ #ifdef QT_KEYPAD_NAVIGATION
+-    case Qt::Key_Select:
+-        if (QApplicationPrivate::keypadNavigationEnabled()
+-                && (!hasEditFocus() || !d->lineEdit)) {
+-            showPopup();
+-            return;
+-        }
+-        break;
+     case Qt::Key_Left:
+     case Qt::Key_Right:
+         if (QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus())
+diff --git a/qtbase/src/widgets/widgets/qdatetimeedit_p.h b/qtbase/src/widgets/widgets/qdatetimeedit_p.h
+index d36b6f8f9a..e0df5b5158 100644
+--- a/qtbase/src/widgets/widgets/qdatetimeedit_p.h
++++ b/qtbase/src/widgets/widgets/qdatetimeedit_p.h
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2018 The Qt Company Ltd.
++** Copyright (C) 2021 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtWidgets module of the Qt Toolkit.
+diff --git a/qtbase/src/widgets/widgets/qgroupbox.cpp b/qtbase/src/widgets/widgets/qgroupbox.cpp
+index 02a0bed325..3f3eccc370 100644
+--- a/qtbase/src/widgets/widgets/qgroupbox.cpp
++++ b/qtbase/src/widgets/widgets/qgroupbox.cpp
+@@ -54,6 +54,8 @@
+ #include "qaccessible.h"
+ #endif
+ #include <private/qwidget_p.h>
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
+ 
+ #include "qdebug.h"
+ 
+@@ -360,7 +362,10 @@ bool QGroupBox::event(QEvent *e)
+         return true;
+     case QEvent::KeyPress: {
+         QKeyEvent *k = static_cast<QKeyEvent*>(e);
+-        if (!k->isAutoRepeat() && (k->key() == Qt::Key_Select || k->key() == Qt::Key_Space)) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (!k->isAutoRepeat() && buttonPressKeys.contains(static_cast<Qt::Key>(k->key()))) {
+             d->pressedControl = QStyle::SC_GroupBoxCheckBox;
+             update(style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxCheckBox, this));
+             return true;
+@@ -369,7 +374,10 @@ bool QGroupBox::event(QEvent *e)
+     }
+     case QEvent::KeyRelease: {
+         QKeyEvent *k = static_cast<QKeyEvent*>(e);
+-        if (!k->isAutoRepeat() && (k->key() == Qt::Key_Select || k->key() == Qt::Key_Space)) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (!k->isAutoRepeat() && buttonPressKeys.contains(static_cast<Qt::Key>(k->key()))) {
+             bool toggle = (d->pressedControl == QStyle::SC_GroupBoxLabel
+                            || d->pressedControl == QStyle::SC_GroupBoxCheckBox);
+             d->pressedControl = QStyle::SC_None;
+diff --git a/qtbase/src/widgets/widgets/qlabel.cpp b/qtbase/src/widgets/widgets/qlabel.cpp
+index 30ff80cbb0..cf2605c17c 100644
+--- a/qtbase/src/widgets/widgets/qlabel.cpp
++++ b/qtbase/src/widgets/widgets/qlabel.cpp
+@@ -421,9 +421,6 @@ void QLabel::setPixmap(const QPixmap &pixmap)
+         d->pixmap = new QPixmap(pixmap);
+     }
+ 
+-    if (d->pixmap->depth() == 1 && !d->pixmap->mask())
+-        d->pixmap->setMask(*((QBitmap *)d->pixmap));
+-
+     d->updateLabel();
+ }
+ 
+diff --git a/qtbase/src/widgets/widgets/qtoolbararealayout.cpp b/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
+index 493c094cc1..d5f4b59017 100644
+--- a/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
++++ b/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
+@@ -1367,7 +1367,7 @@ bool QToolBarAreaLayout::restoreState(QDataStream &stream, const QList<QToolBar*
+                 item.widgetItem = new QWidgetItemV2(toolBar);
+                 toolBar->setOrientation(floating ? ((shown & 2) ? Qt::Vertical : Qt::Horizontal) : dock.o);
+                 toolBar->setVisible(shown & 1);
+-                toolBar->d_func()->setWindowState(floating, true, rect);
++                toolBar->d_func()->setWindowState(floating, false, rect);
+ 
+                 item.preferredSize = item.size;
+                 line.toolBarItems.append(item);
+diff --git a/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp b/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
+index 212c0a2e13..3c77b1ba0b 100644
+--- a/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
++++ b/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
+@@ -126,8 +126,7 @@ public:
+ 
+ void tst_QtConcurrentIterateKernel::instantiate()
+ {
+-    auto future = startThreadEngine(new PrintFor(0, 40)).startAsynchronously();
+-    future.waitForFinished();
++    startThreadEngine(new PrintFor(0, 40)).startBlocking();
+     QCOMPARE(iterations.loadRelaxed(), 40);
+ }
+ 
+@@ -166,10 +165,8 @@ void tst_QtConcurrentIterateKernel::stresstest()
+     const int times = 50;
+     for (int i = 0; i < times; ++i) {
+         counter.storeRelaxed(0);
+-        // ThreadEngine will delete f when it finishes
+-        auto f = new CountFor(0, iterations);
+-        auto future = f->startAsynchronously();
+-        future.waitForFinished();
++        CountFor f(0, iterations);
++        f.startBlocking();
+         QCOMPARE(counter.loadRelaxed(), iterations);
+     }
+ }
+@@ -177,11 +174,8 @@ void tst_QtConcurrentIterateKernel::stresstest()
+ void tst_QtConcurrentIterateKernel::noIterations()
+ {
+     const int times = 20000;
+-    for (int i = 0; i < times; ++i) {
+-        auto future = startThreadEngine(new IterateKernel<TestIterator, void>(0, 0))
+-                              .startAsynchronously();
+-        future.waitForFinished();
+-    }
++    for (int i = 0; i < times; ++i)
++        startThreadEngine(new IterateKernel<TestIterator, void>(0, 0)).startBlocking();
+ }
+ 
+ QMutex threadsMutex;
+@@ -236,10 +230,8 @@ void tst_QtConcurrentIterateKernel::throttling()
+ 
+     threads.clear();
+ 
+-    // ThreadEngine will delete f when it finishes
+-    auto f = new ThrottleFor(0, totalIterations);
+-    auto future = f->startAsynchronously();
+-    future.waitForFinished();
++    ThrottleFor f(0, totalIterations);
++    f.startBlocking();
+ 
+     QCOMPARE(iterations.loadRelaxed(), totalIterations);
+ 
+diff --git a/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp b/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
+index ac7be7acdd..81bc64c8d9 100644
+--- a/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
++++ b/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
+@@ -65,9 +65,16 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::runDirectly()
+ {
+-    PrintUser *engine = new PrintUser();
+-    QFuture<void> f = engine->startAsynchronously();
+-    f.waitForFinished();
++    {
++        PrintUser engine;
++        engine.startSingleThreaded();
++        engine.startBlocking();
++    }
++    {
++        PrintUser *engine = new PrintUser();
++        QFuture<void> f = engine->startAsynchronously();
++        f.waitForFinished();
++    }
+ }
+ 
+ class StringResultUser : public ThreadEngine<QString>
+@@ -99,10 +106,8 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::result()
+ {
+-    // ThreadEngine will delete 'engine' when it finishes
+-    auto engine = new StringResultUser();
+-    auto future = engine->startAsynchronously();
+-    QCOMPARE(future.result(), QString("Foo"));
++    StringResultUser engine;
++    QCOMPARE(*engine.startBlocking(), QString("Foo"));
+ }
+ 
+ class VoidResultUser : public ThreadEngine<void>
+@@ -128,9 +133,17 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::runThroughStarter()
+ {
+-    ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
+-    QFuture<QString> f = starter.startAsynchronously();
+-    QCOMPARE(f.result(), QString("Foo"));
++    {
++        ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
++        QFuture<QString>  f = starter.startAsynchronously();
++        QCOMPARE(f.result(), QString("Foo"));
++    }
++
++    {
++        ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
++        QString str = starter.startBlocking();
++        QCOMPARE(str, QString("Foo"));
++    }
+ }
+ 
+ class CancelUser : public ThreadEngine<void>
+@@ -213,6 +226,12 @@ void tst_QtConcurrentThreadEngine::throttle()
+         f.waitForFinished();
+         QCOMPARE(count.loadRelaxed(), 0);
+     }
++
++    for (int i = 0; i < repeats; ++i) {
++        ThrottleAlwaysUser t;
++        t.startBlocking();
++        QCOMPARE(count.loadRelaxed(), 0);
++    }
+ }
+ 
+ QSet<QThread *> threads;
+@@ -249,17 +268,35 @@ void tst_QtConcurrentThreadEngine::threadCount()
+ {
+     const int repeats = 10;
+     for (int i = 0; i < repeats; ++i) {
++        ThreadCountUser t;
++        t.startBlocking();
++        int count = threads.count();
++        int count_expected = QThreadPool::globalInstance()->maxThreadCount() + 1; // +1 for the main thread.
++        if (count != count_expected)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, count_expected);
++
+         (new ThreadCountUser())->startAsynchronously().waitForFinished();
+-        const auto count = threads.count();
+-        const auto maxThreadCount = QThreadPool::globalInstance()->maxThreadCount();
+-        QVERIFY(count <= maxThreadCount);
+-        QVERIFY(!threads.contains(QThread::currentThread()));
++        count = threads.count();
++        count_expected = QThreadPool::globalInstance()->maxThreadCount();
++        if (count != count_expected)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, count_expected);
+     }
+ 
+     // Set the finish flag immediately, this should give us one thread only.
+     for (int i = 0; i < repeats; ++i) {
++        ThreadCountUser t(true /*finishImmediately*/);
++        t.startBlocking();
++        int count = threads.count();
++        if (count != 1)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, 1);
++
+         (new ThreadCountUser(true /*finishImmediately*/))->startAsynchronously().waitForFinished();
+-        const auto count = threads.count();
++        count = threads.count();
++        if (count != 1)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
+         QCOMPARE(count, 1);
+         QVERIFY(!threads.contains(QThread::currentThread()));
+     }
+@@ -400,6 +437,7 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::exceptions()
+ {
++    // Asynchronous mode:
+     {
+         bool caught = false;
+         try  {
+@@ -412,6 +450,32 @@ void tst_QtConcurrentThreadEngine::exceptions()
+         QVERIFY2(caught, "did not get exception");
+     }
+ 
++    // Blocking mode:
++    // test throwing the exception from a worker thread.
++    {
++        bool caught = false;
++        try  {
++            QtConcurrentExceptionThrower e(QThread::currentThread());
++            e.startBlocking();
++        } catch (const QException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // test throwing the exception from the main thread (different code path)
++    {
++        bool caught = false;
++        try  {
++            QtConcurrentExceptionThrower e(0);
++            e.startBlocking();
++        } catch (const QException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // Asynchronous mode:
+     {
+         bool caught = false;
+         try  {
+@@ -423,6 +487,31 @@ void tst_QtConcurrentThreadEngine::exceptions()
+         }
+         QVERIFY2(caught, "did not get exception");
+     }
++
++    // Blocking mode:
++    // test throwing the exception from a worker thread.
++    {
++        bool caught = false;
++        try  {
++            UnrelatedExceptionThrower e(QThread::currentThread());
++            e.startBlocking();
++        } catch (const QUnhandledException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // test throwing the exception from the main thread (different code path)
++    {
++        bool caught = false;
++        try  {
++            UnrelatedExceptionThrower e(0);
++            e.startBlocking();
++        } catch (const QUnhandledException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
+ }
+ 
+ #endif
+diff --git a/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp b/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
+index 4968742110..f4c3fb711d 100644
+--- a/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
++++ b/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
+@@ -42,6 +42,7 @@ private slots:
+     void writeBlock_data();
+     void writeBlock();
+     void seek();
++    void invalidSeeks();
+     void seekTest_data();
+     void seekTest();
+     void read_rawdata();
+@@ -286,6 +287,29 @@ void tst_QBuffer::seek()
+     QCOMPARE(buffer.size(), pos);
+ }
+ 
++void tst_QBuffer::invalidSeeks()
++{
++    if constexpr (sizeof(qsizetype) == sizeof(qint64)) {
++        // sizeof(qsizetype) == sizeof(qint64), so +1 would overflow
++        QSKIP("This is a 32-bit-only test.");
++    } else {
++        QBuffer buffer;
++        buffer.open(QIODevice::WriteOnly);
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++        constexpr qint64 MaxQByteArrayCapacity = (std::numeric_limits<qsizetype>::max)();
++        // this should fail fast, not after trying to allocate nearly 2 GiB of data,
++        // potentially crashing in the process:
++        QVERIFY(!buffer.seek(2 * MaxQByteArrayCapacity - 1));
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++        // ditto:
++        QVERIFY(!buffer.seek(MaxQByteArrayCapacity + 1));
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++    }
++}
++
+ void tst_QBuffer::seekTest_data()
+ {
+     writeBlock_data();
+diff --git a/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp b/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
+index da5327594c..4a04e0f7c6 100644
+--- a/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
++++ b/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
+@@ -561,7 +561,8 @@ protected:
+     qint64 readData(char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf->size() - offset));
+-        memcpy(data, buf->constData() + offset, maxSize);
++        if (maxSize > 0)
++            memcpy(data, buf->constData() + offset, maxSize);
+         offset += maxSize;
+         return maxSize;
+     }
+@@ -604,13 +605,15 @@ protected:
+     qint64 readData(char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf.size() - pos()));
+-        memcpy(data, buf.constData() + pos(), maxSize);
++        if (maxSize > 0)
++            memcpy(data, buf.constData() + pos(), maxSize);
+         return maxSize;
+     }
+     qint64 writeData(const char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf.size() - pos()));
+-        memcpy(buf.data() + pos(), data, maxSize);
++        if (maxSize > 0)
++            memcpy(buf.data() + pos(), data, maxSize);
+         return maxSize;
+     }
+ 
+diff --git a/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+index db60bead64..f345a44414 100644
+--- a/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
++++ b/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+@@ -1,7 +1,8 @@
+ /****************************************************************************
+ **
+ ** Copyright (C) 2021 The Qt Company Ltd.
+-** Copyright (C) 2020 Intel Corporation.
++** Copyright (C) 2020 The Qt Company Ltd.
++** Copyright (C) 2022 Intel Corporation.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the test suite of the Qt Toolkit.
+@@ -150,6 +151,8 @@ private slots:
+     void startStopStartStopBuffers();
+     void processEventsInAReadyReadSlot_data();
+     void processEventsInAReadyReadSlot();
++    void startFromCurrentWorkingDir_data();
++    void startFromCurrentWorkingDir();
+ 
+     // keep these at the end, since they use lots of processes and sometimes
+     // caused obscure failures to occur in tests that followed them (esp. on the Mac)
+@@ -2731,5 +2734,94 @@ void tst_QProcess::finishProcessBeforeReadingDone_deprecated()
+ 
+ #endif
+ 
++enum class ChdirMode {
++    None = 0,
++    InParent,
++    InChild
++};
++Q_DECLARE_METATYPE(ChdirMode)
++
++void tst_QProcess::startFromCurrentWorkingDir_data()
++{
++    qRegisterMetaType<ChdirMode>();
++    QTest::addColumn<QString>("programPrefix");
++    QTest::addColumn<ChdirMode>("chdirMode");
++    QTest::addColumn<bool>("success");
++
++    constexpr bool IsWindows = true
++#ifdef Q_OS_UNIX
++            && false
++#endif
++            ;
++
++    // baseline: trying to execute the directory, this can't possibly succeed!
++    QTest::newRow("plain-same-cwd") << QString() << ChdirMode::None << false;
++
++    // cross-platform behavior: neither OS searches the setWorkingDirectory()
++    // dir without "./"
++    QTest::newRow("plain-child-chdir") << QString() << ChdirMode::InChild << false;
++
++    // cross-platform behavior: both OSes search the parent's CWD with "./"
++    QTest::newRow("prefixed-parent-chdir") << "./" << ChdirMode::InParent << true;
++
++    // opposite behaviors: Windows searches the parent's CWD and Unix searches
++    // the child's with "./"
++    QTest::newRow("prefixed-child-chdir") << "./" << ChdirMode::InChild << !IsWindows;
++
++    // Windows searches the parent's CWD without "./"
++    QTest::newRow("plain-parent-chdir") << QString() << ChdirMode::InParent << IsWindows;
++}
++
++void tst_QProcess::startFromCurrentWorkingDir()
++{
++    QFETCH(QString, programPrefix);
++    QFETCH(ChdirMode, chdirMode);
++    QFETCH(bool, success);
++
++    QProcess process;
++    qRegisterMetaType<QProcess::ProcessError>();
++    QSignalSpy errorSpy(&process, &QProcess::errorOccurred);
++    QVERIFY(errorSpy.isValid());
++
++    // both the dir name and the executable name
++    const QString target = QStringLiteral("testProcessNormal");
++    process.setProgram(programPrefix + target);
++
++#ifdef Q_OS_UNIX
++    // Reset PATH, to be sure it doesn't contain . or the empty path.
++    // We can't do this on Windows because DLLs are searched in PATH
++    // and Windows always searches "." anyway.
++    auto restoreEnv = qScopeGuard([old = qgetenv("PATH")] {
++        qputenv("PATH", old);
++    });
++    qputenv("PATH", "/");
++#endif
++
++    switch (chdirMode) {
++    case ChdirMode::InParent: {
++        auto restoreCwd = qScopeGuard([old = QDir::currentPath()] {
++            QDir::setCurrent(old);
++        });
++        QVERIFY(QDir::setCurrent(target));
++        process.start();
++        break;
++    }
++    case ChdirMode::InChild:
++        process.setWorkingDirectory(target);
++        Q_FALLTHROUGH();
++    case ChdirMode::None:
++        process.start();
++        break;
++    }
++
++    QCOMPARE(process.waitForStarted(), success);
++    QCOMPARE(errorSpy.count(), int(!success));
++    if (success) {
++        QVERIFY(process.waitForFinished());
++    } else {
++        QCOMPARE(process.error(), QProcess::FailedToStart);
++    }
++}
++
+ QTEST_MAIN(tst_QProcess)
+ #include "tst_qprocess.moc"
+diff --git a/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp b/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp
+index e1ea7a4552..90972caa57 100644
+--- a/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp
++++ b/qtbase/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"
+diff --git a/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+index 9bd66c0835..ed4a0bae5d 100644
+--- a/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
++++ b/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+@@ -158,6 +158,7 @@ private slots:
+     void nullReceiver();
+     void functorReferencesConnection();
+     void disconnectDisconnects();
++    void declarativeData();
+ };
+ 
+ struct QObjectCreatedOnShutdown
+@@ -7679,5 +7680,81 @@ void tst_QObject::disconnectDisconnects()
+ Q_STATIC_ASSERT(QtPrivate::HasQ_OBJECT_Macro<tst_QObject>::Value);
+ Q_STATIC_ASSERT(!QtPrivate::HasQ_OBJECT_Macro<SiblingDeleter>::Value);
+ 
++#ifdef QT_BUILD_INTERNAL
++/*
++    Since QObjectPrivate stores the declarativeData pointer in a union with the pointer
++    to the currently destroyed child, calls to the QtDeclarative handlers need to be
++    correctly guarded. QTBUG-105286
++*/
++namespace QtDeclarative {
++static QAbstractDeclarativeData *theData;
++
++static void destroyed(QAbstractDeclarativeData *data, QObject *)
++{
++    QCOMPARE(data, theData);
++}
++static void signalEmitted(QAbstractDeclarativeData *data, QObject *, int, void **)
++{
++    QCOMPARE(data, theData);
++}
++// we can't use QCOMPARE in the next two functions, as they don't return void
++static int receivers(QAbstractDeclarativeData *data, const QObject *, int)
++{
++    QTest::qCompare(data, theData, "data", "theData", __FILE__, __LINE__);
++    return 0;
++}
++static bool isSignalConnected(QAbstractDeclarativeData *data, const QObject *, int)
++{
++    QTest::qCompare(data, theData, "data", "theData", __FILE__, __LINE__);
++    return true;
++}
++
++class Object : public QObject
++{
++    Q_OBJECT
++public:
++    using QObject::QObject;
++    ~Object()
++    {
++        if (Object *p = static_cast<Object *>(parent()))
++            p->emitSignal();
++    }
++
++    void emitSignal()
++    {
++        emit theSignal();
++    }
++
++signals:
++    void theSignal();
++};
++
++}
++#endif
++
++void tst_QObject::declarativeData()
++{
++#ifdef QT_BUILD_INTERNAL
++    QScopedValueRollback destroyed(QAbstractDeclarativeData::destroyed,
++                                   QtDeclarative::destroyed);
++    QScopedValueRollback signalEmitted(QAbstractDeclarativeData::signalEmitted,
++                                       QtDeclarative::signalEmitted);
++    QScopedValueRollback receivers(QAbstractDeclarativeData::receivers,
++                                   QtDeclarative::receivers);
++    QScopedValueRollback isSignalConnected(QAbstractDeclarativeData::isSignalConnected,
++                                           QtDeclarative::isSignalConnected);
++
++    QtDeclarative::Object p;
++    QObjectPrivate *priv = QObjectPrivate::get(&p);
++    priv->declarativeData = QtDeclarative::theData = new QAbstractDeclarativeData;
++
++    connect(&p, &QtDeclarative::Object::theSignal, &p, []{
++    });
++
++    QtDeclarative::Object *child = new QtDeclarative::Object;
++    child->setParent(&p);
++#endif
++}
++
+ QTEST_MAIN(tst_QObject)
+ #include "tst_qobject.moc"
+diff --git a/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp b/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
+index 0ea422ecbc..1a3256534b 100644
+--- a/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
++++ b/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
+@@ -70,15 +70,15 @@ static inline QString testSuiteWarning()
+ 
+     QString result;
+     QTextStream str(&result);
+-    str << "\nCannot find the shared-mime-info test suite\nstarting from: "
++    str << "\nCannot find the shared-mime-info test suite\nin the parent of: "
+         << QDir::toNativeSeparators(QDir::currentPath()) << "\n"
+            "cd " << QDir::toNativeSeparators(QStringLiteral("tests/auto/corelib/mimetypes/qmimedatabase")) << "\n"
+-           "wget http://cgit.freedesktop.org/xdg/shared-mime-info/snapshot/Release-1-10.zip\n"
+-           "unzip Release-1-10.zip\n";
++           "wget https://gitlab.freedesktop.org/xdg/shared-mime-info/-/archive/2.1/shared-mime-info-2.1.zip\n"
++           "unzip shared-mime-info-2.1.zip\n";
+ #ifdef Q_OS_WIN
+-    str << "mkdir testfiles\nxcopy /s Release-1-10 s-m-i\n";
++    str << "mkdir testfiles\nxcopy /s shared-mime-info-2.1 s-m-i\n";
+ #else
+-    str << "ln -s Release-1-10 s-m-i\n";
++    str << "ln -s shared-mime-info-2.1 s-m-i\n";
+ #endif
+     return result;
+ }
+@@ -154,7 +154,7 @@ void tst_QMimeDatabase::initTestCase()
+     QVERIFY2(copyResourceFile(xmlFileName, xmlTargetFileName, &errorMessage), qPrintable(errorMessage));
+ #endif
+ 
+-    m_testSuite = QFINDTESTDATA("s-m-i/tests");
++    m_testSuite = QFINDTESTDATA("s-m-i/tests/mime-detection");
+     if (m_testSuite.isEmpty())
+         qWarning("%s", qPrintable(testSuiteWarning()));
+ 
+@@ -611,7 +611,7 @@ void tst_QMimeDatabase::allMimeTypes()
+     QVERIFY(!lst.isEmpty());
+ 
+     // Hardcoding this is the only way to check both providers find the same number of mimetypes.
+-    QCOMPARE(lst.count(), 779);
++    QCOMPARE(lst.count(), 811);
+ 
+     foreach (const QMimeType &mime, lst) {
+         const QString name = mime.name();
+@@ -631,10 +631,9 @@ void tst_QMimeDatabase::suffixes_data()
+ 
+     QTest::newRow("mimetype with a single pattern") << "application/pdf" << "*.pdf" << "pdf";
+     QTest::newRow("mimetype with multiple patterns") << "application/x-kpresenter" << "*.kpr;*.kpt" << "kpr";
+-    QTest::newRow("jpeg") << "image/jpeg" << "*.jpe;*.jpg;*.jpeg" << "jpeg";
+-    //if (KMimeType::sharedMimeInfoVersion() > KDE_MAKE_VERSION(0, 60, 0)) {
+-        QTest::newRow("mimetype with many patterns") << "application/vnd.wordperfect" << "*.wp;*.wp4;*.wp5;*.wp6;*.wpd;*.wpp" << "wp";
+-    //}
++    // The preferred suffix for image/jpeg is *.jpg, as per https://bugs.kde.org/show_bug.cgi?id=176737
++    QTest::newRow("jpeg") << "image/jpeg" << "*.jpe;*.jpg;*.jpeg" << "jpg";
++    QTest::newRow("mimetype with many patterns") << "application/vnd.wordperfect" << "*.wp;*.wp4;*.wp5;*.wp6;*.wpd;*.wpp" << "wp";
+     QTest::newRow("oasis text mimetype") << "application/vnd.oasis.opendocument.text" << "*.odt" << "odt";
+     QTest::newRow("oasis presentation mimetype") << "application/vnd.oasis.opendocument.presentation" << "*.odp" << "odp";
+     QTest::newRow("mimetype with multiple patterns") << "text/plain" << "*.asc;*.txt;*,v" << "txt";
+diff --git a/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp b/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
+index 3e58dd03cc..c8f82ef5d5 100644
+--- a/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
++++ b/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
+@@ -176,6 +176,8 @@ private Q_SLOTS:
+     void fromToVariantConversions_data();
+     void fromToVariantConversions();
+ 
++    void noLeakOnNameClash();
++
+ private:
+     QString testDataDir;
+ };
+@@ -3685,5 +3687,23 @@ void tst_QtJson::fromToVariantConversions()
+     }
+ }
+ 
++void tst_QtJson::noLeakOnNameClash()
++{
++    QJsonDocument doc = QJsonDocument::fromJson("{\"\":{\"\":0},\"\":0}");
++    QVERIFY(!doc.isNull());
++    const QJsonObject obj = doc.object();
++
++    // Removed the duplicate key.
++    QCOMPARE(obj.length(), 1);
++
++    // Retained the last of the duplicates.
++    const QJsonValue val = obj.begin().value();
++    QVERIFY(val.isDouble());
++    QCOMPARE(val.toDouble(), 0.0);
++
++    // It should not leak.
++    // In particular it should not forget to deref the container for the inner object.
++}
++
+ QTEST_MAIN(tst_QtJson)
+ #include "tst_qtjson.moc"
+diff --git a/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp b/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
+index a59b58d57f..241c3e84ac 100644
+--- a/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
++++ b/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
+@@ -63,6 +63,7 @@ private slots:
+     void isValidId_data();
+     void isValidId();
+     void malformed();
++    void serialize();
+     // Backend tests
+     void utcTest();
+     void icuTest();
+@@ -947,6 +948,33 @@ void tst_QTimeZone::malformed()
+         barf.offsetFromUtc(now);
+ }
+ 
++void tst_QTimeZone::serialize()
++{
++    int parts = 0;
++#ifndef QT_NO_DEBUG_STREAM
++    qDebug() << QTimeZone(); // to verify no crash
++    parts++;
++#endif
++#ifndef QT_NO_DATASTREAM
++    QByteArray blob;
++    {
++        QDataStream stream(&blob, QIODevice::WriteOnly);
++        stream << QTimeZone("Europe/Oslo") << QTimeZone(420) << QTimeZone() << qint64(-1);
++    }
++    QDataStream stream(&blob, QIODevice::ReadOnly);
++    QTimeZone invalid, offset, oslo;
++    qint64 minusone;
++    stream >> oslo >> offset >> invalid >> minusone;
++    QCOMPARE(oslo, QTimeZone("Europe/Oslo"));
++    QCOMPARE(offset, QTimeZone(420));
++    QVERIFY(!invalid.isValid());
++    QCOMPARE(minusone, qint64(-1));
++    parts++;
++#endif
++    if (!parts)
++        QSKIP("No serialization enabled");
++}
++
+ void tst_QTimeZone::utcTest()
+ {
+ #ifdef QT_BUILD_INTERNAL
+diff --git a/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp b/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
+index 05480c6dd2..70f4c75756 100644
+--- a/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
++++ b/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
+@@ -324,6 +324,13 @@ void tst_QDBusInterface::notValid()
+ 
+     QVERIFY(!interface.isValid());
+     QVERIFY(!QMetaObject::invokeMethod(&interface, "ListNames", Qt::DirectConnection));
++
++    // With a connection, but empty/null service and path specified
++    QDBusConnection con = QDBusConnection::sessionBus();
++    QVERIFY(con.isConnected());
++    QDBusInterface iface({}, {}, {}, con);
++    QVERIFY(!iface.isValid());
++    QVERIFY(!QMetaObject::invokeMethod(&interface, "ListNames", Qt::DirectConnection));
+ }
+ 
+ void tst_QDBusInterface::notValidDerived()
+diff --git a/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp b/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
+index 874468c954..04ceb4ab65 100644
+--- a/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
++++ b/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
+@@ -507,6 +507,10 @@ void tst_QKeySequence::toStringFromKeycode_data()
+     QTest::newRow("Ctrl+Alt+Num+Del") << QKeySequence(Qt::ControlModifier | Qt::AltModifier | Qt::KeypadModifier | Qt::Key_Delete) << "Ctrl+Alt+Num+Del";
+     QTest::newRow("Ctrl+Ins") << QKeySequence(Qt::ControlModifier | Qt::Key_Insert) << "Ctrl+Ins";
+     QTest::newRow("Ctrl+Num+Ins(1)") << QKeySequence(Qt::Key_Insert | Qt::KeypadModifier | Qt::ControlModifier) << "Ctrl+Num+Ins";
++    QTest::newRow("Ctrl") << QKeySequence(Qt::Key_Control) << "Control";
++    QTest::newRow("Alt") << QKeySequence(Qt::Key_Alt) << "Alt";
++    QTest::newRow("Shift") << QKeySequence(Qt::Key_Shift) << "Shift";
++    QTest::newRow("Meta") << QKeySequence(Qt::Key_Meta) << "Meta";
+ }
+ 
+ void tst_QKeySequence::toStringFromKeycode()
+diff --git a/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp b/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+index 15e0ecadaa..b4eca74283 100644
+--- a/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
++++ b/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+@@ -81,6 +81,8 @@ private slots:
+     void registerOpenTypePreferredNamesSystem();
+     void registerOpenTypePreferredNamesApplication();
+ 
++    void stretchRespected();
++
+ private:
+     QString m_ledFont;
+     QString m_testFont;
+@@ -355,6 +357,28 @@ static QString testString()
+     return QStringLiteral("foo bar");
+ }
+ 
++void tst_QFontDatabase::stretchRespected()
++{
++    int italicId = QFontDatabase::addApplicationFont(m_testFontItalic);
++    QVERIFY(italicId != -1);
++
++    QVERIFY(!QFontDatabase::applicationFontFamilies(italicId).isEmpty());
++
++    QString italicFontName = QFontDatabase::applicationFontFamilies(italicId).first();
++
++    QFont italicFont = QFontDatabase().font(italicFontName,
++                                            QString::fromLatin1("Italic"), 14);
++    QVERIFY(italicFont.italic());
++
++    QFont italicStretchedFont = italicFont;
++    italicStretchedFont.setStretch( 400 );
++
++    QVERIFY(QFontMetricsF(italicFont).horizontalAdvance(QStringLiteral("foobar")) <
++            QFontMetricsF(italicStretchedFont).horizontalAdvance(QStringLiteral("foobar")));
++
++    QFontDatabase::removeApplicationFont(italicId);
++}
++
+ void tst_QFontDatabase::condensedFontWidthNoFontMerging()
+ {
+     int regularFontId = QFontDatabase::addApplicationFont(m_testFont);
+diff --git a/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+index 3d4a094c43..b423e11a99 100644
+--- a/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
++++ b/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+@@ -281,6 +281,7 @@ private Q_SLOTS:
+     void ioGetFromFileSpecial();
+     void ioGetFromFile_data();
+     void ioGetFromFile();
++    void ioGetFromFileUrl();
+     void ioGetFromFtp_data();
+     void ioGetFromFtp();
+     void ioGetFromFtpWithReuse();
+@@ -3300,6 +3301,18 @@ void tst_QNetworkReply::ioGetFromFile()
+     QCOMPARE(reader.data, data);
+ }
+ 
++void tst_QNetworkReply::ioGetFromFileUrl()
++{
++    // This immediately fails on non-windows platforms:
++    QNetworkRequest request(QUrl("file://unc-server/some/path"));
++    QNetworkReplyPtr reply(manager.get(request));
++    QSignalSpy finishedSpy(reply.get(), &QNetworkReply::finished);
++    // QTBUG-105618: This would, on non-Windows platforms, never happen because the signal
++    // was emitted before the constructor finished, leaving no chance at all to connect to the
++    // signal
++    QVERIFY(finishedSpy.wait());
++}
++
+ void tst_QNetworkReply::ioGetFromFtp_data()
+ {
+     QTest::addColumn<QString>("fileName");
+diff --git a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
+index 069fa6b341..4cc4d9a5ea 100644
+--- a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
++++ b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
+@@ -1,75 +1,34 @@
+-Certificate:
+-    Data:
+-        Version: 3 (0x2)
+-        Serial Number: 0 (0x0)
+-        Signature Algorithm: sha1WithRSAEncryption
+-        Issuer: C=NO, ST=Oslo, L=Nydalen, O=Nokia Corporation and/or its subsidiary(-ies), OU=Development, CN=fluke.troll.no/emailAddress=ahanssen@trolltech.com
+-        Validity
+-            Not Before: Dec  4 01:10:32 2007 GMT
+-            Not After : Apr 21 01:10:32 2035 GMT
+-        Subject: C=NO, ST=Oslo, O=Nokia Corporation and/or its subsidiary(-ies), OU=Development, CN=fluke.troll.no
+-        Subject Public Key Info:
+-            Public Key Algorithm: rsaEncryption
+-            RSA Public Key: (1024 bit)
+-                Modulus (1024 bit):
+-                    00:a7:c8:a0:4a:c4:19:05:1b:66:ba:32:e2:d2:f1:
+-                    1c:6f:17:82:e4:39:2e:01:51:90:db:04:34:32:11:
+-                    21:c2:0d:6f:59:d8:53:90:54:3f:83:8f:a9:d3:b3:
+-                    d5:ee:1a:9b:80:ae:c3:25:c9:5e:a5:af:4b:60:05:
+-                    aa:a0:d1:91:01:1f:ca:04:83:e3:58:1c:99:32:45:
+-                    84:70:72:58:03:98:4a:63:8b:41:f5:08:49:d2:91:
+-                    02:60:6b:e4:64:fe:dd:a0:aa:74:08:e9:34:4c:91:
+-                    5f:12:3d:37:4d:54:2c:ad:7f:5b:98:60:36:02:8c:
+-                    3b:f6:45:f3:27:6a:9b:94:9d
+-                Exponent: 65537 (0x10001)
+-        X509v3 extensions:
+-            X509v3 Basic Constraints: 
+-                CA:FALSE
+-            Netscape Comment: 
+-                OpenSSL Generated Certificate
+-            X509v3 Subject Key Identifier: 
+-                21:85:04:3D:23:01:66:E5:F7:9F:1A:84:24:8A:AF:0A:79:F4:E5:AC
+-            X509v3 Authority Key Identifier: 
+-                DirName:/C=NO/ST=Oslo/L=Nydalen/O=Nokia Corporation and/or its subsidiary(-ies)/OU=Development/CN=fluke.troll.no/emailAddress=ahanssen@trolltech.com
+-                serial:8E:A8:B4:E8:91:B7:54:2E
+-
+-    Signature Algorithm: sha1WithRSAEncryption
+-        6d:57:5f:d1:05:43:f0:62:05:ec:2a:71:a5:dc:19:08:f2:c4:
+-        a6:bd:bb:25:d9:ca:89:01:0e:e4:cf:1f:c1:8c:c8:24:18:35:
+-        53:59:7b:c0:43:b4:32:e6:98:b2:a6:ef:15:05:0b:48:5f:e1:
+-        a0:0c:97:a9:a1:77:d8:35:18:30:bc:a9:8f:d3:b7:54:c7:f1:
+-        a9:9e:5d:e6:19:bf:f6:3c:5b:2b:d8:e4:3e:62:18:88:8b:d3:
+-        24:e1:40:9b:0c:e6:29:16:62:ab:ea:05:24:70:36:aa:55:93:
+-        ef:02:81:1b:23:10:a2:04:eb:56:95:75:fc:f8:94:b1:5d:42:
+-        c5:3f:36:44:85:5d:3a:2e:90:46:8a:a2:b9:6f:87:ae:0c:15:
+-        40:19:31:90:fc:3b:25:bb:ae:f1:66:13:0d:85:90:d9:49:34:
+-        8f:f2:5d:f9:7a:db:4d:5d:27:f6:76:9d:35:8c:06:a6:4c:a3:
+-        b1:b2:b6:6f:1d:d7:a3:00:fd:72:eb:9e:ea:44:a1:af:21:34:
+-        7d:c7:42:e2:49:91:19:8b:c0:ad:ba:82:80:a8:71:70:f4:35:
+-        31:91:63:84:20:95:e9:60:af:64:8b:cc:ff:3d:8a:76:74:3d:
+-        c8:55:6d:e4:8e:c3:2b:1c:e8:42:18:ae:9f:e6:6b:9c:34:06:
+-        ec:6a:f2:c3
+ -----BEGIN CERTIFICATE-----
+-MIIEEzCCAvugAwIBAgIBADANBgkqhkiG9w0BAQUFADCBnDELMAkGA1UEBhMCTk8x
+-DTALBgNVBAgTBE9zbG8xEDAOBgNVBAcTB055ZGFsZW4xFjAUBgNVBAoTDVRyb2xs
+-dGVjaCBBU0ExFDASBgNVBAsTC0RldmVsb3BtZW50MRcwFQYDVQQDEw5mbHVrZS50
+-cm9sbC5ubzElMCMGCSqGSIb3DQEJARYWYWhhbnNzZW5AdHJvbGx0ZWNoLmNvbTAe
+-Fw0wNzEyMDQwMTEwMzJaFw0zNTA0MjEwMTEwMzJaMGMxCzAJBgNVBAYTAk5PMQ0w
+-CwYDVQQIEwRPc2xvMRYwFAYDVQQKEw1Ucm9sbHRlY2ggQVNBMRQwEgYDVQQLEwtE
+-ZXZlbG9wbWVudDEXMBUGA1UEAxMOZmx1a2UudHJvbGwubm8wgZ8wDQYJKoZIhvcN
+-AQEBBQADgY0AMIGJAoGBAKfIoErEGQUbZroy4tLxHG8XguQ5LgFRkNsENDIRIcIN
+-b1nYU5BUP4OPqdOz1e4am4CuwyXJXqWvS2AFqqDRkQEfygSD41gcmTJFhHByWAOY
+-SmOLQfUISdKRAmBr5GT+3aCqdAjpNEyRXxI9N01ULK1/W5hgNgKMO/ZF8ydqm5Sd
+-AgMBAAGjggEaMIIBFjAJBgNVHRMEAjAAMCwGCWCGSAGG+EIBDQQfFh1PcGVuU1NM
+-IEdlbmVyYXRlZCBDZXJ0aWZpY2F0ZTAdBgNVHQ4EFgQUIYUEPSMBZuX3nxqEJIqv
+-Cnn05awwgbsGA1UdIwSBszCBsKGBoqSBnzCBnDELMAkGA1UEBhMCTk8xDTALBgNV
+-BAgTBE9zbG8xEDAOBgNVBAcTB055ZGFsZW4xFjAUBgNVBAoTDVRyb2xsdGVjaCBB
+-U0ExFDASBgNVBAsTC0RldmVsb3BtZW50MRcwFQYDVQQDEw5mbHVrZS50cm9sbC5u
+-bzElMCMGCSqGSIb3DQEJARYWYWhhbnNzZW5AdHJvbGx0ZWNoLmNvbYIJAI6otOiR
+-t1QuMA0GCSqGSIb3DQEBBQUAA4IBAQBtV1/RBUPwYgXsKnGl3BkI8sSmvbsl2cqJ
+-AQ7kzx/BjMgkGDVTWXvAQ7Qy5piypu8VBQtIX+GgDJepoXfYNRgwvKmP07dUx/Gp
+-nl3mGb/2PFsr2OQ+YhiIi9Mk4UCbDOYpFmKr6gUkcDaqVZPvAoEbIxCiBOtWlXX8
+-+JSxXULFPzZEhV06LpBGiqK5b4euDBVAGTGQ/Dslu67xZhMNhZDZSTSP8l35ettN
+-XSf2dp01jAamTKOxsrZvHdejAP1y657qRKGvITR9x0LiSZEZi8CtuoKAqHFw9DUx
+-kWOEIJXpYK9ki8z/PYp2dD3IVW3kjsMrHOhCGK6f5mucNAbsavLD
++MIIF6zCCA9OgAwIBAgIUfo9amJtJGWqWE6f+SkAO85zkGr4wDQYJKoZIhvcNAQEL
++BQAwgYMxCzAJBgNVBAYTAk5PMQ0wCwYDVQQIDARPc2xvMQ0wCwYDVQQHDARPc2xv
++MRcwFQYDVQQKDA5UaGUgUXQgQ29tcGFueTEMMAoGA1UECwwDUiZEMRIwEAYDVQQD
++DAlIMiBUZXN0ZXIxGzAZBgkqhkiG9w0BCQEWDG1pbmltaUBxdC5pbzAgFw0yMDEw
++MjYxMjAxMzFaGA8yMTIwMTAwMjEyMDEzMVowgYMxCzAJBgNVBAYTAk5PMQ0wCwYD
++VQQIDARPc2xvMQ0wCwYDVQQHDARPc2xvMRcwFQYDVQQKDA5UaGUgUXQgQ29tcGFu
++eTEMMAoGA1UECwwDUiZEMRIwEAYDVQQDDAlIMiBUZXN0ZXIxGzAZBgkqhkiG9w0B
++CQEWDG1pbmltaUBxdC5pbzCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIB
++AOiUp5+E4blouKH7q+rVNR8NoYX2XkBW+q+rpy1zu5ssRSzbqxAjDx9dkht7Qlnf
++VlDT00JvpOWdeuPon5915edQRsY4Unl6mKH29ra3OtUa1/yCJXsGVJTKCj7k4Bxb
++5mZzb/fTlZntMLdTIBMfUbw62FKir1WjKIcJ9fCoG8JaGeKVO4Rh5p0ezd4UUUId
++r1BXl5Nqdqy2vTMsEDnjOsD3egkv8I2SKN4O6n/C3wWYpMOWYZkGoZiKz7rJs/i/
++ez7bsV7JlwdzTlhpJzkcOSVFBP6JlEOxTNNxZ1wtKy7PtZGmsSSATq2e6+bw38Ae
++Op0XnzzqcGjtDDofBmT7OFzZWjS9VZS6+DOOe2QHWle1nCHcHyH4ku6IRlsr9xkR
++NAIlOfnvHHxqJUenoeaZ4oQDjCBKS1KXygJO/tL7BLTQVn/xK1EmPvKNnjzWk4tR
++PnibUhhs5635qpOU/YPqFBh1JjVruZbsWcDAhRcew0uxONXOa9E+4lttQ9ySYa1A
++LvWqJuAX7gu2BsBMLyqfm811YnA7CIFMyO+HlqmkLFfv5L/xIRAXR7l26YGO0VwX
++CGjMfz4NVPMMke4nB7qa9NkpXQBQKMms3Qzd5JW0Hy9Ruj5O8GPcFZmV0twjd1uJ
++PD/cAjkWLaXjdNsJ16QWc2nghQRS6HYqKRX6j+CXOxupAgMBAAGjUzBRMB0GA1Ud
++DgQWBBRSCOU58j9NJZkMamt623qyCrhN3TAfBgNVHSMEGDAWgBRSCOU58j9NJZkM
++amt623qyCrhN3TAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4ICAQCq
++q4jxsWeNDv5Nq14hJtF9HB+ZL64zcZtRjJP1YgNs0QppKICmjPOL2nIMGmI/jKrs
++0eGAL/9XXNVHPxm1OPOncvimMMmU6emZfpMdEtTfKP43+Pg9HgKRjLoQp406vGeQ
++8ki/mbBhrItVPgEm3tu2AFA02XTYi+YxCI9kRZLGkM3FbgtOuTLPl0Z9y+kiPc9F
++uCSC03anBEqv+vDSI8+wODymQ/IJ3Jyz1lxIRDfp4qAekmy0jU2c91VOHHEmOmqq
++kqygGFRdwbe99m9yP63r6q0b5K3X2UnJ6bns0hmTwThYwpVPXLU8jdaTddbMukN2
++/Ef96Tsw8nWOEOPMySHOTIPgwyZRp26b0kA9EmhLwOP401SxXVQCmSRmtwNagmtg
++jJKmZoYBN+//D45ibK8z6Q0oOm9P+Whf/uUXehcRxBxyV3xz7k0wKGQbHj/ddwcy
++IUoIN4lrAlib+lK170kTKN352PDmrpo2gmIzPEsfurKAIMSelDl6H+kih16BtZ8y
++Nz6fh9Soqrg3OSAware8pxV7k51crBMoPLN78KoRV8MFCK4K7Fddq4rRISq6hiXq
++r1nsjoEPuKM9huprmZVZe9t5YcDa2I+wb3IiE3uwpZbAdaLDyQ5n6F/qpsiIkZXn
++gtcF7oqpG5oYrwCcZ53y/ezUgUg7PlSz2XwAGvQtgg==
+ -----END CERTIFICATE-----
+diff --git a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
+index 9d1664d609..337ce541a6 100644
+--- a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
++++ b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
+@@ -1,15 +1,52 @@
+------BEGIN RSA PRIVATE KEY-----
+-MIICXAIBAAKBgQCnyKBKxBkFG2a6MuLS8RxvF4LkOS4BUZDbBDQyESHCDW9Z2FOQ
+-VD+Dj6nTs9XuGpuArsMlyV6lr0tgBaqg0ZEBH8oEg+NYHJkyRYRwclgDmEpji0H1
+-CEnSkQJga+Rk/t2gqnQI6TRMkV8SPTdNVCytf1uYYDYCjDv2RfMnapuUnQIDAQAB
+-AoGANFzLkanTeSGNFM0uttBipFT9F4a00dqHz6JnO7zXAT26I5r8sU1pqQBb6uLz
+-/+Qz5Zwk8RUAQcsMRgJetuPQUb0JZjF6Duv24hNazqXBCu7AZzUenjafwmKC/8ri
+-KpX3fTwqzfzi//FKGgbXQ80yykSSliDL3kn/drATxsLCgQECQQDXhEFWLJ0vVZ1s
+-1Ekf+3NITE+DR16X+LQ4W6vyEHAjTbaNWtcTKdAWLA2l6N4WAAPYSi6awm+zMxx4
+-VomVTsjdAkEAx0z+e7natLeFcrrq8pbU+wa6SAP1VfhQWKitxL1e7u/QO90NCpxE
+-oQYKzMkmmpOOFjQwEMAy1dvFMbm4LHlewQJAC/ksDBaUcQHHqjktCtrUb8rVjAyW
+-A8lscckeB2fEYyG5J6dJVaY4ClNOOs5yMDS2Afk1F6H/xKvtQ/5CzInA/QJATDub
+-K+BPU8jO9q+gpuIi3VIZdupssVGmCgObVCHLakG4uO04y9IyPhV9lA9tALtoIf4c
+-VIvv5fWGXBrZ48kZAQJBAJmVCdzQxd9LZI5vxijUCj5EI4e+x5DRqVUvyP8KCZrC
+-AiNyoDP85T+hBZaSXK3aYGpVwelyj3bvo1GrTNwNWLw=
+------END RSA PRIVATE KEY-----
++-----BEGIN PRIVATE KEY-----
++MIIJQgIBADANBgkqhkiG9w0BAQEFAASCCSwwggkoAgEAAoICAQDolKefhOG5aLih
+++6vq1TUfDaGF9l5AVvqvq6ctc7ubLEUs26sQIw8fXZIbe0JZ31ZQ09NCb6TlnXrj
++6J+fdeXnUEbGOFJ5epih9va2tzrVGtf8giV7BlSUygo+5OAcW+Zmc2/305WZ7TC3
++UyATH1G8OthSoq9VoyiHCfXwqBvCWhnilTuEYeadHs3eFFFCHa9QV5eTanastr0z
++LBA54zrA93oJL/CNkijeDup/wt8FmKTDlmGZBqGYis+6ybP4v3s+27FeyZcHc05Y
++aSc5HDklRQT+iZRDsUzTcWdcLSsuz7WRprEkgE6tnuvm8N/AHjqdF5886nBo7Qw6
++HwZk+zhc2Vo0vVWUuvgzjntkB1pXtZwh3B8h+JLuiEZbK/cZETQCJTn57xx8aiVH
++p6HmmeKEA4wgSktSl8oCTv7S+wS00FZ/8StRJj7yjZ481pOLUT54m1IYbOet+aqT
++lP2D6hQYdSY1a7mW7FnAwIUXHsNLsTjVzmvRPuJbbUPckmGtQC71qibgF+4LtgbA
++TC8qn5vNdWJwOwiBTMjvh5appCxX7+S/8SEQF0e5dumBjtFcFwhozH8+DVTzDJHu
++Jwe6mvTZKV0AUCjJrN0M3eSVtB8vUbo+TvBj3BWZldLcI3dbiTw/3AI5Fi2l43Tb
++CdekFnNp4IUEUuh2KikV+o/glzsbqQIDAQABAoICAFw1q6tr5I48vY7DF+rXsuLn
++5ZUWE1IQ6fzB4lr72nJv/9EEGnMgYzt9PpMUsD6vdCpBgS2C0+6RHArFzJtNA+RM
++iHLIG7K7702veyr/xBx/MwiSlMeMv/XpkFxVI6E6skMGG2s3AMXxKvJTy5CpRx+I
++eQFyLG+Ya1X2lgJes/q+/CpAHkOjCOpcLySQC5NZ74q734V7nSdmn+Zs3tYEh+O/
++eiuwTP/j5b38Te5vVTqDxTciJPmljmXLCwa0N100lWlbcpvw8qbqiTI2Jm3XCbUE
++AzHjW9vmrF3cRS1fXxKFGShw3SRqlkbxjfeWoi8qDPUBS4m8LOr8qG9Wo5Nfon0z
++zLP4bci3zHDvVcaaZrrsUBs/yZbg+Dgka1DmX7ekmeccr2yTdKDFgPupYUyxVbTl
++a9ZLJysjFD7rgBv1ZclHonLp6Vbm+ZoTqvteo4ikAy6L9RtBWJ23XEK34PkP/+c5
++2vWZaOrnjSeBHbFce8cdJSxqWpP+eSCI5I9XbDrYFIsQ/gqKgtzDKy2ihJ2Y8STL
++yO4hyFPFjxc+Gg4/P2PpmT5CY2ty44M0BWs+JGW96CJPrrplf2lmQUQJj5LZY66X
++Z/4C9L7ZYtKZ+bs5SvU46yWugAvQZX22Xm9xLXWyVXRdx3bj+3M3fDnF9di/zdbh
++CgLx7oWPNrXc7FCajnn9AoIBAQD5FMYwRpw9NWT9WDxQwx+cSI4Icbd88ByTW63S
++LzeRwZA0J9/SfwO+aBRupzc9GkGXCiZcGMw3AGsCtig8yFlw8E5KnzN7KlftDMnM
++9NUxxzlR8VwKyLnZfG7sDTl057ZlUujnqhmt/F8F7dIy7FVO1dE/8nngA+FYTCOG
++UZdGjwyBDlDM0JJdUWGY3xslutcpCDN5mzSTKjy9drMvImAshRawxRF6WBpn7vr2
++nC6vciqfx1Mzx1vyk0Jm0ilaydDdLMADjt/iL4Nkr0BEs4k+UzQiKDwp8gu7abQ1
++eBfxd9Iar4htQa2I1Ewl6P01G/q+ZYwgHhJ9RVn4AxQXefILAoIBAQDvCouORdQX
++C8wsyp7MwXlF/3NQeNN5/+B2mhbxrBOf7PmMCXLnkRWcjwJtzypWFqJ0sqai/2+0
++bqbMcjX5maT8stT2shl3zXe/Ejt2e3TBYpc1tyuses8Kb5BMU8hu6tTd3G2CMXpD
++dT6DVemJZCTtwj9aBNIxSizvlgMolJnCpzhPnlfHSI6E+g3m/LTTo3HwbjMSw/Uq
++irgjOpI2wSBB6LZPSgjvfcYPRyWUk16L4A5uSX0cADnovDFLa5/h0wJvN/OoCSQg
++rLCXG5E18EyL5Wc58BCY1ZvxmjG3lQtgPxYu2Jwc36R/y/JKlxW5suER5ZNpbbD4
++uOyTt2VxMQ2bAoIBAQC5+MzRFqdo/AjfL5Y5JrbfVTzXCTDa09xCGd16ZU60QTWN
+++4ed/r+o1sUKqUcRFB2MzEM/2DQBjQpZB/CbEWvWa1XJWXxypXbowveZU+QqOnmN
++uQvj8WLyA3o+PNF9e9QvauwCrHpn8VpxbtPWuaYoKnUFreFZZQxHhPGxRBIS2JOZ
++eDrT8ZaWnkCkh1AZp5smQ71LOprSlmKrg4jd1GjCVMxQR5N5KXbtyv0OTCZ/UFqK
++2aRBsMPyJgkaBChkZPLRcKwc+/wlQRx1fHQb14DNTApMxoXFO7eOwqmOkpAt9iyl
++SBIwoS0UUI5ab88+bBmXNvKcuFdNuQ4nowTJUn9pAoIBADMNkILBXSvS5DeIyuO2
++Sp1tkoZUV+5NfPY3sMDK3KIibaW/+t+EOBZo4L7tKQCb8vRzl21mmsfxfgRaPDbj
++3r3tv9g0b4YLxxBy52pFscj/soXRai17SS7UZwA2QK+XzgDYbDcLNC6mIsTQG4Gx
++dsWk3/zs3KuUSQaehmwrWK+fIUK38c1pLK8v7LoxrLkqxlHwZ04RthHw8KTthH7X
++Pnl1J0LF8CSeOyfWLSuPUfkT0GEzptnNHpEbaHfQM6R6eaGhVJPF6AZme4y6YYgg
++m2ihhSt1n0XVEWpHYWjxFy3mK2mz75unFC4LM+NEY2p2zuUQoCw7NjnY3QYrfCnx
++rRMCggEAXeXsMSLFjjyuoL7iKbAxo52HD/P0fBoy58LyRcwfNVr0lvYan4pYEx+o
++KijIh9K16PqXZXKMA9v003B+ulmF8bJ7SddCZ5NGvnFhUTDe4DdTKgp2RuwQ3Bsc
++3skPIDbhVETyOLCtys34USHrq8U/0DlGY3eLRfxw9GnbKxSBGa/KEu/qQLPNUo50
++7xHZDg7GKeC3kqNJeqKM9rkp0VzIGkEnaD9127LeNDmERDfftxJzFoC/THvUBLfU
++6Sus2ZYwRE8VFvKC30Q45t/c54X3IuhYvAuiCuTmyfE4ruyzyOwKzhUkeeLq1APX
++g0veFbyfzlJ0q8qzD/iffqqIa2ZSmQ==
++-----END PRIVATE KEY-----
+diff --git a/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp b/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
+index 7ba3715e13..752aa122f6 100644
+--- a/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
++++ b/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
+@@ -179,6 +179,7 @@ void tst_QAccessibilityLinux::initTestCase()
+     QVERIFY(!address.isEmpty());
+ 
+     m_window = new AccessibleTestWindow();
++    m_window->setObjectName("mainWindow"_L1);
+     m_window->show();
+ 
+     QVERIFY(QTest::qWaitForWindowExposed(m_window));
+@@ -236,8 +237,11 @@ bool hasState(QDBusInterface *interface, AtspiStateType state)
+ void tst_QAccessibilityLinux::testLabel()
+ {
+     QLabel *l = new QLabel(m_window);
++    l->setObjectName("theObjectName"_L1);
+     l->setText("Hello A11y");
+     m_window->addWidget(l);
++    auto a11yEmpty = new QLabel(m_window);
++    m_window->addWidget(l);
+ 
+     // Application
+     QCOMPARE(getParent(mainWindow), QLatin1String(ATSPI_DBUS_PATH_ROOT));
+@@ -249,6 +253,8 @@ void tst_QAccessibilityLinux::testLabel()
+     QCOMPARE(getChildren(labelInterface).count(), 0);
+     QCOMPARE(labelInterface->call(QDBus::Block, "GetRoleName").arguments().first().toString(), QLatin1String("label"));
+     QCOMPARE(labelInterface->call(QDBus::Block, "GetRole").arguments().first().toUInt(), 29u);
++    QCOMPARE(labelInterface->call(QDBus::Block, "GetAccessibleId").arguments().first().toString(),
++             QLatin1String("mainWindow.theObjectName"));
+     QCOMPARE(getParent(labelInterface), mainWindow->path());
+     QVERIFY(!hasState(labelInterface, ATSPI_STATE_EDITABLE));
+     QVERIFY(hasState(labelInterface, ATSPI_STATE_READ_ONLY));
+@@ -256,7 +262,12 @@ void tst_QAccessibilityLinux::testLabel()
+     l->setText("New text");
+     QCOMPARE(labelInterface->property("Name").toString(), l->text());
+ 
++    auto *a11yEmptyInterface = getInterface(children.at(1), "org.a11y.atspi.Accessible");
++    QCOMPARE(a11yEmptyInterface->call(QDBus::Block, "GetAccessibleId").arguments().first().toString(),
++             QLatin1String("mainWindow.QLabel"));
++
+     m_window->clearChildren();
++    delete a11yEmptyInterface;
+     delete labelInterface;
+ }
+ 
+diff --git a/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+index 76df61c892..6d6d65b791 100644
+--- a/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
++++ b/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2022 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the test suite of the Qt Toolkit.
+@@ -68,6 +68,8 @@ private slots:
+     void query_exec();
+     void execErrorRecovery_data() { generic_data(); }
+     void execErrorRecovery();
++    void prematureExec_data() { generic_data(); }
++    void prematureExec();
+     void first_data() { generic_data(); }
+     void first();
+     void next_data() { generic_data(); }
+@@ -2770,6 +2772,35 @@ void tst_QSqlQuery::execErrorRecovery()
+     QVERIFY_SQL( q, exec() );
+ }
+ 
++void tst_QSqlQuery::prematureExec()
++{
++    QFETCH(QString, dbName);
++    // We only want the engine name, for addDatabase():
++    int cut = dbName.indexOf(QChar('@'));
++    if (cut < 0)
++        QSKIP("Failed to parse database type out of name");
++    dbName.truncate(cut);
++    cut = dbName.indexOf(QChar('_'));
++    if (cut >= 0)
++        dbName = dbName.mid(cut + 1);
++
++    auto db = QSqlDatabase::addDatabase(dbName);
++    QSqlQuery q(db);
++
++    QTest::ignoreMessage(QtWarningMsg,
++                         "QSqlDatabasePrivate::removeDatabase: connection "
++                         "'qt_sql_default_connection' is still in use, all "
++                         "queries will cease to work.");
++    QTest::ignoreMessage(QtWarningMsg,
++                         "QSqlDatabasePrivate::addDatabase: duplicate connection name "
++                         "'qt_sql_default_connection', old connection removed.");
++    auto otherDb = QSqlDatabase::addDatabase(dbName);
++
++    QTest::ignoreMessage(QtWarningMsg, "QSqlQuery::exec: called before driver has been set up");
++    // QTBUG-100037: shouldn't crash !
++    QVERIFY(!q.exec("select stuff from TheVoid"));
++}
++
+ void tst_QSqlQuery::lastInsertId()
+ {
+     QFETCH( QString, dbName );
+diff --git a/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp b/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
+index 4aa3f8d60b..d2050a61aa 100644
+--- a/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
++++ b/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
+@@ -115,6 +115,10 @@ void tst_QAbstractItemModelTester::standardItemModelZeroColumns()
+     // QTBUG-92886
+     model.insertRows(0, 5);
+     model.removeRows(1, 2);
++
++    const QModelIndex parentIndex = model.index(0, 0);
++    model.insertRows(0, 5, parentIndex);
++    model.removeRows(1, 2, parentIndex);
+ }
+ 
+ void tst_QAbstractItemModelTester::testInsertThroughProxy()
+diff --git a/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json b/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
+index 12a4a22a19..ce518e78fb 100644
+--- a/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
++++ b/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
+@@ -668,50 +668,6 @@
+         "inputFile": "task192552.h",
+         "outputRevision": 67
+     },
+-    {
+-        "classes": [
+-            {
+-                "className": "InlineSlotsWithThrowDeclaration",
+-                "object": true,
+-                "qualifiedClassName": "InlineSlotsWithThrowDeclaration",
+-                "slots": [
+-                    {
+-                        "access": "public",
+-                        "name": "a",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "b",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "c",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "d",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "e",
+-                        "returnType": "void"
+-                    }
+-                ],
+-                "superClasses": [
+-                    {
+-                        "access": "public",
+-                        "name": "QObject"
+-                    }
+-                ]
+-            }
+-        ],
+-        "inputFile": "task189996.h",
+-        "outputRevision": 67
+-    },
+     {
+         "classes": [
+             {
+diff --git a/qtbase/tests/auto/tools/moc/moc.pro b/qtbase/tests/auto/tools/moc/moc.pro
+index c324b3a8cd..4aceb78dc0 100644
+--- a/qtbase/tests/auto/tools/moc/moc.pro
++++ b/qtbase/tests/auto/tools/moc/moc.pro
+@@ -15,7 +15,7 @@ cross_compile: DEFINES += MOC_CROSS_COMPILED
+ HEADERS += using-namespaces.h no-keywords.h task87883.h c-comments.h backslash-newlines.h oldstyle-casts.h \
+            slots-with-void-template.h qinvokable.h namespaced-flags.h trigraphs.h \
+            escapes-in-string-literals.h cstyle-enums.h qprivateslots.h gadgetwithnoenums.h \
+-           dir-in-include-path.h single_function_keyword.h task192552.h task189996.h \
++           dir-in-include-path.h single_function_keyword.h task192552.h \
+            task234909.h task240368.h pure-virtual-signals.h cxx11-enums.h \
+            cxx11-final-classes.h \
+            cxx11-explicit-override-control.h \
+diff --git a/qtbase/tests/auto/tools/moc/task189996.h b/qtbase/tests/auto/tools/moc/task189996.h
+deleted file mode 100644
+index f94a051b3a..0000000000
+--- a/qtbase/tests/auto/tools/moc/task189996.h
++++ /dev/null
+@@ -1,47 +0,0 @@
+-/****************************************************************************
+-**
+-** Copyright (C) 2016 The Qt Company Ltd.
+-** Contact: https://www.qt.io/licensing/
+-**
+-** This file is part of the test suite of the Qt Toolkit.
+-**
+-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+-** 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 General Public License Usage
+-** Alternatively, this file may be used under the terms of the GNU
+-** General Public License version 3 as published by the Free Software
+-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+-** 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-3.0.html.
+-**
+-** $QT_END_LICENSE$
+-**
+-****************************************************************************/
+-// inline functions can have throw declarations
+-
+-#ifndef TASK189996_H
+-#define TASK189996_H
+-
+-#include <QObject>
+-
+-class InlineSlotsWithThrowDeclaration : public QObject
+-{
+-    Q_OBJECT
+-
+-public slots:
+-    void a() throw() { }
+-    void b() const throw() { }
+-    void c() throw();
+-    void d() throw(int) { }
+-    void e() const throw(int,double) { }
+-};
+-
+-#endif
+diff --git a/qtbase/tests/auto/tools/moc/tst_moc.cpp b/qtbase/tests/auto/tools/moc/tst_moc.cpp
+index c716aead21..15dd9e41e5 100644
+--- a/qtbase/tests/auto/tools/moc/tst_moc.cpp
++++ b/qtbase/tests/auto/tools/moc/tst_moc.cpp
+@@ -631,7 +631,6 @@ public:
+ private slots:
+     void initTestCase();
+ 
+-    void slotWithException() throw(MyStruct);
+     void dontStripNamespaces();
+     void oldStyleCasts();
+     void warnOnExtraSignalSlotQualifiaction();
+@@ -673,7 +672,6 @@ private slots:
+     void templateGtGt();
+     void qprivateslots();
+     void qprivateproperties();
+-    void inlineSlotsWithThrowDeclaration();
+     void warnOnPropertyWithoutREAD();
+     void constructors();
+     void typenameWithUnsigned();
+@@ -784,12 +782,6 @@ void tst_Moc::initTestCase()
+ #endif
+ }
+ 
+-void tst_Moc::slotWithException() throw(MyStruct)
+-{
+-    // be happy
+-    QVERIFY(true);
+-}
+-
+ void tst_Moc::dontStripNamespaces()
+ {
+     Sender sender;
+@@ -824,7 +816,7 @@ void tst_Moc::oldStyleCasts()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-Wold-style-cast" << "-I" << "."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -894,7 +886,7 @@ void tst_Moc::inputFileNameWithDotsButNoExtension()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-I" << ".."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -1174,7 +1166,7 @@ void tst_Moc::ignoreOptionClashes()
+     QStringList gccArgs;
+     gccArgs << "-c" << "-x" << "c++" << "-I" << ".."
+          << "-I" << qtIncludePath << "-I" << includeDir << "-o" << "/dev/null"
+-         << "-fPIC" << "-std=c++11" <<  "-";
++         << "-fPIC" << "-std=c++1z" <<  "-";
+     proc.start("gcc", gccArgs);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -1593,21 +1585,6 @@ void tst_Moc::qprivateproperties()
+ 
+ }
+ 
+-#include "task189996.h"
+-
+-void InlineSlotsWithThrowDeclaration::c() throw() {}
+-
+-void tst_Moc::inlineSlotsWithThrowDeclaration()
+-{
+-    InlineSlotsWithThrowDeclaration tst;
+-    const QMetaObject *mobj = tst.metaObject();
+-    QVERIFY(mobj->indexOfSlot("a()") != -1);
+-    QVERIFY(mobj->indexOfSlot("b()") != -1);
+-    QVERIFY(mobj->indexOfSlot("c()") != -1);
+-    QVERIFY(mobj->indexOfSlot("d()") != -1);
+-    QVERIFY(mobj->indexOfSlot("e()") != -1);
+-}
+-
+ void tst_Moc::warnOnPropertyWithoutREAD()
+ {
+ #ifdef MOC_CROSS_COMPILED
+@@ -1869,7 +1846,7 @@ void tst_Moc::notifyError()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-I" << "."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+diff --git a/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+index c355ee9665..88c09de8e0 100644
+--- a/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
++++ b/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+@@ -251,6 +251,7 @@ private slots:
+     void testResetCachedSizeHint();
+     void statusTips();
+     void testRemovingColumnsViaLayoutChanged();
++    void testModelMovingColumns();
+ 
+ protected:
+     void setupTestData(bool use_reset_model = false);
+@@ -360,6 +361,12 @@ public:
+         endRemoveColumns();
+     }
+ 
++    void moveColumn(int from, int to)
++    {
++        beginMoveColumns(QModelIndex(), from, from, QModelIndex(), to);
++        endMoveColumns();
++    }
++
+     void cleanup()
+     {
+         emit layoutAboutToBeChanged();
+@@ -3627,5 +3634,18 @@ void tst_QHeaderView::testRemovingColumnsViaLayoutChanged()
+     // The main point of this test is that the section-size restoring code didn't go out of bounds.
+ }
+ 
++void tst_QHeaderView::testModelMovingColumns()
++{
++    QtTestModel model(10, 10);
++    QHeaderView hv(Qt::Horizontal);
++    hv.setModel(&model);
++    hv.resizeSections(QHeaderView::ResizeToContents);
++    hv.show();
++
++    QPersistentModelIndex index3 = model.index(0, 3);
++    model.moveColumn(3, 1);
++    QCOMPARE(index3.column(), 1);
++}
++
+ QTEST_MAIN(tst_QHeaderView)
+ #include "tst_qheaderview.moc"
+diff --git a/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+index 761357b252..06bb706074 100644
+--- a/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
++++ b/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+@@ -397,6 +397,7 @@ private slots:
+     void checkHeaderMinSize();
+ 
+     void resizeToContents();
++    void resizeToContentsSpans();
+ 
+     void tabFocus();
+     void bigModel();
+@@ -3721,6 +3722,70 @@ void tst_QTableView::resizeToContents()
+ 
+ }
+ 
++
++class SpanModel : public QAbstractTableModel
++{
++public:
++    SpanModel(bool sectionsMoved)
++        : _sectionsMoved(sectionsMoved)
++    {}
++    int columnCount(const QModelIndex & = {}) const override { return 2; }
++    int rowCount(const QModelIndex & = {}) const override { return 1; }
++    QVariant data(const QModelIndex &idx, int role = Qt::DisplayRole) const override
++    {
++        if (role != Qt::DisplayRole)
++            return QVariant();
++        const int col = _sectionsMoved ? 1 - idx.column() : idx.column();
++        if (col == 0)
++            return "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.";
++        return QVariant();
++    }
++private:
++    bool _sectionsMoved;
++};
++
++
++void tst_QTableView::resizeToContentsSpans()
++{
++    SpanModel model1(false);
++    SpanModel model2(true);
++    QTableView view1, view2, view3;
++    view1.setModel(&model1);
++    view2.setModel(&model2);
++    view2.horizontalHeader()->moveSection(0, 1);
++    view3.setModel(&model1);
++
++    view1.setSpan(0, 0, 1, 2);
++    view2.setSpan(0, 1, 1, 2);
++    view1.show();
++    view2.show();
++    view3.show();
++    QVERIFY(QTest::qWaitForWindowExposed(&view1));
++    QVERIFY(QTest::qWaitForWindowExposed(&view2));
++    QVERIFY(QTest::qWaitForWindowExposed(&view3));
++    view1.setColumnWidth(0, 100);
++    view1.setColumnWidth(1, 100);
++    view2.setColumnWidth(0, 100);
++    view2.setColumnWidth(1, 100);
++    view3.setColumnWidth(0, 200);
++
++    view1.resizeRowToContents(0);
++    view2.resizeRowToContents(0);
++    view3.resizeRowToContents(0);
++    QCOMPARE(view1.rowHeight(0), view3.rowHeight(0));
++    QCOMPARE(view2.rowHeight(0), view3.rowHeight(0));
++
++    view3.resizeColumnToContents(0);
++    view3.resizeRowToContents(0);
++    // height should be only 1 text line for easy testing
++    view1.setRowHeight(0, view3.verticalHeader()->sectionSize(0));
++    view2.setRowHeight(0, view3.verticalHeader()->sectionSize(0));
++    view1.resizeColumnToContents(0);
++    view2.resizeColumnToContents(1);
++    QCOMPARE(view1.columnWidth(0), view3.columnWidth(0) - view1.columnWidth(1));
++    QCOMPARE(view2.columnWidth(0), view3.columnWidth(0) - view2.columnWidth(1));
++}
++
+ QT_BEGIN_NAMESPACE
+ extern bool Q_WIDGETS_EXPORT qt_tab_all_widgets(); // qapplication.cpp
+ QT_END_NAMESPACE
+diff --git a/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+index a3b8ef78d8..4955cebd5d 100644
+--- a/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
++++ b/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+@@ -1498,7 +1498,7 @@ void tst_QApplication::desktopSettingsAware()
+     environment += QLatin1String("QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM=1");
+     testProcess.setEnvironment(environment);
+ #endif
+-    testProcess.start("desktopsettingsaware_helper");
++    testProcess.start("./desktopsettingsaware_helper");
+     QVERIFY2(testProcess.waitForStarted(),
+              qPrintable(QString::fromLatin1("Cannot start 'desktopsettingsaware_helper': %1").arg(testProcess.errorString())));
+     QVERIFY(testProcess.waitForFinished(10000));
+@@ -2452,7 +2452,7 @@ void tst_QApplication::qtbug_12673()
+ #if QT_CONFIG(process)
+     QProcess testProcess;
+     QStringList arguments;
+-    testProcess.start("modal_helper", arguments);
++    testProcess.start("./modal_helper", arguments);
+     QVERIFY2(testProcess.waitForStarted(),
+              qPrintable(QString::fromLatin1("Cannot start 'modal_helper': %1").arg(testProcess.errorString())));
+     QVERIFY(testProcess.waitForFinished(20000));
+diff --git a/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp b/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
+index eb108a40de..dca5528c1b 100644
+--- a/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
+@@ -41,6 +41,7 @@
+ 
+ #include <private/qguiapplication_p.h>
+ #include <qpa/qplatformintegration.h>
++#include <qpa/qplatformtheme.h>
+ 
+ class tst_QAbstractButton : public QObject
+ {
+@@ -76,6 +77,8 @@ private slots:
+     void keyNavigation();
+ #endif
+ 
++    void buttonPressKeys();
++
+ protected slots:
+     void onClicked();
+     void onToggled( bool on );
+@@ -269,7 +272,13 @@ void tst_QAbstractButton::setAutoRepeat()
+         QCOMPARE(press_count, click_count);
+         QVERIFY(click_count > 1);
+         break;
+-    case 4:
++    case 4: {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(Qt::Key_Enter)) {
++            QSKIP("platform theme has Key_Enter in ButtonPressKeys");
++        }
+         // check that pressing ENTER has no effect when autorepeat is false
+         testWidget->setDown( false );
+         testWidget->setAutoRepeat( false );
+@@ -286,7 +295,14 @@ void tst_QAbstractButton::setAutoRepeat()
+ 
+         QVERIFY( click_count == 0 );
+         break;
+-    case 5:
++    }
++    case 5: {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(Qt::Key_Enter)) {
++            QSKIP("platform theme has Key_Enter in ButtonPressKeys");
++        }
+         // check that pressing ENTER has no effect when autorepeat is true
+         testWidget->setDown( false );
+         testWidget->setAutoRepeat( true );
+@@ -304,6 +320,7 @@ void tst_QAbstractButton::setAutoRepeat()
+ 
+         QVERIFY( click_count == 0 );
+         break;
++    }
+     case 6:
+         // verify autorepeat is off by default.
+         MyButton tmp( 0);
+@@ -651,5 +668,16 @@ void tst_QAbstractButton::keyNavigation()
+ }
+ #endif
+ 
++void tst_QAbstractButton::buttonPressKeys()
++{
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(testWidget, buttonPressKeys[i]);
++        QCOMPARE(click_count, i + 1);
++    }
++}
++
+ QTEST_MAIN(tst_QAbstractButton)
+ #include "tst_qabstractbutton.moc"
+diff --git a/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+index 32437050f5..46b5af6d63 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+@@ -168,6 +168,7 @@ private slots:
+     void checkMenuItemPosWhenStyleSheetIsSet();
+     void checkEmbeddedLineEditWhenStyleSheetIsSet();
+     void propagateStyleChanges();
++    void buttonPressKeys();
+ 
+ private:
+     PlatformInputContext m_platformInputContext;
+@@ -1682,6 +1683,16 @@ void tst_QComboBox::setModel()
+     QCOMPARE(box.rootModelIndex(), rootModelIndex);
+     box.setModel(box.model());
+     QCOMPARE(box.rootModelIndex(), rootModelIndex);
++
++    // check that setting the same model as the completer's doesn't crash
++    QCompleter *completer = new QCompleter(&box);
++    box.setEditable(true);
++    box.setCompleter(completer);
++    auto *listModel = new QStringListModel({ "one", "two" }, completer);
++    completer->setModel(listModel);
++    QCOMPARE(listModel->rowCount(), 2); // make sure it wasn't deleted
++    box.setModel(listModel);
++    QCOMPARE(listModel->rowCount(), 2); // make sure it wasn't deleted
+ }
+ 
+ void tst_QComboBox::setCustomModelAndView()
+@@ -3632,5 +3643,24 @@ void tst_QComboBox::propagateStyleChanges()
+     QVERIFY(frameStyle.inquired);
+ }
+ 
++void tst_QComboBox::buttonPressKeys()
++{
++    QComboBox comboBox;
++    comboBox.setEditable(false);
++    comboBox.addItem(QString::number(1));
++    comboBox.addItem(QString::number(2));
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(&comboBox, buttonPressKeys[i]);
++        // On some platforms, a window will not be immediately visible,
++        // but take some event-loop iterations to complete.
++        // Using QTRY_VERIFY to deal with that.
++        QTRY_VERIFY(comboBox.view()->isVisible());
++        comboBox.hidePopup();
++    }
++}
++
+ QTEST_MAIN(tst_QComboBox)
+ #include "tst_qcombobox.moc"
+diff --git a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
+index be3cfcd104..c228fdfcca 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
++++ b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qcommandlinkbutton
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qcommandlinkbutton.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
+index 0044d33c66..4cf06296e4 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
+@@ -40,6 +40,9 @@
+ #include <QGridLayout>
+ #include <QPainter>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ class tst_QCommandLinkButton : public QObject
+ {
+     Q_OBJECT
+@@ -223,6 +226,13 @@ void tst_QCommandLinkButton::setAutoRepeat()
+     // check that pressing ENTER has no effect
+     resetCounters();
+     testWidget->setDown( false );
++    // Skip after reset if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
+     testWidget->setAutoRepeat( false );
+     QTest::keyPress( testWidget, Qt::Key_Enter );
+ 
+@@ -255,6 +265,14 @@ void tst_QCommandLinkButton::pressed()
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+ 
++    // Skip if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
++
+     QTest::keyPress( testWidget,Qt::Key_Enter );
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+diff --git a/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro b/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
+index 4a5e76ff65..a235fa1fac 100644
+--- a/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
++++ b/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qgroupbox
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qgroupbox.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp b/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
+index 4fb5d262ca..d8d7562b73 100644
+--- a/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
+@@ -35,6 +35,9 @@
+ #include <QRadioButton>
+ #include <QDialog>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ #include "qgroupbox.h"
+ 
+ class tst_QGroupBox : public QObject
+@@ -69,6 +72,7 @@ private slots:
+     void propagateFocus();
+     void task_QTBUG_19170_ignoreMouseReleaseEvent();
+     void task_QTBUG_15519_propagateMouseEvents();
++    void buttonPressKeys();
+ 
+ private:
+     bool checked;
+@@ -610,6 +614,20 @@ void tst_QGroupBox::task_QTBUG_15519_propagateMouseEvents()
+     QCOMPARE(parent.mouseMoved, true);
+ }
+ 
++void tst_QGroupBox::buttonPressKeys()
++{
++    QGroupBox groupBox;
++    groupBox.setCheckable(true);
++    QSignalSpy clickedSpy(&groupBox, &QGroupBox::clicked);
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(&groupBox, buttonPressKeys[i]);
++        QCOMPARE(clickedSpy.length(), i + 1);
++    }
++}
++
+ void tst_QGroupBox::sendMouseMoveEvent(QWidget *widget, const QPoint &localPos)
+ {
+     // Send a MouseMove event without actually moving the pointer
+diff --git a/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro b/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
+index 353ad06ca2..e55f6148f2 100644
+--- a/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
++++ b/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qpushbutton
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qpushbutton.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp b/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
+index e818514a79..4043e9326a 100644
+--- a/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
+@@ -41,6 +41,9 @@
+ #include <QStyleFactory>
+ #include <QTabWidget>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ class tst_QPushButton : public QObject
+ {
+ Q_OBJECT
+@@ -212,6 +215,13 @@ void tst_QPushButton::autoRepeat()
+     // check that pressing ENTER has no effect
+     resetCounters();
+     testWidget->setDown( false );
++    // Skip after reset if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
+     testWidget->setAutoRepeat( false );
+     QTest::keyPress( testWidget, Qt::Key_Enter );
+ 
+@@ -247,6 +257,14 @@ void tst_QPushButton::pressed()
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+ 
++    // Skip if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
++
+     QTest::keyPress( testWidget,Qt::Key_Enter );
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+diff --git a/qtbase/tests/manual/rhi/cubemap_render/buildshader.bat b/qtbase/tests/manual/rhi/cubemap_render/buildshader.bat
+old mode 100755
+new mode 100644
+Submodule qtconnectivity e957d481..056294c0:
+diff --git a/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp b/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
+index e2635fae..a8b8e3b9 100644
+--- a/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
++++ b/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
+@@ -563,9 +563,11 @@ void HciManager::handleHciAclPacket(const quint8 *data, int size)
+ 
+ void HciManager::handleLeMetaEvent(const quint8 *data)
+ {
+-    // Spec v4.2, Vol 2, part E, 7.7.65ff
++    // Spec v5.3, Vol 4, part E, 7.7.65.*
+     switch (*data) {
+-    case 0x1: {
++    case 0x1: // HCI_LE_Connection_Complete
++    case 0xA: // HCI_LE_Enhanced_Connection_Complete
++    {
+         const quint16 handle = bt_get_le16(data + 2);
+         emit connectionComplete(handle);
+         break;
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp b/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
+index 6a93143b..4a18cfc7 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
+@@ -320,7 +320,10 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_finishSdpScan(QBluetoothServiceD
+             for (const QBluetoothUuid &id : serviceClassUuids) {
+                 if (id.minimumSize() == 16) {
+                     serviceInfo.setServiceUuid(id);
+-                    serviceInfo.setServiceName(QBluetoothServiceDiscoveryAgent::tr("Custom Service"));
++                    if (serviceInfo.serviceName().isEmpty()) {
++                        serviceInfo.setServiceName(
++                                    QBluetoothServiceDiscoveryAgent::tr("Custom Service"));
++                    }
+                     QBluetoothServiceInfo::Sequence modSeq =
+                             serviceInfo.attribute(QBluetoothServiceInfo::ServiceClassIds).value<QBluetoothServiceInfo::Sequence>();
+                     modSeq.removeOne(QVariant::fromValue(id));
+@@ -334,8 +337,10 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_finishSdpScan(QBluetoothServiceD
+                 qCDebug(QT_BT_BLUEZ) << "Discovered services" << discoveredDevices.at(0).address().toString()
+                                      << serviceInfo.serviceName() << serviceInfo.serviceUuid()
+                                      << ">>>" << serviceInfo.serviceClassUuids();
+-
+-                emit q->serviceDiscovered(serviceInfo);
++                // Use queued connection to allow us finish the service looping; the application
++                // might call stop() when it has detected the service-of-interest.
++                QMetaObject::invokeMethod(q, "serviceDiscovered", Qt::QueuedConnection,
++                                          Q_ARG(QBluetoothServiceInfo, serviceInfo));
+             }
+         }
+     }
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp b/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
+index e4d85447..aadd4755 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
+@@ -593,7 +593,7 @@ void QBluetoothSocket::setSocketState(QBluetoothSocket::SocketState state)
+ bool QBluetoothSocket::canReadLine() const
+ {
+     Q_D(const QBluetoothSocketBase);
+-    return d->canReadLine();
++    return d->canReadLine() || QIODevice::canReadLine();
+ }
+ 
+ /*!
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp b/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
+index 084aa958..d6aa17a7 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
+@@ -284,6 +284,10 @@ void QBluetoothSocketPrivateBluezDBus::connectToService(
+         return;
+     }
+ 
++    if (service.socketProtocol() != QBluetoothServiceInfo::Protocol::UnknownProtocol)
++        socketType = service.socketProtocol();
++    qCDebug(QT_BT_BLUEZ) << "Socket protocol used:" << socketType;
++
+     connectToService(service.device().address(), targetService, openMode);
+ }
+ 
+diff --git a/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp b/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
+index 05bc1a0f..a7b5ef1f 100644
+--- a/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
++++ b/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
+@@ -142,7 +142,7 @@ void tst_QBluetoothSocket::initTestCase()
+     qDebug() << "Starting discovery";
+ 
+     sda->setUuidFilter(QBluetoothUuid(QString(TEST_SERVICE_UUID)));
+-    sda->start(QBluetoothServiceDiscoveryAgent::MinimalDiscovery);
++    sda->start(QBluetoothServiceDiscoveryAgent::FullDiscovery);
+ 
+     for (int connectTime = MaxConnectTime; !done_discovery && connectTime > 0; connectTime -= 1000)
+         QTest::qWait(1000);
+Submodule qtdeclarative f5701f0d..8defe7bf:
+diff --git a/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h b/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
+index b65b994d6c..15a8cd6878 100644
+--- a/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
++++ b/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
+@@ -86,7 +86,7 @@ public:
+         if (QTypeInfo<T>::isComplex) {
+             for (int i = 0; i < count; ++i)
+                 new (data + i) T(vector.at(i));
+-        } else {
++        } else if (count) {
+             memcpy(data, static_cast<const void*>(vector.constData()), count * sizeof(T));
+         }
+     }
+diff --git a/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp b/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
+index e57cdd8278..94613598af 100644
+--- a/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
++++ b/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
+@@ -1145,8 +1145,7 @@ void Heap::QObjectWrapper::markObjects(Heap::Base *that, QV4::MarkStack *markSta
+ void QObjectWrapper::destroyObject(bool lastCall)
+ {
+     Heap::QObjectWrapper *h = d();
+-    if (!h->internalClass)
+-        return; // destroyObject already got called
++    Q_ASSERT(h->internalClass);
+ 
+     if (h->object()) {
+         QQmlData *ddata = QQmlData::get(h->object(), false);
+@@ -1176,7 +1175,7 @@ void QObjectWrapper::destroyObject(bool lastCall)
+         }
+     }
+ 
+-    h->~Data();
++    h->destroy();
+ }
+ 
+ 
+diff --git a/qtdeclarative/src/qml/memory/qv4mm.cpp b/qtdeclarative/src/qml/memory/qv4mm.cpp
+index 06caf04e5a..da149a67c4 100644
+--- a/qtdeclarative/src/qml/memory/qv4mm.cpp
++++ b/qtdeclarative/src/qml/memory/qv4mm.cpp
+@@ -981,7 +981,7 @@ void MemoryManager::sweep(bool lastSweep, ClassDestroyStatsCallback classCountPt
+ 
+     if (MultiplyWrappedQObjectMap *multiplyWrappedQObjects = engine->m_multiplyWrappedQObjects) {
+         for (MultiplyWrappedQObjectMap::Iterator it = multiplyWrappedQObjects->begin(); it != multiplyWrappedQObjects->end();) {
+-            if (!it.value().isNullOrUndefined())
++            if (it.value().isNullOrUndefined())
+                 it = multiplyWrappedQObjects->erase(it);
+             else
+                 ++it;
+diff --git a/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp b/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
+index 2079a8ed04..a577cb2351 100644
+--- a/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
++++ b/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
+@@ -389,6 +389,12 @@ void QQmlDelegateModelPrivate::connectToAbstractItemModel()
+                       q,  QQmlDelegateModel, SLOT(_q_rowsRemoved(QModelIndex,int,int)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
+                       q,  QQmlDelegateModel, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsInserted(QModelIndex,int,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsInserted(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsRemoved(QModelIndex,int,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsRemoved(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsMoved(QModelIndex,int,int,QModelIndex,int)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
+                       q, QQmlDelegateModel, SLOT(_q_dataChanged(QModelIndex,QModelIndex,QVector<int>)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
+@@ -413,6 +419,12 @@ void QQmlDelegateModelPrivate::disconnectFromAbstractItemModel()
+                         q, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int)));
+     QObject::disconnect(aim, SIGNAL(rowsRemoved(QModelIndex,int,int)),
+                         q, SLOT(_q_rowsRemoved(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsInserted(QModelIndex,int,int)), q,
++                        SLOT(_q_columnsInserted(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsRemoved(QModelIndex,int,int)), q,
++                        SLOT(_q_columnsRemoved(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)), q,
++                        SLOT(_q_columnsMoved(QModelIndex,int,int,QModelIndex,int)));
+     QObject::disconnect(aim, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
+                         q, SLOT(_q_dataChanged(QModelIndex,QModelIndex,QVector<int>)));
+     QObject::disconnect(aim, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
+@@ -1973,6 +1985,38 @@ void QQmlDelegateModel::_q_rowsMoved(
+     }
+ }
+ 
++void QQmlDelegateModel::_q_columnsInserted(const QModelIndex &parent, int begin, int end)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if (parent == d->m_adaptorModel.rootIndex && begin == 0) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
++void QQmlDelegateModel::_q_columnsRemoved(const QModelIndex &parent, int begin, int end)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if (parent == d->m_adaptorModel.rootIndex && begin == 0) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
++void QQmlDelegateModel::_q_columnsMoved(const QModelIndex &parent, int start, int end,
++                                        const QModelIndex &destination, int column)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if ((parent == d->m_adaptorModel.rootIndex && start == 0)
++        || (destination == d->m_adaptorModel.rootIndex && column == 0)) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
+ void QQmlDelegateModel::_q_dataChanged(const QModelIndex &begin, const QModelIndex &end, const QVector<int> &roles)
+ {
+     Q_D(QQmlDelegateModel);
+diff --git a/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h b/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
+index 8aab4badca..d140bfbaaf 100644
+--- a/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
++++ b/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
+@@ -152,6 +152,9 @@ private Q_SLOTS:
+     void _q_itemsMoved(int from, int to, int count);
+     void _q_modelReset();
+     void _q_rowsInserted(const QModelIndex &,int,int);
++    void _q_columnsInserted(const QModelIndex &, int, int);
++    void _q_columnsRemoved(const QModelIndex &, int, int);
++    void _q_columnsMoved(const QModelIndex &, int, int, const QModelIndex &, int);
+     void _q_rowsAboutToBeRemoved(const QModelIndex &parent, int begin, int end);
+     void _q_rowsRemoved(const QModelIndex &,int,int);
+     void _q_rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int);
+diff --git a/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp b/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
+index 85719fdc80..78e2ab302c 100644
+--- a/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
++++ b/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
+@@ -46,6 +46,7 @@
+ #include "QtQuick/private/qquicktextinput_p.h"
+ #include "QtQuick/private/qquickaccessibleattached_p.h"
+ #include "QtQuick/qquicktextdocument.h"
++#include "QtQuick/qquickrendercontrol.h"
+ QT_BEGIN_NAMESPACE
+ 
+ #if QT_CONFIG(accessibility)
+@@ -57,7 +58,19 @@ QAccessibleQuickItem::QAccessibleQuickItem(QQuickItem *item)
+ 
+ QWindow *QAccessibleQuickItem::window() const
+ {
+-    return item()->window();
++    QQuickWindow *window = item()->window();
++
++    // For QQuickWidget the above window will be the offscreen QQuickWindow,
++    // which is not a part of the accessibility tree. Detect this case and
++    // return the window for the QQuickWidget instead.
++    if (window && !window->handle()) {
++        if (QQuickRenderControl *renderControl = QQuickWindowPrivate::get(window)->renderControl) {
++            if (QWindow *renderWindow = renderControl->renderWindow(nullptr))
++                return renderWindow;
++        }
++    }
++
++    return window;
+ }
+ 
+ int QAccessibleQuickItem::childCount() const
+@@ -113,19 +126,15 @@ QAccessibleInterface *QAccessibleQuickItem::childAt(int x, int y) const
+ QAccessibleInterface *QAccessibleQuickItem::parent() const
+ {
+     QQuickItem *parent = item()->parentItem();
+-    QQuickWindow *window = item()->window();
+-    QQuickItem *ci = window ? window->contentItem() : nullptr;
++    QQuickWindow *itemWindow = item()->window();
++    QQuickItem *ci = itemWindow ? itemWindow->contentItem() : nullptr;
+     while (parent && !QQuickItemPrivate::get(parent)->isAccessible && parent != ci)
+         parent = parent->parentItem();
+ 
+     if (parent) {
+         if (parent == ci) {
+-            // Jump out to the scene widget if the parent is the root item.
+-            // There are two root items, QQuickWindow::rootItem and
+-            // QQuickView::declarativeRoot. The former is the true root item,
+-            // but is not a part of the accessibility tree. Check if we hit
+-            // it here and return an interface for the scene instead.
+-            return QAccessible::queryAccessibleInterface(window);
++            // Jump out to the window if the parent is the root item
++            return QAccessible::queryAccessibleInterface(window());
+         } else {
+             while (parent && !parent->d_func()->isAccessible)
+                 parent = parent->parentItem();
+@@ -188,7 +197,7 @@ QAccessible::State QAccessibleQuickItem::state() const
+     QRect viewRect_ = viewRect();
+     QRect itemRect = rect();
+ 
+-    if (viewRect_.isNull() || itemRect.isNull() || !item()->window() || !item()->window()->isVisible() ||!item()->isVisible() || qFuzzyIsNull(item()->opacity()))
++    if (viewRect_.isNull() || itemRect.isNull() || !window() || !window()->isVisible() ||!item()->isVisible() || qFuzzyIsNull(item()->opacity()))
+         state.invisible = true;
+     if (!viewRect_.intersects(itemRect))
+         state.offscreen = true;
+@@ -201,6 +210,10 @@ QAccessible::State QAccessibleQuickItem::state() const
+     if (role() == QAccessible::EditableText)
+         if (auto ti = qobject_cast<QQuickTextInput *>(item()))
+             state.passwordEdit = ti->echoMode() != QQuickTextInput::Normal;
++    if (!item()->isEnabled()) {
++        state.focusable = false;
++        state.disabled = true;
++    }
+     return state;
+ }
+ 
+diff --git a/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h b/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
+index 39ffcaf39c..8baa01330c 100644
+--- a/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
++++ b/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
+@@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE
+ 
+ #if QT_CONFIG(accessibility)
+ 
+-class QAccessibleQuickWindow : public QAccessibleObject
++class Q_QUICK_EXPORT QAccessibleQuickWindow : public QAccessibleObject
+ {
+ public:
+     QAccessibleQuickWindow(QQuickWindow *object);
+diff --git a/qtdeclarative/src/quick/items/qquickdrag.cpp b/qtdeclarative/src/quick/items/qquickdrag.cpp
+index 8321fcfeed..383078b3b9 100644
+--- a/qtdeclarative/src/quick/items/qquickdrag.cpp
++++ b/qtdeclarative/src/quick/items/qquickdrag.cpp
+@@ -481,7 +481,9 @@ void QQuickDragAttached::setKeys(const QStringList &keys)
+     \qmlattachedproperty stringlist QtQuick::Drag::mimeData
+     \since 5.2
+ 
+-    This property holds a map of mimeData that is used during startDrag.
++    This property holds a map from mime type to data that is used during startDrag.
++    The mime data needs to be a \c string, or an \c ArrayBuffer with the data encoded
++    according to the mime type.
+ */
+ 
+ QVariantMap QQuickDragAttached::mimeData() const
+@@ -766,8 +768,12 @@ Qt::DropAction QQuickDragAttachedPrivate::startDrag(Qt::DropActions supportedAct
+     QDrag *drag = new QDrag(source ? source : q);
+     QMimeData *mimeData = new QMimeData();
+ 
+-    for (auto it = externalMimeData.cbegin(), end = externalMimeData.cend(); it != end; ++it)
+-        mimeData->setData(it.key(), it.value().toString().toUtf8());
++    for (auto it = externalMimeData.cbegin(), end = externalMimeData.cend(); it != end; ++it) {
++        if (static_cast<QMetaType::Type>(it.value().type()) == QMetaType::QByteArray)
++            mimeData->setData(it.key(), it.value().toByteArray());
++        else
++            mimeData->setData(it.key(), it.value().toString().toUtf8());
++    }
+ 
+     drag->setMimeData(mimeData);
+     if (pixmapLoader.isReady()) {
+diff --git a/qtdeclarative/src/quick/items/qquickitem.cpp b/qtdeclarative/src/quick/items/qquickitem.cpp
+index 75f1457816..dec0ae19ae 100644
+--- a/qtdeclarative/src/quick/items/qquickitem.cpp
++++ b/qtdeclarative/src/quick/items/qquickitem.cpp
+@@ -59,6 +59,7 @@
+ #include <QtCore/private/qnumeric_p.h>
+ #include <QtGui/qpa/qplatformtheme.h>
+ #include <QtCore/qloggingcategory.h>
++#include <QtCore/private/qduplicatetracker_p.h>
+ 
+ #include <private/qqmlglobal_p.h>
+ #include <private/qqmlengine_p.h>
+@@ -2326,6 +2327,7 @@ QQuickItem::QQuickItem(QQuickItemPrivate &dd, QQuickItem *parent)
+ QQuickItem::~QQuickItem()
+ {
+     Q_D(QQuickItem);
++    d->inDestructor = true;
+ 
+     if (d->windowRefCount > 1)
+         d->windowRefCount = 1; // Make sure window is set to null in next call to derefWindow().
+@@ -2526,6 +2528,7 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo
+     QQuickItem *current = item;
+     qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: startItem:" << startItem;
+     qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: firstFromItem:" << firstFromItem;
++    QDuplicateTracker<QQuickItem *> cycleDetector;
+     do {
+         qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: current:" << current;
+         qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: from:" << from;
+@@ -2592,7 +2595,10 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo
+         // traversed all of the chain (by compare the [current] item with [startItem])
+         // Since the [startItem] might be promoted to its parent if it is invisible,
+         // we still have to check [current] item with original start item
+-        if ((current == startItem || current == originalStartItem) && from == firstFromItem) {
++        // We might also run into a cycle before we reach firstFromItem again
++        // but note that we have to ignore current if we are meant to skip it
++        if (((current == startItem || current == originalStartItem) && from == firstFromItem) ||
++                (!skip && cycleDetector.hasSeen(current))) {
+             // wrapped around, avoid endless loops
+             if (item == contentItem) {
+                 qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: looped, return contentItem";
+@@ -2689,9 +2695,8 @@ void QQuickItem::setParentItem(QQuickItem *parentItem)
+ 
+         const bool wasVisible = isVisible();
+         op->removeChild(this);
+-        if (wasVisible) {
++        if (wasVisible && !op->inDestructor)
+             emit oldParentItem->visibleChildrenChanged();
+-        }
+     } else if (d->window) {
+         QQuickWindowPrivate::get(d->window)->parentlessItems.remove(this);
+     }
+@@ -2768,8 +2773,9 @@ void QQuickItem::setParentItem(QQuickItem *parentItem)
+ 
+     d->itemChange(ItemParentHasChanged, d->parentItem);
+ 
+-    emit parentChanged(d->parentItem);
+-    if (isVisible() && d->parentItem)
++    if (!d->inDestructor)
++        emit parentChanged(d->parentItem);
++    if (isVisible() && d->parentItem && !QQuickItemPrivate::get(d->parentItem)->inDestructor)
+         emit d->parentItem->visibleChildrenChanged();
+ }
+ 
+@@ -2965,7 +2971,8 @@ void QQuickItemPrivate::removeChild(QQuickItem *child)
+ 
+     itemChange(QQuickItem::ItemChildRemovedChange, child);
+ 
+-    emit q->childrenChanged();
++    if (!inDestructor)
++        emit q->childrenChanged();
+ }
+ 
+ void QQuickItemPrivate::refWindow(QQuickWindow *c)
+@@ -3194,6 +3201,7 @@ QQuickItemPrivate::QQuickItemPrivate()
+     , touchEnabled(false)
+ #endif
+     , hasCursorHandler(false)
++    , inDestructor(false)
+     , dirtyAttributes(0)
+     , nextDirtyItem(nullptr)
+     , prevDirtyItem(nullptr)
+@@ -5120,6 +5128,13 @@ void QQuickItem::componentComplete()
+         d->addToDirtyList();
+         QQuickWindowPrivate::get(d->window)->dirtyItem(this);
+     }
++
++#if QT_CONFIG(accessibility)
++    if (d->isAccessible && d->effectiveVisible) {
++        QAccessibleEvent ev(this, QAccessible::ObjectShow);
++        QAccessible::updateAccessibility(&ev);
++    }
++#endif
+ }
+ 
+ QQuickStateGroup *QQuickItemPrivate::_states()
+@@ -6106,9 +6121,11 @@ bool QQuickItemPrivate::setEffectiveVisibleRecur(bool newEffectiveVisible)
+         QAccessible::updateAccessibility(&ev);
+     }
+ #endif
+-    emit q->visibleChanged();
+-    if (childVisibilityChanged)
+-        emit q->visibleChildrenChanged();
++    if (!inDestructor) {
++        emit q->visibleChanged();
++        if (childVisibilityChanged)
++            emit q->visibleChildrenChanged();
++    }
+ 
+     return true;    // effective visibility DID change
+ }
+@@ -6157,6 +6174,15 @@ void QQuickItemPrivate::setEffectiveEnableRecur(QQuickItem *scope, bool newEffec
+     }
+ 
+     itemChange(QQuickItem::ItemEnabledHasChanged, effectiveEnable);
++#if QT_CONFIG(accessibility)
++    if (isAccessible) {
++        QAccessible::State changedState;
++        changedState.disabled = true;
++        changedState.focusable = true;
++        QAccessibleStateChangeEvent ev(q, changedState);
++        QAccessible::updateAccessibility(&ev);
++    }
++#endif
+     emit q->enabledChanged();
+ }
+ 
+diff --git a/qtdeclarative/src/quick/items/qquickitem_p.h b/qtdeclarative/src/quick/items/qquickitem_p.h
+index 841d91bb40..ade8fb61f2 100644
+--- a/qtdeclarative/src/quick/items/qquickitem_p.h
++++ b/qtdeclarative/src/quick/items/qquickitem_p.h
+@@ -472,6 +472,7 @@ public:
+     bool replayingPressEvent:1;
+     bool touchEnabled:1;
+     bool hasCursorHandler:1;
++    quint32 inDestructor:1; // has entered ~QQuickItem
+ 
+     enum DirtyType {
+         TransformOrigin         = 0x00000001,
+diff --git a/qtdeclarative/src/quick/items/qquickitemview.cpp b/qtdeclarative/src/quick/items/qquickitemview.cpp
+index 010a0152e1..f8ad168a17 100644
+--- a/qtdeclarative/src/quick/items/qquickitemview.cpp
++++ b/qtdeclarative/src/quick/items/qquickitemview.cpp
+@@ -1785,7 +1785,7 @@ void QQuickItemViewPrivate::refill(qreal from, qreal to)
+ 
+     do {
+         bufferPause.stop();
+-        if (currentChanges.hasPendingChanges() || bufferedChanges.hasPendingChanges()) {
++        if (currentChanges.hasPendingChanges() || bufferedChanges.hasPendingChanges() || currentChanges.active) {
+             currentChanges.reset();
+             bufferedChanges.reset();
+             releaseVisibleItems(reusableFlag);
+diff --git a/qtdeclarative/src/quick/items/qquickmousearea_p_p.h b/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
+index fba383e268..0d63618622 100644
+--- a/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
++++ b/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
+@@ -61,7 +61,6 @@ QT_BEGIN_NAMESPACE
+ 
+ class QQuickMouseEvent;
+ class QQuickMouseArea;
+-class QQuickPointerMask;
+ class QQuickMouseAreaPrivate : public QQuickItemPrivate
+ {
+     Q_DECLARE_PUBLIC(QQuickMouseArea)
+@@ -100,7 +99,6 @@ public:
+ #if QT_CONFIG(quick_draganddrop)
+     QQuickDrag *drag;
+ #endif
+-    QPointer<QQuickPointerMask> mask;
+     QPointF startScene;
+     QPointF targetStartPos;
+     QPointF lastPos;
+diff --git a/qtdeclarative/src/quick/items/qquicktext.cpp b/qtdeclarative/src/quick/items/qquicktext.cpp
+index 6230186933..e823ca1095 100644
+--- a/qtdeclarative/src/quick/items/qquicktext.cpp
++++ b/qtdeclarative/src/quick/items/qquicktext.cpp
+@@ -2168,7 +2168,7 @@ void QQuickText::resetMaximumLineCount()
+     <img src="" align="top,middle,bottom" width="" height=""> - inline images
+     <ol type="">, <ul type=""> and <li> - ordered and unordered lists
+     <pre></pre> - preformatted
+-    &gt; &lt; &amp;
++    &gt; &lt; &amp; &quot; &nbsp; &apos;
+     \endcode
+ 
+     \c Text.StyledText parser is strict, requiring tags to be correctly nested.
+diff --git a/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp b/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
+index eb4db0f85e..2325a2665b 100644
+--- a/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
++++ b/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
+@@ -446,7 +446,7 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+         const char *textureRecord = allocatorData;
+         for (int i = 0; i < textureCount; ++i, textureRecord += Qtdf::TextureRecordSize) {
+-            if (textureRecord + Qtdf::TextureRecordSize > qtdfTableEnd) {
++            if (qtdfTableEnd - textureRecord < Qtdf::TextureRecordSize) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+@@ -462,7 +462,7 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+         const char *glyphRecord = textureRecord;
+         for (quint32 i = 0; i < glyphCount; ++i, glyphRecord += Qtdf::GlyphRecordSize) {
+-            if (glyphRecord + Qtdf::GlyphRecordSize > qtdfTableEnd) {
++            if (qtdfTableEnd - glyphRecord < Qtdf:: GlyphRecordSize) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+@@ -512,8 +512,8 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+             int width = texInfo->allocatedArea.width();
+             int height = texInfo->allocatedArea.height();
+-            qint64 size = width * height;
+-            if (reinterpret_cast<const char *>(textureData + size) > qtdfTableEnd) {
++            qint64 size = qint64(width) * height;
++            if (qtdfTableEnd - reinterpret_cast<const char *>(textureData) < size) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+diff --git a/qtdeclarative/src/quick/util/qquickstyledtext.cpp b/qtdeclarative/src/quick/util/qquickstyledtext.cpp
+index d531fc9205..a25af90414 100644
+--- a/qtdeclarative/src/quick/util/qquickstyledtext.cpp
++++ b/qtdeclarative/src/quick/util/qquickstyledtext.cpp
+@@ -564,6 +564,8 @@ void QQuickStyledTextPrivate::parseEntity(const QChar *&ch, const QString &textI
+                 textOut += QChar(60);
+             else if (entity == QLatin1String("amp"))
+                 textOut += QChar(38);
++            else if (entity == QLatin1String("apos"))
++                textOut += QChar(39);
+             else if (entity == QLatin1String("quot"))
+                 textOut += QChar(34);
+             else if (entity == QLatin1String("nbsp"))
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp
+new file mode 100644
+index 0000000000..8a1c901880
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp
+@@ -0,0 +1,110 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include "qaccessiblequickwidget_p.h"
++
++#include "qquickwidget_p.h"
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleQuickWidget::QAccessibleQuickWidget(QQuickWidget* widget)
++: QAccessibleWidget(widget)
++, m_accessibleWindow(QQuickWidgetPrivate::get(widget)->offscreenWindow)
++{
++    // NOTE: m_accessibleWindow is a QAccessibleQuickWindow, and not a
++    // QAccessibleQuickWidgetOffscreenWindow (defined below). This means
++    // it will return the Quick item child interfaces, which is what's needed here
++    // (unlike QAccessibleQuickWidgetOffscreenWindow, which will report 0 children).
++}
++
++QAccessibleInterface *QAccessibleQuickWidget::child(int index) const
++{
++    return m_accessibleWindow.child(index);
++}
++
++int QAccessibleQuickWidget::childCount() const
++{
++    return m_accessibleWindow.childCount();
++}
++
++int QAccessibleQuickWidget::indexOfChild(const QAccessibleInterface *iface) const
++{
++    return m_accessibleWindow.indexOfChild(iface);
++}
++
++QAccessibleInterface *QAccessibleQuickWidget::childAt(int x, int y) const
++{
++    return m_accessibleWindow.childAt(x, y);
++}
++
++QAccessibleQuickWidgetOffscreenWindow::QAccessibleQuickWidgetOffscreenWindow(QQuickWindow *window)
++:QAccessibleQuickWindow(window)
++{
++
++}
++
++QAccessibleInterface *QAccessibleQuickWidgetOffscreenWindow::child(int index) const
++{
++    Q_UNUSED(index);
++    return nullptr;
++}
++
++int QAccessibleQuickWidgetOffscreenWindow::childCount() const
++{
++    return 0;
++}
++
++int QAccessibleQuickWidgetOffscreenWindow::indexOfChild(const QAccessibleInterface *iface) const
++{
++    Q_UNUSED(iface);
++    return -1;
++}
++
++QAccessibleInterface *QAccessibleQuickWidgetOffscreenWindow::QAccessibleQuickWidgetOffscreenWindow::childAt(int x, int y) const
++{
++    Q_UNUSED(x);
++    Q_UNUSED(y);
++    return nullptr;
++}
++
++#endif // accessibility
++
++QT_END_NAMESPACE
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h
+new file mode 100644
+index 0000000000..7c2ab930e0
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h
+@@ -0,0 +1,95 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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 QACCESSIBLEQUICKWIDGET_H
++#define QACCESSIBLEQUICKWIDGET_H
++
++//
++//  W A R N I N G
++//  -------------
++//
++// This file is not part of the Qt API.  It exists purely as an
++// implementation detail.  This header file may change from version to
++// version without notice, or even be removed.
++//
++// We mean it.
++//
++
++#include "qquickwidget.h"
++#include <QtWidgets/qaccessiblewidget.h>
++
++#include <private/qaccessiblequickview_p.h>
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++// These classes implement the QQuickWiget accessibility switcharoo,
++// where the child items of the QQuickWidgetOffscreenWindow are reported
++// as child accessible interfaces of the QAccessibleQuickWidget.
++class QAccessibleQuickWidget: public QAccessibleWidget
++{
++public:
++    QAccessibleQuickWidget(QQuickWidget* widget);
++
++    QAccessibleInterface *child(int index) const override;
++    int childCount() const override;
++    int indexOfChild(const QAccessibleInterface *iface) const override;
++    QAccessibleInterface *childAt(int x, int y) const override;
++
++private:
++    QAccessibleQuickWindow m_accessibleWindow;
++    Q_DISABLE_COPY(QAccessibleQuickWidget)
++};
++
++class QAccessibleQuickWidgetOffscreenWindow: public QAccessibleQuickWindow
++{
++public:
++    QAccessibleQuickWidgetOffscreenWindow(QQuickWindow *window);
++    QAccessibleInterface *child(int index) const override;
++    int childCount() const override;
++    int indexOfChild(const QAccessibleInterface *iface) const override;
++    QAccessibleInterface *childAt(int x, int y) const override;
++};
++
++#endif // accessibility
++
++QT_END_NAMESPACE
++
++#endif
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp
+new file mode 100644
+index 0000000000..7ba88a1769
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp
+@@ -0,0 +1,60 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include "qaccessiblequickwidgetfactory_p.h"
++#include "qaccessiblequickwidget_p.h"
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleInterface *qAccessibleQuickWidgetFactory(const QString &classname, QObject *object)
++{
++    if (classname == QLatin1String("QQuickWidget")) {
++        return new QAccessibleQuickWidget(qobject_cast<QQuickWidget *>(object));
++    } else if (classname == QLatin1String("QQuickWidgetOffscreenWindow")) {
++        return new QAccessibleQuickWidgetOffscreenWindow(qobject_cast<QQuickWindow *>(object));
++    }
++    return 0;
++}
++
++#endif // accessibility
++
++QT_END_NAMESPACE
++
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h
+new file mode 100644
+index 0000000000..8c63b09f81
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h
+@@ -0,0 +1,66 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include <QtGui/qaccessible.h>
++
++#ifndef QACCESSIBLEQUICKWIDGETFACTORY_H
++#define QACCESSIBLEQUICKWIDGETFACTORY_H
++
++//
++//  W A R N I N G
++//  -------------
++//
++// This file is not part of the Qt API.  It exists purely as an
++// implementation detail.  This header file may change from version to
++// version without notice, or even be removed.
++//
++// We mean it.
++//
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleInterface *qAccessibleQuickWidgetFactory(const QString &classname, QObject *object);
++
++#endif
++
++QT_END_NAMESPACE
++
++#endif
+diff --git a/qtdeclarative/src/quickwidgets/qquickwidget.cpp b/qtdeclarative/src/quickwidgets/qquickwidget.cpp
+index 39780f8de3..9c97b43518 100644
+--- a/qtdeclarative/src/quickwidgets/qquickwidget.cpp
++++ b/qtdeclarative/src/quickwidgets/qquickwidget.cpp
+@@ -39,6 +39,7 @@
+ 
+ #include "qquickwidget.h"
+ #include "qquickwidget_p.h"
++#include "qaccessiblequickwidgetfactory_p.h"
+ 
+ #include "private/qquickwindow_p.h"
+ #include "private/qquickitem_p.h"
+@@ -75,9 +76,16 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++QQuickWidgetOffscreenWindow::QQuickWidgetOffscreenWindow(QQuickWindowPrivate &dd, QQuickRenderControl *control)
++:QQuickWindow(dd, control)
++{
++    setTitle(QString::fromLatin1("Offscreen"));
++    setObjectName(QString::fromLatin1("QQuickOffScreenWindow"));
++}
++
+ // override setVisble to prevent accidental offscreen window being created
+ // by base class.
+-class QQuickOffcreenWindowPrivate: public QQuickWindowPrivate {
++class QQuickWidgetOffscreenWindowPrivate: public QQuickWindowPrivate {
+ public:
+     void setVisible(bool visible) override {
+         Q_Q(QWindow);
+@@ -105,9 +113,8 @@ void QQuickWidgetPrivate::init(QQmlEngine* e)
+     Q_Q(QQuickWidget);
+ 
+     renderControl = new QQuickWidgetRenderControl(q);
+-    offscreenWindow = new QQuickWindow(*new QQuickOffcreenWindowPrivate(),renderControl);
+-    offscreenWindow->setTitle(QString::fromLatin1("Offscreen"));
+-    offscreenWindow->setObjectName(QString::fromLatin1("QQuickOffScreenWindow"));
++    offscreenWindow = new QQuickWidgetOffscreenWindow(*new QQuickWidgetOffscreenWindowPrivate(), renderControl);
++    offscreenWindow->setScreen(q->screen());
+     // Do not call create() on offscreenWindow.
+ 
+     // Check if the Software Adaptation is being used
+@@ -138,6 +145,10 @@ void QQuickWidgetPrivate::init(QQmlEngine* e)
+     QWidget::connect(offscreenWindow, &QQuickWindow::focusObjectChanged, q, &QQuickWidget::propagateFocusObjectChanged);
+     QObject::connect(renderControl, SIGNAL(renderRequested()), q, SLOT(triggerUpdate()));
+     QObject::connect(renderControl, SIGNAL(sceneChanged()), q, SLOT(triggerUpdate()));
++
++#if QT_CONFIG(accessibility)
++    QAccessible::installFactory(&qAccessibleQuickWidgetFactory);
++#endif
+ }
+ 
+ void QQuickWidgetPrivate::ensureEngine() const
+@@ -901,9 +912,7 @@ void QQuickWidgetPrivate::createContext()
+ 
+         context = new QOpenGLContext;
+         context->setFormat(offscreenWindow->requestedFormat());
+-        const QWindow *win = q->window()->windowHandle();
+-        if (win && win->screen())
+-            context->setScreen(win->screen());
++        context->setScreen(q->screen());
+         QOpenGLContext *shareContext = qt_gl_global_share_context();
+         if (!shareContext)
+             shareContext = QWidgetPrivate::get(q->window())->shareContext();
+@@ -1520,19 +1529,16 @@ bool QQuickWidget::event(QEvent *e)
+         d->handleWindowChange();
+         break;
+ 
+-    case QEvent::ScreenChangeInternal:
+-        if (QWindow *window = this->window()->windowHandle()) {
+-            QScreen *newScreen = window->screen();
+-
+-            if (d->offscreenWindow)
+-                d->offscreenWindow->setScreen(newScreen);
+-            if (d->offscreenSurface)
+-                d->offscreenSurface->setScreen(newScreen);
++    case QEvent::ScreenChangeInternal: {
++        QScreen *newScreen = screen();
++        if (d->offscreenWindow)
++            d->offscreenWindow->setScreen(newScreen);
++        if (d->offscreenSurface)
++            d->offscreenSurface->setScreen(newScreen);
+ #if QT_CONFIG(opengl)
+-            if (d->context)
+-                d->context->setScreen(newScreen);
++        if (d->context)
++            d->context->setScreen(newScreen);
+ #endif
+-        }
+ 
+         if (d->useSoftwareRenderer
+ #if QT_CONFIG(opengl)
+@@ -1545,7 +1551,7 @@ bool QQuickWidget::event(QEvent *e)
+             d->render(true);
+         }
+         break;
+-
++    }
+     case QEvent::Show:
+     case QEvent::Move:
+         d->updatePosition();
+diff --git a/qtdeclarative/src/quickwidgets/qquickwidget_p.h b/qtdeclarative/src/quickwidgets/qquickwidget_p.h
+index 881f7f9220..1a946bcc71 100644
+--- a/qtdeclarative/src/quickwidgets/qquickwidget_p.h
++++ b/qtdeclarative/src/quickwidgets/qquickwidget_p.h
+@@ -148,6 +148,14 @@ public:
+     bool forceFullUpdate;
+ };
+ 
++class QQuickWidgetOffscreenWindow: public QQuickWindow
++{
++    Q_OBJECT
++
++public:
++    QQuickWidgetOffscreenWindow(QQuickWindowPrivate &dd, QQuickRenderControl *control);
++};
++
+ QT_END_NAMESPACE
+ 
+ #endif // QQuickWidget_P_H
+diff --git a/qtdeclarative/src/quickwidgets/quickwidgets.pro b/qtdeclarative/src/quickwidgets/quickwidgets.pro
+index 2438e577ae..85d156b8a3 100644
+--- a/qtdeclarative/src/quickwidgets/quickwidgets.pro
++++ b/qtdeclarative/src/quickwidgets/quickwidgets.pro
+@@ -7,9 +7,13 @@ DEFINES   += QT_NO_URL_CAST_FROM_STRING QT_NO_INTEGER_EVENT_COORDINATES QT_NO_FO
+ HEADERS += \
+     qquickwidget.h \
+     qquickwidget_p.h \
+-    qtquickwidgetsglobal.h
++    qtquickwidgetsglobal.h \
++    qaccessiblequickwidget_p.h \
++    qaccessiblequickwidgetfactory_p.h
+ 
+ SOURCES += \
+-    qquickwidget.cpp
++    qquickwidget.cpp \
++    qaccessiblequickwidget.cpp \
++    qaccessiblequickwidgetfactory.cpp
+ 
+ load(qt_module)
+diff --git a/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+index 3b7d74df63..b75bf820d5 100644
+--- a/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
++++ b/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+@@ -102,6 +102,7 @@ private slots:
+     void valueConversion_RegularExpression();
+     void castWithMultipleInheritance();
+     void collectGarbage();
++    void collectGarbageNestedWrappersTwoEngines();
+     void gcWithNestedDataStructure();
+     void stacktrace();
+     void numberParsing_data();
+@@ -1809,6 +1810,44 @@ void tst_QJSEngine::collectGarbage()
+     QVERIFY(ptr.isNull());
+ }
+ 
++class TestObjectContainer : public QObject
++{
++    Q_OBJECT
++    Q_PROPERTY(QObject *dummy MEMBER m_dummy CONSTANT)
++
++public:
++    TestObjectContainer() : m_dummy(new QObject(this)) {}
++
++private:
++    QObject *m_dummy;
++};
++
++void tst_QJSEngine::collectGarbageNestedWrappersTwoEngines()
++{
++    QJSEngine engine1;
++    QJSEngine engine2;
++
++    TestObjectContainer container;
++    QQmlEngine::setObjectOwnership(&container, QQmlEngine::CppOwnership);
++
++    engine1.globalObject().setProperty("foobar", engine1.newQObject(&container));
++    engine2.globalObject().setProperty("foobar", engine2.newQObject(&container));
++
++    engine1.evaluate("foobar.dummy.baz = 42");
++    engine2.evaluate("foobar.dummy.baz = 43");
++
++    QCOMPARE(engine1.evaluate("foobar.dummy.baz").toInt(), 42);
++    QCOMPARE(engine2.evaluate("foobar.dummy.baz").toInt(), 43);
++
++    engine1.collectGarbage();
++    engine2.collectGarbage();
++
++    // The GC should not collect dummy object wrappers neither in engine1 nor engine2, we
++    // verify that by checking whether the baz property still has its previous value.
++    QCOMPARE(engine1.evaluate("foobar.dummy.baz").toInt(), 42);
++    QCOMPARE(engine2.evaluate("foobar.dummy.baz").toInt(), 43);
++}
++
+ void tst_QJSEngine::gcWithNestedDataStructure()
+ {
+     // The GC must be able to traverse deeply nested objects, otherwise this
+diff --git a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml
+new file mode 100644
+index 0000000000..206133bb39
+--- /dev/null
++++ b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml
+@@ -0,0 +1,11 @@
++import QtQuick 2.8
++
++ListView {
++    id: root
++    width: 200
++    height: 200
++
++    delegate: Text {
++        text: display
++    }
++}
+diff --git a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
+index 35f1e2c94d..1722447830 100644
+--- a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
++++ b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
+@@ -27,6 +27,8 @@
+ ****************************************************************************/
+ 
+ #include <QtTest/qtest.h>
++#include <QtCore/QConcatenateTablesProxyModel>
++#include <QtGui/QStandardItemModel>
+ #include <QtQml/qqmlcomponent.h>
+ #include <QtQmlModels/private/qqmldelegatemodel_p.h>
+ #include <QtQuick/qquickview.h>
+@@ -47,6 +49,7 @@ private slots:
+     void filterOnGroup_removeWhenCompleted();
+     void qtbug_86017();
+     void contextAccessedByHandler();
++    void redrawUponColumnChange();
+ };
+ 
+ class AbstractItemModel : public QAbstractItemModel
+@@ -186,6 +189,30 @@ void tst_QQmlDelegateModel::contextAccessedByHandler()
+     QVERIFY(root->property("works").toBool());
+ }
+ 
++void tst_QQmlDelegateModel::redrawUponColumnChange()
++{
++    QStandardItemModel m1;
++    m1.appendRow({
++            new QStandardItem("Banana"),
++            new QStandardItem("Coconut"),
++    });
++
++    QQuickView view(testFileUrl("redrawUponColumnChange.qml"));
++    QCOMPARE(view.status(), QQuickView::Ready);
++    view.show();
++    QQuickItem *root = view.rootObject();
++    root->setProperty("model", QVariant::fromValue<QObject *>(&m1));
++
++    QObject *item = root->property("currentItem").value<QObject *>();
++    QVERIFY(item);
++    QCOMPARE(item->property("text").toString(), "Banana");
++
++    QVERIFY(root);
++    m1.removeColumn(0);
++
++    QCOMPARE(item->property("text").toString(), "Coconut");
++}
++
+ QTEST_MAIN(tst_QQmlDelegateModel)
+ 
+ #include "tst_qqmldelegatemodel.moc"
+diff --git a/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp b/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
+index 5d635aa63b..824fd89e5b 100644
+--- a/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
++++ b/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
+@@ -76,10 +76,10 @@ void tst_qv4mm::multiWrappedQObjects()
+         QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 1);
+         QCOMPARE(engine2.memoryManager->m_pendingFreedObjectWrapperValue.size(), 0);
+ 
+-        // Moves the additional WeakValue from m_multiplyWrappedQObjects to
+-        // m_pendingFreedObjectWrapperValue. It's still alive after all.
++        // The additional WeakValue from m_multiplyWrappedQObjects hasn't been moved
++        // to m_pendingFreedObjectWrapperValue yet. It's still alive after all.
+         engine1.memoryManager->runGC();
+-        QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 2);
++        QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 1);
+ 
+         // engine2 doesn't own the object as engine1 was the first to wrap it above.
+         // Therefore, no effect here.
+diff --git a/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml b/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml
+new file mode 100644
+index 0000000000..889e480f3b
+--- /dev/null
++++ b/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml
+@@ -0,0 +1,13 @@
++import QtQuick 2.6
++
++Item {
++    visible: true
++    Item {
++        visible: false
++        Item {
++            objectName: "hiddenChild"
++            activeFocusOnTab: true
++            focus: true
++        }
++    }
++}
+diff --git a/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp b/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+index c8f251dbe1..c8ef36ee68 100644
+--- a/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
++++ b/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+@@ -67,6 +67,7 @@ private slots:
+     void activeFocusOnTab10();
+     void activeFocusOnTab_infiniteLoop_data();
+     void activeFocusOnTab_infiniteLoop();
++    void activeFocusOnTab_infiniteLoopControls();
+ 
+     void nextItemInFocusChain();
+     void nextItemInFocusChain2();
+@@ -1057,6 +1058,17 @@ void tst_QQuickItem::activeFocusOnTab_infiniteLoop()
+     QCOMPARE(item, window->rootObject());
+ }
+ 
++
++void tst_QQuickItem::activeFocusOnTab_infiniteLoopControls()
++{
++    auto source = testFileUrl("activeFocusOnTab_infiniteLoop3.qml");
++    QScopedPointer<QQuickView>window(new QQuickView());
++    window->setSource(source);
++    window->show();
++    QVERIFY(window->errors().isEmpty());
++    QTest::keyClick(window.get(), Qt::Key_Tab); // should not hang
++}
++
+ void tst_QQuickItem::nextItemInFocusChain()
+ {
+     if (!qt_tab_all_widgets())
+Submodule qtdoc c0c7bf07...79d6ef69:
+Submodule qtimageformats 2dcf2899..abe44c0f:
+diff --git a/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp b/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
+index dde783c..1bf9074 100644
+--- a/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
+@@ -462,8 +462,12 @@ static bool parseIconEntryInfo(ICNSEntry &icon)
+     if (isIconCompressed(icon))
+         return true;
+     // Icon depth:
+-    if (!depth.isEmpty())
+-        icon.depth = ICNSEntry::Depth(depth.toUInt());
++    if (!depth.isEmpty()) {
++        const uint depthUInt = depth.toUInt();
++        if (depthUInt > 32)
++            return false;
++        icon.depth = ICNSEntry::Depth(depthUInt);
++    }
+     // Try mono if depth not found
+     if (icon.depth == ICNSEntry::DepthUnknown)
+         icon.depth = ICNSEntry::DepthMono;
+@@ -515,6 +519,9 @@ static bool parseIconEntryInfo(ICNSEntry &icon)
+         }
+         icon.height = icon.width;
+     }
++    // Sanity check
++    if (icon.width == 0 || icon.width > 4096)
++        return false;
+     return true;
+ }
+ 
+@@ -685,7 +692,7 @@ bool QICNSHandler::canRead() const
+ bool QICNSHandler::read(QImage *outImage)
+ {
+     QImage img;
+-    if (!ensureScanned()) {
++    if (!ensureScanned() || m_currentIconIndex >= m_icons.size()) {
+         qWarning("QICNSHandler::read(): The device wasn't parsed properly!");
+         return false;
+     }
+@@ -892,7 +899,7 @@ bool QICNSHandler::scanDevice()
+             return false;
+ 
+         const qint64 blockDataOffset = device()->pos();
+-        if (!isBlockHeaderValid(blockHeader)) {
++        if (!isBlockHeaderValid(blockHeader, ICNSBlockHeaderSize + filelength - blockDataOffset)) {
+             qWarning("QICNSHandler::scanDevice(): Failed, bad header at pos %s. OSType \"%s\", length %u",
+                      QByteArray::number(blockDataOffset).constData(),
+                      nameFromOSType(blockHeader.ostype).constData(), blockHeader.length);
+@@ -927,11 +934,14 @@ bool QICNSHandler::scanDevice()
+         case ICNSBlockHeader::TypeOdrp:
+             // Icns container seems to have an embedded icon variant container
+             // Let's start a scan for entries
+-            while (device()->pos() < nextBlockOffset) {
++            while (!stream.atEnd() && device()->pos() < nextBlockOffset) {
+                 ICNSBlockHeader icon;
+                 stream >> icon;
++                if (stream.status() != QDataStream::Ok)
++                    return false;
+                 // Check for incorrect variant entry header and stop scan
+-                if (!isBlockHeaderValid(icon, blockDataLength))
++                quint64 remaining = blockDataLength - (device()->pos() - blockDataOffset);
++                if (!isBlockHeaderValid(icon, ICNSBlockHeaderSize + remaining))
+                     break;
+                 if (!addEntry(icon, device()->pos(), blockHeader.ostype))
+                     return false;
+@@ -1003,7 +1013,7 @@ bool QICNSHandler::scanDevice()
+             break;
+         }
+     }
+-    return true;
++    return (m_icons.size() > 0);
+ }
+ 
+ const ICNSEntry &QICNSHandler::getIconMask(const ICNSEntry &icon) const
+diff --git a/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp b/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
+index 5082023..cb34374 100644
+--- a/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
++++ b/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
+@@ -43,6 +43,7 @@
+ #include "qimage.h"
+ #include "qvariant.h"
+ #include "qcolor.h"
++#include "qimagereader.h"
+ 
+ #include <jasper/jasper.h>
+ #include <math.h> // for pow
+@@ -333,16 +334,46 @@ private:
+ Jpeg2000JasperReader::Jpeg2000JasperReader(QIODevice *iod, SubFormat format)
+     : jasperOk(true), ioDevice(iod), format(format), hasAlpha(false)
+ {
++#if JAS_VERSION_MAJOR < 3
+     if (jas_init()) {
+         jasperOk = false;
+         qDebug("Jasper Library initialization failed");
+     }
++#else
++    jas_conf_clear();
++#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
++    jas_conf_set_max_mem_usage(QImageReader::allocationLimit() * 1024 * 1024);
++#else
++    // 128MB seems to be enough.
++    jas_conf_set_max_mem_usage(128 * 1024 * 1024);
++#endif
++    if (jas_init_library()) {
++        jasperOk = false;
++        qDebug("Jasper library initialization failed");
++    }
++    if (jas_init_thread()) {
++        jas_cleanup_library();
++        jasperOk = false;
++        qDebug("Jasper thread initialization failed");
++    }
++#endif
+ }
+ 
+ Jpeg2000JasperReader::~Jpeg2000JasperReader()
+ {
++#if JAS_VERSION_MAJOR < 3
+     if (jasperOk)
+         jas_cleanup();
++#else
++    if (jasperOk) {
++        if (jas_cleanup_thread()) {
++            qDebug("Jasper thread cleanup failed");
++        }
++        if (jas_cleanup_library()) {
++            qDebug("Jasper library cleanup failed");
++        }
++    }
++#endif
+ }
+ 
+ /*! \internal
+@@ -857,7 +888,7 @@ bool Jpeg2000JasperReader::write(const QImage &image, int quality)
+     }
+ 
+     // Open an empty jasper stream that grows automatically
+-    jas_stream_t * memory_stream = jas_stream_memopen(0, -1);
++    jas_stream_t * memory_stream = jas_stream_memopen(0, 0);
+ 
+     // Jasper wants a non-const string.
+     char *str = qstrdup(jasperFormatString.toLatin1().constData());
+diff --git a/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp b/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
+index 1386750..ac8956c 100644
+--- a/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
+@@ -361,6 +361,8 @@ bool QTiffHandler::read(QImage *image)
+     }
+ 
+     TIFF *const tiff = d->tiff;
++    if (TIFFIsTiled(tiff) && TIFFTileSize64(tiff) > uint64_t(image->sizeInBytes())) // Corrupt image
++        return false;
+     const quint32 width = d->size.width();
+     const quint32 height = d->size.height();
+ 
+diff --git a/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp b/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
+index 82d38cb..d02eb05 100644
+--- a/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
+@@ -45,6 +45,7 @@
+ #include <qdebug.h>
+ #include <qpainter.h>
+ #include <qvariant.h>
++#include <QtEndian>
+ 
+ static const int riffHeaderSize = 12; // RIFF_HEADER_SIZE from webp/format_constants.h
+ 
+@@ -102,21 +103,23 @@ bool QWebpHandler::ensureScanned() const
+ 
+     m_scanState = ScanError;
+ 
+-    if (device()->isSequential()) {
+-        qWarning() << "Sequential devices are not supported";
++    QWebpHandler *that = const_cast<QWebpHandler *>(this);
++    const int headerBytesNeeded = sizeof(WebPBitstreamFeatures);
++    QByteArray header = device()->peek(headerBytesNeeded);
++    if (header.size() < headerBytesNeeded)
+         return false;
+-    }
+ 
+-    qint64 oldPos = device()->pos();
+-    device()->seek(0);
+-
+-    QWebpHandler *that = const_cast<QWebpHandler *>(this);
+-    QByteArray header = device()->peek(sizeof(WebPBitstreamFeatures));
++    // We do no random access during decoding, just a readAll() of the whole image file. So if
++    // if it is all available already, we can accept a sequential device. The riff header contains
++    // the file size minus 8 bytes header
++    qint64 byteSize = qFromLittleEndian<quint32>(header.constData() + 4);
++    if (device()->isSequential() && device()->bytesAvailable() < byteSize + 8) {
++        qWarning() << "QWebpHandler: Insufficient data available in sequential device";
++        return false;
++    }
+     if (WebPGetFeatures((const uint8_t*)header.constData(), header.size(), &(that->m_features)) == VP8_STATUS_OK) {
+         if (m_features.has_animation) {
+             // For animation, we have to read and scan whole file to determine loop count and images count
+-            device()->seek(oldPos);
+-
+             if (that->ensureDemuxer()) {
+                 that->m_loop = WebPDemuxGetI(m_demuxer, WEBP_FF_LOOP_COUNT);
+                 that->m_frameCount = WebPDemuxGetI(m_demuxer, WEBP_FF_FRAME_COUNT);
+@@ -126,17 +129,13 @@ bool QWebpHandler::ensureScanned() const
+                 if (that->m_features.has_alpha)
+                     that->m_composited->fill(Qt::transparent);
+ 
+-                // We do not reset device position since we have read in all data
+                 m_scanState = ScanSuccess;
+-                return true;
+             }
+         } else {
+             m_scanState = ScanSuccess;
+         }
+     }
+ 
+-    device()->seek(oldPos);
+-
+     return m_scanState == ScanSuccess;
+ }
+ 
+@@ -159,7 +158,7 @@ bool QWebpHandler::ensureDemuxer()
+ 
+ bool QWebpHandler::read(QImage *image)
+ {
+-    if (!ensureScanned() || device()->isSequential() || !ensureDemuxer())
++    if (!ensureScanned() || !ensureDemuxer())
+         return false;
+ 
+     QRect prevFrameRect;
+Submodule qtlocation 98a5c511..f991e28c:
+diff --git a/qtlocation/src/location/configure.json b/qtlocation/src/location/configure.json
+index 6d01a9a3..d1e623a1 100644
+--- a/qtlocation/src/location/configure.json
++++ b/qtlocation/src/location/configure.json
+@@ -9,7 +9,7 @@
+             "label": "Qt.labs.location experimental QML plugin",
+             "purpose": "Provides experimental QtLocation QML types",
+             "section": "Location",
+-            "condition": "config.opengl",
++            "condition": "features.opengl",
+             "output": [ "privateFeature" ]
+         },
+         "geoservices_osm": {
+diff --git a/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp b/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
+index a978573d..11e1466f 100644
+--- a/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
++++ b/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
+@@ -158,7 +158,7 @@ void QGeoMapObjectQSGSupport::updateMapObjects(QSGNode *root, QQuickWindow *wind
+     if (!root)
+         return;
+ 
+-    if (m_mapObjectsRootNode && m_mapObjectsRootNode->parent())
++    if (m_mapObjectsRootNode && !m_mapObjectsRootNode->parent())
+         root->appendChildNode(m_mapObjectsRootNode.get());
+ 
+     if (!m_mapObjectsRootNode) {
+diff --git a/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
+index 5a40467e..d123c6a8 100644
+--- a/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
+@@ -59,8 +59,10 @@ QT_BEGIN_NAMESPACE
+ static const QString kPrefixEsri(QStringLiteral("esri."));
+ static const QString kParamUserAgent(kPrefixEsri + QStringLiteral("useragent"));
+ 
+-static const QString kUrlGeocode(QStringLiteral("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates"));
+-static const QString kUrlReverseGeocode(QStringLiteral("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode"));
++static const QString kUrlGeocode(QStringLiteral("https://geocode.arcgis.com/arcgis/rest/services/"
++                                                "World/GeocodeServer/findAddressCandidates"));
++static const QString kUrlReverseGeocode(QStringLiteral(
++        "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode"));
+ 
+ static QString addressToQuery(const QGeoAddress &address)
+ {
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
+index 17492d94..96c12b1b 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
+@@ -46,7 +46,8 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-// JSON reference: http://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
++// JSON reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
+ 
+ static const QString kErrorMessage(QStringLiteral("Error %1: %2."));
+ static const QString kErrorJson(QStringLiteral("Error: invalide JSON document."));
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
+index 8cadfb29..92b6bb13 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
+@@ -44,7 +44,8 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-// JSON reference: http://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
++// JSON reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
+ 
+ GeoRouteReplyEsri::GeoRouteReplyEsri(QNetworkReply *reply, const QGeoRouteRequest &request,
+                                      QObject *parent) :
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
+index 0e6bc2c7..ed613f4b 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
+@@ -48,7 +48,8 @@ static const QString kPrefixEsri(QStringLiteral("esri."));
+ static const QString kParamUserAgent(kPrefixEsri + QStringLiteral("useragent"));
+ static const QString kParamToken(kPrefixEsri + QStringLiteral("token"));
+ 
+-static const QString kUrlRouting(QStringLiteral("http://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve"));
++static const QString kUrlRouting(QStringLiteral(
++        "https://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve"));
+ 
+ GeoRoutingManagerEngineEsri::GeoRoutingManagerEngineEsri(const QVariantMap &parameters,
+                                                          QGeoServiceProvider::Error *error,
+@@ -70,7 +71,8 @@ GeoRoutingManagerEngineEsri::~GeoRoutingManagerEngineEsri()
+ {
+ }
+ 
+-// REST reference: http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
++// REST reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
+ 
+ QGeoRouteReply *GeoRoutingManagerEngineEsri::calculateRoute(const QGeoRouteRequest &request)
+ {
+@@ -125,7 +127,7 @@ void GeoRoutingManagerEngineEsri::replyError(QGeoRouteReply::Error errorCode, co
+ QString GeoRoutingManagerEngineEsri::preferedDirectionLangage()
+ {
+     // list of supported langages is defined in:
+-    // http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
++    // https://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
+     const QStringList supportedLanguages = {
+         "ar", // Generate directions in Arabic
+         "cs", // Generate directions in Czech
+diff --git a/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
+index 5d15835d..24148f95 100644
+--- a/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
+@@ -230,7 +230,8 @@ QGeoMap *GeoTiledMappingManagerEngineEsri::createMap()
+ // ${y} = Y
+ // ${token} = Token
+ 
+-// template = 'http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{{z}}/{{y}}/{{x}}.png'
++// template =
++// 'https://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{{z}}/{{y}}/{{x}}.png'
+ 
+ bool GeoTiledMappingManagerEngineEsri::initializeMapSources(QGeoServiceProvider::Error *error,
+                                                             QString *errorString,
+diff --git a/qtlocation/src/plugins/geoservices/esri/maps.json b/qtlocation/src/plugins/geoservices/esri/maps.json
+index 8167ae7d..862e087d 100644
+--- a/qtlocation/src/plugins/geoservices/esri/maps.json
++++ b/qtlocation/src/plugins/geoservices/esri/maps.json
+@@ -6,8 +6,8 @@
+             "description": "ArcGIS Online World Street Map",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=3b93337983e9436f8db950e38a8629af'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=3b93337983e9436f8db950e38a8629af'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -16,8 +16,8 @@
+             "": "ArcGIS Online World Imagery",
+             "mobile": true,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -26,8 +26,8 @@
+             "description": "ArcGIS Online World Terrain Base",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=c61ad8ab017d49e1a82f580ee1298931'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=c61ad8ab017d49e1a82f580ee1298931'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -36,8 +36,8 @@
+             "description": "ArcGIS Online World Topography",
+             "mobile": true,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=30e5fe3149c34df1ba922e6f5bbf808f'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=30e5fe3149c34df1ba922e6f5bbf808f'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -46,8 +46,8 @@
+             "description": "This map presents land cover and detailed topographic maps for the United States.",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=99cd5fbd98934028802b4f797c4b1732'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=99cd5fbd98934028802b4f797c4b1732'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -56,8 +56,8 @@
+             "description": "National Geographic World Map",
+             "mobile": false,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=b9b1b422198944fbbd5250b3241691b6'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=b9b1b422198944fbbd5250b3241691b6'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -66,8 +66,8 @@
+             "description": "Thematic content providing a neutral background with minimal colors",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=ed712cb1db3e4bae9e85329040fb9a49'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=ed712cb1db3e4bae9e85329040fb9a49'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -76,8 +76,8 @@
+             "description": "Natural Earth physical map for the world",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=c4ec722a1cd34cf0a23904aadf8923a0'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=c4ec722a1cd34cf0a23904aadf8923a0'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -86,8 +86,8 @@
+             "description": "Portrays surface elevation as shaded relief",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=9c5370d0b54f4de1b48a3792d7377ff2'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=9c5370d0b54f4de1b48a3792d7377ff2'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -96,8 +96,8 @@
+             "description": "This map is designed to be used as a basemap by marine GIS professionals and as a reference map by anyone interested in ocean data",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=1e126e7520f9466c9ca28b8f28b5e500'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=1e126e7520f9466c9ca28b8f28b5e500'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -106,8 +106,8 @@
+             "description": "Thematic content providing a neutral background with minimal colors",
+             "mobile": false,
+             "night": true,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=a284a9b99b3446a3910d4144a50990f6'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=a284a9b99b3446a3910d4144a50990f6'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -116,8 +116,8 @@
+             "description": "DeLorme’s topographic basemap is a seamless global data set that portrays transportation, hydrography, jurisdiction boundaries, and major geographic features",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/Specialty/DeLorme_World_Base_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=b165c3df453e4be6b5ac4fdb241effbe'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/Specialty/DeLorme_World_Base_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=b165c3df453e4be6b5ac4fdb241effbe'>Esri</a> contributors"
+         }
+     ]
+ }
+diff --git a/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
+index 3858ddf5..af66f28e 100644
+--- a/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
+@@ -63,8 +63,10 @@ static const QString kCountriesKey(QStringLiteral("detailedCountries"));
+ static const QString kLocalizedNamesKey(QStringLiteral("localizedNames"));
+ static const QString kMaxLocationsKey(QStringLiteral("maxLocations"));
+ 
+-static const QUrl kUrlGeocodeServer("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer?f=pjson");
+-static const QUrl kUrlFindAddressCandidates("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates");
++static const QUrl kUrlGeocodeServer(
++        "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer?f=pjson");
++static const QUrl kUrlFindAddressCandidates("https://geocode.arcgis.com/arcgis/rest/services/World/"
++                                            "GeocodeServer/findAddressCandidates");
+ 
+ PlaceManagerEngineEsri::PlaceManagerEngineEsri(const QVariantMap &parameters, QGeoServiceProvider::Error *error,
+                                                QString *errorString) :
+Submodule qtmultimedia f0344079..0d7cc33a:
+diff --git a/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp b/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
+index 2b5325132..b68b4af1b 100644
+--- a/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
++++ b/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
+@@ -402,6 +402,8 @@ int QPulseAudioInput::bytesReady() const
+ 
+ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ {
++    Q_ASSERT(data != nullptr || len == 0);
++
+     m_bytesAvailable = checkBytesReady();
+ 
+     setError(QAudio::NoError);
+@@ -411,7 +413,8 @@ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ 
+     if (!m_pullMode && !m_tempBuffer.isEmpty()) {
+         readBytes = qMin(static_cast<int>(len), m_tempBuffer.size());
+-        memcpy(data, m_tempBuffer.constData(), readBytes);
++        if (readBytes)
++            memcpy(data, m_tempBuffer.constData(), readBytes);
+         m_totalTimeValue += readBytes;
+ 
+         if (readBytes < m_tempBuffer.size()) {
+@@ -502,9 +505,10 @@ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ 
+ void QPulseAudioInput::applyVolume(const void *src, void *dest, int len)
+ {
++    Q_ASSERT((src && dest) || len == 0);
+     if (m_volume < 1.f)
+         QAudioHelperInternal::qMultiplySamples(m_volume, m_format, src, dest, len);
+-    else
++    else if (len)
+         memcpy(dest, src, len);
+ }
+ 
+Submodule qtpim 02efef5e...f9a8f0fc (commits not present)
+Submodule qtquick3d b85cf622..47defc8b:
+diff --git a/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro b/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
+index ca5c499e..174a075b 100644
+--- a/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
++++ b/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
+@@ -10,7 +10,7 @@ QT_FOR_CONFIG += assetimporters-private
+ include($$OUT_PWD/../qtassetimporters-config.pri)
+ 
+ qtConfig(system-assimp):!if(cross_compile:host_build) {
+-    QMAKE_USE_PRIVATE += assimp
++    QMAKE_USE_PRIVATE += quick3d-assimp
+ } else {
+     include(../../../3rdparty/assimp/assimp.pri)
+ }
+Submodule qtquickcontrols2 3a657dc0..56ce8233:
+diff --git a/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp b/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
+index e5fe734f7..e36922775 100644
+--- a/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
++++ b/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
+@@ -38,6 +38,7 @@
+ #include "qwidgetplatformmenuitem_p.h"
+ 
+ #include <QtGui/qwindow.h>
++#include <QtGui/private/qhighdpiscaling_p.h>
+ #include <QtWidgets/qmenu.h>
+ #include <QtWidgets/qaction.h>
+ 
+@@ -145,7 +146,7 @@ void QWidgetPlatformMenu::showPopup(const QWindow *window, const QRect &targetRe
+ 
+     QPoint targetPos = targetRect.bottomLeft();
+     if (window)
+-        targetPos = window->mapToGlobal(targetPos);
++        targetPos = window->mapToGlobal(QHighDpi::fromNativeLocalPosition(targetPos, window));
+ 
+     const QWidgetPlatformMenuItem *widgetItem = qobject_cast<const QWidgetPlatformMenuItem *>(item);
+     m_menu->popup(targetPos, widgetItem ? widgetItem->action() : nullptr);
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
+index 950e4e099..b81fbea0b 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
+@@ -387,6 +387,17 @@ void QQuickAbstractButtonPrivate::itemImplicitHeightChanged(QQuickItem *item)
+         emit q->implicitIndicatorHeightChanged();
+ }
+ 
++void QQuickAbstractButtonPrivate::itemDestroyed(QQuickItem *item)
++{
++    Q_Q(QQuickAbstractButton);
++    QQuickControlPrivate::itemDestroyed(item);
++    if (item == indicator) {
++        indicator = nullptr;
++        emit q->implicitIndicatorWidthChanged();
++        emit q->implicitIndicatorHeightChanged();
++    }
++}
++
+ QQuickAbstractButton *QQuickAbstractButtonPrivate::findCheckedButton() const
+ {
+     Q_Q(const QQuickAbstractButton);
+@@ -1176,6 +1187,12 @@ QAccessible::Role QQuickAbstractButton::accessibleRole() const
+     }
+     return QAccessible::Button;
+ }
++
++void QQuickAbstractButton::accessiblePressAction()
++{
++    Q_D(QQuickAbstractButton);
++    d->trigger();
++}
+ #endif
+ 
+ QT_END_NAMESPACE
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
+index 0fa48980e..ab66220d0 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
+@@ -209,6 +209,7 @@ protected:
+ #if QT_CONFIG(accessibility)
+     void accessibilityActiveChanged(bool active) override;
+     QAccessible::Role accessibleRole() const override;
++    Q_INVOKABLE void accessiblePressAction();
+ #endif
+ 
+ private:
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
+index 9291c1a87..b729720f2 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
+@@ -109,6 +109,7 @@ public:
+ 
+     void itemImplicitWidthChanged(QQuickItem *item) override;
+     void itemImplicitHeightChanged(QQuickItem *item) override;
++    void itemDestroyed(QQuickItem *item) override;
+ 
+     // copied from qabstractbutton.cpp
+     static const int AUTO_REPEAT_DELAY = 300;
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp b/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
+index 2041e7741..8610cdfae 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
+@@ -145,7 +145,7 @@ int QQuickActionPrivate::ShortcutEntry::shortcutId() const
+ 
+ void QQuickActionPrivate::ShortcutEntry::grab(const QKeySequence &shortcut, bool enabled)
+ {
+-    if (shortcut.isEmpty())
++    if (shortcut.isEmpty() || m_shortcutId)
+         return;
+ 
+     Qt::ShortcutContext context = Qt::WindowShortcut; // TODO
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp b/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
+index f38c2b09c..6eed2a024 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
+@@ -225,6 +225,7 @@ void QQuickContainerPrivate::cleanup()
+     QObject::disconnect(contentModel, &QQmlObjectModel::countChanged, q, &QQuickContainer::countChanged);
+     QObject::disconnect(contentModel, &QQmlObjectModel::childrenChanged, q, &QQuickContainer::contentChildrenChanged);
+     delete contentModel;
++    contentModel = nullptr;
+ }
+ 
+ QQuickItem *QQuickContainerPrivate::itemAt(int index) const
+@@ -436,7 +437,7 @@ void QQuickContainerPrivate::contentChildren_clear(QQmlListProperty<QQuickItem>
+ void QQuickContainerPrivate::updateContentWidth()
+ {
+     Q_Q(QQuickContainer);
+-    if (hasContentWidth || qFuzzyCompare(contentWidth, implicitContentWidth))
++    if (hasContentWidth || qFuzzyCompare(contentWidth, implicitContentWidth) || !contentModel)
+         return;
+ 
+     contentWidth = implicitContentWidth;
+@@ -446,7 +447,7 @@ void QQuickContainerPrivate::updateContentWidth()
+ void QQuickContainerPrivate::updateContentHeight()
+ {
+     Q_Q(QQuickContainer);
+-    if (hasContentHeight || qFuzzyCompare(contentHeight, implicitContentHeight))
++    if (hasContentHeight || qFuzzyCompare(contentHeight, implicitContentHeight) || !contentModel)
+         return;
+ 
+     contentHeight = implicitContentHeight;
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp b/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
+index bbbd0e622..1f4b47343 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
+@@ -845,6 +845,13 @@ void QQuickControlPrivate::executeBackground(bool complete)
+         quickCompleteDeferred(q, backgroundName(), background);
+ }
+ 
++/*
++    \internal
++
++    Hides an item that was replaced by a newer one, rather than
++    deleting it, as the item is typically created in QML and hence
++    we don't own it.
++*/
+ void QQuickControlPrivate::hideOldItem(QQuickItem *item)
+ {
+     if (!item)
+@@ -863,6 +870,29 @@ void QQuickControlPrivate::hideOldItem(QQuickItem *item)
+ #endif
+ }
+ 
++/*
++    \internal
++
++    Named "unhide" because it's used for cases where an item
++    that was previously hidden by \l hideOldItem() wants to be
++    shown by a control again, such as a ScrollBar in ScrollView.
++*/
++void QQuickControlPrivate::unhideOldItem(QQuickControl *control, QQuickItem *item)
++{
++    Q_ASSERT(item);
++    qCDebug(lcItemManagement) << "unhiding old item" << item;
++
++    item->setVisible(true);
++    item->setParentItem(control);
++
++#if QT_CONFIG(accessibility)
++    // Add the item back in to the accessibility tree.
++    QQuickAccessibleAttached *accessible = accessibleAttached(item);
++    if (accessible)
++        accessible->setIgnored(false);
++#endif
++}
++
+ void QQuickControlPrivate::updateBaselineOffset()
+ {
+     Q_Q(QQuickControl);
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h b/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
+index 8e979079e..a6e624c91 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
+@@ -173,6 +173,7 @@ public:
+     virtual void executeBackground(bool complete = false);
+ 
+     static void hideOldItem(QQuickItem *item);
++    static void unhideOldItem(QQuickControl *control, QQuickItem *item);
+ 
+     void updateBaselineOffset();
+ 
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp b/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
+index e6db14eb5..6197d1547 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
+@@ -237,7 +237,7 @@ static QRectF alignedRect(Qt::LayoutDirection direction, Qt::Alignment alignment
+ void QQuickDialogButtonBoxPrivate::resizeContent()
+ {
+     Q_Q(QQuickDialogButtonBox);
+-    if (!contentItem)
++    if (!contentItem || !contentModel)
+         return;
+ 
+     QRectF geometry = q->boundingRect().adjusted(q->leftPadding(), q->topPadding(), -q->rightPadding(), -q->bottomPadding());
+@@ -322,6 +322,9 @@ void QQuickDialogButtonBoxPrivate::updateLayout()
+ qreal QQuickDialogButtonBoxPrivate::getContentWidth() const
+ {
+     Q_Q(const QQuickDialogButtonBox);
++    if (!contentModel)
++        return 0;
++
+     const int count = contentModel->count();
+     const qreal totalSpacing = qMax(0, count - 1) * spacing;
+     qreal totalWidth = totalSpacing;
+@@ -341,6 +344,9 @@ qreal QQuickDialogButtonBoxPrivate::getContentWidth() const
+ qreal QQuickDialogButtonBoxPrivate::getContentHeight() const
+ {
+     Q_Q(const QQuickDialogButtonBox);
++    if (!contentModel)
++        return 0;
++
+     const int count = contentModel->count();
+     qreal maxHeight = 0;
+     for (int i = 0; i < count; ++i) {
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp b/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
+index 91bd59184..0ce518f84 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
+@@ -399,8 +399,11 @@ void QQuickOverlay::itemChange(ItemChange change, const ItemChangeData &data)
+     Q_D(QQuickOverlay);
+     QQuickItem::itemChange(change, data);
+ 
+-    if (change == ItemChildAddedChange || change == ItemChildRemovedChange)
++    if (change == ItemChildAddedChange || change == ItemChildRemovedChange) {
+         setVisible(!d->allDrawers.isEmpty() || !childItems().isEmpty());
++        if (data.item->parent() == d->mouseGrabberPopup)
++            d->setMouseGrabberPopup(nullptr);
++    }
+ }
+ 
+ void QQuickOverlay::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp b/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
+index 4e2f509db..1c4b308cd 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
+@@ -797,6 +797,14 @@ void QQuickScrollBarAttachedPrivate::initHorizontal()
+     if (parent && parent == flickable->parentItem())
+         horizontal->stackAfter(flickable);
+ 
++    // If a scroll bar was previously hidden (due to e.g. setting a new contentItem
++    // on a ScrollView), we need to make sure that we un-hide it.
++    // We don't bother checking if the item is actually the old one, because
++    // if it's not, all of the things the function does (setting parent, visibility, etc.)
++    // should be no-ops anyway.
++    if (auto control = qobject_cast<QQuickControl*>(q_ptr->parent()))
++        QQuickControlPrivate::unhideOldItem(control, horizontal);
++
+     layoutHorizontal();
+     horizontal->setSize(area->property("widthRatio").toReal());
+     horizontal->setPosition(area->property("xPosition").toReal());
+@@ -818,6 +826,9 @@ void QQuickScrollBarAttachedPrivate::initVertical()
+     if (parent && parent == flickable->parentItem())
+         vertical->stackAfter(flickable);
+ 
++    if (auto control = qobject_cast<QQuickControl*>(q_ptr->parent()))
++        QQuickControlPrivate::unhideOldItem(control, vertical);
++
+     layoutVertical();
+     vertical->setSize(area->property("heightRatio").toReal());
+     vertical->setPosition(area->property("yPosition").toReal());
+diff --git a/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml b/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
+index 0e8b08352..cd4931184 100644
+--- a/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
++++ b/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
+@@ -576,4 +576,51 @@ TestCase {
+         verify(newHorizontalScrollBar.visible)
+         verify(!oldHorizontalScrollBar.visible)
+     }
++
++    Component {
++        id: bindingToContentItemAndStandaloneFlickable
++
++        Item {
++            width: 200
++            height: 200
++
++            property alias scrollView: scrollView
++
++            ScrollView {
++                id: scrollView
++                anchors.fill: parent
++                contentItem: listView
++
++                property Item someBinding: contentItem
++            }
++            ListView {
++                id: listView
++                model: 10
++                delegate: ItemDelegate {
++                    text: modelData
++                    width: listView.width
++                }
++            }
++        }
++    }
++
++    // Tests that scroll bars show up for a ScrollView where
++    // - its contentItem is declared as a standalone, separate item
++    // - there is a binding to contentItem (which causes a default Flickable to be created)
++    function test_bindingToContentItemAndStandaloneFlickable() {
++        let root = createTemporaryObject(bindingToContentItemAndStandaloneFlickable, testCase)
++        verify(root)
++
++        let control = root.scrollView
++        let verticalScrollBar = control.ScrollBar.vertical
++        let horizontalScrollBar = control.ScrollBar.horizontal
++        compare(verticalScrollBar.parent, control)
++        compare(horizontalScrollBar.parent, control)
++        verify(verticalScrollBar.visible)
++        verify(horizontalScrollBar.visible)
++
++        mouseDrag(verticalScrollBar, verticalScrollBar.width / 2, verticalScrollBar.height / 2, 0, 50)
++        verify(verticalScrollBar.active)
++        verify(horizontalScrollBar.active)
++    }
+ }
+diff --git a/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml b/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
+index b3fab41ca..10b6baa02 100644
+--- a/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
++++ b/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
+@@ -608,4 +608,27 @@ TestCase {
+         mouseClick(control.indicator)
+         verify(control.activeFocus)
+     }
++
++    Component {
++        id: deletionOrder1
++        Item {
++            Image { id: innerImage }
++            Switch { indicator: innerImage }
++        }
++    }
++
++    Component {
++        id: deletionOrder2
++        Item {
++            Switch { indicator: innerImage }
++            Image { id: innerImage }
++        }
++    }
++
++    function test_deletionOrder() {
++        var control1 = createTemporaryObject(deletionOrder1, testCase)
++        verify(control1)
++        var control2 = createTemporaryObject(deletionOrder2, testCase)
++        verify(control2)
++    }
+ }
+diff --git a/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml b/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml
+new file mode 100644
+index 000000000..9e4598b9f
+--- /dev/null
++++ b/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml
+@@ -0,0 +1,78 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the test suite of the Qt Toolkit.
++**
++** $QT_BEGIN_LICENSE:BSD$
++** Commercial License Usage
++** Licensees holding valid commercial Qt licenses may use this file in
++** accordance with the commercial license agreement provided with the
++** Software or, alternatively, in accordance with the terms contained in
++** a written agreement between you and The Qt Company. For licensing terms
++** and conditions see https://www.qt.io/terms-conditions. For further
++** information use the contact form at https://www.qt.io/contact-us.
++**
++** BSD License Usage
++** Alternatively, you may use this file under the terms of the BSD license
++** as follows:
++**
++** "Redistribution and use in source and binary forms, with or without
++** modification, are permitted provided that the following conditions are
++** met:
++**   * Redistributions of source code must retain the above copyright
++**     notice, this list of conditions and the following disclaimer.
++**   * Redistributions in binary form must reproduce the above copyright
++**     notice, this list of conditions and the following disclaimer in
++**     the documentation and/or other materials provided with the
++**     distribution.
++**   * Neither the name of The Qt Company Ltd nor the names of its
++**     contributors may be used to endorse or promote products derived
++**     from this software without specific prior written permission.
++**
++**
++** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
++** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
++** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
++** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
++** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
++** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
++** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
++** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
++** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
++** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
++** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
++**
++** $QT_END_LICENSE$
++**
++****************************************************************************/
++
++import QtQuick 2.15
++import QtQuick.Controls 2.15
++
++ApplicationWindow {
++    id: window
++    width: 400
++    height: 400
++    title: "releaseAfterExitTransition"
++
++    property alias popup: popup
++    property alias modalPopup: modalPopup
++
++    Popup {
++        id: popup
++        y: parent.height - height
++        width: 50
++        height: 50
++    }
++
++    Popup {
++        id: modalPopup
++        modal: true
++        y: parent.height - height
++        width: 50
++        height: 50
++        exit:  Transition { PauseAnimation { duration: 100 } }
++    }
++}
+diff --git a/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp b/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
+index 54952d128..3d50e2dd4 100644
+--- a/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
++++ b/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
+@@ -100,6 +100,7 @@ private slots:
+     void invisibleToolTipOpen();
+     void centerInOverlayWithinStackViewItem();
+     void destroyDuringExitTransition();
++    void releaseAfterExitTransition();
+ };
+ 
+ void tst_QQuickPopup::initTestCase()
+@@ -1575,6 +1576,34 @@ void tst_QQuickPopup::destroyDuringExitTransition()
+     QVERIFY(!button->isDown());
+ }
+ 
++void tst_QQuickPopup::releaseAfterExitTransition()
++{
++    QQuickApplicationHelper helper(this, "releaseAfterExitTransition.qml");
++    QVERIFY2(helper.ready, helper.failureMessage());
++
++    QQuickWindow *window = helper.window;
++    window->show();
++    QVERIFY(QTest::qWaitForWindowActive(window));
++
++    QQuickOverlay *overlay = QQuickOverlay::overlay(window);
++    QQuickPopup *modalPopup = window->property("modalPopup").value<QQuickPopup *>();
++    QQuickPopup *popup = window->property("popup").value<QQuickPopup *>();
++
++    modalPopup->open();
++    QTRY_VERIFY(modalPopup->isOpened());
++
++    QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++    // wait until the transition is finished and the overlay hides itself
++    QTRY_VERIFY(!overlay->isVisible());
++    QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++
++    popup->open();
++    QTRY_VERIFY(popup->isOpened());
++    QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++    QTRY_VERIFY(!popup->isOpened());
++}
++
++
+ QTEST_QUICKCONTROLS_MAIN(tst_QQuickPopup)
+ 
+ #include "tst_qquickpopup.moc"
+Submodule qtscript 5be95f96...4d8e4bd2 (commits not present)
+Submodule qtspeech 17fc9fde..255845e2:
+diff --git a/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp b/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
+index 6eb74b8..bcc7dd1 100644
+--- a/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
++++ b/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
+@@ -357,7 +357,9 @@ QVector<QLocale> QTextToSpeechEngineSpeechd::availableLocales() const
+ 
+ QVector<QVoice> QTextToSpeechEngineSpeechd::availableVoices() const
+ {
+-    return m_voices.values(m_currentLocale.name()).toVector();
++    QList<QVoice> resultList = m_voices.values(m_currentLocale.name());
++    std::reverse(resultList.begin(), resultList.end());
++    return resultList.toVector();
+ }
+ 
+ // We have no way of knowing our own client_id since speech-dispatcher seems to be incomplete
+Submodule qtsvg 0c05780e..a7a0f249:
+diff --git a/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp b/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
+index 561e77e..12e0574 100644
+--- a/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
++++ b/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
+@@ -191,6 +191,8 @@ bool QSvgIOHandler::read(QImage *image)
+             }
+         }
+         if (!finalSize.isEmpty()) {
++            if (qMax(finalSize.width(), finalSize.height()) > 0xffff)
++                return false; // Assume corrupted file
+             image->fill(d->backColor.rgba());
+             QPainter p(image);
+             d->r.render(&p, bounds);
+diff --git a/qtsvg/src/svg/qsvghandler.cpp b/qtsvg/src/svg/qsvghandler.cpp
+index a5f877f..8dda563 100644
+--- a/qtsvg/src/svg/qsvghandler.cpp
++++ b/qtsvg/src/svg/qsvghandler.cpp
+@@ -1393,9 +1393,10 @@ static void parseFont(QSvgNode *node,
+         case FontSizeNone:
+             break;
+         case FontSizeValue: {
+-            QSvgHandler::LengthType dummy; // should always be pixel size
+-            fontStyle->setSize(qMin(parseLength(attributes.fontSize, dummy, handler),
+-                                    qreal(0xffff)));
++            QSvgHandler::LengthType type;
++            qreal fs = parseLength(attributes.fontSize, type, handler);
++            fs = convertToPixels(fs, true, type);
++            fontStyle->setSize(qMin(fs, qreal(0xffff)));
+         }
+             break;
+         default:
+@@ -2513,6 +2514,8 @@ static bool parseAnimateTransformNode(QSvgNode *parent,
+             ++s;
+         }
+     }
++    if (vals.count() % 3 != 0)
++        return false;
+ 
+     bool ok = true;
+     int begin = parseClockValue(beginStr, &ok);
+@@ -2576,6 +2579,8 @@ static QSvgNode *createCircleNode(QSvgNode *parent,
+     qreal ncx = toDouble(cx);
+     qreal ncy = toDouble(cy);
+     qreal nr  = toDouble(r);
++    if (nr < 0.0)
++        return nullptr;
+ 
+     QRectF rect(ncx-nr, ncy-nr, nr*2, nr*2);
+     QSvgNode *circle = new QSvgCircle(parent, rect);
+@@ -3046,15 +3051,16 @@ static QSvgStyleProperty *createRadialGradientNode(QSvgNode *node,
+ 
+     qreal ncx = 0.5;
+     qreal ncy = 0.5;
+-    qreal nr  = 0.5;
+     if (!cx.isEmpty())
+         ncx = toDouble(cx);
+     if (!cy.isEmpty())
+         ncy = toDouble(cy);
++
++    qreal nr = 0.0;
+     if (!r.isEmpty())
+         nr = toDouble(r);
+-    if (nr < 0.5)
+-        nr = 0.5;
++    if (nr <= 0.0)
++        return nullptr;
+ 
+     qreal nfx = ncx;
+     if (!fx.isEmpty())
+@@ -3350,7 +3356,9 @@ static QSvgNode *createTextNode(QSvgNode *parent,
+     //### editable and rotate not handled
+     QSvgHandler::LengthType type;
+     qreal nx = parseLength(x, type, handler);
++    nx = convertToPixels(nx, true, type);
+     qreal ny = parseLength(y, type, handler);
++    ny = convertToPixels(ny, true, type);
+ 
+     QSvgNode *text = new QSvgText(parent, QPointF(nx, ny));
+     return text;
+@@ -3691,9 +3699,7 @@ void QSvgHandler::parse()
+         case QXmlStreamReader::EndElement:
+             endElement(xml->name());
+             ++remainingUnfinishedElements;
+-            // if we are using somebody else's qxmlstreamreader
+-            // we should not read until the end of the stream
+-            done = !m_ownsReader && (xml->name() == QLatin1String("svg"));
++            done = (xml->name() == QLatin1String("svg"));
+             break;
+         case QXmlStreamReader::Characters:
+             characters(xml->text());
+diff --git a/qtsvg/src/svg/qsvgstructure.cpp b/qtsvg/src/svg/qsvgstructure.cpp
+index b89608b..89c9e4e 100644
+--- a/qtsvg/src/svg/qsvgstructure.cpp
++++ b/qtsvg/src/svg/qsvgstructure.cpp
+@@ -255,9 +255,13 @@ inline static bool isSupportedSvgFeature(const QString &str)
+     };
+ 
+     if (str.length() <= MAX_WORD_LENGTH && str.length() >= MIN_WORD_LENGTH) {
++        const char16_t unicode44 = str.at(44).unicode();
++        const char16_t unicode45 = str.at(45).unicode();
++        if (unicode44 >= sizeof(asso_values) || unicode45 >= sizeof(asso_values))
++            return false;
+         const int key = str.length()
+-                        + asso_values[str.at(45).unicode()]
+-                        + asso_values[str.at(44).unicode()];
++                        + asso_values[unicode45]
++                        + asso_values[unicode44];
+         if (key <= MAX_HASH_VALUE && key >= 0)
+             return str == QLatin1String(wordlist[key]);
+     }
+diff --git a/qtsvg/src/svg/qsvgtinydocument.cpp b/qtsvg/src/svg/qsvgtinydocument.cpp
+index 63d0797..19e7154 100644
+--- a/qtsvg/src/svg/qsvgtinydocument.cpp
++++ b/qtsvg/src/svg/qsvgtinydocument.cpp
+@@ -433,8 +433,16 @@ void QSvgTinyDocument::draw(QPainter *p, QSvgExtraStates &)
+     draw(p);
+ }
+ 
++static bool isValidMatrix(const QTransform &transform)
++{
++    qreal determinant = transform.determinant();
++    return qIsFinite(determinant);
++}
++
+ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect, const QRectF &sourceRect)
+ {
++    QTransform oldTransform = p->worldTransform();
++
+     QRectF target = targetRect;
+     if (target.isEmpty()) {
+         QPaintDevice *dev = p->device();
+@@ -487,6 +495,9 @@ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect,
+         }
+ #endif
+     }
++
++    if (!isValidMatrix(p->worldTransform()))
++        p->setWorldTransform(oldTransform);
+ }
+ 
+ QRectF QSvgTinyDocument::boundsOnElement(const QString &id) const
+diff --git a/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp b/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
+index 36c76ec..db71e02 100644
+--- a/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
++++ b/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
+@@ -86,6 +86,8 @@ private slots:
+     void oss_fuzz_23731();
+     void oss_fuzz_24131();
+     void oss_fuzz_24738();
++    void illegalAnimateTransform_data();
++    void illegalAnimateTransform();
+ 
+ #ifndef QT_NO_COMPRESS
+     void testGzLoading();
+@@ -1646,5 +1648,22 @@ void tst_QSvgRenderer::oss_fuzz_24738()
+     QSvgRenderer().load(QByteArray("<svg><path d=\"a 2 1e-212.....\">"));
+ }
+ 
++void tst_QSvgRenderer::illegalAnimateTransform_data()
++{
++    QTest::addColumn<QByteArray>("svg");
++
++    QTest::newRow("case1") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" values=\"8,0,5,0\">");
++    QTest::newRow("case2") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" values=\"1,2\">");
++    QTest::newRow("case3") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" from=\".. 5 2\" to=\"f\">");
++    QTest::newRow("case4") << QByteArray("<svg><animateTransform type=\"scale\" begin=\"1\" dur=\"2\" by=\"--,..\">");
++}
++
++void tst_QSvgRenderer::illegalAnimateTransform()
++{
++    QFETCH(QByteArray, svg);
++    QSvgRenderer renderer;
++    QVERIFY(!renderer.load(svg)); // also shouldn't assert
++}
++
+ QTEST_MAIN(tst_QSvgRenderer)
+ #include "tst_qsvgrenderer.moc"
+Submodule qttools 6914f7c8..090e526e:
+diff --git a/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp b/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
+index feab1e2d5..cbfb82507 100644
+--- a/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
++++ b/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
+@@ -445,7 +445,9 @@ bool HelpGeneratorPrivate::insertFiles(const QStringList &files, const QString &
+     if (filterSetId < 0)
+         return false;
+     ++filterSetId;
+-    for (int attId : qAsConst(filterAtts)) {
++    QList<int> attValues = filterAtts.values();
++    std::sort(attValues.begin(), attValues.end());
++    for (int attId : qAsConst(attValues)) {
+         m_query->prepare(QLatin1String("INSERT INTO FileAttributeSetTable "
+             "VALUES(?, ?)"));
+         m_query->bindValue(0, filterSetId);
+Submodule qtwayland dfb0129c..2904e1b3:
+diff --git a/qtwayland/src/client/configure.json b/qtwayland/src/client/configure.json
+index 2f424580..29222357 100644
+--- a/qtwayland/src/client/configure.json
++++ b/qtwayland/src/client/configure.json
+@@ -149,8 +149,7 @@
+                     "#endif"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "vulkan-server-buffer": {
+             "label": "Vulkan Buffer Sharing",
+@@ -168,7 +167,8 @@
+                     "exportAllocInfo.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR;",
+                     "return 0;"
+                 ]
+-            }
++            },
++            "use": "wayland-client"
+         },
+         "egl_1_5-wayland": {
+             "label": "EGL 1.5 with Wayland Platform",
+@@ -183,7 +183,7 @@
+                     "eglGetPlatformDisplay(EGL_PLATFORM_WAYLAND_EXT, (struct wl_display *)(nullptr), nullptr);"
+                 ]
+             },
+-            "use": "egl"
++            "use": "egl wayland-client"
+         }
+     },
+ 
+diff --git a/qtwayland/src/client/global/qwaylandclientextension.cpp b/qtwayland/src/client/global/qwaylandclientextension.cpp
+index 125b1e19..edccfe63 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension.cpp
++++ b/qtwayland/src/client/global/qwaylandclientextension.cpp
+@@ -74,7 +74,10 @@ void QWaylandClientExtensionPrivate::handleRegistryGlobal(void *data, ::wl_regis
+ void QWaylandClientExtension::addRegistryListener()
+ {
+     Q_D(QWaylandClientExtension);
+-    d->waylandIntegration->display()->addRegistryListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++    if (!d->registered) {
++        d->waylandIntegration->display()->addRegistryListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++        d->registered = true;
++    }
+ }
+ 
+ QWaylandClientExtension::QWaylandClientExtension(const int ver)
+@@ -88,6 +91,13 @@ QWaylandClientExtension::QWaylandClientExtension(const int ver)
+     QMetaObject::invokeMethod(this, "addRegistryListener", Qt::QueuedConnection);
+ }
+ 
++QWaylandClientExtension::~QWaylandClientExtension()
++{
++    Q_D(QWaylandClientExtension);
++    if (d->registered && !QCoreApplication::closingDown())
++        d->waylandIntegration->display()->removeListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++}
++
+ QtWaylandClient::QWaylandIntegration *QWaylandClientExtension::integration() const
+ {
+     Q_D(const QWaylandClientExtension);
+diff --git a/qtwayland/src/client/global/qwaylandclientextension.h b/qtwayland/src/client/global/qwaylandclientextension.h
+index 98272e57..5bd28398 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension.h
++++ b/qtwayland/src/client/global/qwaylandclientextension.h
+@@ -63,6 +63,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandClientExtension : public QObject
+     Q_PROPERTY(bool active READ isActive NOTIFY activeChanged)
+ public:
+     QWaylandClientExtension(const int version);
++    ~QWaylandClientExtension();
+ 
+     QtWaylandClient::QWaylandIntegration *integration() const;
+     int version() const;
+diff --git a/qtwayland/src/client/global/qwaylandclientextension_p.h b/qtwayland/src/client/global/qwaylandclientextension_p.h
+index 69cc46a0..9091efbe 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension_p.h
++++ b/qtwayland/src/client/global/qwaylandclientextension_p.h
+@@ -68,6 +68,7 @@ public:
+     QtWaylandClient::QWaylandIntegration *waylandIntegration = nullptr;
+     int version = -1;
+     bool active = false;
++    bool registered = false;
+ };
+ 
+ class Q_WAYLAND_CLIENT_EXPORT QWaylandClientExtensionTemplatePrivate : public QWaylandClientExtensionPrivate
+diff --git a/qtwayland/src/client/qwaylanddatadevice.cpp b/qtwayland/src/client/qwaylanddatadevice.cpp
+index 7e2e3308..e3e60ed5 100644
+--- a/qtwayland/src/client/qwaylanddatadevice.cpp
++++ b/qtwayland/src/client/qwaylanddatadevice.cpp
+@@ -72,6 +72,8 @@ QWaylandDataDevice::QWaylandDataDevice(QWaylandDataDeviceManager *manager, QWayl
+ 
+ QWaylandDataDevice::~QWaylandDataDevice()
+ {
++    if (wl_data_device_get_version(object()) >= WL_DATA_DEVICE_RELEASE_SINCE_VERSION)
++        release();
+ }
+ 
+ QWaylandDataOffer *QWaylandDataDevice::selectionOffer() const
+@@ -110,7 +112,7 @@ QWaylandDataOffer *QWaylandDataDevice::dragOffer() const
+     return m_dragOffer.data();
+ }
+ 
+-bool QWaylandDataDevice::startDrag(QMimeData *mimeData, QWaylandWindow *icon)
++bool QWaylandDataDevice::startDrag(QMimeData *mimeData, Qt::DropActions supportedActions, QWaylandWindow *icon)
+ {
+     auto *seat = m_display->currentInputDevice();
+     auto *origin = seat->pointerFocus();
+@@ -123,7 +125,28 @@ bool QWaylandDataDevice::startDrag(QMimeData *mimeData, QWaylandWindow *icon)
+     }
+ 
+     m_dragSource.reset(new QWaylandDataSource(m_display->dndSelectionHandler(), mimeData));
++
++    if (wl_data_device_get_version(object()) >= 3)
++        m_dragSource->set_actions(dropActionsToWl(supportedActions));
++
+     connect(m_dragSource.data(), &QWaylandDataSource::cancelled, this, &QWaylandDataDevice::dragSourceCancelled);
++    connect(m_dragSource.data(), &QWaylandDataSource::dndResponseUpdated, this, [this](bool accepted, Qt::DropAction action) {
++            auto drag = static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag());
++            // in old versions drop action is not set, so we guess
++            if (wl_data_source_get_version(m_dragSource->object()) < 3) {
++                drag->setResponse(accepted);
++            } else {
++                QPlatformDropQtResponse response(accepted, action);
++                drag->setResponse(response);
++            }
++    });
++    connect(m_dragSource.data(), &QWaylandDataSource::dndDropped, this, [](bool accepted, Qt::DropAction action) {
++        QPlatformDropQtResponse response(accepted, action);
++        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setDropResponse(response);
++    });
++    connect(m_dragSource.data(), &QWaylandDataSource::finished, this, []() {
++        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag();
++    });
+ 
+     start_drag(m_dragSource->object(), origin->wlSurface(), icon->wlSurface(), m_display->currentInputDevice()->serial());
+     return true;
+@@ -152,7 +175,7 @@ void QWaylandDataDevice::data_device_drop()
+         supportedActions = drag->supportedActions();
+     } else if (m_dragOffer) {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     } else {
+         return;
+     }
+@@ -162,7 +185,11 @@ void QWaylandDataDevice::data_device_drop()
+                                                                           QGuiApplication::keyboardModifiers());
+ 
+     if (drag) {
+-        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag(response);
++        auto drag =  static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag());
++        drag->setDropResponse(response);
++        drag->finishDrag();
++    } else if (m_dragOffer) {
++        m_dragOffer->finish();
+     }
+ }
+ 
+@@ -186,7 +213,7 @@ void QWaylandDataDevice::data_device_enter(uint32_t serial, wl_surface *surface,
+         supportedActions = drag->supportedActions();
+     } else if (m_dragOffer) {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     }
+ 
+     const QPlatformDragQtResponse &response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
+@@ -197,11 +224,7 @@ void QWaylandDataDevice::data_device_enter(uint32_t serial, wl_surface *surface,
+         static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setResponse(response);
+     }
+ 
+-    if (response.isAccepted()) {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, m_dragOffer->firstFormat().toUtf8().constData());
+-    } else {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, nullptr);
+-    }
++    sendResponse(supportedActions, response);
+ }
+ 
+ void QWaylandDataDevice::data_device_leave()
+@@ -235,10 +258,10 @@ void QWaylandDataDevice::data_device_motion(uint32_t time, wl_fixed_t x, wl_fixe
+         supportedActions = drag->supportedActions();
+     } else {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     }
+ 
+-    QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
++    const QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
+                                                                           QGuiApplication::mouseButtons(),
+                                                                           QGuiApplication::keyboardModifiers());
+ 
+@@ -246,11 +269,7 @@ void QWaylandDataDevice::data_device_motion(uint32_t time, wl_fixed_t x, wl_fixe
+         static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setResponse(response);
+     }
+ 
+-    if (response.isAccepted()) {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, m_dragOffer->firstFormat().toUtf8().constData());
+-    } else {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, nullptr);
+-    }
++    sendResponse(supportedActions, response);
+ }
+ #endif // QT_CONFIG(draganddrop)
+ 
+@@ -277,14 +296,10 @@ void QWaylandDataDevice::selectionSourceCancelled()
+ #if QT_CONFIG(draganddrop)
+ void QWaylandDataDevice::dragSourceCancelled()
+ {
++    static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag();
+     m_dragSource.reset();
+ }
+ 
+-void QWaylandDataDevice::dragSourceTargetChanged(const QString &mimeType)
+-{
+-    static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->updateTarget(mimeType);
+-}
+-
+ QPoint QWaylandDataDevice::calculateDragPosition(int x, int y, QWindow *wnd) const
+ {
+     QPoint pnt(wl_fixed_to_int(x), wl_fixed_to_int(y));
+@@ -297,6 +312,33 @@ QPoint QWaylandDataDevice::calculateDragPosition(int x, int y, QWindow *wnd) con
+     }
+     return pnt;
+ }
++
++void QWaylandDataDevice::sendResponse(Qt::DropActions supportedActions, const QPlatformDragQtResponse &response)
++{
++    if (response.isAccepted()) {
++        if (wl_data_device_get_version(object()) >= 3)
++            m_dragOffer->set_actions(dropActionsToWl(supportedActions), dropActionsToWl(response.acceptedAction()));
++
++        m_dragOffer->accept(m_enterSerial, m_dragOffer->firstFormat());
++    } else {
++        m_dragOffer->accept(m_enterSerial, QString());
++    }
++}
++
++int QWaylandDataDevice::dropActionsToWl(Qt::DropActions actions)
++{
++
++    int wlActions = WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE;
++    if (actions & Qt::CopyAction)
++        wlActions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY;
++    if (actions & (Qt::MoveAction | Qt::TargetMoveAction))
++        wlActions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE;
++
++    // wayland does not support LinkAction at the time of writing
++    return wlActions;
++}
++
++
+ #endif // QT_CONFIG(draganddrop)
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddatadevice_p.h b/qtwayland/src/client/qwaylanddatadevice_p.h
+index 16c3ad28..801dcc2c 100644
+--- a/qtwayland/src/client/qwaylanddatadevice_p.h
++++ b/qtwayland/src/client/qwaylanddatadevice_p.h
+@@ -64,6 +64,7 @@ QT_REQUIRE_CONFIG(wayland_datadevice);
+ QT_BEGIN_NAMESPACE
+ 
+ class QMimeData;
++class QPlatformDragQtResponse;
+ class QWindow;
+ 
+ namespace QtWaylandClient {
+@@ -89,7 +90,7 @@ public:
+ 
+ #if QT_CONFIG(draganddrop)
+     QWaylandDataOffer *dragOffer() const;
+-    bool startDrag(QMimeData *mimeData, QWaylandWindow *icon);
++    bool startDrag(QMimeData *mimeData, Qt::DropActions supportedActions, QWaylandWindow *icon);
+     void cancelDrag();
+ #endif
+ 
+@@ -109,13 +110,16 @@ private Q_SLOTS:
+ 
+ #if QT_CONFIG(draganddrop)
+     void dragSourceCancelled();
+-    void dragSourceTargetChanged(const QString &mimeType);
+ #endif
+ 
+ private:
+ #if QT_CONFIG(draganddrop)
+     QPoint calculateDragPosition(int x, int y, QWindow *wnd) const;
+ #endif
++    void sendResponse(Qt::DropActions supportedActions, const QPlatformDragQtResponse &response);
++
++    static int dropActionsToWl(Qt::DropActions dropActions);
++
+ 
+     QWaylandDisplay *m_display = nullptr;
+     QWaylandInputDevice *m_inputDevice = nullptr;
+diff --git a/qtwayland/src/client/qwaylanddatadevicemanager.cpp b/qtwayland/src/client/qwaylanddatadevicemanager.cpp
+index 35d67307..6dc4f77f 100644
+--- a/qtwayland/src/client/qwaylanddatadevicemanager.cpp
++++ b/qtwayland/src/client/qwaylanddatadevicemanager.cpp
+@@ -50,8 +50,8 @@ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
+-QWaylandDataDeviceManager::QWaylandDataDeviceManager(QWaylandDisplay *display, uint32_t id)
+-    : wl_data_device_manager(display->wl_registry(), id, 1)
++QWaylandDataDeviceManager::QWaylandDataDeviceManager(QWaylandDisplay *display, int version, uint32_t id)
++    : wl_data_device_manager(display->wl_registry(), id, qMin(version, 3))
+     , m_display(display)
+ {
+     // Create transfer devices for all input devices.
+diff --git a/qtwayland/src/client/qwaylanddatadevicemanager_p.h b/qtwayland/src/client/qwaylanddatadevicemanager_p.h
+index bd05c0fb..510d9be4 100644
+--- a/qtwayland/src/client/qwaylanddatadevicemanager_p.h
++++ b/qtwayland/src/client/qwaylanddatadevicemanager_p.h
+@@ -68,7 +68,7 @@ class QWaylandInputDevice;
+ class Q_WAYLAND_CLIENT_EXPORT QWaylandDataDeviceManager : public QtWayland::wl_data_device_manager
+ {
+ public:
+-    QWaylandDataDeviceManager(QWaylandDisplay *display, uint32_t id);
++    QWaylandDataDeviceManager(QWaylandDisplay *display, int version, uint32_t id);
+     ~QWaylandDataDeviceManager() override;
+ 
+     QWaylandDataDevice *getDataDevice(QWaylandInputDevice *inputDevice);
+diff --git a/qtwayland/src/client/qwaylanddataoffer.cpp b/qtwayland/src/client/qwaylanddataoffer.cpp
+index 2297e8a1..fe0ea8c9 100644
+--- a/qtwayland/src/client/qwaylanddataoffer.cpp
++++ b/qtwayland/src/client/qwaylanddataoffer.cpp
+@@ -82,6 +82,15 @@ QMimeData *QWaylandDataOffer::mimeData()
+     return m_mimeData.data();
+ }
+ 
++Qt::DropActions QWaylandDataOffer::supportedActions() const
++{
++    if (wl_data_offer_get_version(const_cast<::wl_data_offer*>(object())) < 3) {
++        return Qt::MoveAction | Qt::CopyAction;
++    }
++
++    return m_supportedActions;
++}
++
+ void QWaylandDataOffer::startReceiving(const QString &mimeType, int fd)
+ {
+     receive(mimeType, fd);
+@@ -93,6 +102,22 @@ void QWaylandDataOffer::data_offer_offer(const QString &mime_type)
+     m_mimeData->appendFormat(mime_type);
+ }
+ 
++void QWaylandDataOffer::data_offer_action(uint32_t dnd_action)
++{
++    Q_UNUSED(dnd_action);
++    // This is the compositor telling the drag target what action it should perform
++    // It does not map nicely into Qt final drop semantics, other than pretending there is only one supported action?
++}
++
++void QWaylandDataOffer::data_offer_source_actions(uint32_t source_actions)
++{
++    m_supportedActions = Qt::DropActions();
++    if (source_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
++        m_supportedActions |= Qt::MoveAction;
++    if (source_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
++        m_supportedActions |= Qt::CopyAction;
++}
++
+ QWaylandMimeData::QWaylandMimeData(QWaylandAbstractDataOffer *dataOffer)
+     : m_dataOffer(dataOffer)
+ {
+@@ -163,17 +188,18 @@ QVariant QWaylandMimeData::retrieveData_sys(const QString &mimeType, QVariant::T
+ 
+ int QWaylandMimeData::readData(int fd, QByteArray &data) const
+ {
+-    fd_set readset;
+-    FD_ZERO(&readset);
+-    FD_SET(fd, &readset);
+-    struct timeval timeout;
++    struct pollfd readset;
++    readset.fd = fd;
++    readset.events = POLLIN;
++    struct timespec timeout;
+     timeout.tv_sec = 1;
+-    timeout.tv_usec = 0;
++    timeout.tv_nsec = 0;
++
+ 
+     Q_FOREVER {
+-        int ready = select(FD_SETSIZE, &readset, nullptr, nullptr, &timeout);
++        int ready = qt_safe_poll(&readset, 1, &timeout);
+         if (ready < 0) {
+-            qWarning() << "QWaylandDataOffer: select() failed";
++            qWarning() << "QWaylandDataOffer: qt_safe_poll() failed";
+             return -1;
+         } else if (ready == 0) {
+             qWarning("QWaylandDataOffer: timeout reading from pipe");
+diff --git a/qtwayland/src/client/qwaylanddataoffer_p.h b/qtwayland/src/client/qwaylanddataoffer_p.h
+index 9cf1483c..6f667398 100644
+--- a/qtwayland/src/client/qwaylanddataoffer_p.h
++++ b/qtwayland/src/client/qwaylanddataoffer_p.h
+@@ -82,6 +82,7 @@ public:
+     explicit QWaylandDataOffer(QWaylandDisplay *display, struct ::wl_data_offer *offer);
+     ~QWaylandDataOffer() override;
+     QMimeData *mimeData() override;
++    Qt::DropActions supportedActions() const;
+ 
+     QString firstFormat() const;
+ 
+@@ -89,10 +90,13 @@ public:
+ 
+ protected:
+     void data_offer_offer(const QString &mime_type) override;
++    void data_offer_source_actions(uint32_t source_actions) override;
++    void data_offer_action(uint32_t dnd_action) override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+     QScopedPointer<QWaylandMimeData> m_mimeData;
++    Qt::DropActions m_supportedActions;
+ };
+ 
+ 
+diff --git a/qtwayland/src/client/qwaylanddatasource.cpp b/qtwayland/src/client/qwaylanddatasource.cpp
+index f45122fb..5599cbd4 100644
+--- a/qtwayland/src/client/qwaylanddatasource.cpp
++++ b/qtwayland/src/client/qwaylanddatasource.cpp
+@@ -101,7 +101,32 @@ void QWaylandDataSource::data_source_send(const QString &mime_type, int32_t fd)
+ 
+ void QWaylandDataSource::data_source_target(const QString &mime_type)
+ {
+-    Q_EMIT targetChanged(mime_type);
++    m_accepted = !mime_type.isEmpty();
++    Q_EMIT dndResponseUpdated(m_accepted, m_dropAction);
++}
++
++void QWaylandDataSource::data_source_action(uint32_t action)
++{
++    Qt::DropAction qtAction = Qt::IgnoreAction;
++
++    if (action == WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
++        qtAction = Qt::MoveAction;
++    else if (action == WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
++        qtAction = Qt::CopyAction;
++
++    m_dropAction = qtAction;
++    Q_EMIT dndResponseUpdated(m_accepted, m_dropAction);
++}
++
++void QWaylandDataSource::data_source_dnd_finished()
++{
++    Q_EMIT finished();
++}
++
++void QWaylandDataSource::data_source_dnd_drop_performed()
++{
++
++    Q_EMIT dndDropped(m_accepted, m_dropAction);
+ }
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddatasource_p.h b/qtwayland/src/client/qwaylanddatasource_p.h
+index 25afff79..96f07bc3 100644
+--- a/qtwayland/src/client/qwaylanddatasource_p.h
++++ b/qtwayland/src/client/qwaylanddatasource_p.h
+@@ -77,17 +77,25 @@ public:
+     QMimeData *mimeData() const;
+ 
+ Q_SIGNALS:
+-    void targetChanged(const QString &mime_type);
+     void cancelled();
++    void finished();
++
++    void dndResponseUpdated(bool accepted, Qt::DropAction action);
++    void dndDropped(bool accepted, Qt::DropAction action);
+ 
+ protected:
+     void data_source_cancelled() override;
+     void data_source_send(const QString &mime_type, int32_t fd) override;
+     void data_source_target(const QString &mime_type) override;
++    void data_source_dnd_drop_performed() override;
++    void data_source_dnd_finished() override;
++    void data_source_action(uint32_t action) override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+     QMimeData *m_mime_data = nullptr;
++    bool m_accepted = false;
++    Qt::DropAction m_dropAction = Qt::IgnoreAction;
+ };
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddisplay.cpp b/qtwayland/src/client/qwaylanddisplay.cpp
+index f10c1f79..c01e238b 100644
+--- a/qtwayland/src/client/qwaylanddisplay.cpp
++++ b/qtwayland/src/client/qwaylanddisplay.cpp
+@@ -85,10 +85,203 @@
+ 
+ #include <errno.h>
+ 
++#include <tuple> // for std::tie
++
++static void checkWaylandError(struct wl_display *display)
++{
++    int ecode = wl_display_get_error(display);
++    if ((ecode == EPIPE || ecode == ECONNRESET)) {
++        // special case this to provide a nicer error
++        qWarning("The Wayland connection broke. Did the Wayland compositor die?");
++    } else {
++        qWarning("The Wayland connection experienced a fatal error: %s", strerror(ecode));
++    }
++    _exit(1);
++}
++
+ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
++class EventThread : public QThread
++{
++    Q_OBJECT
++public:
++    enum OperatingMode {
++        EmitToDispatch, // Emit the signal, allow dispatching in a differnt thread.
++        SelfDispatch, // Dispatch the events inside this thread.
++    };
++
++    EventThread(struct wl_display * wl, struct wl_event_queue * ev_queue,
++                OperatingMode mode)
++        : m_fd(wl_display_get_fd(wl))
++        , m_pipefd{ -1, -1 }
++        , m_wldisplay(wl)
++        , m_wlevqueue(ev_queue)
++        , m_mode(mode)
++        , m_reading(true)
++        , m_quitting(false)
++    {
++        setObjectName(QStringLiteral("WaylandEventThread"));
++    }
++
++    void readAndDispatchEvents()
++    {
++        /*
++         * Dispatch pending events and flush the requests at least once. If the event thread
++         * is not reading, try to call _prepare_read() to allow the event thread to poll().
++         * If that fails, re-try dispatch & flush again until _prepare_read() is successful.
++         *
++         * This allow any call to readAndDispatchEvents() to start event thread's polling,
++         * not only the one issued from event thread's waitForReading(), which means functions
++         * called from dispatch_pending() can safely spin an event loop.
++         */
++        for (;;) {
++            if (dispatchQueuePending() < 0) {
++                checkWaylandError(m_wldisplay);
++                return;
++            }
++
++            wl_display_flush(m_wldisplay);
++
++            // We have to check if event thread is reading every time we dispatch
++            // something, as that may recursively call this function.
++            if (m_reading.loadAcquire())
++                break;
++
++            if (prepareReadQueue() == 0) {
++                QMutexLocker l(&m_mutex);
++                m_reading.storeRelease(true);
++                m_cond.wakeOne();
++                break;
++            }
++        }
++    }
++
++    void stop()
++    {
++        // We have to both write to the pipe and set the flag, as the thread may be
++        // either in the poll() or waiting for _prepare_read().
++        if (m_pipefd[1] != -1 && write(m_pipefd[1], "\0", 1) == -1)
++            qWarning("Failed to write to the pipe: %s.", strerror(errno));
++
++        {
++            QMutexLocker l(&m_mutex);
++            m_quitting = true;
++            m_cond.wakeOne();
++        }
++
++        wait();
++    }
++
++Q_SIGNALS:
++    void needReadAndDispatch();
++
++protected:
++    void run() override
++    {
++        // we use this pipe to make the loop exit otherwise if we simply used a flag on the loop condition, if stop() gets
++        // called while poll() is blocking the thread will never quit since there are no wayland messages coming anymore.
++        struct Pipe
++        {
++            Pipe(int *fds)
++                : fds(fds)
++            {
++                if (qt_safe_pipe(fds) != 0)
++                    qWarning("Pipe creation failed. Quitting may hang.");
++            }
++            ~Pipe()
++            {
++                if (fds[0] != -1) {
++                    close(fds[0]);
++                    close(fds[1]);
++                }
++            }
++
++            int *fds;
++        } pipe(m_pipefd);
++
++        // Make the main thread call wl_prepare_read(), dispatch the pending messages and flush the
++        // outbound ones. Wait until it's done before proceeding, unless we're told to quit.
++        while (waitForReading()) {
++            pollfd fds[2] = { { m_fd, POLLIN, 0 }, { m_pipefd[0], POLLIN, 0 } };
++            poll(fds, 2, -1);
++
++            if (fds[1].revents & POLLIN) {
++                // we don't really care to read the byte that was written here since we're closing down
++                wl_display_cancel_read(m_wldisplay);
++                break;
++            }
++
++            if (fds[0].revents & POLLIN)
++                wl_display_read_events(m_wldisplay);
++                // The polll was succesfull and the event thread did the wl_display_read_events(). On the next iteration of the loop
++                // the event sent to the main thread will cause it to dispatch the messages just read, unless the loop exits in which
++                // case we don't care anymore about them.
++            else
++                wl_display_cancel_read(m_wldisplay);
++        }
++    }
++
++private:
++    bool waitForReading()
++    {
++        Q_ASSERT(QThread::currentThread() == this);
++
++        m_reading.storeRelease(false);
++
++        if (m_mode == SelfDispatch) {
++            readAndDispatchEvents();
++        } else {
++            Q_EMIT needReadAndDispatch();
++
++            QMutexLocker lock(&m_mutex);
++            // m_reading might be set from our emit or some other invocation of
++            // readAndDispatchEvents().
++            while (!m_reading.loadRelaxed() && !m_quitting)
++                m_cond.wait(&m_mutex);
++        }
++
++        return !m_quitting;
++    }
++
++    int dispatchQueuePending()
++    {
++        if (m_wlevqueue)
++            return wl_display_dispatch_queue_pending(m_wldisplay, m_wlevqueue);
++        else
++            return wl_display_dispatch_pending(m_wldisplay);
++    }
++
++    int prepareReadQueue()
++    {
++        if (m_wlevqueue)
++            return wl_display_prepare_read_queue(m_wldisplay, m_wlevqueue);
++        else
++            return wl_display_prepare_read(m_wldisplay);
++    }
++
++    int m_fd;
++    int m_pipefd[2];
++    wl_display *m_wldisplay;
++    wl_event_queue *m_wlevqueue;
++    OperatingMode m_mode;
++
++    /* Concurrency note when operating in EmitToDispatch mode:
++     * m_reading is set to false inside event thread's waitForReading(), and is
++     * set to true inside main thread's readAndDispatchEvents().
++     * The lock is not taken when setting m_reading to false, as the main thread
++     * is not actively waiting for it to turn false. However, the lock is taken
++     * inside readAndDispatchEvents() before setting m_reading to true,
++     * as the event thread is actively waiting for it under the wait condition.
++     */
++
++    QAtomicInteger<bool> m_reading;
++    bool m_quitting;
++    QMutex m_mutex;
++    QWaitCondition m_cond;
++};
++
+ Q_LOGGING_CATEGORY(lcQpaWayland, "qt.qpa.wayland"); // for general (uncategorized) Wayland platform logging
+ 
+ struct wl_surface *QWaylandDisplay::createSurface(void *handle)
+@@ -158,17 +351,16 @@ QWaylandDisplay::QWaylandDisplay(QWaylandIntegration *waylandIntegration)
+     if (!mXkbContext)
+         qCWarning(lcQpaWayland, "failed to create xkb context");
+ #endif
+-
+-    forceRoundTrip();
+-
+-    if (!mWaitingScreens.isEmpty()) {
+-        // Give wl_output.done and zxdg_output_v1.done events a chance to arrive
+-        forceRoundTrip();
+-    }
+ }
+ 
+ QWaylandDisplay::~QWaylandDisplay(void)
+ {
++    if (m_eventThread)
++        m_eventThread->stop();
++
++    if (m_frameEventQueueThread)
++        m_frameEventQueueThread->stop();
++
+     if (mSyncCallback)
+         wl_callback_destroy(mSyncCallback);
+ 
+@@ -187,6 +379,21 @@ QWaylandDisplay::~QWaylandDisplay(void)
+ #endif
+     if (mDisplay)
+         wl_display_disconnect(mDisplay);
++
++    if (m_frameEventQueue)
++        wl_event_queue_destroy(m_frameEventQueue);
++}
++
++// Steps which is called just after constructor. This separates registry_global() out of the constructor
++// so that factory functions in integration can be overridden.
++void QWaylandDisplay::initialize()
++{
++    forceRoundTrip();
++
++    if (!mWaitingScreens.isEmpty()) {
++        // Give wl_output.done and zxdg_output_v1.done events a chance to arrive
++        forceRoundTrip();
++    }
+ }
+ 
+ void QWaylandDisplay::ensureScreen()
+@@ -203,98 +410,37 @@ void QWaylandDisplay::ensureScreen()
+ 
+ void QWaylandDisplay::checkError() const
+ {
+-    int ecode = wl_display_get_error(mDisplay);
+-    if ((ecode == EPIPE || ecode == ECONNRESET)) {
+-        // special case this to provide a nicer error
+-        qWarning("The Wayland connection broke. Did the Wayland compositor die?");
+-    } else {
+-        qWarning("The Wayland connection experienced a fatal error: %s", strerror(ecode));
+-    }
+-    _exit(1);
++    checkWaylandError(mDisplay);
+ }
+ 
++// Called in main thread, either from queued signal or directly.
+ void QWaylandDisplay::flushRequests()
+ {
+-    if (wl_display_prepare_read(mDisplay) == 0) {
+-        wl_display_read_events(mDisplay);
+-    }
+-
+-    if (wl_display_dispatch_pending(mDisplay) < 0)
+-        checkError();
+-
+-    {
+-        QReadLocker locker(&m_frameQueueLock);
+-        for (const FrameQueue &q : mExternalQueues) {
+-            QMutexLocker locker(q.mutex);
+-            while (wl_display_prepare_read_queue(mDisplay, q.queue) != 0)
+-                wl_display_dispatch_queue_pending(mDisplay, q.queue);
+-            wl_display_read_events(mDisplay);
+-            wl_display_dispatch_queue_pending(mDisplay, q.queue);
+-        }
+-    }
+-
+-    wl_display_flush(mDisplay);
+-}
+-
+-void QWaylandDisplay::blockingReadEvents()
+-{
+-    if (wl_display_dispatch(mDisplay) < 0)
+-        checkError();
+-}
+-
+-void QWaylandDisplay::destroyFrameQueue(const QWaylandDisplay::FrameQueue &q)
+-{
+-    QWriteLocker locker(&m_frameQueueLock);
+-    auto it = std::find_if(mExternalQueues.begin(),
+-                           mExternalQueues.end(),
+-                           [&q] (const QWaylandDisplay::FrameQueue &other){ return other.queue == q.queue; });
+-    Q_ASSERT(it != mExternalQueues.end());
+-    mExternalQueues.erase(it);
+-    if (q.queue != nullptr)
+-        wl_event_queue_destroy(q.queue);
+-    delete q.mutex;
++    m_eventThread->readAndDispatchEvents();
+ }
+ 
+-QWaylandDisplay::FrameQueue QWaylandDisplay::createFrameQueue()
++// We have to wait until we have an eventDispatcher before creating the eventThread,
++// otherwise forceRoundTrip() may block inside _events_read() because eventThread is
++// polling.
++void QWaylandDisplay::initEventThread()
+ {
+-    QWriteLocker locker(&m_frameQueueLock);
+-    FrameQueue q{createEventQueue()};
+-    mExternalQueues.append(q);
+-    return q;
+-}
++    m_eventThread.reset(
++            new EventThread(mDisplay, /* default queue */ nullptr, EventThread::EmitToDispatch));
++    connect(m_eventThread.get(), &EventThread::needReadAndDispatch, this,
++            &QWaylandDisplay::flushRequests, Qt::QueuedConnection);
++    m_eventThread->start();
+ 
+-wl_event_queue *QWaylandDisplay::createEventQueue()
+-{
+-    return wl_display_create_queue(mDisplay);
++    // wl_display_disconnect() free this.
++    m_frameEventQueue = wl_display_create_queue(mDisplay);
++    m_frameEventQueueThread.reset(
++            new EventThread(mDisplay, m_frameEventQueue, EventThread::SelfDispatch));
++    m_frameEventQueueThread->start();
+ }
+ 
+-void QWaylandDisplay::dispatchQueueWhile(wl_event_queue *queue, std::function<bool ()> condition, int timeout)
++void QWaylandDisplay::blockingReadEvents()
+ {
+-    if (!condition())
+-        return;
+-
+-    QElapsedTimer timer;
+-    timer.start();
+-    struct pollfd pFd = qt_make_pollfd(wl_display_get_fd(mDisplay), POLLIN);
+-    while (timeout == -1 || timer.elapsed() < timeout) {
+-        while (wl_display_prepare_read_queue(mDisplay, queue) != 0)
+-            wl_display_dispatch_queue_pending(mDisplay, queue);
+-
+-        wl_display_flush(mDisplay);
+-
+-        const int remaining = qMax(timeout - timer.elapsed(), 0ll);
+-        const int pollTimeout = timeout == -1 ? -1 : remaining;
+-        if (qt_poll_msecs(&pFd, 1, pollTimeout) > 0)
+-            wl_display_read_events(mDisplay);
+-        else
+-            wl_display_cancel_read(mDisplay);
+-
+-        if (wl_display_dispatch_queue_pending(mDisplay, queue) < 0)
+-            checkError();
+-
+-        if (!condition())
+-            break;
+-    }
++    if (wl_display_dispatch(mDisplay) < 0)
++        checkWaylandError(mDisplay);
+ }
+ 
+ QWaylandScreen *QWaylandDisplay::screenForOutput(struct wl_output *output) const
+@@ -345,7 +491,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+     if (interface == QStringLiteral("wl_output")) {
+         mWaitingScreens << new QWaylandScreen(this, version, id);
+     } else if (interface == QStringLiteral("wl_compositor")) {
+-        mCompositorVersion = qMin((int)version, 3);
++        mCompositorVersion = qMin((int)version, 4);
+         mCompositor.init(registry, id, mCompositorVersion);
+     } else if (interface == QStringLiteral("wl_shm")) {
+         mShm.reset(new QWaylandShm(this, version, id));
+@@ -354,7 +500,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+         mInputDevices.append(inputDevice);
+ #if QT_CONFIG(wayland_datadevice)
+     } else if (interface == QStringLiteral("wl_data_device_manager")) {
+-        mDndSelectionHandler.reset(new QWaylandDataDeviceManager(this, id));
++        mDndSelectionHandler.reset(new QWaylandDataDeviceManager(this, version, id));
+ #endif
+     } else if (interface == QStringLiteral("qt_surface_extension")) {
+         mWindowExtension.reset(new QtWayland::qt_surface_extension(registry, id, 1));
+@@ -369,6 +515,8 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+ #if QT_CONFIG(wayland_client_primary_selection)
+     } else if (interface == QStringLiteral("zwp_primary_selection_device_manager_v1")) {
+         mPrimarySelectionManager.reset(new QWaylandPrimarySelectionDeviceManagerV1(this, id, 1));
++        for (QWaylandInputDevice *inputDevice : qAsConst(mInputDevices))
++            inputDevice->setPrimarySelectionDevice(mPrimarySelectionManager->createDevice(inputDevice));
+ #endif
+     } else if (interface == QStringLiteral("zwp_text_input_manager_v2") && !mClientSideInputContextRequested) {
+         mTextInputManager.reset(new QtWayland::zwp_text_input_manager_v2(registry, id, 1));
+@@ -427,6 +575,13 @@ void QWaylandDisplay::registry_global_remove(uint32_t id)
+                     inputDevice->setTextInput(nullptr);
+                 mWaylandIntegration->reconfigureInputContext();
+             }
++#if QT_CONFIG(wayland_client_primary_selection)
++            if (global.interface == QStringLiteral("zwp_primary_selection_device_manager_v1")) {
++                mPrimarySelectionManager.reset();
++                for (QWaylandInputDevice *inputDevice : qAsConst(mInputDevices))
++                    inputDevice->setPrimarySelectionDevice(nullptr);
++            }
++#endif
+             mGlobals.removeAt(i);
+             break;
+         }
+@@ -452,9 +607,10 @@ void QWaylandDisplay::addRegistryListener(RegistryListener listener, void *data)
+ 
+ void QWaylandDisplay::removeListener(RegistryListener listener, void *data)
+ {
+-    std::remove_if(mRegistryListeners.begin(), mRegistryListeners.end(), [=](Listener l){
++    auto iter = std::remove_if(mRegistryListeners.begin(), mRegistryListeners.end(), [=](Listener l){
+         return (l.listener == listener && l.data == data);
+     });
++    mRegistryListeners.erase(iter, mRegistryListeners.end());
+ }
+ 
+ uint32_t QWaylandDisplay::currentTimeMillisec()
+@@ -467,50 +623,9 @@ uint32_t QWaylandDisplay::currentTimeMillisec()
+     return 0;
+ }
+ 
+-static void
+-sync_callback(void *data, struct wl_callback *callback, uint32_t serial)
+-{
+-    Q_UNUSED(serial)
+-    bool *done = static_cast<bool *>(data);
+-
+-    *done = true;
+-
+-    // If the wl_callback done event is received after the condition check in the while loop in
+-    // forceRoundTrip(), but before the call to processEvents, the call to processEvents may block
+-    // forever if no more events are posted (eventhough the callback is handled in response to the
+-    // aboutToBlock signal). Hence, we wake up the event dispatcher so forceRoundTrip may return.
+-    // (QTBUG-64696)
+-    if (auto *dispatcher = QThread::currentThread()->eventDispatcher())
+-        dispatcher->wakeUp();
+-
+-    wl_callback_destroy(callback);
+-}
+-
+-static const struct wl_callback_listener sync_listener = {
+-    sync_callback
+-};
+-
+ void QWaylandDisplay::forceRoundTrip()
+ {
+-    // wl_display_roundtrip() works on the main queue only,
+-    // but we use a separate one, so basically reimplement it here
+-    int ret = 0;
+-    bool done = false;
+-    wl_callback *callback = wl_display_sync(mDisplay);
+-    wl_callback_add_listener(callback, &sync_listener, &done);
+-    flushRequests();
+-    if (QThread::currentThread()->eventDispatcher()) {
+-        while (!done && ret >= 0) {
+-            QThread::currentThread()->eventDispatcher()->processEvents(QEventLoop::WaitForMoreEvents);
+-            ret = wl_display_dispatch_pending(mDisplay);
+-        }
+-    } else {
+-        while (!done && ret >= 0)
+-            ret = wl_display_dispatch(mDisplay);
+-    }
+-
+-    if (ret == -1 && !done)
+-        wl_callback_destroy(callback);
++     wl_display_roundtrip(mDisplay);
+ }
+ 
+ bool QWaylandDisplay::supportsWindowDecoration() const
+@@ -574,14 +689,10 @@ void QWaylandDisplay::handleKeyboardFocusChanged(QWaylandInputDevice *inputDevic
+     if (mLastKeyboardFocus == keyboardFocus)
+         return;
+ 
+-    if (mWaylandIntegration->mShellIntegration) {
+-        mWaylandIntegration->mShellIntegration->handleKeyboardFocusChanged(keyboardFocus, mLastKeyboardFocus);
+-    } else {
+-        if (keyboardFocus)
+-            handleWindowActivated(keyboardFocus);
+-        if (mLastKeyboardFocus)
+-            handleWindowDeactivated(mLastKeyboardFocus);
+-    }
++    if (keyboardFocus)
++        handleWindowActivated(keyboardFocus);
++    if (mLastKeyboardFocus)
++        handleWindowDeactivated(mLastKeyboardFocus);
+ 
+     mLastKeyboardFocus = keyboardFocus;
+ }
+@@ -600,6 +711,19 @@ void QWaylandDisplay::handleWaylandSync()
+     QWindow *activeWindow = mActiveWindows.empty() ? nullptr : mActiveWindows.last()->window();
+     if (activeWindow != QGuiApplication::focusWindow())
+         QWindowSystemInterface::handleWindowActivated(activeWindow);
++
++    if (!activeWindow) {
++        if (lastInputDevice()) {
++#if QT_CONFIG(clipboard)
++            if (auto *dataDevice = lastInputDevice()->dataDevice())
++                dataDevice->invalidateSelectionOffer();
++#endif
++#if QT_CONFIG(wayland_client_primary_selection)
++            if (auto *device = lastInputDevice()->primarySelectionDevice())
++                device->invalidateSelectionOffer();
++#endif
++        }
++    }
+ }
+ 
+ const wl_callback_listener QWaylandDisplay::syncCallbackListener = {
+@@ -626,6 +750,13 @@ QWaylandInputDevice *QWaylandDisplay::defaultInputDevice() const
+     return mInputDevices.isEmpty() ? 0 : mInputDevices.first();
+ }
+ 
++bool QWaylandDisplay::isKeyboardAvailable() const
++{
++    return std::any_of(
++            mInputDevices.constBegin(), mInputDevices.constEnd(),
++            [this](const QWaylandInputDevice *device) { return device->keyboard() != nullptr; });
++}
++
+ #if QT_CONFIG(cursor)
+ 
+ QWaylandCursor *QWaylandDisplay::waylandCursor()
+@@ -652,4 +783,6 @@ QWaylandCursorTheme *QWaylandDisplay::loadCursorTheme(const QString &name, int p
+ 
+ } // namespace QtWaylandClient
+ 
++#include "qwaylanddisplay.moc"
++
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/client/qwaylanddisplay_p.h b/qtwayland/src/client/qwaylanddisplay_p.h
+index 3b092bc8..42bc661d 100644
+--- a/qtwayland/src/client/qwaylanddisplay_p.h
++++ b/qtwayland/src/client/qwaylanddisplay_p.h
+@@ -109,6 +109,7 @@ class QWaylandSurface;
+ class QWaylandShellIntegration;
+ class QWaylandCursor;
+ class QWaylandCursorTheme;
++class EventThread;
+ 
+ typedef void (*RegistryListener)(void *data,
+                                  struct wl_registry *registry,
+@@ -120,15 +121,11 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandDisplay : public QObject, public QtWayland
+     Q_OBJECT
+ 
+ public:
+-    struct FrameQueue {
+-        FrameQueue(wl_event_queue *q = nullptr) : queue(q), mutex(new QMutex) {}
+-        wl_event_queue *queue;
+-        QMutex *mutex;
+-    };
+-
+     QWaylandDisplay(QWaylandIntegration *waylandIntegration);
+     ~QWaylandDisplay(void) override;
+ 
++    void initialize();
++
+ #if QT_CONFIG(xkbcommon)
+     struct xkb_context *xkbContext() const { return mXkbContext.get(); }
+ #endif
+@@ -210,11 +207,11 @@ public:
+     void handleKeyboardFocusChanged(QWaylandInputDevice *inputDevice);
+     void handleWindowDestroyed(QWaylandWindow *window);
+ 
+-    wl_event_queue *createEventQueue();
+-    FrameQueue createFrameQueue();
+-    void destroyFrameQueue(const FrameQueue &q);
+-    void dispatchQueueWhile(wl_event_queue *queue, std::function<bool()> condition, int timeout = -1);
++    wl_event_queue *frameEventQueue() { return m_frameEventQueue; };
++
++    bool isKeyboardAvailable() const;
+ 
++    void initEventThread();
+ public slots:
+     void blockingReadEvents();
+     void flushRequests();
+@@ -237,6 +234,9 @@ private:
+     };
+ 
+     struct wl_display *mDisplay = nullptr;
++    QScopedPointer<EventThread> m_eventThread;
++    wl_event_queue *m_frameEventQueue = nullptr;
++    QScopedPointer<EventThread> m_frameEventQueueThread;
+     QtWayland::wl_compositor mCompositor;
+     QScopedPointer<QWaylandShm> mShm;
+     QList<QWaylandScreen *> mWaitingScreens;
+@@ -273,11 +273,9 @@ private:
+     QWaylandInputDevice *mLastInputDevice = nullptr;
+     QPointer<QWaylandWindow> mLastInputWindow;
+     QPointer<QWaylandWindow> mLastKeyboardFocus;
+-    QVector<QWaylandWindow *> mActiveWindows;
+-    QVector<FrameQueue> mExternalQueues;
++    QList<QWaylandWindow *> mActiveWindows;
+     struct wl_callback *mSyncCallback = nullptr;
+     static const wl_callback_listener syncCallbackListener;
+-    QReadWriteLock m_frameQueueLock;
+ 
+     bool mClientSideInputContextRequested = !QPlatformInputContextFactory::requested().isNull();
+ 
+diff --git a/qtwayland/src/client/qwaylanddnd.cpp b/qtwayland/src/client/qwaylanddnd.cpp
+index 6535aa16..7c53f5fa 100644
+--- a/qtwayland/src/client/qwaylanddnd.cpp
++++ b/qtwayland/src/client/qwaylanddnd.cpp
+@@ -66,7 +66,7 @@ void QWaylandDrag::startDrag()
+ {
+     QBasicDrag::startDrag();
+     QWaylandWindow *icon = static_cast<QWaylandWindow *>(shapedPixmapWindow()->handle());
+-    if (m_display->currentInputDevice()->dataDevice()->startDrag(drag()->mimeData(), icon)) {
++    if (m_display->currentInputDevice()->dataDevice()->startDrag(drag()->mimeData(), drag()->supportedActions(), icon)) {
+         icon->addAttachOffset(-drag()->hotSpot());
+     } else {
+         // Cancelling immediately does not work, since the event loop for QDrag::exec is started
+@@ -80,6 +80,9 @@ void QWaylandDrag::cancel()
+     QBasicDrag::cancel();
+ 
+     m_display->currentInputDevice()->dataDevice()->cancelDrag();
++
++    if (drag())
++        drag()->deleteLater();
+ }
+ 
+ void QWaylandDrag::move(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods)
+@@ -103,33 +106,41 @@ void QWaylandDrag::endDrag()
+     m_display->currentInputDevice()->handleEndDrag();
+ }
+ 
+-void QWaylandDrag::updateTarget(const QString &mimeType)
++void QWaylandDrag::setResponse(bool accepted)
+ {
+-    setCanDrop(!mimeType.isEmpty());
+-
+-    if (canDrop()) {
+-        updateCursor(defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers()));
+-    } else {
+-        updateCursor(Qt::IgnoreAction);
+-    }
++    // This method is used for old DataDevices where the drag action is not communicated
++    Qt::DropAction action = defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers());
++    setResponse(QPlatformDropQtResponse(accepted, action));
+ }
+ 
+-void QWaylandDrag::setResponse(const QPlatformDragQtResponse &response)
++void QWaylandDrag::setResponse(const QPlatformDropQtResponse &response)
+ {
+     setCanDrop(response.isAccepted());
+ 
+     if (canDrop()) {
+-        updateCursor(defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers()));
++        updateCursor(response.acceptedAction());
+     } else {
+         updateCursor(Qt::IgnoreAction);
+     }
+ }
+ 
+-void QWaylandDrag::finishDrag(const QPlatformDropQtResponse &response)
++void QWaylandDrag::setDropResponse(const QPlatformDropQtResponse &response)
+ {
+     setExecutedDropAction(response.acceptedAction());
++}
++
++void QWaylandDrag::finishDrag()
++{
+     QKeyEvent event(QEvent::KeyPress, Qt::Key_Escape, Qt::NoModifier);
+     eventFilter(shapedPixmapWindow(), &event);
++
++    if (drag())
++        drag()->deleteLater();
++}
++
++bool QWaylandDrag::ownsDragObject() const
++{
++    return true;
+ }
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddnd_p.h b/qtwayland/src/client/qwaylanddnd_p.h
+index 474fe2ab..46f629ac 100644
+--- a/qtwayland/src/client/qwaylanddnd_p.h
++++ b/qtwayland/src/client/qwaylanddnd_p.h
+@@ -71,9 +71,10 @@ public:
+     QWaylandDrag(QWaylandDisplay *display);
+     ~QWaylandDrag() override;
+ 
+-    void updateTarget(const QString &mimeType);
+-    void setResponse(const QPlatformDragQtResponse &response);
+-    void finishDrag(const QPlatformDropQtResponse &response);
++    void setResponse(bool accepted);
++    void setResponse(const QPlatformDropQtResponse &response);
++    void setDropResponse(const QPlatformDropQtResponse &response);
++    void finishDrag();
+ 
+ protected:
+     void startDrag() override;
+@@ -82,6 +83,7 @@ protected:
+     void drop(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods) override;
+     void endDrag() override;
+ 
++    bool ownsDragObject() const override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+diff --git a/qtwayland/src/client/qwaylandinputdevice.cpp b/qtwayland/src/client/qwaylandinputdevice.cpp
+index 613fe862..4b90de84 100644
+--- a/qtwayland/src/client/qwaylandinputdevice.cpp
++++ b/qtwayland/src/client/qwaylandinputdevice.cpp
+@@ -685,6 +685,11 @@ public:
+ 
+ void QWaylandInputDevice::Pointer::pointer_leave(uint32_t time, struct wl_surface *surface)
+ {
++    invalidateFocus();
++    mButtons = Qt::NoButton;
++
++    mParent->mTime = time;
++
+     // The event may arrive after destroying the window, indicated by
+     // a null surface.
+     if (!surface)
+@@ -696,11 +701,6 @@ void QWaylandInputDevice::Pointer::pointer_leave(uint32_t time, struct wl_surfac
+ 
+     if (!QWaylandWindow::mouseGrab())
+         setFrameEvent(new LeaveEvent(window, mSurfacePos, mGlobalPos));
+-
+-    invalidateFocus();
+-    mButtons = Qt::NoButton;
+-
+-    mParent->mTime = time;
+ }
+ 
+ class MotionEvent : public QWaylandPointerEvent
+@@ -1300,14 +1300,6 @@ void QWaylandInputDevice::Keyboard::handleFocusDestroyed()
+ void QWaylandInputDevice::Keyboard::handleFocusLost()
+ {
+     mFocus = nullptr;
+-#if QT_CONFIG(clipboard)
+-    if (auto *dataDevice = mParent->dataDevice())
+-        dataDevice->invalidateSelectionOffer();
+-#endif
+-#if QT_CONFIG(wayland_client_primary_selection)
+-    if (auto *device = mParent->primarySelectionDevice())
+-        device->invalidateSelectionOffer();
+-#endif
+     mParent->mQDisplay->handleKeyboardFocusChanged(mParent);
+     mRepeatTimer.stop();
+ }
+@@ -1396,6 +1388,7 @@ void QWaylandInputDevice::Touch::touch_cancel()
+     if (touchExt)
+         touchExt->touchCanceled();
+ 
++    mFocus = nullptr;
+     QWindowSystemInterface::handleTouchCancelEvent(nullptr, mParent->mTouchDevice);
+ }
+ 
+diff --git a/qtwayland/src/client/qwaylandintegration.cpp b/qtwayland/src/client/qwaylandintegration.cpp
+index c53ccb78..54861600 100644
+--- a/qtwayland/src/client/qwaylandintegration.cpp
++++ b/qtwayland/src/client/qwaylandintegration.cpp
+@@ -125,6 +125,9 @@ QWaylandIntegration::QWaylandIntegration()
+ #endif
+ 
+     reconfigureInputContext();
++
++    QWaylandWindow::fixedToplevelPositions =
++            !qEnvironmentVariableIsSet("QT_WAYLAND_DISABLE_FIXED_POSITIONS");
+ }
+ 
+ QWaylandIntegration::~QWaylandIntegration()
+@@ -192,14 +195,18 @@ QAbstractEventDispatcher *QWaylandIntegration::createEventDispatcher() const
+ 
+ void QWaylandIntegration::initialize()
+ {
++    mDisplay->initEventThread();
++
++    // Call after eventDispatcher is fully connected, for QWaylandDisplay::forceRoundTrip()
++    mDisplay->initialize();
++
++    // But the aboutToBlock() and awake() should be connected after initializePlatform().
++    // Otherwise the connected flushRequests() may consumes up all events before processEvents starts to wait,
++    // so that processEvents(QEventLoop::WaitForMoreEvents) may be blocked in the forceRoundTrip().
+     QAbstractEventDispatcher *dispatcher = QGuiApplicationPrivate::eventDispatcher;
+     QObject::connect(dispatcher, SIGNAL(aboutToBlock()), mDisplay.data(), SLOT(flushRequests()));
+     QObject::connect(dispatcher, SIGNAL(awake()), mDisplay.data(), SLOT(flushRequests()));
+ 
+-    int fd = wl_display_get_fd(mDisplay->wl_display());
+-    QSocketNotifier *sn = new QSocketNotifier(fd, QSocketNotifier::Read, mDisplay.data());
+-    QObject::connect(sn, SIGNAL(activated(QSocketDescriptor)), mDisplay.data(), SLOT(flushRequests()));
+-
+     // Qt does not support running with no screens
+     mDisplay->ensureScreen();
+ }
+@@ -262,6 +269,14 @@ QWaylandDisplay *QWaylandIntegration::display() const
+     return mDisplay.data();
+ }
+ 
++Qt::KeyboardModifiers QWaylandIntegration::queryKeyboardModifiers() const
++{
++    if (auto *seat = mDisplay->currentInputDevice()) {
++        return seat->modifiers();
++    }
++    return Qt::NoModifier;
++}
++
+ QList<int> QWaylandIntegration::possibleKeys(const QKeyEvent *event) const
+ {
+     if (auto *seat = mDisplay->currentInputDevice())
+@@ -479,7 +494,7 @@ void QWaylandIntegration::reconfigureInputContext()
+     }
+ #endif
+ 
+-    qCDebug(lcQpaWayland) << "using input method:" << inputContext()->metaObject()->className();
++    qCDebug(lcQpaWayland) << "using input method:" << (inputContext() ? inputContext()->metaObject()->className() : "<none>");
+ }
+ 
+ QWaylandShellIntegration *QWaylandIntegration::createShellIntegration(const QString &integrationName)
+diff --git a/qtwayland/src/client/qwaylandintegration_p.h b/qtwayland/src/client/qwaylandintegration_p.h
+index ff70ae25..73b80658 100644
+--- a/qtwayland/src/client/qwaylandintegration_p.h
++++ b/qtwayland/src/client/qwaylandintegration_p.h
+@@ -107,6 +107,8 @@ public:
+ 
+     QWaylandDisplay *display() const;
+ 
++    Qt::KeyboardModifiers queryKeyboardModifiers() const override;
++
+     QList<int> possibleKeys(const QKeyEvent *event) const override;
+ 
+     QStringList themeNames() const override;
+diff --git a/qtwayland/src/client/qwaylandprimaryselectionv1.cpp b/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
+index 832f9678..ea508771 100644
+--- a/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
++++ b/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
+@@ -54,11 +54,6 @@ QWaylandPrimarySelectionDeviceManagerV1::QWaylandPrimarySelectionDeviceManagerV1
+     : zwp_primary_selection_device_manager_v1(display->wl_registry(), id, qMin(version, uint(1)))
+     , m_display(display)
+ {
+-    // Create devices for all seats.
+-    // This only works if we get the global before all devices
+-    const auto seats = m_display->inputDevices();
+-    for (auto *seat : seats)
+-        seat->setPrimarySelectionDevice(createDevice(seat));
+ }
+ 
+ QWaylandPrimarySelectionDeviceV1 *QWaylandPrimarySelectionDeviceManagerV1::createDevice(QWaylandInputDevice *seat)
+diff --git a/qtwayland/src/client/qwaylandscreen.cpp b/qtwayland/src/client/qwaylandscreen.cpp
+index 6cb337de..5537dafd 100644
+--- a/qtwayland/src/client/qwaylandscreen.cpp
++++ b/qtwayland/src/client/qwaylandscreen.cpp
+@@ -60,7 +60,7 @@ QWaylandXdgOutputManagerV1::QWaylandXdgOutputManagerV1(QWaylandDisplay* display,
+ }
+ 
+ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uint32_t id)
+-    : QtWayland::wl_output(waylandDisplay->wl_registry(), id, qMin(version, 2))
++    : QtWayland::wl_output(waylandDisplay->wl_registry(), id, qMin(version, 3))
+     , m_outputId(id)
+     , mWaylandDisplay(waylandDisplay)
+     , mOutputName(QStringLiteral("Screen%1").arg(id))
+@@ -72,7 +72,7 @@ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uin
+         qCWarning(lcQpaWayland) << "wl_output done event not supported by compositor,"
+                                 << "QScreen may not work correctly";
+         mWaylandDisplay->forceRoundTrip(); // Give the compositor a chance to send geometry etc.
+-        mOutputDone = true; // Fake the done event
++        mProcessedEvents |= OutputDoneEvent; // Fake the done event
+         maybeInitialize();
+     }
+ }
+@@ -81,16 +81,29 @@ QWaylandScreen::~QWaylandScreen()
+ {
+     if (zxdg_output_v1::isInitialized())
+         zxdg_output_v1::destroy();
++    if (wl_output::isInitialized() && wl_output_get_version(wl_output::object()) >= WL_OUTPUT_RELEASE_SINCE_VERSION)
++        wl_output::release();
++}
++
++uint QWaylandScreen::requiredEvents() const
++{
++    uint ret = OutputDoneEvent;
++
++    if (mWaylandDisplay->xdgOutputManager()) {
++        ret |= XdgOutputNameEvent;
++
++        if (mWaylandDisplay->xdgOutputManager()->version() < 3)
++            ret |= XdgOutputDoneEvent;
++    }
++    return ret;
+ }
+ 
+ void QWaylandScreen::maybeInitialize()
+ {
+     Q_ASSERT(!mInitialized);
+ 
+-    if (!mOutputDone)
+-        return;
+-
+-    if (mWaylandDisplay->xdgOutputManager() && !mXdgOutputDone)
++    const uint requiredEvents = this->requiredEvents();
++    if ((mProcessedEvents & requiredEvents) != requiredEvents)
+         return;
+ 
+     mInitialized = true;
+@@ -276,9 +289,8 @@ void QWaylandScreen::output_scale(int32_t factor)
+ 
+ void QWaylandScreen::output_done()
+ {
+-    mOutputDone = true;
+-    if (zxdg_output_v1::isInitialized() && mWaylandDisplay->xdgOutputManager()->version() >= 3)
+-        mXdgOutputDone = true;
++    mProcessedEvents |= OutputDoneEvent;
++
+     if (mInitialized) {
+         updateOutputProperties();
+         if (zxdg_output_v1::isInitialized())
+@@ -339,7 +351,7 @@ void QWaylandScreen::zxdg_output_v1_done()
+     if (Q_UNLIKELY(mWaylandDisplay->xdgOutputManager()->version() >= 3))
+         qWarning(lcQpaWayland) << "zxdg_output_v1.done received on version 3 or newer, this is most likely a bug in the compositor";
+ 
+-    mXdgOutputDone = true;
++    mProcessedEvents |= XdgOutputDoneEvent;
+     if (mInitialized)
+         updateXdgOutputProperties();
+     else
+@@ -348,7 +360,11 @@ void QWaylandScreen::zxdg_output_v1_done()
+ 
+ void QWaylandScreen::zxdg_output_v1_name(const QString &name)
+ {
++    if (Q_UNLIKELY(mInitialized))
++        qWarning(lcQpaWayland) << "zxdg_output_v1.name received after output has been initialized, this is most likely a bug in the compositor";
++
+     mOutputName = name;
++    mProcessedEvents |= XdgOutputNameEvent;
+ }
+ 
+ void QWaylandScreen::updateXdgOutputProperties()
+diff --git a/qtwayland/src/client/qwaylandscreen_p.h b/qtwayland/src/client/qwaylandscreen_p.h
+index df1c94f2..050cfdc0 100644
+--- a/qtwayland/src/client/qwaylandscreen_p.h
++++ b/qtwayland/src/client/qwaylandscreen_p.h
+@@ -116,6 +116,13 @@ public:
+     static QWaylandScreen *fromWlOutput(::wl_output *output);
+ 
+ private:
++    enum Event : uint {
++        XdgOutputDoneEvent = 0x1,
++        OutputDoneEvent = 0x2,
++        XdgOutputNameEvent = 0x4,
++    };
++    uint requiredEvents() const;
++
+     void output_mode(uint32_t flags, int width, int height, int refresh) override;
+     void output_geometry(int32_t x, int32_t y,
+                          int32_t width, int32_t height,
+@@ -148,8 +155,7 @@ private:
+     QSize mPhysicalSize;
+     QString mOutputName;
+     Qt::ScreenOrientation m_orientation = Qt::PrimaryOrientation;
+-    bool mOutputDone = false;
+-    bool mXdgOutputDone = false;
++    uint mProcessedEvents = 0;
+     bool mInitialized = false;
+ 
+ #if QT_CONFIG(cursor)
+diff --git a/qtwayland/src/client/qwaylandshmbackingstore.cpp b/qtwayland/src/client/qwaylandshmbackingstore.cpp
+index dc7ff670..41cffdf7 100644
+--- a/qtwayland/src/client/qwaylandshmbackingstore.cpp
++++ b/qtwayland/src/client/qwaylandshmbackingstore.cpp
+@@ -52,6 +52,7 @@
+ 
+ #include <QtWaylandClient/private/wayland-wayland-client-protocol.h>
+ 
++#include <fcntl.h>
+ #include <unistd.h>
+ #include <sys/mman.h>
+ 
+@@ -61,6 +62,9 @@
+ #  ifndef MFD_CLOEXEC
+ #    define MFD_CLOEXEC     0x0001U
+ #  endif
++#  ifndef MFD_ALLOW_SEALING
++#    define MFD_ALLOW_SEALING 0x0002U
++#  endif
+ #endif
+ 
+ QT_BEGIN_NAMESPACE
+@@ -74,8 +78,10 @@ QWaylandShmBuffer::QWaylandShmBuffer(QWaylandDisplay *display,
+     int alloc = stride * size.height();
+     int fd = -1;
+ 
+-#ifdef SYS_memfd_create
+-    fd = syscall(SYS_memfd_create, "wayland-shm", MFD_CLOEXEC);
++#if defined(SYS_memfd_create) && defined(F_SEAL_SEAL)
++    fd = syscall(SYS_memfd_create, "wayland-shm", MFD_CLOEXEC | MFD_ALLOW_SEALING);
++    if (fd >= 0)
++        fcntl(fd, F_ADD_SEALS, F_SEAL_SHRINK | F_SEAL_SEAL);
+ #endif
+ 
+     QScopedPointer<QFile> filePointer;
+diff --git a/qtwayland/src/client/qwaylandwindow.cpp b/qtwayland/src/client/qwaylandwindow.cpp
+index cb82857a..fb2c59dc 100644
+--- a/qtwayland/src/client/qwaylandwindow.cpp
++++ b/qtwayland/src/client/qwaylandwindow.cpp
+@@ -76,7 +76,6 @@ QWaylandWindow *QWaylandWindow::mMouseGrab = nullptr;
+ QWaylandWindow::QWaylandWindow(QWindow *window, QWaylandDisplay *display)
+     : QPlatformWindow(window)
+     , mDisplay(display)
+-    , mFrameQueue(mDisplay->createFrameQueue())
+     , mResizeAfterSwap(qEnvironmentVariableIsSet("QT_WAYLAND_RESIZE_AFTER_SWAP"))
+ {
+     {
+@@ -95,9 +94,6 @@ QWaylandWindow::QWaylandWindow(QWindow *window, QWaylandDisplay *display)
+ 
+ QWaylandWindow::~QWaylandWindow()
+ {
+-    mDisplay->destroyFrameQueue(mFrameQueue);
+-    mDisplay->handleWindowDestroyed(this);
+-
+     delete mWindowDecoration;
+ 
+     if (mSurface)
+@@ -243,6 +239,7 @@ bool QWaylandWindow::shouldCreateSubSurface() const
+ 
+ void QWaylandWindow::reset()
+ {
++    closeChildPopups();
+     delete mShellSurface;
+     mShellSurface = nullptr;
+     delete mSubSurfaceWindow;
+@@ -255,17 +252,22 @@ void QWaylandWindow::reset()
+         mSurface.reset();
+     }
+ 
+-    if (mFrameCallback) {
+-        wl_callback_destroy(mFrameCallback);
+-        mFrameCallback = nullptr;
+-    }
++    {
++        QMutexLocker lock(&mFrameSyncMutex);
++        if (mFrameCallback) {
++            wl_callback_destroy(mFrameCallback);
++            mFrameCallback = nullptr;
++        }
+ 
+-    mFrameCallbackElapsedTimer.invalidate();
+-    mWaitingForFrameCallback = false;
++        mFrameCallbackElapsedTimer.invalidate();
++        mWaitingForFrameCallback = false;
++    }
+     mFrameCallbackTimedOut = false;
+ 
+     mMask = QRegion();
+     mQueuedBuffer = nullptr;
++
++    mDisplay->handleWindowDestroyed(this);
+ }
+ 
+ QWaylandWindow *QWaylandWindow::fromWlSurface(::wl_surface *surface)
+@@ -351,19 +353,25 @@ void QWaylandWindow::setGeometry_helper(const QRect &rect)
+     }
+ }
+ 
+-void QWaylandWindow::setGeometry(const QRect &rect)
++void QWaylandWindow::setGeometry(const QRect &r)
+ {
++    auto rect = r;
++    if (fixedToplevelPositions && !QPlatformWindow::parent() && window()->type() != Qt::Popup
++        && window()->type() != Qt::ToolTip) {
++        rect.moveTo(screen()->geometry().topLeft());
++    }
+     setGeometry_helper(rect);
+ 
+     if (window()->isVisible() && rect.isValid()) {
+         if (mWindowDecoration)
+             mWindowDecoration->update();
+ 
+-        if (mResizeAfterSwap && windowType() == Egl && mSentInitialResize)
++        if (mResizeAfterSwap && windowType() == Egl && mSentInitialResize) {
++            QMutexLocker lock(&mResizeLock);
+             mResizeDirty = true;
+-        else
++        } else {
+             QWindowSystemInterface::handleGeometryChange(window(), geometry());
+-
++        }
+         mSentInitialResize = true;
+     }
+     QRect exposeGeometry(QPoint(), geometry().size());
+@@ -374,7 +382,7 @@ void QWaylandWindow::setGeometry(const QRect &rect)
+         mShellSurface->setWindowGeometry(windowContentGeometry());
+ 
+     if (isOpaque() && mMask.isEmpty())
+-        setOpaqueArea(rect);
++        setOpaqueArea(QRect(QPoint(0, 0), rect.size()));
+ }
+ 
+ void QWaylandWindow::resizeFromApplyConfigure(const QSize &sizeWithMargins, const QPoint &offset)
+@@ -399,21 +407,6 @@ void QWaylandWindow::sendExposeEvent(const QRect &rect)
+     mLastExposeGeometry = rect;
+ }
+ 
+-
+-static QVector<QPointer<QWaylandWindow>> activePopups;
+-
+-void QWaylandWindow::closePopups(QWaylandWindow *parent)
+-{
+-    while (!activePopups.isEmpty()) {
+-        auto popup = activePopups.takeLast();
+-        if (popup.isNull())
+-            continue;
+-        if (popup.data() == parent)
+-            return;
+-        popup->reset();
+-    }
+-}
+-
+ QPlatformScreen *QWaylandWindow::calculateScreenFromSurfaceEvents() const
+ {
+     QReadLocker lock(&mSurfaceLock);
+@@ -433,10 +426,7 @@ void QWaylandWindow::setVisible(bool visible)
+     lastVisible = visible;
+ 
+     if (visible) {
+-        if (window()->type() == Qt::Popup || window()->type() == Qt::ToolTip)
+-            activePopups << this;
+         initWindow();
+-        mDisplay->flushRequests();
+ 
+         setGeometry(windowGeometry());
+         // Don't flush the events here, or else the newly visible window may start drawing, but since
+@@ -444,7 +434,6 @@ void QWaylandWindow::setVisible(bool visible)
+         // QWaylandShmBackingStore::beginPaint().
+     } else {
+         sendExposeEvent(QRect());
+-        closePopups(this);
+         reset();
+     }
+ }
+@@ -556,12 +545,12 @@ void QWaylandWindow::sendRecursiveExposeEvent()
+ 
+ void QWaylandWindow::attach(QWaylandBuffer *buffer, int x, int y)
+ {
+-    Q_ASSERT(!buffer->committed());
+     QReadLocker locker(&mSurfaceLock);
+     if (mSurface == nullptr)
+         return;
+ 
+     if (buffer) {
++        Q_ASSERT(!buffer->committed());
+         handleUpdate();
+         buffer->setBusy();
+ 
+@@ -583,7 +572,11 @@ void QWaylandWindow::damage(const QRect &rect)
+     if (mSurface == nullptr)
+         return;
+ 
+-    mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    const int s = scale();
++    if (mDisplay->compositorVersion() >= 4)
++        mSurface->damage_buffer(s * rect.x(), s * rect.y(), s * rect.width(), s * rect.height());
++    else
++        mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
+ }
+ 
+ void QWaylandWindow::safeCommit(QWaylandBuffer *buffer, const QRegion &damage)
+@@ -619,8 +612,14 @@ void QWaylandWindow::commit(QWaylandBuffer *buffer, const QRegion &damage)
+         return;
+ 
+     attachOffset(buffer);
+-    for (const QRect &rect: damage)
+-        mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    if (mDisplay->compositorVersion() >= 4) {
++        const int s = scale();
++        for (const QRect &rect: damage)
++            mSurface->damage_buffer(s * rect.x(), s * rect.y(), s * rect.width(), s * rect.height());
++    } else {
++        for (const QRect &rect: damage)
++            mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    }
+     Q_ASSERT(!buffer->committed());
+     buffer->setCommitted();
+     mSurface->commit();
+@@ -635,42 +634,53 @@ void QWaylandWindow::commit()
+ 
+ const wl_callback_listener QWaylandWindow::callbackListener = {
+     [](void *data, wl_callback *callback, uint32_t time) {
+-        Q_UNUSED(callback);
+         Q_UNUSED(time);
+         auto *window = static_cast<QWaylandWindow*>(data);
+-        window->handleFrameCallback();
++        window->handleFrameCallback(callback);
+     }
+ };
+ 
+-void QWaylandWindow::handleFrameCallback()
++void QWaylandWindow::handleFrameCallback(wl_callback* callback)
+ {
++    QMutexLocker locker(&mFrameSyncMutex);
++    if (!mFrameCallback) {
++        // This means the callback is already unset by QWaylandWindow::reset.
++        // The wl_callback object will be destroyed there too.
++        return;
++    }
++    Q_ASSERT(callback == mFrameCallback);
++    wl_callback_destroy(callback);
++    mFrameCallback = nullptr;
++
+     mWaitingForFrameCallback = false;
+     mFrameCallbackElapsedTimer.invalidate();
+ 
+     // The rest can wait until we can run it on the correct thread
+-    if (!mWaitingForUpdateDelivery) {
+-        auto doHandleExpose = [this]() {
+-            bool wasExposed = isExposed();
+-            mFrameCallbackTimedOut = false;
+-            if (!wasExposed && isExposed()) // Did setting mFrameCallbackTimedOut make the window exposed?
+-                sendExposeEvent(QRect(QPoint(), geometry().size()));
+-            if (wasExposed && hasPendingUpdateRequest())
+-                deliverUpdateRequest();
+-
+-            mWaitingForUpdateDelivery = false;
+-        };
++    auto doHandleExpose = [this]() {
++        mWaitingForUpdateDelivery.storeRelease(false);
++        bool wasExposed = isExposed();
++        mFrameCallbackTimedOut = false;
++        if (!wasExposed && isExposed()) // Did setting mFrameCallbackTimedOut make the window exposed?
++            sendExposeEvent(QRect(QPoint(), geometry().size()));
++        if (wasExposed && hasPendingUpdateRequest())
++            deliverUpdateRequest();
++    };
+ 
++    if (mWaitingForUpdateDelivery.testAndSetAcquire(false, true)) {
+         // Queued connection, to make sure we don't call handleUpdate() from inside waitForFrameSync()
+         // in the single-threaded case.
+-        mWaitingForUpdateDelivery = true;
+         QMetaObject::invokeMethod(this, doHandleExpose, Qt::QueuedConnection);
+     }
++
++    mFrameSyncWait.notify_all();
+ }
+ 
+ bool QWaylandWindow::waitForFrameSync(int timeout)
+ {
+-    QMutexLocker locker(mFrameQueue.mutex);
+-    mDisplay->dispatchQueueWhile(mFrameQueue.queue, [&]() { return mWaitingForFrameCallback; }, timeout);
++    QMutexLocker locker(&mFrameSyncMutex);
++
++    QDeadlineTimer deadline(timeout);
++    while (mWaitingForFrameCallback && mFrameSyncWait.wait(&mFrameSyncMutex, deadline)) { }
+ 
+     if (mWaitingForFrameCallback) {
+         qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
+@@ -868,6 +878,17 @@ bool QWaylandWindow::createDecoration()
+             subsurf->set_position(pos.x() + m.left(), pos.y() + m.top());
+         }
+         sendExposeEvent(QRect(QPoint(), geometry().size()));
++
++        // This is a special case where the buffer is recreated, but since
++        // the content rect remains the same, the widgets remain the same
++        // size and are not redrawn, leaving the new buffer empty. As a simple
++        // work-around, we trigger a full extra update whenever the client-side
++        // window decorations are toggled while the window is showing.
++        // Note: createDecoration() is sometimes called from the render thread
++        // of Qt Quick. This is essentially wrong and could potentially cause problems,
++        // but until the underlying issue has been fixed, we have to use invokeMethod()
++        // here to avoid asserts.
++        QMetaObject::invokeMethod(window(), &QWindow::requestUpdate);
+     }
+ 
+     return mWindowDecoration;
+@@ -1023,6 +1044,13 @@ void QWaylandWindow::handleScreensChanged()
+ 
+     QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->QPlatformScreen::screen());
+     mLastReportedScreen = newScreen;
++    if (fixedToplevelPositions && !QPlatformWindow::parent() && window()->type() != Qt::Popup
++        && window()->type() != Qt::ToolTip
++        && geometry().topLeft() != newScreen->geometry().topLeft()) {
++        auto geometry = this->geometry();
++        geometry.moveTo(newScreen->geometry().topLeft());
++        setGeometry(geometry);
++    }
+ 
+     int scale = newScreen->isPlaceholder() ? 1 : static_cast<QWaylandScreen *>(newScreen)->scale();
+     if (scale != mScale) {
+@@ -1094,10 +1122,18 @@ bool QWaylandWindow::setMouseGrabEnabled(bool grab)
+     return true;
+ }
+ 
++Qt::WindowStates QWaylandWindow::windowStates() const
++{
++    return mLastReportedWindowStates;
++}
++
+ void QWaylandWindow::handleWindowStatesChanged(Qt::WindowStates states)
+ {
+     createDecoration();
+-    QWindowSystemInterface::handleWindowStateChanged(window(), states, mLastReportedWindowStates);
++    Qt::WindowStates statesWithoutActive = states & ~Qt::WindowActive;
++    Qt::WindowStates lastStatesWithoutActive = mLastReportedWindowStates & ~Qt::WindowActive;
++    QWindowSystemInterface::handleWindowStateChanged(window(), statesWithoutActive,
++                                                     lastStatesWithoutActive);
+     mLastReportedWindowStates = states;
+ }
+ 
+@@ -1139,19 +1175,24 @@ void QWaylandWindow::timerEvent(QTimerEvent *event)
+     if (event->timerId() != mFrameCallbackCheckIntervalTimerId)
+         return;
+ 
+-    bool callbackTimerExpired = mFrameCallbackElapsedTimer.hasExpired(mFrameCallbackTimeout);
+-    if (!mFrameCallbackElapsedTimer.isValid() || callbackTimerExpired ) {
+-        killTimer(mFrameCallbackCheckIntervalTimerId);
+-        mFrameCallbackCheckIntervalTimerId = -1;
+-    }
+-    if (mFrameCallbackElapsedTimer.isValid() && callbackTimerExpired) {
+-        mFrameCallbackElapsedTimer.invalidate();
++    {
++        QMutexLocker lock(&mFrameSyncMutex);
+ 
+-        qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
+-        mFrameCallbackTimedOut = true;
+-        mWaitingForUpdate = false;
+-        sendExposeEvent(QRect());
++        bool callbackTimerExpired = mFrameCallbackElapsedTimer.hasExpired(mFrameCallbackTimeout);
++        if (!mFrameCallbackElapsedTimer.isValid() || callbackTimerExpired ) {
++            killTimer(mFrameCallbackCheckIntervalTimerId);
++            mFrameCallbackCheckIntervalTimerId = -1;
++        }
++        if (!mFrameCallbackElapsedTimer.isValid() || !callbackTimerExpired) {
++            return;
++        }
++        mFrameCallbackElapsedTimer.invalidate();
+     }
++
++    qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
++    mFrameCallbackTimedOut = true;
++    mWaitingForUpdate = false;
++    sendExposeEvent(QRect());
+ }
+ 
+ void QWaylandWindow::requestUpdate()
+@@ -1160,8 +1201,11 @@ void QWaylandWindow::requestUpdate()
+     Q_ASSERT(hasPendingUpdateRequest()); // should be set by QPA
+ 
+     // If we have a frame callback all is good and will be taken care of there
+-    if (mWaitingForFrameCallback)
+-        return;
++    {
++        QMutexLocker locker(&mFrameSyncMutex);
++        if (mWaitingForFrameCallback)
++            return;
++    }
+ 
+     // If we've already called deliverUpdateRequest(), but haven't seen any attach+commit/swap yet
+     // This is a somewhat redundant behavior and might indicate a bug in the calling code, so log
+@@ -1174,7 +1218,12 @@ void QWaylandWindow::requestUpdate()
+     // so use invokeMethod to delay the delivery a bit.
+     QMetaObject::invokeMethod(this, [this] {
+         // Things might have changed in the meantime
+-        if (hasPendingUpdateRequest() && !mWaitingForFrameCallback)
++        {
++            QMutexLocker locker(&mFrameSyncMutex);
++            if (mWaitingForFrameCallback)
++                return;
++        }
++        if (hasPendingUpdateRequest())
+             deliverUpdateRequest();
+     }, Qt::QueuedConnection);
+ }
+@@ -1185,19 +1234,18 @@ void QWaylandWindow::requestUpdate()
+ void QWaylandWindow::handleUpdate()
+ {
+     qCDebug(lcWaylandBackingstore) << "handleUpdate" << QThread::currentThread();
++
+     // TODO: Should sync subsurfaces avoid requesting frame callbacks?
+     QReadLocker lock(&mSurfaceLock);
+     if (!mSurface)
+         return;
+ 
+-    if (mFrameCallback) {
+-        wl_callback_destroy(mFrameCallback);
+-        mFrameCallback = nullptr;
+-    }
++    QMutexLocker locker(&mFrameSyncMutex);
++    if (mWaitingForFrameCallback)
++        return;
+ 
+-    QMutexLocker locker(mFrameQueue.mutex);
+     struct ::wl_surface *wrappedSurface = reinterpret_cast<struct ::wl_surface *>(wl_proxy_create_wrapper(mSurface->object()));
+-    wl_proxy_set_queue(reinterpret_cast<wl_proxy *>(wrappedSurface), mFrameQueue.queue);
++    wl_proxy_set_queue(reinterpret_cast<wl_proxy *>(wrappedSurface), mDisplay->frameEventQueue());
+     mFrameCallback = wl_surface_frame(wrappedSurface);
+     wl_proxy_wrapper_destroy(wrappedSurface);
+     wl_callback_add_listener(mFrameCallback, &QWaylandWindow::callbackListener, this);
+@@ -1207,6 +1255,8 @@ void QWaylandWindow::handleUpdate()
+     // Start a timer for handling the case when the compositor stops sending frame callbacks.
+     if (mFrameCallbackTimeout > 0) {
+         QMetaObject::invokeMethod(this, [this] {
++            QMutexLocker locker(&mFrameSyncMutex);
++
+             if (mWaitingForFrameCallback) {
+                 if (mFrameCallbackCheckIntervalTimerId < 0)
+                     mFrameCallbackCheckIntervalTimerId = startTimer(mFrameCallbackTimeout);
+@@ -1267,6 +1317,20 @@ void QWaylandWindow::setOpaqueArea(const QRegion &opaqueArea)
+     wl_region_destroy(region);
+ }
+ 
++void QWaylandWindow::addChildPopup(QWaylandWindow *surface) {
++    mChildPopups.append(surface);
++}
++
++void QWaylandWindow::removeChildPopup(QWaylandWindow *surface) {
++    mChildPopups.removeAll(surface);
++}
++
++void QWaylandWindow::closeChildPopups() {
++    while (!mChildPopups.isEmpty()) {
++        auto popup = mChildPopups.takeLast();
++        popup->reset();
++    }
++}
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/client/qwaylandwindow_p.h b/qtwayland/src/client/qwaylandwindow_p.h
+index 01337cff..2f219d8c 100644
+--- a/qtwayland/src/client/qwaylandwindow_p.h
++++ b/qtwayland/src/client/qwaylandwindow_p.h
+@@ -98,6 +98,9 @@ public:
+     QWaylandWindow(QWindow *window, QWaylandDisplay *display);
+     ~QWaylandWindow() override;
+ 
++    // Keep Toplevels position on the top left corner of their screen
++    static inline bool fixedToplevelPositions = true;
++
+     virtual WindowType windowType() const = 0;
+     virtual void ensureSize();
+     WId winId() const override;
+@@ -148,6 +151,7 @@ public:
+     void setWindowState(Qt::WindowStates states) override;
+     void setWindowFlags(Qt::WindowFlags flags) override;
+     void handleWindowStatesChanged(Qt::WindowStates states);
++    Qt::WindowStates windowStates() const;
+ 
+     void raise() override;
+     void lower() override;
+@@ -206,6 +210,10 @@ public:
+     void handleUpdate();
+     void deliverUpdateRequest() override;
+ 
++    void addChildPopup(QWaylandWindow* child);
++    void removeChildPopup(QWaylandWindow* child);
++    void closeChildPopups();
++
+ public slots:
+     void applyConfigure();
+ 
+@@ -215,7 +223,11 @@ signals:
+ 
+ protected:
+     QWaylandDisplay *mDisplay = nullptr;
++
++    // mSurface can be written by the main thread. Other threads should claim a read lock for access
++    mutable QReadWriteLock mSurfaceLock;
+     QScopedPointer<QWaylandSurface> mSurface;
++
+     QWaylandShellSurface *mShellSurface = nullptr;
+     QWaylandSubSurface *mSubSurfaceWindow = nullptr;
+     QVector<QWaylandSubSurface *> mChildren;
+@@ -225,13 +237,14 @@ protected:
+     Qt::MouseButtons mMousePressedInContentArea = Qt::NoButton;
+ 
+     WId mWindowId;
+-    bool mWaitingForFrameCallback = false;
+     bool mFrameCallbackTimedOut = false; // Whether the frame callback has timed out
+-    bool mWaitingForUpdateDelivery = false;
+     int mFrameCallbackCheckIntervalTimerId = -1;
+-    QElapsedTimer mFrameCallbackElapsedTimer;
+-    struct ::wl_callback *mFrameCallback = nullptr;
+-    QWaylandDisplay::FrameQueue mFrameQueue;
++    QAtomicInt mWaitingForUpdateDelivery = false;
++
++    bool mWaitingForFrameCallback = false; // Protected by mFrameSyncMutex
++    QElapsedTimer mFrameCallbackElapsedTimer; // Protected by mFrameSyncMutex
++    struct ::wl_callback *mFrameCallback = nullptr; // Protected by mFrameSyncMutex
++    QMutex mFrameSyncMutex;
+     QWaitCondition mFrameSyncWait;
+ 
+     // True when we have called deliverRequestUpdate, but the client has not yet attached a new buffer
+@@ -261,6 +274,8 @@ protected:
+     QWaylandBuffer *mQueuedBuffer = nullptr;
+     QRegion mQueuedBufferDamage;
+ 
++    QList<QPointer<QWaylandWindow>> mChildPopups;
++
+ private:
+     void setGeometry_helper(const QRect &rect);
+     void initWindow();
+@@ -283,12 +298,10 @@ private:
+     QRect mLastExposeGeometry;
+ 
+     static const wl_callback_listener callbackListener;
+-    void handleFrameCallback();
++    void handleFrameCallback(struct ::wl_callback* callback);
+ 
+     static QWaylandWindow *mMouseGrab;
+ 
+-    mutable QReadWriteLock mSurfaceLock;
+-
+     friend class QWaylandSubSurface;
+ };
+ 
+diff --git a/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h b/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
+index ccad0048..4cc9b3b8 100644
+--- a/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
++++ b/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
+@@ -73,11 +73,10 @@ public:
+         return true;
+     }
+     virtual QWaylandShellSurface *createShellSurface(QWaylandWindow *window) = 0;
++    // kept for binary compat with layer-shell-qt
+     virtual void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) {
+-        if (newFocus)
+-            m_display->handleWindowActivated(newFocus);
+-        if (oldFocus)
+-            m_display->handleWindowDeactivated(oldFocus);
++        Q_UNUSED(newFocus);
++        Q_UNUSED(oldFocus);
+     }
+     virtual void *nativeResourceForWindow(const QByteArray &resource, QWindow *window) {
+         Q_UNUSED(resource);
+diff --git a/qtwayland/src/compositor/configure.json b/qtwayland/src/compositor/configure.json
+index bcfd5215..da95d07b 100644
+--- a/qtwayland/src/compositor/configure.json
++++ b/qtwayland/src/compositor/configure.json
+@@ -7,6 +7,31 @@
+     "testDir": "../../config.tests",
+ 
+     "libraries": {
++        "wayland-client": {
++            "label": "Wayland client library",
++            "headers": "wayland-version.h",
++            "test": {
++                "main": [
++                    "#if WAYLAND_VERSION_MAJOR < 1",
++                    "# error Wayland 1.8.0 or higher required",
++                    "#endif",
++                    "#if WAYLAND_VERSION_MAJOR == 1",
++                    "# if WAYLAND_VERSION_MINOR < 8",
++                    "#  error Wayland 1.8.0 or higher required",
++                    "# endif",
++                    "# if WAYLAND_VERSION_MINOR == 8",
++                    "#  if WAYLAND_VERSION_MICRO < 0",
++                    "#   error Wayland 1.8.0 or higher required",
++                    "#  endif",
++                    "# endif",
++                    "#endif"
++                 ]
++            },
++            "sources": [
++                { "type": "pkgConfig", "args": "wayland-client" },
++                "-lwayland-client"
++            ]
++        },
+         "wayland-server": {
+             "label": "wayland-server",
+             "headers": "wayland-version.h",
+@@ -151,8 +176,7 @@
+                     "#endif"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "dmabuf-client-buffer": {
+             "label": "Linux Client dma-buf Buffer Sharing",
+@@ -176,8 +200,7 @@
+                     "return 0;"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "vulkan-server-buffer": {
+             "label": "Vulkan Buffer Sharing",
+@@ -195,7 +218,8 @@
+                     "exportAllocInfo.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR;",
+                     "return 0;"
+                 ]
+-            }
++            },
++            "use": "wayland-client"
+         }
+     },
+ 
+diff --git a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
+index 7889f575..64140672 100644
+--- a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
++++ b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
+@@ -40,6 +40,7 @@
+ #include "qwaylandeglwindow.h"
+ 
+ #include <QtWaylandClient/private/qwaylandscreen_p.h>
++#include <QtWaylandClient/private/qwaylandsurface_p.h>
+ #include "qwaylandglcontext.h"
+ 
+ #include <QtEglSupport/private/qeglconvenience_p.h>
+@@ -124,6 +125,7 @@ void QWaylandEglWindow::updateSurface(bool create)
+         }
+         mOffset = QPoint();
+     } else {
++        QReadLocker locker(&mSurfaceLock);
+         if (m_waylandEglWindow) {
+             int current_width, current_height;
+             static bool disableResizeCheck = qgetenv("QT_WAYLAND_DISABLE_RESIZECHECK").toInt();
+@@ -131,14 +133,16 @@ void QWaylandEglWindow::updateSurface(bool create)
+             if (!disableResizeCheck) {
+                 wl_egl_window_get_attached_size(m_waylandEglWindow, &current_width, &current_height);
+             }
+-            if (disableResizeCheck || (current_width != sizeWithMargins.width() || current_height != sizeWithMargins.height())) {
++            if (disableResizeCheck || (current_width != sizeWithMargins.width() || current_height != sizeWithMargins.height()) || m_requestedSize != sizeWithMargins) {
+                 wl_egl_window_resize(m_waylandEglWindow, sizeWithMargins.width(), sizeWithMargins.height(), mOffset.x(), mOffset.y());
++                m_requestedSize = sizeWithMargins;
+                 mOffset = QPoint();
+ 
+                 m_resize = true;
+             }
+-        } else if (create && wlSurface()) {
+-            m_waylandEglWindow = wl_egl_window_create(wlSurface(), sizeWithMargins.width(), sizeWithMargins.height());
++        } else if (create && mSurface) {
++            m_waylandEglWindow = wl_egl_window_create(mSurface->object(), sizeWithMargins.width(), sizeWithMargins.height());
++            m_requestedSize = sizeWithMargins;
+         }
+ 
+         if (!m_eglSurface && m_waylandEglWindow && create) {
+diff --git a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
+index 5b1f4d56..0079dfef 100644
+--- a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
++++ b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
+@@ -88,6 +88,7 @@ private:
+     mutable QOpenGLFramebufferObject *m_contentFBO = nullptr;
+ 
+     QSurfaceFormat m_format;
++    QSize m_requestedSize;
+ };
+ 
+ }
+diff --git a/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h b/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
+index 56a710c3..c6a8b6c6 100644
+--- a/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
++++ b/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
+@@ -41,6 +41,8 @@
+ #include <QtCore/QTextStream>
+ #include <QtGui/QOpenGLTexture>
+ 
++#include <array>
++
+ #include <EGL/egl.h>
+ #include <EGL/eglext.h>
+ 
+diff --git a/qtwayland/src/plugins/decorations/bradient/main.cpp b/qtwayland/src/plugins/decorations/bradient/main.cpp
+index e75fda3c..fa885143 100644
+--- a/qtwayland/src/plugins/decorations/bradient/main.cpp
++++ b/qtwayland/src/plugins/decorations/bradient/main.cpp
+@@ -164,13 +164,10 @@ void QWaylandBradientDecoration::paint(QPaintDevice *device)
+     // Window icon
+     QIcon icon = waylandWindow()->windowIcon();
+     if (!icon.isNull()) {
+-        QPixmap pixmap = icon.pixmap(QSize(128, 128));
+-        QPixmap scaled = pixmap.scaled(22, 22, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+-
+         QRectF iconRect(0, 0, 22, 22);
+-        p.drawPixmap(iconRect.adjusted(margins().left() + BUTTON_SPACING, 4,
+-                                       margins().left() + BUTTON_SPACING, 4),
+-                     scaled, iconRect);
++        iconRect.adjust(margins().left() + BUTTON_SPACING, 4,
++                        margins().left() + BUTTON_SPACING, 4),
++        icon.paint(&p, iconRect.toRect());
+     }
+ 
+     // Window title
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
+index 85d25e3c..60bdd491 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
+@@ -47,18 +47,21 @@ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
+-QWaylandXdgPopupV5::QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow *window)
++QWaylandXdgPopupV5::QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow* parent, QWaylandWindow *window)
+     : QWaylandShellSurface(window)
+     , QtWayland::xdg_popup_v5(popup)
++    , m_parent(parent)
+     , m_window(window)
+ {
+     if (window->display()->windowExtension())
+         m_extendedWindow = new QWaylandExtendedSurface(window);
++    m_parent->addChildPopup(m_window);
+ }
+ 
+ QWaylandXdgPopupV5::~QWaylandXdgPopupV5()
+ {
+     xdg_popup_destroy(object());
++    m_parent->removeChildPopup(m_window);
+     delete m_extendedWindow;
+ }
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
+index 7494f6a6..d85f130b 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
+@@ -70,7 +70,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgPopupV5 : public QWaylandShellSurface
+ {
+     Q_OBJECT
+ public:
+-    QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow *window);
++    QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow* parent, QWaylandWindow *window);
+     ~QWaylandXdgPopupV5() override;
+ 
+ protected:
+@@ -78,6 +78,7 @@ protected:
+ 
+ private:
+     QWaylandExtendedSurface *m_extendedWindow = nullptr;
++    QWaylandWindow *m_parent = nullptr;
+     QWaylandWindow *m_window = nullptr;
+ };
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
+index 7e242c4a..def8452a 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
+@@ -84,7 +84,7 @@ QWaylandXdgPopupV5 *QWaylandXdgShellV5::createXdgPopup(QWaylandWindow *window, Q
+     int x = position.x() + parentWindow->frameMargins().left();
+     int y = position.y() + parentWindow->frameMargins().top();
+ 
+-    auto popup = new QWaylandXdgPopupV5(get_xdg_popup(window->wlSurface(), parentSurface, seat, m_popupSerial, x, y), window);
++    auto popup = new QWaylandXdgPopupV5(get_xdg_popup(window->wlSurface(), parentSurface, seat, m_popupSerial, x, y), parentWindow, window);
+     m_popups.append(window);
+     QObject::connect(popup, &QWaylandXdgPopupV5::destroyed, [this, window](){
+         m_popups.removeOne(window);
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
+index 4e25949f..cfc60939 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
+@@ -85,13 +85,6 @@ QWaylandShellSurface *QWaylandXdgShellV5Integration::createShellSurface(QWayland
+     return m_xdgShell->createXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellV5Integration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) {
+-    if (newFocus && qobject_cast<QWaylandXdgPopupV5 *>(newFocus->shellSurface()))
+-        m_display->handleWindowActivated(newFocus);
+-    if (oldFocus && qobject_cast<QWaylandXdgPopupV5 *>(oldFocus->shellSurface()))
+-        m_display->handleWindowDeactivated(oldFocus);
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
+index ce6bdb9e..aed88670 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
+@@ -67,7 +67,6 @@ public:
+     QWaylandXdgShellV5Integration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShellV5> m_xdgShell;
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
+index 8c371661..151c78e3 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
+@@ -174,6 +174,7 @@ QWaylandXdgSurfaceV6::Popup::Popup(QWaylandXdgSurfaceV6 *xdgSurface, QWaylandXdg
+     , m_xdgSurface(xdgSurface)
+     , m_parent(parent)
+ {
++    m_parent->window()->addChildPopup(m_xdgSurface->window());
+ }
+ 
+ QWaylandXdgSurfaceV6::Popup::~Popup()
+@@ -181,6 +182,8 @@ QWaylandXdgSurfaceV6::Popup::~Popup()
+     if (isInitialized())
+         destroy();
+ 
++    m_parent->window()->removeChildPopup(m_xdgSurface->window());
++
+     if (m_grabbing) {
+         auto *shell = m_xdgSurface->m_shell;
+         Q_ASSERT(shell->m_topmostGrabbingPopup == this);
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
+index 03164316..e8da8ba1 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
+@@ -68,20 +68,6 @@ QWaylandShellSurface *QWaylandXdgShellV6Integration::createShellSurface(QWayland
+     return m_xdgShell->getXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellV6Integration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus)
+-{
+-    if (newFocus) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurfaceV6 *>(newFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowActivated(newFocus);
+-    }
+-    if (oldFocus && qobject_cast<QWaylandXdgSurfaceV6 *>(oldFocus->shellSurface())) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurfaceV6 *>(oldFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowDeactivated(oldFocus);
+-    }
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
+index 261f8cbb..c1bcd5c6 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
+@@ -65,7 +65,6 @@ public:
+     QWaylandXdgShellV6Integration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShellV6> m_xdgShell;
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
+index f3e3c330..fa6d5808 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
+@@ -67,11 +67,6 @@ QWaylandXdgSurface::Toplevel::Toplevel(QWaylandXdgSurface *xdgSurface)
+ 
+ QWaylandXdgSurface::Toplevel::~Toplevel()
+ {
+-    if (m_applied.states & Qt::WindowActive) {
+-        QWaylandWindow *window = m_xdgSurface->window();
+-        window->display()->handleWindowDeactivated(window);
+-    }
+-
+     // The protocol spec requires that the decoration object is deleted before xdg_toplevel.
+     delete m_decoration;
+     m_decoration = nullptr;
+@@ -85,16 +80,15 @@ void QWaylandXdgSurface::Toplevel::applyConfigure()
+     if (!(m_applied.states & (Qt::WindowMaximized|Qt::WindowFullScreen)))
+         m_normalSize = m_xdgSurface->m_window->windowFrameGeometry().size();
+ 
+-    if ((m_pending.states & Qt::WindowActive) && !(m_applied.states & Qt::WindowActive))
++    if ((m_pending.states & Qt::WindowActive) && !(m_applied.states & Qt::WindowActive)
++        && !m_xdgSurface->m_window->display()->isKeyboardAvailable())
+         m_xdgSurface->m_window->display()->handleWindowActivated(m_xdgSurface->m_window);
+ 
+-    if (!(m_pending.states & Qt::WindowActive) && (m_applied.states & Qt::WindowActive))
++    if (!(m_pending.states & Qt::WindowActive) && (m_applied.states & Qt::WindowActive)
++        && !m_xdgSurface->m_window->display()->isKeyboardAvailable())
+         m_xdgSurface->m_window->display()->handleWindowDeactivated(m_xdgSurface->m_window);
+ 
+-    // TODO: none of the other plugins send WindowActive either, but is it on purpose?
+-    Qt::WindowStates statesWithoutActive = m_pending.states & ~Qt::WindowActive;
+-
+-    m_xdgSurface->m_window->handleWindowStatesChanged(statesWithoutActive);
++    m_xdgSurface->m_window->handleWindowStatesChanged(m_pending.states);
+ 
+     if (m_pending.size.isEmpty()) {
+         // An empty size in the configure means it's up to the client to choose the size
+@@ -105,8 +99,6 @@ void QWaylandXdgSurface::Toplevel::applyConfigure()
+         m_xdgSurface->m_window->resizeFromApplyConfigure(m_pending.size);
+     }
+ 
+-    m_xdgSurface->setSizeHints();
+-
+     m_applied = m_pending;
+     qCDebug(lcQpaWayland) << "Applied pending xdg_toplevel configure event:" << m_applied.size << m_applied.states;
+ }
+@@ -203,12 +195,17 @@ QtWayland::xdg_toplevel::resize_edge QWaylandXdgSurface::Toplevel::convertToResi
+                 | ((edges & Qt::RightEdge) ? resize_edge_right : 0));
+ }
+ 
+-QWaylandXdgSurface::Popup::Popup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parent,
++QWaylandXdgSurface::Popup::Popup(QWaylandXdgSurface *xdgSurface, QWaylandWindow *parent,
+                                  QtWayland::xdg_positioner *positioner)
+-    : xdg_popup(xdgSurface->get_popup(parent->object(), positioner->object()))
+-    , m_xdgSurface(xdgSurface)
++    : m_xdgSurface(xdgSurface)
++    , m_parentXdgSurface(qobject_cast<QWaylandXdgSurface *>(parent->shellSurface()))
+     , m_parent(parent)
+ {
++
++    init(xdgSurface->get_popup(m_parentXdgSurface ? m_parentXdgSurface->object() : nullptr, positioner->object()));
++    if (m_parent) {
++        m_parent->addChildPopup(m_xdgSurface->window());
++    }
+ }
+ 
+ QWaylandXdgSurface::Popup::~Popup()
+@@ -216,10 +213,24 @@ QWaylandXdgSurface::Popup::~Popup()
+     if (isInitialized())
+         destroy();
+ 
++    if (m_parent) {
++        m_parent->removeChildPopup(m_xdgSurface->window());
++    }
++
+     if (m_grabbing) {
+         auto *shell = m_xdgSurface->m_shell;
+         Q_ASSERT(shell->m_topmostGrabbingPopup == this);
+-        shell->m_topmostGrabbingPopup = m_parent->m_popup;
++        shell->m_topmostGrabbingPopup = m_parentXdgSurface ? m_parentXdgSurface->m_popup : nullptr;
++        m_grabbing = false;
++
++        // Synthesize Qt enter/leave events for popup
++        QWindow *leave = nullptr;
++        if (m_xdgSurface && m_xdgSurface->window())
++            leave = m_xdgSurface->window()->window();
++        QWindowSystemInterface::handleLeaveEvent(leave);
++
++        if (QWindow *enter = QGuiApplication::topLevelAt(QCursor::pos()))
++            QWindowSystemInterface::handleEnterEvent(enter, enter->mapFromGlobal(QCursor::pos()), QCursor::pos());
+     }
+ }
+ 
+@@ -257,6 +268,7 @@ QWaylandXdgSurface::QWaylandXdgSurface(QWaylandXdgShell *shell, ::xdg_surface *s
+                 m_toplevel->set_parent(parentXdgSurface->m_toplevel->object());
+         }
+     }
++    setSizeHints();
+ }
+ 
+ QWaylandXdgSurface::~QWaylandXdgSurface()
+@@ -400,8 +412,6 @@ void QWaylandXdgSurface::setPopup(QWaylandWindow *parent)
+ {
+     Q_ASSERT(!m_toplevel && !m_popup);
+ 
+-    auto parentXdgSurface = static_cast<QWaylandXdgSurface *>(parent->shellSurface());
+-
+     auto positioner = new QtWayland::xdg_positioner(m_shell->create_positioner());
+     // set_popup expects a position relative to the parent
+     QPoint transientPos = m_window->geometry().topLeft(); // this is absolute
+@@ -414,8 +424,9 @@ void QWaylandXdgSurface::setPopup(QWaylandWindow *parent)
+     positioner->set_anchor(QtWayland::xdg_positioner::anchor_top_left);
+     positioner->set_gravity(QtWayland::xdg_positioner::gravity_bottom_right);
+     positioner->set_size(m_window->geometry().width(), m_window->geometry().height());
+-    m_popup = new Popup(this, parentXdgSurface, positioner);
++    m_popup = new Popup(this, parent, positioner);
+     positioner->destroy();
++
+     delete positioner;
+ }
+ 
+@@ -437,6 +448,23 @@ void QWaylandXdgSurface::setGrabPopup(QWaylandWindow *parent, QWaylandInputDevic
+     }
+     setPopup(parent);
+     m_popup->grab(device, serial);
++
++    // Synthesize Qt enter/leave events for popup
++    if (!parent)
++        return;
++    QWindow *current = QGuiApplication::topLevelAt(QCursor::pos());
++    QWindow *leave = parent->window();
++    if (current != leave)
++        return;
++
++    QWindowSystemInterface::handleLeaveEvent(leave);
++
++    QWindow *enter = nullptr;
++    if (m_popup && m_popup->m_xdgSurface && m_popup->m_xdgSurface->window())
++        enter = m_popup->m_xdgSurface->window()->window();
++
++    if (enter)
++        QWindowSystemInterface::handleEnterEvent(enter, enter->mapFromGlobal(QCursor::pos()), QCursor::pos());
+ }
+ 
+ void QWaylandXdgSurface::xdg_surface_configure(uint32_t serial)
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
+index 96785205..4b518f0a 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
+@@ -131,14 +131,15 @@ private:
+ 
+     class Popup : public QtWayland::xdg_popup {
+     public:
+-        Popup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parent, QtWayland::xdg_positioner *positioner);
++        Popup(QWaylandXdgSurface *xdgSurface, QWaylandWindow *parent, QtWayland::xdg_positioner *positioner);
+         ~Popup() override;
+ 
+         void grab(QWaylandInputDevice *seat, uint serial);
+         void xdg_popup_popup_done() override;
+ 
+         QWaylandXdgSurface *m_xdgSurface = nullptr;
+-        QWaylandXdgSurface *m_parent = nullptr;
++        QWaylandXdgSurface *m_parentXdgSurface = nullptr;
++        QWaylandWindow *m_parent = nullptr;
+         bool m_grabbing = false;
+     };
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
+index 8769d971..da0dd6a7 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
+@@ -69,20 +69,6 @@ QWaylandShellSurface *QWaylandXdgShellIntegration::createShellSurface(QWaylandWi
+     return m_xdgShell->getXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellIntegration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus)
+-{
+-    if (newFocus) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurface *>(newFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowActivated(newFocus);
+-    }
+-    if (oldFocus && qobject_cast<QWaylandXdgSurface *>(oldFocus->shellSurface())) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurface *>(oldFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowDeactivated(oldFocus);
+-    }
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
+index b6caa6c9..2f929f98 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
+@@ -65,7 +65,6 @@ public:
+     QWaylandXdgShellIntegration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShell> m_xdgShell;
+diff --git a/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp b/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
+index 526d0ef4..f50ccf30 100644
+--- a/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
++++ b/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
+@@ -39,7 +39,10 @@
+ 
+ #include "qwaylandinputmethodeventbuilder_p.h"
+ 
++#include <QBrush>
++#include <QGuiApplication>
+ #include <QInputMethod>
++#include <QPalette>
+ #include <QTextCharFormat>
+ 
+ #ifdef QT_BUILD_WAYLANDCOMPOSITOR_LIB
+@@ -81,32 +84,38 @@ void QWaylandInputMethodEventBuilder::addPreeditStyling(uint32_t index, uint32_t
+     QTextCharFormat format;
+ 
+     switch (style) {
+-    case 0:
+-    case 1:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_NONE:
++        break;
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_DEFAULT:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_UNDERLINE:
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-    case 2:
+-    case 3:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_ACTIVE:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_INACTIVE:
+         format.setFontWeight(QFont::Bold);
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-    case 4:
+-        format.setFontUnderline(true);
+-        format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+-        m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_HIGHLIGHT:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_SELECTION:
++        {
++            format.setFontUnderline(true);
++            format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
++            QPalette palette = qApp->palette();
++            format.setBackground(QBrush(palette.color(QPalette::Active, QPalette::Highlight)));
++            format.setForeground(QBrush(palette.color(QPalette::Active, QPalette::HighlightedText)));
++            m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
++        }
+         break;
+-    case 5:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_INCORRECT:
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::WaveUnderline);
+         format.setUnderlineColor(QColor(Qt::red));
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-//    case QtWayland::wl_text_input::preedit_style_selection:
+-//    case QtWayland::wl_text_input::preedit_style_none:
+     default:
+         break;
+     }
+@@ -153,7 +162,7 @@ QInputMethodEvent QWaylandInputMethodEventBuilder::buildPreedit(const QString &t
+ 
+     if (m_preeditCursor < 0) {
+         attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, 0, QVariant()));
+-    } else if (m_preeditCursor > 0) {
++    } else {
+         attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, indexFromWayland(text, m_preeditCursor), 1, QVariant()));
+     }
+ 
+diff --git a/qtwayland/src/shared/qwaylandmimehelper.cpp b/qtwayland/src/shared/qwaylandmimehelper.cpp
+index a5fdd34d..e2fe1928 100644
+--- a/qtwayland/src/shared/qwaylandmimehelper.cpp
++++ b/qtwayland/src/shared/qwaylandmimehelper.cpp
+@@ -60,7 +60,7 @@ QByteArray QWaylandMimeHelper::getByteArray(QMimeData *mimeData, const QString &
+             buf.open(QIODevice::ReadWrite);
+             QByteArray fmt = "BMP";
+             if (mimeType.startsWith(QLatin1String("image/"))) {
+-                QByteArray imgFmt = mimeType.mid(6).toUpper().toLatin1();
++                QByteArray imgFmt = mimeType.mid(6).toLower().toLatin1();
+                 if (QImageWriter::supportedImageFormats().contains(imgFmt))
+                     fmt = imgFmt;
+             }
+@@ -74,7 +74,7 @@ QByteArray QWaylandMimeHelper::getByteArray(QMimeData *mimeData, const QString &
+         QList<QUrl> urls = mimeData->urls();
+         for (int i = 0; i < urls.count(); ++i) {
+             content.append(urls.at(i).toEncoded());
+-            content.append('\n');
++            content.append("\r\n");
+         }
+     } else {
+         content = mimeData->data(mimeType);
+diff --git a/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp b/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
+index 1568b3b9..067410d0 100644
+--- a/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
++++ b/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
+@@ -35,7 +35,7 @@
+ 
+ using namespace MockCompositor;
+ 
+-constexpr int dataDeviceVersion = 1;
++constexpr int dataDeviceVersion = 3;
+ 
+ class DataDeviceCompositor : public DefaultCompositor {
+ public:
+diff --git a/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp b/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
+index 9312c2e5..2ea382f1 100644
+--- a/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
++++ b/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
+@@ -73,6 +73,7 @@ private slots:
+     void multiTouch();
+     void multiTouchUpAndMotionFrame();
+     void tapAndMoveInSameFrame();
++    void cancelTouch();
+ };
+ 
+ void tst_seatv5::bindsToSeat()
+@@ -646,5 +647,34 @@ void tst_seatv5::tapAndMoveInSameFrame()
+     QTRY_COMPARE(window.m_events.last().touchPoints.first().state(), Qt::TouchPointState::TouchPointReleased);
+ }
+ 
++void tst_seatv5::cancelTouch()
++{
++    TouchWindow window;
++    QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
++
++    exec([=] {
++        auto *t = touch();
++        auto *c = client();
++        t->sendDown(xdgToplevel()->surface(), {32, 32}, 1);
++        t->sendFrame(c);
++        t->sendCancel(c);
++        t->sendFrame(c);
++    });
++
++    QTRY_VERIFY(!window.m_events.empty());
++    {
++        auto e = window.m_events.takeFirst();
++        QCOMPARE(e.type, QEvent::TouchBegin);
++        QCOMPARE(e.touchPointStates, Qt::TouchPointPressed);
++        QCOMPARE(e.touchPoints.length(), 1);
++        QCOMPARE(e.touchPoints.first().pos(), QPointF(32-window.frameMargins().left(), 32-window.frameMargins().top()));
++    }
++    {
++        auto e = window.m_events.takeFirst();
++        QCOMPARE(e.type, QEvent::TouchCancel);
++        QCOMPARE(e.touchPoints.length(), 0);
++    }
++}
++
+ QCOMPOSITOR_TEST_MAIN(tst_seatv5)
+ #include "tst_seatv5.moc"
+diff --git a/qtwayland/tests/auto/client/shared/corecompositor.cpp b/qtwayland/tests/auto/client/shared/corecompositor.cpp
+index 5c6c83ba..fa9b7662 100644
+--- a/qtwayland/tests/auto/client/shared/corecompositor.cpp
++++ b/qtwayland/tests/auto/client/shared/corecompositor.cpp
+@@ -27,6 +27,7 @@
+ ****************************************************************************/
+ 
+ #include "corecompositor.h"
++#include <thread>
+ 
+ namespace MockCompositor {
+ 
+diff --git a/qtwayland/tests/auto/client/shared/coreprotocol.cpp b/qtwayland/tests/auto/client/shared/coreprotocol.cpp
+index 0d988521..d1a2e7cb 100644
+--- a/qtwayland/tests/auto/client/shared/coreprotocol.cpp
++++ b/qtwayland/tests/auto/client/shared/coreprotocol.cpp
+@@ -451,6 +451,13 @@ void Touch::sendFrame(wl_client *client)
+         send_frame(r->handle);
+ }
+ 
++void Touch::sendCancel(wl_client *client)
++{
++    const auto touchResources = resourceMap().values(client);
++    for (auto *r : touchResources)
++        send_cancel(r->handle);
++}
++
+ uint Keyboard::sendEnter(Surface *surface)
+ {
+     auto serial = m_seat->m_compositor->nextSerial();
+diff --git a/qtwayland/tests/auto/client/shared/coreprotocol.h b/qtwayland/tests/auto/client/shared/coreprotocol.h
+index a1af137a..210d8ddb 100644
+--- a/qtwayland/tests/auto/client/shared/coreprotocol.h
++++ b/qtwayland/tests/auto/client/shared/coreprotocol.h
+@@ -158,7 +158,7 @@ class WlCompositor : public Global, public QtWaylandServer::wl_compositor
+ {
+     Q_OBJECT
+ public:
+-    explicit WlCompositor(CoreCompositor *compositor, int version = 3)
++    explicit WlCompositor(CoreCompositor *compositor, int version = 4)
+         : QtWaylandServer::wl_compositor(compositor->m_display, version)
+         , m_compositor(compositor)
+     {}
+@@ -364,6 +364,7 @@ public:
+     uint sendUp(wl_client *client, int id);
+     void sendMotion(wl_client *client, const QPointF &position, int id);
+     void sendFrame(wl_client *client);
++    void sendCancel(wl_client *client);
+ 
+     Seat *m_seat = nullptr;
+ };
+diff --git a/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp b/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
+index a415cbf5..b1d3d07d 100644
+--- a/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
++++ b/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
+@@ -342,7 +342,7 @@ Compositor::Compositor(MockCompositor *mockCompositor)
+         exit(EXIT_FAILURE);
+     }
+ 
+-    wl_global_create(m_display, &wl_compositor_interface, 1, this, bindCompositor);
++    wl_global_create(m_display, &wl_compositor_interface, 4, this, bindCompositor);
+ 
+     m_data_device_manager.reset(new DataDeviceManager(this, m_display));
+ 
+diff --git a/qtwayland/tests/auto/client/shared_old/mocksurface.cpp b/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
+index e9df5f90..c3246e4a 100644
+--- a/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
++++ b/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
+@@ -125,6 +125,16 @@ void Surface::surface_damage(Resource *resource,
+     Q_UNUSED(height);
+ }
+ 
++void Surface::surface_damage_buffer(Resource *resource,
++                                    int32_t x, int32_t y, int32_t width, int32_t height)
++{
++    Q_UNUSED(resource);
++    Q_UNUSED(x);
++    Q_UNUSED(y);
++    Q_UNUSED(width);
++    Q_UNUSED(height);
++}
++
+ void Surface::surface_frame(Resource *resource,
+                             uint32_t callback)
+ {
+diff --git a/qtwayland/tests/auto/client/shared_old/mocksurface.h b/qtwayland/tests/auto/client/shared_old/mocksurface.h
+index 949dc23d..d176837e 100644
+--- a/qtwayland/tests/auto/client/shared_old/mocksurface.h
++++ b/qtwayland/tests/auto/client/shared_old/mocksurface.h
+@@ -65,6 +65,8 @@ protected:
+                         struct wl_resource *buffer, int x, int y) override;
+     void surface_damage(Resource *resource,
+                         int32_t x, int32_t y, int32_t width, int32_t height) override;
++    void surface_damage_buffer(Resource *resource,
++                               int32_t x, int32_t y, int32_t width, int32_t height) override;
+     void surface_frame(Resource *resource,
+                        uint32_t callback) override;
+     void surface_commit(Resource *resource) override;
+diff --git a/qtwayland/tests/auto/client/surface/tst_surface.cpp b/qtwayland/tests/auto/client/surface/tst_surface.cpp
+index 95e4e609..60c672ce 100644
+--- a/qtwayland/tests/auto/client/surface/tst_surface.cpp
++++ b/qtwayland/tests/auto/client/surface/tst_surface.cpp
+@@ -129,6 +129,10 @@ void tst_surface::waitForFrameCallbackGl()
+     // Make sure we follow frame callbacks for some frames
+     for (int i = 0; i < 5; ++i) {
+         xdgPingAndWaitForPong(); // Make sure things have happened on the client
++        if (!qEnvironmentVariableIntValue("QT_WAYLAND_DISABLE_WINDOWDECORATION") && i == 0) {
++            QCOMPARE(bufferSpy.count(), 1);
++            bufferSpy.removeFirst();
++        }
+         exec([&] {
+             QVERIFY(bufferSpy.empty()); // Make sure no extra buffers have arrived
+             QVERIFY(!xdgToplevel()->surface()->m_waitingFrameCallbacks.empty());
+diff --git a/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp b/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
+index 2277bbb8..747875b4 100644
+--- a/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
++++ b/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
+@@ -31,6 +31,7 @@
+ #include <QtGui/QOpenGLWindow>
+ #include <QtGui/qpa/qplatformnativeinterface.h>
+ #include <QtWaylandClient/private/wayland-wayland-client-protocol.h>
++#include <QtWaylandClient/private/qwaylandwindow_p.h>
+ 
+ using namespace MockCompositor;
+ 
+@@ -45,6 +46,7 @@ private slots:
+     void configureStates();
+     void popup();
+     void tooltipOnPopup();
++    void tooltipAndSiblingPopup();
+     void switchPopups();
+     void hidePopupParent();
+     void pongs();
+@@ -138,6 +140,7 @@ void tst_xdgshell::configureSize()
+ 
+ void tst_xdgshell::configureStates()
+ {
++    QVERIFY(qputenv("QT_WAYLAND_FRAME_CALLBACK_TIMEOUT", "0"));
+     QRasterWindow window;
+     window.resize(64, 48);
+     window.show();
+@@ -154,9 +157,12 @@ void tst_xdgshell::configureStates()
+     // Toplevel windows don't know their position on xdg-shell
+ //    QCOMPARE(window.frameGeometry().topLeft(), QPoint()); // TODO: this doesn't currently work when window decorations are enabled
+ 
+-//    QEXPECT_FAIL("", "configure has already been acked, we shouldn't have to wait for isActive", Continue);
+-//    QVERIFY(window.isActive());
+-    QTRY_VERIFY(window.isActive()); // Just make sure it eventually get's set correctly
++    // window.windowstate() is driven by keyboard focus, however for decorations we want to follow
++    // XDGShell this is internal to QtWayland so it is queried directly
++    auto waylandWindow = static_cast<QtWaylandClient::QWaylandWindow *>(window.handle());
++    Q_ASSERT(waylandWindow);
++    QTRY_VERIFY(waylandWindow->windowStates().testFlag(
++            Qt::WindowActive)); // Just make sure it eventually get's set correctly
+ 
+     const QSize screenSize(640, 480);
+     const uint maximizedSerial = exec([=] {
+@@ -186,6 +192,7 @@ void tst_xdgshell::configureStates()
+     QCOMPARE(window.windowStates(), Qt::WindowNoState);
+     QCOMPARE(window.frameGeometry().size(), windowedSize);
+ //    QCOMPARE(window.frameGeometry().topLeft(), QPoint()); // TODO: this doesn't currently work when window decorations are enabled
++    QVERIFY(qunsetenv("QT_WAYLAND_FRAME_CALLBACK_TIMEOUT"));
+ }
+ 
+ void tst_xdgshell::popup()
+@@ -340,6 +347,92 @@ void tst_xdgshell::tooltipOnPopup()
+     QCOMPOSITOR_TRY_COMPARE(xdgPopup(0), nullptr);
+ }
+ 
++void tst_xdgshell::tooltipAndSiblingPopup()
++{
++    class ToolTip : public QRasterWindow {
++    public:
++        explicit ToolTip(QWindow *parent) {
++            setTransientParent(parent);
++            setFlags(Qt::ToolTip);
++            resize(100, 100);
++            show();
++        }
++        void mousePressEvent(QMouseEvent *event) override {
++            QRasterWindow::mousePressEvent(event);
++            m_popup = new QRasterWindow;
++            m_popup->setTransientParent(transientParent());
++            m_popup->setFlags(Qt::Popup);
++            m_popup->resize(100, 100);
++            m_popup->show();
++        }
++
++        QRasterWindow *m_popup = nullptr;
++    };
++
++    class Window : public QRasterWindow {
++    public:
++        void mousePressEvent(QMouseEvent *event) override {
++            QRasterWindow::mousePressEvent(event);
++            m_tooltip = new ToolTip(this);
++        }
++        ToolTip *m_tooltip = nullptr;
++    };
++
++    Window window;
++    window.resize(200, 200);
++    window.show();
++
++    QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
++    exec([=] { xdgToplevel()->sendCompleteConfigure(); });
++    QCOMPOSITOR_TRY_VERIFY(xdgToplevel()->m_xdgSurface->m_committedConfigureSerial);
++
++    exec([=] {
++        auto *surface = xdgToplevel()->surface();
++        auto *p = pointer();
++        auto *c = client();
++        p->sendEnter(surface, {100, 100});
++        p->sendFrame(c);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_pressed);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_released);
++        p->sendFrame(c);
++        p->sendLeave(surface);
++        p->sendFrame(c);
++    });
++
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup());
++    exec([=] { xdgPopup()->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup()->m_xdgSurface->m_committedConfigureSerial);
++    QCOMPOSITOR_TRY_VERIFY(!xdgPopup()->m_grabbed);
++
++    exec([=] {
++        auto *surface = xdgPopup()->surface();
++        auto *p = pointer();
++        auto *c = client();
++        p->sendEnter(surface, {100, 100});
++        p->sendFrame(c);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_pressed);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_released);
++        p->sendFrame(c);
++    });
++
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1));
++    exec([=] { xdgPopup(1)->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1)->m_xdgSurface->m_committedConfigureSerial);
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1)->m_grabbed);
++
++    // Close the middle tooltip (it should not close the sibling popup)
++    window.m_tooltip->close();
++
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(1), nullptr);
++    // Verify the remaining xdg surface is a grab popup..
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(0));
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(0)->m_grabbed);
++
++    window.m_tooltip->m_popup->close();
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(1), nullptr);
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(0), nullptr);
++}
++
+ // QTBUG-65680
+ void tst_xdgshell::switchPopups()
+ {
+@@ -505,7 +598,7 @@ void tst_xdgshell::minMaxSize()
+     window.show();
+     QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
+ 
+-    exec([=] { xdgToplevel()->sendCompleteConfigure(); });
++    // we don't roundtrip with our configuration the initial commit should be correct
+ 
+     QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.minSize, QSize(100, 100));
+     QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.maxSize, QSize(1000, 1000));
+Submodule qtwebchannel 618422ee..f8949655:
+diff --git a/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp b/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
+index 536eb5c..898d769 100644
+--- a/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
++++ b/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
+@@ -186,8 +186,6 @@ Q_DECLARE_TYPEINFO(OverloadResolutionCandidate, Q_MOVABLE_TYPE);
+ QMetaObjectPublisher::QMetaObjectPublisher(QWebChannel *webChannel)
+     : QObject(webChannel)
+     , webChannel(webChannel)
+-    , signalHandler(this)
+-    , clientIsIdle(false)
+     , blockUpdates(false)
+     , propertyUpdatesInitialized(false)
+ {
+@@ -301,17 +299,17 @@ QJsonObject QMetaObjectPublisher::classInfoForObject(const QObject *object, QWeb
+     return data;
+ }
+ 
+-void QMetaObjectPublisher::setClientIsIdle(bool isIdle)
++void QMetaObjectPublisher::setClientIsIdle(bool isIdle, QWebChannelAbstractTransport *transport)
+ {
+-    if (clientIsIdle == isIdle) {
+-        return;
+-    }
+-    clientIsIdle = isIdle;
+-    if (!isIdle && timer.isActive()) {
+-        timer.stop();
+-    } else if (isIdle && !timer.isActive()) {
+-        timer.start(PROPERTY_UPDATE_INTERVAL, this);
+-    }
++    transportState[transport].clientIsIdle = isIdle;
++    if (isIdle)
++        sendEnqueuedPropertyUpdates(transport);
++}
++
++bool QMetaObjectPublisher::isClientIdle(QWebChannelAbstractTransport *transport)
++{
++    auto found = transportState.find(transport);
++    return found != transportState.end() && found.value().clientIsIdle;
+ }
+ 
+ QJsonObject QMetaObjectPublisher::initializeClient(QWebChannelAbstractTransport *transport)
+@@ -333,6 +331,7 @@ QJsonObject QMetaObjectPublisher::initializeClient(QWebChannelAbstractTransport
+ 
+ void QMetaObjectPublisher::initializePropertyUpdates(const QObject *const object, const QJsonObject &objectInfo)
+ {
++    auto *signalHandler = signalHandlerFor(object);
+     foreach (const QJsonValue &propertyInfoVar, objectInfo[KEY_PROPERTIES].toArray()) {
+         const QJsonArray &propertyInfo = propertyInfoVar.toArray();
+         if (propertyInfo.size() < 2) {
+@@ -353,19 +352,19 @@ void QMetaObjectPublisher::initializePropertyUpdates(const QObject *const object
+ 
+         // Only connect for a property update once
+         if (connectedProperties.isEmpty()) {
+-            signalHandler.connectTo(object, signalIndex);
++            signalHandler->connectTo(object, signalIndex);
+         }
+ 
+         connectedProperties.insert(propertyIndex);
+     }
+ 
+     // also always connect to destroyed signal
+-    signalHandler.connectTo(object, s_destroyedSignalIndex);
++    signalHandler->connectTo(object, s_destroyedSignalIndex);
+ }
+ 
+ void QMetaObjectPublisher::sendPendingPropertyUpdates()
+ {
+-    if (blockUpdates || !clientIsIdle || pendingPropertyUpdates.isEmpty()) {
++    if (blockUpdates) {
+         return;
+     }
+ 
+@@ -415,18 +414,19 @@ void QMetaObjectPublisher::sendPendingPropertyUpdates()
+ 
+     // data does not contain specific updates
+     if (!data.isEmpty()) {
+-        setClientIsIdle(false);
+-
+         message[KEY_DATA] = data;
+-        broadcastMessage(message);
++        enqueueBroadcastMessage(message);
+     }
+ 
+     // send every property update which is not supposed to be broadcasted
+     const QHash<QWebChannelAbstractTransport*, QJsonArray>::const_iterator suend = specificUpdates.constEnd();
+     for (QHash<QWebChannelAbstractTransport*, QJsonArray>::const_iterator it = specificUpdates.constBegin(); it != suend; ++it) {
+         message[KEY_DATA] = it.value();
+-        it.key()->sendMessage(message);
++        enqueueMessage(message, it.key());
+     }
++
++    for (auto state = transportState.begin(); state != transportState.end(); ++state)
++        sendEnqueuedPropertyUpdates(state.key());
+ }
+ 
+ QVariant QMetaObjectPublisher::invokeMethod(QObject *const object, const QMetaMethod &method,
+@@ -572,7 +572,7 @@ void QMetaObjectPublisher::signalEmitted(const QObject *object, const int signal
+         }
+     } else {
+         pendingPropertyUpdates[object][signalIndex] = arguments;
+-        if (clientIsIdle && !blockUpdates && !timer.isActive()) {
++        if (!blockUpdates && !timer.isActive()) {
+             timer.start(PROPERTY_UPDATE_INTERVAL, this);
+         }
+     }
+@@ -590,7 +590,7 @@ void QMetaObjectPublisher::objectDestroyed(const QObject *object)
+     // only remove from handler when we initialized the property updates
+     // cf: https://bugreports.qt.io/browse/QTBUG-60250
+     if (propertyUpdatesInitialized) {
+-        signalHandler.remove(object);
++        signalHandlerFor(object)->remove(object);
+         signalToPropertyMap.remove(object);
+     }
+     pendingPropertyUpdates.remove(object);
+@@ -852,6 +852,52 @@ void QMetaObjectPublisher::broadcastMessage(const QJsonObject &message) const
+     }
+ }
+ 
++void QMetaObjectPublisher::enqueueBroadcastMessage(const QJsonObject &message)
++{
++    if (webChannel->d_func()->transports.isEmpty()) {
++        qWarning("QWebChannel is not connected to any transports, cannot send message: %s",
++                 QJsonDocument(message).toJson().constData());
++        return;
++    }
++
++    for (auto *transport : webChannel->d_func()->transports) {
++        auto &state = transportState[transport];
++        state.queuedMessages.append(message);
++    }
++}
++
++void QMetaObjectPublisher::enqueueMessage(const QJsonObject &message,
++                                          QWebChannelAbstractTransport *transport)
++{
++    auto &state = transportState[transport];
++    state.queuedMessages.append(message);
++}
++
++void QMetaObjectPublisher::sendEnqueuedPropertyUpdates(QWebChannelAbstractTransport *transport)
++{
++    auto found = transportState.find(transport);
++    if (found != transportState.end() && found.value().clientIsIdle
++        && !found.value().queuedMessages.isEmpty()) {
++
++        // If the client is connected with an in-process transport, it can
++        // happen that a message triggers a subsequent property change. In
++        // that case, we need to ensure that the queued messages have already
++        // been cleared; otherwise the recursive call will send everythig again.
++        // Case in point: The qmlwebchannel tests fail if we don't clear the
++        // queued messages before sending them out.
++        // For that same reason set the client to "busy" (aka non-idle) just
++        // right before sending out the messages; otherwise a potential
++        // "Idle" type message will not correctly restore the Idle state.
++        const auto messages = std::move(found.value().queuedMessages);
++        Q_ASSERT(found.value().queuedMessages.isEmpty());
++        found.value().clientIsIdle = false;
++
++        for (const auto &message : messages) {
++            transport->sendMessage(message);
++        }
++    }
++}
++
+ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannelAbstractTransport *transport)
+ {
+     if (!webChannel->d_func()->transports.contains(transport)) {
+@@ -866,7 +912,7 @@ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannel
+ 
+     const MessageType type = toType(message.value(KEY_TYPE));
+     if (type == TypeIdle) {
+-        setClientIsIdle(true);
++        setClientIsIdle(true, transport);
+     } else if (type == TypeInit) {
+         if (!message.contains(KEY_ID)) {
+             qWarning("JSON message object is missing the id property: %s",
+@@ -913,9 +959,9 @@ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannel
+                 return;
+             transport->sendMessage(createResponse(message.value(KEY_ID), wrapResult(result, transport)));
+         } else if (type == TypeConnectToSignal) {
+-            signalHandler.connectTo(object, message.value(KEY_SIGNAL).toInt(-1));
++            signalHandlerFor(object)->connectTo(object, message.value(KEY_SIGNAL).toInt(-1));
+         } else if (type == TypeDisconnectFromSignal) {
+-            signalHandler.disconnectFrom(object, message.value(KEY_SIGNAL).toInt(-1));
++            signalHandlerFor(object)->disconnectFrom(object, message.value(KEY_SIGNAL).toInt(-1));
+         } else if (type == TypeSetProperty) {
+             setProperty(object, message.value(KEY_PROPERTY).toInt(-1),
+                         message.value(KEY_VALUE));
+@@ -931,6 +977,7 @@ void QMetaObjectPublisher::setBlockUpdates(bool block)
+     blockUpdates = block;
+ 
+     if (!blockUpdates) {
++        timer.start(PROPERTY_UPDATE_INTERVAL, this);
+         sendPendingPropertyUpdates();
+     } else if (timer.isActive()) {
+         timer.stop();
+@@ -948,4 +995,15 @@ void QMetaObjectPublisher::timerEvent(QTimerEvent *event)
+     }
+ }
+ 
++SignalHandler<QMetaObjectPublisher> *QMetaObjectPublisher::signalHandlerFor(const QObject *object)
++{
++    auto thread = object->thread();
++    auto it = signalHandlers.find(thread);
++    if (it == signalHandlers.end()) {
++        it = signalHandlers.emplace(thread, this).first;
++        it->second.moveToThread(thread);
++    }
++    return &it->second;
++}
++
+ QT_END_NAMESPACE
+diff --git a/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h b/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
+index bbd9875..4713ef1 100644
+--- a/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
++++ b/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
+@@ -59,6 +59,9 @@
+ #include <QBasicTimer>
+ #include <QPointer>
+ #include <QJsonObject>
++#include <QQueue>
++
++#include <unordered_map>
+ 
+ #include "qwebchannelglobal.h"
+ 
+@@ -109,17 +112,36 @@ public:
+      */
+     void broadcastMessage(const QJsonObject &message) const;
+ 
++    /**
++     * Enqueue the given @p message to all known transports.
++     */
++    void enqueueBroadcastMessage(const QJsonObject &message);
++
++    /**
++     * Enqueue the given @p message to @p transport.
++     */
++    void enqueueMessage(const QJsonObject &message, QWebChannelAbstractTransport *transport);
++
++    /**
++     * If client for given @p transport is idle, send queued messaged to @p transport and then mark
++     * the client as not idle.
++     */
++    void sendEnqueuedPropertyUpdates(QWebChannelAbstractTransport *transport);
++
+     /**
+      * Serialize the QMetaObject of @p object and return it in JSON form.
+      */
+     QJsonObject classInfoForObject(const QObject *object, QWebChannelAbstractTransport *transport);
+ 
+     /**
+-     * Set the client to idle or busy, based on the value of @p isIdle.
+-     *
+-     * When the value changed, start/stop the property update timer accordingly.
++     * Set the client to idle or busy for a single @p transport, based on the value of @p isIdle.
++     */
++    void setClientIsIdle(bool isIdle, QWebChannelAbstractTransport *transport);
++
++    /**
++     * Check that client is idle for @p transport.
+      */
+-    void setClientIsIdle(bool isIdle);
++    bool isClientIdle(QWebChannelAbstractTransport *transport);
+ 
+     /**
+      * Initialize clients by sending them the class information of the registered objects.
+@@ -272,10 +294,18 @@ private:
+     friend class TestWebChannel;
+ 
+     QWebChannel *webChannel;
+-    SignalHandler<QMetaObjectPublisher> signalHandler;
++    std::unordered_map<const QThread*, SignalHandler<QMetaObjectPublisher>> signalHandlers;
++    SignalHandler<QMetaObjectPublisher> *signalHandlerFor(const QObject *object);
+ 
+-    // true when the client is idle, false otherwise
+-    bool clientIsIdle;
++    struct TransportState
++    {
++        TransportState() : clientIsIdle(false) { }
++        // true when the client is idle, false otherwise
++        bool clientIsIdle;
++        // messages to send
++        QQueue<QJsonObject> queuedMessages;
++    };
++    QHash<QWebChannelAbstractTransport *, TransportState> transportState;
+ 
+     // true when no property updates should be sent, false otherwise
+     bool blockUpdates;
+diff --git a/qtwebchannel/src/webchannel/signalhandler_p.h b/qtwebchannel/src/webchannel/signalhandler_p.h
+index 27afadb..d77373c 100644
+--- a/qtwebchannel/src/webchannel/signalhandler_p.h
++++ b/qtwebchannel/src/webchannel/signalhandler_p.h
+@@ -56,6 +56,7 @@
+ #include <QVector>
+ #include <QMetaMethod>
+ #include <QDebug>
++#include <QThread>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -71,6 +72,7 @@ static const int s_destroyedSignalIndex = QObject::staticMetaObject.indexOfMetho
+ template<class Receiver>
+ class SignalHandler : public QObject
+ {
++    Q_DISABLE_COPY(SignalHandler)
+ public:
+     SignalHandler(Receiver *receiver, QObject *parent = 0);
+ 
+@@ -268,6 +270,7 @@ int SignalHandler<Receiver>::qt_metacall(QMetaObject::Call call, int methodId, v
+     if (call == QMetaObject::InvokeMetaMethod) {
+         const QObject *object = sender();
+         Q_ASSERT(object);
++        Q_ASSERT(QThread::currentThread() == object->thread());
+         Q_ASSERT(senderSignalIndex() == methodId);
+         Q_ASSERT(m_connectionsCounter.contains(object));
+         Q_ASSERT(m_connectionsCounter.value(object).contains(methodId));
+diff --git a/qtwebchannel/tests/auto/qml/testwebchannel.cpp b/qtwebchannel/tests/auto/qml/testwebchannel.cpp
+index 9891687..3ca81c2 100644
+--- a/qtwebchannel/tests/auto/qml/testwebchannel.cpp
++++ b/qtwebchannel/tests/auto/qml/testwebchannel.cpp
+@@ -46,7 +46,11 @@ TestWebChannel::~TestWebChannel()
+ 
+ bool TestWebChannel::clientIsIdle() const
+ {
+-    return QWebChannel::d_func()->publisher->clientIsIdle;
++    for (auto *transport : QWebChannel::d_func()->transports) {
++        if (QWebChannel::d_func()->publisher->isClientIdle(transport))
++            return true;
++    }
++    return false;
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp b/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
+index 181da9e..37f989a 100644
+--- a/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
++++ b/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
+@@ -785,7 +785,7 @@ void TestWebChannel::testTransportWrapObjectProperties()
+     DummyTransport *dummyTransport = new DummyTransport(this);
+     channel.connectTo(dummyTransport);
+     channel.d_func()->publisher->initializeClient(dummyTransport);
+-    channel.d_func()->publisher->setClientIsIdle(true);
++    channel.d_func()->publisher->setClientIsIdle(true, dummyTransport);
+ 
+     QCOMPARE(channel.d_func()->publisher->transportedWrappedObjects.size(), 0);
+ 
+@@ -943,8 +943,6 @@ void TestWebChannel::testInfiniteRecursion()
+ 
+ void TestWebChannel::testAsyncObject()
+ {
+-    QSKIP("This test is broken. See QTBUG-80729");
+-
+     QWebChannel channel;
+     channel.connectTo(m_dummyTransport);
+ 
+@@ -990,6 +988,50 @@ void TestWebChannel::testAsyncObject()
+     thread.wait();
+ }
+ 
++void TestWebChannel::testPropertyMultipleTransports()
++{
++    DummyTransport transport1;
++    DummyTransport transport2;
++
++    QWebChannel channel;
++    QMetaObjectPublisher *publisher = channel.d_func()->publisher;
++
++    TestObject testObj;
++    testObj.setObjectName("testObject");
++    channel.registerObject(testObj.objectName(), &testObj);
++    channel.connectTo(&transport1);
++    channel.connectTo(&transport2);
++
++    testObj.setProp("Hello");
++
++    publisher->initializeClient(&transport1);
++    publisher->initializeClient(&transport2);
++    publisher->setClientIsIdle(true, &transport1);
++    QCOMPARE(publisher->isClientIdle(&transport1), true);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++    QVERIFY(transport1.messagesSent().isEmpty());
++    QVERIFY(transport2.messagesSent().isEmpty());
++
++    testObj.setProp("World");
++    QTRY_COMPARE_WITH_TIMEOUT(transport1.messagesSent().size(), 1u, 2000);
++    QCOMPARE(transport2.messagesSent().size(), 0u);
++    publisher->setClientIsIdle(true, &transport2);
++    QTRY_COMPARE_WITH_TIMEOUT(transport2.messagesSent().size(), 1u, 2000);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++
++    testObj.setProp("!!!");
++    publisher->setClientIsIdle(true, &transport2);
++    QCOMPARE(publisher->isClientIdle(&transport2), true);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QTRY_COMPARE_WITH_TIMEOUT(transport2.messagesSent().size(), 2u, 2000);
++    QCOMPARE(transport1.messagesSent().size(), 1u);
++    publisher->setClientIsIdle(true, &transport1);
++    QTRY_COMPARE_WITH_TIMEOUT(transport1.messagesSent().size(), 2u, 2000);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++}
++
+ class FunctionWrapper : public QObject
+ {
+     Q_OBJECT
+@@ -1082,7 +1124,7 @@ void TestWebChannel::benchInitializeClients()
+ 
+         publisher->propertyUpdatesInitialized = false;
+         publisher->signalToPropertyMap.clear();
+-        publisher->signalHandler.clear();
++        publisher->signalHandlers.clear();
+     }
+ }
+ 
+@@ -1107,7 +1149,7 @@ void TestWebChannel::benchPropertyUpdates()
+             obj->change();
+         }
+ 
+-        channel.d_func()->publisher->clientIsIdle = true;
++        channel.d_func()->publisher->setClientIsIdle(true, m_dummyTransport);
+         channel.d_func()->publisher->sendPendingPropertyUpdates();
+     }
+ }
+diff --git a/qtwebchannel/tests/auto/webchannel/tst_webchannel.h b/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
+index eae21f4..dd4e690 100644
+--- a/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
++++ b/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
+@@ -348,6 +348,7 @@ private slots:
+     void testJsonToVariant();
+     void testInfiniteRecursion();
+     void testAsyncObject();
++    void testPropertyMultipleTransports();
+     void testDeletionDuringMethodInvocation_data();
+     void testDeletionDuringMethodInvocation();
+ 
+Submodule qtwebengine f328054d...38e0df6c (commits not present)
+Submodule qtwebsockets 65850954..63fb8da1:
+diff --git a/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp b/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
+index 2affdd5..95f1194 100644
+--- a/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
++++ b/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
+@@ -273,6 +273,7 @@ void QWebSocketDataProcessor::clear()
+     if (!m_pConverterState)
+         m_pConverterState = new QTextCodec::ConverterState(QTextCodec::ConvertInvalidToNull |
+                                                            QTextCodec::IgnoreHeader);
++    frame.clear();
+ }
+ 
+ /*!
+diff --git a/qtwebsockets/src/websockets/qwebsocketprotocol.cpp b/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
+index df87a93..d0465f1 100644
+--- a/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
++++ b/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
+@@ -210,7 +210,7 @@ void QWebSocketProtocol::mask(char *payload, quint64 size, quint32 maskingKey)
+                             quint8((maskingKey & 0x0000FF00u) >> 8),
+                             quint8((maskingKey & 0x000000FFu))
+                           };
+-    int i = 0;
++    quint64 i = 0;
+     while (size-- > 0)
+         *payload++ ^= mask[i++ % 4];
+ }
diff --git a/srcpkgs/qt5/template b/srcpkgs/qt5/template
index b6612dffeb1b9..a0d3036af79a4 100644
--- a/srcpkgs/qt5/template
+++ b/srcpkgs/qt5/template
@@ -2,11 +2,11 @@
 #
 # revbump libqtxdg after bumping patch version
 pkgname=qt5
-version=5.15.7+20221119
+version=5.15.8
+revision=1
+build_style=meta
 # commit f8c9fb304bc3e53b3aa07f962cd74e9160decccc
 # base repo: https://invent.kde.org/qt/qt/qt5
-revision=7
-build_style=meta
 hostmakedepends="cmake clang flex perl glib-devel pkg-config
  python3 re2c ruby which"
 makedepends="SDL2-devel Vulkan-Headers alsa-lib-devel double-conversion-devel
@@ -29,9 +29,9 @@ homepage="https://qt.io/"
 # tarball is generated with `git archive-all qt5-$version.tar.gz`
 # to keep the size smaller qtwebengine, qtwebview, qtdocgallery, qtactiveqt and qtpim
 # can be marked with the export-ignore attribute
-distfiles="https://void.johnnynator.dev/distfiles/qt5-${version}.tar.gz"
-checksum=9d57af471c78029a362276b7c99108ea009f511bb9ba6ff6cb884f6ddd255e9f
-python_version=3
+distfiles="https://download.qt.io/archive/qt/5.15/${version}/single/qt-everywhere-opensource-src-${version}.tar.xz"
+checksum=776a9302c336671f9406a53bd30b8e36f825742b2ec44a57c08217bff0fa86b9
+python_version=2 #unverified
 replaces="qt5-doc<5.6.0 qt5-quick1<5.6.0 qt5-quick1-devel<5.6.0 qt5-webkit<5.6.0 qt5-webkit-devel<5.6.0
  qt5-enginio<5.7.1 qt5-enginio-devel<5.7.1 qt5-plugin-gtk<5.7.1 qt5-canvas3d<5.13.0"
 lib32mode=full
@@ -246,7 +246,6 @@ do_configure() {
 	# opts+=" -v"
 	opts+=" -skip qtwebengine"
 	opts+=" -skip qtwebview"
-	opts+=" -skip qtdocgallery"
 	opts+=" -skip qtpim"
 	opts+=" -skip qtsystems"
 	opts+=" -skip qtspeech"

From a6bee5ab2de287207793e827d6726231e2d3e0fc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 068/115] qtav: revbump for ffmpeg4-4.4.3

---
 srcpkgs/qtav/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtav/template b/srcpkgs/qtav/template
index 34c30b2c0c78f..2d00ad104355e 100644
--- a/srcpkgs/qtav/template
+++ b/srcpkgs/qtav/template
@@ -1,10 +1,10 @@
 # Template file for 'qtav'
 pkgname=qtav
 version=1.13.0
-revision=1
+revision=2
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel libass-devel libopenal-devel
+makedepends="ffmpeg4-devel libass-devel libopenal-devel
  libva-glx-devel libXv-devel pulseaudio-devel
  qt5-declarative-devel qt5-svg-devel
  qt5-quickcontrols"

From 7bd46ddf947542f88c7ac9495cff64e708400d00 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 069/115] qtox: revbump for ffmpeg-6.0

---
 srcpkgs/qtox/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qtox/template b/srcpkgs/qtox/template
index 39c643fecdb5a..bb70e7f51240a 100644
--- a/srcpkgs/qtox/template
+++ b/srcpkgs/qtox/template
@@ -1,7 +1,7 @@
 # Template file for 'qtox'
 pkgname=qtox
 version=1.17.6
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DUPDATE_CHECK=OFF
  -DGIT_DESCRIBE=${version}

From 0c832c776c672ac9a2643c5079b20c3d3e57fcf5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 070/115] retroarch: revbump for ffmpeg-6.0

---
 srcpkgs/retroarch/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroarch/template b/srcpkgs/retroarch/template
index 87e621d49ce65..895c4d739380c 100644
--- a/srcpkgs/retroarch/template
+++ b/srcpkgs/retroarch/template
@@ -1,7 +1,7 @@
 # Template file for 'retroarch'
 pkgname=retroarch
 version=1.16.0.3
-revision=1
+revision=2
 build_style=configure
 configure_args="--prefix=/usr --sysconfdir=/etc --enable-networking
  --enable-udev --disable-builtinflac --disable-builtinglslang

From fc6fffd7f97bf04331c1b82208386e95b35886f3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 071/115] scrcpy: revbump for ffmpeg-6.0

---
 srcpkgs/scrcpy/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/scrcpy/template b/srcpkgs/scrcpy/template
index ac18bc03418ce..f39a7f678ab35 100644
--- a/srcpkgs/scrcpy/template
+++ b/srcpkgs/scrcpy/template
@@ -1,7 +1,7 @@
 # Template file for 'scrcpy'
 pkgname=scrcpy
 version=2.1.1
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcompile_server=false
  -Dprebuilt_server=/usr/share/scrcpy/scrcpy-server-v${version}"

From 4b15b8a67f257f845a37b80ba8e1e07f1f19f801 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 17 Oct 2023 08:54:11 -0400
Subject: [PATCH 072/115] New package: spex-x replaces spek-alternative for
 ffmpeg-6.0

---
 srcpkgs/spek-alternative                      |  1 +
 srcpkgs/{spek-alternative => spek-x}/template | 22 ++++++++++++-------
 2 files changed, 15 insertions(+), 8 deletions(-)
 create mode 120000 srcpkgs/spek-alternative
 rename srcpkgs/{spek-alternative => spek-x}/template (52%)

diff --git a/srcpkgs/spek-alternative b/srcpkgs/spek-alternative
new file mode 120000
index 0000000000000..76648236da701
--- /dev/null
+++ b/srcpkgs/spek-alternative
@@ -0,0 +1 @@
+spek-x
\ No newline at end of file
diff --git a/srcpkgs/spek-alternative/template b/srcpkgs/spek-x/template
similarity index 52%
rename from srcpkgs/spek-alternative/template
rename to srcpkgs/spek-x/template
index d7b55c776b1d4..3ded6c2c323e4 100644
--- a/srcpkgs/spek-alternative/template
+++ b/srcpkgs/spek-x/template
@@ -1,18 +1,18 @@
-# Template file for 'spek-alternative'
-pkgname=spek-alternative
-version=0.8.2.3
-revision=2
+# Template file for 'spek-x'
+pkgname=spek-x
+version=0.9.3
+revision=1
 build_style=gnu-configure
 hostmakedepends="automake gettext-devel intltool libtool pkg-config
  wxWidgets-common wxWidgets-gtk3-devel"
 makedepends="ffmpeg-devel wxWidgets-gtk3-devel"
 depends="ffmpeg"
 short_desc="Acoustic spectrum analyser"
-maintainer="Kartik Singh <kartik.ynwa@gmail.com>"
+maintainer="zlice <zlice555@gmail.com>"
 license="GPL-3.0-or-later"
-homepage="https://github.com/withmorten/spek-alternative"
-distfiles="https://github.com/withmorten/spek-alternative/archive/${version}.tar.gz"
-checksum="007ba4b84a310b078e378aa84c8e80783db5821437a757a488c3ecec377e6b2a"
+homepage="https://github.com/MikeWang000000/spek-x"
+distfiles="https://github.com/MikeWang000000/spek-x/archive/v${version}.tar.gz"
+checksum="7f4b109903333cdd310ab2b9176f0dc49a565891376e281a233d342cedf90ef7"
 
 CXXFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
 
@@ -22,3 +22,9 @@ export WX_CONFIG_NAME="wx-config-gtk3"
 pre_configure() {
 	NOCONFIGURE=1 ./autogen.sh
 }
+
+spek-alternative_package() {
+	depends="spek-x"
+	short_desc+=" - transitional dummy package"
+	build_style=meta
+}

From 7c82697772a4b0880f5c6aa30278139cde819c18 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 073/115] ssr: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ssr/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/ssr/template b/srcpkgs/ssr/template
index b055b9ec0774a..3448ca110eb0c 100644
--- a/srcpkgs/ssr/template
+++ b/srcpkgs/ssr/template
@@ -1,11 +1,11 @@
 # Template file for 'ssr'
 pkgname=ssr
 version=0.4.4
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_QT5=ON"
 hostmakedepends="pkg-config"
-makedepends="alsa-lib-devel ffmpeg-devel glu-devel jack-devel pulseaudio-devel
+makedepends="alsa-lib-devel ffmpeg4-devel glu-devel jack-devel pulseaudio-devel
  qt5-tools-devel qt5-x11extras-devel libXinerama-devel v4l-utils-devel"
 depends="desktop-file-utils hicolor-icon-theme"
 short_desc="Simple Screen Recorder for programs and games"

From 2797d5138b018e61cedea761ad232b71f1bcade3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 074/115] synfig: revbump for ffmpeg-6.0 and mlt7

---
 srcpkgs/synfig/patches/ffmpeg6.patch | 71 ++++++++++++++++++++++++++++
 srcpkgs/synfig/template              |  4 +-
 2 files changed, 73 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/synfig/patches/ffmpeg6.patch

diff --git a/srcpkgs/synfig/patches/ffmpeg6.patch b/srcpkgs/synfig/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..10780b42782f4
--- /dev/null
+++ b/srcpkgs/synfig/patches/ffmpeg6.patch
@@ -0,0 +1,71 @@
+--- a/src/modules/mod_libavcodec/trgt_av.cpp	2022-10-25 09:14:12.000000000 -0400
++++ b/src/modules/mod_libavcodec/trgt_av.cpp	2023-05-05 21:34:17.899194559 -0400
+@@ -38,6 +41,7 @@
+ extern "C"
+ {
+ #ifdef HAVE_LIBAVFORMAT_AVFORMAT_H
++#	include <libavcodec/avcodec.h>
+ #	include <libavformat/avformat.h>
+ #elif defined(HAVE_AVFORMAT_H)
+ #	include <avformat.h>
+@@ -155,11 +156,11 @@
+     }
+ 
+ 	bool open_video_stream() {
+-		if (avcodec_open2(video_context, NULL, NULL) < 0) {
++		if (avcodec_open2(video_context, nullptr, nullptr) < 0) {
+ 			synfig::error("Target_LibAVCodec: could not open video codec");
+ 			// seems the calling of avcodec_free_context after error will cause crash
+ 			// so just forget about this context
+-			video_context = NULL;
++			video_context = nullptr;
+ 			close();
+ 			return false;
+         }
+@@ -234,15 +235,21 @@
+ 		close();
+ 
+ 		if (!av_registered) {
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 			av_register_all();
++#endif
+ 			av_registered = true;
+ 		}
+ 
+ 		// guess format
+-		AVOutputFormat *format = av_guess_format(NULL, filename.c_str(), NULL);
++#if LIBAVCODEC_VERSION_MAJOR < 59 // FFMPEG < 5.0
++		AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#else
++		const AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#endif
+ 		if (!format) {
+ 			synfig::warning("Target_LibAVCodec: unable to guess the output format, defaulting to MPEG");
+-			format = av_guess_format("mpeg", NULL, NULL);
++			format = av_guess_format("mpeg", nullptr, nullptr);
+ 		}
+ 		if (!format) {
+ 			synfig::error("Target_LibAVCodec: unable to find 'mpeg' output format");
+@@ -254,6 +261,7 @@
+ 		context = avformat_alloc_context();
+ 		assert(context);
+ 		context->oformat = format;
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 		if (filename.size() + 1 > sizeof(context->filename)) {
+ 			synfig::error(
+ 				"Target_LibAVCodec: filename too long, max length is %d, filename is '%s'",
+@@ -263,6 +271,14 @@
+ 			return false;
+ 		}
+ 		memcpy(context->filename, filename.c_str(), filename.size() + 1);
++#else
++		context->url = av_strndup(filename.c_str(), filename.size());
++		if (!context->url) {
++			synfig::error("Target_LibAVCodec: cannot allocate space for filename");
++			close();
++			return false;
++		}
++#endif
+ 
+ 		packet = av_packet_alloc();
+ 		assert(packet);
diff --git a/srcpkgs/synfig/template b/srcpkgs/synfig/template
index d4d3e341a20bf..703cfd7ebac84 100644
--- a/srcpkgs/synfig/template
+++ b/srcpkgs/synfig/template
@@ -6,7 +6,7 @@ revision=4
 build_style=gnu-configure
 configure_args="--with-boost-libdir=${XBPS_CROSS_BASE}/usr/lib"
 hostmakedepends="boost-build ImageMagick pkg-config intltool"
-makedepends="ETL gettext-devel libxml++-devel mlt-devel libmagick-devel
+makedepends="ETL gettext-devel libxml++-devel mlt7-devel libmagick-devel
  libmng-devel boost-build boost-devel libopenexr-devel ffmpeg-devel"
 depends="ImageMagick"
 short_desc="CLI 2D vector and timeline-based animation software"
@@ -20,7 +20,7 @@ CXXFLAGS="-std=c++11 -DHAVE_LOCALE_H=1"
 
 synfig-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision}
-	 libopenexr-devel libxml++-devel mlt-devel"
+	 libopenexr-devel libxml++-devel mlt7-devel"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/bin/synfig-config

From b00e71bea45aca61ca4548acb5d1f625d76ed8c2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 075/115] timg: revbump for ffmpeg-6.0

---
 srcpkgs/timg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/timg/template b/srcpkgs/timg/template
index 2a2ab763d2fdd..8fb4327535ef9 100644
--- a/srcpkgs/timg/template
+++ b/srcpkgs/timg/template
@@ -1,7 +1,7 @@
 # Template file for 'timg'
 pkgname=timg
 version=1.4.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_OPENSLIDE_SUPPORT=off -Wno-dev"
 hostmakedepends="pkg-config git"

From 894e64f724623a42be1770fa7e2da9f71398afc1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 076/115] tvheadend: revbump for ffmpeg4-4.4.3

---
 srcpkgs/tvheadend/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tvheadend/template b/srcpkgs/tvheadend/template
index 9aea7de4ec705..012d31c4879ff 100644
--- a/srcpkgs/tvheadend/template
+++ b/srcpkgs/tvheadend/template
@@ -8,7 +8,7 @@ configure_args="--enable-dvbscan --disable-ffmpeg_static
 --disable-libx265_static --disable-libvpx_static --disable-libtheora_static
 --disable-libvorbis_static --disable-libfdkaac_static"
 hostmakedepends="gettext pkg-config python3 git which"
-makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg-devel"
+makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg4-devel"
 short_desc="TV streaming server"
 maintainer="lemmi <lemmi@nerd2nerd.org>"
 license="GPL-3.0-only"

From 7f5ff06b18e9e13a9932888a32c26da30df29306 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 077/115] unpaper: update to 7.0.0.

---
 srcpkgs/unpaper/template | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/srcpkgs/unpaper/template b/srcpkgs/unpaper/template
index 38ed47a584016..1ff910e722afc 100644
--- a/srcpkgs/unpaper/template
+++ b/srcpkgs/unpaper/template
@@ -1,13 +1,13 @@
 # Template file for 'unpaper'
 pkgname=unpaper
-version=6.1
-revision=3
-build_style=gnu-configure
+version=7.0.0
+revision=1
+build_style=meson
+hostmakedepends="pkg-config meson libxslt"
+makedepends="ffmpeg-devel python3-Sphinx"
+short_desc="Post-processing tool for scanned sheets of paper"
 maintainer="Orphaned <orphan@voidlinux.org>"
-hostmakedepends="pkg-config libxslt"
-makedepends="ffmpeg-devel"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://www.flameeyes.eu/projects/unpaper"
-short_desc="A post-processing tool for scanned sheets of paper"
 distfiles="https://www.flameeyes.eu/files/${pkgname}-${version}.tar.xz"
-checksum=237c84f5da544b3f7709827f9f12c37c346cdf029b1128fb4633f9bafa5cb930
+checksum=2575fbbf26c22719d1cb882b59602c9900c7f747118ac130883f63419be46a80

From 9994ec032d670d6cb71e00db2b3b159ee11a8696 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 078/115] vba-m: revbump for ffmpeg-6.0

---
 srcpkgs/vba-m/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vba-m/template b/srcpkgs/vba-m/template
index 9c71cefe3f8dd..2223d297c31f5 100644
--- a/srcpkgs/vba-m/template
+++ b/srcpkgs/vba-m/template
@@ -2,7 +2,7 @@
 pkgname=vba-m
 reverts=1292_2
 version=2.1.7
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DENABLE_GTK=TRUE -DENABLE_FFMPEG=TRUE -DENABLE_LINK=TRUE -DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="gettext pkg-config unzip zip yasm wxWidgets-gtk3-devel"

From dc0d760f47bc6d461e157531036a98cb13822b45 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 079/115] vice: revbump for ffmpeg4-4.4.3

---
 srcpkgs/vice/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/vice/template b/srcpkgs/vice/template
index fe9d33a811947..4beab2c5f9ebd 100644
--- a/srcpkgs/vice/template
+++ b/srcpkgs/vice/template
@@ -1,7 +1,7 @@
 # Template file for 'vice'
 pkgname=vice
 version=3.7.1
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="
 	$(vopt_enable sdl2 sdlui2)
@@ -26,7 +26,7 @@ makedepends="
 	$(vopt_if gtk3 gtk+3-devel)
 	$(vopt_if gtk3 pulseaudio-devel)
 	$(vopt_if gtk3 pango-devel)
-	$(vopt_if ffmpeg ffmpeg-devel)"
+	$(vopt_if ffmpeg ffmpeg4-devel)"
 short_desc="Emulator for C64, C128, CBM-II, PET, VIC20, Plus4 and C16"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"

From a9c9bdfcc91bbaacd41f23693fac83c90ded3916 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 080/115] waypipe: revbump for ffmpeg-6.0

---
 srcpkgs/waypipe/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waypipe/template b/srcpkgs/waypipe/template
index 6da88b21bf2a1..4da8058400b58 100644
--- a/srcpkgs/waypipe/template
+++ b/srcpkgs/waypipe/template
@@ -1,7 +1,7 @@
 # Template file for 'waypipe'
 pkgname=waypipe
 version=0.8.6
-revision=1
+revision=2
 build_style=meson
 # lto is off because it causes linking errors in armv6l and armv7l (due to NEON)
 configure_args="-Dwerror=false -Dwith_dmabuf=enabled -Dwith_lz4=enabled

From abb6f6faba72edcb8ea468cbbc45cf4a1b54fcfb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 081/115] wf-recorder: revbump for ffmpeg-6.0

---
 srcpkgs/wf-recorder/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/wf-recorder/template b/srcpkgs/wf-recorder/template
index cdf8d26dcb8e1..08f986b031006 100644
--- a/srcpkgs/wf-recorder/template
+++ b/srcpkgs/wf-recorder/template
@@ -1,7 +1,7 @@
 # Template file for 'wf-recorder'
 pkgname=wf-recorder
 version=0.4.1
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config scdoc wayland-devel"
 makedepends="wayland-protocols wayland-devel ffmpeg-devel libgbm-devel x264-devel

From 7621fdc8e9bff0e12465cfe8cb9dac299fb4ba3a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 082/115] xpra: revbump for ffmpeg-6.0

---
 srcpkgs/xpra/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xpra/template b/srcpkgs/xpra/template
index 394718b56f686..34fbff9b2f1ae 100644
--- a/srcpkgs/xpra/template
+++ b/srcpkgs/xpra/template
@@ -1,7 +1,7 @@
 # Template file for 'xpra'
 pkgname=xpra
 version=5.0.3
-revision=1
+revision=2
 build_style=python3-module
 make_build_args="--without-cuda_kernels --without-cuda_rebuild"
 make_install_args="$(vopt_with docs) ${make_build_args}"

From c738b7e976c736a5a87e246a64eb5a6ba526c853 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:07:40 -0400
Subject: [PATCH 083/115] nv-codec-headers: update to 12.0.16.0

---
 srcpkgs/nv-codec-headers/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/nv-codec-headers/template b/srcpkgs/nv-codec-headers/template
index 3d422a61e4891..251e057f826fb 100644
--- a/srcpkgs/nv-codec-headers/template
+++ b/srcpkgs/nv-codec-headers/template
@@ -1,6 +1,6 @@
 # Template file for 'nv-codec-headers'
 pkgname=nv-codec-headers
-version=11.1.5.1
+version=12.0.16.0
 revision=1
 build_style=gnu-makefile
 short_desc="FFmpeg version of headers required to interface with Nvidias codec APIs"
@@ -8,7 +8,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="MIT"
 homepage="http://git.videolan.org/?p=ffmpeg/nv-codec-headers.git"
 distfiles="https://github.com/FFmpeg/nv-codec-headers/archive/n${version}.tar.gz"
-checksum=d095fbd56aa93772471a323be0ebe65504a0f43f06c76a30b6d25da77b06ae9c
+checksum=2a1533b65f55f9da52956faf0627ed3b74868ac0c7f269990edd21369113b48f
 
 post_install() {
 	sed -n '4,25p' include/ffnvcodec/nvEncodeAPI.h > LICENSE

From 0e88301b47af9a48c0c9c95e1daccbfaa67bf7f7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:08:40 -0400
Subject: [PATCH 084/115] openimagedenoise: revbump for ffmpeg-6.0

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index b792813dba7c2..109deb171c3f7 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,7 +1,7 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
 version=1.4.3
-revision=1
+revision=2
 archs="x86_64*"
 build_style=cmake
 hostmakedepends="ispc python3"

From 520d83e175addeaee6c9862932367aaaa50aa00e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:31:45 -0400
Subject: [PATCH 085/115] shotcut: revbump for ffmpeg-6.0

---
 srcpkgs/shotcut/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/shotcut/template b/srcpkgs/shotcut/template
index 33141fbd862d7..f46cb53b6bfb9 100644
--- a/srcpkgs/shotcut/template
+++ b/srcpkgs/shotcut/template
@@ -1,7 +1,7 @@
 # Template file for 'shotcut'
 pkgname=shotcut
 version=23.09.29
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSHOTCUT_VERSION=${version}"
 hostmakedepends="pkg-config qt6-tools-devel"

From b793cda9adedc840aeea5b60f9d415f54769ef39 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:30 -0400
Subject: [PATCH 086/115] shiboken2: revbump for qt5-5.15.8

---
 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch | 1 +
 srcpkgs/shiboken2/template                                 | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
 create mode 120000 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
new file mode 120000
index 0000000000000..efcf3249bd885
--- /dev/null
+++ b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1 @@
+../../python3-pyside2/patches/importlib-machinery-bypass.patch
\ No newline at end of file
diff --git a/srcpkgs/shiboken2/template b/srcpkgs/shiboken2/template
index 883d6a084d868..f3c06ec245a1f 100644
--- a/srcpkgs/shiboken2/template
+++ b/srcpkgs/shiboken2/template
@@ -1,7 +1,7 @@
 # Template file for 'shiboken2'
 pkgname=shiboken2
 version=5.15.10
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/shiboken2"
 build_style=cmake

From d829089c65fe6e0208709e21b66e430874381d42 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:53 -0400
Subject: [PATCH 087/115] python3-pyside2: revbump for qt5-5.15.8

---
 .../patches/importlib-machinery-bypass.patch      | 15 +++++++++++++++
 srcpkgs/python3-pyside2/template                  |  2 +-
 2 files changed, 16 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
new file mode 100644
index 0000000000000..64c429584776b
--- /dev/null
+++ b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1,15 @@
+Using this prevents an error around line 220 below it.
+"AttributeError: module 'importlib' has no attribute 'machinery'"
+The old backup logic is in place and compiles without issues.
+--- a/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:09:34.688912402 -0400
++++ b/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:10:03.395529582 -0400
+@@ -170,9 +170,6 @@
+
+     # 'zipstring_sequence' comes from signature.cpp
+     zipbytes = base64.b64decode(''.join(zipstring_sequence))
+-    if sys.version_info[0] >= 3:
+-        vzip = zipfile.ZipFile(io.BytesIO(zipbytes))
+-        return sys.meta_path, EmbeddableZipImporter(vzip)
+
+     # Old version for Python 2.7, only.
+     import os
diff --git a/srcpkgs/python3-pyside2/template b/srcpkgs/python3-pyside2/template
index 249efa9098842..52626436ce75f 100644
--- a/srcpkgs/python3-pyside2/template
+++ b/srcpkgs/python3-pyside2/template
@@ -1,7 +1,7 @@
 # Template file for 'python3-pyside2'
 pkgname=python3-pyside2
 version=5.15.10
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/pyside2"
 build_style=cmake

From 6255786530185eb092bc51b8b9d1ec42e6ad3b83 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:35 -0400
Subject: [PATCH 088/115] konqueror: revbump for ffmpeg-6.0

---
 srcpkgs/konqueror/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/konqueror/template b/srcpkgs/konqueror/template
index abfa59e6b7ded..3cc29c12dc1db 100644
--- a/srcpkgs/konqueror/template
+++ b/srcpkgs/konqueror/template
@@ -1,11 +1,11 @@
 # Template file for 'konqueror'
 pkgname=konqueror
 version=23.08.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DDESKTOPTOJSON_EXECUTABLE=/usr/bin/desktoptojson"
 hostmakedepends="extra-cmake-modules python3 qt5-host-tools qt5-qmake kdoctools
-kcoreaddons kconfig gettext"
+ kcoreaddons kconfig gettext"
 makedepends="qt5-devel qt5-webengine-devel qt5-declarative-devel
  qt5-webchannel-devel qt5-location-devel kcmutils-devel kdelibs4support-devel
  karchive-devel khtml-devel kdesu-devel kactivities5-devel"

From 0de0a50798c6bac4f4f117b0a5cae26722f1f532 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:58 -0400
Subject: [PATCH 089/115] qt5-speech: revbump for qt5-5.15.8

---
 srcpkgs/qt5-speech/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-speech/template b/srcpkgs/qt5-speech/template
index 3ecd10d50650c..2d7d4d4d24535 100644
--- a/srcpkgs/qt5-speech/template
+++ b/srcpkgs/qt5-speech/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-speech'
 pkgname=qt5-speech
 version=5.15.7
-revision=2
+revision=3
 _commit=d32f4a479d38a11f547598004b975f4356424a16
 build_style=qmake
 configure_args="-- -flite -flite-alsa -speechd"

From 979f00ea44fed267bf9d82493c2b714a995551e5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 18:38:50 -0400
Subject: [PATCH 090/115] qt5-styleplugins: revbump for qt5-5.15.8

---
 srcpkgs/qt5-styleplugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-styleplugins/template b/srcpkgs/qt5-styleplugins/template
index 96ed97d12cd24..30d93660a2a4e 100644
--- a/srcpkgs/qt5-styleplugins/template
+++ b/srcpkgs/qt5-styleplugins/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-styleplugins'
 pkgname=qt5-styleplugins
 version=5.0.0
-revision=20
+revision=21
 _gitrev=335dbece103e2cbf6c7cf819ab6672c2956b17b3
 build_style=qmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From 28afb572f82195a7af787841fd7964a9fbbd46f3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 7 May 2023 20:15:03 -0400
Subject: [PATCH 091/115] qt6-webengine: revbump for ffmpeg-6.0

---
 srcpkgs/qt6-webengine/template | 1 +
 1 file changed, 1 insertion(+)

diff --git a/srcpkgs/qt6-webengine/template b/srcpkgs/qt6-webengine/template
index 98cdc680481b3..f33a71bd2a0dc 100644
--- a/srcpkgs/qt6-webengine/template
+++ b/srcpkgs/qt6-webengine/template
@@ -158,6 +158,7 @@ pre_install() {
 }
 
 post_install() {
+	vlicense LICENSES/BSD-3-Clause.txt
 	local _file
 	find "${DESTDIR}"/usr/lib/qt6/examples \
 		-path '*/lib/qt6/**/lib/qt6/*' -type f |

From 2b1d1bcf172f7202b43282da1111d6ff5c13e6d0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 21 May 2023 12:44:11 -0400
Subject: [PATCH 092/115] electron24: revbump for ffmpeg-6.0

---
 srcpkgs/electron24/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron24/template b/srcpkgs/electron24/template
index 59e078a7b47cb..a9c865c19c989 100644
--- a/srcpkgs/electron24/template
+++ b/srcpkgs/electron24/template
@@ -1,7 +1,7 @@
 # Template file for 'electron24'
 pkgname=electron24
 version=24.3.0
-revision=1
+revision=2
 _nodever=18.14.0
 _chromiumver=112.0.5615.165
 archs="x86_64* aarch64*"

From be13b9ef1925e77e324499791847135a839f8588 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Jun 2023 08:20:22 -0400
Subject: [PATCH 093/115] gtk4: revbump for ffmpeg-6.0

---
 srcpkgs/gtk4/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gtk4/template b/srcpkgs/gtk4/template
index 6a4e20357a86f..ec0c13d2cc5b0 100644
--- a/srcpkgs/gtk4/template
+++ b/srcpkgs/gtk4/template
@@ -1,7 +1,7 @@
 # Template file for 'gtk4'
 pkgname=gtk4
 version=4.12.3
-revision=1
+revision=2
 build_style=meson
 build_helper="gir"
 configure_args="-Dman-pages=true -Ddocumentation=true -Dbuild-tests=false

From 02a8af385727d24c2868ea2512de85798979a770 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:25:50 -0400
Subject: [PATCH 094/115] electron19: revbump for ffmpeg-6.0

---
 srcpkgs/electron19/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron19/template b/srcpkgs/electron19/template
index 4b40de20a3fe2..b18bc792c8221 100644
--- a/srcpkgs/electron19/template
+++ b/srcpkgs/electron19/template
@@ -1,7 +1,7 @@
 # Template file for 'electron19'
 pkgname=electron19
 version=19.0.8
-revision=3
+revision=4
 _nodever=16.14.2
 _chromiumver=102.0.5005.125
 archs="x86_64* aarch64* ppc64le*"

From 4ef03571b5c0756763eb78c8b932d9c2d8969d37 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:28:26 -0400
Subject: [PATCH 095/115] siril: revbump for ffmpeg-6.0

---
 srcpkgs/siril/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/siril/template b/srcpkgs/siril/template
index 84332f79d060d..62750dd247548 100644
--- a/srcpkgs/siril/template
+++ b/srcpkgs/siril/template
@@ -1,7 +1,7 @@
 # Template file for 'siril'
 pkgname=siril
 version=0.9.12
-revision=10
+revision=11
 build_style=gnu-configure
 hostmakedepends="pkg-config intltool autoconf automake gettext-devel"
 makedepends="fftw-devel libconfig-devel libopencv-devel libffms2-devel

From 803554875e2ef6e7bc7ca7446f948f8165454970 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 10 Jun 2023 00:57:09 -0400
Subject: [PATCH 096/115] qt6-multimedia: revbump for ffmpeg-6.0

---
 srcpkgs/qt6-multimedia/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-multimedia/template b/srcpkgs/qt6-multimedia/template
index ab112006b17e4..67a577e1300fe 100644
--- a/srcpkgs/qt6-multimedia/template
+++ b/srcpkgs/qt6-multimedia/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-multimedia'
 pkgname=qt6-multimedia
 version=6.6.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DQT_FEATURE_gstreamer=ON"
 hostmakedepends="perl qt6-declarative-host-tools pkg-config qt6-shadertools"

From 64c43ccdb18159071cd2d1bd311b191d316cffb5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 22 Jun 2023 10:25:02 -0400
Subject: [PATCH 097/115] kdenlive: revbump for ffmpeg-6.0

---
 srcpkgs/kdenlive/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kdenlive/template b/srcpkgs/kdenlive/template
index ec5fe75860948..e69ecff31f272 100644
--- a/srcpkgs/kdenlive/template
+++ b/srcpkgs/kdenlive/template
@@ -1,7 +1,7 @@
 # Template file for 'kdenlive'
 pkgname=kdenlive
 version=23.08.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="
  extra-cmake-modules kconfig kcoreaddons kdoctools pkg-config python3

From 2e0dea7354898df9452c2b0a20e7cadab1debda0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Jul 2023 11:17:37 -0400
Subject: [PATCH 098/115] DELETE: intel_packages

---
 common/shlibs                                 |   2 +
 srcpkgs/intel-gmmlib/template                 |   2 +-
 ...mmon-Enable-MMC-in-free-kernel-build.patch | 125 ++++++++++++++++++
 srcpkgs/intel-media-driver/template           |   6 +-
 srcpkgs/intel-media-sdk/patches/musl.patch    |  14 ++
 srcpkgs/intel-media-sdk/template              |  37 ++++++
 srcpkgs/intel-media-sdk/update                |   1 +
 srcpkgs/libmfx                                |   1 +
 srcpkgs/libmfx-devel                          |   1 +
 srcpkgs/onevpl-devel                          |   1 +
 srcpkgs/onevpl-intel-gpu-devel                |   1 +
 srcpkgs/onevpl-intel-gpu/template             |  27 ++++
 srcpkgs/onevpl/template                       |  34 +++++
 13 files changed, 248 insertions(+), 4 deletions(-)
 create mode 100644 srcpkgs/intel-media-driver/patches/0001-Media-Common-Enable-MMC-in-free-kernel-build.patch
 create mode 100644 srcpkgs/intel-media-sdk/patches/musl.patch
 create mode 100644 srcpkgs/intel-media-sdk/template
 create mode 100644 srcpkgs/intel-media-sdk/update
 create mode 120000 srcpkgs/libmfx
 create mode 120000 srcpkgs/libmfx-devel
 create mode 120000 srcpkgs/onevpl-devel
 create mode 120000 srcpkgs/onevpl-intel-gpu-devel
 create mode 100644 srcpkgs/onevpl-intel-gpu/template
 create mode 100644 srcpkgs/onevpl/template

diff --git a/common/shlibs b/common/shlibs
index fecac6eed2083..44d06d06c76e1 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4253,6 +4253,8 @@ libgsoapssl++-2.8.124.so gsoap-2.8.124_1
 libjxl.so.0.8 libjxl-0.8.2_1
 libjxl_dec.so.0.8 libjxl-0.8.2_1
 libjxl_threads.so.0.8 libjxl-0.8.2_1
+libmfx.so.1 libmfx-22.6.4_1
+libvpl.so.2 onevpl-2023.1.2_1
 libtext-engine-0.1.so.0 text-engine-0.1.1_1
 libvmaf.so.1 vmaf-2.3.1_1
 liblc3.so.1 liblc3-1.0.3_1
diff --git a/srcpkgs/intel-gmmlib/template b/srcpkgs/intel-gmmlib/template
index b9df642f6320f..3d64be7415298 100644
--- a/srcpkgs/intel-gmmlib/template
+++ b/srcpkgs/intel-gmmlib/template
@@ -14,7 +14,7 @@ build_style=cmake
 # compilers flag in use.
 configure_args="-Wno-dev"
 short_desc="Intel Graphics Memory Management Library"
-maintainer="Orphaned <orphan@voidlinux.org>"
+maintainer="Stefano Ragni <st3r4g@protonmail.com>"
 license="MIT"
 homepage="https://github.com/intel/gmmlib"
 distfiles="https://github.com/intel/gmmlib/archive/intel-gmmlib-${version}.tar.gz"
diff --git a/srcpkgs/intel-media-driver/patches/0001-Media-Common-Enable-MMC-in-free-kernel-build.patch b/srcpkgs/intel-media-driver/patches/0001-Media-Common-Enable-MMC-in-free-kernel-build.patch
new file mode 100644
index 0000000000000..525fb688722c8
--- /dev/null
+++ b/srcpkgs/intel-media-driver/patches/0001-Media-Common-Enable-MMC-in-free-kernel-build.patch
@@ -0,0 +1,125 @@
+From e68feab7db036838d9521ba3b9f00717c37c024c Mon Sep 17 00:00:00 2001
+From: JayYang <jay.yang@intel.com>
+Date: Tue, 21 Mar 2023 17:17:55 +0800
+Subject: [PATCH] [Media Common] Enable MMC in free kernel build
+
+Add mmc build definition in free kernel build
+---
+ media_driver/agnostic/gen9/codec/hal/media_srcs.cmake          | 2 +-
+ media_driver/cmake/linux/media_feature_flags_linux.cmake       | 3 +--
+ .../media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp        | 2 +-
+ .../media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp        | 2 +-
+ .../media_interfaces_m9_glk/media_interfaces_g9_glk.cpp        | 2 +-
+ .../media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp        | 2 +-
+ .../media_interfaces_m9_skl/media_interfaces_g9_skl.cpp        | 2 +-
+ 7 files changed, 7 insertions(+), 8 deletions(-)
+
+diff --git a/media_driver/agnostic/gen9/codec/hal/media_srcs.cmake b/media_driver/agnostic/gen9/codec/hal/media_srcs.cmake
+index 8bb36bafe..78902a22d 100644
+--- a/media_driver/agnostic/gen9/codec/hal/media_srcs.cmake
++++ b/media_driver/agnostic/gen9/codec/hal/media_srcs.cmake
+@@ -27,7 +27,7 @@ set(TMP_1_HEADERS_
+     ${CMAKE_CURRENT_LIST_DIR}/codechal_hw_g9_X.h
+ )
+ 
+-if(${MMC_Supported} STREQUAL "yes")
++if(${MMC_Supported} STREQUAL "yes" AND ENABLE_NONFREE_KERNELS AND ENABLE_KERNELS)
+     set(TMP_1_SOURCES_
+         ${TMP_1_SOURCES_}
+         ${CMAKE_CURRENT_LIST_DIR}/codechal_memdecomp_g9.cpp
+diff --git a/media_driver/cmake/linux/media_feature_flags_linux.cmake b/media_driver/cmake/linux/media_feature_flags_linux.cmake
+index de0ca853f..8121ea60c 100644
+--- a/media_driver/cmake/linux/media_feature_flags_linux.cmake
++++ b/media_driver/cmake/linux/media_feature_flags_linux.cmake
+@@ -35,7 +35,6 @@ if(NOT ENABLE_KERNELS OR NOT ENABLE_NONFREE_KERNELS)
+     bs_set_if_undefined(HEVC_Encode_VME_Supported "no")
+     bs_set_if_undefined(MPEG2_Encode_VME_Supported "no")
+     bs_set_if_undefined(CMRT_HEVC_ENC_FEI_Supported "no")
+-    bs_set_if_undefined(MMC_Supported "no")
+     bs_set_if_undefined(VC1_Decode_Supported "no")
+     bs_set_if_undefined(Decode_Processing_Supported "no")
+     bs_set_if_undefined(Kernel_Auto_Denoise_Supported "no")
+@@ -46,7 +45,6 @@ else()
+     bs_set_if_undefined(HEVC_Encode_VME_Supported "${Encode_VME_Supported}")
+     bs_set_if_undefined(MPEG2_Encode_VME_Supported "${Encode_VME_Supported}")
+     bs_set_if_undefined(CMRT_HEVC_ENC_FEI_Supported "yes")
+-    bs_set_if_undefined(MMC_Supported "yes")
+     bs_set_if_undefined(VC1_Decode_Supported "yes")
+     bs_set_if_undefined(Decode_Processing_Supported "yes")
+     bs_set_if_undefined(Kernel_Auto_Denoise_Supported "yes")
+@@ -64,6 +62,7 @@ bs_set_if_undefined(VP9_Decode_Supported "yes")
+ bs_set_if_undefined(VP_SFC_Supported "yes")
+ bs_set_if_undefined(Common_Encode_Supported "yes")
+ bs_set_if_undefined(Media_Scalability_Supported "yes")
++bs_set_if_undefined(MMC_Supported "yes")
+ 
+ # features controlled by global flag Encode_VDEnc_Supported
+ bs_set_if_undefined(AVC_Encode_VDEnc_Supported "${Encode_VDEnc_Supported}")
+diff --git a/media_driver/media_interface/media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp b/media_driver/media_interface/media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp
+index 3f306ee2a..8e4c0f532 100644
+--- a/media_driver/media_interface/media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp
+@@ -135,7 +135,7 @@ MOS_STATUS MhwInterfacesG9Bxt::Initialize(
+ 
+     return MOS_STATUS_SUCCESS;
+ }
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool bxtRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Bxt>((uint32_t)IGFX_BROXTON);
+diff --git a/media_driver/media_interface/media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp b/media_driver/media_interface/media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp
+index b8fa1eec0..84e0fad1d 100644
+--- a/media_driver/media_interface/media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp
+@@ -44,7 +44,7 @@ static bool cflRegisteredMhw =
+     MediaFactory<uint32_t, MhwInterfaces>::
+     Register<MhwInterfacesG9Kbl>((uint32_t)IGFX_COFFEELAKE);
+ 
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool cflRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Kbl>((uint32_t)IGFX_COFFEELAKE);
+diff --git a/media_driver/media_interface/media_interfaces_m9_glk/media_interfaces_g9_glk.cpp b/media_driver/media_interface/media_interfaces_m9_glk/media_interfaces_g9_glk.cpp
+index de81e6091..2638cb3a6 100644
+--- a/media_driver/media_interface/media_interfaces_m9_glk/media_interfaces_g9_glk.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_glk/media_interfaces_g9_glk.cpp
+@@ -65,7 +65,7 @@ static bool glkRegisteredMhw =
+     MediaFactory<uint32_t, MhwInterfaces>::
+     Register<MhwInterfacesG9Kbl>((uint32_t)IGFX_GEMINILAKE);
+ 
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool glkRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Kbl>((uint32_t)IGFX_GEMINILAKE);
+diff --git a/media_driver/media_interface/media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp b/media_driver/media_interface/media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp
+index 99d786185..4e9c6e7f1 100644
+--- a/media_driver/media_interface/media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp
+@@ -131,7 +131,7 @@ MOS_STATUS MhwInterfacesG9Kbl::Initialize(
+ 
+     return MOS_STATUS_SUCCESS;
+ }
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool kblRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Kbl>((uint32_t)IGFX_KABYLAKE);
+diff --git a/media_driver/media_interface/media_interfaces_m9_skl/media_interfaces_g9_skl.cpp b/media_driver/media_interface/media_interfaces_m9_skl/media_interfaces_g9_skl.cpp
+index e2520edf7..4b0012c64 100644
+--- a/media_driver/media_interface/media_interfaces_m9_skl/media_interfaces_g9_skl.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_skl/media_interfaces_g9_skl.cpp
+@@ -139,7 +139,7 @@ MOS_STATUS MhwInterfacesG9Skl::Initialize(
+ 
+     return MOS_STATUS_SUCCESS;
+ }
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool sklRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Skl>((uint32_t)IGFX_SKYLAKE);
+-- 
+2.40.0
+
diff --git a/srcpkgs/intel-media-driver/template b/srcpkgs/intel-media-driver/template
index 06b7c19a0ba07..1735b90c65ce5 100644
--- a/srcpkgs/intel-media-driver/template
+++ b/srcpkgs/intel-media-driver/template
@@ -1,6 +1,6 @@
 # Template file for 'intel-media-driver'
 pkgname=intel-media-driver
-version=23.3.5
+version=22.6.4
 revision=1
 archs="x86_64*"
 build_style=cmake
@@ -8,11 +8,11 @@ configure_args="-Wno-dev -DENABLE_NONFREE_KERNELS=$(vopt_if nonfree ON OFF)"
 hostmakedepends="pkg-config"
 makedepends="libva-devel libX11-devel intel-gmmlib-devel libpciaccess-devel"
 short_desc="Intel Media Driver for VAAPI (Broadwell+)"
-maintainer="Orphaned <orphan@voidlinux.org>"
+maintainer="Stefano Ragni <st3r4g@protonmail.com>"
 license="MIT, BSD-3-Clause"
 homepage="https://github.com/intel/media-driver"
 distfiles="https://github.com/intel/media-driver/archive/intel-media-${version}.tar.gz"
-checksum=67fd15654bb3c596feb8c85e81221de5632e11f598421c35adc4453d727f0130
+checksum=0c04b9d74b92de41fd409b62913ce4afd799236c0b6bc1983a496990764e5d90
 
 build_options="nonfree"
 desc_option_nonfree="Enable nonfree kernels"
diff --git a/srcpkgs/intel-media-sdk/patches/musl.patch b/srcpkgs/intel-media-sdk/patches/musl.patch
new file mode 100644
index 0000000000000..4ae70924b744f
--- /dev/null
+++ b/srcpkgs/intel-media-sdk/patches/musl.patch
@@ -0,0 +1,14 @@
+--- a/tools/tracer/tracer/tracer_linux.cpp	2022-11-18 03:02:59.000000000 -0500
++++ b/tools/tracer/tracer/tracer_linux.cpp	2022-12-18 01:44:51.341542572 -0500
+@@ -32,6 +32,11 @@
+ #include <dlfcn.h>
+ #include "tracer.h"
+
++#ifndef RTLD_DEEPBIND
++// musl neither defines nor can use RTLD_DEEPBIND
++#define RTLD_DEEPBIND 0
++#endif
++
+ #if defined(__i386__)
+     #define LIBMFXHW "libmfxhw32.so.1"
+ #elif defined(__x86_64__)
diff --git a/srcpkgs/intel-media-sdk/template b/srcpkgs/intel-media-sdk/template
new file mode 100644
index 0000000000000..7aeab51802f8e
--- /dev/null
+++ b/srcpkgs/intel-media-sdk/template
@@ -0,0 +1,37 @@
+# Template file for 'intel-media-sdk'
+pkgname=intel-media-sdk
+version=22.6.4
+revision=1
+archs="x86_64*"
+build_style=cmake
+configure_args="-Wno-dev -DBUILD_SAMPLES=OFF -DBUILD_TESTS=ON"
+hostmakedepends="pkg-config"
+makedepends="libva-devel libdrm-devel intel-gmmlib-devel"
+short_desc="Intel Media SDK"
+maintainer="Stefano Ragni <st3r4g@protonmail.com>"
+license="MIT, BSD-3-Clause"
+homepage="https://github.com/Intel-Media-SDK/MediaSDK"
+distfiles="https://github.com/Intel-Media-SDK/MediaSDK/archive/refs/tags/intel-mediasdk-${version}.tar.gz"
+checksum=197acd056f81e9ff1c27068d50e8c84c2014d94c7ac17cad69d5c2d61e445fd3
+
+post_install() {
+	vlicense LICENSE
+}
+
+libmfx_package() {
+	depends="${makedepends} ${sourcepkg}-${version}_${revision}"
+	short_desc="Intel MediaSDK mfx lib"
+	pkg_install() {
+		vmove usr/lib/mfx
+		vmove "usr/lib/libmfx*.so*"
+	}
+}
+
+libmfx-devel_package() {
+	depends="${makedepends} ${sourcepkg}-${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+	}
+}
diff --git a/srcpkgs/intel-media-sdk/update b/srcpkgs/intel-media-sdk/update
new file mode 100644
index 0000000000000..434a2bc67f7a1
--- /dev/null
+++ b/srcpkgs/intel-media-sdk/update
@@ -0,0 +1 @@
+pkgname=intel-media
diff --git a/srcpkgs/libmfx b/srcpkgs/libmfx
new file mode 120000
index 0000000000000..8ffc7099c2272
--- /dev/null
+++ b/srcpkgs/libmfx
@@ -0,0 +1 @@
+intel-media-sdk
\ No newline at end of file
diff --git a/srcpkgs/libmfx-devel b/srcpkgs/libmfx-devel
new file mode 120000
index 0000000000000..8ffc7099c2272
--- /dev/null
+++ b/srcpkgs/libmfx-devel
@@ -0,0 +1 @@
+intel-media-sdk
\ No newline at end of file
diff --git a/srcpkgs/onevpl-devel b/srcpkgs/onevpl-devel
new file mode 120000
index 0000000000000..e2306500b4871
--- /dev/null
+++ b/srcpkgs/onevpl-devel
@@ -0,0 +1 @@
+onevpl
\ No newline at end of file
diff --git a/srcpkgs/onevpl-intel-gpu-devel b/srcpkgs/onevpl-intel-gpu-devel
new file mode 120000
index 0000000000000..47920ceecf919
--- /dev/null
+++ b/srcpkgs/onevpl-intel-gpu-devel
@@ -0,0 +1 @@
+onevpl-intel-gpu
\ No newline at end of file
diff --git a/srcpkgs/onevpl-intel-gpu/template b/srcpkgs/onevpl-intel-gpu/template
new file mode 100644
index 0000000000000..f14acb728a54d
--- /dev/null
+++ b/srcpkgs/onevpl-intel-gpu/template
@@ -0,0 +1,27 @@
+# Template file for 'onevpl-intel-gpu'
+pkgname=onevpl-intel-gpu
+version=22.6.4
+revision=1
+archs="x86_64*"
+build_style=cmake
+configure_args="-Wno-dev -DCMAKE_BUILD_TYPE=Release"
+hostmakedepends="cmake pkg-config"
+makedepends="libdrm-devel libva-devel onevpl-devel"
+short_desc="Runtime implementation of oneVPL API for Intel Gen GPUs"
+maintainer="zlice <zlice555@gmail.com>"
+license="MIT"
+homepage="https://github.com/oneapi-src/oneVPL-intel-gpu"
+changelog="https://github.com/oneapi-src/oneVPL-intel-gpu/blob/main/CHANGELOG.md"
+distfiles="https://github.com/oneapi-src/oneVPL-intel-gpu/archive/refs/tags/intel-onevpl-${version}.tar.gz"
+checksum=74b0979dcb2af1b7c68edb8cbcb02d539de511090b12fac50652cbacd707c4e6
+
+post_install() {
+	vlicense LICENSE
+}
+
+onevpl-intel-gpu-devel_package() {
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/lib/pkgconfig
+	}
+}
diff --git a/srcpkgs/onevpl/template b/srcpkgs/onevpl/template
new file mode 100644
index 0000000000000..85c7c2da85ce9
--- /dev/null
+++ b/srcpkgs/onevpl/template
@@ -0,0 +1,34 @@
+# Template file for 'onevpl'
+pkgname=onevpl
+version=2023.1.2
+revision=1
+archs="x86_64*"
+build_style=cmake
+configure_args="
+	-DCMAKE_BUILD_TYPE=Release -Wno-dev
+	-DBUILD_PYTHON_BINDING:BOOL='OFF'
+	-DBUILD_EXAMPLES:BOOL='OFF'
+	-DBUILD_TESTS:BOOL='ON'
+	-DINSTALL_EXAMPLE_CODE:BOOL='OFF'"
+hostmakedepends="cmake libX11 python wayland-protocols pkg-config"
+makedepends="libva-devel libX11-devel wayland-devel"
+short_desc="Intel oneAPI Video Processing library"
+maintainer="zlice <zlice555@gmail.com>"
+license="MIT"
+homepage="https://www.intel.com/content/www/us/en/developer/tools/oneapi/onevpl.html"
+distfiles="https://github.com/oneapi-src/oneVPL/archive/v${version}/${pkgname}-${version}.tar.gz"
+checksum=b2261cca174ce1815f3d47c647921ab17f68267c69c1e2444ff27aab7d199cbb
+
+post_install() {
+	vlicense LICENSE
+}
+
+onevpl-devel_package() {
+	depends="${makedepends} ${sourcepkg}-${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.so"
+	}
+}

From 984ed7393882846faeb798e0955bcaca752ff9e3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:20:59 -0400
Subject: [PATCH 099/115] tracker-miners: revbump for ffmpeg-6.0

---
 srcpkgs/tracker-miners/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tracker-miners/template b/srcpkgs/tracker-miners/template
index 0b97f47489f81..f196d2bf9e4a4 100644
--- a/srcpkgs/tracker-miners/template
+++ b/srcpkgs/tracker-miners/template
@@ -1,7 +1,7 @@
 # Template file for 'tracker-miners'
 pkgname=tracker-miners
 version=3.6.1
-revision=1
+revision=2
 build_style=meson
 build_helper=qemu
 # missing libgrss for miner_rss

From d2811f1f07019d3c72d23c51895b400b5b5dc2b6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:21:21 -0400
Subject: [PATCH 100/115] mpd: revbump for ffmpeg-6.0

---
 srcpkgs/mpd/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpd/template b/srcpkgs/mpd/template
index abbeb423a1002..1bca2e877a380 100644
--- a/srcpkgs/mpd/template
+++ b/srcpkgs/mpd/template
@@ -1,7 +1,7 @@
 # Template file for 'mpd'
 pkgname=mpd
 version=0.23.14
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dopus=enabled -Dmikmod=enabled -Dneighbor=true
  -Dsoundcloud=enabled -Dpipe=true -Dtwolame=enabled -Dbzip2=enabled

From a67ee7b79fe5c834bd8099894fac50f0dd94a439 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 17 Jul 2023 15:37:44 -0400
Subject: [PATCH 101/115] mixxx: revbump for ffmpeg-6.0

---
 srcpkgs/mixxx/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mixxx/template b/srcpkgs/mixxx/template
index 23800676bfd09..6921996e4e77b 100644
--- a/srcpkgs/mixxx/template
+++ b/srcpkgs/mixxx/template
@@ -1,7 +1,7 @@
 # Template file for 'mixxx'
 pkgname=mixxx
 version=2.3.3
-revision=5
+revision=6
 build_style=cmake
 configure_args="-DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="extra-cmake-modules pkg-config protobuf qt5-host-tools qt5-qmake"

From 57359f775166e80f2ff2eb5a46f2adda82b7834b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:09:36 -0400
Subject: [PATCH 102/115] musikcube: revbump for ffmpeg-6.0

---
 srcpkgs/musikcube/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/musikcube/template b/srcpkgs/musikcube/template
index 1f78ada1451b6..d9e6186e6697b 100644
--- a/srcpkgs/musikcube/template
+++ b/srcpkgs/musikcube/template
@@ -1,7 +1,7 @@
 # Template file for 'musikcube'
 pkgname=musikcube
 version=3.0.0
-revision=2
+revision=3
 build_style=cmake
 make_cmd=make
 configure_args="-DNO_NCURSESW=1"

From cd6bd550ca02b8577c3e63bb3e41090696559dfb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:02 -0400
Subject: [PATCH 103/115] tg_owt: revbump for ffmpeg-6.0

---
 srcpkgs/tg_owt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tg_owt/template b/srcpkgs/tg_owt/template
index 50bc8310b8859..c93262d5c5de6 100644
--- a/srcpkgs/tg_owt/template
+++ b/srcpkgs/tg_owt/template
@@ -1,7 +1,7 @@
 # Template file for 'tg_owt'
 pkgname=tg_owt
 version=0.0.0.20230921
-revision=1
+revision=2
 _commit=3bb3d757681e6cc5135aec6529a753dc3dcdcfb9
 _libyuv_commit=04821d1e7d60845525e8db55c7bcd41ef5be9406
 _abseil_commit=8c0b94e793a66495e0b1f34a5eb26bd7dc672db0

From 307897b93306c6fb82d392cad4a9479e36d05f99 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:44 -0400
Subject: [PATCH 104/115] telegram-desktop: revbump for ffmpeg-6.0

---
 srcpkgs/telegram-desktop/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/telegram-desktop/template b/srcpkgs/telegram-desktop/template
index 9bd94ce3781ff..d33fc62b10e38 100644
--- a/srcpkgs/telegram-desktop/template
+++ b/srcpkgs/telegram-desktop/template
@@ -1,7 +1,7 @@
 # Template file for 'telegram-desktop'
 pkgname=telegram-desktop
 version=4.11.2
-revision=1
+revision=2
 build_style=cmake
 build_helper="qemu gir"
 configure_args="-DTDESKTOP_API_ID=209235

From 323a054e54b0e48c2f8dc88820a51d98fefea12f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:11:13 -0400
Subject: [PATCH 105/115] mpv: revbump for ffmpeg-6.0

---
 srcpkgs/mpv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpv/template b/srcpkgs/mpv/template
index 933c22bae2ed2..301a77ad22971 100644
--- a/srcpkgs/mpv/template
+++ b/srcpkgs/mpv/template
@@ -1,7 +1,7 @@
 # Template file for 'mpv'
 pkgname=mpv
 version=0.36.0
-revision=2
+revision=3
 build_style=meson
 configure_args="-Dcdda=enabled -Ddvbin=enabled -Ddvdnav=enabled
  -Dlibmpv=true -Dcplugins=enabled

From f9d21c0e458dc4a6c00a4caa886f86d2f49eaf8e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:11:45 -0400
Subject: [PATCH 106/115] gst-plugins-bad1: revbump for ffmpeg-6.0

---
 srcpkgs/gst-plugins-bad1/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index 2bf2f4b0642fe..0fafcb6555395 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-plugins-bad1'
 pkgname=gst-plugins-bad1
 version=1.22.5
-revision=1
+revision=2
 build_helper="gir"
 build_style=meson
 configure_args="-Dpackage-origin=https://voidlinux.org -Ddoc=disabled

From fe2dcccde9ec45cb0d2034eddbe7ec41e18458f5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:12:09 -0400
Subject: [PATCH 107/115] openmw: revbump for ffmpeg-6.0

---
 srcpkgs/openmw/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openmw/template b/srcpkgs/openmw/template
index 0abf5ff7cdbec..b57180f1a4446 100644
--- a/srcpkgs/openmw/template
+++ b/srcpkgs/openmw/template
@@ -1,7 +1,7 @@
 # Template file for 'openmw'
 pkgname=openmw
 version=0.48.0
-revision=2
+revision=3
 build_style=cmake
 _recast_commit=e75adf86f91eb3082220085e42dda62679f9a3ea
 _bullet_tag=3.17

From 521794c8fd8042e2d4a0aebf6f46a3e491968730 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:14:53 -0400
Subject: [PATCH 108/115] lms: revbump for ffmpeg-6.0

---
 srcpkgs/lms/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/lms/template b/srcpkgs/lms/template
index e358f75902a98..3b21c458de519 100644
--- a/srcpkgs/lms/template
+++ b/srcpkgs/lms/template
@@ -1,7 +1,7 @@
 # Template file for 'lms'
 pkgname=lms
 version=3.42.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="wt-devel ffmpeg-devel boost-devel libconfig++-devel taglib-devel pam-devel libgraphicsmagick-devel gtest-devel libarchive-devel"

From e791df4fa76bcd14a037a9293d4291c0f338e05f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:18:18 -0400
Subject: [PATCH 109/115] freecad: revbump for ffmpeg-6.0

---
 srcpkgs/freecad/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/freecad/template b/srcpkgs/freecad/template
index c135701e38b9a..705499e9972a6 100644
--- a/srcpkgs/freecad/template
+++ b/srcpkgs/freecad/template
@@ -1,7 +1,7 @@
 # Template file for 'freecad'
 pkgname=freecad
 version=0.20.2
-revision=7
+revision=8
 build_wrksrc="FreeCAD-${version}"
 build_style=cmake
 pycompile_dirs="usr/lib/${pkgname}/Mod"

From 198c99ff7d8ac1d5dc41f58344ce5b53f85774c7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:40:39 -0400
Subject: [PATCH 110/115] obs: revbump for ffmpeg-6.0

---
 srcpkgs/obs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/obs/template b/srcpkgs/obs/template
index b43b10ef935e9..5d1d5e887409e 100644
--- a/srcpkgs/obs/template
+++ b/srcpkgs/obs/template
@@ -1,7 +1,7 @@
 # Template file for 'obs'
 pkgname=obs
 version=29.1.3
-revision=2
+revision=3
 archs="i686* x86_64* ppc64le* aarch64*"
 build_style=cmake
 configure_args="-DOBS_VERSION_OVERRIDE=${version} -DENABLE_JACK=ON

From bfbc273aec473c37bcf2fe6f86514e5e78018187 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:46:47 -0400
Subject: [PATCH 111/115] mlt7: revbump for ffmpeg-6.0

---
 srcpkgs/mlt7/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mlt7/template b/srcpkgs/mlt7/template
index 6aa3918b0c366..98f302ad3a516 100644
--- a/srcpkgs/mlt7/template
+++ b/srcpkgs/mlt7/template
@@ -1,7 +1,7 @@
 # Template file for 'mlt7'
 pkgname=mlt7
 version=7.20.0
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSWIG_PYTHON=ON -DMOD_QT6=ON"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which

From 34ac62b57868d448d105b1abdfee6d8d7f4bacea Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:47:18 -0400
Subject: [PATCH 112/115] libopenshot: revbump for ffmpeg-6.0

---
 srcpkgs/libopenshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenshot/template b/srcpkgs/libopenshot/template
index 8e57c5f592169..7a8f4520e7892 100644
--- a/srcpkgs/libopenshot/template
+++ b/srcpkgs/libopenshot/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenshot'
 pkgname=libopenshot
 version=0.3.0
-revision=3
+revision=4
 build_style=cmake
 # Builds fail with Ruby-2.4.1
 configure_args="-DENABLE_RUBY=OFF -DUSE_SYSTEM_JSONCPP=ON"

From 53ac8fc2686434d7e7b3b6158b51615303987423 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:10:30 -0500
Subject: [PATCH 113/115] openimageio: revbump for ffmpeg-6.0

---
 srcpkgs/openimageio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimageio/template b/srcpkgs/openimageio/template
index 3ce3f9e49d350..27d2131bc0a61 100644
--- a/srcpkgs/openimageio/template
+++ b/srcpkgs/openimageio/template
@@ -1,7 +1,7 @@
 # Template file for 'openimageio'
 pkgname=openimageio
 version=2.4.9.0
-revision=7
+revision=8
 build_style=cmake
 build_helper=qemu
 configure_args="-DUSE_QT=0 -DUSE_PYTHON=0 -DOIIO_BUILD_TESTS=0

From 38f32a60d7a92d8906af95d3e517a52d1c2b6281 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:11:57 -0500
Subject: [PATCH 114/115] synfigstudio: revbump for ffmpeg-6.0

---
 srcpkgs/synfigstudio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/synfigstudio/template b/srcpkgs/synfigstudio/template
index 09e442da9a680..2bc017cedca6b 100644
--- a/srcpkgs/synfigstudio/template
+++ b/srcpkgs/synfigstudio/template
@@ -2,7 +2,7 @@
 # Should be kept in sync with 'synfig' and 'ETL'
 pkgname=synfigstudio
 version=1.4.4
-revision=4
+revision=5
 build_style=gnu-configure
 configure_args="--disable-update-mimedb"
 hostmakedepends="pkg-config intltool gettext synfig"

From 3ba8818cf16f752ac8a800ec5fe6cc4b0294a811 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:12:32 -0500
Subject: [PATCH 115/115] gmic: revbump for ffmpeg-6.0

---
 srcpkgs/gmic/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gmic/template b/srcpkgs/gmic/template
index 808953e9b543c..d854808f86aa4 100644
--- a/srcpkgs/gmic/template
+++ b/srcpkgs/gmic/template
@@ -1,7 +1,7 @@
 # Template file for 'gmic'
 pkgname=gmic
 version=3.1.6
-revision=5
+revision=6
 _zart_hash=34ebf6cce0bafb98abe57cec83c4a02cd1abeca0
 create_wrksrc=yes
 build_wrksrc="src"

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (36 preceding siblings ...)
  2023-11-08 15:12 ` [PR PATCH] [Updated] " zlice
@ 2023-11-10 20:08 ` zlice
  2023-11-14 13:43 ` zlice
                   ` (59 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2023-11-10 20:08 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 3663 bytes --]

There is an updated pull request by zlice against master on the void-packages repository

https://github.com/zlice/void-packages ffmpeg6-split
https://github.com/void-linux/void-packages/pull/43761

ffmpeg6 split
[ci skip]


#### Testing the changes

- I tested the changes in this PR: **YES**

main testing has been vaapi in Firefox Nightly and enc/dec in Shotcut on Intel A770

#### New package

- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**

#### Local build testing

- I built this PR locally for my native architecture, **x86_64**

#### Discussion

Continuation of https://github.com/void-linux/void-packages/pull/36315

`libavresample` is deprecated, but marked as a dependency when trying to build other packages and install `ffmpeg`(6). I think the right way to handle this is make a meta package and the add to removals?


##### Commit naming / misc

~~Commits are 'dirty' right now, running with [gstreamer 1.22.1 updates](https://github.com/void-linux/void-packages/pull/42861) and [Intel OpenCL](https://github.com/void-linux/void-packages/pull/43084). This will also make [intel packages pr](https://github.com/void-linux/void-packages/pull/41132) obsolete.~~ (see Requirements below)

Maintainer for previous ffmpeg(4) was orphaned, I can put my name in there if that matters, though I don't exactly see myself keeping up on ffmpeg.

This updates QT5 which looks like it is usually hosted by Johnny. Not sure if there's any reason to stay there or these sources are fine.

##### STILL FFMPEG4

These are a mix of emulators, games and/or older packages.

- attract (multiple patches in master)
- audacity (https://github.com/audacity/audacity/issues/2305 and https://sourceforge.net/p/portmedia/wiki/portsmf/ is 'beta')
- ccextractor (master patches? no release)
- vice
- kodi
- mlt (only dep left is flowblade)
- ~~synfig (mlt)~~ (work with mlt7, bump synfigstudio)
- tvheadend
- ssr
- ~~spek-alternative~~ (replace with spek-x)
- ppsspp
- olive
- moc
- mediastreamer
- libextractor
- idjc
- hedgewars
- ~~ffmpegthumbnailer~~ (patches for moviedecoder.xxx files)
- ~~ffmpegthumbs~~ (latest compiles)
- deadbeef
- omxplayer
- qtav (fork has ffmpeg 5 patch - https://github.com/cmguo/QtAV)
- `vlc` (vlc4 will support ffmpeg5, there's a patch to build 3.x with ffmpeg5 but it will lack vaapi)
- `osg` (OpenSceneGraph plus `xine-lib`)


##### HAVE NOT BUILT YET

- omxplayer (rpi only? ffmpeg4)
- kodi (big, but ffmpeg4)


##### UPDATED (for ffmpeg6)

- ~~blender: update to 3.5.1~~ ~~will be revbump with~~ https://github.com/void-linux/void-packages/pull/43992
- unpaper: update to 7.0.0.
- guvcview: update to 2.0.8.
- qt5: update to 5.15.8
- qt5-webengine: update to 5.18.13
- shiboken2: revbump for qt5.15.8 (patch)
- python3-pyside2: update to 5.15.8 (patch)
- New package: spex-x replaces spek-alternative for ffmpeg-6.0


##### Requirements

- ~~[gstreamer 1.22.2](https://github.com/void-linux/void-packages/pull/42861)~~ - a few packages use ffmpeg-devel and require a revbump

- [Intel Packages](https://github.com/void-linux/void-packages/pull/41132) - ffmpeg4 uses different libraries than 6 (libmfx / Intel-MediaSDK vs only oneVPL that Intel is moving to), both are included here

- ~~[shotcut 23.05.14](https://github.com/void-linux/void-packages/pull/44260)~~

- https://github.com/void-linux/void-packages/pull/44781 will remove from this PR

A patch file from https://github.com/void-linux/void-packages/pull/43761.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ffmpeg6-split-43761.patch --]
[-- Type: text/x-diff, Size: 788356 bytes --]

From 6ce7f3392112915e061c7cc9778a9b186102a20a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:16:56 -0400
Subject: [PATCH 001/115] ffmpeg: update to 6.0.

---
 common/shlibs                                 | 26 +++++---
 srcpkgs/ffmpeg/files/altivec.patch            | 60 -------------------
 .../patches/armv5tel-floating-point.patch     | 18 ------
 ...h-libavcodec-libsvtav1-ten_bit_format.diff | 40 -------------
 .../workaround-mesa-readeon-vaapi-bug.patch   | 28 ---------
 srcpkgs/ffmpeg/template                       | 38 ++++++------
 6 files changed, 37 insertions(+), 173 deletions(-)
 delete mode 100644 srcpkgs/ffmpeg/files/altivec.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 delete mode 100644 srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch

diff --git a/common/shlibs b/common/shlibs
index 7e9cee83f8417..a0bacd40913c5 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -385,15 +385,23 @@ libid3tag.so.0 libid3tag-0.15.1b_1
 libgif.so.7 giflib-5.1.0_1
 libImlib2.so.1 imlib2-1.4.2_1
 libmp3lame.so.0 lame-3.98.2_1
-libavdevice.so.58 libavdevice-4.0_1
-libavformat.so.58 libavformat-4.0_1
-libswscale.so.5 libswscale-4.0_1
-libswresample.so.3 libswresample-4.0_1
-libavresample.so.4 libavresample-4.0_1
-libpostproc.so.55 libpostproc-4.0_1
-libavcodec.so.58 libavcodec-4.0_1
-libavutil.so.56 libavutil-4.0_1
-libavfilter.so.7 libavfilter-4.0_1
+libavdevice.so.60 libavdevice-6.0_1
+libavformat.so.60 libavformat-6.0_1
+libswscale.so.7 libswscale-6.0_1
+libswresample.so.4 libswresample-6.0_1
+libpostproc.so.57 libpostproc-6.0_1
+libavcodec.so.60 libavcodec-6.0_1
+libavutil.so.58 libavutil-6.0_1
+libavfilter.so.9 libavfilter-6.0_1
+libavdevice.so.58 libavdevice4-4.0_1
+libavformat.so.58 libavformat4-4.0_1
+libswscale.so.5 libswscale4-4.0_1
+libswresample.so.3 libswresample4-4.0_1
+libavresample.so.4 libavresample4-4.0_1
+libpostproc.so.55 libpostproc4-4.0_1
+libavcodec.so.58 libavcodec4-4.0_1
+libavutil.so.56 libavutil4-4.0_1
+libavfilter.so.7 libavfilter4-4.0_1
 libSDL-1.2.so.0 SDL-1.2.14_1
 libSDL_image-1.2.so.0 SDL_image-1.2.10_1
 libx264.so.157 x264-20190507.2245_1
diff --git a/srcpkgs/ffmpeg/files/altivec.patch b/srcpkgs/ffmpeg/files/altivec.patch
deleted file mode 100644
index 9c57200463320..0000000000000
--- a/srcpkgs/ffmpeg/files/altivec.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-revert some altivec specific change on all ppc* except ppc64le*
-
-q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
-conditionally, for ppc* but not ppc64le* (the new code is valid for
-POWER8 VSX which LE targets as a baseline but not BE)"
-
-
-This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
----
- libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
- 1 file changed, 20 insertions(+), 4 deletions(-)
-
-diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
-index 536545293d..c1e2852adb 100644
---- a/libswscale/ppc/yuv2rgb_altivec.c
-+++ b/libswscale/ppc/yuv2rgb_altivec.c
-@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-     vector signed short R1, G1, B1;                                           \
-     vector unsigned char R, G, B;                                             \
-                                                                               \
-+    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
-+    vector unsigned char align_perm;                                          \
-+                                                                              \
-     vector signed short lCY       = c->CY;                                    \
-     vector signed short lOY       = c->OY;                                    \
-     vector signed short lCRV      = c->CRV;                                   \
-@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
-                                                                               \
-         for (j = 0; j < w / 16; j++) {                                        \
--            y0 = vec_xl(0, y1i);                                              \
-+            y1ivP = (const vector unsigned char *) y1i;                       \
-+            y2ivP = (const vector unsigned char *) y2i;                       \
-+            uivP  = (const vector unsigned char *) ui;                        \
-+            vivP  = (const vector unsigned char *) vi;                        \
-+                                                                              \
-+            align_perm = vec_lvsl(0, y1i);                                    \
-+            y0 = (vector unsigned char)                                       \
-+                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
-                                                                               \
--            y1 = vec_xl(0, y2i);                                              \
-+            align_perm = vec_lvsl(0, y2i);                                    \
-+            y1 = (vector unsigned char)                                       \
-+                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
-                                                                               \
--            u = (vector signed char) vec_xl(0, ui);                           \
-+            align_perm = vec_lvsl(0, ui);                                     \
-+            u = (vector signed char)                                          \
-+                    vec_perm(uivP[0], uivP[1], align_perm);                   \
-                                                                               \
--            v = (vector signed char) vec_xl(0, vi);                           \
-+            align_perm = vec_lvsl(0, vi);                                     \
-+            v = (vector signed char)                                          \
-+                    vec_perm(vivP[0], vivP[1], align_perm);                   \
-                                                                               \
-             u = (vector signed char)                                          \
-                     vec_sub(u,                                                \
--- 
-2.27.0
-
diff --git a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
deleted file mode 100644
index 9a55178c74f0f..0000000000000
--- a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
-+++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
-@@ -39,6 +39,15 @@
- #endif
- #include <fenv.h>
- 
-+#if (FE_ALL_EXCEPT == 0)
-+/* E.g. ARM soft float does not define these */
-+#define FE_INVALID    0
-+#define FE_DIVBYZERO  0
-+#define FE_OVERFLOW   0
-+#define FE_UNDERFLOW  0
-+#define FE_INEXACT    0
-+#endif
-+
- #if CONFIG_LIBFONTCONFIG
- #include <fontconfig/fontconfig.h>
- #endif
diff --git a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
deleted file mode 100644
index aa948f7a8a2df..0000000000000
--- a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
+++ /dev/null
@@ -1,40 +0,0 @@
-#==================================================================================================
-# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
-# From: Christopher Degawa <christopher.degawa@intel.com>
-# Date: Thu, 20 Oct 2022 22:55:27 -0500
-# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
-#
-# compressed_ten_bit_format has been deprecated upstream and has no effect
-# and can be removed. Plus, technically it was never used in the first place
-# since it would require the app (ffmpeg) to set it and do additional
-# processing of the input frames.
-#
-# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
-#
-# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
-#==================================================================================================
---- a/libavcodec/libsvtav1.c
-+++ b/libavcodec/libsvtav1.c
-@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
- 
- static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
- {
--    const int    pack_mode_10bit =
--        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
--    const size_t luma_size_8bit  =
--        config->source_width * config->source_height * (1 << pack_mode_10bit);
--    const size_t luma_size_10bit =
--        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
-+    const size_t luma_size = config->source_width * config->source_height *
-+        (config->encoder_bit_depth > 8 ? 2 : 1);
- 
-     EbSvtIOFormat *in_data;
- 
--    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
-+    svt_enc->raw_size = luma_size * 3 / 2;
- 
-     // allocate buffer for in and out
-     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
--- 
-GitLab
-
diff --git a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
deleted file mode 100644
index 00e3f68a415b8..0000000000000
--- a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
-From: Rainer Hochecker <fernetmenta@online.de>
-Date: Sat, 26 Jan 2019 19:48:35 +0100
-Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
-
-This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
-It was hit frequently when watching h264 channels received via DVB-X.
-Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
----
- libavcodec/vaapi_h264.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
-index 5854587a255..f12fdc457a4 100644
---- a/libavcodec/vaapi_h264.c
-+++ b/libavcodec/vaapi_h264.c
-@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
-     H264SliceContext *sl = &h->slice_ctx[0];
-     int ret;
- 
-+    if (pic->nb_slices == 0) {
-+        ret = AVERROR_INVALIDDATA;
-+        goto finish;
-+    }
-+
-     ret = ff_vaapi_decode_issue(avctx, pic);
-     if (ret < 0)
-         goto finish;
diff --git a/srcpkgs/ffmpeg/template b/srcpkgs/ffmpeg/template
index 5968a09b1f12d..c1f9b7efe40e3 100644
--- a/srcpkgs/ffmpeg/template
+++ b/srcpkgs/ffmpeg/template
@@ -1,15 +1,15 @@
 # Template file for 'ffmpeg'
 # audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
 pkgname=ffmpeg
-version=4.4.4
-revision=5
+version=6.0
+revision=1
 short_desc="Decoding, encoding and streaming software"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="https://www.ffmpeg.org"
 changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
 distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
-checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+checksum=57be87c22d9b49c112b6d24bc67d42508660e6b718b3db89c44e47e289137082
 
 hostmakedepends="pkg-config perl"
 makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
@@ -26,12 +26,13 @@ makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-deve
  $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
  $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
  $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
- $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers Vulkan-Tools Vulkan-ValidationLayers')
+ $(vopt_if onevpl 'onevpl onevpl-devel')
  $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
 depends="ffplay>=${version}_${revision}"
 
 build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
- dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec onevpl"
 build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
 desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
 desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
@@ -39,9 +40,13 @@ desc_option_sofa="Enable support for AES SOFA"
 desc_option_webp="Enable support for WebP"
 
 case "$XBPS_TARGET_MACHINE" in
-	i686*|x86_64*)
-		hostmakedepends+=" nasm"
+	i686*)
 		build_options_default+=" vaapi vdpau nvenc nvdec"
+		hostmakedepends+=" nasm"
+		;;
+	x86_64*)
+		hostmakedepends+=" nasm"
+		build_options_default+=" vaapi vdpau nvenc nvdec onevpl"
 		;;
 	ppc64*) build_options_default+=" vaapi vdpau";;
 	mips*) CFLAGS="-mnan=legacy";;
@@ -115,18 +120,19 @@ do_configure() {
 		$(vopt_enable x265 libx265) \
 		$(vopt_enable v4l2 libv4l2) \
 		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
-		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		--enable-libbs2b --enable-libvidstab \
 		$(vopt_enable dav1d libdav1d) \
 		$(vopt_enable zimg libzimg) \
 		$(vopt_enable webp libwebp) \
 		$(vopt_enable sofa libmysofa) \
 		$(vopt_enable vulkan) \
+		$(vopt_enable onevpl libvpl) \
 		$(vopt_enable drm libdrm) \
 		$(vopt_enable svtav1 libsvtav1) \
 		$(vopt_enable srt libsrt) \
 		$(vopt_enable rist librist) \
-		$(vopt_if nvenc '--enable-nvenc') \
-		$(vopt_if nvdec '--enable-nvdec')
+		$(vopt_enable nvenc nvenc) \
+		$(vopt_enable nvdec nvdec)
 }
 
 do_build() {
@@ -153,10 +159,8 @@ libavdevice_package() {
 }
 
 libavresample_package() {
-	short_desc="FFmpeg audio resampling library"
-	pkg_install() {
-		vmove "usr/lib/libavresample.so.*"
-	}
+	short_desc="Package deprecated, removal needed"
+	build_style=meta
 }
 
 libavformat_package() {
@@ -210,15 +214,13 @@ ffmpeg-devel_package() {
 		libavfilter>=${version}_${revision}
 		libpostproc>=${version}_${revision}
 		libswscale>=${version}_${revision}
-		libswresample>=${version}_${revision}
-		libavresample>=${version}_${revision}"
+		libswresample>=${version}_${revision}"
 	short_desc+=" - development files"
-
+	conflicts="ffmpeg4-devel"
 	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
 		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
 		nostrip_files="/usr/lib/libavfilter.a"
 	fi
-
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig

From b422fe9837e89b8a17d72a60121152c3ea501bee Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:14 -0400
Subject: [PATCH 002/115] openshot: revbump for ffmpeg6.0

---
 srcpkgs/openshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openshot/template b/srcpkgs/openshot/template
index 8f47851eef354..affb652a9d500 100644
--- a/srcpkgs/openshot/template
+++ b/srcpkgs/openshot/template
@@ -1,7 +1,7 @@
 # Template file for 'openshot'
 pkgname=openshot
 version=3.0.0
-revision=2
+revision=3
 build_style=python3-module
 hostmakedepends="python3 python3-setuptools"
 makedepends="ffmpeg-devel python3-PyQt5"

From f01b58ff2adea6ee03b9345e579931a56feb8a06 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:36 -0400
Subject: [PATCH 003/115] sumo: revbump for ffmpeg6.0

---
 srcpkgs/sumo/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/sumo/template b/srcpkgs/sumo/template
index a3fe134aa5acc..a730afa9fafa9 100644
--- a/srcpkgs/sumo/template
+++ b/srcpkgs/sumo/template
@@ -1,7 +1,7 @@
 # Template file for 'sumo'
 pkgname=sumo
 version=1.12.0
-revision=6
+revision=7
 build_style=cmake
 hostmakedepends="libgdal-tools pkg-config swig python3-setuptools"
 makedepends="python3-devel ffmpeg-devel fox-devel gl2ps-devel libgdal-devel

From d32da1b5f1f71e957141362cb94fe351d145b82e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:56:22 -0400
Subject: [PATCH 004/115] New package: ffmpeg4-4.4.4.

---
 srcpkgs/ffmpeg4-devel                         |   1 +
 srcpkgs/ffmpeg4/files/altivec.patch           |  60 +++++
 .../patches/armv5tel-floating-point.patch     |  18 ++
 ...h-libavcodec-libsvtav1-ten_bit_format.diff |  40 +++
 .../workaround-mesa-readeon-vaapi-bug.patch   |  28 ++
 srcpkgs/ffmpeg4/template                      | 240 ++++++++++++++++++
 srcpkgs/libavcodec4                           |   1 +
 srcpkgs/libavdevice4                          |   1 +
 srcpkgs/libavfilter4                          |   1 +
 srcpkgs/libavformat4                          |   1 +
 srcpkgs/libavresample4                        |   1 +
 srcpkgs/libavutil4                            |   1 +
 srcpkgs/libpostproc4                          |   1 +
 srcpkgs/libswresample4                        |   1 +
 srcpkgs/libswscale4                           |   1 +
 15 files changed, 396 insertions(+)
 create mode 120000 srcpkgs/ffmpeg4-devel
 create mode 100644 srcpkgs/ffmpeg4/files/altivec.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 create mode 100644 srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
 create mode 100644 srcpkgs/ffmpeg4/template
 create mode 120000 srcpkgs/libavcodec4
 create mode 120000 srcpkgs/libavdevice4
 create mode 120000 srcpkgs/libavfilter4
 create mode 120000 srcpkgs/libavformat4
 create mode 120000 srcpkgs/libavresample4
 create mode 120000 srcpkgs/libavutil4
 create mode 120000 srcpkgs/libpostproc4
 create mode 120000 srcpkgs/libswresample4
 create mode 120000 srcpkgs/libswscale4

diff --git a/srcpkgs/ffmpeg4-devel b/srcpkgs/ffmpeg4-devel
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/ffmpeg4-devel
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/ffmpeg4/files/altivec.patch b/srcpkgs/ffmpeg4/files/altivec.patch
new file mode 100644
index 0000000000000..9c57200463320
--- /dev/null
+++ b/srcpkgs/ffmpeg4/files/altivec.patch
@@ -0,0 +1,60 @@
+revert some altivec specific change on all ppc* except ppc64le*
+
+q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
+conditionally, for ppc* but not ppc64le* (the new code is valid for
+POWER8 VSX which LE targets as a baseline but not BE)"
+
+
+This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
+---
+ libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
+ 1 file changed, 20 insertions(+), 4 deletions(-)
+
+diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
+index 536545293d..c1e2852adb 100644
+--- a/libswscale/ppc/yuv2rgb_altivec.c
++++ b/libswscale/ppc/yuv2rgb_altivec.c
+@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+     vector signed short R1, G1, B1;                                           \
+     vector unsigned char R, G, B;                                             \
+                                                                               \
++    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
++    vector unsigned char align_perm;                                          \
++                                                                              \
+     vector signed short lCY       = c->CY;                                    \
+     vector signed short lOY       = c->OY;                                    \
+     vector signed short lCRV      = c->CRV;                                   \
+@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
+                                                                               \
+         for (j = 0; j < w / 16; j++) {                                        \
+-            y0 = vec_xl(0, y1i);                                              \
++            y1ivP = (const vector unsigned char *) y1i;                       \
++            y2ivP = (const vector unsigned char *) y2i;                       \
++            uivP  = (const vector unsigned char *) ui;                        \
++            vivP  = (const vector unsigned char *) vi;                        \
++                                                                              \
++            align_perm = vec_lvsl(0, y1i);                                    \
++            y0 = (vector unsigned char)                                       \
++                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
+                                                                               \
+-            y1 = vec_xl(0, y2i);                                              \
++            align_perm = vec_lvsl(0, y2i);                                    \
++            y1 = (vector unsigned char)                                       \
++                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
+                                                                               \
+-            u = (vector signed char) vec_xl(0, ui);                           \
++            align_perm = vec_lvsl(0, ui);                                     \
++            u = (vector signed char)                                          \
++                    vec_perm(uivP[0], uivP[1], align_perm);                   \
+                                                                               \
+-            v = (vector signed char) vec_xl(0, vi);                           \
++            align_perm = vec_lvsl(0, vi);                                     \
++            v = (vector signed char)                                          \
++                    vec_perm(vivP[0], vivP[1], align_perm);                   \
+                                                                               \
+             u = (vector signed char)                                          \
+                     vec_sub(u,                                                \
+-- 
+2.27.0
+
diff --git a/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
new file mode 100644
index 0000000000000..9a55178c74f0f
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
@@ -0,0 +1,18 @@
+--- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
++++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
+@@ -39,6 +39,15 @@
+ #endif
+ #include <fenv.h>
+ 
++#if (FE_ALL_EXCEPT == 0)
++/* E.g. ARM soft float does not define these */
++#define FE_INVALID    0
++#define FE_DIVBYZERO  0
++#define FE_OVERFLOW   0
++#define FE_UNDERFLOW  0
++#define FE_INEXACT    0
++#endif
++
+ #if CONFIG_LIBFONTCONFIG
+ #include <fontconfig/fontconfig.h>
+ #endif
diff --git a/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
new file mode 100644
index 0000000000000..aa948f7a8a2df
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
@@ -0,0 +1,40 @@
+#==================================================================================================
+# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
+# From: Christopher Degawa <christopher.degawa@intel.com>
+# Date: Thu, 20 Oct 2022 22:55:27 -0500
+# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
+#
+# compressed_ten_bit_format has been deprecated upstream and has no effect
+# and can be removed. Plus, technically it was never used in the first place
+# since it would require the app (ffmpeg) to set it and do additional
+# processing of the input frames.
+#
+# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
+#
+# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
+#==================================================================================================
+--- a/libavcodec/libsvtav1.c
++++ b/libavcodec/libsvtav1.c
+@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
+ 
+ static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
+ {
+-    const int    pack_mode_10bit =
+-        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
+-    const size_t luma_size_8bit  =
+-        config->source_width * config->source_height * (1 << pack_mode_10bit);
+-    const size_t luma_size_10bit =
+-        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
++    const size_t luma_size = config->source_width * config->source_height *
++        (config->encoder_bit_depth > 8 ? 2 : 1);
+ 
+     EbSvtIOFormat *in_data;
+ 
+-    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
++    svt_enc->raw_size = luma_size * 3 / 2;
+ 
+     // allocate buffer for in and out
+     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
+-- 
+GitLab
+
diff --git a/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
new file mode 100644
index 0000000000000..00e3f68a415b8
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
@@ -0,0 +1,28 @@
+From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
+From: Rainer Hochecker <fernetmenta@online.de>
+Date: Sat, 26 Jan 2019 19:48:35 +0100
+Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
+
+This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
+It was hit frequently when watching h264 channels received via DVB-X.
+Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
+---
+ libavcodec/vaapi_h264.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
+index 5854587a255..f12fdc457a4 100644
+--- a/libavcodec/vaapi_h264.c
++++ b/libavcodec/vaapi_h264.c
+@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
+     H264SliceContext *sl = &h->slice_ctx[0];
+     int ret;
+ 
++    if (pic->nb_slices == 0) {
++        ret = AVERROR_INVALIDDATA;
++        goto finish;
++    }
++
+     ret = ff_vaapi_decode_issue(avctx, pic);
+     if (ret < 0)
+         goto finish;
diff --git a/srcpkgs/ffmpeg4/template b/srcpkgs/ffmpeg4/template
new file mode 100644
index 0000000000000..f2c851693d367
--- /dev/null
+++ b/srcpkgs/ffmpeg4/template
@@ -0,0 +1,240 @@
+# Template file for 'ffmpeg4'
+# audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
+pkgname=ffmpeg4
+version=4.4.4
+revision=1
+short_desc="Decoding, encoding and streaming software - ffmpeg4 libraries only"
+maintainer="Orphaned <orphan@voidlinux.org>"
+license="GPL-3.0-or-later"
+homepage="https://www.ffmpeg.org"
+changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
+distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
+checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+
+hostmakedepends="pkg-config perl"
+makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
+ libXext-devel libXvMC-devel libxcb-devel lame-devel libtheora-devel
+ libvorbis-devel x264-devel xvidcore-devel jack-devel SDL2-devel
+ libcdio-paranoia-devel librtmp-devel libmodplug-devel gnutls-devel
+ speex-devel celt-devel harfbuzz-devel libass-devel opus-devel ocl-icd-devel
+ libbs2b-devel libvidstab-devel vmaf-devel $(vopt_if pulseaudio pulseaudio-devel)
+ $(vopt_if vaapi libva-devel) $(vopt_if vdpau libvdpau-devel)
+ $(vopt_if x265 x265-devel) $(vopt_if v4l2 v4l-utils-devel)
+ $(vopt_if fdk_aac fdk-aac-devel) $(vopt_if vpx libvpx-devel)
+ $(vopt_if aom libaom-devel) $(vopt_if sndio sndio-devel)
+ $(vopt_if dav1d libdav1d-devel) $(vopt_if zimg zimg-devel)
+ $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
+ $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
+ $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if mfx 'libmfx libmfx-devel')
+ $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
+
+build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec mfx"
+build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
+
+desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
+desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
+desc_option_sofa="Enable support for AES SOFA"
+desc_option_webp="Enable support for WebP"
+
+case "$XBPS_TARGET_MACHINE" in
+	i686*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau nvenc nvdec"
+			;;
+	x86_64*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau mfx nvenc nvdec"
+			;;
+	ppc64*) build_options_default+=" vaapi vdpau";;
+	mips*) CFLAGS="-mnan=legacy";;
+esac
+
+if [ "$XBPS_TARGET_WORDSIZE" != "32" ]; then
+	build_options_default+=" svtav1"
+fi
+
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+fi
+
+_apply_patch() {
+	local args="$1" pname="$(basename $2)"
+
+	if [ ! -f ".${pname}_done" ]; then
+		patch -N $args -i $2
+		touch .${pname}_done
+	fi
+}
+
+post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64le*) ;;
+		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
+	esac
+
+	vsed -i libavfilter/vf_libvmaf.c -e 's!/usr/local/share/model/\(vmaf_v0.6.1\).pkl!/usr/share/vmaf/\1.json!'
+}
+
+do_configure() {
+	# Fix gcc on x86_64-musl only
+	if [ "$XBPS_TARGET_MACHINE" = "x86_64-musl" ]; then
+		vsed -i configure -e "s;_cflags_speed='-O3';_cflags_speed='-O2';"
+	fi
+
+	if [ "$CROSS_BUILD" ]; then
+		case "$XBPS_TARGET_MACHINE" in
+			arm*) _arch="arm";;
+			aarch64*) _arch="aarch64";;
+			mips*) _arch="mips";;
+			ppc64*) _arch="ppc64";;
+			ppc*) _arch="ppc";;
+			*) _arch="${XBPS_TARGET_MACHINE%%-musl}";;
+		esac
+
+		_args+=" --enable-cross-compile
+			--sysroot=$XBPS_CROSS_BASE
+			--cross-prefix=${XBPS_CROSS_TRIPLET}-
+			--target-os=linux --arch=${_arch}"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc|ppc-musl) _args+=" --disable-altivec";;
+	esac
+
+	if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+		_args+=" --extra-libs=-latomic"
+	fi
+
+	./configure --prefix=/usr --disable-debug --enable-gpl --enable-gnutls \
+		--disable-stripping \
+		--enable-libcdio --enable-version3 --enable-runtime-cpudetect \
+		--enable-libmp3lame --enable-libvorbis --enable-libxvid \
+		--enable-libx264 $(vopt_enable vpx libvpx) --enable-libtheora \
+		--enable-shared --enable-static --enable-libxcb \
+		$(vopt_enable pulseaudio libpulse) --enable-libfreetype --enable-libmodplug \
+		--enable-libspeex --enable-libcelt --enable-libass \
+		--enable-libopus --enable-librtmp --enable-libjack \
+		$(vopt_if fdk_aac '--enable-nonfree --enable-libfdk-aac') \
+		--disable-libopencore_amrnb --disable-libopencore_amrwb \
+		--disable-libopenjpeg \
+		--enable-postproc --enable-opencl ${_args} --enable-libvmaf ${_args} \
+		$(vopt_enable x265 libx265) \
+		$(vopt_enable v4l2 libv4l2) \
+		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
+		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		$(vopt_enable dav1d libdav1d) \
+		$(vopt_enable zimg libzimg) \
+		$(vopt_enable webp libwebp) \
+		$(vopt_enable sofa libmysofa) \
+		$(vopt_enable vulkan) \
+		$(vopt_enable drm libdrm) \
+		$(vopt_enable svtav1 libsvtav1) \
+		$(vopt_enable srt libsrt) \
+		$(vopt_enable rist librist) \
+		$(vopt_enable mfx libmfx) \
+		$(vopt_if nvenc '--enable-nvenc') \
+		$(vopt_if nvdec '--enable-nvdec')
+}
+
+do_build() {
+	make ${makejobs}
+	make doc/ff{mpeg,play}.1
+}
+
+do_install() {
+	make DESTDIR=${DESTDIR} install install-man
+	rm -rf ${DESTDIR}/usr/bin
+}
+
+libavcodec4_package() {
+	short_desc="FFmpeg codec library"
+	pkg_install() {
+		vmove "usr/lib/libavcodec.so.*"
+	}
+}
+
+libavdevice4_package() {
+	short_desc="FFmpeg device handling library"
+	pkg_install() {
+		vmove "usr/lib/libavdevice.so.*"
+	}
+}
+
+libavresample4_package() {
+	short_desc="FFmpeg audio resampling library"
+	pkg_install() {
+		vmove "usr/lib/libavresample.so.*"
+	}
+}
+
+libavformat4_package() {
+	short_desc="FFmpeg file format library"
+	pkg_install() {
+		vmove "usr/lib/libavformat.so.*"
+	}
+}
+
+libavutil4_package() {
+	short_desc="FFmpeg utility library"
+	pkg_install() {
+		vmove "usr/lib/libavutil.so.*"
+	}
+}
+
+libavfilter4_package() {
+	short_desc="FFmpeg audio/video filter library"
+	pkg_install() {
+		vmove "usr/lib/libavfilter.so.*"
+	}
+}
+
+libpostproc4_package() {
+	short_desc="FFmpeg video postprocessing library"
+	pkg_install() {
+		vmove "usr/lib/libpostproc.so.*"
+	}
+}
+
+libswscale4_package() {
+	short_desc="FFmpeg video scaling library"
+	pkg_install() {
+		vmove "usr/lib/libswscale.so.*"
+	}
+}
+
+libswresample4_package() {
+	short_desc="FFmpeg video resampling library"
+	pkg_install() {
+		vmove "usr/lib/libswresample.so.*"
+	}
+}
+
+ffmpeg4-devel_package() {
+	depends="
+		libavcodec4>=${version}_${revision}
+		libavdevice4>=${version}_${revision}
+		libavformat4>=${version}_${revision}
+		libavutil4>=${version}_${revision}
+		libavfilter4>=${version}_${revision}
+		libpostproc4>=${version}_${revision}
+		libswscale4>=${version}_${revision}
+		libswresample4>=${version}_${revision}
+		libavresample4>=${version}_${revision}"
+	short_desc+=" - development files"
+	conflicts="ffmpeg-devel"
+	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
+		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
+		nostrip_files="/usr/lib/libavfilter.a"
+	fi
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.a"
+		vmove "usr/lib/*.so"
+		vmove usr/share/ffmpeg/examples
+		vmove usr/share/man/man3
+	}
+}
diff --git a/srcpkgs/libavcodec4 b/srcpkgs/libavcodec4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavcodec4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavdevice4 b/srcpkgs/libavdevice4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavdevice4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavfilter4 b/srcpkgs/libavfilter4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavfilter4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavformat4 b/srcpkgs/libavformat4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavformat4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavresample4 b/srcpkgs/libavresample4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavutil4 b/srcpkgs/libavutil4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavutil4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libpostproc4 b/srcpkgs/libpostproc4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libpostproc4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswresample4 b/srcpkgs/libswresample4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libswresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswscale4 b/srcpkgs/libswscale4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libswscale4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file

From 9ee6fb837a544cab2b3d33d75cca9614240baef6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:04 -0400
Subject: [PATCH 005/115] opencv: update to 4.7.0.

---
 common/shlibs           | 104 ++++++++++++++++++++--------------------
 srcpkgs/opencv/template |   8 ++--
 2 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index a0bacd40913c5..3d769cd4428fa 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2085,58 +2085,58 @@ libcapstone.so.5 capstone-5.0.1_1
 libhavege.so.2 libhaveged-1.9.11_1
 libnih.so.1 libnih-1.0.3_1
 libnih-dbus.so.1 libnih-1.0.3_1
-libopencv_quality.so.406 libopencv-4.6.0_1
-libopencv_reg.so.406 libopencv-4.6.0_1
-libopencv_surface_matching.so.406 libopencv-4.6.0_1
-libopencv_xphoto.so.406 libopencv-4.6.0_1
-libopencv_freetype.so.406 libopencv-4.6.0_1
-libopencv_fuzzy.so.406 libopencv-4.6.0_1
-libopencv_hfs.so.406 libopencv-4.6.0_1
-libopencv_img_hash.so.406 libopencv-4.6.0_1
-libopencv_line_descriptor.so.406 libopencv-4.6.0_1
-libopencv_saliency.so.406 libopencv-4.6.0_1
-libopencv_structured_light.so.406 libopencv-4.6.0_1
-libopencv_aruco.so.406 libopencv-4.6.0_1
-libopencv_bgsegm.so.406 libopencv-4.6.0_1
-libopencv_bioinspired.so.406 libopencv-4.6.0_1
-libopencv_ccalib.so.406 libopencv-4.6.0_1
-libopencv_face.so.406 libopencv-4.6.0_1
-libopencv_tracking.so.406 libopencv-4.6.0_1
-libopencv_xfeatures2d.so.406 libopencv-4.6.0_1
-libopencv_optflow.so.406 libopencv-4.6.0_1
-libopencv_ximgproc.so.406 libopencv-4.6.0_1
-libopencv_plot.so.406 libopencv-4.6.0_1
-libopencv_text.so.406 libopencv-4.6.0_1
-libopencv_ml.so.406 libopencv-4.6.0_1
-libopencv_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn.so.406 libopencv-4.6.0_1
-libopencv_shape.so.406 libopencv-4.6.0_1
-libopencv_stitching.so.406 libopencv-4.6.0_1
-libopencv_photo.so.406 libopencv-4.6.0_1
-libopencv_video.so.406 libopencv-4.6.0_1
-libopencv_calib3d.so.406 libopencv-4.6.0_1
-libopencv_features2d.so.406 libopencv-4.6.0_1
-libopencv_flann.so.406 libopencv-4.6.0_1
-libopencv_highgui.so.406 libopencv-4.6.0_1
-libopencv_videoio.so.406 libopencv-4.6.0_1
-libopencv_imgcodecs.so.406 libopencv-4.6.0_1
-libopencv_imgproc.so.406 libopencv-4.6.0_1
-libopencv_core.so.406 libopencv-4.6.0_1
-libopencv_superres.so.406 libopencv-4.6.0_1
-libopencv_videostab.so.406 libopencv-4.6.0_1
-libopencv_gapi.so.406 libopencv-4.6.0_1
-libopencv_xobjdetect.so.406 libopencv-4.6.0_1
-libopencv_datasets.so.406 libopencv-4.6.0_1
-libopencv_dnn_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn_superres.so.406 libopencv-4.6.0_1
-libopencv_dpm.so.406 libopencv-4.6.0_1
-libopencv_phase_unwrapping.so.406 libopencv-4.6.0_1
-libopencv_stereo.so.406 libopencv-4.6.0_1
-libopencv_rapid.so.406 libopencv-4.6.0_1
-libopencv_intensity_transform.so.406 libopencv-4.6.0_1
-libopencv_alphamat.so.406 libopencv-4.6.0_1
-libopencv_barcode.so.406 libopencv-4.6.0_1
-libopencv_mcc.so.406 libopencv-4.6.0_1
+libopencv_quality.so.407 libopencv-4.7.0_1
+libopencv_reg.so.407 libopencv-4.7.0_1
+libopencv_surface_matching.so.407 libopencv-4.7.0_1
+libopencv_xphoto.so.407 libopencv-4.7.0_1
+libopencv_freetype.so.407 libopencv-4.7.0_1
+libopencv_fuzzy.so.407 libopencv-4.7.0_1
+libopencv_hfs.so.407 libopencv-4.7.0_1
+libopencv_img_hash.so.407 libopencv-4.7.0_1
+libopencv_line_descriptor.so.407 libopencv-4.7.0_1
+libopencv_saliency.so.407 libopencv-4.7.0_1
+libopencv_structured_light.so.407 libopencv-4.7.0_1
+libopencv_aruco.so.407 libopencv-4.7.0_1
+libopencv_bgsegm.so.407 libopencv-4.7.0_1
+libopencv_bioinspired.so.407 libopencv-4.7.0_1
+libopencv_ccalib.so.407 libopencv-4.7.0_1
+libopencv_face.so.407 libopencv-4.7.0_1
+libopencv_tracking.so.407 libopencv-4.7.0_1
+libopencv_xfeatures2d.so.407 libopencv-4.7.0_1
+libopencv_optflow.so.407 libopencv-4.7.0_1
+libopencv_ximgproc.so.407 libopencv-4.7.0_1
+libopencv_plot.so.407 libopencv-4.7.0_1
+libopencv_text.so.407 libopencv-4.7.0_1
+libopencv_ml.so.407 libopencv-4.7.0_1
+libopencv_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn.so.407 libopencv-4.7.0_1
+libopencv_shape.so.407 libopencv-4.7.0_1
+libopencv_stitching.so.407 libopencv-4.7.0_1
+libopencv_photo.so.407 libopencv-4.7.0_1
+libopencv_video.so.407 libopencv-4.7.0_1
+libopencv_calib3d.so.407 libopencv-4.7.0_1
+libopencv_features2d.so.407 libopencv-4.7.0_1
+libopencv_flann.so.407 libopencv-4.7.0_1
+libopencv_highgui.so.407 libopencv-4.7.0_1
+libopencv_videoio.so.407 libopencv-4.7.0_1
+libopencv_imgcodecs.so.407 libopencv-4.7.0_1
+libopencv_imgproc.so.407 libopencv-4.7.0_1
+libopencv_core.so.407 libopencv-4.7.0_1
+libopencv_superres.so.407 libopencv-4.7.0_1
+libopencv_videostab.so.407 libopencv-4.7.0_1
+libopencv_gapi.so.407 libopencv-4.7.0_1
+libopencv_xobjdetect.so.407 libopencv-4.7.0_1
+libopencv_datasets.so.407 libopencv-4.7.0_1
+libopencv_dnn_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn_superres.so.407 libopencv-4.7.0_1
+libopencv_dpm.so.407 libopencv-4.7.0_1
+libopencv_phase_unwrapping.so.407 libopencv-4.7.0_1
+libopencv_stereo.so.407 libopencv-4.7.0_1
+libopencv_rapid.so.407 libopencv-4.7.0_1
+libopencv_intensity_transform.so.407 libopencv-4.7.0_1
+libopencv_alphamat.so.407 libopencv-4.7.0_1
+libopencv_barcode.so.407 libopencv-4.7.0_1
+libopencv_mcc.so.407 libopencv-4.7.0_1
 libuniconf.so.4.6 wvstreams-4.6.1_20
 libwvbase.so.4.6 wvstreams-4.6.1_20
 libwvutils.so.4.6 wvstreams-4.6.1_20
diff --git a/srcpkgs/opencv/template b/srcpkgs/opencv/template
index aea4bfc3a265c..ce94de9424d18 100644
--- a/srcpkgs/opencv/template
+++ b/srcpkgs/opencv/template
@@ -1,7 +1,7 @@
 # Template file for 'opencv'
 pkgname=opencv
-version=4.6.0
-revision=6
+version=4.7.0
+revision=1
 create_wrksrc=yes
 build_wrksrc=${pkgname}-${version}
 build_style=cmake
@@ -24,8 +24,8 @@ homepage="https://opencv.org"
 changelog="https://github.com/opencv/opencv/wiki/ChangeLog"
 distfiles="https://github.com/opencv/opencv/archive/${version}.tar.gz
  https://github.com/opencv/opencv_contrib/archive/${version}.tar.gz>contrib.tar.gz"
-checksum="1ec1cba65f9f20fe5a41fda1586e01c70ea0c9a6d7b67c9e13edf0cfe2239277
- 1777d5fd2b59029cf537e5fd6f8aa68d707075822f90bde683fcde086f85f7a7"
+checksum="8df0079cdbe179748a18d44731af62a245a45ebf5085223dc03133954c662973
+ 42df840cf9055e59d0e22c249cfb19f04743e1bdad113d31b1573d3934d62584"
 patch_args="-Np1 -d ${build_wrksrc}"
 # tests hang indenfinitely, even with test data included
 make_check=no

From 836b94b9448e648fc43becfbb83f8f7c13ca28e9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 006/115] actiona: revbump for opencv-4.7.0

---
 srcpkgs/actiona/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/actiona/template b/srcpkgs/actiona/template
index cf5f0b7a2ae61..0d899311e6df7 100644
--- a/srcpkgs/actiona/template
+++ b/srcpkgs/actiona/template
@@ -1,7 +1,7 @@
 # Template file for 'actiona'
 pkgname=actiona
 version=3.10.1
-revision=2
+revision=3
 build_style=qmake
 configure_args="PKGCONFIG_OPENCV=opencv4"
 hostmakedepends="pkg-config qt5-plugin-mysql qt5-qmake qt5-host-tools"

From 048d21116a1427b9565aaa9331145abf9d91d89e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 007/115] qimgv: revbump for opencv-4.7.0

---
 srcpkgs/qimgv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qimgv/template b/srcpkgs/qimgv/template
index 7eb30db33992c..dd341dfe1bfce 100644
--- a/srcpkgs/qimgv/template
+++ b/srcpkgs/qimgv/template
@@ -1,7 +1,7 @@
 # Template file for 'qimgv'
 pkgname=qimgv
 version=1.0.2
-revision=2
+revision=3
 build_style=cmake
 configure_args="$(vopt_if video -DVIDEO_SUPPORT=ON -DVIDEO_SUPPORT=OFF)
  $(vopt_if scale -DOPENCV_SUPPORT=ON -DOPENCV_SUPPORT=OFF)

From 49d00d5334cb717e7f947ea2b4bb3de11a31ad08 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 008/115] retroshare: revbump for opencv-4.7.0

---
 srcpkgs/retroshare/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroshare/template b/srcpkgs/retroshare/template
index bb17569277a7f..49e2c1cbe8a53 100644
--- a/srcpkgs/retroshare/template
+++ b/srcpkgs/retroshare/template
@@ -1,7 +1,7 @@
 # Template file for 'retroshare'
 pkgname=retroshare
 version=0.6.6
-revision=3
+revision=4
 build_style=qmake
 #XXX broadcast feature requires an ancient udp-discovery-cpp which either needs
 # to be fetched+patched (FTBFS) here or packaged :/

From eced50c90ca214e2a423e8b82d9df37b1cb4f567 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 009/115] waifu2x-converter-cpp: revbump for opencv-4.7.0

---
 srcpkgs/waifu2x-converter-cpp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waifu2x-converter-cpp/template b/srcpkgs/waifu2x-converter-cpp/template
index 361b8a23b9497..c5ac17eb54ea4 100644
--- a/srcpkgs/waifu2x-converter-cpp/template
+++ b/srcpkgs/waifu2x-converter-cpp/template
@@ -1,7 +1,7 @@
 # Template file for 'waifu2x-converter-cpp'
 pkgname=waifu2x-converter-cpp
 version=5.2.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DINSTALL_MODELS=ON"
 hostmakedepends="pkg-config"

From 3416f41596fb9284c0c07774699172cc05fb1729 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:38 -0400
Subject: [PATCH 010/115] vlc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/vlc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vlc/template b/srcpkgs/vlc/template
index c6e7275b514c4..681f2c3bc0827 100644
--- a/srcpkgs/vlc/template
+++ b/srcpkgs/vlc/template
@@ -25,7 +25,7 @@ lib32disabled=yes
 hostmakedepends="automake libtool pkg-config flex gettext libgcrypt-devel
  live555-devel gettext-devel $(vopt_if lua lua52) $(vopt_if chromecast protobuf)"
 makedepends="
- avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg-devel freefont-ttf
+ avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg4-devel freefont-ttf
  gnutls-devel jack-devel liba52-devel libass-devel libbluray-devel
  libcdio-devel libdca-devel libdvbpsi-devel libdvdnav-devel libmad-devel
  libmatroska-devel libmodplug-devel libmpcdec-devel libmpeg2-devel

From 88a11bda0e99b92d4afc8e92649a556a06a0e0c9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:55 -0400
Subject: [PATCH 011/115] osg: revbump for ffmpeg4-4.4.3

---
 srcpkgs/osg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/osg/template b/srcpkgs/osg/template
index a9ebbd287933b..755793f7e11bf 100644
--- a/srcpkgs/osg/template
+++ b/srcpkgs/osg/template
@@ -8,7 +8,7 @@ build_helper="qemu"
 configure_args="-DLIB_POSTFIX="
 hostmakedepends="pkg-config xrandr"
 makedepends="MesaLib-devel gtkglext-devel libcurl-devel giflib-devel librsvg-devel
- jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg-devel xine-lib-devel
+ jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg4-devel xine-lib-devel
  SDL2-devel gst-plugins-base1-devel
  $(vopt_if openexr libopenexr-devel)
  $(vopt_if poppler poppler-glib-devel)

From 305288d1daf8a1399cf1e928dc45d9bc7c29ce20 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:13 -0400
Subject: [PATCH 012/115] xine-lib: revbump for ffmpeg4-4.4.3

---
 srcpkgs/xine-lib/template | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/xine-lib/template b/srcpkgs/xine-lib/template
index 3be4d08eac77a..ed6194c17d11e 100644
--- a/srcpkgs/xine-lib/template
+++ b/srcpkgs/xine-lib/template
@@ -1,14 +1,14 @@
 # Template file for 'xine-lib'
 pkgname=xine-lib
-version=1.2.12
-revision=3
+version=1.2.13
+revision=1
 build_style=gnu-configure
 configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
  --disable-oss"
 hostmakedepends="automake gettext-devel libtool pkg-config perl"
 makedepends="
  zlib-devel alsa-lib-devel libxcb-devel libSM-devel libXext-devel libXv-devel
- libXvMC-devel liba52-devel libmad-devel ffmpeg-devel pulseaudio-devel
+ libXvMC-devel liba52-devel libmad-devel ffmpeg4-devel pulseaudio-devel
  jack-devel samba-devel libflac-devel libmodplug-devel libmpcdec-devel
  speex-devel libtheora-devel libvorbis-devel libdca-devel faad2-devel
  libcdio-devel libbluray-devel aalib-devel libcaca-devel libXinerama-devel
@@ -19,7 +19,7 @@ license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="http://www.xine-project.org"
 changelog="https://sourceforge.net/projects/xine/files/xine-lib/${version}/README.txt/view"
 distfiles="${SOURCEFORGE_SITE}/xine/${pkgname}-${version}.tar.xz"
-checksum=d606270468e1540c2a89c0d7f5fdf11e17ecc0c2698cc0bcb1065ff26abee098
+checksum=5f10d6d718a4a51c17ed1b32b031d4f9b80b061e8276535b2be31e5ac4b75e6f
 
 case "$XBPS_TARGET_MACHINE" in
 	i686-musl)

From cb04f6c645d760e996796bdbe08e341ca710d850 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 013/115] arcan: revbump for ffmpeg-6.0

---
 srcpkgs/arcan/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/arcan/template b/srcpkgs/arcan/template
index efd0afe10576d..b91e6900d42a1 100644
--- a/srcpkgs/arcan/template
+++ b/srcpkgs/arcan/template
@@ -2,7 +2,7 @@
 # !! keep synced with: acfgfs aclip aloadimage
 pkgname=arcan
 version=0.6.2.1
-revision=1
+revision=2
 create_wrksrc=yes
 build_wrksrc=arcan/src
 build_style=cmake

From 7e1ce1198f220b96f3330570ad983900d91d4667 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 014/115] attract: revbump for ffmpeg4-4.4.3

---
 srcpkgs/attract/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/attract/template b/srcpkgs/attract/template
index 26144e931a3c7..e760bf0d18aec 100644
--- a/srcpkgs/attract/template
+++ b/srcpkgs/attract/template
@@ -1,12 +1,12 @@
 # Template file for 'attract'
 pkgname=attract
 version=2.6.2
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="VERBOSE=1"
 make_use_env=yes
 hostmakedepends="pkg-config"
-makedepends="SFML-devel ffmpeg-devel fontconfig-devel glu-devel libarchive-devel
+makedepends="SFML-devel ffmpeg4-devel fontconfig-devel glu-devel libarchive-devel
  libcurl-devel libjpeg-turbo-devel xine-lib rapidjson libXrandr-devel"
 depends="git"
 short_desc="Attract-Mode is a graphical frontend for emulators"

From 9b646682ad07407218b8e6cbd34608d788eb7018 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 015/115] aubio: revbump for ffmpeg-6.0

---
 srcpkgs/aubio/patches/ffmpeg5.patch | 25 +++++++++++++++++++++++++
 srcpkgs/aubio/template              |  2 +-
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/aubio/patches/ffmpeg5.patch

diff --git a/srcpkgs/aubio/patches/ffmpeg5.patch b/srcpkgs/aubio/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..aace41a6e6d9a
--- /dev/null
+++ b/srcpkgs/aubio/patches/ffmpeg5.patch
@@ -0,0 +1,25 @@
+From 8a05420e5dd8c7b8b2447f82dc919765876511b3 Mon Sep 17 00:00:00 2001
+From: Paul Brossier <piem@piem.org>
+Date: Tue, 25 Jan 2022 18:30:27 +0100
+Subject: [PATCH] [source_avcodec] define FF_API_LAVF_AVCTX for libavcodec >
+ 59, thx @berolinux (closes gh-353)
+
+---
+ src/io/source_avcodec.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/io/source_avcodec.c b/src/io/source_avcodec.c
+index e0ae93b5..1421bd9a 100644
+--- a/src/io/source_avcodec.c
++++ b/src/io/source_avcodec.c
+@@ -68,6 +68,10 @@
+ #define AUBIO_AVCODEC_MAX_BUFFER_SIZE AV_INPUT_BUFFER_MIN_SIZE
+ #endif
+ 
++#if LIBAVCODEC_VERSION_MAJOR >= 59
++#define FF_API_LAVF_AVCTX 1
++#endif
++
+ struct _aubio_source_avcodec_t {
+   uint_t hop_size;
+   uint_t samplerate;
diff --git a/srcpkgs/aubio/template b/srcpkgs/aubio/template
index ad1c4b2569917..7d875cc02541a 100644
--- a/srcpkgs/aubio/template
+++ b/srcpkgs/aubio/template
@@ -1,7 +1,7 @@
 # Template file for 'aubio'
 pkgname=aubio
 version=0.4.9
-revision=1
+revision=2
 build_style=waf3
 # XXX lash, pure and swig support.
 hostmakedepends="pkg-config txt2man"

From 6301253ab3753b46afb8432c83bc54af9d86325d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 016/115] audacious-plugins: revbump for ffmpeg-6.0

---
 .../audacious-plugins/patches/ffmpeg5.patch   | 43 +++++++++++++++++++
 srcpkgs/audacious-plugins/template            |  2 +-
 2 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/audacious-plugins/patches/ffmpeg5.patch

diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg5.patch b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..4e5e34099d71c
--- /dev/null
+++ b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
@@ -0,0 +1,43 @@
+commit 298aa371c56c2f52c25a33d9bdec4918b11cebdc
+Author: tibequadorian <tibequadorian@posteo.de>
+Date:   Sat Mar 19 18:40:12 2022 +0100
+
+    audacious-plugins: rebuild against ffmpeg-5.0
+
+diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+new file mode 100644
+index 0000000000..617c11215b
+--- /dev/null
++++ b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+@@ -0,0 +1,31 @@
++From f60beb400eeb1e4778bbfd738bc4a4ccef3de539 Mon Sep 17 00:00:00 2001
++From: John Lindgren <john@jlindgren.net>
++Date: Sat, 5 Mar 2022 12:05:34 -0500
++Subject: [PATCH] Fix build with FFmpeg 5.0
++
++---
++ src/ffaudio/ffaudio-core.cc | 4 ++--
++ 1 file changed, 2 insertions(+), 2 deletions(-)
++
++diff --git a/src/ffaudio/ffaudio-core.cc b/src/ffaudio/ffaudio-core.cc
++index 16dc63e3a..a2b95fd6c 100644
++--- a/src/ffaudio/ffaudio-core.cc
+++++ b/src/ffaudio/ffaudio-core.cc
++@@ -274,7 +274,7 @@ static AVInputFormat * get_format_by_content (const char * name, VFSFile & file)
++         AVProbeData d = {name, buf, filled};
++         score = target;
++ 
++-        f = av_probe_input_format2 (& d, true, & score);
+++        f = (AVInputFormat *) av_probe_input_format2 (& d, true, & score);
++         if (f)
++             break;
++ 
++@@ -347,7 +347,7 @@ static bool find_codec (AVFormatContext * c, CodecInfo * cinfo)
++ #endif
++         if (stream && stream->codecpar && stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
++         {
++-            AVCodec * codec = avcodec_find_decoder (stream->codecpar->codec_id);
+++            AVCodec * codec = (AVCodec *) avcodec_find_decoder (stream->codecpar->codec_id);
++ 
++             if (codec)
++             {
diff --git a/srcpkgs/audacious-plugins/template b/srcpkgs/audacious-plugins/template
index 05e53a9adf78f..4b1968e03de78 100644
--- a/srcpkgs/audacious-plugins/template
+++ b/srcpkgs/audacious-plugins/template
@@ -2,7 +2,7 @@
 #Keep in sync with audacious!
 pkgname=audacious-plugins
 version=4.3.1
-revision=3
+revision=4
 build_style=meson
 configure_args="$(vopt_bool gtk3 gtk) $(vopt_bool gtk3)
  $(vopt_bool qt) $(vopt_bool qt qt6)"

From 04be022c576b9710915c4e5878caca93da85a957 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 017/115] audacity: revbump for ffmpeg4-4.4.3

---
 srcpkgs/audacity/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/audacity/template b/srcpkgs/audacity/template
index 7a8e79ea530cd..df26db1c15873 100644
--- a/srcpkgs/audacity/template
+++ b/srcpkgs/audacity/template
@@ -10,7 +10,7 @@ configure_args="-Daudacity_use_ffmpeg=loaded -Daudacity_lib_preference=system
  -Daudacity_has_vst3=no"
 hostmakedepends="pkg-config gettext python3"
 makedepends="wxWidgets-gtk3-devel gtk+3-devel expat-devel lame-devel
- libsoxr-devel portaudio-devel sqlite-devel libcurl-devel ffmpeg-devel
+ libsoxr-devel portaudio-devel sqlite-devel libcurl-devel ffmpeg4-devel
  libid3tag-devel libmad-devel vamp-plugin-sdk-devel libogg-devel
  libvorbis-devel libflac-devel lilv-devel lv2 serd-devel sord-devel
  sratom-devel suil-devel portmidi-devel soundtouch-devel twolame-devel

From f26916c7fad87f5b58a9e2f83a9fd0161a13f53e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 018/115] avidemux: revbump for ffmpeg-6.0

---
 srcpkgs/avidemux/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/avidemux/template b/srcpkgs/avidemux/template
index 253a0243e2259..557285982d2b8 100644
--- a/srcpkgs/avidemux/template
+++ b/srcpkgs/avidemux/template
@@ -1,7 +1,7 @@
 # Template file for 'avidemux'
 pkgname=avidemux
 version=2.8.0
-revision=2
+revision=3
 # Can't be compiled for aarch64, arm* or mips*
 archs="x86_64* i686*"
 hostmakedepends="cmake pkg-config qt5-host-tools qt5-devel tar yasm"

From 62038a5d8506437002684b40fc8d758b816c9315 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 019/115] blender: revbump for ffmpeg-6.0

---
 srcpkgs/blender/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index 05fdbf8f747e2..093d6d2004e95 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -9,8 +9,8 @@ configure_args="-DWITH_INSTALL_PORTABLE=OFF -DWITH_PYTHON_INSTALL=OFF
  -DWITH_JACK=ON -DWITH_CODEC_FFMPEG=ON -DWITH_CODEC_SNDFILE=ON -DWITH_OPENMP=ON
  -DWITH_FFTW3=ON -DWITH_MOD_OCEANSIM=ON -DWITH_CYCLES_EMBREE=OFF -DWITH_OPENCOLORIO=ON
  -DWITH_IMAGE_OPENEXR=ON -DWITH_IMAGE_OPENJPEG=ON -DWITH_OPENSUBDIV=ON
- -DWITH_OPENCOLLADA=ON -DWITH_SYSTEM_GLEW=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
- -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_LIBDECOR=ON
+ -DWITH_OPENCOLLADA=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
+ -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_WAYLAND_LIBDECOR=ON
  -DWITH_BUILDINFO=OFF -DPYTHON_VERSION=${py3_ver} -DPYTHON_LIBPATH=/usr/lib
  -DPYTHON_LIBRARY=python${py3_ver}${py3_abiver} -DPYTHON_INCLUDE_DIRS=/${py3_inc}
  -DWITH_SYSTEM_LZO=ON -DWITH_SYSTEM_EIGEN3=ON -DWITH_SYSTEM_FREETYPE=ON"

From 0c08b0105eb7ee2578e3fe5115d3fdb2db38d52c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 020/115] cantata: revbump for ffmpeg-6.0

---
 srcpkgs/cantata/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cantata/template b/srcpkgs/cantata/template
index 4b417d80d5c2d..8a90aaa4c07a2 100644
--- a/srcpkgs/cantata/template
+++ b/srcpkgs/cantata/template
@@ -1,7 +1,7 @@
 # Template file for 'cantata'
 pkgname=cantata
 version=2.5.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools qt5-tools"
 makedepends="qt5-devel qt5-tools-devel qt5-svg-devel qt5-xmlpatterns-devel

From 0c53073c61086514674a7b5c64c8cde397600bc7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 021/115] ccextractor: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ccextractor/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/ccextractor/template b/srcpkgs/ccextractor/template
index 9abcd82852b27..6eccad5885af9 100644
--- a/srcpkgs/ccextractor/template
+++ b/srcpkgs/ccextractor/template
@@ -1,12 +1,12 @@
 # Template file for 'ccextractor'
 pkgname=ccextractor
 version=0.93
-revision=1
+revision=2
 build_wrksrc="linux"
 build_style=gnu-configure
 configure_args="--enable-ocr --enable-hardsubx"
 hostmakedepends="automake pkg-config"
-makedepends="leptonica-devel tesseract-ocr-devel ffmpeg-devel"
+makedepends="leptonica-devel tesseract-ocr-devel ffmpeg4-devel"
 short_desc="Extract subtitles from video streams"
 maintainer="newbluemoon <blaumolch@mailbox.org>"
 license="GPL-2.0-or-later"

From 2f3c454363c5e4e29cf95fb3ecc4450a5ac494c3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 022/115] chromaprint: revbump for ffmpeg-6.0

---
 srcpkgs/chromaprint/patches/ffmpeg5.patch | 569 ++++++++++++++++++++++
 srcpkgs/chromaprint/template              |   2 +-
 2 files changed, 570 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromaprint/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromaprint/patches/ffmpeg5.patch b/srcpkgs/chromaprint/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..a9fd307a23c8a
--- /dev/null
+++ b/srcpkgs/chromaprint/patches/ffmpeg5.patch
@@ -0,0 +1,569 @@
+From 8ccad6937177b1b92e40ab8f4447ea27bac009a7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= <lalinsky@gmail.com>
+Date: Fri, 4 Nov 2022 21:47:38 +0100
+Subject: [PATCH] Use FFmpeg 5.x (#120)
+
+* Use FFmpeg 5.1.2 for CI builds
+
+* Build on Ubuntu 20.04
+
+* Upgrade code to FFmpeg 5.x APIs
+
+* Only set FFmpeg include dirs if building tools
+
+* No longer needed
+
+* Use ubuntu 20.04
+---
+ .github/workflows/build.yml                   |   6 +-
+ CMakeLists.txt                                |  16 --
+ package/build.sh                              |   4 +-
+ src/audio/ffmpeg_audio_processor.h            |   2 -
+ src/audio/ffmpeg_audio_processor_avresample.h |  72 -------
+ src/audio/ffmpeg_audio_processor_swresample.h |  18 +-
+ src/audio/ffmpeg_audio_reader.h               | 197 +++++++++---------
+ tests/CMakeLists.txt                          |   6 +
+ 8 files changed, 122 insertions(+), 199 deletions(-)
+ delete mode 100644 src/audio/ffmpeg_audio_processor_avresample.h
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index f8d6a32..4da2405 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -84,9 +84,6 @@ find_package(FFmpeg)
+ if(FFMPEG_LIBRARIES)
+ 	cmake_push_check_state(RESET)
+ 	set(CMAKE_REQUIRED_LIBRARIES ${FFMPEG_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -lm)
+-	check_function_exists(av_packet_unref HAVE_AV_PACKET_UNREF)
+-	check_function_exists(av_frame_alloc HAVE_AV_FRAME_ALLOC)
+-	check_function_exists(av_frame_free HAVE_AV_FRAME_FREE)
+ 	cmake_pop_check_state()
+ endif()
+
+@@ -163,14 +160,11 @@ message(STATUS "Using ${FFT_LIB} for FFT calculations")
+ if(NOT AUDIO_PROCESSOR_LIB)
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+ 		set(AUDIO_PROCESSOR_LIB "swresample")
+-	elseif(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(AUDIO_PROCESSOR_LIB "avresample")
+ 	endif()
+ endif()
+
+ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE OFF)
+ 		set(USE_SWRESAMPLE ON)
+ 		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBSWRESAMPLE_LIBRARIES})
+ 		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBSWRESAMPLE_INCLUDE_DIRS})
+@@ -178,16 +172,6 @@ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+ 	endif()
+ 	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+-elseif(AUDIO_PROCESSOR_LIB STREQUAL "avresample")
+-	if(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE ON)
+-		set(USE_SWRESAMPLE OFF)
+-		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBAVRESAMPLE_LIBRARIES})
+-		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBAVRESAMPLE_INCLUDE_DIRS})
+-	else()
+-		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+-	endif()
+-	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+ else()
+ 	message(STATUS "Building without audio conversion support, please install FFmpeg with libswresample")
+ endif()
+diff --git a/package/build.sh b/package/build.sh
+index da631ae..b41d36e 100755
+--- a/package/build.sh
++++ b/package/build.sh
+@@ -7,8 +7,8 @@ set -eux
+
+ BASE_DIR=$(cd $(dirname $0)/.. && pwd)
+
+-FFMPEG_VERSION=4.4.1
+-FFMPEG_BUILD_TAG=v4.4.1-1
++FFMPEG_VERSION=5.1.2
++FFMPEG_BUILD_TAG=v${FFMPEG_VERSION}-1
+
+ TMP_BUILD_DIR=$BASE_DIR/$(mktemp -d build.XXXXXXXX)
+ trap 'rm -rf $TMP_BUILD_DIR' EXIT
+diff --git a/src/audio/ffmpeg_audio_processor.h b/src/audio/ffmpeg_audio_processor.h
+index 7628fc7..39f4f6d 100644
+--- a/src/audio/ffmpeg_audio_processor.h
++++ b/src/audio/ffmpeg_audio_processor.h
+@@ -10,8 +10,6 @@
+
+ #if defined(USE_SWRESAMPLE)
+ #include "audio/ffmpeg_audio_processor_swresample.h"
+-#elif defined(USE_AVRESAMPLE)
+-#include "audio/ffmpeg_audio_processor_avresample.h"
+ #else
+ #error "no audio processing library"
+ #endif
+diff --git a/src/audio/ffmpeg_audio_processor_avresample.h b/src/audio/ffmpeg_audio_processor_avresample.h
+deleted file mode 100644
+index bd85f92..0000000
+--- a/src/audio/ffmpeg_audio_processor_avresample.h
++++ /dev/null
+@@ -1,72 +0,0 @@
+-// Copyright (C) 2016  Lukas Lalinsky
+-// Distributed under the MIT license, see the LICENSE file for details.
+-
+-#ifndef CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-#define CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-
+-extern "C" {
+-#include <libavresample/avresample.h>
+-}
+-
+-namespace chromaprint {
+-
+-class FFmpegAudioProcessor {
+-public:
+-	FFmpegAudioProcessor() {
+-		m_resample_ctx = avresample_alloc_context();
+-	}
+-
+-	~FFmpegAudioProcessor() {
+-		avresample_free(&m_resample_ctx);
+-	}
+-
+-	void SetCompatibleMode() {
+-		av_opt_set_int(m_resample_ctx, "filter_size", 16, 0);
+-		av_opt_set_int(m_resample_ctx, "phase_shift", 8, 0);
+-		av_opt_set_int(m_resample_ctx, "linear_interp", 1, 0);
+-		av_opt_set_double(m_resample_ctx, "cutoff", 0.8, 0);
+-	}
+-
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "in_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_rate", sample_rate, 0);
+-	}
+-
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "out_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_rate, 0);
+-	}
+-
+-	int Init() {
+-		return avresample_open(m_resample_ctx);
+-	}
+-
+-	int Convert(uint8_t **out, int out_count, const uint8_t **in, int in_count) {
+-		return avresample_convert(m_resample_ctx, out, 0, out_count, (uint8_t **) in, 0, in_count);
+-	}
+-
+-	int Flush(uint8_t **out, int out_count) {
+-		return avresample_read(m_resample_ctx, out, out_count);
+-	}
+-
+-private:
+-	AVAudioResampleContext *m_resample_ctx = nullptr;
+-};
+-
+-}; // namespace chromaprint
+-
+-#endif
+diff --git a/src/audio/ffmpeg_audio_processor_swresample.h b/src/audio/ffmpeg_audio_processor_swresample.h
+index b86266b..b1d4bea 100644
+--- a/src/audio/ffmpeg_audio_processor_swresample.h
++++ b/src/audio/ffmpeg_audio_processor_swresample.h
+@@ -28,30 +28,28 @@ public:
+ 		av_opt_set_double(m_swr_ctx, "cutoff", 0.8, 0);
+ 	}
+
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "icl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "ich", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetInputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "in_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "isf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "in_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "isr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "in_sample_rate", sample_rate, 0);
+ 	}
+
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "ocl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "och", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetOutputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "out_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "osf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "out_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "osr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "out_sample_rate", sample_rate, 0);
+ 	}
+
+ 	int Init() {
+diff --git a/src/audio/ffmpeg_audio_reader.h b/src/audio/ffmpeg_audio_reader.h
+index 5550164..1c6b346 100644
+--- a/src/audio/ffmpeg_audio_reader.h
++++ b/src/audio/ffmpeg_audio_reader.h
+@@ -62,7 +62,7 @@ public:
+ 	bool Read(const int16_t **data, size_t *size);
+
+ 	bool IsOpen() const { return m_opened; }
+-	bool IsFinished() const { return m_finished && !m_got_frame; }
++	bool IsFinished() const { return !m_has_more_packets && !m_has_more_frames; }
+
+ 	std::string GetError() const { return m_error; }
+ 	int GetErrorCode() const { return m_error_code; }
+@@ -74,20 +74,19 @@ private:
+ 	uint8_t *m_convert_buffer[1] = { nullptr };
+ 	int m_convert_buffer_nb_samples = 0;
+
+-	AVInputFormat *m_input_fmt = nullptr;
++	const AVInputFormat *m_input_fmt = nullptr;
+ 	AVDictionary *m_input_opts = nullptr;
+
+ 	AVFormatContext *m_format_ctx = nullptr;
+ 	AVCodecContext *m_codec_ctx = nullptr;
+-	AVFrame *m_frame = nullptr;
+ 	int m_stream_index = -1;
+ 	std::string m_error;
+ 	int m_error_code = 0;
+-	bool m_finished = false;
+ 	bool m_opened = false;
+-	int m_got_frame = 0;
+-	AVPacket m_packet;
+-	AVPacket m_packet0;
++	bool m_has_more_packets = true;
++	bool m_has_more_frames = true;
++	AVPacket *m_packet = nullptr;
++	AVFrame *m_frame = nullptr;
+
+ 	int m_output_sample_rate = 0;
+ 	int m_output_channels = 0;
+@@ -98,19 +97,12 @@ private:
+
+ inline FFmpegAudioReader::FFmpegAudioReader() {
+ 	av_log_set_level(AV_LOG_QUIET);
+-
+-	av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
+ }
+
+ inline FFmpegAudioReader::~FFmpegAudioReader() {
+ 	Close();
+ 	av_dict_free(&m_input_opts);
+ 	av_freep(&m_convert_buffer[0]);
+-	av_packet_unref(&m_packet0);
+ }
+
+ inline bool FFmpegAudioReader::SetInputFormat(const char *name) {
+@@ -135,11 +127,10 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ 	Close();
+
+-    av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
++	m_packet = av_packet_alloc();
++	if (!m_packet) {
++		return false;
++	}
+
+ 	ret = avformat_open_input(&m_format_ctx, file_name.c_str(), m_input_fmt, &m_input_opts);
+ 	if (ret < 0) {
+@@ -153,26 +144,31 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		return false;
+ 	}
+
+-	AVCodec *codec;
++	const AVCodec *codec;
+ 	ret = av_find_best_stream(m_format_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &codec, 0);
+ 	if (ret < 0) {
+ 		SetError("Could not find any audio stream in the file", ret);
+ 		return false;
+ 	}
+ 	m_stream_index = ret;
++	auto stream = m_format_ctx->streams[m_stream_index];
+
+-	m_codec_ctx = m_format_ctx->streams[m_stream_index]->codec;
++	m_codec_ctx = avcodec_alloc_context3(codec);
+ 	m_codec_ctx->request_sample_fmt = AV_SAMPLE_FMT_S16;
+
++	ret = avcodec_parameters_to_context(m_codec_ctx, stream->codecpar);
++	if (ret < 0) {
++		SetError("Could not copy the stream parameters", ret);
++		return false;
++	}
++
+ 	ret = avcodec_open2(m_codec_ctx, codec, nullptr);
+ 	if (ret < 0) {
+ 		SetError("Could not open the codec", ret);
+ 		return false;
+ 	}
+
+-	if (!m_codec_ctx->channel_layout) {
+-		m_codec_ctx->channel_layout = av_get_default_channel_layout(m_codec_ctx->channels);
+-	}
++	av_dump_format(m_format_ctx, 0, "foo", 0);
+
+ 	m_frame = av_frame_alloc();
+ 	if (!m_frame) {
+@@ -183,19 +179,23 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		m_output_sample_rate = m_codec_ctx->sample_rate;
+ 	}
+
+-	if (!m_output_channels) {
+-		m_output_channels = m_codec_ctx->channels;
++	AVChannelLayout output_channel_layout;
++	if (m_output_channels) {
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
++	} else {
++		m_output_channels = m_codec_ctx->ch_layout.nb_channels;
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
+ 	}
+
+-	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
++	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->ch_layout.nb_channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
+ 		m_converter.reset(new FFmpegAudioProcessor());
+ 		m_converter->SetCompatibleMode();
+ 		m_converter->SetInputSampleFormat(m_codec_ctx->sample_fmt);
+ 		m_converter->SetInputSampleRate(m_codec_ctx->sample_rate);
+-		m_converter->SetInputChannelLayout(m_codec_ctx->channel_layout);
++		m_converter->SetInputChannelLayout(&(m_codec_ctx->ch_layout));
+ 		m_converter->SetOutputSampleFormat(AV_SAMPLE_FMT_S16);
+ 		m_converter->SetOutputSampleRate(m_output_sample_rate);
+-		m_converter->SetOutputChannelLayout(av_get_default_channel_layout(m_output_channels));
++		m_converter->SetOutputChannelLayout(&output_channel_layout);
+ 		auto ret = m_converter->Init();
+ 		if (ret != 0) {
+ 			SetError("Could not create an audio converter instance", ret);
+@@ -203,10 +203,11 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		}
+ 	}
+
++	av_channel_layout_uninit(&output_channel_layout);
++
+ 	m_opened = true;
+-	m_finished = false;
+-	m_got_frame = 0;
+-	m_nb_packets = 0;
++	m_has_more_packets = true;
++	m_has_more_frames = true;
+ 	m_decode_error = 0;
+
+ 	return true;
+@@ -214,6 +215,7 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ inline void FFmpegAudioReader::Close() {
+ 	av_frame_free(&m_frame);
++	av_packet_free(&m_packet);
+
+ 	m_stream_index = -1;
+
+@@ -252,91 +254,98 @@ inline bool FFmpegAudioReader::Read(const int16_t **data, size_t *size) {
+ 		return false;
+ 	}
+
++	*data = nullptr;
++	*size = 0;
++
+ 	int ret;
++	bool needs_packet = false;
+ 	while (true) {
+-		while (m_packet.size <= 0) {
+-			av_packet_unref(&m_packet0);
+-			av_init_packet(&m_packet);
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			ret = av_read_frame(m_format_ctx, &m_packet);
++		while (needs_packet && m_packet->size == 0) {
++			ret = av_read_frame(m_format_ctx, m_packet);
+ 			if (ret < 0) {
+ 				if (ret == AVERROR_EOF) {
+-					m_finished = true;
++					needs_packet = false;
++					m_has_more_packets = false;
+ 					break;
+-				} else {
++				}
++				SetError("Error reading from the audio source", ret);
++				return false;
++			}
++			if (m_packet->stream_index == m_stream_index) {
++				needs_packet = false;
++			} else {
++				av_packet_unref(m_packet);
++			}
++		}
++
++		if (m_packet->size != 0) {
++			ret = avcodec_send_packet(m_codec_ctx, m_packet);
++			if (ret < 0) {
++				if (ret != AVERROR(EAGAIN)) {
+ 					SetError("Error reading from the audio source", ret);
+ 					return false;
+ 				}
+-			}
+-			m_packet0 = m_packet;
+-			if (m_packet.stream_index != m_stream_index) {
+-				m_packet.data = nullptr;
+-				m_packet.size = 0;
+ 			} else {
+-				m_nb_packets++;
++				av_packet_unref(m_packet);
+ 			}
+ 		}
+
+-		ret = avcodec_decode_audio4(m_codec_ctx, m_frame, &m_got_frame, &m_packet);
++		ret = avcodec_receive_frame(m_codec_ctx, m_frame);
+ 		if (ret < 0) {
+-			if (m_decode_error) {
+-				SetError("Error decoding audio frame", m_decode_error);
+-				return false;
++			if (ret == AVERROR_EOF) {
++				m_has_more_frames = false;
++			} else if (ret == AVERROR(EAGAIN)) {
++				if (m_has_more_packets) {
++					needs_packet = true;
++					continue;
++				} else {
++					m_has_more_frames = false;
++				}
+ 			}
+-			m_decode_error = ret;
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			continue;
++			SetError("Error decoding the audio source", ret);
++			return false;
+ 		}
+
+-		break;
+-	}
+-
+-	m_decode_error = 0;
+-
+-	const int decoded = std::min(ret, m_packet.size);
+-	m_packet.data += decoded;
+-	m_packet.size -= decoded;
+-
+-	if (m_got_frame) {
+-		if (m_converter) {
+-			if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
+-				int linsize;
+-				av_freep(&m_convert_buffer[0]);
+-				m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
+-				ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
+-				if (ret < 0) {
+-					SetError("Couldn't allocate audio converter buffer", ret);
++		if (m_frame->nb_samples > 0) {
++			if (m_converter) {
++				if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
++					int linsize;
++					av_freep(&m_convert_buffer[0]);
++					m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
++					ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->ch_layout.nb_channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
++					if (ret < 0) {
++						SetError("Couldn't allocate audio converter buffer", ret);
++						return false;
++					}
++				}
++				auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
++				if (nb_samples < 0) {
++					SetError("Couldn't convert audio", ret);
+ 					return false;
+ 				}
+-			}
+-			auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			}
+-			*data = (const int16_t *) m_convert_buffer[0];
+-			*size = nb_samples;
+-		} else {
+-			*data = (const int16_t *) m_frame->data[0];
+-			*size = m_frame->nb_samples;
+-		}
+-	} else {
+-		if (m_finished && m_converter) {
+-			auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			} else if (nb_samples > 0) {
+-				m_got_frame = 1;
+ 				*data = (const int16_t *) m_convert_buffer[0];
+ 				*size = nb_samples;
++			} else {
++				*data = (const int16_t *) m_frame->data[0];
++				*size = m_frame->nb_samples;
++			}
++		} else {
++			if (m_converter) {
++				if (IsFinished()) {
++					auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
++					if (nb_samples < 0) {
++						SetError("Couldn't convert audio", ret);
++						return false;
++					} else if (nb_samples > 0) {
++						*data = (const int16_t *) m_convert_buffer[0];
++						*size = nb_samples;
++					}
++				}
+ 			}
+ 		}
+-	}
+
+-	return true;
++		return true;
++	}
+ }
+
+ inline void FFmpegAudioReader::SetError(const char *message, int errnum) {
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index a2b517b..123e643 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -38,6 +38,12 @@ set(SRCS
+
+ if(BUILD_TOOLS)
+ 	set(SRCS ${SRCS} ../src/audio/ffmpeg_audio_reader_test.cpp)
++    include_directories(
++        ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}
++        ${AUDIO_PROCESSOR_INCLUDE_DIRS}
++    )
+ 	link_libraries(fpcalc_libs)
+ endif()
+
+-- 
+2.38.1
+
+
diff --git a/srcpkgs/chromaprint/template b/srcpkgs/chromaprint/template
index 7ef7838949f3a..1f7bbc70a22c8 100644
--- a/srcpkgs/chromaprint/template
+++ b/srcpkgs/chromaprint/template
@@ -1,7 +1,7 @@
 # Template file for 'chromaprint'
 pkgname=chromaprint
 version=1.5.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DBUILD_TOOLS=ON"
 make_check_target="check"

From 759828be3ca375013d33e5519190813257e76d76 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 023/115] chromium: revbump for ffmpeg-6.0

---
 .../patches/chromium-119-ffmpeg-4.4.patch     | 20 --------
 srcpkgs/chromium/patches/ffmpeg5.patch        | 47 +++++++++++++++++++
 srcpkgs/chromium/template                     |  2 +-
 3 files changed, 48 insertions(+), 21 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch
 create mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch b/srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch
deleted file mode 100644
index 04d04b166ba37..0000000000000
--- a/srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch
+++ /dev/null
@@ -1,20 +0,0 @@
---- a/media/filters/ffmpeg_demuxer.cc.orig
-+++ b/media/filters/ffmpeg_demuxer.cc
-@@ -390,7 +390,7 @@
- 
-   scoped_refptr<DecoderBuffer> buffer;
- 
--    size_t side_data_size = 0;
-+    int side_data_size = 0;
-     uint8_t* side_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
- 
-@@ -453,7 +453,7 @@
-                                        packet->size - data_offset);
-     }
- 
--    size_t skip_samples_size = 0;
-+    int skip_samples_size = 0;
-     const uint32_t* skip_samples_ptr =
-         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
-             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..24e2da38e34ca
--- /dev/null
+++ b/srcpkgs/chromium/patches/ffmpeg5.patch
@@ -0,0 +1,47 @@
+--- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
++++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
+@@ -92,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+-  if (stream->start_time != kNoFFmpegTimestamp)
++  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -1597,7 +1585,7 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+@@ -1618,7 +1606,7 @@
+     if (stream->type() != DemuxerStream::VIDEO)
+       continue;
+ 
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+ 
+     if (!stream->IsEnabled())
diff --git a/srcpkgs/chromium/template b/srcpkgs/chromium/template
index b023946f3ec7b..fe36a6dce20d3 100644
--- a/srcpkgs/chromium/template
+++ b/srcpkgs/chromium/template
@@ -2,7 +2,7 @@
 pkgname=chromium
 # See https://chromiumdash.appspot.com/releases?platform=Linux for the latest version
 version=119.0.6045.105
-revision=3
+revision=4
 archs="i686* x86_64* aarch64* armv7l*"
 hostmakedepends="
  $(vopt_if clang "clang lld llvm15")

From 573b5dd17b4f04e33b6064c175ce0590c68f18c8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 024/115] cmus: revbump for ffmpeg-6.0

---
 srcpkgs/chromium/patches/ffmpeg5.patch | 47 --------------------------
 srcpkgs/cmus/patches/ffmpeg6.patch     | 12 +++++++
 srcpkgs/cmus/template                  |  2 +-
 3 files changed, 13 insertions(+), 48 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch
 create mode 100644 srcpkgs/cmus/patches/ffmpeg6.patch

diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
deleted file mode 100644
index 24e2da38e34ca..0000000000000
--- a/srcpkgs/chromium/patches/ffmpeg5.patch
+++ /dev/null
@@ -1,47 +0,0 @@
---- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
-+++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
-@@ -92,24 +92,12 @@
- 
- static base::TimeDelta ExtractStartTime(AVStream* stream) {
-   // The default start time is zero.
--  base::TimeDelta start_time;
-+  base::TimeDelta start_time = kNoTimestamp;
- 
-   // First try to use  the |start_time| value as is.
--  if (stream->start_time != kNoFFmpegTimestamp)
-+  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
-     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
- 
--  // Next try to use the first DTS value, for codecs where we know PTS == DTS
--  // (excludes all H26x codecs). The start time must be returned in PTS.
--  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
--      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
--      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
--      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
--    const base::TimeDelta first_pts =
--        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
--    if (first_pts < start_time)
--      start_time = first_pts;
--  }
--
-   return start_time;
- }
- 
-@@ -1597,7 +1585,7 @@
-   for (const auto& stream : streams_) {
-     if (!stream || stream->IsEnabled() != enabled)
-       continue;
--    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
-+    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
-       continue;
-     if (!lowest_start_time_stream ||
-         stream->start_time() < lowest_start_time_stream->start_time()) {
-@@ -1618,7 +1606,7 @@
-     if (stream->type() != DemuxerStream::VIDEO)
-       continue;
- 
--    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
-+    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
-       continue;
- 
-     if (!stream->IsEnabled())
diff --git a/srcpkgs/cmus/patches/ffmpeg6.patch b/srcpkgs/cmus/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..ffa95ab811101
--- /dev/null
+++ b/srcpkgs/cmus/patches/ffmpeg6.patch
@@ -0,0 +1,12 @@
+--- a/ip/ffmpeg.c
++++ b/ip/ffmpeg.c
+@@ -202,9 +202,6 @@ static int ffmpeg_open(struct input_plugin_data *ip_data)
+ 			break;
+ 		}
+ 
+-		if (codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+-			cc->flags |= AV_CODEC_FLAG_TRUNCATED;
+-
+ 		if (avcodec_open2(cc, codec, NULL) < 0) {
+ 			d_print("could not open codec: %d, %s\n", cc->codec_id, avcodec_get_name(cc->codec_id));
+ 			err = -IP_ERROR_UNSUPPORTED_FILE_TYPE;
diff --git a/srcpkgs/cmus/template b/srcpkgs/cmus/template
index 0d1436744f1b2..a6e4b4fa86cb8 100644
--- a/srcpkgs/cmus/template
+++ b/srcpkgs/cmus/template
@@ -1,7 +1,7 @@
 # Template file for 'cmus'
 pkgname=cmus
 version=2.10.0
-revision=3
+revision=4
 build_style=configure
 configure_args="prefix=/usr LD=$CC"
 hostmakedepends="pkg-config"

From a725115102c2bd95671039b59eb9af736c5b0785 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 025/115] cyanrip: revbump for ffmpeg-6.0

---
 srcpkgs/cyanrip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cyanrip/template b/srcpkgs/cyanrip/template
index 9796e3461601a..5db30e020d17e 100644
--- a/srcpkgs/cyanrip/template
+++ b/srcpkgs/cyanrip/template
@@ -1,7 +1,7 @@
 # Template file for 'cyanrip'
 pkgname=cyanrip
 version=0.9.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config"
 makedepends="ffmpeg-devel libcdio-devel libcdio-paranoia-devel libcurl-devel libmusicbrainz5-devel"

From 681641732436f0ce22741bf0388d34a3dfe0cc16 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 026/115] deadbeef: revbump for ffmpeg4-4.4.3

---
 srcpkgs/deadbeef/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/deadbeef/template b/srcpkgs/deadbeef/template
index f5f4bf24b8cb6..7b47e615cd48e 100644
--- a/srcpkgs/deadbeef/template
+++ b/srcpkgs/deadbeef/template
@@ -1,14 +1,14 @@
 # Template file for 'deadbeef'
 pkgname=deadbeef
 version=1.8.8
-revision=3
+revision=4
 create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-oss --disable-lfm --disable-notify --disable-gtk2"
 hostmakedepends="automake libtool gettext gettext-devel intltool pkg-config
  yasm clang glib-devel"
 makedepends="
- alsa-lib-devel dbus-devel faad2-devel ffmpeg-devel gtk+3-devel imlib2-devel
+ alsa-lib-devel dbus-devel faad2-devel ffmpeg4-devel gtk+3-devel imlib2-devel
  jansson-devel libcddb-devel libcdio-devel libcurl-devel libflac-devel
  libmad-devel libpng-devel libsamplerate-devel libsndfile-devel libvorbis-devel
  libzip-devel mpg123-devel opusfile-devel pulseaudio-devel wavpack-devel"

From bb4b115d3efbc70095823c3bba462c763811ca9b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 027/115] droidcam-obs-plugin: revbump for ffmpeg-6.0

---
 srcpkgs/droidcam-obs-plugin/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam-obs-plugin/template b/srcpkgs/droidcam-obs-plugin/template
index fc9c9bf6b9d54..fb0480754df4d 100644
--- a/srcpkgs/droidcam-obs-plugin/template
+++ b/srcpkgs/droidcam-obs-plugin/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam-obs-plugin'
 pkgname=droidcam-obs-plugin
 version=2.0.1
-revision=1
+revision=2
 build_style=gnu-makefile
 make_use_env=yes
 make_build_args="ALLOW_STATIC=no"

From cd9b6d6668c86d747e4d6d5e42fa7864bf6ac6cb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 028/115] droidcam: revbump for ffmpeg-6.0

---
 srcpkgs/droidcam/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam/template b/srcpkgs/droidcam/template
index 1c3f1b8b1fc67..32a9220b79a4d 100644
--- a/srcpkgs/droidcam/template
+++ b/srcpkgs/droidcam/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam'
 pkgname=droidcam
 version=1.8.2
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="USBMUXD=-lusbmuxd-2.0 JPEG=-lturbojpeg"
 hostmakedepends="pkg-config"

From 9b1941f1e327a97f85703b1d50dd12afa7e1397e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 029/115] ffmpegthumbnailer: revbump for ffmpeg-6.0

---
 .../ffmpegthumbnailer/patches/ffmpeg6.patch   | 202 ++++++++++++++++++
 srcpkgs/ffmpegthumbnailer/template            |   6 +-
 2 files changed, 205 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch

diff --git a/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..363ff35a28419
--- /dev/null
+++ b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
@@ -0,0 +1,202 @@
+--- a/libffmpegthumbnailer/moviedecoder.cpp	2017-11-21 14:06:57.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.cpp	2023-05-05 13:14:47.946560668 -0400
+@@ -41,11 +41,6 @@
+ namespace ffmpegthumbnailer
+ {
+ 
+-struct SilenceLogLevel
+-{
+-    SilenceLogLevel() { av_log_set_level(AV_LOG_QUIET); }
+-};
+-
+ MovieDecoder::MovieDecoder(AVFormatContext* pavContext)
+ : m_VideoStream(-1)
+ , m_pFormatContext(pavContext)
+@@ -70,8 +65,6 @@
+ 
+ void MovieDecoder::initialize(const string& filename, bool preferEmbeddedMetadata)
+ {
+-    av_register_all();
+-    avcodec_register_all();
+     avformat_network_init();
+ 
+     string inputFile = filename == "-" ? "pipe:" : filename;
+@@ -97,8 +90,7 @@
+ {
+     if (m_pVideoCodecContext)
+     {
+-        avcodec_close(m_pVideoCodecContext);
+-        m_pVideoCodecContext = nullptr;
++        avcodec_free_context(&m_pVideoCodecContext);
+     }
+ 
+     if ((!m_FormatContextWasGiven) && m_pFormatContext)
+@@ -152,10 +144,10 @@
+     for (unsigned int i = 0; i < m_pFormatContext->nb_streams; ++i)
+     {
+         AVStream *stream = m_pFormatContext->streams[i];
+-        auto ctx = m_pFormatContext->streams[i]->codec;
+-        if (ctx->codec_type == AVMEDIA_TYPE_VIDEO)
++        auto par = m_pFormatContext->streams[i]->codecpar;
++        if (par->codec_type == AVMEDIA_TYPE_VIDEO)
+         {
+-            if (!preferEmbeddedMetadata || !isStillImageCodec(ctx->codec_id))
++            if (!preferEmbeddedMetadata || !isStillImageCodec(par->codec_id))
+             {
+                 videoStreams.push_back(i);
+                 continue;
+@@ -203,8 +195,7 @@
+     }
+ 
+     m_pVideoStream = m_pFormatContext->streams[m_VideoStream];
+-    m_pVideoCodecContext = m_pVideoStream->codec;
+-    m_pVideoCodec = avcodec_find_decoder(m_pVideoCodecContext->codec_id);
++    m_pVideoCodec = avcodec_find_decoder(m_pVideoStream->codecpar->codec_id);
+ 
+     if (m_pVideoCodec == nullptr)
+     {
+@@ -214,6 +205,20 @@
+         throw logic_error("Video Codec not found");
+     }
+ 
++    m_pVideoCodecContext = avcodec_alloc_context3(m_pVideoCodec);
++
++    if (m_pVideoCodecContext == nullptr)
++    {
++        destroy();
++        throw logic_error("Could not allocate video codec context");
++    }
++
++    if (avcodec_parameters_to_context(m_pVideoCodecContext, m_pVideoStream->codecpar) < 0)
++    {
++        destroy();
++        throw logic_error("Could not configure video codec context");
++    }
++
+     m_pVideoCodecContext->workaround_bugs = 1;
+ 
+     if (avcodec_open2(m_pVideoCodecContext, m_pVideoCodec, nullptr) < 0)
+@@ -386,13 +391,6 @@
+ 
+ void MovieDecoder::initializeFilterGraph(const AVRational& timeBase, const std::string& size, bool maintainAspectRatio)
+ {
+-    static const AVPixelFormat pixelFormats[] = { AV_PIX_FMT_RGB24, AV_PIX_FMT_NONE };
+-
+-    auto del = [] (AVBufferSinkParams* p) { av_freep(p); };
+-    std::unique_ptr<AVBufferSinkParams, decltype(del)> buffersinkParams(av_buffersink_params_alloc(), del);
+-
+-    avfilter_register_all();
+-
+     m_pFilterGraph = avfilter_graph_alloc();
+     assert(m_pFilterGraph);
+ 
+@@ -404,10 +402,8 @@
+ 
+     checkRc(avfilter_graph_create_filter(&m_pFilterSource, avfilter_get_by_name("buffer"), "thumb_buffer", ss.str().c_str(), nullptr, m_pFilterGraph),
+             "Failed to create filter source");
+-    buffersinkParams->pixel_fmts = pixelFormats;
+-    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, buffersinkParams.get(), m_pFilterGraph),
++    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, nullptr, m_pFilterGraph),
+             "Failed to create filter sink");
+-    buffersinkParams.release();
+ 
+     AVFilterContext* yadifFilter = nullptr;
+     if (m_pFrame->interlaced_frame != 0)
+@@ -500,15 +496,15 @@
+     }
+ 
+     checkRc(av_seek_frame(m_pFormatContext, -1, timestamp, 0), "Seeking in video failed");
+-    avcodec_flush_buffers(m_pFormatContext->streams[m_VideoStream]->codec);
++    avcodec_flush_buffers(m_pVideoCodecContext);
+ 
+     int keyFrameAttempts = 0;
+-    bool gotFrame = 0;
++    bool gotFrame;
+ 
+     do
+     {
+         int count = 0;
+-        gotFrame = 0;
++        gotFrame = false;
+ 
+         while (!gotFrame && count < 20)
+         {
+@@ -552,17 +548,33 @@
+         return false;
+     }
+ 
+-    av_frame_unref(m_pFrame);
+-
+-    int frameFinished;
++    int rc = avcodec_send_packet(m_pVideoCodecContext, m_pPacket);
++    if(rc == AVERROR(EAGAIN))
++    {
++        rc = 0;
++    }
+ 
+-    int bytesDecoded = avcodec_decode_video2(m_pVideoCodecContext, m_pFrame, &frameFinished, m_pPacket);
+-    if (bytesDecoded < 0)
++    if(rc == AVERROR_EOF)
++    {
++        return false;
++    }
++    else if(rc < 0)
+     {
+-        throw logic_error("Failed to decode video frame: bytesDecoded < 0");
++        throw logic_error("Failed to decode video frame: avcodec_send_packet() < 0");
+     }
+ 
+-    return frameFinished > 0;
++    rc = avcodec_receive_frame(m_pVideoCodecContext, m_pFrame);
++    switch(rc)
++    {
++        case 0:
++            return true;
++
++        case AVERROR(EAGAIN):
++            return false;
++
++        default:
++            throw logic_error("Failed to decode video frame: avcodec_receive_frame() < 0");
++    }
+ }
+ 
+ bool MovieDecoder::getVideoPacket()
+@@ -570,8 +582,6 @@
+     bool framesAvailable = true;
+     bool frameDecoded = false;
+ 
+-    int attempts = 0;
+-
+     if (m_pPacket)
+     {
+         av_packet_unref(m_pPacket);
+@@ -580,6 +590,7 @@
+ 
+     m_pPacket = new AVPacket();
+ 
++
+     while (framesAvailable && !frameDecoded)
+     {
+         framesAvailable = av_read_frame(m_pFormatContext, m_pPacket) >= 0;
+@@ -644,7 +655,7 @@
+ 
+ int32_t MovieDecoder::getStreamRotation()
+ {
+-    int32_t* matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
++    auto matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
+     if (matrix)
+     {
+         auto angle = lround(av_display_rotation_get(matrix));
+
+--- a/libffmpegthumbnailer/moviedecoder.h	2017-11-12 04:23:38.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.h	2023-05-05 13:26:07.095529911 -0400
+@@ -78,7 +78,7 @@
+     int                     m_VideoStream;
+     AVFormatContext*        m_pFormatContext;
+     AVCodecContext*         m_pVideoCodecContext;
+-    AVCodec*                m_pVideoCodec;
++    const AVCodec*          m_pVideoCodec;
+     AVFilterGraph*          m_pFilterGraph;
+     AVFilterContext*        m_pFilterSource;
+     AVFilterContext*        m_pFilterSink;
diff --git a/srcpkgs/ffmpegthumbnailer/template b/srcpkgs/ffmpegthumbnailer/template
index 039eea7622b39..35d546018d12a 100644
--- a/srcpkgs/ffmpegthumbnailer/template
+++ b/srcpkgs/ffmpegthumbnailer/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbnailer'
 pkgname=ffmpegthumbnailer
 version=2.2.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libpng-devel libjpeg-turbo-devel ffmpeg-devel"
@@ -9,8 +9,8 @@ depends="ffmpeg"
 short_desc="Lightweight video thumbnailer"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
-homepage="https://github.com/dirkvdb/${pkgname}"
-distfiles="${homepage}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
+homepage="https://github.com/dirkvdb"
+distfiles="${homepage}/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
 checksum=1cb24059c38223f657b300c84dd80491b7040d4b69471c4fea69be862bc99b5b
 
 post_install() {

From 7961cff3e4631dcb261b72f0352d28f542eda089 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 030/115] ffmpegthumbs: revbump for ffmpeg-6.0

---
 srcpkgs/ffmpegthumbs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ffmpegthumbs/template b/srcpkgs/ffmpegthumbs/template
index 5f0b9414dadaf..11b88193528f4 100644
--- a/srcpkgs/ffmpegthumbs/template
+++ b/srcpkgs/ffmpegthumbs/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbs'
 pkgname=ffmpegthumbs
 version=22.12.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules kcoreaddons kconfig-devel
  pkg-config qt5-host-tools qt5-qmake gettext"

From 943f2e4f7e3ac6edfc803f01a4f3cba038e3749c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 031/115] ffms2: revbump for ffmpeg-6.0

---
 srcpkgs/ffms2/patches/ffmpeg5.patch | 424 ++++++++++++++++++++++++++++
 srcpkgs/ffms2/template              |   2 +-
 2 files changed, 425 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ffms2/patches/ffmpeg5.patch

diff --git a/srcpkgs/ffms2/patches/ffmpeg5.patch b/srcpkgs/ffms2/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..1479fabcafcb4
--- /dev/null
+++ b/srcpkgs/ffms2/patches/ffmpeg5.patch
@@ -0,0 +1,424 @@
+From 45673149e9a2f5586855ad472e3059084eaa36b1 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:41:21 +0100
+Subject: [PATCH] Use auto for AVCodec
+
+The geniuses over at FFmpeg decided to constify this API, so old
+versions of the library will return AVCodec *, while new versions
+of the libary will return const AVCodec *, which, in C++, are not
+OK to convert between.
+
+Rather than use some macro hell in ffmscompat.h, we can work around
+this by using auto.
+
+Gross.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 2 +-
+ src/core/indexing.cpp    | 6 +++---
+ src/core/videosource.cpp | 2 +-
+ 3 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index e4ce97c..ac09666 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -469,7 +469,7 @@ void FFMS_AudioSource::OpenFile() {
+ 
+     LAVFOpenFile(SourceFile.c_str(), FormatContext, TrackNumber);
+ 
+-    AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
++    auto *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
+     if (Codec == nullptr)
+         throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+             "Audio codec not found");
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index e547c5a..59fb4e8 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -384,7 +384,7 @@ FFMS_TrackType FFMS_Indexer::GetTrackType(int Track) {
+ }
+ 
+ const char *FFMS_Indexer::GetTrackCodec(int Track) {
+-    AVCodec *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
++    auto *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
+     return codec ? codec->name : nullptr;
+ }
+ 
+@@ -402,7 +402,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             UseDTS);
+ 
+         if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            AVCodec *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (!VideoCodec) {
+                 FormatContext->streams[i]->discard = AVDISCARD_ALL;
+                 IndexMask.erase(i);
+@@ -433,7 +433,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 IndexMask.insert(i);
+             }
+         } else if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+-            AVCodec *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (AudioCodec == nullptr)
+                 throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_UNSUPPORTED,
+                     "Audio codec not found");
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index b889970..8956c22 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -171,7 +171,7 @@ FFMS_VideoSource::FFMS_VideoSource(const char *SourceFile, FFMS_Index &Index, in
+ 
+         LAVFOpenFile(SourceFile, FormatContext, VideoTrack);
+ 
+-        AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
++        auto *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
+         if (Codec == nullptr)
+             throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+                 "Video codec not found");
+-- 
+2.40.0
+
+From 96cbf38ea9381829a1314f432a2c60495dcefaad Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:12:41 +0100
+Subject: [PATCH] all: Update AVPacket API usage
+
+AVPackets must all be on the heap now, since it is no longer
+part of the libav* ABI.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 16 ++++++----
+ src/core/indexing.cpp    | 63 ++++++++++++++++++++++------------------
+ src/core/indexing.h      |  4 +--
+ src/core/utils.cpp       |  6 ----
+ src/core/utils.h         |  1 -
+ src/core/videosource.cpp | 30 ++++++++++---------
+ 6 files changed, 64 insertions(+), 56 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index 37cf9ae..e4ce97c 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -285,10 +285,15 @@ FFMS_AudioSource::AudioBlock *FFMS_AudioSource::CacheBlock(CacheIterator &pos) {
+ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     CurrentFrame = &Frames[PacketNumber];
+ 
+-    AVPacket Packet;
+-    if (!ReadPacket(&Packet))
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++    if (!ReadPacket(Packet)) {
++        av_packet_free(&Packet);
+         throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_UNKNOWN,
+             "ReadPacket unexpectedly failed to read a packet");
++    }
+ 
+     // ReadPacket may have changed the packet number
+     CurrentFrame = &Frames[PacketNumber];
+@@ -297,8 +302,9 @@ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     int NumberOfSamples = 0;
+     AudioBlock *CachedBlock = nullptr;
+     
+-    int Ret = avcodec_send_packet(CodecContext, &Packet);
+-    av_packet_unref(&Packet);
++    int Ret = avcodec_send_packet(CodecContext, Packet);
++    av_packet_unref(Packet);
++    av_packet_free(&Packet);
+ 
+     av_frame_unref(DecodeFrame);
+     Ret = avcodec_receive_frame(CodecContext, DecodeFrame);
+@@ -513,8 +519,6 @@ void FFMS_AudioSource::Seek() {
+ }
+ 
+ bool FFMS_AudioSource::ReadPacket(AVPacket *Packet) {
+-    InitNullPacket(*Packet);
+-
+     while (av_read_frame(FormatContext, Packet) >= 0) {
+         if (Packet->stream_index == TrackNumber) {
+             // Required because not all audio packets, especially in ogg, have a pts. Use the previous valid packet's pts instead.
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index 23fb95b..e547c5a 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -320,7 +320,7 @@ void FFMS_Indexer::CheckAudioProperties(int Track, AVCodecContext *Context) {
+     }
+ }
+ 
+-void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict,
++void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict,
+                                     int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct) {
+     if (VideoContext.Parser) {
+         uint8_t *OB;
+@@ -330,8 +330,8 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+         av_parser_parse2(VideoContext.Parser,
+             VideoContext.CodecContext,
+             &OB, &OBSize,
+-            pkt.data, pkt.size,
+-            pkt.pts, pkt.dts, pkt.pos);
++            pkt->data, pkt->size,
++            pkt->pts, pkt->dts, pkt->pos);
+ 
+         // H.264 (PAFF) and HEVC may have one field per packet, so we need to track
+         // when we have a full or half frame available, and mark one of them as
+@@ -351,15 +351,15 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+ 
+         *RepeatPict = VideoContext.Parser->repeat_pict;
+         *FrameType = VideoContext.Parser->pict_type;
+-        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt.flags & AV_PKT_FLAG_DISCARD));
++        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt->flags & AV_PKT_FLAG_DISCARD));
+     } else {
+-        *Invisible = !!(pkt.flags & AV_PKT_FLAG_DISCARD);
++        *Invisible = !!(pkt->flags & AV_PKT_FLAG_DISCARD);
+     }
+ 
+     if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP8)
+-        ParseVP8(pkt.data[0], Invisible, FrameType);
++        ParseVP8(pkt->data[0], Invisible, FrameType);
+     else if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP9)
+-        ParseVP9(pkt.data[0], Invisible, FrameType);
++        ParseVP9(pkt->data[0], Invisible, FrameType);
+ }
+ 
+ void FFMS_Indexer::Free() {
+@@ -458,32 +458,36 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+         }
+     }
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
+     std::vector<int64_t> LastValidTS(FormatContext->nb_streams, AV_NOPTS_VALUE);
+ 
+     int64_t filesize = avio_size(FormatContext->pb);
+     enum AVPictureStructure LastPicStruct = AV_PICTURE_STRUCTURE_UNKNOWN;
+-    while (av_read_frame(FormatContext, &Packet) >= 0) {
++    while (av_read_frame(FormatContext, Packet) >= 0) {
+         // Update progress
+         // FormatContext->pb can apparently be NULL when opening images.
+         if (IC && FormatContext->pb) {
+-            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate))
++            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate)) {
++                av_packet_free(&Packet);
+                 throw FFMS_Exception(FFMS_ERROR_CANCELLED, FFMS_ERROR_USER,
+                     "Cancelled by user");
++            }
+         }
+-        if (!IndexMask.count(Packet.stream_index)) {
+-            av_packet_unref(&Packet);
++        if (!IndexMask.count(Packet->stream_index)) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+-        int Track = Packet.stream_index;
++        int Track = Packet->stream_index;
+         FFMS_Track &TrackInfo = (*TrackIndices)[Track];
+-        bool KeyFrame = !!(Packet.flags & AV_PKT_FLAG_KEY);
++        bool KeyFrame = !!(Packet->flags & AV_PKT_FLAG_KEY);
+         ReadTS(Packet, LastValidTS[Track], (*TrackIndices)[Track].UseDTS);
+ 
+         if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            int64_t PTS = TrackInfo.UseDTS ? Packet.dts : Packet.pts;
++            int64_t PTS = TrackInfo.UseDTS ? Packet->dts : Packet->pts;
+             if (PTS == AV_NOPTS_VALUE) {
+                 // VPx alt-refs are output as packets which lack timestmps or durations, since
+                 // they are invisible. Currently, the timestamp mangling code in libavformat
+@@ -495,9 +499,11 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 // FFMS2 currently sorts packets by PTS, which will break decoding, otherwise.
+                 bool HasAltRefs = (FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP8 ||
+                                    FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP9);
+-                if (Packet.duration == 0 && !HasAltRefs)
++                if (Packet->duration == 0 && !HasAltRefs) {
++                    av_packet_free(&Packet);
+                     throw FFMS_Exception(FFMS_ERROR_INDEXING, FFMS_ERROR_PARSER,
+                         "Invalid packet pts, dts, and duration");
++                }
+ 
+                 if (TrackInfo.empty())
+                     PTS = 0;
+@@ -513,7 +519,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             ParseVideoPacket(AVContexts[Track], Packet, &RepeatPict, &FrameType, &Invisible, &LastPicStruct);
+ 
+             TrackInfo.AddVideoFrame(PTS, RepeatPict, KeyFrame,
+-                FrameType, Packet.pos, Invisible);
++                FrameType, Packet->pos, Invisible);
+         } else if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+             // For video seeking timestamps are used only if all packets have
+             // timestamps, while for audio they're used if any have timestamps,
+@@ -522,28 +528,29 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 TrackInfo.HasTS = true;
+ 
+             int64_t StartSample = AVContexts[Track].CurrentSample;
+-            uint32_t SampleCount = IndexAudioPacket(Track, &Packet, AVContexts[Track], *TrackIndices);
++            uint32_t SampleCount = IndexAudioPacket(Track, Packet, AVContexts[Track], *TrackIndices);
+             TrackInfo.SampleRate = AVContexts[Track].CodecContext->sample_rate;
+ 
+             TrackInfo.AddAudioFrame(LastValidTS[Track],
+-                StartSample, SampleCount, KeyFrame, Packet.pos, Packet.flags & AV_PKT_FLAG_DISCARD);
++                StartSample, SampleCount, KeyFrame, Packet->pos, Packet->flags & AV_PKT_FLAG_DISCARD);
+         }
+ 
+-        if (!(Packet.flags & AV_PKT_FLAG_DISCARD))
+-            TrackInfo.LastDuration = Packet.duration;
++        if (!(Packet->flags & AV_PKT_FLAG_DISCARD))
++            TrackInfo.LastDuration = Packet->duration;
+ 
+-        av_packet_unref(&Packet);
++        av_packet_unref(Packet);
+     }
++    av_packet_free(&Packet);
+ 
+     TrackIndices->Finalize(AVContexts, FormatContext->iformat->name);
+     return TrackIndices.release();
+ }
+ 
+-void FFMS_Indexer::ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS) {
+-    if (!UseDTS && Packet.pts != AV_NOPTS_VALUE)
+-        TS = Packet.pts;
++void FFMS_Indexer::ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS) {
++    if (!UseDTS && Packet->pts != AV_NOPTS_VALUE)
++        TS = Packet->pts;
+     if (TS == AV_NOPTS_VALUE)
+         UseDTS = true;
+-    if (UseDTS && Packet.dts != AV_NOPTS_VALUE)
+-        TS = Packet.dts;
++    if (UseDTS && Packet->dts != AV_NOPTS_VALUE)
++        TS = Packet->dts;
+ }
+diff --git a/src/core/indexing.h b/src/core/indexing.h
+index 3cfc3c3..5c06868 100644
+--- a/src/core/indexing.h
++++ b/src/core/indexing.h
+@@ -80,10 +80,10 @@ private:
+     int64_t Filesize;
+     uint8_t Digest[20];
+ 
+-    void ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS);
++    void ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS);
+     void CheckAudioProperties(int Track, AVCodecContext *Context);
+     uint32_t IndexAudioPacket(int Track, AVPacket *Packet, SharedAVContext &Context, FFMS_Index &TrackIndices);
+-    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
++    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
+     void Free();
+ public:
+     FFMS_Indexer(const char *Filename);
+diff --git a/src/core/utils.cpp b/src/core/utils.cpp
+index ce67533..8a2e997 100644
+--- a/src/core/utils.cpp
++++ b/src/core/utils.cpp
+@@ -62,12 +62,6 @@ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo) {
+     }
+ }
+ 
+-void InitNullPacket(AVPacket &pkt) {
+-    av_init_packet(&pkt);
+-    pkt.data = nullptr;
+-    pkt.size = 0;
+-}
+-
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames) {
+     AP.SampleFormat = static_cast<FFMS_SampleFormat>(av_get_packed_sample_fmt(CTX->sample_fmt));
+     AP.BitsPerSample = av_get_bytes_per_sample(CTX->sample_fmt) * 8;
+diff --git a/src/core/utils.h b/src/core/utils.h
+index 9819dc7..003ab79 100644
+--- a/src/core/utils.h
++++ b/src/core/utils.h
+@@ -58,7 +58,6 @@ std::unique_ptr<T> make_unique(Args&&... args) {
+ }
+ 
+ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo);
+-void InitNullPacket(AVPacket &pkt);
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames);
+ 
+ void LAVFOpenFile(const char *SourceFile, AVFormatContext *&FormatContext, int Track);
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index 06bd161..b889970 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -673,30 +673,34 @@ void FFMS_VideoSource::DecodeNextFrame(int64_t &AStartTime, int64_t &Pos) {
+     if (HasPendingDelayedFrames())
+         return;
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
+-
+-    while (ReadFrame(&Packet) >= 0) {
+-        if (Packet.stream_index != VideoTrack) {
+-            av_packet_unref(&Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++
++    while (ReadFrame(Packet) >= 0) {
++        if (Packet->stream_index != VideoTrack) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+         if (AStartTime < 0)
+-            AStartTime = Frames.UseDTS ? Packet.dts : Packet.pts;
++            AStartTime = Frames.UseDTS ? Packet->dts : Packet->pts;
+ 
+         if (Pos < 0)
+-            Pos = Packet.pos;
++            Pos = Packet->pos;
+ 
+-        bool FrameFinished = DecodePacket(&Packet);
+-        av_packet_unref(&Packet);
+-        if (FrameFinished)
++        bool FrameFinished = DecodePacket(Packet);
++        av_packet_unref(Packet);
++        if (FrameFinished) {
++            av_packet_free(&Packet);
+             return;
++        }
+     }
+ 
+     // Flush final frames
+-    InitNullPacket(Packet);
+-    DecodePacket(&Packet);
++    DecodePacket(Packet);
++    av_packet_free(&Packet);
+ }
+ 
+ bool FFMS_VideoSource::SeekTo(int n, int SeekOffset) {
+-- 
+2.40.0
+
+From bf9e03e9e08534c024e5a744a6437c4aac160201 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:20:47 +0100
+Subject: [PATCH 2/3] configure: Remove deprecated API use
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ configure.ac | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index b35ef80bc..d19714d0f 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -102,10 +102,10 @@ CFLAGS="$_CFLAGS $FFMPEG_CFLAGS"
+
+ AC_DEFUN([TEST_FFMPEG],
+          [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+-            #include <libavcodec/avcodec.h>
++            #include <libavformat/avformat.h>
+             #include <libswscale/swscale.h>
+             ]],[[
+-                avcodec_register_all();
++                avformat_network_init();
+                 swscale_version();
+             ]])], [eval $1=yes], [eval $1=no])
+         ])
+
diff --git a/srcpkgs/ffms2/template b/srcpkgs/ffms2/template
index 365f64d10cbab..1641ecf43be5b 100644
--- a/srcpkgs/ffms2/template
+++ b/srcpkgs/ffms2/template
@@ -1,7 +1,7 @@
 # Template file for 'ffms2'
 pkgname=ffms2
 version=2.40
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-shared --disable-static"
 hostmakedepends="pkg-config autoconf automake libtool"

From 6d66ecab243642a135492169bbde016430a82832 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 032/115] freerdp: revbump for ffmpeg-6.0

---
 .../freerdp/patches/ffmpeg6_aa2cb9aa.patch    | 42 +++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100644 srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch

diff --git a/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
new file mode 100644
index 0000000000000..a4324da3a8822
--- /dev/null
+++ b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
@@ -0,0 +1,42 @@
+From aa2cb9aa5ff5562433598ba168a466e0752bca0e Mon Sep 17 00:00:00 2001
+From: akallabeth <akallabeth@posteo.net>
+Date: Tue, 14 Feb 2023 07:48:54 +0100
+Subject: [PATCH] Fixed #8686: Update h264 to use new FFMPEG API
+
+---
+ channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c | 2 ++
+ libfreerdp/codec/h264_ffmpeg.c            | 2 ++
+ 2 files changed, 4 insertions(+)
+
+diff --git a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+index 339462d865f..beea80b7a1e 100644
+--- a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
++++ b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+@@ -239,8 +239,10 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYP
+ 		}
+ 	}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 	if (mdecoder->codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		mdecoder->codec_context->flags |= AV_CODEC_FLAG_TRUNCATED;
++#endif
+ 
+ 	return TRUE;
+ }
+diff --git a/libfreerdp/codec/h264_ffmpeg.c b/libfreerdp/codec/h264_ffmpeg.c
+index 8a23db2473c..896a333019b 100644
+--- a/libfreerdp/codec/h264_ffmpeg.c
++++ b/libfreerdp/codec/h264_ffmpeg.c
+@@ -615,10 +615,12 @@ static BOOL libavcodec_init(H264_CONTEXT* h264)
+ 			goto EXCEPTION;
+ 		}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 		if (sys->codecDecoder->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		{
+ 			sys->codecDecoderContext->flags |= AV_CODEC_FLAG_TRUNCATED;
+ 		}
++#endif
+ 
+ #ifdef WITH_VAAPI
+ 

From f67507f9be150ccf103e81567f96170ecec9aa37 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 033/115] gerbera: revbump for ffmpeg-6.0

---
 srcpkgs/gerbera/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gerbera/template b/srcpkgs/gerbera/template
index ae14f35c767c0..2dc0ac0ce03b5 100644
--- a/srcpkgs/gerbera/template
+++ b/srcpkgs/gerbera/template
@@ -1,7 +1,7 @@
 # Template file for 'gerbera'
 pkgname=gerbera
 version=1.12.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_SYSTEMD=0 -DWITH_AVCODEC=1"
 hostmakedepends="pkg-config"

From 82902ed9aed6e9b8765d6a44c351c81e957fa5d3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 034/115] goldendict: revbump for ffmpeg-6.0

---
 srcpkgs/goldendict/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/goldendict/template b/srcpkgs/goldendict/template
index f4a05759f693d..97f44347b03a6 100644
--- a/srcpkgs/goldendict/template
+++ b/srcpkgs/goldendict/template
@@ -1,7 +1,7 @@
 # Template file for 'goldendict'
 pkgname=goldendict
 version=1.5.0
-revision=1
+revision=2
 build_style=qmake
 configure_args="CONFIG+=zim_support goldendict.pro"
 hostmakedepends="qt5-qmake pkg-config qt5-host-tools"
@@ -10,7 +10,7 @@ makedepends="tiff-devel qt5-devel libvorbis-devel zlib-devel
  qt5-webkit-devel lzo-devel bzip2-devel libao-devel qt5-svg-devel
  libeb-devel qt5-x11extras-devel ffmpeg-devel liblzma-devel
  qt5-multimedia-devel"
-short_desc="A feature-rich dictionary lookup program"
+short_desc="Feature-rich dictionary lookup program"
 maintainer="John <me@johnnynator.dev>"
 license="GPL-3.0-or-later"
 homepage="http://goldendict.org/"

From b625e5bd521fb201310130ab307dd90450ee0c7e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 035/115] gst-libav: revbump for ffmpeg-6.0

---
 srcpkgs/gst-libav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index 37485f6f6a9e8..f610e966f23cd 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.22.5
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"

From 4469383b46d14daf4cd30e689edc0a63bc00275a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 036/115] gst-rtsp-server: revbump for ffmpeg-6.0

---
 srcpkgs/gst-rtsp-server/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index f266f4777b3ea..011444eb26739 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
 version=1.22.5
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="glib-devel gst-plugins-bad1-devel gobject-introspection

From ed3a1dd2c07a1c748005e8365af40cbd979c6d16 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 037/115] guvcview: update to 2.0.8.

---
 srcpkgs/guvcview/patches/fix-include.patch | 10 ++++++++++
 srcpkgs/guvcview/template                  |  7 +++----
 2 files changed, 13 insertions(+), 4 deletions(-)
 create mode 100644 srcpkgs/guvcview/patches/fix-include.patch

diff --git a/srcpkgs/guvcview/patches/fix-include.patch b/srcpkgs/guvcview/patches/fix-include.patch
new file mode 100644
index 0000000000000..503c2af3b78c1
--- /dev/null
+++ b/srcpkgs/guvcview/patches/fix-include.patch
@@ -0,0 +1,10 @@
+--- a/guvcview/guvcview.c
++++ b/guvcview/guvcview.c
+@@ -28,6 +28,7 @@
+ #include <sys/stat.h>
+ #include <sys/resource.h>
+ #include <errno.h>
++#include <locale.h>
+ 
+ #include "gview.h"
+ #include "gviewv4l2core.h"
diff --git a/srcpkgs/guvcview/template b/srcpkgs/guvcview/template
index d42fd38fa4ad1..86a7fd619612c 100644
--- a/srcpkgs/guvcview/template
+++ b/srcpkgs/guvcview/template
@@ -1,8 +1,7 @@
 # Template file for 'guvcview'
 pkgname=guvcview
-version=2.0.7
-revision=2
-create_wrksrc=yes
+version=2.0.8
+revision=1
 build_style=gnu-configure
 configure_args="--disable-static --disable-debian-menu"
 hostmakedepends="pkg-config intltool autoconf automake libtool glib-devel"
@@ -14,7 +13,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="http://guvcview.sourceforge.net/"
 distfiles="${SOURCEFORGE_SITE}/${pkgname}/${pkgname}-src-${version}.tar.bz2"
-checksum=f47d51fbd06e44eeaa1a82f4a153c927527c90d94514197a70b2956028cc8ad4
+checksum=a21f4e448286666cf27bafef5290cc953a0a1796b752e5bbe521266dc1230c81
 
 post_patch() {
 	sed '31a#include <locale.h>' -i  guvcview/guvcview.c

From ca07813fc4dddd9cf33f42dc3ff200ba28ef95aa Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 038/115] handbrake: update to 1.6.1

---
 .../patches/fix-missing-x265-link-flag.patch    | 11 ++++++-----
 .../handbrake/patches/libhb-vpl-include.patch   | 15 +++++++++++++++
 srcpkgs/handbrake/template                      | 17 ++++++++++-------
 3 files changed, 31 insertions(+), 12 deletions(-)
 create mode 100644 srcpkgs/handbrake/patches/libhb-vpl-include.patch

diff --git a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
index 26db03867a0c8..d6bb2eda627a3 100644
--- a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
+++ b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
@@ -1,14 +1,15 @@
 --- a/gtk/configure.ac
 +++ b/gtk/configure.ac
 @@ -203,7 +203,7 @@
- 
+
  AM_CONDITIONAL([MINGW], [test "x$mingw_flag" = "xyes"])
- 
--HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg"
-+HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -ldl"
+
+-HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc"
++HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc -ldl"
  HB_CPPFLAGS="$HB_CPPFLAGS $HBINC"
- 
+
  PKG_CHECK_MODULES([x264], [x264], sys_x264=yes, sys_x264=no)
+
 --- a/test/module.defs
 +++ b/test/module.defs
 @@ -69,6 +69,9 @@
diff --git a/srcpkgs/handbrake/patches/libhb-vpl-include.patch b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
new file mode 100644
index 0000000000000..298f9f4ab28f2
--- /dev/null
+++ b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
@@ -0,0 +1,15 @@
+--- a/libhb/module.defs	2023-01-22 11:36:49.000000000 -0500
++++ b/libhb/module.defs	2023-04-03 22:37:52.395467010 -0400
+@@ -46,11 +46,7 @@
+ LIBHB.GCC.I += $(LIBHB.build/) $(CONTRIB.build/)include
+ 
+ ifeq (1,$(FEATURE.qsv))
+-    ifeq ($(HOST.system),freebsd))
+-        LIBHB.GCC.I += $(LOCALBASE)/include/vpl
+-    else
+-        LIBHB.GCC.I += $(CONTRIB.build/)include/vpl
+-    endif
++    LIBHB.GCC.I += /usr/include/vpl
+ endif
+ 
+ ifneq (,$(filter $(HOST.system),freebsd netbsd openbsd))
diff --git a/srcpkgs/handbrake/template b/srcpkgs/handbrake/template
index ca5e4571e49c3..c32cb1bfa31f4 100644
--- a/srcpkgs/handbrake/template
+++ b/srcpkgs/handbrake/template
@@ -1,10 +1,10 @@
 # Template file for 'handbrake'
 pkgname=handbrake
-version=1.5.1
+version=1.6.1
 revision=1
 build_style=gnu-configure
 configure_args="--force --disable-gtk-update-checks --disable-df-fetch --harden
- $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc)"
+ $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc) $(vopt_enable qsv)"
 make_build_args="-C ${XBPS_TRIPLET}"
 make_install_args="-C ${XBPS_TRIPLET}"
 hostmakedepends="automake cmake gettext-devel glib-devel intltool libtool m4 meson nasm pkg-config python3"
@@ -12,8 +12,11 @@ makedepends="bzip2-devel ffmpeg-devel gst-plugins-base1-devel gtk+3-devel
  jansson-devel lame-devel libass-devel libbluray-devel libdav1d-devel
  libdvdnav-devel libdvdread-devel libgudev-devel libnuma-devel
  libsamplerate-devel libtheora-devel libvorbis-devel libvpx-devel libxml2-devel
- opus-devel speex-devel x264-devel x265-devel zimg-devel
+ opus-devel speex-devel x264-devel x265-devel zimg-devel libsvt-av1-devel
  $(vopt_if fdk_aac fdk-aac-devel)
+ $(vopt_if qsv libva-devel)
+ $(vopt_if qsv libdrm-devel)
+ $(vopt_if qsv onevpl-devel)
  $(vopt_if nvenc nv-codec-headers)"
 depends="desktop-file-utils gst-plugins-good1 hicolor-icon-theme"
 short_desc="Multithreaded video transcoder"
@@ -21,15 +24,15 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-2.0-only"
 homepage="https://handbrake.fr/"
 distfiles="https://github.com/HandBrake/HandBrake/releases/download/${version}/HandBrake-${version}-source.tar.bz2"
-checksum=3999fe06d5309c819799a73a968a8ec3840e7840c2b64af8f5cdb7fd8c9430f0
+checksum=94ccfe03db917a91650000c510f7fd53f844da19f19ad4b4be1b8f6bc31a8d4c
 nocross=yes
 
-build_options="fdk_aac nvenc"
+build_options="fdk_aac nvenc qsv"
 
 case "$XBPS_TARGET_MACHINE" in
 	x86_64*|i686*)
 		CFLAGS="-msse"
-		build_options_default="nvenc"
+		build_options_default="nvenc qsv"
 		;;
 esac
 
@@ -37,7 +40,7 @@ pre_configure() {
 	# use system libraries, don't download them
 	rm -rf contrib/
 	for module in fdk-aac ffmpeg libbluray libdav1d libdvdnav libdvdread nvenc \
-		x265 zimg; do
+		x265 zimg svt-av1 libvpl; do
 	    vsed -i "/MODULES += contrib\/${module}/d" make/include/main.defs
 	done
 }

From 52951eae23aeecc7056f924bb026ad933d5ab8bf Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 039/115] hedgewars: revbump for ffmpeg4-4.4.3

---
 srcpkgs/hedgewars/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/hedgewars/template b/srcpkgs/hedgewars/template
index 15a1df6d8861d..d1b7290bfdc19 100644
--- a/srcpkgs/hedgewars/template
+++ b/srcpkgs/hedgewars/template
@@ -1,13 +1,13 @@
 # Template file for 'hedgewars'
 pkgname=hedgewars
 version=1.0.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DNOSERVER=1 -DDATA_INSTALL_DIR=/usr/share/${pkgname}
  -DPHYSFS_SYSTEM=1 -DMINIMAL_FLAGS=1"
 make_cmd=make
 hostmakedepends="lua51 pkg-config qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
+makedepends="ffmpeg4-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
  SDL2_mixer-devel SDL2_net-devel SDL2_ttf-devel"
 depends="libfreeglut"
 short_desc="Funny turn-based artillery game, featuring fighting Hedgehogs!"

From 2ddb183000d1de10f4067e38a736c4767693ddf4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 040/115] idjc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/idjc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/idjc/template b/srcpkgs/idjc/template
index a9cde0665d55b..6f1d21c5781fd 100644
--- a/srcpkgs/idjc/template
+++ b/srcpkgs/idjc/template
@@ -5,7 +5,7 @@ revision=5
 build_style=gnu-configure
 hostmakedepends="pkg-config git python3 automake gettext-devel libtool"
 makedepends="libvorbis-devel libogg-devel jack-devel libsamplerate-devel
- libflac-devel libsndfile-devel mpg123-devel ffmpeg-devel speex-devel
+ libflac-devel libsndfile-devel mpg123-devel ffmpeg4-devel speex-devel
  glib-devel pixman-devel lame-devel python3-gobject-devel libshout-idjc-devel
  opus-devel twolame-devel python3-mutagen python3-devel"
 depends="python3-gobject python3-mutagen desktop-file-utils shared-mime-info python3-dbus jack"

From 8e11a46980c0f1f3e44b9450473bc590e04a7f9f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 041/115] kfilemetadata5: revbump for ffmpeg-6.0

---
 srcpkgs/kfilemetadata5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kfilemetadata5/template b/srcpkgs/kfilemetadata5/template
index 00f7a98cf6399..e294ae5af947c 100644
--- a/srcpkgs/kfilemetadata5/template
+++ b/srcpkgs/kfilemetadata5/template
@@ -1,7 +1,7 @@
 # Template file for 'kfilemetadata5'
 pkgname=kfilemetadata5
 version=5.111.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="kcoreaddons extra-cmake-modules pkg-config qt5-host-tools qt5-qmake
  gettext kcoreaddons python3"

From 8a1e41b1210ae8b9b664a0135a98b2648f3aa319 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 042/115] kid3: revbump for ffmpeg-6.0

---
 srcpkgs/kid3/patches/ffmpeg5.patch | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 srcpkgs/kid3/patches/ffmpeg5.patch

diff --git a/srcpkgs/kid3/patches/ffmpeg5.patch b/srcpkgs/kid3/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..135fc50e07c9b
--- /dev/null
+++ b/srcpkgs/kid3/patches/ffmpeg5.patch
@@ -0,0 +1,17 @@
+# https://aur.archlinux.org/cgit/aur.git/diff/ffmpeg5.patch?h=kid3-cli&id=12410a74906612e7efc0ec8fbce739b4a0fef7e7
+diff --git a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+index e156d424..e12b9abd 100644
+--- a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
++++ b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+@@ -232,7 +232,11 @@ private:
+   friend class Format;
+   friend class Converter;
+   AVCodecContext* m_ptr;
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 0, 0)
+   AVCodec* m_impl;
++#else
++  const AVCodec* m_impl;
++#endif
+   AVFrame* m_frame;
+   bool m_opened;
+ };

From 51ca0e63aeb877d2f021e0d56b97c7a4e4ae54d1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 043/115] kodi: revbump for ffmpeg4-4.4.3

---
 srcpkgs/kodi/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kodi/template b/srcpkgs/kodi/template
index aa59324258a0d..6cf64dfb27294 100644
--- a/srcpkgs/kodi/template
+++ b/srcpkgs/kodi/template
@@ -54,7 +54,7 @@ makedepends="
  libmad-devel fontconfig-devel libXinerama-devel libsamplerate-devel libmms-devel
  enca-devel boost-devel libcurl-devel libva-devel libvdpau-devel libass-devel
  libbluetooth-devel yajl-devel libplist-devel librtmp-devel tinyxml-devel
- taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg-devel
+ taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg4-devel
  giflib-devel libxslt-devel gnutls-devel libssh-devel libmicrohttpd-devel
  libcec-devel dcadec-devel flatbuffers-devel fmt-devel lcms2-devel
  libfstrcmp-devel rapidjson libcdio-paranoia spdlog libwaylandpp-devel

From db80707664402c813ce9294d52d88fff57371eb9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 044/115] kpipewire: revbump for ffmpeg-6.0

---
 srcpkgs/kpipewire/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kpipewire/template b/srcpkgs/kpipewire/template
index b2d3d80c1dd1a..981c7b8890ded 100644
--- a/srcpkgs/kpipewire/template
+++ b/srcpkgs/kpipewire/template
@@ -1,7 +1,7 @@
 # Template file for 'kpipewire'
 pkgname=kpipewire
 version=5.27.9
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules plasma-wayland-protocols gettext
  qt5-qmake qt5-host-tools pkg-config wayland-devel kcoreaddons

From 5faafcb015f3297a05c87ad550a04e149a7864ff Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 045/115] libextractor: revbump for ffmpeg4-4.4.3

---
 srcpkgs/libextractor/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libextractor/template b/srcpkgs/libextractor/template
index bfcea979a308c..fafd8dedbc34b 100644
--- a/srcpkgs/libextractor/template
+++ b/srcpkgs/libextractor/template
@@ -7,7 +7,7 @@ configure_args="--disable-static"
 hostmakedepends="pkg-config"
 makedepends="zlib-devel bzip2-devel exiv2-devel tiff-devel libpng-devel
  libjpeg-turbo-devel libvorbis-devel libflac-devel giflib-devel libmpeg2-devel
- ffmpeg-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
+ ffmpeg4-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
 short_desc="Library used to extract meta data from files"
 maintainer="Martin Riese <grauehaare@gmx.de>"
 license="GPL-3.0-or-later"

From 7cf2587418b2bf1630ba7fd1559f046643146e20 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 046/115] libopenal: revbump for ffmpeg-6.0

---
 srcpkgs/libopenal/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenal/template b/srcpkgs/libopenal/template
index 77218f9e539df..3f49ed75a1fdc 100644
--- a/srcpkgs/libopenal/template
+++ b/srcpkgs/libopenal/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenal'
 pkgname=libopenal
 version=1.22.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DALSOFT_EXAMPLES=OFF"
 hostmakedepends="pkg-config"

From aff85d80e3a9ed5158c0e5f2451bdabf25ae62f6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 047/115] loudgain: revbump for ffmpeg-6.0

---
 srcpkgs/loudgain/patches/ffmpeg5.patch | 11 +++++++++++
 srcpkgs/loudgain/template              |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/loudgain/patches/ffmpeg5.patch

diff --git a/srcpkgs/loudgain/patches/ffmpeg5.patch b/srcpkgs/loudgain/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..16d4510ee98fa
--- /dev/null
+++ b/srcpkgs/loudgain/patches/ffmpeg5.patch
@@ -0,0 +1,11 @@
+--- a/src/scan.c	2019-09-06 11:31:19.000000000 -0400
++++ b/src/scan.c	2023-03-23 11:15:40.867968521 -0400
+@@ -69,8 +69,6 @@
+ 	 * It is now useless
+ 	 * https://github.com/FFmpeg/FFmpeg/blob/70d25268c21cbee5f08304da95be1f647c630c15/doc/APIchanges#L86
+ 	 */
+-  if (avformat_version() < AV_VERSION_INT(58,9,100))
+-    av_register_all();
+ 
+ 	av_log_set_callback(scan_av_log);
+ 
diff --git a/srcpkgs/loudgain/template b/srcpkgs/loudgain/template
index da4f2d56e94c3..4d6bf29efb4fd 100644
--- a/srcpkgs/loudgain/template
+++ b/srcpkgs/loudgain/template
@@ -1,7 +1,7 @@
 # Template file for 'loudgain'
 pkgname=loudgain
 version=0.6.8
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libebur128-devel taglib-devel ffmpeg-devel"

From 2f8233423b5dbe7c851eb27bea37e769bbf85ea0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 048/115] mediastreamer: revbump for ffmpeg4-4.4.3

---
 srcpkgs/mediastreamer/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mediastreamer/template b/srcpkgs/mediastreamer/template
index 0fcffa7653d18..92ada88743a9b 100644
--- a/srcpkgs/mediastreamer/template
+++ b/srcpkgs/mediastreamer/template
@@ -5,7 +5,7 @@ revision=2
 build_style=cmake
 configure_args="-DENABLE_STRICT=0 -DENABLE_UNIT_TESTS=0"
 hostmakedepends="python3"
-makedepends="bzrtp-devel ffmpeg-devel glew-devel libXv-devel libsrtp-devel
+makedepends="bzrtp-devel ffmpeg4-devel glew-devel libXv-devel libsrtp-devel
  libupnp-devel libvpx-devel mbedtls-devel opus-devel ortp-devel pulseaudio-devel
  libtheora-devel speex-devel v4l-utils-devel bcg729-devel bcmatroska2-devel libgsm-devel
  zxing-cpp-devel"

From 6f9f78616eb4522f8d7b07e197a480b76662d015 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 049/115] mgba: revbump for ffmpeg-6.0

---
 srcpkgs/mgba/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mgba/template b/srcpkgs/mgba/template
index 5513e3fd16f3f..f5c87a4893002 100644
--- a/srcpkgs/mgba/template
+++ b/srcpkgs/mgba/template
@@ -1,7 +1,7 @@
 # Template file for 'mgba'
 pkgname=mgba
 version=0.10.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake desktop-file-utils"
 makedepends="SDL2-devel ffmpeg-devel libedit-devel libepoxy-devel libmagick-devel

From dbb3563b6e3ee37b6d187bddf02682864eb47ff4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 050/115] mlt: revbump for ffmpeg4-4.4.3

---
 srcpkgs/mlt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mlt/template b/srcpkgs/mlt/template
index 73e3915aaab9a..ec5054be3b75e 100644
--- a/srcpkgs/mlt/template
+++ b/srcpkgs/mlt/template
@@ -8,7 +8,7 @@ configure_args="--prefix=/usr --libdir=/usr/lib$XBPS_TARGET_WORDSIZE
  --swig-languages=python"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which"
 # XXX: movit vid.stab
-makedepends="alsa-lib-devel ffmpeg-devel gtk+-devel jack-devel ladspa-sdk
+makedepends="alsa-lib-devel ffmpeg4-devel gtk+-devel jack-devel ladspa-sdk
  libexif-devel libsamplerate-devel libxml2-devel sox-devel SDL_image-devel
  fftw-devel frei0r-plugins python3-devel pulseaudio-devel movit-devel
  libvidstab-devel"

From fb6e57cbc63baa5bc5199ae64e86087a392d492f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 051/115] moc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/moc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/moc/template b/srcpkgs/moc/template
index 3a04932c8f1e6..d8de816026b64 100644
--- a/srcpkgs/moc/template
+++ b/srcpkgs/moc/template
@@ -4,7 +4,7 @@ version=2.5.2
 revision=7
 build_style=gnu-configure
 hostmakedepends="pkg-config"
-makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg-devel
+makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg4-devel
  jack-devel alsa-lib-devel libltdl-devel libflac-devel libvorbis-devel
  libmad-devel libmpcdec-devel libmodplug-devel libid3tag-devel faad2-devel
  taglib-devel libsndfile-devel wavpack-devel speex-devel libsamplerate-devel

From 4e8a6bee618a3b1b946c2d7f183638803423255f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 052/115] motion: revbump for ffmpeg-6.0

---
 srcpkgs/motion/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/motion/template b/srcpkgs/motion/template
index 3cf3c3035c5b7..7dca12d851e33 100644
--- a/srcpkgs/motion/template
+++ b/srcpkgs/motion/template
@@ -1,7 +1,7 @@
 # Template file for 'motion'
 pkgname=motion
 version=4.5.1
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake pkg-config gettext-devel tar"
 makedepends="ffmpeg-devel libmicrohttpd-devel v4l-utils-devel gettext-devel"

From 46e16bf0954b708cb43e54815101920797178444 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 053/115] notcurses: revbump for ffmpeg-6.0

---
 srcpkgs/notcurses/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/notcurses/template b/srcpkgs/notcurses/template
index 6dd8a091319f7..3110c30c9aff2 100644
--- a/srcpkgs/notcurses/template
+++ b/srcpkgs/notcurses/template
@@ -1,7 +1,7 @@
 # Template file for 'notcurses'
 pkgname=notcurses
 version=3.0.9
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DUSE_STATIC=ON $(vopt_bool man USE_PANDOC)"
 hostmakedepends="pkg-config $(vopt_if man pandoc)"

From 9fbe43758fe5ccaf8c3398ecf1da39eb27317d05 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 054/115] olive: revbump for ffmpeg4-4.4.3

---
 srcpkgs/olive/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/olive/template b/srcpkgs/olive/template
index 12a46936c9900..5c2917b9c5124 100644
--- a/srcpkgs/olive/template
+++ b/srcpkgs/olive/template
@@ -1,10 +1,10 @@
 # Template file for 'olive'
 pkgname=olive
 version=0.1.2
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools pkg-config"
-makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg-devel frei0r-plugins"
+makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg4-devel frei0r-plugins"
 short_desc="Non-linear video editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"

From b1e67081eb5e951f4dcaf5165580e4036756b115 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 055/115] omxplayer: revbump for ffmpeg4-4.4.3

---
 srcpkgs/omxplayer/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/omxplayer/template b/srcpkgs/omxplayer/template
index 9a66690c83ebb..a21b878878037 100644
--- a/srcpkgs/omxplayer/template
+++ b/srcpkgs/omxplayer/template
@@ -1,7 +1,7 @@
 # Template file for 'omxplayer'
 pkgname=omxplayer
 version=20190102
-revision=2
+revision=3
 short_desc="Commandline OMX player for the Raspberry Pi"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
@@ -15,7 +15,7 @@ checksum=af2d9450f8947842ea8c401fe9f71eec444013ebbdee29f2ac828c9c493c1329
 archs="armv6l* armv7l*"
 build_style=gnu-makefile
 hostmakedepends="ruby-ronn pkg-config"
-makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg-devel dbus-devel"
+makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg4-devel dbus-devel"
 depends="freefont-ttf"
 
 do_build() {

From 52996b6720160aaeeda4b82481bb39cc2502d76b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 056/115] opentoonz: revbump for ffmpeg-6.0

---
 srcpkgs/opentoonz/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/opentoonz/template b/srcpkgs/opentoonz/template
index ee9f7603f55fd..3e81834ca0edd 100644
--- a/srcpkgs/opentoonz/template
+++ b/srcpkgs/opentoonz/template
@@ -1,7 +1,7 @@
 # Template file for 'opentoonz'
 pkgname=opentoonz
 version=1.6.0
-revision=2
+revision=3
 build_wrksrc="toonz/sources"
 build_style=cmake
 make_cmd=make

From 315ba98304d4b41bc265a05c4817c0bb5966424e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 057/115] pianobar: revbump for ffmpeg-6.0

---
 srcpkgs/pianobar/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pianobar/template b/srcpkgs/pianobar/template
index e3febb821a451..1e3dc1bf9308e 100644
--- a/srcpkgs/pianobar/template
+++ b/srcpkgs/pianobar/template
@@ -1,7 +1,7 @@
 # Template file for 'pianobar'
 pkgname=pianobar
 version=2022.04.01
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="V=1"
 hostmakedepends="pkg-config"

From fd55616e3205b975cd0eb92a41e16ac83a85e2f4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 058/115] ppsspp: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ppsspp/template | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/ppsspp/template b/srcpkgs/ppsspp/template
index 2c0ded496eb98..1294ef3ae669c 100644
--- a/srcpkgs/ppsspp/template
+++ b/srcpkgs/ppsspp/template
@@ -1,7 +1,7 @@
 # Template file for 'ppsspp'
 pkgname=ppsspp
 version=1.16.6
-revision=1
+revision=2
 _glslang_commit=b34f619e1c85810dcb3c578107d2e48ba4ee2b37
 _SPIRV_Cross_commit=4212eef67ed0ca048cb726a6767185504e7695e5
 _armips_commit=7bd1ec93d4586985ba1ef420b43b5e620f68695e
@@ -15,7 +15,7 @@ configure_args="-DHEADLESS=1 -DUSE_SYSTEM_FFMPEG=1 -DUNITTEST=ON
  -DUSING_QT_UI=$(vopt_if qt ON OFF) -DUSE_SYSTEM_ZSTD=ON
  -DARMIPS_USE_STD_FILESYSTEM=ON"
 hostmakedepends="pkg-config python3 $(vopt_if qt qt5-host-tools)"
-makedepends="zlib-devel glew-devel ffmpeg-devel libzip-devel
+makedepends="zlib-devel glew-devel ffmpeg4-devel libzip-devel
  snappy-devel rapidjson libpng-devel libzstd-devel
  $(vopt_if sdl2 'SDL2_ttf-devel SDL2-devel') $(vopt_if wayland wayland-devel)
  $(vopt_if qt 'qt5-devel qt5-multimedia-devel')"
@@ -72,7 +72,7 @@ post_extract() {
         mv ${wrksrc}/rcheevos-${_rcheevos_commit} ${wrksrc}/ext/rcheevos
 }
 
-post_patch(){
+post_patch() {
 	# disable git versioning
 	vsed -e 's|find_package(Git)|# &|' -i git-version.cmake
 }
@@ -85,7 +85,6 @@ post_configure() {
 }
 
 do_install() {
-	vlicense LICENSE.TXT
 	vinstall icons/icon.svg 644 usr/share/pixmaps ppsspp.svg
 	vinstall Qt/PPSSPP.desktop 644 usr/share/applications
 	vbin build/PPSSPPHeadless ppsspp-headless

From 4342f1aecebdb0f9afd564359316b63c8087d7d5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 059/115] pqiv: revbump for ffmpeg-6.0

---
 srcpkgs/pqiv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pqiv/template b/srcpkgs/pqiv/template
index 542fc27a2d32a..9308d949b6a1c 100644
--- a/srcpkgs/pqiv/template
+++ b/srcpkgs/pqiv/template
@@ -1,7 +1,7 @@
 # Template file for 'pqiv'
 pkgname=pqiv
 version=2.12
-revision=1
+revision=2
 build_style=gnu-makefile
 hostmakedepends="pkg-config"
 makedepends="glib-devel gtk+3-devel $(vopt_if ffmpeg ffmpeg-devel)

From 90a47c80a001f0e0759412cb92bcebba2f712fcc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 060/115] qmmp: revbump for ffmpeg-6.0

---
 srcpkgs/qmmp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qmmp/template b/srcpkgs/qmmp/template
index 53781ea3bc28a..2da07f1e87eac 100644
--- a/srcpkgs/qmmp/template
+++ b/srcpkgs/qmmp/template
@@ -1,7 +1,7 @@
 # Template file for 'qmmp'
 pkgname=qmmp
 version=1.6.1
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DUSE_HAL:BOOL=FALSE -DQMMP_DEFAULT_UI:STRING=simple"
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From 0b303fad560ea94770f87608b9c006c152c54ccc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 061/115] qt5-webengine: update to 5.15.13

---
 .../chromium-media-filters-cpp14.patch        |  11 ++
 srcpkgs/qt5-webengine/patches/ffmpeg5.patch   | 179 ++++++++++++++++++
 srcpkgs/qt5-webengine/template                |  10 +-
 3 files changed, 195 insertions(+), 5 deletions(-)
 create mode 100644 srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/ffmpeg5.patch

diff --git a/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
new file mode 100644
index 0000000000000..04adc540f2cbc
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
@@ -0,0 +1,11 @@
+--- a/src/3rdparty/chromium/media/filters/BUILD.gn	2023-02-27 13:32:59.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/BUILD.gn	2023-04-02 17:21:39.204066384 -0400
+@@ -96,6 +96,8 @@
+     "//ui/gfx/geometry:geometry",
+   ]
+ 
++  cflags_cc = [ "-std=c++14" ]
++
+   libs = []
+ 
+   if (proprietary_codecs) {
diff --git a/srcpkgs/qt5-webengine/patches/ffmpeg5.patch b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..ac55e1634423a
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
@@ -0,0 +1,179 @@
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:57.732547446 -0400
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:09.486478995 -0400
+@@ -57,6 +57,8 @@
+ 
+ namespace {
+ 
++constexpr int64_t kRelativeTsBase = static_cast<int64_t>(0x7ffeffffffffffff);
++
+ void SetAVStreamDiscard(AVStream* stream, AVDiscard discard) {
+   DCHECK(stream);
+   stream->discard = discard;
+@@ -90,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+   if (stream->start_time != kNoFFmpegTimestamp)
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (stream->first_dts != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, stream->first_dts);
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -408,11 +398,11 @@
+   scoped_refptr<DecoderBuffer> buffer;
+ 
+   if (type() == DemuxerStream::TEXT) {
+-    int id_size = 0;
++    size_t id_size = 0;
+     uint8_t* id_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
+ 
+-    int settings_size = 0;
++    size_t settings_size = 0;
+     uint8_t* settings_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
+ 
+@@ -424,7 +414,7 @@
+     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
+                                      side_data.data(), side_data.size());
+   } else {
+-    int side_data_size = 0;
++    size_t side_data_size = 0;
+     uint8_t* side_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
+ 
+@@ -485,7 +475,7 @@
+                                        packet->size - data_offset);
+     }
+ 
+-    int skip_samples_size = 0;
++    size_t skip_samples_size = 0;
+     const uint32_t* skip_samples_ptr =
+         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
+             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
+@@ -1587,6 +1577,8 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++      continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+       lowest_start_time_stream = stream.get();
+@@ -1604,6 +1596,8 @@
+     if (stream && stream->type() == DemuxerStream::VIDEO &&
+         stream->IsEnabled()) {
+       video_stream = stream.get();
++      if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++        continue;
+       if (video_stream->start_time() <= seek_time) {
+         return video_stream;
+       }
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h qtwebengine-5.15.10/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h
+--- a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-07-11 22:12:47.917192788 -0500
+@@ -29,6 +29,7 @@ extern "C" {
+ #include <libavformat/avformat.h>
+ #include <libavformat/avio.h>
+ #include <libavutil/avutil.h>
++#include <libavutil/channel_layout.h>
+ #include <libavutil/imgutils.h>
+ #include <libavutil/log.h>
+ #include <libavutil/mastering_display_metadata.h>
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/audio_file_reader.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/audio_file_reader.cc
+--- a/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -85,7 +85,7 @@ bool AudioFileReader::OpenDemuxer() {
+ }
+ 
+ bool AudioFileReader::OpenDecoder() {
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (codec) {
+     // MP3 decodes to S16P which we don't support, tell it to use S16 instead.
+     if (codec_context_->sample_fmt == AV_SAMPLE_FMT_S16P)
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -329,7 +329,7 @@ bool FFmpegAudioDecoder::ConfigureDecode
+     }
+   }
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec ||
+       avcodec_open2(codec_context_.get(), codec, &codec_options) < 0) {
+     DLOG(ERROR) << "Could not initialize audio decoder: "
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -59,7 +59,6 @@ static int64_t AVIOSeekOperation(void* o
+ }
+ 
+ void FFmpegGlue::InitializeFFmpeg() {
+-  av_register_all();
+ }
+ 
+ static void LogContainer(bool is_local_file,
+@@ -95,9 +94,6 @@ FFmpegGlue::FFmpegGlue(FFmpegURLProtocol
+   // Enable fast, but inaccurate seeks for MP3.
+   format_context_->flags |= AVFMT_FLAG_FAST_SEEK;
+ 
+-  // Ensures we can read out various metadata bits like vp8 alpha.
+-  format_context_->flags |= AVFMT_FLAG_KEEP_SIDE_DATA;
+-
+   // Ensures format parsing errors will bail out. From an audit on 11/2017, all
+   // instances were real failures. Solves bugs like http://crbug.com/710791.
+   format_context_->error_recognition |= AV_EF_EXPLODE;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -391,7 +391,7 @@ bool FFmpegVideoDecoder::ConfigureDecode
+   if (decode_nalus_)
+     codec_context_->flags2 |= AV_CODEC_FLAG2_CHUNKS;
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
+     ReleaseFFmpegResources();
+     return false;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/media_file_checker.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/media_file_checker.cc
+--- a/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -68,7 +68,7 @@ bool MediaFileChecker::Start(base::TimeD
+       auto context = AVStreamToAVCodecContext(format_context->streams[i]);
+       if (!context)
+         continue;
+-      AVCodec* codec = avcodec_find_decoder(cp->codec_id);
++      const AVCodec* codec = avcodec_find_decoder(cp->codec_id);
+       if (codec && avcodec_open2(context.get(), codec, nullptr) >= 0) {
+         auto loop = std::make_unique<FFmpegDecodingLoop>(context.get());
+         stream_contexts[i] = {std::move(context), std::move(loop)};
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc qtwebengine-5.15.10/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc
+--- a/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -203,7 +203,7 @@ int32_t H264DecoderImpl::InitDecode(cons
+   // a pointer |this|.
+   av_context_->opaque = this;
+ 
+-  AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
+   if (!codec) {
+     // This is an indication that FFmpeg has not been initialized or it has not
+     // been compiled/initialized with the correct set of codecs.
diff --git a/srcpkgs/qt5-webengine/template b/srcpkgs/qt5-webengine/template
index 84de5b12ecdda..b89fe4c1ad50a 100644
--- a/srcpkgs/qt5-webengine/template
+++ b/srcpkgs/qt5-webengine/template
@@ -1,9 +1,9 @@
 # Template file for 'qt5-webengine'
 pkgname=qt5-webengine
-version=5.15.11
-revision=5
+version=5.15.13
+revision=1
 _version="${version}-lts"
-_chromium_commit=be349eaf62e77955791d7bf29f893f1e8a37daf4
+_chromium_commit=e48df7803c7c98b0b2471c94057d32e44a301ad5
 archs="x86_64* i686* armv[67]* ppc64* aarch64*"
 create_wrksrc=yes
 build_style=qmake
@@ -32,8 +32,8 @@ license="GPL-3.0-or-later, LGPL-3.0-or-later"
 homepage="https://qt.io/"
 distfiles="https://github.com/qt/qtwebengine/archive/v${_version}.tar.gz
  https://github.com/qt/qtwebengine-chromium/archive/${_chromium_commit}.tar.gz"
-checksum="aa7466356c450c5f5870f979b93cd7e7e62da1165c328ffcab1a9928db18ad67
- 6f47ed8ab8cc062411f6f206da6353bc8263d6ed6d6290c689a05c01d91f646b"
+checksum="4b59838ed75ef788b59e1e412535a0e42dd9d311661fdeadb191b581ba815c63
+ a91686562b1d4e8b220e0bbcbab5feb64630e2de974b35ac034bf388af771a6c"
 
 no_generic_pkgconfig_link=yes
 build_options="sndio pipewire"

From 956e64a80652fb3f82d94be0217fa2d065cca595 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 062/115] qt5: update to 5.15.8

---
 ...erywhere-opensource-src-5.15.8-kf5-1.patch | 12913 ++++++++++++++++
 srcpkgs/qt5/template                          |    13 +-
 2 files changed, 12919 insertions(+), 7 deletions(-)
 create mode 100644 srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch

diff --git a/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch b/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch
new file mode 100644
index 0000000000000..966c98bcd3bb1
--- /dev/null
+++ b/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch
@@ -0,0 +1,12913 @@
+Submitted By:            Pierre Labastie <pierre_dot_labastie_at_neuf_dot_fr>
+Date:                    2023-01-05
+Initial Package Version: 5.15.8
+Upstream Status:         Applied (according to KDE)
+Origin:                  KDE patch set
+Description:             Patch set maintained by the KDE folks
+see https://dot.kde.org/2021/04/06/announcing-kdes-qt-5-patch-collection
+Patch generated using the procedure in
+https://wiki.linuxfromscratch.org/blfs/ticket/17476#comment:3
+
+Submodule qtbase 4ee4fc18..9cf586d6:
+diff --git a/qtbase/mkspecs/common/android/qplatformdefs.h b/qtbase/mkspecs/common/android/qplatformdefs.h
+index f75bc4093b..2bd59410d4 100644
+--- a/qtbase/mkspecs/common/android/qplatformdefs.h
++++ b/qtbase/mkspecs/common/android/qplatformdefs.h
+@@ -144,11 +144,7 @@
+ #define QT_SIGNAL_ARGS          int
+ #define QT_SIGNAL_IGNORE        SIG_IGN
+ 
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+ #define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+ 
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+diff --git a/qtbase/mkspecs/features/mac/sdk.mk b/qtbase/mkspecs/features/mac/sdk.mk
+index f30b5830b4..a32ceacb6c 100644
+--- a/qtbase/mkspecs/features/mac/sdk.mk
++++ b/qtbase/mkspecs/features/mac/sdk.mk
+@@ -1,6 +1,6 @@
+ 
+ ifeq ($(QT_MAC_SDK_NO_VERSION_CHECK),)
+-    CHECK_SDK_COMMAND = /usr/bin/xcrun --sdk $(EXPORT_QMAKE_MAC_SDK) -show-sdk-version 2>&1
++    CHECK_SDK_COMMAND = /usr/bin/xcrun --sdk $(EXPORT_QMAKE_MAC_SDK) -show-sdk-version 2>/dev/null
+     CURRENT_MAC_SDK_VERSION := $(shell DEVELOPER_DIR=$(EXPORT_QMAKE_XCODE_DEVELOPER_PATH) $(CHECK_SDK_COMMAND))
+     ifneq ($(CURRENT_MAC_SDK_VERSION),$(EXPORT_QMAKE_MAC_SDK_VERSION))
+         # We don't want to complain about out of date SDK unless the target needs to be remade.
+diff --git a/qtbase/mkspecs/linux-clang/qplatformdefs.h b/qtbase/mkspecs/linux-clang/qplatformdefs.h
+index a818d973f0..c1ab72fbc6 100644
+--- a/qtbase/mkspecs/linux-clang/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-clang/qplatformdefs.h
+@@ -79,14 +79,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-g++/qplatformdefs.h b/qtbase/mkspecs/linux-g++/qplatformdefs.h
+index 13523f0702..4d2750d9ec 100644
+--- a/qtbase/mkspecs/linux-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-g++/qplatformdefs.h
+@@ -79,14 +79,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ < 2)
+-#define QT_SOCKLEN_T            int
+-#else
+-#define QT_SOCKLEN_T            socklen_t
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-llvm/qplatformdefs.h b/qtbase/mkspecs/linux-llvm/qplatformdefs.h
+index dc750ab1ef..d3cc39b47f 100644
+--- a/qtbase/mkspecs/linux-llvm/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-llvm/qplatformdefs.h
+@@ -80,14 +80,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h b/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
+index 4c4e53da2a..83baffb3e3 100644
+--- a/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
+@@ -85,16 +85,9 @@
+ #include "../common/posix/qplatformdefs.h"
+ 
+ #undef QT_OPEN_LARGEFILE
+-#undef QT_SOCKLEN_T
+ 
+ #define QT_OPEN_LARGEFILE       0
+ 
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #ifndef SIOCGIFBRDADDR
+ #  define SIOCGIFBRDADDR 0x8919
+ #endif
+diff --git a/qtbase/mkspecs/lynxos-g++/qplatformdefs.h b/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
+index 4339ea2b23..6007af0055 100644
+--- a/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
+@@ -72,14 +72,6 @@
+ 
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp b/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
+index c3c184258f..32af3f8f29 100644
+--- a/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
++++ b/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
+@@ -10,6 +10,7 @@
+ #include "libANGLE/HandleAllocator.h"
+ 
+ #include <algorithm>
++#include <limits>
+ 
+ #include "common/debug.h"
+ 
+diff --git a/qtbase/src/3rdparty/forkfd/forkfd_linux.c b/qtbase/src/3rdparty/forkfd/forkfd_linux.c
+index ffe0e9a5e2..b1f5408d11 100644
+--- a/qtbase/src/3rdparty/forkfd/forkfd_linux.c
++++ b/qtbase/src/3rdparty/forkfd/forkfd_linux.c
+@@ -82,7 +82,8 @@ static int sys_clone(unsigned long cloneflags, int *ptid)
+     return syscall(__NR_clone, cloneflags, child_stack, stack_size, ptid, newtls, ctid);
+ #elif defined(__arc__) || defined(__arm__) || defined(__aarch64__) || defined(__mips__) || \
+     defined(__nds32__) || defined(__hppa__) || defined(__powerpc__) || defined(__i386__) || \
+-    defined(__x86_64__) || defined(__xtensa__) || defined(__alpha__) || defined(__riscv)
++    defined(__x86_64__) || defined(__xtensa__) || defined(__alpha__) || defined(__riscv) || \
++    defined(__loongarch__)
+     /* ctid and newtls are inverted on CONFIG_CLONE_BACKWARDS architectures,
+      * but since both values are 0, there's no harm. */
+     return syscall(__NR_clone, cloneflags, child_stack, ptid, ctid, newtls);
+diff --git a/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java b/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
+index 5792b5b2f5..2f74750fcf 100644
+--- a/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
++++ b/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
+@@ -116,6 +116,7 @@ public class QtNative
+     public static QtThread m_qtThread = new QtThread();
+     private static HashMap<String, Uri> m_cachedUris = new HashMap<String, Uri>();
+     private static ArrayList<String> m_knownDirs = new ArrayList<String>();
++    private static final String NoPermissionErrorMessage = "No permissions to open Uri";
+ 
+     private static final Runnable runPendingCppRunnablesRunnable = new Runnable() {
+         @Override
+@@ -193,11 +194,10 @@ public class QtNative
+                     return iterUri;
+             }
+ 
+-            // Android 6 and earlier could still manage to open the file so we can return the
+-            // parsed uri here
+-            if (Build.VERSION.SDK_INT < 24)
+-                return parsedUri;
+-            return null;
++            // if we only have transient permissions on uri all the above will fail,
++            // but we will be able to read the file anyway, so continue with uri here anyway
++            // and check for SecurityExceptions later
++            return parsedUri;
+         } catch (SecurityException e) {
+             e.printStackTrace();
+             return null;
+@@ -244,7 +244,7 @@ public class QtNative
+         int error = -1;
+ 
+         if (uri == null) {
+-            Log.e(QtTAG, "openFdForContentUrl(): No permissions to open Uri");
++            Log.e(QtTAG, "openFdForContentUrl(): " + NoPermissionErrorMessage);
+             return error;
+         }
+ 
+@@ -254,12 +254,13 @@ public class QtNative
+             return fdDesc.detachFd();
+         } catch (FileNotFoundException e) {
+             e.printStackTrace();
+-            return error;
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "openFdForContentUrl(): Invalid Uri");
+             e.printStackTrace();
+-            return error;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return error;
+     }
+ 
+     public static long getSize(Context context, String contentUrl)
+@@ -270,7 +271,7 @@ public class QtNative
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+ 
+         if (uri == null) {
+-            Log.e(QtTAG, "getSize(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return size;
+         } else if (!m_cachedUris.containsKey(contentUrl)) {
+             m_cachedUris.put(contentUrl, uri);
+@@ -288,12 +289,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "getSize(): Invalid Uri");
+             e.printStackTrace();
+-            return size;
+         }  catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "getSize(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return size;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return size;
+     }
+ 
+     public static boolean checkFileExists(Context context, String contentUrl)
+@@ -303,7 +305,7 @@ public class QtNative
+         if (uri == null)
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+         if (uri == null) {
+-            Log.e(QtTAG, "checkFileExists(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return exists;
+         } else {
+             if (!m_cachedUris.containsKey(contentUrl))
+@@ -321,12 +323,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "checkFileExists(): Invalid Uri");
+             e.printStackTrace();
+-            return exists;
+         } catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "checkFileExists(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return false;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return exists;
+     }
+ 
+     public static boolean checkIfWritable(Context context, String contentUrl)
+@@ -344,7 +347,7 @@ public class QtNative
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+         }
+         if (uri == null) {
+-            Log.e(QtTAG, "isDir(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return isDir;
+         } else {
+             if (!m_cachedUris.containsKey(contentUrl))
+@@ -374,12 +377,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "checkIfDir(): Invalid Uri");
+             e.printStackTrace();
+-            return false;
+         } catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "checkIfDir(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return false;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return false;
+     }
+     public static String[] listContentsFromTreeUri(Context context, String contentUrl)
+     {
+diff --git a/qtbase/src/concurrent/qtconcurrentreducekernel.h b/qtbase/src/concurrent/qtconcurrentreducekernel.h
+index 8f9a938952..a98dedef2e 100644
+--- a/qtbase/src/concurrent/qtconcurrentreducekernel.h
++++ b/qtbase/src/concurrent/qtconcurrentreducekernel.h
+@@ -212,11 +212,13 @@ public:
+ 
+     inline bool shouldThrottle()
+     {
++        std::lock_guard<QMutex> locker(mutex);
+         return (resultsMapSize > (ReduceQueueThrottleLimit * threadCount));
+     }
+ 
+     inline bool shouldStartThread()
+     {
++        std::lock_guard<QMutex> locker(mutex);
+         return (resultsMapSize <= (ReduceQueueStartLimit * threadCount));
+     }
+ };
+diff --git a/qtbase/src/concurrent/qtconcurrentthreadengine.cpp b/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
+index ea6ce3ac42..7f91a2ba68 100644
+--- a/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
++++ b/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
+@@ -176,6 +176,39 @@ void ThreadEngineBase::startSingleThreaded()
+     finish();
+ }
+ 
++void ThreadEngineBase::startBlocking()
++{
++    start();
++    barrier.acquire();
++    startThreads();
++
++    bool throttled = false;
++#ifndef QT_NO_EXCEPTIONS
++    try {
++#endif
++        while (threadFunction() == ThrottleThread) {
++            if (threadThrottleExit()) {
++                throttled = true;
++                break;
++            }
++        }
++#ifndef QT_NO_EXCEPTIONS
++    } catch (QException &e) {
++        handleException(e);
++    } catch (...) {
++        handleException(QUnhandledException());
++    }
++#endif
++
++    if (throttled == false) {
++        barrier.release();
++    }
++
++    barrier.wait();
++    finish();
++    exceptionStore.throwPossibleException();
++}
++
+ void ThreadEngineBase::startThread()
+ {
+     startThreadInternal();
+diff --git a/qtbase/src/concurrent/qtconcurrentthreadengine.h b/qtbase/src/concurrent/qtconcurrentthreadengine.h
+index 7c30cebdbc..a4c8548cc4 100644
+--- a/qtbase/src/concurrent/qtconcurrentthreadengine.h
++++ b/qtbase/src/concurrent/qtconcurrentthreadengine.h
+@@ -91,6 +91,7 @@ public:
+     ThreadEngineBase();
+     virtual ~ThreadEngineBase();
+     void startSingleThreaded();
++    void startBlocking();
+     void startThread();
+     bool isCanceled();
+     void waitForResume();
+@@ -143,6 +144,15 @@ public:
+         return result();
+     }
+ 
++    // Runs the user algorithm using multiple threads.
++    // This function blocks until the algorithm is finished,
++    // and then returns the result.
++    T *startBlocking()
++    {
++        ThreadEngineBase::startBlocking();
++        return result();
++    }
++
+     // Runs the user algorithm using multiple threads.
+     // Does not block, returns a future.
+     QFuture<T> startAsynchronously()
+@@ -223,6 +233,13 @@ class ThreadEngineStarter : public ThreadEngineStarterBase<T>
+ public:
+     ThreadEngineStarter(TypedThreadEngine *eng)
+         : Base(eng) { }
++
++    T startBlocking()
++    {
++        T t = *this->threadEngine->startBlocking();
++        delete this->threadEngine;
++        return t;
++    }
+ };
+ 
+ // Full template specialization where T is void.
+@@ -232,6 +249,12 @@ class ThreadEngineStarter<void> : public ThreadEngineStarterBase<void>
+ public:
+     ThreadEngineStarter(ThreadEngine<void> *_threadEngine)
+         : ThreadEngineStarterBase<void>(_threadEngine) {}
++
++    void startBlocking()
++    {
++        this->threadEngine->startBlocking();
++        delete this->threadEngine;
++    }
+ };
+ 
+ //! [qtconcurrentthreadengine-1]
+diff --git a/qtbase/src/corelib/animation/qvariantanimation.cpp b/qtbase/src/corelib/animation/qvariantanimation.cpp
+index 98b02f0202..eac1524107 100644
+--- a/qtbase/src/corelib/animation/qvariantanimation.cpp
++++ b/qtbase/src/corelib/animation/qvariantanimation.cpp
+@@ -276,7 +276,9 @@ void QVariantAnimationPrivate::setCurrentValueForProgress(const qreal progress)
+ 
+     const qreal startProgress = currentInterval.start.first;
+     const qreal endProgress = currentInterval.end.first;
+-    const qreal localProgress = (progress - startProgress) / (endProgress - startProgress);
++    const qreal localProgress =
++            qIsNull(progress - startProgress) ? 0.0 // avoid 0/0 below
++            /* else */                        : (progress - startProgress) / (endProgress - startProgress);
+ 
+     QVariant ret = q->interpolated(currentInterval.start.second,
+                                    currentInterval.end.second,
+diff --git a/qtbase/src/corelib/global/qnamespace.h b/qtbase/src/corelib/global/qnamespace.h
+index ad4150b317..bf19b1627b 100644
+--- a/qtbase/src/corelib/global/qnamespace.h
++++ b/qtbase/src/corelib/global/qnamespace.h
+@@ -1864,7 +1864,7 @@ public:
+     QT_Q_ENUM(TimerType)
+     QT_Q_ENUM(ScrollPhase)
+     QT_Q_ENUM(MouseEventSource)
+-    QT_Q_FLAG(MouseEventFlag)
++    QT_Q_FLAG(MouseEventFlags)
+     QT_Q_ENUM(ChecksumType)
+     QT_Q_ENUM(HighDpiScaleFactorRoundingPolicy)
+     QT_Q_ENUM(TabFocusBehavior)
+diff --git a/qtbase/src/corelib/global/qrandom.cpp b/qtbase/src/corelib/global/qrandom.cpp
+index 10672c1f92..25f87c7e6a 100644
+--- a/qtbase/src/corelib/global/qrandom.cpp
++++ b/qtbase/src/corelib/global/qrandom.cpp
+@@ -383,7 +383,6 @@ struct QRandomGenerator::SystemAndGlobalGenerators
+ 
+         constexpr SystemAndGlobalGenerators g = {};
+         Q_UNUSED(g);
+-        Q_STATIC_ASSERT(std::is_literal_type<SystemAndGlobalGenerators>::value);
+ #endif
+     }
+ 
+diff --git a/qtbase/src/corelib/io/qbuffer.cpp b/qtbase/src/corelib/io/qbuffer.cpp
+index 595fcd2724..032c0ddd4b 100644
+--- a/qtbase/src/corelib/io/qbuffer.cpp
++++ b/qtbase/src/corelib/io/qbuffer.cpp
+@@ -41,6 +41,8 @@
+ #include <QtCore/qmetaobject.h>
+ #include "private/qiodevice_p.h"
+ 
++#include <limits>
++
+ QT_BEGIN_NAMESPACE
+ 
+ /** QBufferPrivate **/
+@@ -366,7 +368,9 @@ qint64 QBuffer::size() const
+ bool QBuffer::seek(qint64 pos)
+ {
+     Q_D(QBuffer);
+-    if (pos > d->buf->size() && isWritable()) {
++    const auto oldBufSize = d->buf->size();
++    constexpr qint64 MaxSeekPos = (std::numeric_limits<decltype(oldBufSize)>::max)();
++    if (pos <= MaxSeekPos && pos > oldBufSize && isWritable()) {
+         if (seek(d->buf->size())) {
+             const qint64 gapSize = pos - d->buf->size();
+             if (write(QByteArray(gapSize, 0)) != gapSize) {
+@@ -377,7 +381,7 @@ bool QBuffer::seek(qint64 pos)
+             return false;
+         }
+     } else if (pos > d->buf->size() || pos < 0) {
+-        qWarning("QBuffer::seek: Invalid pos: %d", int(pos));
++        qWarning("QBuffer::seek: Invalid pos: %lld", pos);
+         return false;
+     }
+     return QIODevice::seek(pos);
+diff --git a/qtbase/src/corelib/io/qfilesystemengine_win.cpp b/qtbase/src/corelib/io/qfilesystemengine_win.cpp
+index 81d3a71986..c86ed1f9b0 100644
+--- a/qtbase/src/corelib/io/qfilesystemengine_win.cpp
++++ b/qtbase/src/corelib/io/qfilesystemengine_win.cpp
+@@ -664,14 +664,14 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry)
+     return QFileSystemEntry(ret, QFileSystemEntry::FromInternalPath());
+ }
+ 
+-#if defined(Q_CC_MINGW) && WINVER < 0x0602 //  Windows 8 onwards
++#if defined(Q_CC_MINGW) && WINVER < 0x0602 && _WIN32_WINNT < _WIN32_WINNT_WIN8 //  Windows 8 onwards
+ 
+ typedef struct _FILE_ID_INFO {
+     ULONGLONG VolumeSerialNumber;
+     FILE_ID_128 FileId;
+ } FILE_ID_INFO, *PFILE_ID_INFO;
+ 
+-#endif // if defined (Q_CC_MINGW) && WINVER < 0x0602
++#endif // if defined(Q_CC_MINGW) && WINVER < 0x0602 && _WIN32_WINNT < _WIN32_WINNT_WIN8
+ 
+ // File ID for Windows up to version 7 and FAT32 drives
+ static inline QByteArray fileId(HANDLE handle)
+diff --git a/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp b/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
+index 94d9d06bcb..27e0b13b0b 100644
+--- a/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
++++ b/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
+@@ -366,7 +366,9 @@ void QInotifyFileSystemWatcherEngine::readFromInotify()
+     // qDebug("QInotifyFileSystemWatcherEngine::readFromInotify");
+ 
+     int buffSize = 0;
+-    ioctl(inotifyFd, FIONREAD, (char *) &buffSize);
++    if (ioctl(inotifyFd, FIONREAD, (char *) &buffSize) == -1 || buffSize == 0)
++        return;
++
+     QVarLengthArray<char, 4096> buffer(buffSize);
+     buffSize = read(inotifyFd, buffer.data(), buffSize);
+     char *at = buffer.data();
+diff --git a/qtbase/src/corelib/io/qlockfile_win.cpp b/qtbase/src/corelib/io/qlockfile_win.cpp
+index 277f8d4230..38ecef5550 100644
+--- a/qtbase/src/corelib/io/qlockfile_win.cpp
++++ b/qtbase/src/corelib/io/qlockfile_win.cpp
+@@ -48,6 +48,8 @@
+ #include "QtCore/qdebug.h"
+ #include "QtCore/qthread.h"
+ 
++#include "private/qsystemlibrary_p.h"
++
+ QT_BEGIN_NAMESPACE
+ 
+ static inline bool fileExists(const wchar_t *fileName)
+@@ -150,7 +152,7 @@ QString QLockFilePrivate::processNameByPid(qint64 pid)
+ #if !defined(Q_OS_WINRT)
+     typedef DWORD (WINAPI *GetModuleFileNameExFunc)(HANDLE, HMODULE, LPTSTR, DWORD);
+ 
+-    HMODULE hPsapi = LoadLibraryA("psapi");
++    HMODULE hPsapi = QSystemLibrary::load(L"psapi");
+     if (!hPsapi)
+         return QString();
+     GetModuleFileNameExFunc qGetModuleFileNameEx = reinterpret_cast<GetModuleFileNameExFunc>(
+diff --git a/qtbase/src/corelib/io/qprocess_unix.cpp b/qtbase/src/corelib/io/qprocess_unix.cpp
+index 50390e57f5..15c8f30745 100644
+--- a/qtbase/src/corelib/io/qprocess_unix.cpp
++++ b/qtbase/src/corelib/io/qprocess_unix.cpp
+@@ -1,7 +1,7 @@
+ /****************************************************************************
+ **
+ ** Copyright (C) 2016 The Qt Company Ltd.
+-** Copyright (C) 2016 Intel Corporation.
++** Copyright (C) 2022 Intel Corporation.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtCore module of the Qt Toolkit.
+@@ -422,14 +422,15 @@ void QProcessPrivate::startProcess()
+     // Add the program name to the argument list.
+     argv[0] = nullptr;
+     if (!program.contains(QLatin1Char('/'))) {
++        // findExecutable() returns its argument if it's an absolute path,
++        // otherwise it searches $PATH; returns empty if not found (we handle
++        // that case much later)
+         const QString &exeFilePath = QStandardPaths::findExecutable(program);
+-        if (!exeFilePath.isEmpty()) {
+-            const QByteArray &tmp = QFile::encodeName(exeFilePath);
+-            argv[0] = ::strdup(tmp.constData());
+-        }
+-    }
+-    if (!argv[0])
++        const QByteArray &tmp = QFile::encodeName(exeFilePath);
++        argv[0] = ::strdup(tmp.constData());
++    } else {
+         argv[0] = ::strdup(encodedProgramName.constData());
++    }
+ 
+     // Add every argument to the list
+     for (int i = 0; i < arguments.count(); ++i)
+@@ -983,15 +984,16 @@ bool QProcessPrivate::startDetached(qint64 *pid)
+                 envp = _q_dupEnvironment(environment.d.constData()->vars, &envc);
+             }
+ 
+-            QByteArray tmp;
+             if (!program.contains(QLatin1Char('/'))) {
++                // findExecutable() returns its argument if it's an absolute path,
++                // otherwise it searches $PATH; returns empty if not found (we handle
++                // that case much later)
+                 const QString &exeFilePath = QStandardPaths::findExecutable(program);
+-                if (!exeFilePath.isEmpty())
+-                    tmp = QFile::encodeName(exeFilePath);
++                const QByteArray &tmp = QFile::encodeName(exeFilePath);
++                argv[0] = ::strdup(tmp.constData());
++            } else {
++                argv[0] = ::strdup(QFile::encodeName(program));
+             }
+-            if (tmp.isEmpty())
+-                tmp = QFile::encodeName(program);
+-            argv[0] = tmp.data();
+ 
+             if (envp)
+                 qt_safe_execve(argv[0], argv, envp);
+diff --git a/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp b/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
+index 3a79c502af..997a634e76 100644
+--- a/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
++++ b/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
+@@ -3196,9 +3196,8 @@ bool QAbstractItemModel::beginMoveColumns(const QModelIndex &sourceParent, int s
+     destinationChange.needsAdjust = destinationParent.isValid() && destinationParent.row() >= sourceLast && destinationParent.parent() == sourceParent;
+     d->changes.push(destinationChange);
+ 
+-    d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Horizontal);
+-
+     emit columnsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, QPrivateSignal());
++    d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Horizontal);
+     return true;
+ }
+ 
+@@ -3231,7 +3230,6 @@ void QAbstractItemModel::endMoveColumns()
+       adjustedSource = createIndex(adjustedSource.row(), adjustedSource.column() + numMoved, adjustedSource.internalPointer());
+ 
+     d->itemsMoved(adjustedSource, removeChange.first, removeChange.last, adjustedDestination, insertChange.first, Qt::Horizontal);
+-
+     emit columnsMoved(adjustedSource, removeChange.first, removeChange.last, adjustedDestination, insertChange.first, QPrivateSignal());
+ }
+ 
+diff --git a/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+index dc6379d9fb..c5e287ee84 100644
+--- a/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
++++ b/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+@@ -939,8 +939,9 @@ void QSortFilterProxyModelPrivate::insert_source_items(
+                 q->beginInsertColumns(proxy_parent, proxy_start, proxy_end);
+         }
+ 
+-        for (int i = 0; i < source_items.size(); ++i)
+-            proxy_to_source.insert(proxy_start + i, source_items.at(i));
++        // TODO: use the range QList::insert() overload once it is implemented (QTBUG-58633).
++        proxy_to_source.insert(proxy_start, source_items.size(), 0);
++        std::copy(source_items.cbegin(), source_items.cend(), proxy_to_source.begin() + proxy_start);
+ 
+         build_source_to_proxy_mapping(proxy_to_source, source_to_proxy);
+ 
+@@ -3123,8 +3124,9 @@ bool QSortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex &
+ 
+     if (d->filter_data.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();
+@@ -3133,9 +3135,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.hasMatch(key);
+ }
+diff --git a/qtbase/src/corelib/kernel/qcoreapplication.cpp b/qtbase/src/corelib/kernel/qcoreapplication.cpp
+index ca2864df83..132b2eae52 100644
+--- a/qtbase/src/corelib/kernel/qcoreapplication.cpp
++++ b/qtbase/src/corelib/kernel/qcoreapplication.cpp
+@@ -1157,7 +1157,7 @@ static bool doNotify(QObject *receiver, QEvent *event)
+ bool QCoreApplicationPrivate::sendThroughApplicationEventFilters(QObject *receiver, QEvent *event)
+ {
+     // We can't access the application event filters outside of the main thread (race conditions)
+-    Q_ASSERT(receiver->d_func()->threadData.loadRelaxed()->thread.loadAcquire() == mainThread());
++    Q_ASSERT(receiver->d_func()->threadData.loadAcquire()->thread.loadRelaxed() == mainThread());
+ 
+     if (extraData) {
+         // application event filters are only called for objects in the GUI thread
+diff --git a/qtbase/src/corelib/kernel/qobject.cpp b/qtbase/src/corelib/kernel/qobject.cpp
+index 1eb79138d9..36cd780ee1 100644
+--- a/qtbase/src/corelib/kernel/qobject.cpp
++++ b/qtbase/src/corelib/kernel/qobject.cpp
+@@ -1010,7 +1010,7 @@ QObject::~QObject()
+         emit destroyed(this);
+     }
+ 
+-    if (d->declarativeData) {
++    if (!d->isDeletingChildren && d->declarativeData) {
+         if (static_cast<QAbstractDeclarativeDataImpl*>(d->declarativeData)->ownedByQml1) {
+             if (QAbstractDeclarativeData::destroyed_qml1)
+                 QAbstractDeclarativeData::destroyed_qml1(d->declarativeData, this);
+@@ -1580,7 +1580,7 @@ void QObject::moveToThread(QThread *targetThread)
+ 
+     QThreadData *currentData = QThreadData::current();
+     QThreadData *targetData = targetThread ? QThreadData::get2(targetThread) : nullptr;
+-    QThreadData *thisThreadData = d->threadData.loadRelaxed();
++    QThreadData *thisThreadData = d->threadData.loadAcquire();
+     if (!thisThreadData->thread.loadAcquire() && currentData == targetData) {
+         // one exception to the rule: we allow moving objects with no thread affinity to the current thread
+         currentData = d->threadData;
+@@ -2620,7 +2620,7 @@ int QObject::receivers(const char *signal) const
+         if (!d->isSignalConnected(signal_index))
+             return receivers;
+ 
+-        if (d->declarativeData && QAbstractDeclarativeData::receivers) {
++        if (!d->isDeletingChildren && d->declarativeData && QAbstractDeclarativeData::receivers) {
+             receivers += QAbstractDeclarativeData::receivers(d->declarativeData, this,
+                                                              signal_index);
+         }
+diff --git a/qtbase/src/corelib/kernel/qobject_p.h b/qtbase/src/corelib/kernel/qobject_p.h
+index 0b827a52ca..13ffb88999 100644
+--- a/qtbase/src/corelib/kernel/qobject_p.h
++++ b/qtbase/src/corelib/kernel/qobject_p.h
+@@ -444,7 +444,7 @@ inline void QObjectPrivate::checkForIncompatibleLibraryVersion(int version) cons
+ 
+ inline bool QObjectPrivate::isDeclarativeSignalConnected(uint signal_index) const
+ {
+-    return declarativeData && QAbstractDeclarativeData::isSignalConnected
++    return !isDeletingChildren && declarativeData && QAbstractDeclarativeData::isSignalConnected
+             && QAbstractDeclarativeData::isSignalConnected(declarativeData, q_func(), signal_index);
+ }
+ 
+diff --git a/qtbase/src/corelib/kernel/qtranslator.cpp b/qtbase/src/corelib/kernel/qtranslator.cpp
+index 2812ffb7ea..bc0177c5ec 100644
+--- a/qtbase/src/corelib/kernel/qtranslator.cpp
++++ b/qtbase/src/corelib/kernel/qtranslator.cpp
+@@ -902,7 +902,7 @@ static QString getMessage(const uchar *m, const uchar *end, const char *context,
+             goto end;
+         case Tag_Translation: {
+             int len = read32(m);
+-            if (len % 1)
++            if (len & 1)
+                 return QString();
+             m += 4;
+             if (!numerus--) {
+diff --git a/qtbase/src/corelib/mimetypes/qmimedatabase.cpp b/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
+index 9de22cef33..ff868a3268 100644
+--- a/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
+@@ -389,20 +389,23 @@ QMimeType QMimeDatabasePrivate::mimeTypeForFileNameAndData(const QString &fileNa
+         // Disambiguate conflicting extensions (if magic matching found something)
+         if (candidateByData.isValid() && magicAccuracy > 0) {
+             const QString sniffedMime = candidateByData.name();
+-            // If the sniffedMime matches a glob match, use it
++            // If the sniffedMime matches a highest-weight glob match, use it
+             if (candidatesByName.m_matchingMimeTypes.contains(sniffedMime)) {
+                 *accuracyPtr = 100;
+                 return candidateByData;
+             }
+-            for (const QString &m : qAsConst(candidatesByName.m_matchingMimeTypes)) {
++            for (const QString &m : qAsConst(candidatesByName.m_allMatchingMimeTypes)) {
+                 if (inherits(m, sniffedMime)) {
+                     // We have magic + pattern pointing to this, so it's a pretty good match
+                     *accuracyPtr = 100;
+                     return mimeTypeForName(m);
+                 }
+             }
+-            *accuracyPtr = magicAccuracy;
+-            return candidateByData;
++            if (candidatesByName.m_allMatchingMimeTypes.isEmpty()) {
++                // No glob, use magic
++                *accuracyPtr = magicAccuracy;
++                return candidateByData;
++            }
+         }
+     }
+ 
+diff --git a/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp b/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
+index a81112d227..fa8f4c545d 100644
+--- a/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
+@@ -83,7 +83,10 @@ void QMimeGlobMatchResult::addMatch(const QString &mimeType, int weight, const Q
+     }
+     if (!m_matchingMimeTypes.contains(mimeType)) {
+         m_matchingMimeTypes.append(mimeType);
+-        m_allMatchingMimeTypes.append(mimeType);
++        if (replace)
++            m_allMatchingMimeTypes.prepend(mimeType); // highest-weight first
++        else
++            m_allMatchingMimeTypes.append(mimeType);
+         m_knownSuffixLength = knownSuffixLength;
+     }
+ }
+@@ -94,7 +97,7 @@ QMimeGlobPattern::PatternType QMimeGlobPattern::detectPatternType(const QString
+     if (!patternLength)
+         return OtherPattern;
+ 
+-    const bool starCount = pattern.count(QLatin1Char('*')) == 1;
++    const int starCount = pattern.count(QLatin1Char('*'));
+     const bool hasSquareBracket = pattern.indexOf(QLatin1Char('[')) != -1;
+     const bool hasQuestionMark = pattern.indexOf(QLatin1Char('?')) != -1;
+ 
+@@ -106,10 +109,10 @@ QMimeGlobPattern::PatternType QMimeGlobPattern::detectPatternType(const QString
+             // Patterns like "README*" (well this is currently the only one like that...)
+             if (pattern.at(patternLength - 1) == QLatin1Char('*'))
+                 return PrefixPattern;
+-        }
+-        // Names without any wildcards like "README"
+-        if (starCount == 0)
++        } else if (starCount == 0) {
++            // Names without any wildcards like "README"
+             return LiteralPattern;
++        }
+     }
+ 
+     if (pattern == QLatin1String("[0-9][0-9][0-9].vdr"))
+diff --git a/qtbase/src/corelib/mimetypes/qmimeprovider.cpp b/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
+index 258dddf8cb..4642d0f2d0 100644
+--- a/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
+@@ -244,15 +244,18 @@ void QMimeBinaryProvider::addFileNameMatches(const QString &fileName, QMimeGlobM
+     const QString lowerFileName = fileName.toLower();
+     // Check literals (e.g. "Makefile")
+     matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosLiteralListOffset), fileName);
+-    // Check complex globs (e.g. "callgrind.out[0-9]*")
+-    matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosGlobListOffset), fileName);
+     // Check the very common *.txt cases with the suffix tree
+-    const int reverseSuffixTreeOffset = m_cacheFile->getUint32(PosReverseSuffixTreeOffset);
+-    const int numRoots = m_cacheFile->getUint32(reverseSuffixTreeOffset);
+-    const int firstRootOffset = m_cacheFile->getUint32(reverseSuffixTreeOffset + 4);
+-    matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, lowerFileName, lowerFileName.length() - 1, false);
++    if (result.m_matchingMimeTypes.isEmpty()) {
++        const int reverseSuffixTreeOffset = m_cacheFile->getUint32(PosReverseSuffixTreeOffset);
++        const int numRoots = m_cacheFile->getUint32(reverseSuffixTreeOffset);
++        const int firstRootOffset = m_cacheFile->getUint32(reverseSuffixTreeOffset + 4);
++        matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, lowerFileName, lowerFileName.length() - 1, false);
++        if (result.m_matchingMimeTypes.isEmpty())
++            matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, fileName, fileName.length() - 1, true);
++    }
++    // Check complex globs (e.g. "callgrind.out[0-9]*" or "README*")
+     if (result.m_matchingMimeTypes.isEmpty())
+-        matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, fileName, fileName.length() - 1, true);
++        matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosGlobListOffset), fileName);
+ }
+ 
+ void QMimeBinaryProvider::matchGlobList(QMimeGlobMatchResult &result, CacheFile *cacheFile, int off, const QString &fileName)
+diff --git a/qtbase/src/corelib/serialization/qjsonparser.cpp b/qtbase/src/corelib/serialization/qjsonparser.cpp
+index 17e6f111ab..2e40b6c8fb 100644
+--- a/qtbase/src/corelib/serialization/qjsonparser.cpp
++++ b/qtbase/src/corelib/serialization/qjsonparser.cpp
+@@ -379,10 +379,30 @@ error:
+     return QCborValue();
+ }
+ 
++// We need to retain the _last_ value for any duplicate keys and we need to deref containers.
++// Therefore the manual implementation of std::unique().
++template<typename Iterator, typename Compare, typename Assign>
++static Iterator customAssigningUniqueLast(Iterator first, Iterator last,
++                                          Compare compare, Assign assign)
++{
++    first = std::adjacent_find(first, last, compare);
++    if (first == last)
++        return last;
++
++    Iterator result = first;
++    while (++first != last) {
++        if (!compare(*result, *first))
++            ++result;
++        if (result != first)
++            assign(*result, *first);
++    }
++
++    return ++result;
++}
++
+ static void sortContainer(QCborContainerPrivate *container)
+ {
+     using Forward = QJsonPrivate::KeyIterator;
+-    using Reverse = std::reverse_iterator<Forward>;
+     using Value = Forward::value_type;
+ 
+     auto compare = [container](const Value &a, const Value &b)
+@@ -420,17 +440,31 @@ static void sortContainer(QCborContainerPrivate *container)
+         }
+     };
+ 
+-    std::sort(Forward(container->elements.begin()), Forward(container->elements.end()),
+-              [&compare](const Value &a, const Value &b) { return compare(a, b) < 0; });
++    // The elements' containers are owned by the outer container, not by the elements themselves.
++    auto move = [](Forward::reference target, Forward::reference source)
++    {
++        QtCbor::Element &targetValue = target.value();
++
++        // If the target has a container, deref it before overwriting, so that we don't leak.
++        if (targetValue.flags & QtCbor::Element::IsContainer)
++            targetValue.container->deref();
++
++        // Do not move, so that we can clear the value afterwards.
++        target = source;
++
++        // Clear the source value, so that we don't store the same container twice.
++        source.value() = QtCbor::Element();
++    };
++
++    std::stable_sort(
++                Forward(container->elements.begin()), Forward(container->elements.end()),
++                [&compare](const Value &a, const Value &b) { return compare(a, b) < 0; });
+ 
+-    // We need to retain the _last_ value for any duplicate keys. Therefore the reverse dance here.
+-    auto it = std::unique(Reverse(container->elements.end()), Reverse(container->elements.begin()),
+-                          [&compare](const Value &a, const Value &b) {
+-        return compare(a, b) == 0;
+-    }).base().elementsIterator();
++    Forward result = customAssigningUniqueLast(
++                Forward(container->elements.begin()),  Forward(container->elements.end()),
++                [&compare](const Value &a, const Value &b) { return compare(a, b) == 0; }, move);
+ 
+-    // The erase from beginning is expensive but hopefully rare.
+-    container->elements.erase(container->elements.begin(), it);
++    container->elements.erase(result.elementsIterator(), container->elements.end());
+ }
+ 
+ 
+diff --git a/qtbase/src/corelib/serialization/qxmlstream.cpp b/qtbase/src/corelib/serialization/qxmlstream.cpp
+index b2f846544d..7cd457ba3a 100644
+--- a/qtbase/src/corelib/serialization/qxmlstream.cpp
++++ b/qtbase/src/corelib/serialization/qxmlstream.cpp
+@@ -980,7 +980,7 @@ inline uint QXmlStreamReaderPrivate::peekChar()
+ bool QXmlStreamReaderPrivate::scanUntil(const char *str, short tokenToInject)
+ {
+     int pos = textBuffer.size();
+-    int oldLineNumber = lineNumber;
++    const auto oldLineNumber = lineNumber;
+ 
+     uint c;
+     while ((c = getChar()) != StreamEOF) {
+diff --git a/qtbase/src/corelib/text/qstring.cpp b/qtbase/src/corelib/text/qstring.cpp
+index 3e88ab4859..8deeae47bb 100644
+--- a/qtbase/src/corelib/text/qstring.cpp
++++ b/qtbase/src/corelib/text/qstring.cpp
+@@ -12312,7 +12312,7 @@ static qsizetype qLastIndexOf(Haystack haystack0, qsizetype from,
+     const auto needle = needle0.data();
+     const auto *end = haystack;
+     haystack += from;
+-    const std::size_t sl_minus_1 = sl - 1;
++    const std::size_t sl_minus_1 = sl ? sl - 1 : 0;
+     const auto *n = needle + sl_minus_1;
+     const auto *h = haystack + sl_minus_1;
+     std::size_t hashNeedle = 0, hashHaystack = 0;
+diff --git a/qtbase/src/corelib/text/qstringiterator_p.h b/qtbase/src/corelib/text/qstringiterator_p.h
+index 219589b6e4..1d0c66cc78 100644
+--- a/qtbase/src/corelib/text/qstringiterator_p.h
++++ b/qtbase/src/corelib/text/qstringiterator_p.h
+@@ -61,6 +61,8 @@ class QStringIterator
+ {
+     QString::const_iterator i, pos, e;
+     Q_STATIC_ASSERT((std::is_same<QString::const_iterator, const QChar *>::value));
++    static bool less(const QChar *lhs, const QChar *rhs) noexcept
++    { return std::less<QString::const_iterator>{}(lhs, rhs); }
+ public:
+     explicit QStringIterator(QStringView string, qsizetype idx = 0)
+         : i(string.begin()),
+@@ -95,7 +97,8 @@ public:
+ 
+     inline void setPosition(QString::const_iterator position)
+     {
+-        Q_ASSERT_X(i <= position && position <= e, Q_FUNC_INFO, "position out of bounds");
++        Q_ASSERT_X(!less(position, i) && !less(e, position),
++                   Q_FUNC_INFO, "position out of bounds");
+         pos = position;
+     }
+ 
+@@ -103,7 +106,7 @@ public:
+ 
+     inline bool hasNext() const
+     {
+-        return pos < e;
++        return less(pos, e);
+     }
+ 
+     inline void advance()
+@@ -120,16 +123,20 @@ public:
+     {
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+-        if (Q_UNLIKELY((pos++)->isHighSurrogate()))
++        if (Q_UNLIKELY((pos++)->isHighSurrogate())) {
++            Q_ASSERT(hasNext() && pos->isLowSurrogate());
+             ++pos;
++        }
+     }
+ 
+     inline uint peekNextUnchecked() const
+     {
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+-        if (Q_UNLIKELY(pos->isHighSurrogate()))
++        if (Q_UNLIKELY(pos->isHighSurrogate())) {
++            Q_ASSERT(less(pos + 1, e) && pos[1].isLowSurrogate());
+             return QChar::surrogateToUcs4(pos[0], pos[1]);
++        }
+ 
+         return pos->unicode();
+     }
+@@ -155,8 +162,10 @@ public:
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+         const QChar cur = *pos++;
+-        if (Q_UNLIKELY(cur.isHighSurrogate()))
++        if (Q_UNLIKELY(cur.isHighSurrogate())) {
++            Q_ASSERT(hasNext() && pos->isLowSurrogate());
+             return QChar::surrogateToUcs4(cur, *pos++);
++        }
+         return cur.unicode();
+     }
+ 
+@@ -166,7 +175,7 @@ public:
+ 
+         const QChar uc = *pos++;
+         if (Q_UNLIKELY(uc.isSurrogate())) {
+-            if (Q_LIKELY(uc.isHighSurrogate() && pos < e && pos->isLowSurrogate()))
++            if (Q_LIKELY(uc.isHighSurrogate() && hasNext() && pos->isLowSurrogate()))
+                 return QChar::surrogateToUcs4(uc, *pos++);
+             return invalidAs;
+         }
+@@ -178,7 +187,7 @@ public:
+ 
+     inline bool hasPrevious() const
+     {
+-        return pos > i;
++        return less(i, pos);
+     }
+ 
+     inline void recede()
+@@ -196,16 +205,20 @@ public:
+     {
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+-        if (Q_UNLIKELY((--pos)->isLowSurrogate()))
++        if (Q_UNLIKELY((--pos)->isLowSurrogate())) {
++            Q_ASSERT(hasPrevious() && pos[-1].isHighSurrogate());
+             --pos;
++        }
+     }
+ 
+     inline uint peekPreviousUnchecked() const
+     {
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+-        if (Q_UNLIKELY(pos[-1].isLowSurrogate()))
++        if (Q_UNLIKELY(pos[-1].isLowSurrogate())) {
++            Q_ASSERT(less(i + 1, pos) && pos[-2].isHighSurrogate());
+             return QChar::surrogateToUcs4(pos[-2], pos[-1]);
++        }
+         return pos[-1].unicode();
+     }
+ 
+@@ -230,8 +243,10 @@ public:
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+         const QChar cur = *--pos;
+-        if (Q_UNLIKELY(cur.isLowSurrogate()))
++        if (Q_UNLIKELY(cur.isLowSurrogate())) {
++            Q_ASSERT(hasPrevious() && pos[-1].isHighSurrogate());
+             return QChar::surrogateToUcs4(*--pos, cur);
++        }
+         return cur.unicode();
+     }
+ 
+@@ -241,7 +256,7 @@ public:
+ 
+         const QChar uc = *--pos;
+         if (Q_UNLIKELY(uc.isSurrogate())) {
+-            if (Q_LIKELY(uc.isLowSurrogate() && pos > i && pos[-1].isHighSurrogate()))
++            if (Q_LIKELY(uc.isLowSurrogate() && hasPrevious() && pos[-1].isHighSurrogate()))
+                 return QChar::surrogateToUcs4(*--pos, uc);
+             return invalidAs;
+         }
+diff --git a/qtbase/src/corelib/thread/qfutex_p.h b/qtbase/src/corelib/thread/qfutex_p.h
+index f287b752d7..e294537787 100644
+--- a/qtbase/src/corelib/thread/qfutex_p.h
++++ b/qtbase/src/corelib/thread/qfutex_p.h
+@@ -52,6 +52,7 @@
+ //
+ 
+ #include <qglobal.h>
++#include <QtCore/qtsan_impl.h>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -106,16 +107,13 @@ namespace QtLinuxFutex {
+     inline int _q_futex(int *addr, int op, int val, quintptr val2 = 0,
+                         int *addr2 = nullptr, int val3 = 0) noexcept
+     {
+-        // A futex call ensures total ordering on the futex words
+-        // (in either success or failure of the call). Instruct TSAN accordingly,
+-        // as TSAN does not understand the futex(2) syscall.
+-        _q_tsan_release(addr, addr2);
++        QtTsan::futexRelease(addr, addr2);
+ 
+         // we use __NR_futex because some libcs (like Android's bionic) don't
+         // provide SYS_futex etc.
+         int result = syscall(__NR_futex, addr, op | FUTEX_PRIVATE_FLAG, val, val2, addr2, val3);
+ 
+-        _q_tsan_acquire(addr, addr2);
++        QtTsan::futexAcquire(addr, addr2);
+ 
+         return result;
+     }
+diff --git a/qtbase/src/corelib/thread/qmutex.cpp b/qtbase/src/corelib/thread/qmutex.cpp
+index 310d1cb14f..7097122d8e 100644
+--- a/qtbase/src/corelib/thread/qmutex.cpp
++++ b/qtbase/src/corelib/thread/qmutex.cpp
+@@ -152,6 +152,7 @@ public:
+ 
+ /*!
+     \enum QMutex::RecursionMode
++    \obsolete Use QRecursiveMutex to create a recursive mutex.
+ 
+     \value Recursive  In this mode, a thread can lock the same mutex
+                       multiple times and the mutex won't be unlocked
+@@ -173,6 +174,7 @@ public:
+ 
+ /*!
+     Constructs a new mutex. The mutex is created in an unlocked state.
++    \obsolete Use QRecursiveMutex to create a recursive mutex.
+ 
+     If \a mode is QMutex::Recursive, a thread can lock the same mutex
+     multiple times and the mutex won't be unlocked until a
+@@ -197,7 +199,7 @@ QMutex::QMutex(RecursionMode mode)
+ QMutex::~QMutex()
+ {
+     QMutexData *d = d_ptr.loadRelaxed();
+-    if (isRecursive()) {
++    if (QBasicMutex::isRecursive()) {
+         delete static_cast<QRecursiveMutexPrivate *>(d);
+     } else if (d) {
+ #ifndef QT_LINUX_FUTEX
+diff --git a/qtbase/src/corelib/thread/qmutex.h b/qtbase/src/corelib/thread/qmutex.h
+index 73c9e00663..1bae573a03 100644
+--- a/qtbase/src/corelib/thread/qmutex.h
++++ b/qtbase/src/corelib/thread/qmutex.h
+@@ -42,6 +42,7 @@
+ 
+ #include <QtCore/qglobal.h>
+ #include <QtCore/qatomic.h>
++#include <QtCore/qtsan_impl.h>
+ #include <new>
+ 
+ #if __has_include(<chrono>)
+@@ -77,19 +78,37 @@ public:
+ 
+     // BasicLockable concept
+     inline void lock() QT_MUTEX_LOCK_NOEXCEPT {
++        QtTsan::mutexPreLock(this, 0u);
++
+         if (!fastTryLock())
+             lockInternal();
++
++        QtTsan::mutexPostLock(this, 0u, 0);
+     }
+ 
+     // BasicLockable concept
+     inline void unlock() noexcept {
+         Q_ASSERT(d_ptr.loadRelaxed()); //mutex must be locked
++
++        QtTsan::mutexPreUnlock(this, 0u);
++
+         if (!fastTryUnlock())
+             unlockInternal();
++
++        QtTsan::mutexPostUnlock(this, 0u);
+     }
+ 
+     bool tryLock() noexcept {
+-        return fastTryLock();
++        unsigned tsanFlags = QtTsan::TryLock;
++        QtTsan::mutexPreLock(this, tsanFlags);
++
++        const bool success = fastTryLock();
++
++        if (!success)
++            tsanFlags |= QtTsan::TryLockFailed;
++        QtTsan::mutexPostLock(this, tsanFlags, 0);
++
++        return success;
+     }
+ 
+     // Lockable concept
+@@ -134,8 +153,16 @@ public:
+ #else
+     QMutex() { d_ptr.storeRelaxed(nullptr); }
+ #endif
++#if QT_DEPRECATED_SINCE(5,15)
+     enum RecursionMode { NonRecursive, Recursive };
++    QT_DEPRECATED_VERSION_X(5, 15, "Use QRecursiveMutex instead of a recursive QMutex")
+     explicit QMutex(RecursionMode mode);
++
++    QT_DEPRECATED_VERSION_X(5, 15, "Use QRecursiveMutex instead of a recursive QMutex")
++    bool isRecursive() const noexcept
++    { return QBasicMutex::isRecursive(); }
++#endif
++
+     ~QMutex();
+ 
+     // BasicLockable concept
+@@ -166,9 +193,6 @@ public:
+     }
+ #endif
+ 
+-    bool isRecursive() const noexcept
+-    { return QBasicMutex::isRecursive(); }
+-
+ private:
+     Q_DISABLE_COPY(QMutex)
+     friend class QMutexLocker;
+diff --git a/qtbase/src/corelib/thread/qreadwritelock.cpp b/qtbase/src/corelib/thread/qreadwritelock.cpp
+index 8c28507d5a..9dd8503116 100644
+--- a/qtbase/src/corelib/thread/qreadwritelock.cpp
++++ b/qtbase/src/corelib/thread/qreadwritelock.cpp
+@@ -155,7 +155,7 @@ QReadWriteLock::QReadWriteLock(RecursionMode recursionMode)
+ */
+ QReadWriteLock::~QReadWriteLock()
+ {
+-    auto d = d_ptr.loadRelaxed();
++    auto d = d_ptr.loadAcquire();
+     if (isUncontendedLocked(d)) {
+         qWarning("QReadWriteLock: destroying locked QReadWriteLock");
+         return;
+@@ -445,7 +445,7 @@ void QReadWriteLock::unlock()
+ /*! \internal  Helper for QWaitCondition::wait */
+ QReadWriteLock::StateForWaitCondition QReadWriteLock::stateForWaitCondition() const
+ {
+-    QReadWriteLockPrivate *d = d_ptr.loadRelaxed();
++    QReadWriteLockPrivate *d = d_ptr.loadAcquire();
+     switch (quintptr(d) & StateMask) {
+     case StateLockedForRead: return LockedForRead;
+     case StateLockedForWrite: return LockedForWrite;
+@@ -453,6 +453,7 @@ QReadWriteLock::StateForWaitCondition QReadWriteLock::stateForWaitCondition() co
+ 
+     if (!d)
+         return Unlocked;
++    const auto lock = qt_scoped_lock(d->mutex);
+     if (d->writerCount > 1)
+         return RecursivelyLocked;
+     else if (d->writerCount == 1)
+diff --git a/qtbase/src/corelib/thread/qsemaphore.cpp b/qtbase/src/corelib/thread/qsemaphore.cpp
+index 1d01fc1b28..3ecdee3747 100644
+--- a/qtbase/src/corelib/thread/qsemaphore.cpp
++++ b/qtbase/src/corelib/thread/qsemaphore.cpp
+@@ -354,7 +354,12 @@ void QSemaphore::release(int n)
+         quintptr nn = unsigned(n);
+         if (futexHasWaiterCount)
+             nn |= quint64(nn) << 32;    // token count replicated in high word
+-        quintptr prevValue = u.fetchAndAddRelease(nn);
++        quintptr prevValue = u.loadRelaxed();
++        quintptr newValue;
++        do { // loop just to ensure the operations are done atomically
++            newValue = prevValue + nn;
++            newValue &= (futexNeedsWakeAllBit - 1);
++        } while (!u.testAndSetRelease(prevValue, newValue, prevValue));
+         if (futexNeedsWake(prevValue)) {
+ #ifdef FUTEX_OP
+             if (futexHasWaiterCount) {
+@@ -376,7 +381,6 @@ void QSemaphore::release(int n)
+                 quint32 oparg = 0;
+                 quint32 cmp = FUTEX_OP_CMP_NE;
+                 quint32 cmparg = 0;
+-                u.fetchAndAndRelease(futexNeedsWakeAllBit - 1);
+                 futexWakeOp(*futexLow32(&u), n, INT_MAX, *futexHigh32(&u), FUTEX_OP(op, oparg, cmp, cmparg));
+                 return;
+             }
+@@ -388,7 +392,6 @@ 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(futexNeedsWakeAllBit - 1);
+             if (futexHasWaiterCount) {
+                 futexWakeAll(*futexLow32(&u));
+                 futexWakeAll(*futexHigh32(&u));
+diff --git a/qtbase/src/corelib/thread/qthread_p.h b/qtbase/src/corelib/thread/qthread_p.h
+index b2d1628e6e..f32f6f0460 100644
+--- a/qtbase/src/corelib/thread/qthread_p.h
++++ b/qtbase/src/corelib/thread/qthread_p.h
+@@ -174,7 +174,7 @@ public:
+     int returnCode;
+ 
+     uint stackSize;
+-    QThread::Priority priority;
++    std::underlying_type<QThread::Priority>::type priority;
+ 
+     static QThread *threadForId(int id);
+ 
+@@ -213,6 +213,13 @@ public:
+             QCoreApplication::instance()->postEvent(q_ptr, new QEvent(QEvent::Quit));
+         }
+     }
++
++#ifndef Q_OS_INTEGRITY
++private:
++    // Used in QThread(Private)::start to avoid racy access to QObject::objectName,
++    // unset afterwards. On INTEGRITY we set the thread name before starting it.
++    QString objectName;
++#endif
+ };
+ 
+ #else // QT_CONFIG(thread)
+diff --git a/qtbase/src/corelib/thread/qthread_unix.cpp b/qtbase/src/corelib/thread/qthread_unix.cpp
+index 56a8e0a038..610117a640 100644
+--- a/qtbase/src/corelib/thread/qthread_unix.cpp
++++ b/qtbase/src/corelib/thread/qthread_unix.cpp
+@@ -169,8 +169,7 @@ static void set_thread_data(QThreadData *data)
+ 
+ static void clear_thread_data()
+ {
+-    currentThreadData = nullptr;
+-    pthread_setspecific(current_thread_data_key, nullptr);
++    set_thread_data(nullptr);
+ }
+ 
+ template <typename T>
+@@ -296,7 +295,7 @@ void *QThreadPrivate::start(void *arg)
+             QMutexLocker locker(&thr->d_func()->mutex);
+ 
+             // do we need to reset the thread priority?
+-            if (int(thr->d_func()->priority) & ThreadPriorityResetFlag) {
++            if (thr->d_func()->priority & ThreadPriorityResetFlag) {
+                 thr->d_func()->setPriority(QThread::Priority(thr->d_func()->priority & ~ThreadPriorityResetFlag));
+             }
+ 
+@@ -316,10 +315,10 @@ void *QThreadPrivate::start(void *arg)
+             // Sets the name of the current thread. We can only do this
+             // when the thread is starting, as we don't have a cross
+             // platform way of setting the name of an arbitrary thread.
+-            if (Q_LIKELY(thr->objectName().isEmpty()))
++            if (Q_LIKELY(thr->d_func()->objectName.isEmpty()))
+                 setCurrentThreadName(thr->metaObject()->className());
+             else
+-                setCurrentThreadName(thr->objectName().toLocal8Bit());
++                setCurrentThreadName(std::exchange(thr->d_func()->objectName, {}).toLocal8Bit());
+         }
+ #endif
+ 
+@@ -671,7 +670,7 @@ void QThread::start(Priority priority)
+                 // could not set scheduling hints, fallback to inheriting them
+                 // we'll try again from inside the thread
+                 pthread_attr_setinheritsched(&attr, PTHREAD_INHERIT_SCHED);
+-                d->priority = Priority(priority | ThreadPriorityResetFlag);
++                d->priority = static_cast<std::underlying_type<QThread::Priority>::type>(priority) | ThreadPriorityResetFlag;
+             }
+             break;
+         }
+@@ -702,7 +701,10 @@ void QThread::start(Priority priority)
+         pthread_attr_setthreadname(&attr, metaObject()->className());
+     else
+         pthread_attr_setthreadname(&attr, objectName().toLocal8Bit());
++#else
++    d->objectName = objectName();
+ #endif
++
+     pthread_t threadId;
+     int code = pthread_create(&threadId, &attr, QThreadPrivate::start, this);
+     if (code == EPERM) {
+diff --git a/qtbase/src/corelib/thread/qthread_win.cpp b/qtbase/src/corelib/thread/qthread_win.cpp
+index bc70e3178a..4e76972498 100644
+--- a/qtbase/src/corelib/thread/qthread_win.cpp
++++ b/qtbase/src/corelib/thread/qthread_win.cpp
+@@ -394,10 +394,9 @@ unsigned int __stdcall QT_ENSURE_STACK_ALIGNED_FOR_SSE QThreadPrivate::start(voi
+ 
+ #if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) && !defined(Q_OS_WINRT)
+     // sets the name of the current thread.
+-    QByteArray objectName = thr->objectName().toLocal8Bit();
+-    qt_set_thread_name(HANDLE(-1),
+-                       objectName.isEmpty() ?
+-                       thr->metaObject()->className() : objectName.constData());
++    qt_set_thread_name(HANDLE(-1), thr->d_func()->objectName.isEmpty()
++                        ? thr->metaObject()->className()
++                        : std::exchange(thr->d_func()->objectName, {}).toLocal8Bit().constData());
+ #endif
+ 
+     emit thr->started(QThread::QPrivateSignal());
+@@ -503,6 +502,7 @@ void QThread::start(Priority priority)
+     if (d->running)
+         return;
+ 
++    d->objectName = objectName();
+     d->running = true;
+     d->finished = false;
+     d->exited = false;
+@@ -548,7 +548,7 @@ void QThread::start(Priority priority)
+ 
+     int prio;
+     d->priority = priority;
+-    switch (d->priority) {
++    switch (priority) {
+     case IdlePriority:
+         prio = THREAD_PRIORITY_IDLE;
+         break;
+@@ -686,7 +686,7 @@ void QThreadPrivate::setPriority(QThread::Priority threadPriority)
+ 
+     int prio;
+     priority = threadPriority;
+-    switch (priority) {
++    switch (threadPriority) {
+     case QThread::IdlePriority:
+         prio = THREAD_PRIORITY_IDLE;
+         break;
+diff --git a/qtbase/src/corelib/thread/qtsan_impl.h b/qtbase/src/corelib/thread/qtsan_impl.h
+new file mode 100644
+index 0000000000..580a738b91
+--- /dev/null
++++ b/qtbase/src/corelib/thread/qtsan_impl.h
+@@ -0,0 +1,115 @@
++/****************************************************************************
++**
++** Copyright (C) 2017 Intel Corporation.
++** Copyright (C) 2022 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
++** 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 QTSAN_IMPL_H
++#define QTSAN_IMPL_H
++
++#include <QtCore/qglobal.h>
++
++#if (__has_feature(thread_sanitizer) || defined(__SANITIZE_THREAD__)) && __has_include(<sanitizer/tsan_interface.h>)
++#  define QT_BUILDING_UNDER_TSAN
++#  include <sanitizer/tsan_interface.h>
++#endif
++
++QT_BEGIN_NAMESPACE
++
++namespace QtTsan {
++#ifdef QT_BUILDING_UNDER_TSAN
++inline void futexAcquire(void *addr, void *addr2 = nullptr)
++{
++    // A futex call ensures total ordering on the futex words
++    // (in either success or failure of the call). Instruct TSAN accordingly,
++    // as TSAN does not understand the futex(2) syscall (or equivalent).
++    ::__tsan_acquire(addr);
++    if (addr2)
++        ::__tsan_acquire(addr2);
++}
++
++inline void futexRelease(void *addr, void *addr2 = nullptr)
++{
++    if (addr2)
++        ::__tsan_release(addr2);
++    ::__tsan_release(addr);
++}
++
++inline void mutexPreLock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_pre_lock(addr, flags);
++}
++
++inline void mutexPostLock(void *addr, unsigned flags, int recursion)
++{
++    ::__tsan_mutex_post_lock(addr, flags, recursion);
++}
++
++inline void mutexPreUnlock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_pre_unlock(addr, flags);
++}
++
++inline void mutexPostUnlock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_post_unlock(addr, flags);
++}
++
++enum : unsigned {
++    MutexWriteReentrant = ::__tsan_mutex_write_reentrant,
++    TryLock = ::__tsan_mutex_try_lock,
++    TryLockFailed = ::__tsan_mutex_try_lock_failed,
++};
++#else
++inline void futexAcquire(void *, void * = nullptr) {}
++inline void futexRelease(void *, void * = nullptr) {}
++
++enum : unsigned {
++    MutexWriteReentrant,
++    TryLock,
++    TryLockFailed,
++};
++inline void mutexPreLock(void *, unsigned) {}
++inline void mutexPostLock(void *, unsigned, int) {}
++inline void mutexPreUnlock(void *, unsigned) {}
++inline void mutexPostUnlock(void *, unsigned) {}
++#endif // QT_BUILDING_UNDER_TSAN
++} // namespace QtTsan
++
++QT_END_NAMESPACE
++
++#endif // QTSAN_IMPL_H
+diff --git a/qtbase/src/corelib/thread/qwaitcondition_unix.cpp b/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
+index 88b058f410..0f1da4dc9b 100644
+--- a/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
++++ b/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
+@@ -213,7 +213,7 @@ bool QWaitCondition::wait(QMutex *mutex, QDeadlineTimer deadline)
+ {
+     if (! mutex)
+         return false;
+-    if (mutex->isRecursive()) {
++    if (static_cast<QBasicMutex *>(mutex)->isRecursive()) {
+         qWarning("QWaitCondition: cannot wait on recursive mutexes");
+         return false;
+     }
+diff --git a/qtbase/src/corelib/time/qdatetime.cpp b/qtbase/src/corelib/time/qdatetime.cpp
+index ec12569e3f..2c0b098079 100644
+--- a/qtbase/src/corelib/time/qdatetime.cpp
++++ b/qtbase/src/corelib/time/qdatetime.cpp
+@@ -43,6 +43,7 @@
+ #if QT_CONFIG(datetimeparser)
+ #include "private/qdatetimeparser_p.h"
+ #endif
++#include <private/qnumeric_p.h>
+ 
+ #include "qdatastream.h"
+ #include "qset.h"
+@@ -1429,9 +1430,11 @@ QDate QDate::addDays(qint64 ndays) const
+     if (isNull())
+         return QDate();
+ 
+-    // Due to limits on minJd() and maxJd() we know that any overflow
+-    // will be invalid and caught by fromJulianDay().
+-    return fromJulianDay(jd + ndays);
++    qint64 r;
++    if (Q_UNLIKELY(add_overflow(jd, ndays, &r)))
++        return QDate();
++    else
++        return fromJulianDay(r);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/corelib/time/qtimezone.cpp b/qtbase/src/corelib/time/qtimezone.cpp
+index 0309e43e52..3d451696a1 100644
+--- a/qtbase/src/corelib/time/qtimezone.cpp
++++ b/qtbase/src/corelib/time/qtimezone.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2013 John Layt <jlayt@kde.org>
++** Copyright (C) 2020 John Layt <jlayt@kde.org>
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtCore module of the Qt Toolkit.
+@@ -975,9 +975,15 @@ QList<QByteArray> QTimeZone::windowsIdToIanaIds(const QByteArray &windowsId,
+ }
+ 
+ #ifndef QT_NO_DATASTREAM
++// Invalid, as an IANA ID: too long, starts with - and has other invalid characters in it
++static inline QString invalidId() { return QStringLiteral("-No Time Zone Specified!"); }
++
+ QDataStream &operator<<(QDataStream &ds, const QTimeZone &tz)
+ {
+-    tz.d->serialize(ds);
++    if (tz.isValid())
++        tz.d->serialize(ds);
++    else
++        ds << invalidId();
+     return ds;
+ }
+ 
+@@ -985,7 +991,9 @@ QDataStream &operator>>(QDataStream &ds, QTimeZone &tz)
+ {
+     QString ianaId;
+     ds >> ianaId;
+-    if (ianaId == QLatin1String("OffsetFromUtc")) {
++    if (ianaId == invalidId()) {
++        tz = QTimeZone();
++    } else if (ianaId == QLatin1String("OffsetFromUtc")) {
+         int utcOffset;
+         QString name;
+         QString abbreviation;
+diff --git a/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp b/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
+index b1611d7ddb..a7a6a72ccf 100644
+--- a/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
++++ b/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
+@@ -42,6 +42,7 @@
+ #include "qtimezone.h"
+ #include "qtimezoneprivate_p.h"
+ #include "private/qlocale_tools_p.h"
++#include "private/qlocking_p.h"
+ 
+ #include <QtCore/QDataStream>
+ #include <QtCore/QDateTime>
+@@ -62,6 +63,10 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++#if QT_CONFIG(icu)
++static QBasicMutex s_icu_mutex;
++#endif
++
+ /*
+     Private
+ 
+@@ -670,6 +675,9 @@ QTzTimeZonePrivate::~QTzTimeZonePrivate()
+ 
+ QTzTimeZonePrivate *QTzTimeZonePrivate::clone() const
+ {
++#if QT_CONFIG(icu)
++    const auto lock = qt_scoped_lock(s_icu_mutex);
++#endif
+     return new QTzTimeZonePrivate(*this);
+ }
+ 
+@@ -913,12 +921,14 @@ QString QTzTimeZonePrivate::displayName(qint64 atMSecsSinceEpoch,
+                                         const QLocale &locale) const
+ {
+ #if QT_CONFIG(icu)
++    auto lock = qt_unique_lock(s_icu_mutex);
+     if (!m_icu)
+         m_icu = new QIcuTimeZonePrivate(m_id);
+     // TODO small risk may not match if tran times differ due to outdated files
+     // TODO Some valid TZ names are not valid ICU names, use translation table?
+     if (m_icu->isValid())
+         return m_icu->displayName(atMSecsSinceEpoch, nameType, locale);
++    lock.unlock();
+ #else
+     Q_UNUSED(nameType)
+     Q_UNUSED(locale)
+@@ -932,12 +942,14 @@ QString QTzTimeZonePrivate::displayName(QTimeZone::TimeType timeType,
+                                         const QLocale &locale) const
+ {
+ #if QT_CONFIG(icu)
++    auto lock = qt_unique_lock(s_icu_mutex);
+     if (!m_icu)
+         m_icu = new QIcuTimeZonePrivate(m_id);
+     // TODO small risk may not match if tran times differ due to outdated files
+     // TODO Some valid TZ names are not valid ICU names, use translation table?
+     if (m_icu->isValid())
+         return m_icu->displayName(timeType, nameType, locale);
++    lock.unlock();
+ #else
+     Q_UNUSED(timeType)
+     Q_UNUSED(nameType)
+diff --git a/qtbase/src/corelib/tools/qarraydata.h b/qtbase/src/corelib/tools/qarraydata.h
+index dcd95924c1..d01739e7e6 100644
+--- a/qtbase/src/corelib/tools/qarraydata.h
++++ b/qtbase/src/corelib/tools/qarraydata.h
+@@ -42,6 +42,7 @@
+ 
+ #include <QtCore/qrefcount.h>
+ #include <string.h>
++#include <cstdint>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -58,14 +59,14 @@ struct Q_CORE_EXPORT QArrayData
+     {
+         Q_ASSERT(size == 0
+                 || offset < 0 || size_t(offset) >= sizeof(QArrayData));
+-        return reinterpret_cast<char *>(this) + offset;
++        return reinterpret_cast<void *> (reinterpret_cast<uintptr_t>(this) + offset);
+     }
+ 
+     const void *data() const
+     {
+         Q_ASSERT(size == 0
+                 || offset < 0 || size_t(offset) >= sizeof(QArrayData));
+-        return reinterpret_cast<const char *>(this) + offset;
++        return reinterpret_cast<void *> (reinterpret_cast<uintptr_t>(this) + offset);
+     }
+ 
+     // This refers to array data mutability, not "header data" represented by
+diff --git a/qtbase/src/corelib/tools/qfreelist_p.h b/qtbase/src/corelib/tools/qfreelist_p.h
+index 5ba23b344b..9974102136 100644
+--- a/qtbase/src/corelib/tools/qfreelist_p.h
++++ b/qtbase/src/corelib/tools/qfreelist_p.h
+@@ -161,7 +161,7 @@ class QFreeList
+                 return i;
+             x -= size;
+         }
+-        Q_ASSERT(false);
++        Q_UNREACHABLE();
+         return -1;
+     }
+ 
+diff --git a/qtbase/src/corelib/tools/qversionnumber.h b/qtbase/src/corelib/tools/qversionnumber.h
+index d43b86ba51..2843f2b043 100644
+--- a/qtbase/src/corelib/tools/qversionnumber.h
++++ b/qtbase/src/corelib/tools/qversionnumber.h
+@@ -273,10 +273,10 @@ public:
+ 
+     Q_REQUIRED_RESULT Q_CORE_EXPORT QString toString() const;
+ #if QT_STRINGVIEW_LEVEL < 2
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(const QString &string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(const QString &string, int *suffixIndex = nullptr);
+ #endif
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QLatin1String string, int *suffixIndex = nullptr);
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QStringView string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(QLatin1String string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(QStringView string, int *suffixIndex = nullptr);
+ 
+ private:
+ #ifndef QT_NO_DATASTREAM
+diff --git a/qtbase/src/dbus/qdbusintegrator.cpp b/qtbase/src/dbus/qdbusintegrator.cpp
+index 5b66ce971b..28a3b0ffea 100644
+--- a/qtbase/src/dbus/qdbusintegrator.cpp
++++ b/qtbase/src/dbus/qdbusintegrator.cpp
+@@ -1135,7 +1135,13 @@ void QDBusConnectionPrivate::closeConnection()
+         }
+     }
+ 
+-    qDeleteAll(pendingCalls);
++    for (auto it = pendingCalls.begin(); it != pendingCalls.end(); ++it) {
++        auto call = *it;
++        if (!call->ref.deref()) {
++            delete call;
++        }
++    }
++    pendingCalls.clear();
+ 
+     // Disconnect all signals from signal hooks and from the object tree to
+     // avoid QObject::destroyed being sent to dbus daemon thread which has
+@@ -2584,6 +2590,11 @@ QDBusConnectionPrivate::findMetaObject(const QString &service, const QString &pa
+         if (mo)
+             return mo;
+     }
++    if (path.isEmpty()) {
++        error = QDBusError(QDBusError::InvalidObjectPath, QLatin1String("Object path cannot be empty"));
++        lastError = error;
++        return nullptr;
++    }
+ 
+     // introspect the target object
+     QDBusMessage msg = QDBusMessage::createMethodCall(service, path,
+diff --git a/qtbase/src/dbus/qdbusmetaobject.cpp b/qtbase/src/dbus/qdbusmetaobject.cpp
+index 5265568f42..7e9f0f1acc 100644
+--- a/qtbase/src/dbus/qdbusmetaobject.cpp
++++ b/qtbase/src/dbus/qdbusmetaobject.cpp
+@@ -210,6 +210,9 @@ QDBusMetaObjectGenerator::findType(const QByteArray &signature,
+         } else if (signature == "a{ss}") {
+             result.name = "QMap<QString,QString>";
+             type = qMetaTypeId<QMap<QString, QString> >();
++        } else if (signature == "aay") {
++            result.name = "QByteArrayList";
++            type = qMetaTypeId<QByteArrayList>();
+         } else {
+             result.name = "{D-Bus type \"" + signature + "\"}";
+             type = registerComplexDBusType(result.name);
+diff --git a/qtbase/src/gui/accessible/qaccessible.cpp b/qtbase/src/gui/accessible/qaccessible.cpp
+index d705bfccb5..0caf3c808c 100644
+--- a/qtbase/src/gui/accessible/qaccessible.cpp
++++ b/qtbase/src/gui/accessible/qaccessible.cpp
+@@ -54,6 +54,7 @@
+ #include <QtCore/qdebug.h>
+ #include <QtCore/qloggingcategory.h>
+ #include <QtCore/qmetaobject.h>
++#include <QtCore/private/qmetaobject_p.h>
+ #include <QtCore/qhash.h>
+ #include <private/qfactoryloader_p.h>
+ 
+@@ -681,6 +682,25 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
+     // Create a QAccessibleInterface for the object class. Start by the most
+     // derived class and walk up the class hierarchy.
+     const QMetaObject *mo = object->metaObject();
++    const auto *objectPriv = QObjectPrivate::get(object);
++    /*
++     We do not want to cache each and every QML metaobject (Button_QMLTYPE_124,
++     Button_QMLTYPE_125, etc.). Those dynamic metaobjects shouldn't have an
++     accessible interface in any case. Instead, we start the whole checking
++     with the first non-dynamic meta-object. To avoid potential regressions
++     in other areas of Qt that also use dynamic metaobjects, we only do this
++     for objects that are QML-related (approximated by checking whether they
++     have ddata set).
++    */
++    const bool qmlRelated = !objectPriv->isDeletingChildren &&
++                            objectPriv->declarativeData;
++    while (qmlRelated && mo) {
++        auto mop = QMetaObjectPrivate::get(mo);
++        if (!mop || !(mop->flags & DynamicMetaObject))
++            break;
++
++        mo = mo->superClass();
++    };
+     while (mo) {
+         const QString cn = QLatin1String(mo->className());
+ 
+@@ -696,14 +716,15 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
+         // Find a QAccessiblePlugin (factory) for the class name. If there's
+         // no entry in the cache try to create it using the plugin loader.
+         if (!qAccessiblePlugins()->contains(cn)) {
++            QAccessiblePlugin *factory = nullptr; // 0 means "no plugin found". This is cached as well.
+             const int index = loader()->indexOf(cn);
+-            if (index != -1) {
+-                QAccessiblePlugin *factory = qobject_cast<QAccessiblePlugin *>(loader()->instance(index));
+-                qAccessiblePlugins()->insert(cn, factory);
+-            }
++            if (index != -1)
++                factory = qobject_cast<QAccessiblePlugin *>(loader()->instance(index));
++            qAccessiblePlugins()->insert(cn, factory);
+         }
+ 
+         // At this point the cache should contain a valid factory pointer or 0:
++        Q_ASSERT(qAccessiblePlugins()->contains(cn));
+         QAccessiblePlugin *factory = qAccessiblePlugins()->value(cn);
+         if (factory) {
+             QAccessibleInterface *result = factory->create(cn, object);
+diff --git a/qtbase/src/gui/configure.json b/qtbase/src/gui/configure.json
+index 1f08795c57..12c95742d2 100644
+--- a/qtbase/src/gui/configure.json
++++ b/qtbase/src/gui/configure.json
+@@ -834,7 +834,8 @@
+                     "// embedded devices, are not intended to be used together with X. EGL support",
+                     "// has to be disabled in plugins like xcb in this case since the native display,",
+                     "// window and pixmap types will be different than what an X-based platform",
+-                    "// plugin would expect."
++                    "// plugin would expect.",
++                    "#define USE_X11"
+                 ],
+                 "include": [ "EGL/egl.h", "X11/Xlib.h" ],
+                 "main": [
+diff --git a/qtbase/src/gui/image/qbmphandler.cpp b/qtbase/src/gui/image/qbmphandler.cpp
+index 96f1e8cb1d..0e73bbbdb0 100644
+--- a/qtbase/src/gui/image/qbmphandler.cpp
++++ b/qtbase/src/gui/image/qbmphandler.cpp
+@@ -150,16 +150,42 @@ static QDataStream &operator<<(QDataStream &s, const BMP_INFOHDR &bi)
+     return s;
+ }
+ 
+-static int calc_shift(uint mask)
++static uint calc_shift(uint mask)
+ {
+-    int result = 0;
+-    while (mask && !(mask & 1)) {
++    uint result = 0;
++    while ((mask >= 0x100) || (!(mask & 1) && mask)) {
+         result++;
+         mask >>= 1;
+     }
+     return result;
+ }
+ 
++static uint calc_scale(uint low_mask)
++{
++    uint result = 8;
++    while (low_mask && result) {
++        result--;
++        low_mask >>= 1;
++    }
++    return result;
++}
++
++static inline uint apply_scale(uint value, uint scale)
++{
++    if (!(scale & 0x07)) // return immediately if scale == 8 or 0
++        return value;
++
++    uint filled = 8 - scale;
++    uint result = value << scale;
++
++    do {
++        result |= result >> filled;
++        filled <<= 1;
++    } while (filled < 8);
++
++    return result;
++}
++
+ static bool read_dib_fileheader(QDataStream &s, BMP_FILEHDR &bf)
+ {
+     // read BMP file header
+@@ -222,14 +248,14 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+     uint green_mask = 0;
+     uint blue_mask = 0;
+     uint alpha_mask = 0;
+-    int red_shift = 0;
+-    int green_shift = 0;
+-    int blue_shift = 0;
+-    int alpha_shift = 0;
+-    int red_scale = 0;
+-    int green_scale = 0;
+-    int blue_scale = 0;
+-    int alpha_scale = 0;
++    uint red_shift = 0;
++    uint green_shift = 0;
++    uint blue_shift = 0;
++    uint alpha_shift = 0;
++    uint red_scale = 0;
++    uint green_scale = 0;
++    uint blue_scale = 0;
++    uint alpha_scale = 0;
+ 
+     if (!d->isSequential())
+         d->seek(startpos + BMP_FILEHDR_SIZE + bi.biSize); // goto start of colormap or masks
+@@ -308,19 +334,19 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+         red_shift = calc_shift(red_mask);
+         if (((red_mask >> red_shift) + 1) == 0)
+             return false;
+-        red_scale = 256 / ((red_mask >> red_shift) + 1);
++        red_scale = calc_scale(red_mask >> red_shift);
+         green_shift = calc_shift(green_mask);
+         if (((green_mask >> green_shift) + 1) == 0)
+             return false;
+-        green_scale = 256 / ((green_mask >> green_shift) + 1);
++        green_scale = calc_scale(green_mask >> green_shift);
+         blue_shift = calc_shift(blue_mask);
+         if (((blue_mask >> blue_shift) + 1) == 0)
+             return false;
+-        blue_scale = 256 / ((blue_mask >> blue_shift) + 1);
++        blue_scale = calc_scale(blue_mask >> blue_shift);
+         alpha_shift = calc_shift(alpha_mask);
+         if (((alpha_mask >> alpha_shift) + 1) == 0)
+             return false;
+-        alpha_scale = 256 / ((alpha_mask >> alpha_shift) + 1);
++        alpha_scale = calc_scale(alpha_mask >> alpha_shift);
+     } else if (comp == BMP_RGB && (nbits == 24 || nbits == 32)) {
+         blue_mask = 0x000000ff;
+         green_mask = 0x0000ff00;
+@@ -328,17 +354,15 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+         blue_shift = 0;
+         green_shift = 8;
+         red_shift = 16;
+-        blue_scale = green_scale = red_scale = 1;
++        blue_scale = green_scale = red_scale = 0;
+     } else if (comp == BMP_RGB && nbits == 16) {
+         blue_mask = 0x001f;
+         green_mask = 0x03e0;
+         red_mask = 0x7c00;
+         blue_shift = 0;
+-        green_shift = 2;
+-        red_shift = 7;
+-        red_scale = 1;
+-        green_scale = 1;
+-        blue_scale = 8;
++        green_shift = 5;
++        red_shift = 10;
++        blue_scale = green_scale = red_scale = 3;
+     }
+ 
+ #if 0
+@@ -544,10 +568,10 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+                     c |= *(uchar*)(b+2)<<16;
+                 if (nbits > 24)
+                     c |= *(uchar*)(b+3)<<24;
+-                *p++ = qRgba(((c & red_mask) >> red_shift) * red_scale,
+-                                        ((c & green_mask) >> green_shift) * green_scale,
+-                                        ((c & blue_mask) >> blue_shift) * blue_scale,
+-                                        transp ? ((c & alpha_mask) >> alpha_shift) * alpha_scale : 0xff);
++                *p++ = qRgba(apply_scale((c & red_mask) >> red_shift, red_scale),
++                             apply_scale((c & green_mask) >> green_shift, green_scale),
++                             apply_scale((c & blue_mask) >> blue_shift, blue_scale),
++                             transp ? apply_scale((c & alpha_mask) >> alpha_shift, alpha_scale) : 0xff);
+                 b += nbits/8;
+             }
+         }
+diff --git a/qtbase/src/gui/image/qimage.cpp b/qtbase/src/gui/image/qimage.cpp
+index 7152ac1607..0df772564c 100644
+--- a/qtbase/src/gui/image/qimage.cpp
++++ b/qtbase/src/gui/image/qimage.cpp
+@@ -4694,6 +4694,8 @@ QImage QImage::smoothScaled(int w, int h) const {
+ static QImage rotated90(const QImage &image)
+ {
+     QImage out(image.height(), image.width(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+@@ -4722,6 +4724,8 @@ static QImage rotated180(const QImage &image)
+         return image.mirrored(true, true);
+ 
+     QImage out(image.width(), image.height(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+@@ -4734,6 +4738,8 @@ static QImage rotated180(const QImage &image)
+ static QImage rotated270(const QImage &image)
+ {
+     QImage out(image.height(), image.width(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+diff --git a/qtbase/src/gui/kernel/qcursor.cpp b/qtbase/src/gui/kernel/qcursor.cpp
+index d6ccaff8ed..455088241c 100644
+--- a/qtbase/src/gui/kernel/qcursor.cpp
++++ b/qtbase/src/gui/kernel/qcursor.cpp
+@@ -251,7 +251,8 @@ void QCursor::setPos(QScreen *screen, int x, int y)
+ {
+     if (screen) {
+         if (QPlatformCursor *cursor = screen->handle()->cursor()) {
+-            const QPoint devicePos = QHighDpi::toNativePixels(QPoint(x, y), screen);
++            const QPoint pos(x, y);
++            const QPoint devicePos = QHighDpi::toNativePixels(pos, screen->virtualSiblingAt(pos));
+             // Need to check, since some X servers generate null mouse move
+             // events, causing looping in applications which call setPos() on
+             // every mouse move event.
+diff --git a/qtbase/src/gui/kernel/qhighdpiscaling.cpp b/qtbase/src/gui/kernel/qhighdpiscaling.cpp
+index 9bbf2773a9..3ac4a4d8b6 100644
+--- a/qtbase/src/gui/kernel/qhighdpiscaling.cpp
++++ b/qtbase/src/gui/kernel/qhighdpiscaling.cpp
+@@ -580,9 +580,8 @@ void QHighDpiScaling::setScreenFactor(QScreen *screen, qreal factor)
+     else
+         qNamedScreenScaleFactors()->insert(name, factor);
+ 
+-    // hack to force re-evaluation of screen geometry
+     if (screen->handle())
+-        screen->d_func()->setPlatformScreen(screen->handle()); // updates geometries based on scale factor
++        screen->d_func()->updateLogicalDpi();
+ }
+ 
+ QPoint QHighDpiScaling::mapPositionToNative(const QPoint &pos, const QPlatformScreen *platformScreen)
+diff --git a/qtbase/src/gui/kernel/qkeysequence.cpp b/qtbase/src/gui/kernel/qkeysequence.cpp
+index a75b8ef920..4f2d294739 100644
+--- a/qtbase/src/gui/kernel/qkeysequence.cpp
++++ b/qtbase/src/gui/kernel/qkeysequence.cpp
+@@ -701,6 +701,10 @@ static const struct {
+     { Qt::Key_TouchpadToggle,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad Toggle") },
+     { Qt::Key_TouchpadOn,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad On") },
+     { Qt::Key_TouchpadOff,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad Off") },
++    { Qt::Key_Shift,  QT_TRANSLATE_NOOP("QShortcut", "Shift") },
++    { Qt::Key_Control,  QT_TRANSLATE_NOOP("QShortcut", "Control") },
++    { Qt::Key_Alt,  QT_TRANSLATE_NOOP("QShortcut", "Alt") },
++    { Qt::Key_Meta,  QT_TRANSLATE_NOOP("QShortcut", "Meta") },
+ 
+ };
+ static Q_CONSTEXPR int numKeyNames = sizeof keyname / sizeof *keyname;
+diff --git a/qtbase/src/gui/kernel/qplatformservices.cpp b/qtbase/src/gui/kernel/qplatformservices.cpp
+index fdc6a6c4aa..ac47f98c5d 100644
+--- a/qtbase/src/gui/kernel/qplatformservices.cpp
++++ b/qtbase/src/gui/kernel/qplatformservices.cpp
+@@ -55,6 +55,19 @@ QT_BEGIN_NAMESPACE
+     \brief The QPlatformServices provides the backend for desktop-related functionality.
+ */
+ 
++/*!
++    \enum QPlatformServices::Capability
++
++    Capabilities are used to determine a specific platform service's availability.
++
++    \value ColorPickingFromScreen The platform natively supports color picking from screen.
++    This capability indicates that the platform supports "opaque" color picking, where the
++    platform implements a complete user experience for color picking and outputs a color.
++    This is in contrast to the application implementing the color picking user experience
++    (taking care of showing a cross hair, instructing the platform integration to obtain
++    the color at a given pixel, etc.). The related service function is pickColor().
++ */
++
+ QPlatformServices::QPlatformServices()
+ { }
+ 
+@@ -85,5 +98,16 @@ QByteArray QPlatformServices::desktopEnvironment() const
+     return QByteArray("UNKNOWN");
+ }
+ 
++QPlatformServiceColorPicker *QPlatformServices::colorPicker(QWindow *parent)
++{
++    Q_UNUSED(parent);
++    return nullptr;
++}
++
++bool QPlatformServices::hasCapability(Capability capability) const
++{
++    Q_UNUSED(capability)
++    return false;
++}
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/gui/kernel/qplatformservices.h b/qtbase/src/gui/kernel/qplatformservices.h
+index 5de96cfa7d..a8b2a4ce71 100644
+--- a/qtbase/src/gui/kernel/qplatformservices.h
++++ b/qtbase/src/gui/kernel/qplatformservices.h
+@@ -50,16 +50,32 @@
+ //
+ 
+ #include <QtGui/qtguiglobal.h>
++#include <QtCore/qobject.h>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+ class QUrl;
++class QWindow;
++
++class Q_GUI_EXPORT QPlatformServiceColorPicker : public QObject
++{
++    Q_OBJECT
++public:
++    using QObject::QObject;
++    virtual void pickColor() = 0;
++Q_SIGNALS:
++    void colorPicked(const QColor &color);
++};
+ 
+ class Q_GUI_EXPORT QPlatformServices
+ {
+ public:
+     Q_DISABLE_COPY_MOVE(QPlatformServices)
+ 
++    enum Capability {
++        ColorPicking,
++    };
++
+     QPlatformServices();
+     virtual ~QPlatformServices() { }
+ 
+@@ -67,6 +83,10 @@ public:
+     virtual bool openDocument(const QUrl &url);
+ 
+     virtual QByteArray desktopEnvironment() const;
++
++    virtual bool hasCapability(Capability capability) const;
++
++    virtual QPlatformServiceColorPicker *colorPicker(QWindow *parent = nullptr);
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/gui/kernel/qplatformtheme.cpp b/qtbase/src/gui/kernel/qplatformtheme.cpp
+index 71521c0339..2325873245 100644
+--- a/qtbase/src/gui/kernel/qplatformtheme.cpp
++++ b/qtbase/src/gui/kernel/qplatformtheme.cpp
+@@ -163,6 +163,8 @@ QT_BEGIN_NAMESPACE
+ 
+     \value ShowShortcutsInContextMenus (bool) Whether to display shortcut key sequences in context menus.
+ 
++    \value ButtonPressKeys (QList<Qt::Key>) A list of keys that can be used to press buttons via keyboard input.
++
+     \sa themeHint(), QStyle::pixelMetric()
+ */
+ 
+@@ -563,6 +565,8 @@ QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint)
+         }
+     case MouseQuickSelectionThreshold:
+         return QVariant(10);
++    case ButtonPressKeys:
++        return QVariant::fromValue(QList<Qt::Key>({ Qt::Key_Space, Qt::Key_Select }));
+     }
+     return QVariant();
+ }
+diff --git a/qtbase/src/gui/kernel/qplatformtheme.h b/qtbase/src/gui/kernel/qplatformtheme.h
+index 3185fc4541..7e6c9d5740 100644
+--- a/qtbase/src/gui/kernel/qplatformtheme.h
++++ b/qtbase/src/gui/kernel/qplatformtheme.h
+@@ -120,7 +120,8 @@ public:
+         TouchDoubleTapDistance,
+         ShowShortcutsInContextMenus,
+         IconFallbackSearchPaths,
+-        MouseQuickSelectionThreshold
++        MouseQuickSelectionThreshold,
++        ButtonPressKeys
+     };
+ 
+     enum DialogType {
+diff --git a/qtbase/src/gui/kernel/qscreen.cpp b/qtbase/src/gui/kernel/qscreen.cpp
+index 8e0eb35116..5d172a58dd 100644
+--- a/qtbase/src/gui/kernel/qscreen.cpp
++++ b/qtbase/src/gui/kernel/qscreen.cpp
+@@ -77,6 +77,12 @@ QScreen::QScreen(QPlatformScreen *screen)
+     d->setPlatformScreen(screen);
+ }
+ 
++void QScreenPrivate::updateLogicalDpi()
++{
++    logicalDpi = QPlatformScreen::overrideDpi(platformScreen->logicalDpi());
++    updateGeometriesWithSignals(); // updates geometries based on scale factor
++}
++
+ void QScreenPrivate::updateGeometriesWithSignals()
+ {
+     const QRect oldGeometry = geometry;
+diff --git a/qtbase/src/gui/kernel/qscreen_p.h b/qtbase/src/gui/kernel/qscreen_p.h
+index 7da542c25e..e50fc3190b 100644
+--- a/qtbase/src/gui/kernel/qscreen_p.h
++++ b/qtbase/src/gui/kernel/qscreen_p.h
+@@ -70,6 +70,7 @@ public:
+         geometry = platformScreen->deviceIndependentGeometry();
+         availableGeometry = QHighDpi::fromNative(platformScreen->availableGeometry(), QHighDpiScaling::factor(platformScreen), geometry.topLeft());
+     }
++    void updateLogicalDpi();
+ 
+     void updatePrimaryOrientation();
+     void updateGeometriesWithSignals();
+diff --git a/qtbase/src/gui/painting/qblendfunctions_p.h b/qtbase/src/gui/painting/qblendfunctions_p.h
+index 080da98ec4..6997d62b3c 100644
+--- a/qtbase/src/gui/painting/qblendfunctions_p.h
++++ b/qtbase/src/gui/painting/qblendfunctions_p.h
+@@ -246,25 +246,32 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+                                   int dudx, int dvdx, int dudy, int dvdy, int u0, int v0,
+                                   Blender blender)
+ {
+-    int fromY = qMax(qRound(topY), clip.top());
+-    int toY = qMin(qRound(bottomY), clip.top() + clip.height());
++    qint64 fromY = qMax(qRound(topY), clip.top());
++    qint64 toY = qMin(qRound(bottomY), clip.top() + clip.height());
+     if (fromY >= toY)
+         return;
+ 
+     qreal leftSlope = (bottomLeft.x - topLeft.x) / (bottomLeft.y - topLeft.y);
+     qreal rightSlope = (bottomRight.x - topRight.x) / (bottomRight.y - topRight.y);
+-    int dx_l = int(leftSlope * 0x10000);
+-    int dx_r = int(rightSlope * 0x10000);
+-    int x_l = int((topLeft.x + (qreal(0.5) + fromY - topLeft.y) * leftSlope + qreal(0.5)) * 0x10000);
+-    int x_r = int((topRight.x + (qreal(0.5) + fromY - topRight.y) * rightSlope + qreal(0.5)) * 0x10000);
+-
+-    int fromX, toX, x1, x2, u, v, i, ii;
++    qint64 dx_l = qint64(leftSlope * 0x10000);
++    qint64 dx_r = qint64(rightSlope * 0x10000);
++    qint64 x_l = qint64((topLeft.x + (qreal(0.5) + fromY - topLeft.y) * leftSlope + qreal(0.5)) * 0x10000);
++    qint64 x_r = qint64((topRight.x + (qreal(0.5) + fromY - topRight.y) * rightSlope + qreal(0.5)) * 0x10000);
++
++    qint64 sourceRectTop = qint64(sourceRect.top());
++    qint64 sourceRectLeft = qint64(sourceRect.left());
++    qint64 sourceRectWidth = qint64(sourceRect.width());
++    qint64 sourceRectHeight = qint64(sourceRect.height());
++    qint64 clipLeft = qint64(clip.left());
++    qint64 clipWidth = qint64(clip.width());
++
++    qint64 fromX, toX, x1, x2, u, v, i, ii;
+     DestT *line;
+-    for (int y = fromY; y < toY; ++y) {
++    for (qint64 y = fromY; y < toY; ++y) {
+         line = reinterpret_cast<DestT *>(reinterpret_cast<uchar *>(destPixels) + y * dbpl);
+ 
+-        fromX = qMax(x_l >> 16, clip.left());
+-        toX = qMin(x_r >> 16, clip.left() + clip.width());
++        fromX = qMax(x_l >> 16, clipLeft);
++        toX = qMin(x_r >> 16, clipLeft + clipWidth);
+         if (fromX < toX) {
+             // Because of rounding, we can get source coordinates outside the source image.
+             // Clamp these coordinates to the source rect to avoid segmentation fault and
+@@ -275,10 +282,10 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             u = x1 * dudx + y * dudy + u0;
+             v = x1 * dvdx + y * dvdy + v0;
+             for (; x1 < toX; ++x1) {
+-                int uu = u >> 16;
+-                int vv = v >> 16;
+-                if (uu >= sourceRect.left() && uu < sourceRect.left() + sourceRect.width()
+-                    && vv >= sourceRect.top() && vv < sourceRect.top() + sourceRect.height()) {
++                qint64 uu = u >> 16;
++                qint64 vv = v >> 16;
++                if (uu >= sourceRectLeft && uu < sourceRectLeft + sourceRectWidth
++                    && vv >= sourceRectTop && vv < sourceRectTop + sourceRectHeight) {
+                     break;
+                 }
+                 u += dudx;
+@@ -290,10 +297,10 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             u = (x2 - 1) * dudx + y * dudy + u0;
+             v = (x2 - 1) * dvdx + y * dvdy + v0;
+             for (; x2 > x1; --x2) {
+-                int uu = u >> 16;
+-                int vv = v >> 16;
+-                if (uu >= sourceRect.left() && uu < sourceRect.left() + sourceRect.width()
+-                    && vv >= sourceRect.top() && vv < sourceRect.top() + sourceRect.height()) {
++                qint64 uu = u >> 16;
++                qint64 vv = v >> 16;
++                if (uu >= sourceRectLeft && uu < sourceRectLeft + sourceRectWidth
++                    && vv >= sourceRectTop && vv < sourceRectTop + sourceRectHeight) {
+                     break;
+                 }
+                 u -= dudx;
+@@ -308,8 +315,8 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             // Beginning of the scan line, with per-pixel checks.
+             i = x1 - fromX;
+             while (i) {
+-                int uu = qBound(sourceRect.left(), u >> 16, sourceRect.left() + sourceRect.width() - 1);
+-                int vv = qBound(sourceRect.top(), v >> 16, sourceRect.top() + sourceRect.height() - 1);
++                qint64 uu = qBound(sourceRectLeft, u >> 16, sourceRectLeft + sourceRectWidth - 1);
++                qint64 vv = qBound(sourceRectTop, v >> 16, sourceRectTop + sourceRectHeight - 1);
+                 blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + vv * sbpl)[uu]);
+                 u += dudx;
+                 v += dvdx;
+@@ -348,8 +355,8 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             // End of the scan line, with per-pixel checks.
+             i = toX - x2;
+             while (i) {
+-                int uu = qBound(sourceRect.left(), u >> 16, sourceRect.left() + sourceRect.width() - 1);
+-                int vv = qBound(sourceRect.top(), v >> 16, sourceRect.top() + sourceRect.height() - 1);
++                qint64 uu = qBound(sourceRectLeft, u >> 16, sourceRectLeft + sourceRectWidth - 1);
++                qint64 vv = qBound(sourceRectTop, v >> 16, sourceRectTop + sourceRectHeight - 1);
+                 blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + vv * sbpl)[uu]);
+                 u += dudx;
+                 v += dvdx;
+diff --git a/qtbase/src/gui/painting/qcolortrclut_p.h b/qtbase/src/gui/painting/qcolortrclut_p.h
+index 76a6a60803..24fd522e6c 100644
+--- a/qtbase/src/gui/painting/qcolortrclut_p.h
++++ b/qtbase/src/gui/painting/qcolortrclut_p.h
+@@ -118,6 +118,7 @@ public:
+         return QRgba64::fromRgba64(r, g, b, qAlpha(rgb32) * 257);
+ #endif
+     }
++    QRgba64 toLinear64(QRgba64) const = delete;
+ 
+     QRgb toLinear(QRgb rgb32) const
+     {
+diff --git a/qtbase/src/gui/painting/qdrawhelper.cpp b/qtbase/src/gui/painting/qdrawhelper.cpp
+index a61793508a..5ba2d277b7 100644
+--- a/qtbase/src/gui/painting/qdrawhelper.cpp
++++ b/qtbase/src/gui/painting/qdrawhelper.cpp
+@@ -6091,7 +6091,7 @@ static inline void alphargbblend_argb32(quint32 *dst, uint coverage, const QRgba
+ static inline void rgbBlendPixel(QRgba64 &dst, int coverage, QRgba64 slinear, const QColorTrcLut *colorProfile)
+ {
+     // Do a gammacorrected RGB alphablend...
+-    const QRgba64 dlinear = colorProfile ? colorProfile->toLinear64(dst) : dst;
++    const QRgba64 dlinear = colorProfile ? colorProfile->toLinear(dst) : dst;
+ 
+     QRgba64 blend = rgbBlend(dlinear, slinear, coverage);
+ 
+diff --git a/qtbase/src/gui/painting/qpaintengine_raster.cpp b/qtbase/src/gui/painting/qpaintengine_raster.cpp
+index 283923de52..f08eb9cbee 100644
+--- a/qtbase/src/gui/painting/qpaintengine_raster.cpp
++++ b/qtbase/src/gui/painting/qpaintengine_raster.cpp
+@@ -560,31 +560,6 @@ void QRasterPaintEngine::updateMatrix(const QTransform &matrix)
+     QRasterPaintEngineState *s = state();
+     // FALCON: get rid of this line, see drawImage call below.
+     s->matrix = matrix;
+-    QTransform::TransformationType txop = s->matrix.type();
+-
+-    switch (txop) {
+-
+-    case QTransform::TxNone:
+-        s->flags.int_xform = true;
+-        break;
+-
+-    case QTransform::TxTranslate:
+-        s->flags.int_xform = qreal(int(s->matrix.dx())) == s->matrix.dx()
+-                            && qreal(int(s->matrix.dy())) == s->matrix.dy();
+-        break;
+-
+-    case QTransform::TxScale:
+-        s->flags.int_xform = qreal(int(s->matrix.dx())) == s->matrix.dx()
+-                            && qreal(int(s->matrix.dy())) == s->matrix.dy()
+-                            && qreal(int(s->matrix.m11())) == s->matrix.m11()
+-                            && qreal(int(s->matrix.m22())) == s->matrix.m22();
+-        break;
+-
+-    default: // shear / perspective...
+-        s->flags.int_xform = false;
+-        break;
+-    }
+-
+     s->flags.tx_noshear = qt_scaleForTransform(s->matrix, &s->txscale);
+ 
+     ensureOutlineMapper();
+@@ -617,7 +592,6 @@ QRasterPaintEngineState::QRasterPaintEngineState()
+     flags.bilinear = false;
+     flags.legacy_rounding = false;
+     flags.fast_text = true;
+-    flags.int_xform = true;
+     flags.tx_noshear = true;
+     flags.fast_images = true;
+ 
+@@ -1793,7 +1767,7 @@ void QRasterPaintEngine::fill(const QVectorPath &path, const QBrush &brush)
+     QRectF cpRect = path.controlPointRect();
+     const QRectF pathDeviceRect = s->matrix.mapRect(cpRect);
+     // Skip paths that by conservative estimates are completely outside the paint device.
+-    if (!pathDeviceRect.intersects(QRectF(d->deviceRect)))
++    if (!pathDeviceRect.intersects(QRectF(d->deviceRect)) || !pathDeviceRect.isValid())
+         return;
+ 
+     ProcessSpans blend = d->getBrushFunc(pathDeviceRect, &s->brushData);
+diff --git a/qtbase/src/gui/painting/qpaintengine_raster_p.h b/qtbase/src/gui/painting/qpaintengine_raster_p.h
+index 089aadc3f7..bf7363d5aa 100644
+--- a/qtbase/src/gui/painting/qpaintengine_raster_p.h
++++ b/qtbase/src/gui/painting/qpaintengine_raster_p.h
+@@ -111,7 +111,6 @@ public:
+         uint bilinear : 1;
+         uint legacy_rounding : 1;
+         uint fast_text : 1;
+-        uint int_xform : 1;
+         uint tx_noshear : 1;
+         uint fast_images : 1;
+     };
+diff --git a/qtbase/src/gui/painting/qpainterpath.cpp b/qtbase/src/gui/painting/qpainterpath.cpp
+index f9544a3241..d80fafeaf1 100644
+--- a/qtbase/src/gui/painting/qpainterpath.cpp
++++ b/qtbase/src/gui/painting/qpainterpath.cpp
+@@ -1253,7 +1253,7 @@ void QPainterPath::addText(const QPointF &point, const QFont &f, const QString &
+ 
+         if (si.analysis.flags < QScriptAnalysis::TabOrObject) {
+             QGlyphLayout glyphs = eng->shapedGlyphs(&si);
+-            QFontEngine *fe = f.d->engineForScript(si.analysis.script);
++            QFontEngine *fe = eng->fontEngine(si);
+             Q_ASSERT(fe);
+             fe->addOutlineToPath(x, y, glyphs, this,
+                                  si.analysis.bidiLevel % 2
+diff --git a/qtbase/src/gui/painting/qpathclipper_p.h b/qtbase/src/gui/painting/qpathclipper_p.h
+index 9444a87b71..18f64c5e8c 100644
+--- a/qtbase/src/gui/painting/qpathclipper_p.h
++++ b/qtbase/src/gui/painting/qpathclipper_p.h
+@@ -156,7 +156,7 @@ public:
+     int vertex(Direction direction) const;
+ 
+ private:
+-    int m_next[2][2];
++    int m_next[2][2] = { { -1, -1 }, { -1, -1 } };
+ };
+ 
+ class QPathSegments
+@@ -296,10 +296,6 @@ inline QPathEdge::QPathEdge(int a, int b)
+     , angle(0)
+     , invAngle(0)
+ {
+-    m_next[0][0] = -1;
+-    m_next[1][0] = -1;
+-    m_next[0][0] = -1;
+-    m_next[1][0] = -1;
+ }
+ 
+ inline int QPathEdge::next(Traversal traversal, Direction direction) const
+diff --git a/qtbase/src/gui/painting/qpdf.cpp b/qtbase/src/gui/painting/qpdf.cpp
+index 3066744f1b..2c8d3c3b53 100644
+--- a/qtbase/src/gui/painting/qpdf.cpp
++++ b/qtbase/src/gui/painting/qpdf.cpp
+@@ -2760,6 +2760,8 @@ int QPdfEnginePrivate::addBrushPattern(const QTransform &m, bool *specifyColor,
+         return gradientBrush(brush, matrix, gStateObject);
+     }
+ 
++    matrix = brush.transform() * matrix;
++
+     if ((!brush.isOpaque() && brush.style() < Qt::LinearGradientPattern) || opacity != 1.0)
+         *gStateObject = addConstantAlphaObject(qRound(brush.color().alpha() * opacity),
+                                                qRound(pen.color().alpha() * opacity));
+diff --git a/qtbase/src/gui/painting/qstroker.cpp b/qtbase/src/gui/painting/qstroker.cpp
+index cb5d395e80..3b6357a893 100644
+--- a/qtbase/src/gui/painting/qstroker.cpp
++++ b/qtbase/src/gui/painting/qstroker.cpp
+@@ -1182,6 +1182,7 @@ void QDashStroker::processCurrentSubpath()
+         // Check if the entire line should be clipped away or simplified
+         bool clipIt = clipping && !lineIntersectsRect(prev, e, clip_tl, clip_br);
+         bool skipDashing = elen * invSumLength > repetitionLimit();
++        int maxDashes = dashCount;
+         if (skipDashing || clipIt) {
+             // Cut away full dash sequences.
+             elen -= std::floor(elen * invSumLength) * sumLength;
+@@ -1196,7 +1197,7 @@ void QDashStroker::processCurrentSubpath()
+                     pos = estop; // move pos to next path element
+                     done = true;
+                 } else { // Dash is on this line
+-                    pos = dpos + estart;
++                    pos = --maxDashes > 0 ? dpos + estart : estop;
+                     done = pos >= estop;
+                     if (++idash >= dashCount)
+                         idash = 0;
+diff --git a/qtbase/src/gui/painting/qt_attribution.json b/qtbase/src/gui/painting/qt_attribution.json
+index 7b16e8c211..0e87d30aa2 100644
+--- a/qtbase/src/gui/painting/qt_attribution.json
++++ b/qtbase/src/gui/painting/qt_attribution.json
+@@ -10,7 +10,7 @@
+         "Homepage": "http://www.freetype.org",
+         "License": "Freetype Project License or GNU General Public License v2.0 only",
+         "LicenseId": "FTL or GPL-2.0",
+-        "LicenseFile": "../../3rdparty/freetype/docs/LICENSE.TXT",
++        "LicenseFile": "../../3rdparty/freetype/LICENSE.TXT",
+         "Copyright": "Copyright 2000-2016 by David Turner, Robert Wilhelm, and Werner Lemberg."
+     },
+     {
+diff --git a/qtbase/src/gui/rhi/qshader_p_p.h b/qtbase/src/gui/rhi/qshader_p_p.h
+index ec9d25971f..4a5a7a6d51 100644
+--- a/qtbase/src/gui/rhi/qshader_p_p.h
++++ b/qtbase/src/gui/rhi/qshader_p_p.h
+@@ -68,13 +68,13 @@ struct Q_GUI_EXPORT QShaderPrivate
+     {
+     }
+ 
+-    QShaderPrivate(const QShaderPrivate *other)
++    QShaderPrivate(const QShaderPrivate &other)
+         : ref(1),
+-          qsbVersion(other->qsbVersion),
+-          stage(other->stage),
+-          desc(other->desc),
+-          shaders(other->shaders),
+-          bindings(other->bindings)
++          qsbVersion(other.qsbVersion),
++          stage(other.stage),
++          desc(other.desc),
++          shaders(other.shaders),
++          bindings(other.bindings)
+     {
+     }
+ 
+diff --git a/qtbase/src/gui/rhi/qshaderdescription_p_p.h b/qtbase/src/gui/rhi/qshaderdescription_p_p.h
+index ec2b0b6b4c..3da33a8a2b 100644
+--- a/qtbase/src/gui/rhi/qshaderdescription_p_p.h
++++ b/qtbase/src/gui/rhi/qshaderdescription_p_p.h
+@@ -63,16 +63,16 @@ struct Q_GUI_EXPORT QShaderDescriptionPrivate
+         localSize[0] = localSize[1] = localSize[2] = 0;
+     }
+ 
+-    QShaderDescriptionPrivate(const QShaderDescriptionPrivate *other)
++    QShaderDescriptionPrivate(const QShaderDescriptionPrivate &other)
+         : ref(1),
+-          inVars(other->inVars),
+-          outVars(other->outVars),
+-          uniformBlocks(other->uniformBlocks),
+-          pushConstantBlocks(other->pushConstantBlocks),
+-          storageBlocks(other->storageBlocks),
+-          combinedImageSamplers(other->combinedImageSamplers),
+-          storageImages(other->storageImages),
+-          localSize(other->localSize)
++          inVars(other.inVars),
++          outVars(other.outVars),
++          uniformBlocks(other.uniformBlocks),
++          pushConstantBlocks(other.pushConstantBlocks),
++          storageBlocks(other.storageBlocks),
++          combinedImageSamplers(other.combinedImageSamplers),
++          storageImages(other.storageImages),
++          localSize(other.localSize)
+     {
+     }
+ 
+diff --git a/qtbase/src/gui/text/qfontdatabase.cpp b/qtbase/src/gui/text/qfontdatabase.cpp
+index a657a8c516..4fc0100958 100644
+--- a/qtbase/src/gui/text/qfontdatabase.cpp
++++ b/qtbase/src/gui/text/qfontdatabase.cpp
+@@ -983,7 +983,7 @@ QFontEngine *loadSingleEngine(int script,
+         if (style->key.stretch != 0 && request.stretch != 0
+             && (request.styleName.isEmpty() || request.styleName != style->styleName)) {
+             def.stretch = (request.stretch * 100 + style->key.stretch / 2) / style->key.stretch;
+-        } else {
++        } else if (request.stretch == QFont::AnyStretch) {
+             def.stretch = 100;
+         }
+ 
+diff --git a/qtbase/src/gui/text/qtextdocumentlayout.cpp b/qtbase/src/gui/text/qtextdocumentlayout.cpp
+index f3e6ea2100..72267e9380 100644
+--- a/qtbase/src/gui/text/qtextdocumentlayout.cpp
++++ b/qtbase/src/gui/text/qtextdocumentlayout.cpp
+@@ -2123,7 +2123,7 @@ void QTextDocumentLayoutPrivate::drawListItem(const QPointF &offset, QPainter *p
+ {
+     Q_Q(const QTextDocumentLayout);
+     const QTextBlockFormat blockFormat = bl.blockFormat();
+-    const QTextCharFormat charFormat = QTextCursor(bl).charFormat();
++    const QTextCharFormat charFormat = bl.charFormat();
+     QFont font(charFormat.font());
+     if (q->paintDevice())
+         font = QFont(font, q->paintDevice());
+diff --git a/qtbase/src/gui/text/qtextengine.cpp b/qtbase/src/gui/text/qtextengine.cpp
+index ce4abac472..a6c66e5d2d 100644
+--- a/qtbase/src/gui/text/qtextengine.cpp
++++ b/qtbase/src/gui/text/qtextengine.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2021 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtGui module of the Qt Toolkit.
+@@ -1565,6 +1565,12 @@ void QTextEngine::shapeText(int item) const
+         // Overwrite with 0 token to indicate failure
+         QGlyphLayout g = availableGlyphs(&si);
+         g.glyphs[0] = 0;
++        g.attributes[0].clusterStart = true;
++
++        ushort *log_clusters = logClusters(&si);
++        for (int i = 0; i < itemLength; ++i)
++            log_clusters[i] = 0;
++
+         return;
+     }
+ 
+diff --git a/qtbase/src/gui/util/qdesktopservices.cpp b/qtbase/src/gui/util/qdesktopservices.cpp
+index fbb63a9408..4d5fafaaa7 100644
+--- a/qtbase/src/gui/util/qdesktopservices.cpp
++++ b/qtbase/src/gui/util/qdesktopservices.cpp
+@@ -54,6 +54,8 @@
+ #include <qpa/qplatformintegration.h>
+ #include <qdir.h>
+ 
++#include <QtCore/private/qlocking_p.h>
++
+ QT_BEGIN_NAMESPACE
+ 
+ class QOpenUrlHandlerRegistry : public QObject
+@@ -81,6 +83,7 @@ Q_GLOBAL_STATIC(QOpenUrlHandlerRegistry, handlerRegistry)
+ 
+ void QOpenUrlHandlerRegistry::handlerDestroyed(QObject *handler)
+ {
++    const auto lock = qt_scoped_lock(mutex);
+     HandlerHash::Iterator it = handlers.begin();
+     while (it != handlers.end()) {
+         if (it->receiver == handler) {
+@@ -294,7 +297,8 @@ void QDesktopServices::setUrlHandler(const QString &scheme, QObject *receiver, c
+     h.name = method;
+     registry->handlers.insert(scheme.toLower(), h);
+     QObject::connect(receiver, SIGNAL(destroyed(QObject*)),
+-                     registry, SLOT(handlerDestroyed(QObject*)));
++                     registry, SLOT(handlerDestroyed(QObject*)),
++                     Qt::DirectConnection);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/gui/util/qpkmhandler.cpp b/qtbase/src/gui/util/qpkmhandler.cpp
+index e0c3b75efe..3414f9d8ba 100644
+--- a/qtbase/src/gui/util/qpkmhandler.cpp
++++ b/qtbase/src/gui/util/qpkmhandler.cpp
+@@ -57,7 +57,7 @@ struct PkmType
+     quint32 bytesPerBlock;
+ };
+ 
+-static PkmType typeMap[5] = {
++static constexpr PkmType typeMap[5] = {
+     { 0x8D64,  8 },   // GL_ETC1_RGB8_OES
+     { 0x9274,  8 },   // GL_COMPRESSED_RGB8_ETC2
+     { 0, 0 },         // unused (obsolete)
+diff --git a/qtbase/src/network/access/qnetworkreplyfileimpl.cpp b/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
+index b6be93147a..6e69b4c4d3 100644
+--- a/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
++++ b/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
+@@ -89,9 +89,10 @@ QNetworkReplyFileImpl::QNetworkReplyFileImpl(QNetworkAccessManager *manager, con
+         // we handle only local files
+         QString msg = QCoreApplication::translate("QNetworkAccessFileBackend", "Request for opening non-local file %1").arg(url.toString());
+         setError(QNetworkReply::ProtocolInvalidOperationError, msg);
++        setFinished(true); // We're finished, will emit finished() after ctor is done.
+         QMetaObject::invokeMethod(this, "errorOccurred", Qt::QueuedConnection,
+             Q_ARG(QNetworkReply::NetworkError, QNetworkReply::ProtocolInvalidOperationError));
+-        fileOpenFinished(false);
++        QMetaObject::invokeMethod(this, [this](){ fileOpenFinished(false); }, Qt::QueuedConnection);
+         return;
+     }
+ #endif
+diff --git a/qtbase/src/network/access/qnetworkreplyimpl.cpp b/qtbase/src/network/access/qnetworkreplyimpl.cpp
+index bcdf6ee2f1..3b6deb82bd 100644
+--- a/qtbase/src/network/access/qnetworkreplyimpl.cpp
++++ b/qtbase/src/network/access/qnetworkreplyimpl.cpp
+@@ -680,7 +680,7 @@ void QNetworkReplyImplPrivate::appendDownstreamData(QIODevice *data)
+     // read until EOF from data
+     if (Q_UNLIKELY(copyDevice)) {
+         qCritical("QNetworkReplyImpl: copy from QIODevice already in progress -- "
+-                  "backend probly needs to be fixed");
++                  "backend probably needs to be fixed");
+         return;
+     }
+ 
+diff --git a/qtbase/src/network/kernel/qauthenticator.cpp b/qtbase/src/network/kernel/qauthenticator.cpp
+index d9fe7bc47b..ccd04b294a 100644
+--- a/qtbase/src/network/kernel/qauthenticator.cpp
++++ b/qtbase/src/network/kernel/qauthenticator.cpp
+@@ -50,6 +50,7 @@
+ #include <qstring.h>
+ #include <qdatetime.h>
+ #include <qrandom.h>
++#include "private/qsystemlibrary_p.h"
+ 
+ #ifdef Q_OS_WIN
+ #include <qmutex.h>
+@@ -1563,7 +1564,7 @@ static bool q_SSPI_library_load()
+ 
+     // Initialize security interface
+     if (pSecurityFunctionTable == nullptr) {
+-        securityDLLHandle = LoadLibrary(L"secur32.dll");
++        securityDLLHandle = QSystemLibrary::load(L"secur32");
+         if (securityDLLHandle != nullptr) {
+             INIT_SECURITY_INTERFACE pInitSecurityInterface =
+                 reinterpret_cast<INIT_SECURITY_INTERFACE>(
+diff --git a/qtbase/src/network/kernel/qhostinfo_unix.cpp b/qtbase/src/network/kernel/qhostinfo_unix.cpp
+index 9b0a2ee669..73679c9ef1 100644
+--- a/qtbase/src/network/kernel/qhostinfo_unix.cpp
++++ b/qtbase/src/network/kernel/qhostinfo_unix.cpp
+@@ -122,7 +122,6 @@ static QFunctionPointer resolveSymbol(QLibrary &lib, const char *sym)
+ 
+ LibResolv::LibResolv()
+ {
+-    QLibrary lib;
+ #ifdef LIBRESOLV_SO
+     lib.setFileName(QStringLiteral(LIBRESOLV_SO));
+     if (!lib.load())
+diff --git a/qtbase/src/network/socket/qsocks5socketengine.cpp b/qtbase/src/network/socket/qsocks5socketengine.cpp
+index 3a046fd116..97fadca0b3 100644
+--- a/qtbase/src/network/socket/qsocks5socketengine.cpp
++++ b/qtbase/src/network/socket/qsocks5socketengine.cpp
+@@ -1296,7 +1296,7 @@ void QSocks5SocketEnginePrivate::_q_udpSocketReadNotification()
+         int pos = 0;
+         const char *buf = inBuf.constData();
+         if (inBuf.size() < 4) {
+-            QSOCKS5_D_DEBUG << "bugus udp data, discarding";
++            QSOCKS5_D_DEBUG << "bogus udp data, discarding";
+             return;
+         }
+         QSocks5RevivedDatagram datagram;
+diff --git a/qtbase/src/network/ssl/qsslcontext_openssl.cpp b/qtbase/src/network/ssl/qsslcontext_openssl.cpp
+index c9f202f573..c992da9d8e 100644
+--- a/qtbase/src/network/ssl/qsslcontext_openssl.cpp
++++ b/qtbase/src/network/ssl/qsslcontext_openssl.cpp
+@@ -409,7 +409,7 @@ init_context:
+         break;
+     case QSsl::DtlsV1_0OrLater:
+         minVersion = DTLS1_VERSION;
+-        maxVersion = DTLS_MAX_VERSION;
++        maxVersion = 0;
+         break;
+     case QSsl::DtlsV1_2:
+         minVersion = DTLS1_2_VERSION;
+@@ -417,7 +417,7 @@ init_context:
+         break;
+     case QSsl::DtlsV1_2OrLater:
+         minVersion = DTLS1_2_VERSION;
+-        maxVersion = DTLS_MAX_VERSION;
++        maxVersion = 0;
+         break;
+     case QSsl::TlsV1_3OrLater:
+ #ifdef TLS1_3_VERSION
+@@ -455,7 +455,7 @@ init_context:
+     }
+ 
+     // Enable bug workarounds.
+-    long options = QSslSocketBackendPrivate::setupOpenSslOptions(configuration.protocol(), configuration.d->sslOptions);
++    qssloptions options = QSslSocketBackendPrivate::setupOpenSslOptions(configuration.protocol(), configuration.d->sslOptions);
+     q_SSL_CTX_set_options(sslContext->ctx, options);
+ 
+     // Tell OpenSSL to release memory early
+diff --git a/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp b/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
+index aaf8741130..b58935372c 100644
+--- a/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
++++ b/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
+@@ -59,57 +59,6 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-#ifdef OPENSSL_NO_DEPRECATED_3_0
+-
+-static int q_DH_check(DH *dh, int *status)
+-{
+-    // DH_check was first deprecated in OpenSSL 3.0.0, as low-level
+-    // API; the EVP_PKEY family of functions was advised as an alternative.
+-    // As of now EVP_PKEY_params_check ends up calling ... DH_check,
+-    // which is good enough.
+-
+-    Q_ASSERT(dh);
+-    Q_ASSERT(status);
+-
+-    EVP_PKEY *key = q_EVP_PKEY_new();
+-    if (!key) {
+-        qCWarning(lcSsl, "EVP_PKEY_new failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-    const auto keyDeleter = qScopeGuard([key](){
+-        q_EVP_PKEY_free(key);
+-    });
+-    if (!q_EVP_PKEY_set1_DH(key, dh)) {
+-        qCWarning(lcSsl, "EVP_PKEY_set1_DH failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-
+-    EVP_PKEY_CTX *keyCtx = q_EVP_PKEY_CTX_new(key, nullptr);
+-    if (!keyCtx) {
+-        qCWarning(lcSsl, "EVP_PKEY_CTX_new failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-    const auto ctxDeleter = qScopeGuard([keyCtx]{
+-        q_EVP_PKEY_CTX_free(keyCtx);
+-    });
+-
+-    const int result = q_EVP_PKEY_param_check(keyCtx);
+-    QSslSocketBackendPrivate::logAndClearErrorQueue();
+-    // Note: unlike DH_check, we cannot obtain the 'status',
+-    // if the 'result' is 0 (actually the result is 1 only
+-    // if this 'status' was 0). We could probably check the
+-    // errors from the error queue, but it's not needed anyway
+-    // - see the 'isSafeDH' below, how it returns immediately
+-    // on 0.
+-    Q_UNUSED(status)
+-
+-    return result;
+-}
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+-
+ static bool isSafeDH(DH *dh)
+ {
+     int status = 0;
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl.cpp b/qtbase/src/network/ssl/qsslsocket_openssl.cpp
+index 37fad2a68f..8f6858c867 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl.cpp
++++ b/qtbase/src/network/ssl/qsslsocket_openssl.cpp
+@@ -550,9 +550,9 @@ static void q_loadCiphersForConnection(SSL *connection, QList<QSslCipher> &ciphe
+ // Defined in qsslsocket.cpp
+ void q_setDefaultDtlsCiphers(const QList<QSslCipher> &ciphers);
+ 
+-long QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions)
++qssloptions QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions)
+ {
+-    long options;
++    qssloptions options;
+     if (protocol == QSsl::TlsV1SslV3)
+         options = SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3;
+     else if (protocol == QSsl::SecureProtocols)
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_p.h b/qtbase/src/network/ssl/qsslsocket_openssl_p.h
+index 4103de23e8..5547589256 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_p.h
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_p.h
+@@ -107,6 +107,12 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++typedef uint64_t qssloptions;
++#else
++typedef unsigned long qssloptions;
++#endif
++
+ struct QSslErrorEntry {
+     int code;
+     int depth;
+@@ -171,7 +177,7 @@ public:
+     QVector<QSslError> ocspErrors;
+     QByteArray ocspResponseDer;
+ 
+-    Q_AUTOTEST_EXPORT static long setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions);
++    Q_AUTOTEST_EXPORT static qssloptions setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions);
+     static QSslCipher QSslCipher_from_SSL_CIPHER(const SSL_CIPHER *cipher);
+     static QList<QSslCertificate> STACKOFX509_to_QSslCertificates(STACK_OF(X509) *x509);
+     static QList<QSslError> verify(const QList<QSslCertificate> &certificateChain, const QString &hostName);
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp b/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
+index e53fb279f0..459ccd0b19 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
+@@ -148,7 +148,6 @@ DEFINEFUNC(int, EVP_PKEY_up_ref, EVP_PKEY *a, a, return 0, return)
+ DEFINEFUNC2(EVP_PKEY_CTX *, EVP_PKEY_CTX_new, EVP_PKEY *pkey, pkey, ENGINE *e, e, return nullptr, return)
+ DEFINEFUNC(int, EVP_PKEY_param_check, EVP_PKEY_CTX *ctx, ctx, return 0, return)
+ DEFINEFUNC(void, EVP_PKEY_CTX_free, EVP_PKEY_CTX *ctx, ctx, return, return)
+-DEFINEFUNC(int, EVP_PKEY_base_id, EVP_PKEY *a, a, return NID_undef, return)
+ DEFINEFUNC(int, RSA_bits, RSA *a, a, return 0, return)
+ DEFINEFUNC(int, DSA_bits, DSA *a, a, return 0, return)
+ DEFINEFUNC(int, OPENSSL_sk_num, OPENSSL_STACK *a, a, return -1, return)
+@@ -158,7 +157,7 @@ DEFINEFUNC2(void, OPENSSL_sk_push, OPENSSL_STACK *a, a, void *b, b, return, DUMM
+ DEFINEFUNC(void, OPENSSL_sk_free, OPENSSL_STACK *a, a, return, DUMMYARG)
+ DEFINEFUNC2(void *, OPENSSL_sk_value, OPENSSL_STACK *a, a, int b, b, return nullptr, return)
+ DEFINEFUNC(int, SSL_session_reused, SSL *a, a, return 0, return)
+-DEFINEFUNC2(unsigned long, SSL_CTX_set_options, SSL_CTX *ctx, ctx, unsigned long op, op, return 0, return)
++DEFINEFUNC2(qssloptions, SSL_CTX_set_options, SSL_CTX *ctx, ctx, qssloptions op, op, return 0, return)
+ DEFINEFUNC(int, SSL_CTX_get_security_level, const SSL_CTX *ctx, ctx, return -1, return)
+ DEFINEFUNC2(void, SSL_CTX_set_security_level, SSL_CTX *ctx, ctx, int level, level, return, return)
+ #ifdef TLS1_3_VERSION
+@@ -371,7 +370,15 @@ DEFINEFUNC(const SSL_CIPHER *, SSL_get_current_cipher, SSL *a, a, return nullptr
+ DEFINEFUNC(int, SSL_version, const SSL *a, a, return 0, return)
+ DEFINEFUNC2(int, SSL_get_error, SSL *a, a, int b, b, return -1, return)
+ DEFINEFUNC(STACK_OF(X509) *, SSL_get_peer_cert_chain, SSL *a, a, return nullptr, return)
++
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++DEFINEFUNC(X509 *, SSL_get1_peer_certificate, SSL *a, a, return nullptr, return)
++DEFINEFUNC(int, EVP_PKEY_get_base_id, const EVP_PKEY *pkey, pkey, return -1, return)
++#else
+ DEFINEFUNC(X509 *, SSL_get_peer_certificate, SSL *a, a, return nullptr, return)
++DEFINEFUNC(int, EVP_PKEY_base_id, EVP_PKEY *a, a, return NID_undef, return)
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+ DEFINEFUNC(long, SSL_get_verify_result, const SSL *a, a, return -1, return)
+ DEFINEFUNC(SSL *, SSL_new, SSL_CTX *a, a, return nullptr, return)
+ DEFINEFUNC(SSL_CTX *, SSL_get_SSL_CTX, SSL *a, a, return nullptr, return)
+@@ -492,9 +499,7 @@ DEFINEFUNC(DH *, DH_new, DUMMYARG, DUMMYARG, return nullptr, return)
+ DEFINEFUNC(void, DH_free, DH *dh, dh, return, DUMMYARG)
+ DEFINEFUNC3(DH *, d2i_DHparams, DH**a, a, const unsigned char **pp, pp, long length, length, return nullptr, return)
+ DEFINEFUNC2(int, i2d_DHparams, DH *a, a, unsigned char **p, p, return -1, return)
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+ DEFINEFUNC2(int, DH_check, DH *dh, dh, int *codes, codes, return 0, return)
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+ DEFINEFUNC3(BIGNUM *, BN_bin2bn, const unsigned char *s, s, int len, len, BIGNUM *ret, ret, return nullptr, return)
+ 
+ #ifndef OPENSSL_NO_EC
+@@ -868,7 +873,6 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(EVP_PKEY_CTX_new)
+     RESOLVEFUNC(EVP_PKEY_param_check)
+     RESOLVEFUNC(EVP_PKEY_CTX_free)
+-    RESOLVEFUNC(EVP_PKEY_base_id)
+     RESOLVEFUNC(RSA_bits)
+     RESOLVEFUNC(OPENSSL_sk_new_null)
+     RESOLVEFUNC(OPENSSL_sk_push)
+@@ -1107,7 +1111,15 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(SSL_version)
+     RESOLVEFUNC(SSL_get_error)
+     RESOLVEFUNC(SSL_get_peer_cert_chain)
++
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++    RESOLVEFUNC(SSL_get1_peer_certificate)
++    RESOLVEFUNC(EVP_PKEY_get_base_id)
++#else
+     RESOLVEFUNC(SSL_get_peer_certificate)
++    RESOLVEFUNC(EVP_PKEY_base_id)
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+     RESOLVEFUNC(SSL_get_verify_result)
+     RESOLVEFUNC(SSL_new)
+     RESOLVEFUNC(SSL_get_SSL_CTX)
+@@ -1206,9 +1218,7 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(DH_free)
+     RESOLVEFUNC(d2i_DHparams)
+     RESOLVEFUNC(i2d_DHparams)
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+     RESOLVEFUNC(DH_check)
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+     RESOLVEFUNC(BN_bin2bn)
+ 
+ #ifndef OPENSSL_NO_EC
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h b/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
+index 95e8897a3b..27aeffa18a 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
+@@ -237,7 +237,6 @@ Q_AUTOTEST_EXPORT int q_EVP_PKEY_up_ref(EVP_PKEY *a);
+ EVP_PKEY_CTX *q_EVP_PKEY_CTX_new(EVP_PKEY *pkey, ENGINE *e);
+ void q_EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx);
+ int q_EVP_PKEY_param_check(EVP_PKEY_CTX *ctx);
+-int q_EVP_PKEY_base_id(EVP_PKEY *a);
+ int q_RSA_bits(RSA *a);
+ Q_AUTOTEST_EXPORT int q_OPENSSL_sk_num(OPENSSL_STACK *a);
+ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_pop_free(OPENSSL_STACK *a, void (*b)(void *));
+@@ -246,7 +245,7 @@ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_push(OPENSSL_STACK *st, void *data);
+ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_free(OPENSSL_STACK *a);
+ Q_AUTOTEST_EXPORT void * q_OPENSSL_sk_value(OPENSSL_STACK *a, int b);
+ int q_SSL_session_reused(SSL *a);
+-unsigned long q_SSL_CTX_set_options(SSL_CTX *ctx, unsigned long op);
++qssloptions q_SSL_CTX_set_options(SSL_CTX *ctx, qssloptions op);
+ int q_OPENSSL_init_ssl(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings);
+ size_t q_SSL_get_client_random(SSL *a, unsigned char *out, size_t outlen);
+ size_t q_SSL_SESSION_get_master_key(const SSL_SESSION *session, unsigned char *out, size_t outlen);
+@@ -510,7 +509,6 @@ const SSL_CIPHER *q_SSL_get_current_cipher(SSL *a);
+ int q_SSL_version(const SSL *a);
+ int q_SSL_get_error(SSL *a, int b);
+ STACK_OF(X509) *q_SSL_get_peer_cert_chain(SSL *a);
+-X509 *q_SSL_get_peer_certificate(SSL *a);
+ long q_SSL_get_verify_result(const SSL *a);
+ SSL *q_SSL_new(SSL_CTX *a);
+ SSL_CTX *q_SSL_get_SSL_CTX(SSL *a);
+@@ -582,10 +580,7 @@ DH *q_DH_new();
+ void q_DH_free(DH *dh);
+ DH *q_d2i_DHparams(DH **a, const unsigned char **pp, long length);
+ int q_i2d_DHparams(DH *a, unsigned char **p);
+-
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+ int q_DH_check(DH *dh, int *codes);
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+ 
+ BIGNUM *q_BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret);
+ #define q_SSL_CTX_set_tmp_dh(ctx, dh) q_SSL_CTX_ctrl((ctx), SSL_CTRL_SET_TMP_DH, 0, (char *)dh)
+@@ -754,6 +749,17 @@ void q_CRYPTO_free(void *str, const char *file, int line);
+ int q_SSL_CTX_get_security_level(const SSL_CTX *ctx);
+ void q_SSL_CTX_set_security_level(SSL_CTX *ctx, int level);
+ 
++// Here we have the ones that make difference between OpenSSL pre/post v3:
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++X509 *q_SSL_get1_peer_certificate(SSL *a);
++#define q_SSL_get_peer_certificate q_SSL_get1_peer_certificate
++int q_EVP_PKEY_get_base_id(const EVP_PKEY *pkey);
++#define q_EVP_PKEY_base_id q_EVP_PKEY_get_base_id
++#else
++X509 *q_SSL_get_peer_certificate(SSL *a);
++int q_EVP_PKEY_base_id(EVP_PKEY *a);
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+ QT_END_NAMESPACE
+ 
+ #endif
+diff --git a/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h b/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
+index bf37d07fd8..dbd42fb799 100644
+--- a/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
++++ b/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
+@@ -61,7 +61,11 @@
+ # if !defined(Q_OS_INTEGRITY)
+ #  define WIN_INTERFACE_CUSTOM   // NV
+ # endif // Q_OS_INTEGRITY
+-#endif  // QT_EGL_NO_X11
++#else // QT_EGL_NO_X11
++// If one has an eglplatform.h with https://github.com/KhronosGroup/EGL-Registry/pull/130
++// that needs USE_X11 to be defined.
++# define USE_X11
++#endif
+ 
+ #ifdef QT_EGL_WAYLAND
+ # define WAYLAND // NV
+diff --git a/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+index 159b490ce0..00aa80cd58 100644
+--- a/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
++++ b/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+@@ -567,6 +567,8 @@ void QFontconfigDatabase::populateFontDatabase()
+         fonts = FcFontList(nullptr, pattern, os);
+         FcObjectSetDestroy(os);
+         FcPatternDestroy(pattern);
++        if (!fonts)
++            return;
+     }
+ 
+     for (int i = 0; i < fonts->nfont; i++)
+diff --git a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
+index b713c19447..7cb9a8c79a 100644
+--- a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
++++ b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
+@@ -95,6 +95,7 @@ static constexpr const auto KeyTbl = qMakeArray(
+         Xkb2Qt<XKB_KEY_Clear,                   Qt::Key_Delete>,
+         Xkb2Qt<XKB_KEY_Pause,                   Qt::Key_Pause>,
+         Xkb2Qt<XKB_KEY_Print,                   Qt::Key_Print>,
++        Xkb2Qt<XKB_KEY_Sys_Req,                 Qt::Key_SysReq>,
+         Xkb2Qt<0x1005FF60,                      Qt::Key_SysReq>,         // hardcoded Sun SysReq
+         Xkb2Qt<0x1007ff00,                      Qt::Key_SysReq>,         // hardcoded X386 SysReq
+ 
+@@ -471,7 +472,7 @@ QVector<xkb_keysym_t> QXkbCommon::toKeysym(QKeyEvent *event)
+     } else if (event->modifiers() & Qt::KeypadModifier) {
+         if (qtKey >= Qt::Key_0 && qtKey <= Qt::Key_9)
+             keysyms.append(XKB_KEY_KP_0 + (qtKey - Qt::Key_0));
+-    } else if (isLatin(qtKey) && event->text().isUpper()) {
++    } else if (isLatin1(qtKey) && event->text().isUpper()) {
+         keysyms.append(qtKey);
+     }
+ 
+@@ -523,7 +524,7 @@ int QXkbCommon::keysymToQtKey(xkb_keysym_t keysym, Qt::KeyboardModifiers modifie
+         // With standard shortcuts we should prefer a latin character, this is
+         // for checks like "some qkeyevent == QKeySequence::Copy" to work even
+         // when using for example 'russian' keyboard layout.
+-        if (!QXkbCommon::isLatin(keysym)) {
++        if (!QXkbCommon::isLatin1(keysym)) {
+             xkb_keysym_t latinKeysym = QXkbCommon::lookupLatinKeysym(state, code);
+             if (latinKeysym != XKB_KEY_NoSymbol)
+                 keysym = latinKeysym;
+@@ -546,7 +547,7 @@ static int keysymToQtKey_internal(xkb_keysym_t keysym, Qt::KeyboardModifiers mod
+     } else if (keysym >= XKB_KEY_KP_0 && keysym <= XKB_KEY_KP_9) {
+         // numeric keypad keys
+         qtKey = Qt::Key_0 + (keysym - XKB_KEY_KP_0);
+-    } else if (QXkbCommon::isLatin(keysym)) {
++    } else if (QXkbCommon::isLatin1(keysym)) {
+         qtKey = QXkbCommon::qxkbcommon_xkb_keysym_to_upper(keysym);
+     } else {
+         // check if we have a direct mapping
+@@ -678,7 +679,7 @@ QList<int> QXkbCommon::possibleKeys(xkb_state *state, const QKeyEvent *event,
+         Qt::KeyboardModifiers neededMods = ModsTbl[i];
+         if ((modifiers & neededMods) == neededMods) {
+             if (i == 8) {
+-                if (isLatin(baseQtKey))
++                if (isLatin1(baseQtKey))
+                     continue;
+                 // add a latin key as a fall back key
+                 sym = lookupLatinKeysym(state, keycode);
+@@ -733,7 +734,7 @@ void QXkbCommon::verifyHasLatinLayout(xkb_keymap *keymap)
+     for (xkb_layout_index_t layout = 0; layout < layoutCount; ++layout) {
+         for (xkb_keycode_t code = minKeycode; code < maxKeycode; ++code) {
+             xkb_keymap_key_get_syms_by_level(keymap, code, layout, 0, &keysyms);
+-            if (keysyms && isLatin(keysyms[0]))
++            if (keysyms && isLatin1(keysyms[0]))
+                 nrLatinKeys++;
+             if (nrLatinKeys > 10) // arbitrarily chosen threshold
+                 return;
+@@ -766,7 +767,7 @@ xkb_keysym_t QXkbCommon::lookupLatinKeysym(xkb_state *state, xkb_keycode_t keyco
+         xkb_level_index_t level = xkb_state_key_get_level(state, keycode, layout);
+         if (xkb_keymap_key_get_syms_by_level(keymap, keycode, layout, level, &syms) != 1)
+             continue;
+-        if (isLatin(syms[0])) {
++        if (isLatin1(syms[0])) {
+             sym = syms[0];
+             break;
+         }
+diff --git a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
+index 561eae03db..8389bd8f5a 100644
+--- a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
++++ b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
+@@ -94,8 +94,8 @@ public:
+     static void verifyHasLatinLayout(xkb_keymap *keymap);
+     static xkb_keysym_t lookupLatinKeysym(xkb_state *state, xkb_keycode_t keycode);
+ 
+-    static bool isLatin(xkb_keysym_t sym) {
+-        return ((sym >= 'a' && sym <= 'z') || (sym >= 'A' && sym <= 'Z'));
++    static bool isLatin1(xkb_keysym_t sym) {
++        return sym <= 0xff;
+     }
+     static bool isKeypad(xkb_keysym_t sym) {
+         return sym >= XKB_KEY_KP_Space && sym <= XKB_KEY_KP_9;
+diff --git a/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp b/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
+index 8cd7f9b368..406f84663f 100644
+--- a/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
++++ b/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
+@@ -318,7 +318,7 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources,
+ 
+     if (current < 0 && crtc_mode.clock != 0) {
+         modes << crtc_mode;
+-        current = mode.size() - 1;
++        current = modes.size() - 1;
+     }
+ 
+     if (configuration == OutputConfigCurrent)
+diff --git a/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp b/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
+index 9153fd20bb..255ea5e33e 100644
+--- a/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
++++ b/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
+@@ -194,6 +194,9 @@ QString AtSpiAdaptor::introspect(const QString &path) const
+                 "      <arg direction=\"out\" type=\"(so)\"/>\n"
+                 "      <annotation value=\"QSpiObjectReference\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n"
+                 "    </method>\n"
++                "    <method name=\"GetAccessibleId\">\n"
++                "      <arg direction=\"out\" type=\"s\"/>\n"
++                "    </method>\n"
+                 "  </interface>\n"
+                 );
+ 
+@@ -913,8 +916,17 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+     }
+     case QAccessible::NameChanged: {
+         if (sendObject || sendObject_property_change || sendObject_property_change_accessible_name) {
+-            QString path = pathForInterface(event->accessibleInterface());
+-            QVariantList args = packDBusSignalArguments(QLatin1String("accessible-name"), 0, 0, variantForPath(path));
++            QAccessibleInterface *iface = event->accessibleInterface();
++            if (!iface) {
++                qCDebug(lcAccessibilityAtspi,
++                        "NameChanged event from invalid accessible.");
++                return;
++            }
++
++            QString path = pathForInterface(iface);
++            QVariantList args = packDBusSignalArguments(
++                QLatin1String("accessible-name"), 0, 0,
++                QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Name))));
+             sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                            QLatin1String("PropertyChange"), args);
+         }
+@@ -922,8 +934,17 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+     }
+     case QAccessible::DescriptionChanged: {
+         if (sendObject || sendObject_property_change || sendObject_property_change_accessible_description) {
+-            QString path = pathForInterface(event->accessibleInterface());
+-            QVariantList args = packDBusSignalArguments(QLatin1String("accessible-description"), 0, 0, variantForPath(path));
++            QAccessibleInterface *iface = event->accessibleInterface();
++            if (!iface) {
++                qCDebug(lcAccessibilityAtspi,
++                        "DescriptionChanged event from invalid accessible.");
++                return;
++            }
++
++            QString path = pathForInterface(iface);
++            QVariantList args = packDBusSignalArguments(
++                QLatin1String("accessible-description"), 0, 0,
++                QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Description))));
+             sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                            QLatin1String("PropertyChange"), args);
+         }
+@@ -1038,7 +1059,9 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+                 // Combo Box with AT-SPI likes to be special
+                 // It requires a name-change to update caches and then selection-changed
+                 QString path = pathForInterface(iface);
+-                QVariantList args1 = packDBusSignalArguments(QLatin1String("accessible-name"), 0, 0, variantForPath(path));
++                QVariantList args1 = packDBusSignalArguments(
++                    QLatin1String("accessible-name"), 0, 0,
++                    QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Name))));
+                 sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                                QLatin1String("PropertyChange"), args1);
+                 QVariantList args2 = packDBusSignalArguments(QString(), 0, 0, QVariant::fromValue(QDBusVariant(QVariant(0))));
+@@ -1358,6 +1381,26 @@ void AtSpiAdaptor::registerApplication()
+     delete registry;
+ }
+ 
++namespace {
++QString accessibleIdForAccessible(QAccessibleInterface *accessible)
++{
++    QString result;
++    while (accessible) {
++        if (!result.isEmpty())
++            result.prepend(QLatin1Char('.'));
++        if (auto obj = accessible->object()) {
++            const QString name = obj->objectName();
++            if (!name.isEmpty())
++                result.prepend(name);
++            else
++                result.prepend(QString::fromUtf8(obj->metaObject()->className()));
++        }
++        accessible = accessible->parent();
++    }
++    return result;
++}
++} // namespace
++
+ // Accessible
+ bool AtSpiAdaptor::accessibleInterface(QAccessibleInterface *interface, const QString &function, const QDBusMessage &message, const QDBusConnection &connection)
+ {
+@@ -1441,6 +1484,9 @@ bool AtSpiAdaptor::accessibleInterface(QAccessibleInterface *interface, const QS
+             children << ref;
+         }
+         connection.send(message.createReply(QVariant::fromValue(children)));
++    } else if (function == QLatin1String("GetAccessibleId")) {
++        sendReply(connection, message,
++                  QVariant::fromValue(QDBusVariant(accessibleIdForAccessible(interface))));
+     } else {
+         qCDebug(lcAccessibilityAtspi) << "WARNING: AtSpiAdaptor::accessibleInterface does not implement " << function << message.path();
+         return false;
+diff --git a/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp b/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
+index 45ddc8e496..cc734abc63 100644
+--- a/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
++++ b/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
+@@ -69,6 +69,21 @@ QT_BEGIN_NAMESPACE
+ DBusConnection::DBusConnection(QObject *parent)
+     : QObject(parent), m_a11yConnection(QString()), m_enabled(false)
+ {
++    // If the bus is explicitly set via env var it overrides everything else.
++    QByteArray addressEnv = qgetenv("AT_SPI_BUS_ADDRESS");
++    if (!addressEnv.isEmpty()) {
++        // Only connect on next loop run, connections to our enabled signal are
++        // only established after the ctor returns.
++        QMetaObject::invokeMethod(
++                this,
++                [this, addressEnv] {
++                    m_enabled = true;
++                    connectA11yBus(QString::fromLocal8Bit(addressEnv));
++                },
++                Qt::QueuedConnection);
++        return;
++    }
++
+     // Start monitoring if "org.a11y.Bus" is registered as DBus service.
+     QDBusConnection c = QDBusConnection::sessionBus();
+     if (!c.isConnected()) {
+diff --git a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
+index 1a3cab275d..2abe039126 100644
+--- a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
++++ b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
+@@ -51,6 +51,9 @@
+ #include <QtCore/QStandardPaths>
+ #include <QtCore/QUrl>
+ 
++#include <QtGui/QGuiApplication>
++#include <QtGui/QWindow>
++
+ #if QT_CONFIG(dbus)
+ // These QtCore includes are needed for xdg-desktop-portal support
+ #include <QtCore/private/qcore_unix_p.h>
+@@ -58,6 +61,8 @@
+ #include <QtCore/QFileInfo>
+ #include <QtCore/QUrlQuery>
+ 
++#include <QtGui/QColor>
++
+ #include <QtDBus/QDBusConnection>
+ #include <QtDBus/QDBusMessage>
+ #include <QtDBus/QDBusPendingCall>
+@@ -142,6 +147,8 @@ static inline bool detectWebBrowser(const QByteArray &desktop,
+     }
+ 
+     if (desktop == QByteArray("KDE")) {
++        if (checkExecutable(QStringLiteral("kde-open5"), browser))
++            return true;
+         // Konqueror launcher
+         if (checkExecutable(QStringLiteral("kfmclient"), browser)) {
+             browser->append(QLatin1String(" exec"));
+@@ -296,8 +303,135 @@ static inline QDBusMessage xdgDesktopPortalSendEmail(const QUrl &url)
+ 
+     return QDBusConnection::sessionBus().call(message);
+ }
++
++namespace {
++struct XDGDesktopColor
++{
++    double r = 0;
++    double g = 0;
++    double b = 0;
++
++    QColor toQColor() const
++    {
++        constexpr auto rgbMax = 255;
++        return { static_cast<int>(r * rgbMax), static_cast<int>(g * rgbMax),
++                 static_cast<int>(b * rgbMax) };
++    }
++};
++
++const QDBusArgument &operator>>(const QDBusArgument &argument, XDGDesktopColor &myStruct)
++{
++    argument.beginStructure();
++    argument >> myStruct.r >> myStruct.g >> myStruct.b;
++    argument.endStructure();
++    return argument;
++}
++
++class XdgDesktopPortalColorPicker : public QPlatformServiceColorPicker
++{
++    Q_OBJECT
++public:
++    XdgDesktopPortalColorPicker(const QString &parentWindowId, QWindow *parent)
++        : QPlatformServiceColorPicker(parent), m_parentWindowId(parentWindowId)
++    {
++    }
++
++    void pickColor() override
++    {
++        // DBus signature:
++        // PickColor (IN   s      parent_window,
++        //            IN   a{sv}  options
++        //            OUT  o      handle)
++        // Options:
++        // handle_token (s) -  A string that will be used as the last element of the @handle.
++
++        QDBusMessage message = QDBusMessage::createMethodCall(
++                QStringLiteral("org.freedesktop.portal.Desktop"), QStringLiteral("/org/freedesktop/portal/desktop"),
++                QStringLiteral("org.freedesktop.portal.Screenshot"), QStringLiteral("PickColor"));
++        message << m_parentWindowId << QVariantMap();
++
++        QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
++        auto watcher = new QDBusPendingCallWatcher(pendingCall, this);
++        connect(watcher, &QDBusPendingCallWatcher::finished, this,
++                [this](QDBusPendingCallWatcher *watcher) {
++                    watcher->deleteLater();
++                    QDBusPendingReply<QDBusObjectPath> reply = *watcher;
++                    if (reply.isError()) {
++                        qWarning("DBus call to pick color failed: %s",
++                                 qPrintable(reply.error().message()));
++                        Q_EMIT colorPicked({});
++                    } else {
++                        QDBusConnection::sessionBus().connect(
++                                QStringLiteral("org.freedesktop.portal.Desktop"), reply.value().path(),
++                                QStringLiteral("org.freedesktop.portal.Request"), QStringLiteral("Response"), this,
++                                // clang-format off
++                                SLOT(gotColorResponse(uint,QVariantMap))
++                                // clang-format on
++                        );
++                    }
++                });
++    }
++
++private Q_SLOTS:
++    void gotColorResponse(uint result, const QVariantMap &map)
++    {
++        if (result != 0)
++            return;
++        XDGDesktopColor color{};
++        map.value(QStringLiteral("color")).value<QDBusArgument>() >> color;
++        Q_EMIT colorPicked(color.toQColor());
++        deleteLater();
++    }
++
++private:
++    const QString m_parentWindowId;
++};
++} // namespace
++
+ #endif // QT_CONFIG(dbus)
+ 
++QGenericUnixServices::QGenericUnixServices()
++{
++#if QT_CONFIG(dbus)
++    if (qEnvironmentVariableIntValue("QT_NO_XDG_DESKTOP_PORTAL") > 0) {
++        return;
++    }
++    QDBusMessage message = QDBusMessage::createMethodCall(
++            QStringLiteral("org.freedesktop.portal.Desktop"), QStringLiteral("/org/freedesktop/portal/desktop"),
++            QStringLiteral("org.freedesktop.DBus.Properties"), QStringLiteral("Get"));
++    message << QStringLiteral("org.freedesktop.portal.Screenshot")
++            << QStringLiteral("version");
++
++    QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
++    auto watcher = new QDBusPendingCallWatcher(pendingCall);
++    QObject::connect(watcher, &QDBusPendingCallWatcher::finished, watcher,
++                     [this](QDBusPendingCallWatcher *watcher) {
++                         watcher->deleteLater();
++                         QDBusPendingReply<QVariant> reply = *watcher;
++                         if (!reply.isError() && reply.value().toUInt() >= 2)
++                             m_hasScreenshotPortalWithColorPicking = true;
++                     });
++
++#endif
++}
++
++QPlatformServiceColorPicker *QGenericUnixServices::colorPicker(QWindow *parent)
++{
++#if QT_CONFIG(dbus)
++    // Make double sure that we are in a wayland environment. In particular check
++    // WAYLAND_DISPLAY so also XWayland apps benefit from portal-based color picking.
++    // Outside wayland we'll rather rely on other means than the XDG desktop portal.
++    if (!qEnvironmentVariableIsEmpty("WAYLAND_DISPLAY")
++        || QGuiApplication::platformName().startsWith(QLatin1String("wayland"))) {
++        return new XdgDesktopPortalColorPicker(portalWindowIdentifier(parent), parent);
++    }
++    return nullptr;
++#else
++    Q_UNUSED(parent);
++    return nullptr;
++#endif
++}
++
+ QByteArray QGenericUnixServices::desktopEnvironment() const
+ {
+     static const QByteArray result = detectDesktopEnvironment();
+@@ -352,6 +486,8 @@ bool QGenericUnixServices::openDocument(const QUrl &url)
+ }
+ 
+ #else
++QGenericUnixServices::QGenericUnixServices() = default;
++
+ QByteArray QGenericUnixServices::desktopEnvironment() const
+ {
+     return QByteArrayLiteral("UNKNOWN");
+@@ -371,6 +507,30 @@ bool QGenericUnixServices::openDocument(const QUrl &url)
+     return false;
+ }
+ 
++QPlatformServiceColorPicker *QGenericUnixServices::colorPicker(QWindow *parent)
++{
++    Q_UNUSED(parent);
++    return nullptr;
++}
++
+ #endif // QT_NO_MULTIPROCESS
+ 
++QString QGenericUnixServices::portalWindowIdentifier(QWindow *window)
++{
++    if (QGuiApplication::platformName() == QLatin1String("xcb"))
++        return QStringLiteral("x11:") + QString::number(window->winId(), 16);
++    return QString();
++}
++
++bool QGenericUnixServices::hasCapability(Capability capability) const
++{
++    switch (capability) {
++    case Capability::ColorPicking:
++        return m_hasScreenshotPortalWithColorPicking;
++    }
++    return false;
++}
++
+ QT_END_NAMESPACE
++
++#include "qgenericunixservices.moc"
+diff --git a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
+index 8ac3de6f03..30924e64bd 100644
+--- a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
++++ b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
+@@ -59,16 +59,21 @@ QT_BEGIN_NAMESPACE
+ class QGenericUnixServices : public QPlatformServices
+ {
+ public:
+-    QGenericUnixServices() {}
++    QGenericUnixServices();
+ 
+     QByteArray desktopEnvironment() const override;
+ 
++    bool hasCapability(Capability capability) const override;
+     bool openUrl(const QUrl &url) override;
+     bool openDocument(const QUrl &url) override;
++    QPlatformServiceColorPicker *colorPicker(QWindow *parent = nullptr) override;
++
++    virtual QString portalWindowIdentifier(QWindow *window);
+ 
+ private:
+     QString m_webBrowser;
+     QString m_documentLauncher;
++    bool m_hasScreenshotPortalWithColorPicking = false;
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
+index 09470bccc6..cc7c7d4d8a 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
+@@ -69,6 +69,7 @@ const QString MenuBarPath = QLatin1String("/MenuBar");
+ */
+ QDBusMenuConnection::QDBusMenuConnection(QObject *parent, const QString &serviceName)
+     : QObject(parent)
++    , m_serviceName(serviceName)
+     , m_connection(serviceName.isNull() ? QDBusConnection::sessionBus()
+                                         : QDBusConnection::connectToBus(QDBusConnection::SessionBus, serviceName))
+     , m_dbusWatcher(new QDBusServiceWatcher(StatusNotifierWatcherService, m_connection, QDBusServiceWatcher::WatchForRegistration, this))
+@@ -83,6 +84,12 @@ QDBusMenuConnection::QDBusMenuConnection(QObject *parent, const QString &service
+ #endif
+ }
+ 
++QDBusMenuConnection::~QDBusMenuConnection()
++{
++  if (!m_serviceName.isEmpty() && m_connection.isConnected())
++      QDBusConnection::disconnectFromBus(m_serviceName);
++}
++
+ void QDBusMenuConnection::dbusError(const QDBusError &error)
+ {
+     qWarning() << "QDBusTrayIcon encountered a D-Bus error:" << error;
+@@ -105,13 +112,7 @@ void QDBusMenuConnection::unregisterTrayIconMenu(QDBusTrayIcon *item)
+ 
+ bool QDBusMenuConnection::registerTrayIcon(QDBusTrayIcon *item)
+ {
+-    bool success = connection().registerService(item->instanceId());
+-    if (!success) {
+-        qWarning() << "failed to register service" << item->instanceId();
+-        return false;
+-    }
+-
+-    success = connection().registerObject(StatusNotifierItemPath, item);
++    bool success = connection().registerObject(StatusNotifierItemPath, item);
+     if (!success) {
+         unregisterTrayIcon(item);
+         qWarning() << "failed to register" << item->instanceId() << StatusNotifierItemPath;
+@@ -126,21 +127,18 @@ bool QDBusMenuConnection::registerTrayIcon(QDBusTrayIcon *item)
+ 
+ bool QDBusMenuConnection::registerTrayIconWithWatcher(QDBusTrayIcon *item)
+ {
++    Q_UNUSED(item);
+     QDBusMessage registerMethod = QDBusMessage::createMethodCall(
+                 StatusNotifierWatcherService, StatusNotifierWatcherPath, StatusNotifierWatcherService,
+                 QLatin1String("RegisterStatusNotifierItem"));
+-    registerMethod.setArguments(QVariantList() << item->instanceId());
++    registerMethod.setArguments(QVariantList() << m_connection.baseService());
+     return m_connection.callWithCallback(registerMethod, this, SIGNAL(trayIconRegistered()), SLOT(dbusError(QDBusError)));
+ }
+ 
+-bool QDBusMenuConnection::unregisterTrayIcon(QDBusTrayIcon *item)
++void QDBusMenuConnection::unregisterTrayIcon(QDBusTrayIcon *item)
+ {
+     unregisterTrayIconMenu(item);
+     connection().unregisterObject(StatusNotifierItemPath);
+-    bool success = connection().unregisterService(item->instanceId());
+-    if (!success)
+-        qWarning() << "failed to unregister service" << item->instanceId();
+-    return success;
+ }
+ #endif // QT_NO_SYSTEMTRAYICON
+ 
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
+index f484795fbb..97bdfabb85 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
++++ b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
+@@ -70,6 +70,7 @@ class QDBusMenuConnection : public QObject
+ 
+ public:
+     QDBusMenuConnection(QObject *parent = nullptr, const QString &serviceName = QString());
++    ~QDBusMenuConnection();
+     QDBusConnection connection() const { return m_connection; }
+     QDBusServiceWatcher *dbusWatcher() const { return m_dbusWatcher; }
+     bool isStatusNotifierHostRegistered() const { return m_statusNotifierHostRegistered; }
+@@ -78,7 +79,7 @@ public:
+     void unregisterTrayIconMenu(QDBusTrayIcon *item);
+     bool registerTrayIcon(QDBusTrayIcon *item);
+     bool registerTrayIconWithWatcher(QDBusTrayIcon *item);
+-    bool unregisterTrayIcon(QDBusTrayIcon *item);
++    void unregisterTrayIcon(QDBusTrayIcon *item);
+ #endif // QT_NO_SYSTEMTRAYICON
+ 
+ Q_SIGNALS:
+@@ -90,6 +91,7 @@ private Q_SLOTS:
+     void dbusError(const QDBusError &error);
+ 
+ private:
++    QString m_serviceName;
+     QDBusConnection m_connection;
+     QDBusServiceWatcher *m_dbusWatcher;
+     bool m_statusNotifierHostRegistered;
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp b/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
+index bede70975a..76bfec5e5a 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
+@@ -71,8 +71,12 @@ Q_LOGGING_CATEGORY(qLcTray, "qt.qpa.tray")
+ static QString iconTempPath()
+ {
+     QString tempPath = QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation);
+-    if (!tempPath.isEmpty())
++    if (!tempPath.isEmpty()) {
++        QString flatpakId = qEnvironmentVariable("FLATPAK_ID");
++        if (!flatpakId.isEmpty() && QFileInfo::exists(QLatin1String("/.flatpak-info")))
++            tempPath += QLatin1String("/app/") + flatpakId;
+         return tempPath;
++    }
+ 
+     tempPath = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation);
+ 
+diff --git a/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+index cb1b39db64..6e01af052c 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+@@ -755,6 +755,9 @@ QVariant QGnomeTheme::themeHint(QPlatformTheme::ThemeHint hint) const
+         return QVariant(QChar(0x2022));
+     case QPlatformTheme::UiEffects:
+         return QVariant(int(HoverEffect));
++    case QPlatformTheme::ButtonPressKeys:
++        return QVariant::fromValue(
++                QList<Qt::Key>({ Qt::Key_Space, Qt::Key_Return, Qt::Key_Enter, Qt::Key_Select }));
+     default:
+         break;
+     }
+diff --git a/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp b/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
+index 98e05195ee..1e92f43dec 100644
+--- a/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
++++ b/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
+@@ -343,8 +343,7 @@ void QEglFSCursor::paintOnScreen()
+     // screens are siblings of each other. When not enabled, the sibling list
+     // only contains m_screen itself.
+     for (QPlatformScreen *screen : m_screen->virtualSiblings()) {
+-        if (screen->geometry().contains(cr.topLeft().toPoint() + m_cursor.hotSpot)
+-            && QOpenGLContext::currentContext()->screen() == screen->screen())
++        if (screen->geometry().contains(cr.topLeft().toPoint() + m_cursor.hotSpot))
+         {
+             cr.translate(-screen->geometry().topLeft());
+             const QSize screenSize = screen->geometry().size();
+@@ -468,11 +467,12 @@ void QEglFSCursor::draw(const QRectF &r)
+ {
+     StateSaver stateSaver;
+ 
+-    QEglFSCursorData &gfx = static_cast<QEglFSContext*>(QOpenGLContext::currentContext()->handle())->cursorData;
+-    if (!gfx.program) {
+-        // one time initialization
++    // one time initialization
++    if (!QOpenGLFunctions::d_ptr)
+         initializeOpenGLFunctions();
+ 
++    QEglFSCursorData &gfx = static_cast<QEglFSContext*>(QOpenGLContext::currentContext()->handle())->cursorData;
++    if (!gfx.program) {
+         createShaderPrograms();
+ 
+         if (!gfx.atlasTexture) {
+diff --git a/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp b/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
+index 645a0ae2e9..3e0e406f1a 100644
+--- a/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
++++ b/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
+@@ -179,7 +179,7 @@ void QEglFSKmsEventReader::create(QEglFSKmsDevice *device)
+ 
+     m_device = device;
+ 
+-    qCDebug(qLcEglfsKmsDebug, "Initalizing event reader for device %p fd %d",
++    qCDebug(qLcEglfsKmsDebug, "Initializing event reader for device %p fd %d",
+             m_device, m_device->fd());
+ 
+     m_thread = new QEglFSKmsEventReaderThread(m_device->fd());
+diff --git a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
+index 141fb68a23..d4294d425a 100644
+--- a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
++++ b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
+@@ -122,11 +122,13 @@ QOffscreenIntegration::QOffscreenIntegration()
+ #endif
+     m_services.reset(new QPlatformServices);
+ 
+-    QWindowSystemInterface::handleScreenAdded(new QOffscreenScreen);
++    m_screen = new QOffscreenScreen;
++    QWindowSystemInterface::handleScreenAdded(m_screen);
+ }
+ 
+ QOffscreenIntegration::~QOffscreenIntegration()
+ {
++    QWindowSystemInterface::handleScreenRemoved(m_screen);
+ }
+ 
+ void QOffscreenIntegration::initialize()
+diff --git a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
+index 0ea90f6c2f..fe00fde07c 100644
+--- a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
++++ b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
+@@ -84,6 +84,7 @@ protected:
+ #endif
+     QScopedPointer<QPlatformInputContext> m_inputContext;
+     QScopedPointer<QPlatformServices> m_services;
++    QPlatformScreen *m_screen;
+     mutable QScopedPointer<QPlatformNativeInterface> m_nativeInterface;
+ };
+ 
+diff --git a/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp b/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
+index 6fa5a8a2b3..1f49f0aefd 100644
+--- a/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
++++ b/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
+@@ -48,6 +48,7 @@
+ #include <qpa/qplatformnativeinterface.h>
+ #include <QtPlatformHeaders/qwglnativecontext.h>
+ 
++#include <private/qsystemlibrary_p.h>
+ #include <algorithm>
+ 
+ #include <wingdi.h>
+@@ -162,19 +163,25 @@ QFunctionPointer QWindowsOpengl32DLL::resolve(const char *name)
+ 
+ bool QWindowsOpengl32DLL::init(bool softwareRendering)
+ {
+-    const QByteArray opengl32 = QByteArrayLiteral("opengl32.dll");
+-    const QByteArray swopengl = QByteArrayLiteral("opengl32sw.dll");
++    const QByteArray opengl32 = QByteArrayLiteral("opengl32");
++    const QByteArray swopengl = QByteArrayLiteral("opengl32sw");
++    bool useSystemLib = false;
+ 
+     QByteArray openglDll = qgetenv("QT_OPENGL_DLL");
+-    if (openglDll.isEmpty())
++    if (openglDll.isEmpty()) {
+         openglDll = softwareRendering ? swopengl : opengl32;
++        useSystemLib = !softwareRendering;
++    }
+ 
+     openglDll = openglDll.toLower();
+     m_nonOpengl32 = openglDll != opengl32;
+ 
+     qCDebug(lcQpaGl) << "Qt: Using WGL and OpenGL from" << openglDll;
+ 
+-    m_lib = ::LoadLibraryA(openglDll.constData());
++    if (useSystemLib)
++        m_lib = QSystemLibrary::load((wchar_t*)(QString::fromLatin1(openglDll).utf16()));
++    else
++        m_lib = LoadLibraryA(openglDll.constData());
+     if (!m_lib) {
+         qErrnoWarning(::GetLastError(), "Failed to load %s", openglDll.constData());
+         return false;
+@@ -184,7 +191,7 @@ bool QWindowsOpengl32DLL::init(bool softwareRendering)
+         // Load opengl32.dll always. GDI functions like ChoosePixelFormat do
+         // GetModuleHandle for opengl32.dll and behave differently (and call back into
+         // opengl32) when the module is present. This is fine for dummy contexts and windows.
+-        ::LoadLibraryA("opengl32.dll");
++        QSystemLibrary::load(L"opengl32");
+     }
+ 
+     wglCreateContext = reinterpret_cast<HGLRC (WINAPI *)(HDC)>(resolve("wglCreateContext"));
+diff --git a/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp b/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
+index d7d186e804..9eb4011bf2 100644
+--- a/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
++++ b/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
+@@ -49,6 +49,7 @@
+ #include <QtCore/qstandardpaths.h>
+ #include <QtCore/qlibraryinfo.h>
+ #include <QtCore/qhash.h>
++#include <private/qsystemlibrary_p.h>
+ 
+ #ifndef QT_NO_OPENGL
+ #include <private/qopengl_p.h>
+@@ -396,7 +397,7 @@ bool QWindowsOpenGLTester::testDesktopGL()
+ 
+     // Test #1: Load opengl32.dll and try to resolve an OpenGL 2 function.
+     // This will typically fail on systems that do not have a real OpenGL driver.
+-    lib = LoadLibraryA("opengl32.dll");
++    lib = QSystemLibrary::load(L"opengl32");
+     if (lib) {
+         CreateContext = reinterpret_cast<CreateContextType>(
+             reinterpret_cast<QFunctionPointer>(::GetProcAddress(lib, "wglCreateContext")));
+diff --git a/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp b/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
+index 1afa00cfc9..118af6ce73 100644
+--- a/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
++++ b/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
+@@ -41,6 +41,7 @@
+ 
+ #include <QRect>
+ #include <QList>
++#include <QMap>
+ #include <QDebug>
+ 
+ #include <qmath.h>
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp b/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
+index 9e2a37a6a1..e6e175a118 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
+@@ -488,12 +488,12 @@ void QXcbConnection::printXcbError(const char *message, xcb_generic_error_t *err
+     uint clamped_error_code = qMin<uint>(error->error_code, (sizeof(xcb_errors) / sizeof(xcb_errors[0])) - 1);
+     uint clamped_major_code = qMin<uint>(error->major_code, (sizeof(xcb_protocol_request_codes) / sizeof(xcb_protocol_request_codes[0])) - 1);
+ 
+-    qCWarning(lcQpaXcb, "%s: %d (%s), sequence: %d, resource id: %d, major code: %d (%s), minor code: %d",
+-             message,
+-             int(error->error_code), xcb_errors[clamped_error_code],
+-             int(error->sequence), int(error->resource_id),
+-             int(error->major_code), xcb_protocol_request_codes[clamped_major_code],
+-             int(error->minor_code));
++    qCDebug(lcQpaXcb, "%s: %d (%s), sequence: %d, resource id: %d, major code: %d (%s), minor code: %d",
++            message,
++            int(error->error_code), xcb_errors[clamped_error_code],
++            int(error->sequence), int(error->resource_id),
++            int(error->major_code), xcb_protocol_request_codes[clamped_major_code],
++            int(error->minor_code));
+ }
+ 
+ static Qt::MouseButtons translateMouseButtons(int s)
+@@ -702,6 +702,8 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
+             QXcbVirtualDesktop *virtualDesktop = virtualDesktopForRootWindow(propertyNotify->window);
+             if (virtualDesktop)
+                 virtualDesktop->updateWorkArea();
++        } else if (propertyNotify->atom == atom(QXcbAtom::_NET_SUPPORTED)) {
++            m_wmSupport->updateNetWMAtoms();
+         } else {
+             HANDLE_PLATFORM_WINDOW_EVENT(xcb_property_notify_event_t, window, handlePropertyNotifyEvent);
+         }
+@@ -750,7 +752,7 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
+                 case XCB_XKB_NEW_KEYBOARD_NOTIFY: {
+                     xcb_xkb_new_keyboard_notify_event_t *ev = &xkb_event->new_keyboard_notify;
+                     if (ev->changed & XCB_XKB_NKN_DETAIL_KEYCODES)
+-                        m_keyboard->updateKeymap(ev);
++                        m_keyboard->updateKeymap();
+                     break;
+                 }
+                 default:
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp b/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
+index 76869ced60..02d2eebb56 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
+@@ -274,8 +274,7 @@ QPlatformWindow *QXcbIntegration::createForeignWindow(QWindow *window, WId nativ
+ #ifndef QT_NO_OPENGL
+ QPlatformOpenGLContext *QXcbIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
+ {
+-    QXcbScreen *screen = static_cast<QXcbScreen *>(context->screen()->handle());
+-    QXcbGlIntegration *glIntegration = screen->connection()->glIntegration();
++    QXcbGlIntegration *glIntegration = defaultConnection()->glIntegration();
+     if (!glIntegration) {
+         qWarning("QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled");
+         return nullptr;
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+index efecd7e2d1..e8286381a2 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+@@ -365,17 +365,6 @@ void QXcbKeyboard::updateKeymap(xcb_mapping_notify_event_t *event)
+     updateKeymap();
+ }
+ 
+-void QXcbKeyboard::updateKeymap(xcb_xkb_new_keyboard_notify_event_t *event)
+-{
+-    if (!event)
+-        return;
+-
+-    if (event->deviceID != event->oldDeviceID)
+-        m_config = false;
+-
+-    updateKeymap();
+-}
+-
+ void QXcbKeyboard::updateKeymap()
+ {
+     KeysymModifierMap keysymMods;
+@@ -383,6 +372,8 @@ void QXcbKeyboard::updateKeymap()
+         keysymMods = keysymsToModifiers();
+     updateModifiers(keysymMods);
+ 
++    m_config = true;
++
+     if (!m_xkbContext) {
+         m_xkbContext.reset(xkb_context_new(XKB_CONTEXT_NO_DEFAULT_INCLUDES));
+         if (!m_xkbContext) {
+@@ -398,13 +389,8 @@ void QXcbKeyboard::updateKeymap()
+     if (connection()->hasXKB()) {
+         m_xkbKeymap.reset(xkb_x11_keymap_new_from_device(m_xkbContext.get(), xcb_connection(),
+                                                          core_device_id, XKB_KEYMAP_COMPILE_NO_FLAGS));
+-        if (m_xkbKeymap) {
+-            if (m_config)
+-                m_xkbState.reset(xkb_state_new(m_xkbKeymap.get()));
+-            else
+-                m_xkbState.reset(xkb_x11_state_new_from_device(m_xkbKeymap.get(), xcb_connection(), core_device_id));
+-
+-        }
++        if (m_xkbKeymap)
++            m_xkbState.reset(xkb_x11_state_new_from_device(m_xkbKeymap.get(), xcb_connection(), core_device_id));
+     } else {
+         m_xkbKeymap.reset(keymapFromCore(keysymMods));
+         if (m_xkbKeymap)
+@@ -425,8 +411,6 @@ void QXcbKeyboard::updateKeymap()
+     updateXKBMods();
+ 
+     QXkbCommon::verifyHasLatinLayout(m_xkbKeymap.get());
+-
+-    m_config = true;
+ }
+ 
+ QList<int> QXcbKeyboard::possibleKeys(const QKeyEvent *event) const
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
+index b652c85fe3..0ee08aeff2 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
++++ b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
+@@ -69,7 +69,6 @@ public:
+ 
+     Qt::KeyboardModifiers translateModifiers(int s) const;
+     void updateKeymap(xcb_mapping_notify_event_t *event);
+-    void updateKeymap(xcb_xkb_new_keyboard_notify_event_t *event);
+     void updateKeymap();
+     QList<int> possibleKeys(const QKeyEvent *event) const;
+ 
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp b/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
+index ffda7b6a57..863e961f4c 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
+@@ -564,11 +564,6 @@ void QXcbWindow::setGeometry(const QRect &rect)
+ {
+     QPlatformWindow::setGeometry(rect);
+ 
+-    if (shouldDeferTask(Task::SetGeometry)) {
+-        m_deferredGeometry = rect;
+-        return;
+-    }
+-
+     propagateSizeHints();
+ 
+     QXcbScreen *currentScreen = xcbScreen();
+@@ -693,9 +688,6 @@ void QXcbWindow::setVisible(bool visible)
+ 
+ void QXcbWindow::show()
+ {
+-    if (shouldDeferTask(Task::Map))
+-        return;
+-
+     if (window()->isTopLevel()) {
+ 
+         // update WM_NORMAL_HINTS
+@@ -706,7 +698,7 @@ void QXcbWindow::show()
+         if (isTransient(window())) {
+             const QWindow *tp = window()->transientParent();
+             if (tp && tp->handle())
+-                transientXcbParent = static_cast<const QXcbWindow *>(tp->handle())->winId();
++                transientXcbParent = tp->handle()->winId();
+             // Default to client leader if there is no transient parent, else modal dialogs can
+             // be hidden by their parents.
+             if (!transientXcbParent)
+@@ -746,10 +738,6 @@ void QXcbWindow::show()
+ 
+ void QXcbWindow::hide()
+ {
+-    if (shouldDeferTask(Task::Unmap))
+-        return;
+-
+-    m_wmStateValid = false;
+     xcb_unmap_window(xcb_connection(), m_window);
+ 
+     // send synthetic UnmapNotify event according to icccm 4.1.4
+@@ -909,9 +897,6 @@ QXcbWindow::NetWmStates QXcbWindow::netWmStates()
+ 
+ void QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
+ {
+-    if (shouldDeferTask(Task::SetWindowFlags))
+-        return;
+-
+     Qt::WindowType type = static_cast<Qt::WindowType>(int(flags & Qt::WindowType_Mask));
+ 
+     if (type == Qt::ToolTip)
+@@ -941,8 +926,6 @@ void QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
+ 
+     setTransparentForMouseEvents(flags & Qt::WindowTransparentForInput);
+     updateDoesNotAcceptFocus(flags & Qt::WindowDoesNotAcceptFocus);
+-
+-    m_isWmManagedWindow = !(flags & Qt::X11BypassWindowManagerHint);
+ }
+ 
+ void QXcbWindow::setMotifWmHints(Qt::WindowFlags flags)
+@@ -1142,9 +1125,6 @@ void QXcbWindow::setWindowState(Qt::WindowStates state)
+     if (state == m_windowState)
+         return;
+ 
+-    if (shouldDeferTask(Task::SetWindowState))
+-        return;
+-
+     // unset old state
+     if (m_windowState & Qt::WindowMinimized)
+         xcb_map_window(xcb_connection(), m_window);
+@@ -1350,6 +1330,12 @@ void QXcbWindow::setWindowIcon(const QIcon &icon)
+     }
+ 
+     if (!icon_data.isEmpty()) {
++        // Ignore icon exceeding maximum xcb request length
++        if (icon_data.size() > xcb_get_maximum_request_length(xcb_connection())) {
++            qWarning("Ignoring window icon: Size %llu exceeds maximum xcb request length %u.",
++                     icon_data.size(), xcb_get_maximum_request_length(xcb_connection()));
++            return;
++        }
+         xcb_change_property(xcb_connection(),
+                             XCB_PROP_MODE_REPLACE,
+                             m_window,
+@@ -1639,7 +1625,7 @@ void QXcbWindow::setWmWindowType(QXcbWindowFunctions::WmWindowTypes types, Qt::W
+         break;
+     }
+ 
+-    if ((flags & Qt::FramelessWindowHint) && !(type & QXcbWindowFunctions::KdeOverride)) {
++    if ((flags & Qt::FramelessWindowHint) && !(types & QXcbWindowFunctions::KdeOverride)) {
+         // override netwm type - quick and easy for KDE noborder
+         atoms.append(atom(QXcbAtom::_KDE_NET_WM_WINDOW_TYPE_OVERRIDE));
+     }
+@@ -1894,10 +1880,6 @@ void QXcbWindow::handleUnmapNotifyEvent(const xcb_unmap_notify_event_t *event)
+     if (event->window == m_window) {
+         m_mapped = false;
+         QWindowSystemInterface::handleExposeEvent(window(), QRegion());
+-        if (!m_isWmManagedWindow || parent()) {
+-            m_wmStateValid = true;
+-            handleDeferredTasks();
+-        }
+     }
+ }
+ 
+@@ -2212,98 +2194,30 @@ void QXcbWindow::handleLeaveNotifyEvent(const xcb_leave_notify_event_t *event)
+     handleLeaveNotifyEvent(event->root_x, event->root_y, event->mode, event->detail, event->time);
+ }
+ 
+-bool QXcbWindow::shouldDeferTask(Task task)
+-{
+-    if (m_wmStateValid)
+-        return false;
+-
+-    m_deferredTasks.append(task);
+-    return true;
+-}
+-
+-void QXcbWindow::handleDeferredTasks()
+-{
+-    Q_ASSERT(m_wmStateValid == true);
+-    if (m_deferredTasks.isEmpty())
+-        return;
+-
+-    bool map = false;
+-    bool unmap = false;
+-
+-    QVector<Task> tasks;
+-    for (auto taskIt = m_deferredTasks.rbegin(); taskIt != m_deferredTasks.rend(); ++taskIt) {
+-        if (!tasks.contains(*taskIt))
+-            tasks.prepend(*taskIt);
+-    }
+-
+-    for (Task task : tasks) {
+-        switch (task) {
+-        case Task::Map:
+-            map = true;
+-            unmap = false;
+-            break;
+-        case Task::Unmap:
+-            unmap = true;
+-            map = false;
+-            break;
+-        case Task::SetGeometry:
+-            setGeometry(m_deferredGeometry);
+-            break;
+-        case Task::SetWindowFlags:
+-            setWindowFlags(window()->flags());
+-            break;
+-        case Task::SetWindowState:
+-            setWindowState(window()->windowState());
+-            break;
+-        }
+-    }
+-    m_deferredTasks.clear();
+-
+-    if (map) {
+-        Q_ASSERT(unmap == false);
+-        show();
+-    }
+-    if (unmap) {
+-        Q_ASSERT(map == false);
+-        hide();
+-    }
+-}
+-
+ void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *event)
+ {
+     connection()->setTime(event->time);
+ 
+-    const bool wmStateChanged = event->atom == atom(QXcbAtom::WM_STATE);
+-    const bool netWmStateChanged = event->atom == atom(QXcbAtom::_NET_WM_STATE);
+-    if (netWmStateChanged || wmStateChanged) {
+-        if (wmStateChanged && !m_wmStateValid && m_isWmManagedWindow) {
+-            // ICCCM 4.1.4
+-            // Clients that want to re-use a client window (e.g. by mapping it again)
+-            // after withdrawing it must wait for the withdrawal to be complete before
+-            // proceeding. The preferred method for doing this is for clients to wait for
+-            // a window manager to update or remove the WM_STATE property.
+-            m_wmStateValid = true;
+-            handleDeferredTasks();
+-        }
+-        if (event->state == XCB_PROPERTY_DELETE)
++    const bool propertyDeleted = event->state == XCB_PROPERTY_DELETE;
++
++    if (event->atom == atom(QXcbAtom::_NET_WM_STATE) || event->atom == atom(QXcbAtom::WM_STATE)) {
++        if (propertyDeleted)
+             return;
+ 
+-        if (wmStateChanged) {
++        Qt::WindowStates newState = Qt::WindowNoState;
++
++        if (event->atom == atom(QXcbAtom::WM_STATE)) { // WM_STATE: Quick check for 'Minimize'.
+             auto reply = Q_XCB_REPLY(xcb_get_property, xcb_connection(),
+                                      0, m_window, atom(QXcbAtom::WM_STATE),
+                                      XCB_ATOM_ANY, 0, 1024);
+             if (reply && reply->format == 32 && reply->type == atom(QXcbAtom::WM_STATE)) {
+-                auto data = static_cast<const quint32 *>(xcb_get_property_value(reply.get()));
+-                if (reply->length != 0) {
+-                    const bool changedToWithdrawn = data[0] == XCB_ICCCM_WM_STATE_WITHDRAWN;
+-                    const bool changedToIconic = data[0] == XCB_ICCCM_WM_STATE_ICONIC;
+-                    m_minimized = changedToIconic || (changedToWithdrawn && m_minimized);
+-                }
++                const quint32 *data = (const quint32 *)xcb_get_property_value(reply.get());
++                if (reply->length != 0)
++                    m_minimized = (data[0] == XCB_ICCCM_WM_STATE_ICONIC
++                                   || (data[0] == XCB_ICCCM_WM_STATE_WITHDRAWN && m_minimized));
+             }
+         }
+ 
+-        // _NET_WM_STATE handling
+-        Qt::WindowStates newState = Qt::WindowNoState;
+         const NetWmStates states = netWmStates();
+         // _NET_WM_STATE_HIDDEN should be set by the Window Manager to indicate that a window would
+         // not be visible on the screen if its desktop/viewport were active and its coordinates were
+@@ -2325,6 +2239,7 @@ void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *ev
+             if ((m_windowState & Qt::WindowMinimized) && connection()->mouseGrabber() == this)
+                 connection()->setMouseGrabber(nullptr);
+         }
++        return;
+     } else if (event->atom == atom(QXcbAtom::_NET_FRAME_EXTENTS)) {
+         m_dirtyFrameMargins = true;
+     }
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbwindow.h b/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
+index 55af9279b1..6f5c1f5ed9 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
++++ b/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
+@@ -74,14 +74,6 @@ public:
+ 
+     Q_DECLARE_FLAGS(NetWmStates, NetWmState)
+ 
+-    enum Task {
+-        Map,
+-        Unmap,
+-        SetGeometry,
+-        SetWindowFlags,
+-        SetWindowState
+-    };
+-
+     QXcbWindow(QWindow *window);
+     ~QXcbWindow();
+ 
+@@ -151,9 +143,6 @@ public:
+ 
+     QXcbWindow *toWindow() override;
+ 
+-    bool shouldDeferTask(Task task);
+-    void handleDeferredTasks();
+-
+     void handleMouseEvent(xcb_timestamp_t time, const QPoint &local, const QPoint &global,
+                           Qt::KeyboardModifiers modifiers, QEvent::Type type, Qt::MouseEventSource source);
+ 
+@@ -292,11 +281,6 @@ protected:
+     int m_swapInterval = -1;
+ 
+     qreal m_sizeHintsScaleFactor = 1.0;
+-
+-    bool m_wmStateValid = true;
+-    QVector<Task> m_deferredTasks;
+-    bool m_isWmManagedWindow = true;
+-    QRect m_deferredGeometry;
+ };
+ 
+ class QXcbForeignWindow : public QXcbWindow
+diff --git a/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp b/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
+index d9d117faeb..640b49daa0 100644
+--- a/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
++++ b/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
+@@ -85,6 +85,7 @@ QGtk3MenuItem::QGtk3MenuItem()
+       m_checkable(false),
+       m_checked(false),
+       m_enabled(true),
++      m_exclusive(false),
+       m_underline(false),
+       m_invalid(true),
+       m_menu(nullptr),
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
+index 0048bbc1e6..396e7f6d1c 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
+@@ -102,15 +102,12 @@ const QDBusArgument &operator >>(const QDBusArgument &arg, QXdgDesktopPortalFile
+ class QXdgDesktopPortalFileDialogPrivate
+ {
+ public:
+-    QXdgDesktopPortalFileDialogPrivate(QPlatformFileDialogHelper *nativeFileDialog)
++    QXdgDesktopPortalFileDialogPrivate(QPlatformFileDialogHelper *nativeFileDialog, uint fileChooserPortalVersion)
+         : nativeFileDialog(nativeFileDialog)
++        , fileChooserPortalVersion(fileChooserPortalVersion)
+     { }
+ 
+-    WId winId = 0;
+-    bool directoryMode = false;
+-    bool modal = false;
+-    bool multipleFiles = false;
+-    bool saveFile = false;
++    QEventLoop loop;
+     QString acceptLabel;
+     QString directory;
+     QString title;
+@@ -121,19 +118,27 @@ public:
+     QString selectedMimeTypeFilter;
+     QString selectedNameFilter;
+     QStringList selectedFiles;
+-    QPlatformFileDialogHelper *nativeFileDialog = nullptr;
++    std::unique_ptr<QPlatformFileDialogHelper> nativeFileDialog;
++    uint fileChooserPortalVersion = 0;
++    bool failedToOpen = false;
++    bool directoryMode = false;
++    bool multipleFiles = false;
++    bool saveFile = false;
+ };
+ 
+-QXdgDesktopPortalFileDialog::QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog)
++QXdgDesktopPortalFileDialog::QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog, uint fileChooserPortalVersion)
+     : QPlatformFileDialogHelper()
+-    , d_ptr(new QXdgDesktopPortalFileDialogPrivate(nativeFileDialog))
++    , d_ptr(new QXdgDesktopPortalFileDialogPrivate(nativeFileDialog, fileChooserPortalVersion))
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+     if (d->nativeFileDialog) {
+-        connect(d->nativeFileDialog, SIGNAL(accept()), this, SIGNAL(accept()));
+-        connect(d->nativeFileDialog, SIGNAL(reject()), this, SIGNAL(reject()));
++        connect(d->nativeFileDialog.get(), SIGNAL(accept()), this, SIGNAL(accept()));
++        connect(d->nativeFileDialog.get(), SIGNAL(reject()), this, SIGNAL(reject()));
+     }
++
++    d->loop.connect(this, SIGNAL(accept()), SLOT(quit()));
++    d->loop.connect(this, SIGNAL(reject()), SLOT(quit()));
+ }
+ 
+ QXdgDesktopPortalFileDialog::~QXdgDesktopPortalFileDialog()
+@@ -177,7 +182,7 @@ void QXdgDesktopPortalFileDialog::initializeDialog()
+     setDirectory(options()->initialDirectory());
+ }
+ 
+-void QXdgDesktopPortalFileDialog::openPortal()
++void QXdgDesktopPortalFileDialog::openPortal(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent)
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+@@ -185,13 +190,13 @@ void QXdgDesktopPortalFileDialog::openPortal()
+                                                           QLatin1String("/org/freedesktop/portal/desktop"),
+                                                           QLatin1String("org.freedesktop.portal.FileChooser"),
+                                                           d->saveFile ? QLatin1String("SaveFile") : QLatin1String("OpenFile"));
+-    QString parentWindowId = QLatin1String("x11:") + QString::number(d->winId, 16);
++    QString parentWindowId = QLatin1String("x11:") + QString::number(parent ? parent->winId() : 0, 16);
+ 
+     QVariantMap options;
+     if (!d->acceptLabel.isEmpty())
+         options.insert(QLatin1String("accept_label"), d->acceptLabel);
+ 
+-    options.insert(QLatin1String("modal"), d->modal);
++    options.insert(QLatin1String("modal"), windowModality != Qt::NonModal);
+     options.insert(QLatin1String("multiple"), d->multipleFiles);
+     options.insert(QLatin1String("directory"), d->directoryMode);
+ 
+@@ -290,10 +295,18 @@ void QXdgDesktopPortalFileDialog::openPortal()
+ 
+     QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
+     QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingCall);
+-    connect(watcher, &QDBusPendingCallWatcher::finished, this, [this] (QDBusPendingCallWatcher *watcher) {
++    connect(watcher, &QDBusPendingCallWatcher::finished, this, [=] (QDBusPendingCallWatcher *watcher) {
+         QDBusPendingReply<QDBusObjectPath> reply = *watcher;
+-        if (reply.isError()) {
+-            Q_EMIT reject();
++        // Any error means the dialog is not shown and we need to fallback
++        d->failedToOpen = reply.isError();
++        if (d->failedToOpen) {
++            if (d->nativeFileDialog) {
++                d->nativeFileDialog->show(windowFlags, windowModality, parent);
++                if (d->loop.isRunning())
++                    d->nativeFileDialog->exec();
++            } else {
++                Q_EMIT reject();
++            }
+         } else {
+             QDBusConnection::sessionBus().connect(nullptr,
+                                                   reply.value().path(),
+@@ -302,6 +315,7 @@ void QXdgDesktopPortalFileDialog::openPortal()
+                                                   this,
+                                                   SLOT(gotResponse(uint,QVariantMap)));
+         }
++        watcher->deleteLater();
+     });
+ }
+ 
+@@ -326,7 +340,7 @@ QUrl QXdgDesktopPortalFileDialog::directory() const
+ {
+     Q_D(const QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog())
+         return d->nativeFileDialog->directory();
+ 
+     return d->directory;
+@@ -348,7 +362,7 @@ QList<QUrl> QXdgDesktopPortalFileDialog::selectedFiles() const
+ {
+     Q_D(const QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog())
+         return d->nativeFileDialog->selectedFiles();
+ 
+     QList<QUrl> files;
+@@ -403,16 +417,13 @@ void QXdgDesktopPortalFileDialog::exec()
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly)) {
++    if (d->nativeFileDialog && useNativeFileDialog()) {
+         d->nativeFileDialog->exec();
+         return;
+     }
+ 
+     // HACK we have to avoid returning until we emit that the dialog was accepted or rejected
+-    QEventLoop loop;
+-    loop.connect(this, SIGNAL(accept()), SLOT(quit()));
+-    loop.connect(this, SIGNAL(reject()), SLOT(quit()));
+-    loop.exec();
++    d->loop.exec();
+ }
+ 
+ void QXdgDesktopPortalFileDialog::hide()
+@@ -429,13 +440,10 @@ bool QXdgDesktopPortalFileDialog::show(Qt::WindowFlags windowFlags, Qt::WindowMo
+ 
+     initializeDialog();
+ 
+-    d->modal = windowModality != Qt::NonModal;
+-    d->winId = parent ? parent->winId() : 0;
+-
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog(OpenFallback))
+         return d->nativeFileDialog->show(windowFlags, windowModality, parent);
+ 
+-    openPortal();
++    openPortal(windowFlags, windowModality, parent);
+ 
+     return true;
+ }
+@@ -465,4 +473,21 @@ void QXdgDesktopPortalFileDialog::gotResponse(uint response, const QVariantMap &
+     }
+ }
+ 
++bool QXdgDesktopPortalFileDialog::useNativeFileDialog(QXdgDesktopPortalFileDialog::FallbackType fallbackType) const
++{
++    Q_D(const QXdgDesktopPortalFileDialog);
++
++    if (d->failedToOpen && fallbackType != OpenFallback)
++        return true;
++
++    if (d->fileChooserPortalVersion < 3) {
++        if (options()->fileMode() == QFileDialogOptions::Directory)
++            return true;
++        else if (options()->fileMode() == QFileDialogOptions::DirectoryOnly)
++            return true;
++    }
++
++    return false;
++}
++
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
+index 4f4de96ecf..65e22a5cf2 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
+@@ -51,6 +51,11 @@ class QXdgDesktopPortalFileDialog : public QPlatformFileDialogHelper
+     Q_OBJECT
+     Q_DECLARE_PRIVATE(QXdgDesktopPortalFileDialog)
+ public:
++    enum FallbackType {
++        GenericFallback,
++        OpenFallback
++    };
++
+     enum ConditionType : uint {
+         GlobalPattern = 0,
+         MimeType = 1
+@@ -69,7 +74,7 @@ public:
+     };
+     typedef QVector<Filter> FilterList;
+ 
+-    QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog = nullptr);
++    QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog = nullptr, uint fileChooserPortalVersion = 0);
+     ~QXdgDesktopPortalFileDialog();
+ 
+     bool defaultNameFilterDisables() const override;
+@@ -92,7 +97,8 @@ private Q_SLOTS:
+ 
+ private:
+     void initializeDialog();
+-    void openPortal();
++    void openPortal(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent);
++    bool useNativeFileDialog(FallbackType fallbackType = GenericFallback) const;
+ 
+     QScopedPointer<QXdgDesktopPortalFileDialogPrivate> d_ptr;
+ };
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
+index fb324afbd8..b809503122 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
+@@ -111,6 +111,7 @@ QXdgDesktopPortalTheme::QXdgDesktopPortalTheme()
+         if (reply.isValid()) {
+             d->fileChooserPortalVersion = reply.value().toUInt();
+         }
++        watcher->deleteLater();
+     });
+ }
+ 
+@@ -152,11 +153,12 @@ QPlatformDialogHelper* QXdgDesktopPortalTheme::createPlatformDialogHelper(Dialog
+ {
+     Q_D(const QXdgDesktopPortalTheme);
+ 
+-    if (type == FileDialog) {
++    if (type == FileDialog && d->fileChooserPortalVersion) {
+         // Older versions of FileChooser portal don't support opening directories, therefore we fallback
+         // to native file dialog opened inside the sandbox to open a directory.
+-        if (d->fileChooserPortalVersion < 3 && d->baseTheme->usePlatformNativeDialog(type))
+-            return new QXdgDesktopPortalFileDialog(static_cast<QPlatformFileDialogHelper*>(d->baseTheme->createPlatformDialogHelper(type)));
++        if (d->baseTheme->usePlatformNativeDialog(type))
++            return new QXdgDesktopPortalFileDialog(static_cast<QPlatformFileDialogHelper*>(d->baseTheme->createPlatformDialogHelper(type)),
++                                                   d->fileChooserPortalVersion);
+ 
+         return new QXdgDesktopPortalFileDialog;
+     }
+diff --git a/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp b/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
+index 43d5e119ad..1f9cbc4565 100644
+--- a/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
++++ b/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
+@@ -89,8 +89,10 @@ void QCupsPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &v
+         break;
+     case PPK_Duplex: {
+         QPrint::DuplexMode mode = QPrint::DuplexMode(value.toInt());
+-        if (mode != d->duplex && d->m_printDevice.supportedDuplexModes().contains(mode))
++        if (d->m_printDevice.supportedDuplexModes().contains(mode)) {
+             d->duplex = mode;
++            d->duplexRequestedExplicitly = true;
++        }
+         break;
+     }
+     case PPK_PrinterName:
+@@ -277,9 +279,12 @@ void QCupsPrintEnginePrivate::changePrinter(const QString &newPrinter)
+     m_printDevice.swap(printDevice);
+     printerName = m_printDevice.id();
+ 
+-    // Check if new printer supports current settings, otherwise us defaults
+-    if (duplex != QPrint::DuplexAuto && !m_printDevice.supportedDuplexModes().contains(duplex))
++    // in case a duplex value was explicitly set, check if new printer supports current value,
++    // otherwise use device default
++    if (!duplexRequestedExplicitly || !m_printDevice.supportedDuplexModes().contains(duplex)) {
+         duplex = m_printDevice.defaultDuplexMode();
++        duplexRequestedExplicitly = false;
++    }
+     QPrint::ColorMode colorMode = grayscale ? QPrint::GrayScale : QPrint::Color;
+     if (!m_printDevice.supportedColorModes().contains(colorMode))
+         grayscale = m_printDevice.defaultColorMode() == QPrint::GrayScale;
+diff --git a/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h b/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
+index c021b0c643..8f81fe478d 100644
+--- a/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
++++ b/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
+@@ -100,6 +100,7 @@ private:
+     QStringList cupsOptions;
+     QString cupsTempFile;
+     QPrint::DuplexMode duplex;
++    bool duplexRequestedExplicitly = false;
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp b/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
+index 67e7154fa6..40876152e5 100644
+--- a/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
++++ b/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
+@@ -817,7 +817,7 @@ bool QIBaseResultPrivate::writeArray(int column, const QList<QVariant> &list)
+     ba.resize(int(bufLen));
+ 
+     if (list.size() > arraySize) {
+-        error = QLatin1String("Array size missmatch: size of %1 is %2, size of provided list is %3");
++        error = QLatin1String("Array size mismatch: size of %1 is %2, size of provided list is %3");
+         error = error.arg(QLatin1String(sqlname)).arg(arraySize).arg(list.size());
+         q->setLastError(QSqlError(error, QLatin1String(""), QSqlError::StatementError));
+         return false;
+diff --git a/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp b/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
+index 7ca055eea2..6bc9d46755 100644
+--- a/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
++++ b/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
+@@ -223,7 +223,7 @@ public:
+     struct QMyField
+     {
+         char *outField = nullptr;
+-        MYSQL_FIELD *myField = nullptr;
++        const MYSQL_FIELD *myField = nullptr;
+         QMetaType::Type type = QMetaType::UnknownType;
+         my_bool nullIndicator = false;
+         ulong bufLength = 0ul;
+@@ -361,7 +361,7 @@ static bool qIsInteger(int t)
+ void QMYSQLResultPrivate::bindBlobs()
+ {
+     int i;
+-    MYSQL_FIELD *fieldInfo;
++    const MYSQL_FIELD *fieldInfo;
+     MYSQL_BIND *bind;
+ 
+     for(i = 0; i < fields.count(); ++i) {
+@@ -379,7 +379,6 @@ void QMYSQLResultPrivate::bindBlobs()
+ bool QMYSQLResultPrivate::bindInValues()
+ {
+     MYSQL_BIND *bind;
+-    char *field;
+     int i = 0;
+ 
+     if (!meta)
+@@ -392,35 +391,34 @@ bool QMYSQLResultPrivate::bindInValues()
+     inBinds = new MYSQL_BIND[fields.size()];
+     memset(inBinds, 0, fields.size() * sizeof(MYSQL_BIND));
+ 
+-    MYSQL_FIELD *fieldInfo;
++    const MYSQL_FIELD *fieldInfo;
+ 
+     while((fieldInfo = mysql_fetch_field(meta))) {
++        bind = &inBinds[i];
++
+         QMyField &f = fields[i];
+         f.myField = fieldInfo;
+-
++        bind->buffer_length = f.bufLength = fieldInfo->length + 1;
++        bind->buffer_type = fieldInfo->type;
+         f.type = qDecodeMYSQLType(fieldInfo->type, fieldInfo->flags);
+         if (qIsBlob(fieldInfo->type)) {
+             // the size of a blob-field is available as soon as we call
+             // mysql_stmt_store_result()
+             // after mysql_stmt_exec() in QMYSQLResult::exec()
+-            fieldInfo->length = 0;
++            bind->buffer_length = f.bufLength = 0;
+             hasBlobs = true;
+         } else if (qIsInteger(f.type)) {
+-            fieldInfo->length = 8;
++            bind->buffer_length = f.bufLength = 8;
+         } else {
+-            fieldInfo->type = MYSQL_TYPE_STRING;
++            bind->buffer_type = MYSQL_TYPE_STRING;
+         }
+-        bind = &inBinds[i];
+-        field = new char[fieldInfo->length + 1];
+-        memset(field, 0, fieldInfo->length + 1);
+ 
+-        bind->buffer_type = fieldInfo->type;
+-        bind->buffer = field;
+-        bind->buffer_length = f.bufLength = fieldInfo->length + 1;
+         bind->is_null = &f.nullIndicator;
+         bind->length = &f.bufLength;
+         bind->is_unsigned = fieldInfo->flags & UNSIGNED_FLAG ? 1 : 0;
+-        f.outField=field;
++
++        char *field = new char[bind->buffer_length + 1]{};
++        bind->buffer = f.outField = field;
+ 
+         ++i;
+     }
+@@ -1369,20 +1367,20 @@ bool QMYSQLDriver::open(const QString& db,
+     }
+ 
+ #if MYSQL_VERSION_ID >= 50007
+-    if (mysql_get_client_version() >= 50503 && mysql_get_server_version(d->mysql) >= 50503) {
+-        // force the communication to be utf8mb4 (only utf8mb4 supports 4-byte characters)
+-        mysql_set_character_set(d->mysql, "utf8mb4");
++    // force the communication to be utf8mb4 (only utf8mb4 supports 4-byte characters)
++    if (mysql_set_character_set(d->mysql, "utf8mb4")) {
++        // this failed, try forcing it to utf (BMP only)
++        if (mysql_set_character_set(d->mysql, "utf8"))
++            qWarning() << "MySQL: Unable to set the client character set to utf8.";
+ #if QT_CONFIG(textcodec)
+-        d->tc = QTextCodec::codecForName("UTF-8");
++        else
++            d->tc = codec(d->mysql);
+ #endif
+-    } else
+-    {
+-        // force the communication to be utf8
+-        mysql_set_character_set(d->mysql, "utf8");
++    }
+ #if QT_CONFIG(textcodec)
+-        d->tc = codec(d->mysql);
++    else
++        d->tc = QTextCodec::codecForName("UTF-8");
+ #endif
+-    }
+ #endif  // MYSQL_VERSION_ID >= 50007
+ 
+     d->preparedQuerysEnabled = checkPreparedQueries(d->mysql);
+diff --git a/qtbase/src/printsupport/dialogs/images/print-24.png b/qtbase/src/printsupport/dialogs/images/printer-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/print-24.png
+rename to src/printsupport/dialogs/images/printer-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/print-32.png b/qtbase/src/printsupport/dialogs/images/printer-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/print-32.png
+rename to src/printsupport/dialogs/images/printer-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-sided-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-facing-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-sided-24.png
+rename to src/printsupport/dialogs/images/view-pages-facing-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-sided-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-facing-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-sided-32.png
+rename to src/printsupport/dialogs/images/view-pages-facing-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-multi-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-overview-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-multi-24.png
+rename to src/printsupport/dialogs/images/view-pages-overview-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-multi-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-overview-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-multi-32.png
+rename to src/printsupport/dialogs/images/view-pages-overview-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-one-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-single-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-one-24.png
+rename to src/printsupport/dialogs/images/view-pages-single-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-one-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-single-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-one-32.png
+rename to src/printsupport/dialogs/images/view-pages-single-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-page-24.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-page-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-page-24.png
+rename to src/printsupport/dialogs/images/zoom-fit-page-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-page-32.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-page-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-page-32.png
+rename to src/printsupport/dialogs/images/zoom-fit-page-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-width-24.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-width-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-width-24.png
+rename to src/printsupport/dialogs/images/zoom-fit-width-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-width-32.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-width-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-width-32.png
+rename to src/printsupport/dialogs/images/zoom-fit-width-32.png
+diff --git a/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp b/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
+index 78e5b8d1ef..2a28516719 100644
+--- a/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
++++ b/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
+@@ -532,6 +532,7 @@ void QPageSetupWidget::updateWidget()
+ void QPageSetupWidget::setupPrinter() const
+ {
+     m_printer->setPageLayout(m_pageLayout);
++    m_printer->setPageOrientation(m_pageLayout.orientation());
+ #if QT_CONFIG(cups)
+     QCUPSSupport::PagesPerSheet pagesPerSheet = qvariant_cast<QCUPSSupport::PagesPerSheet>(m_ui.pagesPerSheetCombo->currentData()
+ );
+diff --git a/qtbase/src/printsupport/dialogs/qprintdialog.qrc b/qtbase/src/printsupport/dialogs/qprintdialog.qrc
+index 5a579baa55..10b8e1d341 100644
+--- a/qtbase/src/printsupport/dialogs/qprintdialog.qrc
++++ b/qtbase/src/printsupport/dialogs/qprintdialog.qrc
+@@ -1,9 +1,9 @@
+ <!DOCTYPE RCC><RCC version="1.0">
+ <qresource prefix="/qt-project.org/dialogs/qprintpreviewdialog">
+-<file>images/fit-page-24.png</file>
+-<file>images/fit-page-32.png</file>
+-<file>images/fit-width-24.png</file>
+-<file>images/fit-width-32.png</file>
++<file>images/zoom-fit-page-24.png</file>
++<file>images/zoom-fit-page-32.png</file>
++<file>images/zoom-fit-width-24.png</file>
++<file>images/zoom-fit-width-32.png</file>
+ <file>images/go-first-24.png</file>
+ <file>images/go-first-32.png</file>
+ <file>images/go-last-24.png</file>
+@@ -18,14 +18,14 @@
+ <file>images/layout-portrait-32.png</file>
+ <file>images/page-setup-24.png</file>
+ <file>images/page-setup-32.png</file>
+-<file>images/print-24.png</file>
+-<file>images/print-32.png</file>
+-<file>images/view-page-multi-24.png</file>
+-<file>images/view-page-multi-32.png</file>
+-<file>images/view-page-one-24.png</file>
+-<file>images/view-page-one-32.png</file>
+-<file>images/view-page-sided-24.png</file>
+-<file>images/view-page-sided-32.png</file>
++<file>images/printer-24.png</file>
++<file>images/printer-32.png</file>
++<file>images/view-pages-overview-24.png</file>
++<file>images/view-pages-overview-32.png</file>
++<file>images/view-pages-single-24.png</file>
++<file>images/view-pages-single-32.png</file>
++<file>images/view-pages-facing-24.png</file>
++<file>images/view-pages-facing-32.png</file>
+ <file>images/zoom-in-24.png</file>
+ <file>images/zoom-in-32.png</file>
+ <file>images/zoom-out-24.png</file>
+diff --git a/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp b/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
+index c5b845f4ec..5a5ba1d0a8 100644
+--- a/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
++++ b/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
+@@ -702,13 +702,14 @@ void QPrintDialogPrivate::selectPrinter(const QPrinter::OutputFormat outputForma
+         else
+             options.grayscale->setChecked(true);
+ 
+-        // keep duplex value explicitly set by user, if any, and selected printer supports it;
+-        // use device default otherwise
++        // duplex priorities to be as follows:
++        // 1) a user-selected duplex value in the dialog has highest prority
++        // 2) duplex value set in the QPrinter
+         QPrint::DuplexMode duplex;
+         if (explicitDuplexMode != QPrint::DuplexAuto && supportedDuplexMode.contains(explicitDuplexMode))
+             duplex = explicitDuplexMode;
+         else
+-            duplex = top->d->m_currentPrintDevice.defaultDuplexMode();
++            duplex = static_cast<QPrint::DuplexMode>(p->duplex());
+         switch (duplex) {
+         case QPrint::DuplexNone:
+             options.noDuplex->setChecked(true); break;
+@@ -1242,10 +1243,10 @@ void QUnixPrintWidgetPrivate::_q_printerChanged(int index)
+             QString filename = widget.filename->text();
+             widget.filename->setText(filename);
+             widget.lOutput->setEnabled(true);
+-            if (optionsPane)
+-                optionsPane->selectPrinter(QPrinter::PdfFormat);
+             printer->setOutputFormat(QPrinter::PdfFormat);
+             m_currentPrintDevice = QPrintDevice();
++            if (optionsPane)
++                optionsPane->selectPrinter(QPrinter::PdfFormat);
+             return;
+         }
+     }
+diff --git a/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp b/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
+index 39575d5f57..23b7e89538 100644
+--- a/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
++++ b/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
+@@ -352,7 +352,7 @@ void QPrintPreviewDialogPrivate::init(QPrinter *_printer)
+ static inline void qt_setupActionIcon(QAction *action, QLatin1String name)
+ {
+     QLatin1String imagePrefix(":/qt-project.org/dialogs/qprintpreviewdialog/images/");
+-    QIcon icon;
++    QIcon icon = QIcon::fromTheme(name);
+     icon.addFile(imagePrefix + name + QLatin1String("-24.png"), QSize(24, 24));
+     icon.addFile(imagePrefix + name + QLatin1String("-32.png"), QSize(32, 32));
+     action->setIcon(icon);
+@@ -383,8 +383,8 @@ void QPrintPreviewDialogPrivate::setupActions()
+     fitPageAction->setObjectName(QLatin1String("fitPageAction"));
+     fitWidthAction->setCheckable(true);
+     fitPageAction->setCheckable(true);
+-    qt_setupActionIcon(fitWidthAction, QLatin1String("fit-width"));
+-    qt_setupActionIcon(fitPageAction, QLatin1String("fit-page"));
++    qt_setupActionIcon(fitWidthAction, QLatin1String("zoom-fit-width"));
++    qt_setupActionIcon(fitPageAction, QLatin1String("zoom-fit-page"));
+     QObject::connect(fitGroup, SIGNAL(triggered(QAction*)), q, SLOT(_q_fit(QAction*)));
+ 
+     // Zoom
+@@ -410,9 +410,9 @@ void QPrintPreviewDialogPrivate::setupActions()
+     singleModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show single page"));
+     facingModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show facing pages"));
+     overviewModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show overview of all pages"));
+-    qt_setupActionIcon(singleModeAction, QLatin1String("view-page-one"));
+-    qt_setupActionIcon(facingModeAction, QLatin1String("view-page-sided"));
+-    qt_setupActionIcon(overviewModeAction, QLatin1String("view-page-multi"));
++    qt_setupActionIcon(singleModeAction, QLatin1String("view-pages-single"));
++    qt_setupActionIcon(facingModeAction, QLatin1String("view-pages-facing"));
++    qt_setupActionIcon(overviewModeAction, QLatin1String("view-pages-overview"));
+     singleModeAction->setObjectName(QLatin1String("singleModeAction"));
+     facingModeAction->setObjectName(QLatin1String("facingModeAction"));
+     overviewModeAction->setObjectName(QLatin1String("overviewModeAction"));
+@@ -426,7 +426,7 @@ void QPrintPreviewDialogPrivate::setupActions()
+     printerGroup = new QActionGroup(q);
+     printAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Print"));
+     pageSetupAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Page setup"));
+-    qt_setupActionIcon(printAction, QLatin1String("print"));
++    qt_setupActionIcon(printAction, QLatin1String("printer"));
+     qt_setupActionIcon(pageSetupAction, QLatin1String("page-setup"));
+     QObject::connect(printAction, SIGNAL(triggered(bool)), q, SLOT(_q_print()));
+     QObject::connect(pageSetupAction, SIGNAL(triggered(bool)), q, SLOT(_q_pageSetup()));
+diff --git a/qtbase/src/sql/kernel/qsqlquery.cpp b/qtbase/src/sql/kernel/qsqlquery.cpp
+index 32c6166c79..60afef10c3 100644
+--- a/qtbase/src/sql/kernel/qsqlquery.cpp
++++ b/qtbase/src/sql/kernel/qsqlquery.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2022 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtSql module of the Qt Toolkit.
+@@ -377,6 +377,10 @@ bool QSqlQuery::exec(const QString& query)
+     QElapsedTimer t;
+     t.start();
+ #endif
++    if (!driver()) {
++        qWarning("QSqlQuery::exec: called before driver has been set up");
++        return false;
++    }
+     if (d->ref.loadRelaxed() != 1) {
+         bool fo = isForwardOnly();
+         *this = QSqlQuery(driver()->createResult());
+diff --git a/qtbase/src/testlib/qabstractitemmodeltester.cpp b/qtbase/src/testlib/qabstractitemmodeltester.cpp
+index 8efb9c53d4..ce062f66d7 100644
+--- a/qtbase/src/testlib/qabstractitemmodeltester.cpp
++++ b/qtbase/src/testlib/qabstractitemmodeltester.cpp
+@@ -454,7 +454,7 @@ void QAbstractItemModelTesterPrivate::parent()
+ 
+     // Common error test #2, make sure that a second level index has a parent
+     // that is the first level index.
+-    if (model->rowCount(topIndex) > 0) {
++    if (model->rowCount(topIndex) > 0 && model->columnCount(topIndex) > 0) {
+         QModelIndex childIndex = model->index(0, 0, topIndex);
+         MODELTESTER_VERIFY(childIndex.isValid());
+         MODELTESTER_COMPARE(model->parent(childIndex), topIndex);
+diff --git a/qtbase/src/testlib/qasciikey.cpp b/qtbase/src/testlib/qasciikey.cpp
+index 9a308da2bc..93498b256f 100644
+--- a/qtbase/src/testlib/qasciikey.cpp
++++ b/qtbase/src/testlib/qasciikey.cpp
+@@ -498,6 +498,11 @@ char QTest::keyToAscii(Qt::Key key)
+     case Qt::Key_LaunchE : return 0; // = 0x10b0,
+     case Qt::Key_LaunchF : return 0; // = 0x10b1,
+ 
++    // Keypad navigation keys
++    case Qt::Key_Select : return 0; // = 0x01010000
++    case Qt::Key_Yes : return 0; // = 0x01010001
++    case Qt::Key_No : return 0; // = 0x01010002
++
+     default: QTEST_ASSERT(false); return 0;
+     }
+ }
+diff --git a/qtbase/src/testlib/qtestresult.cpp b/qtbase/src/testlib/qtestresult.cpp
+index 88028aac6e..2e89930776 100644
+--- a/qtbase/src/testlib/qtestresult.cpp
++++ b/qtbase/src/testlib/qtestresult.cpp
+@@ -251,7 +251,8 @@ bool QTestResult::verify(bool statement, const char *statementStr,
+ {
+     QTEST_ASSERT(statementStr);
+ 
+-    char msg[1024] = {'\0'};
++    char msg[1024];
++    msg[0] = '\0';
+ 
+     if (QTestLog::verboseLevel() >= 2) {
+         qsnprintf(msg, 1024, "QVERIFY(%s)", statementStr);
+@@ -309,7 +310,8 @@ static bool compareHelper(bool success, const char *failureMsg,
+                           bool hasValues = true)
+ {
+     const size_t maxMsgLen = 1024;
+-    char msg[maxMsgLen] = {'\0'};
++    char msg[maxMsgLen];
++    msg[0] = '\0';
+ 
+     QTEST_ASSERT(expected);
+     QTEST_ASSERT(actual);
+diff --git a/qtbase/src/widgets/dialogs/qcolordialog.cpp b/qtbase/src/widgets/dialogs/qcolordialog.cpp
+index 4247731275..cb325be85c 100644
+--- a/qtbase/src/widgets/dialogs/qcolordialog.cpp
++++ b/qtbase/src/widgets/dialogs/qcolordialog.cpp
+@@ -78,7 +78,10 @@
+ #include "qwindow.h"
+ 
+ #include "private/qdialog_p.h"
++#include "private/qguiapplication_p.h"
+ 
++#include <qpa/qplatformservices.h>
++#include <qpa/qplatformintegration.h>
+ #include <algorithm>
+ 
+ QT_BEGIN_NAMESPACE
+@@ -1611,6 +1614,20 @@ void QColorDialogPrivate::_q_newStandard(int r, int c)
+ void QColorDialogPrivate::_q_pickScreenColor()
+ {
+     Q_Q(QColorDialog);
++
++    auto *platformServices = QGuiApplicationPrivate::platformIntegration()->services();
++    if (platformServices->hasCapability(QPlatformServices::Capability::ColorPicking)) {
++        if (auto *colorPicker = platformServices->colorPicker(q->windowHandle())) {
++            q->connect(colorPicker, &QPlatformServiceColorPicker::colorPicked, q,
++                       [q, colorPicker](const QColor &color) {
++                           colorPicker->deleteLater();
++                           q->setCurrentColor(color);
++                       });
++            colorPicker->pickColor();
++            return;
++        }
++    }
++
+     if (!colorPickingEventFilter)
+         colorPickingEventFilter = new QColorPickingEventFilter(this, q);
+     q->installEventFilter(colorPickingEventFilter);
+diff --git a/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp b/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
+index e120817edc..8ea36b5427 100644
+--- a/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
++++ b/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
+@@ -400,12 +400,7 @@ bool QAbstractItemDelegate::helpEvent(QHelpEvent *event,
+         const QString tooltip = index.isValid() ?
+               d->textForRole(Qt::ToolTipRole, index.data(Qt::ToolTipRole), option.locale, precision) :
+               QString();
+-        QRect rect;
+-        if (index.isValid()) {
+-            const QRect r = view->visualRect(index);
+-            rect = QRect(view->mapToGlobal(r.topLeft()), r.size());
+-        }
+-        QToolTip::showText(he->globalPos(), tooltip, view, rect);
++        QToolTip::showText(he->globalPos(), tooltip, view->viewport(), option.rect);
+         event->setAccepted(!tooltip.isEmpty());
+         break;
+         }
+diff --git a/qtbase/src/widgets/itemviews/qlistview.cpp b/qtbase/src/widgets/itemviews/qlistview.cpp
+index 2b34476642..eebfaa030e 100644
+--- a/qtbase/src/widgets/itemviews/qlistview.cpp
++++ b/qtbase/src/widgets/itemviews/qlistview.cpp
+@@ -3386,6 +3386,7 @@ void QIconModeViewBase::updateContentsSize()
+ */
+ void QListView::currentChanged(const QModelIndex &current, const QModelIndex &previous)
+ {
++    QAbstractItemView::currentChanged(current, previous);
+ #ifndef QT_NO_ACCESSIBILITY
+     if (QAccessible::isActive()) {
+         if (current.isValid()) {
+@@ -3396,7 +3397,6 @@ void QListView::currentChanged(const QModelIndex &current, const QModelIndex &pr
+         }
+     }
+ #endif
+-    QAbstractItemView::currentChanged(current, previous);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/widgets/itemviews/qtableview.cpp b/qtbase/src/widgets/itemviews/qtableview.cpp
+index 934ac581b2..f79bb24249 100644
+--- a/qtbase/src/widgets/itemviews/qtableview.cpp
++++ b/qtbase/src/widgets/itemviews/qtableview.cpp
+@@ -1013,6 +1013,7 @@ void QTableViewPrivate::drawCell(QPainter *painter, const QStyleOptionViewItem &
+ int QTableViewPrivate::widthHintForIndex(const QModelIndex &index, int hint, const QStyleOptionViewItem &option) const
+ {
+     Q_Q(const QTableView);
++    const int oldHint = hint;
+     QWidget *editor = editorForIndex(index).widget.data();
+     if (editor && persistent.contains(editor)) {
+         hint = qMax(hint, editor->sizeHint().width());
+@@ -1021,6 +1022,17 @@ int QTableViewPrivate::widthHintForIndex(const QModelIndex &index, int hint, con
+         hint = qBound(min, hint, max);
+     }
+     hint = qMax(hint, q->itemDelegate(index)->sizeHint(option, index).width());
++
++    if (hasSpans()) {
++        auto span = spans.spanAt(index.column(), index.row());
++        if (span && span->m_left == index.column() && span->m_top == index.row()) {
++            // spans are screwed up when sections are moved
++            const auto left = logicalColumn(span->m_left);
++            for (int i = 1; i <= span->width(); ++i)
++               hint -= q->columnWidth(visualColumn(left + i));
++        }
++        hint = std::max(hint, oldHint);
++    }
+     return hint;
+ }
+ 
+@@ -1053,6 +1065,11 @@ int QTableViewPrivate::heightHintForIndex(const QModelIndex &index, int hint, QS
+         option.rect.setHeight(height);
+         option.rect.setX(q->columnViewportPosition(index.column()));
+         option.rect.setWidth(q->columnWidth(index.column()));
++        if (hasSpans()) {
++            auto span = spans.spanAt(index.column(), index.row());
++            if (span && span->m_left == index.column() && span->m_top == index.row())
++                option.rect.setWidth(std::max(option.rect.width(), visualSpanRect(*span).width()));
++        }
+         // 1px less space when grid is shown (see drawCell)
+         if (showGrid)
+             option.rect.setWidth(option.rect.width() - 1);
+diff --git a/qtbase/src/widgets/kernel/qaction.h b/qtbase/src/widgets/kernel/qaction.h
+index 258a1ea0a0..737c1e8285 100644
+--- a/qtbase/src/widgets/kernel/qaction.h
++++ b/qtbase/src/widgets/kernel/qaction.h
+@@ -81,7 +81,7 @@ class Q_WIDGETS_EXPORT QAction : public QObject
+     Q_PROPERTY(MenuRole menuRole READ menuRole WRITE setMenuRole NOTIFY changed)
+     Q_PROPERTY(bool iconVisibleInMenu READ isIconVisibleInMenu WRITE setIconVisibleInMenu NOTIFY changed)
+     Q_PROPERTY(bool shortcutVisibleInContextMenu READ isShortcutVisibleInContextMenu WRITE setShortcutVisibleInContextMenu NOTIFY changed)
+-    Q_PROPERTY(Priority priority READ priority WRITE setPriority)
++    Q_PROPERTY(Priority priority READ priority WRITE setPriority NOTIFY changed)
+ 
+ public:
+     // note this is copied into qplatformmenu.h, which must stay in sync
+diff --git a/qtbase/src/widgets/kernel/qwidget.cpp b/qtbase/src/widgets/kernel/qwidget.cpp
+index 9eba1e001e..26f6d27e18 100644
+--- a/qtbase/src/widgets/kernel/qwidget.cpp
++++ b/qtbase/src/widgets/kernel/qwidget.cpp
+@@ -5296,7 +5296,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
+         QWidgetEffectSourcePrivate *sourced = static_cast<QWidgetEffectSourcePrivate *>
+                                                          (source->d_func());
+         if (!sourced->context) {
+-            const QRegion effectRgn(rgn.boundingRect());
++            const QRegion effectRgn((flags & UseEffectRegionBounds) ? rgn.boundingRect() : rgn);
+             QWidgetPaintContext context(pdev, effectRgn, offset, flags, sharedPainter, repaintManager);
+             sourced->context = &context;
+             if (!sharedPainter) {
+@@ -5328,6 +5328,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
+         }
+     }
+ #endif // QT_CONFIG(graphicseffect)
++    flags = flags & ~UseEffectRegionBounds;
+ 
+     const bool alsoOnScreen = flags & DrawPaintOnScreen;
+     const bool recursive = flags & DrawRecursive;
+diff --git a/qtbase/src/widgets/kernel/qwidget_p.h b/qtbase/src/widgets/kernel/qwidget_p.h
+index eef6b8fa2c..c432f4b5d5 100644
+--- a/qtbase/src/widgets/kernel/qwidget_p.h
++++ b/qtbase/src/widgets/kernel/qwidget_p.h
+@@ -229,7 +229,8 @@ public:
+         DontSubtractOpaqueChildren = 0x10,
+         DontDrawOpaqueChildren = 0x20,
+         DontDrawNativeChildren = 0x40,
+-        DontSetCompositionMode = 0x80
++        DontSetCompositionMode = 0x80,
++        UseEffectRegionBounds = 0x100
+     };
+     Q_DECLARE_FLAGS(DrawWidgetFlags, DrawWidgetFlag)
+     Q_FLAG(DrawWidgetFlags)
+diff --git a/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp b/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
+index 02880b34da..0d44e1326d 100644
+--- a/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
++++ b/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
+@@ -1018,7 +1018,8 @@ void QWidgetRepaintManager::paintAndFlush()
+ 
+     // Paint the rest with composition.
+     if (repaintAllWidgets || !dirtyCopy.isEmpty()) {
+-        QWidgetPrivate::DrawWidgetFlags flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive;
++        QWidgetPrivate::DrawWidgetFlags flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive
++                | QWidgetPrivate::UseEffectRegionBounds;
+         tlw->d_func()->drawWidget(store->paintDevice(), dirtyCopy, QPoint(), flags, nullptr, this);
+     }
+ 
+diff --git a/qtbase/src/widgets/styles/qfusionstyle.cpp b/qtbase/src/widgets/styles/qfusionstyle.cpp
+index f4345d97c4..962912c838 100644
+--- a/qtbase/src/widgets/styles/qfusionstyle.cpp
++++ b/qtbase/src/widgets/styles/qfusionstyle.cpp
+@@ -1772,14 +1772,6 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio
+             proxy()->drawControl(CE_PushButtonLabel, &subopt, painter, widget);
+         }
+         break;
+-    case CE_PushButtonLabel:
+-        if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
+-            QStyleOptionButton b(*button);
+-            // no PM_ButtonShiftHorizontal and PM_ButtonShiftVertical for fusion style
+-            b.state &= ~(State_On | State_Sunken);
+-            QCommonStyle::drawControl(element, &b, painter, widget);
+-        }
+-        break;
+     case CE_MenuBarEmptyArea:
+         painter->save();
+     {
+diff --git a/qtbase/src/widgets/util/qcompleter.cpp b/qtbase/src/widgets/util/qcompleter.cpp
+index 18b24063d8..ef7207a8a3 100644
+--- a/qtbase/src/widgets/util/qcompleter.cpp
++++ b/qtbase/src/widgets/util/qcompleter.cpp
+@@ -1120,6 +1120,8 @@ void QCompleter::setModel(QAbstractItemModel *model)
+ {
+     Q_D(QCompleter);
+     QAbstractItemModel *oldModel = d->proxy->sourceModel();
++    if (oldModel == model)
++        return;
+ #if QT_CONFIG(filesystemmodel)
+     if (qobject_cast<const QFileSystemModel *>(oldModel))
+         setCompletionRole(Qt::EditRole); // QTBUG-54642, clear FileNameRole set by QFileSystemModel
+diff --git a/qtbase/src/widgets/widgets/qabstractbutton.cpp b/qtbase/src/widgets/widgets/qabstractbutton.cpp
+index a128b23950..dc40bf62fb 100644
+--- a/qtbase/src/widgets/widgets/qabstractbutton.cpp
++++ b/qtbase/src/widgets/widgets/qabstractbutton.cpp
+@@ -56,6 +56,7 @@
+ #ifndef QT_NO_ACCESSIBILITY
+ #include "qaccessible.h"
+ #endif
++#include <qpa/qplatformtheme.h>
+ 
+ #include <algorithm>
+ 
+@@ -1076,19 +1077,19 @@ void QAbstractButton::keyPressEvent(QKeyEvent *e)
+ {
+     Q_D(QAbstractButton);
+     bool next = true;
+-    switch (e->key()) {
+-    case Qt::Key_Enter:
+-    case Qt::Key_Return:
+-        e->ignore();
+-        break;
+-    case Qt::Key_Select:
+-    case Qt::Key_Space:
+-        if (!e->isAutoRepeat()) {
+-            setDown(true);
+-            repaint();
+-            d->emitPressed();
+-        }
+-        break;
++
++    const auto key = static_cast<Qt::Key>(e->key());
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(key) && !e->isAutoRepeat()) {
++        setDown(true);
++        repaint();
++        d->emitPressed();
++        return;
++    }
++
++    switch (key) {
+     case Qt::Key_Up:
+         next = false;
+         Q_FALLTHROUGH();
+@@ -1153,15 +1154,15 @@ void QAbstractButton::keyReleaseEvent(QKeyEvent *e)
+     if (!e->isAutoRepeat())
+         d->repeatTimer.stop();
+ 
+-    switch (e->key()) {
+-    case Qt::Key_Select:
+-    case Qt::Key_Space:
+-        if (!e->isAutoRepeat() && d->down)
+-            d->click();
+-        break;
+-    default:
+-        e->ignore();
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(static_cast<Qt::Key>(e->key())) && !e->isAutoRepeat() && d->down) {
++        d->click();
++        return;
+     }
++
++    e->ignore();
+ }
+ 
+ /*!\reimp
+diff --git a/qtbase/src/widgets/widgets/qcombobox.cpp b/qtbase/src/widgets/widgets/qcombobox.cpp
+index 7a496c27e0..0a3d96647b 100644
+--- a/qtbase/src/widgets/widgets/qcombobox.cpp
++++ b/qtbase/src/widgets/widgets/qcombobox.cpp
+@@ -3352,7 +3352,23 @@ void QComboBox::keyPressEvent(QKeyEvent *e)
+ 
+     Move move = NoMove;
+     int newIndex = currentIndex();
+-    switch (e->key()) {
++
++    bool pressLikeButton = !d->lineEdit;
++#ifdef QT_KEYPAD_NAVIGATION
++    pressLikeButton |= QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus();
++#endif
++    auto key = static_cast<Qt::Key>(e->key());
++    if (pressLikeButton) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(key)) {
++            showPopup();
++            return;
++        }
++    }
++
++    switch (key) {
+     case Qt::Key_Up:
+         if (e->modifiers() & Qt::ControlModifier)
+             break; // pass to line edit for auto completion
+@@ -3394,26 +3410,11 @@ void QComboBox::keyPressEvent(QKeyEvent *e)
+             return;
+         }
+         break;
+-    case Qt::Key_Space:
+-        if (!d->lineEdit) {
+-            showPopup();
+-            return;
+-        }
+-        break;
+-    case Qt::Key_Enter:
+-    case Qt::Key_Return:
+     case Qt::Key_Escape:
+         if (!d->lineEdit)
+             e->ignore();
+         break;
+ #ifdef QT_KEYPAD_NAVIGATION
+-    case Qt::Key_Select:
+-        if (QApplicationPrivate::keypadNavigationEnabled()
+-                && (!hasEditFocus() || !d->lineEdit)) {
+-            showPopup();
+-            return;
+-        }
+-        break;
+     case Qt::Key_Left:
+     case Qt::Key_Right:
+         if (QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus())
+diff --git a/qtbase/src/widgets/widgets/qdatetimeedit_p.h b/qtbase/src/widgets/widgets/qdatetimeedit_p.h
+index d36b6f8f9a..e0df5b5158 100644
+--- a/qtbase/src/widgets/widgets/qdatetimeedit_p.h
++++ b/qtbase/src/widgets/widgets/qdatetimeedit_p.h
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2018 The Qt Company Ltd.
++** Copyright (C) 2021 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtWidgets module of the Qt Toolkit.
+diff --git a/qtbase/src/widgets/widgets/qgroupbox.cpp b/qtbase/src/widgets/widgets/qgroupbox.cpp
+index 02a0bed325..3f3eccc370 100644
+--- a/qtbase/src/widgets/widgets/qgroupbox.cpp
++++ b/qtbase/src/widgets/widgets/qgroupbox.cpp
+@@ -54,6 +54,8 @@
+ #include "qaccessible.h"
+ #endif
+ #include <private/qwidget_p.h>
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
+ 
+ #include "qdebug.h"
+ 
+@@ -360,7 +362,10 @@ bool QGroupBox::event(QEvent *e)
+         return true;
+     case QEvent::KeyPress: {
+         QKeyEvent *k = static_cast<QKeyEvent*>(e);
+-        if (!k->isAutoRepeat() && (k->key() == Qt::Key_Select || k->key() == Qt::Key_Space)) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (!k->isAutoRepeat() && buttonPressKeys.contains(static_cast<Qt::Key>(k->key()))) {
+             d->pressedControl = QStyle::SC_GroupBoxCheckBox;
+             update(style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxCheckBox, this));
+             return true;
+@@ -369,7 +374,10 @@ bool QGroupBox::event(QEvent *e)
+     }
+     case QEvent::KeyRelease: {
+         QKeyEvent *k = static_cast<QKeyEvent*>(e);
+-        if (!k->isAutoRepeat() && (k->key() == Qt::Key_Select || k->key() == Qt::Key_Space)) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (!k->isAutoRepeat() && buttonPressKeys.contains(static_cast<Qt::Key>(k->key()))) {
+             bool toggle = (d->pressedControl == QStyle::SC_GroupBoxLabel
+                            || d->pressedControl == QStyle::SC_GroupBoxCheckBox);
+             d->pressedControl = QStyle::SC_None;
+diff --git a/qtbase/src/widgets/widgets/qlabel.cpp b/qtbase/src/widgets/widgets/qlabel.cpp
+index 30ff80cbb0..cf2605c17c 100644
+--- a/qtbase/src/widgets/widgets/qlabel.cpp
++++ b/qtbase/src/widgets/widgets/qlabel.cpp
+@@ -421,9 +421,6 @@ void QLabel::setPixmap(const QPixmap &pixmap)
+         d->pixmap = new QPixmap(pixmap);
+     }
+ 
+-    if (d->pixmap->depth() == 1 && !d->pixmap->mask())
+-        d->pixmap->setMask(*((QBitmap *)d->pixmap));
+-
+     d->updateLabel();
+ }
+ 
+diff --git a/qtbase/src/widgets/widgets/qtoolbararealayout.cpp b/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
+index 493c094cc1..d5f4b59017 100644
+--- a/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
++++ b/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
+@@ -1367,7 +1367,7 @@ bool QToolBarAreaLayout::restoreState(QDataStream &stream, const QList<QToolBar*
+                 item.widgetItem = new QWidgetItemV2(toolBar);
+                 toolBar->setOrientation(floating ? ((shown & 2) ? Qt::Vertical : Qt::Horizontal) : dock.o);
+                 toolBar->setVisible(shown & 1);
+-                toolBar->d_func()->setWindowState(floating, true, rect);
++                toolBar->d_func()->setWindowState(floating, false, rect);
+ 
+                 item.preferredSize = item.size;
+                 line.toolBarItems.append(item);
+diff --git a/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp b/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
+index 212c0a2e13..3c77b1ba0b 100644
+--- a/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
++++ b/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
+@@ -126,8 +126,7 @@ public:
+ 
+ void tst_QtConcurrentIterateKernel::instantiate()
+ {
+-    auto future = startThreadEngine(new PrintFor(0, 40)).startAsynchronously();
+-    future.waitForFinished();
++    startThreadEngine(new PrintFor(0, 40)).startBlocking();
+     QCOMPARE(iterations.loadRelaxed(), 40);
+ }
+ 
+@@ -166,10 +165,8 @@ void tst_QtConcurrentIterateKernel::stresstest()
+     const int times = 50;
+     for (int i = 0; i < times; ++i) {
+         counter.storeRelaxed(0);
+-        // ThreadEngine will delete f when it finishes
+-        auto f = new CountFor(0, iterations);
+-        auto future = f->startAsynchronously();
+-        future.waitForFinished();
++        CountFor f(0, iterations);
++        f.startBlocking();
+         QCOMPARE(counter.loadRelaxed(), iterations);
+     }
+ }
+@@ -177,11 +174,8 @@ void tst_QtConcurrentIterateKernel::stresstest()
+ void tst_QtConcurrentIterateKernel::noIterations()
+ {
+     const int times = 20000;
+-    for (int i = 0; i < times; ++i) {
+-        auto future = startThreadEngine(new IterateKernel<TestIterator, void>(0, 0))
+-                              .startAsynchronously();
+-        future.waitForFinished();
+-    }
++    for (int i = 0; i < times; ++i)
++        startThreadEngine(new IterateKernel<TestIterator, void>(0, 0)).startBlocking();
+ }
+ 
+ QMutex threadsMutex;
+@@ -236,10 +230,8 @@ void tst_QtConcurrentIterateKernel::throttling()
+ 
+     threads.clear();
+ 
+-    // ThreadEngine will delete f when it finishes
+-    auto f = new ThrottleFor(0, totalIterations);
+-    auto future = f->startAsynchronously();
+-    future.waitForFinished();
++    ThrottleFor f(0, totalIterations);
++    f.startBlocking();
+ 
+     QCOMPARE(iterations.loadRelaxed(), totalIterations);
+ 
+diff --git a/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp b/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
+index ac7be7acdd..81bc64c8d9 100644
+--- a/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
++++ b/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
+@@ -65,9 +65,16 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::runDirectly()
+ {
+-    PrintUser *engine = new PrintUser();
+-    QFuture<void> f = engine->startAsynchronously();
+-    f.waitForFinished();
++    {
++        PrintUser engine;
++        engine.startSingleThreaded();
++        engine.startBlocking();
++    }
++    {
++        PrintUser *engine = new PrintUser();
++        QFuture<void> f = engine->startAsynchronously();
++        f.waitForFinished();
++    }
+ }
+ 
+ class StringResultUser : public ThreadEngine<QString>
+@@ -99,10 +106,8 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::result()
+ {
+-    // ThreadEngine will delete 'engine' when it finishes
+-    auto engine = new StringResultUser();
+-    auto future = engine->startAsynchronously();
+-    QCOMPARE(future.result(), QString("Foo"));
++    StringResultUser engine;
++    QCOMPARE(*engine.startBlocking(), QString("Foo"));
+ }
+ 
+ class VoidResultUser : public ThreadEngine<void>
+@@ -128,9 +133,17 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::runThroughStarter()
+ {
+-    ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
+-    QFuture<QString> f = starter.startAsynchronously();
+-    QCOMPARE(f.result(), QString("Foo"));
++    {
++        ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
++        QFuture<QString>  f = starter.startAsynchronously();
++        QCOMPARE(f.result(), QString("Foo"));
++    }
++
++    {
++        ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
++        QString str = starter.startBlocking();
++        QCOMPARE(str, QString("Foo"));
++    }
+ }
+ 
+ class CancelUser : public ThreadEngine<void>
+@@ -213,6 +226,12 @@ void tst_QtConcurrentThreadEngine::throttle()
+         f.waitForFinished();
+         QCOMPARE(count.loadRelaxed(), 0);
+     }
++
++    for (int i = 0; i < repeats; ++i) {
++        ThrottleAlwaysUser t;
++        t.startBlocking();
++        QCOMPARE(count.loadRelaxed(), 0);
++    }
+ }
+ 
+ QSet<QThread *> threads;
+@@ -249,17 +268,35 @@ void tst_QtConcurrentThreadEngine::threadCount()
+ {
+     const int repeats = 10;
+     for (int i = 0; i < repeats; ++i) {
++        ThreadCountUser t;
++        t.startBlocking();
++        int count = threads.count();
++        int count_expected = QThreadPool::globalInstance()->maxThreadCount() + 1; // +1 for the main thread.
++        if (count != count_expected)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, count_expected);
++
+         (new ThreadCountUser())->startAsynchronously().waitForFinished();
+-        const auto count = threads.count();
+-        const auto maxThreadCount = QThreadPool::globalInstance()->maxThreadCount();
+-        QVERIFY(count <= maxThreadCount);
+-        QVERIFY(!threads.contains(QThread::currentThread()));
++        count = threads.count();
++        count_expected = QThreadPool::globalInstance()->maxThreadCount();
++        if (count != count_expected)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, count_expected);
+     }
+ 
+     // Set the finish flag immediately, this should give us one thread only.
+     for (int i = 0; i < repeats; ++i) {
++        ThreadCountUser t(true /*finishImmediately*/);
++        t.startBlocking();
++        int count = threads.count();
++        if (count != 1)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, 1);
++
+         (new ThreadCountUser(true /*finishImmediately*/))->startAsynchronously().waitForFinished();
+-        const auto count = threads.count();
++        count = threads.count();
++        if (count != 1)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
+         QCOMPARE(count, 1);
+         QVERIFY(!threads.contains(QThread::currentThread()));
+     }
+@@ -400,6 +437,7 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::exceptions()
+ {
++    // Asynchronous mode:
+     {
+         bool caught = false;
+         try  {
+@@ -412,6 +450,32 @@ void tst_QtConcurrentThreadEngine::exceptions()
+         QVERIFY2(caught, "did not get exception");
+     }
+ 
++    // Blocking mode:
++    // test throwing the exception from a worker thread.
++    {
++        bool caught = false;
++        try  {
++            QtConcurrentExceptionThrower e(QThread::currentThread());
++            e.startBlocking();
++        } catch (const QException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // test throwing the exception from the main thread (different code path)
++    {
++        bool caught = false;
++        try  {
++            QtConcurrentExceptionThrower e(0);
++            e.startBlocking();
++        } catch (const QException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // Asynchronous mode:
+     {
+         bool caught = false;
+         try  {
+@@ -423,6 +487,31 @@ void tst_QtConcurrentThreadEngine::exceptions()
+         }
+         QVERIFY2(caught, "did not get exception");
+     }
++
++    // Blocking mode:
++    // test throwing the exception from a worker thread.
++    {
++        bool caught = false;
++        try  {
++            UnrelatedExceptionThrower e(QThread::currentThread());
++            e.startBlocking();
++        } catch (const QUnhandledException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // test throwing the exception from the main thread (different code path)
++    {
++        bool caught = false;
++        try  {
++            UnrelatedExceptionThrower e(0);
++            e.startBlocking();
++        } catch (const QUnhandledException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
+ }
+ 
+ #endif
+diff --git a/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp b/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
+index 4968742110..f4c3fb711d 100644
+--- a/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
++++ b/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
+@@ -42,6 +42,7 @@ private slots:
+     void writeBlock_data();
+     void writeBlock();
+     void seek();
++    void invalidSeeks();
+     void seekTest_data();
+     void seekTest();
+     void read_rawdata();
+@@ -286,6 +287,29 @@ void tst_QBuffer::seek()
+     QCOMPARE(buffer.size(), pos);
+ }
+ 
++void tst_QBuffer::invalidSeeks()
++{
++    if constexpr (sizeof(qsizetype) == sizeof(qint64)) {
++        // sizeof(qsizetype) == sizeof(qint64), so +1 would overflow
++        QSKIP("This is a 32-bit-only test.");
++    } else {
++        QBuffer buffer;
++        buffer.open(QIODevice::WriteOnly);
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++        constexpr qint64 MaxQByteArrayCapacity = (std::numeric_limits<qsizetype>::max)();
++        // this should fail fast, not after trying to allocate nearly 2 GiB of data,
++        // potentially crashing in the process:
++        QVERIFY(!buffer.seek(2 * MaxQByteArrayCapacity - 1));
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++        // ditto:
++        QVERIFY(!buffer.seek(MaxQByteArrayCapacity + 1));
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++    }
++}
++
+ void tst_QBuffer::seekTest_data()
+ {
+     writeBlock_data();
+diff --git a/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp b/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
+index da5327594c..4a04e0f7c6 100644
+--- a/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
++++ b/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
+@@ -561,7 +561,8 @@ protected:
+     qint64 readData(char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf->size() - offset));
+-        memcpy(data, buf->constData() + offset, maxSize);
++        if (maxSize > 0)
++            memcpy(data, buf->constData() + offset, maxSize);
+         offset += maxSize;
+         return maxSize;
+     }
+@@ -604,13 +605,15 @@ protected:
+     qint64 readData(char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf.size() - pos()));
+-        memcpy(data, buf.constData() + pos(), maxSize);
++        if (maxSize > 0)
++            memcpy(data, buf.constData() + pos(), maxSize);
+         return maxSize;
+     }
+     qint64 writeData(const char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf.size() - pos()));
+-        memcpy(buf.data() + pos(), data, maxSize);
++        if (maxSize > 0)
++            memcpy(buf.data() + pos(), data, maxSize);
+         return maxSize;
+     }
+ 
+diff --git a/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+index db60bead64..f345a44414 100644
+--- a/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
++++ b/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+@@ -1,7 +1,8 @@
+ /****************************************************************************
+ **
+ ** Copyright (C) 2021 The Qt Company Ltd.
+-** Copyright (C) 2020 Intel Corporation.
++** Copyright (C) 2020 The Qt Company Ltd.
++** Copyright (C) 2022 Intel Corporation.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the test suite of the Qt Toolkit.
+@@ -150,6 +151,8 @@ private slots:
+     void startStopStartStopBuffers();
+     void processEventsInAReadyReadSlot_data();
+     void processEventsInAReadyReadSlot();
++    void startFromCurrentWorkingDir_data();
++    void startFromCurrentWorkingDir();
+ 
+     // keep these at the end, since they use lots of processes and sometimes
+     // caused obscure failures to occur in tests that followed them (esp. on the Mac)
+@@ -2731,5 +2734,94 @@ void tst_QProcess::finishProcessBeforeReadingDone_deprecated()
+ 
+ #endif
+ 
++enum class ChdirMode {
++    None = 0,
++    InParent,
++    InChild
++};
++Q_DECLARE_METATYPE(ChdirMode)
++
++void tst_QProcess::startFromCurrentWorkingDir_data()
++{
++    qRegisterMetaType<ChdirMode>();
++    QTest::addColumn<QString>("programPrefix");
++    QTest::addColumn<ChdirMode>("chdirMode");
++    QTest::addColumn<bool>("success");
++
++    constexpr bool IsWindows = true
++#ifdef Q_OS_UNIX
++            && false
++#endif
++            ;
++
++    // baseline: trying to execute the directory, this can't possibly succeed!
++    QTest::newRow("plain-same-cwd") << QString() << ChdirMode::None << false;
++
++    // cross-platform behavior: neither OS searches the setWorkingDirectory()
++    // dir without "./"
++    QTest::newRow("plain-child-chdir") << QString() << ChdirMode::InChild << false;
++
++    // cross-platform behavior: both OSes search the parent's CWD with "./"
++    QTest::newRow("prefixed-parent-chdir") << "./" << ChdirMode::InParent << true;
++
++    // opposite behaviors: Windows searches the parent's CWD and Unix searches
++    // the child's with "./"
++    QTest::newRow("prefixed-child-chdir") << "./" << ChdirMode::InChild << !IsWindows;
++
++    // Windows searches the parent's CWD without "./"
++    QTest::newRow("plain-parent-chdir") << QString() << ChdirMode::InParent << IsWindows;
++}
++
++void tst_QProcess::startFromCurrentWorkingDir()
++{
++    QFETCH(QString, programPrefix);
++    QFETCH(ChdirMode, chdirMode);
++    QFETCH(bool, success);
++
++    QProcess process;
++    qRegisterMetaType<QProcess::ProcessError>();
++    QSignalSpy errorSpy(&process, &QProcess::errorOccurred);
++    QVERIFY(errorSpy.isValid());
++
++    // both the dir name and the executable name
++    const QString target = QStringLiteral("testProcessNormal");
++    process.setProgram(programPrefix + target);
++
++#ifdef Q_OS_UNIX
++    // Reset PATH, to be sure it doesn't contain . or the empty path.
++    // We can't do this on Windows because DLLs are searched in PATH
++    // and Windows always searches "." anyway.
++    auto restoreEnv = qScopeGuard([old = qgetenv("PATH")] {
++        qputenv("PATH", old);
++    });
++    qputenv("PATH", "/");
++#endif
++
++    switch (chdirMode) {
++    case ChdirMode::InParent: {
++        auto restoreCwd = qScopeGuard([old = QDir::currentPath()] {
++            QDir::setCurrent(old);
++        });
++        QVERIFY(QDir::setCurrent(target));
++        process.start();
++        break;
++    }
++    case ChdirMode::InChild:
++        process.setWorkingDirectory(target);
++        Q_FALLTHROUGH();
++    case ChdirMode::None:
++        process.start();
++        break;
++    }
++
++    QCOMPARE(process.waitForStarted(), success);
++    QCOMPARE(errorSpy.count(), int(!success));
++    if (success) {
++        QVERIFY(process.waitForFinished());
++    } else {
++        QCOMPARE(process.error(), QProcess::FailedToStart);
++    }
++}
++
+ QTEST_MAIN(tst_QProcess)
+ #include "tst_qprocess.moc"
+diff --git a/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp b/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp
+index e1ea7a4552..90972caa57 100644
+--- a/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp
++++ b/qtbase/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"
+diff --git a/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+index 9bd66c0835..ed4a0bae5d 100644
+--- a/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
++++ b/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+@@ -158,6 +158,7 @@ private slots:
+     void nullReceiver();
+     void functorReferencesConnection();
+     void disconnectDisconnects();
++    void declarativeData();
+ };
+ 
+ struct QObjectCreatedOnShutdown
+@@ -7679,5 +7680,81 @@ void tst_QObject::disconnectDisconnects()
+ Q_STATIC_ASSERT(QtPrivate::HasQ_OBJECT_Macro<tst_QObject>::Value);
+ Q_STATIC_ASSERT(!QtPrivate::HasQ_OBJECT_Macro<SiblingDeleter>::Value);
+ 
++#ifdef QT_BUILD_INTERNAL
++/*
++    Since QObjectPrivate stores the declarativeData pointer in a union with the pointer
++    to the currently destroyed child, calls to the QtDeclarative handlers need to be
++    correctly guarded. QTBUG-105286
++*/
++namespace QtDeclarative {
++static QAbstractDeclarativeData *theData;
++
++static void destroyed(QAbstractDeclarativeData *data, QObject *)
++{
++    QCOMPARE(data, theData);
++}
++static void signalEmitted(QAbstractDeclarativeData *data, QObject *, int, void **)
++{
++    QCOMPARE(data, theData);
++}
++// we can't use QCOMPARE in the next two functions, as they don't return void
++static int receivers(QAbstractDeclarativeData *data, const QObject *, int)
++{
++    QTest::qCompare(data, theData, "data", "theData", __FILE__, __LINE__);
++    return 0;
++}
++static bool isSignalConnected(QAbstractDeclarativeData *data, const QObject *, int)
++{
++    QTest::qCompare(data, theData, "data", "theData", __FILE__, __LINE__);
++    return true;
++}
++
++class Object : public QObject
++{
++    Q_OBJECT
++public:
++    using QObject::QObject;
++    ~Object()
++    {
++        if (Object *p = static_cast<Object *>(parent()))
++            p->emitSignal();
++    }
++
++    void emitSignal()
++    {
++        emit theSignal();
++    }
++
++signals:
++    void theSignal();
++};
++
++}
++#endif
++
++void tst_QObject::declarativeData()
++{
++#ifdef QT_BUILD_INTERNAL
++    QScopedValueRollback destroyed(QAbstractDeclarativeData::destroyed,
++                                   QtDeclarative::destroyed);
++    QScopedValueRollback signalEmitted(QAbstractDeclarativeData::signalEmitted,
++                                       QtDeclarative::signalEmitted);
++    QScopedValueRollback receivers(QAbstractDeclarativeData::receivers,
++                                   QtDeclarative::receivers);
++    QScopedValueRollback isSignalConnected(QAbstractDeclarativeData::isSignalConnected,
++                                           QtDeclarative::isSignalConnected);
++
++    QtDeclarative::Object p;
++    QObjectPrivate *priv = QObjectPrivate::get(&p);
++    priv->declarativeData = QtDeclarative::theData = new QAbstractDeclarativeData;
++
++    connect(&p, &QtDeclarative::Object::theSignal, &p, []{
++    });
++
++    QtDeclarative::Object *child = new QtDeclarative::Object;
++    child->setParent(&p);
++#endif
++}
++
+ QTEST_MAIN(tst_QObject)
+ #include "tst_qobject.moc"
+diff --git a/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp b/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
+index 0ea422ecbc..1a3256534b 100644
+--- a/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
++++ b/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
+@@ -70,15 +70,15 @@ static inline QString testSuiteWarning()
+ 
+     QString result;
+     QTextStream str(&result);
+-    str << "\nCannot find the shared-mime-info test suite\nstarting from: "
++    str << "\nCannot find the shared-mime-info test suite\nin the parent of: "
+         << QDir::toNativeSeparators(QDir::currentPath()) << "\n"
+            "cd " << QDir::toNativeSeparators(QStringLiteral("tests/auto/corelib/mimetypes/qmimedatabase")) << "\n"
+-           "wget http://cgit.freedesktop.org/xdg/shared-mime-info/snapshot/Release-1-10.zip\n"
+-           "unzip Release-1-10.zip\n";
++           "wget https://gitlab.freedesktop.org/xdg/shared-mime-info/-/archive/2.1/shared-mime-info-2.1.zip\n"
++           "unzip shared-mime-info-2.1.zip\n";
+ #ifdef Q_OS_WIN
+-    str << "mkdir testfiles\nxcopy /s Release-1-10 s-m-i\n";
++    str << "mkdir testfiles\nxcopy /s shared-mime-info-2.1 s-m-i\n";
+ #else
+-    str << "ln -s Release-1-10 s-m-i\n";
++    str << "ln -s shared-mime-info-2.1 s-m-i\n";
+ #endif
+     return result;
+ }
+@@ -154,7 +154,7 @@ void tst_QMimeDatabase::initTestCase()
+     QVERIFY2(copyResourceFile(xmlFileName, xmlTargetFileName, &errorMessage), qPrintable(errorMessage));
+ #endif
+ 
+-    m_testSuite = QFINDTESTDATA("s-m-i/tests");
++    m_testSuite = QFINDTESTDATA("s-m-i/tests/mime-detection");
+     if (m_testSuite.isEmpty())
+         qWarning("%s", qPrintable(testSuiteWarning()));
+ 
+@@ -611,7 +611,7 @@ void tst_QMimeDatabase::allMimeTypes()
+     QVERIFY(!lst.isEmpty());
+ 
+     // Hardcoding this is the only way to check both providers find the same number of mimetypes.
+-    QCOMPARE(lst.count(), 779);
++    QCOMPARE(lst.count(), 811);
+ 
+     foreach (const QMimeType &mime, lst) {
+         const QString name = mime.name();
+@@ -631,10 +631,9 @@ void tst_QMimeDatabase::suffixes_data()
+ 
+     QTest::newRow("mimetype with a single pattern") << "application/pdf" << "*.pdf" << "pdf";
+     QTest::newRow("mimetype with multiple patterns") << "application/x-kpresenter" << "*.kpr;*.kpt" << "kpr";
+-    QTest::newRow("jpeg") << "image/jpeg" << "*.jpe;*.jpg;*.jpeg" << "jpeg";
+-    //if (KMimeType::sharedMimeInfoVersion() > KDE_MAKE_VERSION(0, 60, 0)) {
+-        QTest::newRow("mimetype with many patterns") << "application/vnd.wordperfect" << "*.wp;*.wp4;*.wp5;*.wp6;*.wpd;*.wpp" << "wp";
+-    //}
++    // The preferred suffix for image/jpeg is *.jpg, as per https://bugs.kde.org/show_bug.cgi?id=176737
++    QTest::newRow("jpeg") << "image/jpeg" << "*.jpe;*.jpg;*.jpeg" << "jpg";
++    QTest::newRow("mimetype with many patterns") << "application/vnd.wordperfect" << "*.wp;*.wp4;*.wp5;*.wp6;*.wpd;*.wpp" << "wp";
+     QTest::newRow("oasis text mimetype") << "application/vnd.oasis.opendocument.text" << "*.odt" << "odt";
+     QTest::newRow("oasis presentation mimetype") << "application/vnd.oasis.opendocument.presentation" << "*.odp" << "odp";
+     QTest::newRow("mimetype with multiple patterns") << "text/plain" << "*.asc;*.txt;*,v" << "txt";
+diff --git a/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp b/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
+index 3e58dd03cc..c8f82ef5d5 100644
+--- a/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
++++ b/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
+@@ -176,6 +176,8 @@ private Q_SLOTS:
+     void fromToVariantConversions_data();
+     void fromToVariantConversions();
+ 
++    void noLeakOnNameClash();
++
+ private:
+     QString testDataDir;
+ };
+@@ -3685,5 +3687,23 @@ void tst_QtJson::fromToVariantConversions()
+     }
+ }
+ 
++void tst_QtJson::noLeakOnNameClash()
++{
++    QJsonDocument doc = QJsonDocument::fromJson("{\"\":{\"\":0},\"\":0}");
++    QVERIFY(!doc.isNull());
++    const QJsonObject obj = doc.object();
++
++    // Removed the duplicate key.
++    QCOMPARE(obj.length(), 1);
++
++    // Retained the last of the duplicates.
++    const QJsonValue val = obj.begin().value();
++    QVERIFY(val.isDouble());
++    QCOMPARE(val.toDouble(), 0.0);
++
++    // It should not leak.
++    // In particular it should not forget to deref the container for the inner object.
++}
++
+ QTEST_MAIN(tst_QtJson)
+ #include "tst_qtjson.moc"
+diff --git a/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp b/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
+index a59b58d57f..241c3e84ac 100644
+--- a/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
++++ b/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
+@@ -63,6 +63,7 @@ private slots:
+     void isValidId_data();
+     void isValidId();
+     void malformed();
++    void serialize();
+     // Backend tests
+     void utcTest();
+     void icuTest();
+@@ -947,6 +948,33 @@ void tst_QTimeZone::malformed()
+         barf.offsetFromUtc(now);
+ }
+ 
++void tst_QTimeZone::serialize()
++{
++    int parts = 0;
++#ifndef QT_NO_DEBUG_STREAM
++    qDebug() << QTimeZone(); // to verify no crash
++    parts++;
++#endif
++#ifndef QT_NO_DATASTREAM
++    QByteArray blob;
++    {
++        QDataStream stream(&blob, QIODevice::WriteOnly);
++        stream << QTimeZone("Europe/Oslo") << QTimeZone(420) << QTimeZone() << qint64(-1);
++    }
++    QDataStream stream(&blob, QIODevice::ReadOnly);
++    QTimeZone invalid, offset, oslo;
++    qint64 minusone;
++    stream >> oslo >> offset >> invalid >> minusone;
++    QCOMPARE(oslo, QTimeZone("Europe/Oslo"));
++    QCOMPARE(offset, QTimeZone(420));
++    QVERIFY(!invalid.isValid());
++    QCOMPARE(minusone, qint64(-1));
++    parts++;
++#endif
++    if (!parts)
++        QSKIP("No serialization enabled");
++}
++
+ void tst_QTimeZone::utcTest()
+ {
+ #ifdef QT_BUILD_INTERNAL
+diff --git a/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp b/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
+index 05480c6dd2..70f4c75756 100644
+--- a/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
++++ b/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
+@@ -324,6 +324,13 @@ void tst_QDBusInterface::notValid()
+ 
+     QVERIFY(!interface.isValid());
+     QVERIFY(!QMetaObject::invokeMethod(&interface, "ListNames", Qt::DirectConnection));
++
++    // With a connection, but empty/null service and path specified
++    QDBusConnection con = QDBusConnection::sessionBus();
++    QVERIFY(con.isConnected());
++    QDBusInterface iface({}, {}, {}, con);
++    QVERIFY(!iface.isValid());
++    QVERIFY(!QMetaObject::invokeMethod(&interface, "ListNames", Qt::DirectConnection));
+ }
+ 
+ void tst_QDBusInterface::notValidDerived()
+diff --git a/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp b/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
+index 874468c954..04ceb4ab65 100644
+--- a/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
++++ b/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
+@@ -507,6 +507,10 @@ void tst_QKeySequence::toStringFromKeycode_data()
+     QTest::newRow("Ctrl+Alt+Num+Del") << QKeySequence(Qt::ControlModifier | Qt::AltModifier | Qt::KeypadModifier | Qt::Key_Delete) << "Ctrl+Alt+Num+Del";
+     QTest::newRow("Ctrl+Ins") << QKeySequence(Qt::ControlModifier | Qt::Key_Insert) << "Ctrl+Ins";
+     QTest::newRow("Ctrl+Num+Ins(1)") << QKeySequence(Qt::Key_Insert | Qt::KeypadModifier | Qt::ControlModifier) << "Ctrl+Num+Ins";
++    QTest::newRow("Ctrl") << QKeySequence(Qt::Key_Control) << "Control";
++    QTest::newRow("Alt") << QKeySequence(Qt::Key_Alt) << "Alt";
++    QTest::newRow("Shift") << QKeySequence(Qt::Key_Shift) << "Shift";
++    QTest::newRow("Meta") << QKeySequence(Qt::Key_Meta) << "Meta";
+ }
+ 
+ void tst_QKeySequence::toStringFromKeycode()
+diff --git a/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp b/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+index 15e0ecadaa..b4eca74283 100644
+--- a/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
++++ b/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+@@ -81,6 +81,8 @@ private slots:
+     void registerOpenTypePreferredNamesSystem();
+     void registerOpenTypePreferredNamesApplication();
+ 
++    void stretchRespected();
++
+ private:
+     QString m_ledFont;
+     QString m_testFont;
+@@ -355,6 +357,28 @@ static QString testString()
+     return QStringLiteral("foo bar");
+ }
+ 
++void tst_QFontDatabase::stretchRespected()
++{
++    int italicId = QFontDatabase::addApplicationFont(m_testFontItalic);
++    QVERIFY(italicId != -1);
++
++    QVERIFY(!QFontDatabase::applicationFontFamilies(italicId).isEmpty());
++
++    QString italicFontName = QFontDatabase::applicationFontFamilies(italicId).first();
++
++    QFont italicFont = QFontDatabase().font(italicFontName,
++                                            QString::fromLatin1("Italic"), 14);
++    QVERIFY(italicFont.italic());
++
++    QFont italicStretchedFont = italicFont;
++    italicStretchedFont.setStretch( 400 );
++
++    QVERIFY(QFontMetricsF(italicFont).horizontalAdvance(QStringLiteral("foobar")) <
++            QFontMetricsF(italicStretchedFont).horizontalAdvance(QStringLiteral("foobar")));
++
++    QFontDatabase::removeApplicationFont(italicId);
++}
++
+ void tst_QFontDatabase::condensedFontWidthNoFontMerging()
+ {
+     int regularFontId = QFontDatabase::addApplicationFont(m_testFont);
+diff --git a/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+index 3d4a094c43..b423e11a99 100644
+--- a/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
++++ b/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+@@ -281,6 +281,7 @@ private Q_SLOTS:
+     void ioGetFromFileSpecial();
+     void ioGetFromFile_data();
+     void ioGetFromFile();
++    void ioGetFromFileUrl();
+     void ioGetFromFtp_data();
+     void ioGetFromFtp();
+     void ioGetFromFtpWithReuse();
+@@ -3300,6 +3301,18 @@ void tst_QNetworkReply::ioGetFromFile()
+     QCOMPARE(reader.data, data);
+ }
+ 
++void tst_QNetworkReply::ioGetFromFileUrl()
++{
++    // This immediately fails on non-windows platforms:
++    QNetworkRequest request(QUrl("file://unc-server/some/path"));
++    QNetworkReplyPtr reply(manager.get(request));
++    QSignalSpy finishedSpy(reply.get(), &QNetworkReply::finished);
++    // QTBUG-105618: This would, on non-Windows platforms, never happen because the signal
++    // was emitted before the constructor finished, leaving no chance at all to connect to the
++    // signal
++    QVERIFY(finishedSpy.wait());
++}
++
+ void tst_QNetworkReply::ioGetFromFtp_data()
+ {
+     QTest::addColumn<QString>("fileName");
+diff --git a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
+index 069fa6b341..4cc4d9a5ea 100644
+--- a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
++++ b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
+@@ -1,75 +1,34 @@
+-Certificate:
+-    Data:
+-        Version: 3 (0x2)
+-        Serial Number: 0 (0x0)
+-        Signature Algorithm: sha1WithRSAEncryption
+-        Issuer: C=NO, ST=Oslo, L=Nydalen, O=Nokia Corporation and/or its subsidiary(-ies), OU=Development, CN=fluke.troll.no/emailAddress=ahanssen@trolltech.com
+-        Validity
+-            Not Before: Dec  4 01:10:32 2007 GMT
+-            Not After : Apr 21 01:10:32 2035 GMT
+-        Subject: C=NO, ST=Oslo, O=Nokia Corporation and/or its subsidiary(-ies), OU=Development, CN=fluke.troll.no
+-        Subject Public Key Info:
+-            Public Key Algorithm: rsaEncryption
+-            RSA Public Key: (1024 bit)
+-                Modulus (1024 bit):
+-                    00:a7:c8:a0:4a:c4:19:05:1b:66:ba:32:e2:d2:f1:
+-                    1c:6f:17:82:e4:39:2e:01:51:90:db:04:34:32:11:
+-                    21:c2:0d:6f:59:d8:53:90:54:3f:83:8f:a9:d3:b3:
+-                    d5:ee:1a:9b:80:ae:c3:25:c9:5e:a5:af:4b:60:05:
+-                    aa:a0:d1:91:01:1f:ca:04:83:e3:58:1c:99:32:45:
+-                    84:70:72:58:03:98:4a:63:8b:41:f5:08:49:d2:91:
+-                    02:60:6b:e4:64:fe:dd:a0:aa:74:08:e9:34:4c:91:
+-                    5f:12:3d:37:4d:54:2c:ad:7f:5b:98:60:36:02:8c:
+-                    3b:f6:45:f3:27:6a:9b:94:9d
+-                Exponent: 65537 (0x10001)
+-        X509v3 extensions:
+-            X509v3 Basic Constraints: 
+-                CA:FALSE
+-            Netscape Comment: 
+-                OpenSSL Generated Certificate
+-            X509v3 Subject Key Identifier: 
+-                21:85:04:3D:23:01:66:E5:F7:9F:1A:84:24:8A:AF:0A:79:F4:E5:AC
+-            X509v3 Authority Key Identifier: 
+-                DirName:/C=NO/ST=Oslo/L=Nydalen/O=Nokia Corporation and/or its subsidiary(-ies)/OU=Development/CN=fluke.troll.no/emailAddress=ahanssen@trolltech.com
+-                serial:8E:A8:B4:E8:91:B7:54:2E
+-
+-    Signature Algorithm: sha1WithRSAEncryption
+-        6d:57:5f:d1:05:43:f0:62:05:ec:2a:71:a5:dc:19:08:f2:c4:
+-        a6:bd:bb:25:d9:ca:89:01:0e:e4:cf:1f:c1:8c:c8:24:18:35:
+-        53:59:7b:c0:43:b4:32:e6:98:b2:a6:ef:15:05:0b:48:5f:e1:
+-        a0:0c:97:a9:a1:77:d8:35:18:30:bc:a9:8f:d3:b7:54:c7:f1:
+-        a9:9e:5d:e6:19:bf:f6:3c:5b:2b:d8:e4:3e:62:18:88:8b:d3:
+-        24:e1:40:9b:0c:e6:29:16:62:ab:ea:05:24:70:36:aa:55:93:
+-        ef:02:81:1b:23:10:a2:04:eb:56:95:75:fc:f8:94:b1:5d:42:
+-        c5:3f:36:44:85:5d:3a:2e:90:46:8a:a2:b9:6f:87:ae:0c:15:
+-        40:19:31:90:fc:3b:25:bb:ae:f1:66:13:0d:85:90:d9:49:34:
+-        8f:f2:5d:f9:7a:db:4d:5d:27:f6:76:9d:35:8c:06:a6:4c:a3:
+-        b1:b2:b6:6f:1d:d7:a3:00:fd:72:eb:9e:ea:44:a1:af:21:34:
+-        7d:c7:42:e2:49:91:19:8b:c0:ad:ba:82:80:a8:71:70:f4:35:
+-        31:91:63:84:20:95:e9:60:af:64:8b:cc:ff:3d:8a:76:74:3d:
+-        c8:55:6d:e4:8e:c3:2b:1c:e8:42:18:ae:9f:e6:6b:9c:34:06:
+-        ec:6a:f2:c3
+ -----BEGIN CERTIFICATE-----
+-MIIEEzCCAvugAwIBAgIBADANBgkqhkiG9w0BAQUFADCBnDELMAkGA1UEBhMCTk8x
+-DTALBgNVBAgTBE9zbG8xEDAOBgNVBAcTB055ZGFsZW4xFjAUBgNVBAoTDVRyb2xs
+-dGVjaCBBU0ExFDASBgNVBAsTC0RldmVsb3BtZW50MRcwFQYDVQQDEw5mbHVrZS50
+-cm9sbC5ubzElMCMGCSqGSIb3DQEJARYWYWhhbnNzZW5AdHJvbGx0ZWNoLmNvbTAe
+-Fw0wNzEyMDQwMTEwMzJaFw0zNTA0MjEwMTEwMzJaMGMxCzAJBgNVBAYTAk5PMQ0w
+-CwYDVQQIEwRPc2xvMRYwFAYDVQQKEw1Ucm9sbHRlY2ggQVNBMRQwEgYDVQQLEwtE
+-ZXZlbG9wbWVudDEXMBUGA1UEAxMOZmx1a2UudHJvbGwubm8wgZ8wDQYJKoZIhvcN
+-AQEBBQADgY0AMIGJAoGBAKfIoErEGQUbZroy4tLxHG8XguQ5LgFRkNsENDIRIcIN
+-b1nYU5BUP4OPqdOz1e4am4CuwyXJXqWvS2AFqqDRkQEfygSD41gcmTJFhHByWAOY
+-SmOLQfUISdKRAmBr5GT+3aCqdAjpNEyRXxI9N01ULK1/W5hgNgKMO/ZF8ydqm5Sd
+-AgMBAAGjggEaMIIBFjAJBgNVHRMEAjAAMCwGCWCGSAGG+EIBDQQfFh1PcGVuU1NM
+-IEdlbmVyYXRlZCBDZXJ0aWZpY2F0ZTAdBgNVHQ4EFgQUIYUEPSMBZuX3nxqEJIqv
+-Cnn05awwgbsGA1UdIwSBszCBsKGBoqSBnzCBnDELMAkGA1UEBhMCTk8xDTALBgNV
+-BAgTBE9zbG8xEDAOBgNVBAcTB055ZGFsZW4xFjAUBgNVBAoTDVRyb2xsdGVjaCBB
+-U0ExFDASBgNVBAsTC0RldmVsb3BtZW50MRcwFQYDVQQDEw5mbHVrZS50cm9sbC5u
+-bzElMCMGCSqGSIb3DQEJARYWYWhhbnNzZW5AdHJvbGx0ZWNoLmNvbYIJAI6otOiR
+-t1QuMA0GCSqGSIb3DQEBBQUAA4IBAQBtV1/RBUPwYgXsKnGl3BkI8sSmvbsl2cqJ
+-AQ7kzx/BjMgkGDVTWXvAQ7Qy5piypu8VBQtIX+GgDJepoXfYNRgwvKmP07dUx/Gp
+-nl3mGb/2PFsr2OQ+YhiIi9Mk4UCbDOYpFmKr6gUkcDaqVZPvAoEbIxCiBOtWlXX8
+-+JSxXULFPzZEhV06LpBGiqK5b4euDBVAGTGQ/Dslu67xZhMNhZDZSTSP8l35ettN
+-XSf2dp01jAamTKOxsrZvHdejAP1y657qRKGvITR9x0LiSZEZi8CtuoKAqHFw9DUx
+-kWOEIJXpYK9ki8z/PYp2dD3IVW3kjsMrHOhCGK6f5mucNAbsavLD
++MIIF6zCCA9OgAwIBAgIUfo9amJtJGWqWE6f+SkAO85zkGr4wDQYJKoZIhvcNAQEL
++BQAwgYMxCzAJBgNVBAYTAk5PMQ0wCwYDVQQIDARPc2xvMQ0wCwYDVQQHDARPc2xv
++MRcwFQYDVQQKDA5UaGUgUXQgQ29tcGFueTEMMAoGA1UECwwDUiZEMRIwEAYDVQQD
++DAlIMiBUZXN0ZXIxGzAZBgkqhkiG9w0BCQEWDG1pbmltaUBxdC5pbzAgFw0yMDEw
++MjYxMjAxMzFaGA8yMTIwMTAwMjEyMDEzMVowgYMxCzAJBgNVBAYTAk5PMQ0wCwYD
++VQQIDARPc2xvMQ0wCwYDVQQHDARPc2xvMRcwFQYDVQQKDA5UaGUgUXQgQ29tcGFu
++eTEMMAoGA1UECwwDUiZEMRIwEAYDVQQDDAlIMiBUZXN0ZXIxGzAZBgkqhkiG9w0B
++CQEWDG1pbmltaUBxdC5pbzCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIB
++AOiUp5+E4blouKH7q+rVNR8NoYX2XkBW+q+rpy1zu5ssRSzbqxAjDx9dkht7Qlnf
++VlDT00JvpOWdeuPon5915edQRsY4Unl6mKH29ra3OtUa1/yCJXsGVJTKCj7k4Bxb
++5mZzb/fTlZntMLdTIBMfUbw62FKir1WjKIcJ9fCoG8JaGeKVO4Rh5p0ezd4UUUId
++r1BXl5Nqdqy2vTMsEDnjOsD3egkv8I2SKN4O6n/C3wWYpMOWYZkGoZiKz7rJs/i/
++ez7bsV7JlwdzTlhpJzkcOSVFBP6JlEOxTNNxZ1wtKy7PtZGmsSSATq2e6+bw38Ae
++Op0XnzzqcGjtDDofBmT7OFzZWjS9VZS6+DOOe2QHWle1nCHcHyH4ku6IRlsr9xkR
++NAIlOfnvHHxqJUenoeaZ4oQDjCBKS1KXygJO/tL7BLTQVn/xK1EmPvKNnjzWk4tR
++PnibUhhs5635qpOU/YPqFBh1JjVruZbsWcDAhRcew0uxONXOa9E+4lttQ9ySYa1A
++LvWqJuAX7gu2BsBMLyqfm811YnA7CIFMyO+HlqmkLFfv5L/xIRAXR7l26YGO0VwX
++CGjMfz4NVPMMke4nB7qa9NkpXQBQKMms3Qzd5JW0Hy9Ruj5O8GPcFZmV0twjd1uJ
++PD/cAjkWLaXjdNsJ16QWc2nghQRS6HYqKRX6j+CXOxupAgMBAAGjUzBRMB0GA1Ud
++DgQWBBRSCOU58j9NJZkMamt623qyCrhN3TAfBgNVHSMEGDAWgBRSCOU58j9NJZkM
++amt623qyCrhN3TAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4ICAQCq
++q4jxsWeNDv5Nq14hJtF9HB+ZL64zcZtRjJP1YgNs0QppKICmjPOL2nIMGmI/jKrs
++0eGAL/9XXNVHPxm1OPOncvimMMmU6emZfpMdEtTfKP43+Pg9HgKRjLoQp406vGeQ
++8ki/mbBhrItVPgEm3tu2AFA02XTYi+YxCI9kRZLGkM3FbgtOuTLPl0Z9y+kiPc9F
++uCSC03anBEqv+vDSI8+wODymQ/IJ3Jyz1lxIRDfp4qAekmy0jU2c91VOHHEmOmqq
++kqygGFRdwbe99m9yP63r6q0b5K3X2UnJ6bns0hmTwThYwpVPXLU8jdaTddbMukN2
++/Ef96Tsw8nWOEOPMySHOTIPgwyZRp26b0kA9EmhLwOP401SxXVQCmSRmtwNagmtg
++jJKmZoYBN+//D45ibK8z6Q0oOm9P+Whf/uUXehcRxBxyV3xz7k0wKGQbHj/ddwcy
++IUoIN4lrAlib+lK170kTKN352PDmrpo2gmIzPEsfurKAIMSelDl6H+kih16BtZ8y
++Nz6fh9Soqrg3OSAware8pxV7k51crBMoPLN78KoRV8MFCK4K7Fddq4rRISq6hiXq
++r1nsjoEPuKM9huprmZVZe9t5YcDa2I+wb3IiE3uwpZbAdaLDyQ5n6F/qpsiIkZXn
++gtcF7oqpG5oYrwCcZ53y/ezUgUg7PlSz2XwAGvQtgg==
+ -----END CERTIFICATE-----
+diff --git a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
+index 9d1664d609..337ce541a6 100644
+--- a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
++++ b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
+@@ -1,15 +1,52 @@
+------BEGIN RSA PRIVATE KEY-----
+-MIICXAIBAAKBgQCnyKBKxBkFG2a6MuLS8RxvF4LkOS4BUZDbBDQyESHCDW9Z2FOQ
+-VD+Dj6nTs9XuGpuArsMlyV6lr0tgBaqg0ZEBH8oEg+NYHJkyRYRwclgDmEpji0H1
+-CEnSkQJga+Rk/t2gqnQI6TRMkV8SPTdNVCytf1uYYDYCjDv2RfMnapuUnQIDAQAB
+-AoGANFzLkanTeSGNFM0uttBipFT9F4a00dqHz6JnO7zXAT26I5r8sU1pqQBb6uLz
+-/+Qz5Zwk8RUAQcsMRgJetuPQUb0JZjF6Duv24hNazqXBCu7AZzUenjafwmKC/8ri
+-KpX3fTwqzfzi//FKGgbXQ80yykSSliDL3kn/drATxsLCgQECQQDXhEFWLJ0vVZ1s
+-1Ekf+3NITE+DR16X+LQ4W6vyEHAjTbaNWtcTKdAWLA2l6N4WAAPYSi6awm+zMxx4
+-VomVTsjdAkEAx0z+e7natLeFcrrq8pbU+wa6SAP1VfhQWKitxL1e7u/QO90NCpxE
+-oQYKzMkmmpOOFjQwEMAy1dvFMbm4LHlewQJAC/ksDBaUcQHHqjktCtrUb8rVjAyW
+-A8lscckeB2fEYyG5J6dJVaY4ClNOOs5yMDS2Afk1F6H/xKvtQ/5CzInA/QJATDub
+-K+BPU8jO9q+gpuIi3VIZdupssVGmCgObVCHLakG4uO04y9IyPhV9lA9tALtoIf4c
+-VIvv5fWGXBrZ48kZAQJBAJmVCdzQxd9LZI5vxijUCj5EI4e+x5DRqVUvyP8KCZrC
+-AiNyoDP85T+hBZaSXK3aYGpVwelyj3bvo1GrTNwNWLw=
+------END RSA PRIVATE KEY-----
++-----BEGIN PRIVATE KEY-----
++MIIJQgIBADANBgkqhkiG9w0BAQEFAASCCSwwggkoAgEAAoICAQDolKefhOG5aLih
+++6vq1TUfDaGF9l5AVvqvq6ctc7ubLEUs26sQIw8fXZIbe0JZ31ZQ09NCb6TlnXrj
++6J+fdeXnUEbGOFJ5epih9va2tzrVGtf8giV7BlSUygo+5OAcW+Zmc2/305WZ7TC3
++UyATH1G8OthSoq9VoyiHCfXwqBvCWhnilTuEYeadHs3eFFFCHa9QV5eTanastr0z
++LBA54zrA93oJL/CNkijeDup/wt8FmKTDlmGZBqGYis+6ybP4v3s+27FeyZcHc05Y
++aSc5HDklRQT+iZRDsUzTcWdcLSsuz7WRprEkgE6tnuvm8N/AHjqdF5886nBo7Qw6
++HwZk+zhc2Vo0vVWUuvgzjntkB1pXtZwh3B8h+JLuiEZbK/cZETQCJTn57xx8aiVH
++p6HmmeKEA4wgSktSl8oCTv7S+wS00FZ/8StRJj7yjZ481pOLUT54m1IYbOet+aqT
++lP2D6hQYdSY1a7mW7FnAwIUXHsNLsTjVzmvRPuJbbUPckmGtQC71qibgF+4LtgbA
++TC8qn5vNdWJwOwiBTMjvh5appCxX7+S/8SEQF0e5dumBjtFcFwhozH8+DVTzDJHu
++Jwe6mvTZKV0AUCjJrN0M3eSVtB8vUbo+TvBj3BWZldLcI3dbiTw/3AI5Fi2l43Tb
++CdekFnNp4IUEUuh2KikV+o/glzsbqQIDAQABAoICAFw1q6tr5I48vY7DF+rXsuLn
++5ZUWE1IQ6fzB4lr72nJv/9EEGnMgYzt9PpMUsD6vdCpBgS2C0+6RHArFzJtNA+RM
++iHLIG7K7702veyr/xBx/MwiSlMeMv/XpkFxVI6E6skMGG2s3AMXxKvJTy5CpRx+I
++eQFyLG+Ya1X2lgJes/q+/CpAHkOjCOpcLySQC5NZ74q734V7nSdmn+Zs3tYEh+O/
++eiuwTP/j5b38Te5vVTqDxTciJPmljmXLCwa0N100lWlbcpvw8qbqiTI2Jm3XCbUE
++AzHjW9vmrF3cRS1fXxKFGShw3SRqlkbxjfeWoi8qDPUBS4m8LOr8qG9Wo5Nfon0z
++zLP4bci3zHDvVcaaZrrsUBs/yZbg+Dgka1DmX7ekmeccr2yTdKDFgPupYUyxVbTl
++a9ZLJysjFD7rgBv1ZclHonLp6Vbm+ZoTqvteo4ikAy6L9RtBWJ23XEK34PkP/+c5
++2vWZaOrnjSeBHbFce8cdJSxqWpP+eSCI5I9XbDrYFIsQ/gqKgtzDKy2ihJ2Y8STL
++yO4hyFPFjxc+Gg4/P2PpmT5CY2ty44M0BWs+JGW96CJPrrplf2lmQUQJj5LZY66X
++Z/4C9L7ZYtKZ+bs5SvU46yWugAvQZX22Xm9xLXWyVXRdx3bj+3M3fDnF9di/zdbh
++CgLx7oWPNrXc7FCajnn9AoIBAQD5FMYwRpw9NWT9WDxQwx+cSI4Icbd88ByTW63S
++LzeRwZA0J9/SfwO+aBRupzc9GkGXCiZcGMw3AGsCtig8yFlw8E5KnzN7KlftDMnM
++9NUxxzlR8VwKyLnZfG7sDTl057ZlUujnqhmt/F8F7dIy7FVO1dE/8nngA+FYTCOG
++UZdGjwyBDlDM0JJdUWGY3xslutcpCDN5mzSTKjy9drMvImAshRawxRF6WBpn7vr2
++nC6vciqfx1Mzx1vyk0Jm0ilaydDdLMADjt/iL4Nkr0BEs4k+UzQiKDwp8gu7abQ1
++eBfxd9Iar4htQa2I1Ewl6P01G/q+ZYwgHhJ9RVn4AxQXefILAoIBAQDvCouORdQX
++C8wsyp7MwXlF/3NQeNN5/+B2mhbxrBOf7PmMCXLnkRWcjwJtzypWFqJ0sqai/2+0
++bqbMcjX5maT8stT2shl3zXe/Ejt2e3TBYpc1tyuses8Kb5BMU8hu6tTd3G2CMXpD
++dT6DVemJZCTtwj9aBNIxSizvlgMolJnCpzhPnlfHSI6E+g3m/LTTo3HwbjMSw/Uq
++irgjOpI2wSBB6LZPSgjvfcYPRyWUk16L4A5uSX0cADnovDFLa5/h0wJvN/OoCSQg
++rLCXG5E18EyL5Wc58BCY1ZvxmjG3lQtgPxYu2Jwc36R/y/JKlxW5suER5ZNpbbD4
++uOyTt2VxMQ2bAoIBAQC5+MzRFqdo/AjfL5Y5JrbfVTzXCTDa09xCGd16ZU60QTWN
+++4ed/r+o1sUKqUcRFB2MzEM/2DQBjQpZB/CbEWvWa1XJWXxypXbowveZU+QqOnmN
++uQvj8WLyA3o+PNF9e9QvauwCrHpn8VpxbtPWuaYoKnUFreFZZQxHhPGxRBIS2JOZ
++eDrT8ZaWnkCkh1AZp5smQ71LOprSlmKrg4jd1GjCVMxQR5N5KXbtyv0OTCZ/UFqK
++2aRBsMPyJgkaBChkZPLRcKwc+/wlQRx1fHQb14DNTApMxoXFO7eOwqmOkpAt9iyl
++SBIwoS0UUI5ab88+bBmXNvKcuFdNuQ4nowTJUn9pAoIBADMNkILBXSvS5DeIyuO2
++Sp1tkoZUV+5NfPY3sMDK3KIibaW/+t+EOBZo4L7tKQCb8vRzl21mmsfxfgRaPDbj
++3r3tv9g0b4YLxxBy52pFscj/soXRai17SS7UZwA2QK+XzgDYbDcLNC6mIsTQG4Gx
++dsWk3/zs3KuUSQaehmwrWK+fIUK38c1pLK8v7LoxrLkqxlHwZ04RthHw8KTthH7X
++Pnl1J0LF8CSeOyfWLSuPUfkT0GEzptnNHpEbaHfQM6R6eaGhVJPF6AZme4y6YYgg
++m2ihhSt1n0XVEWpHYWjxFy3mK2mz75unFC4LM+NEY2p2zuUQoCw7NjnY3QYrfCnx
++rRMCggEAXeXsMSLFjjyuoL7iKbAxo52HD/P0fBoy58LyRcwfNVr0lvYan4pYEx+o
++KijIh9K16PqXZXKMA9v003B+ulmF8bJ7SddCZ5NGvnFhUTDe4DdTKgp2RuwQ3Bsc
++3skPIDbhVETyOLCtys34USHrq8U/0DlGY3eLRfxw9GnbKxSBGa/KEu/qQLPNUo50
++7xHZDg7GKeC3kqNJeqKM9rkp0VzIGkEnaD9127LeNDmERDfftxJzFoC/THvUBLfU
++6Sus2ZYwRE8VFvKC30Q45t/c54X3IuhYvAuiCuTmyfE4ruyzyOwKzhUkeeLq1APX
++g0veFbyfzlJ0q8qzD/iffqqIa2ZSmQ==
++-----END PRIVATE KEY-----
+diff --git a/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp b/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
+index 7ba3715e13..752aa122f6 100644
+--- a/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
++++ b/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
+@@ -179,6 +179,7 @@ void tst_QAccessibilityLinux::initTestCase()
+     QVERIFY(!address.isEmpty());
+ 
+     m_window = new AccessibleTestWindow();
++    m_window->setObjectName("mainWindow"_L1);
+     m_window->show();
+ 
+     QVERIFY(QTest::qWaitForWindowExposed(m_window));
+@@ -236,8 +237,11 @@ bool hasState(QDBusInterface *interface, AtspiStateType state)
+ void tst_QAccessibilityLinux::testLabel()
+ {
+     QLabel *l = new QLabel(m_window);
++    l->setObjectName("theObjectName"_L1);
+     l->setText("Hello A11y");
+     m_window->addWidget(l);
++    auto a11yEmpty = new QLabel(m_window);
++    m_window->addWidget(l);
+ 
+     // Application
+     QCOMPARE(getParent(mainWindow), QLatin1String(ATSPI_DBUS_PATH_ROOT));
+@@ -249,6 +253,8 @@ void tst_QAccessibilityLinux::testLabel()
+     QCOMPARE(getChildren(labelInterface).count(), 0);
+     QCOMPARE(labelInterface->call(QDBus::Block, "GetRoleName").arguments().first().toString(), QLatin1String("label"));
+     QCOMPARE(labelInterface->call(QDBus::Block, "GetRole").arguments().first().toUInt(), 29u);
++    QCOMPARE(labelInterface->call(QDBus::Block, "GetAccessibleId").arguments().first().toString(),
++             QLatin1String("mainWindow.theObjectName"));
+     QCOMPARE(getParent(labelInterface), mainWindow->path());
+     QVERIFY(!hasState(labelInterface, ATSPI_STATE_EDITABLE));
+     QVERIFY(hasState(labelInterface, ATSPI_STATE_READ_ONLY));
+@@ -256,7 +262,12 @@ void tst_QAccessibilityLinux::testLabel()
+     l->setText("New text");
+     QCOMPARE(labelInterface->property("Name").toString(), l->text());
+ 
++    auto *a11yEmptyInterface = getInterface(children.at(1), "org.a11y.atspi.Accessible");
++    QCOMPARE(a11yEmptyInterface->call(QDBus::Block, "GetAccessibleId").arguments().first().toString(),
++             QLatin1String("mainWindow.QLabel"));
++
+     m_window->clearChildren();
++    delete a11yEmptyInterface;
+     delete labelInterface;
+ }
+ 
+diff --git a/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+index 76df61c892..6d6d65b791 100644
+--- a/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
++++ b/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2022 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the test suite of the Qt Toolkit.
+@@ -68,6 +68,8 @@ private slots:
+     void query_exec();
+     void execErrorRecovery_data() { generic_data(); }
+     void execErrorRecovery();
++    void prematureExec_data() { generic_data(); }
++    void prematureExec();
+     void first_data() { generic_data(); }
+     void first();
+     void next_data() { generic_data(); }
+@@ -2770,6 +2772,35 @@ void tst_QSqlQuery::execErrorRecovery()
+     QVERIFY_SQL( q, exec() );
+ }
+ 
++void tst_QSqlQuery::prematureExec()
++{
++    QFETCH(QString, dbName);
++    // We only want the engine name, for addDatabase():
++    int cut = dbName.indexOf(QChar('@'));
++    if (cut < 0)
++        QSKIP("Failed to parse database type out of name");
++    dbName.truncate(cut);
++    cut = dbName.indexOf(QChar('_'));
++    if (cut >= 0)
++        dbName = dbName.mid(cut + 1);
++
++    auto db = QSqlDatabase::addDatabase(dbName);
++    QSqlQuery q(db);
++
++    QTest::ignoreMessage(QtWarningMsg,
++                         "QSqlDatabasePrivate::removeDatabase: connection "
++                         "'qt_sql_default_connection' is still in use, all "
++                         "queries will cease to work.");
++    QTest::ignoreMessage(QtWarningMsg,
++                         "QSqlDatabasePrivate::addDatabase: duplicate connection name "
++                         "'qt_sql_default_connection', old connection removed.");
++    auto otherDb = QSqlDatabase::addDatabase(dbName);
++
++    QTest::ignoreMessage(QtWarningMsg, "QSqlQuery::exec: called before driver has been set up");
++    // QTBUG-100037: shouldn't crash !
++    QVERIFY(!q.exec("select stuff from TheVoid"));
++}
++
+ void tst_QSqlQuery::lastInsertId()
+ {
+     QFETCH( QString, dbName );
+diff --git a/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp b/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
+index 4aa3f8d60b..d2050a61aa 100644
+--- a/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
++++ b/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
+@@ -115,6 +115,10 @@ void tst_QAbstractItemModelTester::standardItemModelZeroColumns()
+     // QTBUG-92886
+     model.insertRows(0, 5);
+     model.removeRows(1, 2);
++
++    const QModelIndex parentIndex = model.index(0, 0);
++    model.insertRows(0, 5, parentIndex);
++    model.removeRows(1, 2, parentIndex);
+ }
+ 
+ void tst_QAbstractItemModelTester::testInsertThroughProxy()
+diff --git a/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json b/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
+index 12a4a22a19..ce518e78fb 100644
+--- a/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
++++ b/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
+@@ -668,50 +668,6 @@
+         "inputFile": "task192552.h",
+         "outputRevision": 67
+     },
+-    {
+-        "classes": [
+-            {
+-                "className": "InlineSlotsWithThrowDeclaration",
+-                "object": true,
+-                "qualifiedClassName": "InlineSlotsWithThrowDeclaration",
+-                "slots": [
+-                    {
+-                        "access": "public",
+-                        "name": "a",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "b",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "c",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "d",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "e",
+-                        "returnType": "void"
+-                    }
+-                ],
+-                "superClasses": [
+-                    {
+-                        "access": "public",
+-                        "name": "QObject"
+-                    }
+-                ]
+-            }
+-        ],
+-        "inputFile": "task189996.h",
+-        "outputRevision": 67
+-    },
+     {
+         "classes": [
+             {
+diff --git a/qtbase/tests/auto/tools/moc/moc.pro b/qtbase/tests/auto/tools/moc/moc.pro
+index c324b3a8cd..4aceb78dc0 100644
+--- a/qtbase/tests/auto/tools/moc/moc.pro
++++ b/qtbase/tests/auto/tools/moc/moc.pro
+@@ -15,7 +15,7 @@ cross_compile: DEFINES += MOC_CROSS_COMPILED
+ HEADERS += using-namespaces.h no-keywords.h task87883.h c-comments.h backslash-newlines.h oldstyle-casts.h \
+            slots-with-void-template.h qinvokable.h namespaced-flags.h trigraphs.h \
+            escapes-in-string-literals.h cstyle-enums.h qprivateslots.h gadgetwithnoenums.h \
+-           dir-in-include-path.h single_function_keyword.h task192552.h task189996.h \
++           dir-in-include-path.h single_function_keyword.h task192552.h \
+            task234909.h task240368.h pure-virtual-signals.h cxx11-enums.h \
+            cxx11-final-classes.h \
+            cxx11-explicit-override-control.h \
+diff --git a/qtbase/tests/auto/tools/moc/task189996.h b/qtbase/tests/auto/tools/moc/task189996.h
+deleted file mode 100644
+index f94a051b3a..0000000000
+--- a/qtbase/tests/auto/tools/moc/task189996.h
++++ /dev/null
+@@ -1,47 +0,0 @@
+-/****************************************************************************
+-**
+-** Copyright (C) 2016 The Qt Company Ltd.
+-** Contact: https://www.qt.io/licensing/
+-**
+-** This file is part of the test suite of the Qt Toolkit.
+-**
+-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+-** 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 General Public License Usage
+-** Alternatively, this file may be used under the terms of the GNU
+-** General Public License version 3 as published by the Free Software
+-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+-** 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-3.0.html.
+-**
+-** $QT_END_LICENSE$
+-**
+-****************************************************************************/
+-// inline functions can have throw declarations
+-
+-#ifndef TASK189996_H
+-#define TASK189996_H
+-
+-#include <QObject>
+-
+-class InlineSlotsWithThrowDeclaration : public QObject
+-{
+-    Q_OBJECT
+-
+-public slots:
+-    void a() throw() { }
+-    void b() const throw() { }
+-    void c() throw();
+-    void d() throw(int) { }
+-    void e() const throw(int,double) { }
+-};
+-
+-#endif
+diff --git a/qtbase/tests/auto/tools/moc/tst_moc.cpp b/qtbase/tests/auto/tools/moc/tst_moc.cpp
+index c716aead21..15dd9e41e5 100644
+--- a/qtbase/tests/auto/tools/moc/tst_moc.cpp
++++ b/qtbase/tests/auto/tools/moc/tst_moc.cpp
+@@ -631,7 +631,6 @@ public:
+ private slots:
+     void initTestCase();
+ 
+-    void slotWithException() throw(MyStruct);
+     void dontStripNamespaces();
+     void oldStyleCasts();
+     void warnOnExtraSignalSlotQualifiaction();
+@@ -673,7 +672,6 @@ private slots:
+     void templateGtGt();
+     void qprivateslots();
+     void qprivateproperties();
+-    void inlineSlotsWithThrowDeclaration();
+     void warnOnPropertyWithoutREAD();
+     void constructors();
+     void typenameWithUnsigned();
+@@ -784,12 +782,6 @@ void tst_Moc::initTestCase()
+ #endif
+ }
+ 
+-void tst_Moc::slotWithException() throw(MyStruct)
+-{
+-    // be happy
+-    QVERIFY(true);
+-}
+-
+ void tst_Moc::dontStripNamespaces()
+ {
+     Sender sender;
+@@ -824,7 +816,7 @@ void tst_Moc::oldStyleCasts()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-Wold-style-cast" << "-I" << "."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -894,7 +886,7 @@ void tst_Moc::inputFileNameWithDotsButNoExtension()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-I" << ".."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -1174,7 +1166,7 @@ void tst_Moc::ignoreOptionClashes()
+     QStringList gccArgs;
+     gccArgs << "-c" << "-x" << "c++" << "-I" << ".."
+          << "-I" << qtIncludePath << "-I" << includeDir << "-o" << "/dev/null"
+-         << "-fPIC" << "-std=c++11" <<  "-";
++         << "-fPIC" << "-std=c++1z" <<  "-";
+     proc.start("gcc", gccArgs);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -1593,21 +1585,6 @@ void tst_Moc::qprivateproperties()
+ 
+ }
+ 
+-#include "task189996.h"
+-
+-void InlineSlotsWithThrowDeclaration::c() throw() {}
+-
+-void tst_Moc::inlineSlotsWithThrowDeclaration()
+-{
+-    InlineSlotsWithThrowDeclaration tst;
+-    const QMetaObject *mobj = tst.metaObject();
+-    QVERIFY(mobj->indexOfSlot("a()") != -1);
+-    QVERIFY(mobj->indexOfSlot("b()") != -1);
+-    QVERIFY(mobj->indexOfSlot("c()") != -1);
+-    QVERIFY(mobj->indexOfSlot("d()") != -1);
+-    QVERIFY(mobj->indexOfSlot("e()") != -1);
+-}
+-
+ void tst_Moc::warnOnPropertyWithoutREAD()
+ {
+ #ifdef MOC_CROSS_COMPILED
+@@ -1869,7 +1846,7 @@ void tst_Moc::notifyError()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-I" << "."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+diff --git a/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+index c355ee9665..88c09de8e0 100644
+--- a/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
++++ b/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+@@ -251,6 +251,7 @@ private slots:
+     void testResetCachedSizeHint();
+     void statusTips();
+     void testRemovingColumnsViaLayoutChanged();
++    void testModelMovingColumns();
+ 
+ protected:
+     void setupTestData(bool use_reset_model = false);
+@@ -360,6 +361,12 @@ public:
+         endRemoveColumns();
+     }
+ 
++    void moveColumn(int from, int to)
++    {
++        beginMoveColumns(QModelIndex(), from, from, QModelIndex(), to);
++        endMoveColumns();
++    }
++
+     void cleanup()
+     {
+         emit layoutAboutToBeChanged();
+@@ -3627,5 +3634,18 @@ void tst_QHeaderView::testRemovingColumnsViaLayoutChanged()
+     // The main point of this test is that the section-size restoring code didn't go out of bounds.
+ }
+ 
++void tst_QHeaderView::testModelMovingColumns()
++{
++    QtTestModel model(10, 10);
++    QHeaderView hv(Qt::Horizontal);
++    hv.setModel(&model);
++    hv.resizeSections(QHeaderView::ResizeToContents);
++    hv.show();
++
++    QPersistentModelIndex index3 = model.index(0, 3);
++    model.moveColumn(3, 1);
++    QCOMPARE(index3.column(), 1);
++}
++
+ QTEST_MAIN(tst_QHeaderView)
+ #include "tst_qheaderview.moc"
+diff --git a/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+index 761357b252..06bb706074 100644
+--- a/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
++++ b/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+@@ -397,6 +397,7 @@ private slots:
+     void checkHeaderMinSize();
+ 
+     void resizeToContents();
++    void resizeToContentsSpans();
+ 
+     void tabFocus();
+     void bigModel();
+@@ -3721,6 +3722,70 @@ void tst_QTableView::resizeToContents()
+ 
+ }
+ 
++
++class SpanModel : public QAbstractTableModel
++{
++public:
++    SpanModel(bool sectionsMoved)
++        : _sectionsMoved(sectionsMoved)
++    {}
++    int columnCount(const QModelIndex & = {}) const override { return 2; }
++    int rowCount(const QModelIndex & = {}) const override { return 1; }
++    QVariant data(const QModelIndex &idx, int role = Qt::DisplayRole) const override
++    {
++        if (role != Qt::DisplayRole)
++            return QVariant();
++        const int col = _sectionsMoved ? 1 - idx.column() : idx.column();
++        if (col == 0)
++            return "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.";
++        return QVariant();
++    }
++private:
++    bool _sectionsMoved;
++};
++
++
++void tst_QTableView::resizeToContentsSpans()
++{
++    SpanModel model1(false);
++    SpanModel model2(true);
++    QTableView view1, view2, view3;
++    view1.setModel(&model1);
++    view2.setModel(&model2);
++    view2.horizontalHeader()->moveSection(0, 1);
++    view3.setModel(&model1);
++
++    view1.setSpan(0, 0, 1, 2);
++    view2.setSpan(0, 1, 1, 2);
++    view1.show();
++    view2.show();
++    view3.show();
++    QVERIFY(QTest::qWaitForWindowExposed(&view1));
++    QVERIFY(QTest::qWaitForWindowExposed(&view2));
++    QVERIFY(QTest::qWaitForWindowExposed(&view3));
++    view1.setColumnWidth(0, 100);
++    view1.setColumnWidth(1, 100);
++    view2.setColumnWidth(0, 100);
++    view2.setColumnWidth(1, 100);
++    view3.setColumnWidth(0, 200);
++
++    view1.resizeRowToContents(0);
++    view2.resizeRowToContents(0);
++    view3.resizeRowToContents(0);
++    QCOMPARE(view1.rowHeight(0), view3.rowHeight(0));
++    QCOMPARE(view2.rowHeight(0), view3.rowHeight(0));
++
++    view3.resizeColumnToContents(0);
++    view3.resizeRowToContents(0);
++    // height should be only 1 text line for easy testing
++    view1.setRowHeight(0, view3.verticalHeader()->sectionSize(0));
++    view2.setRowHeight(0, view3.verticalHeader()->sectionSize(0));
++    view1.resizeColumnToContents(0);
++    view2.resizeColumnToContents(1);
++    QCOMPARE(view1.columnWidth(0), view3.columnWidth(0) - view1.columnWidth(1));
++    QCOMPARE(view2.columnWidth(0), view3.columnWidth(0) - view2.columnWidth(1));
++}
++
+ QT_BEGIN_NAMESPACE
+ extern bool Q_WIDGETS_EXPORT qt_tab_all_widgets(); // qapplication.cpp
+ QT_END_NAMESPACE
+diff --git a/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+index a3b8ef78d8..4955cebd5d 100644
+--- a/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
++++ b/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+@@ -1498,7 +1498,7 @@ void tst_QApplication::desktopSettingsAware()
+     environment += QLatin1String("QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM=1");
+     testProcess.setEnvironment(environment);
+ #endif
+-    testProcess.start("desktopsettingsaware_helper");
++    testProcess.start("./desktopsettingsaware_helper");
+     QVERIFY2(testProcess.waitForStarted(),
+              qPrintable(QString::fromLatin1("Cannot start 'desktopsettingsaware_helper': %1").arg(testProcess.errorString())));
+     QVERIFY(testProcess.waitForFinished(10000));
+@@ -2452,7 +2452,7 @@ void tst_QApplication::qtbug_12673()
+ #if QT_CONFIG(process)
+     QProcess testProcess;
+     QStringList arguments;
+-    testProcess.start("modal_helper", arguments);
++    testProcess.start("./modal_helper", arguments);
+     QVERIFY2(testProcess.waitForStarted(),
+              qPrintable(QString::fromLatin1("Cannot start 'modal_helper': %1").arg(testProcess.errorString())));
+     QVERIFY(testProcess.waitForFinished(20000));
+diff --git a/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp b/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
+index eb108a40de..dca5528c1b 100644
+--- a/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
+@@ -41,6 +41,7 @@
+ 
+ #include <private/qguiapplication_p.h>
+ #include <qpa/qplatformintegration.h>
++#include <qpa/qplatformtheme.h>
+ 
+ class tst_QAbstractButton : public QObject
+ {
+@@ -76,6 +77,8 @@ private slots:
+     void keyNavigation();
+ #endif
+ 
++    void buttonPressKeys();
++
+ protected slots:
+     void onClicked();
+     void onToggled( bool on );
+@@ -269,7 +272,13 @@ void tst_QAbstractButton::setAutoRepeat()
+         QCOMPARE(press_count, click_count);
+         QVERIFY(click_count > 1);
+         break;
+-    case 4:
++    case 4: {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(Qt::Key_Enter)) {
++            QSKIP("platform theme has Key_Enter in ButtonPressKeys");
++        }
+         // check that pressing ENTER has no effect when autorepeat is false
+         testWidget->setDown( false );
+         testWidget->setAutoRepeat( false );
+@@ -286,7 +295,14 @@ void tst_QAbstractButton::setAutoRepeat()
+ 
+         QVERIFY( click_count == 0 );
+         break;
+-    case 5:
++    }
++    case 5: {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(Qt::Key_Enter)) {
++            QSKIP("platform theme has Key_Enter in ButtonPressKeys");
++        }
+         // check that pressing ENTER has no effect when autorepeat is true
+         testWidget->setDown( false );
+         testWidget->setAutoRepeat( true );
+@@ -304,6 +320,7 @@ void tst_QAbstractButton::setAutoRepeat()
+ 
+         QVERIFY( click_count == 0 );
+         break;
++    }
+     case 6:
+         // verify autorepeat is off by default.
+         MyButton tmp( 0);
+@@ -651,5 +668,16 @@ void tst_QAbstractButton::keyNavigation()
+ }
+ #endif
+ 
++void tst_QAbstractButton::buttonPressKeys()
++{
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(testWidget, buttonPressKeys[i]);
++        QCOMPARE(click_count, i + 1);
++    }
++}
++
+ QTEST_MAIN(tst_QAbstractButton)
+ #include "tst_qabstractbutton.moc"
+diff --git a/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+index 32437050f5..46b5af6d63 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+@@ -168,6 +168,7 @@ private slots:
+     void checkMenuItemPosWhenStyleSheetIsSet();
+     void checkEmbeddedLineEditWhenStyleSheetIsSet();
+     void propagateStyleChanges();
++    void buttonPressKeys();
+ 
+ private:
+     PlatformInputContext m_platformInputContext;
+@@ -1682,6 +1683,16 @@ void tst_QComboBox::setModel()
+     QCOMPARE(box.rootModelIndex(), rootModelIndex);
+     box.setModel(box.model());
+     QCOMPARE(box.rootModelIndex(), rootModelIndex);
++
++    // check that setting the same model as the completer's doesn't crash
++    QCompleter *completer = new QCompleter(&box);
++    box.setEditable(true);
++    box.setCompleter(completer);
++    auto *listModel = new QStringListModel({ "one", "two" }, completer);
++    completer->setModel(listModel);
++    QCOMPARE(listModel->rowCount(), 2); // make sure it wasn't deleted
++    box.setModel(listModel);
++    QCOMPARE(listModel->rowCount(), 2); // make sure it wasn't deleted
+ }
+ 
+ void tst_QComboBox::setCustomModelAndView()
+@@ -3632,5 +3643,24 @@ void tst_QComboBox::propagateStyleChanges()
+     QVERIFY(frameStyle.inquired);
+ }
+ 
++void tst_QComboBox::buttonPressKeys()
++{
++    QComboBox comboBox;
++    comboBox.setEditable(false);
++    comboBox.addItem(QString::number(1));
++    comboBox.addItem(QString::number(2));
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(&comboBox, buttonPressKeys[i]);
++        // On some platforms, a window will not be immediately visible,
++        // but take some event-loop iterations to complete.
++        // Using QTRY_VERIFY to deal with that.
++        QTRY_VERIFY(comboBox.view()->isVisible());
++        comboBox.hidePopup();
++    }
++}
++
+ QTEST_MAIN(tst_QComboBox)
+ #include "tst_qcombobox.moc"
+diff --git a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
+index be3cfcd104..c228fdfcca 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
++++ b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qcommandlinkbutton
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qcommandlinkbutton.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
+index 0044d33c66..4cf06296e4 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
+@@ -40,6 +40,9 @@
+ #include <QGridLayout>
+ #include <QPainter>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ class tst_QCommandLinkButton : public QObject
+ {
+     Q_OBJECT
+@@ -223,6 +226,13 @@ void tst_QCommandLinkButton::setAutoRepeat()
+     // check that pressing ENTER has no effect
+     resetCounters();
+     testWidget->setDown( false );
++    // Skip after reset if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
+     testWidget->setAutoRepeat( false );
+     QTest::keyPress( testWidget, Qt::Key_Enter );
+ 
+@@ -255,6 +265,14 @@ void tst_QCommandLinkButton::pressed()
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+ 
++    // Skip if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
++
+     QTest::keyPress( testWidget,Qt::Key_Enter );
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+diff --git a/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro b/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
+index 4a5e76ff65..a235fa1fac 100644
+--- a/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
++++ b/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qgroupbox
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qgroupbox.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp b/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
+index 4fb5d262ca..d8d7562b73 100644
+--- a/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
+@@ -35,6 +35,9 @@
+ #include <QRadioButton>
+ #include <QDialog>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ #include "qgroupbox.h"
+ 
+ class tst_QGroupBox : public QObject
+@@ -69,6 +72,7 @@ private slots:
+     void propagateFocus();
+     void task_QTBUG_19170_ignoreMouseReleaseEvent();
+     void task_QTBUG_15519_propagateMouseEvents();
++    void buttonPressKeys();
+ 
+ private:
+     bool checked;
+@@ -610,6 +614,20 @@ void tst_QGroupBox::task_QTBUG_15519_propagateMouseEvents()
+     QCOMPARE(parent.mouseMoved, true);
+ }
+ 
++void tst_QGroupBox::buttonPressKeys()
++{
++    QGroupBox groupBox;
++    groupBox.setCheckable(true);
++    QSignalSpy clickedSpy(&groupBox, &QGroupBox::clicked);
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(&groupBox, buttonPressKeys[i]);
++        QCOMPARE(clickedSpy.length(), i + 1);
++    }
++}
++
+ void tst_QGroupBox::sendMouseMoveEvent(QWidget *widget, const QPoint &localPos)
+ {
+     // Send a MouseMove event without actually moving the pointer
+diff --git a/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro b/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
+index 353ad06ca2..e55f6148f2 100644
+--- a/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
++++ b/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qpushbutton
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qpushbutton.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp b/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
+index e818514a79..4043e9326a 100644
+--- a/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
+@@ -41,6 +41,9 @@
+ #include <QStyleFactory>
+ #include <QTabWidget>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ class tst_QPushButton : public QObject
+ {
+ Q_OBJECT
+@@ -212,6 +215,13 @@ void tst_QPushButton::autoRepeat()
+     // check that pressing ENTER has no effect
+     resetCounters();
+     testWidget->setDown( false );
++    // Skip after reset if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
+     testWidget->setAutoRepeat( false );
+     QTest::keyPress( testWidget, Qt::Key_Enter );
+ 
+@@ -247,6 +257,14 @@ void tst_QPushButton::pressed()
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+ 
++    // Skip if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
++
+     QTest::keyPress( testWidget,Qt::Key_Enter );
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+diff --git a/qtbase/tests/manual/rhi/cubemap_render/buildshader.bat b/qtbase/tests/manual/rhi/cubemap_render/buildshader.bat
+old mode 100755
+new mode 100644
+Submodule qtconnectivity e957d481..056294c0:
+diff --git a/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp b/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
+index e2635fae..a8b8e3b9 100644
+--- a/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
++++ b/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
+@@ -563,9 +563,11 @@ void HciManager::handleHciAclPacket(const quint8 *data, int size)
+ 
+ void HciManager::handleLeMetaEvent(const quint8 *data)
+ {
+-    // Spec v4.2, Vol 2, part E, 7.7.65ff
++    // Spec v5.3, Vol 4, part E, 7.7.65.*
+     switch (*data) {
+-    case 0x1: {
++    case 0x1: // HCI_LE_Connection_Complete
++    case 0xA: // HCI_LE_Enhanced_Connection_Complete
++    {
+         const quint16 handle = bt_get_le16(data + 2);
+         emit connectionComplete(handle);
+         break;
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp b/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
+index 6a93143b..4a18cfc7 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
+@@ -320,7 +320,10 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_finishSdpScan(QBluetoothServiceD
+             for (const QBluetoothUuid &id : serviceClassUuids) {
+                 if (id.minimumSize() == 16) {
+                     serviceInfo.setServiceUuid(id);
+-                    serviceInfo.setServiceName(QBluetoothServiceDiscoveryAgent::tr("Custom Service"));
++                    if (serviceInfo.serviceName().isEmpty()) {
++                        serviceInfo.setServiceName(
++                                    QBluetoothServiceDiscoveryAgent::tr("Custom Service"));
++                    }
+                     QBluetoothServiceInfo::Sequence modSeq =
+                             serviceInfo.attribute(QBluetoothServiceInfo::ServiceClassIds).value<QBluetoothServiceInfo::Sequence>();
+                     modSeq.removeOne(QVariant::fromValue(id));
+@@ -334,8 +337,10 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_finishSdpScan(QBluetoothServiceD
+                 qCDebug(QT_BT_BLUEZ) << "Discovered services" << discoveredDevices.at(0).address().toString()
+                                      << serviceInfo.serviceName() << serviceInfo.serviceUuid()
+                                      << ">>>" << serviceInfo.serviceClassUuids();
+-
+-                emit q->serviceDiscovered(serviceInfo);
++                // Use queued connection to allow us finish the service looping; the application
++                // might call stop() when it has detected the service-of-interest.
++                QMetaObject::invokeMethod(q, "serviceDiscovered", Qt::QueuedConnection,
++                                          Q_ARG(QBluetoothServiceInfo, serviceInfo));
+             }
+         }
+     }
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp b/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
+index e4d85447..aadd4755 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
+@@ -593,7 +593,7 @@ void QBluetoothSocket::setSocketState(QBluetoothSocket::SocketState state)
+ bool QBluetoothSocket::canReadLine() const
+ {
+     Q_D(const QBluetoothSocketBase);
+-    return d->canReadLine();
++    return d->canReadLine() || QIODevice::canReadLine();
+ }
+ 
+ /*!
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp b/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
+index 084aa958..d6aa17a7 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
+@@ -284,6 +284,10 @@ void QBluetoothSocketPrivateBluezDBus::connectToService(
+         return;
+     }
+ 
++    if (service.socketProtocol() != QBluetoothServiceInfo::Protocol::UnknownProtocol)
++        socketType = service.socketProtocol();
++    qCDebug(QT_BT_BLUEZ) << "Socket protocol used:" << socketType;
++
+     connectToService(service.device().address(), targetService, openMode);
+ }
+ 
+diff --git a/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp b/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
+index 05bc1a0f..a7b5ef1f 100644
+--- a/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
++++ b/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
+@@ -142,7 +142,7 @@ void tst_QBluetoothSocket::initTestCase()
+     qDebug() << "Starting discovery";
+ 
+     sda->setUuidFilter(QBluetoothUuid(QString(TEST_SERVICE_UUID)));
+-    sda->start(QBluetoothServiceDiscoveryAgent::MinimalDiscovery);
++    sda->start(QBluetoothServiceDiscoveryAgent::FullDiscovery);
+ 
+     for (int connectTime = MaxConnectTime; !done_discovery && connectTime > 0; connectTime -= 1000)
+         QTest::qWait(1000);
+Submodule qtdeclarative f5701f0d..8defe7bf:
+diff --git a/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h b/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
+index b65b994d6c..15a8cd6878 100644
+--- a/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
++++ b/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
+@@ -86,7 +86,7 @@ public:
+         if (QTypeInfo<T>::isComplex) {
+             for (int i = 0; i < count; ++i)
+                 new (data + i) T(vector.at(i));
+-        } else {
++        } else if (count) {
+             memcpy(data, static_cast<const void*>(vector.constData()), count * sizeof(T));
+         }
+     }
+diff --git a/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp b/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
+index e57cdd8278..94613598af 100644
+--- a/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
++++ b/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
+@@ -1145,8 +1145,7 @@ void Heap::QObjectWrapper::markObjects(Heap::Base *that, QV4::MarkStack *markSta
+ void QObjectWrapper::destroyObject(bool lastCall)
+ {
+     Heap::QObjectWrapper *h = d();
+-    if (!h->internalClass)
+-        return; // destroyObject already got called
++    Q_ASSERT(h->internalClass);
+ 
+     if (h->object()) {
+         QQmlData *ddata = QQmlData::get(h->object(), false);
+@@ -1176,7 +1175,7 @@ void QObjectWrapper::destroyObject(bool lastCall)
+         }
+     }
+ 
+-    h->~Data();
++    h->destroy();
+ }
+ 
+ 
+diff --git a/qtdeclarative/src/qml/memory/qv4mm.cpp b/qtdeclarative/src/qml/memory/qv4mm.cpp
+index 06caf04e5a..da149a67c4 100644
+--- a/qtdeclarative/src/qml/memory/qv4mm.cpp
++++ b/qtdeclarative/src/qml/memory/qv4mm.cpp
+@@ -981,7 +981,7 @@ void MemoryManager::sweep(bool lastSweep, ClassDestroyStatsCallback classCountPt
+ 
+     if (MultiplyWrappedQObjectMap *multiplyWrappedQObjects = engine->m_multiplyWrappedQObjects) {
+         for (MultiplyWrappedQObjectMap::Iterator it = multiplyWrappedQObjects->begin(); it != multiplyWrappedQObjects->end();) {
+-            if (!it.value().isNullOrUndefined())
++            if (it.value().isNullOrUndefined())
+                 it = multiplyWrappedQObjects->erase(it);
+             else
+                 ++it;
+diff --git a/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp b/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
+index 2079a8ed04..a577cb2351 100644
+--- a/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
++++ b/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
+@@ -389,6 +389,12 @@ void QQmlDelegateModelPrivate::connectToAbstractItemModel()
+                       q,  QQmlDelegateModel, SLOT(_q_rowsRemoved(QModelIndex,int,int)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
+                       q,  QQmlDelegateModel, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsInserted(QModelIndex,int,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsInserted(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsRemoved(QModelIndex,int,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsRemoved(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsMoved(QModelIndex,int,int,QModelIndex,int)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
+                       q, QQmlDelegateModel, SLOT(_q_dataChanged(QModelIndex,QModelIndex,QVector<int>)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
+@@ -413,6 +419,12 @@ void QQmlDelegateModelPrivate::disconnectFromAbstractItemModel()
+                         q, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int)));
+     QObject::disconnect(aim, SIGNAL(rowsRemoved(QModelIndex,int,int)),
+                         q, SLOT(_q_rowsRemoved(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsInserted(QModelIndex,int,int)), q,
++                        SLOT(_q_columnsInserted(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsRemoved(QModelIndex,int,int)), q,
++                        SLOT(_q_columnsRemoved(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)), q,
++                        SLOT(_q_columnsMoved(QModelIndex,int,int,QModelIndex,int)));
+     QObject::disconnect(aim, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
+                         q, SLOT(_q_dataChanged(QModelIndex,QModelIndex,QVector<int>)));
+     QObject::disconnect(aim, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
+@@ -1973,6 +1985,38 @@ void QQmlDelegateModel::_q_rowsMoved(
+     }
+ }
+ 
++void QQmlDelegateModel::_q_columnsInserted(const QModelIndex &parent, int begin, int end)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if (parent == d->m_adaptorModel.rootIndex && begin == 0) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
++void QQmlDelegateModel::_q_columnsRemoved(const QModelIndex &parent, int begin, int end)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if (parent == d->m_adaptorModel.rootIndex && begin == 0) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
++void QQmlDelegateModel::_q_columnsMoved(const QModelIndex &parent, int start, int end,
++                                        const QModelIndex &destination, int column)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if ((parent == d->m_adaptorModel.rootIndex && start == 0)
++        || (destination == d->m_adaptorModel.rootIndex && column == 0)) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
+ void QQmlDelegateModel::_q_dataChanged(const QModelIndex &begin, const QModelIndex &end, const QVector<int> &roles)
+ {
+     Q_D(QQmlDelegateModel);
+diff --git a/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h b/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
+index 8aab4badca..d140bfbaaf 100644
+--- a/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
++++ b/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
+@@ -152,6 +152,9 @@ private Q_SLOTS:
+     void _q_itemsMoved(int from, int to, int count);
+     void _q_modelReset();
+     void _q_rowsInserted(const QModelIndex &,int,int);
++    void _q_columnsInserted(const QModelIndex &, int, int);
++    void _q_columnsRemoved(const QModelIndex &, int, int);
++    void _q_columnsMoved(const QModelIndex &, int, int, const QModelIndex &, int);
+     void _q_rowsAboutToBeRemoved(const QModelIndex &parent, int begin, int end);
+     void _q_rowsRemoved(const QModelIndex &,int,int);
+     void _q_rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int);
+diff --git a/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp b/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
+index 85719fdc80..78e2ab302c 100644
+--- a/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
++++ b/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
+@@ -46,6 +46,7 @@
+ #include "QtQuick/private/qquicktextinput_p.h"
+ #include "QtQuick/private/qquickaccessibleattached_p.h"
+ #include "QtQuick/qquicktextdocument.h"
++#include "QtQuick/qquickrendercontrol.h"
+ QT_BEGIN_NAMESPACE
+ 
+ #if QT_CONFIG(accessibility)
+@@ -57,7 +58,19 @@ QAccessibleQuickItem::QAccessibleQuickItem(QQuickItem *item)
+ 
+ QWindow *QAccessibleQuickItem::window() const
+ {
+-    return item()->window();
++    QQuickWindow *window = item()->window();
++
++    // For QQuickWidget the above window will be the offscreen QQuickWindow,
++    // which is not a part of the accessibility tree. Detect this case and
++    // return the window for the QQuickWidget instead.
++    if (window && !window->handle()) {
++        if (QQuickRenderControl *renderControl = QQuickWindowPrivate::get(window)->renderControl) {
++            if (QWindow *renderWindow = renderControl->renderWindow(nullptr))
++                return renderWindow;
++        }
++    }
++
++    return window;
+ }
+ 
+ int QAccessibleQuickItem::childCount() const
+@@ -113,19 +126,15 @@ QAccessibleInterface *QAccessibleQuickItem::childAt(int x, int y) const
+ QAccessibleInterface *QAccessibleQuickItem::parent() const
+ {
+     QQuickItem *parent = item()->parentItem();
+-    QQuickWindow *window = item()->window();
+-    QQuickItem *ci = window ? window->contentItem() : nullptr;
++    QQuickWindow *itemWindow = item()->window();
++    QQuickItem *ci = itemWindow ? itemWindow->contentItem() : nullptr;
+     while (parent && !QQuickItemPrivate::get(parent)->isAccessible && parent != ci)
+         parent = parent->parentItem();
+ 
+     if (parent) {
+         if (parent == ci) {
+-            // Jump out to the scene widget if the parent is the root item.
+-            // There are two root items, QQuickWindow::rootItem and
+-            // QQuickView::declarativeRoot. The former is the true root item,
+-            // but is not a part of the accessibility tree. Check if we hit
+-            // it here and return an interface for the scene instead.
+-            return QAccessible::queryAccessibleInterface(window);
++            // Jump out to the window if the parent is the root item
++            return QAccessible::queryAccessibleInterface(window());
+         } else {
+             while (parent && !parent->d_func()->isAccessible)
+                 parent = parent->parentItem();
+@@ -188,7 +197,7 @@ QAccessible::State QAccessibleQuickItem::state() const
+     QRect viewRect_ = viewRect();
+     QRect itemRect = rect();
+ 
+-    if (viewRect_.isNull() || itemRect.isNull() || !item()->window() || !item()->window()->isVisible() ||!item()->isVisible() || qFuzzyIsNull(item()->opacity()))
++    if (viewRect_.isNull() || itemRect.isNull() || !window() || !window()->isVisible() ||!item()->isVisible() || qFuzzyIsNull(item()->opacity()))
+         state.invisible = true;
+     if (!viewRect_.intersects(itemRect))
+         state.offscreen = true;
+@@ -201,6 +210,10 @@ QAccessible::State QAccessibleQuickItem::state() const
+     if (role() == QAccessible::EditableText)
+         if (auto ti = qobject_cast<QQuickTextInput *>(item()))
+             state.passwordEdit = ti->echoMode() != QQuickTextInput::Normal;
++    if (!item()->isEnabled()) {
++        state.focusable = false;
++        state.disabled = true;
++    }
+     return state;
+ }
+ 
+diff --git a/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h b/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
+index 39ffcaf39c..8baa01330c 100644
+--- a/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
++++ b/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
+@@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE
+ 
+ #if QT_CONFIG(accessibility)
+ 
+-class QAccessibleQuickWindow : public QAccessibleObject
++class Q_QUICK_EXPORT QAccessibleQuickWindow : public QAccessibleObject
+ {
+ public:
+     QAccessibleQuickWindow(QQuickWindow *object);
+diff --git a/qtdeclarative/src/quick/items/qquickdrag.cpp b/qtdeclarative/src/quick/items/qquickdrag.cpp
+index 8321fcfeed..383078b3b9 100644
+--- a/qtdeclarative/src/quick/items/qquickdrag.cpp
++++ b/qtdeclarative/src/quick/items/qquickdrag.cpp
+@@ -481,7 +481,9 @@ void QQuickDragAttached::setKeys(const QStringList &keys)
+     \qmlattachedproperty stringlist QtQuick::Drag::mimeData
+     \since 5.2
+ 
+-    This property holds a map of mimeData that is used during startDrag.
++    This property holds a map from mime type to data that is used during startDrag.
++    The mime data needs to be a \c string, or an \c ArrayBuffer with the data encoded
++    according to the mime type.
+ */
+ 
+ QVariantMap QQuickDragAttached::mimeData() const
+@@ -766,8 +768,12 @@ Qt::DropAction QQuickDragAttachedPrivate::startDrag(Qt::DropActions supportedAct
+     QDrag *drag = new QDrag(source ? source : q);
+     QMimeData *mimeData = new QMimeData();
+ 
+-    for (auto it = externalMimeData.cbegin(), end = externalMimeData.cend(); it != end; ++it)
+-        mimeData->setData(it.key(), it.value().toString().toUtf8());
++    for (auto it = externalMimeData.cbegin(), end = externalMimeData.cend(); it != end; ++it) {
++        if (static_cast<QMetaType::Type>(it.value().type()) == QMetaType::QByteArray)
++            mimeData->setData(it.key(), it.value().toByteArray());
++        else
++            mimeData->setData(it.key(), it.value().toString().toUtf8());
++    }
+ 
+     drag->setMimeData(mimeData);
+     if (pixmapLoader.isReady()) {
+diff --git a/qtdeclarative/src/quick/items/qquickitem.cpp b/qtdeclarative/src/quick/items/qquickitem.cpp
+index 75f1457816..dec0ae19ae 100644
+--- a/qtdeclarative/src/quick/items/qquickitem.cpp
++++ b/qtdeclarative/src/quick/items/qquickitem.cpp
+@@ -59,6 +59,7 @@
+ #include <QtCore/private/qnumeric_p.h>
+ #include <QtGui/qpa/qplatformtheme.h>
+ #include <QtCore/qloggingcategory.h>
++#include <QtCore/private/qduplicatetracker_p.h>
+ 
+ #include <private/qqmlglobal_p.h>
+ #include <private/qqmlengine_p.h>
+@@ -2326,6 +2327,7 @@ QQuickItem::QQuickItem(QQuickItemPrivate &dd, QQuickItem *parent)
+ QQuickItem::~QQuickItem()
+ {
+     Q_D(QQuickItem);
++    d->inDestructor = true;
+ 
+     if (d->windowRefCount > 1)
+         d->windowRefCount = 1; // Make sure window is set to null in next call to derefWindow().
+@@ -2526,6 +2528,7 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo
+     QQuickItem *current = item;
+     qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: startItem:" << startItem;
+     qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: firstFromItem:" << firstFromItem;
++    QDuplicateTracker<QQuickItem *> cycleDetector;
+     do {
+         qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: current:" << current;
+         qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: from:" << from;
+@@ -2592,7 +2595,10 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo
+         // traversed all of the chain (by compare the [current] item with [startItem])
+         // Since the [startItem] might be promoted to its parent if it is invisible,
+         // we still have to check [current] item with original start item
+-        if ((current == startItem || current == originalStartItem) && from == firstFromItem) {
++        // We might also run into a cycle before we reach firstFromItem again
++        // but note that we have to ignore current if we are meant to skip it
++        if (((current == startItem || current == originalStartItem) && from == firstFromItem) ||
++                (!skip && cycleDetector.hasSeen(current))) {
+             // wrapped around, avoid endless loops
+             if (item == contentItem) {
+                 qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: looped, return contentItem";
+@@ -2689,9 +2695,8 @@ void QQuickItem::setParentItem(QQuickItem *parentItem)
+ 
+         const bool wasVisible = isVisible();
+         op->removeChild(this);
+-        if (wasVisible) {
++        if (wasVisible && !op->inDestructor)
+             emit oldParentItem->visibleChildrenChanged();
+-        }
+     } else if (d->window) {
+         QQuickWindowPrivate::get(d->window)->parentlessItems.remove(this);
+     }
+@@ -2768,8 +2773,9 @@ void QQuickItem::setParentItem(QQuickItem *parentItem)
+ 
+     d->itemChange(ItemParentHasChanged, d->parentItem);
+ 
+-    emit parentChanged(d->parentItem);
+-    if (isVisible() && d->parentItem)
++    if (!d->inDestructor)
++        emit parentChanged(d->parentItem);
++    if (isVisible() && d->parentItem && !QQuickItemPrivate::get(d->parentItem)->inDestructor)
+         emit d->parentItem->visibleChildrenChanged();
+ }
+ 
+@@ -2965,7 +2971,8 @@ void QQuickItemPrivate::removeChild(QQuickItem *child)
+ 
+     itemChange(QQuickItem::ItemChildRemovedChange, child);
+ 
+-    emit q->childrenChanged();
++    if (!inDestructor)
++        emit q->childrenChanged();
+ }
+ 
+ void QQuickItemPrivate::refWindow(QQuickWindow *c)
+@@ -3194,6 +3201,7 @@ QQuickItemPrivate::QQuickItemPrivate()
+     , touchEnabled(false)
+ #endif
+     , hasCursorHandler(false)
++    , inDestructor(false)
+     , dirtyAttributes(0)
+     , nextDirtyItem(nullptr)
+     , prevDirtyItem(nullptr)
+@@ -5120,6 +5128,13 @@ void QQuickItem::componentComplete()
+         d->addToDirtyList();
+         QQuickWindowPrivate::get(d->window)->dirtyItem(this);
+     }
++
++#if QT_CONFIG(accessibility)
++    if (d->isAccessible && d->effectiveVisible) {
++        QAccessibleEvent ev(this, QAccessible::ObjectShow);
++        QAccessible::updateAccessibility(&ev);
++    }
++#endif
+ }
+ 
+ QQuickStateGroup *QQuickItemPrivate::_states()
+@@ -6106,9 +6121,11 @@ bool QQuickItemPrivate::setEffectiveVisibleRecur(bool newEffectiveVisible)
+         QAccessible::updateAccessibility(&ev);
+     }
+ #endif
+-    emit q->visibleChanged();
+-    if (childVisibilityChanged)
+-        emit q->visibleChildrenChanged();
++    if (!inDestructor) {
++        emit q->visibleChanged();
++        if (childVisibilityChanged)
++            emit q->visibleChildrenChanged();
++    }
+ 
+     return true;    // effective visibility DID change
+ }
+@@ -6157,6 +6174,15 @@ void QQuickItemPrivate::setEffectiveEnableRecur(QQuickItem *scope, bool newEffec
+     }
+ 
+     itemChange(QQuickItem::ItemEnabledHasChanged, effectiveEnable);
++#if QT_CONFIG(accessibility)
++    if (isAccessible) {
++        QAccessible::State changedState;
++        changedState.disabled = true;
++        changedState.focusable = true;
++        QAccessibleStateChangeEvent ev(q, changedState);
++        QAccessible::updateAccessibility(&ev);
++    }
++#endif
+     emit q->enabledChanged();
+ }
+ 
+diff --git a/qtdeclarative/src/quick/items/qquickitem_p.h b/qtdeclarative/src/quick/items/qquickitem_p.h
+index 841d91bb40..ade8fb61f2 100644
+--- a/qtdeclarative/src/quick/items/qquickitem_p.h
++++ b/qtdeclarative/src/quick/items/qquickitem_p.h
+@@ -472,6 +472,7 @@ public:
+     bool replayingPressEvent:1;
+     bool touchEnabled:1;
+     bool hasCursorHandler:1;
++    quint32 inDestructor:1; // has entered ~QQuickItem
+ 
+     enum DirtyType {
+         TransformOrigin         = 0x00000001,
+diff --git a/qtdeclarative/src/quick/items/qquickitemview.cpp b/qtdeclarative/src/quick/items/qquickitemview.cpp
+index 010a0152e1..f8ad168a17 100644
+--- a/qtdeclarative/src/quick/items/qquickitemview.cpp
++++ b/qtdeclarative/src/quick/items/qquickitemview.cpp
+@@ -1785,7 +1785,7 @@ void QQuickItemViewPrivate::refill(qreal from, qreal to)
+ 
+     do {
+         bufferPause.stop();
+-        if (currentChanges.hasPendingChanges() || bufferedChanges.hasPendingChanges()) {
++        if (currentChanges.hasPendingChanges() || bufferedChanges.hasPendingChanges() || currentChanges.active) {
+             currentChanges.reset();
+             bufferedChanges.reset();
+             releaseVisibleItems(reusableFlag);
+diff --git a/qtdeclarative/src/quick/items/qquickmousearea_p_p.h b/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
+index fba383e268..0d63618622 100644
+--- a/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
++++ b/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
+@@ -61,7 +61,6 @@ QT_BEGIN_NAMESPACE
+ 
+ class QQuickMouseEvent;
+ class QQuickMouseArea;
+-class QQuickPointerMask;
+ class QQuickMouseAreaPrivate : public QQuickItemPrivate
+ {
+     Q_DECLARE_PUBLIC(QQuickMouseArea)
+@@ -100,7 +99,6 @@ public:
+ #if QT_CONFIG(quick_draganddrop)
+     QQuickDrag *drag;
+ #endif
+-    QPointer<QQuickPointerMask> mask;
+     QPointF startScene;
+     QPointF targetStartPos;
+     QPointF lastPos;
+diff --git a/qtdeclarative/src/quick/items/qquicktext.cpp b/qtdeclarative/src/quick/items/qquicktext.cpp
+index 6230186933..e823ca1095 100644
+--- a/qtdeclarative/src/quick/items/qquicktext.cpp
++++ b/qtdeclarative/src/quick/items/qquicktext.cpp
+@@ -2168,7 +2168,7 @@ void QQuickText::resetMaximumLineCount()
+     <img src="" align="top,middle,bottom" width="" height=""> - inline images
+     <ol type="">, <ul type=""> and <li> - ordered and unordered lists
+     <pre></pre> - preformatted
+-    &gt; &lt; &amp;
++    &gt; &lt; &amp; &quot; &nbsp; &apos;
+     \endcode
+ 
+     \c Text.StyledText parser is strict, requiring tags to be correctly nested.
+diff --git a/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp b/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
+index eb4db0f85e..2325a2665b 100644
+--- a/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
++++ b/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
+@@ -446,7 +446,7 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+         const char *textureRecord = allocatorData;
+         for (int i = 0; i < textureCount; ++i, textureRecord += Qtdf::TextureRecordSize) {
+-            if (textureRecord + Qtdf::TextureRecordSize > qtdfTableEnd) {
++            if (qtdfTableEnd - textureRecord < Qtdf::TextureRecordSize) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+@@ -462,7 +462,7 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+         const char *glyphRecord = textureRecord;
+         for (quint32 i = 0; i < glyphCount; ++i, glyphRecord += Qtdf::GlyphRecordSize) {
+-            if (glyphRecord + Qtdf::GlyphRecordSize > qtdfTableEnd) {
++            if (qtdfTableEnd - glyphRecord < Qtdf:: GlyphRecordSize) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+@@ -512,8 +512,8 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+             int width = texInfo->allocatedArea.width();
+             int height = texInfo->allocatedArea.height();
+-            qint64 size = width * height;
+-            if (reinterpret_cast<const char *>(textureData + size) > qtdfTableEnd) {
++            qint64 size = qint64(width) * height;
++            if (qtdfTableEnd - reinterpret_cast<const char *>(textureData) < size) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+diff --git a/qtdeclarative/src/quick/util/qquickstyledtext.cpp b/qtdeclarative/src/quick/util/qquickstyledtext.cpp
+index d531fc9205..a25af90414 100644
+--- a/qtdeclarative/src/quick/util/qquickstyledtext.cpp
++++ b/qtdeclarative/src/quick/util/qquickstyledtext.cpp
+@@ -564,6 +564,8 @@ void QQuickStyledTextPrivate::parseEntity(const QChar *&ch, const QString &textI
+                 textOut += QChar(60);
+             else if (entity == QLatin1String("amp"))
+                 textOut += QChar(38);
++            else if (entity == QLatin1String("apos"))
++                textOut += QChar(39);
+             else if (entity == QLatin1String("quot"))
+                 textOut += QChar(34);
+             else if (entity == QLatin1String("nbsp"))
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp
+new file mode 100644
+index 0000000000..8a1c901880
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp
+@@ -0,0 +1,110 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include "qaccessiblequickwidget_p.h"
++
++#include "qquickwidget_p.h"
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleQuickWidget::QAccessibleQuickWidget(QQuickWidget* widget)
++: QAccessibleWidget(widget)
++, m_accessibleWindow(QQuickWidgetPrivate::get(widget)->offscreenWindow)
++{
++    // NOTE: m_accessibleWindow is a QAccessibleQuickWindow, and not a
++    // QAccessibleQuickWidgetOffscreenWindow (defined below). This means
++    // it will return the Quick item child interfaces, which is what's needed here
++    // (unlike QAccessibleQuickWidgetOffscreenWindow, which will report 0 children).
++}
++
++QAccessibleInterface *QAccessibleQuickWidget::child(int index) const
++{
++    return m_accessibleWindow.child(index);
++}
++
++int QAccessibleQuickWidget::childCount() const
++{
++    return m_accessibleWindow.childCount();
++}
++
++int QAccessibleQuickWidget::indexOfChild(const QAccessibleInterface *iface) const
++{
++    return m_accessibleWindow.indexOfChild(iface);
++}
++
++QAccessibleInterface *QAccessibleQuickWidget::childAt(int x, int y) const
++{
++    return m_accessibleWindow.childAt(x, y);
++}
++
++QAccessibleQuickWidgetOffscreenWindow::QAccessibleQuickWidgetOffscreenWindow(QQuickWindow *window)
++:QAccessibleQuickWindow(window)
++{
++
++}
++
++QAccessibleInterface *QAccessibleQuickWidgetOffscreenWindow::child(int index) const
++{
++    Q_UNUSED(index);
++    return nullptr;
++}
++
++int QAccessibleQuickWidgetOffscreenWindow::childCount() const
++{
++    return 0;
++}
++
++int QAccessibleQuickWidgetOffscreenWindow::indexOfChild(const QAccessibleInterface *iface) const
++{
++    Q_UNUSED(iface);
++    return -1;
++}
++
++QAccessibleInterface *QAccessibleQuickWidgetOffscreenWindow::QAccessibleQuickWidgetOffscreenWindow::childAt(int x, int y) const
++{
++    Q_UNUSED(x);
++    Q_UNUSED(y);
++    return nullptr;
++}
++
++#endif // accessibility
++
++QT_END_NAMESPACE
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h
+new file mode 100644
+index 0000000000..7c2ab930e0
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h
+@@ -0,0 +1,95 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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 QACCESSIBLEQUICKWIDGET_H
++#define QACCESSIBLEQUICKWIDGET_H
++
++//
++//  W A R N I N G
++//  -------------
++//
++// This file is not part of the Qt API.  It exists purely as an
++// implementation detail.  This header file may change from version to
++// version without notice, or even be removed.
++//
++// We mean it.
++//
++
++#include "qquickwidget.h"
++#include <QtWidgets/qaccessiblewidget.h>
++
++#include <private/qaccessiblequickview_p.h>
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++// These classes implement the QQuickWiget accessibility switcharoo,
++// where the child items of the QQuickWidgetOffscreenWindow are reported
++// as child accessible interfaces of the QAccessibleQuickWidget.
++class QAccessibleQuickWidget: public QAccessibleWidget
++{
++public:
++    QAccessibleQuickWidget(QQuickWidget* widget);
++
++    QAccessibleInterface *child(int index) const override;
++    int childCount() const override;
++    int indexOfChild(const QAccessibleInterface *iface) const override;
++    QAccessibleInterface *childAt(int x, int y) const override;
++
++private:
++    QAccessibleQuickWindow m_accessibleWindow;
++    Q_DISABLE_COPY(QAccessibleQuickWidget)
++};
++
++class QAccessibleQuickWidgetOffscreenWindow: public QAccessibleQuickWindow
++{
++public:
++    QAccessibleQuickWidgetOffscreenWindow(QQuickWindow *window);
++    QAccessibleInterface *child(int index) const override;
++    int childCount() const override;
++    int indexOfChild(const QAccessibleInterface *iface) const override;
++    QAccessibleInterface *childAt(int x, int y) const override;
++};
++
++#endif // accessibility
++
++QT_END_NAMESPACE
++
++#endif
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp
+new file mode 100644
+index 0000000000..7ba88a1769
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp
+@@ -0,0 +1,60 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include "qaccessiblequickwidgetfactory_p.h"
++#include "qaccessiblequickwidget_p.h"
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleInterface *qAccessibleQuickWidgetFactory(const QString &classname, QObject *object)
++{
++    if (classname == QLatin1String("QQuickWidget")) {
++        return new QAccessibleQuickWidget(qobject_cast<QQuickWidget *>(object));
++    } else if (classname == QLatin1String("QQuickWidgetOffscreenWindow")) {
++        return new QAccessibleQuickWidgetOffscreenWindow(qobject_cast<QQuickWindow *>(object));
++    }
++    return 0;
++}
++
++#endif // accessibility
++
++QT_END_NAMESPACE
++
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h
+new file mode 100644
+index 0000000000..8c63b09f81
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h
+@@ -0,0 +1,66 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include <QtGui/qaccessible.h>
++
++#ifndef QACCESSIBLEQUICKWIDGETFACTORY_H
++#define QACCESSIBLEQUICKWIDGETFACTORY_H
++
++//
++//  W A R N I N G
++//  -------------
++//
++// This file is not part of the Qt API.  It exists purely as an
++// implementation detail.  This header file may change from version to
++// version without notice, or even be removed.
++//
++// We mean it.
++//
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleInterface *qAccessibleQuickWidgetFactory(const QString &classname, QObject *object);
++
++#endif
++
++QT_END_NAMESPACE
++
++#endif
+diff --git a/qtdeclarative/src/quickwidgets/qquickwidget.cpp b/qtdeclarative/src/quickwidgets/qquickwidget.cpp
+index 39780f8de3..9c97b43518 100644
+--- a/qtdeclarative/src/quickwidgets/qquickwidget.cpp
++++ b/qtdeclarative/src/quickwidgets/qquickwidget.cpp
+@@ -39,6 +39,7 @@
+ 
+ #include "qquickwidget.h"
+ #include "qquickwidget_p.h"
++#include "qaccessiblequickwidgetfactory_p.h"
+ 
+ #include "private/qquickwindow_p.h"
+ #include "private/qquickitem_p.h"
+@@ -75,9 +76,16 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++QQuickWidgetOffscreenWindow::QQuickWidgetOffscreenWindow(QQuickWindowPrivate &dd, QQuickRenderControl *control)
++:QQuickWindow(dd, control)
++{
++    setTitle(QString::fromLatin1("Offscreen"));
++    setObjectName(QString::fromLatin1("QQuickOffScreenWindow"));
++}
++
+ // override setVisble to prevent accidental offscreen window being created
+ // by base class.
+-class QQuickOffcreenWindowPrivate: public QQuickWindowPrivate {
++class QQuickWidgetOffscreenWindowPrivate: public QQuickWindowPrivate {
+ public:
+     void setVisible(bool visible) override {
+         Q_Q(QWindow);
+@@ -105,9 +113,8 @@ void QQuickWidgetPrivate::init(QQmlEngine* e)
+     Q_Q(QQuickWidget);
+ 
+     renderControl = new QQuickWidgetRenderControl(q);
+-    offscreenWindow = new QQuickWindow(*new QQuickOffcreenWindowPrivate(),renderControl);
+-    offscreenWindow->setTitle(QString::fromLatin1("Offscreen"));
+-    offscreenWindow->setObjectName(QString::fromLatin1("QQuickOffScreenWindow"));
++    offscreenWindow = new QQuickWidgetOffscreenWindow(*new QQuickWidgetOffscreenWindowPrivate(), renderControl);
++    offscreenWindow->setScreen(q->screen());
+     // Do not call create() on offscreenWindow.
+ 
+     // Check if the Software Adaptation is being used
+@@ -138,6 +145,10 @@ void QQuickWidgetPrivate::init(QQmlEngine* e)
+     QWidget::connect(offscreenWindow, &QQuickWindow::focusObjectChanged, q, &QQuickWidget::propagateFocusObjectChanged);
+     QObject::connect(renderControl, SIGNAL(renderRequested()), q, SLOT(triggerUpdate()));
+     QObject::connect(renderControl, SIGNAL(sceneChanged()), q, SLOT(triggerUpdate()));
++
++#if QT_CONFIG(accessibility)
++    QAccessible::installFactory(&qAccessibleQuickWidgetFactory);
++#endif
+ }
+ 
+ void QQuickWidgetPrivate::ensureEngine() const
+@@ -901,9 +912,7 @@ void QQuickWidgetPrivate::createContext()
+ 
+         context = new QOpenGLContext;
+         context->setFormat(offscreenWindow->requestedFormat());
+-        const QWindow *win = q->window()->windowHandle();
+-        if (win && win->screen())
+-            context->setScreen(win->screen());
++        context->setScreen(q->screen());
+         QOpenGLContext *shareContext = qt_gl_global_share_context();
+         if (!shareContext)
+             shareContext = QWidgetPrivate::get(q->window())->shareContext();
+@@ -1520,19 +1529,16 @@ bool QQuickWidget::event(QEvent *e)
+         d->handleWindowChange();
+         break;
+ 
+-    case QEvent::ScreenChangeInternal:
+-        if (QWindow *window = this->window()->windowHandle()) {
+-            QScreen *newScreen = window->screen();
+-
+-            if (d->offscreenWindow)
+-                d->offscreenWindow->setScreen(newScreen);
+-            if (d->offscreenSurface)
+-                d->offscreenSurface->setScreen(newScreen);
++    case QEvent::ScreenChangeInternal: {
++        QScreen *newScreen = screen();
++        if (d->offscreenWindow)
++            d->offscreenWindow->setScreen(newScreen);
++        if (d->offscreenSurface)
++            d->offscreenSurface->setScreen(newScreen);
+ #if QT_CONFIG(opengl)
+-            if (d->context)
+-                d->context->setScreen(newScreen);
++        if (d->context)
++            d->context->setScreen(newScreen);
+ #endif
+-        }
+ 
+         if (d->useSoftwareRenderer
+ #if QT_CONFIG(opengl)
+@@ -1545,7 +1551,7 @@ bool QQuickWidget::event(QEvent *e)
+             d->render(true);
+         }
+         break;
+-
++    }
+     case QEvent::Show:
+     case QEvent::Move:
+         d->updatePosition();
+diff --git a/qtdeclarative/src/quickwidgets/qquickwidget_p.h b/qtdeclarative/src/quickwidgets/qquickwidget_p.h
+index 881f7f9220..1a946bcc71 100644
+--- a/qtdeclarative/src/quickwidgets/qquickwidget_p.h
++++ b/qtdeclarative/src/quickwidgets/qquickwidget_p.h
+@@ -148,6 +148,14 @@ public:
+     bool forceFullUpdate;
+ };
+ 
++class QQuickWidgetOffscreenWindow: public QQuickWindow
++{
++    Q_OBJECT
++
++public:
++    QQuickWidgetOffscreenWindow(QQuickWindowPrivate &dd, QQuickRenderControl *control);
++};
++
+ QT_END_NAMESPACE
+ 
+ #endif // QQuickWidget_P_H
+diff --git a/qtdeclarative/src/quickwidgets/quickwidgets.pro b/qtdeclarative/src/quickwidgets/quickwidgets.pro
+index 2438e577ae..85d156b8a3 100644
+--- a/qtdeclarative/src/quickwidgets/quickwidgets.pro
++++ b/qtdeclarative/src/quickwidgets/quickwidgets.pro
+@@ -7,9 +7,13 @@ DEFINES   += QT_NO_URL_CAST_FROM_STRING QT_NO_INTEGER_EVENT_COORDINATES QT_NO_FO
+ HEADERS += \
+     qquickwidget.h \
+     qquickwidget_p.h \
+-    qtquickwidgetsglobal.h
++    qtquickwidgetsglobal.h \
++    qaccessiblequickwidget_p.h \
++    qaccessiblequickwidgetfactory_p.h
+ 
+ SOURCES += \
+-    qquickwidget.cpp
++    qquickwidget.cpp \
++    qaccessiblequickwidget.cpp \
++    qaccessiblequickwidgetfactory.cpp
+ 
+ load(qt_module)
+diff --git a/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+index 3b7d74df63..b75bf820d5 100644
+--- a/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
++++ b/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+@@ -102,6 +102,7 @@ private slots:
+     void valueConversion_RegularExpression();
+     void castWithMultipleInheritance();
+     void collectGarbage();
++    void collectGarbageNestedWrappersTwoEngines();
+     void gcWithNestedDataStructure();
+     void stacktrace();
+     void numberParsing_data();
+@@ -1809,6 +1810,44 @@ void tst_QJSEngine::collectGarbage()
+     QVERIFY(ptr.isNull());
+ }
+ 
++class TestObjectContainer : public QObject
++{
++    Q_OBJECT
++    Q_PROPERTY(QObject *dummy MEMBER m_dummy CONSTANT)
++
++public:
++    TestObjectContainer() : m_dummy(new QObject(this)) {}
++
++private:
++    QObject *m_dummy;
++};
++
++void tst_QJSEngine::collectGarbageNestedWrappersTwoEngines()
++{
++    QJSEngine engine1;
++    QJSEngine engine2;
++
++    TestObjectContainer container;
++    QQmlEngine::setObjectOwnership(&container, QQmlEngine::CppOwnership);
++
++    engine1.globalObject().setProperty("foobar", engine1.newQObject(&container));
++    engine2.globalObject().setProperty("foobar", engine2.newQObject(&container));
++
++    engine1.evaluate("foobar.dummy.baz = 42");
++    engine2.evaluate("foobar.dummy.baz = 43");
++
++    QCOMPARE(engine1.evaluate("foobar.dummy.baz").toInt(), 42);
++    QCOMPARE(engine2.evaluate("foobar.dummy.baz").toInt(), 43);
++
++    engine1.collectGarbage();
++    engine2.collectGarbage();
++
++    // The GC should not collect dummy object wrappers neither in engine1 nor engine2, we
++    // verify that by checking whether the baz property still has its previous value.
++    QCOMPARE(engine1.evaluate("foobar.dummy.baz").toInt(), 42);
++    QCOMPARE(engine2.evaluate("foobar.dummy.baz").toInt(), 43);
++}
++
+ void tst_QJSEngine::gcWithNestedDataStructure()
+ {
+     // The GC must be able to traverse deeply nested objects, otherwise this
+diff --git a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml
+new file mode 100644
+index 0000000000..206133bb39
+--- /dev/null
++++ b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml
+@@ -0,0 +1,11 @@
++import QtQuick 2.8
++
++ListView {
++    id: root
++    width: 200
++    height: 200
++
++    delegate: Text {
++        text: display
++    }
++}
+diff --git a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
+index 35f1e2c94d..1722447830 100644
+--- a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
++++ b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
+@@ -27,6 +27,8 @@
+ ****************************************************************************/
+ 
+ #include <QtTest/qtest.h>
++#include <QtCore/QConcatenateTablesProxyModel>
++#include <QtGui/QStandardItemModel>
+ #include <QtQml/qqmlcomponent.h>
+ #include <QtQmlModels/private/qqmldelegatemodel_p.h>
+ #include <QtQuick/qquickview.h>
+@@ -47,6 +49,7 @@ private slots:
+     void filterOnGroup_removeWhenCompleted();
+     void qtbug_86017();
+     void contextAccessedByHandler();
++    void redrawUponColumnChange();
+ };
+ 
+ class AbstractItemModel : public QAbstractItemModel
+@@ -186,6 +189,30 @@ void tst_QQmlDelegateModel::contextAccessedByHandler()
+     QVERIFY(root->property("works").toBool());
+ }
+ 
++void tst_QQmlDelegateModel::redrawUponColumnChange()
++{
++    QStandardItemModel m1;
++    m1.appendRow({
++            new QStandardItem("Banana"),
++            new QStandardItem("Coconut"),
++    });
++
++    QQuickView view(testFileUrl("redrawUponColumnChange.qml"));
++    QCOMPARE(view.status(), QQuickView::Ready);
++    view.show();
++    QQuickItem *root = view.rootObject();
++    root->setProperty("model", QVariant::fromValue<QObject *>(&m1));
++
++    QObject *item = root->property("currentItem").value<QObject *>();
++    QVERIFY(item);
++    QCOMPARE(item->property("text").toString(), "Banana");
++
++    QVERIFY(root);
++    m1.removeColumn(0);
++
++    QCOMPARE(item->property("text").toString(), "Coconut");
++}
++
+ QTEST_MAIN(tst_QQmlDelegateModel)
+ 
+ #include "tst_qqmldelegatemodel.moc"
+diff --git a/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp b/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
+index 5d635aa63b..824fd89e5b 100644
+--- a/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
++++ b/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
+@@ -76,10 +76,10 @@ void tst_qv4mm::multiWrappedQObjects()
+         QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 1);
+         QCOMPARE(engine2.memoryManager->m_pendingFreedObjectWrapperValue.size(), 0);
+ 
+-        // Moves the additional WeakValue from m_multiplyWrappedQObjects to
+-        // m_pendingFreedObjectWrapperValue. It's still alive after all.
++        // The additional WeakValue from m_multiplyWrappedQObjects hasn't been moved
++        // to m_pendingFreedObjectWrapperValue yet. It's still alive after all.
+         engine1.memoryManager->runGC();
+-        QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 2);
++        QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 1);
+ 
+         // engine2 doesn't own the object as engine1 was the first to wrap it above.
+         // Therefore, no effect here.
+diff --git a/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml b/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml
+new file mode 100644
+index 0000000000..889e480f3b
+--- /dev/null
++++ b/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml
+@@ -0,0 +1,13 @@
++import QtQuick 2.6
++
++Item {
++    visible: true
++    Item {
++        visible: false
++        Item {
++            objectName: "hiddenChild"
++            activeFocusOnTab: true
++            focus: true
++        }
++    }
++}
+diff --git a/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp b/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+index c8f251dbe1..c8ef36ee68 100644
+--- a/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
++++ b/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+@@ -67,6 +67,7 @@ private slots:
+     void activeFocusOnTab10();
+     void activeFocusOnTab_infiniteLoop_data();
+     void activeFocusOnTab_infiniteLoop();
++    void activeFocusOnTab_infiniteLoopControls();
+ 
+     void nextItemInFocusChain();
+     void nextItemInFocusChain2();
+@@ -1057,6 +1058,17 @@ void tst_QQuickItem::activeFocusOnTab_infiniteLoop()
+     QCOMPARE(item, window->rootObject());
+ }
+ 
++
++void tst_QQuickItem::activeFocusOnTab_infiniteLoopControls()
++{
++    auto source = testFileUrl("activeFocusOnTab_infiniteLoop3.qml");
++    QScopedPointer<QQuickView>window(new QQuickView());
++    window->setSource(source);
++    window->show();
++    QVERIFY(window->errors().isEmpty());
++    QTest::keyClick(window.get(), Qt::Key_Tab); // should not hang
++}
++
+ void tst_QQuickItem::nextItemInFocusChain()
+ {
+     if (!qt_tab_all_widgets())
+Submodule qtdoc c0c7bf07...79d6ef69:
+Submodule qtimageformats 2dcf2899..abe44c0f:
+diff --git a/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp b/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
+index dde783c..1bf9074 100644
+--- a/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
+@@ -462,8 +462,12 @@ static bool parseIconEntryInfo(ICNSEntry &icon)
+     if (isIconCompressed(icon))
+         return true;
+     // Icon depth:
+-    if (!depth.isEmpty())
+-        icon.depth = ICNSEntry::Depth(depth.toUInt());
++    if (!depth.isEmpty()) {
++        const uint depthUInt = depth.toUInt();
++        if (depthUInt > 32)
++            return false;
++        icon.depth = ICNSEntry::Depth(depthUInt);
++    }
+     // Try mono if depth not found
+     if (icon.depth == ICNSEntry::DepthUnknown)
+         icon.depth = ICNSEntry::DepthMono;
+@@ -515,6 +519,9 @@ static bool parseIconEntryInfo(ICNSEntry &icon)
+         }
+         icon.height = icon.width;
+     }
++    // Sanity check
++    if (icon.width == 0 || icon.width > 4096)
++        return false;
+     return true;
+ }
+ 
+@@ -685,7 +692,7 @@ bool QICNSHandler::canRead() const
+ bool QICNSHandler::read(QImage *outImage)
+ {
+     QImage img;
+-    if (!ensureScanned()) {
++    if (!ensureScanned() || m_currentIconIndex >= m_icons.size()) {
+         qWarning("QICNSHandler::read(): The device wasn't parsed properly!");
+         return false;
+     }
+@@ -892,7 +899,7 @@ bool QICNSHandler::scanDevice()
+             return false;
+ 
+         const qint64 blockDataOffset = device()->pos();
+-        if (!isBlockHeaderValid(blockHeader)) {
++        if (!isBlockHeaderValid(blockHeader, ICNSBlockHeaderSize + filelength - blockDataOffset)) {
+             qWarning("QICNSHandler::scanDevice(): Failed, bad header at pos %s. OSType \"%s\", length %u",
+                      QByteArray::number(blockDataOffset).constData(),
+                      nameFromOSType(blockHeader.ostype).constData(), blockHeader.length);
+@@ -927,11 +934,14 @@ bool QICNSHandler::scanDevice()
+         case ICNSBlockHeader::TypeOdrp:
+             // Icns container seems to have an embedded icon variant container
+             // Let's start a scan for entries
+-            while (device()->pos() < nextBlockOffset) {
++            while (!stream.atEnd() && device()->pos() < nextBlockOffset) {
+                 ICNSBlockHeader icon;
+                 stream >> icon;
++                if (stream.status() != QDataStream::Ok)
++                    return false;
+                 // Check for incorrect variant entry header and stop scan
+-                if (!isBlockHeaderValid(icon, blockDataLength))
++                quint64 remaining = blockDataLength - (device()->pos() - blockDataOffset);
++                if (!isBlockHeaderValid(icon, ICNSBlockHeaderSize + remaining))
+                     break;
+                 if (!addEntry(icon, device()->pos(), blockHeader.ostype))
+                     return false;
+@@ -1003,7 +1013,7 @@ bool QICNSHandler::scanDevice()
+             break;
+         }
+     }
+-    return true;
++    return (m_icons.size() > 0);
+ }
+ 
+ const ICNSEntry &QICNSHandler::getIconMask(const ICNSEntry &icon) const
+diff --git a/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp b/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
+index 5082023..cb34374 100644
+--- a/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
++++ b/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
+@@ -43,6 +43,7 @@
+ #include "qimage.h"
+ #include "qvariant.h"
+ #include "qcolor.h"
++#include "qimagereader.h"
+ 
+ #include <jasper/jasper.h>
+ #include <math.h> // for pow
+@@ -333,16 +334,46 @@ private:
+ Jpeg2000JasperReader::Jpeg2000JasperReader(QIODevice *iod, SubFormat format)
+     : jasperOk(true), ioDevice(iod), format(format), hasAlpha(false)
+ {
++#if JAS_VERSION_MAJOR < 3
+     if (jas_init()) {
+         jasperOk = false;
+         qDebug("Jasper Library initialization failed");
+     }
++#else
++    jas_conf_clear();
++#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
++    jas_conf_set_max_mem_usage(QImageReader::allocationLimit() * 1024 * 1024);
++#else
++    // 128MB seems to be enough.
++    jas_conf_set_max_mem_usage(128 * 1024 * 1024);
++#endif
++    if (jas_init_library()) {
++        jasperOk = false;
++        qDebug("Jasper library initialization failed");
++    }
++    if (jas_init_thread()) {
++        jas_cleanup_library();
++        jasperOk = false;
++        qDebug("Jasper thread initialization failed");
++    }
++#endif
+ }
+ 
+ Jpeg2000JasperReader::~Jpeg2000JasperReader()
+ {
++#if JAS_VERSION_MAJOR < 3
+     if (jasperOk)
+         jas_cleanup();
++#else
++    if (jasperOk) {
++        if (jas_cleanup_thread()) {
++            qDebug("Jasper thread cleanup failed");
++        }
++        if (jas_cleanup_library()) {
++            qDebug("Jasper library cleanup failed");
++        }
++    }
++#endif
+ }
+ 
+ /*! \internal
+@@ -857,7 +888,7 @@ bool Jpeg2000JasperReader::write(const QImage &image, int quality)
+     }
+ 
+     // Open an empty jasper stream that grows automatically
+-    jas_stream_t * memory_stream = jas_stream_memopen(0, -1);
++    jas_stream_t * memory_stream = jas_stream_memopen(0, 0);
+ 
+     // Jasper wants a non-const string.
+     char *str = qstrdup(jasperFormatString.toLatin1().constData());
+diff --git a/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp b/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
+index 1386750..ac8956c 100644
+--- a/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
+@@ -361,6 +361,8 @@ bool QTiffHandler::read(QImage *image)
+     }
+ 
+     TIFF *const tiff = d->tiff;
++    if (TIFFIsTiled(tiff) && TIFFTileSize64(tiff) > uint64_t(image->sizeInBytes())) // Corrupt image
++        return false;
+     const quint32 width = d->size.width();
+     const quint32 height = d->size.height();
+ 
+diff --git a/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp b/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
+index 82d38cb..d02eb05 100644
+--- a/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
+@@ -45,6 +45,7 @@
+ #include <qdebug.h>
+ #include <qpainter.h>
+ #include <qvariant.h>
++#include <QtEndian>
+ 
+ static const int riffHeaderSize = 12; // RIFF_HEADER_SIZE from webp/format_constants.h
+ 
+@@ -102,21 +103,23 @@ bool QWebpHandler::ensureScanned() const
+ 
+     m_scanState = ScanError;
+ 
+-    if (device()->isSequential()) {
+-        qWarning() << "Sequential devices are not supported";
++    QWebpHandler *that = const_cast<QWebpHandler *>(this);
++    const int headerBytesNeeded = sizeof(WebPBitstreamFeatures);
++    QByteArray header = device()->peek(headerBytesNeeded);
++    if (header.size() < headerBytesNeeded)
+         return false;
+-    }
+ 
+-    qint64 oldPos = device()->pos();
+-    device()->seek(0);
+-
+-    QWebpHandler *that = const_cast<QWebpHandler *>(this);
+-    QByteArray header = device()->peek(sizeof(WebPBitstreamFeatures));
++    // We do no random access during decoding, just a readAll() of the whole image file. So if
++    // if it is all available already, we can accept a sequential device. The riff header contains
++    // the file size minus 8 bytes header
++    qint64 byteSize = qFromLittleEndian<quint32>(header.constData() + 4);
++    if (device()->isSequential() && device()->bytesAvailable() < byteSize + 8) {
++        qWarning() << "QWebpHandler: Insufficient data available in sequential device";
++        return false;
++    }
+     if (WebPGetFeatures((const uint8_t*)header.constData(), header.size(), &(that->m_features)) == VP8_STATUS_OK) {
+         if (m_features.has_animation) {
+             // For animation, we have to read and scan whole file to determine loop count and images count
+-            device()->seek(oldPos);
+-
+             if (that->ensureDemuxer()) {
+                 that->m_loop = WebPDemuxGetI(m_demuxer, WEBP_FF_LOOP_COUNT);
+                 that->m_frameCount = WebPDemuxGetI(m_demuxer, WEBP_FF_FRAME_COUNT);
+@@ -126,17 +129,13 @@ bool QWebpHandler::ensureScanned() const
+                 if (that->m_features.has_alpha)
+                     that->m_composited->fill(Qt::transparent);
+ 
+-                // We do not reset device position since we have read in all data
+                 m_scanState = ScanSuccess;
+-                return true;
+             }
+         } else {
+             m_scanState = ScanSuccess;
+         }
+     }
+ 
+-    device()->seek(oldPos);
+-
+     return m_scanState == ScanSuccess;
+ }
+ 
+@@ -159,7 +158,7 @@ bool QWebpHandler::ensureDemuxer()
+ 
+ bool QWebpHandler::read(QImage *image)
+ {
+-    if (!ensureScanned() || device()->isSequential() || !ensureDemuxer())
++    if (!ensureScanned() || !ensureDemuxer())
+         return false;
+ 
+     QRect prevFrameRect;
+Submodule qtlocation 98a5c511..f991e28c:
+diff --git a/qtlocation/src/location/configure.json b/qtlocation/src/location/configure.json
+index 6d01a9a3..d1e623a1 100644
+--- a/qtlocation/src/location/configure.json
++++ b/qtlocation/src/location/configure.json
+@@ -9,7 +9,7 @@
+             "label": "Qt.labs.location experimental QML plugin",
+             "purpose": "Provides experimental QtLocation QML types",
+             "section": "Location",
+-            "condition": "config.opengl",
++            "condition": "features.opengl",
+             "output": [ "privateFeature" ]
+         },
+         "geoservices_osm": {
+diff --git a/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp b/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
+index a978573d..11e1466f 100644
+--- a/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
++++ b/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
+@@ -158,7 +158,7 @@ void QGeoMapObjectQSGSupport::updateMapObjects(QSGNode *root, QQuickWindow *wind
+     if (!root)
+         return;
+ 
+-    if (m_mapObjectsRootNode && m_mapObjectsRootNode->parent())
++    if (m_mapObjectsRootNode && !m_mapObjectsRootNode->parent())
+         root->appendChildNode(m_mapObjectsRootNode.get());
+ 
+     if (!m_mapObjectsRootNode) {
+diff --git a/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
+index 5a40467e..d123c6a8 100644
+--- a/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
+@@ -59,8 +59,10 @@ QT_BEGIN_NAMESPACE
+ static const QString kPrefixEsri(QStringLiteral("esri."));
+ static const QString kParamUserAgent(kPrefixEsri + QStringLiteral("useragent"));
+ 
+-static const QString kUrlGeocode(QStringLiteral("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates"));
+-static const QString kUrlReverseGeocode(QStringLiteral("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode"));
++static const QString kUrlGeocode(QStringLiteral("https://geocode.arcgis.com/arcgis/rest/services/"
++                                                "World/GeocodeServer/findAddressCandidates"));
++static const QString kUrlReverseGeocode(QStringLiteral(
++        "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode"));
+ 
+ static QString addressToQuery(const QGeoAddress &address)
+ {
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
+index 17492d94..96c12b1b 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
+@@ -46,7 +46,8 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-// JSON reference: http://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
++// JSON reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
+ 
+ static const QString kErrorMessage(QStringLiteral("Error %1: %2."));
+ static const QString kErrorJson(QStringLiteral("Error: invalide JSON document."));
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
+index 8cadfb29..92b6bb13 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
+@@ -44,7 +44,8 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-// JSON reference: http://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
++// JSON reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
+ 
+ GeoRouteReplyEsri::GeoRouteReplyEsri(QNetworkReply *reply, const QGeoRouteRequest &request,
+                                      QObject *parent) :
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
+index 0e6bc2c7..ed613f4b 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
+@@ -48,7 +48,8 @@ static const QString kPrefixEsri(QStringLiteral("esri."));
+ static const QString kParamUserAgent(kPrefixEsri + QStringLiteral("useragent"));
+ static const QString kParamToken(kPrefixEsri + QStringLiteral("token"));
+ 
+-static const QString kUrlRouting(QStringLiteral("http://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve"));
++static const QString kUrlRouting(QStringLiteral(
++        "https://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve"));
+ 
+ GeoRoutingManagerEngineEsri::GeoRoutingManagerEngineEsri(const QVariantMap &parameters,
+                                                          QGeoServiceProvider::Error *error,
+@@ -70,7 +71,8 @@ GeoRoutingManagerEngineEsri::~GeoRoutingManagerEngineEsri()
+ {
+ }
+ 
+-// REST reference: http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
++// REST reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
+ 
+ QGeoRouteReply *GeoRoutingManagerEngineEsri::calculateRoute(const QGeoRouteRequest &request)
+ {
+@@ -125,7 +127,7 @@ void GeoRoutingManagerEngineEsri::replyError(QGeoRouteReply::Error errorCode, co
+ QString GeoRoutingManagerEngineEsri::preferedDirectionLangage()
+ {
+     // list of supported langages is defined in:
+-    // http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
++    // https://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
+     const QStringList supportedLanguages = {
+         "ar", // Generate directions in Arabic
+         "cs", // Generate directions in Czech
+diff --git a/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
+index 5d15835d..24148f95 100644
+--- a/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
+@@ -230,7 +230,8 @@ QGeoMap *GeoTiledMappingManagerEngineEsri::createMap()
+ // ${y} = Y
+ // ${token} = Token
+ 
+-// template = 'http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{{z}}/{{y}}/{{x}}.png'
++// template =
++// 'https://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{{z}}/{{y}}/{{x}}.png'
+ 
+ bool GeoTiledMappingManagerEngineEsri::initializeMapSources(QGeoServiceProvider::Error *error,
+                                                             QString *errorString,
+diff --git a/qtlocation/src/plugins/geoservices/esri/maps.json b/qtlocation/src/plugins/geoservices/esri/maps.json
+index 8167ae7d..862e087d 100644
+--- a/qtlocation/src/plugins/geoservices/esri/maps.json
++++ b/qtlocation/src/plugins/geoservices/esri/maps.json
+@@ -6,8 +6,8 @@
+             "description": "ArcGIS Online World Street Map",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=3b93337983e9436f8db950e38a8629af'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=3b93337983e9436f8db950e38a8629af'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -16,8 +16,8 @@
+             "": "ArcGIS Online World Imagery",
+             "mobile": true,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -26,8 +26,8 @@
+             "description": "ArcGIS Online World Terrain Base",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=c61ad8ab017d49e1a82f580ee1298931'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=c61ad8ab017d49e1a82f580ee1298931'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -36,8 +36,8 @@
+             "description": "ArcGIS Online World Topography",
+             "mobile": true,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=30e5fe3149c34df1ba922e6f5bbf808f'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=30e5fe3149c34df1ba922e6f5bbf808f'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -46,8 +46,8 @@
+             "description": "This map presents land cover and detailed topographic maps for the United States.",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=99cd5fbd98934028802b4f797c4b1732'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=99cd5fbd98934028802b4f797c4b1732'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -56,8 +56,8 @@
+             "description": "National Geographic World Map",
+             "mobile": false,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=b9b1b422198944fbbd5250b3241691b6'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=b9b1b422198944fbbd5250b3241691b6'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -66,8 +66,8 @@
+             "description": "Thematic content providing a neutral background with minimal colors",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=ed712cb1db3e4bae9e85329040fb9a49'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=ed712cb1db3e4bae9e85329040fb9a49'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -76,8 +76,8 @@
+             "description": "Natural Earth physical map for the world",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=c4ec722a1cd34cf0a23904aadf8923a0'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=c4ec722a1cd34cf0a23904aadf8923a0'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -86,8 +86,8 @@
+             "description": "Portrays surface elevation as shaded relief",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=9c5370d0b54f4de1b48a3792d7377ff2'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=9c5370d0b54f4de1b48a3792d7377ff2'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -96,8 +96,8 @@
+             "description": "This map is designed to be used as a basemap by marine GIS professionals and as a reference map by anyone interested in ocean data",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=1e126e7520f9466c9ca28b8f28b5e500'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=1e126e7520f9466c9ca28b8f28b5e500'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -106,8 +106,8 @@
+             "description": "Thematic content providing a neutral background with minimal colors",
+             "mobile": false,
+             "night": true,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=a284a9b99b3446a3910d4144a50990f6'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=a284a9b99b3446a3910d4144a50990f6'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -116,8 +116,8 @@
+             "description": "DeLorme’s topographic basemap is a seamless global data set that portrays transportation, hydrography, jurisdiction boundaries, and major geographic features",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/Specialty/DeLorme_World_Base_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=b165c3df453e4be6b5ac4fdb241effbe'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/Specialty/DeLorme_World_Base_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=b165c3df453e4be6b5ac4fdb241effbe'>Esri</a> contributors"
+         }
+     ]
+ }
+diff --git a/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
+index 3858ddf5..af66f28e 100644
+--- a/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
+@@ -63,8 +63,10 @@ static const QString kCountriesKey(QStringLiteral("detailedCountries"));
+ static const QString kLocalizedNamesKey(QStringLiteral("localizedNames"));
+ static const QString kMaxLocationsKey(QStringLiteral("maxLocations"));
+ 
+-static const QUrl kUrlGeocodeServer("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer?f=pjson");
+-static const QUrl kUrlFindAddressCandidates("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates");
++static const QUrl kUrlGeocodeServer(
++        "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer?f=pjson");
++static const QUrl kUrlFindAddressCandidates("https://geocode.arcgis.com/arcgis/rest/services/World/"
++                                            "GeocodeServer/findAddressCandidates");
+ 
+ PlaceManagerEngineEsri::PlaceManagerEngineEsri(const QVariantMap &parameters, QGeoServiceProvider::Error *error,
+                                                QString *errorString) :
+Submodule qtmultimedia f0344079..0d7cc33a:
+diff --git a/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp b/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
+index 2b5325132..b68b4af1b 100644
+--- a/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
++++ b/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
+@@ -402,6 +402,8 @@ int QPulseAudioInput::bytesReady() const
+ 
+ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ {
++    Q_ASSERT(data != nullptr || len == 0);
++
+     m_bytesAvailable = checkBytesReady();
+ 
+     setError(QAudio::NoError);
+@@ -411,7 +413,8 @@ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ 
+     if (!m_pullMode && !m_tempBuffer.isEmpty()) {
+         readBytes = qMin(static_cast<int>(len), m_tempBuffer.size());
+-        memcpy(data, m_tempBuffer.constData(), readBytes);
++        if (readBytes)
++            memcpy(data, m_tempBuffer.constData(), readBytes);
+         m_totalTimeValue += readBytes;
+ 
+         if (readBytes < m_tempBuffer.size()) {
+@@ -502,9 +505,10 @@ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ 
+ void QPulseAudioInput::applyVolume(const void *src, void *dest, int len)
+ {
++    Q_ASSERT((src && dest) || len == 0);
+     if (m_volume < 1.f)
+         QAudioHelperInternal::qMultiplySamples(m_volume, m_format, src, dest, len);
+-    else
++    else if (len)
+         memcpy(dest, src, len);
+ }
+ 
+Submodule qtpim 02efef5e...f9a8f0fc (commits not present)
+Submodule qtquick3d b85cf622..47defc8b:
+diff --git a/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro b/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
+index ca5c499e..174a075b 100644
+--- a/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
++++ b/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
+@@ -10,7 +10,7 @@ QT_FOR_CONFIG += assetimporters-private
+ include($$OUT_PWD/../qtassetimporters-config.pri)
+ 
+ qtConfig(system-assimp):!if(cross_compile:host_build) {
+-    QMAKE_USE_PRIVATE += assimp
++    QMAKE_USE_PRIVATE += quick3d-assimp
+ } else {
+     include(../../../3rdparty/assimp/assimp.pri)
+ }
+Submodule qtquickcontrols2 3a657dc0..56ce8233:
+diff --git a/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp b/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
+index e5fe734f7..e36922775 100644
+--- a/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
++++ b/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
+@@ -38,6 +38,7 @@
+ #include "qwidgetplatformmenuitem_p.h"
+ 
+ #include <QtGui/qwindow.h>
++#include <QtGui/private/qhighdpiscaling_p.h>
+ #include <QtWidgets/qmenu.h>
+ #include <QtWidgets/qaction.h>
+ 
+@@ -145,7 +146,7 @@ void QWidgetPlatformMenu::showPopup(const QWindow *window, const QRect &targetRe
+ 
+     QPoint targetPos = targetRect.bottomLeft();
+     if (window)
+-        targetPos = window->mapToGlobal(targetPos);
++        targetPos = window->mapToGlobal(QHighDpi::fromNativeLocalPosition(targetPos, window));
+ 
+     const QWidgetPlatformMenuItem *widgetItem = qobject_cast<const QWidgetPlatformMenuItem *>(item);
+     m_menu->popup(targetPos, widgetItem ? widgetItem->action() : nullptr);
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
+index 950e4e099..b81fbea0b 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
+@@ -387,6 +387,17 @@ void QQuickAbstractButtonPrivate::itemImplicitHeightChanged(QQuickItem *item)
+         emit q->implicitIndicatorHeightChanged();
+ }
+ 
++void QQuickAbstractButtonPrivate::itemDestroyed(QQuickItem *item)
++{
++    Q_Q(QQuickAbstractButton);
++    QQuickControlPrivate::itemDestroyed(item);
++    if (item == indicator) {
++        indicator = nullptr;
++        emit q->implicitIndicatorWidthChanged();
++        emit q->implicitIndicatorHeightChanged();
++    }
++}
++
+ QQuickAbstractButton *QQuickAbstractButtonPrivate::findCheckedButton() const
+ {
+     Q_Q(const QQuickAbstractButton);
+@@ -1176,6 +1187,12 @@ QAccessible::Role QQuickAbstractButton::accessibleRole() const
+     }
+     return QAccessible::Button;
+ }
++
++void QQuickAbstractButton::accessiblePressAction()
++{
++    Q_D(QQuickAbstractButton);
++    d->trigger();
++}
+ #endif
+ 
+ QT_END_NAMESPACE
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
+index 0fa48980e..ab66220d0 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
+@@ -209,6 +209,7 @@ protected:
+ #if QT_CONFIG(accessibility)
+     void accessibilityActiveChanged(bool active) override;
+     QAccessible::Role accessibleRole() const override;
++    Q_INVOKABLE void accessiblePressAction();
+ #endif
+ 
+ private:
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
+index 9291c1a87..b729720f2 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
+@@ -109,6 +109,7 @@ public:
+ 
+     void itemImplicitWidthChanged(QQuickItem *item) override;
+     void itemImplicitHeightChanged(QQuickItem *item) override;
++    void itemDestroyed(QQuickItem *item) override;
+ 
+     // copied from qabstractbutton.cpp
+     static const int AUTO_REPEAT_DELAY = 300;
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp b/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
+index 2041e7741..8610cdfae 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
+@@ -145,7 +145,7 @@ int QQuickActionPrivate::ShortcutEntry::shortcutId() const
+ 
+ void QQuickActionPrivate::ShortcutEntry::grab(const QKeySequence &shortcut, bool enabled)
+ {
+-    if (shortcut.isEmpty())
++    if (shortcut.isEmpty() || m_shortcutId)
+         return;
+ 
+     Qt::ShortcutContext context = Qt::WindowShortcut; // TODO
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp b/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
+index f38c2b09c..6eed2a024 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
+@@ -225,6 +225,7 @@ void QQuickContainerPrivate::cleanup()
+     QObject::disconnect(contentModel, &QQmlObjectModel::countChanged, q, &QQuickContainer::countChanged);
+     QObject::disconnect(contentModel, &QQmlObjectModel::childrenChanged, q, &QQuickContainer::contentChildrenChanged);
+     delete contentModel;
++    contentModel = nullptr;
+ }
+ 
+ QQuickItem *QQuickContainerPrivate::itemAt(int index) const
+@@ -436,7 +437,7 @@ void QQuickContainerPrivate::contentChildren_clear(QQmlListProperty<QQuickItem>
+ void QQuickContainerPrivate::updateContentWidth()
+ {
+     Q_Q(QQuickContainer);
+-    if (hasContentWidth || qFuzzyCompare(contentWidth, implicitContentWidth))
++    if (hasContentWidth || qFuzzyCompare(contentWidth, implicitContentWidth) || !contentModel)
+         return;
+ 
+     contentWidth = implicitContentWidth;
+@@ -446,7 +447,7 @@ void QQuickContainerPrivate::updateContentWidth()
+ void QQuickContainerPrivate::updateContentHeight()
+ {
+     Q_Q(QQuickContainer);
+-    if (hasContentHeight || qFuzzyCompare(contentHeight, implicitContentHeight))
++    if (hasContentHeight || qFuzzyCompare(contentHeight, implicitContentHeight) || !contentModel)
+         return;
+ 
+     contentHeight = implicitContentHeight;
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp b/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
+index bbbd0e622..1f4b47343 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
+@@ -845,6 +845,13 @@ void QQuickControlPrivate::executeBackground(bool complete)
+         quickCompleteDeferred(q, backgroundName(), background);
+ }
+ 
++/*
++    \internal
++
++    Hides an item that was replaced by a newer one, rather than
++    deleting it, as the item is typically created in QML and hence
++    we don't own it.
++*/
+ void QQuickControlPrivate::hideOldItem(QQuickItem *item)
+ {
+     if (!item)
+@@ -863,6 +870,29 @@ void QQuickControlPrivate::hideOldItem(QQuickItem *item)
+ #endif
+ }
+ 
++/*
++    \internal
++
++    Named "unhide" because it's used for cases where an item
++    that was previously hidden by \l hideOldItem() wants to be
++    shown by a control again, such as a ScrollBar in ScrollView.
++*/
++void QQuickControlPrivate::unhideOldItem(QQuickControl *control, QQuickItem *item)
++{
++    Q_ASSERT(item);
++    qCDebug(lcItemManagement) << "unhiding old item" << item;
++
++    item->setVisible(true);
++    item->setParentItem(control);
++
++#if QT_CONFIG(accessibility)
++    // Add the item back in to the accessibility tree.
++    QQuickAccessibleAttached *accessible = accessibleAttached(item);
++    if (accessible)
++        accessible->setIgnored(false);
++#endif
++}
++
+ void QQuickControlPrivate::updateBaselineOffset()
+ {
+     Q_Q(QQuickControl);
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h b/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
+index 8e979079e..a6e624c91 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
+@@ -173,6 +173,7 @@ public:
+     virtual void executeBackground(bool complete = false);
+ 
+     static void hideOldItem(QQuickItem *item);
++    static void unhideOldItem(QQuickControl *control, QQuickItem *item);
+ 
+     void updateBaselineOffset();
+ 
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp b/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
+index e6db14eb5..6197d1547 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
+@@ -237,7 +237,7 @@ static QRectF alignedRect(Qt::LayoutDirection direction, Qt::Alignment alignment
+ void QQuickDialogButtonBoxPrivate::resizeContent()
+ {
+     Q_Q(QQuickDialogButtonBox);
+-    if (!contentItem)
++    if (!contentItem || !contentModel)
+         return;
+ 
+     QRectF geometry = q->boundingRect().adjusted(q->leftPadding(), q->topPadding(), -q->rightPadding(), -q->bottomPadding());
+@@ -322,6 +322,9 @@ void QQuickDialogButtonBoxPrivate::updateLayout()
+ qreal QQuickDialogButtonBoxPrivate::getContentWidth() const
+ {
+     Q_Q(const QQuickDialogButtonBox);
++    if (!contentModel)
++        return 0;
++
+     const int count = contentModel->count();
+     const qreal totalSpacing = qMax(0, count - 1) * spacing;
+     qreal totalWidth = totalSpacing;
+@@ -341,6 +344,9 @@ qreal QQuickDialogButtonBoxPrivate::getContentWidth() const
+ qreal QQuickDialogButtonBoxPrivate::getContentHeight() const
+ {
+     Q_Q(const QQuickDialogButtonBox);
++    if (!contentModel)
++        return 0;
++
+     const int count = contentModel->count();
+     qreal maxHeight = 0;
+     for (int i = 0; i < count; ++i) {
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp b/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
+index 91bd59184..0ce518f84 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
+@@ -399,8 +399,11 @@ void QQuickOverlay::itemChange(ItemChange change, const ItemChangeData &data)
+     Q_D(QQuickOverlay);
+     QQuickItem::itemChange(change, data);
+ 
+-    if (change == ItemChildAddedChange || change == ItemChildRemovedChange)
++    if (change == ItemChildAddedChange || change == ItemChildRemovedChange) {
+         setVisible(!d->allDrawers.isEmpty() || !childItems().isEmpty());
++        if (data.item->parent() == d->mouseGrabberPopup)
++            d->setMouseGrabberPopup(nullptr);
++    }
+ }
+ 
+ void QQuickOverlay::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp b/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
+index 4e2f509db..1c4b308cd 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
+@@ -797,6 +797,14 @@ void QQuickScrollBarAttachedPrivate::initHorizontal()
+     if (parent && parent == flickable->parentItem())
+         horizontal->stackAfter(flickable);
+ 
++    // If a scroll bar was previously hidden (due to e.g. setting a new contentItem
++    // on a ScrollView), we need to make sure that we un-hide it.
++    // We don't bother checking if the item is actually the old one, because
++    // if it's not, all of the things the function does (setting parent, visibility, etc.)
++    // should be no-ops anyway.
++    if (auto control = qobject_cast<QQuickControl*>(q_ptr->parent()))
++        QQuickControlPrivate::unhideOldItem(control, horizontal);
++
+     layoutHorizontal();
+     horizontal->setSize(area->property("widthRatio").toReal());
+     horizontal->setPosition(area->property("xPosition").toReal());
+@@ -818,6 +826,9 @@ void QQuickScrollBarAttachedPrivate::initVertical()
+     if (parent && parent == flickable->parentItem())
+         vertical->stackAfter(flickable);
+ 
++    if (auto control = qobject_cast<QQuickControl*>(q_ptr->parent()))
++        QQuickControlPrivate::unhideOldItem(control, vertical);
++
+     layoutVertical();
+     vertical->setSize(area->property("heightRatio").toReal());
+     vertical->setPosition(area->property("yPosition").toReal());
+diff --git a/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml b/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
+index 0e8b08352..cd4931184 100644
+--- a/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
++++ b/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
+@@ -576,4 +576,51 @@ TestCase {
+         verify(newHorizontalScrollBar.visible)
+         verify(!oldHorizontalScrollBar.visible)
+     }
++
++    Component {
++        id: bindingToContentItemAndStandaloneFlickable
++
++        Item {
++            width: 200
++            height: 200
++
++            property alias scrollView: scrollView
++
++            ScrollView {
++                id: scrollView
++                anchors.fill: parent
++                contentItem: listView
++
++                property Item someBinding: contentItem
++            }
++            ListView {
++                id: listView
++                model: 10
++                delegate: ItemDelegate {
++                    text: modelData
++                    width: listView.width
++                }
++            }
++        }
++    }
++
++    // Tests that scroll bars show up for a ScrollView where
++    // - its contentItem is declared as a standalone, separate item
++    // - there is a binding to contentItem (which causes a default Flickable to be created)
++    function test_bindingToContentItemAndStandaloneFlickable() {
++        let root = createTemporaryObject(bindingToContentItemAndStandaloneFlickable, testCase)
++        verify(root)
++
++        let control = root.scrollView
++        let verticalScrollBar = control.ScrollBar.vertical
++        let horizontalScrollBar = control.ScrollBar.horizontal
++        compare(verticalScrollBar.parent, control)
++        compare(horizontalScrollBar.parent, control)
++        verify(verticalScrollBar.visible)
++        verify(horizontalScrollBar.visible)
++
++        mouseDrag(verticalScrollBar, verticalScrollBar.width / 2, verticalScrollBar.height / 2, 0, 50)
++        verify(verticalScrollBar.active)
++        verify(horizontalScrollBar.active)
++    }
+ }
+diff --git a/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml b/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
+index b3fab41ca..10b6baa02 100644
+--- a/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
++++ b/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
+@@ -608,4 +608,27 @@ TestCase {
+         mouseClick(control.indicator)
+         verify(control.activeFocus)
+     }
++
++    Component {
++        id: deletionOrder1
++        Item {
++            Image { id: innerImage }
++            Switch { indicator: innerImage }
++        }
++    }
++
++    Component {
++        id: deletionOrder2
++        Item {
++            Switch { indicator: innerImage }
++            Image { id: innerImage }
++        }
++    }
++
++    function test_deletionOrder() {
++        var control1 = createTemporaryObject(deletionOrder1, testCase)
++        verify(control1)
++        var control2 = createTemporaryObject(deletionOrder2, testCase)
++        verify(control2)
++    }
+ }
+diff --git a/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml b/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml
+new file mode 100644
+index 000000000..9e4598b9f
+--- /dev/null
++++ b/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml
+@@ -0,0 +1,78 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the test suite of the Qt Toolkit.
++**
++** $QT_BEGIN_LICENSE:BSD$
++** Commercial License Usage
++** Licensees holding valid commercial Qt licenses may use this file in
++** accordance with the commercial license agreement provided with the
++** Software or, alternatively, in accordance with the terms contained in
++** a written agreement between you and The Qt Company. For licensing terms
++** and conditions see https://www.qt.io/terms-conditions. For further
++** information use the contact form at https://www.qt.io/contact-us.
++**
++** BSD License Usage
++** Alternatively, you may use this file under the terms of the BSD license
++** as follows:
++**
++** "Redistribution and use in source and binary forms, with or without
++** modification, are permitted provided that the following conditions are
++** met:
++**   * Redistributions of source code must retain the above copyright
++**     notice, this list of conditions and the following disclaimer.
++**   * Redistributions in binary form must reproduce the above copyright
++**     notice, this list of conditions and the following disclaimer in
++**     the documentation and/or other materials provided with the
++**     distribution.
++**   * Neither the name of The Qt Company Ltd nor the names of its
++**     contributors may be used to endorse or promote products derived
++**     from this software without specific prior written permission.
++**
++**
++** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
++** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
++** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
++** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
++** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
++** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
++** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
++** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
++** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
++** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
++** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
++**
++** $QT_END_LICENSE$
++**
++****************************************************************************/
++
++import QtQuick 2.15
++import QtQuick.Controls 2.15
++
++ApplicationWindow {
++    id: window
++    width: 400
++    height: 400
++    title: "releaseAfterExitTransition"
++
++    property alias popup: popup
++    property alias modalPopup: modalPopup
++
++    Popup {
++        id: popup
++        y: parent.height - height
++        width: 50
++        height: 50
++    }
++
++    Popup {
++        id: modalPopup
++        modal: true
++        y: parent.height - height
++        width: 50
++        height: 50
++        exit:  Transition { PauseAnimation { duration: 100 } }
++    }
++}
+diff --git a/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp b/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
+index 54952d128..3d50e2dd4 100644
+--- a/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
++++ b/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
+@@ -100,6 +100,7 @@ private slots:
+     void invisibleToolTipOpen();
+     void centerInOverlayWithinStackViewItem();
+     void destroyDuringExitTransition();
++    void releaseAfterExitTransition();
+ };
+ 
+ void tst_QQuickPopup::initTestCase()
+@@ -1575,6 +1576,34 @@ void tst_QQuickPopup::destroyDuringExitTransition()
+     QVERIFY(!button->isDown());
+ }
+ 
++void tst_QQuickPopup::releaseAfterExitTransition()
++{
++    QQuickApplicationHelper helper(this, "releaseAfterExitTransition.qml");
++    QVERIFY2(helper.ready, helper.failureMessage());
++
++    QQuickWindow *window = helper.window;
++    window->show();
++    QVERIFY(QTest::qWaitForWindowActive(window));
++
++    QQuickOverlay *overlay = QQuickOverlay::overlay(window);
++    QQuickPopup *modalPopup = window->property("modalPopup").value<QQuickPopup *>();
++    QQuickPopup *popup = window->property("popup").value<QQuickPopup *>();
++
++    modalPopup->open();
++    QTRY_VERIFY(modalPopup->isOpened());
++
++    QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++    // wait until the transition is finished and the overlay hides itself
++    QTRY_VERIFY(!overlay->isVisible());
++    QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++
++    popup->open();
++    QTRY_VERIFY(popup->isOpened());
++    QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++    QTRY_VERIFY(!popup->isOpened());
++}
++
++
+ QTEST_QUICKCONTROLS_MAIN(tst_QQuickPopup)
+ 
+ #include "tst_qquickpopup.moc"
+Submodule qtscript 5be95f96...4d8e4bd2 (commits not present)
+Submodule qtspeech 17fc9fde..255845e2:
+diff --git a/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp b/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
+index 6eb74b8..bcc7dd1 100644
+--- a/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
++++ b/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
+@@ -357,7 +357,9 @@ QVector<QLocale> QTextToSpeechEngineSpeechd::availableLocales() const
+ 
+ QVector<QVoice> QTextToSpeechEngineSpeechd::availableVoices() const
+ {
+-    return m_voices.values(m_currentLocale.name()).toVector();
++    QList<QVoice> resultList = m_voices.values(m_currentLocale.name());
++    std::reverse(resultList.begin(), resultList.end());
++    return resultList.toVector();
+ }
+ 
+ // We have no way of knowing our own client_id since speech-dispatcher seems to be incomplete
+Submodule qtsvg 0c05780e..a7a0f249:
+diff --git a/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp b/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
+index 561e77e..12e0574 100644
+--- a/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
++++ b/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
+@@ -191,6 +191,8 @@ bool QSvgIOHandler::read(QImage *image)
+             }
+         }
+         if (!finalSize.isEmpty()) {
++            if (qMax(finalSize.width(), finalSize.height()) > 0xffff)
++                return false; // Assume corrupted file
+             image->fill(d->backColor.rgba());
+             QPainter p(image);
+             d->r.render(&p, bounds);
+diff --git a/qtsvg/src/svg/qsvghandler.cpp b/qtsvg/src/svg/qsvghandler.cpp
+index a5f877f..8dda563 100644
+--- a/qtsvg/src/svg/qsvghandler.cpp
++++ b/qtsvg/src/svg/qsvghandler.cpp
+@@ -1393,9 +1393,10 @@ static void parseFont(QSvgNode *node,
+         case FontSizeNone:
+             break;
+         case FontSizeValue: {
+-            QSvgHandler::LengthType dummy; // should always be pixel size
+-            fontStyle->setSize(qMin(parseLength(attributes.fontSize, dummy, handler),
+-                                    qreal(0xffff)));
++            QSvgHandler::LengthType type;
++            qreal fs = parseLength(attributes.fontSize, type, handler);
++            fs = convertToPixels(fs, true, type);
++            fontStyle->setSize(qMin(fs, qreal(0xffff)));
+         }
+             break;
+         default:
+@@ -2513,6 +2514,8 @@ static bool parseAnimateTransformNode(QSvgNode *parent,
+             ++s;
+         }
+     }
++    if (vals.count() % 3 != 0)
++        return false;
+ 
+     bool ok = true;
+     int begin = parseClockValue(beginStr, &ok);
+@@ -2576,6 +2579,8 @@ static QSvgNode *createCircleNode(QSvgNode *parent,
+     qreal ncx = toDouble(cx);
+     qreal ncy = toDouble(cy);
+     qreal nr  = toDouble(r);
++    if (nr < 0.0)
++        return nullptr;
+ 
+     QRectF rect(ncx-nr, ncy-nr, nr*2, nr*2);
+     QSvgNode *circle = new QSvgCircle(parent, rect);
+@@ -3046,15 +3051,16 @@ static QSvgStyleProperty *createRadialGradientNode(QSvgNode *node,
+ 
+     qreal ncx = 0.5;
+     qreal ncy = 0.5;
+-    qreal nr  = 0.5;
+     if (!cx.isEmpty())
+         ncx = toDouble(cx);
+     if (!cy.isEmpty())
+         ncy = toDouble(cy);
++
++    qreal nr = 0.0;
+     if (!r.isEmpty())
+         nr = toDouble(r);
+-    if (nr < 0.5)
+-        nr = 0.5;
++    if (nr <= 0.0)
++        return nullptr;
+ 
+     qreal nfx = ncx;
+     if (!fx.isEmpty())
+@@ -3350,7 +3356,9 @@ static QSvgNode *createTextNode(QSvgNode *parent,
+     //### editable and rotate not handled
+     QSvgHandler::LengthType type;
+     qreal nx = parseLength(x, type, handler);
++    nx = convertToPixels(nx, true, type);
+     qreal ny = parseLength(y, type, handler);
++    ny = convertToPixels(ny, true, type);
+ 
+     QSvgNode *text = new QSvgText(parent, QPointF(nx, ny));
+     return text;
+@@ -3691,9 +3699,7 @@ void QSvgHandler::parse()
+         case QXmlStreamReader::EndElement:
+             endElement(xml->name());
+             ++remainingUnfinishedElements;
+-            // if we are using somebody else's qxmlstreamreader
+-            // we should not read until the end of the stream
+-            done = !m_ownsReader && (xml->name() == QLatin1String("svg"));
++            done = (xml->name() == QLatin1String("svg"));
+             break;
+         case QXmlStreamReader::Characters:
+             characters(xml->text());
+diff --git a/qtsvg/src/svg/qsvgstructure.cpp b/qtsvg/src/svg/qsvgstructure.cpp
+index b89608b..89c9e4e 100644
+--- a/qtsvg/src/svg/qsvgstructure.cpp
++++ b/qtsvg/src/svg/qsvgstructure.cpp
+@@ -255,9 +255,13 @@ inline static bool isSupportedSvgFeature(const QString &str)
+     };
+ 
+     if (str.length() <= MAX_WORD_LENGTH && str.length() >= MIN_WORD_LENGTH) {
++        const char16_t unicode44 = str.at(44).unicode();
++        const char16_t unicode45 = str.at(45).unicode();
++        if (unicode44 >= sizeof(asso_values) || unicode45 >= sizeof(asso_values))
++            return false;
+         const int key = str.length()
+-                        + asso_values[str.at(45).unicode()]
+-                        + asso_values[str.at(44).unicode()];
++                        + asso_values[unicode45]
++                        + asso_values[unicode44];
+         if (key <= MAX_HASH_VALUE && key >= 0)
+             return str == QLatin1String(wordlist[key]);
+     }
+diff --git a/qtsvg/src/svg/qsvgtinydocument.cpp b/qtsvg/src/svg/qsvgtinydocument.cpp
+index 63d0797..19e7154 100644
+--- a/qtsvg/src/svg/qsvgtinydocument.cpp
++++ b/qtsvg/src/svg/qsvgtinydocument.cpp
+@@ -433,8 +433,16 @@ void QSvgTinyDocument::draw(QPainter *p, QSvgExtraStates &)
+     draw(p);
+ }
+ 
++static bool isValidMatrix(const QTransform &transform)
++{
++    qreal determinant = transform.determinant();
++    return qIsFinite(determinant);
++}
++
+ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect, const QRectF &sourceRect)
+ {
++    QTransform oldTransform = p->worldTransform();
++
+     QRectF target = targetRect;
+     if (target.isEmpty()) {
+         QPaintDevice *dev = p->device();
+@@ -487,6 +495,9 @@ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect,
+         }
+ #endif
+     }
++
++    if (!isValidMatrix(p->worldTransform()))
++        p->setWorldTransform(oldTransform);
+ }
+ 
+ QRectF QSvgTinyDocument::boundsOnElement(const QString &id) const
+diff --git a/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp b/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
+index 36c76ec..db71e02 100644
+--- a/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
++++ b/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
+@@ -86,6 +86,8 @@ private slots:
+     void oss_fuzz_23731();
+     void oss_fuzz_24131();
+     void oss_fuzz_24738();
++    void illegalAnimateTransform_data();
++    void illegalAnimateTransform();
+ 
+ #ifndef QT_NO_COMPRESS
+     void testGzLoading();
+@@ -1646,5 +1648,22 @@ void tst_QSvgRenderer::oss_fuzz_24738()
+     QSvgRenderer().load(QByteArray("<svg><path d=\"a 2 1e-212.....\">"));
+ }
+ 
++void tst_QSvgRenderer::illegalAnimateTransform_data()
++{
++    QTest::addColumn<QByteArray>("svg");
++
++    QTest::newRow("case1") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" values=\"8,0,5,0\">");
++    QTest::newRow("case2") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" values=\"1,2\">");
++    QTest::newRow("case3") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" from=\".. 5 2\" to=\"f\">");
++    QTest::newRow("case4") << QByteArray("<svg><animateTransform type=\"scale\" begin=\"1\" dur=\"2\" by=\"--,..\">");
++}
++
++void tst_QSvgRenderer::illegalAnimateTransform()
++{
++    QFETCH(QByteArray, svg);
++    QSvgRenderer renderer;
++    QVERIFY(!renderer.load(svg)); // also shouldn't assert
++}
++
+ QTEST_MAIN(tst_QSvgRenderer)
+ #include "tst_qsvgrenderer.moc"
+Submodule qttools 6914f7c8..090e526e:
+diff --git a/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp b/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
+index feab1e2d5..cbfb82507 100644
+--- a/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
++++ b/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
+@@ -445,7 +445,9 @@ bool HelpGeneratorPrivate::insertFiles(const QStringList &files, const QString &
+     if (filterSetId < 0)
+         return false;
+     ++filterSetId;
+-    for (int attId : qAsConst(filterAtts)) {
++    QList<int> attValues = filterAtts.values();
++    std::sort(attValues.begin(), attValues.end());
++    for (int attId : qAsConst(attValues)) {
+         m_query->prepare(QLatin1String("INSERT INTO FileAttributeSetTable "
+             "VALUES(?, ?)"));
+         m_query->bindValue(0, filterSetId);
+Submodule qtwayland dfb0129c..2904e1b3:
+diff --git a/qtwayland/src/client/configure.json b/qtwayland/src/client/configure.json
+index 2f424580..29222357 100644
+--- a/qtwayland/src/client/configure.json
++++ b/qtwayland/src/client/configure.json
+@@ -149,8 +149,7 @@
+                     "#endif"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "vulkan-server-buffer": {
+             "label": "Vulkan Buffer Sharing",
+@@ -168,7 +167,8 @@
+                     "exportAllocInfo.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR;",
+                     "return 0;"
+                 ]
+-            }
++            },
++            "use": "wayland-client"
+         },
+         "egl_1_5-wayland": {
+             "label": "EGL 1.5 with Wayland Platform",
+@@ -183,7 +183,7 @@
+                     "eglGetPlatformDisplay(EGL_PLATFORM_WAYLAND_EXT, (struct wl_display *)(nullptr), nullptr);"
+                 ]
+             },
+-            "use": "egl"
++            "use": "egl wayland-client"
+         }
+     },
+ 
+diff --git a/qtwayland/src/client/global/qwaylandclientextension.cpp b/qtwayland/src/client/global/qwaylandclientextension.cpp
+index 125b1e19..edccfe63 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension.cpp
++++ b/qtwayland/src/client/global/qwaylandclientextension.cpp
+@@ -74,7 +74,10 @@ void QWaylandClientExtensionPrivate::handleRegistryGlobal(void *data, ::wl_regis
+ void QWaylandClientExtension::addRegistryListener()
+ {
+     Q_D(QWaylandClientExtension);
+-    d->waylandIntegration->display()->addRegistryListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++    if (!d->registered) {
++        d->waylandIntegration->display()->addRegistryListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++        d->registered = true;
++    }
+ }
+ 
+ QWaylandClientExtension::QWaylandClientExtension(const int ver)
+@@ -88,6 +91,13 @@ QWaylandClientExtension::QWaylandClientExtension(const int ver)
+     QMetaObject::invokeMethod(this, "addRegistryListener", Qt::QueuedConnection);
+ }
+ 
++QWaylandClientExtension::~QWaylandClientExtension()
++{
++    Q_D(QWaylandClientExtension);
++    if (d->registered && !QCoreApplication::closingDown())
++        d->waylandIntegration->display()->removeListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++}
++
+ QtWaylandClient::QWaylandIntegration *QWaylandClientExtension::integration() const
+ {
+     Q_D(const QWaylandClientExtension);
+diff --git a/qtwayland/src/client/global/qwaylandclientextension.h b/qtwayland/src/client/global/qwaylandclientextension.h
+index 98272e57..5bd28398 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension.h
++++ b/qtwayland/src/client/global/qwaylandclientextension.h
+@@ -63,6 +63,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandClientExtension : public QObject
+     Q_PROPERTY(bool active READ isActive NOTIFY activeChanged)
+ public:
+     QWaylandClientExtension(const int version);
++    ~QWaylandClientExtension();
+ 
+     QtWaylandClient::QWaylandIntegration *integration() const;
+     int version() const;
+diff --git a/qtwayland/src/client/global/qwaylandclientextension_p.h b/qtwayland/src/client/global/qwaylandclientextension_p.h
+index 69cc46a0..9091efbe 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension_p.h
++++ b/qtwayland/src/client/global/qwaylandclientextension_p.h
+@@ -68,6 +68,7 @@ public:
+     QtWaylandClient::QWaylandIntegration *waylandIntegration = nullptr;
+     int version = -1;
+     bool active = false;
++    bool registered = false;
+ };
+ 
+ class Q_WAYLAND_CLIENT_EXPORT QWaylandClientExtensionTemplatePrivate : public QWaylandClientExtensionPrivate
+diff --git a/qtwayland/src/client/qwaylanddatadevice.cpp b/qtwayland/src/client/qwaylanddatadevice.cpp
+index 7e2e3308..e3e60ed5 100644
+--- a/qtwayland/src/client/qwaylanddatadevice.cpp
++++ b/qtwayland/src/client/qwaylanddatadevice.cpp
+@@ -72,6 +72,8 @@ QWaylandDataDevice::QWaylandDataDevice(QWaylandDataDeviceManager *manager, QWayl
+ 
+ QWaylandDataDevice::~QWaylandDataDevice()
+ {
++    if (wl_data_device_get_version(object()) >= WL_DATA_DEVICE_RELEASE_SINCE_VERSION)
++        release();
+ }
+ 
+ QWaylandDataOffer *QWaylandDataDevice::selectionOffer() const
+@@ -110,7 +112,7 @@ QWaylandDataOffer *QWaylandDataDevice::dragOffer() const
+     return m_dragOffer.data();
+ }
+ 
+-bool QWaylandDataDevice::startDrag(QMimeData *mimeData, QWaylandWindow *icon)
++bool QWaylandDataDevice::startDrag(QMimeData *mimeData, Qt::DropActions supportedActions, QWaylandWindow *icon)
+ {
+     auto *seat = m_display->currentInputDevice();
+     auto *origin = seat->pointerFocus();
+@@ -123,7 +125,28 @@ bool QWaylandDataDevice::startDrag(QMimeData *mimeData, QWaylandWindow *icon)
+     }
+ 
+     m_dragSource.reset(new QWaylandDataSource(m_display->dndSelectionHandler(), mimeData));
++
++    if (wl_data_device_get_version(object()) >= 3)
++        m_dragSource->set_actions(dropActionsToWl(supportedActions));
++
+     connect(m_dragSource.data(), &QWaylandDataSource::cancelled, this, &QWaylandDataDevice::dragSourceCancelled);
++    connect(m_dragSource.data(), &QWaylandDataSource::dndResponseUpdated, this, [this](bool accepted, Qt::DropAction action) {
++            auto drag = static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag());
++            // in old versions drop action is not set, so we guess
++            if (wl_data_source_get_version(m_dragSource->object()) < 3) {
++                drag->setResponse(accepted);
++            } else {
++                QPlatformDropQtResponse response(accepted, action);
++                drag->setResponse(response);
++            }
++    });
++    connect(m_dragSource.data(), &QWaylandDataSource::dndDropped, this, [](bool accepted, Qt::DropAction action) {
++        QPlatformDropQtResponse response(accepted, action);
++        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setDropResponse(response);
++    });
++    connect(m_dragSource.data(), &QWaylandDataSource::finished, this, []() {
++        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag();
++    });
+ 
+     start_drag(m_dragSource->object(), origin->wlSurface(), icon->wlSurface(), m_display->currentInputDevice()->serial());
+     return true;
+@@ -152,7 +175,7 @@ void QWaylandDataDevice::data_device_drop()
+         supportedActions = drag->supportedActions();
+     } else if (m_dragOffer) {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     } else {
+         return;
+     }
+@@ -162,7 +185,11 @@ void QWaylandDataDevice::data_device_drop()
+                                                                           QGuiApplication::keyboardModifiers());
+ 
+     if (drag) {
+-        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag(response);
++        auto drag =  static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag());
++        drag->setDropResponse(response);
++        drag->finishDrag();
++    } else if (m_dragOffer) {
++        m_dragOffer->finish();
+     }
+ }
+ 
+@@ -186,7 +213,7 @@ void QWaylandDataDevice::data_device_enter(uint32_t serial, wl_surface *surface,
+         supportedActions = drag->supportedActions();
+     } else if (m_dragOffer) {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     }
+ 
+     const QPlatformDragQtResponse &response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
+@@ -197,11 +224,7 @@ void QWaylandDataDevice::data_device_enter(uint32_t serial, wl_surface *surface,
+         static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setResponse(response);
+     }
+ 
+-    if (response.isAccepted()) {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, m_dragOffer->firstFormat().toUtf8().constData());
+-    } else {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, nullptr);
+-    }
++    sendResponse(supportedActions, response);
+ }
+ 
+ void QWaylandDataDevice::data_device_leave()
+@@ -235,10 +258,10 @@ void QWaylandDataDevice::data_device_motion(uint32_t time, wl_fixed_t x, wl_fixe
+         supportedActions = drag->supportedActions();
+     } else {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     }
+ 
+-    QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
++    const QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
+                                                                           QGuiApplication::mouseButtons(),
+                                                                           QGuiApplication::keyboardModifiers());
+ 
+@@ -246,11 +269,7 @@ void QWaylandDataDevice::data_device_motion(uint32_t time, wl_fixed_t x, wl_fixe
+         static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setResponse(response);
+     }
+ 
+-    if (response.isAccepted()) {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, m_dragOffer->firstFormat().toUtf8().constData());
+-    } else {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, nullptr);
+-    }
++    sendResponse(supportedActions, response);
+ }
+ #endif // QT_CONFIG(draganddrop)
+ 
+@@ -277,14 +296,10 @@ void QWaylandDataDevice::selectionSourceCancelled()
+ #if QT_CONFIG(draganddrop)
+ void QWaylandDataDevice::dragSourceCancelled()
+ {
++    static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag();
+     m_dragSource.reset();
+ }
+ 
+-void QWaylandDataDevice::dragSourceTargetChanged(const QString &mimeType)
+-{
+-    static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->updateTarget(mimeType);
+-}
+-
+ QPoint QWaylandDataDevice::calculateDragPosition(int x, int y, QWindow *wnd) const
+ {
+     QPoint pnt(wl_fixed_to_int(x), wl_fixed_to_int(y));
+@@ -297,6 +312,33 @@ QPoint QWaylandDataDevice::calculateDragPosition(int x, int y, QWindow *wnd) con
+     }
+     return pnt;
+ }
++
++void QWaylandDataDevice::sendResponse(Qt::DropActions supportedActions, const QPlatformDragQtResponse &response)
++{
++    if (response.isAccepted()) {
++        if (wl_data_device_get_version(object()) >= 3)
++            m_dragOffer->set_actions(dropActionsToWl(supportedActions), dropActionsToWl(response.acceptedAction()));
++
++        m_dragOffer->accept(m_enterSerial, m_dragOffer->firstFormat());
++    } else {
++        m_dragOffer->accept(m_enterSerial, QString());
++    }
++}
++
++int QWaylandDataDevice::dropActionsToWl(Qt::DropActions actions)
++{
++
++    int wlActions = WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE;
++    if (actions & Qt::CopyAction)
++        wlActions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY;
++    if (actions & (Qt::MoveAction | Qt::TargetMoveAction))
++        wlActions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE;
++
++    // wayland does not support LinkAction at the time of writing
++    return wlActions;
++}
++
++
+ #endif // QT_CONFIG(draganddrop)
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddatadevice_p.h b/qtwayland/src/client/qwaylanddatadevice_p.h
+index 16c3ad28..801dcc2c 100644
+--- a/qtwayland/src/client/qwaylanddatadevice_p.h
++++ b/qtwayland/src/client/qwaylanddatadevice_p.h
+@@ -64,6 +64,7 @@ QT_REQUIRE_CONFIG(wayland_datadevice);
+ QT_BEGIN_NAMESPACE
+ 
+ class QMimeData;
++class QPlatformDragQtResponse;
+ class QWindow;
+ 
+ namespace QtWaylandClient {
+@@ -89,7 +90,7 @@ public:
+ 
+ #if QT_CONFIG(draganddrop)
+     QWaylandDataOffer *dragOffer() const;
+-    bool startDrag(QMimeData *mimeData, QWaylandWindow *icon);
++    bool startDrag(QMimeData *mimeData, Qt::DropActions supportedActions, QWaylandWindow *icon);
+     void cancelDrag();
+ #endif
+ 
+@@ -109,13 +110,16 @@ private Q_SLOTS:
+ 
+ #if QT_CONFIG(draganddrop)
+     void dragSourceCancelled();
+-    void dragSourceTargetChanged(const QString &mimeType);
+ #endif
+ 
+ private:
+ #if QT_CONFIG(draganddrop)
+     QPoint calculateDragPosition(int x, int y, QWindow *wnd) const;
+ #endif
++    void sendResponse(Qt::DropActions supportedActions, const QPlatformDragQtResponse &response);
++
++    static int dropActionsToWl(Qt::DropActions dropActions);
++
+ 
+     QWaylandDisplay *m_display = nullptr;
+     QWaylandInputDevice *m_inputDevice = nullptr;
+diff --git a/qtwayland/src/client/qwaylanddatadevicemanager.cpp b/qtwayland/src/client/qwaylanddatadevicemanager.cpp
+index 35d67307..6dc4f77f 100644
+--- a/qtwayland/src/client/qwaylanddatadevicemanager.cpp
++++ b/qtwayland/src/client/qwaylanddatadevicemanager.cpp
+@@ -50,8 +50,8 @@ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
+-QWaylandDataDeviceManager::QWaylandDataDeviceManager(QWaylandDisplay *display, uint32_t id)
+-    : wl_data_device_manager(display->wl_registry(), id, 1)
++QWaylandDataDeviceManager::QWaylandDataDeviceManager(QWaylandDisplay *display, int version, uint32_t id)
++    : wl_data_device_manager(display->wl_registry(), id, qMin(version, 3))
+     , m_display(display)
+ {
+     // Create transfer devices for all input devices.
+diff --git a/qtwayland/src/client/qwaylanddatadevicemanager_p.h b/qtwayland/src/client/qwaylanddatadevicemanager_p.h
+index bd05c0fb..510d9be4 100644
+--- a/qtwayland/src/client/qwaylanddatadevicemanager_p.h
++++ b/qtwayland/src/client/qwaylanddatadevicemanager_p.h
+@@ -68,7 +68,7 @@ class QWaylandInputDevice;
+ class Q_WAYLAND_CLIENT_EXPORT QWaylandDataDeviceManager : public QtWayland::wl_data_device_manager
+ {
+ public:
+-    QWaylandDataDeviceManager(QWaylandDisplay *display, uint32_t id);
++    QWaylandDataDeviceManager(QWaylandDisplay *display, int version, uint32_t id);
+     ~QWaylandDataDeviceManager() override;
+ 
+     QWaylandDataDevice *getDataDevice(QWaylandInputDevice *inputDevice);
+diff --git a/qtwayland/src/client/qwaylanddataoffer.cpp b/qtwayland/src/client/qwaylanddataoffer.cpp
+index 2297e8a1..fe0ea8c9 100644
+--- a/qtwayland/src/client/qwaylanddataoffer.cpp
++++ b/qtwayland/src/client/qwaylanddataoffer.cpp
+@@ -82,6 +82,15 @@ QMimeData *QWaylandDataOffer::mimeData()
+     return m_mimeData.data();
+ }
+ 
++Qt::DropActions QWaylandDataOffer::supportedActions() const
++{
++    if (wl_data_offer_get_version(const_cast<::wl_data_offer*>(object())) < 3) {
++        return Qt::MoveAction | Qt::CopyAction;
++    }
++
++    return m_supportedActions;
++}
++
+ void QWaylandDataOffer::startReceiving(const QString &mimeType, int fd)
+ {
+     receive(mimeType, fd);
+@@ -93,6 +102,22 @@ void QWaylandDataOffer::data_offer_offer(const QString &mime_type)
+     m_mimeData->appendFormat(mime_type);
+ }
+ 
++void QWaylandDataOffer::data_offer_action(uint32_t dnd_action)
++{
++    Q_UNUSED(dnd_action);
++    // This is the compositor telling the drag target what action it should perform
++    // It does not map nicely into Qt final drop semantics, other than pretending there is only one supported action?
++}
++
++void QWaylandDataOffer::data_offer_source_actions(uint32_t source_actions)
++{
++    m_supportedActions = Qt::DropActions();
++    if (source_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
++        m_supportedActions |= Qt::MoveAction;
++    if (source_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
++        m_supportedActions |= Qt::CopyAction;
++}
++
+ QWaylandMimeData::QWaylandMimeData(QWaylandAbstractDataOffer *dataOffer)
+     : m_dataOffer(dataOffer)
+ {
+@@ -163,17 +188,18 @@ QVariant QWaylandMimeData::retrieveData_sys(const QString &mimeType, QVariant::T
+ 
+ int QWaylandMimeData::readData(int fd, QByteArray &data) const
+ {
+-    fd_set readset;
+-    FD_ZERO(&readset);
+-    FD_SET(fd, &readset);
+-    struct timeval timeout;
++    struct pollfd readset;
++    readset.fd = fd;
++    readset.events = POLLIN;
++    struct timespec timeout;
+     timeout.tv_sec = 1;
+-    timeout.tv_usec = 0;
++    timeout.tv_nsec = 0;
++
+ 
+     Q_FOREVER {
+-        int ready = select(FD_SETSIZE, &readset, nullptr, nullptr, &timeout);
++        int ready = qt_safe_poll(&readset, 1, &timeout);
+         if (ready < 0) {
+-            qWarning() << "QWaylandDataOffer: select() failed";
++            qWarning() << "QWaylandDataOffer: qt_safe_poll() failed";
+             return -1;
+         } else if (ready == 0) {
+             qWarning("QWaylandDataOffer: timeout reading from pipe");
+diff --git a/qtwayland/src/client/qwaylanddataoffer_p.h b/qtwayland/src/client/qwaylanddataoffer_p.h
+index 9cf1483c..6f667398 100644
+--- a/qtwayland/src/client/qwaylanddataoffer_p.h
++++ b/qtwayland/src/client/qwaylanddataoffer_p.h
+@@ -82,6 +82,7 @@ public:
+     explicit QWaylandDataOffer(QWaylandDisplay *display, struct ::wl_data_offer *offer);
+     ~QWaylandDataOffer() override;
+     QMimeData *mimeData() override;
++    Qt::DropActions supportedActions() const;
+ 
+     QString firstFormat() const;
+ 
+@@ -89,10 +90,13 @@ public:
+ 
+ protected:
+     void data_offer_offer(const QString &mime_type) override;
++    void data_offer_source_actions(uint32_t source_actions) override;
++    void data_offer_action(uint32_t dnd_action) override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+     QScopedPointer<QWaylandMimeData> m_mimeData;
++    Qt::DropActions m_supportedActions;
+ };
+ 
+ 
+diff --git a/qtwayland/src/client/qwaylanddatasource.cpp b/qtwayland/src/client/qwaylanddatasource.cpp
+index f45122fb..5599cbd4 100644
+--- a/qtwayland/src/client/qwaylanddatasource.cpp
++++ b/qtwayland/src/client/qwaylanddatasource.cpp
+@@ -101,7 +101,32 @@ void QWaylandDataSource::data_source_send(const QString &mime_type, int32_t fd)
+ 
+ void QWaylandDataSource::data_source_target(const QString &mime_type)
+ {
+-    Q_EMIT targetChanged(mime_type);
++    m_accepted = !mime_type.isEmpty();
++    Q_EMIT dndResponseUpdated(m_accepted, m_dropAction);
++}
++
++void QWaylandDataSource::data_source_action(uint32_t action)
++{
++    Qt::DropAction qtAction = Qt::IgnoreAction;
++
++    if (action == WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
++        qtAction = Qt::MoveAction;
++    else if (action == WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
++        qtAction = Qt::CopyAction;
++
++    m_dropAction = qtAction;
++    Q_EMIT dndResponseUpdated(m_accepted, m_dropAction);
++}
++
++void QWaylandDataSource::data_source_dnd_finished()
++{
++    Q_EMIT finished();
++}
++
++void QWaylandDataSource::data_source_dnd_drop_performed()
++{
++
++    Q_EMIT dndDropped(m_accepted, m_dropAction);
+ }
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddatasource_p.h b/qtwayland/src/client/qwaylanddatasource_p.h
+index 25afff79..96f07bc3 100644
+--- a/qtwayland/src/client/qwaylanddatasource_p.h
++++ b/qtwayland/src/client/qwaylanddatasource_p.h
+@@ -77,17 +77,25 @@ public:
+     QMimeData *mimeData() const;
+ 
+ Q_SIGNALS:
+-    void targetChanged(const QString &mime_type);
+     void cancelled();
++    void finished();
++
++    void dndResponseUpdated(bool accepted, Qt::DropAction action);
++    void dndDropped(bool accepted, Qt::DropAction action);
+ 
+ protected:
+     void data_source_cancelled() override;
+     void data_source_send(const QString &mime_type, int32_t fd) override;
+     void data_source_target(const QString &mime_type) override;
++    void data_source_dnd_drop_performed() override;
++    void data_source_dnd_finished() override;
++    void data_source_action(uint32_t action) override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+     QMimeData *m_mime_data = nullptr;
++    bool m_accepted = false;
++    Qt::DropAction m_dropAction = Qt::IgnoreAction;
+ };
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddisplay.cpp b/qtwayland/src/client/qwaylanddisplay.cpp
+index f10c1f79..c01e238b 100644
+--- a/qtwayland/src/client/qwaylanddisplay.cpp
++++ b/qtwayland/src/client/qwaylanddisplay.cpp
+@@ -85,10 +85,203 @@
+ 
+ #include <errno.h>
+ 
++#include <tuple> // for std::tie
++
++static void checkWaylandError(struct wl_display *display)
++{
++    int ecode = wl_display_get_error(display);
++    if ((ecode == EPIPE || ecode == ECONNRESET)) {
++        // special case this to provide a nicer error
++        qWarning("The Wayland connection broke. Did the Wayland compositor die?");
++    } else {
++        qWarning("The Wayland connection experienced a fatal error: %s", strerror(ecode));
++    }
++    _exit(1);
++}
++
+ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
++class EventThread : public QThread
++{
++    Q_OBJECT
++public:
++    enum OperatingMode {
++        EmitToDispatch, // Emit the signal, allow dispatching in a differnt thread.
++        SelfDispatch, // Dispatch the events inside this thread.
++    };
++
++    EventThread(struct wl_display * wl, struct wl_event_queue * ev_queue,
++                OperatingMode mode)
++        : m_fd(wl_display_get_fd(wl))
++        , m_pipefd{ -1, -1 }
++        , m_wldisplay(wl)
++        , m_wlevqueue(ev_queue)
++        , m_mode(mode)
++        , m_reading(true)
++        , m_quitting(false)
++    {
++        setObjectName(QStringLiteral("WaylandEventThread"));
++    }
++
++    void readAndDispatchEvents()
++    {
++        /*
++         * Dispatch pending events and flush the requests at least once. If the event thread
++         * is not reading, try to call _prepare_read() to allow the event thread to poll().
++         * If that fails, re-try dispatch & flush again until _prepare_read() is successful.
++         *
++         * This allow any call to readAndDispatchEvents() to start event thread's polling,
++         * not only the one issued from event thread's waitForReading(), which means functions
++         * called from dispatch_pending() can safely spin an event loop.
++         */
++        for (;;) {
++            if (dispatchQueuePending() < 0) {
++                checkWaylandError(m_wldisplay);
++                return;
++            }
++
++            wl_display_flush(m_wldisplay);
++
++            // We have to check if event thread is reading every time we dispatch
++            // something, as that may recursively call this function.
++            if (m_reading.loadAcquire())
++                break;
++
++            if (prepareReadQueue() == 0) {
++                QMutexLocker l(&m_mutex);
++                m_reading.storeRelease(true);
++                m_cond.wakeOne();
++                break;
++            }
++        }
++    }
++
++    void stop()
++    {
++        // We have to both write to the pipe and set the flag, as the thread may be
++        // either in the poll() or waiting for _prepare_read().
++        if (m_pipefd[1] != -1 && write(m_pipefd[1], "\0", 1) == -1)
++            qWarning("Failed to write to the pipe: %s.", strerror(errno));
++
++        {
++            QMutexLocker l(&m_mutex);
++            m_quitting = true;
++            m_cond.wakeOne();
++        }
++
++        wait();
++    }
++
++Q_SIGNALS:
++    void needReadAndDispatch();
++
++protected:
++    void run() override
++    {
++        // we use this pipe to make the loop exit otherwise if we simply used a flag on the loop condition, if stop() gets
++        // called while poll() is blocking the thread will never quit since there are no wayland messages coming anymore.
++        struct Pipe
++        {
++            Pipe(int *fds)
++                : fds(fds)
++            {
++                if (qt_safe_pipe(fds) != 0)
++                    qWarning("Pipe creation failed. Quitting may hang.");
++            }
++            ~Pipe()
++            {
++                if (fds[0] != -1) {
++                    close(fds[0]);
++                    close(fds[1]);
++                }
++            }
++
++            int *fds;
++        } pipe(m_pipefd);
++
++        // Make the main thread call wl_prepare_read(), dispatch the pending messages and flush the
++        // outbound ones. Wait until it's done before proceeding, unless we're told to quit.
++        while (waitForReading()) {
++            pollfd fds[2] = { { m_fd, POLLIN, 0 }, { m_pipefd[0], POLLIN, 0 } };
++            poll(fds, 2, -1);
++
++            if (fds[1].revents & POLLIN) {
++                // we don't really care to read the byte that was written here since we're closing down
++                wl_display_cancel_read(m_wldisplay);
++                break;
++            }
++
++            if (fds[0].revents & POLLIN)
++                wl_display_read_events(m_wldisplay);
++                // The polll was succesfull and the event thread did the wl_display_read_events(). On the next iteration of the loop
++                // the event sent to the main thread will cause it to dispatch the messages just read, unless the loop exits in which
++                // case we don't care anymore about them.
++            else
++                wl_display_cancel_read(m_wldisplay);
++        }
++    }
++
++private:
++    bool waitForReading()
++    {
++        Q_ASSERT(QThread::currentThread() == this);
++
++        m_reading.storeRelease(false);
++
++        if (m_mode == SelfDispatch) {
++            readAndDispatchEvents();
++        } else {
++            Q_EMIT needReadAndDispatch();
++
++            QMutexLocker lock(&m_mutex);
++            // m_reading might be set from our emit or some other invocation of
++            // readAndDispatchEvents().
++            while (!m_reading.loadRelaxed() && !m_quitting)
++                m_cond.wait(&m_mutex);
++        }
++
++        return !m_quitting;
++    }
++
++    int dispatchQueuePending()
++    {
++        if (m_wlevqueue)
++            return wl_display_dispatch_queue_pending(m_wldisplay, m_wlevqueue);
++        else
++            return wl_display_dispatch_pending(m_wldisplay);
++    }
++
++    int prepareReadQueue()
++    {
++        if (m_wlevqueue)
++            return wl_display_prepare_read_queue(m_wldisplay, m_wlevqueue);
++        else
++            return wl_display_prepare_read(m_wldisplay);
++    }
++
++    int m_fd;
++    int m_pipefd[2];
++    wl_display *m_wldisplay;
++    wl_event_queue *m_wlevqueue;
++    OperatingMode m_mode;
++
++    /* Concurrency note when operating in EmitToDispatch mode:
++     * m_reading is set to false inside event thread's waitForReading(), and is
++     * set to true inside main thread's readAndDispatchEvents().
++     * The lock is not taken when setting m_reading to false, as the main thread
++     * is not actively waiting for it to turn false. However, the lock is taken
++     * inside readAndDispatchEvents() before setting m_reading to true,
++     * as the event thread is actively waiting for it under the wait condition.
++     */
++
++    QAtomicInteger<bool> m_reading;
++    bool m_quitting;
++    QMutex m_mutex;
++    QWaitCondition m_cond;
++};
++
+ Q_LOGGING_CATEGORY(lcQpaWayland, "qt.qpa.wayland"); // for general (uncategorized) Wayland platform logging
+ 
+ struct wl_surface *QWaylandDisplay::createSurface(void *handle)
+@@ -158,17 +351,16 @@ QWaylandDisplay::QWaylandDisplay(QWaylandIntegration *waylandIntegration)
+     if (!mXkbContext)
+         qCWarning(lcQpaWayland, "failed to create xkb context");
+ #endif
+-
+-    forceRoundTrip();
+-
+-    if (!mWaitingScreens.isEmpty()) {
+-        // Give wl_output.done and zxdg_output_v1.done events a chance to arrive
+-        forceRoundTrip();
+-    }
+ }
+ 
+ QWaylandDisplay::~QWaylandDisplay(void)
+ {
++    if (m_eventThread)
++        m_eventThread->stop();
++
++    if (m_frameEventQueueThread)
++        m_frameEventQueueThread->stop();
++
+     if (mSyncCallback)
+         wl_callback_destroy(mSyncCallback);
+ 
+@@ -187,6 +379,21 @@ QWaylandDisplay::~QWaylandDisplay(void)
+ #endif
+     if (mDisplay)
+         wl_display_disconnect(mDisplay);
++
++    if (m_frameEventQueue)
++        wl_event_queue_destroy(m_frameEventQueue);
++}
++
++// Steps which is called just after constructor. This separates registry_global() out of the constructor
++// so that factory functions in integration can be overridden.
++void QWaylandDisplay::initialize()
++{
++    forceRoundTrip();
++
++    if (!mWaitingScreens.isEmpty()) {
++        // Give wl_output.done and zxdg_output_v1.done events a chance to arrive
++        forceRoundTrip();
++    }
+ }
+ 
+ void QWaylandDisplay::ensureScreen()
+@@ -203,98 +410,37 @@ void QWaylandDisplay::ensureScreen()
+ 
+ void QWaylandDisplay::checkError() const
+ {
+-    int ecode = wl_display_get_error(mDisplay);
+-    if ((ecode == EPIPE || ecode == ECONNRESET)) {
+-        // special case this to provide a nicer error
+-        qWarning("The Wayland connection broke. Did the Wayland compositor die?");
+-    } else {
+-        qWarning("The Wayland connection experienced a fatal error: %s", strerror(ecode));
+-    }
+-    _exit(1);
++    checkWaylandError(mDisplay);
+ }
+ 
++// Called in main thread, either from queued signal or directly.
+ void QWaylandDisplay::flushRequests()
+ {
+-    if (wl_display_prepare_read(mDisplay) == 0) {
+-        wl_display_read_events(mDisplay);
+-    }
+-
+-    if (wl_display_dispatch_pending(mDisplay) < 0)
+-        checkError();
+-
+-    {
+-        QReadLocker locker(&m_frameQueueLock);
+-        for (const FrameQueue &q : mExternalQueues) {
+-            QMutexLocker locker(q.mutex);
+-            while (wl_display_prepare_read_queue(mDisplay, q.queue) != 0)
+-                wl_display_dispatch_queue_pending(mDisplay, q.queue);
+-            wl_display_read_events(mDisplay);
+-            wl_display_dispatch_queue_pending(mDisplay, q.queue);
+-        }
+-    }
+-
+-    wl_display_flush(mDisplay);
+-}
+-
+-void QWaylandDisplay::blockingReadEvents()
+-{
+-    if (wl_display_dispatch(mDisplay) < 0)
+-        checkError();
+-}
+-
+-void QWaylandDisplay::destroyFrameQueue(const QWaylandDisplay::FrameQueue &q)
+-{
+-    QWriteLocker locker(&m_frameQueueLock);
+-    auto it = std::find_if(mExternalQueues.begin(),
+-                           mExternalQueues.end(),
+-                           [&q] (const QWaylandDisplay::FrameQueue &other){ return other.queue == q.queue; });
+-    Q_ASSERT(it != mExternalQueues.end());
+-    mExternalQueues.erase(it);
+-    if (q.queue != nullptr)
+-        wl_event_queue_destroy(q.queue);
+-    delete q.mutex;
++    m_eventThread->readAndDispatchEvents();
+ }
+ 
+-QWaylandDisplay::FrameQueue QWaylandDisplay::createFrameQueue()
++// We have to wait until we have an eventDispatcher before creating the eventThread,
++// otherwise forceRoundTrip() may block inside _events_read() because eventThread is
++// polling.
++void QWaylandDisplay::initEventThread()
+ {
+-    QWriteLocker locker(&m_frameQueueLock);
+-    FrameQueue q{createEventQueue()};
+-    mExternalQueues.append(q);
+-    return q;
+-}
++    m_eventThread.reset(
++            new EventThread(mDisplay, /* default queue */ nullptr, EventThread::EmitToDispatch));
++    connect(m_eventThread.get(), &EventThread::needReadAndDispatch, this,
++            &QWaylandDisplay::flushRequests, Qt::QueuedConnection);
++    m_eventThread->start();
+ 
+-wl_event_queue *QWaylandDisplay::createEventQueue()
+-{
+-    return wl_display_create_queue(mDisplay);
++    // wl_display_disconnect() free this.
++    m_frameEventQueue = wl_display_create_queue(mDisplay);
++    m_frameEventQueueThread.reset(
++            new EventThread(mDisplay, m_frameEventQueue, EventThread::SelfDispatch));
++    m_frameEventQueueThread->start();
+ }
+ 
+-void QWaylandDisplay::dispatchQueueWhile(wl_event_queue *queue, std::function<bool ()> condition, int timeout)
++void QWaylandDisplay::blockingReadEvents()
+ {
+-    if (!condition())
+-        return;
+-
+-    QElapsedTimer timer;
+-    timer.start();
+-    struct pollfd pFd = qt_make_pollfd(wl_display_get_fd(mDisplay), POLLIN);
+-    while (timeout == -1 || timer.elapsed() < timeout) {
+-        while (wl_display_prepare_read_queue(mDisplay, queue) != 0)
+-            wl_display_dispatch_queue_pending(mDisplay, queue);
+-
+-        wl_display_flush(mDisplay);
+-
+-        const int remaining = qMax(timeout - timer.elapsed(), 0ll);
+-        const int pollTimeout = timeout == -1 ? -1 : remaining;
+-        if (qt_poll_msecs(&pFd, 1, pollTimeout) > 0)
+-            wl_display_read_events(mDisplay);
+-        else
+-            wl_display_cancel_read(mDisplay);
+-
+-        if (wl_display_dispatch_queue_pending(mDisplay, queue) < 0)
+-            checkError();
+-
+-        if (!condition())
+-            break;
+-    }
++    if (wl_display_dispatch(mDisplay) < 0)
++        checkWaylandError(mDisplay);
+ }
+ 
+ QWaylandScreen *QWaylandDisplay::screenForOutput(struct wl_output *output) const
+@@ -345,7 +491,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+     if (interface == QStringLiteral("wl_output")) {
+         mWaitingScreens << new QWaylandScreen(this, version, id);
+     } else if (interface == QStringLiteral("wl_compositor")) {
+-        mCompositorVersion = qMin((int)version, 3);
++        mCompositorVersion = qMin((int)version, 4);
+         mCompositor.init(registry, id, mCompositorVersion);
+     } else if (interface == QStringLiteral("wl_shm")) {
+         mShm.reset(new QWaylandShm(this, version, id));
+@@ -354,7 +500,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+         mInputDevices.append(inputDevice);
+ #if QT_CONFIG(wayland_datadevice)
+     } else if (interface == QStringLiteral("wl_data_device_manager")) {
+-        mDndSelectionHandler.reset(new QWaylandDataDeviceManager(this, id));
++        mDndSelectionHandler.reset(new QWaylandDataDeviceManager(this, version, id));
+ #endif
+     } else if (interface == QStringLiteral("qt_surface_extension")) {
+         mWindowExtension.reset(new QtWayland::qt_surface_extension(registry, id, 1));
+@@ -369,6 +515,8 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+ #if QT_CONFIG(wayland_client_primary_selection)
+     } else if (interface == QStringLiteral("zwp_primary_selection_device_manager_v1")) {
+         mPrimarySelectionManager.reset(new QWaylandPrimarySelectionDeviceManagerV1(this, id, 1));
++        for (QWaylandInputDevice *inputDevice : qAsConst(mInputDevices))
++            inputDevice->setPrimarySelectionDevice(mPrimarySelectionManager->createDevice(inputDevice));
+ #endif
+     } else if (interface == QStringLiteral("zwp_text_input_manager_v2") && !mClientSideInputContextRequested) {
+         mTextInputManager.reset(new QtWayland::zwp_text_input_manager_v2(registry, id, 1));
+@@ -427,6 +575,13 @@ void QWaylandDisplay::registry_global_remove(uint32_t id)
+                     inputDevice->setTextInput(nullptr);
+                 mWaylandIntegration->reconfigureInputContext();
+             }
++#if QT_CONFIG(wayland_client_primary_selection)
++            if (global.interface == QStringLiteral("zwp_primary_selection_device_manager_v1")) {
++                mPrimarySelectionManager.reset();
++                for (QWaylandInputDevice *inputDevice : qAsConst(mInputDevices))
++                    inputDevice->setPrimarySelectionDevice(nullptr);
++            }
++#endif
+             mGlobals.removeAt(i);
+             break;
+         }
+@@ -452,9 +607,10 @@ void QWaylandDisplay::addRegistryListener(RegistryListener listener, void *data)
+ 
+ void QWaylandDisplay::removeListener(RegistryListener listener, void *data)
+ {
+-    std::remove_if(mRegistryListeners.begin(), mRegistryListeners.end(), [=](Listener l){
++    auto iter = std::remove_if(mRegistryListeners.begin(), mRegistryListeners.end(), [=](Listener l){
+         return (l.listener == listener && l.data == data);
+     });
++    mRegistryListeners.erase(iter, mRegistryListeners.end());
+ }
+ 
+ uint32_t QWaylandDisplay::currentTimeMillisec()
+@@ -467,50 +623,9 @@ uint32_t QWaylandDisplay::currentTimeMillisec()
+     return 0;
+ }
+ 
+-static void
+-sync_callback(void *data, struct wl_callback *callback, uint32_t serial)
+-{
+-    Q_UNUSED(serial)
+-    bool *done = static_cast<bool *>(data);
+-
+-    *done = true;
+-
+-    // If the wl_callback done event is received after the condition check in the while loop in
+-    // forceRoundTrip(), but before the call to processEvents, the call to processEvents may block
+-    // forever if no more events are posted (eventhough the callback is handled in response to the
+-    // aboutToBlock signal). Hence, we wake up the event dispatcher so forceRoundTrip may return.
+-    // (QTBUG-64696)
+-    if (auto *dispatcher = QThread::currentThread()->eventDispatcher())
+-        dispatcher->wakeUp();
+-
+-    wl_callback_destroy(callback);
+-}
+-
+-static const struct wl_callback_listener sync_listener = {
+-    sync_callback
+-};
+-
+ void QWaylandDisplay::forceRoundTrip()
+ {
+-    // wl_display_roundtrip() works on the main queue only,
+-    // but we use a separate one, so basically reimplement it here
+-    int ret = 0;
+-    bool done = false;
+-    wl_callback *callback = wl_display_sync(mDisplay);
+-    wl_callback_add_listener(callback, &sync_listener, &done);
+-    flushRequests();
+-    if (QThread::currentThread()->eventDispatcher()) {
+-        while (!done && ret >= 0) {
+-            QThread::currentThread()->eventDispatcher()->processEvents(QEventLoop::WaitForMoreEvents);
+-            ret = wl_display_dispatch_pending(mDisplay);
+-        }
+-    } else {
+-        while (!done && ret >= 0)
+-            ret = wl_display_dispatch(mDisplay);
+-    }
+-
+-    if (ret == -1 && !done)
+-        wl_callback_destroy(callback);
++     wl_display_roundtrip(mDisplay);
+ }
+ 
+ bool QWaylandDisplay::supportsWindowDecoration() const
+@@ -574,14 +689,10 @@ void QWaylandDisplay::handleKeyboardFocusChanged(QWaylandInputDevice *inputDevic
+     if (mLastKeyboardFocus == keyboardFocus)
+         return;
+ 
+-    if (mWaylandIntegration->mShellIntegration) {
+-        mWaylandIntegration->mShellIntegration->handleKeyboardFocusChanged(keyboardFocus, mLastKeyboardFocus);
+-    } else {
+-        if (keyboardFocus)
+-            handleWindowActivated(keyboardFocus);
+-        if (mLastKeyboardFocus)
+-            handleWindowDeactivated(mLastKeyboardFocus);
+-    }
++    if (keyboardFocus)
++        handleWindowActivated(keyboardFocus);
++    if (mLastKeyboardFocus)
++        handleWindowDeactivated(mLastKeyboardFocus);
+ 
+     mLastKeyboardFocus = keyboardFocus;
+ }
+@@ -600,6 +711,19 @@ void QWaylandDisplay::handleWaylandSync()
+     QWindow *activeWindow = mActiveWindows.empty() ? nullptr : mActiveWindows.last()->window();
+     if (activeWindow != QGuiApplication::focusWindow())
+         QWindowSystemInterface::handleWindowActivated(activeWindow);
++
++    if (!activeWindow) {
++        if (lastInputDevice()) {
++#if QT_CONFIG(clipboard)
++            if (auto *dataDevice = lastInputDevice()->dataDevice())
++                dataDevice->invalidateSelectionOffer();
++#endif
++#if QT_CONFIG(wayland_client_primary_selection)
++            if (auto *device = lastInputDevice()->primarySelectionDevice())
++                device->invalidateSelectionOffer();
++#endif
++        }
++    }
+ }
+ 
+ const wl_callback_listener QWaylandDisplay::syncCallbackListener = {
+@@ -626,6 +750,13 @@ QWaylandInputDevice *QWaylandDisplay::defaultInputDevice() const
+     return mInputDevices.isEmpty() ? 0 : mInputDevices.first();
+ }
+ 
++bool QWaylandDisplay::isKeyboardAvailable() const
++{
++    return std::any_of(
++            mInputDevices.constBegin(), mInputDevices.constEnd(),
++            [this](const QWaylandInputDevice *device) { return device->keyboard() != nullptr; });
++}
++
+ #if QT_CONFIG(cursor)
+ 
+ QWaylandCursor *QWaylandDisplay::waylandCursor()
+@@ -652,4 +783,6 @@ QWaylandCursorTheme *QWaylandDisplay::loadCursorTheme(const QString &name, int p
+ 
+ } // namespace QtWaylandClient
+ 
++#include "qwaylanddisplay.moc"
++
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/client/qwaylanddisplay_p.h b/qtwayland/src/client/qwaylanddisplay_p.h
+index 3b092bc8..42bc661d 100644
+--- a/qtwayland/src/client/qwaylanddisplay_p.h
++++ b/qtwayland/src/client/qwaylanddisplay_p.h
+@@ -109,6 +109,7 @@ class QWaylandSurface;
+ class QWaylandShellIntegration;
+ class QWaylandCursor;
+ class QWaylandCursorTheme;
++class EventThread;
+ 
+ typedef void (*RegistryListener)(void *data,
+                                  struct wl_registry *registry,
+@@ -120,15 +121,11 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandDisplay : public QObject, public QtWayland
+     Q_OBJECT
+ 
+ public:
+-    struct FrameQueue {
+-        FrameQueue(wl_event_queue *q = nullptr) : queue(q), mutex(new QMutex) {}
+-        wl_event_queue *queue;
+-        QMutex *mutex;
+-    };
+-
+     QWaylandDisplay(QWaylandIntegration *waylandIntegration);
+     ~QWaylandDisplay(void) override;
+ 
++    void initialize();
++
+ #if QT_CONFIG(xkbcommon)
+     struct xkb_context *xkbContext() const { return mXkbContext.get(); }
+ #endif
+@@ -210,11 +207,11 @@ public:
+     void handleKeyboardFocusChanged(QWaylandInputDevice *inputDevice);
+     void handleWindowDestroyed(QWaylandWindow *window);
+ 
+-    wl_event_queue *createEventQueue();
+-    FrameQueue createFrameQueue();
+-    void destroyFrameQueue(const FrameQueue &q);
+-    void dispatchQueueWhile(wl_event_queue *queue, std::function<bool()> condition, int timeout = -1);
++    wl_event_queue *frameEventQueue() { return m_frameEventQueue; };
++
++    bool isKeyboardAvailable() const;
+ 
++    void initEventThread();
+ public slots:
+     void blockingReadEvents();
+     void flushRequests();
+@@ -237,6 +234,9 @@ private:
+     };
+ 
+     struct wl_display *mDisplay = nullptr;
++    QScopedPointer<EventThread> m_eventThread;
++    wl_event_queue *m_frameEventQueue = nullptr;
++    QScopedPointer<EventThread> m_frameEventQueueThread;
+     QtWayland::wl_compositor mCompositor;
+     QScopedPointer<QWaylandShm> mShm;
+     QList<QWaylandScreen *> mWaitingScreens;
+@@ -273,11 +273,9 @@ private:
+     QWaylandInputDevice *mLastInputDevice = nullptr;
+     QPointer<QWaylandWindow> mLastInputWindow;
+     QPointer<QWaylandWindow> mLastKeyboardFocus;
+-    QVector<QWaylandWindow *> mActiveWindows;
+-    QVector<FrameQueue> mExternalQueues;
++    QList<QWaylandWindow *> mActiveWindows;
+     struct wl_callback *mSyncCallback = nullptr;
+     static const wl_callback_listener syncCallbackListener;
+-    QReadWriteLock m_frameQueueLock;
+ 
+     bool mClientSideInputContextRequested = !QPlatformInputContextFactory::requested().isNull();
+ 
+diff --git a/qtwayland/src/client/qwaylanddnd.cpp b/qtwayland/src/client/qwaylanddnd.cpp
+index 6535aa16..7c53f5fa 100644
+--- a/qtwayland/src/client/qwaylanddnd.cpp
++++ b/qtwayland/src/client/qwaylanddnd.cpp
+@@ -66,7 +66,7 @@ void QWaylandDrag::startDrag()
+ {
+     QBasicDrag::startDrag();
+     QWaylandWindow *icon = static_cast<QWaylandWindow *>(shapedPixmapWindow()->handle());
+-    if (m_display->currentInputDevice()->dataDevice()->startDrag(drag()->mimeData(), icon)) {
++    if (m_display->currentInputDevice()->dataDevice()->startDrag(drag()->mimeData(), drag()->supportedActions(), icon)) {
+         icon->addAttachOffset(-drag()->hotSpot());
+     } else {
+         // Cancelling immediately does not work, since the event loop for QDrag::exec is started
+@@ -80,6 +80,9 @@ void QWaylandDrag::cancel()
+     QBasicDrag::cancel();
+ 
+     m_display->currentInputDevice()->dataDevice()->cancelDrag();
++
++    if (drag())
++        drag()->deleteLater();
+ }
+ 
+ void QWaylandDrag::move(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods)
+@@ -103,33 +106,41 @@ void QWaylandDrag::endDrag()
+     m_display->currentInputDevice()->handleEndDrag();
+ }
+ 
+-void QWaylandDrag::updateTarget(const QString &mimeType)
++void QWaylandDrag::setResponse(bool accepted)
+ {
+-    setCanDrop(!mimeType.isEmpty());
+-
+-    if (canDrop()) {
+-        updateCursor(defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers()));
+-    } else {
+-        updateCursor(Qt::IgnoreAction);
+-    }
++    // This method is used for old DataDevices where the drag action is not communicated
++    Qt::DropAction action = defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers());
++    setResponse(QPlatformDropQtResponse(accepted, action));
+ }
+ 
+-void QWaylandDrag::setResponse(const QPlatformDragQtResponse &response)
++void QWaylandDrag::setResponse(const QPlatformDropQtResponse &response)
+ {
+     setCanDrop(response.isAccepted());
+ 
+     if (canDrop()) {
+-        updateCursor(defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers()));
++        updateCursor(response.acceptedAction());
+     } else {
+         updateCursor(Qt::IgnoreAction);
+     }
+ }
+ 
+-void QWaylandDrag::finishDrag(const QPlatformDropQtResponse &response)
++void QWaylandDrag::setDropResponse(const QPlatformDropQtResponse &response)
+ {
+     setExecutedDropAction(response.acceptedAction());
++}
++
++void QWaylandDrag::finishDrag()
++{
+     QKeyEvent event(QEvent::KeyPress, Qt::Key_Escape, Qt::NoModifier);
+     eventFilter(shapedPixmapWindow(), &event);
++
++    if (drag())
++        drag()->deleteLater();
++}
++
++bool QWaylandDrag::ownsDragObject() const
++{
++    return true;
+ }
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddnd_p.h b/qtwayland/src/client/qwaylanddnd_p.h
+index 474fe2ab..46f629ac 100644
+--- a/qtwayland/src/client/qwaylanddnd_p.h
++++ b/qtwayland/src/client/qwaylanddnd_p.h
+@@ -71,9 +71,10 @@ public:
+     QWaylandDrag(QWaylandDisplay *display);
+     ~QWaylandDrag() override;
+ 
+-    void updateTarget(const QString &mimeType);
+-    void setResponse(const QPlatformDragQtResponse &response);
+-    void finishDrag(const QPlatformDropQtResponse &response);
++    void setResponse(bool accepted);
++    void setResponse(const QPlatformDropQtResponse &response);
++    void setDropResponse(const QPlatformDropQtResponse &response);
++    void finishDrag();
+ 
+ protected:
+     void startDrag() override;
+@@ -82,6 +83,7 @@ protected:
+     void drop(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods) override;
+     void endDrag() override;
+ 
++    bool ownsDragObject() const override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+diff --git a/qtwayland/src/client/qwaylandinputdevice.cpp b/qtwayland/src/client/qwaylandinputdevice.cpp
+index 613fe862..4b90de84 100644
+--- a/qtwayland/src/client/qwaylandinputdevice.cpp
++++ b/qtwayland/src/client/qwaylandinputdevice.cpp
+@@ -685,6 +685,11 @@ public:
+ 
+ void QWaylandInputDevice::Pointer::pointer_leave(uint32_t time, struct wl_surface *surface)
+ {
++    invalidateFocus();
++    mButtons = Qt::NoButton;
++
++    mParent->mTime = time;
++
+     // The event may arrive after destroying the window, indicated by
+     // a null surface.
+     if (!surface)
+@@ -696,11 +701,6 @@ void QWaylandInputDevice::Pointer::pointer_leave(uint32_t time, struct wl_surfac
+ 
+     if (!QWaylandWindow::mouseGrab())
+         setFrameEvent(new LeaveEvent(window, mSurfacePos, mGlobalPos));
+-
+-    invalidateFocus();
+-    mButtons = Qt::NoButton;
+-
+-    mParent->mTime = time;
+ }
+ 
+ class MotionEvent : public QWaylandPointerEvent
+@@ -1300,14 +1300,6 @@ void QWaylandInputDevice::Keyboard::handleFocusDestroyed()
+ void QWaylandInputDevice::Keyboard::handleFocusLost()
+ {
+     mFocus = nullptr;
+-#if QT_CONFIG(clipboard)
+-    if (auto *dataDevice = mParent->dataDevice())
+-        dataDevice->invalidateSelectionOffer();
+-#endif
+-#if QT_CONFIG(wayland_client_primary_selection)
+-    if (auto *device = mParent->primarySelectionDevice())
+-        device->invalidateSelectionOffer();
+-#endif
+     mParent->mQDisplay->handleKeyboardFocusChanged(mParent);
+     mRepeatTimer.stop();
+ }
+@@ -1396,6 +1388,7 @@ void QWaylandInputDevice::Touch::touch_cancel()
+     if (touchExt)
+         touchExt->touchCanceled();
+ 
++    mFocus = nullptr;
+     QWindowSystemInterface::handleTouchCancelEvent(nullptr, mParent->mTouchDevice);
+ }
+ 
+diff --git a/qtwayland/src/client/qwaylandintegration.cpp b/qtwayland/src/client/qwaylandintegration.cpp
+index c53ccb78..54861600 100644
+--- a/qtwayland/src/client/qwaylandintegration.cpp
++++ b/qtwayland/src/client/qwaylandintegration.cpp
+@@ -125,6 +125,9 @@ QWaylandIntegration::QWaylandIntegration()
+ #endif
+ 
+     reconfigureInputContext();
++
++    QWaylandWindow::fixedToplevelPositions =
++            !qEnvironmentVariableIsSet("QT_WAYLAND_DISABLE_FIXED_POSITIONS");
+ }
+ 
+ QWaylandIntegration::~QWaylandIntegration()
+@@ -192,14 +195,18 @@ QAbstractEventDispatcher *QWaylandIntegration::createEventDispatcher() const
+ 
+ void QWaylandIntegration::initialize()
+ {
++    mDisplay->initEventThread();
++
++    // Call after eventDispatcher is fully connected, for QWaylandDisplay::forceRoundTrip()
++    mDisplay->initialize();
++
++    // But the aboutToBlock() and awake() should be connected after initializePlatform().
++    // Otherwise the connected flushRequests() may consumes up all events before processEvents starts to wait,
++    // so that processEvents(QEventLoop::WaitForMoreEvents) may be blocked in the forceRoundTrip().
+     QAbstractEventDispatcher *dispatcher = QGuiApplicationPrivate::eventDispatcher;
+     QObject::connect(dispatcher, SIGNAL(aboutToBlock()), mDisplay.data(), SLOT(flushRequests()));
+     QObject::connect(dispatcher, SIGNAL(awake()), mDisplay.data(), SLOT(flushRequests()));
+ 
+-    int fd = wl_display_get_fd(mDisplay->wl_display());
+-    QSocketNotifier *sn = new QSocketNotifier(fd, QSocketNotifier::Read, mDisplay.data());
+-    QObject::connect(sn, SIGNAL(activated(QSocketDescriptor)), mDisplay.data(), SLOT(flushRequests()));
+-
+     // Qt does not support running with no screens
+     mDisplay->ensureScreen();
+ }
+@@ -262,6 +269,14 @@ QWaylandDisplay *QWaylandIntegration::display() const
+     return mDisplay.data();
+ }
+ 
++Qt::KeyboardModifiers QWaylandIntegration::queryKeyboardModifiers() const
++{
++    if (auto *seat = mDisplay->currentInputDevice()) {
++        return seat->modifiers();
++    }
++    return Qt::NoModifier;
++}
++
+ QList<int> QWaylandIntegration::possibleKeys(const QKeyEvent *event) const
+ {
+     if (auto *seat = mDisplay->currentInputDevice())
+@@ -479,7 +494,7 @@ void QWaylandIntegration::reconfigureInputContext()
+     }
+ #endif
+ 
+-    qCDebug(lcQpaWayland) << "using input method:" << inputContext()->metaObject()->className();
++    qCDebug(lcQpaWayland) << "using input method:" << (inputContext() ? inputContext()->metaObject()->className() : "<none>");
+ }
+ 
+ QWaylandShellIntegration *QWaylandIntegration::createShellIntegration(const QString &integrationName)
+diff --git a/qtwayland/src/client/qwaylandintegration_p.h b/qtwayland/src/client/qwaylandintegration_p.h
+index ff70ae25..73b80658 100644
+--- a/qtwayland/src/client/qwaylandintegration_p.h
++++ b/qtwayland/src/client/qwaylandintegration_p.h
+@@ -107,6 +107,8 @@ public:
+ 
+     QWaylandDisplay *display() const;
+ 
++    Qt::KeyboardModifiers queryKeyboardModifiers() const override;
++
+     QList<int> possibleKeys(const QKeyEvent *event) const override;
+ 
+     QStringList themeNames() const override;
+diff --git a/qtwayland/src/client/qwaylandprimaryselectionv1.cpp b/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
+index 832f9678..ea508771 100644
+--- a/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
++++ b/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
+@@ -54,11 +54,6 @@ QWaylandPrimarySelectionDeviceManagerV1::QWaylandPrimarySelectionDeviceManagerV1
+     : zwp_primary_selection_device_manager_v1(display->wl_registry(), id, qMin(version, uint(1)))
+     , m_display(display)
+ {
+-    // Create devices for all seats.
+-    // This only works if we get the global before all devices
+-    const auto seats = m_display->inputDevices();
+-    for (auto *seat : seats)
+-        seat->setPrimarySelectionDevice(createDevice(seat));
+ }
+ 
+ QWaylandPrimarySelectionDeviceV1 *QWaylandPrimarySelectionDeviceManagerV1::createDevice(QWaylandInputDevice *seat)
+diff --git a/qtwayland/src/client/qwaylandscreen.cpp b/qtwayland/src/client/qwaylandscreen.cpp
+index 6cb337de..5537dafd 100644
+--- a/qtwayland/src/client/qwaylandscreen.cpp
++++ b/qtwayland/src/client/qwaylandscreen.cpp
+@@ -60,7 +60,7 @@ QWaylandXdgOutputManagerV1::QWaylandXdgOutputManagerV1(QWaylandDisplay* display,
+ }
+ 
+ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uint32_t id)
+-    : QtWayland::wl_output(waylandDisplay->wl_registry(), id, qMin(version, 2))
++    : QtWayland::wl_output(waylandDisplay->wl_registry(), id, qMin(version, 3))
+     , m_outputId(id)
+     , mWaylandDisplay(waylandDisplay)
+     , mOutputName(QStringLiteral("Screen%1").arg(id))
+@@ -72,7 +72,7 @@ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uin
+         qCWarning(lcQpaWayland) << "wl_output done event not supported by compositor,"
+                                 << "QScreen may not work correctly";
+         mWaylandDisplay->forceRoundTrip(); // Give the compositor a chance to send geometry etc.
+-        mOutputDone = true; // Fake the done event
++        mProcessedEvents |= OutputDoneEvent; // Fake the done event
+         maybeInitialize();
+     }
+ }
+@@ -81,16 +81,29 @@ QWaylandScreen::~QWaylandScreen()
+ {
+     if (zxdg_output_v1::isInitialized())
+         zxdg_output_v1::destroy();
++    if (wl_output::isInitialized() && wl_output_get_version(wl_output::object()) >= WL_OUTPUT_RELEASE_SINCE_VERSION)
++        wl_output::release();
++}
++
++uint QWaylandScreen::requiredEvents() const
++{
++    uint ret = OutputDoneEvent;
++
++    if (mWaylandDisplay->xdgOutputManager()) {
++        ret |= XdgOutputNameEvent;
++
++        if (mWaylandDisplay->xdgOutputManager()->version() < 3)
++            ret |= XdgOutputDoneEvent;
++    }
++    return ret;
+ }
+ 
+ void QWaylandScreen::maybeInitialize()
+ {
+     Q_ASSERT(!mInitialized);
+ 
+-    if (!mOutputDone)
+-        return;
+-
+-    if (mWaylandDisplay->xdgOutputManager() && !mXdgOutputDone)
++    const uint requiredEvents = this->requiredEvents();
++    if ((mProcessedEvents & requiredEvents) != requiredEvents)
+         return;
+ 
+     mInitialized = true;
+@@ -276,9 +289,8 @@ void QWaylandScreen::output_scale(int32_t factor)
+ 
+ void QWaylandScreen::output_done()
+ {
+-    mOutputDone = true;
+-    if (zxdg_output_v1::isInitialized() && mWaylandDisplay->xdgOutputManager()->version() >= 3)
+-        mXdgOutputDone = true;
++    mProcessedEvents |= OutputDoneEvent;
++
+     if (mInitialized) {
+         updateOutputProperties();
+         if (zxdg_output_v1::isInitialized())
+@@ -339,7 +351,7 @@ void QWaylandScreen::zxdg_output_v1_done()
+     if (Q_UNLIKELY(mWaylandDisplay->xdgOutputManager()->version() >= 3))
+         qWarning(lcQpaWayland) << "zxdg_output_v1.done received on version 3 or newer, this is most likely a bug in the compositor";
+ 
+-    mXdgOutputDone = true;
++    mProcessedEvents |= XdgOutputDoneEvent;
+     if (mInitialized)
+         updateXdgOutputProperties();
+     else
+@@ -348,7 +360,11 @@ void QWaylandScreen::zxdg_output_v1_done()
+ 
+ void QWaylandScreen::zxdg_output_v1_name(const QString &name)
+ {
++    if (Q_UNLIKELY(mInitialized))
++        qWarning(lcQpaWayland) << "zxdg_output_v1.name received after output has been initialized, this is most likely a bug in the compositor";
++
+     mOutputName = name;
++    mProcessedEvents |= XdgOutputNameEvent;
+ }
+ 
+ void QWaylandScreen::updateXdgOutputProperties()
+diff --git a/qtwayland/src/client/qwaylandscreen_p.h b/qtwayland/src/client/qwaylandscreen_p.h
+index df1c94f2..050cfdc0 100644
+--- a/qtwayland/src/client/qwaylandscreen_p.h
++++ b/qtwayland/src/client/qwaylandscreen_p.h
+@@ -116,6 +116,13 @@ public:
+     static QWaylandScreen *fromWlOutput(::wl_output *output);
+ 
+ private:
++    enum Event : uint {
++        XdgOutputDoneEvent = 0x1,
++        OutputDoneEvent = 0x2,
++        XdgOutputNameEvent = 0x4,
++    };
++    uint requiredEvents() const;
++
+     void output_mode(uint32_t flags, int width, int height, int refresh) override;
+     void output_geometry(int32_t x, int32_t y,
+                          int32_t width, int32_t height,
+@@ -148,8 +155,7 @@ private:
+     QSize mPhysicalSize;
+     QString mOutputName;
+     Qt::ScreenOrientation m_orientation = Qt::PrimaryOrientation;
+-    bool mOutputDone = false;
+-    bool mXdgOutputDone = false;
++    uint mProcessedEvents = 0;
+     bool mInitialized = false;
+ 
+ #if QT_CONFIG(cursor)
+diff --git a/qtwayland/src/client/qwaylandshmbackingstore.cpp b/qtwayland/src/client/qwaylandshmbackingstore.cpp
+index dc7ff670..41cffdf7 100644
+--- a/qtwayland/src/client/qwaylandshmbackingstore.cpp
++++ b/qtwayland/src/client/qwaylandshmbackingstore.cpp
+@@ -52,6 +52,7 @@
+ 
+ #include <QtWaylandClient/private/wayland-wayland-client-protocol.h>
+ 
++#include <fcntl.h>
+ #include <unistd.h>
+ #include <sys/mman.h>
+ 
+@@ -61,6 +62,9 @@
+ #  ifndef MFD_CLOEXEC
+ #    define MFD_CLOEXEC     0x0001U
+ #  endif
++#  ifndef MFD_ALLOW_SEALING
++#    define MFD_ALLOW_SEALING 0x0002U
++#  endif
+ #endif
+ 
+ QT_BEGIN_NAMESPACE
+@@ -74,8 +78,10 @@ QWaylandShmBuffer::QWaylandShmBuffer(QWaylandDisplay *display,
+     int alloc = stride * size.height();
+     int fd = -1;
+ 
+-#ifdef SYS_memfd_create
+-    fd = syscall(SYS_memfd_create, "wayland-shm", MFD_CLOEXEC);
++#if defined(SYS_memfd_create) && defined(F_SEAL_SEAL)
++    fd = syscall(SYS_memfd_create, "wayland-shm", MFD_CLOEXEC | MFD_ALLOW_SEALING);
++    if (fd >= 0)
++        fcntl(fd, F_ADD_SEALS, F_SEAL_SHRINK | F_SEAL_SEAL);
+ #endif
+ 
+     QScopedPointer<QFile> filePointer;
+diff --git a/qtwayland/src/client/qwaylandwindow.cpp b/qtwayland/src/client/qwaylandwindow.cpp
+index cb82857a..fb2c59dc 100644
+--- a/qtwayland/src/client/qwaylandwindow.cpp
++++ b/qtwayland/src/client/qwaylandwindow.cpp
+@@ -76,7 +76,6 @@ QWaylandWindow *QWaylandWindow::mMouseGrab = nullptr;
+ QWaylandWindow::QWaylandWindow(QWindow *window, QWaylandDisplay *display)
+     : QPlatformWindow(window)
+     , mDisplay(display)
+-    , mFrameQueue(mDisplay->createFrameQueue())
+     , mResizeAfterSwap(qEnvironmentVariableIsSet("QT_WAYLAND_RESIZE_AFTER_SWAP"))
+ {
+     {
+@@ -95,9 +94,6 @@ QWaylandWindow::QWaylandWindow(QWindow *window, QWaylandDisplay *display)
+ 
+ QWaylandWindow::~QWaylandWindow()
+ {
+-    mDisplay->destroyFrameQueue(mFrameQueue);
+-    mDisplay->handleWindowDestroyed(this);
+-
+     delete mWindowDecoration;
+ 
+     if (mSurface)
+@@ -243,6 +239,7 @@ bool QWaylandWindow::shouldCreateSubSurface() const
+ 
+ void QWaylandWindow::reset()
+ {
++    closeChildPopups();
+     delete mShellSurface;
+     mShellSurface = nullptr;
+     delete mSubSurfaceWindow;
+@@ -255,17 +252,22 @@ void QWaylandWindow::reset()
+         mSurface.reset();
+     }
+ 
+-    if (mFrameCallback) {
+-        wl_callback_destroy(mFrameCallback);
+-        mFrameCallback = nullptr;
+-    }
++    {
++        QMutexLocker lock(&mFrameSyncMutex);
++        if (mFrameCallback) {
++            wl_callback_destroy(mFrameCallback);
++            mFrameCallback = nullptr;
++        }
+ 
+-    mFrameCallbackElapsedTimer.invalidate();
+-    mWaitingForFrameCallback = false;
++        mFrameCallbackElapsedTimer.invalidate();
++        mWaitingForFrameCallback = false;
++    }
+     mFrameCallbackTimedOut = false;
+ 
+     mMask = QRegion();
+     mQueuedBuffer = nullptr;
++
++    mDisplay->handleWindowDestroyed(this);
+ }
+ 
+ QWaylandWindow *QWaylandWindow::fromWlSurface(::wl_surface *surface)
+@@ -351,19 +353,25 @@ void QWaylandWindow::setGeometry_helper(const QRect &rect)
+     }
+ }
+ 
+-void QWaylandWindow::setGeometry(const QRect &rect)
++void QWaylandWindow::setGeometry(const QRect &r)
+ {
++    auto rect = r;
++    if (fixedToplevelPositions && !QPlatformWindow::parent() && window()->type() != Qt::Popup
++        && window()->type() != Qt::ToolTip) {
++        rect.moveTo(screen()->geometry().topLeft());
++    }
+     setGeometry_helper(rect);
+ 
+     if (window()->isVisible() && rect.isValid()) {
+         if (mWindowDecoration)
+             mWindowDecoration->update();
+ 
+-        if (mResizeAfterSwap && windowType() == Egl && mSentInitialResize)
++        if (mResizeAfterSwap && windowType() == Egl && mSentInitialResize) {
++            QMutexLocker lock(&mResizeLock);
+             mResizeDirty = true;
+-        else
++        } else {
+             QWindowSystemInterface::handleGeometryChange(window(), geometry());
+-
++        }
+         mSentInitialResize = true;
+     }
+     QRect exposeGeometry(QPoint(), geometry().size());
+@@ -374,7 +382,7 @@ void QWaylandWindow::setGeometry(const QRect &rect)
+         mShellSurface->setWindowGeometry(windowContentGeometry());
+ 
+     if (isOpaque() && mMask.isEmpty())
+-        setOpaqueArea(rect);
++        setOpaqueArea(QRect(QPoint(0, 0), rect.size()));
+ }
+ 
+ void QWaylandWindow::resizeFromApplyConfigure(const QSize &sizeWithMargins, const QPoint &offset)
+@@ -399,21 +407,6 @@ void QWaylandWindow::sendExposeEvent(const QRect &rect)
+     mLastExposeGeometry = rect;
+ }
+ 
+-
+-static QVector<QPointer<QWaylandWindow>> activePopups;
+-
+-void QWaylandWindow::closePopups(QWaylandWindow *parent)
+-{
+-    while (!activePopups.isEmpty()) {
+-        auto popup = activePopups.takeLast();
+-        if (popup.isNull())
+-            continue;
+-        if (popup.data() == parent)
+-            return;
+-        popup->reset();
+-    }
+-}
+-
+ QPlatformScreen *QWaylandWindow::calculateScreenFromSurfaceEvents() const
+ {
+     QReadLocker lock(&mSurfaceLock);
+@@ -433,10 +426,7 @@ void QWaylandWindow::setVisible(bool visible)
+     lastVisible = visible;
+ 
+     if (visible) {
+-        if (window()->type() == Qt::Popup || window()->type() == Qt::ToolTip)
+-            activePopups << this;
+         initWindow();
+-        mDisplay->flushRequests();
+ 
+         setGeometry(windowGeometry());
+         // Don't flush the events here, or else the newly visible window may start drawing, but since
+@@ -444,7 +434,6 @@ void QWaylandWindow::setVisible(bool visible)
+         // QWaylandShmBackingStore::beginPaint().
+     } else {
+         sendExposeEvent(QRect());
+-        closePopups(this);
+         reset();
+     }
+ }
+@@ -556,12 +545,12 @@ void QWaylandWindow::sendRecursiveExposeEvent()
+ 
+ void QWaylandWindow::attach(QWaylandBuffer *buffer, int x, int y)
+ {
+-    Q_ASSERT(!buffer->committed());
+     QReadLocker locker(&mSurfaceLock);
+     if (mSurface == nullptr)
+         return;
+ 
+     if (buffer) {
++        Q_ASSERT(!buffer->committed());
+         handleUpdate();
+         buffer->setBusy();
+ 
+@@ -583,7 +572,11 @@ void QWaylandWindow::damage(const QRect &rect)
+     if (mSurface == nullptr)
+         return;
+ 
+-    mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    const int s = scale();
++    if (mDisplay->compositorVersion() >= 4)
++        mSurface->damage_buffer(s * rect.x(), s * rect.y(), s * rect.width(), s * rect.height());
++    else
++        mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
+ }
+ 
+ void QWaylandWindow::safeCommit(QWaylandBuffer *buffer, const QRegion &damage)
+@@ -619,8 +612,14 @@ void QWaylandWindow::commit(QWaylandBuffer *buffer, const QRegion &damage)
+         return;
+ 
+     attachOffset(buffer);
+-    for (const QRect &rect: damage)
+-        mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    if (mDisplay->compositorVersion() >= 4) {
++        const int s = scale();
++        for (const QRect &rect: damage)
++            mSurface->damage_buffer(s * rect.x(), s * rect.y(), s * rect.width(), s * rect.height());
++    } else {
++        for (const QRect &rect: damage)
++            mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    }
+     Q_ASSERT(!buffer->committed());
+     buffer->setCommitted();
+     mSurface->commit();
+@@ -635,42 +634,53 @@ void QWaylandWindow::commit()
+ 
+ const wl_callback_listener QWaylandWindow::callbackListener = {
+     [](void *data, wl_callback *callback, uint32_t time) {
+-        Q_UNUSED(callback);
+         Q_UNUSED(time);
+         auto *window = static_cast<QWaylandWindow*>(data);
+-        window->handleFrameCallback();
++        window->handleFrameCallback(callback);
+     }
+ };
+ 
+-void QWaylandWindow::handleFrameCallback()
++void QWaylandWindow::handleFrameCallback(wl_callback* callback)
+ {
++    QMutexLocker locker(&mFrameSyncMutex);
++    if (!mFrameCallback) {
++        // This means the callback is already unset by QWaylandWindow::reset.
++        // The wl_callback object will be destroyed there too.
++        return;
++    }
++    Q_ASSERT(callback == mFrameCallback);
++    wl_callback_destroy(callback);
++    mFrameCallback = nullptr;
++
+     mWaitingForFrameCallback = false;
+     mFrameCallbackElapsedTimer.invalidate();
+ 
+     // The rest can wait until we can run it on the correct thread
+-    if (!mWaitingForUpdateDelivery) {
+-        auto doHandleExpose = [this]() {
+-            bool wasExposed = isExposed();
+-            mFrameCallbackTimedOut = false;
+-            if (!wasExposed && isExposed()) // Did setting mFrameCallbackTimedOut make the window exposed?
+-                sendExposeEvent(QRect(QPoint(), geometry().size()));
+-            if (wasExposed && hasPendingUpdateRequest())
+-                deliverUpdateRequest();
+-
+-            mWaitingForUpdateDelivery = false;
+-        };
++    auto doHandleExpose = [this]() {
++        mWaitingForUpdateDelivery.storeRelease(false);
++        bool wasExposed = isExposed();
++        mFrameCallbackTimedOut = false;
++        if (!wasExposed && isExposed()) // Did setting mFrameCallbackTimedOut make the window exposed?
++            sendExposeEvent(QRect(QPoint(), geometry().size()));
++        if (wasExposed && hasPendingUpdateRequest())
++            deliverUpdateRequest();
++    };
+ 
++    if (mWaitingForUpdateDelivery.testAndSetAcquire(false, true)) {
+         // Queued connection, to make sure we don't call handleUpdate() from inside waitForFrameSync()
+         // in the single-threaded case.
+-        mWaitingForUpdateDelivery = true;
+         QMetaObject::invokeMethod(this, doHandleExpose, Qt::QueuedConnection);
+     }
++
++    mFrameSyncWait.notify_all();
+ }
+ 
+ bool QWaylandWindow::waitForFrameSync(int timeout)
+ {
+-    QMutexLocker locker(mFrameQueue.mutex);
+-    mDisplay->dispatchQueueWhile(mFrameQueue.queue, [&]() { return mWaitingForFrameCallback; }, timeout);
++    QMutexLocker locker(&mFrameSyncMutex);
++
++    QDeadlineTimer deadline(timeout);
++    while (mWaitingForFrameCallback && mFrameSyncWait.wait(&mFrameSyncMutex, deadline)) { }
+ 
+     if (mWaitingForFrameCallback) {
+         qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
+@@ -868,6 +878,17 @@ bool QWaylandWindow::createDecoration()
+             subsurf->set_position(pos.x() + m.left(), pos.y() + m.top());
+         }
+         sendExposeEvent(QRect(QPoint(), geometry().size()));
++
++        // This is a special case where the buffer is recreated, but since
++        // the content rect remains the same, the widgets remain the same
++        // size and are not redrawn, leaving the new buffer empty. As a simple
++        // work-around, we trigger a full extra update whenever the client-side
++        // window decorations are toggled while the window is showing.
++        // Note: createDecoration() is sometimes called from the render thread
++        // of Qt Quick. This is essentially wrong and could potentially cause problems,
++        // but until the underlying issue has been fixed, we have to use invokeMethod()
++        // here to avoid asserts.
++        QMetaObject::invokeMethod(window(), &QWindow::requestUpdate);
+     }
+ 
+     return mWindowDecoration;
+@@ -1023,6 +1044,13 @@ void QWaylandWindow::handleScreensChanged()
+ 
+     QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->QPlatformScreen::screen());
+     mLastReportedScreen = newScreen;
++    if (fixedToplevelPositions && !QPlatformWindow::parent() && window()->type() != Qt::Popup
++        && window()->type() != Qt::ToolTip
++        && geometry().topLeft() != newScreen->geometry().topLeft()) {
++        auto geometry = this->geometry();
++        geometry.moveTo(newScreen->geometry().topLeft());
++        setGeometry(geometry);
++    }
+ 
+     int scale = newScreen->isPlaceholder() ? 1 : static_cast<QWaylandScreen *>(newScreen)->scale();
+     if (scale != mScale) {
+@@ -1094,10 +1122,18 @@ bool QWaylandWindow::setMouseGrabEnabled(bool grab)
+     return true;
+ }
+ 
++Qt::WindowStates QWaylandWindow::windowStates() const
++{
++    return mLastReportedWindowStates;
++}
++
+ void QWaylandWindow::handleWindowStatesChanged(Qt::WindowStates states)
+ {
+     createDecoration();
+-    QWindowSystemInterface::handleWindowStateChanged(window(), states, mLastReportedWindowStates);
++    Qt::WindowStates statesWithoutActive = states & ~Qt::WindowActive;
++    Qt::WindowStates lastStatesWithoutActive = mLastReportedWindowStates & ~Qt::WindowActive;
++    QWindowSystemInterface::handleWindowStateChanged(window(), statesWithoutActive,
++                                                     lastStatesWithoutActive);
+     mLastReportedWindowStates = states;
+ }
+ 
+@@ -1139,19 +1175,24 @@ void QWaylandWindow::timerEvent(QTimerEvent *event)
+     if (event->timerId() != mFrameCallbackCheckIntervalTimerId)
+         return;
+ 
+-    bool callbackTimerExpired = mFrameCallbackElapsedTimer.hasExpired(mFrameCallbackTimeout);
+-    if (!mFrameCallbackElapsedTimer.isValid() || callbackTimerExpired ) {
+-        killTimer(mFrameCallbackCheckIntervalTimerId);
+-        mFrameCallbackCheckIntervalTimerId = -1;
+-    }
+-    if (mFrameCallbackElapsedTimer.isValid() && callbackTimerExpired) {
+-        mFrameCallbackElapsedTimer.invalidate();
++    {
++        QMutexLocker lock(&mFrameSyncMutex);
+ 
+-        qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
+-        mFrameCallbackTimedOut = true;
+-        mWaitingForUpdate = false;
+-        sendExposeEvent(QRect());
++        bool callbackTimerExpired = mFrameCallbackElapsedTimer.hasExpired(mFrameCallbackTimeout);
++        if (!mFrameCallbackElapsedTimer.isValid() || callbackTimerExpired ) {
++            killTimer(mFrameCallbackCheckIntervalTimerId);
++            mFrameCallbackCheckIntervalTimerId = -1;
++        }
++        if (!mFrameCallbackElapsedTimer.isValid() || !callbackTimerExpired) {
++            return;
++        }
++        mFrameCallbackElapsedTimer.invalidate();
+     }
++
++    qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
++    mFrameCallbackTimedOut = true;
++    mWaitingForUpdate = false;
++    sendExposeEvent(QRect());
+ }
+ 
+ void QWaylandWindow::requestUpdate()
+@@ -1160,8 +1201,11 @@ void QWaylandWindow::requestUpdate()
+     Q_ASSERT(hasPendingUpdateRequest()); // should be set by QPA
+ 
+     // If we have a frame callback all is good and will be taken care of there
+-    if (mWaitingForFrameCallback)
+-        return;
++    {
++        QMutexLocker locker(&mFrameSyncMutex);
++        if (mWaitingForFrameCallback)
++            return;
++    }
+ 
+     // If we've already called deliverUpdateRequest(), but haven't seen any attach+commit/swap yet
+     // This is a somewhat redundant behavior and might indicate a bug in the calling code, so log
+@@ -1174,7 +1218,12 @@ void QWaylandWindow::requestUpdate()
+     // so use invokeMethod to delay the delivery a bit.
+     QMetaObject::invokeMethod(this, [this] {
+         // Things might have changed in the meantime
+-        if (hasPendingUpdateRequest() && !mWaitingForFrameCallback)
++        {
++            QMutexLocker locker(&mFrameSyncMutex);
++            if (mWaitingForFrameCallback)
++                return;
++        }
++        if (hasPendingUpdateRequest())
+             deliverUpdateRequest();
+     }, Qt::QueuedConnection);
+ }
+@@ -1185,19 +1234,18 @@ void QWaylandWindow::requestUpdate()
+ void QWaylandWindow::handleUpdate()
+ {
+     qCDebug(lcWaylandBackingstore) << "handleUpdate" << QThread::currentThread();
++
+     // TODO: Should sync subsurfaces avoid requesting frame callbacks?
+     QReadLocker lock(&mSurfaceLock);
+     if (!mSurface)
+         return;
+ 
+-    if (mFrameCallback) {
+-        wl_callback_destroy(mFrameCallback);
+-        mFrameCallback = nullptr;
+-    }
++    QMutexLocker locker(&mFrameSyncMutex);
++    if (mWaitingForFrameCallback)
++        return;
+ 
+-    QMutexLocker locker(mFrameQueue.mutex);
+     struct ::wl_surface *wrappedSurface = reinterpret_cast<struct ::wl_surface *>(wl_proxy_create_wrapper(mSurface->object()));
+-    wl_proxy_set_queue(reinterpret_cast<wl_proxy *>(wrappedSurface), mFrameQueue.queue);
++    wl_proxy_set_queue(reinterpret_cast<wl_proxy *>(wrappedSurface), mDisplay->frameEventQueue());
+     mFrameCallback = wl_surface_frame(wrappedSurface);
+     wl_proxy_wrapper_destroy(wrappedSurface);
+     wl_callback_add_listener(mFrameCallback, &QWaylandWindow::callbackListener, this);
+@@ -1207,6 +1255,8 @@ void QWaylandWindow::handleUpdate()
+     // Start a timer for handling the case when the compositor stops sending frame callbacks.
+     if (mFrameCallbackTimeout > 0) {
+         QMetaObject::invokeMethod(this, [this] {
++            QMutexLocker locker(&mFrameSyncMutex);
++
+             if (mWaitingForFrameCallback) {
+                 if (mFrameCallbackCheckIntervalTimerId < 0)
+                     mFrameCallbackCheckIntervalTimerId = startTimer(mFrameCallbackTimeout);
+@@ -1267,6 +1317,20 @@ void QWaylandWindow::setOpaqueArea(const QRegion &opaqueArea)
+     wl_region_destroy(region);
+ }
+ 
++void QWaylandWindow::addChildPopup(QWaylandWindow *surface) {
++    mChildPopups.append(surface);
++}
++
++void QWaylandWindow::removeChildPopup(QWaylandWindow *surface) {
++    mChildPopups.removeAll(surface);
++}
++
++void QWaylandWindow::closeChildPopups() {
++    while (!mChildPopups.isEmpty()) {
++        auto popup = mChildPopups.takeLast();
++        popup->reset();
++    }
++}
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/client/qwaylandwindow_p.h b/qtwayland/src/client/qwaylandwindow_p.h
+index 01337cff..2f219d8c 100644
+--- a/qtwayland/src/client/qwaylandwindow_p.h
++++ b/qtwayland/src/client/qwaylandwindow_p.h
+@@ -98,6 +98,9 @@ public:
+     QWaylandWindow(QWindow *window, QWaylandDisplay *display);
+     ~QWaylandWindow() override;
+ 
++    // Keep Toplevels position on the top left corner of their screen
++    static inline bool fixedToplevelPositions = true;
++
+     virtual WindowType windowType() const = 0;
+     virtual void ensureSize();
+     WId winId() const override;
+@@ -148,6 +151,7 @@ public:
+     void setWindowState(Qt::WindowStates states) override;
+     void setWindowFlags(Qt::WindowFlags flags) override;
+     void handleWindowStatesChanged(Qt::WindowStates states);
++    Qt::WindowStates windowStates() const;
+ 
+     void raise() override;
+     void lower() override;
+@@ -206,6 +210,10 @@ public:
+     void handleUpdate();
+     void deliverUpdateRequest() override;
+ 
++    void addChildPopup(QWaylandWindow* child);
++    void removeChildPopup(QWaylandWindow* child);
++    void closeChildPopups();
++
+ public slots:
+     void applyConfigure();
+ 
+@@ -215,7 +223,11 @@ signals:
+ 
+ protected:
+     QWaylandDisplay *mDisplay = nullptr;
++
++    // mSurface can be written by the main thread. Other threads should claim a read lock for access
++    mutable QReadWriteLock mSurfaceLock;
+     QScopedPointer<QWaylandSurface> mSurface;
++
+     QWaylandShellSurface *mShellSurface = nullptr;
+     QWaylandSubSurface *mSubSurfaceWindow = nullptr;
+     QVector<QWaylandSubSurface *> mChildren;
+@@ -225,13 +237,14 @@ protected:
+     Qt::MouseButtons mMousePressedInContentArea = Qt::NoButton;
+ 
+     WId mWindowId;
+-    bool mWaitingForFrameCallback = false;
+     bool mFrameCallbackTimedOut = false; // Whether the frame callback has timed out
+-    bool mWaitingForUpdateDelivery = false;
+     int mFrameCallbackCheckIntervalTimerId = -1;
+-    QElapsedTimer mFrameCallbackElapsedTimer;
+-    struct ::wl_callback *mFrameCallback = nullptr;
+-    QWaylandDisplay::FrameQueue mFrameQueue;
++    QAtomicInt mWaitingForUpdateDelivery = false;
++
++    bool mWaitingForFrameCallback = false; // Protected by mFrameSyncMutex
++    QElapsedTimer mFrameCallbackElapsedTimer; // Protected by mFrameSyncMutex
++    struct ::wl_callback *mFrameCallback = nullptr; // Protected by mFrameSyncMutex
++    QMutex mFrameSyncMutex;
+     QWaitCondition mFrameSyncWait;
+ 
+     // True when we have called deliverRequestUpdate, but the client has not yet attached a new buffer
+@@ -261,6 +274,8 @@ protected:
+     QWaylandBuffer *mQueuedBuffer = nullptr;
+     QRegion mQueuedBufferDamage;
+ 
++    QList<QPointer<QWaylandWindow>> mChildPopups;
++
+ private:
+     void setGeometry_helper(const QRect &rect);
+     void initWindow();
+@@ -283,12 +298,10 @@ private:
+     QRect mLastExposeGeometry;
+ 
+     static const wl_callback_listener callbackListener;
+-    void handleFrameCallback();
++    void handleFrameCallback(struct ::wl_callback* callback);
+ 
+     static QWaylandWindow *mMouseGrab;
+ 
+-    mutable QReadWriteLock mSurfaceLock;
+-
+     friend class QWaylandSubSurface;
+ };
+ 
+diff --git a/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h b/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
+index ccad0048..4cc9b3b8 100644
+--- a/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
++++ b/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
+@@ -73,11 +73,10 @@ public:
+         return true;
+     }
+     virtual QWaylandShellSurface *createShellSurface(QWaylandWindow *window) = 0;
++    // kept for binary compat with layer-shell-qt
+     virtual void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) {
+-        if (newFocus)
+-            m_display->handleWindowActivated(newFocus);
+-        if (oldFocus)
+-            m_display->handleWindowDeactivated(oldFocus);
++        Q_UNUSED(newFocus);
++        Q_UNUSED(oldFocus);
+     }
+     virtual void *nativeResourceForWindow(const QByteArray &resource, QWindow *window) {
+         Q_UNUSED(resource);
+diff --git a/qtwayland/src/compositor/configure.json b/qtwayland/src/compositor/configure.json
+index bcfd5215..da95d07b 100644
+--- a/qtwayland/src/compositor/configure.json
++++ b/qtwayland/src/compositor/configure.json
+@@ -7,6 +7,31 @@
+     "testDir": "../../config.tests",
+ 
+     "libraries": {
++        "wayland-client": {
++            "label": "Wayland client library",
++            "headers": "wayland-version.h",
++            "test": {
++                "main": [
++                    "#if WAYLAND_VERSION_MAJOR < 1",
++                    "# error Wayland 1.8.0 or higher required",
++                    "#endif",
++                    "#if WAYLAND_VERSION_MAJOR == 1",
++                    "# if WAYLAND_VERSION_MINOR < 8",
++                    "#  error Wayland 1.8.0 or higher required",
++                    "# endif",
++                    "# if WAYLAND_VERSION_MINOR == 8",
++                    "#  if WAYLAND_VERSION_MICRO < 0",
++                    "#   error Wayland 1.8.0 or higher required",
++                    "#  endif",
++                    "# endif",
++                    "#endif"
++                 ]
++            },
++            "sources": [
++                { "type": "pkgConfig", "args": "wayland-client" },
++                "-lwayland-client"
++            ]
++        },
+         "wayland-server": {
+             "label": "wayland-server",
+             "headers": "wayland-version.h",
+@@ -151,8 +176,7 @@
+                     "#endif"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "dmabuf-client-buffer": {
+             "label": "Linux Client dma-buf Buffer Sharing",
+@@ -176,8 +200,7 @@
+                     "return 0;"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "vulkan-server-buffer": {
+             "label": "Vulkan Buffer Sharing",
+@@ -195,7 +218,8 @@
+                     "exportAllocInfo.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR;",
+                     "return 0;"
+                 ]
+-            }
++            },
++            "use": "wayland-client"
+         }
+     },
+ 
+diff --git a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
+index 7889f575..64140672 100644
+--- a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
++++ b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
+@@ -40,6 +40,7 @@
+ #include "qwaylandeglwindow.h"
+ 
+ #include <QtWaylandClient/private/qwaylandscreen_p.h>
++#include <QtWaylandClient/private/qwaylandsurface_p.h>
+ #include "qwaylandglcontext.h"
+ 
+ #include <QtEglSupport/private/qeglconvenience_p.h>
+@@ -124,6 +125,7 @@ void QWaylandEglWindow::updateSurface(bool create)
+         }
+         mOffset = QPoint();
+     } else {
++        QReadLocker locker(&mSurfaceLock);
+         if (m_waylandEglWindow) {
+             int current_width, current_height;
+             static bool disableResizeCheck = qgetenv("QT_WAYLAND_DISABLE_RESIZECHECK").toInt();
+@@ -131,14 +133,16 @@ void QWaylandEglWindow::updateSurface(bool create)
+             if (!disableResizeCheck) {
+                 wl_egl_window_get_attached_size(m_waylandEglWindow, &current_width, &current_height);
+             }
+-            if (disableResizeCheck || (current_width != sizeWithMargins.width() || current_height != sizeWithMargins.height())) {
++            if (disableResizeCheck || (current_width != sizeWithMargins.width() || current_height != sizeWithMargins.height()) || m_requestedSize != sizeWithMargins) {
+                 wl_egl_window_resize(m_waylandEglWindow, sizeWithMargins.width(), sizeWithMargins.height(), mOffset.x(), mOffset.y());
++                m_requestedSize = sizeWithMargins;
+                 mOffset = QPoint();
+ 
+                 m_resize = true;
+             }
+-        } else if (create && wlSurface()) {
+-            m_waylandEglWindow = wl_egl_window_create(wlSurface(), sizeWithMargins.width(), sizeWithMargins.height());
++        } else if (create && mSurface) {
++            m_waylandEglWindow = wl_egl_window_create(mSurface->object(), sizeWithMargins.width(), sizeWithMargins.height());
++            m_requestedSize = sizeWithMargins;
+         }
+ 
+         if (!m_eglSurface && m_waylandEglWindow && create) {
+diff --git a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
+index 5b1f4d56..0079dfef 100644
+--- a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
++++ b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
+@@ -88,6 +88,7 @@ private:
+     mutable QOpenGLFramebufferObject *m_contentFBO = nullptr;
+ 
+     QSurfaceFormat m_format;
++    QSize m_requestedSize;
+ };
+ 
+ }
+diff --git a/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h b/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
+index 56a710c3..c6a8b6c6 100644
+--- a/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
++++ b/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
+@@ -41,6 +41,8 @@
+ #include <QtCore/QTextStream>
+ #include <QtGui/QOpenGLTexture>
+ 
++#include <array>
++
+ #include <EGL/egl.h>
+ #include <EGL/eglext.h>
+ 
+diff --git a/qtwayland/src/plugins/decorations/bradient/main.cpp b/qtwayland/src/plugins/decorations/bradient/main.cpp
+index e75fda3c..fa885143 100644
+--- a/qtwayland/src/plugins/decorations/bradient/main.cpp
++++ b/qtwayland/src/plugins/decorations/bradient/main.cpp
+@@ -164,13 +164,10 @@ void QWaylandBradientDecoration::paint(QPaintDevice *device)
+     // Window icon
+     QIcon icon = waylandWindow()->windowIcon();
+     if (!icon.isNull()) {
+-        QPixmap pixmap = icon.pixmap(QSize(128, 128));
+-        QPixmap scaled = pixmap.scaled(22, 22, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+-
+         QRectF iconRect(0, 0, 22, 22);
+-        p.drawPixmap(iconRect.adjusted(margins().left() + BUTTON_SPACING, 4,
+-                                       margins().left() + BUTTON_SPACING, 4),
+-                     scaled, iconRect);
++        iconRect.adjust(margins().left() + BUTTON_SPACING, 4,
++                        margins().left() + BUTTON_SPACING, 4),
++        icon.paint(&p, iconRect.toRect());
+     }
+ 
+     // Window title
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
+index 85d25e3c..60bdd491 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
+@@ -47,18 +47,21 @@ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
+-QWaylandXdgPopupV5::QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow *window)
++QWaylandXdgPopupV5::QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow* parent, QWaylandWindow *window)
+     : QWaylandShellSurface(window)
+     , QtWayland::xdg_popup_v5(popup)
++    , m_parent(parent)
+     , m_window(window)
+ {
+     if (window->display()->windowExtension())
+         m_extendedWindow = new QWaylandExtendedSurface(window);
++    m_parent->addChildPopup(m_window);
+ }
+ 
+ QWaylandXdgPopupV5::~QWaylandXdgPopupV5()
+ {
+     xdg_popup_destroy(object());
++    m_parent->removeChildPopup(m_window);
+     delete m_extendedWindow;
+ }
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
+index 7494f6a6..d85f130b 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
+@@ -70,7 +70,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgPopupV5 : public QWaylandShellSurface
+ {
+     Q_OBJECT
+ public:
+-    QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow *window);
++    QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow* parent, QWaylandWindow *window);
+     ~QWaylandXdgPopupV5() override;
+ 
+ protected:
+@@ -78,6 +78,7 @@ protected:
+ 
+ private:
+     QWaylandExtendedSurface *m_extendedWindow = nullptr;
++    QWaylandWindow *m_parent = nullptr;
+     QWaylandWindow *m_window = nullptr;
+ };
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
+index 7e242c4a..def8452a 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
+@@ -84,7 +84,7 @@ QWaylandXdgPopupV5 *QWaylandXdgShellV5::createXdgPopup(QWaylandWindow *window, Q
+     int x = position.x() + parentWindow->frameMargins().left();
+     int y = position.y() + parentWindow->frameMargins().top();
+ 
+-    auto popup = new QWaylandXdgPopupV5(get_xdg_popup(window->wlSurface(), parentSurface, seat, m_popupSerial, x, y), window);
++    auto popup = new QWaylandXdgPopupV5(get_xdg_popup(window->wlSurface(), parentSurface, seat, m_popupSerial, x, y), parentWindow, window);
+     m_popups.append(window);
+     QObject::connect(popup, &QWaylandXdgPopupV5::destroyed, [this, window](){
+         m_popups.removeOne(window);
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
+index 4e25949f..cfc60939 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
+@@ -85,13 +85,6 @@ QWaylandShellSurface *QWaylandXdgShellV5Integration::createShellSurface(QWayland
+     return m_xdgShell->createXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellV5Integration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) {
+-    if (newFocus && qobject_cast<QWaylandXdgPopupV5 *>(newFocus->shellSurface()))
+-        m_display->handleWindowActivated(newFocus);
+-    if (oldFocus && qobject_cast<QWaylandXdgPopupV5 *>(oldFocus->shellSurface()))
+-        m_display->handleWindowDeactivated(oldFocus);
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
+index ce6bdb9e..aed88670 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
+@@ -67,7 +67,6 @@ public:
+     QWaylandXdgShellV5Integration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShellV5> m_xdgShell;
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
+index 8c371661..151c78e3 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
+@@ -174,6 +174,7 @@ QWaylandXdgSurfaceV6::Popup::Popup(QWaylandXdgSurfaceV6 *xdgSurface, QWaylandXdg
+     , m_xdgSurface(xdgSurface)
+     , m_parent(parent)
+ {
++    m_parent->window()->addChildPopup(m_xdgSurface->window());
+ }
+ 
+ QWaylandXdgSurfaceV6::Popup::~Popup()
+@@ -181,6 +182,8 @@ QWaylandXdgSurfaceV6::Popup::~Popup()
+     if (isInitialized())
+         destroy();
+ 
++    m_parent->window()->removeChildPopup(m_xdgSurface->window());
++
+     if (m_grabbing) {
+         auto *shell = m_xdgSurface->m_shell;
+         Q_ASSERT(shell->m_topmostGrabbingPopup == this);
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
+index 03164316..e8da8ba1 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
+@@ -68,20 +68,6 @@ QWaylandShellSurface *QWaylandXdgShellV6Integration::createShellSurface(QWayland
+     return m_xdgShell->getXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellV6Integration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus)
+-{
+-    if (newFocus) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurfaceV6 *>(newFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowActivated(newFocus);
+-    }
+-    if (oldFocus && qobject_cast<QWaylandXdgSurfaceV6 *>(oldFocus->shellSurface())) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurfaceV6 *>(oldFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowDeactivated(oldFocus);
+-    }
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
+index 261f8cbb..c1bcd5c6 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
+@@ -65,7 +65,6 @@ public:
+     QWaylandXdgShellV6Integration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShellV6> m_xdgShell;
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
+index f3e3c330..fa6d5808 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
+@@ -67,11 +67,6 @@ QWaylandXdgSurface::Toplevel::Toplevel(QWaylandXdgSurface *xdgSurface)
+ 
+ QWaylandXdgSurface::Toplevel::~Toplevel()
+ {
+-    if (m_applied.states & Qt::WindowActive) {
+-        QWaylandWindow *window = m_xdgSurface->window();
+-        window->display()->handleWindowDeactivated(window);
+-    }
+-
+     // The protocol spec requires that the decoration object is deleted before xdg_toplevel.
+     delete m_decoration;
+     m_decoration = nullptr;
+@@ -85,16 +80,15 @@ void QWaylandXdgSurface::Toplevel::applyConfigure()
+     if (!(m_applied.states & (Qt::WindowMaximized|Qt::WindowFullScreen)))
+         m_normalSize = m_xdgSurface->m_window->windowFrameGeometry().size();
+ 
+-    if ((m_pending.states & Qt::WindowActive) && !(m_applied.states & Qt::WindowActive))
++    if ((m_pending.states & Qt::WindowActive) && !(m_applied.states & Qt::WindowActive)
++        && !m_xdgSurface->m_window->display()->isKeyboardAvailable())
+         m_xdgSurface->m_window->display()->handleWindowActivated(m_xdgSurface->m_window);
+ 
+-    if (!(m_pending.states & Qt::WindowActive) && (m_applied.states & Qt::WindowActive))
++    if (!(m_pending.states & Qt::WindowActive) && (m_applied.states & Qt::WindowActive)
++        && !m_xdgSurface->m_window->display()->isKeyboardAvailable())
+         m_xdgSurface->m_window->display()->handleWindowDeactivated(m_xdgSurface->m_window);
+ 
+-    // TODO: none of the other plugins send WindowActive either, but is it on purpose?
+-    Qt::WindowStates statesWithoutActive = m_pending.states & ~Qt::WindowActive;
+-
+-    m_xdgSurface->m_window->handleWindowStatesChanged(statesWithoutActive);
++    m_xdgSurface->m_window->handleWindowStatesChanged(m_pending.states);
+ 
+     if (m_pending.size.isEmpty()) {
+         // An empty size in the configure means it's up to the client to choose the size
+@@ -105,8 +99,6 @@ void QWaylandXdgSurface::Toplevel::applyConfigure()
+         m_xdgSurface->m_window->resizeFromApplyConfigure(m_pending.size);
+     }
+ 
+-    m_xdgSurface->setSizeHints();
+-
+     m_applied = m_pending;
+     qCDebug(lcQpaWayland) << "Applied pending xdg_toplevel configure event:" << m_applied.size << m_applied.states;
+ }
+@@ -203,12 +195,17 @@ QtWayland::xdg_toplevel::resize_edge QWaylandXdgSurface::Toplevel::convertToResi
+                 | ((edges & Qt::RightEdge) ? resize_edge_right : 0));
+ }
+ 
+-QWaylandXdgSurface::Popup::Popup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parent,
++QWaylandXdgSurface::Popup::Popup(QWaylandXdgSurface *xdgSurface, QWaylandWindow *parent,
+                                  QtWayland::xdg_positioner *positioner)
+-    : xdg_popup(xdgSurface->get_popup(parent->object(), positioner->object()))
+-    , m_xdgSurface(xdgSurface)
++    : m_xdgSurface(xdgSurface)
++    , m_parentXdgSurface(qobject_cast<QWaylandXdgSurface *>(parent->shellSurface()))
+     , m_parent(parent)
+ {
++
++    init(xdgSurface->get_popup(m_parentXdgSurface ? m_parentXdgSurface->object() : nullptr, positioner->object()));
++    if (m_parent) {
++        m_parent->addChildPopup(m_xdgSurface->window());
++    }
+ }
+ 
+ QWaylandXdgSurface::Popup::~Popup()
+@@ -216,10 +213,24 @@ QWaylandXdgSurface::Popup::~Popup()
+     if (isInitialized())
+         destroy();
+ 
++    if (m_parent) {
++        m_parent->removeChildPopup(m_xdgSurface->window());
++    }
++
+     if (m_grabbing) {
+         auto *shell = m_xdgSurface->m_shell;
+         Q_ASSERT(shell->m_topmostGrabbingPopup == this);
+-        shell->m_topmostGrabbingPopup = m_parent->m_popup;
++        shell->m_topmostGrabbingPopup = m_parentXdgSurface ? m_parentXdgSurface->m_popup : nullptr;
++        m_grabbing = false;
++
++        // Synthesize Qt enter/leave events for popup
++        QWindow *leave = nullptr;
++        if (m_xdgSurface && m_xdgSurface->window())
++            leave = m_xdgSurface->window()->window();
++        QWindowSystemInterface::handleLeaveEvent(leave);
++
++        if (QWindow *enter = QGuiApplication::topLevelAt(QCursor::pos()))
++            QWindowSystemInterface::handleEnterEvent(enter, enter->mapFromGlobal(QCursor::pos()), QCursor::pos());
+     }
+ }
+ 
+@@ -257,6 +268,7 @@ QWaylandXdgSurface::QWaylandXdgSurface(QWaylandXdgShell *shell, ::xdg_surface *s
+                 m_toplevel->set_parent(parentXdgSurface->m_toplevel->object());
+         }
+     }
++    setSizeHints();
+ }
+ 
+ QWaylandXdgSurface::~QWaylandXdgSurface()
+@@ -400,8 +412,6 @@ void QWaylandXdgSurface::setPopup(QWaylandWindow *parent)
+ {
+     Q_ASSERT(!m_toplevel && !m_popup);
+ 
+-    auto parentXdgSurface = static_cast<QWaylandXdgSurface *>(parent->shellSurface());
+-
+     auto positioner = new QtWayland::xdg_positioner(m_shell->create_positioner());
+     // set_popup expects a position relative to the parent
+     QPoint transientPos = m_window->geometry().topLeft(); // this is absolute
+@@ -414,8 +424,9 @@ void QWaylandXdgSurface::setPopup(QWaylandWindow *parent)
+     positioner->set_anchor(QtWayland::xdg_positioner::anchor_top_left);
+     positioner->set_gravity(QtWayland::xdg_positioner::gravity_bottom_right);
+     positioner->set_size(m_window->geometry().width(), m_window->geometry().height());
+-    m_popup = new Popup(this, parentXdgSurface, positioner);
++    m_popup = new Popup(this, parent, positioner);
+     positioner->destroy();
++
+     delete positioner;
+ }
+ 
+@@ -437,6 +448,23 @@ void QWaylandXdgSurface::setGrabPopup(QWaylandWindow *parent, QWaylandInputDevic
+     }
+     setPopup(parent);
+     m_popup->grab(device, serial);
++
++    // Synthesize Qt enter/leave events for popup
++    if (!parent)
++        return;
++    QWindow *current = QGuiApplication::topLevelAt(QCursor::pos());
++    QWindow *leave = parent->window();
++    if (current != leave)
++        return;
++
++    QWindowSystemInterface::handleLeaveEvent(leave);
++
++    QWindow *enter = nullptr;
++    if (m_popup && m_popup->m_xdgSurface && m_popup->m_xdgSurface->window())
++        enter = m_popup->m_xdgSurface->window()->window();
++
++    if (enter)
++        QWindowSystemInterface::handleEnterEvent(enter, enter->mapFromGlobal(QCursor::pos()), QCursor::pos());
+ }
+ 
+ void QWaylandXdgSurface::xdg_surface_configure(uint32_t serial)
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
+index 96785205..4b518f0a 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
+@@ -131,14 +131,15 @@ private:
+ 
+     class Popup : public QtWayland::xdg_popup {
+     public:
+-        Popup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parent, QtWayland::xdg_positioner *positioner);
++        Popup(QWaylandXdgSurface *xdgSurface, QWaylandWindow *parent, QtWayland::xdg_positioner *positioner);
+         ~Popup() override;
+ 
+         void grab(QWaylandInputDevice *seat, uint serial);
+         void xdg_popup_popup_done() override;
+ 
+         QWaylandXdgSurface *m_xdgSurface = nullptr;
+-        QWaylandXdgSurface *m_parent = nullptr;
++        QWaylandXdgSurface *m_parentXdgSurface = nullptr;
++        QWaylandWindow *m_parent = nullptr;
+         bool m_grabbing = false;
+     };
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
+index 8769d971..da0dd6a7 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
+@@ -69,20 +69,6 @@ QWaylandShellSurface *QWaylandXdgShellIntegration::createShellSurface(QWaylandWi
+     return m_xdgShell->getXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellIntegration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus)
+-{
+-    if (newFocus) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurface *>(newFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowActivated(newFocus);
+-    }
+-    if (oldFocus && qobject_cast<QWaylandXdgSurface *>(oldFocus->shellSurface())) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurface *>(oldFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowDeactivated(oldFocus);
+-    }
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
+index b6caa6c9..2f929f98 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
+@@ -65,7 +65,6 @@ public:
+     QWaylandXdgShellIntegration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShell> m_xdgShell;
+diff --git a/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp b/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
+index 526d0ef4..f50ccf30 100644
+--- a/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
++++ b/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
+@@ -39,7 +39,10 @@
+ 
+ #include "qwaylandinputmethodeventbuilder_p.h"
+ 
++#include <QBrush>
++#include <QGuiApplication>
+ #include <QInputMethod>
++#include <QPalette>
+ #include <QTextCharFormat>
+ 
+ #ifdef QT_BUILD_WAYLANDCOMPOSITOR_LIB
+@@ -81,32 +84,38 @@ void QWaylandInputMethodEventBuilder::addPreeditStyling(uint32_t index, uint32_t
+     QTextCharFormat format;
+ 
+     switch (style) {
+-    case 0:
+-    case 1:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_NONE:
++        break;
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_DEFAULT:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_UNDERLINE:
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-    case 2:
+-    case 3:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_ACTIVE:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_INACTIVE:
+         format.setFontWeight(QFont::Bold);
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-    case 4:
+-        format.setFontUnderline(true);
+-        format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+-        m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_HIGHLIGHT:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_SELECTION:
++        {
++            format.setFontUnderline(true);
++            format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
++            QPalette palette = qApp->palette();
++            format.setBackground(QBrush(palette.color(QPalette::Active, QPalette::Highlight)));
++            format.setForeground(QBrush(palette.color(QPalette::Active, QPalette::HighlightedText)));
++            m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
++        }
+         break;
+-    case 5:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_INCORRECT:
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::WaveUnderline);
+         format.setUnderlineColor(QColor(Qt::red));
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-//    case QtWayland::wl_text_input::preedit_style_selection:
+-//    case QtWayland::wl_text_input::preedit_style_none:
+     default:
+         break;
+     }
+@@ -153,7 +162,7 @@ QInputMethodEvent QWaylandInputMethodEventBuilder::buildPreedit(const QString &t
+ 
+     if (m_preeditCursor < 0) {
+         attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, 0, QVariant()));
+-    } else if (m_preeditCursor > 0) {
++    } else {
+         attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, indexFromWayland(text, m_preeditCursor), 1, QVariant()));
+     }
+ 
+diff --git a/qtwayland/src/shared/qwaylandmimehelper.cpp b/qtwayland/src/shared/qwaylandmimehelper.cpp
+index a5fdd34d..e2fe1928 100644
+--- a/qtwayland/src/shared/qwaylandmimehelper.cpp
++++ b/qtwayland/src/shared/qwaylandmimehelper.cpp
+@@ -60,7 +60,7 @@ QByteArray QWaylandMimeHelper::getByteArray(QMimeData *mimeData, const QString &
+             buf.open(QIODevice::ReadWrite);
+             QByteArray fmt = "BMP";
+             if (mimeType.startsWith(QLatin1String("image/"))) {
+-                QByteArray imgFmt = mimeType.mid(6).toUpper().toLatin1();
++                QByteArray imgFmt = mimeType.mid(6).toLower().toLatin1();
+                 if (QImageWriter::supportedImageFormats().contains(imgFmt))
+                     fmt = imgFmt;
+             }
+@@ -74,7 +74,7 @@ QByteArray QWaylandMimeHelper::getByteArray(QMimeData *mimeData, const QString &
+         QList<QUrl> urls = mimeData->urls();
+         for (int i = 0; i < urls.count(); ++i) {
+             content.append(urls.at(i).toEncoded());
+-            content.append('\n');
++            content.append("\r\n");
+         }
+     } else {
+         content = mimeData->data(mimeType);
+diff --git a/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp b/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
+index 1568b3b9..067410d0 100644
+--- a/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
++++ b/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
+@@ -35,7 +35,7 @@
+ 
+ using namespace MockCompositor;
+ 
+-constexpr int dataDeviceVersion = 1;
++constexpr int dataDeviceVersion = 3;
+ 
+ class DataDeviceCompositor : public DefaultCompositor {
+ public:
+diff --git a/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp b/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
+index 9312c2e5..2ea382f1 100644
+--- a/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
++++ b/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
+@@ -73,6 +73,7 @@ private slots:
+     void multiTouch();
+     void multiTouchUpAndMotionFrame();
+     void tapAndMoveInSameFrame();
++    void cancelTouch();
+ };
+ 
+ void tst_seatv5::bindsToSeat()
+@@ -646,5 +647,34 @@ void tst_seatv5::tapAndMoveInSameFrame()
+     QTRY_COMPARE(window.m_events.last().touchPoints.first().state(), Qt::TouchPointState::TouchPointReleased);
+ }
+ 
++void tst_seatv5::cancelTouch()
++{
++    TouchWindow window;
++    QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
++
++    exec([=] {
++        auto *t = touch();
++        auto *c = client();
++        t->sendDown(xdgToplevel()->surface(), {32, 32}, 1);
++        t->sendFrame(c);
++        t->sendCancel(c);
++        t->sendFrame(c);
++    });
++
++    QTRY_VERIFY(!window.m_events.empty());
++    {
++        auto e = window.m_events.takeFirst();
++        QCOMPARE(e.type, QEvent::TouchBegin);
++        QCOMPARE(e.touchPointStates, Qt::TouchPointPressed);
++        QCOMPARE(e.touchPoints.length(), 1);
++        QCOMPARE(e.touchPoints.first().pos(), QPointF(32-window.frameMargins().left(), 32-window.frameMargins().top()));
++    }
++    {
++        auto e = window.m_events.takeFirst();
++        QCOMPARE(e.type, QEvent::TouchCancel);
++        QCOMPARE(e.touchPoints.length(), 0);
++    }
++}
++
+ QCOMPOSITOR_TEST_MAIN(tst_seatv5)
+ #include "tst_seatv5.moc"
+diff --git a/qtwayland/tests/auto/client/shared/corecompositor.cpp b/qtwayland/tests/auto/client/shared/corecompositor.cpp
+index 5c6c83ba..fa9b7662 100644
+--- a/qtwayland/tests/auto/client/shared/corecompositor.cpp
++++ b/qtwayland/tests/auto/client/shared/corecompositor.cpp
+@@ -27,6 +27,7 @@
+ ****************************************************************************/
+ 
+ #include "corecompositor.h"
++#include <thread>
+ 
+ namespace MockCompositor {
+ 
+diff --git a/qtwayland/tests/auto/client/shared/coreprotocol.cpp b/qtwayland/tests/auto/client/shared/coreprotocol.cpp
+index 0d988521..d1a2e7cb 100644
+--- a/qtwayland/tests/auto/client/shared/coreprotocol.cpp
++++ b/qtwayland/tests/auto/client/shared/coreprotocol.cpp
+@@ -451,6 +451,13 @@ void Touch::sendFrame(wl_client *client)
+         send_frame(r->handle);
+ }
+ 
++void Touch::sendCancel(wl_client *client)
++{
++    const auto touchResources = resourceMap().values(client);
++    for (auto *r : touchResources)
++        send_cancel(r->handle);
++}
++
+ uint Keyboard::sendEnter(Surface *surface)
+ {
+     auto serial = m_seat->m_compositor->nextSerial();
+diff --git a/qtwayland/tests/auto/client/shared/coreprotocol.h b/qtwayland/tests/auto/client/shared/coreprotocol.h
+index a1af137a..210d8ddb 100644
+--- a/qtwayland/tests/auto/client/shared/coreprotocol.h
++++ b/qtwayland/tests/auto/client/shared/coreprotocol.h
+@@ -158,7 +158,7 @@ class WlCompositor : public Global, public QtWaylandServer::wl_compositor
+ {
+     Q_OBJECT
+ public:
+-    explicit WlCompositor(CoreCompositor *compositor, int version = 3)
++    explicit WlCompositor(CoreCompositor *compositor, int version = 4)
+         : QtWaylandServer::wl_compositor(compositor->m_display, version)
+         , m_compositor(compositor)
+     {}
+@@ -364,6 +364,7 @@ public:
+     uint sendUp(wl_client *client, int id);
+     void sendMotion(wl_client *client, const QPointF &position, int id);
+     void sendFrame(wl_client *client);
++    void sendCancel(wl_client *client);
+ 
+     Seat *m_seat = nullptr;
+ };
+diff --git a/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp b/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
+index a415cbf5..b1d3d07d 100644
+--- a/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
++++ b/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
+@@ -342,7 +342,7 @@ Compositor::Compositor(MockCompositor *mockCompositor)
+         exit(EXIT_FAILURE);
+     }
+ 
+-    wl_global_create(m_display, &wl_compositor_interface, 1, this, bindCompositor);
++    wl_global_create(m_display, &wl_compositor_interface, 4, this, bindCompositor);
+ 
+     m_data_device_manager.reset(new DataDeviceManager(this, m_display));
+ 
+diff --git a/qtwayland/tests/auto/client/shared_old/mocksurface.cpp b/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
+index e9df5f90..c3246e4a 100644
+--- a/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
++++ b/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
+@@ -125,6 +125,16 @@ void Surface::surface_damage(Resource *resource,
+     Q_UNUSED(height);
+ }
+ 
++void Surface::surface_damage_buffer(Resource *resource,
++                                    int32_t x, int32_t y, int32_t width, int32_t height)
++{
++    Q_UNUSED(resource);
++    Q_UNUSED(x);
++    Q_UNUSED(y);
++    Q_UNUSED(width);
++    Q_UNUSED(height);
++}
++
+ void Surface::surface_frame(Resource *resource,
+                             uint32_t callback)
+ {
+diff --git a/qtwayland/tests/auto/client/shared_old/mocksurface.h b/qtwayland/tests/auto/client/shared_old/mocksurface.h
+index 949dc23d..d176837e 100644
+--- a/qtwayland/tests/auto/client/shared_old/mocksurface.h
++++ b/qtwayland/tests/auto/client/shared_old/mocksurface.h
+@@ -65,6 +65,8 @@ protected:
+                         struct wl_resource *buffer, int x, int y) override;
+     void surface_damage(Resource *resource,
+                         int32_t x, int32_t y, int32_t width, int32_t height) override;
++    void surface_damage_buffer(Resource *resource,
++                               int32_t x, int32_t y, int32_t width, int32_t height) override;
+     void surface_frame(Resource *resource,
+                        uint32_t callback) override;
+     void surface_commit(Resource *resource) override;
+diff --git a/qtwayland/tests/auto/client/surface/tst_surface.cpp b/qtwayland/tests/auto/client/surface/tst_surface.cpp
+index 95e4e609..60c672ce 100644
+--- a/qtwayland/tests/auto/client/surface/tst_surface.cpp
++++ b/qtwayland/tests/auto/client/surface/tst_surface.cpp
+@@ -129,6 +129,10 @@ void tst_surface::waitForFrameCallbackGl()
+     // Make sure we follow frame callbacks for some frames
+     for (int i = 0; i < 5; ++i) {
+         xdgPingAndWaitForPong(); // Make sure things have happened on the client
++        if (!qEnvironmentVariableIntValue("QT_WAYLAND_DISABLE_WINDOWDECORATION") && i == 0) {
++            QCOMPARE(bufferSpy.count(), 1);
++            bufferSpy.removeFirst();
++        }
+         exec([&] {
+             QVERIFY(bufferSpy.empty()); // Make sure no extra buffers have arrived
+             QVERIFY(!xdgToplevel()->surface()->m_waitingFrameCallbacks.empty());
+diff --git a/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp b/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
+index 2277bbb8..747875b4 100644
+--- a/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
++++ b/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
+@@ -31,6 +31,7 @@
+ #include <QtGui/QOpenGLWindow>
+ #include <QtGui/qpa/qplatformnativeinterface.h>
+ #include <QtWaylandClient/private/wayland-wayland-client-protocol.h>
++#include <QtWaylandClient/private/qwaylandwindow_p.h>
+ 
+ using namespace MockCompositor;
+ 
+@@ -45,6 +46,7 @@ private slots:
+     void configureStates();
+     void popup();
+     void tooltipOnPopup();
++    void tooltipAndSiblingPopup();
+     void switchPopups();
+     void hidePopupParent();
+     void pongs();
+@@ -138,6 +140,7 @@ void tst_xdgshell::configureSize()
+ 
+ void tst_xdgshell::configureStates()
+ {
++    QVERIFY(qputenv("QT_WAYLAND_FRAME_CALLBACK_TIMEOUT", "0"));
+     QRasterWindow window;
+     window.resize(64, 48);
+     window.show();
+@@ -154,9 +157,12 @@ void tst_xdgshell::configureStates()
+     // Toplevel windows don't know their position on xdg-shell
+ //    QCOMPARE(window.frameGeometry().topLeft(), QPoint()); // TODO: this doesn't currently work when window decorations are enabled
+ 
+-//    QEXPECT_FAIL("", "configure has already been acked, we shouldn't have to wait for isActive", Continue);
+-//    QVERIFY(window.isActive());
+-    QTRY_VERIFY(window.isActive()); // Just make sure it eventually get's set correctly
++    // window.windowstate() is driven by keyboard focus, however for decorations we want to follow
++    // XDGShell this is internal to QtWayland so it is queried directly
++    auto waylandWindow = static_cast<QtWaylandClient::QWaylandWindow *>(window.handle());
++    Q_ASSERT(waylandWindow);
++    QTRY_VERIFY(waylandWindow->windowStates().testFlag(
++            Qt::WindowActive)); // Just make sure it eventually get's set correctly
+ 
+     const QSize screenSize(640, 480);
+     const uint maximizedSerial = exec([=] {
+@@ -186,6 +192,7 @@ void tst_xdgshell::configureStates()
+     QCOMPARE(window.windowStates(), Qt::WindowNoState);
+     QCOMPARE(window.frameGeometry().size(), windowedSize);
+ //    QCOMPARE(window.frameGeometry().topLeft(), QPoint()); // TODO: this doesn't currently work when window decorations are enabled
++    QVERIFY(qunsetenv("QT_WAYLAND_FRAME_CALLBACK_TIMEOUT"));
+ }
+ 
+ void tst_xdgshell::popup()
+@@ -340,6 +347,92 @@ void tst_xdgshell::tooltipOnPopup()
+     QCOMPOSITOR_TRY_COMPARE(xdgPopup(0), nullptr);
+ }
+ 
++void tst_xdgshell::tooltipAndSiblingPopup()
++{
++    class ToolTip : public QRasterWindow {
++    public:
++        explicit ToolTip(QWindow *parent) {
++            setTransientParent(parent);
++            setFlags(Qt::ToolTip);
++            resize(100, 100);
++            show();
++        }
++        void mousePressEvent(QMouseEvent *event) override {
++            QRasterWindow::mousePressEvent(event);
++            m_popup = new QRasterWindow;
++            m_popup->setTransientParent(transientParent());
++            m_popup->setFlags(Qt::Popup);
++            m_popup->resize(100, 100);
++            m_popup->show();
++        }
++
++        QRasterWindow *m_popup = nullptr;
++    };
++
++    class Window : public QRasterWindow {
++    public:
++        void mousePressEvent(QMouseEvent *event) override {
++            QRasterWindow::mousePressEvent(event);
++            m_tooltip = new ToolTip(this);
++        }
++        ToolTip *m_tooltip = nullptr;
++    };
++
++    Window window;
++    window.resize(200, 200);
++    window.show();
++
++    QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
++    exec([=] { xdgToplevel()->sendCompleteConfigure(); });
++    QCOMPOSITOR_TRY_VERIFY(xdgToplevel()->m_xdgSurface->m_committedConfigureSerial);
++
++    exec([=] {
++        auto *surface = xdgToplevel()->surface();
++        auto *p = pointer();
++        auto *c = client();
++        p->sendEnter(surface, {100, 100});
++        p->sendFrame(c);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_pressed);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_released);
++        p->sendFrame(c);
++        p->sendLeave(surface);
++        p->sendFrame(c);
++    });
++
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup());
++    exec([=] { xdgPopup()->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup()->m_xdgSurface->m_committedConfigureSerial);
++    QCOMPOSITOR_TRY_VERIFY(!xdgPopup()->m_grabbed);
++
++    exec([=] {
++        auto *surface = xdgPopup()->surface();
++        auto *p = pointer();
++        auto *c = client();
++        p->sendEnter(surface, {100, 100});
++        p->sendFrame(c);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_pressed);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_released);
++        p->sendFrame(c);
++    });
++
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1));
++    exec([=] { xdgPopup(1)->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1)->m_xdgSurface->m_committedConfigureSerial);
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1)->m_grabbed);
++
++    // Close the middle tooltip (it should not close the sibling popup)
++    window.m_tooltip->close();
++
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(1), nullptr);
++    // Verify the remaining xdg surface is a grab popup..
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(0));
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(0)->m_grabbed);
++
++    window.m_tooltip->m_popup->close();
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(1), nullptr);
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(0), nullptr);
++}
++
+ // QTBUG-65680
+ void tst_xdgshell::switchPopups()
+ {
+@@ -505,7 +598,7 @@ void tst_xdgshell::minMaxSize()
+     window.show();
+     QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
+ 
+-    exec([=] { xdgToplevel()->sendCompleteConfigure(); });
++    // we don't roundtrip with our configuration the initial commit should be correct
+ 
+     QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.minSize, QSize(100, 100));
+     QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.maxSize, QSize(1000, 1000));
+Submodule qtwebchannel 618422ee..f8949655:
+diff --git a/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp b/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
+index 536eb5c..898d769 100644
+--- a/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
++++ b/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
+@@ -186,8 +186,6 @@ Q_DECLARE_TYPEINFO(OverloadResolutionCandidate, Q_MOVABLE_TYPE);
+ QMetaObjectPublisher::QMetaObjectPublisher(QWebChannel *webChannel)
+     : QObject(webChannel)
+     , webChannel(webChannel)
+-    , signalHandler(this)
+-    , clientIsIdle(false)
+     , blockUpdates(false)
+     , propertyUpdatesInitialized(false)
+ {
+@@ -301,17 +299,17 @@ QJsonObject QMetaObjectPublisher::classInfoForObject(const QObject *object, QWeb
+     return data;
+ }
+ 
+-void QMetaObjectPublisher::setClientIsIdle(bool isIdle)
++void QMetaObjectPublisher::setClientIsIdle(bool isIdle, QWebChannelAbstractTransport *transport)
+ {
+-    if (clientIsIdle == isIdle) {
+-        return;
+-    }
+-    clientIsIdle = isIdle;
+-    if (!isIdle && timer.isActive()) {
+-        timer.stop();
+-    } else if (isIdle && !timer.isActive()) {
+-        timer.start(PROPERTY_UPDATE_INTERVAL, this);
+-    }
++    transportState[transport].clientIsIdle = isIdle;
++    if (isIdle)
++        sendEnqueuedPropertyUpdates(transport);
++}
++
++bool QMetaObjectPublisher::isClientIdle(QWebChannelAbstractTransport *transport)
++{
++    auto found = transportState.find(transport);
++    return found != transportState.end() && found.value().clientIsIdle;
+ }
+ 
+ QJsonObject QMetaObjectPublisher::initializeClient(QWebChannelAbstractTransport *transport)
+@@ -333,6 +331,7 @@ QJsonObject QMetaObjectPublisher::initializeClient(QWebChannelAbstractTransport
+ 
+ void QMetaObjectPublisher::initializePropertyUpdates(const QObject *const object, const QJsonObject &objectInfo)
+ {
++    auto *signalHandler = signalHandlerFor(object);
+     foreach (const QJsonValue &propertyInfoVar, objectInfo[KEY_PROPERTIES].toArray()) {
+         const QJsonArray &propertyInfo = propertyInfoVar.toArray();
+         if (propertyInfo.size() < 2) {
+@@ -353,19 +352,19 @@ void QMetaObjectPublisher::initializePropertyUpdates(const QObject *const object
+ 
+         // Only connect for a property update once
+         if (connectedProperties.isEmpty()) {
+-            signalHandler.connectTo(object, signalIndex);
++            signalHandler->connectTo(object, signalIndex);
+         }
+ 
+         connectedProperties.insert(propertyIndex);
+     }
+ 
+     // also always connect to destroyed signal
+-    signalHandler.connectTo(object, s_destroyedSignalIndex);
++    signalHandler->connectTo(object, s_destroyedSignalIndex);
+ }
+ 
+ void QMetaObjectPublisher::sendPendingPropertyUpdates()
+ {
+-    if (blockUpdates || !clientIsIdle || pendingPropertyUpdates.isEmpty()) {
++    if (blockUpdates) {
+         return;
+     }
+ 
+@@ -415,18 +414,19 @@ void QMetaObjectPublisher::sendPendingPropertyUpdates()
+ 
+     // data does not contain specific updates
+     if (!data.isEmpty()) {
+-        setClientIsIdle(false);
+-
+         message[KEY_DATA] = data;
+-        broadcastMessage(message);
++        enqueueBroadcastMessage(message);
+     }
+ 
+     // send every property update which is not supposed to be broadcasted
+     const QHash<QWebChannelAbstractTransport*, QJsonArray>::const_iterator suend = specificUpdates.constEnd();
+     for (QHash<QWebChannelAbstractTransport*, QJsonArray>::const_iterator it = specificUpdates.constBegin(); it != suend; ++it) {
+         message[KEY_DATA] = it.value();
+-        it.key()->sendMessage(message);
++        enqueueMessage(message, it.key());
+     }
++
++    for (auto state = transportState.begin(); state != transportState.end(); ++state)
++        sendEnqueuedPropertyUpdates(state.key());
+ }
+ 
+ QVariant QMetaObjectPublisher::invokeMethod(QObject *const object, const QMetaMethod &method,
+@@ -572,7 +572,7 @@ void QMetaObjectPublisher::signalEmitted(const QObject *object, const int signal
+         }
+     } else {
+         pendingPropertyUpdates[object][signalIndex] = arguments;
+-        if (clientIsIdle && !blockUpdates && !timer.isActive()) {
++        if (!blockUpdates && !timer.isActive()) {
+             timer.start(PROPERTY_UPDATE_INTERVAL, this);
+         }
+     }
+@@ -590,7 +590,7 @@ void QMetaObjectPublisher::objectDestroyed(const QObject *object)
+     // only remove from handler when we initialized the property updates
+     // cf: https://bugreports.qt.io/browse/QTBUG-60250
+     if (propertyUpdatesInitialized) {
+-        signalHandler.remove(object);
++        signalHandlerFor(object)->remove(object);
+         signalToPropertyMap.remove(object);
+     }
+     pendingPropertyUpdates.remove(object);
+@@ -852,6 +852,52 @@ void QMetaObjectPublisher::broadcastMessage(const QJsonObject &message) const
+     }
+ }
+ 
++void QMetaObjectPublisher::enqueueBroadcastMessage(const QJsonObject &message)
++{
++    if (webChannel->d_func()->transports.isEmpty()) {
++        qWarning("QWebChannel is not connected to any transports, cannot send message: %s",
++                 QJsonDocument(message).toJson().constData());
++        return;
++    }
++
++    for (auto *transport : webChannel->d_func()->transports) {
++        auto &state = transportState[transport];
++        state.queuedMessages.append(message);
++    }
++}
++
++void QMetaObjectPublisher::enqueueMessage(const QJsonObject &message,
++                                          QWebChannelAbstractTransport *transport)
++{
++    auto &state = transportState[transport];
++    state.queuedMessages.append(message);
++}
++
++void QMetaObjectPublisher::sendEnqueuedPropertyUpdates(QWebChannelAbstractTransport *transport)
++{
++    auto found = transportState.find(transport);
++    if (found != transportState.end() && found.value().clientIsIdle
++        && !found.value().queuedMessages.isEmpty()) {
++
++        // If the client is connected with an in-process transport, it can
++        // happen that a message triggers a subsequent property change. In
++        // that case, we need to ensure that the queued messages have already
++        // been cleared; otherwise the recursive call will send everythig again.
++        // Case in point: The qmlwebchannel tests fail if we don't clear the
++        // queued messages before sending them out.
++        // For that same reason set the client to "busy" (aka non-idle) just
++        // right before sending out the messages; otherwise a potential
++        // "Idle" type message will not correctly restore the Idle state.
++        const auto messages = std::move(found.value().queuedMessages);
++        Q_ASSERT(found.value().queuedMessages.isEmpty());
++        found.value().clientIsIdle = false;
++
++        for (const auto &message : messages) {
++            transport->sendMessage(message);
++        }
++    }
++}
++
+ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannelAbstractTransport *transport)
+ {
+     if (!webChannel->d_func()->transports.contains(transport)) {
+@@ -866,7 +912,7 @@ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannel
+ 
+     const MessageType type = toType(message.value(KEY_TYPE));
+     if (type == TypeIdle) {
+-        setClientIsIdle(true);
++        setClientIsIdle(true, transport);
+     } else if (type == TypeInit) {
+         if (!message.contains(KEY_ID)) {
+             qWarning("JSON message object is missing the id property: %s",
+@@ -913,9 +959,9 @@ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannel
+                 return;
+             transport->sendMessage(createResponse(message.value(KEY_ID), wrapResult(result, transport)));
+         } else if (type == TypeConnectToSignal) {
+-            signalHandler.connectTo(object, message.value(KEY_SIGNAL).toInt(-1));
++            signalHandlerFor(object)->connectTo(object, message.value(KEY_SIGNAL).toInt(-1));
+         } else if (type == TypeDisconnectFromSignal) {
+-            signalHandler.disconnectFrom(object, message.value(KEY_SIGNAL).toInt(-1));
++            signalHandlerFor(object)->disconnectFrom(object, message.value(KEY_SIGNAL).toInt(-1));
+         } else if (type == TypeSetProperty) {
+             setProperty(object, message.value(KEY_PROPERTY).toInt(-1),
+                         message.value(KEY_VALUE));
+@@ -931,6 +977,7 @@ void QMetaObjectPublisher::setBlockUpdates(bool block)
+     blockUpdates = block;
+ 
+     if (!blockUpdates) {
++        timer.start(PROPERTY_UPDATE_INTERVAL, this);
+         sendPendingPropertyUpdates();
+     } else if (timer.isActive()) {
+         timer.stop();
+@@ -948,4 +995,15 @@ void QMetaObjectPublisher::timerEvent(QTimerEvent *event)
+     }
+ }
+ 
++SignalHandler<QMetaObjectPublisher> *QMetaObjectPublisher::signalHandlerFor(const QObject *object)
++{
++    auto thread = object->thread();
++    auto it = signalHandlers.find(thread);
++    if (it == signalHandlers.end()) {
++        it = signalHandlers.emplace(thread, this).first;
++        it->second.moveToThread(thread);
++    }
++    return &it->second;
++}
++
+ QT_END_NAMESPACE
+diff --git a/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h b/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
+index bbd9875..4713ef1 100644
+--- a/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
++++ b/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
+@@ -59,6 +59,9 @@
+ #include <QBasicTimer>
+ #include <QPointer>
+ #include <QJsonObject>
++#include <QQueue>
++
++#include <unordered_map>
+ 
+ #include "qwebchannelglobal.h"
+ 
+@@ -109,17 +112,36 @@ public:
+      */
+     void broadcastMessage(const QJsonObject &message) const;
+ 
++    /**
++     * Enqueue the given @p message to all known transports.
++     */
++    void enqueueBroadcastMessage(const QJsonObject &message);
++
++    /**
++     * Enqueue the given @p message to @p transport.
++     */
++    void enqueueMessage(const QJsonObject &message, QWebChannelAbstractTransport *transport);
++
++    /**
++     * If client for given @p transport is idle, send queued messaged to @p transport and then mark
++     * the client as not idle.
++     */
++    void sendEnqueuedPropertyUpdates(QWebChannelAbstractTransport *transport);
++
+     /**
+      * Serialize the QMetaObject of @p object and return it in JSON form.
+      */
+     QJsonObject classInfoForObject(const QObject *object, QWebChannelAbstractTransport *transport);
+ 
+     /**
+-     * Set the client to idle or busy, based on the value of @p isIdle.
+-     *
+-     * When the value changed, start/stop the property update timer accordingly.
++     * Set the client to idle or busy for a single @p transport, based on the value of @p isIdle.
++     */
++    void setClientIsIdle(bool isIdle, QWebChannelAbstractTransport *transport);
++
++    /**
++     * Check that client is idle for @p transport.
+      */
+-    void setClientIsIdle(bool isIdle);
++    bool isClientIdle(QWebChannelAbstractTransport *transport);
+ 
+     /**
+      * Initialize clients by sending them the class information of the registered objects.
+@@ -272,10 +294,18 @@ private:
+     friend class TestWebChannel;
+ 
+     QWebChannel *webChannel;
+-    SignalHandler<QMetaObjectPublisher> signalHandler;
++    std::unordered_map<const QThread*, SignalHandler<QMetaObjectPublisher>> signalHandlers;
++    SignalHandler<QMetaObjectPublisher> *signalHandlerFor(const QObject *object);
+ 
+-    // true when the client is idle, false otherwise
+-    bool clientIsIdle;
++    struct TransportState
++    {
++        TransportState() : clientIsIdle(false) { }
++        // true when the client is idle, false otherwise
++        bool clientIsIdle;
++        // messages to send
++        QQueue<QJsonObject> queuedMessages;
++    };
++    QHash<QWebChannelAbstractTransport *, TransportState> transportState;
+ 
+     // true when no property updates should be sent, false otherwise
+     bool blockUpdates;
+diff --git a/qtwebchannel/src/webchannel/signalhandler_p.h b/qtwebchannel/src/webchannel/signalhandler_p.h
+index 27afadb..d77373c 100644
+--- a/qtwebchannel/src/webchannel/signalhandler_p.h
++++ b/qtwebchannel/src/webchannel/signalhandler_p.h
+@@ -56,6 +56,7 @@
+ #include <QVector>
+ #include <QMetaMethod>
+ #include <QDebug>
++#include <QThread>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -71,6 +72,7 @@ static const int s_destroyedSignalIndex = QObject::staticMetaObject.indexOfMetho
+ template<class Receiver>
+ class SignalHandler : public QObject
+ {
++    Q_DISABLE_COPY(SignalHandler)
+ public:
+     SignalHandler(Receiver *receiver, QObject *parent = 0);
+ 
+@@ -268,6 +270,7 @@ int SignalHandler<Receiver>::qt_metacall(QMetaObject::Call call, int methodId, v
+     if (call == QMetaObject::InvokeMetaMethod) {
+         const QObject *object = sender();
+         Q_ASSERT(object);
++        Q_ASSERT(QThread::currentThread() == object->thread());
+         Q_ASSERT(senderSignalIndex() == methodId);
+         Q_ASSERT(m_connectionsCounter.contains(object));
+         Q_ASSERT(m_connectionsCounter.value(object).contains(methodId));
+diff --git a/qtwebchannel/tests/auto/qml/testwebchannel.cpp b/qtwebchannel/tests/auto/qml/testwebchannel.cpp
+index 9891687..3ca81c2 100644
+--- a/qtwebchannel/tests/auto/qml/testwebchannel.cpp
++++ b/qtwebchannel/tests/auto/qml/testwebchannel.cpp
+@@ -46,7 +46,11 @@ TestWebChannel::~TestWebChannel()
+ 
+ bool TestWebChannel::clientIsIdle() const
+ {
+-    return QWebChannel::d_func()->publisher->clientIsIdle;
++    for (auto *transport : QWebChannel::d_func()->transports) {
++        if (QWebChannel::d_func()->publisher->isClientIdle(transport))
++            return true;
++    }
++    return false;
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp b/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
+index 181da9e..37f989a 100644
+--- a/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
++++ b/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
+@@ -785,7 +785,7 @@ void TestWebChannel::testTransportWrapObjectProperties()
+     DummyTransport *dummyTransport = new DummyTransport(this);
+     channel.connectTo(dummyTransport);
+     channel.d_func()->publisher->initializeClient(dummyTransport);
+-    channel.d_func()->publisher->setClientIsIdle(true);
++    channel.d_func()->publisher->setClientIsIdle(true, dummyTransport);
+ 
+     QCOMPARE(channel.d_func()->publisher->transportedWrappedObjects.size(), 0);
+ 
+@@ -943,8 +943,6 @@ void TestWebChannel::testInfiniteRecursion()
+ 
+ void TestWebChannel::testAsyncObject()
+ {
+-    QSKIP("This test is broken. See QTBUG-80729");
+-
+     QWebChannel channel;
+     channel.connectTo(m_dummyTransport);
+ 
+@@ -990,6 +988,50 @@ void TestWebChannel::testAsyncObject()
+     thread.wait();
+ }
+ 
++void TestWebChannel::testPropertyMultipleTransports()
++{
++    DummyTransport transport1;
++    DummyTransport transport2;
++
++    QWebChannel channel;
++    QMetaObjectPublisher *publisher = channel.d_func()->publisher;
++
++    TestObject testObj;
++    testObj.setObjectName("testObject");
++    channel.registerObject(testObj.objectName(), &testObj);
++    channel.connectTo(&transport1);
++    channel.connectTo(&transport2);
++
++    testObj.setProp("Hello");
++
++    publisher->initializeClient(&transport1);
++    publisher->initializeClient(&transport2);
++    publisher->setClientIsIdle(true, &transport1);
++    QCOMPARE(publisher->isClientIdle(&transport1), true);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++    QVERIFY(transport1.messagesSent().isEmpty());
++    QVERIFY(transport2.messagesSent().isEmpty());
++
++    testObj.setProp("World");
++    QTRY_COMPARE_WITH_TIMEOUT(transport1.messagesSent().size(), 1u, 2000);
++    QCOMPARE(transport2.messagesSent().size(), 0u);
++    publisher->setClientIsIdle(true, &transport2);
++    QTRY_COMPARE_WITH_TIMEOUT(transport2.messagesSent().size(), 1u, 2000);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++
++    testObj.setProp("!!!");
++    publisher->setClientIsIdle(true, &transport2);
++    QCOMPARE(publisher->isClientIdle(&transport2), true);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QTRY_COMPARE_WITH_TIMEOUT(transport2.messagesSent().size(), 2u, 2000);
++    QCOMPARE(transport1.messagesSent().size(), 1u);
++    publisher->setClientIsIdle(true, &transport1);
++    QTRY_COMPARE_WITH_TIMEOUT(transport1.messagesSent().size(), 2u, 2000);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++}
++
+ class FunctionWrapper : public QObject
+ {
+     Q_OBJECT
+@@ -1082,7 +1124,7 @@ void TestWebChannel::benchInitializeClients()
+ 
+         publisher->propertyUpdatesInitialized = false;
+         publisher->signalToPropertyMap.clear();
+-        publisher->signalHandler.clear();
++        publisher->signalHandlers.clear();
+     }
+ }
+ 
+@@ -1107,7 +1149,7 @@ void TestWebChannel::benchPropertyUpdates()
+             obj->change();
+         }
+ 
+-        channel.d_func()->publisher->clientIsIdle = true;
++        channel.d_func()->publisher->setClientIsIdle(true, m_dummyTransport);
+         channel.d_func()->publisher->sendPendingPropertyUpdates();
+     }
+ }
+diff --git a/qtwebchannel/tests/auto/webchannel/tst_webchannel.h b/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
+index eae21f4..dd4e690 100644
+--- a/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
++++ b/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
+@@ -348,6 +348,7 @@ private slots:
+     void testJsonToVariant();
+     void testInfiniteRecursion();
+     void testAsyncObject();
++    void testPropertyMultipleTransports();
+     void testDeletionDuringMethodInvocation_data();
+     void testDeletionDuringMethodInvocation();
+ 
+Submodule qtwebengine f328054d...38e0df6c (commits not present)
+Submodule qtwebsockets 65850954..63fb8da1:
+diff --git a/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp b/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
+index 2affdd5..95f1194 100644
+--- a/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
++++ b/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
+@@ -273,6 +273,7 @@ void QWebSocketDataProcessor::clear()
+     if (!m_pConverterState)
+         m_pConverterState = new QTextCodec::ConverterState(QTextCodec::ConvertInvalidToNull |
+                                                            QTextCodec::IgnoreHeader);
++    frame.clear();
+ }
+ 
+ /*!
+diff --git a/qtwebsockets/src/websockets/qwebsocketprotocol.cpp b/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
+index df87a93..d0465f1 100644
+--- a/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
++++ b/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
+@@ -210,7 +210,7 @@ void QWebSocketProtocol::mask(char *payload, quint64 size, quint32 maskingKey)
+                             quint8((maskingKey & 0x0000FF00u) >> 8),
+                             quint8((maskingKey & 0x000000FFu))
+                           };
+-    int i = 0;
++    quint64 i = 0;
+     while (size-- > 0)
+         *payload++ ^= mask[i++ % 4];
+ }
diff --git a/srcpkgs/qt5/template b/srcpkgs/qt5/template
index f879df3a3e706..a0d3036af79a4 100644
--- a/srcpkgs/qt5/template
+++ b/srcpkgs/qt5/template
@@ -2,11 +2,11 @@
 #
 # revbump libqtxdg after bumping patch version
 pkgname=qt5
-version=5.15.7+20221119
+version=5.15.8
+revision=1
+build_style=meta
 # commit f8c9fb304bc3e53b3aa07f962cd74e9160decccc
 # base repo: https://invent.kde.org/qt/qt/qt5
-revision=8
-build_style=meta
 hostmakedepends="cmake clang flex perl glib-devel pkg-config
  python3 re2c ruby which"
 makedepends="SDL2-devel Vulkan-Headers alsa-lib-devel double-conversion-devel
@@ -29,9 +29,9 @@ homepage="https://qt.io/"
 # tarball is generated with `git archive-all qt5-$version.tar.gz`
 # to keep the size smaller qtwebengine, qtwebview, qtdocgallery, qtactiveqt and qtpim
 # can be marked with the export-ignore attribute
-distfiles="https://void.johnnynator.dev/distfiles/qt5-${version}.tar.gz"
-checksum=9d57af471c78029a362276b7c99108ea009f511bb9ba6ff6cb884f6ddd255e9f
-python_version=3
+distfiles="https://download.qt.io/archive/qt/5.15/${version}/single/qt-everywhere-opensource-src-${version}.tar.xz"
+checksum=776a9302c336671f9406a53bd30b8e36f825742b2ec44a57c08217bff0fa86b9
+python_version=2 #unverified
 replaces="qt5-doc<5.6.0 qt5-quick1<5.6.0 qt5-quick1-devel<5.6.0 qt5-webkit<5.6.0 qt5-webkit-devel<5.6.0
  qt5-enginio<5.7.1 qt5-enginio-devel<5.7.1 qt5-plugin-gtk<5.7.1 qt5-canvas3d<5.13.0"
 lib32mode=full
@@ -246,7 +246,6 @@ do_configure() {
 	# opts+=" -v"
 	opts+=" -skip qtwebengine"
 	opts+=" -skip qtwebview"
-	opts+=" -skip qtdocgallery"
 	opts+=" -skip qtpim"
 	opts+=" -skip qtsystems"
 	opts+=" -skip qtspeech"

From 4693e3136c6112a6a18474afd66720728d3a62cd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 063/115] qtav: revbump for ffmpeg4-4.4.3

---
 srcpkgs/qtav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qtav/template b/srcpkgs/qtav/template
index 775d5a139a9ef..2d00ad104355e 100644
--- a/srcpkgs/qtav/template
+++ b/srcpkgs/qtav/template
@@ -4,7 +4,7 @@ version=1.13.0
 revision=2
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel libass-devel libopenal-devel
+makedepends="ffmpeg4-devel libass-devel libopenal-devel
  libva-glx-devel libXv-devel pulseaudio-devel
  qt5-declarative-devel qt5-svg-devel
  qt5-quickcontrols"

From 073a65d48671b41a083964f13b08a34e8eafc183 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 064/115] qtox: revbump for ffmpeg-6.0

---
 srcpkgs/qtox/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qtox/template b/srcpkgs/qtox/template
index 39c643fecdb5a..bb70e7f51240a 100644
--- a/srcpkgs/qtox/template
+++ b/srcpkgs/qtox/template
@@ -1,7 +1,7 @@
 # Template file for 'qtox'
 pkgname=qtox
 version=1.17.6
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DUPDATE_CHECK=OFF
  -DGIT_DESCRIBE=${version}

From d67cc6805106bd64a0d2122bb3cda7ccbb028b47 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 065/115] retroarch: revbump for ffmpeg-6.0

---
 srcpkgs/retroarch/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroarch/template b/srcpkgs/retroarch/template
index cb3125c5dbf1a..c65c26f7bf033 100644
--- a/srcpkgs/retroarch/template
+++ b/srcpkgs/retroarch/template
@@ -1,7 +1,7 @@
 # Template file for 'retroarch'
 pkgname=retroarch
 version=1.16.0.3
-revision=3
+revision=4
 build_style=configure
 configure_args="--prefix=/usr --sysconfdir=/etc --enable-networking
  --enable-udev --disable-builtinflac --disable-builtinglslang

From 0c84fa451823f4e1b58164c6d9dcec5fac0c1aa6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 066/115] scrcpy: revbump for ffmpeg-6.0

---
 srcpkgs/scrcpy/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/scrcpy/template b/srcpkgs/scrcpy/template
index ac18bc03418ce..f39a7f678ab35 100644
--- a/srcpkgs/scrcpy/template
+++ b/srcpkgs/scrcpy/template
@@ -1,7 +1,7 @@
 # Template file for 'scrcpy'
 pkgname=scrcpy
 version=2.1.1
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcompile_server=false
  -Dprebuilt_server=/usr/share/scrcpy/scrcpy-server-v${version}"

From ae4bf104c04d7919dfef62ac24e58f6cdaf4b994 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 17 Oct 2023 08:54:11 -0400
Subject: [PATCH 067/115] New package: spex-x replaces spek-alternative for
 ffmpeg-6.0

---
 srcpkgs/spek-alternative                      |  1 +
 srcpkgs/{spek-alternative => spek-x}/template | 22 ++++++++++++-------
 2 files changed, 15 insertions(+), 8 deletions(-)
 create mode 120000 srcpkgs/spek-alternative
 rename srcpkgs/{spek-alternative => spek-x}/template (52%)

diff --git a/srcpkgs/spek-alternative b/srcpkgs/spek-alternative
new file mode 120000
index 0000000000000..76648236da701
--- /dev/null
+++ b/srcpkgs/spek-alternative
@@ -0,0 +1 @@
+spek-x
\ No newline at end of file
diff --git a/srcpkgs/spek-alternative/template b/srcpkgs/spek-x/template
similarity index 52%
rename from srcpkgs/spek-alternative/template
rename to srcpkgs/spek-x/template
index d7b55c776b1d4..3ded6c2c323e4 100644
--- a/srcpkgs/spek-alternative/template
+++ b/srcpkgs/spek-x/template
@@ -1,18 +1,18 @@
-# Template file for 'spek-alternative'
-pkgname=spek-alternative
-version=0.8.2.3
-revision=2
+# Template file for 'spek-x'
+pkgname=spek-x
+version=0.9.3
+revision=1
 build_style=gnu-configure
 hostmakedepends="automake gettext-devel intltool libtool pkg-config
  wxWidgets-common wxWidgets-gtk3-devel"
 makedepends="ffmpeg-devel wxWidgets-gtk3-devel"
 depends="ffmpeg"
 short_desc="Acoustic spectrum analyser"
-maintainer="Kartik Singh <kartik.ynwa@gmail.com>"
+maintainer="zlice <zlice555@gmail.com>"
 license="GPL-3.0-or-later"
-homepage="https://github.com/withmorten/spek-alternative"
-distfiles="https://github.com/withmorten/spek-alternative/archive/${version}.tar.gz"
-checksum="007ba4b84a310b078e378aa84c8e80783db5821437a757a488c3ecec377e6b2a"
+homepage="https://github.com/MikeWang000000/spek-x"
+distfiles="https://github.com/MikeWang000000/spek-x/archive/v${version}.tar.gz"
+checksum="7f4b109903333cdd310ab2b9176f0dc49a565891376e281a233d342cedf90ef7"
 
 CXXFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
 
@@ -22,3 +22,9 @@ export WX_CONFIG_NAME="wx-config-gtk3"
 pre_configure() {
 	NOCONFIGURE=1 ./autogen.sh
 }
+
+spek-alternative_package() {
+	depends="spek-x"
+	short_desc+=" - transitional dummy package"
+	build_style=meta
+}

From 5630793981d98eddb85b3254689d3628cf362a94 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 068/115] ssr: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ssr/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ssr/template b/srcpkgs/ssr/template
index 842b2423aad10..3448ca110eb0c 100644
--- a/srcpkgs/ssr/template
+++ b/srcpkgs/ssr/template
@@ -5,7 +5,7 @@ revision=2
 build_style=cmake
 configure_args="-DWITH_QT5=ON"
 hostmakedepends="pkg-config"
-makedepends="alsa-lib-devel ffmpeg-devel glu-devel jack-devel pulseaudio-devel
+makedepends="alsa-lib-devel ffmpeg4-devel glu-devel jack-devel pulseaudio-devel
  qt5-tools-devel qt5-x11extras-devel libXinerama-devel v4l-utils-devel"
 depends="desktop-file-utils hicolor-icon-theme"
 short_desc="Simple Screen Recorder for programs and games"

From 6cb7ea21cadc01a1be815b877f06297780b063f7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 069/115] synfig: revbump for ffmpeg-6.0 and mlt7

---
 srcpkgs/synfig/patches/ffmpeg6.patch | 71 ++++++++++++++++++++++++++++
 srcpkgs/synfig/template              |  4 +-
 2 files changed, 73 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/synfig/patches/ffmpeg6.patch

diff --git a/srcpkgs/synfig/patches/ffmpeg6.patch b/srcpkgs/synfig/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..10780b42782f4
--- /dev/null
+++ b/srcpkgs/synfig/patches/ffmpeg6.patch
@@ -0,0 +1,71 @@
+--- a/src/modules/mod_libavcodec/trgt_av.cpp	2022-10-25 09:14:12.000000000 -0400
++++ b/src/modules/mod_libavcodec/trgt_av.cpp	2023-05-05 21:34:17.899194559 -0400
+@@ -38,6 +41,7 @@
+ extern "C"
+ {
+ #ifdef HAVE_LIBAVFORMAT_AVFORMAT_H
++#	include <libavcodec/avcodec.h>
+ #	include <libavformat/avformat.h>
+ #elif defined(HAVE_AVFORMAT_H)
+ #	include <avformat.h>
+@@ -155,11 +156,11 @@
+     }
+ 
+ 	bool open_video_stream() {
+-		if (avcodec_open2(video_context, NULL, NULL) < 0) {
++		if (avcodec_open2(video_context, nullptr, nullptr) < 0) {
+ 			synfig::error("Target_LibAVCodec: could not open video codec");
+ 			// seems the calling of avcodec_free_context after error will cause crash
+ 			// so just forget about this context
+-			video_context = NULL;
++			video_context = nullptr;
+ 			close();
+ 			return false;
+         }
+@@ -234,15 +235,21 @@
+ 		close();
+ 
+ 		if (!av_registered) {
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 			av_register_all();
++#endif
+ 			av_registered = true;
+ 		}
+ 
+ 		// guess format
+-		AVOutputFormat *format = av_guess_format(NULL, filename.c_str(), NULL);
++#if LIBAVCODEC_VERSION_MAJOR < 59 // FFMPEG < 5.0
++		AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#else
++		const AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#endif
+ 		if (!format) {
+ 			synfig::warning("Target_LibAVCodec: unable to guess the output format, defaulting to MPEG");
+-			format = av_guess_format("mpeg", NULL, NULL);
++			format = av_guess_format("mpeg", nullptr, nullptr);
+ 		}
+ 		if (!format) {
+ 			synfig::error("Target_LibAVCodec: unable to find 'mpeg' output format");
+@@ -254,6 +261,7 @@
+ 		context = avformat_alloc_context();
+ 		assert(context);
+ 		context->oformat = format;
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 		if (filename.size() + 1 > sizeof(context->filename)) {
+ 			synfig::error(
+ 				"Target_LibAVCodec: filename too long, max length is %d, filename is '%s'",
+@@ -263,6 +271,14 @@
+ 			return false;
+ 		}
+ 		memcpy(context->filename, filename.c_str(), filename.size() + 1);
++#else
++		context->url = av_strndup(filename.c_str(), filename.size());
++		if (!context->url) {
++			synfig::error("Target_LibAVCodec: cannot allocate space for filename");
++			close();
++			return false;
++		}
++#endif
+ 
+ 		packet = av_packet_alloc();
+ 		assert(packet);
diff --git a/srcpkgs/synfig/template b/srcpkgs/synfig/template
index d4d3e341a20bf..703cfd7ebac84 100644
--- a/srcpkgs/synfig/template
+++ b/srcpkgs/synfig/template
@@ -6,7 +6,7 @@ revision=4
 build_style=gnu-configure
 configure_args="--with-boost-libdir=${XBPS_CROSS_BASE}/usr/lib"
 hostmakedepends="boost-build ImageMagick pkg-config intltool"
-makedepends="ETL gettext-devel libxml++-devel mlt-devel libmagick-devel
+makedepends="ETL gettext-devel libxml++-devel mlt7-devel libmagick-devel
  libmng-devel boost-build boost-devel libopenexr-devel ffmpeg-devel"
 depends="ImageMagick"
 short_desc="CLI 2D vector and timeline-based animation software"
@@ -20,7 +20,7 @@ CXXFLAGS="-std=c++11 -DHAVE_LOCALE_H=1"
 
 synfig-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision}
-	 libopenexr-devel libxml++-devel mlt-devel"
+	 libopenexr-devel libxml++-devel mlt7-devel"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/bin/synfig-config

From ae3ca2ddc5b2871fbb1dbd351e6163dddcaa921f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 070/115] timg: revbump for ffmpeg-6.0

---
 srcpkgs/timg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/timg/template b/srcpkgs/timg/template
index 2a2ab763d2fdd..8fb4327535ef9 100644
--- a/srcpkgs/timg/template
+++ b/srcpkgs/timg/template
@@ -1,7 +1,7 @@
 # Template file for 'timg'
 pkgname=timg
 version=1.4.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_OPENSLIDE_SUPPORT=off -Wno-dev"
 hostmakedepends="pkg-config git"

From 33c6c573a49f0d78a9e9bfc2b33b33887656d182 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 071/115] tvheadend: revbump for ffmpeg4-4.4.3

---
 srcpkgs/tvheadend/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tvheadend/template b/srcpkgs/tvheadend/template
index 9aea7de4ec705..012d31c4879ff 100644
--- a/srcpkgs/tvheadend/template
+++ b/srcpkgs/tvheadend/template
@@ -8,7 +8,7 @@ configure_args="--enable-dvbscan --disable-ffmpeg_static
 --disable-libx265_static --disable-libvpx_static --disable-libtheora_static
 --disable-libvorbis_static --disable-libfdkaac_static"
 hostmakedepends="gettext pkg-config python3 git which"
-makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg-devel"
+makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg4-devel"
 short_desc="TV streaming server"
 maintainer="lemmi <lemmi@nerd2nerd.org>"
 license="GPL-3.0-only"

From be74de2ab0ec93c81fc5fa8383917517f9d17194 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 072/115] unpaper: update to 7.0.0.

---
 srcpkgs/unpaper/template | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/srcpkgs/unpaper/template b/srcpkgs/unpaper/template
index 38ed47a584016..1ff910e722afc 100644
--- a/srcpkgs/unpaper/template
+++ b/srcpkgs/unpaper/template
@@ -1,13 +1,13 @@
 # Template file for 'unpaper'
 pkgname=unpaper
-version=6.1
-revision=3
-build_style=gnu-configure
+version=7.0.0
+revision=1
+build_style=meson
+hostmakedepends="pkg-config meson libxslt"
+makedepends="ffmpeg-devel python3-Sphinx"
+short_desc="Post-processing tool for scanned sheets of paper"
 maintainer="Orphaned <orphan@voidlinux.org>"
-hostmakedepends="pkg-config libxslt"
-makedepends="ffmpeg-devel"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://www.flameeyes.eu/projects/unpaper"
-short_desc="A post-processing tool for scanned sheets of paper"
 distfiles="https://www.flameeyes.eu/files/${pkgname}-${version}.tar.xz"
-checksum=237c84f5da544b3f7709827f9f12c37c346cdf029b1128fb4633f9bafa5cb930
+checksum=2575fbbf26c22719d1cb882b59602c9900c7f747118ac130883f63419be46a80

From 578383c4d8e97c989ce3c52664b9276172c6aeb7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 073/115] vba-m: revbump for ffmpeg-6.0

---
 srcpkgs/vba-m/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vba-m/template b/srcpkgs/vba-m/template
index 9c71cefe3f8dd..2223d297c31f5 100644
--- a/srcpkgs/vba-m/template
+++ b/srcpkgs/vba-m/template
@@ -2,7 +2,7 @@
 pkgname=vba-m
 reverts=1292_2
 version=2.1.7
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DENABLE_GTK=TRUE -DENABLE_FFMPEG=TRUE -DENABLE_LINK=TRUE -DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="gettext pkg-config unzip zip yasm wxWidgets-gtk3-devel"

From 49e76d48b2c9c9740408ee1d2d372f4309ba5341 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 074/115] vice: revbump for ffmpeg4-4.4.3

---
 srcpkgs/vice/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vice/template b/srcpkgs/vice/template
index b1f866d35095e..4beab2c5f9ebd 100644
--- a/srcpkgs/vice/template
+++ b/srcpkgs/vice/template
@@ -26,7 +26,7 @@ makedepends="
 	$(vopt_if gtk3 gtk+3-devel)
 	$(vopt_if gtk3 pulseaudio-devel)
 	$(vopt_if gtk3 pango-devel)
-	$(vopt_if ffmpeg ffmpeg-devel)"
+	$(vopt_if ffmpeg ffmpeg4-devel)"
 short_desc="Emulator for C64, C128, CBM-II, PET, VIC20, Plus4 and C16"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"

From 800c04c3758f65238348f09346dc128e7472faf1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 075/115] waypipe: revbump for ffmpeg-6.0

---
 srcpkgs/waypipe/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waypipe/template b/srcpkgs/waypipe/template
index 6da88b21bf2a1..4da8058400b58 100644
--- a/srcpkgs/waypipe/template
+++ b/srcpkgs/waypipe/template
@@ -1,7 +1,7 @@
 # Template file for 'waypipe'
 pkgname=waypipe
 version=0.8.6
-revision=1
+revision=2
 build_style=meson
 # lto is off because it causes linking errors in armv6l and armv7l (due to NEON)
 configure_args="-Dwerror=false -Dwith_dmabuf=enabled -Dwith_lz4=enabled

From 9710df6454150f62afeb850fd911c7374b88c7c0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 076/115] xpra: revbump for ffmpeg-6.0

---
 srcpkgs/xpra/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xpra/template b/srcpkgs/xpra/template
index 394718b56f686..34fbff9b2f1ae 100644
--- a/srcpkgs/xpra/template
+++ b/srcpkgs/xpra/template
@@ -1,7 +1,7 @@
 # Template file for 'xpra'
 pkgname=xpra
 version=5.0.3
-revision=1
+revision=2
 build_style=python3-module
 make_build_args="--without-cuda_kernels --without-cuda_rebuild"
 make_install_args="$(vopt_with docs) ${make_build_args}"

From 032f028db840cfcc95d490f0b6497be116fd0dc3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:07:40 -0400
Subject: [PATCH 077/115] nv-codec-headers: update to 12.0.16.0

---
 srcpkgs/nv-codec-headers/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/nv-codec-headers/template b/srcpkgs/nv-codec-headers/template
index 3d422a61e4891..251e057f826fb 100644
--- a/srcpkgs/nv-codec-headers/template
+++ b/srcpkgs/nv-codec-headers/template
@@ -1,6 +1,6 @@
 # Template file for 'nv-codec-headers'
 pkgname=nv-codec-headers
-version=11.1.5.1
+version=12.0.16.0
 revision=1
 build_style=gnu-makefile
 short_desc="FFmpeg version of headers required to interface with Nvidias codec APIs"
@@ -8,7 +8,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="MIT"
 homepage="http://git.videolan.org/?p=ffmpeg/nv-codec-headers.git"
 distfiles="https://github.com/FFmpeg/nv-codec-headers/archive/n${version}.tar.gz"
-checksum=d095fbd56aa93772471a323be0ebe65504a0f43f06c76a30b6d25da77b06ae9c
+checksum=2a1533b65f55f9da52956faf0627ed3b74868ac0c7f269990edd21369113b48f
 
 post_install() {
 	sed -n '4,25p' include/ffnvcodec/nvEncodeAPI.h > LICENSE

From 1b7374a38d4d895e861e56bb63200a0371451735 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:08:40 -0400
Subject: [PATCH 078/115] openimagedenoise: revbump for ffmpeg-6.0

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index b792813dba7c2..109deb171c3f7 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,7 +1,7 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
 version=1.4.3
-revision=1
+revision=2
 archs="x86_64*"
 build_style=cmake
 hostmakedepends="ispc python3"

From 3b1a2815202c1bda0124e23a8cc5c700974355a1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:31:45 -0400
Subject: [PATCH 079/115] shotcut: revbump for ffmpeg-6.0

---
 srcpkgs/shotcut/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/shotcut/template b/srcpkgs/shotcut/template
index 33141fbd862d7..f46cb53b6bfb9 100644
--- a/srcpkgs/shotcut/template
+++ b/srcpkgs/shotcut/template
@@ -1,7 +1,7 @@
 # Template file for 'shotcut'
 pkgname=shotcut
 version=23.09.29
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSHOTCUT_VERSION=${version}"
 hostmakedepends="pkg-config qt6-tools-devel"

From 9a9827056968c9ec4162a6a069fe5e373a95e579 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:30 -0400
Subject: [PATCH 080/115] shiboken2: revbump for qt5-5.15.8

---
 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch | 1 +
 srcpkgs/shiboken2/template                                 | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
 create mode 120000 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
new file mode 120000
index 0000000000000..efcf3249bd885
--- /dev/null
+++ b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1 @@
+../../python3-pyside2/patches/importlib-machinery-bypass.patch
\ No newline at end of file
diff --git a/srcpkgs/shiboken2/template b/srcpkgs/shiboken2/template
index 883d6a084d868..f3c06ec245a1f 100644
--- a/srcpkgs/shiboken2/template
+++ b/srcpkgs/shiboken2/template
@@ -1,7 +1,7 @@
 # Template file for 'shiboken2'
 pkgname=shiboken2
 version=5.15.10
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/shiboken2"
 build_style=cmake

From 310a0635ace3853609fbbb8d6fd6fa53f35512db Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:53 -0400
Subject: [PATCH 081/115] python3-pyside2: revbump for qt5-5.15.8

---
 .../patches/importlib-machinery-bypass.patch      | 15 +++++++++++++++
 srcpkgs/python3-pyside2/template                  |  2 +-
 2 files changed, 16 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
new file mode 100644
index 0000000000000..64c429584776b
--- /dev/null
+++ b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1,15 @@
+Using this prevents an error around line 220 below it.
+"AttributeError: module 'importlib' has no attribute 'machinery'"
+The old backup logic is in place and compiles without issues.
+--- a/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:09:34.688912402 -0400
++++ b/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:10:03.395529582 -0400
+@@ -170,9 +170,6 @@
+
+     # 'zipstring_sequence' comes from signature.cpp
+     zipbytes = base64.b64decode(''.join(zipstring_sequence))
+-    if sys.version_info[0] >= 3:
+-        vzip = zipfile.ZipFile(io.BytesIO(zipbytes))
+-        return sys.meta_path, EmbeddableZipImporter(vzip)
+
+     # Old version for Python 2.7, only.
+     import os
diff --git a/srcpkgs/python3-pyside2/template b/srcpkgs/python3-pyside2/template
index 249efa9098842..52626436ce75f 100644
--- a/srcpkgs/python3-pyside2/template
+++ b/srcpkgs/python3-pyside2/template
@@ -1,7 +1,7 @@
 # Template file for 'python3-pyside2'
 pkgname=python3-pyside2
 version=5.15.10
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/pyside2"
 build_style=cmake

From 491da5bada66fd54c596a2795cf292eedb7a88c0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:35 -0400
Subject: [PATCH 082/115] konqueror: revbump for ffmpeg-6.0

---
 srcpkgs/konqueror/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/konqueror/template b/srcpkgs/konqueror/template
index abfa59e6b7ded..3cc29c12dc1db 100644
--- a/srcpkgs/konqueror/template
+++ b/srcpkgs/konqueror/template
@@ -1,11 +1,11 @@
 # Template file for 'konqueror'
 pkgname=konqueror
 version=23.08.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DDESKTOPTOJSON_EXECUTABLE=/usr/bin/desktoptojson"
 hostmakedepends="extra-cmake-modules python3 qt5-host-tools qt5-qmake kdoctools
-kcoreaddons kconfig gettext"
+ kcoreaddons kconfig gettext"
 makedepends="qt5-devel qt5-webengine-devel qt5-declarative-devel
  qt5-webchannel-devel qt5-location-devel kcmutils-devel kdelibs4support-devel
  karchive-devel khtml-devel kdesu-devel kactivities5-devel"

From 6af0be972332e95494bc20ee91e27c4cf9723d04 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:58 -0400
Subject: [PATCH 083/115] qt5-speech: revbump for qt5-5.15.8

---
 srcpkgs/qt5-speech/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-speech/template b/srcpkgs/qt5-speech/template
index 3ecd10d50650c..2d7d4d4d24535 100644
--- a/srcpkgs/qt5-speech/template
+++ b/srcpkgs/qt5-speech/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-speech'
 pkgname=qt5-speech
 version=5.15.7
-revision=2
+revision=3
 _commit=d32f4a479d38a11f547598004b975f4356424a16
 build_style=qmake
 configure_args="-- -flite -flite-alsa -speechd"

From d46cf1627cdb1b45a2b58b51c4d72c3acbad1e06 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 18:38:50 -0400
Subject: [PATCH 084/115] qt5-styleplugins: revbump for qt5-5.15.8

---
 srcpkgs/qt5-styleplugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-styleplugins/template b/srcpkgs/qt5-styleplugins/template
index 96ed97d12cd24..30d93660a2a4e 100644
--- a/srcpkgs/qt5-styleplugins/template
+++ b/srcpkgs/qt5-styleplugins/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-styleplugins'
 pkgname=qt5-styleplugins
 version=5.0.0
-revision=20
+revision=21
 _gitrev=335dbece103e2cbf6c7cf819ab6672c2956b17b3
 build_style=qmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From ec0e9e882f5d26ee40c0f02a987bb15499239d7e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 7 May 2023 20:15:03 -0400
Subject: [PATCH 085/115] qt6-webengine: revbump for ffmpeg-6.0

---
 srcpkgs/qt6-webengine/template | 1 +
 1 file changed, 1 insertion(+)

diff --git a/srcpkgs/qt6-webengine/template b/srcpkgs/qt6-webengine/template
index 98cdc680481b3..f33a71bd2a0dc 100644
--- a/srcpkgs/qt6-webengine/template
+++ b/srcpkgs/qt6-webengine/template
@@ -158,6 +158,7 @@ pre_install() {
 }
 
 post_install() {
+	vlicense LICENSES/BSD-3-Clause.txt
 	local _file
 	find "${DESTDIR}"/usr/lib/qt6/examples \
 		-path '*/lib/qt6/**/lib/qt6/*' -type f |

From 891631ac50091e9a32e6a261e0f0e2eb7e61cf5a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Jun 2023 08:20:22 -0400
Subject: [PATCH 086/115] gtk4: revbump for ffmpeg-6.0

---
 srcpkgs/gtk4/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gtk4/template b/srcpkgs/gtk4/template
index 6a4e20357a86f..ec0c13d2cc5b0 100644
--- a/srcpkgs/gtk4/template
+++ b/srcpkgs/gtk4/template
@@ -1,7 +1,7 @@
 # Template file for 'gtk4'
 pkgname=gtk4
 version=4.12.3
-revision=1
+revision=2
 build_style=meson
 build_helper="gir"
 configure_args="-Dman-pages=true -Ddocumentation=true -Dbuild-tests=false

From f5bad60ae1a89b7c1eaa7667361d9e78b56bd8d9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:28:26 -0400
Subject: [PATCH 087/115] siril: revbump for ffmpeg-6.0

---
 srcpkgs/siril/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/siril/template b/srcpkgs/siril/template
index 84332f79d060d..62750dd247548 100644
--- a/srcpkgs/siril/template
+++ b/srcpkgs/siril/template
@@ -1,7 +1,7 @@
 # Template file for 'siril'
 pkgname=siril
 version=0.9.12
-revision=10
+revision=11
 build_style=gnu-configure
 hostmakedepends="pkg-config intltool autoconf automake gettext-devel"
 makedepends="fftw-devel libconfig-devel libopencv-devel libffms2-devel

From e8d753b62a7ef524e2a383db6c4de71d62e1b359 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 22 Jun 2023 10:25:02 -0400
Subject: [PATCH 088/115] kdenlive: revbump for ffmpeg-6.0

---
 srcpkgs/kdenlive/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kdenlive/template b/srcpkgs/kdenlive/template
index ec5fe75860948..e69ecff31f272 100644
--- a/srcpkgs/kdenlive/template
+++ b/srcpkgs/kdenlive/template
@@ -1,7 +1,7 @@
 # Template file for 'kdenlive'
 pkgname=kdenlive
 version=23.08.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="
  extra-cmake-modules kconfig kcoreaddons kdoctools pkg-config python3

From ba79e1b897f84ebbb3203bcf7e56210c1466092a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Jul 2023 11:17:37 -0400
Subject: [PATCH 089/115] DELETE: intel_packages

---
 common/shlibs                                 |   2 +
 srcpkgs/intel-gmmlib/template                 |   2 +-
 ...mmon-Enable-MMC-in-free-kernel-build.patch | 125 ++++++++++++++++++
 srcpkgs/intel-media-driver/template           |   6 +-
 srcpkgs/intel-media-sdk/patches/musl.patch    |  14 ++
 srcpkgs/intel-media-sdk/template              |  37 ++++++
 srcpkgs/intel-media-sdk/update                |   1 +
 srcpkgs/libmfx                                |   1 +
 srcpkgs/libmfx-devel                          |   1 +
 srcpkgs/onevpl-devel                          |   1 +
 srcpkgs/onevpl-intel-gpu-devel                |   1 +
 srcpkgs/onevpl-intel-gpu/template             |  27 ++++
 srcpkgs/onevpl/template                       |  34 +++++
 13 files changed, 248 insertions(+), 4 deletions(-)
 create mode 100644 srcpkgs/intel-media-driver/patches/0001-Media-Common-Enable-MMC-in-free-kernel-build.patch
 create mode 100644 srcpkgs/intel-media-sdk/patches/musl.patch
 create mode 100644 srcpkgs/intel-media-sdk/template
 create mode 100644 srcpkgs/intel-media-sdk/update
 create mode 120000 srcpkgs/libmfx
 create mode 120000 srcpkgs/libmfx-devel
 create mode 120000 srcpkgs/onevpl-devel
 create mode 120000 srcpkgs/onevpl-intel-gpu-devel
 create mode 100644 srcpkgs/onevpl-intel-gpu/template
 create mode 100644 srcpkgs/onevpl/template

diff --git a/common/shlibs b/common/shlibs
index 3d769cd4428fa..e893a88bc6a20 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4253,6 +4253,8 @@ libgsoapssl++-2.8.124.so gsoap-2.8.124_1
 libjxl.so.0.8 libjxl-0.8.2_1
 libjxl_dec.so.0.8 libjxl-0.8.2_1
 libjxl_threads.so.0.8 libjxl-0.8.2_1
+libmfx.so.1 libmfx-22.6.4_1
+libvpl.so.2 onevpl-2023.1.2_1
 libtext-engine-0.1.so.0 text-engine-0.1.1_1
 libvmaf.so.1 vmaf-2.3.1_1
 liblc3.so.1 liblc3-1.0.3_1
diff --git a/srcpkgs/intel-gmmlib/template b/srcpkgs/intel-gmmlib/template
index b9df642f6320f..3d64be7415298 100644
--- a/srcpkgs/intel-gmmlib/template
+++ b/srcpkgs/intel-gmmlib/template
@@ -14,7 +14,7 @@ build_style=cmake
 # compilers flag in use.
 configure_args="-Wno-dev"
 short_desc="Intel Graphics Memory Management Library"
-maintainer="Orphaned <orphan@voidlinux.org>"
+maintainer="Stefano Ragni <st3r4g@protonmail.com>"
 license="MIT"
 homepage="https://github.com/intel/gmmlib"
 distfiles="https://github.com/intel/gmmlib/archive/intel-gmmlib-${version}.tar.gz"
diff --git a/srcpkgs/intel-media-driver/patches/0001-Media-Common-Enable-MMC-in-free-kernel-build.patch b/srcpkgs/intel-media-driver/patches/0001-Media-Common-Enable-MMC-in-free-kernel-build.patch
new file mode 100644
index 0000000000000..525fb688722c8
--- /dev/null
+++ b/srcpkgs/intel-media-driver/patches/0001-Media-Common-Enable-MMC-in-free-kernel-build.patch
@@ -0,0 +1,125 @@
+From e68feab7db036838d9521ba3b9f00717c37c024c Mon Sep 17 00:00:00 2001
+From: JayYang <jay.yang@intel.com>
+Date: Tue, 21 Mar 2023 17:17:55 +0800
+Subject: [PATCH] [Media Common] Enable MMC in free kernel build
+
+Add mmc build definition in free kernel build
+---
+ media_driver/agnostic/gen9/codec/hal/media_srcs.cmake          | 2 +-
+ media_driver/cmake/linux/media_feature_flags_linux.cmake       | 3 +--
+ .../media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp        | 2 +-
+ .../media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp        | 2 +-
+ .../media_interfaces_m9_glk/media_interfaces_g9_glk.cpp        | 2 +-
+ .../media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp        | 2 +-
+ .../media_interfaces_m9_skl/media_interfaces_g9_skl.cpp        | 2 +-
+ 7 files changed, 7 insertions(+), 8 deletions(-)
+
+diff --git a/media_driver/agnostic/gen9/codec/hal/media_srcs.cmake b/media_driver/agnostic/gen9/codec/hal/media_srcs.cmake
+index 8bb36bafe..78902a22d 100644
+--- a/media_driver/agnostic/gen9/codec/hal/media_srcs.cmake
++++ b/media_driver/agnostic/gen9/codec/hal/media_srcs.cmake
+@@ -27,7 +27,7 @@ set(TMP_1_HEADERS_
+     ${CMAKE_CURRENT_LIST_DIR}/codechal_hw_g9_X.h
+ )
+ 
+-if(${MMC_Supported} STREQUAL "yes")
++if(${MMC_Supported} STREQUAL "yes" AND ENABLE_NONFREE_KERNELS AND ENABLE_KERNELS)
+     set(TMP_1_SOURCES_
+         ${TMP_1_SOURCES_}
+         ${CMAKE_CURRENT_LIST_DIR}/codechal_memdecomp_g9.cpp
+diff --git a/media_driver/cmake/linux/media_feature_flags_linux.cmake b/media_driver/cmake/linux/media_feature_flags_linux.cmake
+index de0ca853f..8121ea60c 100644
+--- a/media_driver/cmake/linux/media_feature_flags_linux.cmake
++++ b/media_driver/cmake/linux/media_feature_flags_linux.cmake
+@@ -35,7 +35,6 @@ if(NOT ENABLE_KERNELS OR NOT ENABLE_NONFREE_KERNELS)
+     bs_set_if_undefined(HEVC_Encode_VME_Supported "no")
+     bs_set_if_undefined(MPEG2_Encode_VME_Supported "no")
+     bs_set_if_undefined(CMRT_HEVC_ENC_FEI_Supported "no")
+-    bs_set_if_undefined(MMC_Supported "no")
+     bs_set_if_undefined(VC1_Decode_Supported "no")
+     bs_set_if_undefined(Decode_Processing_Supported "no")
+     bs_set_if_undefined(Kernel_Auto_Denoise_Supported "no")
+@@ -46,7 +45,6 @@ else()
+     bs_set_if_undefined(HEVC_Encode_VME_Supported "${Encode_VME_Supported}")
+     bs_set_if_undefined(MPEG2_Encode_VME_Supported "${Encode_VME_Supported}")
+     bs_set_if_undefined(CMRT_HEVC_ENC_FEI_Supported "yes")
+-    bs_set_if_undefined(MMC_Supported "yes")
+     bs_set_if_undefined(VC1_Decode_Supported "yes")
+     bs_set_if_undefined(Decode_Processing_Supported "yes")
+     bs_set_if_undefined(Kernel_Auto_Denoise_Supported "yes")
+@@ -64,6 +62,7 @@ bs_set_if_undefined(VP9_Decode_Supported "yes")
+ bs_set_if_undefined(VP_SFC_Supported "yes")
+ bs_set_if_undefined(Common_Encode_Supported "yes")
+ bs_set_if_undefined(Media_Scalability_Supported "yes")
++bs_set_if_undefined(MMC_Supported "yes")
+ 
+ # features controlled by global flag Encode_VDEnc_Supported
+ bs_set_if_undefined(AVC_Encode_VDEnc_Supported "${Encode_VDEnc_Supported}")
+diff --git a/media_driver/media_interface/media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp b/media_driver/media_interface/media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp
+index 3f306ee2a..8e4c0f532 100644
+--- a/media_driver/media_interface/media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp
+@@ -135,7 +135,7 @@ MOS_STATUS MhwInterfacesG9Bxt::Initialize(
+ 
+     return MOS_STATUS_SUCCESS;
+ }
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool bxtRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Bxt>((uint32_t)IGFX_BROXTON);
+diff --git a/media_driver/media_interface/media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp b/media_driver/media_interface/media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp
+index b8fa1eec0..84e0fad1d 100644
+--- a/media_driver/media_interface/media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp
+@@ -44,7 +44,7 @@ static bool cflRegisteredMhw =
+     MediaFactory<uint32_t, MhwInterfaces>::
+     Register<MhwInterfacesG9Kbl>((uint32_t)IGFX_COFFEELAKE);
+ 
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool cflRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Kbl>((uint32_t)IGFX_COFFEELAKE);
+diff --git a/media_driver/media_interface/media_interfaces_m9_glk/media_interfaces_g9_glk.cpp b/media_driver/media_interface/media_interfaces_m9_glk/media_interfaces_g9_glk.cpp
+index de81e6091..2638cb3a6 100644
+--- a/media_driver/media_interface/media_interfaces_m9_glk/media_interfaces_g9_glk.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_glk/media_interfaces_g9_glk.cpp
+@@ -65,7 +65,7 @@ static bool glkRegisteredMhw =
+     MediaFactory<uint32_t, MhwInterfaces>::
+     Register<MhwInterfacesG9Kbl>((uint32_t)IGFX_GEMINILAKE);
+ 
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool glkRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Kbl>((uint32_t)IGFX_GEMINILAKE);
+diff --git a/media_driver/media_interface/media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp b/media_driver/media_interface/media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp
+index 99d786185..4e9c6e7f1 100644
+--- a/media_driver/media_interface/media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp
+@@ -131,7 +131,7 @@ MOS_STATUS MhwInterfacesG9Kbl::Initialize(
+ 
+     return MOS_STATUS_SUCCESS;
+ }
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool kblRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Kbl>((uint32_t)IGFX_KABYLAKE);
+diff --git a/media_driver/media_interface/media_interfaces_m9_skl/media_interfaces_g9_skl.cpp b/media_driver/media_interface/media_interfaces_m9_skl/media_interfaces_g9_skl.cpp
+index e2520edf7..4b0012c64 100644
+--- a/media_driver/media_interface/media_interfaces_m9_skl/media_interfaces_g9_skl.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_skl/media_interfaces_g9_skl.cpp
+@@ -139,7 +139,7 @@ MOS_STATUS MhwInterfacesG9Skl::Initialize(
+ 
+     return MOS_STATUS_SUCCESS;
+ }
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool sklRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Skl>((uint32_t)IGFX_SKYLAKE);
+-- 
+2.40.0
+
diff --git a/srcpkgs/intel-media-driver/template b/srcpkgs/intel-media-driver/template
index 06b7c19a0ba07..1735b90c65ce5 100644
--- a/srcpkgs/intel-media-driver/template
+++ b/srcpkgs/intel-media-driver/template
@@ -1,6 +1,6 @@
 # Template file for 'intel-media-driver'
 pkgname=intel-media-driver
-version=23.3.5
+version=22.6.4
 revision=1
 archs="x86_64*"
 build_style=cmake
@@ -8,11 +8,11 @@ configure_args="-Wno-dev -DENABLE_NONFREE_KERNELS=$(vopt_if nonfree ON OFF)"
 hostmakedepends="pkg-config"
 makedepends="libva-devel libX11-devel intel-gmmlib-devel libpciaccess-devel"
 short_desc="Intel Media Driver for VAAPI (Broadwell+)"
-maintainer="Orphaned <orphan@voidlinux.org>"
+maintainer="Stefano Ragni <st3r4g@protonmail.com>"
 license="MIT, BSD-3-Clause"
 homepage="https://github.com/intel/media-driver"
 distfiles="https://github.com/intel/media-driver/archive/intel-media-${version}.tar.gz"
-checksum=67fd15654bb3c596feb8c85e81221de5632e11f598421c35adc4453d727f0130
+checksum=0c04b9d74b92de41fd409b62913ce4afd799236c0b6bc1983a496990764e5d90
 
 build_options="nonfree"
 desc_option_nonfree="Enable nonfree kernels"
diff --git a/srcpkgs/intel-media-sdk/patches/musl.patch b/srcpkgs/intel-media-sdk/patches/musl.patch
new file mode 100644
index 0000000000000..4ae70924b744f
--- /dev/null
+++ b/srcpkgs/intel-media-sdk/patches/musl.patch
@@ -0,0 +1,14 @@
+--- a/tools/tracer/tracer/tracer_linux.cpp	2022-11-18 03:02:59.000000000 -0500
++++ b/tools/tracer/tracer/tracer_linux.cpp	2022-12-18 01:44:51.341542572 -0500
+@@ -32,6 +32,11 @@
+ #include <dlfcn.h>
+ #include "tracer.h"
+
++#ifndef RTLD_DEEPBIND
++// musl neither defines nor can use RTLD_DEEPBIND
++#define RTLD_DEEPBIND 0
++#endif
++
+ #if defined(__i386__)
+     #define LIBMFXHW "libmfxhw32.so.1"
+ #elif defined(__x86_64__)
diff --git a/srcpkgs/intel-media-sdk/template b/srcpkgs/intel-media-sdk/template
new file mode 100644
index 0000000000000..7aeab51802f8e
--- /dev/null
+++ b/srcpkgs/intel-media-sdk/template
@@ -0,0 +1,37 @@
+# Template file for 'intel-media-sdk'
+pkgname=intel-media-sdk
+version=22.6.4
+revision=1
+archs="x86_64*"
+build_style=cmake
+configure_args="-Wno-dev -DBUILD_SAMPLES=OFF -DBUILD_TESTS=ON"
+hostmakedepends="pkg-config"
+makedepends="libva-devel libdrm-devel intel-gmmlib-devel"
+short_desc="Intel Media SDK"
+maintainer="Stefano Ragni <st3r4g@protonmail.com>"
+license="MIT, BSD-3-Clause"
+homepage="https://github.com/Intel-Media-SDK/MediaSDK"
+distfiles="https://github.com/Intel-Media-SDK/MediaSDK/archive/refs/tags/intel-mediasdk-${version}.tar.gz"
+checksum=197acd056f81e9ff1c27068d50e8c84c2014d94c7ac17cad69d5c2d61e445fd3
+
+post_install() {
+	vlicense LICENSE
+}
+
+libmfx_package() {
+	depends="${makedepends} ${sourcepkg}-${version}_${revision}"
+	short_desc="Intel MediaSDK mfx lib"
+	pkg_install() {
+		vmove usr/lib/mfx
+		vmove "usr/lib/libmfx*.so*"
+	}
+}
+
+libmfx-devel_package() {
+	depends="${makedepends} ${sourcepkg}-${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+	}
+}
diff --git a/srcpkgs/intel-media-sdk/update b/srcpkgs/intel-media-sdk/update
new file mode 100644
index 0000000000000..434a2bc67f7a1
--- /dev/null
+++ b/srcpkgs/intel-media-sdk/update
@@ -0,0 +1 @@
+pkgname=intel-media
diff --git a/srcpkgs/libmfx b/srcpkgs/libmfx
new file mode 120000
index 0000000000000..8ffc7099c2272
--- /dev/null
+++ b/srcpkgs/libmfx
@@ -0,0 +1 @@
+intel-media-sdk
\ No newline at end of file
diff --git a/srcpkgs/libmfx-devel b/srcpkgs/libmfx-devel
new file mode 120000
index 0000000000000..8ffc7099c2272
--- /dev/null
+++ b/srcpkgs/libmfx-devel
@@ -0,0 +1 @@
+intel-media-sdk
\ No newline at end of file
diff --git a/srcpkgs/onevpl-devel b/srcpkgs/onevpl-devel
new file mode 120000
index 0000000000000..e2306500b4871
--- /dev/null
+++ b/srcpkgs/onevpl-devel
@@ -0,0 +1 @@
+onevpl
\ No newline at end of file
diff --git a/srcpkgs/onevpl-intel-gpu-devel b/srcpkgs/onevpl-intel-gpu-devel
new file mode 120000
index 0000000000000..47920ceecf919
--- /dev/null
+++ b/srcpkgs/onevpl-intel-gpu-devel
@@ -0,0 +1 @@
+onevpl-intel-gpu
\ No newline at end of file
diff --git a/srcpkgs/onevpl-intel-gpu/template b/srcpkgs/onevpl-intel-gpu/template
new file mode 100644
index 0000000000000..f14acb728a54d
--- /dev/null
+++ b/srcpkgs/onevpl-intel-gpu/template
@@ -0,0 +1,27 @@
+# Template file for 'onevpl-intel-gpu'
+pkgname=onevpl-intel-gpu
+version=22.6.4
+revision=1
+archs="x86_64*"
+build_style=cmake
+configure_args="-Wno-dev -DCMAKE_BUILD_TYPE=Release"
+hostmakedepends="cmake pkg-config"
+makedepends="libdrm-devel libva-devel onevpl-devel"
+short_desc="Runtime implementation of oneVPL API for Intel Gen GPUs"
+maintainer="zlice <zlice555@gmail.com>"
+license="MIT"
+homepage="https://github.com/oneapi-src/oneVPL-intel-gpu"
+changelog="https://github.com/oneapi-src/oneVPL-intel-gpu/blob/main/CHANGELOG.md"
+distfiles="https://github.com/oneapi-src/oneVPL-intel-gpu/archive/refs/tags/intel-onevpl-${version}.tar.gz"
+checksum=74b0979dcb2af1b7c68edb8cbcb02d539de511090b12fac50652cbacd707c4e6
+
+post_install() {
+	vlicense LICENSE
+}
+
+onevpl-intel-gpu-devel_package() {
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/lib/pkgconfig
+	}
+}
diff --git a/srcpkgs/onevpl/template b/srcpkgs/onevpl/template
new file mode 100644
index 0000000000000..85c7c2da85ce9
--- /dev/null
+++ b/srcpkgs/onevpl/template
@@ -0,0 +1,34 @@
+# Template file for 'onevpl'
+pkgname=onevpl
+version=2023.1.2
+revision=1
+archs="x86_64*"
+build_style=cmake
+configure_args="
+	-DCMAKE_BUILD_TYPE=Release -Wno-dev
+	-DBUILD_PYTHON_BINDING:BOOL='OFF'
+	-DBUILD_EXAMPLES:BOOL='OFF'
+	-DBUILD_TESTS:BOOL='ON'
+	-DINSTALL_EXAMPLE_CODE:BOOL='OFF'"
+hostmakedepends="cmake libX11 python wayland-protocols pkg-config"
+makedepends="libva-devel libX11-devel wayland-devel"
+short_desc="Intel oneAPI Video Processing library"
+maintainer="zlice <zlice555@gmail.com>"
+license="MIT"
+homepage="https://www.intel.com/content/www/us/en/developer/tools/oneapi/onevpl.html"
+distfiles="https://github.com/oneapi-src/oneVPL/archive/v${version}/${pkgname}-${version}.tar.gz"
+checksum=b2261cca174ce1815f3d47c647921ab17f68267c69c1e2444ff27aab7d199cbb
+
+post_install() {
+	vlicense LICENSE
+}
+
+onevpl-devel_package() {
+	depends="${makedepends} ${sourcepkg}-${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.so"
+	}
+}

From a948deab1047ffafda84dd78f2c88fa99835acdd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:20:59 -0400
Subject: [PATCH 090/115] tracker-miners: revbump for ffmpeg-6.0

---
 srcpkgs/tracker-miners/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tracker-miners/template b/srcpkgs/tracker-miners/template
index 0b97f47489f81..f196d2bf9e4a4 100644
--- a/srcpkgs/tracker-miners/template
+++ b/srcpkgs/tracker-miners/template
@@ -1,7 +1,7 @@
 # Template file for 'tracker-miners'
 pkgname=tracker-miners
 version=3.6.1
-revision=1
+revision=2
 build_style=meson
 build_helper=qemu
 # missing libgrss for miner_rss

From 6b080de2a9afd3fc837aa2bace4ca5d86c0d7e2e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:21:21 -0400
Subject: [PATCH 091/115] mpd: revbump for ffmpeg-6.0

---
 srcpkgs/mpd/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpd/template b/srcpkgs/mpd/template
index 645c1b778e407..60287cc9f6e3c 100644
--- a/srcpkgs/mpd/template
+++ b/srcpkgs/mpd/template
@@ -1,7 +1,7 @@
 # Template file for 'mpd'
 pkgname=mpd
 version=0.23.14
-revision=3
+revision=4
 build_style=meson
 configure_args="-Dopus=enabled -Dmikmod=enabled -Dneighbor=true
  -Dsoundcloud=enabled -Dpipe=true -Dtwolame=enabled -Dbzip2=enabled

From 9c86a89579460ae8df14b401126ec3d47a168149 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:02 -0400
Subject: [PATCH 092/115] tg_owt: revbump for ffmpeg-6.0

---
 srcpkgs/tg_owt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tg_owt/template b/srcpkgs/tg_owt/template
index 50bc8310b8859..c93262d5c5de6 100644
--- a/srcpkgs/tg_owt/template
+++ b/srcpkgs/tg_owt/template
@@ -1,7 +1,7 @@
 # Template file for 'tg_owt'
 pkgname=tg_owt
 version=0.0.0.20230921
-revision=1
+revision=2
 _commit=3bb3d757681e6cc5135aec6529a753dc3dcdcfb9
 _libyuv_commit=04821d1e7d60845525e8db55c7bcd41ef5be9406
 _abseil_commit=8c0b94e793a66495e0b1f34a5eb26bd7dc672db0

From 80a67282d1ffeedfb58fea79b6f5a5256307906e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:44 -0400
Subject: [PATCH 093/115] telegram-desktop: revbump for ffmpeg-6.0

---
 srcpkgs/telegram-desktop/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/telegram-desktop/template b/srcpkgs/telegram-desktop/template
index 9bd94ce3781ff..d33fc62b10e38 100644
--- a/srcpkgs/telegram-desktop/template
+++ b/srcpkgs/telegram-desktop/template
@@ -1,7 +1,7 @@
 # Template file for 'telegram-desktop'
 pkgname=telegram-desktop
 version=4.11.2
-revision=1
+revision=2
 build_style=cmake
 build_helper="qemu gir"
 configure_args="-DTDESKTOP_API_ID=209235

From 5d99188a172708a1886b40fbd9e30a2bed2ae8b8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:11:45 -0400
Subject: [PATCH 094/115] gst-plugins-bad1: revbump for ffmpeg-6.0

---
 srcpkgs/gst-plugins-bad1/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index 2bf2f4b0642fe..0fafcb6555395 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-plugins-bad1'
 pkgname=gst-plugins-bad1
 version=1.22.5
-revision=1
+revision=2
 build_helper="gir"
 build_style=meson
 configure_args="-Dpackage-origin=https://voidlinux.org -Ddoc=disabled

From fcb319d991ecf364e0e92ba0927178128e37eb9e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:12:09 -0400
Subject: [PATCH 095/115] openmw: revbump for ffmpeg-6.0

---
 srcpkgs/openmw/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openmw/template b/srcpkgs/openmw/template
index 0abf5ff7cdbec..b57180f1a4446 100644
--- a/srcpkgs/openmw/template
+++ b/srcpkgs/openmw/template
@@ -1,7 +1,7 @@
 # Template file for 'openmw'
 pkgname=openmw
 version=0.48.0
-revision=2
+revision=3
 build_style=cmake
 _recast_commit=e75adf86f91eb3082220085e42dda62679f9a3ea
 _bullet_tag=3.17

From 256cf6030add864f0705de0a317bb22945a4c82b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:14:53 -0400
Subject: [PATCH 096/115] lms: revbump for ffmpeg-6.0

---
 srcpkgs/lms/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/lms/template b/srcpkgs/lms/template
index e358f75902a98..3b21c458de519 100644
--- a/srcpkgs/lms/template
+++ b/srcpkgs/lms/template
@@ -1,7 +1,7 @@
 # Template file for 'lms'
 pkgname=lms
 version=3.42.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="wt-devel ffmpeg-devel boost-devel libconfig++-devel taglib-devel pam-devel libgraphicsmagick-devel gtest-devel libarchive-devel"

From c9dfefae5a91ddffe405283ab6ceeaee44598c6e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:18:18 -0400
Subject: [PATCH 097/115] freecad: revbump for ffmpeg-6.0

---
 srcpkgs/freecad/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/freecad/template b/srcpkgs/freecad/template
index c135701e38b9a..705499e9972a6 100644
--- a/srcpkgs/freecad/template
+++ b/srcpkgs/freecad/template
@@ -1,7 +1,7 @@
 # Template file for 'freecad'
 pkgname=freecad
 version=0.20.2
-revision=7
+revision=8
 build_wrksrc="FreeCAD-${version}"
 build_style=cmake
 pycompile_dirs="usr/lib/${pkgname}/Mod"

From f458f0ee6b5c16733d0abc5823e454e6e186b612 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:47:18 -0400
Subject: [PATCH 098/115] libopenshot: revbump for ffmpeg-6.0

---
 srcpkgs/libopenshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenshot/template b/srcpkgs/libopenshot/template
index 8e57c5f592169..7a8f4520e7892 100644
--- a/srcpkgs/libopenshot/template
+++ b/srcpkgs/libopenshot/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenshot'
 pkgname=libopenshot
 version=0.3.0
-revision=3
+revision=4
 build_style=cmake
 # Builds fail with Ruby-2.4.1
 configure_args="-DENABLE_RUBY=OFF -DUSE_SYSTEM_JSONCPP=ON"

From 9854266586675fd4efa41c6d3362d7ef9272010b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:10:30 -0500
Subject: [PATCH 099/115] openimageio: revbump for ffmpeg-6.0

---
 srcpkgs/openimageio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimageio/template b/srcpkgs/openimageio/template
index 3ce3f9e49d350..27d2131bc0a61 100644
--- a/srcpkgs/openimageio/template
+++ b/srcpkgs/openimageio/template
@@ -1,7 +1,7 @@
 # Template file for 'openimageio'
 pkgname=openimageio
 version=2.4.9.0
-revision=7
+revision=8
 build_style=cmake
 build_helper=qemu
 configure_args="-DUSE_QT=0 -DUSE_PYTHON=0 -DOIIO_BUILD_TESTS=0

From 04799e2891ab8024fc67fef31dfe3b944024a657 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:11:57 -0500
Subject: [PATCH 100/115] synfigstudio: revbump for ffmpeg-6.0

---
 srcpkgs/synfigstudio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/synfigstudio/template b/srcpkgs/synfigstudio/template
index 09e442da9a680..2bc017cedca6b 100644
--- a/srcpkgs/synfigstudio/template
+++ b/srcpkgs/synfigstudio/template
@@ -2,7 +2,7 @@
 # Should be kept in sync with 'synfig' and 'ETL'
 pkgname=synfigstudio
 version=1.4.4
-revision=4
+revision=5
 build_style=gnu-configure
 configure_args="--disable-update-mimedb"
 hostmakedepends="pkg-config intltool gettext synfig"

From 5132387291939cd4ebf7f15764c8827f06f6e634 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:12:32 -0500
Subject: [PATCH 101/115] gmic: revbump for ffmpeg-6.0

---
 srcpkgs/gmic/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gmic/template b/srcpkgs/gmic/template
index 808953e9b543c..d854808f86aa4 100644
--- a/srcpkgs/gmic/template
+++ b/srcpkgs/gmic/template
@@ -1,7 +1,7 @@
 # Template file for 'gmic'
 pkgname=gmic
 version=3.1.6
-revision=5
+revision=6
 _zart_hash=34ebf6cce0bafb98abe57cec83c4a02cd1abeca0
 create_wrksrc=yes
 build_wrksrc="src"

From fa697e5acffc0b93e8d022ebb07d9f3b551740b3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:10 -0500
Subject: [PATCH 102/115] mixxx: revbump for ffmpeg-6.0

---
 srcpkgs/mixxx/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mixxx/template b/srcpkgs/mixxx/template
index 6921996e4e77b..6a79b328c1abf 100644
--- a/srcpkgs/mixxx/template
+++ b/srcpkgs/mixxx/template
@@ -1,7 +1,7 @@
 # Template file for 'mixxx'
 pkgname=mixxx
 version=2.3.3
-revision=6
+revision=7
 build_style=cmake
 configure_args="-DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="extra-cmake-modules pkg-config protobuf qt5-host-tools qt5-qmake"

From 0f16ee63fb874acc1930cbe8fc6cc193aef8b04b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:28 -0500
Subject: [PATCH 103/115] musikcube: revbump for ffmpeg-6.0

---
 srcpkgs/musikcube/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/musikcube/template b/srcpkgs/musikcube/template
index d9e6186e6697b..637952d50aca3 100644
--- a/srcpkgs/musikcube/template
+++ b/srcpkgs/musikcube/template
@@ -1,7 +1,7 @@
 # Template file for 'musikcube'
 pkgname=musikcube
 version=3.0.0
-revision=3
+revision=4
 build_style=cmake
 make_cmd=make
 configure_args="-DNO_NCURSESW=1"

From e84179db955fc2fe8043947835fe70fc84cfb403 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:45 -0500
Subject: [PATCH 104/115] electron24: revbump for ffmpeg-6.0

---
 srcpkgs/electron24/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron24/template b/srcpkgs/electron24/template
index a9c865c19c989..b8613e4362bc7 100644
--- a/srcpkgs/electron24/template
+++ b/srcpkgs/electron24/template
@@ -1,7 +1,7 @@
 # Template file for 'electron24'
 pkgname=electron24
 version=24.3.0
-revision=2
+revision=3
 _nodever=18.14.0
 _chromiumver=112.0.5615.165
 archs="x86_64* aarch64*"

From 0e5ad2e6bb208073aca2e59068138ad7e146fb24 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:00 -0500
Subject: [PATCH 105/115] electron19: revbump for ffmpeg-6.0

---
 srcpkgs/electron19/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron19/template b/srcpkgs/electron19/template
index b18bc792c8221..29fb34e254eea 100644
--- a/srcpkgs/electron19/template
+++ b/srcpkgs/electron19/template
@@ -1,7 +1,7 @@
 # Template file for 'electron19'
 pkgname=electron19
 version=19.0.8
-revision=4
+revision=5
 _nodever=16.14.2
 _chromiumver=102.0.5005.125
 archs="x86_64* aarch64* ppc64le*"

From 8a9b8947a36eab9f18d312d15050330b1e43b7e2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:13 -0500
Subject: [PATCH 106/115] wf-recorder: revbump for ffmpeg-6.0

---
 srcpkgs/wf-recorder/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/wf-recorder/template b/srcpkgs/wf-recorder/template
index 08f986b031006..63c45cf4b814d 100644
--- a/srcpkgs/wf-recorder/template
+++ b/srcpkgs/wf-recorder/template
@@ -1,7 +1,7 @@
 # Template file for 'wf-recorder'
 pkgname=wf-recorder
 version=0.4.1
-revision=2
+revision=3
 build_style=meson
 hostmakedepends="pkg-config scdoc wayland-devel"
 makedepends="wayland-protocols wayland-devel ffmpeg-devel libgbm-devel x264-devel

From 416105c35e4dc88f34fbee4668a9166d0c183fd0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:26 -0500
Subject: [PATCH 107/115] obs: revbump for ffmpeg-6.0

---
 srcpkgs/obs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/obs/template b/srcpkgs/obs/template
index 5d1d5e887409e..3eaaf8d4c8200 100644
--- a/srcpkgs/obs/template
+++ b/srcpkgs/obs/template
@@ -1,7 +1,7 @@
 # Template file for 'obs'
 pkgname=obs
 version=29.1.3
-revision=3
+revision=4
 archs="i686* x86_64* ppc64le* aarch64*"
 build_style=cmake
 configure_args="-DOBS_VERSION_OVERRIDE=${version} -DENABLE_JACK=ON

From b30bf1090a75e10319a2ec13d7942731b802c978 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:36 -0500
Subject: [PATCH 108/115] mlt7: revbump for ffmpeg-6.0

---
 srcpkgs/mlt7/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mlt7/template b/srcpkgs/mlt7/template
index 98f302ad3a516..7eb8c00fa1580 100644
--- a/srcpkgs/mlt7/template
+++ b/srcpkgs/mlt7/template
@@ -1,7 +1,7 @@
 # Template file for 'mlt7'
 pkgname=mlt7
 version=7.20.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DSWIG_PYTHON=ON -DMOD_QT6=ON"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which

From 94518af14c54bef399786e506c598b92af195aa7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:48 -0500
Subject: [PATCH 109/115] qt6-multimedia: revbump for ffmpeg-6.0

---
 srcpkgs/qt6-multimedia/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-multimedia/template b/srcpkgs/qt6-multimedia/template
index 67a577e1300fe..1da626ecf515a 100644
--- a/srcpkgs/qt6-multimedia/template
+++ b/srcpkgs/qt6-multimedia/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-multimedia'
 pkgname=qt6-multimedia
 version=6.6.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DQT_FEATURE_gstreamer=ON"
 hostmakedepends="perl qt6-declarative-host-tools pkg-config qt6-shadertools"

From 238b3085e6f29b14e9bce38d0de9d10a908cb434 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:00:15 -0500
Subject: [PATCH 110/115] baresip: revbump for ffmpeg-6.0

---
 srcpkgs/baresip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/baresip/template b/srcpkgs/baresip/template
index 12c8954ef7b9b..b16b67beab8d2 100644
--- a/srcpkgs/baresip/template
+++ b/srcpkgs/baresip/template
@@ -1,7 +1,7 @@
 # Template file for 'baresip'
 pkgname=baresip
 version=3.6.0
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config glib-devel"
 makedepends="libgsm-devel libpng-devel openssl-devel libsndfile-devel

From 78f029e57538aa2d4139bbf877237828e3405b19 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:30 -0500
Subject: [PATCH 111/115] QMPlay2: revbump for ffmpeg-6.0

---
 srcpkgs/QMPlay2/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/QMPlay2/template b/srcpkgs/QMPlay2/template
index 46c80f64a1349..942258ce60fb7 100644
--- a/srcpkgs/QMPlay2/template
+++ b/srcpkgs/QMPlay2/template
@@ -1,7 +1,7 @@
 # Template file for 'QMPlay2'
 pkgname=QMPlay2
 version=23.10.22
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools"
 makedepends="alsa-lib-devel ffmpeg-devel libass-devel libcdio-devel libgme-devel

From ca4de4222da5be3f7db48f1aed83394b251a03fc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:34 -0500
Subject: [PATCH 112/115] alsa-plugins: revbump for ffmpeg-6.0

---
 srcpkgs/alsa-plugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/alsa-plugins/template b/srcpkgs/alsa-plugins/template
index a5708a7d82a8f..7bfdad046c483 100644
--- a/srcpkgs/alsa-plugins/template
+++ b/srcpkgs/alsa-plugins/template
@@ -1,7 +1,7 @@
 # Template file for 'alsa-plugins'
 pkgname=alsa-plugins
 version=1.2.7.1
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--disable-maemo-plugin"
 hostmakedepends="pkg-config"

From 421a7271c3c89a2193ad2ce78c0c1944424f9f5c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:39 -0500
Subject: [PATCH 113/115] dolphin-emu: revbump for ffmpeg-6.0

---
 srcpkgs/dolphin-emu/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/dolphin-emu/template b/srcpkgs/dolphin-emu/template
index 070993aac31d2..96edf50d3e4a1 100644
--- a/srcpkgs/dolphin-emu/template
+++ b/srcpkgs/dolphin-emu/template
@@ -1,7 +1,7 @@
 # Template file for 'dolphin-emu'
 pkgname=dolphin-emu
 version=5.0.19368
-revision=2
+revision=3
 _dolphin_commit=dadbeb4bae7e7fa23af2b46e0add4143094dc107
 _mgba_commit=44e074a15e9651481f7f652ac006a7c9d58cbeb9
 _googletest_commit=be03d00f5f0cc3a997d1a368bee8a1fe93651f48

From 3ff034eca5f86860344ee70f06ac179a88522f95 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:43 -0500
Subject: [PATCH 114/115] minidlna: revbump for ffmpeg-6.0

---
 srcpkgs/minidlna/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/minidlna/template b/srcpkgs/minidlna/template
index 5fa929f3a0c12..742991ecd04af 100644
--- a/srcpkgs/minidlna/template
+++ b/srcpkgs/minidlna/template
@@ -1,7 +1,7 @@
 # Template file for 'minidlna'
 pkgname=minidlna
 version=1.3.3
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="
  --sbindir=/usr/bin

From d6a5dfa4db47cd6a5b96ba1c3ccefa5923587b0c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:07:39 -0500
Subject: [PATCH 115/115] mpv: revbump for ffmpeg-6.0

---
 srcpkgs/mpv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpv/template b/srcpkgs/mpv/template
index 301a77ad22971..1541726adbb17 100644
--- a/srcpkgs/mpv/template
+++ b/srcpkgs/mpv/template
@@ -1,7 +1,7 @@
 # Template file for 'mpv'
 pkgname=mpv
 version=0.36.0
-revision=3
+revision=4
 build_style=meson
 configure_args="-Dcdda=enabled -Ddvbin=enabled -Ddvdnav=enabled
  -Dlibmpv=true -Dcplugins=enabled

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (37 preceding siblings ...)
  2023-11-10 20:08 ` zlice
@ 2023-11-14 13:43 ` zlice
  2023-11-20 23:00 ` zlice
                   ` (58 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2023-11-14 13:43 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 3663 bytes --]

There is an updated pull request by zlice against master on the void-packages repository

https://github.com/zlice/void-packages ffmpeg6-split
https://github.com/void-linux/void-packages/pull/43761

ffmpeg6 split
[ci skip]


#### Testing the changes

- I tested the changes in this PR: **YES**

main testing has been vaapi in Firefox Nightly and enc/dec in Shotcut on Intel A770

#### New package

- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**

#### Local build testing

- I built this PR locally for my native architecture, **x86_64**

#### Discussion

Continuation of https://github.com/void-linux/void-packages/pull/36315

`libavresample` is deprecated, but marked as a dependency when trying to build other packages and install `ffmpeg`(6). I think the right way to handle this is make a meta package and the add to removals?


##### Commit naming / misc

~~Commits are 'dirty' right now, running with [gstreamer 1.22.1 updates](https://github.com/void-linux/void-packages/pull/42861) and [Intel OpenCL](https://github.com/void-linux/void-packages/pull/43084). This will also make [intel packages pr](https://github.com/void-linux/void-packages/pull/41132) obsolete.~~ (see Requirements below)

Maintainer for previous ffmpeg(4) was orphaned, I can put my name in there if that matters, though I don't exactly see myself keeping up on ffmpeg.

This updates QT5 which looks like it is usually hosted by Johnny. Not sure if there's any reason to stay there or these sources are fine.

##### STILL FFMPEG4

These are a mix of emulators, games and/or older packages.

- attract (multiple patches in master)
- audacity (https://github.com/audacity/audacity/issues/2305 and https://sourceforge.net/p/portmedia/wiki/portsmf/ is 'beta')
- ccextractor (master patches? no release)
- vice
- kodi
- mlt (only dep left is flowblade)
- ~~synfig (mlt)~~ (work with mlt7, bump synfigstudio)
- tvheadend
- ssr
- ~~spek-alternative~~ (replace with spek-x)
- ppsspp
- olive
- moc
- mediastreamer
- libextractor
- idjc
- hedgewars
- ~~ffmpegthumbnailer~~ (patches for moviedecoder.xxx files)
- ~~ffmpegthumbs~~ (latest compiles)
- deadbeef
- omxplayer
- qtav (fork has ffmpeg 5 patch - https://github.com/cmguo/QtAV)
- `vlc` (vlc4 will support ffmpeg5, there's a patch to build 3.x with ffmpeg5 but it will lack vaapi)
- `osg` (OpenSceneGraph plus `xine-lib`)


##### HAVE NOT BUILT YET

- omxplayer (rpi only? ffmpeg4)
- kodi (big, but ffmpeg4)


##### UPDATED (for ffmpeg6)

- ~~blender: update to 3.5.1~~ ~~will be revbump with~~ https://github.com/void-linux/void-packages/pull/43992
- unpaper: update to 7.0.0.
- guvcview: update to 2.0.8.
- qt5: update to 5.15.8
- qt5-webengine: update to 5.18.13
- shiboken2: revbump for qt5.15.8 (patch)
- python3-pyside2: update to 5.15.8 (patch)
- New package: spex-x replaces spek-alternative for ffmpeg-6.0


##### Requirements

- ~~[gstreamer 1.22.2](https://github.com/void-linux/void-packages/pull/42861)~~ - a few packages use ffmpeg-devel and require a revbump

- [Intel Packages](https://github.com/void-linux/void-packages/pull/41132) - ffmpeg4 uses different libraries than 6 (libmfx / Intel-MediaSDK vs only oneVPL that Intel is moving to), both are included here

- ~~[shotcut 23.05.14](https://github.com/void-linux/void-packages/pull/44260)~~

- https://github.com/void-linux/void-packages/pull/44781 will remove from this PR

A patch file from https://github.com/void-linux/void-packages/pull/43761.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ffmpeg6-split-43761.patch --]
[-- Type: text/x-diff, Size: 788609 bytes --]

From 6d70303ccf1882aa307cddaa8bbbb9249bd10cdb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:16:56 -0400
Subject: [PATCH 001/115] ffmpeg: update to 6.0.1.

---
 common/shlibs                                 | 26 +++++---
 srcpkgs/ffmpeg/files/altivec.patch            | 60 -------------------
 .../patches/armv5tel-floating-point.patch     | 18 ------
 ...h-libavcodec-libsvtav1-ten_bit_format.diff | 40 -------------
 .../workaround-mesa-readeon-vaapi-bug.patch   | 28 ---------
 srcpkgs/ffmpeg/template                       | 38 ++++++------
 6 files changed, 37 insertions(+), 173 deletions(-)
 delete mode 100644 srcpkgs/ffmpeg/files/altivec.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 delete mode 100644 srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch

diff --git a/common/shlibs b/common/shlibs
index ede20ee14a683..a728c0eaab57f 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -385,15 +385,23 @@ libid3tag.so.0 libid3tag-0.15.1b_1
 libgif.so.7 giflib-5.1.0_1
 libImlib2.so.1 imlib2-1.4.2_1
 libmp3lame.so.0 lame-3.98.2_1
-libavdevice.so.58 libavdevice-4.0_1
-libavformat.so.58 libavformat-4.0_1
-libswscale.so.5 libswscale-4.0_1
-libswresample.so.3 libswresample-4.0_1
-libavresample.so.4 libavresample-4.0_1
-libpostproc.so.55 libpostproc-4.0_1
-libavcodec.so.58 libavcodec-4.0_1
-libavutil.so.56 libavutil-4.0_1
-libavfilter.so.7 libavfilter-4.0_1
+libavdevice.so.60 libavdevice-6.0_1
+libavformat.so.60 libavformat-6.0_1
+libswscale.so.7 libswscale-6.0_1
+libswresample.so.4 libswresample-6.0_1
+libpostproc.so.57 libpostproc-6.0_1
+libavcodec.so.60 libavcodec-6.0_1
+libavutil.so.58 libavutil-6.0_1
+libavfilter.so.9 libavfilter-6.0_1
+libavdevice.so.58 libavdevice4-4.0_1
+libavformat.so.58 libavformat4-4.0_1
+libswscale.so.5 libswscale4-4.0_1
+libswresample.so.3 libswresample4-4.0_1
+libavresample.so.4 libavresample4-4.0_1
+libpostproc.so.55 libpostproc4-4.0_1
+libavcodec.so.58 libavcodec4-4.0_1
+libavutil.so.56 libavutil4-4.0_1
+libavfilter.so.7 libavfilter4-4.0_1
 libSDL-1.2.so.0 SDL-1.2.14_1
 libSDL_image-1.2.so.0 SDL_image-1.2.10_1
 libx264.so.157 x264-20190507.2245_1
diff --git a/srcpkgs/ffmpeg/files/altivec.patch b/srcpkgs/ffmpeg/files/altivec.patch
deleted file mode 100644
index 9c57200463320..0000000000000
--- a/srcpkgs/ffmpeg/files/altivec.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-revert some altivec specific change on all ppc* except ppc64le*
-
-q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
-conditionally, for ppc* but not ppc64le* (the new code is valid for
-POWER8 VSX which LE targets as a baseline but not BE)"
-
-
-This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
----
- libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
- 1 file changed, 20 insertions(+), 4 deletions(-)
-
-diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
-index 536545293d..c1e2852adb 100644
---- a/libswscale/ppc/yuv2rgb_altivec.c
-+++ b/libswscale/ppc/yuv2rgb_altivec.c
-@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-     vector signed short R1, G1, B1;                                           \
-     vector unsigned char R, G, B;                                             \
-                                                                               \
-+    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
-+    vector unsigned char align_perm;                                          \
-+                                                                              \
-     vector signed short lCY       = c->CY;                                    \
-     vector signed short lOY       = c->OY;                                    \
-     vector signed short lCRV      = c->CRV;                                   \
-@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
-                                                                               \
-         for (j = 0; j < w / 16; j++) {                                        \
--            y0 = vec_xl(0, y1i);                                              \
-+            y1ivP = (const vector unsigned char *) y1i;                       \
-+            y2ivP = (const vector unsigned char *) y2i;                       \
-+            uivP  = (const vector unsigned char *) ui;                        \
-+            vivP  = (const vector unsigned char *) vi;                        \
-+                                                                              \
-+            align_perm = vec_lvsl(0, y1i);                                    \
-+            y0 = (vector unsigned char)                                       \
-+                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
-                                                                               \
--            y1 = vec_xl(0, y2i);                                              \
-+            align_perm = vec_lvsl(0, y2i);                                    \
-+            y1 = (vector unsigned char)                                       \
-+                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
-                                                                               \
--            u = (vector signed char) vec_xl(0, ui);                           \
-+            align_perm = vec_lvsl(0, ui);                                     \
-+            u = (vector signed char)                                          \
-+                    vec_perm(uivP[0], uivP[1], align_perm);                   \
-                                                                               \
--            v = (vector signed char) vec_xl(0, vi);                           \
-+            align_perm = vec_lvsl(0, vi);                                     \
-+            v = (vector signed char)                                          \
-+                    vec_perm(vivP[0], vivP[1], align_perm);                   \
-                                                                               \
-             u = (vector signed char)                                          \
-                     vec_sub(u,                                                \
--- 
-2.27.0
-
diff --git a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
deleted file mode 100644
index 9a55178c74f0f..0000000000000
--- a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
-+++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
-@@ -39,6 +39,15 @@
- #endif
- #include <fenv.h>
- 
-+#if (FE_ALL_EXCEPT == 0)
-+/* E.g. ARM soft float does not define these */
-+#define FE_INVALID    0
-+#define FE_DIVBYZERO  0
-+#define FE_OVERFLOW   0
-+#define FE_UNDERFLOW  0
-+#define FE_INEXACT    0
-+#endif
-+
- #if CONFIG_LIBFONTCONFIG
- #include <fontconfig/fontconfig.h>
- #endif
diff --git a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
deleted file mode 100644
index aa948f7a8a2df..0000000000000
--- a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
+++ /dev/null
@@ -1,40 +0,0 @@
-#==================================================================================================
-# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
-# From: Christopher Degawa <christopher.degawa@intel.com>
-# Date: Thu, 20 Oct 2022 22:55:27 -0500
-# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
-#
-# compressed_ten_bit_format has been deprecated upstream and has no effect
-# and can be removed. Plus, technically it was never used in the first place
-# since it would require the app (ffmpeg) to set it and do additional
-# processing of the input frames.
-#
-# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
-#
-# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
-#==================================================================================================
---- a/libavcodec/libsvtav1.c
-+++ b/libavcodec/libsvtav1.c
-@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
- 
- static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
- {
--    const int    pack_mode_10bit =
--        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
--    const size_t luma_size_8bit  =
--        config->source_width * config->source_height * (1 << pack_mode_10bit);
--    const size_t luma_size_10bit =
--        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
-+    const size_t luma_size = config->source_width * config->source_height *
-+        (config->encoder_bit_depth > 8 ? 2 : 1);
- 
-     EbSvtIOFormat *in_data;
- 
--    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
-+    svt_enc->raw_size = luma_size * 3 / 2;
- 
-     // allocate buffer for in and out
-     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
--- 
-GitLab
-
diff --git a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
deleted file mode 100644
index 00e3f68a415b8..0000000000000
--- a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
-From: Rainer Hochecker <fernetmenta@online.de>
-Date: Sat, 26 Jan 2019 19:48:35 +0100
-Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
-
-This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
-It was hit frequently when watching h264 channels received via DVB-X.
-Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
----
- libavcodec/vaapi_h264.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
-index 5854587a255..f12fdc457a4 100644
---- a/libavcodec/vaapi_h264.c
-+++ b/libavcodec/vaapi_h264.c
-@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
-     H264SliceContext *sl = &h->slice_ctx[0];
-     int ret;
- 
-+    if (pic->nb_slices == 0) {
-+        ret = AVERROR_INVALIDDATA;
-+        goto finish;
-+    }
-+
-     ret = ff_vaapi_decode_issue(avctx, pic);
-     if (ret < 0)
-         goto finish;
diff --git a/srcpkgs/ffmpeg/template b/srcpkgs/ffmpeg/template
index 5968a09b1f12d..751c24126c22d 100644
--- a/srcpkgs/ffmpeg/template
+++ b/srcpkgs/ffmpeg/template
@@ -1,15 +1,15 @@
 # Template file for 'ffmpeg'
 # audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
 pkgname=ffmpeg
-version=4.4.4
-revision=5
+version=6.0.1
+revision=1
 short_desc="Decoding, encoding and streaming software"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="https://www.ffmpeg.org"
 changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
 distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
-checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+checksum=9b16b8731d78e596b4be0d720428ca42df642bb2d78342881ff7f5bc29fc9623
 
 hostmakedepends="pkg-config perl"
 makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
@@ -26,12 +26,13 @@ makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-deve
  $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
  $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
  $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
- $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers Vulkan-Tools Vulkan-ValidationLayers')
+ $(vopt_if onevpl 'onevpl onevpl-devel')
  $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
 depends="ffplay>=${version}_${revision}"
 
 build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
- dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec onevpl"
 build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
 desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
 desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
@@ -39,9 +40,13 @@ desc_option_sofa="Enable support for AES SOFA"
 desc_option_webp="Enable support for WebP"
 
 case "$XBPS_TARGET_MACHINE" in
-	i686*|x86_64*)
-		hostmakedepends+=" nasm"
+	i686*)
 		build_options_default+=" vaapi vdpau nvenc nvdec"
+		hostmakedepends+=" nasm"
+		;;
+	x86_64*)
+		hostmakedepends+=" nasm"
+		build_options_default+=" vaapi vdpau nvenc nvdec onevpl"
 		;;
 	ppc64*) build_options_default+=" vaapi vdpau";;
 	mips*) CFLAGS="-mnan=legacy";;
@@ -115,18 +120,19 @@ do_configure() {
 		$(vopt_enable x265 libx265) \
 		$(vopt_enable v4l2 libv4l2) \
 		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
-		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		--enable-libbs2b --enable-libvidstab \
 		$(vopt_enable dav1d libdav1d) \
 		$(vopt_enable zimg libzimg) \
 		$(vopt_enable webp libwebp) \
 		$(vopt_enable sofa libmysofa) \
 		$(vopt_enable vulkan) \
+		$(vopt_enable onevpl libvpl) \
 		$(vopt_enable drm libdrm) \
 		$(vopt_enable svtav1 libsvtav1) \
 		$(vopt_enable srt libsrt) \
 		$(vopt_enable rist librist) \
-		$(vopt_if nvenc '--enable-nvenc') \
-		$(vopt_if nvdec '--enable-nvdec')
+		$(vopt_enable nvenc nvenc) \
+		$(vopt_enable nvdec nvdec)
 }
 
 do_build() {
@@ -153,10 +159,8 @@ libavdevice_package() {
 }
 
 libavresample_package() {
-	short_desc="FFmpeg audio resampling library"
-	pkg_install() {
-		vmove "usr/lib/libavresample.so.*"
-	}
+	short_desc="Package deprecated, removal needed"
+	build_style=meta
 }
 
 libavformat_package() {
@@ -210,15 +214,13 @@ ffmpeg-devel_package() {
 		libavfilter>=${version}_${revision}
 		libpostproc>=${version}_${revision}
 		libswscale>=${version}_${revision}
-		libswresample>=${version}_${revision}
-		libavresample>=${version}_${revision}"
+		libswresample>=${version}_${revision}"
 	short_desc+=" - development files"
-
+	conflicts="ffmpeg4-devel"
 	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
 		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
 		nostrip_files="/usr/lib/libavfilter.a"
 	fi
-
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig

From fea875e8a9f5ba3df54ffbdcfbaa8863761b2ddb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:14 -0400
Subject: [PATCH 002/115] openshot: revbump for ffmpeg6.0

---
 srcpkgs/openshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openshot/template b/srcpkgs/openshot/template
index 8f47851eef354..affb652a9d500 100644
--- a/srcpkgs/openshot/template
+++ b/srcpkgs/openshot/template
@@ -1,7 +1,7 @@
 # Template file for 'openshot'
 pkgname=openshot
 version=3.0.0
-revision=2
+revision=3
 build_style=python3-module
 hostmakedepends="python3 python3-setuptools"
 makedepends="ffmpeg-devel python3-PyQt5"

From 5be26c6d52c2779e161ab1e6d1c7c14818e960b5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:36 -0400
Subject: [PATCH 003/115] sumo: revbump for ffmpeg6.0

---
 srcpkgs/sumo/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/sumo/template b/srcpkgs/sumo/template
index a3fe134aa5acc..a730afa9fafa9 100644
--- a/srcpkgs/sumo/template
+++ b/srcpkgs/sumo/template
@@ -1,7 +1,7 @@
 # Template file for 'sumo'
 pkgname=sumo
 version=1.12.0
-revision=6
+revision=7
 build_style=cmake
 hostmakedepends="libgdal-tools pkg-config swig python3-setuptools"
 makedepends="python3-devel ffmpeg-devel fox-devel gl2ps-devel libgdal-devel

From 98368652c0d6c4695825cff160823ab5a588eae3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:56:22 -0400
Subject: [PATCH 004/115] New package: ffmpeg4-4.4.4.

---
 srcpkgs/ffmpeg4-devel                         |   1 +
 srcpkgs/ffmpeg4/files/altivec.patch           |  60 +++++
 .../patches/armv5tel-floating-point.patch     |  18 ++
 ...h-libavcodec-libsvtav1-ten_bit_format.diff |  40 +++
 .../workaround-mesa-readeon-vaapi-bug.patch   |  28 ++
 srcpkgs/ffmpeg4/template                      | 240 ++++++++++++++++++
 srcpkgs/libavcodec4                           |   1 +
 srcpkgs/libavdevice4                          |   1 +
 srcpkgs/libavfilter4                          |   1 +
 srcpkgs/libavformat4                          |   1 +
 srcpkgs/libavresample4                        |   1 +
 srcpkgs/libavutil4                            |   1 +
 srcpkgs/libpostproc4                          |   1 +
 srcpkgs/libswresample4                        |   1 +
 srcpkgs/libswscale4                           |   1 +
 15 files changed, 396 insertions(+)
 create mode 120000 srcpkgs/ffmpeg4-devel
 create mode 100644 srcpkgs/ffmpeg4/files/altivec.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 create mode 100644 srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
 create mode 100644 srcpkgs/ffmpeg4/template
 create mode 120000 srcpkgs/libavcodec4
 create mode 120000 srcpkgs/libavdevice4
 create mode 120000 srcpkgs/libavfilter4
 create mode 120000 srcpkgs/libavformat4
 create mode 120000 srcpkgs/libavresample4
 create mode 120000 srcpkgs/libavutil4
 create mode 120000 srcpkgs/libpostproc4
 create mode 120000 srcpkgs/libswresample4
 create mode 120000 srcpkgs/libswscale4

diff --git a/srcpkgs/ffmpeg4-devel b/srcpkgs/ffmpeg4-devel
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/ffmpeg4-devel
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/ffmpeg4/files/altivec.patch b/srcpkgs/ffmpeg4/files/altivec.patch
new file mode 100644
index 0000000000000..9c57200463320
--- /dev/null
+++ b/srcpkgs/ffmpeg4/files/altivec.patch
@@ -0,0 +1,60 @@
+revert some altivec specific change on all ppc* except ppc64le*
+
+q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
+conditionally, for ppc* but not ppc64le* (the new code is valid for
+POWER8 VSX which LE targets as a baseline but not BE)"
+
+
+This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
+---
+ libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
+ 1 file changed, 20 insertions(+), 4 deletions(-)
+
+diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
+index 536545293d..c1e2852adb 100644
+--- a/libswscale/ppc/yuv2rgb_altivec.c
++++ b/libswscale/ppc/yuv2rgb_altivec.c
+@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+     vector signed short R1, G1, B1;                                           \
+     vector unsigned char R, G, B;                                             \
+                                                                               \
++    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
++    vector unsigned char align_perm;                                          \
++                                                                              \
+     vector signed short lCY       = c->CY;                                    \
+     vector signed short lOY       = c->OY;                                    \
+     vector signed short lCRV      = c->CRV;                                   \
+@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
+                                                                               \
+         for (j = 0; j < w / 16; j++) {                                        \
+-            y0 = vec_xl(0, y1i);                                              \
++            y1ivP = (const vector unsigned char *) y1i;                       \
++            y2ivP = (const vector unsigned char *) y2i;                       \
++            uivP  = (const vector unsigned char *) ui;                        \
++            vivP  = (const vector unsigned char *) vi;                        \
++                                                                              \
++            align_perm = vec_lvsl(0, y1i);                                    \
++            y0 = (vector unsigned char)                                       \
++                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
+                                                                               \
+-            y1 = vec_xl(0, y2i);                                              \
++            align_perm = vec_lvsl(0, y2i);                                    \
++            y1 = (vector unsigned char)                                       \
++                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
+                                                                               \
+-            u = (vector signed char) vec_xl(0, ui);                           \
++            align_perm = vec_lvsl(0, ui);                                     \
++            u = (vector signed char)                                          \
++                    vec_perm(uivP[0], uivP[1], align_perm);                   \
+                                                                               \
+-            v = (vector signed char) vec_xl(0, vi);                           \
++            align_perm = vec_lvsl(0, vi);                                     \
++            v = (vector signed char)                                          \
++                    vec_perm(vivP[0], vivP[1], align_perm);                   \
+                                                                               \
+             u = (vector signed char)                                          \
+                     vec_sub(u,                                                \
+-- 
+2.27.0
+
diff --git a/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
new file mode 100644
index 0000000000000..9a55178c74f0f
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
@@ -0,0 +1,18 @@
+--- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
++++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
+@@ -39,6 +39,15 @@
+ #endif
+ #include <fenv.h>
+ 
++#if (FE_ALL_EXCEPT == 0)
++/* E.g. ARM soft float does not define these */
++#define FE_INVALID    0
++#define FE_DIVBYZERO  0
++#define FE_OVERFLOW   0
++#define FE_UNDERFLOW  0
++#define FE_INEXACT    0
++#endif
++
+ #if CONFIG_LIBFONTCONFIG
+ #include <fontconfig/fontconfig.h>
+ #endif
diff --git a/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
new file mode 100644
index 0000000000000..aa948f7a8a2df
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
@@ -0,0 +1,40 @@
+#==================================================================================================
+# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
+# From: Christopher Degawa <christopher.degawa@intel.com>
+# Date: Thu, 20 Oct 2022 22:55:27 -0500
+# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
+#
+# compressed_ten_bit_format has been deprecated upstream and has no effect
+# and can be removed. Plus, technically it was never used in the first place
+# since it would require the app (ffmpeg) to set it and do additional
+# processing of the input frames.
+#
+# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
+#
+# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
+#==================================================================================================
+--- a/libavcodec/libsvtav1.c
++++ b/libavcodec/libsvtav1.c
+@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
+ 
+ static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
+ {
+-    const int    pack_mode_10bit =
+-        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
+-    const size_t luma_size_8bit  =
+-        config->source_width * config->source_height * (1 << pack_mode_10bit);
+-    const size_t luma_size_10bit =
+-        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
++    const size_t luma_size = config->source_width * config->source_height *
++        (config->encoder_bit_depth > 8 ? 2 : 1);
+ 
+     EbSvtIOFormat *in_data;
+ 
+-    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
++    svt_enc->raw_size = luma_size * 3 / 2;
+ 
+     // allocate buffer for in and out
+     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
+-- 
+GitLab
+
diff --git a/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
new file mode 100644
index 0000000000000..00e3f68a415b8
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
@@ -0,0 +1,28 @@
+From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
+From: Rainer Hochecker <fernetmenta@online.de>
+Date: Sat, 26 Jan 2019 19:48:35 +0100
+Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
+
+This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
+It was hit frequently when watching h264 channels received via DVB-X.
+Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
+---
+ libavcodec/vaapi_h264.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
+index 5854587a255..f12fdc457a4 100644
+--- a/libavcodec/vaapi_h264.c
++++ b/libavcodec/vaapi_h264.c
+@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
+     H264SliceContext *sl = &h->slice_ctx[0];
+     int ret;
+ 
++    if (pic->nb_slices == 0) {
++        ret = AVERROR_INVALIDDATA;
++        goto finish;
++    }
++
+     ret = ff_vaapi_decode_issue(avctx, pic);
+     if (ret < 0)
+         goto finish;
diff --git a/srcpkgs/ffmpeg4/template b/srcpkgs/ffmpeg4/template
new file mode 100644
index 0000000000000..f2c851693d367
--- /dev/null
+++ b/srcpkgs/ffmpeg4/template
@@ -0,0 +1,240 @@
+# Template file for 'ffmpeg4'
+# audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
+pkgname=ffmpeg4
+version=4.4.4
+revision=1
+short_desc="Decoding, encoding and streaming software - ffmpeg4 libraries only"
+maintainer="Orphaned <orphan@voidlinux.org>"
+license="GPL-3.0-or-later"
+homepage="https://www.ffmpeg.org"
+changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
+distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
+checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+
+hostmakedepends="pkg-config perl"
+makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
+ libXext-devel libXvMC-devel libxcb-devel lame-devel libtheora-devel
+ libvorbis-devel x264-devel xvidcore-devel jack-devel SDL2-devel
+ libcdio-paranoia-devel librtmp-devel libmodplug-devel gnutls-devel
+ speex-devel celt-devel harfbuzz-devel libass-devel opus-devel ocl-icd-devel
+ libbs2b-devel libvidstab-devel vmaf-devel $(vopt_if pulseaudio pulseaudio-devel)
+ $(vopt_if vaapi libva-devel) $(vopt_if vdpau libvdpau-devel)
+ $(vopt_if x265 x265-devel) $(vopt_if v4l2 v4l-utils-devel)
+ $(vopt_if fdk_aac fdk-aac-devel) $(vopt_if vpx libvpx-devel)
+ $(vopt_if aom libaom-devel) $(vopt_if sndio sndio-devel)
+ $(vopt_if dav1d libdav1d-devel) $(vopt_if zimg zimg-devel)
+ $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
+ $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
+ $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if mfx 'libmfx libmfx-devel')
+ $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
+
+build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec mfx"
+build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
+
+desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
+desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
+desc_option_sofa="Enable support for AES SOFA"
+desc_option_webp="Enable support for WebP"
+
+case "$XBPS_TARGET_MACHINE" in
+	i686*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau nvenc nvdec"
+			;;
+	x86_64*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau mfx nvenc nvdec"
+			;;
+	ppc64*) build_options_default+=" vaapi vdpau";;
+	mips*) CFLAGS="-mnan=legacy";;
+esac
+
+if [ "$XBPS_TARGET_WORDSIZE" != "32" ]; then
+	build_options_default+=" svtav1"
+fi
+
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+fi
+
+_apply_patch() {
+	local args="$1" pname="$(basename $2)"
+
+	if [ ! -f ".${pname}_done" ]; then
+		patch -N $args -i $2
+		touch .${pname}_done
+	fi
+}
+
+post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64le*) ;;
+		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
+	esac
+
+	vsed -i libavfilter/vf_libvmaf.c -e 's!/usr/local/share/model/\(vmaf_v0.6.1\).pkl!/usr/share/vmaf/\1.json!'
+}
+
+do_configure() {
+	# Fix gcc on x86_64-musl only
+	if [ "$XBPS_TARGET_MACHINE" = "x86_64-musl" ]; then
+		vsed -i configure -e "s;_cflags_speed='-O3';_cflags_speed='-O2';"
+	fi
+
+	if [ "$CROSS_BUILD" ]; then
+		case "$XBPS_TARGET_MACHINE" in
+			arm*) _arch="arm";;
+			aarch64*) _arch="aarch64";;
+			mips*) _arch="mips";;
+			ppc64*) _arch="ppc64";;
+			ppc*) _arch="ppc";;
+			*) _arch="${XBPS_TARGET_MACHINE%%-musl}";;
+		esac
+
+		_args+=" --enable-cross-compile
+			--sysroot=$XBPS_CROSS_BASE
+			--cross-prefix=${XBPS_CROSS_TRIPLET}-
+			--target-os=linux --arch=${_arch}"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc|ppc-musl) _args+=" --disable-altivec";;
+	esac
+
+	if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+		_args+=" --extra-libs=-latomic"
+	fi
+
+	./configure --prefix=/usr --disable-debug --enable-gpl --enable-gnutls \
+		--disable-stripping \
+		--enable-libcdio --enable-version3 --enable-runtime-cpudetect \
+		--enable-libmp3lame --enable-libvorbis --enable-libxvid \
+		--enable-libx264 $(vopt_enable vpx libvpx) --enable-libtheora \
+		--enable-shared --enable-static --enable-libxcb \
+		$(vopt_enable pulseaudio libpulse) --enable-libfreetype --enable-libmodplug \
+		--enable-libspeex --enable-libcelt --enable-libass \
+		--enable-libopus --enable-librtmp --enable-libjack \
+		$(vopt_if fdk_aac '--enable-nonfree --enable-libfdk-aac') \
+		--disable-libopencore_amrnb --disable-libopencore_amrwb \
+		--disable-libopenjpeg \
+		--enable-postproc --enable-opencl ${_args} --enable-libvmaf ${_args} \
+		$(vopt_enable x265 libx265) \
+		$(vopt_enable v4l2 libv4l2) \
+		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
+		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		$(vopt_enable dav1d libdav1d) \
+		$(vopt_enable zimg libzimg) \
+		$(vopt_enable webp libwebp) \
+		$(vopt_enable sofa libmysofa) \
+		$(vopt_enable vulkan) \
+		$(vopt_enable drm libdrm) \
+		$(vopt_enable svtav1 libsvtav1) \
+		$(vopt_enable srt libsrt) \
+		$(vopt_enable rist librist) \
+		$(vopt_enable mfx libmfx) \
+		$(vopt_if nvenc '--enable-nvenc') \
+		$(vopt_if nvdec '--enable-nvdec')
+}
+
+do_build() {
+	make ${makejobs}
+	make doc/ff{mpeg,play}.1
+}
+
+do_install() {
+	make DESTDIR=${DESTDIR} install install-man
+	rm -rf ${DESTDIR}/usr/bin
+}
+
+libavcodec4_package() {
+	short_desc="FFmpeg codec library"
+	pkg_install() {
+		vmove "usr/lib/libavcodec.so.*"
+	}
+}
+
+libavdevice4_package() {
+	short_desc="FFmpeg device handling library"
+	pkg_install() {
+		vmove "usr/lib/libavdevice.so.*"
+	}
+}
+
+libavresample4_package() {
+	short_desc="FFmpeg audio resampling library"
+	pkg_install() {
+		vmove "usr/lib/libavresample.so.*"
+	}
+}
+
+libavformat4_package() {
+	short_desc="FFmpeg file format library"
+	pkg_install() {
+		vmove "usr/lib/libavformat.so.*"
+	}
+}
+
+libavutil4_package() {
+	short_desc="FFmpeg utility library"
+	pkg_install() {
+		vmove "usr/lib/libavutil.so.*"
+	}
+}
+
+libavfilter4_package() {
+	short_desc="FFmpeg audio/video filter library"
+	pkg_install() {
+		vmove "usr/lib/libavfilter.so.*"
+	}
+}
+
+libpostproc4_package() {
+	short_desc="FFmpeg video postprocessing library"
+	pkg_install() {
+		vmove "usr/lib/libpostproc.so.*"
+	}
+}
+
+libswscale4_package() {
+	short_desc="FFmpeg video scaling library"
+	pkg_install() {
+		vmove "usr/lib/libswscale.so.*"
+	}
+}
+
+libswresample4_package() {
+	short_desc="FFmpeg video resampling library"
+	pkg_install() {
+		vmove "usr/lib/libswresample.so.*"
+	}
+}
+
+ffmpeg4-devel_package() {
+	depends="
+		libavcodec4>=${version}_${revision}
+		libavdevice4>=${version}_${revision}
+		libavformat4>=${version}_${revision}
+		libavutil4>=${version}_${revision}
+		libavfilter4>=${version}_${revision}
+		libpostproc4>=${version}_${revision}
+		libswscale4>=${version}_${revision}
+		libswresample4>=${version}_${revision}
+		libavresample4>=${version}_${revision}"
+	short_desc+=" - development files"
+	conflicts="ffmpeg-devel"
+	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
+		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
+		nostrip_files="/usr/lib/libavfilter.a"
+	fi
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.a"
+		vmove "usr/lib/*.so"
+		vmove usr/share/ffmpeg/examples
+		vmove usr/share/man/man3
+	}
+}
diff --git a/srcpkgs/libavcodec4 b/srcpkgs/libavcodec4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavcodec4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavdevice4 b/srcpkgs/libavdevice4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavdevice4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavfilter4 b/srcpkgs/libavfilter4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavfilter4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavformat4 b/srcpkgs/libavformat4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavformat4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavresample4 b/srcpkgs/libavresample4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavutil4 b/srcpkgs/libavutil4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavutil4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libpostproc4 b/srcpkgs/libpostproc4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libpostproc4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswresample4 b/srcpkgs/libswresample4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libswresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswscale4 b/srcpkgs/libswscale4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libswscale4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file

From 1a16d6178549284aa1dc5892a4ec688d15457123 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:04 -0400
Subject: [PATCH 005/115] opencv: update to 4.7.0.

---
 common/shlibs           | 104 ++++++++++++++++++++--------------------
 srcpkgs/opencv/template |   8 ++--
 2 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index a728c0eaab57f..5745ff0ca7b84 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2085,58 +2085,58 @@ libcapstone.so.5 capstone-5.0.1_1
 libhavege.so.2 libhaveged-1.9.11_1
 libnih.so.1 libnih-1.0.3_1
 libnih-dbus.so.1 libnih-1.0.3_1
-libopencv_quality.so.406 libopencv-4.6.0_1
-libopencv_reg.so.406 libopencv-4.6.0_1
-libopencv_surface_matching.so.406 libopencv-4.6.0_1
-libopencv_xphoto.so.406 libopencv-4.6.0_1
-libopencv_freetype.so.406 libopencv-4.6.0_1
-libopencv_fuzzy.so.406 libopencv-4.6.0_1
-libopencv_hfs.so.406 libopencv-4.6.0_1
-libopencv_img_hash.so.406 libopencv-4.6.0_1
-libopencv_line_descriptor.so.406 libopencv-4.6.0_1
-libopencv_saliency.so.406 libopencv-4.6.0_1
-libopencv_structured_light.so.406 libopencv-4.6.0_1
-libopencv_aruco.so.406 libopencv-4.6.0_1
-libopencv_bgsegm.so.406 libopencv-4.6.0_1
-libopencv_bioinspired.so.406 libopencv-4.6.0_1
-libopencv_ccalib.so.406 libopencv-4.6.0_1
-libopencv_face.so.406 libopencv-4.6.0_1
-libopencv_tracking.so.406 libopencv-4.6.0_1
-libopencv_xfeatures2d.so.406 libopencv-4.6.0_1
-libopencv_optflow.so.406 libopencv-4.6.0_1
-libopencv_ximgproc.so.406 libopencv-4.6.0_1
-libopencv_plot.so.406 libopencv-4.6.0_1
-libopencv_text.so.406 libopencv-4.6.0_1
-libopencv_ml.so.406 libopencv-4.6.0_1
-libopencv_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn.so.406 libopencv-4.6.0_1
-libopencv_shape.so.406 libopencv-4.6.0_1
-libopencv_stitching.so.406 libopencv-4.6.0_1
-libopencv_photo.so.406 libopencv-4.6.0_1
-libopencv_video.so.406 libopencv-4.6.0_1
-libopencv_calib3d.so.406 libopencv-4.6.0_1
-libopencv_features2d.so.406 libopencv-4.6.0_1
-libopencv_flann.so.406 libopencv-4.6.0_1
-libopencv_highgui.so.406 libopencv-4.6.0_1
-libopencv_videoio.so.406 libopencv-4.6.0_1
-libopencv_imgcodecs.so.406 libopencv-4.6.0_1
-libopencv_imgproc.so.406 libopencv-4.6.0_1
-libopencv_core.so.406 libopencv-4.6.0_1
-libopencv_superres.so.406 libopencv-4.6.0_1
-libopencv_videostab.so.406 libopencv-4.6.0_1
-libopencv_gapi.so.406 libopencv-4.6.0_1
-libopencv_xobjdetect.so.406 libopencv-4.6.0_1
-libopencv_datasets.so.406 libopencv-4.6.0_1
-libopencv_dnn_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn_superres.so.406 libopencv-4.6.0_1
-libopencv_dpm.so.406 libopencv-4.6.0_1
-libopencv_phase_unwrapping.so.406 libopencv-4.6.0_1
-libopencv_stereo.so.406 libopencv-4.6.0_1
-libopencv_rapid.so.406 libopencv-4.6.0_1
-libopencv_intensity_transform.so.406 libopencv-4.6.0_1
-libopencv_alphamat.so.406 libopencv-4.6.0_1
-libopencv_barcode.so.406 libopencv-4.6.0_1
-libopencv_mcc.so.406 libopencv-4.6.0_1
+libopencv_quality.so.407 libopencv-4.7.0_1
+libopencv_reg.so.407 libopencv-4.7.0_1
+libopencv_surface_matching.so.407 libopencv-4.7.0_1
+libopencv_xphoto.so.407 libopencv-4.7.0_1
+libopencv_freetype.so.407 libopencv-4.7.0_1
+libopencv_fuzzy.so.407 libopencv-4.7.0_1
+libopencv_hfs.so.407 libopencv-4.7.0_1
+libopencv_img_hash.so.407 libopencv-4.7.0_1
+libopencv_line_descriptor.so.407 libopencv-4.7.0_1
+libopencv_saliency.so.407 libopencv-4.7.0_1
+libopencv_structured_light.so.407 libopencv-4.7.0_1
+libopencv_aruco.so.407 libopencv-4.7.0_1
+libopencv_bgsegm.so.407 libopencv-4.7.0_1
+libopencv_bioinspired.so.407 libopencv-4.7.0_1
+libopencv_ccalib.so.407 libopencv-4.7.0_1
+libopencv_face.so.407 libopencv-4.7.0_1
+libopencv_tracking.so.407 libopencv-4.7.0_1
+libopencv_xfeatures2d.so.407 libopencv-4.7.0_1
+libopencv_optflow.so.407 libopencv-4.7.0_1
+libopencv_ximgproc.so.407 libopencv-4.7.0_1
+libopencv_plot.so.407 libopencv-4.7.0_1
+libopencv_text.so.407 libopencv-4.7.0_1
+libopencv_ml.so.407 libopencv-4.7.0_1
+libopencv_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn.so.407 libopencv-4.7.0_1
+libopencv_shape.so.407 libopencv-4.7.0_1
+libopencv_stitching.so.407 libopencv-4.7.0_1
+libopencv_photo.so.407 libopencv-4.7.0_1
+libopencv_video.so.407 libopencv-4.7.0_1
+libopencv_calib3d.so.407 libopencv-4.7.0_1
+libopencv_features2d.so.407 libopencv-4.7.0_1
+libopencv_flann.so.407 libopencv-4.7.0_1
+libopencv_highgui.so.407 libopencv-4.7.0_1
+libopencv_videoio.so.407 libopencv-4.7.0_1
+libopencv_imgcodecs.so.407 libopencv-4.7.0_1
+libopencv_imgproc.so.407 libopencv-4.7.0_1
+libopencv_core.so.407 libopencv-4.7.0_1
+libopencv_superres.so.407 libopencv-4.7.0_1
+libopencv_videostab.so.407 libopencv-4.7.0_1
+libopencv_gapi.so.407 libopencv-4.7.0_1
+libopencv_xobjdetect.so.407 libopencv-4.7.0_1
+libopencv_datasets.so.407 libopencv-4.7.0_1
+libopencv_dnn_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn_superres.so.407 libopencv-4.7.0_1
+libopencv_dpm.so.407 libopencv-4.7.0_1
+libopencv_phase_unwrapping.so.407 libopencv-4.7.0_1
+libopencv_stereo.so.407 libopencv-4.7.0_1
+libopencv_rapid.so.407 libopencv-4.7.0_1
+libopencv_intensity_transform.so.407 libopencv-4.7.0_1
+libopencv_alphamat.so.407 libopencv-4.7.0_1
+libopencv_barcode.so.407 libopencv-4.7.0_1
+libopencv_mcc.so.407 libopencv-4.7.0_1
 libuniconf.so.4.6 wvstreams-4.6.1_20
 libwvbase.so.4.6 wvstreams-4.6.1_20
 libwvutils.so.4.6 wvstreams-4.6.1_20
diff --git a/srcpkgs/opencv/template b/srcpkgs/opencv/template
index aea4bfc3a265c..ce94de9424d18 100644
--- a/srcpkgs/opencv/template
+++ b/srcpkgs/opencv/template
@@ -1,7 +1,7 @@
 # Template file for 'opencv'
 pkgname=opencv
-version=4.6.0
-revision=6
+version=4.7.0
+revision=1
 create_wrksrc=yes
 build_wrksrc=${pkgname}-${version}
 build_style=cmake
@@ -24,8 +24,8 @@ homepage="https://opencv.org"
 changelog="https://github.com/opencv/opencv/wiki/ChangeLog"
 distfiles="https://github.com/opencv/opencv/archive/${version}.tar.gz
  https://github.com/opencv/opencv_contrib/archive/${version}.tar.gz>contrib.tar.gz"
-checksum="1ec1cba65f9f20fe5a41fda1586e01c70ea0c9a6d7b67c9e13edf0cfe2239277
- 1777d5fd2b59029cf537e5fd6f8aa68d707075822f90bde683fcde086f85f7a7"
+checksum="8df0079cdbe179748a18d44731af62a245a45ebf5085223dc03133954c662973
+ 42df840cf9055e59d0e22c249cfb19f04743e1bdad113d31b1573d3934d62584"
 patch_args="-Np1 -d ${build_wrksrc}"
 # tests hang indenfinitely, even with test data included
 make_check=no

From 1314592fbf949d2d32889e9eba2ca695a81fbd6a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 006/115] actiona: revbump for opencv-4.7.0

---
 srcpkgs/actiona/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/actiona/template b/srcpkgs/actiona/template
index cf5f0b7a2ae61..0d899311e6df7 100644
--- a/srcpkgs/actiona/template
+++ b/srcpkgs/actiona/template
@@ -1,7 +1,7 @@
 # Template file for 'actiona'
 pkgname=actiona
 version=3.10.1
-revision=2
+revision=3
 build_style=qmake
 configure_args="PKGCONFIG_OPENCV=opencv4"
 hostmakedepends="pkg-config qt5-plugin-mysql qt5-qmake qt5-host-tools"

From 4e2c81fbccdef360d87f8305ec405f7ead56273b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 007/115] qimgv: revbump for opencv-4.7.0

---
 srcpkgs/qimgv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qimgv/template b/srcpkgs/qimgv/template
index 7eb30db33992c..dd341dfe1bfce 100644
--- a/srcpkgs/qimgv/template
+++ b/srcpkgs/qimgv/template
@@ -1,7 +1,7 @@
 # Template file for 'qimgv'
 pkgname=qimgv
 version=1.0.2
-revision=2
+revision=3
 build_style=cmake
 configure_args="$(vopt_if video -DVIDEO_SUPPORT=ON -DVIDEO_SUPPORT=OFF)
  $(vopt_if scale -DOPENCV_SUPPORT=ON -DOPENCV_SUPPORT=OFF)

From cb9b3c69dccda41362ae583c3c62103d5a1dd433 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 008/115] retroshare: revbump for opencv-4.7.0

---
 srcpkgs/retroshare/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroshare/template b/srcpkgs/retroshare/template
index bb17569277a7f..49e2c1cbe8a53 100644
--- a/srcpkgs/retroshare/template
+++ b/srcpkgs/retroshare/template
@@ -1,7 +1,7 @@
 # Template file for 'retroshare'
 pkgname=retroshare
 version=0.6.6
-revision=3
+revision=4
 build_style=qmake
 #XXX broadcast feature requires an ancient udp-discovery-cpp which either needs
 # to be fetched+patched (FTBFS) here or packaged :/

From c80bfd278b3c8a05726548bba6cda0d81562c76d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 009/115] waifu2x-converter-cpp: revbump for opencv-4.7.0

---
 srcpkgs/waifu2x-converter-cpp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waifu2x-converter-cpp/template b/srcpkgs/waifu2x-converter-cpp/template
index 361b8a23b9497..c5ac17eb54ea4 100644
--- a/srcpkgs/waifu2x-converter-cpp/template
+++ b/srcpkgs/waifu2x-converter-cpp/template
@@ -1,7 +1,7 @@
 # Template file for 'waifu2x-converter-cpp'
 pkgname=waifu2x-converter-cpp
 version=5.2.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DINSTALL_MODELS=ON"
 hostmakedepends="pkg-config"

From aeae85204e505720d3edfee7c402ee147923a5c4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:38 -0400
Subject: [PATCH 010/115] vlc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/vlc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vlc/template b/srcpkgs/vlc/template
index c6e7275b514c4..681f2c3bc0827 100644
--- a/srcpkgs/vlc/template
+++ b/srcpkgs/vlc/template
@@ -25,7 +25,7 @@ lib32disabled=yes
 hostmakedepends="automake libtool pkg-config flex gettext libgcrypt-devel
  live555-devel gettext-devel $(vopt_if lua lua52) $(vopt_if chromecast protobuf)"
 makedepends="
- avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg-devel freefont-ttf
+ avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg4-devel freefont-ttf
  gnutls-devel jack-devel liba52-devel libass-devel libbluray-devel
  libcdio-devel libdca-devel libdvbpsi-devel libdvdnav-devel libmad-devel
  libmatroska-devel libmodplug-devel libmpcdec-devel libmpeg2-devel

From d980e39ca8c839dd2a218197c865745088b9cadb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:55 -0400
Subject: [PATCH 011/115] osg: revbump for ffmpeg4-4.4.3

---
 srcpkgs/osg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/osg/template b/srcpkgs/osg/template
index a9ebbd287933b..755793f7e11bf 100644
--- a/srcpkgs/osg/template
+++ b/srcpkgs/osg/template
@@ -8,7 +8,7 @@ build_helper="qemu"
 configure_args="-DLIB_POSTFIX="
 hostmakedepends="pkg-config xrandr"
 makedepends="MesaLib-devel gtkglext-devel libcurl-devel giflib-devel librsvg-devel
- jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg-devel xine-lib-devel
+ jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg4-devel xine-lib-devel
  SDL2-devel gst-plugins-base1-devel
  $(vopt_if openexr libopenexr-devel)
  $(vopt_if poppler poppler-glib-devel)

From f395f0eff83764a9fd87acaa6d0f9a774913870b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:13 -0400
Subject: [PATCH 012/115] xine-lib: revbump for ffmpeg4-4.4.3

---
 srcpkgs/xine-lib/template | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/xine-lib/template b/srcpkgs/xine-lib/template
index 3be4d08eac77a..ed6194c17d11e 100644
--- a/srcpkgs/xine-lib/template
+++ b/srcpkgs/xine-lib/template
@@ -1,14 +1,14 @@
 # Template file for 'xine-lib'
 pkgname=xine-lib
-version=1.2.12
-revision=3
+version=1.2.13
+revision=1
 build_style=gnu-configure
 configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
  --disable-oss"
 hostmakedepends="automake gettext-devel libtool pkg-config perl"
 makedepends="
  zlib-devel alsa-lib-devel libxcb-devel libSM-devel libXext-devel libXv-devel
- libXvMC-devel liba52-devel libmad-devel ffmpeg-devel pulseaudio-devel
+ libXvMC-devel liba52-devel libmad-devel ffmpeg4-devel pulseaudio-devel
  jack-devel samba-devel libflac-devel libmodplug-devel libmpcdec-devel
  speex-devel libtheora-devel libvorbis-devel libdca-devel faad2-devel
  libcdio-devel libbluray-devel aalib-devel libcaca-devel libXinerama-devel
@@ -19,7 +19,7 @@ license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="http://www.xine-project.org"
 changelog="https://sourceforge.net/projects/xine/files/xine-lib/${version}/README.txt/view"
 distfiles="${SOURCEFORGE_SITE}/xine/${pkgname}-${version}.tar.xz"
-checksum=d606270468e1540c2a89c0d7f5fdf11e17ecc0c2698cc0bcb1065ff26abee098
+checksum=5f10d6d718a4a51c17ed1b32b031d4f9b80b061e8276535b2be31e5ac4b75e6f
 
 case "$XBPS_TARGET_MACHINE" in
 	i686-musl)

From 752182839bb301e072edaed81d1ab85cab3fa904 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 013/115] arcan: revbump for ffmpeg-6.0

---
 srcpkgs/arcan/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/arcan/template b/srcpkgs/arcan/template
index efd0afe10576d..b91e6900d42a1 100644
--- a/srcpkgs/arcan/template
+++ b/srcpkgs/arcan/template
@@ -2,7 +2,7 @@
 # !! keep synced with: acfgfs aclip aloadimage
 pkgname=arcan
 version=0.6.2.1
-revision=1
+revision=2
 create_wrksrc=yes
 build_wrksrc=arcan/src
 build_style=cmake

From 7bb0435e8452065c54624321b254fddfaa5f2d23 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 014/115] attract: revbump for ffmpeg4-4.4.3

---
 srcpkgs/attract/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/attract/template b/srcpkgs/attract/template
index 26144e931a3c7..e760bf0d18aec 100644
--- a/srcpkgs/attract/template
+++ b/srcpkgs/attract/template
@@ -1,12 +1,12 @@
 # Template file for 'attract'
 pkgname=attract
 version=2.6.2
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="VERBOSE=1"
 make_use_env=yes
 hostmakedepends="pkg-config"
-makedepends="SFML-devel ffmpeg-devel fontconfig-devel glu-devel libarchive-devel
+makedepends="SFML-devel ffmpeg4-devel fontconfig-devel glu-devel libarchive-devel
  libcurl-devel libjpeg-turbo-devel xine-lib rapidjson libXrandr-devel"
 depends="git"
 short_desc="Attract-Mode is a graphical frontend for emulators"

From 1d453cb7a2f744cf786322cf114de71befe14603 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 015/115] aubio: revbump for ffmpeg-6.0

---
 srcpkgs/aubio/patches/ffmpeg5.patch | 25 +++++++++++++++++++++++++
 srcpkgs/aubio/template              |  2 +-
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/aubio/patches/ffmpeg5.patch

diff --git a/srcpkgs/aubio/patches/ffmpeg5.patch b/srcpkgs/aubio/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..aace41a6e6d9a
--- /dev/null
+++ b/srcpkgs/aubio/patches/ffmpeg5.patch
@@ -0,0 +1,25 @@
+From 8a05420e5dd8c7b8b2447f82dc919765876511b3 Mon Sep 17 00:00:00 2001
+From: Paul Brossier <piem@piem.org>
+Date: Tue, 25 Jan 2022 18:30:27 +0100
+Subject: [PATCH] [source_avcodec] define FF_API_LAVF_AVCTX for libavcodec >
+ 59, thx @berolinux (closes gh-353)
+
+---
+ src/io/source_avcodec.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/io/source_avcodec.c b/src/io/source_avcodec.c
+index e0ae93b5..1421bd9a 100644
+--- a/src/io/source_avcodec.c
++++ b/src/io/source_avcodec.c
+@@ -68,6 +68,10 @@
+ #define AUBIO_AVCODEC_MAX_BUFFER_SIZE AV_INPUT_BUFFER_MIN_SIZE
+ #endif
+ 
++#if LIBAVCODEC_VERSION_MAJOR >= 59
++#define FF_API_LAVF_AVCTX 1
++#endif
++
+ struct _aubio_source_avcodec_t {
+   uint_t hop_size;
+   uint_t samplerate;
diff --git a/srcpkgs/aubio/template b/srcpkgs/aubio/template
index ad1c4b2569917..7d875cc02541a 100644
--- a/srcpkgs/aubio/template
+++ b/srcpkgs/aubio/template
@@ -1,7 +1,7 @@
 # Template file for 'aubio'
 pkgname=aubio
 version=0.4.9
-revision=1
+revision=2
 build_style=waf3
 # XXX lash, pure and swig support.
 hostmakedepends="pkg-config txt2man"

From 18990c837e760ceb4851f718f7dc30182e265234 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 016/115] audacious-plugins: revbump for ffmpeg-6.0

---
 .../audacious-plugins/patches/ffmpeg5.patch   | 43 +++++++++++++++++++
 srcpkgs/audacious-plugins/template            |  2 +-
 2 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/audacious-plugins/patches/ffmpeg5.patch

diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg5.patch b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..4e5e34099d71c
--- /dev/null
+++ b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
@@ -0,0 +1,43 @@
+commit 298aa371c56c2f52c25a33d9bdec4918b11cebdc
+Author: tibequadorian <tibequadorian@posteo.de>
+Date:   Sat Mar 19 18:40:12 2022 +0100
+
+    audacious-plugins: rebuild against ffmpeg-5.0
+
+diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+new file mode 100644
+index 0000000000..617c11215b
+--- /dev/null
++++ b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+@@ -0,0 +1,31 @@
++From f60beb400eeb1e4778bbfd738bc4a4ccef3de539 Mon Sep 17 00:00:00 2001
++From: John Lindgren <john@jlindgren.net>
++Date: Sat, 5 Mar 2022 12:05:34 -0500
++Subject: [PATCH] Fix build with FFmpeg 5.0
++
++---
++ src/ffaudio/ffaudio-core.cc | 4 ++--
++ 1 file changed, 2 insertions(+), 2 deletions(-)
++
++diff --git a/src/ffaudio/ffaudio-core.cc b/src/ffaudio/ffaudio-core.cc
++index 16dc63e3a..a2b95fd6c 100644
++--- a/src/ffaudio/ffaudio-core.cc
+++++ b/src/ffaudio/ffaudio-core.cc
++@@ -274,7 +274,7 @@ static AVInputFormat * get_format_by_content (const char * name, VFSFile & file)
++         AVProbeData d = {name, buf, filled};
++         score = target;
++ 
++-        f = av_probe_input_format2 (& d, true, & score);
+++        f = (AVInputFormat *) av_probe_input_format2 (& d, true, & score);
++         if (f)
++             break;
++ 
++@@ -347,7 +347,7 @@ static bool find_codec (AVFormatContext * c, CodecInfo * cinfo)
++ #endif
++         if (stream && stream->codecpar && stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
++         {
++-            AVCodec * codec = avcodec_find_decoder (stream->codecpar->codec_id);
+++            AVCodec * codec = (AVCodec *) avcodec_find_decoder (stream->codecpar->codec_id);
++ 
++             if (codec)
++             {
diff --git a/srcpkgs/audacious-plugins/template b/srcpkgs/audacious-plugins/template
index 05e53a9adf78f..4b1968e03de78 100644
--- a/srcpkgs/audacious-plugins/template
+++ b/srcpkgs/audacious-plugins/template
@@ -2,7 +2,7 @@
 #Keep in sync with audacious!
 pkgname=audacious-plugins
 version=4.3.1
-revision=3
+revision=4
 build_style=meson
 configure_args="$(vopt_bool gtk3 gtk) $(vopt_bool gtk3)
  $(vopt_bool qt) $(vopt_bool qt qt6)"

From f896c9ad5d0e68714003e6280fcde093f86d2ad3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 017/115] audacity: revbump for ffmpeg4-4.4.3

---
 srcpkgs/audacity/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/audacity/template b/srcpkgs/audacity/template
index 7a8e79ea530cd..464c8144a3d45 100644
--- a/srcpkgs/audacity/template
+++ b/srcpkgs/audacity/template
@@ -1,7 +1,7 @@
 # Template file for 'audacity'
 pkgname=audacity
 version=3.3.3
-revision=2
+revision=3
 build_style=cmake
 build_helper="cmake-wxWidgets-gtk3 qemu"
 configure_args="-Daudacity_use_ffmpeg=loaded -Daudacity_lib_preference=system
@@ -10,7 +10,7 @@ configure_args="-Daudacity_use_ffmpeg=loaded -Daudacity_lib_preference=system
  -Daudacity_has_vst3=no"
 hostmakedepends="pkg-config gettext python3"
 makedepends="wxWidgets-gtk3-devel gtk+3-devel expat-devel lame-devel
- libsoxr-devel portaudio-devel sqlite-devel libcurl-devel ffmpeg-devel
+ libsoxr-devel portaudio-devel sqlite-devel libcurl-devel ffmpeg4-devel
  libid3tag-devel libmad-devel vamp-plugin-sdk-devel libogg-devel
  libvorbis-devel libflac-devel lilv-devel lv2 serd-devel sord-devel
  sratom-devel suil-devel portmidi-devel soundtouch-devel twolame-devel

From bea4c2e36f8227aced9fe9406759e1e6ffe2df13 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 018/115] avidemux: revbump for ffmpeg-6.0

---
 srcpkgs/avidemux/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/avidemux/template b/srcpkgs/avidemux/template
index 253a0243e2259..557285982d2b8 100644
--- a/srcpkgs/avidemux/template
+++ b/srcpkgs/avidemux/template
@@ -1,7 +1,7 @@
 # Template file for 'avidemux'
 pkgname=avidemux
 version=2.8.0
-revision=2
+revision=3
 # Can't be compiled for aarch64, arm* or mips*
 archs="x86_64* i686*"
 hostmakedepends="cmake pkg-config qt5-host-tools qt5-devel tar yasm"

From 1b55be7b0108937bddc19a35ef615d61ec97398d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 019/115] blender: revbump for ffmpeg-6.0

---
 srcpkgs/blender/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index 05fdbf8f747e2..093d6d2004e95 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -9,8 +9,8 @@ configure_args="-DWITH_INSTALL_PORTABLE=OFF -DWITH_PYTHON_INSTALL=OFF
  -DWITH_JACK=ON -DWITH_CODEC_FFMPEG=ON -DWITH_CODEC_SNDFILE=ON -DWITH_OPENMP=ON
  -DWITH_FFTW3=ON -DWITH_MOD_OCEANSIM=ON -DWITH_CYCLES_EMBREE=OFF -DWITH_OPENCOLORIO=ON
  -DWITH_IMAGE_OPENEXR=ON -DWITH_IMAGE_OPENJPEG=ON -DWITH_OPENSUBDIV=ON
- -DWITH_OPENCOLLADA=ON -DWITH_SYSTEM_GLEW=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
- -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_LIBDECOR=ON
+ -DWITH_OPENCOLLADA=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
+ -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_WAYLAND_LIBDECOR=ON
  -DWITH_BUILDINFO=OFF -DPYTHON_VERSION=${py3_ver} -DPYTHON_LIBPATH=/usr/lib
  -DPYTHON_LIBRARY=python${py3_ver}${py3_abiver} -DPYTHON_INCLUDE_DIRS=/${py3_inc}
  -DWITH_SYSTEM_LZO=ON -DWITH_SYSTEM_EIGEN3=ON -DWITH_SYSTEM_FREETYPE=ON"

From 6d1f5a63933dc28bc60903632814e89f6b1d0932 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 020/115] cantata: revbump for ffmpeg-6.0

---
 srcpkgs/cantata/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cantata/template b/srcpkgs/cantata/template
index 4b417d80d5c2d..8a90aaa4c07a2 100644
--- a/srcpkgs/cantata/template
+++ b/srcpkgs/cantata/template
@@ -1,7 +1,7 @@
 # Template file for 'cantata'
 pkgname=cantata
 version=2.5.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools qt5-tools"
 makedepends="qt5-devel qt5-tools-devel qt5-svg-devel qt5-xmlpatterns-devel

From 8c6c0e020a8d60ca7740bf87a0191daed4eb3fe4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 021/115] ccextractor: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ccextractor/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/ccextractor/template b/srcpkgs/ccextractor/template
index 9abcd82852b27..6eccad5885af9 100644
--- a/srcpkgs/ccextractor/template
+++ b/srcpkgs/ccextractor/template
@@ -1,12 +1,12 @@
 # Template file for 'ccextractor'
 pkgname=ccextractor
 version=0.93
-revision=1
+revision=2
 build_wrksrc="linux"
 build_style=gnu-configure
 configure_args="--enable-ocr --enable-hardsubx"
 hostmakedepends="automake pkg-config"
-makedepends="leptonica-devel tesseract-ocr-devel ffmpeg-devel"
+makedepends="leptonica-devel tesseract-ocr-devel ffmpeg4-devel"
 short_desc="Extract subtitles from video streams"
 maintainer="newbluemoon <blaumolch@mailbox.org>"
 license="GPL-2.0-or-later"

From 5375eb0508d131887d1e42c9bee51d50e63f8f58 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 022/115] chromaprint: revbump for ffmpeg-6.0

---
 srcpkgs/chromaprint/patches/ffmpeg5.patch | 569 ++++++++++++++++++++++
 srcpkgs/chromaprint/template              |   2 +-
 2 files changed, 570 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromaprint/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromaprint/patches/ffmpeg5.patch b/srcpkgs/chromaprint/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..a9fd307a23c8a
--- /dev/null
+++ b/srcpkgs/chromaprint/patches/ffmpeg5.patch
@@ -0,0 +1,569 @@
+From 8ccad6937177b1b92e40ab8f4447ea27bac009a7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= <lalinsky@gmail.com>
+Date: Fri, 4 Nov 2022 21:47:38 +0100
+Subject: [PATCH] Use FFmpeg 5.x (#120)
+
+* Use FFmpeg 5.1.2 for CI builds
+
+* Build on Ubuntu 20.04
+
+* Upgrade code to FFmpeg 5.x APIs
+
+* Only set FFmpeg include dirs if building tools
+
+* No longer needed
+
+* Use ubuntu 20.04
+---
+ .github/workflows/build.yml                   |   6 +-
+ CMakeLists.txt                                |  16 --
+ package/build.sh                              |   4 +-
+ src/audio/ffmpeg_audio_processor.h            |   2 -
+ src/audio/ffmpeg_audio_processor_avresample.h |  72 -------
+ src/audio/ffmpeg_audio_processor_swresample.h |  18 +-
+ src/audio/ffmpeg_audio_reader.h               | 197 +++++++++---------
+ tests/CMakeLists.txt                          |   6 +
+ 8 files changed, 122 insertions(+), 199 deletions(-)
+ delete mode 100644 src/audio/ffmpeg_audio_processor_avresample.h
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index f8d6a32..4da2405 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -84,9 +84,6 @@ find_package(FFmpeg)
+ if(FFMPEG_LIBRARIES)
+ 	cmake_push_check_state(RESET)
+ 	set(CMAKE_REQUIRED_LIBRARIES ${FFMPEG_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -lm)
+-	check_function_exists(av_packet_unref HAVE_AV_PACKET_UNREF)
+-	check_function_exists(av_frame_alloc HAVE_AV_FRAME_ALLOC)
+-	check_function_exists(av_frame_free HAVE_AV_FRAME_FREE)
+ 	cmake_pop_check_state()
+ endif()
+
+@@ -163,14 +160,11 @@ message(STATUS "Using ${FFT_LIB} for FFT calculations")
+ if(NOT AUDIO_PROCESSOR_LIB)
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+ 		set(AUDIO_PROCESSOR_LIB "swresample")
+-	elseif(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(AUDIO_PROCESSOR_LIB "avresample")
+ 	endif()
+ endif()
+
+ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE OFF)
+ 		set(USE_SWRESAMPLE ON)
+ 		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBSWRESAMPLE_LIBRARIES})
+ 		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBSWRESAMPLE_INCLUDE_DIRS})
+@@ -178,16 +172,6 @@ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+ 	endif()
+ 	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+-elseif(AUDIO_PROCESSOR_LIB STREQUAL "avresample")
+-	if(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE ON)
+-		set(USE_SWRESAMPLE OFF)
+-		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBAVRESAMPLE_LIBRARIES})
+-		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBAVRESAMPLE_INCLUDE_DIRS})
+-	else()
+-		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+-	endif()
+-	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+ else()
+ 	message(STATUS "Building without audio conversion support, please install FFmpeg with libswresample")
+ endif()
+diff --git a/package/build.sh b/package/build.sh
+index da631ae..b41d36e 100755
+--- a/package/build.sh
++++ b/package/build.sh
+@@ -7,8 +7,8 @@ set -eux
+
+ BASE_DIR=$(cd $(dirname $0)/.. && pwd)
+
+-FFMPEG_VERSION=4.4.1
+-FFMPEG_BUILD_TAG=v4.4.1-1
++FFMPEG_VERSION=5.1.2
++FFMPEG_BUILD_TAG=v${FFMPEG_VERSION}-1
+
+ TMP_BUILD_DIR=$BASE_DIR/$(mktemp -d build.XXXXXXXX)
+ trap 'rm -rf $TMP_BUILD_DIR' EXIT
+diff --git a/src/audio/ffmpeg_audio_processor.h b/src/audio/ffmpeg_audio_processor.h
+index 7628fc7..39f4f6d 100644
+--- a/src/audio/ffmpeg_audio_processor.h
++++ b/src/audio/ffmpeg_audio_processor.h
+@@ -10,8 +10,6 @@
+
+ #if defined(USE_SWRESAMPLE)
+ #include "audio/ffmpeg_audio_processor_swresample.h"
+-#elif defined(USE_AVRESAMPLE)
+-#include "audio/ffmpeg_audio_processor_avresample.h"
+ #else
+ #error "no audio processing library"
+ #endif
+diff --git a/src/audio/ffmpeg_audio_processor_avresample.h b/src/audio/ffmpeg_audio_processor_avresample.h
+deleted file mode 100644
+index bd85f92..0000000
+--- a/src/audio/ffmpeg_audio_processor_avresample.h
++++ /dev/null
+@@ -1,72 +0,0 @@
+-// Copyright (C) 2016  Lukas Lalinsky
+-// Distributed under the MIT license, see the LICENSE file for details.
+-
+-#ifndef CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-#define CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-
+-extern "C" {
+-#include <libavresample/avresample.h>
+-}
+-
+-namespace chromaprint {
+-
+-class FFmpegAudioProcessor {
+-public:
+-	FFmpegAudioProcessor() {
+-		m_resample_ctx = avresample_alloc_context();
+-	}
+-
+-	~FFmpegAudioProcessor() {
+-		avresample_free(&m_resample_ctx);
+-	}
+-
+-	void SetCompatibleMode() {
+-		av_opt_set_int(m_resample_ctx, "filter_size", 16, 0);
+-		av_opt_set_int(m_resample_ctx, "phase_shift", 8, 0);
+-		av_opt_set_int(m_resample_ctx, "linear_interp", 1, 0);
+-		av_opt_set_double(m_resample_ctx, "cutoff", 0.8, 0);
+-	}
+-
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "in_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_rate", sample_rate, 0);
+-	}
+-
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "out_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_rate, 0);
+-	}
+-
+-	int Init() {
+-		return avresample_open(m_resample_ctx);
+-	}
+-
+-	int Convert(uint8_t **out, int out_count, const uint8_t **in, int in_count) {
+-		return avresample_convert(m_resample_ctx, out, 0, out_count, (uint8_t **) in, 0, in_count);
+-	}
+-
+-	int Flush(uint8_t **out, int out_count) {
+-		return avresample_read(m_resample_ctx, out, out_count);
+-	}
+-
+-private:
+-	AVAudioResampleContext *m_resample_ctx = nullptr;
+-};
+-
+-}; // namespace chromaprint
+-
+-#endif
+diff --git a/src/audio/ffmpeg_audio_processor_swresample.h b/src/audio/ffmpeg_audio_processor_swresample.h
+index b86266b..b1d4bea 100644
+--- a/src/audio/ffmpeg_audio_processor_swresample.h
++++ b/src/audio/ffmpeg_audio_processor_swresample.h
+@@ -28,30 +28,28 @@ public:
+ 		av_opt_set_double(m_swr_ctx, "cutoff", 0.8, 0);
+ 	}
+
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "icl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "ich", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetInputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "in_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "isf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "in_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "isr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "in_sample_rate", sample_rate, 0);
+ 	}
+
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "ocl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "och", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetOutputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "out_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "osf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "out_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "osr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "out_sample_rate", sample_rate, 0);
+ 	}
+
+ 	int Init() {
+diff --git a/src/audio/ffmpeg_audio_reader.h b/src/audio/ffmpeg_audio_reader.h
+index 5550164..1c6b346 100644
+--- a/src/audio/ffmpeg_audio_reader.h
++++ b/src/audio/ffmpeg_audio_reader.h
+@@ -62,7 +62,7 @@ public:
+ 	bool Read(const int16_t **data, size_t *size);
+
+ 	bool IsOpen() const { return m_opened; }
+-	bool IsFinished() const { return m_finished && !m_got_frame; }
++	bool IsFinished() const { return !m_has_more_packets && !m_has_more_frames; }
+
+ 	std::string GetError() const { return m_error; }
+ 	int GetErrorCode() const { return m_error_code; }
+@@ -74,20 +74,19 @@ private:
+ 	uint8_t *m_convert_buffer[1] = { nullptr };
+ 	int m_convert_buffer_nb_samples = 0;
+
+-	AVInputFormat *m_input_fmt = nullptr;
++	const AVInputFormat *m_input_fmt = nullptr;
+ 	AVDictionary *m_input_opts = nullptr;
+
+ 	AVFormatContext *m_format_ctx = nullptr;
+ 	AVCodecContext *m_codec_ctx = nullptr;
+-	AVFrame *m_frame = nullptr;
+ 	int m_stream_index = -1;
+ 	std::string m_error;
+ 	int m_error_code = 0;
+-	bool m_finished = false;
+ 	bool m_opened = false;
+-	int m_got_frame = 0;
+-	AVPacket m_packet;
+-	AVPacket m_packet0;
++	bool m_has_more_packets = true;
++	bool m_has_more_frames = true;
++	AVPacket *m_packet = nullptr;
++	AVFrame *m_frame = nullptr;
+
+ 	int m_output_sample_rate = 0;
+ 	int m_output_channels = 0;
+@@ -98,19 +97,12 @@ private:
+
+ inline FFmpegAudioReader::FFmpegAudioReader() {
+ 	av_log_set_level(AV_LOG_QUIET);
+-
+-	av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
+ }
+
+ inline FFmpegAudioReader::~FFmpegAudioReader() {
+ 	Close();
+ 	av_dict_free(&m_input_opts);
+ 	av_freep(&m_convert_buffer[0]);
+-	av_packet_unref(&m_packet0);
+ }
+
+ inline bool FFmpegAudioReader::SetInputFormat(const char *name) {
+@@ -135,11 +127,10 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ 	Close();
+
+-    av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
++	m_packet = av_packet_alloc();
++	if (!m_packet) {
++		return false;
++	}
+
+ 	ret = avformat_open_input(&m_format_ctx, file_name.c_str(), m_input_fmt, &m_input_opts);
+ 	if (ret < 0) {
+@@ -153,26 +144,31 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		return false;
+ 	}
+
+-	AVCodec *codec;
++	const AVCodec *codec;
+ 	ret = av_find_best_stream(m_format_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &codec, 0);
+ 	if (ret < 0) {
+ 		SetError("Could not find any audio stream in the file", ret);
+ 		return false;
+ 	}
+ 	m_stream_index = ret;
++	auto stream = m_format_ctx->streams[m_stream_index];
+
+-	m_codec_ctx = m_format_ctx->streams[m_stream_index]->codec;
++	m_codec_ctx = avcodec_alloc_context3(codec);
+ 	m_codec_ctx->request_sample_fmt = AV_SAMPLE_FMT_S16;
+
++	ret = avcodec_parameters_to_context(m_codec_ctx, stream->codecpar);
++	if (ret < 0) {
++		SetError("Could not copy the stream parameters", ret);
++		return false;
++	}
++
+ 	ret = avcodec_open2(m_codec_ctx, codec, nullptr);
+ 	if (ret < 0) {
+ 		SetError("Could not open the codec", ret);
+ 		return false;
+ 	}
+
+-	if (!m_codec_ctx->channel_layout) {
+-		m_codec_ctx->channel_layout = av_get_default_channel_layout(m_codec_ctx->channels);
+-	}
++	av_dump_format(m_format_ctx, 0, "foo", 0);
+
+ 	m_frame = av_frame_alloc();
+ 	if (!m_frame) {
+@@ -183,19 +179,23 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		m_output_sample_rate = m_codec_ctx->sample_rate;
+ 	}
+
+-	if (!m_output_channels) {
+-		m_output_channels = m_codec_ctx->channels;
++	AVChannelLayout output_channel_layout;
++	if (m_output_channels) {
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
++	} else {
++		m_output_channels = m_codec_ctx->ch_layout.nb_channels;
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
+ 	}
+
+-	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
++	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->ch_layout.nb_channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
+ 		m_converter.reset(new FFmpegAudioProcessor());
+ 		m_converter->SetCompatibleMode();
+ 		m_converter->SetInputSampleFormat(m_codec_ctx->sample_fmt);
+ 		m_converter->SetInputSampleRate(m_codec_ctx->sample_rate);
+-		m_converter->SetInputChannelLayout(m_codec_ctx->channel_layout);
++		m_converter->SetInputChannelLayout(&(m_codec_ctx->ch_layout));
+ 		m_converter->SetOutputSampleFormat(AV_SAMPLE_FMT_S16);
+ 		m_converter->SetOutputSampleRate(m_output_sample_rate);
+-		m_converter->SetOutputChannelLayout(av_get_default_channel_layout(m_output_channels));
++		m_converter->SetOutputChannelLayout(&output_channel_layout);
+ 		auto ret = m_converter->Init();
+ 		if (ret != 0) {
+ 			SetError("Could not create an audio converter instance", ret);
+@@ -203,10 +203,11 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		}
+ 	}
+
++	av_channel_layout_uninit(&output_channel_layout);
++
+ 	m_opened = true;
+-	m_finished = false;
+-	m_got_frame = 0;
+-	m_nb_packets = 0;
++	m_has_more_packets = true;
++	m_has_more_frames = true;
+ 	m_decode_error = 0;
+
+ 	return true;
+@@ -214,6 +215,7 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ inline void FFmpegAudioReader::Close() {
+ 	av_frame_free(&m_frame);
++	av_packet_free(&m_packet);
+
+ 	m_stream_index = -1;
+
+@@ -252,91 +254,98 @@ inline bool FFmpegAudioReader::Read(const int16_t **data, size_t *size) {
+ 		return false;
+ 	}
+
++	*data = nullptr;
++	*size = 0;
++
+ 	int ret;
++	bool needs_packet = false;
+ 	while (true) {
+-		while (m_packet.size <= 0) {
+-			av_packet_unref(&m_packet0);
+-			av_init_packet(&m_packet);
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			ret = av_read_frame(m_format_ctx, &m_packet);
++		while (needs_packet && m_packet->size == 0) {
++			ret = av_read_frame(m_format_ctx, m_packet);
+ 			if (ret < 0) {
+ 				if (ret == AVERROR_EOF) {
+-					m_finished = true;
++					needs_packet = false;
++					m_has_more_packets = false;
+ 					break;
+-				} else {
++				}
++				SetError("Error reading from the audio source", ret);
++				return false;
++			}
++			if (m_packet->stream_index == m_stream_index) {
++				needs_packet = false;
++			} else {
++				av_packet_unref(m_packet);
++			}
++		}
++
++		if (m_packet->size != 0) {
++			ret = avcodec_send_packet(m_codec_ctx, m_packet);
++			if (ret < 0) {
++				if (ret != AVERROR(EAGAIN)) {
+ 					SetError("Error reading from the audio source", ret);
+ 					return false;
+ 				}
+-			}
+-			m_packet0 = m_packet;
+-			if (m_packet.stream_index != m_stream_index) {
+-				m_packet.data = nullptr;
+-				m_packet.size = 0;
+ 			} else {
+-				m_nb_packets++;
++				av_packet_unref(m_packet);
+ 			}
+ 		}
+
+-		ret = avcodec_decode_audio4(m_codec_ctx, m_frame, &m_got_frame, &m_packet);
++		ret = avcodec_receive_frame(m_codec_ctx, m_frame);
+ 		if (ret < 0) {
+-			if (m_decode_error) {
+-				SetError("Error decoding audio frame", m_decode_error);
+-				return false;
++			if (ret == AVERROR_EOF) {
++				m_has_more_frames = false;
++			} else if (ret == AVERROR(EAGAIN)) {
++				if (m_has_more_packets) {
++					needs_packet = true;
++					continue;
++				} else {
++					m_has_more_frames = false;
++				}
+ 			}
+-			m_decode_error = ret;
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			continue;
++			SetError("Error decoding the audio source", ret);
++			return false;
+ 		}
+
+-		break;
+-	}
+-
+-	m_decode_error = 0;
+-
+-	const int decoded = std::min(ret, m_packet.size);
+-	m_packet.data += decoded;
+-	m_packet.size -= decoded;
+-
+-	if (m_got_frame) {
+-		if (m_converter) {
+-			if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
+-				int linsize;
+-				av_freep(&m_convert_buffer[0]);
+-				m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
+-				ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
+-				if (ret < 0) {
+-					SetError("Couldn't allocate audio converter buffer", ret);
++		if (m_frame->nb_samples > 0) {
++			if (m_converter) {
++				if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
++					int linsize;
++					av_freep(&m_convert_buffer[0]);
++					m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
++					ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->ch_layout.nb_channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
++					if (ret < 0) {
++						SetError("Couldn't allocate audio converter buffer", ret);
++						return false;
++					}
++				}
++				auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
++				if (nb_samples < 0) {
++					SetError("Couldn't convert audio", ret);
+ 					return false;
+ 				}
+-			}
+-			auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			}
+-			*data = (const int16_t *) m_convert_buffer[0];
+-			*size = nb_samples;
+-		} else {
+-			*data = (const int16_t *) m_frame->data[0];
+-			*size = m_frame->nb_samples;
+-		}
+-	} else {
+-		if (m_finished && m_converter) {
+-			auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			} else if (nb_samples > 0) {
+-				m_got_frame = 1;
+ 				*data = (const int16_t *) m_convert_buffer[0];
+ 				*size = nb_samples;
++			} else {
++				*data = (const int16_t *) m_frame->data[0];
++				*size = m_frame->nb_samples;
++			}
++		} else {
++			if (m_converter) {
++				if (IsFinished()) {
++					auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
++					if (nb_samples < 0) {
++						SetError("Couldn't convert audio", ret);
++						return false;
++					} else if (nb_samples > 0) {
++						*data = (const int16_t *) m_convert_buffer[0];
++						*size = nb_samples;
++					}
++				}
+ 			}
+ 		}
+-	}
+
+-	return true;
++		return true;
++	}
+ }
+
+ inline void FFmpegAudioReader::SetError(const char *message, int errnum) {
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index a2b517b..123e643 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -38,6 +38,12 @@ set(SRCS
+
+ if(BUILD_TOOLS)
+ 	set(SRCS ${SRCS} ../src/audio/ffmpeg_audio_reader_test.cpp)
++    include_directories(
++        ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}
++        ${AUDIO_PROCESSOR_INCLUDE_DIRS}
++    )
+ 	link_libraries(fpcalc_libs)
+ endif()
+
+-- 
+2.38.1
+
+
diff --git a/srcpkgs/chromaprint/template b/srcpkgs/chromaprint/template
index 7ef7838949f3a..1f7bbc70a22c8 100644
--- a/srcpkgs/chromaprint/template
+++ b/srcpkgs/chromaprint/template
@@ -1,7 +1,7 @@
 # Template file for 'chromaprint'
 pkgname=chromaprint
 version=1.5.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DBUILD_TOOLS=ON"
 make_check_target="check"

From ed9ec925a2f732daee6611ee8848ec10e8be441a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 023/115] chromium: revbump for ffmpeg-6.0

---
 .../patches/chromium-119-ffmpeg-4.4.patch     | 20 --------
 srcpkgs/chromium/patches/ffmpeg5.patch        | 47 +++++++++++++++++++
 srcpkgs/chromium/template                     |  2 +-
 3 files changed, 48 insertions(+), 21 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch
 create mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch b/srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch
deleted file mode 100644
index 04d04b166ba37..0000000000000
--- a/srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch
+++ /dev/null
@@ -1,20 +0,0 @@
---- a/media/filters/ffmpeg_demuxer.cc.orig
-+++ b/media/filters/ffmpeg_demuxer.cc
-@@ -390,7 +390,7 @@
- 
-   scoped_refptr<DecoderBuffer> buffer;
- 
--    size_t side_data_size = 0;
-+    int side_data_size = 0;
-     uint8_t* side_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
- 
-@@ -453,7 +453,7 @@
-                                        packet->size - data_offset);
-     }
- 
--    size_t skip_samples_size = 0;
-+    int skip_samples_size = 0;
-     const uint32_t* skip_samples_ptr =
-         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
-             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..24e2da38e34ca
--- /dev/null
+++ b/srcpkgs/chromium/patches/ffmpeg5.patch
@@ -0,0 +1,47 @@
+--- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
++++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
+@@ -92,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+-  if (stream->start_time != kNoFFmpegTimestamp)
++  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -1597,7 +1585,7 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+@@ -1618,7 +1606,7 @@
+     if (stream->type() != DemuxerStream::VIDEO)
+       continue;
+ 
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+ 
+     if (!stream->IsEnabled())
diff --git a/srcpkgs/chromium/template b/srcpkgs/chromium/template
index b023946f3ec7b..fe36a6dce20d3 100644
--- a/srcpkgs/chromium/template
+++ b/srcpkgs/chromium/template
@@ -2,7 +2,7 @@
 pkgname=chromium
 # See https://chromiumdash.appspot.com/releases?platform=Linux for the latest version
 version=119.0.6045.105
-revision=3
+revision=4
 archs="i686* x86_64* aarch64* armv7l*"
 hostmakedepends="
  $(vopt_if clang "clang lld llvm15")

From 111f15ac66c89b048843c659cc183d0cc11ff26e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 024/115] cmus: revbump for ffmpeg-6.0

---
 srcpkgs/chromium/patches/ffmpeg5.patch | 47 --------------------------
 srcpkgs/cmus/patches/ffmpeg6.patch     | 12 +++++++
 srcpkgs/cmus/template                  |  2 +-
 3 files changed, 13 insertions(+), 48 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch
 create mode 100644 srcpkgs/cmus/patches/ffmpeg6.patch

diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
deleted file mode 100644
index 24e2da38e34ca..0000000000000
--- a/srcpkgs/chromium/patches/ffmpeg5.patch
+++ /dev/null
@@ -1,47 +0,0 @@
---- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
-+++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
-@@ -92,24 +92,12 @@
- 
- static base::TimeDelta ExtractStartTime(AVStream* stream) {
-   // The default start time is zero.
--  base::TimeDelta start_time;
-+  base::TimeDelta start_time = kNoTimestamp;
- 
-   // First try to use  the |start_time| value as is.
--  if (stream->start_time != kNoFFmpegTimestamp)
-+  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
-     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
- 
--  // Next try to use the first DTS value, for codecs where we know PTS == DTS
--  // (excludes all H26x codecs). The start time must be returned in PTS.
--  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
--      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
--      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
--      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
--    const base::TimeDelta first_pts =
--        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
--    if (first_pts < start_time)
--      start_time = first_pts;
--  }
--
-   return start_time;
- }
- 
-@@ -1597,7 +1585,7 @@
-   for (const auto& stream : streams_) {
-     if (!stream || stream->IsEnabled() != enabled)
-       continue;
--    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
-+    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
-       continue;
-     if (!lowest_start_time_stream ||
-         stream->start_time() < lowest_start_time_stream->start_time()) {
-@@ -1618,7 +1606,7 @@
-     if (stream->type() != DemuxerStream::VIDEO)
-       continue;
- 
--    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
-+    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
-       continue;
- 
-     if (!stream->IsEnabled())
diff --git a/srcpkgs/cmus/patches/ffmpeg6.patch b/srcpkgs/cmus/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..ffa95ab811101
--- /dev/null
+++ b/srcpkgs/cmus/patches/ffmpeg6.patch
@@ -0,0 +1,12 @@
+--- a/ip/ffmpeg.c
++++ b/ip/ffmpeg.c
+@@ -202,9 +202,6 @@ static int ffmpeg_open(struct input_plugin_data *ip_data)
+ 			break;
+ 		}
+ 
+-		if (codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+-			cc->flags |= AV_CODEC_FLAG_TRUNCATED;
+-
+ 		if (avcodec_open2(cc, codec, NULL) < 0) {
+ 			d_print("could not open codec: %d, %s\n", cc->codec_id, avcodec_get_name(cc->codec_id));
+ 			err = -IP_ERROR_UNSUPPORTED_FILE_TYPE;
diff --git a/srcpkgs/cmus/template b/srcpkgs/cmus/template
index 0d1436744f1b2..a6e4b4fa86cb8 100644
--- a/srcpkgs/cmus/template
+++ b/srcpkgs/cmus/template
@@ -1,7 +1,7 @@
 # Template file for 'cmus'
 pkgname=cmus
 version=2.10.0
-revision=3
+revision=4
 build_style=configure
 configure_args="prefix=/usr LD=$CC"
 hostmakedepends="pkg-config"

From f0f525f154bb49d525edc3b19dc886e6d3a3f82f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 025/115] cyanrip: revbump for ffmpeg-6.0

---
 srcpkgs/cyanrip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cyanrip/template b/srcpkgs/cyanrip/template
index 9796e3461601a..5db30e020d17e 100644
--- a/srcpkgs/cyanrip/template
+++ b/srcpkgs/cyanrip/template
@@ -1,7 +1,7 @@
 # Template file for 'cyanrip'
 pkgname=cyanrip
 version=0.9.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config"
 makedepends="ffmpeg-devel libcdio-devel libcdio-paranoia-devel libcurl-devel libmusicbrainz5-devel"

From 32210f7b42f45a20cb630b5cbbfccc4a9d3c3393 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 026/115] deadbeef: revbump for ffmpeg4-4.4.3

---
 srcpkgs/deadbeef/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/deadbeef/template b/srcpkgs/deadbeef/template
index f5f4bf24b8cb6..7b47e615cd48e 100644
--- a/srcpkgs/deadbeef/template
+++ b/srcpkgs/deadbeef/template
@@ -1,14 +1,14 @@
 # Template file for 'deadbeef'
 pkgname=deadbeef
 version=1.8.8
-revision=3
+revision=4
 create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-oss --disable-lfm --disable-notify --disable-gtk2"
 hostmakedepends="automake libtool gettext gettext-devel intltool pkg-config
  yasm clang glib-devel"
 makedepends="
- alsa-lib-devel dbus-devel faad2-devel ffmpeg-devel gtk+3-devel imlib2-devel
+ alsa-lib-devel dbus-devel faad2-devel ffmpeg4-devel gtk+3-devel imlib2-devel
  jansson-devel libcddb-devel libcdio-devel libcurl-devel libflac-devel
  libmad-devel libpng-devel libsamplerate-devel libsndfile-devel libvorbis-devel
  libzip-devel mpg123-devel opusfile-devel pulseaudio-devel wavpack-devel"

From 9b356b92b5c020ce59c926b561d8884b5b507575 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 027/115] droidcam-obs-plugin: revbump for ffmpeg-6.0

---
 srcpkgs/droidcam-obs-plugin/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam-obs-plugin/template b/srcpkgs/droidcam-obs-plugin/template
index fc9c9bf6b9d54..fb0480754df4d 100644
--- a/srcpkgs/droidcam-obs-plugin/template
+++ b/srcpkgs/droidcam-obs-plugin/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam-obs-plugin'
 pkgname=droidcam-obs-plugin
 version=2.0.1
-revision=1
+revision=2
 build_style=gnu-makefile
 make_use_env=yes
 make_build_args="ALLOW_STATIC=no"

From 1c4b2fde038329b94652c7fdb0f3004667320584 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 028/115] droidcam: revbump for ffmpeg-6.0

---
 srcpkgs/droidcam/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam/template b/srcpkgs/droidcam/template
index 1c3f1b8b1fc67..32a9220b79a4d 100644
--- a/srcpkgs/droidcam/template
+++ b/srcpkgs/droidcam/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam'
 pkgname=droidcam
 version=1.8.2
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="USBMUXD=-lusbmuxd-2.0 JPEG=-lturbojpeg"
 hostmakedepends="pkg-config"

From 45241dbeba7399e017180cca278ba4a6224abfcc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 029/115] ffmpegthumbnailer: revbump for ffmpeg-6.0

---
 .../ffmpegthumbnailer/patches/ffmpeg6.patch   | 202 ++++++++++++++++++
 srcpkgs/ffmpegthumbnailer/template            |   6 +-
 2 files changed, 205 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch

diff --git a/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..363ff35a28419
--- /dev/null
+++ b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
@@ -0,0 +1,202 @@
+--- a/libffmpegthumbnailer/moviedecoder.cpp	2017-11-21 14:06:57.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.cpp	2023-05-05 13:14:47.946560668 -0400
+@@ -41,11 +41,6 @@
+ namespace ffmpegthumbnailer
+ {
+ 
+-struct SilenceLogLevel
+-{
+-    SilenceLogLevel() { av_log_set_level(AV_LOG_QUIET); }
+-};
+-
+ MovieDecoder::MovieDecoder(AVFormatContext* pavContext)
+ : m_VideoStream(-1)
+ , m_pFormatContext(pavContext)
+@@ -70,8 +65,6 @@
+ 
+ void MovieDecoder::initialize(const string& filename, bool preferEmbeddedMetadata)
+ {
+-    av_register_all();
+-    avcodec_register_all();
+     avformat_network_init();
+ 
+     string inputFile = filename == "-" ? "pipe:" : filename;
+@@ -97,8 +90,7 @@
+ {
+     if (m_pVideoCodecContext)
+     {
+-        avcodec_close(m_pVideoCodecContext);
+-        m_pVideoCodecContext = nullptr;
++        avcodec_free_context(&m_pVideoCodecContext);
+     }
+ 
+     if ((!m_FormatContextWasGiven) && m_pFormatContext)
+@@ -152,10 +144,10 @@
+     for (unsigned int i = 0; i < m_pFormatContext->nb_streams; ++i)
+     {
+         AVStream *stream = m_pFormatContext->streams[i];
+-        auto ctx = m_pFormatContext->streams[i]->codec;
+-        if (ctx->codec_type == AVMEDIA_TYPE_VIDEO)
++        auto par = m_pFormatContext->streams[i]->codecpar;
++        if (par->codec_type == AVMEDIA_TYPE_VIDEO)
+         {
+-            if (!preferEmbeddedMetadata || !isStillImageCodec(ctx->codec_id))
++            if (!preferEmbeddedMetadata || !isStillImageCodec(par->codec_id))
+             {
+                 videoStreams.push_back(i);
+                 continue;
+@@ -203,8 +195,7 @@
+     }
+ 
+     m_pVideoStream = m_pFormatContext->streams[m_VideoStream];
+-    m_pVideoCodecContext = m_pVideoStream->codec;
+-    m_pVideoCodec = avcodec_find_decoder(m_pVideoCodecContext->codec_id);
++    m_pVideoCodec = avcodec_find_decoder(m_pVideoStream->codecpar->codec_id);
+ 
+     if (m_pVideoCodec == nullptr)
+     {
+@@ -214,6 +205,20 @@
+         throw logic_error("Video Codec not found");
+     }
+ 
++    m_pVideoCodecContext = avcodec_alloc_context3(m_pVideoCodec);
++
++    if (m_pVideoCodecContext == nullptr)
++    {
++        destroy();
++        throw logic_error("Could not allocate video codec context");
++    }
++
++    if (avcodec_parameters_to_context(m_pVideoCodecContext, m_pVideoStream->codecpar) < 0)
++    {
++        destroy();
++        throw logic_error("Could not configure video codec context");
++    }
++
+     m_pVideoCodecContext->workaround_bugs = 1;
+ 
+     if (avcodec_open2(m_pVideoCodecContext, m_pVideoCodec, nullptr) < 0)
+@@ -386,13 +391,6 @@
+ 
+ void MovieDecoder::initializeFilterGraph(const AVRational& timeBase, const std::string& size, bool maintainAspectRatio)
+ {
+-    static const AVPixelFormat pixelFormats[] = { AV_PIX_FMT_RGB24, AV_PIX_FMT_NONE };
+-
+-    auto del = [] (AVBufferSinkParams* p) { av_freep(p); };
+-    std::unique_ptr<AVBufferSinkParams, decltype(del)> buffersinkParams(av_buffersink_params_alloc(), del);
+-
+-    avfilter_register_all();
+-
+     m_pFilterGraph = avfilter_graph_alloc();
+     assert(m_pFilterGraph);
+ 
+@@ -404,10 +402,8 @@
+ 
+     checkRc(avfilter_graph_create_filter(&m_pFilterSource, avfilter_get_by_name("buffer"), "thumb_buffer", ss.str().c_str(), nullptr, m_pFilterGraph),
+             "Failed to create filter source");
+-    buffersinkParams->pixel_fmts = pixelFormats;
+-    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, buffersinkParams.get(), m_pFilterGraph),
++    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, nullptr, m_pFilterGraph),
+             "Failed to create filter sink");
+-    buffersinkParams.release();
+ 
+     AVFilterContext* yadifFilter = nullptr;
+     if (m_pFrame->interlaced_frame != 0)
+@@ -500,15 +496,15 @@
+     }
+ 
+     checkRc(av_seek_frame(m_pFormatContext, -1, timestamp, 0), "Seeking in video failed");
+-    avcodec_flush_buffers(m_pFormatContext->streams[m_VideoStream]->codec);
++    avcodec_flush_buffers(m_pVideoCodecContext);
+ 
+     int keyFrameAttempts = 0;
+-    bool gotFrame = 0;
++    bool gotFrame;
+ 
+     do
+     {
+         int count = 0;
+-        gotFrame = 0;
++        gotFrame = false;
+ 
+         while (!gotFrame && count < 20)
+         {
+@@ -552,17 +548,33 @@
+         return false;
+     }
+ 
+-    av_frame_unref(m_pFrame);
+-
+-    int frameFinished;
++    int rc = avcodec_send_packet(m_pVideoCodecContext, m_pPacket);
++    if(rc == AVERROR(EAGAIN))
++    {
++        rc = 0;
++    }
+ 
+-    int bytesDecoded = avcodec_decode_video2(m_pVideoCodecContext, m_pFrame, &frameFinished, m_pPacket);
+-    if (bytesDecoded < 0)
++    if(rc == AVERROR_EOF)
++    {
++        return false;
++    }
++    else if(rc < 0)
+     {
+-        throw logic_error("Failed to decode video frame: bytesDecoded < 0");
++        throw logic_error("Failed to decode video frame: avcodec_send_packet() < 0");
+     }
+ 
+-    return frameFinished > 0;
++    rc = avcodec_receive_frame(m_pVideoCodecContext, m_pFrame);
++    switch(rc)
++    {
++        case 0:
++            return true;
++
++        case AVERROR(EAGAIN):
++            return false;
++
++        default:
++            throw logic_error("Failed to decode video frame: avcodec_receive_frame() < 0");
++    }
+ }
+ 
+ bool MovieDecoder::getVideoPacket()
+@@ -570,8 +582,6 @@
+     bool framesAvailable = true;
+     bool frameDecoded = false;
+ 
+-    int attempts = 0;
+-
+     if (m_pPacket)
+     {
+         av_packet_unref(m_pPacket);
+@@ -580,6 +590,7 @@
+ 
+     m_pPacket = new AVPacket();
+ 
++
+     while (framesAvailable && !frameDecoded)
+     {
+         framesAvailable = av_read_frame(m_pFormatContext, m_pPacket) >= 0;
+@@ -644,7 +655,7 @@
+ 
+ int32_t MovieDecoder::getStreamRotation()
+ {
+-    int32_t* matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
++    auto matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
+     if (matrix)
+     {
+         auto angle = lround(av_display_rotation_get(matrix));
+
+--- a/libffmpegthumbnailer/moviedecoder.h	2017-11-12 04:23:38.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.h	2023-05-05 13:26:07.095529911 -0400
+@@ -78,7 +78,7 @@
+     int                     m_VideoStream;
+     AVFormatContext*        m_pFormatContext;
+     AVCodecContext*         m_pVideoCodecContext;
+-    AVCodec*                m_pVideoCodec;
++    const AVCodec*          m_pVideoCodec;
+     AVFilterGraph*          m_pFilterGraph;
+     AVFilterContext*        m_pFilterSource;
+     AVFilterContext*        m_pFilterSink;
diff --git a/srcpkgs/ffmpegthumbnailer/template b/srcpkgs/ffmpegthumbnailer/template
index 039eea7622b39..35d546018d12a 100644
--- a/srcpkgs/ffmpegthumbnailer/template
+++ b/srcpkgs/ffmpegthumbnailer/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbnailer'
 pkgname=ffmpegthumbnailer
 version=2.2.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libpng-devel libjpeg-turbo-devel ffmpeg-devel"
@@ -9,8 +9,8 @@ depends="ffmpeg"
 short_desc="Lightweight video thumbnailer"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
-homepage="https://github.com/dirkvdb/${pkgname}"
-distfiles="${homepage}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
+homepage="https://github.com/dirkvdb"
+distfiles="${homepage}/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
 checksum=1cb24059c38223f657b300c84dd80491b7040d4b69471c4fea69be862bc99b5b
 
 post_install() {

From bf9e51d6746384b1c7e37757e4afb751f1ccfa1a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 030/115] ffmpegthumbs: revbump for ffmpeg-6.0

---
 srcpkgs/ffmpegthumbs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ffmpegthumbs/template b/srcpkgs/ffmpegthumbs/template
index 5f0b9414dadaf..11b88193528f4 100644
--- a/srcpkgs/ffmpegthumbs/template
+++ b/srcpkgs/ffmpegthumbs/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbs'
 pkgname=ffmpegthumbs
 version=22.12.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules kcoreaddons kconfig-devel
  pkg-config qt5-host-tools qt5-qmake gettext"

From 73f62f7e16569baa2b2c35f7f5ce8e9cb620049c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 031/115] ffms2: revbump for ffmpeg-6.0

---
 srcpkgs/ffms2/patches/ffmpeg5.patch | 424 ++++++++++++++++++++++++++++
 srcpkgs/ffms2/template              |   2 +-
 2 files changed, 425 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ffms2/patches/ffmpeg5.patch

diff --git a/srcpkgs/ffms2/patches/ffmpeg5.patch b/srcpkgs/ffms2/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..1479fabcafcb4
--- /dev/null
+++ b/srcpkgs/ffms2/patches/ffmpeg5.patch
@@ -0,0 +1,424 @@
+From 45673149e9a2f5586855ad472e3059084eaa36b1 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:41:21 +0100
+Subject: [PATCH] Use auto for AVCodec
+
+The geniuses over at FFmpeg decided to constify this API, so old
+versions of the library will return AVCodec *, while new versions
+of the libary will return const AVCodec *, which, in C++, are not
+OK to convert between.
+
+Rather than use some macro hell in ffmscompat.h, we can work around
+this by using auto.
+
+Gross.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 2 +-
+ src/core/indexing.cpp    | 6 +++---
+ src/core/videosource.cpp | 2 +-
+ 3 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index e4ce97c..ac09666 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -469,7 +469,7 @@ void FFMS_AudioSource::OpenFile() {
+ 
+     LAVFOpenFile(SourceFile.c_str(), FormatContext, TrackNumber);
+ 
+-    AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
++    auto *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
+     if (Codec == nullptr)
+         throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+             "Audio codec not found");
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index e547c5a..59fb4e8 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -384,7 +384,7 @@ FFMS_TrackType FFMS_Indexer::GetTrackType(int Track) {
+ }
+ 
+ const char *FFMS_Indexer::GetTrackCodec(int Track) {
+-    AVCodec *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
++    auto *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
+     return codec ? codec->name : nullptr;
+ }
+ 
+@@ -402,7 +402,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             UseDTS);
+ 
+         if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            AVCodec *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (!VideoCodec) {
+                 FormatContext->streams[i]->discard = AVDISCARD_ALL;
+                 IndexMask.erase(i);
+@@ -433,7 +433,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 IndexMask.insert(i);
+             }
+         } else if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+-            AVCodec *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (AudioCodec == nullptr)
+                 throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_UNSUPPORTED,
+                     "Audio codec not found");
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index b889970..8956c22 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -171,7 +171,7 @@ FFMS_VideoSource::FFMS_VideoSource(const char *SourceFile, FFMS_Index &Index, in
+ 
+         LAVFOpenFile(SourceFile, FormatContext, VideoTrack);
+ 
+-        AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
++        auto *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
+         if (Codec == nullptr)
+             throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+                 "Video codec not found");
+-- 
+2.40.0
+
+From 96cbf38ea9381829a1314f432a2c60495dcefaad Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:12:41 +0100
+Subject: [PATCH] all: Update AVPacket API usage
+
+AVPackets must all be on the heap now, since it is no longer
+part of the libav* ABI.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 16 ++++++----
+ src/core/indexing.cpp    | 63 ++++++++++++++++++++++------------------
+ src/core/indexing.h      |  4 +--
+ src/core/utils.cpp       |  6 ----
+ src/core/utils.h         |  1 -
+ src/core/videosource.cpp | 30 ++++++++++---------
+ 6 files changed, 64 insertions(+), 56 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index 37cf9ae..e4ce97c 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -285,10 +285,15 @@ FFMS_AudioSource::AudioBlock *FFMS_AudioSource::CacheBlock(CacheIterator &pos) {
+ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     CurrentFrame = &Frames[PacketNumber];
+ 
+-    AVPacket Packet;
+-    if (!ReadPacket(&Packet))
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++    if (!ReadPacket(Packet)) {
++        av_packet_free(&Packet);
+         throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_UNKNOWN,
+             "ReadPacket unexpectedly failed to read a packet");
++    }
+ 
+     // ReadPacket may have changed the packet number
+     CurrentFrame = &Frames[PacketNumber];
+@@ -297,8 +302,9 @@ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     int NumberOfSamples = 0;
+     AudioBlock *CachedBlock = nullptr;
+     
+-    int Ret = avcodec_send_packet(CodecContext, &Packet);
+-    av_packet_unref(&Packet);
++    int Ret = avcodec_send_packet(CodecContext, Packet);
++    av_packet_unref(Packet);
++    av_packet_free(&Packet);
+ 
+     av_frame_unref(DecodeFrame);
+     Ret = avcodec_receive_frame(CodecContext, DecodeFrame);
+@@ -513,8 +519,6 @@ void FFMS_AudioSource::Seek() {
+ }
+ 
+ bool FFMS_AudioSource::ReadPacket(AVPacket *Packet) {
+-    InitNullPacket(*Packet);
+-
+     while (av_read_frame(FormatContext, Packet) >= 0) {
+         if (Packet->stream_index == TrackNumber) {
+             // Required because not all audio packets, especially in ogg, have a pts. Use the previous valid packet's pts instead.
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index 23fb95b..e547c5a 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -320,7 +320,7 @@ void FFMS_Indexer::CheckAudioProperties(int Track, AVCodecContext *Context) {
+     }
+ }
+ 
+-void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict,
++void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict,
+                                     int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct) {
+     if (VideoContext.Parser) {
+         uint8_t *OB;
+@@ -330,8 +330,8 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+         av_parser_parse2(VideoContext.Parser,
+             VideoContext.CodecContext,
+             &OB, &OBSize,
+-            pkt.data, pkt.size,
+-            pkt.pts, pkt.dts, pkt.pos);
++            pkt->data, pkt->size,
++            pkt->pts, pkt->dts, pkt->pos);
+ 
+         // H.264 (PAFF) and HEVC may have one field per packet, so we need to track
+         // when we have a full or half frame available, and mark one of them as
+@@ -351,15 +351,15 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+ 
+         *RepeatPict = VideoContext.Parser->repeat_pict;
+         *FrameType = VideoContext.Parser->pict_type;
+-        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt.flags & AV_PKT_FLAG_DISCARD));
++        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt->flags & AV_PKT_FLAG_DISCARD));
+     } else {
+-        *Invisible = !!(pkt.flags & AV_PKT_FLAG_DISCARD);
++        *Invisible = !!(pkt->flags & AV_PKT_FLAG_DISCARD);
+     }
+ 
+     if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP8)
+-        ParseVP8(pkt.data[0], Invisible, FrameType);
++        ParseVP8(pkt->data[0], Invisible, FrameType);
+     else if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP9)
+-        ParseVP9(pkt.data[0], Invisible, FrameType);
++        ParseVP9(pkt->data[0], Invisible, FrameType);
+ }
+ 
+ void FFMS_Indexer::Free() {
+@@ -458,32 +458,36 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+         }
+     }
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
+     std::vector<int64_t> LastValidTS(FormatContext->nb_streams, AV_NOPTS_VALUE);
+ 
+     int64_t filesize = avio_size(FormatContext->pb);
+     enum AVPictureStructure LastPicStruct = AV_PICTURE_STRUCTURE_UNKNOWN;
+-    while (av_read_frame(FormatContext, &Packet) >= 0) {
++    while (av_read_frame(FormatContext, Packet) >= 0) {
+         // Update progress
+         // FormatContext->pb can apparently be NULL when opening images.
+         if (IC && FormatContext->pb) {
+-            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate))
++            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate)) {
++                av_packet_free(&Packet);
+                 throw FFMS_Exception(FFMS_ERROR_CANCELLED, FFMS_ERROR_USER,
+                     "Cancelled by user");
++            }
+         }
+-        if (!IndexMask.count(Packet.stream_index)) {
+-            av_packet_unref(&Packet);
++        if (!IndexMask.count(Packet->stream_index)) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+-        int Track = Packet.stream_index;
++        int Track = Packet->stream_index;
+         FFMS_Track &TrackInfo = (*TrackIndices)[Track];
+-        bool KeyFrame = !!(Packet.flags & AV_PKT_FLAG_KEY);
++        bool KeyFrame = !!(Packet->flags & AV_PKT_FLAG_KEY);
+         ReadTS(Packet, LastValidTS[Track], (*TrackIndices)[Track].UseDTS);
+ 
+         if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            int64_t PTS = TrackInfo.UseDTS ? Packet.dts : Packet.pts;
++            int64_t PTS = TrackInfo.UseDTS ? Packet->dts : Packet->pts;
+             if (PTS == AV_NOPTS_VALUE) {
+                 // VPx alt-refs are output as packets which lack timestmps or durations, since
+                 // they are invisible. Currently, the timestamp mangling code in libavformat
+@@ -495,9 +499,11 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 // FFMS2 currently sorts packets by PTS, which will break decoding, otherwise.
+                 bool HasAltRefs = (FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP8 ||
+                                    FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP9);
+-                if (Packet.duration == 0 && !HasAltRefs)
++                if (Packet->duration == 0 && !HasAltRefs) {
++                    av_packet_free(&Packet);
+                     throw FFMS_Exception(FFMS_ERROR_INDEXING, FFMS_ERROR_PARSER,
+                         "Invalid packet pts, dts, and duration");
++                }
+ 
+                 if (TrackInfo.empty())
+                     PTS = 0;
+@@ -513,7 +519,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             ParseVideoPacket(AVContexts[Track], Packet, &RepeatPict, &FrameType, &Invisible, &LastPicStruct);
+ 
+             TrackInfo.AddVideoFrame(PTS, RepeatPict, KeyFrame,
+-                FrameType, Packet.pos, Invisible);
++                FrameType, Packet->pos, Invisible);
+         } else if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+             // For video seeking timestamps are used only if all packets have
+             // timestamps, while for audio they're used if any have timestamps,
+@@ -522,28 +528,29 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 TrackInfo.HasTS = true;
+ 
+             int64_t StartSample = AVContexts[Track].CurrentSample;
+-            uint32_t SampleCount = IndexAudioPacket(Track, &Packet, AVContexts[Track], *TrackIndices);
++            uint32_t SampleCount = IndexAudioPacket(Track, Packet, AVContexts[Track], *TrackIndices);
+             TrackInfo.SampleRate = AVContexts[Track].CodecContext->sample_rate;
+ 
+             TrackInfo.AddAudioFrame(LastValidTS[Track],
+-                StartSample, SampleCount, KeyFrame, Packet.pos, Packet.flags & AV_PKT_FLAG_DISCARD);
++                StartSample, SampleCount, KeyFrame, Packet->pos, Packet->flags & AV_PKT_FLAG_DISCARD);
+         }
+ 
+-        if (!(Packet.flags & AV_PKT_FLAG_DISCARD))
+-            TrackInfo.LastDuration = Packet.duration;
++        if (!(Packet->flags & AV_PKT_FLAG_DISCARD))
++            TrackInfo.LastDuration = Packet->duration;
+ 
+-        av_packet_unref(&Packet);
++        av_packet_unref(Packet);
+     }
++    av_packet_free(&Packet);
+ 
+     TrackIndices->Finalize(AVContexts, FormatContext->iformat->name);
+     return TrackIndices.release();
+ }
+ 
+-void FFMS_Indexer::ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS) {
+-    if (!UseDTS && Packet.pts != AV_NOPTS_VALUE)
+-        TS = Packet.pts;
++void FFMS_Indexer::ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS) {
++    if (!UseDTS && Packet->pts != AV_NOPTS_VALUE)
++        TS = Packet->pts;
+     if (TS == AV_NOPTS_VALUE)
+         UseDTS = true;
+-    if (UseDTS && Packet.dts != AV_NOPTS_VALUE)
+-        TS = Packet.dts;
++    if (UseDTS && Packet->dts != AV_NOPTS_VALUE)
++        TS = Packet->dts;
+ }
+diff --git a/src/core/indexing.h b/src/core/indexing.h
+index 3cfc3c3..5c06868 100644
+--- a/src/core/indexing.h
++++ b/src/core/indexing.h
+@@ -80,10 +80,10 @@ private:
+     int64_t Filesize;
+     uint8_t Digest[20];
+ 
+-    void ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS);
++    void ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS);
+     void CheckAudioProperties(int Track, AVCodecContext *Context);
+     uint32_t IndexAudioPacket(int Track, AVPacket *Packet, SharedAVContext &Context, FFMS_Index &TrackIndices);
+-    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
++    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
+     void Free();
+ public:
+     FFMS_Indexer(const char *Filename);
+diff --git a/src/core/utils.cpp b/src/core/utils.cpp
+index ce67533..8a2e997 100644
+--- a/src/core/utils.cpp
++++ b/src/core/utils.cpp
+@@ -62,12 +62,6 @@ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo) {
+     }
+ }
+ 
+-void InitNullPacket(AVPacket &pkt) {
+-    av_init_packet(&pkt);
+-    pkt.data = nullptr;
+-    pkt.size = 0;
+-}
+-
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames) {
+     AP.SampleFormat = static_cast<FFMS_SampleFormat>(av_get_packed_sample_fmt(CTX->sample_fmt));
+     AP.BitsPerSample = av_get_bytes_per_sample(CTX->sample_fmt) * 8;
+diff --git a/src/core/utils.h b/src/core/utils.h
+index 9819dc7..003ab79 100644
+--- a/src/core/utils.h
++++ b/src/core/utils.h
+@@ -58,7 +58,6 @@ std::unique_ptr<T> make_unique(Args&&... args) {
+ }
+ 
+ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo);
+-void InitNullPacket(AVPacket &pkt);
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames);
+ 
+ void LAVFOpenFile(const char *SourceFile, AVFormatContext *&FormatContext, int Track);
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index 06bd161..b889970 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -673,30 +673,34 @@ void FFMS_VideoSource::DecodeNextFrame(int64_t &AStartTime, int64_t &Pos) {
+     if (HasPendingDelayedFrames())
+         return;
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
+-
+-    while (ReadFrame(&Packet) >= 0) {
+-        if (Packet.stream_index != VideoTrack) {
+-            av_packet_unref(&Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++
++    while (ReadFrame(Packet) >= 0) {
++        if (Packet->stream_index != VideoTrack) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+         if (AStartTime < 0)
+-            AStartTime = Frames.UseDTS ? Packet.dts : Packet.pts;
++            AStartTime = Frames.UseDTS ? Packet->dts : Packet->pts;
+ 
+         if (Pos < 0)
+-            Pos = Packet.pos;
++            Pos = Packet->pos;
+ 
+-        bool FrameFinished = DecodePacket(&Packet);
+-        av_packet_unref(&Packet);
+-        if (FrameFinished)
++        bool FrameFinished = DecodePacket(Packet);
++        av_packet_unref(Packet);
++        if (FrameFinished) {
++            av_packet_free(&Packet);
+             return;
++        }
+     }
+ 
+     // Flush final frames
+-    InitNullPacket(Packet);
+-    DecodePacket(&Packet);
++    DecodePacket(Packet);
++    av_packet_free(&Packet);
+ }
+ 
+ bool FFMS_VideoSource::SeekTo(int n, int SeekOffset) {
+-- 
+2.40.0
+
+From bf9e03e9e08534c024e5a744a6437c4aac160201 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:20:47 +0100
+Subject: [PATCH 2/3] configure: Remove deprecated API use
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ configure.ac | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index b35ef80bc..d19714d0f 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -102,10 +102,10 @@ CFLAGS="$_CFLAGS $FFMPEG_CFLAGS"
+
+ AC_DEFUN([TEST_FFMPEG],
+          [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+-            #include <libavcodec/avcodec.h>
++            #include <libavformat/avformat.h>
+             #include <libswscale/swscale.h>
+             ]],[[
+-                avcodec_register_all();
++                avformat_network_init();
+                 swscale_version();
+             ]])], [eval $1=yes], [eval $1=no])
+         ])
+
diff --git a/srcpkgs/ffms2/template b/srcpkgs/ffms2/template
index 365f64d10cbab..1641ecf43be5b 100644
--- a/srcpkgs/ffms2/template
+++ b/srcpkgs/ffms2/template
@@ -1,7 +1,7 @@
 # Template file for 'ffms2'
 pkgname=ffms2
 version=2.40
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-shared --disable-static"
 hostmakedepends="pkg-config autoconf automake libtool"

From 712fd572598ac8899bc69ce389ec82c9a0ac5c82 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 032/115] freerdp: revbump for ffmpeg-6.0

---
 .../freerdp/patches/ffmpeg6_aa2cb9aa.patch    | 42 +++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100644 srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch

diff --git a/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
new file mode 100644
index 0000000000000..a4324da3a8822
--- /dev/null
+++ b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
@@ -0,0 +1,42 @@
+From aa2cb9aa5ff5562433598ba168a466e0752bca0e Mon Sep 17 00:00:00 2001
+From: akallabeth <akallabeth@posteo.net>
+Date: Tue, 14 Feb 2023 07:48:54 +0100
+Subject: [PATCH] Fixed #8686: Update h264 to use new FFMPEG API
+
+---
+ channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c | 2 ++
+ libfreerdp/codec/h264_ffmpeg.c            | 2 ++
+ 2 files changed, 4 insertions(+)
+
+diff --git a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+index 339462d865f..beea80b7a1e 100644
+--- a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
++++ b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+@@ -239,8 +239,10 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYP
+ 		}
+ 	}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 	if (mdecoder->codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		mdecoder->codec_context->flags |= AV_CODEC_FLAG_TRUNCATED;
++#endif
+ 
+ 	return TRUE;
+ }
+diff --git a/libfreerdp/codec/h264_ffmpeg.c b/libfreerdp/codec/h264_ffmpeg.c
+index 8a23db2473c..896a333019b 100644
+--- a/libfreerdp/codec/h264_ffmpeg.c
++++ b/libfreerdp/codec/h264_ffmpeg.c
+@@ -615,10 +615,12 @@ static BOOL libavcodec_init(H264_CONTEXT* h264)
+ 			goto EXCEPTION;
+ 		}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 		if (sys->codecDecoder->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		{
+ 			sys->codecDecoderContext->flags |= AV_CODEC_FLAG_TRUNCATED;
+ 		}
++#endif
+ 
+ #ifdef WITH_VAAPI
+ 

From 8d0e83a4a6f18ab3743526d11383d46742733eea Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 033/115] gerbera: revbump for ffmpeg-6.0

---
 srcpkgs/gerbera/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gerbera/template b/srcpkgs/gerbera/template
index ae14f35c767c0..2dc0ac0ce03b5 100644
--- a/srcpkgs/gerbera/template
+++ b/srcpkgs/gerbera/template
@@ -1,7 +1,7 @@
 # Template file for 'gerbera'
 pkgname=gerbera
 version=1.12.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_SYSTEMD=0 -DWITH_AVCODEC=1"
 hostmakedepends="pkg-config"

From 6879fa0c7872290cbca69fffab83b67ebd2adbfb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 034/115] goldendict: revbump for ffmpeg-6.0

---
 srcpkgs/goldendict/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/goldendict/template b/srcpkgs/goldendict/template
index f4a05759f693d..97f44347b03a6 100644
--- a/srcpkgs/goldendict/template
+++ b/srcpkgs/goldendict/template
@@ -1,7 +1,7 @@
 # Template file for 'goldendict'
 pkgname=goldendict
 version=1.5.0
-revision=1
+revision=2
 build_style=qmake
 configure_args="CONFIG+=zim_support goldendict.pro"
 hostmakedepends="qt5-qmake pkg-config qt5-host-tools"
@@ -10,7 +10,7 @@ makedepends="tiff-devel qt5-devel libvorbis-devel zlib-devel
  qt5-webkit-devel lzo-devel bzip2-devel libao-devel qt5-svg-devel
  libeb-devel qt5-x11extras-devel ffmpeg-devel liblzma-devel
  qt5-multimedia-devel"
-short_desc="A feature-rich dictionary lookup program"
+short_desc="Feature-rich dictionary lookup program"
 maintainer="John <me@johnnynator.dev>"
 license="GPL-3.0-or-later"
 homepage="http://goldendict.org/"

From 8912f1a982c58880829cce08110236af156d7cca Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 035/115] gst-libav: revbump for ffmpeg-6.0

---
 srcpkgs/gst-libav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index 37485f6f6a9e8..f610e966f23cd 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.22.5
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"

From 75152c4ac1748b01cdf402e576ea9e33eb59720d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 036/115] gst-rtsp-server: revbump for ffmpeg-6.0

---
 srcpkgs/gst-rtsp-server/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index f266f4777b3ea..011444eb26739 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
 version=1.22.5
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="glib-devel gst-plugins-bad1-devel gobject-introspection

From fbde44b2f773c251fb6fec6b11b7d50c4e42361b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 037/115] guvcview: update to 2.0.8.

---
 srcpkgs/guvcview/patches/fix-include.patch | 10 ++++++++++
 srcpkgs/guvcview/template                  |  7 +++----
 2 files changed, 13 insertions(+), 4 deletions(-)
 create mode 100644 srcpkgs/guvcview/patches/fix-include.patch

diff --git a/srcpkgs/guvcview/patches/fix-include.patch b/srcpkgs/guvcview/patches/fix-include.patch
new file mode 100644
index 0000000000000..503c2af3b78c1
--- /dev/null
+++ b/srcpkgs/guvcview/patches/fix-include.patch
@@ -0,0 +1,10 @@
+--- a/guvcview/guvcview.c
++++ b/guvcview/guvcview.c
+@@ -28,6 +28,7 @@
+ #include <sys/stat.h>
+ #include <sys/resource.h>
+ #include <errno.h>
++#include <locale.h>
+ 
+ #include "gview.h"
+ #include "gviewv4l2core.h"
diff --git a/srcpkgs/guvcview/template b/srcpkgs/guvcview/template
index d42fd38fa4ad1..86a7fd619612c 100644
--- a/srcpkgs/guvcview/template
+++ b/srcpkgs/guvcview/template
@@ -1,8 +1,7 @@
 # Template file for 'guvcview'
 pkgname=guvcview
-version=2.0.7
-revision=2
-create_wrksrc=yes
+version=2.0.8
+revision=1
 build_style=gnu-configure
 configure_args="--disable-static --disable-debian-menu"
 hostmakedepends="pkg-config intltool autoconf automake libtool glib-devel"
@@ -14,7 +13,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="http://guvcview.sourceforge.net/"
 distfiles="${SOURCEFORGE_SITE}/${pkgname}/${pkgname}-src-${version}.tar.bz2"
-checksum=f47d51fbd06e44eeaa1a82f4a153c927527c90d94514197a70b2956028cc8ad4
+checksum=a21f4e448286666cf27bafef5290cc953a0a1796b752e5bbe521266dc1230c81
 
 post_patch() {
 	sed '31a#include <locale.h>' -i  guvcview/guvcview.c

From e903a5f8b6189e0ff53fececdf2e6f2e094e7e43 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 038/115] handbrake: update to 1.6.1

---
 .../patches/fix-missing-x265-link-flag.patch    | 11 ++++++-----
 .../handbrake/patches/libhb-vpl-include.patch   | 15 +++++++++++++++
 srcpkgs/handbrake/template                      | 17 ++++++++++-------
 3 files changed, 31 insertions(+), 12 deletions(-)
 create mode 100644 srcpkgs/handbrake/patches/libhb-vpl-include.patch

diff --git a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
index 26db03867a0c8..d6bb2eda627a3 100644
--- a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
+++ b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
@@ -1,14 +1,15 @@
 --- a/gtk/configure.ac
 +++ b/gtk/configure.ac
 @@ -203,7 +203,7 @@
- 
+
  AM_CONDITIONAL([MINGW], [test "x$mingw_flag" = "xyes"])
- 
--HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg"
-+HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -ldl"
+
+-HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc"
++HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc -ldl"
  HB_CPPFLAGS="$HB_CPPFLAGS $HBINC"
- 
+
  PKG_CHECK_MODULES([x264], [x264], sys_x264=yes, sys_x264=no)
+
 --- a/test/module.defs
 +++ b/test/module.defs
 @@ -69,6 +69,9 @@
diff --git a/srcpkgs/handbrake/patches/libhb-vpl-include.patch b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
new file mode 100644
index 0000000000000..298f9f4ab28f2
--- /dev/null
+++ b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
@@ -0,0 +1,15 @@
+--- a/libhb/module.defs	2023-01-22 11:36:49.000000000 -0500
++++ b/libhb/module.defs	2023-04-03 22:37:52.395467010 -0400
+@@ -46,11 +46,7 @@
+ LIBHB.GCC.I += $(LIBHB.build/) $(CONTRIB.build/)include
+ 
+ ifeq (1,$(FEATURE.qsv))
+-    ifeq ($(HOST.system),freebsd))
+-        LIBHB.GCC.I += $(LOCALBASE)/include/vpl
+-    else
+-        LIBHB.GCC.I += $(CONTRIB.build/)include/vpl
+-    endif
++    LIBHB.GCC.I += /usr/include/vpl
+ endif
+ 
+ ifneq (,$(filter $(HOST.system),freebsd netbsd openbsd))
diff --git a/srcpkgs/handbrake/template b/srcpkgs/handbrake/template
index ca5e4571e49c3..c32cb1bfa31f4 100644
--- a/srcpkgs/handbrake/template
+++ b/srcpkgs/handbrake/template
@@ -1,10 +1,10 @@
 # Template file for 'handbrake'
 pkgname=handbrake
-version=1.5.1
+version=1.6.1
 revision=1
 build_style=gnu-configure
 configure_args="--force --disable-gtk-update-checks --disable-df-fetch --harden
- $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc)"
+ $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc) $(vopt_enable qsv)"
 make_build_args="-C ${XBPS_TRIPLET}"
 make_install_args="-C ${XBPS_TRIPLET}"
 hostmakedepends="automake cmake gettext-devel glib-devel intltool libtool m4 meson nasm pkg-config python3"
@@ -12,8 +12,11 @@ makedepends="bzip2-devel ffmpeg-devel gst-plugins-base1-devel gtk+3-devel
  jansson-devel lame-devel libass-devel libbluray-devel libdav1d-devel
  libdvdnav-devel libdvdread-devel libgudev-devel libnuma-devel
  libsamplerate-devel libtheora-devel libvorbis-devel libvpx-devel libxml2-devel
- opus-devel speex-devel x264-devel x265-devel zimg-devel
+ opus-devel speex-devel x264-devel x265-devel zimg-devel libsvt-av1-devel
  $(vopt_if fdk_aac fdk-aac-devel)
+ $(vopt_if qsv libva-devel)
+ $(vopt_if qsv libdrm-devel)
+ $(vopt_if qsv onevpl-devel)
  $(vopt_if nvenc nv-codec-headers)"
 depends="desktop-file-utils gst-plugins-good1 hicolor-icon-theme"
 short_desc="Multithreaded video transcoder"
@@ -21,15 +24,15 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-2.0-only"
 homepage="https://handbrake.fr/"
 distfiles="https://github.com/HandBrake/HandBrake/releases/download/${version}/HandBrake-${version}-source.tar.bz2"
-checksum=3999fe06d5309c819799a73a968a8ec3840e7840c2b64af8f5cdb7fd8c9430f0
+checksum=94ccfe03db917a91650000c510f7fd53f844da19f19ad4b4be1b8f6bc31a8d4c
 nocross=yes
 
-build_options="fdk_aac nvenc"
+build_options="fdk_aac nvenc qsv"
 
 case "$XBPS_TARGET_MACHINE" in
 	x86_64*|i686*)
 		CFLAGS="-msse"
-		build_options_default="nvenc"
+		build_options_default="nvenc qsv"
 		;;
 esac
 
@@ -37,7 +40,7 @@ pre_configure() {
 	# use system libraries, don't download them
 	rm -rf contrib/
 	for module in fdk-aac ffmpeg libbluray libdav1d libdvdnav libdvdread nvenc \
-		x265 zimg; do
+		x265 zimg svt-av1 libvpl; do
 	    vsed -i "/MODULES += contrib\/${module}/d" make/include/main.defs
 	done
 }

From fc3625379739d8e08010c62ac025c5540c1e9336 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 039/115] hedgewars: revbump for ffmpeg4-4.4.3

---
 srcpkgs/hedgewars/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/hedgewars/template b/srcpkgs/hedgewars/template
index 15a1df6d8861d..d1b7290bfdc19 100644
--- a/srcpkgs/hedgewars/template
+++ b/srcpkgs/hedgewars/template
@@ -1,13 +1,13 @@
 # Template file for 'hedgewars'
 pkgname=hedgewars
 version=1.0.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DNOSERVER=1 -DDATA_INSTALL_DIR=/usr/share/${pkgname}
  -DPHYSFS_SYSTEM=1 -DMINIMAL_FLAGS=1"
 make_cmd=make
 hostmakedepends="lua51 pkg-config qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
+makedepends="ffmpeg4-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
  SDL2_mixer-devel SDL2_net-devel SDL2_ttf-devel"
 depends="libfreeglut"
 short_desc="Funny turn-based artillery game, featuring fighting Hedgehogs!"

From 0aae7bc58d84b95bf5189e437d1d2f60cf397ed3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 040/115] idjc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/idjc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/idjc/template b/srcpkgs/idjc/template
index a9cde0665d55b..6f1d21c5781fd 100644
--- a/srcpkgs/idjc/template
+++ b/srcpkgs/idjc/template
@@ -5,7 +5,7 @@ revision=5
 build_style=gnu-configure
 hostmakedepends="pkg-config git python3 automake gettext-devel libtool"
 makedepends="libvorbis-devel libogg-devel jack-devel libsamplerate-devel
- libflac-devel libsndfile-devel mpg123-devel ffmpeg-devel speex-devel
+ libflac-devel libsndfile-devel mpg123-devel ffmpeg4-devel speex-devel
  glib-devel pixman-devel lame-devel python3-gobject-devel libshout-idjc-devel
  opus-devel twolame-devel python3-mutagen python3-devel"
 depends="python3-gobject python3-mutagen desktop-file-utils shared-mime-info python3-dbus jack"

From f33fd2d60b0e7d07be4d78fbea2f889ce24e11e6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 041/115] kfilemetadata5: revbump for ffmpeg-6.0

---
 srcpkgs/kfilemetadata5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kfilemetadata5/template b/srcpkgs/kfilemetadata5/template
index 00f7a98cf6399..e294ae5af947c 100644
--- a/srcpkgs/kfilemetadata5/template
+++ b/srcpkgs/kfilemetadata5/template
@@ -1,7 +1,7 @@
 # Template file for 'kfilemetadata5'
 pkgname=kfilemetadata5
 version=5.111.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="kcoreaddons extra-cmake-modules pkg-config qt5-host-tools qt5-qmake
  gettext kcoreaddons python3"

From 1c7cf7671dab16e80fae66f727326857296a41ba Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 042/115] kid3: revbump for ffmpeg-6.0

---
 srcpkgs/kid3/patches/ffmpeg5.patch | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 srcpkgs/kid3/patches/ffmpeg5.patch

diff --git a/srcpkgs/kid3/patches/ffmpeg5.patch b/srcpkgs/kid3/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..135fc50e07c9b
--- /dev/null
+++ b/srcpkgs/kid3/patches/ffmpeg5.patch
@@ -0,0 +1,17 @@
+# https://aur.archlinux.org/cgit/aur.git/diff/ffmpeg5.patch?h=kid3-cli&id=12410a74906612e7efc0ec8fbce739b4a0fef7e7
+diff --git a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+index e156d424..e12b9abd 100644
+--- a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
++++ b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+@@ -232,7 +232,11 @@ private:
+   friend class Format;
+   friend class Converter;
+   AVCodecContext* m_ptr;
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 0, 0)
+   AVCodec* m_impl;
++#else
++  const AVCodec* m_impl;
++#endif
+   AVFrame* m_frame;
+   bool m_opened;
+ };

From 83b8d68efac7cac0844a5201a171bc123aee74e2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 043/115] kodi: revbump for ffmpeg4-4.4.3

---
 srcpkgs/kodi/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kodi/template b/srcpkgs/kodi/template
index aa59324258a0d..6cf64dfb27294 100644
--- a/srcpkgs/kodi/template
+++ b/srcpkgs/kodi/template
@@ -54,7 +54,7 @@ makedepends="
  libmad-devel fontconfig-devel libXinerama-devel libsamplerate-devel libmms-devel
  enca-devel boost-devel libcurl-devel libva-devel libvdpau-devel libass-devel
  libbluetooth-devel yajl-devel libplist-devel librtmp-devel tinyxml-devel
- taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg-devel
+ taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg4-devel
  giflib-devel libxslt-devel gnutls-devel libssh-devel libmicrohttpd-devel
  libcec-devel dcadec-devel flatbuffers-devel fmt-devel lcms2-devel
  libfstrcmp-devel rapidjson libcdio-paranoia spdlog libwaylandpp-devel

From 919962ebdd77d07c3f359ae69715110352653d9a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 044/115] kpipewire: revbump for ffmpeg-6.0

---
 srcpkgs/kpipewire/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kpipewire/template b/srcpkgs/kpipewire/template
index b2d3d80c1dd1a..981c7b8890ded 100644
--- a/srcpkgs/kpipewire/template
+++ b/srcpkgs/kpipewire/template
@@ -1,7 +1,7 @@
 # Template file for 'kpipewire'
 pkgname=kpipewire
 version=5.27.9
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules plasma-wayland-protocols gettext
  qt5-qmake qt5-host-tools pkg-config wayland-devel kcoreaddons

From e70d760be3a554ed64fb129a0d5087a046db5ad9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 045/115] libextractor: revbump for ffmpeg4-4.4.3

---
 srcpkgs/libextractor/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libextractor/template b/srcpkgs/libextractor/template
index bfcea979a308c..fafd8dedbc34b 100644
--- a/srcpkgs/libextractor/template
+++ b/srcpkgs/libextractor/template
@@ -7,7 +7,7 @@ configure_args="--disable-static"
 hostmakedepends="pkg-config"
 makedepends="zlib-devel bzip2-devel exiv2-devel tiff-devel libpng-devel
  libjpeg-turbo-devel libvorbis-devel libflac-devel giflib-devel libmpeg2-devel
- ffmpeg-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
+ ffmpeg4-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
 short_desc="Library used to extract meta data from files"
 maintainer="Martin Riese <grauehaare@gmx.de>"
 license="GPL-3.0-or-later"

From 9050e28ed296a4007600ba24377c07f42510073c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 046/115] libopenal: revbump for ffmpeg-6.0

---
 srcpkgs/libopenal/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenal/template b/srcpkgs/libopenal/template
index 77218f9e539df..3f49ed75a1fdc 100644
--- a/srcpkgs/libopenal/template
+++ b/srcpkgs/libopenal/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenal'
 pkgname=libopenal
 version=1.22.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DALSOFT_EXAMPLES=OFF"
 hostmakedepends="pkg-config"

From c6d131566bbb8250710a87b0a18ffaf532557b09 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 047/115] loudgain: revbump for ffmpeg-6.0

---
 srcpkgs/loudgain/patches/ffmpeg5.patch | 11 +++++++++++
 srcpkgs/loudgain/template              |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/loudgain/patches/ffmpeg5.patch

diff --git a/srcpkgs/loudgain/patches/ffmpeg5.patch b/srcpkgs/loudgain/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..16d4510ee98fa
--- /dev/null
+++ b/srcpkgs/loudgain/patches/ffmpeg5.patch
@@ -0,0 +1,11 @@
+--- a/src/scan.c	2019-09-06 11:31:19.000000000 -0400
++++ b/src/scan.c	2023-03-23 11:15:40.867968521 -0400
+@@ -69,8 +69,6 @@
+ 	 * It is now useless
+ 	 * https://github.com/FFmpeg/FFmpeg/blob/70d25268c21cbee5f08304da95be1f647c630c15/doc/APIchanges#L86
+ 	 */
+-  if (avformat_version() < AV_VERSION_INT(58,9,100))
+-    av_register_all();
+ 
+ 	av_log_set_callback(scan_av_log);
+ 
diff --git a/srcpkgs/loudgain/template b/srcpkgs/loudgain/template
index da4f2d56e94c3..4d6bf29efb4fd 100644
--- a/srcpkgs/loudgain/template
+++ b/srcpkgs/loudgain/template
@@ -1,7 +1,7 @@
 # Template file for 'loudgain'
 pkgname=loudgain
 version=0.6.8
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libebur128-devel taglib-devel ffmpeg-devel"

From 84e8d5a5ac87291f574640378c07633865c701e8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 048/115] mediastreamer: revbump for ffmpeg4-4.4.3

---
 srcpkgs/mediastreamer/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mediastreamer/template b/srcpkgs/mediastreamer/template
index 0fcffa7653d18..92ada88743a9b 100644
--- a/srcpkgs/mediastreamer/template
+++ b/srcpkgs/mediastreamer/template
@@ -5,7 +5,7 @@ revision=2
 build_style=cmake
 configure_args="-DENABLE_STRICT=0 -DENABLE_UNIT_TESTS=0"
 hostmakedepends="python3"
-makedepends="bzrtp-devel ffmpeg-devel glew-devel libXv-devel libsrtp-devel
+makedepends="bzrtp-devel ffmpeg4-devel glew-devel libXv-devel libsrtp-devel
  libupnp-devel libvpx-devel mbedtls-devel opus-devel ortp-devel pulseaudio-devel
  libtheora-devel speex-devel v4l-utils-devel bcg729-devel bcmatroska2-devel libgsm-devel
  zxing-cpp-devel"

From 96551aeeddefc6ae6d4ae4474feb523906a15403 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 049/115] mgba: revbump for ffmpeg-6.0

---
 srcpkgs/mgba/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mgba/template b/srcpkgs/mgba/template
index 5513e3fd16f3f..f5c87a4893002 100644
--- a/srcpkgs/mgba/template
+++ b/srcpkgs/mgba/template
@@ -1,7 +1,7 @@
 # Template file for 'mgba'
 pkgname=mgba
 version=0.10.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake desktop-file-utils"
 makedepends="SDL2-devel ffmpeg-devel libedit-devel libepoxy-devel libmagick-devel

From 2e0a503b88e0fc3e6d7ff32c5f6912fc133ec9ab Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 050/115] mlt: revbump for ffmpeg4-4.4.3

---
 srcpkgs/mlt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mlt/template b/srcpkgs/mlt/template
index 73e3915aaab9a..ec5054be3b75e 100644
--- a/srcpkgs/mlt/template
+++ b/srcpkgs/mlt/template
@@ -8,7 +8,7 @@ configure_args="--prefix=/usr --libdir=/usr/lib$XBPS_TARGET_WORDSIZE
  --swig-languages=python"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which"
 # XXX: movit vid.stab
-makedepends="alsa-lib-devel ffmpeg-devel gtk+-devel jack-devel ladspa-sdk
+makedepends="alsa-lib-devel ffmpeg4-devel gtk+-devel jack-devel ladspa-sdk
  libexif-devel libsamplerate-devel libxml2-devel sox-devel SDL_image-devel
  fftw-devel frei0r-plugins python3-devel pulseaudio-devel movit-devel
  libvidstab-devel"

From a2bab62ddaa16af33041a9547701b426fe930d69 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 051/115] moc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/moc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/moc/template b/srcpkgs/moc/template
index 3a04932c8f1e6..d8de816026b64 100644
--- a/srcpkgs/moc/template
+++ b/srcpkgs/moc/template
@@ -4,7 +4,7 @@ version=2.5.2
 revision=7
 build_style=gnu-configure
 hostmakedepends="pkg-config"
-makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg-devel
+makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg4-devel
  jack-devel alsa-lib-devel libltdl-devel libflac-devel libvorbis-devel
  libmad-devel libmpcdec-devel libmodplug-devel libid3tag-devel faad2-devel
  taglib-devel libsndfile-devel wavpack-devel speex-devel libsamplerate-devel

From a8118bbcfd1cbc39a94ef9869b45b503f77dfdfe Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 052/115] motion: revbump for ffmpeg-6.0

---
 srcpkgs/motion/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/motion/template b/srcpkgs/motion/template
index 607ebeb3c7b24..bf63a91d9764f 100644
--- a/srcpkgs/motion/template
+++ b/srcpkgs/motion/template
@@ -1,7 +1,7 @@
 # Template file for 'motion'
 pkgname=motion
 version=4.6.0
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake pkg-config gettext-devel tar"
 makedepends="ffmpeg-devel libmicrohttpd-devel v4l-utils-devel gettext-devel"

From e81d29ebe1e75c62734bec3f9a34ed93bbcf86f0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 053/115] notcurses: revbump for ffmpeg-6.0

---
 srcpkgs/notcurses/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/notcurses/template b/srcpkgs/notcurses/template
index 6dd8a091319f7..3110c30c9aff2 100644
--- a/srcpkgs/notcurses/template
+++ b/srcpkgs/notcurses/template
@@ -1,7 +1,7 @@
 # Template file for 'notcurses'
 pkgname=notcurses
 version=3.0.9
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DUSE_STATIC=ON $(vopt_bool man USE_PANDOC)"
 hostmakedepends="pkg-config $(vopt_if man pandoc)"

From 7c7bf3abd0a8d87d718dc38e05e112cc22ab72b8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 054/115] olive: revbump for ffmpeg4-4.4.3

---
 srcpkgs/olive/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/olive/template b/srcpkgs/olive/template
index 12a46936c9900..5c2917b9c5124 100644
--- a/srcpkgs/olive/template
+++ b/srcpkgs/olive/template
@@ -1,10 +1,10 @@
 # Template file for 'olive'
 pkgname=olive
 version=0.1.2
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools pkg-config"
-makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg-devel frei0r-plugins"
+makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg4-devel frei0r-plugins"
 short_desc="Non-linear video editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"

From d10acfc23ffe6f744586daf4fef6ae430e80f43b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 055/115] omxplayer: revbump for ffmpeg4-4.4.3

---
 srcpkgs/omxplayer/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/omxplayer/template b/srcpkgs/omxplayer/template
index 9a66690c83ebb..a21b878878037 100644
--- a/srcpkgs/omxplayer/template
+++ b/srcpkgs/omxplayer/template
@@ -1,7 +1,7 @@
 # Template file for 'omxplayer'
 pkgname=omxplayer
 version=20190102
-revision=2
+revision=3
 short_desc="Commandline OMX player for the Raspberry Pi"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
@@ -15,7 +15,7 @@ checksum=af2d9450f8947842ea8c401fe9f71eec444013ebbdee29f2ac828c9c493c1329
 archs="armv6l* armv7l*"
 build_style=gnu-makefile
 hostmakedepends="ruby-ronn pkg-config"
-makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg-devel dbus-devel"
+makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg4-devel dbus-devel"
 depends="freefont-ttf"
 
 do_build() {

From 6f08f2583ff3004d25bdaabe608cfb5c2bbb325f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 056/115] opentoonz: revbump for ffmpeg-6.0

---
 srcpkgs/opentoonz/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/opentoonz/template b/srcpkgs/opentoonz/template
index ee9f7603f55fd..3e81834ca0edd 100644
--- a/srcpkgs/opentoonz/template
+++ b/srcpkgs/opentoonz/template
@@ -1,7 +1,7 @@
 # Template file for 'opentoonz'
 pkgname=opentoonz
 version=1.6.0
-revision=2
+revision=3
 build_wrksrc="toonz/sources"
 build_style=cmake
 make_cmd=make

From 93869e33e0a1433f97620ca3194396a8a007af1c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 057/115] pianobar: revbump for ffmpeg-6.0

---
 srcpkgs/pianobar/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pianobar/template b/srcpkgs/pianobar/template
index e3febb821a451..1e3dc1bf9308e 100644
--- a/srcpkgs/pianobar/template
+++ b/srcpkgs/pianobar/template
@@ -1,7 +1,7 @@
 # Template file for 'pianobar'
 pkgname=pianobar
 version=2022.04.01
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="V=1"
 hostmakedepends="pkg-config"

From 356346876c3a3c43eadde3bc6530ec71c0ce6231 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 058/115] ppsspp: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ppsspp/template | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/ppsspp/template b/srcpkgs/ppsspp/template
index 2c0ded496eb98..1294ef3ae669c 100644
--- a/srcpkgs/ppsspp/template
+++ b/srcpkgs/ppsspp/template
@@ -1,7 +1,7 @@
 # Template file for 'ppsspp'
 pkgname=ppsspp
 version=1.16.6
-revision=1
+revision=2
 _glslang_commit=b34f619e1c85810dcb3c578107d2e48ba4ee2b37
 _SPIRV_Cross_commit=4212eef67ed0ca048cb726a6767185504e7695e5
 _armips_commit=7bd1ec93d4586985ba1ef420b43b5e620f68695e
@@ -15,7 +15,7 @@ configure_args="-DHEADLESS=1 -DUSE_SYSTEM_FFMPEG=1 -DUNITTEST=ON
  -DUSING_QT_UI=$(vopt_if qt ON OFF) -DUSE_SYSTEM_ZSTD=ON
  -DARMIPS_USE_STD_FILESYSTEM=ON"
 hostmakedepends="pkg-config python3 $(vopt_if qt qt5-host-tools)"
-makedepends="zlib-devel glew-devel ffmpeg-devel libzip-devel
+makedepends="zlib-devel glew-devel ffmpeg4-devel libzip-devel
  snappy-devel rapidjson libpng-devel libzstd-devel
  $(vopt_if sdl2 'SDL2_ttf-devel SDL2-devel') $(vopt_if wayland wayland-devel)
  $(vopt_if qt 'qt5-devel qt5-multimedia-devel')"
@@ -72,7 +72,7 @@ post_extract() {
         mv ${wrksrc}/rcheevos-${_rcheevos_commit} ${wrksrc}/ext/rcheevos
 }
 
-post_patch(){
+post_patch() {
 	# disable git versioning
 	vsed -e 's|find_package(Git)|# &|' -i git-version.cmake
 }
@@ -85,7 +85,6 @@ post_configure() {
 }
 
 do_install() {
-	vlicense LICENSE.TXT
 	vinstall icons/icon.svg 644 usr/share/pixmaps ppsspp.svg
 	vinstall Qt/PPSSPP.desktop 644 usr/share/applications
 	vbin build/PPSSPPHeadless ppsspp-headless

From 74a6cfdd6f04d8ee536ba1fae00dc781ad175695 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 059/115] pqiv: revbump for ffmpeg-6.0

---
 srcpkgs/pqiv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pqiv/template b/srcpkgs/pqiv/template
index 542fc27a2d32a..9308d949b6a1c 100644
--- a/srcpkgs/pqiv/template
+++ b/srcpkgs/pqiv/template
@@ -1,7 +1,7 @@
 # Template file for 'pqiv'
 pkgname=pqiv
 version=2.12
-revision=1
+revision=2
 build_style=gnu-makefile
 hostmakedepends="pkg-config"
 makedepends="glib-devel gtk+3-devel $(vopt_if ffmpeg ffmpeg-devel)

From 60020eebaf7d4862c9124179fc1ef915923e0303 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 060/115] qmmp: revbump for ffmpeg-6.0

---
 srcpkgs/qmmp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qmmp/template b/srcpkgs/qmmp/template
index 53781ea3bc28a..2da07f1e87eac 100644
--- a/srcpkgs/qmmp/template
+++ b/srcpkgs/qmmp/template
@@ -1,7 +1,7 @@
 # Template file for 'qmmp'
 pkgname=qmmp
 version=1.6.1
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DUSE_HAL:BOOL=FALSE -DQMMP_DEFAULT_UI:STRING=simple"
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From 207139777ed75f6292ddf088f59f6b996c7e3e26 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 061/115] qt5-webengine: update to 5.15.13

---
 .../chromium-media-filters-cpp14.patch        |  11 ++
 srcpkgs/qt5-webengine/patches/ffmpeg5.patch   | 179 ++++++++++++++++++
 srcpkgs/qt5-webengine/template                |  10 +-
 3 files changed, 195 insertions(+), 5 deletions(-)
 create mode 100644 srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/ffmpeg5.patch

diff --git a/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
new file mode 100644
index 0000000000000..04adc540f2cbc
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
@@ -0,0 +1,11 @@
+--- a/src/3rdparty/chromium/media/filters/BUILD.gn	2023-02-27 13:32:59.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/BUILD.gn	2023-04-02 17:21:39.204066384 -0400
+@@ -96,6 +96,8 @@
+     "//ui/gfx/geometry:geometry",
+   ]
+ 
++  cflags_cc = [ "-std=c++14" ]
++
+   libs = []
+ 
+   if (proprietary_codecs) {
diff --git a/srcpkgs/qt5-webengine/patches/ffmpeg5.patch b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..ac55e1634423a
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
@@ -0,0 +1,179 @@
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:57.732547446 -0400
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:09.486478995 -0400
+@@ -57,6 +57,8 @@
+ 
+ namespace {
+ 
++constexpr int64_t kRelativeTsBase = static_cast<int64_t>(0x7ffeffffffffffff);
++
+ void SetAVStreamDiscard(AVStream* stream, AVDiscard discard) {
+   DCHECK(stream);
+   stream->discard = discard;
+@@ -90,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+   if (stream->start_time != kNoFFmpegTimestamp)
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (stream->first_dts != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, stream->first_dts);
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -408,11 +398,11 @@
+   scoped_refptr<DecoderBuffer> buffer;
+ 
+   if (type() == DemuxerStream::TEXT) {
+-    int id_size = 0;
++    size_t id_size = 0;
+     uint8_t* id_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
+ 
+-    int settings_size = 0;
++    size_t settings_size = 0;
+     uint8_t* settings_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
+ 
+@@ -424,7 +414,7 @@
+     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
+                                      side_data.data(), side_data.size());
+   } else {
+-    int side_data_size = 0;
++    size_t side_data_size = 0;
+     uint8_t* side_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
+ 
+@@ -485,7 +475,7 @@
+                                        packet->size - data_offset);
+     }
+ 
+-    int skip_samples_size = 0;
++    size_t skip_samples_size = 0;
+     const uint32_t* skip_samples_ptr =
+         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
+             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
+@@ -1587,6 +1577,8 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++      continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+       lowest_start_time_stream = stream.get();
+@@ -1604,6 +1596,8 @@
+     if (stream && stream->type() == DemuxerStream::VIDEO &&
+         stream->IsEnabled()) {
+       video_stream = stream.get();
++      if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++        continue;
+       if (video_stream->start_time() <= seek_time) {
+         return video_stream;
+       }
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h qtwebengine-5.15.10/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h
+--- a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-07-11 22:12:47.917192788 -0500
+@@ -29,6 +29,7 @@ extern "C" {
+ #include <libavformat/avformat.h>
+ #include <libavformat/avio.h>
+ #include <libavutil/avutil.h>
++#include <libavutil/channel_layout.h>
+ #include <libavutil/imgutils.h>
+ #include <libavutil/log.h>
+ #include <libavutil/mastering_display_metadata.h>
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/audio_file_reader.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/audio_file_reader.cc
+--- a/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -85,7 +85,7 @@ bool AudioFileReader::OpenDemuxer() {
+ }
+ 
+ bool AudioFileReader::OpenDecoder() {
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (codec) {
+     // MP3 decodes to S16P which we don't support, tell it to use S16 instead.
+     if (codec_context_->sample_fmt == AV_SAMPLE_FMT_S16P)
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -329,7 +329,7 @@ bool FFmpegAudioDecoder::ConfigureDecode
+     }
+   }
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec ||
+       avcodec_open2(codec_context_.get(), codec, &codec_options) < 0) {
+     DLOG(ERROR) << "Could not initialize audio decoder: "
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -59,7 +59,6 @@ static int64_t AVIOSeekOperation(void* o
+ }
+ 
+ void FFmpegGlue::InitializeFFmpeg() {
+-  av_register_all();
+ }
+ 
+ static void LogContainer(bool is_local_file,
+@@ -95,9 +94,6 @@ FFmpegGlue::FFmpegGlue(FFmpegURLProtocol
+   // Enable fast, but inaccurate seeks for MP3.
+   format_context_->flags |= AVFMT_FLAG_FAST_SEEK;
+ 
+-  // Ensures we can read out various metadata bits like vp8 alpha.
+-  format_context_->flags |= AVFMT_FLAG_KEEP_SIDE_DATA;
+-
+   // Ensures format parsing errors will bail out. From an audit on 11/2017, all
+   // instances were real failures. Solves bugs like http://crbug.com/710791.
+   format_context_->error_recognition |= AV_EF_EXPLODE;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -391,7 +391,7 @@ bool FFmpegVideoDecoder::ConfigureDecode
+   if (decode_nalus_)
+     codec_context_->flags2 |= AV_CODEC_FLAG2_CHUNKS;
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
+     ReleaseFFmpegResources();
+     return false;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/media_file_checker.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/media_file_checker.cc
+--- a/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -68,7 +68,7 @@ bool MediaFileChecker::Start(base::TimeD
+       auto context = AVStreamToAVCodecContext(format_context->streams[i]);
+       if (!context)
+         continue;
+-      AVCodec* codec = avcodec_find_decoder(cp->codec_id);
++      const AVCodec* codec = avcodec_find_decoder(cp->codec_id);
+       if (codec && avcodec_open2(context.get(), codec, nullptr) >= 0) {
+         auto loop = std::make_unique<FFmpegDecodingLoop>(context.get());
+         stream_contexts[i] = {std::move(context), std::move(loop)};
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc qtwebengine-5.15.10/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc
+--- a/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -203,7 +203,7 @@ int32_t H264DecoderImpl::InitDecode(cons
+   // a pointer |this|.
+   av_context_->opaque = this;
+ 
+-  AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
+   if (!codec) {
+     // This is an indication that FFmpeg has not been initialized or it has not
+     // been compiled/initialized with the correct set of codecs.
diff --git a/srcpkgs/qt5-webengine/template b/srcpkgs/qt5-webengine/template
index 84de5b12ecdda..b89fe4c1ad50a 100644
--- a/srcpkgs/qt5-webengine/template
+++ b/srcpkgs/qt5-webengine/template
@@ -1,9 +1,9 @@
 # Template file for 'qt5-webengine'
 pkgname=qt5-webengine
-version=5.15.11
-revision=5
+version=5.15.13
+revision=1
 _version="${version}-lts"
-_chromium_commit=be349eaf62e77955791d7bf29f893f1e8a37daf4
+_chromium_commit=e48df7803c7c98b0b2471c94057d32e44a301ad5
 archs="x86_64* i686* armv[67]* ppc64* aarch64*"
 create_wrksrc=yes
 build_style=qmake
@@ -32,8 +32,8 @@ license="GPL-3.0-or-later, LGPL-3.0-or-later"
 homepage="https://qt.io/"
 distfiles="https://github.com/qt/qtwebengine/archive/v${_version}.tar.gz
  https://github.com/qt/qtwebengine-chromium/archive/${_chromium_commit}.tar.gz"
-checksum="aa7466356c450c5f5870f979b93cd7e7e62da1165c328ffcab1a9928db18ad67
- 6f47ed8ab8cc062411f6f206da6353bc8263d6ed6d6290c689a05c01d91f646b"
+checksum="4b59838ed75ef788b59e1e412535a0e42dd9d311661fdeadb191b581ba815c63
+ a91686562b1d4e8b220e0bbcbab5feb64630e2de974b35ac034bf388af771a6c"
 
 no_generic_pkgconfig_link=yes
 build_options="sndio pipewire"

From 8d589f3068ced5636dbd6cb582ccff9a0c63dc73 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 062/115] qt5: update to 5.15.8

---
 ...erywhere-opensource-src-5.15.8-kf5-1.patch | 12913 ++++++++++++++++
 srcpkgs/qt5/template                          |    13 +-
 2 files changed, 12919 insertions(+), 7 deletions(-)
 create mode 100644 srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch

diff --git a/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch b/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch
new file mode 100644
index 0000000000000..966c98bcd3bb1
--- /dev/null
+++ b/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch
@@ -0,0 +1,12913 @@
+Submitted By:            Pierre Labastie <pierre_dot_labastie_at_neuf_dot_fr>
+Date:                    2023-01-05
+Initial Package Version: 5.15.8
+Upstream Status:         Applied (according to KDE)
+Origin:                  KDE patch set
+Description:             Patch set maintained by the KDE folks
+see https://dot.kde.org/2021/04/06/announcing-kdes-qt-5-patch-collection
+Patch generated using the procedure in
+https://wiki.linuxfromscratch.org/blfs/ticket/17476#comment:3
+
+Submodule qtbase 4ee4fc18..9cf586d6:
+diff --git a/qtbase/mkspecs/common/android/qplatformdefs.h b/qtbase/mkspecs/common/android/qplatformdefs.h
+index f75bc4093b..2bd59410d4 100644
+--- a/qtbase/mkspecs/common/android/qplatformdefs.h
++++ b/qtbase/mkspecs/common/android/qplatformdefs.h
+@@ -144,11 +144,7 @@
+ #define QT_SIGNAL_ARGS          int
+ #define QT_SIGNAL_IGNORE        SIG_IGN
+ 
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+ #define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+ 
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+diff --git a/qtbase/mkspecs/features/mac/sdk.mk b/qtbase/mkspecs/features/mac/sdk.mk
+index f30b5830b4..a32ceacb6c 100644
+--- a/qtbase/mkspecs/features/mac/sdk.mk
++++ b/qtbase/mkspecs/features/mac/sdk.mk
+@@ -1,6 +1,6 @@
+ 
+ ifeq ($(QT_MAC_SDK_NO_VERSION_CHECK),)
+-    CHECK_SDK_COMMAND = /usr/bin/xcrun --sdk $(EXPORT_QMAKE_MAC_SDK) -show-sdk-version 2>&1
++    CHECK_SDK_COMMAND = /usr/bin/xcrun --sdk $(EXPORT_QMAKE_MAC_SDK) -show-sdk-version 2>/dev/null
+     CURRENT_MAC_SDK_VERSION := $(shell DEVELOPER_DIR=$(EXPORT_QMAKE_XCODE_DEVELOPER_PATH) $(CHECK_SDK_COMMAND))
+     ifneq ($(CURRENT_MAC_SDK_VERSION),$(EXPORT_QMAKE_MAC_SDK_VERSION))
+         # We don't want to complain about out of date SDK unless the target needs to be remade.
+diff --git a/qtbase/mkspecs/linux-clang/qplatformdefs.h b/qtbase/mkspecs/linux-clang/qplatformdefs.h
+index a818d973f0..c1ab72fbc6 100644
+--- a/qtbase/mkspecs/linux-clang/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-clang/qplatformdefs.h
+@@ -79,14 +79,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-g++/qplatformdefs.h b/qtbase/mkspecs/linux-g++/qplatformdefs.h
+index 13523f0702..4d2750d9ec 100644
+--- a/qtbase/mkspecs/linux-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-g++/qplatformdefs.h
+@@ -79,14 +79,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ < 2)
+-#define QT_SOCKLEN_T            int
+-#else
+-#define QT_SOCKLEN_T            socklen_t
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-llvm/qplatformdefs.h b/qtbase/mkspecs/linux-llvm/qplatformdefs.h
+index dc750ab1ef..d3cc39b47f 100644
+--- a/qtbase/mkspecs/linux-llvm/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-llvm/qplatformdefs.h
+@@ -80,14 +80,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h b/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
+index 4c4e53da2a..83baffb3e3 100644
+--- a/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
+@@ -85,16 +85,9 @@
+ #include "../common/posix/qplatformdefs.h"
+ 
+ #undef QT_OPEN_LARGEFILE
+-#undef QT_SOCKLEN_T
+ 
+ #define QT_OPEN_LARGEFILE       0
+ 
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #ifndef SIOCGIFBRDADDR
+ #  define SIOCGIFBRDADDR 0x8919
+ #endif
+diff --git a/qtbase/mkspecs/lynxos-g++/qplatformdefs.h b/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
+index 4339ea2b23..6007af0055 100644
+--- a/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
+@@ -72,14 +72,6 @@
+ 
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp b/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
+index c3c184258f..32af3f8f29 100644
+--- a/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
++++ b/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
+@@ -10,6 +10,7 @@
+ #include "libANGLE/HandleAllocator.h"
+ 
+ #include <algorithm>
++#include <limits>
+ 
+ #include "common/debug.h"
+ 
+diff --git a/qtbase/src/3rdparty/forkfd/forkfd_linux.c b/qtbase/src/3rdparty/forkfd/forkfd_linux.c
+index ffe0e9a5e2..b1f5408d11 100644
+--- a/qtbase/src/3rdparty/forkfd/forkfd_linux.c
++++ b/qtbase/src/3rdparty/forkfd/forkfd_linux.c
+@@ -82,7 +82,8 @@ static int sys_clone(unsigned long cloneflags, int *ptid)
+     return syscall(__NR_clone, cloneflags, child_stack, stack_size, ptid, newtls, ctid);
+ #elif defined(__arc__) || defined(__arm__) || defined(__aarch64__) || defined(__mips__) || \
+     defined(__nds32__) || defined(__hppa__) || defined(__powerpc__) || defined(__i386__) || \
+-    defined(__x86_64__) || defined(__xtensa__) || defined(__alpha__) || defined(__riscv)
++    defined(__x86_64__) || defined(__xtensa__) || defined(__alpha__) || defined(__riscv) || \
++    defined(__loongarch__)
+     /* ctid and newtls are inverted on CONFIG_CLONE_BACKWARDS architectures,
+      * but since both values are 0, there's no harm. */
+     return syscall(__NR_clone, cloneflags, child_stack, ptid, ctid, newtls);
+diff --git a/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java b/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
+index 5792b5b2f5..2f74750fcf 100644
+--- a/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
++++ b/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
+@@ -116,6 +116,7 @@ public class QtNative
+     public static QtThread m_qtThread = new QtThread();
+     private static HashMap<String, Uri> m_cachedUris = new HashMap<String, Uri>();
+     private static ArrayList<String> m_knownDirs = new ArrayList<String>();
++    private static final String NoPermissionErrorMessage = "No permissions to open Uri";
+ 
+     private static final Runnable runPendingCppRunnablesRunnable = new Runnable() {
+         @Override
+@@ -193,11 +194,10 @@ public class QtNative
+                     return iterUri;
+             }
+ 
+-            // Android 6 and earlier could still manage to open the file so we can return the
+-            // parsed uri here
+-            if (Build.VERSION.SDK_INT < 24)
+-                return parsedUri;
+-            return null;
++            // if we only have transient permissions on uri all the above will fail,
++            // but we will be able to read the file anyway, so continue with uri here anyway
++            // and check for SecurityExceptions later
++            return parsedUri;
+         } catch (SecurityException e) {
+             e.printStackTrace();
+             return null;
+@@ -244,7 +244,7 @@ public class QtNative
+         int error = -1;
+ 
+         if (uri == null) {
+-            Log.e(QtTAG, "openFdForContentUrl(): No permissions to open Uri");
++            Log.e(QtTAG, "openFdForContentUrl(): " + NoPermissionErrorMessage);
+             return error;
+         }
+ 
+@@ -254,12 +254,13 @@ public class QtNative
+             return fdDesc.detachFd();
+         } catch (FileNotFoundException e) {
+             e.printStackTrace();
+-            return error;
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "openFdForContentUrl(): Invalid Uri");
+             e.printStackTrace();
+-            return error;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return error;
+     }
+ 
+     public static long getSize(Context context, String contentUrl)
+@@ -270,7 +271,7 @@ public class QtNative
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+ 
+         if (uri == null) {
+-            Log.e(QtTAG, "getSize(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return size;
+         } else if (!m_cachedUris.containsKey(contentUrl)) {
+             m_cachedUris.put(contentUrl, uri);
+@@ -288,12 +289,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "getSize(): Invalid Uri");
+             e.printStackTrace();
+-            return size;
+         }  catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "getSize(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return size;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return size;
+     }
+ 
+     public static boolean checkFileExists(Context context, String contentUrl)
+@@ -303,7 +305,7 @@ public class QtNative
+         if (uri == null)
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+         if (uri == null) {
+-            Log.e(QtTAG, "checkFileExists(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return exists;
+         } else {
+             if (!m_cachedUris.containsKey(contentUrl))
+@@ -321,12 +323,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "checkFileExists(): Invalid Uri");
+             e.printStackTrace();
+-            return exists;
+         } catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "checkFileExists(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return false;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return exists;
+     }
+ 
+     public static boolean checkIfWritable(Context context, String contentUrl)
+@@ -344,7 +347,7 @@ public class QtNative
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+         }
+         if (uri == null) {
+-            Log.e(QtTAG, "isDir(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return isDir;
+         } else {
+             if (!m_cachedUris.containsKey(contentUrl))
+@@ -374,12 +377,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "checkIfDir(): Invalid Uri");
+             e.printStackTrace();
+-            return false;
+         } catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "checkIfDir(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return false;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return false;
+     }
+     public static String[] listContentsFromTreeUri(Context context, String contentUrl)
+     {
+diff --git a/qtbase/src/concurrent/qtconcurrentreducekernel.h b/qtbase/src/concurrent/qtconcurrentreducekernel.h
+index 8f9a938952..a98dedef2e 100644
+--- a/qtbase/src/concurrent/qtconcurrentreducekernel.h
++++ b/qtbase/src/concurrent/qtconcurrentreducekernel.h
+@@ -212,11 +212,13 @@ public:
+ 
+     inline bool shouldThrottle()
+     {
++        std::lock_guard<QMutex> locker(mutex);
+         return (resultsMapSize > (ReduceQueueThrottleLimit * threadCount));
+     }
+ 
+     inline bool shouldStartThread()
+     {
++        std::lock_guard<QMutex> locker(mutex);
+         return (resultsMapSize <= (ReduceQueueStartLimit * threadCount));
+     }
+ };
+diff --git a/qtbase/src/concurrent/qtconcurrentthreadengine.cpp b/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
+index ea6ce3ac42..7f91a2ba68 100644
+--- a/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
++++ b/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
+@@ -176,6 +176,39 @@ void ThreadEngineBase::startSingleThreaded()
+     finish();
+ }
+ 
++void ThreadEngineBase::startBlocking()
++{
++    start();
++    barrier.acquire();
++    startThreads();
++
++    bool throttled = false;
++#ifndef QT_NO_EXCEPTIONS
++    try {
++#endif
++        while (threadFunction() == ThrottleThread) {
++            if (threadThrottleExit()) {
++                throttled = true;
++                break;
++            }
++        }
++#ifndef QT_NO_EXCEPTIONS
++    } catch (QException &e) {
++        handleException(e);
++    } catch (...) {
++        handleException(QUnhandledException());
++    }
++#endif
++
++    if (throttled == false) {
++        barrier.release();
++    }
++
++    barrier.wait();
++    finish();
++    exceptionStore.throwPossibleException();
++}
++
+ void ThreadEngineBase::startThread()
+ {
+     startThreadInternal();
+diff --git a/qtbase/src/concurrent/qtconcurrentthreadengine.h b/qtbase/src/concurrent/qtconcurrentthreadengine.h
+index 7c30cebdbc..a4c8548cc4 100644
+--- a/qtbase/src/concurrent/qtconcurrentthreadengine.h
++++ b/qtbase/src/concurrent/qtconcurrentthreadengine.h
+@@ -91,6 +91,7 @@ public:
+     ThreadEngineBase();
+     virtual ~ThreadEngineBase();
+     void startSingleThreaded();
++    void startBlocking();
+     void startThread();
+     bool isCanceled();
+     void waitForResume();
+@@ -143,6 +144,15 @@ public:
+         return result();
+     }
+ 
++    // Runs the user algorithm using multiple threads.
++    // This function blocks until the algorithm is finished,
++    // and then returns the result.
++    T *startBlocking()
++    {
++        ThreadEngineBase::startBlocking();
++        return result();
++    }
++
+     // Runs the user algorithm using multiple threads.
+     // Does not block, returns a future.
+     QFuture<T> startAsynchronously()
+@@ -223,6 +233,13 @@ class ThreadEngineStarter : public ThreadEngineStarterBase<T>
+ public:
+     ThreadEngineStarter(TypedThreadEngine *eng)
+         : Base(eng) { }
++
++    T startBlocking()
++    {
++        T t = *this->threadEngine->startBlocking();
++        delete this->threadEngine;
++        return t;
++    }
+ };
+ 
+ // Full template specialization where T is void.
+@@ -232,6 +249,12 @@ class ThreadEngineStarter<void> : public ThreadEngineStarterBase<void>
+ public:
+     ThreadEngineStarter(ThreadEngine<void> *_threadEngine)
+         : ThreadEngineStarterBase<void>(_threadEngine) {}
++
++    void startBlocking()
++    {
++        this->threadEngine->startBlocking();
++        delete this->threadEngine;
++    }
+ };
+ 
+ //! [qtconcurrentthreadengine-1]
+diff --git a/qtbase/src/corelib/animation/qvariantanimation.cpp b/qtbase/src/corelib/animation/qvariantanimation.cpp
+index 98b02f0202..eac1524107 100644
+--- a/qtbase/src/corelib/animation/qvariantanimation.cpp
++++ b/qtbase/src/corelib/animation/qvariantanimation.cpp
+@@ -276,7 +276,9 @@ void QVariantAnimationPrivate::setCurrentValueForProgress(const qreal progress)
+ 
+     const qreal startProgress = currentInterval.start.first;
+     const qreal endProgress = currentInterval.end.first;
+-    const qreal localProgress = (progress - startProgress) / (endProgress - startProgress);
++    const qreal localProgress =
++            qIsNull(progress - startProgress) ? 0.0 // avoid 0/0 below
++            /* else */                        : (progress - startProgress) / (endProgress - startProgress);
+ 
+     QVariant ret = q->interpolated(currentInterval.start.second,
+                                    currentInterval.end.second,
+diff --git a/qtbase/src/corelib/global/qnamespace.h b/qtbase/src/corelib/global/qnamespace.h
+index ad4150b317..bf19b1627b 100644
+--- a/qtbase/src/corelib/global/qnamespace.h
++++ b/qtbase/src/corelib/global/qnamespace.h
+@@ -1864,7 +1864,7 @@ public:
+     QT_Q_ENUM(TimerType)
+     QT_Q_ENUM(ScrollPhase)
+     QT_Q_ENUM(MouseEventSource)
+-    QT_Q_FLAG(MouseEventFlag)
++    QT_Q_FLAG(MouseEventFlags)
+     QT_Q_ENUM(ChecksumType)
+     QT_Q_ENUM(HighDpiScaleFactorRoundingPolicy)
+     QT_Q_ENUM(TabFocusBehavior)
+diff --git a/qtbase/src/corelib/global/qrandom.cpp b/qtbase/src/corelib/global/qrandom.cpp
+index 10672c1f92..25f87c7e6a 100644
+--- a/qtbase/src/corelib/global/qrandom.cpp
++++ b/qtbase/src/corelib/global/qrandom.cpp
+@@ -383,7 +383,6 @@ struct QRandomGenerator::SystemAndGlobalGenerators
+ 
+         constexpr SystemAndGlobalGenerators g = {};
+         Q_UNUSED(g);
+-        Q_STATIC_ASSERT(std::is_literal_type<SystemAndGlobalGenerators>::value);
+ #endif
+     }
+ 
+diff --git a/qtbase/src/corelib/io/qbuffer.cpp b/qtbase/src/corelib/io/qbuffer.cpp
+index 595fcd2724..032c0ddd4b 100644
+--- a/qtbase/src/corelib/io/qbuffer.cpp
++++ b/qtbase/src/corelib/io/qbuffer.cpp
+@@ -41,6 +41,8 @@
+ #include <QtCore/qmetaobject.h>
+ #include "private/qiodevice_p.h"
+ 
++#include <limits>
++
+ QT_BEGIN_NAMESPACE
+ 
+ /** QBufferPrivate **/
+@@ -366,7 +368,9 @@ qint64 QBuffer::size() const
+ bool QBuffer::seek(qint64 pos)
+ {
+     Q_D(QBuffer);
+-    if (pos > d->buf->size() && isWritable()) {
++    const auto oldBufSize = d->buf->size();
++    constexpr qint64 MaxSeekPos = (std::numeric_limits<decltype(oldBufSize)>::max)();
++    if (pos <= MaxSeekPos && pos > oldBufSize && isWritable()) {
+         if (seek(d->buf->size())) {
+             const qint64 gapSize = pos - d->buf->size();
+             if (write(QByteArray(gapSize, 0)) != gapSize) {
+@@ -377,7 +381,7 @@ bool QBuffer::seek(qint64 pos)
+             return false;
+         }
+     } else if (pos > d->buf->size() || pos < 0) {
+-        qWarning("QBuffer::seek: Invalid pos: %d", int(pos));
++        qWarning("QBuffer::seek: Invalid pos: %lld", pos);
+         return false;
+     }
+     return QIODevice::seek(pos);
+diff --git a/qtbase/src/corelib/io/qfilesystemengine_win.cpp b/qtbase/src/corelib/io/qfilesystemengine_win.cpp
+index 81d3a71986..c86ed1f9b0 100644
+--- a/qtbase/src/corelib/io/qfilesystemengine_win.cpp
++++ b/qtbase/src/corelib/io/qfilesystemengine_win.cpp
+@@ -664,14 +664,14 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry)
+     return QFileSystemEntry(ret, QFileSystemEntry::FromInternalPath());
+ }
+ 
+-#if defined(Q_CC_MINGW) && WINVER < 0x0602 //  Windows 8 onwards
++#if defined(Q_CC_MINGW) && WINVER < 0x0602 && _WIN32_WINNT < _WIN32_WINNT_WIN8 //  Windows 8 onwards
+ 
+ typedef struct _FILE_ID_INFO {
+     ULONGLONG VolumeSerialNumber;
+     FILE_ID_128 FileId;
+ } FILE_ID_INFO, *PFILE_ID_INFO;
+ 
+-#endif // if defined (Q_CC_MINGW) && WINVER < 0x0602
++#endif // if defined(Q_CC_MINGW) && WINVER < 0x0602 && _WIN32_WINNT < _WIN32_WINNT_WIN8
+ 
+ // File ID for Windows up to version 7 and FAT32 drives
+ static inline QByteArray fileId(HANDLE handle)
+diff --git a/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp b/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
+index 94d9d06bcb..27e0b13b0b 100644
+--- a/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
++++ b/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
+@@ -366,7 +366,9 @@ void QInotifyFileSystemWatcherEngine::readFromInotify()
+     // qDebug("QInotifyFileSystemWatcherEngine::readFromInotify");
+ 
+     int buffSize = 0;
+-    ioctl(inotifyFd, FIONREAD, (char *) &buffSize);
++    if (ioctl(inotifyFd, FIONREAD, (char *) &buffSize) == -1 || buffSize == 0)
++        return;
++
+     QVarLengthArray<char, 4096> buffer(buffSize);
+     buffSize = read(inotifyFd, buffer.data(), buffSize);
+     char *at = buffer.data();
+diff --git a/qtbase/src/corelib/io/qlockfile_win.cpp b/qtbase/src/corelib/io/qlockfile_win.cpp
+index 277f8d4230..38ecef5550 100644
+--- a/qtbase/src/corelib/io/qlockfile_win.cpp
++++ b/qtbase/src/corelib/io/qlockfile_win.cpp
+@@ -48,6 +48,8 @@
+ #include "QtCore/qdebug.h"
+ #include "QtCore/qthread.h"
+ 
++#include "private/qsystemlibrary_p.h"
++
+ QT_BEGIN_NAMESPACE
+ 
+ static inline bool fileExists(const wchar_t *fileName)
+@@ -150,7 +152,7 @@ QString QLockFilePrivate::processNameByPid(qint64 pid)
+ #if !defined(Q_OS_WINRT)
+     typedef DWORD (WINAPI *GetModuleFileNameExFunc)(HANDLE, HMODULE, LPTSTR, DWORD);
+ 
+-    HMODULE hPsapi = LoadLibraryA("psapi");
++    HMODULE hPsapi = QSystemLibrary::load(L"psapi");
+     if (!hPsapi)
+         return QString();
+     GetModuleFileNameExFunc qGetModuleFileNameEx = reinterpret_cast<GetModuleFileNameExFunc>(
+diff --git a/qtbase/src/corelib/io/qprocess_unix.cpp b/qtbase/src/corelib/io/qprocess_unix.cpp
+index 50390e57f5..15c8f30745 100644
+--- a/qtbase/src/corelib/io/qprocess_unix.cpp
++++ b/qtbase/src/corelib/io/qprocess_unix.cpp
+@@ -1,7 +1,7 @@
+ /****************************************************************************
+ **
+ ** Copyright (C) 2016 The Qt Company Ltd.
+-** Copyright (C) 2016 Intel Corporation.
++** Copyright (C) 2022 Intel Corporation.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtCore module of the Qt Toolkit.
+@@ -422,14 +422,15 @@ void QProcessPrivate::startProcess()
+     // Add the program name to the argument list.
+     argv[0] = nullptr;
+     if (!program.contains(QLatin1Char('/'))) {
++        // findExecutable() returns its argument if it's an absolute path,
++        // otherwise it searches $PATH; returns empty if not found (we handle
++        // that case much later)
+         const QString &exeFilePath = QStandardPaths::findExecutable(program);
+-        if (!exeFilePath.isEmpty()) {
+-            const QByteArray &tmp = QFile::encodeName(exeFilePath);
+-            argv[0] = ::strdup(tmp.constData());
+-        }
+-    }
+-    if (!argv[0])
++        const QByteArray &tmp = QFile::encodeName(exeFilePath);
++        argv[0] = ::strdup(tmp.constData());
++    } else {
+         argv[0] = ::strdup(encodedProgramName.constData());
++    }
+ 
+     // Add every argument to the list
+     for (int i = 0; i < arguments.count(); ++i)
+@@ -983,15 +984,16 @@ bool QProcessPrivate::startDetached(qint64 *pid)
+                 envp = _q_dupEnvironment(environment.d.constData()->vars, &envc);
+             }
+ 
+-            QByteArray tmp;
+             if (!program.contains(QLatin1Char('/'))) {
++                // findExecutable() returns its argument if it's an absolute path,
++                // otherwise it searches $PATH; returns empty if not found (we handle
++                // that case much later)
+                 const QString &exeFilePath = QStandardPaths::findExecutable(program);
+-                if (!exeFilePath.isEmpty())
+-                    tmp = QFile::encodeName(exeFilePath);
++                const QByteArray &tmp = QFile::encodeName(exeFilePath);
++                argv[0] = ::strdup(tmp.constData());
++            } else {
++                argv[0] = ::strdup(QFile::encodeName(program));
+             }
+-            if (tmp.isEmpty())
+-                tmp = QFile::encodeName(program);
+-            argv[0] = tmp.data();
+ 
+             if (envp)
+                 qt_safe_execve(argv[0], argv, envp);
+diff --git a/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp b/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
+index 3a79c502af..997a634e76 100644
+--- a/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
++++ b/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
+@@ -3196,9 +3196,8 @@ bool QAbstractItemModel::beginMoveColumns(const QModelIndex &sourceParent, int s
+     destinationChange.needsAdjust = destinationParent.isValid() && destinationParent.row() >= sourceLast && destinationParent.parent() == sourceParent;
+     d->changes.push(destinationChange);
+ 
+-    d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Horizontal);
+-
+     emit columnsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, QPrivateSignal());
++    d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Horizontal);
+     return true;
+ }
+ 
+@@ -3231,7 +3230,6 @@ void QAbstractItemModel::endMoveColumns()
+       adjustedSource = createIndex(adjustedSource.row(), adjustedSource.column() + numMoved, adjustedSource.internalPointer());
+ 
+     d->itemsMoved(adjustedSource, removeChange.first, removeChange.last, adjustedDestination, insertChange.first, Qt::Horizontal);
+-
+     emit columnsMoved(adjustedSource, removeChange.first, removeChange.last, adjustedDestination, insertChange.first, QPrivateSignal());
+ }
+ 
+diff --git a/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+index dc6379d9fb..c5e287ee84 100644
+--- a/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
++++ b/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+@@ -939,8 +939,9 @@ void QSortFilterProxyModelPrivate::insert_source_items(
+                 q->beginInsertColumns(proxy_parent, proxy_start, proxy_end);
+         }
+ 
+-        for (int i = 0; i < source_items.size(); ++i)
+-            proxy_to_source.insert(proxy_start + i, source_items.at(i));
++        // TODO: use the range QList::insert() overload once it is implemented (QTBUG-58633).
++        proxy_to_source.insert(proxy_start, source_items.size(), 0);
++        std::copy(source_items.cbegin(), source_items.cend(), proxy_to_source.begin() + proxy_start);
+ 
+         build_source_to_proxy_mapping(proxy_to_source, source_to_proxy);
+ 
+@@ -3123,8 +3124,9 @@ bool QSortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex &
+ 
+     if (d->filter_data.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();
+@@ -3133,9 +3135,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.hasMatch(key);
+ }
+diff --git a/qtbase/src/corelib/kernel/qcoreapplication.cpp b/qtbase/src/corelib/kernel/qcoreapplication.cpp
+index ca2864df83..132b2eae52 100644
+--- a/qtbase/src/corelib/kernel/qcoreapplication.cpp
++++ b/qtbase/src/corelib/kernel/qcoreapplication.cpp
+@@ -1157,7 +1157,7 @@ static bool doNotify(QObject *receiver, QEvent *event)
+ bool QCoreApplicationPrivate::sendThroughApplicationEventFilters(QObject *receiver, QEvent *event)
+ {
+     // We can't access the application event filters outside of the main thread (race conditions)
+-    Q_ASSERT(receiver->d_func()->threadData.loadRelaxed()->thread.loadAcquire() == mainThread());
++    Q_ASSERT(receiver->d_func()->threadData.loadAcquire()->thread.loadRelaxed() == mainThread());
+ 
+     if (extraData) {
+         // application event filters are only called for objects in the GUI thread
+diff --git a/qtbase/src/corelib/kernel/qobject.cpp b/qtbase/src/corelib/kernel/qobject.cpp
+index 1eb79138d9..36cd780ee1 100644
+--- a/qtbase/src/corelib/kernel/qobject.cpp
++++ b/qtbase/src/corelib/kernel/qobject.cpp
+@@ -1010,7 +1010,7 @@ QObject::~QObject()
+         emit destroyed(this);
+     }
+ 
+-    if (d->declarativeData) {
++    if (!d->isDeletingChildren && d->declarativeData) {
+         if (static_cast<QAbstractDeclarativeDataImpl*>(d->declarativeData)->ownedByQml1) {
+             if (QAbstractDeclarativeData::destroyed_qml1)
+                 QAbstractDeclarativeData::destroyed_qml1(d->declarativeData, this);
+@@ -1580,7 +1580,7 @@ void QObject::moveToThread(QThread *targetThread)
+ 
+     QThreadData *currentData = QThreadData::current();
+     QThreadData *targetData = targetThread ? QThreadData::get2(targetThread) : nullptr;
+-    QThreadData *thisThreadData = d->threadData.loadRelaxed();
++    QThreadData *thisThreadData = d->threadData.loadAcquire();
+     if (!thisThreadData->thread.loadAcquire() && currentData == targetData) {
+         // one exception to the rule: we allow moving objects with no thread affinity to the current thread
+         currentData = d->threadData;
+@@ -2620,7 +2620,7 @@ int QObject::receivers(const char *signal) const
+         if (!d->isSignalConnected(signal_index))
+             return receivers;
+ 
+-        if (d->declarativeData && QAbstractDeclarativeData::receivers) {
++        if (!d->isDeletingChildren && d->declarativeData && QAbstractDeclarativeData::receivers) {
+             receivers += QAbstractDeclarativeData::receivers(d->declarativeData, this,
+                                                              signal_index);
+         }
+diff --git a/qtbase/src/corelib/kernel/qobject_p.h b/qtbase/src/corelib/kernel/qobject_p.h
+index 0b827a52ca..13ffb88999 100644
+--- a/qtbase/src/corelib/kernel/qobject_p.h
++++ b/qtbase/src/corelib/kernel/qobject_p.h
+@@ -444,7 +444,7 @@ inline void QObjectPrivate::checkForIncompatibleLibraryVersion(int version) cons
+ 
+ inline bool QObjectPrivate::isDeclarativeSignalConnected(uint signal_index) const
+ {
+-    return declarativeData && QAbstractDeclarativeData::isSignalConnected
++    return !isDeletingChildren && declarativeData && QAbstractDeclarativeData::isSignalConnected
+             && QAbstractDeclarativeData::isSignalConnected(declarativeData, q_func(), signal_index);
+ }
+ 
+diff --git a/qtbase/src/corelib/kernel/qtranslator.cpp b/qtbase/src/corelib/kernel/qtranslator.cpp
+index 2812ffb7ea..bc0177c5ec 100644
+--- a/qtbase/src/corelib/kernel/qtranslator.cpp
++++ b/qtbase/src/corelib/kernel/qtranslator.cpp
+@@ -902,7 +902,7 @@ static QString getMessage(const uchar *m, const uchar *end, const char *context,
+             goto end;
+         case Tag_Translation: {
+             int len = read32(m);
+-            if (len % 1)
++            if (len & 1)
+                 return QString();
+             m += 4;
+             if (!numerus--) {
+diff --git a/qtbase/src/corelib/mimetypes/qmimedatabase.cpp b/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
+index 9de22cef33..ff868a3268 100644
+--- a/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
+@@ -389,20 +389,23 @@ QMimeType QMimeDatabasePrivate::mimeTypeForFileNameAndData(const QString &fileNa
+         // Disambiguate conflicting extensions (if magic matching found something)
+         if (candidateByData.isValid() && magicAccuracy > 0) {
+             const QString sniffedMime = candidateByData.name();
+-            // If the sniffedMime matches a glob match, use it
++            // If the sniffedMime matches a highest-weight glob match, use it
+             if (candidatesByName.m_matchingMimeTypes.contains(sniffedMime)) {
+                 *accuracyPtr = 100;
+                 return candidateByData;
+             }
+-            for (const QString &m : qAsConst(candidatesByName.m_matchingMimeTypes)) {
++            for (const QString &m : qAsConst(candidatesByName.m_allMatchingMimeTypes)) {
+                 if (inherits(m, sniffedMime)) {
+                     // We have magic + pattern pointing to this, so it's a pretty good match
+                     *accuracyPtr = 100;
+                     return mimeTypeForName(m);
+                 }
+             }
+-            *accuracyPtr = magicAccuracy;
+-            return candidateByData;
++            if (candidatesByName.m_allMatchingMimeTypes.isEmpty()) {
++                // No glob, use magic
++                *accuracyPtr = magicAccuracy;
++                return candidateByData;
++            }
+         }
+     }
+ 
+diff --git a/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp b/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
+index a81112d227..fa8f4c545d 100644
+--- a/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
+@@ -83,7 +83,10 @@ void QMimeGlobMatchResult::addMatch(const QString &mimeType, int weight, const Q
+     }
+     if (!m_matchingMimeTypes.contains(mimeType)) {
+         m_matchingMimeTypes.append(mimeType);
+-        m_allMatchingMimeTypes.append(mimeType);
++        if (replace)
++            m_allMatchingMimeTypes.prepend(mimeType); // highest-weight first
++        else
++            m_allMatchingMimeTypes.append(mimeType);
+         m_knownSuffixLength = knownSuffixLength;
+     }
+ }
+@@ -94,7 +97,7 @@ QMimeGlobPattern::PatternType QMimeGlobPattern::detectPatternType(const QString
+     if (!patternLength)
+         return OtherPattern;
+ 
+-    const bool starCount = pattern.count(QLatin1Char('*')) == 1;
++    const int starCount = pattern.count(QLatin1Char('*'));
+     const bool hasSquareBracket = pattern.indexOf(QLatin1Char('[')) != -1;
+     const bool hasQuestionMark = pattern.indexOf(QLatin1Char('?')) != -1;
+ 
+@@ -106,10 +109,10 @@ QMimeGlobPattern::PatternType QMimeGlobPattern::detectPatternType(const QString
+             // Patterns like "README*" (well this is currently the only one like that...)
+             if (pattern.at(patternLength - 1) == QLatin1Char('*'))
+                 return PrefixPattern;
+-        }
+-        // Names without any wildcards like "README"
+-        if (starCount == 0)
++        } else if (starCount == 0) {
++            // Names without any wildcards like "README"
+             return LiteralPattern;
++        }
+     }
+ 
+     if (pattern == QLatin1String("[0-9][0-9][0-9].vdr"))
+diff --git a/qtbase/src/corelib/mimetypes/qmimeprovider.cpp b/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
+index 258dddf8cb..4642d0f2d0 100644
+--- a/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
+@@ -244,15 +244,18 @@ void QMimeBinaryProvider::addFileNameMatches(const QString &fileName, QMimeGlobM
+     const QString lowerFileName = fileName.toLower();
+     // Check literals (e.g. "Makefile")
+     matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosLiteralListOffset), fileName);
+-    // Check complex globs (e.g. "callgrind.out[0-9]*")
+-    matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosGlobListOffset), fileName);
+     // Check the very common *.txt cases with the suffix tree
+-    const int reverseSuffixTreeOffset = m_cacheFile->getUint32(PosReverseSuffixTreeOffset);
+-    const int numRoots = m_cacheFile->getUint32(reverseSuffixTreeOffset);
+-    const int firstRootOffset = m_cacheFile->getUint32(reverseSuffixTreeOffset + 4);
+-    matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, lowerFileName, lowerFileName.length() - 1, false);
++    if (result.m_matchingMimeTypes.isEmpty()) {
++        const int reverseSuffixTreeOffset = m_cacheFile->getUint32(PosReverseSuffixTreeOffset);
++        const int numRoots = m_cacheFile->getUint32(reverseSuffixTreeOffset);
++        const int firstRootOffset = m_cacheFile->getUint32(reverseSuffixTreeOffset + 4);
++        matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, lowerFileName, lowerFileName.length() - 1, false);
++        if (result.m_matchingMimeTypes.isEmpty())
++            matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, fileName, fileName.length() - 1, true);
++    }
++    // Check complex globs (e.g. "callgrind.out[0-9]*" or "README*")
+     if (result.m_matchingMimeTypes.isEmpty())
+-        matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, fileName, fileName.length() - 1, true);
++        matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosGlobListOffset), fileName);
+ }
+ 
+ void QMimeBinaryProvider::matchGlobList(QMimeGlobMatchResult &result, CacheFile *cacheFile, int off, const QString &fileName)
+diff --git a/qtbase/src/corelib/serialization/qjsonparser.cpp b/qtbase/src/corelib/serialization/qjsonparser.cpp
+index 17e6f111ab..2e40b6c8fb 100644
+--- a/qtbase/src/corelib/serialization/qjsonparser.cpp
++++ b/qtbase/src/corelib/serialization/qjsonparser.cpp
+@@ -379,10 +379,30 @@ error:
+     return QCborValue();
+ }
+ 
++// We need to retain the _last_ value for any duplicate keys and we need to deref containers.
++// Therefore the manual implementation of std::unique().
++template<typename Iterator, typename Compare, typename Assign>
++static Iterator customAssigningUniqueLast(Iterator first, Iterator last,
++                                          Compare compare, Assign assign)
++{
++    first = std::adjacent_find(first, last, compare);
++    if (first == last)
++        return last;
++
++    Iterator result = first;
++    while (++first != last) {
++        if (!compare(*result, *first))
++            ++result;
++        if (result != first)
++            assign(*result, *first);
++    }
++
++    return ++result;
++}
++
+ static void sortContainer(QCborContainerPrivate *container)
+ {
+     using Forward = QJsonPrivate::KeyIterator;
+-    using Reverse = std::reverse_iterator<Forward>;
+     using Value = Forward::value_type;
+ 
+     auto compare = [container](const Value &a, const Value &b)
+@@ -420,17 +440,31 @@ static void sortContainer(QCborContainerPrivate *container)
+         }
+     };
+ 
+-    std::sort(Forward(container->elements.begin()), Forward(container->elements.end()),
+-              [&compare](const Value &a, const Value &b) { return compare(a, b) < 0; });
++    // The elements' containers are owned by the outer container, not by the elements themselves.
++    auto move = [](Forward::reference target, Forward::reference source)
++    {
++        QtCbor::Element &targetValue = target.value();
++
++        // If the target has a container, deref it before overwriting, so that we don't leak.
++        if (targetValue.flags & QtCbor::Element::IsContainer)
++            targetValue.container->deref();
++
++        // Do not move, so that we can clear the value afterwards.
++        target = source;
++
++        // Clear the source value, so that we don't store the same container twice.
++        source.value() = QtCbor::Element();
++    };
++
++    std::stable_sort(
++                Forward(container->elements.begin()), Forward(container->elements.end()),
++                [&compare](const Value &a, const Value &b) { return compare(a, b) < 0; });
+ 
+-    // We need to retain the _last_ value for any duplicate keys. Therefore the reverse dance here.
+-    auto it = std::unique(Reverse(container->elements.end()), Reverse(container->elements.begin()),
+-                          [&compare](const Value &a, const Value &b) {
+-        return compare(a, b) == 0;
+-    }).base().elementsIterator();
++    Forward result = customAssigningUniqueLast(
++                Forward(container->elements.begin()),  Forward(container->elements.end()),
++                [&compare](const Value &a, const Value &b) { return compare(a, b) == 0; }, move);
+ 
+-    // The erase from beginning is expensive but hopefully rare.
+-    container->elements.erase(container->elements.begin(), it);
++    container->elements.erase(result.elementsIterator(), container->elements.end());
+ }
+ 
+ 
+diff --git a/qtbase/src/corelib/serialization/qxmlstream.cpp b/qtbase/src/corelib/serialization/qxmlstream.cpp
+index b2f846544d..7cd457ba3a 100644
+--- a/qtbase/src/corelib/serialization/qxmlstream.cpp
++++ b/qtbase/src/corelib/serialization/qxmlstream.cpp
+@@ -980,7 +980,7 @@ inline uint QXmlStreamReaderPrivate::peekChar()
+ bool QXmlStreamReaderPrivate::scanUntil(const char *str, short tokenToInject)
+ {
+     int pos = textBuffer.size();
+-    int oldLineNumber = lineNumber;
++    const auto oldLineNumber = lineNumber;
+ 
+     uint c;
+     while ((c = getChar()) != StreamEOF) {
+diff --git a/qtbase/src/corelib/text/qstring.cpp b/qtbase/src/corelib/text/qstring.cpp
+index 3e88ab4859..8deeae47bb 100644
+--- a/qtbase/src/corelib/text/qstring.cpp
++++ b/qtbase/src/corelib/text/qstring.cpp
+@@ -12312,7 +12312,7 @@ static qsizetype qLastIndexOf(Haystack haystack0, qsizetype from,
+     const auto needle = needle0.data();
+     const auto *end = haystack;
+     haystack += from;
+-    const std::size_t sl_minus_1 = sl - 1;
++    const std::size_t sl_minus_1 = sl ? sl - 1 : 0;
+     const auto *n = needle + sl_minus_1;
+     const auto *h = haystack + sl_minus_1;
+     std::size_t hashNeedle = 0, hashHaystack = 0;
+diff --git a/qtbase/src/corelib/text/qstringiterator_p.h b/qtbase/src/corelib/text/qstringiterator_p.h
+index 219589b6e4..1d0c66cc78 100644
+--- a/qtbase/src/corelib/text/qstringiterator_p.h
++++ b/qtbase/src/corelib/text/qstringiterator_p.h
+@@ -61,6 +61,8 @@ class QStringIterator
+ {
+     QString::const_iterator i, pos, e;
+     Q_STATIC_ASSERT((std::is_same<QString::const_iterator, const QChar *>::value));
++    static bool less(const QChar *lhs, const QChar *rhs) noexcept
++    { return std::less<QString::const_iterator>{}(lhs, rhs); }
+ public:
+     explicit QStringIterator(QStringView string, qsizetype idx = 0)
+         : i(string.begin()),
+@@ -95,7 +97,8 @@ public:
+ 
+     inline void setPosition(QString::const_iterator position)
+     {
+-        Q_ASSERT_X(i <= position && position <= e, Q_FUNC_INFO, "position out of bounds");
++        Q_ASSERT_X(!less(position, i) && !less(e, position),
++                   Q_FUNC_INFO, "position out of bounds");
+         pos = position;
+     }
+ 
+@@ -103,7 +106,7 @@ public:
+ 
+     inline bool hasNext() const
+     {
+-        return pos < e;
++        return less(pos, e);
+     }
+ 
+     inline void advance()
+@@ -120,16 +123,20 @@ public:
+     {
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+-        if (Q_UNLIKELY((pos++)->isHighSurrogate()))
++        if (Q_UNLIKELY((pos++)->isHighSurrogate())) {
++            Q_ASSERT(hasNext() && pos->isLowSurrogate());
+             ++pos;
++        }
+     }
+ 
+     inline uint peekNextUnchecked() const
+     {
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+-        if (Q_UNLIKELY(pos->isHighSurrogate()))
++        if (Q_UNLIKELY(pos->isHighSurrogate())) {
++            Q_ASSERT(less(pos + 1, e) && pos[1].isLowSurrogate());
+             return QChar::surrogateToUcs4(pos[0], pos[1]);
++        }
+ 
+         return pos->unicode();
+     }
+@@ -155,8 +162,10 @@ public:
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+         const QChar cur = *pos++;
+-        if (Q_UNLIKELY(cur.isHighSurrogate()))
++        if (Q_UNLIKELY(cur.isHighSurrogate())) {
++            Q_ASSERT(hasNext() && pos->isLowSurrogate());
+             return QChar::surrogateToUcs4(cur, *pos++);
++        }
+         return cur.unicode();
+     }
+ 
+@@ -166,7 +175,7 @@ public:
+ 
+         const QChar uc = *pos++;
+         if (Q_UNLIKELY(uc.isSurrogate())) {
+-            if (Q_LIKELY(uc.isHighSurrogate() && pos < e && pos->isLowSurrogate()))
++            if (Q_LIKELY(uc.isHighSurrogate() && hasNext() && pos->isLowSurrogate()))
+                 return QChar::surrogateToUcs4(uc, *pos++);
+             return invalidAs;
+         }
+@@ -178,7 +187,7 @@ public:
+ 
+     inline bool hasPrevious() const
+     {
+-        return pos > i;
++        return less(i, pos);
+     }
+ 
+     inline void recede()
+@@ -196,16 +205,20 @@ public:
+     {
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+-        if (Q_UNLIKELY((--pos)->isLowSurrogate()))
++        if (Q_UNLIKELY((--pos)->isLowSurrogate())) {
++            Q_ASSERT(hasPrevious() && pos[-1].isHighSurrogate());
+             --pos;
++        }
+     }
+ 
+     inline uint peekPreviousUnchecked() const
+     {
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+-        if (Q_UNLIKELY(pos[-1].isLowSurrogate()))
++        if (Q_UNLIKELY(pos[-1].isLowSurrogate())) {
++            Q_ASSERT(less(i + 1, pos) && pos[-2].isHighSurrogate());
+             return QChar::surrogateToUcs4(pos[-2], pos[-1]);
++        }
+         return pos[-1].unicode();
+     }
+ 
+@@ -230,8 +243,10 @@ public:
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+         const QChar cur = *--pos;
+-        if (Q_UNLIKELY(cur.isLowSurrogate()))
++        if (Q_UNLIKELY(cur.isLowSurrogate())) {
++            Q_ASSERT(hasPrevious() && pos[-1].isHighSurrogate());
+             return QChar::surrogateToUcs4(*--pos, cur);
++        }
+         return cur.unicode();
+     }
+ 
+@@ -241,7 +256,7 @@ public:
+ 
+         const QChar uc = *--pos;
+         if (Q_UNLIKELY(uc.isSurrogate())) {
+-            if (Q_LIKELY(uc.isLowSurrogate() && pos > i && pos[-1].isHighSurrogate()))
++            if (Q_LIKELY(uc.isLowSurrogate() && hasPrevious() && pos[-1].isHighSurrogate()))
+                 return QChar::surrogateToUcs4(*--pos, uc);
+             return invalidAs;
+         }
+diff --git a/qtbase/src/corelib/thread/qfutex_p.h b/qtbase/src/corelib/thread/qfutex_p.h
+index f287b752d7..e294537787 100644
+--- a/qtbase/src/corelib/thread/qfutex_p.h
++++ b/qtbase/src/corelib/thread/qfutex_p.h
+@@ -52,6 +52,7 @@
+ //
+ 
+ #include <qglobal.h>
++#include <QtCore/qtsan_impl.h>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -106,16 +107,13 @@ namespace QtLinuxFutex {
+     inline int _q_futex(int *addr, int op, int val, quintptr val2 = 0,
+                         int *addr2 = nullptr, int val3 = 0) noexcept
+     {
+-        // A futex call ensures total ordering on the futex words
+-        // (in either success or failure of the call). Instruct TSAN accordingly,
+-        // as TSAN does not understand the futex(2) syscall.
+-        _q_tsan_release(addr, addr2);
++        QtTsan::futexRelease(addr, addr2);
+ 
+         // we use __NR_futex because some libcs (like Android's bionic) don't
+         // provide SYS_futex etc.
+         int result = syscall(__NR_futex, addr, op | FUTEX_PRIVATE_FLAG, val, val2, addr2, val3);
+ 
+-        _q_tsan_acquire(addr, addr2);
++        QtTsan::futexAcquire(addr, addr2);
+ 
+         return result;
+     }
+diff --git a/qtbase/src/corelib/thread/qmutex.cpp b/qtbase/src/corelib/thread/qmutex.cpp
+index 310d1cb14f..7097122d8e 100644
+--- a/qtbase/src/corelib/thread/qmutex.cpp
++++ b/qtbase/src/corelib/thread/qmutex.cpp
+@@ -152,6 +152,7 @@ public:
+ 
+ /*!
+     \enum QMutex::RecursionMode
++    \obsolete Use QRecursiveMutex to create a recursive mutex.
+ 
+     \value Recursive  In this mode, a thread can lock the same mutex
+                       multiple times and the mutex won't be unlocked
+@@ -173,6 +174,7 @@ public:
+ 
+ /*!
+     Constructs a new mutex. The mutex is created in an unlocked state.
++    \obsolete Use QRecursiveMutex to create a recursive mutex.
+ 
+     If \a mode is QMutex::Recursive, a thread can lock the same mutex
+     multiple times and the mutex won't be unlocked until a
+@@ -197,7 +199,7 @@ QMutex::QMutex(RecursionMode mode)
+ QMutex::~QMutex()
+ {
+     QMutexData *d = d_ptr.loadRelaxed();
+-    if (isRecursive()) {
++    if (QBasicMutex::isRecursive()) {
+         delete static_cast<QRecursiveMutexPrivate *>(d);
+     } else if (d) {
+ #ifndef QT_LINUX_FUTEX
+diff --git a/qtbase/src/corelib/thread/qmutex.h b/qtbase/src/corelib/thread/qmutex.h
+index 73c9e00663..1bae573a03 100644
+--- a/qtbase/src/corelib/thread/qmutex.h
++++ b/qtbase/src/corelib/thread/qmutex.h
+@@ -42,6 +42,7 @@
+ 
+ #include <QtCore/qglobal.h>
+ #include <QtCore/qatomic.h>
++#include <QtCore/qtsan_impl.h>
+ #include <new>
+ 
+ #if __has_include(<chrono>)
+@@ -77,19 +78,37 @@ public:
+ 
+     // BasicLockable concept
+     inline void lock() QT_MUTEX_LOCK_NOEXCEPT {
++        QtTsan::mutexPreLock(this, 0u);
++
+         if (!fastTryLock())
+             lockInternal();
++
++        QtTsan::mutexPostLock(this, 0u, 0);
+     }
+ 
+     // BasicLockable concept
+     inline void unlock() noexcept {
+         Q_ASSERT(d_ptr.loadRelaxed()); //mutex must be locked
++
++        QtTsan::mutexPreUnlock(this, 0u);
++
+         if (!fastTryUnlock())
+             unlockInternal();
++
++        QtTsan::mutexPostUnlock(this, 0u);
+     }
+ 
+     bool tryLock() noexcept {
+-        return fastTryLock();
++        unsigned tsanFlags = QtTsan::TryLock;
++        QtTsan::mutexPreLock(this, tsanFlags);
++
++        const bool success = fastTryLock();
++
++        if (!success)
++            tsanFlags |= QtTsan::TryLockFailed;
++        QtTsan::mutexPostLock(this, tsanFlags, 0);
++
++        return success;
+     }
+ 
+     // Lockable concept
+@@ -134,8 +153,16 @@ public:
+ #else
+     QMutex() { d_ptr.storeRelaxed(nullptr); }
+ #endif
++#if QT_DEPRECATED_SINCE(5,15)
+     enum RecursionMode { NonRecursive, Recursive };
++    QT_DEPRECATED_VERSION_X(5, 15, "Use QRecursiveMutex instead of a recursive QMutex")
+     explicit QMutex(RecursionMode mode);
++
++    QT_DEPRECATED_VERSION_X(5, 15, "Use QRecursiveMutex instead of a recursive QMutex")
++    bool isRecursive() const noexcept
++    { return QBasicMutex::isRecursive(); }
++#endif
++
+     ~QMutex();
+ 
+     // BasicLockable concept
+@@ -166,9 +193,6 @@ public:
+     }
+ #endif
+ 
+-    bool isRecursive() const noexcept
+-    { return QBasicMutex::isRecursive(); }
+-
+ private:
+     Q_DISABLE_COPY(QMutex)
+     friend class QMutexLocker;
+diff --git a/qtbase/src/corelib/thread/qreadwritelock.cpp b/qtbase/src/corelib/thread/qreadwritelock.cpp
+index 8c28507d5a..9dd8503116 100644
+--- a/qtbase/src/corelib/thread/qreadwritelock.cpp
++++ b/qtbase/src/corelib/thread/qreadwritelock.cpp
+@@ -155,7 +155,7 @@ QReadWriteLock::QReadWriteLock(RecursionMode recursionMode)
+ */
+ QReadWriteLock::~QReadWriteLock()
+ {
+-    auto d = d_ptr.loadRelaxed();
++    auto d = d_ptr.loadAcquire();
+     if (isUncontendedLocked(d)) {
+         qWarning("QReadWriteLock: destroying locked QReadWriteLock");
+         return;
+@@ -445,7 +445,7 @@ void QReadWriteLock::unlock()
+ /*! \internal  Helper for QWaitCondition::wait */
+ QReadWriteLock::StateForWaitCondition QReadWriteLock::stateForWaitCondition() const
+ {
+-    QReadWriteLockPrivate *d = d_ptr.loadRelaxed();
++    QReadWriteLockPrivate *d = d_ptr.loadAcquire();
+     switch (quintptr(d) & StateMask) {
+     case StateLockedForRead: return LockedForRead;
+     case StateLockedForWrite: return LockedForWrite;
+@@ -453,6 +453,7 @@ QReadWriteLock::StateForWaitCondition QReadWriteLock::stateForWaitCondition() co
+ 
+     if (!d)
+         return Unlocked;
++    const auto lock = qt_scoped_lock(d->mutex);
+     if (d->writerCount > 1)
+         return RecursivelyLocked;
+     else if (d->writerCount == 1)
+diff --git a/qtbase/src/corelib/thread/qsemaphore.cpp b/qtbase/src/corelib/thread/qsemaphore.cpp
+index 1d01fc1b28..3ecdee3747 100644
+--- a/qtbase/src/corelib/thread/qsemaphore.cpp
++++ b/qtbase/src/corelib/thread/qsemaphore.cpp
+@@ -354,7 +354,12 @@ void QSemaphore::release(int n)
+         quintptr nn = unsigned(n);
+         if (futexHasWaiterCount)
+             nn |= quint64(nn) << 32;    // token count replicated in high word
+-        quintptr prevValue = u.fetchAndAddRelease(nn);
++        quintptr prevValue = u.loadRelaxed();
++        quintptr newValue;
++        do { // loop just to ensure the operations are done atomically
++            newValue = prevValue + nn;
++            newValue &= (futexNeedsWakeAllBit - 1);
++        } while (!u.testAndSetRelease(prevValue, newValue, prevValue));
+         if (futexNeedsWake(prevValue)) {
+ #ifdef FUTEX_OP
+             if (futexHasWaiterCount) {
+@@ -376,7 +381,6 @@ void QSemaphore::release(int n)
+                 quint32 oparg = 0;
+                 quint32 cmp = FUTEX_OP_CMP_NE;
+                 quint32 cmparg = 0;
+-                u.fetchAndAndRelease(futexNeedsWakeAllBit - 1);
+                 futexWakeOp(*futexLow32(&u), n, INT_MAX, *futexHigh32(&u), FUTEX_OP(op, oparg, cmp, cmparg));
+                 return;
+             }
+@@ -388,7 +392,6 @@ 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(futexNeedsWakeAllBit - 1);
+             if (futexHasWaiterCount) {
+                 futexWakeAll(*futexLow32(&u));
+                 futexWakeAll(*futexHigh32(&u));
+diff --git a/qtbase/src/corelib/thread/qthread_p.h b/qtbase/src/corelib/thread/qthread_p.h
+index b2d1628e6e..f32f6f0460 100644
+--- a/qtbase/src/corelib/thread/qthread_p.h
++++ b/qtbase/src/corelib/thread/qthread_p.h
+@@ -174,7 +174,7 @@ public:
+     int returnCode;
+ 
+     uint stackSize;
+-    QThread::Priority priority;
++    std::underlying_type<QThread::Priority>::type priority;
+ 
+     static QThread *threadForId(int id);
+ 
+@@ -213,6 +213,13 @@ public:
+             QCoreApplication::instance()->postEvent(q_ptr, new QEvent(QEvent::Quit));
+         }
+     }
++
++#ifndef Q_OS_INTEGRITY
++private:
++    // Used in QThread(Private)::start to avoid racy access to QObject::objectName,
++    // unset afterwards. On INTEGRITY we set the thread name before starting it.
++    QString objectName;
++#endif
+ };
+ 
+ #else // QT_CONFIG(thread)
+diff --git a/qtbase/src/corelib/thread/qthread_unix.cpp b/qtbase/src/corelib/thread/qthread_unix.cpp
+index 56a8e0a038..610117a640 100644
+--- a/qtbase/src/corelib/thread/qthread_unix.cpp
++++ b/qtbase/src/corelib/thread/qthread_unix.cpp
+@@ -169,8 +169,7 @@ static void set_thread_data(QThreadData *data)
+ 
+ static void clear_thread_data()
+ {
+-    currentThreadData = nullptr;
+-    pthread_setspecific(current_thread_data_key, nullptr);
++    set_thread_data(nullptr);
+ }
+ 
+ template <typename T>
+@@ -296,7 +295,7 @@ void *QThreadPrivate::start(void *arg)
+             QMutexLocker locker(&thr->d_func()->mutex);
+ 
+             // do we need to reset the thread priority?
+-            if (int(thr->d_func()->priority) & ThreadPriorityResetFlag) {
++            if (thr->d_func()->priority & ThreadPriorityResetFlag) {
+                 thr->d_func()->setPriority(QThread::Priority(thr->d_func()->priority & ~ThreadPriorityResetFlag));
+             }
+ 
+@@ -316,10 +315,10 @@ void *QThreadPrivate::start(void *arg)
+             // Sets the name of the current thread. We can only do this
+             // when the thread is starting, as we don't have a cross
+             // platform way of setting the name of an arbitrary thread.
+-            if (Q_LIKELY(thr->objectName().isEmpty()))
++            if (Q_LIKELY(thr->d_func()->objectName.isEmpty()))
+                 setCurrentThreadName(thr->metaObject()->className());
+             else
+-                setCurrentThreadName(thr->objectName().toLocal8Bit());
++                setCurrentThreadName(std::exchange(thr->d_func()->objectName, {}).toLocal8Bit());
+         }
+ #endif
+ 
+@@ -671,7 +670,7 @@ void QThread::start(Priority priority)
+                 // could not set scheduling hints, fallback to inheriting them
+                 // we'll try again from inside the thread
+                 pthread_attr_setinheritsched(&attr, PTHREAD_INHERIT_SCHED);
+-                d->priority = Priority(priority | ThreadPriorityResetFlag);
++                d->priority = static_cast<std::underlying_type<QThread::Priority>::type>(priority) | ThreadPriorityResetFlag;
+             }
+             break;
+         }
+@@ -702,7 +701,10 @@ void QThread::start(Priority priority)
+         pthread_attr_setthreadname(&attr, metaObject()->className());
+     else
+         pthread_attr_setthreadname(&attr, objectName().toLocal8Bit());
++#else
++    d->objectName = objectName();
+ #endif
++
+     pthread_t threadId;
+     int code = pthread_create(&threadId, &attr, QThreadPrivate::start, this);
+     if (code == EPERM) {
+diff --git a/qtbase/src/corelib/thread/qthread_win.cpp b/qtbase/src/corelib/thread/qthread_win.cpp
+index bc70e3178a..4e76972498 100644
+--- a/qtbase/src/corelib/thread/qthread_win.cpp
++++ b/qtbase/src/corelib/thread/qthread_win.cpp
+@@ -394,10 +394,9 @@ unsigned int __stdcall QT_ENSURE_STACK_ALIGNED_FOR_SSE QThreadPrivate::start(voi
+ 
+ #if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) && !defined(Q_OS_WINRT)
+     // sets the name of the current thread.
+-    QByteArray objectName = thr->objectName().toLocal8Bit();
+-    qt_set_thread_name(HANDLE(-1),
+-                       objectName.isEmpty() ?
+-                       thr->metaObject()->className() : objectName.constData());
++    qt_set_thread_name(HANDLE(-1), thr->d_func()->objectName.isEmpty()
++                        ? thr->metaObject()->className()
++                        : std::exchange(thr->d_func()->objectName, {}).toLocal8Bit().constData());
+ #endif
+ 
+     emit thr->started(QThread::QPrivateSignal());
+@@ -503,6 +502,7 @@ void QThread::start(Priority priority)
+     if (d->running)
+         return;
+ 
++    d->objectName = objectName();
+     d->running = true;
+     d->finished = false;
+     d->exited = false;
+@@ -548,7 +548,7 @@ void QThread::start(Priority priority)
+ 
+     int prio;
+     d->priority = priority;
+-    switch (d->priority) {
++    switch (priority) {
+     case IdlePriority:
+         prio = THREAD_PRIORITY_IDLE;
+         break;
+@@ -686,7 +686,7 @@ void QThreadPrivate::setPriority(QThread::Priority threadPriority)
+ 
+     int prio;
+     priority = threadPriority;
+-    switch (priority) {
++    switch (threadPriority) {
+     case QThread::IdlePriority:
+         prio = THREAD_PRIORITY_IDLE;
+         break;
+diff --git a/qtbase/src/corelib/thread/qtsan_impl.h b/qtbase/src/corelib/thread/qtsan_impl.h
+new file mode 100644
+index 0000000000..580a738b91
+--- /dev/null
++++ b/qtbase/src/corelib/thread/qtsan_impl.h
+@@ -0,0 +1,115 @@
++/****************************************************************************
++**
++** Copyright (C) 2017 Intel Corporation.
++** Copyright (C) 2022 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
++** 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 QTSAN_IMPL_H
++#define QTSAN_IMPL_H
++
++#include <QtCore/qglobal.h>
++
++#if (__has_feature(thread_sanitizer) || defined(__SANITIZE_THREAD__)) && __has_include(<sanitizer/tsan_interface.h>)
++#  define QT_BUILDING_UNDER_TSAN
++#  include <sanitizer/tsan_interface.h>
++#endif
++
++QT_BEGIN_NAMESPACE
++
++namespace QtTsan {
++#ifdef QT_BUILDING_UNDER_TSAN
++inline void futexAcquire(void *addr, void *addr2 = nullptr)
++{
++    // A futex call ensures total ordering on the futex words
++    // (in either success or failure of the call). Instruct TSAN accordingly,
++    // as TSAN does not understand the futex(2) syscall (or equivalent).
++    ::__tsan_acquire(addr);
++    if (addr2)
++        ::__tsan_acquire(addr2);
++}
++
++inline void futexRelease(void *addr, void *addr2 = nullptr)
++{
++    if (addr2)
++        ::__tsan_release(addr2);
++    ::__tsan_release(addr);
++}
++
++inline void mutexPreLock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_pre_lock(addr, flags);
++}
++
++inline void mutexPostLock(void *addr, unsigned flags, int recursion)
++{
++    ::__tsan_mutex_post_lock(addr, flags, recursion);
++}
++
++inline void mutexPreUnlock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_pre_unlock(addr, flags);
++}
++
++inline void mutexPostUnlock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_post_unlock(addr, flags);
++}
++
++enum : unsigned {
++    MutexWriteReentrant = ::__tsan_mutex_write_reentrant,
++    TryLock = ::__tsan_mutex_try_lock,
++    TryLockFailed = ::__tsan_mutex_try_lock_failed,
++};
++#else
++inline void futexAcquire(void *, void * = nullptr) {}
++inline void futexRelease(void *, void * = nullptr) {}
++
++enum : unsigned {
++    MutexWriteReentrant,
++    TryLock,
++    TryLockFailed,
++};
++inline void mutexPreLock(void *, unsigned) {}
++inline void mutexPostLock(void *, unsigned, int) {}
++inline void mutexPreUnlock(void *, unsigned) {}
++inline void mutexPostUnlock(void *, unsigned) {}
++#endif // QT_BUILDING_UNDER_TSAN
++} // namespace QtTsan
++
++QT_END_NAMESPACE
++
++#endif // QTSAN_IMPL_H
+diff --git a/qtbase/src/corelib/thread/qwaitcondition_unix.cpp b/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
+index 88b058f410..0f1da4dc9b 100644
+--- a/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
++++ b/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
+@@ -213,7 +213,7 @@ bool QWaitCondition::wait(QMutex *mutex, QDeadlineTimer deadline)
+ {
+     if (! mutex)
+         return false;
+-    if (mutex->isRecursive()) {
++    if (static_cast<QBasicMutex *>(mutex)->isRecursive()) {
+         qWarning("QWaitCondition: cannot wait on recursive mutexes");
+         return false;
+     }
+diff --git a/qtbase/src/corelib/time/qdatetime.cpp b/qtbase/src/corelib/time/qdatetime.cpp
+index ec12569e3f..2c0b098079 100644
+--- a/qtbase/src/corelib/time/qdatetime.cpp
++++ b/qtbase/src/corelib/time/qdatetime.cpp
+@@ -43,6 +43,7 @@
+ #if QT_CONFIG(datetimeparser)
+ #include "private/qdatetimeparser_p.h"
+ #endif
++#include <private/qnumeric_p.h>
+ 
+ #include "qdatastream.h"
+ #include "qset.h"
+@@ -1429,9 +1430,11 @@ QDate QDate::addDays(qint64 ndays) const
+     if (isNull())
+         return QDate();
+ 
+-    // Due to limits on minJd() and maxJd() we know that any overflow
+-    // will be invalid and caught by fromJulianDay().
+-    return fromJulianDay(jd + ndays);
++    qint64 r;
++    if (Q_UNLIKELY(add_overflow(jd, ndays, &r)))
++        return QDate();
++    else
++        return fromJulianDay(r);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/corelib/time/qtimezone.cpp b/qtbase/src/corelib/time/qtimezone.cpp
+index 0309e43e52..3d451696a1 100644
+--- a/qtbase/src/corelib/time/qtimezone.cpp
++++ b/qtbase/src/corelib/time/qtimezone.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2013 John Layt <jlayt@kde.org>
++** Copyright (C) 2020 John Layt <jlayt@kde.org>
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtCore module of the Qt Toolkit.
+@@ -975,9 +975,15 @@ QList<QByteArray> QTimeZone::windowsIdToIanaIds(const QByteArray &windowsId,
+ }
+ 
+ #ifndef QT_NO_DATASTREAM
++// Invalid, as an IANA ID: too long, starts with - and has other invalid characters in it
++static inline QString invalidId() { return QStringLiteral("-No Time Zone Specified!"); }
++
+ QDataStream &operator<<(QDataStream &ds, const QTimeZone &tz)
+ {
+-    tz.d->serialize(ds);
++    if (tz.isValid())
++        tz.d->serialize(ds);
++    else
++        ds << invalidId();
+     return ds;
+ }
+ 
+@@ -985,7 +991,9 @@ QDataStream &operator>>(QDataStream &ds, QTimeZone &tz)
+ {
+     QString ianaId;
+     ds >> ianaId;
+-    if (ianaId == QLatin1String("OffsetFromUtc")) {
++    if (ianaId == invalidId()) {
++        tz = QTimeZone();
++    } else if (ianaId == QLatin1String("OffsetFromUtc")) {
+         int utcOffset;
+         QString name;
+         QString abbreviation;
+diff --git a/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp b/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
+index b1611d7ddb..a7a6a72ccf 100644
+--- a/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
++++ b/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
+@@ -42,6 +42,7 @@
+ #include "qtimezone.h"
+ #include "qtimezoneprivate_p.h"
+ #include "private/qlocale_tools_p.h"
++#include "private/qlocking_p.h"
+ 
+ #include <QtCore/QDataStream>
+ #include <QtCore/QDateTime>
+@@ -62,6 +63,10 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++#if QT_CONFIG(icu)
++static QBasicMutex s_icu_mutex;
++#endif
++
+ /*
+     Private
+ 
+@@ -670,6 +675,9 @@ QTzTimeZonePrivate::~QTzTimeZonePrivate()
+ 
+ QTzTimeZonePrivate *QTzTimeZonePrivate::clone() const
+ {
++#if QT_CONFIG(icu)
++    const auto lock = qt_scoped_lock(s_icu_mutex);
++#endif
+     return new QTzTimeZonePrivate(*this);
+ }
+ 
+@@ -913,12 +921,14 @@ QString QTzTimeZonePrivate::displayName(qint64 atMSecsSinceEpoch,
+                                         const QLocale &locale) const
+ {
+ #if QT_CONFIG(icu)
++    auto lock = qt_unique_lock(s_icu_mutex);
+     if (!m_icu)
+         m_icu = new QIcuTimeZonePrivate(m_id);
+     // TODO small risk may not match if tran times differ due to outdated files
+     // TODO Some valid TZ names are not valid ICU names, use translation table?
+     if (m_icu->isValid())
+         return m_icu->displayName(atMSecsSinceEpoch, nameType, locale);
++    lock.unlock();
+ #else
+     Q_UNUSED(nameType)
+     Q_UNUSED(locale)
+@@ -932,12 +942,14 @@ QString QTzTimeZonePrivate::displayName(QTimeZone::TimeType timeType,
+                                         const QLocale &locale) const
+ {
+ #if QT_CONFIG(icu)
++    auto lock = qt_unique_lock(s_icu_mutex);
+     if (!m_icu)
+         m_icu = new QIcuTimeZonePrivate(m_id);
+     // TODO small risk may not match if tran times differ due to outdated files
+     // TODO Some valid TZ names are not valid ICU names, use translation table?
+     if (m_icu->isValid())
+         return m_icu->displayName(timeType, nameType, locale);
++    lock.unlock();
+ #else
+     Q_UNUSED(timeType)
+     Q_UNUSED(nameType)
+diff --git a/qtbase/src/corelib/tools/qarraydata.h b/qtbase/src/corelib/tools/qarraydata.h
+index dcd95924c1..d01739e7e6 100644
+--- a/qtbase/src/corelib/tools/qarraydata.h
++++ b/qtbase/src/corelib/tools/qarraydata.h
+@@ -42,6 +42,7 @@
+ 
+ #include <QtCore/qrefcount.h>
+ #include <string.h>
++#include <cstdint>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -58,14 +59,14 @@ struct Q_CORE_EXPORT QArrayData
+     {
+         Q_ASSERT(size == 0
+                 || offset < 0 || size_t(offset) >= sizeof(QArrayData));
+-        return reinterpret_cast<char *>(this) + offset;
++        return reinterpret_cast<void *> (reinterpret_cast<uintptr_t>(this) + offset);
+     }
+ 
+     const void *data() const
+     {
+         Q_ASSERT(size == 0
+                 || offset < 0 || size_t(offset) >= sizeof(QArrayData));
+-        return reinterpret_cast<const char *>(this) + offset;
++        return reinterpret_cast<void *> (reinterpret_cast<uintptr_t>(this) + offset);
+     }
+ 
+     // This refers to array data mutability, not "header data" represented by
+diff --git a/qtbase/src/corelib/tools/qfreelist_p.h b/qtbase/src/corelib/tools/qfreelist_p.h
+index 5ba23b344b..9974102136 100644
+--- a/qtbase/src/corelib/tools/qfreelist_p.h
++++ b/qtbase/src/corelib/tools/qfreelist_p.h
+@@ -161,7 +161,7 @@ class QFreeList
+                 return i;
+             x -= size;
+         }
+-        Q_ASSERT(false);
++        Q_UNREACHABLE();
+         return -1;
+     }
+ 
+diff --git a/qtbase/src/corelib/tools/qversionnumber.h b/qtbase/src/corelib/tools/qversionnumber.h
+index d43b86ba51..2843f2b043 100644
+--- a/qtbase/src/corelib/tools/qversionnumber.h
++++ b/qtbase/src/corelib/tools/qversionnumber.h
+@@ -273,10 +273,10 @@ public:
+ 
+     Q_REQUIRED_RESULT Q_CORE_EXPORT QString toString() const;
+ #if QT_STRINGVIEW_LEVEL < 2
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(const QString &string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(const QString &string, int *suffixIndex = nullptr);
+ #endif
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QLatin1String string, int *suffixIndex = nullptr);
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QStringView string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(QLatin1String string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(QStringView string, int *suffixIndex = nullptr);
+ 
+ private:
+ #ifndef QT_NO_DATASTREAM
+diff --git a/qtbase/src/dbus/qdbusintegrator.cpp b/qtbase/src/dbus/qdbusintegrator.cpp
+index 5b66ce971b..28a3b0ffea 100644
+--- a/qtbase/src/dbus/qdbusintegrator.cpp
++++ b/qtbase/src/dbus/qdbusintegrator.cpp
+@@ -1135,7 +1135,13 @@ void QDBusConnectionPrivate::closeConnection()
+         }
+     }
+ 
+-    qDeleteAll(pendingCalls);
++    for (auto it = pendingCalls.begin(); it != pendingCalls.end(); ++it) {
++        auto call = *it;
++        if (!call->ref.deref()) {
++            delete call;
++        }
++    }
++    pendingCalls.clear();
+ 
+     // Disconnect all signals from signal hooks and from the object tree to
+     // avoid QObject::destroyed being sent to dbus daemon thread which has
+@@ -2584,6 +2590,11 @@ QDBusConnectionPrivate::findMetaObject(const QString &service, const QString &pa
+         if (mo)
+             return mo;
+     }
++    if (path.isEmpty()) {
++        error = QDBusError(QDBusError::InvalidObjectPath, QLatin1String("Object path cannot be empty"));
++        lastError = error;
++        return nullptr;
++    }
+ 
+     // introspect the target object
+     QDBusMessage msg = QDBusMessage::createMethodCall(service, path,
+diff --git a/qtbase/src/dbus/qdbusmetaobject.cpp b/qtbase/src/dbus/qdbusmetaobject.cpp
+index 5265568f42..7e9f0f1acc 100644
+--- a/qtbase/src/dbus/qdbusmetaobject.cpp
++++ b/qtbase/src/dbus/qdbusmetaobject.cpp
+@@ -210,6 +210,9 @@ QDBusMetaObjectGenerator::findType(const QByteArray &signature,
+         } else if (signature == "a{ss}") {
+             result.name = "QMap<QString,QString>";
+             type = qMetaTypeId<QMap<QString, QString> >();
++        } else if (signature == "aay") {
++            result.name = "QByteArrayList";
++            type = qMetaTypeId<QByteArrayList>();
+         } else {
+             result.name = "{D-Bus type \"" + signature + "\"}";
+             type = registerComplexDBusType(result.name);
+diff --git a/qtbase/src/gui/accessible/qaccessible.cpp b/qtbase/src/gui/accessible/qaccessible.cpp
+index d705bfccb5..0caf3c808c 100644
+--- a/qtbase/src/gui/accessible/qaccessible.cpp
++++ b/qtbase/src/gui/accessible/qaccessible.cpp
+@@ -54,6 +54,7 @@
+ #include <QtCore/qdebug.h>
+ #include <QtCore/qloggingcategory.h>
+ #include <QtCore/qmetaobject.h>
++#include <QtCore/private/qmetaobject_p.h>
+ #include <QtCore/qhash.h>
+ #include <private/qfactoryloader_p.h>
+ 
+@@ -681,6 +682,25 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
+     // Create a QAccessibleInterface for the object class. Start by the most
+     // derived class and walk up the class hierarchy.
+     const QMetaObject *mo = object->metaObject();
++    const auto *objectPriv = QObjectPrivate::get(object);
++    /*
++     We do not want to cache each and every QML metaobject (Button_QMLTYPE_124,
++     Button_QMLTYPE_125, etc.). Those dynamic metaobjects shouldn't have an
++     accessible interface in any case. Instead, we start the whole checking
++     with the first non-dynamic meta-object. To avoid potential regressions
++     in other areas of Qt that also use dynamic metaobjects, we only do this
++     for objects that are QML-related (approximated by checking whether they
++     have ddata set).
++    */
++    const bool qmlRelated = !objectPriv->isDeletingChildren &&
++                            objectPriv->declarativeData;
++    while (qmlRelated && mo) {
++        auto mop = QMetaObjectPrivate::get(mo);
++        if (!mop || !(mop->flags & DynamicMetaObject))
++            break;
++
++        mo = mo->superClass();
++    };
+     while (mo) {
+         const QString cn = QLatin1String(mo->className());
+ 
+@@ -696,14 +716,15 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
+         // Find a QAccessiblePlugin (factory) for the class name. If there's
+         // no entry in the cache try to create it using the plugin loader.
+         if (!qAccessiblePlugins()->contains(cn)) {
++            QAccessiblePlugin *factory = nullptr; // 0 means "no plugin found". This is cached as well.
+             const int index = loader()->indexOf(cn);
+-            if (index != -1) {
+-                QAccessiblePlugin *factory = qobject_cast<QAccessiblePlugin *>(loader()->instance(index));
+-                qAccessiblePlugins()->insert(cn, factory);
+-            }
++            if (index != -1)
++                factory = qobject_cast<QAccessiblePlugin *>(loader()->instance(index));
++            qAccessiblePlugins()->insert(cn, factory);
+         }
+ 
+         // At this point the cache should contain a valid factory pointer or 0:
++        Q_ASSERT(qAccessiblePlugins()->contains(cn));
+         QAccessiblePlugin *factory = qAccessiblePlugins()->value(cn);
+         if (factory) {
+             QAccessibleInterface *result = factory->create(cn, object);
+diff --git a/qtbase/src/gui/configure.json b/qtbase/src/gui/configure.json
+index 1f08795c57..12c95742d2 100644
+--- a/qtbase/src/gui/configure.json
++++ b/qtbase/src/gui/configure.json
+@@ -834,7 +834,8 @@
+                     "// embedded devices, are not intended to be used together with X. EGL support",
+                     "// has to be disabled in plugins like xcb in this case since the native display,",
+                     "// window and pixmap types will be different than what an X-based platform",
+-                    "// plugin would expect."
++                    "// plugin would expect.",
++                    "#define USE_X11"
+                 ],
+                 "include": [ "EGL/egl.h", "X11/Xlib.h" ],
+                 "main": [
+diff --git a/qtbase/src/gui/image/qbmphandler.cpp b/qtbase/src/gui/image/qbmphandler.cpp
+index 96f1e8cb1d..0e73bbbdb0 100644
+--- a/qtbase/src/gui/image/qbmphandler.cpp
++++ b/qtbase/src/gui/image/qbmphandler.cpp
+@@ -150,16 +150,42 @@ static QDataStream &operator<<(QDataStream &s, const BMP_INFOHDR &bi)
+     return s;
+ }
+ 
+-static int calc_shift(uint mask)
++static uint calc_shift(uint mask)
+ {
+-    int result = 0;
+-    while (mask && !(mask & 1)) {
++    uint result = 0;
++    while ((mask >= 0x100) || (!(mask & 1) && mask)) {
+         result++;
+         mask >>= 1;
+     }
+     return result;
+ }
+ 
++static uint calc_scale(uint low_mask)
++{
++    uint result = 8;
++    while (low_mask && result) {
++        result--;
++        low_mask >>= 1;
++    }
++    return result;
++}
++
++static inline uint apply_scale(uint value, uint scale)
++{
++    if (!(scale & 0x07)) // return immediately if scale == 8 or 0
++        return value;
++
++    uint filled = 8 - scale;
++    uint result = value << scale;
++
++    do {
++        result |= result >> filled;
++        filled <<= 1;
++    } while (filled < 8);
++
++    return result;
++}
++
+ static bool read_dib_fileheader(QDataStream &s, BMP_FILEHDR &bf)
+ {
+     // read BMP file header
+@@ -222,14 +248,14 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+     uint green_mask = 0;
+     uint blue_mask = 0;
+     uint alpha_mask = 0;
+-    int red_shift = 0;
+-    int green_shift = 0;
+-    int blue_shift = 0;
+-    int alpha_shift = 0;
+-    int red_scale = 0;
+-    int green_scale = 0;
+-    int blue_scale = 0;
+-    int alpha_scale = 0;
++    uint red_shift = 0;
++    uint green_shift = 0;
++    uint blue_shift = 0;
++    uint alpha_shift = 0;
++    uint red_scale = 0;
++    uint green_scale = 0;
++    uint blue_scale = 0;
++    uint alpha_scale = 0;
+ 
+     if (!d->isSequential())
+         d->seek(startpos + BMP_FILEHDR_SIZE + bi.biSize); // goto start of colormap or masks
+@@ -308,19 +334,19 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+         red_shift = calc_shift(red_mask);
+         if (((red_mask >> red_shift) + 1) == 0)
+             return false;
+-        red_scale = 256 / ((red_mask >> red_shift) + 1);
++        red_scale = calc_scale(red_mask >> red_shift);
+         green_shift = calc_shift(green_mask);
+         if (((green_mask >> green_shift) + 1) == 0)
+             return false;
+-        green_scale = 256 / ((green_mask >> green_shift) + 1);
++        green_scale = calc_scale(green_mask >> green_shift);
+         blue_shift = calc_shift(blue_mask);
+         if (((blue_mask >> blue_shift) + 1) == 0)
+             return false;
+-        blue_scale = 256 / ((blue_mask >> blue_shift) + 1);
++        blue_scale = calc_scale(blue_mask >> blue_shift);
+         alpha_shift = calc_shift(alpha_mask);
+         if (((alpha_mask >> alpha_shift) + 1) == 0)
+             return false;
+-        alpha_scale = 256 / ((alpha_mask >> alpha_shift) + 1);
++        alpha_scale = calc_scale(alpha_mask >> alpha_shift);
+     } else if (comp == BMP_RGB && (nbits == 24 || nbits == 32)) {
+         blue_mask = 0x000000ff;
+         green_mask = 0x0000ff00;
+@@ -328,17 +354,15 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+         blue_shift = 0;
+         green_shift = 8;
+         red_shift = 16;
+-        blue_scale = green_scale = red_scale = 1;
++        blue_scale = green_scale = red_scale = 0;
+     } else if (comp == BMP_RGB && nbits == 16) {
+         blue_mask = 0x001f;
+         green_mask = 0x03e0;
+         red_mask = 0x7c00;
+         blue_shift = 0;
+-        green_shift = 2;
+-        red_shift = 7;
+-        red_scale = 1;
+-        green_scale = 1;
+-        blue_scale = 8;
++        green_shift = 5;
++        red_shift = 10;
++        blue_scale = green_scale = red_scale = 3;
+     }
+ 
+ #if 0
+@@ -544,10 +568,10 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+                     c |= *(uchar*)(b+2)<<16;
+                 if (nbits > 24)
+                     c |= *(uchar*)(b+3)<<24;
+-                *p++ = qRgba(((c & red_mask) >> red_shift) * red_scale,
+-                                        ((c & green_mask) >> green_shift) * green_scale,
+-                                        ((c & blue_mask) >> blue_shift) * blue_scale,
+-                                        transp ? ((c & alpha_mask) >> alpha_shift) * alpha_scale : 0xff);
++                *p++ = qRgba(apply_scale((c & red_mask) >> red_shift, red_scale),
++                             apply_scale((c & green_mask) >> green_shift, green_scale),
++                             apply_scale((c & blue_mask) >> blue_shift, blue_scale),
++                             transp ? apply_scale((c & alpha_mask) >> alpha_shift, alpha_scale) : 0xff);
+                 b += nbits/8;
+             }
+         }
+diff --git a/qtbase/src/gui/image/qimage.cpp b/qtbase/src/gui/image/qimage.cpp
+index 7152ac1607..0df772564c 100644
+--- a/qtbase/src/gui/image/qimage.cpp
++++ b/qtbase/src/gui/image/qimage.cpp
+@@ -4694,6 +4694,8 @@ QImage QImage::smoothScaled(int w, int h) const {
+ static QImage rotated90(const QImage &image)
+ {
+     QImage out(image.height(), image.width(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+@@ -4722,6 +4724,8 @@ static QImage rotated180(const QImage &image)
+         return image.mirrored(true, true);
+ 
+     QImage out(image.width(), image.height(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+@@ -4734,6 +4738,8 @@ static QImage rotated180(const QImage &image)
+ static QImage rotated270(const QImage &image)
+ {
+     QImage out(image.height(), image.width(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+diff --git a/qtbase/src/gui/kernel/qcursor.cpp b/qtbase/src/gui/kernel/qcursor.cpp
+index d6ccaff8ed..455088241c 100644
+--- a/qtbase/src/gui/kernel/qcursor.cpp
++++ b/qtbase/src/gui/kernel/qcursor.cpp
+@@ -251,7 +251,8 @@ void QCursor::setPos(QScreen *screen, int x, int y)
+ {
+     if (screen) {
+         if (QPlatformCursor *cursor = screen->handle()->cursor()) {
+-            const QPoint devicePos = QHighDpi::toNativePixels(QPoint(x, y), screen);
++            const QPoint pos(x, y);
++            const QPoint devicePos = QHighDpi::toNativePixels(pos, screen->virtualSiblingAt(pos));
+             // Need to check, since some X servers generate null mouse move
+             // events, causing looping in applications which call setPos() on
+             // every mouse move event.
+diff --git a/qtbase/src/gui/kernel/qhighdpiscaling.cpp b/qtbase/src/gui/kernel/qhighdpiscaling.cpp
+index 9bbf2773a9..3ac4a4d8b6 100644
+--- a/qtbase/src/gui/kernel/qhighdpiscaling.cpp
++++ b/qtbase/src/gui/kernel/qhighdpiscaling.cpp
+@@ -580,9 +580,8 @@ void QHighDpiScaling::setScreenFactor(QScreen *screen, qreal factor)
+     else
+         qNamedScreenScaleFactors()->insert(name, factor);
+ 
+-    // hack to force re-evaluation of screen geometry
+     if (screen->handle())
+-        screen->d_func()->setPlatformScreen(screen->handle()); // updates geometries based on scale factor
++        screen->d_func()->updateLogicalDpi();
+ }
+ 
+ QPoint QHighDpiScaling::mapPositionToNative(const QPoint &pos, const QPlatformScreen *platformScreen)
+diff --git a/qtbase/src/gui/kernel/qkeysequence.cpp b/qtbase/src/gui/kernel/qkeysequence.cpp
+index a75b8ef920..4f2d294739 100644
+--- a/qtbase/src/gui/kernel/qkeysequence.cpp
++++ b/qtbase/src/gui/kernel/qkeysequence.cpp
+@@ -701,6 +701,10 @@ static const struct {
+     { Qt::Key_TouchpadToggle,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad Toggle") },
+     { Qt::Key_TouchpadOn,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad On") },
+     { Qt::Key_TouchpadOff,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad Off") },
++    { Qt::Key_Shift,  QT_TRANSLATE_NOOP("QShortcut", "Shift") },
++    { Qt::Key_Control,  QT_TRANSLATE_NOOP("QShortcut", "Control") },
++    { Qt::Key_Alt,  QT_TRANSLATE_NOOP("QShortcut", "Alt") },
++    { Qt::Key_Meta,  QT_TRANSLATE_NOOP("QShortcut", "Meta") },
+ 
+ };
+ static Q_CONSTEXPR int numKeyNames = sizeof keyname / sizeof *keyname;
+diff --git a/qtbase/src/gui/kernel/qplatformservices.cpp b/qtbase/src/gui/kernel/qplatformservices.cpp
+index fdc6a6c4aa..ac47f98c5d 100644
+--- a/qtbase/src/gui/kernel/qplatformservices.cpp
++++ b/qtbase/src/gui/kernel/qplatformservices.cpp
+@@ -55,6 +55,19 @@ QT_BEGIN_NAMESPACE
+     \brief The QPlatformServices provides the backend for desktop-related functionality.
+ */
+ 
++/*!
++    \enum QPlatformServices::Capability
++
++    Capabilities are used to determine a specific platform service's availability.
++
++    \value ColorPickingFromScreen The platform natively supports color picking from screen.
++    This capability indicates that the platform supports "opaque" color picking, where the
++    platform implements a complete user experience for color picking and outputs a color.
++    This is in contrast to the application implementing the color picking user experience
++    (taking care of showing a cross hair, instructing the platform integration to obtain
++    the color at a given pixel, etc.). The related service function is pickColor().
++ */
++
+ QPlatformServices::QPlatformServices()
+ { }
+ 
+@@ -85,5 +98,16 @@ QByteArray QPlatformServices::desktopEnvironment() const
+     return QByteArray("UNKNOWN");
+ }
+ 
++QPlatformServiceColorPicker *QPlatformServices::colorPicker(QWindow *parent)
++{
++    Q_UNUSED(parent);
++    return nullptr;
++}
++
++bool QPlatformServices::hasCapability(Capability capability) const
++{
++    Q_UNUSED(capability)
++    return false;
++}
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/gui/kernel/qplatformservices.h b/qtbase/src/gui/kernel/qplatformservices.h
+index 5de96cfa7d..a8b2a4ce71 100644
+--- a/qtbase/src/gui/kernel/qplatformservices.h
++++ b/qtbase/src/gui/kernel/qplatformservices.h
+@@ -50,16 +50,32 @@
+ //
+ 
+ #include <QtGui/qtguiglobal.h>
++#include <QtCore/qobject.h>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+ class QUrl;
++class QWindow;
++
++class Q_GUI_EXPORT QPlatformServiceColorPicker : public QObject
++{
++    Q_OBJECT
++public:
++    using QObject::QObject;
++    virtual void pickColor() = 0;
++Q_SIGNALS:
++    void colorPicked(const QColor &color);
++};
+ 
+ class Q_GUI_EXPORT QPlatformServices
+ {
+ public:
+     Q_DISABLE_COPY_MOVE(QPlatformServices)
+ 
++    enum Capability {
++        ColorPicking,
++    };
++
+     QPlatformServices();
+     virtual ~QPlatformServices() { }
+ 
+@@ -67,6 +83,10 @@ public:
+     virtual bool openDocument(const QUrl &url);
+ 
+     virtual QByteArray desktopEnvironment() const;
++
++    virtual bool hasCapability(Capability capability) const;
++
++    virtual QPlatformServiceColorPicker *colorPicker(QWindow *parent = nullptr);
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/gui/kernel/qplatformtheme.cpp b/qtbase/src/gui/kernel/qplatformtheme.cpp
+index 71521c0339..2325873245 100644
+--- a/qtbase/src/gui/kernel/qplatformtheme.cpp
++++ b/qtbase/src/gui/kernel/qplatformtheme.cpp
+@@ -163,6 +163,8 @@ QT_BEGIN_NAMESPACE
+ 
+     \value ShowShortcutsInContextMenus (bool) Whether to display shortcut key sequences in context menus.
+ 
++    \value ButtonPressKeys (QList<Qt::Key>) A list of keys that can be used to press buttons via keyboard input.
++
+     \sa themeHint(), QStyle::pixelMetric()
+ */
+ 
+@@ -563,6 +565,8 @@ QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint)
+         }
+     case MouseQuickSelectionThreshold:
+         return QVariant(10);
++    case ButtonPressKeys:
++        return QVariant::fromValue(QList<Qt::Key>({ Qt::Key_Space, Qt::Key_Select }));
+     }
+     return QVariant();
+ }
+diff --git a/qtbase/src/gui/kernel/qplatformtheme.h b/qtbase/src/gui/kernel/qplatformtheme.h
+index 3185fc4541..7e6c9d5740 100644
+--- a/qtbase/src/gui/kernel/qplatformtheme.h
++++ b/qtbase/src/gui/kernel/qplatformtheme.h
+@@ -120,7 +120,8 @@ public:
+         TouchDoubleTapDistance,
+         ShowShortcutsInContextMenus,
+         IconFallbackSearchPaths,
+-        MouseQuickSelectionThreshold
++        MouseQuickSelectionThreshold,
++        ButtonPressKeys
+     };
+ 
+     enum DialogType {
+diff --git a/qtbase/src/gui/kernel/qscreen.cpp b/qtbase/src/gui/kernel/qscreen.cpp
+index 8e0eb35116..5d172a58dd 100644
+--- a/qtbase/src/gui/kernel/qscreen.cpp
++++ b/qtbase/src/gui/kernel/qscreen.cpp
+@@ -77,6 +77,12 @@ QScreen::QScreen(QPlatformScreen *screen)
+     d->setPlatformScreen(screen);
+ }
+ 
++void QScreenPrivate::updateLogicalDpi()
++{
++    logicalDpi = QPlatformScreen::overrideDpi(platformScreen->logicalDpi());
++    updateGeometriesWithSignals(); // updates geometries based on scale factor
++}
++
+ void QScreenPrivate::updateGeometriesWithSignals()
+ {
+     const QRect oldGeometry = geometry;
+diff --git a/qtbase/src/gui/kernel/qscreen_p.h b/qtbase/src/gui/kernel/qscreen_p.h
+index 7da542c25e..e50fc3190b 100644
+--- a/qtbase/src/gui/kernel/qscreen_p.h
++++ b/qtbase/src/gui/kernel/qscreen_p.h
+@@ -70,6 +70,7 @@ public:
+         geometry = platformScreen->deviceIndependentGeometry();
+         availableGeometry = QHighDpi::fromNative(platformScreen->availableGeometry(), QHighDpiScaling::factor(platformScreen), geometry.topLeft());
+     }
++    void updateLogicalDpi();
+ 
+     void updatePrimaryOrientation();
+     void updateGeometriesWithSignals();
+diff --git a/qtbase/src/gui/painting/qblendfunctions_p.h b/qtbase/src/gui/painting/qblendfunctions_p.h
+index 080da98ec4..6997d62b3c 100644
+--- a/qtbase/src/gui/painting/qblendfunctions_p.h
++++ b/qtbase/src/gui/painting/qblendfunctions_p.h
+@@ -246,25 +246,32 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+                                   int dudx, int dvdx, int dudy, int dvdy, int u0, int v0,
+                                   Blender blender)
+ {
+-    int fromY = qMax(qRound(topY), clip.top());
+-    int toY = qMin(qRound(bottomY), clip.top() + clip.height());
++    qint64 fromY = qMax(qRound(topY), clip.top());
++    qint64 toY = qMin(qRound(bottomY), clip.top() + clip.height());
+     if (fromY >= toY)
+         return;
+ 
+     qreal leftSlope = (bottomLeft.x - topLeft.x) / (bottomLeft.y - topLeft.y);
+     qreal rightSlope = (bottomRight.x - topRight.x) / (bottomRight.y - topRight.y);
+-    int dx_l = int(leftSlope * 0x10000);
+-    int dx_r = int(rightSlope * 0x10000);
+-    int x_l = int((topLeft.x + (qreal(0.5) + fromY - topLeft.y) * leftSlope + qreal(0.5)) * 0x10000);
+-    int x_r = int((topRight.x + (qreal(0.5) + fromY - topRight.y) * rightSlope + qreal(0.5)) * 0x10000);
+-
+-    int fromX, toX, x1, x2, u, v, i, ii;
++    qint64 dx_l = qint64(leftSlope * 0x10000);
++    qint64 dx_r = qint64(rightSlope * 0x10000);
++    qint64 x_l = qint64((topLeft.x + (qreal(0.5) + fromY - topLeft.y) * leftSlope + qreal(0.5)) * 0x10000);
++    qint64 x_r = qint64((topRight.x + (qreal(0.5) + fromY - topRight.y) * rightSlope + qreal(0.5)) * 0x10000);
++
++    qint64 sourceRectTop = qint64(sourceRect.top());
++    qint64 sourceRectLeft = qint64(sourceRect.left());
++    qint64 sourceRectWidth = qint64(sourceRect.width());
++    qint64 sourceRectHeight = qint64(sourceRect.height());
++    qint64 clipLeft = qint64(clip.left());
++    qint64 clipWidth = qint64(clip.width());
++
++    qint64 fromX, toX, x1, x2, u, v, i, ii;
+     DestT *line;
+-    for (int y = fromY; y < toY; ++y) {
++    for (qint64 y = fromY; y < toY; ++y) {
+         line = reinterpret_cast<DestT *>(reinterpret_cast<uchar *>(destPixels) + y * dbpl);
+ 
+-        fromX = qMax(x_l >> 16, clip.left());
+-        toX = qMin(x_r >> 16, clip.left() + clip.width());
++        fromX = qMax(x_l >> 16, clipLeft);
++        toX = qMin(x_r >> 16, clipLeft + clipWidth);
+         if (fromX < toX) {
+             // Because of rounding, we can get source coordinates outside the source image.
+             // Clamp these coordinates to the source rect to avoid segmentation fault and
+@@ -275,10 +282,10 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             u = x1 * dudx + y * dudy + u0;
+             v = x1 * dvdx + y * dvdy + v0;
+             for (; x1 < toX; ++x1) {
+-                int uu = u >> 16;
+-                int vv = v >> 16;
+-                if (uu >= sourceRect.left() && uu < sourceRect.left() + sourceRect.width()
+-                    && vv >= sourceRect.top() && vv < sourceRect.top() + sourceRect.height()) {
++                qint64 uu = u >> 16;
++                qint64 vv = v >> 16;
++                if (uu >= sourceRectLeft && uu < sourceRectLeft + sourceRectWidth
++                    && vv >= sourceRectTop && vv < sourceRectTop + sourceRectHeight) {
+                     break;
+                 }
+                 u += dudx;
+@@ -290,10 +297,10 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             u = (x2 - 1) * dudx + y * dudy + u0;
+             v = (x2 - 1) * dvdx + y * dvdy + v0;
+             for (; x2 > x1; --x2) {
+-                int uu = u >> 16;
+-                int vv = v >> 16;
+-                if (uu >= sourceRect.left() && uu < sourceRect.left() + sourceRect.width()
+-                    && vv >= sourceRect.top() && vv < sourceRect.top() + sourceRect.height()) {
++                qint64 uu = u >> 16;
++                qint64 vv = v >> 16;
++                if (uu >= sourceRectLeft && uu < sourceRectLeft + sourceRectWidth
++                    && vv >= sourceRectTop && vv < sourceRectTop + sourceRectHeight) {
+                     break;
+                 }
+                 u -= dudx;
+@@ -308,8 +315,8 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             // Beginning of the scan line, with per-pixel checks.
+             i = x1 - fromX;
+             while (i) {
+-                int uu = qBound(sourceRect.left(), u >> 16, sourceRect.left() + sourceRect.width() - 1);
+-                int vv = qBound(sourceRect.top(), v >> 16, sourceRect.top() + sourceRect.height() - 1);
++                qint64 uu = qBound(sourceRectLeft, u >> 16, sourceRectLeft + sourceRectWidth - 1);
++                qint64 vv = qBound(sourceRectTop, v >> 16, sourceRectTop + sourceRectHeight - 1);
+                 blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + vv * sbpl)[uu]);
+                 u += dudx;
+                 v += dvdx;
+@@ -348,8 +355,8 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             // End of the scan line, with per-pixel checks.
+             i = toX - x2;
+             while (i) {
+-                int uu = qBound(sourceRect.left(), u >> 16, sourceRect.left() + sourceRect.width() - 1);
+-                int vv = qBound(sourceRect.top(), v >> 16, sourceRect.top() + sourceRect.height() - 1);
++                qint64 uu = qBound(sourceRectLeft, u >> 16, sourceRectLeft + sourceRectWidth - 1);
++                qint64 vv = qBound(sourceRectTop, v >> 16, sourceRectTop + sourceRectHeight - 1);
+                 blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + vv * sbpl)[uu]);
+                 u += dudx;
+                 v += dvdx;
+diff --git a/qtbase/src/gui/painting/qcolortrclut_p.h b/qtbase/src/gui/painting/qcolortrclut_p.h
+index 76a6a60803..24fd522e6c 100644
+--- a/qtbase/src/gui/painting/qcolortrclut_p.h
++++ b/qtbase/src/gui/painting/qcolortrclut_p.h
+@@ -118,6 +118,7 @@ public:
+         return QRgba64::fromRgba64(r, g, b, qAlpha(rgb32) * 257);
+ #endif
+     }
++    QRgba64 toLinear64(QRgba64) const = delete;
+ 
+     QRgb toLinear(QRgb rgb32) const
+     {
+diff --git a/qtbase/src/gui/painting/qdrawhelper.cpp b/qtbase/src/gui/painting/qdrawhelper.cpp
+index a61793508a..5ba2d277b7 100644
+--- a/qtbase/src/gui/painting/qdrawhelper.cpp
++++ b/qtbase/src/gui/painting/qdrawhelper.cpp
+@@ -6091,7 +6091,7 @@ static inline void alphargbblend_argb32(quint32 *dst, uint coverage, const QRgba
+ static inline void rgbBlendPixel(QRgba64 &dst, int coverage, QRgba64 slinear, const QColorTrcLut *colorProfile)
+ {
+     // Do a gammacorrected RGB alphablend...
+-    const QRgba64 dlinear = colorProfile ? colorProfile->toLinear64(dst) : dst;
++    const QRgba64 dlinear = colorProfile ? colorProfile->toLinear(dst) : dst;
+ 
+     QRgba64 blend = rgbBlend(dlinear, slinear, coverage);
+ 
+diff --git a/qtbase/src/gui/painting/qpaintengine_raster.cpp b/qtbase/src/gui/painting/qpaintengine_raster.cpp
+index 283923de52..f08eb9cbee 100644
+--- a/qtbase/src/gui/painting/qpaintengine_raster.cpp
++++ b/qtbase/src/gui/painting/qpaintengine_raster.cpp
+@@ -560,31 +560,6 @@ void QRasterPaintEngine::updateMatrix(const QTransform &matrix)
+     QRasterPaintEngineState *s = state();
+     // FALCON: get rid of this line, see drawImage call below.
+     s->matrix = matrix;
+-    QTransform::TransformationType txop = s->matrix.type();
+-
+-    switch (txop) {
+-
+-    case QTransform::TxNone:
+-        s->flags.int_xform = true;
+-        break;
+-
+-    case QTransform::TxTranslate:
+-        s->flags.int_xform = qreal(int(s->matrix.dx())) == s->matrix.dx()
+-                            && qreal(int(s->matrix.dy())) == s->matrix.dy();
+-        break;
+-
+-    case QTransform::TxScale:
+-        s->flags.int_xform = qreal(int(s->matrix.dx())) == s->matrix.dx()
+-                            && qreal(int(s->matrix.dy())) == s->matrix.dy()
+-                            && qreal(int(s->matrix.m11())) == s->matrix.m11()
+-                            && qreal(int(s->matrix.m22())) == s->matrix.m22();
+-        break;
+-
+-    default: // shear / perspective...
+-        s->flags.int_xform = false;
+-        break;
+-    }
+-
+     s->flags.tx_noshear = qt_scaleForTransform(s->matrix, &s->txscale);
+ 
+     ensureOutlineMapper();
+@@ -617,7 +592,6 @@ QRasterPaintEngineState::QRasterPaintEngineState()
+     flags.bilinear = false;
+     flags.legacy_rounding = false;
+     flags.fast_text = true;
+-    flags.int_xform = true;
+     flags.tx_noshear = true;
+     flags.fast_images = true;
+ 
+@@ -1793,7 +1767,7 @@ void QRasterPaintEngine::fill(const QVectorPath &path, const QBrush &brush)
+     QRectF cpRect = path.controlPointRect();
+     const QRectF pathDeviceRect = s->matrix.mapRect(cpRect);
+     // Skip paths that by conservative estimates are completely outside the paint device.
+-    if (!pathDeviceRect.intersects(QRectF(d->deviceRect)))
++    if (!pathDeviceRect.intersects(QRectF(d->deviceRect)) || !pathDeviceRect.isValid())
+         return;
+ 
+     ProcessSpans blend = d->getBrushFunc(pathDeviceRect, &s->brushData);
+diff --git a/qtbase/src/gui/painting/qpaintengine_raster_p.h b/qtbase/src/gui/painting/qpaintengine_raster_p.h
+index 089aadc3f7..bf7363d5aa 100644
+--- a/qtbase/src/gui/painting/qpaintengine_raster_p.h
++++ b/qtbase/src/gui/painting/qpaintengine_raster_p.h
+@@ -111,7 +111,6 @@ public:
+         uint bilinear : 1;
+         uint legacy_rounding : 1;
+         uint fast_text : 1;
+-        uint int_xform : 1;
+         uint tx_noshear : 1;
+         uint fast_images : 1;
+     };
+diff --git a/qtbase/src/gui/painting/qpainterpath.cpp b/qtbase/src/gui/painting/qpainterpath.cpp
+index f9544a3241..d80fafeaf1 100644
+--- a/qtbase/src/gui/painting/qpainterpath.cpp
++++ b/qtbase/src/gui/painting/qpainterpath.cpp
+@@ -1253,7 +1253,7 @@ void QPainterPath::addText(const QPointF &point, const QFont &f, const QString &
+ 
+         if (si.analysis.flags < QScriptAnalysis::TabOrObject) {
+             QGlyphLayout glyphs = eng->shapedGlyphs(&si);
+-            QFontEngine *fe = f.d->engineForScript(si.analysis.script);
++            QFontEngine *fe = eng->fontEngine(si);
+             Q_ASSERT(fe);
+             fe->addOutlineToPath(x, y, glyphs, this,
+                                  si.analysis.bidiLevel % 2
+diff --git a/qtbase/src/gui/painting/qpathclipper_p.h b/qtbase/src/gui/painting/qpathclipper_p.h
+index 9444a87b71..18f64c5e8c 100644
+--- a/qtbase/src/gui/painting/qpathclipper_p.h
++++ b/qtbase/src/gui/painting/qpathclipper_p.h
+@@ -156,7 +156,7 @@ public:
+     int vertex(Direction direction) const;
+ 
+ private:
+-    int m_next[2][2];
++    int m_next[2][2] = { { -1, -1 }, { -1, -1 } };
+ };
+ 
+ class QPathSegments
+@@ -296,10 +296,6 @@ inline QPathEdge::QPathEdge(int a, int b)
+     , angle(0)
+     , invAngle(0)
+ {
+-    m_next[0][0] = -1;
+-    m_next[1][0] = -1;
+-    m_next[0][0] = -1;
+-    m_next[1][0] = -1;
+ }
+ 
+ inline int QPathEdge::next(Traversal traversal, Direction direction) const
+diff --git a/qtbase/src/gui/painting/qpdf.cpp b/qtbase/src/gui/painting/qpdf.cpp
+index 3066744f1b..2c8d3c3b53 100644
+--- a/qtbase/src/gui/painting/qpdf.cpp
++++ b/qtbase/src/gui/painting/qpdf.cpp
+@@ -2760,6 +2760,8 @@ int QPdfEnginePrivate::addBrushPattern(const QTransform &m, bool *specifyColor,
+         return gradientBrush(brush, matrix, gStateObject);
+     }
+ 
++    matrix = brush.transform() * matrix;
++
+     if ((!brush.isOpaque() && brush.style() < Qt::LinearGradientPattern) || opacity != 1.0)
+         *gStateObject = addConstantAlphaObject(qRound(brush.color().alpha() * opacity),
+                                                qRound(pen.color().alpha() * opacity));
+diff --git a/qtbase/src/gui/painting/qstroker.cpp b/qtbase/src/gui/painting/qstroker.cpp
+index cb5d395e80..3b6357a893 100644
+--- a/qtbase/src/gui/painting/qstroker.cpp
++++ b/qtbase/src/gui/painting/qstroker.cpp
+@@ -1182,6 +1182,7 @@ void QDashStroker::processCurrentSubpath()
+         // Check if the entire line should be clipped away or simplified
+         bool clipIt = clipping && !lineIntersectsRect(prev, e, clip_tl, clip_br);
+         bool skipDashing = elen * invSumLength > repetitionLimit();
++        int maxDashes = dashCount;
+         if (skipDashing || clipIt) {
+             // Cut away full dash sequences.
+             elen -= std::floor(elen * invSumLength) * sumLength;
+@@ -1196,7 +1197,7 @@ void QDashStroker::processCurrentSubpath()
+                     pos = estop; // move pos to next path element
+                     done = true;
+                 } else { // Dash is on this line
+-                    pos = dpos + estart;
++                    pos = --maxDashes > 0 ? dpos + estart : estop;
+                     done = pos >= estop;
+                     if (++idash >= dashCount)
+                         idash = 0;
+diff --git a/qtbase/src/gui/painting/qt_attribution.json b/qtbase/src/gui/painting/qt_attribution.json
+index 7b16e8c211..0e87d30aa2 100644
+--- a/qtbase/src/gui/painting/qt_attribution.json
++++ b/qtbase/src/gui/painting/qt_attribution.json
+@@ -10,7 +10,7 @@
+         "Homepage": "http://www.freetype.org",
+         "License": "Freetype Project License or GNU General Public License v2.0 only",
+         "LicenseId": "FTL or GPL-2.0",
+-        "LicenseFile": "../../3rdparty/freetype/docs/LICENSE.TXT",
++        "LicenseFile": "../../3rdparty/freetype/LICENSE.TXT",
+         "Copyright": "Copyright 2000-2016 by David Turner, Robert Wilhelm, and Werner Lemberg."
+     },
+     {
+diff --git a/qtbase/src/gui/rhi/qshader_p_p.h b/qtbase/src/gui/rhi/qshader_p_p.h
+index ec9d25971f..4a5a7a6d51 100644
+--- a/qtbase/src/gui/rhi/qshader_p_p.h
++++ b/qtbase/src/gui/rhi/qshader_p_p.h
+@@ -68,13 +68,13 @@ struct Q_GUI_EXPORT QShaderPrivate
+     {
+     }
+ 
+-    QShaderPrivate(const QShaderPrivate *other)
++    QShaderPrivate(const QShaderPrivate &other)
+         : ref(1),
+-          qsbVersion(other->qsbVersion),
+-          stage(other->stage),
+-          desc(other->desc),
+-          shaders(other->shaders),
+-          bindings(other->bindings)
++          qsbVersion(other.qsbVersion),
++          stage(other.stage),
++          desc(other.desc),
++          shaders(other.shaders),
++          bindings(other.bindings)
+     {
+     }
+ 
+diff --git a/qtbase/src/gui/rhi/qshaderdescription_p_p.h b/qtbase/src/gui/rhi/qshaderdescription_p_p.h
+index ec2b0b6b4c..3da33a8a2b 100644
+--- a/qtbase/src/gui/rhi/qshaderdescription_p_p.h
++++ b/qtbase/src/gui/rhi/qshaderdescription_p_p.h
+@@ -63,16 +63,16 @@ struct Q_GUI_EXPORT QShaderDescriptionPrivate
+         localSize[0] = localSize[1] = localSize[2] = 0;
+     }
+ 
+-    QShaderDescriptionPrivate(const QShaderDescriptionPrivate *other)
++    QShaderDescriptionPrivate(const QShaderDescriptionPrivate &other)
+         : ref(1),
+-          inVars(other->inVars),
+-          outVars(other->outVars),
+-          uniformBlocks(other->uniformBlocks),
+-          pushConstantBlocks(other->pushConstantBlocks),
+-          storageBlocks(other->storageBlocks),
+-          combinedImageSamplers(other->combinedImageSamplers),
+-          storageImages(other->storageImages),
+-          localSize(other->localSize)
++          inVars(other.inVars),
++          outVars(other.outVars),
++          uniformBlocks(other.uniformBlocks),
++          pushConstantBlocks(other.pushConstantBlocks),
++          storageBlocks(other.storageBlocks),
++          combinedImageSamplers(other.combinedImageSamplers),
++          storageImages(other.storageImages),
++          localSize(other.localSize)
+     {
+     }
+ 
+diff --git a/qtbase/src/gui/text/qfontdatabase.cpp b/qtbase/src/gui/text/qfontdatabase.cpp
+index a657a8c516..4fc0100958 100644
+--- a/qtbase/src/gui/text/qfontdatabase.cpp
++++ b/qtbase/src/gui/text/qfontdatabase.cpp
+@@ -983,7 +983,7 @@ QFontEngine *loadSingleEngine(int script,
+         if (style->key.stretch != 0 && request.stretch != 0
+             && (request.styleName.isEmpty() || request.styleName != style->styleName)) {
+             def.stretch = (request.stretch * 100 + style->key.stretch / 2) / style->key.stretch;
+-        } else {
++        } else if (request.stretch == QFont::AnyStretch) {
+             def.stretch = 100;
+         }
+ 
+diff --git a/qtbase/src/gui/text/qtextdocumentlayout.cpp b/qtbase/src/gui/text/qtextdocumentlayout.cpp
+index f3e6ea2100..72267e9380 100644
+--- a/qtbase/src/gui/text/qtextdocumentlayout.cpp
++++ b/qtbase/src/gui/text/qtextdocumentlayout.cpp
+@@ -2123,7 +2123,7 @@ void QTextDocumentLayoutPrivate::drawListItem(const QPointF &offset, QPainter *p
+ {
+     Q_Q(const QTextDocumentLayout);
+     const QTextBlockFormat blockFormat = bl.blockFormat();
+-    const QTextCharFormat charFormat = QTextCursor(bl).charFormat();
++    const QTextCharFormat charFormat = bl.charFormat();
+     QFont font(charFormat.font());
+     if (q->paintDevice())
+         font = QFont(font, q->paintDevice());
+diff --git a/qtbase/src/gui/text/qtextengine.cpp b/qtbase/src/gui/text/qtextengine.cpp
+index ce4abac472..a6c66e5d2d 100644
+--- a/qtbase/src/gui/text/qtextengine.cpp
++++ b/qtbase/src/gui/text/qtextengine.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2021 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtGui module of the Qt Toolkit.
+@@ -1565,6 +1565,12 @@ void QTextEngine::shapeText(int item) const
+         // Overwrite with 0 token to indicate failure
+         QGlyphLayout g = availableGlyphs(&si);
+         g.glyphs[0] = 0;
++        g.attributes[0].clusterStart = true;
++
++        ushort *log_clusters = logClusters(&si);
++        for (int i = 0; i < itemLength; ++i)
++            log_clusters[i] = 0;
++
+         return;
+     }
+ 
+diff --git a/qtbase/src/gui/util/qdesktopservices.cpp b/qtbase/src/gui/util/qdesktopservices.cpp
+index fbb63a9408..4d5fafaaa7 100644
+--- a/qtbase/src/gui/util/qdesktopservices.cpp
++++ b/qtbase/src/gui/util/qdesktopservices.cpp
+@@ -54,6 +54,8 @@
+ #include <qpa/qplatformintegration.h>
+ #include <qdir.h>
+ 
++#include <QtCore/private/qlocking_p.h>
++
+ QT_BEGIN_NAMESPACE
+ 
+ class QOpenUrlHandlerRegistry : public QObject
+@@ -81,6 +83,7 @@ Q_GLOBAL_STATIC(QOpenUrlHandlerRegistry, handlerRegistry)
+ 
+ void QOpenUrlHandlerRegistry::handlerDestroyed(QObject *handler)
+ {
++    const auto lock = qt_scoped_lock(mutex);
+     HandlerHash::Iterator it = handlers.begin();
+     while (it != handlers.end()) {
+         if (it->receiver == handler) {
+@@ -294,7 +297,8 @@ void QDesktopServices::setUrlHandler(const QString &scheme, QObject *receiver, c
+     h.name = method;
+     registry->handlers.insert(scheme.toLower(), h);
+     QObject::connect(receiver, SIGNAL(destroyed(QObject*)),
+-                     registry, SLOT(handlerDestroyed(QObject*)));
++                     registry, SLOT(handlerDestroyed(QObject*)),
++                     Qt::DirectConnection);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/gui/util/qpkmhandler.cpp b/qtbase/src/gui/util/qpkmhandler.cpp
+index e0c3b75efe..3414f9d8ba 100644
+--- a/qtbase/src/gui/util/qpkmhandler.cpp
++++ b/qtbase/src/gui/util/qpkmhandler.cpp
+@@ -57,7 +57,7 @@ struct PkmType
+     quint32 bytesPerBlock;
+ };
+ 
+-static PkmType typeMap[5] = {
++static constexpr PkmType typeMap[5] = {
+     { 0x8D64,  8 },   // GL_ETC1_RGB8_OES
+     { 0x9274,  8 },   // GL_COMPRESSED_RGB8_ETC2
+     { 0, 0 },         // unused (obsolete)
+diff --git a/qtbase/src/network/access/qnetworkreplyfileimpl.cpp b/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
+index b6be93147a..6e69b4c4d3 100644
+--- a/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
++++ b/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
+@@ -89,9 +89,10 @@ QNetworkReplyFileImpl::QNetworkReplyFileImpl(QNetworkAccessManager *manager, con
+         // we handle only local files
+         QString msg = QCoreApplication::translate("QNetworkAccessFileBackend", "Request for opening non-local file %1").arg(url.toString());
+         setError(QNetworkReply::ProtocolInvalidOperationError, msg);
++        setFinished(true); // We're finished, will emit finished() after ctor is done.
+         QMetaObject::invokeMethod(this, "errorOccurred", Qt::QueuedConnection,
+             Q_ARG(QNetworkReply::NetworkError, QNetworkReply::ProtocolInvalidOperationError));
+-        fileOpenFinished(false);
++        QMetaObject::invokeMethod(this, [this](){ fileOpenFinished(false); }, Qt::QueuedConnection);
+         return;
+     }
+ #endif
+diff --git a/qtbase/src/network/access/qnetworkreplyimpl.cpp b/qtbase/src/network/access/qnetworkreplyimpl.cpp
+index bcdf6ee2f1..3b6deb82bd 100644
+--- a/qtbase/src/network/access/qnetworkreplyimpl.cpp
++++ b/qtbase/src/network/access/qnetworkreplyimpl.cpp
+@@ -680,7 +680,7 @@ void QNetworkReplyImplPrivate::appendDownstreamData(QIODevice *data)
+     // read until EOF from data
+     if (Q_UNLIKELY(copyDevice)) {
+         qCritical("QNetworkReplyImpl: copy from QIODevice already in progress -- "
+-                  "backend probly needs to be fixed");
++                  "backend probably needs to be fixed");
+         return;
+     }
+ 
+diff --git a/qtbase/src/network/kernel/qauthenticator.cpp b/qtbase/src/network/kernel/qauthenticator.cpp
+index d9fe7bc47b..ccd04b294a 100644
+--- a/qtbase/src/network/kernel/qauthenticator.cpp
++++ b/qtbase/src/network/kernel/qauthenticator.cpp
+@@ -50,6 +50,7 @@
+ #include <qstring.h>
+ #include <qdatetime.h>
+ #include <qrandom.h>
++#include "private/qsystemlibrary_p.h"
+ 
+ #ifdef Q_OS_WIN
+ #include <qmutex.h>
+@@ -1563,7 +1564,7 @@ static bool q_SSPI_library_load()
+ 
+     // Initialize security interface
+     if (pSecurityFunctionTable == nullptr) {
+-        securityDLLHandle = LoadLibrary(L"secur32.dll");
++        securityDLLHandle = QSystemLibrary::load(L"secur32");
+         if (securityDLLHandle != nullptr) {
+             INIT_SECURITY_INTERFACE pInitSecurityInterface =
+                 reinterpret_cast<INIT_SECURITY_INTERFACE>(
+diff --git a/qtbase/src/network/kernel/qhostinfo_unix.cpp b/qtbase/src/network/kernel/qhostinfo_unix.cpp
+index 9b0a2ee669..73679c9ef1 100644
+--- a/qtbase/src/network/kernel/qhostinfo_unix.cpp
++++ b/qtbase/src/network/kernel/qhostinfo_unix.cpp
+@@ -122,7 +122,6 @@ static QFunctionPointer resolveSymbol(QLibrary &lib, const char *sym)
+ 
+ LibResolv::LibResolv()
+ {
+-    QLibrary lib;
+ #ifdef LIBRESOLV_SO
+     lib.setFileName(QStringLiteral(LIBRESOLV_SO));
+     if (!lib.load())
+diff --git a/qtbase/src/network/socket/qsocks5socketengine.cpp b/qtbase/src/network/socket/qsocks5socketengine.cpp
+index 3a046fd116..97fadca0b3 100644
+--- a/qtbase/src/network/socket/qsocks5socketengine.cpp
++++ b/qtbase/src/network/socket/qsocks5socketengine.cpp
+@@ -1296,7 +1296,7 @@ void QSocks5SocketEnginePrivate::_q_udpSocketReadNotification()
+         int pos = 0;
+         const char *buf = inBuf.constData();
+         if (inBuf.size() < 4) {
+-            QSOCKS5_D_DEBUG << "bugus udp data, discarding";
++            QSOCKS5_D_DEBUG << "bogus udp data, discarding";
+             return;
+         }
+         QSocks5RevivedDatagram datagram;
+diff --git a/qtbase/src/network/ssl/qsslcontext_openssl.cpp b/qtbase/src/network/ssl/qsslcontext_openssl.cpp
+index c9f202f573..c992da9d8e 100644
+--- a/qtbase/src/network/ssl/qsslcontext_openssl.cpp
++++ b/qtbase/src/network/ssl/qsslcontext_openssl.cpp
+@@ -409,7 +409,7 @@ init_context:
+         break;
+     case QSsl::DtlsV1_0OrLater:
+         minVersion = DTLS1_VERSION;
+-        maxVersion = DTLS_MAX_VERSION;
++        maxVersion = 0;
+         break;
+     case QSsl::DtlsV1_2:
+         minVersion = DTLS1_2_VERSION;
+@@ -417,7 +417,7 @@ init_context:
+         break;
+     case QSsl::DtlsV1_2OrLater:
+         minVersion = DTLS1_2_VERSION;
+-        maxVersion = DTLS_MAX_VERSION;
++        maxVersion = 0;
+         break;
+     case QSsl::TlsV1_3OrLater:
+ #ifdef TLS1_3_VERSION
+@@ -455,7 +455,7 @@ init_context:
+     }
+ 
+     // Enable bug workarounds.
+-    long options = QSslSocketBackendPrivate::setupOpenSslOptions(configuration.protocol(), configuration.d->sslOptions);
++    qssloptions options = QSslSocketBackendPrivate::setupOpenSslOptions(configuration.protocol(), configuration.d->sslOptions);
+     q_SSL_CTX_set_options(sslContext->ctx, options);
+ 
+     // Tell OpenSSL to release memory early
+diff --git a/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp b/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
+index aaf8741130..b58935372c 100644
+--- a/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
++++ b/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
+@@ -59,57 +59,6 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-#ifdef OPENSSL_NO_DEPRECATED_3_0
+-
+-static int q_DH_check(DH *dh, int *status)
+-{
+-    // DH_check was first deprecated in OpenSSL 3.0.0, as low-level
+-    // API; the EVP_PKEY family of functions was advised as an alternative.
+-    // As of now EVP_PKEY_params_check ends up calling ... DH_check,
+-    // which is good enough.
+-
+-    Q_ASSERT(dh);
+-    Q_ASSERT(status);
+-
+-    EVP_PKEY *key = q_EVP_PKEY_new();
+-    if (!key) {
+-        qCWarning(lcSsl, "EVP_PKEY_new failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-    const auto keyDeleter = qScopeGuard([key](){
+-        q_EVP_PKEY_free(key);
+-    });
+-    if (!q_EVP_PKEY_set1_DH(key, dh)) {
+-        qCWarning(lcSsl, "EVP_PKEY_set1_DH failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-
+-    EVP_PKEY_CTX *keyCtx = q_EVP_PKEY_CTX_new(key, nullptr);
+-    if (!keyCtx) {
+-        qCWarning(lcSsl, "EVP_PKEY_CTX_new failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-    const auto ctxDeleter = qScopeGuard([keyCtx]{
+-        q_EVP_PKEY_CTX_free(keyCtx);
+-    });
+-
+-    const int result = q_EVP_PKEY_param_check(keyCtx);
+-    QSslSocketBackendPrivate::logAndClearErrorQueue();
+-    // Note: unlike DH_check, we cannot obtain the 'status',
+-    // if the 'result' is 0 (actually the result is 1 only
+-    // if this 'status' was 0). We could probably check the
+-    // errors from the error queue, but it's not needed anyway
+-    // - see the 'isSafeDH' below, how it returns immediately
+-    // on 0.
+-    Q_UNUSED(status)
+-
+-    return result;
+-}
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+-
+ static bool isSafeDH(DH *dh)
+ {
+     int status = 0;
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl.cpp b/qtbase/src/network/ssl/qsslsocket_openssl.cpp
+index 37fad2a68f..8f6858c867 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl.cpp
++++ b/qtbase/src/network/ssl/qsslsocket_openssl.cpp
+@@ -550,9 +550,9 @@ static void q_loadCiphersForConnection(SSL *connection, QList<QSslCipher> &ciphe
+ // Defined in qsslsocket.cpp
+ void q_setDefaultDtlsCiphers(const QList<QSslCipher> &ciphers);
+ 
+-long QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions)
++qssloptions QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions)
+ {
+-    long options;
++    qssloptions options;
+     if (protocol == QSsl::TlsV1SslV3)
+         options = SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3;
+     else if (protocol == QSsl::SecureProtocols)
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_p.h b/qtbase/src/network/ssl/qsslsocket_openssl_p.h
+index 4103de23e8..5547589256 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_p.h
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_p.h
+@@ -107,6 +107,12 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++typedef uint64_t qssloptions;
++#else
++typedef unsigned long qssloptions;
++#endif
++
+ struct QSslErrorEntry {
+     int code;
+     int depth;
+@@ -171,7 +177,7 @@ public:
+     QVector<QSslError> ocspErrors;
+     QByteArray ocspResponseDer;
+ 
+-    Q_AUTOTEST_EXPORT static long setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions);
++    Q_AUTOTEST_EXPORT static qssloptions setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions);
+     static QSslCipher QSslCipher_from_SSL_CIPHER(const SSL_CIPHER *cipher);
+     static QList<QSslCertificate> STACKOFX509_to_QSslCertificates(STACK_OF(X509) *x509);
+     static QList<QSslError> verify(const QList<QSslCertificate> &certificateChain, const QString &hostName);
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp b/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
+index e53fb279f0..459ccd0b19 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
+@@ -148,7 +148,6 @@ DEFINEFUNC(int, EVP_PKEY_up_ref, EVP_PKEY *a, a, return 0, return)
+ DEFINEFUNC2(EVP_PKEY_CTX *, EVP_PKEY_CTX_new, EVP_PKEY *pkey, pkey, ENGINE *e, e, return nullptr, return)
+ DEFINEFUNC(int, EVP_PKEY_param_check, EVP_PKEY_CTX *ctx, ctx, return 0, return)
+ DEFINEFUNC(void, EVP_PKEY_CTX_free, EVP_PKEY_CTX *ctx, ctx, return, return)
+-DEFINEFUNC(int, EVP_PKEY_base_id, EVP_PKEY *a, a, return NID_undef, return)
+ DEFINEFUNC(int, RSA_bits, RSA *a, a, return 0, return)
+ DEFINEFUNC(int, DSA_bits, DSA *a, a, return 0, return)
+ DEFINEFUNC(int, OPENSSL_sk_num, OPENSSL_STACK *a, a, return -1, return)
+@@ -158,7 +157,7 @@ DEFINEFUNC2(void, OPENSSL_sk_push, OPENSSL_STACK *a, a, void *b, b, return, DUMM
+ DEFINEFUNC(void, OPENSSL_sk_free, OPENSSL_STACK *a, a, return, DUMMYARG)
+ DEFINEFUNC2(void *, OPENSSL_sk_value, OPENSSL_STACK *a, a, int b, b, return nullptr, return)
+ DEFINEFUNC(int, SSL_session_reused, SSL *a, a, return 0, return)
+-DEFINEFUNC2(unsigned long, SSL_CTX_set_options, SSL_CTX *ctx, ctx, unsigned long op, op, return 0, return)
++DEFINEFUNC2(qssloptions, SSL_CTX_set_options, SSL_CTX *ctx, ctx, qssloptions op, op, return 0, return)
+ DEFINEFUNC(int, SSL_CTX_get_security_level, const SSL_CTX *ctx, ctx, return -1, return)
+ DEFINEFUNC2(void, SSL_CTX_set_security_level, SSL_CTX *ctx, ctx, int level, level, return, return)
+ #ifdef TLS1_3_VERSION
+@@ -371,7 +370,15 @@ DEFINEFUNC(const SSL_CIPHER *, SSL_get_current_cipher, SSL *a, a, return nullptr
+ DEFINEFUNC(int, SSL_version, const SSL *a, a, return 0, return)
+ DEFINEFUNC2(int, SSL_get_error, SSL *a, a, int b, b, return -1, return)
+ DEFINEFUNC(STACK_OF(X509) *, SSL_get_peer_cert_chain, SSL *a, a, return nullptr, return)
++
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++DEFINEFUNC(X509 *, SSL_get1_peer_certificate, SSL *a, a, return nullptr, return)
++DEFINEFUNC(int, EVP_PKEY_get_base_id, const EVP_PKEY *pkey, pkey, return -1, return)
++#else
+ DEFINEFUNC(X509 *, SSL_get_peer_certificate, SSL *a, a, return nullptr, return)
++DEFINEFUNC(int, EVP_PKEY_base_id, EVP_PKEY *a, a, return NID_undef, return)
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+ DEFINEFUNC(long, SSL_get_verify_result, const SSL *a, a, return -1, return)
+ DEFINEFUNC(SSL *, SSL_new, SSL_CTX *a, a, return nullptr, return)
+ DEFINEFUNC(SSL_CTX *, SSL_get_SSL_CTX, SSL *a, a, return nullptr, return)
+@@ -492,9 +499,7 @@ DEFINEFUNC(DH *, DH_new, DUMMYARG, DUMMYARG, return nullptr, return)
+ DEFINEFUNC(void, DH_free, DH *dh, dh, return, DUMMYARG)
+ DEFINEFUNC3(DH *, d2i_DHparams, DH**a, a, const unsigned char **pp, pp, long length, length, return nullptr, return)
+ DEFINEFUNC2(int, i2d_DHparams, DH *a, a, unsigned char **p, p, return -1, return)
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+ DEFINEFUNC2(int, DH_check, DH *dh, dh, int *codes, codes, return 0, return)
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+ DEFINEFUNC3(BIGNUM *, BN_bin2bn, const unsigned char *s, s, int len, len, BIGNUM *ret, ret, return nullptr, return)
+ 
+ #ifndef OPENSSL_NO_EC
+@@ -868,7 +873,6 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(EVP_PKEY_CTX_new)
+     RESOLVEFUNC(EVP_PKEY_param_check)
+     RESOLVEFUNC(EVP_PKEY_CTX_free)
+-    RESOLVEFUNC(EVP_PKEY_base_id)
+     RESOLVEFUNC(RSA_bits)
+     RESOLVEFUNC(OPENSSL_sk_new_null)
+     RESOLVEFUNC(OPENSSL_sk_push)
+@@ -1107,7 +1111,15 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(SSL_version)
+     RESOLVEFUNC(SSL_get_error)
+     RESOLVEFUNC(SSL_get_peer_cert_chain)
++
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++    RESOLVEFUNC(SSL_get1_peer_certificate)
++    RESOLVEFUNC(EVP_PKEY_get_base_id)
++#else
+     RESOLVEFUNC(SSL_get_peer_certificate)
++    RESOLVEFUNC(EVP_PKEY_base_id)
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+     RESOLVEFUNC(SSL_get_verify_result)
+     RESOLVEFUNC(SSL_new)
+     RESOLVEFUNC(SSL_get_SSL_CTX)
+@@ -1206,9 +1218,7 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(DH_free)
+     RESOLVEFUNC(d2i_DHparams)
+     RESOLVEFUNC(i2d_DHparams)
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+     RESOLVEFUNC(DH_check)
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+     RESOLVEFUNC(BN_bin2bn)
+ 
+ #ifndef OPENSSL_NO_EC
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h b/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
+index 95e8897a3b..27aeffa18a 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
+@@ -237,7 +237,6 @@ Q_AUTOTEST_EXPORT int q_EVP_PKEY_up_ref(EVP_PKEY *a);
+ EVP_PKEY_CTX *q_EVP_PKEY_CTX_new(EVP_PKEY *pkey, ENGINE *e);
+ void q_EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx);
+ int q_EVP_PKEY_param_check(EVP_PKEY_CTX *ctx);
+-int q_EVP_PKEY_base_id(EVP_PKEY *a);
+ int q_RSA_bits(RSA *a);
+ Q_AUTOTEST_EXPORT int q_OPENSSL_sk_num(OPENSSL_STACK *a);
+ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_pop_free(OPENSSL_STACK *a, void (*b)(void *));
+@@ -246,7 +245,7 @@ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_push(OPENSSL_STACK *st, void *data);
+ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_free(OPENSSL_STACK *a);
+ Q_AUTOTEST_EXPORT void * q_OPENSSL_sk_value(OPENSSL_STACK *a, int b);
+ int q_SSL_session_reused(SSL *a);
+-unsigned long q_SSL_CTX_set_options(SSL_CTX *ctx, unsigned long op);
++qssloptions q_SSL_CTX_set_options(SSL_CTX *ctx, qssloptions op);
+ int q_OPENSSL_init_ssl(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings);
+ size_t q_SSL_get_client_random(SSL *a, unsigned char *out, size_t outlen);
+ size_t q_SSL_SESSION_get_master_key(const SSL_SESSION *session, unsigned char *out, size_t outlen);
+@@ -510,7 +509,6 @@ const SSL_CIPHER *q_SSL_get_current_cipher(SSL *a);
+ int q_SSL_version(const SSL *a);
+ int q_SSL_get_error(SSL *a, int b);
+ STACK_OF(X509) *q_SSL_get_peer_cert_chain(SSL *a);
+-X509 *q_SSL_get_peer_certificate(SSL *a);
+ long q_SSL_get_verify_result(const SSL *a);
+ SSL *q_SSL_new(SSL_CTX *a);
+ SSL_CTX *q_SSL_get_SSL_CTX(SSL *a);
+@@ -582,10 +580,7 @@ DH *q_DH_new();
+ void q_DH_free(DH *dh);
+ DH *q_d2i_DHparams(DH **a, const unsigned char **pp, long length);
+ int q_i2d_DHparams(DH *a, unsigned char **p);
+-
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+ int q_DH_check(DH *dh, int *codes);
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+ 
+ BIGNUM *q_BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret);
+ #define q_SSL_CTX_set_tmp_dh(ctx, dh) q_SSL_CTX_ctrl((ctx), SSL_CTRL_SET_TMP_DH, 0, (char *)dh)
+@@ -754,6 +749,17 @@ void q_CRYPTO_free(void *str, const char *file, int line);
+ int q_SSL_CTX_get_security_level(const SSL_CTX *ctx);
+ void q_SSL_CTX_set_security_level(SSL_CTX *ctx, int level);
+ 
++// Here we have the ones that make difference between OpenSSL pre/post v3:
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++X509 *q_SSL_get1_peer_certificate(SSL *a);
++#define q_SSL_get_peer_certificate q_SSL_get1_peer_certificate
++int q_EVP_PKEY_get_base_id(const EVP_PKEY *pkey);
++#define q_EVP_PKEY_base_id q_EVP_PKEY_get_base_id
++#else
++X509 *q_SSL_get_peer_certificate(SSL *a);
++int q_EVP_PKEY_base_id(EVP_PKEY *a);
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+ QT_END_NAMESPACE
+ 
+ #endif
+diff --git a/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h b/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
+index bf37d07fd8..dbd42fb799 100644
+--- a/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
++++ b/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
+@@ -61,7 +61,11 @@
+ # if !defined(Q_OS_INTEGRITY)
+ #  define WIN_INTERFACE_CUSTOM   // NV
+ # endif // Q_OS_INTEGRITY
+-#endif  // QT_EGL_NO_X11
++#else // QT_EGL_NO_X11
++// If one has an eglplatform.h with https://github.com/KhronosGroup/EGL-Registry/pull/130
++// that needs USE_X11 to be defined.
++# define USE_X11
++#endif
+ 
+ #ifdef QT_EGL_WAYLAND
+ # define WAYLAND // NV
+diff --git a/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+index 159b490ce0..00aa80cd58 100644
+--- a/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
++++ b/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+@@ -567,6 +567,8 @@ void QFontconfigDatabase::populateFontDatabase()
+         fonts = FcFontList(nullptr, pattern, os);
+         FcObjectSetDestroy(os);
+         FcPatternDestroy(pattern);
++        if (!fonts)
++            return;
+     }
+ 
+     for (int i = 0; i < fonts->nfont; i++)
+diff --git a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
+index b713c19447..7cb9a8c79a 100644
+--- a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
++++ b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
+@@ -95,6 +95,7 @@ static constexpr const auto KeyTbl = qMakeArray(
+         Xkb2Qt<XKB_KEY_Clear,                   Qt::Key_Delete>,
+         Xkb2Qt<XKB_KEY_Pause,                   Qt::Key_Pause>,
+         Xkb2Qt<XKB_KEY_Print,                   Qt::Key_Print>,
++        Xkb2Qt<XKB_KEY_Sys_Req,                 Qt::Key_SysReq>,
+         Xkb2Qt<0x1005FF60,                      Qt::Key_SysReq>,         // hardcoded Sun SysReq
+         Xkb2Qt<0x1007ff00,                      Qt::Key_SysReq>,         // hardcoded X386 SysReq
+ 
+@@ -471,7 +472,7 @@ QVector<xkb_keysym_t> QXkbCommon::toKeysym(QKeyEvent *event)
+     } else if (event->modifiers() & Qt::KeypadModifier) {
+         if (qtKey >= Qt::Key_0 && qtKey <= Qt::Key_9)
+             keysyms.append(XKB_KEY_KP_0 + (qtKey - Qt::Key_0));
+-    } else if (isLatin(qtKey) && event->text().isUpper()) {
++    } else if (isLatin1(qtKey) && event->text().isUpper()) {
+         keysyms.append(qtKey);
+     }
+ 
+@@ -523,7 +524,7 @@ int QXkbCommon::keysymToQtKey(xkb_keysym_t keysym, Qt::KeyboardModifiers modifie
+         // With standard shortcuts we should prefer a latin character, this is
+         // for checks like "some qkeyevent == QKeySequence::Copy" to work even
+         // when using for example 'russian' keyboard layout.
+-        if (!QXkbCommon::isLatin(keysym)) {
++        if (!QXkbCommon::isLatin1(keysym)) {
+             xkb_keysym_t latinKeysym = QXkbCommon::lookupLatinKeysym(state, code);
+             if (latinKeysym != XKB_KEY_NoSymbol)
+                 keysym = latinKeysym;
+@@ -546,7 +547,7 @@ static int keysymToQtKey_internal(xkb_keysym_t keysym, Qt::KeyboardModifiers mod
+     } else if (keysym >= XKB_KEY_KP_0 && keysym <= XKB_KEY_KP_9) {
+         // numeric keypad keys
+         qtKey = Qt::Key_0 + (keysym - XKB_KEY_KP_0);
+-    } else if (QXkbCommon::isLatin(keysym)) {
++    } else if (QXkbCommon::isLatin1(keysym)) {
+         qtKey = QXkbCommon::qxkbcommon_xkb_keysym_to_upper(keysym);
+     } else {
+         // check if we have a direct mapping
+@@ -678,7 +679,7 @@ QList<int> QXkbCommon::possibleKeys(xkb_state *state, const QKeyEvent *event,
+         Qt::KeyboardModifiers neededMods = ModsTbl[i];
+         if ((modifiers & neededMods) == neededMods) {
+             if (i == 8) {
+-                if (isLatin(baseQtKey))
++                if (isLatin1(baseQtKey))
+                     continue;
+                 // add a latin key as a fall back key
+                 sym = lookupLatinKeysym(state, keycode);
+@@ -733,7 +734,7 @@ void QXkbCommon::verifyHasLatinLayout(xkb_keymap *keymap)
+     for (xkb_layout_index_t layout = 0; layout < layoutCount; ++layout) {
+         for (xkb_keycode_t code = minKeycode; code < maxKeycode; ++code) {
+             xkb_keymap_key_get_syms_by_level(keymap, code, layout, 0, &keysyms);
+-            if (keysyms && isLatin(keysyms[0]))
++            if (keysyms && isLatin1(keysyms[0]))
+                 nrLatinKeys++;
+             if (nrLatinKeys > 10) // arbitrarily chosen threshold
+                 return;
+@@ -766,7 +767,7 @@ xkb_keysym_t QXkbCommon::lookupLatinKeysym(xkb_state *state, xkb_keycode_t keyco
+         xkb_level_index_t level = xkb_state_key_get_level(state, keycode, layout);
+         if (xkb_keymap_key_get_syms_by_level(keymap, keycode, layout, level, &syms) != 1)
+             continue;
+-        if (isLatin(syms[0])) {
++        if (isLatin1(syms[0])) {
+             sym = syms[0];
+             break;
+         }
+diff --git a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
+index 561eae03db..8389bd8f5a 100644
+--- a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
++++ b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
+@@ -94,8 +94,8 @@ public:
+     static void verifyHasLatinLayout(xkb_keymap *keymap);
+     static xkb_keysym_t lookupLatinKeysym(xkb_state *state, xkb_keycode_t keycode);
+ 
+-    static bool isLatin(xkb_keysym_t sym) {
+-        return ((sym >= 'a' && sym <= 'z') || (sym >= 'A' && sym <= 'Z'));
++    static bool isLatin1(xkb_keysym_t sym) {
++        return sym <= 0xff;
+     }
+     static bool isKeypad(xkb_keysym_t sym) {
+         return sym >= XKB_KEY_KP_Space && sym <= XKB_KEY_KP_9;
+diff --git a/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp b/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
+index 8cd7f9b368..406f84663f 100644
+--- a/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
++++ b/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
+@@ -318,7 +318,7 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources,
+ 
+     if (current < 0 && crtc_mode.clock != 0) {
+         modes << crtc_mode;
+-        current = mode.size() - 1;
++        current = modes.size() - 1;
+     }
+ 
+     if (configuration == OutputConfigCurrent)
+diff --git a/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp b/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
+index 9153fd20bb..255ea5e33e 100644
+--- a/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
++++ b/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
+@@ -194,6 +194,9 @@ QString AtSpiAdaptor::introspect(const QString &path) const
+                 "      <arg direction=\"out\" type=\"(so)\"/>\n"
+                 "      <annotation value=\"QSpiObjectReference\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n"
+                 "    </method>\n"
++                "    <method name=\"GetAccessibleId\">\n"
++                "      <arg direction=\"out\" type=\"s\"/>\n"
++                "    </method>\n"
+                 "  </interface>\n"
+                 );
+ 
+@@ -913,8 +916,17 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+     }
+     case QAccessible::NameChanged: {
+         if (sendObject || sendObject_property_change || sendObject_property_change_accessible_name) {
+-            QString path = pathForInterface(event->accessibleInterface());
+-            QVariantList args = packDBusSignalArguments(QLatin1String("accessible-name"), 0, 0, variantForPath(path));
++            QAccessibleInterface *iface = event->accessibleInterface();
++            if (!iface) {
++                qCDebug(lcAccessibilityAtspi,
++                        "NameChanged event from invalid accessible.");
++                return;
++            }
++
++            QString path = pathForInterface(iface);
++            QVariantList args = packDBusSignalArguments(
++                QLatin1String("accessible-name"), 0, 0,
++                QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Name))));
+             sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                            QLatin1String("PropertyChange"), args);
+         }
+@@ -922,8 +934,17 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+     }
+     case QAccessible::DescriptionChanged: {
+         if (sendObject || sendObject_property_change || sendObject_property_change_accessible_description) {
+-            QString path = pathForInterface(event->accessibleInterface());
+-            QVariantList args = packDBusSignalArguments(QLatin1String("accessible-description"), 0, 0, variantForPath(path));
++            QAccessibleInterface *iface = event->accessibleInterface();
++            if (!iface) {
++                qCDebug(lcAccessibilityAtspi,
++                        "DescriptionChanged event from invalid accessible.");
++                return;
++            }
++
++            QString path = pathForInterface(iface);
++            QVariantList args = packDBusSignalArguments(
++                QLatin1String("accessible-description"), 0, 0,
++                QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Description))));
+             sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                            QLatin1String("PropertyChange"), args);
+         }
+@@ -1038,7 +1059,9 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+                 // Combo Box with AT-SPI likes to be special
+                 // It requires a name-change to update caches and then selection-changed
+                 QString path = pathForInterface(iface);
+-                QVariantList args1 = packDBusSignalArguments(QLatin1String("accessible-name"), 0, 0, variantForPath(path));
++                QVariantList args1 = packDBusSignalArguments(
++                    QLatin1String("accessible-name"), 0, 0,
++                    QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Name))));
+                 sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                                QLatin1String("PropertyChange"), args1);
+                 QVariantList args2 = packDBusSignalArguments(QString(), 0, 0, QVariant::fromValue(QDBusVariant(QVariant(0))));
+@@ -1358,6 +1381,26 @@ void AtSpiAdaptor::registerApplication()
+     delete registry;
+ }
+ 
++namespace {
++QString accessibleIdForAccessible(QAccessibleInterface *accessible)
++{
++    QString result;
++    while (accessible) {
++        if (!result.isEmpty())
++            result.prepend(QLatin1Char('.'));
++        if (auto obj = accessible->object()) {
++            const QString name = obj->objectName();
++            if (!name.isEmpty())
++                result.prepend(name);
++            else
++                result.prepend(QString::fromUtf8(obj->metaObject()->className()));
++        }
++        accessible = accessible->parent();
++    }
++    return result;
++}
++} // namespace
++
+ // Accessible
+ bool AtSpiAdaptor::accessibleInterface(QAccessibleInterface *interface, const QString &function, const QDBusMessage &message, const QDBusConnection &connection)
+ {
+@@ -1441,6 +1484,9 @@ bool AtSpiAdaptor::accessibleInterface(QAccessibleInterface *interface, const QS
+             children << ref;
+         }
+         connection.send(message.createReply(QVariant::fromValue(children)));
++    } else if (function == QLatin1String("GetAccessibleId")) {
++        sendReply(connection, message,
++                  QVariant::fromValue(QDBusVariant(accessibleIdForAccessible(interface))));
+     } else {
+         qCDebug(lcAccessibilityAtspi) << "WARNING: AtSpiAdaptor::accessibleInterface does not implement " << function << message.path();
+         return false;
+diff --git a/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp b/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
+index 45ddc8e496..cc734abc63 100644
+--- a/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
++++ b/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
+@@ -69,6 +69,21 @@ QT_BEGIN_NAMESPACE
+ DBusConnection::DBusConnection(QObject *parent)
+     : QObject(parent), m_a11yConnection(QString()), m_enabled(false)
+ {
++    // If the bus is explicitly set via env var it overrides everything else.
++    QByteArray addressEnv = qgetenv("AT_SPI_BUS_ADDRESS");
++    if (!addressEnv.isEmpty()) {
++        // Only connect on next loop run, connections to our enabled signal are
++        // only established after the ctor returns.
++        QMetaObject::invokeMethod(
++                this,
++                [this, addressEnv] {
++                    m_enabled = true;
++                    connectA11yBus(QString::fromLocal8Bit(addressEnv));
++                },
++                Qt::QueuedConnection);
++        return;
++    }
++
+     // Start monitoring if "org.a11y.Bus" is registered as DBus service.
+     QDBusConnection c = QDBusConnection::sessionBus();
+     if (!c.isConnected()) {
+diff --git a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
+index 1a3cab275d..2abe039126 100644
+--- a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
++++ b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
+@@ -51,6 +51,9 @@
+ #include <QtCore/QStandardPaths>
+ #include <QtCore/QUrl>
+ 
++#include <QtGui/QGuiApplication>
++#include <QtGui/QWindow>
++
+ #if QT_CONFIG(dbus)
+ // These QtCore includes are needed for xdg-desktop-portal support
+ #include <QtCore/private/qcore_unix_p.h>
+@@ -58,6 +61,8 @@
+ #include <QtCore/QFileInfo>
+ #include <QtCore/QUrlQuery>
+ 
++#include <QtGui/QColor>
++
+ #include <QtDBus/QDBusConnection>
+ #include <QtDBus/QDBusMessage>
+ #include <QtDBus/QDBusPendingCall>
+@@ -142,6 +147,8 @@ static inline bool detectWebBrowser(const QByteArray &desktop,
+     }
+ 
+     if (desktop == QByteArray("KDE")) {
++        if (checkExecutable(QStringLiteral("kde-open5"), browser))
++            return true;
+         // Konqueror launcher
+         if (checkExecutable(QStringLiteral("kfmclient"), browser)) {
+             browser->append(QLatin1String(" exec"));
+@@ -296,8 +303,135 @@ static inline QDBusMessage xdgDesktopPortalSendEmail(const QUrl &url)
+ 
+     return QDBusConnection::sessionBus().call(message);
+ }
++
++namespace {
++struct XDGDesktopColor
++{
++    double r = 0;
++    double g = 0;
++    double b = 0;
++
++    QColor toQColor() const
++    {
++        constexpr auto rgbMax = 255;
++        return { static_cast<int>(r * rgbMax), static_cast<int>(g * rgbMax),
++                 static_cast<int>(b * rgbMax) };
++    }
++};
++
++const QDBusArgument &operator>>(const QDBusArgument &argument, XDGDesktopColor &myStruct)
++{
++    argument.beginStructure();
++    argument >> myStruct.r >> myStruct.g >> myStruct.b;
++    argument.endStructure();
++    return argument;
++}
++
++class XdgDesktopPortalColorPicker : public QPlatformServiceColorPicker
++{
++    Q_OBJECT
++public:
++    XdgDesktopPortalColorPicker(const QString &parentWindowId, QWindow *parent)
++        : QPlatformServiceColorPicker(parent), m_parentWindowId(parentWindowId)
++    {
++    }
++
++    void pickColor() override
++    {
++        // DBus signature:
++        // PickColor (IN   s      parent_window,
++        //            IN   a{sv}  options
++        //            OUT  o      handle)
++        // Options:
++        // handle_token (s) -  A string that will be used as the last element of the @handle.
++
++        QDBusMessage message = QDBusMessage::createMethodCall(
++                QStringLiteral("org.freedesktop.portal.Desktop"), QStringLiteral("/org/freedesktop/portal/desktop"),
++                QStringLiteral("org.freedesktop.portal.Screenshot"), QStringLiteral("PickColor"));
++        message << m_parentWindowId << QVariantMap();
++
++        QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
++        auto watcher = new QDBusPendingCallWatcher(pendingCall, this);
++        connect(watcher, &QDBusPendingCallWatcher::finished, this,
++                [this](QDBusPendingCallWatcher *watcher) {
++                    watcher->deleteLater();
++                    QDBusPendingReply<QDBusObjectPath> reply = *watcher;
++                    if (reply.isError()) {
++                        qWarning("DBus call to pick color failed: %s",
++                                 qPrintable(reply.error().message()));
++                        Q_EMIT colorPicked({});
++                    } else {
++                        QDBusConnection::sessionBus().connect(
++                                QStringLiteral("org.freedesktop.portal.Desktop"), reply.value().path(),
++                                QStringLiteral("org.freedesktop.portal.Request"), QStringLiteral("Response"), this,
++                                // clang-format off
++                                SLOT(gotColorResponse(uint,QVariantMap))
++                                // clang-format on
++                        );
++                    }
++                });
++    }
++
++private Q_SLOTS:
++    void gotColorResponse(uint result, const QVariantMap &map)
++    {
++        if (result != 0)
++            return;
++        XDGDesktopColor color{};
++        map.value(QStringLiteral("color")).value<QDBusArgument>() >> color;
++        Q_EMIT colorPicked(color.toQColor());
++        deleteLater();
++    }
++
++private:
++    const QString m_parentWindowId;
++};
++} // namespace
++
+ #endif // QT_CONFIG(dbus)
+ 
++QGenericUnixServices::QGenericUnixServices()
++{
++#if QT_CONFIG(dbus)
++    if (qEnvironmentVariableIntValue("QT_NO_XDG_DESKTOP_PORTAL") > 0) {
++        return;
++    }
++    QDBusMessage message = QDBusMessage::createMethodCall(
++            QStringLiteral("org.freedesktop.portal.Desktop"), QStringLiteral("/org/freedesktop/portal/desktop"),
++            QStringLiteral("org.freedesktop.DBus.Properties"), QStringLiteral("Get"));
++    message << QStringLiteral("org.freedesktop.portal.Screenshot")
++            << QStringLiteral("version");
++
++    QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
++    auto watcher = new QDBusPendingCallWatcher(pendingCall);
++    QObject::connect(watcher, &QDBusPendingCallWatcher::finished, watcher,
++                     [this](QDBusPendingCallWatcher *watcher) {
++                         watcher->deleteLater();
++                         QDBusPendingReply<QVariant> reply = *watcher;
++                         if (!reply.isError() && reply.value().toUInt() >= 2)
++                             m_hasScreenshotPortalWithColorPicking = true;
++                     });
++
++#endif
++}
++
++QPlatformServiceColorPicker *QGenericUnixServices::colorPicker(QWindow *parent)
++{
++#if QT_CONFIG(dbus)
++    // Make double sure that we are in a wayland environment. In particular check
++    // WAYLAND_DISPLAY so also XWayland apps benefit from portal-based color picking.
++    // Outside wayland we'll rather rely on other means than the XDG desktop portal.
++    if (!qEnvironmentVariableIsEmpty("WAYLAND_DISPLAY")
++        || QGuiApplication::platformName().startsWith(QLatin1String("wayland"))) {
++        return new XdgDesktopPortalColorPicker(portalWindowIdentifier(parent), parent);
++    }
++    return nullptr;
++#else
++    Q_UNUSED(parent);
++    return nullptr;
++#endif
++}
++
+ QByteArray QGenericUnixServices::desktopEnvironment() const
+ {
+     static const QByteArray result = detectDesktopEnvironment();
+@@ -352,6 +486,8 @@ bool QGenericUnixServices::openDocument(const QUrl &url)
+ }
+ 
+ #else
++QGenericUnixServices::QGenericUnixServices() = default;
++
+ QByteArray QGenericUnixServices::desktopEnvironment() const
+ {
+     return QByteArrayLiteral("UNKNOWN");
+@@ -371,6 +507,30 @@ bool QGenericUnixServices::openDocument(const QUrl &url)
+     return false;
+ }
+ 
++QPlatformServiceColorPicker *QGenericUnixServices::colorPicker(QWindow *parent)
++{
++    Q_UNUSED(parent);
++    return nullptr;
++}
++
+ #endif // QT_NO_MULTIPROCESS
+ 
++QString QGenericUnixServices::portalWindowIdentifier(QWindow *window)
++{
++    if (QGuiApplication::platformName() == QLatin1String("xcb"))
++        return QStringLiteral("x11:") + QString::number(window->winId(), 16);
++    return QString();
++}
++
++bool QGenericUnixServices::hasCapability(Capability capability) const
++{
++    switch (capability) {
++    case Capability::ColorPicking:
++        return m_hasScreenshotPortalWithColorPicking;
++    }
++    return false;
++}
++
+ QT_END_NAMESPACE
++
++#include "qgenericunixservices.moc"
+diff --git a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
+index 8ac3de6f03..30924e64bd 100644
+--- a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
++++ b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
+@@ -59,16 +59,21 @@ QT_BEGIN_NAMESPACE
+ class QGenericUnixServices : public QPlatformServices
+ {
+ public:
+-    QGenericUnixServices() {}
++    QGenericUnixServices();
+ 
+     QByteArray desktopEnvironment() const override;
+ 
++    bool hasCapability(Capability capability) const override;
+     bool openUrl(const QUrl &url) override;
+     bool openDocument(const QUrl &url) override;
++    QPlatformServiceColorPicker *colorPicker(QWindow *parent = nullptr) override;
++
++    virtual QString portalWindowIdentifier(QWindow *window);
+ 
+ private:
+     QString m_webBrowser;
+     QString m_documentLauncher;
++    bool m_hasScreenshotPortalWithColorPicking = false;
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
+index 09470bccc6..cc7c7d4d8a 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
+@@ -69,6 +69,7 @@ const QString MenuBarPath = QLatin1String("/MenuBar");
+ */
+ QDBusMenuConnection::QDBusMenuConnection(QObject *parent, const QString &serviceName)
+     : QObject(parent)
++    , m_serviceName(serviceName)
+     , m_connection(serviceName.isNull() ? QDBusConnection::sessionBus()
+                                         : QDBusConnection::connectToBus(QDBusConnection::SessionBus, serviceName))
+     , m_dbusWatcher(new QDBusServiceWatcher(StatusNotifierWatcherService, m_connection, QDBusServiceWatcher::WatchForRegistration, this))
+@@ -83,6 +84,12 @@ QDBusMenuConnection::QDBusMenuConnection(QObject *parent, const QString &service
+ #endif
+ }
+ 
++QDBusMenuConnection::~QDBusMenuConnection()
++{
++  if (!m_serviceName.isEmpty() && m_connection.isConnected())
++      QDBusConnection::disconnectFromBus(m_serviceName);
++}
++
+ void QDBusMenuConnection::dbusError(const QDBusError &error)
+ {
+     qWarning() << "QDBusTrayIcon encountered a D-Bus error:" << error;
+@@ -105,13 +112,7 @@ void QDBusMenuConnection::unregisterTrayIconMenu(QDBusTrayIcon *item)
+ 
+ bool QDBusMenuConnection::registerTrayIcon(QDBusTrayIcon *item)
+ {
+-    bool success = connection().registerService(item->instanceId());
+-    if (!success) {
+-        qWarning() << "failed to register service" << item->instanceId();
+-        return false;
+-    }
+-
+-    success = connection().registerObject(StatusNotifierItemPath, item);
++    bool success = connection().registerObject(StatusNotifierItemPath, item);
+     if (!success) {
+         unregisterTrayIcon(item);
+         qWarning() << "failed to register" << item->instanceId() << StatusNotifierItemPath;
+@@ -126,21 +127,18 @@ bool QDBusMenuConnection::registerTrayIcon(QDBusTrayIcon *item)
+ 
+ bool QDBusMenuConnection::registerTrayIconWithWatcher(QDBusTrayIcon *item)
+ {
++    Q_UNUSED(item);
+     QDBusMessage registerMethod = QDBusMessage::createMethodCall(
+                 StatusNotifierWatcherService, StatusNotifierWatcherPath, StatusNotifierWatcherService,
+                 QLatin1String("RegisterStatusNotifierItem"));
+-    registerMethod.setArguments(QVariantList() << item->instanceId());
++    registerMethod.setArguments(QVariantList() << m_connection.baseService());
+     return m_connection.callWithCallback(registerMethod, this, SIGNAL(trayIconRegistered()), SLOT(dbusError(QDBusError)));
+ }
+ 
+-bool QDBusMenuConnection::unregisterTrayIcon(QDBusTrayIcon *item)
++void QDBusMenuConnection::unregisterTrayIcon(QDBusTrayIcon *item)
+ {
+     unregisterTrayIconMenu(item);
+     connection().unregisterObject(StatusNotifierItemPath);
+-    bool success = connection().unregisterService(item->instanceId());
+-    if (!success)
+-        qWarning() << "failed to unregister service" << item->instanceId();
+-    return success;
+ }
+ #endif // QT_NO_SYSTEMTRAYICON
+ 
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
+index f484795fbb..97bdfabb85 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
++++ b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
+@@ -70,6 +70,7 @@ class QDBusMenuConnection : public QObject
+ 
+ public:
+     QDBusMenuConnection(QObject *parent = nullptr, const QString &serviceName = QString());
++    ~QDBusMenuConnection();
+     QDBusConnection connection() const { return m_connection; }
+     QDBusServiceWatcher *dbusWatcher() const { return m_dbusWatcher; }
+     bool isStatusNotifierHostRegistered() const { return m_statusNotifierHostRegistered; }
+@@ -78,7 +79,7 @@ public:
+     void unregisterTrayIconMenu(QDBusTrayIcon *item);
+     bool registerTrayIcon(QDBusTrayIcon *item);
+     bool registerTrayIconWithWatcher(QDBusTrayIcon *item);
+-    bool unregisterTrayIcon(QDBusTrayIcon *item);
++    void unregisterTrayIcon(QDBusTrayIcon *item);
+ #endif // QT_NO_SYSTEMTRAYICON
+ 
+ Q_SIGNALS:
+@@ -90,6 +91,7 @@ private Q_SLOTS:
+     void dbusError(const QDBusError &error);
+ 
+ private:
++    QString m_serviceName;
+     QDBusConnection m_connection;
+     QDBusServiceWatcher *m_dbusWatcher;
+     bool m_statusNotifierHostRegistered;
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp b/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
+index bede70975a..76bfec5e5a 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
+@@ -71,8 +71,12 @@ Q_LOGGING_CATEGORY(qLcTray, "qt.qpa.tray")
+ static QString iconTempPath()
+ {
+     QString tempPath = QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation);
+-    if (!tempPath.isEmpty())
++    if (!tempPath.isEmpty()) {
++        QString flatpakId = qEnvironmentVariable("FLATPAK_ID");
++        if (!flatpakId.isEmpty() && QFileInfo::exists(QLatin1String("/.flatpak-info")))
++            tempPath += QLatin1String("/app/") + flatpakId;
+         return tempPath;
++    }
+ 
+     tempPath = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation);
+ 
+diff --git a/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+index cb1b39db64..6e01af052c 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+@@ -755,6 +755,9 @@ QVariant QGnomeTheme::themeHint(QPlatformTheme::ThemeHint hint) const
+         return QVariant(QChar(0x2022));
+     case QPlatformTheme::UiEffects:
+         return QVariant(int(HoverEffect));
++    case QPlatformTheme::ButtonPressKeys:
++        return QVariant::fromValue(
++                QList<Qt::Key>({ Qt::Key_Space, Qt::Key_Return, Qt::Key_Enter, Qt::Key_Select }));
+     default:
+         break;
+     }
+diff --git a/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp b/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
+index 98e05195ee..1e92f43dec 100644
+--- a/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
++++ b/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
+@@ -343,8 +343,7 @@ void QEglFSCursor::paintOnScreen()
+     // screens are siblings of each other. When not enabled, the sibling list
+     // only contains m_screen itself.
+     for (QPlatformScreen *screen : m_screen->virtualSiblings()) {
+-        if (screen->geometry().contains(cr.topLeft().toPoint() + m_cursor.hotSpot)
+-            && QOpenGLContext::currentContext()->screen() == screen->screen())
++        if (screen->geometry().contains(cr.topLeft().toPoint() + m_cursor.hotSpot))
+         {
+             cr.translate(-screen->geometry().topLeft());
+             const QSize screenSize = screen->geometry().size();
+@@ -468,11 +467,12 @@ void QEglFSCursor::draw(const QRectF &r)
+ {
+     StateSaver stateSaver;
+ 
+-    QEglFSCursorData &gfx = static_cast<QEglFSContext*>(QOpenGLContext::currentContext()->handle())->cursorData;
+-    if (!gfx.program) {
+-        // one time initialization
++    // one time initialization
++    if (!QOpenGLFunctions::d_ptr)
+         initializeOpenGLFunctions();
+ 
++    QEglFSCursorData &gfx = static_cast<QEglFSContext*>(QOpenGLContext::currentContext()->handle())->cursorData;
++    if (!gfx.program) {
+         createShaderPrograms();
+ 
+         if (!gfx.atlasTexture) {
+diff --git a/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp b/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
+index 645a0ae2e9..3e0e406f1a 100644
+--- a/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
++++ b/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
+@@ -179,7 +179,7 @@ void QEglFSKmsEventReader::create(QEglFSKmsDevice *device)
+ 
+     m_device = device;
+ 
+-    qCDebug(qLcEglfsKmsDebug, "Initalizing event reader for device %p fd %d",
++    qCDebug(qLcEglfsKmsDebug, "Initializing event reader for device %p fd %d",
+             m_device, m_device->fd());
+ 
+     m_thread = new QEglFSKmsEventReaderThread(m_device->fd());
+diff --git a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
+index 141fb68a23..d4294d425a 100644
+--- a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
++++ b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
+@@ -122,11 +122,13 @@ QOffscreenIntegration::QOffscreenIntegration()
+ #endif
+     m_services.reset(new QPlatformServices);
+ 
+-    QWindowSystemInterface::handleScreenAdded(new QOffscreenScreen);
++    m_screen = new QOffscreenScreen;
++    QWindowSystemInterface::handleScreenAdded(m_screen);
+ }
+ 
+ QOffscreenIntegration::~QOffscreenIntegration()
+ {
++    QWindowSystemInterface::handleScreenRemoved(m_screen);
+ }
+ 
+ void QOffscreenIntegration::initialize()
+diff --git a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
+index 0ea90f6c2f..fe00fde07c 100644
+--- a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
++++ b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
+@@ -84,6 +84,7 @@ protected:
+ #endif
+     QScopedPointer<QPlatformInputContext> m_inputContext;
+     QScopedPointer<QPlatformServices> m_services;
++    QPlatformScreen *m_screen;
+     mutable QScopedPointer<QPlatformNativeInterface> m_nativeInterface;
+ };
+ 
+diff --git a/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp b/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
+index 6fa5a8a2b3..1f49f0aefd 100644
+--- a/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
++++ b/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
+@@ -48,6 +48,7 @@
+ #include <qpa/qplatformnativeinterface.h>
+ #include <QtPlatformHeaders/qwglnativecontext.h>
+ 
++#include <private/qsystemlibrary_p.h>
+ #include <algorithm>
+ 
+ #include <wingdi.h>
+@@ -162,19 +163,25 @@ QFunctionPointer QWindowsOpengl32DLL::resolve(const char *name)
+ 
+ bool QWindowsOpengl32DLL::init(bool softwareRendering)
+ {
+-    const QByteArray opengl32 = QByteArrayLiteral("opengl32.dll");
+-    const QByteArray swopengl = QByteArrayLiteral("opengl32sw.dll");
++    const QByteArray opengl32 = QByteArrayLiteral("opengl32");
++    const QByteArray swopengl = QByteArrayLiteral("opengl32sw");
++    bool useSystemLib = false;
+ 
+     QByteArray openglDll = qgetenv("QT_OPENGL_DLL");
+-    if (openglDll.isEmpty())
++    if (openglDll.isEmpty()) {
+         openglDll = softwareRendering ? swopengl : opengl32;
++        useSystemLib = !softwareRendering;
++    }
+ 
+     openglDll = openglDll.toLower();
+     m_nonOpengl32 = openglDll != opengl32;
+ 
+     qCDebug(lcQpaGl) << "Qt: Using WGL and OpenGL from" << openglDll;
+ 
+-    m_lib = ::LoadLibraryA(openglDll.constData());
++    if (useSystemLib)
++        m_lib = QSystemLibrary::load((wchar_t*)(QString::fromLatin1(openglDll).utf16()));
++    else
++        m_lib = LoadLibraryA(openglDll.constData());
+     if (!m_lib) {
+         qErrnoWarning(::GetLastError(), "Failed to load %s", openglDll.constData());
+         return false;
+@@ -184,7 +191,7 @@ bool QWindowsOpengl32DLL::init(bool softwareRendering)
+         // Load opengl32.dll always. GDI functions like ChoosePixelFormat do
+         // GetModuleHandle for opengl32.dll and behave differently (and call back into
+         // opengl32) when the module is present. This is fine for dummy contexts and windows.
+-        ::LoadLibraryA("opengl32.dll");
++        QSystemLibrary::load(L"opengl32");
+     }
+ 
+     wglCreateContext = reinterpret_cast<HGLRC (WINAPI *)(HDC)>(resolve("wglCreateContext"));
+diff --git a/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp b/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
+index d7d186e804..9eb4011bf2 100644
+--- a/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
++++ b/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
+@@ -49,6 +49,7 @@
+ #include <QtCore/qstandardpaths.h>
+ #include <QtCore/qlibraryinfo.h>
+ #include <QtCore/qhash.h>
++#include <private/qsystemlibrary_p.h>
+ 
+ #ifndef QT_NO_OPENGL
+ #include <private/qopengl_p.h>
+@@ -396,7 +397,7 @@ bool QWindowsOpenGLTester::testDesktopGL()
+ 
+     // Test #1: Load opengl32.dll and try to resolve an OpenGL 2 function.
+     // This will typically fail on systems that do not have a real OpenGL driver.
+-    lib = LoadLibraryA("opengl32.dll");
++    lib = QSystemLibrary::load(L"opengl32");
+     if (lib) {
+         CreateContext = reinterpret_cast<CreateContextType>(
+             reinterpret_cast<QFunctionPointer>(::GetProcAddress(lib, "wglCreateContext")));
+diff --git a/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp b/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
+index 1afa00cfc9..118af6ce73 100644
+--- a/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
++++ b/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
+@@ -41,6 +41,7 @@
+ 
+ #include <QRect>
+ #include <QList>
++#include <QMap>
+ #include <QDebug>
+ 
+ #include <qmath.h>
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp b/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
+index 9e2a37a6a1..e6e175a118 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
+@@ -488,12 +488,12 @@ void QXcbConnection::printXcbError(const char *message, xcb_generic_error_t *err
+     uint clamped_error_code = qMin<uint>(error->error_code, (sizeof(xcb_errors) / sizeof(xcb_errors[0])) - 1);
+     uint clamped_major_code = qMin<uint>(error->major_code, (sizeof(xcb_protocol_request_codes) / sizeof(xcb_protocol_request_codes[0])) - 1);
+ 
+-    qCWarning(lcQpaXcb, "%s: %d (%s), sequence: %d, resource id: %d, major code: %d (%s), minor code: %d",
+-             message,
+-             int(error->error_code), xcb_errors[clamped_error_code],
+-             int(error->sequence), int(error->resource_id),
+-             int(error->major_code), xcb_protocol_request_codes[clamped_major_code],
+-             int(error->minor_code));
++    qCDebug(lcQpaXcb, "%s: %d (%s), sequence: %d, resource id: %d, major code: %d (%s), minor code: %d",
++            message,
++            int(error->error_code), xcb_errors[clamped_error_code],
++            int(error->sequence), int(error->resource_id),
++            int(error->major_code), xcb_protocol_request_codes[clamped_major_code],
++            int(error->minor_code));
+ }
+ 
+ static Qt::MouseButtons translateMouseButtons(int s)
+@@ -702,6 +702,8 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
+             QXcbVirtualDesktop *virtualDesktop = virtualDesktopForRootWindow(propertyNotify->window);
+             if (virtualDesktop)
+                 virtualDesktop->updateWorkArea();
++        } else if (propertyNotify->atom == atom(QXcbAtom::_NET_SUPPORTED)) {
++            m_wmSupport->updateNetWMAtoms();
+         } else {
+             HANDLE_PLATFORM_WINDOW_EVENT(xcb_property_notify_event_t, window, handlePropertyNotifyEvent);
+         }
+@@ -750,7 +752,7 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
+                 case XCB_XKB_NEW_KEYBOARD_NOTIFY: {
+                     xcb_xkb_new_keyboard_notify_event_t *ev = &xkb_event->new_keyboard_notify;
+                     if (ev->changed & XCB_XKB_NKN_DETAIL_KEYCODES)
+-                        m_keyboard->updateKeymap(ev);
++                        m_keyboard->updateKeymap();
+                     break;
+                 }
+                 default:
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp b/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
+index 76869ced60..02d2eebb56 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
+@@ -274,8 +274,7 @@ QPlatformWindow *QXcbIntegration::createForeignWindow(QWindow *window, WId nativ
+ #ifndef QT_NO_OPENGL
+ QPlatformOpenGLContext *QXcbIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
+ {
+-    QXcbScreen *screen = static_cast<QXcbScreen *>(context->screen()->handle());
+-    QXcbGlIntegration *glIntegration = screen->connection()->glIntegration();
++    QXcbGlIntegration *glIntegration = defaultConnection()->glIntegration();
+     if (!glIntegration) {
+         qWarning("QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled");
+         return nullptr;
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+index efecd7e2d1..e8286381a2 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+@@ -365,17 +365,6 @@ void QXcbKeyboard::updateKeymap(xcb_mapping_notify_event_t *event)
+     updateKeymap();
+ }
+ 
+-void QXcbKeyboard::updateKeymap(xcb_xkb_new_keyboard_notify_event_t *event)
+-{
+-    if (!event)
+-        return;
+-
+-    if (event->deviceID != event->oldDeviceID)
+-        m_config = false;
+-
+-    updateKeymap();
+-}
+-
+ void QXcbKeyboard::updateKeymap()
+ {
+     KeysymModifierMap keysymMods;
+@@ -383,6 +372,8 @@ void QXcbKeyboard::updateKeymap()
+         keysymMods = keysymsToModifiers();
+     updateModifiers(keysymMods);
+ 
++    m_config = true;
++
+     if (!m_xkbContext) {
+         m_xkbContext.reset(xkb_context_new(XKB_CONTEXT_NO_DEFAULT_INCLUDES));
+         if (!m_xkbContext) {
+@@ -398,13 +389,8 @@ void QXcbKeyboard::updateKeymap()
+     if (connection()->hasXKB()) {
+         m_xkbKeymap.reset(xkb_x11_keymap_new_from_device(m_xkbContext.get(), xcb_connection(),
+                                                          core_device_id, XKB_KEYMAP_COMPILE_NO_FLAGS));
+-        if (m_xkbKeymap) {
+-            if (m_config)
+-                m_xkbState.reset(xkb_state_new(m_xkbKeymap.get()));
+-            else
+-                m_xkbState.reset(xkb_x11_state_new_from_device(m_xkbKeymap.get(), xcb_connection(), core_device_id));
+-
+-        }
++        if (m_xkbKeymap)
++            m_xkbState.reset(xkb_x11_state_new_from_device(m_xkbKeymap.get(), xcb_connection(), core_device_id));
+     } else {
+         m_xkbKeymap.reset(keymapFromCore(keysymMods));
+         if (m_xkbKeymap)
+@@ -425,8 +411,6 @@ void QXcbKeyboard::updateKeymap()
+     updateXKBMods();
+ 
+     QXkbCommon::verifyHasLatinLayout(m_xkbKeymap.get());
+-
+-    m_config = true;
+ }
+ 
+ QList<int> QXcbKeyboard::possibleKeys(const QKeyEvent *event) const
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
+index b652c85fe3..0ee08aeff2 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
++++ b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
+@@ -69,7 +69,6 @@ public:
+ 
+     Qt::KeyboardModifiers translateModifiers(int s) const;
+     void updateKeymap(xcb_mapping_notify_event_t *event);
+-    void updateKeymap(xcb_xkb_new_keyboard_notify_event_t *event);
+     void updateKeymap();
+     QList<int> possibleKeys(const QKeyEvent *event) const;
+ 
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp b/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
+index ffda7b6a57..863e961f4c 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
+@@ -564,11 +564,6 @@ void QXcbWindow::setGeometry(const QRect &rect)
+ {
+     QPlatformWindow::setGeometry(rect);
+ 
+-    if (shouldDeferTask(Task::SetGeometry)) {
+-        m_deferredGeometry = rect;
+-        return;
+-    }
+-
+     propagateSizeHints();
+ 
+     QXcbScreen *currentScreen = xcbScreen();
+@@ -693,9 +688,6 @@ void QXcbWindow::setVisible(bool visible)
+ 
+ void QXcbWindow::show()
+ {
+-    if (shouldDeferTask(Task::Map))
+-        return;
+-
+     if (window()->isTopLevel()) {
+ 
+         // update WM_NORMAL_HINTS
+@@ -706,7 +698,7 @@ void QXcbWindow::show()
+         if (isTransient(window())) {
+             const QWindow *tp = window()->transientParent();
+             if (tp && tp->handle())
+-                transientXcbParent = static_cast<const QXcbWindow *>(tp->handle())->winId();
++                transientXcbParent = tp->handle()->winId();
+             // Default to client leader if there is no transient parent, else modal dialogs can
+             // be hidden by their parents.
+             if (!transientXcbParent)
+@@ -746,10 +738,6 @@ void QXcbWindow::show()
+ 
+ void QXcbWindow::hide()
+ {
+-    if (shouldDeferTask(Task::Unmap))
+-        return;
+-
+-    m_wmStateValid = false;
+     xcb_unmap_window(xcb_connection(), m_window);
+ 
+     // send synthetic UnmapNotify event according to icccm 4.1.4
+@@ -909,9 +897,6 @@ QXcbWindow::NetWmStates QXcbWindow::netWmStates()
+ 
+ void QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
+ {
+-    if (shouldDeferTask(Task::SetWindowFlags))
+-        return;
+-
+     Qt::WindowType type = static_cast<Qt::WindowType>(int(flags & Qt::WindowType_Mask));
+ 
+     if (type == Qt::ToolTip)
+@@ -941,8 +926,6 @@ void QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
+ 
+     setTransparentForMouseEvents(flags & Qt::WindowTransparentForInput);
+     updateDoesNotAcceptFocus(flags & Qt::WindowDoesNotAcceptFocus);
+-
+-    m_isWmManagedWindow = !(flags & Qt::X11BypassWindowManagerHint);
+ }
+ 
+ void QXcbWindow::setMotifWmHints(Qt::WindowFlags flags)
+@@ -1142,9 +1125,6 @@ void QXcbWindow::setWindowState(Qt::WindowStates state)
+     if (state == m_windowState)
+         return;
+ 
+-    if (shouldDeferTask(Task::SetWindowState))
+-        return;
+-
+     // unset old state
+     if (m_windowState & Qt::WindowMinimized)
+         xcb_map_window(xcb_connection(), m_window);
+@@ -1350,6 +1330,12 @@ void QXcbWindow::setWindowIcon(const QIcon &icon)
+     }
+ 
+     if (!icon_data.isEmpty()) {
++        // Ignore icon exceeding maximum xcb request length
++        if (icon_data.size() > xcb_get_maximum_request_length(xcb_connection())) {
++            qWarning("Ignoring window icon: Size %llu exceeds maximum xcb request length %u.",
++                     icon_data.size(), xcb_get_maximum_request_length(xcb_connection()));
++            return;
++        }
+         xcb_change_property(xcb_connection(),
+                             XCB_PROP_MODE_REPLACE,
+                             m_window,
+@@ -1639,7 +1625,7 @@ void QXcbWindow::setWmWindowType(QXcbWindowFunctions::WmWindowTypes types, Qt::W
+         break;
+     }
+ 
+-    if ((flags & Qt::FramelessWindowHint) && !(type & QXcbWindowFunctions::KdeOverride)) {
++    if ((flags & Qt::FramelessWindowHint) && !(types & QXcbWindowFunctions::KdeOverride)) {
+         // override netwm type - quick and easy for KDE noborder
+         atoms.append(atom(QXcbAtom::_KDE_NET_WM_WINDOW_TYPE_OVERRIDE));
+     }
+@@ -1894,10 +1880,6 @@ void QXcbWindow::handleUnmapNotifyEvent(const xcb_unmap_notify_event_t *event)
+     if (event->window == m_window) {
+         m_mapped = false;
+         QWindowSystemInterface::handleExposeEvent(window(), QRegion());
+-        if (!m_isWmManagedWindow || parent()) {
+-            m_wmStateValid = true;
+-            handleDeferredTasks();
+-        }
+     }
+ }
+ 
+@@ -2212,98 +2194,30 @@ void QXcbWindow::handleLeaveNotifyEvent(const xcb_leave_notify_event_t *event)
+     handleLeaveNotifyEvent(event->root_x, event->root_y, event->mode, event->detail, event->time);
+ }
+ 
+-bool QXcbWindow::shouldDeferTask(Task task)
+-{
+-    if (m_wmStateValid)
+-        return false;
+-
+-    m_deferredTasks.append(task);
+-    return true;
+-}
+-
+-void QXcbWindow::handleDeferredTasks()
+-{
+-    Q_ASSERT(m_wmStateValid == true);
+-    if (m_deferredTasks.isEmpty())
+-        return;
+-
+-    bool map = false;
+-    bool unmap = false;
+-
+-    QVector<Task> tasks;
+-    for (auto taskIt = m_deferredTasks.rbegin(); taskIt != m_deferredTasks.rend(); ++taskIt) {
+-        if (!tasks.contains(*taskIt))
+-            tasks.prepend(*taskIt);
+-    }
+-
+-    for (Task task : tasks) {
+-        switch (task) {
+-        case Task::Map:
+-            map = true;
+-            unmap = false;
+-            break;
+-        case Task::Unmap:
+-            unmap = true;
+-            map = false;
+-            break;
+-        case Task::SetGeometry:
+-            setGeometry(m_deferredGeometry);
+-            break;
+-        case Task::SetWindowFlags:
+-            setWindowFlags(window()->flags());
+-            break;
+-        case Task::SetWindowState:
+-            setWindowState(window()->windowState());
+-            break;
+-        }
+-    }
+-    m_deferredTasks.clear();
+-
+-    if (map) {
+-        Q_ASSERT(unmap == false);
+-        show();
+-    }
+-    if (unmap) {
+-        Q_ASSERT(map == false);
+-        hide();
+-    }
+-}
+-
+ void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *event)
+ {
+     connection()->setTime(event->time);
+ 
+-    const bool wmStateChanged = event->atom == atom(QXcbAtom::WM_STATE);
+-    const bool netWmStateChanged = event->atom == atom(QXcbAtom::_NET_WM_STATE);
+-    if (netWmStateChanged || wmStateChanged) {
+-        if (wmStateChanged && !m_wmStateValid && m_isWmManagedWindow) {
+-            // ICCCM 4.1.4
+-            // Clients that want to re-use a client window (e.g. by mapping it again)
+-            // after withdrawing it must wait for the withdrawal to be complete before
+-            // proceeding. The preferred method for doing this is for clients to wait for
+-            // a window manager to update or remove the WM_STATE property.
+-            m_wmStateValid = true;
+-            handleDeferredTasks();
+-        }
+-        if (event->state == XCB_PROPERTY_DELETE)
++    const bool propertyDeleted = event->state == XCB_PROPERTY_DELETE;
++
++    if (event->atom == atom(QXcbAtom::_NET_WM_STATE) || event->atom == atom(QXcbAtom::WM_STATE)) {
++        if (propertyDeleted)
+             return;
+ 
+-        if (wmStateChanged) {
++        Qt::WindowStates newState = Qt::WindowNoState;
++
++        if (event->atom == atom(QXcbAtom::WM_STATE)) { // WM_STATE: Quick check for 'Minimize'.
+             auto reply = Q_XCB_REPLY(xcb_get_property, xcb_connection(),
+                                      0, m_window, atom(QXcbAtom::WM_STATE),
+                                      XCB_ATOM_ANY, 0, 1024);
+             if (reply && reply->format == 32 && reply->type == atom(QXcbAtom::WM_STATE)) {
+-                auto data = static_cast<const quint32 *>(xcb_get_property_value(reply.get()));
+-                if (reply->length != 0) {
+-                    const bool changedToWithdrawn = data[0] == XCB_ICCCM_WM_STATE_WITHDRAWN;
+-                    const bool changedToIconic = data[0] == XCB_ICCCM_WM_STATE_ICONIC;
+-                    m_minimized = changedToIconic || (changedToWithdrawn && m_minimized);
+-                }
++                const quint32 *data = (const quint32 *)xcb_get_property_value(reply.get());
++                if (reply->length != 0)
++                    m_minimized = (data[0] == XCB_ICCCM_WM_STATE_ICONIC
++                                   || (data[0] == XCB_ICCCM_WM_STATE_WITHDRAWN && m_minimized));
+             }
+         }
+ 
+-        // _NET_WM_STATE handling
+-        Qt::WindowStates newState = Qt::WindowNoState;
+         const NetWmStates states = netWmStates();
+         // _NET_WM_STATE_HIDDEN should be set by the Window Manager to indicate that a window would
+         // not be visible on the screen if its desktop/viewport were active and its coordinates were
+@@ -2325,6 +2239,7 @@ void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *ev
+             if ((m_windowState & Qt::WindowMinimized) && connection()->mouseGrabber() == this)
+                 connection()->setMouseGrabber(nullptr);
+         }
++        return;
+     } else if (event->atom == atom(QXcbAtom::_NET_FRAME_EXTENTS)) {
+         m_dirtyFrameMargins = true;
+     }
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbwindow.h b/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
+index 55af9279b1..6f5c1f5ed9 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
++++ b/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
+@@ -74,14 +74,6 @@ public:
+ 
+     Q_DECLARE_FLAGS(NetWmStates, NetWmState)
+ 
+-    enum Task {
+-        Map,
+-        Unmap,
+-        SetGeometry,
+-        SetWindowFlags,
+-        SetWindowState
+-    };
+-
+     QXcbWindow(QWindow *window);
+     ~QXcbWindow();
+ 
+@@ -151,9 +143,6 @@ public:
+ 
+     QXcbWindow *toWindow() override;
+ 
+-    bool shouldDeferTask(Task task);
+-    void handleDeferredTasks();
+-
+     void handleMouseEvent(xcb_timestamp_t time, const QPoint &local, const QPoint &global,
+                           Qt::KeyboardModifiers modifiers, QEvent::Type type, Qt::MouseEventSource source);
+ 
+@@ -292,11 +281,6 @@ protected:
+     int m_swapInterval = -1;
+ 
+     qreal m_sizeHintsScaleFactor = 1.0;
+-
+-    bool m_wmStateValid = true;
+-    QVector<Task> m_deferredTasks;
+-    bool m_isWmManagedWindow = true;
+-    QRect m_deferredGeometry;
+ };
+ 
+ class QXcbForeignWindow : public QXcbWindow
+diff --git a/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp b/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
+index d9d117faeb..640b49daa0 100644
+--- a/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
++++ b/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
+@@ -85,6 +85,7 @@ QGtk3MenuItem::QGtk3MenuItem()
+       m_checkable(false),
+       m_checked(false),
+       m_enabled(true),
++      m_exclusive(false),
+       m_underline(false),
+       m_invalid(true),
+       m_menu(nullptr),
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
+index 0048bbc1e6..396e7f6d1c 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
+@@ -102,15 +102,12 @@ const QDBusArgument &operator >>(const QDBusArgument &arg, QXdgDesktopPortalFile
+ class QXdgDesktopPortalFileDialogPrivate
+ {
+ public:
+-    QXdgDesktopPortalFileDialogPrivate(QPlatformFileDialogHelper *nativeFileDialog)
++    QXdgDesktopPortalFileDialogPrivate(QPlatformFileDialogHelper *nativeFileDialog, uint fileChooserPortalVersion)
+         : nativeFileDialog(nativeFileDialog)
++        , fileChooserPortalVersion(fileChooserPortalVersion)
+     { }
+ 
+-    WId winId = 0;
+-    bool directoryMode = false;
+-    bool modal = false;
+-    bool multipleFiles = false;
+-    bool saveFile = false;
++    QEventLoop loop;
+     QString acceptLabel;
+     QString directory;
+     QString title;
+@@ -121,19 +118,27 @@ public:
+     QString selectedMimeTypeFilter;
+     QString selectedNameFilter;
+     QStringList selectedFiles;
+-    QPlatformFileDialogHelper *nativeFileDialog = nullptr;
++    std::unique_ptr<QPlatformFileDialogHelper> nativeFileDialog;
++    uint fileChooserPortalVersion = 0;
++    bool failedToOpen = false;
++    bool directoryMode = false;
++    bool multipleFiles = false;
++    bool saveFile = false;
+ };
+ 
+-QXdgDesktopPortalFileDialog::QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog)
++QXdgDesktopPortalFileDialog::QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog, uint fileChooserPortalVersion)
+     : QPlatformFileDialogHelper()
+-    , d_ptr(new QXdgDesktopPortalFileDialogPrivate(nativeFileDialog))
++    , d_ptr(new QXdgDesktopPortalFileDialogPrivate(nativeFileDialog, fileChooserPortalVersion))
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+     if (d->nativeFileDialog) {
+-        connect(d->nativeFileDialog, SIGNAL(accept()), this, SIGNAL(accept()));
+-        connect(d->nativeFileDialog, SIGNAL(reject()), this, SIGNAL(reject()));
++        connect(d->nativeFileDialog.get(), SIGNAL(accept()), this, SIGNAL(accept()));
++        connect(d->nativeFileDialog.get(), SIGNAL(reject()), this, SIGNAL(reject()));
+     }
++
++    d->loop.connect(this, SIGNAL(accept()), SLOT(quit()));
++    d->loop.connect(this, SIGNAL(reject()), SLOT(quit()));
+ }
+ 
+ QXdgDesktopPortalFileDialog::~QXdgDesktopPortalFileDialog()
+@@ -177,7 +182,7 @@ void QXdgDesktopPortalFileDialog::initializeDialog()
+     setDirectory(options()->initialDirectory());
+ }
+ 
+-void QXdgDesktopPortalFileDialog::openPortal()
++void QXdgDesktopPortalFileDialog::openPortal(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent)
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+@@ -185,13 +190,13 @@ void QXdgDesktopPortalFileDialog::openPortal()
+                                                           QLatin1String("/org/freedesktop/portal/desktop"),
+                                                           QLatin1String("org.freedesktop.portal.FileChooser"),
+                                                           d->saveFile ? QLatin1String("SaveFile") : QLatin1String("OpenFile"));
+-    QString parentWindowId = QLatin1String("x11:") + QString::number(d->winId, 16);
++    QString parentWindowId = QLatin1String("x11:") + QString::number(parent ? parent->winId() : 0, 16);
+ 
+     QVariantMap options;
+     if (!d->acceptLabel.isEmpty())
+         options.insert(QLatin1String("accept_label"), d->acceptLabel);
+ 
+-    options.insert(QLatin1String("modal"), d->modal);
++    options.insert(QLatin1String("modal"), windowModality != Qt::NonModal);
+     options.insert(QLatin1String("multiple"), d->multipleFiles);
+     options.insert(QLatin1String("directory"), d->directoryMode);
+ 
+@@ -290,10 +295,18 @@ void QXdgDesktopPortalFileDialog::openPortal()
+ 
+     QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
+     QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingCall);
+-    connect(watcher, &QDBusPendingCallWatcher::finished, this, [this] (QDBusPendingCallWatcher *watcher) {
++    connect(watcher, &QDBusPendingCallWatcher::finished, this, [=] (QDBusPendingCallWatcher *watcher) {
+         QDBusPendingReply<QDBusObjectPath> reply = *watcher;
+-        if (reply.isError()) {
+-            Q_EMIT reject();
++        // Any error means the dialog is not shown and we need to fallback
++        d->failedToOpen = reply.isError();
++        if (d->failedToOpen) {
++            if (d->nativeFileDialog) {
++                d->nativeFileDialog->show(windowFlags, windowModality, parent);
++                if (d->loop.isRunning())
++                    d->nativeFileDialog->exec();
++            } else {
++                Q_EMIT reject();
++            }
+         } else {
+             QDBusConnection::sessionBus().connect(nullptr,
+                                                   reply.value().path(),
+@@ -302,6 +315,7 @@ void QXdgDesktopPortalFileDialog::openPortal()
+                                                   this,
+                                                   SLOT(gotResponse(uint,QVariantMap)));
+         }
++        watcher->deleteLater();
+     });
+ }
+ 
+@@ -326,7 +340,7 @@ QUrl QXdgDesktopPortalFileDialog::directory() const
+ {
+     Q_D(const QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog())
+         return d->nativeFileDialog->directory();
+ 
+     return d->directory;
+@@ -348,7 +362,7 @@ QList<QUrl> QXdgDesktopPortalFileDialog::selectedFiles() const
+ {
+     Q_D(const QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog())
+         return d->nativeFileDialog->selectedFiles();
+ 
+     QList<QUrl> files;
+@@ -403,16 +417,13 @@ void QXdgDesktopPortalFileDialog::exec()
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly)) {
++    if (d->nativeFileDialog && useNativeFileDialog()) {
+         d->nativeFileDialog->exec();
+         return;
+     }
+ 
+     // HACK we have to avoid returning until we emit that the dialog was accepted or rejected
+-    QEventLoop loop;
+-    loop.connect(this, SIGNAL(accept()), SLOT(quit()));
+-    loop.connect(this, SIGNAL(reject()), SLOT(quit()));
+-    loop.exec();
++    d->loop.exec();
+ }
+ 
+ void QXdgDesktopPortalFileDialog::hide()
+@@ -429,13 +440,10 @@ bool QXdgDesktopPortalFileDialog::show(Qt::WindowFlags windowFlags, Qt::WindowMo
+ 
+     initializeDialog();
+ 
+-    d->modal = windowModality != Qt::NonModal;
+-    d->winId = parent ? parent->winId() : 0;
+-
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog(OpenFallback))
+         return d->nativeFileDialog->show(windowFlags, windowModality, parent);
+ 
+-    openPortal();
++    openPortal(windowFlags, windowModality, parent);
+ 
+     return true;
+ }
+@@ -465,4 +473,21 @@ void QXdgDesktopPortalFileDialog::gotResponse(uint response, const QVariantMap &
+     }
+ }
+ 
++bool QXdgDesktopPortalFileDialog::useNativeFileDialog(QXdgDesktopPortalFileDialog::FallbackType fallbackType) const
++{
++    Q_D(const QXdgDesktopPortalFileDialog);
++
++    if (d->failedToOpen && fallbackType != OpenFallback)
++        return true;
++
++    if (d->fileChooserPortalVersion < 3) {
++        if (options()->fileMode() == QFileDialogOptions::Directory)
++            return true;
++        else if (options()->fileMode() == QFileDialogOptions::DirectoryOnly)
++            return true;
++    }
++
++    return false;
++}
++
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
+index 4f4de96ecf..65e22a5cf2 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
+@@ -51,6 +51,11 @@ class QXdgDesktopPortalFileDialog : public QPlatformFileDialogHelper
+     Q_OBJECT
+     Q_DECLARE_PRIVATE(QXdgDesktopPortalFileDialog)
+ public:
++    enum FallbackType {
++        GenericFallback,
++        OpenFallback
++    };
++
+     enum ConditionType : uint {
+         GlobalPattern = 0,
+         MimeType = 1
+@@ -69,7 +74,7 @@ public:
+     };
+     typedef QVector<Filter> FilterList;
+ 
+-    QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog = nullptr);
++    QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog = nullptr, uint fileChooserPortalVersion = 0);
+     ~QXdgDesktopPortalFileDialog();
+ 
+     bool defaultNameFilterDisables() const override;
+@@ -92,7 +97,8 @@ private Q_SLOTS:
+ 
+ private:
+     void initializeDialog();
+-    void openPortal();
++    void openPortal(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent);
++    bool useNativeFileDialog(FallbackType fallbackType = GenericFallback) const;
+ 
+     QScopedPointer<QXdgDesktopPortalFileDialogPrivate> d_ptr;
+ };
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
+index fb324afbd8..b809503122 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
+@@ -111,6 +111,7 @@ QXdgDesktopPortalTheme::QXdgDesktopPortalTheme()
+         if (reply.isValid()) {
+             d->fileChooserPortalVersion = reply.value().toUInt();
+         }
++        watcher->deleteLater();
+     });
+ }
+ 
+@@ -152,11 +153,12 @@ QPlatformDialogHelper* QXdgDesktopPortalTheme::createPlatformDialogHelper(Dialog
+ {
+     Q_D(const QXdgDesktopPortalTheme);
+ 
+-    if (type == FileDialog) {
++    if (type == FileDialog && d->fileChooserPortalVersion) {
+         // Older versions of FileChooser portal don't support opening directories, therefore we fallback
+         // to native file dialog opened inside the sandbox to open a directory.
+-        if (d->fileChooserPortalVersion < 3 && d->baseTheme->usePlatformNativeDialog(type))
+-            return new QXdgDesktopPortalFileDialog(static_cast<QPlatformFileDialogHelper*>(d->baseTheme->createPlatformDialogHelper(type)));
++        if (d->baseTheme->usePlatformNativeDialog(type))
++            return new QXdgDesktopPortalFileDialog(static_cast<QPlatformFileDialogHelper*>(d->baseTheme->createPlatformDialogHelper(type)),
++                                                   d->fileChooserPortalVersion);
+ 
+         return new QXdgDesktopPortalFileDialog;
+     }
+diff --git a/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp b/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
+index 43d5e119ad..1f9cbc4565 100644
+--- a/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
++++ b/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
+@@ -89,8 +89,10 @@ void QCupsPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &v
+         break;
+     case PPK_Duplex: {
+         QPrint::DuplexMode mode = QPrint::DuplexMode(value.toInt());
+-        if (mode != d->duplex && d->m_printDevice.supportedDuplexModes().contains(mode))
++        if (d->m_printDevice.supportedDuplexModes().contains(mode)) {
+             d->duplex = mode;
++            d->duplexRequestedExplicitly = true;
++        }
+         break;
+     }
+     case PPK_PrinterName:
+@@ -277,9 +279,12 @@ void QCupsPrintEnginePrivate::changePrinter(const QString &newPrinter)
+     m_printDevice.swap(printDevice);
+     printerName = m_printDevice.id();
+ 
+-    // Check if new printer supports current settings, otherwise us defaults
+-    if (duplex != QPrint::DuplexAuto && !m_printDevice.supportedDuplexModes().contains(duplex))
++    // in case a duplex value was explicitly set, check if new printer supports current value,
++    // otherwise use device default
++    if (!duplexRequestedExplicitly || !m_printDevice.supportedDuplexModes().contains(duplex)) {
+         duplex = m_printDevice.defaultDuplexMode();
++        duplexRequestedExplicitly = false;
++    }
+     QPrint::ColorMode colorMode = grayscale ? QPrint::GrayScale : QPrint::Color;
+     if (!m_printDevice.supportedColorModes().contains(colorMode))
+         grayscale = m_printDevice.defaultColorMode() == QPrint::GrayScale;
+diff --git a/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h b/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
+index c021b0c643..8f81fe478d 100644
+--- a/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
++++ b/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
+@@ -100,6 +100,7 @@ private:
+     QStringList cupsOptions;
+     QString cupsTempFile;
+     QPrint::DuplexMode duplex;
++    bool duplexRequestedExplicitly = false;
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp b/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
+index 67e7154fa6..40876152e5 100644
+--- a/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
++++ b/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
+@@ -817,7 +817,7 @@ bool QIBaseResultPrivate::writeArray(int column, const QList<QVariant> &list)
+     ba.resize(int(bufLen));
+ 
+     if (list.size() > arraySize) {
+-        error = QLatin1String("Array size missmatch: size of %1 is %2, size of provided list is %3");
++        error = QLatin1String("Array size mismatch: size of %1 is %2, size of provided list is %3");
+         error = error.arg(QLatin1String(sqlname)).arg(arraySize).arg(list.size());
+         q->setLastError(QSqlError(error, QLatin1String(""), QSqlError::StatementError));
+         return false;
+diff --git a/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp b/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
+index 7ca055eea2..6bc9d46755 100644
+--- a/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
++++ b/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
+@@ -223,7 +223,7 @@ public:
+     struct QMyField
+     {
+         char *outField = nullptr;
+-        MYSQL_FIELD *myField = nullptr;
++        const MYSQL_FIELD *myField = nullptr;
+         QMetaType::Type type = QMetaType::UnknownType;
+         my_bool nullIndicator = false;
+         ulong bufLength = 0ul;
+@@ -361,7 +361,7 @@ static bool qIsInteger(int t)
+ void QMYSQLResultPrivate::bindBlobs()
+ {
+     int i;
+-    MYSQL_FIELD *fieldInfo;
++    const MYSQL_FIELD *fieldInfo;
+     MYSQL_BIND *bind;
+ 
+     for(i = 0; i < fields.count(); ++i) {
+@@ -379,7 +379,6 @@ void QMYSQLResultPrivate::bindBlobs()
+ bool QMYSQLResultPrivate::bindInValues()
+ {
+     MYSQL_BIND *bind;
+-    char *field;
+     int i = 0;
+ 
+     if (!meta)
+@@ -392,35 +391,34 @@ bool QMYSQLResultPrivate::bindInValues()
+     inBinds = new MYSQL_BIND[fields.size()];
+     memset(inBinds, 0, fields.size() * sizeof(MYSQL_BIND));
+ 
+-    MYSQL_FIELD *fieldInfo;
++    const MYSQL_FIELD *fieldInfo;
+ 
+     while((fieldInfo = mysql_fetch_field(meta))) {
++        bind = &inBinds[i];
++
+         QMyField &f = fields[i];
+         f.myField = fieldInfo;
+-
++        bind->buffer_length = f.bufLength = fieldInfo->length + 1;
++        bind->buffer_type = fieldInfo->type;
+         f.type = qDecodeMYSQLType(fieldInfo->type, fieldInfo->flags);
+         if (qIsBlob(fieldInfo->type)) {
+             // the size of a blob-field is available as soon as we call
+             // mysql_stmt_store_result()
+             // after mysql_stmt_exec() in QMYSQLResult::exec()
+-            fieldInfo->length = 0;
++            bind->buffer_length = f.bufLength = 0;
+             hasBlobs = true;
+         } else if (qIsInteger(f.type)) {
+-            fieldInfo->length = 8;
++            bind->buffer_length = f.bufLength = 8;
+         } else {
+-            fieldInfo->type = MYSQL_TYPE_STRING;
++            bind->buffer_type = MYSQL_TYPE_STRING;
+         }
+-        bind = &inBinds[i];
+-        field = new char[fieldInfo->length + 1];
+-        memset(field, 0, fieldInfo->length + 1);
+ 
+-        bind->buffer_type = fieldInfo->type;
+-        bind->buffer = field;
+-        bind->buffer_length = f.bufLength = fieldInfo->length + 1;
+         bind->is_null = &f.nullIndicator;
+         bind->length = &f.bufLength;
+         bind->is_unsigned = fieldInfo->flags & UNSIGNED_FLAG ? 1 : 0;
+-        f.outField=field;
++
++        char *field = new char[bind->buffer_length + 1]{};
++        bind->buffer = f.outField = field;
+ 
+         ++i;
+     }
+@@ -1369,20 +1367,20 @@ bool QMYSQLDriver::open(const QString& db,
+     }
+ 
+ #if MYSQL_VERSION_ID >= 50007
+-    if (mysql_get_client_version() >= 50503 && mysql_get_server_version(d->mysql) >= 50503) {
+-        // force the communication to be utf8mb4 (only utf8mb4 supports 4-byte characters)
+-        mysql_set_character_set(d->mysql, "utf8mb4");
++    // force the communication to be utf8mb4 (only utf8mb4 supports 4-byte characters)
++    if (mysql_set_character_set(d->mysql, "utf8mb4")) {
++        // this failed, try forcing it to utf (BMP only)
++        if (mysql_set_character_set(d->mysql, "utf8"))
++            qWarning() << "MySQL: Unable to set the client character set to utf8.";
+ #if QT_CONFIG(textcodec)
+-        d->tc = QTextCodec::codecForName("UTF-8");
++        else
++            d->tc = codec(d->mysql);
+ #endif
+-    } else
+-    {
+-        // force the communication to be utf8
+-        mysql_set_character_set(d->mysql, "utf8");
++    }
+ #if QT_CONFIG(textcodec)
+-        d->tc = codec(d->mysql);
++    else
++        d->tc = QTextCodec::codecForName("UTF-8");
+ #endif
+-    }
+ #endif  // MYSQL_VERSION_ID >= 50007
+ 
+     d->preparedQuerysEnabled = checkPreparedQueries(d->mysql);
+diff --git a/qtbase/src/printsupport/dialogs/images/print-24.png b/qtbase/src/printsupport/dialogs/images/printer-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/print-24.png
+rename to src/printsupport/dialogs/images/printer-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/print-32.png b/qtbase/src/printsupport/dialogs/images/printer-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/print-32.png
+rename to src/printsupport/dialogs/images/printer-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-sided-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-facing-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-sided-24.png
+rename to src/printsupport/dialogs/images/view-pages-facing-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-sided-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-facing-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-sided-32.png
+rename to src/printsupport/dialogs/images/view-pages-facing-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-multi-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-overview-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-multi-24.png
+rename to src/printsupport/dialogs/images/view-pages-overview-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-multi-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-overview-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-multi-32.png
+rename to src/printsupport/dialogs/images/view-pages-overview-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-one-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-single-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-one-24.png
+rename to src/printsupport/dialogs/images/view-pages-single-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-one-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-single-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-one-32.png
+rename to src/printsupport/dialogs/images/view-pages-single-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-page-24.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-page-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-page-24.png
+rename to src/printsupport/dialogs/images/zoom-fit-page-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-page-32.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-page-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-page-32.png
+rename to src/printsupport/dialogs/images/zoom-fit-page-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-width-24.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-width-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-width-24.png
+rename to src/printsupport/dialogs/images/zoom-fit-width-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-width-32.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-width-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-width-32.png
+rename to src/printsupport/dialogs/images/zoom-fit-width-32.png
+diff --git a/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp b/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
+index 78e5b8d1ef..2a28516719 100644
+--- a/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
++++ b/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
+@@ -532,6 +532,7 @@ void QPageSetupWidget::updateWidget()
+ void QPageSetupWidget::setupPrinter() const
+ {
+     m_printer->setPageLayout(m_pageLayout);
++    m_printer->setPageOrientation(m_pageLayout.orientation());
+ #if QT_CONFIG(cups)
+     QCUPSSupport::PagesPerSheet pagesPerSheet = qvariant_cast<QCUPSSupport::PagesPerSheet>(m_ui.pagesPerSheetCombo->currentData()
+ );
+diff --git a/qtbase/src/printsupport/dialogs/qprintdialog.qrc b/qtbase/src/printsupport/dialogs/qprintdialog.qrc
+index 5a579baa55..10b8e1d341 100644
+--- a/qtbase/src/printsupport/dialogs/qprintdialog.qrc
++++ b/qtbase/src/printsupport/dialogs/qprintdialog.qrc
+@@ -1,9 +1,9 @@
+ <!DOCTYPE RCC><RCC version="1.0">
+ <qresource prefix="/qt-project.org/dialogs/qprintpreviewdialog">
+-<file>images/fit-page-24.png</file>
+-<file>images/fit-page-32.png</file>
+-<file>images/fit-width-24.png</file>
+-<file>images/fit-width-32.png</file>
++<file>images/zoom-fit-page-24.png</file>
++<file>images/zoom-fit-page-32.png</file>
++<file>images/zoom-fit-width-24.png</file>
++<file>images/zoom-fit-width-32.png</file>
+ <file>images/go-first-24.png</file>
+ <file>images/go-first-32.png</file>
+ <file>images/go-last-24.png</file>
+@@ -18,14 +18,14 @@
+ <file>images/layout-portrait-32.png</file>
+ <file>images/page-setup-24.png</file>
+ <file>images/page-setup-32.png</file>
+-<file>images/print-24.png</file>
+-<file>images/print-32.png</file>
+-<file>images/view-page-multi-24.png</file>
+-<file>images/view-page-multi-32.png</file>
+-<file>images/view-page-one-24.png</file>
+-<file>images/view-page-one-32.png</file>
+-<file>images/view-page-sided-24.png</file>
+-<file>images/view-page-sided-32.png</file>
++<file>images/printer-24.png</file>
++<file>images/printer-32.png</file>
++<file>images/view-pages-overview-24.png</file>
++<file>images/view-pages-overview-32.png</file>
++<file>images/view-pages-single-24.png</file>
++<file>images/view-pages-single-32.png</file>
++<file>images/view-pages-facing-24.png</file>
++<file>images/view-pages-facing-32.png</file>
+ <file>images/zoom-in-24.png</file>
+ <file>images/zoom-in-32.png</file>
+ <file>images/zoom-out-24.png</file>
+diff --git a/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp b/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
+index c5b845f4ec..5a5ba1d0a8 100644
+--- a/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
++++ b/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
+@@ -702,13 +702,14 @@ void QPrintDialogPrivate::selectPrinter(const QPrinter::OutputFormat outputForma
+         else
+             options.grayscale->setChecked(true);
+ 
+-        // keep duplex value explicitly set by user, if any, and selected printer supports it;
+-        // use device default otherwise
++        // duplex priorities to be as follows:
++        // 1) a user-selected duplex value in the dialog has highest prority
++        // 2) duplex value set in the QPrinter
+         QPrint::DuplexMode duplex;
+         if (explicitDuplexMode != QPrint::DuplexAuto && supportedDuplexMode.contains(explicitDuplexMode))
+             duplex = explicitDuplexMode;
+         else
+-            duplex = top->d->m_currentPrintDevice.defaultDuplexMode();
++            duplex = static_cast<QPrint::DuplexMode>(p->duplex());
+         switch (duplex) {
+         case QPrint::DuplexNone:
+             options.noDuplex->setChecked(true); break;
+@@ -1242,10 +1243,10 @@ void QUnixPrintWidgetPrivate::_q_printerChanged(int index)
+             QString filename = widget.filename->text();
+             widget.filename->setText(filename);
+             widget.lOutput->setEnabled(true);
+-            if (optionsPane)
+-                optionsPane->selectPrinter(QPrinter::PdfFormat);
+             printer->setOutputFormat(QPrinter::PdfFormat);
+             m_currentPrintDevice = QPrintDevice();
++            if (optionsPane)
++                optionsPane->selectPrinter(QPrinter::PdfFormat);
+             return;
+         }
+     }
+diff --git a/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp b/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
+index 39575d5f57..23b7e89538 100644
+--- a/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
++++ b/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
+@@ -352,7 +352,7 @@ void QPrintPreviewDialogPrivate::init(QPrinter *_printer)
+ static inline void qt_setupActionIcon(QAction *action, QLatin1String name)
+ {
+     QLatin1String imagePrefix(":/qt-project.org/dialogs/qprintpreviewdialog/images/");
+-    QIcon icon;
++    QIcon icon = QIcon::fromTheme(name);
+     icon.addFile(imagePrefix + name + QLatin1String("-24.png"), QSize(24, 24));
+     icon.addFile(imagePrefix + name + QLatin1String("-32.png"), QSize(32, 32));
+     action->setIcon(icon);
+@@ -383,8 +383,8 @@ void QPrintPreviewDialogPrivate::setupActions()
+     fitPageAction->setObjectName(QLatin1String("fitPageAction"));
+     fitWidthAction->setCheckable(true);
+     fitPageAction->setCheckable(true);
+-    qt_setupActionIcon(fitWidthAction, QLatin1String("fit-width"));
+-    qt_setupActionIcon(fitPageAction, QLatin1String("fit-page"));
++    qt_setupActionIcon(fitWidthAction, QLatin1String("zoom-fit-width"));
++    qt_setupActionIcon(fitPageAction, QLatin1String("zoom-fit-page"));
+     QObject::connect(fitGroup, SIGNAL(triggered(QAction*)), q, SLOT(_q_fit(QAction*)));
+ 
+     // Zoom
+@@ -410,9 +410,9 @@ void QPrintPreviewDialogPrivate::setupActions()
+     singleModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show single page"));
+     facingModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show facing pages"));
+     overviewModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show overview of all pages"));
+-    qt_setupActionIcon(singleModeAction, QLatin1String("view-page-one"));
+-    qt_setupActionIcon(facingModeAction, QLatin1String("view-page-sided"));
+-    qt_setupActionIcon(overviewModeAction, QLatin1String("view-page-multi"));
++    qt_setupActionIcon(singleModeAction, QLatin1String("view-pages-single"));
++    qt_setupActionIcon(facingModeAction, QLatin1String("view-pages-facing"));
++    qt_setupActionIcon(overviewModeAction, QLatin1String("view-pages-overview"));
+     singleModeAction->setObjectName(QLatin1String("singleModeAction"));
+     facingModeAction->setObjectName(QLatin1String("facingModeAction"));
+     overviewModeAction->setObjectName(QLatin1String("overviewModeAction"));
+@@ -426,7 +426,7 @@ void QPrintPreviewDialogPrivate::setupActions()
+     printerGroup = new QActionGroup(q);
+     printAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Print"));
+     pageSetupAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Page setup"));
+-    qt_setupActionIcon(printAction, QLatin1String("print"));
++    qt_setupActionIcon(printAction, QLatin1String("printer"));
+     qt_setupActionIcon(pageSetupAction, QLatin1String("page-setup"));
+     QObject::connect(printAction, SIGNAL(triggered(bool)), q, SLOT(_q_print()));
+     QObject::connect(pageSetupAction, SIGNAL(triggered(bool)), q, SLOT(_q_pageSetup()));
+diff --git a/qtbase/src/sql/kernel/qsqlquery.cpp b/qtbase/src/sql/kernel/qsqlquery.cpp
+index 32c6166c79..60afef10c3 100644
+--- a/qtbase/src/sql/kernel/qsqlquery.cpp
++++ b/qtbase/src/sql/kernel/qsqlquery.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2022 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtSql module of the Qt Toolkit.
+@@ -377,6 +377,10 @@ bool QSqlQuery::exec(const QString& query)
+     QElapsedTimer t;
+     t.start();
+ #endif
++    if (!driver()) {
++        qWarning("QSqlQuery::exec: called before driver has been set up");
++        return false;
++    }
+     if (d->ref.loadRelaxed() != 1) {
+         bool fo = isForwardOnly();
+         *this = QSqlQuery(driver()->createResult());
+diff --git a/qtbase/src/testlib/qabstractitemmodeltester.cpp b/qtbase/src/testlib/qabstractitemmodeltester.cpp
+index 8efb9c53d4..ce062f66d7 100644
+--- a/qtbase/src/testlib/qabstractitemmodeltester.cpp
++++ b/qtbase/src/testlib/qabstractitemmodeltester.cpp
+@@ -454,7 +454,7 @@ void QAbstractItemModelTesterPrivate::parent()
+ 
+     // Common error test #2, make sure that a second level index has a parent
+     // that is the first level index.
+-    if (model->rowCount(topIndex) > 0) {
++    if (model->rowCount(topIndex) > 0 && model->columnCount(topIndex) > 0) {
+         QModelIndex childIndex = model->index(0, 0, topIndex);
+         MODELTESTER_VERIFY(childIndex.isValid());
+         MODELTESTER_COMPARE(model->parent(childIndex), topIndex);
+diff --git a/qtbase/src/testlib/qasciikey.cpp b/qtbase/src/testlib/qasciikey.cpp
+index 9a308da2bc..93498b256f 100644
+--- a/qtbase/src/testlib/qasciikey.cpp
++++ b/qtbase/src/testlib/qasciikey.cpp
+@@ -498,6 +498,11 @@ char QTest::keyToAscii(Qt::Key key)
+     case Qt::Key_LaunchE : return 0; // = 0x10b0,
+     case Qt::Key_LaunchF : return 0; // = 0x10b1,
+ 
++    // Keypad navigation keys
++    case Qt::Key_Select : return 0; // = 0x01010000
++    case Qt::Key_Yes : return 0; // = 0x01010001
++    case Qt::Key_No : return 0; // = 0x01010002
++
+     default: QTEST_ASSERT(false); return 0;
+     }
+ }
+diff --git a/qtbase/src/testlib/qtestresult.cpp b/qtbase/src/testlib/qtestresult.cpp
+index 88028aac6e..2e89930776 100644
+--- a/qtbase/src/testlib/qtestresult.cpp
++++ b/qtbase/src/testlib/qtestresult.cpp
+@@ -251,7 +251,8 @@ bool QTestResult::verify(bool statement, const char *statementStr,
+ {
+     QTEST_ASSERT(statementStr);
+ 
+-    char msg[1024] = {'\0'};
++    char msg[1024];
++    msg[0] = '\0';
+ 
+     if (QTestLog::verboseLevel() >= 2) {
+         qsnprintf(msg, 1024, "QVERIFY(%s)", statementStr);
+@@ -309,7 +310,8 @@ static bool compareHelper(bool success, const char *failureMsg,
+                           bool hasValues = true)
+ {
+     const size_t maxMsgLen = 1024;
+-    char msg[maxMsgLen] = {'\0'};
++    char msg[maxMsgLen];
++    msg[0] = '\0';
+ 
+     QTEST_ASSERT(expected);
+     QTEST_ASSERT(actual);
+diff --git a/qtbase/src/widgets/dialogs/qcolordialog.cpp b/qtbase/src/widgets/dialogs/qcolordialog.cpp
+index 4247731275..cb325be85c 100644
+--- a/qtbase/src/widgets/dialogs/qcolordialog.cpp
++++ b/qtbase/src/widgets/dialogs/qcolordialog.cpp
+@@ -78,7 +78,10 @@
+ #include "qwindow.h"
+ 
+ #include "private/qdialog_p.h"
++#include "private/qguiapplication_p.h"
+ 
++#include <qpa/qplatformservices.h>
++#include <qpa/qplatformintegration.h>
+ #include <algorithm>
+ 
+ QT_BEGIN_NAMESPACE
+@@ -1611,6 +1614,20 @@ void QColorDialogPrivate::_q_newStandard(int r, int c)
+ void QColorDialogPrivate::_q_pickScreenColor()
+ {
+     Q_Q(QColorDialog);
++
++    auto *platformServices = QGuiApplicationPrivate::platformIntegration()->services();
++    if (platformServices->hasCapability(QPlatformServices::Capability::ColorPicking)) {
++        if (auto *colorPicker = platformServices->colorPicker(q->windowHandle())) {
++            q->connect(colorPicker, &QPlatformServiceColorPicker::colorPicked, q,
++                       [q, colorPicker](const QColor &color) {
++                           colorPicker->deleteLater();
++                           q->setCurrentColor(color);
++                       });
++            colorPicker->pickColor();
++            return;
++        }
++    }
++
+     if (!colorPickingEventFilter)
+         colorPickingEventFilter = new QColorPickingEventFilter(this, q);
+     q->installEventFilter(colorPickingEventFilter);
+diff --git a/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp b/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
+index e120817edc..8ea36b5427 100644
+--- a/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
++++ b/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
+@@ -400,12 +400,7 @@ bool QAbstractItemDelegate::helpEvent(QHelpEvent *event,
+         const QString tooltip = index.isValid() ?
+               d->textForRole(Qt::ToolTipRole, index.data(Qt::ToolTipRole), option.locale, precision) :
+               QString();
+-        QRect rect;
+-        if (index.isValid()) {
+-            const QRect r = view->visualRect(index);
+-            rect = QRect(view->mapToGlobal(r.topLeft()), r.size());
+-        }
+-        QToolTip::showText(he->globalPos(), tooltip, view, rect);
++        QToolTip::showText(he->globalPos(), tooltip, view->viewport(), option.rect);
+         event->setAccepted(!tooltip.isEmpty());
+         break;
+         }
+diff --git a/qtbase/src/widgets/itemviews/qlistview.cpp b/qtbase/src/widgets/itemviews/qlistview.cpp
+index 2b34476642..eebfaa030e 100644
+--- a/qtbase/src/widgets/itemviews/qlistview.cpp
++++ b/qtbase/src/widgets/itemviews/qlistview.cpp
+@@ -3386,6 +3386,7 @@ void QIconModeViewBase::updateContentsSize()
+ */
+ void QListView::currentChanged(const QModelIndex &current, const QModelIndex &previous)
+ {
++    QAbstractItemView::currentChanged(current, previous);
+ #ifndef QT_NO_ACCESSIBILITY
+     if (QAccessible::isActive()) {
+         if (current.isValid()) {
+@@ -3396,7 +3397,6 @@ void QListView::currentChanged(const QModelIndex &current, const QModelIndex &pr
+         }
+     }
+ #endif
+-    QAbstractItemView::currentChanged(current, previous);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/widgets/itemviews/qtableview.cpp b/qtbase/src/widgets/itemviews/qtableview.cpp
+index 934ac581b2..f79bb24249 100644
+--- a/qtbase/src/widgets/itemviews/qtableview.cpp
++++ b/qtbase/src/widgets/itemviews/qtableview.cpp
+@@ -1013,6 +1013,7 @@ void QTableViewPrivate::drawCell(QPainter *painter, const QStyleOptionViewItem &
+ int QTableViewPrivate::widthHintForIndex(const QModelIndex &index, int hint, const QStyleOptionViewItem &option) const
+ {
+     Q_Q(const QTableView);
++    const int oldHint = hint;
+     QWidget *editor = editorForIndex(index).widget.data();
+     if (editor && persistent.contains(editor)) {
+         hint = qMax(hint, editor->sizeHint().width());
+@@ -1021,6 +1022,17 @@ int QTableViewPrivate::widthHintForIndex(const QModelIndex &index, int hint, con
+         hint = qBound(min, hint, max);
+     }
+     hint = qMax(hint, q->itemDelegate(index)->sizeHint(option, index).width());
++
++    if (hasSpans()) {
++        auto span = spans.spanAt(index.column(), index.row());
++        if (span && span->m_left == index.column() && span->m_top == index.row()) {
++            // spans are screwed up when sections are moved
++            const auto left = logicalColumn(span->m_left);
++            for (int i = 1; i <= span->width(); ++i)
++               hint -= q->columnWidth(visualColumn(left + i));
++        }
++        hint = std::max(hint, oldHint);
++    }
+     return hint;
+ }
+ 
+@@ -1053,6 +1065,11 @@ int QTableViewPrivate::heightHintForIndex(const QModelIndex &index, int hint, QS
+         option.rect.setHeight(height);
+         option.rect.setX(q->columnViewportPosition(index.column()));
+         option.rect.setWidth(q->columnWidth(index.column()));
++        if (hasSpans()) {
++            auto span = spans.spanAt(index.column(), index.row());
++            if (span && span->m_left == index.column() && span->m_top == index.row())
++                option.rect.setWidth(std::max(option.rect.width(), visualSpanRect(*span).width()));
++        }
+         // 1px less space when grid is shown (see drawCell)
+         if (showGrid)
+             option.rect.setWidth(option.rect.width() - 1);
+diff --git a/qtbase/src/widgets/kernel/qaction.h b/qtbase/src/widgets/kernel/qaction.h
+index 258a1ea0a0..737c1e8285 100644
+--- a/qtbase/src/widgets/kernel/qaction.h
++++ b/qtbase/src/widgets/kernel/qaction.h
+@@ -81,7 +81,7 @@ class Q_WIDGETS_EXPORT QAction : public QObject
+     Q_PROPERTY(MenuRole menuRole READ menuRole WRITE setMenuRole NOTIFY changed)
+     Q_PROPERTY(bool iconVisibleInMenu READ isIconVisibleInMenu WRITE setIconVisibleInMenu NOTIFY changed)
+     Q_PROPERTY(bool shortcutVisibleInContextMenu READ isShortcutVisibleInContextMenu WRITE setShortcutVisibleInContextMenu NOTIFY changed)
+-    Q_PROPERTY(Priority priority READ priority WRITE setPriority)
++    Q_PROPERTY(Priority priority READ priority WRITE setPriority NOTIFY changed)
+ 
+ public:
+     // note this is copied into qplatformmenu.h, which must stay in sync
+diff --git a/qtbase/src/widgets/kernel/qwidget.cpp b/qtbase/src/widgets/kernel/qwidget.cpp
+index 9eba1e001e..26f6d27e18 100644
+--- a/qtbase/src/widgets/kernel/qwidget.cpp
++++ b/qtbase/src/widgets/kernel/qwidget.cpp
+@@ -5296,7 +5296,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
+         QWidgetEffectSourcePrivate *sourced = static_cast<QWidgetEffectSourcePrivate *>
+                                                          (source->d_func());
+         if (!sourced->context) {
+-            const QRegion effectRgn(rgn.boundingRect());
++            const QRegion effectRgn((flags & UseEffectRegionBounds) ? rgn.boundingRect() : rgn);
+             QWidgetPaintContext context(pdev, effectRgn, offset, flags, sharedPainter, repaintManager);
+             sourced->context = &context;
+             if (!sharedPainter) {
+@@ -5328,6 +5328,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
+         }
+     }
+ #endif // QT_CONFIG(graphicseffect)
++    flags = flags & ~UseEffectRegionBounds;
+ 
+     const bool alsoOnScreen = flags & DrawPaintOnScreen;
+     const bool recursive = flags & DrawRecursive;
+diff --git a/qtbase/src/widgets/kernel/qwidget_p.h b/qtbase/src/widgets/kernel/qwidget_p.h
+index eef6b8fa2c..c432f4b5d5 100644
+--- a/qtbase/src/widgets/kernel/qwidget_p.h
++++ b/qtbase/src/widgets/kernel/qwidget_p.h
+@@ -229,7 +229,8 @@ public:
+         DontSubtractOpaqueChildren = 0x10,
+         DontDrawOpaqueChildren = 0x20,
+         DontDrawNativeChildren = 0x40,
+-        DontSetCompositionMode = 0x80
++        DontSetCompositionMode = 0x80,
++        UseEffectRegionBounds = 0x100
+     };
+     Q_DECLARE_FLAGS(DrawWidgetFlags, DrawWidgetFlag)
+     Q_FLAG(DrawWidgetFlags)
+diff --git a/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp b/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
+index 02880b34da..0d44e1326d 100644
+--- a/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
++++ b/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
+@@ -1018,7 +1018,8 @@ void QWidgetRepaintManager::paintAndFlush()
+ 
+     // Paint the rest with composition.
+     if (repaintAllWidgets || !dirtyCopy.isEmpty()) {
+-        QWidgetPrivate::DrawWidgetFlags flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive;
++        QWidgetPrivate::DrawWidgetFlags flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive
++                | QWidgetPrivate::UseEffectRegionBounds;
+         tlw->d_func()->drawWidget(store->paintDevice(), dirtyCopy, QPoint(), flags, nullptr, this);
+     }
+ 
+diff --git a/qtbase/src/widgets/styles/qfusionstyle.cpp b/qtbase/src/widgets/styles/qfusionstyle.cpp
+index f4345d97c4..962912c838 100644
+--- a/qtbase/src/widgets/styles/qfusionstyle.cpp
++++ b/qtbase/src/widgets/styles/qfusionstyle.cpp
+@@ -1772,14 +1772,6 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio
+             proxy()->drawControl(CE_PushButtonLabel, &subopt, painter, widget);
+         }
+         break;
+-    case CE_PushButtonLabel:
+-        if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
+-            QStyleOptionButton b(*button);
+-            // no PM_ButtonShiftHorizontal and PM_ButtonShiftVertical for fusion style
+-            b.state &= ~(State_On | State_Sunken);
+-            QCommonStyle::drawControl(element, &b, painter, widget);
+-        }
+-        break;
+     case CE_MenuBarEmptyArea:
+         painter->save();
+     {
+diff --git a/qtbase/src/widgets/util/qcompleter.cpp b/qtbase/src/widgets/util/qcompleter.cpp
+index 18b24063d8..ef7207a8a3 100644
+--- a/qtbase/src/widgets/util/qcompleter.cpp
++++ b/qtbase/src/widgets/util/qcompleter.cpp
+@@ -1120,6 +1120,8 @@ void QCompleter::setModel(QAbstractItemModel *model)
+ {
+     Q_D(QCompleter);
+     QAbstractItemModel *oldModel = d->proxy->sourceModel();
++    if (oldModel == model)
++        return;
+ #if QT_CONFIG(filesystemmodel)
+     if (qobject_cast<const QFileSystemModel *>(oldModel))
+         setCompletionRole(Qt::EditRole); // QTBUG-54642, clear FileNameRole set by QFileSystemModel
+diff --git a/qtbase/src/widgets/widgets/qabstractbutton.cpp b/qtbase/src/widgets/widgets/qabstractbutton.cpp
+index a128b23950..dc40bf62fb 100644
+--- a/qtbase/src/widgets/widgets/qabstractbutton.cpp
++++ b/qtbase/src/widgets/widgets/qabstractbutton.cpp
+@@ -56,6 +56,7 @@
+ #ifndef QT_NO_ACCESSIBILITY
+ #include "qaccessible.h"
+ #endif
++#include <qpa/qplatformtheme.h>
+ 
+ #include <algorithm>
+ 
+@@ -1076,19 +1077,19 @@ void QAbstractButton::keyPressEvent(QKeyEvent *e)
+ {
+     Q_D(QAbstractButton);
+     bool next = true;
+-    switch (e->key()) {
+-    case Qt::Key_Enter:
+-    case Qt::Key_Return:
+-        e->ignore();
+-        break;
+-    case Qt::Key_Select:
+-    case Qt::Key_Space:
+-        if (!e->isAutoRepeat()) {
+-            setDown(true);
+-            repaint();
+-            d->emitPressed();
+-        }
+-        break;
++
++    const auto key = static_cast<Qt::Key>(e->key());
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(key) && !e->isAutoRepeat()) {
++        setDown(true);
++        repaint();
++        d->emitPressed();
++        return;
++    }
++
++    switch (key) {
+     case Qt::Key_Up:
+         next = false;
+         Q_FALLTHROUGH();
+@@ -1153,15 +1154,15 @@ void QAbstractButton::keyReleaseEvent(QKeyEvent *e)
+     if (!e->isAutoRepeat())
+         d->repeatTimer.stop();
+ 
+-    switch (e->key()) {
+-    case Qt::Key_Select:
+-    case Qt::Key_Space:
+-        if (!e->isAutoRepeat() && d->down)
+-            d->click();
+-        break;
+-    default:
+-        e->ignore();
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(static_cast<Qt::Key>(e->key())) && !e->isAutoRepeat() && d->down) {
++        d->click();
++        return;
+     }
++
++    e->ignore();
+ }
+ 
+ /*!\reimp
+diff --git a/qtbase/src/widgets/widgets/qcombobox.cpp b/qtbase/src/widgets/widgets/qcombobox.cpp
+index 7a496c27e0..0a3d96647b 100644
+--- a/qtbase/src/widgets/widgets/qcombobox.cpp
++++ b/qtbase/src/widgets/widgets/qcombobox.cpp
+@@ -3352,7 +3352,23 @@ void QComboBox::keyPressEvent(QKeyEvent *e)
+ 
+     Move move = NoMove;
+     int newIndex = currentIndex();
+-    switch (e->key()) {
++
++    bool pressLikeButton = !d->lineEdit;
++#ifdef QT_KEYPAD_NAVIGATION
++    pressLikeButton |= QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus();
++#endif
++    auto key = static_cast<Qt::Key>(e->key());
++    if (pressLikeButton) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(key)) {
++            showPopup();
++            return;
++        }
++    }
++
++    switch (key) {
+     case Qt::Key_Up:
+         if (e->modifiers() & Qt::ControlModifier)
+             break; // pass to line edit for auto completion
+@@ -3394,26 +3410,11 @@ void QComboBox::keyPressEvent(QKeyEvent *e)
+             return;
+         }
+         break;
+-    case Qt::Key_Space:
+-        if (!d->lineEdit) {
+-            showPopup();
+-            return;
+-        }
+-        break;
+-    case Qt::Key_Enter:
+-    case Qt::Key_Return:
+     case Qt::Key_Escape:
+         if (!d->lineEdit)
+             e->ignore();
+         break;
+ #ifdef QT_KEYPAD_NAVIGATION
+-    case Qt::Key_Select:
+-        if (QApplicationPrivate::keypadNavigationEnabled()
+-                && (!hasEditFocus() || !d->lineEdit)) {
+-            showPopup();
+-            return;
+-        }
+-        break;
+     case Qt::Key_Left:
+     case Qt::Key_Right:
+         if (QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus())
+diff --git a/qtbase/src/widgets/widgets/qdatetimeedit_p.h b/qtbase/src/widgets/widgets/qdatetimeedit_p.h
+index d36b6f8f9a..e0df5b5158 100644
+--- a/qtbase/src/widgets/widgets/qdatetimeedit_p.h
++++ b/qtbase/src/widgets/widgets/qdatetimeedit_p.h
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2018 The Qt Company Ltd.
++** Copyright (C) 2021 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtWidgets module of the Qt Toolkit.
+diff --git a/qtbase/src/widgets/widgets/qgroupbox.cpp b/qtbase/src/widgets/widgets/qgroupbox.cpp
+index 02a0bed325..3f3eccc370 100644
+--- a/qtbase/src/widgets/widgets/qgroupbox.cpp
++++ b/qtbase/src/widgets/widgets/qgroupbox.cpp
+@@ -54,6 +54,8 @@
+ #include "qaccessible.h"
+ #endif
+ #include <private/qwidget_p.h>
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
+ 
+ #include "qdebug.h"
+ 
+@@ -360,7 +362,10 @@ bool QGroupBox::event(QEvent *e)
+         return true;
+     case QEvent::KeyPress: {
+         QKeyEvent *k = static_cast<QKeyEvent*>(e);
+-        if (!k->isAutoRepeat() && (k->key() == Qt::Key_Select || k->key() == Qt::Key_Space)) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (!k->isAutoRepeat() && buttonPressKeys.contains(static_cast<Qt::Key>(k->key()))) {
+             d->pressedControl = QStyle::SC_GroupBoxCheckBox;
+             update(style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxCheckBox, this));
+             return true;
+@@ -369,7 +374,10 @@ bool QGroupBox::event(QEvent *e)
+     }
+     case QEvent::KeyRelease: {
+         QKeyEvent *k = static_cast<QKeyEvent*>(e);
+-        if (!k->isAutoRepeat() && (k->key() == Qt::Key_Select || k->key() == Qt::Key_Space)) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (!k->isAutoRepeat() && buttonPressKeys.contains(static_cast<Qt::Key>(k->key()))) {
+             bool toggle = (d->pressedControl == QStyle::SC_GroupBoxLabel
+                            || d->pressedControl == QStyle::SC_GroupBoxCheckBox);
+             d->pressedControl = QStyle::SC_None;
+diff --git a/qtbase/src/widgets/widgets/qlabel.cpp b/qtbase/src/widgets/widgets/qlabel.cpp
+index 30ff80cbb0..cf2605c17c 100644
+--- a/qtbase/src/widgets/widgets/qlabel.cpp
++++ b/qtbase/src/widgets/widgets/qlabel.cpp
+@@ -421,9 +421,6 @@ void QLabel::setPixmap(const QPixmap &pixmap)
+         d->pixmap = new QPixmap(pixmap);
+     }
+ 
+-    if (d->pixmap->depth() == 1 && !d->pixmap->mask())
+-        d->pixmap->setMask(*((QBitmap *)d->pixmap));
+-
+     d->updateLabel();
+ }
+ 
+diff --git a/qtbase/src/widgets/widgets/qtoolbararealayout.cpp b/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
+index 493c094cc1..d5f4b59017 100644
+--- a/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
++++ b/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
+@@ -1367,7 +1367,7 @@ bool QToolBarAreaLayout::restoreState(QDataStream &stream, const QList<QToolBar*
+                 item.widgetItem = new QWidgetItemV2(toolBar);
+                 toolBar->setOrientation(floating ? ((shown & 2) ? Qt::Vertical : Qt::Horizontal) : dock.o);
+                 toolBar->setVisible(shown & 1);
+-                toolBar->d_func()->setWindowState(floating, true, rect);
++                toolBar->d_func()->setWindowState(floating, false, rect);
+ 
+                 item.preferredSize = item.size;
+                 line.toolBarItems.append(item);
+diff --git a/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp b/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
+index 212c0a2e13..3c77b1ba0b 100644
+--- a/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
++++ b/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
+@@ -126,8 +126,7 @@ public:
+ 
+ void tst_QtConcurrentIterateKernel::instantiate()
+ {
+-    auto future = startThreadEngine(new PrintFor(0, 40)).startAsynchronously();
+-    future.waitForFinished();
++    startThreadEngine(new PrintFor(0, 40)).startBlocking();
+     QCOMPARE(iterations.loadRelaxed(), 40);
+ }
+ 
+@@ -166,10 +165,8 @@ void tst_QtConcurrentIterateKernel::stresstest()
+     const int times = 50;
+     for (int i = 0; i < times; ++i) {
+         counter.storeRelaxed(0);
+-        // ThreadEngine will delete f when it finishes
+-        auto f = new CountFor(0, iterations);
+-        auto future = f->startAsynchronously();
+-        future.waitForFinished();
++        CountFor f(0, iterations);
++        f.startBlocking();
+         QCOMPARE(counter.loadRelaxed(), iterations);
+     }
+ }
+@@ -177,11 +174,8 @@ void tst_QtConcurrentIterateKernel::stresstest()
+ void tst_QtConcurrentIterateKernel::noIterations()
+ {
+     const int times = 20000;
+-    for (int i = 0; i < times; ++i) {
+-        auto future = startThreadEngine(new IterateKernel<TestIterator, void>(0, 0))
+-                              .startAsynchronously();
+-        future.waitForFinished();
+-    }
++    for (int i = 0; i < times; ++i)
++        startThreadEngine(new IterateKernel<TestIterator, void>(0, 0)).startBlocking();
+ }
+ 
+ QMutex threadsMutex;
+@@ -236,10 +230,8 @@ void tst_QtConcurrentIterateKernel::throttling()
+ 
+     threads.clear();
+ 
+-    // ThreadEngine will delete f when it finishes
+-    auto f = new ThrottleFor(0, totalIterations);
+-    auto future = f->startAsynchronously();
+-    future.waitForFinished();
++    ThrottleFor f(0, totalIterations);
++    f.startBlocking();
+ 
+     QCOMPARE(iterations.loadRelaxed(), totalIterations);
+ 
+diff --git a/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp b/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
+index ac7be7acdd..81bc64c8d9 100644
+--- a/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
++++ b/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
+@@ -65,9 +65,16 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::runDirectly()
+ {
+-    PrintUser *engine = new PrintUser();
+-    QFuture<void> f = engine->startAsynchronously();
+-    f.waitForFinished();
++    {
++        PrintUser engine;
++        engine.startSingleThreaded();
++        engine.startBlocking();
++    }
++    {
++        PrintUser *engine = new PrintUser();
++        QFuture<void> f = engine->startAsynchronously();
++        f.waitForFinished();
++    }
+ }
+ 
+ class StringResultUser : public ThreadEngine<QString>
+@@ -99,10 +106,8 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::result()
+ {
+-    // ThreadEngine will delete 'engine' when it finishes
+-    auto engine = new StringResultUser();
+-    auto future = engine->startAsynchronously();
+-    QCOMPARE(future.result(), QString("Foo"));
++    StringResultUser engine;
++    QCOMPARE(*engine.startBlocking(), QString("Foo"));
+ }
+ 
+ class VoidResultUser : public ThreadEngine<void>
+@@ -128,9 +133,17 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::runThroughStarter()
+ {
+-    ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
+-    QFuture<QString> f = starter.startAsynchronously();
+-    QCOMPARE(f.result(), QString("Foo"));
++    {
++        ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
++        QFuture<QString>  f = starter.startAsynchronously();
++        QCOMPARE(f.result(), QString("Foo"));
++    }
++
++    {
++        ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
++        QString str = starter.startBlocking();
++        QCOMPARE(str, QString("Foo"));
++    }
+ }
+ 
+ class CancelUser : public ThreadEngine<void>
+@@ -213,6 +226,12 @@ void tst_QtConcurrentThreadEngine::throttle()
+         f.waitForFinished();
+         QCOMPARE(count.loadRelaxed(), 0);
+     }
++
++    for (int i = 0; i < repeats; ++i) {
++        ThrottleAlwaysUser t;
++        t.startBlocking();
++        QCOMPARE(count.loadRelaxed(), 0);
++    }
+ }
+ 
+ QSet<QThread *> threads;
+@@ -249,17 +268,35 @@ void tst_QtConcurrentThreadEngine::threadCount()
+ {
+     const int repeats = 10;
+     for (int i = 0; i < repeats; ++i) {
++        ThreadCountUser t;
++        t.startBlocking();
++        int count = threads.count();
++        int count_expected = QThreadPool::globalInstance()->maxThreadCount() + 1; // +1 for the main thread.
++        if (count != count_expected)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, count_expected);
++
+         (new ThreadCountUser())->startAsynchronously().waitForFinished();
+-        const auto count = threads.count();
+-        const auto maxThreadCount = QThreadPool::globalInstance()->maxThreadCount();
+-        QVERIFY(count <= maxThreadCount);
+-        QVERIFY(!threads.contains(QThread::currentThread()));
++        count = threads.count();
++        count_expected = QThreadPool::globalInstance()->maxThreadCount();
++        if (count != count_expected)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, count_expected);
+     }
+ 
+     // Set the finish flag immediately, this should give us one thread only.
+     for (int i = 0; i < repeats; ++i) {
++        ThreadCountUser t(true /*finishImmediately*/);
++        t.startBlocking();
++        int count = threads.count();
++        if (count != 1)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, 1);
++
+         (new ThreadCountUser(true /*finishImmediately*/))->startAsynchronously().waitForFinished();
+-        const auto count = threads.count();
++        count = threads.count();
++        if (count != 1)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
+         QCOMPARE(count, 1);
+         QVERIFY(!threads.contains(QThread::currentThread()));
+     }
+@@ -400,6 +437,7 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::exceptions()
+ {
++    // Asynchronous mode:
+     {
+         bool caught = false;
+         try  {
+@@ -412,6 +450,32 @@ void tst_QtConcurrentThreadEngine::exceptions()
+         QVERIFY2(caught, "did not get exception");
+     }
+ 
++    // Blocking mode:
++    // test throwing the exception from a worker thread.
++    {
++        bool caught = false;
++        try  {
++            QtConcurrentExceptionThrower e(QThread::currentThread());
++            e.startBlocking();
++        } catch (const QException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // test throwing the exception from the main thread (different code path)
++    {
++        bool caught = false;
++        try  {
++            QtConcurrentExceptionThrower e(0);
++            e.startBlocking();
++        } catch (const QException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // Asynchronous mode:
+     {
+         bool caught = false;
+         try  {
+@@ -423,6 +487,31 @@ void tst_QtConcurrentThreadEngine::exceptions()
+         }
+         QVERIFY2(caught, "did not get exception");
+     }
++
++    // Blocking mode:
++    // test throwing the exception from a worker thread.
++    {
++        bool caught = false;
++        try  {
++            UnrelatedExceptionThrower e(QThread::currentThread());
++            e.startBlocking();
++        } catch (const QUnhandledException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // test throwing the exception from the main thread (different code path)
++    {
++        bool caught = false;
++        try  {
++            UnrelatedExceptionThrower e(0);
++            e.startBlocking();
++        } catch (const QUnhandledException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
+ }
+ 
+ #endif
+diff --git a/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp b/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
+index 4968742110..f4c3fb711d 100644
+--- a/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
++++ b/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
+@@ -42,6 +42,7 @@ private slots:
+     void writeBlock_data();
+     void writeBlock();
+     void seek();
++    void invalidSeeks();
+     void seekTest_data();
+     void seekTest();
+     void read_rawdata();
+@@ -286,6 +287,29 @@ void tst_QBuffer::seek()
+     QCOMPARE(buffer.size(), pos);
+ }
+ 
++void tst_QBuffer::invalidSeeks()
++{
++    if constexpr (sizeof(qsizetype) == sizeof(qint64)) {
++        // sizeof(qsizetype) == sizeof(qint64), so +1 would overflow
++        QSKIP("This is a 32-bit-only test.");
++    } else {
++        QBuffer buffer;
++        buffer.open(QIODevice::WriteOnly);
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++        constexpr qint64 MaxQByteArrayCapacity = (std::numeric_limits<qsizetype>::max)();
++        // this should fail fast, not after trying to allocate nearly 2 GiB of data,
++        // potentially crashing in the process:
++        QVERIFY(!buffer.seek(2 * MaxQByteArrayCapacity - 1));
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++        // ditto:
++        QVERIFY(!buffer.seek(MaxQByteArrayCapacity + 1));
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++    }
++}
++
+ void tst_QBuffer::seekTest_data()
+ {
+     writeBlock_data();
+diff --git a/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp b/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
+index da5327594c..4a04e0f7c6 100644
+--- a/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
++++ b/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
+@@ -561,7 +561,8 @@ protected:
+     qint64 readData(char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf->size() - offset));
+-        memcpy(data, buf->constData() + offset, maxSize);
++        if (maxSize > 0)
++            memcpy(data, buf->constData() + offset, maxSize);
+         offset += maxSize;
+         return maxSize;
+     }
+@@ -604,13 +605,15 @@ protected:
+     qint64 readData(char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf.size() - pos()));
+-        memcpy(data, buf.constData() + pos(), maxSize);
++        if (maxSize > 0)
++            memcpy(data, buf.constData() + pos(), maxSize);
+         return maxSize;
+     }
+     qint64 writeData(const char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf.size() - pos()));
+-        memcpy(buf.data() + pos(), data, maxSize);
++        if (maxSize > 0)
++            memcpy(buf.data() + pos(), data, maxSize);
+         return maxSize;
+     }
+ 
+diff --git a/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+index db60bead64..f345a44414 100644
+--- a/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
++++ b/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+@@ -1,7 +1,8 @@
+ /****************************************************************************
+ **
+ ** Copyright (C) 2021 The Qt Company Ltd.
+-** Copyright (C) 2020 Intel Corporation.
++** Copyright (C) 2020 The Qt Company Ltd.
++** Copyright (C) 2022 Intel Corporation.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the test suite of the Qt Toolkit.
+@@ -150,6 +151,8 @@ private slots:
+     void startStopStartStopBuffers();
+     void processEventsInAReadyReadSlot_data();
+     void processEventsInAReadyReadSlot();
++    void startFromCurrentWorkingDir_data();
++    void startFromCurrentWorkingDir();
+ 
+     // keep these at the end, since they use lots of processes and sometimes
+     // caused obscure failures to occur in tests that followed them (esp. on the Mac)
+@@ -2731,5 +2734,94 @@ void tst_QProcess::finishProcessBeforeReadingDone_deprecated()
+ 
+ #endif
+ 
++enum class ChdirMode {
++    None = 0,
++    InParent,
++    InChild
++};
++Q_DECLARE_METATYPE(ChdirMode)
++
++void tst_QProcess::startFromCurrentWorkingDir_data()
++{
++    qRegisterMetaType<ChdirMode>();
++    QTest::addColumn<QString>("programPrefix");
++    QTest::addColumn<ChdirMode>("chdirMode");
++    QTest::addColumn<bool>("success");
++
++    constexpr bool IsWindows = true
++#ifdef Q_OS_UNIX
++            && false
++#endif
++            ;
++
++    // baseline: trying to execute the directory, this can't possibly succeed!
++    QTest::newRow("plain-same-cwd") << QString() << ChdirMode::None << false;
++
++    // cross-platform behavior: neither OS searches the setWorkingDirectory()
++    // dir without "./"
++    QTest::newRow("plain-child-chdir") << QString() << ChdirMode::InChild << false;
++
++    // cross-platform behavior: both OSes search the parent's CWD with "./"
++    QTest::newRow("prefixed-parent-chdir") << "./" << ChdirMode::InParent << true;
++
++    // opposite behaviors: Windows searches the parent's CWD and Unix searches
++    // the child's with "./"
++    QTest::newRow("prefixed-child-chdir") << "./" << ChdirMode::InChild << !IsWindows;
++
++    // Windows searches the parent's CWD without "./"
++    QTest::newRow("plain-parent-chdir") << QString() << ChdirMode::InParent << IsWindows;
++}
++
++void tst_QProcess::startFromCurrentWorkingDir()
++{
++    QFETCH(QString, programPrefix);
++    QFETCH(ChdirMode, chdirMode);
++    QFETCH(bool, success);
++
++    QProcess process;
++    qRegisterMetaType<QProcess::ProcessError>();
++    QSignalSpy errorSpy(&process, &QProcess::errorOccurred);
++    QVERIFY(errorSpy.isValid());
++
++    // both the dir name and the executable name
++    const QString target = QStringLiteral("testProcessNormal");
++    process.setProgram(programPrefix + target);
++
++#ifdef Q_OS_UNIX
++    // Reset PATH, to be sure it doesn't contain . or the empty path.
++    // We can't do this on Windows because DLLs are searched in PATH
++    // and Windows always searches "." anyway.
++    auto restoreEnv = qScopeGuard([old = qgetenv("PATH")] {
++        qputenv("PATH", old);
++    });
++    qputenv("PATH", "/");
++#endif
++
++    switch (chdirMode) {
++    case ChdirMode::InParent: {
++        auto restoreCwd = qScopeGuard([old = QDir::currentPath()] {
++            QDir::setCurrent(old);
++        });
++        QVERIFY(QDir::setCurrent(target));
++        process.start();
++        break;
++    }
++    case ChdirMode::InChild:
++        process.setWorkingDirectory(target);
++        Q_FALLTHROUGH();
++    case ChdirMode::None:
++        process.start();
++        break;
++    }
++
++    QCOMPARE(process.waitForStarted(), success);
++    QCOMPARE(errorSpy.count(), int(!success));
++    if (success) {
++        QVERIFY(process.waitForFinished());
++    } else {
++        QCOMPARE(process.error(), QProcess::FailedToStart);
++    }
++}
++
+ QTEST_MAIN(tst_QProcess)
+ #include "tst_qprocess.moc"
+diff --git a/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp b/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp
+index e1ea7a4552..90972caa57 100644
+--- a/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp
++++ b/qtbase/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"
+diff --git a/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+index 9bd66c0835..ed4a0bae5d 100644
+--- a/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
++++ b/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+@@ -158,6 +158,7 @@ private slots:
+     void nullReceiver();
+     void functorReferencesConnection();
+     void disconnectDisconnects();
++    void declarativeData();
+ };
+ 
+ struct QObjectCreatedOnShutdown
+@@ -7679,5 +7680,81 @@ void tst_QObject::disconnectDisconnects()
+ Q_STATIC_ASSERT(QtPrivate::HasQ_OBJECT_Macro<tst_QObject>::Value);
+ Q_STATIC_ASSERT(!QtPrivate::HasQ_OBJECT_Macro<SiblingDeleter>::Value);
+ 
++#ifdef QT_BUILD_INTERNAL
++/*
++    Since QObjectPrivate stores the declarativeData pointer in a union with the pointer
++    to the currently destroyed child, calls to the QtDeclarative handlers need to be
++    correctly guarded. QTBUG-105286
++*/
++namespace QtDeclarative {
++static QAbstractDeclarativeData *theData;
++
++static void destroyed(QAbstractDeclarativeData *data, QObject *)
++{
++    QCOMPARE(data, theData);
++}
++static void signalEmitted(QAbstractDeclarativeData *data, QObject *, int, void **)
++{
++    QCOMPARE(data, theData);
++}
++// we can't use QCOMPARE in the next two functions, as they don't return void
++static int receivers(QAbstractDeclarativeData *data, const QObject *, int)
++{
++    QTest::qCompare(data, theData, "data", "theData", __FILE__, __LINE__);
++    return 0;
++}
++static bool isSignalConnected(QAbstractDeclarativeData *data, const QObject *, int)
++{
++    QTest::qCompare(data, theData, "data", "theData", __FILE__, __LINE__);
++    return true;
++}
++
++class Object : public QObject
++{
++    Q_OBJECT
++public:
++    using QObject::QObject;
++    ~Object()
++    {
++        if (Object *p = static_cast<Object *>(parent()))
++            p->emitSignal();
++    }
++
++    void emitSignal()
++    {
++        emit theSignal();
++    }
++
++signals:
++    void theSignal();
++};
++
++}
++#endif
++
++void tst_QObject::declarativeData()
++{
++#ifdef QT_BUILD_INTERNAL
++    QScopedValueRollback destroyed(QAbstractDeclarativeData::destroyed,
++                                   QtDeclarative::destroyed);
++    QScopedValueRollback signalEmitted(QAbstractDeclarativeData::signalEmitted,
++                                       QtDeclarative::signalEmitted);
++    QScopedValueRollback receivers(QAbstractDeclarativeData::receivers,
++                                   QtDeclarative::receivers);
++    QScopedValueRollback isSignalConnected(QAbstractDeclarativeData::isSignalConnected,
++                                           QtDeclarative::isSignalConnected);
++
++    QtDeclarative::Object p;
++    QObjectPrivate *priv = QObjectPrivate::get(&p);
++    priv->declarativeData = QtDeclarative::theData = new QAbstractDeclarativeData;
++
++    connect(&p, &QtDeclarative::Object::theSignal, &p, []{
++    });
++
++    QtDeclarative::Object *child = new QtDeclarative::Object;
++    child->setParent(&p);
++#endif
++}
++
+ QTEST_MAIN(tst_QObject)
+ #include "tst_qobject.moc"
+diff --git a/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp b/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
+index 0ea422ecbc..1a3256534b 100644
+--- a/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
++++ b/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
+@@ -70,15 +70,15 @@ static inline QString testSuiteWarning()
+ 
+     QString result;
+     QTextStream str(&result);
+-    str << "\nCannot find the shared-mime-info test suite\nstarting from: "
++    str << "\nCannot find the shared-mime-info test suite\nin the parent of: "
+         << QDir::toNativeSeparators(QDir::currentPath()) << "\n"
+            "cd " << QDir::toNativeSeparators(QStringLiteral("tests/auto/corelib/mimetypes/qmimedatabase")) << "\n"
+-           "wget http://cgit.freedesktop.org/xdg/shared-mime-info/snapshot/Release-1-10.zip\n"
+-           "unzip Release-1-10.zip\n";
++           "wget https://gitlab.freedesktop.org/xdg/shared-mime-info/-/archive/2.1/shared-mime-info-2.1.zip\n"
++           "unzip shared-mime-info-2.1.zip\n";
+ #ifdef Q_OS_WIN
+-    str << "mkdir testfiles\nxcopy /s Release-1-10 s-m-i\n";
++    str << "mkdir testfiles\nxcopy /s shared-mime-info-2.1 s-m-i\n";
+ #else
+-    str << "ln -s Release-1-10 s-m-i\n";
++    str << "ln -s shared-mime-info-2.1 s-m-i\n";
+ #endif
+     return result;
+ }
+@@ -154,7 +154,7 @@ void tst_QMimeDatabase::initTestCase()
+     QVERIFY2(copyResourceFile(xmlFileName, xmlTargetFileName, &errorMessage), qPrintable(errorMessage));
+ #endif
+ 
+-    m_testSuite = QFINDTESTDATA("s-m-i/tests");
++    m_testSuite = QFINDTESTDATA("s-m-i/tests/mime-detection");
+     if (m_testSuite.isEmpty())
+         qWarning("%s", qPrintable(testSuiteWarning()));
+ 
+@@ -611,7 +611,7 @@ void tst_QMimeDatabase::allMimeTypes()
+     QVERIFY(!lst.isEmpty());
+ 
+     // Hardcoding this is the only way to check both providers find the same number of mimetypes.
+-    QCOMPARE(lst.count(), 779);
++    QCOMPARE(lst.count(), 811);
+ 
+     foreach (const QMimeType &mime, lst) {
+         const QString name = mime.name();
+@@ -631,10 +631,9 @@ void tst_QMimeDatabase::suffixes_data()
+ 
+     QTest::newRow("mimetype with a single pattern") << "application/pdf" << "*.pdf" << "pdf";
+     QTest::newRow("mimetype with multiple patterns") << "application/x-kpresenter" << "*.kpr;*.kpt" << "kpr";
+-    QTest::newRow("jpeg") << "image/jpeg" << "*.jpe;*.jpg;*.jpeg" << "jpeg";
+-    //if (KMimeType::sharedMimeInfoVersion() > KDE_MAKE_VERSION(0, 60, 0)) {
+-        QTest::newRow("mimetype with many patterns") << "application/vnd.wordperfect" << "*.wp;*.wp4;*.wp5;*.wp6;*.wpd;*.wpp" << "wp";
+-    //}
++    // The preferred suffix for image/jpeg is *.jpg, as per https://bugs.kde.org/show_bug.cgi?id=176737
++    QTest::newRow("jpeg") << "image/jpeg" << "*.jpe;*.jpg;*.jpeg" << "jpg";
++    QTest::newRow("mimetype with many patterns") << "application/vnd.wordperfect" << "*.wp;*.wp4;*.wp5;*.wp6;*.wpd;*.wpp" << "wp";
+     QTest::newRow("oasis text mimetype") << "application/vnd.oasis.opendocument.text" << "*.odt" << "odt";
+     QTest::newRow("oasis presentation mimetype") << "application/vnd.oasis.opendocument.presentation" << "*.odp" << "odp";
+     QTest::newRow("mimetype with multiple patterns") << "text/plain" << "*.asc;*.txt;*,v" << "txt";
+diff --git a/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp b/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
+index 3e58dd03cc..c8f82ef5d5 100644
+--- a/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
++++ b/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
+@@ -176,6 +176,8 @@ private Q_SLOTS:
+     void fromToVariantConversions_data();
+     void fromToVariantConversions();
+ 
++    void noLeakOnNameClash();
++
+ private:
+     QString testDataDir;
+ };
+@@ -3685,5 +3687,23 @@ void tst_QtJson::fromToVariantConversions()
+     }
+ }
+ 
++void tst_QtJson::noLeakOnNameClash()
++{
++    QJsonDocument doc = QJsonDocument::fromJson("{\"\":{\"\":0},\"\":0}");
++    QVERIFY(!doc.isNull());
++    const QJsonObject obj = doc.object();
++
++    // Removed the duplicate key.
++    QCOMPARE(obj.length(), 1);
++
++    // Retained the last of the duplicates.
++    const QJsonValue val = obj.begin().value();
++    QVERIFY(val.isDouble());
++    QCOMPARE(val.toDouble(), 0.0);
++
++    // It should not leak.
++    // In particular it should not forget to deref the container for the inner object.
++}
++
+ QTEST_MAIN(tst_QtJson)
+ #include "tst_qtjson.moc"
+diff --git a/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp b/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
+index a59b58d57f..241c3e84ac 100644
+--- a/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
++++ b/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
+@@ -63,6 +63,7 @@ private slots:
+     void isValidId_data();
+     void isValidId();
+     void malformed();
++    void serialize();
+     // Backend tests
+     void utcTest();
+     void icuTest();
+@@ -947,6 +948,33 @@ void tst_QTimeZone::malformed()
+         barf.offsetFromUtc(now);
+ }
+ 
++void tst_QTimeZone::serialize()
++{
++    int parts = 0;
++#ifndef QT_NO_DEBUG_STREAM
++    qDebug() << QTimeZone(); // to verify no crash
++    parts++;
++#endif
++#ifndef QT_NO_DATASTREAM
++    QByteArray blob;
++    {
++        QDataStream stream(&blob, QIODevice::WriteOnly);
++        stream << QTimeZone("Europe/Oslo") << QTimeZone(420) << QTimeZone() << qint64(-1);
++    }
++    QDataStream stream(&blob, QIODevice::ReadOnly);
++    QTimeZone invalid, offset, oslo;
++    qint64 minusone;
++    stream >> oslo >> offset >> invalid >> minusone;
++    QCOMPARE(oslo, QTimeZone("Europe/Oslo"));
++    QCOMPARE(offset, QTimeZone(420));
++    QVERIFY(!invalid.isValid());
++    QCOMPARE(minusone, qint64(-1));
++    parts++;
++#endif
++    if (!parts)
++        QSKIP("No serialization enabled");
++}
++
+ void tst_QTimeZone::utcTest()
+ {
+ #ifdef QT_BUILD_INTERNAL
+diff --git a/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp b/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
+index 05480c6dd2..70f4c75756 100644
+--- a/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
++++ b/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
+@@ -324,6 +324,13 @@ void tst_QDBusInterface::notValid()
+ 
+     QVERIFY(!interface.isValid());
+     QVERIFY(!QMetaObject::invokeMethod(&interface, "ListNames", Qt::DirectConnection));
++
++    // With a connection, but empty/null service and path specified
++    QDBusConnection con = QDBusConnection::sessionBus();
++    QVERIFY(con.isConnected());
++    QDBusInterface iface({}, {}, {}, con);
++    QVERIFY(!iface.isValid());
++    QVERIFY(!QMetaObject::invokeMethod(&interface, "ListNames", Qt::DirectConnection));
+ }
+ 
+ void tst_QDBusInterface::notValidDerived()
+diff --git a/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp b/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
+index 874468c954..04ceb4ab65 100644
+--- a/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
++++ b/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
+@@ -507,6 +507,10 @@ void tst_QKeySequence::toStringFromKeycode_data()
+     QTest::newRow("Ctrl+Alt+Num+Del") << QKeySequence(Qt::ControlModifier | Qt::AltModifier | Qt::KeypadModifier | Qt::Key_Delete) << "Ctrl+Alt+Num+Del";
+     QTest::newRow("Ctrl+Ins") << QKeySequence(Qt::ControlModifier | Qt::Key_Insert) << "Ctrl+Ins";
+     QTest::newRow("Ctrl+Num+Ins(1)") << QKeySequence(Qt::Key_Insert | Qt::KeypadModifier | Qt::ControlModifier) << "Ctrl+Num+Ins";
++    QTest::newRow("Ctrl") << QKeySequence(Qt::Key_Control) << "Control";
++    QTest::newRow("Alt") << QKeySequence(Qt::Key_Alt) << "Alt";
++    QTest::newRow("Shift") << QKeySequence(Qt::Key_Shift) << "Shift";
++    QTest::newRow("Meta") << QKeySequence(Qt::Key_Meta) << "Meta";
+ }
+ 
+ void tst_QKeySequence::toStringFromKeycode()
+diff --git a/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp b/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+index 15e0ecadaa..b4eca74283 100644
+--- a/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
++++ b/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+@@ -81,6 +81,8 @@ private slots:
+     void registerOpenTypePreferredNamesSystem();
+     void registerOpenTypePreferredNamesApplication();
+ 
++    void stretchRespected();
++
+ private:
+     QString m_ledFont;
+     QString m_testFont;
+@@ -355,6 +357,28 @@ static QString testString()
+     return QStringLiteral("foo bar");
+ }
+ 
++void tst_QFontDatabase::stretchRespected()
++{
++    int italicId = QFontDatabase::addApplicationFont(m_testFontItalic);
++    QVERIFY(italicId != -1);
++
++    QVERIFY(!QFontDatabase::applicationFontFamilies(italicId).isEmpty());
++
++    QString italicFontName = QFontDatabase::applicationFontFamilies(italicId).first();
++
++    QFont italicFont = QFontDatabase().font(italicFontName,
++                                            QString::fromLatin1("Italic"), 14);
++    QVERIFY(italicFont.italic());
++
++    QFont italicStretchedFont = italicFont;
++    italicStretchedFont.setStretch( 400 );
++
++    QVERIFY(QFontMetricsF(italicFont).horizontalAdvance(QStringLiteral("foobar")) <
++            QFontMetricsF(italicStretchedFont).horizontalAdvance(QStringLiteral("foobar")));
++
++    QFontDatabase::removeApplicationFont(italicId);
++}
++
+ void tst_QFontDatabase::condensedFontWidthNoFontMerging()
+ {
+     int regularFontId = QFontDatabase::addApplicationFont(m_testFont);
+diff --git a/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+index 3d4a094c43..b423e11a99 100644
+--- a/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
++++ b/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+@@ -281,6 +281,7 @@ private Q_SLOTS:
+     void ioGetFromFileSpecial();
+     void ioGetFromFile_data();
+     void ioGetFromFile();
++    void ioGetFromFileUrl();
+     void ioGetFromFtp_data();
+     void ioGetFromFtp();
+     void ioGetFromFtpWithReuse();
+@@ -3300,6 +3301,18 @@ void tst_QNetworkReply::ioGetFromFile()
+     QCOMPARE(reader.data, data);
+ }
+ 
++void tst_QNetworkReply::ioGetFromFileUrl()
++{
++    // This immediately fails on non-windows platforms:
++    QNetworkRequest request(QUrl("file://unc-server/some/path"));
++    QNetworkReplyPtr reply(manager.get(request));
++    QSignalSpy finishedSpy(reply.get(), &QNetworkReply::finished);
++    // QTBUG-105618: This would, on non-Windows platforms, never happen because the signal
++    // was emitted before the constructor finished, leaving no chance at all to connect to the
++    // signal
++    QVERIFY(finishedSpy.wait());
++}
++
+ void tst_QNetworkReply::ioGetFromFtp_data()
+ {
+     QTest::addColumn<QString>("fileName");
+diff --git a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
+index 069fa6b341..4cc4d9a5ea 100644
+--- a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
++++ b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
+@@ -1,75 +1,34 @@
+-Certificate:
+-    Data:
+-        Version: 3 (0x2)
+-        Serial Number: 0 (0x0)
+-        Signature Algorithm: sha1WithRSAEncryption
+-        Issuer: C=NO, ST=Oslo, L=Nydalen, O=Nokia Corporation and/or its subsidiary(-ies), OU=Development, CN=fluke.troll.no/emailAddress=ahanssen@trolltech.com
+-        Validity
+-            Not Before: Dec  4 01:10:32 2007 GMT
+-            Not After : Apr 21 01:10:32 2035 GMT
+-        Subject: C=NO, ST=Oslo, O=Nokia Corporation and/or its subsidiary(-ies), OU=Development, CN=fluke.troll.no
+-        Subject Public Key Info:
+-            Public Key Algorithm: rsaEncryption
+-            RSA Public Key: (1024 bit)
+-                Modulus (1024 bit):
+-                    00:a7:c8:a0:4a:c4:19:05:1b:66:ba:32:e2:d2:f1:
+-                    1c:6f:17:82:e4:39:2e:01:51:90:db:04:34:32:11:
+-                    21:c2:0d:6f:59:d8:53:90:54:3f:83:8f:a9:d3:b3:
+-                    d5:ee:1a:9b:80:ae:c3:25:c9:5e:a5:af:4b:60:05:
+-                    aa:a0:d1:91:01:1f:ca:04:83:e3:58:1c:99:32:45:
+-                    84:70:72:58:03:98:4a:63:8b:41:f5:08:49:d2:91:
+-                    02:60:6b:e4:64:fe:dd:a0:aa:74:08:e9:34:4c:91:
+-                    5f:12:3d:37:4d:54:2c:ad:7f:5b:98:60:36:02:8c:
+-                    3b:f6:45:f3:27:6a:9b:94:9d
+-                Exponent: 65537 (0x10001)
+-        X509v3 extensions:
+-            X509v3 Basic Constraints: 
+-                CA:FALSE
+-            Netscape Comment: 
+-                OpenSSL Generated Certificate
+-            X509v3 Subject Key Identifier: 
+-                21:85:04:3D:23:01:66:E5:F7:9F:1A:84:24:8A:AF:0A:79:F4:E5:AC
+-            X509v3 Authority Key Identifier: 
+-                DirName:/C=NO/ST=Oslo/L=Nydalen/O=Nokia Corporation and/or its subsidiary(-ies)/OU=Development/CN=fluke.troll.no/emailAddress=ahanssen@trolltech.com
+-                serial:8E:A8:B4:E8:91:B7:54:2E
+-
+-    Signature Algorithm: sha1WithRSAEncryption
+-        6d:57:5f:d1:05:43:f0:62:05:ec:2a:71:a5:dc:19:08:f2:c4:
+-        a6:bd:bb:25:d9:ca:89:01:0e:e4:cf:1f:c1:8c:c8:24:18:35:
+-        53:59:7b:c0:43:b4:32:e6:98:b2:a6:ef:15:05:0b:48:5f:e1:
+-        a0:0c:97:a9:a1:77:d8:35:18:30:bc:a9:8f:d3:b7:54:c7:f1:
+-        a9:9e:5d:e6:19:bf:f6:3c:5b:2b:d8:e4:3e:62:18:88:8b:d3:
+-        24:e1:40:9b:0c:e6:29:16:62:ab:ea:05:24:70:36:aa:55:93:
+-        ef:02:81:1b:23:10:a2:04:eb:56:95:75:fc:f8:94:b1:5d:42:
+-        c5:3f:36:44:85:5d:3a:2e:90:46:8a:a2:b9:6f:87:ae:0c:15:
+-        40:19:31:90:fc:3b:25:bb:ae:f1:66:13:0d:85:90:d9:49:34:
+-        8f:f2:5d:f9:7a:db:4d:5d:27:f6:76:9d:35:8c:06:a6:4c:a3:
+-        b1:b2:b6:6f:1d:d7:a3:00:fd:72:eb:9e:ea:44:a1:af:21:34:
+-        7d:c7:42:e2:49:91:19:8b:c0:ad:ba:82:80:a8:71:70:f4:35:
+-        31:91:63:84:20:95:e9:60:af:64:8b:cc:ff:3d:8a:76:74:3d:
+-        c8:55:6d:e4:8e:c3:2b:1c:e8:42:18:ae:9f:e6:6b:9c:34:06:
+-        ec:6a:f2:c3
+ -----BEGIN CERTIFICATE-----
+-MIIEEzCCAvugAwIBAgIBADANBgkqhkiG9w0BAQUFADCBnDELMAkGA1UEBhMCTk8x
+-DTALBgNVBAgTBE9zbG8xEDAOBgNVBAcTB055ZGFsZW4xFjAUBgNVBAoTDVRyb2xs
+-dGVjaCBBU0ExFDASBgNVBAsTC0RldmVsb3BtZW50MRcwFQYDVQQDEw5mbHVrZS50
+-cm9sbC5ubzElMCMGCSqGSIb3DQEJARYWYWhhbnNzZW5AdHJvbGx0ZWNoLmNvbTAe
+-Fw0wNzEyMDQwMTEwMzJaFw0zNTA0MjEwMTEwMzJaMGMxCzAJBgNVBAYTAk5PMQ0w
+-CwYDVQQIEwRPc2xvMRYwFAYDVQQKEw1Ucm9sbHRlY2ggQVNBMRQwEgYDVQQLEwtE
+-ZXZlbG9wbWVudDEXMBUGA1UEAxMOZmx1a2UudHJvbGwubm8wgZ8wDQYJKoZIhvcN
+-AQEBBQADgY0AMIGJAoGBAKfIoErEGQUbZroy4tLxHG8XguQ5LgFRkNsENDIRIcIN
+-b1nYU5BUP4OPqdOz1e4am4CuwyXJXqWvS2AFqqDRkQEfygSD41gcmTJFhHByWAOY
+-SmOLQfUISdKRAmBr5GT+3aCqdAjpNEyRXxI9N01ULK1/W5hgNgKMO/ZF8ydqm5Sd
+-AgMBAAGjggEaMIIBFjAJBgNVHRMEAjAAMCwGCWCGSAGG+EIBDQQfFh1PcGVuU1NM
+-IEdlbmVyYXRlZCBDZXJ0aWZpY2F0ZTAdBgNVHQ4EFgQUIYUEPSMBZuX3nxqEJIqv
+-Cnn05awwgbsGA1UdIwSBszCBsKGBoqSBnzCBnDELMAkGA1UEBhMCTk8xDTALBgNV
+-BAgTBE9zbG8xEDAOBgNVBAcTB055ZGFsZW4xFjAUBgNVBAoTDVRyb2xsdGVjaCBB
+-U0ExFDASBgNVBAsTC0RldmVsb3BtZW50MRcwFQYDVQQDEw5mbHVrZS50cm9sbC5u
+-bzElMCMGCSqGSIb3DQEJARYWYWhhbnNzZW5AdHJvbGx0ZWNoLmNvbYIJAI6otOiR
+-t1QuMA0GCSqGSIb3DQEBBQUAA4IBAQBtV1/RBUPwYgXsKnGl3BkI8sSmvbsl2cqJ
+-AQ7kzx/BjMgkGDVTWXvAQ7Qy5piypu8VBQtIX+GgDJepoXfYNRgwvKmP07dUx/Gp
+-nl3mGb/2PFsr2OQ+YhiIi9Mk4UCbDOYpFmKr6gUkcDaqVZPvAoEbIxCiBOtWlXX8
+-+JSxXULFPzZEhV06LpBGiqK5b4euDBVAGTGQ/Dslu67xZhMNhZDZSTSP8l35ettN
+-XSf2dp01jAamTKOxsrZvHdejAP1y657qRKGvITR9x0LiSZEZi8CtuoKAqHFw9DUx
+-kWOEIJXpYK9ki8z/PYp2dD3IVW3kjsMrHOhCGK6f5mucNAbsavLD
++MIIF6zCCA9OgAwIBAgIUfo9amJtJGWqWE6f+SkAO85zkGr4wDQYJKoZIhvcNAQEL
++BQAwgYMxCzAJBgNVBAYTAk5PMQ0wCwYDVQQIDARPc2xvMQ0wCwYDVQQHDARPc2xv
++MRcwFQYDVQQKDA5UaGUgUXQgQ29tcGFueTEMMAoGA1UECwwDUiZEMRIwEAYDVQQD
++DAlIMiBUZXN0ZXIxGzAZBgkqhkiG9w0BCQEWDG1pbmltaUBxdC5pbzAgFw0yMDEw
++MjYxMjAxMzFaGA8yMTIwMTAwMjEyMDEzMVowgYMxCzAJBgNVBAYTAk5PMQ0wCwYD
++VQQIDARPc2xvMQ0wCwYDVQQHDARPc2xvMRcwFQYDVQQKDA5UaGUgUXQgQ29tcGFu
++eTEMMAoGA1UECwwDUiZEMRIwEAYDVQQDDAlIMiBUZXN0ZXIxGzAZBgkqhkiG9w0B
++CQEWDG1pbmltaUBxdC5pbzCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIB
++AOiUp5+E4blouKH7q+rVNR8NoYX2XkBW+q+rpy1zu5ssRSzbqxAjDx9dkht7Qlnf
++VlDT00JvpOWdeuPon5915edQRsY4Unl6mKH29ra3OtUa1/yCJXsGVJTKCj7k4Bxb
++5mZzb/fTlZntMLdTIBMfUbw62FKir1WjKIcJ9fCoG8JaGeKVO4Rh5p0ezd4UUUId
++r1BXl5Nqdqy2vTMsEDnjOsD3egkv8I2SKN4O6n/C3wWYpMOWYZkGoZiKz7rJs/i/
++ez7bsV7JlwdzTlhpJzkcOSVFBP6JlEOxTNNxZ1wtKy7PtZGmsSSATq2e6+bw38Ae
++Op0XnzzqcGjtDDofBmT7OFzZWjS9VZS6+DOOe2QHWle1nCHcHyH4ku6IRlsr9xkR
++NAIlOfnvHHxqJUenoeaZ4oQDjCBKS1KXygJO/tL7BLTQVn/xK1EmPvKNnjzWk4tR
++PnibUhhs5635qpOU/YPqFBh1JjVruZbsWcDAhRcew0uxONXOa9E+4lttQ9ySYa1A
++LvWqJuAX7gu2BsBMLyqfm811YnA7CIFMyO+HlqmkLFfv5L/xIRAXR7l26YGO0VwX
++CGjMfz4NVPMMke4nB7qa9NkpXQBQKMms3Qzd5JW0Hy9Ruj5O8GPcFZmV0twjd1uJ
++PD/cAjkWLaXjdNsJ16QWc2nghQRS6HYqKRX6j+CXOxupAgMBAAGjUzBRMB0GA1Ud
++DgQWBBRSCOU58j9NJZkMamt623qyCrhN3TAfBgNVHSMEGDAWgBRSCOU58j9NJZkM
++amt623qyCrhN3TAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4ICAQCq
++q4jxsWeNDv5Nq14hJtF9HB+ZL64zcZtRjJP1YgNs0QppKICmjPOL2nIMGmI/jKrs
++0eGAL/9XXNVHPxm1OPOncvimMMmU6emZfpMdEtTfKP43+Pg9HgKRjLoQp406vGeQ
++8ki/mbBhrItVPgEm3tu2AFA02XTYi+YxCI9kRZLGkM3FbgtOuTLPl0Z9y+kiPc9F
++uCSC03anBEqv+vDSI8+wODymQ/IJ3Jyz1lxIRDfp4qAekmy0jU2c91VOHHEmOmqq
++kqygGFRdwbe99m9yP63r6q0b5K3X2UnJ6bns0hmTwThYwpVPXLU8jdaTddbMukN2
++/Ef96Tsw8nWOEOPMySHOTIPgwyZRp26b0kA9EmhLwOP401SxXVQCmSRmtwNagmtg
++jJKmZoYBN+//D45ibK8z6Q0oOm9P+Whf/uUXehcRxBxyV3xz7k0wKGQbHj/ddwcy
++IUoIN4lrAlib+lK170kTKN352PDmrpo2gmIzPEsfurKAIMSelDl6H+kih16BtZ8y
++Nz6fh9Soqrg3OSAware8pxV7k51crBMoPLN78KoRV8MFCK4K7Fddq4rRISq6hiXq
++r1nsjoEPuKM9huprmZVZe9t5YcDa2I+wb3IiE3uwpZbAdaLDyQ5n6F/qpsiIkZXn
++gtcF7oqpG5oYrwCcZ53y/ezUgUg7PlSz2XwAGvQtgg==
+ -----END CERTIFICATE-----
+diff --git a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
+index 9d1664d609..337ce541a6 100644
+--- a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
++++ b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
+@@ -1,15 +1,52 @@
+------BEGIN RSA PRIVATE KEY-----
+-MIICXAIBAAKBgQCnyKBKxBkFG2a6MuLS8RxvF4LkOS4BUZDbBDQyESHCDW9Z2FOQ
+-VD+Dj6nTs9XuGpuArsMlyV6lr0tgBaqg0ZEBH8oEg+NYHJkyRYRwclgDmEpji0H1
+-CEnSkQJga+Rk/t2gqnQI6TRMkV8SPTdNVCytf1uYYDYCjDv2RfMnapuUnQIDAQAB
+-AoGANFzLkanTeSGNFM0uttBipFT9F4a00dqHz6JnO7zXAT26I5r8sU1pqQBb6uLz
+-/+Qz5Zwk8RUAQcsMRgJetuPQUb0JZjF6Duv24hNazqXBCu7AZzUenjafwmKC/8ri
+-KpX3fTwqzfzi//FKGgbXQ80yykSSliDL3kn/drATxsLCgQECQQDXhEFWLJ0vVZ1s
+-1Ekf+3NITE+DR16X+LQ4W6vyEHAjTbaNWtcTKdAWLA2l6N4WAAPYSi6awm+zMxx4
+-VomVTsjdAkEAx0z+e7natLeFcrrq8pbU+wa6SAP1VfhQWKitxL1e7u/QO90NCpxE
+-oQYKzMkmmpOOFjQwEMAy1dvFMbm4LHlewQJAC/ksDBaUcQHHqjktCtrUb8rVjAyW
+-A8lscckeB2fEYyG5J6dJVaY4ClNOOs5yMDS2Afk1F6H/xKvtQ/5CzInA/QJATDub
+-K+BPU8jO9q+gpuIi3VIZdupssVGmCgObVCHLakG4uO04y9IyPhV9lA9tALtoIf4c
+-VIvv5fWGXBrZ48kZAQJBAJmVCdzQxd9LZI5vxijUCj5EI4e+x5DRqVUvyP8KCZrC
+-AiNyoDP85T+hBZaSXK3aYGpVwelyj3bvo1GrTNwNWLw=
+------END RSA PRIVATE KEY-----
++-----BEGIN PRIVATE KEY-----
++MIIJQgIBADANBgkqhkiG9w0BAQEFAASCCSwwggkoAgEAAoICAQDolKefhOG5aLih
+++6vq1TUfDaGF9l5AVvqvq6ctc7ubLEUs26sQIw8fXZIbe0JZ31ZQ09NCb6TlnXrj
++6J+fdeXnUEbGOFJ5epih9va2tzrVGtf8giV7BlSUygo+5OAcW+Zmc2/305WZ7TC3
++UyATH1G8OthSoq9VoyiHCfXwqBvCWhnilTuEYeadHs3eFFFCHa9QV5eTanastr0z
++LBA54zrA93oJL/CNkijeDup/wt8FmKTDlmGZBqGYis+6ybP4v3s+27FeyZcHc05Y
++aSc5HDklRQT+iZRDsUzTcWdcLSsuz7WRprEkgE6tnuvm8N/AHjqdF5886nBo7Qw6
++HwZk+zhc2Vo0vVWUuvgzjntkB1pXtZwh3B8h+JLuiEZbK/cZETQCJTn57xx8aiVH
++p6HmmeKEA4wgSktSl8oCTv7S+wS00FZ/8StRJj7yjZ481pOLUT54m1IYbOet+aqT
++lP2D6hQYdSY1a7mW7FnAwIUXHsNLsTjVzmvRPuJbbUPckmGtQC71qibgF+4LtgbA
++TC8qn5vNdWJwOwiBTMjvh5appCxX7+S/8SEQF0e5dumBjtFcFwhozH8+DVTzDJHu
++Jwe6mvTZKV0AUCjJrN0M3eSVtB8vUbo+TvBj3BWZldLcI3dbiTw/3AI5Fi2l43Tb
++CdekFnNp4IUEUuh2KikV+o/glzsbqQIDAQABAoICAFw1q6tr5I48vY7DF+rXsuLn
++5ZUWE1IQ6fzB4lr72nJv/9EEGnMgYzt9PpMUsD6vdCpBgS2C0+6RHArFzJtNA+RM
++iHLIG7K7702veyr/xBx/MwiSlMeMv/XpkFxVI6E6skMGG2s3AMXxKvJTy5CpRx+I
++eQFyLG+Ya1X2lgJes/q+/CpAHkOjCOpcLySQC5NZ74q734V7nSdmn+Zs3tYEh+O/
++eiuwTP/j5b38Te5vVTqDxTciJPmljmXLCwa0N100lWlbcpvw8qbqiTI2Jm3XCbUE
++AzHjW9vmrF3cRS1fXxKFGShw3SRqlkbxjfeWoi8qDPUBS4m8LOr8qG9Wo5Nfon0z
++zLP4bci3zHDvVcaaZrrsUBs/yZbg+Dgka1DmX7ekmeccr2yTdKDFgPupYUyxVbTl
++a9ZLJysjFD7rgBv1ZclHonLp6Vbm+ZoTqvteo4ikAy6L9RtBWJ23XEK34PkP/+c5
++2vWZaOrnjSeBHbFce8cdJSxqWpP+eSCI5I9XbDrYFIsQ/gqKgtzDKy2ihJ2Y8STL
++yO4hyFPFjxc+Gg4/P2PpmT5CY2ty44M0BWs+JGW96CJPrrplf2lmQUQJj5LZY66X
++Z/4C9L7ZYtKZ+bs5SvU46yWugAvQZX22Xm9xLXWyVXRdx3bj+3M3fDnF9di/zdbh
++CgLx7oWPNrXc7FCajnn9AoIBAQD5FMYwRpw9NWT9WDxQwx+cSI4Icbd88ByTW63S
++LzeRwZA0J9/SfwO+aBRupzc9GkGXCiZcGMw3AGsCtig8yFlw8E5KnzN7KlftDMnM
++9NUxxzlR8VwKyLnZfG7sDTl057ZlUujnqhmt/F8F7dIy7FVO1dE/8nngA+FYTCOG
++UZdGjwyBDlDM0JJdUWGY3xslutcpCDN5mzSTKjy9drMvImAshRawxRF6WBpn7vr2
++nC6vciqfx1Mzx1vyk0Jm0ilaydDdLMADjt/iL4Nkr0BEs4k+UzQiKDwp8gu7abQ1
++eBfxd9Iar4htQa2I1Ewl6P01G/q+ZYwgHhJ9RVn4AxQXefILAoIBAQDvCouORdQX
++C8wsyp7MwXlF/3NQeNN5/+B2mhbxrBOf7PmMCXLnkRWcjwJtzypWFqJ0sqai/2+0
++bqbMcjX5maT8stT2shl3zXe/Ejt2e3TBYpc1tyuses8Kb5BMU8hu6tTd3G2CMXpD
++dT6DVemJZCTtwj9aBNIxSizvlgMolJnCpzhPnlfHSI6E+g3m/LTTo3HwbjMSw/Uq
++irgjOpI2wSBB6LZPSgjvfcYPRyWUk16L4A5uSX0cADnovDFLa5/h0wJvN/OoCSQg
++rLCXG5E18EyL5Wc58BCY1ZvxmjG3lQtgPxYu2Jwc36R/y/JKlxW5suER5ZNpbbD4
++uOyTt2VxMQ2bAoIBAQC5+MzRFqdo/AjfL5Y5JrbfVTzXCTDa09xCGd16ZU60QTWN
+++4ed/r+o1sUKqUcRFB2MzEM/2DQBjQpZB/CbEWvWa1XJWXxypXbowveZU+QqOnmN
++uQvj8WLyA3o+PNF9e9QvauwCrHpn8VpxbtPWuaYoKnUFreFZZQxHhPGxRBIS2JOZ
++eDrT8ZaWnkCkh1AZp5smQ71LOprSlmKrg4jd1GjCVMxQR5N5KXbtyv0OTCZ/UFqK
++2aRBsMPyJgkaBChkZPLRcKwc+/wlQRx1fHQb14DNTApMxoXFO7eOwqmOkpAt9iyl
++SBIwoS0UUI5ab88+bBmXNvKcuFdNuQ4nowTJUn9pAoIBADMNkILBXSvS5DeIyuO2
++Sp1tkoZUV+5NfPY3sMDK3KIibaW/+t+EOBZo4L7tKQCb8vRzl21mmsfxfgRaPDbj
++3r3tv9g0b4YLxxBy52pFscj/soXRai17SS7UZwA2QK+XzgDYbDcLNC6mIsTQG4Gx
++dsWk3/zs3KuUSQaehmwrWK+fIUK38c1pLK8v7LoxrLkqxlHwZ04RthHw8KTthH7X
++Pnl1J0LF8CSeOyfWLSuPUfkT0GEzptnNHpEbaHfQM6R6eaGhVJPF6AZme4y6YYgg
++m2ihhSt1n0XVEWpHYWjxFy3mK2mz75unFC4LM+NEY2p2zuUQoCw7NjnY3QYrfCnx
++rRMCggEAXeXsMSLFjjyuoL7iKbAxo52HD/P0fBoy58LyRcwfNVr0lvYan4pYEx+o
++KijIh9K16PqXZXKMA9v003B+ulmF8bJ7SddCZ5NGvnFhUTDe4DdTKgp2RuwQ3Bsc
++3skPIDbhVETyOLCtys34USHrq8U/0DlGY3eLRfxw9GnbKxSBGa/KEu/qQLPNUo50
++7xHZDg7GKeC3kqNJeqKM9rkp0VzIGkEnaD9127LeNDmERDfftxJzFoC/THvUBLfU
++6Sus2ZYwRE8VFvKC30Q45t/c54X3IuhYvAuiCuTmyfE4ruyzyOwKzhUkeeLq1APX
++g0veFbyfzlJ0q8qzD/iffqqIa2ZSmQ==
++-----END PRIVATE KEY-----
+diff --git a/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp b/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
+index 7ba3715e13..752aa122f6 100644
+--- a/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
++++ b/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
+@@ -179,6 +179,7 @@ void tst_QAccessibilityLinux::initTestCase()
+     QVERIFY(!address.isEmpty());
+ 
+     m_window = new AccessibleTestWindow();
++    m_window->setObjectName("mainWindow"_L1);
+     m_window->show();
+ 
+     QVERIFY(QTest::qWaitForWindowExposed(m_window));
+@@ -236,8 +237,11 @@ bool hasState(QDBusInterface *interface, AtspiStateType state)
+ void tst_QAccessibilityLinux::testLabel()
+ {
+     QLabel *l = new QLabel(m_window);
++    l->setObjectName("theObjectName"_L1);
+     l->setText("Hello A11y");
+     m_window->addWidget(l);
++    auto a11yEmpty = new QLabel(m_window);
++    m_window->addWidget(l);
+ 
+     // Application
+     QCOMPARE(getParent(mainWindow), QLatin1String(ATSPI_DBUS_PATH_ROOT));
+@@ -249,6 +253,8 @@ void tst_QAccessibilityLinux::testLabel()
+     QCOMPARE(getChildren(labelInterface).count(), 0);
+     QCOMPARE(labelInterface->call(QDBus::Block, "GetRoleName").arguments().first().toString(), QLatin1String("label"));
+     QCOMPARE(labelInterface->call(QDBus::Block, "GetRole").arguments().first().toUInt(), 29u);
++    QCOMPARE(labelInterface->call(QDBus::Block, "GetAccessibleId").arguments().first().toString(),
++             QLatin1String("mainWindow.theObjectName"));
+     QCOMPARE(getParent(labelInterface), mainWindow->path());
+     QVERIFY(!hasState(labelInterface, ATSPI_STATE_EDITABLE));
+     QVERIFY(hasState(labelInterface, ATSPI_STATE_READ_ONLY));
+@@ -256,7 +262,12 @@ void tst_QAccessibilityLinux::testLabel()
+     l->setText("New text");
+     QCOMPARE(labelInterface->property("Name").toString(), l->text());
+ 
++    auto *a11yEmptyInterface = getInterface(children.at(1), "org.a11y.atspi.Accessible");
++    QCOMPARE(a11yEmptyInterface->call(QDBus::Block, "GetAccessibleId").arguments().first().toString(),
++             QLatin1String("mainWindow.QLabel"));
++
+     m_window->clearChildren();
++    delete a11yEmptyInterface;
+     delete labelInterface;
+ }
+ 
+diff --git a/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+index 76df61c892..6d6d65b791 100644
+--- a/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
++++ b/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2022 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the test suite of the Qt Toolkit.
+@@ -68,6 +68,8 @@ private slots:
+     void query_exec();
+     void execErrorRecovery_data() { generic_data(); }
+     void execErrorRecovery();
++    void prematureExec_data() { generic_data(); }
++    void prematureExec();
+     void first_data() { generic_data(); }
+     void first();
+     void next_data() { generic_data(); }
+@@ -2770,6 +2772,35 @@ void tst_QSqlQuery::execErrorRecovery()
+     QVERIFY_SQL( q, exec() );
+ }
+ 
++void tst_QSqlQuery::prematureExec()
++{
++    QFETCH(QString, dbName);
++    // We only want the engine name, for addDatabase():
++    int cut = dbName.indexOf(QChar('@'));
++    if (cut < 0)
++        QSKIP("Failed to parse database type out of name");
++    dbName.truncate(cut);
++    cut = dbName.indexOf(QChar('_'));
++    if (cut >= 0)
++        dbName = dbName.mid(cut + 1);
++
++    auto db = QSqlDatabase::addDatabase(dbName);
++    QSqlQuery q(db);
++
++    QTest::ignoreMessage(QtWarningMsg,
++                         "QSqlDatabasePrivate::removeDatabase: connection "
++                         "'qt_sql_default_connection' is still in use, all "
++                         "queries will cease to work.");
++    QTest::ignoreMessage(QtWarningMsg,
++                         "QSqlDatabasePrivate::addDatabase: duplicate connection name "
++                         "'qt_sql_default_connection', old connection removed.");
++    auto otherDb = QSqlDatabase::addDatabase(dbName);
++
++    QTest::ignoreMessage(QtWarningMsg, "QSqlQuery::exec: called before driver has been set up");
++    // QTBUG-100037: shouldn't crash !
++    QVERIFY(!q.exec("select stuff from TheVoid"));
++}
++
+ void tst_QSqlQuery::lastInsertId()
+ {
+     QFETCH( QString, dbName );
+diff --git a/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp b/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
+index 4aa3f8d60b..d2050a61aa 100644
+--- a/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
++++ b/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
+@@ -115,6 +115,10 @@ void tst_QAbstractItemModelTester::standardItemModelZeroColumns()
+     // QTBUG-92886
+     model.insertRows(0, 5);
+     model.removeRows(1, 2);
++
++    const QModelIndex parentIndex = model.index(0, 0);
++    model.insertRows(0, 5, parentIndex);
++    model.removeRows(1, 2, parentIndex);
+ }
+ 
+ void tst_QAbstractItemModelTester::testInsertThroughProxy()
+diff --git a/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json b/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
+index 12a4a22a19..ce518e78fb 100644
+--- a/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
++++ b/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
+@@ -668,50 +668,6 @@
+         "inputFile": "task192552.h",
+         "outputRevision": 67
+     },
+-    {
+-        "classes": [
+-            {
+-                "className": "InlineSlotsWithThrowDeclaration",
+-                "object": true,
+-                "qualifiedClassName": "InlineSlotsWithThrowDeclaration",
+-                "slots": [
+-                    {
+-                        "access": "public",
+-                        "name": "a",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "b",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "c",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "d",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "e",
+-                        "returnType": "void"
+-                    }
+-                ],
+-                "superClasses": [
+-                    {
+-                        "access": "public",
+-                        "name": "QObject"
+-                    }
+-                ]
+-            }
+-        ],
+-        "inputFile": "task189996.h",
+-        "outputRevision": 67
+-    },
+     {
+         "classes": [
+             {
+diff --git a/qtbase/tests/auto/tools/moc/moc.pro b/qtbase/tests/auto/tools/moc/moc.pro
+index c324b3a8cd..4aceb78dc0 100644
+--- a/qtbase/tests/auto/tools/moc/moc.pro
++++ b/qtbase/tests/auto/tools/moc/moc.pro
+@@ -15,7 +15,7 @@ cross_compile: DEFINES += MOC_CROSS_COMPILED
+ HEADERS += using-namespaces.h no-keywords.h task87883.h c-comments.h backslash-newlines.h oldstyle-casts.h \
+            slots-with-void-template.h qinvokable.h namespaced-flags.h trigraphs.h \
+            escapes-in-string-literals.h cstyle-enums.h qprivateslots.h gadgetwithnoenums.h \
+-           dir-in-include-path.h single_function_keyword.h task192552.h task189996.h \
++           dir-in-include-path.h single_function_keyword.h task192552.h \
+            task234909.h task240368.h pure-virtual-signals.h cxx11-enums.h \
+            cxx11-final-classes.h \
+            cxx11-explicit-override-control.h \
+diff --git a/qtbase/tests/auto/tools/moc/task189996.h b/qtbase/tests/auto/tools/moc/task189996.h
+deleted file mode 100644
+index f94a051b3a..0000000000
+--- a/qtbase/tests/auto/tools/moc/task189996.h
++++ /dev/null
+@@ -1,47 +0,0 @@
+-/****************************************************************************
+-**
+-** Copyright (C) 2016 The Qt Company Ltd.
+-** Contact: https://www.qt.io/licensing/
+-**
+-** This file is part of the test suite of the Qt Toolkit.
+-**
+-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+-** 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 General Public License Usage
+-** Alternatively, this file may be used under the terms of the GNU
+-** General Public License version 3 as published by the Free Software
+-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+-** 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-3.0.html.
+-**
+-** $QT_END_LICENSE$
+-**
+-****************************************************************************/
+-// inline functions can have throw declarations
+-
+-#ifndef TASK189996_H
+-#define TASK189996_H
+-
+-#include <QObject>
+-
+-class InlineSlotsWithThrowDeclaration : public QObject
+-{
+-    Q_OBJECT
+-
+-public slots:
+-    void a() throw() { }
+-    void b() const throw() { }
+-    void c() throw();
+-    void d() throw(int) { }
+-    void e() const throw(int,double) { }
+-};
+-
+-#endif
+diff --git a/qtbase/tests/auto/tools/moc/tst_moc.cpp b/qtbase/tests/auto/tools/moc/tst_moc.cpp
+index c716aead21..15dd9e41e5 100644
+--- a/qtbase/tests/auto/tools/moc/tst_moc.cpp
++++ b/qtbase/tests/auto/tools/moc/tst_moc.cpp
+@@ -631,7 +631,6 @@ public:
+ private slots:
+     void initTestCase();
+ 
+-    void slotWithException() throw(MyStruct);
+     void dontStripNamespaces();
+     void oldStyleCasts();
+     void warnOnExtraSignalSlotQualifiaction();
+@@ -673,7 +672,6 @@ private slots:
+     void templateGtGt();
+     void qprivateslots();
+     void qprivateproperties();
+-    void inlineSlotsWithThrowDeclaration();
+     void warnOnPropertyWithoutREAD();
+     void constructors();
+     void typenameWithUnsigned();
+@@ -784,12 +782,6 @@ void tst_Moc::initTestCase()
+ #endif
+ }
+ 
+-void tst_Moc::slotWithException() throw(MyStruct)
+-{
+-    // be happy
+-    QVERIFY(true);
+-}
+-
+ void tst_Moc::dontStripNamespaces()
+ {
+     Sender sender;
+@@ -824,7 +816,7 @@ void tst_Moc::oldStyleCasts()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-Wold-style-cast" << "-I" << "."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -894,7 +886,7 @@ void tst_Moc::inputFileNameWithDotsButNoExtension()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-I" << ".."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -1174,7 +1166,7 @@ void tst_Moc::ignoreOptionClashes()
+     QStringList gccArgs;
+     gccArgs << "-c" << "-x" << "c++" << "-I" << ".."
+          << "-I" << qtIncludePath << "-I" << includeDir << "-o" << "/dev/null"
+-         << "-fPIC" << "-std=c++11" <<  "-";
++         << "-fPIC" << "-std=c++1z" <<  "-";
+     proc.start("gcc", gccArgs);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -1593,21 +1585,6 @@ void tst_Moc::qprivateproperties()
+ 
+ }
+ 
+-#include "task189996.h"
+-
+-void InlineSlotsWithThrowDeclaration::c() throw() {}
+-
+-void tst_Moc::inlineSlotsWithThrowDeclaration()
+-{
+-    InlineSlotsWithThrowDeclaration tst;
+-    const QMetaObject *mobj = tst.metaObject();
+-    QVERIFY(mobj->indexOfSlot("a()") != -1);
+-    QVERIFY(mobj->indexOfSlot("b()") != -1);
+-    QVERIFY(mobj->indexOfSlot("c()") != -1);
+-    QVERIFY(mobj->indexOfSlot("d()") != -1);
+-    QVERIFY(mobj->indexOfSlot("e()") != -1);
+-}
+-
+ void tst_Moc::warnOnPropertyWithoutREAD()
+ {
+ #ifdef MOC_CROSS_COMPILED
+@@ -1869,7 +1846,7 @@ void tst_Moc::notifyError()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-I" << "."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+diff --git a/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+index c355ee9665..88c09de8e0 100644
+--- a/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
++++ b/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+@@ -251,6 +251,7 @@ private slots:
+     void testResetCachedSizeHint();
+     void statusTips();
+     void testRemovingColumnsViaLayoutChanged();
++    void testModelMovingColumns();
+ 
+ protected:
+     void setupTestData(bool use_reset_model = false);
+@@ -360,6 +361,12 @@ public:
+         endRemoveColumns();
+     }
+ 
++    void moveColumn(int from, int to)
++    {
++        beginMoveColumns(QModelIndex(), from, from, QModelIndex(), to);
++        endMoveColumns();
++    }
++
+     void cleanup()
+     {
+         emit layoutAboutToBeChanged();
+@@ -3627,5 +3634,18 @@ void tst_QHeaderView::testRemovingColumnsViaLayoutChanged()
+     // The main point of this test is that the section-size restoring code didn't go out of bounds.
+ }
+ 
++void tst_QHeaderView::testModelMovingColumns()
++{
++    QtTestModel model(10, 10);
++    QHeaderView hv(Qt::Horizontal);
++    hv.setModel(&model);
++    hv.resizeSections(QHeaderView::ResizeToContents);
++    hv.show();
++
++    QPersistentModelIndex index3 = model.index(0, 3);
++    model.moveColumn(3, 1);
++    QCOMPARE(index3.column(), 1);
++}
++
+ QTEST_MAIN(tst_QHeaderView)
+ #include "tst_qheaderview.moc"
+diff --git a/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+index 761357b252..06bb706074 100644
+--- a/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
++++ b/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+@@ -397,6 +397,7 @@ private slots:
+     void checkHeaderMinSize();
+ 
+     void resizeToContents();
++    void resizeToContentsSpans();
+ 
+     void tabFocus();
+     void bigModel();
+@@ -3721,6 +3722,70 @@ void tst_QTableView::resizeToContents()
+ 
+ }
+ 
++
++class SpanModel : public QAbstractTableModel
++{
++public:
++    SpanModel(bool sectionsMoved)
++        : _sectionsMoved(sectionsMoved)
++    {}
++    int columnCount(const QModelIndex & = {}) const override { return 2; }
++    int rowCount(const QModelIndex & = {}) const override { return 1; }
++    QVariant data(const QModelIndex &idx, int role = Qt::DisplayRole) const override
++    {
++        if (role != Qt::DisplayRole)
++            return QVariant();
++        const int col = _sectionsMoved ? 1 - idx.column() : idx.column();
++        if (col == 0)
++            return "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.";
++        return QVariant();
++    }
++private:
++    bool _sectionsMoved;
++};
++
++
++void tst_QTableView::resizeToContentsSpans()
++{
++    SpanModel model1(false);
++    SpanModel model2(true);
++    QTableView view1, view2, view3;
++    view1.setModel(&model1);
++    view2.setModel(&model2);
++    view2.horizontalHeader()->moveSection(0, 1);
++    view3.setModel(&model1);
++
++    view1.setSpan(0, 0, 1, 2);
++    view2.setSpan(0, 1, 1, 2);
++    view1.show();
++    view2.show();
++    view3.show();
++    QVERIFY(QTest::qWaitForWindowExposed(&view1));
++    QVERIFY(QTest::qWaitForWindowExposed(&view2));
++    QVERIFY(QTest::qWaitForWindowExposed(&view3));
++    view1.setColumnWidth(0, 100);
++    view1.setColumnWidth(1, 100);
++    view2.setColumnWidth(0, 100);
++    view2.setColumnWidth(1, 100);
++    view3.setColumnWidth(0, 200);
++
++    view1.resizeRowToContents(0);
++    view2.resizeRowToContents(0);
++    view3.resizeRowToContents(0);
++    QCOMPARE(view1.rowHeight(0), view3.rowHeight(0));
++    QCOMPARE(view2.rowHeight(0), view3.rowHeight(0));
++
++    view3.resizeColumnToContents(0);
++    view3.resizeRowToContents(0);
++    // height should be only 1 text line for easy testing
++    view1.setRowHeight(0, view3.verticalHeader()->sectionSize(0));
++    view2.setRowHeight(0, view3.verticalHeader()->sectionSize(0));
++    view1.resizeColumnToContents(0);
++    view2.resizeColumnToContents(1);
++    QCOMPARE(view1.columnWidth(0), view3.columnWidth(0) - view1.columnWidth(1));
++    QCOMPARE(view2.columnWidth(0), view3.columnWidth(0) - view2.columnWidth(1));
++}
++
+ QT_BEGIN_NAMESPACE
+ extern bool Q_WIDGETS_EXPORT qt_tab_all_widgets(); // qapplication.cpp
+ QT_END_NAMESPACE
+diff --git a/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+index a3b8ef78d8..4955cebd5d 100644
+--- a/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
++++ b/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+@@ -1498,7 +1498,7 @@ void tst_QApplication::desktopSettingsAware()
+     environment += QLatin1String("QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM=1");
+     testProcess.setEnvironment(environment);
+ #endif
+-    testProcess.start("desktopsettingsaware_helper");
++    testProcess.start("./desktopsettingsaware_helper");
+     QVERIFY2(testProcess.waitForStarted(),
+              qPrintable(QString::fromLatin1("Cannot start 'desktopsettingsaware_helper': %1").arg(testProcess.errorString())));
+     QVERIFY(testProcess.waitForFinished(10000));
+@@ -2452,7 +2452,7 @@ void tst_QApplication::qtbug_12673()
+ #if QT_CONFIG(process)
+     QProcess testProcess;
+     QStringList arguments;
+-    testProcess.start("modal_helper", arguments);
++    testProcess.start("./modal_helper", arguments);
+     QVERIFY2(testProcess.waitForStarted(),
+              qPrintable(QString::fromLatin1("Cannot start 'modal_helper': %1").arg(testProcess.errorString())));
+     QVERIFY(testProcess.waitForFinished(20000));
+diff --git a/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp b/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
+index eb108a40de..dca5528c1b 100644
+--- a/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
+@@ -41,6 +41,7 @@
+ 
+ #include <private/qguiapplication_p.h>
+ #include <qpa/qplatformintegration.h>
++#include <qpa/qplatformtheme.h>
+ 
+ class tst_QAbstractButton : public QObject
+ {
+@@ -76,6 +77,8 @@ private slots:
+     void keyNavigation();
+ #endif
+ 
++    void buttonPressKeys();
++
+ protected slots:
+     void onClicked();
+     void onToggled( bool on );
+@@ -269,7 +272,13 @@ void tst_QAbstractButton::setAutoRepeat()
+         QCOMPARE(press_count, click_count);
+         QVERIFY(click_count > 1);
+         break;
+-    case 4:
++    case 4: {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(Qt::Key_Enter)) {
++            QSKIP("platform theme has Key_Enter in ButtonPressKeys");
++        }
+         // check that pressing ENTER has no effect when autorepeat is false
+         testWidget->setDown( false );
+         testWidget->setAutoRepeat( false );
+@@ -286,7 +295,14 @@ void tst_QAbstractButton::setAutoRepeat()
+ 
+         QVERIFY( click_count == 0 );
+         break;
+-    case 5:
++    }
++    case 5: {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(Qt::Key_Enter)) {
++            QSKIP("platform theme has Key_Enter in ButtonPressKeys");
++        }
+         // check that pressing ENTER has no effect when autorepeat is true
+         testWidget->setDown( false );
+         testWidget->setAutoRepeat( true );
+@@ -304,6 +320,7 @@ void tst_QAbstractButton::setAutoRepeat()
+ 
+         QVERIFY( click_count == 0 );
+         break;
++    }
+     case 6:
+         // verify autorepeat is off by default.
+         MyButton tmp( 0);
+@@ -651,5 +668,16 @@ void tst_QAbstractButton::keyNavigation()
+ }
+ #endif
+ 
++void tst_QAbstractButton::buttonPressKeys()
++{
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(testWidget, buttonPressKeys[i]);
++        QCOMPARE(click_count, i + 1);
++    }
++}
++
+ QTEST_MAIN(tst_QAbstractButton)
+ #include "tst_qabstractbutton.moc"
+diff --git a/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+index 32437050f5..46b5af6d63 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+@@ -168,6 +168,7 @@ private slots:
+     void checkMenuItemPosWhenStyleSheetIsSet();
+     void checkEmbeddedLineEditWhenStyleSheetIsSet();
+     void propagateStyleChanges();
++    void buttonPressKeys();
+ 
+ private:
+     PlatformInputContext m_platformInputContext;
+@@ -1682,6 +1683,16 @@ void tst_QComboBox::setModel()
+     QCOMPARE(box.rootModelIndex(), rootModelIndex);
+     box.setModel(box.model());
+     QCOMPARE(box.rootModelIndex(), rootModelIndex);
++
++    // check that setting the same model as the completer's doesn't crash
++    QCompleter *completer = new QCompleter(&box);
++    box.setEditable(true);
++    box.setCompleter(completer);
++    auto *listModel = new QStringListModel({ "one", "two" }, completer);
++    completer->setModel(listModel);
++    QCOMPARE(listModel->rowCount(), 2); // make sure it wasn't deleted
++    box.setModel(listModel);
++    QCOMPARE(listModel->rowCount(), 2); // make sure it wasn't deleted
+ }
+ 
+ void tst_QComboBox::setCustomModelAndView()
+@@ -3632,5 +3643,24 @@ void tst_QComboBox::propagateStyleChanges()
+     QVERIFY(frameStyle.inquired);
+ }
+ 
++void tst_QComboBox::buttonPressKeys()
++{
++    QComboBox comboBox;
++    comboBox.setEditable(false);
++    comboBox.addItem(QString::number(1));
++    comboBox.addItem(QString::number(2));
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(&comboBox, buttonPressKeys[i]);
++        // On some platforms, a window will not be immediately visible,
++        // but take some event-loop iterations to complete.
++        // Using QTRY_VERIFY to deal with that.
++        QTRY_VERIFY(comboBox.view()->isVisible());
++        comboBox.hidePopup();
++    }
++}
++
+ QTEST_MAIN(tst_QComboBox)
+ #include "tst_qcombobox.moc"
+diff --git a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
+index be3cfcd104..c228fdfcca 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
++++ b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qcommandlinkbutton
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qcommandlinkbutton.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
+index 0044d33c66..4cf06296e4 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
+@@ -40,6 +40,9 @@
+ #include <QGridLayout>
+ #include <QPainter>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ class tst_QCommandLinkButton : public QObject
+ {
+     Q_OBJECT
+@@ -223,6 +226,13 @@ void tst_QCommandLinkButton::setAutoRepeat()
+     // check that pressing ENTER has no effect
+     resetCounters();
+     testWidget->setDown( false );
++    // Skip after reset if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
+     testWidget->setAutoRepeat( false );
+     QTest::keyPress( testWidget, Qt::Key_Enter );
+ 
+@@ -255,6 +265,14 @@ void tst_QCommandLinkButton::pressed()
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+ 
++    // Skip if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
++
+     QTest::keyPress( testWidget,Qt::Key_Enter );
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+diff --git a/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro b/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
+index 4a5e76ff65..a235fa1fac 100644
+--- a/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
++++ b/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qgroupbox
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qgroupbox.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp b/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
+index 4fb5d262ca..d8d7562b73 100644
+--- a/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
+@@ -35,6 +35,9 @@
+ #include <QRadioButton>
+ #include <QDialog>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ #include "qgroupbox.h"
+ 
+ class tst_QGroupBox : public QObject
+@@ -69,6 +72,7 @@ private slots:
+     void propagateFocus();
+     void task_QTBUG_19170_ignoreMouseReleaseEvent();
+     void task_QTBUG_15519_propagateMouseEvents();
++    void buttonPressKeys();
+ 
+ private:
+     bool checked;
+@@ -610,6 +614,20 @@ void tst_QGroupBox::task_QTBUG_15519_propagateMouseEvents()
+     QCOMPARE(parent.mouseMoved, true);
+ }
+ 
++void tst_QGroupBox::buttonPressKeys()
++{
++    QGroupBox groupBox;
++    groupBox.setCheckable(true);
++    QSignalSpy clickedSpy(&groupBox, &QGroupBox::clicked);
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(&groupBox, buttonPressKeys[i]);
++        QCOMPARE(clickedSpy.length(), i + 1);
++    }
++}
++
+ void tst_QGroupBox::sendMouseMoveEvent(QWidget *widget, const QPoint &localPos)
+ {
+     // Send a MouseMove event without actually moving the pointer
+diff --git a/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro b/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
+index 353ad06ca2..e55f6148f2 100644
+--- a/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
++++ b/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qpushbutton
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qpushbutton.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp b/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
+index e818514a79..4043e9326a 100644
+--- a/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
+@@ -41,6 +41,9 @@
+ #include <QStyleFactory>
+ #include <QTabWidget>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ class tst_QPushButton : public QObject
+ {
+ Q_OBJECT
+@@ -212,6 +215,13 @@ void tst_QPushButton::autoRepeat()
+     // check that pressing ENTER has no effect
+     resetCounters();
+     testWidget->setDown( false );
++    // Skip after reset if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
+     testWidget->setAutoRepeat( false );
+     QTest::keyPress( testWidget, Qt::Key_Enter );
+ 
+@@ -247,6 +257,14 @@ void tst_QPushButton::pressed()
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+ 
++    // Skip if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
++
+     QTest::keyPress( testWidget,Qt::Key_Enter );
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+diff --git a/qtbase/tests/manual/rhi/cubemap_render/buildshader.bat b/qtbase/tests/manual/rhi/cubemap_render/buildshader.bat
+old mode 100755
+new mode 100644
+Submodule qtconnectivity e957d481..056294c0:
+diff --git a/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp b/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
+index e2635fae..a8b8e3b9 100644
+--- a/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
++++ b/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
+@@ -563,9 +563,11 @@ void HciManager::handleHciAclPacket(const quint8 *data, int size)
+ 
+ void HciManager::handleLeMetaEvent(const quint8 *data)
+ {
+-    // Spec v4.2, Vol 2, part E, 7.7.65ff
++    // Spec v5.3, Vol 4, part E, 7.7.65.*
+     switch (*data) {
+-    case 0x1: {
++    case 0x1: // HCI_LE_Connection_Complete
++    case 0xA: // HCI_LE_Enhanced_Connection_Complete
++    {
+         const quint16 handle = bt_get_le16(data + 2);
+         emit connectionComplete(handle);
+         break;
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp b/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
+index 6a93143b..4a18cfc7 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
+@@ -320,7 +320,10 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_finishSdpScan(QBluetoothServiceD
+             for (const QBluetoothUuid &id : serviceClassUuids) {
+                 if (id.minimumSize() == 16) {
+                     serviceInfo.setServiceUuid(id);
+-                    serviceInfo.setServiceName(QBluetoothServiceDiscoveryAgent::tr("Custom Service"));
++                    if (serviceInfo.serviceName().isEmpty()) {
++                        serviceInfo.setServiceName(
++                                    QBluetoothServiceDiscoveryAgent::tr("Custom Service"));
++                    }
+                     QBluetoothServiceInfo::Sequence modSeq =
+                             serviceInfo.attribute(QBluetoothServiceInfo::ServiceClassIds).value<QBluetoothServiceInfo::Sequence>();
+                     modSeq.removeOne(QVariant::fromValue(id));
+@@ -334,8 +337,10 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_finishSdpScan(QBluetoothServiceD
+                 qCDebug(QT_BT_BLUEZ) << "Discovered services" << discoveredDevices.at(0).address().toString()
+                                      << serviceInfo.serviceName() << serviceInfo.serviceUuid()
+                                      << ">>>" << serviceInfo.serviceClassUuids();
+-
+-                emit q->serviceDiscovered(serviceInfo);
++                // Use queued connection to allow us finish the service looping; the application
++                // might call stop() when it has detected the service-of-interest.
++                QMetaObject::invokeMethod(q, "serviceDiscovered", Qt::QueuedConnection,
++                                          Q_ARG(QBluetoothServiceInfo, serviceInfo));
+             }
+         }
+     }
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp b/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
+index e4d85447..aadd4755 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
+@@ -593,7 +593,7 @@ void QBluetoothSocket::setSocketState(QBluetoothSocket::SocketState state)
+ bool QBluetoothSocket::canReadLine() const
+ {
+     Q_D(const QBluetoothSocketBase);
+-    return d->canReadLine();
++    return d->canReadLine() || QIODevice::canReadLine();
+ }
+ 
+ /*!
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp b/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
+index 084aa958..d6aa17a7 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
+@@ -284,6 +284,10 @@ void QBluetoothSocketPrivateBluezDBus::connectToService(
+         return;
+     }
+ 
++    if (service.socketProtocol() != QBluetoothServiceInfo::Protocol::UnknownProtocol)
++        socketType = service.socketProtocol();
++    qCDebug(QT_BT_BLUEZ) << "Socket protocol used:" << socketType;
++
+     connectToService(service.device().address(), targetService, openMode);
+ }
+ 
+diff --git a/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp b/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
+index 05bc1a0f..a7b5ef1f 100644
+--- a/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
++++ b/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
+@@ -142,7 +142,7 @@ void tst_QBluetoothSocket::initTestCase()
+     qDebug() << "Starting discovery";
+ 
+     sda->setUuidFilter(QBluetoothUuid(QString(TEST_SERVICE_UUID)));
+-    sda->start(QBluetoothServiceDiscoveryAgent::MinimalDiscovery);
++    sda->start(QBluetoothServiceDiscoveryAgent::FullDiscovery);
+ 
+     for (int connectTime = MaxConnectTime; !done_discovery && connectTime > 0; connectTime -= 1000)
+         QTest::qWait(1000);
+Submodule qtdeclarative f5701f0d..8defe7bf:
+diff --git a/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h b/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
+index b65b994d6c..15a8cd6878 100644
+--- a/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
++++ b/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
+@@ -86,7 +86,7 @@ public:
+         if (QTypeInfo<T>::isComplex) {
+             for (int i = 0; i < count; ++i)
+                 new (data + i) T(vector.at(i));
+-        } else {
++        } else if (count) {
+             memcpy(data, static_cast<const void*>(vector.constData()), count * sizeof(T));
+         }
+     }
+diff --git a/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp b/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
+index e57cdd8278..94613598af 100644
+--- a/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
++++ b/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
+@@ -1145,8 +1145,7 @@ void Heap::QObjectWrapper::markObjects(Heap::Base *that, QV4::MarkStack *markSta
+ void QObjectWrapper::destroyObject(bool lastCall)
+ {
+     Heap::QObjectWrapper *h = d();
+-    if (!h->internalClass)
+-        return; // destroyObject already got called
++    Q_ASSERT(h->internalClass);
+ 
+     if (h->object()) {
+         QQmlData *ddata = QQmlData::get(h->object(), false);
+@@ -1176,7 +1175,7 @@ void QObjectWrapper::destroyObject(bool lastCall)
+         }
+     }
+ 
+-    h->~Data();
++    h->destroy();
+ }
+ 
+ 
+diff --git a/qtdeclarative/src/qml/memory/qv4mm.cpp b/qtdeclarative/src/qml/memory/qv4mm.cpp
+index 06caf04e5a..da149a67c4 100644
+--- a/qtdeclarative/src/qml/memory/qv4mm.cpp
++++ b/qtdeclarative/src/qml/memory/qv4mm.cpp
+@@ -981,7 +981,7 @@ void MemoryManager::sweep(bool lastSweep, ClassDestroyStatsCallback classCountPt
+ 
+     if (MultiplyWrappedQObjectMap *multiplyWrappedQObjects = engine->m_multiplyWrappedQObjects) {
+         for (MultiplyWrappedQObjectMap::Iterator it = multiplyWrappedQObjects->begin(); it != multiplyWrappedQObjects->end();) {
+-            if (!it.value().isNullOrUndefined())
++            if (it.value().isNullOrUndefined())
+                 it = multiplyWrappedQObjects->erase(it);
+             else
+                 ++it;
+diff --git a/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp b/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
+index 2079a8ed04..a577cb2351 100644
+--- a/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
++++ b/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
+@@ -389,6 +389,12 @@ void QQmlDelegateModelPrivate::connectToAbstractItemModel()
+                       q,  QQmlDelegateModel, SLOT(_q_rowsRemoved(QModelIndex,int,int)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
+                       q,  QQmlDelegateModel, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsInserted(QModelIndex,int,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsInserted(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsRemoved(QModelIndex,int,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsRemoved(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsMoved(QModelIndex,int,int,QModelIndex,int)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
+                       q, QQmlDelegateModel, SLOT(_q_dataChanged(QModelIndex,QModelIndex,QVector<int>)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
+@@ -413,6 +419,12 @@ void QQmlDelegateModelPrivate::disconnectFromAbstractItemModel()
+                         q, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int)));
+     QObject::disconnect(aim, SIGNAL(rowsRemoved(QModelIndex,int,int)),
+                         q, SLOT(_q_rowsRemoved(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsInserted(QModelIndex,int,int)), q,
++                        SLOT(_q_columnsInserted(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsRemoved(QModelIndex,int,int)), q,
++                        SLOT(_q_columnsRemoved(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)), q,
++                        SLOT(_q_columnsMoved(QModelIndex,int,int,QModelIndex,int)));
+     QObject::disconnect(aim, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
+                         q, SLOT(_q_dataChanged(QModelIndex,QModelIndex,QVector<int>)));
+     QObject::disconnect(aim, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
+@@ -1973,6 +1985,38 @@ void QQmlDelegateModel::_q_rowsMoved(
+     }
+ }
+ 
++void QQmlDelegateModel::_q_columnsInserted(const QModelIndex &parent, int begin, int end)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if (parent == d->m_adaptorModel.rootIndex && begin == 0) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
++void QQmlDelegateModel::_q_columnsRemoved(const QModelIndex &parent, int begin, int end)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if (parent == d->m_adaptorModel.rootIndex && begin == 0) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
++void QQmlDelegateModel::_q_columnsMoved(const QModelIndex &parent, int start, int end,
++                                        const QModelIndex &destination, int column)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if ((parent == d->m_adaptorModel.rootIndex && start == 0)
++        || (destination == d->m_adaptorModel.rootIndex && column == 0)) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
+ void QQmlDelegateModel::_q_dataChanged(const QModelIndex &begin, const QModelIndex &end, const QVector<int> &roles)
+ {
+     Q_D(QQmlDelegateModel);
+diff --git a/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h b/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
+index 8aab4badca..d140bfbaaf 100644
+--- a/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
++++ b/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
+@@ -152,6 +152,9 @@ private Q_SLOTS:
+     void _q_itemsMoved(int from, int to, int count);
+     void _q_modelReset();
+     void _q_rowsInserted(const QModelIndex &,int,int);
++    void _q_columnsInserted(const QModelIndex &, int, int);
++    void _q_columnsRemoved(const QModelIndex &, int, int);
++    void _q_columnsMoved(const QModelIndex &, int, int, const QModelIndex &, int);
+     void _q_rowsAboutToBeRemoved(const QModelIndex &parent, int begin, int end);
+     void _q_rowsRemoved(const QModelIndex &,int,int);
+     void _q_rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int);
+diff --git a/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp b/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
+index 85719fdc80..78e2ab302c 100644
+--- a/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
++++ b/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
+@@ -46,6 +46,7 @@
+ #include "QtQuick/private/qquicktextinput_p.h"
+ #include "QtQuick/private/qquickaccessibleattached_p.h"
+ #include "QtQuick/qquicktextdocument.h"
++#include "QtQuick/qquickrendercontrol.h"
+ QT_BEGIN_NAMESPACE
+ 
+ #if QT_CONFIG(accessibility)
+@@ -57,7 +58,19 @@ QAccessibleQuickItem::QAccessibleQuickItem(QQuickItem *item)
+ 
+ QWindow *QAccessibleQuickItem::window() const
+ {
+-    return item()->window();
++    QQuickWindow *window = item()->window();
++
++    // For QQuickWidget the above window will be the offscreen QQuickWindow,
++    // which is not a part of the accessibility tree. Detect this case and
++    // return the window for the QQuickWidget instead.
++    if (window && !window->handle()) {
++        if (QQuickRenderControl *renderControl = QQuickWindowPrivate::get(window)->renderControl) {
++            if (QWindow *renderWindow = renderControl->renderWindow(nullptr))
++                return renderWindow;
++        }
++    }
++
++    return window;
+ }
+ 
+ int QAccessibleQuickItem::childCount() const
+@@ -113,19 +126,15 @@ QAccessibleInterface *QAccessibleQuickItem::childAt(int x, int y) const
+ QAccessibleInterface *QAccessibleQuickItem::parent() const
+ {
+     QQuickItem *parent = item()->parentItem();
+-    QQuickWindow *window = item()->window();
+-    QQuickItem *ci = window ? window->contentItem() : nullptr;
++    QQuickWindow *itemWindow = item()->window();
++    QQuickItem *ci = itemWindow ? itemWindow->contentItem() : nullptr;
+     while (parent && !QQuickItemPrivate::get(parent)->isAccessible && parent != ci)
+         parent = parent->parentItem();
+ 
+     if (parent) {
+         if (parent == ci) {
+-            // Jump out to the scene widget if the parent is the root item.
+-            // There are two root items, QQuickWindow::rootItem and
+-            // QQuickView::declarativeRoot. The former is the true root item,
+-            // but is not a part of the accessibility tree. Check if we hit
+-            // it here and return an interface for the scene instead.
+-            return QAccessible::queryAccessibleInterface(window);
++            // Jump out to the window if the parent is the root item
++            return QAccessible::queryAccessibleInterface(window());
+         } else {
+             while (parent && !parent->d_func()->isAccessible)
+                 parent = parent->parentItem();
+@@ -188,7 +197,7 @@ QAccessible::State QAccessibleQuickItem::state() const
+     QRect viewRect_ = viewRect();
+     QRect itemRect = rect();
+ 
+-    if (viewRect_.isNull() || itemRect.isNull() || !item()->window() || !item()->window()->isVisible() ||!item()->isVisible() || qFuzzyIsNull(item()->opacity()))
++    if (viewRect_.isNull() || itemRect.isNull() || !window() || !window()->isVisible() ||!item()->isVisible() || qFuzzyIsNull(item()->opacity()))
+         state.invisible = true;
+     if (!viewRect_.intersects(itemRect))
+         state.offscreen = true;
+@@ -201,6 +210,10 @@ QAccessible::State QAccessibleQuickItem::state() const
+     if (role() == QAccessible::EditableText)
+         if (auto ti = qobject_cast<QQuickTextInput *>(item()))
+             state.passwordEdit = ti->echoMode() != QQuickTextInput::Normal;
++    if (!item()->isEnabled()) {
++        state.focusable = false;
++        state.disabled = true;
++    }
+     return state;
+ }
+ 
+diff --git a/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h b/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
+index 39ffcaf39c..8baa01330c 100644
+--- a/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
++++ b/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
+@@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE
+ 
+ #if QT_CONFIG(accessibility)
+ 
+-class QAccessibleQuickWindow : public QAccessibleObject
++class Q_QUICK_EXPORT QAccessibleQuickWindow : public QAccessibleObject
+ {
+ public:
+     QAccessibleQuickWindow(QQuickWindow *object);
+diff --git a/qtdeclarative/src/quick/items/qquickdrag.cpp b/qtdeclarative/src/quick/items/qquickdrag.cpp
+index 8321fcfeed..383078b3b9 100644
+--- a/qtdeclarative/src/quick/items/qquickdrag.cpp
++++ b/qtdeclarative/src/quick/items/qquickdrag.cpp
+@@ -481,7 +481,9 @@ void QQuickDragAttached::setKeys(const QStringList &keys)
+     \qmlattachedproperty stringlist QtQuick::Drag::mimeData
+     \since 5.2
+ 
+-    This property holds a map of mimeData that is used during startDrag.
++    This property holds a map from mime type to data that is used during startDrag.
++    The mime data needs to be a \c string, or an \c ArrayBuffer with the data encoded
++    according to the mime type.
+ */
+ 
+ QVariantMap QQuickDragAttached::mimeData() const
+@@ -766,8 +768,12 @@ Qt::DropAction QQuickDragAttachedPrivate::startDrag(Qt::DropActions supportedAct
+     QDrag *drag = new QDrag(source ? source : q);
+     QMimeData *mimeData = new QMimeData();
+ 
+-    for (auto it = externalMimeData.cbegin(), end = externalMimeData.cend(); it != end; ++it)
+-        mimeData->setData(it.key(), it.value().toString().toUtf8());
++    for (auto it = externalMimeData.cbegin(), end = externalMimeData.cend(); it != end; ++it) {
++        if (static_cast<QMetaType::Type>(it.value().type()) == QMetaType::QByteArray)
++            mimeData->setData(it.key(), it.value().toByteArray());
++        else
++            mimeData->setData(it.key(), it.value().toString().toUtf8());
++    }
+ 
+     drag->setMimeData(mimeData);
+     if (pixmapLoader.isReady()) {
+diff --git a/qtdeclarative/src/quick/items/qquickitem.cpp b/qtdeclarative/src/quick/items/qquickitem.cpp
+index 75f1457816..dec0ae19ae 100644
+--- a/qtdeclarative/src/quick/items/qquickitem.cpp
++++ b/qtdeclarative/src/quick/items/qquickitem.cpp
+@@ -59,6 +59,7 @@
+ #include <QtCore/private/qnumeric_p.h>
+ #include <QtGui/qpa/qplatformtheme.h>
+ #include <QtCore/qloggingcategory.h>
++#include <QtCore/private/qduplicatetracker_p.h>
+ 
+ #include <private/qqmlglobal_p.h>
+ #include <private/qqmlengine_p.h>
+@@ -2326,6 +2327,7 @@ QQuickItem::QQuickItem(QQuickItemPrivate &dd, QQuickItem *parent)
+ QQuickItem::~QQuickItem()
+ {
+     Q_D(QQuickItem);
++    d->inDestructor = true;
+ 
+     if (d->windowRefCount > 1)
+         d->windowRefCount = 1; // Make sure window is set to null in next call to derefWindow().
+@@ -2526,6 +2528,7 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo
+     QQuickItem *current = item;
+     qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: startItem:" << startItem;
+     qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: firstFromItem:" << firstFromItem;
++    QDuplicateTracker<QQuickItem *> cycleDetector;
+     do {
+         qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: current:" << current;
+         qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: from:" << from;
+@@ -2592,7 +2595,10 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo
+         // traversed all of the chain (by compare the [current] item with [startItem])
+         // Since the [startItem] might be promoted to its parent if it is invisible,
+         // we still have to check [current] item with original start item
+-        if ((current == startItem || current == originalStartItem) && from == firstFromItem) {
++        // We might also run into a cycle before we reach firstFromItem again
++        // but note that we have to ignore current if we are meant to skip it
++        if (((current == startItem || current == originalStartItem) && from == firstFromItem) ||
++                (!skip && cycleDetector.hasSeen(current))) {
+             // wrapped around, avoid endless loops
+             if (item == contentItem) {
+                 qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: looped, return contentItem";
+@@ -2689,9 +2695,8 @@ void QQuickItem::setParentItem(QQuickItem *parentItem)
+ 
+         const bool wasVisible = isVisible();
+         op->removeChild(this);
+-        if (wasVisible) {
++        if (wasVisible && !op->inDestructor)
+             emit oldParentItem->visibleChildrenChanged();
+-        }
+     } else if (d->window) {
+         QQuickWindowPrivate::get(d->window)->parentlessItems.remove(this);
+     }
+@@ -2768,8 +2773,9 @@ void QQuickItem::setParentItem(QQuickItem *parentItem)
+ 
+     d->itemChange(ItemParentHasChanged, d->parentItem);
+ 
+-    emit parentChanged(d->parentItem);
+-    if (isVisible() && d->parentItem)
++    if (!d->inDestructor)
++        emit parentChanged(d->parentItem);
++    if (isVisible() && d->parentItem && !QQuickItemPrivate::get(d->parentItem)->inDestructor)
+         emit d->parentItem->visibleChildrenChanged();
+ }
+ 
+@@ -2965,7 +2971,8 @@ void QQuickItemPrivate::removeChild(QQuickItem *child)
+ 
+     itemChange(QQuickItem::ItemChildRemovedChange, child);
+ 
+-    emit q->childrenChanged();
++    if (!inDestructor)
++        emit q->childrenChanged();
+ }
+ 
+ void QQuickItemPrivate::refWindow(QQuickWindow *c)
+@@ -3194,6 +3201,7 @@ QQuickItemPrivate::QQuickItemPrivate()
+     , touchEnabled(false)
+ #endif
+     , hasCursorHandler(false)
++    , inDestructor(false)
+     , dirtyAttributes(0)
+     , nextDirtyItem(nullptr)
+     , prevDirtyItem(nullptr)
+@@ -5120,6 +5128,13 @@ void QQuickItem::componentComplete()
+         d->addToDirtyList();
+         QQuickWindowPrivate::get(d->window)->dirtyItem(this);
+     }
++
++#if QT_CONFIG(accessibility)
++    if (d->isAccessible && d->effectiveVisible) {
++        QAccessibleEvent ev(this, QAccessible::ObjectShow);
++        QAccessible::updateAccessibility(&ev);
++    }
++#endif
+ }
+ 
+ QQuickStateGroup *QQuickItemPrivate::_states()
+@@ -6106,9 +6121,11 @@ bool QQuickItemPrivate::setEffectiveVisibleRecur(bool newEffectiveVisible)
+         QAccessible::updateAccessibility(&ev);
+     }
+ #endif
+-    emit q->visibleChanged();
+-    if (childVisibilityChanged)
+-        emit q->visibleChildrenChanged();
++    if (!inDestructor) {
++        emit q->visibleChanged();
++        if (childVisibilityChanged)
++            emit q->visibleChildrenChanged();
++    }
+ 
+     return true;    // effective visibility DID change
+ }
+@@ -6157,6 +6174,15 @@ void QQuickItemPrivate::setEffectiveEnableRecur(QQuickItem *scope, bool newEffec
+     }
+ 
+     itemChange(QQuickItem::ItemEnabledHasChanged, effectiveEnable);
++#if QT_CONFIG(accessibility)
++    if (isAccessible) {
++        QAccessible::State changedState;
++        changedState.disabled = true;
++        changedState.focusable = true;
++        QAccessibleStateChangeEvent ev(q, changedState);
++        QAccessible::updateAccessibility(&ev);
++    }
++#endif
+     emit q->enabledChanged();
+ }
+ 
+diff --git a/qtdeclarative/src/quick/items/qquickitem_p.h b/qtdeclarative/src/quick/items/qquickitem_p.h
+index 841d91bb40..ade8fb61f2 100644
+--- a/qtdeclarative/src/quick/items/qquickitem_p.h
++++ b/qtdeclarative/src/quick/items/qquickitem_p.h
+@@ -472,6 +472,7 @@ public:
+     bool replayingPressEvent:1;
+     bool touchEnabled:1;
+     bool hasCursorHandler:1;
++    quint32 inDestructor:1; // has entered ~QQuickItem
+ 
+     enum DirtyType {
+         TransformOrigin         = 0x00000001,
+diff --git a/qtdeclarative/src/quick/items/qquickitemview.cpp b/qtdeclarative/src/quick/items/qquickitemview.cpp
+index 010a0152e1..f8ad168a17 100644
+--- a/qtdeclarative/src/quick/items/qquickitemview.cpp
++++ b/qtdeclarative/src/quick/items/qquickitemview.cpp
+@@ -1785,7 +1785,7 @@ void QQuickItemViewPrivate::refill(qreal from, qreal to)
+ 
+     do {
+         bufferPause.stop();
+-        if (currentChanges.hasPendingChanges() || bufferedChanges.hasPendingChanges()) {
++        if (currentChanges.hasPendingChanges() || bufferedChanges.hasPendingChanges() || currentChanges.active) {
+             currentChanges.reset();
+             bufferedChanges.reset();
+             releaseVisibleItems(reusableFlag);
+diff --git a/qtdeclarative/src/quick/items/qquickmousearea_p_p.h b/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
+index fba383e268..0d63618622 100644
+--- a/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
++++ b/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
+@@ -61,7 +61,6 @@ QT_BEGIN_NAMESPACE
+ 
+ class QQuickMouseEvent;
+ class QQuickMouseArea;
+-class QQuickPointerMask;
+ class QQuickMouseAreaPrivate : public QQuickItemPrivate
+ {
+     Q_DECLARE_PUBLIC(QQuickMouseArea)
+@@ -100,7 +99,6 @@ public:
+ #if QT_CONFIG(quick_draganddrop)
+     QQuickDrag *drag;
+ #endif
+-    QPointer<QQuickPointerMask> mask;
+     QPointF startScene;
+     QPointF targetStartPos;
+     QPointF lastPos;
+diff --git a/qtdeclarative/src/quick/items/qquicktext.cpp b/qtdeclarative/src/quick/items/qquicktext.cpp
+index 6230186933..e823ca1095 100644
+--- a/qtdeclarative/src/quick/items/qquicktext.cpp
++++ b/qtdeclarative/src/quick/items/qquicktext.cpp
+@@ -2168,7 +2168,7 @@ void QQuickText::resetMaximumLineCount()
+     <img src="" align="top,middle,bottom" width="" height=""> - inline images
+     <ol type="">, <ul type=""> and <li> - ordered and unordered lists
+     <pre></pre> - preformatted
+-    &gt; &lt; &amp;
++    &gt; &lt; &amp; &quot; &nbsp; &apos;
+     \endcode
+ 
+     \c Text.StyledText parser is strict, requiring tags to be correctly nested.
+diff --git a/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp b/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
+index eb4db0f85e..2325a2665b 100644
+--- a/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
++++ b/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
+@@ -446,7 +446,7 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+         const char *textureRecord = allocatorData;
+         for (int i = 0; i < textureCount; ++i, textureRecord += Qtdf::TextureRecordSize) {
+-            if (textureRecord + Qtdf::TextureRecordSize > qtdfTableEnd) {
++            if (qtdfTableEnd - textureRecord < Qtdf::TextureRecordSize) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+@@ -462,7 +462,7 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+         const char *glyphRecord = textureRecord;
+         for (quint32 i = 0; i < glyphCount; ++i, glyphRecord += Qtdf::GlyphRecordSize) {
+-            if (glyphRecord + Qtdf::GlyphRecordSize > qtdfTableEnd) {
++            if (qtdfTableEnd - glyphRecord < Qtdf:: GlyphRecordSize) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+@@ -512,8 +512,8 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+             int width = texInfo->allocatedArea.width();
+             int height = texInfo->allocatedArea.height();
+-            qint64 size = width * height;
+-            if (reinterpret_cast<const char *>(textureData + size) > qtdfTableEnd) {
++            qint64 size = qint64(width) * height;
++            if (qtdfTableEnd - reinterpret_cast<const char *>(textureData) < size) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+diff --git a/qtdeclarative/src/quick/util/qquickstyledtext.cpp b/qtdeclarative/src/quick/util/qquickstyledtext.cpp
+index d531fc9205..a25af90414 100644
+--- a/qtdeclarative/src/quick/util/qquickstyledtext.cpp
++++ b/qtdeclarative/src/quick/util/qquickstyledtext.cpp
+@@ -564,6 +564,8 @@ void QQuickStyledTextPrivate::parseEntity(const QChar *&ch, const QString &textI
+                 textOut += QChar(60);
+             else if (entity == QLatin1String("amp"))
+                 textOut += QChar(38);
++            else if (entity == QLatin1String("apos"))
++                textOut += QChar(39);
+             else if (entity == QLatin1String("quot"))
+                 textOut += QChar(34);
+             else if (entity == QLatin1String("nbsp"))
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp
+new file mode 100644
+index 0000000000..8a1c901880
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp
+@@ -0,0 +1,110 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include "qaccessiblequickwidget_p.h"
++
++#include "qquickwidget_p.h"
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleQuickWidget::QAccessibleQuickWidget(QQuickWidget* widget)
++: QAccessibleWidget(widget)
++, m_accessibleWindow(QQuickWidgetPrivate::get(widget)->offscreenWindow)
++{
++    // NOTE: m_accessibleWindow is a QAccessibleQuickWindow, and not a
++    // QAccessibleQuickWidgetOffscreenWindow (defined below). This means
++    // it will return the Quick item child interfaces, which is what's needed here
++    // (unlike QAccessibleQuickWidgetOffscreenWindow, which will report 0 children).
++}
++
++QAccessibleInterface *QAccessibleQuickWidget::child(int index) const
++{
++    return m_accessibleWindow.child(index);
++}
++
++int QAccessibleQuickWidget::childCount() const
++{
++    return m_accessibleWindow.childCount();
++}
++
++int QAccessibleQuickWidget::indexOfChild(const QAccessibleInterface *iface) const
++{
++    return m_accessibleWindow.indexOfChild(iface);
++}
++
++QAccessibleInterface *QAccessibleQuickWidget::childAt(int x, int y) const
++{
++    return m_accessibleWindow.childAt(x, y);
++}
++
++QAccessibleQuickWidgetOffscreenWindow::QAccessibleQuickWidgetOffscreenWindow(QQuickWindow *window)
++:QAccessibleQuickWindow(window)
++{
++
++}
++
++QAccessibleInterface *QAccessibleQuickWidgetOffscreenWindow::child(int index) const
++{
++    Q_UNUSED(index);
++    return nullptr;
++}
++
++int QAccessibleQuickWidgetOffscreenWindow::childCount() const
++{
++    return 0;
++}
++
++int QAccessibleQuickWidgetOffscreenWindow::indexOfChild(const QAccessibleInterface *iface) const
++{
++    Q_UNUSED(iface);
++    return -1;
++}
++
++QAccessibleInterface *QAccessibleQuickWidgetOffscreenWindow::QAccessibleQuickWidgetOffscreenWindow::childAt(int x, int y) const
++{
++    Q_UNUSED(x);
++    Q_UNUSED(y);
++    return nullptr;
++}
++
++#endif // accessibility
++
++QT_END_NAMESPACE
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h
+new file mode 100644
+index 0000000000..7c2ab930e0
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h
+@@ -0,0 +1,95 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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 QACCESSIBLEQUICKWIDGET_H
++#define QACCESSIBLEQUICKWIDGET_H
++
++//
++//  W A R N I N G
++//  -------------
++//
++// This file is not part of the Qt API.  It exists purely as an
++// implementation detail.  This header file may change from version to
++// version without notice, or even be removed.
++//
++// We mean it.
++//
++
++#include "qquickwidget.h"
++#include <QtWidgets/qaccessiblewidget.h>
++
++#include <private/qaccessiblequickview_p.h>
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++// These classes implement the QQuickWiget accessibility switcharoo,
++// where the child items of the QQuickWidgetOffscreenWindow are reported
++// as child accessible interfaces of the QAccessibleQuickWidget.
++class QAccessibleQuickWidget: public QAccessibleWidget
++{
++public:
++    QAccessibleQuickWidget(QQuickWidget* widget);
++
++    QAccessibleInterface *child(int index) const override;
++    int childCount() const override;
++    int indexOfChild(const QAccessibleInterface *iface) const override;
++    QAccessibleInterface *childAt(int x, int y) const override;
++
++private:
++    QAccessibleQuickWindow m_accessibleWindow;
++    Q_DISABLE_COPY(QAccessibleQuickWidget)
++};
++
++class QAccessibleQuickWidgetOffscreenWindow: public QAccessibleQuickWindow
++{
++public:
++    QAccessibleQuickWidgetOffscreenWindow(QQuickWindow *window);
++    QAccessibleInterface *child(int index) const override;
++    int childCount() const override;
++    int indexOfChild(const QAccessibleInterface *iface) const override;
++    QAccessibleInterface *childAt(int x, int y) const override;
++};
++
++#endif // accessibility
++
++QT_END_NAMESPACE
++
++#endif
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp
+new file mode 100644
+index 0000000000..7ba88a1769
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp
+@@ -0,0 +1,60 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include "qaccessiblequickwidgetfactory_p.h"
++#include "qaccessiblequickwidget_p.h"
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleInterface *qAccessibleQuickWidgetFactory(const QString &classname, QObject *object)
++{
++    if (classname == QLatin1String("QQuickWidget")) {
++        return new QAccessibleQuickWidget(qobject_cast<QQuickWidget *>(object));
++    } else if (classname == QLatin1String("QQuickWidgetOffscreenWindow")) {
++        return new QAccessibleQuickWidgetOffscreenWindow(qobject_cast<QQuickWindow *>(object));
++    }
++    return 0;
++}
++
++#endif // accessibility
++
++QT_END_NAMESPACE
++
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h
+new file mode 100644
+index 0000000000..8c63b09f81
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h
+@@ -0,0 +1,66 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include <QtGui/qaccessible.h>
++
++#ifndef QACCESSIBLEQUICKWIDGETFACTORY_H
++#define QACCESSIBLEQUICKWIDGETFACTORY_H
++
++//
++//  W A R N I N G
++//  -------------
++//
++// This file is not part of the Qt API.  It exists purely as an
++// implementation detail.  This header file may change from version to
++// version without notice, or even be removed.
++//
++// We mean it.
++//
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleInterface *qAccessibleQuickWidgetFactory(const QString &classname, QObject *object);
++
++#endif
++
++QT_END_NAMESPACE
++
++#endif
+diff --git a/qtdeclarative/src/quickwidgets/qquickwidget.cpp b/qtdeclarative/src/quickwidgets/qquickwidget.cpp
+index 39780f8de3..9c97b43518 100644
+--- a/qtdeclarative/src/quickwidgets/qquickwidget.cpp
++++ b/qtdeclarative/src/quickwidgets/qquickwidget.cpp
+@@ -39,6 +39,7 @@
+ 
+ #include "qquickwidget.h"
+ #include "qquickwidget_p.h"
++#include "qaccessiblequickwidgetfactory_p.h"
+ 
+ #include "private/qquickwindow_p.h"
+ #include "private/qquickitem_p.h"
+@@ -75,9 +76,16 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++QQuickWidgetOffscreenWindow::QQuickWidgetOffscreenWindow(QQuickWindowPrivate &dd, QQuickRenderControl *control)
++:QQuickWindow(dd, control)
++{
++    setTitle(QString::fromLatin1("Offscreen"));
++    setObjectName(QString::fromLatin1("QQuickOffScreenWindow"));
++}
++
+ // override setVisble to prevent accidental offscreen window being created
+ // by base class.
+-class QQuickOffcreenWindowPrivate: public QQuickWindowPrivate {
++class QQuickWidgetOffscreenWindowPrivate: public QQuickWindowPrivate {
+ public:
+     void setVisible(bool visible) override {
+         Q_Q(QWindow);
+@@ -105,9 +113,8 @@ void QQuickWidgetPrivate::init(QQmlEngine* e)
+     Q_Q(QQuickWidget);
+ 
+     renderControl = new QQuickWidgetRenderControl(q);
+-    offscreenWindow = new QQuickWindow(*new QQuickOffcreenWindowPrivate(),renderControl);
+-    offscreenWindow->setTitle(QString::fromLatin1("Offscreen"));
+-    offscreenWindow->setObjectName(QString::fromLatin1("QQuickOffScreenWindow"));
++    offscreenWindow = new QQuickWidgetOffscreenWindow(*new QQuickWidgetOffscreenWindowPrivate(), renderControl);
++    offscreenWindow->setScreen(q->screen());
+     // Do not call create() on offscreenWindow.
+ 
+     // Check if the Software Adaptation is being used
+@@ -138,6 +145,10 @@ void QQuickWidgetPrivate::init(QQmlEngine* e)
+     QWidget::connect(offscreenWindow, &QQuickWindow::focusObjectChanged, q, &QQuickWidget::propagateFocusObjectChanged);
+     QObject::connect(renderControl, SIGNAL(renderRequested()), q, SLOT(triggerUpdate()));
+     QObject::connect(renderControl, SIGNAL(sceneChanged()), q, SLOT(triggerUpdate()));
++
++#if QT_CONFIG(accessibility)
++    QAccessible::installFactory(&qAccessibleQuickWidgetFactory);
++#endif
+ }
+ 
+ void QQuickWidgetPrivate::ensureEngine() const
+@@ -901,9 +912,7 @@ void QQuickWidgetPrivate::createContext()
+ 
+         context = new QOpenGLContext;
+         context->setFormat(offscreenWindow->requestedFormat());
+-        const QWindow *win = q->window()->windowHandle();
+-        if (win && win->screen())
+-            context->setScreen(win->screen());
++        context->setScreen(q->screen());
+         QOpenGLContext *shareContext = qt_gl_global_share_context();
+         if (!shareContext)
+             shareContext = QWidgetPrivate::get(q->window())->shareContext();
+@@ -1520,19 +1529,16 @@ bool QQuickWidget::event(QEvent *e)
+         d->handleWindowChange();
+         break;
+ 
+-    case QEvent::ScreenChangeInternal:
+-        if (QWindow *window = this->window()->windowHandle()) {
+-            QScreen *newScreen = window->screen();
+-
+-            if (d->offscreenWindow)
+-                d->offscreenWindow->setScreen(newScreen);
+-            if (d->offscreenSurface)
+-                d->offscreenSurface->setScreen(newScreen);
++    case QEvent::ScreenChangeInternal: {
++        QScreen *newScreen = screen();
++        if (d->offscreenWindow)
++            d->offscreenWindow->setScreen(newScreen);
++        if (d->offscreenSurface)
++            d->offscreenSurface->setScreen(newScreen);
+ #if QT_CONFIG(opengl)
+-            if (d->context)
+-                d->context->setScreen(newScreen);
++        if (d->context)
++            d->context->setScreen(newScreen);
+ #endif
+-        }
+ 
+         if (d->useSoftwareRenderer
+ #if QT_CONFIG(opengl)
+@@ -1545,7 +1551,7 @@ bool QQuickWidget::event(QEvent *e)
+             d->render(true);
+         }
+         break;
+-
++    }
+     case QEvent::Show:
+     case QEvent::Move:
+         d->updatePosition();
+diff --git a/qtdeclarative/src/quickwidgets/qquickwidget_p.h b/qtdeclarative/src/quickwidgets/qquickwidget_p.h
+index 881f7f9220..1a946bcc71 100644
+--- a/qtdeclarative/src/quickwidgets/qquickwidget_p.h
++++ b/qtdeclarative/src/quickwidgets/qquickwidget_p.h
+@@ -148,6 +148,14 @@ public:
+     bool forceFullUpdate;
+ };
+ 
++class QQuickWidgetOffscreenWindow: public QQuickWindow
++{
++    Q_OBJECT
++
++public:
++    QQuickWidgetOffscreenWindow(QQuickWindowPrivate &dd, QQuickRenderControl *control);
++};
++
+ QT_END_NAMESPACE
+ 
+ #endif // QQuickWidget_P_H
+diff --git a/qtdeclarative/src/quickwidgets/quickwidgets.pro b/qtdeclarative/src/quickwidgets/quickwidgets.pro
+index 2438e577ae..85d156b8a3 100644
+--- a/qtdeclarative/src/quickwidgets/quickwidgets.pro
++++ b/qtdeclarative/src/quickwidgets/quickwidgets.pro
+@@ -7,9 +7,13 @@ DEFINES   += QT_NO_URL_CAST_FROM_STRING QT_NO_INTEGER_EVENT_COORDINATES QT_NO_FO
+ HEADERS += \
+     qquickwidget.h \
+     qquickwidget_p.h \
+-    qtquickwidgetsglobal.h
++    qtquickwidgetsglobal.h \
++    qaccessiblequickwidget_p.h \
++    qaccessiblequickwidgetfactory_p.h
+ 
+ SOURCES += \
+-    qquickwidget.cpp
++    qquickwidget.cpp \
++    qaccessiblequickwidget.cpp \
++    qaccessiblequickwidgetfactory.cpp
+ 
+ load(qt_module)
+diff --git a/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+index 3b7d74df63..b75bf820d5 100644
+--- a/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
++++ b/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+@@ -102,6 +102,7 @@ private slots:
+     void valueConversion_RegularExpression();
+     void castWithMultipleInheritance();
+     void collectGarbage();
++    void collectGarbageNestedWrappersTwoEngines();
+     void gcWithNestedDataStructure();
+     void stacktrace();
+     void numberParsing_data();
+@@ -1809,6 +1810,44 @@ void tst_QJSEngine::collectGarbage()
+     QVERIFY(ptr.isNull());
+ }
+ 
++class TestObjectContainer : public QObject
++{
++    Q_OBJECT
++    Q_PROPERTY(QObject *dummy MEMBER m_dummy CONSTANT)
++
++public:
++    TestObjectContainer() : m_dummy(new QObject(this)) {}
++
++private:
++    QObject *m_dummy;
++};
++
++void tst_QJSEngine::collectGarbageNestedWrappersTwoEngines()
++{
++    QJSEngine engine1;
++    QJSEngine engine2;
++
++    TestObjectContainer container;
++    QQmlEngine::setObjectOwnership(&container, QQmlEngine::CppOwnership);
++
++    engine1.globalObject().setProperty("foobar", engine1.newQObject(&container));
++    engine2.globalObject().setProperty("foobar", engine2.newQObject(&container));
++
++    engine1.evaluate("foobar.dummy.baz = 42");
++    engine2.evaluate("foobar.dummy.baz = 43");
++
++    QCOMPARE(engine1.evaluate("foobar.dummy.baz").toInt(), 42);
++    QCOMPARE(engine2.evaluate("foobar.dummy.baz").toInt(), 43);
++
++    engine1.collectGarbage();
++    engine2.collectGarbage();
++
++    // The GC should not collect dummy object wrappers neither in engine1 nor engine2, we
++    // verify that by checking whether the baz property still has its previous value.
++    QCOMPARE(engine1.evaluate("foobar.dummy.baz").toInt(), 42);
++    QCOMPARE(engine2.evaluate("foobar.dummy.baz").toInt(), 43);
++}
++
+ void tst_QJSEngine::gcWithNestedDataStructure()
+ {
+     // The GC must be able to traverse deeply nested objects, otherwise this
+diff --git a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml
+new file mode 100644
+index 0000000000..206133bb39
+--- /dev/null
++++ b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml
+@@ -0,0 +1,11 @@
++import QtQuick 2.8
++
++ListView {
++    id: root
++    width: 200
++    height: 200
++
++    delegate: Text {
++        text: display
++    }
++}
+diff --git a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
+index 35f1e2c94d..1722447830 100644
+--- a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
++++ b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
+@@ -27,6 +27,8 @@
+ ****************************************************************************/
+ 
+ #include <QtTest/qtest.h>
++#include <QtCore/QConcatenateTablesProxyModel>
++#include <QtGui/QStandardItemModel>
+ #include <QtQml/qqmlcomponent.h>
+ #include <QtQmlModels/private/qqmldelegatemodel_p.h>
+ #include <QtQuick/qquickview.h>
+@@ -47,6 +49,7 @@ private slots:
+     void filterOnGroup_removeWhenCompleted();
+     void qtbug_86017();
+     void contextAccessedByHandler();
++    void redrawUponColumnChange();
+ };
+ 
+ class AbstractItemModel : public QAbstractItemModel
+@@ -186,6 +189,30 @@ void tst_QQmlDelegateModel::contextAccessedByHandler()
+     QVERIFY(root->property("works").toBool());
+ }
+ 
++void tst_QQmlDelegateModel::redrawUponColumnChange()
++{
++    QStandardItemModel m1;
++    m1.appendRow({
++            new QStandardItem("Banana"),
++            new QStandardItem("Coconut"),
++    });
++
++    QQuickView view(testFileUrl("redrawUponColumnChange.qml"));
++    QCOMPARE(view.status(), QQuickView::Ready);
++    view.show();
++    QQuickItem *root = view.rootObject();
++    root->setProperty("model", QVariant::fromValue<QObject *>(&m1));
++
++    QObject *item = root->property("currentItem").value<QObject *>();
++    QVERIFY(item);
++    QCOMPARE(item->property("text").toString(), "Banana");
++
++    QVERIFY(root);
++    m1.removeColumn(0);
++
++    QCOMPARE(item->property("text").toString(), "Coconut");
++}
++
+ QTEST_MAIN(tst_QQmlDelegateModel)
+ 
+ #include "tst_qqmldelegatemodel.moc"
+diff --git a/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp b/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
+index 5d635aa63b..824fd89e5b 100644
+--- a/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
++++ b/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
+@@ -76,10 +76,10 @@ void tst_qv4mm::multiWrappedQObjects()
+         QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 1);
+         QCOMPARE(engine2.memoryManager->m_pendingFreedObjectWrapperValue.size(), 0);
+ 
+-        // Moves the additional WeakValue from m_multiplyWrappedQObjects to
+-        // m_pendingFreedObjectWrapperValue. It's still alive after all.
++        // The additional WeakValue from m_multiplyWrappedQObjects hasn't been moved
++        // to m_pendingFreedObjectWrapperValue yet. It's still alive after all.
+         engine1.memoryManager->runGC();
+-        QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 2);
++        QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 1);
+ 
+         // engine2 doesn't own the object as engine1 was the first to wrap it above.
+         // Therefore, no effect here.
+diff --git a/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml b/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml
+new file mode 100644
+index 0000000000..889e480f3b
+--- /dev/null
++++ b/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml
+@@ -0,0 +1,13 @@
++import QtQuick 2.6
++
++Item {
++    visible: true
++    Item {
++        visible: false
++        Item {
++            objectName: "hiddenChild"
++            activeFocusOnTab: true
++            focus: true
++        }
++    }
++}
+diff --git a/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp b/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+index c8f251dbe1..c8ef36ee68 100644
+--- a/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
++++ b/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+@@ -67,6 +67,7 @@ private slots:
+     void activeFocusOnTab10();
+     void activeFocusOnTab_infiniteLoop_data();
+     void activeFocusOnTab_infiniteLoop();
++    void activeFocusOnTab_infiniteLoopControls();
+ 
+     void nextItemInFocusChain();
+     void nextItemInFocusChain2();
+@@ -1057,6 +1058,17 @@ void tst_QQuickItem::activeFocusOnTab_infiniteLoop()
+     QCOMPARE(item, window->rootObject());
+ }
+ 
++
++void tst_QQuickItem::activeFocusOnTab_infiniteLoopControls()
++{
++    auto source = testFileUrl("activeFocusOnTab_infiniteLoop3.qml");
++    QScopedPointer<QQuickView>window(new QQuickView());
++    window->setSource(source);
++    window->show();
++    QVERIFY(window->errors().isEmpty());
++    QTest::keyClick(window.get(), Qt::Key_Tab); // should not hang
++}
++
+ void tst_QQuickItem::nextItemInFocusChain()
+ {
+     if (!qt_tab_all_widgets())
+Submodule qtdoc c0c7bf07...79d6ef69:
+Submodule qtimageformats 2dcf2899..abe44c0f:
+diff --git a/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp b/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
+index dde783c..1bf9074 100644
+--- a/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
+@@ -462,8 +462,12 @@ static bool parseIconEntryInfo(ICNSEntry &icon)
+     if (isIconCompressed(icon))
+         return true;
+     // Icon depth:
+-    if (!depth.isEmpty())
+-        icon.depth = ICNSEntry::Depth(depth.toUInt());
++    if (!depth.isEmpty()) {
++        const uint depthUInt = depth.toUInt();
++        if (depthUInt > 32)
++            return false;
++        icon.depth = ICNSEntry::Depth(depthUInt);
++    }
+     // Try mono if depth not found
+     if (icon.depth == ICNSEntry::DepthUnknown)
+         icon.depth = ICNSEntry::DepthMono;
+@@ -515,6 +519,9 @@ static bool parseIconEntryInfo(ICNSEntry &icon)
+         }
+         icon.height = icon.width;
+     }
++    // Sanity check
++    if (icon.width == 0 || icon.width > 4096)
++        return false;
+     return true;
+ }
+ 
+@@ -685,7 +692,7 @@ bool QICNSHandler::canRead() const
+ bool QICNSHandler::read(QImage *outImage)
+ {
+     QImage img;
+-    if (!ensureScanned()) {
++    if (!ensureScanned() || m_currentIconIndex >= m_icons.size()) {
+         qWarning("QICNSHandler::read(): The device wasn't parsed properly!");
+         return false;
+     }
+@@ -892,7 +899,7 @@ bool QICNSHandler::scanDevice()
+             return false;
+ 
+         const qint64 blockDataOffset = device()->pos();
+-        if (!isBlockHeaderValid(blockHeader)) {
++        if (!isBlockHeaderValid(blockHeader, ICNSBlockHeaderSize + filelength - blockDataOffset)) {
+             qWarning("QICNSHandler::scanDevice(): Failed, bad header at pos %s. OSType \"%s\", length %u",
+                      QByteArray::number(blockDataOffset).constData(),
+                      nameFromOSType(blockHeader.ostype).constData(), blockHeader.length);
+@@ -927,11 +934,14 @@ bool QICNSHandler::scanDevice()
+         case ICNSBlockHeader::TypeOdrp:
+             // Icns container seems to have an embedded icon variant container
+             // Let's start a scan for entries
+-            while (device()->pos() < nextBlockOffset) {
++            while (!stream.atEnd() && device()->pos() < nextBlockOffset) {
+                 ICNSBlockHeader icon;
+                 stream >> icon;
++                if (stream.status() != QDataStream::Ok)
++                    return false;
+                 // Check for incorrect variant entry header and stop scan
+-                if (!isBlockHeaderValid(icon, blockDataLength))
++                quint64 remaining = blockDataLength - (device()->pos() - blockDataOffset);
++                if (!isBlockHeaderValid(icon, ICNSBlockHeaderSize + remaining))
+                     break;
+                 if (!addEntry(icon, device()->pos(), blockHeader.ostype))
+                     return false;
+@@ -1003,7 +1013,7 @@ bool QICNSHandler::scanDevice()
+             break;
+         }
+     }
+-    return true;
++    return (m_icons.size() > 0);
+ }
+ 
+ const ICNSEntry &QICNSHandler::getIconMask(const ICNSEntry &icon) const
+diff --git a/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp b/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
+index 5082023..cb34374 100644
+--- a/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
++++ b/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
+@@ -43,6 +43,7 @@
+ #include "qimage.h"
+ #include "qvariant.h"
+ #include "qcolor.h"
++#include "qimagereader.h"
+ 
+ #include <jasper/jasper.h>
+ #include <math.h> // for pow
+@@ -333,16 +334,46 @@ private:
+ Jpeg2000JasperReader::Jpeg2000JasperReader(QIODevice *iod, SubFormat format)
+     : jasperOk(true), ioDevice(iod), format(format), hasAlpha(false)
+ {
++#if JAS_VERSION_MAJOR < 3
+     if (jas_init()) {
+         jasperOk = false;
+         qDebug("Jasper Library initialization failed");
+     }
++#else
++    jas_conf_clear();
++#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
++    jas_conf_set_max_mem_usage(QImageReader::allocationLimit() * 1024 * 1024);
++#else
++    // 128MB seems to be enough.
++    jas_conf_set_max_mem_usage(128 * 1024 * 1024);
++#endif
++    if (jas_init_library()) {
++        jasperOk = false;
++        qDebug("Jasper library initialization failed");
++    }
++    if (jas_init_thread()) {
++        jas_cleanup_library();
++        jasperOk = false;
++        qDebug("Jasper thread initialization failed");
++    }
++#endif
+ }
+ 
+ Jpeg2000JasperReader::~Jpeg2000JasperReader()
+ {
++#if JAS_VERSION_MAJOR < 3
+     if (jasperOk)
+         jas_cleanup();
++#else
++    if (jasperOk) {
++        if (jas_cleanup_thread()) {
++            qDebug("Jasper thread cleanup failed");
++        }
++        if (jas_cleanup_library()) {
++            qDebug("Jasper library cleanup failed");
++        }
++    }
++#endif
+ }
+ 
+ /*! \internal
+@@ -857,7 +888,7 @@ bool Jpeg2000JasperReader::write(const QImage &image, int quality)
+     }
+ 
+     // Open an empty jasper stream that grows automatically
+-    jas_stream_t * memory_stream = jas_stream_memopen(0, -1);
++    jas_stream_t * memory_stream = jas_stream_memopen(0, 0);
+ 
+     // Jasper wants a non-const string.
+     char *str = qstrdup(jasperFormatString.toLatin1().constData());
+diff --git a/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp b/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
+index 1386750..ac8956c 100644
+--- a/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
+@@ -361,6 +361,8 @@ bool QTiffHandler::read(QImage *image)
+     }
+ 
+     TIFF *const tiff = d->tiff;
++    if (TIFFIsTiled(tiff) && TIFFTileSize64(tiff) > uint64_t(image->sizeInBytes())) // Corrupt image
++        return false;
+     const quint32 width = d->size.width();
+     const quint32 height = d->size.height();
+ 
+diff --git a/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp b/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
+index 82d38cb..d02eb05 100644
+--- a/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
+@@ -45,6 +45,7 @@
+ #include <qdebug.h>
+ #include <qpainter.h>
+ #include <qvariant.h>
++#include <QtEndian>
+ 
+ static const int riffHeaderSize = 12; // RIFF_HEADER_SIZE from webp/format_constants.h
+ 
+@@ -102,21 +103,23 @@ bool QWebpHandler::ensureScanned() const
+ 
+     m_scanState = ScanError;
+ 
+-    if (device()->isSequential()) {
+-        qWarning() << "Sequential devices are not supported";
++    QWebpHandler *that = const_cast<QWebpHandler *>(this);
++    const int headerBytesNeeded = sizeof(WebPBitstreamFeatures);
++    QByteArray header = device()->peek(headerBytesNeeded);
++    if (header.size() < headerBytesNeeded)
+         return false;
+-    }
+ 
+-    qint64 oldPos = device()->pos();
+-    device()->seek(0);
+-
+-    QWebpHandler *that = const_cast<QWebpHandler *>(this);
+-    QByteArray header = device()->peek(sizeof(WebPBitstreamFeatures));
++    // We do no random access during decoding, just a readAll() of the whole image file. So if
++    // if it is all available already, we can accept a sequential device. The riff header contains
++    // the file size minus 8 bytes header
++    qint64 byteSize = qFromLittleEndian<quint32>(header.constData() + 4);
++    if (device()->isSequential() && device()->bytesAvailable() < byteSize + 8) {
++        qWarning() << "QWebpHandler: Insufficient data available in sequential device";
++        return false;
++    }
+     if (WebPGetFeatures((const uint8_t*)header.constData(), header.size(), &(that->m_features)) == VP8_STATUS_OK) {
+         if (m_features.has_animation) {
+             // For animation, we have to read and scan whole file to determine loop count and images count
+-            device()->seek(oldPos);
+-
+             if (that->ensureDemuxer()) {
+                 that->m_loop = WebPDemuxGetI(m_demuxer, WEBP_FF_LOOP_COUNT);
+                 that->m_frameCount = WebPDemuxGetI(m_demuxer, WEBP_FF_FRAME_COUNT);
+@@ -126,17 +129,13 @@ bool QWebpHandler::ensureScanned() const
+                 if (that->m_features.has_alpha)
+                     that->m_composited->fill(Qt::transparent);
+ 
+-                // We do not reset device position since we have read in all data
+                 m_scanState = ScanSuccess;
+-                return true;
+             }
+         } else {
+             m_scanState = ScanSuccess;
+         }
+     }
+ 
+-    device()->seek(oldPos);
+-
+     return m_scanState == ScanSuccess;
+ }
+ 
+@@ -159,7 +158,7 @@ bool QWebpHandler::ensureDemuxer()
+ 
+ bool QWebpHandler::read(QImage *image)
+ {
+-    if (!ensureScanned() || device()->isSequential() || !ensureDemuxer())
++    if (!ensureScanned() || !ensureDemuxer())
+         return false;
+ 
+     QRect prevFrameRect;
+Submodule qtlocation 98a5c511..f991e28c:
+diff --git a/qtlocation/src/location/configure.json b/qtlocation/src/location/configure.json
+index 6d01a9a3..d1e623a1 100644
+--- a/qtlocation/src/location/configure.json
++++ b/qtlocation/src/location/configure.json
+@@ -9,7 +9,7 @@
+             "label": "Qt.labs.location experimental QML plugin",
+             "purpose": "Provides experimental QtLocation QML types",
+             "section": "Location",
+-            "condition": "config.opengl",
++            "condition": "features.opengl",
+             "output": [ "privateFeature" ]
+         },
+         "geoservices_osm": {
+diff --git a/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp b/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
+index a978573d..11e1466f 100644
+--- a/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
++++ b/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
+@@ -158,7 +158,7 @@ void QGeoMapObjectQSGSupport::updateMapObjects(QSGNode *root, QQuickWindow *wind
+     if (!root)
+         return;
+ 
+-    if (m_mapObjectsRootNode && m_mapObjectsRootNode->parent())
++    if (m_mapObjectsRootNode && !m_mapObjectsRootNode->parent())
+         root->appendChildNode(m_mapObjectsRootNode.get());
+ 
+     if (!m_mapObjectsRootNode) {
+diff --git a/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
+index 5a40467e..d123c6a8 100644
+--- a/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
+@@ -59,8 +59,10 @@ QT_BEGIN_NAMESPACE
+ static const QString kPrefixEsri(QStringLiteral("esri."));
+ static const QString kParamUserAgent(kPrefixEsri + QStringLiteral("useragent"));
+ 
+-static const QString kUrlGeocode(QStringLiteral("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates"));
+-static const QString kUrlReverseGeocode(QStringLiteral("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode"));
++static const QString kUrlGeocode(QStringLiteral("https://geocode.arcgis.com/arcgis/rest/services/"
++                                                "World/GeocodeServer/findAddressCandidates"));
++static const QString kUrlReverseGeocode(QStringLiteral(
++        "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode"));
+ 
+ static QString addressToQuery(const QGeoAddress &address)
+ {
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
+index 17492d94..96c12b1b 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
+@@ -46,7 +46,8 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-// JSON reference: http://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
++// JSON reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
+ 
+ static const QString kErrorMessage(QStringLiteral("Error %1: %2."));
+ static const QString kErrorJson(QStringLiteral("Error: invalide JSON document."));
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
+index 8cadfb29..92b6bb13 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
+@@ -44,7 +44,8 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-// JSON reference: http://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
++// JSON reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
+ 
+ GeoRouteReplyEsri::GeoRouteReplyEsri(QNetworkReply *reply, const QGeoRouteRequest &request,
+                                      QObject *parent) :
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
+index 0e6bc2c7..ed613f4b 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
+@@ -48,7 +48,8 @@ static const QString kPrefixEsri(QStringLiteral("esri."));
+ static const QString kParamUserAgent(kPrefixEsri + QStringLiteral("useragent"));
+ static const QString kParamToken(kPrefixEsri + QStringLiteral("token"));
+ 
+-static const QString kUrlRouting(QStringLiteral("http://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve"));
++static const QString kUrlRouting(QStringLiteral(
++        "https://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve"));
+ 
+ GeoRoutingManagerEngineEsri::GeoRoutingManagerEngineEsri(const QVariantMap &parameters,
+                                                          QGeoServiceProvider::Error *error,
+@@ -70,7 +71,8 @@ GeoRoutingManagerEngineEsri::~GeoRoutingManagerEngineEsri()
+ {
+ }
+ 
+-// REST reference: http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
++// REST reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
+ 
+ QGeoRouteReply *GeoRoutingManagerEngineEsri::calculateRoute(const QGeoRouteRequest &request)
+ {
+@@ -125,7 +127,7 @@ void GeoRoutingManagerEngineEsri::replyError(QGeoRouteReply::Error errorCode, co
+ QString GeoRoutingManagerEngineEsri::preferedDirectionLangage()
+ {
+     // list of supported langages is defined in:
+-    // http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
++    // https://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
+     const QStringList supportedLanguages = {
+         "ar", // Generate directions in Arabic
+         "cs", // Generate directions in Czech
+diff --git a/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
+index 5d15835d..24148f95 100644
+--- a/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
+@@ -230,7 +230,8 @@ QGeoMap *GeoTiledMappingManagerEngineEsri::createMap()
+ // ${y} = Y
+ // ${token} = Token
+ 
+-// template = 'http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{{z}}/{{y}}/{{x}}.png'
++// template =
++// 'https://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{{z}}/{{y}}/{{x}}.png'
+ 
+ bool GeoTiledMappingManagerEngineEsri::initializeMapSources(QGeoServiceProvider::Error *error,
+                                                             QString *errorString,
+diff --git a/qtlocation/src/plugins/geoservices/esri/maps.json b/qtlocation/src/plugins/geoservices/esri/maps.json
+index 8167ae7d..862e087d 100644
+--- a/qtlocation/src/plugins/geoservices/esri/maps.json
++++ b/qtlocation/src/plugins/geoservices/esri/maps.json
+@@ -6,8 +6,8 @@
+             "description": "ArcGIS Online World Street Map",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=3b93337983e9436f8db950e38a8629af'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=3b93337983e9436f8db950e38a8629af'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -16,8 +16,8 @@
+             "": "ArcGIS Online World Imagery",
+             "mobile": true,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -26,8 +26,8 @@
+             "description": "ArcGIS Online World Terrain Base",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=c61ad8ab017d49e1a82f580ee1298931'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=c61ad8ab017d49e1a82f580ee1298931'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -36,8 +36,8 @@
+             "description": "ArcGIS Online World Topography",
+             "mobile": true,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=30e5fe3149c34df1ba922e6f5bbf808f'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=30e5fe3149c34df1ba922e6f5bbf808f'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -46,8 +46,8 @@
+             "description": "This map presents land cover and detailed topographic maps for the United States.",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=99cd5fbd98934028802b4f797c4b1732'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=99cd5fbd98934028802b4f797c4b1732'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -56,8 +56,8 @@
+             "description": "National Geographic World Map",
+             "mobile": false,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=b9b1b422198944fbbd5250b3241691b6'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=b9b1b422198944fbbd5250b3241691b6'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -66,8 +66,8 @@
+             "description": "Thematic content providing a neutral background with minimal colors",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=ed712cb1db3e4bae9e85329040fb9a49'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=ed712cb1db3e4bae9e85329040fb9a49'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -76,8 +76,8 @@
+             "description": "Natural Earth physical map for the world",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=c4ec722a1cd34cf0a23904aadf8923a0'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=c4ec722a1cd34cf0a23904aadf8923a0'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -86,8 +86,8 @@
+             "description": "Portrays surface elevation as shaded relief",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=9c5370d0b54f4de1b48a3792d7377ff2'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=9c5370d0b54f4de1b48a3792d7377ff2'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -96,8 +96,8 @@
+             "description": "This map is designed to be used as a basemap by marine GIS professionals and as a reference map by anyone interested in ocean data",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=1e126e7520f9466c9ca28b8f28b5e500'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=1e126e7520f9466c9ca28b8f28b5e500'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -106,8 +106,8 @@
+             "description": "Thematic content providing a neutral background with minimal colors",
+             "mobile": false,
+             "night": true,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=a284a9b99b3446a3910d4144a50990f6'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=a284a9b99b3446a3910d4144a50990f6'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -116,8 +116,8 @@
+             "description": "DeLorme’s topographic basemap is a seamless global data set that portrays transportation, hydrography, jurisdiction boundaries, and major geographic features",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/Specialty/DeLorme_World_Base_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=b165c3df453e4be6b5ac4fdb241effbe'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/Specialty/DeLorme_World_Base_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=b165c3df453e4be6b5ac4fdb241effbe'>Esri</a> contributors"
+         }
+     ]
+ }
+diff --git a/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
+index 3858ddf5..af66f28e 100644
+--- a/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
+@@ -63,8 +63,10 @@ static const QString kCountriesKey(QStringLiteral("detailedCountries"));
+ static const QString kLocalizedNamesKey(QStringLiteral("localizedNames"));
+ static const QString kMaxLocationsKey(QStringLiteral("maxLocations"));
+ 
+-static const QUrl kUrlGeocodeServer("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer?f=pjson");
+-static const QUrl kUrlFindAddressCandidates("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates");
++static const QUrl kUrlGeocodeServer(
++        "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer?f=pjson");
++static const QUrl kUrlFindAddressCandidates("https://geocode.arcgis.com/arcgis/rest/services/World/"
++                                            "GeocodeServer/findAddressCandidates");
+ 
+ PlaceManagerEngineEsri::PlaceManagerEngineEsri(const QVariantMap &parameters, QGeoServiceProvider::Error *error,
+                                                QString *errorString) :
+Submodule qtmultimedia f0344079..0d7cc33a:
+diff --git a/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp b/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
+index 2b5325132..b68b4af1b 100644
+--- a/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
++++ b/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
+@@ -402,6 +402,8 @@ int QPulseAudioInput::bytesReady() const
+ 
+ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ {
++    Q_ASSERT(data != nullptr || len == 0);
++
+     m_bytesAvailable = checkBytesReady();
+ 
+     setError(QAudio::NoError);
+@@ -411,7 +413,8 @@ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ 
+     if (!m_pullMode && !m_tempBuffer.isEmpty()) {
+         readBytes = qMin(static_cast<int>(len), m_tempBuffer.size());
+-        memcpy(data, m_tempBuffer.constData(), readBytes);
++        if (readBytes)
++            memcpy(data, m_tempBuffer.constData(), readBytes);
+         m_totalTimeValue += readBytes;
+ 
+         if (readBytes < m_tempBuffer.size()) {
+@@ -502,9 +505,10 @@ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ 
+ void QPulseAudioInput::applyVolume(const void *src, void *dest, int len)
+ {
++    Q_ASSERT((src && dest) || len == 0);
+     if (m_volume < 1.f)
+         QAudioHelperInternal::qMultiplySamples(m_volume, m_format, src, dest, len);
+-    else
++    else if (len)
+         memcpy(dest, src, len);
+ }
+ 
+Submodule qtpim 02efef5e...f9a8f0fc (commits not present)
+Submodule qtquick3d b85cf622..47defc8b:
+diff --git a/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro b/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
+index ca5c499e..174a075b 100644
+--- a/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
++++ b/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
+@@ -10,7 +10,7 @@ QT_FOR_CONFIG += assetimporters-private
+ include($$OUT_PWD/../qtassetimporters-config.pri)
+ 
+ qtConfig(system-assimp):!if(cross_compile:host_build) {
+-    QMAKE_USE_PRIVATE += assimp
++    QMAKE_USE_PRIVATE += quick3d-assimp
+ } else {
+     include(../../../3rdparty/assimp/assimp.pri)
+ }
+Submodule qtquickcontrols2 3a657dc0..56ce8233:
+diff --git a/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp b/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
+index e5fe734f7..e36922775 100644
+--- a/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
++++ b/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
+@@ -38,6 +38,7 @@
+ #include "qwidgetplatformmenuitem_p.h"
+ 
+ #include <QtGui/qwindow.h>
++#include <QtGui/private/qhighdpiscaling_p.h>
+ #include <QtWidgets/qmenu.h>
+ #include <QtWidgets/qaction.h>
+ 
+@@ -145,7 +146,7 @@ void QWidgetPlatformMenu::showPopup(const QWindow *window, const QRect &targetRe
+ 
+     QPoint targetPos = targetRect.bottomLeft();
+     if (window)
+-        targetPos = window->mapToGlobal(targetPos);
++        targetPos = window->mapToGlobal(QHighDpi::fromNativeLocalPosition(targetPos, window));
+ 
+     const QWidgetPlatformMenuItem *widgetItem = qobject_cast<const QWidgetPlatformMenuItem *>(item);
+     m_menu->popup(targetPos, widgetItem ? widgetItem->action() : nullptr);
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
+index 950e4e099..b81fbea0b 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
+@@ -387,6 +387,17 @@ void QQuickAbstractButtonPrivate::itemImplicitHeightChanged(QQuickItem *item)
+         emit q->implicitIndicatorHeightChanged();
+ }
+ 
++void QQuickAbstractButtonPrivate::itemDestroyed(QQuickItem *item)
++{
++    Q_Q(QQuickAbstractButton);
++    QQuickControlPrivate::itemDestroyed(item);
++    if (item == indicator) {
++        indicator = nullptr;
++        emit q->implicitIndicatorWidthChanged();
++        emit q->implicitIndicatorHeightChanged();
++    }
++}
++
+ QQuickAbstractButton *QQuickAbstractButtonPrivate::findCheckedButton() const
+ {
+     Q_Q(const QQuickAbstractButton);
+@@ -1176,6 +1187,12 @@ QAccessible::Role QQuickAbstractButton::accessibleRole() const
+     }
+     return QAccessible::Button;
+ }
++
++void QQuickAbstractButton::accessiblePressAction()
++{
++    Q_D(QQuickAbstractButton);
++    d->trigger();
++}
+ #endif
+ 
+ QT_END_NAMESPACE
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
+index 0fa48980e..ab66220d0 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
+@@ -209,6 +209,7 @@ protected:
+ #if QT_CONFIG(accessibility)
+     void accessibilityActiveChanged(bool active) override;
+     QAccessible::Role accessibleRole() const override;
++    Q_INVOKABLE void accessiblePressAction();
+ #endif
+ 
+ private:
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
+index 9291c1a87..b729720f2 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
+@@ -109,6 +109,7 @@ public:
+ 
+     void itemImplicitWidthChanged(QQuickItem *item) override;
+     void itemImplicitHeightChanged(QQuickItem *item) override;
++    void itemDestroyed(QQuickItem *item) override;
+ 
+     // copied from qabstractbutton.cpp
+     static const int AUTO_REPEAT_DELAY = 300;
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp b/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
+index 2041e7741..8610cdfae 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
+@@ -145,7 +145,7 @@ int QQuickActionPrivate::ShortcutEntry::shortcutId() const
+ 
+ void QQuickActionPrivate::ShortcutEntry::grab(const QKeySequence &shortcut, bool enabled)
+ {
+-    if (shortcut.isEmpty())
++    if (shortcut.isEmpty() || m_shortcutId)
+         return;
+ 
+     Qt::ShortcutContext context = Qt::WindowShortcut; // TODO
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp b/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
+index f38c2b09c..6eed2a024 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
+@@ -225,6 +225,7 @@ void QQuickContainerPrivate::cleanup()
+     QObject::disconnect(contentModel, &QQmlObjectModel::countChanged, q, &QQuickContainer::countChanged);
+     QObject::disconnect(contentModel, &QQmlObjectModel::childrenChanged, q, &QQuickContainer::contentChildrenChanged);
+     delete contentModel;
++    contentModel = nullptr;
+ }
+ 
+ QQuickItem *QQuickContainerPrivate::itemAt(int index) const
+@@ -436,7 +437,7 @@ void QQuickContainerPrivate::contentChildren_clear(QQmlListProperty<QQuickItem>
+ void QQuickContainerPrivate::updateContentWidth()
+ {
+     Q_Q(QQuickContainer);
+-    if (hasContentWidth || qFuzzyCompare(contentWidth, implicitContentWidth))
++    if (hasContentWidth || qFuzzyCompare(contentWidth, implicitContentWidth) || !contentModel)
+         return;
+ 
+     contentWidth = implicitContentWidth;
+@@ -446,7 +447,7 @@ void QQuickContainerPrivate::updateContentWidth()
+ void QQuickContainerPrivate::updateContentHeight()
+ {
+     Q_Q(QQuickContainer);
+-    if (hasContentHeight || qFuzzyCompare(contentHeight, implicitContentHeight))
++    if (hasContentHeight || qFuzzyCompare(contentHeight, implicitContentHeight) || !contentModel)
+         return;
+ 
+     contentHeight = implicitContentHeight;
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp b/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
+index bbbd0e622..1f4b47343 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
+@@ -845,6 +845,13 @@ void QQuickControlPrivate::executeBackground(bool complete)
+         quickCompleteDeferred(q, backgroundName(), background);
+ }
+ 
++/*
++    \internal
++
++    Hides an item that was replaced by a newer one, rather than
++    deleting it, as the item is typically created in QML and hence
++    we don't own it.
++*/
+ void QQuickControlPrivate::hideOldItem(QQuickItem *item)
+ {
+     if (!item)
+@@ -863,6 +870,29 @@ void QQuickControlPrivate::hideOldItem(QQuickItem *item)
+ #endif
+ }
+ 
++/*
++    \internal
++
++    Named "unhide" because it's used for cases where an item
++    that was previously hidden by \l hideOldItem() wants to be
++    shown by a control again, such as a ScrollBar in ScrollView.
++*/
++void QQuickControlPrivate::unhideOldItem(QQuickControl *control, QQuickItem *item)
++{
++    Q_ASSERT(item);
++    qCDebug(lcItemManagement) << "unhiding old item" << item;
++
++    item->setVisible(true);
++    item->setParentItem(control);
++
++#if QT_CONFIG(accessibility)
++    // Add the item back in to the accessibility tree.
++    QQuickAccessibleAttached *accessible = accessibleAttached(item);
++    if (accessible)
++        accessible->setIgnored(false);
++#endif
++}
++
+ void QQuickControlPrivate::updateBaselineOffset()
+ {
+     Q_Q(QQuickControl);
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h b/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
+index 8e979079e..a6e624c91 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
+@@ -173,6 +173,7 @@ public:
+     virtual void executeBackground(bool complete = false);
+ 
+     static void hideOldItem(QQuickItem *item);
++    static void unhideOldItem(QQuickControl *control, QQuickItem *item);
+ 
+     void updateBaselineOffset();
+ 
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp b/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
+index e6db14eb5..6197d1547 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
+@@ -237,7 +237,7 @@ static QRectF alignedRect(Qt::LayoutDirection direction, Qt::Alignment alignment
+ void QQuickDialogButtonBoxPrivate::resizeContent()
+ {
+     Q_Q(QQuickDialogButtonBox);
+-    if (!contentItem)
++    if (!contentItem || !contentModel)
+         return;
+ 
+     QRectF geometry = q->boundingRect().adjusted(q->leftPadding(), q->topPadding(), -q->rightPadding(), -q->bottomPadding());
+@@ -322,6 +322,9 @@ void QQuickDialogButtonBoxPrivate::updateLayout()
+ qreal QQuickDialogButtonBoxPrivate::getContentWidth() const
+ {
+     Q_Q(const QQuickDialogButtonBox);
++    if (!contentModel)
++        return 0;
++
+     const int count = contentModel->count();
+     const qreal totalSpacing = qMax(0, count - 1) * spacing;
+     qreal totalWidth = totalSpacing;
+@@ -341,6 +344,9 @@ qreal QQuickDialogButtonBoxPrivate::getContentWidth() const
+ qreal QQuickDialogButtonBoxPrivate::getContentHeight() const
+ {
+     Q_Q(const QQuickDialogButtonBox);
++    if (!contentModel)
++        return 0;
++
+     const int count = contentModel->count();
+     qreal maxHeight = 0;
+     for (int i = 0; i < count; ++i) {
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp b/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
+index 91bd59184..0ce518f84 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
+@@ -399,8 +399,11 @@ void QQuickOverlay::itemChange(ItemChange change, const ItemChangeData &data)
+     Q_D(QQuickOverlay);
+     QQuickItem::itemChange(change, data);
+ 
+-    if (change == ItemChildAddedChange || change == ItemChildRemovedChange)
++    if (change == ItemChildAddedChange || change == ItemChildRemovedChange) {
+         setVisible(!d->allDrawers.isEmpty() || !childItems().isEmpty());
++        if (data.item->parent() == d->mouseGrabberPopup)
++            d->setMouseGrabberPopup(nullptr);
++    }
+ }
+ 
+ void QQuickOverlay::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp b/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
+index 4e2f509db..1c4b308cd 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
+@@ -797,6 +797,14 @@ void QQuickScrollBarAttachedPrivate::initHorizontal()
+     if (parent && parent == flickable->parentItem())
+         horizontal->stackAfter(flickable);
+ 
++    // If a scroll bar was previously hidden (due to e.g. setting a new contentItem
++    // on a ScrollView), we need to make sure that we un-hide it.
++    // We don't bother checking if the item is actually the old one, because
++    // if it's not, all of the things the function does (setting parent, visibility, etc.)
++    // should be no-ops anyway.
++    if (auto control = qobject_cast<QQuickControl*>(q_ptr->parent()))
++        QQuickControlPrivate::unhideOldItem(control, horizontal);
++
+     layoutHorizontal();
+     horizontal->setSize(area->property("widthRatio").toReal());
+     horizontal->setPosition(area->property("xPosition").toReal());
+@@ -818,6 +826,9 @@ void QQuickScrollBarAttachedPrivate::initVertical()
+     if (parent && parent == flickable->parentItem())
+         vertical->stackAfter(flickable);
+ 
++    if (auto control = qobject_cast<QQuickControl*>(q_ptr->parent()))
++        QQuickControlPrivate::unhideOldItem(control, vertical);
++
+     layoutVertical();
+     vertical->setSize(area->property("heightRatio").toReal());
+     vertical->setPosition(area->property("yPosition").toReal());
+diff --git a/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml b/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
+index 0e8b08352..cd4931184 100644
+--- a/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
++++ b/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
+@@ -576,4 +576,51 @@ TestCase {
+         verify(newHorizontalScrollBar.visible)
+         verify(!oldHorizontalScrollBar.visible)
+     }
++
++    Component {
++        id: bindingToContentItemAndStandaloneFlickable
++
++        Item {
++            width: 200
++            height: 200
++
++            property alias scrollView: scrollView
++
++            ScrollView {
++                id: scrollView
++                anchors.fill: parent
++                contentItem: listView
++
++                property Item someBinding: contentItem
++            }
++            ListView {
++                id: listView
++                model: 10
++                delegate: ItemDelegate {
++                    text: modelData
++                    width: listView.width
++                }
++            }
++        }
++    }
++
++    // Tests that scroll bars show up for a ScrollView where
++    // - its contentItem is declared as a standalone, separate item
++    // - there is a binding to contentItem (which causes a default Flickable to be created)
++    function test_bindingToContentItemAndStandaloneFlickable() {
++        let root = createTemporaryObject(bindingToContentItemAndStandaloneFlickable, testCase)
++        verify(root)
++
++        let control = root.scrollView
++        let verticalScrollBar = control.ScrollBar.vertical
++        let horizontalScrollBar = control.ScrollBar.horizontal
++        compare(verticalScrollBar.parent, control)
++        compare(horizontalScrollBar.parent, control)
++        verify(verticalScrollBar.visible)
++        verify(horizontalScrollBar.visible)
++
++        mouseDrag(verticalScrollBar, verticalScrollBar.width / 2, verticalScrollBar.height / 2, 0, 50)
++        verify(verticalScrollBar.active)
++        verify(horizontalScrollBar.active)
++    }
+ }
+diff --git a/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml b/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
+index b3fab41ca..10b6baa02 100644
+--- a/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
++++ b/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
+@@ -608,4 +608,27 @@ TestCase {
+         mouseClick(control.indicator)
+         verify(control.activeFocus)
+     }
++
++    Component {
++        id: deletionOrder1
++        Item {
++            Image { id: innerImage }
++            Switch { indicator: innerImage }
++        }
++    }
++
++    Component {
++        id: deletionOrder2
++        Item {
++            Switch { indicator: innerImage }
++            Image { id: innerImage }
++        }
++    }
++
++    function test_deletionOrder() {
++        var control1 = createTemporaryObject(deletionOrder1, testCase)
++        verify(control1)
++        var control2 = createTemporaryObject(deletionOrder2, testCase)
++        verify(control2)
++    }
+ }
+diff --git a/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml b/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml
+new file mode 100644
+index 000000000..9e4598b9f
+--- /dev/null
++++ b/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml
+@@ -0,0 +1,78 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the test suite of the Qt Toolkit.
++**
++** $QT_BEGIN_LICENSE:BSD$
++** Commercial License Usage
++** Licensees holding valid commercial Qt licenses may use this file in
++** accordance with the commercial license agreement provided with the
++** Software or, alternatively, in accordance with the terms contained in
++** a written agreement between you and The Qt Company. For licensing terms
++** and conditions see https://www.qt.io/terms-conditions. For further
++** information use the contact form at https://www.qt.io/contact-us.
++**
++** BSD License Usage
++** Alternatively, you may use this file under the terms of the BSD license
++** as follows:
++**
++** "Redistribution and use in source and binary forms, with or without
++** modification, are permitted provided that the following conditions are
++** met:
++**   * Redistributions of source code must retain the above copyright
++**     notice, this list of conditions and the following disclaimer.
++**   * Redistributions in binary form must reproduce the above copyright
++**     notice, this list of conditions and the following disclaimer in
++**     the documentation and/or other materials provided with the
++**     distribution.
++**   * Neither the name of The Qt Company Ltd nor the names of its
++**     contributors may be used to endorse or promote products derived
++**     from this software without specific prior written permission.
++**
++**
++** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
++** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
++** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
++** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
++** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
++** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
++** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
++** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
++** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
++** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
++** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
++**
++** $QT_END_LICENSE$
++**
++****************************************************************************/
++
++import QtQuick 2.15
++import QtQuick.Controls 2.15
++
++ApplicationWindow {
++    id: window
++    width: 400
++    height: 400
++    title: "releaseAfterExitTransition"
++
++    property alias popup: popup
++    property alias modalPopup: modalPopup
++
++    Popup {
++        id: popup
++        y: parent.height - height
++        width: 50
++        height: 50
++    }
++
++    Popup {
++        id: modalPopup
++        modal: true
++        y: parent.height - height
++        width: 50
++        height: 50
++        exit:  Transition { PauseAnimation { duration: 100 } }
++    }
++}
+diff --git a/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp b/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
+index 54952d128..3d50e2dd4 100644
+--- a/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
++++ b/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
+@@ -100,6 +100,7 @@ private slots:
+     void invisibleToolTipOpen();
+     void centerInOverlayWithinStackViewItem();
+     void destroyDuringExitTransition();
++    void releaseAfterExitTransition();
+ };
+ 
+ void tst_QQuickPopup::initTestCase()
+@@ -1575,6 +1576,34 @@ void tst_QQuickPopup::destroyDuringExitTransition()
+     QVERIFY(!button->isDown());
+ }
+ 
++void tst_QQuickPopup::releaseAfterExitTransition()
++{
++    QQuickApplicationHelper helper(this, "releaseAfterExitTransition.qml");
++    QVERIFY2(helper.ready, helper.failureMessage());
++
++    QQuickWindow *window = helper.window;
++    window->show();
++    QVERIFY(QTest::qWaitForWindowActive(window));
++
++    QQuickOverlay *overlay = QQuickOverlay::overlay(window);
++    QQuickPopup *modalPopup = window->property("modalPopup").value<QQuickPopup *>();
++    QQuickPopup *popup = window->property("popup").value<QQuickPopup *>();
++
++    modalPopup->open();
++    QTRY_VERIFY(modalPopup->isOpened());
++
++    QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++    // wait until the transition is finished and the overlay hides itself
++    QTRY_VERIFY(!overlay->isVisible());
++    QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++
++    popup->open();
++    QTRY_VERIFY(popup->isOpened());
++    QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++    QTRY_VERIFY(!popup->isOpened());
++}
++
++
+ QTEST_QUICKCONTROLS_MAIN(tst_QQuickPopup)
+ 
+ #include "tst_qquickpopup.moc"
+Submodule qtscript 5be95f96...4d8e4bd2 (commits not present)
+Submodule qtspeech 17fc9fde..255845e2:
+diff --git a/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp b/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
+index 6eb74b8..bcc7dd1 100644
+--- a/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
++++ b/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
+@@ -357,7 +357,9 @@ QVector<QLocale> QTextToSpeechEngineSpeechd::availableLocales() const
+ 
+ QVector<QVoice> QTextToSpeechEngineSpeechd::availableVoices() const
+ {
+-    return m_voices.values(m_currentLocale.name()).toVector();
++    QList<QVoice> resultList = m_voices.values(m_currentLocale.name());
++    std::reverse(resultList.begin(), resultList.end());
++    return resultList.toVector();
+ }
+ 
+ // We have no way of knowing our own client_id since speech-dispatcher seems to be incomplete
+Submodule qtsvg 0c05780e..a7a0f249:
+diff --git a/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp b/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
+index 561e77e..12e0574 100644
+--- a/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
++++ b/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
+@@ -191,6 +191,8 @@ bool QSvgIOHandler::read(QImage *image)
+             }
+         }
+         if (!finalSize.isEmpty()) {
++            if (qMax(finalSize.width(), finalSize.height()) > 0xffff)
++                return false; // Assume corrupted file
+             image->fill(d->backColor.rgba());
+             QPainter p(image);
+             d->r.render(&p, bounds);
+diff --git a/qtsvg/src/svg/qsvghandler.cpp b/qtsvg/src/svg/qsvghandler.cpp
+index a5f877f..8dda563 100644
+--- a/qtsvg/src/svg/qsvghandler.cpp
++++ b/qtsvg/src/svg/qsvghandler.cpp
+@@ -1393,9 +1393,10 @@ static void parseFont(QSvgNode *node,
+         case FontSizeNone:
+             break;
+         case FontSizeValue: {
+-            QSvgHandler::LengthType dummy; // should always be pixel size
+-            fontStyle->setSize(qMin(parseLength(attributes.fontSize, dummy, handler),
+-                                    qreal(0xffff)));
++            QSvgHandler::LengthType type;
++            qreal fs = parseLength(attributes.fontSize, type, handler);
++            fs = convertToPixels(fs, true, type);
++            fontStyle->setSize(qMin(fs, qreal(0xffff)));
+         }
+             break;
+         default:
+@@ -2513,6 +2514,8 @@ static bool parseAnimateTransformNode(QSvgNode *parent,
+             ++s;
+         }
+     }
++    if (vals.count() % 3 != 0)
++        return false;
+ 
+     bool ok = true;
+     int begin = parseClockValue(beginStr, &ok);
+@@ -2576,6 +2579,8 @@ static QSvgNode *createCircleNode(QSvgNode *parent,
+     qreal ncx = toDouble(cx);
+     qreal ncy = toDouble(cy);
+     qreal nr  = toDouble(r);
++    if (nr < 0.0)
++        return nullptr;
+ 
+     QRectF rect(ncx-nr, ncy-nr, nr*2, nr*2);
+     QSvgNode *circle = new QSvgCircle(parent, rect);
+@@ -3046,15 +3051,16 @@ static QSvgStyleProperty *createRadialGradientNode(QSvgNode *node,
+ 
+     qreal ncx = 0.5;
+     qreal ncy = 0.5;
+-    qreal nr  = 0.5;
+     if (!cx.isEmpty())
+         ncx = toDouble(cx);
+     if (!cy.isEmpty())
+         ncy = toDouble(cy);
++
++    qreal nr = 0.0;
+     if (!r.isEmpty())
+         nr = toDouble(r);
+-    if (nr < 0.5)
+-        nr = 0.5;
++    if (nr <= 0.0)
++        return nullptr;
+ 
+     qreal nfx = ncx;
+     if (!fx.isEmpty())
+@@ -3350,7 +3356,9 @@ static QSvgNode *createTextNode(QSvgNode *parent,
+     //### editable and rotate not handled
+     QSvgHandler::LengthType type;
+     qreal nx = parseLength(x, type, handler);
++    nx = convertToPixels(nx, true, type);
+     qreal ny = parseLength(y, type, handler);
++    ny = convertToPixels(ny, true, type);
+ 
+     QSvgNode *text = new QSvgText(parent, QPointF(nx, ny));
+     return text;
+@@ -3691,9 +3699,7 @@ void QSvgHandler::parse()
+         case QXmlStreamReader::EndElement:
+             endElement(xml->name());
+             ++remainingUnfinishedElements;
+-            // if we are using somebody else's qxmlstreamreader
+-            // we should not read until the end of the stream
+-            done = !m_ownsReader && (xml->name() == QLatin1String("svg"));
++            done = (xml->name() == QLatin1String("svg"));
+             break;
+         case QXmlStreamReader::Characters:
+             characters(xml->text());
+diff --git a/qtsvg/src/svg/qsvgstructure.cpp b/qtsvg/src/svg/qsvgstructure.cpp
+index b89608b..89c9e4e 100644
+--- a/qtsvg/src/svg/qsvgstructure.cpp
++++ b/qtsvg/src/svg/qsvgstructure.cpp
+@@ -255,9 +255,13 @@ inline static bool isSupportedSvgFeature(const QString &str)
+     };
+ 
+     if (str.length() <= MAX_WORD_LENGTH && str.length() >= MIN_WORD_LENGTH) {
++        const char16_t unicode44 = str.at(44).unicode();
++        const char16_t unicode45 = str.at(45).unicode();
++        if (unicode44 >= sizeof(asso_values) || unicode45 >= sizeof(asso_values))
++            return false;
+         const int key = str.length()
+-                        + asso_values[str.at(45).unicode()]
+-                        + asso_values[str.at(44).unicode()];
++                        + asso_values[unicode45]
++                        + asso_values[unicode44];
+         if (key <= MAX_HASH_VALUE && key >= 0)
+             return str == QLatin1String(wordlist[key]);
+     }
+diff --git a/qtsvg/src/svg/qsvgtinydocument.cpp b/qtsvg/src/svg/qsvgtinydocument.cpp
+index 63d0797..19e7154 100644
+--- a/qtsvg/src/svg/qsvgtinydocument.cpp
++++ b/qtsvg/src/svg/qsvgtinydocument.cpp
+@@ -433,8 +433,16 @@ void QSvgTinyDocument::draw(QPainter *p, QSvgExtraStates &)
+     draw(p);
+ }
+ 
++static bool isValidMatrix(const QTransform &transform)
++{
++    qreal determinant = transform.determinant();
++    return qIsFinite(determinant);
++}
++
+ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect, const QRectF &sourceRect)
+ {
++    QTransform oldTransform = p->worldTransform();
++
+     QRectF target = targetRect;
+     if (target.isEmpty()) {
+         QPaintDevice *dev = p->device();
+@@ -487,6 +495,9 @@ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect,
+         }
+ #endif
+     }
++
++    if (!isValidMatrix(p->worldTransform()))
++        p->setWorldTransform(oldTransform);
+ }
+ 
+ QRectF QSvgTinyDocument::boundsOnElement(const QString &id) const
+diff --git a/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp b/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
+index 36c76ec..db71e02 100644
+--- a/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
++++ b/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
+@@ -86,6 +86,8 @@ private slots:
+     void oss_fuzz_23731();
+     void oss_fuzz_24131();
+     void oss_fuzz_24738();
++    void illegalAnimateTransform_data();
++    void illegalAnimateTransform();
+ 
+ #ifndef QT_NO_COMPRESS
+     void testGzLoading();
+@@ -1646,5 +1648,22 @@ void tst_QSvgRenderer::oss_fuzz_24738()
+     QSvgRenderer().load(QByteArray("<svg><path d=\"a 2 1e-212.....\">"));
+ }
+ 
++void tst_QSvgRenderer::illegalAnimateTransform_data()
++{
++    QTest::addColumn<QByteArray>("svg");
++
++    QTest::newRow("case1") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" values=\"8,0,5,0\">");
++    QTest::newRow("case2") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" values=\"1,2\">");
++    QTest::newRow("case3") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" from=\".. 5 2\" to=\"f\">");
++    QTest::newRow("case4") << QByteArray("<svg><animateTransform type=\"scale\" begin=\"1\" dur=\"2\" by=\"--,..\">");
++}
++
++void tst_QSvgRenderer::illegalAnimateTransform()
++{
++    QFETCH(QByteArray, svg);
++    QSvgRenderer renderer;
++    QVERIFY(!renderer.load(svg)); // also shouldn't assert
++}
++
+ QTEST_MAIN(tst_QSvgRenderer)
+ #include "tst_qsvgrenderer.moc"
+Submodule qttools 6914f7c8..090e526e:
+diff --git a/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp b/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
+index feab1e2d5..cbfb82507 100644
+--- a/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
++++ b/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
+@@ -445,7 +445,9 @@ bool HelpGeneratorPrivate::insertFiles(const QStringList &files, const QString &
+     if (filterSetId < 0)
+         return false;
+     ++filterSetId;
+-    for (int attId : qAsConst(filterAtts)) {
++    QList<int> attValues = filterAtts.values();
++    std::sort(attValues.begin(), attValues.end());
++    for (int attId : qAsConst(attValues)) {
+         m_query->prepare(QLatin1String("INSERT INTO FileAttributeSetTable "
+             "VALUES(?, ?)"));
+         m_query->bindValue(0, filterSetId);
+Submodule qtwayland dfb0129c..2904e1b3:
+diff --git a/qtwayland/src/client/configure.json b/qtwayland/src/client/configure.json
+index 2f424580..29222357 100644
+--- a/qtwayland/src/client/configure.json
++++ b/qtwayland/src/client/configure.json
+@@ -149,8 +149,7 @@
+                     "#endif"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "vulkan-server-buffer": {
+             "label": "Vulkan Buffer Sharing",
+@@ -168,7 +167,8 @@
+                     "exportAllocInfo.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR;",
+                     "return 0;"
+                 ]
+-            }
++            },
++            "use": "wayland-client"
+         },
+         "egl_1_5-wayland": {
+             "label": "EGL 1.5 with Wayland Platform",
+@@ -183,7 +183,7 @@
+                     "eglGetPlatformDisplay(EGL_PLATFORM_WAYLAND_EXT, (struct wl_display *)(nullptr), nullptr);"
+                 ]
+             },
+-            "use": "egl"
++            "use": "egl wayland-client"
+         }
+     },
+ 
+diff --git a/qtwayland/src/client/global/qwaylandclientextension.cpp b/qtwayland/src/client/global/qwaylandclientextension.cpp
+index 125b1e19..edccfe63 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension.cpp
++++ b/qtwayland/src/client/global/qwaylandclientextension.cpp
+@@ -74,7 +74,10 @@ void QWaylandClientExtensionPrivate::handleRegistryGlobal(void *data, ::wl_regis
+ void QWaylandClientExtension::addRegistryListener()
+ {
+     Q_D(QWaylandClientExtension);
+-    d->waylandIntegration->display()->addRegistryListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++    if (!d->registered) {
++        d->waylandIntegration->display()->addRegistryListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++        d->registered = true;
++    }
+ }
+ 
+ QWaylandClientExtension::QWaylandClientExtension(const int ver)
+@@ -88,6 +91,13 @@ QWaylandClientExtension::QWaylandClientExtension(const int ver)
+     QMetaObject::invokeMethod(this, "addRegistryListener", Qt::QueuedConnection);
+ }
+ 
++QWaylandClientExtension::~QWaylandClientExtension()
++{
++    Q_D(QWaylandClientExtension);
++    if (d->registered && !QCoreApplication::closingDown())
++        d->waylandIntegration->display()->removeListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++}
++
+ QtWaylandClient::QWaylandIntegration *QWaylandClientExtension::integration() const
+ {
+     Q_D(const QWaylandClientExtension);
+diff --git a/qtwayland/src/client/global/qwaylandclientextension.h b/qtwayland/src/client/global/qwaylandclientextension.h
+index 98272e57..5bd28398 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension.h
++++ b/qtwayland/src/client/global/qwaylandclientextension.h
+@@ -63,6 +63,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandClientExtension : public QObject
+     Q_PROPERTY(bool active READ isActive NOTIFY activeChanged)
+ public:
+     QWaylandClientExtension(const int version);
++    ~QWaylandClientExtension();
+ 
+     QtWaylandClient::QWaylandIntegration *integration() const;
+     int version() const;
+diff --git a/qtwayland/src/client/global/qwaylandclientextension_p.h b/qtwayland/src/client/global/qwaylandclientextension_p.h
+index 69cc46a0..9091efbe 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension_p.h
++++ b/qtwayland/src/client/global/qwaylandclientextension_p.h
+@@ -68,6 +68,7 @@ public:
+     QtWaylandClient::QWaylandIntegration *waylandIntegration = nullptr;
+     int version = -1;
+     bool active = false;
++    bool registered = false;
+ };
+ 
+ class Q_WAYLAND_CLIENT_EXPORT QWaylandClientExtensionTemplatePrivate : public QWaylandClientExtensionPrivate
+diff --git a/qtwayland/src/client/qwaylanddatadevice.cpp b/qtwayland/src/client/qwaylanddatadevice.cpp
+index 7e2e3308..e3e60ed5 100644
+--- a/qtwayland/src/client/qwaylanddatadevice.cpp
++++ b/qtwayland/src/client/qwaylanddatadevice.cpp
+@@ -72,6 +72,8 @@ QWaylandDataDevice::QWaylandDataDevice(QWaylandDataDeviceManager *manager, QWayl
+ 
+ QWaylandDataDevice::~QWaylandDataDevice()
+ {
++    if (wl_data_device_get_version(object()) >= WL_DATA_DEVICE_RELEASE_SINCE_VERSION)
++        release();
+ }
+ 
+ QWaylandDataOffer *QWaylandDataDevice::selectionOffer() const
+@@ -110,7 +112,7 @@ QWaylandDataOffer *QWaylandDataDevice::dragOffer() const
+     return m_dragOffer.data();
+ }
+ 
+-bool QWaylandDataDevice::startDrag(QMimeData *mimeData, QWaylandWindow *icon)
++bool QWaylandDataDevice::startDrag(QMimeData *mimeData, Qt::DropActions supportedActions, QWaylandWindow *icon)
+ {
+     auto *seat = m_display->currentInputDevice();
+     auto *origin = seat->pointerFocus();
+@@ -123,7 +125,28 @@ bool QWaylandDataDevice::startDrag(QMimeData *mimeData, QWaylandWindow *icon)
+     }
+ 
+     m_dragSource.reset(new QWaylandDataSource(m_display->dndSelectionHandler(), mimeData));
++
++    if (wl_data_device_get_version(object()) >= 3)
++        m_dragSource->set_actions(dropActionsToWl(supportedActions));
++
+     connect(m_dragSource.data(), &QWaylandDataSource::cancelled, this, &QWaylandDataDevice::dragSourceCancelled);
++    connect(m_dragSource.data(), &QWaylandDataSource::dndResponseUpdated, this, [this](bool accepted, Qt::DropAction action) {
++            auto drag = static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag());
++            // in old versions drop action is not set, so we guess
++            if (wl_data_source_get_version(m_dragSource->object()) < 3) {
++                drag->setResponse(accepted);
++            } else {
++                QPlatformDropQtResponse response(accepted, action);
++                drag->setResponse(response);
++            }
++    });
++    connect(m_dragSource.data(), &QWaylandDataSource::dndDropped, this, [](bool accepted, Qt::DropAction action) {
++        QPlatformDropQtResponse response(accepted, action);
++        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setDropResponse(response);
++    });
++    connect(m_dragSource.data(), &QWaylandDataSource::finished, this, []() {
++        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag();
++    });
+ 
+     start_drag(m_dragSource->object(), origin->wlSurface(), icon->wlSurface(), m_display->currentInputDevice()->serial());
+     return true;
+@@ -152,7 +175,7 @@ void QWaylandDataDevice::data_device_drop()
+         supportedActions = drag->supportedActions();
+     } else if (m_dragOffer) {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     } else {
+         return;
+     }
+@@ -162,7 +185,11 @@ void QWaylandDataDevice::data_device_drop()
+                                                                           QGuiApplication::keyboardModifiers());
+ 
+     if (drag) {
+-        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag(response);
++        auto drag =  static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag());
++        drag->setDropResponse(response);
++        drag->finishDrag();
++    } else if (m_dragOffer) {
++        m_dragOffer->finish();
+     }
+ }
+ 
+@@ -186,7 +213,7 @@ void QWaylandDataDevice::data_device_enter(uint32_t serial, wl_surface *surface,
+         supportedActions = drag->supportedActions();
+     } else if (m_dragOffer) {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     }
+ 
+     const QPlatformDragQtResponse &response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
+@@ -197,11 +224,7 @@ void QWaylandDataDevice::data_device_enter(uint32_t serial, wl_surface *surface,
+         static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setResponse(response);
+     }
+ 
+-    if (response.isAccepted()) {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, m_dragOffer->firstFormat().toUtf8().constData());
+-    } else {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, nullptr);
+-    }
++    sendResponse(supportedActions, response);
+ }
+ 
+ void QWaylandDataDevice::data_device_leave()
+@@ -235,10 +258,10 @@ void QWaylandDataDevice::data_device_motion(uint32_t time, wl_fixed_t x, wl_fixe
+         supportedActions = drag->supportedActions();
+     } else {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     }
+ 
+-    QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
++    const QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
+                                                                           QGuiApplication::mouseButtons(),
+                                                                           QGuiApplication::keyboardModifiers());
+ 
+@@ -246,11 +269,7 @@ void QWaylandDataDevice::data_device_motion(uint32_t time, wl_fixed_t x, wl_fixe
+         static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setResponse(response);
+     }
+ 
+-    if (response.isAccepted()) {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, m_dragOffer->firstFormat().toUtf8().constData());
+-    } else {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, nullptr);
+-    }
++    sendResponse(supportedActions, response);
+ }
+ #endif // QT_CONFIG(draganddrop)
+ 
+@@ -277,14 +296,10 @@ void QWaylandDataDevice::selectionSourceCancelled()
+ #if QT_CONFIG(draganddrop)
+ void QWaylandDataDevice::dragSourceCancelled()
+ {
++    static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag();
+     m_dragSource.reset();
+ }
+ 
+-void QWaylandDataDevice::dragSourceTargetChanged(const QString &mimeType)
+-{
+-    static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->updateTarget(mimeType);
+-}
+-
+ QPoint QWaylandDataDevice::calculateDragPosition(int x, int y, QWindow *wnd) const
+ {
+     QPoint pnt(wl_fixed_to_int(x), wl_fixed_to_int(y));
+@@ -297,6 +312,33 @@ QPoint QWaylandDataDevice::calculateDragPosition(int x, int y, QWindow *wnd) con
+     }
+     return pnt;
+ }
++
++void QWaylandDataDevice::sendResponse(Qt::DropActions supportedActions, const QPlatformDragQtResponse &response)
++{
++    if (response.isAccepted()) {
++        if (wl_data_device_get_version(object()) >= 3)
++            m_dragOffer->set_actions(dropActionsToWl(supportedActions), dropActionsToWl(response.acceptedAction()));
++
++        m_dragOffer->accept(m_enterSerial, m_dragOffer->firstFormat());
++    } else {
++        m_dragOffer->accept(m_enterSerial, QString());
++    }
++}
++
++int QWaylandDataDevice::dropActionsToWl(Qt::DropActions actions)
++{
++
++    int wlActions = WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE;
++    if (actions & Qt::CopyAction)
++        wlActions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY;
++    if (actions & (Qt::MoveAction | Qt::TargetMoveAction))
++        wlActions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE;
++
++    // wayland does not support LinkAction at the time of writing
++    return wlActions;
++}
++
++
+ #endif // QT_CONFIG(draganddrop)
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddatadevice_p.h b/qtwayland/src/client/qwaylanddatadevice_p.h
+index 16c3ad28..801dcc2c 100644
+--- a/qtwayland/src/client/qwaylanddatadevice_p.h
++++ b/qtwayland/src/client/qwaylanddatadevice_p.h
+@@ -64,6 +64,7 @@ QT_REQUIRE_CONFIG(wayland_datadevice);
+ QT_BEGIN_NAMESPACE
+ 
+ class QMimeData;
++class QPlatformDragQtResponse;
+ class QWindow;
+ 
+ namespace QtWaylandClient {
+@@ -89,7 +90,7 @@ public:
+ 
+ #if QT_CONFIG(draganddrop)
+     QWaylandDataOffer *dragOffer() const;
+-    bool startDrag(QMimeData *mimeData, QWaylandWindow *icon);
++    bool startDrag(QMimeData *mimeData, Qt::DropActions supportedActions, QWaylandWindow *icon);
+     void cancelDrag();
+ #endif
+ 
+@@ -109,13 +110,16 @@ private Q_SLOTS:
+ 
+ #if QT_CONFIG(draganddrop)
+     void dragSourceCancelled();
+-    void dragSourceTargetChanged(const QString &mimeType);
+ #endif
+ 
+ private:
+ #if QT_CONFIG(draganddrop)
+     QPoint calculateDragPosition(int x, int y, QWindow *wnd) const;
+ #endif
++    void sendResponse(Qt::DropActions supportedActions, const QPlatformDragQtResponse &response);
++
++    static int dropActionsToWl(Qt::DropActions dropActions);
++
+ 
+     QWaylandDisplay *m_display = nullptr;
+     QWaylandInputDevice *m_inputDevice = nullptr;
+diff --git a/qtwayland/src/client/qwaylanddatadevicemanager.cpp b/qtwayland/src/client/qwaylanddatadevicemanager.cpp
+index 35d67307..6dc4f77f 100644
+--- a/qtwayland/src/client/qwaylanddatadevicemanager.cpp
++++ b/qtwayland/src/client/qwaylanddatadevicemanager.cpp
+@@ -50,8 +50,8 @@ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
+-QWaylandDataDeviceManager::QWaylandDataDeviceManager(QWaylandDisplay *display, uint32_t id)
+-    : wl_data_device_manager(display->wl_registry(), id, 1)
++QWaylandDataDeviceManager::QWaylandDataDeviceManager(QWaylandDisplay *display, int version, uint32_t id)
++    : wl_data_device_manager(display->wl_registry(), id, qMin(version, 3))
+     , m_display(display)
+ {
+     // Create transfer devices for all input devices.
+diff --git a/qtwayland/src/client/qwaylanddatadevicemanager_p.h b/qtwayland/src/client/qwaylanddatadevicemanager_p.h
+index bd05c0fb..510d9be4 100644
+--- a/qtwayland/src/client/qwaylanddatadevicemanager_p.h
++++ b/qtwayland/src/client/qwaylanddatadevicemanager_p.h
+@@ -68,7 +68,7 @@ class QWaylandInputDevice;
+ class Q_WAYLAND_CLIENT_EXPORT QWaylandDataDeviceManager : public QtWayland::wl_data_device_manager
+ {
+ public:
+-    QWaylandDataDeviceManager(QWaylandDisplay *display, uint32_t id);
++    QWaylandDataDeviceManager(QWaylandDisplay *display, int version, uint32_t id);
+     ~QWaylandDataDeviceManager() override;
+ 
+     QWaylandDataDevice *getDataDevice(QWaylandInputDevice *inputDevice);
+diff --git a/qtwayland/src/client/qwaylanddataoffer.cpp b/qtwayland/src/client/qwaylanddataoffer.cpp
+index 2297e8a1..fe0ea8c9 100644
+--- a/qtwayland/src/client/qwaylanddataoffer.cpp
++++ b/qtwayland/src/client/qwaylanddataoffer.cpp
+@@ -82,6 +82,15 @@ QMimeData *QWaylandDataOffer::mimeData()
+     return m_mimeData.data();
+ }
+ 
++Qt::DropActions QWaylandDataOffer::supportedActions() const
++{
++    if (wl_data_offer_get_version(const_cast<::wl_data_offer*>(object())) < 3) {
++        return Qt::MoveAction | Qt::CopyAction;
++    }
++
++    return m_supportedActions;
++}
++
+ void QWaylandDataOffer::startReceiving(const QString &mimeType, int fd)
+ {
+     receive(mimeType, fd);
+@@ -93,6 +102,22 @@ void QWaylandDataOffer::data_offer_offer(const QString &mime_type)
+     m_mimeData->appendFormat(mime_type);
+ }
+ 
++void QWaylandDataOffer::data_offer_action(uint32_t dnd_action)
++{
++    Q_UNUSED(dnd_action);
++    // This is the compositor telling the drag target what action it should perform
++    // It does not map nicely into Qt final drop semantics, other than pretending there is only one supported action?
++}
++
++void QWaylandDataOffer::data_offer_source_actions(uint32_t source_actions)
++{
++    m_supportedActions = Qt::DropActions();
++    if (source_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
++        m_supportedActions |= Qt::MoveAction;
++    if (source_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
++        m_supportedActions |= Qt::CopyAction;
++}
++
+ QWaylandMimeData::QWaylandMimeData(QWaylandAbstractDataOffer *dataOffer)
+     : m_dataOffer(dataOffer)
+ {
+@@ -163,17 +188,18 @@ QVariant QWaylandMimeData::retrieveData_sys(const QString &mimeType, QVariant::T
+ 
+ int QWaylandMimeData::readData(int fd, QByteArray &data) const
+ {
+-    fd_set readset;
+-    FD_ZERO(&readset);
+-    FD_SET(fd, &readset);
+-    struct timeval timeout;
++    struct pollfd readset;
++    readset.fd = fd;
++    readset.events = POLLIN;
++    struct timespec timeout;
+     timeout.tv_sec = 1;
+-    timeout.tv_usec = 0;
++    timeout.tv_nsec = 0;
++
+ 
+     Q_FOREVER {
+-        int ready = select(FD_SETSIZE, &readset, nullptr, nullptr, &timeout);
++        int ready = qt_safe_poll(&readset, 1, &timeout);
+         if (ready < 0) {
+-            qWarning() << "QWaylandDataOffer: select() failed";
++            qWarning() << "QWaylandDataOffer: qt_safe_poll() failed";
+             return -1;
+         } else if (ready == 0) {
+             qWarning("QWaylandDataOffer: timeout reading from pipe");
+diff --git a/qtwayland/src/client/qwaylanddataoffer_p.h b/qtwayland/src/client/qwaylanddataoffer_p.h
+index 9cf1483c..6f667398 100644
+--- a/qtwayland/src/client/qwaylanddataoffer_p.h
++++ b/qtwayland/src/client/qwaylanddataoffer_p.h
+@@ -82,6 +82,7 @@ public:
+     explicit QWaylandDataOffer(QWaylandDisplay *display, struct ::wl_data_offer *offer);
+     ~QWaylandDataOffer() override;
+     QMimeData *mimeData() override;
++    Qt::DropActions supportedActions() const;
+ 
+     QString firstFormat() const;
+ 
+@@ -89,10 +90,13 @@ public:
+ 
+ protected:
+     void data_offer_offer(const QString &mime_type) override;
++    void data_offer_source_actions(uint32_t source_actions) override;
++    void data_offer_action(uint32_t dnd_action) override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+     QScopedPointer<QWaylandMimeData> m_mimeData;
++    Qt::DropActions m_supportedActions;
+ };
+ 
+ 
+diff --git a/qtwayland/src/client/qwaylanddatasource.cpp b/qtwayland/src/client/qwaylanddatasource.cpp
+index f45122fb..5599cbd4 100644
+--- a/qtwayland/src/client/qwaylanddatasource.cpp
++++ b/qtwayland/src/client/qwaylanddatasource.cpp
+@@ -101,7 +101,32 @@ void QWaylandDataSource::data_source_send(const QString &mime_type, int32_t fd)
+ 
+ void QWaylandDataSource::data_source_target(const QString &mime_type)
+ {
+-    Q_EMIT targetChanged(mime_type);
++    m_accepted = !mime_type.isEmpty();
++    Q_EMIT dndResponseUpdated(m_accepted, m_dropAction);
++}
++
++void QWaylandDataSource::data_source_action(uint32_t action)
++{
++    Qt::DropAction qtAction = Qt::IgnoreAction;
++
++    if (action == WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
++        qtAction = Qt::MoveAction;
++    else if (action == WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
++        qtAction = Qt::CopyAction;
++
++    m_dropAction = qtAction;
++    Q_EMIT dndResponseUpdated(m_accepted, m_dropAction);
++}
++
++void QWaylandDataSource::data_source_dnd_finished()
++{
++    Q_EMIT finished();
++}
++
++void QWaylandDataSource::data_source_dnd_drop_performed()
++{
++
++    Q_EMIT dndDropped(m_accepted, m_dropAction);
+ }
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddatasource_p.h b/qtwayland/src/client/qwaylanddatasource_p.h
+index 25afff79..96f07bc3 100644
+--- a/qtwayland/src/client/qwaylanddatasource_p.h
++++ b/qtwayland/src/client/qwaylanddatasource_p.h
+@@ -77,17 +77,25 @@ public:
+     QMimeData *mimeData() const;
+ 
+ Q_SIGNALS:
+-    void targetChanged(const QString &mime_type);
+     void cancelled();
++    void finished();
++
++    void dndResponseUpdated(bool accepted, Qt::DropAction action);
++    void dndDropped(bool accepted, Qt::DropAction action);
+ 
+ protected:
+     void data_source_cancelled() override;
+     void data_source_send(const QString &mime_type, int32_t fd) override;
+     void data_source_target(const QString &mime_type) override;
++    void data_source_dnd_drop_performed() override;
++    void data_source_dnd_finished() override;
++    void data_source_action(uint32_t action) override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+     QMimeData *m_mime_data = nullptr;
++    bool m_accepted = false;
++    Qt::DropAction m_dropAction = Qt::IgnoreAction;
+ };
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddisplay.cpp b/qtwayland/src/client/qwaylanddisplay.cpp
+index f10c1f79..c01e238b 100644
+--- a/qtwayland/src/client/qwaylanddisplay.cpp
++++ b/qtwayland/src/client/qwaylanddisplay.cpp
+@@ -85,10 +85,203 @@
+ 
+ #include <errno.h>
+ 
++#include <tuple> // for std::tie
++
++static void checkWaylandError(struct wl_display *display)
++{
++    int ecode = wl_display_get_error(display);
++    if ((ecode == EPIPE || ecode == ECONNRESET)) {
++        // special case this to provide a nicer error
++        qWarning("The Wayland connection broke. Did the Wayland compositor die?");
++    } else {
++        qWarning("The Wayland connection experienced a fatal error: %s", strerror(ecode));
++    }
++    _exit(1);
++}
++
+ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
++class EventThread : public QThread
++{
++    Q_OBJECT
++public:
++    enum OperatingMode {
++        EmitToDispatch, // Emit the signal, allow dispatching in a differnt thread.
++        SelfDispatch, // Dispatch the events inside this thread.
++    };
++
++    EventThread(struct wl_display * wl, struct wl_event_queue * ev_queue,
++                OperatingMode mode)
++        : m_fd(wl_display_get_fd(wl))
++        , m_pipefd{ -1, -1 }
++        , m_wldisplay(wl)
++        , m_wlevqueue(ev_queue)
++        , m_mode(mode)
++        , m_reading(true)
++        , m_quitting(false)
++    {
++        setObjectName(QStringLiteral("WaylandEventThread"));
++    }
++
++    void readAndDispatchEvents()
++    {
++        /*
++         * Dispatch pending events and flush the requests at least once. If the event thread
++         * is not reading, try to call _prepare_read() to allow the event thread to poll().
++         * If that fails, re-try dispatch & flush again until _prepare_read() is successful.
++         *
++         * This allow any call to readAndDispatchEvents() to start event thread's polling,
++         * not only the one issued from event thread's waitForReading(), which means functions
++         * called from dispatch_pending() can safely spin an event loop.
++         */
++        for (;;) {
++            if (dispatchQueuePending() < 0) {
++                checkWaylandError(m_wldisplay);
++                return;
++            }
++
++            wl_display_flush(m_wldisplay);
++
++            // We have to check if event thread is reading every time we dispatch
++            // something, as that may recursively call this function.
++            if (m_reading.loadAcquire())
++                break;
++
++            if (prepareReadQueue() == 0) {
++                QMutexLocker l(&m_mutex);
++                m_reading.storeRelease(true);
++                m_cond.wakeOne();
++                break;
++            }
++        }
++    }
++
++    void stop()
++    {
++        // We have to both write to the pipe and set the flag, as the thread may be
++        // either in the poll() or waiting for _prepare_read().
++        if (m_pipefd[1] != -1 && write(m_pipefd[1], "\0", 1) == -1)
++            qWarning("Failed to write to the pipe: %s.", strerror(errno));
++
++        {
++            QMutexLocker l(&m_mutex);
++            m_quitting = true;
++            m_cond.wakeOne();
++        }
++
++        wait();
++    }
++
++Q_SIGNALS:
++    void needReadAndDispatch();
++
++protected:
++    void run() override
++    {
++        // we use this pipe to make the loop exit otherwise if we simply used a flag on the loop condition, if stop() gets
++        // called while poll() is blocking the thread will never quit since there are no wayland messages coming anymore.
++        struct Pipe
++        {
++            Pipe(int *fds)
++                : fds(fds)
++            {
++                if (qt_safe_pipe(fds) != 0)
++                    qWarning("Pipe creation failed. Quitting may hang.");
++            }
++            ~Pipe()
++            {
++                if (fds[0] != -1) {
++                    close(fds[0]);
++                    close(fds[1]);
++                }
++            }
++
++            int *fds;
++        } pipe(m_pipefd);
++
++        // Make the main thread call wl_prepare_read(), dispatch the pending messages and flush the
++        // outbound ones. Wait until it's done before proceeding, unless we're told to quit.
++        while (waitForReading()) {
++            pollfd fds[2] = { { m_fd, POLLIN, 0 }, { m_pipefd[0], POLLIN, 0 } };
++            poll(fds, 2, -1);
++
++            if (fds[1].revents & POLLIN) {
++                // we don't really care to read the byte that was written here since we're closing down
++                wl_display_cancel_read(m_wldisplay);
++                break;
++            }
++
++            if (fds[0].revents & POLLIN)
++                wl_display_read_events(m_wldisplay);
++                // The polll was succesfull and the event thread did the wl_display_read_events(). On the next iteration of the loop
++                // the event sent to the main thread will cause it to dispatch the messages just read, unless the loop exits in which
++                // case we don't care anymore about them.
++            else
++                wl_display_cancel_read(m_wldisplay);
++        }
++    }
++
++private:
++    bool waitForReading()
++    {
++        Q_ASSERT(QThread::currentThread() == this);
++
++        m_reading.storeRelease(false);
++
++        if (m_mode == SelfDispatch) {
++            readAndDispatchEvents();
++        } else {
++            Q_EMIT needReadAndDispatch();
++
++            QMutexLocker lock(&m_mutex);
++            // m_reading might be set from our emit or some other invocation of
++            // readAndDispatchEvents().
++            while (!m_reading.loadRelaxed() && !m_quitting)
++                m_cond.wait(&m_mutex);
++        }
++
++        return !m_quitting;
++    }
++
++    int dispatchQueuePending()
++    {
++        if (m_wlevqueue)
++            return wl_display_dispatch_queue_pending(m_wldisplay, m_wlevqueue);
++        else
++            return wl_display_dispatch_pending(m_wldisplay);
++    }
++
++    int prepareReadQueue()
++    {
++        if (m_wlevqueue)
++            return wl_display_prepare_read_queue(m_wldisplay, m_wlevqueue);
++        else
++            return wl_display_prepare_read(m_wldisplay);
++    }
++
++    int m_fd;
++    int m_pipefd[2];
++    wl_display *m_wldisplay;
++    wl_event_queue *m_wlevqueue;
++    OperatingMode m_mode;
++
++    /* Concurrency note when operating in EmitToDispatch mode:
++     * m_reading is set to false inside event thread's waitForReading(), and is
++     * set to true inside main thread's readAndDispatchEvents().
++     * The lock is not taken when setting m_reading to false, as the main thread
++     * is not actively waiting for it to turn false. However, the lock is taken
++     * inside readAndDispatchEvents() before setting m_reading to true,
++     * as the event thread is actively waiting for it under the wait condition.
++     */
++
++    QAtomicInteger<bool> m_reading;
++    bool m_quitting;
++    QMutex m_mutex;
++    QWaitCondition m_cond;
++};
++
+ Q_LOGGING_CATEGORY(lcQpaWayland, "qt.qpa.wayland"); // for general (uncategorized) Wayland platform logging
+ 
+ struct wl_surface *QWaylandDisplay::createSurface(void *handle)
+@@ -158,17 +351,16 @@ QWaylandDisplay::QWaylandDisplay(QWaylandIntegration *waylandIntegration)
+     if (!mXkbContext)
+         qCWarning(lcQpaWayland, "failed to create xkb context");
+ #endif
+-
+-    forceRoundTrip();
+-
+-    if (!mWaitingScreens.isEmpty()) {
+-        // Give wl_output.done and zxdg_output_v1.done events a chance to arrive
+-        forceRoundTrip();
+-    }
+ }
+ 
+ QWaylandDisplay::~QWaylandDisplay(void)
+ {
++    if (m_eventThread)
++        m_eventThread->stop();
++
++    if (m_frameEventQueueThread)
++        m_frameEventQueueThread->stop();
++
+     if (mSyncCallback)
+         wl_callback_destroy(mSyncCallback);
+ 
+@@ -187,6 +379,21 @@ QWaylandDisplay::~QWaylandDisplay(void)
+ #endif
+     if (mDisplay)
+         wl_display_disconnect(mDisplay);
++
++    if (m_frameEventQueue)
++        wl_event_queue_destroy(m_frameEventQueue);
++}
++
++// Steps which is called just after constructor. This separates registry_global() out of the constructor
++// so that factory functions in integration can be overridden.
++void QWaylandDisplay::initialize()
++{
++    forceRoundTrip();
++
++    if (!mWaitingScreens.isEmpty()) {
++        // Give wl_output.done and zxdg_output_v1.done events a chance to arrive
++        forceRoundTrip();
++    }
+ }
+ 
+ void QWaylandDisplay::ensureScreen()
+@@ -203,98 +410,37 @@ void QWaylandDisplay::ensureScreen()
+ 
+ void QWaylandDisplay::checkError() const
+ {
+-    int ecode = wl_display_get_error(mDisplay);
+-    if ((ecode == EPIPE || ecode == ECONNRESET)) {
+-        // special case this to provide a nicer error
+-        qWarning("The Wayland connection broke. Did the Wayland compositor die?");
+-    } else {
+-        qWarning("The Wayland connection experienced a fatal error: %s", strerror(ecode));
+-    }
+-    _exit(1);
++    checkWaylandError(mDisplay);
+ }
+ 
++// Called in main thread, either from queued signal or directly.
+ void QWaylandDisplay::flushRequests()
+ {
+-    if (wl_display_prepare_read(mDisplay) == 0) {
+-        wl_display_read_events(mDisplay);
+-    }
+-
+-    if (wl_display_dispatch_pending(mDisplay) < 0)
+-        checkError();
+-
+-    {
+-        QReadLocker locker(&m_frameQueueLock);
+-        for (const FrameQueue &q : mExternalQueues) {
+-            QMutexLocker locker(q.mutex);
+-            while (wl_display_prepare_read_queue(mDisplay, q.queue) != 0)
+-                wl_display_dispatch_queue_pending(mDisplay, q.queue);
+-            wl_display_read_events(mDisplay);
+-            wl_display_dispatch_queue_pending(mDisplay, q.queue);
+-        }
+-    }
+-
+-    wl_display_flush(mDisplay);
+-}
+-
+-void QWaylandDisplay::blockingReadEvents()
+-{
+-    if (wl_display_dispatch(mDisplay) < 0)
+-        checkError();
+-}
+-
+-void QWaylandDisplay::destroyFrameQueue(const QWaylandDisplay::FrameQueue &q)
+-{
+-    QWriteLocker locker(&m_frameQueueLock);
+-    auto it = std::find_if(mExternalQueues.begin(),
+-                           mExternalQueues.end(),
+-                           [&q] (const QWaylandDisplay::FrameQueue &other){ return other.queue == q.queue; });
+-    Q_ASSERT(it != mExternalQueues.end());
+-    mExternalQueues.erase(it);
+-    if (q.queue != nullptr)
+-        wl_event_queue_destroy(q.queue);
+-    delete q.mutex;
++    m_eventThread->readAndDispatchEvents();
+ }
+ 
+-QWaylandDisplay::FrameQueue QWaylandDisplay::createFrameQueue()
++// We have to wait until we have an eventDispatcher before creating the eventThread,
++// otherwise forceRoundTrip() may block inside _events_read() because eventThread is
++// polling.
++void QWaylandDisplay::initEventThread()
+ {
+-    QWriteLocker locker(&m_frameQueueLock);
+-    FrameQueue q{createEventQueue()};
+-    mExternalQueues.append(q);
+-    return q;
+-}
++    m_eventThread.reset(
++            new EventThread(mDisplay, /* default queue */ nullptr, EventThread::EmitToDispatch));
++    connect(m_eventThread.get(), &EventThread::needReadAndDispatch, this,
++            &QWaylandDisplay::flushRequests, Qt::QueuedConnection);
++    m_eventThread->start();
+ 
+-wl_event_queue *QWaylandDisplay::createEventQueue()
+-{
+-    return wl_display_create_queue(mDisplay);
++    // wl_display_disconnect() free this.
++    m_frameEventQueue = wl_display_create_queue(mDisplay);
++    m_frameEventQueueThread.reset(
++            new EventThread(mDisplay, m_frameEventQueue, EventThread::SelfDispatch));
++    m_frameEventQueueThread->start();
+ }
+ 
+-void QWaylandDisplay::dispatchQueueWhile(wl_event_queue *queue, std::function<bool ()> condition, int timeout)
++void QWaylandDisplay::blockingReadEvents()
+ {
+-    if (!condition())
+-        return;
+-
+-    QElapsedTimer timer;
+-    timer.start();
+-    struct pollfd pFd = qt_make_pollfd(wl_display_get_fd(mDisplay), POLLIN);
+-    while (timeout == -1 || timer.elapsed() < timeout) {
+-        while (wl_display_prepare_read_queue(mDisplay, queue) != 0)
+-            wl_display_dispatch_queue_pending(mDisplay, queue);
+-
+-        wl_display_flush(mDisplay);
+-
+-        const int remaining = qMax(timeout - timer.elapsed(), 0ll);
+-        const int pollTimeout = timeout == -1 ? -1 : remaining;
+-        if (qt_poll_msecs(&pFd, 1, pollTimeout) > 0)
+-            wl_display_read_events(mDisplay);
+-        else
+-            wl_display_cancel_read(mDisplay);
+-
+-        if (wl_display_dispatch_queue_pending(mDisplay, queue) < 0)
+-            checkError();
+-
+-        if (!condition())
+-            break;
+-    }
++    if (wl_display_dispatch(mDisplay) < 0)
++        checkWaylandError(mDisplay);
+ }
+ 
+ QWaylandScreen *QWaylandDisplay::screenForOutput(struct wl_output *output) const
+@@ -345,7 +491,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+     if (interface == QStringLiteral("wl_output")) {
+         mWaitingScreens << new QWaylandScreen(this, version, id);
+     } else if (interface == QStringLiteral("wl_compositor")) {
+-        mCompositorVersion = qMin((int)version, 3);
++        mCompositorVersion = qMin((int)version, 4);
+         mCompositor.init(registry, id, mCompositorVersion);
+     } else if (interface == QStringLiteral("wl_shm")) {
+         mShm.reset(new QWaylandShm(this, version, id));
+@@ -354,7 +500,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+         mInputDevices.append(inputDevice);
+ #if QT_CONFIG(wayland_datadevice)
+     } else if (interface == QStringLiteral("wl_data_device_manager")) {
+-        mDndSelectionHandler.reset(new QWaylandDataDeviceManager(this, id));
++        mDndSelectionHandler.reset(new QWaylandDataDeviceManager(this, version, id));
+ #endif
+     } else if (interface == QStringLiteral("qt_surface_extension")) {
+         mWindowExtension.reset(new QtWayland::qt_surface_extension(registry, id, 1));
+@@ -369,6 +515,8 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+ #if QT_CONFIG(wayland_client_primary_selection)
+     } else if (interface == QStringLiteral("zwp_primary_selection_device_manager_v1")) {
+         mPrimarySelectionManager.reset(new QWaylandPrimarySelectionDeviceManagerV1(this, id, 1));
++        for (QWaylandInputDevice *inputDevice : qAsConst(mInputDevices))
++            inputDevice->setPrimarySelectionDevice(mPrimarySelectionManager->createDevice(inputDevice));
+ #endif
+     } else if (interface == QStringLiteral("zwp_text_input_manager_v2") && !mClientSideInputContextRequested) {
+         mTextInputManager.reset(new QtWayland::zwp_text_input_manager_v2(registry, id, 1));
+@@ -427,6 +575,13 @@ void QWaylandDisplay::registry_global_remove(uint32_t id)
+                     inputDevice->setTextInput(nullptr);
+                 mWaylandIntegration->reconfigureInputContext();
+             }
++#if QT_CONFIG(wayland_client_primary_selection)
++            if (global.interface == QStringLiteral("zwp_primary_selection_device_manager_v1")) {
++                mPrimarySelectionManager.reset();
++                for (QWaylandInputDevice *inputDevice : qAsConst(mInputDevices))
++                    inputDevice->setPrimarySelectionDevice(nullptr);
++            }
++#endif
+             mGlobals.removeAt(i);
+             break;
+         }
+@@ -452,9 +607,10 @@ void QWaylandDisplay::addRegistryListener(RegistryListener listener, void *data)
+ 
+ void QWaylandDisplay::removeListener(RegistryListener listener, void *data)
+ {
+-    std::remove_if(mRegistryListeners.begin(), mRegistryListeners.end(), [=](Listener l){
++    auto iter = std::remove_if(mRegistryListeners.begin(), mRegistryListeners.end(), [=](Listener l){
+         return (l.listener == listener && l.data == data);
+     });
++    mRegistryListeners.erase(iter, mRegistryListeners.end());
+ }
+ 
+ uint32_t QWaylandDisplay::currentTimeMillisec()
+@@ -467,50 +623,9 @@ uint32_t QWaylandDisplay::currentTimeMillisec()
+     return 0;
+ }
+ 
+-static void
+-sync_callback(void *data, struct wl_callback *callback, uint32_t serial)
+-{
+-    Q_UNUSED(serial)
+-    bool *done = static_cast<bool *>(data);
+-
+-    *done = true;
+-
+-    // If the wl_callback done event is received after the condition check in the while loop in
+-    // forceRoundTrip(), but before the call to processEvents, the call to processEvents may block
+-    // forever if no more events are posted (eventhough the callback is handled in response to the
+-    // aboutToBlock signal). Hence, we wake up the event dispatcher so forceRoundTrip may return.
+-    // (QTBUG-64696)
+-    if (auto *dispatcher = QThread::currentThread()->eventDispatcher())
+-        dispatcher->wakeUp();
+-
+-    wl_callback_destroy(callback);
+-}
+-
+-static const struct wl_callback_listener sync_listener = {
+-    sync_callback
+-};
+-
+ void QWaylandDisplay::forceRoundTrip()
+ {
+-    // wl_display_roundtrip() works on the main queue only,
+-    // but we use a separate one, so basically reimplement it here
+-    int ret = 0;
+-    bool done = false;
+-    wl_callback *callback = wl_display_sync(mDisplay);
+-    wl_callback_add_listener(callback, &sync_listener, &done);
+-    flushRequests();
+-    if (QThread::currentThread()->eventDispatcher()) {
+-        while (!done && ret >= 0) {
+-            QThread::currentThread()->eventDispatcher()->processEvents(QEventLoop::WaitForMoreEvents);
+-            ret = wl_display_dispatch_pending(mDisplay);
+-        }
+-    } else {
+-        while (!done && ret >= 0)
+-            ret = wl_display_dispatch(mDisplay);
+-    }
+-
+-    if (ret == -1 && !done)
+-        wl_callback_destroy(callback);
++     wl_display_roundtrip(mDisplay);
+ }
+ 
+ bool QWaylandDisplay::supportsWindowDecoration() const
+@@ -574,14 +689,10 @@ void QWaylandDisplay::handleKeyboardFocusChanged(QWaylandInputDevice *inputDevic
+     if (mLastKeyboardFocus == keyboardFocus)
+         return;
+ 
+-    if (mWaylandIntegration->mShellIntegration) {
+-        mWaylandIntegration->mShellIntegration->handleKeyboardFocusChanged(keyboardFocus, mLastKeyboardFocus);
+-    } else {
+-        if (keyboardFocus)
+-            handleWindowActivated(keyboardFocus);
+-        if (mLastKeyboardFocus)
+-            handleWindowDeactivated(mLastKeyboardFocus);
+-    }
++    if (keyboardFocus)
++        handleWindowActivated(keyboardFocus);
++    if (mLastKeyboardFocus)
++        handleWindowDeactivated(mLastKeyboardFocus);
+ 
+     mLastKeyboardFocus = keyboardFocus;
+ }
+@@ -600,6 +711,19 @@ void QWaylandDisplay::handleWaylandSync()
+     QWindow *activeWindow = mActiveWindows.empty() ? nullptr : mActiveWindows.last()->window();
+     if (activeWindow != QGuiApplication::focusWindow())
+         QWindowSystemInterface::handleWindowActivated(activeWindow);
++
++    if (!activeWindow) {
++        if (lastInputDevice()) {
++#if QT_CONFIG(clipboard)
++            if (auto *dataDevice = lastInputDevice()->dataDevice())
++                dataDevice->invalidateSelectionOffer();
++#endif
++#if QT_CONFIG(wayland_client_primary_selection)
++            if (auto *device = lastInputDevice()->primarySelectionDevice())
++                device->invalidateSelectionOffer();
++#endif
++        }
++    }
+ }
+ 
+ const wl_callback_listener QWaylandDisplay::syncCallbackListener = {
+@@ -626,6 +750,13 @@ QWaylandInputDevice *QWaylandDisplay::defaultInputDevice() const
+     return mInputDevices.isEmpty() ? 0 : mInputDevices.first();
+ }
+ 
++bool QWaylandDisplay::isKeyboardAvailable() const
++{
++    return std::any_of(
++            mInputDevices.constBegin(), mInputDevices.constEnd(),
++            [this](const QWaylandInputDevice *device) { return device->keyboard() != nullptr; });
++}
++
+ #if QT_CONFIG(cursor)
+ 
+ QWaylandCursor *QWaylandDisplay::waylandCursor()
+@@ -652,4 +783,6 @@ QWaylandCursorTheme *QWaylandDisplay::loadCursorTheme(const QString &name, int p
+ 
+ } // namespace QtWaylandClient
+ 
++#include "qwaylanddisplay.moc"
++
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/client/qwaylanddisplay_p.h b/qtwayland/src/client/qwaylanddisplay_p.h
+index 3b092bc8..42bc661d 100644
+--- a/qtwayland/src/client/qwaylanddisplay_p.h
++++ b/qtwayland/src/client/qwaylanddisplay_p.h
+@@ -109,6 +109,7 @@ class QWaylandSurface;
+ class QWaylandShellIntegration;
+ class QWaylandCursor;
+ class QWaylandCursorTheme;
++class EventThread;
+ 
+ typedef void (*RegistryListener)(void *data,
+                                  struct wl_registry *registry,
+@@ -120,15 +121,11 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandDisplay : public QObject, public QtWayland
+     Q_OBJECT
+ 
+ public:
+-    struct FrameQueue {
+-        FrameQueue(wl_event_queue *q = nullptr) : queue(q), mutex(new QMutex) {}
+-        wl_event_queue *queue;
+-        QMutex *mutex;
+-    };
+-
+     QWaylandDisplay(QWaylandIntegration *waylandIntegration);
+     ~QWaylandDisplay(void) override;
+ 
++    void initialize();
++
+ #if QT_CONFIG(xkbcommon)
+     struct xkb_context *xkbContext() const { return mXkbContext.get(); }
+ #endif
+@@ -210,11 +207,11 @@ public:
+     void handleKeyboardFocusChanged(QWaylandInputDevice *inputDevice);
+     void handleWindowDestroyed(QWaylandWindow *window);
+ 
+-    wl_event_queue *createEventQueue();
+-    FrameQueue createFrameQueue();
+-    void destroyFrameQueue(const FrameQueue &q);
+-    void dispatchQueueWhile(wl_event_queue *queue, std::function<bool()> condition, int timeout = -1);
++    wl_event_queue *frameEventQueue() { return m_frameEventQueue; };
++
++    bool isKeyboardAvailable() const;
+ 
++    void initEventThread();
+ public slots:
+     void blockingReadEvents();
+     void flushRequests();
+@@ -237,6 +234,9 @@ private:
+     };
+ 
+     struct wl_display *mDisplay = nullptr;
++    QScopedPointer<EventThread> m_eventThread;
++    wl_event_queue *m_frameEventQueue = nullptr;
++    QScopedPointer<EventThread> m_frameEventQueueThread;
+     QtWayland::wl_compositor mCompositor;
+     QScopedPointer<QWaylandShm> mShm;
+     QList<QWaylandScreen *> mWaitingScreens;
+@@ -273,11 +273,9 @@ private:
+     QWaylandInputDevice *mLastInputDevice = nullptr;
+     QPointer<QWaylandWindow> mLastInputWindow;
+     QPointer<QWaylandWindow> mLastKeyboardFocus;
+-    QVector<QWaylandWindow *> mActiveWindows;
+-    QVector<FrameQueue> mExternalQueues;
++    QList<QWaylandWindow *> mActiveWindows;
+     struct wl_callback *mSyncCallback = nullptr;
+     static const wl_callback_listener syncCallbackListener;
+-    QReadWriteLock m_frameQueueLock;
+ 
+     bool mClientSideInputContextRequested = !QPlatformInputContextFactory::requested().isNull();
+ 
+diff --git a/qtwayland/src/client/qwaylanddnd.cpp b/qtwayland/src/client/qwaylanddnd.cpp
+index 6535aa16..7c53f5fa 100644
+--- a/qtwayland/src/client/qwaylanddnd.cpp
++++ b/qtwayland/src/client/qwaylanddnd.cpp
+@@ -66,7 +66,7 @@ void QWaylandDrag::startDrag()
+ {
+     QBasicDrag::startDrag();
+     QWaylandWindow *icon = static_cast<QWaylandWindow *>(shapedPixmapWindow()->handle());
+-    if (m_display->currentInputDevice()->dataDevice()->startDrag(drag()->mimeData(), icon)) {
++    if (m_display->currentInputDevice()->dataDevice()->startDrag(drag()->mimeData(), drag()->supportedActions(), icon)) {
+         icon->addAttachOffset(-drag()->hotSpot());
+     } else {
+         // Cancelling immediately does not work, since the event loop for QDrag::exec is started
+@@ -80,6 +80,9 @@ void QWaylandDrag::cancel()
+     QBasicDrag::cancel();
+ 
+     m_display->currentInputDevice()->dataDevice()->cancelDrag();
++
++    if (drag())
++        drag()->deleteLater();
+ }
+ 
+ void QWaylandDrag::move(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods)
+@@ -103,33 +106,41 @@ void QWaylandDrag::endDrag()
+     m_display->currentInputDevice()->handleEndDrag();
+ }
+ 
+-void QWaylandDrag::updateTarget(const QString &mimeType)
++void QWaylandDrag::setResponse(bool accepted)
+ {
+-    setCanDrop(!mimeType.isEmpty());
+-
+-    if (canDrop()) {
+-        updateCursor(defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers()));
+-    } else {
+-        updateCursor(Qt::IgnoreAction);
+-    }
++    // This method is used for old DataDevices where the drag action is not communicated
++    Qt::DropAction action = defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers());
++    setResponse(QPlatformDropQtResponse(accepted, action));
+ }
+ 
+-void QWaylandDrag::setResponse(const QPlatformDragQtResponse &response)
++void QWaylandDrag::setResponse(const QPlatformDropQtResponse &response)
+ {
+     setCanDrop(response.isAccepted());
+ 
+     if (canDrop()) {
+-        updateCursor(defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers()));
++        updateCursor(response.acceptedAction());
+     } else {
+         updateCursor(Qt::IgnoreAction);
+     }
+ }
+ 
+-void QWaylandDrag::finishDrag(const QPlatformDropQtResponse &response)
++void QWaylandDrag::setDropResponse(const QPlatformDropQtResponse &response)
+ {
+     setExecutedDropAction(response.acceptedAction());
++}
++
++void QWaylandDrag::finishDrag()
++{
+     QKeyEvent event(QEvent::KeyPress, Qt::Key_Escape, Qt::NoModifier);
+     eventFilter(shapedPixmapWindow(), &event);
++
++    if (drag())
++        drag()->deleteLater();
++}
++
++bool QWaylandDrag::ownsDragObject() const
++{
++    return true;
+ }
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddnd_p.h b/qtwayland/src/client/qwaylanddnd_p.h
+index 474fe2ab..46f629ac 100644
+--- a/qtwayland/src/client/qwaylanddnd_p.h
++++ b/qtwayland/src/client/qwaylanddnd_p.h
+@@ -71,9 +71,10 @@ public:
+     QWaylandDrag(QWaylandDisplay *display);
+     ~QWaylandDrag() override;
+ 
+-    void updateTarget(const QString &mimeType);
+-    void setResponse(const QPlatformDragQtResponse &response);
+-    void finishDrag(const QPlatformDropQtResponse &response);
++    void setResponse(bool accepted);
++    void setResponse(const QPlatformDropQtResponse &response);
++    void setDropResponse(const QPlatformDropQtResponse &response);
++    void finishDrag();
+ 
+ protected:
+     void startDrag() override;
+@@ -82,6 +83,7 @@ protected:
+     void drop(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods) override;
+     void endDrag() override;
+ 
++    bool ownsDragObject() const override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+diff --git a/qtwayland/src/client/qwaylandinputdevice.cpp b/qtwayland/src/client/qwaylandinputdevice.cpp
+index 613fe862..4b90de84 100644
+--- a/qtwayland/src/client/qwaylandinputdevice.cpp
++++ b/qtwayland/src/client/qwaylandinputdevice.cpp
+@@ -685,6 +685,11 @@ public:
+ 
+ void QWaylandInputDevice::Pointer::pointer_leave(uint32_t time, struct wl_surface *surface)
+ {
++    invalidateFocus();
++    mButtons = Qt::NoButton;
++
++    mParent->mTime = time;
++
+     // The event may arrive after destroying the window, indicated by
+     // a null surface.
+     if (!surface)
+@@ -696,11 +701,6 @@ void QWaylandInputDevice::Pointer::pointer_leave(uint32_t time, struct wl_surfac
+ 
+     if (!QWaylandWindow::mouseGrab())
+         setFrameEvent(new LeaveEvent(window, mSurfacePos, mGlobalPos));
+-
+-    invalidateFocus();
+-    mButtons = Qt::NoButton;
+-
+-    mParent->mTime = time;
+ }
+ 
+ class MotionEvent : public QWaylandPointerEvent
+@@ -1300,14 +1300,6 @@ void QWaylandInputDevice::Keyboard::handleFocusDestroyed()
+ void QWaylandInputDevice::Keyboard::handleFocusLost()
+ {
+     mFocus = nullptr;
+-#if QT_CONFIG(clipboard)
+-    if (auto *dataDevice = mParent->dataDevice())
+-        dataDevice->invalidateSelectionOffer();
+-#endif
+-#if QT_CONFIG(wayland_client_primary_selection)
+-    if (auto *device = mParent->primarySelectionDevice())
+-        device->invalidateSelectionOffer();
+-#endif
+     mParent->mQDisplay->handleKeyboardFocusChanged(mParent);
+     mRepeatTimer.stop();
+ }
+@@ -1396,6 +1388,7 @@ void QWaylandInputDevice::Touch::touch_cancel()
+     if (touchExt)
+         touchExt->touchCanceled();
+ 
++    mFocus = nullptr;
+     QWindowSystemInterface::handleTouchCancelEvent(nullptr, mParent->mTouchDevice);
+ }
+ 
+diff --git a/qtwayland/src/client/qwaylandintegration.cpp b/qtwayland/src/client/qwaylandintegration.cpp
+index c53ccb78..54861600 100644
+--- a/qtwayland/src/client/qwaylandintegration.cpp
++++ b/qtwayland/src/client/qwaylandintegration.cpp
+@@ -125,6 +125,9 @@ QWaylandIntegration::QWaylandIntegration()
+ #endif
+ 
+     reconfigureInputContext();
++
++    QWaylandWindow::fixedToplevelPositions =
++            !qEnvironmentVariableIsSet("QT_WAYLAND_DISABLE_FIXED_POSITIONS");
+ }
+ 
+ QWaylandIntegration::~QWaylandIntegration()
+@@ -192,14 +195,18 @@ QAbstractEventDispatcher *QWaylandIntegration::createEventDispatcher() const
+ 
+ void QWaylandIntegration::initialize()
+ {
++    mDisplay->initEventThread();
++
++    // Call after eventDispatcher is fully connected, for QWaylandDisplay::forceRoundTrip()
++    mDisplay->initialize();
++
++    // But the aboutToBlock() and awake() should be connected after initializePlatform().
++    // Otherwise the connected flushRequests() may consumes up all events before processEvents starts to wait,
++    // so that processEvents(QEventLoop::WaitForMoreEvents) may be blocked in the forceRoundTrip().
+     QAbstractEventDispatcher *dispatcher = QGuiApplicationPrivate::eventDispatcher;
+     QObject::connect(dispatcher, SIGNAL(aboutToBlock()), mDisplay.data(), SLOT(flushRequests()));
+     QObject::connect(dispatcher, SIGNAL(awake()), mDisplay.data(), SLOT(flushRequests()));
+ 
+-    int fd = wl_display_get_fd(mDisplay->wl_display());
+-    QSocketNotifier *sn = new QSocketNotifier(fd, QSocketNotifier::Read, mDisplay.data());
+-    QObject::connect(sn, SIGNAL(activated(QSocketDescriptor)), mDisplay.data(), SLOT(flushRequests()));
+-
+     // Qt does not support running with no screens
+     mDisplay->ensureScreen();
+ }
+@@ -262,6 +269,14 @@ QWaylandDisplay *QWaylandIntegration::display() const
+     return mDisplay.data();
+ }
+ 
++Qt::KeyboardModifiers QWaylandIntegration::queryKeyboardModifiers() const
++{
++    if (auto *seat = mDisplay->currentInputDevice()) {
++        return seat->modifiers();
++    }
++    return Qt::NoModifier;
++}
++
+ QList<int> QWaylandIntegration::possibleKeys(const QKeyEvent *event) const
+ {
+     if (auto *seat = mDisplay->currentInputDevice())
+@@ -479,7 +494,7 @@ void QWaylandIntegration::reconfigureInputContext()
+     }
+ #endif
+ 
+-    qCDebug(lcQpaWayland) << "using input method:" << inputContext()->metaObject()->className();
++    qCDebug(lcQpaWayland) << "using input method:" << (inputContext() ? inputContext()->metaObject()->className() : "<none>");
+ }
+ 
+ QWaylandShellIntegration *QWaylandIntegration::createShellIntegration(const QString &integrationName)
+diff --git a/qtwayland/src/client/qwaylandintegration_p.h b/qtwayland/src/client/qwaylandintegration_p.h
+index ff70ae25..73b80658 100644
+--- a/qtwayland/src/client/qwaylandintegration_p.h
++++ b/qtwayland/src/client/qwaylandintegration_p.h
+@@ -107,6 +107,8 @@ public:
+ 
+     QWaylandDisplay *display() const;
+ 
++    Qt::KeyboardModifiers queryKeyboardModifiers() const override;
++
+     QList<int> possibleKeys(const QKeyEvent *event) const override;
+ 
+     QStringList themeNames() const override;
+diff --git a/qtwayland/src/client/qwaylandprimaryselectionv1.cpp b/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
+index 832f9678..ea508771 100644
+--- a/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
++++ b/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
+@@ -54,11 +54,6 @@ QWaylandPrimarySelectionDeviceManagerV1::QWaylandPrimarySelectionDeviceManagerV1
+     : zwp_primary_selection_device_manager_v1(display->wl_registry(), id, qMin(version, uint(1)))
+     , m_display(display)
+ {
+-    // Create devices for all seats.
+-    // This only works if we get the global before all devices
+-    const auto seats = m_display->inputDevices();
+-    for (auto *seat : seats)
+-        seat->setPrimarySelectionDevice(createDevice(seat));
+ }
+ 
+ QWaylandPrimarySelectionDeviceV1 *QWaylandPrimarySelectionDeviceManagerV1::createDevice(QWaylandInputDevice *seat)
+diff --git a/qtwayland/src/client/qwaylandscreen.cpp b/qtwayland/src/client/qwaylandscreen.cpp
+index 6cb337de..5537dafd 100644
+--- a/qtwayland/src/client/qwaylandscreen.cpp
++++ b/qtwayland/src/client/qwaylandscreen.cpp
+@@ -60,7 +60,7 @@ QWaylandXdgOutputManagerV1::QWaylandXdgOutputManagerV1(QWaylandDisplay* display,
+ }
+ 
+ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uint32_t id)
+-    : QtWayland::wl_output(waylandDisplay->wl_registry(), id, qMin(version, 2))
++    : QtWayland::wl_output(waylandDisplay->wl_registry(), id, qMin(version, 3))
+     , m_outputId(id)
+     , mWaylandDisplay(waylandDisplay)
+     , mOutputName(QStringLiteral("Screen%1").arg(id))
+@@ -72,7 +72,7 @@ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uin
+         qCWarning(lcQpaWayland) << "wl_output done event not supported by compositor,"
+                                 << "QScreen may not work correctly";
+         mWaylandDisplay->forceRoundTrip(); // Give the compositor a chance to send geometry etc.
+-        mOutputDone = true; // Fake the done event
++        mProcessedEvents |= OutputDoneEvent; // Fake the done event
+         maybeInitialize();
+     }
+ }
+@@ -81,16 +81,29 @@ QWaylandScreen::~QWaylandScreen()
+ {
+     if (zxdg_output_v1::isInitialized())
+         zxdg_output_v1::destroy();
++    if (wl_output::isInitialized() && wl_output_get_version(wl_output::object()) >= WL_OUTPUT_RELEASE_SINCE_VERSION)
++        wl_output::release();
++}
++
++uint QWaylandScreen::requiredEvents() const
++{
++    uint ret = OutputDoneEvent;
++
++    if (mWaylandDisplay->xdgOutputManager()) {
++        ret |= XdgOutputNameEvent;
++
++        if (mWaylandDisplay->xdgOutputManager()->version() < 3)
++            ret |= XdgOutputDoneEvent;
++    }
++    return ret;
+ }
+ 
+ void QWaylandScreen::maybeInitialize()
+ {
+     Q_ASSERT(!mInitialized);
+ 
+-    if (!mOutputDone)
+-        return;
+-
+-    if (mWaylandDisplay->xdgOutputManager() && !mXdgOutputDone)
++    const uint requiredEvents = this->requiredEvents();
++    if ((mProcessedEvents & requiredEvents) != requiredEvents)
+         return;
+ 
+     mInitialized = true;
+@@ -276,9 +289,8 @@ void QWaylandScreen::output_scale(int32_t factor)
+ 
+ void QWaylandScreen::output_done()
+ {
+-    mOutputDone = true;
+-    if (zxdg_output_v1::isInitialized() && mWaylandDisplay->xdgOutputManager()->version() >= 3)
+-        mXdgOutputDone = true;
++    mProcessedEvents |= OutputDoneEvent;
++
+     if (mInitialized) {
+         updateOutputProperties();
+         if (zxdg_output_v1::isInitialized())
+@@ -339,7 +351,7 @@ void QWaylandScreen::zxdg_output_v1_done()
+     if (Q_UNLIKELY(mWaylandDisplay->xdgOutputManager()->version() >= 3))
+         qWarning(lcQpaWayland) << "zxdg_output_v1.done received on version 3 or newer, this is most likely a bug in the compositor";
+ 
+-    mXdgOutputDone = true;
++    mProcessedEvents |= XdgOutputDoneEvent;
+     if (mInitialized)
+         updateXdgOutputProperties();
+     else
+@@ -348,7 +360,11 @@ void QWaylandScreen::zxdg_output_v1_done()
+ 
+ void QWaylandScreen::zxdg_output_v1_name(const QString &name)
+ {
++    if (Q_UNLIKELY(mInitialized))
++        qWarning(lcQpaWayland) << "zxdg_output_v1.name received after output has been initialized, this is most likely a bug in the compositor";
++
+     mOutputName = name;
++    mProcessedEvents |= XdgOutputNameEvent;
+ }
+ 
+ void QWaylandScreen::updateXdgOutputProperties()
+diff --git a/qtwayland/src/client/qwaylandscreen_p.h b/qtwayland/src/client/qwaylandscreen_p.h
+index df1c94f2..050cfdc0 100644
+--- a/qtwayland/src/client/qwaylandscreen_p.h
++++ b/qtwayland/src/client/qwaylandscreen_p.h
+@@ -116,6 +116,13 @@ public:
+     static QWaylandScreen *fromWlOutput(::wl_output *output);
+ 
+ private:
++    enum Event : uint {
++        XdgOutputDoneEvent = 0x1,
++        OutputDoneEvent = 0x2,
++        XdgOutputNameEvent = 0x4,
++    };
++    uint requiredEvents() const;
++
+     void output_mode(uint32_t flags, int width, int height, int refresh) override;
+     void output_geometry(int32_t x, int32_t y,
+                          int32_t width, int32_t height,
+@@ -148,8 +155,7 @@ private:
+     QSize mPhysicalSize;
+     QString mOutputName;
+     Qt::ScreenOrientation m_orientation = Qt::PrimaryOrientation;
+-    bool mOutputDone = false;
+-    bool mXdgOutputDone = false;
++    uint mProcessedEvents = 0;
+     bool mInitialized = false;
+ 
+ #if QT_CONFIG(cursor)
+diff --git a/qtwayland/src/client/qwaylandshmbackingstore.cpp b/qtwayland/src/client/qwaylandshmbackingstore.cpp
+index dc7ff670..41cffdf7 100644
+--- a/qtwayland/src/client/qwaylandshmbackingstore.cpp
++++ b/qtwayland/src/client/qwaylandshmbackingstore.cpp
+@@ -52,6 +52,7 @@
+ 
+ #include <QtWaylandClient/private/wayland-wayland-client-protocol.h>
+ 
++#include <fcntl.h>
+ #include <unistd.h>
+ #include <sys/mman.h>
+ 
+@@ -61,6 +62,9 @@
+ #  ifndef MFD_CLOEXEC
+ #    define MFD_CLOEXEC     0x0001U
+ #  endif
++#  ifndef MFD_ALLOW_SEALING
++#    define MFD_ALLOW_SEALING 0x0002U
++#  endif
+ #endif
+ 
+ QT_BEGIN_NAMESPACE
+@@ -74,8 +78,10 @@ QWaylandShmBuffer::QWaylandShmBuffer(QWaylandDisplay *display,
+     int alloc = stride * size.height();
+     int fd = -1;
+ 
+-#ifdef SYS_memfd_create
+-    fd = syscall(SYS_memfd_create, "wayland-shm", MFD_CLOEXEC);
++#if defined(SYS_memfd_create) && defined(F_SEAL_SEAL)
++    fd = syscall(SYS_memfd_create, "wayland-shm", MFD_CLOEXEC | MFD_ALLOW_SEALING);
++    if (fd >= 0)
++        fcntl(fd, F_ADD_SEALS, F_SEAL_SHRINK | F_SEAL_SEAL);
+ #endif
+ 
+     QScopedPointer<QFile> filePointer;
+diff --git a/qtwayland/src/client/qwaylandwindow.cpp b/qtwayland/src/client/qwaylandwindow.cpp
+index cb82857a..fb2c59dc 100644
+--- a/qtwayland/src/client/qwaylandwindow.cpp
++++ b/qtwayland/src/client/qwaylandwindow.cpp
+@@ -76,7 +76,6 @@ QWaylandWindow *QWaylandWindow::mMouseGrab = nullptr;
+ QWaylandWindow::QWaylandWindow(QWindow *window, QWaylandDisplay *display)
+     : QPlatformWindow(window)
+     , mDisplay(display)
+-    , mFrameQueue(mDisplay->createFrameQueue())
+     , mResizeAfterSwap(qEnvironmentVariableIsSet("QT_WAYLAND_RESIZE_AFTER_SWAP"))
+ {
+     {
+@@ -95,9 +94,6 @@ QWaylandWindow::QWaylandWindow(QWindow *window, QWaylandDisplay *display)
+ 
+ QWaylandWindow::~QWaylandWindow()
+ {
+-    mDisplay->destroyFrameQueue(mFrameQueue);
+-    mDisplay->handleWindowDestroyed(this);
+-
+     delete mWindowDecoration;
+ 
+     if (mSurface)
+@@ -243,6 +239,7 @@ bool QWaylandWindow::shouldCreateSubSurface() const
+ 
+ void QWaylandWindow::reset()
+ {
++    closeChildPopups();
+     delete mShellSurface;
+     mShellSurface = nullptr;
+     delete mSubSurfaceWindow;
+@@ -255,17 +252,22 @@ void QWaylandWindow::reset()
+         mSurface.reset();
+     }
+ 
+-    if (mFrameCallback) {
+-        wl_callback_destroy(mFrameCallback);
+-        mFrameCallback = nullptr;
+-    }
++    {
++        QMutexLocker lock(&mFrameSyncMutex);
++        if (mFrameCallback) {
++            wl_callback_destroy(mFrameCallback);
++            mFrameCallback = nullptr;
++        }
+ 
+-    mFrameCallbackElapsedTimer.invalidate();
+-    mWaitingForFrameCallback = false;
++        mFrameCallbackElapsedTimer.invalidate();
++        mWaitingForFrameCallback = false;
++    }
+     mFrameCallbackTimedOut = false;
+ 
+     mMask = QRegion();
+     mQueuedBuffer = nullptr;
++
++    mDisplay->handleWindowDestroyed(this);
+ }
+ 
+ QWaylandWindow *QWaylandWindow::fromWlSurface(::wl_surface *surface)
+@@ -351,19 +353,25 @@ void QWaylandWindow::setGeometry_helper(const QRect &rect)
+     }
+ }
+ 
+-void QWaylandWindow::setGeometry(const QRect &rect)
++void QWaylandWindow::setGeometry(const QRect &r)
+ {
++    auto rect = r;
++    if (fixedToplevelPositions && !QPlatformWindow::parent() && window()->type() != Qt::Popup
++        && window()->type() != Qt::ToolTip) {
++        rect.moveTo(screen()->geometry().topLeft());
++    }
+     setGeometry_helper(rect);
+ 
+     if (window()->isVisible() && rect.isValid()) {
+         if (mWindowDecoration)
+             mWindowDecoration->update();
+ 
+-        if (mResizeAfterSwap && windowType() == Egl && mSentInitialResize)
++        if (mResizeAfterSwap && windowType() == Egl && mSentInitialResize) {
++            QMutexLocker lock(&mResizeLock);
+             mResizeDirty = true;
+-        else
++        } else {
+             QWindowSystemInterface::handleGeometryChange(window(), geometry());
+-
++        }
+         mSentInitialResize = true;
+     }
+     QRect exposeGeometry(QPoint(), geometry().size());
+@@ -374,7 +382,7 @@ void QWaylandWindow::setGeometry(const QRect &rect)
+         mShellSurface->setWindowGeometry(windowContentGeometry());
+ 
+     if (isOpaque() && mMask.isEmpty())
+-        setOpaqueArea(rect);
++        setOpaqueArea(QRect(QPoint(0, 0), rect.size()));
+ }
+ 
+ void QWaylandWindow::resizeFromApplyConfigure(const QSize &sizeWithMargins, const QPoint &offset)
+@@ -399,21 +407,6 @@ void QWaylandWindow::sendExposeEvent(const QRect &rect)
+     mLastExposeGeometry = rect;
+ }
+ 
+-
+-static QVector<QPointer<QWaylandWindow>> activePopups;
+-
+-void QWaylandWindow::closePopups(QWaylandWindow *parent)
+-{
+-    while (!activePopups.isEmpty()) {
+-        auto popup = activePopups.takeLast();
+-        if (popup.isNull())
+-            continue;
+-        if (popup.data() == parent)
+-            return;
+-        popup->reset();
+-    }
+-}
+-
+ QPlatformScreen *QWaylandWindow::calculateScreenFromSurfaceEvents() const
+ {
+     QReadLocker lock(&mSurfaceLock);
+@@ -433,10 +426,7 @@ void QWaylandWindow::setVisible(bool visible)
+     lastVisible = visible;
+ 
+     if (visible) {
+-        if (window()->type() == Qt::Popup || window()->type() == Qt::ToolTip)
+-            activePopups << this;
+         initWindow();
+-        mDisplay->flushRequests();
+ 
+         setGeometry(windowGeometry());
+         // Don't flush the events here, or else the newly visible window may start drawing, but since
+@@ -444,7 +434,6 @@ void QWaylandWindow::setVisible(bool visible)
+         // QWaylandShmBackingStore::beginPaint().
+     } else {
+         sendExposeEvent(QRect());
+-        closePopups(this);
+         reset();
+     }
+ }
+@@ -556,12 +545,12 @@ void QWaylandWindow::sendRecursiveExposeEvent()
+ 
+ void QWaylandWindow::attach(QWaylandBuffer *buffer, int x, int y)
+ {
+-    Q_ASSERT(!buffer->committed());
+     QReadLocker locker(&mSurfaceLock);
+     if (mSurface == nullptr)
+         return;
+ 
+     if (buffer) {
++        Q_ASSERT(!buffer->committed());
+         handleUpdate();
+         buffer->setBusy();
+ 
+@@ -583,7 +572,11 @@ void QWaylandWindow::damage(const QRect &rect)
+     if (mSurface == nullptr)
+         return;
+ 
+-    mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    const int s = scale();
++    if (mDisplay->compositorVersion() >= 4)
++        mSurface->damage_buffer(s * rect.x(), s * rect.y(), s * rect.width(), s * rect.height());
++    else
++        mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
+ }
+ 
+ void QWaylandWindow::safeCommit(QWaylandBuffer *buffer, const QRegion &damage)
+@@ -619,8 +612,14 @@ void QWaylandWindow::commit(QWaylandBuffer *buffer, const QRegion &damage)
+         return;
+ 
+     attachOffset(buffer);
+-    for (const QRect &rect: damage)
+-        mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    if (mDisplay->compositorVersion() >= 4) {
++        const int s = scale();
++        for (const QRect &rect: damage)
++            mSurface->damage_buffer(s * rect.x(), s * rect.y(), s * rect.width(), s * rect.height());
++    } else {
++        for (const QRect &rect: damage)
++            mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    }
+     Q_ASSERT(!buffer->committed());
+     buffer->setCommitted();
+     mSurface->commit();
+@@ -635,42 +634,53 @@ void QWaylandWindow::commit()
+ 
+ const wl_callback_listener QWaylandWindow::callbackListener = {
+     [](void *data, wl_callback *callback, uint32_t time) {
+-        Q_UNUSED(callback);
+         Q_UNUSED(time);
+         auto *window = static_cast<QWaylandWindow*>(data);
+-        window->handleFrameCallback();
++        window->handleFrameCallback(callback);
+     }
+ };
+ 
+-void QWaylandWindow::handleFrameCallback()
++void QWaylandWindow::handleFrameCallback(wl_callback* callback)
+ {
++    QMutexLocker locker(&mFrameSyncMutex);
++    if (!mFrameCallback) {
++        // This means the callback is already unset by QWaylandWindow::reset.
++        // The wl_callback object will be destroyed there too.
++        return;
++    }
++    Q_ASSERT(callback == mFrameCallback);
++    wl_callback_destroy(callback);
++    mFrameCallback = nullptr;
++
+     mWaitingForFrameCallback = false;
+     mFrameCallbackElapsedTimer.invalidate();
+ 
+     // The rest can wait until we can run it on the correct thread
+-    if (!mWaitingForUpdateDelivery) {
+-        auto doHandleExpose = [this]() {
+-            bool wasExposed = isExposed();
+-            mFrameCallbackTimedOut = false;
+-            if (!wasExposed && isExposed()) // Did setting mFrameCallbackTimedOut make the window exposed?
+-                sendExposeEvent(QRect(QPoint(), geometry().size()));
+-            if (wasExposed && hasPendingUpdateRequest())
+-                deliverUpdateRequest();
+-
+-            mWaitingForUpdateDelivery = false;
+-        };
++    auto doHandleExpose = [this]() {
++        mWaitingForUpdateDelivery.storeRelease(false);
++        bool wasExposed = isExposed();
++        mFrameCallbackTimedOut = false;
++        if (!wasExposed && isExposed()) // Did setting mFrameCallbackTimedOut make the window exposed?
++            sendExposeEvent(QRect(QPoint(), geometry().size()));
++        if (wasExposed && hasPendingUpdateRequest())
++            deliverUpdateRequest();
++    };
+ 
++    if (mWaitingForUpdateDelivery.testAndSetAcquire(false, true)) {
+         // Queued connection, to make sure we don't call handleUpdate() from inside waitForFrameSync()
+         // in the single-threaded case.
+-        mWaitingForUpdateDelivery = true;
+         QMetaObject::invokeMethod(this, doHandleExpose, Qt::QueuedConnection);
+     }
++
++    mFrameSyncWait.notify_all();
+ }
+ 
+ bool QWaylandWindow::waitForFrameSync(int timeout)
+ {
+-    QMutexLocker locker(mFrameQueue.mutex);
+-    mDisplay->dispatchQueueWhile(mFrameQueue.queue, [&]() { return mWaitingForFrameCallback; }, timeout);
++    QMutexLocker locker(&mFrameSyncMutex);
++
++    QDeadlineTimer deadline(timeout);
++    while (mWaitingForFrameCallback && mFrameSyncWait.wait(&mFrameSyncMutex, deadline)) { }
+ 
+     if (mWaitingForFrameCallback) {
+         qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
+@@ -868,6 +878,17 @@ bool QWaylandWindow::createDecoration()
+             subsurf->set_position(pos.x() + m.left(), pos.y() + m.top());
+         }
+         sendExposeEvent(QRect(QPoint(), geometry().size()));
++
++        // This is a special case where the buffer is recreated, but since
++        // the content rect remains the same, the widgets remain the same
++        // size and are not redrawn, leaving the new buffer empty. As a simple
++        // work-around, we trigger a full extra update whenever the client-side
++        // window decorations are toggled while the window is showing.
++        // Note: createDecoration() is sometimes called from the render thread
++        // of Qt Quick. This is essentially wrong and could potentially cause problems,
++        // but until the underlying issue has been fixed, we have to use invokeMethod()
++        // here to avoid asserts.
++        QMetaObject::invokeMethod(window(), &QWindow::requestUpdate);
+     }
+ 
+     return mWindowDecoration;
+@@ -1023,6 +1044,13 @@ void QWaylandWindow::handleScreensChanged()
+ 
+     QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->QPlatformScreen::screen());
+     mLastReportedScreen = newScreen;
++    if (fixedToplevelPositions && !QPlatformWindow::parent() && window()->type() != Qt::Popup
++        && window()->type() != Qt::ToolTip
++        && geometry().topLeft() != newScreen->geometry().topLeft()) {
++        auto geometry = this->geometry();
++        geometry.moveTo(newScreen->geometry().topLeft());
++        setGeometry(geometry);
++    }
+ 
+     int scale = newScreen->isPlaceholder() ? 1 : static_cast<QWaylandScreen *>(newScreen)->scale();
+     if (scale != mScale) {
+@@ -1094,10 +1122,18 @@ bool QWaylandWindow::setMouseGrabEnabled(bool grab)
+     return true;
+ }
+ 
++Qt::WindowStates QWaylandWindow::windowStates() const
++{
++    return mLastReportedWindowStates;
++}
++
+ void QWaylandWindow::handleWindowStatesChanged(Qt::WindowStates states)
+ {
+     createDecoration();
+-    QWindowSystemInterface::handleWindowStateChanged(window(), states, mLastReportedWindowStates);
++    Qt::WindowStates statesWithoutActive = states & ~Qt::WindowActive;
++    Qt::WindowStates lastStatesWithoutActive = mLastReportedWindowStates & ~Qt::WindowActive;
++    QWindowSystemInterface::handleWindowStateChanged(window(), statesWithoutActive,
++                                                     lastStatesWithoutActive);
+     mLastReportedWindowStates = states;
+ }
+ 
+@@ -1139,19 +1175,24 @@ void QWaylandWindow::timerEvent(QTimerEvent *event)
+     if (event->timerId() != mFrameCallbackCheckIntervalTimerId)
+         return;
+ 
+-    bool callbackTimerExpired = mFrameCallbackElapsedTimer.hasExpired(mFrameCallbackTimeout);
+-    if (!mFrameCallbackElapsedTimer.isValid() || callbackTimerExpired ) {
+-        killTimer(mFrameCallbackCheckIntervalTimerId);
+-        mFrameCallbackCheckIntervalTimerId = -1;
+-    }
+-    if (mFrameCallbackElapsedTimer.isValid() && callbackTimerExpired) {
+-        mFrameCallbackElapsedTimer.invalidate();
++    {
++        QMutexLocker lock(&mFrameSyncMutex);
+ 
+-        qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
+-        mFrameCallbackTimedOut = true;
+-        mWaitingForUpdate = false;
+-        sendExposeEvent(QRect());
++        bool callbackTimerExpired = mFrameCallbackElapsedTimer.hasExpired(mFrameCallbackTimeout);
++        if (!mFrameCallbackElapsedTimer.isValid() || callbackTimerExpired ) {
++            killTimer(mFrameCallbackCheckIntervalTimerId);
++            mFrameCallbackCheckIntervalTimerId = -1;
++        }
++        if (!mFrameCallbackElapsedTimer.isValid() || !callbackTimerExpired) {
++            return;
++        }
++        mFrameCallbackElapsedTimer.invalidate();
+     }
++
++    qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
++    mFrameCallbackTimedOut = true;
++    mWaitingForUpdate = false;
++    sendExposeEvent(QRect());
+ }
+ 
+ void QWaylandWindow::requestUpdate()
+@@ -1160,8 +1201,11 @@ void QWaylandWindow::requestUpdate()
+     Q_ASSERT(hasPendingUpdateRequest()); // should be set by QPA
+ 
+     // If we have a frame callback all is good and will be taken care of there
+-    if (mWaitingForFrameCallback)
+-        return;
++    {
++        QMutexLocker locker(&mFrameSyncMutex);
++        if (mWaitingForFrameCallback)
++            return;
++    }
+ 
+     // If we've already called deliverUpdateRequest(), but haven't seen any attach+commit/swap yet
+     // This is a somewhat redundant behavior and might indicate a bug in the calling code, so log
+@@ -1174,7 +1218,12 @@ void QWaylandWindow::requestUpdate()
+     // so use invokeMethod to delay the delivery a bit.
+     QMetaObject::invokeMethod(this, [this] {
+         // Things might have changed in the meantime
+-        if (hasPendingUpdateRequest() && !mWaitingForFrameCallback)
++        {
++            QMutexLocker locker(&mFrameSyncMutex);
++            if (mWaitingForFrameCallback)
++                return;
++        }
++        if (hasPendingUpdateRequest())
+             deliverUpdateRequest();
+     }, Qt::QueuedConnection);
+ }
+@@ -1185,19 +1234,18 @@ void QWaylandWindow::requestUpdate()
+ void QWaylandWindow::handleUpdate()
+ {
+     qCDebug(lcWaylandBackingstore) << "handleUpdate" << QThread::currentThread();
++
+     // TODO: Should sync subsurfaces avoid requesting frame callbacks?
+     QReadLocker lock(&mSurfaceLock);
+     if (!mSurface)
+         return;
+ 
+-    if (mFrameCallback) {
+-        wl_callback_destroy(mFrameCallback);
+-        mFrameCallback = nullptr;
+-    }
++    QMutexLocker locker(&mFrameSyncMutex);
++    if (mWaitingForFrameCallback)
++        return;
+ 
+-    QMutexLocker locker(mFrameQueue.mutex);
+     struct ::wl_surface *wrappedSurface = reinterpret_cast<struct ::wl_surface *>(wl_proxy_create_wrapper(mSurface->object()));
+-    wl_proxy_set_queue(reinterpret_cast<wl_proxy *>(wrappedSurface), mFrameQueue.queue);
++    wl_proxy_set_queue(reinterpret_cast<wl_proxy *>(wrappedSurface), mDisplay->frameEventQueue());
+     mFrameCallback = wl_surface_frame(wrappedSurface);
+     wl_proxy_wrapper_destroy(wrappedSurface);
+     wl_callback_add_listener(mFrameCallback, &QWaylandWindow::callbackListener, this);
+@@ -1207,6 +1255,8 @@ void QWaylandWindow::handleUpdate()
+     // Start a timer for handling the case when the compositor stops sending frame callbacks.
+     if (mFrameCallbackTimeout > 0) {
+         QMetaObject::invokeMethod(this, [this] {
++            QMutexLocker locker(&mFrameSyncMutex);
++
+             if (mWaitingForFrameCallback) {
+                 if (mFrameCallbackCheckIntervalTimerId < 0)
+                     mFrameCallbackCheckIntervalTimerId = startTimer(mFrameCallbackTimeout);
+@@ -1267,6 +1317,20 @@ void QWaylandWindow::setOpaqueArea(const QRegion &opaqueArea)
+     wl_region_destroy(region);
+ }
+ 
++void QWaylandWindow::addChildPopup(QWaylandWindow *surface) {
++    mChildPopups.append(surface);
++}
++
++void QWaylandWindow::removeChildPopup(QWaylandWindow *surface) {
++    mChildPopups.removeAll(surface);
++}
++
++void QWaylandWindow::closeChildPopups() {
++    while (!mChildPopups.isEmpty()) {
++        auto popup = mChildPopups.takeLast();
++        popup->reset();
++    }
++}
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/client/qwaylandwindow_p.h b/qtwayland/src/client/qwaylandwindow_p.h
+index 01337cff..2f219d8c 100644
+--- a/qtwayland/src/client/qwaylandwindow_p.h
++++ b/qtwayland/src/client/qwaylandwindow_p.h
+@@ -98,6 +98,9 @@ public:
+     QWaylandWindow(QWindow *window, QWaylandDisplay *display);
+     ~QWaylandWindow() override;
+ 
++    // Keep Toplevels position on the top left corner of their screen
++    static inline bool fixedToplevelPositions = true;
++
+     virtual WindowType windowType() const = 0;
+     virtual void ensureSize();
+     WId winId() const override;
+@@ -148,6 +151,7 @@ public:
+     void setWindowState(Qt::WindowStates states) override;
+     void setWindowFlags(Qt::WindowFlags flags) override;
+     void handleWindowStatesChanged(Qt::WindowStates states);
++    Qt::WindowStates windowStates() const;
+ 
+     void raise() override;
+     void lower() override;
+@@ -206,6 +210,10 @@ public:
+     void handleUpdate();
+     void deliverUpdateRequest() override;
+ 
++    void addChildPopup(QWaylandWindow* child);
++    void removeChildPopup(QWaylandWindow* child);
++    void closeChildPopups();
++
+ public slots:
+     void applyConfigure();
+ 
+@@ -215,7 +223,11 @@ signals:
+ 
+ protected:
+     QWaylandDisplay *mDisplay = nullptr;
++
++    // mSurface can be written by the main thread. Other threads should claim a read lock for access
++    mutable QReadWriteLock mSurfaceLock;
+     QScopedPointer<QWaylandSurface> mSurface;
++
+     QWaylandShellSurface *mShellSurface = nullptr;
+     QWaylandSubSurface *mSubSurfaceWindow = nullptr;
+     QVector<QWaylandSubSurface *> mChildren;
+@@ -225,13 +237,14 @@ protected:
+     Qt::MouseButtons mMousePressedInContentArea = Qt::NoButton;
+ 
+     WId mWindowId;
+-    bool mWaitingForFrameCallback = false;
+     bool mFrameCallbackTimedOut = false; // Whether the frame callback has timed out
+-    bool mWaitingForUpdateDelivery = false;
+     int mFrameCallbackCheckIntervalTimerId = -1;
+-    QElapsedTimer mFrameCallbackElapsedTimer;
+-    struct ::wl_callback *mFrameCallback = nullptr;
+-    QWaylandDisplay::FrameQueue mFrameQueue;
++    QAtomicInt mWaitingForUpdateDelivery = false;
++
++    bool mWaitingForFrameCallback = false; // Protected by mFrameSyncMutex
++    QElapsedTimer mFrameCallbackElapsedTimer; // Protected by mFrameSyncMutex
++    struct ::wl_callback *mFrameCallback = nullptr; // Protected by mFrameSyncMutex
++    QMutex mFrameSyncMutex;
+     QWaitCondition mFrameSyncWait;
+ 
+     // True when we have called deliverRequestUpdate, but the client has not yet attached a new buffer
+@@ -261,6 +274,8 @@ protected:
+     QWaylandBuffer *mQueuedBuffer = nullptr;
+     QRegion mQueuedBufferDamage;
+ 
++    QList<QPointer<QWaylandWindow>> mChildPopups;
++
+ private:
+     void setGeometry_helper(const QRect &rect);
+     void initWindow();
+@@ -283,12 +298,10 @@ private:
+     QRect mLastExposeGeometry;
+ 
+     static const wl_callback_listener callbackListener;
+-    void handleFrameCallback();
++    void handleFrameCallback(struct ::wl_callback* callback);
+ 
+     static QWaylandWindow *mMouseGrab;
+ 
+-    mutable QReadWriteLock mSurfaceLock;
+-
+     friend class QWaylandSubSurface;
+ };
+ 
+diff --git a/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h b/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
+index ccad0048..4cc9b3b8 100644
+--- a/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
++++ b/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
+@@ -73,11 +73,10 @@ public:
+         return true;
+     }
+     virtual QWaylandShellSurface *createShellSurface(QWaylandWindow *window) = 0;
++    // kept for binary compat with layer-shell-qt
+     virtual void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) {
+-        if (newFocus)
+-            m_display->handleWindowActivated(newFocus);
+-        if (oldFocus)
+-            m_display->handleWindowDeactivated(oldFocus);
++        Q_UNUSED(newFocus);
++        Q_UNUSED(oldFocus);
+     }
+     virtual void *nativeResourceForWindow(const QByteArray &resource, QWindow *window) {
+         Q_UNUSED(resource);
+diff --git a/qtwayland/src/compositor/configure.json b/qtwayland/src/compositor/configure.json
+index bcfd5215..da95d07b 100644
+--- a/qtwayland/src/compositor/configure.json
++++ b/qtwayland/src/compositor/configure.json
+@@ -7,6 +7,31 @@
+     "testDir": "../../config.tests",
+ 
+     "libraries": {
++        "wayland-client": {
++            "label": "Wayland client library",
++            "headers": "wayland-version.h",
++            "test": {
++                "main": [
++                    "#if WAYLAND_VERSION_MAJOR < 1",
++                    "# error Wayland 1.8.0 or higher required",
++                    "#endif",
++                    "#if WAYLAND_VERSION_MAJOR == 1",
++                    "# if WAYLAND_VERSION_MINOR < 8",
++                    "#  error Wayland 1.8.0 or higher required",
++                    "# endif",
++                    "# if WAYLAND_VERSION_MINOR == 8",
++                    "#  if WAYLAND_VERSION_MICRO < 0",
++                    "#   error Wayland 1.8.0 or higher required",
++                    "#  endif",
++                    "# endif",
++                    "#endif"
++                 ]
++            },
++            "sources": [
++                { "type": "pkgConfig", "args": "wayland-client" },
++                "-lwayland-client"
++            ]
++        },
+         "wayland-server": {
+             "label": "wayland-server",
+             "headers": "wayland-version.h",
+@@ -151,8 +176,7 @@
+                     "#endif"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "dmabuf-client-buffer": {
+             "label": "Linux Client dma-buf Buffer Sharing",
+@@ -176,8 +200,7 @@
+                     "return 0;"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "vulkan-server-buffer": {
+             "label": "Vulkan Buffer Sharing",
+@@ -195,7 +218,8 @@
+                     "exportAllocInfo.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR;",
+                     "return 0;"
+                 ]
+-            }
++            },
++            "use": "wayland-client"
+         }
+     },
+ 
+diff --git a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
+index 7889f575..64140672 100644
+--- a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
++++ b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
+@@ -40,6 +40,7 @@
+ #include "qwaylandeglwindow.h"
+ 
+ #include <QtWaylandClient/private/qwaylandscreen_p.h>
++#include <QtWaylandClient/private/qwaylandsurface_p.h>
+ #include "qwaylandglcontext.h"
+ 
+ #include <QtEglSupport/private/qeglconvenience_p.h>
+@@ -124,6 +125,7 @@ void QWaylandEglWindow::updateSurface(bool create)
+         }
+         mOffset = QPoint();
+     } else {
++        QReadLocker locker(&mSurfaceLock);
+         if (m_waylandEglWindow) {
+             int current_width, current_height;
+             static bool disableResizeCheck = qgetenv("QT_WAYLAND_DISABLE_RESIZECHECK").toInt();
+@@ -131,14 +133,16 @@ void QWaylandEglWindow::updateSurface(bool create)
+             if (!disableResizeCheck) {
+                 wl_egl_window_get_attached_size(m_waylandEglWindow, &current_width, &current_height);
+             }
+-            if (disableResizeCheck || (current_width != sizeWithMargins.width() || current_height != sizeWithMargins.height())) {
++            if (disableResizeCheck || (current_width != sizeWithMargins.width() || current_height != sizeWithMargins.height()) || m_requestedSize != sizeWithMargins) {
+                 wl_egl_window_resize(m_waylandEglWindow, sizeWithMargins.width(), sizeWithMargins.height(), mOffset.x(), mOffset.y());
++                m_requestedSize = sizeWithMargins;
+                 mOffset = QPoint();
+ 
+                 m_resize = true;
+             }
+-        } else if (create && wlSurface()) {
+-            m_waylandEglWindow = wl_egl_window_create(wlSurface(), sizeWithMargins.width(), sizeWithMargins.height());
++        } else if (create && mSurface) {
++            m_waylandEglWindow = wl_egl_window_create(mSurface->object(), sizeWithMargins.width(), sizeWithMargins.height());
++            m_requestedSize = sizeWithMargins;
+         }
+ 
+         if (!m_eglSurface && m_waylandEglWindow && create) {
+diff --git a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
+index 5b1f4d56..0079dfef 100644
+--- a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
++++ b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
+@@ -88,6 +88,7 @@ private:
+     mutable QOpenGLFramebufferObject *m_contentFBO = nullptr;
+ 
+     QSurfaceFormat m_format;
++    QSize m_requestedSize;
+ };
+ 
+ }
+diff --git a/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h b/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
+index 56a710c3..c6a8b6c6 100644
+--- a/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
++++ b/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
+@@ -41,6 +41,8 @@
+ #include <QtCore/QTextStream>
+ #include <QtGui/QOpenGLTexture>
+ 
++#include <array>
++
+ #include <EGL/egl.h>
+ #include <EGL/eglext.h>
+ 
+diff --git a/qtwayland/src/plugins/decorations/bradient/main.cpp b/qtwayland/src/plugins/decorations/bradient/main.cpp
+index e75fda3c..fa885143 100644
+--- a/qtwayland/src/plugins/decorations/bradient/main.cpp
++++ b/qtwayland/src/plugins/decorations/bradient/main.cpp
+@@ -164,13 +164,10 @@ void QWaylandBradientDecoration::paint(QPaintDevice *device)
+     // Window icon
+     QIcon icon = waylandWindow()->windowIcon();
+     if (!icon.isNull()) {
+-        QPixmap pixmap = icon.pixmap(QSize(128, 128));
+-        QPixmap scaled = pixmap.scaled(22, 22, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+-
+         QRectF iconRect(0, 0, 22, 22);
+-        p.drawPixmap(iconRect.adjusted(margins().left() + BUTTON_SPACING, 4,
+-                                       margins().left() + BUTTON_SPACING, 4),
+-                     scaled, iconRect);
++        iconRect.adjust(margins().left() + BUTTON_SPACING, 4,
++                        margins().left() + BUTTON_SPACING, 4),
++        icon.paint(&p, iconRect.toRect());
+     }
+ 
+     // Window title
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
+index 85d25e3c..60bdd491 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
+@@ -47,18 +47,21 @@ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
+-QWaylandXdgPopupV5::QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow *window)
++QWaylandXdgPopupV5::QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow* parent, QWaylandWindow *window)
+     : QWaylandShellSurface(window)
+     , QtWayland::xdg_popup_v5(popup)
++    , m_parent(parent)
+     , m_window(window)
+ {
+     if (window->display()->windowExtension())
+         m_extendedWindow = new QWaylandExtendedSurface(window);
++    m_parent->addChildPopup(m_window);
+ }
+ 
+ QWaylandXdgPopupV5::~QWaylandXdgPopupV5()
+ {
+     xdg_popup_destroy(object());
++    m_parent->removeChildPopup(m_window);
+     delete m_extendedWindow;
+ }
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
+index 7494f6a6..d85f130b 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
+@@ -70,7 +70,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgPopupV5 : public QWaylandShellSurface
+ {
+     Q_OBJECT
+ public:
+-    QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow *window);
++    QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow* parent, QWaylandWindow *window);
+     ~QWaylandXdgPopupV5() override;
+ 
+ protected:
+@@ -78,6 +78,7 @@ protected:
+ 
+ private:
+     QWaylandExtendedSurface *m_extendedWindow = nullptr;
++    QWaylandWindow *m_parent = nullptr;
+     QWaylandWindow *m_window = nullptr;
+ };
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
+index 7e242c4a..def8452a 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
+@@ -84,7 +84,7 @@ QWaylandXdgPopupV5 *QWaylandXdgShellV5::createXdgPopup(QWaylandWindow *window, Q
+     int x = position.x() + parentWindow->frameMargins().left();
+     int y = position.y() + parentWindow->frameMargins().top();
+ 
+-    auto popup = new QWaylandXdgPopupV5(get_xdg_popup(window->wlSurface(), parentSurface, seat, m_popupSerial, x, y), window);
++    auto popup = new QWaylandXdgPopupV5(get_xdg_popup(window->wlSurface(), parentSurface, seat, m_popupSerial, x, y), parentWindow, window);
+     m_popups.append(window);
+     QObject::connect(popup, &QWaylandXdgPopupV5::destroyed, [this, window](){
+         m_popups.removeOne(window);
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
+index 4e25949f..cfc60939 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
+@@ -85,13 +85,6 @@ QWaylandShellSurface *QWaylandXdgShellV5Integration::createShellSurface(QWayland
+     return m_xdgShell->createXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellV5Integration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) {
+-    if (newFocus && qobject_cast<QWaylandXdgPopupV5 *>(newFocus->shellSurface()))
+-        m_display->handleWindowActivated(newFocus);
+-    if (oldFocus && qobject_cast<QWaylandXdgPopupV5 *>(oldFocus->shellSurface()))
+-        m_display->handleWindowDeactivated(oldFocus);
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
+index ce6bdb9e..aed88670 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
+@@ -67,7 +67,6 @@ public:
+     QWaylandXdgShellV5Integration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShellV5> m_xdgShell;
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
+index 8c371661..151c78e3 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
+@@ -174,6 +174,7 @@ QWaylandXdgSurfaceV6::Popup::Popup(QWaylandXdgSurfaceV6 *xdgSurface, QWaylandXdg
+     , m_xdgSurface(xdgSurface)
+     , m_parent(parent)
+ {
++    m_parent->window()->addChildPopup(m_xdgSurface->window());
+ }
+ 
+ QWaylandXdgSurfaceV6::Popup::~Popup()
+@@ -181,6 +182,8 @@ QWaylandXdgSurfaceV6::Popup::~Popup()
+     if (isInitialized())
+         destroy();
+ 
++    m_parent->window()->removeChildPopup(m_xdgSurface->window());
++
+     if (m_grabbing) {
+         auto *shell = m_xdgSurface->m_shell;
+         Q_ASSERT(shell->m_topmostGrabbingPopup == this);
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
+index 03164316..e8da8ba1 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
+@@ -68,20 +68,6 @@ QWaylandShellSurface *QWaylandXdgShellV6Integration::createShellSurface(QWayland
+     return m_xdgShell->getXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellV6Integration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus)
+-{
+-    if (newFocus) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurfaceV6 *>(newFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowActivated(newFocus);
+-    }
+-    if (oldFocus && qobject_cast<QWaylandXdgSurfaceV6 *>(oldFocus->shellSurface())) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurfaceV6 *>(oldFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowDeactivated(oldFocus);
+-    }
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
+index 261f8cbb..c1bcd5c6 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
+@@ -65,7 +65,6 @@ public:
+     QWaylandXdgShellV6Integration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShellV6> m_xdgShell;
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
+index f3e3c330..fa6d5808 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
+@@ -67,11 +67,6 @@ QWaylandXdgSurface::Toplevel::Toplevel(QWaylandXdgSurface *xdgSurface)
+ 
+ QWaylandXdgSurface::Toplevel::~Toplevel()
+ {
+-    if (m_applied.states & Qt::WindowActive) {
+-        QWaylandWindow *window = m_xdgSurface->window();
+-        window->display()->handleWindowDeactivated(window);
+-    }
+-
+     // The protocol spec requires that the decoration object is deleted before xdg_toplevel.
+     delete m_decoration;
+     m_decoration = nullptr;
+@@ -85,16 +80,15 @@ void QWaylandXdgSurface::Toplevel::applyConfigure()
+     if (!(m_applied.states & (Qt::WindowMaximized|Qt::WindowFullScreen)))
+         m_normalSize = m_xdgSurface->m_window->windowFrameGeometry().size();
+ 
+-    if ((m_pending.states & Qt::WindowActive) && !(m_applied.states & Qt::WindowActive))
++    if ((m_pending.states & Qt::WindowActive) && !(m_applied.states & Qt::WindowActive)
++        && !m_xdgSurface->m_window->display()->isKeyboardAvailable())
+         m_xdgSurface->m_window->display()->handleWindowActivated(m_xdgSurface->m_window);
+ 
+-    if (!(m_pending.states & Qt::WindowActive) && (m_applied.states & Qt::WindowActive))
++    if (!(m_pending.states & Qt::WindowActive) && (m_applied.states & Qt::WindowActive)
++        && !m_xdgSurface->m_window->display()->isKeyboardAvailable())
+         m_xdgSurface->m_window->display()->handleWindowDeactivated(m_xdgSurface->m_window);
+ 
+-    // TODO: none of the other plugins send WindowActive either, but is it on purpose?
+-    Qt::WindowStates statesWithoutActive = m_pending.states & ~Qt::WindowActive;
+-
+-    m_xdgSurface->m_window->handleWindowStatesChanged(statesWithoutActive);
++    m_xdgSurface->m_window->handleWindowStatesChanged(m_pending.states);
+ 
+     if (m_pending.size.isEmpty()) {
+         // An empty size in the configure means it's up to the client to choose the size
+@@ -105,8 +99,6 @@ void QWaylandXdgSurface::Toplevel::applyConfigure()
+         m_xdgSurface->m_window->resizeFromApplyConfigure(m_pending.size);
+     }
+ 
+-    m_xdgSurface->setSizeHints();
+-
+     m_applied = m_pending;
+     qCDebug(lcQpaWayland) << "Applied pending xdg_toplevel configure event:" << m_applied.size << m_applied.states;
+ }
+@@ -203,12 +195,17 @@ QtWayland::xdg_toplevel::resize_edge QWaylandXdgSurface::Toplevel::convertToResi
+                 | ((edges & Qt::RightEdge) ? resize_edge_right : 0));
+ }
+ 
+-QWaylandXdgSurface::Popup::Popup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parent,
++QWaylandXdgSurface::Popup::Popup(QWaylandXdgSurface *xdgSurface, QWaylandWindow *parent,
+                                  QtWayland::xdg_positioner *positioner)
+-    : xdg_popup(xdgSurface->get_popup(parent->object(), positioner->object()))
+-    , m_xdgSurface(xdgSurface)
++    : m_xdgSurface(xdgSurface)
++    , m_parentXdgSurface(qobject_cast<QWaylandXdgSurface *>(parent->shellSurface()))
+     , m_parent(parent)
+ {
++
++    init(xdgSurface->get_popup(m_parentXdgSurface ? m_parentXdgSurface->object() : nullptr, positioner->object()));
++    if (m_parent) {
++        m_parent->addChildPopup(m_xdgSurface->window());
++    }
+ }
+ 
+ QWaylandXdgSurface::Popup::~Popup()
+@@ -216,10 +213,24 @@ QWaylandXdgSurface::Popup::~Popup()
+     if (isInitialized())
+         destroy();
+ 
++    if (m_parent) {
++        m_parent->removeChildPopup(m_xdgSurface->window());
++    }
++
+     if (m_grabbing) {
+         auto *shell = m_xdgSurface->m_shell;
+         Q_ASSERT(shell->m_topmostGrabbingPopup == this);
+-        shell->m_topmostGrabbingPopup = m_parent->m_popup;
++        shell->m_topmostGrabbingPopup = m_parentXdgSurface ? m_parentXdgSurface->m_popup : nullptr;
++        m_grabbing = false;
++
++        // Synthesize Qt enter/leave events for popup
++        QWindow *leave = nullptr;
++        if (m_xdgSurface && m_xdgSurface->window())
++            leave = m_xdgSurface->window()->window();
++        QWindowSystemInterface::handleLeaveEvent(leave);
++
++        if (QWindow *enter = QGuiApplication::topLevelAt(QCursor::pos()))
++            QWindowSystemInterface::handleEnterEvent(enter, enter->mapFromGlobal(QCursor::pos()), QCursor::pos());
+     }
+ }
+ 
+@@ -257,6 +268,7 @@ QWaylandXdgSurface::QWaylandXdgSurface(QWaylandXdgShell *shell, ::xdg_surface *s
+                 m_toplevel->set_parent(parentXdgSurface->m_toplevel->object());
+         }
+     }
++    setSizeHints();
+ }
+ 
+ QWaylandXdgSurface::~QWaylandXdgSurface()
+@@ -400,8 +412,6 @@ void QWaylandXdgSurface::setPopup(QWaylandWindow *parent)
+ {
+     Q_ASSERT(!m_toplevel && !m_popup);
+ 
+-    auto parentXdgSurface = static_cast<QWaylandXdgSurface *>(parent->shellSurface());
+-
+     auto positioner = new QtWayland::xdg_positioner(m_shell->create_positioner());
+     // set_popup expects a position relative to the parent
+     QPoint transientPos = m_window->geometry().topLeft(); // this is absolute
+@@ -414,8 +424,9 @@ void QWaylandXdgSurface::setPopup(QWaylandWindow *parent)
+     positioner->set_anchor(QtWayland::xdg_positioner::anchor_top_left);
+     positioner->set_gravity(QtWayland::xdg_positioner::gravity_bottom_right);
+     positioner->set_size(m_window->geometry().width(), m_window->geometry().height());
+-    m_popup = new Popup(this, parentXdgSurface, positioner);
++    m_popup = new Popup(this, parent, positioner);
+     positioner->destroy();
++
+     delete positioner;
+ }
+ 
+@@ -437,6 +448,23 @@ void QWaylandXdgSurface::setGrabPopup(QWaylandWindow *parent, QWaylandInputDevic
+     }
+     setPopup(parent);
+     m_popup->grab(device, serial);
++
++    // Synthesize Qt enter/leave events for popup
++    if (!parent)
++        return;
++    QWindow *current = QGuiApplication::topLevelAt(QCursor::pos());
++    QWindow *leave = parent->window();
++    if (current != leave)
++        return;
++
++    QWindowSystemInterface::handleLeaveEvent(leave);
++
++    QWindow *enter = nullptr;
++    if (m_popup && m_popup->m_xdgSurface && m_popup->m_xdgSurface->window())
++        enter = m_popup->m_xdgSurface->window()->window();
++
++    if (enter)
++        QWindowSystemInterface::handleEnterEvent(enter, enter->mapFromGlobal(QCursor::pos()), QCursor::pos());
+ }
+ 
+ void QWaylandXdgSurface::xdg_surface_configure(uint32_t serial)
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
+index 96785205..4b518f0a 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
+@@ -131,14 +131,15 @@ private:
+ 
+     class Popup : public QtWayland::xdg_popup {
+     public:
+-        Popup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parent, QtWayland::xdg_positioner *positioner);
++        Popup(QWaylandXdgSurface *xdgSurface, QWaylandWindow *parent, QtWayland::xdg_positioner *positioner);
+         ~Popup() override;
+ 
+         void grab(QWaylandInputDevice *seat, uint serial);
+         void xdg_popup_popup_done() override;
+ 
+         QWaylandXdgSurface *m_xdgSurface = nullptr;
+-        QWaylandXdgSurface *m_parent = nullptr;
++        QWaylandXdgSurface *m_parentXdgSurface = nullptr;
++        QWaylandWindow *m_parent = nullptr;
+         bool m_grabbing = false;
+     };
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
+index 8769d971..da0dd6a7 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
+@@ -69,20 +69,6 @@ QWaylandShellSurface *QWaylandXdgShellIntegration::createShellSurface(QWaylandWi
+     return m_xdgShell->getXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellIntegration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus)
+-{
+-    if (newFocus) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurface *>(newFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowActivated(newFocus);
+-    }
+-    if (oldFocus && qobject_cast<QWaylandXdgSurface *>(oldFocus->shellSurface())) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurface *>(oldFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowDeactivated(oldFocus);
+-    }
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
+index b6caa6c9..2f929f98 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
+@@ -65,7 +65,6 @@ public:
+     QWaylandXdgShellIntegration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShell> m_xdgShell;
+diff --git a/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp b/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
+index 526d0ef4..f50ccf30 100644
+--- a/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
++++ b/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
+@@ -39,7 +39,10 @@
+ 
+ #include "qwaylandinputmethodeventbuilder_p.h"
+ 
++#include <QBrush>
++#include <QGuiApplication>
+ #include <QInputMethod>
++#include <QPalette>
+ #include <QTextCharFormat>
+ 
+ #ifdef QT_BUILD_WAYLANDCOMPOSITOR_LIB
+@@ -81,32 +84,38 @@ void QWaylandInputMethodEventBuilder::addPreeditStyling(uint32_t index, uint32_t
+     QTextCharFormat format;
+ 
+     switch (style) {
+-    case 0:
+-    case 1:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_NONE:
++        break;
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_DEFAULT:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_UNDERLINE:
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-    case 2:
+-    case 3:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_ACTIVE:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_INACTIVE:
+         format.setFontWeight(QFont::Bold);
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-    case 4:
+-        format.setFontUnderline(true);
+-        format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+-        m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_HIGHLIGHT:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_SELECTION:
++        {
++            format.setFontUnderline(true);
++            format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
++            QPalette palette = qApp->palette();
++            format.setBackground(QBrush(palette.color(QPalette::Active, QPalette::Highlight)));
++            format.setForeground(QBrush(palette.color(QPalette::Active, QPalette::HighlightedText)));
++            m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
++        }
+         break;
+-    case 5:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_INCORRECT:
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::WaveUnderline);
+         format.setUnderlineColor(QColor(Qt::red));
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-//    case QtWayland::wl_text_input::preedit_style_selection:
+-//    case QtWayland::wl_text_input::preedit_style_none:
+     default:
+         break;
+     }
+@@ -153,7 +162,7 @@ QInputMethodEvent QWaylandInputMethodEventBuilder::buildPreedit(const QString &t
+ 
+     if (m_preeditCursor < 0) {
+         attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, 0, QVariant()));
+-    } else if (m_preeditCursor > 0) {
++    } else {
+         attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, indexFromWayland(text, m_preeditCursor), 1, QVariant()));
+     }
+ 
+diff --git a/qtwayland/src/shared/qwaylandmimehelper.cpp b/qtwayland/src/shared/qwaylandmimehelper.cpp
+index a5fdd34d..e2fe1928 100644
+--- a/qtwayland/src/shared/qwaylandmimehelper.cpp
++++ b/qtwayland/src/shared/qwaylandmimehelper.cpp
+@@ -60,7 +60,7 @@ QByteArray QWaylandMimeHelper::getByteArray(QMimeData *mimeData, const QString &
+             buf.open(QIODevice::ReadWrite);
+             QByteArray fmt = "BMP";
+             if (mimeType.startsWith(QLatin1String("image/"))) {
+-                QByteArray imgFmt = mimeType.mid(6).toUpper().toLatin1();
++                QByteArray imgFmt = mimeType.mid(6).toLower().toLatin1();
+                 if (QImageWriter::supportedImageFormats().contains(imgFmt))
+                     fmt = imgFmt;
+             }
+@@ -74,7 +74,7 @@ QByteArray QWaylandMimeHelper::getByteArray(QMimeData *mimeData, const QString &
+         QList<QUrl> urls = mimeData->urls();
+         for (int i = 0; i < urls.count(); ++i) {
+             content.append(urls.at(i).toEncoded());
+-            content.append('\n');
++            content.append("\r\n");
+         }
+     } else {
+         content = mimeData->data(mimeType);
+diff --git a/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp b/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
+index 1568b3b9..067410d0 100644
+--- a/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
++++ b/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
+@@ -35,7 +35,7 @@
+ 
+ using namespace MockCompositor;
+ 
+-constexpr int dataDeviceVersion = 1;
++constexpr int dataDeviceVersion = 3;
+ 
+ class DataDeviceCompositor : public DefaultCompositor {
+ public:
+diff --git a/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp b/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
+index 9312c2e5..2ea382f1 100644
+--- a/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
++++ b/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
+@@ -73,6 +73,7 @@ private slots:
+     void multiTouch();
+     void multiTouchUpAndMotionFrame();
+     void tapAndMoveInSameFrame();
++    void cancelTouch();
+ };
+ 
+ void tst_seatv5::bindsToSeat()
+@@ -646,5 +647,34 @@ void tst_seatv5::tapAndMoveInSameFrame()
+     QTRY_COMPARE(window.m_events.last().touchPoints.first().state(), Qt::TouchPointState::TouchPointReleased);
+ }
+ 
++void tst_seatv5::cancelTouch()
++{
++    TouchWindow window;
++    QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
++
++    exec([=] {
++        auto *t = touch();
++        auto *c = client();
++        t->sendDown(xdgToplevel()->surface(), {32, 32}, 1);
++        t->sendFrame(c);
++        t->sendCancel(c);
++        t->sendFrame(c);
++    });
++
++    QTRY_VERIFY(!window.m_events.empty());
++    {
++        auto e = window.m_events.takeFirst();
++        QCOMPARE(e.type, QEvent::TouchBegin);
++        QCOMPARE(e.touchPointStates, Qt::TouchPointPressed);
++        QCOMPARE(e.touchPoints.length(), 1);
++        QCOMPARE(e.touchPoints.first().pos(), QPointF(32-window.frameMargins().left(), 32-window.frameMargins().top()));
++    }
++    {
++        auto e = window.m_events.takeFirst();
++        QCOMPARE(e.type, QEvent::TouchCancel);
++        QCOMPARE(e.touchPoints.length(), 0);
++    }
++}
++
+ QCOMPOSITOR_TEST_MAIN(tst_seatv5)
+ #include "tst_seatv5.moc"
+diff --git a/qtwayland/tests/auto/client/shared/corecompositor.cpp b/qtwayland/tests/auto/client/shared/corecompositor.cpp
+index 5c6c83ba..fa9b7662 100644
+--- a/qtwayland/tests/auto/client/shared/corecompositor.cpp
++++ b/qtwayland/tests/auto/client/shared/corecompositor.cpp
+@@ -27,6 +27,7 @@
+ ****************************************************************************/
+ 
+ #include "corecompositor.h"
++#include <thread>
+ 
+ namespace MockCompositor {
+ 
+diff --git a/qtwayland/tests/auto/client/shared/coreprotocol.cpp b/qtwayland/tests/auto/client/shared/coreprotocol.cpp
+index 0d988521..d1a2e7cb 100644
+--- a/qtwayland/tests/auto/client/shared/coreprotocol.cpp
++++ b/qtwayland/tests/auto/client/shared/coreprotocol.cpp
+@@ -451,6 +451,13 @@ void Touch::sendFrame(wl_client *client)
+         send_frame(r->handle);
+ }
+ 
++void Touch::sendCancel(wl_client *client)
++{
++    const auto touchResources = resourceMap().values(client);
++    for (auto *r : touchResources)
++        send_cancel(r->handle);
++}
++
+ uint Keyboard::sendEnter(Surface *surface)
+ {
+     auto serial = m_seat->m_compositor->nextSerial();
+diff --git a/qtwayland/tests/auto/client/shared/coreprotocol.h b/qtwayland/tests/auto/client/shared/coreprotocol.h
+index a1af137a..210d8ddb 100644
+--- a/qtwayland/tests/auto/client/shared/coreprotocol.h
++++ b/qtwayland/tests/auto/client/shared/coreprotocol.h
+@@ -158,7 +158,7 @@ class WlCompositor : public Global, public QtWaylandServer::wl_compositor
+ {
+     Q_OBJECT
+ public:
+-    explicit WlCompositor(CoreCompositor *compositor, int version = 3)
++    explicit WlCompositor(CoreCompositor *compositor, int version = 4)
+         : QtWaylandServer::wl_compositor(compositor->m_display, version)
+         , m_compositor(compositor)
+     {}
+@@ -364,6 +364,7 @@ public:
+     uint sendUp(wl_client *client, int id);
+     void sendMotion(wl_client *client, const QPointF &position, int id);
+     void sendFrame(wl_client *client);
++    void sendCancel(wl_client *client);
+ 
+     Seat *m_seat = nullptr;
+ };
+diff --git a/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp b/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
+index a415cbf5..b1d3d07d 100644
+--- a/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
++++ b/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
+@@ -342,7 +342,7 @@ Compositor::Compositor(MockCompositor *mockCompositor)
+         exit(EXIT_FAILURE);
+     }
+ 
+-    wl_global_create(m_display, &wl_compositor_interface, 1, this, bindCompositor);
++    wl_global_create(m_display, &wl_compositor_interface, 4, this, bindCompositor);
+ 
+     m_data_device_manager.reset(new DataDeviceManager(this, m_display));
+ 
+diff --git a/qtwayland/tests/auto/client/shared_old/mocksurface.cpp b/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
+index e9df5f90..c3246e4a 100644
+--- a/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
++++ b/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
+@@ -125,6 +125,16 @@ void Surface::surface_damage(Resource *resource,
+     Q_UNUSED(height);
+ }
+ 
++void Surface::surface_damage_buffer(Resource *resource,
++                                    int32_t x, int32_t y, int32_t width, int32_t height)
++{
++    Q_UNUSED(resource);
++    Q_UNUSED(x);
++    Q_UNUSED(y);
++    Q_UNUSED(width);
++    Q_UNUSED(height);
++}
++
+ void Surface::surface_frame(Resource *resource,
+                             uint32_t callback)
+ {
+diff --git a/qtwayland/tests/auto/client/shared_old/mocksurface.h b/qtwayland/tests/auto/client/shared_old/mocksurface.h
+index 949dc23d..d176837e 100644
+--- a/qtwayland/tests/auto/client/shared_old/mocksurface.h
++++ b/qtwayland/tests/auto/client/shared_old/mocksurface.h
+@@ -65,6 +65,8 @@ protected:
+                         struct wl_resource *buffer, int x, int y) override;
+     void surface_damage(Resource *resource,
+                         int32_t x, int32_t y, int32_t width, int32_t height) override;
++    void surface_damage_buffer(Resource *resource,
++                               int32_t x, int32_t y, int32_t width, int32_t height) override;
+     void surface_frame(Resource *resource,
+                        uint32_t callback) override;
+     void surface_commit(Resource *resource) override;
+diff --git a/qtwayland/tests/auto/client/surface/tst_surface.cpp b/qtwayland/tests/auto/client/surface/tst_surface.cpp
+index 95e4e609..60c672ce 100644
+--- a/qtwayland/tests/auto/client/surface/tst_surface.cpp
++++ b/qtwayland/tests/auto/client/surface/tst_surface.cpp
+@@ -129,6 +129,10 @@ void tst_surface::waitForFrameCallbackGl()
+     // Make sure we follow frame callbacks for some frames
+     for (int i = 0; i < 5; ++i) {
+         xdgPingAndWaitForPong(); // Make sure things have happened on the client
++        if (!qEnvironmentVariableIntValue("QT_WAYLAND_DISABLE_WINDOWDECORATION") && i == 0) {
++            QCOMPARE(bufferSpy.count(), 1);
++            bufferSpy.removeFirst();
++        }
+         exec([&] {
+             QVERIFY(bufferSpy.empty()); // Make sure no extra buffers have arrived
+             QVERIFY(!xdgToplevel()->surface()->m_waitingFrameCallbacks.empty());
+diff --git a/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp b/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
+index 2277bbb8..747875b4 100644
+--- a/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
++++ b/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
+@@ -31,6 +31,7 @@
+ #include <QtGui/QOpenGLWindow>
+ #include <QtGui/qpa/qplatformnativeinterface.h>
+ #include <QtWaylandClient/private/wayland-wayland-client-protocol.h>
++#include <QtWaylandClient/private/qwaylandwindow_p.h>
+ 
+ using namespace MockCompositor;
+ 
+@@ -45,6 +46,7 @@ private slots:
+     void configureStates();
+     void popup();
+     void tooltipOnPopup();
++    void tooltipAndSiblingPopup();
+     void switchPopups();
+     void hidePopupParent();
+     void pongs();
+@@ -138,6 +140,7 @@ void tst_xdgshell::configureSize()
+ 
+ void tst_xdgshell::configureStates()
+ {
++    QVERIFY(qputenv("QT_WAYLAND_FRAME_CALLBACK_TIMEOUT", "0"));
+     QRasterWindow window;
+     window.resize(64, 48);
+     window.show();
+@@ -154,9 +157,12 @@ void tst_xdgshell::configureStates()
+     // Toplevel windows don't know their position on xdg-shell
+ //    QCOMPARE(window.frameGeometry().topLeft(), QPoint()); // TODO: this doesn't currently work when window decorations are enabled
+ 
+-//    QEXPECT_FAIL("", "configure has already been acked, we shouldn't have to wait for isActive", Continue);
+-//    QVERIFY(window.isActive());
+-    QTRY_VERIFY(window.isActive()); // Just make sure it eventually get's set correctly
++    // window.windowstate() is driven by keyboard focus, however for decorations we want to follow
++    // XDGShell this is internal to QtWayland so it is queried directly
++    auto waylandWindow = static_cast<QtWaylandClient::QWaylandWindow *>(window.handle());
++    Q_ASSERT(waylandWindow);
++    QTRY_VERIFY(waylandWindow->windowStates().testFlag(
++            Qt::WindowActive)); // Just make sure it eventually get's set correctly
+ 
+     const QSize screenSize(640, 480);
+     const uint maximizedSerial = exec([=] {
+@@ -186,6 +192,7 @@ void tst_xdgshell::configureStates()
+     QCOMPARE(window.windowStates(), Qt::WindowNoState);
+     QCOMPARE(window.frameGeometry().size(), windowedSize);
+ //    QCOMPARE(window.frameGeometry().topLeft(), QPoint()); // TODO: this doesn't currently work when window decorations are enabled
++    QVERIFY(qunsetenv("QT_WAYLAND_FRAME_CALLBACK_TIMEOUT"));
+ }
+ 
+ void tst_xdgshell::popup()
+@@ -340,6 +347,92 @@ void tst_xdgshell::tooltipOnPopup()
+     QCOMPOSITOR_TRY_COMPARE(xdgPopup(0), nullptr);
+ }
+ 
++void tst_xdgshell::tooltipAndSiblingPopup()
++{
++    class ToolTip : public QRasterWindow {
++    public:
++        explicit ToolTip(QWindow *parent) {
++            setTransientParent(parent);
++            setFlags(Qt::ToolTip);
++            resize(100, 100);
++            show();
++        }
++        void mousePressEvent(QMouseEvent *event) override {
++            QRasterWindow::mousePressEvent(event);
++            m_popup = new QRasterWindow;
++            m_popup->setTransientParent(transientParent());
++            m_popup->setFlags(Qt::Popup);
++            m_popup->resize(100, 100);
++            m_popup->show();
++        }
++
++        QRasterWindow *m_popup = nullptr;
++    };
++
++    class Window : public QRasterWindow {
++    public:
++        void mousePressEvent(QMouseEvent *event) override {
++            QRasterWindow::mousePressEvent(event);
++            m_tooltip = new ToolTip(this);
++        }
++        ToolTip *m_tooltip = nullptr;
++    };
++
++    Window window;
++    window.resize(200, 200);
++    window.show();
++
++    QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
++    exec([=] { xdgToplevel()->sendCompleteConfigure(); });
++    QCOMPOSITOR_TRY_VERIFY(xdgToplevel()->m_xdgSurface->m_committedConfigureSerial);
++
++    exec([=] {
++        auto *surface = xdgToplevel()->surface();
++        auto *p = pointer();
++        auto *c = client();
++        p->sendEnter(surface, {100, 100});
++        p->sendFrame(c);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_pressed);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_released);
++        p->sendFrame(c);
++        p->sendLeave(surface);
++        p->sendFrame(c);
++    });
++
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup());
++    exec([=] { xdgPopup()->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup()->m_xdgSurface->m_committedConfigureSerial);
++    QCOMPOSITOR_TRY_VERIFY(!xdgPopup()->m_grabbed);
++
++    exec([=] {
++        auto *surface = xdgPopup()->surface();
++        auto *p = pointer();
++        auto *c = client();
++        p->sendEnter(surface, {100, 100});
++        p->sendFrame(c);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_pressed);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_released);
++        p->sendFrame(c);
++    });
++
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1));
++    exec([=] { xdgPopup(1)->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1)->m_xdgSurface->m_committedConfigureSerial);
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1)->m_grabbed);
++
++    // Close the middle tooltip (it should not close the sibling popup)
++    window.m_tooltip->close();
++
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(1), nullptr);
++    // Verify the remaining xdg surface is a grab popup..
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(0));
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(0)->m_grabbed);
++
++    window.m_tooltip->m_popup->close();
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(1), nullptr);
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(0), nullptr);
++}
++
+ // QTBUG-65680
+ void tst_xdgshell::switchPopups()
+ {
+@@ -505,7 +598,7 @@ void tst_xdgshell::minMaxSize()
+     window.show();
+     QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
+ 
+-    exec([=] { xdgToplevel()->sendCompleteConfigure(); });
++    // we don't roundtrip with our configuration the initial commit should be correct
+ 
+     QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.minSize, QSize(100, 100));
+     QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.maxSize, QSize(1000, 1000));
+Submodule qtwebchannel 618422ee..f8949655:
+diff --git a/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp b/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
+index 536eb5c..898d769 100644
+--- a/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
++++ b/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
+@@ -186,8 +186,6 @@ Q_DECLARE_TYPEINFO(OverloadResolutionCandidate, Q_MOVABLE_TYPE);
+ QMetaObjectPublisher::QMetaObjectPublisher(QWebChannel *webChannel)
+     : QObject(webChannel)
+     , webChannel(webChannel)
+-    , signalHandler(this)
+-    , clientIsIdle(false)
+     , blockUpdates(false)
+     , propertyUpdatesInitialized(false)
+ {
+@@ -301,17 +299,17 @@ QJsonObject QMetaObjectPublisher::classInfoForObject(const QObject *object, QWeb
+     return data;
+ }
+ 
+-void QMetaObjectPublisher::setClientIsIdle(bool isIdle)
++void QMetaObjectPublisher::setClientIsIdle(bool isIdle, QWebChannelAbstractTransport *transport)
+ {
+-    if (clientIsIdle == isIdle) {
+-        return;
+-    }
+-    clientIsIdle = isIdle;
+-    if (!isIdle && timer.isActive()) {
+-        timer.stop();
+-    } else if (isIdle && !timer.isActive()) {
+-        timer.start(PROPERTY_UPDATE_INTERVAL, this);
+-    }
++    transportState[transport].clientIsIdle = isIdle;
++    if (isIdle)
++        sendEnqueuedPropertyUpdates(transport);
++}
++
++bool QMetaObjectPublisher::isClientIdle(QWebChannelAbstractTransport *transport)
++{
++    auto found = transportState.find(transport);
++    return found != transportState.end() && found.value().clientIsIdle;
+ }
+ 
+ QJsonObject QMetaObjectPublisher::initializeClient(QWebChannelAbstractTransport *transport)
+@@ -333,6 +331,7 @@ QJsonObject QMetaObjectPublisher::initializeClient(QWebChannelAbstractTransport
+ 
+ void QMetaObjectPublisher::initializePropertyUpdates(const QObject *const object, const QJsonObject &objectInfo)
+ {
++    auto *signalHandler = signalHandlerFor(object);
+     foreach (const QJsonValue &propertyInfoVar, objectInfo[KEY_PROPERTIES].toArray()) {
+         const QJsonArray &propertyInfo = propertyInfoVar.toArray();
+         if (propertyInfo.size() < 2) {
+@@ -353,19 +352,19 @@ void QMetaObjectPublisher::initializePropertyUpdates(const QObject *const object
+ 
+         // Only connect for a property update once
+         if (connectedProperties.isEmpty()) {
+-            signalHandler.connectTo(object, signalIndex);
++            signalHandler->connectTo(object, signalIndex);
+         }
+ 
+         connectedProperties.insert(propertyIndex);
+     }
+ 
+     // also always connect to destroyed signal
+-    signalHandler.connectTo(object, s_destroyedSignalIndex);
++    signalHandler->connectTo(object, s_destroyedSignalIndex);
+ }
+ 
+ void QMetaObjectPublisher::sendPendingPropertyUpdates()
+ {
+-    if (blockUpdates || !clientIsIdle || pendingPropertyUpdates.isEmpty()) {
++    if (blockUpdates) {
+         return;
+     }
+ 
+@@ -415,18 +414,19 @@ void QMetaObjectPublisher::sendPendingPropertyUpdates()
+ 
+     // data does not contain specific updates
+     if (!data.isEmpty()) {
+-        setClientIsIdle(false);
+-
+         message[KEY_DATA] = data;
+-        broadcastMessage(message);
++        enqueueBroadcastMessage(message);
+     }
+ 
+     // send every property update which is not supposed to be broadcasted
+     const QHash<QWebChannelAbstractTransport*, QJsonArray>::const_iterator suend = specificUpdates.constEnd();
+     for (QHash<QWebChannelAbstractTransport*, QJsonArray>::const_iterator it = specificUpdates.constBegin(); it != suend; ++it) {
+         message[KEY_DATA] = it.value();
+-        it.key()->sendMessage(message);
++        enqueueMessage(message, it.key());
+     }
++
++    for (auto state = transportState.begin(); state != transportState.end(); ++state)
++        sendEnqueuedPropertyUpdates(state.key());
+ }
+ 
+ QVariant QMetaObjectPublisher::invokeMethod(QObject *const object, const QMetaMethod &method,
+@@ -572,7 +572,7 @@ void QMetaObjectPublisher::signalEmitted(const QObject *object, const int signal
+         }
+     } else {
+         pendingPropertyUpdates[object][signalIndex] = arguments;
+-        if (clientIsIdle && !blockUpdates && !timer.isActive()) {
++        if (!blockUpdates && !timer.isActive()) {
+             timer.start(PROPERTY_UPDATE_INTERVAL, this);
+         }
+     }
+@@ -590,7 +590,7 @@ void QMetaObjectPublisher::objectDestroyed(const QObject *object)
+     // only remove from handler when we initialized the property updates
+     // cf: https://bugreports.qt.io/browse/QTBUG-60250
+     if (propertyUpdatesInitialized) {
+-        signalHandler.remove(object);
++        signalHandlerFor(object)->remove(object);
+         signalToPropertyMap.remove(object);
+     }
+     pendingPropertyUpdates.remove(object);
+@@ -852,6 +852,52 @@ void QMetaObjectPublisher::broadcastMessage(const QJsonObject &message) const
+     }
+ }
+ 
++void QMetaObjectPublisher::enqueueBroadcastMessage(const QJsonObject &message)
++{
++    if (webChannel->d_func()->transports.isEmpty()) {
++        qWarning("QWebChannel is not connected to any transports, cannot send message: %s",
++                 QJsonDocument(message).toJson().constData());
++        return;
++    }
++
++    for (auto *transport : webChannel->d_func()->transports) {
++        auto &state = transportState[transport];
++        state.queuedMessages.append(message);
++    }
++}
++
++void QMetaObjectPublisher::enqueueMessage(const QJsonObject &message,
++                                          QWebChannelAbstractTransport *transport)
++{
++    auto &state = transportState[transport];
++    state.queuedMessages.append(message);
++}
++
++void QMetaObjectPublisher::sendEnqueuedPropertyUpdates(QWebChannelAbstractTransport *transport)
++{
++    auto found = transportState.find(transport);
++    if (found != transportState.end() && found.value().clientIsIdle
++        && !found.value().queuedMessages.isEmpty()) {
++
++        // If the client is connected with an in-process transport, it can
++        // happen that a message triggers a subsequent property change. In
++        // that case, we need to ensure that the queued messages have already
++        // been cleared; otherwise the recursive call will send everythig again.
++        // Case in point: The qmlwebchannel tests fail if we don't clear the
++        // queued messages before sending them out.
++        // For that same reason set the client to "busy" (aka non-idle) just
++        // right before sending out the messages; otherwise a potential
++        // "Idle" type message will not correctly restore the Idle state.
++        const auto messages = std::move(found.value().queuedMessages);
++        Q_ASSERT(found.value().queuedMessages.isEmpty());
++        found.value().clientIsIdle = false;
++
++        for (const auto &message : messages) {
++            transport->sendMessage(message);
++        }
++    }
++}
++
+ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannelAbstractTransport *transport)
+ {
+     if (!webChannel->d_func()->transports.contains(transport)) {
+@@ -866,7 +912,7 @@ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannel
+ 
+     const MessageType type = toType(message.value(KEY_TYPE));
+     if (type == TypeIdle) {
+-        setClientIsIdle(true);
++        setClientIsIdle(true, transport);
+     } else if (type == TypeInit) {
+         if (!message.contains(KEY_ID)) {
+             qWarning("JSON message object is missing the id property: %s",
+@@ -913,9 +959,9 @@ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannel
+                 return;
+             transport->sendMessage(createResponse(message.value(KEY_ID), wrapResult(result, transport)));
+         } else if (type == TypeConnectToSignal) {
+-            signalHandler.connectTo(object, message.value(KEY_SIGNAL).toInt(-1));
++            signalHandlerFor(object)->connectTo(object, message.value(KEY_SIGNAL).toInt(-1));
+         } else if (type == TypeDisconnectFromSignal) {
+-            signalHandler.disconnectFrom(object, message.value(KEY_SIGNAL).toInt(-1));
++            signalHandlerFor(object)->disconnectFrom(object, message.value(KEY_SIGNAL).toInt(-1));
+         } else if (type == TypeSetProperty) {
+             setProperty(object, message.value(KEY_PROPERTY).toInt(-1),
+                         message.value(KEY_VALUE));
+@@ -931,6 +977,7 @@ void QMetaObjectPublisher::setBlockUpdates(bool block)
+     blockUpdates = block;
+ 
+     if (!blockUpdates) {
++        timer.start(PROPERTY_UPDATE_INTERVAL, this);
+         sendPendingPropertyUpdates();
+     } else if (timer.isActive()) {
+         timer.stop();
+@@ -948,4 +995,15 @@ void QMetaObjectPublisher::timerEvent(QTimerEvent *event)
+     }
+ }
+ 
++SignalHandler<QMetaObjectPublisher> *QMetaObjectPublisher::signalHandlerFor(const QObject *object)
++{
++    auto thread = object->thread();
++    auto it = signalHandlers.find(thread);
++    if (it == signalHandlers.end()) {
++        it = signalHandlers.emplace(thread, this).first;
++        it->second.moveToThread(thread);
++    }
++    return &it->second;
++}
++
+ QT_END_NAMESPACE
+diff --git a/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h b/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
+index bbd9875..4713ef1 100644
+--- a/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
++++ b/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
+@@ -59,6 +59,9 @@
+ #include <QBasicTimer>
+ #include <QPointer>
+ #include <QJsonObject>
++#include <QQueue>
++
++#include <unordered_map>
+ 
+ #include "qwebchannelglobal.h"
+ 
+@@ -109,17 +112,36 @@ public:
+      */
+     void broadcastMessage(const QJsonObject &message) const;
+ 
++    /**
++     * Enqueue the given @p message to all known transports.
++     */
++    void enqueueBroadcastMessage(const QJsonObject &message);
++
++    /**
++     * Enqueue the given @p message to @p transport.
++     */
++    void enqueueMessage(const QJsonObject &message, QWebChannelAbstractTransport *transport);
++
++    /**
++     * If client for given @p transport is idle, send queued messaged to @p transport and then mark
++     * the client as not idle.
++     */
++    void sendEnqueuedPropertyUpdates(QWebChannelAbstractTransport *transport);
++
+     /**
+      * Serialize the QMetaObject of @p object and return it in JSON form.
+      */
+     QJsonObject classInfoForObject(const QObject *object, QWebChannelAbstractTransport *transport);
+ 
+     /**
+-     * Set the client to idle or busy, based on the value of @p isIdle.
+-     *
+-     * When the value changed, start/stop the property update timer accordingly.
++     * Set the client to idle or busy for a single @p transport, based on the value of @p isIdle.
++     */
++    void setClientIsIdle(bool isIdle, QWebChannelAbstractTransport *transport);
++
++    /**
++     * Check that client is idle for @p transport.
+      */
+-    void setClientIsIdle(bool isIdle);
++    bool isClientIdle(QWebChannelAbstractTransport *transport);
+ 
+     /**
+      * Initialize clients by sending them the class information of the registered objects.
+@@ -272,10 +294,18 @@ private:
+     friend class TestWebChannel;
+ 
+     QWebChannel *webChannel;
+-    SignalHandler<QMetaObjectPublisher> signalHandler;
++    std::unordered_map<const QThread*, SignalHandler<QMetaObjectPublisher>> signalHandlers;
++    SignalHandler<QMetaObjectPublisher> *signalHandlerFor(const QObject *object);
+ 
+-    // true when the client is idle, false otherwise
+-    bool clientIsIdle;
++    struct TransportState
++    {
++        TransportState() : clientIsIdle(false) { }
++        // true when the client is idle, false otherwise
++        bool clientIsIdle;
++        // messages to send
++        QQueue<QJsonObject> queuedMessages;
++    };
++    QHash<QWebChannelAbstractTransport *, TransportState> transportState;
+ 
+     // true when no property updates should be sent, false otherwise
+     bool blockUpdates;
+diff --git a/qtwebchannel/src/webchannel/signalhandler_p.h b/qtwebchannel/src/webchannel/signalhandler_p.h
+index 27afadb..d77373c 100644
+--- a/qtwebchannel/src/webchannel/signalhandler_p.h
++++ b/qtwebchannel/src/webchannel/signalhandler_p.h
+@@ -56,6 +56,7 @@
+ #include <QVector>
+ #include <QMetaMethod>
+ #include <QDebug>
++#include <QThread>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -71,6 +72,7 @@ static const int s_destroyedSignalIndex = QObject::staticMetaObject.indexOfMetho
+ template<class Receiver>
+ class SignalHandler : public QObject
+ {
++    Q_DISABLE_COPY(SignalHandler)
+ public:
+     SignalHandler(Receiver *receiver, QObject *parent = 0);
+ 
+@@ -268,6 +270,7 @@ int SignalHandler<Receiver>::qt_metacall(QMetaObject::Call call, int methodId, v
+     if (call == QMetaObject::InvokeMetaMethod) {
+         const QObject *object = sender();
+         Q_ASSERT(object);
++        Q_ASSERT(QThread::currentThread() == object->thread());
+         Q_ASSERT(senderSignalIndex() == methodId);
+         Q_ASSERT(m_connectionsCounter.contains(object));
+         Q_ASSERT(m_connectionsCounter.value(object).contains(methodId));
+diff --git a/qtwebchannel/tests/auto/qml/testwebchannel.cpp b/qtwebchannel/tests/auto/qml/testwebchannel.cpp
+index 9891687..3ca81c2 100644
+--- a/qtwebchannel/tests/auto/qml/testwebchannel.cpp
++++ b/qtwebchannel/tests/auto/qml/testwebchannel.cpp
+@@ -46,7 +46,11 @@ TestWebChannel::~TestWebChannel()
+ 
+ bool TestWebChannel::clientIsIdle() const
+ {
+-    return QWebChannel::d_func()->publisher->clientIsIdle;
++    for (auto *transport : QWebChannel::d_func()->transports) {
++        if (QWebChannel::d_func()->publisher->isClientIdle(transport))
++            return true;
++    }
++    return false;
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp b/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
+index 181da9e..37f989a 100644
+--- a/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
++++ b/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
+@@ -785,7 +785,7 @@ void TestWebChannel::testTransportWrapObjectProperties()
+     DummyTransport *dummyTransport = new DummyTransport(this);
+     channel.connectTo(dummyTransport);
+     channel.d_func()->publisher->initializeClient(dummyTransport);
+-    channel.d_func()->publisher->setClientIsIdle(true);
++    channel.d_func()->publisher->setClientIsIdle(true, dummyTransport);
+ 
+     QCOMPARE(channel.d_func()->publisher->transportedWrappedObjects.size(), 0);
+ 
+@@ -943,8 +943,6 @@ void TestWebChannel::testInfiniteRecursion()
+ 
+ void TestWebChannel::testAsyncObject()
+ {
+-    QSKIP("This test is broken. See QTBUG-80729");
+-
+     QWebChannel channel;
+     channel.connectTo(m_dummyTransport);
+ 
+@@ -990,6 +988,50 @@ void TestWebChannel::testAsyncObject()
+     thread.wait();
+ }
+ 
++void TestWebChannel::testPropertyMultipleTransports()
++{
++    DummyTransport transport1;
++    DummyTransport transport2;
++
++    QWebChannel channel;
++    QMetaObjectPublisher *publisher = channel.d_func()->publisher;
++
++    TestObject testObj;
++    testObj.setObjectName("testObject");
++    channel.registerObject(testObj.objectName(), &testObj);
++    channel.connectTo(&transport1);
++    channel.connectTo(&transport2);
++
++    testObj.setProp("Hello");
++
++    publisher->initializeClient(&transport1);
++    publisher->initializeClient(&transport2);
++    publisher->setClientIsIdle(true, &transport1);
++    QCOMPARE(publisher->isClientIdle(&transport1), true);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++    QVERIFY(transport1.messagesSent().isEmpty());
++    QVERIFY(transport2.messagesSent().isEmpty());
++
++    testObj.setProp("World");
++    QTRY_COMPARE_WITH_TIMEOUT(transport1.messagesSent().size(), 1u, 2000);
++    QCOMPARE(transport2.messagesSent().size(), 0u);
++    publisher->setClientIsIdle(true, &transport2);
++    QTRY_COMPARE_WITH_TIMEOUT(transport2.messagesSent().size(), 1u, 2000);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++
++    testObj.setProp("!!!");
++    publisher->setClientIsIdle(true, &transport2);
++    QCOMPARE(publisher->isClientIdle(&transport2), true);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QTRY_COMPARE_WITH_TIMEOUT(transport2.messagesSent().size(), 2u, 2000);
++    QCOMPARE(transport1.messagesSent().size(), 1u);
++    publisher->setClientIsIdle(true, &transport1);
++    QTRY_COMPARE_WITH_TIMEOUT(transport1.messagesSent().size(), 2u, 2000);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++}
++
+ class FunctionWrapper : public QObject
+ {
+     Q_OBJECT
+@@ -1082,7 +1124,7 @@ void TestWebChannel::benchInitializeClients()
+ 
+         publisher->propertyUpdatesInitialized = false;
+         publisher->signalToPropertyMap.clear();
+-        publisher->signalHandler.clear();
++        publisher->signalHandlers.clear();
+     }
+ }
+ 
+@@ -1107,7 +1149,7 @@ void TestWebChannel::benchPropertyUpdates()
+             obj->change();
+         }
+ 
+-        channel.d_func()->publisher->clientIsIdle = true;
++        channel.d_func()->publisher->setClientIsIdle(true, m_dummyTransport);
+         channel.d_func()->publisher->sendPendingPropertyUpdates();
+     }
+ }
+diff --git a/qtwebchannel/tests/auto/webchannel/tst_webchannel.h b/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
+index eae21f4..dd4e690 100644
+--- a/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
++++ b/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
+@@ -348,6 +348,7 @@ private slots:
+     void testJsonToVariant();
+     void testInfiniteRecursion();
+     void testAsyncObject();
++    void testPropertyMultipleTransports();
+     void testDeletionDuringMethodInvocation_data();
+     void testDeletionDuringMethodInvocation();
+ 
+Submodule qtwebengine f328054d...38e0df6c (commits not present)
+Submodule qtwebsockets 65850954..63fb8da1:
+diff --git a/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp b/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
+index 2affdd5..95f1194 100644
+--- a/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
++++ b/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
+@@ -273,6 +273,7 @@ void QWebSocketDataProcessor::clear()
+     if (!m_pConverterState)
+         m_pConverterState = new QTextCodec::ConverterState(QTextCodec::ConvertInvalidToNull |
+                                                            QTextCodec::IgnoreHeader);
++    frame.clear();
+ }
+ 
+ /*!
+diff --git a/qtwebsockets/src/websockets/qwebsocketprotocol.cpp b/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
+index df87a93..d0465f1 100644
+--- a/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
++++ b/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
+@@ -210,7 +210,7 @@ void QWebSocketProtocol::mask(char *payload, quint64 size, quint32 maskingKey)
+                             quint8((maskingKey & 0x0000FF00u) >> 8),
+                             quint8((maskingKey & 0x000000FFu))
+                           };
+-    int i = 0;
++    quint64 i = 0;
+     while (size-- > 0)
+         *payload++ ^= mask[i++ % 4];
+ }
diff --git a/srcpkgs/qt5/template b/srcpkgs/qt5/template
index f879df3a3e706..a0d3036af79a4 100644
--- a/srcpkgs/qt5/template
+++ b/srcpkgs/qt5/template
@@ -2,11 +2,11 @@
 #
 # revbump libqtxdg after bumping patch version
 pkgname=qt5
-version=5.15.7+20221119
+version=5.15.8
+revision=1
+build_style=meta
 # commit f8c9fb304bc3e53b3aa07f962cd74e9160decccc
 # base repo: https://invent.kde.org/qt/qt/qt5
-revision=8
-build_style=meta
 hostmakedepends="cmake clang flex perl glib-devel pkg-config
  python3 re2c ruby which"
 makedepends="SDL2-devel Vulkan-Headers alsa-lib-devel double-conversion-devel
@@ -29,9 +29,9 @@ homepage="https://qt.io/"
 # tarball is generated with `git archive-all qt5-$version.tar.gz`
 # to keep the size smaller qtwebengine, qtwebview, qtdocgallery, qtactiveqt and qtpim
 # can be marked with the export-ignore attribute
-distfiles="https://void.johnnynator.dev/distfiles/qt5-${version}.tar.gz"
-checksum=9d57af471c78029a362276b7c99108ea009f511bb9ba6ff6cb884f6ddd255e9f
-python_version=3
+distfiles="https://download.qt.io/archive/qt/5.15/${version}/single/qt-everywhere-opensource-src-${version}.tar.xz"
+checksum=776a9302c336671f9406a53bd30b8e36f825742b2ec44a57c08217bff0fa86b9
+python_version=2 #unverified
 replaces="qt5-doc<5.6.0 qt5-quick1<5.6.0 qt5-quick1-devel<5.6.0 qt5-webkit<5.6.0 qt5-webkit-devel<5.6.0
  qt5-enginio<5.7.1 qt5-enginio-devel<5.7.1 qt5-plugin-gtk<5.7.1 qt5-canvas3d<5.13.0"
 lib32mode=full
@@ -246,7 +246,6 @@ do_configure() {
 	# opts+=" -v"
 	opts+=" -skip qtwebengine"
 	opts+=" -skip qtwebview"
-	opts+=" -skip qtdocgallery"
 	opts+=" -skip qtpim"
 	opts+=" -skip qtsystems"
 	opts+=" -skip qtspeech"

From 8fa5563db3bae26f6f409c6974c0a409775f046c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 063/115] qtav: revbump for ffmpeg4-4.4.3

---
 srcpkgs/qtav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qtav/template b/srcpkgs/qtav/template
index 775d5a139a9ef..2d00ad104355e 100644
--- a/srcpkgs/qtav/template
+++ b/srcpkgs/qtav/template
@@ -4,7 +4,7 @@ version=1.13.0
 revision=2
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel libass-devel libopenal-devel
+makedepends="ffmpeg4-devel libass-devel libopenal-devel
  libva-glx-devel libXv-devel pulseaudio-devel
  qt5-declarative-devel qt5-svg-devel
  qt5-quickcontrols"

From fadf06fbe146648854d3acb7e6815b2cef857640 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 064/115] qtox: revbump for ffmpeg-6.0

---
 srcpkgs/qtox/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qtox/template b/srcpkgs/qtox/template
index 39c643fecdb5a..bb70e7f51240a 100644
--- a/srcpkgs/qtox/template
+++ b/srcpkgs/qtox/template
@@ -1,7 +1,7 @@
 # Template file for 'qtox'
 pkgname=qtox
 version=1.17.6
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DUPDATE_CHECK=OFF
  -DGIT_DESCRIBE=${version}

From 38853d5e20fc6b9d92db785151f926eeb01b8478 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 065/115] retroarch: revbump for ffmpeg-6.0

---
 srcpkgs/retroarch/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroarch/template b/srcpkgs/retroarch/template
index cb3125c5dbf1a..c65c26f7bf033 100644
--- a/srcpkgs/retroarch/template
+++ b/srcpkgs/retroarch/template
@@ -1,7 +1,7 @@
 # Template file for 'retroarch'
 pkgname=retroarch
 version=1.16.0.3
-revision=3
+revision=4
 build_style=configure
 configure_args="--prefix=/usr --sysconfdir=/etc --enable-networking
  --enable-udev --disable-builtinflac --disable-builtinglslang

From c87f564a7a97bb2cb5e7ef0a60966c38a38b0c4c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 066/115] scrcpy: revbump for ffmpeg-6.0

---
 srcpkgs/scrcpy/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/scrcpy/template b/srcpkgs/scrcpy/template
index ac18bc03418ce..f39a7f678ab35 100644
--- a/srcpkgs/scrcpy/template
+++ b/srcpkgs/scrcpy/template
@@ -1,7 +1,7 @@
 # Template file for 'scrcpy'
 pkgname=scrcpy
 version=2.1.1
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcompile_server=false
  -Dprebuilt_server=/usr/share/scrcpy/scrcpy-server-v${version}"

From 02d70d400a250545b362db8fe955b88dcf31d1b8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 17 Oct 2023 08:54:11 -0400
Subject: [PATCH 067/115] New package: spex-x replaces spek-alternative for
 ffmpeg-6.0

---
 srcpkgs/spek-alternative                      |  1 +
 srcpkgs/{spek-alternative => spek-x}/template | 22 ++++++++++++-------
 2 files changed, 15 insertions(+), 8 deletions(-)
 create mode 120000 srcpkgs/spek-alternative
 rename srcpkgs/{spek-alternative => spek-x}/template (52%)

diff --git a/srcpkgs/spek-alternative b/srcpkgs/spek-alternative
new file mode 120000
index 0000000000000..76648236da701
--- /dev/null
+++ b/srcpkgs/spek-alternative
@@ -0,0 +1 @@
+spek-x
\ No newline at end of file
diff --git a/srcpkgs/spek-alternative/template b/srcpkgs/spek-x/template
similarity index 52%
rename from srcpkgs/spek-alternative/template
rename to srcpkgs/spek-x/template
index d7b55c776b1d4..3ded6c2c323e4 100644
--- a/srcpkgs/spek-alternative/template
+++ b/srcpkgs/spek-x/template
@@ -1,18 +1,18 @@
-# Template file for 'spek-alternative'
-pkgname=spek-alternative
-version=0.8.2.3
-revision=2
+# Template file for 'spek-x'
+pkgname=spek-x
+version=0.9.3
+revision=1
 build_style=gnu-configure
 hostmakedepends="automake gettext-devel intltool libtool pkg-config
  wxWidgets-common wxWidgets-gtk3-devel"
 makedepends="ffmpeg-devel wxWidgets-gtk3-devel"
 depends="ffmpeg"
 short_desc="Acoustic spectrum analyser"
-maintainer="Kartik Singh <kartik.ynwa@gmail.com>"
+maintainer="zlice <zlice555@gmail.com>"
 license="GPL-3.0-or-later"
-homepage="https://github.com/withmorten/spek-alternative"
-distfiles="https://github.com/withmorten/spek-alternative/archive/${version}.tar.gz"
-checksum="007ba4b84a310b078e378aa84c8e80783db5821437a757a488c3ecec377e6b2a"
+homepage="https://github.com/MikeWang000000/spek-x"
+distfiles="https://github.com/MikeWang000000/spek-x/archive/v${version}.tar.gz"
+checksum="7f4b109903333cdd310ab2b9176f0dc49a565891376e281a233d342cedf90ef7"
 
 CXXFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
 
@@ -22,3 +22,9 @@ export WX_CONFIG_NAME="wx-config-gtk3"
 pre_configure() {
 	NOCONFIGURE=1 ./autogen.sh
 }
+
+spek-alternative_package() {
+	depends="spek-x"
+	short_desc+=" - transitional dummy package"
+	build_style=meta
+}

From 5d471e21274aacc92dc4979efb527d69d0f5f65b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 068/115] ssr: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ssr/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ssr/template b/srcpkgs/ssr/template
index 842b2423aad10..3448ca110eb0c 100644
--- a/srcpkgs/ssr/template
+++ b/srcpkgs/ssr/template
@@ -5,7 +5,7 @@ revision=2
 build_style=cmake
 configure_args="-DWITH_QT5=ON"
 hostmakedepends="pkg-config"
-makedepends="alsa-lib-devel ffmpeg-devel glu-devel jack-devel pulseaudio-devel
+makedepends="alsa-lib-devel ffmpeg4-devel glu-devel jack-devel pulseaudio-devel
  qt5-tools-devel qt5-x11extras-devel libXinerama-devel v4l-utils-devel"
 depends="desktop-file-utils hicolor-icon-theme"
 short_desc="Simple Screen Recorder for programs and games"

From 530c958b1a9ab503b59f4b5bc6edc46bfaa870ef Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 069/115] synfig: revbump for ffmpeg-6.0 and mlt7

---
 srcpkgs/synfig/patches/ffmpeg6.patch | 71 ++++++++++++++++++++++++++++
 srcpkgs/synfig/template              |  4 +-
 2 files changed, 73 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/synfig/patches/ffmpeg6.patch

diff --git a/srcpkgs/synfig/patches/ffmpeg6.patch b/srcpkgs/synfig/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..10780b42782f4
--- /dev/null
+++ b/srcpkgs/synfig/patches/ffmpeg6.patch
@@ -0,0 +1,71 @@
+--- a/src/modules/mod_libavcodec/trgt_av.cpp	2022-10-25 09:14:12.000000000 -0400
++++ b/src/modules/mod_libavcodec/trgt_av.cpp	2023-05-05 21:34:17.899194559 -0400
+@@ -38,6 +41,7 @@
+ extern "C"
+ {
+ #ifdef HAVE_LIBAVFORMAT_AVFORMAT_H
++#	include <libavcodec/avcodec.h>
+ #	include <libavformat/avformat.h>
+ #elif defined(HAVE_AVFORMAT_H)
+ #	include <avformat.h>
+@@ -155,11 +156,11 @@
+     }
+ 
+ 	bool open_video_stream() {
+-		if (avcodec_open2(video_context, NULL, NULL) < 0) {
++		if (avcodec_open2(video_context, nullptr, nullptr) < 0) {
+ 			synfig::error("Target_LibAVCodec: could not open video codec");
+ 			// seems the calling of avcodec_free_context after error will cause crash
+ 			// so just forget about this context
+-			video_context = NULL;
++			video_context = nullptr;
+ 			close();
+ 			return false;
+         }
+@@ -234,15 +235,21 @@
+ 		close();
+ 
+ 		if (!av_registered) {
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 			av_register_all();
++#endif
+ 			av_registered = true;
+ 		}
+ 
+ 		// guess format
+-		AVOutputFormat *format = av_guess_format(NULL, filename.c_str(), NULL);
++#if LIBAVCODEC_VERSION_MAJOR < 59 // FFMPEG < 5.0
++		AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#else
++		const AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#endif
+ 		if (!format) {
+ 			synfig::warning("Target_LibAVCodec: unable to guess the output format, defaulting to MPEG");
+-			format = av_guess_format("mpeg", NULL, NULL);
++			format = av_guess_format("mpeg", nullptr, nullptr);
+ 		}
+ 		if (!format) {
+ 			synfig::error("Target_LibAVCodec: unable to find 'mpeg' output format");
+@@ -254,6 +261,7 @@
+ 		context = avformat_alloc_context();
+ 		assert(context);
+ 		context->oformat = format;
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 		if (filename.size() + 1 > sizeof(context->filename)) {
+ 			synfig::error(
+ 				"Target_LibAVCodec: filename too long, max length is %d, filename is '%s'",
+@@ -263,6 +271,14 @@
+ 			return false;
+ 		}
+ 		memcpy(context->filename, filename.c_str(), filename.size() + 1);
++#else
++		context->url = av_strndup(filename.c_str(), filename.size());
++		if (!context->url) {
++			synfig::error("Target_LibAVCodec: cannot allocate space for filename");
++			close();
++			return false;
++		}
++#endif
+ 
+ 		packet = av_packet_alloc();
+ 		assert(packet);
diff --git a/srcpkgs/synfig/template b/srcpkgs/synfig/template
index d4d3e341a20bf..703cfd7ebac84 100644
--- a/srcpkgs/synfig/template
+++ b/srcpkgs/synfig/template
@@ -6,7 +6,7 @@ revision=4
 build_style=gnu-configure
 configure_args="--with-boost-libdir=${XBPS_CROSS_BASE}/usr/lib"
 hostmakedepends="boost-build ImageMagick pkg-config intltool"
-makedepends="ETL gettext-devel libxml++-devel mlt-devel libmagick-devel
+makedepends="ETL gettext-devel libxml++-devel mlt7-devel libmagick-devel
  libmng-devel boost-build boost-devel libopenexr-devel ffmpeg-devel"
 depends="ImageMagick"
 short_desc="CLI 2D vector and timeline-based animation software"
@@ -20,7 +20,7 @@ CXXFLAGS="-std=c++11 -DHAVE_LOCALE_H=1"
 
 synfig-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision}
-	 libopenexr-devel libxml++-devel mlt-devel"
+	 libopenexr-devel libxml++-devel mlt7-devel"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/bin/synfig-config

From fb6d227fdf3aae92d92ca848b328d5b140c419e9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 070/115] timg: revbump for ffmpeg-6.0

---
 srcpkgs/timg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/timg/template b/srcpkgs/timg/template
index 2a2ab763d2fdd..8fb4327535ef9 100644
--- a/srcpkgs/timg/template
+++ b/srcpkgs/timg/template
@@ -1,7 +1,7 @@
 # Template file for 'timg'
 pkgname=timg
 version=1.4.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_OPENSLIDE_SUPPORT=off -Wno-dev"
 hostmakedepends="pkg-config git"

From 4abd7dc39ec81cf0e0fa0dc0873f6cb074b5de6c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 071/115] tvheadend: revbump for ffmpeg4-4.4.3

---
 srcpkgs/tvheadend/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tvheadend/template b/srcpkgs/tvheadend/template
index 9aea7de4ec705..012d31c4879ff 100644
--- a/srcpkgs/tvheadend/template
+++ b/srcpkgs/tvheadend/template
@@ -8,7 +8,7 @@ configure_args="--enable-dvbscan --disable-ffmpeg_static
 --disable-libx265_static --disable-libvpx_static --disable-libtheora_static
 --disable-libvorbis_static --disable-libfdkaac_static"
 hostmakedepends="gettext pkg-config python3 git which"
-makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg-devel"
+makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg4-devel"
 short_desc="TV streaming server"
 maintainer="lemmi <lemmi@nerd2nerd.org>"
 license="GPL-3.0-only"

From c677688c6262b536115178bd2a24b289dd1af2fd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 072/115] unpaper: update to 7.0.0.

---
 srcpkgs/unpaper/template | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/srcpkgs/unpaper/template b/srcpkgs/unpaper/template
index 38ed47a584016..1ff910e722afc 100644
--- a/srcpkgs/unpaper/template
+++ b/srcpkgs/unpaper/template
@@ -1,13 +1,13 @@
 # Template file for 'unpaper'
 pkgname=unpaper
-version=6.1
-revision=3
-build_style=gnu-configure
+version=7.0.0
+revision=1
+build_style=meson
+hostmakedepends="pkg-config meson libxslt"
+makedepends="ffmpeg-devel python3-Sphinx"
+short_desc="Post-processing tool for scanned sheets of paper"
 maintainer="Orphaned <orphan@voidlinux.org>"
-hostmakedepends="pkg-config libxslt"
-makedepends="ffmpeg-devel"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://www.flameeyes.eu/projects/unpaper"
-short_desc="A post-processing tool for scanned sheets of paper"
 distfiles="https://www.flameeyes.eu/files/${pkgname}-${version}.tar.xz"
-checksum=237c84f5da544b3f7709827f9f12c37c346cdf029b1128fb4633f9bafa5cb930
+checksum=2575fbbf26c22719d1cb882b59602c9900c7f747118ac130883f63419be46a80

From 2f2b8c07b54107cbebea9a8a634ec75c3a31ac45 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 073/115] vba-m: revbump for ffmpeg-6.0

---
 srcpkgs/vba-m/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vba-m/template b/srcpkgs/vba-m/template
index 9c71cefe3f8dd..2223d297c31f5 100644
--- a/srcpkgs/vba-m/template
+++ b/srcpkgs/vba-m/template
@@ -2,7 +2,7 @@
 pkgname=vba-m
 reverts=1292_2
 version=2.1.7
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DENABLE_GTK=TRUE -DENABLE_FFMPEG=TRUE -DENABLE_LINK=TRUE -DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="gettext pkg-config unzip zip yasm wxWidgets-gtk3-devel"

From a4daa4696773ce00cde7d5e5d8e955b41ba94f88 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 074/115] vice: revbump for ffmpeg4-4.4.3

---
 srcpkgs/vice/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vice/template b/srcpkgs/vice/template
index b1f866d35095e..4beab2c5f9ebd 100644
--- a/srcpkgs/vice/template
+++ b/srcpkgs/vice/template
@@ -26,7 +26,7 @@ makedepends="
 	$(vopt_if gtk3 gtk+3-devel)
 	$(vopt_if gtk3 pulseaudio-devel)
 	$(vopt_if gtk3 pango-devel)
-	$(vopt_if ffmpeg ffmpeg-devel)"
+	$(vopt_if ffmpeg ffmpeg4-devel)"
 short_desc="Emulator for C64, C128, CBM-II, PET, VIC20, Plus4 and C16"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"

From c0ac9e657a14a4e712098044dd2bd2144e3e4651 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 075/115] waypipe: revbump for ffmpeg-6.0

---
 srcpkgs/waypipe/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waypipe/template b/srcpkgs/waypipe/template
index 6da88b21bf2a1..4da8058400b58 100644
--- a/srcpkgs/waypipe/template
+++ b/srcpkgs/waypipe/template
@@ -1,7 +1,7 @@
 # Template file for 'waypipe'
 pkgname=waypipe
 version=0.8.6
-revision=1
+revision=2
 build_style=meson
 # lto is off because it causes linking errors in armv6l and armv7l (due to NEON)
 configure_args="-Dwerror=false -Dwith_dmabuf=enabled -Dwith_lz4=enabled

From 85714c1ff146f761376129a82bbee0570509bc93 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 076/115] xpra: revbump for ffmpeg-6.0

---
 srcpkgs/xpra/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xpra/template b/srcpkgs/xpra/template
index 394718b56f686..34fbff9b2f1ae 100644
--- a/srcpkgs/xpra/template
+++ b/srcpkgs/xpra/template
@@ -1,7 +1,7 @@
 # Template file for 'xpra'
 pkgname=xpra
 version=5.0.3
-revision=1
+revision=2
 build_style=python3-module
 make_build_args="--without-cuda_kernels --without-cuda_rebuild"
 make_install_args="$(vopt_with docs) ${make_build_args}"

From cc62e478610b2bf688f0f30f77f57f888338354d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:07:40 -0400
Subject: [PATCH 077/115] nv-codec-headers: update to 12.0.16.0

---
 srcpkgs/nv-codec-headers/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/nv-codec-headers/template b/srcpkgs/nv-codec-headers/template
index 3d422a61e4891..251e057f826fb 100644
--- a/srcpkgs/nv-codec-headers/template
+++ b/srcpkgs/nv-codec-headers/template
@@ -1,6 +1,6 @@
 # Template file for 'nv-codec-headers'
 pkgname=nv-codec-headers
-version=11.1.5.1
+version=12.0.16.0
 revision=1
 build_style=gnu-makefile
 short_desc="FFmpeg version of headers required to interface with Nvidias codec APIs"
@@ -8,7 +8,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="MIT"
 homepage="http://git.videolan.org/?p=ffmpeg/nv-codec-headers.git"
 distfiles="https://github.com/FFmpeg/nv-codec-headers/archive/n${version}.tar.gz"
-checksum=d095fbd56aa93772471a323be0ebe65504a0f43f06c76a30b6d25da77b06ae9c
+checksum=2a1533b65f55f9da52956faf0627ed3b74868ac0c7f269990edd21369113b48f
 
 post_install() {
 	sed -n '4,25p' include/ffnvcodec/nvEncodeAPI.h > LICENSE

From b4f5f77fcb4bdc4784c703aaeba47ed1bc0fd20d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:08:40 -0400
Subject: [PATCH 078/115] openimagedenoise: revbump for ffmpeg-6.0

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index b792813dba7c2..109deb171c3f7 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,7 +1,7 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
 version=1.4.3
-revision=1
+revision=2
 archs="x86_64*"
 build_style=cmake
 hostmakedepends="ispc python3"

From 857235c38194207e25da3370364e83a1623ddd96 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:31:45 -0400
Subject: [PATCH 079/115] shotcut: revbump for ffmpeg-6.0

---
 srcpkgs/shotcut/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/shotcut/template b/srcpkgs/shotcut/template
index 33141fbd862d7..f46cb53b6bfb9 100644
--- a/srcpkgs/shotcut/template
+++ b/srcpkgs/shotcut/template
@@ -1,7 +1,7 @@
 # Template file for 'shotcut'
 pkgname=shotcut
 version=23.09.29
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSHOTCUT_VERSION=${version}"
 hostmakedepends="pkg-config qt6-tools-devel"

From 8ecd820d082f30c5e09b86390f1006cd1ca0fabc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:30 -0400
Subject: [PATCH 080/115] shiboken2: revbump for qt5-5.15.8

---
 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch | 1 +
 srcpkgs/shiboken2/template                                 | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
 create mode 120000 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
new file mode 120000
index 0000000000000..efcf3249bd885
--- /dev/null
+++ b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1 @@
+../../python3-pyside2/patches/importlib-machinery-bypass.patch
\ No newline at end of file
diff --git a/srcpkgs/shiboken2/template b/srcpkgs/shiboken2/template
index 883d6a084d868..f3c06ec245a1f 100644
--- a/srcpkgs/shiboken2/template
+++ b/srcpkgs/shiboken2/template
@@ -1,7 +1,7 @@
 # Template file for 'shiboken2'
 pkgname=shiboken2
 version=5.15.10
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/shiboken2"
 build_style=cmake

From ba4480bddf67eacaff8945c386bab2fd53a906b0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:53 -0400
Subject: [PATCH 081/115] python3-pyside2: revbump for qt5-5.15.8

---
 .../patches/importlib-machinery-bypass.patch      | 15 +++++++++++++++
 srcpkgs/python3-pyside2/template                  |  2 +-
 2 files changed, 16 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
new file mode 100644
index 0000000000000..64c429584776b
--- /dev/null
+++ b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1,15 @@
+Using this prevents an error around line 220 below it.
+"AttributeError: module 'importlib' has no attribute 'machinery'"
+The old backup logic is in place and compiles without issues.
+--- a/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:09:34.688912402 -0400
++++ b/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:10:03.395529582 -0400
+@@ -170,9 +170,6 @@
+
+     # 'zipstring_sequence' comes from signature.cpp
+     zipbytes = base64.b64decode(''.join(zipstring_sequence))
+-    if sys.version_info[0] >= 3:
+-        vzip = zipfile.ZipFile(io.BytesIO(zipbytes))
+-        return sys.meta_path, EmbeddableZipImporter(vzip)
+
+     # Old version for Python 2.7, only.
+     import os
diff --git a/srcpkgs/python3-pyside2/template b/srcpkgs/python3-pyside2/template
index 249efa9098842..52626436ce75f 100644
--- a/srcpkgs/python3-pyside2/template
+++ b/srcpkgs/python3-pyside2/template
@@ -1,7 +1,7 @@
 # Template file for 'python3-pyside2'
 pkgname=python3-pyside2
 version=5.15.10
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/pyside2"
 build_style=cmake

From 53323b2f0481cb8623b7e9b43fdca97fafcc91e3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:35 -0400
Subject: [PATCH 082/115] konqueror: revbump for ffmpeg-6.0

---
 srcpkgs/konqueror/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/konqueror/template b/srcpkgs/konqueror/template
index abfa59e6b7ded..3cc29c12dc1db 100644
--- a/srcpkgs/konqueror/template
+++ b/srcpkgs/konqueror/template
@@ -1,11 +1,11 @@
 # Template file for 'konqueror'
 pkgname=konqueror
 version=23.08.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DDESKTOPTOJSON_EXECUTABLE=/usr/bin/desktoptojson"
 hostmakedepends="extra-cmake-modules python3 qt5-host-tools qt5-qmake kdoctools
-kcoreaddons kconfig gettext"
+ kcoreaddons kconfig gettext"
 makedepends="qt5-devel qt5-webengine-devel qt5-declarative-devel
  qt5-webchannel-devel qt5-location-devel kcmutils-devel kdelibs4support-devel
  karchive-devel khtml-devel kdesu-devel kactivities5-devel"

From 590d468ce64e7e2e9d76350ff9dba57483baf740 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:58 -0400
Subject: [PATCH 083/115] qt5-speech: revbump for qt5-5.15.8

---
 srcpkgs/qt5-speech/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-speech/template b/srcpkgs/qt5-speech/template
index 3ecd10d50650c..2d7d4d4d24535 100644
--- a/srcpkgs/qt5-speech/template
+++ b/srcpkgs/qt5-speech/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-speech'
 pkgname=qt5-speech
 version=5.15.7
-revision=2
+revision=3
 _commit=d32f4a479d38a11f547598004b975f4356424a16
 build_style=qmake
 configure_args="-- -flite -flite-alsa -speechd"

From bd4265a00c30d88dfd4c60ae099064752568047a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 18:38:50 -0400
Subject: [PATCH 084/115] qt5-styleplugins: revbump for qt5-5.15.8

---
 srcpkgs/qt5-styleplugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-styleplugins/template b/srcpkgs/qt5-styleplugins/template
index 96ed97d12cd24..30d93660a2a4e 100644
--- a/srcpkgs/qt5-styleplugins/template
+++ b/srcpkgs/qt5-styleplugins/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-styleplugins'
 pkgname=qt5-styleplugins
 version=5.0.0
-revision=20
+revision=21
 _gitrev=335dbece103e2cbf6c7cf819ab6672c2956b17b3
 build_style=qmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From c0b675dc17fab0f487976bcde7d5d728ac7476ae Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 7 May 2023 20:15:03 -0400
Subject: [PATCH 085/115] qt6-webengine: revbump for ffmpeg-6.0

---
 srcpkgs/qt6-webengine/template | 1 +
 1 file changed, 1 insertion(+)

diff --git a/srcpkgs/qt6-webengine/template b/srcpkgs/qt6-webengine/template
index 98cdc680481b3..f33a71bd2a0dc 100644
--- a/srcpkgs/qt6-webengine/template
+++ b/srcpkgs/qt6-webengine/template
@@ -158,6 +158,7 @@ pre_install() {
 }
 
 post_install() {
+	vlicense LICENSES/BSD-3-Clause.txt
 	local _file
 	find "${DESTDIR}"/usr/lib/qt6/examples \
 		-path '*/lib/qt6/**/lib/qt6/*' -type f |

From af73f659ce09962fcd2bbf27efb31c4c5324bbbf Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Jun 2023 08:20:22 -0400
Subject: [PATCH 086/115] gtk4: revbump for ffmpeg-6.0

---
 srcpkgs/gtk4/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gtk4/template b/srcpkgs/gtk4/template
index 6a4e20357a86f..ec0c13d2cc5b0 100644
--- a/srcpkgs/gtk4/template
+++ b/srcpkgs/gtk4/template
@@ -1,7 +1,7 @@
 # Template file for 'gtk4'
 pkgname=gtk4
 version=4.12.3
-revision=1
+revision=2
 build_style=meson
 build_helper="gir"
 configure_args="-Dman-pages=true -Ddocumentation=true -Dbuild-tests=false

From d9e54f32fe224e98fc61f6d013809910be81c2b4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:28:26 -0400
Subject: [PATCH 087/115] siril: revbump for ffmpeg-6.0

---
 srcpkgs/siril/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/siril/template b/srcpkgs/siril/template
index 84332f79d060d..62750dd247548 100644
--- a/srcpkgs/siril/template
+++ b/srcpkgs/siril/template
@@ -1,7 +1,7 @@
 # Template file for 'siril'
 pkgname=siril
 version=0.9.12
-revision=10
+revision=11
 build_style=gnu-configure
 hostmakedepends="pkg-config intltool autoconf automake gettext-devel"
 makedepends="fftw-devel libconfig-devel libopencv-devel libffms2-devel

From cf1de2a336b3773285b9ca435ae05d65585a6f3f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 22 Jun 2023 10:25:02 -0400
Subject: [PATCH 088/115] kdenlive: revbump for ffmpeg-6.0

---
 srcpkgs/kdenlive/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kdenlive/template b/srcpkgs/kdenlive/template
index ec5fe75860948..e69ecff31f272 100644
--- a/srcpkgs/kdenlive/template
+++ b/srcpkgs/kdenlive/template
@@ -1,7 +1,7 @@
 # Template file for 'kdenlive'
 pkgname=kdenlive
 version=23.08.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="
  extra-cmake-modules kconfig kcoreaddons kdoctools pkg-config python3

From c61830cfabc6d54c8748a1d956397a9e627d84f5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Jul 2023 11:17:37 -0400
Subject: [PATCH 089/115] DELETE: intel_packages

---
 common/shlibs                                 |   2 +
 srcpkgs/intel-gmmlib/template                 |   2 +-
 ...mmon-Enable-MMC-in-free-kernel-build.patch | 125 ++++++++++++++++++
 srcpkgs/intel-media-driver/template           |   6 +-
 srcpkgs/intel-media-sdk/patches/musl.patch    |  14 ++
 srcpkgs/intel-media-sdk/template              |  37 ++++++
 srcpkgs/intel-media-sdk/update                |   1 +
 srcpkgs/libmfx                                |   1 +
 srcpkgs/libmfx-devel                          |   1 +
 srcpkgs/onevpl-devel                          |   1 +
 srcpkgs/onevpl-intel-gpu-devel                |   1 +
 srcpkgs/onevpl-intel-gpu/template             |  27 ++++
 srcpkgs/onevpl/template                       |  34 +++++
 13 files changed, 248 insertions(+), 4 deletions(-)
 create mode 100644 srcpkgs/intel-media-driver/patches/0001-Media-Common-Enable-MMC-in-free-kernel-build.patch
 create mode 100644 srcpkgs/intel-media-sdk/patches/musl.patch
 create mode 100644 srcpkgs/intel-media-sdk/template
 create mode 100644 srcpkgs/intel-media-sdk/update
 create mode 120000 srcpkgs/libmfx
 create mode 120000 srcpkgs/libmfx-devel
 create mode 120000 srcpkgs/onevpl-devel
 create mode 120000 srcpkgs/onevpl-intel-gpu-devel
 create mode 100644 srcpkgs/onevpl-intel-gpu/template
 create mode 100644 srcpkgs/onevpl/template

diff --git a/common/shlibs b/common/shlibs
index 5745ff0ca7b84..ff183faba55aa 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4253,6 +4253,8 @@ libgsoapssl++-2.8.124.so gsoap-2.8.124_1
 libjxl.so.0.8 libjxl-0.8.2_1
 libjxl_dec.so.0.8 libjxl-0.8.2_1
 libjxl_threads.so.0.8 libjxl-0.8.2_1
+libmfx.so.1 libmfx-22.6.4_1
+libvpl.so.2 onevpl-2023.1.2_1
 libtext-engine-0.1.so.0 text-engine-0.1.1_1
 libvmaf.so.1 vmaf-2.3.1_1
 liblc3.so.1 liblc3-1.0.3_1
diff --git a/srcpkgs/intel-gmmlib/template b/srcpkgs/intel-gmmlib/template
index b9df642f6320f..3d64be7415298 100644
--- a/srcpkgs/intel-gmmlib/template
+++ b/srcpkgs/intel-gmmlib/template
@@ -14,7 +14,7 @@ build_style=cmake
 # compilers flag in use.
 configure_args="-Wno-dev"
 short_desc="Intel Graphics Memory Management Library"
-maintainer="Orphaned <orphan@voidlinux.org>"
+maintainer="Stefano Ragni <st3r4g@protonmail.com>"
 license="MIT"
 homepage="https://github.com/intel/gmmlib"
 distfiles="https://github.com/intel/gmmlib/archive/intel-gmmlib-${version}.tar.gz"
diff --git a/srcpkgs/intel-media-driver/patches/0001-Media-Common-Enable-MMC-in-free-kernel-build.patch b/srcpkgs/intel-media-driver/patches/0001-Media-Common-Enable-MMC-in-free-kernel-build.patch
new file mode 100644
index 0000000000000..525fb688722c8
--- /dev/null
+++ b/srcpkgs/intel-media-driver/patches/0001-Media-Common-Enable-MMC-in-free-kernel-build.patch
@@ -0,0 +1,125 @@
+From e68feab7db036838d9521ba3b9f00717c37c024c Mon Sep 17 00:00:00 2001
+From: JayYang <jay.yang@intel.com>
+Date: Tue, 21 Mar 2023 17:17:55 +0800
+Subject: [PATCH] [Media Common] Enable MMC in free kernel build
+
+Add mmc build definition in free kernel build
+---
+ media_driver/agnostic/gen9/codec/hal/media_srcs.cmake          | 2 +-
+ media_driver/cmake/linux/media_feature_flags_linux.cmake       | 3 +--
+ .../media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp        | 2 +-
+ .../media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp        | 2 +-
+ .../media_interfaces_m9_glk/media_interfaces_g9_glk.cpp        | 2 +-
+ .../media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp        | 2 +-
+ .../media_interfaces_m9_skl/media_interfaces_g9_skl.cpp        | 2 +-
+ 7 files changed, 7 insertions(+), 8 deletions(-)
+
+diff --git a/media_driver/agnostic/gen9/codec/hal/media_srcs.cmake b/media_driver/agnostic/gen9/codec/hal/media_srcs.cmake
+index 8bb36bafe..78902a22d 100644
+--- a/media_driver/agnostic/gen9/codec/hal/media_srcs.cmake
++++ b/media_driver/agnostic/gen9/codec/hal/media_srcs.cmake
+@@ -27,7 +27,7 @@ set(TMP_1_HEADERS_
+     ${CMAKE_CURRENT_LIST_DIR}/codechal_hw_g9_X.h
+ )
+ 
+-if(${MMC_Supported} STREQUAL "yes")
++if(${MMC_Supported} STREQUAL "yes" AND ENABLE_NONFREE_KERNELS AND ENABLE_KERNELS)
+     set(TMP_1_SOURCES_
+         ${TMP_1_SOURCES_}
+         ${CMAKE_CURRENT_LIST_DIR}/codechal_memdecomp_g9.cpp
+diff --git a/media_driver/cmake/linux/media_feature_flags_linux.cmake b/media_driver/cmake/linux/media_feature_flags_linux.cmake
+index de0ca853f..8121ea60c 100644
+--- a/media_driver/cmake/linux/media_feature_flags_linux.cmake
++++ b/media_driver/cmake/linux/media_feature_flags_linux.cmake
+@@ -35,7 +35,6 @@ if(NOT ENABLE_KERNELS OR NOT ENABLE_NONFREE_KERNELS)
+     bs_set_if_undefined(HEVC_Encode_VME_Supported "no")
+     bs_set_if_undefined(MPEG2_Encode_VME_Supported "no")
+     bs_set_if_undefined(CMRT_HEVC_ENC_FEI_Supported "no")
+-    bs_set_if_undefined(MMC_Supported "no")
+     bs_set_if_undefined(VC1_Decode_Supported "no")
+     bs_set_if_undefined(Decode_Processing_Supported "no")
+     bs_set_if_undefined(Kernel_Auto_Denoise_Supported "no")
+@@ -46,7 +45,6 @@ else()
+     bs_set_if_undefined(HEVC_Encode_VME_Supported "${Encode_VME_Supported}")
+     bs_set_if_undefined(MPEG2_Encode_VME_Supported "${Encode_VME_Supported}")
+     bs_set_if_undefined(CMRT_HEVC_ENC_FEI_Supported "yes")
+-    bs_set_if_undefined(MMC_Supported "yes")
+     bs_set_if_undefined(VC1_Decode_Supported "yes")
+     bs_set_if_undefined(Decode_Processing_Supported "yes")
+     bs_set_if_undefined(Kernel_Auto_Denoise_Supported "yes")
+@@ -64,6 +62,7 @@ bs_set_if_undefined(VP9_Decode_Supported "yes")
+ bs_set_if_undefined(VP_SFC_Supported "yes")
+ bs_set_if_undefined(Common_Encode_Supported "yes")
+ bs_set_if_undefined(Media_Scalability_Supported "yes")
++bs_set_if_undefined(MMC_Supported "yes")
+ 
+ # features controlled by global flag Encode_VDEnc_Supported
+ bs_set_if_undefined(AVC_Encode_VDEnc_Supported "${Encode_VDEnc_Supported}")
+diff --git a/media_driver/media_interface/media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp b/media_driver/media_interface/media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp
+index 3f306ee2a..8e4c0f532 100644
+--- a/media_driver/media_interface/media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp
+@@ -135,7 +135,7 @@ MOS_STATUS MhwInterfacesG9Bxt::Initialize(
+ 
+     return MOS_STATUS_SUCCESS;
+ }
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool bxtRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Bxt>((uint32_t)IGFX_BROXTON);
+diff --git a/media_driver/media_interface/media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp b/media_driver/media_interface/media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp
+index b8fa1eec0..84e0fad1d 100644
+--- a/media_driver/media_interface/media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp
+@@ -44,7 +44,7 @@ static bool cflRegisteredMhw =
+     MediaFactory<uint32_t, MhwInterfaces>::
+     Register<MhwInterfacesG9Kbl>((uint32_t)IGFX_COFFEELAKE);
+ 
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool cflRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Kbl>((uint32_t)IGFX_COFFEELAKE);
+diff --git a/media_driver/media_interface/media_interfaces_m9_glk/media_interfaces_g9_glk.cpp b/media_driver/media_interface/media_interfaces_m9_glk/media_interfaces_g9_glk.cpp
+index de81e6091..2638cb3a6 100644
+--- a/media_driver/media_interface/media_interfaces_m9_glk/media_interfaces_g9_glk.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_glk/media_interfaces_g9_glk.cpp
+@@ -65,7 +65,7 @@ static bool glkRegisteredMhw =
+     MediaFactory<uint32_t, MhwInterfaces>::
+     Register<MhwInterfacesG9Kbl>((uint32_t)IGFX_GEMINILAKE);
+ 
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool glkRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Kbl>((uint32_t)IGFX_GEMINILAKE);
+diff --git a/media_driver/media_interface/media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp b/media_driver/media_interface/media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp
+index 99d786185..4e9c6e7f1 100644
+--- a/media_driver/media_interface/media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp
+@@ -131,7 +131,7 @@ MOS_STATUS MhwInterfacesG9Kbl::Initialize(
+ 
+     return MOS_STATUS_SUCCESS;
+ }
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool kblRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Kbl>((uint32_t)IGFX_KABYLAKE);
+diff --git a/media_driver/media_interface/media_interfaces_m9_skl/media_interfaces_g9_skl.cpp b/media_driver/media_interface/media_interfaces_m9_skl/media_interfaces_g9_skl.cpp
+index e2520edf7..4b0012c64 100644
+--- a/media_driver/media_interface/media_interfaces_m9_skl/media_interfaces_g9_skl.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_skl/media_interfaces_g9_skl.cpp
+@@ -139,7 +139,7 @@ MOS_STATUS MhwInterfacesG9Skl::Initialize(
+ 
+     return MOS_STATUS_SUCCESS;
+ }
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool sklRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Skl>((uint32_t)IGFX_SKYLAKE);
+-- 
+2.40.0
+
diff --git a/srcpkgs/intel-media-driver/template b/srcpkgs/intel-media-driver/template
index 06b7c19a0ba07..1735b90c65ce5 100644
--- a/srcpkgs/intel-media-driver/template
+++ b/srcpkgs/intel-media-driver/template
@@ -1,6 +1,6 @@
 # Template file for 'intel-media-driver'
 pkgname=intel-media-driver
-version=23.3.5
+version=22.6.4
 revision=1
 archs="x86_64*"
 build_style=cmake
@@ -8,11 +8,11 @@ configure_args="-Wno-dev -DENABLE_NONFREE_KERNELS=$(vopt_if nonfree ON OFF)"
 hostmakedepends="pkg-config"
 makedepends="libva-devel libX11-devel intel-gmmlib-devel libpciaccess-devel"
 short_desc="Intel Media Driver for VAAPI (Broadwell+)"
-maintainer="Orphaned <orphan@voidlinux.org>"
+maintainer="Stefano Ragni <st3r4g@protonmail.com>"
 license="MIT, BSD-3-Clause"
 homepage="https://github.com/intel/media-driver"
 distfiles="https://github.com/intel/media-driver/archive/intel-media-${version}.tar.gz"
-checksum=67fd15654bb3c596feb8c85e81221de5632e11f598421c35adc4453d727f0130
+checksum=0c04b9d74b92de41fd409b62913ce4afd799236c0b6bc1983a496990764e5d90
 
 build_options="nonfree"
 desc_option_nonfree="Enable nonfree kernels"
diff --git a/srcpkgs/intel-media-sdk/patches/musl.patch b/srcpkgs/intel-media-sdk/patches/musl.patch
new file mode 100644
index 0000000000000..4ae70924b744f
--- /dev/null
+++ b/srcpkgs/intel-media-sdk/patches/musl.patch
@@ -0,0 +1,14 @@
+--- a/tools/tracer/tracer/tracer_linux.cpp	2022-11-18 03:02:59.000000000 -0500
++++ b/tools/tracer/tracer/tracer_linux.cpp	2022-12-18 01:44:51.341542572 -0500
+@@ -32,6 +32,11 @@
+ #include <dlfcn.h>
+ #include "tracer.h"
+
++#ifndef RTLD_DEEPBIND
++// musl neither defines nor can use RTLD_DEEPBIND
++#define RTLD_DEEPBIND 0
++#endif
++
+ #if defined(__i386__)
+     #define LIBMFXHW "libmfxhw32.so.1"
+ #elif defined(__x86_64__)
diff --git a/srcpkgs/intel-media-sdk/template b/srcpkgs/intel-media-sdk/template
new file mode 100644
index 0000000000000..7aeab51802f8e
--- /dev/null
+++ b/srcpkgs/intel-media-sdk/template
@@ -0,0 +1,37 @@
+# Template file for 'intel-media-sdk'
+pkgname=intel-media-sdk
+version=22.6.4
+revision=1
+archs="x86_64*"
+build_style=cmake
+configure_args="-Wno-dev -DBUILD_SAMPLES=OFF -DBUILD_TESTS=ON"
+hostmakedepends="pkg-config"
+makedepends="libva-devel libdrm-devel intel-gmmlib-devel"
+short_desc="Intel Media SDK"
+maintainer="Stefano Ragni <st3r4g@protonmail.com>"
+license="MIT, BSD-3-Clause"
+homepage="https://github.com/Intel-Media-SDK/MediaSDK"
+distfiles="https://github.com/Intel-Media-SDK/MediaSDK/archive/refs/tags/intel-mediasdk-${version}.tar.gz"
+checksum=197acd056f81e9ff1c27068d50e8c84c2014d94c7ac17cad69d5c2d61e445fd3
+
+post_install() {
+	vlicense LICENSE
+}
+
+libmfx_package() {
+	depends="${makedepends} ${sourcepkg}-${version}_${revision}"
+	short_desc="Intel MediaSDK mfx lib"
+	pkg_install() {
+		vmove usr/lib/mfx
+		vmove "usr/lib/libmfx*.so*"
+	}
+}
+
+libmfx-devel_package() {
+	depends="${makedepends} ${sourcepkg}-${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+	}
+}
diff --git a/srcpkgs/intel-media-sdk/update b/srcpkgs/intel-media-sdk/update
new file mode 100644
index 0000000000000..434a2bc67f7a1
--- /dev/null
+++ b/srcpkgs/intel-media-sdk/update
@@ -0,0 +1 @@
+pkgname=intel-media
diff --git a/srcpkgs/libmfx b/srcpkgs/libmfx
new file mode 120000
index 0000000000000..8ffc7099c2272
--- /dev/null
+++ b/srcpkgs/libmfx
@@ -0,0 +1 @@
+intel-media-sdk
\ No newline at end of file
diff --git a/srcpkgs/libmfx-devel b/srcpkgs/libmfx-devel
new file mode 120000
index 0000000000000..8ffc7099c2272
--- /dev/null
+++ b/srcpkgs/libmfx-devel
@@ -0,0 +1 @@
+intel-media-sdk
\ No newline at end of file
diff --git a/srcpkgs/onevpl-devel b/srcpkgs/onevpl-devel
new file mode 120000
index 0000000000000..e2306500b4871
--- /dev/null
+++ b/srcpkgs/onevpl-devel
@@ -0,0 +1 @@
+onevpl
\ No newline at end of file
diff --git a/srcpkgs/onevpl-intel-gpu-devel b/srcpkgs/onevpl-intel-gpu-devel
new file mode 120000
index 0000000000000..47920ceecf919
--- /dev/null
+++ b/srcpkgs/onevpl-intel-gpu-devel
@@ -0,0 +1 @@
+onevpl-intel-gpu
\ No newline at end of file
diff --git a/srcpkgs/onevpl-intel-gpu/template b/srcpkgs/onevpl-intel-gpu/template
new file mode 100644
index 0000000000000..f14acb728a54d
--- /dev/null
+++ b/srcpkgs/onevpl-intel-gpu/template
@@ -0,0 +1,27 @@
+# Template file for 'onevpl-intel-gpu'
+pkgname=onevpl-intel-gpu
+version=22.6.4
+revision=1
+archs="x86_64*"
+build_style=cmake
+configure_args="-Wno-dev -DCMAKE_BUILD_TYPE=Release"
+hostmakedepends="cmake pkg-config"
+makedepends="libdrm-devel libva-devel onevpl-devel"
+short_desc="Runtime implementation of oneVPL API for Intel Gen GPUs"
+maintainer="zlice <zlice555@gmail.com>"
+license="MIT"
+homepage="https://github.com/oneapi-src/oneVPL-intel-gpu"
+changelog="https://github.com/oneapi-src/oneVPL-intel-gpu/blob/main/CHANGELOG.md"
+distfiles="https://github.com/oneapi-src/oneVPL-intel-gpu/archive/refs/tags/intel-onevpl-${version}.tar.gz"
+checksum=74b0979dcb2af1b7c68edb8cbcb02d539de511090b12fac50652cbacd707c4e6
+
+post_install() {
+	vlicense LICENSE
+}
+
+onevpl-intel-gpu-devel_package() {
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/lib/pkgconfig
+	}
+}
diff --git a/srcpkgs/onevpl/template b/srcpkgs/onevpl/template
new file mode 100644
index 0000000000000..85c7c2da85ce9
--- /dev/null
+++ b/srcpkgs/onevpl/template
@@ -0,0 +1,34 @@
+# Template file for 'onevpl'
+pkgname=onevpl
+version=2023.1.2
+revision=1
+archs="x86_64*"
+build_style=cmake
+configure_args="
+	-DCMAKE_BUILD_TYPE=Release -Wno-dev
+	-DBUILD_PYTHON_BINDING:BOOL='OFF'
+	-DBUILD_EXAMPLES:BOOL='OFF'
+	-DBUILD_TESTS:BOOL='ON'
+	-DINSTALL_EXAMPLE_CODE:BOOL='OFF'"
+hostmakedepends="cmake libX11 python wayland-protocols pkg-config"
+makedepends="libva-devel libX11-devel wayland-devel"
+short_desc="Intel oneAPI Video Processing library"
+maintainer="zlice <zlice555@gmail.com>"
+license="MIT"
+homepage="https://www.intel.com/content/www/us/en/developer/tools/oneapi/onevpl.html"
+distfiles="https://github.com/oneapi-src/oneVPL/archive/v${version}/${pkgname}-${version}.tar.gz"
+checksum=b2261cca174ce1815f3d47c647921ab17f68267c69c1e2444ff27aab7d199cbb
+
+post_install() {
+	vlicense LICENSE
+}
+
+onevpl-devel_package() {
+	depends="${makedepends} ${sourcepkg}-${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.so"
+	}
+}

From 9ff6d82b872d245f08a108e2100518ef1e9e58d0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:20:59 -0400
Subject: [PATCH 090/115] tracker-miners: revbump for ffmpeg-6.0

---
 srcpkgs/tracker-miners/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tracker-miners/template b/srcpkgs/tracker-miners/template
index 0b97f47489f81..f196d2bf9e4a4 100644
--- a/srcpkgs/tracker-miners/template
+++ b/srcpkgs/tracker-miners/template
@@ -1,7 +1,7 @@
 # Template file for 'tracker-miners'
 pkgname=tracker-miners
 version=3.6.1
-revision=1
+revision=2
 build_style=meson
 build_helper=qemu
 # missing libgrss for miner_rss

From 232c6fcc544bc3ff97bc14eafa7d7198a3c08757 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:21:21 -0400
Subject: [PATCH 091/115] mpd: revbump for ffmpeg-6.0

---
 srcpkgs/mpd/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpd/template b/srcpkgs/mpd/template
index 645c1b778e407..60287cc9f6e3c 100644
--- a/srcpkgs/mpd/template
+++ b/srcpkgs/mpd/template
@@ -1,7 +1,7 @@
 # Template file for 'mpd'
 pkgname=mpd
 version=0.23.14
-revision=3
+revision=4
 build_style=meson
 configure_args="-Dopus=enabled -Dmikmod=enabled -Dneighbor=true
  -Dsoundcloud=enabled -Dpipe=true -Dtwolame=enabled -Dbzip2=enabled

From 54af3c2af57fe5164ba71d6b313ae56dfb34d906 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:02 -0400
Subject: [PATCH 092/115] tg_owt: revbump for ffmpeg-6.0

---
 srcpkgs/tg_owt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tg_owt/template b/srcpkgs/tg_owt/template
index 50bc8310b8859..c93262d5c5de6 100644
--- a/srcpkgs/tg_owt/template
+++ b/srcpkgs/tg_owt/template
@@ -1,7 +1,7 @@
 # Template file for 'tg_owt'
 pkgname=tg_owt
 version=0.0.0.20230921
-revision=1
+revision=2
 _commit=3bb3d757681e6cc5135aec6529a753dc3dcdcfb9
 _libyuv_commit=04821d1e7d60845525e8db55c7bcd41ef5be9406
 _abseil_commit=8c0b94e793a66495e0b1f34a5eb26bd7dc672db0

From 969f1448d4a387bf1576ca55ef80d144cc64b8c4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:44 -0400
Subject: [PATCH 093/115] telegram-desktop: revbump for ffmpeg-6.0

---
 srcpkgs/telegram-desktop/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/telegram-desktop/template b/srcpkgs/telegram-desktop/template
index 9bd94ce3781ff..d33fc62b10e38 100644
--- a/srcpkgs/telegram-desktop/template
+++ b/srcpkgs/telegram-desktop/template
@@ -1,7 +1,7 @@
 # Template file for 'telegram-desktop'
 pkgname=telegram-desktop
 version=4.11.2
-revision=1
+revision=2
 build_style=cmake
 build_helper="qemu gir"
 configure_args="-DTDESKTOP_API_ID=209235

From f4c018a849b80c7be440c3659913a6282647efa6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:11:45 -0400
Subject: [PATCH 094/115] gst-plugins-bad1: revbump for ffmpeg-6.0

---
 srcpkgs/gst-plugins-bad1/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index 2bf2f4b0642fe..0fafcb6555395 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-plugins-bad1'
 pkgname=gst-plugins-bad1
 version=1.22.5
-revision=1
+revision=2
 build_helper="gir"
 build_style=meson
 configure_args="-Dpackage-origin=https://voidlinux.org -Ddoc=disabled

From d0d33b1bcfcce6da71de384b8fb25469442b9d73 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:12:09 -0400
Subject: [PATCH 095/115] openmw: revbump for ffmpeg-6.0

---
 srcpkgs/openmw/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openmw/template b/srcpkgs/openmw/template
index 0abf5ff7cdbec..b57180f1a4446 100644
--- a/srcpkgs/openmw/template
+++ b/srcpkgs/openmw/template
@@ -1,7 +1,7 @@
 # Template file for 'openmw'
 pkgname=openmw
 version=0.48.0
-revision=2
+revision=3
 build_style=cmake
 _recast_commit=e75adf86f91eb3082220085e42dda62679f9a3ea
 _bullet_tag=3.17

From 5372d635bdd3152a932542920b3338ea0d705eec Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:14:53 -0400
Subject: [PATCH 096/115] lms: revbump for ffmpeg-6.0

---
 srcpkgs/lms/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/lms/template b/srcpkgs/lms/template
index e358f75902a98..3b21c458de519 100644
--- a/srcpkgs/lms/template
+++ b/srcpkgs/lms/template
@@ -1,7 +1,7 @@
 # Template file for 'lms'
 pkgname=lms
 version=3.42.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="wt-devel ffmpeg-devel boost-devel libconfig++-devel taglib-devel pam-devel libgraphicsmagick-devel gtest-devel libarchive-devel"

From 12da408b7dff1e27f726a5ea032fed6e505477f3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:18:18 -0400
Subject: [PATCH 097/115] freecad: revbump for ffmpeg-6.0

---
 srcpkgs/freecad/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/freecad/template b/srcpkgs/freecad/template
index c135701e38b9a..705499e9972a6 100644
--- a/srcpkgs/freecad/template
+++ b/srcpkgs/freecad/template
@@ -1,7 +1,7 @@
 # Template file for 'freecad'
 pkgname=freecad
 version=0.20.2
-revision=7
+revision=8
 build_wrksrc="FreeCAD-${version}"
 build_style=cmake
 pycompile_dirs="usr/lib/${pkgname}/Mod"

From 9cef68c8b74d2b40d5ab41b9fa174144c4549e31 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:47:18 -0400
Subject: [PATCH 098/115] libopenshot: revbump for ffmpeg-6.0

---
 srcpkgs/libopenshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenshot/template b/srcpkgs/libopenshot/template
index 8e57c5f592169..7a8f4520e7892 100644
--- a/srcpkgs/libopenshot/template
+++ b/srcpkgs/libopenshot/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenshot'
 pkgname=libopenshot
 version=0.3.0
-revision=3
+revision=4
 build_style=cmake
 # Builds fail with Ruby-2.4.1
 configure_args="-DENABLE_RUBY=OFF -DUSE_SYSTEM_JSONCPP=ON"

From 5976bfbdfcafd64c915b053e9bd315636ae36d0b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:10:30 -0500
Subject: [PATCH 099/115] openimageio: revbump for ffmpeg-6.0

---
 srcpkgs/openimageio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimageio/template b/srcpkgs/openimageio/template
index 3ce3f9e49d350..27d2131bc0a61 100644
--- a/srcpkgs/openimageio/template
+++ b/srcpkgs/openimageio/template
@@ -1,7 +1,7 @@
 # Template file for 'openimageio'
 pkgname=openimageio
 version=2.4.9.0
-revision=7
+revision=8
 build_style=cmake
 build_helper=qemu
 configure_args="-DUSE_QT=0 -DUSE_PYTHON=0 -DOIIO_BUILD_TESTS=0

From 3da8f6724f8fb593ad010b34ca55b069bfeb393b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:11:57 -0500
Subject: [PATCH 100/115] synfigstudio: revbump for ffmpeg-6.0

---
 srcpkgs/synfigstudio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/synfigstudio/template b/srcpkgs/synfigstudio/template
index 09e442da9a680..2bc017cedca6b 100644
--- a/srcpkgs/synfigstudio/template
+++ b/srcpkgs/synfigstudio/template
@@ -2,7 +2,7 @@
 # Should be kept in sync with 'synfig' and 'ETL'
 pkgname=synfigstudio
 version=1.4.4
-revision=4
+revision=5
 build_style=gnu-configure
 configure_args="--disable-update-mimedb"
 hostmakedepends="pkg-config intltool gettext synfig"

From 4a25a614808bd66c2e56002ea2c14bc0328f99c8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:12:32 -0500
Subject: [PATCH 101/115] gmic: revbump for ffmpeg-6.0

---
 srcpkgs/gmic/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gmic/template b/srcpkgs/gmic/template
index 808953e9b543c..d854808f86aa4 100644
--- a/srcpkgs/gmic/template
+++ b/srcpkgs/gmic/template
@@ -1,7 +1,7 @@
 # Template file for 'gmic'
 pkgname=gmic
 version=3.1.6
-revision=5
+revision=6
 _zart_hash=34ebf6cce0bafb98abe57cec83c4a02cd1abeca0
 create_wrksrc=yes
 build_wrksrc="src"

From 4ea62a89fd6912c286ccf6c61b0e3c005a39453e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:10 -0500
Subject: [PATCH 102/115] mixxx: revbump for ffmpeg-6.0

---
 srcpkgs/mixxx/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mixxx/template b/srcpkgs/mixxx/template
index 6921996e4e77b..6a79b328c1abf 100644
--- a/srcpkgs/mixxx/template
+++ b/srcpkgs/mixxx/template
@@ -1,7 +1,7 @@
 # Template file for 'mixxx'
 pkgname=mixxx
 version=2.3.3
-revision=6
+revision=7
 build_style=cmake
 configure_args="-DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="extra-cmake-modules pkg-config protobuf qt5-host-tools qt5-qmake"

From 1790ca5578e22fc074a2ba0bef810a56f57c9109 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:28 -0500
Subject: [PATCH 103/115] musikcube: revbump for ffmpeg-6.0

---
 srcpkgs/musikcube/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/musikcube/template b/srcpkgs/musikcube/template
index d9e6186e6697b..637952d50aca3 100644
--- a/srcpkgs/musikcube/template
+++ b/srcpkgs/musikcube/template
@@ -1,7 +1,7 @@
 # Template file for 'musikcube'
 pkgname=musikcube
 version=3.0.0
-revision=3
+revision=4
 build_style=cmake
 make_cmd=make
 configure_args="-DNO_NCURSESW=1"

From 42029d110a22a93d7228aacadc27cf775e645b50 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:45 -0500
Subject: [PATCH 104/115] electron24: revbump for ffmpeg-6.0

---
 srcpkgs/electron24/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron24/template b/srcpkgs/electron24/template
index a9c865c19c989..b8613e4362bc7 100644
--- a/srcpkgs/electron24/template
+++ b/srcpkgs/electron24/template
@@ -1,7 +1,7 @@
 # Template file for 'electron24'
 pkgname=electron24
 version=24.3.0
-revision=2
+revision=3
 _nodever=18.14.0
 _chromiumver=112.0.5615.165
 archs="x86_64* aarch64*"

From bc098747e02b0fe494ed0fec2810c277522dca22 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:00 -0500
Subject: [PATCH 105/115] electron19: revbump for ffmpeg-6.0

---
 srcpkgs/electron19/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron19/template b/srcpkgs/electron19/template
index b18bc792c8221..29fb34e254eea 100644
--- a/srcpkgs/electron19/template
+++ b/srcpkgs/electron19/template
@@ -1,7 +1,7 @@
 # Template file for 'electron19'
 pkgname=electron19
 version=19.0.8
-revision=4
+revision=5
 _nodever=16.14.2
 _chromiumver=102.0.5005.125
 archs="x86_64* aarch64* ppc64le*"

From 3750497c58ec6e1cfa172b0198cd805d39d0246f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:13 -0500
Subject: [PATCH 106/115] wf-recorder: revbump for ffmpeg-6.0

---
 srcpkgs/wf-recorder/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/wf-recorder/template b/srcpkgs/wf-recorder/template
index 08f986b031006..63c45cf4b814d 100644
--- a/srcpkgs/wf-recorder/template
+++ b/srcpkgs/wf-recorder/template
@@ -1,7 +1,7 @@
 # Template file for 'wf-recorder'
 pkgname=wf-recorder
 version=0.4.1
-revision=2
+revision=3
 build_style=meson
 hostmakedepends="pkg-config scdoc wayland-devel"
 makedepends="wayland-protocols wayland-devel ffmpeg-devel libgbm-devel x264-devel

From d858bf2e5f2df5aad533f2836726f81f52b3a0d3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:26 -0500
Subject: [PATCH 107/115] obs: revbump for ffmpeg-6.0

---
 srcpkgs/obs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/obs/template b/srcpkgs/obs/template
index 5d1d5e887409e..3eaaf8d4c8200 100644
--- a/srcpkgs/obs/template
+++ b/srcpkgs/obs/template
@@ -1,7 +1,7 @@
 # Template file for 'obs'
 pkgname=obs
 version=29.1.3
-revision=3
+revision=4
 archs="i686* x86_64* ppc64le* aarch64*"
 build_style=cmake
 configure_args="-DOBS_VERSION_OVERRIDE=${version} -DENABLE_JACK=ON

From 97647221a6a5f712c61f05dce5d0e3edaa2eb0c4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:36 -0500
Subject: [PATCH 108/115] mlt7: revbump for ffmpeg-6.0

---
 srcpkgs/mlt7/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mlt7/template b/srcpkgs/mlt7/template
index 98f302ad3a516..7eb8c00fa1580 100644
--- a/srcpkgs/mlt7/template
+++ b/srcpkgs/mlt7/template
@@ -1,7 +1,7 @@
 # Template file for 'mlt7'
 pkgname=mlt7
 version=7.20.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DSWIG_PYTHON=ON -DMOD_QT6=ON"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which

From f761b73e5e24e5b8be22c75d8189ccf651660b9a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:48 -0500
Subject: [PATCH 109/115] qt6-multimedia: revbump for ffmpeg-6.0

---
 srcpkgs/qt6-multimedia/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-multimedia/template b/srcpkgs/qt6-multimedia/template
index 67a577e1300fe..1da626ecf515a 100644
--- a/srcpkgs/qt6-multimedia/template
+++ b/srcpkgs/qt6-multimedia/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-multimedia'
 pkgname=qt6-multimedia
 version=6.6.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DQT_FEATURE_gstreamer=ON"
 hostmakedepends="perl qt6-declarative-host-tools pkg-config qt6-shadertools"

From 058d5ab5a44693cbcb64ee987c21e31b676bcf6a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:00:15 -0500
Subject: [PATCH 110/115] baresip: revbump for ffmpeg-6.0

---
 srcpkgs/baresip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/baresip/template b/srcpkgs/baresip/template
index 12c8954ef7b9b..b16b67beab8d2 100644
--- a/srcpkgs/baresip/template
+++ b/srcpkgs/baresip/template
@@ -1,7 +1,7 @@
 # Template file for 'baresip'
 pkgname=baresip
 version=3.6.0
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config glib-devel"
 makedepends="libgsm-devel libpng-devel openssl-devel libsndfile-devel

From abf201d09057bac2b39f8bb65e54d6d70c22f582 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:30 -0500
Subject: [PATCH 111/115] QMPlay2: revbump for ffmpeg-6.0

---
 srcpkgs/QMPlay2/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/QMPlay2/template b/srcpkgs/QMPlay2/template
index 46c80f64a1349..942258ce60fb7 100644
--- a/srcpkgs/QMPlay2/template
+++ b/srcpkgs/QMPlay2/template
@@ -1,7 +1,7 @@
 # Template file for 'QMPlay2'
 pkgname=QMPlay2
 version=23.10.22
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools"
 makedepends="alsa-lib-devel ffmpeg-devel libass-devel libcdio-devel libgme-devel

From 880e46ea88de2776f7de87431a335e271b23f57d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:34 -0500
Subject: [PATCH 112/115] alsa-plugins: revbump for ffmpeg-6.0

---
 srcpkgs/alsa-plugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/alsa-plugins/template b/srcpkgs/alsa-plugins/template
index a5708a7d82a8f..7bfdad046c483 100644
--- a/srcpkgs/alsa-plugins/template
+++ b/srcpkgs/alsa-plugins/template
@@ -1,7 +1,7 @@
 # Template file for 'alsa-plugins'
 pkgname=alsa-plugins
 version=1.2.7.1
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--disable-maemo-plugin"
 hostmakedepends="pkg-config"

From 4b72feed04f5fa60e8b930238657add8573a40c4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:39 -0500
Subject: [PATCH 113/115] dolphin-emu: revbump for ffmpeg-6.0

---
 srcpkgs/dolphin-emu/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/dolphin-emu/template b/srcpkgs/dolphin-emu/template
index 070993aac31d2..96edf50d3e4a1 100644
--- a/srcpkgs/dolphin-emu/template
+++ b/srcpkgs/dolphin-emu/template
@@ -1,7 +1,7 @@
 # Template file for 'dolphin-emu'
 pkgname=dolphin-emu
 version=5.0.19368
-revision=2
+revision=3
 _dolphin_commit=dadbeb4bae7e7fa23af2b46e0add4143094dc107
 _mgba_commit=44e074a15e9651481f7f652ac006a7c9d58cbeb9
 _googletest_commit=be03d00f5f0cc3a997d1a368bee8a1fe93651f48

From 0834ab63f3ee679ee0078524651a193b47ba939c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:43 -0500
Subject: [PATCH 114/115] minidlna: revbump for ffmpeg-6.0

---
 srcpkgs/minidlna/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/minidlna/template b/srcpkgs/minidlna/template
index 5fa929f3a0c12..742991ecd04af 100644
--- a/srcpkgs/minidlna/template
+++ b/srcpkgs/minidlna/template
@@ -1,7 +1,7 @@
 # Template file for 'minidlna'
 pkgname=minidlna
 version=1.3.3
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="
  --sbindir=/usr/bin

From 985bba2fe5f27bbf22e37e87fe340ce4545c8d07 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:07:39 -0500
Subject: [PATCH 115/115] mpv: revbump for ffmpeg-6.0

---
 srcpkgs/mpv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpv/template b/srcpkgs/mpv/template
index 301a77ad22971..1541726adbb17 100644
--- a/srcpkgs/mpv/template
+++ b/srcpkgs/mpv/template
@@ -1,7 +1,7 @@
 # Template file for 'mpv'
 pkgname=mpv
 version=0.36.0
-revision=3
+revision=4
 build_style=meson
 configure_args="-Dcdda=enabled -Ddvbin=enabled -Ddvdnav=enabled
  -Dlibmpv=true -Dcplugins=enabled

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (38 preceding siblings ...)
  2023-11-14 13:43 ` zlice
@ 2023-11-20 23:00 ` zlice
  2023-12-03 16:39 ` mhmdanas
                   ` (57 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2023-11-20 23:00 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 3743 bytes --]

There is an updated pull request by zlice against master on the void-packages repository

https://github.com/zlice/void-packages ffmpeg6-split
https://github.com/void-linux/void-packages/pull/43761

ffmpeg6 split
[ci skip]


#### Testing the changes

- I tested the changes in this PR: **YES**

main testing has been vaapi in Firefox Nightly and enc/dec in Shotcut on Intel A770

#### New package

- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**

#### Local build testing

- I built this PR locally for my native architecture, **x86_64**

#### Discussion

Continuation of https://github.com/void-linux/void-packages/pull/36315

`libavresample` is deprecated, but marked as a dependency when trying to build other packages and install `ffmpeg`(6). I think the right way to handle this is make a meta package and the add to removals?


##### Commit naming / misc

~~Commits are 'dirty' right now, running with [gstreamer 1.22.1 updates](https://github.com/void-linux/void-packages/pull/42861) and [Intel OpenCL](https://github.com/void-linux/void-packages/pull/43084). This will also make [intel packages pr](https://github.com/void-linux/void-packages/pull/41132) obsolete.~~ (see Requirements below)

Maintainer for previous ffmpeg(4) was orphaned, I can put my name in there if that matters, though I don't exactly see myself keeping up on ffmpeg.

This updates QT5 which looks like it is usually hosted by Johnny. Not sure if there's any reason to stay there or these sources are fine.

##### STILL FFMPEG4

These are a mix of emulators, games and/or older packages.

- attract (multiple patches in master)
- audacity (https://github.com/audacity/audacity/issues/2305 and https://sourceforge.net/p/portmedia/wiki/portsmf/ is 'beta')
- ccextractor (master patches? no release)
- vice
- kodi
- mlt (only dep left is flowblade)
- ~~synfig (mlt)~~ (work with mlt7, bump synfigstudio)
- tvheadend
- ssr
- ~~spek-alternative~~ (replace with spek-x)
- ppsspp
- olive
- moc
- mediastreamer
- libextractor
- idjc
- hedgewars
- ~~ffmpegthumbnailer~~ (patches for moviedecoder.xxx files)
- ~~ffmpegthumbs~~ (latest compiles)
- deadbeef
- omxplayer
- qtav (fork has ffmpeg 5 patch - https://github.com/cmguo/QtAV)
- `vlc` (vlc4 will support ffmpeg5, there's a patch to build 3.x with ffmpeg5 but it will lack vaapi)
- `osg` (OpenSceneGraph plus `xine-lib`)


##### HAVE NOT BUILT YET

- omxplayer (rpi only? ffmpeg4)
- kodi (big, but ffmpeg4)


##### UPDATED (for ffmpeg6)

- ~~blender: update to 3.5.1~~ ~~will be revbump with~~ https://github.com/void-linux/void-packages/pull/43992
- unpaper: update to 7.0.0.
- guvcview: update to 2.0.8.
- qt5: update to 5.15.8
- qt5-webengine: update to 5.18.13
- shiboken2: revbump for qt5.15.8 (patch)
- python3-pyside2: update to 5.15.8 (patch)
- New package: spex-x replaces spek-alternative for ffmpeg-6.0


##### Requirements

- ~~[gstreamer 1.22.2](https://github.com/void-linux/void-packages/pull/42861)~~ - a few packages use ffmpeg-devel and require a revbump

- ~~[Intel Packages](https://github.com/void-linux/void-packages/pull/41132)~~ [Intel Packages v2](https://github.com/void-linux/void-packages/pull/47330) - ffmpeg4 uses different libraries than 6 (libmfx / Intel-MediaSDK vs only oneVPL that Intel is moving to), both are included here

- ~~[shotcut 23.05.14](https://github.com/void-linux/void-packages/pull/44260)~~

- https://github.com/void-linux/void-packages/pull/44781 will remove from this PR

A patch file from https://github.com/void-linux/void-packages/pull/43761.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ffmpeg6-split-43761.patch --]
[-- Type: text/x-diff, Size: 798129 bytes --]

From c35deb78b4906cada051a359158917221aebca8b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:16:56 -0400
Subject: [PATCH 001/115] ffmpeg: update to 6.0.1.

---
 common/shlibs                                 | 26 +++++---
 srcpkgs/ffmpeg/files/altivec.patch            | 60 -------------------
 .../patches/armv5tel-floating-point.patch     | 18 ------
 ...h-libavcodec-libsvtav1-ten_bit_format.diff | 40 -------------
 .../workaround-mesa-readeon-vaapi-bug.patch   | 28 ---------
 srcpkgs/ffmpeg/template                       | 38 ++++++------
 6 files changed, 37 insertions(+), 173 deletions(-)
 delete mode 100644 srcpkgs/ffmpeg/files/altivec.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 delete mode 100644 srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch

diff --git a/common/shlibs b/common/shlibs
index 247bfca781f5d..c28a56791d9c1 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -385,15 +385,23 @@ libid3tag.so.0 libid3tag-0.15.1b_1
 libgif.so.7 giflib-5.1.0_1
 libImlib2.so.1 imlib2-1.4.2_1
 libmp3lame.so.0 lame-3.98.2_1
-libavdevice.so.58 libavdevice-4.0_1
-libavformat.so.58 libavformat-4.0_1
-libswscale.so.5 libswscale-4.0_1
-libswresample.so.3 libswresample-4.0_1
-libavresample.so.4 libavresample-4.0_1
-libpostproc.so.55 libpostproc-4.0_1
-libavcodec.so.58 libavcodec-4.0_1
-libavutil.so.56 libavutil-4.0_1
-libavfilter.so.7 libavfilter-4.0_1
+libavdevice.so.60 libavdevice-6.0_1
+libavformat.so.60 libavformat-6.0_1
+libswscale.so.7 libswscale-6.0_1
+libswresample.so.4 libswresample-6.0_1
+libpostproc.so.57 libpostproc-6.0_1
+libavcodec.so.60 libavcodec-6.0_1
+libavutil.so.58 libavutil-6.0_1
+libavfilter.so.9 libavfilter-6.0_1
+libavdevice.so.58 libavdevice4-4.0_1
+libavformat.so.58 libavformat4-4.0_1
+libswscale.so.5 libswscale4-4.0_1
+libswresample.so.3 libswresample4-4.0_1
+libavresample.so.4 libavresample4-4.0_1
+libpostproc.so.55 libpostproc4-4.0_1
+libavcodec.so.58 libavcodec4-4.0_1
+libavutil.so.56 libavutil4-4.0_1
+libavfilter.so.7 libavfilter4-4.0_1
 libSDL-1.2.so.0 SDL-1.2.14_1
 libSDL_image-1.2.so.0 SDL_image-1.2.10_1
 libx264.so.157 x264-20190507.2245_1
diff --git a/srcpkgs/ffmpeg/files/altivec.patch b/srcpkgs/ffmpeg/files/altivec.patch
deleted file mode 100644
index 9c57200463320..0000000000000
--- a/srcpkgs/ffmpeg/files/altivec.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-revert some altivec specific change on all ppc* except ppc64le*
-
-q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
-conditionally, for ppc* but not ppc64le* (the new code is valid for
-POWER8 VSX which LE targets as a baseline but not BE)"
-
-
-This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
----
- libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
- 1 file changed, 20 insertions(+), 4 deletions(-)
-
-diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
-index 536545293d..c1e2852adb 100644
---- a/libswscale/ppc/yuv2rgb_altivec.c
-+++ b/libswscale/ppc/yuv2rgb_altivec.c
-@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-     vector signed short R1, G1, B1;                                           \
-     vector unsigned char R, G, B;                                             \
-                                                                               \
-+    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
-+    vector unsigned char align_perm;                                          \
-+                                                                              \
-     vector signed short lCY       = c->CY;                                    \
-     vector signed short lOY       = c->OY;                                    \
-     vector signed short lCRV      = c->CRV;                                   \
-@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
-                                                                               \
-         for (j = 0; j < w / 16; j++) {                                        \
--            y0 = vec_xl(0, y1i);                                              \
-+            y1ivP = (const vector unsigned char *) y1i;                       \
-+            y2ivP = (const vector unsigned char *) y2i;                       \
-+            uivP  = (const vector unsigned char *) ui;                        \
-+            vivP  = (const vector unsigned char *) vi;                        \
-+                                                                              \
-+            align_perm = vec_lvsl(0, y1i);                                    \
-+            y0 = (vector unsigned char)                                       \
-+                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
-                                                                               \
--            y1 = vec_xl(0, y2i);                                              \
-+            align_perm = vec_lvsl(0, y2i);                                    \
-+            y1 = (vector unsigned char)                                       \
-+                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
-                                                                               \
--            u = (vector signed char) vec_xl(0, ui);                           \
-+            align_perm = vec_lvsl(0, ui);                                     \
-+            u = (vector signed char)                                          \
-+                    vec_perm(uivP[0], uivP[1], align_perm);                   \
-                                                                               \
--            v = (vector signed char) vec_xl(0, vi);                           \
-+            align_perm = vec_lvsl(0, vi);                                     \
-+            v = (vector signed char)                                          \
-+                    vec_perm(vivP[0], vivP[1], align_perm);                   \
-                                                                               \
-             u = (vector signed char)                                          \
-                     vec_sub(u,                                                \
--- 
-2.27.0
-
diff --git a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
deleted file mode 100644
index 9a55178c74f0f..0000000000000
--- a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
-+++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
-@@ -39,6 +39,15 @@
- #endif
- #include <fenv.h>
- 
-+#if (FE_ALL_EXCEPT == 0)
-+/* E.g. ARM soft float does not define these */
-+#define FE_INVALID    0
-+#define FE_DIVBYZERO  0
-+#define FE_OVERFLOW   0
-+#define FE_UNDERFLOW  0
-+#define FE_INEXACT    0
-+#endif
-+
- #if CONFIG_LIBFONTCONFIG
- #include <fontconfig/fontconfig.h>
- #endif
diff --git a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
deleted file mode 100644
index aa948f7a8a2df..0000000000000
--- a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
+++ /dev/null
@@ -1,40 +0,0 @@
-#==================================================================================================
-# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
-# From: Christopher Degawa <christopher.degawa@intel.com>
-# Date: Thu, 20 Oct 2022 22:55:27 -0500
-# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
-#
-# compressed_ten_bit_format has been deprecated upstream and has no effect
-# and can be removed. Plus, technically it was never used in the first place
-# since it would require the app (ffmpeg) to set it and do additional
-# processing of the input frames.
-#
-# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
-#
-# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
-#==================================================================================================
---- a/libavcodec/libsvtav1.c
-+++ b/libavcodec/libsvtav1.c
-@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
- 
- static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
- {
--    const int    pack_mode_10bit =
--        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
--    const size_t luma_size_8bit  =
--        config->source_width * config->source_height * (1 << pack_mode_10bit);
--    const size_t luma_size_10bit =
--        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
-+    const size_t luma_size = config->source_width * config->source_height *
-+        (config->encoder_bit_depth > 8 ? 2 : 1);
- 
-     EbSvtIOFormat *in_data;
- 
--    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
-+    svt_enc->raw_size = luma_size * 3 / 2;
- 
-     // allocate buffer for in and out
-     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
--- 
-GitLab
-
diff --git a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
deleted file mode 100644
index 00e3f68a415b8..0000000000000
--- a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
-From: Rainer Hochecker <fernetmenta@online.de>
-Date: Sat, 26 Jan 2019 19:48:35 +0100
-Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
-
-This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
-It was hit frequently when watching h264 channels received via DVB-X.
-Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
----
- libavcodec/vaapi_h264.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
-index 5854587a255..f12fdc457a4 100644
---- a/libavcodec/vaapi_h264.c
-+++ b/libavcodec/vaapi_h264.c
-@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
-     H264SliceContext *sl = &h->slice_ctx[0];
-     int ret;
- 
-+    if (pic->nb_slices == 0) {
-+        ret = AVERROR_INVALIDDATA;
-+        goto finish;
-+    }
-+
-     ret = ff_vaapi_decode_issue(avctx, pic);
-     if (ret < 0)
-         goto finish;
diff --git a/srcpkgs/ffmpeg/template b/srcpkgs/ffmpeg/template
index 5968a09b1f12d..751c24126c22d 100644
--- a/srcpkgs/ffmpeg/template
+++ b/srcpkgs/ffmpeg/template
@@ -1,15 +1,15 @@
 # Template file for 'ffmpeg'
 # audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
 pkgname=ffmpeg
-version=4.4.4
-revision=5
+version=6.0.1
+revision=1
 short_desc="Decoding, encoding and streaming software"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="https://www.ffmpeg.org"
 changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
 distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
-checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+checksum=9b16b8731d78e596b4be0d720428ca42df642bb2d78342881ff7f5bc29fc9623
 
 hostmakedepends="pkg-config perl"
 makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
@@ -26,12 +26,13 @@ makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-deve
  $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
  $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
  $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
- $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers Vulkan-Tools Vulkan-ValidationLayers')
+ $(vopt_if onevpl 'onevpl onevpl-devel')
  $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
 depends="ffplay>=${version}_${revision}"
 
 build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
- dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec onevpl"
 build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
 desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
 desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
@@ -39,9 +40,13 @@ desc_option_sofa="Enable support for AES SOFA"
 desc_option_webp="Enable support for WebP"
 
 case "$XBPS_TARGET_MACHINE" in
-	i686*|x86_64*)
-		hostmakedepends+=" nasm"
+	i686*)
 		build_options_default+=" vaapi vdpau nvenc nvdec"
+		hostmakedepends+=" nasm"
+		;;
+	x86_64*)
+		hostmakedepends+=" nasm"
+		build_options_default+=" vaapi vdpau nvenc nvdec onevpl"
 		;;
 	ppc64*) build_options_default+=" vaapi vdpau";;
 	mips*) CFLAGS="-mnan=legacy";;
@@ -115,18 +120,19 @@ do_configure() {
 		$(vopt_enable x265 libx265) \
 		$(vopt_enable v4l2 libv4l2) \
 		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
-		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		--enable-libbs2b --enable-libvidstab \
 		$(vopt_enable dav1d libdav1d) \
 		$(vopt_enable zimg libzimg) \
 		$(vopt_enable webp libwebp) \
 		$(vopt_enable sofa libmysofa) \
 		$(vopt_enable vulkan) \
+		$(vopt_enable onevpl libvpl) \
 		$(vopt_enable drm libdrm) \
 		$(vopt_enable svtav1 libsvtav1) \
 		$(vopt_enable srt libsrt) \
 		$(vopt_enable rist librist) \
-		$(vopt_if nvenc '--enable-nvenc') \
-		$(vopt_if nvdec '--enable-nvdec')
+		$(vopt_enable nvenc nvenc) \
+		$(vopt_enable nvdec nvdec)
 }
 
 do_build() {
@@ -153,10 +159,8 @@ libavdevice_package() {
 }
 
 libavresample_package() {
-	short_desc="FFmpeg audio resampling library"
-	pkg_install() {
-		vmove "usr/lib/libavresample.so.*"
-	}
+	short_desc="Package deprecated, removal needed"
+	build_style=meta
 }
 
 libavformat_package() {
@@ -210,15 +214,13 @@ ffmpeg-devel_package() {
 		libavfilter>=${version}_${revision}
 		libpostproc>=${version}_${revision}
 		libswscale>=${version}_${revision}
-		libswresample>=${version}_${revision}
-		libavresample>=${version}_${revision}"
+		libswresample>=${version}_${revision}"
 	short_desc+=" - development files"
-
+	conflicts="ffmpeg4-devel"
 	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
 		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
 		nostrip_files="/usr/lib/libavfilter.a"
 	fi
-
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig

From 1da93aafbe49fe43d5ecbaab91cb5af46326d5ec Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:14 -0400
Subject: [PATCH 002/115] openshot: revbump for ffmpeg6.0

---
 srcpkgs/openshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openshot/template b/srcpkgs/openshot/template
index 8f47851eef354..affb652a9d500 100644
--- a/srcpkgs/openshot/template
+++ b/srcpkgs/openshot/template
@@ -1,7 +1,7 @@
 # Template file for 'openshot'
 pkgname=openshot
 version=3.0.0
-revision=2
+revision=3
 build_style=python3-module
 hostmakedepends="python3 python3-setuptools"
 makedepends="ffmpeg-devel python3-PyQt5"

From cb291c7922730351f2dfff2a819fa679e85a68af Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:36 -0400
Subject: [PATCH 003/115] sumo: revbump for ffmpeg6.0

---
 srcpkgs/sumo/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/sumo/template b/srcpkgs/sumo/template
index a3fe134aa5acc..a730afa9fafa9 100644
--- a/srcpkgs/sumo/template
+++ b/srcpkgs/sumo/template
@@ -1,7 +1,7 @@
 # Template file for 'sumo'
 pkgname=sumo
 version=1.12.0
-revision=6
+revision=7
 build_style=cmake
 hostmakedepends="libgdal-tools pkg-config swig python3-setuptools"
 makedepends="python3-devel ffmpeg-devel fox-devel gl2ps-devel libgdal-devel

From 366bcc9cdd74ab4597c684ec2f55a457cd3c475a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:56:22 -0400
Subject: [PATCH 004/115] New package: ffmpeg4-4.4.4.

---
 srcpkgs/ffmpeg4-devel                         |   1 +
 srcpkgs/ffmpeg4/files/altivec.patch           |  60 +++++
 .../patches/armv5tel-floating-point.patch     |  18 ++
 ...h-libavcodec-libsvtav1-ten_bit_format.diff |  40 +++
 .../workaround-mesa-readeon-vaapi-bug.patch   |  28 ++
 srcpkgs/ffmpeg4/template                      | 240 ++++++++++++++++++
 srcpkgs/libavcodec4                           |   1 +
 srcpkgs/libavdevice4                          |   1 +
 srcpkgs/libavfilter4                          |   1 +
 srcpkgs/libavformat4                          |   1 +
 srcpkgs/libavresample4                        |   1 +
 srcpkgs/libavutil4                            |   1 +
 srcpkgs/libpostproc4                          |   1 +
 srcpkgs/libswresample4                        |   1 +
 srcpkgs/libswscale4                           |   1 +
 15 files changed, 396 insertions(+)
 create mode 120000 srcpkgs/ffmpeg4-devel
 create mode 100644 srcpkgs/ffmpeg4/files/altivec.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 create mode 100644 srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
 create mode 100644 srcpkgs/ffmpeg4/template
 create mode 120000 srcpkgs/libavcodec4
 create mode 120000 srcpkgs/libavdevice4
 create mode 120000 srcpkgs/libavfilter4
 create mode 120000 srcpkgs/libavformat4
 create mode 120000 srcpkgs/libavresample4
 create mode 120000 srcpkgs/libavutil4
 create mode 120000 srcpkgs/libpostproc4
 create mode 120000 srcpkgs/libswresample4
 create mode 120000 srcpkgs/libswscale4

diff --git a/srcpkgs/ffmpeg4-devel b/srcpkgs/ffmpeg4-devel
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/ffmpeg4-devel
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/ffmpeg4/files/altivec.patch b/srcpkgs/ffmpeg4/files/altivec.patch
new file mode 100644
index 0000000000000..9c57200463320
--- /dev/null
+++ b/srcpkgs/ffmpeg4/files/altivec.patch
@@ -0,0 +1,60 @@
+revert some altivec specific change on all ppc* except ppc64le*
+
+q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
+conditionally, for ppc* but not ppc64le* (the new code is valid for
+POWER8 VSX which LE targets as a baseline but not BE)"
+
+
+This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
+---
+ libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
+ 1 file changed, 20 insertions(+), 4 deletions(-)
+
+diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
+index 536545293d..c1e2852adb 100644
+--- a/libswscale/ppc/yuv2rgb_altivec.c
++++ b/libswscale/ppc/yuv2rgb_altivec.c
+@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+     vector signed short R1, G1, B1;                                           \
+     vector unsigned char R, G, B;                                             \
+                                                                               \
++    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
++    vector unsigned char align_perm;                                          \
++                                                                              \
+     vector signed short lCY       = c->CY;                                    \
+     vector signed short lOY       = c->OY;                                    \
+     vector signed short lCRV      = c->CRV;                                   \
+@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
+                                                                               \
+         for (j = 0; j < w / 16; j++) {                                        \
+-            y0 = vec_xl(0, y1i);                                              \
++            y1ivP = (const vector unsigned char *) y1i;                       \
++            y2ivP = (const vector unsigned char *) y2i;                       \
++            uivP  = (const vector unsigned char *) ui;                        \
++            vivP  = (const vector unsigned char *) vi;                        \
++                                                                              \
++            align_perm = vec_lvsl(0, y1i);                                    \
++            y0 = (vector unsigned char)                                       \
++                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
+                                                                               \
+-            y1 = vec_xl(0, y2i);                                              \
++            align_perm = vec_lvsl(0, y2i);                                    \
++            y1 = (vector unsigned char)                                       \
++                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
+                                                                               \
+-            u = (vector signed char) vec_xl(0, ui);                           \
++            align_perm = vec_lvsl(0, ui);                                     \
++            u = (vector signed char)                                          \
++                    vec_perm(uivP[0], uivP[1], align_perm);                   \
+                                                                               \
+-            v = (vector signed char) vec_xl(0, vi);                           \
++            align_perm = vec_lvsl(0, vi);                                     \
++            v = (vector signed char)                                          \
++                    vec_perm(vivP[0], vivP[1], align_perm);                   \
+                                                                               \
+             u = (vector signed char)                                          \
+                     vec_sub(u,                                                \
+-- 
+2.27.0
+
diff --git a/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
new file mode 100644
index 0000000000000..9a55178c74f0f
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
@@ -0,0 +1,18 @@
+--- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
++++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
+@@ -39,6 +39,15 @@
+ #endif
+ #include <fenv.h>
+ 
++#if (FE_ALL_EXCEPT == 0)
++/* E.g. ARM soft float does not define these */
++#define FE_INVALID    0
++#define FE_DIVBYZERO  0
++#define FE_OVERFLOW   0
++#define FE_UNDERFLOW  0
++#define FE_INEXACT    0
++#endif
++
+ #if CONFIG_LIBFONTCONFIG
+ #include <fontconfig/fontconfig.h>
+ #endif
diff --git a/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
new file mode 100644
index 0000000000000..aa948f7a8a2df
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
@@ -0,0 +1,40 @@
+#==================================================================================================
+# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
+# From: Christopher Degawa <christopher.degawa@intel.com>
+# Date: Thu, 20 Oct 2022 22:55:27 -0500
+# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
+#
+# compressed_ten_bit_format has been deprecated upstream and has no effect
+# and can be removed. Plus, technically it was never used in the first place
+# since it would require the app (ffmpeg) to set it and do additional
+# processing of the input frames.
+#
+# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
+#
+# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
+#==================================================================================================
+--- a/libavcodec/libsvtav1.c
++++ b/libavcodec/libsvtav1.c
+@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
+ 
+ static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
+ {
+-    const int    pack_mode_10bit =
+-        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
+-    const size_t luma_size_8bit  =
+-        config->source_width * config->source_height * (1 << pack_mode_10bit);
+-    const size_t luma_size_10bit =
+-        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
++    const size_t luma_size = config->source_width * config->source_height *
++        (config->encoder_bit_depth > 8 ? 2 : 1);
+ 
+     EbSvtIOFormat *in_data;
+ 
+-    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
++    svt_enc->raw_size = luma_size * 3 / 2;
+ 
+     // allocate buffer for in and out
+     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
+-- 
+GitLab
+
diff --git a/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
new file mode 100644
index 0000000000000..00e3f68a415b8
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
@@ -0,0 +1,28 @@
+From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
+From: Rainer Hochecker <fernetmenta@online.de>
+Date: Sat, 26 Jan 2019 19:48:35 +0100
+Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
+
+This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
+It was hit frequently when watching h264 channels received via DVB-X.
+Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
+---
+ libavcodec/vaapi_h264.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
+index 5854587a255..f12fdc457a4 100644
+--- a/libavcodec/vaapi_h264.c
++++ b/libavcodec/vaapi_h264.c
+@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
+     H264SliceContext *sl = &h->slice_ctx[0];
+     int ret;
+ 
++    if (pic->nb_slices == 0) {
++        ret = AVERROR_INVALIDDATA;
++        goto finish;
++    }
++
+     ret = ff_vaapi_decode_issue(avctx, pic);
+     if (ret < 0)
+         goto finish;
diff --git a/srcpkgs/ffmpeg4/template b/srcpkgs/ffmpeg4/template
new file mode 100644
index 0000000000000..f2c851693d367
--- /dev/null
+++ b/srcpkgs/ffmpeg4/template
@@ -0,0 +1,240 @@
+# Template file for 'ffmpeg4'
+# audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
+pkgname=ffmpeg4
+version=4.4.4
+revision=1
+short_desc="Decoding, encoding and streaming software - ffmpeg4 libraries only"
+maintainer="Orphaned <orphan@voidlinux.org>"
+license="GPL-3.0-or-later"
+homepage="https://www.ffmpeg.org"
+changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
+distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
+checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+
+hostmakedepends="pkg-config perl"
+makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
+ libXext-devel libXvMC-devel libxcb-devel lame-devel libtheora-devel
+ libvorbis-devel x264-devel xvidcore-devel jack-devel SDL2-devel
+ libcdio-paranoia-devel librtmp-devel libmodplug-devel gnutls-devel
+ speex-devel celt-devel harfbuzz-devel libass-devel opus-devel ocl-icd-devel
+ libbs2b-devel libvidstab-devel vmaf-devel $(vopt_if pulseaudio pulseaudio-devel)
+ $(vopt_if vaapi libva-devel) $(vopt_if vdpau libvdpau-devel)
+ $(vopt_if x265 x265-devel) $(vopt_if v4l2 v4l-utils-devel)
+ $(vopt_if fdk_aac fdk-aac-devel) $(vopt_if vpx libvpx-devel)
+ $(vopt_if aom libaom-devel) $(vopt_if sndio sndio-devel)
+ $(vopt_if dav1d libdav1d-devel) $(vopt_if zimg zimg-devel)
+ $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
+ $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
+ $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if mfx 'libmfx libmfx-devel')
+ $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
+
+build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec mfx"
+build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
+
+desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
+desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
+desc_option_sofa="Enable support for AES SOFA"
+desc_option_webp="Enable support for WebP"
+
+case "$XBPS_TARGET_MACHINE" in
+	i686*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau nvenc nvdec"
+			;;
+	x86_64*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau mfx nvenc nvdec"
+			;;
+	ppc64*) build_options_default+=" vaapi vdpau";;
+	mips*) CFLAGS="-mnan=legacy";;
+esac
+
+if [ "$XBPS_TARGET_WORDSIZE" != "32" ]; then
+	build_options_default+=" svtav1"
+fi
+
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+fi
+
+_apply_patch() {
+	local args="$1" pname="$(basename $2)"
+
+	if [ ! -f ".${pname}_done" ]; then
+		patch -N $args -i $2
+		touch .${pname}_done
+	fi
+}
+
+post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64le*) ;;
+		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
+	esac
+
+	vsed -i libavfilter/vf_libvmaf.c -e 's!/usr/local/share/model/\(vmaf_v0.6.1\).pkl!/usr/share/vmaf/\1.json!'
+}
+
+do_configure() {
+	# Fix gcc on x86_64-musl only
+	if [ "$XBPS_TARGET_MACHINE" = "x86_64-musl" ]; then
+		vsed -i configure -e "s;_cflags_speed='-O3';_cflags_speed='-O2';"
+	fi
+
+	if [ "$CROSS_BUILD" ]; then
+		case "$XBPS_TARGET_MACHINE" in
+			arm*) _arch="arm";;
+			aarch64*) _arch="aarch64";;
+			mips*) _arch="mips";;
+			ppc64*) _arch="ppc64";;
+			ppc*) _arch="ppc";;
+			*) _arch="${XBPS_TARGET_MACHINE%%-musl}";;
+		esac
+
+		_args+=" --enable-cross-compile
+			--sysroot=$XBPS_CROSS_BASE
+			--cross-prefix=${XBPS_CROSS_TRIPLET}-
+			--target-os=linux --arch=${_arch}"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc|ppc-musl) _args+=" --disable-altivec";;
+	esac
+
+	if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+		_args+=" --extra-libs=-latomic"
+	fi
+
+	./configure --prefix=/usr --disable-debug --enable-gpl --enable-gnutls \
+		--disable-stripping \
+		--enable-libcdio --enable-version3 --enable-runtime-cpudetect \
+		--enable-libmp3lame --enable-libvorbis --enable-libxvid \
+		--enable-libx264 $(vopt_enable vpx libvpx) --enable-libtheora \
+		--enable-shared --enable-static --enable-libxcb \
+		$(vopt_enable pulseaudio libpulse) --enable-libfreetype --enable-libmodplug \
+		--enable-libspeex --enable-libcelt --enable-libass \
+		--enable-libopus --enable-librtmp --enable-libjack \
+		$(vopt_if fdk_aac '--enable-nonfree --enable-libfdk-aac') \
+		--disable-libopencore_amrnb --disable-libopencore_amrwb \
+		--disable-libopenjpeg \
+		--enable-postproc --enable-opencl ${_args} --enable-libvmaf ${_args} \
+		$(vopt_enable x265 libx265) \
+		$(vopt_enable v4l2 libv4l2) \
+		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
+		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		$(vopt_enable dav1d libdav1d) \
+		$(vopt_enable zimg libzimg) \
+		$(vopt_enable webp libwebp) \
+		$(vopt_enable sofa libmysofa) \
+		$(vopt_enable vulkan) \
+		$(vopt_enable drm libdrm) \
+		$(vopt_enable svtav1 libsvtav1) \
+		$(vopt_enable srt libsrt) \
+		$(vopt_enable rist librist) \
+		$(vopt_enable mfx libmfx) \
+		$(vopt_if nvenc '--enable-nvenc') \
+		$(vopt_if nvdec '--enable-nvdec')
+}
+
+do_build() {
+	make ${makejobs}
+	make doc/ff{mpeg,play}.1
+}
+
+do_install() {
+	make DESTDIR=${DESTDIR} install install-man
+	rm -rf ${DESTDIR}/usr/bin
+}
+
+libavcodec4_package() {
+	short_desc="FFmpeg codec library"
+	pkg_install() {
+		vmove "usr/lib/libavcodec.so.*"
+	}
+}
+
+libavdevice4_package() {
+	short_desc="FFmpeg device handling library"
+	pkg_install() {
+		vmove "usr/lib/libavdevice.so.*"
+	}
+}
+
+libavresample4_package() {
+	short_desc="FFmpeg audio resampling library"
+	pkg_install() {
+		vmove "usr/lib/libavresample.so.*"
+	}
+}
+
+libavformat4_package() {
+	short_desc="FFmpeg file format library"
+	pkg_install() {
+		vmove "usr/lib/libavformat.so.*"
+	}
+}
+
+libavutil4_package() {
+	short_desc="FFmpeg utility library"
+	pkg_install() {
+		vmove "usr/lib/libavutil.so.*"
+	}
+}
+
+libavfilter4_package() {
+	short_desc="FFmpeg audio/video filter library"
+	pkg_install() {
+		vmove "usr/lib/libavfilter.so.*"
+	}
+}
+
+libpostproc4_package() {
+	short_desc="FFmpeg video postprocessing library"
+	pkg_install() {
+		vmove "usr/lib/libpostproc.so.*"
+	}
+}
+
+libswscale4_package() {
+	short_desc="FFmpeg video scaling library"
+	pkg_install() {
+		vmove "usr/lib/libswscale.so.*"
+	}
+}
+
+libswresample4_package() {
+	short_desc="FFmpeg video resampling library"
+	pkg_install() {
+		vmove "usr/lib/libswresample.so.*"
+	}
+}
+
+ffmpeg4-devel_package() {
+	depends="
+		libavcodec4>=${version}_${revision}
+		libavdevice4>=${version}_${revision}
+		libavformat4>=${version}_${revision}
+		libavutil4>=${version}_${revision}
+		libavfilter4>=${version}_${revision}
+		libpostproc4>=${version}_${revision}
+		libswscale4>=${version}_${revision}
+		libswresample4>=${version}_${revision}
+		libavresample4>=${version}_${revision}"
+	short_desc+=" - development files"
+	conflicts="ffmpeg-devel"
+	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
+		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
+		nostrip_files="/usr/lib/libavfilter.a"
+	fi
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.a"
+		vmove "usr/lib/*.so"
+		vmove usr/share/ffmpeg/examples
+		vmove usr/share/man/man3
+	}
+}
diff --git a/srcpkgs/libavcodec4 b/srcpkgs/libavcodec4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavcodec4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavdevice4 b/srcpkgs/libavdevice4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavdevice4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavfilter4 b/srcpkgs/libavfilter4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavfilter4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavformat4 b/srcpkgs/libavformat4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavformat4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavresample4 b/srcpkgs/libavresample4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavutil4 b/srcpkgs/libavutil4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavutil4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libpostproc4 b/srcpkgs/libpostproc4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libpostproc4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswresample4 b/srcpkgs/libswresample4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libswresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswscale4 b/srcpkgs/libswscale4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libswscale4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file

From 33031d8b67347d7d250eb8cb9f5658549fa33e06 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:04 -0400
Subject: [PATCH 005/115] opencv: update to 4.7.0.

---
 common/shlibs           | 104 ++++++++++++++++++++--------------------
 srcpkgs/opencv/template |   8 ++--
 2 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index c28a56791d9c1..7b20ec435781e 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2084,58 +2084,58 @@ libcapstone.so.5 capstone-5.0.1_1
 libhavege.so.2 libhaveged-1.9.11_1
 libnih.so.1 libnih-1.0.3_1
 libnih-dbus.so.1 libnih-1.0.3_1
-libopencv_quality.so.406 libopencv-4.6.0_1
-libopencv_reg.so.406 libopencv-4.6.0_1
-libopencv_surface_matching.so.406 libopencv-4.6.0_1
-libopencv_xphoto.so.406 libopencv-4.6.0_1
-libopencv_freetype.so.406 libopencv-4.6.0_1
-libopencv_fuzzy.so.406 libopencv-4.6.0_1
-libopencv_hfs.so.406 libopencv-4.6.0_1
-libopencv_img_hash.so.406 libopencv-4.6.0_1
-libopencv_line_descriptor.so.406 libopencv-4.6.0_1
-libopencv_saliency.so.406 libopencv-4.6.0_1
-libopencv_structured_light.so.406 libopencv-4.6.0_1
-libopencv_aruco.so.406 libopencv-4.6.0_1
-libopencv_bgsegm.so.406 libopencv-4.6.0_1
-libopencv_bioinspired.so.406 libopencv-4.6.0_1
-libopencv_ccalib.so.406 libopencv-4.6.0_1
-libopencv_face.so.406 libopencv-4.6.0_1
-libopencv_tracking.so.406 libopencv-4.6.0_1
-libopencv_xfeatures2d.so.406 libopencv-4.6.0_1
-libopencv_optflow.so.406 libopencv-4.6.0_1
-libopencv_ximgproc.so.406 libopencv-4.6.0_1
-libopencv_plot.so.406 libopencv-4.6.0_1
-libopencv_text.so.406 libopencv-4.6.0_1
-libopencv_ml.so.406 libopencv-4.6.0_1
-libopencv_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn.so.406 libopencv-4.6.0_1
-libopencv_shape.so.406 libopencv-4.6.0_1
-libopencv_stitching.so.406 libopencv-4.6.0_1
-libopencv_photo.so.406 libopencv-4.6.0_1
-libopencv_video.so.406 libopencv-4.6.0_1
-libopencv_calib3d.so.406 libopencv-4.6.0_1
-libopencv_features2d.so.406 libopencv-4.6.0_1
-libopencv_flann.so.406 libopencv-4.6.0_1
-libopencv_highgui.so.406 libopencv-4.6.0_1
-libopencv_videoio.so.406 libopencv-4.6.0_1
-libopencv_imgcodecs.so.406 libopencv-4.6.0_1
-libopencv_imgproc.so.406 libopencv-4.6.0_1
-libopencv_core.so.406 libopencv-4.6.0_1
-libopencv_superres.so.406 libopencv-4.6.0_1
-libopencv_videostab.so.406 libopencv-4.6.0_1
-libopencv_gapi.so.406 libopencv-4.6.0_1
-libopencv_xobjdetect.so.406 libopencv-4.6.0_1
-libopencv_datasets.so.406 libopencv-4.6.0_1
-libopencv_dnn_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn_superres.so.406 libopencv-4.6.0_1
-libopencv_dpm.so.406 libopencv-4.6.0_1
-libopencv_phase_unwrapping.so.406 libopencv-4.6.0_1
-libopencv_stereo.so.406 libopencv-4.6.0_1
-libopencv_rapid.so.406 libopencv-4.6.0_1
-libopencv_intensity_transform.so.406 libopencv-4.6.0_1
-libopencv_alphamat.so.406 libopencv-4.6.0_1
-libopencv_barcode.so.406 libopencv-4.6.0_1
-libopencv_mcc.so.406 libopencv-4.6.0_1
+libopencv_quality.so.407 libopencv-4.7.0_1
+libopencv_reg.so.407 libopencv-4.7.0_1
+libopencv_surface_matching.so.407 libopencv-4.7.0_1
+libopencv_xphoto.so.407 libopencv-4.7.0_1
+libopencv_freetype.so.407 libopencv-4.7.0_1
+libopencv_fuzzy.so.407 libopencv-4.7.0_1
+libopencv_hfs.so.407 libopencv-4.7.0_1
+libopencv_img_hash.so.407 libopencv-4.7.0_1
+libopencv_line_descriptor.so.407 libopencv-4.7.0_1
+libopencv_saliency.so.407 libopencv-4.7.0_1
+libopencv_structured_light.so.407 libopencv-4.7.0_1
+libopencv_aruco.so.407 libopencv-4.7.0_1
+libopencv_bgsegm.so.407 libopencv-4.7.0_1
+libopencv_bioinspired.so.407 libopencv-4.7.0_1
+libopencv_ccalib.so.407 libopencv-4.7.0_1
+libopencv_face.so.407 libopencv-4.7.0_1
+libopencv_tracking.so.407 libopencv-4.7.0_1
+libopencv_xfeatures2d.so.407 libopencv-4.7.0_1
+libopencv_optflow.so.407 libopencv-4.7.0_1
+libopencv_ximgproc.so.407 libopencv-4.7.0_1
+libopencv_plot.so.407 libopencv-4.7.0_1
+libopencv_text.so.407 libopencv-4.7.0_1
+libopencv_ml.so.407 libopencv-4.7.0_1
+libopencv_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn.so.407 libopencv-4.7.0_1
+libopencv_shape.so.407 libopencv-4.7.0_1
+libopencv_stitching.so.407 libopencv-4.7.0_1
+libopencv_photo.so.407 libopencv-4.7.0_1
+libopencv_video.so.407 libopencv-4.7.0_1
+libopencv_calib3d.so.407 libopencv-4.7.0_1
+libopencv_features2d.so.407 libopencv-4.7.0_1
+libopencv_flann.so.407 libopencv-4.7.0_1
+libopencv_highgui.so.407 libopencv-4.7.0_1
+libopencv_videoio.so.407 libopencv-4.7.0_1
+libopencv_imgcodecs.so.407 libopencv-4.7.0_1
+libopencv_imgproc.so.407 libopencv-4.7.0_1
+libopencv_core.so.407 libopencv-4.7.0_1
+libopencv_superres.so.407 libopencv-4.7.0_1
+libopencv_videostab.so.407 libopencv-4.7.0_1
+libopencv_gapi.so.407 libopencv-4.7.0_1
+libopencv_xobjdetect.so.407 libopencv-4.7.0_1
+libopencv_datasets.so.407 libopencv-4.7.0_1
+libopencv_dnn_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn_superres.so.407 libopencv-4.7.0_1
+libopencv_dpm.so.407 libopencv-4.7.0_1
+libopencv_phase_unwrapping.so.407 libopencv-4.7.0_1
+libopencv_stereo.so.407 libopencv-4.7.0_1
+libopencv_rapid.so.407 libopencv-4.7.0_1
+libopencv_intensity_transform.so.407 libopencv-4.7.0_1
+libopencv_alphamat.so.407 libopencv-4.7.0_1
+libopencv_barcode.so.407 libopencv-4.7.0_1
+libopencv_mcc.so.407 libopencv-4.7.0_1
 libuniconf.so.4.6 wvstreams-4.6.1_20
 libwvbase.so.4.6 wvstreams-4.6.1_20
 libwvutils.so.4.6 wvstreams-4.6.1_20
diff --git a/srcpkgs/opencv/template b/srcpkgs/opencv/template
index aea4bfc3a265c..ce94de9424d18 100644
--- a/srcpkgs/opencv/template
+++ b/srcpkgs/opencv/template
@@ -1,7 +1,7 @@
 # Template file for 'opencv'
 pkgname=opencv
-version=4.6.0
-revision=6
+version=4.7.0
+revision=1
 create_wrksrc=yes
 build_wrksrc=${pkgname}-${version}
 build_style=cmake
@@ -24,8 +24,8 @@ homepage="https://opencv.org"
 changelog="https://github.com/opencv/opencv/wiki/ChangeLog"
 distfiles="https://github.com/opencv/opencv/archive/${version}.tar.gz
  https://github.com/opencv/opencv_contrib/archive/${version}.tar.gz>contrib.tar.gz"
-checksum="1ec1cba65f9f20fe5a41fda1586e01c70ea0c9a6d7b67c9e13edf0cfe2239277
- 1777d5fd2b59029cf537e5fd6f8aa68d707075822f90bde683fcde086f85f7a7"
+checksum="8df0079cdbe179748a18d44731af62a245a45ebf5085223dc03133954c662973
+ 42df840cf9055e59d0e22c249cfb19f04743e1bdad113d31b1573d3934d62584"
 patch_args="-Np1 -d ${build_wrksrc}"
 # tests hang indenfinitely, even with test data included
 make_check=no

From f22d38eecb6f980ea8d932db944174fee7b9f23d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 006/115] actiona: revbump for opencv-4.7.0

---
 srcpkgs/actiona/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/actiona/template b/srcpkgs/actiona/template
index cf5f0b7a2ae61..0d899311e6df7 100644
--- a/srcpkgs/actiona/template
+++ b/srcpkgs/actiona/template
@@ -1,7 +1,7 @@
 # Template file for 'actiona'
 pkgname=actiona
 version=3.10.1
-revision=2
+revision=3
 build_style=qmake
 configure_args="PKGCONFIG_OPENCV=opencv4"
 hostmakedepends="pkg-config qt5-plugin-mysql qt5-qmake qt5-host-tools"

From 67f498f4df5fb80590c80b7637783e63b0421d15 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 007/115] retroshare: revbump for opencv-4.7.0

---
 srcpkgs/retroshare/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroshare/template b/srcpkgs/retroshare/template
index bb17569277a7f..49e2c1cbe8a53 100644
--- a/srcpkgs/retroshare/template
+++ b/srcpkgs/retroshare/template
@@ -1,7 +1,7 @@
 # Template file for 'retroshare'
 pkgname=retroshare
 version=0.6.6
-revision=3
+revision=4
 build_style=qmake
 #XXX broadcast feature requires an ancient udp-discovery-cpp which either needs
 # to be fetched+patched (FTBFS) here or packaged :/

From de801f4eeb99fdf3ee698e6e7510da0159c99673 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 008/115] waifu2x-converter-cpp: revbump for opencv-4.7.0

---
 srcpkgs/waifu2x-converter-cpp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waifu2x-converter-cpp/template b/srcpkgs/waifu2x-converter-cpp/template
index 361b8a23b9497..c5ac17eb54ea4 100644
--- a/srcpkgs/waifu2x-converter-cpp/template
+++ b/srcpkgs/waifu2x-converter-cpp/template
@@ -1,7 +1,7 @@
 # Template file for 'waifu2x-converter-cpp'
 pkgname=waifu2x-converter-cpp
 version=5.2.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DINSTALL_MODELS=ON"
 hostmakedepends="pkg-config"

From cd3f870ee0f365c746d1a138ece669ef8c3abd2f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:38 -0400
Subject: [PATCH 009/115] vlc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/vlc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vlc/template b/srcpkgs/vlc/template
index abc5eeba01564..5f291b1b81e23 100644
--- a/srcpkgs/vlc/template
+++ b/srcpkgs/vlc/template
@@ -25,7 +25,7 @@ lib32disabled=yes
 hostmakedepends="automake libtool pkg-config flex gettext libgcrypt-devel
  live555-devel gettext-devel $(vopt_if lua lua52) $(vopt_if chromecast protobuf)"
 makedepends="
- avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg-devel freefont-ttf
+ avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg4-devel freefont-ttf
  gnutls-devel jack-devel liba52-devel libass-devel libbluray-devel
  libcdio-devel libdca-devel libdvbpsi-devel libdvdnav-devel libmad-devel
  libmatroska-devel libmodplug-devel libmpcdec-devel libmpeg2-devel

From a3f41b70e822084221d1efb11302827e4ecfff94 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:55 -0400
Subject: [PATCH 010/115] osg: revbump for ffmpeg4-4.4.3

---
 srcpkgs/osg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/osg/template b/srcpkgs/osg/template
index a9ebbd287933b..755793f7e11bf 100644
--- a/srcpkgs/osg/template
+++ b/srcpkgs/osg/template
@@ -8,7 +8,7 @@ build_helper="qemu"
 configure_args="-DLIB_POSTFIX="
 hostmakedepends="pkg-config xrandr"
 makedepends="MesaLib-devel gtkglext-devel libcurl-devel giflib-devel librsvg-devel
- jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg-devel xine-lib-devel
+ jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg4-devel xine-lib-devel
  SDL2-devel gst-plugins-base1-devel
  $(vopt_if openexr libopenexr-devel)
  $(vopt_if poppler poppler-glib-devel)

From 5dcb27d863cc6fd27435f412917d215920246cdb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:13 -0400
Subject: [PATCH 011/115] xine-lib: revbump for ffmpeg4-4.4.3

---
 srcpkgs/xine-lib/template | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/xine-lib/template b/srcpkgs/xine-lib/template
index 3be4d08eac77a..ed6194c17d11e 100644
--- a/srcpkgs/xine-lib/template
+++ b/srcpkgs/xine-lib/template
@@ -1,14 +1,14 @@
 # Template file for 'xine-lib'
 pkgname=xine-lib
-version=1.2.12
-revision=3
+version=1.2.13
+revision=1
 build_style=gnu-configure
 configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
  --disable-oss"
 hostmakedepends="automake gettext-devel libtool pkg-config perl"
 makedepends="
  zlib-devel alsa-lib-devel libxcb-devel libSM-devel libXext-devel libXv-devel
- libXvMC-devel liba52-devel libmad-devel ffmpeg-devel pulseaudio-devel
+ libXvMC-devel liba52-devel libmad-devel ffmpeg4-devel pulseaudio-devel
  jack-devel samba-devel libflac-devel libmodplug-devel libmpcdec-devel
  speex-devel libtheora-devel libvorbis-devel libdca-devel faad2-devel
  libcdio-devel libbluray-devel aalib-devel libcaca-devel libXinerama-devel
@@ -19,7 +19,7 @@ license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="http://www.xine-project.org"
 changelog="https://sourceforge.net/projects/xine/files/xine-lib/${version}/README.txt/view"
 distfiles="${SOURCEFORGE_SITE}/xine/${pkgname}-${version}.tar.xz"
-checksum=d606270468e1540c2a89c0d7f5fdf11e17ecc0c2698cc0bcb1065ff26abee098
+checksum=5f10d6d718a4a51c17ed1b32b031d4f9b80b061e8276535b2be31e5ac4b75e6f
 
 case "$XBPS_TARGET_MACHINE" in
 	i686-musl)

From fe9cb5b1b925f25690e2e2841b937734a3d46c32 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 012/115] arcan: revbump for ffmpeg-6.0

---
 srcpkgs/arcan/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/arcan/template b/srcpkgs/arcan/template
index efd0afe10576d..b91e6900d42a1 100644
--- a/srcpkgs/arcan/template
+++ b/srcpkgs/arcan/template
@@ -2,7 +2,7 @@
 # !! keep synced with: acfgfs aclip aloadimage
 pkgname=arcan
 version=0.6.2.1
-revision=1
+revision=2
 create_wrksrc=yes
 build_wrksrc=arcan/src
 build_style=cmake

From 3c60f318cfcbed49419b7d9fd450517d07a461fa Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 013/115] attract: revbump for ffmpeg4-4.4.3

---
 srcpkgs/attract/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/attract/template b/srcpkgs/attract/template
index 26144e931a3c7..e760bf0d18aec 100644
--- a/srcpkgs/attract/template
+++ b/srcpkgs/attract/template
@@ -1,12 +1,12 @@
 # Template file for 'attract'
 pkgname=attract
 version=2.6.2
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="VERBOSE=1"
 make_use_env=yes
 hostmakedepends="pkg-config"
-makedepends="SFML-devel ffmpeg-devel fontconfig-devel glu-devel libarchive-devel
+makedepends="SFML-devel ffmpeg4-devel fontconfig-devel glu-devel libarchive-devel
  libcurl-devel libjpeg-turbo-devel xine-lib rapidjson libXrandr-devel"
 depends="git"
 short_desc="Attract-Mode is a graphical frontend for emulators"

From 060d396529a9d9d9cb9ac6e5e45666b12c30f7dc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 014/115] aubio: revbump for ffmpeg-6.0

---
 srcpkgs/aubio/patches/ffmpeg5.patch | 25 +++++++++++++++++++++++++
 srcpkgs/aubio/template              |  2 +-
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/aubio/patches/ffmpeg5.patch

diff --git a/srcpkgs/aubio/patches/ffmpeg5.patch b/srcpkgs/aubio/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..aace41a6e6d9a
--- /dev/null
+++ b/srcpkgs/aubio/patches/ffmpeg5.patch
@@ -0,0 +1,25 @@
+From 8a05420e5dd8c7b8b2447f82dc919765876511b3 Mon Sep 17 00:00:00 2001
+From: Paul Brossier <piem@piem.org>
+Date: Tue, 25 Jan 2022 18:30:27 +0100
+Subject: [PATCH] [source_avcodec] define FF_API_LAVF_AVCTX for libavcodec >
+ 59, thx @berolinux (closes gh-353)
+
+---
+ src/io/source_avcodec.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/io/source_avcodec.c b/src/io/source_avcodec.c
+index e0ae93b5..1421bd9a 100644
+--- a/src/io/source_avcodec.c
++++ b/src/io/source_avcodec.c
+@@ -68,6 +68,10 @@
+ #define AUBIO_AVCODEC_MAX_BUFFER_SIZE AV_INPUT_BUFFER_MIN_SIZE
+ #endif
+ 
++#if LIBAVCODEC_VERSION_MAJOR >= 59
++#define FF_API_LAVF_AVCTX 1
++#endif
++
+ struct _aubio_source_avcodec_t {
+   uint_t hop_size;
+   uint_t samplerate;
diff --git a/srcpkgs/aubio/template b/srcpkgs/aubio/template
index ad1c4b2569917..7d875cc02541a 100644
--- a/srcpkgs/aubio/template
+++ b/srcpkgs/aubio/template
@@ -1,7 +1,7 @@
 # Template file for 'aubio'
 pkgname=aubio
 version=0.4.9
-revision=1
+revision=2
 build_style=waf3
 # XXX lash, pure and swig support.
 hostmakedepends="pkg-config txt2man"

From 40741d27a9bb913a34ec4fe2b9b51eadfc761391 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 015/115] audacious-plugins: revbump for ffmpeg-6.0

---
 .../audacious-plugins/patches/ffmpeg5.patch   | 43 +++++++++++++++++++
 srcpkgs/audacious-plugins/template            |  2 +-
 2 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/audacious-plugins/patches/ffmpeg5.patch

diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg5.patch b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..4e5e34099d71c
--- /dev/null
+++ b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
@@ -0,0 +1,43 @@
+commit 298aa371c56c2f52c25a33d9bdec4918b11cebdc
+Author: tibequadorian <tibequadorian@posteo.de>
+Date:   Sat Mar 19 18:40:12 2022 +0100
+
+    audacious-plugins: rebuild against ffmpeg-5.0
+
+diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+new file mode 100644
+index 0000000000..617c11215b
+--- /dev/null
++++ b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+@@ -0,0 +1,31 @@
++From f60beb400eeb1e4778bbfd738bc4a4ccef3de539 Mon Sep 17 00:00:00 2001
++From: John Lindgren <john@jlindgren.net>
++Date: Sat, 5 Mar 2022 12:05:34 -0500
++Subject: [PATCH] Fix build with FFmpeg 5.0
++
++---
++ src/ffaudio/ffaudio-core.cc | 4 ++--
++ 1 file changed, 2 insertions(+), 2 deletions(-)
++
++diff --git a/src/ffaudio/ffaudio-core.cc b/src/ffaudio/ffaudio-core.cc
++index 16dc63e3a..a2b95fd6c 100644
++--- a/src/ffaudio/ffaudio-core.cc
+++++ b/src/ffaudio/ffaudio-core.cc
++@@ -274,7 +274,7 @@ static AVInputFormat * get_format_by_content (const char * name, VFSFile & file)
++         AVProbeData d = {name, buf, filled};
++         score = target;
++ 
++-        f = av_probe_input_format2 (& d, true, & score);
+++        f = (AVInputFormat *) av_probe_input_format2 (& d, true, & score);
++         if (f)
++             break;
++ 
++@@ -347,7 +347,7 @@ static bool find_codec (AVFormatContext * c, CodecInfo * cinfo)
++ #endif
++         if (stream && stream->codecpar && stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
++         {
++-            AVCodec * codec = avcodec_find_decoder (stream->codecpar->codec_id);
+++            AVCodec * codec = (AVCodec *) avcodec_find_decoder (stream->codecpar->codec_id);
++ 
++             if (codec)
++             {
diff --git a/srcpkgs/audacious-plugins/template b/srcpkgs/audacious-plugins/template
index 05e53a9adf78f..4b1968e03de78 100644
--- a/srcpkgs/audacious-plugins/template
+++ b/srcpkgs/audacious-plugins/template
@@ -2,7 +2,7 @@
 #Keep in sync with audacious!
 pkgname=audacious-plugins
 version=4.3.1
-revision=3
+revision=4
 build_style=meson
 configure_args="$(vopt_bool gtk3 gtk) $(vopt_bool gtk3)
  $(vopt_bool qt) $(vopt_bool qt qt6)"

From 5851dd88ab55c5a83689d5687a97edcca4b113e4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 016/115] audacity: revbump for ffmpeg4-4.4.3

---
 srcpkgs/audacity/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/audacity/template b/srcpkgs/audacity/template
index 7b838119ab261..fb15f782ac1f7 100644
--- a/srcpkgs/audacity/template
+++ b/srcpkgs/audacity/template
@@ -1,7 +1,7 @@
 # Template file for 'audacity'
 pkgname=audacity
 version=3.4.2
-revision=1
+revision=2
 build_style=cmake
 build_helper="cmake-wxWidgets-gtk3 qemu"
 configure_args="-Daudacity_use_ffmpeg=loaded -Daudacity_lib_preference=system
@@ -12,7 +12,7 @@ configure_args="-Daudacity_use_ffmpeg=loaded -Daudacity_lib_preference=system
  -Daudacity_has_updates_check=OFF -DAUDACITY_BUILD_LEVEL=2"
 hostmakedepends="pkg-config gettext python3"
 makedepends="wxWidgets-gtk3-devel gtk+3-devel expat-devel lame-devel
- libsoxr-devel portaudio-devel sqlite-devel ffmpeg-devel
+ libsoxr-devel portaudio-devel sqlite-devel ffmpeg4-devel
  libid3tag-devel libmad-devel vamp-plugin-sdk-devel libogg-devel
  libvorbis-devel libflac-devel lilv-devel lv2 serd-devel sord-devel
  sratom-devel suil-devel portmidi-devel soundtouch-devel twolame-devel

From 11cc92a19f4d2fb04feb22d3da8466c1c8392f91 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 017/115] avidemux: revbump for ffmpeg-6.0

---
 srcpkgs/avidemux/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/avidemux/template b/srcpkgs/avidemux/template
index 253a0243e2259..557285982d2b8 100644
--- a/srcpkgs/avidemux/template
+++ b/srcpkgs/avidemux/template
@@ -1,7 +1,7 @@
 # Template file for 'avidemux'
 pkgname=avidemux
 version=2.8.0
-revision=2
+revision=3
 # Can't be compiled for aarch64, arm* or mips*
 archs="x86_64* i686*"
 hostmakedepends="cmake pkg-config qt5-host-tools qt5-devel tar yasm"

From 7706e96641c66563b9d6f274194942e1c4cc5c65 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 018/115] blender: revbump for ffmpeg-6.0

---
 srcpkgs/blender/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index 05fdbf8f747e2..093d6d2004e95 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -9,8 +9,8 @@ configure_args="-DWITH_INSTALL_PORTABLE=OFF -DWITH_PYTHON_INSTALL=OFF
  -DWITH_JACK=ON -DWITH_CODEC_FFMPEG=ON -DWITH_CODEC_SNDFILE=ON -DWITH_OPENMP=ON
  -DWITH_FFTW3=ON -DWITH_MOD_OCEANSIM=ON -DWITH_CYCLES_EMBREE=OFF -DWITH_OPENCOLORIO=ON
  -DWITH_IMAGE_OPENEXR=ON -DWITH_IMAGE_OPENJPEG=ON -DWITH_OPENSUBDIV=ON
- -DWITH_OPENCOLLADA=ON -DWITH_SYSTEM_GLEW=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
- -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_LIBDECOR=ON
+ -DWITH_OPENCOLLADA=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
+ -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_WAYLAND_LIBDECOR=ON
  -DWITH_BUILDINFO=OFF -DPYTHON_VERSION=${py3_ver} -DPYTHON_LIBPATH=/usr/lib
  -DPYTHON_LIBRARY=python${py3_ver}${py3_abiver} -DPYTHON_INCLUDE_DIRS=/${py3_inc}
  -DWITH_SYSTEM_LZO=ON -DWITH_SYSTEM_EIGEN3=ON -DWITH_SYSTEM_FREETYPE=ON"

From 0919b4539e5b35e1067240461438fc1edcdc455b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 019/115] cantata: revbump for ffmpeg-6.0

---
 srcpkgs/cantata/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cantata/template b/srcpkgs/cantata/template
index 4b417d80d5c2d..8a90aaa4c07a2 100644
--- a/srcpkgs/cantata/template
+++ b/srcpkgs/cantata/template
@@ -1,7 +1,7 @@
 # Template file for 'cantata'
 pkgname=cantata
 version=2.5.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools qt5-tools"
 makedepends="qt5-devel qt5-tools-devel qt5-svg-devel qt5-xmlpatterns-devel

From d22cba0f6683214c27f1a22c3e1e2a0380d2bcdd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 020/115] ccextractor: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ccextractor/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/ccextractor/template b/srcpkgs/ccextractor/template
index 9abcd82852b27..6eccad5885af9 100644
--- a/srcpkgs/ccextractor/template
+++ b/srcpkgs/ccextractor/template
@@ -1,12 +1,12 @@
 # Template file for 'ccextractor'
 pkgname=ccextractor
 version=0.93
-revision=1
+revision=2
 build_wrksrc="linux"
 build_style=gnu-configure
 configure_args="--enable-ocr --enable-hardsubx"
 hostmakedepends="automake pkg-config"
-makedepends="leptonica-devel tesseract-ocr-devel ffmpeg-devel"
+makedepends="leptonica-devel tesseract-ocr-devel ffmpeg4-devel"
 short_desc="Extract subtitles from video streams"
 maintainer="newbluemoon <blaumolch@mailbox.org>"
 license="GPL-2.0-or-later"

From 02d37af6c85e7be0298593068fad3990090d2a70 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 021/115] chromaprint: revbump for ffmpeg-6.0

---
 srcpkgs/chromaprint/patches/ffmpeg5.patch | 569 ++++++++++++++++++++++
 srcpkgs/chromaprint/template              |   2 +-
 2 files changed, 570 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromaprint/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromaprint/patches/ffmpeg5.patch b/srcpkgs/chromaprint/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..a9fd307a23c8a
--- /dev/null
+++ b/srcpkgs/chromaprint/patches/ffmpeg5.patch
@@ -0,0 +1,569 @@
+From 8ccad6937177b1b92e40ab8f4447ea27bac009a7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= <lalinsky@gmail.com>
+Date: Fri, 4 Nov 2022 21:47:38 +0100
+Subject: [PATCH] Use FFmpeg 5.x (#120)
+
+* Use FFmpeg 5.1.2 for CI builds
+
+* Build on Ubuntu 20.04
+
+* Upgrade code to FFmpeg 5.x APIs
+
+* Only set FFmpeg include dirs if building tools
+
+* No longer needed
+
+* Use ubuntu 20.04
+---
+ .github/workflows/build.yml                   |   6 +-
+ CMakeLists.txt                                |  16 --
+ package/build.sh                              |   4 +-
+ src/audio/ffmpeg_audio_processor.h            |   2 -
+ src/audio/ffmpeg_audio_processor_avresample.h |  72 -------
+ src/audio/ffmpeg_audio_processor_swresample.h |  18 +-
+ src/audio/ffmpeg_audio_reader.h               | 197 +++++++++---------
+ tests/CMakeLists.txt                          |   6 +
+ 8 files changed, 122 insertions(+), 199 deletions(-)
+ delete mode 100644 src/audio/ffmpeg_audio_processor_avresample.h
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index f8d6a32..4da2405 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -84,9 +84,6 @@ find_package(FFmpeg)
+ if(FFMPEG_LIBRARIES)
+ 	cmake_push_check_state(RESET)
+ 	set(CMAKE_REQUIRED_LIBRARIES ${FFMPEG_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -lm)
+-	check_function_exists(av_packet_unref HAVE_AV_PACKET_UNREF)
+-	check_function_exists(av_frame_alloc HAVE_AV_FRAME_ALLOC)
+-	check_function_exists(av_frame_free HAVE_AV_FRAME_FREE)
+ 	cmake_pop_check_state()
+ endif()
+
+@@ -163,14 +160,11 @@ message(STATUS "Using ${FFT_LIB} for FFT calculations")
+ if(NOT AUDIO_PROCESSOR_LIB)
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+ 		set(AUDIO_PROCESSOR_LIB "swresample")
+-	elseif(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(AUDIO_PROCESSOR_LIB "avresample")
+ 	endif()
+ endif()
+
+ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE OFF)
+ 		set(USE_SWRESAMPLE ON)
+ 		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBSWRESAMPLE_LIBRARIES})
+ 		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBSWRESAMPLE_INCLUDE_DIRS})
+@@ -178,16 +172,6 @@ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+ 	endif()
+ 	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+-elseif(AUDIO_PROCESSOR_LIB STREQUAL "avresample")
+-	if(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE ON)
+-		set(USE_SWRESAMPLE OFF)
+-		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBAVRESAMPLE_LIBRARIES})
+-		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBAVRESAMPLE_INCLUDE_DIRS})
+-	else()
+-		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+-	endif()
+-	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+ else()
+ 	message(STATUS "Building without audio conversion support, please install FFmpeg with libswresample")
+ endif()
+diff --git a/package/build.sh b/package/build.sh
+index da631ae..b41d36e 100755
+--- a/package/build.sh
++++ b/package/build.sh
+@@ -7,8 +7,8 @@ set -eux
+
+ BASE_DIR=$(cd $(dirname $0)/.. && pwd)
+
+-FFMPEG_VERSION=4.4.1
+-FFMPEG_BUILD_TAG=v4.4.1-1
++FFMPEG_VERSION=5.1.2
++FFMPEG_BUILD_TAG=v${FFMPEG_VERSION}-1
+
+ TMP_BUILD_DIR=$BASE_DIR/$(mktemp -d build.XXXXXXXX)
+ trap 'rm -rf $TMP_BUILD_DIR' EXIT
+diff --git a/src/audio/ffmpeg_audio_processor.h b/src/audio/ffmpeg_audio_processor.h
+index 7628fc7..39f4f6d 100644
+--- a/src/audio/ffmpeg_audio_processor.h
++++ b/src/audio/ffmpeg_audio_processor.h
+@@ -10,8 +10,6 @@
+
+ #if defined(USE_SWRESAMPLE)
+ #include "audio/ffmpeg_audio_processor_swresample.h"
+-#elif defined(USE_AVRESAMPLE)
+-#include "audio/ffmpeg_audio_processor_avresample.h"
+ #else
+ #error "no audio processing library"
+ #endif
+diff --git a/src/audio/ffmpeg_audio_processor_avresample.h b/src/audio/ffmpeg_audio_processor_avresample.h
+deleted file mode 100644
+index bd85f92..0000000
+--- a/src/audio/ffmpeg_audio_processor_avresample.h
++++ /dev/null
+@@ -1,72 +0,0 @@
+-// Copyright (C) 2016  Lukas Lalinsky
+-// Distributed under the MIT license, see the LICENSE file for details.
+-
+-#ifndef CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-#define CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-
+-extern "C" {
+-#include <libavresample/avresample.h>
+-}
+-
+-namespace chromaprint {
+-
+-class FFmpegAudioProcessor {
+-public:
+-	FFmpegAudioProcessor() {
+-		m_resample_ctx = avresample_alloc_context();
+-	}
+-
+-	~FFmpegAudioProcessor() {
+-		avresample_free(&m_resample_ctx);
+-	}
+-
+-	void SetCompatibleMode() {
+-		av_opt_set_int(m_resample_ctx, "filter_size", 16, 0);
+-		av_opt_set_int(m_resample_ctx, "phase_shift", 8, 0);
+-		av_opt_set_int(m_resample_ctx, "linear_interp", 1, 0);
+-		av_opt_set_double(m_resample_ctx, "cutoff", 0.8, 0);
+-	}
+-
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "in_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_rate", sample_rate, 0);
+-	}
+-
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "out_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_rate, 0);
+-	}
+-
+-	int Init() {
+-		return avresample_open(m_resample_ctx);
+-	}
+-
+-	int Convert(uint8_t **out, int out_count, const uint8_t **in, int in_count) {
+-		return avresample_convert(m_resample_ctx, out, 0, out_count, (uint8_t **) in, 0, in_count);
+-	}
+-
+-	int Flush(uint8_t **out, int out_count) {
+-		return avresample_read(m_resample_ctx, out, out_count);
+-	}
+-
+-private:
+-	AVAudioResampleContext *m_resample_ctx = nullptr;
+-};
+-
+-}; // namespace chromaprint
+-
+-#endif
+diff --git a/src/audio/ffmpeg_audio_processor_swresample.h b/src/audio/ffmpeg_audio_processor_swresample.h
+index b86266b..b1d4bea 100644
+--- a/src/audio/ffmpeg_audio_processor_swresample.h
++++ b/src/audio/ffmpeg_audio_processor_swresample.h
+@@ -28,30 +28,28 @@ public:
+ 		av_opt_set_double(m_swr_ctx, "cutoff", 0.8, 0);
+ 	}
+
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "icl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "ich", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetInputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "in_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "isf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "in_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "isr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "in_sample_rate", sample_rate, 0);
+ 	}
+
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "ocl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "och", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetOutputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "out_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "osf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "out_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "osr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "out_sample_rate", sample_rate, 0);
+ 	}
+
+ 	int Init() {
+diff --git a/src/audio/ffmpeg_audio_reader.h b/src/audio/ffmpeg_audio_reader.h
+index 5550164..1c6b346 100644
+--- a/src/audio/ffmpeg_audio_reader.h
++++ b/src/audio/ffmpeg_audio_reader.h
+@@ -62,7 +62,7 @@ public:
+ 	bool Read(const int16_t **data, size_t *size);
+
+ 	bool IsOpen() const { return m_opened; }
+-	bool IsFinished() const { return m_finished && !m_got_frame; }
++	bool IsFinished() const { return !m_has_more_packets && !m_has_more_frames; }
+
+ 	std::string GetError() const { return m_error; }
+ 	int GetErrorCode() const { return m_error_code; }
+@@ -74,20 +74,19 @@ private:
+ 	uint8_t *m_convert_buffer[1] = { nullptr };
+ 	int m_convert_buffer_nb_samples = 0;
+
+-	AVInputFormat *m_input_fmt = nullptr;
++	const AVInputFormat *m_input_fmt = nullptr;
+ 	AVDictionary *m_input_opts = nullptr;
+
+ 	AVFormatContext *m_format_ctx = nullptr;
+ 	AVCodecContext *m_codec_ctx = nullptr;
+-	AVFrame *m_frame = nullptr;
+ 	int m_stream_index = -1;
+ 	std::string m_error;
+ 	int m_error_code = 0;
+-	bool m_finished = false;
+ 	bool m_opened = false;
+-	int m_got_frame = 0;
+-	AVPacket m_packet;
+-	AVPacket m_packet0;
++	bool m_has_more_packets = true;
++	bool m_has_more_frames = true;
++	AVPacket *m_packet = nullptr;
++	AVFrame *m_frame = nullptr;
+
+ 	int m_output_sample_rate = 0;
+ 	int m_output_channels = 0;
+@@ -98,19 +97,12 @@ private:
+
+ inline FFmpegAudioReader::FFmpegAudioReader() {
+ 	av_log_set_level(AV_LOG_QUIET);
+-
+-	av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
+ }
+
+ inline FFmpegAudioReader::~FFmpegAudioReader() {
+ 	Close();
+ 	av_dict_free(&m_input_opts);
+ 	av_freep(&m_convert_buffer[0]);
+-	av_packet_unref(&m_packet0);
+ }
+
+ inline bool FFmpegAudioReader::SetInputFormat(const char *name) {
+@@ -135,11 +127,10 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ 	Close();
+
+-    av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
++	m_packet = av_packet_alloc();
++	if (!m_packet) {
++		return false;
++	}
+
+ 	ret = avformat_open_input(&m_format_ctx, file_name.c_str(), m_input_fmt, &m_input_opts);
+ 	if (ret < 0) {
+@@ -153,26 +144,31 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		return false;
+ 	}
+
+-	AVCodec *codec;
++	const AVCodec *codec;
+ 	ret = av_find_best_stream(m_format_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &codec, 0);
+ 	if (ret < 0) {
+ 		SetError("Could not find any audio stream in the file", ret);
+ 		return false;
+ 	}
+ 	m_stream_index = ret;
++	auto stream = m_format_ctx->streams[m_stream_index];
+
+-	m_codec_ctx = m_format_ctx->streams[m_stream_index]->codec;
++	m_codec_ctx = avcodec_alloc_context3(codec);
+ 	m_codec_ctx->request_sample_fmt = AV_SAMPLE_FMT_S16;
+
++	ret = avcodec_parameters_to_context(m_codec_ctx, stream->codecpar);
++	if (ret < 0) {
++		SetError("Could not copy the stream parameters", ret);
++		return false;
++	}
++
+ 	ret = avcodec_open2(m_codec_ctx, codec, nullptr);
+ 	if (ret < 0) {
+ 		SetError("Could not open the codec", ret);
+ 		return false;
+ 	}
+
+-	if (!m_codec_ctx->channel_layout) {
+-		m_codec_ctx->channel_layout = av_get_default_channel_layout(m_codec_ctx->channels);
+-	}
++	av_dump_format(m_format_ctx, 0, "foo", 0);
+
+ 	m_frame = av_frame_alloc();
+ 	if (!m_frame) {
+@@ -183,19 +179,23 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		m_output_sample_rate = m_codec_ctx->sample_rate;
+ 	}
+
+-	if (!m_output_channels) {
+-		m_output_channels = m_codec_ctx->channels;
++	AVChannelLayout output_channel_layout;
++	if (m_output_channels) {
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
++	} else {
++		m_output_channels = m_codec_ctx->ch_layout.nb_channels;
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
+ 	}
+
+-	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
++	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->ch_layout.nb_channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
+ 		m_converter.reset(new FFmpegAudioProcessor());
+ 		m_converter->SetCompatibleMode();
+ 		m_converter->SetInputSampleFormat(m_codec_ctx->sample_fmt);
+ 		m_converter->SetInputSampleRate(m_codec_ctx->sample_rate);
+-		m_converter->SetInputChannelLayout(m_codec_ctx->channel_layout);
++		m_converter->SetInputChannelLayout(&(m_codec_ctx->ch_layout));
+ 		m_converter->SetOutputSampleFormat(AV_SAMPLE_FMT_S16);
+ 		m_converter->SetOutputSampleRate(m_output_sample_rate);
+-		m_converter->SetOutputChannelLayout(av_get_default_channel_layout(m_output_channels));
++		m_converter->SetOutputChannelLayout(&output_channel_layout);
+ 		auto ret = m_converter->Init();
+ 		if (ret != 0) {
+ 			SetError("Could not create an audio converter instance", ret);
+@@ -203,10 +203,11 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		}
+ 	}
+
++	av_channel_layout_uninit(&output_channel_layout);
++
+ 	m_opened = true;
+-	m_finished = false;
+-	m_got_frame = 0;
+-	m_nb_packets = 0;
++	m_has_more_packets = true;
++	m_has_more_frames = true;
+ 	m_decode_error = 0;
+
+ 	return true;
+@@ -214,6 +215,7 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ inline void FFmpegAudioReader::Close() {
+ 	av_frame_free(&m_frame);
++	av_packet_free(&m_packet);
+
+ 	m_stream_index = -1;
+
+@@ -252,91 +254,98 @@ inline bool FFmpegAudioReader::Read(const int16_t **data, size_t *size) {
+ 		return false;
+ 	}
+
++	*data = nullptr;
++	*size = 0;
++
+ 	int ret;
++	bool needs_packet = false;
+ 	while (true) {
+-		while (m_packet.size <= 0) {
+-			av_packet_unref(&m_packet0);
+-			av_init_packet(&m_packet);
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			ret = av_read_frame(m_format_ctx, &m_packet);
++		while (needs_packet && m_packet->size == 0) {
++			ret = av_read_frame(m_format_ctx, m_packet);
+ 			if (ret < 0) {
+ 				if (ret == AVERROR_EOF) {
+-					m_finished = true;
++					needs_packet = false;
++					m_has_more_packets = false;
+ 					break;
+-				} else {
++				}
++				SetError("Error reading from the audio source", ret);
++				return false;
++			}
++			if (m_packet->stream_index == m_stream_index) {
++				needs_packet = false;
++			} else {
++				av_packet_unref(m_packet);
++			}
++		}
++
++		if (m_packet->size != 0) {
++			ret = avcodec_send_packet(m_codec_ctx, m_packet);
++			if (ret < 0) {
++				if (ret != AVERROR(EAGAIN)) {
+ 					SetError("Error reading from the audio source", ret);
+ 					return false;
+ 				}
+-			}
+-			m_packet0 = m_packet;
+-			if (m_packet.stream_index != m_stream_index) {
+-				m_packet.data = nullptr;
+-				m_packet.size = 0;
+ 			} else {
+-				m_nb_packets++;
++				av_packet_unref(m_packet);
+ 			}
+ 		}
+
+-		ret = avcodec_decode_audio4(m_codec_ctx, m_frame, &m_got_frame, &m_packet);
++		ret = avcodec_receive_frame(m_codec_ctx, m_frame);
+ 		if (ret < 0) {
+-			if (m_decode_error) {
+-				SetError("Error decoding audio frame", m_decode_error);
+-				return false;
++			if (ret == AVERROR_EOF) {
++				m_has_more_frames = false;
++			} else if (ret == AVERROR(EAGAIN)) {
++				if (m_has_more_packets) {
++					needs_packet = true;
++					continue;
++				} else {
++					m_has_more_frames = false;
++				}
+ 			}
+-			m_decode_error = ret;
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			continue;
++			SetError("Error decoding the audio source", ret);
++			return false;
+ 		}
+
+-		break;
+-	}
+-
+-	m_decode_error = 0;
+-
+-	const int decoded = std::min(ret, m_packet.size);
+-	m_packet.data += decoded;
+-	m_packet.size -= decoded;
+-
+-	if (m_got_frame) {
+-		if (m_converter) {
+-			if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
+-				int linsize;
+-				av_freep(&m_convert_buffer[0]);
+-				m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
+-				ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
+-				if (ret < 0) {
+-					SetError("Couldn't allocate audio converter buffer", ret);
++		if (m_frame->nb_samples > 0) {
++			if (m_converter) {
++				if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
++					int linsize;
++					av_freep(&m_convert_buffer[0]);
++					m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
++					ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->ch_layout.nb_channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
++					if (ret < 0) {
++						SetError("Couldn't allocate audio converter buffer", ret);
++						return false;
++					}
++				}
++				auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
++				if (nb_samples < 0) {
++					SetError("Couldn't convert audio", ret);
+ 					return false;
+ 				}
+-			}
+-			auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			}
+-			*data = (const int16_t *) m_convert_buffer[0];
+-			*size = nb_samples;
+-		} else {
+-			*data = (const int16_t *) m_frame->data[0];
+-			*size = m_frame->nb_samples;
+-		}
+-	} else {
+-		if (m_finished && m_converter) {
+-			auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			} else if (nb_samples > 0) {
+-				m_got_frame = 1;
+ 				*data = (const int16_t *) m_convert_buffer[0];
+ 				*size = nb_samples;
++			} else {
++				*data = (const int16_t *) m_frame->data[0];
++				*size = m_frame->nb_samples;
++			}
++		} else {
++			if (m_converter) {
++				if (IsFinished()) {
++					auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
++					if (nb_samples < 0) {
++						SetError("Couldn't convert audio", ret);
++						return false;
++					} else if (nb_samples > 0) {
++						*data = (const int16_t *) m_convert_buffer[0];
++						*size = nb_samples;
++					}
++				}
+ 			}
+ 		}
+-	}
+
+-	return true;
++		return true;
++	}
+ }
+
+ inline void FFmpegAudioReader::SetError(const char *message, int errnum) {
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index a2b517b..123e643 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -38,6 +38,12 @@ set(SRCS
+
+ if(BUILD_TOOLS)
+ 	set(SRCS ${SRCS} ../src/audio/ffmpeg_audio_reader_test.cpp)
++    include_directories(
++        ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}
++        ${AUDIO_PROCESSOR_INCLUDE_DIRS}
++    )
+ 	link_libraries(fpcalc_libs)
+ endif()
+
+-- 
+2.38.1
+
+
diff --git a/srcpkgs/chromaprint/template b/srcpkgs/chromaprint/template
index 7ef7838949f3a..1f7bbc70a22c8 100644
--- a/srcpkgs/chromaprint/template
+++ b/srcpkgs/chromaprint/template
@@ -1,7 +1,7 @@
 # Template file for 'chromaprint'
 pkgname=chromaprint
 version=1.5.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DBUILD_TOOLS=ON"
 make_check_target="check"

From 741d56c1159ec1e5dcc2a32c8bbf7ab61f3b538e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 022/115] chromium: revbump for ffmpeg-6.0

---
 .../patches/chromium-119-ffmpeg-4.4.patch     | 20 --------
 srcpkgs/chromium/patches/ffmpeg5.patch        | 47 +++++++++++++++++++
 srcpkgs/chromium/template                     |  2 +-
 3 files changed, 48 insertions(+), 21 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch
 create mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch b/srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch
deleted file mode 100644
index 04d04b166ba37..0000000000000
--- a/srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch
+++ /dev/null
@@ -1,20 +0,0 @@
---- a/media/filters/ffmpeg_demuxer.cc.orig
-+++ b/media/filters/ffmpeg_demuxer.cc
-@@ -390,7 +390,7 @@
- 
-   scoped_refptr<DecoderBuffer> buffer;
- 
--    size_t side_data_size = 0;
-+    int side_data_size = 0;
-     uint8_t* side_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
- 
-@@ -453,7 +453,7 @@
-                                        packet->size - data_offset);
-     }
- 
--    size_t skip_samples_size = 0;
-+    int skip_samples_size = 0;
-     const uint32_t* skip_samples_ptr =
-         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
-             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..24e2da38e34ca
--- /dev/null
+++ b/srcpkgs/chromium/patches/ffmpeg5.patch
@@ -0,0 +1,47 @@
+--- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
++++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
+@@ -92,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+-  if (stream->start_time != kNoFFmpegTimestamp)
++  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -1597,7 +1585,7 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+@@ -1618,7 +1606,7 @@
+     if (stream->type() != DemuxerStream::VIDEO)
+       continue;
+ 
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+ 
+     if (!stream->IsEnabled())
diff --git a/srcpkgs/chromium/template b/srcpkgs/chromium/template
index b023946f3ec7b..fe36a6dce20d3 100644
--- a/srcpkgs/chromium/template
+++ b/srcpkgs/chromium/template
@@ -2,7 +2,7 @@
 pkgname=chromium
 # See https://chromiumdash.appspot.com/releases?platform=Linux for the latest version
 version=119.0.6045.105
-revision=3
+revision=4
 archs="i686* x86_64* aarch64* armv7l*"
 hostmakedepends="
  $(vopt_if clang "clang lld llvm15")

From 7bf1a482cf62b49cae2d4cfd81e4308822e01faa Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 023/115] cmus: revbump for ffmpeg-6.0

---
 srcpkgs/chromium/patches/ffmpeg5.patch | 47 --------------------------
 srcpkgs/cmus/patches/ffmpeg6.patch     | 12 +++++++
 srcpkgs/cmus/template                  |  2 +-
 3 files changed, 13 insertions(+), 48 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch
 create mode 100644 srcpkgs/cmus/patches/ffmpeg6.patch

diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
deleted file mode 100644
index 24e2da38e34ca..0000000000000
--- a/srcpkgs/chromium/patches/ffmpeg5.patch
+++ /dev/null
@@ -1,47 +0,0 @@
---- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
-+++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
-@@ -92,24 +92,12 @@
- 
- static base::TimeDelta ExtractStartTime(AVStream* stream) {
-   // The default start time is zero.
--  base::TimeDelta start_time;
-+  base::TimeDelta start_time = kNoTimestamp;
- 
-   // First try to use  the |start_time| value as is.
--  if (stream->start_time != kNoFFmpegTimestamp)
-+  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
-     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
- 
--  // Next try to use the first DTS value, for codecs where we know PTS == DTS
--  // (excludes all H26x codecs). The start time must be returned in PTS.
--  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
--      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
--      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
--      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
--    const base::TimeDelta first_pts =
--        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
--    if (first_pts < start_time)
--      start_time = first_pts;
--  }
--
-   return start_time;
- }
- 
-@@ -1597,7 +1585,7 @@
-   for (const auto& stream : streams_) {
-     if (!stream || stream->IsEnabled() != enabled)
-       continue;
--    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
-+    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
-       continue;
-     if (!lowest_start_time_stream ||
-         stream->start_time() < lowest_start_time_stream->start_time()) {
-@@ -1618,7 +1606,7 @@
-     if (stream->type() != DemuxerStream::VIDEO)
-       continue;
- 
--    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
-+    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
-       continue;
- 
-     if (!stream->IsEnabled())
diff --git a/srcpkgs/cmus/patches/ffmpeg6.patch b/srcpkgs/cmus/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..ffa95ab811101
--- /dev/null
+++ b/srcpkgs/cmus/patches/ffmpeg6.patch
@@ -0,0 +1,12 @@
+--- a/ip/ffmpeg.c
++++ b/ip/ffmpeg.c
+@@ -202,9 +202,6 @@ static int ffmpeg_open(struct input_plugin_data *ip_data)
+ 			break;
+ 		}
+ 
+-		if (codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+-			cc->flags |= AV_CODEC_FLAG_TRUNCATED;
+-
+ 		if (avcodec_open2(cc, codec, NULL) < 0) {
+ 			d_print("could not open codec: %d, %s\n", cc->codec_id, avcodec_get_name(cc->codec_id));
+ 			err = -IP_ERROR_UNSUPPORTED_FILE_TYPE;
diff --git a/srcpkgs/cmus/template b/srcpkgs/cmus/template
index 0d1436744f1b2..a6e4b4fa86cb8 100644
--- a/srcpkgs/cmus/template
+++ b/srcpkgs/cmus/template
@@ -1,7 +1,7 @@
 # Template file for 'cmus'
 pkgname=cmus
 version=2.10.0
-revision=3
+revision=4
 build_style=configure
 configure_args="prefix=/usr LD=$CC"
 hostmakedepends="pkg-config"

From 76df444d75eee3c3e3db734441bd8805fce3e419 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 024/115] cyanrip: revbump for ffmpeg-6.0

---
 srcpkgs/cyanrip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cyanrip/template b/srcpkgs/cyanrip/template
index 9796e3461601a..5db30e020d17e 100644
--- a/srcpkgs/cyanrip/template
+++ b/srcpkgs/cyanrip/template
@@ -1,7 +1,7 @@
 # Template file for 'cyanrip'
 pkgname=cyanrip
 version=0.9.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config"
 makedepends="ffmpeg-devel libcdio-devel libcdio-paranoia-devel libcurl-devel libmusicbrainz5-devel"

From 63525db3dff88bc19c1b7b28ced84843bb040978 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 025/115] deadbeef: revbump for ffmpeg4-4.4.3

---
 srcpkgs/deadbeef/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/deadbeef/template b/srcpkgs/deadbeef/template
index f5f4bf24b8cb6..7b47e615cd48e 100644
--- a/srcpkgs/deadbeef/template
+++ b/srcpkgs/deadbeef/template
@@ -1,14 +1,14 @@
 # Template file for 'deadbeef'
 pkgname=deadbeef
 version=1.8.8
-revision=3
+revision=4
 create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-oss --disable-lfm --disable-notify --disable-gtk2"
 hostmakedepends="automake libtool gettext gettext-devel intltool pkg-config
  yasm clang glib-devel"
 makedepends="
- alsa-lib-devel dbus-devel faad2-devel ffmpeg-devel gtk+3-devel imlib2-devel
+ alsa-lib-devel dbus-devel faad2-devel ffmpeg4-devel gtk+3-devel imlib2-devel
  jansson-devel libcddb-devel libcdio-devel libcurl-devel libflac-devel
  libmad-devel libpng-devel libsamplerate-devel libsndfile-devel libvorbis-devel
  libzip-devel mpg123-devel opusfile-devel pulseaudio-devel wavpack-devel"

From 25a39f738bf00c4ca265a63309f30eda896800cd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 026/115] droidcam-obs-plugin: revbump for ffmpeg-6.0

---
 srcpkgs/droidcam-obs-plugin/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam-obs-plugin/template b/srcpkgs/droidcam-obs-plugin/template
index fc9c9bf6b9d54..fb0480754df4d 100644
--- a/srcpkgs/droidcam-obs-plugin/template
+++ b/srcpkgs/droidcam-obs-plugin/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam-obs-plugin'
 pkgname=droidcam-obs-plugin
 version=2.0.1
-revision=1
+revision=2
 build_style=gnu-makefile
 make_use_env=yes
 make_build_args="ALLOW_STATIC=no"

From ce3fee529c6073c987db50c8159fa457ae3661b1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 027/115] droidcam: revbump for ffmpeg-6.0

---
 srcpkgs/droidcam/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam/template b/srcpkgs/droidcam/template
index 1c3f1b8b1fc67..32a9220b79a4d 100644
--- a/srcpkgs/droidcam/template
+++ b/srcpkgs/droidcam/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam'
 pkgname=droidcam
 version=1.8.2
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="USBMUXD=-lusbmuxd-2.0 JPEG=-lturbojpeg"
 hostmakedepends="pkg-config"

From 6c59a831b2a9d238e0f782bf27f63c7e454d995f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 028/115] ffmpegthumbnailer: revbump for ffmpeg-6.0

---
 .../ffmpegthumbnailer/patches/ffmpeg6.patch   | 202 ++++++++++++++++++
 srcpkgs/ffmpegthumbnailer/template            |   6 +-
 2 files changed, 205 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch

diff --git a/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..363ff35a28419
--- /dev/null
+++ b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
@@ -0,0 +1,202 @@
+--- a/libffmpegthumbnailer/moviedecoder.cpp	2017-11-21 14:06:57.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.cpp	2023-05-05 13:14:47.946560668 -0400
+@@ -41,11 +41,6 @@
+ namespace ffmpegthumbnailer
+ {
+ 
+-struct SilenceLogLevel
+-{
+-    SilenceLogLevel() { av_log_set_level(AV_LOG_QUIET); }
+-};
+-
+ MovieDecoder::MovieDecoder(AVFormatContext* pavContext)
+ : m_VideoStream(-1)
+ , m_pFormatContext(pavContext)
+@@ -70,8 +65,6 @@
+ 
+ void MovieDecoder::initialize(const string& filename, bool preferEmbeddedMetadata)
+ {
+-    av_register_all();
+-    avcodec_register_all();
+     avformat_network_init();
+ 
+     string inputFile = filename == "-" ? "pipe:" : filename;
+@@ -97,8 +90,7 @@
+ {
+     if (m_pVideoCodecContext)
+     {
+-        avcodec_close(m_pVideoCodecContext);
+-        m_pVideoCodecContext = nullptr;
++        avcodec_free_context(&m_pVideoCodecContext);
+     }
+ 
+     if ((!m_FormatContextWasGiven) && m_pFormatContext)
+@@ -152,10 +144,10 @@
+     for (unsigned int i = 0; i < m_pFormatContext->nb_streams; ++i)
+     {
+         AVStream *stream = m_pFormatContext->streams[i];
+-        auto ctx = m_pFormatContext->streams[i]->codec;
+-        if (ctx->codec_type == AVMEDIA_TYPE_VIDEO)
++        auto par = m_pFormatContext->streams[i]->codecpar;
++        if (par->codec_type == AVMEDIA_TYPE_VIDEO)
+         {
+-            if (!preferEmbeddedMetadata || !isStillImageCodec(ctx->codec_id))
++            if (!preferEmbeddedMetadata || !isStillImageCodec(par->codec_id))
+             {
+                 videoStreams.push_back(i);
+                 continue;
+@@ -203,8 +195,7 @@
+     }
+ 
+     m_pVideoStream = m_pFormatContext->streams[m_VideoStream];
+-    m_pVideoCodecContext = m_pVideoStream->codec;
+-    m_pVideoCodec = avcodec_find_decoder(m_pVideoCodecContext->codec_id);
++    m_pVideoCodec = avcodec_find_decoder(m_pVideoStream->codecpar->codec_id);
+ 
+     if (m_pVideoCodec == nullptr)
+     {
+@@ -214,6 +205,20 @@
+         throw logic_error("Video Codec not found");
+     }
+ 
++    m_pVideoCodecContext = avcodec_alloc_context3(m_pVideoCodec);
++
++    if (m_pVideoCodecContext == nullptr)
++    {
++        destroy();
++        throw logic_error("Could not allocate video codec context");
++    }
++
++    if (avcodec_parameters_to_context(m_pVideoCodecContext, m_pVideoStream->codecpar) < 0)
++    {
++        destroy();
++        throw logic_error("Could not configure video codec context");
++    }
++
+     m_pVideoCodecContext->workaround_bugs = 1;
+ 
+     if (avcodec_open2(m_pVideoCodecContext, m_pVideoCodec, nullptr) < 0)
+@@ -386,13 +391,6 @@
+ 
+ void MovieDecoder::initializeFilterGraph(const AVRational& timeBase, const std::string& size, bool maintainAspectRatio)
+ {
+-    static const AVPixelFormat pixelFormats[] = { AV_PIX_FMT_RGB24, AV_PIX_FMT_NONE };
+-
+-    auto del = [] (AVBufferSinkParams* p) { av_freep(p); };
+-    std::unique_ptr<AVBufferSinkParams, decltype(del)> buffersinkParams(av_buffersink_params_alloc(), del);
+-
+-    avfilter_register_all();
+-
+     m_pFilterGraph = avfilter_graph_alloc();
+     assert(m_pFilterGraph);
+ 
+@@ -404,10 +402,8 @@
+ 
+     checkRc(avfilter_graph_create_filter(&m_pFilterSource, avfilter_get_by_name("buffer"), "thumb_buffer", ss.str().c_str(), nullptr, m_pFilterGraph),
+             "Failed to create filter source");
+-    buffersinkParams->pixel_fmts = pixelFormats;
+-    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, buffersinkParams.get(), m_pFilterGraph),
++    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, nullptr, m_pFilterGraph),
+             "Failed to create filter sink");
+-    buffersinkParams.release();
+ 
+     AVFilterContext* yadifFilter = nullptr;
+     if (m_pFrame->interlaced_frame != 0)
+@@ -500,15 +496,15 @@
+     }
+ 
+     checkRc(av_seek_frame(m_pFormatContext, -1, timestamp, 0), "Seeking in video failed");
+-    avcodec_flush_buffers(m_pFormatContext->streams[m_VideoStream]->codec);
++    avcodec_flush_buffers(m_pVideoCodecContext);
+ 
+     int keyFrameAttempts = 0;
+-    bool gotFrame = 0;
++    bool gotFrame;
+ 
+     do
+     {
+         int count = 0;
+-        gotFrame = 0;
++        gotFrame = false;
+ 
+         while (!gotFrame && count < 20)
+         {
+@@ -552,17 +548,33 @@
+         return false;
+     }
+ 
+-    av_frame_unref(m_pFrame);
+-
+-    int frameFinished;
++    int rc = avcodec_send_packet(m_pVideoCodecContext, m_pPacket);
++    if(rc == AVERROR(EAGAIN))
++    {
++        rc = 0;
++    }
+ 
+-    int bytesDecoded = avcodec_decode_video2(m_pVideoCodecContext, m_pFrame, &frameFinished, m_pPacket);
+-    if (bytesDecoded < 0)
++    if(rc == AVERROR_EOF)
++    {
++        return false;
++    }
++    else if(rc < 0)
+     {
+-        throw logic_error("Failed to decode video frame: bytesDecoded < 0");
++        throw logic_error("Failed to decode video frame: avcodec_send_packet() < 0");
+     }
+ 
+-    return frameFinished > 0;
++    rc = avcodec_receive_frame(m_pVideoCodecContext, m_pFrame);
++    switch(rc)
++    {
++        case 0:
++            return true;
++
++        case AVERROR(EAGAIN):
++            return false;
++
++        default:
++            throw logic_error("Failed to decode video frame: avcodec_receive_frame() < 0");
++    }
+ }
+ 
+ bool MovieDecoder::getVideoPacket()
+@@ -570,8 +582,6 @@
+     bool framesAvailable = true;
+     bool frameDecoded = false;
+ 
+-    int attempts = 0;
+-
+     if (m_pPacket)
+     {
+         av_packet_unref(m_pPacket);
+@@ -580,6 +590,7 @@
+ 
+     m_pPacket = new AVPacket();
+ 
++
+     while (framesAvailable && !frameDecoded)
+     {
+         framesAvailable = av_read_frame(m_pFormatContext, m_pPacket) >= 0;
+@@ -644,7 +655,7 @@
+ 
+ int32_t MovieDecoder::getStreamRotation()
+ {
+-    int32_t* matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
++    auto matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
+     if (matrix)
+     {
+         auto angle = lround(av_display_rotation_get(matrix));
+
+--- a/libffmpegthumbnailer/moviedecoder.h	2017-11-12 04:23:38.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.h	2023-05-05 13:26:07.095529911 -0400
+@@ -78,7 +78,7 @@
+     int                     m_VideoStream;
+     AVFormatContext*        m_pFormatContext;
+     AVCodecContext*         m_pVideoCodecContext;
+-    AVCodec*                m_pVideoCodec;
++    const AVCodec*          m_pVideoCodec;
+     AVFilterGraph*          m_pFilterGraph;
+     AVFilterContext*        m_pFilterSource;
+     AVFilterContext*        m_pFilterSink;
diff --git a/srcpkgs/ffmpegthumbnailer/template b/srcpkgs/ffmpegthumbnailer/template
index 039eea7622b39..35d546018d12a 100644
--- a/srcpkgs/ffmpegthumbnailer/template
+++ b/srcpkgs/ffmpegthumbnailer/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbnailer'
 pkgname=ffmpegthumbnailer
 version=2.2.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libpng-devel libjpeg-turbo-devel ffmpeg-devel"
@@ -9,8 +9,8 @@ depends="ffmpeg"
 short_desc="Lightweight video thumbnailer"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
-homepage="https://github.com/dirkvdb/${pkgname}"
-distfiles="${homepage}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
+homepage="https://github.com/dirkvdb"
+distfiles="${homepage}/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
 checksum=1cb24059c38223f657b300c84dd80491b7040d4b69471c4fea69be862bc99b5b
 
 post_install() {

From 0e2dd6b2dc1e82f44cd2a655704605f1d4e9073f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 029/115] ffmpegthumbs: revbump for ffmpeg-6.0

---
 srcpkgs/ffmpegthumbs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ffmpegthumbs/template b/srcpkgs/ffmpegthumbs/template
index 5f0b9414dadaf..11b88193528f4 100644
--- a/srcpkgs/ffmpegthumbs/template
+++ b/srcpkgs/ffmpegthumbs/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbs'
 pkgname=ffmpegthumbs
 version=22.12.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules kcoreaddons kconfig-devel
  pkg-config qt5-host-tools qt5-qmake gettext"

From 465e3bb8943bf68b6e1001db6609c1d2f8f3cad2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 030/115] ffms2: revbump for ffmpeg-6.0

---
 srcpkgs/ffms2/patches/ffmpeg5.patch | 424 ++++++++++++++++++++++++++++
 srcpkgs/ffms2/template              |   2 +-
 2 files changed, 425 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ffms2/patches/ffmpeg5.patch

diff --git a/srcpkgs/ffms2/patches/ffmpeg5.patch b/srcpkgs/ffms2/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..1479fabcafcb4
--- /dev/null
+++ b/srcpkgs/ffms2/patches/ffmpeg5.patch
@@ -0,0 +1,424 @@
+From 45673149e9a2f5586855ad472e3059084eaa36b1 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:41:21 +0100
+Subject: [PATCH] Use auto for AVCodec
+
+The geniuses over at FFmpeg decided to constify this API, so old
+versions of the library will return AVCodec *, while new versions
+of the libary will return const AVCodec *, which, in C++, are not
+OK to convert between.
+
+Rather than use some macro hell in ffmscompat.h, we can work around
+this by using auto.
+
+Gross.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 2 +-
+ src/core/indexing.cpp    | 6 +++---
+ src/core/videosource.cpp | 2 +-
+ 3 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index e4ce97c..ac09666 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -469,7 +469,7 @@ void FFMS_AudioSource::OpenFile() {
+ 
+     LAVFOpenFile(SourceFile.c_str(), FormatContext, TrackNumber);
+ 
+-    AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
++    auto *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
+     if (Codec == nullptr)
+         throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+             "Audio codec not found");
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index e547c5a..59fb4e8 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -384,7 +384,7 @@ FFMS_TrackType FFMS_Indexer::GetTrackType(int Track) {
+ }
+ 
+ const char *FFMS_Indexer::GetTrackCodec(int Track) {
+-    AVCodec *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
++    auto *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
+     return codec ? codec->name : nullptr;
+ }
+ 
+@@ -402,7 +402,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             UseDTS);
+ 
+         if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            AVCodec *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (!VideoCodec) {
+                 FormatContext->streams[i]->discard = AVDISCARD_ALL;
+                 IndexMask.erase(i);
+@@ -433,7 +433,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 IndexMask.insert(i);
+             }
+         } else if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+-            AVCodec *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (AudioCodec == nullptr)
+                 throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_UNSUPPORTED,
+                     "Audio codec not found");
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index b889970..8956c22 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -171,7 +171,7 @@ FFMS_VideoSource::FFMS_VideoSource(const char *SourceFile, FFMS_Index &Index, in
+ 
+         LAVFOpenFile(SourceFile, FormatContext, VideoTrack);
+ 
+-        AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
++        auto *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
+         if (Codec == nullptr)
+             throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+                 "Video codec not found");
+-- 
+2.40.0
+
+From 96cbf38ea9381829a1314f432a2c60495dcefaad Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:12:41 +0100
+Subject: [PATCH] all: Update AVPacket API usage
+
+AVPackets must all be on the heap now, since it is no longer
+part of the libav* ABI.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 16 ++++++----
+ src/core/indexing.cpp    | 63 ++++++++++++++++++++++------------------
+ src/core/indexing.h      |  4 +--
+ src/core/utils.cpp       |  6 ----
+ src/core/utils.h         |  1 -
+ src/core/videosource.cpp | 30 ++++++++++---------
+ 6 files changed, 64 insertions(+), 56 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index 37cf9ae..e4ce97c 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -285,10 +285,15 @@ FFMS_AudioSource::AudioBlock *FFMS_AudioSource::CacheBlock(CacheIterator &pos) {
+ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     CurrentFrame = &Frames[PacketNumber];
+ 
+-    AVPacket Packet;
+-    if (!ReadPacket(&Packet))
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++    if (!ReadPacket(Packet)) {
++        av_packet_free(&Packet);
+         throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_UNKNOWN,
+             "ReadPacket unexpectedly failed to read a packet");
++    }
+ 
+     // ReadPacket may have changed the packet number
+     CurrentFrame = &Frames[PacketNumber];
+@@ -297,8 +302,9 @@ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     int NumberOfSamples = 0;
+     AudioBlock *CachedBlock = nullptr;
+     
+-    int Ret = avcodec_send_packet(CodecContext, &Packet);
+-    av_packet_unref(&Packet);
++    int Ret = avcodec_send_packet(CodecContext, Packet);
++    av_packet_unref(Packet);
++    av_packet_free(&Packet);
+ 
+     av_frame_unref(DecodeFrame);
+     Ret = avcodec_receive_frame(CodecContext, DecodeFrame);
+@@ -513,8 +519,6 @@ void FFMS_AudioSource::Seek() {
+ }
+ 
+ bool FFMS_AudioSource::ReadPacket(AVPacket *Packet) {
+-    InitNullPacket(*Packet);
+-
+     while (av_read_frame(FormatContext, Packet) >= 0) {
+         if (Packet->stream_index == TrackNumber) {
+             // Required because not all audio packets, especially in ogg, have a pts. Use the previous valid packet's pts instead.
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index 23fb95b..e547c5a 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -320,7 +320,7 @@ void FFMS_Indexer::CheckAudioProperties(int Track, AVCodecContext *Context) {
+     }
+ }
+ 
+-void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict,
++void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict,
+                                     int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct) {
+     if (VideoContext.Parser) {
+         uint8_t *OB;
+@@ -330,8 +330,8 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+         av_parser_parse2(VideoContext.Parser,
+             VideoContext.CodecContext,
+             &OB, &OBSize,
+-            pkt.data, pkt.size,
+-            pkt.pts, pkt.dts, pkt.pos);
++            pkt->data, pkt->size,
++            pkt->pts, pkt->dts, pkt->pos);
+ 
+         // H.264 (PAFF) and HEVC may have one field per packet, so we need to track
+         // when we have a full or half frame available, and mark one of them as
+@@ -351,15 +351,15 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+ 
+         *RepeatPict = VideoContext.Parser->repeat_pict;
+         *FrameType = VideoContext.Parser->pict_type;
+-        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt.flags & AV_PKT_FLAG_DISCARD));
++        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt->flags & AV_PKT_FLAG_DISCARD));
+     } else {
+-        *Invisible = !!(pkt.flags & AV_PKT_FLAG_DISCARD);
++        *Invisible = !!(pkt->flags & AV_PKT_FLAG_DISCARD);
+     }
+ 
+     if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP8)
+-        ParseVP8(pkt.data[0], Invisible, FrameType);
++        ParseVP8(pkt->data[0], Invisible, FrameType);
+     else if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP9)
+-        ParseVP9(pkt.data[0], Invisible, FrameType);
++        ParseVP9(pkt->data[0], Invisible, FrameType);
+ }
+ 
+ void FFMS_Indexer::Free() {
+@@ -458,32 +458,36 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+         }
+     }
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
+     std::vector<int64_t> LastValidTS(FormatContext->nb_streams, AV_NOPTS_VALUE);
+ 
+     int64_t filesize = avio_size(FormatContext->pb);
+     enum AVPictureStructure LastPicStruct = AV_PICTURE_STRUCTURE_UNKNOWN;
+-    while (av_read_frame(FormatContext, &Packet) >= 0) {
++    while (av_read_frame(FormatContext, Packet) >= 0) {
+         // Update progress
+         // FormatContext->pb can apparently be NULL when opening images.
+         if (IC && FormatContext->pb) {
+-            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate))
++            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate)) {
++                av_packet_free(&Packet);
+                 throw FFMS_Exception(FFMS_ERROR_CANCELLED, FFMS_ERROR_USER,
+                     "Cancelled by user");
++            }
+         }
+-        if (!IndexMask.count(Packet.stream_index)) {
+-            av_packet_unref(&Packet);
++        if (!IndexMask.count(Packet->stream_index)) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+-        int Track = Packet.stream_index;
++        int Track = Packet->stream_index;
+         FFMS_Track &TrackInfo = (*TrackIndices)[Track];
+-        bool KeyFrame = !!(Packet.flags & AV_PKT_FLAG_KEY);
++        bool KeyFrame = !!(Packet->flags & AV_PKT_FLAG_KEY);
+         ReadTS(Packet, LastValidTS[Track], (*TrackIndices)[Track].UseDTS);
+ 
+         if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            int64_t PTS = TrackInfo.UseDTS ? Packet.dts : Packet.pts;
++            int64_t PTS = TrackInfo.UseDTS ? Packet->dts : Packet->pts;
+             if (PTS == AV_NOPTS_VALUE) {
+                 // VPx alt-refs are output as packets which lack timestmps or durations, since
+                 // they are invisible. Currently, the timestamp mangling code in libavformat
+@@ -495,9 +499,11 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 // FFMS2 currently sorts packets by PTS, which will break decoding, otherwise.
+                 bool HasAltRefs = (FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP8 ||
+                                    FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP9);
+-                if (Packet.duration == 0 && !HasAltRefs)
++                if (Packet->duration == 0 && !HasAltRefs) {
++                    av_packet_free(&Packet);
+                     throw FFMS_Exception(FFMS_ERROR_INDEXING, FFMS_ERROR_PARSER,
+                         "Invalid packet pts, dts, and duration");
++                }
+ 
+                 if (TrackInfo.empty())
+                     PTS = 0;
+@@ -513,7 +519,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             ParseVideoPacket(AVContexts[Track], Packet, &RepeatPict, &FrameType, &Invisible, &LastPicStruct);
+ 
+             TrackInfo.AddVideoFrame(PTS, RepeatPict, KeyFrame,
+-                FrameType, Packet.pos, Invisible);
++                FrameType, Packet->pos, Invisible);
+         } else if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+             // For video seeking timestamps are used only if all packets have
+             // timestamps, while for audio they're used if any have timestamps,
+@@ -522,28 +528,29 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 TrackInfo.HasTS = true;
+ 
+             int64_t StartSample = AVContexts[Track].CurrentSample;
+-            uint32_t SampleCount = IndexAudioPacket(Track, &Packet, AVContexts[Track], *TrackIndices);
++            uint32_t SampleCount = IndexAudioPacket(Track, Packet, AVContexts[Track], *TrackIndices);
+             TrackInfo.SampleRate = AVContexts[Track].CodecContext->sample_rate;
+ 
+             TrackInfo.AddAudioFrame(LastValidTS[Track],
+-                StartSample, SampleCount, KeyFrame, Packet.pos, Packet.flags & AV_PKT_FLAG_DISCARD);
++                StartSample, SampleCount, KeyFrame, Packet->pos, Packet->flags & AV_PKT_FLAG_DISCARD);
+         }
+ 
+-        if (!(Packet.flags & AV_PKT_FLAG_DISCARD))
+-            TrackInfo.LastDuration = Packet.duration;
++        if (!(Packet->flags & AV_PKT_FLAG_DISCARD))
++            TrackInfo.LastDuration = Packet->duration;
+ 
+-        av_packet_unref(&Packet);
++        av_packet_unref(Packet);
+     }
++    av_packet_free(&Packet);
+ 
+     TrackIndices->Finalize(AVContexts, FormatContext->iformat->name);
+     return TrackIndices.release();
+ }
+ 
+-void FFMS_Indexer::ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS) {
+-    if (!UseDTS && Packet.pts != AV_NOPTS_VALUE)
+-        TS = Packet.pts;
++void FFMS_Indexer::ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS) {
++    if (!UseDTS && Packet->pts != AV_NOPTS_VALUE)
++        TS = Packet->pts;
+     if (TS == AV_NOPTS_VALUE)
+         UseDTS = true;
+-    if (UseDTS && Packet.dts != AV_NOPTS_VALUE)
+-        TS = Packet.dts;
++    if (UseDTS && Packet->dts != AV_NOPTS_VALUE)
++        TS = Packet->dts;
+ }
+diff --git a/src/core/indexing.h b/src/core/indexing.h
+index 3cfc3c3..5c06868 100644
+--- a/src/core/indexing.h
++++ b/src/core/indexing.h
+@@ -80,10 +80,10 @@ private:
+     int64_t Filesize;
+     uint8_t Digest[20];
+ 
+-    void ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS);
++    void ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS);
+     void CheckAudioProperties(int Track, AVCodecContext *Context);
+     uint32_t IndexAudioPacket(int Track, AVPacket *Packet, SharedAVContext &Context, FFMS_Index &TrackIndices);
+-    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
++    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
+     void Free();
+ public:
+     FFMS_Indexer(const char *Filename);
+diff --git a/src/core/utils.cpp b/src/core/utils.cpp
+index ce67533..8a2e997 100644
+--- a/src/core/utils.cpp
++++ b/src/core/utils.cpp
+@@ -62,12 +62,6 @@ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo) {
+     }
+ }
+ 
+-void InitNullPacket(AVPacket &pkt) {
+-    av_init_packet(&pkt);
+-    pkt.data = nullptr;
+-    pkt.size = 0;
+-}
+-
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames) {
+     AP.SampleFormat = static_cast<FFMS_SampleFormat>(av_get_packed_sample_fmt(CTX->sample_fmt));
+     AP.BitsPerSample = av_get_bytes_per_sample(CTX->sample_fmt) * 8;
+diff --git a/src/core/utils.h b/src/core/utils.h
+index 9819dc7..003ab79 100644
+--- a/src/core/utils.h
++++ b/src/core/utils.h
+@@ -58,7 +58,6 @@ std::unique_ptr<T> make_unique(Args&&... args) {
+ }
+ 
+ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo);
+-void InitNullPacket(AVPacket &pkt);
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames);
+ 
+ void LAVFOpenFile(const char *SourceFile, AVFormatContext *&FormatContext, int Track);
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index 06bd161..b889970 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -673,30 +673,34 @@ void FFMS_VideoSource::DecodeNextFrame(int64_t &AStartTime, int64_t &Pos) {
+     if (HasPendingDelayedFrames())
+         return;
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
+-
+-    while (ReadFrame(&Packet) >= 0) {
+-        if (Packet.stream_index != VideoTrack) {
+-            av_packet_unref(&Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++
++    while (ReadFrame(Packet) >= 0) {
++        if (Packet->stream_index != VideoTrack) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+         if (AStartTime < 0)
+-            AStartTime = Frames.UseDTS ? Packet.dts : Packet.pts;
++            AStartTime = Frames.UseDTS ? Packet->dts : Packet->pts;
+ 
+         if (Pos < 0)
+-            Pos = Packet.pos;
++            Pos = Packet->pos;
+ 
+-        bool FrameFinished = DecodePacket(&Packet);
+-        av_packet_unref(&Packet);
+-        if (FrameFinished)
++        bool FrameFinished = DecodePacket(Packet);
++        av_packet_unref(Packet);
++        if (FrameFinished) {
++            av_packet_free(&Packet);
+             return;
++        }
+     }
+ 
+     // Flush final frames
+-    InitNullPacket(Packet);
+-    DecodePacket(&Packet);
++    DecodePacket(Packet);
++    av_packet_free(&Packet);
+ }
+ 
+ bool FFMS_VideoSource::SeekTo(int n, int SeekOffset) {
+-- 
+2.40.0
+
+From bf9e03e9e08534c024e5a744a6437c4aac160201 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:20:47 +0100
+Subject: [PATCH 2/3] configure: Remove deprecated API use
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ configure.ac | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index b35ef80bc..d19714d0f 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -102,10 +102,10 @@ CFLAGS="$_CFLAGS $FFMPEG_CFLAGS"
+
+ AC_DEFUN([TEST_FFMPEG],
+          [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+-            #include <libavcodec/avcodec.h>
++            #include <libavformat/avformat.h>
+             #include <libswscale/swscale.h>
+             ]],[[
+-                avcodec_register_all();
++                avformat_network_init();
+                 swscale_version();
+             ]])], [eval $1=yes], [eval $1=no])
+         ])
+
diff --git a/srcpkgs/ffms2/template b/srcpkgs/ffms2/template
index 365f64d10cbab..1641ecf43be5b 100644
--- a/srcpkgs/ffms2/template
+++ b/srcpkgs/ffms2/template
@@ -1,7 +1,7 @@
 # Template file for 'ffms2'
 pkgname=ffms2
 version=2.40
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-shared --disable-static"
 hostmakedepends="pkg-config autoconf automake libtool"

From a54c1de90930600c70105483972604e3c4f46fed Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 031/115] freerdp: revbump for ffmpeg-6.0

---
 .../freerdp/patches/ffmpeg6_aa2cb9aa.patch    | 42 +++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100644 srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch

diff --git a/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
new file mode 100644
index 0000000000000..a4324da3a8822
--- /dev/null
+++ b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
@@ -0,0 +1,42 @@
+From aa2cb9aa5ff5562433598ba168a466e0752bca0e Mon Sep 17 00:00:00 2001
+From: akallabeth <akallabeth@posteo.net>
+Date: Tue, 14 Feb 2023 07:48:54 +0100
+Subject: [PATCH] Fixed #8686: Update h264 to use new FFMPEG API
+
+---
+ channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c | 2 ++
+ libfreerdp/codec/h264_ffmpeg.c            | 2 ++
+ 2 files changed, 4 insertions(+)
+
+diff --git a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+index 339462d865f..beea80b7a1e 100644
+--- a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
++++ b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+@@ -239,8 +239,10 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYP
+ 		}
+ 	}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 	if (mdecoder->codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		mdecoder->codec_context->flags |= AV_CODEC_FLAG_TRUNCATED;
++#endif
+ 
+ 	return TRUE;
+ }
+diff --git a/libfreerdp/codec/h264_ffmpeg.c b/libfreerdp/codec/h264_ffmpeg.c
+index 8a23db2473c..896a333019b 100644
+--- a/libfreerdp/codec/h264_ffmpeg.c
++++ b/libfreerdp/codec/h264_ffmpeg.c
+@@ -615,10 +615,12 @@ static BOOL libavcodec_init(H264_CONTEXT* h264)
+ 			goto EXCEPTION;
+ 		}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 		if (sys->codecDecoder->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		{
+ 			sys->codecDecoderContext->flags |= AV_CODEC_FLAG_TRUNCATED;
+ 		}
++#endif
+ 
+ #ifdef WITH_VAAPI
+ 

From d8fb249473e71df800176086ce0abd10cf842c50 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 032/115] gerbera: revbump for ffmpeg-6.0

---
 srcpkgs/gerbera/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gerbera/template b/srcpkgs/gerbera/template
index ae14f35c767c0..2dc0ac0ce03b5 100644
--- a/srcpkgs/gerbera/template
+++ b/srcpkgs/gerbera/template
@@ -1,7 +1,7 @@
 # Template file for 'gerbera'
 pkgname=gerbera
 version=1.12.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_SYSTEMD=0 -DWITH_AVCODEC=1"
 hostmakedepends="pkg-config"

From f9db4bc59c7c4c7a483a1066d87628aacdd03113 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 033/115] goldendict: revbump for ffmpeg-6.0

---
 srcpkgs/goldendict/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/goldendict/template b/srcpkgs/goldendict/template
index f4a05759f693d..97f44347b03a6 100644
--- a/srcpkgs/goldendict/template
+++ b/srcpkgs/goldendict/template
@@ -1,7 +1,7 @@
 # Template file for 'goldendict'
 pkgname=goldendict
 version=1.5.0
-revision=1
+revision=2
 build_style=qmake
 configure_args="CONFIG+=zim_support goldendict.pro"
 hostmakedepends="qt5-qmake pkg-config qt5-host-tools"
@@ -10,7 +10,7 @@ makedepends="tiff-devel qt5-devel libvorbis-devel zlib-devel
  qt5-webkit-devel lzo-devel bzip2-devel libao-devel qt5-svg-devel
  libeb-devel qt5-x11extras-devel ffmpeg-devel liblzma-devel
  qt5-multimedia-devel"
-short_desc="A feature-rich dictionary lookup program"
+short_desc="Feature-rich dictionary lookup program"
 maintainer="John <me@johnnynator.dev>"
 license="GPL-3.0-or-later"
 homepage="http://goldendict.org/"

From 2f5d54d019ffb2bbd95c2ef2cf4c142fb304045c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 034/115] gst-libav: revbump for ffmpeg-6.0

---
 srcpkgs/gst-libav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index 37485f6f6a9e8..f610e966f23cd 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.22.5
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"

From 5f52683ad61d809ae64886248c934908ed56cc23 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 035/115] gst-rtsp-server: revbump for ffmpeg-6.0

---
 srcpkgs/gst-rtsp-server/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index f266f4777b3ea..011444eb26739 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
 version=1.22.5
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="glib-devel gst-plugins-bad1-devel gobject-introspection

From 12c544d4e023a1ac7f16ce82e4fb5587718e0f3f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 036/115] guvcview: update to 2.0.8.

---
 srcpkgs/guvcview/patches/fix-include.patch | 10 ++++++++++
 srcpkgs/guvcview/template                  |  7 +++----
 2 files changed, 13 insertions(+), 4 deletions(-)
 create mode 100644 srcpkgs/guvcview/patches/fix-include.patch

diff --git a/srcpkgs/guvcview/patches/fix-include.patch b/srcpkgs/guvcview/patches/fix-include.patch
new file mode 100644
index 0000000000000..503c2af3b78c1
--- /dev/null
+++ b/srcpkgs/guvcview/patches/fix-include.patch
@@ -0,0 +1,10 @@
+--- a/guvcview/guvcview.c
++++ b/guvcview/guvcview.c
+@@ -28,6 +28,7 @@
+ #include <sys/stat.h>
+ #include <sys/resource.h>
+ #include <errno.h>
++#include <locale.h>
+ 
+ #include "gview.h"
+ #include "gviewv4l2core.h"
diff --git a/srcpkgs/guvcview/template b/srcpkgs/guvcview/template
index d42fd38fa4ad1..86a7fd619612c 100644
--- a/srcpkgs/guvcview/template
+++ b/srcpkgs/guvcview/template
@@ -1,8 +1,7 @@
 # Template file for 'guvcview'
 pkgname=guvcview
-version=2.0.7
-revision=2
-create_wrksrc=yes
+version=2.0.8
+revision=1
 build_style=gnu-configure
 configure_args="--disable-static --disable-debian-menu"
 hostmakedepends="pkg-config intltool autoconf automake libtool glib-devel"
@@ -14,7 +13,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="http://guvcview.sourceforge.net/"
 distfiles="${SOURCEFORGE_SITE}/${pkgname}/${pkgname}-src-${version}.tar.bz2"
-checksum=f47d51fbd06e44eeaa1a82f4a153c927527c90d94514197a70b2956028cc8ad4
+checksum=a21f4e448286666cf27bafef5290cc953a0a1796b752e5bbe521266dc1230c81
 
 post_patch() {
 	sed '31a#include <locale.h>' -i  guvcview/guvcview.c

From 711fb620326ce5842df1e5d5e3225bef36342b08 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 037/115] handbrake: update to 1.6.1

---
 .../patches/fix-missing-x265-link-flag.patch    | 11 ++++++-----
 .../handbrake/patches/libhb-vpl-include.patch   | 15 +++++++++++++++
 srcpkgs/handbrake/template                      | 17 ++++++++++-------
 3 files changed, 31 insertions(+), 12 deletions(-)
 create mode 100644 srcpkgs/handbrake/patches/libhb-vpl-include.patch

diff --git a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
index 26db03867a0c8..d6bb2eda627a3 100644
--- a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
+++ b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
@@ -1,14 +1,15 @@
 --- a/gtk/configure.ac
 +++ b/gtk/configure.ac
 @@ -203,7 +203,7 @@
- 
+
  AM_CONDITIONAL([MINGW], [test "x$mingw_flag" = "xyes"])
- 
--HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg"
-+HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -ldl"
+
+-HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc"
++HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc -ldl"
  HB_CPPFLAGS="$HB_CPPFLAGS $HBINC"
- 
+
  PKG_CHECK_MODULES([x264], [x264], sys_x264=yes, sys_x264=no)
+
 --- a/test/module.defs
 +++ b/test/module.defs
 @@ -69,6 +69,9 @@
diff --git a/srcpkgs/handbrake/patches/libhb-vpl-include.patch b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
new file mode 100644
index 0000000000000..298f9f4ab28f2
--- /dev/null
+++ b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
@@ -0,0 +1,15 @@
+--- a/libhb/module.defs	2023-01-22 11:36:49.000000000 -0500
++++ b/libhb/module.defs	2023-04-03 22:37:52.395467010 -0400
+@@ -46,11 +46,7 @@
+ LIBHB.GCC.I += $(LIBHB.build/) $(CONTRIB.build/)include
+ 
+ ifeq (1,$(FEATURE.qsv))
+-    ifeq ($(HOST.system),freebsd))
+-        LIBHB.GCC.I += $(LOCALBASE)/include/vpl
+-    else
+-        LIBHB.GCC.I += $(CONTRIB.build/)include/vpl
+-    endif
++    LIBHB.GCC.I += /usr/include/vpl
+ endif
+ 
+ ifneq (,$(filter $(HOST.system),freebsd netbsd openbsd))
diff --git a/srcpkgs/handbrake/template b/srcpkgs/handbrake/template
index ca5e4571e49c3..c32cb1bfa31f4 100644
--- a/srcpkgs/handbrake/template
+++ b/srcpkgs/handbrake/template
@@ -1,10 +1,10 @@
 # Template file for 'handbrake'
 pkgname=handbrake
-version=1.5.1
+version=1.6.1
 revision=1
 build_style=gnu-configure
 configure_args="--force --disable-gtk-update-checks --disable-df-fetch --harden
- $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc)"
+ $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc) $(vopt_enable qsv)"
 make_build_args="-C ${XBPS_TRIPLET}"
 make_install_args="-C ${XBPS_TRIPLET}"
 hostmakedepends="automake cmake gettext-devel glib-devel intltool libtool m4 meson nasm pkg-config python3"
@@ -12,8 +12,11 @@ makedepends="bzip2-devel ffmpeg-devel gst-plugins-base1-devel gtk+3-devel
  jansson-devel lame-devel libass-devel libbluray-devel libdav1d-devel
  libdvdnav-devel libdvdread-devel libgudev-devel libnuma-devel
  libsamplerate-devel libtheora-devel libvorbis-devel libvpx-devel libxml2-devel
- opus-devel speex-devel x264-devel x265-devel zimg-devel
+ opus-devel speex-devel x264-devel x265-devel zimg-devel libsvt-av1-devel
  $(vopt_if fdk_aac fdk-aac-devel)
+ $(vopt_if qsv libva-devel)
+ $(vopt_if qsv libdrm-devel)
+ $(vopt_if qsv onevpl-devel)
  $(vopt_if nvenc nv-codec-headers)"
 depends="desktop-file-utils gst-plugins-good1 hicolor-icon-theme"
 short_desc="Multithreaded video transcoder"
@@ -21,15 +24,15 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-2.0-only"
 homepage="https://handbrake.fr/"
 distfiles="https://github.com/HandBrake/HandBrake/releases/download/${version}/HandBrake-${version}-source.tar.bz2"
-checksum=3999fe06d5309c819799a73a968a8ec3840e7840c2b64af8f5cdb7fd8c9430f0
+checksum=94ccfe03db917a91650000c510f7fd53f844da19f19ad4b4be1b8f6bc31a8d4c
 nocross=yes
 
-build_options="fdk_aac nvenc"
+build_options="fdk_aac nvenc qsv"
 
 case "$XBPS_TARGET_MACHINE" in
 	x86_64*|i686*)
 		CFLAGS="-msse"
-		build_options_default="nvenc"
+		build_options_default="nvenc qsv"
 		;;
 esac
 
@@ -37,7 +40,7 @@ pre_configure() {
 	# use system libraries, don't download them
 	rm -rf contrib/
 	for module in fdk-aac ffmpeg libbluray libdav1d libdvdnav libdvdread nvenc \
-		x265 zimg; do
+		x265 zimg svt-av1 libvpl; do
 	    vsed -i "/MODULES += contrib\/${module}/d" make/include/main.defs
 	done
 }

From c2baa8aaa8b82e7de6cd9af8cb3bfda03a11f53b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 038/115] hedgewars: revbump for ffmpeg4-4.4.3

---
 srcpkgs/hedgewars/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/hedgewars/template b/srcpkgs/hedgewars/template
index 15a1df6d8861d..d1b7290bfdc19 100644
--- a/srcpkgs/hedgewars/template
+++ b/srcpkgs/hedgewars/template
@@ -1,13 +1,13 @@
 # Template file for 'hedgewars'
 pkgname=hedgewars
 version=1.0.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DNOSERVER=1 -DDATA_INSTALL_DIR=/usr/share/${pkgname}
  -DPHYSFS_SYSTEM=1 -DMINIMAL_FLAGS=1"
 make_cmd=make
 hostmakedepends="lua51 pkg-config qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
+makedepends="ffmpeg4-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
  SDL2_mixer-devel SDL2_net-devel SDL2_ttf-devel"
 depends="libfreeglut"
 short_desc="Funny turn-based artillery game, featuring fighting Hedgehogs!"

From 2e9eafec6ae674621206b22aabb2b3c5a7cc6a72 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 039/115] idjc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/idjc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/idjc/template b/srcpkgs/idjc/template
index a9cde0665d55b..6f1d21c5781fd 100644
--- a/srcpkgs/idjc/template
+++ b/srcpkgs/idjc/template
@@ -5,7 +5,7 @@ revision=5
 build_style=gnu-configure
 hostmakedepends="pkg-config git python3 automake gettext-devel libtool"
 makedepends="libvorbis-devel libogg-devel jack-devel libsamplerate-devel
- libflac-devel libsndfile-devel mpg123-devel ffmpeg-devel speex-devel
+ libflac-devel libsndfile-devel mpg123-devel ffmpeg4-devel speex-devel
  glib-devel pixman-devel lame-devel python3-gobject-devel libshout-idjc-devel
  opus-devel twolame-devel python3-mutagen python3-devel"
 depends="python3-gobject python3-mutagen desktop-file-utils shared-mime-info python3-dbus jack"

From 780a893f7a9ebd1c2020847fe9dbc81e6cc5e067 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 040/115] kid3: revbump for ffmpeg-6.0

---
 srcpkgs/kid3/patches/ffmpeg5.patch | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 srcpkgs/kid3/patches/ffmpeg5.patch

diff --git a/srcpkgs/kid3/patches/ffmpeg5.patch b/srcpkgs/kid3/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..135fc50e07c9b
--- /dev/null
+++ b/srcpkgs/kid3/patches/ffmpeg5.patch
@@ -0,0 +1,17 @@
+# https://aur.archlinux.org/cgit/aur.git/diff/ffmpeg5.patch?h=kid3-cli&id=12410a74906612e7efc0ec8fbce739b4a0fef7e7
+diff --git a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+index e156d424..e12b9abd 100644
+--- a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
++++ b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+@@ -232,7 +232,11 @@ private:
+   friend class Format;
+   friend class Converter;
+   AVCodecContext* m_ptr;
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 0, 0)
+   AVCodec* m_impl;
++#else
++  const AVCodec* m_impl;
++#endif
+   AVFrame* m_frame;
+   bool m_opened;
+ };

From 83cec06b2b67e65d67a8d9682ee79aa53bc30cf7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 041/115] kodi: revbump for ffmpeg4-4.4.3

---
 srcpkgs/kodi/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kodi/template b/srcpkgs/kodi/template
index aa59324258a0d..6cf64dfb27294 100644
--- a/srcpkgs/kodi/template
+++ b/srcpkgs/kodi/template
@@ -54,7 +54,7 @@ makedepends="
  libmad-devel fontconfig-devel libXinerama-devel libsamplerate-devel libmms-devel
  enca-devel boost-devel libcurl-devel libva-devel libvdpau-devel libass-devel
  libbluetooth-devel yajl-devel libplist-devel librtmp-devel tinyxml-devel
- taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg-devel
+ taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg4-devel
  giflib-devel libxslt-devel gnutls-devel libssh-devel libmicrohttpd-devel
  libcec-devel dcadec-devel flatbuffers-devel fmt-devel lcms2-devel
  libfstrcmp-devel rapidjson libcdio-paranoia spdlog libwaylandpp-devel

From de0f69036188abc7026aaa49f5647e763f98d138 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 042/115] kpipewire: revbump for ffmpeg-6.0

---
 srcpkgs/kpipewire/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kpipewire/template b/srcpkgs/kpipewire/template
index b2d3d80c1dd1a..981c7b8890ded 100644
--- a/srcpkgs/kpipewire/template
+++ b/srcpkgs/kpipewire/template
@@ -1,7 +1,7 @@
 # Template file for 'kpipewire'
 pkgname=kpipewire
 version=5.27.9
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules plasma-wayland-protocols gettext
  qt5-qmake qt5-host-tools pkg-config wayland-devel kcoreaddons

From 66c702e4207c7e79ad6cea759b9a26036b6e7e13 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 043/115] libextractor: revbump for ffmpeg4-4.4.3

---
 srcpkgs/libextractor/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libextractor/template b/srcpkgs/libextractor/template
index 044c663a3a0b9..ace88ae128da5 100644
--- a/srcpkgs/libextractor/template
+++ b/srcpkgs/libextractor/template
@@ -7,7 +7,7 @@ configure_args="--disable-static"
 hostmakedepends="pkg-config"
 makedepends="zlib-devel bzip2-devel exiv2-devel tiff-devel libpng-devel
  libjpeg-turbo-devel libvorbis-devel libflac-devel giflib-devel libmpeg2-devel
- ffmpeg-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
+ ffmpeg4-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
 short_desc="Library used to extract meta data from files"
 maintainer="Martin Riese <grauehaare@gmx.de>"
 license="GPL-3.0-or-later"

From 9786290f2af5dcd3a983cd70f9ab003c459808c4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 044/115] libopenal: revbump for ffmpeg-6.0

---
 srcpkgs/libopenal/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenal/template b/srcpkgs/libopenal/template
index 77218f9e539df..3f49ed75a1fdc 100644
--- a/srcpkgs/libopenal/template
+++ b/srcpkgs/libopenal/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenal'
 pkgname=libopenal
 version=1.22.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DALSOFT_EXAMPLES=OFF"
 hostmakedepends="pkg-config"

From afe187fab8d0e8be0d6622255e39bbd1b91ee1de Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 045/115] loudgain: revbump for ffmpeg-6.0

---
 srcpkgs/loudgain/patches/ffmpeg5.patch | 11 +++++++++++
 srcpkgs/loudgain/template              |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/loudgain/patches/ffmpeg5.patch

diff --git a/srcpkgs/loudgain/patches/ffmpeg5.patch b/srcpkgs/loudgain/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..16d4510ee98fa
--- /dev/null
+++ b/srcpkgs/loudgain/patches/ffmpeg5.patch
@@ -0,0 +1,11 @@
+--- a/src/scan.c	2019-09-06 11:31:19.000000000 -0400
++++ b/src/scan.c	2023-03-23 11:15:40.867968521 -0400
+@@ -69,8 +69,6 @@
+ 	 * It is now useless
+ 	 * https://github.com/FFmpeg/FFmpeg/blob/70d25268c21cbee5f08304da95be1f647c630c15/doc/APIchanges#L86
+ 	 */
+-  if (avformat_version() < AV_VERSION_INT(58,9,100))
+-    av_register_all();
+ 
+ 	av_log_set_callback(scan_av_log);
+ 
diff --git a/srcpkgs/loudgain/template b/srcpkgs/loudgain/template
index da4f2d56e94c3..4d6bf29efb4fd 100644
--- a/srcpkgs/loudgain/template
+++ b/srcpkgs/loudgain/template
@@ -1,7 +1,7 @@
 # Template file for 'loudgain'
 pkgname=loudgain
 version=0.6.8
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libebur128-devel taglib-devel ffmpeg-devel"

From 033c41eefcc2e1ae1e2a07f16216e90d8200ca6a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 046/115] mediastreamer: revbump for ffmpeg4-4.4.3

---
 srcpkgs/mediastreamer/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mediastreamer/template b/srcpkgs/mediastreamer/template
index 0fcffa7653d18..92ada88743a9b 100644
--- a/srcpkgs/mediastreamer/template
+++ b/srcpkgs/mediastreamer/template
@@ -5,7 +5,7 @@ revision=2
 build_style=cmake
 configure_args="-DENABLE_STRICT=0 -DENABLE_UNIT_TESTS=0"
 hostmakedepends="python3"
-makedepends="bzrtp-devel ffmpeg-devel glew-devel libXv-devel libsrtp-devel
+makedepends="bzrtp-devel ffmpeg4-devel glew-devel libXv-devel libsrtp-devel
  libupnp-devel libvpx-devel mbedtls-devel opus-devel ortp-devel pulseaudio-devel
  libtheora-devel speex-devel v4l-utils-devel bcg729-devel bcmatroska2-devel libgsm-devel
  zxing-cpp-devel"

From 0d6aa09a3b246dc9bff560cc07eb0d9fedcd0b5f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 047/115] mgba: revbump for ffmpeg-6.0

---
 srcpkgs/mgba/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mgba/template b/srcpkgs/mgba/template
index 5513e3fd16f3f..f5c87a4893002 100644
--- a/srcpkgs/mgba/template
+++ b/srcpkgs/mgba/template
@@ -1,7 +1,7 @@
 # Template file for 'mgba'
 pkgname=mgba
 version=0.10.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake desktop-file-utils"
 makedepends="SDL2-devel ffmpeg-devel libedit-devel libepoxy-devel libmagick-devel

From a1c8cea459f1ca7ff497fd21bfcd8a28dca0eeca Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 048/115] mlt: revbump for ffmpeg4-4.4.3

---
 srcpkgs/mlt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mlt/template b/srcpkgs/mlt/template
index 73e3915aaab9a..ec5054be3b75e 100644
--- a/srcpkgs/mlt/template
+++ b/srcpkgs/mlt/template
@@ -8,7 +8,7 @@ configure_args="--prefix=/usr --libdir=/usr/lib$XBPS_TARGET_WORDSIZE
  --swig-languages=python"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which"
 # XXX: movit vid.stab
-makedepends="alsa-lib-devel ffmpeg-devel gtk+-devel jack-devel ladspa-sdk
+makedepends="alsa-lib-devel ffmpeg4-devel gtk+-devel jack-devel ladspa-sdk
  libexif-devel libsamplerate-devel libxml2-devel sox-devel SDL_image-devel
  fftw-devel frei0r-plugins python3-devel pulseaudio-devel movit-devel
  libvidstab-devel"

From 148e114f95cddd6ec3e0c2e7d73d805bc033a349 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 049/115] moc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/moc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/moc/template b/srcpkgs/moc/template
index 3a04932c8f1e6..d8de816026b64 100644
--- a/srcpkgs/moc/template
+++ b/srcpkgs/moc/template
@@ -4,7 +4,7 @@ version=2.5.2
 revision=7
 build_style=gnu-configure
 hostmakedepends="pkg-config"
-makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg-devel
+makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg4-devel
  jack-devel alsa-lib-devel libltdl-devel libflac-devel libvorbis-devel
  libmad-devel libmpcdec-devel libmodplug-devel libid3tag-devel faad2-devel
  taglib-devel libsndfile-devel wavpack-devel speex-devel libsamplerate-devel

From dec97bf2bf9e1e8b3b3777171fc1df0e252fb778 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 050/115] motion: revbump for ffmpeg-6.0

---
 srcpkgs/motion/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/motion/template b/srcpkgs/motion/template
index 607ebeb3c7b24..bf63a91d9764f 100644
--- a/srcpkgs/motion/template
+++ b/srcpkgs/motion/template
@@ -1,7 +1,7 @@
 # Template file for 'motion'
 pkgname=motion
 version=4.6.0
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake pkg-config gettext-devel tar"
 makedepends="ffmpeg-devel libmicrohttpd-devel v4l-utils-devel gettext-devel"

From e5eba91d36fc30b0a26cfa57dbab56e228a45146 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 051/115] notcurses: revbump for ffmpeg-6.0

---
 srcpkgs/notcurses/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/notcurses/template b/srcpkgs/notcurses/template
index 6dd8a091319f7..3110c30c9aff2 100644
--- a/srcpkgs/notcurses/template
+++ b/srcpkgs/notcurses/template
@@ -1,7 +1,7 @@
 # Template file for 'notcurses'
 pkgname=notcurses
 version=3.0.9
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DUSE_STATIC=ON $(vopt_bool man USE_PANDOC)"
 hostmakedepends="pkg-config $(vopt_if man pandoc)"

From 969ebe227d9e56f1785e9f0e41e78b8b5b80834a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 052/115] olive: revbump for ffmpeg4-4.4.3

---
 srcpkgs/olive/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/olive/template b/srcpkgs/olive/template
index 12a46936c9900..5c2917b9c5124 100644
--- a/srcpkgs/olive/template
+++ b/srcpkgs/olive/template
@@ -1,10 +1,10 @@
 # Template file for 'olive'
 pkgname=olive
 version=0.1.2
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools pkg-config"
-makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg-devel frei0r-plugins"
+makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg4-devel frei0r-plugins"
 short_desc="Non-linear video editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"

From 3afc8d8f113c8e3b7441ab3496d3fcbec084f275 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 053/115] omxplayer: revbump for ffmpeg4-4.4.3

---
 srcpkgs/omxplayer/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/omxplayer/template b/srcpkgs/omxplayer/template
index 9a66690c83ebb..a21b878878037 100644
--- a/srcpkgs/omxplayer/template
+++ b/srcpkgs/omxplayer/template
@@ -1,7 +1,7 @@
 # Template file for 'omxplayer'
 pkgname=omxplayer
 version=20190102
-revision=2
+revision=3
 short_desc="Commandline OMX player for the Raspberry Pi"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
@@ -15,7 +15,7 @@ checksum=af2d9450f8947842ea8c401fe9f71eec444013ebbdee29f2ac828c9c493c1329
 archs="armv6l* armv7l*"
 build_style=gnu-makefile
 hostmakedepends="ruby-ronn pkg-config"
-makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg-devel dbus-devel"
+makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg4-devel dbus-devel"
 depends="freefont-ttf"
 
 do_build() {

From cf2fa4f154d61dd867aded6009748f9356493d85 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 054/115] opentoonz: revbump for ffmpeg-6.0

---
 srcpkgs/opentoonz/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/opentoonz/template b/srcpkgs/opentoonz/template
index ee9f7603f55fd..3e81834ca0edd 100644
--- a/srcpkgs/opentoonz/template
+++ b/srcpkgs/opentoonz/template
@@ -1,7 +1,7 @@
 # Template file for 'opentoonz'
 pkgname=opentoonz
 version=1.6.0
-revision=2
+revision=3
 build_wrksrc="toonz/sources"
 build_style=cmake
 make_cmd=make

From 40ecde0a2dee4300abd7b99818ae2c0a47a7e655 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 055/115] pianobar: revbump for ffmpeg-6.0

---
 srcpkgs/pianobar/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pianobar/template b/srcpkgs/pianobar/template
index e3febb821a451..1e3dc1bf9308e 100644
--- a/srcpkgs/pianobar/template
+++ b/srcpkgs/pianobar/template
@@ -1,7 +1,7 @@
 # Template file for 'pianobar'
 pkgname=pianobar
 version=2022.04.01
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="V=1"
 hostmakedepends="pkg-config"

From 72afae0cb38702b52861488ae8e795379339ab84 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 056/115] ppsspp: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ppsspp/template | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/ppsspp/template b/srcpkgs/ppsspp/template
index 2c0ded496eb98..1294ef3ae669c 100644
--- a/srcpkgs/ppsspp/template
+++ b/srcpkgs/ppsspp/template
@@ -1,7 +1,7 @@
 # Template file for 'ppsspp'
 pkgname=ppsspp
 version=1.16.6
-revision=1
+revision=2
 _glslang_commit=b34f619e1c85810dcb3c578107d2e48ba4ee2b37
 _SPIRV_Cross_commit=4212eef67ed0ca048cb726a6767185504e7695e5
 _armips_commit=7bd1ec93d4586985ba1ef420b43b5e620f68695e
@@ -15,7 +15,7 @@ configure_args="-DHEADLESS=1 -DUSE_SYSTEM_FFMPEG=1 -DUNITTEST=ON
  -DUSING_QT_UI=$(vopt_if qt ON OFF) -DUSE_SYSTEM_ZSTD=ON
  -DARMIPS_USE_STD_FILESYSTEM=ON"
 hostmakedepends="pkg-config python3 $(vopt_if qt qt5-host-tools)"
-makedepends="zlib-devel glew-devel ffmpeg-devel libzip-devel
+makedepends="zlib-devel glew-devel ffmpeg4-devel libzip-devel
  snappy-devel rapidjson libpng-devel libzstd-devel
  $(vopt_if sdl2 'SDL2_ttf-devel SDL2-devel') $(vopt_if wayland wayland-devel)
  $(vopt_if qt 'qt5-devel qt5-multimedia-devel')"
@@ -72,7 +72,7 @@ post_extract() {
         mv ${wrksrc}/rcheevos-${_rcheevos_commit} ${wrksrc}/ext/rcheevos
 }
 
-post_patch(){
+post_patch() {
 	# disable git versioning
 	vsed -e 's|find_package(Git)|# &|' -i git-version.cmake
 }
@@ -85,7 +85,6 @@ post_configure() {
 }
 
 do_install() {
-	vlicense LICENSE.TXT
 	vinstall icons/icon.svg 644 usr/share/pixmaps ppsspp.svg
 	vinstall Qt/PPSSPP.desktop 644 usr/share/applications
 	vbin build/PPSSPPHeadless ppsspp-headless

From 4bff12bce26311f966abf0d337461a0520485a6b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 057/115] pqiv: revbump for ffmpeg-6.0

---
 srcpkgs/pqiv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pqiv/template b/srcpkgs/pqiv/template
index 542fc27a2d32a..9308d949b6a1c 100644
--- a/srcpkgs/pqiv/template
+++ b/srcpkgs/pqiv/template
@@ -1,7 +1,7 @@
 # Template file for 'pqiv'
 pkgname=pqiv
 version=2.12
-revision=1
+revision=2
 build_style=gnu-makefile
 hostmakedepends="pkg-config"
 makedepends="glib-devel gtk+3-devel $(vopt_if ffmpeg ffmpeg-devel)

From fdfbe5dc25e8c3de5c6dc694a7978e78651a0c35 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 058/115] qmmp: revbump for ffmpeg-6.0

---
 srcpkgs/qmmp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qmmp/template b/srcpkgs/qmmp/template
index 53781ea3bc28a..2da07f1e87eac 100644
--- a/srcpkgs/qmmp/template
+++ b/srcpkgs/qmmp/template
@@ -1,7 +1,7 @@
 # Template file for 'qmmp'
 pkgname=qmmp
 version=1.6.1
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DUSE_HAL:BOOL=FALSE -DQMMP_DEFAULT_UI:STRING=simple"
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From 0e15b670c818a789795168e23490d7a71a91fec6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 059/115] qt5-webengine: update to 5.15.15

---
 .../chromium-media-filters-cpp14.patch        |  11 ++
 srcpkgs/qt5-webengine/patches/ffmpeg5.patch   | 179 ++++++++++++++++++
 srcpkgs/qt5-webengine/template                |  10 +-
 3 files changed, 195 insertions(+), 5 deletions(-)
 create mode 100644 srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/ffmpeg5.patch

diff --git a/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
new file mode 100644
index 0000000000000..04adc540f2cbc
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
@@ -0,0 +1,11 @@
+--- a/src/3rdparty/chromium/media/filters/BUILD.gn	2023-02-27 13:32:59.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/BUILD.gn	2023-04-02 17:21:39.204066384 -0400
+@@ -96,6 +96,8 @@
+     "//ui/gfx/geometry:geometry",
+   ]
+ 
++  cflags_cc = [ "-std=c++14" ]
++
+   libs = []
+ 
+   if (proprietary_codecs) {
diff --git a/srcpkgs/qt5-webengine/patches/ffmpeg5.patch b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..ac55e1634423a
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
@@ -0,0 +1,179 @@
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:57.732547446 -0400
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:09.486478995 -0400
+@@ -57,6 +57,8 @@
+ 
+ namespace {
+ 
++constexpr int64_t kRelativeTsBase = static_cast<int64_t>(0x7ffeffffffffffff);
++
+ void SetAVStreamDiscard(AVStream* stream, AVDiscard discard) {
+   DCHECK(stream);
+   stream->discard = discard;
+@@ -90,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+   if (stream->start_time != kNoFFmpegTimestamp)
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (stream->first_dts != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, stream->first_dts);
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -408,11 +398,11 @@
+   scoped_refptr<DecoderBuffer> buffer;
+ 
+   if (type() == DemuxerStream::TEXT) {
+-    int id_size = 0;
++    size_t id_size = 0;
+     uint8_t* id_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
+ 
+-    int settings_size = 0;
++    size_t settings_size = 0;
+     uint8_t* settings_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
+ 
+@@ -424,7 +414,7 @@
+     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
+                                      side_data.data(), side_data.size());
+   } else {
+-    int side_data_size = 0;
++    size_t side_data_size = 0;
+     uint8_t* side_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
+ 
+@@ -485,7 +475,7 @@
+                                        packet->size - data_offset);
+     }
+ 
+-    int skip_samples_size = 0;
++    size_t skip_samples_size = 0;
+     const uint32_t* skip_samples_ptr =
+         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
+             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
+@@ -1587,6 +1577,8 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++      continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+       lowest_start_time_stream = stream.get();
+@@ -1604,6 +1596,8 @@
+     if (stream && stream->type() == DemuxerStream::VIDEO &&
+         stream->IsEnabled()) {
+       video_stream = stream.get();
++      if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++        continue;
+       if (video_stream->start_time() <= seek_time) {
+         return video_stream;
+       }
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h qtwebengine-5.15.10/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h
+--- a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-07-11 22:12:47.917192788 -0500
+@@ -29,6 +29,7 @@ extern "C" {
+ #include <libavformat/avformat.h>
+ #include <libavformat/avio.h>
+ #include <libavutil/avutil.h>
++#include <libavutil/channel_layout.h>
+ #include <libavutil/imgutils.h>
+ #include <libavutil/log.h>
+ #include <libavutil/mastering_display_metadata.h>
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/audio_file_reader.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/audio_file_reader.cc
+--- a/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -85,7 +85,7 @@ bool AudioFileReader::OpenDemuxer() {
+ }
+ 
+ bool AudioFileReader::OpenDecoder() {
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (codec) {
+     // MP3 decodes to S16P which we don't support, tell it to use S16 instead.
+     if (codec_context_->sample_fmt == AV_SAMPLE_FMT_S16P)
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -329,7 +329,7 @@ bool FFmpegAudioDecoder::ConfigureDecode
+     }
+   }
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec ||
+       avcodec_open2(codec_context_.get(), codec, &codec_options) < 0) {
+     DLOG(ERROR) << "Could not initialize audio decoder: "
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -59,7 +59,6 @@ static int64_t AVIOSeekOperation(void* o
+ }
+ 
+ void FFmpegGlue::InitializeFFmpeg() {
+-  av_register_all();
+ }
+ 
+ static void LogContainer(bool is_local_file,
+@@ -95,9 +94,6 @@ FFmpegGlue::FFmpegGlue(FFmpegURLProtocol
+   // Enable fast, but inaccurate seeks for MP3.
+   format_context_->flags |= AVFMT_FLAG_FAST_SEEK;
+ 
+-  // Ensures we can read out various metadata bits like vp8 alpha.
+-  format_context_->flags |= AVFMT_FLAG_KEEP_SIDE_DATA;
+-
+   // Ensures format parsing errors will bail out. From an audit on 11/2017, all
+   // instances were real failures. Solves bugs like http://crbug.com/710791.
+   format_context_->error_recognition |= AV_EF_EXPLODE;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -391,7 +391,7 @@ bool FFmpegVideoDecoder::ConfigureDecode
+   if (decode_nalus_)
+     codec_context_->flags2 |= AV_CODEC_FLAG2_CHUNKS;
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
+     ReleaseFFmpegResources();
+     return false;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/media_file_checker.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/media_file_checker.cc
+--- a/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -68,7 +68,7 @@ bool MediaFileChecker::Start(base::TimeD
+       auto context = AVStreamToAVCodecContext(format_context->streams[i]);
+       if (!context)
+         continue;
+-      AVCodec* codec = avcodec_find_decoder(cp->codec_id);
++      const AVCodec* codec = avcodec_find_decoder(cp->codec_id);
+       if (codec && avcodec_open2(context.get(), codec, nullptr) >= 0) {
+         auto loop = std::make_unique<FFmpegDecodingLoop>(context.get());
+         stream_contexts[i] = {std::move(context), std::move(loop)};
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc qtwebengine-5.15.10/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc
+--- a/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -203,7 +203,7 @@ int32_t H264DecoderImpl::InitDecode(cons
+   // a pointer |this|.
+   av_context_->opaque = this;
+ 
+-  AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
+   if (!codec) {
+     // This is an indication that FFmpeg has not been initialized or it has not
+     // been compiled/initialized with the correct set of codecs.
diff --git a/srcpkgs/qt5-webengine/template b/srcpkgs/qt5-webengine/template
index 84de5b12ecdda..e00807ced9f2b 100644
--- a/srcpkgs/qt5-webengine/template
+++ b/srcpkgs/qt5-webengine/template
@@ -1,9 +1,9 @@
 # Template file for 'qt5-webengine'
 pkgname=qt5-webengine
-version=5.15.11
-revision=5
+version=5.15.15
+revision=1
 _version="${version}-lts"
-_chromium_commit=be349eaf62e77955791d7bf29f893f1e8a37daf4
+_chromium_commit=e48df7803c7c98b0b2471c94057d32e44a301ad5
 archs="x86_64* i686* armv[67]* ppc64* aarch64*"
 create_wrksrc=yes
 build_style=qmake
@@ -32,8 +32,8 @@ license="GPL-3.0-or-later, LGPL-3.0-or-later"
 homepage="https://qt.io/"
 distfiles="https://github.com/qt/qtwebengine/archive/v${_version}.tar.gz
  https://github.com/qt/qtwebengine-chromium/archive/${_chromium_commit}.tar.gz"
-checksum="aa7466356c450c5f5870f979b93cd7e7e62da1165c328ffcab1a9928db18ad67
- 6f47ed8ab8cc062411f6f206da6353bc8263d6ed6d6290c689a05c01d91f646b"
+checksum="1c2a3b6ae39c937068b38e3bd1d5a8f1ed61ea680496fc225e6fd0de11e2af7a
+ a91686562b1d4e8b220e0bbcbab5feb64630e2de974b35ac034bf388af771a6c"
 
 no_generic_pkgconfig_link=yes
 build_options="sndio pipewire"

From b12a7ff1e0943e6305d61abd8dd85001e442a373 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 060/115] qt5: update to 5.15.8

---
 ...erywhere-opensource-src-5.15.8-kf5-1.patch | 12913 ++++++++++++++++
 srcpkgs/qt5/template                          |    13 +-
 2 files changed, 12919 insertions(+), 7 deletions(-)
 create mode 100644 srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch

diff --git a/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch b/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch
new file mode 100644
index 0000000000000..966c98bcd3bb1
--- /dev/null
+++ b/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch
@@ -0,0 +1,12913 @@
+Submitted By:            Pierre Labastie <pierre_dot_labastie_at_neuf_dot_fr>
+Date:                    2023-01-05
+Initial Package Version: 5.15.8
+Upstream Status:         Applied (according to KDE)
+Origin:                  KDE patch set
+Description:             Patch set maintained by the KDE folks
+see https://dot.kde.org/2021/04/06/announcing-kdes-qt-5-patch-collection
+Patch generated using the procedure in
+https://wiki.linuxfromscratch.org/blfs/ticket/17476#comment:3
+
+Submodule qtbase 4ee4fc18..9cf586d6:
+diff --git a/qtbase/mkspecs/common/android/qplatformdefs.h b/qtbase/mkspecs/common/android/qplatformdefs.h
+index f75bc4093b..2bd59410d4 100644
+--- a/qtbase/mkspecs/common/android/qplatformdefs.h
++++ b/qtbase/mkspecs/common/android/qplatformdefs.h
+@@ -144,11 +144,7 @@
+ #define QT_SIGNAL_ARGS          int
+ #define QT_SIGNAL_IGNORE        SIG_IGN
+ 
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+ #define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+ 
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+diff --git a/qtbase/mkspecs/features/mac/sdk.mk b/qtbase/mkspecs/features/mac/sdk.mk
+index f30b5830b4..a32ceacb6c 100644
+--- a/qtbase/mkspecs/features/mac/sdk.mk
++++ b/qtbase/mkspecs/features/mac/sdk.mk
+@@ -1,6 +1,6 @@
+ 
+ ifeq ($(QT_MAC_SDK_NO_VERSION_CHECK),)
+-    CHECK_SDK_COMMAND = /usr/bin/xcrun --sdk $(EXPORT_QMAKE_MAC_SDK) -show-sdk-version 2>&1
++    CHECK_SDK_COMMAND = /usr/bin/xcrun --sdk $(EXPORT_QMAKE_MAC_SDK) -show-sdk-version 2>/dev/null
+     CURRENT_MAC_SDK_VERSION := $(shell DEVELOPER_DIR=$(EXPORT_QMAKE_XCODE_DEVELOPER_PATH) $(CHECK_SDK_COMMAND))
+     ifneq ($(CURRENT_MAC_SDK_VERSION),$(EXPORT_QMAKE_MAC_SDK_VERSION))
+         # We don't want to complain about out of date SDK unless the target needs to be remade.
+diff --git a/qtbase/mkspecs/linux-clang/qplatformdefs.h b/qtbase/mkspecs/linux-clang/qplatformdefs.h
+index a818d973f0..c1ab72fbc6 100644
+--- a/qtbase/mkspecs/linux-clang/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-clang/qplatformdefs.h
+@@ -79,14 +79,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-g++/qplatformdefs.h b/qtbase/mkspecs/linux-g++/qplatformdefs.h
+index 13523f0702..4d2750d9ec 100644
+--- a/qtbase/mkspecs/linux-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-g++/qplatformdefs.h
+@@ -79,14 +79,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ < 2)
+-#define QT_SOCKLEN_T            int
+-#else
+-#define QT_SOCKLEN_T            socklen_t
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-llvm/qplatformdefs.h b/qtbase/mkspecs/linux-llvm/qplatformdefs.h
+index dc750ab1ef..d3cc39b47f 100644
+--- a/qtbase/mkspecs/linux-llvm/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-llvm/qplatformdefs.h
+@@ -80,14 +80,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h b/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
+index 4c4e53da2a..83baffb3e3 100644
+--- a/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
+@@ -85,16 +85,9 @@
+ #include "../common/posix/qplatformdefs.h"
+ 
+ #undef QT_OPEN_LARGEFILE
+-#undef QT_SOCKLEN_T
+ 
+ #define QT_OPEN_LARGEFILE       0
+ 
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #ifndef SIOCGIFBRDADDR
+ #  define SIOCGIFBRDADDR 0x8919
+ #endif
+diff --git a/qtbase/mkspecs/lynxos-g++/qplatformdefs.h b/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
+index 4339ea2b23..6007af0055 100644
+--- a/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
+@@ -72,14 +72,6 @@
+ 
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp b/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
+index c3c184258f..32af3f8f29 100644
+--- a/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
++++ b/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
+@@ -10,6 +10,7 @@
+ #include "libANGLE/HandleAllocator.h"
+ 
+ #include <algorithm>
++#include <limits>
+ 
+ #include "common/debug.h"
+ 
+diff --git a/qtbase/src/3rdparty/forkfd/forkfd_linux.c b/qtbase/src/3rdparty/forkfd/forkfd_linux.c
+index ffe0e9a5e2..b1f5408d11 100644
+--- a/qtbase/src/3rdparty/forkfd/forkfd_linux.c
++++ b/qtbase/src/3rdparty/forkfd/forkfd_linux.c
+@@ -82,7 +82,8 @@ static int sys_clone(unsigned long cloneflags, int *ptid)
+     return syscall(__NR_clone, cloneflags, child_stack, stack_size, ptid, newtls, ctid);
+ #elif defined(__arc__) || defined(__arm__) || defined(__aarch64__) || defined(__mips__) || \
+     defined(__nds32__) || defined(__hppa__) || defined(__powerpc__) || defined(__i386__) || \
+-    defined(__x86_64__) || defined(__xtensa__) || defined(__alpha__) || defined(__riscv)
++    defined(__x86_64__) || defined(__xtensa__) || defined(__alpha__) || defined(__riscv) || \
++    defined(__loongarch__)
+     /* ctid and newtls are inverted on CONFIG_CLONE_BACKWARDS architectures,
+      * but since both values are 0, there's no harm. */
+     return syscall(__NR_clone, cloneflags, child_stack, ptid, ctid, newtls);
+diff --git a/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java b/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
+index 5792b5b2f5..2f74750fcf 100644
+--- a/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
++++ b/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
+@@ -116,6 +116,7 @@ public class QtNative
+     public static QtThread m_qtThread = new QtThread();
+     private static HashMap<String, Uri> m_cachedUris = new HashMap<String, Uri>();
+     private static ArrayList<String> m_knownDirs = new ArrayList<String>();
++    private static final String NoPermissionErrorMessage = "No permissions to open Uri";
+ 
+     private static final Runnable runPendingCppRunnablesRunnable = new Runnable() {
+         @Override
+@@ -193,11 +194,10 @@ public class QtNative
+                     return iterUri;
+             }
+ 
+-            // Android 6 and earlier could still manage to open the file so we can return the
+-            // parsed uri here
+-            if (Build.VERSION.SDK_INT < 24)
+-                return parsedUri;
+-            return null;
++            // if we only have transient permissions on uri all the above will fail,
++            // but we will be able to read the file anyway, so continue with uri here anyway
++            // and check for SecurityExceptions later
++            return parsedUri;
+         } catch (SecurityException e) {
+             e.printStackTrace();
+             return null;
+@@ -244,7 +244,7 @@ public class QtNative
+         int error = -1;
+ 
+         if (uri == null) {
+-            Log.e(QtTAG, "openFdForContentUrl(): No permissions to open Uri");
++            Log.e(QtTAG, "openFdForContentUrl(): " + NoPermissionErrorMessage);
+             return error;
+         }
+ 
+@@ -254,12 +254,13 @@ public class QtNative
+             return fdDesc.detachFd();
+         } catch (FileNotFoundException e) {
+             e.printStackTrace();
+-            return error;
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "openFdForContentUrl(): Invalid Uri");
+             e.printStackTrace();
+-            return error;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return error;
+     }
+ 
+     public static long getSize(Context context, String contentUrl)
+@@ -270,7 +271,7 @@ public class QtNative
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+ 
+         if (uri == null) {
+-            Log.e(QtTAG, "getSize(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return size;
+         } else if (!m_cachedUris.containsKey(contentUrl)) {
+             m_cachedUris.put(contentUrl, uri);
+@@ -288,12 +289,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "getSize(): Invalid Uri");
+             e.printStackTrace();
+-            return size;
+         }  catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "getSize(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return size;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return size;
+     }
+ 
+     public static boolean checkFileExists(Context context, String contentUrl)
+@@ -303,7 +305,7 @@ public class QtNative
+         if (uri == null)
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+         if (uri == null) {
+-            Log.e(QtTAG, "checkFileExists(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return exists;
+         } else {
+             if (!m_cachedUris.containsKey(contentUrl))
+@@ -321,12 +323,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "checkFileExists(): Invalid Uri");
+             e.printStackTrace();
+-            return exists;
+         } catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "checkFileExists(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return false;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return exists;
+     }
+ 
+     public static boolean checkIfWritable(Context context, String contentUrl)
+@@ -344,7 +347,7 @@ public class QtNative
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+         }
+         if (uri == null) {
+-            Log.e(QtTAG, "isDir(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return isDir;
+         } else {
+             if (!m_cachedUris.containsKey(contentUrl))
+@@ -374,12 +377,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "checkIfDir(): Invalid Uri");
+             e.printStackTrace();
+-            return false;
+         } catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "checkIfDir(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return false;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return false;
+     }
+     public static String[] listContentsFromTreeUri(Context context, String contentUrl)
+     {
+diff --git a/qtbase/src/concurrent/qtconcurrentreducekernel.h b/qtbase/src/concurrent/qtconcurrentreducekernel.h
+index 8f9a938952..a98dedef2e 100644
+--- a/qtbase/src/concurrent/qtconcurrentreducekernel.h
++++ b/qtbase/src/concurrent/qtconcurrentreducekernel.h
+@@ -212,11 +212,13 @@ public:
+ 
+     inline bool shouldThrottle()
+     {
++        std::lock_guard<QMutex> locker(mutex);
+         return (resultsMapSize > (ReduceQueueThrottleLimit * threadCount));
+     }
+ 
+     inline bool shouldStartThread()
+     {
++        std::lock_guard<QMutex> locker(mutex);
+         return (resultsMapSize <= (ReduceQueueStartLimit * threadCount));
+     }
+ };
+diff --git a/qtbase/src/concurrent/qtconcurrentthreadengine.cpp b/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
+index ea6ce3ac42..7f91a2ba68 100644
+--- a/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
++++ b/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
+@@ -176,6 +176,39 @@ void ThreadEngineBase::startSingleThreaded()
+     finish();
+ }
+ 
++void ThreadEngineBase::startBlocking()
++{
++    start();
++    barrier.acquire();
++    startThreads();
++
++    bool throttled = false;
++#ifndef QT_NO_EXCEPTIONS
++    try {
++#endif
++        while (threadFunction() == ThrottleThread) {
++            if (threadThrottleExit()) {
++                throttled = true;
++                break;
++            }
++        }
++#ifndef QT_NO_EXCEPTIONS
++    } catch (QException &e) {
++        handleException(e);
++    } catch (...) {
++        handleException(QUnhandledException());
++    }
++#endif
++
++    if (throttled == false) {
++        barrier.release();
++    }
++
++    barrier.wait();
++    finish();
++    exceptionStore.throwPossibleException();
++}
++
+ void ThreadEngineBase::startThread()
+ {
+     startThreadInternal();
+diff --git a/qtbase/src/concurrent/qtconcurrentthreadengine.h b/qtbase/src/concurrent/qtconcurrentthreadengine.h
+index 7c30cebdbc..a4c8548cc4 100644
+--- a/qtbase/src/concurrent/qtconcurrentthreadengine.h
++++ b/qtbase/src/concurrent/qtconcurrentthreadengine.h
+@@ -91,6 +91,7 @@ public:
+     ThreadEngineBase();
+     virtual ~ThreadEngineBase();
+     void startSingleThreaded();
++    void startBlocking();
+     void startThread();
+     bool isCanceled();
+     void waitForResume();
+@@ -143,6 +144,15 @@ public:
+         return result();
+     }
+ 
++    // Runs the user algorithm using multiple threads.
++    // This function blocks until the algorithm is finished,
++    // and then returns the result.
++    T *startBlocking()
++    {
++        ThreadEngineBase::startBlocking();
++        return result();
++    }
++
+     // Runs the user algorithm using multiple threads.
+     // Does not block, returns a future.
+     QFuture<T> startAsynchronously()
+@@ -223,6 +233,13 @@ class ThreadEngineStarter : public ThreadEngineStarterBase<T>
+ public:
+     ThreadEngineStarter(TypedThreadEngine *eng)
+         : Base(eng) { }
++
++    T startBlocking()
++    {
++        T t = *this->threadEngine->startBlocking();
++        delete this->threadEngine;
++        return t;
++    }
+ };
+ 
+ // Full template specialization where T is void.
+@@ -232,6 +249,12 @@ class ThreadEngineStarter<void> : public ThreadEngineStarterBase<void>
+ public:
+     ThreadEngineStarter(ThreadEngine<void> *_threadEngine)
+         : ThreadEngineStarterBase<void>(_threadEngine) {}
++
++    void startBlocking()
++    {
++        this->threadEngine->startBlocking();
++        delete this->threadEngine;
++    }
+ };
+ 
+ //! [qtconcurrentthreadengine-1]
+diff --git a/qtbase/src/corelib/animation/qvariantanimation.cpp b/qtbase/src/corelib/animation/qvariantanimation.cpp
+index 98b02f0202..eac1524107 100644
+--- a/qtbase/src/corelib/animation/qvariantanimation.cpp
++++ b/qtbase/src/corelib/animation/qvariantanimation.cpp
+@@ -276,7 +276,9 @@ void QVariantAnimationPrivate::setCurrentValueForProgress(const qreal progress)
+ 
+     const qreal startProgress = currentInterval.start.first;
+     const qreal endProgress = currentInterval.end.first;
+-    const qreal localProgress = (progress - startProgress) / (endProgress - startProgress);
++    const qreal localProgress =
++            qIsNull(progress - startProgress) ? 0.0 // avoid 0/0 below
++            /* else */                        : (progress - startProgress) / (endProgress - startProgress);
+ 
+     QVariant ret = q->interpolated(currentInterval.start.second,
+                                    currentInterval.end.second,
+diff --git a/qtbase/src/corelib/global/qnamespace.h b/qtbase/src/corelib/global/qnamespace.h
+index ad4150b317..bf19b1627b 100644
+--- a/qtbase/src/corelib/global/qnamespace.h
++++ b/qtbase/src/corelib/global/qnamespace.h
+@@ -1864,7 +1864,7 @@ public:
+     QT_Q_ENUM(TimerType)
+     QT_Q_ENUM(ScrollPhase)
+     QT_Q_ENUM(MouseEventSource)
+-    QT_Q_FLAG(MouseEventFlag)
++    QT_Q_FLAG(MouseEventFlags)
+     QT_Q_ENUM(ChecksumType)
+     QT_Q_ENUM(HighDpiScaleFactorRoundingPolicy)
+     QT_Q_ENUM(TabFocusBehavior)
+diff --git a/qtbase/src/corelib/global/qrandom.cpp b/qtbase/src/corelib/global/qrandom.cpp
+index 10672c1f92..25f87c7e6a 100644
+--- a/qtbase/src/corelib/global/qrandom.cpp
++++ b/qtbase/src/corelib/global/qrandom.cpp
+@@ -383,7 +383,6 @@ struct QRandomGenerator::SystemAndGlobalGenerators
+ 
+         constexpr SystemAndGlobalGenerators g = {};
+         Q_UNUSED(g);
+-        Q_STATIC_ASSERT(std::is_literal_type<SystemAndGlobalGenerators>::value);
+ #endif
+     }
+ 
+diff --git a/qtbase/src/corelib/io/qbuffer.cpp b/qtbase/src/corelib/io/qbuffer.cpp
+index 595fcd2724..032c0ddd4b 100644
+--- a/qtbase/src/corelib/io/qbuffer.cpp
++++ b/qtbase/src/corelib/io/qbuffer.cpp
+@@ -41,6 +41,8 @@
+ #include <QtCore/qmetaobject.h>
+ #include "private/qiodevice_p.h"
+ 
++#include <limits>
++
+ QT_BEGIN_NAMESPACE
+ 
+ /** QBufferPrivate **/
+@@ -366,7 +368,9 @@ qint64 QBuffer::size() const
+ bool QBuffer::seek(qint64 pos)
+ {
+     Q_D(QBuffer);
+-    if (pos > d->buf->size() && isWritable()) {
++    const auto oldBufSize = d->buf->size();
++    constexpr qint64 MaxSeekPos = (std::numeric_limits<decltype(oldBufSize)>::max)();
++    if (pos <= MaxSeekPos && pos > oldBufSize && isWritable()) {
+         if (seek(d->buf->size())) {
+             const qint64 gapSize = pos - d->buf->size();
+             if (write(QByteArray(gapSize, 0)) != gapSize) {
+@@ -377,7 +381,7 @@ bool QBuffer::seek(qint64 pos)
+             return false;
+         }
+     } else if (pos > d->buf->size() || pos < 0) {
+-        qWarning("QBuffer::seek: Invalid pos: %d", int(pos));
++        qWarning("QBuffer::seek: Invalid pos: %lld", pos);
+         return false;
+     }
+     return QIODevice::seek(pos);
+diff --git a/qtbase/src/corelib/io/qfilesystemengine_win.cpp b/qtbase/src/corelib/io/qfilesystemengine_win.cpp
+index 81d3a71986..c86ed1f9b0 100644
+--- a/qtbase/src/corelib/io/qfilesystemengine_win.cpp
++++ b/qtbase/src/corelib/io/qfilesystemengine_win.cpp
+@@ -664,14 +664,14 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry)
+     return QFileSystemEntry(ret, QFileSystemEntry::FromInternalPath());
+ }
+ 
+-#if defined(Q_CC_MINGW) && WINVER < 0x0602 //  Windows 8 onwards
++#if defined(Q_CC_MINGW) && WINVER < 0x0602 && _WIN32_WINNT < _WIN32_WINNT_WIN8 //  Windows 8 onwards
+ 
+ typedef struct _FILE_ID_INFO {
+     ULONGLONG VolumeSerialNumber;
+     FILE_ID_128 FileId;
+ } FILE_ID_INFO, *PFILE_ID_INFO;
+ 
+-#endif // if defined (Q_CC_MINGW) && WINVER < 0x0602
++#endif // if defined(Q_CC_MINGW) && WINVER < 0x0602 && _WIN32_WINNT < _WIN32_WINNT_WIN8
+ 
+ // File ID for Windows up to version 7 and FAT32 drives
+ static inline QByteArray fileId(HANDLE handle)
+diff --git a/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp b/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
+index 94d9d06bcb..27e0b13b0b 100644
+--- a/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
++++ b/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
+@@ -366,7 +366,9 @@ void QInotifyFileSystemWatcherEngine::readFromInotify()
+     // qDebug("QInotifyFileSystemWatcherEngine::readFromInotify");
+ 
+     int buffSize = 0;
+-    ioctl(inotifyFd, FIONREAD, (char *) &buffSize);
++    if (ioctl(inotifyFd, FIONREAD, (char *) &buffSize) == -1 || buffSize == 0)
++        return;
++
+     QVarLengthArray<char, 4096> buffer(buffSize);
+     buffSize = read(inotifyFd, buffer.data(), buffSize);
+     char *at = buffer.data();
+diff --git a/qtbase/src/corelib/io/qlockfile_win.cpp b/qtbase/src/corelib/io/qlockfile_win.cpp
+index 277f8d4230..38ecef5550 100644
+--- a/qtbase/src/corelib/io/qlockfile_win.cpp
++++ b/qtbase/src/corelib/io/qlockfile_win.cpp
+@@ -48,6 +48,8 @@
+ #include "QtCore/qdebug.h"
+ #include "QtCore/qthread.h"
+ 
++#include "private/qsystemlibrary_p.h"
++
+ QT_BEGIN_NAMESPACE
+ 
+ static inline bool fileExists(const wchar_t *fileName)
+@@ -150,7 +152,7 @@ QString QLockFilePrivate::processNameByPid(qint64 pid)
+ #if !defined(Q_OS_WINRT)
+     typedef DWORD (WINAPI *GetModuleFileNameExFunc)(HANDLE, HMODULE, LPTSTR, DWORD);
+ 
+-    HMODULE hPsapi = LoadLibraryA("psapi");
++    HMODULE hPsapi = QSystemLibrary::load(L"psapi");
+     if (!hPsapi)
+         return QString();
+     GetModuleFileNameExFunc qGetModuleFileNameEx = reinterpret_cast<GetModuleFileNameExFunc>(
+diff --git a/qtbase/src/corelib/io/qprocess_unix.cpp b/qtbase/src/corelib/io/qprocess_unix.cpp
+index 50390e57f5..15c8f30745 100644
+--- a/qtbase/src/corelib/io/qprocess_unix.cpp
++++ b/qtbase/src/corelib/io/qprocess_unix.cpp
+@@ -1,7 +1,7 @@
+ /****************************************************************************
+ **
+ ** Copyright (C) 2016 The Qt Company Ltd.
+-** Copyright (C) 2016 Intel Corporation.
++** Copyright (C) 2022 Intel Corporation.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtCore module of the Qt Toolkit.
+@@ -422,14 +422,15 @@ void QProcessPrivate::startProcess()
+     // Add the program name to the argument list.
+     argv[0] = nullptr;
+     if (!program.contains(QLatin1Char('/'))) {
++        // findExecutable() returns its argument if it's an absolute path,
++        // otherwise it searches $PATH; returns empty if not found (we handle
++        // that case much later)
+         const QString &exeFilePath = QStandardPaths::findExecutable(program);
+-        if (!exeFilePath.isEmpty()) {
+-            const QByteArray &tmp = QFile::encodeName(exeFilePath);
+-            argv[0] = ::strdup(tmp.constData());
+-        }
+-    }
+-    if (!argv[0])
++        const QByteArray &tmp = QFile::encodeName(exeFilePath);
++        argv[0] = ::strdup(tmp.constData());
++    } else {
+         argv[0] = ::strdup(encodedProgramName.constData());
++    }
+ 
+     // Add every argument to the list
+     for (int i = 0; i < arguments.count(); ++i)
+@@ -983,15 +984,16 @@ bool QProcessPrivate::startDetached(qint64 *pid)
+                 envp = _q_dupEnvironment(environment.d.constData()->vars, &envc);
+             }
+ 
+-            QByteArray tmp;
+             if (!program.contains(QLatin1Char('/'))) {
++                // findExecutable() returns its argument if it's an absolute path,
++                // otherwise it searches $PATH; returns empty if not found (we handle
++                // that case much later)
+                 const QString &exeFilePath = QStandardPaths::findExecutable(program);
+-                if (!exeFilePath.isEmpty())
+-                    tmp = QFile::encodeName(exeFilePath);
++                const QByteArray &tmp = QFile::encodeName(exeFilePath);
++                argv[0] = ::strdup(tmp.constData());
++            } else {
++                argv[0] = ::strdup(QFile::encodeName(program));
+             }
+-            if (tmp.isEmpty())
+-                tmp = QFile::encodeName(program);
+-            argv[0] = tmp.data();
+ 
+             if (envp)
+                 qt_safe_execve(argv[0], argv, envp);
+diff --git a/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp b/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
+index 3a79c502af..997a634e76 100644
+--- a/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
++++ b/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
+@@ -3196,9 +3196,8 @@ bool QAbstractItemModel::beginMoveColumns(const QModelIndex &sourceParent, int s
+     destinationChange.needsAdjust = destinationParent.isValid() && destinationParent.row() >= sourceLast && destinationParent.parent() == sourceParent;
+     d->changes.push(destinationChange);
+ 
+-    d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Horizontal);
+-
+     emit columnsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, QPrivateSignal());
++    d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Horizontal);
+     return true;
+ }
+ 
+@@ -3231,7 +3230,6 @@ void QAbstractItemModel::endMoveColumns()
+       adjustedSource = createIndex(adjustedSource.row(), adjustedSource.column() + numMoved, adjustedSource.internalPointer());
+ 
+     d->itemsMoved(adjustedSource, removeChange.first, removeChange.last, adjustedDestination, insertChange.first, Qt::Horizontal);
+-
+     emit columnsMoved(adjustedSource, removeChange.first, removeChange.last, adjustedDestination, insertChange.first, QPrivateSignal());
+ }
+ 
+diff --git a/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+index dc6379d9fb..c5e287ee84 100644
+--- a/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
++++ b/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+@@ -939,8 +939,9 @@ void QSortFilterProxyModelPrivate::insert_source_items(
+                 q->beginInsertColumns(proxy_parent, proxy_start, proxy_end);
+         }
+ 
+-        for (int i = 0; i < source_items.size(); ++i)
+-            proxy_to_source.insert(proxy_start + i, source_items.at(i));
++        // TODO: use the range QList::insert() overload once it is implemented (QTBUG-58633).
++        proxy_to_source.insert(proxy_start, source_items.size(), 0);
++        std::copy(source_items.cbegin(), source_items.cend(), proxy_to_source.begin() + proxy_start);
+ 
+         build_source_to_proxy_mapping(proxy_to_source, source_to_proxy);
+ 
+@@ -3123,8 +3124,9 @@ bool QSortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex &
+ 
+     if (d->filter_data.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();
+@@ -3133,9 +3135,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.hasMatch(key);
+ }
+diff --git a/qtbase/src/corelib/kernel/qcoreapplication.cpp b/qtbase/src/corelib/kernel/qcoreapplication.cpp
+index ca2864df83..132b2eae52 100644
+--- a/qtbase/src/corelib/kernel/qcoreapplication.cpp
++++ b/qtbase/src/corelib/kernel/qcoreapplication.cpp
+@@ -1157,7 +1157,7 @@ static bool doNotify(QObject *receiver, QEvent *event)
+ bool QCoreApplicationPrivate::sendThroughApplicationEventFilters(QObject *receiver, QEvent *event)
+ {
+     // We can't access the application event filters outside of the main thread (race conditions)
+-    Q_ASSERT(receiver->d_func()->threadData.loadRelaxed()->thread.loadAcquire() == mainThread());
++    Q_ASSERT(receiver->d_func()->threadData.loadAcquire()->thread.loadRelaxed() == mainThread());
+ 
+     if (extraData) {
+         // application event filters are only called for objects in the GUI thread
+diff --git a/qtbase/src/corelib/kernel/qobject.cpp b/qtbase/src/corelib/kernel/qobject.cpp
+index 1eb79138d9..36cd780ee1 100644
+--- a/qtbase/src/corelib/kernel/qobject.cpp
++++ b/qtbase/src/corelib/kernel/qobject.cpp
+@@ -1010,7 +1010,7 @@ QObject::~QObject()
+         emit destroyed(this);
+     }
+ 
+-    if (d->declarativeData) {
++    if (!d->isDeletingChildren && d->declarativeData) {
+         if (static_cast<QAbstractDeclarativeDataImpl*>(d->declarativeData)->ownedByQml1) {
+             if (QAbstractDeclarativeData::destroyed_qml1)
+                 QAbstractDeclarativeData::destroyed_qml1(d->declarativeData, this);
+@@ -1580,7 +1580,7 @@ void QObject::moveToThread(QThread *targetThread)
+ 
+     QThreadData *currentData = QThreadData::current();
+     QThreadData *targetData = targetThread ? QThreadData::get2(targetThread) : nullptr;
+-    QThreadData *thisThreadData = d->threadData.loadRelaxed();
++    QThreadData *thisThreadData = d->threadData.loadAcquire();
+     if (!thisThreadData->thread.loadAcquire() && currentData == targetData) {
+         // one exception to the rule: we allow moving objects with no thread affinity to the current thread
+         currentData = d->threadData;
+@@ -2620,7 +2620,7 @@ int QObject::receivers(const char *signal) const
+         if (!d->isSignalConnected(signal_index))
+             return receivers;
+ 
+-        if (d->declarativeData && QAbstractDeclarativeData::receivers) {
++        if (!d->isDeletingChildren && d->declarativeData && QAbstractDeclarativeData::receivers) {
+             receivers += QAbstractDeclarativeData::receivers(d->declarativeData, this,
+                                                              signal_index);
+         }
+diff --git a/qtbase/src/corelib/kernel/qobject_p.h b/qtbase/src/corelib/kernel/qobject_p.h
+index 0b827a52ca..13ffb88999 100644
+--- a/qtbase/src/corelib/kernel/qobject_p.h
++++ b/qtbase/src/corelib/kernel/qobject_p.h
+@@ -444,7 +444,7 @@ inline void QObjectPrivate::checkForIncompatibleLibraryVersion(int version) cons
+ 
+ inline bool QObjectPrivate::isDeclarativeSignalConnected(uint signal_index) const
+ {
+-    return declarativeData && QAbstractDeclarativeData::isSignalConnected
++    return !isDeletingChildren && declarativeData && QAbstractDeclarativeData::isSignalConnected
+             && QAbstractDeclarativeData::isSignalConnected(declarativeData, q_func(), signal_index);
+ }
+ 
+diff --git a/qtbase/src/corelib/kernel/qtranslator.cpp b/qtbase/src/corelib/kernel/qtranslator.cpp
+index 2812ffb7ea..bc0177c5ec 100644
+--- a/qtbase/src/corelib/kernel/qtranslator.cpp
++++ b/qtbase/src/corelib/kernel/qtranslator.cpp
+@@ -902,7 +902,7 @@ static QString getMessage(const uchar *m, const uchar *end, const char *context,
+             goto end;
+         case Tag_Translation: {
+             int len = read32(m);
+-            if (len % 1)
++            if (len & 1)
+                 return QString();
+             m += 4;
+             if (!numerus--) {
+diff --git a/qtbase/src/corelib/mimetypes/qmimedatabase.cpp b/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
+index 9de22cef33..ff868a3268 100644
+--- a/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
+@@ -389,20 +389,23 @@ QMimeType QMimeDatabasePrivate::mimeTypeForFileNameAndData(const QString &fileNa
+         // Disambiguate conflicting extensions (if magic matching found something)
+         if (candidateByData.isValid() && magicAccuracy > 0) {
+             const QString sniffedMime = candidateByData.name();
+-            // If the sniffedMime matches a glob match, use it
++            // If the sniffedMime matches a highest-weight glob match, use it
+             if (candidatesByName.m_matchingMimeTypes.contains(sniffedMime)) {
+                 *accuracyPtr = 100;
+                 return candidateByData;
+             }
+-            for (const QString &m : qAsConst(candidatesByName.m_matchingMimeTypes)) {
++            for (const QString &m : qAsConst(candidatesByName.m_allMatchingMimeTypes)) {
+                 if (inherits(m, sniffedMime)) {
+                     // We have magic + pattern pointing to this, so it's a pretty good match
+                     *accuracyPtr = 100;
+                     return mimeTypeForName(m);
+                 }
+             }
+-            *accuracyPtr = magicAccuracy;
+-            return candidateByData;
++            if (candidatesByName.m_allMatchingMimeTypes.isEmpty()) {
++                // No glob, use magic
++                *accuracyPtr = magicAccuracy;
++                return candidateByData;
++            }
+         }
+     }
+ 
+diff --git a/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp b/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
+index a81112d227..fa8f4c545d 100644
+--- a/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
+@@ -83,7 +83,10 @@ void QMimeGlobMatchResult::addMatch(const QString &mimeType, int weight, const Q
+     }
+     if (!m_matchingMimeTypes.contains(mimeType)) {
+         m_matchingMimeTypes.append(mimeType);
+-        m_allMatchingMimeTypes.append(mimeType);
++        if (replace)
++            m_allMatchingMimeTypes.prepend(mimeType); // highest-weight first
++        else
++            m_allMatchingMimeTypes.append(mimeType);
+         m_knownSuffixLength = knownSuffixLength;
+     }
+ }
+@@ -94,7 +97,7 @@ QMimeGlobPattern::PatternType QMimeGlobPattern::detectPatternType(const QString
+     if (!patternLength)
+         return OtherPattern;
+ 
+-    const bool starCount = pattern.count(QLatin1Char('*')) == 1;
++    const int starCount = pattern.count(QLatin1Char('*'));
+     const bool hasSquareBracket = pattern.indexOf(QLatin1Char('[')) != -1;
+     const bool hasQuestionMark = pattern.indexOf(QLatin1Char('?')) != -1;
+ 
+@@ -106,10 +109,10 @@ QMimeGlobPattern::PatternType QMimeGlobPattern::detectPatternType(const QString
+             // Patterns like "README*" (well this is currently the only one like that...)
+             if (pattern.at(patternLength - 1) == QLatin1Char('*'))
+                 return PrefixPattern;
+-        }
+-        // Names without any wildcards like "README"
+-        if (starCount == 0)
++        } else if (starCount == 0) {
++            // Names without any wildcards like "README"
+             return LiteralPattern;
++        }
+     }
+ 
+     if (pattern == QLatin1String("[0-9][0-9][0-9].vdr"))
+diff --git a/qtbase/src/corelib/mimetypes/qmimeprovider.cpp b/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
+index 258dddf8cb..4642d0f2d0 100644
+--- a/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
+@@ -244,15 +244,18 @@ void QMimeBinaryProvider::addFileNameMatches(const QString &fileName, QMimeGlobM
+     const QString lowerFileName = fileName.toLower();
+     // Check literals (e.g. "Makefile")
+     matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosLiteralListOffset), fileName);
+-    // Check complex globs (e.g. "callgrind.out[0-9]*")
+-    matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosGlobListOffset), fileName);
+     // Check the very common *.txt cases with the suffix tree
+-    const int reverseSuffixTreeOffset = m_cacheFile->getUint32(PosReverseSuffixTreeOffset);
+-    const int numRoots = m_cacheFile->getUint32(reverseSuffixTreeOffset);
+-    const int firstRootOffset = m_cacheFile->getUint32(reverseSuffixTreeOffset + 4);
+-    matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, lowerFileName, lowerFileName.length() - 1, false);
++    if (result.m_matchingMimeTypes.isEmpty()) {
++        const int reverseSuffixTreeOffset = m_cacheFile->getUint32(PosReverseSuffixTreeOffset);
++        const int numRoots = m_cacheFile->getUint32(reverseSuffixTreeOffset);
++        const int firstRootOffset = m_cacheFile->getUint32(reverseSuffixTreeOffset + 4);
++        matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, lowerFileName, lowerFileName.length() - 1, false);
++        if (result.m_matchingMimeTypes.isEmpty())
++            matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, fileName, fileName.length() - 1, true);
++    }
++    // Check complex globs (e.g. "callgrind.out[0-9]*" or "README*")
+     if (result.m_matchingMimeTypes.isEmpty())
+-        matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, fileName, fileName.length() - 1, true);
++        matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosGlobListOffset), fileName);
+ }
+ 
+ void QMimeBinaryProvider::matchGlobList(QMimeGlobMatchResult &result, CacheFile *cacheFile, int off, const QString &fileName)
+diff --git a/qtbase/src/corelib/serialization/qjsonparser.cpp b/qtbase/src/corelib/serialization/qjsonparser.cpp
+index 17e6f111ab..2e40b6c8fb 100644
+--- a/qtbase/src/corelib/serialization/qjsonparser.cpp
++++ b/qtbase/src/corelib/serialization/qjsonparser.cpp
+@@ -379,10 +379,30 @@ error:
+     return QCborValue();
+ }
+ 
++// We need to retain the _last_ value for any duplicate keys and we need to deref containers.
++// Therefore the manual implementation of std::unique().
++template<typename Iterator, typename Compare, typename Assign>
++static Iterator customAssigningUniqueLast(Iterator first, Iterator last,
++                                          Compare compare, Assign assign)
++{
++    first = std::adjacent_find(first, last, compare);
++    if (first == last)
++        return last;
++
++    Iterator result = first;
++    while (++first != last) {
++        if (!compare(*result, *first))
++            ++result;
++        if (result != first)
++            assign(*result, *first);
++    }
++
++    return ++result;
++}
++
+ static void sortContainer(QCborContainerPrivate *container)
+ {
+     using Forward = QJsonPrivate::KeyIterator;
+-    using Reverse = std::reverse_iterator<Forward>;
+     using Value = Forward::value_type;
+ 
+     auto compare = [container](const Value &a, const Value &b)
+@@ -420,17 +440,31 @@ static void sortContainer(QCborContainerPrivate *container)
+         }
+     };
+ 
+-    std::sort(Forward(container->elements.begin()), Forward(container->elements.end()),
+-              [&compare](const Value &a, const Value &b) { return compare(a, b) < 0; });
++    // The elements' containers are owned by the outer container, not by the elements themselves.
++    auto move = [](Forward::reference target, Forward::reference source)
++    {
++        QtCbor::Element &targetValue = target.value();
++
++        // If the target has a container, deref it before overwriting, so that we don't leak.
++        if (targetValue.flags & QtCbor::Element::IsContainer)
++            targetValue.container->deref();
++
++        // Do not move, so that we can clear the value afterwards.
++        target = source;
++
++        // Clear the source value, so that we don't store the same container twice.
++        source.value() = QtCbor::Element();
++    };
++
++    std::stable_sort(
++                Forward(container->elements.begin()), Forward(container->elements.end()),
++                [&compare](const Value &a, const Value &b) { return compare(a, b) < 0; });
+ 
+-    // We need to retain the _last_ value for any duplicate keys. Therefore the reverse dance here.
+-    auto it = std::unique(Reverse(container->elements.end()), Reverse(container->elements.begin()),
+-                          [&compare](const Value &a, const Value &b) {
+-        return compare(a, b) == 0;
+-    }).base().elementsIterator();
++    Forward result = customAssigningUniqueLast(
++                Forward(container->elements.begin()),  Forward(container->elements.end()),
++                [&compare](const Value &a, const Value &b) { return compare(a, b) == 0; }, move);
+ 
+-    // The erase from beginning is expensive but hopefully rare.
+-    container->elements.erase(container->elements.begin(), it);
++    container->elements.erase(result.elementsIterator(), container->elements.end());
+ }
+ 
+ 
+diff --git a/qtbase/src/corelib/serialization/qxmlstream.cpp b/qtbase/src/corelib/serialization/qxmlstream.cpp
+index b2f846544d..7cd457ba3a 100644
+--- a/qtbase/src/corelib/serialization/qxmlstream.cpp
++++ b/qtbase/src/corelib/serialization/qxmlstream.cpp
+@@ -980,7 +980,7 @@ inline uint QXmlStreamReaderPrivate::peekChar()
+ bool QXmlStreamReaderPrivate::scanUntil(const char *str, short tokenToInject)
+ {
+     int pos = textBuffer.size();
+-    int oldLineNumber = lineNumber;
++    const auto oldLineNumber = lineNumber;
+ 
+     uint c;
+     while ((c = getChar()) != StreamEOF) {
+diff --git a/qtbase/src/corelib/text/qstring.cpp b/qtbase/src/corelib/text/qstring.cpp
+index 3e88ab4859..8deeae47bb 100644
+--- a/qtbase/src/corelib/text/qstring.cpp
++++ b/qtbase/src/corelib/text/qstring.cpp
+@@ -12312,7 +12312,7 @@ static qsizetype qLastIndexOf(Haystack haystack0, qsizetype from,
+     const auto needle = needle0.data();
+     const auto *end = haystack;
+     haystack += from;
+-    const std::size_t sl_minus_1 = sl - 1;
++    const std::size_t sl_minus_1 = sl ? sl - 1 : 0;
+     const auto *n = needle + sl_minus_1;
+     const auto *h = haystack + sl_minus_1;
+     std::size_t hashNeedle = 0, hashHaystack = 0;
+diff --git a/qtbase/src/corelib/text/qstringiterator_p.h b/qtbase/src/corelib/text/qstringiterator_p.h
+index 219589b6e4..1d0c66cc78 100644
+--- a/qtbase/src/corelib/text/qstringiterator_p.h
++++ b/qtbase/src/corelib/text/qstringiterator_p.h
+@@ -61,6 +61,8 @@ class QStringIterator
+ {
+     QString::const_iterator i, pos, e;
+     Q_STATIC_ASSERT((std::is_same<QString::const_iterator, const QChar *>::value));
++    static bool less(const QChar *lhs, const QChar *rhs) noexcept
++    { return std::less<QString::const_iterator>{}(lhs, rhs); }
+ public:
+     explicit QStringIterator(QStringView string, qsizetype idx = 0)
+         : i(string.begin()),
+@@ -95,7 +97,8 @@ public:
+ 
+     inline void setPosition(QString::const_iterator position)
+     {
+-        Q_ASSERT_X(i <= position && position <= e, Q_FUNC_INFO, "position out of bounds");
++        Q_ASSERT_X(!less(position, i) && !less(e, position),
++                   Q_FUNC_INFO, "position out of bounds");
+         pos = position;
+     }
+ 
+@@ -103,7 +106,7 @@ public:
+ 
+     inline bool hasNext() const
+     {
+-        return pos < e;
++        return less(pos, e);
+     }
+ 
+     inline void advance()
+@@ -120,16 +123,20 @@ public:
+     {
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+-        if (Q_UNLIKELY((pos++)->isHighSurrogate()))
++        if (Q_UNLIKELY((pos++)->isHighSurrogate())) {
++            Q_ASSERT(hasNext() && pos->isLowSurrogate());
+             ++pos;
++        }
+     }
+ 
+     inline uint peekNextUnchecked() const
+     {
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+-        if (Q_UNLIKELY(pos->isHighSurrogate()))
++        if (Q_UNLIKELY(pos->isHighSurrogate())) {
++            Q_ASSERT(less(pos + 1, e) && pos[1].isLowSurrogate());
+             return QChar::surrogateToUcs4(pos[0], pos[1]);
++        }
+ 
+         return pos->unicode();
+     }
+@@ -155,8 +162,10 @@ public:
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+         const QChar cur = *pos++;
+-        if (Q_UNLIKELY(cur.isHighSurrogate()))
++        if (Q_UNLIKELY(cur.isHighSurrogate())) {
++            Q_ASSERT(hasNext() && pos->isLowSurrogate());
+             return QChar::surrogateToUcs4(cur, *pos++);
++        }
+         return cur.unicode();
+     }
+ 
+@@ -166,7 +175,7 @@ public:
+ 
+         const QChar uc = *pos++;
+         if (Q_UNLIKELY(uc.isSurrogate())) {
+-            if (Q_LIKELY(uc.isHighSurrogate() && pos < e && pos->isLowSurrogate()))
++            if (Q_LIKELY(uc.isHighSurrogate() && hasNext() && pos->isLowSurrogate()))
+                 return QChar::surrogateToUcs4(uc, *pos++);
+             return invalidAs;
+         }
+@@ -178,7 +187,7 @@ public:
+ 
+     inline bool hasPrevious() const
+     {
+-        return pos > i;
++        return less(i, pos);
+     }
+ 
+     inline void recede()
+@@ -196,16 +205,20 @@ public:
+     {
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+-        if (Q_UNLIKELY((--pos)->isLowSurrogate()))
++        if (Q_UNLIKELY((--pos)->isLowSurrogate())) {
++            Q_ASSERT(hasPrevious() && pos[-1].isHighSurrogate());
+             --pos;
++        }
+     }
+ 
+     inline uint peekPreviousUnchecked() const
+     {
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+-        if (Q_UNLIKELY(pos[-1].isLowSurrogate()))
++        if (Q_UNLIKELY(pos[-1].isLowSurrogate())) {
++            Q_ASSERT(less(i + 1, pos) && pos[-2].isHighSurrogate());
+             return QChar::surrogateToUcs4(pos[-2], pos[-1]);
++        }
+         return pos[-1].unicode();
+     }
+ 
+@@ -230,8 +243,10 @@ public:
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+         const QChar cur = *--pos;
+-        if (Q_UNLIKELY(cur.isLowSurrogate()))
++        if (Q_UNLIKELY(cur.isLowSurrogate())) {
++            Q_ASSERT(hasPrevious() && pos[-1].isHighSurrogate());
+             return QChar::surrogateToUcs4(*--pos, cur);
++        }
+         return cur.unicode();
+     }
+ 
+@@ -241,7 +256,7 @@ public:
+ 
+         const QChar uc = *--pos;
+         if (Q_UNLIKELY(uc.isSurrogate())) {
+-            if (Q_LIKELY(uc.isLowSurrogate() && pos > i && pos[-1].isHighSurrogate()))
++            if (Q_LIKELY(uc.isLowSurrogate() && hasPrevious() && pos[-1].isHighSurrogate()))
+                 return QChar::surrogateToUcs4(*--pos, uc);
+             return invalidAs;
+         }
+diff --git a/qtbase/src/corelib/thread/qfutex_p.h b/qtbase/src/corelib/thread/qfutex_p.h
+index f287b752d7..e294537787 100644
+--- a/qtbase/src/corelib/thread/qfutex_p.h
++++ b/qtbase/src/corelib/thread/qfutex_p.h
+@@ -52,6 +52,7 @@
+ //
+ 
+ #include <qglobal.h>
++#include <QtCore/qtsan_impl.h>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -106,16 +107,13 @@ namespace QtLinuxFutex {
+     inline int _q_futex(int *addr, int op, int val, quintptr val2 = 0,
+                         int *addr2 = nullptr, int val3 = 0) noexcept
+     {
+-        // A futex call ensures total ordering on the futex words
+-        // (in either success or failure of the call). Instruct TSAN accordingly,
+-        // as TSAN does not understand the futex(2) syscall.
+-        _q_tsan_release(addr, addr2);
++        QtTsan::futexRelease(addr, addr2);
+ 
+         // we use __NR_futex because some libcs (like Android's bionic) don't
+         // provide SYS_futex etc.
+         int result = syscall(__NR_futex, addr, op | FUTEX_PRIVATE_FLAG, val, val2, addr2, val3);
+ 
+-        _q_tsan_acquire(addr, addr2);
++        QtTsan::futexAcquire(addr, addr2);
+ 
+         return result;
+     }
+diff --git a/qtbase/src/corelib/thread/qmutex.cpp b/qtbase/src/corelib/thread/qmutex.cpp
+index 310d1cb14f..7097122d8e 100644
+--- a/qtbase/src/corelib/thread/qmutex.cpp
++++ b/qtbase/src/corelib/thread/qmutex.cpp
+@@ -152,6 +152,7 @@ public:
+ 
+ /*!
+     \enum QMutex::RecursionMode
++    \obsolete Use QRecursiveMutex to create a recursive mutex.
+ 
+     \value Recursive  In this mode, a thread can lock the same mutex
+                       multiple times and the mutex won't be unlocked
+@@ -173,6 +174,7 @@ public:
+ 
+ /*!
+     Constructs a new mutex. The mutex is created in an unlocked state.
++    \obsolete Use QRecursiveMutex to create a recursive mutex.
+ 
+     If \a mode is QMutex::Recursive, a thread can lock the same mutex
+     multiple times and the mutex won't be unlocked until a
+@@ -197,7 +199,7 @@ QMutex::QMutex(RecursionMode mode)
+ QMutex::~QMutex()
+ {
+     QMutexData *d = d_ptr.loadRelaxed();
+-    if (isRecursive()) {
++    if (QBasicMutex::isRecursive()) {
+         delete static_cast<QRecursiveMutexPrivate *>(d);
+     } else if (d) {
+ #ifndef QT_LINUX_FUTEX
+diff --git a/qtbase/src/corelib/thread/qmutex.h b/qtbase/src/corelib/thread/qmutex.h
+index 73c9e00663..1bae573a03 100644
+--- a/qtbase/src/corelib/thread/qmutex.h
++++ b/qtbase/src/corelib/thread/qmutex.h
+@@ -42,6 +42,7 @@
+ 
+ #include <QtCore/qglobal.h>
+ #include <QtCore/qatomic.h>
++#include <QtCore/qtsan_impl.h>
+ #include <new>
+ 
+ #if __has_include(<chrono>)
+@@ -77,19 +78,37 @@ public:
+ 
+     // BasicLockable concept
+     inline void lock() QT_MUTEX_LOCK_NOEXCEPT {
++        QtTsan::mutexPreLock(this, 0u);
++
+         if (!fastTryLock())
+             lockInternal();
++
++        QtTsan::mutexPostLock(this, 0u, 0);
+     }
+ 
+     // BasicLockable concept
+     inline void unlock() noexcept {
+         Q_ASSERT(d_ptr.loadRelaxed()); //mutex must be locked
++
++        QtTsan::mutexPreUnlock(this, 0u);
++
+         if (!fastTryUnlock())
+             unlockInternal();
++
++        QtTsan::mutexPostUnlock(this, 0u);
+     }
+ 
+     bool tryLock() noexcept {
+-        return fastTryLock();
++        unsigned tsanFlags = QtTsan::TryLock;
++        QtTsan::mutexPreLock(this, tsanFlags);
++
++        const bool success = fastTryLock();
++
++        if (!success)
++            tsanFlags |= QtTsan::TryLockFailed;
++        QtTsan::mutexPostLock(this, tsanFlags, 0);
++
++        return success;
+     }
+ 
+     // Lockable concept
+@@ -134,8 +153,16 @@ public:
+ #else
+     QMutex() { d_ptr.storeRelaxed(nullptr); }
+ #endif
++#if QT_DEPRECATED_SINCE(5,15)
+     enum RecursionMode { NonRecursive, Recursive };
++    QT_DEPRECATED_VERSION_X(5, 15, "Use QRecursiveMutex instead of a recursive QMutex")
+     explicit QMutex(RecursionMode mode);
++
++    QT_DEPRECATED_VERSION_X(5, 15, "Use QRecursiveMutex instead of a recursive QMutex")
++    bool isRecursive() const noexcept
++    { return QBasicMutex::isRecursive(); }
++#endif
++
+     ~QMutex();
+ 
+     // BasicLockable concept
+@@ -166,9 +193,6 @@ public:
+     }
+ #endif
+ 
+-    bool isRecursive() const noexcept
+-    { return QBasicMutex::isRecursive(); }
+-
+ private:
+     Q_DISABLE_COPY(QMutex)
+     friend class QMutexLocker;
+diff --git a/qtbase/src/corelib/thread/qreadwritelock.cpp b/qtbase/src/corelib/thread/qreadwritelock.cpp
+index 8c28507d5a..9dd8503116 100644
+--- a/qtbase/src/corelib/thread/qreadwritelock.cpp
++++ b/qtbase/src/corelib/thread/qreadwritelock.cpp
+@@ -155,7 +155,7 @@ QReadWriteLock::QReadWriteLock(RecursionMode recursionMode)
+ */
+ QReadWriteLock::~QReadWriteLock()
+ {
+-    auto d = d_ptr.loadRelaxed();
++    auto d = d_ptr.loadAcquire();
+     if (isUncontendedLocked(d)) {
+         qWarning("QReadWriteLock: destroying locked QReadWriteLock");
+         return;
+@@ -445,7 +445,7 @@ void QReadWriteLock::unlock()
+ /*! \internal  Helper for QWaitCondition::wait */
+ QReadWriteLock::StateForWaitCondition QReadWriteLock::stateForWaitCondition() const
+ {
+-    QReadWriteLockPrivate *d = d_ptr.loadRelaxed();
++    QReadWriteLockPrivate *d = d_ptr.loadAcquire();
+     switch (quintptr(d) & StateMask) {
+     case StateLockedForRead: return LockedForRead;
+     case StateLockedForWrite: return LockedForWrite;
+@@ -453,6 +453,7 @@ QReadWriteLock::StateForWaitCondition QReadWriteLock::stateForWaitCondition() co
+ 
+     if (!d)
+         return Unlocked;
++    const auto lock = qt_scoped_lock(d->mutex);
+     if (d->writerCount > 1)
+         return RecursivelyLocked;
+     else if (d->writerCount == 1)
+diff --git a/qtbase/src/corelib/thread/qsemaphore.cpp b/qtbase/src/corelib/thread/qsemaphore.cpp
+index 1d01fc1b28..3ecdee3747 100644
+--- a/qtbase/src/corelib/thread/qsemaphore.cpp
++++ b/qtbase/src/corelib/thread/qsemaphore.cpp
+@@ -354,7 +354,12 @@ void QSemaphore::release(int n)
+         quintptr nn = unsigned(n);
+         if (futexHasWaiterCount)
+             nn |= quint64(nn) << 32;    // token count replicated in high word
+-        quintptr prevValue = u.fetchAndAddRelease(nn);
++        quintptr prevValue = u.loadRelaxed();
++        quintptr newValue;
++        do { // loop just to ensure the operations are done atomically
++            newValue = prevValue + nn;
++            newValue &= (futexNeedsWakeAllBit - 1);
++        } while (!u.testAndSetRelease(prevValue, newValue, prevValue));
+         if (futexNeedsWake(prevValue)) {
+ #ifdef FUTEX_OP
+             if (futexHasWaiterCount) {
+@@ -376,7 +381,6 @@ void QSemaphore::release(int n)
+                 quint32 oparg = 0;
+                 quint32 cmp = FUTEX_OP_CMP_NE;
+                 quint32 cmparg = 0;
+-                u.fetchAndAndRelease(futexNeedsWakeAllBit - 1);
+                 futexWakeOp(*futexLow32(&u), n, INT_MAX, *futexHigh32(&u), FUTEX_OP(op, oparg, cmp, cmparg));
+                 return;
+             }
+@@ -388,7 +392,6 @@ 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(futexNeedsWakeAllBit - 1);
+             if (futexHasWaiterCount) {
+                 futexWakeAll(*futexLow32(&u));
+                 futexWakeAll(*futexHigh32(&u));
+diff --git a/qtbase/src/corelib/thread/qthread_p.h b/qtbase/src/corelib/thread/qthread_p.h
+index b2d1628e6e..f32f6f0460 100644
+--- a/qtbase/src/corelib/thread/qthread_p.h
++++ b/qtbase/src/corelib/thread/qthread_p.h
+@@ -174,7 +174,7 @@ public:
+     int returnCode;
+ 
+     uint stackSize;
+-    QThread::Priority priority;
++    std::underlying_type<QThread::Priority>::type priority;
+ 
+     static QThread *threadForId(int id);
+ 
+@@ -213,6 +213,13 @@ public:
+             QCoreApplication::instance()->postEvent(q_ptr, new QEvent(QEvent::Quit));
+         }
+     }
++
++#ifndef Q_OS_INTEGRITY
++private:
++    // Used in QThread(Private)::start to avoid racy access to QObject::objectName,
++    // unset afterwards. On INTEGRITY we set the thread name before starting it.
++    QString objectName;
++#endif
+ };
+ 
+ #else // QT_CONFIG(thread)
+diff --git a/qtbase/src/corelib/thread/qthread_unix.cpp b/qtbase/src/corelib/thread/qthread_unix.cpp
+index 56a8e0a038..610117a640 100644
+--- a/qtbase/src/corelib/thread/qthread_unix.cpp
++++ b/qtbase/src/corelib/thread/qthread_unix.cpp
+@@ -169,8 +169,7 @@ static void set_thread_data(QThreadData *data)
+ 
+ static void clear_thread_data()
+ {
+-    currentThreadData = nullptr;
+-    pthread_setspecific(current_thread_data_key, nullptr);
++    set_thread_data(nullptr);
+ }
+ 
+ template <typename T>
+@@ -296,7 +295,7 @@ void *QThreadPrivate::start(void *arg)
+             QMutexLocker locker(&thr->d_func()->mutex);
+ 
+             // do we need to reset the thread priority?
+-            if (int(thr->d_func()->priority) & ThreadPriorityResetFlag) {
++            if (thr->d_func()->priority & ThreadPriorityResetFlag) {
+                 thr->d_func()->setPriority(QThread::Priority(thr->d_func()->priority & ~ThreadPriorityResetFlag));
+             }
+ 
+@@ -316,10 +315,10 @@ void *QThreadPrivate::start(void *arg)
+             // Sets the name of the current thread. We can only do this
+             // when the thread is starting, as we don't have a cross
+             // platform way of setting the name of an arbitrary thread.
+-            if (Q_LIKELY(thr->objectName().isEmpty()))
++            if (Q_LIKELY(thr->d_func()->objectName.isEmpty()))
+                 setCurrentThreadName(thr->metaObject()->className());
+             else
+-                setCurrentThreadName(thr->objectName().toLocal8Bit());
++                setCurrentThreadName(std::exchange(thr->d_func()->objectName, {}).toLocal8Bit());
+         }
+ #endif
+ 
+@@ -671,7 +670,7 @@ void QThread::start(Priority priority)
+                 // could not set scheduling hints, fallback to inheriting them
+                 // we'll try again from inside the thread
+                 pthread_attr_setinheritsched(&attr, PTHREAD_INHERIT_SCHED);
+-                d->priority = Priority(priority | ThreadPriorityResetFlag);
++                d->priority = static_cast<std::underlying_type<QThread::Priority>::type>(priority) | ThreadPriorityResetFlag;
+             }
+             break;
+         }
+@@ -702,7 +701,10 @@ void QThread::start(Priority priority)
+         pthread_attr_setthreadname(&attr, metaObject()->className());
+     else
+         pthread_attr_setthreadname(&attr, objectName().toLocal8Bit());
++#else
++    d->objectName = objectName();
+ #endif
++
+     pthread_t threadId;
+     int code = pthread_create(&threadId, &attr, QThreadPrivate::start, this);
+     if (code == EPERM) {
+diff --git a/qtbase/src/corelib/thread/qthread_win.cpp b/qtbase/src/corelib/thread/qthread_win.cpp
+index bc70e3178a..4e76972498 100644
+--- a/qtbase/src/corelib/thread/qthread_win.cpp
++++ b/qtbase/src/corelib/thread/qthread_win.cpp
+@@ -394,10 +394,9 @@ unsigned int __stdcall QT_ENSURE_STACK_ALIGNED_FOR_SSE QThreadPrivate::start(voi
+ 
+ #if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) && !defined(Q_OS_WINRT)
+     // sets the name of the current thread.
+-    QByteArray objectName = thr->objectName().toLocal8Bit();
+-    qt_set_thread_name(HANDLE(-1),
+-                       objectName.isEmpty() ?
+-                       thr->metaObject()->className() : objectName.constData());
++    qt_set_thread_name(HANDLE(-1), thr->d_func()->objectName.isEmpty()
++                        ? thr->metaObject()->className()
++                        : std::exchange(thr->d_func()->objectName, {}).toLocal8Bit().constData());
+ #endif
+ 
+     emit thr->started(QThread::QPrivateSignal());
+@@ -503,6 +502,7 @@ void QThread::start(Priority priority)
+     if (d->running)
+         return;
+ 
++    d->objectName = objectName();
+     d->running = true;
+     d->finished = false;
+     d->exited = false;
+@@ -548,7 +548,7 @@ void QThread::start(Priority priority)
+ 
+     int prio;
+     d->priority = priority;
+-    switch (d->priority) {
++    switch (priority) {
+     case IdlePriority:
+         prio = THREAD_PRIORITY_IDLE;
+         break;
+@@ -686,7 +686,7 @@ void QThreadPrivate::setPriority(QThread::Priority threadPriority)
+ 
+     int prio;
+     priority = threadPriority;
+-    switch (priority) {
++    switch (threadPriority) {
+     case QThread::IdlePriority:
+         prio = THREAD_PRIORITY_IDLE;
+         break;
+diff --git a/qtbase/src/corelib/thread/qtsan_impl.h b/qtbase/src/corelib/thread/qtsan_impl.h
+new file mode 100644
+index 0000000000..580a738b91
+--- /dev/null
++++ b/qtbase/src/corelib/thread/qtsan_impl.h
+@@ -0,0 +1,115 @@
++/****************************************************************************
++**
++** Copyright (C) 2017 Intel Corporation.
++** Copyright (C) 2022 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
++** 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 QTSAN_IMPL_H
++#define QTSAN_IMPL_H
++
++#include <QtCore/qglobal.h>
++
++#if (__has_feature(thread_sanitizer) || defined(__SANITIZE_THREAD__)) && __has_include(<sanitizer/tsan_interface.h>)
++#  define QT_BUILDING_UNDER_TSAN
++#  include <sanitizer/tsan_interface.h>
++#endif
++
++QT_BEGIN_NAMESPACE
++
++namespace QtTsan {
++#ifdef QT_BUILDING_UNDER_TSAN
++inline void futexAcquire(void *addr, void *addr2 = nullptr)
++{
++    // A futex call ensures total ordering on the futex words
++    // (in either success or failure of the call). Instruct TSAN accordingly,
++    // as TSAN does not understand the futex(2) syscall (or equivalent).
++    ::__tsan_acquire(addr);
++    if (addr2)
++        ::__tsan_acquire(addr2);
++}
++
++inline void futexRelease(void *addr, void *addr2 = nullptr)
++{
++    if (addr2)
++        ::__tsan_release(addr2);
++    ::__tsan_release(addr);
++}
++
++inline void mutexPreLock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_pre_lock(addr, flags);
++}
++
++inline void mutexPostLock(void *addr, unsigned flags, int recursion)
++{
++    ::__tsan_mutex_post_lock(addr, flags, recursion);
++}
++
++inline void mutexPreUnlock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_pre_unlock(addr, flags);
++}
++
++inline void mutexPostUnlock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_post_unlock(addr, flags);
++}
++
++enum : unsigned {
++    MutexWriteReentrant = ::__tsan_mutex_write_reentrant,
++    TryLock = ::__tsan_mutex_try_lock,
++    TryLockFailed = ::__tsan_mutex_try_lock_failed,
++};
++#else
++inline void futexAcquire(void *, void * = nullptr) {}
++inline void futexRelease(void *, void * = nullptr) {}
++
++enum : unsigned {
++    MutexWriteReentrant,
++    TryLock,
++    TryLockFailed,
++};
++inline void mutexPreLock(void *, unsigned) {}
++inline void mutexPostLock(void *, unsigned, int) {}
++inline void mutexPreUnlock(void *, unsigned) {}
++inline void mutexPostUnlock(void *, unsigned) {}
++#endif // QT_BUILDING_UNDER_TSAN
++} // namespace QtTsan
++
++QT_END_NAMESPACE
++
++#endif // QTSAN_IMPL_H
+diff --git a/qtbase/src/corelib/thread/qwaitcondition_unix.cpp b/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
+index 88b058f410..0f1da4dc9b 100644
+--- a/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
++++ b/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
+@@ -213,7 +213,7 @@ bool QWaitCondition::wait(QMutex *mutex, QDeadlineTimer deadline)
+ {
+     if (! mutex)
+         return false;
+-    if (mutex->isRecursive()) {
++    if (static_cast<QBasicMutex *>(mutex)->isRecursive()) {
+         qWarning("QWaitCondition: cannot wait on recursive mutexes");
+         return false;
+     }
+diff --git a/qtbase/src/corelib/time/qdatetime.cpp b/qtbase/src/corelib/time/qdatetime.cpp
+index ec12569e3f..2c0b098079 100644
+--- a/qtbase/src/corelib/time/qdatetime.cpp
++++ b/qtbase/src/corelib/time/qdatetime.cpp
+@@ -43,6 +43,7 @@
+ #if QT_CONFIG(datetimeparser)
+ #include "private/qdatetimeparser_p.h"
+ #endif
++#include <private/qnumeric_p.h>
+ 
+ #include "qdatastream.h"
+ #include "qset.h"
+@@ -1429,9 +1430,11 @@ QDate QDate::addDays(qint64 ndays) const
+     if (isNull())
+         return QDate();
+ 
+-    // Due to limits on minJd() and maxJd() we know that any overflow
+-    // will be invalid and caught by fromJulianDay().
+-    return fromJulianDay(jd + ndays);
++    qint64 r;
++    if (Q_UNLIKELY(add_overflow(jd, ndays, &r)))
++        return QDate();
++    else
++        return fromJulianDay(r);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/corelib/time/qtimezone.cpp b/qtbase/src/corelib/time/qtimezone.cpp
+index 0309e43e52..3d451696a1 100644
+--- a/qtbase/src/corelib/time/qtimezone.cpp
++++ b/qtbase/src/corelib/time/qtimezone.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2013 John Layt <jlayt@kde.org>
++** Copyright (C) 2020 John Layt <jlayt@kde.org>
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtCore module of the Qt Toolkit.
+@@ -975,9 +975,15 @@ QList<QByteArray> QTimeZone::windowsIdToIanaIds(const QByteArray &windowsId,
+ }
+ 
+ #ifndef QT_NO_DATASTREAM
++// Invalid, as an IANA ID: too long, starts with - and has other invalid characters in it
++static inline QString invalidId() { return QStringLiteral("-No Time Zone Specified!"); }
++
+ QDataStream &operator<<(QDataStream &ds, const QTimeZone &tz)
+ {
+-    tz.d->serialize(ds);
++    if (tz.isValid())
++        tz.d->serialize(ds);
++    else
++        ds << invalidId();
+     return ds;
+ }
+ 
+@@ -985,7 +991,9 @@ QDataStream &operator>>(QDataStream &ds, QTimeZone &tz)
+ {
+     QString ianaId;
+     ds >> ianaId;
+-    if (ianaId == QLatin1String("OffsetFromUtc")) {
++    if (ianaId == invalidId()) {
++        tz = QTimeZone();
++    } else if (ianaId == QLatin1String("OffsetFromUtc")) {
+         int utcOffset;
+         QString name;
+         QString abbreviation;
+diff --git a/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp b/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
+index b1611d7ddb..a7a6a72ccf 100644
+--- a/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
++++ b/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
+@@ -42,6 +42,7 @@
+ #include "qtimezone.h"
+ #include "qtimezoneprivate_p.h"
+ #include "private/qlocale_tools_p.h"
++#include "private/qlocking_p.h"
+ 
+ #include <QtCore/QDataStream>
+ #include <QtCore/QDateTime>
+@@ -62,6 +63,10 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++#if QT_CONFIG(icu)
++static QBasicMutex s_icu_mutex;
++#endif
++
+ /*
+     Private
+ 
+@@ -670,6 +675,9 @@ QTzTimeZonePrivate::~QTzTimeZonePrivate()
+ 
+ QTzTimeZonePrivate *QTzTimeZonePrivate::clone() const
+ {
++#if QT_CONFIG(icu)
++    const auto lock = qt_scoped_lock(s_icu_mutex);
++#endif
+     return new QTzTimeZonePrivate(*this);
+ }
+ 
+@@ -913,12 +921,14 @@ QString QTzTimeZonePrivate::displayName(qint64 atMSecsSinceEpoch,
+                                         const QLocale &locale) const
+ {
+ #if QT_CONFIG(icu)
++    auto lock = qt_unique_lock(s_icu_mutex);
+     if (!m_icu)
+         m_icu = new QIcuTimeZonePrivate(m_id);
+     // TODO small risk may not match if tran times differ due to outdated files
+     // TODO Some valid TZ names are not valid ICU names, use translation table?
+     if (m_icu->isValid())
+         return m_icu->displayName(atMSecsSinceEpoch, nameType, locale);
++    lock.unlock();
+ #else
+     Q_UNUSED(nameType)
+     Q_UNUSED(locale)
+@@ -932,12 +942,14 @@ QString QTzTimeZonePrivate::displayName(QTimeZone::TimeType timeType,
+                                         const QLocale &locale) const
+ {
+ #if QT_CONFIG(icu)
++    auto lock = qt_unique_lock(s_icu_mutex);
+     if (!m_icu)
+         m_icu = new QIcuTimeZonePrivate(m_id);
+     // TODO small risk may not match if tran times differ due to outdated files
+     // TODO Some valid TZ names are not valid ICU names, use translation table?
+     if (m_icu->isValid())
+         return m_icu->displayName(timeType, nameType, locale);
++    lock.unlock();
+ #else
+     Q_UNUSED(timeType)
+     Q_UNUSED(nameType)
+diff --git a/qtbase/src/corelib/tools/qarraydata.h b/qtbase/src/corelib/tools/qarraydata.h
+index dcd95924c1..d01739e7e6 100644
+--- a/qtbase/src/corelib/tools/qarraydata.h
++++ b/qtbase/src/corelib/tools/qarraydata.h
+@@ -42,6 +42,7 @@
+ 
+ #include <QtCore/qrefcount.h>
+ #include <string.h>
++#include <cstdint>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -58,14 +59,14 @@ struct Q_CORE_EXPORT QArrayData
+     {
+         Q_ASSERT(size == 0
+                 || offset < 0 || size_t(offset) >= sizeof(QArrayData));
+-        return reinterpret_cast<char *>(this) + offset;
++        return reinterpret_cast<void *> (reinterpret_cast<uintptr_t>(this) + offset);
+     }
+ 
+     const void *data() const
+     {
+         Q_ASSERT(size == 0
+                 || offset < 0 || size_t(offset) >= sizeof(QArrayData));
+-        return reinterpret_cast<const char *>(this) + offset;
++        return reinterpret_cast<void *> (reinterpret_cast<uintptr_t>(this) + offset);
+     }
+ 
+     // This refers to array data mutability, not "header data" represented by
+diff --git a/qtbase/src/corelib/tools/qfreelist_p.h b/qtbase/src/corelib/tools/qfreelist_p.h
+index 5ba23b344b..9974102136 100644
+--- a/qtbase/src/corelib/tools/qfreelist_p.h
++++ b/qtbase/src/corelib/tools/qfreelist_p.h
+@@ -161,7 +161,7 @@ class QFreeList
+                 return i;
+             x -= size;
+         }
+-        Q_ASSERT(false);
++        Q_UNREACHABLE();
+         return -1;
+     }
+ 
+diff --git a/qtbase/src/corelib/tools/qversionnumber.h b/qtbase/src/corelib/tools/qversionnumber.h
+index d43b86ba51..2843f2b043 100644
+--- a/qtbase/src/corelib/tools/qversionnumber.h
++++ b/qtbase/src/corelib/tools/qversionnumber.h
+@@ -273,10 +273,10 @@ public:
+ 
+     Q_REQUIRED_RESULT Q_CORE_EXPORT QString toString() const;
+ #if QT_STRINGVIEW_LEVEL < 2
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(const QString &string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(const QString &string, int *suffixIndex = nullptr);
+ #endif
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QLatin1String string, int *suffixIndex = nullptr);
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QStringView string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(QLatin1String string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(QStringView string, int *suffixIndex = nullptr);
+ 
+ private:
+ #ifndef QT_NO_DATASTREAM
+diff --git a/qtbase/src/dbus/qdbusintegrator.cpp b/qtbase/src/dbus/qdbusintegrator.cpp
+index 5b66ce971b..28a3b0ffea 100644
+--- a/qtbase/src/dbus/qdbusintegrator.cpp
++++ b/qtbase/src/dbus/qdbusintegrator.cpp
+@@ -1135,7 +1135,13 @@ void QDBusConnectionPrivate::closeConnection()
+         }
+     }
+ 
+-    qDeleteAll(pendingCalls);
++    for (auto it = pendingCalls.begin(); it != pendingCalls.end(); ++it) {
++        auto call = *it;
++        if (!call->ref.deref()) {
++            delete call;
++        }
++    }
++    pendingCalls.clear();
+ 
+     // Disconnect all signals from signal hooks and from the object tree to
+     // avoid QObject::destroyed being sent to dbus daemon thread which has
+@@ -2584,6 +2590,11 @@ QDBusConnectionPrivate::findMetaObject(const QString &service, const QString &pa
+         if (mo)
+             return mo;
+     }
++    if (path.isEmpty()) {
++        error = QDBusError(QDBusError::InvalidObjectPath, QLatin1String("Object path cannot be empty"));
++        lastError = error;
++        return nullptr;
++    }
+ 
+     // introspect the target object
+     QDBusMessage msg = QDBusMessage::createMethodCall(service, path,
+diff --git a/qtbase/src/dbus/qdbusmetaobject.cpp b/qtbase/src/dbus/qdbusmetaobject.cpp
+index 5265568f42..7e9f0f1acc 100644
+--- a/qtbase/src/dbus/qdbusmetaobject.cpp
++++ b/qtbase/src/dbus/qdbusmetaobject.cpp
+@@ -210,6 +210,9 @@ QDBusMetaObjectGenerator::findType(const QByteArray &signature,
+         } else if (signature == "a{ss}") {
+             result.name = "QMap<QString,QString>";
+             type = qMetaTypeId<QMap<QString, QString> >();
++        } else if (signature == "aay") {
++            result.name = "QByteArrayList";
++            type = qMetaTypeId<QByteArrayList>();
+         } else {
+             result.name = "{D-Bus type \"" + signature + "\"}";
+             type = registerComplexDBusType(result.name);
+diff --git a/qtbase/src/gui/accessible/qaccessible.cpp b/qtbase/src/gui/accessible/qaccessible.cpp
+index d705bfccb5..0caf3c808c 100644
+--- a/qtbase/src/gui/accessible/qaccessible.cpp
++++ b/qtbase/src/gui/accessible/qaccessible.cpp
+@@ -54,6 +54,7 @@
+ #include <QtCore/qdebug.h>
+ #include <QtCore/qloggingcategory.h>
+ #include <QtCore/qmetaobject.h>
++#include <QtCore/private/qmetaobject_p.h>
+ #include <QtCore/qhash.h>
+ #include <private/qfactoryloader_p.h>
+ 
+@@ -681,6 +682,25 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
+     // Create a QAccessibleInterface for the object class. Start by the most
+     // derived class and walk up the class hierarchy.
+     const QMetaObject *mo = object->metaObject();
++    const auto *objectPriv = QObjectPrivate::get(object);
++    /*
++     We do not want to cache each and every QML metaobject (Button_QMLTYPE_124,
++     Button_QMLTYPE_125, etc.). Those dynamic metaobjects shouldn't have an
++     accessible interface in any case. Instead, we start the whole checking
++     with the first non-dynamic meta-object. To avoid potential regressions
++     in other areas of Qt that also use dynamic metaobjects, we only do this
++     for objects that are QML-related (approximated by checking whether they
++     have ddata set).
++    */
++    const bool qmlRelated = !objectPriv->isDeletingChildren &&
++                            objectPriv->declarativeData;
++    while (qmlRelated && mo) {
++        auto mop = QMetaObjectPrivate::get(mo);
++        if (!mop || !(mop->flags & DynamicMetaObject))
++            break;
++
++        mo = mo->superClass();
++    };
+     while (mo) {
+         const QString cn = QLatin1String(mo->className());
+ 
+@@ -696,14 +716,15 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
+         // Find a QAccessiblePlugin (factory) for the class name. If there's
+         // no entry in the cache try to create it using the plugin loader.
+         if (!qAccessiblePlugins()->contains(cn)) {
++            QAccessiblePlugin *factory = nullptr; // 0 means "no plugin found". This is cached as well.
+             const int index = loader()->indexOf(cn);
+-            if (index != -1) {
+-                QAccessiblePlugin *factory = qobject_cast<QAccessiblePlugin *>(loader()->instance(index));
+-                qAccessiblePlugins()->insert(cn, factory);
+-            }
++            if (index != -1)
++                factory = qobject_cast<QAccessiblePlugin *>(loader()->instance(index));
++            qAccessiblePlugins()->insert(cn, factory);
+         }
+ 
+         // At this point the cache should contain a valid factory pointer or 0:
++        Q_ASSERT(qAccessiblePlugins()->contains(cn));
+         QAccessiblePlugin *factory = qAccessiblePlugins()->value(cn);
+         if (factory) {
+             QAccessibleInterface *result = factory->create(cn, object);
+diff --git a/qtbase/src/gui/configure.json b/qtbase/src/gui/configure.json
+index 1f08795c57..12c95742d2 100644
+--- a/qtbase/src/gui/configure.json
++++ b/qtbase/src/gui/configure.json
+@@ -834,7 +834,8 @@
+                     "// embedded devices, are not intended to be used together with X. EGL support",
+                     "// has to be disabled in plugins like xcb in this case since the native display,",
+                     "// window and pixmap types will be different than what an X-based platform",
+-                    "// plugin would expect."
++                    "// plugin would expect.",
++                    "#define USE_X11"
+                 ],
+                 "include": [ "EGL/egl.h", "X11/Xlib.h" ],
+                 "main": [
+diff --git a/qtbase/src/gui/image/qbmphandler.cpp b/qtbase/src/gui/image/qbmphandler.cpp
+index 96f1e8cb1d..0e73bbbdb0 100644
+--- a/qtbase/src/gui/image/qbmphandler.cpp
++++ b/qtbase/src/gui/image/qbmphandler.cpp
+@@ -150,16 +150,42 @@ static QDataStream &operator<<(QDataStream &s, const BMP_INFOHDR &bi)
+     return s;
+ }
+ 
+-static int calc_shift(uint mask)
++static uint calc_shift(uint mask)
+ {
+-    int result = 0;
+-    while (mask && !(mask & 1)) {
++    uint result = 0;
++    while ((mask >= 0x100) || (!(mask & 1) && mask)) {
+         result++;
+         mask >>= 1;
+     }
+     return result;
+ }
+ 
++static uint calc_scale(uint low_mask)
++{
++    uint result = 8;
++    while (low_mask && result) {
++        result--;
++        low_mask >>= 1;
++    }
++    return result;
++}
++
++static inline uint apply_scale(uint value, uint scale)
++{
++    if (!(scale & 0x07)) // return immediately if scale == 8 or 0
++        return value;
++
++    uint filled = 8 - scale;
++    uint result = value << scale;
++
++    do {
++        result |= result >> filled;
++        filled <<= 1;
++    } while (filled < 8);
++
++    return result;
++}
++
+ static bool read_dib_fileheader(QDataStream &s, BMP_FILEHDR &bf)
+ {
+     // read BMP file header
+@@ -222,14 +248,14 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+     uint green_mask = 0;
+     uint blue_mask = 0;
+     uint alpha_mask = 0;
+-    int red_shift = 0;
+-    int green_shift = 0;
+-    int blue_shift = 0;
+-    int alpha_shift = 0;
+-    int red_scale = 0;
+-    int green_scale = 0;
+-    int blue_scale = 0;
+-    int alpha_scale = 0;
++    uint red_shift = 0;
++    uint green_shift = 0;
++    uint blue_shift = 0;
++    uint alpha_shift = 0;
++    uint red_scale = 0;
++    uint green_scale = 0;
++    uint blue_scale = 0;
++    uint alpha_scale = 0;
+ 
+     if (!d->isSequential())
+         d->seek(startpos + BMP_FILEHDR_SIZE + bi.biSize); // goto start of colormap or masks
+@@ -308,19 +334,19 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+         red_shift = calc_shift(red_mask);
+         if (((red_mask >> red_shift) + 1) == 0)
+             return false;
+-        red_scale = 256 / ((red_mask >> red_shift) + 1);
++        red_scale = calc_scale(red_mask >> red_shift);
+         green_shift = calc_shift(green_mask);
+         if (((green_mask >> green_shift) + 1) == 0)
+             return false;
+-        green_scale = 256 / ((green_mask >> green_shift) + 1);
++        green_scale = calc_scale(green_mask >> green_shift);
+         blue_shift = calc_shift(blue_mask);
+         if (((blue_mask >> blue_shift) + 1) == 0)
+             return false;
+-        blue_scale = 256 / ((blue_mask >> blue_shift) + 1);
++        blue_scale = calc_scale(blue_mask >> blue_shift);
+         alpha_shift = calc_shift(alpha_mask);
+         if (((alpha_mask >> alpha_shift) + 1) == 0)
+             return false;
+-        alpha_scale = 256 / ((alpha_mask >> alpha_shift) + 1);
++        alpha_scale = calc_scale(alpha_mask >> alpha_shift);
+     } else if (comp == BMP_RGB && (nbits == 24 || nbits == 32)) {
+         blue_mask = 0x000000ff;
+         green_mask = 0x0000ff00;
+@@ -328,17 +354,15 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+         blue_shift = 0;
+         green_shift = 8;
+         red_shift = 16;
+-        blue_scale = green_scale = red_scale = 1;
++        blue_scale = green_scale = red_scale = 0;
+     } else if (comp == BMP_RGB && nbits == 16) {
+         blue_mask = 0x001f;
+         green_mask = 0x03e0;
+         red_mask = 0x7c00;
+         blue_shift = 0;
+-        green_shift = 2;
+-        red_shift = 7;
+-        red_scale = 1;
+-        green_scale = 1;
+-        blue_scale = 8;
++        green_shift = 5;
++        red_shift = 10;
++        blue_scale = green_scale = red_scale = 3;
+     }
+ 
+ #if 0
+@@ -544,10 +568,10 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+                     c |= *(uchar*)(b+2)<<16;
+                 if (nbits > 24)
+                     c |= *(uchar*)(b+3)<<24;
+-                *p++ = qRgba(((c & red_mask) >> red_shift) * red_scale,
+-                                        ((c & green_mask) >> green_shift) * green_scale,
+-                                        ((c & blue_mask) >> blue_shift) * blue_scale,
+-                                        transp ? ((c & alpha_mask) >> alpha_shift) * alpha_scale : 0xff);
++                *p++ = qRgba(apply_scale((c & red_mask) >> red_shift, red_scale),
++                             apply_scale((c & green_mask) >> green_shift, green_scale),
++                             apply_scale((c & blue_mask) >> blue_shift, blue_scale),
++                             transp ? apply_scale((c & alpha_mask) >> alpha_shift, alpha_scale) : 0xff);
+                 b += nbits/8;
+             }
+         }
+diff --git a/qtbase/src/gui/image/qimage.cpp b/qtbase/src/gui/image/qimage.cpp
+index 7152ac1607..0df772564c 100644
+--- a/qtbase/src/gui/image/qimage.cpp
++++ b/qtbase/src/gui/image/qimage.cpp
+@@ -4694,6 +4694,8 @@ QImage QImage::smoothScaled(int w, int h) const {
+ static QImage rotated90(const QImage &image)
+ {
+     QImage out(image.height(), image.width(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+@@ -4722,6 +4724,8 @@ static QImage rotated180(const QImage &image)
+         return image.mirrored(true, true);
+ 
+     QImage out(image.width(), image.height(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+@@ -4734,6 +4738,8 @@ static QImage rotated180(const QImage &image)
+ static QImage rotated270(const QImage &image)
+ {
+     QImage out(image.height(), image.width(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+diff --git a/qtbase/src/gui/kernel/qcursor.cpp b/qtbase/src/gui/kernel/qcursor.cpp
+index d6ccaff8ed..455088241c 100644
+--- a/qtbase/src/gui/kernel/qcursor.cpp
++++ b/qtbase/src/gui/kernel/qcursor.cpp
+@@ -251,7 +251,8 @@ void QCursor::setPos(QScreen *screen, int x, int y)
+ {
+     if (screen) {
+         if (QPlatformCursor *cursor = screen->handle()->cursor()) {
+-            const QPoint devicePos = QHighDpi::toNativePixels(QPoint(x, y), screen);
++            const QPoint pos(x, y);
++            const QPoint devicePos = QHighDpi::toNativePixels(pos, screen->virtualSiblingAt(pos));
+             // Need to check, since some X servers generate null mouse move
+             // events, causing looping in applications which call setPos() on
+             // every mouse move event.
+diff --git a/qtbase/src/gui/kernel/qhighdpiscaling.cpp b/qtbase/src/gui/kernel/qhighdpiscaling.cpp
+index 9bbf2773a9..3ac4a4d8b6 100644
+--- a/qtbase/src/gui/kernel/qhighdpiscaling.cpp
++++ b/qtbase/src/gui/kernel/qhighdpiscaling.cpp
+@@ -580,9 +580,8 @@ void QHighDpiScaling::setScreenFactor(QScreen *screen, qreal factor)
+     else
+         qNamedScreenScaleFactors()->insert(name, factor);
+ 
+-    // hack to force re-evaluation of screen geometry
+     if (screen->handle())
+-        screen->d_func()->setPlatformScreen(screen->handle()); // updates geometries based on scale factor
++        screen->d_func()->updateLogicalDpi();
+ }
+ 
+ QPoint QHighDpiScaling::mapPositionToNative(const QPoint &pos, const QPlatformScreen *platformScreen)
+diff --git a/qtbase/src/gui/kernel/qkeysequence.cpp b/qtbase/src/gui/kernel/qkeysequence.cpp
+index a75b8ef920..4f2d294739 100644
+--- a/qtbase/src/gui/kernel/qkeysequence.cpp
++++ b/qtbase/src/gui/kernel/qkeysequence.cpp
+@@ -701,6 +701,10 @@ static const struct {
+     { Qt::Key_TouchpadToggle,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad Toggle") },
+     { Qt::Key_TouchpadOn,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad On") },
+     { Qt::Key_TouchpadOff,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad Off") },
++    { Qt::Key_Shift,  QT_TRANSLATE_NOOP("QShortcut", "Shift") },
++    { Qt::Key_Control,  QT_TRANSLATE_NOOP("QShortcut", "Control") },
++    { Qt::Key_Alt,  QT_TRANSLATE_NOOP("QShortcut", "Alt") },
++    { Qt::Key_Meta,  QT_TRANSLATE_NOOP("QShortcut", "Meta") },
+ 
+ };
+ static Q_CONSTEXPR int numKeyNames = sizeof keyname / sizeof *keyname;
+diff --git a/qtbase/src/gui/kernel/qplatformservices.cpp b/qtbase/src/gui/kernel/qplatformservices.cpp
+index fdc6a6c4aa..ac47f98c5d 100644
+--- a/qtbase/src/gui/kernel/qplatformservices.cpp
++++ b/qtbase/src/gui/kernel/qplatformservices.cpp
+@@ -55,6 +55,19 @@ QT_BEGIN_NAMESPACE
+     \brief The QPlatformServices provides the backend for desktop-related functionality.
+ */
+ 
++/*!
++    \enum QPlatformServices::Capability
++
++    Capabilities are used to determine a specific platform service's availability.
++
++    \value ColorPickingFromScreen The platform natively supports color picking from screen.
++    This capability indicates that the platform supports "opaque" color picking, where the
++    platform implements a complete user experience for color picking and outputs a color.
++    This is in contrast to the application implementing the color picking user experience
++    (taking care of showing a cross hair, instructing the platform integration to obtain
++    the color at a given pixel, etc.). The related service function is pickColor().
++ */
++
+ QPlatformServices::QPlatformServices()
+ { }
+ 
+@@ -85,5 +98,16 @@ QByteArray QPlatformServices::desktopEnvironment() const
+     return QByteArray("UNKNOWN");
+ }
+ 
++QPlatformServiceColorPicker *QPlatformServices::colorPicker(QWindow *parent)
++{
++    Q_UNUSED(parent);
++    return nullptr;
++}
++
++bool QPlatformServices::hasCapability(Capability capability) const
++{
++    Q_UNUSED(capability)
++    return false;
++}
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/gui/kernel/qplatformservices.h b/qtbase/src/gui/kernel/qplatformservices.h
+index 5de96cfa7d..a8b2a4ce71 100644
+--- a/qtbase/src/gui/kernel/qplatformservices.h
++++ b/qtbase/src/gui/kernel/qplatformservices.h
+@@ -50,16 +50,32 @@
+ //
+ 
+ #include <QtGui/qtguiglobal.h>
++#include <QtCore/qobject.h>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+ class QUrl;
++class QWindow;
++
++class Q_GUI_EXPORT QPlatformServiceColorPicker : public QObject
++{
++    Q_OBJECT
++public:
++    using QObject::QObject;
++    virtual void pickColor() = 0;
++Q_SIGNALS:
++    void colorPicked(const QColor &color);
++};
+ 
+ class Q_GUI_EXPORT QPlatformServices
+ {
+ public:
+     Q_DISABLE_COPY_MOVE(QPlatformServices)
+ 
++    enum Capability {
++        ColorPicking,
++    };
++
+     QPlatformServices();
+     virtual ~QPlatformServices() { }
+ 
+@@ -67,6 +83,10 @@ public:
+     virtual bool openDocument(const QUrl &url);
+ 
+     virtual QByteArray desktopEnvironment() const;
++
++    virtual bool hasCapability(Capability capability) const;
++
++    virtual QPlatformServiceColorPicker *colorPicker(QWindow *parent = nullptr);
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/gui/kernel/qplatformtheme.cpp b/qtbase/src/gui/kernel/qplatformtheme.cpp
+index 71521c0339..2325873245 100644
+--- a/qtbase/src/gui/kernel/qplatformtheme.cpp
++++ b/qtbase/src/gui/kernel/qplatformtheme.cpp
+@@ -163,6 +163,8 @@ QT_BEGIN_NAMESPACE
+ 
+     \value ShowShortcutsInContextMenus (bool) Whether to display shortcut key sequences in context menus.
+ 
++    \value ButtonPressKeys (QList<Qt::Key>) A list of keys that can be used to press buttons via keyboard input.
++
+     \sa themeHint(), QStyle::pixelMetric()
+ */
+ 
+@@ -563,6 +565,8 @@ QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint)
+         }
+     case MouseQuickSelectionThreshold:
+         return QVariant(10);
++    case ButtonPressKeys:
++        return QVariant::fromValue(QList<Qt::Key>({ Qt::Key_Space, Qt::Key_Select }));
+     }
+     return QVariant();
+ }
+diff --git a/qtbase/src/gui/kernel/qplatformtheme.h b/qtbase/src/gui/kernel/qplatformtheme.h
+index 3185fc4541..7e6c9d5740 100644
+--- a/qtbase/src/gui/kernel/qplatformtheme.h
++++ b/qtbase/src/gui/kernel/qplatformtheme.h
+@@ -120,7 +120,8 @@ public:
+         TouchDoubleTapDistance,
+         ShowShortcutsInContextMenus,
+         IconFallbackSearchPaths,
+-        MouseQuickSelectionThreshold
++        MouseQuickSelectionThreshold,
++        ButtonPressKeys
+     };
+ 
+     enum DialogType {
+diff --git a/qtbase/src/gui/kernel/qscreen.cpp b/qtbase/src/gui/kernel/qscreen.cpp
+index 8e0eb35116..5d172a58dd 100644
+--- a/qtbase/src/gui/kernel/qscreen.cpp
++++ b/qtbase/src/gui/kernel/qscreen.cpp
+@@ -77,6 +77,12 @@ QScreen::QScreen(QPlatformScreen *screen)
+     d->setPlatformScreen(screen);
+ }
+ 
++void QScreenPrivate::updateLogicalDpi()
++{
++    logicalDpi = QPlatformScreen::overrideDpi(platformScreen->logicalDpi());
++    updateGeometriesWithSignals(); // updates geometries based on scale factor
++}
++
+ void QScreenPrivate::updateGeometriesWithSignals()
+ {
+     const QRect oldGeometry = geometry;
+diff --git a/qtbase/src/gui/kernel/qscreen_p.h b/qtbase/src/gui/kernel/qscreen_p.h
+index 7da542c25e..e50fc3190b 100644
+--- a/qtbase/src/gui/kernel/qscreen_p.h
++++ b/qtbase/src/gui/kernel/qscreen_p.h
+@@ -70,6 +70,7 @@ public:
+         geometry = platformScreen->deviceIndependentGeometry();
+         availableGeometry = QHighDpi::fromNative(platformScreen->availableGeometry(), QHighDpiScaling::factor(platformScreen), geometry.topLeft());
+     }
++    void updateLogicalDpi();
+ 
+     void updatePrimaryOrientation();
+     void updateGeometriesWithSignals();
+diff --git a/qtbase/src/gui/painting/qblendfunctions_p.h b/qtbase/src/gui/painting/qblendfunctions_p.h
+index 080da98ec4..6997d62b3c 100644
+--- a/qtbase/src/gui/painting/qblendfunctions_p.h
++++ b/qtbase/src/gui/painting/qblendfunctions_p.h
+@@ -246,25 +246,32 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+                                   int dudx, int dvdx, int dudy, int dvdy, int u0, int v0,
+                                   Blender blender)
+ {
+-    int fromY = qMax(qRound(topY), clip.top());
+-    int toY = qMin(qRound(bottomY), clip.top() + clip.height());
++    qint64 fromY = qMax(qRound(topY), clip.top());
++    qint64 toY = qMin(qRound(bottomY), clip.top() + clip.height());
+     if (fromY >= toY)
+         return;
+ 
+     qreal leftSlope = (bottomLeft.x - topLeft.x) / (bottomLeft.y - topLeft.y);
+     qreal rightSlope = (bottomRight.x - topRight.x) / (bottomRight.y - topRight.y);
+-    int dx_l = int(leftSlope * 0x10000);
+-    int dx_r = int(rightSlope * 0x10000);
+-    int x_l = int((topLeft.x + (qreal(0.5) + fromY - topLeft.y) * leftSlope + qreal(0.5)) * 0x10000);
+-    int x_r = int((topRight.x + (qreal(0.5) + fromY - topRight.y) * rightSlope + qreal(0.5)) * 0x10000);
+-
+-    int fromX, toX, x1, x2, u, v, i, ii;
++    qint64 dx_l = qint64(leftSlope * 0x10000);
++    qint64 dx_r = qint64(rightSlope * 0x10000);
++    qint64 x_l = qint64((topLeft.x + (qreal(0.5) + fromY - topLeft.y) * leftSlope + qreal(0.5)) * 0x10000);
++    qint64 x_r = qint64((topRight.x + (qreal(0.5) + fromY - topRight.y) * rightSlope + qreal(0.5)) * 0x10000);
++
++    qint64 sourceRectTop = qint64(sourceRect.top());
++    qint64 sourceRectLeft = qint64(sourceRect.left());
++    qint64 sourceRectWidth = qint64(sourceRect.width());
++    qint64 sourceRectHeight = qint64(sourceRect.height());
++    qint64 clipLeft = qint64(clip.left());
++    qint64 clipWidth = qint64(clip.width());
++
++    qint64 fromX, toX, x1, x2, u, v, i, ii;
+     DestT *line;
+-    for (int y = fromY; y < toY; ++y) {
++    for (qint64 y = fromY; y < toY; ++y) {
+         line = reinterpret_cast<DestT *>(reinterpret_cast<uchar *>(destPixels) + y * dbpl);
+ 
+-        fromX = qMax(x_l >> 16, clip.left());
+-        toX = qMin(x_r >> 16, clip.left() + clip.width());
++        fromX = qMax(x_l >> 16, clipLeft);
++        toX = qMin(x_r >> 16, clipLeft + clipWidth);
+         if (fromX < toX) {
+             // Because of rounding, we can get source coordinates outside the source image.
+             // Clamp these coordinates to the source rect to avoid segmentation fault and
+@@ -275,10 +282,10 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             u = x1 * dudx + y * dudy + u0;
+             v = x1 * dvdx + y * dvdy + v0;
+             for (; x1 < toX; ++x1) {
+-                int uu = u >> 16;
+-                int vv = v >> 16;
+-                if (uu >= sourceRect.left() && uu < sourceRect.left() + sourceRect.width()
+-                    && vv >= sourceRect.top() && vv < sourceRect.top() + sourceRect.height()) {
++                qint64 uu = u >> 16;
++                qint64 vv = v >> 16;
++                if (uu >= sourceRectLeft && uu < sourceRectLeft + sourceRectWidth
++                    && vv >= sourceRectTop && vv < sourceRectTop + sourceRectHeight) {
+                     break;
+                 }
+                 u += dudx;
+@@ -290,10 +297,10 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             u = (x2 - 1) * dudx + y * dudy + u0;
+             v = (x2 - 1) * dvdx + y * dvdy + v0;
+             for (; x2 > x1; --x2) {
+-                int uu = u >> 16;
+-                int vv = v >> 16;
+-                if (uu >= sourceRect.left() && uu < sourceRect.left() + sourceRect.width()
+-                    && vv >= sourceRect.top() && vv < sourceRect.top() + sourceRect.height()) {
++                qint64 uu = u >> 16;
++                qint64 vv = v >> 16;
++                if (uu >= sourceRectLeft && uu < sourceRectLeft + sourceRectWidth
++                    && vv >= sourceRectTop && vv < sourceRectTop + sourceRectHeight) {
+                     break;
+                 }
+                 u -= dudx;
+@@ -308,8 +315,8 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             // Beginning of the scan line, with per-pixel checks.
+             i = x1 - fromX;
+             while (i) {
+-                int uu = qBound(sourceRect.left(), u >> 16, sourceRect.left() + sourceRect.width() - 1);
+-                int vv = qBound(sourceRect.top(), v >> 16, sourceRect.top() + sourceRect.height() - 1);
++                qint64 uu = qBound(sourceRectLeft, u >> 16, sourceRectLeft + sourceRectWidth - 1);
++                qint64 vv = qBound(sourceRectTop, v >> 16, sourceRectTop + sourceRectHeight - 1);
+                 blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + vv * sbpl)[uu]);
+                 u += dudx;
+                 v += dvdx;
+@@ -348,8 +355,8 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             // End of the scan line, with per-pixel checks.
+             i = toX - x2;
+             while (i) {
+-                int uu = qBound(sourceRect.left(), u >> 16, sourceRect.left() + sourceRect.width() - 1);
+-                int vv = qBound(sourceRect.top(), v >> 16, sourceRect.top() + sourceRect.height() - 1);
++                qint64 uu = qBound(sourceRectLeft, u >> 16, sourceRectLeft + sourceRectWidth - 1);
++                qint64 vv = qBound(sourceRectTop, v >> 16, sourceRectTop + sourceRectHeight - 1);
+                 blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + vv * sbpl)[uu]);
+                 u += dudx;
+                 v += dvdx;
+diff --git a/qtbase/src/gui/painting/qcolortrclut_p.h b/qtbase/src/gui/painting/qcolortrclut_p.h
+index 76a6a60803..24fd522e6c 100644
+--- a/qtbase/src/gui/painting/qcolortrclut_p.h
++++ b/qtbase/src/gui/painting/qcolortrclut_p.h
+@@ -118,6 +118,7 @@ public:
+         return QRgba64::fromRgba64(r, g, b, qAlpha(rgb32) * 257);
+ #endif
+     }
++    QRgba64 toLinear64(QRgba64) const = delete;
+ 
+     QRgb toLinear(QRgb rgb32) const
+     {
+diff --git a/qtbase/src/gui/painting/qdrawhelper.cpp b/qtbase/src/gui/painting/qdrawhelper.cpp
+index a61793508a..5ba2d277b7 100644
+--- a/qtbase/src/gui/painting/qdrawhelper.cpp
++++ b/qtbase/src/gui/painting/qdrawhelper.cpp
+@@ -6091,7 +6091,7 @@ static inline void alphargbblend_argb32(quint32 *dst, uint coverage, const QRgba
+ static inline void rgbBlendPixel(QRgba64 &dst, int coverage, QRgba64 slinear, const QColorTrcLut *colorProfile)
+ {
+     // Do a gammacorrected RGB alphablend...
+-    const QRgba64 dlinear = colorProfile ? colorProfile->toLinear64(dst) : dst;
++    const QRgba64 dlinear = colorProfile ? colorProfile->toLinear(dst) : dst;
+ 
+     QRgba64 blend = rgbBlend(dlinear, slinear, coverage);
+ 
+diff --git a/qtbase/src/gui/painting/qpaintengine_raster.cpp b/qtbase/src/gui/painting/qpaintengine_raster.cpp
+index 283923de52..f08eb9cbee 100644
+--- a/qtbase/src/gui/painting/qpaintengine_raster.cpp
++++ b/qtbase/src/gui/painting/qpaintengine_raster.cpp
+@@ -560,31 +560,6 @@ void QRasterPaintEngine::updateMatrix(const QTransform &matrix)
+     QRasterPaintEngineState *s = state();
+     // FALCON: get rid of this line, see drawImage call below.
+     s->matrix = matrix;
+-    QTransform::TransformationType txop = s->matrix.type();
+-
+-    switch (txop) {
+-
+-    case QTransform::TxNone:
+-        s->flags.int_xform = true;
+-        break;
+-
+-    case QTransform::TxTranslate:
+-        s->flags.int_xform = qreal(int(s->matrix.dx())) == s->matrix.dx()
+-                            && qreal(int(s->matrix.dy())) == s->matrix.dy();
+-        break;
+-
+-    case QTransform::TxScale:
+-        s->flags.int_xform = qreal(int(s->matrix.dx())) == s->matrix.dx()
+-                            && qreal(int(s->matrix.dy())) == s->matrix.dy()
+-                            && qreal(int(s->matrix.m11())) == s->matrix.m11()
+-                            && qreal(int(s->matrix.m22())) == s->matrix.m22();
+-        break;
+-
+-    default: // shear / perspective...
+-        s->flags.int_xform = false;
+-        break;
+-    }
+-
+     s->flags.tx_noshear = qt_scaleForTransform(s->matrix, &s->txscale);
+ 
+     ensureOutlineMapper();
+@@ -617,7 +592,6 @@ QRasterPaintEngineState::QRasterPaintEngineState()
+     flags.bilinear = false;
+     flags.legacy_rounding = false;
+     flags.fast_text = true;
+-    flags.int_xform = true;
+     flags.tx_noshear = true;
+     flags.fast_images = true;
+ 
+@@ -1793,7 +1767,7 @@ void QRasterPaintEngine::fill(const QVectorPath &path, const QBrush &brush)
+     QRectF cpRect = path.controlPointRect();
+     const QRectF pathDeviceRect = s->matrix.mapRect(cpRect);
+     // Skip paths that by conservative estimates are completely outside the paint device.
+-    if (!pathDeviceRect.intersects(QRectF(d->deviceRect)))
++    if (!pathDeviceRect.intersects(QRectF(d->deviceRect)) || !pathDeviceRect.isValid())
+         return;
+ 
+     ProcessSpans blend = d->getBrushFunc(pathDeviceRect, &s->brushData);
+diff --git a/qtbase/src/gui/painting/qpaintengine_raster_p.h b/qtbase/src/gui/painting/qpaintengine_raster_p.h
+index 089aadc3f7..bf7363d5aa 100644
+--- a/qtbase/src/gui/painting/qpaintengine_raster_p.h
++++ b/qtbase/src/gui/painting/qpaintengine_raster_p.h
+@@ -111,7 +111,6 @@ public:
+         uint bilinear : 1;
+         uint legacy_rounding : 1;
+         uint fast_text : 1;
+-        uint int_xform : 1;
+         uint tx_noshear : 1;
+         uint fast_images : 1;
+     };
+diff --git a/qtbase/src/gui/painting/qpainterpath.cpp b/qtbase/src/gui/painting/qpainterpath.cpp
+index f9544a3241..d80fafeaf1 100644
+--- a/qtbase/src/gui/painting/qpainterpath.cpp
++++ b/qtbase/src/gui/painting/qpainterpath.cpp
+@@ -1253,7 +1253,7 @@ void QPainterPath::addText(const QPointF &point, const QFont &f, const QString &
+ 
+         if (si.analysis.flags < QScriptAnalysis::TabOrObject) {
+             QGlyphLayout glyphs = eng->shapedGlyphs(&si);
+-            QFontEngine *fe = f.d->engineForScript(si.analysis.script);
++            QFontEngine *fe = eng->fontEngine(si);
+             Q_ASSERT(fe);
+             fe->addOutlineToPath(x, y, glyphs, this,
+                                  si.analysis.bidiLevel % 2
+diff --git a/qtbase/src/gui/painting/qpathclipper_p.h b/qtbase/src/gui/painting/qpathclipper_p.h
+index 9444a87b71..18f64c5e8c 100644
+--- a/qtbase/src/gui/painting/qpathclipper_p.h
++++ b/qtbase/src/gui/painting/qpathclipper_p.h
+@@ -156,7 +156,7 @@ public:
+     int vertex(Direction direction) const;
+ 
+ private:
+-    int m_next[2][2];
++    int m_next[2][2] = { { -1, -1 }, { -1, -1 } };
+ };
+ 
+ class QPathSegments
+@@ -296,10 +296,6 @@ inline QPathEdge::QPathEdge(int a, int b)
+     , angle(0)
+     , invAngle(0)
+ {
+-    m_next[0][0] = -1;
+-    m_next[1][0] = -1;
+-    m_next[0][0] = -1;
+-    m_next[1][0] = -1;
+ }
+ 
+ inline int QPathEdge::next(Traversal traversal, Direction direction) const
+diff --git a/qtbase/src/gui/painting/qpdf.cpp b/qtbase/src/gui/painting/qpdf.cpp
+index 3066744f1b..2c8d3c3b53 100644
+--- a/qtbase/src/gui/painting/qpdf.cpp
++++ b/qtbase/src/gui/painting/qpdf.cpp
+@@ -2760,6 +2760,8 @@ int QPdfEnginePrivate::addBrushPattern(const QTransform &m, bool *specifyColor,
+         return gradientBrush(brush, matrix, gStateObject);
+     }
+ 
++    matrix = brush.transform() * matrix;
++
+     if ((!brush.isOpaque() && brush.style() < Qt::LinearGradientPattern) || opacity != 1.0)
+         *gStateObject = addConstantAlphaObject(qRound(brush.color().alpha() * opacity),
+                                                qRound(pen.color().alpha() * opacity));
+diff --git a/qtbase/src/gui/painting/qstroker.cpp b/qtbase/src/gui/painting/qstroker.cpp
+index cb5d395e80..3b6357a893 100644
+--- a/qtbase/src/gui/painting/qstroker.cpp
++++ b/qtbase/src/gui/painting/qstroker.cpp
+@@ -1182,6 +1182,7 @@ void QDashStroker::processCurrentSubpath()
+         // Check if the entire line should be clipped away or simplified
+         bool clipIt = clipping && !lineIntersectsRect(prev, e, clip_tl, clip_br);
+         bool skipDashing = elen * invSumLength > repetitionLimit();
++        int maxDashes = dashCount;
+         if (skipDashing || clipIt) {
+             // Cut away full dash sequences.
+             elen -= std::floor(elen * invSumLength) * sumLength;
+@@ -1196,7 +1197,7 @@ void QDashStroker::processCurrentSubpath()
+                     pos = estop; // move pos to next path element
+                     done = true;
+                 } else { // Dash is on this line
+-                    pos = dpos + estart;
++                    pos = --maxDashes > 0 ? dpos + estart : estop;
+                     done = pos >= estop;
+                     if (++idash >= dashCount)
+                         idash = 0;
+diff --git a/qtbase/src/gui/painting/qt_attribution.json b/qtbase/src/gui/painting/qt_attribution.json
+index 7b16e8c211..0e87d30aa2 100644
+--- a/qtbase/src/gui/painting/qt_attribution.json
++++ b/qtbase/src/gui/painting/qt_attribution.json
+@@ -10,7 +10,7 @@
+         "Homepage": "http://www.freetype.org",
+         "License": "Freetype Project License or GNU General Public License v2.0 only",
+         "LicenseId": "FTL or GPL-2.0",
+-        "LicenseFile": "../../3rdparty/freetype/docs/LICENSE.TXT",
++        "LicenseFile": "../../3rdparty/freetype/LICENSE.TXT",
+         "Copyright": "Copyright 2000-2016 by David Turner, Robert Wilhelm, and Werner Lemberg."
+     },
+     {
+diff --git a/qtbase/src/gui/rhi/qshader_p_p.h b/qtbase/src/gui/rhi/qshader_p_p.h
+index ec9d25971f..4a5a7a6d51 100644
+--- a/qtbase/src/gui/rhi/qshader_p_p.h
++++ b/qtbase/src/gui/rhi/qshader_p_p.h
+@@ -68,13 +68,13 @@ struct Q_GUI_EXPORT QShaderPrivate
+     {
+     }
+ 
+-    QShaderPrivate(const QShaderPrivate *other)
++    QShaderPrivate(const QShaderPrivate &other)
+         : ref(1),
+-          qsbVersion(other->qsbVersion),
+-          stage(other->stage),
+-          desc(other->desc),
+-          shaders(other->shaders),
+-          bindings(other->bindings)
++          qsbVersion(other.qsbVersion),
++          stage(other.stage),
++          desc(other.desc),
++          shaders(other.shaders),
++          bindings(other.bindings)
+     {
+     }
+ 
+diff --git a/qtbase/src/gui/rhi/qshaderdescription_p_p.h b/qtbase/src/gui/rhi/qshaderdescription_p_p.h
+index ec2b0b6b4c..3da33a8a2b 100644
+--- a/qtbase/src/gui/rhi/qshaderdescription_p_p.h
++++ b/qtbase/src/gui/rhi/qshaderdescription_p_p.h
+@@ -63,16 +63,16 @@ struct Q_GUI_EXPORT QShaderDescriptionPrivate
+         localSize[0] = localSize[1] = localSize[2] = 0;
+     }
+ 
+-    QShaderDescriptionPrivate(const QShaderDescriptionPrivate *other)
++    QShaderDescriptionPrivate(const QShaderDescriptionPrivate &other)
+         : ref(1),
+-          inVars(other->inVars),
+-          outVars(other->outVars),
+-          uniformBlocks(other->uniformBlocks),
+-          pushConstantBlocks(other->pushConstantBlocks),
+-          storageBlocks(other->storageBlocks),
+-          combinedImageSamplers(other->combinedImageSamplers),
+-          storageImages(other->storageImages),
+-          localSize(other->localSize)
++          inVars(other.inVars),
++          outVars(other.outVars),
++          uniformBlocks(other.uniformBlocks),
++          pushConstantBlocks(other.pushConstantBlocks),
++          storageBlocks(other.storageBlocks),
++          combinedImageSamplers(other.combinedImageSamplers),
++          storageImages(other.storageImages),
++          localSize(other.localSize)
+     {
+     }
+ 
+diff --git a/qtbase/src/gui/text/qfontdatabase.cpp b/qtbase/src/gui/text/qfontdatabase.cpp
+index a657a8c516..4fc0100958 100644
+--- a/qtbase/src/gui/text/qfontdatabase.cpp
++++ b/qtbase/src/gui/text/qfontdatabase.cpp
+@@ -983,7 +983,7 @@ QFontEngine *loadSingleEngine(int script,
+         if (style->key.stretch != 0 && request.stretch != 0
+             && (request.styleName.isEmpty() || request.styleName != style->styleName)) {
+             def.stretch = (request.stretch * 100 + style->key.stretch / 2) / style->key.stretch;
+-        } else {
++        } else if (request.stretch == QFont::AnyStretch) {
+             def.stretch = 100;
+         }
+ 
+diff --git a/qtbase/src/gui/text/qtextdocumentlayout.cpp b/qtbase/src/gui/text/qtextdocumentlayout.cpp
+index f3e6ea2100..72267e9380 100644
+--- a/qtbase/src/gui/text/qtextdocumentlayout.cpp
++++ b/qtbase/src/gui/text/qtextdocumentlayout.cpp
+@@ -2123,7 +2123,7 @@ void QTextDocumentLayoutPrivate::drawListItem(const QPointF &offset, QPainter *p
+ {
+     Q_Q(const QTextDocumentLayout);
+     const QTextBlockFormat blockFormat = bl.blockFormat();
+-    const QTextCharFormat charFormat = QTextCursor(bl).charFormat();
++    const QTextCharFormat charFormat = bl.charFormat();
+     QFont font(charFormat.font());
+     if (q->paintDevice())
+         font = QFont(font, q->paintDevice());
+diff --git a/qtbase/src/gui/text/qtextengine.cpp b/qtbase/src/gui/text/qtextengine.cpp
+index ce4abac472..a6c66e5d2d 100644
+--- a/qtbase/src/gui/text/qtextengine.cpp
++++ b/qtbase/src/gui/text/qtextengine.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2021 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtGui module of the Qt Toolkit.
+@@ -1565,6 +1565,12 @@ void QTextEngine::shapeText(int item) const
+         // Overwrite with 0 token to indicate failure
+         QGlyphLayout g = availableGlyphs(&si);
+         g.glyphs[0] = 0;
++        g.attributes[0].clusterStart = true;
++
++        ushort *log_clusters = logClusters(&si);
++        for (int i = 0; i < itemLength; ++i)
++            log_clusters[i] = 0;
++
+         return;
+     }
+ 
+diff --git a/qtbase/src/gui/util/qdesktopservices.cpp b/qtbase/src/gui/util/qdesktopservices.cpp
+index fbb63a9408..4d5fafaaa7 100644
+--- a/qtbase/src/gui/util/qdesktopservices.cpp
++++ b/qtbase/src/gui/util/qdesktopservices.cpp
+@@ -54,6 +54,8 @@
+ #include <qpa/qplatformintegration.h>
+ #include <qdir.h>
+ 
++#include <QtCore/private/qlocking_p.h>
++
+ QT_BEGIN_NAMESPACE
+ 
+ class QOpenUrlHandlerRegistry : public QObject
+@@ -81,6 +83,7 @@ Q_GLOBAL_STATIC(QOpenUrlHandlerRegistry, handlerRegistry)
+ 
+ void QOpenUrlHandlerRegistry::handlerDestroyed(QObject *handler)
+ {
++    const auto lock = qt_scoped_lock(mutex);
+     HandlerHash::Iterator it = handlers.begin();
+     while (it != handlers.end()) {
+         if (it->receiver == handler) {
+@@ -294,7 +297,8 @@ void QDesktopServices::setUrlHandler(const QString &scheme, QObject *receiver, c
+     h.name = method;
+     registry->handlers.insert(scheme.toLower(), h);
+     QObject::connect(receiver, SIGNAL(destroyed(QObject*)),
+-                     registry, SLOT(handlerDestroyed(QObject*)));
++                     registry, SLOT(handlerDestroyed(QObject*)),
++                     Qt::DirectConnection);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/gui/util/qpkmhandler.cpp b/qtbase/src/gui/util/qpkmhandler.cpp
+index e0c3b75efe..3414f9d8ba 100644
+--- a/qtbase/src/gui/util/qpkmhandler.cpp
++++ b/qtbase/src/gui/util/qpkmhandler.cpp
+@@ -57,7 +57,7 @@ struct PkmType
+     quint32 bytesPerBlock;
+ };
+ 
+-static PkmType typeMap[5] = {
++static constexpr PkmType typeMap[5] = {
+     { 0x8D64,  8 },   // GL_ETC1_RGB8_OES
+     { 0x9274,  8 },   // GL_COMPRESSED_RGB8_ETC2
+     { 0, 0 },         // unused (obsolete)
+diff --git a/qtbase/src/network/access/qnetworkreplyfileimpl.cpp b/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
+index b6be93147a..6e69b4c4d3 100644
+--- a/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
++++ b/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
+@@ -89,9 +89,10 @@ QNetworkReplyFileImpl::QNetworkReplyFileImpl(QNetworkAccessManager *manager, con
+         // we handle only local files
+         QString msg = QCoreApplication::translate("QNetworkAccessFileBackend", "Request for opening non-local file %1").arg(url.toString());
+         setError(QNetworkReply::ProtocolInvalidOperationError, msg);
++        setFinished(true); // We're finished, will emit finished() after ctor is done.
+         QMetaObject::invokeMethod(this, "errorOccurred", Qt::QueuedConnection,
+             Q_ARG(QNetworkReply::NetworkError, QNetworkReply::ProtocolInvalidOperationError));
+-        fileOpenFinished(false);
++        QMetaObject::invokeMethod(this, [this](){ fileOpenFinished(false); }, Qt::QueuedConnection);
+         return;
+     }
+ #endif
+diff --git a/qtbase/src/network/access/qnetworkreplyimpl.cpp b/qtbase/src/network/access/qnetworkreplyimpl.cpp
+index bcdf6ee2f1..3b6deb82bd 100644
+--- a/qtbase/src/network/access/qnetworkreplyimpl.cpp
++++ b/qtbase/src/network/access/qnetworkreplyimpl.cpp
+@@ -680,7 +680,7 @@ void QNetworkReplyImplPrivate::appendDownstreamData(QIODevice *data)
+     // read until EOF from data
+     if (Q_UNLIKELY(copyDevice)) {
+         qCritical("QNetworkReplyImpl: copy from QIODevice already in progress -- "
+-                  "backend probly needs to be fixed");
++                  "backend probably needs to be fixed");
+         return;
+     }
+ 
+diff --git a/qtbase/src/network/kernel/qauthenticator.cpp b/qtbase/src/network/kernel/qauthenticator.cpp
+index d9fe7bc47b..ccd04b294a 100644
+--- a/qtbase/src/network/kernel/qauthenticator.cpp
++++ b/qtbase/src/network/kernel/qauthenticator.cpp
+@@ -50,6 +50,7 @@
+ #include <qstring.h>
+ #include <qdatetime.h>
+ #include <qrandom.h>
++#include "private/qsystemlibrary_p.h"
+ 
+ #ifdef Q_OS_WIN
+ #include <qmutex.h>
+@@ -1563,7 +1564,7 @@ static bool q_SSPI_library_load()
+ 
+     // Initialize security interface
+     if (pSecurityFunctionTable == nullptr) {
+-        securityDLLHandle = LoadLibrary(L"secur32.dll");
++        securityDLLHandle = QSystemLibrary::load(L"secur32");
+         if (securityDLLHandle != nullptr) {
+             INIT_SECURITY_INTERFACE pInitSecurityInterface =
+                 reinterpret_cast<INIT_SECURITY_INTERFACE>(
+diff --git a/qtbase/src/network/kernel/qhostinfo_unix.cpp b/qtbase/src/network/kernel/qhostinfo_unix.cpp
+index 9b0a2ee669..73679c9ef1 100644
+--- a/qtbase/src/network/kernel/qhostinfo_unix.cpp
++++ b/qtbase/src/network/kernel/qhostinfo_unix.cpp
+@@ -122,7 +122,6 @@ static QFunctionPointer resolveSymbol(QLibrary &lib, const char *sym)
+ 
+ LibResolv::LibResolv()
+ {
+-    QLibrary lib;
+ #ifdef LIBRESOLV_SO
+     lib.setFileName(QStringLiteral(LIBRESOLV_SO));
+     if (!lib.load())
+diff --git a/qtbase/src/network/socket/qsocks5socketengine.cpp b/qtbase/src/network/socket/qsocks5socketengine.cpp
+index 3a046fd116..97fadca0b3 100644
+--- a/qtbase/src/network/socket/qsocks5socketengine.cpp
++++ b/qtbase/src/network/socket/qsocks5socketengine.cpp
+@@ -1296,7 +1296,7 @@ void QSocks5SocketEnginePrivate::_q_udpSocketReadNotification()
+         int pos = 0;
+         const char *buf = inBuf.constData();
+         if (inBuf.size() < 4) {
+-            QSOCKS5_D_DEBUG << "bugus udp data, discarding";
++            QSOCKS5_D_DEBUG << "bogus udp data, discarding";
+             return;
+         }
+         QSocks5RevivedDatagram datagram;
+diff --git a/qtbase/src/network/ssl/qsslcontext_openssl.cpp b/qtbase/src/network/ssl/qsslcontext_openssl.cpp
+index c9f202f573..c992da9d8e 100644
+--- a/qtbase/src/network/ssl/qsslcontext_openssl.cpp
++++ b/qtbase/src/network/ssl/qsslcontext_openssl.cpp
+@@ -409,7 +409,7 @@ init_context:
+         break;
+     case QSsl::DtlsV1_0OrLater:
+         minVersion = DTLS1_VERSION;
+-        maxVersion = DTLS_MAX_VERSION;
++        maxVersion = 0;
+         break;
+     case QSsl::DtlsV1_2:
+         minVersion = DTLS1_2_VERSION;
+@@ -417,7 +417,7 @@ init_context:
+         break;
+     case QSsl::DtlsV1_2OrLater:
+         minVersion = DTLS1_2_VERSION;
+-        maxVersion = DTLS_MAX_VERSION;
++        maxVersion = 0;
+         break;
+     case QSsl::TlsV1_3OrLater:
+ #ifdef TLS1_3_VERSION
+@@ -455,7 +455,7 @@ init_context:
+     }
+ 
+     // Enable bug workarounds.
+-    long options = QSslSocketBackendPrivate::setupOpenSslOptions(configuration.protocol(), configuration.d->sslOptions);
++    qssloptions options = QSslSocketBackendPrivate::setupOpenSslOptions(configuration.protocol(), configuration.d->sslOptions);
+     q_SSL_CTX_set_options(sslContext->ctx, options);
+ 
+     // Tell OpenSSL to release memory early
+diff --git a/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp b/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
+index aaf8741130..b58935372c 100644
+--- a/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
++++ b/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
+@@ -59,57 +59,6 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-#ifdef OPENSSL_NO_DEPRECATED_3_0
+-
+-static int q_DH_check(DH *dh, int *status)
+-{
+-    // DH_check was first deprecated in OpenSSL 3.0.0, as low-level
+-    // API; the EVP_PKEY family of functions was advised as an alternative.
+-    // As of now EVP_PKEY_params_check ends up calling ... DH_check,
+-    // which is good enough.
+-
+-    Q_ASSERT(dh);
+-    Q_ASSERT(status);
+-
+-    EVP_PKEY *key = q_EVP_PKEY_new();
+-    if (!key) {
+-        qCWarning(lcSsl, "EVP_PKEY_new failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-    const auto keyDeleter = qScopeGuard([key](){
+-        q_EVP_PKEY_free(key);
+-    });
+-    if (!q_EVP_PKEY_set1_DH(key, dh)) {
+-        qCWarning(lcSsl, "EVP_PKEY_set1_DH failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-
+-    EVP_PKEY_CTX *keyCtx = q_EVP_PKEY_CTX_new(key, nullptr);
+-    if (!keyCtx) {
+-        qCWarning(lcSsl, "EVP_PKEY_CTX_new failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-    const auto ctxDeleter = qScopeGuard([keyCtx]{
+-        q_EVP_PKEY_CTX_free(keyCtx);
+-    });
+-
+-    const int result = q_EVP_PKEY_param_check(keyCtx);
+-    QSslSocketBackendPrivate::logAndClearErrorQueue();
+-    // Note: unlike DH_check, we cannot obtain the 'status',
+-    // if the 'result' is 0 (actually the result is 1 only
+-    // if this 'status' was 0). We could probably check the
+-    // errors from the error queue, but it's not needed anyway
+-    // - see the 'isSafeDH' below, how it returns immediately
+-    // on 0.
+-    Q_UNUSED(status)
+-
+-    return result;
+-}
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+-
+ static bool isSafeDH(DH *dh)
+ {
+     int status = 0;
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl.cpp b/qtbase/src/network/ssl/qsslsocket_openssl.cpp
+index 37fad2a68f..8f6858c867 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl.cpp
++++ b/qtbase/src/network/ssl/qsslsocket_openssl.cpp
+@@ -550,9 +550,9 @@ static void q_loadCiphersForConnection(SSL *connection, QList<QSslCipher> &ciphe
+ // Defined in qsslsocket.cpp
+ void q_setDefaultDtlsCiphers(const QList<QSslCipher> &ciphers);
+ 
+-long QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions)
++qssloptions QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions)
+ {
+-    long options;
++    qssloptions options;
+     if (protocol == QSsl::TlsV1SslV3)
+         options = SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3;
+     else if (protocol == QSsl::SecureProtocols)
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_p.h b/qtbase/src/network/ssl/qsslsocket_openssl_p.h
+index 4103de23e8..5547589256 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_p.h
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_p.h
+@@ -107,6 +107,12 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++typedef uint64_t qssloptions;
++#else
++typedef unsigned long qssloptions;
++#endif
++
+ struct QSslErrorEntry {
+     int code;
+     int depth;
+@@ -171,7 +177,7 @@ public:
+     QVector<QSslError> ocspErrors;
+     QByteArray ocspResponseDer;
+ 
+-    Q_AUTOTEST_EXPORT static long setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions);
++    Q_AUTOTEST_EXPORT static qssloptions setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions);
+     static QSslCipher QSslCipher_from_SSL_CIPHER(const SSL_CIPHER *cipher);
+     static QList<QSslCertificate> STACKOFX509_to_QSslCertificates(STACK_OF(X509) *x509);
+     static QList<QSslError> verify(const QList<QSslCertificate> &certificateChain, const QString &hostName);
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp b/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
+index e53fb279f0..459ccd0b19 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
+@@ -148,7 +148,6 @@ DEFINEFUNC(int, EVP_PKEY_up_ref, EVP_PKEY *a, a, return 0, return)
+ DEFINEFUNC2(EVP_PKEY_CTX *, EVP_PKEY_CTX_new, EVP_PKEY *pkey, pkey, ENGINE *e, e, return nullptr, return)
+ DEFINEFUNC(int, EVP_PKEY_param_check, EVP_PKEY_CTX *ctx, ctx, return 0, return)
+ DEFINEFUNC(void, EVP_PKEY_CTX_free, EVP_PKEY_CTX *ctx, ctx, return, return)
+-DEFINEFUNC(int, EVP_PKEY_base_id, EVP_PKEY *a, a, return NID_undef, return)
+ DEFINEFUNC(int, RSA_bits, RSA *a, a, return 0, return)
+ DEFINEFUNC(int, DSA_bits, DSA *a, a, return 0, return)
+ DEFINEFUNC(int, OPENSSL_sk_num, OPENSSL_STACK *a, a, return -1, return)
+@@ -158,7 +157,7 @@ DEFINEFUNC2(void, OPENSSL_sk_push, OPENSSL_STACK *a, a, void *b, b, return, DUMM
+ DEFINEFUNC(void, OPENSSL_sk_free, OPENSSL_STACK *a, a, return, DUMMYARG)
+ DEFINEFUNC2(void *, OPENSSL_sk_value, OPENSSL_STACK *a, a, int b, b, return nullptr, return)
+ DEFINEFUNC(int, SSL_session_reused, SSL *a, a, return 0, return)
+-DEFINEFUNC2(unsigned long, SSL_CTX_set_options, SSL_CTX *ctx, ctx, unsigned long op, op, return 0, return)
++DEFINEFUNC2(qssloptions, SSL_CTX_set_options, SSL_CTX *ctx, ctx, qssloptions op, op, return 0, return)
+ DEFINEFUNC(int, SSL_CTX_get_security_level, const SSL_CTX *ctx, ctx, return -1, return)
+ DEFINEFUNC2(void, SSL_CTX_set_security_level, SSL_CTX *ctx, ctx, int level, level, return, return)
+ #ifdef TLS1_3_VERSION
+@@ -371,7 +370,15 @@ DEFINEFUNC(const SSL_CIPHER *, SSL_get_current_cipher, SSL *a, a, return nullptr
+ DEFINEFUNC(int, SSL_version, const SSL *a, a, return 0, return)
+ DEFINEFUNC2(int, SSL_get_error, SSL *a, a, int b, b, return -1, return)
+ DEFINEFUNC(STACK_OF(X509) *, SSL_get_peer_cert_chain, SSL *a, a, return nullptr, return)
++
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++DEFINEFUNC(X509 *, SSL_get1_peer_certificate, SSL *a, a, return nullptr, return)
++DEFINEFUNC(int, EVP_PKEY_get_base_id, const EVP_PKEY *pkey, pkey, return -1, return)
++#else
+ DEFINEFUNC(X509 *, SSL_get_peer_certificate, SSL *a, a, return nullptr, return)
++DEFINEFUNC(int, EVP_PKEY_base_id, EVP_PKEY *a, a, return NID_undef, return)
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+ DEFINEFUNC(long, SSL_get_verify_result, const SSL *a, a, return -1, return)
+ DEFINEFUNC(SSL *, SSL_new, SSL_CTX *a, a, return nullptr, return)
+ DEFINEFUNC(SSL_CTX *, SSL_get_SSL_CTX, SSL *a, a, return nullptr, return)
+@@ -492,9 +499,7 @@ DEFINEFUNC(DH *, DH_new, DUMMYARG, DUMMYARG, return nullptr, return)
+ DEFINEFUNC(void, DH_free, DH *dh, dh, return, DUMMYARG)
+ DEFINEFUNC3(DH *, d2i_DHparams, DH**a, a, const unsigned char **pp, pp, long length, length, return nullptr, return)
+ DEFINEFUNC2(int, i2d_DHparams, DH *a, a, unsigned char **p, p, return -1, return)
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+ DEFINEFUNC2(int, DH_check, DH *dh, dh, int *codes, codes, return 0, return)
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+ DEFINEFUNC3(BIGNUM *, BN_bin2bn, const unsigned char *s, s, int len, len, BIGNUM *ret, ret, return nullptr, return)
+ 
+ #ifndef OPENSSL_NO_EC
+@@ -868,7 +873,6 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(EVP_PKEY_CTX_new)
+     RESOLVEFUNC(EVP_PKEY_param_check)
+     RESOLVEFUNC(EVP_PKEY_CTX_free)
+-    RESOLVEFUNC(EVP_PKEY_base_id)
+     RESOLVEFUNC(RSA_bits)
+     RESOLVEFUNC(OPENSSL_sk_new_null)
+     RESOLVEFUNC(OPENSSL_sk_push)
+@@ -1107,7 +1111,15 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(SSL_version)
+     RESOLVEFUNC(SSL_get_error)
+     RESOLVEFUNC(SSL_get_peer_cert_chain)
++
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++    RESOLVEFUNC(SSL_get1_peer_certificate)
++    RESOLVEFUNC(EVP_PKEY_get_base_id)
++#else
+     RESOLVEFUNC(SSL_get_peer_certificate)
++    RESOLVEFUNC(EVP_PKEY_base_id)
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+     RESOLVEFUNC(SSL_get_verify_result)
+     RESOLVEFUNC(SSL_new)
+     RESOLVEFUNC(SSL_get_SSL_CTX)
+@@ -1206,9 +1218,7 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(DH_free)
+     RESOLVEFUNC(d2i_DHparams)
+     RESOLVEFUNC(i2d_DHparams)
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+     RESOLVEFUNC(DH_check)
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+     RESOLVEFUNC(BN_bin2bn)
+ 
+ #ifndef OPENSSL_NO_EC
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h b/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
+index 95e8897a3b..27aeffa18a 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
+@@ -237,7 +237,6 @@ Q_AUTOTEST_EXPORT int q_EVP_PKEY_up_ref(EVP_PKEY *a);
+ EVP_PKEY_CTX *q_EVP_PKEY_CTX_new(EVP_PKEY *pkey, ENGINE *e);
+ void q_EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx);
+ int q_EVP_PKEY_param_check(EVP_PKEY_CTX *ctx);
+-int q_EVP_PKEY_base_id(EVP_PKEY *a);
+ int q_RSA_bits(RSA *a);
+ Q_AUTOTEST_EXPORT int q_OPENSSL_sk_num(OPENSSL_STACK *a);
+ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_pop_free(OPENSSL_STACK *a, void (*b)(void *));
+@@ -246,7 +245,7 @@ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_push(OPENSSL_STACK *st, void *data);
+ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_free(OPENSSL_STACK *a);
+ Q_AUTOTEST_EXPORT void * q_OPENSSL_sk_value(OPENSSL_STACK *a, int b);
+ int q_SSL_session_reused(SSL *a);
+-unsigned long q_SSL_CTX_set_options(SSL_CTX *ctx, unsigned long op);
++qssloptions q_SSL_CTX_set_options(SSL_CTX *ctx, qssloptions op);
+ int q_OPENSSL_init_ssl(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings);
+ size_t q_SSL_get_client_random(SSL *a, unsigned char *out, size_t outlen);
+ size_t q_SSL_SESSION_get_master_key(const SSL_SESSION *session, unsigned char *out, size_t outlen);
+@@ -510,7 +509,6 @@ const SSL_CIPHER *q_SSL_get_current_cipher(SSL *a);
+ int q_SSL_version(const SSL *a);
+ int q_SSL_get_error(SSL *a, int b);
+ STACK_OF(X509) *q_SSL_get_peer_cert_chain(SSL *a);
+-X509 *q_SSL_get_peer_certificate(SSL *a);
+ long q_SSL_get_verify_result(const SSL *a);
+ SSL *q_SSL_new(SSL_CTX *a);
+ SSL_CTX *q_SSL_get_SSL_CTX(SSL *a);
+@@ -582,10 +580,7 @@ DH *q_DH_new();
+ void q_DH_free(DH *dh);
+ DH *q_d2i_DHparams(DH **a, const unsigned char **pp, long length);
+ int q_i2d_DHparams(DH *a, unsigned char **p);
+-
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+ int q_DH_check(DH *dh, int *codes);
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+ 
+ BIGNUM *q_BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret);
+ #define q_SSL_CTX_set_tmp_dh(ctx, dh) q_SSL_CTX_ctrl((ctx), SSL_CTRL_SET_TMP_DH, 0, (char *)dh)
+@@ -754,6 +749,17 @@ void q_CRYPTO_free(void *str, const char *file, int line);
+ int q_SSL_CTX_get_security_level(const SSL_CTX *ctx);
+ void q_SSL_CTX_set_security_level(SSL_CTX *ctx, int level);
+ 
++// Here we have the ones that make difference between OpenSSL pre/post v3:
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++X509 *q_SSL_get1_peer_certificate(SSL *a);
++#define q_SSL_get_peer_certificate q_SSL_get1_peer_certificate
++int q_EVP_PKEY_get_base_id(const EVP_PKEY *pkey);
++#define q_EVP_PKEY_base_id q_EVP_PKEY_get_base_id
++#else
++X509 *q_SSL_get_peer_certificate(SSL *a);
++int q_EVP_PKEY_base_id(EVP_PKEY *a);
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+ QT_END_NAMESPACE
+ 
+ #endif
+diff --git a/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h b/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
+index bf37d07fd8..dbd42fb799 100644
+--- a/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
++++ b/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
+@@ -61,7 +61,11 @@
+ # if !defined(Q_OS_INTEGRITY)
+ #  define WIN_INTERFACE_CUSTOM   // NV
+ # endif // Q_OS_INTEGRITY
+-#endif  // QT_EGL_NO_X11
++#else // QT_EGL_NO_X11
++// If one has an eglplatform.h with https://github.com/KhronosGroup/EGL-Registry/pull/130
++// that needs USE_X11 to be defined.
++# define USE_X11
++#endif
+ 
+ #ifdef QT_EGL_WAYLAND
+ # define WAYLAND // NV
+diff --git a/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+index 159b490ce0..00aa80cd58 100644
+--- a/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
++++ b/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+@@ -567,6 +567,8 @@ void QFontconfigDatabase::populateFontDatabase()
+         fonts = FcFontList(nullptr, pattern, os);
+         FcObjectSetDestroy(os);
+         FcPatternDestroy(pattern);
++        if (!fonts)
++            return;
+     }
+ 
+     for (int i = 0; i < fonts->nfont; i++)
+diff --git a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
+index b713c19447..7cb9a8c79a 100644
+--- a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
++++ b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
+@@ -95,6 +95,7 @@ static constexpr const auto KeyTbl = qMakeArray(
+         Xkb2Qt<XKB_KEY_Clear,                   Qt::Key_Delete>,
+         Xkb2Qt<XKB_KEY_Pause,                   Qt::Key_Pause>,
+         Xkb2Qt<XKB_KEY_Print,                   Qt::Key_Print>,
++        Xkb2Qt<XKB_KEY_Sys_Req,                 Qt::Key_SysReq>,
+         Xkb2Qt<0x1005FF60,                      Qt::Key_SysReq>,         // hardcoded Sun SysReq
+         Xkb2Qt<0x1007ff00,                      Qt::Key_SysReq>,         // hardcoded X386 SysReq
+ 
+@@ -471,7 +472,7 @@ QVector<xkb_keysym_t> QXkbCommon::toKeysym(QKeyEvent *event)
+     } else if (event->modifiers() & Qt::KeypadModifier) {
+         if (qtKey >= Qt::Key_0 && qtKey <= Qt::Key_9)
+             keysyms.append(XKB_KEY_KP_0 + (qtKey - Qt::Key_0));
+-    } else if (isLatin(qtKey) && event->text().isUpper()) {
++    } else if (isLatin1(qtKey) && event->text().isUpper()) {
+         keysyms.append(qtKey);
+     }
+ 
+@@ -523,7 +524,7 @@ int QXkbCommon::keysymToQtKey(xkb_keysym_t keysym, Qt::KeyboardModifiers modifie
+         // With standard shortcuts we should prefer a latin character, this is
+         // for checks like "some qkeyevent == QKeySequence::Copy" to work even
+         // when using for example 'russian' keyboard layout.
+-        if (!QXkbCommon::isLatin(keysym)) {
++        if (!QXkbCommon::isLatin1(keysym)) {
+             xkb_keysym_t latinKeysym = QXkbCommon::lookupLatinKeysym(state, code);
+             if (latinKeysym != XKB_KEY_NoSymbol)
+                 keysym = latinKeysym;
+@@ -546,7 +547,7 @@ static int keysymToQtKey_internal(xkb_keysym_t keysym, Qt::KeyboardModifiers mod
+     } else if (keysym >= XKB_KEY_KP_0 && keysym <= XKB_KEY_KP_9) {
+         // numeric keypad keys
+         qtKey = Qt::Key_0 + (keysym - XKB_KEY_KP_0);
+-    } else if (QXkbCommon::isLatin(keysym)) {
++    } else if (QXkbCommon::isLatin1(keysym)) {
+         qtKey = QXkbCommon::qxkbcommon_xkb_keysym_to_upper(keysym);
+     } else {
+         // check if we have a direct mapping
+@@ -678,7 +679,7 @@ QList<int> QXkbCommon::possibleKeys(xkb_state *state, const QKeyEvent *event,
+         Qt::KeyboardModifiers neededMods = ModsTbl[i];
+         if ((modifiers & neededMods) == neededMods) {
+             if (i == 8) {
+-                if (isLatin(baseQtKey))
++                if (isLatin1(baseQtKey))
+                     continue;
+                 // add a latin key as a fall back key
+                 sym = lookupLatinKeysym(state, keycode);
+@@ -733,7 +734,7 @@ void QXkbCommon::verifyHasLatinLayout(xkb_keymap *keymap)
+     for (xkb_layout_index_t layout = 0; layout < layoutCount; ++layout) {
+         for (xkb_keycode_t code = minKeycode; code < maxKeycode; ++code) {
+             xkb_keymap_key_get_syms_by_level(keymap, code, layout, 0, &keysyms);
+-            if (keysyms && isLatin(keysyms[0]))
++            if (keysyms && isLatin1(keysyms[0]))
+                 nrLatinKeys++;
+             if (nrLatinKeys > 10) // arbitrarily chosen threshold
+                 return;
+@@ -766,7 +767,7 @@ xkb_keysym_t QXkbCommon::lookupLatinKeysym(xkb_state *state, xkb_keycode_t keyco
+         xkb_level_index_t level = xkb_state_key_get_level(state, keycode, layout);
+         if (xkb_keymap_key_get_syms_by_level(keymap, keycode, layout, level, &syms) != 1)
+             continue;
+-        if (isLatin(syms[0])) {
++        if (isLatin1(syms[0])) {
+             sym = syms[0];
+             break;
+         }
+diff --git a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
+index 561eae03db..8389bd8f5a 100644
+--- a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
++++ b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
+@@ -94,8 +94,8 @@ public:
+     static void verifyHasLatinLayout(xkb_keymap *keymap);
+     static xkb_keysym_t lookupLatinKeysym(xkb_state *state, xkb_keycode_t keycode);
+ 
+-    static bool isLatin(xkb_keysym_t sym) {
+-        return ((sym >= 'a' && sym <= 'z') || (sym >= 'A' && sym <= 'Z'));
++    static bool isLatin1(xkb_keysym_t sym) {
++        return sym <= 0xff;
+     }
+     static bool isKeypad(xkb_keysym_t sym) {
+         return sym >= XKB_KEY_KP_Space && sym <= XKB_KEY_KP_9;
+diff --git a/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp b/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
+index 8cd7f9b368..406f84663f 100644
+--- a/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
++++ b/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
+@@ -318,7 +318,7 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources,
+ 
+     if (current < 0 && crtc_mode.clock != 0) {
+         modes << crtc_mode;
+-        current = mode.size() - 1;
++        current = modes.size() - 1;
+     }
+ 
+     if (configuration == OutputConfigCurrent)
+diff --git a/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp b/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
+index 9153fd20bb..255ea5e33e 100644
+--- a/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
++++ b/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
+@@ -194,6 +194,9 @@ QString AtSpiAdaptor::introspect(const QString &path) const
+                 "      <arg direction=\"out\" type=\"(so)\"/>\n"
+                 "      <annotation value=\"QSpiObjectReference\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n"
+                 "    </method>\n"
++                "    <method name=\"GetAccessibleId\">\n"
++                "      <arg direction=\"out\" type=\"s\"/>\n"
++                "    </method>\n"
+                 "  </interface>\n"
+                 );
+ 
+@@ -913,8 +916,17 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+     }
+     case QAccessible::NameChanged: {
+         if (sendObject || sendObject_property_change || sendObject_property_change_accessible_name) {
+-            QString path = pathForInterface(event->accessibleInterface());
+-            QVariantList args = packDBusSignalArguments(QLatin1String("accessible-name"), 0, 0, variantForPath(path));
++            QAccessibleInterface *iface = event->accessibleInterface();
++            if (!iface) {
++                qCDebug(lcAccessibilityAtspi,
++                        "NameChanged event from invalid accessible.");
++                return;
++            }
++
++            QString path = pathForInterface(iface);
++            QVariantList args = packDBusSignalArguments(
++                QLatin1String("accessible-name"), 0, 0,
++                QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Name))));
+             sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                            QLatin1String("PropertyChange"), args);
+         }
+@@ -922,8 +934,17 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+     }
+     case QAccessible::DescriptionChanged: {
+         if (sendObject || sendObject_property_change || sendObject_property_change_accessible_description) {
+-            QString path = pathForInterface(event->accessibleInterface());
+-            QVariantList args = packDBusSignalArguments(QLatin1String("accessible-description"), 0, 0, variantForPath(path));
++            QAccessibleInterface *iface = event->accessibleInterface();
++            if (!iface) {
++                qCDebug(lcAccessibilityAtspi,
++                        "DescriptionChanged event from invalid accessible.");
++                return;
++            }
++
++            QString path = pathForInterface(iface);
++            QVariantList args = packDBusSignalArguments(
++                QLatin1String("accessible-description"), 0, 0,
++                QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Description))));
+             sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                            QLatin1String("PropertyChange"), args);
+         }
+@@ -1038,7 +1059,9 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+                 // Combo Box with AT-SPI likes to be special
+                 // It requires a name-change to update caches and then selection-changed
+                 QString path = pathForInterface(iface);
+-                QVariantList args1 = packDBusSignalArguments(QLatin1String("accessible-name"), 0, 0, variantForPath(path));
++                QVariantList args1 = packDBusSignalArguments(
++                    QLatin1String("accessible-name"), 0, 0,
++                    QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Name))));
+                 sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                                QLatin1String("PropertyChange"), args1);
+                 QVariantList args2 = packDBusSignalArguments(QString(), 0, 0, QVariant::fromValue(QDBusVariant(QVariant(0))));
+@@ -1358,6 +1381,26 @@ void AtSpiAdaptor::registerApplication()
+     delete registry;
+ }
+ 
++namespace {
++QString accessibleIdForAccessible(QAccessibleInterface *accessible)
++{
++    QString result;
++    while (accessible) {
++        if (!result.isEmpty())
++            result.prepend(QLatin1Char('.'));
++        if (auto obj = accessible->object()) {
++            const QString name = obj->objectName();
++            if (!name.isEmpty())
++                result.prepend(name);
++            else
++                result.prepend(QString::fromUtf8(obj->metaObject()->className()));
++        }
++        accessible = accessible->parent();
++    }
++    return result;
++}
++} // namespace
++
+ // Accessible
+ bool AtSpiAdaptor::accessibleInterface(QAccessibleInterface *interface, const QString &function, const QDBusMessage &message, const QDBusConnection &connection)
+ {
+@@ -1441,6 +1484,9 @@ bool AtSpiAdaptor::accessibleInterface(QAccessibleInterface *interface, const QS
+             children << ref;
+         }
+         connection.send(message.createReply(QVariant::fromValue(children)));
++    } else if (function == QLatin1String("GetAccessibleId")) {
++        sendReply(connection, message,
++                  QVariant::fromValue(QDBusVariant(accessibleIdForAccessible(interface))));
+     } else {
+         qCDebug(lcAccessibilityAtspi) << "WARNING: AtSpiAdaptor::accessibleInterface does not implement " << function << message.path();
+         return false;
+diff --git a/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp b/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
+index 45ddc8e496..cc734abc63 100644
+--- a/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
++++ b/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
+@@ -69,6 +69,21 @@ QT_BEGIN_NAMESPACE
+ DBusConnection::DBusConnection(QObject *parent)
+     : QObject(parent), m_a11yConnection(QString()), m_enabled(false)
+ {
++    // If the bus is explicitly set via env var it overrides everything else.
++    QByteArray addressEnv = qgetenv("AT_SPI_BUS_ADDRESS");
++    if (!addressEnv.isEmpty()) {
++        // Only connect on next loop run, connections to our enabled signal are
++        // only established after the ctor returns.
++        QMetaObject::invokeMethod(
++                this,
++                [this, addressEnv] {
++                    m_enabled = true;
++                    connectA11yBus(QString::fromLocal8Bit(addressEnv));
++                },
++                Qt::QueuedConnection);
++        return;
++    }
++
+     // Start monitoring if "org.a11y.Bus" is registered as DBus service.
+     QDBusConnection c = QDBusConnection::sessionBus();
+     if (!c.isConnected()) {
+diff --git a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
+index 1a3cab275d..2abe039126 100644
+--- a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
++++ b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
+@@ -51,6 +51,9 @@
+ #include <QtCore/QStandardPaths>
+ #include <QtCore/QUrl>
+ 
++#include <QtGui/QGuiApplication>
++#include <QtGui/QWindow>
++
+ #if QT_CONFIG(dbus)
+ // These QtCore includes are needed for xdg-desktop-portal support
+ #include <QtCore/private/qcore_unix_p.h>
+@@ -58,6 +61,8 @@
+ #include <QtCore/QFileInfo>
+ #include <QtCore/QUrlQuery>
+ 
++#include <QtGui/QColor>
++
+ #include <QtDBus/QDBusConnection>
+ #include <QtDBus/QDBusMessage>
+ #include <QtDBus/QDBusPendingCall>
+@@ -142,6 +147,8 @@ static inline bool detectWebBrowser(const QByteArray &desktop,
+     }
+ 
+     if (desktop == QByteArray("KDE")) {
++        if (checkExecutable(QStringLiteral("kde-open5"), browser))
++            return true;
+         // Konqueror launcher
+         if (checkExecutable(QStringLiteral("kfmclient"), browser)) {
+             browser->append(QLatin1String(" exec"));
+@@ -296,8 +303,135 @@ static inline QDBusMessage xdgDesktopPortalSendEmail(const QUrl &url)
+ 
+     return QDBusConnection::sessionBus().call(message);
+ }
++
++namespace {
++struct XDGDesktopColor
++{
++    double r = 0;
++    double g = 0;
++    double b = 0;
++
++    QColor toQColor() const
++    {
++        constexpr auto rgbMax = 255;
++        return { static_cast<int>(r * rgbMax), static_cast<int>(g * rgbMax),
++                 static_cast<int>(b * rgbMax) };
++    }
++};
++
++const QDBusArgument &operator>>(const QDBusArgument &argument, XDGDesktopColor &myStruct)
++{
++    argument.beginStructure();
++    argument >> myStruct.r >> myStruct.g >> myStruct.b;
++    argument.endStructure();
++    return argument;
++}
++
++class XdgDesktopPortalColorPicker : public QPlatformServiceColorPicker
++{
++    Q_OBJECT
++public:
++    XdgDesktopPortalColorPicker(const QString &parentWindowId, QWindow *parent)
++        : QPlatformServiceColorPicker(parent), m_parentWindowId(parentWindowId)
++    {
++    }
++
++    void pickColor() override
++    {
++        // DBus signature:
++        // PickColor (IN   s      parent_window,
++        //            IN   a{sv}  options
++        //            OUT  o      handle)
++        // Options:
++        // handle_token (s) -  A string that will be used as the last element of the @handle.
++
++        QDBusMessage message = QDBusMessage::createMethodCall(
++                QStringLiteral("org.freedesktop.portal.Desktop"), QStringLiteral("/org/freedesktop/portal/desktop"),
++                QStringLiteral("org.freedesktop.portal.Screenshot"), QStringLiteral("PickColor"));
++        message << m_parentWindowId << QVariantMap();
++
++        QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
++        auto watcher = new QDBusPendingCallWatcher(pendingCall, this);
++        connect(watcher, &QDBusPendingCallWatcher::finished, this,
++                [this](QDBusPendingCallWatcher *watcher) {
++                    watcher->deleteLater();
++                    QDBusPendingReply<QDBusObjectPath> reply = *watcher;
++                    if (reply.isError()) {
++                        qWarning("DBus call to pick color failed: %s",
++                                 qPrintable(reply.error().message()));
++                        Q_EMIT colorPicked({});
++                    } else {
++                        QDBusConnection::sessionBus().connect(
++                                QStringLiteral("org.freedesktop.portal.Desktop"), reply.value().path(),
++                                QStringLiteral("org.freedesktop.portal.Request"), QStringLiteral("Response"), this,
++                                // clang-format off
++                                SLOT(gotColorResponse(uint,QVariantMap))
++                                // clang-format on
++                        );
++                    }
++                });
++    }
++
++private Q_SLOTS:
++    void gotColorResponse(uint result, const QVariantMap &map)
++    {
++        if (result != 0)
++            return;
++        XDGDesktopColor color{};
++        map.value(QStringLiteral("color")).value<QDBusArgument>() >> color;
++        Q_EMIT colorPicked(color.toQColor());
++        deleteLater();
++    }
++
++private:
++    const QString m_parentWindowId;
++};
++} // namespace
++
+ #endif // QT_CONFIG(dbus)
+ 
++QGenericUnixServices::QGenericUnixServices()
++{
++#if QT_CONFIG(dbus)
++    if (qEnvironmentVariableIntValue("QT_NO_XDG_DESKTOP_PORTAL") > 0) {
++        return;
++    }
++    QDBusMessage message = QDBusMessage::createMethodCall(
++            QStringLiteral("org.freedesktop.portal.Desktop"), QStringLiteral("/org/freedesktop/portal/desktop"),
++            QStringLiteral("org.freedesktop.DBus.Properties"), QStringLiteral("Get"));
++    message << QStringLiteral("org.freedesktop.portal.Screenshot")
++            << QStringLiteral("version");
++
++    QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
++    auto watcher = new QDBusPendingCallWatcher(pendingCall);
++    QObject::connect(watcher, &QDBusPendingCallWatcher::finished, watcher,
++                     [this](QDBusPendingCallWatcher *watcher) {
++                         watcher->deleteLater();
++                         QDBusPendingReply<QVariant> reply = *watcher;
++                         if (!reply.isError() && reply.value().toUInt() >= 2)
++                             m_hasScreenshotPortalWithColorPicking = true;
++                     });
++
++#endif
++}
++
++QPlatformServiceColorPicker *QGenericUnixServices::colorPicker(QWindow *parent)
++{
++#if QT_CONFIG(dbus)
++    // Make double sure that we are in a wayland environment. In particular check
++    // WAYLAND_DISPLAY so also XWayland apps benefit from portal-based color picking.
++    // Outside wayland we'll rather rely on other means than the XDG desktop portal.
++    if (!qEnvironmentVariableIsEmpty("WAYLAND_DISPLAY")
++        || QGuiApplication::platformName().startsWith(QLatin1String("wayland"))) {
++        return new XdgDesktopPortalColorPicker(portalWindowIdentifier(parent), parent);
++    }
++    return nullptr;
++#else
++    Q_UNUSED(parent);
++    return nullptr;
++#endif
++}
++
+ QByteArray QGenericUnixServices::desktopEnvironment() const
+ {
+     static const QByteArray result = detectDesktopEnvironment();
+@@ -352,6 +486,8 @@ bool QGenericUnixServices::openDocument(const QUrl &url)
+ }
+ 
+ #else
++QGenericUnixServices::QGenericUnixServices() = default;
++
+ QByteArray QGenericUnixServices::desktopEnvironment() const
+ {
+     return QByteArrayLiteral("UNKNOWN");
+@@ -371,6 +507,30 @@ bool QGenericUnixServices::openDocument(const QUrl &url)
+     return false;
+ }
+ 
++QPlatformServiceColorPicker *QGenericUnixServices::colorPicker(QWindow *parent)
++{
++    Q_UNUSED(parent);
++    return nullptr;
++}
++
+ #endif // QT_NO_MULTIPROCESS
+ 
++QString QGenericUnixServices::portalWindowIdentifier(QWindow *window)
++{
++    if (QGuiApplication::platformName() == QLatin1String("xcb"))
++        return QStringLiteral("x11:") + QString::number(window->winId(), 16);
++    return QString();
++}
++
++bool QGenericUnixServices::hasCapability(Capability capability) const
++{
++    switch (capability) {
++    case Capability::ColorPicking:
++        return m_hasScreenshotPortalWithColorPicking;
++    }
++    return false;
++}
++
+ QT_END_NAMESPACE
++
++#include "qgenericunixservices.moc"
+diff --git a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
+index 8ac3de6f03..30924e64bd 100644
+--- a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
++++ b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
+@@ -59,16 +59,21 @@ QT_BEGIN_NAMESPACE
+ class QGenericUnixServices : public QPlatformServices
+ {
+ public:
+-    QGenericUnixServices() {}
++    QGenericUnixServices();
+ 
+     QByteArray desktopEnvironment() const override;
+ 
++    bool hasCapability(Capability capability) const override;
+     bool openUrl(const QUrl &url) override;
+     bool openDocument(const QUrl &url) override;
++    QPlatformServiceColorPicker *colorPicker(QWindow *parent = nullptr) override;
++
++    virtual QString portalWindowIdentifier(QWindow *window);
+ 
+ private:
+     QString m_webBrowser;
+     QString m_documentLauncher;
++    bool m_hasScreenshotPortalWithColorPicking = false;
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
+index 09470bccc6..cc7c7d4d8a 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
+@@ -69,6 +69,7 @@ const QString MenuBarPath = QLatin1String("/MenuBar");
+ */
+ QDBusMenuConnection::QDBusMenuConnection(QObject *parent, const QString &serviceName)
+     : QObject(parent)
++    , m_serviceName(serviceName)
+     , m_connection(serviceName.isNull() ? QDBusConnection::sessionBus()
+                                         : QDBusConnection::connectToBus(QDBusConnection::SessionBus, serviceName))
+     , m_dbusWatcher(new QDBusServiceWatcher(StatusNotifierWatcherService, m_connection, QDBusServiceWatcher::WatchForRegistration, this))
+@@ -83,6 +84,12 @@ QDBusMenuConnection::QDBusMenuConnection(QObject *parent, const QString &service
+ #endif
+ }
+ 
++QDBusMenuConnection::~QDBusMenuConnection()
++{
++  if (!m_serviceName.isEmpty() && m_connection.isConnected())
++      QDBusConnection::disconnectFromBus(m_serviceName);
++}
++
+ void QDBusMenuConnection::dbusError(const QDBusError &error)
+ {
+     qWarning() << "QDBusTrayIcon encountered a D-Bus error:" << error;
+@@ -105,13 +112,7 @@ void QDBusMenuConnection::unregisterTrayIconMenu(QDBusTrayIcon *item)
+ 
+ bool QDBusMenuConnection::registerTrayIcon(QDBusTrayIcon *item)
+ {
+-    bool success = connection().registerService(item->instanceId());
+-    if (!success) {
+-        qWarning() << "failed to register service" << item->instanceId();
+-        return false;
+-    }
+-
+-    success = connection().registerObject(StatusNotifierItemPath, item);
++    bool success = connection().registerObject(StatusNotifierItemPath, item);
+     if (!success) {
+         unregisterTrayIcon(item);
+         qWarning() << "failed to register" << item->instanceId() << StatusNotifierItemPath;
+@@ -126,21 +127,18 @@ bool QDBusMenuConnection::registerTrayIcon(QDBusTrayIcon *item)
+ 
+ bool QDBusMenuConnection::registerTrayIconWithWatcher(QDBusTrayIcon *item)
+ {
++    Q_UNUSED(item);
+     QDBusMessage registerMethod = QDBusMessage::createMethodCall(
+                 StatusNotifierWatcherService, StatusNotifierWatcherPath, StatusNotifierWatcherService,
+                 QLatin1String("RegisterStatusNotifierItem"));
+-    registerMethod.setArguments(QVariantList() << item->instanceId());
++    registerMethod.setArguments(QVariantList() << m_connection.baseService());
+     return m_connection.callWithCallback(registerMethod, this, SIGNAL(trayIconRegistered()), SLOT(dbusError(QDBusError)));
+ }
+ 
+-bool QDBusMenuConnection::unregisterTrayIcon(QDBusTrayIcon *item)
++void QDBusMenuConnection::unregisterTrayIcon(QDBusTrayIcon *item)
+ {
+     unregisterTrayIconMenu(item);
+     connection().unregisterObject(StatusNotifierItemPath);
+-    bool success = connection().unregisterService(item->instanceId());
+-    if (!success)
+-        qWarning() << "failed to unregister service" << item->instanceId();
+-    return success;
+ }
+ #endif // QT_NO_SYSTEMTRAYICON
+ 
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
+index f484795fbb..97bdfabb85 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
++++ b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
+@@ -70,6 +70,7 @@ class QDBusMenuConnection : public QObject
+ 
+ public:
+     QDBusMenuConnection(QObject *parent = nullptr, const QString &serviceName = QString());
++    ~QDBusMenuConnection();
+     QDBusConnection connection() const { return m_connection; }
+     QDBusServiceWatcher *dbusWatcher() const { return m_dbusWatcher; }
+     bool isStatusNotifierHostRegistered() const { return m_statusNotifierHostRegistered; }
+@@ -78,7 +79,7 @@ public:
+     void unregisterTrayIconMenu(QDBusTrayIcon *item);
+     bool registerTrayIcon(QDBusTrayIcon *item);
+     bool registerTrayIconWithWatcher(QDBusTrayIcon *item);
+-    bool unregisterTrayIcon(QDBusTrayIcon *item);
++    void unregisterTrayIcon(QDBusTrayIcon *item);
+ #endif // QT_NO_SYSTEMTRAYICON
+ 
+ Q_SIGNALS:
+@@ -90,6 +91,7 @@ private Q_SLOTS:
+     void dbusError(const QDBusError &error);
+ 
+ private:
++    QString m_serviceName;
+     QDBusConnection m_connection;
+     QDBusServiceWatcher *m_dbusWatcher;
+     bool m_statusNotifierHostRegistered;
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp b/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
+index bede70975a..76bfec5e5a 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
+@@ -71,8 +71,12 @@ Q_LOGGING_CATEGORY(qLcTray, "qt.qpa.tray")
+ static QString iconTempPath()
+ {
+     QString tempPath = QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation);
+-    if (!tempPath.isEmpty())
++    if (!tempPath.isEmpty()) {
++        QString flatpakId = qEnvironmentVariable("FLATPAK_ID");
++        if (!flatpakId.isEmpty() && QFileInfo::exists(QLatin1String("/.flatpak-info")))
++            tempPath += QLatin1String("/app/") + flatpakId;
+         return tempPath;
++    }
+ 
+     tempPath = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation);
+ 
+diff --git a/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+index cb1b39db64..6e01af052c 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+@@ -755,6 +755,9 @@ QVariant QGnomeTheme::themeHint(QPlatformTheme::ThemeHint hint) const
+         return QVariant(QChar(0x2022));
+     case QPlatformTheme::UiEffects:
+         return QVariant(int(HoverEffect));
++    case QPlatformTheme::ButtonPressKeys:
++        return QVariant::fromValue(
++                QList<Qt::Key>({ Qt::Key_Space, Qt::Key_Return, Qt::Key_Enter, Qt::Key_Select }));
+     default:
+         break;
+     }
+diff --git a/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp b/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
+index 98e05195ee..1e92f43dec 100644
+--- a/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
++++ b/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
+@@ -343,8 +343,7 @@ void QEglFSCursor::paintOnScreen()
+     // screens are siblings of each other. When not enabled, the sibling list
+     // only contains m_screen itself.
+     for (QPlatformScreen *screen : m_screen->virtualSiblings()) {
+-        if (screen->geometry().contains(cr.topLeft().toPoint() + m_cursor.hotSpot)
+-            && QOpenGLContext::currentContext()->screen() == screen->screen())
++        if (screen->geometry().contains(cr.topLeft().toPoint() + m_cursor.hotSpot))
+         {
+             cr.translate(-screen->geometry().topLeft());
+             const QSize screenSize = screen->geometry().size();
+@@ -468,11 +467,12 @@ void QEglFSCursor::draw(const QRectF &r)
+ {
+     StateSaver stateSaver;
+ 
+-    QEglFSCursorData &gfx = static_cast<QEglFSContext*>(QOpenGLContext::currentContext()->handle())->cursorData;
+-    if (!gfx.program) {
+-        // one time initialization
++    // one time initialization
++    if (!QOpenGLFunctions::d_ptr)
+         initializeOpenGLFunctions();
+ 
++    QEglFSCursorData &gfx = static_cast<QEglFSContext*>(QOpenGLContext::currentContext()->handle())->cursorData;
++    if (!gfx.program) {
+         createShaderPrograms();
+ 
+         if (!gfx.atlasTexture) {
+diff --git a/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp b/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
+index 645a0ae2e9..3e0e406f1a 100644
+--- a/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
++++ b/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
+@@ -179,7 +179,7 @@ void QEglFSKmsEventReader::create(QEglFSKmsDevice *device)
+ 
+     m_device = device;
+ 
+-    qCDebug(qLcEglfsKmsDebug, "Initalizing event reader for device %p fd %d",
++    qCDebug(qLcEglfsKmsDebug, "Initializing event reader for device %p fd %d",
+             m_device, m_device->fd());
+ 
+     m_thread = new QEglFSKmsEventReaderThread(m_device->fd());
+diff --git a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
+index 141fb68a23..d4294d425a 100644
+--- a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
++++ b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
+@@ -122,11 +122,13 @@ QOffscreenIntegration::QOffscreenIntegration()
+ #endif
+     m_services.reset(new QPlatformServices);
+ 
+-    QWindowSystemInterface::handleScreenAdded(new QOffscreenScreen);
++    m_screen = new QOffscreenScreen;
++    QWindowSystemInterface::handleScreenAdded(m_screen);
+ }
+ 
+ QOffscreenIntegration::~QOffscreenIntegration()
+ {
++    QWindowSystemInterface::handleScreenRemoved(m_screen);
+ }
+ 
+ void QOffscreenIntegration::initialize()
+diff --git a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
+index 0ea90f6c2f..fe00fde07c 100644
+--- a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
++++ b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
+@@ -84,6 +84,7 @@ protected:
+ #endif
+     QScopedPointer<QPlatformInputContext> m_inputContext;
+     QScopedPointer<QPlatformServices> m_services;
++    QPlatformScreen *m_screen;
+     mutable QScopedPointer<QPlatformNativeInterface> m_nativeInterface;
+ };
+ 
+diff --git a/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp b/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
+index 6fa5a8a2b3..1f49f0aefd 100644
+--- a/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
++++ b/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
+@@ -48,6 +48,7 @@
+ #include <qpa/qplatformnativeinterface.h>
+ #include <QtPlatformHeaders/qwglnativecontext.h>
+ 
++#include <private/qsystemlibrary_p.h>
+ #include <algorithm>
+ 
+ #include <wingdi.h>
+@@ -162,19 +163,25 @@ QFunctionPointer QWindowsOpengl32DLL::resolve(const char *name)
+ 
+ bool QWindowsOpengl32DLL::init(bool softwareRendering)
+ {
+-    const QByteArray opengl32 = QByteArrayLiteral("opengl32.dll");
+-    const QByteArray swopengl = QByteArrayLiteral("opengl32sw.dll");
++    const QByteArray opengl32 = QByteArrayLiteral("opengl32");
++    const QByteArray swopengl = QByteArrayLiteral("opengl32sw");
++    bool useSystemLib = false;
+ 
+     QByteArray openglDll = qgetenv("QT_OPENGL_DLL");
+-    if (openglDll.isEmpty())
++    if (openglDll.isEmpty()) {
+         openglDll = softwareRendering ? swopengl : opengl32;
++        useSystemLib = !softwareRendering;
++    }
+ 
+     openglDll = openglDll.toLower();
+     m_nonOpengl32 = openglDll != opengl32;
+ 
+     qCDebug(lcQpaGl) << "Qt: Using WGL and OpenGL from" << openglDll;
+ 
+-    m_lib = ::LoadLibraryA(openglDll.constData());
++    if (useSystemLib)
++        m_lib = QSystemLibrary::load((wchar_t*)(QString::fromLatin1(openglDll).utf16()));
++    else
++        m_lib = LoadLibraryA(openglDll.constData());
+     if (!m_lib) {
+         qErrnoWarning(::GetLastError(), "Failed to load %s", openglDll.constData());
+         return false;
+@@ -184,7 +191,7 @@ bool QWindowsOpengl32DLL::init(bool softwareRendering)
+         // Load opengl32.dll always. GDI functions like ChoosePixelFormat do
+         // GetModuleHandle for opengl32.dll and behave differently (and call back into
+         // opengl32) when the module is present. This is fine for dummy contexts and windows.
+-        ::LoadLibraryA("opengl32.dll");
++        QSystemLibrary::load(L"opengl32");
+     }
+ 
+     wglCreateContext = reinterpret_cast<HGLRC (WINAPI *)(HDC)>(resolve("wglCreateContext"));
+diff --git a/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp b/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
+index d7d186e804..9eb4011bf2 100644
+--- a/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
++++ b/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
+@@ -49,6 +49,7 @@
+ #include <QtCore/qstandardpaths.h>
+ #include <QtCore/qlibraryinfo.h>
+ #include <QtCore/qhash.h>
++#include <private/qsystemlibrary_p.h>
+ 
+ #ifndef QT_NO_OPENGL
+ #include <private/qopengl_p.h>
+@@ -396,7 +397,7 @@ bool QWindowsOpenGLTester::testDesktopGL()
+ 
+     // Test #1: Load opengl32.dll and try to resolve an OpenGL 2 function.
+     // This will typically fail on systems that do not have a real OpenGL driver.
+-    lib = LoadLibraryA("opengl32.dll");
++    lib = QSystemLibrary::load(L"opengl32");
+     if (lib) {
+         CreateContext = reinterpret_cast<CreateContextType>(
+             reinterpret_cast<QFunctionPointer>(::GetProcAddress(lib, "wglCreateContext")));
+diff --git a/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp b/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
+index 1afa00cfc9..118af6ce73 100644
+--- a/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
++++ b/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
+@@ -41,6 +41,7 @@
+ 
+ #include <QRect>
+ #include <QList>
++#include <QMap>
+ #include <QDebug>
+ 
+ #include <qmath.h>
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp b/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
+index 9e2a37a6a1..e6e175a118 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
+@@ -488,12 +488,12 @@ void QXcbConnection::printXcbError(const char *message, xcb_generic_error_t *err
+     uint clamped_error_code = qMin<uint>(error->error_code, (sizeof(xcb_errors) / sizeof(xcb_errors[0])) - 1);
+     uint clamped_major_code = qMin<uint>(error->major_code, (sizeof(xcb_protocol_request_codes) / sizeof(xcb_protocol_request_codes[0])) - 1);
+ 
+-    qCWarning(lcQpaXcb, "%s: %d (%s), sequence: %d, resource id: %d, major code: %d (%s), minor code: %d",
+-             message,
+-             int(error->error_code), xcb_errors[clamped_error_code],
+-             int(error->sequence), int(error->resource_id),
+-             int(error->major_code), xcb_protocol_request_codes[clamped_major_code],
+-             int(error->minor_code));
++    qCDebug(lcQpaXcb, "%s: %d (%s), sequence: %d, resource id: %d, major code: %d (%s), minor code: %d",
++            message,
++            int(error->error_code), xcb_errors[clamped_error_code],
++            int(error->sequence), int(error->resource_id),
++            int(error->major_code), xcb_protocol_request_codes[clamped_major_code],
++            int(error->minor_code));
+ }
+ 
+ static Qt::MouseButtons translateMouseButtons(int s)
+@@ -702,6 +702,8 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
+             QXcbVirtualDesktop *virtualDesktop = virtualDesktopForRootWindow(propertyNotify->window);
+             if (virtualDesktop)
+                 virtualDesktop->updateWorkArea();
++        } else if (propertyNotify->atom == atom(QXcbAtom::_NET_SUPPORTED)) {
++            m_wmSupport->updateNetWMAtoms();
+         } else {
+             HANDLE_PLATFORM_WINDOW_EVENT(xcb_property_notify_event_t, window, handlePropertyNotifyEvent);
+         }
+@@ -750,7 +752,7 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
+                 case XCB_XKB_NEW_KEYBOARD_NOTIFY: {
+                     xcb_xkb_new_keyboard_notify_event_t *ev = &xkb_event->new_keyboard_notify;
+                     if (ev->changed & XCB_XKB_NKN_DETAIL_KEYCODES)
+-                        m_keyboard->updateKeymap(ev);
++                        m_keyboard->updateKeymap();
+                     break;
+                 }
+                 default:
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp b/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
+index 76869ced60..02d2eebb56 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
+@@ -274,8 +274,7 @@ QPlatformWindow *QXcbIntegration::createForeignWindow(QWindow *window, WId nativ
+ #ifndef QT_NO_OPENGL
+ QPlatformOpenGLContext *QXcbIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
+ {
+-    QXcbScreen *screen = static_cast<QXcbScreen *>(context->screen()->handle());
+-    QXcbGlIntegration *glIntegration = screen->connection()->glIntegration();
++    QXcbGlIntegration *glIntegration = defaultConnection()->glIntegration();
+     if (!glIntegration) {
+         qWarning("QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled");
+         return nullptr;
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+index efecd7e2d1..e8286381a2 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+@@ -365,17 +365,6 @@ void QXcbKeyboard::updateKeymap(xcb_mapping_notify_event_t *event)
+     updateKeymap();
+ }
+ 
+-void QXcbKeyboard::updateKeymap(xcb_xkb_new_keyboard_notify_event_t *event)
+-{
+-    if (!event)
+-        return;
+-
+-    if (event->deviceID != event->oldDeviceID)
+-        m_config = false;
+-
+-    updateKeymap();
+-}
+-
+ void QXcbKeyboard::updateKeymap()
+ {
+     KeysymModifierMap keysymMods;
+@@ -383,6 +372,8 @@ void QXcbKeyboard::updateKeymap()
+         keysymMods = keysymsToModifiers();
+     updateModifiers(keysymMods);
+ 
++    m_config = true;
++
+     if (!m_xkbContext) {
+         m_xkbContext.reset(xkb_context_new(XKB_CONTEXT_NO_DEFAULT_INCLUDES));
+         if (!m_xkbContext) {
+@@ -398,13 +389,8 @@ void QXcbKeyboard::updateKeymap()
+     if (connection()->hasXKB()) {
+         m_xkbKeymap.reset(xkb_x11_keymap_new_from_device(m_xkbContext.get(), xcb_connection(),
+                                                          core_device_id, XKB_KEYMAP_COMPILE_NO_FLAGS));
+-        if (m_xkbKeymap) {
+-            if (m_config)
+-                m_xkbState.reset(xkb_state_new(m_xkbKeymap.get()));
+-            else
+-                m_xkbState.reset(xkb_x11_state_new_from_device(m_xkbKeymap.get(), xcb_connection(), core_device_id));
+-
+-        }
++        if (m_xkbKeymap)
++            m_xkbState.reset(xkb_x11_state_new_from_device(m_xkbKeymap.get(), xcb_connection(), core_device_id));
+     } else {
+         m_xkbKeymap.reset(keymapFromCore(keysymMods));
+         if (m_xkbKeymap)
+@@ -425,8 +411,6 @@ void QXcbKeyboard::updateKeymap()
+     updateXKBMods();
+ 
+     QXkbCommon::verifyHasLatinLayout(m_xkbKeymap.get());
+-
+-    m_config = true;
+ }
+ 
+ QList<int> QXcbKeyboard::possibleKeys(const QKeyEvent *event) const
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
+index b652c85fe3..0ee08aeff2 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
++++ b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
+@@ -69,7 +69,6 @@ public:
+ 
+     Qt::KeyboardModifiers translateModifiers(int s) const;
+     void updateKeymap(xcb_mapping_notify_event_t *event);
+-    void updateKeymap(xcb_xkb_new_keyboard_notify_event_t *event);
+     void updateKeymap();
+     QList<int> possibleKeys(const QKeyEvent *event) const;
+ 
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp b/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
+index ffda7b6a57..863e961f4c 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
+@@ -564,11 +564,6 @@ void QXcbWindow::setGeometry(const QRect &rect)
+ {
+     QPlatformWindow::setGeometry(rect);
+ 
+-    if (shouldDeferTask(Task::SetGeometry)) {
+-        m_deferredGeometry = rect;
+-        return;
+-    }
+-
+     propagateSizeHints();
+ 
+     QXcbScreen *currentScreen = xcbScreen();
+@@ -693,9 +688,6 @@ void QXcbWindow::setVisible(bool visible)
+ 
+ void QXcbWindow::show()
+ {
+-    if (shouldDeferTask(Task::Map))
+-        return;
+-
+     if (window()->isTopLevel()) {
+ 
+         // update WM_NORMAL_HINTS
+@@ -706,7 +698,7 @@ void QXcbWindow::show()
+         if (isTransient(window())) {
+             const QWindow *tp = window()->transientParent();
+             if (tp && tp->handle())
+-                transientXcbParent = static_cast<const QXcbWindow *>(tp->handle())->winId();
++                transientXcbParent = tp->handle()->winId();
+             // Default to client leader if there is no transient parent, else modal dialogs can
+             // be hidden by their parents.
+             if (!transientXcbParent)
+@@ -746,10 +738,6 @@ void QXcbWindow::show()
+ 
+ void QXcbWindow::hide()
+ {
+-    if (shouldDeferTask(Task::Unmap))
+-        return;
+-
+-    m_wmStateValid = false;
+     xcb_unmap_window(xcb_connection(), m_window);
+ 
+     // send synthetic UnmapNotify event according to icccm 4.1.4
+@@ -909,9 +897,6 @@ QXcbWindow::NetWmStates QXcbWindow::netWmStates()
+ 
+ void QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
+ {
+-    if (shouldDeferTask(Task::SetWindowFlags))
+-        return;
+-
+     Qt::WindowType type = static_cast<Qt::WindowType>(int(flags & Qt::WindowType_Mask));
+ 
+     if (type == Qt::ToolTip)
+@@ -941,8 +926,6 @@ void QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
+ 
+     setTransparentForMouseEvents(flags & Qt::WindowTransparentForInput);
+     updateDoesNotAcceptFocus(flags & Qt::WindowDoesNotAcceptFocus);
+-
+-    m_isWmManagedWindow = !(flags & Qt::X11BypassWindowManagerHint);
+ }
+ 
+ void QXcbWindow::setMotifWmHints(Qt::WindowFlags flags)
+@@ -1142,9 +1125,6 @@ void QXcbWindow::setWindowState(Qt::WindowStates state)
+     if (state == m_windowState)
+         return;
+ 
+-    if (shouldDeferTask(Task::SetWindowState))
+-        return;
+-
+     // unset old state
+     if (m_windowState & Qt::WindowMinimized)
+         xcb_map_window(xcb_connection(), m_window);
+@@ -1350,6 +1330,12 @@ void QXcbWindow::setWindowIcon(const QIcon &icon)
+     }
+ 
+     if (!icon_data.isEmpty()) {
++        // Ignore icon exceeding maximum xcb request length
++        if (icon_data.size() > xcb_get_maximum_request_length(xcb_connection())) {
++            qWarning("Ignoring window icon: Size %llu exceeds maximum xcb request length %u.",
++                     icon_data.size(), xcb_get_maximum_request_length(xcb_connection()));
++            return;
++        }
+         xcb_change_property(xcb_connection(),
+                             XCB_PROP_MODE_REPLACE,
+                             m_window,
+@@ -1639,7 +1625,7 @@ void QXcbWindow::setWmWindowType(QXcbWindowFunctions::WmWindowTypes types, Qt::W
+         break;
+     }
+ 
+-    if ((flags & Qt::FramelessWindowHint) && !(type & QXcbWindowFunctions::KdeOverride)) {
++    if ((flags & Qt::FramelessWindowHint) && !(types & QXcbWindowFunctions::KdeOverride)) {
+         // override netwm type - quick and easy for KDE noborder
+         atoms.append(atom(QXcbAtom::_KDE_NET_WM_WINDOW_TYPE_OVERRIDE));
+     }
+@@ -1894,10 +1880,6 @@ void QXcbWindow::handleUnmapNotifyEvent(const xcb_unmap_notify_event_t *event)
+     if (event->window == m_window) {
+         m_mapped = false;
+         QWindowSystemInterface::handleExposeEvent(window(), QRegion());
+-        if (!m_isWmManagedWindow || parent()) {
+-            m_wmStateValid = true;
+-            handleDeferredTasks();
+-        }
+     }
+ }
+ 
+@@ -2212,98 +2194,30 @@ void QXcbWindow::handleLeaveNotifyEvent(const xcb_leave_notify_event_t *event)
+     handleLeaveNotifyEvent(event->root_x, event->root_y, event->mode, event->detail, event->time);
+ }
+ 
+-bool QXcbWindow::shouldDeferTask(Task task)
+-{
+-    if (m_wmStateValid)
+-        return false;
+-
+-    m_deferredTasks.append(task);
+-    return true;
+-}
+-
+-void QXcbWindow::handleDeferredTasks()
+-{
+-    Q_ASSERT(m_wmStateValid == true);
+-    if (m_deferredTasks.isEmpty())
+-        return;
+-
+-    bool map = false;
+-    bool unmap = false;
+-
+-    QVector<Task> tasks;
+-    for (auto taskIt = m_deferredTasks.rbegin(); taskIt != m_deferredTasks.rend(); ++taskIt) {
+-        if (!tasks.contains(*taskIt))
+-            tasks.prepend(*taskIt);
+-    }
+-
+-    for (Task task : tasks) {
+-        switch (task) {
+-        case Task::Map:
+-            map = true;
+-            unmap = false;
+-            break;
+-        case Task::Unmap:
+-            unmap = true;
+-            map = false;
+-            break;
+-        case Task::SetGeometry:
+-            setGeometry(m_deferredGeometry);
+-            break;
+-        case Task::SetWindowFlags:
+-            setWindowFlags(window()->flags());
+-            break;
+-        case Task::SetWindowState:
+-            setWindowState(window()->windowState());
+-            break;
+-        }
+-    }
+-    m_deferredTasks.clear();
+-
+-    if (map) {
+-        Q_ASSERT(unmap == false);
+-        show();
+-    }
+-    if (unmap) {
+-        Q_ASSERT(map == false);
+-        hide();
+-    }
+-}
+-
+ void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *event)
+ {
+     connection()->setTime(event->time);
+ 
+-    const bool wmStateChanged = event->atom == atom(QXcbAtom::WM_STATE);
+-    const bool netWmStateChanged = event->atom == atom(QXcbAtom::_NET_WM_STATE);
+-    if (netWmStateChanged || wmStateChanged) {
+-        if (wmStateChanged && !m_wmStateValid && m_isWmManagedWindow) {
+-            // ICCCM 4.1.4
+-            // Clients that want to re-use a client window (e.g. by mapping it again)
+-            // after withdrawing it must wait for the withdrawal to be complete before
+-            // proceeding. The preferred method for doing this is for clients to wait for
+-            // a window manager to update or remove the WM_STATE property.
+-            m_wmStateValid = true;
+-            handleDeferredTasks();
+-        }
+-        if (event->state == XCB_PROPERTY_DELETE)
++    const bool propertyDeleted = event->state == XCB_PROPERTY_DELETE;
++
++    if (event->atom == atom(QXcbAtom::_NET_WM_STATE) || event->atom == atom(QXcbAtom::WM_STATE)) {
++        if (propertyDeleted)
+             return;
+ 
+-        if (wmStateChanged) {
++        Qt::WindowStates newState = Qt::WindowNoState;
++
++        if (event->atom == atom(QXcbAtom::WM_STATE)) { // WM_STATE: Quick check for 'Minimize'.
+             auto reply = Q_XCB_REPLY(xcb_get_property, xcb_connection(),
+                                      0, m_window, atom(QXcbAtom::WM_STATE),
+                                      XCB_ATOM_ANY, 0, 1024);
+             if (reply && reply->format == 32 && reply->type == atom(QXcbAtom::WM_STATE)) {
+-                auto data = static_cast<const quint32 *>(xcb_get_property_value(reply.get()));
+-                if (reply->length != 0) {
+-                    const bool changedToWithdrawn = data[0] == XCB_ICCCM_WM_STATE_WITHDRAWN;
+-                    const bool changedToIconic = data[0] == XCB_ICCCM_WM_STATE_ICONIC;
+-                    m_minimized = changedToIconic || (changedToWithdrawn && m_minimized);
+-                }
++                const quint32 *data = (const quint32 *)xcb_get_property_value(reply.get());
++                if (reply->length != 0)
++                    m_minimized = (data[0] == XCB_ICCCM_WM_STATE_ICONIC
++                                   || (data[0] == XCB_ICCCM_WM_STATE_WITHDRAWN && m_minimized));
+             }
+         }
+ 
+-        // _NET_WM_STATE handling
+-        Qt::WindowStates newState = Qt::WindowNoState;
+         const NetWmStates states = netWmStates();
+         // _NET_WM_STATE_HIDDEN should be set by the Window Manager to indicate that a window would
+         // not be visible on the screen if its desktop/viewport were active and its coordinates were
+@@ -2325,6 +2239,7 @@ void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *ev
+             if ((m_windowState & Qt::WindowMinimized) && connection()->mouseGrabber() == this)
+                 connection()->setMouseGrabber(nullptr);
+         }
++        return;
+     } else if (event->atom == atom(QXcbAtom::_NET_FRAME_EXTENTS)) {
+         m_dirtyFrameMargins = true;
+     }
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbwindow.h b/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
+index 55af9279b1..6f5c1f5ed9 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
++++ b/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
+@@ -74,14 +74,6 @@ public:
+ 
+     Q_DECLARE_FLAGS(NetWmStates, NetWmState)
+ 
+-    enum Task {
+-        Map,
+-        Unmap,
+-        SetGeometry,
+-        SetWindowFlags,
+-        SetWindowState
+-    };
+-
+     QXcbWindow(QWindow *window);
+     ~QXcbWindow();
+ 
+@@ -151,9 +143,6 @@ public:
+ 
+     QXcbWindow *toWindow() override;
+ 
+-    bool shouldDeferTask(Task task);
+-    void handleDeferredTasks();
+-
+     void handleMouseEvent(xcb_timestamp_t time, const QPoint &local, const QPoint &global,
+                           Qt::KeyboardModifiers modifiers, QEvent::Type type, Qt::MouseEventSource source);
+ 
+@@ -292,11 +281,6 @@ protected:
+     int m_swapInterval = -1;
+ 
+     qreal m_sizeHintsScaleFactor = 1.0;
+-
+-    bool m_wmStateValid = true;
+-    QVector<Task> m_deferredTasks;
+-    bool m_isWmManagedWindow = true;
+-    QRect m_deferredGeometry;
+ };
+ 
+ class QXcbForeignWindow : public QXcbWindow
+diff --git a/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp b/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
+index d9d117faeb..640b49daa0 100644
+--- a/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
++++ b/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
+@@ -85,6 +85,7 @@ QGtk3MenuItem::QGtk3MenuItem()
+       m_checkable(false),
+       m_checked(false),
+       m_enabled(true),
++      m_exclusive(false),
+       m_underline(false),
+       m_invalid(true),
+       m_menu(nullptr),
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
+index 0048bbc1e6..396e7f6d1c 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
+@@ -102,15 +102,12 @@ const QDBusArgument &operator >>(const QDBusArgument &arg, QXdgDesktopPortalFile
+ class QXdgDesktopPortalFileDialogPrivate
+ {
+ public:
+-    QXdgDesktopPortalFileDialogPrivate(QPlatformFileDialogHelper *nativeFileDialog)
++    QXdgDesktopPortalFileDialogPrivate(QPlatformFileDialogHelper *nativeFileDialog, uint fileChooserPortalVersion)
+         : nativeFileDialog(nativeFileDialog)
++        , fileChooserPortalVersion(fileChooserPortalVersion)
+     { }
+ 
+-    WId winId = 0;
+-    bool directoryMode = false;
+-    bool modal = false;
+-    bool multipleFiles = false;
+-    bool saveFile = false;
++    QEventLoop loop;
+     QString acceptLabel;
+     QString directory;
+     QString title;
+@@ -121,19 +118,27 @@ public:
+     QString selectedMimeTypeFilter;
+     QString selectedNameFilter;
+     QStringList selectedFiles;
+-    QPlatformFileDialogHelper *nativeFileDialog = nullptr;
++    std::unique_ptr<QPlatformFileDialogHelper> nativeFileDialog;
++    uint fileChooserPortalVersion = 0;
++    bool failedToOpen = false;
++    bool directoryMode = false;
++    bool multipleFiles = false;
++    bool saveFile = false;
+ };
+ 
+-QXdgDesktopPortalFileDialog::QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog)
++QXdgDesktopPortalFileDialog::QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog, uint fileChooserPortalVersion)
+     : QPlatformFileDialogHelper()
+-    , d_ptr(new QXdgDesktopPortalFileDialogPrivate(nativeFileDialog))
++    , d_ptr(new QXdgDesktopPortalFileDialogPrivate(nativeFileDialog, fileChooserPortalVersion))
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+     if (d->nativeFileDialog) {
+-        connect(d->nativeFileDialog, SIGNAL(accept()), this, SIGNAL(accept()));
+-        connect(d->nativeFileDialog, SIGNAL(reject()), this, SIGNAL(reject()));
++        connect(d->nativeFileDialog.get(), SIGNAL(accept()), this, SIGNAL(accept()));
++        connect(d->nativeFileDialog.get(), SIGNAL(reject()), this, SIGNAL(reject()));
+     }
++
++    d->loop.connect(this, SIGNAL(accept()), SLOT(quit()));
++    d->loop.connect(this, SIGNAL(reject()), SLOT(quit()));
+ }
+ 
+ QXdgDesktopPortalFileDialog::~QXdgDesktopPortalFileDialog()
+@@ -177,7 +182,7 @@ void QXdgDesktopPortalFileDialog::initializeDialog()
+     setDirectory(options()->initialDirectory());
+ }
+ 
+-void QXdgDesktopPortalFileDialog::openPortal()
++void QXdgDesktopPortalFileDialog::openPortal(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent)
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+@@ -185,13 +190,13 @@ void QXdgDesktopPortalFileDialog::openPortal()
+                                                           QLatin1String("/org/freedesktop/portal/desktop"),
+                                                           QLatin1String("org.freedesktop.portal.FileChooser"),
+                                                           d->saveFile ? QLatin1String("SaveFile") : QLatin1String("OpenFile"));
+-    QString parentWindowId = QLatin1String("x11:") + QString::number(d->winId, 16);
++    QString parentWindowId = QLatin1String("x11:") + QString::number(parent ? parent->winId() : 0, 16);
+ 
+     QVariantMap options;
+     if (!d->acceptLabel.isEmpty())
+         options.insert(QLatin1String("accept_label"), d->acceptLabel);
+ 
+-    options.insert(QLatin1String("modal"), d->modal);
++    options.insert(QLatin1String("modal"), windowModality != Qt::NonModal);
+     options.insert(QLatin1String("multiple"), d->multipleFiles);
+     options.insert(QLatin1String("directory"), d->directoryMode);
+ 
+@@ -290,10 +295,18 @@ void QXdgDesktopPortalFileDialog::openPortal()
+ 
+     QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
+     QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingCall);
+-    connect(watcher, &QDBusPendingCallWatcher::finished, this, [this] (QDBusPendingCallWatcher *watcher) {
++    connect(watcher, &QDBusPendingCallWatcher::finished, this, [=] (QDBusPendingCallWatcher *watcher) {
+         QDBusPendingReply<QDBusObjectPath> reply = *watcher;
+-        if (reply.isError()) {
+-            Q_EMIT reject();
++        // Any error means the dialog is not shown and we need to fallback
++        d->failedToOpen = reply.isError();
++        if (d->failedToOpen) {
++            if (d->nativeFileDialog) {
++                d->nativeFileDialog->show(windowFlags, windowModality, parent);
++                if (d->loop.isRunning())
++                    d->nativeFileDialog->exec();
++            } else {
++                Q_EMIT reject();
++            }
+         } else {
+             QDBusConnection::sessionBus().connect(nullptr,
+                                                   reply.value().path(),
+@@ -302,6 +315,7 @@ void QXdgDesktopPortalFileDialog::openPortal()
+                                                   this,
+                                                   SLOT(gotResponse(uint,QVariantMap)));
+         }
++        watcher->deleteLater();
+     });
+ }
+ 
+@@ -326,7 +340,7 @@ QUrl QXdgDesktopPortalFileDialog::directory() const
+ {
+     Q_D(const QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog())
+         return d->nativeFileDialog->directory();
+ 
+     return d->directory;
+@@ -348,7 +362,7 @@ QList<QUrl> QXdgDesktopPortalFileDialog::selectedFiles() const
+ {
+     Q_D(const QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog())
+         return d->nativeFileDialog->selectedFiles();
+ 
+     QList<QUrl> files;
+@@ -403,16 +417,13 @@ void QXdgDesktopPortalFileDialog::exec()
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly)) {
++    if (d->nativeFileDialog && useNativeFileDialog()) {
+         d->nativeFileDialog->exec();
+         return;
+     }
+ 
+     // HACK we have to avoid returning until we emit that the dialog was accepted or rejected
+-    QEventLoop loop;
+-    loop.connect(this, SIGNAL(accept()), SLOT(quit()));
+-    loop.connect(this, SIGNAL(reject()), SLOT(quit()));
+-    loop.exec();
++    d->loop.exec();
+ }
+ 
+ void QXdgDesktopPortalFileDialog::hide()
+@@ -429,13 +440,10 @@ bool QXdgDesktopPortalFileDialog::show(Qt::WindowFlags windowFlags, Qt::WindowMo
+ 
+     initializeDialog();
+ 
+-    d->modal = windowModality != Qt::NonModal;
+-    d->winId = parent ? parent->winId() : 0;
+-
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog(OpenFallback))
+         return d->nativeFileDialog->show(windowFlags, windowModality, parent);
+ 
+-    openPortal();
++    openPortal(windowFlags, windowModality, parent);
+ 
+     return true;
+ }
+@@ -465,4 +473,21 @@ void QXdgDesktopPortalFileDialog::gotResponse(uint response, const QVariantMap &
+     }
+ }
+ 
++bool QXdgDesktopPortalFileDialog::useNativeFileDialog(QXdgDesktopPortalFileDialog::FallbackType fallbackType) const
++{
++    Q_D(const QXdgDesktopPortalFileDialog);
++
++    if (d->failedToOpen && fallbackType != OpenFallback)
++        return true;
++
++    if (d->fileChooserPortalVersion < 3) {
++        if (options()->fileMode() == QFileDialogOptions::Directory)
++            return true;
++        else if (options()->fileMode() == QFileDialogOptions::DirectoryOnly)
++            return true;
++    }
++
++    return false;
++}
++
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
+index 4f4de96ecf..65e22a5cf2 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
+@@ -51,6 +51,11 @@ class QXdgDesktopPortalFileDialog : public QPlatformFileDialogHelper
+     Q_OBJECT
+     Q_DECLARE_PRIVATE(QXdgDesktopPortalFileDialog)
+ public:
++    enum FallbackType {
++        GenericFallback,
++        OpenFallback
++    };
++
+     enum ConditionType : uint {
+         GlobalPattern = 0,
+         MimeType = 1
+@@ -69,7 +74,7 @@ public:
+     };
+     typedef QVector<Filter> FilterList;
+ 
+-    QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog = nullptr);
++    QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog = nullptr, uint fileChooserPortalVersion = 0);
+     ~QXdgDesktopPortalFileDialog();
+ 
+     bool defaultNameFilterDisables() const override;
+@@ -92,7 +97,8 @@ private Q_SLOTS:
+ 
+ private:
+     void initializeDialog();
+-    void openPortal();
++    void openPortal(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent);
++    bool useNativeFileDialog(FallbackType fallbackType = GenericFallback) const;
+ 
+     QScopedPointer<QXdgDesktopPortalFileDialogPrivate> d_ptr;
+ };
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
+index fb324afbd8..b809503122 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
+@@ -111,6 +111,7 @@ QXdgDesktopPortalTheme::QXdgDesktopPortalTheme()
+         if (reply.isValid()) {
+             d->fileChooserPortalVersion = reply.value().toUInt();
+         }
++        watcher->deleteLater();
+     });
+ }
+ 
+@@ -152,11 +153,12 @@ QPlatformDialogHelper* QXdgDesktopPortalTheme::createPlatformDialogHelper(Dialog
+ {
+     Q_D(const QXdgDesktopPortalTheme);
+ 
+-    if (type == FileDialog) {
++    if (type == FileDialog && d->fileChooserPortalVersion) {
+         // Older versions of FileChooser portal don't support opening directories, therefore we fallback
+         // to native file dialog opened inside the sandbox to open a directory.
+-        if (d->fileChooserPortalVersion < 3 && d->baseTheme->usePlatformNativeDialog(type))
+-            return new QXdgDesktopPortalFileDialog(static_cast<QPlatformFileDialogHelper*>(d->baseTheme->createPlatformDialogHelper(type)));
++        if (d->baseTheme->usePlatformNativeDialog(type))
++            return new QXdgDesktopPortalFileDialog(static_cast<QPlatformFileDialogHelper*>(d->baseTheme->createPlatformDialogHelper(type)),
++                                                   d->fileChooserPortalVersion);
+ 
+         return new QXdgDesktopPortalFileDialog;
+     }
+diff --git a/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp b/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
+index 43d5e119ad..1f9cbc4565 100644
+--- a/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
++++ b/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
+@@ -89,8 +89,10 @@ void QCupsPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &v
+         break;
+     case PPK_Duplex: {
+         QPrint::DuplexMode mode = QPrint::DuplexMode(value.toInt());
+-        if (mode != d->duplex && d->m_printDevice.supportedDuplexModes().contains(mode))
++        if (d->m_printDevice.supportedDuplexModes().contains(mode)) {
+             d->duplex = mode;
++            d->duplexRequestedExplicitly = true;
++        }
+         break;
+     }
+     case PPK_PrinterName:
+@@ -277,9 +279,12 @@ void QCupsPrintEnginePrivate::changePrinter(const QString &newPrinter)
+     m_printDevice.swap(printDevice);
+     printerName = m_printDevice.id();
+ 
+-    // Check if new printer supports current settings, otherwise us defaults
+-    if (duplex != QPrint::DuplexAuto && !m_printDevice.supportedDuplexModes().contains(duplex))
++    // in case a duplex value was explicitly set, check if new printer supports current value,
++    // otherwise use device default
++    if (!duplexRequestedExplicitly || !m_printDevice.supportedDuplexModes().contains(duplex)) {
+         duplex = m_printDevice.defaultDuplexMode();
++        duplexRequestedExplicitly = false;
++    }
+     QPrint::ColorMode colorMode = grayscale ? QPrint::GrayScale : QPrint::Color;
+     if (!m_printDevice.supportedColorModes().contains(colorMode))
+         grayscale = m_printDevice.defaultColorMode() == QPrint::GrayScale;
+diff --git a/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h b/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
+index c021b0c643..8f81fe478d 100644
+--- a/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
++++ b/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
+@@ -100,6 +100,7 @@ private:
+     QStringList cupsOptions;
+     QString cupsTempFile;
+     QPrint::DuplexMode duplex;
++    bool duplexRequestedExplicitly = false;
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp b/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
+index 67e7154fa6..40876152e5 100644
+--- a/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
++++ b/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
+@@ -817,7 +817,7 @@ bool QIBaseResultPrivate::writeArray(int column, const QList<QVariant> &list)
+     ba.resize(int(bufLen));
+ 
+     if (list.size() > arraySize) {
+-        error = QLatin1String("Array size missmatch: size of %1 is %2, size of provided list is %3");
++        error = QLatin1String("Array size mismatch: size of %1 is %2, size of provided list is %3");
+         error = error.arg(QLatin1String(sqlname)).arg(arraySize).arg(list.size());
+         q->setLastError(QSqlError(error, QLatin1String(""), QSqlError::StatementError));
+         return false;
+diff --git a/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp b/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
+index 7ca055eea2..6bc9d46755 100644
+--- a/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
++++ b/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
+@@ -223,7 +223,7 @@ public:
+     struct QMyField
+     {
+         char *outField = nullptr;
+-        MYSQL_FIELD *myField = nullptr;
++        const MYSQL_FIELD *myField = nullptr;
+         QMetaType::Type type = QMetaType::UnknownType;
+         my_bool nullIndicator = false;
+         ulong bufLength = 0ul;
+@@ -361,7 +361,7 @@ static bool qIsInteger(int t)
+ void QMYSQLResultPrivate::bindBlobs()
+ {
+     int i;
+-    MYSQL_FIELD *fieldInfo;
++    const MYSQL_FIELD *fieldInfo;
+     MYSQL_BIND *bind;
+ 
+     for(i = 0; i < fields.count(); ++i) {
+@@ -379,7 +379,6 @@ void QMYSQLResultPrivate::bindBlobs()
+ bool QMYSQLResultPrivate::bindInValues()
+ {
+     MYSQL_BIND *bind;
+-    char *field;
+     int i = 0;
+ 
+     if (!meta)
+@@ -392,35 +391,34 @@ bool QMYSQLResultPrivate::bindInValues()
+     inBinds = new MYSQL_BIND[fields.size()];
+     memset(inBinds, 0, fields.size() * sizeof(MYSQL_BIND));
+ 
+-    MYSQL_FIELD *fieldInfo;
++    const MYSQL_FIELD *fieldInfo;
+ 
+     while((fieldInfo = mysql_fetch_field(meta))) {
++        bind = &inBinds[i];
++
+         QMyField &f = fields[i];
+         f.myField = fieldInfo;
+-
++        bind->buffer_length = f.bufLength = fieldInfo->length + 1;
++        bind->buffer_type = fieldInfo->type;
+         f.type = qDecodeMYSQLType(fieldInfo->type, fieldInfo->flags);
+         if (qIsBlob(fieldInfo->type)) {
+             // the size of a blob-field is available as soon as we call
+             // mysql_stmt_store_result()
+             // after mysql_stmt_exec() in QMYSQLResult::exec()
+-            fieldInfo->length = 0;
++            bind->buffer_length = f.bufLength = 0;
+             hasBlobs = true;
+         } else if (qIsInteger(f.type)) {
+-            fieldInfo->length = 8;
++            bind->buffer_length = f.bufLength = 8;
+         } else {
+-            fieldInfo->type = MYSQL_TYPE_STRING;
++            bind->buffer_type = MYSQL_TYPE_STRING;
+         }
+-        bind = &inBinds[i];
+-        field = new char[fieldInfo->length + 1];
+-        memset(field, 0, fieldInfo->length + 1);
+ 
+-        bind->buffer_type = fieldInfo->type;
+-        bind->buffer = field;
+-        bind->buffer_length = f.bufLength = fieldInfo->length + 1;
+         bind->is_null = &f.nullIndicator;
+         bind->length = &f.bufLength;
+         bind->is_unsigned = fieldInfo->flags & UNSIGNED_FLAG ? 1 : 0;
+-        f.outField=field;
++
++        char *field = new char[bind->buffer_length + 1]{};
++        bind->buffer = f.outField = field;
+ 
+         ++i;
+     }
+@@ -1369,20 +1367,20 @@ bool QMYSQLDriver::open(const QString& db,
+     }
+ 
+ #if MYSQL_VERSION_ID >= 50007
+-    if (mysql_get_client_version() >= 50503 && mysql_get_server_version(d->mysql) >= 50503) {
+-        // force the communication to be utf8mb4 (only utf8mb4 supports 4-byte characters)
+-        mysql_set_character_set(d->mysql, "utf8mb4");
++    // force the communication to be utf8mb4 (only utf8mb4 supports 4-byte characters)
++    if (mysql_set_character_set(d->mysql, "utf8mb4")) {
++        // this failed, try forcing it to utf (BMP only)
++        if (mysql_set_character_set(d->mysql, "utf8"))
++            qWarning() << "MySQL: Unable to set the client character set to utf8.";
+ #if QT_CONFIG(textcodec)
+-        d->tc = QTextCodec::codecForName("UTF-8");
++        else
++            d->tc = codec(d->mysql);
+ #endif
+-    } else
+-    {
+-        // force the communication to be utf8
+-        mysql_set_character_set(d->mysql, "utf8");
++    }
+ #if QT_CONFIG(textcodec)
+-        d->tc = codec(d->mysql);
++    else
++        d->tc = QTextCodec::codecForName("UTF-8");
+ #endif
+-    }
+ #endif  // MYSQL_VERSION_ID >= 50007
+ 
+     d->preparedQuerysEnabled = checkPreparedQueries(d->mysql);
+diff --git a/qtbase/src/printsupport/dialogs/images/print-24.png b/qtbase/src/printsupport/dialogs/images/printer-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/print-24.png
+rename to src/printsupport/dialogs/images/printer-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/print-32.png b/qtbase/src/printsupport/dialogs/images/printer-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/print-32.png
+rename to src/printsupport/dialogs/images/printer-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-sided-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-facing-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-sided-24.png
+rename to src/printsupport/dialogs/images/view-pages-facing-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-sided-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-facing-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-sided-32.png
+rename to src/printsupport/dialogs/images/view-pages-facing-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-multi-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-overview-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-multi-24.png
+rename to src/printsupport/dialogs/images/view-pages-overview-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-multi-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-overview-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-multi-32.png
+rename to src/printsupport/dialogs/images/view-pages-overview-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-one-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-single-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-one-24.png
+rename to src/printsupport/dialogs/images/view-pages-single-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-one-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-single-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-one-32.png
+rename to src/printsupport/dialogs/images/view-pages-single-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-page-24.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-page-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-page-24.png
+rename to src/printsupport/dialogs/images/zoom-fit-page-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-page-32.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-page-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-page-32.png
+rename to src/printsupport/dialogs/images/zoom-fit-page-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-width-24.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-width-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-width-24.png
+rename to src/printsupport/dialogs/images/zoom-fit-width-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-width-32.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-width-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-width-32.png
+rename to src/printsupport/dialogs/images/zoom-fit-width-32.png
+diff --git a/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp b/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
+index 78e5b8d1ef..2a28516719 100644
+--- a/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
++++ b/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
+@@ -532,6 +532,7 @@ void QPageSetupWidget::updateWidget()
+ void QPageSetupWidget::setupPrinter() const
+ {
+     m_printer->setPageLayout(m_pageLayout);
++    m_printer->setPageOrientation(m_pageLayout.orientation());
+ #if QT_CONFIG(cups)
+     QCUPSSupport::PagesPerSheet pagesPerSheet = qvariant_cast<QCUPSSupport::PagesPerSheet>(m_ui.pagesPerSheetCombo->currentData()
+ );
+diff --git a/qtbase/src/printsupport/dialogs/qprintdialog.qrc b/qtbase/src/printsupport/dialogs/qprintdialog.qrc
+index 5a579baa55..10b8e1d341 100644
+--- a/qtbase/src/printsupport/dialogs/qprintdialog.qrc
++++ b/qtbase/src/printsupport/dialogs/qprintdialog.qrc
+@@ -1,9 +1,9 @@
+ <!DOCTYPE RCC><RCC version="1.0">
+ <qresource prefix="/qt-project.org/dialogs/qprintpreviewdialog">
+-<file>images/fit-page-24.png</file>
+-<file>images/fit-page-32.png</file>
+-<file>images/fit-width-24.png</file>
+-<file>images/fit-width-32.png</file>
++<file>images/zoom-fit-page-24.png</file>
++<file>images/zoom-fit-page-32.png</file>
++<file>images/zoom-fit-width-24.png</file>
++<file>images/zoom-fit-width-32.png</file>
+ <file>images/go-first-24.png</file>
+ <file>images/go-first-32.png</file>
+ <file>images/go-last-24.png</file>
+@@ -18,14 +18,14 @@
+ <file>images/layout-portrait-32.png</file>
+ <file>images/page-setup-24.png</file>
+ <file>images/page-setup-32.png</file>
+-<file>images/print-24.png</file>
+-<file>images/print-32.png</file>
+-<file>images/view-page-multi-24.png</file>
+-<file>images/view-page-multi-32.png</file>
+-<file>images/view-page-one-24.png</file>
+-<file>images/view-page-one-32.png</file>
+-<file>images/view-page-sided-24.png</file>
+-<file>images/view-page-sided-32.png</file>
++<file>images/printer-24.png</file>
++<file>images/printer-32.png</file>
++<file>images/view-pages-overview-24.png</file>
++<file>images/view-pages-overview-32.png</file>
++<file>images/view-pages-single-24.png</file>
++<file>images/view-pages-single-32.png</file>
++<file>images/view-pages-facing-24.png</file>
++<file>images/view-pages-facing-32.png</file>
+ <file>images/zoom-in-24.png</file>
+ <file>images/zoom-in-32.png</file>
+ <file>images/zoom-out-24.png</file>
+diff --git a/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp b/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
+index c5b845f4ec..5a5ba1d0a8 100644
+--- a/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
++++ b/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
+@@ -702,13 +702,14 @@ void QPrintDialogPrivate::selectPrinter(const QPrinter::OutputFormat outputForma
+         else
+             options.grayscale->setChecked(true);
+ 
+-        // keep duplex value explicitly set by user, if any, and selected printer supports it;
+-        // use device default otherwise
++        // duplex priorities to be as follows:
++        // 1) a user-selected duplex value in the dialog has highest prority
++        // 2) duplex value set in the QPrinter
+         QPrint::DuplexMode duplex;
+         if (explicitDuplexMode != QPrint::DuplexAuto && supportedDuplexMode.contains(explicitDuplexMode))
+             duplex = explicitDuplexMode;
+         else
+-            duplex = top->d->m_currentPrintDevice.defaultDuplexMode();
++            duplex = static_cast<QPrint::DuplexMode>(p->duplex());
+         switch (duplex) {
+         case QPrint::DuplexNone:
+             options.noDuplex->setChecked(true); break;
+@@ -1242,10 +1243,10 @@ void QUnixPrintWidgetPrivate::_q_printerChanged(int index)
+             QString filename = widget.filename->text();
+             widget.filename->setText(filename);
+             widget.lOutput->setEnabled(true);
+-            if (optionsPane)
+-                optionsPane->selectPrinter(QPrinter::PdfFormat);
+             printer->setOutputFormat(QPrinter::PdfFormat);
+             m_currentPrintDevice = QPrintDevice();
++            if (optionsPane)
++                optionsPane->selectPrinter(QPrinter::PdfFormat);
+             return;
+         }
+     }
+diff --git a/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp b/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
+index 39575d5f57..23b7e89538 100644
+--- a/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
++++ b/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
+@@ -352,7 +352,7 @@ void QPrintPreviewDialogPrivate::init(QPrinter *_printer)
+ static inline void qt_setupActionIcon(QAction *action, QLatin1String name)
+ {
+     QLatin1String imagePrefix(":/qt-project.org/dialogs/qprintpreviewdialog/images/");
+-    QIcon icon;
++    QIcon icon = QIcon::fromTheme(name);
+     icon.addFile(imagePrefix + name + QLatin1String("-24.png"), QSize(24, 24));
+     icon.addFile(imagePrefix + name + QLatin1String("-32.png"), QSize(32, 32));
+     action->setIcon(icon);
+@@ -383,8 +383,8 @@ void QPrintPreviewDialogPrivate::setupActions()
+     fitPageAction->setObjectName(QLatin1String("fitPageAction"));
+     fitWidthAction->setCheckable(true);
+     fitPageAction->setCheckable(true);
+-    qt_setupActionIcon(fitWidthAction, QLatin1String("fit-width"));
+-    qt_setupActionIcon(fitPageAction, QLatin1String("fit-page"));
++    qt_setupActionIcon(fitWidthAction, QLatin1String("zoom-fit-width"));
++    qt_setupActionIcon(fitPageAction, QLatin1String("zoom-fit-page"));
+     QObject::connect(fitGroup, SIGNAL(triggered(QAction*)), q, SLOT(_q_fit(QAction*)));
+ 
+     // Zoom
+@@ -410,9 +410,9 @@ void QPrintPreviewDialogPrivate::setupActions()
+     singleModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show single page"));
+     facingModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show facing pages"));
+     overviewModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show overview of all pages"));
+-    qt_setupActionIcon(singleModeAction, QLatin1String("view-page-one"));
+-    qt_setupActionIcon(facingModeAction, QLatin1String("view-page-sided"));
+-    qt_setupActionIcon(overviewModeAction, QLatin1String("view-page-multi"));
++    qt_setupActionIcon(singleModeAction, QLatin1String("view-pages-single"));
++    qt_setupActionIcon(facingModeAction, QLatin1String("view-pages-facing"));
++    qt_setupActionIcon(overviewModeAction, QLatin1String("view-pages-overview"));
+     singleModeAction->setObjectName(QLatin1String("singleModeAction"));
+     facingModeAction->setObjectName(QLatin1String("facingModeAction"));
+     overviewModeAction->setObjectName(QLatin1String("overviewModeAction"));
+@@ -426,7 +426,7 @@ void QPrintPreviewDialogPrivate::setupActions()
+     printerGroup = new QActionGroup(q);
+     printAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Print"));
+     pageSetupAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Page setup"));
+-    qt_setupActionIcon(printAction, QLatin1String("print"));
++    qt_setupActionIcon(printAction, QLatin1String("printer"));
+     qt_setupActionIcon(pageSetupAction, QLatin1String("page-setup"));
+     QObject::connect(printAction, SIGNAL(triggered(bool)), q, SLOT(_q_print()));
+     QObject::connect(pageSetupAction, SIGNAL(triggered(bool)), q, SLOT(_q_pageSetup()));
+diff --git a/qtbase/src/sql/kernel/qsqlquery.cpp b/qtbase/src/sql/kernel/qsqlquery.cpp
+index 32c6166c79..60afef10c3 100644
+--- a/qtbase/src/sql/kernel/qsqlquery.cpp
++++ b/qtbase/src/sql/kernel/qsqlquery.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2022 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtSql module of the Qt Toolkit.
+@@ -377,6 +377,10 @@ bool QSqlQuery::exec(const QString& query)
+     QElapsedTimer t;
+     t.start();
+ #endif
++    if (!driver()) {
++        qWarning("QSqlQuery::exec: called before driver has been set up");
++        return false;
++    }
+     if (d->ref.loadRelaxed() != 1) {
+         bool fo = isForwardOnly();
+         *this = QSqlQuery(driver()->createResult());
+diff --git a/qtbase/src/testlib/qabstractitemmodeltester.cpp b/qtbase/src/testlib/qabstractitemmodeltester.cpp
+index 8efb9c53d4..ce062f66d7 100644
+--- a/qtbase/src/testlib/qabstractitemmodeltester.cpp
++++ b/qtbase/src/testlib/qabstractitemmodeltester.cpp
+@@ -454,7 +454,7 @@ void QAbstractItemModelTesterPrivate::parent()
+ 
+     // Common error test #2, make sure that a second level index has a parent
+     // that is the first level index.
+-    if (model->rowCount(topIndex) > 0) {
++    if (model->rowCount(topIndex) > 0 && model->columnCount(topIndex) > 0) {
+         QModelIndex childIndex = model->index(0, 0, topIndex);
+         MODELTESTER_VERIFY(childIndex.isValid());
+         MODELTESTER_COMPARE(model->parent(childIndex), topIndex);
+diff --git a/qtbase/src/testlib/qasciikey.cpp b/qtbase/src/testlib/qasciikey.cpp
+index 9a308da2bc..93498b256f 100644
+--- a/qtbase/src/testlib/qasciikey.cpp
++++ b/qtbase/src/testlib/qasciikey.cpp
+@@ -498,6 +498,11 @@ char QTest::keyToAscii(Qt::Key key)
+     case Qt::Key_LaunchE : return 0; // = 0x10b0,
+     case Qt::Key_LaunchF : return 0; // = 0x10b1,
+ 
++    // Keypad navigation keys
++    case Qt::Key_Select : return 0; // = 0x01010000
++    case Qt::Key_Yes : return 0; // = 0x01010001
++    case Qt::Key_No : return 0; // = 0x01010002
++
+     default: QTEST_ASSERT(false); return 0;
+     }
+ }
+diff --git a/qtbase/src/testlib/qtestresult.cpp b/qtbase/src/testlib/qtestresult.cpp
+index 88028aac6e..2e89930776 100644
+--- a/qtbase/src/testlib/qtestresult.cpp
++++ b/qtbase/src/testlib/qtestresult.cpp
+@@ -251,7 +251,8 @@ bool QTestResult::verify(bool statement, const char *statementStr,
+ {
+     QTEST_ASSERT(statementStr);
+ 
+-    char msg[1024] = {'\0'};
++    char msg[1024];
++    msg[0] = '\0';
+ 
+     if (QTestLog::verboseLevel() >= 2) {
+         qsnprintf(msg, 1024, "QVERIFY(%s)", statementStr);
+@@ -309,7 +310,8 @@ static bool compareHelper(bool success, const char *failureMsg,
+                           bool hasValues = true)
+ {
+     const size_t maxMsgLen = 1024;
+-    char msg[maxMsgLen] = {'\0'};
++    char msg[maxMsgLen];
++    msg[0] = '\0';
+ 
+     QTEST_ASSERT(expected);
+     QTEST_ASSERT(actual);
+diff --git a/qtbase/src/widgets/dialogs/qcolordialog.cpp b/qtbase/src/widgets/dialogs/qcolordialog.cpp
+index 4247731275..cb325be85c 100644
+--- a/qtbase/src/widgets/dialogs/qcolordialog.cpp
++++ b/qtbase/src/widgets/dialogs/qcolordialog.cpp
+@@ -78,7 +78,10 @@
+ #include "qwindow.h"
+ 
+ #include "private/qdialog_p.h"
++#include "private/qguiapplication_p.h"
+ 
++#include <qpa/qplatformservices.h>
++#include <qpa/qplatformintegration.h>
+ #include <algorithm>
+ 
+ QT_BEGIN_NAMESPACE
+@@ -1611,6 +1614,20 @@ void QColorDialogPrivate::_q_newStandard(int r, int c)
+ void QColorDialogPrivate::_q_pickScreenColor()
+ {
+     Q_Q(QColorDialog);
++
++    auto *platformServices = QGuiApplicationPrivate::platformIntegration()->services();
++    if (platformServices->hasCapability(QPlatformServices::Capability::ColorPicking)) {
++        if (auto *colorPicker = platformServices->colorPicker(q->windowHandle())) {
++            q->connect(colorPicker, &QPlatformServiceColorPicker::colorPicked, q,
++                       [q, colorPicker](const QColor &color) {
++                           colorPicker->deleteLater();
++                           q->setCurrentColor(color);
++                       });
++            colorPicker->pickColor();
++            return;
++        }
++    }
++
+     if (!colorPickingEventFilter)
+         colorPickingEventFilter = new QColorPickingEventFilter(this, q);
+     q->installEventFilter(colorPickingEventFilter);
+diff --git a/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp b/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
+index e120817edc..8ea36b5427 100644
+--- a/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
++++ b/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
+@@ -400,12 +400,7 @@ bool QAbstractItemDelegate::helpEvent(QHelpEvent *event,
+         const QString tooltip = index.isValid() ?
+               d->textForRole(Qt::ToolTipRole, index.data(Qt::ToolTipRole), option.locale, precision) :
+               QString();
+-        QRect rect;
+-        if (index.isValid()) {
+-            const QRect r = view->visualRect(index);
+-            rect = QRect(view->mapToGlobal(r.topLeft()), r.size());
+-        }
+-        QToolTip::showText(he->globalPos(), tooltip, view, rect);
++        QToolTip::showText(he->globalPos(), tooltip, view->viewport(), option.rect);
+         event->setAccepted(!tooltip.isEmpty());
+         break;
+         }
+diff --git a/qtbase/src/widgets/itemviews/qlistview.cpp b/qtbase/src/widgets/itemviews/qlistview.cpp
+index 2b34476642..eebfaa030e 100644
+--- a/qtbase/src/widgets/itemviews/qlistview.cpp
++++ b/qtbase/src/widgets/itemviews/qlistview.cpp
+@@ -3386,6 +3386,7 @@ void QIconModeViewBase::updateContentsSize()
+ */
+ void QListView::currentChanged(const QModelIndex &current, const QModelIndex &previous)
+ {
++    QAbstractItemView::currentChanged(current, previous);
+ #ifndef QT_NO_ACCESSIBILITY
+     if (QAccessible::isActive()) {
+         if (current.isValid()) {
+@@ -3396,7 +3397,6 @@ void QListView::currentChanged(const QModelIndex &current, const QModelIndex &pr
+         }
+     }
+ #endif
+-    QAbstractItemView::currentChanged(current, previous);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/widgets/itemviews/qtableview.cpp b/qtbase/src/widgets/itemviews/qtableview.cpp
+index 934ac581b2..f79bb24249 100644
+--- a/qtbase/src/widgets/itemviews/qtableview.cpp
++++ b/qtbase/src/widgets/itemviews/qtableview.cpp
+@@ -1013,6 +1013,7 @@ void QTableViewPrivate::drawCell(QPainter *painter, const QStyleOptionViewItem &
+ int QTableViewPrivate::widthHintForIndex(const QModelIndex &index, int hint, const QStyleOptionViewItem &option) const
+ {
+     Q_Q(const QTableView);
++    const int oldHint = hint;
+     QWidget *editor = editorForIndex(index).widget.data();
+     if (editor && persistent.contains(editor)) {
+         hint = qMax(hint, editor->sizeHint().width());
+@@ -1021,6 +1022,17 @@ int QTableViewPrivate::widthHintForIndex(const QModelIndex &index, int hint, con
+         hint = qBound(min, hint, max);
+     }
+     hint = qMax(hint, q->itemDelegate(index)->sizeHint(option, index).width());
++
++    if (hasSpans()) {
++        auto span = spans.spanAt(index.column(), index.row());
++        if (span && span->m_left == index.column() && span->m_top == index.row()) {
++            // spans are screwed up when sections are moved
++            const auto left = logicalColumn(span->m_left);
++            for (int i = 1; i <= span->width(); ++i)
++               hint -= q->columnWidth(visualColumn(left + i));
++        }
++        hint = std::max(hint, oldHint);
++    }
+     return hint;
+ }
+ 
+@@ -1053,6 +1065,11 @@ int QTableViewPrivate::heightHintForIndex(const QModelIndex &index, int hint, QS
+         option.rect.setHeight(height);
+         option.rect.setX(q->columnViewportPosition(index.column()));
+         option.rect.setWidth(q->columnWidth(index.column()));
++        if (hasSpans()) {
++            auto span = spans.spanAt(index.column(), index.row());
++            if (span && span->m_left == index.column() && span->m_top == index.row())
++                option.rect.setWidth(std::max(option.rect.width(), visualSpanRect(*span).width()));
++        }
+         // 1px less space when grid is shown (see drawCell)
+         if (showGrid)
+             option.rect.setWidth(option.rect.width() - 1);
+diff --git a/qtbase/src/widgets/kernel/qaction.h b/qtbase/src/widgets/kernel/qaction.h
+index 258a1ea0a0..737c1e8285 100644
+--- a/qtbase/src/widgets/kernel/qaction.h
++++ b/qtbase/src/widgets/kernel/qaction.h
+@@ -81,7 +81,7 @@ class Q_WIDGETS_EXPORT QAction : public QObject
+     Q_PROPERTY(MenuRole menuRole READ menuRole WRITE setMenuRole NOTIFY changed)
+     Q_PROPERTY(bool iconVisibleInMenu READ isIconVisibleInMenu WRITE setIconVisibleInMenu NOTIFY changed)
+     Q_PROPERTY(bool shortcutVisibleInContextMenu READ isShortcutVisibleInContextMenu WRITE setShortcutVisibleInContextMenu NOTIFY changed)
+-    Q_PROPERTY(Priority priority READ priority WRITE setPriority)
++    Q_PROPERTY(Priority priority READ priority WRITE setPriority NOTIFY changed)
+ 
+ public:
+     // note this is copied into qplatformmenu.h, which must stay in sync
+diff --git a/qtbase/src/widgets/kernel/qwidget.cpp b/qtbase/src/widgets/kernel/qwidget.cpp
+index 9eba1e001e..26f6d27e18 100644
+--- a/qtbase/src/widgets/kernel/qwidget.cpp
++++ b/qtbase/src/widgets/kernel/qwidget.cpp
+@@ -5296,7 +5296,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
+         QWidgetEffectSourcePrivate *sourced = static_cast<QWidgetEffectSourcePrivate *>
+                                                          (source->d_func());
+         if (!sourced->context) {
+-            const QRegion effectRgn(rgn.boundingRect());
++            const QRegion effectRgn((flags & UseEffectRegionBounds) ? rgn.boundingRect() : rgn);
+             QWidgetPaintContext context(pdev, effectRgn, offset, flags, sharedPainter, repaintManager);
+             sourced->context = &context;
+             if (!sharedPainter) {
+@@ -5328,6 +5328,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
+         }
+     }
+ #endif // QT_CONFIG(graphicseffect)
++    flags = flags & ~UseEffectRegionBounds;
+ 
+     const bool alsoOnScreen = flags & DrawPaintOnScreen;
+     const bool recursive = flags & DrawRecursive;
+diff --git a/qtbase/src/widgets/kernel/qwidget_p.h b/qtbase/src/widgets/kernel/qwidget_p.h
+index eef6b8fa2c..c432f4b5d5 100644
+--- a/qtbase/src/widgets/kernel/qwidget_p.h
++++ b/qtbase/src/widgets/kernel/qwidget_p.h
+@@ -229,7 +229,8 @@ public:
+         DontSubtractOpaqueChildren = 0x10,
+         DontDrawOpaqueChildren = 0x20,
+         DontDrawNativeChildren = 0x40,
+-        DontSetCompositionMode = 0x80
++        DontSetCompositionMode = 0x80,
++        UseEffectRegionBounds = 0x100
+     };
+     Q_DECLARE_FLAGS(DrawWidgetFlags, DrawWidgetFlag)
+     Q_FLAG(DrawWidgetFlags)
+diff --git a/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp b/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
+index 02880b34da..0d44e1326d 100644
+--- a/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
++++ b/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
+@@ -1018,7 +1018,8 @@ void QWidgetRepaintManager::paintAndFlush()
+ 
+     // Paint the rest with composition.
+     if (repaintAllWidgets || !dirtyCopy.isEmpty()) {
+-        QWidgetPrivate::DrawWidgetFlags flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive;
++        QWidgetPrivate::DrawWidgetFlags flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive
++                | QWidgetPrivate::UseEffectRegionBounds;
+         tlw->d_func()->drawWidget(store->paintDevice(), dirtyCopy, QPoint(), flags, nullptr, this);
+     }
+ 
+diff --git a/qtbase/src/widgets/styles/qfusionstyle.cpp b/qtbase/src/widgets/styles/qfusionstyle.cpp
+index f4345d97c4..962912c838 100644
+--- a/qtbase/src/widgets/styles/qfusionstyle.cpp
++++ b/qtbase/src/widgets/styles/qfusionstyle.cpp
+@@ -1772,14 +1772,6 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio
+             proxy()->drawControl(CE_PushButtonLabel, &subopt, painter, widget);
+         }
+         break;
+-    case CE_PushButtonLabel:
+-        if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
+-            QStyleOptionButton b(*button);
+-            // no PM_ButtonShiftHorizontal and PM_ButtonShiftVertical for fusion style
+-            b.state &= ~(State_On | State_Sunken);
+-            QCommonStyle::drawControl(element, &b, painter, widget);
+-        }
+-        break;
+     case CE_MenuBarEmptyArea:
+         painter->save();
+     {
+diff --git a/qtbase/src/widgets/util/qcompleter.cpp b/qtbase/src/widgets/util/qcompleter.cpp
+index 18b24063d8..ef7207a8a3 100644
+--- a/qtbase/src/widgets/util/qcompleter.cpp
++++ b/qtbase/src/widgets/util/qcompleter.cpp
+@@ -1120,6 +1120,8 @@ void QCompleter::setModel(QAbstractItemModel *model)
+ {
+     Q_D(QCompleter);
+     QAbstractItemModel *oldModel = d->proxy->sourceModel();
++    if (oldModel == model)
++        return;
+ #if QT_CONFIG(filesystemmodel)
+     if (qobject_cast<const QFileSystemModel *>(oldModel))
+         setCompletionRole(Qt::EditRole); // QTBUG-54642, clear FileNameRole set by QFileSystemModel
+diff --git a/qtbase/src/widgets/widgets/qabstractbutton.cpp b/qtbase/src/widgets/widgets/qabstractbutton.cpp
+index a128b23950..dc40bf62fb 100644
+--- a/qtbase/src/widgets/widgets/qabstractbutton.cpp
++++ b/qtbase/src/widgets/widgets/qabstractbutton.cpp
+@@ -56,6 +56,7 @@
+ #ifndef QT_NO_ACCESSIBILITY
+ #include "qaccessible.h"
+ #endif
++#include <qpa/qplatformtheme.h>
+ 
+ #include <algorithm>
+ 
+@@ -1076,19 +1077,19 @@ void QAbstractButton::keyPressEvent(QKeyEvent *e)
+ {
+     Q_D(QAbstractButton);
+     bool next = true;
+-    switch (e->key()) {
+-    case Qt::Key_Enter:
+-    case Qt::Key_Return:
+-        e->ignore();
+-        break;
+-    case Qt::Key_Select:
+-    case Qt::Key_Space:
+-        if (!e->isAutoRepeat()) {
+-            setDown(true);
+-            repaint();
+-            d->emitPressed();
+-        }
+-        break;
++
++    const auto key = static_cast<Qt::Key>(e->key());
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(key) && !e->isAutoRepeat()) {
++        setDown(true);
++        repaint();
++        d->emitPressed();
++        return;
++    }
++
++    switch (key) {
+     case Qt::Key_Up:
+         next = false;
+         Q_FALLTHROUGH();
+@@ -1153,15 +1154,15 @@ void QAbstractButton::keyReleaseEvent(QKeyEvent *e)
+     if (!e->isAutoRepeat())
+         d->repeatTimer.stop();
+ 
+-    switch (e->key()) {
+-    case Qt::Key_Select:
+-    case Qt::Key_Space:
+-        if (!e->isAutoRepeat() && d->down)
+-            d->click();
+-        break;
+-    default:
+-        e->ignore();
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(static_cast<Qt::Key>(e->key())) && !e->isAutoRepeat() && d->down) {
++        d->click();
++        return;
+     }
++
++    e->ignore();
+ }
+ 
+ /*!\reimp
+diff --git a/qtbase/src/widgets/widgets/qcombobox.cpp b/qtbase/src/widgets/widgets/qcombobox.cpp
+index 7a496c27e0..0a3d96647b 100644
+--- a/qtbase/src/widgets/widgets/qcombobox.cpp
++++ b/qtbase/src/widgets/widgets/qcombobox.cpp
+@@ -3352,7 +3352,23 @@ void QComboBox::keyPressEvent(QKeyEvent *e)
+ 
+     Move move = NoMove;
+     int newIndex = currentIndex();
+-    switch (e->key()) {
++
++    bool pressLikeButton = !d->lineEdit;
++#ifdef QT_KEYPAD_NAVIGATION
++    pressLikeButton |= QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus();
++#endif
++    auto key = static_cast<Qt::Key>(e->key());
++    if (pressLikeButton) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(key)) {
++            showPopup();
++            return;
++        }
++    }
++
++    switch (key) {
+     case Qt::Key_Up:
+         if (e->modifiers() & Qt::ControlModifier)
+             break; // pass to line edit for auto completion
+@@ -3394,26 +3410,11 @@ void QComboBox::keyPressEvent(QKeyEvent *e)
+             return;
+         }
+         break;
+-    case Qt::Key_Space:
+-        if (!d->lineEdit) {
+-            showPopup();
+-            return;
+-        }
+-        break;
+-    case Qt::Key_Enter:
+-    case Qt::Key_Return:
+     case Qt::Key_Escape:
+         if (!d->lineEdit)
+             e->ignore();
+         break;
+ #ifdef QT_KEYPAD_NAVIGATION
+-    case Qt::Key_Select:
+-        if (QApplicationPrivate::keypadNavigationEnabled()
+-                && (!hasEditFocus() || !d->lineEdit)) {
+-            showPopup();
+-            return;
+-        }
+-        break;
+     case Qt::Key_Left:
+     case Qt::Key_Right:
+         if (QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus())
+diff --git a/qtbase/src/widgets/widgets/qdatetimeedit_p.h b/qtbase/src/widgets/widgets/qdatetimeedit_p.h
+index d36b6f8f9a..e0df5b5158 100644
+--- a/qtbase/src/widgets/widgets/qdatetimeedit_p.h
++++ b/qtbase/src/widgets/widgets/qdatetimeedit_p.h
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2018 The Qt Company Ltd.
++** Copyright (C) 2021 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtWidgets module of the Qt Toolkit.
+diff --git a/qtbase/src/widgets/widgets/qgroupbox.cpp b/qtbase/src/widgets/widgets/qgroupbox.cpp
+index 02a0bed325..3f3eccc370 100644
+--- a/qtbase/src/widgets/widgets/qgroupbox.cpp
++++ b/qtbase/src/widgets/widgets/qgroupbox.cpp
+@@ -54,6 +54,8 @@
+ #include "qaccessible.h"
+ #endif
+ #include <private/qwidget_p.h>
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
+ 
+ #include "qdebug.h"
+ 
+@@ -360,7 +362,10 @@ bool QGroupBox::event(QEvent *e)
+         return true;
+     case QEvent::KeyPress: {
+         QKeyEvent *k = static_cast<QKeyEvent*>(e);
+-        if (!k->isAutoRepeat() && (k->key() == Qt::Key_Select || k->key() == Qt::Key_Space)) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (!k->isAutoRepeat() && buttonPressKeys.contains(static_cast<Qt::Key>(k->key()))) {
+             d->pressedControl = QStyle::SC_GroupBoxCheckBox;
+             update(style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxCheckBox, this));
+             return true;
+@@ -369,7 +374,10 @@ bool QGroupBox::event(QEvent *e)
+     }
+     case QEvent::KeyRelease: {
+         QKeyEvent *k = static_cast<QKeyEvent*>(e);
+-        if (!k->isAutoRepeat() && (k->key() == Qt::Key_Select || k->key() == Qt::Key_Space)) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (!k->isAutoRepeat() && buttonPressKeys.contains(static_cast<Qt::Key>(k->key()))) {
+             bool toggle = (d->pressedControl == QStyle::SC_GroupBoxLabel
+                            || d->pressedControl == QStyle::SC_GroupBoxCheckBox);
+             d->pressedControl = QStyle::SC_None;
+diff --git a/qtbase/src/widgets/widgets/qlabel.cpp b/qtbase/src/widgets/widgets/qlabel.cpp
+index 30ff80cbb0..cf2605c17c 100644
+--- a/qtbase/src/widgets/widgets/qlabel.cpp
++++ b/qtbase/src/widgets/widgets/qlabel.cpp
+@@ -421,9 +421,6 @@ void QLabel::setPixmap(const QPixmap &pixmap)
+         d->pixmap = new QPixmap(pixmap);
+     }
+ 
+-    if (d->pixmap->depth() == 1 && !d->pixmap->mask())
+-        d->pixmap->setMask(*((QBitmap *)d->pixmap));
+-
+     d->updateLabel();
+ }
+ 
+diff --git a/qtbase/src/widgets/widgets/qtoolbararealayout.cpp b/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
+index 493c094cc1..d5f4b59017 100644
+--- a/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
++++ b/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
+@@ -1367,7 +1367,7 @@ bool QToolBarAreaLayout::restoreState(QDataStream &stream, const QList<QToolBar*
+                 item.widgetItem = new QWidgetItemV2(toolBar);
+                 toolBar->setOrientation(floating ? ((shown & 2) ? Qt::Vertical : Qt::Horizontal) : dock.o);
+                 toolBar->setVisible(shown & 1);
+-                toolBar->d_func()->setWindowState(floating, true, rect);
++                toolBar->d_func()->setWindowState(floating, false, rect);
+ 
+                 item.preferredSize = item.size;
+                 line.toolBarItems.append(item);
+diff --git a/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp b/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
+index 212c0a2e13..3c77b1ba0b 100644
+--- a/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
++++ b/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
+@@ -126,8 +126,7 @@ public:
+ 
+ void tst_QtConcurrentIterateKernel::instantiate()
+ {
+-    auto future = startThreadEngine(new PrintFor(0, 40)).startAsynchronously();
+-    future.waitForFinished();
++    startThreadEngine(new PrintFor(0, 40)).startBlocking();
+     QCOMPARE(iterations.loadRelaxed(), 40);
+ }
+ 
+@@ -166,10 +165,8 @@ void tst_QtConcurrentIterateKernel::stresstest()
+     const int times = 50;
+     for (int i = 0; i < times; ++i) {
+         counter.storeRelaxed(0);
+-        // ThreadEngine will delete f when it finishes
+-        auto f = new CountFor(0, iterations);
+-        auto future = f->startAsynchronously();
+-        future.waitForFinished();
++        CountFor f(0, iterations);
++        f.startBlocking();
+         QCOMPARE(counter.loadRelaxed(), iterations);
+     }
+ }
+@@ -177,11 +174,8 @@ void tst_QtConcurrentIterateKernel::stresstest()
+ void tst_QtConcurrentIterateKernel::noIterations()
+ {
+     const int times = 20000;
+-    for (int i = 0; i < times; ++i) {
+-        auto future = startThreadEngine(new IterateKernel<TestIterator, void>(0, 0))
+-                              .startAsynchronously();
+-        future.waitForFinished();
+-    }
++    for (int i = 0; i < times; ++i)
++        startThreadEngine(new IterateKernel<TestIterator, void>(0, 0)).startBlocking();
+ }
+ 
+ QMutex threadsMutex;
+@@ -236,10 +230,8 @@ void tst_QtConcurrentIterateKernel::throttling()
+ 
+     threads.clear();
+ 
+-    // ThreadEngine will delete f when it finishes
+-    auto f = new ThrottleFor(0, totalIterations);
+-    auto future = f->startAsynchronously();
+-    future.waitForFinished();
++    ThrottleFor f(0, totalIterations);
++    f.startBlocking();
+ 
+     QCOMPARE(iterations.loadRelaxed(), totalIterations);
+ 
+diff --git a/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp b/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
+index ac7be7acdd..81bc64c8d9 100644
+--- a/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
++++ b/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
+@@ -65,9 +65,16 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::runDirectly()
+ {
+-    PrintUser *engine = new PrintUser();
+-    QFuture<void> f = engine->startAsynchronously();
+-    f.waitForFinished();
++    {
++        PrintUser engine;
++        engine.startSingleThreaded();
++        engine.startBlocking();
++    }
++    {
++        PrintUser *engine = new PrintUser();
++        QFuture<void> f = engine->startAsynchronously();
++        f.waitForFinished();
++    }
+ }
+ 
+ class StringResultUser : public ThreadEngine<QString>
+@@ -99,10 +106,8 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::result()
+ {
+-    // ThreadEngine will delete 'engine' when it finishes
+-    auto engine = new StringResultUser();
+-    auto future = engine->startAsynchronously();
+-    QCOMPARE(future.result(), QString("Foo"));
++    StringResultUser engine;
++    QCOMPARE(*engine.startBlocking(), QString("Foo"));
+ }
+ 
+ class VoidResultUser : public ThreadEngine<void>
+@@ -128,9 +133,17 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::runThroughStarter()
+ {
+-    ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
+-    QFuture<QString> f = starter.startAsynchronously();
+-    QCOMPARE(f.result(), QString("Foo"));
++    {
++        ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
++        QFuture<QString>  f = starter.startAsynchronously();
++        QCOMPARE(f.result(), QString("Foo"));
++    }
++
++    {
++        ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
++        QString str = starter.startBlocking();
++        QCOMPARE(str, QString("Foo"));
++    }
+ }
+ 
+ class CancelUser : public ThreadEngine<void>
+@@ -213,6 +226,12 @@ void tst_QtConcurrentThreadEngine::throttle()
+         f.waitForFinished();
+         QCOMPARE(count.loadRelaxed(), 0);
+     }
++
++    for (int i = 0; i < repeats; ++i) {
++        ThrottleAlwaysUser t;
++        t.startBlocking();
++        QCOMPARE(count.loadRelaxed(), 0);
++    }
+ }
+ 
+ QSet<QThread *> threads;
+@@ -249,17 +268,35 @@ void tst_QtConcurrentThreadEngine::threadCount()
+ {
+     const int repeats = 10;
+     for (int i = 0; i < repeats; ++i) {
++        ThreadCountUser t;
++        t.startBlocking();
++        int count = threads.count();
++        int count_expected = QThreadPool::globalInstance()->maxThreadCount() + 1; // +1 for the main thread.
++        if (count != count_expected)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, count_expected);
++
+         (new ThreadCountUser())->startAsynchronously().waitForFinished();
+-        const auto count = threads.count();
+-        const auto maxThreadCount = QThreadPool::globalInstance()->maxThreadCount();
+-        QVERIFY(count <= maxThreadCount);
+-        QVERIFY(!threads.contains(QThread::currentThread()));
++        count = threads.count();
++        count_expected = QThreadPool::globalInstance()->maxThreadCount();
++        if (count != count_expected)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, count_expected);
+     }
+ 
+     // Set the finish flag immediately, this should give us one thread only.
+     for (int i = 0; i < repeats; ++i) {
++        ThreadCountUser t(true /*finishImmediately*/);
++        t.startBlocking();
++        int count = threads.count();
++        if (count != 1)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, 1);
++
+         (new ThreadCountUser(true /*finishImmediately*/))->startAsynchronously().waitForFinished();
+-        const auto count = threads.count();
++        count = threads.count();
++        if (count != 1)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
+         QCOMPARE(count, 1);
+         QVERIFY(!threads.contains(QThread::currentThread()));
+     }
+@@ -400,6 +437,7 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::exceptions()
+ {
++    // Asynchronous mode:
+     {
+         bool caught = false;
+         try  {
+@@ -412,6 +450,32 @@ void tst_QtConcurrentThreadEngine::exceptions()
+         QVERIFY2(caught, "did not get exception");
+     }
+ 
++    // Blocking mode:
++    // test throwing the exception from a worker thread.
++    {
++        bool caught = false;
++        try  {
++            QtConcurrentExceptionThrower e(QThread::currentThread());
++            e.startBlocking();
++        } catch (const QException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // test throwing the exception from the main thread (different code path)
++    {
++        bool caught = false;
++        try  {
++            QtConcurrentExceptionThrower e(0);
++            e.startBlocking();
++        } catch (const QException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // Asynchronous mode:
+     {
+         bool caught = false;
+         try  {
+@@ -423,6 +487,31 @@ void tst_QtConcurrentThreadEngine::exceptions()
+         }
+         QVERIFY2(caught, "did not get exception");
+     }
++
++    // Blocking mode:
++    // test throwing the exception from a worker thread.
++    {
++        bool caught = false;
++        try  {
++            UnrelatedExceptionThrower e(QThread::currentThread());
++            e.startBlocking();
++        } catch (const QUnhandledException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // test throwing the exception from the main thread (different code path)
++    {
++        bool caught = false;
++        try  {
++            UnrelatedExceptionThrower e(0);
++            e.startBlocking();
++        } catch (const QUnhandledException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
+ }
+ 
+ #endif
+diff --git a/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp b/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
+index 4968742110..f4c3fb711d 100644
+--- a/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
++++ b/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
+@@ -42,6 +42,7 @@ private slots:
+     void writeBlock_data();
+     void writeBlock();
+     void seek();
++    void invalidSeeks();
+     void seekTest_data();
+     void seekTest();
+     void read_rawdata();
+@@ -286,6 +287,29 @@ void tst_QBuffer::seek()
+     QCOMPARE(buffer.size(), pos);
+ }
+ 
++void tst_QBuffer::invalidSeeks()
++{
++    if constexpr (sizeof(qsizetype) == sizeof(qint64)) {
++        // sizeof(qsizetype) == sizeof(qint64), so +1 would overflow
++        QSKIP("This is a 32-bit-only test.");
++    } else {
++        QBuffer buffer;
++        buffer.open(QIODevice::WriteOnly);
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++        constexpr qint64 MaxQByteArrayCapacity = (std::numeric_limits<qsizetype>::max)();
++        // this should fail fast, not after trying to allocate nearly 2 GiB of data,
++        // potentially crashing in the process:
++        QVERIFY(!buffer.seek(2 * MaxQByteArrayCapacity - 1));
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++        // ditto:
++        QVERIFY(!buffer.seek(MaxQByteArrayCapacity + 1));
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++    }
++}
++
+ void tst_QBuffer::seekTest_data()
+ {
+     writeBlock_data();
+diff --git a/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp b/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
+index da5327594c..4a04e0f7c6 100644
+--- a/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
++++ b/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
+@@ -561,7 +561,8 @@ protected:
+     qint64 readData(char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf->size() - offset));
+-        memcpy(data, buf->constData() + offset, maxSize);
++        if (maxSize > 0)
++            memcpy(data, buf->constData() + offset, maxSize);
+         offset += maxSize;
+         return maxSize;
+     }
+@@ -604,13 +605,15 @@ protected:
+     qint64 readData(char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf.size() - pos()));
+-        memcpy(data, buf.constData() + pos(), maxSize);
++        if (maxSize > 0)
++            memcpy(data, buf.constData() + pos(), maxSize);
+         return maxSize;
+     }
+     qint64 writeData(const char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf.size() - pos()));
+-        memcpy(buf.data() + pos(), data, maxSize);
++        if (maxSize > 0)
++            memcpy(buf.data() + pos(), data, maxSize);
+         return maxSize;
+     }
+ 
+diff --git a/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+index db60bead64..f345a44414 100644
+--- a/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
++++ b/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+@@ -1,7 +1,8 @@
+ /****************************************************************************
+ **
+ ** Copyright (C) 2021 The Qt Company Ltd.
+-** Copyright (C) 2020 Intel Corporation.
++** Copyright (C) 2020 The Qt Company Ltd.
++** Copyright (C) 2022 Intel Corporation.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the test suite of the Qt Toolkit.
+@@ -150,6 +151,8 @@ private slots:
+     void startStopStartStopBuffers();
+     void processEventsInAReadyReadSlot_data();
+     void processEventsInAReadyReadSlot();
++    void startFromCurrentWorkingDir_data();
++    void startFromCurrentWorkingDir();
+ 
+     // keep these at the end, since they use lots of processes and sometimes
+     // caused obscure failures to occur in tests that followed them (esp. on the Mac)
+@@ -2731,5 +2734,94 @@ void tst_QProcess::finishProcessBeforeReadingDone_deprecated()
+ 
+ #endif
+ 
++enum class ChdirMode {
++    None = 0,
++    InParent,
++    InChild
++};
++Q_DECLARE_METATYPE(ChdirMode)
++
++void tst_QProcess::startFromCurrentWorkingDir_data()
++{
++    qRegisterMetaType<ChdirMode>();
++    QTest::addColumn<QString>("programPrefix");
++    QTest::addColumn<ChdirMode>("chdirMode");
++    QTest::addColumn<bool>("success");
++
++    constexpr bool IsWindows = true
++#ifdef Q_OS_UNIX
++            && false
++#endif
++            ;
++
++    // baseline: trying to execute the directory, this can't possibly succeed!
++    QTest::newRow("plain-same-cwd") << QString() << ChdirMode::None << false;
++
++    // cross-platform behavior: neither OS searches the setWorkingDirectory()
++    // dir without "./"
++    QTest::newRow("plain-child-chdir") << QString() << ChdirMode::InChild << false;
++
++    // cross-platform behavior: both OSes search the parent's CWD with "./"
++    QTest::newRow("prefixed-parent-chdir") << "./" << ChdirMode::InParent << true;
++
++    // opposite behaviors: Windows searches the parent's CWD and Unix searches
++    // the child's with "./"
++    QTest::newRow("prefixed-child-chdir") << "./" << ChdirMode::InChild << !IsWindows;
++
++    // Windows searches the parent's CWD without "./"
++    QTest::newRow("plain-parent-chdir") << QString() << ChdirMode::InParent << IsWindows;
++}
++
++void tst_QProcess::startFromCurrentWorkingDir()
++{
++    QFETCH(QString, programPrefix);
++    QFETCH(ChdirMode, chdirMode);
++    QFETCH(bool, success);
++
++    QProcess process;
++    qRegisterMetaType<QProcess::ProcessError>();
++    QSignalSpy errorSpy(&process, &QProcess::errorOccurred);
++    QVERIFY(errorSpy.isValid());
++
++    // both the dir name and the executable name
++    const QString target = QStringLiteral("testProcessNormal");
++    process.setProgram(programPrefix + target);
++
++#ifdef Q_OS_UNIX
++    // Reset PATH, to be sure it doesn't contain . or the empty path.
++    // We can't do this on Windows because DLLs are searched in PATH
++    // and Windows always searches "." anyway.
++    auto restoreEnv = qScopeGuard([old = qgetenv("PATH")] {
++        qputenv("PATH", old);
++    });
++    qputenv("PATH", "/");
++#endif
++
++    switch (chdirMode) {
++    case ChdirMode::InParent: {
++        auto restoreCwd = qScopeGuard([old = QDir::currentPath()] {
++            QDir::setCurrent(old);
++        });
++        QVERIFY(QDir::setCurrent(target));
++        process.start();
++        break;
++    }
++    case ChdirMode::InChild:
++        process.setWorkingDirectory(target);
++        Q_FALLTHROUGH();
++    case ChdirMode::None:
++        process.start();
++        break;
++    }
++
++    QCOMPARE(process.waitForStarted(), success);
++    QCOMPARE(errorSpy.count(), int(!success));
++    if (success) {
++        QVERIFY(process.waitForFinished());
++    } else {
++        QCOMPARE(process.error(), QProcess::FailedToStart);
++    }
++}
++
+ QTEST_MAIN(tst_QProcess)
+ #include "tst_qprocess.moc"
+diff --git a/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp b/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp
+index e1ea7a4552..90972caa57 100644
+--- a/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp
++++ b/qtbase/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"
+diff --git a/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+index 9bd66c0835..ed4a0bae5d 100644
+--- a/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
++++ b/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+@@ -158,6 +158,7 @@ private slots:
+     void nullReceiver();
+     void functorReferencesConnection();
+     void disconnectDisconnects();
++    void declarativeData();
+ };
+ 
+ struct QObjectCreatedOnShutdown
+@@ -7679,5 +7680,81 @@ void tst_QObject::disconnectDisconnects()
+ Q_STATIC_ASSERT(QtPrivate::HasQ_OBJECT_Macro<tst_QObject>::Value);
+ Q_STATIC_ASSERT(!QtPrivate::HasQ_OBJECT_Macro<SiblingDeleter>::Value);
+ 
++#ifdef QT_BUILD_INTERNAL
++/*
++    Since QObjectPrivate stores the declarativeData pointer in a union with the pointer
++    to the currently destroyed child, calls to the QtDeclarative handlers need to be
++    correctly guarded. QTBUG-105286
++*/
++namespace QtDeclarative {
++static QAbstractDeclarativeData *theData;
++
++static void destroyed(QAbstractDeclarativeData *data, QObject *)
++{
++    QCOMPARE(data, theData);
++}
++static void signalEmitted(QAbstractDeclarativeData *data, QObject *, int, void **)
++{
++    QCOMPARE(data, theData);
++}
++// we can't use QCOMPARE in the next two functions, as they don't return void
++static int receivers(QAbstractDeclarativeData *data, const QObject *, int)
++{
++    QTest::qCompare(data, theData, "data", "theData", __FILE__, __LINE__);
++    return 0;
++}
++static bool isSignalConnected(QAbstractDeclarativeData *data, const QObject *, int)
++{
++    QTest::qCompare(data, theData, "data", "theData", __FILE__, __LINE__);
++    return true;
++}
++
++class Object : public QObject
++{
++    Q_OBJECT
++public:
++    using QObject::QObject;
++    ~Object()
++    {
++        if (Object *p = static_cast<Object *>(parent()))
++            p->emitSignal();
++    }
++
++    void emitSignal()
++    {
++        emit theSignal();
++    }
++
++signals:
++    void theSignal();
++};
++
++}
++#endif
++
++void tst_QObject::declarativeData()
++{
++#ifdef QT_BUILD_INTERNAL
++    QScopedValueRollback destroyed(QAbstractDeclarativeData::destroyed,
++                                   QtDeclarative::destroyed);
++    QScopedValueRollback signalEmitted(QAbstractDeclarativeData::signalEmitted,
++                                       QtDeclarative::signalEmitted);
++    QScopedValueRollback receivers(QAbstractDeclarativeData::receivers,
++                                   QtDeclarative::receivers);
++    QScopedValueRollback isSignalConnected(QAbstractDeclarativeData::isSignalConnected,
++                                           QtDeclarative::isSignalConnected);
++
++    QtDeclarative::Object p;
++    QObjectPrivate *priv = QObjectPrivate::get(&p);
++    priv->declarativeData = QtDeclarative::theData = new QAbstractDeclarativeData;
++
++    connect(&p, &QtDeclarative::Object::theSignal, &p, []{
++    });
++
++    QtDeclarative::Object *child = new QtDeclarative::Object;
++    child->setParent(&p);
++#endif
++}
++
+ QTEST_MAIN(tst_QObject)
+ #include "tst_qobject.moc"
+diff --git a/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp b/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
+index 0ea422ecbc..1a3256534b 100644
+--- a/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
++++ b/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
+@@ -70,15 +70,15 @@ static inline QString testSuiteWarning()
+ 
+     QString result;
+     QTextStream str(&result);
+-    str << "\nCannot find the shared-mime-info test suite\nstarting from: "
++    str << "\nCannot find the shared-mime-info test suite\nin the parent of: "
+         << QDir::toNativeSeparators(QDir::currentPath()) << "\n"
+            "cd " << QDir::toNativeSeparators(QStringLiteral("tests/auto/corelib/mimetypes/qmimedatabase")) << "\n"
+-           "wget http://cgit.freedesktop.org/xdg/shared-mime-info/snapshot/Release-1-10.zip\n"
+-           "unzip Release-1-10.zip\n";
++           "wget https://gitlab.freedesktop.org/xdg/shared-mime-info/-/archive/2.1/shared-mime-info-2.1.zip\n"
++           "unzip shared-mime-info-2.1.zip\n";
+ #ifdef Q_OS_WIN
+-    str << "mkdir testfiles\nxcopy /s Release-1-10 s-m-i\n";
++    str << "mkdir testfiles\nxcopy /s shared-mime-info-2.1 s-m-i\n";
+ #else
+-    str << "ln -s Release-1-10 s-m-i\n";
++    str << "ln -s shared-mime-info-2.1 s-m-i\n";
+ #endif
+     return result;
+ }
+@@ -154,7 +154,7 @@ void tst_QMimeDatabase::initTestCase()
+     QVERIFY2(copyResourceFile(xmlFileName, xmlTargetFileName, &errorMessage), qPrintable(errorMessage));
+ #endif
+ 
+-    m_testSuite = QFINDTESTDATA("s-m-i/tests");
++    m_testSuite = QFINDTESTDATA("s-m-i/tests/mime-detection");
+     if (m_testSuite.isEmpty())
+         qWarning("%s", qPrintable(testSuiteWarning()));
+ 
+@@ -611,7 +611,7 @@ void tst_QMimeDatabase::allMimeTypes()
+     QVERIFY(!lst.isEmpty());
+ 
+     // Hardcoding this is the only way to check both providers find the same number of mimetypes.
+-    QCOMPARE(lst.count(), 779);
++    QCOMPARE(lst.count(), 811);
+ 
+     foreach (const QMimeType &mime, lst) {
+         const QString name = mime.name();
+@@ -631,10 +631,9 @@ void tst_QMimeDatabase::suffixes_data()
+ 
+     QTest::newRow("mimetype with a single pattern") << "application/pdf" << "*.pdf" << "pdf";
+     QTest::newRow("mimetype with multiple patterns") << "application/x-kpresenter" << "*.kpr;*.kpt" << "kpr";
+-    QTest::newRow("jpeg") << "image/jpeg" << "*.jpe;*.jpg;*.jpeg" << "jpeg";
+-    //if (KMimeType::sharedMimeInfoVersion() > KDE_MAKE_VERSION(0, 60, 0)) {
+-        QTest::newRow("mimetype with many patterns") << "application/vnd.wordperfect" << "*.wp;*.wp4;*.wp5;*.wp6;*.wpd;*.wpp" << "wp";
+-    //}
++    // The preferred suffix for image/jpeg is *.jpg, as per https://bugs.kde.org/show_bug.cgi?id=176737
++    QTest::newRow("jpeg") << "image/jpeg" << "*.jpe;*.jpg;*.jpeg" << "jpg";
++    QTest::newRow("mimetype with many patterns") << "application/vnd.wordperfect" << "*.wp;*.wp4;*.wp5;*.wp6;*.wpd;*.wpp" << "wp";
+     QTest::newRow("oasis text mimetype") << "application/vnd.oasis.opendocument.text" << "*.odt" << "odt";
+     QTest::newRow("oasis presentation mimetype") << "application/vnd.oasis.opendocument.presentation" << "*.odp" << "odp";
+     QTest::newRow("mimetype with multiple patterns") << "text/plain" << "*.asc;*.txt;*,v" << "txt";
+diff --git a/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp b/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
+index 3e58dd03cc..c8f82ef5d5 100644
+--- a/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
++++ b/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
+@@ -176,6 +176,8 @@ private Q_SLOTS:
+     void fromToVariantConversions_data();
+     void fromToVariantConversions();
+ 
++    void noLeakOnNameClash();
++
+ private:
+     QString testDataDir;
+ };
+@@ -3685,5 +3687,23 @@ void tst_QtJson::fromToVariantConversions()
+     }
+ }
+ 
++void tst_QtJson::noLeakOnNameClash()
++{
++    QJsonDocument doc = QJsonDocument::fromJson("{\"\":{\"\":0},\"\":0}");
++    QVERIFY(!doc.isNull());
++    const QJsonObject obj = doc.object();
++
++    // Removed the duplicate key.
++    QCOMPARE(obj.length(), 1);
++
++    // Retained the last of the duplicates.
++    const QJsonValue val = obj.begin().value();
++    QVERIFY(val.isDouble());
++    QCOMPARE(val.toDouble(), 0.0);
++
++    // It should not leak.
++    // In particular it should not forget to deref the container for the inner object.
++}
++
+ QTEST_MAIN(tst_QtJson)
+ #include "tst_qtjson.moc"
+diff --git a/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp b/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
+index a59b58d57f..241c3e84ac 100644
+--- a/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
++++ b/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
+@@ -63,6 +63,7 @@ private slots:
+     void isValidId_data();
+     void isValidId();
+     void malformed();
++    void serialize();
+     // Backend tests
+     void utcTest();
+     void icuTest();
+@@ -947,6 +948,33 @@ void tst_QTimeZone::malformed()
+         barf.offsetFromUtc(now);
+ }
+ 
++void tst_QTimeZone::serialize()
++{
++    int parts = 0;
++#ifndef QT_NO_DEBUG_STREAM
++    qDebug() << QTimeZone(); // to verify no crash
++    parts++;
++#endif
++#ifndef QT_NO_DATASTREAM
++    QByteArray blob;
++    {
++        QDataStream stream(&blob, QIODevice::WriteOnly);
++        stream << QTimeZone("Europe/Oslo") << QTimeZone(420) << QTimeZone() << qint64(-1);
++    }
++    QDataStream stream(&blob, QIODevice::ReadOnly);
++    QTimeZone invalid, offset, oslo;
++    qint64 minusone;
++    stream >> oslo >> offset >> invalid >> minusone;
++    QCOMPARE(oslo, QTimeZone("Europe/Oslo"));
++    QCOMPARE(offset, QTimeZone(420));
++    QVERIFY(!invalid.isValid());
++    QCOMPARE(minusone, qint64(-1));
++    parts++;
++#endif
++    if (!parts)
++        QSKIP("No serialization enabled");
++}
++
+ void tst_QTimeZone::utcTest()
+ {
+ #ifdef QT_BUILD_INTERNAL
+diff --git a/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp b/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
+index 05480c6dd2..70f4c75756 100644
+--- a/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
++++ b/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
+@@ -324,6 +324,13 @@ void tst_QDBusInterface::notValid()
+ 
+     QVERIFY(!interface.isValid());
+     QVERIFY(!QMetaObject::invokeMethod(&interface, "ListNames", Qt::DirectConnection));
++
++    // With a connection, but empty/null service and path specified
++    QDBusConnection con = QDBusConnection::sessionBus();
++    QVERIFY(con.isConnected());
++    QDBusInterface iface({}, {}, {}, con);
++    QVERIFY(!iface.isValid());
++    QVERIFY(!QMetaObject::invokeMethod(&interface, "ListNames", Qt::DirectConnection));
+ }
+ 
+ void tst_QDBusInterface::notValidDerived()
+diff --git a/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp b/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
+index 874468c954..04ceb4ab65 100644
+--- a/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
++++ b/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
+@@ -507,6 +507,10 @@ void tst_QKeySequence::toStringFromKeycode_data()
+     QTest::newRow("Ctrl+Alt+Num+Del") << QKeySequence(Qt::ControlModifier | Qt::AltModifier | Qt::KeypadModifier | Qt::Key_Delete) << "Ctrl+Alt+Num+Del";
+     QTest::newRow("Ctrl+Ins") << QKeySequence(Qt::ControlModifier | Qt::Key_Insert) << "Ctrl+Ins";
+     QTest::newRow("Ctrl+Num+Ins(1)") << QKeySequence(Qt::Key_Insert | Qt::KeypadModifier | Qt::ControlModifier) << "Ctrl+Num+Ins";
++    QTest::newRow("Ctrl") << QKeySequence(Qt::Key_Control) << "Control";
++    QTest::newRow("Alt") << QKeySequence(Qt::Key_Alt) << "Alt";
++    QTest::newRow("Shift") << QKeySequence(Qt::Key_Shift) << "Shift";
++    QTest::newRow("Meta") << QKeySequence(Qt::Key_Meta) << "Meta";
+ }
+ 
+ void tst_QKeySequence::toStringFromKeycode()
+diff --git a/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp b/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+index 15e0ecadaa..b4eca74283 100644
+--- a/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
++++ b/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+@@ -81,6 +81,8 @@ private slots:
+     void registerOpenTypePreferredNamesSystem();
+     void registerOpenTypePreferredNamesApplication();
+ 
++    void stretchRespected();
++
+ private:
+     QString m_ledFont;
+     QString m_testFont;
+@@ -355,6 +357,28 @@ static QString testString()
+     return QStringLiteral("foo bar");
+ }
+ 
++void tst_QFontDatabase::stretchRespected()
++{
++    int italicId = QFontDatabase::addApplicationFont(m_testFontItalic);
++    QVERIFY(italicId != -1);
++
++    QVERIFY(!QFontDatabase::applicationFontFamilies(italicId).isEmpty());
++
++    QString italicFontName = QFontDatabase::applicationFontFamilies(italicId).first();
++
++    QFont italicFont = QFontDatabase().font(italicFontName,
++                                            QString::fromLatin1("Italic"), 14);
++    QVERIFY(italicFont.italic());
++
++    QFont italicStretchedFont = italicFont;
++    italicStretchedFont.setStretch( 400 );
++
++    QVERIFY(QFontMetricsF(italicFont).horizontalAdvance(QStringLiteral("foobar")) <
++            QFontMetricsF(italicStretchedFont).horizontalAdvance(QStringLiteral("foobar")));
++
++    QFontDatabase::removeApplicationFont(italicId);
++}
++
+ void tst_QFontDatabase::condensedFontWidthNoFontMerging()
+ {
+     int regularFontId = QFontDatabase::addApplicationFont(m_testFont);
+diff --git a/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+index 3d4a094c43..b423e11a99 100644
+--- a/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
++++ b/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+@@ -281,6 +281,7 @@ private Q_SLOTS:
+     void ioGetFromFileSpecial();
+     void ioGetFromFile_data();
+     void ioGetFromFile();
++    void ioGetFromFileUrl();
+     void ioGetFromFtp_data();
+     void ioGetFromFtp();
+     void ioGetFromFtpWithReuse();
+@@ -3300,6 +3301,18 @@ void tst_QNetworkReply::ioGetFromFile()
+     QCOMPARE(reader.data, data);
+ }
+ 
++void tst_QNetworkReply::ioGetFromFileUrl()
++{
++    // This immediately fails on non-windows platforms:
++    QNetworkRequest request(QUrl("file://unc-server/some/path"));
++    QNetworkReplyPtr reply(manager.get(request));
++    QSignalSpy finishedSpy(reply.get(), &QNetworkReply::finished);
++    // QTBUG-105618: This would, on non-Windows platforms, never happen because the signal
++    // was emitted before the constructor finished, leaving no chance at all to connect to the
++    // signal
++    QVERIFY(finishedSpy.wait());
++}
++
+ void tst_QNetworkReply::ioGetFromFtp_data()
+ {
+     QTest::addColumn<QString>("fileName");
+diff --git a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
+index 069fa6b341..4cc4d9a5ea 100644
+--- a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
++++ b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
+@@ -1,75 +1,34 @@
+-Certificate:
+-    Data:
+-        Version: 3 (0x2)
+-        Serial Number: 0 (0x0)
+-        Signature Algorithm: sha1WithRSAEncryption
+-        Issuer: C=NO, ST=Oslo, L=Nydalen, O=Nokia Corporation and/or its subsidiary(-ies), OU=Development, CN=fluke.troll.no/emailAddress=ahanssen@trolltech.com
+-        Validity
+-            Not Before: Dec  4 01:10:32 2007 GMT
+-            Not After : Apr 21 01:10:32 2035 GMT
+-        Subject: C=NO, ST=Oslo, O=Nokia Corporation and/or its subsidiary(-ies), OU=Development, CN=fluke.troll.no
+-        Subject Public Key Info:
+-            Public Key Algorithm: rsaEncryption
+-            RSA Public Key: (1024 bit)
+-                Modulus (1024 bit):
+-                    00:a7:c8:a0:4a:c4:19:05:1b:66:ba:32:e2:d2:f1:
+-                    1c:6f:17:82:e4:39:2e:01:51:90:db:04:34:32:11:
+-                    21:c2:0d:6f:59:d8:53:90:54:3f:83:8f:a9:d3:b3:
+-                    d5:ee:1a:9b:80:ae:c3:25:c9:5e:a5:af:4b:60:05:
+-                    aa:a0:d1:91:01:1f:ca:04:83:e3:58:1c:99:32:45:
+-                    84:70:72:58:03:98:4a:63:8b:41:f5:08:49:d2:91:
+-                    02:60:6b:e4:64:fe:dd:a0:aa:74:08:e9:34:4c:91:
+-                    5f:12:3d:37:4d:54:2c:ad:7f:5b:98:60:36:02:8c:
+-                    3b:f6:45:f3:27:6a:9b:94:9d
+-                Exponent: 65537 (0x10001)
+-        X509v3 extensions:
+-            X509v3 Basic Constraints: 
+-                CA:FALSE
+-            Netscape Comment: 
+-                OpenSSL Generated Certificate
+-            X509v3 Subject Key Identifier: 
+-                21:85:04:3D:23:01:66:E5:F7:9F:1A:84:24:8A:AF:0A:79:F4:E5:AC
+-            X509v3 Authority Key Identifier: 
+-                DirName:/C=NO/ST=Oslo/L=Nydalen/O=Nokia Corporation and/or its subsidiary(-ies)/OU=Development/CN=fluke.troll.no/emailAddress=ahanssen@trolltech.com
+-                serial:8E:A8:B4:E8:91:B7:54:2E
+-
+-    Signature Algorithm: sha1WithRSAEncryption
+-        6d:57:5f:d1:05:43:f0:62:05:ec:2a:71:a5:dc:19:08:f2:c4:
+-        a6:bd:bb:25:d9:ca:89:01:0e:e4:cf:1f:c1:8c:c8:24:18:35:
+-        53:59:7b:c0:43:b4:32:e6:98:b2:a6:ef:15:05:0b:48:5f:e1:
+-        a0:0c:97:a9:a1:77:d8:35:18:30:bc:a9:8f:d3:b7:54:c7:f1:
+-        a9:9e:5d:e6:19:bf:f6:3c:5b:2b:d8:e4:3e:62:18:88:8b:d3:
+-        24:e1:40:9b:0c:e6:29:16:62:ab:ea:05:24:70:36:aa:55:93:
+-        ef:02:81:1b:23:10:a2:04:eb:56:95:75:fc:f8:94:b1:5d:42:
+-        c5:3f:36:44:85:5d:3a:2e:90:46:8a:a2:b9:6f:87:ae:0c:15:
+-        40:19:31:90:fc:3b:25:bb:ae:f1:66:13:0d:85:90:d9:49:34:
+-        8f:f2:5d:f9:7a:db:4d:5d:27:f6:76:9d:35:8c:06:a6:4c:a3:
+-        b1:b2:b6:6f:1d:d7:a3:00:fd:72:eb:9e:ea:44:a1:af:21:34:
+-        7d:c7:42:e2:49:91:19:8b:c0:ad:ba:82:80:a8:71:70:f4:35:
+-        31:91:63:84:20:95:e9:60:af:64:8b:cc:ff:3d:8a:76:74:3d:
+-        c8:55:6d:e4:8e:c3:2b:1c:e8:42:18:ae:9f:e6:6b:9c:34:06:
+-        ec:6a:f2:c3
+ -----BEGIN CERTIFICATE-----
+-MIIEEzCCAvugAwIBAgIBADANBgkqhkiG9w0BAQUFADCBnDELMAkGA1UEBhMCTk8x
+-DTALBgNVBAgTBE9zbG8xEDAOBgNVBAcTB055ZGFsZW4xFjAUBgNVBAoTDVRyb2xs
+-dGVjaCBBU0ExFDASBgNVBAsTC0RldmVsb3BtZW50MRcwFQYDVQQDEw5mbHVrZS50
+-cm9sbC5ubzElMCMGCSqGSIb3DQEJARYWYWhhbnNzZW5AdHJvbGx0ZWNoLmNvbTAe
+-Fw0wNzEyMDQwMTEwMzJaFw0zNTA0MjEwMTEwMzJaMGMxCzAJBgNVBAYTAk5PMQ0w
+-CwYDVQQIEwRPc2xvMRYwFAYDVQQKEw1Ucm9sbHRlY2ggQVNBMRQwEgYDVQQLEwtE
+-ZXZlbG9wbWVudDEXMBUGA1UEAxMOZmx1a2UudHJvbGwubm8wgZ8wDQYJKoZIhvcN
+-AQEBBQADgY0AMIGJAoGBAKfIoErEGQUbZroy4tLxHG8XguQ5LgFRkNsENDIRIcIN
+-b1nYU5BUP4OPqdOz1e4am4CuwyXJXqWvS2AFqqDRkQEfygSD41gcmTJFhHByWAOY
+-SmOLQfUISdKRAmBr5GT+3aCqdAjpNEyRXxI9N01ULK1/W5hgNgKMO/ZF8ydqm5Sd
+-AgMBAAGjggEaMIIBFjAJBgNVHRMEAjAAMCwGCWCGSAGG+EIBDQQfFh1PcGVuU1NM
+-IEdlbmVyYXRlZCBDZXJ0aWZpY2F0ZTAdBgNVHQ4EFgQUIYUEPSMBZuX3nxqEJIqv
+-Cnn05awwgbsGA1UdIwSBszCBsKGBoqSBnzCBnDELMAkGA1UEBhMCTk8xDTALBgNV
+-BAgTBE9zbG8xEDAOBgNVBAcTB055ZGFsZW4xFjAUBgNVBAoTDVRyb2xsdGVjaCBB
+-U0ExFDASBgNVBAsTC0RldmVsb3BtZW50MRcwFQYDVQQDEw5mbHVrZS50cm9sbC5u
+-bzElMCMGCSqGSIb3DQEJARYWYWhhbnNzZW5AdHJvbGx0ZWNoLmNvbYIJAI6otOiR
+-t1QuMA0GCSqGSIb3DQEBBQUAA4IBAQBtV1/RBUPwYgXsKnGl3BkI8sSmvbsl2cqJ
+-AQ7kzx/BjMgkGDVTWXvAQ7Qy5piypu8VBQtIX+GgDJepoXfYNRgwvKmP07dUx/Gp
+-nl3mGb/2PFsr2OQ+YhiIi9Mk4UCbDOYpFmKr6gUkcDaqVZPvAoEbIxCiBOtWlXX8
+-+JSxXULFPzZEhV06LpBGiqK5b4euDBVAGTGQ/Dslu67xZhMNhZDZSTSP8l35ettN
+-XSf2dp01jAamTKOxsrZvHdejAP1y657qRKGvITR9x0LiSZEZi8CtuoKAqHFw9DUx
+-kWOEIJXpYK9ki8z/PYp2dD3IVW3kjsMrHOhCGK6f5mucNAbsavLD
++MIIF6zCCA9OgAwIBAgIUfo9amJtJGWqWE6f+SkAO85zkGr4wDQYJKoZIhvcNAQEL
++BQAwgYMxCzAJBgNVBAYTAk5PMQ0wCwYDVQQIDARPc2xvMQ0wCwYDVQQHDARPc2xv
++MRcwFQYDVQQKDA5UaGUgUXQgQ29tcGFueTEMMAoGA1UECwwDUiZEMRIwEAYDVQQD
++DAlIMiBUZXN0ZXIxGzAZBgkqhkiG9w0BCQEWDG1pbmltaUBxdC5pbzAgFw0yMDEw
++MjYxMjAxMzFaGA8yMTIwMTAwMjEyMDEzMVowgYMxCzAJBgNVBAYTAk5PMQ0wCwYD
++VQQIDARPc2xvMQ0wCwYDVQQHDARPc2xvMRcwFQYDVQQKDA5UaGUgUXQgQ29tcGFu
++eTEMMAoGA1UECwwDUiZEMRIwEAYDVQQDDAlIMiBUZXN0ZXIxGzAZBgkqhkiG9w0B
++CQEWDG1pbmltaUBxdC5pbzCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIB
++AOiUp5+E4blouKH7q+rVNR8NoYX2XkBW+q+rpy1zu5ssRSzbqxAjDx9dkht7Qlnf
++VlDT00JvpOWdeuPon5915edQRsY4Unl6mKH29ra3OtUa1/yCJXsGVJTKCj7k4Bxb
++5mZzb/fTlZntMLdTIBMfUbw62FKir1WjKIcJ9fCoG8JaGeKVO4Rh5p0ezd4UUUId
++r1BXl5Nqdqy2vTMsEDnjOsD3egkv8I2SKN4O6n/C3wWYpMOWYZkGoZiKz7rJs/i/
++ez7bsV7JlwdzTlhpJzkcOSVFBP6JlEOxTNNxZ1wtKy7PtZGmsSSATq2e6+bw38Ae
++Op0XnzzqcGjtDDofBmT7OFzZWjS9VZS6+DOOe2QHWle1nCHcHyH4ku6IRlsr9xkR
++NAIlOfnvHHxqJUenoeaZ4oQDjCBKS1KXygJO/tL7BLTQVn/xK1EmPvKNnjzWk4tR
++PnibUhhs5635qpOU/YPqFBh1JjVruZbsWcDAhRcew0uxONXOa9E+4lttQ9ySYa1A
++LvWqJuAX7gu2BsBMLyqfm811YnA7CIFMyO+HlqmkLFfv5L/xIRAXR7l26YGO0VwX
++CGjMfz4NVPMMke4nB7qa9NkpXQBQKMms3Qzd5JW0Hy9Ruj5O8GPcFZmV0twjd1uJ
++PD/cAjkWLaXjdNsJ16QWc2nghQRS6HYqKRX6j+CXOxupAgMBAAGjUzBRMB0GA1Ud
++DgQWBBRSCOU58j9NJZkMamt623qyCrhN3TAfBgNVHSMEGDAWgBRSCOU58j9NJZkM
++amt623qyCrhN3TAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4ICAQCq
++q4jxsWeNDv5Nq14hJtF9HB+ZL64zcZtRjJP1YgNs0QppKICmjPOL2nIMGmI/jKrs
++0eGAL/9XXNVHPxm1OPOncvimMMmU6emZfpMdEtTfKP43+Pg9HgKRjLoQp406vGeQ
++8ki/mbBhrItVPgEm3tu2AFA02XTYi+YxCI9kRZLGkM3FbgtOuTLPl0Z9y+kiPc9F
++uCSC03anBEqv+vDSI8+wODymQ/IJ3Jyz1lxIRDfp4qAekmy0jU2c91VOHHEmOmqq
++kqygGFRdwbe99m9yP63r6q0b5K3X2UnJ6bns0hmTwThYwpVPXLU8jdaTddbMukN2
++/Ef96Tsw8nWOEOPMySHOTIPgwyZRp26b0kA9EmhLwOP401SxXVQCmSRmtwNagmtg
++jJKmZoYBN+//D45ibK8z6Q0oOm9P+Whf/uUXehcRxBxyV3xz7k0wKGQbHj/ddwcy
++IUoIN4lrAlib+lK170kTKN352PDmrpo2gmIzPEsfurKAIMSelDl6H+kih16BtZ8y
++Nz6fh9Soqrg3OSAware8pxV7k51crBMoPLN78KoRV8MFCK4K7Fddq4rRISq6hiXq
++r1nsjoEPuKM9huprmZVZe9t5YcDa2I+wb3IiE3uwpZbAdaLDyQ5n6F/qpsiIkZXn
++gtcF7oqpG5oYrwCcZ53y/ezUgUg7PlSz2XwAGvQtgg==
+ -----END CERTIFICATE-----
+diff --git a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
+index 9d1664d609..337ce541a6 100644
+--- a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
++++ b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
+@@ -1,15 +1,52 @@
+------BEGIN RSA PRIVATE KEY-----
+-MIICXAIBAAKBgQCnyKBKxBkFG2a6MuLS8RxvF4LkOS4BUZDbBDQyESHCDW9Z2FOQ
+-VD+Dj6nTs9XuGpuArsMlyV6lr0tgBaqg0ZEBH8oEg+NYHJkyRYRwclgDmEpji0H1
+-CEnSkQJga+Rk/t2gqnQI6TRMkV8SPTdNVCytf1uYYDYCjDv2RfMnapuUnQIDAQAB
+-AoGANFzLkanTeSGNFM0uttBipFT9F4a00dqHz6JnO7zXAT26I5r8sU1pqQBb6uLz
+-/+Qz5Zwk8RUAQcsMRgJetuPQUb0JZjF6Duv24hNazqXBCu7AZzUenjafwmKC/8ri
+-KpX3fTwqzfzi//FKGgbXQ80yykSSliDL3kn/drATxsLCgQECQQDXhEFWLJ0vVZ1s
+-1Ekf+3NITE+DR16X+LQ4W6vyEHAjTbaNWtcTKdAWLA2l6N4WAAPYSi6awm+zMxx4
+-VomVTsjdAkEAx0z+e7natLeFcrrq8pbU+wa6SAP1VfhQWKitxL1e7u/QO90NCpxE
+-oQYKzMkmmpOOFjQwEMAy1dvFMbm4LHlewQJAC/ksDBaUcQHHqjktCtrUb8rVjAyW
+-A8lscckeB2fEYyG5J6dJVaY4ClNOOs5yMDS2Afk1F6H/xKvtQ/5CzInA/QJATDub
+-K+BPU8jO9q+gpuIi3VIZdupssVGmCgObVCHLakG4uO04y9IyPhV9lA9tALtoIf4c
+-VIvv5fWGXBrZ48kZAQJBAJmVCdzQxd9LZI5vxijUCj5EI4e+x5DRqVUvyP8KCZrC
+-AiNyoDP85T+hBZaSXK3aYGpVwelyj3bvo1GrTNwNWLw=
+------END RSA PRIVATE KEY-----
++-----BEGIN PRIVATE KEY-----
++MIIJQgIBADANBgkqhkiG9w0BAQEFAASCCSwwggkoAgEAAoICAQDolKefhOG5aLih
+++6vq1TUfDaGF9l5AVvqvq6ctc7ubLEUs26sQIw8fXZIbe0JZ31ZQ09NCb6TlnXrj
++6J+fdeXnUEbGOFJ5epih9va2tzrVGtf8giV7BlSUygo+5OAcW+Zmc2/305WZ7TC3
++UyATH1G8OthSoq9VoyiHCfXwqBvCWhnilTuEYeadHs3eFFFCHa9QV5eTanastr0z
++LBA54zrA93oJL/CNkijeDup/wt8FmKTDlmGZBqGYis+6ybP4v3s+27FeyZcHc05Y
++aSc5HDklRQT+iZRDsUzTcWdcLSsuz7WRprEkgE6tnuvm8N/AHjqdF5886nBo7Qw6
++HwZk+zhc2Vo0vVWUuvgzjntkB1pXtZwh3B8h+JLuiEZbK/cZETQCJTn57xx8aiVH
++p6HmmeKEA4wgSktSl8oCTv7S+wS00FZ/8StRJj7yjZ481pOLUT54m1IYbOet+aqT
++lP2D6hQYdSY1a7mW7FnAwIUXHsNLsTjVzmvRPuJbbUPckmGtQC71qibgF+4LtgbA
++TC8qn5vNdWJwOwiBTMjvh5appCxX7+S/8SEQF0e5dumBjtFcFwhozH8+DVTzDJHu
++Jwe6mvTZKV0AUCjJrN0M3eSVtB8vUbo+TvBj3BWZldLcI3dbiTw/3AI5Fi2l43Tb
++CdekFnNp4IUEUuh2KikV+o/glzsbqQIDAQABAoICAFw1q6tr5I48vY7DF+rXsuLn
++5ZUWE1IQ6fzB4lr72nJv/9EEGnMgYzt9PpMUsD6vdCpBgS2C0+6RHArFzJtNA+RM
++iHLIG7K7702veyr/xBx/MwiSlMeMv/XpkFxVI6E6skMGG2s3AMXxKvJTy5CpRx+I
++eQFyLG+Ya1X2lgJes/q+/CpAHkOjCOpcLySQC5NZ74q734V7nSdmn+Zs3tYEh+O/
++eiuwTP/j5b38Te5vVTqDxTciJPmljmXLCwa0N100lWlbcpvw8qbqiTI2Jm3XCbUE
++AzHjW9vmrF3cRS1fXxKFGShw3SRqlkbxjfeWoi8qDPUBS4m8LOr8qG9Wo5Nfon0z
++zLP4bci3zHDvVcaaZrrsUBs/yZbg+Dgka1DmX7ekmeccr2yTdKDFgPupYUyxVbTl
++a9ZLJysjFD7rgBv1ZclHonLp6Vbm+ZoTqvteo4ikAy6L9RtBWJ23XEK34PkP/+c5
++2vWZaOrnjSeBHbFce8cdJSxqWpP+eSCI5I9XbDrYFIsQ/gqKgtzDKy2ihJ2Y8STL
++yO4hyFPFjxc+Gg4/P2PpmT5CY2ty44M0BWs+JGW96CJPrrplf2lmQUQJj5LZY66X
++Z/4C9L7ZYtKZ+bs5SvU46yWugAvQZX22Xm9xLXWyVXRdx3bj+3M3fDnF9di/zdbh
++CgLx7oWPNrXc7FCajnn9AoIBAQD5FMYwRpw9NWT9WDxQwx+cSI4Icbd88ByTW63S
++LzeRwZA0J9/SfwO+aBRupzc9GkGXCiZcGMw3AGsCtig8yFlw8E5KnzN7KlftDMnM
++9NUxxzlR8VwKyLnZfG7sDTl057ZlUujnqhmt/F8F7dIy7FVO1dE/8nngA+FYTCOG
++UZdGjwyBDlDM0JJdUWGY3xslutcpCDN5mzSTKjy9drMvImAshRawxRF6WBpn7vr2
++nC6vciqfx1Mzx1vyk0Jm0ilaydDdLMADjt/iL4Nkr0BEs4k+UzQiKDwp8gu7abQ1
++eBfxd9Iar4htQa2I1Ewl6P01G/q+ZYwgHhJ9RVn4AxQXefILAoIBAQDvCouORdQX
++C8wsyp7MwXlF/3NQeNN5/+B2mhbxrBOf7PmMCXLnkRWcjwJtzypWFqJ0sqai/2+0
++bqbMcjX5maT8stT2shl3zXe/Ejt2e3TBYpc1tyuses8Kb5BMU8hu6tTd3G2CMXpD
++dT6DVemJZCTtwj9aBNIxSizvlgMolJnCpzhPnlfHSI6E+g3m/LTTo3HwbjMSw/Uq
++irgjOpI2wSBB6LZPSgjvfcYPRyWUk16L4A5uSX0cADnovDFLa5/h0wJvN/OoCSQg
++rLCXG5E18EyL5Wc58BCY1ZvxmjG3lQtgPxYu2Jwc36R/y/JKlxW5suER5ZNpbbD4
++uOyTt2VxMQ2bAoIBAQC5+MzRFqdo/AjfL5Y5JrbfVTzXCTDa09xCGd16ZU60QTWN
+++4ed/r+o1sUKqUcRFB2MzEM/2DQBjQpZB/CbEWvWa1XJWXxypXbowveZU+QqOnmN
++uQvj8WLyA3o+PNF9e9QvauwCrHpn8VpxbtPWuaYoKnUFreFZZQxHhPGxRBIS2JOZ
++eDrT8ZaWnkCkh1AZp5smQ71LOprSlmKrg4jd1GjCVMxQR5N5KXbtyv0OTCZ/UFqK
++2aRBsMPyJgkaBChkZPLRcKwc+/wlQRx1fHQb14DNTApMxoXFO7eOwqmOkpAt9iyl
++SBIwoS0UUI5ab88+bBmXNvKcuFdNuQ4nowTJUn9pAoIBADMNkILBXSvS5DeIyuO2
++Sp1tkoZUV+5NfPY3sMDK3KIibaW/+t+EOBZo4L7tKQCb8vRzl21mmsfxfgRaPDbj
++3r3tv9g0b4YLxxBy52pFscj/soXRai17SS7UZwA2QK+XzgDYbDcLNC6mIsTQG4Gx
++dsWk3/zs3KuUSQaehmwrWK+fIUK38c1pLK8v7LoxrLkqxlHwZ04RthHw8KTthH7X
++Pnl1J0LF8CSeOyfWLSuPUfkT0GEzptnNHpEbaHfQM6R6eaGhVJPF6AZme4y6YYgg
++m2ihhSt1n0XVEWpHYWjxFy3mK2mz75unFC4LM+NEY2p2zuUQoCw7NjnY3QYrfCnx
++rRMCggEAXeXsMSLFjjyuoL7iKbAxo52HD/P0fBoy58LyRcwfNVr0lvYan4pYEx+o
++KijIh9K16PqXZXKMA9v003B+ulmF8bJ7SddCZ5NGvnFhUTDe4DdTKgp2RuwQ3Bsc
++3skPIDbhVETyOLCtys34USHrq8U/0DlGY3eLRfxw9GnbKxSBGa/KEu/qQLPNUo50
++7xHZDg7GKeC3kqNJeqKM9rkp0VzIGkEnaD9127LeNDmERDfftxJzFoC/THvUBLfU
++6Sus2ZYwRE8VFvKC30Q45t/c54X3IuhYvAuiCuTmyfE4ruyzyOwKzhUkeeLq1APX
++g0veFbyfzlJ0q8qzD/iffqqIa2ZSmQ==
++-----END PRIVATE KEY-----
+diff --git a/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp b/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
+index 7ba3715e13..752aa122f6 100644
+--- a/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
++++ b/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
+@@ -179,6 +179,7 @@ void tst_QAccessibilityLinux::initTestCase()
+     QVERIFY(!address.isEmpty());
+ 
+     m_window = new AccessibleTestWindow();
++    m_window->setObjectName("mainWindow"_L1);
+     m_window->show();
+ 
+     QVERIFY(QTest::qWaitForWindowExposed(m_window));
+@@ -236,8 +237,11 @@ bool hasState(QDBusInterface *interface, AtspiStateType state)
+ void tst_QAccessibilityLinux::testLabel()
+ {
+     QLabel *l = new QLabel(m_window);
++    l->setObjectName("theObjectName"_L1);
+     l->setText("Hello A11y");
+     m_window->addWidget(l);
++    auto a11yEmpty = new QLabel(m_window);
++    m_window->addWidget(l);
+ 
+     // Application
+     QCOMPARE(getParent(mainWindow), QLatin1String(ATSPI_DBUS_PATH_ROOT));
+@@ -249,6 +253,8 @@ void tst_QAccessibilityLinux::testLabel()
+     QCOMPARE(getChildren(labelInterface).count(), 0);
+     QCOMPARE(labelInterface->call(QDBus::Block, "GetRoleName").arguments().first().toString(), QLatin1String("label"));
+     QCOMPARE(labelInterface->call(QDBus::Block, "GetRole").arguments().first().toUInt(), 29u);
++    QCOMPARE(labelInterface->call(QDBus::Block, "GetAccessibleId").arguments().first().toString(),
++             QLatin1String("mainWindow.theObjectName"));
+     QCOMPARE(getParent(labelInterface), mainWindow->path());
+     QVERIFY(!hasState(labelInterface, ATSPI_STATE_EDITABLE));
+     QVERIFY(hasState(labelInterface, ATSPI_STATE_READ_ONLY));
+@@ -256,7 +262,12 @@ void tst_QAccessibilityLinux::testLabel()
+     l->setText("New text");
+     QCOMPARE(labelInterface->property("Name").toString(), l->text());
+ 
++    auto *a11yEmptyInterface = getInterface(children.at(1), "org.a11y.atspi.Accessible");
++    QCOMPARE(a11yEmptyInterface->call(QDBus::Block, "GetAccessibleId").arguments().first().toString(),
++             QLatin1String("mainWindow.QLabel"));
++
+     m_window->clearChildren();
++    delete a11yEmptyInterface;
+     delete labelInterface;
+ }
+ 
+diff --git a/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+index 76df61c892..6d6d65b791 100644
+--- a/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
++++ b/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2022 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the test suite of the Qt Toolkit.
+@@ -68,6 +68,8 @@ private slots:
+     void query_exec();
+     void execErrorRecovery_data() { generic_data(); }
+     void execErrorRecovery();
++    void prematureExec_data() { generic_data(); }
++    void prematureExec();
+     void first_data() { generic_data(); }
+     void first();
+     void next_data() { generic_data(); }
+@@ -2770,6 +2772,35 @@ void tst_QSqlQuery::execErrorRecovery()
+     QVERIFY_SQL( q, exec() );
+ }
+ 
++void tst_QSqlQuery::prematureExec()
++{
++    QFETCH(QString, dbName);
++    // We only want the engine name, for addDatabase():
++    int cut = dbName.indexOf(QChar('@'));
++    if (cut < 0)
++        QSKIP("Failed to parse database type out of name");
++    dbName.truncate(cut);
++    cut = dbName.indexOf(QChar('_'));
++    if (cut >= 0)
++        dbName = dbName.mid(cut + 1);
++
++    auto db = QSqlDatabase::addDatabase(dbName);
++    QSqlQuery q(db);
++
++    QTest::ignoreMessage(QtWarningMsg,
++                         "QSqlDatabasePrivate::removeDatabase: connection "
++                         "'qt_sql_default_connection' is still in use, all "
++                         "queries will cease to work.");
++    QTest::ignoreMessage(QtWarningMsg,
++                         "QSqlDatabasePrivate::addDatabase: duplicate connection name "
++                         "'qt_sql_default_connection', old connection removed.");
++    auto otherDb = QSqlDatabase::addDatabase(dbName);
++
++    QTest::ignoreMessage(QtWarningMsg, "QSqlQuery::exec: called before driver has been set up");
++    // QTBUG-100037: shouldn't crash !
++    QVERIFY(!q.exec("select stuff from TheVoid"));
++}
++
+ void tst_QSqlQuery::lastInsertId()
+ {
+     QFETCH( QString, dbName );
+diff --git a/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp b/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
+index 4aa3f8d60b..d2050a61aa 100644
+--- a/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
++++ b/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
+@@ -115,6 +115,10 @@ void tst_QAbstractItemModelTester::standardItemModelZeroColumns()
+     // QTBUG-92886
+     model.insertRows(0, 5);
+     model.removeRows(1, 2);
++
++    const QModelIndex parentIndex = model.index(0, 0);
++    model.insertRows(0, 5, parentIndex);
++    model.removeRows(1, 2, parentIndex);
+ }
+ 
+ void tst_QAbstractItemModelTester::testInsertThroughProxy()
+diff --git a/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json b/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
+index 12a4a22a19..ce518e78fb 100644
+--- a/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
++++ b/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
+@@ -668,50 +668,6 @@
+         "inputFile": "task192552.h",
+         "outputRevision": 67
+     },
+-    {
+-        "classes": [
+-            {
+-                "className": "InlineSlotsWithThrowDeclaration",
+-                "object": true,
+-                "qualifiedClassName": "InlineSlotsWithThrowDeclaration",
+-                "slots": [
+-                    {
+-                        "access": "public",
+-                        "name": "a",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "b",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "c",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "d",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "e",
+-                        "returnType": "void"
+-                    }
+-                ],
+-                "superClasses": [
+-                    {
+-                        "access": "public",
+-                        "name": "QObject"
+-                    }
+-                ]
+-            }
+-        ],
+-        "inputFile": "task189996.h",
+-        "outputRevision": 67
+-    },
+     {
+         "classes": [
+             {
+diff --git a/qtbase/tests/auto/tools/moc/moc.pro b/qtbase/tests/auto/tools/moc/moc.pro
+index c324b3a8cd..4aceb78dc0 100644
+--- a/qtbase/tests/auto/tools/moc/moc.pro
++++ b/qtbase/tests/auto/tools/moc/moc.pro
+@@ -15,7 +15,7 @@ cross_compile: DEFINES += MOC_CROSS_COMPILED
+ HEADERS += using-namespaces.h no-keywords.h task87883.h c-comments.h backslash-newlines.h oldstyle-casts.h \
+            slots-with-void-template.h qinvokable.h namespaced-flags.h trigraphs.h \
+            escapes-in-string-literals.h cstyle-enums.h qprivateslots.h gadgetwithnoenums.h \
+-           dir-in-include-path.h single_function_keyword.h task192552.h task189996.h \
++           dir-in-include-path.h single_function_keyword.h task192552.h \
+            task234909.h task240368.h pure-virtual-signals.h cxx11-enums.h \
+            cxx11-final-classes.h \
+            cxx11-explicit-override-control.h \
+diff --git a/qtbase/tests/auto/tools/moc/task189996.h b/qtbase/tests/auto/tools/moc/task189996.h
+deleted file mode 100644
+index f94a051b3a..0000000000
+--- a/qtbase/tests/auto/tools/moc/task189996.h
++++ /dev/null
+@@ -1,47 +0,0 @@
+-/****************************************************************************
+-**
+-** Copyright (C) 2016 The Qt Company Ltd.
+-** Contact: https://www.qt.io/licensing/
+-**
+-** This file is part of the test suite of the Qt Toolkit.
+-**
+-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+-** 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 General Public License Usage
+-** Alternatively, this file may be used under the terms of the GNU
+-** General Public License version 3 as published by the Free Software
+-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+-** 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-3.0.html.
+-**
+-** $QT_END_LICENSE$
+-**
+-****************************************************************************/
+-// inline functions can have throw declarations
+-
+-#ifndef TASK189996_H
+-#define TASK189996_H
+-
+-#include <QObject>
+-
+-class InlineSlotsWithThrowDeclaration : public QObject
+-{
+-    Q_OBJECT
+-
+-public slots:
+-    void a() throw() { }
+-    void b() const throw() { }
+-    void c() throw();
+-    void d() throw(int) { }
+-    void e() const throw(int,double) { }
+-};
+-
+-#endif
+diff --git a/qtbase/tests/auto/tools/moc/tst_moc.cpp b/qtbase/tests/auto/tools/moc/tst_moc.cpp
+index c716aead21..15dd9e41e5 100644
+--- a/qtbase/tests/auto/tools/moc/tst_moc.cpp
++++ b/qtbase/tests/auto/tools/moc/tst_moc.cpp
+@@ -631,7 +631,6 @@ public:
+ private slots:
+     void initTestCase();
+ 
+-    void slotWithException() throw(MyStruct);
+     void dontStripNamespaces();
+     void oldStyleCasts();
+     void warnOnExtraSignalSlotQualifiaction();
+@@ -673,7 +672,6 @@ private slots:
+     void templateGtGt();
+     void qprivateslots();
+     void qprivateproperties();
+-    void inlineSlotsWithThrowDeclaration();
+     void warnOnPropertyWithoutREAD();
+     void constructors();
+     void typenameWithUnsigned();
+@@ -784,12 +782,6 @@ void tst_Moc::initTestCase()
+ #endif
+ }
+ 
+-void tst_Moc::slotWithException() throw(MyStruct)
+-{
+-    // be happy
+-    QVERIFY(true);
+-}
+-
+ void tst_Moc::dontStripNamespaces()
+ {
+     Sender sender;
+@@ -824,7 +816,7 @@ void tst_Moc::oldStyleCasts()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-Wold-style-cast" << "-I" << "."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -894,7 +886,7 @@ void tst_Moc::inputFileNameWithDotsButNoExtension()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-I" << ".."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -1174,7 +1166,7 @@ void tst_Moc::ignoreOptionClashes()
+     QStringList gccArgs;
+     gccArgs << "-c" << "-x" << "c++" << "-I" << ".."
+          << "-I" << qtIncludePath << "-I" << includeDir << "-o" << "/dev/null"
+-         << "-fPIC" << "-std=c++11" <<  "-";
++         << "-fPIC" << "-std=c++1z" <<  "-";
+     proc.start("gcc", gccArgs);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -1593,21 +1585,6 @@ void tst_Moc::qprivateproperties()
+ 
+ }
+ 
+-#include "task189996.h"
+-
+-void InlineSlotsWithThrowDeclaration::c() throw() {}
+-
+-void tst_Moc::inlineSlotsWithThrowDeclaration()
+-{
+-    InlineSlotsWithThrowDeclaration tst;
+-    const QMetaObject *mobj = tst.metaObject();
+-    QVERIFY(mobj->indexOfSlot("a()") != -1);
+-    QVERIFY(mobj->indexOfSlot("b()") != -1);
+-    QVERIFY(mobj->indexOfSlot("c()") != -1);
+-    QVERIFY(mobj->indexOfSlot("d()") != -1);
+-    QVERIFY(mobj->indexOfSlot("e()") != -1);
+-}
+-
+ void tst_Moc::warnOnPropertyWithoutREAD()
+ {
+ #ifdef MOC_CROSS_COMPILED
+@@ -1869,7 +1846,7 @@ void tst_Moc::notifyError()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-I" << "."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+diff --git a/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+index c355ee9665..88c09de8e0 100644
+--- a/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
++++ b/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+@@ -251,6 +251,7 @@ private slots:
+     void testResetCachedSizeHint();
+     void statusTips();
+     void testRemovingColumnsViaLayoutChanged();
++    void testModelMovingColumns();
+ 
+ protected:
+     void setupTestData(bool use_reset_model = false);
+@@ -360,6 +361,12 @@ public:
+         endRemoveColumns();
+     }
+ 
++    void moveColumn(int from, int to)
++    {
++        beginMoveColumns(QModelIndex(), from, from, QModelIndex(), to);
++        endMoveColumns();
++    }
++
+     void cleanup()
+     {
+         emit layoutAboutToBeChanged();
+@@ -3627,5 +3634,18 @@ void tst_QHeaderView::testRemovingColumnsViaLayoutChanged()
+     // The main point of this test is that the section-size restoring code didn't go out of bounds.
+ }
+ 
++void tst_QHeaderView::testModelMovingColumns()
++{
++    QtTestModel model(10, 10);
++    QHeaderView hv(Qt::Horizontal);
++    hv.setModel(&model);
++    hv.resizeSections(QHeaderView::ResizeToContents);
++    hv.show();
++
++    QPersistentModelIndex index3 = model.index(0, 3);
++    model.moveColumn(3, 1);
++    QCOMPARE(index3.column(), 1);
++}
++
+ QTEST_MAIN(tst_QHeaderView)
+ #include "tst_qheaderview.moc"
+diff --git a/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+index 761357b252..06bb706074 100644
+--- a/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
++++ b/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+@@ -397,6 +397,7 @@ private slots:
+     void checkHeaderMinSize();
+ 
+     void resizeToContents();
++    void resizeToContentsSpans();
+ 
+     void tabFocus();
+     void bigModel();
+@@ -3721,6 +3722,70 @@ void tst_QTableView::resizeToContents()
+ 
+ }
+ 
++
++class SpanModel : public QAbstractTableModel
++{
++public:
++    SpanModel(bool sectionsMoved)
++        : _sectionsMoved(sectionsMoved)
++    {}
++    int columnCount(const QModelIndex & = {}) const override { return 2; }
++    int rowCount(const QModelIndex & = {}) const override { return 1; }
++    QVariant data(const QModelIndex &idx, int role = Qt::DisplayRole) const override
++    {
++        if (role != Qt::DisplayRole)
++            return QVariant();
++        const int col = _sectionsMoved ? 1 - idx.column() : idx.column();
++        if (col == 0)
++            return "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.";
++        return QVariant();
++    }
++private:
++    bool _sectionsMoved;
++};
++
++
++void tst_QTableView::resizeToContentsSpans()
++{
++    SpanModel model1(false);
++    SpanModel model2(true);
++    QTableView view1, view2, view3;
++    view1.setModel(&model1);
++    view2.setModel(&model2);
++    view2.horizontalHeader()->moveSection(0, 1);
++    view3.setModel(&model1);
++
++    view1.setSpan(0, 0, 1, 2);
++    view2.setSpan(0, 1, 1, 2);
++    view1.show();
++    view2.show();
++    view3.show();
++    QVERIFY(QTest::qWaitForWindowExposed(&view1));
++    QVERIFY(QTest::qWaitForWindowExposed(&view2));
++    QVERIFY(QTest::qWaitForWindowExposed(&view3));
++    view1.setColumnWidth(0, 100);
++    view1.setColumnWidth(1, 100);
++    view2.setColumnWidth(0, 100);
++    view2.setColumnWidth(1, 100);
++    view3.setColumnWidth(0, 200);
++
++    view1.resizeRowToContents(0);
++    view2.resizeRowToContents(0);
++    view3.resizeRowToContents(0);
++    QCOMPARE(view1.rowHeight(0), view3.rowHeight(0));
++    QCOMPARE(view2.rowHeight(0), view3.rowHeight(0));
++
++    view3.resizeColumnToContents(0);
++    view3.resizeRowToContents(0);
++    // height should be only 1 text line for easy testing
++    view1.setRowHeight(0, view3.verticalHeader()->sectionSize(0));
++    view2.setRowHeight(0, view3.verticalHeader()->sectionSize(0));
++    view1.resizeColumnToContents(0);
++    view2.resizeColumnToContents(1);
++    QCOMPARE(view1.columnWidth(0), view3.columnWidth(0) - view1.columnWidth(1));
++    QCOMPARE(view2.columnWidth(0), view3.columnWidth(0) - view2.columnWidth(1));
++}
++
+ QT_BEGIN_NAMESPACE
+ extern bool Q_WIDGETS_EXPORT qt_tab_all_widgets(); // qapplication.cpp
+ QT_END_NAMESPACE
+diff --git a/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+index a3b8ef78d8..4955cebd5d 100644
+--- a/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
++++ b/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+@@ -1498,7 +1498,7 @@ void tst_QApplication::desktopSettingsAware()
+     environment += QLatin1String("QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM=1");
+     testProcess.setEnvironment(environment);
+ #endif
+-    testProcess.start("desktopsettingsaware_helper");
++    testProcess.start("./desktopsettingsaware_helper");
+     QVERIFY2(testProcess.waitForStarted(),
+              qPrintable(QString::fromLatin1("Cannot start 'desktopsettingsaware_helper': %1").arg(testProcess.errorString())));
+     QVERIFY(testProcess.waitForFinished(10000));
+@@ -2452,7 +2452,7 @@ void tst_QApplication::qtbug_12673()
+ #if QT_CONFIG(process)
+     QProcess testProcess;
+     QStringList arguments;
+-    testProcess.start("modal_helper", arguments);
++    testProcess.start("./modal_helper", arguments);
+     QVERIFY2(testProcess.waitForStarted(),
+              qPrintable(QString::fromLatin1("Cannot start 'modal_helper': %1").arg(testProcess.errorString())));
+     QVERIFY(testProcess.waitForFinished(20000));
+diff --git a/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp b/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
+index eb108a40de..dca5528c1b 100644
+--- a/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
+@@ -41,6 +41,7 @@
+ 
+ #include <private/qguiapplication_p.h>
+ #include <qpa/qplatformintegration.h>
++#include <qpa/qplatformtheme.h>
+ 
+ class tst_QAbstractButton : public QObject
+ {
+@@ -76,6 +77,8 @@ private slots:
+     void keyNavigation();
+ #endif
+ 
++    void buttonPressKeys();
++
+ protected slots:
+     void onClicked();
+     void onToggled( bool on );
+@@ -269,7 +272,13 @@ void tst_QAbstractButton::setAutoRepeat()
+         QCOMPARE(press_count, click_count);
+         QVERIFY(click_count > 1);
+         break;
+-    case 4:
++    case 4: {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(Qt::Key_Enter)) {
++            QSKIP("platform theme has Key_Enter in ButtonPressKeys");
++        }
+         // check that pressing ENTER has no effect when autorepeat is false
+         testWidget->setDown( false );
+         testWidget->setAutoRepeat( false );
+@@ -286,7 +295,14 @@ void tst_QAbstractButton::setAutoRepeat()
+ 
+         QVERIFY( click_count == 0 );
+         break;
+-    case 5:
++    }
++    case 5: {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(Qt::Key_Enter)) {
++            QSKIP("platform theme has Key_Enter in ButtonPressKeys");
++        }
+         // check that pressing ENTER has no effect when autorepeat is true
+         testWidget->setDown( false );
+         testWidget->setAutoRepeat( true );
+@@ -304,6 +320,7 @@ void tst_QAbstractButton::setAutoRepeat()
+ 
+         QVERIFY( click_count == 0 );
+         break;
++    }
+     case 6:
+         // verify autorepeat is off by default.
+         MyButton tmp( 0);
+@@ -651,5 +668,16 @@ void tst_QAbstractButton::keyNavigation()
+ }
+ #endif
+ 
++void tst_QAbstractButton::buttonPressKeys()
++{
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(testWidget, buttonPressKeys[i]);
++        QCOMPARE(click_count, i + 1);
++    }
++}
++
+ QTEST_MAIN(tst_QAbstractButton)
+ #include "tst_qabstractbutton.moc"
+diff --git a/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+index 32437050f5..46b5af6d63 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+@@ -168,6 +168,7 @@ private slots:
+     void checkMenuItemPosWhenStyleSheetIsSet();
+     void checkEmbeddedLineEditWhenStyleSheetIsSet();
+     void propagateStyleChanges();
++    void buttonPressKeys();
+ 
+ private:
+     PlatformInputContext m_platformInputContext;
+@@ -1682,6 +1683,16 @@ void tst_QComboBox::setModel()
+     QCOMPARE(box.rootModelIndex(), rootModelIndex);
+     box.setModel(box.model());
+     QCOMPARE(box.rootModelIndex(), rootModelIndex);
++
++    // check that setting the same model as the completer's doesn't crash
++    QCompleter *completer = new QCompleter(&box);
++    box.setEditable(true);
++    box.setCompleter(completer);
++    auto *listModel = new QStringListModel({ "one", "two" }, completer);
++    completer->setModel(listModel);
++    QCOMPARE(listModel->rowCount(), 2); // make sure it wasn't deleted
++    box.setModel(listModel);
++    QCOMPARE(listModel->rowCount(), 2); // make sure it wasn't deleted
+ }
+ 
+ void tst_QComboBox::setCustomModelAndView()
+@@ -3632,5 +3643,24 @@ void tst_QComboBox::propagateStyleChanges()
+     QVERIFY(frameStyle.inquired);
+ }
+ 
++void tst_QComboBox::buttonPressKeys()
++{
++    QComboBox comboBox;
++    comboBox.setEditable(false);
++    comboBox.addItem(QString::number(1));
++    comboBox.addItem(QString::number(2));
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(&comboBox, buttonPressKeys[i]);
++        // On some platforms, a window will not be immediately visible,
++        // but take some event-loop iterations to complete.
++        // Using QTRY_VERIFY to deal with that.
++        QTRY_VERIFY(comboBox.view()->isVisible());
++        comboBox.hidePopup();
++    }
++}
++
+ QTEST_MAIN(tst_QComboBox)
+ #include "tst_qcombobox.moc"
+diff --git a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
+index be3cfcd104..c228fdfcca 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
++++ b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qcommandlinkbutton
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qcommandlinkbutton.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
+index 0044d33c66..4cf06296e4 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
+@@ -40,6 +40,9 @@
+ #include <QGridLayout>
+ #include <QPainter>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ class tst_QCommandLinkButton : public QObject
+ {
+     Q_OBJECT
+@@ -223,6 +226,13 @@ void tst_QCommandLinkButton::setAutoRepeat()
+     // check that pressing ENTER has no effect
+     resetCounters();
+     testWidget->setDown( false );
++    // Skip after reset if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
+     testWidget->setAutoRepeat( false );
+     QTest::keyPress( testWidget, Qt::Key_Enter );
+ 
+@@ -255,6 +265,14 @@ void tst_QCommandLinkButton::pressed()
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+ 
++    // Skip if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
++
+     QTest::keyPress( testWidget,Qt::Key_Enter );
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+diff --git a/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro b/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
+index 4a5e76ff65..a235fa1fac 100644
+--- a/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
++++ b/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qgroupbox
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qgroupbox.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp b/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
+index 4fb5d262ca..d8d7562b73 100644
+--- a/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
+@@ -35,6 +35,9 @@
+ #include <QRadioButton>
+ #include <QDialog>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ #include "qgroupbox.h"
+ 
+ class tst_QGroupBox : public QObject
+@@ -69,6 +72,7 @@ private slots:
+     void propagateFocus();
+     void task_QTBUG_19170_ignoreMouseReleaseEvent();
+     void task_QTBUG_15519_propagateMouseEvents();
++    void buttonPressKeys();
+ 
+ private:
+     bool checked;
+@@ -610,6 +614,20 @@ void tst_QGroupBox::task_QTBUG_15519_propagateMouseEvents()
+     QCOMPARE(parent.mouseMoved, true);
+ }
+ 
++void tst_QGroupBox::buttonPressKeys()
++{
++    QGroupBox groupBox;
++    groupBox.setCheckable(true);
++    QSignalSpy clickedSpy(&groupBox, &QGroupBox::clicked);
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(&groupBox, buttonPressKeys[i]);
++        QCOMPARE(clickedSpy.length(), i + 1);
++    }
++}
++
+ void tst_QGroupBox::sendMouseMoveEvent(QWidget *widget, const QPoint &localPos)
+ {
+     // Send a MouseMove event without actually moving the pointer
+diff --git a/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro b/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
+index 353ad06ca2..e55f6148f2 100644
+--- a/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
++++ b/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qpushbutton
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qpushbutton.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp b/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
+index e818514a79..4043e9326a 100644
+--- a/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
+@@ -41,6 +41,9 @@
+ #include <QStyleFactory>
+ #include <QTabWidget>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ class tst_QPushButton : public QObject
+ {
+ Q_OBJECT
+@@ -212,6 +215,13 @@ void tst_QPushButton::autoRepeat()
+     // check that pressing ENTER has no effect
+     resetCounters();
+     testWidget->setDown( false );
++    // Skip after reset if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
+     testWidget->setAutoRepeat( false );
+     QTest::keyPress( testWidget, Qt::Key_Enter );
+ 
+@@ -247,6 +257,14 @@ void tst_QPushButton::pressed()
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+ 
++    // Skip if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
++
+     QTest::keyPress( testWidget,Qt::Key_Enter );
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+diff --git a/qtbase/tests/manual/rhi/cubemap_render/buildshader.bat b/qtbase/tests/manual/rhi/cubemap_render/buildshader.bat
+old mode 100755
+new mode 100644
+Submodule qtconnectivity e957d481..056294c0:
+diff --git a/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp b/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
+index e2635fae..a8b8e3b9 100644
+--- a/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
++++ b/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
+@@ -563,9 +563,11 @@ void HciManager::handleHciAclPacket(const quint8 *data, int size)
+ 
+ void HciManager::handleLeMetaEvent(const quint8 *data)
+ {
+-    // Spec v4.2, Vol 2, part E, 7.7.65ff
++    // Spec v5.3, Vol 4, part E, 7.7.65.*
+     switch (*data) {
+-    case 0x1: {
++    case 0x1: // HCI_LE_Connection_Complete
++    case 0xA: // HCI_LE_Enhanced_Connection_Complete
++    {
+         const quint16 handle = bt_get_le16(data + 2);
+         emit connectionComplete(handle);
+         break;
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp b/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
+index 6a93143b..4a18cfc7 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
+@@ -320,7 +320,10 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_finishSdpScan(QBluetoothServiceD
+             for (const QBluetoothUuid &id : serviceClassUuids) {
+                 if (id.minimumSize() == 16) {
+                     serviceInfo.setServiceUuid(id);
+-                    serviceInfo.setServiceName(QBluetoothServiceDiscoveryAgent::tr("Custom Service"));
++                    if (serviceInfo.serviceName().isEmpty()) {
++                        serviceInfo.setServiceName(
++                                    QBluetoothServiceDiscoveryAgent::tr("Custom Service"));
++                    }
+                     QBluetoothServiceInfo::Sequence modSeq =
+                             serviceInfo.attribute(QBluetoothServiceInfo::ServiceClassIds).value<QBluetoothServiceInfo::Sequence>();
+                     modSeq.removeOne(QVariant::fromValue(id));
+@@ -334,8 +337,10 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_finishSdpScan(QBluetoothServiceD
+                 qCDebug(QT_BT_BLUEZ) << "Discovered services" << discoveredDevices.at(0).address().toString()
+                                      << serviceInfo.serviceName() << serviceInfo.serviceUuid()
+                                      << ">>>" << serviceInfo.serviceClassUuids();
+-
+-                emit q->serviceDiscovered(serviceInfo);
++                // Use queued connection to allow us finish the service looping; the application
++                // might call stop() when it has detected the service-of-interest.
++                QMetaObject::invokeMethod(q, "serviceDiscovered", Qt::QueuedConnection,
++                                          Q_ARG(QBluetoothServiceInfo, serviceInfo));
+             }
+         }
+     }
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp b/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
+index e4d85447..aadd4755 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
+@@ -593,7 +593,7 @@ void QBluetoothSocket::setSocketState(QBluetoothSocket::SocketState state)
+ bool QBluetoothSocket::canReadLine() const
+ {
+     Q_D(const QBluetoothSocketBase);
+-    return d->canReadLine();
++    return d->canReadLine() || QIODevice::canReadLine();
+ }
+ 
+ /*!
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp b/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
+index 084aa958..d6aa17a7 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
+@@ -284,6 +284,10 @@ void QBluetoothSocketPrivateBluezDBus::connectToService(
+         return;
+     }
+ 
++    if (service.socketProtocol() != QBluetoothServiceInfo::Protocol::UnknownProtocol)
++        socketType = service.socketProtocol();
++    qCDebug(QT_BT_BLUEZ) << "Socket protocol used:" << socketType;
++
+     connectToService(service.device().address(), targetService, openMode);
+ }
+ 
+diff --git a/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp b/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
+index 05bc1a0f..a7b5ef1f 100644
+--- a/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
++++ b/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
+@@ -142,7 +142,7 @@ void tst_QBluetoothSocket::initTestCase()
+     qDebug() << "Starting discovery";
+ 
+     sda->setUuidFilter(QBluetoothUuid(QString(TEST_SERVICE_UUID)));
+-    sda->start(QBluetoothServiceDiscoveryAgent::MinimalDiscovery);
++    sda->start(QBluetoothServiceDiscoveryAgent::FullDiscovery);
+ 
+     for (int connectTime = MaxConnectTime; !done_discovery && connectTime > 0; connectTime -= 1000)
+         QTest::qWait(1000);
+Submodule qtdeclarative f5701f0d..8defe7bf:
+diff --git a/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h b/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
+index b65b994d6c..15a8cd6878 100644
+--- a/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
++++ b/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
+@@ -86,7 +86,7 @@ public:
+         if (QTypeInfo<T>::isComplex) {
+             for (int i = 0; i < count; ++i)
+                 new (data + i) T(vector.at(i));
+-        } else {
++        } else if (count) {
+             memcpy(data, static_cast<const void*>(vector.constData()), count * sizeof(T));
+         }
+     }
+diff --git a/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp b/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
+index e57cdd8278..94613598af 100644
+--- a/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
++++ b/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
+@@ -1145,8 +1145,7 @@ void Heap::QObjectWrapper::markObjects(Heap::Base *that, QV4::MarkStack *markSta
+ void QObjectWrapper::destroyObject(bool lastCall)
+ {
+     Heap::QObjectWrapper *h = d();
+-    if (!h->internalClass)
+-        return; // destroyObject already got called
++    Q_ASSERT(h->internalClass);
+ 
+     if (h->object()) {
+         QQmlData *ddata = QQmlData::get(h->object(), false);
+@@ -1176,7 +1175,7 @@ void QObjectWrapper::destroyObject(bool lastCall)
+         }
+     }
+ 
+-    h->~Data();
++    h->destroy();
+ }
+ 
+ 
+diff --git a/qtdeclarative/src/qml/memory/qv4mm.cpp b/qtdeclarative/src/qml/memory/qv4mm.cpp
+index 06caf04e5a..da149a67c4 100644
+--- a/qtdeclarative/src/qml/memory/qv4mm.cpp
++++ b/qtdeclarative/src/qml/memory/qv4mm.cpp
+@@ -981,7 +981,7 @@ void MemoryManager::sweep(bool lastSweep, ClassDestroyStatsCallback classCountPt
+ 
+     if (MultiplyWrappedQObjectMap *multiplyWrappedQObjects = engine->m_multiplyWrappedQObjects) {
+         for (MultiplyWrappedQObjectMap::Iterator it = multiplyWrappedQObjects->begin(); it != multiplyWrappedQObjects->end();) {
+-            if (!it.value().isNullOrUndefined())
++            if (it.value().isNullOrUndefined())
+                 it = multiplyWrappedQObjects->erase(it);
+             else
+                 ++it;
+diff --git a/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp b/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
+index 2079a8ed04..a577cb2351 100644
+--- a/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
++++ b/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
+@@ -389,6 +389,12 @@ void QQmlDelegateModelPrivate::connectToAbstractItemModel()
+                       q,  QQmlDelegateModel, SLOT(_q_rowsRemoved(QModelIndex,int,int)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
+                       q,  QQmlDelegateModel, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsInserted(QModelIndex,int,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsInserted(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsRemoved(QModelIndex,int,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsRemoved(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsMoved(QModelIndex,int,int,QModelIndex,int)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
+                       q, QQmlDelegateModel, SLOT(_q_dataChanged(QModelIndex,QModelIndex,QVector<int>)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
+@@ -413,6 +419,12 @@ void QQmlDelegateModelPrivate::disconnectFromAbstractItemModel()
+                         q, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int)));
+     QObject::disconnect(aim, SIGNAL(rowsRemoved(QModelIndex,int,int)),
+                         q, SLOT(_q_rowsRemoved(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsInserted(QModelIndex,int,int)), q,
++                        SLOT(_q_columnsInserted(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsRemoved(QModelIndex,int,int)), q,
++                        SLOT(_q_columnsRemoved(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)), q,
++                        SLOT(_q_columnsMoved(QModelIndex,int,int,QModelIndex,int)));
+     QObject::disconnect(aim, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
+                         q, SLOT(_q_dataChanged(QModelIndex,QModelIndex,QVector<int>)));
+     QObject::disconnect(aim, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
+@@ -1973,6 +1985,38 @@ void QQmlDelegateModel::_q_rowsMoved(
+     }
+ }
+ 
++void QQmlDelegateModel::_q_columnsInserted(const QModelIndex &parent, int begin, int end)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if (parent == d->m_adaptorModel.rootIndex && begin == 0) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
++void QQmlDelegateModel::_q_columnsRemoved(const QModelIndex &parent, int begin, int end)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if (parent == d->m_adaptorModel.rootIndex && begin == 0) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
++void QQmlDelegateModel::_q_columnsMoved(const QModelIndex &parent, int start, int end,
++                                        const QModelIndex &destination, int column)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if ((parent == d->m_adaptorModel.rootIndex && start == 0)
++        || (destination == d->m_adaptorModel.rootIndex && column == 0)) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
+ void QQmlDelegateModel::_q_dataChanged(const QModelIndex &begin, const QModelIndex &end, const QVector<int> &roles)
+ {
+     Q_D(QQmlDelegateModel);
+diff --git a/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h b/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
+index 8aab4badca..d140bfbaaf 100644
+--- a/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
++++ b/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
+@@ -152,6 +152,9 @@ private Q_SLOTS:
+     void _q_itemsMoved(int from, int to, int count);
+     void _q_modelReset();
+     void _q_rowsInserted(const QModelIndex &,int,int);
++    void _q_columnsInserted(const QModelIndex &, int, int);
++    void _q_columnsRemoved(const QModelIndex &, int, int);
++    void _q_columnsMoved(const QModelIndex &, int, int, const QModelIndex &, int);
+     void _q_rowsAboutToBeRemoved(const QModelIndex &parent, int begin, int end);
+     void _q_rowsRemoved(const QModelIndex &,int,int);
+     void _q_rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int);
+diff --git a/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp b/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
+index 85719fdc80..78e2ab302c 100644
+--- a/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
++++ b/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
+@@ -46,6 +46,7 @@
+ #include "QtQuick/private/qquicktextinput_p.h"
+ #include "QtQuick/private/qquickaccessibleattached_p.h"
+ #include "QtQuick/qquicktextdocument.h"
++#include "QtQuick/qquickrendercontrol.h"
+ QT_BEGIN_NAMESPACE
+ 
+ #if QT_CONFIG(accessibility)
+@@ -57,7 +58,19 @@ QAccessibleQuickItem::QAccessibleQuickItem(QQuickItem *item)
+ 
+ QWindow *QAccessibleQuickItem::window() const
+ {
+-    return item()->window();
++    QQuickWindow *window = item()->window();
++
++    // For QQuickWidget the above window will be the offscreen QQuickWindow,
++    // which is not a part of the accessibility tree. Detect this case and
++    // return the window for the QQuickWidget instead.
++    if (window && !window->handle()) {
++        if (QQuickRenderControl *renderControl = QQuickWindowPrivate::get(window)->renderControl) {
++            if (QWindow *renderWindow = renderControl->renderWindow(nullptr))
++                return renderWindow;
++        }
++    }
++
++    return window;
+ }
+ 
+ int QAccessibleQuickItem::childCount() const
+@@ -113,19 +126,15 @@ QAccessibleInterface *QAccessibleQuickItem::childAt(int x, int y) const
+ QAccessibleInterface *QAccessibleQuickItem::parent() const
+ {
+     QQuickItem *parent = item()->parentItem();
+-    QQuickWindow *window = item()->window();
+-    QQuickItem *ci = window ? window->contentItem() : nullptr;
++    QQuickWindow *itemWindow = item()->window();
++    QQuickItem *ci = itemWindow ? itemWindow->contentItem() : nullptr;
+     while (parent && !QQuickItemPrivate::get(parent)->isAccessible && parent != ci)
+         parent = parent->parentItem();
+ 
+     if (parent) {
+         if (parent == ci) {
+-            // Jump out to the scene widget if the parent is the root item.
+-            // There are two root items, QQuickWindow::rootItem and
+-            // QQuickView::declarativeRoot. The former is the true root item,
+-            // but is not a part of the accessibility tree. Check if we hit
+-            // it here and return an interface for the scene instead.
+-            return QAccessible::queryAccessibleInterface(window);
++            // Jump out to the window if the parent is the root item
++            return QAccessible::queryAccessibleInterface(window());
+         } else {
+             while (parent && !parent->d_func()->isAccessible)
+                 parent = parent->parentItem();
+@@ -188,7 +197,7 @@ QAccessible::State QAccessibleQuickItem::state() const
+     QRect viewRect_ = viewRect();
+     QRect itemRect = rect();
+ 
+-    if (viewRect_.isNull() || itemRect.isNull() || !item()->window() || !item()->window()->isVisible() ||!item()->isVisible() || qFuzzyIsNull(item()->opacity()))
++    if (viewRect_.isNull() || itemRect.isNull() || !window() || !window()->isVisible() ||!item()->isVisible() || qFuzzyIsNull(item()->opacity()))
+         state.invisible = true;
+     if (!viewRect_.intersects(itemRect))
+         state.offscreen = true;
+@@ -201,6 +210,10 @@ QAccessible::State QAccessibleQuickItem::state() const
+     if (role() == QAccessible::EditableText)
+         if (auto ti = qobject_cast<QQuickTextInput *>(item()))
+             state.passwordEdit = ti->echoMode() != QQuickTextInput::Normal;
++    if (!item()->isEnabled()) {
++        state.focusable = false;
++        state.disabled = true;
++    }
+     return state;
+ }
+ 
+diff --git a/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h b/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
+index 39ffcaf39c..8baa01330c 100644
+--- a/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
++++ b/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
+@@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE
+ 
+ #if QT_CONFIG(accessibility)
+ 
+-class QAccessibleQuickWindow : public QAccessibleObject
++class Q_QUICK_EXPORT QAccessibleQuickWindow : public QAccessibleObject
+ {
+ public:
+     QAccessibleQuickWindow(QQuickWindow *object);
+diff --git a/qtdeclarative/src/quick/items/qquickdrag.cpp b/qtdeclarative/src/quick/items/qquickdrag.cpp
+index 8321fcfeed..383078b3b9 100644
+--- a/qtdeclarative/src/quick/items/qquickdrag.cpp
++++ b/qtdeclarative/src/quick/items/qquickdrag.cpp
+@@ -481,7 +481,9 @@ void QQuickDragAttached::setKeys(const QStringList &keys)
+     \qmlattachedproperty stringlist QtQuick::Drag::mimeData
+     \since 5.2
+ 
+-    This property holds a map of mimeData that is used during startDrag.
++    This property holds a map from mime type to data that is used during startDrag.
++    The mime data needs to be a \c string, or an \c ArrayBuffer with the data encoded
++    according to the mime type.
+ */
+ 
+ QVariantMap QQuickDragAttached::mimeData() const
+@@ -766,8 +768,12 @@ Qt::DropAction QQuickDragAttachedPrivate::startDrag(Qt::DropActions supportedAct
+     QDrag *drag = new QDrag(source ? source : q);
+     QMimeData *mimeData = new QMimeData();
+ 
+-    for (auto it = externalMimeData.cbegin(), end = externalMimeData.cend(); it != end; ++it)
+-        mimeData->setData(it.key(), it.value().toString().toUtf8());
++    for (auto it = externalMimeData.cbegin(), end = externalMimeData.cend(); it != end; ++it) {
++        if (static_cast<QMetaType::Type>(it.value().type()) == QMetaType::QByteArray)
++            mimeData->setData(it.key(), it.value().toByteArray());
++        else
++            mimeData->setData(it.key(), it.value().toString().toUtf8());
++    }
+ 
+     drag->setMimeData(mimeData);
+     if (pixmapLoader.isReady()) {
+diff --git a/qtdeclarative/src/quick/items/qquickitem.cpp b/qtdeclarative/src/quick/items/qquickitem.cpp
+index 75f1457816..dec0ae19ae 100644
+--- a/qtdeclarative/src/quick/items/qquickitem.cpp
++++ b/qtdeclarative/src/quick/items/qquickitem.cpp
+@@ -59,6 +59,7 @@
+ #include <QtCore/private/qnumeric_p.h>
+ #include <QtGui/qpa/qplatformtheme.h>
+ #include <QtCore/qloggingcategory.h>
++#include <QtCore/private/qduplicatetracker_p.h>
+ 
+ #include <private/qqmlglobal_p.h>
+ #include <private/qqmlengine_p.h>
+@@ -2326,6 +2327,7 @@ QQuickItem::QQuickItem(QQuickItemPrivate &dd, QQuickItem *parent)
+ QQuickItem::~QQuickItem()
+ {
+     Q_D(QQuickItem);
++    d->inDestructor = true;
+ 
+     if (d->windowRefCount > 1)
+         d->windowRefCount = 1; // Make sure window is set to null in next call to derefWindow().
+@@ -2526,6 +2528,7 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo
+     QQuickItem *current = item;
+     qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: startItem:" << startItem;
+     qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: firstFromItem:" << firstFromItem;
++    QDuplicateTracker<QQuickItem *> cycleDetector;
+     do {
+         qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: current:" << current;
+         qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: from:" << from;
+@@ -2592,7 +2595,10 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo
+         // traversed all of the chain (by compare the [current] item with [startItem])
+         // Since the [startItem] might be promoted to its parent if it is invisible,
+         // we still have to check [current] item with original start item
+-        if ((current == startItem || current == originalStartItem) && from == firstFromItem) {
++        // We might also run into a cycle before we reach firstFromItem again
++        // but note that we have to ignore current if we are meant to skip it
++        if (((current == startItem || current == originalStartItem) && from == firstFromItem) ||
++                (!skip && cycleDetector.hasSeen(current))) {
+             // wrapped around, avoid endless loops
+             if (item == contentItem) {
+                 qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: looped, return contentItem";
+@@ -2689,9 +2695,8 @@ void QQuickItem::setParentItem(QQuickItem *parentItem)
+ 
+         const bool wasVisible = isVisible();
+         op->removeChild(this);
+-        if (wasVisible) {
++        if (wasVisible && !op->inDestructor)
+             emit oldParentItem->visibleChildrenChanged();
+-        }
+     } else if (d->window) {
+         QQuickWindowPrivate::get(d->window)->parentlessItems.remove(this);
+     }
+@@ -2768,8 +2773,9 @@ void QQuickItem::setParentItem(QQuickItem *parentItem)
+ 
+     d->itemChange(ItemParentHasChanged, d->parentItem);
+ 
+-    emit parentChanged(d->parentItem);
+-    if (isVisible() && d->parentItem)
++    if (!d->inDestructor)
++        emit parentChanged(d->parentItem);
++    if (isVisible() && d->parentItem && !QQuickItemPrivate::get(d->parentItem)->inDestructor)
+         emit d->parentItem->visibleChildrenChanged();
+ }
+ 
+@@ -2965,7 +2971,8 @@ void QQuickItemPrivate::removeChild(QQuickItem *child)
+ 
+     itemChange(QQuickItem::ItemChildRemovedChange, child);
+ 
+-    emit q->childrenChanged();
++    if (!inDestructor)
++        emit q->childrenChanged();
+ }
+ 
+ void QQuickItemPrivate::refWindow(QQuickWindow *c)
+@@ -3194,6 +3201,7 @@ QQuickItemPrivate::QQuickItemPrivate()
+     , touchEnabled(false)
+ #endif
+     , hasCursorHandler(false)
++    , inDestructor(false)
+     , dirtyAttributes(0)
+     , nextDirtyItem(nullptr)
+     , prevDirtyItem(nullptr)
+@@ -5120,6 +5128,13 @@ void QQuickItem::componentComplete()
+         d->addToDirtyList();
+         QQuickWindowPrivate::get(d->window)->dirtyItem(this);
+     }
++
++#if QT_CONFIG(accessibility)
++    if (d->isAccessible && d->effectiveVisible) {
++        QAccessibleEvent ev(this, QAccessible::ObjectShow);
++        QAccessible::updateAccessibility(&ev);
++    }
++#endif
+ }
+ 
+ QQuickStateGroup *QQuickItemPrivate::_states()
+@@ -6106,9 +6121,11 @@ bool QQuickItemPrivate::setEffectiveVisibleRecur(bool newEffectiveVisible)
+         QAccessible::updateAccessibility(&ev);
+     }
+ #endif
+-    emit q->visibleChanged();
+-    if (childVisibilityChanged)
+-        emit q->visibleChildrenChanged();
++    if (!inDestructor) {
++        emit q->visibleChanged();
++        if (childVisibilityChanged)
++            emit q->visibleChildrenChanged();
++    }
+ 
+     return true;    // effective visibility DID change
+ }
+@@ -6157,6 +6174,15 @@ void QQuickItemPrivate::setEffectiveEnableRecur(QQuickItem *scope, bool newEffec
+     }
+ 
+     itemChange(QQuickItem::ItemEnabledHasChanged, effectiveEnable);
++#if QT_CONFIG(accessibility)
++    if (isAccessible) {
++        QAccessible::State changedState;
++        changedState.disabled = true;
++        changedState.focusable = true;
++        QAccessibleStateChangeEvent ev(q, changedState);
++        QAccessible::updateAccessibility(&ev);
++    }
++#endif
+     emit q->enabledChanged();
+ }
+ 
+diff --git a/qtdeclarative/src/quick/items/qquickitem_p.h b/qtdeclarative/src/quick/items/qquickitem_p.h
+index 841d91bb40..ade8fb61f2 100644
+--- a/qtdeclarative/src/quick/items/qquickitem_p.h
++++ b/qtdeclarative/src/quick/items/qquickitem_p.h
+@@ -472,6 +472,7 @@ public:
+     bool replayingPressEvent:1;
+     bool touchEnabled:1;
+     bool hasCursorHandler:1;
++    quint32 inDestructor:1; // has entered ~QQuickItem
+ 
+     enum DirtyType {
+         TransformOrigin         = 0x00000001,
+diff --git a/qtdeclarative/src/quick/items/qquickitemview.cpp b/qtdeclarative/src/quick/items/qquickitemview.cpp
+index 010a0152e1..f8ad168a17 100644
+--- a/qtdeclarative/src/quick/items/qquickitemview.cpp
++++ b/qtdeclarative/src/quick/items/qquickitemview.cpp
+@@ -1785,7 +1785,7 @@ void QQuickItemViewPrivate::refill(qreal from, qreal to)
+ 
+     do {
+         bufferPause.stop();
+-        if (currentChanges.hasPendingChanges() || bufferedChanges.hasPendingChanges()) {
++        if (currentChanges.hasPendingChanges() || bufferedChanges.hasPendingChanges() || currentChanges.active) {
+             currentChanges.reset();
+             bufferedChanges.reset();
+             releaseVisibleItems(reusableFlag);
+diff --git a/qtdeclarative/src/quick/items/qquickmousearea_p_p.h b/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
+index fba383e268..0d63618622 100644
+--- a/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
++++ b/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
+@@ -61,7 +61,6 @@ QT_BEGIN_NAMESPACE
+ 
+ class QQuickMouseEvent;
+ class QQuickMouseArea;
+-class QQuickPointerMask;
+ class QQuickMouseAreaPrivate : public QQuickItemPrivate
+ {
+     Q_DECLARE_PUBLIC(QQuickMouseArea)
+@@ -100,7 +99,6 @@ public:
+ #if QT_CONFIG(quick_draganddrop)
+     QQuickDrag *drag;
+ #endif
+-    QPointer<QQuickPointerMask> mask;
+     QPointF startScene;
+     QPointF targetStartPos;
+     QPointF lastPos;
+diff --git a/qtdeclarative/src/quick/items/qquicktext.cpp b/qtdeclarative/src/quick/items/qquicktext.cpp
+index 6230186933..e823ca1095 100644
+--- a/qtdeclarative/src/quick/items/qquicktext.cpp
++++ b/qtdeclarative/src/quick/items/qquicktext.cpp
+@@ -2168,7 +2168,7 @@ void QQuickText::resetMaximumLineCount()
+     <img src="" align="top,middle,bottom" width="" height=""> - inline images
+     <ol type="">, <ul type=""> and <li> - ordered and unordered lists
+     <pre></pre> - preformatted
+-    &gt; &lt; &amp;
++    &gt; &lt; &amp; &quot; &nbsp; &apos;
+     \endcode
+ 
+     \c Text.StyledText parser is strict, requiring tags to be correctly nested.
+diff --git a/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp b/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
+index eb4db0f85e..2325a2665b 100644
+--- a/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
++++ b/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
+@@ -446,7 +446,7 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+         const char *textureRecord = allocatorData;
+         for (int i = 0; i < textureCount; ++i, textureRecord += Qtdf::TextureRecordSize) {
+-            if (textureRecord + Qtdf::TextureRecordSize > qtdfTableEnd) {
++            if (qtdfTableEnd - textureRecord < Qtdf::TextureRecordSize) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+@@ -462,7 +462,7 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+         const char *glyphRecord = textureRecord;
+         for (quint32 i = 0; i < glyphCount; ++i, glyphRecord += Qtdf::GlyphRecordSize) {
+-            if (glyphRecord + Qtdf::GlyphRecordSize > qtdfTableEnd) {
++            if (qtdfTableEnd - glyphRecord < Qtdf:: GlyphRecordSize) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+@@ -512,8 +512,8 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+             int width = texInfo->allocatedArea.width();
+             int height = texInfo->allocatedArea.height();
+-            qint64 size = width * height;
+-            if (reinterpret_cast<const char *>(textureData + size) > qtdfTableEnd) {
++            qint64 size = qint64(width) * height;
++            if (qtdfTableEnd - reinterpret_cast<const char *>(textureData) < size) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+diff --git a/qtdeclarative/src/quick/util/qquickstyledtext.cpp b/qtdeclarative/src/quick/util/qquickstyledtext.cpp
+index d531fc9205..a25af90414 100644
+--- a/qtdeclarative/src/quick/util/qquickstyledtext.cpp
++++ b/qtdeclarative/src/quick/util/qquickstyledtext.cpp
+@@ -564,6 +564,8 @@ void QQuickStyledTextPrivate::parseEntity(const QChar *&ch, const QString &textI
+                 textOut += QChar(60);
+             else if (entity == QLatin1String("amp"))
+                 textOut += QChar(38);
++            else if (entity == QLatin1String("apos"))
++                textOut += QChar(39);
+             else if (entity == QLatin1String("quot"))
+                 textOut += QChar(34);
+             else if (entity == QLatin1String("nbsp"))
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp
+new file mode 100644
+index 0000000000..8a1c901880
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp
+@@ -0,0 +1,110 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include "qaccessiblequickwidget_p.h"
++
++#include "qquickwidget_p.h"
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleQuickWidget::QAccessibleQuickWidget(QQuickWidget* widget)
++: QAccessibleWidget(widget)
++, m_accessibleWindow(QQuickWidgetPrivate::get(widget)->offscreenWindow)
++{
++    // NOTE: m_accessibleWindow is a QAccessibleQuickWindow, and not a
++    // QAccessibleQuickWidgetOffscreenWindow (defined below). This means
++    // it will return the Quick item child interfaces, which is what's needed here
++    // (unlike QAccessibleQuickWidgetOffscreenWindow, which will report 0 children).
++}
++
++QAccessibleInterface *QAccessibleQuickWidget::child(int index) const
++{
++    return m_accessibleWindow.child(index);
++}
++
++int QAccessibleQuickWidget::childCount() const
++{
++    return m_accessibleWindow.childCount();
++}
++
++int QAccessibleQuickWidget::indexOfChild(const QAccessibleInterface *iface) const
++{
++    return m_accessibleWindow.indexOfChild(iface);
++}
++
++QAccessibleInterface *QAccessibleQuickWidget::childAt(int x, int y) const
++{
++    return m_accessibleWindow.childAt(x, y);
++}
++
++QAccessibleQuickWidgetOffscreenWindow::QAccessibleQuickWidgetOffscreenWindow(QQuickWindow *window)
++:QAccessibleQuickWindow(window)
++{
++
++}
++
++QAccessibleInterface *QAccessibleQuickWidgetOffscreenWindow::child(int index) const
++{
++    Q_UNUSED(index);
++    return nullptr;
++}
++
++int QAccessibleQuickWidgetOffscreenWindow::childCount() const
++{
++    return 0;
++}
++
++int QAccessibleQuickWidgetOffscreenWindow::indexOfChild(const QAccessibleInterface *iface) const
++{
++    Q_UNUSED(iface);
++    return -1;
++}
++
++QAccessibleInterface *QAccessibleQuickWidgetOffscreenWindow::QAccessibleQuickWidgetOffscreenWindow::childAt(int x, int y) const
++{
++    Q_UNUSED(x);
++    Q_UNUSED(y);
++    return nullptr;
++}
++
++#endif // accessibility
++
++QT_END_NAMESPACE
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h
+new file mode 100644
+index 0000000000..7c2ab930e0
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h
+@@ -0,0 +1,95 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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 QACCESSIBLEQUICKWIDGET_H
++#define QACCESSIBLEQUICKWIDGET_H
++
++//
++//  W A R N I N G
++//  -------------
++//
++// This file is not part of the Qt API.  It exists purely as an
++// implementation detail.  This header file may change from version to
++// version without notice, or even be removed.
++//
++// We mean it.
++//
++
++#include "qquickwidget.h"
++#include <QtWidgets/qaccessiblewidget.h>
++
++#include <private/qaccessiblequickview_p.h>
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++// These classes implement the QQuickWiget accessibility switcharoo,
++// where the child items of the QQuickWidgetOffscreenWindow are reported
++// as child accessible interfaces of the QAccessibleQuickWidget.
++class QAccessibleQuickWidget: public QAccessibleWidget
++{
++public:
++    QAccessibleQuickWidget(QQuickWidget* widget);
++
++    QAccessibleInterface *child(int index) const override;
++    int childCount() const override;
++    int indexOfChild(const QAccessibleInterface *iface) const override;
++    QAccessibleInterface *childAt(int x, int y) const override;
++
++private:
++    QAccessibleQuickWindow m_accessibleWindow;
++    Q_DISABLE_COPY(QAccessibleQuickWidget)
++};
++
++class QAccessibleQuickWidgetOffscreenWindow: public QAccessibleQuickWindow
++{
++public:
++    QAccessibleQuickWidgetOffscreenWindow(QQuickWindow *window);
++    QAccessibleInterface *child(int index) const override;
++    int childCount() const override;
++    int indexOfChild(const QAccessibleInterface *iface) const override;
++    QAccessibleInterface *childAt(int x, int y) const override;
++};
++
++#endif // accessibility
++
++QT_END_NAMESPACE
++
++#endif
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp
+new file mode 100644
+index 0000000000..7ba88a1769
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp
+@@ -0,0 +1,60 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include "qaccessiblequickwidgetfactory_p.h"
++#include "qaccessiblequickwidget_p.h"
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleInterface *qAccessibleQuickWidgetFactory(const QString &classname, QObject *object)
++{
++    if (classname == QLatin1String("QQuickWidget")) {
++        return new QAccessibleQuickWidget(qobject_cast<QQuickWidget *>(object));
++    } else if (classname == QLatin1String("QQuickWidgetOffscreenWindow")) {
++        return new QAccessibleQuickWidgetOffscreenWindow(qobject_cast<QQuickWindow *>(object));
++    }
++    return 0;
++}
++
++#endif // accessibility
++
++QT_END_NAMESPACE
++
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h
+new file mode 100644
+index 0000000000..8c63b09f81
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h
+@@ -0,0 +1,66 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include <QtGui/qaccessible.h>
++
++#ifndef QACCESSIBLEQUICKWIDGETFACTORY_H
++#define QACCESSIBLEQUICKWIDGETFACTORY_H
++
++//
++//  W A R N I N G
++//  -------------
++//
++// This file is not part of the Qt API.  It exists purely as an
++// implementation detail.  This header file may change from version to
++// version without notice, or even be removed.
++//
++// We mean it.
++//
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleInterface *qAccessibleQuickWidgetFactory(const QString &classname, QObject *object);
++
++#endif
++
++QT_END_NAMESPACE
++
++#endif
+diff --git a/qtdeclarative/src/quickwidgets/qquickwidget.cpp b/qtdeclarative/src/quickwidgets/qquickwidget.cpp
+index 39780f8de3..9c97b43518 100644
+--- a/qtdeclarative/src/quickwidgets/qquickwidget.cpp
++++ b/qtdeclarative/src/quickwidgets/qquickwidget.cpp
+@@ -39,6 +39,7 @@
+ 
+ #include "qquickwidget.h"
+ #include "qquickwidget_p.h"
++#include "qaccessiblequickwidgetfactory_p.h"
+ 
+ #include "private/qquickwindow_p.h"
+ #include "private/qquickitem_p.h"
+@@ -75,9 +76,16 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++QQuickWidgetOffscreenWindow::QQuickWidgetOffscreenWindow(QQuickWindowPrivate &dd, QQuickRenderControl *control)
++:QQuickWindow(dd, control)
++{
++    setTitle(QString::fromLatin1("Offscreen"));
++    setObjectName(QString::fromLatin1("QQuickOffScreenWindow"));
++}
++
+ // override setVisble to prevent accidental offscreen window being created
+ // by base class.
+-class QQuickOffcreenWindowPrivate: public QQuickWindowPrivate {
++class QQuickWidgetOffscreenWindowPrivate: public QQuickWindowPrivate {
+ public:
+     void setVisible(bool visible) override {
+         Q_Q(QWindow);
+@@ -105,9 +113,8 @@ void QQuickWidgetPrivate::init(QQmlEngine* e)
+     Q_Q(QQuickWidget);
+ 
+     renderControl = new QQuickWidgetRenderControl(q);
+-    offscreenWindow = new QQuickWindow(*new QQuickOffcreenWindowPrivate(),renderControl);
+-    offscreenWindow->setTitle(QString::fromLatin1("Offscreen"));
+-    offscreenWindow->setObjectName(QString::fromLatin1("QQuickOffScreenWindow"));
++    offscreenWindow = new QQuickWidgetOffscreenWindow(*new QQuickWidgetOffscreenWindowPrivate(), renderControl);
++    offscreenWindow->setScreen(q->screen());
+     // Do not call create() on offscreenWindow.
+ 
+     // Check if the Software Adaptation is being used
+@@ -138,6 +145,10 @@ void QQuickWidgetPrivate::init(QQmlEngine* e)
+     QWidget::connect(offscreenWindow, &QQuickWindow::focusObjectChanged, q, &QQuickWidget::propagateFocusObjectChanged);
+     QObject::connect(renderControl, SIGNAL(renderRequested()), q, SLOT(triggerUpdate()));
+     QObject::connect(renderControl, SIGNAL(sceneChanged()), q, SLOT(triggerUpdate()));
++
++#if QT_CONFIG(accessibility)
++    QAccessible::installFactory(&qAccessibleQuickWidgetFactory);
++#endif
+ }
+ 
+ void QQuickWidgetPrivate::ensureEngine() const
+@@ -901,9 +912,7 @@ void QQuickWidgetPrivate::createContext()
+ 
+         context = new QOpenGLContext;
+         context->setFormat(offscreenWindow->requestedFormat());
+-        const QWindow *win = q->window()->windowHandle();
+-        if (win && win->screen())
+-            context->setScreen(win->screen());
++        context->setScreen(q->screen());
+         QOpenGLContext *shareContext = qt_gl_global_share_context();
+         if (!shareContext)
+             shareContext = QWidgetPrivate::get(q->window())->shareContext();
+@@ -1520,19 +1529,16 @@ bool QQuickWidget::event(QEvent *e)
+         d->handleWindowChange();
+         break;
+ 
+-    case QEvent::ScreenChangeInternal:
+-        if (QWindow *window = this->window()->windowHandle()) {
+-            QScreen *newScreen = window->screen();
+-
+-            if (d->offscreenWindow)
+-                d->offscreenWindow->setScreen(newScreen);
+-            if (d->offscreenSurface)
+-                d->offscreenSurface->setScreen(newScreen);
++    case QEvent::ScreenChangeInternal: {
++        QScreen *newScreen = screen();
++        if (d->offscreenWindow)
++            d->offscreenWindow->setScreen(newScreen);
++        if (d->offscreenSurface)
++            d->offscreenSurface->setScreen(newScreen);
+ #if QT_CONFIG(opengl)
+-            if (d->context)
+-                d->context->setScreen(newScreen);
++        if (d->context)
++            d->context->setScreen(newScreen);
+ #endif
+-        }
+ 
+         if (d->useSoftwareRenderer
+ #if QT_CONFIG(opengl)
+@@ -1545,7 +1551,7 @@ bool QQuickWidget::event(QEvent *e)
+             d->render(true);
+         }
+         break;
+-
++    }
+     case QEvent::Show:
+     case QEvent::Move:
+         d->updatePosition();
+diff --git a/qtdeclarative/src/quickwidgets/qquickwidget_p.h b/qtdeclarative/src/quickwidgets/qquickwidget_p.h
+index 881f7f9220..1a946bcc71 100644
+--- a/qtdeclarative/src/quickwidgets/qquickwidget_p.h
++++ b/qtdeclarative/src/quickwidgets/qquickwidget_p.h
+@@ -148,6 +148,14 @@ public:
+     bool forceFullUpdate;
+ };
+ 
++class QQuickWidgetOffscreenWindow: public QQuickWindow
++{
++    Q_OBJECT
++
++public:
++    QQuickWidgetOffscreenWindow(QQuickWindowPrivate &dd, QQuickRenderControl *control);
++};
++
+ QT_END_NAMESPACE
+ 
+ #endif // QQuickWidget_P_H
+diff --git a/qtdeclarative/src/quickwidgets/quickwidgets.pro b/qtdeclarative/src/quickwidgets/quickwidgets.pro
+index 2438e577ae..85d156b8a3 100644
+--- a/qtdeclarative/src/quickwidgets/quickwidgets.pro
++++ b/qtdeclarative/src/quickwidgets/quickwidgets.pro
+@@ -7,9 +7,13 @@ DEFINES   += QT_NO_URL_CAST_FROM_STRING QT_NO_INTEGER_EVENT_COORDINATES QT_NO_FO
+ HEADERS += \
+     qquickwidget.h \
+     qquickwidget_p.h \
+-    qtquickwidgetsglobal.h
++    qtquickwidgetsglobal.h \
++    qaccessiblequickwidget_p.h \
++    qaccessiblequickwidgetfactory_p.h
+ 
+ SOURCES += \
+-    qquickwidget.cpp
++    qquickwidget.cpp \
++    qaccessiblequickwidget.cpp \
++    qaccessiblequickwidgetfactory.cpp
+ 
+ load(qt_module)
+diff --git a/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+index 3b7d74df63..b75bf820d5 100644
+--- a/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
++++ b/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+@@ -102,6 +102,7 @@ private slots:
+     void valueConversion_RegularExpression();
+     void castWithMultipleInheritance();
+     void collectGarbage();
++    void collectGarbageNestedWrappersTwoEngines();
+     void gcWithNestedDataStructure();
+     void stacktrace();
+     void numberParsing_data();
+@@ -1809,6 +1810,44 @@ void tst_QJSEngine::collectGarbage()
+     QVERIFY(ptr.isNull());
+ }
+ 
++class TestObjectContainer : public QObject
++{
++    Q_OBJECT
++    Q_PROPERTY(QObject *dummy MEMBER m_dummy CONSTANT)
++
++public:
++    TestObjectContainer() : m_dummy(new QObject(this)) {}
++
++private:
++    QObject *m_dummy;
++};
++
++void tst_QJSEngine::collectGarbageNestedWrappersTwoEngines()
++{
++    QJSEngine engine1;
++    QJSEngine engine2;
++
++    TestObjectContainer container;
++    QQmlEngine::setObjectOwnership(&container, QQmlEngine::CppOwnership);
++
++    engine1.globalObject().setProperty("foobar", engine1.newQObject(&container));
++    engine2.globalObject().setProperty("foobar", engine2.newQObject(&container));
++
++    engine1.evaluate("foobar.dummy.baz = 42");
++    engine2.evaluate("foobar.dummy.baz = 43");
++
++    QCOMPARE(engine1.evaluate("foobar.dummy.baz").toInt(), 42);
++    QCOMPARE(engine2.evaluate("foobar.dummy.baz").toInt(), 43);
++
++    engine1.collectGarbage();
++    engine2.collectGarbage();
++
++    // The GC should not collect dummy object wrappers neither in engine1 nor engine2, we
++    // verify that by checking whether the baz property still has its previous value.
++    QCOMPARE(engine1.evaluate("foobar.dummy.baz").toInt(), 42);
++    QCOMPARE(engine2.evaluate("foobar.dummy.baz").toInt(), 43);
++}
++
+ void tst_QJSEngine::gcWithNestedDataStructure()
+ {
+     // The GC must be able to traverse deeply nested objects, otherwise this
+diff --git a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml
+new file mode 100644
+index 0000000000..206133bb39
+--- /dev/null
++++ b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml
+@@ -0,0 +1,11 @@
++import QtQuick 2.8
++
++ListView {
++    id: root
++    width: 200
++    height: 200
++
++    delegate: Text {
++        text: display
++    }
++}
+diff --git a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
+index 35f1e2c94d..1722447830 100644
+--- a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
++++ b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
+@@ -27,6 +27,8 @@
+ ****************************************************************************/
+ 
+ #include <QtTest/qtest.h>
++#include <QtCore/QConcatenateTablesProxyModel>
++#include <QtGui/QStandardItemModel>
+ #include <QtQml/qqmlcomponent.h>
+ #include <QtQmlModels/private/qqmldelegatemodel_p.h>
+ #include <QtQuick/qquickview.h>
+@@ -47,6 +49,7 @@ private slots:
+     void filterOnGroup_removeWhenCompleted();
+     void qtbug_86017();
+     void contextAccessedByHandler();
++    void redrawUponColumnChange();
+ };
+ 
+ class AbstractItemModel : public QAbstractItemModel
+@@ -186,6 +189,30 @@ void tst_QQmlDelegateModel::contextAccessedByHandler()
+     QVERIFY(root->property("works").toBool());
+ }
+ 
++void tst_QQmlDelegateModel::redrawUponColumnChange()
++{
++    QStandardItemModel m1;
++    m1.appendRow({
++            new QStandardItem("Banana"),
++            new QStandardItem("Coconut"),
++    });
++
++    QQuickView view(testFileUrl("redrawUponColumnChange.qml"));
++    QCOMPARE(view.status(), QQuickView::Ready);
++    view.show();
++    QQuickItem *root = view.rootObject();
++    root->setProperty("model", QVariant::fromValue<QObject *>(&m1));
++
++    QObject *item = root->property("currentItem").value<QObject *>();
++    QVERIFY(item);
++    QCOMPARE(item->property("text").toString(), "Banana");
++
++    QVERIFY(root);
++    m1.removeColumn(0);
++
++    QCOMPARE(item->property("text").toString(), "Coconut");
++}
++
+ QTEST_MAIN(tst_QQmlDelegateModel)
+ 
+ #include "tst_qqmldelegatemodel.moc"
+diff --git a/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp b/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
+index 5d635aa63b..824fd89e5b 100644
+--- a/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
++++ b/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
+@@ -76,10 +76,10 @@ void tst_qv4mm::multiWrappedQObjects()
+         QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 1);
+         QCOMPARE(engine2.memoryManager->m_pendingFreedObjectWrapperValue.size(), 0);
+ 
+-        // Moves the additional WeakValue from m_multiplyWrappedQObjects to
+-        // m_pendingFreedObjectWrapperValue. It's still alive after all.
++        // The additional WeakValue from m_multiplyWrappedQObjects hasn't been moved
++        // to m_pendingFreedObjectWrapperValue yet. It's still alive after all.
+         engine1.memoryManager->runGC();
+-        QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 2);
++        QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 1);
+ 
+         // engine2 doesn't own the object as engine1 was the first to wrap it above.
+         // Therefore, no effect here.
+diff --git a/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml b/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml
+new file mode 100644
+index 0000000000..889e480f3b
+--- /dev/null
++++ b/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml
+@@ -0,0 +1,13 @@
++import QtQuick 2.6
++
++Item {
++    visible: true
++    Item {
++        visible: false
++        Item {
++            objectName: "hiddenChild"
++            activeFocusOnTab: true
++            focus: true
++        }
++    }
++}
+diff --git a/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp b/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+index c8f251dbe1..c8ef36ee68 100644
+--- a/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
++++ b/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+@@ -67,6 +67,7 @@ private slots:
+     void activeFocusOnTab10();
+     void activeFocusOnTab_infiniteLoop_data();
+     void activeFocusOnTab_infiniteLoop();
++    void activeFocusOnTab_infiniteLoopControls();
+ 
+     void nextItemInFocusChain();
+     void nextItemInFocusChain2();
+@@ -1057,6 +1058,17 @@ void tst_QQuickItem::activeFocusOnTab_infiniteLoop()
+     QCOMPARE(item, window->rootObject());
+ }
+ 
++
++void tst_QQuickItem::activeFocusOnTab_infiniteLoopControls()
++{
++    auto source = testFileUrl("activeFocusOnTab_infiniteLoop3.qml");
++    QScopedPointer<QQuickView>window(new QQuickView());
++    window->setSource(source);
++    window->show();
++    QVERIFY(window->errors().isEmpty());
++    QTest::keyClick(window.get(), Qt::Key_Tab); // should not hang
++}
++
+ void tst_QQuickItem::nextItemInFocusChain()
+ {
+     if (!qt_tab_all_widgets())
+Submodule qtdoc c0c7bf07...79d6ef69:
+Submodule qtimageformats 2dcf2899..abe44c0f:
+diff --git a/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp b/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
+index dde783c..1bf9074 100644
+--- a/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
+@@ -462,8 +462,12 @@ static bool parseIconEntryInfo(ICNSEntry &icon)
+     if (isIconCompressed(icon))
+         return true;
+     // Icon depth:
+-    if (!depth.isEmpty())
+-        icon.depth = ICNSEntry::Depth(depth.toUInt());
++    if (!depth.isEmpty()) {
++        const uint depthUInt = depth.toUInt();
++        if (depthUInt > 32)
++            return false;
++        icon.depth = ICNSEntry::Depth(depthUInt);
++    }
+     // Try mono if depth not found
+     if (icon.depth == ICNSEntry::DepthUnknown)
+         icon.depth = ICNSEntry::DepthMono;
+@@ -515,6 +519,9 @@ static bool parseIconEntryInfo(ICNSEntry &icon)
+         }
+         icon.height = icon.width;
+     }
++    // Sanity check
++    if (icon.width == 0 || icon.width > 4096)
++        return false;
+     return true;
+ }
+ 
+@@ -685,7 +692,7 @@ bool QICNSHandler::canRead() const
+ bool QICNSHandler::read(QImage *outImage)
+ {
+     QImage img;
+-    if (!ensureScanned()) {
++    if (!ensureScanned() || m_currentIconIndex >= m_icons.size()) {
+         qWarning("QICNSHandler::read(): The device wasn't parsed properly!");
+         return false;
+     }
+@@ -892,7 +899,7 @@ bool QICNSHandler::scanDevice()
+             return false;
+ 
+         const qint64 blockDataOffset = device()->pos();
+-        if (!isBlockHeaderValid(blockHeader)) {
++        if (!isBlockHeaderValid(blockHeader, ICNSBlockHeaderSize + filelength - blockDataOffset)) {
+             qWarning("QICNSHandler::scanDevice(): Failed, bad header at pos %s. OSType \"%s\", length %u",
+                      QByteArray::number(blockDataOffset).constData(),
+                      nameFromOSType(blockHeader.ostype).constData(), blockHeader.length);
+@@ -927,11 +934,14 @@ bool QICNSHandler::scanDevice()
+         case ICNSBlockHeader::TypeOdrp:
+             // Icns container seems to have an embedded icon variant container
+             // Let's start a scan for entries
+-            while (device()->pos() < nextBlockOffset) {
++            while (!stream.atEnd() && device()->pos() < nextBlockOffset) {
+                 ICNSBlockHeader icon;
+                 stream >> icon;
++                if (stream.status() != QDataStream::Ok)
++                    return false;
+                 // Check for incorrect variant entry header and stop scan
+-                if (!isBlockHeaderValid(icon, blockDataLength))
++                quint64 remaining = blockDataLength - (device()->pos() - blockDataOffset);
++                if (!isBlockHeaderValid(icon, ICNSBlockHeaderSize + remaining))
+                     break;
+                 if (!addEntry(icon, device()->pos(), blockHeader.ostype))
+                     return false;
+@@ -1003,7 +1013,7 @@ bool QICNSHandler::scanDevice()
+             break;
+         }
+     }
+-    return true;
++    return (m_icons.size() > 0);
+ }
+ 
+ const ICNSEntry &QICNSHandler::getIconMask(const ICNSEntry &icon) const
+diff --git a/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp b/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
+index 5082023..cb34374 100644
+--- a/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
++++ b/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
+@@ -43,6 +43,7 @@
+ #include "qimage.h"
+ #include "qvariant.h"
+ #include "qcolor.h"
++#include "qimagereader.h"
+ 
+ #include <jasper/jasper.h>
+ #include <math.h> // for pow
+@@ -333,16 +334,46 @@ private:
+ Jpeg2000JasperReader::Jpeg2000JasperReader(QIODevice *iod, SubFormat format)
+     : jasperOk(true), ioDevice(iod), format(format), hasAlpha(false)
+ {
++#if JAS_VERSION_MAJOR < 3
+     if (jas_init()) {
+         jasperOk = false;
+         qDebug("Jasper Library initialization failed");
+     }
++#else
++    jas_conf_clear();
++#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
++    jas_conf_set_max_mem_usage(QImageReader::allocationLimit() * 1024 * 1024);
++#else
++    // 128MB seems to be enough.
++    jas_conf_set_max_mem_usage(128 * 1024 * 1024);
++#endif
++    if (jas_init_library()) {
++        jasperOk = false;
++        qDebug("Jasper library initialization failed");
++    }
++    if (jas_init_thread()) {
++        jas_cleanup_library();
++        jasperOk = false;
++        qDebug("Jasper thread initialization failed");
++    }
++#endif
+ }
+ 
+ Jpeg2000JasperReader::~Jpeg2000JasperReader()
+ {
++#if JAS_VERSION_MAJOR < 3
+     if (jasperOk)
+         jas_cleanup();
++#else
++    if (jasperOk) {
++        if (jas_cleanup_thread()) {
++            qDebug("Jasper thread cleanup failed");
++        }
++        if (jas_cleanup_library()) {
++            qDebug("Jasper library cleanup failed");
++        }
++    }
++#endif
+ }
+ 
+ /*! \internal
+@@ -857,7 +888,7 @@ bool Jpeg2000JasperReader::write(const QImage &image, int quality)
+     }
+ 
+     // Open an empty jasper stream that grows automatically
+-    jas_stream_t * memory_stream = jas_stream_memopen(0, -1);
++    jas_stream_t * memory_stream = jas_stream_memopen(0, 0);
+ 
+     // Jasper wants a non-const string.
+     char *str = qstrdup(jasperFormatString.toLatin1().constData());
+diff --git a/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp b/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
+index 1386750..ac8956c 100644
+--- a/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
+@@ -361,6 +361,8 @@ bool QTiffHandler::read(QImage *image)
+     }
+ 
+     TIFF *const tiff = d->tiff;
++    if (TIFFIsTiled(tiff) && TIFFTileSize64(tiff) > uint64_t(image->sizeInBytes())) // Corrupt image
++        return false;
+     const quint32 width = d->size.width();
+     const quint32 height = d->size.height();
+ 
+diff --git a/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp b/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
+index 82d38cb..d02eb05 100644
+--- a/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
+@@ -45,6 +45,7 @@
+ #include <qdebug.h>
+ #include <qpainter.h>
+ #include <qvariant.h>
++#include <QtEndian>
+ 
+ static const int riffHeaderSize = 12; // RIFF_HEADER_SIZE from webp/format_constants.h
+ 
+@@ -102,21 +103,23 @@ bool QWebpHandler::ensureScanned() const
+ 
+     m_scanState = ScanError;
+ 
+-    if (device()->isSequential()) {
+-        qWarning() << "Sequential devices are not supported";
++    QWebpHandler *that = const_cast<QWebpHandler *>(this);
++    const int headerBytesNeeded = sizeof(WebPBitstreamFeatures);
++    QByteArray header = device()->peek(headerBytesNeeded);
++    if (header.size() < headerBytesNeeded)
+         return false;
+-    }
+ 
+-    qint64 oldPos = device()->pos();
+-    device()->seek(0);
+-
+-    QWebpHandler *that = const_cast<QWebpHandler *>(this);
+-    QByteArray header = device()->peek(sizeof(WebPBitstreamFeatures));
++    // We do no random access during decoding, just a readAll() of the whole image file. So if
++    // if it is all available already, we can accept a sequential device. The riff header contains
++    // the file size minus 8 bytes header
++    qint64 byteSize = qFromLittleEndian<quint32>(header.constData() + 4);
++    if (device()->isSequential() && device()->bytesAvailable() < byteSize + 8) {
++        qWarning() << "QWebpHandler: Insufficient data available in sequential device";
++        return false;
++    }
+     if (WebPGetFeatures((const uint8_t*)header.constData(), header.size(), &(that->m_features)) == VP8_STATUS_OK) {
+         if (m_features.has_animation) {
+             // For animation, we have to read and scan whole file to determine loop count and images count
+-            device()->seek(oldPos);
+-
+             if (that->ensureDemuxer()) {
+                 that->m_loop = WebPDemuxGetI(m_demuxer, WEBP_FF_LOOP_COUNT);
+                 that->m_frameCount = WebPDemuxGetI(m_demuxer, WEBP_FF_FRAME_COUNT);
+@@ -126,17 +129,13 @@ bool QWebpHandler::ensureScanned() const
+                 if (that->m_features.has_alpha)
+                     that->m_composited->fill(Qt::transparent);
+ 
+-                // We do not reset device position since we have read in all data
+                 m_scanState = ScanSuccess;
+-                return true;
+             }
+         } else {
+             m_scanState = ScanSuccess;
+         }
+     }
+ 
+-    device()->seek(oldPos);
+-
+     return m_scanState == ScanSuccess;
+ }
+ 
+@@ -159,7 +158,7 @@ bool QWebpHandler::ensureDemuxer()
+ 
+ bool QWebpHandler::read(QImage *image)
+ {
+-    if (!ensureScanned() || device()->isSequential() || !ensureDemuxer())
++    if (!ensureScanned() || !ensureDemuxer())
+         return false;
+ 
+     QRect prevFrameRect;
+Submodule qtlocation 98a5c511..f991e28c:
+diff --git a/qtlocation/src/location/configure.json b/qtlocation/src/location/configure.json
+index 6d01a9a3..d1e623a1 100644
+--- a/qtlocation/src/location/configure.json
++++ b/qtlocation/src/location/configure.json
+@@ -9,7 +9,7 @@
+             "label": "Qt.labs.location experimental QML plugin",
+             "purpose": "Provides experimental QtLocation QML types",
+             "section": "Location",
+-            "condition": "config.opengl",
++            "condition": "features.opengl",
+             "output": [ "privateFeature" ]
+         },
+         "geoservices_osm": {
+diff --git a/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp b/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
+index a978573d..11e1466f 100644
+--- a/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
++++ b/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
+@@ -158,7 +158,7 @@ void QGeoMapObjectQSGSupport::updateMapObjects(QSGNode *root, QQuickWindow *wind
+     if (!root)
+         return;
+ 
+-    if (m_mapObjectsRootNode && m_mapObjectsRootNode->parent())
++    if (m_mapObjectsRootNode && !m_mapObjectsRootNode->parent())
+         root->appendChildNode(m_mapObjectsRootNode.get());
+ 
+     if (!m_mapObjectsRootNode) {
+diff --git a/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
+index 5a40467e..d123c6a8 100644
+--- a/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
+@@ -59,8 +59,10 @@ QT_BEGIN_NAMESPACE
+ static const QString kPrefixEsri(QStringLiteral("esri."));
+ static const QString kParamUserAgent(kPrefixEsri + QStringLiteral("useragent"));
+ 
+-static const QString kUrlGeocode(QStringLiteral("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates"));
+-static const QString kUrlReverseGeocode(QStringLiteral("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode"));
++static const QString kUrlGeocode(QStringLiteral("https://geocode.arcgis.com/arcgis/rest/services/"
++                                                "World/GeocodeServer/findAddressCandidates"));
++static const QString kUrlReverseGeocode(QStringLiteral(
++        "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode"));
+ 
+ static QString addressToQuery(const QGeoAddress &address)
+ {
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
+index 17492d94..96c12b1b 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
+@@ -46,7 +46,8 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-// JSON reference: http://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
++// JSON reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
+ 
+ static const QString kErrorMessage(QStringLiteral("Error %1: %2."));
+ static const QString kErrorJson(QStringLiteral("Error: invalide JSON document."));
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
+index 8cadfb29..92b6bb13 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
+@@ -44,7 +44,8 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-// JSON reference: http://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
++// JSON reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
+ 
+ GeoRouteReplyEsri::GeoRouteReplyEsri(QNetworkReply *reply, const QGeoRouteRequest &request,
+                                      QObject *parent) :
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
+index 0e6bc2c7..ed613f4b 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
+@@ -48,7 +48,8 @@ static const QString kPrefixEsri(QStringLiteral("esri."));
+ static const QString kParamUserAgent(kPrefixEsri + QStringLiteral("useragent"));
+ static const QString kParamToken(kPrefixEsri + QStringLiteral("token"));
+ 
+-static const QString kUrlRouting(QStringLiteral("http://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve"));
++static const QString kUrlRouting(QStringLiteral(
++        "https://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve"));
+ 
+ GeoRoutingManagerEngineEsri::GeoRoutingManagerEngineEsri(const QVariantMap &parameters,
+                                                          QGeoServiceProvider::Error *error,
+@@ -70,7 +71,8 @@ GeoRoutingManagerEngineEsri::~GeoRoutingManagerEngineEsri()
+ {
+ }
+ 
+-// REST reference: http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
++// REST reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
+ 
+ QGeoRouteReply *GeoRoutingManagerEngineEsri::calculateRoute(const QGeoRouteRequest &request)
+ {
+@@ -125,7 +127,7 @@ void GeoRoutingManagerEngineEsri::replyError(QGeoRouteReply::Error errorCode, co
+ QString GeoRoutingManagerEngineEsri::preferedDirectionLangage()
+ {
+     // list of supported langages is defined in:
+-    // http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
++    // https://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
+     const QStringList supportedLanguages = {
+         "ar", // Generate directions in Arabic
+         "cs", // Generate directions in Czech
+diff --git a/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
+index 5d15835d..24148f95 100644
+--- a/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
+@@ -230,7 +230,8 @@ QGeoMap *GeoTiledMappingManagerEngineEsri::createMap()
+ // ${y} = Y
+ // ${token} = Token
+ 
+-// template = 'http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{{z}}/{{y}}/{{x}}.png'
++// template =
++// 'https://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{{z}}/{{y}}/{{x}}.png'
+ 
+ bool GeoTiledMappingManagerEngineEsri::initializeMapSources(QGeoServiceProvider::Error *error,
+                                                             QString *errorString,
+diff --git a/qtlocation/src/plugins/geoservices/esri/maps.json b/qtlocation/src/plugins/geoservices/esri/maps.json
+index 8167ae7d..862e087d 100644
+--- a/qtlocation/src/plugins/geoservices/esri/maps.json
++++ b/qtlocation/src/plugins/geoservices/esri/maps.json
+@@ -6,8 +6,8 @@
+             "description": "ArcGIS Online World Street Map",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=3b93337983e9436f8db950e38a8629af'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=3b93337983e9436f8db950e38a8629af'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -16,8 +16,8 @@
+             "": "ArcGIS Online World Imagery",
+             "mobile": true,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -26,8 +26,8 @@
+             "description": "ArcGIS Online World Terrain Base",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=c61ad8ab017d49e1a82f580ee1298931'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=c61ad8ab017d49e1a82f580ee1298931'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -36,8 +36,8 @@
+             "description": "ArcGIS Online World Topography",
+             "mobile": true,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=30e5fe3149c34df1ba922e6f5bbf808f'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=30e5fe3149c34df1ba922e6f5bbf808f'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -46,8 +46,8 @@
+             "description": "This map presents land cover and detailed topographic maps for the United States.",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=99cd5fbd98934028802b4f797c4b1732'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=99cd5fbd98934028802b4f797c4b1732'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -56,8 +56,8 @@
+             "description": "National Geographic World Map",
+             "mobile": false,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=b9b1b422198944fbbd5250b3241691b6'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=b9b1b422198944fbbd5250b3241691b6'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -66,8 +66,8 @@
+             "description": "Thematic content providing a neutral background with minimal colors",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=ed712cb1db3e4bae9e85329040fb9a49'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=ed712cb1db3e4bae9e85329040fb9a49'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -76,8 +76,8 @@
+             "description": "Natural Earth physical map for the world",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=c4ec722a1cd34cf0a23904aadf8923a0'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=c4ec722a1cd34cf0a23904aadf8923a0'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -86,8 +86,8 @@
+             "description": "Portrays surface elevation as shaded relief",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=9c5370d0b54f4de1b48a3792d7377ff2'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=9c5370d0b54f4de1b48a3792d7377ff2'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -96,8 +96,8 @@
+             "description": "This map is designed to be used as a basemap by marine GIS professionals and as a reference map by anyone interested in ocean data",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=1e126e7520f9466c9ca28b8f28b5e500'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=1e126e7520f9466c9ca28b8f28b5e500'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -106,8 +106,8 @@
+             "description": "Thematic content providing a neutral background with minimal colors",
+             "mobile": false,
+             "night": true,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=a284a9b99b3446a3910d4144a50990f6'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=a284a9b99b3446a3910d4144a50990f6'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -116,8 +116,8 @@
+             "description": "DeLorme’s topographic basemap is a seamless global data set that portrays transportation, hydrography, jurisdiction boundaries, and major geographic features",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/Specialty/DeLorme_World_Base_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=b165c3df453e4be6b5ac4fdb241effbe'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/Specialty/DeLorme_World_Base_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=b165c3df453e4be6b5ac4fdb241effbe'>Esri</a> contributors"
+         }
+     ]
+ }
+diff --git a/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
+index 3858ddf5..af66f28e 100644
+--- a/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
+@@ -63,8 +63,10 @@ static const QString kCountriesKey(QStringLiteral("detailedCountries"));
+ static const QString kLocalizedNamesKey(QStringLiteral("localizedNames"));
+ static const QString kMaxLocationsKey(QStringLiteral("maxLocations"));
+ 
+-static const QUrl kUrlGeocodeServer("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer?f=pjson");
+-static const QUrl kUrlFindAddressCandidates("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates");
++static const QUrl kUrlGeocodeServer(
++        "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer?f=pjson");
++static const QUrl kUrlFindAddressCandidates("https://geocode.arcgis.com/arcgis/rest/services/World/"
++                                            "GeocodeServer/findAddressCandidates");
+ 
+ PlaceManagerEngineEsri::PlaceManagerEngineEsri(const QVariantMap &parameters, QGeoServiceProvider::Error *error,
+                                                QString *errorString) :
+Submodule qtmultimedia f0344079..0d7cc33a:
+diff --git a/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp b/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
+index 2b5325132..b68b4af1b 100644
+--- a/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
++++ b/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
+@@ -402,6 +402,8 @@ int QPulseAudioInput::bytesReady() const
+ 
+ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ {
++    Q_ASSERT(data != nullptr || len == 0);
++
+     m_bytesAvailable = checkBytesReady();
+ 
+     setError(QAudio::NoError);
+@@ -411,7 +413,8 @@ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ 
+     if (!m_pullMode && !m_tempBuffer.isEmpty()) {
+         readBytes = qMin(static_cast<int>(len), m_tempBuffer.size());
+-        memcpy(data, m_tempBuffer.constData(), readBytes);
++        if (readBytes)
++            memcpy(data, m_tempBuffer.constData(), readBytes);
+         m_totalTimeValue += readBytes;
+ 
+         if (readBytes < m_tempBuffer.size()) {
+@@ -502,9 +505,10 @@ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ 
+ void QPulseAudioInput::applyVolume(const void *src, void *dest, int len)
+ {
++    Q_ASSERT((src && dest) || len == 0);
+     if (m_volume < 1.f)
+         QAudioHelperInternal::qMultiplySamples(m_volume, m_format, src, dest, len);
+-    else
++    else if (len)
+         memcpy(dest, src, len);
+ }
+ 
+Submodule qtpim 02efef5e...f9a8f0fc (commits not present)
+Submodule qtquick3d b85cf622..47defc8b:
+diff --git a/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro b/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
+index ca5c499e..174a075b 100644
+--- a/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
++++ b/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
+@@ -10,7 +10,7 @@ QT_FOR_CONFIG += assetimporters-private
+ include($$OUT_PWD/../qtassetimporters-config.pri)
+ 
+ qtConfig(system-assimp):!if(cross_compile:host_build) {
+-    QMAKE_USE_PRIVATE += assimp
++    QMAKE_USE_PRIVATE += quick3d-assimp
+ } else {
+     include(../../../3rdparty/assimp/assimp.pri)
+ }
+Submodule qtquickcontrols2 3a657dc0..56ce8233:
+diff --git a/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp b/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
+index e5fe734f7..e36922775 100644
+--- a/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
++++ b/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
+@@ -38,6 +38,7 @@
+ #include "qwidgetplatformmenuitem_p.h"
+ 
+ #include <QtGui/qwindow.h>
++#include <QtGui/private/qhighdpiscaling_p.h>
+ #include <QtWidgets/qmenu.h>
+ #include <QtWidgets/qaction.h>
+ 
+@@ -145,7 +146,7 @@ void QWidgetPlatformMenu::showPopup(const QWindow *window, const QRect &targetRe
+ 
+     QPoint targetPos = targetRect.bottomLeft();
+     if (window)
+-        targetPos = window->mapToGlobal(targetPos);
++        targetPos = window->mapToGlobal(QHighDpi::fromNativeLocalPosition(targetPos, window));
+ 
+     const QWidgetPlatformMenuItem *widgetItem = qobject_cast<const QWidgetPlatformMenuItem *>(item);
+     m_menu->popup(targetPos, widgetItem ? widgetItem->action() : nullptr);
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
+index 950e4e099..b81fbea0b 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
+@@ -387,6 +387,17 @@ void QQuickAbstractButtonPrivate::itemImplicitHeightChanged(QQuickItem *item)
+         emit q->implicitIndicatorHeightChanged();
+ }
+ 
++void QQuickAbstractButtonPrivate::itemDestroyed(QQuickItem *item)
++{
++    Q_Q(QQuickAbstractButton);
++    QQuickControlPrivate::itemDestroyed(item);
++    if (item == indicator) {
++        indicator = nullptr;
++        emit q->implicitIndicatorWidthChanged();
++        emit q->implicitIndicatorHeightChanged();
++    }
++}
++
+ QQuickAbstractButton *QQuickAbstractButtonPrivate::findCheckedButton() const
+ {
+     Q_Q(const QQuickAbstractButton);
+@@ -1176,6 +1187,12 @@ QAccessible::Role QQuickAbstractButton::accessibleRole() const
+     }
+     return QAccessible::Button;
+ }
++
++void QQuickAbstractButton::accessiblePressAction()
++{
++    Q_D(QQuickAbstractButton);
++    d->trigger();
++}
+ #endif
+ 
+ QT_END_NAMESPACE
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
+index 0fa48980e..ab66220d0 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
+@@ -209,6 +209,7 @@ protected:
+ #if QT_CONFIG(accessibility)
+     void accessibilityActiveChanged(bool active) override;
+     QAccessible::Role accessibleRole() const override;
++    Q_INVOKABLE void accessiblePressAction();
+ #endif
+ 
+ private:
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
+index 9291c1a87..b729720f2 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
+@@ -109,6 +109,7 @@ public:
+ 
+     void itemImplicitWidthChanged(QQuickItem *item) override;
+     void itemImplicitHeightChanged(QQuickItem *item) override;
++    void itemDestroyed(QQuickItem *item) override;
+ 
+     // copied from qabstractbutton.cpp
+     static const int AUTO_REPEAT_DELAY = 300;
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp b/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
+index 2041e7741..8610cdfae 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
+@@ -145,7 +145,7 @@ int QQuickActionPrivate::ShortcutEntry::shortcutId() const
+ 
+ void QQuickActionPrivate::ShortcutEntry::grab(const QKeySequence &shortcut, bool enabled)
+ {
+-    if (shortcut.isEmpty())
++    if (shortcut.isEmpty() || m_shortcutId)
+         return;
+ 
+     Qt::ShortcutContext context = Qt::WindowShortcut; // TODO
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp b/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
+index f38c2b09c..6eed2a024 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
+@@ -225,6 +225,7 @@ void QQuickContainerPrivate::cleanup()
+     QObject::disconnect(contentModel, &QQmlObjectModel::countChanged, q, &QQuickContainer::countChanged);
+     QObject::disconnect(contentModel, &QQmlObjectModel::childrenChanged, q, &QQuickContainer::contentChildrenChanged);
+     delete contentModel;
++    contentModel = nullptr;
+ }
+ 
+ QQuickItem *QQuickContainerPrivate::itemAt(int index) const
+@@ -436,7 +437,7 @@ void QQuickContainerPrivate::contentChildren_clear(QQmlListProperty<QQuickItem>
+ void QQuickContainerPrivate::updateContentWidth()
+ {
+     Q_Q(QQuickContainer);
+-    if (hasContentWidth || qFuzzyCompare(contentWidth, implicitContentWidth))
++    if (hasContentWidth || qFuzzyCompare(contentWidth, implicitContentWidth) || !contentModel)
+         return;
+ 
+     contentWidth = implicitContentWidth;
+@@ -446,7 +447,7 @@ void QQuickContainerPrivate::updateContentWidth()
+ void QQuickContainerPrivate::updateContentHeight()
+ {
+     Q_Q(QQuickContainer);
+-    if (hasContentHeight || qFuzzyCompare(contentHeight, implicitContentHeight))
++    if (hasContentHeight || qFuzzyCompare(contentHeight, implicitContentHeight) || !contentModel)
+         return;
+ 
+     contentHeight = implicitContentHeight;
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp b/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
+index bbbd0e622..1f4b47343 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
+@@ -845,6 +845,13 @@ void QQuickControlPrivate::executeBackground(bool complete)
+         quickCompleteDeferred(q, backgroundName(), background);
+ }
+ 
++/*
++    \internal
++
++    Hides an item that was replaced by a newer one, rather than
++    deleting it, as the item is typically created in QML and hence
++    we don't own it.
++*/
+ void QQuickControlPrivate::hideOldItem(QQuickItem *item)
+ {
+     if (!item)
+@@ -863,6 +870,29 @@ void QQuickControlPrivate::hideOldItem(QQuickItem *item)
+ #endif
+ }
+ 
++/*
++    \internal
++
++    Named "unhide" because it's used for cases where an item
++    that was previously hidden by \l hideOldItem() wants to be
++    shown by a control again, such as a ScrollBar in ScrollView.
++*/
++void QQuickControlPrivate::unhideOldItem(QQuickControl *control, QQuickItem *item)
++{
++    Q_ASSERT(item);
++    qCDebug(lcItemManagement) << "unhiding old item" << item;
++
++    item->setVisible(true);
++    item->setParentItem(control);
++
++#if QT_CONFIG(accessibility)
++    // Add the item back in to the accessibility tree.
++    QQuickAccessibleAttached *accessible = accessibleAttached(item);
++    if (accessible)
++        accessible->setIgnored(false);
++#endif
++}
++
+ void QQuickControlPrivate::updateBaselineOffset()
+ {
+     Q_Q(QQuickControl);
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h b/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
+index 8e979079e..a6e624c91 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
+@@ -173,6 +173,7 @@ public:
+     virtual void executeBackground(bool complete = false);
+ 
+     static void hideOldItem(QQuickItem *item);
++    static void unhideOldItem(QQuickControl *control, QQuickItem *item);
+ 
+     void updateBaselineOffset();
+ 
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp b/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
+index e6db14eb5..6197d1547 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
+@@ -237,7 +237,7 @@ static QRectF alignedRect(Qt::LayoutDirection direction, Qt::Alignment alignment
+ void QQuickDialogButtonBoxPrivate::resizeContent()
+ {
+     Q_Q(QQuickDialogButtonBox);
+-    if (!contentItem)
++    if (!contentItem || !contentModel)
+         return;
+ 
+     QRectF geometry = q->boundingRect().adjusted(q->leftPadding(), q->topPadding(), -q->rightPadding(), -q->bottomPadding());
+@@ -322,6 +322,9 @@ void QQuickDialogButtonBoxPrivate::updateLayout()
+ qreal QQuickDialogButtonBoxPrivate::getContentWidth() const
+ {
+     Q_Q(const QQuickDialogButtonBox);
++    if (!contentModel)
++        return 0;
++
+     const int count = contentModel->count();
+     const qreal totalSpacing = qMax(0, count - 1) * spacing;
+     qreal totalWidth = totalSpacing;
+@@ -341,6 +344,9 @@ qreal QQuickDialogButtonBoxPrivate::getContentWidth() const
+ qreal QQuickDialogButtonBoxPrivate::getContentHeight() const
+ {
+     Q_Q(const QQuickDialogButtonBox);
++    if (!contentModel)
++        return 0;
++
+     const int count = contentModel->count();
+     qreal maxHeight = 0;
+     for (int i = 0; i < count; ++i) {
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp b/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
+index 91bd59184..0ce518f84 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
+@@ -399,8 +399,11 @@ void QQuickOverlay::itemChange(ItemChange change, const ItemChangeData &data)
+     Q_D(QQuickOverlay);
+     QQuickItem::itemChange(change, data);
+ 
+-    if (change == ItemChildAddedChange || change == ItemChildRemovedChange)
++    if (change == ItemChildAddedChange || change == ItemChildRemovedChange) {
+         setVisible(!d->allDrawers.isEmpty() || !childItems().isEmpty());
++        if (data.item->parent() == d->mouseGrabberPopup)
++            d->setMouseGrabberPopup(nullptr);
++    }
+ }
+ 
+ void QQuickOverlay::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp b/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
+index 4e2f509db..1c4b308cd 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
+@@ -797,6 +797,14 @@ void QQuickScrollBarAttachedPrivate::initHorizontal()
+     if (parent && parent == flickable->parentItem())
+         horizontal->stackAfter(flickable);
+ 
++    // If a scroll bar was previously hidden (due to e.g. setting a new contentItem
++    // on a ScrollView), we need to make sure that we un-hide it.
++    // We don't bother checking if the item is actually the old one, because
++    // if it's not, all of the things the function does (setting parent, visibility, etc.)
++    // should be no-ops anyway.
++    if (auto control = qobject_cast<QQuickControl*>(q_ptr->parent()))
++        QQuickControlPrivate::unhideOldItem(control, horizontal);
++
+     layoutHorizontal();
+     horizontal->setSize(area->property("widthRatio").toReal());
+     horizontal->setPosition(area->property("xPosition").toReal());
+@@ -818,6 +826,9 @@ void QQuickScrollBarAttachedPrivate::initVertical()
+     if (parent && parent == flickable->parentItem())
+         vertical->stackAfter(flickable);
+ 
++    if (auto control = qobject_cast<QQuickControl*>(q_ptr->parent()))
++        QQuickControlPrivate::unhideOldItem(control, vertical);
++
+     layoutVertical();
+     vertical->setSize(area->property("heightRatio").toReal());
+     vertical->setPosition(area->property("yPosition").toReal());
+diff --git a/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml b/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
+index 0e8b08352..cd4931184 100644
+--- a/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
++++ b/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
+@@ -576,4 +576,51 @@ TestCase {
+         verify(newHorizontalScrollBar.visible)
+         verify(!oldHorizontalScrollBar.visible)
+     }
++
++    Component {
++        id: bindingToContentItemAndStandaloneFlickable
++
++        Item {
++            width: 200
++            height: 200
++
++            property alias scrollView: scrollView
++
++            ScrollView {
++                id: scrollView
++                anchors.fill: parent
++                contentItem: listView
++
++                property Item someBinding: contentItem
++            }
++            ListView {
++                id: listView
++                model: 10
++                delegate: ItemDelegate {
++                    text: modelData
++                    width: listView.width
++                }
++            }
++        }
++    }
++
++    // Tests that scroll bars show up for a ScrollView where
++    // - its contentItem is declared as a standalone, separate item
++    // - there is a binding to contentItem (which causes a default Flickable to be created)
++    function test_bindingToContentItemAndStandaloneFlickable() {
++        let root = createTemporaryObject(bindingToContentItemAndStandaloneFlickable, testCase)
++        verify(root)
++
++        let control = root.scrollView
++        let verticalScrollBar = control.ScrollBar.vertical
++        let horizontalScrollBar = control.ScrollBar.horizontal
++        compare(verticalScrollBar.parent, control)
++        compare(horizontalScrollBar.parent, control)
++        verify(verticalScrollBar.visible)
++        verify(horizontalScrollBar.visible)
++
++        mouseDrag(verticalScrollBar, verticalScrollBar.width / 2, verticalScrollBar.height / 2, 0, 50)
++        verify(verticalScrollBar.active)
++        verify(horizontalScrollBar.active)
++    }
+ }
+diff --git a/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml b/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
+index b3fab41ca..10b6baa02 100644
+--- a/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
++++ b/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
+@@ -608,4 +608,27 @@ TestCase {
+         mouseClick(control.indicator)
+         verify(control.activeFocus)
+     }
++
++    Component {
++        id: deletionOrder1
++        Item {
++            Image { id: innerImage }
++            Switch { indicator: innerImage }
++        }
++    }
++
++    Component {
++        id: deletionOrder2
++        Item {
++            Switch { indicator: innerImage }
++            Image { id: innerImage }
++        }
++    }
++
++    function test_deletionOrder() {
++        var control1 = createTemporaryObject(deletionOrder1, testCase)
++        verify(control1)
++        var control2 = createTemporaryObject(deletionOrder2, testCase)
++        verify(control2)
++    }
+ }
+diff --git a/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml b/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml
+new file mode 100644
+index 000000000..9e4598b9f
+--- /dev/null
++++ b/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml
+@@ -0,0 +1,78 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the test suite of the Qt Toolkit.
++**
++** $QT_BEGIN_LICENSE:BSD$
++** Commercial License Usage
++** Licensees holding valid commercial Qt licenses may use this file in
++** accordance with the commercial license agreement provided with the
++** Software or, alternatively, in accordance with the terms contained in
++** a written agreement between you and The Qt Company. For licensing terms
++** and conditions see https://www.qt.io/terms-conditions. For further
++** information use the contact form at https://www.qt.io/contact-us.
++**
++** BSD License Usage
++** Alternatively, you may use this file under the terms of the BSD license
++** as follows:
++**
++** "Redistribution and use in source and binary forms, with or without
++** modification, are permitted provided that the following conditions are
++** met:
++**   * Redistributions of source code must retain the above copyright
++**     notice, this list of conditions and the following disclaimer.
++**   * Redistributions in binary form must reproduce the above copyright
++**     notice, this list of conditions and the following disclaimer in
++**     the documentation and/or other materials provided with the
++**     distribution.
++**   * Neither the name of The Qt Company Ltd nor the names of its
++**     contributors may be used to endorse or promote products derived
++**     from this software without specific prior written permission.
++**
++**
++** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
++** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
++** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
++** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
++** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
++** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
++** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
++** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
++** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
++** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
++** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
++**
++** $QT_END_LICENSE$
++**
++****************************************************************************/
++
++import QtQuick 2.15
++import QtQuick.Controls 2.15
++
++ApplicationWindow {
++    id: window
++    width: 400
++    height: 400
++    title: "releaseAfterExitTransition"
++
++    property alias popup: popup
++    property alias modalPopup: modalPopup
++
++    Popup {
++        id: popup
++        y: parent.height - height
++        width: 50
++        height: 50
++    }
++
++    Popup {
++        id: modalPopup
++        modal: true
++        y: parent.height - height
++        width: 50
++        height: 50
++        exit:  Transition { PauseAnimation { duration: 100 } }
++    }
++}
+diff --git a/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp b/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
+index 54952d128..3d50e2dd4 100644
+--- a/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
++++ b/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
+@@ -100,6 +100,7 @@ private slots:
+     void invisibleToolTipOpen();
+     void centerInOverlayWithinStackViewItem();
+     void destroyDuringExitTransition();
++    void releaseAfterExitTransition();
+ };
+ 
+ void tst_QQuickPopup::initTestCase()
+@@ -1575,6 +1576,34 @@ void tst_QQuickPopup::destroyDuringExitTransition()
+     QVERIFY(!button->isDown());
+ }
+ 
++void tst_QQuickPopup::releaseAfterExitTransition()
++{
++    QQuickApplicationHelper helper(this, "releaseAfterExitTransition.qml");
++    QVERIFY2(helper.ready, helper.failureMessage());
++
++    QQuickWindow *window = helper.window;
++    window->show();
++    QVERIFY(QTest::qWaitForWindowActive(window));
++
++    QQuickOverlay *overlay = QQuickOverlay::overlay(window);
++    QQuickPopup *modalPopup = window->property("modalPopup").value<QQuickPopup *>();
++    QQuickPopup *popup = window->property("popup").value<QQuickPopup *>();
++
++    modalPopup->open();
++    QTRY_VERIFY(modalPopup->isOpened());
++
++    QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++    // wait until the transition is finished and the overlay hides itself
++    QTRY_VERIFY(!overlay->isVisible());
++    QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++
++    popup->open();
++    QTRY_VERIFY(popup->isOpened());
++    QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++    QTRY_VERIFY(!popup->isOpened());
++}
++
++
+ QTEST_QUICKCONTROLS_MAIN(tst_QQuickPopup)
+ 
+ #include "tst_qquickpopup.moc"
+Submodule qtscript 5be95f96...4d8e4bd2 (commits not present)
+Submodule qtspeech 17fc9fde..255845e2:
+diff --git a/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp b/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
+index 6eb74b8..bcc7dd1 100644
+--- a/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
++++ b/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
+@@ -357,7 +357,9 @@ QVector<QLocale> QTextToSpeechEngineSpeechd::availableLocales() const
+ 
+ QVector<QVoice> QTextToSpeechEngineSpeechd::availableVoices() const
+ {
+-    return m_voices.values(m_currentLocale.name()).toVector();
++    QList<QVoice> resultList = m_voices.values(m_currentLocale.name());
++    std::reverse(resultList.begin(), resultList.end());
++    return resultList.toVector();
+ }
+ 
+ // We have no way of knowing our own client_id since speech-dispatcher seems to be incomplete
+Submodule qtsvg 0c05780e..a7a0f249:
+diff --git a/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp b/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
+index 561e77e..12e0574 100644
+--- a/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
++++ b/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
+@@ -191,6 +191,8 @@ bool QSvgIOHandler::read(QImage *image)
+             }
+         }
+         if (!finalSize.isEmpty()) {
++            if (qMax(finalSize.width(), finalSize.height()) > 0xffff)
++                return false; // Assume corrupted file
+             image->fill(d->backColor.rgba());
+             QPainter p(image);
+             d->r.render(&p, bounds);
+diff --git a/qtsvg/src/svg/qsvghandler.cpp b/qtsvg/src/svg/qsvghandler.cpp
+index a5f877f..8dda563 100644
+--- a/qtsvg/src/svg/qsvghandler.cpp
++++ b/qtsvg/src/svg/qsvghandler.cpp
+@@ -1393,9 +1393,10 @@ static void parseFont(QSvgNode *node,
+         case FontSizeNone:
+             break;
+         case FontSizeValue: {
+-            QSvgHandler::LengthType dummy; // should always be pixel size
+-            fontStyle->setSize(qMin(parseLength(attributes.fontSize, dummy, handler),
+-                                    qreal(0xffff)));
++            QSvgHandler::LengthType type;
++            qreal fs = parseLength(attributes.fontSize, type, handler);
++            fs = convertToPixels(fs, true, type);
++            fontStyle->setSize(qMin(fs, qreal(0xffff)));
+         }
+             break;
+         default:
+@@ -2513,6 +2514,8 @@ static bool parseAnimateTransformNode(QSvgNode *parent,
+             ++s;
+         }
+     }
++    if (vals.count() % 3 != 0)
++        return false;
+ 
+     bool ok = true;
+     int begin = parseClockValue(beginStr, &ok);
+@@ -2576,6 +2579,8 @@ static QSvgNode *createCircleNode(QSvgNode *parent,
+     qreal ncx = toDouble(cx);
+     qreal ncy = toDouble(cy);
+     qreal nr  = toDouble(r);
++    if (nr < 0.0)
++        return nullptr;
+ 
+     QRectF rect(ncx-nr, ncy-nr, nr*2, nr*2);
+     QSvgNode *circle = new QSvgCircle(parent, rect);
+@@ -3046,15 +3051,16 @@ static QSvgStyleProperty *createRadialGradientNode(QSvgNode *node,
+ 
+     qreal ncx = 0.5;
+     qreal ncy = 0.5;
+-    qreal nr  = 0.5;
+     if (!cx.isEmpty())
+         ncx = toDouble(cx);
+     if (!cy.isEmpty())
+         ncy = toDouble(cy);
++
++    qreal nr = 0.0;
+     if (!r.isEmpty())
+         nr = toDouble(r);
+-    if (nr < 0.5)
+-        nr = 0.5;
++    if (nr <= 0.0)
++        return nullptr;
+ 
+     qreal nfx = ncx;
+     if (!fx.isEmpty())
+@@ -3350,7 +3356,9 @@ static QSvgNode *createTextNode(QSvgNode *parent,
+     //### editable and rotate not handled
+     QSvgHandler::LengthType type;
+     qreal nx = parseLength(x, type, handler);
++    nx = convertToPixels(nx, true, type);
+     qreal ny = parseLength(y, type, handler);
++    ny = convertToPixels(ny, true, type);
+ 
+     QSvgNode *text = new QSvgText(parent, QPointF(nx, ny));
+     return text;
+@@ -3691,9 +3699,7 @@ void QSvgHandler::parse()
+         case QXmlStreamReader::EndElement:
+             endElement(xml->name());
+             ++remainingUnfinishedElements;
+-            // if we are using somebody else's qxmlstreamreader
+-            // we should not read until the end of the stream
+-            done = !m_ownsReader && (xml->name() == QLatin1String("svg"));
++            done = (xml->name() == QLatin1String("svg"));
+             break;
+         case QXmlStreamReader::Characters:
+             characters(xml->text());
+diff --git a/qtsvg/src/svg/qsvgstructure.cpp b/qtsvg/src/svg/qsvgstructure.cpp
+index b89608b..89c9e4e 100644
+--- a/qtsvg/src/svg/qsvgstructure.cpp
++++ b/qtsvg/src/svg/qsvgstructure.cpp
+@@ -255,9 +255,13 @@ inline static bool isSupportedSvgFeature(const QString &str)
+     };
+ 
+     if (str.length() <= MAX_WORD_LENGTH && str.length() >= MIN_WORD_LENGTH) {
++        const char16_t unicode44 = str.at(44).unicode();
++        const char16_t unicode45 = str.at(45).unicode();
++        if (unicode44 >= sizeof(asso_values) || unicode45 >= sizeof(asso_values))
++            return false;
+         const int key = str.length()
+-                        + asso_values[str.at(45).unicode()]
+-                        + asso_values[str.at(44).unicode()];
++                        + asso_values[unicode45]
++                        + asso_values[unicode44];
+         if (key <= MAX_HASH_VALUE && key >= 0)
+             return str == QLatin1String(wordlist[key]);
+     }
+diff --git a/qtsvg/src/svg/qsvgtinydocument.cpp b/qtsvg/src/svg/qsvgtinydocument.cpp
+index 63d0797..19e7154 100644
+--- a/qtsvg/src/svg/qsvgtinydocument.cpp
++++ b/qtsvg/src/svg/qsvgtinydocument.cpp
+@@ -433,8 +433,16 @@ void QSvgTinyDocument::draw(QPainter *p, QSvgExtraStates &)
+     draw(p);
+ }
+ 
++static bool isValidMatrix(const QTransform &transform)
++{
++    qreal determinant = transform.determinant();
++    return qIsFinite(determinant);
++}
++
+ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect, const QRectF &sourceRect)
+ {
++    QTransform oldTransform = p->worldTransform();
++
+     QRectF target = targetRect;
+     if (target.isEmpty()) {
+         QPaintDevice *dev = p->device();
+@@ -487,6 +495,9 @@ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect,
+         }
+ #endif
+     }
++
++    if (!isValidMatrix(p->worldTransform()))
++        p->setWorldTransform(oldTransform);
+ }
+ 
+ QRectF QSvgTinyDocument::boundsOnElement(const QString &id) const
+diff --git a/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp b/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
+index 36c76ec..db71e02 100644
+--- a/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
++++ b/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
+@@ -86,6 +86,8 @@ private slots:
+     void oss_fuzz_23731();
+     void oss_fuzz_24131();
+     void oss_fuzz_24738();
++    void illegalAnimateTransform_data();
++    void illegalAnimateTransform();
+ 
+ #ifndef QT_NO_COMPRESS
+     void testGzLoading();
+@@ -1646,5 +1648,22 @@ void tst_QSvgRenderer::oss_fuzz_24738()
+     QSvgRenderer().load(QByteArray("<svg><path d=\"a 2 1e-212.....\">"));
+ }
+ 
++void tst_QSvgRenderer::illegalAnimateTransform_data()
++{
++    QTest::addColumn<QByteArray>("svg");
++
++    QTest::newRow("case1") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" values=\"8,0,5,0\">");
++    QTest::newRow("case2") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" values=\"1,2\">");
++    QTest::newRow("case3") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" from=\".. 5 2\" to=\"f\">");
++    QTest::newRow("case4") << QByteArray("<svg><animateTransform type=\"scale\" begin=\"1\" dur=\"2\" by=\"--,..\">");
++}
++
++void tst_QSvgRenderer::illegalAnimateTransform()
++{
++    QFETCH(QByteArray, svg);
++    QSvgRenderer renderer;
++    QVERIFY(!renderer.load(svg)); // also shouldn't assert
++}
++
+ QTEST_MAIN(tst_QSvgRenderer)
+ #include "tst_qsvgrenderer.moc"
+Submodule qttools 6914f7c8..090e526e:
+diff --git a/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp b/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
+index feab1e2d5..cbfb82507 100644
+--- a/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
++++ b/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
+@@ -445,7 +445,9 @@ bool HelpGeneratorPrivate::insertFiles(const QStringList &files, const QString &
+     if (filterSetId < 0)
+         return false;
+     ++filterSetId;
+-    for (int attId : qAsConst(filterAtts)) {
++    QList<int> attValues = filterAtts.values();
++    std::sort(attValues.begin(), attValues.end());
++    for (int attId : qAsConst(attValues)) {
+         m_query->prepare(QLatin1String("INSERT INTO FileAttributeSetTable "
+             "VALUES(?, ?)"));
+         m_query->bindValue(0, filterSetId);
+Submodule qtwayland dfb0129c..2904e1b3:
+diff --git a/qtwayland/src/client/configure.json b/qtwayland/src/client/configure.json
+index 2f424580..29222357 100644
+--- a/qtwayland/src/client/configure.json
++++ b/qtwayland/src/client/configure.json
+@@ -149,8 +149,7 @@
+                     "#endif"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "vulkan-server-buffer": {
+             "label": "Vulkan Buffer Sharing",
+@@ -168,7 +167,8 @@
+                     "exportAllocInfo.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR;",
+                     "return 0;"
+                 ]
+-            }
++            },
++            "use": "wayland-client"
+         },
+         "egl_1_5-wayland": {
+             "label": "EGL 1.5 with Wayland Platform",
+@@ -183,7 +183,7 @@
+                     "eglGetPlatformDisplay(EGL_PLATFORM_WAYLAND_EXT, (struct wl_display *)(nullptr), nullptr);"
+                 ]
+             },
+-            "use": "egl"
++            "use": "egl wayland-client"
+         }
+     },
+ 
+diff --git a/qtwayland/src/client/global/qwaylandclientextension.cpp b/qtwayland/src/client/global/qwaylandclientextension.cpp
+index 125b1e19..edccfe63 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension.cpp
++++ b/qtwayland/src/client/global/qwaylandclientextension.cpp
+@@ -74,7 +74,10 @@ void QWaylandClientExtensionPrivate::handleRegistryGlobal(void *data, ::wl_regis
+ void QWaylandClientExtension::addRegistryListener()
+ {
+     Q_D(QWaylandClientExtension);
+-    d->waylandIntegration->display()->addRegistryListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++    if (!d->registered) {
++        d->waylandIntegration->display()->addRegistryListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++        d->registered = true;
++    }
+ }
+ 
+ QWaylandClientExtension::QWaylandClientExtension(const int ver)
+@@ -88,6 +91,13 @@ QWaylandClientExtension::QWaylandClientExtension(const int ver)
+     QMetaObject::invokeMethod(this, "addRegistryListener", Qt::QueuedConnection);
+ }
+ 
++QWaylandClientExtension::~QWaylandClientExtension()
++{
++    Q_D(QWaylandClientExtension);
++    if (d->registered && !QCoreApplication::closingDown())
++        d->waylandIntegration->display()->removeListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++}
++
+ QtWaylandClient::QWaylandIntegration *QWaylandClientExtension::integration() const
+ {
+     Q_D(const QWaylandClientExtension);
+diff --git a/qtwayland/src/client/global/qwaylandclientextension.h b/qtwayland/src/client/global/qwaylandclientextension.h
+index 98272e57..5bd28398 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension.h
++++ b/qtwayland/src/client/global/qwaylandclientextension.h
+@@ -63,6 +63,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandClientExtension : public QObject
+     Q_PROPERTY(bool active READ isActive NOTIFY activeChanged)
+ public:
+     QWaylandClientExtension(const int version);
++    ~QWaylandClientExtension();
+ 
+     QtWaylandClient::QWaylandIntegration *integration() const;
+     int version() const;
+diff --git a/qtwayland/src/client/global/qwaylandclientextension_p.h b/qtwayland/src/client/global/qwaylandclientextension_p.h
+index 69cc46a0..9091efbe 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension_p.h
++++ b/qtwayland/src/client/global/qwaylandclientextension_p.h
+@@ -68,6 +68,7 @@ public:
+     QtWaylandClient::QWaylandIntegration *waylandIntegration = nullptr;
+     int version = -1;
+     bool active = false;
++    bool registered = false;
+ };
+ 
+ class Q_WAYLAND_CLIENT_EXPORT QWaylandClientExtensionTemplatePrivate : public QWaylandClientExtensionPrivate
+diff --git a/qtwayland/src/client/qwaylanddatadevice.cpp b/qtwayland/src/client/qwaylanddatadevice.cpp
+index 7e2e3308..e3e60ed5 100644
+--- a/qtwayland/src/client/qwaylanddatadevice.cpp
++++ b/qtwayland/src/client/qwaylanddatadevice.cpp
+@@ -72,6 +72,8 @@ QWaylandDataDevice::QWaylandDataDevice(QWaylandDataDeviceManager *manager, QWayl
+ 
+ QWaylandDataDevice::~QWaylandDataDevice()
+ {
++    if (wl_data_device_get_version(object()) >= WL_DATA_DEVICE_RELEASE_SINCE_VERSION)
++        release();
+ }
+ 
+ QWaylandDataOffer *QWaylandDataDevice::selectionOffer() const
+@@ -110,7 +112,7 @@ QWaylandDataOffer *QWaylandDataDevice::dragOffer() const
+     return m_dragOffer.data();
+ }
+ 
+-bool QWaylandDataDevice::startDrag(QMimeData *mimeData, QWaylandWindow *icon)
++bool QWaylandDataDevice::startDrag(QMimeData *mimeData, Qt::DropActions supportedActions, QWaylandWindow *icon)
+ {
+     auto *seat = m_display->currentInputDevice();
+     auto *origin = seat->pointerFocus();
+@@ -123,7 +125,28 @@ bool QWaylandDataDevice::startDrag(QMimeData *mimeData, QWaylandWindow *icon)
+     }
+ 
+     m_dragSource.reset(new QWaylandDataSource(m_display->dndSelectionHandler(), mimeData));
++
++    if (wl_data_device_get_version(object()) >= 3)
++        m_dragSource->set_actions(dropActionsToWl(supportedActions));
++
+     connect(m_dragSource.data(), &QWaylandDataSource::cancelled, this, &QWaylandDataDevice::dragSourceCancelled);
++    connect(m_dragSource.data(), &QWaylandDataSource::dndResponseUpdated, this, [this](bool accepted, Qt::DropAction action) {
++            auto drag = static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag());
++            // in old versions drop action is not set, so we guess
++            if (wl_data_source_get_version(m_dragSource->object()) < 3) {
++                drag->setResponse(accepted);
++            } else {
++                QPlatformDropQtResponse response(accepted, action);
++                drag->setResponse(response);
++            }
++    });
++    connect(m_dragSource.data(), &QWaylandDataSource::dndDropped, this, [](bool accepted, Qt::DropAction action) {
++        QPlatformDropQtResponse response(accepted, action);
++        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setDropResponse(response);
++    });
++    connect(m_dragSource.data(), &QWaylandDataSource::finished, this, []() {
++        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag();
++    });
+ 
+     start_drag(m_dragSource->object(), origin->wlSurface(), icon->wlSurface(), m_display->currentInputDevice()->serial());
+     return true;
+@@ -152,7 +175,7 @@ void QWaylandDataDevice::data_device_drop()
+         supportedActions = drag->supportedActions();
+     } else if (m_dragOffer) {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     } else {
+         return;
+     }
+@@ -162,7 +185,11 @@ void QWaylandDataDevice::data_device_drop()
+                                                                           QGuiApplication::keyboardModifiers());
+ 
+     if (drag) {
+-        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag(response);
++        auto drag =  static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag());
++        drag->setDropResponse(response);
++        drag->finishDrag();
++    } else if (m_dragOffer) {
++        m_dragOffer->finish();
+     }
+ }
+ 
+@@ -186,7 +213,7 @@ void QWaylandDataDevice::data_device_enter(uint32_t serial, wl_surface *surface,
+         supportedActions = drag->supportedActions();
+     } else if (m_dragOffer) {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     }
+ 
+     const QPlatformDragQtResponse &response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
+@@ -197,11 +224,7 @@ void QWaylandDataDevice::data_device_enter(uint32_t serial, wl_surface *surface,
+         static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setResponse(response);
+     }
+ 
+-    if (response.isAccepted()) {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, m_dragOffer->firstFormat().toUtf8().constData());
+-    } else {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, nullptr);
+-    }
++    sendResponse(supportedActions, response);
+ }
+ 
+ void QWaylandDataDevice::data_device_leave()
+@@ -235,10 +258,10 @@ void QWaylandDataDevice::data_device_motion(uint32_t time, wl_fixed_t x, wl_fixe
+         supportedActions = drag->supportedActions();
+     } else {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     }
+ 
+-    QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
++    const QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
+                                                                           QGuiApplication::mouseButtons(),
+                                                                           QGuiApplication::keyboardModifiers());
+ 
+@@ -246,11 +269,7 @@ void QWaylandDataDevice::data_device_motion(uint32_t time, wl_fixed_t x, wl_fixe
+         static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setResponse(response);
+     }
+ 
+-    if (response.isAccepted()) {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, m_dragOffer->firstFormat().toUtf8().constData());
+-    } else {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, nullptr);
+-    }
++    sendResponse(supportedActions, response);
+ }
+ #endif // QT_CONFIG(draganddrop)
+ 
+@@ -277,14 +296,10 @@ void QWaylandDataDevice::selectionSourceCancelled()
+ #if QT_CONFIG(draganddrop)
+ void QWaylandDataDevice::dragSourceCancelled()
+ {
++    static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag();
+     m_dragSource.reset();
+ }
+ 
+-void QWaylandDataDevice::dragSourceTargetChanged(const QString &mimeType)
+-{
+-    static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->updateTarget(mimeType);
+-}
+-
+ QPoint QWaylandDataDevice::calculateDragPosition(int x, int y, QWindow *wnd) const
+ {
+     QPoint pnt(wl_fixed_to_int(x), wl_fixed_to_int(y));
+@@ -297,6 +312,33 @@ QPoint QWaylandDataDevice::calculateDragPosition(int x, int y, QWindow *wnd) con
+     }
+     return pnt;
+ }
++
++void QWaylandDataDevice::sendResponse(Qt::DropActions supportedActions, const QPlatformDragQtResponse &response)
++{
++    if (response.isAccepted()) {
++        if (wl_data_device_get_version(object()) >= 3)
++            m_dragOffer->set_actions(dropActionsToWl(supportedActions), dropActionsToWl(response.acceptedAction()));
++
++        m_dragOffer->accept(m_enterSerial, m_dragOffer->firstFormat());
++    } else {
++        m_dragOffer->accept(m_enterSerial, QString());
++    }
++}
++
++int QWaylandDataDevice::dropActionsToWl(Qt::DropActions actions)
++{
++
++    int wlActions = WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE;
++    if (actions & Qt::CopyAction)
++        wlActions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY;
++    if (actions & (Qt::MoveAction | Qt::TargetMoveAction))
++        wlActions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE;
++
++    // wayland does not support LinkAction at the time of writing
++    return wlActions;
++}
++
++
+ #endif // QT_CONFIG(draganddrop)
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddatadevice_p.h b/qtwayland/src/client/qwaylanddatadevice_p.h
+index 16c3ad28..801dcc2c 100644
+--- a/qtwayland/src/client/qwaylanddatadevice_p.h
++++ b/qtwayland/src/client/qwaylanddatadevice_p.h
+@@ -64,6 +64,7 @@ QT_REQUIRE_CONFIG(wayland_datadevice);
+ QT_BEGIN_NAMESPACE
+ 
+ class QMimeData;
++class QPlatformDragQtResponse;
+ class QWindow;
+ 
+ namespace QtWaylandClient {
+@@ -89,7 +90,7 @@ public:
+ 
+ #if QT_CONFIG(draganddrop)
+     QWaylandDataOffer *dragOffer() const;
+-    bool startDrag(QMimeData *mimeData, QWaylandWindow *icon);
++    bool startDrag(QMimeData *mimeData, Qt::DropActions supportedActions, QWaylandWindow *icon);
+     void cancelDrag();
+ #endif
+ 
+@@ -109,13 +110,16 @@ private Q_SLOTS:
+ 
+ #if QT_CONFIG(draganddrop)
+     void dragSourceCancelled();
+-    void dragSourceTargetChanged(const QString &mimeType);
+ #endif
+ 
+ private:
+ #if QT_CONFIG(draganddrop)
+     QPoint calculateDragPosition(int x, int y, QWindow *wnd) const;
+ #endif
++    void sendResponse(Qt::DropActions supportedActions, const QPlatformDragQtResponse &response);
++
++    static int dropActionsToWl(Qt::DropActions dropActions);
++
+ 
+     QWaylandDisplay *m_display = nullptr;
+     QWaylandInputDevice *m_inputDevice = nullptr;
+diff --git a/qtwayland/src/client/qwaylanddatadevicemanager.cpp b/qtwayland/src/client/qwaylanddatadevicemanager.cpp
+index 35d67307..6dc4f77f 100644
+--- a/qtwayland/src/client/qwaylanddatadevicemanager.cpp
++++ b/qtwayland/src/client/qwaylanddatadevicemanager.cpp
+@@ -50,8 +50,8 @@ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
+-QWaylandDataDeviceManager::QWaylandDataDeviceManager(QWaylandDisplay *display, uint32_t id)
+-    : wl_data_device_manager(display->wl_registry(), id, 1)
++QWaylandDataDeviceManager::QWaylandDataDeviceManager(QWaylandDisplay *display, int version, uint32_t id)
++    : wl_data_device_manager(display->wl_registry(), id, qMin(version, 3))
+     , m_display(display)
+ {
+     // Create transfer devices for all input devices.
+diff --git a/qtwayland/src/client/qwaylanddatadevicemanager_p.h b/qtwayland/src/client/qwaylanddatadevicemanager_p.h
+index bd05c0fb..510d9be4 100644
+--- a/qtwayland/src/client/qwaylanddatadevicemanager_p.h
++++ b/qtwayland/src/client/qwaylanddatadevicemanager_p.h
+@@ -68,7 +68,7 @@ class QWaylandInputDevice;
+ class Q_WAYLAND_CLIENT_EXPORT QWaylandDataDeviceManager : public QtWayland::wl_data_device_manager
+ {
+ public:
+-    QWaylandDataDeviceManager(QWaylandDisplay *display, uint32_t id);
++    QWaylandDataDeviceManager(QWaylandDisplay *display, int version, uint32_t id);
+     ~QWaylandDataDeviceManager() override;
+ 
+     QWaylandDataDevice *getDataDevice(QWaylandInputDevice *inputDevice);
+diff --git a/qtwayland/src/client/qwaylanddataoffer.cpp b/qtwayland/src/client/qwaylanddataoffer.cpp
+index 2297e8a1..fe0ea8c9 100644
+--- a/qtwayland/src/client/qwaylanddataoffer.cpp
++++ b/qtwayland/src/client/qwaylanddataoffer.cpp
+@@ -82,6 +82,15 @@ QMimeData *QWaylandDataOffer::mimeData()
+     return m_mimeData.data();
+ }
+ 
++Qt::DropActions QWaylandDataOffer::supportedActions() const
++{
++    if (wl_data_offer_get_version(const_cast<::wl_data_offer*>(object())) < 3) {
++        return Qt::MoveAction | Qt::CopyAction;
++    }
++
++    return m_supportedActions;
++}
++
+ void QWaylandDataOffer::startReceiving(const QString &mimeType, int fd)
+ {
+     receive(mimeType, fd);
+@@ -93,6 +102,22 @@ void QWaylandDataOffer::data_offer_offer(const QString &mime_type)
+     m_mimeData->appendFormat(mime_type);
+ }
+ 
++void QWaylandDataOffer::data_offer_action(uint32_t dnd_action)
++{
++    Q_UNUSED(dnd_action);
++    // This is the compositor telling the drag target what action it should perform
++    // It does not map nicely into Qt final drop semantics, other than pretending there is only one supported action?
++}
++
++void QWaylandDataOffer::data_offer_source_actions(uint32_t source_actions)
++{
++    m_supportedActions = Qt::DropActions();
++    if (source_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
++        m_supportedActions |= Qt::MoveAction;
++    if (source_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
++        m_supportedActions |= Qt::CopyAction;
++}
++
+ QWaylandMimeData::QWaylandMimeData(QWaylandAbstractDataOffer *dataOffer)
+     : m_dataOffer(dataOffer)
+ {
+@@ -163,17 +188,18 @@ QVariant QWaylandMimeData::retrieveData_sys(const QString &mimeType, QVariant::T
+ 
+ int QWaylandMimeData::readData(int fd, QByteArray &data) const
+ {
+-    fd_set readset;
+-    FD_ZERO(&readset);
+-    FD_SET(fd, &readset);
+-    struct timeval timeout;
++    struct pollfd readset;
++    readset.fd = fd;
++    readset.events = POLLIN;
++    struct timespec timeout;
+     timeout.tv_sec = 1;
+-    timeout.tv_usec = 0;
++    timeout.tv_nsec = 0;
++
+ 
+     Q_FOREVER {
+-        int ready = select(FD_SETSIZE, &readset, nullptr, nullptr, &timeout);
++        int ready = qt_safe_poll(&readset, 1, &timeout);
+         if (ready < 0) {
+-            qWarning() << "QWaylandDataOffer: select() failed";
++            qWarning() << "QWaylandDataOffer: qt_safe_poll() failed";
+             return -1;
+         } else if (ready == 0) {
+             qWarning("QWaylandDataOffer: timeout reading from pipe");
+diff --git a/qtwayland/src/client/qwaylanddataoffer_p.h b/qtwayland/src/client/qwaylanddataoffer_p.h
+index 9cf1483c..6f667398 100644
+--- a/qtwayland/src/client/qwaylanddataoffer_p.h
++++ b/qtwayland/src/client/qwaylanddataoffer_p.h
+@@ -82,6 +82,7 @@ public:
+     explicit QWaylandDataOffer(QWaylandDisplay *display, struct ::wl_data_offer *offer);
+     ~QWaylandDataOffer() override;
+     QMimeData *mimeData() override;
++    Qt::DropActions supportedActions() const;
+ 
+     QString firstFormat() const;
+ 
+@@ -89,10 +90,13 @@ public:
+ 
+ protected:
+     void data_offer_offer(const QString &mime_type) override;
++    void data_offer_source_actions(uint32_t source_actions) override;
++    void data_offer_action(uint32_t dnd_action) override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+     QScopedPointer<QWaylandMimeData> m_mimeData;
++    Qt::DropActions m_supportedActions;
+ };
+ 
+ 
+diff --git a/qtwayland/src/client/qwaylanddatasource.cpp b/qtwayland/src/client/qwaylanddatasource.cpp
+index f45122fb..5599cbd4 100644
+--- a/qtwayland/src/client/qwaylanddatasource.cpp
++++ b/qtwayland/src/client/qwaylanddatasource.cpp
+@@ -101,7 +101,32 @@ void QWaylandDataSource::data_source_send(const QString &mime_type, int32_t fd)
+ 
+ void QWaylandDataSource::data_source_target(const QString &mime_type)
+ {
+-    Q_EMIT targetChanged(mime_type);
++    m_accepted = !mime_type.isEmpty();
++    Q_EMIT dndResponseUpdated(m_accepted, m_dropAction);
++}
++
++void QWaylandDataSource::data_source_action(uint32_t action)
++{
++    Qt::DropAction qtAction = Qt::IgnoreAction;
++
++    if (action == WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
++        qtAction = Qt::MoveAction;
++    else if (action == WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
++        qtAction = Qt::CopyAction;
++
++    m_dropAction = qtAction;
++    Q_EMIT dndResponseUpdated(m_accepted, m_dropAction);
++}
++
++void QWaylandDataSource::data_source_dnd_finished()
++{
++    Q_EMIT finished();
++}
++
++void QWaylandDataSource::data_source_dnd_drop_performed()
++{
++
++    Q_EMIT dndDropped(m_accepted, m_dropAction);
+ }
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddatasource_p.h b/qtwayland/src/client/qwaylanddatasource_p.h
+index 25afff79..96f07bc3 100644
+--- a/qtwayland/src/client/qwaylanddatasource_p.h
++++ b/qtwayland/src/client/qwaylanddatasource_p.h
+@@ -77,17 +77,25 @@ public:
+     QMimeData *mimeData() const;
+ 
+ Q_SIGNALS:
+-    void targetChanged(const QString &mime_type);
+     void cancelled();
++    void finished();
++
++    void dndResponseUpdated(bool accepted, Qt::DropAction action);
++    void dndDropped(bool accepted, Qt::DropAction action);
+ 
+ protected:
+     void data_source_cancelled() override;
+     void data_source_send(const QString &mime_type, int32_t fd) override;
+     void data_source_target(const QString &mime_type) override;
++    void data_source_dnd_drop_performed() override;
++    void data_source_dnd_finished() override;
++    void data_source_action(uint32_t action) override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+     QMimeData *m_mime_data = nullptr;
++    bool m_accepted = false;
++    Qt::DropAction m_dropAction = Qt::IgnoreAction;
+ };
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddisplay.cpp b/qtwayland/src/client/qwaylanddisplay.cpp
+index f10c1f79..c01e238b 100644
+--- a/qtwayland/src/client/qwaylanddisplay.cpp
++++ b/qtwayland/src/client/qwaylanddisplay.cpp
+@@ -85,10 +85,203 @@
+ 
+ #include <errno.h>
+ 
++#include <tuple> // for std::tie
++
++static void checkWaylandError(struct wl_display *display)
++{
++    int ecode = wl_display_get_error(display);
++    if ((ecode == EPIPE || ecode == ECONNRESET)) {
++        // special case this to provide a nicer error
++        qWarning("The Wayland connection broke. Did the Wayland compositor die?");
++    } else {
++        qWarning("The Wayland connection experienced a fatal error: %s", strerror(ecode));
++    }
++    _exit(1);
++}
++
+ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
++class EventThread : public QThread
++{
++    Q_OBJECT
++public:
++    enum OperatingMode {
++        EmitToDispatch, // Emit the signal, allow dispatching in a differnt thread.
++        SelfDispatch, // Dispatch the events inside this thread.
++    };
++
++    EventThread(struct wl_display * wl, struct wl_event_queue * ev_queue,
++                OperatingMode mode)
++        : m_fd(wl_display_get_fd(wl))
++        , m_pipefd{ -1, -1 }
++        , m_wldisplay(wl)
++        , m_wlevqueue(ev_queue)
++        , m_mode(mode)
++        , m_reading(true)
++        , m_quitting(false)
++    {
++        setObjectName(QStringLiteral("WaylandEventThread"));
++    }
++
++    void readAndDispatchEvents()
++    {
++        /*
++         * Dispatch pending events and flush the requests at least once. If the event thread
++         * is not reading, try to call _prepare_read() to allow the event thread to poll().
++         * If that fails, re-try dispatch & flush again until _prepare_read() is successful.
++         *
++         * This allow any call to readAndDispatchEvents() to start event thread's polling,
++         * not only the one issued from event thread's waitForReading(), which means functions
++         * called from dispatch_pending() can safely spin an event loop.
++         */
++        for (;;) {
++            if (dispatchQueuePending() < 0) {
++                checkWaylandError(m_wldisplay);
++                return;
++            }
++
++            wl_display_flush(m_wldisplay);
++
++            // We have to check if event thread is reading every time we dispatch
++            // something, as that may recursively call this function.
++            if (m_reading.loadAcquire())
++                break;
++
++            if (prepareReadQueue() == 0) {
++                QMutexLocker l(&m_mutex);
++                m_reading.storeRelease(true);
++                m_cond.wakeOne();
++                break;
++            }
++        }
++    }
++
++    void stop()
++    {
++        // We have to both write to the pipe and set the flag, as the thread may be
++        // either in the poll() or waiting for _prepare_read().
++        if (m_pipefd[1] != -1 && write(m_pipefd[1], "\0", 1) == -1)
++            qWarning("Failed to write to the pipe: %s.", strerror(errno));
++
++        {
++            QMutexLocker l(&m_mutex);
++            m_quitting = true;
++            m_cond.wakeOne();
++        }
++
++        wait();
++    }
++
++Q_SIGNALS:
++    void needReadAndDispatch();
++
++protected:
++    void run() override
++    {
++        // we use this pipe to make the loop exit otherwise if we simply used a flag on the loop condition, if stop() gets
++        // called while poll() is blocking the thread will never quit since there are no wayland messages coming anymore.
++        struct Pipe
++        {
++            Pipe(int *fds)
++                : fds(fds)
++            {
++                if (qt_safe_pipe(fds) != 0)
++                    qWarning("Pipe creation failed. Quitting may hang.");
++            }
++            ~Pipe()
++            {
++                if (fds[0] != -1) {
++                    close(fds[0]);
++                    close(fds[1]);
++                }
++            }
++
++            int *fds;
++        } pipe(m_pipefd);
++
++        // Make the main thread call wl_prepare_read(), dispatch the pending messages and flush the
++        // outbound ones. Wait until it's done before proceeding, unless we're told to quit.
++        while (waitForReading()) {
++            pollfd fds[2] = { { m_fd, POLLIN, 0 }, { m_pipefd[0], POLLIN, 0 } };
++            poll(fds, 2, -1);
++
++            if (fds[1].revents & POLLIN) {
++                // we don't really care to read the byte that was written here since we're closing down
++                wl_display_cancel_read(m_wldisplay);
++                break;
++            }
++
++            if (fds[0].revents & POLLIN)
++                wl_display_read_events(m_wldisplay);
++                // The polll was succesfull and the event thread did the wl_display_read_events(). On the next iteration of the loop
++                // the event sent to the main thread will cause it to dispatch the messages just read, unless the loop exits in which
++                // case we don't care anymore about them.
++            else
++                wl_display_cancel_read(m_wldisplay);
++        }
++    }
++
++private:
++    bool waitForReading()
++    {
++        Q_ASSERT(QThread::currentThread() == this);
++
++        m_reading.storeRelease(false);
++
++        if (m_mode == SelfDispatch) {
++            readAndDispatchEvents();
++        } else {
++            Q_EMIT needReadAndDispatch();
++
++            QMutexLocker lock(&m_mutex);
++            // m_reading might be set from our emit or some other invocation of
++            // readAndDispatchEvents().
++            while (!m_reading.loadRelaxed() && !m_quitting)
++                m_cond.wait(&m_mutex);
++        }
++
++        return !m_quitting;
++    }
++
++    int dispatchQueuePending()
++    {
++        if (m_wlevqueue)
++            return wl_display_dispatch_queue_pending(m_wldisplay, m_wlevqueue);
++        else
++            return wl_display_dispatch_pending(m_wldisplay);
++    }
++
++    int prepareReadQueue()
++    {
++        if (m_wlevqueue)
++            return wl_display_prepare_read_queue(m_wldisplay, m_wlevqueue);
++        else
++            return wl_display_prepare_read(m_wldisplay);
++    }
++
++    int m_fd;
++    int m_pipefd[2];
++    wl_display *m_wldisplay;
++    wl_event_queue *m_wlevqueue;
++    OperatingMode m_mode;
++
++    /* Concurrency note when operating in EmitToDispatch mode:
++     * m_reading is set to false inside event thread's waitForReading(), and is
++     * set to true inside main thread's readAndDispatchEvents().
++     * The lock is not taken when setting m_reading to false, as the main thread
++     * is not actively waiting for it to turn false. However, the lock is taken
++     * inside readAndDispatchEvents() before setting m_reading to true,
++     * as the event thread is actively waiting for it under the wait condition.
++     */
++
++    QAtomicInteger<bool> m_reading;
++    bool m_quitting;
++    QMutex m_mutex;
++    QWaitCondition m_cond;
++};
++
+ Q_LOGGING_CATEGORY(lcQpaWayland, "qt.qpa.wayland"); // for general (uncategorized) Wayland platform logging
+ 
+ struct wl_surface *QWaylandDisplay::createSurface(void *handle)
+@@ -158,17 +351,16 @@ QWaylandDisplay::QWaylandDisplay(QWaylandIntegration *waylandIntegration)
+     if (!mXkbContext)
+         qCWarning(lcQpaWayland, "failed to create xkb context");
+ #endif
+-
+-    forceRoundTrip();
+-
+-    if (!mWaitingScreens.isEmpty()) {
+-        // Give wl_output.done and zxdg_output_v1.done events a chance to arrive
+-        forceRoundTrip();
+-    }
+ }
+ 
+ QWaylandDisplay::~QWaylandDisplay(void)
+ {
++    if (m_eventThread)
++        m_eventThread->stop();
++
++    if (m_frameEventQueueThread)
++        m_frameEventQueueThread->stop();
++
+     if (mSyncCallback)
+         wl_callback_destroy(mSyncCallback);
+ 
+@@ -187,6 +379,21 @@ QWaylandDisplay::~QWaylandDisplay(void)
+ #endif
+     if (mDisplay)
+         wl_display_disconnect(mDisplay);
++
++    if (m_frameEventQueue)
++        wl_event_queue_destroy(m_frameEventQueue);
++}
++
++// Steps which is called just after constructor. This separates registry_global() out of the constructor
++// so that factory functions in integration can be overridden.
++void QWaylandDisplay::initialize()
++{
++    forceRoundTrip();
++
++    if (!mWaitingScreens.isEmpty()) {
++        // Give wl_output.done and zxdg_output_v1.done events a chance to arrive
++        forceRoundTrip();
++    }
+ }
+ 
+ void QWaylandDisplay::ensureScreen()
+@@ -203,98 +410,37 @@ void QWaylandDisplay::ensureScreen()
+ 
+ void QWaylandDisplay::checkError() const
+ {
+-    int ecode = wl_display_get_error(mDisplay);
+-    if ((ecode == EPIPE || ecode == ECONNRESET)) {
+-        // special case this to provide a nicer error
+-        qWarning("The Wayland connection broke. Did the Wayland compositor die?");
+-    } else {
+-        qWarning("The Wayland connection experienced a fatal error: %s", strerror(ecode));
+-    }
+-    _exit(1);
++    checkWaylandError(mDisplay);
+ }
+ 
++// Called in main thread, either from queued signal or directly.
+ void QWaylandDisplay::flushRequests()
+ {
+-    if (wl_display_prepare_read(mDisplay) == 0) {
+-        wl_display_read_events(mDisplay);
+-    }
+-
+-    if (wl_display_dispatch_pending(mDisplay) < 0)
+-        checkError();
+-
+-    {
+-        QReadLocker locker(&m_frameQueueLock);
+-        for (const FrameQueue &q : mExternalQueues) {
+-            QMutexLocker locker(q.mutex);
+-            while (wl_display_prepare_read_queue(mDisplay, q.queue) != 0)
+-                wl_display_dispatch_queue_pending(mDisplay, q.queue);
+-            wl_display_read_events(mDisplay);
+-            wl_display_dispatch_queue_pending(mDisplay, q.queue);
+-        }
+-    }
+-
+-    wl_display_flush(mDisplay);
+-}
+-
+-void QWaylandDisplay::blockingReadEvents()
+-{
+-    if (wl_display_dispatch(mDisplay) < 0)
+-        checkError();
+-}
+-
+-void QWaylandDisplay::destroyFrameQueue(const QWaylandDisplay::FrameQueue &q)
+-{
+-    QWriteLocker locker(&m_frameQueueLock);
+-    auto it = std::find_if(mExternalQueues.begin(),
+-                           mExternalQueues.end(),
+-                           [&q] (const QWaylandDisplay::FrameQueue &other){ return other.queue == q.queue; });
+-    Q_ASSERT(it != mExternalQueues.end());
+-    mExternalQueues.erase(it);
+-    if (q.queue != nullptr)
+-        wl_event_queue_destroy(q.queue);
+-    delete q.mutex;
++    m_eventThread->readAndDispatchEvents();
+ }
+ 
+-QWaylandDisplay::FrameQueue QWaylandDisplay::createFrameQueue()
++// We have to wait until we have an eventDispatcher before creating the eventThread,
++// otherwise forceRoundTrip() may block inside _events_read() because eventThread is
++// polling.
++void QWaylandDisplay::initEventThread()
+ {
+-    QWriteLocker locker(&m_frameQueueLock);
+-    FrameQueue q{createEventQueue()};
+-    mExternalQueues.append(q);
+-    return q;
+-}
++    m_eventThread.reset(
++            new EventThread(mDisplay, /* default queue */ nullptr, EventThread::EmitToDispatch));
++    connect(m_eventThread.get(), &EventThread::needReadAndDispatch, this,
++            &QWaylandDisplay::flushRequests, Qt::QueuedConnection);
++    m_eventThread->start();
+ 
+-wl_event_queue *QWaylandDisplay::createEventQueue()
+-{
+-    return wl_display_create_queue(mDisplay);
++    // wl_display_disconnect() free this.
++    m_frameEventQueue = wl_display_create_queue(mDisplay);
++    m_frameEventQueueThread.reset(
++            new EventThread(mDisplay, m_frameEventQueue, EventThread::SelfDispatch));
++    m_frameEventQueueThread->start();
+ }
+ 
+-void QWaylandDisplay::dispatchQueueWhile(wl_event_queue *queue, std::function<bool ()> condition, int timeout)
++void QWaylandDisplay::blockingReadEvents()
+ {
+-    if (!condition())
+-        return;
+-
+-    QElapsedTimer timer;
+-    timer.start();
+-    struct pollfd pFd = qt_make_pollfd(wl_display_get_fd(mDisplay), POLLIN);
+-    while (timeout == -1 || timer.elapsed() < timeout) {
+-        while (wl_display_prepare_read_queue(mDisplay, queue) != 0)
+-            wl_display_dispatch_queue_pending(mDisplay, queue);
+-
+-        wl_display_flush(mDisplay);
+-
+-        const int remaining = qMax(timeout - timer.elapsed(), 0ll);
+-        const int pollTimeout = timeout == -1 ? -1 : remaining;
+-        if (qt_poll_msecs(&pFd, 1, pollTimeout) > 0)
+-            wl_display_read_events(mDisplay);
+-        else
+-            wl_display_cancel_read(mDisplay);
+-
+-        if (wl_display_dispatch_queue_pending(mDisplay, queue) < 0)
+-            checkError();
+-
+-        if (!condition())
+-            break;
+-    }
++    if (wl_display_dispatch(mDisplay) < 0)
++        checkWaylandError(mDisplay);
+ }
+ 
+ QWaylandScreen *QWaylandDisplay::screenForOutput(struct wl_output *output) const
+@@ -345,7 +491,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+     if (interface == QStringLiteral("wl_output")) {
+         mWaitingScreens << new QWaylandScreen(this, version, id);
+     } else if (interface == QStringLiteral("wl_compositor")) {
+-        mCompositorVersion = qMin((int)version, 3);
++        mCompositorVersion = qMin((int)version, 4);
+         mCompositor.init(registry, id, mCompositorVersion);
+     } else if (interface == QStringLiteral("wl_shm")) {
+         mShm.reset(new QWaylandShm(this, version, id));
+@@ -354,7 +500,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+         mInputDevices.append(inputDevice);
+ #if QT_CONFIG(wayland_datadevice)
+     } else if (interface == QStringLiteral("wl_data_device_manager")) {
+-        mDndSelectionHandler.reset(new QWaylandDataDeviceManager(this, id));
++        mDndSelectionHandler.reset(new QWaylandDataDeviceManager(this, version, id));
+ #endif
+     } else if (interface == QStringLiteral("qt_surface_extension")) {
+         mWindowExtension.reset(new QtWayland::qt_surface_extension(registry, id, 1));
+@@ -369,6 +515,8 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+ #if QT_CONFIG(wayland_client_primary_selection)
+     } else if (interface == QStringLiteral("zwp_primary_selection_device_manager_v1")) {
+         mPrimarySelectionManager.reset(new QWaylandPrimarySelectionDeviceManagerV1(this, id, 1));
++        for (QWaylandInputDevice *inputDevice : qAsConst(mInputDevices))
++            inputDevice->setPrimarySelectionDevice(mPrimarySelectionManager->createDevice(inputDevice));
+ #endif
+     } else if (interface == QStringLiteral("zwp_text_input_manager_v2") && !mClientSideInputContextRequested) {
+         mTextInputManager.reset(new QtWayland::zwp_text_input_manager_v2(registry, id, 1));
+@@ -427,6 +575,13 @@ void QWaylandDisplay::registry_global_remove(uint32_t id)
+                     inputDevice->setTextInput(nullptr);
+                 mWaylandIntegration->reconfigureInputContext();
+             }
++#if QT_CONFIG(wayland_client_primary_selection)
++            if (global.interface == QStringLiteral("zwp_primary_selection_device_manager_v1")) {
++                mPrimarySelectionManager.reset();
++                for (QWaylandInputDevice *inputDevice : qAsConst(mInputDevices))
++                    inputDevice->setPrimarySelectionDevice(nullptr);
++            }
++#endif
+             mGlobals.removeAt(i);
+             break;
+         }
+@@ -452,9 +607,10 @@ void QWaylandDisplay::addRegistryListener(RegistryListener listener, void *data)
+ 
+ void QWaylandDisplay::removeListener(RegistryListener listener, void *data)
+ {
+-    std::remove_if(mRegistryListeners.begin(), mRegistryListeners.end(), [=](Listener l){
++    auto iter = std::remove_if(mRegistryListeners.begin(), mRegistryListeners.end(), [=](Listener l){
+         return (l.listener == listener && l.data == data);
+     });
++    mRegistryListeners.erase(iter, mRegistryListeners.end());
+ }
+ 
+ uint32_t QWaylandDisplay::currentTimeMillisec()
+@@ -467,50 +623,9 @@ uint32_t QWaylandDisplay::currentTimeMillisec()
+     return 0;
+ }
+ 
+-static void
+-sync_callback(void *data, struct wl_callback *callback, uint32_t serial)
+-{
+-    Q_UNUSED(serial)
+-    bool *done = static_cast<bool *>(data);
+-
+-    *done = true;
+-
+-    // If the wl_callback done event is received after the condition check in the while loop in
+-    // forceRoundTrip(), but before the call to processEvents, the call to processEvents may block
+-    // forever if no more events are posted (eventhough the callback is handled in response to the
+-    // aboutToBlock signal). Hence, we wake up the event dispatcher so forceRoundTrip may return.
+-    // (QTBUG-64696)
+-    if (auto *dispatcher = QThread::currentThread()->eventDispatcher())
+-        dispatcher->wakeUp();
+-
+-    wl_callback_destroy(callback);
+-}
+-
+-static const struct wl_callback_listener sync_listener = {
+-    sync_callback
+-};
+-
+ void QWaylandDisplay::forceRoundTrip()
+ {
+-    // wl_display_roundtrip() works on the main queue only,
+-    // but we use a separate one, so basically reimplement it here
+-    int ret = 0;
+-    bool done = false;
+-    wl_callback *callback = wl_display_sync(mDisplay);
+-    wl_callback_add_listener(callback, &sync_listener, &done);
+-    flushRequests();
+-    if (QThread::currentThread()->eventDispatcher()) {
+-        while (!done && ret >= 0) {
+-            QThread::currentThread()->eventDispatcher()->processEvents(QEventLoop::WaitForMoreEvents);
+-            ret = wl_display_dispatch_pending(mDisplay);
+-        }
+-    } else {
+-        while (!done && ret >= 0)
+-            ret = wl_display_dispatch(mDisplay);
+-    }
+-
+-    if (ret == -1 && !done)
+-        wl_callback_destroy(callback);
++     wl_display_roundtrip(mDisplay);
+ }
+ 
+ bool QWaylandDisplay::supportsWindowDecoration() const
+@@ -574,14 +689,10 @@ void QWaylandDisplay::handleKeyboardFocusChanged(QWaylandInputDevice *inputDevic
+     if (mLastKeyboardFocus == keyboardFocus)
+         return;
+ 
+-    if (mWaylandIntegration->mShellIntegration) {
+-        mWaylandIntegration->mShellIntegration->handleKeyboardFocusChanged(keyboardFocus, mLastKeyboardFocus);
+-    } else {
+-        if (keyboardFocus)
+-            handleWindowActivated(keyboardFocus);
+-        if (mLastKeyboardFocus)
+-            handleWindowDeactivated(mLastKeyboardFocus);
+-    }
++    if (keyboardFocus)
++        handleWindowActivated(keyboardFocus);
++    if (mLastKeyboardFocus)
++        handleWindowDeactivated(mLastKeyboardFocus);
+ 
+     mLastKeyboardFocus = keyboardFocus;
+ }
+@@ -600,6 +711,19 @@ void QWaylandDisplay::handleWaylandSync()
+     QWindow *activeWindow = mActiveWindows.empty() ? nullptr : mActiveWindows.last()->window();
+     if (activeWindow != QGuiApplication::focusWindow())
+         QWindowSystemInterface::handleWindowActivated(activeWindow);
++
++    if (!activeWindow) {
++        if (lastInputDevice()) {
++#if QT_CONFIG(clipboard)
++            if (auto *dataDevice = lastInputDevice()->dataDevice())
++                dataDevice->invalidateSelectionOffer();
++#endif
++#if QT_CONFIG(wayland_client_primary_selection)
++            if (auto *device = lastInputDevice()->primarySelectionDevice())
++                device->invalidateSelectionOffer();
++#endif
++        }
++    }
+ }
+ 
+ const wl_callback_listener QWaylandDisplay::syncCallbackListener = {
+@@ -626,6 +750,13 @@ QWaylandInputDevice *QWaylandDisplay::defaultInputDevice() const
+     return mInputDevices.isEmpty() ? 0 : mInputDevices.first();
+ }
+ 
++bool QWaylandDisplay::isKeyboardAvailable() const
++{
++    return std::any_of(
++            mInputDevices.constBegin(), mInputDevices.constEnd(),
++            [this](const QWaylandInputDevice *device) { return device->keyboard() != nullptr; });
++}
++
+ #if QT_CONFIG(cursor)
+ 
+ QWaylandCursor *QWaylandDisplay::waylandCursor()
+@@ -652,4 +783,6 @@ QWaylandCursorTheme *QWaylandDisplay::loadCursorTheme(const QString &name, int p
+ 
+ } // namespace QtWaylandClient
+ 
++#include "qwaylanddisplay.moc"
++
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/client/qwaylanddisplay_p.h b/qtwayland/src/client/qwaylanddisplay_p.h
+index 3b092bc8..42bc661d 100644
+--- a/qtwayland/src/client/qwaylanddisplay_p.h
++++ b/qtwayland/src/client/qwaylanddisplay_p.h
+@@ -109,6 +109,7 @@ class QWaylandSurface;
+ class QWaylandShellIntegration;
+ class QWaylandCursor;
+ class QWaylandCursorTheme;
++class EventThread;
+ 
+ typedef void (*RegistryListener)(void *data,
+                                  struct wl_registry *registry,
+@@ -120,15 +121,11 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandDisplay : public QObject, public QtWayland
+     Q_OBJECT
+ 
+ public:
+-    struct FrameQueue {
+-        FrameQueue(wl_event_queue *q = nullptr) : queue(q), mutex(new QMutex) {}
+-        wl_event_queue *queue;
+-        QMutex *mutex;
+-    };
+-
+     QWaylandDisplay(QWaylandIntegration *waylandIntegration);
+     ~QWaylandDisplay(void) override;
+ 
++    void initialize();
++
+ #if QT_CONFIG(xkbcommon)
+     struct xkb_context *xkbContext() const { return mXkbContext.get(); }
+ #endif
+@@ -210,11 +207,11 @@ public:
+     void handleKeyboardFocusChanged(QWaylandInputDevice *inputDevice);
+     void handleWindowDestroyed(QWaylandWindow *window);
+ 
+-    wl_event_queue *createEventQueue();
+-    FrameQueue createFrameQueue();
+-    void destroyFrameQueue(const FrameQueue &q);
+-    void dispatchQueueWhile(wl_event_queue *queue, std::function<bool()> condition, int timeout = -1);
++    wl_event_queue *frameEventQueue() { return m_frameEventQueue; };
++
++    bool isKeyboardAvailable() const;
+ 
++    void initEventThread();
+ public slots:
+     void blockingReadEvents();
+     void flushRequests();
+@@ -237,6 +234,9 @@ private:
+     };
+ 
+     struct wl_display *mDisplay = nullptr;
++    QScopedPointer<EventThread> m_eventThread;
++    wl_event_queue *m_frameEventQueue = nullptr;
++    QScopedPointer<EventThread> m_frameEventQueueThread;
+     QtWayland::wl_compositor mCompositor;
+     QScopedPointer<QWaylandShm> mShm;
+     QList<QWaylandScreen *> mWaitingScreens;
+@@ -273,11 +273,9 @@ private:
+     QWaylandInputDevice *mLastInputDevice = nullptr;
+     QPointer<QWaylandWindow> mLastInputWindow;
+     QPointer<QWaylandWindow> mLastKeyboardFocus;
+-    QVector<QWaylandWindow *> mActiveWindows;
+-    QVector<FrameQueue> mExternalQueues;
++    QList<QWaylandWindow *> mActiveWindows;
+     struct wl_callback *mSyncCallback = nullptr;
+     static const wl_callback_listener syncCallbackListener;
+-    QReadWriteLock m_frameQueueLock;
+ 
+     bool mClientSideInputContextRequested = !QPlatformInputContextFactory::requested().isNull();
+ 
+diff --git a/qtwayland/src/client/qwaylanddnd.cpp b/qtwayland/src/client/qwaylanddnd.cpp
+index 6535aa16..7c53f5fa 100644
+--- a/qtwayland/src/client/qwaylanddnd.cpp
++++ b/qtwayland/src/client/qwaylanddnd.cpp
+@@ -66,7 +66,7 @@ void QWaylandDrag::startDrag()
+ {
+     QBasicDrag::startDrag();
+     QWaylandWindow *icon = static_cast<QWaylandWindow *>(shapedPixmapWindow()->handle());
+-    if (m_display->currentInputDevice()->dataDevice()->startDrag(drag()->mimeData(), icon)) {
++    if (m_display->currentInputDevice()->dataDevice()->startDrag(drag()->mimeData(), drag()->supportedActions(), icon)) {
+         icon->addAttachOffset(-drag()->hotSpot());
+     } else {
+         // Cancelling immediately does not work, since the event loop for QDrag::exec is started
+@@ -80,6 +80,9 @@ void QWaylandDrag::cancel()
+     QBasicDrag::cancel();
+ 
+     m_display->currentInputDevice()->dataDevice()->cancelDrag();
++
++    if (drag())
++        drag()->deleteLater();
+ }
+ 
+ void QWaylandDrag::move(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods)
+@@ -103,33 +106,41 @@ void QWaylandDrag::endDrag()
+     m_display->currentInputDevice()->handleEndDrag();
+ }
+ 
+-void QWaylandDrag::updateTarget(const QString &mimeType)
++void QWaylandDrag::setResponse(bool accepted)
+ {
+-    setCanDrop(!mimeType.isEmpty());
+-
+-    if (canDrop()) {
+-        updateCursor(defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers()));
+-    } else {
+-        updateCursor(Qt::IgnoreAction);
+-    }
++    // This method is used for old DataDevices where the drag action is not communicated
++    Qt::DropAction action = defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers());
++    setResponse(QPlatformDropQtResponse(accepted, action));
+ }
+ 
+-void QWaylandDrag::setResponse(const QPlatformDragQtResponse &response)
++void QWaylandDrag::setResponse(const QPlatformDropQtResponse &response)
+ {
+     setCanDrop(response.isAccepted());
+ 
+     if (canDrop()) {
+-        updateCursor(defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers()));
++        updateCursor(response.acceptedAction());
+     } else {
+         updateCursor(Qt::IgnoreAction);
+     }
+ }
+ 
+-void QWaylandDrag::finishDrag(const QPlatformDropQtResponse &response)
++void QWaylandDrag::setDropResponse(const QPlatformDropQtResponse &response)
+ {
+     setExecutedDropAction(response.acceptedAction());
++}
++
++void QWaylandDrag::finishDrag()
++{
+     QKeyEvent event(QEvent::KeyPress, Qt::Key_Escape, Qt::NoModifier);
+     eventFilter(shapedPixmapWindow(), &event);
++
++    if (drag())
++        drag()->deleteLater();
++}
++
++bool QWaylandDrag::ownsDragObject() const
++{
++    return true;
+ }
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddnd_p.h b/qtwayland/src/client/qwaylanddnd_p.h
+index 474fe2ab..46f629ac 100644
+--- a/qtwayland/src/client/qwaylanddnd_p.h
++++ b/qtwayland/src/client/qwaylanddnd_p.h
+@@ -71,9 +71,10 @@ public:
+     QWaylandDrag(QWaylandDisplay *display);
+     ~QWaylandDrag() override;
+ 
+-    void updateTarget(const QString &mimeType);
+-    void setResponse(const QPlatformDragQtResponse &response);
+-    void finishDrag(const QPlatformDropQtResponse &response);
++    void setResponse(bool accepted);
++    void setResponse(const QPlatformDropQtResponse &response);
++    void setDropResponse(const QPlatformDropQtResponse &response);
++    void finishDrag();
+ 
+ protected:
+     void startDrag() override;
+@@ -82,6 +83,7 @@ protected:
+     void drop(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods) override;
+     void endDrag() override;
+ 
++    bool ownsDragObject() const override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+diff --git a/qtwayland/src/client/qwaylandinputdevice.cpp b/qtwayland/src/client/qwaylandinputdevice.cpp
+index 613fe862..4b90de84 100644
+--- a/qtwayland/src/client/qwaylandinputdevice.cpp
++++ b/qtwayland/src/client/qwaylandinputdevice.cpp
+@@ -685,6 +685,11 @@ public:
+ 
+ void QWaylandInputDevice::Pointer::pointer_leave(uint32_t time, struct wl_surface *surface)
+ {
++    invalidateFocus();
++    mButtons = Qt::NoButton;
++
++    mParent->mTime = time;
++
+     // The event may arrive after destroying the window, indicated by
+     // a null surface.
+     if (!surface)
+@@ -696,11 +701,6 @@ void QWaylandInputDevice::Pointer::pointer_leave(uint32_t time, struct wl_surfac
+ 
+     if (!QWaylandWindow::mouseGrab())
+         setFrameEvent(new LeaveEvent(window, mSurfacePos, mGlobalPos));
+-
+-    invalidateFocus();
+-    mButtons = Qt::NoButton;
+-
+-    mParent->mTime = time;
+ }
+ 
+ class MotionEvent : public QWaylandPointerEvent
+@@ -1300,14 +1300,6 @@ void QWaylandInputDevice::Keyboard::handleFocusDestroyed()
+ void QWaylandInputDevice::Keyboard::handleFocusLost()
+ {
+     mFocus = nullptr;
+-#if QT_CONFIG(clipboard)
+-    if (auto *dataDevice = mParent->dataDevice())
+-        dataDevice->invalidateSelectionOffer();
+-#endif
+-#if QT_CONFIG(wayland_client_primary_selection)
+-    if (auto *device = mParent->primarySelectionDevice())
+-        device->invalidateSelectionOffer();
+-#endif
+     mParent->mQDisplay->handleKeyboardFocusChanged(mParent);
+     mRepeatTimer.stop();
+ }
+@@ -1396,6 +1388,7 @@ void QWaylandInputDevice::Touch::touch_cancel()
+     if (touchExt)
+         touchExt->touchCanceled();
+ 
++    mFocus = nullptr;
+     QWindowSystemInterface::handleTouchCancelEvent(nullptr, mParent->mTouchDevice);
+ }
+ 
+diff --git a/qtwayland/src/client/qwaylandintegration.cpp b/qtwayland/src/client/qwaylandintegration.cpp
+index c53ccb78..54861600 100644
+--- a/qtwayland/src/client/qwaylandintegration.cpp
++++ b/qtwayland/src/client/qwaylandintegration.cpp
+@@ -125,6 +125,9 @@ QWaylandIntegration::QWaylandIntegration()
+ #endif
+ 
+     reconfigureInputContext();
++
++    QWaylandWindow::fixedToplevelPositions =
++            !qEnvironmentVariableIsSet("QT_WAYLAND_DISABLE_FIXED_POSITIONS");
+ }
+ 
+ QWaylandIntegration::~QWaylandIntegration()
+@@ -192,14 +195,18 @@ QAbstractEventDispatcher *QWaylandIntegration::createEventDispatcher() const
+ 
+ void QWaylandIntegration::initialize()
+ {
++    mDisplay->initEventThread();
++
++    // Call after eventDispatcher is fully connected, for QWaylandDisplay::forceRoundTrip()
++    mDisplay->initialize();
++
++    // But the aboutToBlock() and awake() should be connected after initializePlatform().
++    // Otherwise the connected flushRequests() may consumes up all events before processEvents starts to wait,
++    // so that processEvents(QEventLoop::WaitForMoreEvents) may be blocked in the forceRoundTrip().
+     QAbstractEventDispatcher *dispatcher = QGuiApplicationPrivate::eventDispatcher;
+     QObject::connect(dispatcher, SIGNAL(aboutToBlock()), mDisplay.data(), SLOT(flushRequests()));
+     QObject::connect(dispatcher, SIGNAL(awake()), mDisplay.data(), SLOT(flushRequests()));
+ 
+-    int fd = wl_display_get_fd(mDisplay->wl_display());
+-    QSocketNotifier *sn = new QSocketNotifier(fd, QSocketNotifier::Read, mDisplay.data());
+-    QObject::connect(sn, SIGNAL(activated(QSocketDescriptor)), mDisplay.data(), SLOT(flushRequests()));
+-
+     // Qt does not support running with no screens
+     mDisplay->ensureScreen();
+ }
+@@ -262,6 +269,14 @@ QWaylandDisplay *QWaylandIntegration::display() const
+     return mDisplay.data();
+ }
+ 
++Qt::KeyboardModifiers QWaylandIntegration::queryKeyboardModifiers() const
++{
++    if (auto *seat = mDisplay->currentInputDevice()) {
++        return seat->modifiers();
++    }
++    return Qt::NoModifier;
++}
++
+ QList<int> QWaylandIntegration::possibleKeys(const QKeyEvent *event) const
+ {
+     if (auto *seat = mDisplay->currentInputDevice())
+@@ -479,7 +494,7 @@ void QWaylandIntegration::reconfigureInputContext()
+     }
+ #endif
+ 
+-    qCDebug(lcQpaWayland) << "using input method:" << inputContext()->metaObject()->className();
++    qCDebug(lcQpaWayland) << "using input method:" << (inputContext() ? inputContext()->metaObject()->className() : "<none>");
+ }
+ 
+ QWaylandShellIntegration *QWaylandIntegration::createShellIntegration(const QString &integrationName)
+diff --git a/qtwayland/src/client/qwaylandintegration_p.h b/qtwayland/src/client/qwaylandintegration_p.h
+index ff70ae25..73b80658 100644
+--- a/qtwayland/src/client/qwaylandintegration_p.h
++++ b/qtwayland/src/client/qwaylandintegration_p.h
+@@ -107,6 +107,8 @@ public:
+ 
+     QWaylandDisplay *display() const;
+ 
++    Qt::KeyboardModifiers queryKeyboardModifiers() const override;
++
+     QList<int> possibleKeys(const QKeyEvent *event) const override;
+ 
+     QStringList themeNames() const override;
+diff --git a/qtwayland/src/client/qwaylandprimaryselectionv1.cpp b/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
+index 832f9678..ea508771 100644
+--- a/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
++++ b/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
+@@ -54,11 +54,6 @@ QWaylandPrimarySelectionDeviceManagerV1::QWaylandPrimarySelectionDeviceManagerV1
+     : zwp_primary_selection_device_manager_v1(display->wl_registry(), id, qMin(version, uint(1)))
+     , m_display(display)
+ {
+-    // Create devices for all seats.
+-    // This only works if we get the global before all devices
+-    const auto seats = m_display->inputDevices();
+-    for (auto *seat : seats)
+-        seat->setPrimarySelectionDevice(createDevice(seat));
+ }
+ 
+ QWaylandPrimarySelectionDeviceV1 *QWaylandPrimarySelectionDeviceManagerV1::createDevice(QWaylandInputDevice *seat)
+diff --git a/qtwayland/src/client/qwaylandscreen.cpp b/qtwayland/src/client/qwaylandscreen.cpp
+index 6cb337de..5537dafd 100644
+--- a/qtwayland/src/client/qwaylandscreen.cpp
++++ b/qtwayland/src/client/qwaylandscreen.cpp
+@@ -60,7 +60,7 @@ QWaylandXdgOutputManagerV1::QWaylandXdgOutputManagerV1(QWaylandDisplay* display,
+ }
+ 
+ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uint32_t id)
+-    : QtWayland::wl_output(waylandDisplay->wl_registry(), id, qMin(version, 2))
++    : QtWayland::wl_output(waylandDisplay->wl_registry(), id, qMin(version, 3))
+     , m_outputId(id)
+     , mWaylandDisplay(waylandDisplay)
+     , mOutputName(QStringLiteral("Screen%1").arg(id))
+@@ -72,7 +72,7 @@ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uin
+         qCWarning(lcQpaWayland) << "wl_output done event not supported by compositor,"
+                                 << "QScreen may not work correctly";
+         mWaylandDisplay->forceRoundTrip(); // Give the compositor a chance to send geometry etc.
+-        mOutputDone = true; // Fake the done event
++        mProcessedEvents |= OutputDoneEvent; // Fake the done event
+         maybeInitialize();
+     }
+ }
+@@ -81,16 +81,29 @@ QWaylandScreen::~QWaylandScreen()
+ {
+     if (zxdg_output_v1::isInitialized())
+         zxdg_output_v1::destroy();
++    if (wl_output::isInitialized() && wl_output_get_version(wl_output::object()) >= WL_OUTPUT_RELEASE_SINCE_VERSION)
++        wl_output::release();
++}
++
++uint QWaylandScreen::requiredEvents() const
++{
++    uint ret = OutputDoneEvent;
++
++    if (mWaylandDisplay->xdgOutputManager()) {
++        ret |= XdgOutputNameEvent;
++
++        if (mWaylandDisplay->xdgOutputManager()->version() < 3)
++            ret |= XdgOutputDoneEvent;
++    }
++    return ret;
+ }
+ 
+ void QWaylandScreen::maybeInitialize()
+ {
+     Q_ASSERT(!mInitialized);
+ 
+-    if (!mOutputDone)
+-        return;
+-
+-    if (mWaylandDisplay->xdgOutputManager() && !mXdgOutputDone)
++    const uint requiredEvents = this->requiredEvents();
++    if ((mProcessedEvents & requiredEvents) != requiredEvents)
+         return;
+ 
+     mInitialized = true;
+@@ -276,9 +289,8 @@ void QWaylandScreen::output_scale(int32_t factor)
+ 
+ void QWaylandScreen::output_done()
+ {
+-    mOutputDone = true;
+-    if (zxdg_output_v1::isInitialized() && mWaylandDisplay->xdgOutputManager()->version() >= 3)
+-        mXdgOutputDone = true;
++    mProcessedEvents |= OutputDoneEvent;
++
+     if (mInitialized) {
+         updateOutputProperties();
+         if (zxdg_output_v1::isInitialized())
+@@ -339,7 +351,7 @@ void QWaylandScreen::zxdg_output_v1_done()
+     if (Q_UNLIKELY(mWaylandDisplay->xdgOutputManager()->version() >= 3))
+         qWarning(lcQpaWayland) << "zxdg_output_v1.done received on version 3 or newer, this is most likely a bug in the compositor";
+ 
+-    mXdgOutputDone = true;
++    mProcessedEvents |= XdgOutputDoneEvent;
+     if (mInitialized)
+         updateXdgOutputProperties();
+     else
+@@ -348,7 +360,11 @@ void QWaylandScreen::zxdg_output_v1_done()
+ 
+ void QWaylandScreen::zxdg_output_v1_name(const QString &name)
+ {
++    if (Q_UNLIKELY(mInitialized))
++        qWarning(lcQpaWayland) << "zxdg_output_v1.name received after output has been initialized, this is most likely a bug in the compositor";
++
+     mOutputName = name;
++    mProcessedEvents |= XdgOutputNameEvent;
+ }
+ 
+ void QWaylandScreen::updateXdgOutputProperties()
+diff --git a/qtwayland/src/client/qwaylandscreen_p.h b/qtwayland/src/client/qwaylandscreen_p.h
+index df1c94f2..050cfdc0 100644
+--- a/qtwayland/src/client/qwaylandscreen_p.h
++++ b/qtwayland/src/client/qwaylandscreen_p.h
+@@ -116,6 +116,13 @@ public:
+     static QWaylandScreen *fromWlOutput(::wl_output *output);
+ 
+ private:
++    enum Event : uint {
++        XdgOutputDoneEvent = 0x1,
++        OutputDoneEvent = 0x2,
++        XdgOutputNameEvent = 0x4,
++    };
++    uint requiredEvents() const;
++
+     void output_mode(uint32_t flags, int width, int height, int refresh) override;
+     void output_geometry(int32_t x, int32_t y,
+                          int32_t width, int32_t height,
+@@ -148,8 +155,7 @@ private:
+     QSize mPhysicalSize;
+     QString mOutputName;
+     Qt::ScreenOrientation m_orientation = Qt::PrimaryOrientation;
+-    bool mOutputDone = false;
+-    bool mXdgOutputDone = false;
++    uint mProcessedEvents = 0;
+     bool mInitialized = false;
+ 
+ #if QT_CONFIG(cursor)
+diff --git a/qtwayland/src/client/qwaylandshmbackingstore.cpp b/qtwayland/src/client/qwaylandshmbackingstore.cpp
+index dc7ff670..41cffdf7 100644
+--- a/qtwayland/src/client/qwaylandshmbackingstore.cpp
++++ b/qtwayland/src/client/qwaylandshmbackingstore.cpp
+@@ -52,6 +52,7 @@
+ 
+ #include <QtWaylandClient/private/wayland-wayland-client-protocol.h>
+ 
++#include <fcntl.h>
+ #include <unistd.h>
+ #include <sys/mman.h>
+ 
+@@ -61,6 +62,9 @@
+ #  ifndef MFD_CLOEXEC
+ #    define MFD_CLOEXEC     0x0001U
+ #  endif
++#  ifndef MFD_ALLOW_SEALING
++#    define MFD_ALLOW_SEALING 0x0002U
++#  endif
+ #endif
+ 
+ QT_BEGIN_NAMESPACE
+@@ -74,8 +78,10 @@ QWaylandShmBuffer::QWaylandShmBuffer(QWaylandDisplay *display,
+     int alloc = stride * size.height();
+     int fd = -1;
+ 
+-#ifdef SYS_memfd_create
+-    fd = syscall(SYS_memfd_create, "wayland-shm", MFD_CLOEXEC);
++#if defined(SYS_memfd_create) && defined(F_SEAL_SEAL)
++    fd = syscall(SYS_memfd_create, "wayland-shm", MFD_CLOEXEC | MFD_ALLOW_SEALING);
++    if (fd >= 0)
++        fcntl(fd, F_ADD_SEALS, F_SEAL_SHRINK | F_SEAL_SEAL);
+ #endif
+ 
+     QScopedPointer<QFile> filePointer;
+diff --git a/qtwayland/src/client/qwaylandwindow.cpp b/qtwayland/src/client/qwaylandwindow.cpp
+index cb82857a..fb2c59dc 100644
+--- a/qtwayland/src/client/qwaylandwindow.cpp
++++ b/qtwayland/src/client/qwaylandwindow.cpp
+@@ -76,7 +76,6 @@ QWaylandWindow *QWaylandWindow::mMouseGrab = nullptr;
+ QWaylandWindow::QWaylandWindow(QWindow *window, QWaylandDisplay *display)
+     : QPlatformWindow(window)
+     , mDisplay(display)
+-    , mFrameQueue(mDisplay->createFrameQueue())
+     , mResizeAfterSwap(qEnvironmentVariableIsSet("QT_WAYLAND_RESIZE_AFTER_SWAP"))
+ {
+     {
+@@ -95,9 +94,6 @@ QWaylandWindow::QWaylandWindow(QWindow *window, QWaylandDisplay *display)
+ 
+ QWaylandWindow::~QWaylandWindow()
+ {
+-    mDisplay->destroyFrameQueue(mFrameQueue);
+-    mDisplay->handleWindowDestroyed(this);
+-
+     delete mWindowDecoration;
+ 
+     if (mSurface)
+@@ -243,6 +239,7 @@ bool QWaylandWindow::shouldCreateSubSurface() const
+ 
+ void QWaylandWindow::reset()
+ {
++    closeChildPopups();
+     delete mShellSurface;
+     mShellSurface = nullptr;
+     delete mSubSurfaceWindow;
+@@ -255,17 +252,22 @@ void QWaylandWindow::reset()
+         mSurface.reset();
+     }
+ 
+-    if (mFrameCallback) {
+-        wl_callback_destroy(mFrameCallback);
+-        mFrameCallback = nullptr;
+-    }
++    {
++        QMutexLocker lock(&mFrameSyncMutex);
++        if (mFrameCallback) {
++            wl_callback_destroy(mFrameCallback);
++            mFrameCallback = nullptr;
++        }
+ 
+-    mFrameCallbackElapsedTimer.invalidate();
+-    mWaitingForFrameCallback = false;
++        mFrameCallbackElapsedTimer.invalidate();
++        mWaitingForFrameCallback = false;
++    }
+     mFrameCallbackTimedOut = false;
+ 
+     mMask = QRegion();
+     mQueuedBuffer = nullptr;
++
++    mDisplay->handleWindowDestroyed(this);
+ }
+ 
+ QWaylandWindow *QWaylandWindow::fromWlSurface(::wl_surface *surface)
+@@ -351,19 +353,25 @@ void QWaylandWindow::setGeometry_helper(const QRect &rect)
+     }
+ }
+ 
+-void QWaylandWindow::setGeometry(const QRect &rect)
++void QWaylandWindow::setGeometry(const QRect &r)
+ {
++    auto rect = r;
++    if (fixedToplevelPositions && !QPlatformWindow::parent() && window()->type() != Qt::Popup
++        && window()->type() != Qt::ToolTip) {
++        rect.moveTo(screen()->geometry().topLeft());
++    }
+     setGeometry_helper(rect);
+ 
+     if (window()->isVisible() && rect.isValid()) {
+         if (mWindowDecoration)
+             mWindowDecoration->update();
+ 
+-        if (mResizeAfterSwap && windowType() == Egl && mSentInitialResize)
++        if (mResizeAfterSwap && windowType() == Egl && mSentInitialResize) {
++            QMutexLocker lock(&mResizeLock);
+             mResizeDirty = true;
+-        else
++        } else {
+             QWindowSystemInterface::handleGeometryChange(window(), geometry());
+-
++        }
+         mSentInitialResize = true;
+     }
+     QRect exposeGeometry(QPoint(), geometry().size());
+@@ -374,7 +382,7 @@ void QWaylandWindow::setGeometry(const QRect &rect)
+         mShellSurface->setWindowGeometry(windowContentGeometry());
+ 
+     if (isOpaque() && mMask.isEmpty())
+-        setOpaqueArea(rect);
++        setOpaqueArea(QRect(QPoint(0, 0), rect.size()));
+ }
+ 
+ void QWaylandWindow::resizeFromApplyConfigure(const QSize &sizeWithMargins, const QPoint &offset)
+@@ -399,21 +407,6 @@ void QWaylandWindow::sendExposeEvent(const QRect &rect)
+     mLastExposeGeometry = rect;
+ }
+ 
+-
+-static QVector<QPointer<QWaylandWindow>> activePopups;
+-
+-void QWaylandWindow::closePopups(QWaylandWindow *parent)
+-{
+-    while (!activePopups.isEmpty()) {
+-        auto popup = activePopups.takeLast();
+-        if (popup.isNull())
+-            continue;
+-        if (popup.data() == parent)
+-            return;
+-        popup->reset();
+-    }
+-}
+-
+ QPlatformScreen *QWaylandWindow::calculateScreenFromSurfaceEvents() const
+ {
+     QReadLocker lock(&mSurfaceLock);
+@@ -433,10 +426,7 @@ void QWaylandWindow::setVisible(bool visible)
+     lastVisible = visible;
+ 
+     if (visible) {
+-        if (window()->type() == Qt::Popup || window()->type() == Qt::ToolTip)
+-            activePopups << this;
+         initWindow();
+-        mDisplay->flushRequests();
+ 
+         setGeometry(windowGeometry());
+         // Don't flush the events here, or else the newly visible window may start drawing, but since
+@@ -444,7 +434,6 @@ void QWaylandWindow::setVisible(bool visible)
+         // QWaylandShmBackingStore::beginPaint().
+     } else {
+         sendExposeEvent(QRect());
+-        closePopups(this);
+         reset();
+     }
+ }
+@@ -556,12 +545,12 @@ void QWaylandWindow::sendRecursiveExposeEvent()
+ 
+ void QWaylandWindow::attach(QWaylandBuffer *buffer, int x, int y)
+ {
+-    Q_ASSERT(!buffer->committed());
+     QReadLocker locker(&mSurfaceLock);
+     if (mSurface == nullptr)
+         return;
+ 
+     if (buffer) {
++        Q_ASSERT(!buffer->committed());
+         handleUpdate();
+         buffer->setBusy();
+ 
+@@ -583,7 +572,11 @@ void QWaylandWindow::damage(const QRect &rect)
+     if (mSurface == nullptr)
+         return;
+ 
+-    mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    const int s = scale();
++    if (mDisplay->compositorVersion() >= 4)
++        mSurface->damage_buffer(s * rect.x(), s * rect.y(), s * rect.width(), s * rect.height());
++    else
++        mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
+ }
+ 
+ void QWaylandWindow::safeCommit(QWaylandBuffer *buffer, const QRegion &damage)
+@@ -619,8 +612,14 @@ void QWaylandWindow::commit(QWaylandBuffer *buffer, const QRegion &damage)
+         return;
+ 
+     attachOffset(buffer);
+-    for (const QRect &rect: damage)
+-        mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    if (mDisplay->compositorVersion() >= 4) {
++        const int s = scale();
++        for (const QRect &rect: damage)
++            mSurface->damage_buffer(s * rect.x(), s * rect.y(), s * rect.width(), s * rect.height());
++    } else {
++        for (const QRect &rect: damage)
++            mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    }
+     Q_ASSERT(!buffer->committed());
+     buffer->setCommitted();
+     mSurface->commit();
+@@ -635,42 +634,53 @@ void QWaylandWindow::commit()
+ 
+ const wl_callback_listener QWaylandWindow::callbackListener = {
+     [](void *data, wl_callback *callback, uint32_t time) {
+-        Q_UNUSED(callback);
+         Q_UNUSED(time);
+         auto *window = static_cast<QWaylandWindow*>(data);
+-        window->handleFrameCallback();
++        window->handleFrameCallback(callback);
+     }
+ };
+ 
+-void QWaylandWindow::handleFrameCallback()
++void QWaylandWindow::handleFrameCallback(wl_callback* callback)
+ {
++    QMutexLocker locker(&mFrameSyncMutex);
++    if (!mFrameCallback) {
++        // This means the callback is already unset by QWaylandWindow::reset.
++        // The wl_callback object will be destroyed there too.
++        return;
++    }
++    Q_ASSERT(callback == mFrameCallback);
++    wl_callback_destroy(callback);
++    mFrameCallback = nullptr;
++
+     mWaitingForFrameCallback = false;
+     mFrameCallbackElapsedTimer.invalidate();
+ 
+     // The rest can wait until we can run it on the correct thread
+-    if (!mWaitingForUpdateDelivery) {
+-        auto doHandleExpose = [this]() {
+-            bool wasExposed = isExposed();
+-            mFrameCallbackTimedOut = false;
+-            if (!wasExposed && isExposed()) // Did setting mFrameCallbackTimedOut make the window exposed?
+-                sendExposeEvent(QRect(QPoint(), geometry().size()));
+-            if (wasExposed && hasPendingUpdateRequest())
+-                deliverUpdateRequest();
+-
+-            mWaitingForUpdateDelivery = false;
+-        };
++    auto doHandleExpose = [this]() {
++        mWaitingForUpdateDelivery.storeRelease(false);
++        bool wasExposed = isExposed();
++        mFrameCallbackTimedOut = false;
++        if (!wasExposed && isExposed()) // Did setting mFrameCallbackTimedOut make the window exposed?
++            sendExposeEvent(QRect(QPoint(), geometry().size()));
++        if (wasExposed && hasPendingUpdateRequest())
++            deliverUpdateRequest();
++    };
+ 
++    if (mWaitingForUpdateDelivery.testAndSetAcquire(false, true)) {
+         // Queued connection, to make sure we don't call handleUpdate() from inside waitForFrameSync()
+         // in the single-threaded case.
+-        mWaitingForUpdateDelivery = true;
+         QMetaObject::invokeMethod(this, doHandleExpose, Qt::QueuedConnection);
+     }
++
++    mFrameSyncWait.notify_all();
+ }
+ 
+ bool QWaylandWindow::waitForFrameSync(int timeout)
+ {
+-    QMutexLocker locker(mFrameQueue.mutex);
+-    mDisplay->dispatchQueueWhile(mFrameQueue.queue, [&]() { return mWaitingForFrameCallback; }, timeout);
++    QMutexLocker locker(&mFrameSyncMutex);
++
++    QDeadlineTimer deadline(timeout);
++    while (mWaitingForFrameCallback && mFrameSyncWait.wait(&mFrameSyncMutex, deadline)) { }
+ 
+     if (mWaitingForFrameCallback) {
+         qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
+@@ -868,6 +878,17 @@ bool QWaylandWindow::createDecoration()
+             subsurf->set_position(pos.x() + m.left(), pos.y() + m.top());
+         }
+         sendExposeEvent(QRect(QPoint(), geometry().size()));
++
++        // This is a special case where the buffer is recreated, but since
++        // the content rect remains the same, the widgets remain the same
++        // size and are not redrawn, leaving the new buffer empty. As a simple
++        // work-around, we trigger a full extra update whenever the client-side
++        // window decorations are toggled while the window is showing.
++        // Note: createDecoration() is sometimes called from the render thread
++        // of Qt Quick. This is essentially wrong and could potentially cause problems,
++        // but until the underlying issue has been fixed, we have to use invokeMethod()
++        // here to avoid asserts.
++        QMetaObject::invokeMethod(window(), &QWindow::requestUpdate);
+     }
+ 
+     return mWindowDecoration;
+@@ -1023,6 +1044,13 @@ void QWaylandWindow::handleScreensChanged()
+ 
+     QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->QPlatformScreen::screen());
+     mLastReportedScreen = newScreen;
++    if (fixedToplevelPositions && !QPlatformWindow::parent() && window()->type() != Qt::Popup
++        && window()->type() != Qt::ToolTip
++        && geometry().topLeft() != newScreen->geometry().topLeft()) {
++        auto geometry = this->geometry();
++        geometry.moveTo(newScreen->geometry().topLeft());
++        setGeometry(geometry);
++    }
+ 
+     int scale = newScreen->isPlaceholder() ? 1 : static_cast<QWaylandScreen *>(newScreen)->scale();
+     if (scale != mScale) {
+@@ -1094,10 +1122,18 @@ bool QWaylandWindow::setMouseGrabEnabled(bool grab)
+     return true;
+ }
+ 
++Qt::WindowStates QWaylandWindow::windowStates() const
++{
++    return mLastReportedWindowStates;
++}
++
+ void QWaylandWindow::handleWindowStatesChanged(Qt::WindowStates states)
+ {
+     createDecoration();
+-    QWindowSystemInterface::handleWindowStateChanged(window(), states, mLastReportedWindowStates);
++    Qt::WindowStates statesWithoutActive = states & ~Qt::WindowActive;
++    Qt::WindowStates lastStatesWithoutActive = mLastReportedWindowStates & ~Qt::WindowActive;
++    QWindowSystemInterface::handleWindowStateChanged(window(), statesWithoutActive,
++                                                     lastStatesWithoutActive);
+     mLastReportedWindowStates = states;
+ }
+ 
+@@ -1139,19 +1175,24 @@ void QWaylandWindow::timerEvent(QTimerEvent *event)
+     if (event->timerId() != mFrameCallbackCheckIntervalTimerId)
+         return;
+ 
+-    bool callbackTimerExpired = mFrameCallbackElapsedTimer.hasExpired(mFrameCallbackTimeout);
+-    if (!mFrameCallbackElapsedTimer.isValid() || callbackTimerExpired ) {
+-        killTimer(mFrameCallbackCheckIntervalTimerId);
+-        mFrameCallbackCheckIntervalTimerId = -1;
+-    }
+-    if (mFrameCallbackElapsedTimer.isValid() && callbackTimerExpired) {
+-        mFrameCallbackElapsedTimer.invalidate();
++    {
++        QMutexLocker lock(&mFrameSyncMutex);
+ 
+-        qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
+-        mFrameCallbackTimedOut = true;
+-        mWaitingForUpdate = false;
+-        sendExposeEvent(QRect());
++        bool callbackTimerExpired = mFrameCallbackElapsedTimer.hasExpired(mFrameCallbackTimeout);
++        if (!mFrameCallbackElapsedTimer.isValid() || callbackTimerExpired ) {
++            killTimer(mFrameCallbackCheckIntervalTimerId);
++            mFrameCallbackCheckIntervalTimerId = -1;
++        }
++        if (!mFrameCallbackElapsedTimer.isValid() || !callbackTimerExpired) {
++            return;
++        }
++        mFrameCallbackElapsedTimer.invalidate();
+     }
++
++    qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
++    mFrameCallbackTimedOut = true;
++    mWaitingForUpdate = false;
++    sendExposeEvent(QRect());
+ }
+ 
+ void QWaylandWindow::requestUpdate()
+@@ -1160,8 +1201,11 @@ void QWaylandWindow::requestUpdate()
+     Q_ASSERT(hasPendingUpdateRequest()); // should be set by QPA
+ 
+     // If we have a frame callback all is good and will be taken care of there
+-    if (mWaitingForFrameCallback)
+-        return;
++    {
++        QMutexLocker locker(&mFrameSyncMutex);
++        if (mWaitingForFrameCallback)
++            return;
++    }
+ 
+     // If we've already called deliverUpdateRequest(), but haven't seen any attach+commit/swap yet
+     // This is a somewhat redundant behavior and might indicate a bug in the calling code, so log
+@@ -1174,7 +1218,12 @@ void QWaylandWindow::requestUpdate()
+     // so use invokeMethod to delay the delivery a bit.
+     QMetaObject::invokeMethod(this, [this] {
+         // Things might have changed in the meantime
+-        if (hasPendingUpdateRequest() && !mWaitingForFrameCallback)
++        {
++            QMutexLocker locker(&mFrameSyncMutex);
++            if (mWaitingForFrameCallback)
++                return;
++        }
++        if (hasPendingUpdateRequest())
+             deliverUpdateRequest();
+     }, Qt::QueuedConnection);
+ }
+@@ -1185,19 +1234,18 @@ void QWaylandWindow::requestUpdate()
+ void QWaylandWindow::handleUpdate()
+ {
+     qCDebug(lcWaylandBackingstore) << "handleUpdate" << QThread::currentThread();
++
+     // TODO: Should sync subsurfaces avoid requesting frame callbacks?
+     QReadLocker lock(&mSurfaceLock);
+     if (!mSurface)
+         return;
+ 
+-    if (mFrameCallback) {
+-        wl_callback_destroy(mFrameCallback);
+-        mFrameCallback = nullptr;
+-    }
++    QMutexLocker locker(&mFrameSyncMutex);
++    if (mWaitingForFrameCallback)
++        return;
+ 
+-    QMutexLocker locker(mFrameQueue.mutex);
+     struct ::wl_surface *wrappedSurface = reinterpret_cast<struct ::wl_surface *>(wl_proxy_create_wrapper(mSurface->object()));
+-    wl_proxy_set_queue(reinterpret_cast<wl_proxy *>(wrappedSurface), mFrameQueue.queue);
++    wl_proxy_set_queue(reinterpret_cast<wl_proxy *>(wrappedSurface), mDisplay->frameEventQueue());
+     mFrameCallback = wl_surface_frame(wrappedSurface);
+     wl_proxy_wrapper_destroy(wrappedSurface);
+     wl_callback_add_listener(mFrameCallback, &QWaylandWindow::callbackListener, this);
+@@ -1207,6 +1255,8 @@ void QWaylandWindow::handleUpdate()
+     // Start a timer for handling the case when the compositor stops sending frame callbacks.
+     if (mFrameCallbackTimeout > 0) {
+         QMetaObject::invokeMethod(this, [this] {
++            QMutexLocker locker(&mFrameSyncMutex);
++
+             if (mWaitingForFrameCallback) {
+                 if (mFrameCallbackCheckIntervalTimerId < 0)
+                     mFrameCallbackCheckIntervalTimerId = startTimer(mFrameCallbackTimeout);
+@@ -1267,6 +1317,20 @@ void QWaylandWindow::setOpaqueArea(const QRegion &opaqueArea)
+     wl_region_destroy(region);
+ }
+ 
++void QWaylandWindow::addChildPopup(QWaylandWindow *surface) {
++    mChildPopups.append(surface);
++}
++
++void QWaylandWindow::removeChildPopup(QWaylandWindow *surface) {
++    mChildPopups.removeAll(surface);
++}
++
++void QWaylandWindow::closeChildPopups() {
++    while (!mChildPopups.isEmpty()) {
++        auto popup = mChildPopups.takeLast();
++        popup->reset();
++    }
++}
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/client/qwaylandwindow_p.h b/qtwayland/src/client/qwaylandwindow_p.h
+index 01337cff..2f219d8c 100644
+--- a/qtwayland/src/client/qwaylandwindow_p.h
++++ b/qtwayland/src/client/qwaylandwindow_p.h
+@@ -98,6 +98,9 @@ public:
+     QWaylandWindow(QWindow *window, QWaylandDisplay *display);
+     ~QWaylandWindow() override;
+ 
++    // Keep Toplevels position on the top left corner of their screen
++    static inline bool fixedToplevelPositions = true;
++
+     virtual WindowType windowType() const = 0;
+     virtual void ensureSize();
+     WId winId() const override;
+@@ -148,6 +151,7 @@ public:
+     void setWindowState(Qt::WindowStates states) override;
+     void setWindowFlags(Qt::WindowFlags flags) override;
+     void handleWindowStatesChanged(Qt::WindowStates states);
++    Qt::WindowStates windowStates() const;
+ 
+     void raise() override;
+     void lower() override;
+@@ -206,6 +210,10 @@ public:
+     void handleUpdate();
+     void deliverUpdateRequest() override;
+ 
++    void addChildPopup(QWaylandWindow* child);
++    void removeChildPopup(QWaylandWindow* child);
++    void closeChildPopups();
++
+ public slots:
+     void applyConfigure();
+ 
+@@ -215,7 +223,11 @@ signals:
+ 
+ protected:
+     QWaylandDisplay *mDisplay = nullptr;
++
++    // mSurface can be written by the main thread. Other threads should claim a read lock for access
++    mutable QReadWriteLock mSurfaceLock;
+     QScopedPointer<QWaylandSurface> mSurface;
++
+     QWaylandShellSurface *mShellSurface = nullptr;
+     QWaylandSubSurface *mSubSurfaceWindow = nullptr;
+     QVector<QWaylandSubSurface *> mChildren;
+@@ -225,13 +237,14 @@ protected:
+     Qt::MouseButtons mMousePressedInContentArea = Qt::NoButton;
+ 
+     WId mWindowId;
+-    bool mWaitingForFrameCallback = false;
+     bool mFrameCallbackTimedOut = false; // Whether the frame callback has timed out
+-    bool mWaitingForUpdateDelivery = false;
+     int mFrameCallbackCheckIntervalTimerId = -1;
+-    QElapsedTimer mFrameCallbackElapsedTimer;
+-    struct ::wl_callback *mFrameCallback = nullptr;
+-    QWaylandDisplay::FrameQueue mFrameQueue;
++    QAtomicInt mWaitingForUpdateDelivery = false;
++
++    bool mWaitingForFrameCallback = false; // Protected by mFrameSyncMutex
++    QElapsedTimer mFrameCallbackElapsedTimer; // Protected by mFrameSyncMutex
++    struct ::wl_callback *mFrameCallback = nullptr; // Protected by mFrameSyncMutex
++    QMutex mFrameSyncMutex;
+     QWaitCondition mFrameSyncWait;
+ 
+     // True when we have called deliverRequestUpdate, but the client has not yet attached a new buffer
+@@ -261,6 +274,8 @@ protected:
+     QWaylandBuffer *mQueuedBuffer = nullptr;
+     QRegion mQueuedBufferDamage;
+ 
++    QList<QPointer<QWaylandWindow>> mChildPopups;
++
+ private:
+     void setGeometry_helper(const QRect &rect);
+     void initWindow();
+@@ -283,12 +298,10 @@ private:
+     QRect mLastExposeGeometry;
+ 
+     static const wl_callback_listener callbackListener;
+-    void handleFrameCallback();
++    void handleFrameCallback(struct ::wl_callback* callback);
+ 
+     static QWaylandWindow *mMouseGrab;
+ 
+-    mutable QReadWriteLock mSurfaceLock;
+-
+     friend class QWaylandSubSurface;
+ };
+ 
+diff --git a/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h b/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
+index ccad0048..4cc9b3b8 100644
+--- a/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
++++ b/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
+@@ -73,11 +73,10 @@ public:
+         return true;
+     }
+     virtual QWaylandShellSurface *createShellSurface(QWaylandWindow *window) = 0;
++    // kept for binary compat with layer-shell-qt
+     virtual void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) {
+-        if (newFocus)
+-            m_display->handleWindowActivated(newFocus);
+-        if (oldFocus)
+-            m_display->handleWindowDeactivated(oldFocus);
++        Q_UNUSED(newFocus);
++        Q_UNUSED(oldFocus);
+     }
+     virtual void *nativeResourceForWindow(const QByteArray &resource, QWindow *window) {
+         Q_UNUSED(resource);
+diff --git a/qtwayland/src/compositor/configure.json b/qtwayland/src/compositor/configure.json
+index bcfd5215..da95d07b 100644
+--- a/qtwayland/src/compositor/configure.json
++++ b/qtwayland/src/compositor/configure.json
+@@ -7,6 +7,31 @@
+     "testDir": "../../config.tests",
+ 
+     "libraries": {
++        "wayland-client": {
++            "label": "Wayland client library",
++            "headers": "wayland-version.h",
++            "test": {
++                "main": [
++                    "#if WAYLAND_VERSION_MAJOR < 1",
++                    "# error Wayland 1.8.0 or higher required",
++                    "#endif",
++                    "#if WAYLAND_VERSION_MAJOR == 1",
++                    "# if WAYLAND_VERSION_MINOR < 8",
++                    "#  error Wayland 1.8.0 or higher required",
++                    "# endif",
++                    "# if WAYLAND_VERSION_MINOR == 8",
++                    "#  if WAYLAND_VERSION_MICRO < 0",
++                    "#   error Wayland 1.8.0 or higher required",
++                    "#  endif",
++                    "# endif",
++                    "#endif"
++                 ]
++            },
++            "sources": [
++                { "type": "pkgConfig", "args": "wayland-client" },
++                "-lwayland-client"
++            ]
++        },
+         "wayland-server": {
+             "label": "wayland-server",
+             "headers": "wayland-version.h",
+@@ -151,8 +176,7 @@
+                     "#endif"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "dmabuf-client-buffer": {
+             "label": "Linux Client dma-buf Buffer Sharing",
+@@ -176,8 +200,7 @@
+                     "return 0;"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "vulkan-server-buffer": {
+             "label": "Vulkan Buffer Sharing",
+@@ -195,7 +218,8 @@
+                     "exportAllocInfo.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR;",
+                     "return 0;"
+                 ]
+-            }
++            },
++            "use": "wayland-client"
+         }
+     },
+ 
+diff --git a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
+index 7889f575..64140672 100644
+--- a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
++++ b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
+@@ -40,6 +40,7 @@
+ #include "qwaylandeglwindow.h"
+ 
+ #include <QtWaylandClient/private/qwaylandscreen_p.h>
++#include <QtWaylandClient/private/qwaylandsurface_p.h>
+ #include "qwaylandglcontext.h"
+ 
+ #include <QtEglSupport/private/qeglconvenience_p.h>
+@@ -124,6 +125,7 @@ void QWaylandEglWindow::updateSurface(bool create)
+         }
+         mOffset = QPoint();
+     } else {
++        QReadLocker locker(&mSurfaceLock);
+         if (m_waylandEglWindow) {
+             int current_width, current_height;
+             static bool disableResizeCheck = qgetenv("QT_WAYLAND_DISABLE_RESIZECHECK").toInt();
+@@ -131,14 +133,16 @@ void QWaylandEglWindow::updateSurface(bool create)
+             if (!disableResizeCheck) {
+                 wl_egl_window_get_attached_size(m_waylandEglWindow, &current_width, &current_height);
+             }
+-            if (disableResizeCheck || (current_width != sizeWithMargins.width() || current_height != sizeWithMargins.height())) {
++            if (disableResizeCheck || (current_width != sizeWithMargins.width() || current_height != sizeWithMargins.height()) || m_requestedSize != sizeWithMargins) {
+                 wl_egl_window_resize(m_waylandEglWindow, sizeWithMargins.width(), sizeWithMargins.height(), mOffset.x(), mOffset.y());
++                m_requestedSize = sizeWithMargins;
+                 mOffset = QPoint();
+ 
+                 m_resize = true;
+             }
+-        } else if (create && wlSurface()) {
+-            m_waylandEglWindow = wl_egl_window_create(wlSurface(), sizeWithMargins.width(), sizeWithMargins.height());
++        } else if (create && mSurface) {
++            m_waylandEglWindow = wl_egl_window_create(mSurface->object(), sizeWithMargins.width(), sizeWithMargins.height());
++            m_requestedSize = sizeWithMargins;
+         }
+ 
+         if (!m_eglSurface && m_waylandEglWindow && create) {
+diff --git a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
+index 5b1f4d56..0079dfef 100644
+--- a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
++++ b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
+@@ -88,6 +88,7 @@ private:
+     mutable QOpenGLFramebufferObject *m_contentFBO = nullptr;
+ 
+     QSurfaceFormat m_format;
++    QSize m_requestedSize;
+ };
+ 
+ }
+diff --git a/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h b/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
+index 56a710c3..c6a8b6c6 100644
+--- a/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
++++ b/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
+@@ -41,6 +41,8 @@
+ #include <QtCore/QTextStream>
+ #include <QtGui/QOpenGLTexture>
+ 
++#include <array>
++
+ #include <EGL/egl.h>
+ #include <EGL/eglext.h>
+ 
+diff --git a/qtwayland/src/plugins/decorations/bradient/main.cpp b/qtwayland/src/plugins/decorations/bradient/main.cpp
+index e75fda3c..fa885143 100644
+--- a/qtwayland/src/plugins/decorations/bradient/main.cpp
++++ b/qtwayland/src/plugins/decorations/bradient/main.cpp
+@@ -164,13 +164,10 @@ void QWaylandBradientDecoration::paint(QPaintDevice *device)
+     // Window icon
+     QIcon icon = waylandWindow()->windowIcon();
+     if (!icon.isNull()) {
+-        QPixmap pixmap = icon.pixmap(QSize(128, 128));
+-        QPixmap scaled = pixmap.scaled(22, 22, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+-
+         QRectF iconRect(0, 0, 22, 22);
+-        p.drawPixmap(iconRect.adjusted(margins().left() + BUTTON_SPACING, 4,
+-                                       margins().left() + BUTTON_SPACING, 4),
+-                     scaled, iconRect);
++        iconRect.adjust(margins().left() + BUTTON_SPACING, 4,
++                        margins().left() + BUTTON_SPACING, 4),
++        icon.paint(&p, iconRect.toRect());
+     }
+ 
+     // Window title
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
+index 85d25e3c..60bdd491 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
+@@ -47,18 +47,21 @@ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
+-QWaylandXdgPopupV5::QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow *window)
++QWaylandXdgPopupV5::QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow* parent, QWaylandWindow *window)
+     : QWaylandShellSurface(window)
+     , QtWayland::xdg_popup_v5(popup)
++    , m_parent(parent)
+     , m_window(window)
+ {
+     if (window->display()->windowExtension())
+         m_extendedWindow = new QWaylandExtendedSurface(window);
++    m_parent->addChildPopup(m_window);
+ }
+ 
+ QWaylandXdgPopupV5::~QWaylandXdgPopupV5()
+ {
+     xdg_popup_destroy(object());
++    m_parent->removeChildPopup(m_window);
+     delete m_extendedWindow;
+ }
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
+index 7494f6a6..d85f130b 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
+@@ -70,7 +70,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgPopupV5 : public QWaylandShellSurface
+ {
+     Q_OBJECT
+ public:
+-    QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow *window);
++    QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow* parent, QWaylandWindow *window);
+     ~QWaylandXdgPopupV5() override;
+ 
+ protected:
+@@ -78,6 +78,7 @@ protected:
+ 
+ private:
+     QWaylandExtendedSurface *m_extendedWindow = nullptr;
++    QWaylandWindow *m_parent = nullptr;
+     QWaylandWindow *m_window = nullptr;
+ };
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
+index 7e242c4a..def8452a 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
+@@ -84,7 +84,7 @@ QWaylandXdgPopupV5 *QWaylandXdgShellV5::createXdgPopup(QWaylandWindow *window, Q
+     int x = position.x() + parentWindow->frameMargins().left();
+     int y = position.y() + parentWindow->frameMargins().top();
+ 
+-    auto popup = new QWaylandXdgPopupV5(get_xdg_popup(window->wlSurface(), parentSurface, seat, m_popupSerial, x, y), window);
++    auto popup = new QWaylandXdgPopupV5(get_xdg_popup(window->wlSurface(), parentSurface, seat, m_popupSerial, x, y), parentWindow, window);
+     m_popups.append(window);
+     QObject::connect(popup, &QWaylandXdgPopupV5::destroyed, [this, window](){
+         m_popups.removeOne(window);
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
+index 4e25949f..cfc60939 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
+@@ -85,13 +85,6 @@ QWaylandShellSurface *QWaylandXdgShellV5Integration::createShellSurface(QWayland
+     return m_xdgShell->createXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellV5Integration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) {
+-    if (newFocus && qobject_cast<QWaylandXdgPopupV5 *>(newFocus->shellSurface()))
+-        m_display->handleWindowActivated(newFocus);
+-    if (oldFocus && qobject_cast<QWaylandXdgPopupV5 *>(oldFocus->shellSurface()))
+-        m_display->handleWindowDeactivated(oldFocus);
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
+index ce6bdb9e..aed88670 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
+@@ -67,7 +67,6 @@ public:
+     QWaylandXdgShellV5Integration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShellV5> m_xdgShell;
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
+index 8c371661..151c78e3 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
+@@ -174,6 +174,7 @@ QWaylandXdgSurfaceV6::Popup::Popup(QWaylandXdgSurfaceV6 *xdgSurface, QWaylandXdg
+     , m_xdgSurface(xdgSurface)
+     , m_parent(parent)
+ {
++    m_parent->window()->addChildPopup(m_xdgSurface->window());
+ }
+ 
+ QWaylandXdgSurfaceV6::Popup::~Popup()
+@@ -181,6 +182,8 @@ QWaylandXdgSurfaceV6::Popup::~Popup()
+     if (isInitialized())
+         destroy();
+ 
++    m_parent->window()->removeChildPopup(m_xdgSurface->window());
++
+     if (m_grabbing) {
+         auto *shell = m_xdgSurface->m_shell;
+         Q_ASSERT(shell->m_topmostGrabbingPopup == this);
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
+index 03164316..e8da8ba1 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
+@@ -68,20 +68,6 @@ QWaylandShellSurface *QWaylandXdgShellV6Integration::createShellSurface(QWayland
+     return m_xdgShell->getXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellV6Integration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus)
+-{
+-    if (newFocus) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurfaceV6 *>(newFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowActivated(newFocus);
+-    }
+-    if (oldFocus && qobject_cast<QWaylandXdgSurfaceV6 *>(oldFocus->shellSurface())) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurfaceV6 *>(oldFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowDeactivated(oldFocus);
+-    }
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
+index 261f8cbb..c1bcd5c6 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
+@@ -65,7 +65,6 @@ public:
+     QWaylandXdgShellV6Integration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShellV6> m_xdgShell;
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
+index f3e3c330..fa6d5808 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
+@@ -67,11 +67,6 @@ QWaylandXdgSurface::Toplevel::Toplevel(QWaylandXdgSurface *xdgSurface)
+ 
+ QWaylandXdgSurface::Toplevel::~Toplevel()
+ {
+-    if (m_applied.states & Qt::WindowActive) {
+-        QWaylandWindow *window = m_xdgSurface->window();
+-        window->display()->handleWindowDeactivated(window);
+-    }
+-
+     // The protocol spec requires that the decoration object is deleted before xdg_toplevel.
+     delete m_decoration;
+     m_decoration = nullptr;
+@@ -85,16 +80,15 @@ void QWaylandXdgSurface::Toplevel::applyConfigure()
+     if (!(m_applied.states & (Qt::WindowMaximized|Qt::WindowFullScreen)))
+         m_normalSize = m_xdgSurface->m_window->windowFrameGeometry().size();
+ 
+-    if ((m_pending.states & Qt::WindowActive) && !(m_applied.states & Qt::WindowActive))
++    if ((m_pending.states & Qt::WindowActive) && !(m_applied.states & Qt::WindowActive)
++        && !m_xdgSurface->m_window->display()->isKeyboardAvailable())
+         m_xdgSurface->m_window->display()->handleWindowActivated(m_xdgSurface->m_window);
+ 
+-    if (!(m_pending.states & Qt::WindowActive) && (m_applied.states & Qt::WindowActive))
++    if (!(m_pending.states & Qt::WindowActive) && (m_applied.states & Qt::WindowActive)
++        && !m_xdgSurface->m_window->display()->isKeyboardAvailable())
+         m_xdgSurface->m_window->display()->handleWindowDeactivated(m_xdgSurface->m_window);
+ 
+-    // TODO: none of the other plugins send WindowActive either, but is it on purpose?
+-    Qt::WindowStates statesWithoutActive = m_pending.states & ~Qt::WindowActive;
+-
+-    m_xdgSurface->m_window->handleWindowStatesChanged(statesWithoutActive);
++    m_xdgSurface->m_window->handleWindowStatesChanged(m_pending.states);
+ 
+     if (m_pending.size.isEmpty()) {
+         // An empty size in the configure means it's up to the client to choose the size
+@@ -105,8 +99,6 @@ void QWaylandXdgSurface::Toplevel::applyConfigure()
+         m_xdgSurface->m_window->resizeFromApplyConfigure(m_pending.size);
+     }
+ 
+-    m_xdgSurface->setSizeHints();
+-
+     m_applied = m_pending;
+     qCDebug(lcQpaWayland) << "Applied pending xdg_toplevel configure event:" << m_applied.size << m_applied.states;
+ }
+@@ -203,12 +195,17 @@ QtWayland::xdg_toplevel::resize_edge QWaylandXdgSurface::Toplevel::convertToResi
+                 | ((edges & Qt::RightEdge) ? resize_edge_right : 0));
+ }
+ 
+-QWaylandXdgSurface::Popup::Popup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parent,
++QWaylandXdgSurface::Popup::Popup(QWaylandXdgSurface *xdgSurface, QWaylandWindow *parent,
+                                  QtWayland::xdg_positioner *positioner)
+-    : xdg_popup(xdgSurface->get_popup(parent->object(), positioner->object()))
+-    , m_xdgSurface(xdgSurface)
++    : m_xdgSurface(xdgSurface)
++    , m_parentXdgSurface(qobject_cast<QWaylandXdgSurface *>(parent->shellSurface()))
+     , m_parent(parent)
+ {
++
++    init(xdgSurface->get_popup(m_parentXdgSurface ? m_parentXdgSurface->object() : nullptr, positioner->object()));
++    if (m_parent) {
++        m_parent->addChildPopup(m_xdgSurface->window());
++    }
+ }
+ 
+ QWaylandXdgSurface::Popup::~Popup()
+@@ -216,10 +213,24 @@ QWaylandXdgSurface::Popup::~Popup()
+     if (isInitialized())
+         destroy();
+ 
++    if (m_parent) {
++        m_parent->removeChildPopup(m_xdgSurface->window());
++    }
++
+     if (m_grabbing) {
+         auto *shell = m_xdgSurface->m_shell;
+         Q_ASSERT(shell->m_topmostGrabbingPopup == this);
+-        shell->m_topmostGrabbingPopup = m_parent->m_popup;
++        shell->m_topmostGrabbingPopup = m_parentXdgSurface ? m_parentXdgSurface->m_popup : nullptr;
++        m_grabbing = false;
++
++        // Synthesize Qt enter/leave events for popup
++        QWindow *leave = nullptr;
++        if (m_xdgSurface && m_xdgSurface->window())
++            leave = m_xdgSurface->window()->window();
++        QWindowSystemInterface::handleLeaveEvent(leave);
++
++        if (QWindow *enter = QGuiApplication::topLevelAt(QCursor::pos()))
++            QWindowSystemInterface::handleEnterEvent(enter, enter->mapFromGlobal(QCursor::pos()), QCursor::pos());
+     }
+ }
+ 
+@@ -257,6 +268,7 @@ QWaylandXdgSurface::QWaylandXdgSurface(QWaylandXdgShell *shell, ::xdg_surface *s
+                 m_toplevel->set_parent(parentXdgSurface->m_toplevel->object());
+         }
+     }
++    setSizeHints();
+ }
+ 
+ QWaylandXdgSurface::~QWaylandXdgSurface()
+@@ -400,8 +412,6 @@ void QWaylandXdgSurface::setPopup(QWaylandWindow *parent)
+ {
+     Q_ASSERT(!m_toplevel && !m_popup);
+ 
+-    auto parentXdgSurface = static_cast<QWaylandXdgSurface *>(parent->shellSurface());
+-
+     auto positioner = new QtWayland::xdg_positioner(m_shell->create_positioner());
+     // set_popup expects a position relative to the parent
+     QPoint transientPos = m_window->geometry().topLeft(); // this is absolute
+@@ -414,8 +424,9 @@ void QWaylandXdgSurface::setPopup(QWaylandWindow *parent)
+     positioner->set_anchor(QtWayland::xdg_positioner::anchor_top_left);
+     positioner->set_gravity(QtWayland::xdg_positioner::gravity_bottom_right);
+     positioner->set_size(m_window->geometry().width(), m_window->geometry().height());
+-    m_popup = new Popup(this, parentXdgSurface, positioner);
++    m_popup = new Popup(this, parent, positioner);
+     positioner->destroy();
++
+     delete positioner;
+ }
+ 
+@@ -437,6 +448,23 @@ void QWaylandXdgSurface::setGrabPopup(QWaylandWindow *parent, QWaylandInputDevic
+     }
+     setPopup(parent);
+     m_popup->grab(device, serial);
++
++    // Synthesize Qt enter/leave events for popup
++    if (!parent)
++        return;
++    QWindow *current = QGuiApplication::topLevelAt(QCursor::pos());
++    QWindow *leave = parent->window();
++    if (current != leave)
++        return;
++
++    QWindowSystemInterface::handleLeaveEvent(leave);
++
++    QWindow *enter = nullptr;
++    if (m_popup && m_popup->m_xdgSurface && m_popup->m_xdgSurface->window())
++        enter = m_popup->m_xdgSurface->window()->window();
++
++    if (enter)
++        QWindowSystemInterface::handleEnterEvent(enter, enter->mapFromGlobal(QCursor::pos()), QCursor::pos());
+ }
+ 
+ void QWaylandXdgSurface::xdg_surface_configure(uint32_t serial)
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
+index 96785205..4b518f0a 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
+@@ -131,14 +131,15 @@ private:
+ 
+     class Popup : public QtWayland::xdg_popup {
+     public:
+-        Popup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parent, QtWayland::xdg_positioner *positioner);
++        Popup(QWaylandXdgSurface *xdgSurface, QWaylandWindow *parent, QtWayland::xdg_positioner *positioner);
+         ~Popup() override;
+ 
+         void grab(QWaylandInputDevice *seat, uint serial);
+         void xdg_popup_popup_done() override;
+ 
+         QWaylandXdgSurface *m_xdgSurface = nullptr;
+-        QWaylandXdgSurface *m_parent = nullptr;
++        QWaylandXdgSurface *m_parentXdgSurface = nullptr;
++        QWaylandWindow *m_parent = nullptr;
+         bool m_grabbing = false;
+     };
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
+index 8769d971..da0dd6a7 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
+@@ -69,20 +69,6 @@ QWaylandShellSurface *QWaylandXdgShellIntegration::createShellSurface(QWaylandWi
+     return m_xdgShell->getXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellIntegration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus)
+-{
+-    if (newFocus) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurface *>(newFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowActivated(newFocus);
+-    }
+-    if (oldFocus && qobject_cast<QWaylandXdgSurface *>(oldFocus->shellSurface())) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurface *>(oldFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowDeactivated(oldFocus);
+-    }
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
+index b6caa6c9..2f929f98 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
+@@ -65,7 +65,6 @@ public:
+     QWaylandXdgShellIntegration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShell> m_xdgShell;
+diff --git a/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp b/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
+index 526d0ef4..f50ccf30 100644
+--- a/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
++++ b/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
+@@ -39,7 +39,10 @@
+ 
+ #include "qwaylandinputmethodeventbuilder_p.h"
+ 
++#include <QBrush>
++#include <QGuiApplication>
+ #include <QInputMethod>
++#include <QPalette>
+ #include <QTextCharFormat>
+ 
+ #ifdef QT_BUILD_WAYLANDCOMPOSITOR_LIB
+@@ -81,32 +84,38 @@ void QWaylandInputMethodEventBuilder::addPreeditStyling(uint32_t index, uint32_t
+     QTextCharFormat format;
+ 
+     switch (style) {
+-    case 0:
+-    case 1:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_NONE:
++        break;
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_DEFAULT:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_UNDERLINE:
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-    case 2:
+-    case 3:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_ACTIVE:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_INACTIVE:
+         format.setFontWeight(QFont::Bold);
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-    case 4:
+-        format.setFontUnderline(true);
+-        format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+-        m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_HIGHLIGHT:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_SELECTION:
++        {
++            format.setFontUnderline(true);
++            format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
++            QPalette palette = qApp->palette();
++            format.setBackground(QBrush(palette.color(QPalette::Active, QPalette::Highlight)));
++            format.setForeground(QBrush(palette.color(QPalette::Active, QPalette::HighlightedText)));
++            m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
++        }
+         break;
+-    case 5:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_INCORRECT:
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::WaveUnderline);
+         format.setUnderlineColor(QColor(Qt::red));
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-//    case QtWayland::wl_text_input::preedit_style_selection:
+-//    case QtWayland::wl_text_input::preedit_style_none:
+     default:
+         break;
+     }
+@@ -153,7 +162,7 @@ QInputMethodEvent QWaylandInputMethodEventBuilder::buildPreedit(const QString &t
+ 
+     if (m_preeditCursor < 0) {
+         attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, 0, QVariant()));
+-    } else if (m_preeditCursor > 0) {
++    } else {
+         attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, indexFromWayland(text, m_preeditCursor), 1, QVariant()));
+     }
+ 
+diff --git a/qtwayland/src/shared/qwaylandmimehelper.cpp b/qtwayland/src/shared/qwaylandmimehelper.cpp
+index a5fdd34d..e2fe1928 100644
+--- a/qtwayland/src/shared/qwaylandmimehelper.cpp
++++ b/qtwayland/src/shared/qwaylandmimehelper.cpp
+@@ -60,7 +60,7 @@ QByteArray QWaylandMimeHelper::getByteArray(QMimeData *mimeData, const QString &
+             buf.open(QIODevice::ReadWrite);
+             QByteArray fmt = "BMP";
+             if (mimeType.startsWith(QLatin1String("image/"))) {
+-                QByteArray imgFmt = mimeType.mid(6).toUpper().toLatin1();
++                QByteArray imgFmt = mimeType.mid(6).toLower().toLatin1();
+                 if (QImageWriter::supportedImageFormats().contains(imgFmt))
+                     fmt = imgFmt;
+             }
+@@ -74,7 +74,7 @@ QByteArray QWaylandMimeHelper::getByteArray(QMimeData *mimeData, const QString &
+         QList<QUrl> urls = mimeData->urls();
+         for (int i = 0; i < urls.count(); ++i) {
+             content.append(urls.at(i).toEncoded());
+-            content.append('\n');
++            content.append("\r\n");
+         }
+     } else {
+         content = mimeData->data(mimeType);
+diff --git a/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp b/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
+index 1568b3b9..067410d0 100644
+--- a/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
++++ b/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
+@@ -35,7 +35,7 @@
+ 
+ using namespace MockCompositor;
+ 
+-constexpr int dataDeviceVersion = 1;
++constexpr int dataDeviceVersion = 3;
+ 
+ class DataDeviceCompositor : public DefaultCompositor {
+ public:
+diff --git a/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp b/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
+index 9312c2e5..2ea382f1 100644
+--- a/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
++++ b/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
+@@ -73,6 +73,7 @@ private slots:
+     void multiTouch();
+     void multiTouchUpAndMotionFrame();
+     void tapAndMoveInSameFrame();
++    void cancelTouch();
+ };
+ 
+ void tst_seatv5::bindsToSeat()
+@@ -646,5 +647,34 @@ void tst_seatv5::tapAndMoveInSameFrame()
+     QTRY_COMPARE(window.m_events.last().touchPoints.first().state(), Qt::TouchPointState::TouchPointReleased);
+ }
+ 
++void tst_seatv5::cancelTouch()
++{
++    TouchWindow window;
++    QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
++
++    exec([=] {
++        auto *t = touch();
++        auto *c = client();
++        t->sendDown(xdgToplevel()->surface(), {32, 32}, 1);
++        t->sendFrame(c);
++        t->sendCancel(c);
++        t->sendFrame(c);
++    });
++
++    QTRY_VERIFY(!window.m_events.empty());
++    {
++        auto e = window.m_events.takeFirst();
++        QCOMPARE(e.type, QEvent::TouchBegin);
++        QCOMPARE(e.touchPointStates, Qt::TouchPointPressed);
++        QCOMPARE(e.touchPoints.length(), 1);
++        QCOMPARE(e.touchPoints.first().pos(), QPointF(32-window.frameMargins().left(), 32-window.frameMargins().top()));
++    }
++    {
++        auto e = window.m_events.takeFirst();
++        QCOMPARE(e.type, QEvent::TouchCancel);
++        QCOMPARE(e.touchPoints.length(), 0);
++    }
++}
++
+ QCOMPOSITOR_TEST_MAIN(tst_seatv5)
+ #include "tst_seatv5.moc"
+diff --git a/qtwayland/tests/auto/client/shared/corecompositor.cpp b/qtwayland/tests/auto/client/shared/corecompositor.cpp
+index 5c6c83ba..fa9b7662 100644
+--- a/qtwayland/tests/auto/client/shared/corecompositor.cpp
++++ b/qtwayland/tests/auto/client/shared/corecompositor.cpp
+@@ -27,6 +27,7 @@
+ ****************************************************************************/
+ 
+ #include "corecompositor.h"
++#include <thread>
+ 
+ namespace MockCompositor {
+ 
+diff --git a/qtwayland/tests/auto/client/shared/coreprotocol.cpp b/qtwayland/tests/auto/client/shared/coreprotocol.cpp
+index 0d988521..d1a2e7cb 100644
+--- a/qtwayland/tests/auto/client/shared/coreprotocol.cpp
++++ b/qtwayland/tests/auto/client/shared/coreprotocol.cpp
+@@ -451,6 +451,13 @@ void Touch::sendFrame(wl_client *client)
+         send_frame(r->handle);
+ }
+ 
++void Touch::sendCancel(wl_client *client)
++{
++    const auto touchResources = resourceMap().values(client);
++    for (auto *r : touchResources)
++        send_cancel(r->handle);
++}
++
+ uint Keyboard::sendEnter(Surface *surface)
+ {
+     auto serial = m_seat->m_compositor->nextSerial();
+diff --git a/qtwayland/tests/auto/client/shared/coreprotocol.h b/qtwayland/tests/auto/client/shared/coreprotocol.h
+index a1af137a..210d8ddb 100644
+--- a/qtwayland/tests/auto/client/shared/coreprotocol.h
++++ b/qtwayland/tests/auto/client/shared/coreprotocol.h
+@@ -158,7 +158,7 @@ class WlCompositor : public Global, public QtWaylandServer::wl_compositor
+ {
+     Q_OBJECT
+ public:
+-    explicit WlCompositor(CoreCompositor *compositor, int version = 3)
++    explicit WlCompositor(CoreCompositor *compositor, int version = 4)
+         : QtWaylandServer::wl_compositor(compositor->m_display, version)
+         , m_compositor(compositor)
+     {}
+@@ -364,6 +364,7 @@ public:
+     uint sendUp(wl_client *client, int id);
+     void sendMotion(wl_client *client, const QPointF &position, int id);
+     void sendFrame(wl_client *client);
++    void sendCancel(wl_client *client);
+ 
+     Seat *m_seat = nullptr;
+ };
+diff --git a/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp b/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
+index a415cbf5..b1d3d07d 100644
+--- a/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
++++ b/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
+@@ -342,7 +342,7 @@ Compositor::Compositor(MockCompositor *mockCompositor)
+         exit(EXIT_FAILURE);
+     }
+ 
+-    wl_global_create(m_display, &wl_compositor_interface, 1, this, bindCompositor);
++    wl_global_create(m_display, &wl_compositor_interface, 4, this, bindCompositor);
+ 
+     m_data_device_manager.reset(new DataDeviceManager(this, m_display));
+ 
+diff --git a/qtwayland/tests/auto/client/shared_old/mocksurface.cpp b/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
+index e9df5f90..c3246e4a 100644
+--- a/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
++++ b/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
+@@ -125,6 +125,16 @@ void Surface::surface_damage(Resource *resource,
+     Q_UNUSED(height);
+ }
+ 
++void Surface::surface_damage_buffer(Resource *resource,
++                                    int32_t x, int32_t y, int32_t width, int32_t height)
++{
++    Q_UNUSED(resource);
++    Q_UNUSED(x);
++    Q_UNUSED(y);
++    Q_UNUSED(width);
++    Q_UNUSED(height);
++}
++
+ void Surface::surface_frame(Resource *resource,
+                             uint32_t callback)
+ {
+diff --git a/qtwayland/tests/auto/client/shared_old/mocksurface.h b/qtwayland/tests/auto/client/shared_old/mocksurface.h
+index 949dc23d..d176837e 100644
+--- a/qtwayland/tests/auto/client/shared_old/mocksurface.h
++++ b/qtwayland/tests/auto/client/shared_old/mocksurface.h
+@@ -65,6 +65,8 @@ protected:
+                         struct wl_resource *buffer, int x, int y) override;
+     void surface_damage(Resource *resource,
+                         int32_t x, int32_t y, int32_t width, int32_t height) override;
++    void surface_damage_buffer(Resource *resource,
++                               int32_t x, int32_t y, int32_t width, int32_t height) override;
+     void surface_frame(Resource *resource,
+                        uint32_t callback) override;
+     void surface_commit(Resource *resource) override;
+diff --git a/qtwayland/tests/auto/client/surface/tst_surface.cpp b/qtwayland/tests/auto/client/surface/tst_surface.cpp
+index 95e4e609..60c672ce 100644
+--- a/qtwayland/tests/auto/client/surface/tst_surface.cpp
++++ b/qtwayland/tests/auto/client/surface/tst_surface.cpp
+@@ -129,6 +129,10 @@ void tst_surface::waitForFrameCallbackGl()
+     // Make sure we follow frame callbacks for some frames
+     for (int i = 0; i < 5; ++i) {
+         xdgPingAndWaitForPong(); // Make sure things have happened on the client
++        if (!qEnvironmentVariableIntValue("QT_WAYLAND_DISABLE_WINDOWDECORATION") && i == 0) {
++            QCOMPARE(bufferSpy.count(), 1);
++            bufferSpy.removeFirst();
++        }
+         exec([&] {
+             QVERIFY(bufferSpy.empty()); // Make sure no extra buffers have arrived
+             QVERIFY(!xdgToplevel()->surface()->m_waitingFrameCallbacks.empty());
+diff --git a/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp b/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
+index 2277bbb8..747875b4 100644
+--- a/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
++++ b/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
+@@ -31,6 +31,7 @@
+ #include <QtGui/QOpenGLWindow>
+ #include <QtGui/qpa/qplatformnativeinterface.h>
+ #include <QtWaylandClient/private/wayland-wayland-client-protocol.h>
++#include <QtWaylandClient/private/qwaylandwindow_p.h>
+ 
+ using namespace MockCompositor;
+ 
+@@ -45,6 +46,7 @@ private slots:
+     void configureStates();
+     void popup();
+     void tooltipOnPopup();
++    void tooltipAndSiblingPopup();
+     void switchPopups();
+     void hidePopupParent();
+     void pongs();
+@@ -138,6 +140,7 @@ void tst_xdgshell::configureSize()
+ 
+ void tst_xdgshell::configureStates()
+ {
++    QVERIFY(qputenv("QT_WAYLAND_FRAME_CALLBACK_TIMEOUT", "0"));
+     QRasterWindow window;
+     window.resize(64, 48);
+     window.show();
+@@ -154,9 +157,12 @@ void tst_xdgshell::configureStates()
+     // Toplevel windows don't know their position on xdg-shell
+ //    QCOMPARE(window.frameGeometry().topLeft(), QPoint()); // TODO: this doesn't currently work when window decorations are enabled
+ 
+-//    QEXPECT_FAIL("", "configure has already been acked, we shouldn't have to wait for isActive", Continue);
+-//    QVERIFY(window.isActive());
+-    QTRY_VERIFY(window.isActive()); // Just make sure it eventually get's set correctly
++    // window.windowstate() is driven by keyboard focus, however for decorations we want to follow
++    // XDGShell this is internal to QtWayland so it is queried directly
++    auto waylandWindow = static_cast<QtWaylandClient::QWaylandWindow *>(window.handle());
++    Q_ASSERT(waylandWindow);
++    QTRY_VERIFY(waylandWindow->windowStates().testFlag(
++            Qt::WindowActive)); // Just make sure it eventually get's set correctly
+ 
+     const QSize screenSize(640, 480);
+     const uint maximizedSerial = exec([=] {
+@@ -186,6 +192,7 @@ void tst_xdgshell::configureStates()
+     QCOMPARE(window.windowStates(), Qt::WindowNoState);
+     QCOMPARE(window.frameGeometry().size(), windowedSize);
+ //    QCOMPARE(window.frameGeometry().topLeft(), QPoint()); // TODO: this doesn't currently work when window decorations are enabled
++    QVERIFY(qunsetenv("QT_WAYLAND_FRAME_CALLBACK_TIMEOUT"));
+ }
+ 
+ void tst_xdgshell::popup()
+@@ -340,6 +347,92 @@ void tst_xdgshell::tooltipOnPopup()
+     QCOMPOSITOR_TRY_COMPARE(xdgPopup(0), nullptr);
+ }
+ 
++void tst_xdgshell::tooltipAndSiblingPopup()
++{
++    class ToolTip : public QRasterWindow {
++    public:
++        explicit ToolTip(QWindow *parent) {
++            setTransientParent(parent);
++            setFlags(Qt::ToolTip);
++            resize(100, 100);
++            show();
++        }
++        void mousePressEvent(QMouseEvent *event) override {
++            QRasterWindow::mousePressEvent(event);
++            m_popup = new QRasterWindow;
++            m_popup->setTransientParent(transientParent());
++            m_popup->setFlags(Qt::Popup);
++            m_popup->resize(100, 100);
++            m_popup->show();
++        }
++
++        QRasterWindow *m_popup = nullptr;
++    };
++
++    class Window : public QRasterWindow {
++    public:
++        void mousePressEvent(QMouseEvent *event) override {
++            QRasterWindow::mousePressEvent(event);
++            m_tooltip = new ToolTip(this);
++        }
++        ToolTip *m_tooltip = nullptr;
++    };
++
++    Window window;
++    window.resize(200, 200);
++    window.show();
++
++    QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
++    exec([=] { xdgToplevel()->sendCompleteConfigure(); });
++    QCOMPOSITOR_TRY_VERIFY(xdgToplevel()->m_xdgSurface->m_committedConfigureSerial);
++
++    exec([=] {
++        auto *surface = xdgToplevel()->surface();
++        auto *p = pointer();
++        auto *c = client();
++        p->sendEnter(surface, {100, 100});
++        p->sendFrame(c);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_pressed);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_released);
++        p->sendFrame(c);
++        p->sendLeave(surface);
++        p->sendFrame(c);
++    });
++
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup());
++    exec([=] { xdgPopup()->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup()->m_xdgSurface->m_committedConfigureSerial);
++    QCOMPOSITOR_TRY_VERIFY(!xdgPopup()->m_grabbed);
++
++    exec([=] {
++        auto *surface = xdgPopup()->surface();
++        auto *p = pointer();
++        auto *c = client();
++        p->sendEnter(surface, {100, 100});
++        p->sendFrame(c);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_pressed);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_released);
++        p->sendFrame(c);
++    });
++
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1));
++    exec([=] { xdgPopup(1)->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1)->m_xdgSurface->m_committedConfigureSerial);
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1)->m_grabbed);
++
++    // Close the middle tooltip (it should not close the sibling popup)
++    window.m_tooltip->close();
++
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(1), nullptr);
++    // Verify the remaining xdg surface is a grab popup..
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(0));
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(0)->m_grabbed);
++
++    window.m_tooltip->m_popup->close();
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(1), nullptr);
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(0), nullptr);
++}
++
+ // QTBUG-65680
+ void tst_xdgshell::switchPopups()
+ {
+@@ -505,7 +598,7 @@ void tst_xdgshell::minMaxSize()
+     window.show();
+     QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
+ 
+-    exec([=] { xdgToplevel()->sendCompleteConfigure(); });
++    // we don't roundtrip with our configuration the initial commit should be correct
+ 
+     QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.minSize, QSize(100, 100));
+     QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.maxSize, QSize(1000, 1000));
+Submodule qtwebchannel 618422ee..f8949655:
+diff --git a/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp b/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
+index 536eb5c..898d769 100644
+--- a/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
++++ b/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
+@@ -186,8 +186,6 @@ Q_DECLARE_TYPEINFO(OverloadResolutionCandidate, Q_MOVABLE_TYPE);
+ QMetaObjectPublisher::QMetaObjectPublisher(QWebChannel *webChannel)
+     : QObject(webChannel)
+     , webChannel(webChannel)
+-    , signalHandler(this)
+-    , clientIsIdle(false)
+     , blockUpdates(false)
+     , propertyUpdatesInitialized(false)
+ {
+@@ -301,17 +299,17 @@ QJsonObject QMetaObjectPublisher::classInfoForObject(const QObject *object, QWeb
+     return data;
+ }
+ 
+-void QMetaObjectPublisher::setClientIsIdle(bool isIdle)
++void QMetaObjectPublisher::setClientIsIdle(bool isIdle, QWebChannelAbstractTransport *transport)
+ {
+-    if (clientIsIdle == isIdle) {
+-        return;
+-    }
+-    clientIsIdle = isIdle;
+-    if (!isIdle && timer.isActive()) {
+-        timer.stop();
+-    } else if (isIdle && !timer.isActive()) {
+-        timer.start(PROPERTY_UPDATE_INTERVAL, this);
+-    }
++    transportState[transport].clientIsIdle = isIdle;
++    if (isIdle)
++        sendEnqueuedPropertyUpdates(transport);
++}
++
++bool QMetaObjectPublisher::isClientIdle(QWebChannelAbstractTransport *transport)
++{
++    auto found = transportState.find(transport);
++    return found != transportState.end() && found.value().clientIsIdle;
+ }
+ 
+ QJsonObject QMetaObjectPublisher::initializeClient(QWebChannelAbstractTransport *transport)
+@@ -333,6 +331,7 @@ QJsonObject QMetaObjectPublisher::initializeClient(QWebChannelAbstractTransport
+ 
+ void QMetaObjectPublisher::initializePropertyUpdates(const QObject *const object, const QJsonObject &objectInfo)
+ {
++    auto *signalHandler = signalHandlerFor(object);
+     foreach (const QJsonValue &propertyInfoVar, objectInfo[KEY_PROPERTIES].toArray()) {
+         const QJsonArray &propertyInfo = propertyInfoVar.toArray();
+         if (propertyInfo.size() < 2) {
+@@ -353,19 +352,19 @@ void QMetaObjectPublisher::initializePropertyUpdates(const QObject *const object
+ 
+         // Only connect for a property update once
+         if (connectedProperties.isEmpty()) {
+-            signalHandler.connectTo(object, signalIndex);
++            signalHandler->connectTo(object, signalIndex);
+         }
+ 
+         connectedProperties.insert(propertyIndex);
+     }
+ 
+     // also always connect to destroyed signal
+-    signalHandler.connectTo(object, s_destroyedSignalIndex);
++    signalHandler->connectTo(object, s_destroyedSignalIndex);
+ }
+ 
+ void QMetaObjectPublisher::sendPendingPropertyUpdates()
+ {
+-    if (blockUpdates || !clientIsIdle || pendingPropertyUpdates.isEmpty()) {
++    if (blockUpdates) {
+         return;
+     }
+ 
+@@ -415,18 +414,19 @@ void QMetaObjectPublisher::sendPendingPropertyUpdates()
+ 
+     // data does not contain specific updates
+     if (!data.isEmpty()) {
+-        setClientIsIdle(false);
+-
+         message[KEY_DATA] = data;
+-        broadcastMessage(message);
++        enqueueBroadcastMessage(message);
+     }
+ 
+     // send every property update which is not supposed to be broadcasted
+     const QHash<QWebChannelAbstractTransport*, QJsonArray>::const_iterator suend = specificUpdates.constEnd();
+     for (QHash<QWebChannelAbstractTransport*, QJsonArray>::const_iterator it = specificUpdates.constBegin(); it != suend; ++it) {
+         message[KEY_DATA] = it.value();
+-        it.key()->sendMessage(message);
++        enqueueMessage(message, it.key());
+     }
++
++    for (auto state = transportState.begin(); state != transportState.end(); ++state)
++        sendEnqueuedPropertyUpdates(state.key());
+ }
+ 
+ QVariant QMetaObjectPublisher::invokeMethod(QObject *const object, const QMetaMethod &method,
+@@ -572,7 +572,7 @@ void QMetaObjectPublisher::signalEmitted(const QObject *object, const int signal
+         }
+     } else {
+         pendingPropertyUpdates[object][signalIndex] = arguments;
+-        if (clientIsIdle && !blockUpdates && !timer.isActive()) {
++        if (!blockUpdates && !timer.isActive()) {
+             timer.start(PROPERTY_UPDATE_INTERVAL, this);
+         }
+     }
+@@ -590,7 +590,7 @@ void QMetaObjectPublisher::objectDestroyed(const QObject *object)
+     // only remove from handler when we initialized the property updates
+     // cf: https://bugreports.qt.io/browse/QTBUG-60250
+     if (propertyUpdatesInitialized) {
+-        signalHandler.remove(object);
++        signalHandlerFor(object)->remove(object);
+         signalToPropertyMap.remove(object);
+     }
+     pendingPropertyUpdates.remove(object);
+@@ -852,6 +852,52 @@ void QMetaObjectPublisher::broadcastMessage(const QJsonObject &message) const
+     }
+ }
+ 
++void QMetaObjectPublisher::enqueueBroadcastMessage(const QJsonObject &message)
++{
++    if (webChannel->d_func()->transports.isEmpty()) {
++        qWarning("QWebChannel is not connected to any transports, cannot send message: %s",
++                 QJsonDocument(message).toJson().constData());
++        return;
++    }
++
++    for (auto *transport : webChannel->d_func()->transports) {
++        auto &state = transportState[transport];
++        state.queuedMessages.append(message);
++    }
++}
++
++void QMetaObjectPublisher::enqueueMessage(const QJsonObject &message,
++                                          QWebChannelAbstractTransport *transport)
++{
++    auto &state = transportState[transport];
++    state.queuedMessages.append(message);
++}
++
++void QMetaObjectPublisher::sendEnqueuedPropertyUpdates(QWebChannelAbstractTransport *transport)
++{
++    auto found = transportState.find(transport);
++    if (found != transportState.end() && found.value().clientIsIdle
++        && !found.value().queuedMessages.isEmpty()) {
++
++        // If the client is connected with an in-process transport, it can
++        // happen that a message triggers a subsequent property change. In
++        // that case, we need to ensure that the queued messages have already
++        // been cleared; otherwise the recursive call will send everythig again.
++        // Case in point: The qmlwebchannel tests fail if we don't clear the
++        // queued messages before sending them out.
++        // For that same reason set the client to "busy" (aka non-idle) just
++        // right before sending out the messages; otherwise a potential
++        // "Idle" type message will not correctly restore the Idle state.
++        const auto messages = std::move(found.value().queuedMessages);
++        Q_ASSERT(found.value().queuedMessages.isEmpty());
++        found.value().clientIsIdle = false;
++
++        for (const auto &message : messages) {
++            transport->sendMessage(message);
++        }
++    }
++}
++
+ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannelAbstractTransport *transport)
+ {
+     if (!webChannel->d_func()->transports.contains(transport)) {
+@@ -866,7 +912,7 @@ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannel
+ 
+     const MessageType type = toType(message.value(KEY_TYPE));
+     if (type == TypeIdle) {
+-        setClientIsIdle(true);
++        setClientIsIdle(true, transport);
+     } else if (type == TypeInit) {
+         if (!message.contains(KEY_ID)) {
+             qWarning("JSON message object is missing the id property: %s",
+@@ -913,9 +959,9 @@ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannel
+                 return;
+             transport->sendMessage(createResponse(message.value(KEY_ID), wrapResult(result, transport)));
+         } else if (type == TypeConnectToSignal) {
+-            signalHandler.connectTo(object, message.value(KEY_SIGNAL).toInt(-1));
++            signalHandlerFor(object)->connectTo(object, message.value(KEY_SIGNAL).toInt(-1));
+         } else if (type == TypeDisconnectFromSignal) {
+-            signalHandler.disconnectFrom(object, message.value(KEY_SIGNAL).toInt(-1));
++            signalHandlerFor(object)->disconnectFrom(object, message.value(KEY_SIGNAL).toInt(-1));
+         } else if (type == TypeSetProperty) {
+             setProperty(object, message.value(KEY_PROPERTY).toInt(-1),
+                         message.value(KEY_VALUE));
+@@ -931,6 +977,7 @@ void QMetaObjectPublisher::setBlockUpdates(bool block)
+     blockUpdates = block;
+ 
+     if (!blockUpdates) {
++        timer.start(PROPERTY_UPDATE_INTERVAL, this);
+         sendPendingPropertyUpdates();
+     } else if (timer.isActive()) {
+         timer.stop();
+@@ -948,4 +995,15 @@ void QMetaObjectPublisher::timerEvent(QTimerEvent *event)
+     }
+ }
+ 
++SignalHandler<QMetaObjectPublisher> *QMetaObjectPublisher::signalHandlerFor(const QObject *object)
++{
++    auto thread = object->thread();
++    auto it = signalHandlers.find(thread);
++    if (it == signalHandlers.end()) {
++        it = signalHandlers.emplace(thread, this).first;
++        it->second.moveToThread(thread);
++    }
++    return &it->second;
++}
++
+ QT_END_NAMESPACE
+diff --git a/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h b/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
+index bbd9875..4713ef1 100644
+--- a/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
++++ b/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
+@@ -59,6 +59,9 @@
+ #include <QBasicTimer>
+ #include <QPointer>
+ #include <QJsonObject>
++#include <QQueue>
++
++#include <unordered_map>
+ 
+ #include "qwebchannelglobal.h"
+ 
+@@ -109,17 +112,36 @@ public:
+      */
+     void broadcastMessage(const QJsonObject &message) const;
+ 
++    /**
++     * Enqueue the given @p message to all known transports.
++     */
++    void enqueueBroadcastMessage(const QJsonObject &message);
++
++    /**
++     * Enqueue the given @p message to @p transport.
++     */
++    void enqueueMessage(const QJsonObject &message, QWebChannelAbstractTransport *transport);
++
++    /**
++     * If client for given @p transport is idle, send queued messaged to @p transport and then mark
++     * the client as not idle.
++     */
++    void sendEnqueuedPropertyUpdates(QWebChannelAbstractTransport *transport);
++
+     /**
+      * Serialize the QMetaObject of @p object and return it in JSON form.
+      */
+     QJsonObject classInfoForObject(const QObject *object, QWebChannelAbstractTransport *transport);
+ 
+     /**
+-     * Set the client to idle or busy, based on the value of @p isIdle.
+-     *
+-     * When the value changed, start/stop the property update timer accordingly.
++     * Set the client to idle or busy for a single @p transport, based on the value of @p isIdle.
++     */
++    void setClientIsIdle(bool isIdle, QWebChannelAbstractTransport *transport);
++
++    /**
++     * Check that client is idle for @p transport.
+      */
+-    void setClientIsIdle(bool isIdle);
++    bool isClientIdle(QWebChannelAbstractTransport *transport);
+ 
+     /**
+      * Initialize clients by sending them the class information of the registered objects.
+@@ -272,10 +294,18 @@ private:
+     friend class TestWebChannel;
+ 
+     QWebChannel *webChannel;
+-    SignalHandler<QMetaObjectPublisher> signalHandler;
++    std::unordered_map<const QThread*, SignalHandler<QMetaObjectPublisher>> signalHandlers;
++    SignalHandler<QMetaObjectPublisher> *signalHandlerFor(const QObject *object);
+ 
+-    // true when the client is idle, false otherwise
+-    bool clientIsIdle;
++    struct TransportState
++    {
++        TransportState() : clientIsIdle(false) { }
++        // true when the client is idle, false otherwise
++        bool clientIsIdle;
++        // messages to send
++        QQueue<QJsonObject> queuedMessages;
++    };
++    QHash<QWebChannelAbstractTransport *, TransportState> transportState;
+ 
+     // true when no property updates should be sent, false otherwise
+     bool blockUpdates;
+diff --git a/qtwebchannel/src/webchannel/signalhandler_p.h b/qtwebchannel/src/webchannel/signalhandler_p.h
+index 27afadb..d77373c 100644
+--- a/qtwebchannel/src/webchannel/signalhandler_p.h
++++ b/qtwebchannel/src/webchannel/signalhandler_p.h
+@@ -56,6 +56,7 @@
+ #include <QVector>
+ #include <QMetaMethod>
+ #include <QDebug>
++#include <QThread>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -71,6 +72,7 @@ static const int s_destroyedSignalIndex = QObject::staticMetaObject.indexOfMetho
+ template<class Receiver>
+ class SignalHandler : public QObject
+ {
++    Q_DISABLE_COPY(SignalHandler)
+ public:
+     SignalHandler(Receiver *receiver, QObject *parent = 0);
+ 
+@@ -268,6 +270,7 @@ int SignalHandler<Receiver>::qt_metacall(QMetaObject::Call call, int methodId, v
+     if (call == QMetaObject::InvokeMetaMethod) {
+         const QObject *object = sender();
+         Q_ASSERT(object);
++        Q_ASSERT(QThread::currentThread() == object->thread());
+         Q_ASSERT(senderSignalIndex() == methodId);
+         Q_ASSERT(m_connectionsCounter.contains(object));
+         Q_ASSERT(m_connectionsCounter.value(object).contains(methodId));
+diff --git a/qtwebchannel/tests/auto/qml/testwebchannel.cpp b/qtwebchannel/tests/auto/qml/testwebchannel.cpp
+index 9891687..3ca81c2 100644
+--- a/qtwebchannel/tests/auto/qml/testwebchannel.cpp
++++ b/qtwebchannel/tests/auto/qml/testwebchannel.cpp
+@@ -46,7 +46,11 @@ TestWebChannel::~TestWebChannel()
+ 
+ bool TestWebChannel::clientIsIdle() const
+ {
+-    return QWebChannel::d_func()->publisher->clientIsIdle;
++    for (auto *transport : QWebChannel::d_func()->transports) {
++        if (QWebChannel::d_func()->publisher->isClientIdle(transport))
++            return true;
++    }
++    return false;
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp b/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
+index 181da9e..37f989a 100644
+--- a/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
++++ b/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
+@@ -785,7 +785,7 @@ void TestWebChannel::testTransportWrapObjectProperties()
+     DummyTransport *dummyTransport = new DummyTransport(this);
+     channel.connectTo(dummyTransport);
+     channel.d_func()->publisher->initializeClient(dummyTransport);
+-    channel.d_func()->publisher->setClientIsIdle(true);
++    channel.d_func()->publisher->setClientIsIdle(true, dummyTransport);
+ 
+     QCOMPARE(channel.d_func()->publisher->transportedWrappedObjects.size(), 0);
+ 
+@@ -943,8 +943,6 @@ void TestWebChannel::testInfiniteRecursion()
+ 
+ void TestWebChannel::testAsyncObject()
+ {
+-    QSKIP("This test is broken. See QTBUG-80729");
+-
+     QWebChannel channel;
+     channel.connectTo(m_dummyTransport);
+ 
+@@ -990,6 +988,50 @@ void TestWebChannel::testAsyncObject()
+     thread.wait();
+ }
+ 
++void TestWebChannel::testPropertyMultipleTransports()
++{
++    DummyTransport transport1;
++    DummyTransport transport2;
++
++    QWebChannel channel;
++    QMetaObjectPublisher *publisher = channel.d_func()->publisher;
++
++    TestObject testObj;
++    testObj.setObjectName("testObject");
++    channel.registerObject(testObj.objectName(), &testObj);
++    channel.connectTo(&transport1);
++    channel.connectTo(&transport2);
++
++    testObj.setProp("Hello");
++
++    publisher->initializeClient(&transport1);
++    publisher->initializeClient(&transport2);
++    publisher->setClientIsIdle(true, &transport1);
++    QCOMPARE(publisher->isClientIdle(&transport1), true);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++    QVERIFY(transport1.messagesSent().isEmpty());
++    QVERIFY(transport2.messagesSent().isEmpty());
++
++    testObj.setProp("World");
++    QTRY_COMPARE_WITH_TIMEOUT(transport1.messagesSent().size(), 1u, 2000);
++    QCOMPARE(transport2.messagesSent().size(), 0u);
++    publisher->setClientIsIdle(true, &transport2);
++    QTRY_COMPARE_WITH_TIMEOUT(transport2.messagesSent().size(), 1u, 2000);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++
++    testObj.setProp("!!!");
++    publisher->setClientIsIdle(true, &transport2);
++    QCOMPARE(publisher->isClientIdle(&transport2), true);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QTRY_COMPARE_WITH_TIMEOUT(transport2.messagesSent().size(), 2u, 2000);
++    QCOMPARE(transport1.messagesSent().size(), 1u);
++    publisher->setClientIsIdle(true, &transport1);
++    QTRY_COMPARE_WITH_TIMEOUT(transport1.messagesSent().size(), 2u, 2000);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++}
++
+ class FunctionWrapper : public QObject
+ {
+     Q_OBJECT
+@@ -1082,7 +1124,7 @@ void TestWebChannel::benchInitializeClients()
+ 
+         publisher->propertyUpdatesInitialized = false;
+         publisher->signalToPropertyMap.clear();
+-        publisher->signalHandler.clear();
++        publisher->signalHandlers.clear();
+     }
+ }
+ 
+@@ -1107,7 +1149,7 @@ void TestWebChannel::benchPropertyUpdates()
+             obj->change();
+         }
+ 
+-        channel.d_func()->publisher->clientIsIdle = true;
++        channel.d_func()->publisher->setClientIsIdle(true, m_dummyTransport);
+         channel.d_func()->publisher->sendPendingPropertyUpdates();
+     }
+ }
+diff --git a/qtwebchannel/tests/auto/webchannel/tst_webchannel.h b/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
+index eae21f4..dd4e690 100644
+--- a/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
++++ b/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
+@@ -348,6 +348,7 @@ private slots:
+     void testJsonToVariant();
+     void testInfiniteRecursion();
+     void testAsyncObject();
++    void testPropertyMultipleTransports();
+     void testDeletionDuringMethodInvocation_data();
+     void testDeletionDuringMethodInvocation();
+ 
+Submodule qtwebengine f328054d...38e0df6c (commits not present)
+Submodule qtwebsockets 65850954..63fb8da1:
+diff --git a/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp b/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
+index 2affdd5..95f1194 100644
+--- a/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
++++ b/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
+@@ -273,6 +273,7 @@ void QWebSocketDataProcessor::clear()
+     if (!m_pConverterState)
+         m_pConverterState = new QTextCodec::ConverterState(QTextCodec::ConvertInvalidToNull |
+                                                            QTextCodec::IgnoreHeader);
++    frame.clear();
+ }
+ 
+ /*!
+diff --git a/qtwebsockets/src/websockets/qwebsocketprotocol.cpp b/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
+index df87a93..d0465f1 100644
+--- a/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
++++ b/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
+@@ -210,7 +210,7 @@ void QWebSocketProtocol::mask(char *payload, quint64 size, quint32 maskingKey)
+                             quint8((maskingKey & 0x0000FF00u) >> 8),
+                             quint8((maskingKey & 0x000000FFu))
+                           };
+-    int i = 0;
++    quint64 i = 0;
+     while (size-- > 0)
+         *payload++ ^= mask[i++ % 4];
+ }
diff --git a/srcpkgs/qt5/template b/srcpkgs/qt5/template
index f879df3a3e706..a0d3036af79a4 100644
--- a/srcpkgs/qt5/template
+++ b/srcpkgs/qt5/template
@@ -2,11 +2,11 @@
 #
 # revbump libqtxdg after bumping patch version
 pkgname=qt5
-version=5.15.7+20221119
+version=5.15.8
+revision=1
+build_style=meta
 # commit f8c9fb304bc3e53b3aa07f962cd74e9160decccc
 # base repo: https://invent.kde.org/qt/qt/qt5
-revision=8
-build_style=meta
 hostmakedepends="cmake clang flex perl glib-devel pkg-config
  python3 re2c ruby which"
 makedepends="SDL2-devel Vulkan-Headers alsa-lib-devel double-conversion-devel
@@ -29,9 +29,9 @@ homepage="https://qt.io/"
 # tarball is generated with `git archive-all qt5-$version.tar.gz`
 # to keep the size smaller qtwebengine, qtwebview, qtdocgallery, qtactiveqt and qtpim
 # can be marked with the export-ignore attribute
-distfiles="https://void.johnnynator.dev/distfiles/qt5-${version}.tar.gz"
-checksum=9d57af471c78029a362276b7c99108ea009f511bb9ba6ff6cb884f6ddd255e9f
-python_version=3
+distfiles="https://download.qt.io/archive/qt/5.15/${version}/single/qt-everywhere-opensource-src-${version}.tar.xz"
+checksum=776a9302c336671f9406a53bd30b8e36f825742b2ec44a57c08217bff0fa86b9
+python_version=2 #unverified
 replaces="qt5-doc<5.6.0 qt5-quick1<5.6.0 qt5-quick1-devel<5.6.0 qt5-webkit<5.6.0 qt5-webkit-devel<5.6.0
  qt5-enginio<5.7.1 qt5-enginio-devel<5.7.1 qt5-plugin-gtk<5.7.1 qt5-canvas3d<5.13.0"
 lib32mode=full
@@ -246,7 +246,6 @@ do_configure() {
 	# opts+=" -v"
 	opts+=" -skip qtwebengine"
 	opts+=" -skip qtwebview"
-	opts+=" -skip qtdocgallery"
 	opts+=" -skip qtpim"
 	opts+=" -skip qtsystems"
 	opts+=" -skip qtspeech"

From a9d83416fea3a65112d2b6529bd90c984e0edfbb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 061/115] qtav: revbump for ffmpeg4-4.4.3

---
 srcpkgs/qtav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qtav/template b/srcpkgs/qtav/template
index 775d5a139a9ef..2d00ad104355e 100644
--- a/srcpkgs/qtav/template
+++ b/srcpkgs/qtav/template
@@ -4,7 +4,7 @@ version=1.13.0
 revision=2
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel libass-devel libopenal-devel
+makedepends="ffmpeg4-devel libass-devel libopenal-devel
  libva-glx-devel libXv-devel pulseaudio-devel
  qt5-declarative-devel qt5-svg-devel
  qt5-quickcontrols"

From 1439fd6007f27f2ad9312c97ca421b568e7fdb7c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 062/115] qtox: revbump for ffmpeg-6.0

---
 srcpkgs/qtox/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qtox/template b/srcpkgs/qtox/template
index 39c643fecdb5a..bb70e7f51240a 100644
--- a/srcpkgs/qtox/template
+++ b/srcpkgs/qtox/template
@@ -1,7 +1,7 @@
 # Template file for 'qtox'
 pkgname=qtox
 version=1.17.6
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DUPDATE_CHECK=OFF
  -DGIT_DESCRIBE=${version}

From 9b716ace10d60eb396ab239580675294154cc7d6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 063/115] retroarch: revbump for ffmpeg-6.0

---
 srcpkgs/retroarch/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroarch/template b/srcpkgs/retroarch/template
index cb3125c5dbf1a..c65c26f7bf033 100644
--- a/srcpkgs/retroarch/template
+++ b/srcpkgs/retroarch/template
@@ -1,7 +1,7 @@
 # Template file for 'retroarch'
 pkgname=retroarch
 version=1.16.0.3
-revision=3
+revision=4
 build_style=configure
 configure_args="--prefix=/usr --sysconfdir=/etc --enable-networking
  --enable-udev --disable-builtinflac --disable-builtinglslang

From 43a1a104b75d4dc23aab86ec7c74d19fef939019 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 064/115] scrcpy: revbump for ffmpeg-6.0

---
 srcpkgs/scrcpy/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/scrcpy/template b/srcpkgs/scrcpy/template
index ac18bc03418ce..f39a7f678ab35 100644
--- a/srcpkgs/scrcpy/template
+++ b/srcpkgs/scrcpy/template
@@ -1,7 +1,7 @@
 # Template file for 'scrcpy'
 pkgname=scrcpy
 version=2.1.1
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcompile_server=false
  -Dprebuilt_server=/usr/share/scrcpy/scrcpy-server-v${version}"

From 6f22506b8bd67982ac2b94fe85f804cd27758246 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 17 Oct 2023 08:54:11 -0400
Subject: [PATCH 065/115] New package: spex-x replaces spek-alternative for
 ffmpeg-6.0

---
 srcpkgs/spek-alternative                      |  1 +
 srcpkgs/{spek-alternative => spek-x}/template | 22 ++++++++++++-------
 2 files changed, 15 insertions(+), 8 deletions(-)
 create mode 120000 srcpkgs/spek-alternative
 rename srcpkgs/{spek-alternative => spek-x}/template (52%)

diff --git a/srcpkgs/spek-alternative b/srcpkgs/spek-alternative
new file mode 120000
index 0000000000000..76648236da701
--- /dev/null
+++ b/srcpkgs/spek-alternative
@@ -0,0 +1 @@
+spek-x
\ No newline at end of file
diff --git a/srcpkgs/spek-alternative/template b/srcpkgs/spek-x/template
similarity index 52%
rename from srcpkgs/spek-alternative/template
rename to srcpkgs/spek-x/template
index d7b55c776b1d4..3ded6c2c323e4 100644
--- a/srcpkgs/spek-alternative/template
+++ b/srcpkgs/spek-x/template
@@ -1,18 +1,18 @@
-# Template file for 'spek-alternative'
-pkgname=spek-alternative
-version=0.8.2.3
-revision=2
+# Template file for 'spek-x'
+pkgname=spek-x
+version=0.9.3
+revision=1
 build_style=gnu-configure
 hostmakedepends="automake gettext-devel intltool libtool pkg-config
  wxWidgets-common wxWidgets-gtk3-devel"
 makedepends="ffmpeg-devel wxWidgets-gtk3-devel"
 depends="ffmpeg"
 short_desc="Acoustic spectrum analyser"
-maintainer="Kartik Singh <kartik.ynwa@gmail.com>"
+maintainer="zlice <zlice555@gmail.com>"
 license="GPL-3.0-or-later"
-homepage="https://github.com/withmorten/spek-alternative"
-distfiles="https://github.com/withmorten/spek-alternative/archive/${version}.tar.gz"
-checksum="007ba4b84a310b078e378aa84c8e80783db5821437a757a488c3ecec377e6b2a"
+homepage="https://github.com/MikeWang000000/spek-x"
+distfiles="https://github.com/MikeWang000000/spek-x/archive/v${version}.tar.gz"
+checksum="7f4b109903333cdd310ab2b9176f0dc49a565891376e281a233d342cedf90ef7"
 
 CXXFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
 
@@ -22,3 +22,9 @@ export WX_CONFIG_NAME="wx-config-gtk3"
 pre_configure() {
 	NOCONFIGURE=1 ./autogen.sh
 }
+
+spek-alternative_package() {
+	depends="spek-x"
+	short_desc+=" - transitional dummy package"
+	build_style=meta
+}

From 9def6621a4aee970bc5b5fa6e062dc912f0ebc69 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 066/115] ssr: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ssr/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ssr/template b/srcpkgs/ssr/template
index 842b2423aad10..3448ca110eb0c 100644
--- a/srcpkgs/ssr/template
+++ b/srcpkgs/ssr/template
@@ -5,7 +5,7 @@ revision=2
 build_style=cmake
 configure_args="-DWITH_QT5=ON"
 hostmakedepends="pkg-config"
-makedepends="alsa-lib-devel ffmpeg-devel glu-devel jack-devel pulseaudio-devel
+makedepends="alsa-lib-devel ffmpeg4-devel glu-devel jack-devel pulseaudio-devel
  qt5-tools-devel qt5-x11extras-devel libXinerama-devel v4l-utils-devel"
 depends="desktop-file-utils hicolor-icon-theme"
 short_desc="Simple Screen Recorder for programs and games"

From 9ef6a8402b9cad2e219feeaad2062b8ca9c2bbf9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 067/115] synfig: revbump for ffmpeg-6.0 and mlt7

---
 srcpkgs/synfig/patches/ffmpeg6.patch | 71 ++++++++++++++++++++++++++++
 srcpkgs/synfig/template              |  4 +-
 2 files changed, 73 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/synfig/patches/ffmpeg6.patch

diff --git a/srcpkgs/synfig/patches/ffmpeg6.patch b/srcpkgs/synfig/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..10780b42782f4
--- /dev/null
+++ b/srcpkgs/synfig/patches/ffmpeg6.patch
@@ -0,0 +1,71 @@
+--- a/src/modules/mod_libavcodec/trgt_av.cpp	2022-10-25 09:14:12.000000000 -0400
++++ b/src/modules/mod_libavcodec/trgt_av.cpp	2023-05-05 21:34:17.899194559 -0400
+@@ -38,6 +41,7 @@
+ extern "C"
+ {
+ #ifdef HAVE_LIBAVFORMAT_AVFORMAT_H
++#	include <libavcodec/avcodec.h>
+ #	include <libavformat/avformat.h>
+ #elif defined(HAVE_AVFORMAT_H)
+ #	include <avformat.h>
+@@ -155,11 +156,11 @@
+     }
+ 
+ 	bool open_video_stream() {
+-		if (avcodec_open2(video_context, NULL, NULL) < 0) {
++		if (avcodec_open2(video_context, nullptr, nullptr) < 0) {
+ 			synfig::error("Target_LibAVCodec: could not open video codec");
+ 			// seems the calling of avcodec_free_context after error will cause crash
+ 			// so just forget about this context
+-			video_context = NULL;
++			video_context = nullptr;
+ 			close();
+ 			return false;
+         }
+@@ -234,15 +235,21 @@
+ 		close();
+ 
+ 		if (!av_registered) {
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 			av_register_all();
++#endif
+ 			av_registered = true;
+ 		}
+ 
+ 		// guess format
+-		AVOutputFormat *format = av_guess_format(NULL, filename.c_str(), NULL);
++#if LIBAVCODEC_VERSION_MAJOR < 59 // FFMPEG < 5.0
++		AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#else
++		const AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#endif
+ 		if (!format) {
+ 			synfig::warning("Target_LibAVCodec: unable to guess the output format, defaulting to MPEG");
+-			format = av_guess_format("mpeg", NULL, NULL);
++			format = av_guess_format("mpeg", nullptr, nullptr);
+ 		}
+ 		if (!format) {
+ 			synfig::error("Target_LibAVCodec: unable to find 'mpeg' output format");
+@@ -254,6 +261,7 @@
+ 		context = avformat_alloc_context();
+ 		assert(context);
+ 		context->oformat = format;
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 		if (filename.size() + 1 > sizeof(context->filename)) {
+ 			synfig::error(
+ 				"Target_LibAVCodec: filename too long, max length is %d, filename is '%s'",
+@@ -263,6 +271,14 @@
+ 			return false;
+ 		}
+ 		memcpy(context->filename, filename.c_str(), filename.size() + 1);
++#else
++		context->url = av_strndup(filename.c_str(), filename.size());
++		if (!context->url) {
++			synfig::error("Target_LibAVCodec: cannot allocate space for filename");
++			close();
++			return false;
++		}
++#endif
+ 
+ 		packet = av_packet_alloc();
+ 		assert(packet);
diff --git a/srcpkgs/synfig/template b/srcpkgs/synfig/template
index d4d3e341a20bf..703cfd7ebac84 100644
--- a/srcpkgs/synfig/template
+++ b/srcpkgs/synfig/template
@@ -6,7 +6,7 @@ revision=4
 build_style=gnu-configure
 configure_args="--with-boost-libdir=${XBPS_CROSS_BASE}/usr/lib"
 hostmakedepends="boost-build ImageMagick pkg-config intltool"
-makedepends="ETL gettext-devel libxml++-devel mlt-devel libmagick-devel
+makedepends="ETL gettext-devel libxml++-devel mlt7-devel libmagick-devel
  libmng-devel boost-build boost-devel libopenexr-devel ffmpeg-devel"
 depends="ImageMagick"
 short_desc="CLI 2D vector and timeline-based animation software"
@@ -20,7 +20,7 @@ CXXFLAGS="-std=c++11 -DHAVE_LOCALE_H=1"
 
 synfig-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision}
-	 libopenexr-devel libxml++-devel mlt-devel"
+	 libopenexr-devel libxml++-devel mlt7-devel"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/bin/synfig-config

From cbd72ae12a2a608c1e59d331d0af7652b308fd0c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 068/115] timg: revbump for ffmpeg-6.0

---
 srcpkgs/timg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/timg/template b/srcpkgs/timg/template
index 2a2ab763d2fdd..8fb4327535ef9 100644
--- a/srcpkgs/timg/template
+++ b/srcpkgs/timg/template
@@ -1,7 +1,7 @@
 # Template file for 'timg'
 pkgname=timg
 version=1.4.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_OPENSLIDE_SUPPORT=off -Wno-dev"
 hostmakedepends="pkg-config git"

From 1bea1f2fc375cd559f62a07bb916a5a051d874e1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 069/115] tvheadend: revbump for ffmpeg4-4.4.3

---
 srcpkgs/tvheadend/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tvheadend/template b/srcpkgs/tvheadend/template
index 9aea7de4ec705..012d31c4879ff 100644
--- a/srcpkgs/tvheadend/template
+++ b/srcpkgs/tvheadend/template
@@ -8,7 +8,7 @@ configure_args="--enable-dvbscan --disable-ffmpeg_static
 --disable-libx265_static --disable-libvpx_static --disable-libtheora_static
 --disable-libvorbis_static --disable-libfdkaac_static"
 hostmakedepends="gettext pkg-config python3 git which"
-makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg-devel"
+makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg4-devel"
 short_desc="TV streaming server"
 maintainer="lemmi <lemmi@nerd2nerd.org>"
 license="GPL-3.0-only"

From 5c17d8d13cbd8b336e996992248845cc2a214dcb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 070/115] unpaper: update to 7.0.0.

---
 srcpkgs/unpaper/template | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/srcpkgs/unpaper/template b/srcpkgs/unpaper/template
index 38ed47a584016..1ff910e722afc 100644
--- a/srcpkgs/unpaper/template
+++ b/srcpkgs/unpaper/template
@@ -1,13 +1,13 @@
 # Template file for 'unpaper'
 pkgname=unpaper
-version=6.1
-revision=3
-build_style=gnu-configure
+version=7.0.0
+revision=1
+build_style=meson
+hostmakedepends="pkg-config meson libxslt"
+makedepends="ffmpeg-devel python3-Sphinx"
+short_desc="Post-processing tool for scanned sheets of paper"
 maintainer="Orphaned <orphan@voidlinux.org>"
-hostmakedepends="pkg-config libxslt"
-makedepends="ffmpeg-devel"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://www.flameeyes.eu/projects/unpaper"
-short_desc="A post-processing tool for scanned sheets of paper"
 distfiles="https://www.flameeyes.eu/files/${pkgname}-${version}.tar.xz"
-checksum=237c84f5da544b3f7709827f9f12c37c346cdf029b1128fb4633f9bafa5cb930
+checksum=2575fbbf26c22719d1cb882b59602c9900c7f747118ac130883f63419be46a80

From 0c4e499508b9b7c506490a0ac4ce1720fb43eafd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 071/115] vba-m: revbump for ffmpeg-6.0

---
 srcpkgs/vba-m/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vba-m/template b/srcpkgs/vba-m/template
index 9c71cefe3f8dd..2223d297c31f5 100644
--- a/srcpkgs/vba-m/template
+++ b/srcpkgs/vba-m/template
@@ -2,7 +2,7 @@
 pkgname=vba-m
 reverts=1292_2
 version=2.1.7
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DENABLE_GTK=TRUE -DENABLE_FFMPEG=TRUE -DENABLE_LINK=TRUE -DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="gettext pkg-config unzip zip yasm wxWidgets-gtk3-devel"

From f6944b6a796a147d4e22728abd227624224df2af Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 072/115] vice: revbump for ffmpeg4-4.4.3

---
 srcpkgs/vice/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vice/template b/srcpkgs/vice/template
index b1f866d35095e..4beab2c5f9ebd 100644
--- a/srcpkgs/vice/template
+++ b/srcpkgs/vice/template
@@ -26,7 +26,7 @@ makedepends="
 	$(vopt_if gtk3 gtk+3-devel)
 	$(vopt_if gtk3 pulseaudio-devel)
 	$(vopt_if gtk3 pango-devel)
-	$(vopt_if ffmpeg ffmpeg-devel)"
+	$(vopt_if ffmpeg ffmpeg4-devel)"
 short_desc="Emulator for C64, C128, CBM-II, PET, VIC20, Plus4 and C16"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"

From 90249a8c57a3138fccaa992a887ed5c7733f49c8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 073/115] waypipe: revbump for ffmpeg-6.0

---
 srcpkgs/waypipe/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waypipe/template b/srcpkgs/waypipe/template
index 6da88b21bf2a1..4da8058400b58 100644
--- a/srcpkgs/waypipe/template
+++ b/srcpkgs/waypipe/template
@@ -1,7 +1,7 @@
 # Template file for 'waypipe'
 pkgname=waypipe
 version=0.8.6
-revision=1
+revision=2
 build_style=meson
 # lto is off because it causes linking errors in armv6l and armv7l (due to NEON)
 configure_args="-Dwerror=false -Dwith_dmabuf=enabled -Dwith_lz4=enabled

From bf5f11a8c3d8a905738ad16c24af05060d252672 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 074/115] xpra: revbump for ffmpeg-6.0

---
 srcpkgs/xpra/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xpra/template b/srcpkgs/xpra/template
index 394718b56f686..34fbff9b2f1ae 100644
--- a/srcpkgs/xpra/template
+++ b/srcpkgs/xpra/template
@@ -1,7 +1,7 @@
 # Template file for 'xpra'
 pkgname=xpra
 version=5.0.3
-revision=1
+revision=2
 build_style=python3-module
 make_build_args="--without-cuda_kernels --without-cuda_rebuild"
 make_install_args="$(vopt_with docs) ${make_build_args}"

From b83cdd6e60d84ebe175ccbdc12846c02eb00f3e1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:07:40 -0400
Subject: [PATCH 075/115] nv-codec-headers: update to 12.0.16.0

---
 srcpkgs/nv-codec-headers/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/nv-codec-headers/template b/srcpkgs/nv-codec-headers/template
index 3d422a61e4891..251e057f826fb 100644
--- a/srcpkgs/nv-codec-headers/template
+++ b/srcpkgs/nv-codec-headers/template
@@ -1,6 +1,6 @@
 # Template file for 'nv-codec-headers'
 pkgname=nv-codec-headers
-version=11.1.5.1
+version=12.0.16.0
 revision=1
 build_style=gnu-makefile
 short_desc="FFmpeg version of headers required to interface with Nvidias codec APIs"
@@ -8,7 +8,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="MIT"
 homepage="http://git.videolan.org/?p=ffmpeg/nv-codec-headers.git"
 distfiles="https://github.com/FFmpeg/nv-codec-headers/archive/n${version}.tar.gz"
-checksum=d095fbd56aa93772471a323be0ebe65504a0f43f06c76a30b6d25da77b06ae9c
+checksum=2a1533b65f55f9da52956faf0627ed3b74868ac0c7f269990edd21369113b48f
 
 post_install() {
 	sed -n '4,25p' include/ffnvcodec/nvEncodeAPI.h > LICENSE

From 37ecf3ba5e1bb66c4f2a04ad65a9baab1068584b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:08:40 -0400
Subject: [PATCH 076/115] openimagedenoise: revbump for ffmpeg-6.0

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index b792813dba7c2..109deb171c3f7 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,7 +1,7 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
 version=1.4.3
-revision=1
+revision=2
 archs="x86_64*"
 build_style=cmake
 hostmakedepends="ispc python3"

From 186f45c15ef90afcbffa778c9425d40dd882593e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:31:45 -0400
Subject: [PATCH 077/115] shotcut: revbump for ffmpeg-6.0

---
 srcpkgs/shotcut/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/shotcut/template b/srcpkgs/shotcut/template
index 33141fbd862d7..f46cb53b6bfb9 100644
--- a/srcpkgs/shotcut/template
+++ b/srcpkgs/shotcut/template
@@ -1,7 +1,7 @@
 # Template file for 'shotcut'
 pkgname=shotcut
 version=23.09.29
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSHOTCUT_VERSION=${version}"
 hostmakedepends="pkg-config qt6-tools-devel"

From 862621f40ae71473d8e94189616bc5810aabbf46 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:30 -0400
Subject: [PATCH 078/115] shiboken2: revbump for qt5-5.15.8

---
 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch | 1 +
 srcpkgs/shiboken2/template                                 | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
 create mode 120000 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
new file mode 120000
index 0000000000000..efcf3249bd885
--- /dev/null
+++ b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1 @@
+../../python3-pyside2/patches/importlib-machinery-bypass.patch
\ No newline at end of file
diff --git a/srcpkgs/shiboken2/template b/srcpkgs/shiboken2/template
index 883d6a084d868..f3c06ec245a1f 100644
--- a/srcpkgs/shiboken2/template
+++ b/srcpkgs/shiboken2/template
@@ -1,7 +1,7 @@
 # Template file for 'shiboken2'
 pkgname=shiboken2
 version=5.15.10
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/shiboken2"
 build_style=cmake

From 3970792f1a2f844780179bbd3f25e392ed8a4eac Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:53 -0400
Subject: [PATCH 079/115] python3-pyside2: revbump for qt5-5.15.8

---
 .../patches/importlib-machinery-bypass.patch      | 15 +++++++++++++++
 srcpkgs/python3-pyside2/template                  |  2 +-
 2 files changed, 16 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
new file mode 100644
index 0000000000000..64c429584776b
--- /dev/null
+++ b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1,15 @@
+Using this prevents an error around line 220 below it.
+"AttributeError: module 'importlib' has no attribute 'machinery'"
+The old backup logic is in place and compiles without issues.
+--- a/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:09:34.688912402 -0400
++++ b/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:10:03.395529582 -0400
+@@ -170,9 +170,6 @@
+
+     # 'zipstring_sequence' comes from signature.cpp
+     zipbytes = base64.b64decode(''.join(zipstring_sequence))
+-    if sys.version_info[0] >= 3:
+-        vzip = zipfile.ZipFile(io.BytesIO(zipbytes))
+-        return sys.meta_path, EmbeddableZipImporter(vzip)
+
+     # Old version for Python 2.7, only.
+     import os
diff --git a/srcpkgs/python3-pyside2/template b/srcpkgs/python3-pyside2/template
index 249efa9098842..52626436ce75f 100644
--- a/srcpkgs/python3-pyside2/template
+++ b/srcpkgs/python3-pyside2/template
@@ -1,7 +1,7 @@
 # Template file for 'python3-pyside2'
 pkgname=python3-pyside2
 version=5.15.10
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/pyside2"
 build_style=cmake

From f0062136eba55d66db7421cec244b5808a2f0daf Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:35 -0400
Subject: [PATCH 080/115] konqueror: revbump for ffmpeg-6.0

---
 srcpkgs/konqueror/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/konqueror/template b/srcpkgs/konqueror/template
index abfa59e6b7ded..3cc29c12dc1db 100644
--- a/srcpkgs/konqueror/template
+++ b/srcpkgs/konqueror/template
@@ -1,11 +1,11 @@
 # Template file for 'konqueror'
 pkgname=konqueror
 version=23.08.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DDESKTOPTOJSON_EXECUTABLE=/usr/bin/desktoptojson"
 hostmakedepends="extra-cmake-modules python3 qt5-host-tools qt5-qmake kdoctools
-kcoreaddons kconfig gettext"
+ kcoreaddons kconfig gettext"
 makedepends="qt5-devel qt5-webengine-devel qt5-declarative-devel
  qt5-webchannel-devel qt5-location-devel kcmutils-devel kdelibs4support-devel
  karchive-devel khtml-devel kdesu-devel kactivities5-devel"

From 0dc87f8b19c53c722fd7218f3c0b2de3478937d5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:58 -0400
Subject: [PATCH 081/115] qt5-speech: revbump for qt5-5.15.8

---
 srcpkgs/qt5-speech/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-speech/template b/srcpkgs/qt5-speech/template
index 3ecd10d50650c..2d7d4d4d24535 100644
--- a/srcpkgs/qt5-speech/template
+++ b/srcpkgs/qt5-speech/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-speech'
 pkgname=qt5-speech
 version=5.15.7
-revision=2
+revision=3
 _commit=d32f4a479d38a11f547598004b975f4356424a16
 build_style=qmake
 configure_args="-- -flite -flite-alsa -speechd"

From 3abb8d1331e9da5ade3e529c2153aefb4a799898 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 18:38:50 -0400
Subject: [PATCH 082/115] qt5-styleplugins: revbump for qt5-5.15.8

---
 srcpkgs/qt5-styleplugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-styleplugins/template b/srcpkgs/qt5-styleplugins/template
index 96ed97d12cd24..30d93660a2a4e 100644
--- a/srcpkgs/qt5-styleplugins/template
+++ b/srcpkgs/qt5-styleplugins/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-styleplugins'
 pkgname=qt5-styleplugins
 version=5.0.0
-revision=20
+revision=21
 _gitrev=335dbece103e2cbf6c7cf819ab6672c2956b17b3
 build_style=qmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From df24fdf4d023329a557c22d8f3a20377613a7ad6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 7 May 2023 20:15:03 -0400
Subject: [PATCH 083/115] qt6-webengine: revbump for ffmpeg-6.0

---
 srcpkgs/qt6-webengine/template | 1 +
 1 file changed, 1 insertion(+)

diff --git a/srcpkgs/qt6-webengine/template b/srcpkgs/qt6-webengine/template
index 98cdc680481b3..f33a71bd2a0dc 100644
--- a/srcpkgs/qt6-webengine/template
+++ b/srcpkgs/qt6-webengine/template
@@ -158,6 +158,7 @@ pre_install() {
 }
 
 post_install() {
+	vlicense LICENSES/BSD-3-Clause.txt
 	local _file
 	find "${DESTDIR}"/usr/lib/qt6/examples \
 		-path '*/lib/qt6/**/lib/qt6/*' -type f |

From b6dc4e9bbbce93c55fe4e978e02c5e05f766f566 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Jun 2023 08:20:22 -0400
Subject: [PATCH 084/115] gtk4: revbump for ffmpeg-6.0

---
 srcpkgs/gtk4/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gtk4/template b/srcpkgs/gtk4/template
index 6a4e20357a86f..ec0c13d2cc5b0 100644
--- a/srcpkgs/gtk4/template
+++ b/srcpkgs/gtk4/template
@@ -1,7 +1,7 @@
 # Template file for 'gtk4'
 pkgname=gtk4
 version=4.12.3
-revision=1
+revision=2
 build_style=meson
 build_helper="gir"
 configure_args="-Dman-pages=true -Ddocumentation=true -Dbuild-tests=false

From bc18798d564b4a44ecc46c42c7dc616f76781f2e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:28:26 -0400
Subject: [PATCH 085/115] siril: revbump for ffmpeg-6.0

---
 srcpkgs/siril/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/siril/template b/srcpkgs/siril/template
index 84332f79d060d..62750dd247548 100644
--- a/srcpkgs/siril/template
+++ b/srcpkgs/siril/template
@@ -1,7 +1,7 @@
 # Template file for 'siril'
 pkgname=siril
 version=0.9.12
-revision=10
+revision=11
 build_style=gnu-configure
 hostmakedepends="pkg-config intltool autoconf automake gettext-devel"
 makedepends="fftw-devel libconfig-devel libopencv-devel libffms2-devel

From 6d81a61b2842ff5dc2e3223a35b02c218897b23f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 22 Jun 2023 10:25:02 -0400
Subject: [PATCH 086/115] kdenlive: revbump for ffmpeg-6.0

---
 srcpkgs/kdenlive/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kdenlive/template b/srcpkgs/kdenlive/template
index ec5fe75860948..e69ecff31f272 100644
--- a/srcpkgs/kdenlive/template
+++ b/srcpkgs/kdenlive/template
@@ -1,7 +1,7 @@
 # Template file for 'kdenlive'
 pkgname=kdenlive
 version=23.08.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="
  extra-cmake-modules kconfig kcoreaddons kdoctools pkg-config python3

From 1d386c5a39d2940e71a42623e8ed4cbb11d29386 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Jul 2023 11:17:37 -0400
Subject: [PATCH 087/115] DELETE: intel_packages

---
 common/shlibs                                 |   2 +
 srcpkgs/intel-gmmlib/template                 |   2 +-
 ...mmon-Enable-MMC-in-free-kernel-build.patch | 125 ++++++++++++++++++
 srcpkgs/intel-media-driver/template           |   6 +-
 srcpkgs/intel-media-sdk/patches/musl.patch    |  14 ++
 srcpkgs/intel-media-sdk/template              |  37 ++++++
 srcpkgs/intel-media-sdk/update                |   1 +
 srcpkgs/libmfx                                |   1 +
 srcpkgs/libmfx-devel                          |   1 +
 srcpkgs/onevpl-devel                          |   1 +
 srcpkgs/onevpl-intel-gpu-devel                |   1 +
 srcpkgs/onevpl-intel-gpu/template             |  27 ++++
 srcpkgs/onevpl/template                       |  34 +++++
 13 files changed, 248 insertions(+), 4 deletions(-)
 create mode 100644 srcpkgs/intel-media-driver/patches/0001-Media-Common-Enable-MMC-in-free-kernel-build.patch
 create mode 100644 srcpkgs/intel-media-sdk/patches/musl.patch
 create mode 100644 srcpkgs/intel-media-sdk/template
 create mode 100644 srcpkgs/intel-media-sdk/update
 create mode 120000 srcpkgs/libmfx
 create mode 120000 srcpkgs/libmfx-devel
 create mode 120000 srcpkgs/onevpl-devel
 create mode 120000 srcpkgs/onevpl-intel-gpu-devel
 create mode 100644 srcpkgs/onevpl-intel-gpu/template
 create mode 100644 srcpkgs/onevpl/template

diff --git a/common/shlibs b/common/shlibs
index 7b20ec435781e..79aff9907ff38 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4254,6 +4254,8 @@ libgsoapssl++-2.8.124.so gsoap-2.8.124_1
 libjxl.so.0.8 libjxl-0.8.2_1
 libjxl_dec.so.0.8 libjxl-0.8.2_1
 libjxl_threads.so.0.8 libjxl-0.8.2_1
+libmfx.so.1 libmfx-22.6.4_1
+libvpl.so.2 onevpl-2023.1.2_1
 libtext-engine-0.1.so.0 text-engine-0.1.1_1
 libvmaf.so.1 vmaf-2.3.1_1
 liblc3.so.1 liblc3-1.0.3_1
diff --git a/srcpkgs/intel-gmmlib/template b/srcpkgs/intel-gmmlib/template
index b9df642f6320f..3d64be7415298 100644
--- a/srcpkgs/intel-gmmlib/template
+++ b/srcpkgs/intel-gmmlib/template
@@ -14,7 +14,7 @@ build_style=cmake
 # compilers flag in use.
 configure_args="-Wno-dev"
 short_desc="Intel Graphics Memory Management Library"
-maintainer="Orphaned <orphan@voidlinux.org>"
+maintainer="Stefano Ragni <st3r4g@protonmail.com>"
 license="MIT"
 homepage="https://github.com/intel/gmmlib"
 distfiles="https://github.com/intel/gmmlib/archive/intel-gmmlib-${version}.tar.gz"
diff --git a/srcpkgs/intel-media-driver/patches/0001-Media-Common-Enable-MMC-in-free-kernel-build.patch b/srcpkgs/intel-media-driver/patches/0001-Media-Common-Enable-MMC-in-free-kernel-build.patch
new file mode 100644
index 0000000000000..525fb688722c8
--- /dev/null
+++ b/srcpkgs/intel-media-driver/patches/0001-Media-Common-Enable-MMC-in-free-kernel-build.patch
@@ -0,0 +1,125 @@
+From e68feab7db036838d9521ba3b9f00717c37c024c Mon Sep 17 00:00:00 2001
+From: JayYang <jay.yang@intel.com>
+Date: Tue, 21 Mar 2023 17:17:55 +0800
+Subject: [PATCH] [Media Common] Enable MMC in free kernel build
+
+Add mmc build definition in free kernel build
+---
+ media_driver/agnostic/gen9/codec/hal/media_srcs.cmake          | 2 +-
+ media_driver/cmake/linux/media_feature_flags_linux.cmake       | 3 +--
+ .../media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp        | 2 +-
+ .../media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp        | 2 +-
+ .../media_interfaces_m9_glk/media_interfaces_g9_glk.cpp        | 2 +-
+ .../media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp        | 2 +-
+ .../media_interfaces_m9_skl/media_interfaces_g9_skl.cpp        | 2 +-
+ 7 files changed, 7 insertions(+), 8 deletions(-)
+
+diff --git a/media_driver/agnostic/gen9/codec/hal/media_srcs.cmake b/media_driver/agnostic/gen9/codec/hal/media_srcs.cmake
+index 8bb36bafe..78902a22d 100644
+--- a/media_driver/agnostic/gen9/codec/hal/media_srcs.cmake
++++ b/media_driver/agnostic/gen9/codec/hal/media_srcs.cmake
+@@ -27,7 +27,7 @@ set(TMP_1_HEADERS_
+     ${CMAKE_CURRENT_LIST_DIR}/codechal_hw_g9_X.h
+ )
+ 
+-if(${MMC_Supported} STREQUAL "yes")
++if(${MMC_Supported} STREQUAL "yes" AND ENABLE_NONFREE_KERNELS AND ENABLE_KERNELS)
+     set(TMP_1_SOURCES_
+         ${TMP_1_SOURCES_}
+         ${CMAKE_CURRENT_LIST_DIR}/codechal_memdecomp_g9.cpp
+diff --git a/media_driver/cmake/linux/media_feature_flags_linux.cmake b/media_driver/cmake/linux/media_feature_flags_linux.cmake
+index de0ca853f..8121ea60c 100644
+--- a/media_driver/cmake/linux/media_feature_flags_linux.cmake
++++ b/media_driver/cmake/linux/media_feature_flags_linux.cmake
+@@ -35,7 +35,6 @@ if(NOT ENABLE_KERNELS OR NOT ENABLE_NONFREE_KERNELS)
+     bs_set_if_undefined(HEVC_Encode_VME_Supported "no")
+     bs_set_if_undefined(MPEG2_Encode_VME_Supported "no")
+     bs_set_if_undefined(CMRT_HEVC_ENC_FEI_Supported "no")
+-    bs_set_if_undefined(MMC_Supported "no")
+     bs_set_if_undefined(VC1_Decode_Supported "no")
+     bs_set_if_undefined(Decode_Processing_Supported "no")
+     bs_set_if_undefined(Kernel_Auto_Denoise_Supported "no")
+@@ -46,7 +45,6 @@ else()
+     bs_set_if_undefined(HEVC_Encode_VME_Supported "${Encode_VME_Supported}")
+     bs_set_if_undefined(MPEG2_Encode_VME_Supported "${Encode_VME_Supported}")
+     bs_set_if_undefined(CMRT_HEVC_ENC_FEI_Supported "yes")
+-    bs_set_if_undefined(MMC_Supported "yes")
+     bs_set_if_undefined(VC1_Decode_Supported "yes")
+     bs_set_if_undefined(Decode_Processing_Supported "yes")
+     bs_set_if_undefined(Kernel_Auto_Denoise_Supported "yes")
+@@ -64,6 +62,7 @@ bs_set_if_undefined(VP9_Decode_Supported "yes")
+ bs_set_if_undefined(VP_SFC_Supported "yes")
+ bs_set_if_undefined(Common_Encode_Supported "yes")
+ bs_set_if_undefined(Media_Scalability_Supported "yes")
++bs_set_if_undefined(MMC_Supported "yes")
+ 
+ # features controlled by global flag Encode_VDEnc_Supported
+ bs_set_if_undefined(AVC_Encode_VDEnc_Supported "${Encode_VDEnc_Supported}")
+diff --git a/media_driver/media_interface/media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp b/media_driver/media_interface/media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp
+index 3f306ee2a..8e4c0f532 100644
+--- a/media_driver/media_interface/media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_bxt/media_interfaces_g9_bxt.cpp
+@@ -135,7 +135,7 @@ MOS_STATUS MhwInterfacesG9Bxt::Initialize(
+ 
+     return MOS_STATUS_SUCCESS;
+ }
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool bxtRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Bxt>((uint32_t)IGFX_BROXTON);
+diff --git a/media_driver/media_interface/media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp b/media_driver/media_interface/media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp
+index b8fa1eec0..84e0fad1d 100644
+--- a/media_driver/media_interface/media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_cfl/media_interfaces_g9_cfl.cpp
+@@ -44,7 +44,7 @@ static bool cflRegisteredMhw =
+     MediaFactory<uint32_t, MhwInterfaces>::
+     Register<MhwInterfacesG9Kbl>((uint32_t)IGFX_COFFEELAKE);
+ 
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool cflRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Kbl>((uint32_t)IGFX_COFFEELAKE);
+diff --git a/media_driver/media_interface/media_interfaces_m9_glk/media_interfaces_g9_glk.cpp b/media_driver/media_interface/media_interfaces_m9_glk/media_interfaces_g9_glk.cpp
+index de81e6091..2638cb3a6 100644
+--- a/media_driver/media_interface/media_interfaces_m9_glk/media_interfaces_g9_glk.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_glk/media_interfaces_g9_glk.cpp
+@@ -65,7 +65,7 @@ static bool glkRegisteredMhw =
+     MediaFactory<uint32_t, MhwInterfaces>::
+     Register<MhwInterfacesG9Kbl>((uint32_t)IGFX_GEMINILAKE);
+ 
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool glkRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Kbl>((uint32_t)IGFX_GEMINILAKE);
+diff --git a/media_driver/media_interface/media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp b/media_driver/media_interface/media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp
+index 99d786185..4e9c6e7f1 100644
+--- a/media_driver/media_interface/media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_kbl/media_interfaces_g9_kbl.cpp
+@@ -131,7 +131,7 @@ MOS_STATUS MhwInterfacesG9Kbl::Initialize(
+ 
+     return MOS_STATUS_SUCCESS;
+ }
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool kblRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Kbl>((uint32_t)IGFX_KABYLAKE);
+diff --git a/media_driver/media_interface/media_interfaces_m9_skl/media_interfaces_g9_skl.cpp b/media_driver/media_interface/media_interfaces_m9_skl/media_interfaces_g9_skl.cpp
+index e2520edf7..4b0012c64 100644
+--- a/media_driver/media_interface/media_interfaces_m9_skl/media_interfaces_g9_skl.cpp
++++ b/media_driver/media_interface/media_interfaces_m9_skl/media_interfaces_g9_skl.cpp
+@@ -139,7 +139,7 @@ MOS_STATUS MhwInterfacesG9Skl::Initialize(
+ 
+     return MOS_STATUS_SUCCESS;
+ }
+-#ifdef _MMC_SUPPORTED
++#if defined(_MMC_SUPPORTED) && defined(ENABLE_KERNELS) && !defined(_FULL_OPEN_SOURCE)
+ static bool sklRegisteredMmd =
+     MediaFactory<uint32_t, MmdDevice>::
+     Register<MmdDeviceG9Skl>((uint32_t)IGFX_SKYLAKE);
+-- 
+2.40.0
+
diff --git a/srcpkgs/intel-media-driver/template b/srcpkgs/intel-media-driver/template
index 06b7c19a0ba07..1735b90c65ce5 100644
--- a/srcpkgs/intel-media-driver/template
+++ b/srcpkgs/intel-media-driver/template
@@ -1,6 +1,6 @@
 # Template file for 'intel-media-driver'
 pkgname=intel-media-driver
-version=23.3.5
+version=22.6.4
 revision=1
 archs="x86_64*"
 build_style=cmake
@@ -8,11 +8,11 @@ configure_args="-Wno-dev -DENABLE_NONFREE_KERNELS=$(vopt_if nonfree ON OFF)"
 hostmakedepends="pkg-config"
 makedepends="libva-devel libX11-devel intel-gmmlib-devel libpciaccess-devel"
 short_desc="Intel Media Driver for VAAPI (Broadwell+)"
-maintainer="Orphaned <orphan@voidlinux.org>"
+maintainer="Stefano Ragni <st3r4g@protonmail.com>"
 license="MIT, BSD-3-Clause"
 homepage="https://github.com/intel/media-driver"
 distfiles="https://github.com/intel/media-driver/archive/intel-media-${version}.tar.gz"
-checksum=67fd15654bb3c596feb8c85e81221de5632e11f598421c35adc4453d727f0130
+checksum=0c04b9d74b92de41fd409b62913ce4afd799236c0b6bc1983a496990764e5d90
 
 build_options="nonfree"
 desc_option_nonfree="Enable nonfree kernels"
diff --git a/srcpkgs/intel-media-sdk/patches/musl.patch b/srcpkgs/intel-media-sdk/patches/musl.patch
new file mode 100644
index 0000000000000..4ae70924b744f
--- /dev/null
+++ b/srcpkgs/intel-media-sdk/patches/musl.patch
@@ -0,0 +1,14 @@
+--- a/tools/tracer/tracer/tracer_linux.cpp	2022-11-18 03:02:59.000000000 -0500
++++ b/tools/tracer/tracer/tracer_linux.cpp	2022-12-18 01:44:51.341542572 -0500
+@@ -32,6 +32,11 @@
+ #include <dlfcn.h>
+ #include "tracer.h"
+
++#ifndef RTLD_DEEPBIND
++// musl neither defines nor can use RTLD_DEEPBIND
++#define RTLD_DEEPBIND 0
++#endif
++
+ #if defined(__i386__)
+     #define LIBMFXHW "libmfxhw32.so.1"
+ #elif defined(__x86_64__)
diff --git a/srcpkgs/intel-media-sdk/template b/srcpkgs/intel-media-sdk/template
new file mode 100644
index 0000000000000..7aeab51802f8e
--- /dev/null
+++ b/srcpkgs/intel-media-sdk/template
@@ -0,0 +1,37 @@
+# Template file for 'intel-media-sdk'
+pkgname=intel-media-sdk
+version=22.6.4
+revision=1
+archs="x86_64*"
+build_style=cmake
+configure_args="-Wno-dev -DBUILD_SAMPLES=OFF -DBUILD_TESTS=ON"
+hostmakedepends="pkg-config"
+makedepends="libva-devel libdrm-devel intel-gmmlib-devel"
+short_desc="Intel Media SDK"
+maintainer="Stefano Ragni <st3r4g@protonmail.com>"
+license="MIT, BSD-3-Clause"
+homepage="https://github.com/Intel-Media-SDK/MediaSDK"
+distfiles="https://github.com/Intel-Media-SDK/MediaSDK/archive/refs/tags/intel-mediasdk-${version}.tar.gz"
+checksum=197acd056f81e9ff1c27068d50e8c84c2014d94c7ac17cad69d5c2d61e445fd3
+
+post_install() {
+	vlicense LICENSE
+}
+
+libmfx_package() {
+	depends="${makedepends} ${sourcepkg}-${version}_${revision}"
+	short_desc="Intel MediaSDK mfx lib"
+	pkg_install() {
+		vmove usr/lib/mfx
+		vmove "usr/lib/libmfx*.so*"
+	}
+}
+
+libmfx-devel_package() {
+	depends="${makedepends} ${sourcepkg}-${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+	}
+}
diff --git a/srcpkgs/intel-media-sdk/update b/srcpkgs/intel-media-sdk/update
new file mode 100644
index 0000000000000..434a2bc67f7a1
--- /dev/null
+++ b/srcpkgs/intel-media-sdk/update
@@ -0,0 +1 @@
+pkgname=intel-media
diff --git a/srcpkgs/libmfx b/srcpkgs/libmfx
new file mode 120000
index 0000000000000..8ffc7099c2272
--- /dev/null
+++ b/srcpkgs/libmfx
@@ -0,0 +1 @@
+intel-media-sdk
\ No newline at end of file
diff --git a/srcpkgs/libmfx-devel b/srcpkgs/libmfx-devel
new file mode 120000
index 0000000000000..8ffc7099c2272
--- /dev/null
+++ b/srcpkgs/libmfx-devel
@@ -0,0 +1 @@
+intel-media-sdk
\ No newline at end of file
diff --git a/srcpkgs/onevpl-devel b/srcpkgs/onevpl-devel
new file mode 120000
index 0000000000000..e2306500b4871
--- /dev/null
+++ b/srcpkgs/onevpl-devel
@@ -0,0 +1 @@
+onevpl
\ No newline at end of file
diff --git a/srcpkgs/onevpl-intel-gpu-devel b/srcpkgs/onevpl-intel-gpu-devel
new file mode 120000
index 0000000000000..47920ceecf919
--- /dev/null
+++ b/srcpkgs/onevpl-intel-gpu-devel
@@ -0,0 +1 @@
+onevpl-intel-gpu
\ No newline at end of file
diff --git a/srcpkgs/onevpl-intel-gpu/template b/srcpkgs/onevpl-intel-gpu/template
new file mode 100644
index 0000000000000..f14acb728a54d
--- /dev/null
+++ b/srcpkgs/onevpl-intel-gpu/template
@@ -0,0 +1,27 @@
+# Template file for 'onevpl-intel-gpu'
+pkgname=onevpl-intel-gpu
+version=22.6.4
+revision=1
+archs="x86_64*"
+build_style=cmake
+configure_args="-Wno-dev -DCMAKE_BUILD_TYPE=Release"
+hostmakedepends="cmake pkg-config"
+makedepends="libdrm-devel libva-devel onevpl-devel"
+short_desc="Runtime implementation of oneVPL API for Intel Gen GPUs"
+maintainer="zlice <zlice555@gmail.com>"
+license="MIT"
+homepage="https://github.com/oneapi-src/oneVPL-intel-gpu"
+changelog="https://github.com/oneapi-src/oneVPL-intel-gpu/blob/main/CHANGELOG.md"
+distfiles="https://github.com/oneapi-src/oneVPL-intel-gpu/archive/refs/tags/intel-onevpl-${version}.tar.gz"
+checksum=74b0979dcb2af1b7c68edb8cbcb02d539de511090b12fac50652cbacd707c4e6
+
+post_install() {
+	vlicense LICENSE
+}
+
+onevpl-intel-gpu-devel_package() {
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/lib/pkgconfig
+	}
+}
diff --git a/srcpkgs/onevpl/template b/srcpkgs/onevpl/template
new file mode 100644
index 0000000000000..85c7c2da85ce9
--- /dev/null
+++ b/srcpkgs/onevpl/template
@@ -0,0 +1,34 @@
+# Template file for 'onevpl'
+pkgname=onevpl
+version=2023.1.2
+revision=1
+archs="x86_64*"
+build_style=cmake
+configure_args="
+	-DCMAKE_BUILD_TYPE=Release -Wno-dev
+	-DBUILD_PYTHON_BINDING:BOOL='OFF'
+	-DBUILD_EXAMPLES:BOOL='OFF'
+	-DBUILD_TESTS:BOOL='ON'
+	-DINSTALL_EXAMPLE_CODE:BOOL='OFF'"
+hostmakedepends="cmake libX11 python wayland-protocols pkg-config"
+makedepends="libva-devel libX11-devel wayland-devel"
+short_desc="Intel oneAPI Video Processing library"
+maintainer="zlice <zlice555@gmail.com>"
+license="MIT"
+homepage="https://www.intel.com/content/www/us/en/developer/tools/oneapi/onevpl.html"
+distfiles="https://github.com/oneapi-src/oneVPL/archive/v${version}/${pkgname}-${version}.tar.gz"
+checksum=b2261cca174ce1815f3d47c647921ab17f68267c69c1e2444ff27aab7d199cbb
+
+post_install() {
+	vlicense LICENSE
+}
+
+onevpl-devel_package() {
+	depends="${makedepends} ${sourcepkg}-${version}_${revision}"
+	short_desc+=" - development files"
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.so"
+	}
+}

From 4a5b81fc50e1ad39c4af55f5835bb381fc5437a5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:20:59 -0400
Subject: [PATCH 088/115] tracker-miners: revbump for ffmpeg-6.0

---
 srcpkgs/tracker-miners/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tracker-miners/template b/srcpkgs/tracker-miners/template
index 0b97f47489f81..f196d2bf9e4a4 100644
--- a/srcpkgs/tracker-miners/template
+++ b/srcpkgs/tracker-miners/template
@@ -1,7 +1,7 @@
 # Template file for 'tracker-miners'
 pkgname=tracker-miners
 version=3.6.1
-revision=1
+revision=2
 build_style=meson
 build_helper=qemu
 # missing libgrss for miner_rss

From 0a7f446f0ffa13d08591f21e3080f876dfaa9ab1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:21:21 -0400
Subject: [PATCH 089/115] mpd: revbump for ffmpeg-6.0

---
 srcpkgs/mpd/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpd/template b/srcpkgs/mpd/template
index 645c1b778e407..60287cc9f6e3c 100644
--- a/srcpkgs/mpd/template
+++ b/srcpkgs/mpd/template
@@ -1,7 +1,7 @@
 # Template file for 'mpd'
 pkgname=mpd
 version=0.23.14
-revision=3
+revision=4
 build_style=meson
 configure_args="-Dopus=enabled -Dmikmod=enabled -Dneighbor=true
  -Dsoundcloud=enabled -Dpipe=true -Dtwolame=enabled -Dbzip2=enabled

From e409f8e5b78d1e93a13557e20cbc29d4a278f3f5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:02 -0400
Subject: [PATCH 090/115] tg_owt: revbump for ffmpeg-6.0

---
 srcpkgs/tg_owt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tg_owt/template b/srcpkgs/tg_owt/template
index 50bc8310b8859..c93262d5c5de6 100644
--- a/srcpkgs/tg_owt/template
+++ b/srcpkgs/tg_owt/template
@@ -1,7 +1,7 @@
 # Template file for 'tg_owt'
 pkgname=tg_owt
 version=0.0.0.20230921
-revision=1
+revision=2
 _commit=3bb3d757681e6cc5135aec6529a753dc3dcdcfb9
 _libyuv_commit=04821d1e7d60845525e8db55c7bcd41ef5be9406
 _abseil_commit=8c0b94e793a66495e0b1f34a5eb26bd7dc672db0

From f12e27b858c84c595f080db6546984f564e73481 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:44 -0400
Subject: [PATCH 091/115] telegram-desktop: revbump for ffmpeg-6.0

---
 srcpkgs/telegram-desktop/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/telegram-desktop/template b/srcpkgs/telegram-desktop/template
index 9bd94ce3781ff..d33fc62b10e38 100644
--- a/srcpkgs/telegram-desktop/template
+++ b/srcpkgs/telegram-desktop/template
@@ -1,7 +1,7 @@
 # Template file for 'telegram-desktop'
 pkgname=telegram-desktop
 version=4.11.2
-revision=1
+revision=2
 build_style=cmake
 build_helper="qemu gir"
 configure_args="-DTDESKTOP_API_ID=209235

From 1cdc8916d2c208a4b762a5c6a229cefa4db791fb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:11:45 -0400
Subject: [PATCH 092/115] gst-plugins-bad1: revbump for ffmpeg-6.0

---
 srcpkgs/gst-plugins-bad1/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index 2bf2f4b0642fe..0fafcb6555395 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-plugins-bad1'
 pkgname=gst-plugins-bad1
 version=1.22.5
-revision=1
+revision=2
 build_helper="gir"
 build_style=meson
 configure_args="-Dpackage-origin=https://voidlinux.org -Ddoc=disabled

From 2055479fb0dbe9110c38570eab840c12190e4cd6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:12:09 -0400
Subject: [PATCH 093/115] openmw: revbump for ffmpeg-6.0

---
 srcpkgs/openmw/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openmw/template b/srcpkgs/openmw/template
index 0abf5ff7cdbec..b57180f1a4446 100644
--- a/srcpkgs/openmw/template
+++ b/srcpkgs/openmw/template
@@ -1,7 +1,7 @@
 # Template file for 'openmw'
 pkgname=openmw
 version=0.48.0
-revision=2
+revision=3
 build_style=cmake
 _recast_commit=e75adf86f91eb3082220085e42dda62679f9a3ea
 _bullet_tag=3.17

From ec8568019793b2af2886b6b666f5c3bdbacc2b87 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:14:53 -0400
Subject: [PATCH 094/115] lms: revbump for ffmpeg-6.0

---
 srcpkgs/lms/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/lms/template b/srcpkgs/lms/template
index e358f75902a98..3b21c458de519 100644
--- a/srcpkgs/lms/template
+++ b/srcpkgs/lms/template
@@ -1,7 +1,7 @@
 # Template file for 'lms'
 pkgname=lms
 version=3.42.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="wt-devel ffmpeg-devel boost-devel libconfig++-devel taglib-devel pam-devel libgraphicsmagick-devel gtest-devel libarchive-devel"

From 0427c6f1706becd15ba9862b99d86b39e939f981 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:18:18 -0400
Subject: [PATCH 095/115] freecad: revbump for qt5-5.15.8

---
 srcpkgs/freecad/patches/001-include.patch     | 112 ------------------
 .../154-revert-gui-tmp-redirect-stderr.patch  |  68 -----------
 ...d63c8c9b1280978be841d04e68a0a55cceb9.patch |  30 -----
 srcpkgs/freecad/template                      |  13 +-
 4 files changed, 7 insertions(+), 216 deletions(-)
 delete mode 100644 srcpkgs/freecad/patches/001-include.patch
 delete mode 100644 srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
 delete mode 100644 srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch

diff --git a/srcpkgs/freecad/patches/001-include.patch b/srcpkgs/freecad/patches/001-include.patch
deleted file mode 100644
index 28b5af54999b9..0000000000000
--- a/srcpkgs/freecad/patches/001-include.patch
+++ /dev/null
@@ -1,112 +0,0 @@
-From 9a41845a417189776741297c50a3827ce292bc4f Mon Sep 17 00:00:00 2001
-From: Uwe <donovaly@users.noreply.github.com>
-Date: Sun, 3 Jul 2022 22:51:16 +0200
-Subject: [PATCH] [Part] OCCError.h: remove unneeded includes
-
-- also sort includes
----
- src/Mod/Part/App/OCCError.h             | 36 +++----------------------
- src/Mod/Part/App/OffsetCurvePyImp.cpp   | 12 ++++-----
- src/Mod/Part/App/OffsetSurfacePyImp.cpp | 10 +++----
- 3 files changed, 12 insertions(+), 46 deletions(-)
-
---- a/src/Mod/Part/App/OCCError.h
-+++ b/src/Mod/Part/App/OCCError.h
-@@ -23,36 +23,8 @@
- #ifndef _OCCError_h_
- #define _OCCError_h_
- 
--# include <Standard_Version.hxx>
- # include <Standard_Failure.hxx>
--# include <Standard_AbortiveTransaction.hxx>
--# include <Standard_ConstructionError.hxx>
--# if OCC_VERSION_HEX >= 0x060500
--# include <Standard_DefineException.hxx>
--# endif
--# include <Standard_DimensionError.hxx>
--# include <Standard_DimensionMismatch.hxx>
--# include <Standard_DivideByZero.hxx>
--# include <Standard_DomainError.hxx>
--# include <Standard_ImmutableObject.hxx>
--# include <Standard_LicenseError.hxx>
--# include <Standard_LicenseNotFound.hxx>
--# include <Standard_MultiplyDefined.hxx>
--# include <Standard_NegativeValue.hxx>
--# include <Standard_NoMoreObject.hxx>
--# include <Standard_NoSuchObject.hxx>
--# include <Standard_NotImplemented.hxx>
--# include <Standard_NullObject.hxx>
--# include <Standard_NullValue.hxx>
--# include <Standard_NumericError.hxx>
--# include <Standard_OutOfMemory.hxx>
--# include <Standard_OutOfRange.hxx>
--# include <Standard_Overflow.hxx>
--# include <Standard_ProgramError.hxx>
--# include <Standard_RangeError.hxx>
--# include <Standard_TooManyUsers.hxx>
--# include <Standard_TypeMismatch.hxx>
--# include <Standard_Underflow.hxx>
-+# include <Standard_Version.hxx>
- 
- #include <Mod/Part/PartGlobal.h>
- #include <Base/Console.h>
-@@ -88,4 +60,3 @@ PartExport extern PyObject* PartExceptio
- 
- #define PY_CATCH_OCC _PY_CATCH_OCC(return(NULL))
- #endif  // _OCCError_h_
--
---- a/src/Mod/Part/App/OffsetCurvePyImp.cpp
-+++ b/src/Mod/Part/App/OffsetCurvePyImp.cpp
-@@ -20,20 +20,20 @@
-  *                                                                         *
-  ***************************************************************************/
- 
--
- #include "PreCompiled.h"
- #ifndef _PreComp_
- # include <Geom_OffsetCurve.hxx>
- #endif
- 
--#include "OCCError.h"
--#include "Geometry.h"
-+#include <Base/GeometryPyCXX.h>
-+#include <Base/Vector3D.h>
-+#include <Base/VectorPy.h>
-+
- #include "OffsetCurvePy.h"
- #include "OffsetCurvePy.cpp"
-+#include "Geometry.h"
-+#include "OCCError.h"
- 
--#include <Base/GeometryPyCXX.h>
--#include <Base/VectorPy.h>
--#include <Base/Vector3D.h>
- 
- using namespace Part;
- 
---- a/src/Mod/Part/App/OffsetSurfacePyImp.cpp
-+++ b/src/Mod/Part/App/OffsetSurfacePyImp.cpp
-@@ -20,20 +20,16 @@
-  *                                                                         *
-  ***************************************************************************/
- 
--
- #include "PreCompiled.h"
- #ifndef _PreComp_
- # include <Geom_OffsetSurface.hxx>
- # include <memory>
- #endif
- 
--#include <Base/VectorPy.h>
--#include <Base/Vector3D.h>
--
- #include "OCCError.h"
--#include "Geometry.h"
--#include <Mod/Part/App/OffsetSurfacePy.h>
--#include <Mod/Part/App/OffsetSurfacePy.cpp>
-+#include "OffsetSurfacePy.h"
-+#include "OffsetSurfacePy.cpp"
-+
- 
- using namespace Part;
- 
diff --git a/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch b/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
deleted file mode 100644
index d6a9adabdec83..0000000000000
--- a/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
+++ /dev/null
@@ -1,68 +0,0 @@
-see https://github.com/FreeCAD/FreeCAD/commit/cfe94b00d3434f3e2c8b5114d2909f628c330fa8#commitcomment-71413407
-
-upstream: yes
-
-From 7b377a216b9185960e4cee980a6504dc1a755f50 Mon Sep 17 00:00:00 2001
-From: wmayer <wmayer@users.sourceforge.net>
-Date: Wed, 29 Jun 2022 15:19:18 +0200
-Subject: [PATCH] Gui: remove workaround for spnav 0.23 due to build failure
- with musl libc
-
----
- src/Gui/3Dconnexion/GuiNativeEventLinux.cpp | 27 ---------------------
- 1 file changed, 27 deletions(-)
-
---- a/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp
-+++ b/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp
-@@ -21,42 +21,17 @@
-  ***************************************************************************/
- 
- #include <FCConfig.h>
--#include <cstdio>
- 
- #include "GuiNativeEventLinux.h"
- 
- #include "GuiApplicationNativeEventAware.h"
- #include <Base/Console.h>
--#include <Base/FileInfo.h>
- #include <QMainWindow>
- 
- #include <QSocketNotifier>
- 
- #include <spnav.h>
- 
--namespace {
--class RedirectStdErr
--{
--public:
--    RedirectStdErr()
--        : fi(Base::FileInfo::getTempFileName())
--        , file(stderr)
--    {
--        stderr = fopen(fi.filePath().c_str(), "w");
--    }
--    ~RedirectStdErr()
--    {
--        fclose(stderr);
--        fi.deleteFile();
--        stderr = file;
--    }
--
--private:
--    Base::FileInfo fi;
--    FILE* file;
--};
--}
--
- Gui::GuiNativeEvent::GuiNativeEvent(Gui::GUIApplicationNativeEventAware *app)
- : GuiAbstractNativeEvent(app)
- {
-@@ -72,8 +47,6 @@ Gui::GuiNativeEvent::~GuiNativeEvent()
- 
- void Gui::GuiNativeEvent::initSpaceball(QMainWindow *window)
- {
--    // tmp. redirect stderr to a file to suppress an error message from spnav_open()
--    RedirectStdErr err;
-     Q_UNUSED(window)
-     if (spnav_open() == -1) {
-         Base::Console().Log("Couldn't connect to spacenav daemon. Please ignore if you don't have a spacemouse.\n");
diff --git a/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch b/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch
deleted file mode 100644
index d4acf370ca0a4..0000000000000
--- a/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-From fe02d63c8c9b1280978be841d04e68a0a55cceb9 Mon Sep 17 00:00:00 2001
-From: Roy-043 <70520633+Roy-043@users.noreply.github.com>
-Date: Thu, 29 Dec 2022 23:20:38 +0100
-Subject: [PATCH] Draft: update inspect.getargspec to inspect.getfullargspec
- (#8101)
-
----
- src/Mod/Draft/draftguitools/gui_snapper.py | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
---- a/src/Mod/Draft/draftguitools/gui_snapper.py
-+++ b/src/Mod/Draft/draftguitools/gui_snapper.py
-@@ -1426,7 +1426,7 @@ class Snapper:
-             Gui.Snapper.off()
-             self.ui.offUi()
-             if callback:
--                if len(inspect.getargspec(callback).args) > 1:
-+                if len(inspect.getfullargspec(callback).args) > 1:
-                     obj = None
-                     if self.snapInfo and ("Object" in self.snapInfo) and self.snapInfo["Object"]:
-                         obj = App.ActiveDocument.getObject(self.snapInfo["Object"])
-@@ -1445,7 +1445,7 @@ class Snapper:
-             Gui.Snapper.off()
-             self.ui.offUi()
-             if callback:
--                if len(inspect.getargspec(callback).args) > 1:
-+                if len(inspect.getfullargspec(callback).args) > 1:
-                     callback(None, None)
-                 else:
-                     callback(None)
diff --git a/srcpkgs/freecad/template b/srcpkgs/freecad/template
index c135701e38b9a..f8c5b9cf906c7 100644
--- a/srcpkgs/freecad/template
+++ b/srcpkgs/freecad/template
@@ -1,7 +1,7 @@
 # Template file for 'freecad'
 pkgname=freecad
-version=0.20.2
-revision=7
+version=0.21.1
+revision=2
 build_wrksrc="FreeCAD-${version}"
 build_style=cmake
 pycompile_dirs="usr/lib/${pkgname}/Mod"
@@ -23,9 +23,10 @@ makedepends="python3-devel boost-devel libxerces-c-devel zlib-devel occt-devel
  vtk-devel hdf5-devel openmpi-devel libmed-devel eigen double-conversion-devel
  coin3-devel libshiboken2-devel libspnav-devel pyside2-tools
  liblz4-devel libpyside2-python3-devel python3-matplotlib netcdf-devel
- jsoncpp-devel qt5-devel qt5-svg-devel qt5-tools-devel qt5-webkit-devel
- qt5-xmlpatterns-devel coin3-doc glew-devel python3-pivy"
-depends="python3-matplotlib python3-pyside2-webengine python3-pivy"
+ jsoncpp-devel qt5-devel qt5-svg-devel qt5-tools-devel qt5-webengine-devel
+ qt5-xmlpatterns-devel qt5-declarative-devel qt5-webchannel-devel qt5-location-devel
+ coin3-doc glew-devel python3-pivy"
+depends="python3-matplotlib python3-pyside2-webengine python3-pivy python3-GitPython python3-Markdown"
 short_desc="General purpose 3D CAD modeler"
 maintainer="yopito <pierre.bourgin@free.fr>"
 license="LGPL-2.0-or-later"
@@ -35,7 +36,7 @@ distfiles="
  https://github.com/FreeCAD/FreeCAD/archive/${version}.tar.gz
  ${SOURCEFORGE_SITE}/cxx/pycxx-${_pycxxver}.tar.gz
 "
-checksum="46922f3a477e742e1a89cd5346692d63aebb2b67af887b3e463e094a4ae055da
+checksum="e9b1fd0323f101268c7f3be52db42e4a29222f2e306ae6c4a6fc309cb418d35a
  4b91e1e1141c23fbd5039df635c4bb6e75632168548f56b83ce177193c0c98c6"
 python_version=3
 patch_args="-Np1 -d ${build_wrksrc}"

From 3be8af5038dcfe8c49cdb1ff5b5c58b0b4e50b0a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:47:18 -0400
Subject: [PATCH 096/115] libopenshot: revbump for ffmpeg-6.0

---
 srcpkgs/libopenshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenshot/template b/srcpkgs/libopenshot/template
index 8e57c5f592169..7a8f4520e7892 100644
--- a/srcpkgs/libopenshot/template
+++ b/srcpkgs/libopenshot/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenshot'
 pkgname=libopenshot
 version=0.3.0
-revision=3
+revision=4
 build_style=cmake
 # Builds fail with Ruby-2.4.1
 configure_args="-DENABLE_RUBY=OFF -DUSE_SYSTEM_JSONCPP=ON"

From 6b61c4d753abe9c8ee84e8e5afb0d3edb26193a4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:10:30 -0500
Subject: [PATCH 097/115] openimageio: revbump for ffmpeg-6.0

---
 srcpkgs/openimageio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimageio/template b/srcpkgs/openimageio/template
index 3ce3f9e49d350..27d2131bc0a61 100644
--- a/srcpkgs/openimageio/template
+++ b/srcpkgs/openimageio/template
@@ -1,7 +1,7 @@
 # Template file for 'openimageio'
 pkgname=openimageio
 version=2.4.9.0
-revision=7
+revision=8
 build_style=cmake
 build_helper=qemu
 configure_args="-DUSE_QT=0 -DUSE_PYTHON=0 -DOIIO_BUILD_TESTS=0

From 7219616b5cd2fca1538bcefdc2fd11e66acf5b06 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:11:57 -0500
Subject: [PATCH 098/115] synfigstudio: revbump for ffmpeg-6.0

---
 srcpkgs/synfigstudio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/synfigstudio/template b/srcpkgs/synfigstudio/template
index 09e442da9a680..2bc017cedca6b 100644
--- a/srcpkgs/synfigstudio/template
+++ b/srcpkgs/synfigstudio/template
@@ -2,7 +2,7 @@
 # Should be kept in sync with 'synfig' and 'ETL'
 pkgname=synfigstudio
 version=1.4.4
-revision=4
+revision=5
 build_style=gnu-configure
 configure_args="--disable-update-mimedb"
 hostmakedepends="pkg-config intltool gettext synfig"

From bc8823316e1d018edabcbc7f6f4241c1e38d8938 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:12:32 -0500
Subject: [PATCH 099/115] gmic: revbump for ffmpeg-6.0

---
 srcpkgs/gmic/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gmic/template b/srcpkgs/gmic/template
index 808953e9b543c..d854808f86aa4 100644
--- a/srcpkgs/gmic/template
+++ b/srcpkgs/gmic/template
@@ -1,7 +1,7 @@
 # Template file for 'gmic'
 pkgname=gmic
 version=3.1.6
-revision=5
+revision=6
 _zart_hash=34ebf6cce0bafb98abe57cec83c4a02cd1abeca0
 create_wrksrc=yes
 build_wrksrc="src"

From 4bdc31debe56477d6c99f4d7d39a7abd35031f70 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:10 -0500
Subject: [PATCH 100/115] mixxx: revbump for ffmpeg-6.0

---
 srcpkgs/mixxx/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mixxx/template b/srcpkgs/mixxx/template
index 6921996e4e77b..6a79b328c1abf 100644
--- a/srcpkgs/mixxx/template
+++ b/srcpkgs/mixxx/template
@@ -1,7 +1,7 @@
 # Template file for 'mixxx'
 pkgname=mixxx
 version=2.3.3
-revision=6
+revision=7
 build_style=cmake
 configure_args="-DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="extra-cmake-modules pkg-config protobuf qt5-host-tools qt5-qmake"

From 4ed9edd73ca2cf3295b36dd99f11c52d027d0ed0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:28 -0500
Subject: [PATCH 101/115] musikcube: revbump for ffmpeg-6.0

---
 srcpkgs/musikcube/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/musikcube/template b/srcpkgs/musikcube/template
index d9e6186e6697b..637952d50aca3 100644
--- a/srcpkgs/musikcube/template
+++ b/srcpkgs/musikcube/template
@@ -1,7 +1,7 @@
 # Template file for 'musikcube'
 pkgname=musikcube
 version=3.0.0
-revision=3
+revision=4
 build_style=cmake
 make_cmd=make
 configure_args="-DNO_NCURSESW=1"

From 2ecfa9f5d24037abc960832de98bff93f2037aa0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:45 -0500
Subject: [PATCH 102/115] electron24: revbump for ffmpeg-6.0

---
 srcpkgs/electron24/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron24/template b/srcpkgs/electron24/template
index a9c865c19c989..b8613e4362bc7 100644
--- a/srcpkgs/electron24/template
+++ b/srcpkgs/electron24/template
@@ -1,7 +1,7 @@
 # Template file for 'electron24'
 pkgname=electron24
 version=24.3.0
-revision=2
+revision=3
 _nodever=18.14.0
 _chromiumver=112.0.5615.165
 archs="x86_64* aarch64*"

From addbc6897710707855a93e90604dc6d454403443 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:00 -0500
Subject: [PATCH 103/115] electron19: revbump for ffmpeg-6.0

---
 srcpkgs/electron19/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron19/template b/srcpkgs/electron19/template
index b18bc792c8221..29fb34e254eea 100644
--- a/srcpkgs/electron19/template
+++ b/srcpkgs/electron19/template
@@ -1,7 +1,7 @@
 # Template file for 'electron19'
 pkgname=electron19
 version=19.0.8
-revision=4
+revision=5
 _nodever=16.14.2
 _chromiumver=102.0.5005.125
 archs="x86_64* aarch64* ppc64le*"

From f0a1ff6b594c4c1b08dd002ce28a8177162372d8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:13 -0500
Subject: [PATCH 104/115] wf-recorder: revbump for ffmpeg-6.0

---
 srcpkgs/wf-recorder/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/wf-recorder/template b/srcpkgs/wf-recorder/template
index 08f986b031006..63c45cf4b814d 100644
--- a/srcpkgs/wf-recorder/template
+++ b/srcpkgs/wf-recorder/template
@@ -1,7 +1,7 @@
 # Template file for 'wf-recorder'
 pkgname=wf-recorder
 version=0.4.1
-revision=2
+revision=3
 build_style=meson
 hostmakedepends="pkg-config scdoc wayland-devel"
 makedepends="wayland-protocols wayland-devel ffmpeg-devel libgbm-devel x264-devel

From bacb43e1d397b7f4e18dc96b8c7341a34ac87a70 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:26 -0500
Subject: [PATCH 105/115] obs: revbump for ffmpeg-6.0

---
 srcpkgs/obs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/obs/template b/srcpkgs/obs/template
index b343f1131bfcf..a25a67433e285 100644
--- a/srcpkgs/obs/template
+++ b/srcpkgs/obs/template
@@ -1,7 +1,7 @@
 # Template file for 'obs'
 pkgname=obs
 version=30.0.0
-revision=2
+revision=3
 archs="i686* x86_64* ppc64le* aarch64* riscv64*"
 build_style=cmake
 configure_args="-DOBS_VERSION_OVERRIDE=${version} -DENABLE_JACK=ON

From 806626aaadb8fce3928e097f760a815057144ad2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:36 -0500
Subject: [PATCH 106/115] mlt7: revbump for ffmpeg-6.0

---
 srcpkgs/mlt7/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mlt7/template b/srcpkgs/mlt7/template
index 98f302ad3a516..7eb8c00fa1580 100644
--- a/srcpkgs/mlt7/template
+++ b/srcpkgs/mlt7/template
@@ -1,7 +1,7 @@
 # Template file for 'mlt7'
 pkgname=mlt7
 version=7.20.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DSWIG_PYTHON=ON -DMOD_QT6=ON"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which

From f525c4b8b1f608dbfff8dba7d7c1e7bf75141546 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:48 -0500
Subject: [PATCH 107/115] qt6-multimedia: revbump for ffmpeg-6.0

---
 srcpkgs/qt6-multimedia/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-multimedia/template b/srcpkgs/qt6-multimedia/template
index 67a577e1300fe..1da626ecf515a 100644
--- a/srcpkgs/qt6-multimedia/template
+++ b/srcpkgs/qt6-multimedia/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-multimedia'
 pkgname=qt6-multimedia
 version=6.6.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DQT_FEATURE_gstreamer=ON"
 hostmakedepends="perl qt6-declarative-host-tools pkg-config qt6-shadertools"

From e35079f8da1366be3cd8241a9c6cce551bd67aac Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:00:15 -0500
Subject: [PATCH 108/115] baresip: revbump for ffmpeg-6.0

---
 srcpkgs/baresip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/baresip/template b/srcpkgs/baresip/template
index 12c8954ef7b9b..b16b67beab8d2 100644
--- a/srcpkgs/baresip/template
+++ b/srcpkgs/baresip/template
@@ -1,7 +1,7 @@
 # Template file for 'baresip'
 pkgname=baresip
 version=3.6.0
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config glib-devel"
 makedepends="libgsm-devel libpng-devel openssl-devel libsndfile-devel

From f9795183b38c6fd2787cee39a859795cc7c634f7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:30 -0500
Subject: [PATCH 109/115] QMPlay2: revbump for ffmpeg-6.0

---
 srcpkgs/QMPlay2/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/QMPlay2/template b/srcpkgs/QMPlay2/template
index 46c80f64a1349..942258ce60fb7 100644
--- a/srcpkgs/QMPlay2/template
+++ b/srcpkgs/QMPlay2/template
@@ -1,7 +1,7 @@
 # Template file for 'QMPlay2'
 pkgname=QMPlay2
 version=23.10.22
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools"
 makedepends="alsa-lib-devel ffmpeg-devel libass-devel libcdio-devel libgme-devel

From 80b2ab2272af16be0c58a75528025934161e6a49 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:34 -0500
Subject: [PATCH 110/115] alsa-plugins: revbump for ffmpeg-6.0

---
 srcpkgs/alsa-plugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/alsa-plugins/template b/srcpkgs/alsa-plugins/template
index a5708a7d82a8f..7bfdad046c483 100644
--- a/srcpkgs/alsa-plugins/template
+++ b/srcpkgs/alsa-plugins/template
@@ -1,7 +1,7 @@
 # Template file for 'alsa-plugins'
 pkgname=alsa-plugins
 version=1.2.7.1
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--disable-maemo-plugin"
 hostmakedepends="pkg-config"

From 6fa06464d3aa8fb9eb3026d45fddbb86deb30a42 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:39 -0500
Subject: [PATCH 111/115] dolphin-emu: revbump for ffmpeg-6.0

---
 srcpkgs/dolphin-emu/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/dolphin-emu/template b/srcpkgs/dolphin-emu/template
index 070993aac31d2..96edf50d3e4a1 100644
--- a/srcpkgs/dolphin-emu/template
+++ b/srcpkgs/dolphin-emu/template
@@ -1,7 +1,7 @@
 # Template file for 'dolphin-emu'
 pkgname=dolphin-emu
 version=5.0.19368
-revision=2
+revision=3
 _dolphin_commit=dadbeb4bae7e7fa23af2b46e0add4143094dc107
 _mgba_commit=44e074a15e9651481f7f652ac006a7c9d58cbeb9
 _googletest_commit=be03d00f5f0cc3a997d1a368bee8a1fe93651f48

From c5bd2835773b6769df23a6b8872a4559f6aa660b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:43 -0500
Subject: [PATCH 112/115] minidlna: revbump for ffmpeg-6.0

---
 srcpkgs/minidlna/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/minidlna/template b/srcpkgs/minidlna/template
index 5fa929f3a0c12..742991ecd04af 100644
--- a/srcpkgs/minidlna/template
+++ b/srcpkgs/minidlna/template
@@ -1,7 +1,7 @@
 # Template file for 'minidlna'
 pkgname=minidlna
 version=1.3.3
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="
  --sbindir=/usr/bin

From ef4a4cd8e9c90c459dc3c881f5dc8f053bcac82b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 17:57:47 -0500
Subject: [PATCH 113/115] mpv: revbump for ffmpeg-6.0

---
 srcpkgs/mpv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpv/template b/srcpkgs/mpv/template
index 4948d1e332cb8..1ac1b167af189 100644
--- a/srcpkgs/mpv/template
+++ b/srcpkgs/mpv/template
@@ -1,7 +1,7 @@
 # Template file for 'mpv'
 pkgname=mpv
 version=0.36.0
-revision=4
+revision=5
 build_style=meson
 configure_args="-Dcdda=enabled -Ddvbin=enabled -Ddvdnav=enabled
  -Dlibmpv=true -Dcplugins=enabled

From f6fb2a4c7b9989a60973f874e370e79de1efc043 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 17:59:29 -0500
Subject: [PATCH 114/115] qimgv: revbump for ffmpeg-6.0

---
 srcpkgs/qimgv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qimgv/template b/srcpkgs/qimgv/template
index dd341dfe1bfce..8a7e1c081ef12 100644
--- a/srcpkgs/qimgv/template
+++ b/srcpkgs/qimgv/template
@@ -1,7 +1,7 @@
 # Template file for 'qimgv'
 pkgname=qimgv
 version=1.0.2
-revision=3
+revision=4
 build_style=cmake
 configure_args="$(vopt_if video -DVIDEO_SUPPORT=ON -DVIDEO_SUPPORT=OFF)
  $(vopt_if scale -DOPENCV_SUPPORT=ON -DOPENCV_SUPPORT=OFF)

From 72c289f6b984987af66494fb5d02cefc2d7e34b0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 18:00:36 -0500
Subject: [PATCH 115/115] kfilemetadata5: revbump for ffmpeg-6.0

---
 srcpkgs/kfilemetadata5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kfilemetadata5/template b/srcpkgs/kfilemetadata5/template
index e294ae5af947c..1453b37720ae1 100644
--- a/srcpkgs/kfilemetadata5/template
+++ b/srcpkgs/kfilemetadata5/template
@@ -1,7 +1,7 @@
 # Template file for 'kfilemetadata5'
 pkgname=kfilemetadata5
 version=5.111.0
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="kcoreaddons extra-cmake-modules pkg-config qt5-host-tools qt5-qmake
  gettext kcoreaddons python3"

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (39 preceding siblings ...)
  2023-11-20 23:00 ` zlice
@ 2023-12-03 16:39 ` mhmdanas
  2023-12-03 16:45 ` [PR PATCH] [Updated] " zlice
                   ` (56 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: mhmdanas @ 2023-12-03 16:39 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 204 bytes --]

New comment by mhmdanas on void-packages repository

https://github.com/void-linux/void-packages/pull/43761#issuecomment-1837533837

Comment:
I'd like to help move this along, is there anything I can do?

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (40 preceding siblings ...)
  2023-12-03 16:39 ` mhmdanas
@ 2023-12-03 16:45 ` zlice
  2023-12-03 16:59 ` zlice
                   ` (55 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2023-12-03 16:45 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 3743 bytes --]

There is an updated pull request by zlice against master on the void-packages repository

https://github.com/zlice/void-packages ffmpeg6-split
https://github.com/void-linux/void-packages/pull/43761

ffmpeg6 split
[ci skip]


#### Testing the changes

- I tested the changes in this PR: **YES**

main testing has been vaapi in Firefox Nightly and enc/dec in Shotcut on Intel A770

#### New package

- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**

#### Local build testing

- I built this PR locally for my native architecture, **x86_64**

#### Discussion

Continuation of https://github.com/void-linux/void-packages/pull/36315

`libavresample` is deprecated, but marked as a dependency when trying to build other packages and install `ffmpeg`(6). I think the right way to handle this is make a meta package and the add to removals?


##### Commit naming / misc

~~Commits are 'dirty' right now, running with [gstreamer 1.22.1 updates](https://github.com/void-linux/void-packages/pull/42861) and [Intel OpenCL](https://github.com/void-linux/void-packages/pull/43084). This will also make [intel packages pr](https://github.com/void-linux/void-packages/pull/41132) obsolete.~~ (see Requirements below)

Maintainer for previous ffmpeg(4) was orphaned, I can put my name in there if that matters, though I don't exactly see myself keeping up on ffmpeg.

This updates QT5 which looks like it is usually hosted by Johnny. Not sure if there's any reason to stay there or these sources are fine.

##### STILL FFMPEG4

These are a mix of emulators, games and/or older packages.

- attract (multiple patches in master)
- audacity (https://github.com/audacity/audacity/issues/2305 and https://sourceforge.net/p/portmedia/wiki/portsmf/ is 'beta')
- ccextractor (master patches? no release)
- vice
- kodi
- mlt (only dep left is flowblade)
- ~~synfig (mlt)~~ (work with mlt7, bump synfigstudio)
- tvheadend
- ssr
- ~~spek-alternative~~ (replace with spek-x)
- ppsspp
- olive
- moc
- mediastreamer
- libextractor
- idjc
- hedgewars
- ~~ffmpegthumbnailer~~ (patches for moviedecoder.xxx files)
- ~~ffmpegthumbs~~ (latest compiles)
- deadbeef
- omxplayer
- qtav (fork has ffmpeg 5 patch - https://github.com/cmguo/QtAV)
- `vlc` (vlc4 will support ffmpeg5, there's a patch to build 3.x with ffmpeg5 but it will lack vaapi)
- `osg` (OpenSceneGraph plus `xine-lib`)


##### HAVE NOT BUILT YET

- omxplayer (rpi only? ffmpeg4)
- kodi (big, but ffmpeg4)


##### UPDATED (for ffmpeg6)

- ~~blender: update to 3.5.1~~ ~~will be revbump with~~ https://github.com/void-linux/void-packages/pull/43992
- unpaper: update to 7.0.0.
- guvcview: update to 2.0.8.
- qt5: update to 5.15.8
- qt5-webengine: update to 5.18.13
- shiboken2: revbump for qt5.15.8 (patch)
- python3-pyside2: update to 5.15.8 (patch)
- New package: spex-x replaces spek-alternative for ffmpeg-6.0


##### Requirements

- ~~[gstreamer 1.22.2](https://github.com/void-linux/void-packages/pull/42861)~~ - a few packages use ffmpeg-devel and require a revbump

- ~~[Intel Packages](https://github.com/void-linux/void-packages/pull/41132)~~ [Intel Packages v2](https://github.com/void-linux/void-packages/pull/47330) - ffmpeg4 uses different libraries than 6 (libmfx / Intel-MediaSDK vs only oneVPL that Intel is moving to), both are included here

- ~~[shotcut 23.05.14](https://github.com/void-linux/void-packages/pull/44260)~~

- https://github.com/void-linux/void-packages/pull/44781 will remove from this PR

A patch file from https://github.com/void-linux/void-packages/pull/43761.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ffmpeg6-split-43761.patch --]
[-- Type: text/x-diff, Size: 781623 bytes --]

From 8cf0c3b89ce2e5f00358ad3d03449ac888560457 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:16:56 -0400
Subject: [PATCH 001/114] ffmpeg: update to 6.0.1.

---
 common/shlibs                                 | 26 +++++---
 srcpkgs/ffmpeg/files/altivec.patch            | 60 -------------------
 .../patches/armv5tel-floating-point.patch     | 18 ------
 ...h-libavcodec-libsvtav1-ten_bit_format.diff | 40 -------------
 .../workaround-mesa-readeon-vaapi-bug.patch   | 28 ---------
 srcpkgs/ffmpeg/template                       | 38 ++++++------
 6 files changed, 37 insertions(+), 173 deletions(-)
 delete mode 100644 srcpkgs/ffmpeg/files/altivec.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 delete mode 100644 srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch

diff --git a/common/shlibs b/common/shlibs
index 1b25a12956eeb..134d88afb91c2 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -385,15 +385,23 @@ libid3tag.so.0 libid3tag-0.15.1b_1
 libgif.so.7 giflib-5.1.0_1
 libImlib2.so.1 imlib2-1.4.2_1
 libmp3lame.so.0 lame-3.98.2_1
-libavdevice.so.58 libavdevice-4.0_1
-libavformat.so.58 libavformat-4.0_1
-libswscale.so.5 libswscale-4.0_1
-libswresample.so.3 libswresample-4.0_1
-libavresample.so.4 libavresample-4.0_1
-libpostproc.so.55 libpostproc-4.0_1
-libavcodec.so.58 libavcodec-4.0_1
-libavutil.so.56 libavutil-4.0_1
-libavfilter.so.7 libavfilter-4.0_1
+libavdevice.so.60 libavdevice-6.0_1
+libavformat.so.60 libavformat-6.0_1
+libswscale.so.7 libswscale-6.0_1
+libswresample.so.4 libswresample-6.0_1
+libpostproc.so.57 libpostproc-6.0_1
+libavcodec.so.60 libavcodec-6.0_1
+libavutil.so.58 libavutil-6.0_1
+libavfilter.so.9 libavfilter-6.0_1
+libavdevice.so.58 libavdevice4-4.0_1
+libavformat.so.58 libavformat4-4.0_1
+libswscale.so.5 libswscale4-4.0_1
+libswresample.so.3 libswresample4-4.0_1
+libavresample.so.4 libavresample4-4.0_1
+libpostproc.so.55 libpostproc4-4.0_1
+libavcodec.so.58 libavcodec4-4.0_1
+libavutil.so.56 libavutil4-4.0_1
+libavfilter.so.7 libavfilter4-4.0_1
 libSDL-1.2.so.0 SDL-1.2.14_1
 libSDL_image-1.2.so.0 SDL_image-1.2.10_1
 libx264.so.157 x264-20190507.2245_1
diff --git a/srcpkgs/ffmpeg/files/altivec.patch b/srcpkgs/ffmpeg/files/altivec.patch
deleted file mode 100644
index 9c57200463320..0000000000000
--- a/srcpkgs/ffmpeg/files/altivec.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-revert some altivec specific change on all ppc* except ppc64le*
-
-q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
-conditionally, for ppc* but not ppc64le* (the new code is valid for
-POWER8 VSX which LE targets as a baseline but not BE)"
-
-
-This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
----
- libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
- 1 file changed, 20 insertions(+), 4 deletions(-)
-
-diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
-index 536545293d..c1e2852adb 100644
---- a/libswscale/ppc/yuv2rgb_altivec.c
-+++ b/libswscale/ppc/yuv2rgb_altivec.c
-@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-     vector signed short R1, G1, B1;                                           \
-     vector unsigned char R, G, B;                                             \
-                                                                               \
-+    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
-+    vector unsigned char align_perm;                                          \
-+                                                                              \
-     vector signed short lCY       = c->CY;                                    \
-     vector signed short lOY       = c->OY;                                    \
-     vector signed short lCRV      = c->CRV;                                   \
-@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
-                                                                               \
-         for (j = 0; j < w / 16; j++) {                                        \
--            y0 = vec_xl(0, y1i);                                              \
-+            y1ivP = (const vector unsigned char *) y1i;                       \
-+            y2ivP = (const vector unsigned char *) y2i;                       \
-+            uivP  = (const vector unsigned char *) ui;                        \
-+            vivP  = (const vector unsigned char *) vi;                        \
-+                                                                              \
-+            align_perm = vec_lvsl(0, y1i);                                    \
-+            y0 = (vector unsigned char)                                       \
-+                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
-                                                                               \
--            y1 = vec_xl(0, y2i);                                              \
-+            align_perm = vec_lvsl(0, y2i);                                    \
-+            y1 = (vector unsigned char)                                       \
-+                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
-                                                                               \
--            u = (vector signed char) vec_xl(0, ui);                           \
-+            align_perm = vec_lvsl(0, ui);                                     \
-+            u = (vector signed char)                                          \
-+                    vec_perm(uivP[0], uivP[1], align_perm);                   \
-                                                                               \
--            v = (vector signed char) vec_xl(0, vi);                           \
-+            align_perm = vec_lvsl(0, vi);                                     \
-+            v = (vector signed char)                                          \
-+                    vec_perm(vivP[0], vivP[1], align_perm);                   \
-                                                                               \
-             u = (vector signed char)                                          \
-                     vec_sub(u,                                                \
--- 
-2.27.0
-
diff --git a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
deleted file mode 100644
index 9a55178c74f0f..0000000000000
--- a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
-+++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
-@@ -39,6 +39,15 @@
- #endif
- #include <fenv.h>
- 
-+#if (FE_ALL_EXCEPT == 0)
-+/* E.g. ARM soft float does not define these */
-+#define FE_INVALID    0
-+#define FE_DIVBYZERO  0
-+#define FE_OVERFLOW   0
-+#define FE_UNDERFLOW  0
-+#define FE_INEXACT    0
-+#endif
-+
- #if CONFIG_LIBFONTCONFIG
- #include <fontconfig/fontconfig.h>
- #endif
diff --git a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
deleted file mode 100644
index aa948f7a8a2df..0000000000000
--- a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
+++ /dev/null
@@ -1,40 +0,0 @@
-#==================================================================================================
-# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
-# From: Christopher Degawa <christopher.degawa@intel.com>
-# Date: Thu, 20 Oct 2022 22:55:27 -0500
-# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
-#
-# compressed_ten_bit_format has been deprecated upstream and has no effect
-# and can be removed. Plus, technically it was never used in the first place
-# since it would require the app (ffmpeg) to set it and do additional
-# processing of the input frames.
-#
-# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
-#
-# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
-#==================================================================================================
---- a/libavcodec/libsvtav1.c
-+++ b/libavcodec/libsvtav1.c
-@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
- 
- static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
- {
--    const int    pack_mode_10bit =
--        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
--    const size_t luma_size_8bit  =
--        config->source_width * config->source_height * (1 << pack_mode_10bit);
--    const size_t luma_size_10bit =
--        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
-+    const size_t luma_size = config->source_width * config->source_height *
-+        (config->encoder_bit_depth > 8 ? 2 : 1);
- 
-     EbSvtIOFormat *in_data;
- 
--    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
-+    svt_enc->raw_size = luma_size * 3 / 2;
- 
-     // allocate buffer for in and out
-     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
--- 
-GitLab
-
diff --git a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
deleted file mode 100644
index 00e3f68a415b8..0000000000000
--- a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
-From: Rainer Hochecker <fernetmenta@online.de>
-Date: Sat, 26 Jan 2019 19:48:35 +0100
-Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
-
-This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
-It was hit frequently when watching h264 channels received via DVB-X.
-Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
----
- libavcodec/vaapi_h264.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
-index 5854587a255..f12fdc457a4 100644
---- a/libavcodec/vaapi_h264.c
-+++ b/libavcodec/vaapi_h264.c
-@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
-     H264SliceContext *sl = &h->slice_ctx[0];
-     int ret;
- 
-+    if (pic->nb_slices == 0) {
-+        ret = AVERROR_INVALIDDATA;
-+        goto finish;
-+    }
-+
-     ret = ff_vaapi_decode_issue(avctx, pic);
-     if (ret < 0)
-         goto finish;
diff --git a/srcpkgs/ffmpeg/template b/srcpkgs/ffmpeg/template
index 5968a09b1f12d..52fcf4d68797a 100644
--- a/srcpkgs/ffmpeg/template
+++ b/srcpkgs/ffmpeg/template
@@ -1,15 +1,15 @@
 # Template file for 'ffmpeg'
 # audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
 pkgname=ffmpeg
-version=4.4.4
-revision=5
+version=6.0.1
+revision=1
 short_desc="Decoding, encoding and streaming software"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="https://www.ffmpeg.org"
 changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
 distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
-checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+checksum=9b16b8731d78e596b4be0d720428ca42df642bb2d78342881ff7f5bc29fc9623
 
 hostmakedepends="pkg-config perl"
 makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
@@ -26,12 +26,13 @@ makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-deve
  $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
  $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
  $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
- $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers Vulkan-Tools Vulkan-ValidationLayers')
+ $(vopt_if onevpl 'oneVPL oneVPL-devel')
  $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
 depends="ffplay>=${version}_${revision}"
 
 build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
- dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec onevpl"
 build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
 desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
 desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
@@ -39,9 +40,13 @@ desc_option_sofa="Enable support for AES SOFA"
 desc_option_webp="Enable support for WebP"
 
 case "$XBPS_TARGET_MACHINE" in
-	i686*|x86_64*)
-		hostmakedepends+=" nasm"
+	i686*)
 		build_options_default+=" vaapi vdpau nvenc nvdec"
+		hostmakedepends+=" nasm"
+		;;
+	x86_64*)
+		hostmakedepends+=" nasm"
+		build_options_default+=" vaapi vdpau nvenc nvdec onevpl"
 		;;
 	ppc64*) build_options_default+=" vaapi vdpau";;
 	mips*) CFLAGS="-mnan=legacy";;
@@ -115,18 +120,19 @@ do_configure() {
 		$(vopt_enable x265 libx265) \
 		$(vopt_enable v4l2 libv4l2) \
 		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
-		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		--enable-libbs2b --enable-libvidstab \
 		$(vopt_enable dav1d libdav1d) \
 		$(vopt_enable zimg libzimg) \
 		$(vopt_enable webp libwebp) \
 		$(vopt_enable sofa libmysofa) \
 		$(vopt_enable vulkan) \
+		$(vopt_enable onevpl libvpl) \
 		$(vopt_enable drm libdrm) \
 		$(vopt_enable svtav1 libsvtav1) \
 		$(vopt_enable srt libsrt) \
 		$(vopt_enable rist librist) \
-		$(vopt_if nvenc '--enable-nvenc') \
-		$(vopt_if nvdec '--enable-nvdec')
+		$(vopt_enable nvenc nvenc) \
+		$(vopt_enable nvdec nvdec)
 }
 
 do_build() {
@@ -153,10 +159,8 @@ libavdevice_package() {
 }
 
 libavresample_package() {
-	short_desc="FFmpeg audio resampling library"
-	pkg_install() {
-		vmove "usr/lib/libavresample.so.*"
-	}
+	short_desc="Package deprecated, removal needed"
+	build_style=meta
 }
 
 libavformat_package() {
@@ -210,15 +214,13 @@ ffmpeg-devel_package() {
 		libavfilter>=${version}_${revision}
 		libpostproc>=${version}_${revision}
 		libswscale>=${version}_${revision}
-		libswresample>=${version}_${revision}
-		libavresample>=${version}_${revision}"
+		libswresample>=${version}_${revision}"
 	short_desc+=" - development files"
-
+	conflicts="ffmpeg4-devel"
 	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
 		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
 		nostrip_files="/usr/lib/libavfilter.a"
 	fi
-
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig

From f8fffbea99a5eb128b2e3e476fb5a49529a941aa Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:14 -0400
Subject: [PATCH 002/114] openshot: revbump for ffmpeg6.0

---
 srcpkgs/openshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openshot/template b/srcpkgs/openshot/template
index 8f47851eef354..affb652a9d500 100644
--- a/srcpkgs/openshot/template
+++ b/srcpkgs/openshot/template
@@ -1,7 +1,7 @@
 # Template file for 'openshot'
 pkgname=openshot
 version=3.0.0
-revision=2
+revision=3
 build_style=python3-module
 hostmakedepends="python3 python3-setuptools"
 makedepends="ffmpeg-devel python3-PyQt5"

From 51ef944597ab29f540610eeaf3c0a9d5f2738703 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:36 -0400
Subject: [PATCH 003/114] sumo: revbump for ffmpeg6.0

---
 srcpkgs/sumo/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/sumo/template b/srcpkgs/sumo/template
index a3fe134aa5acc..a730afa9fafa9 100644
--- a/srcpkgs/sumo/template
+++ b/srcpkgs/sumo/template
@@ -1,7 +1,7 @@
 # Template file for 'sumo'
 pkgname=sumo
 version=1.12.0
-revision=6
+revision=7
 build_style=cmake
 hostmakedepends="libgdal-tools pkg-config swig python3-setuptools"
 makedepends="python3-devel ffmpeg-devel fox-devel gl2ps-devel libgdal-devel

From a043a9fc66d2bc8714b43fcfc2681953cf30d570 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:56:22 -0400
Subject: [PATCH 004/114] New package: ffmpeg4-4.4.4.

---
 srcpkgs/ffmpeg4-devel                         |   1 +
 srcpkgs/ffmpeg4/files/altivec.patch           |  60 +++++
 .../patches/armv5tel-floating-point.patch     |  18 ++
 ...h-libavcodec-libsvtav1-ten_bit_format.diff |  40 +++
 .../workaround-mesa-readeon-vaapi-bug.patch   |  28 +++
 srcpkgs/ffmpeg4/template                      | 234 ++++++++++++++++++
 srcpkgs/libavcodec4                           |   1 +
 srcpkgs/libavdevice4                          |   1 +
 srcpkgs/libavfilter4                          |   1 +
 srcpkgs/libavformat4                          |   1 +
 srcpkgs/libavresample4                        |   1 +
 srcpkgs/libavutil4                            |   1 +
 srcpkgs/libpostproc4                          |   1 +
 srcpkgs/libswresample4                        |   1 +
 srcpkgs/libswscale4                           |   1 +
 15 files changed, 390 insertions(+)
 create mode 120000 srcpkgs/ffmpeg4-devel
 create mode 100644 srcpkgs/ffmpeg4/files/altivec.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 create mode 100644 srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
 create mode 100644 srcpkgs/ffmpeg4/template
 create mode 120000 srcpkgs/libavcodec4
 create mode 120000 srcpkgs/libavdevice4
 create mode 120000 srcpkgs/libavfilter4
 create mode 120000 srcpkgs/libavformat4
 create mode 120000 srcpkgs/libavresample4
 create mode 120000 srcpkgs/libavutil4
 create mode 120000 srcpkgs/libpostproc4
 create mode 120000 srcpkgs/libswresample4
 create mode 120000 srcpkgs/libswscale4

diff --git a/srcpkgs/ffmpeg4-devel b/srcpkgs/ffmpeg4-devel
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/ffmpeg4-devel
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/ffmpeg4/files/altivec.patch b/srcpkgs/ffmpeg4/files/altivec.patch
new file mode 100644
index 0000000000000..9c57200463320
--- /dev/null
+++ b/srcpkgs/ffmpeg4/files/altivec.patch
@@ -0,0 +1,60 @@
+revert some altivec specific change on all ppc* except ppc64le*
+
+q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
+conditionally, for ppc* but not ppc64le* (the new code is valid for
+POWER8 VSX which LE targets as a baseline but not BE)"
+
+
+This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
+---
+ libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
+ 1 file changed, 20 insertions(+), 4 deletions(-)
+
+diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
+index 536545293d..c1e2852adb 100644
+--- a/libswscale/ppc/yuv2rgb_altivec.c
++++ b/libswscale/ppc/yuv2rgb_altivec.c
+@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+     vector signed short R1, G1, B1;                                           \
+     vector unsigned char R, G, B;                                             \
+                                                                               \
++    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
++    vector unsigned char align_perm;                                          \
++                                                                              \
+     vector signed short lCY       = c->CY;                                    \
+     vector signed short lOY       = c->OY;                                    \
+     vector signed short lCRV      = c->CRV;                                   \
+@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
+                                                                               \
+         for (j = 0; j < w / 16; j++) {                                        \
+-            y0 = vec_xl(0, y1i);                                              \
++            y1ivP = (const vector unsigned char *) y1i;                       \
++            y2ivP = (const vector unsigned char *) y2i;                       \
++            uivP  = (const vector unsigned char *) ui;                        \
++            vivP  = (const vector unsigned char *) vi;                        \
++                                                                              \
++            align_perm = vec_lvsl(0, y1i);                                    \
++            y0 = (vector unsigned char)                                       \
++                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
+                                                                               \
+-            y1 = vec_xl(0, y2i);                                              \
++            align_perm = vec_lvsl(0, y2i);                                    \
++            y1 = (vector unsigned char)                                       \
++                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
+                                                                               \
+-            u = (vector signed char) vec_xl(0, ui);                           \
++            align_perm = vec_lvsl(0, ui);                                     \
++            u = (vector signed char)                                          \
++                    vec_perm(uivP[0], uivP[1], align_perm);                   \
+                                                                               \
+-            v = (vector signed char) vec_xl(0, vi);                           \
++            align_perm = vec_lvsl(0, vi);                                     \
++            v = (vector signed char)                                          \
++                    vec_perm(vivP[0], vivP[1], align_perm);                   \
+                                                                               \
+             u = (vector signed char)                                          \
+                     vec_sub(u,                                                \
+-- 
+2.27.0
+
diff --git a/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
new file mode 100644
index 0000000000000..9a55178c74f0f
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
@@ -0,0 +1,18 @@
+--- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
++++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
+@@ -39,6 +39,15 @@
+ #endif
+ #include <fenv.h>
+ 
++#if (FE_ALL_EXCEPT == 0)
++/* E.g. ARM soft float does not define these */
++#define FE_INVALID    0
++#define FE_DIVBYZERO  0
++#define FE_OVERFLOW   0
++#define FE_UNDERFLOW  0
++#define FE_INEXACT    0
++#endif
++
+ #if CONFIG_LIBFONTCONFIG
+ #include <fontconfig/fontconfig.h>
+ #endif
diff --git a/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
new file mode 100644
index 0000000000000..aa948f7a8a2df
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
@@ -0,0 +1,40 @@
+#==================================================================================================
+# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
+# From: Christopher Degawa <christopher.degawa@intel.com>
+# Date: Thu, 20 Oct 2022 22:55:27 -0500
+# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
+#
+# compressed_ten_bit_format has been deprecated upstream and has no effect
+# and can be removed. Plus, technically it was never used in the first place
+# since it would require the app (ffmpeg) to set it and do additional
+# processing of the input frames.
+#
+# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
+#
+# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
+#==================================================================================================
+--- a/libavcodec/libsvtav1.c
++++ b/libavcodec/libsvtav1.c
+@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
+ 
+ static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
+ {
+-    const int    pack_mode_10bit =
+-        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
+-    const size_t luma_size_8bit  =
+-        config->source_width * config->source_height * (1 << pack_mode_10bit);
+-    const size_t luma_size_10bit =
+-        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
++    const size_t luma_size = config->source_width * config->source_height *
++        (config->encoder_bit_depth > 8 ? 2 : 1);
+ 
+     EbSvtIOFormat *in_data;
+ 
+-    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
++    svt_enc->raw_size = luma_size * 3 / 2;
+ 
+     // allocate buffer for in and out
+     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
+-- 
+GitLab
+
diff --git a/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
new file mode 100644
index 0000000000000..00e3f68a415b8
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
@@ -0,0 +1,28 @@
+From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
+From: Rainer Hochecker <fernetmenta@online.de>
+Date: Sat, 26 Jan 2019 19:48:35 +0100
+Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
+
+This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
+It was hit frequently when watching h264 channels received via DVB-X.
+Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
+---
+ libavcodec/vaapi_h264.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
+index 5854587a255..f12fdc457a4 100644
+--- a/libavcodec/vaapi_h264.c
++++ b/libavcodec/vaapi_h264.c
+@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
+     H264SliceContext *sl = &h->slice_ctx[0];
+     int ret;
+ 
++    if (pic->nb_slices == 0) {
++        ret = AVERROR_INVALIDDATA;
++        goto finish;
++    }
++
+     ret = ff_vaapi_decode_issue(avctx, pic);
+     if (ret < 0)
+         goto finish;
diff --git a/srcpkgs/ffmpeg4/template b/srcpkgs/ffmpeg4/template
new file mode 100644
index 0000000000000..9ba14bdb8ddf3
--- /dev/null
+++ b/srcpkgs/ffmpeg4/template
@@ -0,0 +1,234 @@
+# Template file for 'ffmpeg4'
+# audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
+pkgname=ffmpeg4
+version=4.4.4
+revision=1
+short_desc="Decoding, encoding and streaming software - ffmpeg4 libraries only"
+maintainer="Orphaned <orphan@voidlinux.org>"
+license="GPL-3.0-or-later"
+homepage="https://www.ffmpeg.org"
+changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
+distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
+checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+
+hostmakedepends="pkg-config perl"
+makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
+ libXext-devel libXvMC-devel libxcb-devel lame-devel libtheora-devel
+ libvorbis-devel x264-devel xvidcore-devel jack-devel SDL2-devel
+ libcdio-paranoia-devel librtmp-devel libmodplug-devel gnutls-devel
+ speex-devel celt-devel harfbuzz-devel libass-devel opus-devel ocl-icd-devel
+ libbs2b-devel libvidstab-devel vmaf-devel $(vopt_if pulseaudio pulseaudio-devel)
+ $(vopt_if vaapi libva-devel) $(vopt_if vdpau libvdpau-devel)
+ $(vopt_if x265 x265-devel) $(vopt_if v4l2 v4l-utils-devel)
+ $(vopt_if fdk_aac fdk-aac-devel) $(vopt_if vpx libvpx-devel)
+ $(vopt_if aom libaom-devel) $(vopt_if sndio sndio-devel)
+ $(vopt_if dav1d libdav1d-devel) $(vopt_if zimg zimg-devel)
+ $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
+ $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
+ $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
+
+build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
+
+desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
+desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
+desc_option_sofa="Enable support for AES SOFA"
+desc_option_webp="Enable support for WebP"
+
+case "$XBPS_TARGET_MACHINE" in
+	i686*|x86_64*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau nvenc nvdec"
+			;;
+	ppc64*) build_options_default+=" vaapi vdpau";;
+	mips*) CFLAGS="-mnan=legacy";;
+esac
+
+if [ "$XBPS_TARGET_WORDSIZE" != "32" ]; then
+	build_options_default+=" svtav1"
+fi
+
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+fi
+
+_apply_patch() {
+	local args="$1" pname="$(basename $2)"
+
+	if [ ! -f ".${pname}_done" ]; then
+		patch -N $args -i $2
+		touch .${pname}_done
+	fi
+}
+
+post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64le*) ;;
+		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
+	esac
+
+	vsed -i libavfilter/vf_libvmaf.c -e 's!/usr/local/share/model/\(vmaf_v0.6.1\).pkl!/usr/share/vmaf/\1.json!'
+}
+
+do_configure() {
+	# Fix gcc on x86_64-musl only
+	if [ "$XBPS_TARGET_MACHINE" = "x86_64-musl" ]; then
+		vsed -i configure -e "s;_cflags_speed='-O3';_cflags_speed='-O2';"
+	fi
+
+	if [ "$CROSS_BUILD" ]; then
+		case "$XBPS_TARGET_MACHINE" in
+			arm*) _arch="arm";;
+			aarch64*) _arch="aarch64";;
+			mips*) _arch="mips";;
+			ppc64*) _arch="ppc64";;
+			ppc*) _arch="ppc";;
+			*) _arch="${XBPS_TARGET_MACHINE%%-musl}";;
+		esac
+
+		_args+=" --enable-cross-compile
+			--sysroot=$XBPS_CROSS_BASE
+			--cross-prefix=${XBPS_CROSS_TRIPLET}-
+			--target-os=linux --arch=${_arch}"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc|ppc-musl) _args+=" --disable-altivec";;
+	esac
+
+	if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+		_args+=" --extra-libs=-latomic"
+	fi
+
+	./configure --prefix=/usr --disable-debug --enable-gpl --enable-gnutls \
+		--disable-stripping \
+		--enable-libcdio --enable-version3 --enable-runtime-cpudetect \
+		--enable-libmp3lame --enable-libvorbis --enable-libxvid \
+		--enable-libx264 $(vopt_enable vpx libvpx) --enable-libtheora \
+		--enable-shared --enable-static --enable-libxcb \
+		$(vopt_enable pulseaudio libpulse) --enable-libfreetype --enable-libmodplug \
+		--enable-libspeex --enable-libcelt --enable-libass \
+		--enable-libopus --enable-librtmp --enable-libjack \
+		$(vopt_if fdk_aac '--enable-nonfree --enable-libfdk-aac') \
+		--disable-libopencore_amrnb --disable-libopencore_amrwb \
+		--disable-libopenjpeg \
+		--enable-postproc --enable-opencl ${_args} --enable-libvmaf ${_args} \
+		$(vopt_enable x265 libx265) \
+		$(vopt_enable v4l2 libv4l2) \
+		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
+		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		$(vopt_enable dav1d libdav1d) \
+		$(vopt_enable zimg libzimg) \
+		$(vopt_enable webp libwebp) \
+		$(vopt_enable sofa libmysofa) \
+		$(vopt_enable vulkan) \
+		$(vopt_enable drm libdrm) \
+		$(vopt_enable svtav1 libsvtav1) \
+		$(vopt_enable srt libsrt) \
+		$(vopt_enable rist librist) \
+		$(vopt_if nvenc '--enable-nvenc') \
+		$(vopt_if nvdec '--enable-nvdec')
+}
+
+do_build() {
+	make ${makejobs}
+	make doc/ff{mpeg,play}.1
+}
+
+do_install() {
+	make DESTDIR=${DESTDIR} install install-man
+	rm -rf ${DESTDIR}/usr/bin
+}
+
+libavcodec4_package() {
+	short_desc="FFmpeg codec library"
+	pkg_install() {
+		vmove "usr/lib/libavcodec.so.*"
+	}
+}
+
+libavdevice4_package() {
+	short_desc="FFmpeg device handling library"
+	pkg_install() {
+		vmove "usr/lib/libavdevice.so.*"
+	}
+}
+
+libavresample4_package() {
+	short_desc="FFmpeg audio resampling library"
+	pkg_install() {
+		vmove "usr/lib/libavresample.so.*"
+	}
+}
+
+libavformat4_package() {
+	short_desc="FFmpeg file format library"
+	pkg_install() {
+		vmove "usr/lib/libavformat.so.*"
+	}
+}
+
+libavutil4_package() {
+	short_desc="FFmpeg utility library"
+	pkg_install() {
+		vmove "usr/lib/libavutil.so.*"
+	}
+}
+
+libavfilter4_package() {
+	short_desc="FFmpeg audio/video filter library"
+	pkg_install() {
+		vmove "usr/lib/libavfilter.so.*"
+	}
+}
+
+libpostproc4_package() {
+	short_desc="FFmpeg video postprocessing library"
+	pkg_install() {
+		vmove "usr/lib/libpostproc.so.*"
+	}
+}
+
+libswscale4_package() {
+	short_desc="FFmpeg video scaling library"
+	pkg_install() {
+		vmove "usr/lib/libswscale.so.*"
+	}
+}
+
+libswresample4_package() {
+	short_desc="FFmpeg video resampling library"
+	pkg_install() {
+		vmove "usr/lib/libswresample.so.*"
+	}
+}
+
+ffmpeg4-devel_package() {
+	depends="
+		libavcodec4>=${version}_${revision}
+		libavdevice4>=${version}_${revision}
+		libavformat4>=${version}_${revision}
+		libavutil4>=${version}_${revision}
+		libavfilter4>=${version}_${revision}
+		libpostproc4>=${version}_${revision}
+		libswscale4>=${version}_${revision}
+		libswresample4>=${version}_${revision}
+		libavresample4>=${version}_${revision}"
+	short_desc+=" - development files"
+	conflicts="ffmpeg-devel"
+	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
+		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
+		nostrip_files="/usr/lib/libavfilter.a"
+	fi
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.a"
+		vmove "usr/lib/*.so"
+		vmove usr/share/ffmpeg/examples
+		vmove usr/share/man/man3
+	}
+}
diff --git a/srcpkgs/libavcodec4 b/srcpkgs/libavcodec4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavcodec4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavdevice4 b/srcpkgs/libavdevice4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavdevice4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavfilter4 b/srcpkgs/libavfilter4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavfilter4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavformat4 b/srcpkgs/libavformat4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavformat4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavresample4 b/srcpkgs/libavresample4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavutil4 b/srcpkgs/libavutil4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavutil4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libpostproc4 b/srcpkgs/libpostproc4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libpostproc4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswresample4 b/srcpkgs/libswresample4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libswresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswscale4 b/srcpkgs/libswscale4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libswscale4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file

From 1e3279cc07726346889fc32431fb69d65061b28c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:04 -0400
Subject: [PATCH 005/114] opencv: update to 4.7.0.

---
 common/shlibs           | 104 ++++++++++++++++++++--------------------
 srcpkgs/opencv/template |   8 ++--
 2 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index 134d88afb91c2..941434f03af35 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2084,58 +2084,58 @@ libcapstone.so.5 capstone-5.0.1_1
 libhavege.so.2 libhaveged-1.9.11_1
 libnih.so.1 libnih-1.0.3_1
 libnih-dbus.so.1 libnih-1.0.3_1
-libopencv_quality.so.406 libopencv-4.6.0_1
-libopencv_reg.so.406 libopencv-4.6.0_1
-libopencv_surface_matching.so.406 libopencv-4.6.0_1
-libopencv_xphoto.so.406 libopencv-4.6.0_1
-libopencv_freetype.so.406 libopencv-4.6.0_1
-libopencv_fuzzy.so.406 libopencv-4.6.0_1
-libopencv_hfs.so.406 libopencv-4.6.0_1
-libopencv_img_hash.so.406 libopencv-4.6.0_1
-libopencv_line_descriptor.so.406 libopencv-4.6.0_1
-libopencv_saliency.so.406 libopencv-4.6.0_1
-libopencv_structured_light.so.406 libopencv-4.6.0_1
-libopencv_aruco.so.406 libopencv-4.6.0_1
-libopencv_bgsegm.so.406 libopencv-4.6.0_1
-libopencv_bioinspired.so.406 libopencv-4.6.0_1
-libopencv_ccalib.so.406 libopencv-4.6.0_1
-libopencv_face.so.406 libopencv-4.6.0_1
-libopencv_tracking.so.406 libopencv-4.6.0_1
-libopencv_xfeatures2d.so.406 libopencv-4.6.0_1
-libopencv_optflow.so.406 libopencv-4.6.0_1
-libopencv_ximgproc.so.406 libopencv-4.6.0_1
-libopencv_plot.so.406 libopencv-4.6.0_1
-libopencv_text.so.406 libopencv-4.6.0_1
-libopencv_ml.so.406 libopencv-4.6.0_1
-libopencv_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn.so.406 libopencv-4.6.0_1
-libopencv_shape.so.406 libopencv-4.6.0_1
-libopencv_stitching.so.406 libopencv-4.6.0_1
-libopencv_photo.so.406 libopencv-4.6.0_1
-libopencv_video.so.406 libopencv-4.6.0_1
-libopencv_calib3d.so.406 libopencv-4.6.0_1
-libopencv_features2d.so.406 libopencv-4.6.0_1
-libopencv_flann.so.406 libopencv-4.6.0_1
-libopencv_highgui.so.406 libopencv-4.6.0_1
-libopencv_videoio.so.406 libopencv-4.6.0_1
-libopencv_imgcodecs.so.406 libopencv-4.6.0_1
-libopencv_imgproc.so.406 libopencv-4.6.0_1
-libopencv_core.so.406 libopencv-4.6.0_1
-libopencv_superres.so.406 libopencv-4.6.0_1
-libopencv_videostab.so.406 libopencv-4.6.0_1
-libopencv_gapi.so.406 libopencv-4.6.0_1
-libopencv_xobjdetect.so.406 libopencv-4.6.0_1
-libopencv_datasets.so.406 libopencv-4.6.0_1
-libopencv_dnn_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn_superres.so.406 libopencv-4.6.0_1
-libopencv_dpm.so.406 libopencv-4.6.0_1
-libopencv_phase_unwrapping.so.406 libopencv-4.6.0_1
-libopencv_stereo.so.406 libopencv-4.6.0_1
-libopencv_rapid.so.406 libopencv-4.6.0_1
-libopencv_intensity_transform.so.406 libopencv-4.6.0_1
-libopencv_alphamat.so.406 libopencv-4.6.0_1
-libopencv_barcode.so.406 libopencv-4.6.0_1
-libopencv_mcc.so.406 libopencv-4.6.0_1
+libopencv_quality.so.407 libopencv-4.7.0_1
+libopencv_reg.so.407 libopencv-4.7.0_1
+libopencv_surface_matching.so.407 libopencv-4.7.0_1
+libopencv_xphoto.so.407 libopencv-4.7.0_1
+libopencv_freetype.so.407 libopencv-4.7.0_1
+libopencv_fuzzy.so.407 libopencv-4.7.0_1
+libopencv_hfs.so.407 libopencv-4.7.0_1
+libopencv_img_hash.so.407 libopencv-4.7.0_1
+libopencv_line_descriptor.so.407 libopencv-4.7.0_1
+libopencv_saliency.so.407 libopencv-4.7.0_1
+libopencv_structured_light.so.407 libopencv-4.7.0_1
+libopencv_aruco.so.407 libopencv-4.7.0_1
+libopencv_bgsegm.so.407 libopencv-4.7.0_1
+libopencv_bioinspired.so.407 libopencv-4.7.0_1
+libopencv_ccalib.so.407 libopencv-4.7.0_1
+libopencv_face.so.407 libopencv-4.7.0_1
+libopencv_tracking.so.407 libopencv-4.7.0_1
+libopencv_xfeatures2d.so.407 libopencv-4.7.0_1
+libopencv_optflow.so.407 libopencv-4.7.0_1
+libopencv_ximgproc.so.407 libopencv-4.7.0_1
+libopencv_plot.so.407 libopencv-4.7.0_1
+libopencv_text.so.407 libopencv-4.7.0_1
+libopencv_ml.so.407 libopencv-4.7.0_1
+libopencv_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn.so.407 libopencv-4.7.0_1
+libopencv_shape.so.407 libopencv-4.7.0_1
+libopencv_stitching.so.407 libopencv-4.7.0_1
+libopencv_photo.so.407 libopencv-4.7.0_1
+libopencv_video.so.407 libopencv-4.7.0_1
+libopencv_calib3d.so.407 libopencv-4.7.0_1
+libopencv_features2d.so.407 libopencv-4.7.0_1
+libopencv_flann.so.407 libopencv-4.7.0_1
+libopencv_highgui.so.407 libopencv-4.7.0_1
+libopencv_videoio.so.407 libopencv-4.7.0_1
+libopencv_imgcodecs.so.407 libopencv-4.7.0_1
+libopencv_imgproc.so.407 libopencv-4.7.0_1
+libopencv_core.so.407 libopencv-4.7.0_1
+libopencv_superres.so.407 libopencv-4.7.0_1
+libopencv_videostab.so.407 libopencv-4.7.0_1
+libopencv_gapi.so.407 libopencv-4.7.0_1
+libopencv_xobjdetect.so.407 libopencv-4.7.0_1
+libopencv_datasets.so.407 libopencv-4.7.0_1
+libopencv_dnn_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn_superres.so.407 libopencv-4.7.0_1
+libopencv_dpm.so.407 libopencv-4.7.0_1
+libopencv_phase_unwrapping.so.407 libopencv-4.7.0_1
+libopencv_stereo.so.407 libopencv-4.7.0_1
+libopencv_rapid.so.407 libopencv-4.7.0_1
+libopencv_intensity_transform.so.407 libopencv-4.7.0_1
+libopencv_alphamat.so.407 libopencv-4.7.0_1
+libopencv_barcode.so.407 libopencv-4.7.0_1
+libopencv_mcc.so.407 libopencv-4.7.0_1
 libuniconf.so.4.6 wvstreams-4.6.1_20
 libwvbase.so.4.6 wvstreams-4.6.1_20
 libwvutils.so.4.6 wvstreams-4.6.1_20
diff --git a/srcpkgs/opencv/template b/srcpkgs/opencv/template
index aea4bfc3a265c..ce94de9424d18 100644
--- a/srcpkgs/opencv/template
+++ b/srcpkgs/opencv/template
@@ -1,7 +1,7 @@
 # Template file for 'opencv'
 pkgname=opencv
-version=4.6.0
-revision=6
+version=4.7.0
+revision=1
 create_wrksrc=yes
 build_wrksrc=${pkgname}-${version}
 build_style=cmake
@@ -24,8 +24,8 @@ homepage="https://opencv.org"
 changelog="https://github.com/opencv/opencv/wiki/ChangeLog"
 distfiles="https://github.com/opencv/opencv/archive/${version}.tar.gz
  https://github.com/opencv/opencv_contrib/archive/${version}.tar.gz>contrib.tar.gz"
-checksum="1ec1cba65f9f20fe5a41fda1586e01c70ea0c9a6d7b67c9e13edf0cfe2239277
- 1777d5fd2b59029cf537e5fd6f8aa68d707075822f90bde683fcde086f85f7a7"
+checksum="8df0079cdbe179748a18d44731af62a245a45ebf5085223dc03133954c662973
+ 42df840cf9055e59d0e22c249cfb19f04743e1bdad113d31b1573d3934d62584"
 patch_args="-Np1 -d ${build_wrksrc}"
 # tests hang indenfinitely, even with test data included
 make_check=no

From 38865e67b3184c75d4f9c647f0816ccd7ae0b9eb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 006/114] actiona: revbump for opencv-4.7.0

---
 srcpkgs/actiona/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/actiona/template b/srcpkgs/actiona/template
index cf5f0b7a2ae61..0d899311e6df7 100644
--- a/srcpkgs/actiona/template
+++ b/srcpkgs/actiona/template
@@ -1,7 +1,7 @@
 # Template file for 'actiona'
 pkgname=actiona
 version=3.10.1
-revision=2
+revision=3
 build_style=qmake
 configure_args="PKGCONFIG_OPENCV=opencv4"
 hostmakedepends="pkg-config qt5-plugin-mysql qt5-qmake qt5-host-tools"

From d0d68c5bc8e62ab31277925824d00159817bcc73 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 007/114] retroshare: revbump for opencv-4.7.0

---
 srcpkgs/retroshare/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroshare/template b/srcpkgs/retroshare/template
index bb17569277a7f..49e2c1cbe8a53 100644
--- a/srcpkgs/retroshare/template
+++ b/srcpkgs/retroshare/template
@@ -1,7 +1,7 @@
 # Template file for 'retroshare'
 pkgname=retroshare
 version=0.6.6
-revision=3
+revision=4
 build_style=qmake
 #XXX broadcast feature requires an ancient udp-discovery-cpp which either needs
 # to be fetched+patched (FTBFS) here or packaged :/

From ec57c62d012b4173509a085e1d3179c6cc700613 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 008/114] waifu2x-converter-cpp: revbump for opencv-4.7.0

---
 srcpkgs/waifu2x-converter-cpp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waifu2x-converter-cpp/template b/srcpkgs/waifu2x-converter-cpp/template
index 361b8a23b9497..c5ac17eb54ea4 100644
--- a/srcpkgs/waifu2x-converter-cpp/template
+++ b/srcpkgs/waifu2x-converter-cpp/template
@@ -1,7 +1,7 @@
 # Template file for 'waifu2x-converter-cpp'
 pkgname=waifu2x-converter-cpp
 version=5.2.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DINSTALL_MODELS=ON"
 hostmakedepends="pkg-config"

From 7b4b4942972ea491bbfdaad593ade4f2e00fb19d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:38 -0400
Subject: [PATCH 009/114] vlc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/vlc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vlc/template b/srcpkgs/vlc/template
index abc5eeba01564..5f291b1b81e23 100644
--- a/srcpkgs/vlc/template
+++ b/srcpkgs/vlc/template
@@ -25,7 +25,7 @@ lib32disabled=yes
 hostmakedepends="automake libtool pkg-config flex gettext libgcrypt-devel
  live555-devel gettext-devel $(vopt_if lua lua52) $(vopt_if chromecast protobuf)"
 makedepends="
- avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg-devel freefont-ttf
+ avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg4-devel freefont-ttf
  gnutls-devel jack-devel liba52-devel libass-devel libbluray-devel
  libcdio-devel libdca-devel libdvbpsi-devel libdvdnav-devel libmad-devel
  libmatroska-devel libmodplug-devel libmpcdec-devel libmpeg2-devel

From 14146a8a73e60bda2a3987eec3896830c9c0ceca Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:55 -0400
Subject: [PATCH 010/114] osg: revbump for ffmpeg4-4.4.3

---
 srcpkgs/osg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/osg/template b/srcpkgs/osg/template
index a9ebbd287933b..755793f7e11bf 100644
--- a/srcpkgs/osg/template
+++ b/srcpkgs/osg/template
@@ -8,7 +8,7 @@ build_helper="qemu"
 configure_args="-DLIB_POSTFIX="
 hostmakedepends="pkg-config xrandr"
 makedepends="MesaLib-devel gtkglext-devel libcurl-devel giflib-devel librsvg-devel
- jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg-devel xine-lib-devel
+ jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg4-devel xine-lib-devel
  SDL2-devel gst-plugins-base1-devel
  $(vopt_if openexr libopenexr-devel)
  $(vopt_if poppler poppler-glib-devel)

From 1f5100d0f20bbfd6afb62a4014883273454e37f7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:13 -0400
Subject: [PATCH 011/114] xine-lib: revbump for ffmpeg4-4.4.3

---
 srcpkgs/xine-lib/template | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/xine-lib/template b/srcpkgs/xine-lib/template
index 3be4d08eac77a..ed6194c17d11e 100644
--- a/srcpkgs/xine-lib/template
+++ b/srcpkgs/xine-lib/template
@@ -1,14 +1,14 @@
 # Template file for 'xine-lib'
 pkgname=xine-lib
-version=1.2.12
-revision=3
+version=1.2.13
+revision=1
 build_style=gnu-configure
 configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
  --disable-oss"
 hostmakedepends="automake gettext-devel libtool pkg-config perl"
 makedepends="
  zlib-devel alsa-lib-devel libxcb-devel libSM-devel libXext-devel libXv-devel
- libXvMC-devel liba52-devel libmad-devel ffmpeg-devel pulseaudio-devel
+ libXvMC-devel liba52-devel libmad-devel ffmpeg4-devel pulseaudio-devel
  jack-devel samba-devel libflac-devel libmodplug-devel libmpcdec-devel
  speex-devel libtheora-devel libvorbis-devel libdca-devel faad2-devel
  libcdio-devel libbluray-devel aalib-devel libcaca-devel libXinerama-devel
@@ -19,7 +19,7 @@ license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="http://www.xine-project.org"
 changelog="https://sourceforge.net/projects/xine/files/xine-lib/${version}/README.txt/view"
 distfiles="${SOURCEFORGE_SITE}/xine/${pkgname}-${version}.tar.xz"
-checksum=d606270468e1540c2a89c0d7f5fdf11e17ecc0c2698cc0bcb1065ff26abee098
+checksum=5f10d6d718a4a51c17ed1b32b031d4f9b80b061e8276535b2be31e5ac4b75e6f
 
 case "$XBPS_TARGET_MACHINE" in
 	i686-musl)

From 24f069591dcd1e5427beccd4f1487bc09191ba65 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 012/114] arcan: revbump for ffmpeg-6.0

---
 srcpkgs/arcan/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/arcan/template b/srcpkgs/arcan/template
index efd0afe10576d..b91e6900d42a1 100644
--- a/srcpkgs/arcan/template
+++ b/srcpkgs/arcan/template
@@ -2,7 +2,7 @@
 # !! keep synced with: acfgfs aclip aloadimage
 pkgname=arcan
 version=0.6.2.1
-revision=1
+revision=2
 create_wrksrc=yes
 build_wrksrc=arcan/src
 build_style=cmake

From 621943f39bbe91ceda0d99b43aadd5bf73210939 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 013/114] attract: revbump for ffmpeg4-4.4.3

---
 srcpkgs/attract/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/attract/template b/srcpkgs/attract/template
index 26144e931a3c7..e760bf0d18aec 100644
--- a/srcpkgs/attract/template
+++ b/srcpkgs/attract/template
@@ -1,12 +1,12 @@
 # Template file for 'attract'
 pkgname=attract
 version=2.6.2
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="VERBOSE=1"
 make_use_env=yes
 hostmakedepends="pkg-config"
-makedepends="SFML-devel ffmpeg-devel fontconfig-devel glu-devel libarchive-devel
+makedepends="SFML-devel ffmpeg4-devel fontconfig-devel glu-devel libarchive-devel
  libcurl-devel libjpeg-turbo-devel xine-lib rapidjson libXrandr-devel"
 depends="git"
 short_desc="Attract-Mode is a graphical frontend for emulators"

From b79a4d16ef069e25a6b4219aeac4b4a94a7b4136 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 014/114] aubio: revbump for ffmpeg-6.0

---
 srcpkgs/aubio/patches/ffmpeg5.patch | 25 +++++++++++++++++++++++++
 srcpkgs/aubio/template              |  2 +-
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/aubio/patches/ffmpeg5.patch

diff --git a/srcpkgs/aubio/patches/ffmpeg5.patch b/srcpkgs/aubio/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..aace41a6e6d9a
--- /dev/null
+++ b/srcpkgs/aubio/patches/ffmpeg5.patch
@@ -0,0 +1,25 @@
+From 8a05420e5dd8c7b8b2447f82dc919765876511b3 Mon Sep 17 00:00:00 2001
+From: Paul Brossier <piem@piem.org>
+Date: Tue, 25 Jan 2022 18:30:27 +0100
+Subject: [PATCH] [source_avcodec] define FF_API_LAVF_AVCTX for libavcodec >
+ 59, thx @berolinux (closes gh-353)
+
+---
+ src/io/source_avcodec.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/io/source_avcodec.c b/src/io/source_avcodec.c
+index e0ae93b5..1421bd9a 100644
+--- a/src/io/source_avcodec.c
++++ b/src/io/source_avcodec.c
+@@ -68,6 +68,10 @@
+ #define AUBIO_AVCODEC_MAX_BUFFER_SIZE AV_INPUT_BUFFER_MIN_SIZE
+ #endif
+ 
++#if LIBAVCODEC_VERSION_MAJOR >= 59
++#define FF_API_LAVF_AVCTX 1
++#endif
++
+ struct _aubio_source_avcodec_t {
+   uint_t hop_size;
+   uint_t samplerate;
diff --git a/srcpkgs/aubio/template b/srcpkgs/aubio/template
index ad1c4b2569917..7d875cc02541a 100644
--- a/srcpkgs/aubio/template
+++ b/srcpkgs/aubio/template
@@ -1,7 +1,7 @@
 # Template file for 'aubio'
 pkgname=aubio
 version=0.4.9
-revision=1
+revision=2
 build_style=waf3
 # XXX lash, pure and swig support.
 hostmakedepends="pkg-config txt2man"

From 7ad17350fddb0327c248b95af3f37b259d937f16 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 015/114] audacious-plugins: revbump for ffmpeg-6.0

---
 .../audacious-plugins/patches/ffmpeg5.patch   | 43 +++++++++++++++++++
 srcpkgs/audacious-plugins/template            |  2 +-
 2 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/audacious-plugins/patches/ffmpeg5.patch

diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg5.patch b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..4e5e34099d71c
--- /dev/null
+++ b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
@@ -0,0 +1,43 @@
+commit 298aa371c56c2f52c25a33d9bdec4918b11cebdc
+Author: tibequadorian <tibequadorian@posteo.de>
+Date:   Sat Mar 19 18:40:12 2022 +0100
+
+    audacious-plugins: rebuild against ffmpeg-5.0
+
+diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+new file mode 100644
+index 0000000000..617c11215b
+--- /dev/null
++++ b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+@@ -0,0 +1,31 @@
++From f60beb400eeb1e4778bbfd738bc4a4ccef3de539 Mon Sep 17 00:00:00 2001
++From: John Lindgren <john@jlindgren.net>
++Date: Sat, 5 Mar 2022 12:05:34 -0500
++Subject: [PATCH] Fix build with FFmpeg 5.0
++
++---
++ src/ffaudio/ffaudio-core.cc | 4 ++--
++ 1 file changed, 2 insertions(+), 2 deletions(-)
++
++diff --git a/src/ffaudio/ffaudio-core.cc b/src/ffaudio/ffaudio-core.cc
++index 16dc63e3a..a2b95fd6c 100644
++--- a/src/ffaudio/ffaudio-core.cc
+++++ b/src/ffaudio/ffaudio-core.cc
++@@ -274,7 +274,7 @@ static AVInputFormat * get_format_by_content (const char * name, VFSFile & file)
++         AVProbeData d = {name, buf, filled};
++         score = target;
++ 
++-        f = av_probe_input_format2 (& d, true, & score);
+++        f = (AVInputFormat *) av_probe_input_format2 (& d, true, & score);
++         if (f)
++             break;
++ 
++@@ -347,7 +347,7 @@ static bool find_codec (AVFormatContext * c, CodecInfo * cinfo)
++ #endif
++         if (stream && stream->codecpar && stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
++         {
++-            AVCodec * codec = avcodec_find_decoder (stream->codecpar->codec_id);
+++            AVCodec * codec = (AVCodec *) avcodec_find_decoder (stream->codecpar->codec_id);
++ 
++             if (codec)
++             {
diff --git a/srcpkgs/audacious-plugins/template b/srcpkgs/audacious-plugins/template
index 05e53a9adf78f..4b1968e03de78 100644
--- a/srcpkgs/audacious-plugins/template
+++ b/srcpkgs/audacious-plugins/template
@@ -2,7 +2,7 @@
 #Keep in sync with audacious!
 pkgname=audacious-plugins
 version=4.3.1
-revision=3
+revision=4
 build_style=meson
 configure_args="$(vopt_bool gtk3 gtk) $(vopt_bool gtk3)
  $(vopt_bool qt) $(vopt_bool qt qt6)"

From b17521903cda07a78a13e382fd937b51c226ac65 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 016/114] audacity: revbump for ffmpeg4-4.4.3

---
 srcpkgs/audacity/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/audacity/template b/srcpkgs/audacity/template
index 7b838119ab261..fb15f782ac1f7 100644
--- a/srcpkgs/audacity/template
+++ b/srcpkgs/audacity/template
@@ -1,7 +1,7 @@
 # Template file for 'audacity'
 pkgname=audacity
 version=3.4.2
-revision=1
+revision=2
 build_style=cmake
 build_helper="cmake-wxWidgets-gtk3 qemu"
 configure_args="-Daudacity_use_ffmpeg=loaded -Daudacity_lib_preference=system
@@ -12,7 +12,7 @@ configure_args="-Daudacity_use_ffmpeg=loaded -Daudacity_lib_preference=system
  -Daudacity_has_updates_check=OFF -DAUDACITY_BUILD_LEVEL=2"
 hostmakedepends="pkg-config gettext python3"
 makedepends="wxWidgets-gtk3-devel gtk+3-devel expat-devel lame-devel
- libsoxr-devel portaudio-devel sqlite-devel ffmpeg-devel
+ libsoxr-devel portaudio-devel sqlite-devel ffmpeg4-devel
  libid3tag-devel libmad-devel vamp-plugin-sdk-devel libogg-devel
  libvorbis-devel libflac-devel lilv-devel lv2 serd-devel sord-devel
  sratom-devel suil-devel portmidi-devel soundtouch-devel twolame-devel

From f5021798d5ed6568db1f4c8488ec25ccd094bad4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 017/114] avidemux: revbump for ffmpeg-6.0

---
 srcpkgs/avidemux/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/avidemux/template b/srcpkgs/avidemux/template
index 253a0243e2259..557285982d2b8 100644
--- a/srcpkgs/avidemux/template
+++ b/srcpkgs/avidemux/template
@@ -1,7 +1,7 @@
 # Template file for 'avidemux'
 pkgname=avidemux
 version=2.8.0
-revision=2
+revision=3
 # Can't be compiled for aarch64, arm* or mips*
 archs="x86_64* i686*"
 hostmakedepends="cmake pkg-config qt5-host-tools qt5-devel tar yasm"

From 89eb44444718eaa27bf4bf82fe9bdd5a52de6ffd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 018/114] blender: revbump for ffmpeg-6.0

---
 srcpkgs/blender/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index 05fdbf8f747e2..093d6d2004e95 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -9,8 +9,8 @@ configure_args="-DWITH_INSTALL_PORTABLE=OFF -DWITH_PYTHON_INSTALL=OFF
  -DWITH_JACK=ON -DWITH_CODEC_FFMPEG=ON -DWITH_CODEC_SNDFILE=ON -DWITH_OPENMP=ON
  -DWITH_FFTW3=ON -DWITH_MOD_OCEANSIM=ON -DWITH_CYCLES_EMBREE=OFF -DWITH_OPENCOLORIO=ON
  -DWITH_IMAGE_OPENEXR=ON -DWITH_IMAGE_OPENJPEG=ON -DWITH_OPENSUBDIV=ON
- -DWITH_OPENCOLLADA=ON -DWITH_SYSTEM_GLEW=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
- -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_LIBDECOR=ON
+ -DWITH_OPENCOLLADA=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
+ -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_WAYLAND_LIBDECOR=ON
  -DWITH_BUILDINFO=OFF -DPYTHON_VERSION=${py3_ver} -DPYTHON_LIBPATH=/usr/lib
  -DPYTHON_LIBRARY=python${py3_ver}${py3_abiver} -DPYTHON_INCLUDE_DIRS=/${py3_inc}
  -DWITH_SYSTEM_LZO=ON -DWITH_SYSTEM_EIGEN3=ON -DWITH_SYSTEM_FREETYPE=ON"

From 28aa410d48443ef5c27342e8922eafcfeed2f1d9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 019/114] cantata: revbump for ffmpeg-6.0

---
 srcpkgs/cantata/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cantata/template b/srcpkgs/cantata/template
index 4b417d80d5c2d..8a90aaa4c07a2 100644
--- a/srcpkgs/cantata/template
+++ b/srcpkgs/cantata/template
@@ -1,7 +1,7 @@
 # Template file for 'cantata'
 pkgname=cantata
 version=2.5.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools qt5-tools"
 makedepends="qt5-devel qt5-tools-devel qt5-svg-devel qt5-xmlpatterns-devel

From 8281751adbbe1da17bbbff2978a11c320e95a2ce Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 020/114] ccextractor: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ccextractor/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/ccextractor/template b/srcpkgs/ccextractor/template
index 9abcd82852b27..6eccad5885af9 100644
--- a/srcpkgs/ccextractor/template
+++ b/srcpkgs/ccextractor/template
@@ -1,12 +1,12 @@
 # Template file for 'ccextractor'
 pkgname=ccextractor
 version=0.93
-revision=1
+revision=2
 build_wrksrc="linux"
 build_style=gnu-configure
 configure_args="--enable-ocr --enable-hardsubx"
 hostmakedepends="automake pkg-config"
-makedepends="leptonica-devel tesseract-ocr-devel ffmpeg-devel"
+makedepends="leptonica-devel tesseract-ocr-devel ffmpeg4-devel"
 short_desc="Extract subtitles from video streams"
 maintainer="newbluemoon <blaumolch@mailbox.org>"
 license="GPL-2.0-or-later"

From 527ffbaf514935c23de3965989a3d98606325c7c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 021/114] chromaprint: revbump for ffmpeg-6.0

---
 srcpkgs/chromaprint/patches/ffmpeg5.patch | 569 ++++++++++++++++++++++
 srcpkgs/chromaprint/template              |   2 +-
 2 files changed, 570 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromaprint/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromaprint/patches/ffmpeg5.patch b/srcpkgs/chromaprint/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..a9fd307a23c8a
--- /dev/null
+++ b/srcpkgs/chromaprint/patches/ffmpeg5.patch
@@ -0,0 +1,569 @@
+From 8ccad6937177b1b92e40ab8f4447ea27bac009a7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= <lalinsky@gmail.com>
+Date: Fri, 4 Nov 2022 21:47:38 +0100
+Subject: [PATCH] Use FFmpeg 5.x (#120)
+
+* Use FFmpeg 5.1.2 for CI builds
+
+* Build on Ubuntu 20.04
+
+* Upgrade code to FFmpeg 5.x APIs
+
+* Only set FFmpeg include dirs if building tools
+
+* No longer needed
+
+* Use ubuntu 20.04
+---
+ .github/workflows/build.yml                   |   6 +-
+ CMakeLists.txt                                |  16 --
+ package/build.sh                              |   4 +-
+ src/audio/ffmpeg_audio_processor.h            |   2 -
+ src/audio/ffmpeg_audio_processor_avresample.h |  72 -------
+ src/audio/ffmpeg_audio_processor_swresample.h |  18 +-
+ src/audio/ffmpeg_audio_reader.h               | 197 +++++++++---------
+ tests/CMakeLists.txt                          |   6 +
+ 8 files changed, 122 insertions(+), 199 deletions(-)
+ delete mode 100644 src/audio/ffmpeg_audio_processor_avresample.h
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index f8d6a32..4da2405 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -84,9 +84,6 @@ find_package(FFmpeg)
+ if(FFMPEG_LIBRARIES)
+ 	cmake_push_check_state(RESET)
+ 	set(CMAKE_REQUIRED_LIBRARIES ${FFMPEG_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -lm)
+-	check_function_exists(av_packet_unref HAVE_AV_PACKET_UNREF)
+-	check_function_exists(av_frame_alloc HAVE_AV_FRAME_ALLOC)
+-	check_function_exists(av_frame_free HAVE_AV_FRAME_FREE)
+ 	cmake_pop_check_state()
+ endif()
+
+@@ -163,14 +160,11 @@ message(STATUS "Using ${FFT_LIB} for FFT calculations")
+ if(NOT AUDIO_PROCESSOR_LIB)
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+ 		set(AUDIO_PROCESSOR_LIB "swresample")
+-	elseif(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(AUDIO_PROCESSOR_LIB "avresample")
+ 	endif()
+ endif()
+
+ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE OFF)
+ 		set(USE_SWRESAMPLE ON)
+ 		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBSWRESAMPLE_LIBRARIES})
+ 		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBSWRESAMPLE_INCLUDE_DIRS})
+@@ -178,16 +172,6 @@ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+ 	endif()
+ 	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+-elseif(AUDIO_PROCESSOR_LIB STREQUAL "avresample")
+-	if(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE ON)
+-		set(USE_SWRESAMPLE OFF)
+-		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBAVRESAMPLE_LIBRARIES})
+-		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBAVRESAMPLE_INCLUDE_DIRS})
+-	else()
+-		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+-	endif()
+-	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+ else()
+ 	message(STATUS "Building without audio conversion support, please install FFmpeg with libswresample")
+ endif()
+diff --git a/package/build.sh b/package/build.sh
+index da631ae..b41d36e 100755
+--- a/package/build.sh
++++ b/package/build.sh
+@@ -7,8 +7,8 @@ set -eux
+
+ BASE_DIR=$(cd $(dirname $0)/.. && pwd)
+
+-FFMPEG_VERSION=4.4.1
+-FFMPEG_BUILD_TAG=v4.4.1-1
++FFMPEG_VERSION=5.1.2
++FFMPEG_BUILD_TAG=v${FFMPEG_VERSION}-1
+
+ TMP_BUILD_DIR=$BASE_DIR/$(mktemp -d build.XXXXXXXX)
+ trap 'rm -rf $TMP_BUILD_DIR' EXIT
+diff --git a/src/audio/ffmpeg_audio_processor.h b/src/audio/ffmpeg_audio_processor.h
+index 7628fc7..39f4f6d 100644
+--- a/src/audio/ffmpeg_audio_processor.h
++++ b/src/audio/ffmpeg_audio_processor.h
+@@ -10,8 +10,6 @@
+
+ #if defined(USE_SWRESAMPLE)
+ #include "audio/ffmpeg_audio_processor_swresample.h"
+-#elif defined(USE_AVRESAMPLE)
+-#include "audio/ffmpeg_audio_processor_avresample.h"
+ #else
+ #error "no audio processing library"
+ #endif
+diff --git a/src/audio/ffmpeg_audio_processor_avresample.h b/src/audio/ffmpeg_audio_processor_avresample.h
+deleted file mode 100644
+index bd85f92..0000000
+--- a/src/audio/ffmpeg_audio_processor_avresample.h
++++ /dev/null
+@@ -1,72 +0,0 @@
+-// Copyright (C) 2016  Lukas Lalinsky
+-// Distributed under the MIT license, see the LICENSE file for details.
+-
+-#ifndef CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-#define CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-
+-extern "C" {
+-#include <libavresample/avresample.h>
+-}
+-
+-namespace chromaprint {
+-
+-class FFmpegAudioProcessor {
+-public:
+-	FFmpegAudioProcessor() {
+-		m_resample_ctx = avresample_alloc_context();
+-	}
+-
+-	~FFmpegAudioProcessor() {
+-		avresample_free(&m_resample_ctx);
+-	}
+-
+-	void SetCompatibleMode() {
+-		av_opt_set_int(m_resample_ctx, "filter_size", 16, 0);
+-		av_opt_set_int(m_resample_ctx, "phase_shift", 8, 0);
+-		av_opt_set_int(m_resample_ctx, "linear_interp", 1, 0);
+-		av_opt_set_double(m_resample_ctx, "cutoff", 0.8, 0);
+-	}
+-
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "in_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_rate", sample_rate, 0);
+-	}
+-
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "out_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_rate, 0);
+-	}
+-
+-	int Init() {
+-		return avresample_open(m_resample_ctx);
+-	}
+-
+-	int Convert(uint8_t **out, int out_count, const uint8_t **in, int in_count) {
+-		return avresample_convert(m_resample_ctx, out, 0, out_count, (uint8_t **) in, 0, in_count);
+-	}
+-
+-	int Flush(uint8_t **out, int out_count) {
+-		return avresample_read(m_resample_ctx, out, out_count);
+-	}
+-
+-private:
+-	AVAudioResampleContext *m_resample_ctx = nullptr;
+-};
+-
+-}; // namespace chromaprint
+-
+-#endif
+diff --git a/src/audio/ffmpeg_audio_processor_swresample.h b/src/audio/ffmpeg_audio_processor_swresample.h
+index b86266b..b1d4bea 100644
+--- a/src/audio/ffmpeg_audio_processor_swresample.h
++++ b/src/audio/ffmpeg_audio_processor_swresample.h
+@@ -28,30 +28,28 @@ public:
+ 		av_opt_set_double(m_swr_ctx, "cutoff", 0.8, 0);
+ 	}
+
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "icl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "ich", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetInputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "in_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "isf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "in_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "isr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "in_sample_rate", sample_rate, 0);
+ 	}
+
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "ocl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "och", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetOutputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "out_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "osf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "out_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "osr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "out_sample_rate", sample_rate, 0);
+ 	}
+
+ 	int Init() {
+diff --git a/src/audio/ffmpeg_audio_reader.h b/src/audio/ffmpeg_audio_reader.h
+index 5550164..1c6b346 100644
+--- a/src/audio/ffmpeg_audio_reader.h
++++ b/src/audio/ffmpeg_audio_reader.h
+@@ -62,7 +62,7 @@ public:
+ 	bool Read(const int16_t **data, size_t *size);
+
+ 	bool IsOpen() const { return m_opened; }
+-	bool IsFinished() const { return m_finished && !m_got_frame; }
++	bool IsFinished() const { return !m_has_more_packets && !m_has_more_frames; }
+
+ 	std::string GetError() const { return m_error; }
+ 	int GetErrorCode() const { return m_error_code; }
+@@ -74,20 +74,19 @@ private:
+ 	uint8_t *m_convert_buffer[1] = { nullptr };
+ 	int m_convert_buffer_nb_samples = 0;
+
+-	AVInputFormat *m_input_fmt = nullptr;
++	const AVInputFormat *m_input_fmt = nullptr;
+ 	AVDictionary *m_input_opts = nullptr;
+
+ 	AVFormatContext *m_format_ctx = nullptr;
+ 	AVCodecContext *m_codec_ctx = nullptr;
+-	AVFrame *m_frame = nullptr;
+ 	int m_stream_index = -1;
+ 	std::string m_error;
+ 	int m_error_code = 0;
+-	bool m_finished = false;
+ 	bool m_opened = false;
+-	int m_got_frame = 0;
+-	AVPacket m_packet;
+-	AVPacket m_packet0;
++	bool m_has_more_packets = true;
++	bool m_has_more_frames = true;
++	AVPacket *m_packet = nullptr;
++	AVFrame *m_frame = nullptr;
+
+ 	int m_output_sample_rate = 0;
+ 	int m_output_channels = 0;
+@@ -98,19 +97,12 @@ private:
+
+ inline FFmpegAudioReader::FFmpegAudioReader() {
+ 	av_log_set_level(AV_LOG_QUIET);
+-
+-	av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
+ }
+
+ inline FFmpegAudioReader::~FFmpegAudioReader() {
+ 	Close();
+ 	av_dict_free(&m_input_opts);
+ 	av_freep(&m_convert_buffer[0]);
+-	av_packet_unref(&m_packet0);
+ }
+
+ inline bool FFmpegAudioReader::SetInputFormat(const char *name) {
+@@ -135,11 +127,10 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ 	Close();
+
+-    av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
++	m_packet = av_packet_alloc();
++	if (!m_packet) {
++		return false;
++	}
+
+ 	ret = avformat_open_input(&m_format_ctx, file_name.c_str(), m_input_fmt, &m_input_opts);
+ 	if (ret < 0) {
+@@ -153,26 +144,31 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		return false;
+ 	}
+
+-	AVCodec *codec;
++	const AVCodec *codec;
+ 	ret = av_find_best_stream(m_format_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &codec, 0);
+ 	if (ret < 0) {
+ 		SetError("Could not find any audio stream in the file", ret);
+ 		return false;
+ 	}
+ 	m_stream_index = ret;
++	auto stream = m_format_ctx->streams[m_stream_index];
+
+-	m_codec_ctx = m_format_ctx->streams[m_stream_index]->codec;
++	m_codec_ctx = avcodec_alloc_context3(codec);
+ 	m_codec_ctx->request_sample_fmt = AV_SAMPLE_FMT_S16;
+
++	ret = avcodec_parameters_to_context(m_codec_ctx, stream->codecpar);
++	if (ret < 0) {
++		SetError("Could not copy the stream parameters", ret);
++		return false;
++	}
++
+ 	ret = avcodec_open2(m_codec_ctx, codec, nullptr);
+ 	if (ret < 0) {
+ 		SetError("Could not open the codec", ret);
+ 		return false;
+ 	}
+
+-	if (!m_codec_ctx->channel_layout) {
+-		m_codec_ctx->channel_layout = av_get_default_channel_layout(m_codec_ctx->channels);
+-	}
++	av_dump_format(m_format_ctx, 0, "foo", 0);
+
+ 	m_frame = av_frame_alloc();
+ 	if (!m_frame) {
+@@ -183,19 +179,23 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		m_output_sample_rate = m_codec_ctx->sample_rate;
+ 	}
+
+-	if (!m_output_channels) {
+-		m_output_channels = m_codec_ctx->channels;
++	AVChannelLayout output_channel_layout;
++	if (m_output_channels) {
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
++	} else {
++		m_output_channels = m_codec_ctx->ch_layout.nb_channels;
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
+ 	}
+
+-	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
++	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->ch_layout.nb_channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
+ 		m_converter.reset(new FFmpegAudioProcessor());
+ 		m_converter->SetCompatibleMode();
+ 		m_converter->SetInputSampleFormat(m_codec_ctx->sample_fmt);
+ 		m_converter->SetInputSampleRate(m_codec_ctx->sample_rate);
+-		m_converter->SetInputChannelLayout(m_codec_ctx->channel_layout);
++		m_converter->SetInputChannelLayout(&(m_codec_ctx->ch_layout));
+ 		m_converter->SetOutputSampleFormat(AV_SAMPLE_FMT_S16);
+ 		m_converter->SetOutputSampleRate(m_output_sample_rate);
+-		m_converter->SetOutputChannelLayout(av_get_default_channel_layout(m_output_channels));
++		m_converter->SetOutputChannelLayout(&output_channel_layout);
+ 		auto ret = m_converter->Init();
+ 		if (ret != 0) {
+ 			SetError("Could not create an audio converter instance", ret);
+@@ -203,10 +203,11 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		}
+ 	}
+
++	av_channel_layout_uninit(&output_channel_layout);
++
+ 	m_opened = true;
+-	m_finished = false;
+-	m_got_frame = 0;
+-	m_nb_packets = 0;
++	m_has_more_packets = true;
++	m_has_more_frames = true;
+ 	m_decode_error = 0;
+
+ 	return true;
+@@ -214,6 +215,7 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ inline void FFmpegAudioReader::Close() {
+ 	av_frame_free(&m_frame);
++	av_packet_free(&m_packet);
+
+ 	m_stream_index = -1;
+
+@@ -252,91 +254,98 @@ inline bool FFmpegAudioReader::Read(const int16_t **data, size_t *size) {
+ 		return false;
+ 	}
+
++	*data = nullptr;
++	*size = 0;
++
+ 	int ret;
++	bool needs_packet = false;
+ 	while (true) {
+-		while (m_packet.size <= 0) {
+-			av_packet_unref(&m_packet0);
+-			av_init_packet(&m_packet);
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			ret = av_read_frame(m_format_ctx, &m_packet);
++		while (needs_packet && m_packet->size == 0) {
++			ret = av_read_frame(m_format_ctx, m_packet);
+ 			if (ret < 0) {
+ 				if (ret == AVERROR_EOF) {
+-					m_finished = true;
++					needs_packet = false;
++					m_has_more_packets = false;
+ 					break;
+-				} else {
++				}
++				SetError("Error reading from the audio source", ret);
++				return false;
++			}
++			if (m_packet->stream_index == m_stream_index) {
++				needs_packet = false;
++			} else {
++				av_packet_unref(m_packet);
++			}
++		}
++
++		if (m_packet->size != 0) {
++			ret = avcodec_send_packet(m_codec_ctx, m_packet);
++			if (ret < 0) {
++				if (ret != AVERROR(EAGAIN)) {
+ 					SetError("Error reading from the audio source", ret);
+ 					return false;
+ 				}
+-			}
+-			m_packet0 = m_packet;
+-			if (m_packet.stream_index != m_stream_index) {
+-				m_packet.data = nullptr;
+-				m_packet.size = 0;
+ 			} else {
+-				m_nb_packets++;
++				av_packet_unref(m_packet);
+ 			}
+ 		}
+
+-		ret = avcodec_decode_audio4(m_codec_ctx, m_frame, &m_got_frame, &m_packet);
++		ret = avcodec_receive_frame(m_codec_ctx, m_frame);
+ 		if (ret < 0) {
+-			if (m_decode_error) {
+-				SetError("Error decoding audio frame", m_decode_error);
+-				return false;
++			if (ret == AVERROR_EOF) {
++				m_has_more_frames = false;
++			} else if (ret == AVERROR(EAGAIN)) {
++				if (m_has_more_packets) {
++					needs_packet = true;
++					continue;
++				} else {
++					m_has_more_frames = false;
++				}
+ 			}
+-			m_decode_error = ret;
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			continue;
++			SetError("Error decoding the audio source", ret);
++			return false;
+ 		}
+
+-		break;
+-	}
+-
+-	m_decode_error = 0;
+-
+-	const int decoded = std::min(ret, m_packet.size);
+-	m_packet.data += decoded;
+-	m_packet.size -= decoded;
+-
+-	if (m_got_frame) {
+-		if (m_converter) {
+-			if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
+-				int linsize;
+-				av_freep(&m_convert_buffer[0]);
+-				m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
+-				ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
+-				if (ret < 0) {
+-					SetError("Couldn't allocate audio converter buffer", ret);
++		if (m_frame->nb_samples > 0) {
++			if (m_converter) {
++				if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
++					int linsize;
++					av_freep(&m_convert_buffer[0]);
++					m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
++					ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->ch_layout.nb_channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
++					if (ret < 0) {
++						SetError("Couldn't allocate audio converter buffer", ret);
++						return false;
++					}
++				}
++				auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
++				if (nb_samples < 0) {
++					SetError("Couldn't convert audio", ret);
+ 					return false;
+ 				}
+-			}
+-			auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			}
+-			*data = (const int16_t *) m_convert_buffer[0];
+-			*size = nb_samples;
+-		} else {
+-			*data = (const int16_t *) m_frame->data[0];
+-			*size = m_frame->nb_samples;
+-		}
+-	} else {
+-		if (m_finished && m_converter) {
+-			auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			} else if (nb_samples > 0) {
+-				m_got_frame = 1;
+ 				*data = (const int16_t *) m_convert_buffer[0];
+ 				*size = nb_samples;
++			} else {
++				*data = (const int16_t *) m_frame->data[0];
++				*size = m_frame->nb_samples;
++			}
++		} else {
++			if (m_converter) {
++				if (IsFinished()) {
++					auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
++					if (nb_samples < 0) {
++						SetError("Couldn't convert audio", ret);
++						return false;
++					} else if (nb_samples > 0) {
++						*data = (const int16_t *) m_convert_buffer[0];
++						*size = nb_samples;
++					}
++				}
+ 			}
+ 		}
+-	}
+
+-	return true;
++		return true;
++	}
+ }
+
+ inline void FFmpegAudioReader::SetError(const char *message, int errnum) {
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index a2b517b..123e643 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -38,6 +38,12 @@ set(SRCS
+
+ if(BUILD_TOOLS)
+ 	set(SRCS ${SRCS} ../src/audio/ffmpeg_audio_reader_test.cpp)
++    include_directories(
++        ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}
++        ${AUDIO_PROCESSOR_INCLUDE_DIRS}
++    )
+ 	link_libraries(fpcalc_libs)
+ endif()
+
+-- 
+2.38.1
+
+
diff --git a/srcpkgs/chromaprint/template b/srcpkgs/chromaprint/template
index 7ef7838949f3a..1f7bbc70a22c8 100644
--- a/srcpkgs/chromaprint/template
+++ b/srcpkgs/chromaprint/template
@@ -1,7 +1,7 @@
 # Template file for 'chromaprint'
 pkgname=chromaprint
 version=1.5.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DBUILD_TOOLS=ON"
 make_check_target="check"

From 3357d70e5835d1bb57a7226454d27306c9f8aa1c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 022/114] chromium: revbump for ffmpeg-6.0

---
 .../patches/chromium-119-ffmpeg-4.4.patch     | 20 --------
 srcpkgs/chromium/patches/ffmpeg5.patch        | 47 +++++++++++++++++++
 srcpkgs/chromium/template                     |  2 +-
 3 files changed, 48 insertions(+), 21 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch
 create mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch b/srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch
deleted file mode 100644
index 04d04b166ba37..0000000000000
--- a/srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch
+++ /dev/null
@@ -1,20 +0,0 @@
---- a/media/filters/ffmpeg_demuxer.cc.orig
-+++ b/media/filters/ffmpeg_demuxer.cc
-@@ -390,7 +390,7 @@
- 
-   scoped_refptr<DecoderBuffer> buffer;
- 
--    size_t side_data_size = 0;
-+    int side_data_size = 0;
-     uint8_t* side_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
- 
-@@ -453,7 +453,7 @@
-                                        packet->size - data_offset);
-     }
- 
--    size_t skip_samples_size = 0;
-+    int skip_samples_size = 0;
-     const uint32_t* skip_samples_ptr =
-         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
-             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..24e2da38e34ca
--- /dev/null
+++ b/srcpkgs/chromium/patches/ffmpeg5.patch
@@ -0,0 +1,47 @@
+--- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
++++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
+@@ -92,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+-  if (stream->start_time != kNoFFmpegTimestamp)
++  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -1597,7 +1585,7 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+@@ -1618,7 +1606,7 @@
+     if (stream->type() != DemuxerStream::VIDEO)
+       continue;
+ 
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+ 
+     if (!stream->IsEnabled())
diff --git a/srcpkgs/chromium/template b/srcpkgs/chromium/template
index b023946f3ec7b..fe36a6dce20d3 100644
--- a/srcpkgs/chromium/template
+++ b/srcpkgs/chromium/template
@@ -2,7 +2,7 @@
 pkgname=chromium
 # See https://chromiumdash.appspot.com/releases?platform=Linux for the latest version
 version=119.0.6045.105
-revision=3
+revision=4
 archs="i686* x86_64* aarch64* armv7l*"
 hostmakedepends="
  $(vopt_if clang "clang lld llvm15")

From 56426489424c9b98066ff9b00465f361c293e9be Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 023/114] cmus: revbump for ffmpeg-6.0

---
 srcpkgs/chromium/patches/ffmpeg5.patch | 47 --------------------------
 srcpkgs/cmus/patches/ffmpeg6.patch     | 12 +++++++
 srcpkgs/cmus/template                  |  2 +-
 3 files changed, 13 insertions(+), 48 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch
 create mode 100644 srcpkgs/cmus/patches/ffmpeg6.patch

diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
deleted file mode 100644
index 24e2da38e34ca..0000000000000
--- a/srcpkgs/chromium/patches/ffmpeg5.patch
+++ /dev/null
@@ -1,47 +0,0 @@
---- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
-+++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
-@@ -92,24 +92,12 @@
- 
- static base::TimeDelta ExtractStartTime(AVStream* stream) {
-   // The default start time is zero.
--  base::TimeDelta start_time;
-+  base::TimeDelta start_time = kNoTimestamp;
- 
-   // First try to use  the |start_time| value as is.
--  if (stream->start_time != kNoFFmpegTimestamp)
-+  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
-     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
- 
--  // Next try to use the first DTS value, for codecs where we know PTS == DTS
--  // (excludes all H26x codecs). The start time must be returned in PTS.
--  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
--      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
--      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
--      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
--    const base::TimeDelta first_pts =
--        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
--    if (first_pts < start_time)
--      start_time = first_pts;
--  }
--
-   return start_time;
- }
- 
-@@ -1597,7 +1585,7 @@
-   for (const auto& stream : streams_) {
-     if (!stream || stream->IsEnabled() != enabled)
-       continue;
--    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
-+    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
-       continue;
-     if (!lowest_start_time_stream ||
-         stream->start_time() < lowest_start_time_stream->start_time()) {
-@@ -1618,7 +1606,7 @@
-     if (stream->type() != DemuxerStream::VIDEO)
-       continue;
- 
--    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
-+    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
-       continue;
- 
-     if (!stream->IsEnabled())
diff --git a/srcpkgs/cmus/patches/ffmpeg6.patch b/srcpkgs/cmus/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..ffa95ab811101
--- /dev/null
+++ b/srcpkgs/cmus/patches/ffmpeg6.patch
@@ -0,0 +1,12 @@
+--- a/ip/ffmpeg.c
++++ b/ip/ffmpeg.c
+@@ -202,9 +202,6 @@ static int ffmpeg_open(struct input_plugin_data *ip_data)
+ 			break;
+ 		}
+ 
+-		if (codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+-			cc->flags |= AV_CODEC_FLAG_TRUNCATED;
+-
+ 		if (avcodec_open2(cc, codec, NULL) < 0) {
+ 			d_print("could not open codec: %d, %s\n", cc->codec_id, avcodec_get_name(cc->codec_id));
+ 			err = -IP_ERROR_UNSUPPORTED_FILE_TYPE;
diff --git a/srcpkgs/cmus/template b/srcpkgs/cmus/template
index 0d1436744f1b2..a6e4b4fa86cb8 100644
--- a/srcpkgs/cmus/template
+++ b/srcpkgs/cmus/template
@@ -1,7 +1,7 @@
 # Template file for 'cmus'
 pkgname=cmus
 version=2.10.0
-revision=3
+revision=4
 build_style=configure
 configure_args="prefix=/usr LD=$CC"
 hostmakedepends="pkg-config"

From fc71370ad5f67e1f74d9415ac334fb14c5380d5c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 024/114] cyanrip: revbump for ffmpeg-6.0

---
 srcpkgs/cyanrip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cyanrip/template b/srcpkgs/cyanrip/template
index 9796e3461601a..5db30e020d17e 100644
--- a/srcpkgs/cyanrip/template
+++ b/srcpkgs/cyanrip/template
@@ -1,7 +1,7 @@
 # Template file for 'cyanrip'
 pkgname=cyanrip
 version=0.9.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config"
 makedepends="ffmpeg-devel libcdio-devel libcdio-paranoia-devel libcurl-devel libmusicbrainz5-devel"

From fc75e509e6c6be8aca686bcc8610bb99603203a2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 025/114] deadbeef: revbump for ffmpeg4-4.4.3

---
 srcpkgs/deadbeef/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/deadbeef/template b/srcpkgs/deadbeef/template
index f5f4bf24b8cb6..7b47e615cd48e 100644
--- a/srcpkgs/deadbeef/template
+++ b/srcpkgs/deadbeef/template
@@ -1,14 +1,14 @@
 # Template file for 'deadbeef'
 pkgname=deadbeef
 version=1.8.8
-revision=3
+revision=4
 create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-oss --disable-lfm --disable-notify --disable-gtk2"
 hostmakedepends="automake libtool gettext gettext-devel intltool pkg-config
  yasm clang glib-devel"
 makedepends="
- alsa-lib-devel dbus-devel faad2-devel ffmpeg-devel gtk+3-devel imlib2-devel
+ alsa-lib-devel dbus-devel faad2-devel ffmpeg4-devel gtk+3-devel imlib2-devel
  jansson-devel libcddb-devel libcdio-devel libcurl-devel libflac-devel
  libmad-devel libpng-devel libsamplerate-devel libsndfile-devel libvorbis-devel
  libzip-devel mpg123-devel opusfile-devel pulseaudio-devel wavpack-devel"

From 663407b425625ea64aac3ad22fdc91a0909e29f4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 026/114] droidcam-obs-plugin: revbump for ffmpeg-6.0

---
 srcpkgs/droidcam-obs-plugin/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam-obs-plugin/template b/srcpkgs/droidcam-obs-plugin/template
index fc9c9bf6b9d54..fb0480754df4d 100644
--- a/srcpkgs/droidcam-obs-plugin/template
+++ b/srcpkgs/droidcam-obs-plugin/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam-obs-plugin'
 pkgname=droidcam-obs-plugin
 version=2.0.1
-revision=1
+revision=2
 build_style=gnu-makefile
 make_use_env=yes
 make_build_args="ALLOW_STATIC=no"

From e9f6dbcbde0b5c6e2fe17ea84079b01725afb5fa Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 027/114] droidcam: revbump for ffmpeg-6.0

---
 srcpkgs/droidcam/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam/template b/srcpkgs/droidcam/template
index 1c3f1b8b1fc67..32a9220b79a4d 100644
--- a/srcpkgs/droidcam/template
+++ b/srcpkgs/droidcam/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam'
 pkgname=droidcam
 version=1.8.2
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="USBMUXD=-lusbmuxd-2.0 JPEG=-lturbojpeg"
 hostmakedepends="pkg-config"

From 853ee6d1a48ea1abeec02af14dafe789999edc19 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 028/114] ffmpegthumbnailer: revbump for ffmpeg-6.0

---
 .../ffmpegthumbnailer/patches/ffmpeg6.patch   | 202 ++++++++++++++++++
 srcpkgs/ffmpegthumbnailer/template            |   6 +-
 2 files changed, 205 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch

diff --git a/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..363ff35a28419
--- /dev/null
+++ b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
@@ -0,0 +1,202 @@
+--- a/libffmpegthumbnailer/moviedecoder.cpp	2017-11-21 14:06:57.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.cpp	2023-05-05 13:14:47.946560668 -0400
+@@ -41,11 +41,6 @@
+ namespace ffmpegthumbnailer
+ {
+ 
+-struct SilenceLogLevel
+-{
+-    SilenceLogLevel() { av_log_set_level(AV_LOG_QUIET); }
+-};
+-
+ MovieDecoder::MovieDecoder(AVFormatContext* pavContext)
+ : m_VideoStream(-1)
+ , m_pFormatContext(pavContext)
+@@ -70,8 +65,6 @@
+ 
+ void MovieDecoder::initialize(const string& filename, bool preferEmbeddedMetadata)
+ {
+-    av_register_all();
+-    avcodec_register_all();
+     avformat_network_init();
+ 
+     string inputFile = filename == "-" ? "pipe:" : filename;
+@@ -97,8 +90,7 @@
+ {
+     if (m_pVideoCodecContext)
+     {
+-        avcodec_close(m_pVideoCodecContext);
+-        m_pVideoCodecContext = nullptr;
++        avcodec_free_context(&m_pVideoCodecContext);
+     }
+ 
+     if ((!m_FormatContextWasGiven) && m_pFormatContext)
+@@ -152,10 +144,10 @@
+     for (unsigned int i = 0; i < m_pFormatContext->nb_streams; ++i)
+     {
+         AVStream *stream = m_pFormatContext->streams[i];
+-        auto ctx = m_pFormatContext->streams[i]->codec;
+-        if (ctx->codec_type == AVMEDIA_TYPE_VIDEO)
++        auto par = m_pFormatContext->streams[i]->codecpar;
++        if (par->codec_type == AVMEDIA_TYPE_VIDEO)
+         {
+-            if (!preferEmbeddedMetadata || !isStillImageCodec(ctx->codec_id))
++            if (!preferEmbeddedMetadata || !isStillImageCodec(par->codec_id))
+             {
+                 videoStreams.push_back(i);
+                 continue;
+@@ -203,8 +195,7 @@
+     }
+ 
+     m_pVideoStream = m_pFormatContext->streams[m_VideoStream];
+-    m_pVideoCodecContext = m_pVideoStream->codec;
+-    m_pVideoCodec = avcodec_find_decoder(m_pVideoCodecContext->codec_id);
++    m_pVideoCodec = avcodec_find_decoder(m_pVideoStream->codecpar->codec_id);
+ 
+     if (m_pVideoCodec == nullptr)
+     {
+@@ -214,6 +205,20 @@
+         throw logic_error("Video Codec not found");
+     }
+ 
++    m_pVideoCodecContext = avcodec_alloc_context3(m_pVideoCodec);
++
++    if (m_pVideoCodecContext == nullptr)
++    {
++        destroy();
++        throw logic_error("Could not allocate video codec context");
++    }
++
++    if (avcodec_parameters_to_context(m_pVideoCodecContext, m_pVideoStream->codecpar) < 0)
++    {
++        destroy();
++        throw logic_error("Could not configure video codec context");
++    }
++
+     m_pVideoCodecContext->workaround_bugs = 1;
+ 
+     if (avcodec_open2(m_pVideoCodecContext, m_pVideoCodec, nullptr) < 0)
+@@ -386,13 +391,6 @@
+ 
+ void MovieDecoder::initializeFilterGraph(const AVRational& timeBase, const std::string& size, bool maintainAspectRatio)
+ {
+-    static const AVPixelFormat pixelFormats[] = { AV_PIX_FMT_RGB24, AV_PIX_FMT_NONE };
+-
+-    auto del = [] (AVBufferSinkParams* p) { av_freep(p); };
+-    std::unique_ptr<AVBufferSinkParams, decltype(del)> buffersinkParams(av_buffersink_params_alloc(), del);
+-
+-    avfilter_register_all();
+-
+     m_pFilterGraph = avfilter_graph_alloc();
+     assert(m_pFilterGraph);
+ 
+@@ -404,10 +402,8 @@
+ 
+     checkRc(avfilter_graph_create_filter(&m_pFilterSource, avfilter_get_by_name("buffer"), "thumb_buffer", ss.str().c_str(), nullptr, m_pFilterGraph),
+             "Failed to create filter source");
+-    buffersinkParams->pixel_fmts = pixelFormats;
+-    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, buffersinkParams.get(), m_pFilterGraph),
++    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, nullptr, m_pFilterGraph),
+             "Failed to create filter sink");
+-    buffersinkParams.release();
+ 
+     AVFilterContext* yadifFilter = nullptr;
+     if (m_pFrame->interlaced_frame != 0)
+@@ -500,15 +496,15 @@
+     }
+ 
+     checkRc(av_seek_frame(m_pFormatContext, -1, timestamp, 0), "Seeking in video failed");
+-    avcodec_flush_buffers(m_pFormatContext->streams[m_VideoStream]->codec);
++    avcodec_flush_buffers(m_pVideoCodecContext);
+ 
+     int keyFrameAttempts = 0;
+-    bool gotFrame = 0;
++    bool gotFrame;
+ 
+     do
+     {
+         int count = 0;
+-        gotFrame = 0;
++        gotFrame = false;
+ 
+         while (!gotFrame && count < 20)
+         {
+@@ -552,17 +548,33 @@
+         return false;
+     }
+ 
+-    av_frame_unref(m_pFrame);
+-
+-    int frameFinished;
++    int rc = avcodec_send_packet(m_pVideoCodecContext, m_pPacket);
++    if(rc == AVERROR(EAGAIN))
++    {
++        rc = 0;
++    }
+ 
+-    int bytesDecoded = avcodec_decode_video2(m_pVideoCodecContext, m_pFrame, &frameFinished, m_pPacket);
+-    if (bytesDecoded < 0)
++    if(rc == AVERROR_EOF)
++    {
++        return false;
++    }
++    else if(rc < 0)
+     {
+-        throw logic_error("Failed to decode video frame: bytesDecoded < 0");
++        throw logic_error("Failed to decode video frame: avcodec_send_packet() < 0");
+     }
+ 
+-    return frameFinished > 0;
++    rc = avcodec_receive_frame(m_pVideoCodecContext, m_pFrame);
++    switch(rc)
++    {
++        case 0:
++            return true;
++
++        case AVERROR(EAGAIN):
++            return false;
++
++        default:
++            throw logic_error("Failed to decode video frame: avcodec_receive_frame() < 0");
++    }
+ }
+ 
+ bool MovieDecoder::getVideoPacket()
+@@ -570,8 +582,6 @@
+     bool framesAvailable = true;
+     bool frameDecoded = false;
+ 
+-    int attempts = 0;
+-
+     if (m_pPacket)
+     {
+         av_packet_unref(m_pPacket);
+@@ -580,6 +590,7 @@
+ 
+     m_pPacket = new AVPacket();
+ 
++
+     while (framesAvailable && !frameDecoded)
+     {
+         framesAvailable = av_read_frame(m_pFormatContext, m_pPacket) >= 0;
+@@ -644,7 +655,7 @@
+ 
+ int32_t MovieDecoder::getStreamRotation()
+ {
+-    int32_t* matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
++    auto matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
+     if (matrix)
+     {
+         auto angle = lround(av_display_rotation_get(matrix));
+
+--- a/libffmpegthumbnailer/moviedecoder.h	2017-11-12 04:23:38.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.h	2023-05-05 13:26:07.095529911 -0400
+@@ -78,7 +78,7 @@
+     int                     m_VideoStream;
+     AVFormatContext*        m_pFormatContext;
+     AVCodecContext*         m_pVideoCodecContext;
+-    AVCodec*                m_pVideoCodec;
++    const AVCodec*          m_pVideoCodec;
+     AVFilterGraph*          m_pFilterGraph;
+     AVFilterContext*        m_pFilterSource;
+     AVFilterContext*        m_pFilterSink;
diff --git a/srcpkgs/ffmpegthumbnailer/template b/srcpkgs/ffmpegthumbnailer/template
index 039eea7622b39..35d546018d12a 100644
--- a/srcpkgs/ffmpegthumbnailer/template
+++ b/srcpkgs/ffmpegthumbnailer/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbnailer'
 pkgname=ffmpegthumbnailer
 version=2.2.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libpng-devel libjpeg-turbo-devel ffmpeg-devel"
@@ -9,8 +9,8 @@ depends="ffmpeg"
 short_desc="Lightweight video thumbnailer"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
-homepage="https://github.com/dirkvdb/${pkgname}"
-distfiles="${homepage}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
+homepage="https://github.com/dirkvdb"
+distfiles="${homepage}/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
 checksum=1cb24059c38223f657b300c84dd80491b7040d4b69471c4fea69be862bc99b5b
 
 post_install() {

From e9ae0c8f2e03a30c99e7e2e67f7b8a8a65f96255 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 029/114] ffmpegthumbs: revbump for ffmpeg-6.0

---
 srcpkgs/ffmpegthumbs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ffmpegthumbs/template b/srcpkgs/ffmpegthumbs/template
index 5f0b9414dadaf..11b88193528f4 100644
--- a/srcpkgs/ffmpegthumbs/template
+++ b/srcpkgs/ffmpegthumbs/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbs'
 pkgname=ffmpegthumbs
 version=22.12.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules kcoreaddons kconfig-devel
  pkg-config qt5-host-tools qt5-qmake gettext"

From dae8fc59b3f9e4d3bbff3f5c1449360577473a3d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 030/114] ffms2: revbump for ffmpeg-6.0

---
 srcpkgs/ffms2/patches/ffmpeg5.patch | 424 ++++++++++++++++++++++++++++
 srcpkgs/ffms2/template              |   2 +-
 2 files changed, 425 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ffms2/patches/ffmpeg5.patch

diff --git a/srcpkgs/ffms2/patches/ffmpeg5.patch b/srcpkgs/ffms2/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..1479fabcafcb4
--- /dev/null
+++ b/srcpkgs/ffms2/patches/ffmpeg5.patch
@@ -0,0 +1,424 @@
+From 45673149e9a2f5586855ad472e3059084eaa36b1 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:41:21 +0100
+Subject: [PATCH] Use auto for AVCodec
+
+The geniuses over at FFmpeg decided to constify this API, so old
+versions of the library will return AVCodec *, while new versions
+of the libary will return const AVCodec *, which, in C++, are not
+OK to convert between.
+
+Rather than use some macro hell in ffmscompat.h, we can work around
+this by using auto.
+
+Gross.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 2 +-
+ src/core/indexing.cpp    | 6 +++---
+ src/core/videosource.cpp | 2 +-
+ 3 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index e4ce97c..ac09666 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -469,7 +469,7 @@ void FFMS_AudioSource::OpenFile() {
+ 
+     LAVFOpenFile(SourceFile.c_str(), FormatContext, TrackNumber);
+ 
+-    AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
++    auto *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
+     if (Codec == nullptr)
+         throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+             "Audio codec not found");
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index e547c5a..59fb4e8 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -384,7 +384,7 @@ FFMS_TrackType FFMS_Indexer::GetTrackType(int Track) {
+ }
+ 
+ const char *FFMS_Indexer::GetTrackCodec(int Track) {
+-    AVCodec *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
++    auto *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
+     return codec ? codec->name : nullptr;
+ }
+ 
+@@ -402,7 +402,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             UseDTS);
+ 
+         if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            AVCodec *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (!VideoCodec) {
+                 FormatContext->streams[i]->discard = AVDISCARD_ALL;
+                 IndexMask.erase(i);
+@@ -433,7 +433,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 IndexMask.insert(i);
+             }
+         } else if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+-            AVCodec *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (AudioCodec == nullptr)
+                 throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_UNSUPPORTED,
+                     "Audio codec not found");
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index b889970..8956c22 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -171,7 +171,7 @@ FFMS_VideoSource::FFMS_VideoSource(const char *SourceFile, FFMS_Index &Index, in
+ 
+         LAVFOpenFile(SourceFile, FormatContext, VideoTrack);
+ 
+-        AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
++        auto *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
+         if (Codec == nullptr)
+             throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+                 "Video codec not found");
+-- 
+2.40.0
+
+From 96cbf38ea9381829a1314f432a2c60495dcefaad Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:12:41 +0100
+Subject: [PATCH] all: Update AVPacket API usage
+
+AVPackets must all be on the heap now, since it is no longer
+part of the libav* ABI.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 16 ++++++----
+ src/core/indexing.cpp    | 63 ++++++++++++++++++++++------------------
+ src/core/indexing.h      |  4 +--
+ src/core/utils.cpp       |  6 ----
+ src/core/utils.h         |  1 -
+ src/core/videosource.cpp | 30 ++++++++++---------
+ 6 files changed, 64 insertions(+), 56 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index 37cf9ae..e4ce97c 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -285,10 +285,15 @@ FFMS_AudioSource::AudioBlock *FFMS_AudioSource::CacheBlock(CacheIterator &pos) {
+ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     CurrentFrame = &Frames[PacketNumber];
+ 
+-    AVPacket Packet;
+-    if (!ReadPacket(&Packet))
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++    if (!ReadPacket(Packet)) {
++        av_packet_free(&Packet);
+         throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_UNKNOWN,
+             "ReadPacket unexpectedly failed to read a packet");
++    }
+ 
+     // ReadPacket may have changed the packet number
+     CurrentFrame = &Frames[PacketNumber];
+@@ -297,8 +302,9 @@ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     int NumberOfSamples = 0;
+     AudioBlock *CachedBlock = nullptr;
+     
+-    int Ret = avcodec_send_packet(CodecContext, &Packet);
+-    av_packet_unref(&Packet);
++    int Ret = avcodec_send_packet(CodecContext, Packet);
++    av_packet_unref(Packet);
++    av_packet_free(&Packet);
+ 
+     av_frame_unref(DecodeFrame);
+     Ret = avcodec_receive_frame(CodecContext, DecodeFrame);
+@@ -513,8 +519,6 @@ void FFMS_AudioSource::Seek() {
+ }
+ 
+ bool FFMS_AudioSource::ReadPacket(AVPacket *Packet) {
+-    InitNullPacket(*Packet);
+-
+     while (av_read_frame(FormatContext, Packet) >= 0) {
+         if (Packet->stream_index == TrackNumber) {
+             // Required because not all audio packets, especially in ogg, have a pts. Use the previous valid packet's pts instead.
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index 23fb95b..e547c5a 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -320,7 +320,7 @@ void FFMS_Indexer::CheckAudioProperties(int Track, AVCodecContext *Context) {
+     }
+ }
+ 
+-void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict,
++void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict,
+                                     int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct) {
+     if (VideoContext.Parser) {
+         uint8_t *OB;
+@@ -330,8 +330,8 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+         av_parser_parse2(VideoContext.Parser,
+             VideoContext.CodecContext,
+             &OB, &OBSize,
+-            pkt.data, pkt.size,
+-            pkt.pts, pkt.dts, pkt.pos);
++            pkt->data, pkt->size,
++            pkt->pts, pkt->dts, pkt->pos);
+ 
+         // H.264 (PAFF) and HEVC may have one field per packet, so we need to track
+         // when we have a full or half frame available, and mark one of them as
+@@ -351,15 +351,15 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+ 
+         *RepeatPict = VideoContext.Parser->repeat_pict;
+         *FrameType = VideoContext.Parser->pict_type;
+-        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt.flags & AV_PKT_FLAG_DISCARD));
++        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt->flags & AV_PKT_FLAG_DISCARD));
+     } else {
+-        *Invisible = !!(pkt.flags & AV_PKT_FLAG_DISCARD);
++        *Invisible = !!(pkt->flags & AV_PKT_FLAG_DISCARD);
+     }
+ 
+     if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP8)
+-        ParseVP8(pkt.data[0], Invisible, FrameType);
++        ParseVP8(pkt->data[0], Invisible, FrameType);
+     else if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP9)
+-        ParseVP9(pkt.data[0], Invisible, FrameType);
++        ParseVP9(pkt->data[0], Invisible, FrameType);
+ }
+ 
+ void FFMS_Indexer::Free() {
+@@ -458,32 +458,36 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+         }
+     }
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
+     std::vector<int64_t> LastValidTS(FormatContext->nb_streams, AV_NOPTS_VALUE);
+ 
+     int64_t filesize = avio_size(FormatContext->pb);
+     enum AVPictureStructure LastPicStruct = AV_PICTURE_STRUCTURE_UNKNOWN;
+-    while (av_read_frame(FormatContext, &Packet) >= 0) {
++    while (av_read_frame(FormatContext, Packet) >= 0) {
+         // Update progress
+         // FormatContext->pb can apparently be NULL when opening images.
+         if (IC && FormatContext->pb) {
+-            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate))
++            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate)) {
++                av_packet_free(&Packet);
+                 throw FFMS_Exception(FFMS_ERROR_CANCELLED, FFMS_ERROR_USER,
+                     "Cancelled by user");
++            }
+         }
+-        if (!IndexMask.count(Packet.stream_index)) {
+-            av_packet_unref(&Packet);
++        if (!IndexMask.count(Packet->stream_index)) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+-        int Track = Packet.stream_index;
++        int Track = Packet->stream_index;
+         FFMS_Track &TrackInfo = (*TrackIndices)[Track];
+-        bool KeyFrame = !!(Packet.flags & AV_PKT_FLAG_KEY);
++        bool KeyFrame = !!(Packet->flags & AV_PKT_FLAG_KEY);
+         ReadTS(Packet, LastValidTS[Track], (*TrackIndices)[Track].UseDTS);
+ 
+         if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            int64_t PTS = TrackInfo.UseDTS ? Packet.dts : Packet.pts;
++            int64_t PTS = TrackInfo.UseDTS ? Packet->dts : Packet->pts;
+             if (PTS == AV_NOPTS_VALUE) {
+                 // VPx alt-refs are output as packets which lack timestmps or durations, since
+                 // they are invisible. Currently, the timestamp mangling code in libavformat
+@@ -495,9 +499,11 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 // FFMS2 currently sorts packets by PTS, which will break decoding, otherwise.
+                 bool HasAltRefs = (FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP8 ||
+                                    FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP9);
+-                if (Packet.duration == 0 && !HasAltRefs)
++                if (Packet->duration == 0 && !HasAltRefs) {
++                    av_packet_free(&Packet);
+                     throw FFMS_Exception(FFMS_ERROR_INDEXING, FFMS_ERROR_PARSER,
+                         "Invalid packet pts, dts, and duration");
++                }
+ 
+                 if (TrackInfo.empty())
+                     PTS = 0;
+@@ -513,7 +519,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             ParseVideoPacket(AVContexts[Track], Packet, &RepeatPict, &FrameType, &Invisible, &LastPicStruct);
+ 
+             TrackInfo.AddVideoFrame(PTS, RepeatPict, KeyFrame,
+-                FrameType, Packet.pos, Invisible);
++                FrameType, Packet->pos, Invisible);
+         } else if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+             // For video seeking timestamps are used only if all packets have
+             // timestamps, while for audio they're used if any have timestamps,
+@@ -522,28 +528,29 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 TrackInfo.HasTS = true;
+ 
+             int64_t StartSample = AVContexts[Track].CurrentSample;
+-            uint32_t SampleCount = IndexAudioPacket(Track, &Packet, AVContexts[Track], *TrackIndices);
++            uint32_t SampleCount = IndexAudioPacket(Track, Packet, AVContexts[Track], *TrackIndices);
+             TrackInfo.SampleRate = AVContexts[Track].CodecContext->sample_rate;
+ 
+             TrackInfo.AddAudioFrame(LastValidTS[Track],
+-                StartSample, SampleCount, KeyFrame, Packet.pos, Packet.flags & AV_PKT_FLAG_DISCARD);
++                StartSample, SampleCount, KeyFrame, Packet->pos, Packet->flags & AV_PKT_FLAG_DISCARD);
+         }
+ 
+-        if (!(Packet.flags & AV_PKT_FLAG_DISCARD))
+-            TrackInfo.LastDuration = Packet.duration;
++        if (!(Packet->flags & AV_PKT_FLAG_DISCARD))
++            TrackInfo.LastDuration = Packet->duration;
+ 
+-        av_packet_unref(&Packet);
++        av_packet_unref(Packet);
+     }
++    av_packet_free(&Packet);
+ 
+     TrackIndices->Finalize(AVContexts, FormatContext->iformat->name);
+     return TrackIndices.release();
+ }
+ 
+-void FFMS_Indexer::ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS) {
+-    if (!UseDTS && Packet.pts != AV_NOPTS_VALUE)
+-        TS = Packet.pts;
++void FFMS_Indexer::ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS) {
++    if (!UseDTS && Packet->pts != AV_NOPTS_VALUE)
++        TS = Packet->pts;
+     if (TS == AV_NOPTS_VALUE)
+         UseDTS = true;
+-    if (UseDTS && Packet.dts != AV_NOPTS_VALUE)
+-        TS = Packet.dts;
++    if (UseDTS && Packet->dts != AV_NOPTS_VALUE)
++        TS = Packet->dts;
+ }
+diff --git a/src/core/indexing.h b/src/core/indexing.h
+index 3cfc3c3..5c06868 100644
+--- a/src/core/indexing.h
++++ b/src/core/indexing.h
+@@ -80,10 +80,10 @@ private:
+     int64_t Filesize;
+     uint8_t Digest[20];
+ 
+-    void ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS);
++    void ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS);
+     void CheckAudioProperties(int Track, AVCodecContext *Context);
+     uint32_t IndexAudioPacket(int Track, AVPacket *Packet, SharedAVContext &Context, FFMS_Index &TrackIndices);
+-    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
++    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
+     void Free();
+ public:
+     FFMS_Indexer(const char *Filename);
+diff --git a/src/core/utils.cpp b/src/core/utils.cpp
+index ce67533..8a2e997 100644
+--- a/src/core/utils.cpp
++++ b/src/core/utils.cpp
+@@ -62,12 +62,6 @@ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo) {
+     }
+ }
+ 
+-void InitNullPacket(AVPacket &pkt) {
+-    av_init_packet(&pkt);
+-    pkt.data = nullptr;
+-    pkt.size = 0;
+-}
+-
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames) {
+     AP.SampleFormat = static_cast<FFMS_SampleFormat>(av_get_packed_sample_fmt(CTX->sample_fmt));
+     AP.BitsPerSample = av_get_bytes_per_sample(CTX->sample_fmt) * 8;
+diff --git a/src/core/utils.h b/src/core/utils.h
+index 9819dc7..003ab79 100644
+--- a/src/core/utils.h
++++ b/src/core/utils.h
+@@ -58,7 +58,6 @@ std::unique_ptr<T> make_unique(Args&&... args) {
+ }
+ 
+ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo);
+-void InitNullPacket(AVPacket &pkt);
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames);
+ 
+ void LAVFOpenFile(const char *SourceFile, AVFormatContext *&FormatContext, int Track);
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index 06bd161..b889970 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -673,30 +673,34 @@ void FFMS_VideoSource::DecodeNextFrame(int64_t &AStartTime, int64_t &Pos) {
+     if (HasPendingDelayedFrames())
+         return;
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
+-
+-    while (ReadFrame(&Packet) >= 0) {
+-        if (Packet.stream_index != VideoTrack) {
+-            av_packet_unref(&Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++
++    while (ReadFrame(Packet) >= 0) {
++        if (Packet->stream_index != VideoTrack) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+         if (AStartTime < 0)
+-            AStartTime = Frames.UseDTS ? Packet.dts : Packet.pts;
++            AStartTime = Frames.UseDTS ? Packet->dts : Packet->pts;
+ 
+         if (Pos < 0)
+-            Pos = Packet.pos;
++            Pos = Packet->pos;
+ 
+-        bool FrameFinished = DecodePacket(&Packet);
+-        av_packet_unref(&Packet);
+-        if (FrameFinished)
++        bool FrameFinished = DecodePacket(Packet);
++        av_packet_unref(Packet);
++        if (FrameFinished) {
++            av_packet_free(&Packet);
+             return;
++        }
+     }
+ 
+     // Flush final frames
+-    InitNullPacket(Packet);
+-    DecodePacket(&Packet);
++    DecodePacket(Packet);
++    av_packet_free(&Packet);
+ }
+ 
+ bool FFMS_VideoSource::SeekTo(int n, int SeekOffset) {
+-- 
+2.40.0
+
+From bf9e03e9e08534c024e5a744a6437c4aac160201 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:20:47 +0100
+Subject: [PATCH 2/3] configure: Remove deprecated API use
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ configure.ac | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index b35ef80bc..d19714d0f 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -102,10 +102,10 @@ CFLAGS="$_CFLAGS $FFMPEG_CFLAGS"
+
+ AC_DEFUN([TEST_FFMPEG],
+          [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+-            #include <libavcodec/avcodec.h>
++            #include <libavformat/avformat.h>
+             #include <libswscale/swscale.h>
+             ]],[[
+-                avcodec_register_all();
++                avformat_network_init();
+                 swscale_version();
+             ]])], [eval $1=yes], [eval $1=no])
+         ])
+
diff --git a/srcpkgs/ffms2/template b/srcpkgs/ffms2/template
index 365f64d10cbab..1641ecf43be5b 100644
--- a/srcpkgs/ffms2/template
+++ b/srcpkgs/ffms2/template
@@ -1,7 +1,7 @@
 # Template file for 'ffms2'
 pkgname=ffms2
 version=2.40
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-shared --disable-static"
 hostmakedepends="pkg-config autoconf automake libtool"

From b9460f28a948820677b75e96e3bb8d600c11ad7d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 031/114] freerdp: revbump for ffmpeg-6.0

---
 .../freerdp/patches/ffmpeg6_aa2cb9aa.patch    | 42 +++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100644 srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch

diff --git a/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
new file mode 100644
index 0000000000000..a4324da3a8822
--- /dev/null
+++ b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
@@ -0,0 +1,42 @@
+From aa2cb9aa5ff5562433598ba168a466e0752bca0e Mon Sep 17 00:00:00 2001
+From: akallabeth <akallabeth@posteo.net>
+Date: Tue, 14 Feb 2023 07:48:54 +0100
+Subject: [PATCH] Fixed #8686: Update h264 to use new FFMPEG API
+
+---
+ channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c | 2 ++
+ libfreerdp/codec/h264_ffmpeg.c            | 2 ++
+ 2 files changed, 4 insertions(+)
+
+diff --git a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+index 339462d865f..beea80b7a1e 100644
+--- a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
++++ b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+@@ -239,8 +239,10 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYP
+ 		}
+ 	}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 	if (mdecoder->codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		mdecoder->codec_context->flags |= AV_CODEC_FLAG_TRUNCATED;
++#endif
+ 
+ 	return TRUE;
+ }
+diff --git a/libfreerdp/codec/h264_ffmpeg.c b/libfreerdp/codec/h264_ffmpeg.c
+index 8a23db2473c..896a333019b 100644
+--- a/libfreerdp/codec/h264_ffmpeg.c
++++ b/libfreerdp/codec/h264_ffmpeg.c
+@@ -615,10 +615,12 @@ static BOOL libavcodec_init(H264_CONTEXT* h264)
+ 			goto EXCEPTION;
+ 		}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 		if (sys->codecDecoder->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		{
+ 			sys->codecDecoderContext->flags |= AV_CODEC_FLAG_TRUNCATED;
+ 		}
++#endif
+ 
+ #ifdef WITH_VAAPI
+ 

From eed6b09f40e39098aec384ab6accc35368cecce2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 032/114] gerbera: revbump for ffmpeg-6.0

---
 srcpkgs/gerbera/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gerbera/template b/srcpkgs/gerbera/template
index ae14f35c767c0..2dc0ac0ce03b5 100644
--- a/srcpkgs/gerbera/template
+++ b/srcpkgs/gerbera/template
@@ -1,7 +1,7 @@
 # Template file for 'gerbera'
 pkgname=gerbera
 version=1.12.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_SYSTEMD=0 -DWITH_AVCODEC=1"
 hostmakedepends="pkg-config"

From 191e2ef0642f0fc806607a3855681938a7f41ff1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 033/114] goldendict: revbump for ffmpeg-6.0

---
 srcpkgs/goldendict/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/goldendict/template b/srcpkgs/goldendict/template
index f4a05759f693d..97f44347b03a6 100644
--- a/srcpkgs/goldendict/template
+++ b/srcpkgs/goldendict/template
@@ -1,7 +1,7 @@
 # Template file for 'goldendict'
 pkgname=goldendict
 version=1.5.0
-revision=1
+revision=2
 build_style=qmake
 configure_args="CONFIG+=zim_support goldendict.pro"
 hostmakedepends="qt5-qmake pkg-config qt5-host-tools"
@@ -10,7 +10,7 @@ makedepends="tiff-devel qt5-devel libvorbis-devel zlib-devel
  qt5-webkit-devel lzo-devel bzip2-devel libao-devel qt5-svg-devel
  libeb-devel qt5-x11extras-devel ffmpeg-devel liblzma-devel
  qt5-multimedia-devel"
-short_desc="A feature-rich dictionary lookup program"
+short_desc="Feature-rich dictionary lookup program"
 maintainer="John <me@johnnynator.dev>"
 license="GPL-3.0-or-later"
 homepage="http://goldendict.org/"

From 7dae794ac9a7b246a6d1a9450af40664935a6124 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 034/114] gst-libav: revbump for ffmpeg-6.0

---
 srcpkgs/gst-libav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index 78afeee4aefb2..f892eb2063564 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.22.7
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"

From dd497c7c0fe05e2021e0dc70e8a7830044db0572 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 035/114] gst-rtsp-server: revbump for ffmpeg-6.0

---
 srcpkgs/gst-rtsp-server/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index 2c280c84f1514..83a2949fd9482 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
 version=1.22.7
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="glib-devel gst-plugins-bad1-devel gobject-introspection

From dc4d1a38900f49110adccf12f601557a1b492fb5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 036/114] guvcview: update to 2.0.8.

---
 srcpkgs/guvcview/patches/fix-include.patch | 10 ++++++++++
 srcpkgs/guvcview/template                  |  7 +++----
 2 files changed, 13 insertions(+), 4 deletions(-)
 create mode 100644 srcpkgs/guvcview/patches/fix-include.patch

diff --git a/srcpkgs/guvcview/patches/fix-include.patch b/srcpkgs/guvcview/patches/fix-include.patch
new file mode 100644
index 0000000000000..503c2af3b78c1
--- /dev/null
+++ b/srcpkgs/guvcview/patches/fix-include.patch
@@ -0,0 +1,10 @@
+--- a/guvcview/guvcview.c
++++ b/guvcview/guvcview.c
+@@ -28,6 +28,7 @@
+ #include <sys/stat.h>
+ #include <sys/resource.h>
+ #include <errno.h>
++#include <locale.h>
+ 
+ #include "gview.h"
+ #include "gviewv4l2core.h"
diff --git a/srcpkgs/guvcview/template b/srcpkgs/guvcview/template
index d42fd38fa4ad1..86a7fd619612c 100644
--- a/srcpkgs/guvcview/template
+++ b/srcpkgs/guvcview/template
@@ -1,8 +1,7 @@
 # Template file for 'guvcview'
 pkgname=guvcview
-version=2.0.7
-revision=2
-create_wrksrc=yes
+version=2.0.8
+revision=1
 build_style=gnu-configure
 configure_args="--disable-static --disable-debian-menu"
 hostmakedepends="pkg-config intltool autoconf automake libtool glib-devel"
@@ -14,7 +13,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="http://guvcview.sourceforge.net/"
 distfiles="${SOURCEFORGE_SITE}/${pkgname}/${pkgname}-src-${version}.tar.bz2"
-checksum=f47d51fbd06e44eeaa1a82f4a153c927527c90d94514197a70b2956028cc8ad4
+checksum=a21f4e448286666cf27bafef5290cc953a0a1796b752e5bbe521266dc1230c81
 
 post_patch() {
 	sed '31a#include <locale.h>' -i  guvcview/guvcview.c

From abd6e66524b21ae8828a6f87bf3e8f3c8b85d3ba Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 037/114] handbrake: update to 1.6.1

---
 .../patches/fix-missing-x265-link-flag.patch    | 11 ++++++-----
 .../handbrake/patches/libhb-vpl-include.patch   | 15 +++++++++++++++
 srcpkgs/handbrake/template                      | 17 ++++++++++-------
 3 files changed, 31 insertions(+), 12 deletions(-)
 create mode 100644 srcpkgs/handbrake/patches/libhb-vpl-include.patch

diff --git a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
index 26db03867a0c8..d6bb2eda627a3 100644
--- a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
+++ b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
@@ -1,14 +1,15 @@
 --- a/gtk/configure.ac
 +++ b/gtk/configure.ac
 @@ -203,7 +203,7 @@
- 
+
  AM_CONDITIONAL([MINGW], [test "x$mingw_flag" = "xyes"])
- 
--HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg"
-+HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -ldl"
+
+-HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc"
++HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc -ldl"
  HB_CPPFLAGS="$HB_CPPFLAGS $HBINC"
- 
+
  PKG_CHECK_MODULES([x264], [x264], sys_x264=yes, sys_x264=no)
+
 --- a/test/module.defs
 +++ b/test/module.defs
 @@ -69,6 +69,9 @@
diff --git a/srcpkgs/handbrake/patches/libhb-vpl-include.patch b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
new file mode 100644
index 0000000000000..298f9f4ab28f2
--- /dev/null
+++ b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
@@ -0,0 +1,15 @@
+--- a/libhb/module.defs	2023-01-22 11:36:49.000000000 -0500
++++ b/libhb/module.defs	2023-04-03 22:37:52.395467010 -0400
+@@ -46,11 +46,7 @@
+ LIBHB.GCC.I += $(LIBHB.build/) $(CONTRIB.build/)include
+ 
+ ifeq (1,$(FEATURE.qsv))
+-    ifeq ($(HOST.system),freebsd))
+-        LIBHB.GCC.I += $(LOCALBASE)/include/vpl
+-    else
+-        LIBHB.GCC.I += $(CONTRIB.build/)include/vpl
+-    endif
++    LIBHB.GCC.I += /usr/include/vpl
+ endif
+ 
+ ifneq (,$(filter $(HOST.system),freebsd netbsd openbsd))
diff --git a/srcpkgs/handbrake/template b/srcpkgs/handbrake/template
index ca5e4571e49c3..c32cb1bfa31f4 100644
--- a/srcpkgs/handbrake/template
+++ b/srcpkgs/handbrake/template
@@ -1,10 +1,10 @@
 # Template file for 'handbrake'
 pkgname=handbrake
-version=1.5.1
+version=1.6.1
 revision=1
 build_style=gnu-configure
 configure_args="--force --disable-gtk-update-checks --disable-df-fetch --harden
- $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc)"
+ $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc) $(vopt_enable qsv)"
 make_build_args="-C ${XBPS_TRIPLET}"
 make_install_args="-C ${XBPS_TRIPLET}"
 hostmakedepends="automake cmake gettext-devel glib-devel intltool libtool m4 meson nasm pkg-config python3"
@@ -12,8 +12,11 @@ makedepends="bzip2-devel ffmpeg-devel gst-plugins-base1-devel gtk+3-devel
  jansson-devel lame-devel libass-devel libbluray-devel libdav1d-devel
  libdvdnav-devel libdvdread-devel libgudev-devel libnuma-devel
  libsamplerate-devel libtheora-devel libvorbis-devel libvpx-devel libxml2-devel
- opus-devel speex-devel x264-devel x265-devel zimg-devel
+ opus-devel speex-devel x264-devel x265-devel zimg-devel libsvt-av1-devel
  $(vopt_if fdk_aac fdk-aac-devel)
+ $(vopt_if qsv libva-devel)
+ $(vopt_if qsv libdrm-devel)
+ $(vopt_if qsv onevpl-devel)
  $(vopt_if nvenc nv-codec-headers)"
 depends="desktop-file-utils gst-plugins-good1 hicolor-icon-theme"
 short_desc="Multithreaded video transcoder"
@@ -21,15 +24,15 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-2.0-only"
 homepage="https://handbrake.fr/"
 distfiles="https://github.com/HandBrake/HandBrake/releases/download/${version}/HandBrake-${version}-source.tar.bz2"
-checksum=3999fe06d5309c819799a73a968a8ec3840e7840c2b64af8f5cdb7fd8c9430f0
+checksum=94ccfe03db917a91650000c510f7fd53f844da19f19ad4b4be1b8f6bc31a8d4c
 nocross=yes
 
-build_options="fdk_aac nvenc"
+build_options="fdk_aac nvenc qsv"
 
 case "$XBPS_TARGET_MACHINE" in
 	x86_64*|i686*)
 		CFLAGS="-msse"
-		build_options_default="nvenc"
+		build_options_default="nvenc qsv"
 		;;
 esac
 
@@ -37,7 +40,7 @@ pre_configure() {
 	# use system libraries, don't download them
 	rm -rf contrib/
 	for module in fdk-aac ffmpeg libbluray libdav1d libdvdnav libdvdread nvenc \
-		x265 zimg; do
+		x265 zimg svt-av1 libvpl; do
 	    vsed -i "/MODULES += contrib\/${module}/d" make/include/main.defs
 	done
 }

From e52f49bffd2c8bd6b9138399750ca41ed4f56264 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 038/114] hedgewars: revbump for ffmpeg4-4.4.3

---
 srcpkgs/hedgewars/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/hedgewars/template b/srcpkgs/hedgewars/template
index 15a1df6d8861d..d1b7290bfdc19 100644
--- a/srcpkgs/hedgewars/template
+++ b/srcpkgs/hedgewars/template
@@ -1,13 +1,13 @@
 # Template file for 'hedgewars'
 pkgname=hedgewars
 version=1.0.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DNOSERVER=1 -DDATA_INSTALL_DIR=/usr/share/${pkgname}
  -DPHYSFS_SYSTEM=1 -DMINIMAL_FLAGS=1"
 make_cmd=make
 hostmakedepends="lua51 pkg-config qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
+makedepends="ffmpeg4-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
  SDL2_mixer-devel SDL2_net-devel SDL2_ttf-devel"
 depends="libfreeglut"
 short_desc="Funny turn-based artillery game, featuring fighting Hedgehogs!"

From 5e4ead007c0cde6d65fb3cda0a7f029e80d676f1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 039/114] idjc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/idjc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/idjc/template b/srcpkgs/idjc/template
index a9cde0665d55b..6f1d21c5781fd 100644
--- a/srcpkgs/idjc/template
+++ b/srcpkgs/idjc/template
@@ -5,7 +5,7 @@ revision=5
 build_style=gnu-configure
 hostmakedepends="pkg-config git python3 automake gettext-devel libtool"
 makedepends="libvorbis-devel libogg-devel jack-devel libsamplerate-devel
- libflac-devel libsndfile-devel mpg123-devel ffmpeg-devel speex-devel
+ libflac-devel libsndfile-devel mpg123-devel ffmpeg4-devel speex-devel
  glib-devel pixman-devel lame-devel python3-gobject-devel libshout-idjc-devel
  opus-devel twolame-devel python3-mutagen python3-devel"
 depends="python3-gobject python3-mutagen desktop-file-utils shared-mime-info python3-dbus jack"

From 0a75e6442b17aad942943034b2ab699f2b1019d0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 040/114] kid3: revbump for ffmpeg-6.0

---
 srcpkgs/kid3/patches/ffmpeg5.patch | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 srcpkgs/kid3/patches/ffmpeg5.patch

diff --git a/srcpkgs/kid3/patches/ffmpeg5.patch b/srcpkgs/kid3/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..135fc50e07c9b
--- /dev/null
+++ b/srcpkgs/kid3/patches/ffmpeg5.patch
@@ -0,0 +1,17 @@
+# https://aur.archlinux.org/cgit/aur.git/diff/ffmpeg5.patch?h=kid3-cli&id=12410a74906612e7efc0ec8fbce739b4a0fef7e7
+diff --git a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+index e156d424..e12b9abd 100644
+--- a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
++++ b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+@@ -232,7 +232,11 @@ private:
+   friend class Format;
+   friend class Converter;
+   AVCodecContext* m_ptr;
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 0, 0)
+   AVCodec* m_impl;
++#else
++  const AVCodec* m_impl;
++#endif
+   AVFrame* m_frame;
+   bool m_opened;
+ };

From a7f81adb259e5ae23f0980eadb9f05ccc2a14275 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 041/114] kodi: revbump for ffmpeg4-4.4.3

---
 srcpkgs/kodi/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kodi/template b/srcpkgs/kodi/template
index aa59324258a0d..6cf64dfb27294 100644
--- a/srcpkgs/kodi/template
+++ b/srcpkgs/kodi/template
@@ -54,7 +54,7 @@ makedepends="
  libmad-devel fontconfig-devel libXinerama-devel libsamplerate-devel libmms-devel
  enca-devel boost-devel libcurl-devel libva-devel libvdpau-devel libass-devel
  libbluetooth-devel yajl-devel libplist-devel librtmp-devel tinyxml-devel
- taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg-devel
+ taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg4-devel
  giflib-devel libxslt-devel gnutls-devel libssh-devel libmicrohttpd-devel
  libcec-devel dcadec-devel flatbuffers-devel fmt-devel lcms2-devel
  libfstrcmp-devel rapidjson libcdio-paranoia spdlog libwaylandpp-devel

From 6247d50970d8169328b2be2757f3ef40472b052d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 042/114] kpipewire: revbump for ffmpeg-6.0

---
 srcpkgs/kpipewire/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kpipewire/template b/srcpkgs/kpipewire/template
index b2d3d80c1dd1a..981c7b8890ded 100644
--- a/srcpkgs/kpipewire/template
+++ b/srcpkgs/kpipewire/template
@@ -1,7 +1,7 @@
 # Template file for 'kpipewire'
 pkgname=kpipewire
 version=5.27.9
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules plasma-wayland-protocols gettext
  qt5-qmake qt5-host-tools pkg-config wayland-devel kcoreaddons

From f62da19cdd33bc41846358da79a17ce9c2fb1c54 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 043/114] libextractor: revbump for ffmpeg4-4.4.3

---
 srcpkgs/libextractor/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libextractor/template b/srcpkgs/libextractor/template
index 044c663a3a0b9..ace88ae128da5 100644
--- a/srcpkgs/libextractor/template
+++ b/srcpkgs/libextractor/template
@@ -7,7 +7,7 @@ configure_args="--disable-static"
 hostmakedepends="pkg-config"
 makedepends="zlib-devel bzip2-devel exiv2-devel tiff-devel libpng-devel
  libjpeg-turbo-devel libvorbis-devel libflac-devel giflib-devel libmpeg2-devel
- ffmpeg-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
+ ffmpeg4-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
 short_desc="Library used to extract meta data from files"
 maintainer="Martin Riese <grauehaare@gmx.de>"
 license="GPL-3.0-or-later"

From f414e07050d4a39d454b7301da81f95e92d8a37b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 044/114] libopenal: revbump for ffmpeg-6.0

---
 srcpkgs/libopenal/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenal/template b/srcpkgs/libopenal/template
index 88d0f11307d81..8308fca0393e3 100644
--- a/srcpkgs/libopenal/template
+++ b/srcpkgs/libopenal/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenal'
 pkgname=libopenal
 version=1.23.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DALSOFT_EXAMPLES=OFF"
 hostmakedepends="pkg-config"

From a9799ee1149898f6d37e11aa64e545c66aa8f818 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 045/114] loudgain: revbump for ffmpeg-6.0

---
 srcpkgs/loudgain/patches/ffmpeg5.patch | 11 +++++++++++
 srcpkgs/loudgain/template              |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/loudgain/patches/ffmpeg5.patch

diff --git a/srcpkgs/loudgain/patches/ffmpeg5.patch b/srcpkgs/loudgain/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..16d4510ee98fa
--- /dev/null
+++ b/srcpkgs/loudgain/patches/ffmpeg5.patch
@@ -0,0 +1,11 @@
+--- a/src/scan.c	2019-09-06 11:31:19.000000000 -0400
++++ b/src/scan.c	2023-03-23 11:15:40.867968521 -0400
+@@ -69,8 +69,6 @@
+ 	 * It is now useless
+ 	 * https://github.com/FFmpeg/FFmpeg/blob/70d25268c21cbee5f08304da95be1f647c630c15/doc/APIchanges#L86
+ 	 */
+-  if (avformat_version() < AV_VERSION_INT(58,9,100))
+-    av_register_all();
+ 
+ 	av_log_set_callback(scan_av_log);
+ 
diff --git a/srcpkgs/loudgain/template b/srcpkgs/loudgain/template
index da4f2d56e94c3..4d6bf29efb4fd 100644
--- a/srcpkgs/loudgain/template
+++ b/srcpkgs/loudgain/template
@@ -1,7 +1,7 @@
 # Template file for 'loudgain'
 pkgname=loudgain
 version=0.6.8
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libebur128-devel taglib-devel ffmpeg-devel"

From a6171a1d6efdb7e5385918cbef11723cf083c7c5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 046/114] mediastreamer: revbump for ffmpeg4-4.4.3

---
 srcpkgs/mediastreamer/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mediastreamer/template b/srcpkgs/mediastreamer/template
index 0fcffa7653d18..92ada88743a9b 100644
--- a/srcpkgs/mediastreamer/template
+++ b/srcpkgs/mediastreamer/template
@@ -5,7 +5,7 @@ revision=2
 build_style=cmake
 configure_args="-DENABLE_STRICT=0 -DENABLE_UNIT_TESTS=0"
 hostmakedepends="python3"
-makedepends="bzrtp-devel ffmpeg-devel glew-devel libXv-devel libsrtp-devel
+makedepends="bzrtp-devel ffmpeg4-devel glew-devel libXv-devel libsrtp-devel
  libupnp-devel libvpx-devel mbedtls-devel opus-devel ortp-devel pulseaudio-devel
  libtheora-devel speex-devel v4l-utils-devel bcg729-devel bcmatroska2-devel libgsm-devel
  zxing-cpp-devel"

From 9abbbd47d400e64b85f196319963c7be2bcfbdc8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 047/114] mgba: revbump for ffmpeg-6.0

---
 srcpkgs/mgba/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mgba/template b/srcpkgs/mgba/template
index 5513e3fd16f3f..f5c87a4893002 100644
--- a/srcpkgs/mgba/template
+++ b/srcpkgs/mgba/template
@@ -1,7 +1,7 @@
 # Template file for 'mgba'
 pkgname=mgba
 version=0.10.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake desktop-file-utils"
 makedepends="SDL2-devel ffmpeg-devel libedit-devel libepoxy-devel libmagick-devel

From 46a5db27b844928cea4ff3115d5e81ce0093fc35 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 048/114] mlt: revbump for ffmpeg4-4.4.3

---
 srcpkgs/mlt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mlt/template b/srcpkgs/mlt/template
index 73e3915aaab9a..ec5054be3b75e 100644
--- a/srcpkgs/mlt/template
+++ b/srcpkgs/mlt/template
@@ -8,7 +8,7 @@ configure_args="--prefix=/usr --libdir=/usr/lib$XBPS_TARGET_WORDSIZE
  --swig-languages=python"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which"
 # XXX: movit vid.stab
-makedepends="alsa-lib-devel ffmpeg-devel gtk+-devel jack-devel ladspa-sdk
+makedepends="alsa-lib-devel ffmpeg4-devel gtk+-devel jack-devel ladspa-sdk
  libexif-devel libsamplerate-devel libxml2-devel sox-devel SDL_image-devel
  fftw-devel frei0r-plugins python3-devel pulseaudio-devel movit-devel
  libvidstab-devel"

From 9b9077982606d995ed8c9a39b7069547906345d5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 049/114] moc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/moc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/moc/template b/srcpkgs/moc/template
index 3a04932c8f1e6..d8de816026b64 100644
--- a/srcpkgs/moc/template
+++ b/srcpkgs/moc/template
@@ -4,7 +4,7 @@ version=2.5.2
 revision=7
 build_style=gnu-configure
 hostmakedepends="pkg-config"
-makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg-devel
+makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg4-devel
  jack-devel alsa-lib-devel libltdl-devel libflac-devel libvorbis-devel
  libmad-devel libmpcdec-devel libmodplug-devel libid3tag-devel faad2-devel
  taglib-devel libsndfile-devel wavpack-devel speex-devel libsamplerate-devel

From a7c42cb280435c80019aa73be0c0b74b3d7d3daa Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 050/114] motion: revbump for ffmpeg-6.0

---
 srcpkgs/motion/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/motion/template b/srcpkgs/motion/template
index 607ebeb3c7b24..bf63a91d9764f 100644
--- a/srcpkgs/motion/template
+++ b/srcpkgs/motion/template
@@ -1,7 +1,7 @@
 # Template file for 'motion'
 pkgname=motion
 version=4.6.0
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake pkg-config gettext-devel tar"
 makedepends="ffmpeg-devel libmicrohttpd-devel v4l-utils-devel gettext-devel"

From 94c04149fef187035616b86c8242d5bc2eec4318 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 051/114] notcurses: revbump for ffmpeg-6.0

---
 srcpkgs/notcurses/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/notcurses/template b/srcpkgs/notcurses/template
index 6dd8a091319f7..3110c30c9aff2 100644
--- a/srcpkgs/notcurses/template
+++ b/srcpkgs/notcurses/template
@@ -1,7 +1,7 @@
 # Template file for 'notcurses'
 pkgname=notcurses
 version=3.0.9
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DUSE_STATIC=ON $(vopt_bool man USE_PANDOC)"
 hostmakedepends="pkg-config $(vopt_if man pandoc)"

From d337a227fa7831a6000c85be4f5cc29767fc31f7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 052/114] olive: revbump for ffmpeg4-4.4.3

---
 srcpkgs/olive/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/olive/template b/srcpkgs/olive/template
index 12a46936c9900..5c2917b9c5124 100644
--- a/srcpkgs/olive/template
+++ b/srcpkgs/olive/template
@@ -1,10 +1,10 @@
 # Template file for 'olive'
 pkgname=olive
 version=0.1.2
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools pkg-config"
-makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg-devel frei0r-plugins"
+makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg4-devel frei0r-plugins"
 short_desc="Non-linear video editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"

From 29438fef8035347350a0526890d29f63a80cfc33 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 053/114] omxplayer: revbump for ffmpeg4-4.4.3

---
 srcpkgs/omxplayer/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/omxplayer/template b/srcpkgs/omxplayer/template
index 9a66690c83ebb..a21b878878037 100644
--- a/srcpkgs/omxplayer/template
+++ b/srcpkgs/omxplayer/template
@@ -1,7 +1,7 @@
 # Template file for 'omxplayer'
 pkgname=omxplayer
 version=20190102
-revision=2
+revision=3
 short_desc="Commandline OMX player for the Raspberry Pi"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
@@ -15,7 +15,7 @@ checksum=af2d9450f8947842ea8c401fe9f71eec444013ebbdee29f2ac828c9c493c1329
 archs="armv6l* armv7l*"
 build_style=gnu-makefile
 hostmakedepends="ruby-ronn pkg-config"
-makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg-devel dbus-devel"
+makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg4-devel dbus-devel"
 depends="freefont-ttf"
 
 do_build() {

From 1d3c377c4955da67532177e8204506dc62811202 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 054/114] opentoonz: revbump for ffmpeg-6.0

---
 srcpkgs/opentoonz/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/opentoonz/template b/srcpkgs/opentoonz/template
index ee9f7603f55fd..3e81834ca0edd 100644
--- a/srcpkgs/opentoonz/template
+++ b/srcpkgs/opentoonz/template
@@ -1,7 +1,7 @@
 # Template file for 'opentoonz'
 pkgname=opentoonz
 version=1.6.0
-revision=2
+revision=3
 build_wrksrc="toonz/sources"
 build_style=cmake
 make_cmd=make

From ecbbf02f0118d1a10af9a3a8e2923dbf6ec7e468 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 055/114] pianobar: revbump for ffmpeg-6.0

---
 srcpkgs/pianobar/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pianobar/template b/srcpkgs/pianobar/template
index e3febb821a451..1e3dc1bf9308e 100644
--- a/srcpkgs/pianobar/template
+++ b/srcpkgs/pianobar/template
@@ -1,7 +1,7 @@
 # Template file for 'pianobar'
 pkgname=pianobar
 version=2022.04.01
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="V=1"
 hostmakedepends="pkg-config"

From bddba89620258a10eba0d131f7caa310f0639276 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 056/114] ppsspp: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ppsspp/template | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/ppsspp/template b/srcpkgs/ppsspp/template
index 2c0ded496eb98..1294ef3ae669c 100644
--- a/srcpkgs/ppsspp/template
+++ b/srcpkgs/ppsspp/template
@@ -1,7 +1,7 @@
 # Template file for 'ppsspp'
 pkgname=ppsspp
 version=1.16.6
-revision=1
+revision=2
 _glslang_commit=b34f619e1c85810dcb3c578107d2e48ba4ee2b37
 _SPIRV_Cross_commit=4212eef67ed0ca048cb726a6767185504e7695e5
 _armips_commit=7bd1ec93d4586985ba1ef420b43b5e620f68695e
@@ -15,7 +15,7 @@ configure_args="-DHEADLESS=1 -DUSE_SYSTEM_FFMPEG=1 -DUNITTEST=ON
  -DUSING_QT_UI=$(vopt_if qt ON OFF) -DUSE_SYSTEM_ZSTD=ON
  -DARMIPS_USE_STD_FILESYSTEM=ON"
 hostmakedepends="pkg-config python3 $(vopt_if qt qt5-host-tools)"
-makedepends="zlib-devel glew-devel ffmpeg-devel libzip-devel
+makedepends="zlib-devel glew-devel ffmpeg4-devel libzip-devel
  snappy-devel rapidjson libpng-devel libzstd-devel
  $(vopt_if sdl2 'SDL2_ttf-devel SDL2-devel') $(vopt_if wayland wayland-devel)
  $(vopt_if qt 'qt5-devel qt5-multimedia-devel')"
@@ -72,7 +72,7 @@ post_extract() {
         mv ${wrksrc}/rcheevos-${_rcheevos_commit} ${wrksrc}/ext/rcheevos
 }
 
-post_patch(){
+post_patch() {
 	# disable git versioning
 	vsed -e 's|find_package(Git)|# &|' -i git-version.cmake
 }
@@ -85,7 +85,6 @@ post_configure() {
 }
 
 do_install() {
-	vlicense LICENSE.TXT
 	vinstall icons/icon.svg 644 usr/share/pixmaps ppsspp.svg
 	vinstall Qt/PPSSPP.desktop 644 usr/share/applications
 	vbin build/PPSSPPHeadless ppsspp-headless

From 97103c5a1cf2c2e870fe82cdabd9e6732576776f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 057/114] pqiv: revbump for ffmpeg-6.0

---
 srcpkgs/pqiv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pqiv/template b/srcpkgs/pqiv/template
index 542fc27a2d32a..9308d949b6a1c 100644
--- a/srcpkgs/pqiv/template
+++ b/srcpkgs/pqiv/template
@@ -1,7 +1,7 @@
 # Template file for 'pqiv'
 pkgname=pqiv
 version=2.12
-revision=1
+revision=2
 build_style=gnu-makefile
 hostmakedepends="pkg-config"
 makedepends="glib-devel gtk+3-devel $(vopt_if ffmpeg ffmpeg-devel)

From 308050b2f532a312793d576eda4f34fdbdb46533 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 058/114] qmmp: revbump for ffmpeg-6.0

---
 srcpkgs/qmmp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qmmp/template b/srcpkgs/qmmp/template
index 53781ea3bc28a..2da07f1e87eac 100644
--- a/srcpkgs/qmmp/template
+++ b/srcpkgs/qmmp/template
@@ -1,7 +1,7 @@
 # Template file for 'qmmp'
 pkgname=qmmp
 version=1.6.1
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DUSE_HAL:BOOL=FALSE -DQMMP_DEFAULT_UI:STRING=simple"
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From d9ef0ef91b3bc5f70569539f5551ee794e9462f4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 059/114] qt5-webengine: update to 5.15.15

---
 .../chromium-media-filters-cpp14.patch        |  11 ++
 srcpkgs/qt5-webengine/patches/ffmpeg5.patch   | 179 ++++++++++++++++++
 srcpkgs/qt5-webengine/template                |  10 +-
 3 files changed, 195 insertions(+), 5 deletions(-)
 create mode 100644 srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/ffmpeg5.patch

diff --git a/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
new file mode 100644
index 0000000000000..04adc540f2cbc
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
@@ -0,0 +1,11 @@
+--- a/src/3rdparty/chromium/media/filters/BUILD.gn	2023-02-27 13:32:59.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/BUILD.gn	2023-04-02 17:21:39.204066384 -0400
+@@ -96,6 +96,8 @@
+     "//ui/gfx/geometry:geometry",
+   ]
+ 
++  cflags_cc = [ "-std=c++14" ]
++
+   libs = []
+ 
+   if (proprietary_codecs) {
diff --git a/srcpkgs/qt5-webengine/patches/ffmpeg5.patch b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..ac55e1634423a
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
@@ -0,0 +1,179 @@
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:57.732547446 -0400
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:09.486478995 -0400
+@@ -57,6 +57,8 @@
+ 
+ namespace {
+ 
++constexpr int64_t kRelativeTsBase = static_cast<int64_t>(0x7ffeffffffffffff);
++
+ void SetAVStreamDiscard(AVStream* stream, AVDiscard discard) {
+   DCHECK(stream);
+   stream->discard = discard;
+@@ -90,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+   if (stream->start_time != kNoFFmpegTimestamp)
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (stream->first_dts != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, stream->first_dts);
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -408,11 +398,11 @@
+   scoped_refptr<DecoderBuffer> buffer;
+ 
+   if (type() == DemuxerStream::TEXT) {
+-    int id_size = 0;
++    size_t id_size = 0;
+     uint8_t* id_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
+ 
+-    int settings_size = 0;
++    size_t settings_size = 0;
+     uint8_t* settings_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
+ 
+@@ -424,7 +414,7 @@
+     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
+                                      side_data.data(), side_data.size());
+   } else {
+-    int side_data_size = 0;
++    size_t side_data_size = 0;
+     uint8_t* side_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
+ 
+@@ -485,7 +475,7 @@
+                                        packet->size - data_offset);
+     }
+ 
+-    int skip_samples_size = 0;
++    size_t skip_samples_size = 0;
+     const uint32_t* skip_samples_ptr =
+         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
+             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
+@@ -1587,6 +1577,8 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++      continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+       lowest_start_time_stream = stream.get();
+@@ -1604,6 +1596,8 @@
+     if (stream && stream->type() == DemuxerStream::VIDEO &&
+         stream->IsEnabled()) {
+       video_stream = stream.get();
++      if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++        continue;
+       if (video_stream->start_time() <= seek_time) {
+         return video_stream;
+       }
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h qtwebengine-5.15.10/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h
+--- a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-07-11 22:12:47.917192788 -0500
+@@ -29,6 +29,7 @@ extern "C" {
+ #include <libavformat/avformat.h>
+ #include <libavformat/avio.h>
+ #include <libavutil/avutil.h>
++#include <libavutil/channel_layout.h>
+ #include <libavutil/imgutils.h>
+ #include <libavutil/log.h>
+ #include <libavutil/mastering_display_metadata.h>
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/audio_file_reader.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/audio_file_reader.cc
+--- a/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -85,7 +85,7 @@ bool AudioFileReader::OpenDemuxer() {
+ }
+ 
+ bool AudioFileReader::OpenDecoder() {
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (codec) {
+     // MP3 decodes to S16P which we don't support, tell it to use S16 instead.
+     if (codec_context_->sample_fmt == AV_SAMPLE_FMT_S16P)
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -329,7 +329,7 @@ bool FFmpegAudioDecoder::ConfigureDecode
+     }
+   }
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec ||
+       avcodec_open2(codec_context_.get(), codec, &codec_options) < 0) {
+     DLOG(ERROR) << "Could not initialize audio decoder: "
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -59,7 +59,6 @@ static int64_t AVIOSeekOperation(void* o
+ }
+ 
+ void FFmpegGlue::InitializeFFmpeg() {
+-  av_register_all();
+ }
+ 
+ static void LogContainer(bool is_local_file,
+@@ -95,9 +94,6 @@ FFmpegGlue::FFmpegGlue(FFmpegURLProtocol
+   // Enable fast, but inaccurate seeks for MP3.
+   format_context_->flags |= AVFMT_FLAG_FAST_SEEK;
+ 
+-  // Ensures we can read out various metadata bits like vp8 alpha.
+-  format_context_->flags |= AVFMT_FLAG_KEEP_SIDE_DATA;
+-
+   // Ensures format parsing errors will bail out. From an audit on 11/2017, all
+   // instances were real failures. Solves bugs like http://crbug.com/710791.
+   format_context_->error_recognition |= AV_EF_EXPLODE;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -391,7 +391,7 @@ bool FFmpegVideoDecoder::ConfigureDecode
+   if (decode_nalus_)
+     codec_context_->flags2 |= AV_CODEC_FLAG2_CHUNKS;
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
+     ReleaseFFmpegResources();
+     return false;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/media_file_checker.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/media_file_checker.cc
+--- a/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -68,7 +68,7 @@ bool MediaFileChecker::Start(base::TimeD
+       auto context = AVStreamToAVCodecContext(format_context->streams[i]);
+       if (!context)
+         continue;
+-      AVCodec* codec = avcodec_find_decoder(cp->codec_id);
++      const AVCodec* codec = avcodec_find_decoder(cp->codec_id);
+       if (codec && avcodec_open2(context.get(), codec, nullptr) >= 0) {
+         auto loop = std::make_unique<FFmpegDecodingLoop>(context.get());
+         stream_contexts[i] = {std::move(context), std::move(loop)};
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc qtwebengine-5.15.10/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc
+--- a/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -203,7 +203,7 @@ int32_t H264DecoderImpl::InitDecode(cons
+   // a pointer |this|.
+   av_context_->opaque = this;
+ 
+-  AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
+   if (!codec) {
+     // This is an indication that FFmpeg has not been initialized or it has not
+     // been compiled/initialized with the correct set of codecs.
diff --git a/srcpkgs/qt5-webengine/template b/srcpkgs/qt5-webengine/template
index 84de5b12ecdda..e00807ced9f2b 100644
--- a/srcpkgs/qt5-webengine/template
+++ b/srcpkgs/qt5-webengine/template
@@ -1,9 +1,9 @@
 # Template file for 'qt5-webengine'
 pkgname=qt5-webengine
-version=5.15.11
-revision=5
+version=5.15.15
+revision=1
 _version="${version}-lts"
-_chromium_commit=be349eaf62e77955791d7bf29f893f1e8a37daf4
+_chromium_commit=e48df7803c7c98b0b2471c94057d32e44a301ad5
 archs="x86_64* i686* armv[67]* ppc64* aarch64*"
 create_wrksrc=yes
 build_style=qmake
@@ -32,8 +32,8 @@ license="GPL-3.0-or-later, LGPL-3.0-or-later"
 homepage="https://qt.io/"
 distfiles="https://github.com/qt/qtwebengine/archive/v${_version}.tar.gz
  https://github.com/qt/qtwebengine-chromium/archive/${_chromium_commit}.tar.gz"
-checksum="aa7466356c450c5f5870f979b93cd7e7e62da1165c328ffcab1a9928db18ad67
- 6f47ed8ab8cc062411f6f206da6353bc8263d6ed6d6290c689a05c01d91f646b"
+checksum="1c2a3b6ae39c937068b38e3bd1d5a8f1ed61ea680496fc225e6fd0de11e2af7a
+ a91686562b1d4e8b220e0bbcbab5feb64630e2de974b35ac034bf388af771a6c"
 
 no_generic_pkgconfig_link=yes
 build_options="sndio pipewire"

From b0905f2dc22953d4326737ed29f91d54d123aa69 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 060/114] qt5: update to 5.15.8

---
 ...erywhere-opensource-src-5.15.8-kf5-1.patch | 12913 ++++++++++++++++
 srcpkgs/qt5/template                          |    13 +-
 2 files changed, 12919 insertions(+), 7 deletions(-)
 create mode 100644 srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch

diff --git a/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch b/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch
new file mode 100644
index 0000000000000..966c98bcd3bb1
--- /dev/null
+++ b/srcpkgs/qt5/patches/qt-everywhere-opensource-src-5.15.8-kf5-1.patch
@@ -0,0 +1,12913 @@
+Submitted By:            Pierre Labastie <pierre_dot_labastie_at_neuf_dot_fr>
+Date:                    2023-01-05
+Initial Package Version: 5.15.8
+Upstream Status:         Applied (according to KDE)
+Origin:                  KDE patch set
+Description:             Patch set maintained by the KDE folks
+see https://dot.kde.org/2021/04/06/announcing-kdes-qt-5-patch-collection
+Patch generated using the procedure in
+https://wiki.linuxfromscratch.org/blfs/ticket/17476#comment:3
+
+Submodule qtbase 4ee4fc18..9cf586d6:
+diff --git a/qtbase/mkspecs/common/android/qplatformdefs.h b/qtbase/mkspecs/common/android/qplatformdefs.h
+index f75bc4093b..2bd59410d4 100644
+--- a/qtbase/mkspecs/common/android/qplatformdefs.h
++++ b/qtbase/mkspecs/common/android/qplatformdefs.h
+@@ -144,11 +144,7 @@
+ #define QT_SIGNAL_ARGS          int
+ #define QT_SIGNAL_IGNORE        SIG_IGN
+ 
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+ #define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+ 
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+diff --git a/qtbase/mkspecs/features/mac/sdk.mk b/qtbase/mkspecs/features/mac/sdk.mk
+index f30b5830b4..a32ceacb6c 100644
+--- a/qtbase/mkspecs/features/mac/sdk.mk
++++ b/qtbase/mkspecs/features/mac/sdk.mk
+@@ -1,6 +1,6 @@
+ 
+ ifeq ($(QT_MAC_SDK_NO_VERSION_CHECK),)
+-    CHECK_SDK_COMMAND = /usr/bin/xcrun --sdk $(EXPORT_QMAKE_MAC_SDK) -show-sdk-version 2>&1
++    CHECK_SDK_COMMAND = /usr/bin/xcrun --sdk $(EXPORT_QMAKE_MAC_SDK) -show-sdk-version 2>/dev/null
+     CURRENT_MAC_SDK_VERSION := $(shell DEVELOPER_DIR=$(EXPORT_QMAKE_XCODE_DEVELOPER_PATH) $(CHECK_SDK_COMMAND))
+     ifneq ($(CURRENT_MAC_SDK_VERSION),$(EXPORT_QMAKE_MAC_SDK_VERSION))
+         # We don't want to complain about out of date SDK unless the target needs to be remade.
+diff --git a/qtbase/mkspecs/linux-clang/qplatformdefs.h b/qtbase/mkspecs/linux-clang/qplatformdefs.h
+index a818d973f0..c1ab72fbc6 100644
+--- a/qtbase/mkspecs/linux-clang/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-clang/qplatformdefs.h
+@@ -79,14 +79,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-g++/qplatformdefs.h b/qtbase/mkspecs/linux-g++/qplatformdefs.h
+index 13523f0702..4d2750d9ec 100644
+--- a/qtbase/mkspecs/linux-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-g++/qplatformdefs.h
+@@ -79,14 +79,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ < 2)
+-#define QT_SOCKLEN_T            int
+-#else
+-#define QT_SOCKLEN_T            socklen_t
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-llvm/qplatformdefs.h b/qtbase/mkspecs/linux-llvm/qplatformdefs.h
+index dc750ab1ef..d3cc39b47f 100644
+--- a/qtbase/mkspecs/linux-llvm/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-llvm/qplatformdefs.h
+@@ -80,14 +80,6 @@
+ #define QT_USE_XOPEN_LFS_EXTENSIONS
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h b/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
+index 4c4e53da2a..83baffb3e3 100644
+--- a/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/linux-lsb-g++/qplatformdefs.h
+@@ -85,16 +85,9 @@
+ #include "../common/posix/qplatformdefs.h"
+ 
+ #undef QT_OPEN_LARGEFILE
+-#undef QT_SOCKLEN_T
+ 
+ #define QT_OPEN_LARGEFILE       0
+ 
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #ifndef SIOCGIFBRDADDR
+ #  define SIOCGIFBRDADDR 0x8919
+ #endif
+diff --git a/qtbase/mkspecs/lynxos-g++/qplatformdefs.h b/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
+index 4339ea2b23..6007af0055 100644
+--- a/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
++++ b/qtbase/mkspecs/lynxos-g++/qplatformdefs.h
+@@ -72,14 +72,6 @@
+ 
+ #include "../common/posix/qplatformdefs.h"
+ 
+-#undef QT_SOCKLEN_T
+-
+-#if defined(__GLIBC__) && (__GLIBC__ >= 2)
+-#define QT_SOCKLEN_T            socklen_t
+-#else
+-#define QT_SOCKLEN_T            int
+-#endif
+-
+ #if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500)
+ #define QT_SNPRINTF             ::snprintf
+ #define QT_VSNPRINTF            ::vsnprintf
+diff --git a/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp b/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
+index c3c184258f..32af3f8f29 100644
+--- a/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
++++ b/qtbase/src/3rdparty/angle/src/libANGLE/HandleAllocator.cpp
+@@ -10,6 +10,7 @@
+ #include "libANGLE/HandleAllocator.h"
+ 
+ #include <algorithm>
++#include <limits>
+ 
+ #include "common/debug.h"
+ 
+diff --git a/qtbase/src/3rdparty/forkfd/forkfd_linux.c b/qtbase/src/3rdparty/forkfd/forkfd_linux.c
+index ffe0e9a5e2..b1f5408d11 100644
+--- a/qtbase/src/3rdparty/forkfd/forkfd_linux.c
++++ b/qtbase/src/3rdparty/forkfd/forkfd_linux.c
+@@ -82,7 +82,8 @@ static int sys_clone(unsigned long cloneflags, int *ptid)
+     return syscall(__NR_clone, cloneflags, child_stack, stack_size, ptid, newtls, ctid);
+ #elif defined(__arc__) || defined(__arm__) || defined(__aarch64__) || defined(__mips__) || \
+     defined(__nds32__) || defined(__hppa__) || defined(__powerpc__) || defined(__i386__) || \
+-    defined(__x86_64__) || defined(__xtensa__) || defined(__alpha__) || defined(__riscv)
++    defined(__x86_64__) || defined(__xtensa__) || defined(__alpha__) || defined(__riscv) || \
++    defined(__loongarch__)
+     /* ctid and newtls are inverted on CONFIG_CLONE_BACKWARDS architectures,
+      * but since both values are 0, there's no harm. */
+     return syscall(__NR_clone, cloneflags, child_stack, ptid, ctid, newtls);
+diff --git a/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java b/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
+index 5792b5b2f5..2f74750fcf 100644
+--- a/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
++++ b/qtbase/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
+@@ -116,6 +116,7 @@ public class QtNative
+     public static QtThread m_qtThread = new QtThread();
+     private static HashMap<String, Uri> m_cachedUris = new HashMap<String, Uri>();
+     private static ArrayList<String> m_knownDirs = new ArrayList<String>();
++    private static final String NoPermissionErrorMessage = "No permissions to open Uri";
+ 
+     private static final Runnable runPendingCppRunnablesRunnable = new Runnable() {
+         @Override
+@@ -193,11 +194,10 @@ public class QtNative
+                     return iterUri;
+             }
+ 
+-            // Android 6 and earlier could still manage to open the file so we can return the
+-            // parsed uri here
+-            if (Build.VERSION.SDK_INT < 24)
+-                return parsedUri;
+-            return null;
++            // if we only have transient permissions on uri all the above will fail,
++            // but we will be able to read the file anyway, so continue with uri here anyway
++            // and check for SecurityExceptions later
++            return parsedUri;
+         } catch (SecurityException e) {
+             e.printStackTrace();
+             return null;
+@@ -244,7 +244,7 @@ public class QtNative
+         int error = -1;
+ 
+         if (uri == null) {
+-            Log.e(QtTAG, "openFdForContentUrl(): No permissions to open Uri");
++            Log.e(QtTAG, "openFdForContentUrl(): " + NoPermissionErrorMessage);
+             return error;
+         }
+ 
+@@ -254,12 +254,13 @@ public class QtNative
+             return fdDesc.detachFd();
+         } catch (FileNotFoundException e) {
+             e.printStackTrace();
+-            return error;
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "openFdForContentUrl(): Invalid Uri");
+             e.printStackTrace();
+-            return error;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return error;
+     }
+ 
+     public static long getSize(Context context, String contentUrl)
+@@ -270,7 +271,7 @@ public class QtNative
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+ 
+         if (uri == null) {
+-            Log.e(QtTAG, "getSize(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return size;
+         } else if (!m_cachedUris.containsKey(contentUrl)) {
+             m_cachedUris.put(contentUrl, uri);
+@@ -288,12 +289,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "getSize(): Invalid Uri");
+             e.printStackTrace();
+-            return size;
+         }  catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "getSize(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return size;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return size;
+     }
+ 
+     public static boolean checkFileExists(Context context, String contentUrl)
+@@ -303,7 +305,7 @@ public class QtNative
+         if (uri == null)
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+         if (uri == null) {
+-            Log.e(QtTAG, "checkFileExists(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return exists;
+         } else {
+             if (!m_cachedUris.containsKey(contentUrl))
+@@ -321,12 +323,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "checkFileExists(): Invalid Uri");
+             e.printStackTrace();
+-            return exists;
+         } catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "checkFileExists(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return false;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return exists;
+     }
+ 
+     public static boolean checkIfWritable(Context context, String contentUrl)
+@@ -344,7 +347,7 @@ public class QtNative
+             uri = getUriWithValidPermission(context, contentUrl, "r");
+         }
+         if (uri == null) {
+-            Log.e(QtTAG, "isDir(): No permissions to open Uri");
++            Log.e(QtTAG, NoPermissionErrorMessage);
+             return isDir;
+         } else {
+             if (!m_cachedUris.containsKey(contentUrl))
+@@ -374,12 +377,13 @@ public class QtNative
+         } catch (IllegalArgumentException e) {
+             Log.e(QtTAG, "checkIfDir(): Invalid Uri");
+             e.printStackTrace();
+-            return false;
+         } catch (UnsupportedOperationException e) {
+             Log.e(QtTAG, "checkIfDir(): Unsupported operation for given Uri");
+             e.printStackTrace();
+-            return false;
++        } catch (SecurityException e) {
++            Log.e(QtTAG, NoPermissionErrorMessage);
+         }
++        return false;
+     }
+     public static String[] listContentsFromTreeUri(Context context, String contentUrl)
+     {
+diff --git a/qtbase/src/concurrent/qtconcurrentreducekernel.h b/qtbase/src/concurrent/qtconcurrentreducekernel.h
+index 8f9a938952..a98dedef2e 100644
+--- a/qtbase/src/concurrent/qtconcurrentreducekernel.h
++++ b/qtbase/src/concurrent/qtconcurrentreducekernel.h
+@@ -212,11 +212,13 @@ public:
+ 
+     inline bool shouldThrottle()
+     {
++        std::lock_guard<QMutex> locker(mutex);
+         return (resultsMapSize > (ReduceQueueThrottleLimit * threadCount));
+     }
+ 
+     inline bool shouldStartThread()
+     {
++        std::lock_guard<QMutex> locker(mutex);
+         return (resultsMapSize <= (ReduceQueueStartLimit * threadCount));
+     }
+ };
+diff --git a/qtbase/src/concurrent/qtconcurrentthreadengine.cpp b/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
+index ea6ce3ac42..7f91a2ba68 100644
+--- a/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
++++ b/qtbase/src/concurrent/qtconcurrentthreadengine.cpp
+@@ -176,6 +176,39 @@ void ThreadEngineBase::startSingleThreaded()
+     finish();
+ }
+ 
++void ThreadEngineBase::startBlocking()
++{
++    start();
++    barrier.acquire();
++    startThreads();
++
++    bool throttled = false;
++#ifndef QT_NO_EXCEPTIONS
++    try {
++#endif
++        while (threadFunction() == ThrottleThread) {
++            if (threadThrottleExit()) {
++                throttled = true;
++                break;
++            }
++        }
++#ifndef QT_NO_EXCEPTIONS
++    } catch (QException &e) {
++        handleException(e);
++    } catch (...) {
++        handleException(QUnhandledException());
++    }
++#endif
++
++    if (throttled == false) {
++        barrier.release();
++    }
++
++    barrier.wait();
++    finish();
++    exceptionStore.throwPossibleException();
++}
++
+ void ThreadEngineBase::startThread()
+ {
+     startThreadInternal();
+diff --git a/qtbase/src/concurrent/qtconcurrentthreadengine.h b/qtbase/src/concurrent/qtconcurrentthreadengine.h
+index 7c30cebdbc..a4c8548cc4 100644
+--- a/qtbase/src/concurrent/qtconcurrentthreadengine.h
++++ b/qtbase/src/concurrent/qtconcurrentthreadengine.h
+@@ -91,6 +91,7 @@ public:
+     ThreadEngineBase();
+     virtual ~ThreadEngineBase();
+     void startSingleThreaded();
++    void startBlocking();
+     void startThread();
+     bool isCanceled();
+     void waitForResume();
+@@ -143,6 +144,15 @@ public:
+         return result();
+     }
+ 
++    // Runs the user algorithm using multiple threads.
++    // This function blocks until the algorithm is finished,
++    // and then returns the result.
++    T *startBlocking()
++    {
++        ThreadEngineBase::startBlocking();
++        return result();
++    }
++
+     // Runs the user algorithm using multiple threads.
+     // Does not block, returns a future.
+     QFuture<T> startAsynchronously()
+@@ -223,6 +233,13 @@ class ThreadEngineStarter : public ThreadEngineStarterBase<T>
+ public:
+     ThreadEngineStarter(TypedThreadEngine *eng)
+         : Base(eng) { }
++
++    T startBlocking()
++    {
++        T t = *this->threadEngine->startBlocking();
++        delete this->threadEngine;
++        return t;
++    }
+ };
+ 
+ // Full template specialization where T is void.
+@@ -232,6 +249,12 @@ class ThreadEngineStarter<void> : public ThreadEngineStarterBase<void>
+ public:
+     ThreadEngineStarter(ThreadEngine<void> *_threadEngine)
+         : ThreadEngineStarterBase<void>(_threadEngine) {}
++
++    void startBlocking()
++    {
++        this->threadEngine->startBlocking();
++        delete this->threadEngine;
++    }
+ };
+ 
+ //! [qtconcurrentthreadengine-1]
+diff --git a/qtbase/src/corelib/animation/qvariantanimation.cpp b/qtbase/src/corelib/animation/qvariantanimation.cpp
+index 98b02f0202..eac1524107 100644
+--- a/qtbase/src/corelib/animation/qvariantanimation.cpp
++++ b/qtbase/src/corelib/animation/qvariantanimation.cpp
+@@ -276,7 +276,9 @@ void QVariantAnimationPrivate::setCurrentValueForProgress(const qreal progress)
+ 
+     const qreal startProgress = currentInterval.start.first;
+     const qreal endProgress = currentInterval.end.first;
+-    const qreal localProgress = (progress - startProgress) / (endProgress - startProgress);
++    const qreal localProgress =
++            qIsNull(progress - startProgress) ? 0.0 // avoid 0/0 below
++            /* else */                        : (progress - startProgress) / (endProgress - startProgress);
+ 
+     QVariant ret = q->interpolated(currentInterval.start.second,
+                                    currentInterval.end.second,
+diff --git a/qtbase/src/corelib/global/qnamespace.h b/qtbase/src/corelib/global/qnamespace.h
+index ad4150b317..bf19b1627b 100644
+--- a/qtbase/src/corelib/global/qnamespace.h
++++ b/qtbase/src/corelib/global/qnamespace.h
+@@ -1864,7 +1864,7 @@ public:
+     QT_Q_ENUM(TimerType)
+     QT_Q_ENUM(ScrollPhase)
+     QT_Q_ENUM(MouseEventSource)
+-    QT_Q_FLAG(MouseEventFlag)
++    QT_Q_FLAG(MouseEventFlags)
+     QT_Q_ENUM(ChecksumType)
+     QT_Q_ENUM(HighDpiScaleFactorRoundingPolicy)
+     QT_Q_ENUM(TabFocusBehavior)
+diff --git a/qtbase/src/corelib/global/qrandom.cpp b/qtbase/src/corelib/global/qrandom.cpp
+index 10672c1f92..25f87c7e6a 100644
+--- a/qtbase/src/corelib/global/qrandom.cpp
++++ b/qtbase/src/corelib/global/qrandom.cpp
+@@ -383,7 +383,6 @@ struct QRandomGenerator::SystemAndGlobalGenerators
+ 
+         constexpr SystemAndGlobalGenerators g = {};
+         Q_UNUSED(g);
+-        Q_STATIC_ASSERT(std::is_literal_type<SystemAndGlobalGenerators>::value);
+ #endif
+     }
+ 
+diff --git a/qtbase/src/corelib/io/qbuffer.cpp b/qtbase/src/corelib/io/qbuffer.cpp
+index 595fcd2724..032c0ddd4b 100644
+--- a/qtbase/src/corelib/io/qbuffer.cpp
++++ b/qtbase/src/corelib/io/qbuffer.cpp
+@@ -41,6 +41,8 @@
+ #include <QtCore/qmetaobject.h>
+ #include "private/qiodevice_p.h"
+ 
++#include <limits>
++
+ QT_BEGIN_NAMESPACE
+ 
+ /** QBufferPrivate **/
+@@ -366,7 +368,9 @@ qint64 QBuffer::size() const
+ bool QBuffer::seek(qint64 pos)
+ {
+     Q_D(QBuffer);
+-    if (pos > d->buf->size() && isWritable()) {
++    const auto oldBufSize = d->buf->size();
++    constexpr qint64 MaxSeekPos = (std::numeric_limits<decltype(oldBufSize)>::max)();
++    if (pos <= MaxSeekPos && pos > oldBufSize && isWritable()) {
+         if (seek(d->buf->size())) {
+             const qint64 gapSize = pos - d->buf->size();
+             if (write(QByteArray(gapSize, 0)) != gapSize) {
+@@ -377,7 +381,7 @@ bool QBuffer::seek(qint64 pos)
+             return false;
+         }
+     } else if (pos > d->buf->size() || pos < 0) {
+-        qWarning("QBuffer::seek: Invalid pos: %d", int(pos));
++        qWarning("QBuffer::seek: Invalid pos: %lld", pos);
+         return false;
+     }
+     return QIODevice::seek(pos);
+diff --git a/qtbase/src/corelib/io/qfilesystemengine_win.cpp b/qtbase/src/corelib/io/qfilesystemengine_win.cpp
+index 81d3a71986..c86ed1f9b0 100644
+--- a/qtbase/src/corelib/io/qfilesystemengine_win.cpp
++++ b/qtbase/src/corelib/io/qfilesystemengine_win.cpp
+@@ -664,14 +664,14 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry)
+     return QFileSystemEntry(ret, QFileSystemEntry::FromInternalPath());
+ }
+ 
+-#if defined(Q_CC_MINGW) && WINVER < 0x0602 //  Windows 8 onwards
++#if defined(Q_CC_MINGW) && WINVER < 0x0602 && _WIN32_WINNT < _WIN32_WINNT_WIN8 //  Windows 8 onwards
+ 
+ typedef struct _FILE_ID_INFO {
+     ULONGLONG VolumeSerialNumber;
+     FILE_ID_128 FileId;
+ } FILE_ID_INFO, *PFILE_ID_INFO;
+ 
+-#endif // if defined (Q_CC_MINGW) && WINVER < 0x0602
++#endif // if defined(Q_CC_MINGW) && WINVER < 0x0602 && _WIN32_WINNT < _WIN32_WINNT_WIN8
+ 
+ // File ID for Windows up to version 7 and FAT32 drives
+ static inline QByteArray fileId(HANDLE handle)
+diff --git a/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp b/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
+index 94d9d06bcb..27e0b13b0b 100644
+--- a/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
++++ b/qtbase/src/corelib/io/qfilesystemwatcher_inotify.cpp
+@@ -366,7 +366,9 @@ void QInotifyFileSystemWatcherEngine::readFromInotify()
+     // qDebug("QInotifyFileSystemWatcherEngine::readFromInotify");
+ 
+     int buffSize = 0;
+-    ioctl(inotifyFd, FIONREAD, (char *) &buffSize);
++    if (ioctl(inotifyFd, FIONREAD, (char *) &buffSize) == -1 || buffSize == 0)
++        return;
++
+     QVarLengthArray<char, 4096> buffer(buffSize);
+     buffSize = read(inotifyFd, buffer.data(), buffSize);
+     char *at = buffer.data();
+diff --git a/qtbase/src/corelib/io/qlockfile_win.cpp b/qtbase/src/corelib/io/qlockfile_win.cpp
+index 277f8d4230..38ecef5550 100644
+--- a/qtbase/src/corelib/io/qlockfile_win.cpp
++++ b/qtbase/src/corelib/io/qlockfile_win.cpp
+@@ -48,6 +48,8 @@
+ #include "QtCore/qdebug.h"
+ #include "QtCore/qthread.h"
+ 
++#include "private/qsystemlibrary_p.h"
++
+ QT_BEGIN_NAMESPACE
+ 
+ static inline bool fileExists(const wchar_t *fileName)
+@@ -150,7 +152,7 @@ QString QLockFilePrivate::processNameByPid(qint64 pid)
+ #if !defined(Q_OS_WINRT)
+     typedef DWORD (WINAPI *GetModuleFileNameExFunc)(HANDLE, HMODULE, LPTSTR, DWORD);
+ 
+-    HMODULE hPsapi = LoadLibraryA("psapi");
++    HMODULE hPsapi = QSystemLibrary::load(L"psapi");
+     if (!hPsapi)
+         return QString();
+     GetModuleFileNameExFunc qGetModuleFileNameEx = reinterpret_cast<GetModuleFileNameExFunc>(
+diff --git a/qtbase/src/corelib/io/qprocess_unix.cpp b/qtbase/src/corelib/io/qprocess_unix.cpp
+index 50390e57f5..15c8f30745 100644
+--- a/qtbase/src/corelib/io/qprocess_unix.cpp
++++ b/qtbase/src/corelib/io/qprocess_unix.cpp
+@@ -1,7 +1,7 @@
+ /****************************************************************************
+ **
+ ** Copyright (C) 2016 The Qt Company Ltd.
+-** Copyright (C) 2016 Intel Corporation.
++** Copyright (C) 2022 Intel Corporation.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtCore module of the Qt Toolkit.
+@@ -422,14 +422,15 @@ void QProcessPrivate::startProcess()
+     // Add the program name to the argument list.
+     argv[0] = nullptr;
+     if (!program.contains(QLatin1Char('/'))) {
++        // findExecutable() returns its argument if it's an absolute path,
++        // otherwise it searches $PATH; returns empty if not found (we handle
++        // that case much later)
+         const QString &exeFilePath = QStandardPaths::findExecutable(program);
+-        if (!exeFilePath.isEmpty()) {
+-            const QByteArray &tmp = QFile::encodeName(exeFilePath);
+-            argv[0] = ::strdup(tmp.constData());
+-        }
+-    }
+-    if (!argv[0])
++        const QByteArray &tmp = QFile::encodeName(exeFilePath);
++        argv[0] = ::strdup(tmp.constData());
++    } else {
+         argv[0] = ::strdup(encodedProgramName.constData());
++    }
+ 
+     // Add every argument to the list
+     for (int i = 0; i < arguments.count(); ++i)
+@@ -983,15 +984,16 @@ bool QProcessPrivate::startDetached(qint64 *pid)
+                 envp = _q_dupEnvironment(environment.d.constData()->vars, &envc);
+             }
+ 
+-            QByteArray tmp;
+             if (!program.contains(QLatin1Char('/'))) {
++                // findExecutable() returns its argument if it's an absolute path,
++                // otherwise it searches $PATH; returns empty if not found (we handle
++                // that case much later)
+                 const QString &exeFilePath = QStandardPaths::findExecutable(program);
+-                if (!exeFilePath.isEmpty())
+-                    tmp = QFile::encodeName(exeFilePath);
++                const QByteArray &tmp = QFile::encodeName(exeFilePath);
++                argv[0] = ::strdup(tmp.constData());
++            } else {
++                argv[0] = ::strdup(QFile::encodeName(program));
+             }
+-            if (tmp.isEmpty())
+-                tmp = QFile::encodeName(program);
+-            argv[0] = tmp.data();
+ 
+             if (envp)
+                 qt_safe_execve(argv[0], argv, envp);
+diff --git a/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp b/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
+index 3a79c502af..997a634e76 100644
+--- a/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
++++ b/qtbase/src/corelib/itemmodels/qabstractitemmodel.cpp
+@@ -3196,9 +3196,8 @@ bool QAbstractItemModel::beginMoveColumns(const QModelIndex &sourceParent, int s
+     destinationChange.needsAdjust = destinationParent.isValid() && destinationParent.row() >= sourceLast && destinationParent.parent() == sourceParent;
+     d->changes.push(destinationChange);
+ 
+-    d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Horizontal);
+-
+     emit columnsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, QPrivateSignal());
++    d->itemsAboutToBeMoved(sourceParent, sourceFirst, sourceLast, destinationParent, destinationChild, Qt::Horizontal);
+     return true;
+ }
+ 
+@@ -3231,7 +3230,6 @@ void QAbstractItemModel::endMoveColumns()
+       adjustedSource = createIndex(adjustedSource.row(), adjustedSource.column() + numMoved, adjustedSource.internalPointer());
+ 
+     d->itemsMoved(adjustedSource, removeChange.first, removeChange.last, adjustedDestination, insertChange.first, Qt::Horizontal);
+-
+     emit columnsMoved(adjustedSource, removeChange.first, removeChange.last, adjustedDestination, insertChange.first, QPrivateSignal());
+ }
+ 
+diff --git a/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+index dc6379d9fb..c5e287ee84 100644
+--- a/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
++++ b/qtbase/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+@@ -939,8 +939,9 @@ void QSortFilterProxyModelPrivate::insert_source_items(
+                 q->beginInsertColumns(proxy_parent, proxy_start, proxy_end);
+         }
+ 
+-        for (int i = 0; i < source_items.size(); ++i)
+-            proxy_to_source.insert(proxy_start + i, source_items.at(i));
++        // TODO: use the range QList::insert() overload once it is implemented (QTBUG-58633).
++        proxy_to_source.insert(proxy_start, source_items.size(), 0);
++        std::copy(source_items.cbegin(), source_items.cend(), proxy_to_source.begin() + proxy_start);
+ 
+         build_source_to_proxy_mapping(proxy_to_source, source_to_proxy);
+ 
+@@ -3123,8 +3124,9 @@ bool QSortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex &
+ 
+     if (d->filter_data.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();
+@@ -3133,9 +3135,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.hasMatch(key);
+ }
+diff --git a/qtbase/src/corelib/kernel/qcoreapplication.cpp b/qtbase/src/corelib/kernel/qcoreapplication.cpp
+index ca2864df83..132b2eae52 100644
+--- a/qtbase/src/corelib/kernel/qcoreapplication.cpp
++++ b/qtbase/src/corelib/kernel/qcoreapplication.cpp
+@@ -1157,7 +1157,7 @@ static bool doNotify(QObject *receiver, QEvent *event)
+ bool QCoreApplicationPrivate::sendThroughApplicationEventFilters(QObject *receiver, QEvent *event)
+ {
+     // We can't access the application event filters outside of the main thread (race conditions)
+-    Q_ASSERT(receiver->d_func()->threadData.loadRelaxed()->thread.loadAcquire() == mainThread());
++    Q_ASSERT(receiver->d_func()->threadData.loadAcquire()->thread.loadRelaxed() == mainThread());
+ 
+     if (extraData) {
+         // application event filters are only called for objects in the GUI thread
+diff --git a/qtbase/src/corelib/kernel/qobject.cpp b/qtbase/src/corelib/kernel/qobject.cpp
+index 1eb79138d9..36cd780ee1 100644
+--- a/qtbase/src/corelib/kernel/qobject.cpp
++++ b/qtbase/src/corelib/kernel/qobject.cpp
+@@ -1010,7 +1010,7 @@ QObject::~QObject()
+         emit destroyed(this);
+     }
+ 
+-    if (d->declarativeData) {
++    if (!d->isDeletingChildren && d->declarativeData) {
+         if (static_cast<QAbstractDeclarativeDataImpl*>(d->declarativeData)->ownedByQml1) {
+             if (QAbstractDeclarativeData::destroyed_qml1)
+                 QAbstractDeclarativeData::destroyed_qml1(d->declarativeData, this);
+@@ -1580,7 +1580,7 @@ void QObject::moveToThread(QThread *targetThread)
+ 
+     QThreadData *currentData = QThreadData::current();
+     QThreadData *targetData = targetThread ? QThreadData::get2(targetThread) : nullptr;
+-    QThreadData *thisThreadData = d->threadData.loadRelaxed();
++    QThreadData *thisThreadData = d->threadData.loadAcquire();
+     if (!thisThreadData->thread.loadAcquire() && currentData == targetData) {
+         // one exception to the rule: we allow moving objects with no thread affinity to the current thread
+         currentData = d->threadData;
+@@ -2620,7 +2620,7 @@ int QObject::receivers(const char *signal) const
+         if (!d->isSignalConnected(signal_index))
+             return receivers;
+ 
+-        if (d->declarativeData && QAbstractDeclarativeData::receivers) {
++        if (!d->isDeletingChildren && d->declarativeData && QAbstractDeclarativeData::receivers) {
+             receivers += QAbstractDeclarativeData::receivers(d->declarativeData, this,
+                                                              signal_index);
+         }
+diff --git a/qtbase/src/corelib/kernel/qobject_p.h b/qtbase/src/corelib/kernel/qobject_p.h
+index 0b827a52ca..13ffb88999 100644
+--- a/qtbase/src/corelib/kernel/qobject_p.h
++++ b/qtbase/src/corelib/kernel/qobject_p.h
+@@ -444,7 +444,7 @@ inline void QObjectPrivate::checkForIncompatibleLibraryVersion(int version) cons
+ 
+ inline bool QObjectPrivate::isDeclarativeSignalConnected(uint signal_index) const
+ {
+-    return declarativeData && QAbstractDeclarativeData::isSignalConnected
++    return !isDeletingChildren && declarativeData && QAbstractDeclarativeData::isSignalConnected
+             && QAbstractDeclarativeData::isSignalConnected(declarativeData, q_func(), signal_index);
+ }
+ 
+diff --git a/qtbase/src/corelib/kernel/qtranslator.cpp b/qtbase/src/corelib/kernel/qtranslator.cpp
+index 2812ffb7ea..bc0177c5ec 100644
+--- a/qtbase/src/corelib/kernel/qtranslator.cpp
++++ b/qtbase/src/corelib/kernel/qtranslator.cpp
+@@ -902,7 +902,7 @@ static QString getMessage(const uchar *m, const uchar *end, const char *context,
+             goto end;
+         case Tag_Translation: {
+             int len = read32(m);
+-            if (len % 1)
++            if (len & 1)
+                 return QString();
+             m += 4;
+             if (!numerus--) {
+diff --git a/qtbase/src/corelib/mimetypes/qmimedatabase.cpp b/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
+index 9de22cef33..ff868a3268 100644
+--- a/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimedatabase.cpp
+@@ -389,20 +389,23 @@ QMimeType QMimeDatabasePrivate::mimeTypeForFileNameAndData(const QString &fileNa
+         // Disambiguate conflicting extensions (if magic matching found something)
+         if (candidateByData.isValid() && magicAccuracy > 0) {
+             const QString sniffedMime = candidateByData.name();
+-            // If the sniffedMime matches a glob match, use it
++            // If the sniffedMime matches a highest-weight glob match, use it
+             if (candidatesByName.m_matchingMimeTypes.contains(sniffedMime)) {
+                 *accuracyPtr = 100;
+                 return candidateByData;
+             }
+-            for (const QString &m : qAsConst(candidatesByName.m_matchingMimeTypes)) {
++            for (const QString &m : qAsConst(candidatesByName.m_allMatchingMimeTypes)) {
+                 if (inherits(m, sniffedMime)) {
+                     // We have magic + pattern pointing to this, so it's a pretty good match
+                     *accuracyPtr = 100;
+                     return mimeTypeForName(m);
+                 }
+             }
+-            *accuracyPtr = magicAccuracy;
+-            return candidateByData;
++            if (candidatesByName.m_allMatchingMimeTypes.isEmpty()) {
++                // No glob, use magic
++                *accuracyPtr = magicAccuracy;
++                return candidateByData;
++            }
+         }
+     }
+ 
+diff --git a/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp b/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
+index a81112d227..fa8f4c545d 100644
+--- a/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimeglobpattern.cpp
+@@ -83,7 +83,10 @@ void QMimeGlobMatchResult::addMatch(const QString &mimeType, int weight, const Q
+     }
+     if (!m_matchingMimeTypes.contains(mimeType)) {
+         m_matchingMimeTypes.append(mimeType);
+-        m_allMatchingMimeTypes.append(mimeType);
++        if (replace)
++            m_allMatchingMimeTypes.prepend(mimeType); // highest-weight first
++        else
++            m_allMatchingMimeTypes.append(mimeType);
+         m_knownSuffixLength = knownSuffixLength;
+     }
+ }
+@@ -94,7 +97,7 @@ QMimeGlobPattern::PatternType QMimeGlobPattern::detectPatternType(const QString
+     if (!patternLength)
+         return OtherPattern;
+ 
+-    const bool starCount = pattern.count(QLatin1Char('*')) == 1;
++    const int starCount = pattern.count(QLatin1Char('*'));
+     const bool hasSquareBracket = pattern.indexOf(QLatin1Char('[')) != -1;
+     const bool hasQuestionMark = pattern.indexOf(QLatin1Char('?')) != -1;
+ 
+@@ -106,10 +109,10 @@ QMimeGlobPattern::PatternType QMimeGlobPattern::detectPatternType(const QString
+             // Patterns like "README*" (well this is currently the only one like that...)
+             if (pattern.at(patternLength - 1) == QLatin1Char('*'))
+                 return PrefixPattern;
+-        }
+-        // Names without any wildcards like "README"
+-        if (starCount == 0)
++        } else if (starCount == 0) {
++            // Names without any wildcards like "README"
+             return LiteralPattern;
++        }
+     }
+ 
+     if (pattern == QLatin1String("[0-9][0-9][0-9].vdr"))
+diff --git a/qtbase/src/corelib/mimetypes/qmimeprovider.cpp b/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
+index 258dddf8cb..4642d0f2d0 100644
+--- a/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
++++ b/qtbase/src/corelib/mimetypes/qmimeprovider.cpp
+@@ -244,15 +244,18 @@ void QMimeBinaryProvider::addFileNameMatches(const QString &fileName, QMimeGlobM
+     const QString lowerFileName = fileName.toLower();
+     // Check literals (e.g. "Makefile")
+     matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosLiteralListOffset), fileName);
+-    // Check complex globs (e.g. "callgrind.out[0-9]*")
+-    matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosGlobListOffset), fileName);
+     // Check the very common *.txt cases with the suffix tree
+-    const int reverseSuffixTreeOffset = m_cacheFile->getUint32(PosReverseSuffixTreeOffset);
+-    const int numRoots = m_cacheFile->getUint32(reverseSuffixTreeOffset);
+-    const int firstRootOffset = m_cacheFile->getUint32(reverseSuffixTreeOffset + 4);
+-    matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, lowerFileName, lowerFileName.length() - 1, false);
++    if (result.m_matchingMimeTypes.isEmpty()) {
++        const int reverseSuffixTreeOffset = m_cacheFile->getUint32(PosReverseSuffixTreeOffset);
++        const int numRoots = m_cacheFile->getUint32(reverseSuffixTreeOffset);
++        const int firstRootOffset = m_cacheFile->getUint32(reverseSuffixTreeOffset + 4);
++        matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, lowerFileName, lowerFileName.length() - 1, false);
++        if (result.m_matchingMimeTypes.isEmpty())
++            matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, fileName, fileName.length() - 1, true);
++    }
++    // Check complex globs (e.g. "callgrind.out[0-9]*" or "README*")
+     if (result.m_matchingMimeTypes.isEmpty())
+-        matchSuffixTree(result, m_cacheFile, numRoots, firstRootOffset, fileName, fileName.length() - 1, true);
++        matchGlobList(result, m_cacheFile, m_cacheFile->getUint32(PosGlobListOffset), fileName);
+ }
+ 
+ void QMimeBinaryProvider::matchGlobList(QMimeGlobMatchResult &result, CacheFile *cacheFile, int off, const QString &fileName)
+diff --git a/qtbase/src/corelib/serialization/qjsonparser.cpp b/qtbase/src/corelib/serialization/qjsonparser.cpp
+index 17e6f111ab..2e40b6c8fb 100644
+--- a/qtbase/src/corelib/serialization/qjsonparser.cpp
++++ b/qtbase/src/corelib/serialization/qjsonparser.cpp
+@@ -379,10 +379,30 @@ error:
+     return QCborValue();
+ }
+ 
++// We need to retain the _last_ value for any duplicate keys and we need to deref containers.
++// Therefore the manual implementation of std::unique().
++template<typename Iterator, typename Compare, typename Assign>
++static Iterator customAssigningUniqueLast(Iterator first, Iterator last,
++                                          Compare compare, Assign assign)
++{
++    first = std::adjacent_find(first, last, compare);
++    if (first == last)
++        return last;
++
++    Iterator result = first;
++    while (++first != last) {
++        if (!compare(*result, *first))
++            ++result;
++        if (result != first)
++            assign(*result, *first);
++    }
++
++    return ++result;
++}
++
+ static void sortContainer(QCborContainerPrivate *container)
+ {
+     using Forward = QJsonPrivate::KeyIterator;
+-    using Reverse = std::reverse_iterator<Forward>;
+     using Value = Forward::value_type;
+ 
+     auto compare = [container](const Value &a, const Value &b)
+@@ -420,17 +440,31 @@ static void sortContainer(QCborContainerPrivate *container)
+         }
+     };
+ 
+-    std::sort(Forward(container->elements.begin()), Forward(container->elements.end()),
+-              [&compare](const Value &a, const Value &b) { return compare(a, b) < 0; });
++    // The elements' containers are owned by the outer container, not by the elements themselves.
++    auto move = [](Forward::reference target, Forward::reference source)
++    {
++        QtCbor::Element &targetValue = target.value();
++
++        // If the target has a container, deref it before overwriting, so that we don't leak.
++        if (targetValue.flags & QtCbor::Element::IsContainer)
++            targetValue.container->deref();
++
++        // Do not move, so that we can clear the value afterwards.
++        target = source;
++
++        // Clear the source value, so that we don't store the same container twice.
++        source.value() = QtCbor::Element();
++    };
++
++    std::stable_sort(
++                Forward(container->elements.begin()), Forward(container->elements.end()),
++                [&compare](const Value &a, const Value &b) { return compare(a, b) < 0; });
+ 
+-    // We need to retain the _last_ value for any duplicate keys. Therefore the reverse dance here.
+-    auto it = std::unique(Reverse(container->elements.end()), Reverse(container->elements.begin()),
+-                          [&compare](const Value &a, const Value &b) {
+-        return compare(a, b) == 0;
+-    }).base().elementsIterator();
++    Forward result = customAssigningUniqueLast(
++                Forward(container->elements.begin()),  Forward(container->elements.end()),
++                [&compare](const Value &a, const Value &b) { return compare(a, b) == 0; }, move);
+ 
+-    // The erase from beginning is expensive but hopefully rare.
+-    container->elements.erase(container->elements.begin(), it);
++    container->elements.erase(result.elementsIterator(), container->elements.end());
+ }
+ 
+ 
+diff --git a/qtbase/src/corelib/serialization/qxmlstream.cpp b/qtbase/src/corelib/serialization/qxmlstream.cpp
+index b2f846544d..7cd457ba3a 100644
+--- a/qtbase/src/corelib/serialization/qxmlstream.cpp
++++ b/qtbase/src/corelib/serialization/qxmlstream.cpp
+@@ -980,7 +980,7 @@ inline uint QXmlStreamReaderPrivate::peekChar()
+ bool QXmlStreamReaderPrivate::scanUntil(const char *str, short tokenToInject)
+ {
+     int pos = textBuffer.size();
+-    int oldLineNumber = lineNumber;
++    const auto oldLineNumber = lineNumber;
+ 
+     uint c;
+     while ((c = getChar()) != StreamEOF) {
+diff --git a/qtbase/src/corelib/text/qstring.cpp b/qtbase/src/corelib/text/qstring.cpp
+index 3e88ab4859..8deeae47bb 100644
+--- a/qtbase/src/corelib/text/qstring.cpp
++++ b/qtbase/src/corelib/text/qstring.cpp
+@@ -12312,7 +12312,7 @@ static qsizetype qLastIndexOf(Haystack haystack0, qsizetype from,
+     const auto needle = needle0.data();
+     const auto *end = haystack;
+     haystack += from;
+-    const std::size_t sl_minus_1 = sl - 1;
++    const std::size_t sl_minus_1 = sl ? sl - 1 : 0;
+     const auto *n = needle + sl_minus_1;
+     const auto *h = haystack + sl_minus_1;
+     std::size_t hashNeedle = 0, hashHaystack = 0;
+diff --git a/qtbase/src/corelib/text/qstringiterator_p.h b/qtbase/src/corelib/text/qstringiterator_p.h
+index 219589b6e4..1d0c66cc78 100644
+--- a/qtbase/src/corelib/text/qstringiterator_p.h
++++ b/qtbase/src/corelib/text/qstringiterator_p.h
+@@ -61,6 +61,8 @@ class QStringIterator
+ {
+     QString::const_iterator i, pos, e;
+     Q_STATIC_ASSERT((std::is_same<QString::const_iterator, const QChar *>::value));
++    static bool less(const QChar *lhs, const QChar *rhs) noexcept
++    { return std::less<QString::const_iterator>{}(lhs, rhs); }
+ public:
+     explicit QStringIterator(QStringView string, qsizetype idx = 0)
+         : i(string.begin()),
+@@ -95,7 +97,8 @@ public:
+ 
+     inline void setPosition(QString::const_iterator position)
+     {
+-        Q_ASSERT_X(i <= position && position <= e, Q_FUNC_INFO, "position out of bounds");
++        Q_ASSERT_X(!less(position, i) && !less(e, position),
++                   Q_FUNC_INFO, "position out of bounds");
+         pos = position;
+     }
+ 
+@@ -103,7 +106,7 @@ public:
+ 
+     inline bool hasNext() const
+     {
+-        return pos < e;
++        return less(pos, e);
+     }
+ 
+     inline void advance()
+@@ -120,16 +123,20 @@ public:
+     {
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+-        if (Q_UNLIKELY((pos++)->isHighSurrogate()))
++        if (Q_UNLIKELY((pos++)->isHighSurrogate())) {
++            Q_ASSERT(hasNext() && pos->isLowSurrogate());
+             ++pos;
++        }
+     }
+ 
+     inline uint peekNextUnchecked() const
+     {
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+-        if (Q_UNLIKELY(pos->isHighSurrogate()))
++        if (Q_UNLIKELY(pos->isHighSurrogate())) {
++            Q_ASSERT(less(pos + 1, e) && pos[1].isLowSurrogate());
+             return QChar::surrogateToUcs4(pos[0], pos[1]);
++        }
+ 
+         return pos->unicode();
+     }
+@@ -155,8 +162,10 @@ public:
+         Q_ASSERT_X(hasNext(), Q_FUNC_INFO, "iterator hasn't a next item");
+ 
+         const QChar cur = *pos++;
+-        if (Q_UNLIKELY(cur.isHighSurrogate()))
++        if (Q_UNLIKELY(cur.isHighSurrogate())) {
++            Q_ASSERT(hasNext() && pos->isLowSurrogate());
+             return QChar::surrogateToUcs4(cur, *pos++);
++        }
+         return cur.unicode();
+     }
+ 
+@@ -166,7 +175,7 @@ public:
+ 
+         const QChar uc = *pos++;
+         if (Q_UNLIKELY(uc.isSurrogate())) {
+-            if (Q_LIKELY(uc.isHighSurrogate() && pos < e && pos->isLowSurrogate()))
++            if (Q_LIKELY(uc.isHighSurrogate() && hasNext() && pos->isLowSurrogate()))
+                 return QChar::surrogateToUcs4(uc, *pos++);
+             return invalidAs;
+         }
+@@ -178,7 +187,7 @@ public:
+ 
+     inline bool hasPrevious() const
+     {
+-        return pos > i;
++        return less(i, pos);
+     }
+ 
+     inline void recede()
+@@ -196,16 +205,20 @@ public:
+     {
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+-        if (Q_UNLIKELY((--pos)->isLowSurrogate()))
++        if (Q_UNLIKELY((--pos)->isLowSurrogate())) {
++            Q_ASSERT(hasPrevious() && pos[-1].isHighSurrogate());
+             --pos;
++        }
+     }
+ 
+     inline uint peekPreviousUnchecked() const
+     {
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+-        if (Q_UNLIKELY(pos[-1].isLowSurrogate()))
++        if (Q_UNLIKELY(pos[-1].isLowSurrogate())) {
++            Q_ASSERT(less(i + 1, pos) && pos[-2].isHighSurrogate());
+             return QChar::surrogateToUcs4(pos[-2], pos[-1]);
++        }
+         return pos[-1].unicode();
+     }
+ 
+@@ -230,8 +243,10 @@ public:
+         Q_ASSERT_X(hasPrevious(), Q_FUNC_INFO, "iterator hasn't a previous item");
+ 
+         const QChar cur = *--pos;
+-        if (Q_UNLIKELY(cur.isLowSurrogate()))
++        if (Q_UNLIKELY(cur.isLowSurrogate())) {
++            Q_ASSERT(hasPrevious() && pos[-1].isHighSurrogate());
+             return QChar::surrogateToUcs4(*--pos, cur);
++        }
+         return cur.unicode();
+     }
+ 
+@@ -241,7 +256,7 @@ public:
+ 
+         const QChar uc = *--pos;
+         if (Q_UNLIKELY(uc.isSurrogate())) {
+-            if (Q_LIKELY(uc.isLowSurrogate() && pos > i && pos[-1].isHighSurrogate()))
++            if (Q_LIKELY(uc.isLowSurrogate() && hasPrevious() && pos[-1].isHighSurrogate()))
+                 return QChar::surrogateToUcs4(*--pos, uc);
+             return invalidAs;
+         }
+diff --git a/qtbase/src/corelib/thread/qfutex_p.h b/qtbase/src/corelib/thread/qfutex_p.h
+index f287b752d7..e294537787 100644
+--- a/qtbase/src/corelib/thread/qfutex_p.h
++++ b/qtbase/src/corelib/thread/qfutex_p.h
+@@ -52,6 +52,7 @@
+ //
+ 
+ #include <qglobal.h>
++#include <QtCore/qtsan_impl.h>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -106,16 +107,13 @@ namespace QtLinuxFutex {
+     inline int _q_futex(int *addr, int op, int val, quintptr val2 = 0,
+                         int *addr2 = nullptr, int val3 = 0) noexcept
+     {
+-        // A futex call ensures total ordering on the futex words
+-        // (in either success or failure of the call). Instruct TSAN accordingly,
+-        // as TSAN does not understand the futex(2) syscall.
+-        _q_tsan_release(addr, addr2);
++        QtTsan::futexRelease(addr, addr2);
+ 
+         // we use __NR_futex because some libcs (like Android's bionic) don't
+         // provide SYS_futex etc.
+         int result = syscall(__NR_futex, addr, op | FUTEX_PRIVATE_FLAG, val, val2, addr2, val3);
+ 
+-        _q_tsan_acquire(addr, addr2);
++        QtTsan::futexAcquire(addr, addr2);
+ 
+         return result;
+     }
+diff --git a/qtbase/src/corelib/thread/qmutex.cpp b/qtbase/src/corelib/thread/qmutex.cpp
+index 310d1cb14f..7097122d8e 100644
+--- a/qtbase/src/corelib/thread/qmutex.cpp
++++ b/qtbase/src/corelib/thread/qmutex.cpp
+@@ -152,6 +152,7 @@ public:
+ 
+ /*!
+     \enum QMutex::RecursionMode
++    \obsolete Use QRecursiveMutex to create a recursive mutex.
+ 
+     \value Recursive  In this mode, a thread can lock the same mutex
+                       multiple times and the mutex won't be unlocked
+@@ -173,6 +174,7 @@ public:
+ 
+ /*!
+     Constructs a new mutex. The mutex is created in an unlocked state.
++    \obsolete Use QRecursiveMutex to create a recursive mutex.
+ 
+     If \a mode is QMutex::Recursive, a thread can lock the same mutex
+     multiple times and the mutex won't be unlocked until a
+@@ -197,7 +199,7 @@ QMutex::QMutex(RecursionMode mode)
+ QMutex::~QMutex()
+ {
+     QMutexData *d = d_ptr.loadRelaxed();
+-    if (isRecursive()) {
++    if (QBasicMutex::isRecursive()) {
+         delete static_cast<QRecursiveMutexPrivate *>(d);
+     } else if (d) {
+ #ifndef QT_LINUX_FUTEX
+diff --git a/qtbase/src/corelib/thread/qmutex.h b/qtbase/src/corelib/thread/qmutex.h
+index 73c9e00663..1bae573a03 100644
+--- a/qtbase/src/corelib/thread/qmutex.h
++++ b/qtbase/src/corelib/thread/qmutex.h
+@@ -42,6 +42,7 @@
+ 
+ #include <QtCore/qglobal.h>
+ #include <QtCore/qatomic.h>
++#include <QtCore/qtsan_impl.h>
+ #include <new>
+ 
+ #if __has_include(<chrono>)
+@@ -77,19 +78,37 @@ public:
+ 
+     // BasicLockable concept
+     inline void lock() QT_MUTEX_LOCK_NOEXCEPT {
++        QtTsan::mutexPreLock(this, 0u);
++
+         if (!fastTryLock())
+             lockInternal();
++
++        QtTsan::mutexPostLock(this, 0u, 0);
+     }
+ 
+     // BasicLockable concept
+     inline void unlock() noexcept {
+         Q_ASSERT(d_ptr.loadRelaxed()); //mutex must be locked
++
++        QtTsan::mutexPreUnlock(this, 0u);
++
+         if (!fastTryUnlock())
+             unlockInternal();
++
++        QtTsan::mutexPostUnlock(this, 0u);
+     }
+ 
+     bool tryLock() noexcept {
+-        return fastTryLock();
++        unsigned tsanFlags = QtTsan::TryLock;
++        QtTsan::mutexPreLock(this, tsanFlags);
++
++        const bool success = fastTryLock();
++
++        if (!success)
++            tsanFlags |= QtTsan::TryLockFailed;
++        QtTsan::mutexPostLock(this, tsanFlags, 0);
++
++        return success;
+     }
+ 
+     // Lockable concept
+@@ -134,8 +153,16 @@ public:
+ #else
+     QMutex() { d_ptr.storeRelaxed(nullptr); }
+ #endif
++#if QT_DEPRECATED_SINCE(5,15)
+     enum RecursionMode { NonRecursive, Recursive };
++    QT_DEPRECATED_VERSION_X(5, 15, "Use QRecursiveMutex instead of a recursive QMutex")
+     explicit QMutex(RecursionMode mode);
++
++    QT_DEPRECATED_VERSION_X(5, 15, "Use QRecursiveMutex instead of a recursive QMutex")
++    bool isRecursive() const noexcept
++    { return QBasicMutex::isRecursive(); }
++#endif
++
+     ~QMutex();
+ 
+     // BasicLockable concept
+@@ -166,9 +193,6 @@ public:
+     }
+ #endif
+ 
+-    bool isRecursive() const noexcept
+-    { return QBasicMutex::isRecursive(); }
+-
+ private:
+     Q_DISABLE_COPY(QMutex)
+     friend class QMutexLocker;
+diff --git a/qtbase/src/corelib/thread/qreadwritelock.cpp b/qtbase/src/corelib/thread/qreadwritelock.cpp
+index 8c28507d5a..9dd8503116 100644
+--- a/qtbase/src/corelib/thread/qreadwritelock.cpp
++++ b/qtbase/src/corelib/thread/qreadwritelock.cpp
+@@ -155,7 +155,7 @@ QReadWriteLock::QReadWriteLock(RecursionMode recursionMode)
+ */
+ QReadWriteLock::~QReadWriteLock()
+ {
+-    auto d = d_ptr.loadRelaxed();
++    auto d = d_ptr.loadAcquire();
+     if (isUncontendedLocked(d)) {
+         qWarning("QReadWriteLock: destroying locked QReadWriteLock");
+         return;
+@@ -445,7 +445,7 @@ void QReadWriteLock::unlock()
+ /*! \internal  Helper for QWaitCondition::wait */
+ QReadWriteLock::StateForWaitCondition QReadWriteLock::stateForWaitCondition() const
+ {
+-    QReadWriteLockPrivate *d = d_ptr.loadRelaxed();
++    QReadWriteLockPrivate *d = d_ptr.loadAcquire();
+     switch (quintptr(d) & StateMask) {
+     case StateLockedForRead: return LockedForRead;
+     case StateLockedForWrite: return LockedForWrite;
+@@ -453,6 +453,7 @@ QReadWriteLock::StateForWaitCondition QReadWriteLock::stateForWaitCondition() co
+ 
+     if (!d)
+         return Unlocked;
++    const auto lock = qt_scoped_lock(d->mutex);
+     if (d->writerCount > 1)
+         return RecursivelyLocked;
+     else if (d->writerCount == 1)
+diff --git a/qtbase/src/corelib/thread/qsemaphore.cpp b/qtbase/src/corelib/thread/qsemaphore.cpp
+index 1d01fc1b28..3ecdee3747 100644
+--- a/qtbase/src/corelib/thread/qsemaphore.cpp
++++ b/qtbase/src/corelib/thread/qsemaphore.cpp
+@@ -354,7 +354,12 @@ void QSemaphore::release(int n)
+         quintptr nn = unsigned(n);
+         if (futexHasWaiterCount)
+             nn |= quint64(nn) << 32;    // token count replicated in high word
+-        quintptr prevValue = u.fetchAndAddRelease(nn);
++        quintptr prevValue = u.loadRelaxed();
++        quintptr newValue;
++        do { // loop just to ensure the operations are done atomically
++            newValue = prevValue + nn;
++            newValue &= (futexNeedsWakeAllBit - 1);
++        } while (!u.testAndSetRelease(prevValue, newValue, prevValue));
+         if (futexNeedsWake(prevValue)) {
+ #ifdef FUTEX_OP
+             if (futexHasWaiterCount) {
+@@ -376,7 +381,6 @@ void QSemaphore::release(int n)
+                 quint32 oparg = 0;
+                 quint32 cmp = FUTEX_OP_CMP_NE;
+                 quint32 cmparg = 0;
+-                u.fetchAndAndRelease(futexNeedsWakeAllBit - 1);
+                 futexWakeOp(*futexLow32(&u), n, INT_MAX, *futexHigh32(&u), FUTEX_OP(op, oparg, cmp, cmparg));
+                 return;
+             }
+@@ -388,7 +392,6 @@ 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(futexNeedsWakeAllBit - 1);
+             if (futexHasWaiterCount) {
+                 futexWakeAll(*futexLow32(&u));
+                 futexWakeAll(*futexHigh32(&u));
+diff --git a/qtbase/src/corelib/thread/qthread_p.h b/qtbase/src/corelib/thread/qthread_p.h
+index b2d1628e6e..f32f6f0460 100644
+--- a/qtbase/src/corelib/thread/qthread_p.h
++++ b/qtbase/src/corelib/thread/qthread_p.h
+@@ -174,7 +174,7 @@ public:
+     int returnCode;
+ 
+     uint stackSize;
+-    QThread::Priority priority;
++    std::underlying_type<QThread::Priority>::type priority;
+ 
+     static QThread *threadForId(int id);
+ 
+@@ -213,6 +213,13 @@ public:
+             QCoreApplication::instance()->postEvent(q_ptr, new QEvent(QEvent::Quit));
+         }
+     }
++
++#ifndef Q_OS_INTEGRITY
++private:
++    // Used in QThread(Private)::start to avoid racy access to QObject::objectName,
++    // unset afterwards. On INTEGRITY we set the thread name before starting it.
++    QString objectName;
++#endif
+ };
+ 
+ #else // QT_CONFIG(thread)
+diff --git a/qtbase/src/corelib/thread/qthread_unix.cpp b/qtbase/src/corelib/thread/qthread_unix.cpp
+index 56a8e0a038..610117a640 100644
+--- a/qtbase/src/corelib/thread/qthread_unix.cpp
++++ b/qtbase/src/corelib/thread/qthread_unix.cpp
+@@ -169,8 +169,7 @@ static void set_thread_data(QThreadData *data)
+ 
+ static void clear_thread_data()
+ {
+-    currentThreadData = nullptr;
+-    pthread_setspecific(current_thread_data_key, nullptr);
++    set_thread_data(nullptr);
+ }
+ 
+ template <typename T>
+@@ -296,7 +295,7 @@ void *QThreadPrivate::start(void *arg)
+             QMutexLocker locker(&thr->d_func()->mutex);
+ 
+             // do we need to reset the thread priority?
+-            if (int(thr->d_func()->priority) & ThreadPriorityResetFlag) {
++            if (thr->d_func()->priority & ThreadPriorityResetFlag) {
+                 thr->d_func()->setPriority(QThread::Priority(thr->d_func()->priority & ~ThreadPriorityResetFlag));
+             }
+ 
+@@ -316,10 +315,10 @@ void *QThreadPrivate::start(void *arg)
+             // Sets the name of the current thread. We can only do this
+             // when the thread is starting, as we don't have a cross
+             // platform way of setting the name of an arbitrary thread.
+-            if (Q_LIKELY(thr->objectName().isEmpty()))
++            if (Q_LIKELY(thr->d_func()->objectName.isEmpty()))
+                 setCurrentThreadName(thr->metaObject()->className());
+             else
+-                setCurrentThreadName(thr->objectName().toLocal8Bit());
++                setCurrentThreadName(std::exchange(thr->d_func()->objectName, {}).toLocal8Bit());
+         }
+ #endif
+ 
+@@ -671,7 +670,7 @@ void QThread::start(Priority priority)
+                 // could not set scheduling hints, fallback to inheriting them
+                 // we'll try again from inside the thread
+                 pthread_attr_setinheritsched(&attr, PTHREAD_INHERIT_SCHED);
+-                d->priority = Priority(priority | ThreadPriorityResetFlag);
++                d->priority = static_cast<std::underlying_type<QThread::Priority>::type>(priority) | ThreadPriorityResetFlag;
+             }
+             break;
+         }
+@@ -702,7 +701,10 @@ void QThread::start(Priority priority)
+         pthread_attr_setthreadname(&attr, metaObject()->className());
+     else
+         pthread_attr_setthreadname(&attr, objectName().toLocal8Bit());
++#else
++    d->objectName = objectName();
+ #endif
++
+     pthread_t threadId;
+     int code = pthread_create(&threadId, &attr, QThreadPrivate::start, this);
+     if (code == EPERM) {
+diff --git a/qtbase/src/corelib/thread/qthread_win.cpp b/qtbase/src/corelib/thread/qthread_win.cpp
+index bc70e3178a..4e76972498 100644
+--- a/qtbase/src/corelib/thread/qthread_win.cpp
++++ b/qtbase/src/corelib/thread/qthread_win.cpp
+@@ -394,10 +394,9 @@ unsigned int __stdcall QT_ENSURE_STACK_ALIGNED_FOR_SSE QThreadPrivate::start(voi
+ 
+ #if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) && !defined(Q_OS_WINRT)
+     // sets the name of the current thread.
+-    QByteArray objectName = thr->objectName().toLocal8Bit();
+-    qt_set_thread_name(HANDLE(-1),
+-                       objectName.isEmpty() ?
+-                       thr->metaObject()->className() : objectName.constData());
++    qt_set_thread_name(HANDLE(-1), thr->d_func()->objectName.isEmpty()
++                        ? thr->metaObject()->className()
++                        : std::exchange(thr->d_func()->objectName, {}).toLocal8Bit().constData());
+ #endif
+ 
+     emit thr->started(QThread::QPrivateSignal());
+@@ -503,6 +502,7 @@ void QThread::start(Priority priority)
+     if (d->running)
+         return;
+ 
++    d->objectName = objectName();
+     d->running = true;
+     d->finished = false;
+     d->exited = false;
+@@ -548,7 +548,7 @@ void QThread::start(Priority priority)
+ 
+     int prio;
+     d->priority = priority;
+-    switch (d->priority) {
++    switch (priority) {
+     case IdlePriority:
+         prio = THREAD_PRIORITY_IDLE;
+         break;
+@@ -686,7 +686,7 @@ void QThreadPrivate::setPriority(QThread::Priority threadPriority)
+ 
+     int prio;
+     priority = threadPriority;
+-    switch (priority) {
++    switch (threadPriority) {
+     case QThread::IdlePriority:
+         prio = THREAD_PRIORITY_IDLE;
+         break;
+diff --git a/qtbase/src/corelib/thread/qtsan_impl.h b/qtbase/src/corelib/thread/qtsan_impl.h
+new file mode 100644
+index 0000000000..580a738b91
+--- /dev/null
++++ b/qtbase/src/corelib/thread/qtsan_impl.h
+@@ -0,0 +1,115 @@
++/****************************************************************************
++**
++** Copyright (C) 2017 Intel Corporation.
++** Copyright (C) 2022 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
++** 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 QTSAN_IMPL_H
++#define QTSAN_IMPL_H
++
++#include <QtCore/qglobal.h>
++
++#if (__has_feature(thread_sanitizer) || defined(__SANITIZE_THREAD__)) && __has_include(<sanitizer/tsan_interface.h>)
++#  define QT_BUILDING_UNDER_TSAN
++#  include <sanitizer/tsan_interface.h>
++#endif
++
++QT_BEGIN_NAMESPACE
++
++namespace QtTsan {
++#ifdef QT_BUILDING_UNDER_TSAN
++inline void futexAcquire(void *addr, void *addr2 = nullptr)
++{
++    // A futex call ensures total ordering on the futex words
++    // (in either success or failure of the call). Instruct TSAN accordingly,
++    // as TSAN does not understand the futex(2) syscall (or equivalent).
++    ::__tsan_acquire(addr);
++    if (addr2)
++        ::__tsan_acquire(addr2);
++}
++
++inline void futexRelease(void *addr, void *addr2 = nullptr)
++{
++    if (addr2)
++        ::__tsan_release(addr2);
++    ::__tsan_release(addr);
++}
++
++inline void mutexPreLock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_pre_lock(addr, flags);
++}
++
++inline void mutexPostLock(void *addr, unsigned flags, int recursion)
++{
++    ::__tsan_mutex_post_lock(addr, flags, recursion);
++}
++
++inline void mutexPreUnlock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_pre_unlock(addr, flags);
++}
++
++inline void mutexPostUnlock(void *addr, unsigned flags)
++{
++    ::__tsan_mutex_post_unlock(addr, flags);
++}
++
++enum : unsigned {
++    MutexWriteReentrant = ::__tsan_mutex_write_reentrant,
++    TryLock = ::__tsan_mutex_try_lock,
++    TryLockFailed = ::__tsan_mutex_try_lock_failed,
++};
++#else
++inline void futexAcquire(void *, void * = nullptr) {}
++inline void futexRelease(void *, void * = nullptr) {}
++
++enum : unsigned {
++    MutexWriteReentrant,
++    TryLock,
++    TryLockFailed,
++};
++inline void mutexPreLock(void *, unsigned) {}
++inline void mutexPostLock(void *, unsigned, int) {}
++inline void mutexPreUnlock(void *, unsigned) {}
++inline void mutexPostUnlock(void *, unsigned) {}
++#endif // QT_BUILDING_UNDER_TSAN
++} // namespace QtTsan
++
++QT_END_NAMESPACE
++
++#endif // QTSAN_IMPL_H
+diff --git a/qtbase/src/corelib/thread/qwaitcondition_unix.cpp b/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
+index 88b058f410..0f1da4dc9b 100644
+--- a/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
++++ b/qtbase/src/corelib/thread/qwaitcondition_unix.cpp
+@@ -213,7 +213,7 @@ bool QWaitCondition::wait(QMutex *mutex, QDeadlineTimer deadline)
+ {
+     if (! mutex)
+         return false;
+-    if (mutex->isRecursive()) {
++    if (static_cast<QBasicMutex *>(mutex)->isRecursive()) {
+         qWarning("QWaitCondition: cannot wait on recursive mutexes");
+         return false;
+     }
+diff --git a/qtbase/src/corelib/time/qdatetime.cpp b/qtbase/src/corelib/time/qdatetime.cpp
+index ec12569e3f..2c0b098079 100644
+--- a/qtbase/src/corelib/time/qdatetime.cpp
++++ b/qtbase/src/corelib/time/qdatetime.cpp
+@@ -43,6 +43,7 @@
+ #if QT_CONFIG(datetimeparser)
+ #include "private/qdatetimeparser_p.h"
+ #endif
++#include <private/qnumeric_p.h>
+ 
+ #include "qdatastream.h"
+ #include "qset.h"
+@@ -1429,9 +1430,11 @@ QDate QDate::addDays(qint64 ndays) const
+     if (isNull())
+         return QDate();
+ 
+-    // Due to limits on minJd() and maxJd() we know that any overflow
+-    // will be invalid and caught by fromJulianDay().
+-    return fromJulianDay(jd + ndays);
++    qint64 r;
++    if (Q_UNLIKELY(add_overflow(jd, ndays, &r)))
++        return QDate();
++    else
++        return fromJulianDay(r);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/corelib/time/qtimezone.cpp b/qtbase/src/corelib/time/qtimezone.cpp
+index 0309e43e52..3d451696a1 100644
+--- a/qtbase/src/corelib/time/qtimezone.cpp
++++ b/qtbase/src/corelib/time/qtimezone.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2013 John Layt <jlayt@kde.org>
++** Copyright (C) 2020 John Layt <jlayt@kde.org>
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtCore module of the Qt Toolkit.
+@@ -975,9 +975,15 @@ QList<QByteArray> QTimeZone::windowsIdToIanaIds(const QByteArray &windowsId,
+ }
+ 
+ #ifndef QT_NO_DATASTREAM
++// Invalid, as an IANA ID: too long, starts with - and has other invalid characters in it
++static inline QString invalidId() { return QStringLiteral("-No Time Zone Specified!"); }
++
+ QDataStream &operator<<(QDataStream &ds, const QTimeZone &tz)
+ {
+-    tz.d->serialize(ds);
++    if (tz.isValid())
++        tz.d->serialize(ds);
++    else
++        ds << invalidId();
+     return ds;
+ }
+ 
+@@ -985,7 +991,9 @@ QDataStream &operator>>(QDataStream &ds, QTimeZone &tz)
+ {
+     QString ianaId;
+     ds >> ianaId;
+-    if (ianaId == QLatin1String("OffsetFromUtc")) {
++    if (ianaId == invalidId()) {
++        tz = QTimeZone();
++    } else if (ianaId == QLatin1String("OffsetFromUtc")) {
+         int utcOffset;
+         QString name;
+         QString abbreviation;
+diff --git a/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp b/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
+index b1611d7ddb..a7a6a72ccf 100644
+--- a/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
++++ b/qtbase/src/corelib/time/qtimezoneprivate_tz.cpp
+@@ -42,6 +42,7 @@
+ #include "qtimezone.h"
+ #include "qtimezoneprivate_p.h"
+ #include "private/qlocale_tools_p.h"
++#include "private/qlocking_p.h"
+ 
+ #include <QtCore/QDataStream>
+ #include <QtCore/QDateTime>
+@@ -62,6 +63,10 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++#if QT_CONFIG(icu)
++static QBasicMutex s_icu_mutex;
++#endif
++
+ /*
+     Private
+ 
+@@ -670,6 +675,9 @@ QTzTimeZonePrivate::~QTzTimeZonePrivate()
+ 
+ QTzTimeZonePrivate *QTzTimeZonePrivate::clone() const
+ {
++#if QT_CONFIG(icu)
++    const auto lock = qt_scoped_lock(s_icu_mutex);
++#endif
+     return new QTzTimeZonePrivate(*this);
+ }
+ 
+@@ -913,12 +921,14 @@ QString QTzTimeZonePrivate::displayName(qint64 atMSecsSinceEpoch,
+                                         const QLocale &locale) const
+ {
+ #if QT_CONFIG(icu)
++    auto lock = qt_unique_lock(s_icu_mutex);
+     if (!m_icu)
+         m_icu = new QIcuTimeZonePrivate(m_id);
+     // TODO small risk may not match if tran times differ due to outdated files
+     // TODO Some valid TZ names are not valid ICU names, use translation table?
+     if (m_icu->isValid())
+         return m_icu->displayName(atMSecsSinceEpoch, nameType, locale);
++    lock.unlock();
+ #else
+     Q_UNUSED(nameType)
+     Q_UNUSED(locale)
+@@ -932,12 +942,14 @@ QString QTzTimeZonePrivate::displayName(QTimeZone::TimeType timeType,
+                                         const QLocale &locale) const
+ {
+ #if QT_CONFIG(icu)
++    auto lock = qt_unique_lock(s_icu_mutex);
+     if (!m_icu)
+         m_icu = new QIcuTimeZonePrivate(m_id);
+     // TODO small risk may not match if tran times differ due to outdated files
+     // TODO Some valid TZ names are not valid ICU names, use translation table?
+     if (m_icu->isValid())
+         return m_icu->displayName(timeType, nameType, locale);
++    lock.unlock();
+ #else
+     Q_UNUSED(timeType)
+     Q_UNUSED(nameType)
+diff --git a/qtbase/src/corelib/tools/qarraydata.h b/qtbase/src/corelib/tools/qarraydata.h
+index dcd95924c1..d01739e7e6 100644
+--- a/qtbase/src/corelib/tools/qarraydata.h
++++ b/qtbase/src/corelib/tools/qarraydata.h
+@@ -42,6 +42,7 @@
+ 
+ #include <QtCore/qrefcount.h>
+ #include <string.h>
++#include <cstdint>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -58,14 +59,14 @@ struct Q_CORE_EXPORT QArrayData
+     {
+         Q_ASSERT(size == 0
+                 || offset < 0 || size_t(offset) >= sizeof(QArrayData));
+-        return reinterpret_cast<char *>(this) + offset;
++        return reinterpret_cast<void *> (reinterpret_cast<uintptr_t>(this) + offset);
+     }
+ 
+     const void *data() const
+     {
+         Q_ASSERT(size == 0
+                 || offset < 0 || size_t(offset) >= sizeof(QArrayData));
+-        return reinterpret_cast<const char *>(this) + offset;
++        return reinterpret_cast<void *> (reinterpret_cast<uintptr_t>(this) + offset);
+     }
+ 
+     // This refers to array data mutability, not "header data" represented by
+diff --git a/qtbase/src/corelib/tools/qfreelist_p.h b/qtbase/src/corelib/tools/qfreelist_p.h
+index 5ba23b344b..9974102136 100644
+--- a/qtbase/src/corelib/tools/qfreelist_p.h
++++ b/qtbase/src/corelib/tools/qfreelist_p.h
+@@ -161,7 +161,7 @@ class QFreeList
+                 return i;
+             x -= size;
+         }
+-        Q_ASSERT(false);
++        Q_UNREACHABLE();
+         return -1;
+     }
+ 
+diff --git a/qtbase/src/corelib/tools/qversionnumber.h b/qtbase/src/corelib/tools/qversionnumber.h
+index d43b86ba51..2843f2b043 100644
+--- a/qtbase/src/corelib/tools/qversionnumber.h
++++ b/qtbase/src/corelib/tools/qversionnumber.h
+@@ -273,10 +273,10 @@ public:
+ 
+     Q_REQUIRED_RESULT Q_CORE_EXPORT QString toString() const;
+ #if QT_STRINGVIEW_LEVEL < 2
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(const QString &string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(const QString &string, int *suffixIndex = nullptr);
+ #endif
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QLatin1String string, int *suffixIndex = nullptr);
+-    Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QStringView string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(QLatin1String string, int *suffixIndex = nullptr);
++    Q_REQUIRED_RESULT Q_CORE_EXPORT static QVersionNumber fromString(QStringView string, int *suffixIndex = nullptr);
+ 
+ private:
+ #ifndef QT_NO_DATASTREAM
+diff --git a/qtbase/src/dbus/qdbusintegrator.cpp b/qtbase/src/dbus/qdbusintegrator.cpp
+index 5b66ce971b..28a3b0ffea 100644
+--- a/qtbase/src/dbus/qdbusintegrator.cpp
++++ b/qtbase/src/dbus/qdbusintegrator.cpp
+@@ -1135,7 +1135,13 @@ void QDBusConnectionPrivate::closeConnection()
+         }
+     }
+ 
+-    qDeleteAll(pendingCalls);
++    for (auto it = pendingCalls.begin(); it != pendingCalls.end(); ++it) {
++        auto call = *it;
++        if (!call->ref.deref()) {
++            delete call;
++        }
++    }
++    pendingCalls.clear();
+ 
+     // Disconnect all signals from signal hooks and from the object tree to
+     // avoid QObject::destroyed being sent to dbus daemon thread which has
+@@ -2584,6 +2590,11 @@ QDBusConnectionPrivate::findMetaObject(const QString &service, const QString &pa
+         if (mo)
+             return mo;
+     }
++    if (path.isEmpty()) {
++        error = QDBusError(QDBusError::InvalidObjectPath, QLatin1String("Object path cannot be empty"));
++        lastError = error;
++        return nullptr;
++    }
+ 
+     // introspect the target object
+     QDBusMessage msg = QDBusMessage::createMethodCall(service, path,
+diff --git a/qtbase/src/dbus/qdbusmetaobject.cpp b/qtbase/src/dbus/qdbusmetaobject.cpp
+index 5265568f42..7e9f0f1acc 100644
+--- a/qtbase/src/dbus/qdbusmetaobject.cpp
++++ b/qtbase/src/dbus/qdbusmetaobject.cpp
+@@ -210,6 +210,9 @@ QDBusMetaObjectGenerator::findType(const QByteArray &signature,
+         } else if (signature == "a{ss}") {
+             result.name = "QMap<QString,QString>";
+             type = qMetaTypeId<QMap<QString, QString> >();
++        } else if (signature == "aay") {
++            result.name = "QByteArrayList";
++            type = qMetaTypeId<QByteArrayList>();
+         } else {
+             result.name = "{D-Bus type \"" + signature + "\"}";
+             type = registerComplexDBusType(result.name);
+diff --git a/qtbase/src/gui/accessible/qaccessible.cpp b/qtbase/src/gui/accessible/qaccessible.cpp
+index d705bfccb5..0caf3c808c 100644
+--- a/qtbase/src/gui/accessible/qaccessible.cpp
++++ b/qtbase/src/gui/accessible/qaccessible.cpp
+@@ -54,6 +54,7 @@
+ #include <QtCore/qdebug.h>
+ #include <QtCore/qloggingcategory.h>
+ #include <QtCore/qmetaobject.h>
++#include <QtCore/private/qmetaobject_p.h>
+ #include <QtCore/qhash.h>
+ #include <private/qfactoryloader_p.h>
+ 
+@@ -681,6 +682,25 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
+     // Create a QAccessibleInterface for the object class. Start by the most
+     // derived class and walk up the class hierarchy.
+     const QMetaObject *mo = object->metaObject();
++    const auto *objectPriv = QObjectPrivate::get(object);
++    /*
++     We do not want to cache each and every QML metaobject (Button_QMLTYPE_124,
++     Button_QMLTYPE_125, etc.). Those dynamic metaobjects shouldn't have an
++     accessible interface in any case. Instead, we start the whole checking
++     with the first non-dynamic meta-object. To avoid potential regressions
++     in other areas of Qt that also use dynamic metaobjects, we only do this
++     for objects that are QML-related (approximated by checking whether they
++     have ddata set).
++    */
++    const bool qmlRelated = !objectPriv->isDeletingChildren &&
++                            objectPriv->declarativeData;
++    while (qmlRelated && mo) {
++        auto mop = QMetaObjectPrivate::get(mo);
++        if (!mop || !(mop->flags & DynamicMetaObject))
++            break;
++
++        mo = mo->superClass();
++    };
+     while (mo) {
+         const QString cn = QLatin1String(mo->className());
+ 
+@@ -696,14 +716,15 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object)
+         // Find a QAccessiblePlugin (factory) for the class name. If there's
+         // no entry in the cache try to create it using the plugin loader.
+         if (!qAccessiblePlugins()->contains(cn)) {
++            QAccessiblePlugin *factory = nullptr; // 0 means "no plugin found". This is cached as well.
+             const int index = loader()->indexOf(cn);
+-            if (index != -1) {
+-                QAccessiblePlugin *factory = qobject_cast<QAccessiblePlugin *>(loader()->instance(index));
+-                qAccessiblePlugins()->insert(cn, factory);
+-            }
++            if (index != -1)
++                factory = qobject_cast<QAccessiblePlugin *>(loader()->instance(index));
++            qAccessiblePlugins()->insert(cn, factory);
+         }
+ 
+         // At this point the cache should contain a valid factory pointer or 0:
++        Q_ASSERT(qAccessiblePlugins()->contains(cn));
+         QAccessiblePlugin *factory = qAccessiblePlugins()->value(cn);
+         if (factory) {
+             QAccessibleInterface *result = factory->create(cn, object);
+diff --git a/qtbase/src/gui/configure.json b/qtbase/src/gui/configure.json
+index 1f08795c57..12c95742d2 100644
+--- a/qtbase/src/gui/configure.json
++++ b/qtbase/src/gui/configure.json
+@@ -834,7 +834,8 @@
+                     "// embedded devices, are not intended to be used together with X. EGL support",
+                     "// has to be disabled in plugins like xcb in this case since the native display,",
+                     "// window and pixmap types will be different than what an X-based platform",
+-                    "// plugin would expect."
++                    "// plugin would expect.",
++                    "#define USE_X11"
+                 ],
+                 "include": [ "EGL/egl.h", "X11/Xlib.h" ],
+                 "main": [
+diff --git a/qtbase/src/gui/image/qbmphandler.cpp b/qtbase/src/gui/image/qbmphandler.cpp
+index 96f1e8cb1d..0e73bbbdb0 100644
+--- a/qtbase/src/gui/image/qbmphandler.cpp
++++ b/qtbase/src/gui/image/qbmphandler.cpp
+@@ -150,16 +150,42 @@ static QDataStream &operator<<(QDataStream &s, const BMP_INFOHDR &bi)
+     return s;
+ }
+ 
+-static int calc_shift(uint mask)
++static uint calc_shift(uint mask)
+ {
+-    int result = 0;
+-    while (mask && !(mask & 1)) {
++    uint result = 0;
++    while ((mask >= 0x100) || (!(mask & 1) && mask)) {
+         result++;
+         mask >>= 1;
+     }
+     return result;
+ }
+ 
++static uint calc_scale(uint low_mask)
++{
++    uint result = 8;
++    while (low_mask && result) {
++        result--;
++        low_mask >>= 1;
++    }
++    return result;
++}
++
++static inline uint apply_scale(uint value, uint scale)
++{
++    if (!(scale & 0x07)) // return immediately if scale == 8 or 0
++        return value;
++
++    uint filled = 8 - scale;
++    uint result = value << scale;
++
++    do {
++        result |= result >> filled;
++        filled <<= 1;
++    } while (filled < 8);
++
++    return result;
++}
++
+ static bool read_dib_fileheader(QDataStream &s, BMP_FILEHDR &bf)
+ {
+     // read BMP file header
+@@ -222,14 +248,14 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+     uint green_mask = 0;
+     uint blue_mask = 0;
+     uint alpha_mask = 0;
+-    int red_shift = 0;
+-    int green_shift = 0;
+-    int blue_shift = 0;
+-    int alpha_shift = 0;
+-    int red_scale = 0;
+-    int green_scale = 0;
+-    int blue_scale = 0;
+-    int alpha_scale = 0;
++    uint red_shift = 0;
++    uint green_shift = 0;
++    uint blue_shift = 0;
++    uint alpha_shift = 0;
++    uint red_scale = 0;
++    uint green_scale = 0;
++    uint blue_scale = 0;
++    uint alpha_scale = 0;
+ 
+     if (!d->isSequential())
+         d->seek(startpos + BMP_FILEHDR_SIZE + bi.biSize); // goto start of colormap or masks
+@@ -308,19 +334,19 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+         red_shift = calc_shift(red_mask);
+         if (((red_mask >> red_shift) + 1) == 0)
+             return false;
+-        red_scale = 256 / ((red_mask >> red_shift) + 1);
++        red_scale = calc_scale(red_mask >> red_shift);
+         green_shift = calc_shift(green_mask);
+         if (((green_mask >> green_shift) + 1) == 0)
+             return false;
+-        green_scale = 256 / ((green_mask >> green_shift) + 1);
++        green_scale = calc_scale(green_mask >> green_shift);
+         blue_shift = calc_shift(blue_mask);
+         if (((blue_mask >> blue_shift) + 1) == 0)
+             return false;
+-        blue_scale = 256 / ((blue_mask >> blue_shift) + 1);
++        blue_scale = calc_scale(blue_mask >> blue_shift);
+         alpha_shift = calc_shift(alpha_mask);
+         if (((alpha_mask >> alpha_shift) + 1) == 0)
+             return false;
+-        alpha_scale = 256 / ((alpha_mask >> alpha_shift) + 1);
++        alpha_scale = calc_scale(alpha_mask >> alpha_shift);
+     } else if (comp == BMP_RGB && (nbits == 24 || nbits == 32)) {
+         blue_mask = 0x000000ff;
+         green_mask = 0x0000ff00;
+@@ -328,17 +354,15 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+         blue_shift = 0;
+         green_shift = 8;
+         red_shift = 16;
+-        blue_scale = green_scale = red_scale = 1;
++        blue_scale = green_scale = red_scale = 0;
+     } else if (comp == BMP_RGB && nbits == 16) {
+         blue_mask = 0x001f;
+         green_mask = 0x03e0;
+         red_mask = 0x7c00;
+         blue_shift = 0;
+-        green_shift = 2;
+-        red_shift = 7;
+-        red_scale = 1;
+-        green_scale = 1;
+-        blue_scale = 8;
++        green_shift = 5;
++        red_shift = 10;
++        blue_scale = green_scale = red_scale = 3;
+     }
+ 
+ #if 0
+@@ -544,10 +568,10 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset,
+                     c |= *(uchar*)(b+2)<<16;
+                 if (nbits > 24)
+                     c |= *(uchar*)(b+3)<<24;
+-                *p++ = qRgba(((c & red_mask) >> red_shift) * red_scale,
+-                                        ((c & green_mask) >> green_shift) * green_scale,
+-                                        ((c & blue_mask) >> blue_shift) * blue_scale,
+-                                        transp ? ((c & alpha_mask) >> alpha_shift) * alpha_scale : 0xff);
++                *p++ = qRgba(apply_scale((c & red_mask) >> red_shift, red_scale),
++                             apply_scale((c & green_mask) >> green_shift, green_scale),
++                             apply_scale((c & blue_mask) >> blue_shift, blue_scale),
++                             transp ? apply_scale((c & alpha_mask) >> alpha_shift, alpha_scale) : 0xff);
+                 b += nbits/8;
+             }
+         }
+diff --git a/qtbase/src/gui/image/qimage.cpp b/qtbase/src/gui/image/qimage.cpp
+index 7152ac1607..0df772564c 100644
+--- a/qtbase/src/gui/image/qimage.cpp
++++ b/qtbase/src/gui/image/qimage.cpp
+@@ -4694,6 +4694,8 @@ QImage QImage::smoothScaled(int w, int h) const {
+ static QImage rotated90(const QImage &image)
+ {
+     QImage out(image.height(), image.width(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+@@ -4722,6 +4724,8 @@ static QImage rotated180(const QImage &image)
+         return image.mirrored(true, true);
+ 
+     QImage out(image.width(), image.height(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+@@ -4734,6 +4738,8 @@ static QImage rotated180(const QImage &image)
+ static QImage rotated270(const QImage &image)
+ {
+     QImage out(image.height(), image.width(), image.format());
++    if (out.isNull())
++        return out;
+     copyMetadata(&out, image);
+     if (image.colorCount() > 0)
+         out.setColorTable(image.colorTable());
+diff --git a/qtbase/src/gui/kernel/qcursor.cpp b/qtbase/src/gui/kernel/qcursor.cpp
+index d6ccaff8ed..455088241c 100644
+--- a/qtbase/src/gui/kernel/qcursor.cpp
++++ b/qtbase/src/gui/kernel/qcursor.cpp
+@@ -251,7 +251,8 @@ void QCursor::setPos(QScreen *screen, int x, int y)
+ {
+     if (screen) {
+         if (QPlatformCursor *cursor = screen->handle()->cursor()) {
+-            const QPoint devicePos = QHighDpi::toNativePixels(QPoint(x, y), screen);
++            const QPoint pos(x, y);
++            const QPoint devicePos = QHighDpi::toNativePixels(pos, screen->virtualSiblingAt(pos));
+             // Need to check, since some X servers generate null mouse move
+             // events, causing looping in applications which call setPos() on
+             // every mouse move event.
+diff --git a/qtbase/src/gui/kernel/qhighdpiscaling.cpp b/qtbase/src/gui/kernel/qhighdpiscaling.cpp
+index 9bbf2773a9..3ac4a4d8b6 100644
+--- a/qtbase/src/gui/kernel/qhighdpiscaling.cpp
++++ b/qtbase/src/gui/kernel/qhighdpiscaling.cpp
+@@ -580,9 +580,8 @@ void QHighDpiScaling::setScreenFactor(QScreen *screen, qreal factor)
+     else
+         qNamedScreenScaleFactors()->insert(name, factor);
+ 
+-    // hack to force re-evaluation of screen geometry
+     if (screen->handle())
+-        screen->d_func()->setPlatformScreen(screen->handle()); // updates geometries based on scale factor
++        screen->d_func()->updateLogicalDpi();
+ }
+ 
+ QPoint QHighDpiScaling::mapPositionToNative(const QPoint &pos, const QPlatformScreen *platformScreen)
+diff --git a/qtbase/src/gui/kernel/qkeysequence.cpp b/qtbase/src/gui/kernel/qkeysequence.cpp
+index a75b8ef920..4f2d294739 100644
+--- a/qtbase/src/gui/kernel/qkeysequence.cpp
++++ b/qtbase/src/gui/kernel/qkeysequence.cpp
+@@ -701,6 +701,10 @@ static const struct {
+     { Qt::Key_TouchpadToggle,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad Toggle") },
+     { Qt::Key_TouchpadOn,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad On") },
+     { Qt::Key_TouchpadOff,  QT_TRANSLATE_NOOP("QShortcut", "Touchpad Off") },
++    { Qt::Key_Shift,  QT_TRANSLATE_NOOP("QShortcut", "Shift") },
++    { Qt::Key_Control,  QT_TRANSLATE_NOOP("QShortcut", "Control") },
++    { Qt::Key_Alt,  QT_TRANSLATE_NOOP("QShortcut", "Alt") },
++    { Qt::Key_Meta,  QT_TRANSLATE_NOOP("QShortcut", "Meta") },
+ 
+ };
+ static Q_CONSTEXPR int numKeyNames = sizeof keyname / sizeof *keyname;
+diff --git a/qtbase/src/gui/kernel/qplatformservices.cpp b/qtbase/src/gui/kernel/qplatformservices.cpp
+index fdc6a6c4aa..ac47f98c5d 100644
+--- a/qtbase/src/gui/kernel/qplatformservices.cpp
++++ b/qtbase/src/gui/kernel/qplatformservices.cpp
+@@ -55,6 +55,19 @@ QT_BEGIN_NAMESPACE
+     \brief The QPlatformServices provides the backend for desktop-related functionality.
+ */
+ 
++/*!
++    \enum QPlatformServices::Capability
++
++    Capabilities are used to determine a specific platform service's availability.
++
++    \value ColorPickingFromScreen The platform natively supports color picking from screen.
++    This capability indicates that the platform supports "opaque" color picking, where the
++    platform implements a complete user experience for color picking and outputs a color.
++    This is in contrast to the application implementing the color picking user experience
++    (taking care of showing a cross hair, instructing the platform integration to obtain
++    the color at a given pixel, etc.). The related service function is pickColor().
++ */
++
+ QPlatformServices::QPlatformServices()
+ { }
+ 
+@@ -85,5 +98,16 @@ QByteArray QPlatformServices::desktopEnvironment() const
+     return QByteArray("UNKNOWN");
+ }
+ 
++QPlatformServiceColorPicker *QPlatformServices::colorPicker(QWindow *parent)
++{
++    Q_UNUSED(parent);
++    return nullptr;
++}
++
++bool QPlatformServices::hasCapability(Capability capability) const
++{
++    Q_UNUSED(capability)
++    return false;
++}
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/gui/kernel/qplatformservices.h b/qtbase/src/gui/kernel/qplatformservices.h
+index 5de96cfa7d..a8b2a4ce71 100644
+--- a/qtbase/src/gui/kernel/qplatformservices.h
++++ b/qtbase/src/gui/kernel/qplatformservices.h
+@@ -50,16 +50,32 @@
+ //
+ 
+ #include <QtGui/qtguiglobal.h>
++#include <QtCore/qobject.h>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+ class QUrl;
++class QWindow;
++
++class Q_GUI_EXPORT QPlatformServiceColorPicker : public QObject
++{
++    Q_OBJECT
++public:
++    using QObject::QObject;
++    virtual void pickColor() = 0;
++Q_SIGNALS:
++    void colorPicked(const QColor &color);
++};
+ 
+ class Q_GUI_EXPORT QPlatformServices
+ {
+ public:
+     Q_DISABLE_COPY_MOVE(QPlatformServices)
+ 
++    enum Capability {
++        ColorPicking,
++    };
++
+     QPlatformServices();
+     virtual ~QPlatformServices() { }
+ 
+@@ -67,6 +83,10 @@ public:
+     virtual bool openDocument(const QUrl &url);
+ 
+     virtual QByteArray desktopEnvironment() const;
++
++    virtual bool hasCapability(Capability capability) const;
++
++    virtual QPlatformServiceColorPicker *colorPicker(QWindow *parent = nullptr);
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/gui/kernel/qplatformtheme.cpp b/qtbase/src/gui/kernel/qplatformtheme.cpp
+index 71521c0339..2325873245 100644
+--- a/qtbase/src/gui/kernel/qplatformtheme.cpp
++++ b/qtbase/src/gui/kernel/qplatformtheme.cpp
+@@ -163,6 +163,8 @@ QT_BEGIN_NAMESPACE
+ 
+     \value ShowShortcutsInContextMenus (bool) Whether to display shortcut key sequences in context menus.
+ 
++    \value ButtonPressKeys (QList<Qt::Key>) A list of keys that can be used to press buttons via keyboard input.
++
+     \sa themeHint(), QStyle::pixelMetric()
+ */
+ 
+@@ -563,6 +565,8 @@ QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint)
+         }
+     case MouseQuickSelectionThreshold:
+         return QVariant(10);
++    case ButtonPressKeys:
++        return QVariant::fromValue(QList<Qt::Key>({ Qt::Key_Space, Qt::Key_Select }));
+     }
+     return QVariant();
+ }
+diff --git a/qtbase/src/gui/kernel/qplatformtheme.h b/qtbase/src/gui/kernel/qplatformtheme.h
+index 3185fc4541..7e6c9d5740 100644
+--- a/qtbase/src/gui/kernel/qplatformtheme.h
++++ b/qtbase/src/gui/kernel/qplatformtheme.h
+@@ -120,7 +120,8 @@ public:
+         TouchDoubleTapDistance,
+         ShowShortcutsInContextMenus,
+         IconFallbackSearchPaths,
+-        MouseQuickSelectionThreshold
++        MouseQuickSelectionThreshold,
++        ButtonPressKeys
+     };
+ 
+     enum DialogType {
+diff --git a/qtbase/src/gui/kernel/qscreen.cpp b/qtbase/src/gui/kernel/qscreen.cpp
+index 8e0eb35116..5d172a58dd 100644
+--- a/qtbase/src/gui/kernel/qscreen.cpp
++++ b/qtbase/src/gui/kernel/qscreen.cpp
+@@ -77,6 +77,12 @@ QScreen::QScreen(QPlatformScreen *screen)
+     d->setPlatformScreen(screen);
+ }
+ 
++void QScreenPrivate::updateLogicalDpi()
++{
++    logicalDpi = QPlatformScreen::overrideDpi(platformScreen->logicalDpi());
++    updateGeometriesWithSignals(); // updates geometries based on scale factor
++}
++
+ void QScreenPrivate::updateGeometriesWithSignals()
+ {
+     const QRect oldGeometry = geometry;
+diff --git a/qtbase/src/gui/kernel/qscreen_p.h b/qtbase/src/gui/kernel/qscreen_p.h
+index 7da542c25e..e50fc3190b 100644
+--- a/qtbase/src/gui/kernel/qscreen_p.h
++++ b/qtbase/src/gui/kernel/qscreen_p.h
+@@ -70,6 +70,7 @@ public:
+         geometry = platformScreen->deviceIndependentGeometry();
+         availableGeometry = QHighDpi::fromNative(platformScreen->availableGeometry(), QHighDpiScaling::factor(platformScreen), geometry.topLeft());
+     }
++    void updateLogicalDpi();
+ 
+     void updatePrimaryOrientation();
+     void updateGeometriesWithSignals();
+diff --git a/qtbase/src/gui/painting/qblendfunctions_p.h b/qtbase/src/gui/painting/qblendfunctions_p.h
+index 080da98ec4..6997d62b3c 100644
+--- a/qtbase/src/gui/painting/qblendfunctions_p.h
++++ b/qtbase/src/gui/painting/qblendfunctions_p.h
+@@ -246,25 +246,32 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+                                   int dudx, int dvdx, int dudy, int dvdy, int u0, int v0,
+                                   Blender blender)
+ {
+-    int fromY = qMax(qRound(topY), clip.top());
+-    int toY = qMin(qRound(bottomY), clip.top() + clip.height());
++    qint64 fromY = qMax(qRound(topY), clip.top());
++    qint64 toY = qMin(qRound(bottomY), clip.top() + clip.height());
+     if (fromY >= toY)
+         return;
+ 
+     qreal leftSlope = (bottomLeft.x - topLeft.x) / (bottomLeft.y - topLeft.y);
+     qreal rightSlope = (bottomRight.x - topRight.x) / (bottomRight.y - topRight.y);
+-    int dx_l = int(leftSlope * 0x10000);
+-    int dx_r = int(rightSlope * 0x10000);
+-    int x_l = int((topLeft.x + (qreal(0.5) + fromY - topLeft.y) * leftSlope + qreal(0.5)) * 0x10000);
+-    int x_r = int((topRight.x + (qreal(0.5) + fromY - topRight.y) * rightSlope + qreal(0.5)) * 0x10000);
+-
+-    int fromX, toX, x1, x2, u, v, i, ii;
++    qint64 dx_l = qint64(leftSlope * 0x10000);
++    qint64 dx_r = qint64(rightSlope * 0x10000);
++    qint64 x_l = qint64((topLeft.x + (qreal(0.5) + fromY - topLeft.y) * leftSlope + qreal(0.5)) * 0x10000);
++    qint64 x_r = qint64((topRight.x + (qreal(0.5) + fromY - topRight.y) * rightSlope + qreal(0.5)) * 0x10000);
++
++    qint64 sourceRectTop = qint64(sourceRect.top());
++    qint64 sourceRectLeft = qint64(sourceRect.left());
++    qint64 sourceRectWidth = qint64(sourceRect.width());
++    qint64 sourceRectHeight = qint64(sourceRect.height());
++    qint64 clipLeft = qint64(clip.left());
++    qint64 clipWidth = qint64(clip.width());
++
++    qint64 fromX, toX, x1, x2, u, v, i, ii;
+     DestT *line;
+-    for (int y = fromY; y < toY; ++y) {
++    for (qint64 y = fromY; y < toY; ++y) {
+         line = reinterpret_cast<DestT *>(reinterpret_cast<uchar *>(destPixels) + y * dbpl);
+ 
+-        fromX = qMax(x_l >> 16, clip.left());
+-        toX = qMin(x_r >> 16, clip.left() + clip.width());
++        fromX = qMax(x_l >> 16, clipLeft);
++        toX = qMin(x_r >> 16, clipLeft + clipWidth);
+         if (fromX < toX) {
+             // Because of rounding, we can get source coordinates outside the source image.
+             // Clamp these coordinates to the source rect to avoid segmentation fault and
+@@ -275,10 +282,10 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             u = x1 * dudx + y * dudy + u0;
+             v = x1 * dvdx + y * dvdy + v0;
+             for (; x1 < toX; ++x1) {
+-                int uu = u >> 16;
+-                int vv = v >> 16;
+-                if (uu >= sourceRect.left() && uu < sourceRect.left() + sourceRect.width()
+-                    && vv >= sourceRect.top() && vv < sourceRect.top() + sourceRect.height()) {
++                qint64 uu = u >> 16;
++                qint64 vv = v >> 16;
++                if (uu >= sourceRectLeft && uu < sourceRectLeft + sourceRectWidth
++                    && vv >= sourceRectTop && vv < sourceRectTop + sourceRectHeight) {
+                     break;
+                 }
+                 u += dudx;
+@@ -290,10 +297,10 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             u = (x2 - 1) * dudx + y * dudy + u0;
+             v = (x2 - 1) * dvdx + y * dvdy + v0;
+             for (; x2 > x1; --x2) {
+-                int uu = u >> 16;
+-                int vv = v >> 16;
+-                if (uu >= sourceRect.left() && uu < sourceRect.left() + sourceRect.width()
+-                    && vv >= sourceRect.top() && vv < sourceRect.top() + sourceRect.height()) {
++                qint64 uu = u >> 16;
++                qint64 vv = v >> 16;
++                if (uu >= sourceRectLeft && uu < sourceRectLeft + sourceRectWidth
++                    && vv >= sourceRectTop && vv < sourceRectTop + sourceRectHeight) {
+                     break;
+                 }
+                 u -= dudx;
+@@ -308,8 +315,8 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             // Beginning of the scan line, with per-pixel checks.
+             i = x1 - fromX;
+             while (i) {
+-                int uu = qBound(sourceRect.left(), u >> 16, sourceRect.left() + sourceRect.width() - 1);
+-                int vv = qBound(sourceRect.top(), v >> 16, sourceRect.top() + sourceRect.height() - 1);
++                qint64 uu = qBound(sourceRectLeft, u >> 16, sourceRectLeft + sourceRectWidth - 1);
++                qint64 vv = qBound(sourceRectTop, v >> 16, sourceRectTop + sourceRectHeight - 1);
+                 blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + vv * sbpl)[uu]);
+                 u += dudx;
+                 v += dvdx;
+@@ -348,8 +355,8 @@ void qt_transform_image_rasterize(DestT *destPixels, int dbpl,
+             // End of the scan line, with per-pixel checks.
+             i = toX - x2;
+             while (i) {
+-                int uu = qBound(sourceRect.left(), u >> 16, sourceRect.left() + sourceRect.width() - 1);
+-                int vv = qBound(sourceRect.top(), v >> 16, sourceRect.top() + sourceRect.height() - 1);
++                qint64 uu = qBound(sourceRectLeft, u >> 16, sourceRectLeft + sourceRectWidth - 1);
++                qint64 vv = qBound(sourceRectTop, v >> 16, sourceRectTop + sourceRectHeight - 1);
+                 blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + vv * sbpl)[uu]);
+                 u += dudx;
+                 v += dvdx;
+diff --git a/qtbase/src/gui/painting/qcolortrclut_p.h b/qtbase/src/gui/painting/qcolortrclut_p.h
+index 76a6a60803..24fd522e6c 100644
+--- a/qtbase/src/gui/painting/qcolortrclut_p.h
++++ b/qtbase/src/gui/painting/qcolortrclut_p.h
+@@ -118,6 +118,7 @@ public:
+         return QRgba64::fromRgba64(r, g, b, qAlpha(rgb32) * 257);
+ #endif
+     }
++    QRgba64 toLinear64(QRgba64) const = delete;
+ 
+     QRgb toLinear(QRgb rgb32) const
+     {
+diff --git a/qtbase/src/gui/painting/qdrawhelper.cpp b/qtbase/src/gui/painting/qdrawhelper.cpp
+index a61793508a..5ba2d277b7 100644
+--- a/qtbase/src/gui/painting/qdrawhelper.cpp
++++ b/qtbase/src/gui/painting/qdrawhelper.cpp
+@@ -6091,7 +6091,7 @@ static inline void alphargbblend_argb32(quint32 *dst, uint coverage, const QRgba
+ static inline void rgbBlendPixel(QRgba64 &dst, int coverage, QRgba64 slinear, const QColorTrcLut *colorProfile)
+ {
+     // Do a gammacorrected RGB alphablend...
+-    const QRgba64 dlinear = colorProfile ? colorProfile->toLinear64(dst) : dst;
++    const QRgba64 dlinear = colorProfile ? colorProfile->toLinear(dst) : dst;
+ 
+     QRgba64 blend = rgbBlend(dlinear, slinear, coverage);
+ 
+diff --git a/qtbase/src/gui/painting/qpaintengine_raster.cpp b/qtbase/src/gui/painting/qpaintengine_raster.cpp
+index 283923de52..f08eb9cbee 100644
+--- a/qtbase/src/gui/painting/qpaintengine_raster.cpp
++++ b/qtbase/src/gui/painting/qpaintengine_raster.cpp
+@@ -560,31 +560,6 @@ void QRasterPaintEngine::updateMatrix(const QTransform &matrix)
+     QRasterPaintEngineState *s = state();
+     // FALCON: get rid of this line, see drawImage call below.
+     s->matrix = matrix;
+-    QTransform::TransformationType txop = s->matrix.type();
+-
+-    switch (txop) {
+-
+-    case QTransform::TxNone:
+-        s->flags.int_xform = true;
+-        break;
+-
+-    case QTransform::TxTranslate:
+-        s->flags.int_xform = qreal(int(s->matrix.dx())) == s->matrix.dx()
+-                            && qreal(int(s->matrix.dy())) == s->matrix.dy();
+-        break;
+-
+-    case QTransform::TxScale:
+-        s->flags.int_xform = qreal(int(s->matrix.dx())) == s->matrix.dx()
+-                            && qreal(int(s->matrix.dy())) == s->matrix.dy()
+-                            && qreal(int(s->matrix.m11())) == s->matrix.m11()
+-                            && qreal(int(s->matrix.m22())) == s->matrix.m22();
+-        break;
+-
+-    default: // shear / perspective...
+-        s->flags.int_xform = false;
+-        break;
+-    }
+-
+     s->flags.tx_noshear = qt_scaleForTransform(s->matrix, &s->txscale);
+ 
+     ensureOutlineMapper();
+@@ -617,7 +592,6 @@ QRasterPaintEngineState::QRasterPaintEngineState()
+     flags.bilinear = false;
+     flags.legacy_rounding = false;
+     flags.fast_text = true;
+-    flags.int_xform = true;
+     flags.tx_noshear = true;
+     flags.fast_images = true;
+ 
+@@ -1793,7 +1767,7 @@ void QRasterPaintEngine::fill(const QVectorPath &path, const QBrush &brush)
+     QRectF cpRect = path.controlPointRect();
+     const QRectF pathDeviceRect = s->matrix.mapRect(cpRect);
+     // Skip paths that by conservative estimates are completely outside the paint device.
+-    if (!pathDeviceRect.intersects(QRectF(d->deviceRect)))
++    if (!pathDeviceRect.intersects(QRectF(d->deviceRect)) || !pathDeviceRect.isValid())
+         return;
+ 
+     ProcessSpans blend = d->getBrushFunc(pathDeviceRect, &s->brushData);
+diff --git a/qtbase/src/gui/painting/qpaintengine_raster_p.h b/qtbase/src/gui/painting/qpaintengine_raster_p.h
+index 089aadc3f7..bf7363d5aa 100644
+--- a/qtbase/src/gui/painting/qpaintengine_raster_p.h
++++ b/qtbase/src/gui/painting/qpaintengine_raster_p.h
+@@ -111,7 +111,6 @@ public:
+         uint bilinear : 1;
+         uint legacy_rounding : 1;
+         uint fast_text : 1;
+-        uint int_xform : 1;
+         uint tx_noshear : 1;
+         uint fast_images : 1;
+     };
+diff --git a/qtbase/src/gui/painting/qpainterpath.cpp b/qtbase/src/gui/painting/qpainterpath.cpp
+index f9544a3241..d80fafeaf1 100644
+--- a/qtbase/src/gui/painting/qpainterpath.cpp
++++ b/qtbase/src/gui/painting/qpainterpath.cpp
+@@ -1253,7 +1253,7 @@ void QPainterPath::addText(const QPointF &point, const QFont &f, const QString &
+ 
+         if (si.analysis.flags < QScriptAnalysis::TabOrObject) {
+             QGlyphLayout glyphs = eng->shapedGlyphs(&si);
+-            QFontEngine *fe = f.d->engineForScript(si.analysis.script);
++            QFontEngine *fe = eng->fontEngine(si);
+             Q_ASSERT(fe);
+             fe->addOutlineToPath(x, y, glyphs, this,
+                                  si.analysis.bidiLevel % 2
+diff --git a/qtbase/src/gui/painting/qpathclipper_p.h b/qtbase/src/gui/painting/qpathclipper_p.h
+index 9444a87b71..18f64c5e8c 100644
+--- a/qtbase/src/gui/painting/qpathclipper_p.h
++++ b/qtbase/src/gui/painting/qpathclipper_p.h
+@@ -156,7 +156,7 @@ public:
+     int vertex(Direction direction) const;
+ 
+ private:
+-    int m_next[2][2];
++    int m_next[2][2] = { { -1, -1 }, { -1, -1 } };
+ };
+ 
+ class QPathSegments
+@@ -296,10 +296,6 @@ inline QPathEdge::QPathEdge(int a, int b)
+     , angle(0)
+     , invAngle(0)
+ {
+-    m_next[0][0] = -1;
+-    m_next[1][0] = -1;
+-    m_next[0][0] = -1;
+-    m_next[1][0] = -1;
+ }
+ 
+ inline int QPathEdge::next(Traversal traversal, Direction direction) const
+diff --git a/qtbase/src/gui/painting/qpdf.cpp b/qtbase/src/gui/painting/qpdf.cpp
+index 3066744f1b..2c8d3c3b53 100644
+--- a/qtbase/src/gui/painting/qpdf.cpp
++++ b/qtbase/src/gui/painting/qpdf.cpp
+@@ -2760,6 +2760,8 @@ int QPdfEnginePrivate::addBrushPattern(const QTransform &m, bool *specifyColor,
+         return gradientBrush(brush, matrix, gStateObject);
+     }
+ 
++    matrix = brush.transform() * matrix;
++
+     if ((!brush.isOpaque() && brush.style() < Qt::LinearGradientPattern) || opacity != 1.0)
+         *gStateObject = addConstantAlphaObject(qRound(brush.color().alpha() * opacity),
+                                                qRound(pen.color().alpha() * opacity));
+diff --git a/qtbase/src/gui/painting/qstroker.cpp b/qtbase/src/gui/painting/qstroker.cpp
+index cb5d395e80..3b6357a893 100644
+--- a/qtbase/src/gui/painting/qstroker.cpp
++++ b/qtbase/src/gui/painting/qstroker.cpp
+@@ -1182,6 +1182,7 @@ void QDashStroker::processCurrentSubpath()
+         // Check if the entire line should be clipped away or simplified
+         bool clipIt = clipping && !lineIntersectsRect(prev, e, clip_tl, clip_br);
+         bool skipDashing = elen * invSumLength > repetitionLimit();
++        int maxDashes = dashCount;
+         if (skipDashing || clipIt) {
+             // Cut away full dash sequences.
+             elen -= std::floor(elen * invSumLength) * sumLength;
+@@ -1196,7 +1197,7 @@ void QDashStroker::processCurrentSubpath()
+                     pos = estop; // move pos to next path element
+                     done = true;
+                 } else { // Dash is on this line
+-                    pos = dpos + estart;
++                    pos = --maxDashes > 0 ? dpos + estart : estop;
+                     done = pos >= estop;
+                     if (++idash >= dashCount)
+                         idash = 0;
+diff --git a/qtbase/src/gui/painting/qt_attribution.json b/qtbase/src/gui/painting/qt_attribution.json
+index 7b16e8c211..0e87d30aa2 100644
+--- a/qtbase/src/gui/painting/qt_attribution.json
++++ b/qtbase/src/gui/painting/qt_attribution.json
+@@ -10,7 +10,7 @@
+         "Homepage": "http://www.freetype.org",
+         "License": "Freetype Project License or GNU General Public License v2.0 only",
+         "LicenseId": "FTL or GPL-2.0",
+-        "LicenseFile": "../../3rdparty/freetype/docs/LICENSE.TXT",
++        "LicenseFile": "../../3rdparty/freetype/LICENSE.TXT",
+         "Copyright": "Copyright 2000-2016 by David Turner, Robert Wilhelm, and Werner Lemberg."
+     },
+     {
+diff --git a/qtbase/src/gui/rhi/qshader_p_p.h b/qtbase/src/gui/rhi/qshader_p_p.h
+index ec9d25971f..4a5a7a6d51 100644
+--- a/qtbase/src/gui/rhi/qshader_p_p.h
++++ b/qtbase/src/gui/rhi/qshader_p_p.h
+@@ -68,13 +68,13 @@ struct Q_GUI_EXPORT QShaderPrivate
+     {
+     }
+ 
+-    QShaderPrivate(const QShaderPrivate *other)
++    QShaderPrivate(const QShaderPrivate &other)
+         : ref(1),
+-          qsbVersion(other->qsbVersion),
+-          stage(other->stage),
+-          desc(other->desc),
+-          shaders(other->shaders),
+-          bindings(other->bindings)
++          qsbVersion(other.qsbVersion),
++          stage(other.stage),
++          desc(other.desc),
++          shaders(other.shaders),
++          bindings(other.bindings)
+     {
+     }
+ 
+diff --git a/qtbase/src/gui/rhi/qshaderdescription_p_p.h b/qtbase/src/gui/rhi/qshaderdescription_p_p.h
+index ec2b0b6b4c..3da33a8a2b 100644
+--- a/qtbase/src/gui/rhi/qshaderdescription_p_p.h
++++ b/qtbase/src/gui/rhi/qshaderdescription_p_p.h
+@@ -63,16 +63,16 @@ struct Q_GUI_EXPORT QShaderDescriptionPrivate
+         localSize[0] = localSize[1] = localSize[2] = 0;
+     }
+ 
+-    QShaderDescriptionPrivate(const QShaderDescriptionPrivate *other)
++    QShaderDescriptionPrivate(const QShaderDescriptionPrivate &other)
+         : ref(1),
+-          inVars(other->inVars),
+-          outVars(other->outVars),
+-          uniformBlocks(other->uniformBlocks),
+-          pushConstantBlocks(other->pushConstantBlocks),
+-          storageBlocks(other->storageBlocks),
+-          combinedImageSamplers(other->combinedImageSamplers),
+-          storageImages(other->storageImages),
+-          localSize(other->localSize)
++          inVars(other.inVars),
++          outVars(other.outVars),
++          uniformBlocks(other.uniformBlocks),
++          pushConstantBlocks(other.pushConstantBlocks),
++          storageBlocks(other.storageBlocks),
++          combinedImageSamplers(other.combinedImageSamplers),
++          storageImages(other.storageImages),
++          localSize(other.localSize)
+     {
+     }
+ 
+diff --git a/qtbase/src/gui/text/qfontdatabase.cpp b/qtbase/src/gui/text/qfontdatabase.cpp
+index a657a8c516..4fc0100958 100644
+--- a/qtbase/src/gui/text/qfontdatabase.cpp
++++ b/qtbase/src/gui/text/qfontdatabase.cpp
+@@ -983,7 +983,7 @@ QFontEngine *loadSingleEngine(int script,
+         if (style->key.stretch != 0 && request.stretch != 0
+             && (request.styleName.isEmpty() || request.styleName != style->styleName)) {
+             def.stretch = (request.stretch * 100 + style->key.stretch / 2) / style->key.stretch;
+-        } else {
++        } else if (request.stretch == QFont::AnyStretch) {
+             def.stretch = 100;
+         }
+ 
+diff --git a/qtbase/src/gui/text/qtextdocumentlayout.cpp b/qtbase/src/gui/text/qtextdocumentlayout.cpp
+index f3e6ea2100..72267e9380 100644
+--- a/qtbase/src/gui/text/qtextdocumentlayout.cpp
++++ b/qtbase/src/gui/text/qtextdocumentlayout.cpp
+@@ -2123,7 +2123,7 @@ void QTextDocumentLayoutPrivate::drawListItem(const QPointF &offset, QPainter *p
+ {
+     Q_Q(const QTextDocumentLayout);
+     const QTextBlockFormat blockFormat = bl.blockFormat();
+-    const QTextCharFormat charFormat = QTextCursor(bl).charFormat();
++    const QTextCharFormat charFormat = bl.charFormat();
+     QFont font(charFormat.font());
+     if (q->paintDevice())
+         font = QFont(font, q->paintDevice());
+diff --git a/qtbase/src/gui/text/qtextengine.cpp b/qtbase/src/gui/text/qtextengine.cpp
+index ce4abac472..a6c66e5d2d 100644
+--- a/qtbase/src/gui/text/qtextengine.cpp
++++ b/qtbase/src/gui/text/qtextengine.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2021 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtGui module of the Qt Toolkit.
+@@ -1565,6 +1565,12 @@ void QTextEngine::shapeText(int item) const
+         // Overwrite with 0 token to indicate failure
+         QGlyphLayout g = availableGlyphs(&si);
+         g.glyphs[0] = 0;
++        g.attributes[0].clusterStart = true;
++
++        ushort *log_clusters = logClusters(&si);
++        for (int i = 0; i < itemLength; ++i)
++            log_clusters[i] = 0;
++
+         return;
+     }
+ 
+diff --git a/qtbase/src/gui/util/qdesktopservices.cpp b/qtbase/src/gui/util/qdesktopservices.cpp
+index fbb63a9408..4d5fafaaa7 100644
+--- a/qtbase/src/gui/util/qdesktopservices.cpp
++++ b/qtbase/src/gui/util/qdesktopservices.cpp
+@@ -54,6 +54,8 @@
+ #include <qpa/qplatformintegration.h>
+ #include <qdir.h>
+ 
++#include <QtCore/private/qlocking_p.h>
++
+ QT_BEGIN_NAMESPACE
+ 
+ class QOpenUrlHandlerRegistry : public QObject
+@@ -81,6 +83,7 @@ Q_GLOBAL_STATIC(QOpenUrlHandlerRegistry, handlerRegistry)
+ 
+ void QOpenUrlHandlerRegistry::handlerDestroyed(QObject *handler)
+ {
++    const auto lock = qt_scoped_lock(mutex);
+     HandlerHash::Iterator it = handlers.begin();
+     while (it != handlers.end()) {
+         if (it->receiver == handler) {
+@@ -294,7 +297,8 @@ void QDesktopServices::setUrlHandler(const QString &scheme, QObject *receiver, c
+     h.name = method;
+     registry->handlers.insert(scheme.toLower(), h);
+     QObject::connect(receiver, SIGNAL(destroyed(QObject*)),
+-                     registry, SLOT(handlerDestroyed(QObject*)));
++                     registry, SLOT(handlerDestroyed(QObject*)),
++                     Qt::DirectConnection);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/gui/util/qpkmhandler.cpp b/qtbase/src/gui/util/qpkmhandler.cpp
+index e0c3b75efe..3414f9d8ba 100644
+--- a/qtbase/src/gui/util/qpkmhandler.cpp
++++ b/qtbase/src/gui/util/qpkmhandler.cpp
+@@ -57,7 +57,7 @@ struct PkmType
+     quint32 bytesPerBlock;
+ };
+ 
+-static PkmType typeMap[5] = {
++static constexpr PkmType typeMap[5] = {
+     { 0x8D64,  8 },   // GL_ETC1_RGB8_OES
+     { 0x9274,  8 },   // GL_COMPRESSED_RGB8_ETC2
+     { 0, 0 },         // unused (obsolete)
+diff --git a/qtbase/src/network/access/qnetworkreplyfileimpl.cpp b/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
+index b6be93147a..6e69b4c4d3 100644
+--- a/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
++++ b/qtbase/src/network/access/qnetworkreplyfileimpl.cpp
+@@ -89,9 +89,10 @@ QNetworkReplyFileImpl::QNetworkReplyFileImpl(QNetworkAccessManager *manager, con
+         // we handle only local files
+         QString msg = QCoreApplication::translate("QNetworkAccessFileBackend", "Request for opening non-local file %1").arg(url.toString());
+         setError(QNetworkReply::ProtocolInvalidOperationError, msg);
++        setFinished(true); // We're finished, will emit finished() after ctor is done.
+         QMetaObject::invokeMethod(this, "errorOccurred", Qt::QueuedConnection,
+             Q_ARG(QNetworkReply::NetworkError, QNetworkReply::ProtocolInvalidOperationError));
+-        fileOpenFinished(false);
++        QMetaObject::invokeMethod(this, [this](){ fileOpenFinished(false); }, Qt::QueuedConnection);
+         return;
+     }
+ #endif
+diff --git a/qtbase/src/network/access/qnetworkreplyimpl.cpp b/qtbase/src/network/access/qnetworkreplyimpl.cpp
+index bcdf6ee2f1..3b6deb82bd 100644
+--- a/qtbase/src/network/access/qnetworkreplyimpl.cpp
++++ b/qtbase/src/network/access/qnetworkreplyimpl.cpp
+@@ -680,7 +680,7 @@ void QNetworkReplyImplPrivate::appendDownstreamData(QIODevice *data)
+     // read until EOF from data
+     if (Q_UNLIKELY(copyDevice)) {
+         qCritical("QNetworkReplyImpl: copy from QIODevice already in progress -- "
+-                  "backend probly needs to be fixed");
++                  "backend probably needs to be fixed");
+         return;
+     }
+ 
+diff --git a/qtbase/src/network/kernel/qauthenticator.cpp b/qtbase/src/network/kernel/qauthenticator.cpp
+index d9fe7bc47b..ccd04b294a 100644
+--- a/qtbase/src/network/kernel/qauthenticator.cpp
++++ b/qtbase/src/network/kernel/qauthenticator.cpp
+@@ -50,6 +50,7 @@
+ #include <qstring.h>
+ #include <qdatetime.h>
+ #include <qrandom.h>
++#include "private/qsystemlibrary_p.h"
+ 
+ #ifdef Q_OS_WIN
+ #include <qmutex.h>
+@@ -1563,7 +1564,7 @@ static bool q_SSPI_library_load()
+ 
+     // Initialize security interface
+     if (pSecurityFunctionTable == nullptr) {
+-        securityDLLHandle = LoadLibrary(L"secur32.dll");
++        securityDLLHandle = QSystemLibrary::load(L"secur32");
+         if (securityDLLHandle != nullptr) {
+             INIT_SECURITY_INTERFACE pInitSecurityInterface =
+                 reinterpret_cast<INIT_SECURITY_INTERFACE>(
+diff --git a/qtbase/src/network/kernel/qhostinfo_unix.cpp b/qtbase/src/network/kernel/qhostinfo_unix.cpp
+index 9b0a2ee669..73679c9ef1 100644
+--- a/qtbase/src/network/kernel/qhostinfo_unix.cpp
++++ b/qtbase/src/network/kernel/qhostinfo_unix.cpp
+@@ -122,7 +122,6 @@ static QFunctionPointer resolveSymbol(QLibrary &lib, const char *sym)
+ 
+ LibResolv::LibResolv()
+ {
+-    QLibrary lib;
+ #ifdef LIBRESOLV_SO
+     lib.setFileName(QStringLiteral(LIBRESOLV_SO));
+     if (!lib.load())
+diff --git a/qtbase/src/network/socket/qsocks5socketengine.cpp b/qtbase/src/network/socket/qsocks5socketengine.cpp
+index 3a046fd116..97fadca0b3 100644
+--- a/qtbase/src/network/socket/qsocks5socketengine.cpp
++++ b/qtbase/src/network/socket/qsocks5socketengine.cpp
+@@ -1296,7 +1296,7 @@ void QSocks5SocketEnginePrivate::_q_udpSocketReadNotification()
+         int pos = 0;
+         const char *buf = inBuf.constData();
+         if (inBuf.size() < 4) {
+-            QSOCKS5_D_DEBUG << "bugus udp data, discarding";
++            QSOCKS5_D_DEBUG << "bogus udp data, discarding";
+             return;
+         }
+         QSocks5RevivedDatagram datagram;
+diff --git a/qtbase/src/network/ssl/qsslcontext_openssl.cpp b/qtbase/src/network/ssl/qsslcontext_openssl.cpp
+index c9f202f573..c992da9d8e 100644
+--- a/qtbase/src/network/ssl/qsslcontext_openssl.cpp
++++ b/qtbase/src/network/ssl/qsslcontext_openssl.cpp
+@@ -409,7 +409,7 @@ init_context:
+         break;
+     case QSsl::DtlsV1_0OrLater:
+         minVersion = DTLS1_VERSION;
+-        maxVersion = DTLS_MAX_VERSION;
++        maxVersion = 0;
+         break;
+     case QSsl::DtlsV1_2:
+         minVersion = DTLS1_2_VERSION;
+@@ -417,7 +417,7 @@ init_context:
+         break;
+     case QSsl::DtlsV1_2OrLater:
+         minVersion = DTLS1_2_VERSION;
+-        maxVersion = DTLS_MAX_VERSION;
++        maxVersion = 0;
+         break;
+     case QSsl::TlsV1_3OrLater:
+ #ifdef TLS1_3_VERSION
+@@ -455,7 +455,7 @@ init_context:
+     }
+ 
+     // Enable bug workarounds.
+-    long options = QSslSocketBackendPrivate::setupOpenSslOptions(configuration.protocol(), configuration.d->sslOptions);
++    qssloptions options = QSslSocketBackendPrivate::setupOpenSslOptions(configuration.protocol(), configuration.d->sslOptions);
+     q_SSL_CTX_set_options(sslContext->ctx, options);
+ 
+     // Tell OpenSSL to release memory early
+diff --git a/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp b/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
+index aaf8741130..b58935372c 100644
+--- a/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
++++ b/qtbase/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
+@@ -59,57 +59,6 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-#ifdef OPENSSL_NO_DEPRECATED_3_0
+-
+-static int q_DH_check(DH *dh, int *status)
+-{
+-    // DH_check was first deprecated in OpenSSL 3.0.0, as low-level
+-    // API; the EVP_PKEY family of functions was advised as an alternative.
+-    // As of now EVP_PKEY_params_check ends up calling ... DH_check,
+-    // which is good enough.
+-
+-    Q_ASSERT(dh);
+-    Q_ASSERT(status);
+-
+-    EVP_PKEY *key = q_EVP_PKEY_new();
+-    if (!key) {
+-        qCWarning(lcSsl, "EVP_PKEY_new failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-    const auto keyDeleter = qScopeGuard([key](){
+-        q_EVP_PKEY_free(key);
+-    });
+-    if (!q_EVP_PKEY_set1_DH(key, dh)) {
+-        qCWarning(lcSsl, "EVP_PKEY_set1_DH failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-
+-    EVP_PKEY_CTX *keyCtx = q_EVP_PKEY_CTX_new(key, nullptr);
+-    if (!keyCtx) {
+-        qCWarning(lcSsl, "EVP_PKEY_CTX_new failed");
+-        QSslSocketBackendPrivate::logAndClearErrorQueue();
+-        return 0;
+-    }
+-    const auto ctxDeleter = qScopeGuard([keyCtx]{
+-        q_EVP_PKEY_CTX_free(keyCtx);
+-    });
+-
+-    const int result = q_EVP_PKEY_param_check(keyCtx);
+-    QSslSocketBackendPrivate::logAndClearErrorQueue();
+-    // Note: unlike DH_check, we cannot obtain the 'status',
+-    // if the 'result' is 0 (actually the result is 1 only
+-    // if this 'status' was 0). We could probably check the
+-    // errors from the error queue, but it's not needed anyway
+-    // - see the 'isSafeDH' below, how it returns immediately
+-    // on 0.
+-    Q_UNUSED(status)
+-
+-    return result;
+-}
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+-
+ static bool isSafeDH(DH *dh)
+ {
+     int status = 0;
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl.cpp b/qtbase/src/network/ssl/qsslsocket_openssl.cpp
+index 37fad2a68f..8f6858c867 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl.cpp
++++ b/qtbase/src/network/ssl/qsslsocket_openssl.cpp
+@@ -550,9 +550,9 @@ static void q_loadCiphersForConnection(SSL *connection, QList<QSslCipher> &ciphe
+ // Defined in qsslsocket.cpp
+ void q_setDefaultDtlsCiphers(const QList<QSslCipher> &ciphers);
+ 
+-long QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions)
++qssloptions QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions)
+ {
+-    long options;
++    qssloptions options;
+     if (protocol == QSsl::TlsV1SslV3)
+         options = SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3;
+     else if (protocol == QSsl::SecureProtocols)
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_p.h b/qtbase/src/network/ssl/qsslsocket_openssl_p.h
+index 4103de23e8..5547589256 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_p.h
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_p.h
+@@ -107,6 +107,12 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++typedef uint64_t qssloptions;
++#else
++typedef unsigned long qssloptions;
++#endif
++
+ struct QSslErrorEntry {
+     int code;
+     int depth;
+@@ -171,7 +177,7 @@ public:
+     QVector<QSslError> ocspErrors;
+     QByteArray ocspResponseDer;
+ 
+-    Q_AUTOTEST_EXPORT static long setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions);
++    Q_AUTOTEST_EXPORT static qssloptions setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions);
+     static QSslCipher QSslCipher_from_SSL_CIPHER(const SSL_CIPHER *cipher);
+     static QList<QSslCertificate> STACKOFX509_to_QSslCertificates(STACK_OF(X509) *x509);
+     static QList<QSslError> verify(const QList<QSslCertificate> &certificateChain, const QString &hostName);
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp b/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
+index e53fb279f0..459ccd0b19 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp
+@@ -148,7 +148,6 @@ DEFINEFUNC(int, EVP_PKEY_up_ref, EVP_PKEY *a, a, return 0, return)
+ DEFINEFUNC2(EVP_PKEY_CTX *, EVP_PKEY_CTX_new, EVP_PKEY *pkey, pkey, ENGINE *e, e, return nullptr, return)
+ DEFINEFUNC(int, EVP_PKEY_param_check, EVP_PKEY_CTX *ctx, ctx, return 0, return)
+ DEFINEFUNC(void, EVP_PKEY_CTX_free, EVP_PKEY_CTX *ctx, ctx, return, return)
+-DEFINEFUNC(int, EVP_PKEY_base_id, EVP_PKEY *a, a, return NID_undef, return)
+ DEFINEFUNC(int, RSA_bits, RSA *a, a, return 0, return)
+ DEFINEFUNC(int, DSA_bits, DSA *a, a, return 0, return)
+ DEFINEFUNC(int, OPENSSL_sk_num, OPENSSL_STACK *a, a, return -1, return)
+@@ -158,7 +157,7 @@ DEFINEFUNC2(void, OPENSSL_sk_push, OPENSSL_STACK *a, a, void *b, b, return, DUMM
+ DEFINEFUNC(void, OPENSSL_sk_free, OPENSSL_STACK *a, a, return, DUMMYARG)
+ DEFINEFUNC2(void *, OPENSSL_sk_value, OPENSSL_STACK *a, a, int b, b, return nullptr, return)
+ DEFINEFUNC(int, SSL_session_reused, SSL *a, a, return 0, return)
+-DEFINEFUNC2(unsigned long, SSL_CTX_set_options, SSL_CTX *ctx, ctx, unsigned long op, op, return 0, return)
++DEFINEFUNC2(qssloptions, SSL_CTX_set_options, SSL_CTX *ctx, ctx, qssloptions op, op, return 0, return)
+ DEFINEFUNC(int, SSL_CTX_get_security_level, const SSL_CTX *ctx, ctx, return -1, return)
+ DEFINEFUNC2(void, SSL_CTX_set_security_level, SSL_CTX *ctx, ctx, int level, level, return, return)
+ #ifdef TLS1_3_VERSION
+@@ -371,7 +370,15 @@ DEFINEFUNC(const SSL_CIPHER *, SSL_get_current_cipher, SSL *a, a, return nullptr
+ DEFINEFUNC(int, SSL_version, const SSL *a, a, return 0, return)
+ DEFINEFUNC2(int, SSL_get_error, SSL *a, a, int b, b, return -1, return)
+ DEFINEFUNC(STACK_OF(X509) *, SSL_get_peer_cert_chain, SSL *a, a, return nullptr, return)
++
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++DEFINEFUNC(X509 *, SSL_get1_peer_certificate, SSL *a, a, return nullptr, return)
++DEFINEFUNC(int, EVP_PKEY_get_base_id, const EVP_PKEY *pkey, pkey, return -1, return)
++#else
+ DEFINEFUNC(X509 *, SSL_get_peer_certificate, SSL *a, a, return nullptr, return)
++DEFINEFUNC(int, EVP_PKEY_base_id, EVP_PKEY *a, a, return NID_undef, return)
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+ DEFINEFUNC(long, SSL_get_verify_result, const SSL *a, a, return -1, return)
+ DEFINEFUNC(SSL *, SSL_new, SSL_CTX *a, a, return nullptr, return)
+ DEFINEFUNC(SSL_CTX *, SSL_get_SSL_CTX, SSL *a, a, return nullptr, return)
+@@ -492,9 +499,7 @@ DEFINEFUNC(DH *, DH_new, DUMMYARG, DUMMYARG, return nullptr, return)
+ DEFINEFUNC(void, DH_free, DH *dh, dh, return, DUMMYARG)
+ DEFINEFUNC3(DH *, d2i_DHparams, DH**a, a, const unsigned char **pp, pp, long length, length, return nullptr, return)
+ DEFINEFUNC2(int, i2d_DHparams, DH *a, a, unsigned char **p, p, return -1, return)
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+ DEFINEFUNC2(int, DH_check, DH *dh, dh, int *codes, codes, return 0, return)
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+ DEFINEFUNC3(BIGNUM *, BN_bin2bn, const unsigned char *s, s, int len, len, BIGNUM *ret, ret, return nullptr, return)
+ 
+ #ifndef OPENSSL_NO_EC
+@@ -868,7 +873,6 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(EVP_PKEY_CTX_new)
+     RESOLVEFUNC(EVP_PKEY_param_check)
+     RESOLVEFUNC(EVP_PKEY_CTX_free)
+-    RESOLVEFUNC(EVP_PKEY_base_id)
+     RESOLVEFUNC(RSA_bits)
+     RESOLVEFUNC(OPENSSL_sk_new_null)
+     RESOLVEFUNC(OPENSSL_sk_push)
+@@ -1107,7 +1111,15 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(SSL_version)
+     RESOLVEFUNC(SSL_get_error)
+     RESOLVEFUNC(SSL_get_peer_cert_chain)
++
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++    RESOLVEFUNC(SSL_get1_peer_certificate)
++    RESOLVEFUNC(EVP_PKEY_get_base_id)
++#else
+     RESOLVEFUNC(SSL_get_peer_certificate)
++    RESOLVEFUNC(EVP_PKEY_base_id)
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+     RESOLVEFUNC(SSL_get_verify_result)
+     RESOLVEFUNC(SSL_new)
+     RESOLVEFUNC(SSL_get_SSL_CTX)
+@@ -1206,9 +1218,7 @@ bool q_resolveOpenSslSymbols()
+     RESOLVEFUNC(DH_free)
+     RESOLVEFUNC(d2i_DHparams)
+     RESOLVEFUNC(i2d_DHparams)
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+     RESOLVEFUNC(DH_check)
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+     RESOLVEFUNC(BN_bin2bn)
+ 
+ #ifndef OPENSSL_NO_EC
+diff --git a/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h b/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
+index 95e8897a3b..27aeffa18a 100644
+--- a/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
++++ b/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h
+@@ -237,7 +237,6 @@ Q_AUTOTEST_EXPORT int q_EVP_PKEY_up_ref(EVP_PKEY *a);
+ EVP_PKEY_CTX *q_EVP_PKEY_CTX_new(EVP_PKEY *pkey, ENGINE *e);
+ void q_EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx);
+ int q_EVP_PKEY_param_check(EVP_PKEY_CTX *ctx);
+-int q_EVP_PKEY_base_id(EVP_PKEY *a);
+ int q_RSA_bits(RSA *a);
+ Q_AUTOTEST_EXPORT int q_OPENSSL_sk_num(OPENSSL_STACK *a);
+ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_pop_free(OPENSSL_STACK *a, void (*b)(void *));
+@@ -246,7 +245,7 @@ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_push(OPENSSL_STACK *st, void *data);
+ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_free(OPENSSL_STACK *a);
+ Q_AUTOTEST_EXPORT void * q_OPENSSL_sk_value(OPENSSL_STACK *a, int b);
+ int q_SSL_session_reused(SSL *a);
+-unsigned long q_SSL_CTX_set_options(SSL_CTX *ctx, unsigned long op);
++qssloptions q_SSL_CTX_set_options(SSL_CTX *ctx, qssloptions op);
+ int q_OPENSSL_init_ssl(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings);
+ size_t q_SSL_get_client_random(SSL *a, unsigned char *out, size_t outlen);
+ size_t q_SSL_SESSION_get_master_key(const SSL_SESSION *session, unsigned char *out, size_t outlen);
+@@ -510,7 +509,6 @@ const SSL_CIPHER *q_SSL_get_current_cipher(SSL *a);
+ int q_SSL_version(const SSL *a);
+ int q_SSL_get_error(SSL *a, int b);
+ STACK_OF(X509) *q_SSL_get_peer_cert_chain(SSL *a);
+-X509 *q_SSL_get_peer_certificate(SSL *a);
+ long q_SSL_get_verify_result(const SSL *a);
+ SSL *q_SSL_new(SSL_CTX *a);
+ SSL_CTX *q_SSL_get_SSL_CTX(SSL *a);
+@@ -582,10 +580,7 @@ DH *q_DH_new();
+ void q_DH_free(DH *dh);
+ DH *q_d2i_DHparams(DH **a, const unsigned char **pp, long length);
+ int q_i2d_DHparams(DH *a, unsigned char **p);
+-
+-#ifndef OPENSSL_NO_DEPRECATED_3_0
+ int q_DH_check(DH *dh, int *codes);
+-#endif // OPENSSL_NO_DEPRECATED_3_0
+ 
+ BIGNUM *q_BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret);
+ #define q_SSL_CTX_set_tmp_dh(ctx, dh) q_SSL_CTX_ctrl((ctx), SSL_CTRL_SET_TMP_DH, 0, (char *)dh)
+@@ -754,6 +749,17 @@ void q_CRYPTO_free(void *str, const char *file, int line);
+ int q_SSL_CTX_get_security_level(const SSL_CTX *ctx);
+ void q_SSL_CTX_set_security_level(SSL_CTX *ctx, int level);
+ 
++// Here we have the ones that make difference between OpenSSL pre/post v3:
++#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
++X509 *q_SSL_get1_peer_certificate(SSL *a);
++#define q_SSL_get_peer_certificate q_SSL_get1_peer_certificate
++int q_EVP_PKEY_get_base_id(const EVP_PKEY *pkey);
++#define q_EVP_PKEY_base_id q_EVP_PKEY_get_base_id
++#else
++X509 *q_SSL_get_peer_certificate(SSL *a);
++int q_EVP_PKEY_base_id(EVP_PKEY *a);
++#endif // OPENSSL_VERSION_MAJOR >= 3
++
+ QT_END_NAMESPACE
+ 
+ #endif
+diff --git a/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h b/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
+index bf37d07fd8..dbd42fb799 100644
+--- a/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
++++ b/qtbase/src/platformsupport/eglconvenience/qt_egl_p.h
+@@ -61,7 +61,11 @@
+ # if !defined(Q_OS_INTEGRITY)
+ #  define WIN_INTERFACE_CUSTOM   // NV
+ # endif // Q_OS_INTEGRITY
+-#endif  // QT_EGL_NO_X11
++#else // QT_EGL_NO_X11
++// If one has an eglplatform.h with https://github.com/KhronosGroup/EGL-Registry/pull/130
++// that needs USE_X11 to be defined.
++# define USE_X11
++#endif
+ 
+ #ifdef QT_EGL_WAYLAND
+ # define WAYLAND // NV
+diff --git a/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+index 159b490ce0..00aa80cd58 100644
+--- a/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
++++ b/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+@@ -567,6 +567,8 @@ void QFontconfigDatabase::populateFontDatabase()
+         fonts = FcFontList(nullptr, pattern, os);
+         FcObjectSetDestroy(os);
+         FcPatternDestroy(pattern);
++        if (!fonts)
++            return;
+     }
+ 
+     for (int i = 0; i < fonts->nfont; i++)
+diff --git a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
+index b713c19447..7cb9a8c79a 100644
+--- a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
++++ b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon.cpp
+@@ -95,6 +95,7 @@ static constexpr const auto KeyTbl = qMakeArray(
+         Xkb2Qt<XKB_KEY_Clear,                   Qt::Key_Delete>,
+         Xkb2Qt<XKB_KEY_Pause,                   Qt::Key_Pause>,
+         Xkb2Qt<XKB_KEY_Print,                   Qt::Key_Print>,
++        Xkb2Qt<XKB_KEY_Sys_Req,                 Qt::Key_SysReq>,
+         Xkb2Qt<0x1005FF60,                      Qt::Key_SysReq>,         // hardcoded Sun SysReq
+         Xkb2Qt<0x1007ff00,                      Qt::Key_SysReq>,         // hardcoded X386 SysReq
+ 
+@@ -471,7 +472,7 @@ QVector<xkb_keysym_t> QXkbCommon::toKeysym(QKeyEvent *event)
+     } else if (event->modifiers() & Qt::KeypadModifier) {
+         if (qtKey >= Qt::Key_0 && qtKey <= Qt::Key_9)
+             keysyms.append(XKB_KEY_KP_0 + (qtKey - Qt::Key_0));
+-    } else if (isLatin(qtKey) && event->text().isUpper()) {
++    } else if (isLatin1(qtKey) && event->text().isUpper()) {
+         keysyms.append(qtKey);
+     }
+ 
+@@ -523,7 +524,7 @@ int QXkbCommon::keysymToQtKey(xkb_keysym_t keysym, Qt::KeyboardModifiers modifie
+         // With standard shortcuts we should prefer a latin character, this is
+         // for checks like "some qkeyevent == QKeySequence::Copy" to work even
+         // when using for example 'russian' keyboard layout.
+-        if (!QXkbCommon::isLatin(keysym)) {
++        if (!QXkbCommon::isLatin1(keysym)) {
+             xkb_keysym_t latinKeysym = QXkbCommon::lookupLatinKeysym(state, code);
+             if (latinKeysym != XKB_KEY_NoSymbol)
+                 keysym = latinKeysym;
+@@ -546,7 +547,7 @@ static int keysymToQtKey_internal(xkb_keysym_t keysym, Qt::KeyboardModifiers mod
+     } else if (keysym >= XKB_KEY_KP_0 && keysym <= XKB_KEY_KP_9) {
+         // numeric keypad keys
+         qtKey = Qt::Key_0 + (keysym - XKB_KEY_KP_0);
+-    } else if (QXkbCommon::isLatin(keysym)) {
++    } else if (QXkbCommon::isLatin1(keysym)) {
+         qtKey = QXkbCommon::qxkbcommon_xkb_keysym_to_upper(keysym);
+     } else {
+         // check if we have a direct mapping
+@@ -678,7 +679,7 @@ QList<int> QXkbCommon::possibleKeys(xkb_state *state, const QKeyEvent *event,
+         Qt::KeyboardModifiers neededMods = ModsTbl[i];
+         if ((modifiers & neededMods) == neededMods) {
+             if (i == 8) {
+-                if (isLatin(baseQtKey))
++                if (isLatin1(baseQtKey))
+                     continue;
+                 // add a latin key as a fall back key
+                 sym = lookupLatinKeysym(state, keycode);
+@@ -733,7 +734,7 @@ void QXkbCommon::verifyHasLatinLayout(xkb_keymap *keymap)
+     for (xkb_layout_index_t layout = 0; layout < layoutCount; ++layout) {
+         for (xkb_keycode_t code = minKeycode; code < maxKeycode; ++code) {
+             xkb_keymap_key_get_syms_by_level(keymap, code, layout, 0, &keysyms);
+-            if (keysyms && isLatin(keysyms[0]))
++            if (keysyms && isLatin1(keysyms[0]))
+                 nrLatinKeys++;
+             if (nrLatinKeys > 10) // arbitrarily chosen threshold
+                 return;
+@@ -766,7 +767,7 @@ xkb_keysym_t QXkbCommon::lookupLatinKeysym(xkb_state *state, xkb_keycode_t keyco
+         xkb_level_index_t level = xkb_state_key_get_level(state, keycode, layout);
+         if (xkb_keymap_key_get_syms_by_level(keymap, keycode, layout, level, &syms) != 1)
+             continue;
+-        if (isLatin(syms[0])) {
++        if (isLatin1(syms[0])) {
+             sym = syms[0];
+             break;
+         }
+diff --git a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
+index 561eae03db..8389bd8f5a 100644
+--- a/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
++++ b/qtbase/src/platformsupport/input/xkbcommon/qxkbcommon_p.h
+@@ -94,8 +94,8 @@ public:
+     static void verifyHasLatinLayout(xkb_keymap *keymap);
+     static xkb_keysym_t lookupLatinKeysym(xkb_state *state, xkb_keycode_t keycode);
+ 
+-    static bool isLatin(xkb_keysym_t sym) {
+-        return ((sym >= 'a' && sym <= 'z') || (sym >= 'A' && sym <= 'Z'));
++    static bool isLatin1(xkb_keysym_t sym) {
++        return sym <= 0xff;
+     }
+     static bool isKeypad(xkb_keysym_t sym) {
+         return sym >= XKB_KEY_KP_Space && sym <= XKB_KEY_KP_9;
+diff --git a/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp b/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
+index 8cd7f9b368..406f84663f 100644
+--- a/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
++++ b/qtbase/src/platformsupport/kmsconvenience/qkmsdevice.cpp
+@@ -318,7 +318,7 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources,
+ 
+     if (current < 0 && crtc_mode.clock != 0) {
+         modes << crtc_mode;
+-        current = mode.size() - 1;
++        current = modes.size() - 1;
+     }
+ 
+     if (configuration == OutputConfigCurrent)
+diff --git a/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp b/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
+index 9153fd20bb..255ea5e33e 100644
+--- a/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
++++ b/qtbase/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
+@@ -194,6 +194,9 @@ QString AtSpiAdaptor::introspect(const QString &path) const
+                 "      <arg direction=\"out\" type=\"(so)\"/>\n"
+                 "      <annotation value=\"QSpiObjectReference\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n"
+                 "    </method>\n"
++                "    <method name=\"GetAccessibleId\">\n"
++                "      <arg direction=\"out\" type=\"s\"/>\n"
++                "    </method>\n"
+                 "  </interface>\n"
+                 );
+ 
+@@ -913,8 +916,17 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+     }
+     case QAccessible::NameChanged: {
+         if (sendObject || sendObject_property_change || sendObject_property_change_accessible_name) {
+-            QString path = pathForInterface(event->accessibleInterface());
+-            QVariantList args = packDBusSignalArguments(QLatin1String("accessible-name"), 0, 0, variantForPath(path));
++            QAccessibleInterface *iface = event->accessibleInterface();
++            if (!iface) {
++                qCDebug(lcAccessibilityAtspi,
++                        "NameChanged event from invalid accessible.");
++                return;
++            }
++
++            QString path = pathForInterface(iface);
++            QVariantList args = packDBusSignalArguments(
++                QLatin1String("accessible-name"), 0, 0,
++                QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Name))));
+             sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                            QLatin1String("PropertyChange"), args);
+         }
+@@ -922,8 +934,17 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+     }
+     case QAccessible::DescriptionChanged: {
+         if (sendObject || sendObject_property_change || sendObject_property_change_accessible_description) {
+-            QString path = pathForInterface(event->accessibleInterface());
+-            QVariantList args = packDBusSignalArguments(QLatin1String("accessible-description"), 0, 0, variantForPath(path));
++            QAccessibleInterface *iface = event->accessibleInterface();
++            if (!iface) {
++                qCDebug(lcAccessibilityAtspi,
++                        "DescriptionChanged event from invalid accessible.");
++                return;
++            }
++
++            QString path = pathForInterface(iface);
++            QVariantList args = packDBusSignalArguments(
++                QLatin1String("accessible-description"), 0, 0,
++                QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Description))));
+             sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                            QLatin1String("PropertyChange"), args);
+         }
+@@ -1038,7 +1059,9 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
+                 // Combo Box with AT-SPI likes to be special
+                 // It requires a name-change to update caches and then selection-changed
+                 QString path = pathForInterface(iface);
+-                QVariantList args1 = packDBusSignalArguments(QLatin1String("accessible-name"), 0, 0, variantForPath(path));
++                QVariantList args1 = packDBusSignalArguments(
++                    QLatin1String("accessible-name"), 0, 0,
++                    QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Name))));
+                 sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+                                QLatin1String("PropertyChange"), args1);
+                 QVariantList args2 = packDBusSignalArguments(QString(), 0, 0, QVariant::fromValue(QDBusVariant(QVariant(0))));
+@@ -1358,6 +1381,26 @@ void AtSpiAdaptor::registerApplication()
+     delete registry;
+ }
+ 
++namespace {
++QString accessibleIdForAccessible(QAccessibleInterface *accessible)
++{
++    QString result;
++    while (accessible) {
++        if (!result.isEmpty())
++            result.prepend(QLatin1Char('.'));
++        if (auto obj = accessible->object()) {
++            const QString name = obj->objectName();
++            if (!name.isEmpty())
++                result.prepend(name);
++            else
++                result.prepend(QString::fromUtf8(obj->metaObject()->className()));
++        }
++        accessible = accessible->parent();
++    }
++    return result;
++}
++} // namespace
++
+ // Accessible
+ bool AtSpiAdaptor::accessibleInterface(QAccessibleInterface *interface, const QString &function, const QDBusMessage &message, const QDBusConnection &connection)
+ {
+@@ -1441,6 +1484,9 @@ bool AtSpiAdaptor::accessibleInterface(QAccessibleInterface *interface, const QS
+             children << ref;
+         }
+         connection.send(message.createReply(QVariant::fromValue(children)));
++    } else if (function == QLatin1String("GetAccessibleId")) {
++        sendReply(connection, message,
++                  QVariant::fromValue(QDBusVariant(accessibleIdForAccessible(interface))));
+     } else {
+         qCDebug(lcAccessibilityAtspi) << "WARNING: AtSpiAdaptor::accessibleInterface does not implement " << function << message.path();
+         return false;
+diff --git a/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp b/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
+index 45ddc8e496..cc734abc63 100644
+--- a/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
++++ b/qtbase/src/platformsupport/linuxaccessibility/dbusconnection.cpp
+@@ -69,6 +69,21 @@ QT_BEGIN_NAMESPACE
+ DBusConnection::DBusConnection(QObject *parent)
+     : QObject(parent), m_a11yConnection(QString()), m_enabled(false)
+ {
++    // If the bus is explicitly set via env var it overrides everything else.
++    QByteArray addressEnv = qgetenv("AT_SPI_BUS_ADDRESS");
++    if (!addressEnv.isEmpty()) {
++        // Only connect on next loop run, connections to our enabled signal are
++        // only established after the ctor returns.
++        QMetaObject::invokeMethod(
++                this,
++                [this, addressEnv] {
++                    m_enabled = true;
++                    connectA11yBus(QString::fromLocal8Bit(addressEnv));
++                },
++                Qt::QueuedConnection);
++        return;
++    }
++
+     // Start monitoring if "org.a11y.Bus" is registered as DBus service.
+     QDBusConnection c = QDBusConnection::sessionBus();
+     if (!c.isConnected()) {
+diff --git a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
+index 1a3cab275d..2abe039126 100644
+--- a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
++++ b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
+@@ -51,6 +51,9 @@
+ #include <QtCore/QStandardPaths>
+ #include <QtCore/QUrl>
+ 
++#include <QtGui/QGuiApplication>
++#include <QtGui/QWindow>
++
+ #if QT_CONFIG(dbus)
+ // These QtCore includes are needed for xdg-desktop-portal support
+ #include <QtCore/private/qcore_unix_p.h>
+@@ -58,6 +61,8 @@
+ #include <QtCore/QFileInfo>
+ #include <QtCore/QUrlQuery>
+ 
++#include <QtGui/QColor>
++
+ #include <QtDBus/QDBusConnection>
+ #include <QtDBus/QDBusMessage>
+ #include <QtDBus/QDBusPendingCall>
+@@ -142,6 +147,8 @@ static inline bool detectWebBrowser(const QByteArray &desktop,
+     }
+ 
+     if (desktop == QByteArray("KDE")) {
++        if (checkExecutable(QStringLiteral("kde-open5"), browser))
++            return true;
+         // Konqueror launcher
+         if (checkExecutable(QStringLiteral("kfmclient"), browser)) {
+             browser->append(QLatin1String(" exec"));
+@@ -296,8 +303,135 @@ static inline QDBusMessage xdgDesktopPortalSendEmail(const QUrl &url)
+ 
+     return QDBusConnection::sessionBus().call(message);
+ }
++
++namespace {
++struct XDGDesktopColor
++{
++    double r = 0;
++    double g = 0;
++    double b = 0;
++
++    QColor toQColor() const
++    {
++        constexpr auto rgbMax = 255;
++        return { static_cast<int>(r * rgbMax), static_cast<int>(g * rgbMax),
++                 static_cast<int>(b * rgbMax) };
++    }
++};
++
++const QDBusArgument &operator>>(const QDBusArgument &argument, XDGDesktopColor &myStruct)
++{
++    argument.beginStructure();
++    argument >> myStruct.r >> myStruct.g >> myStruct.b;
++    argument.endStructure();
++    return argument;
++}
++
++class XdgDesktopPortalColorPicker : public QPlatformServiceColorPicker
++{
++    Q_OBJECT
++public:
++    XdgDesktopPortalColorPicker(const QString &parentWindowId, QWindow *parent)
++        : QPlatformServiceColorPicker(parent), m_parentWindowId(parentWindowId)
++    {
++    }
++
++    void pickColor() override
++    {
++        // DBus signature:
++        // PickColor (IN   s      parent_window,
++        //            IN   a{sv}  options
++        //            OUT  o      handle)
++        // Options:
++        // handle_token (s) -  A string that will be used as the last element of the @handle.
++
++        QDBusMessage message = QDBusMessage::createMethodCall(
++                QStringLiteral("org.freedesktop.portal.Desktop"), QStringLiteral("/org/freedesktop/portal/desktop"),
++                QStringLiteral("org.freedesktop.portal.Screenshot"), QStringLiteral("PickColor"));
++        message << m_parentWindowId << QVariantMap();
++
++        QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
++        auto watcher = new QDBusPendingCallWatcher(pendingCall, this);
++        connect(watcher, &QDBusPendingCallWatcher::finished, this,
++                [this](QDBusPendingCallWatcher *watcher) {
++                    watcher->deleteLater();
++                    QDBusPendingReply<QDBusObjectPath> reply = *watcher;
++                    if (reply.isError()) {
++                        qWarning("DBus call to pick color failed: %s",
++                                 qPrintable(reply.error().message()));
++                        Q_EMIT colorPicked({});
++                    } else {
++                        QDBusConnection::sessionBus().connect(
++                                QStringLiteral("org.freedesktop.portal.Desktop"), reply.value().path(),
++                                QStringLiteral("org.freedesktop.portal.Request"), QStringLiteral("Response"), this,
++                                // clang-format off
++                                SLOT(gotColorResponse(uint,QVariantMap))
++                                // clang-format on
++                        );
++                    }
++                });
++    }
++
++private Q_SLOTS:
++    void gotColorResponse(uint result, const QVariantMap &map)
++    {
++        if (result != 0)
++            return;
++        XDGDesktopColor color{};
++        map.value(QStringLiteral("color")).value<QDBusArgument>() >> color;
++        Q_EMIT colorPicked(color.toQColor());
++        deleteLater();
++    }
++
++private:
++    const QString m_parentWindowId;
++};
++} // namespace
++
+ #endif // QT_CONFIG(dbus)
+ 
++QGenericUnixServices::QGenericUnixServices()
++{
++#if QT_CONFIG(dbus)
++    if (qEnvironmentVariableIntValue("QT_NO_XDG_DESKTOP_PORTAL") > 0) {
++        return;
++    }
++    QDBusMessage message = QDBusMessage::createMethodCall(
++            QStringLiteral("org.freedesktop.portal.Desktop"), QStringLiteral("/org/freedesktop/portal/desktop"),
++            QStringLiteral("org.freedesktop.DBus.Properties"), QStringLiteral("Get"));
++    message << QStringLiteral("org.freedesktop.portal.Screenshot")
++            << QStringLiteral("version");
++
++    QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
++    auto watcher = new QDBusPendingCallWatcher(pendingCall);
++    QObject::connect(watcher, &QDBusPendingCallWatcher::finished, watcher,
++                     [this](QDBusPendingCallWatcher *watcher) {
++                         watcher->deleteLater();
++                         QDBusPendingReply<QVariant> reply = *watcher;
++                         if (!reply.isError() && reply.value().toUInt() >= 2)
++                             m_hasScreenshotPortalWithColorPicking = true;
++                     });
++
++#endif
++}
++
++QPlatformServiceColorPicker *QGenericUnixServices::colorPicker(QWindow *parent)
++{
++#if QT_CONFIG(dbus)
++    // Make double sure that we are in a wayland environment. In particular check
++    // WAYLAND_DISPLAY so also XWayland apps benefit from portal-based color picking.
++    // Outside wayland we'll rather rely on other means than the XDG desktop portal.
++    if (!qEnvironmentVariableIsEmpty("WAYLAND_DISPLAY")
++        || QGuiApplication::platformName().startsWith(QLatin1String("wayland"))) {
++        return new XdgDesktopPortalColorPicker(portalWindowIdentifier(parent), parent);
++    }
++    return nullptr;
++#else
++    Q_UNUSED(parent);
++    return nullptr;
++#endif
++}
++
+ QByteArray QGenericUnixServices::desktopEnvironment() const
+ {
+     static const QByteArray result = detectDesktopEnvironment();
+@@ -352,6 +486,8 @@ bool QGenericUnixServices::openDocument(const QUrl &url)
+ }
+ 
+ #else
++QGenericUnixServices::QGenericUnixServices() = default;
++
+ QByteArray QGenericUnixServices::desktopEnvironment() const
+ {
+     return QByteArrayLiteral("UNKNOWN");
+@@ -371,6 +507,30 @@ bool QGenericUnixServices::openDocument(const QUrl &url)
+     return false;
+ }
+ 
++QPlatformServiceColorPicker *QGenericUnixServices::colorPicker(QWindow *parent)
++{
++    Q_UNUSED(parent);
++    return nullptr;
++}
++
+ #endif // QT_NO_MULTIPROCESS
+ 
++QString QGenericUnixServices::portalWindowIdentifier(QWindow *window)
++{
++    if (QGuiApplication::platformName() == QLatin1String("xcb"))
++        return QStringLiteral("x11:") + QString::number(window->winId(), 16);
++    return QString();
++}
++
++bool QGenericUnixServices::hasCapability(Capability capability) const
++{
++    switch (capability) {
++    case Capability::ColorPicking:
++        return m_hasScreenshotPortalWithColorPicking;
++    }
++    return false;
++}
++
+ QT_END_NAMESPACE
++
++#include "qgenericunixservices.moc"
+diff --git a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
+index 8ac3de6f03..30924e64bd 100644
+--- a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
++++ b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices_p.h
+@@ -59,16 +59,21 @@ QT_BEGIN_NAMESPACE
+ class QGenericUnixServices : public QPlatformServices
+ {
+ public:
+-    QGenericUnixServices() {}
++    QGenericUnixServices();
+ 
+     QByteArray desktopEnvironment() const override;
+ 
++    bool hasCapability(Capability capability) const override;
+     bool openUrl(const QUrl &url) override;
+     bool openDocument(const QUrl &url) override;
++    QPlatformServiceColorPicker *colorPicker(QWindow *parent = nullptr) override;
++
++    virtual QString portalWindowIdentifier(QWindow *window);
+ 
+ private:
+     QString m_webBrowser;
+     QString m_documentLauncher;
++    bool m_hasScreenshotPortalWithColorPicking = false;
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
+index 09470bccc6..cc7c7d4d8a 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection.cpp
+@@ -69,6 +69,7 @@ const QString MenuBarPath = QLatin1String("/MenuBar");
+ */
+ QDBusMenuConnection::QDBusMenuConnection(QObject *parent, const QString &serviceName)
+     : QObject(parent)
++    , m_serviceName(serviceName)
+     , m_connection(serviceName.isNull() ? QDBusConnection::sessionBus()
+                                         : QDBusConnection::connectToBus(QDBusConnection::SessionBus, serviceName))
+     , m_dbusWatcher(new QDBusServiceWatcher(StatusNotifierWatcherService, m_connection, QDBusServiceWatcher::WatchForRegistration, this))
+@@ -83,6 +84,12 @@ QDBusMenuConnection::QDBusMenuConnection(QObject *parent, const QString &service
+ #endif
+ }
+ 
++QDBusMenuConnection::~QDBusMenuConnection()
++{
++  if (!m_serviceName.isEmpty() && m_connection.isConnected())
++      QDBusConnection::disconnectFromBus(m_serviceName);
++}
++
+ void QDBusMenuConnection::dbusError(const QDBusError &error)
+ {
+     qWarning() << "QDBusTrayIcon encountered a D-Bus error:" << error;
+@@ -105,13 +112,7 @@ void QDBusMenuConnection::unregisterTrayIconMenu(QDBusTrayIcon *item)
+ 
+ bool QDBusMenuConnection::registerTrayIcon(QDBusTrayIcon *item)
+ {
+-    bool success = connection().registerService(item->instanceId());
+-    if (!success) {
+-        qWarning() << "failed to register service" << item->instanceId();
+-        return false;
+-    }
+-
+-    success = connection().registerObject(StatusNotifierItemPath, item);
++    bool success = connection().registerObject(StatusNotifierItemPath, item);
+     if (!success) {
+         unregisterTrayIcon(item);
+         qWarning() << "failed to register" << item->instanceId() << StatusNotifierItemPath;
+@@ -126,21 +127,18 @@ bool QDBusMenuConnection::registerTrayIcon(QDBusTrayIcon *item)
+ 
+ bool QDBusMenuConnection::registerTrayIconWithWatcher(QDBusTrayIcon *item)
+ {
++    Q_UNUSED(item);
+     QDBusMessage registerMethod = QDBusMessage::createMethodCall(
+                 StatusNotifierWatcherService, StatusNotifierWatcherPath, StatusNotifierWatcherService,
+                 QLatin1String("RegisterStatusNotifierItem"));
+-    registerMethod.setArguments(QVariantList() << item->instanceId());
++    registerMethod.setArguments(QVariantList() << m_connection.baseService());
+     return m_connection.callWithCallback(registerMethod, this, SIGNAL(trayIconRegistered()), SLOT(dbusError(QDBusError)));
+ }
+ 
+-bool QDBusMenuConnection::unregisterTrayIcon(QDBusTrayIcon *item)
++void QDBusMenuConnection::unregisterTrayIcon(QDBusTrayIcon *item)
+ {
+     unregisterTrayIconMenu(item);
+     connection().unregisterObject(StatusNotifierItemPath);
+-    bool success = connection().unregisterService(item->instanceId());
+-    if (!success)
+-        qWarning() << "failed to unregister service" << item->instanceId();
+-    return success;
+ }
+ #endif // QT_NO_SYSTEMTRAYICON
+ 
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
+index f484795fbb..97bdfabb85 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
++++ b/qtbase/src/platformsupport/themes/genericunix/dbusmenu/qdbusmenuconnection_p.h
+@@ -70,6 +70,7 @@ class QDBusMenuConnection : public QObject
+ 
+ public:
+     QDBusMenuConnection(QObject *parent = nullptr, const QString &serviceName = QString());
++    ~QDBusMenuConnection();
+     QDBusConnection connection() const { return m_connection; }
+     QDBusServiceWatcher *dbusWatcher() const { return m_dbusWatcher; }
+     bool isStatusNotifierHostRegistered() const { return m_statusNotifierHostRegistered; }
+@@ -78,7 +79,7 @@ public:
+     void unregisterTrayIconMenu(QDBusTrayIcon *item);
+     bool registerTrayIcon(QDBusTrayIcon *item);
+     bool registerTrayIconWithWatcher(QDBusTrayIcon *item);
+-    bool unregisterTrayIcon(QDBusTrayIcon *item);
++    void unregisterTrayIcon(QDBusTrayIcon *item);
+ #endif // QT_NO_SYSTEMTRAYICON
+ 
+ Q_SIGNALS:
+@@ -90,6 +91,7 @@ private Q_SLOTS:
+     void dbusError(const QDBusError &error);
+ 
+ private:
++    QString m_serviceName;
+     QDBusConnection m_connection;
+     QDBusServiceWatcher *m_dbusWatcher;
+     bool m_statusNotifierHostRegistered;
+diff --git a/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp b/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
+index bede70975a..76bfec5e5a 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp
+@@ -71,8 +71,12 @@ Q_LOGGING_CATEGORY(qLcTray, "qt.qpa.tray")
+ static QString iconTempPath()
+ {
+     QString tempPath = QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation);
+-    if (!tempPath.isEmpty())
++    if (!tempPath.isEmpty()) {
++        QString flatpakId = qEnvironmentVariable("FLATPAK_ID");
++        if (!flatpakId.isEmpty() && QFileInfo::exists(QLatin1String("/.flatpak-info")))
++            tempPath += QLatin1String("/app/") + flatpakId;
+         return tempPath;
++    }
+ 
+     tempPath = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation);
+ 
+diff --git a/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+index cb1b39db64..6e01af052c 100644
+--- a/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
++++ b/qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+@@ -755,6 +755,9 @@ QVariant QGnomeTheme::themeHint(QPlatformTheme::ThemeHint hint) const
+         return QVariant(QChar(0x2022));
+     case QPlatformTheme::UiEffects:
+         return QVariant(int(HoverEffect));
++    case QPlatformTheme::ButtonPressKeys:
++        return QVariant::fromValue(
++                QList<Qt::Key>({ Qt::Key_Space, Qt::Key_Return, Qt::Key_Enter, Qt::Key_Select }));
+     default:
+         break;
+     }
+diff --git a/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp b/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
+index 98e05195ee..1e92f43dec 100644
+--- a/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
++++ b/qtbase/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
+@@ -343,8 +343,7 @@ void QEglFSCursor::paintOnScreen()
+     // screens are siblings of each other. When not enabled, the sibling list
+     // only contains m_screen itself.
+     for (QPlatformScreen *screen : m_screen->virtualSiblings()) {
+-        if (screen->geometry().contains(cr.topLeft().toPoint() + m_cursor.hotSpot)
+-            && QOpenGLContext::currentContext()->screen() == screen->screen())
++        if (screen->geometry().contains(cr.topLeft().toPoint() + m_cursor.hotSpot))
+         {
+             cr.translate(-screen->geometry().topLeft());
+             const QSize screenSize = screen->geometry().size();
+@@ -468,11 +467,12 @@ void QEglFSCursor::draw(const QRectF &r)
+ {
+     StateSaver stateSaver;
+ 
+-    QEglFSCursorData &gfx = static_cast<QEglFSContext*>(QOpenGLContext::currentContext()->handle())->cursorData;
+-    if (!gfx.program) {
+-        // one time initialization
++    // one time initialization
++    if (!QOpenGLFunctions::d_ptr)
+         initializeOpenGLFunctions();
+ 
++    QEglFSCursorData &gfx = static_cast<QEglFSContext*>(QOpenGLContext::currentContext()->handle())->cursorData;
++    if (!gfx.program) {
+         createShaderPrograms();
+ 
+         if (!gfx.atlasTexture) {
+diff --git a/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp b/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
+index 645a0ae2e9..3e0e406f1a 100644
+--- a/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
++++ b/qtbase/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp
+@@ -179,7 +179,7 @@ void QEglFSKmsEventReader::create(QEglFSKmsDevice *device)
+ 
+     m_device = device;
+ 
+-    qCDebug(qLcEglfsKmsDebug, "Initalizing event reader for device %p fd %d",
++    qCDebug(qLcEglfsKmsDebug, "Initializing event reader for device %p fd %d",
+             m_device, m_device->fd());
+ 
+     m_thread = new QEglFSKmsEventReaderThread(m_device->fd());
+diff --git a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
+index 141fb68a23..d4294d425a 100644
+--- a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
++++ b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.cpp
+@@ -122,11 +122,13 @@ QOffscreenIntegration::QOffscreenIntegration()
+ #endif
+     m_services.reset(new QPlatformServices);
+ 
+-    QWindowSystemInterface::handleScreenAdded(new QOffscreenScreen);
++    m_screen = new QOffscreenScreen;
++    QWindowSystemInterface::handleScreenAdded(m_screen);
+ }
+ 
+ QOffscreenIntegration::~QOffscreenIntegration()
+ {
++    QWindowSystemInterface::handleScreenRemoved(m_screen);
+ }
+ 
+ void QOffscreenIntegration::initialize()
+diff --git a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
+index 0ea90f6c2f..fe00fde07c 100644
+--- a/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
++++ b/qtbase/src/plugins/platforms/offscreen/qoffscreenintegration.h
+@@ -84,6 +84,7 @@ protected:
+ #endif
+     QScopedPointer<QPlatformInputContext> m_inputContext;
+     QScopedPointer<QPlatformServices> m_services;
++    QPlatformScreen *m_screen;
+     mutable QScopedPointer<QPlatformNativeInterface> m_nativeInterface;
+ };
+ 
+diff --git a/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp b/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
+index 6fa5a8a2b3..1f49f0aefd 100644
+--- a/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
++++ b/qtbase/src/plugins/platforms/windows/qwindowsglcontext.cpp
+@@ -48,6 +48,7 @@
+ #include <qpa/qplatformnativeinterface.h>
+ #include <QtPlatformHeaders/qwglnativecontext.h>
+ 
++#include <private/qsystemlibrary_p.h>
+ #include <algorithm>
+ 
+ #include <wingdi.h>
+@@ -162,19 +163,25 @@ QFunctionPointer QWindowsOpengl32DLL::resolve(const char *name)
+ 
+ bool QWindowsOpengl32DLL::init(bool softwareRendering)
+ {
+-    const QByteArray opengl32 = QByteArrayLiteral("opengl32.dll");
+-    const QByteArray swopengl = QByteArrayLiteral("opengl32sw.dll");
++    const QByteArray opengl32 = QByteArrayLiteral("opengl32");
++    const QByteArray swopengl = QByteArrayLiteral("opengl32sw");
++    bool useSystemLib = false;
+ 
+     QByteArray openglDll = qgetenv("QT_OPENGL_DLL");
+-    if (openglDll.isEmpty())
++    if (openglDll.isEmpty()) {
+         openglDll = softwareRendering ? swopengl : opengl32;
++        useSystemLib = !softwareRendering;
++    }
+ 
+     openglDll = openglDll.toLower();
+     m_nonOpengl32 = openglDll != opengl32;
+ 
+     qCDebug(lcQpaGl) << "Qt: Using WGL and OpenGL from" << openglDll;
+ 
+-    m_lib = ::LoadLibraryA(openglDll.constData());
++    if (useSystemLib)
++        m_lib = QSystemLibrary::load((wchar_t*)(QString::fromLatin1(openglDll).utf16()));
++    else
++        m_lib = LoadLibraryA(openglDll.constData());
+     if (!m_lib) {
+         qErrnoWarning(::GetLastError(), "Failed to load %s", openglDll.constData());
+         return false;
+@@ -184,7 +191,7 @@ bool QWindowsOpengl32DLL::init(bool softwareRendering)
+         // Load opengl32.dll always. GDI functions like ChoosePixelFormat do
+         // GetModuleHandle for opengl32.dll and behave differently (and call back into
+         // opengl32) when the module is present. This is fine for dummy contexts and windows.
+-        ::LoadLibraryA("opengl32.dll");
++        QSystemLibrary::load(L"opengl32");
+     }
+ 
+     wglCreateContext = reinterpret_cast<HGLRC (WINAPI *)(HDC)>(resolve("wglCreateContext"));
+diff --git a/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp b/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
+index d7d186e804..9eb4011bf2 100644
+--- a/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
++++ b/qtbase/src/plugins/platforms/windows/qwindowsopengltester.cpp
+@@ -49,6 +49,7 @@
+ #include <QtCore/qstandardpaths.h>
+ #include <QtCore/qlibraryinfo.h>
+ #include <QtCore/qhash.h>
++#include <private/qsystemlibrary_p.h>
+ 
+ #ifndef QT_NO_OPENGL
+ #include <private/qopengl_p.h>
+@@ -396,7 +397,7 @@ bool QWindowsOpenGLTester::testDesktopGL()
+ 
+     // Test #1: Load opengl32.dll and try to resolve an OpenGL 2 function.
+     // This will typically fail on systems that do not have a real OpenGL driver.
+-    lib = LoadLibraryA("opengl32.dll");
++    lib = QSystemLibrary::load(L"opengl32");
+     if (lib) {
+         CreateContext = reinterpret_cast<CreateContextType>(
+             reinterpret_cast<QFunctionPointer>(::GetProcAddress(lib, "wglCreateContext")));
+diff --git a/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp b/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
+index 1afa00cfc9..118af6ce73 100644
+--- a/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
++++ b/qtbase/src/plugins/platforms/xcb/nativepainting/qtessellator.cpp
+@@ -41,6 +41,7 @@
+ 
+ #include <QRect>
+ #include <QList>
++#include <QMap>
+ #include <QDebug>
+ 
+ #include <qmath.h>
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp b/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
+index 9e2a37a6a1..e6e175a118 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp
+@@ -488,12 +488,12 @@ void QXcbConnection::printXcbError(const char *message, xcb_generic_error_t *err
+     uint clamped_error_code = qMin<uint>(error->error_code, (sizeof(xcb_errors) / sizeof(xcb_errors[0])) - 1);
+     uint clamped_major_code = qMin<uint>(error->major_code, (sizeof(xcb_protocol_request_codes) / sizeof(xcb_protocol_request_codes[0])) - 1);
+ 
+-    qCWarning(lcQpaXcb, "%s: %d (%s), sequence: %d, resource id: %d, major code: %d (%s), minor code: %d",
+-             message,
+-             int(error->error_code), xcb_errors[clamped_error_code],
+-             int(error->sequence), int(error->resource_id),
+-             int(error->major_code), xcb_protocol_request_codes[clamped_major_code],
+-             int(error->minor_code));
++    qCDebug(lcQpaXcb, "%s: %d (%s), sequence: %d, resource id: %d, major code: %d (%s), minor code: %d",
++            message,
++            int(error->error_code), xcb_errors[clamped_error_code],
++            int(error->sequence), int(error->resource_id),
++            int(error->major_code), xcb_protocol_request_codes[clamped_major_code],
++            int(error->minor_code));
+ }
+ 
+ static Qt::MouseButtons translateMouseButtons(int s)
+@@ -702,6 +702,8 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
+             QXcbVirtualDesktop *virtualDesktop = virtualDesktopForRootWindow(propertyNotify->window);
+             if (virtualDesktop)
+                 virtualDesktop->updateWorkArea();
++        } else if (propertyNotify->atom == atom(QXcbAtom::_NET_SUPPORTED)) {
++            m_wmSupport->updateNetWMAtoms();
+         } else {
+             HANDLE_PLATFORM_WINDOW_EVENT(xcb_property_notify_event_t, window, handlePropertyNotifyEvent);
+         }
+@@ -750,7 +752,7 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
+                 case XCB_XKB_NEW_KEYBOARD_NOTIFY: {
+                     xcb_xkb_new_keyboard_notify_event_t *ev = &xkb_event->new_keyboard_notify;
+                     if (ev->changed & XCB_XKB_NKN_DETAIL_KEYCODES)
+-                        m_keyboard->updateKeymap(ev);
++                        m_keyboard->updateKeymap();
+                     break;
+                 }
+                 default:
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp b/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
+index 76869ced60..02d2eebb56 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbintegration.cpp
+@@ -274,8 +274,7 @@ QPlatformWindow *QXcbIntegration::createForeignWindow(QWindow *window, WId nativ
+ #ifndef QT_NO_OPENGL
+ QPlatformOpenGLContext *QXcbIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
+ {
+-    QXcbScreen *screen = static_cast<QXcbScreen *>(context->screen()->handle());
+-    QXcbGlIntegration *glIntegration = screen->connection()->glIntegration();
++    QXcbGlIntegration *glIntegration = defaultConnection()->glIntegration();
+     if (!glIntegration) {
+         qWarning("QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled");
+         return nullptr;
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+index efecd7e2d1..e8286381a2 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+@@ -365,17 +365,6 @@ void QXcbKeyboard::updateKeymap(xcb_mapping_notify_event_t *event)
+     updateKeymap();
+ }
+ 
+-void QXcbKeyboard::updateKeymap(xcb_xkb_new_keyboard_notify_event_t *event)
+-{
+-    if (!event)
+-        return;
+-
+-    if (event->deviceID != event->oldDeviceID)
+-        m_config = false;
+-
+-    updateKeymap();
+-}
+-
+ void QXcbKeyboard::updateKeymap()
+ {
+     KeysymModifierMap keysymMods;
+@@ -383,6 +372,8 @@ void QXcbKeyboard::updateKeymap()
+         keysymMods = keysymsToModifiers();
+     updateModifiers(keysymMods);
+ 
++    m_config = true;
++
+     if (!m_xkbContext) {
+         m_xkbContext.reset(xkb_context_new(XKB_CONTEXT_NO_DEFAULT_INCLUDES));
+         if (!m_xkbContext) {
+@@ -398,13 +389,8 @@ void QXcbKeyboard::updateKeymap()
+     if (connection()->hasXKB()) {
+         m_xkbKeymap.reset(xkb_x11_keymap_new_from_device(m_xkbContext.get(), xcb_connection(),
+                                                          core_device_id, XKB_KEYMAP_COMPILE_NO_FLAGS));
+-        if (m_xkbKeymap) {
+-            if (m_config)
+-                m_xkbState.reset(xkb_state_new(m_xkbKeymap.get()));
+-            else
+-                m_xkbState.reset(xkb_x11_state_new_from_device(m_xkbKeymap.get(), xcb_connection(), core_device_id));
+-
+-        }
++        if (m_xkbKeymap)
++            m_xkbState.reset(xkb_x11_state_new_from_device(m_xkbKeymap.get(), xcb_connection(), core_device_id));
+     } else {
+         m_xkbKeymap.reset(keymapFromCore(keysymMods));
+         if (m_xkbKeymap)
+@@ -425,8 +411,6 @@ void QXcbKeyboard::updateKeymap()
+     updateXKBMods();
+ 
+     QXkbCommon::verifyHasLatinLayout(m_xkbKeymap.get());
+-
+-    m_config = true;
+ }
+ 
+ QList<int> QXcbKeyboard::possibleKeys(const QKeyEvent *event) const
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
+index b652c85fe3..0ee08aeff2 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
++++ b/qtbase/src/plugins/platforms/xcb/qxcbkeyboard.h
+@@ -69,7 +69,6 @@ public:
+ 
+     Qt::KeyboardModifiers translateModifiers(int s) const;
+     void updateKeymap(xcb_mapping_notify_event_t *event);
+-    void updateKeymap(xcb_xkb_new_keyboard_notify_event_t *event);
+     void updateKeymap();
+     QList<int> possibleKeys(const QKeyEvent *event) const;
+ 
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp b/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
+index ffda7b6a57..863e961f4c 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
++++ b/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp
+@@ -564,11 +564,6 @@ void QXcbWindow::setGeometry(const QRect &rect)
+ {
+     QPlatformWindow::setGeometry(rect);
+ 
+-    if (shouldDeferTask(Task::SetGeometry)) {
+-        m_deferredGeometry = rect;
+-        return;
+-    }
+-
+     propagateSizeHints();
+ 
+     QXcbScreen *currentScreen = xcbScreen();
+@@ -693,9 +688,6 @@ void QXcbWindow::setVisible(bool visible)
+ 
+ void QXcbWindow::show()
+ {
+-    if (shouldDeferTask(Task::Map))
+-        return;
+-
+     if (window()->isTopLevel()) {
+ 
+         // update WM_NORMAL_HINTS
+@@ -706,7 +698,7 @@ void QXcbWindow::show()
+         if (isTransient(window())) {
+             const QWindow *tp = window()->transientParent();
+             if (tp && tp->handle())
+-                transientXcbParent = static_cast<const QXcbWindow *>(tp->handle())->winId();
++                transientXcbParent = tp->handle()->winId();
+             // Default to client leader if there is no transient parent, else modal dialogs can
+             // be hidden by their parents.
+             if (!transientXcbParent)
+@@ -746,10 +738,6 @@ void QXcbWindow::show()
+ 
+ void QXcbWindow::hide()
+ {
+-    if (shouldDeferTask(Task::Unmap))
+-        return;
+-
+-    m_wmStateValid = false;
+     xcb_unmap_window(xcb_connection(), m_window);
+ 
+     // send synthetic UnmapNotify event according to icccm 4.1.4
+@@ -909,9 +897,6 @@ QXcbWindow::NetWmStates QXcbWindow::netWmStates()
+ 
+ void QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
+ {
+-    if (shouldDeferTask(Task::SetWindowFlags))
+-        return;
+-
+     Qt::WindowType type = static_cast<Qt::WindowType>(int(flags & Qt::WindowType_Mask));
+ 
+     if (type == Qt::ToolTip)
+@@ -941,8 +926,6 @@ void QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
+ 
+     setTransparentForMouseEvents(flags & Qt::WindowTransparentForInput);
+     updateDoesNotAcceptFocus(flags & Qt::WindowDoesNotAcceptFocus);
+-
+-    m_isWmManagedWindow = !(flags & Qt::X11BypassWindowManagerHint);
+ }
+ 
+ void QXcbWindow::setMotifWmHints(Qt::WindowFlags flags)
+@@ -1142,9 +1125,6 @@ void QXcbWindow::setWindowState(Qt::WindowStates state)
+     if (state == m_windowState)
+         return;
+ 
+-    if (shouldDeferTask(Task::SetWindowState))
+-        return;
+-
+     // unset old state
+     if (m_windowState & Qt::WindowMinimized)
+         xcb_map_window(xcb_connection(), m_window);
+@@ -1350,6 +1330,12 @@ void QXcbWindow::setWindowIcon(const QIcon &icon)
+     }
+ 
+     if (!icon_data.isEmpty()) {
++        // Ignore icon exceeding maximum xcb request length
++        if (icon_data.size() > xcb_get_maximum_request_length(xcb_connection())) {
++            qWarning("Ignoring window icon: Size %llu exceeds maximum xcb request length %u.",
++                     icon_data.size(), xcb_get_maximum_request_length(xcb_connection()));
++            return;
++        }
+         xcb_change_property(xcb_connection(),
+                             XCB_PROP_MODE_REPLACE,
+                             m_window,
+@@ -1639,7 +1625,7 @@ void QXcbWindow::setWmWindowType(QXcbWindowFunctions::WmWindowTypes types, Qt::W
+         break;
+     }
+ 
+-    if ((flags & Qt::FramelessWindowHint) && !(type & QXcbWindowFunctions::KdeOverride)) {
++    if ((flags & Qt::FramelessWindowHint) && !(types & QXcbWindowFunctions::KdeOverride)) {
+         // override netwm type - quick and easy for KDE noborder
+         atoms.append(atom(QXcbAtom::_KDE_NET_WM_WINDOW_TYPE_OVERRIDE));
+     }
+@@ -1894,10 +1880,6 @@ void QXcbWindow::handleUnmapNotifyEvent(const xcb_unmap_notify_event_t *event)
+     if (event->window == m_window) {
+         m_mapped = false;
+         QWindowSystemInterface::handleExposeEvent(window(), QRegion());
+-        if (!m_isWmManagedWindow || parent()) {
+-            m_wmStateValid = true;
+-            handleDeferredTasks();
+-        }
+     }
+ }
+ 
+@@ -2212,98 +2194,30 @@ void QXcbWindow::handleLeaveNotifyEvent(const xcb_leave_notify_event_t *event)
+     handleLeaveNotifyEvent(event->root_x, event->root_y, event->mode, event->detail, event->time);
+ }
+ 
+-bool QXcbWindow::shouldDeferTask(Task task)
+-{
+-    if (m_wmStateValid)
+-        return false;
+-
+-    m_deferredTasks.append(task);
+-    return true;
+-}
+-
+-void QXcbWindow::handleDeferredTasks()
+-{
+-    Q_ASSERT(m_wmStateValid == true);
+-    if (m_deferredTasks.isEmpty())
+-        return;
+-
+-    bool map = false;
+-    bool unmap = false;
+-
+-    QVector<Task> tasks;
+-    for (auto taskIt = m_deferredTasks.rbegin(); taskIt != m_deferredTasks.rend(); ++taskIt) {
+-        if (!tasks.contains(*taskIt))
+-            tasks.prepend(*taskIt);
+-    }
+-
+-    for (Task task : tasks) {
+-        switch (task) {
+-        case Task::Map:
+-            map = true;
+-            unmap = false;
+-            break;
+-        case Task::Unmap:
+-            unmap = true;
+-            map = false;
+-            break;
+-        case Task::SetGeometry:
+-            setGeometry(m_deferredGeometry);
+-            break;
+-        case Task::SetWindowFlags:
+-            setWindowFlags(window()->flags());
+-            break;
+-        case Task::SetWindowState:
+-            setWindowState(window()->windowState());
+-            break;
+-        }
+-    }
+-    m_deferredTasks.clear();
+-
+-    if (map) {
+-        Q_ASSERT(unmap == false);
+-        show();
+-    }
+-    if (unmap) {
+-        Q_ASSERT(map == false);
+-        hide();
+-    }
+-}
+-
+ void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *event)
+ {
+     connection()->setTime(event->time);
+ 
+-    const bool wmStateChanged = event->atom == atom(QXcbAtom::WM_STATE);
+-    const bool netWmStateChanged = event->atom == atom(QXcbAtom::_NET_WM_STATE);
+-    if (netWmStateChanged || wmStateChanged) {
+-        if (wmStateChanged && !m_wmStateValid && m_isWmManagedWindow) {
+-            // ICCCM 4.1.4
+-            // Clients that want to re-use a client window (e.g. by mapping it again)
+-            // after withdrawing it must wait for the withdrawal to be complete before
+-            // proceeding. The preferred method for doing this is for clients to wait for
+-            // a window manager to update or remove the WM_STATE property.
+-            m_wmStateValid = true;
+-            handleDeferredTasks();
+-        }
+-        if (event->state == XCB_PROPERTY_DELETE)
++    const bool propertyDeleted = event->state == XCB_PROPERTY_DELETE;
++
++    if (event->atom == atom(QXcbAtom::_NET_WM_STATE) || event->atom == atom(QXcbAtom::WM_STATE)) {
++        if (propertyDeleted)
+             return;
+ 
+-        if (wmStateChanged) {
++        Qt::WindowStates newState = Qt::WindowNoState;
++
++        if (event->atom == atom(QXcbAtom::WM_STATE)) { // WM_STATE: Quick check for 'Minimize'.
+             auto reply = Q_XCB_REPLY(xcb_get_property, xcb_connection(),
+                                      0, m_window, atom(QXcbAtom::WM_STATE),
+                                      XCB_ATOM_ANY, 0, 1024);
+             if (reply && reply->format == 32 && reply->type == atom(QXcbAtom::WM_STATE)) {
+-                auto data = static_cast<const quint32 *>(xcb_get_property_value(reply.get()));
+-                if (reply->length != 0) {
+-                    const bool changedToWithdrawn = data[0] == XCB_ICCCM_WM_STATE_WITHDRAWN;
+-                    const bool changedToIconic = data[0] == XCB_ICCCM_WM_STATE_ICONIC;
+-                    m_minimized = changedToIconic || (changedToWithdrawn && m_minimized);
+-                }
++                const quint32 *data = (const quint32 *)xcb_get_property_value(reply.get());
++                if (reply->length != 0)
++                    m_minimized = (data[0] == XCB_ICCCM_WM_STATE_ICONIC
++                                   || (data[0] == XCB_ICCCM_WM_STATE_WITHDRAWN && m_minimized));
+             }
+         }
+ 
+-        // _NET_WM_STATE handling
+-        Qt::WindowStates newState = Qt::WindowNoState;
+         const NetWmStates states = netWmStates();
+         // _NET_WM_STATE_HIDDEN should be set by the Window Manager to indicate that a window would
+         // not be visible on the screen if its desktop/viewport were active and its coordinates were
+@@ -2325,6 +2239,7 @@ void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *ev
+             if ((m_windowState & Qt::WindowMinimized) && connection()->mouseGrabber() == this)
+                 connection()->setMouseGrabber(nullptr);
+         }
++        return;
+     } else if (event->atom == atom(QXcbAtom::_NET_FRAME_EXTENTS)) {
+         m_dirtyFrameMargins = true;
+     }
+diff --git a/qtbase/src/plugins/platforms/xcb/qxcbwindow.h b/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
+index 55af9279b1..6f5c1f5ed9 100644
+--- a/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
++++ b/qtbase/src/plugins/platforms/xcb/qxcbwindow.h
+@@ -74,14 +74,6 @@ public:
+ 
+     Q_DECLARE_FLAGS(NetWmStates, NetWmState)
+ 
+-    enum Task {
+-        Map,
+-        Unmap,
+-        SetGeometry,
+-        SetWindowFlags,
+-        SetWindowState
+-    };
+-
+     QXcbWindow(QWindow *window);
+     ~QXcbWindow();
+ 
+@@ -151,9 +143,6 @@ public:
+ 
+     QXcbWindow *toWindow() override;
+ 
+-    bool shouldDeferTask(Task task);
+-    void handleDeferredTasks();
+-
+     void handleMouseEvent(xcb_timestamp_t time, const QPoint &local, const QPoint &global,
+                           Qt::KeyboardModifiers modifiers, QEvent::Type type, Qt::MouseEventSource source);
+ 
+@@ -292,11 +281,6 @@ protected:
+     int m_swapInterval = -1;
+ 
+     qreal m_sizeHintsScaleFactor = 1.0;
+-
+-    bool m_wmStateValid = true;
+-    QVector<Task> m_deferredTasks;
+-    bool m_isWmManagedWindow = true;
+-    QRect m_deferredGeometry;
+ };
+ 
+ class QXcbForeignWindow : public QXcbWindow
+diff --git a/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp b/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
+index d9d117faeb..640b49daa0 100644
+--- a/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
++++ b/qtbase/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
+@@ -85,6 +85,7 @@ QGtk3MenuItem::QGtk3MenuItem()
+       m_checkable(false),
+       m_checked(false),
+       m_enabled(true),
++      m_exclusive(false),
+       m_underline(false),
+       m_invalid(true),
+       m_menu(nullptr),
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
+index 0048bbc1e6..396e7f6d1c 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp
+@@ -102,15 +102,12 @@ const QDBusArgument &operator >>(const QDBusArgument &arg, QXdgDesktopPortalFile
+ class QXdgDesktopPortalFileDialogPrivate
+ {
+ public:
+-    QXdgDesktopPortalFileDialogPrivate(QPlatformFileDialogHelper *nativeFileDialog)
++    QXdgDesktopPortalFileDialogPrivate(QPlatformFileDialogHelper *nativeFileDialog, uint fileChooserPortalVersion)
+         : nativeFileDialog(nativeFileDialog)
++        , fileChooserPortalVersion(fileChooserPortalVersion)
+     { }
+ 
+-    WId winId = 0;
+-    bool directoryMode = false;
+-    bool modal = false;
+-    bool multipleFiles = false;
+-    bool saveFile = false;
++    QEventLoop loop;
+     QString acceptLabel;
+     QString directory;
+     QString title;
+@@ -121,19 +118,27 @@ public:
+     QString selectedMimeTypeFilter;
+     QString selectedNameFilter;
+     QStringList selectedFiles;
+-    QPlatformFileDialogHelper *nativeFileDialog = nullptr;
++    std::unique_ptr<QPlatformFileDialogHelper> nativeFileDialog;
++    uint fileChooserPortalVersion = 0;
++    bool failedToOpen = false;
++    bool directoryMode = false;
++    bool multipleFiles = false;
++    bool saveFile = false;
+ };
+ 
+-QXdgDesktopPortalFileDialog::QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog)
++QXdgDesktopPortalFileDialog::QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog, uint fileChooserPortalVersion)
+     : QPlatformFileDialogHelper()
+-    , d_ptr(new QXdgDesktopPortalFileDialogPrivate(nativeFileDialog))
++    , d_ptr(new QXdgDesktopPortalFileDialogPrivate(nativeFileDialog, fileChooserPortalVersion))
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+     if (d->nativeFileDialog) {
+-        connect(d->nativeFileDialog, SIGNAL(accept()), this, SIGNAL(accept()));
+-        connect(d->nativeFileDialog, SIGNAL(reject()), this, SIGNAL(reject()));
++        connect(d->nativeFileDialog.get(), SIGNAL(accept()), this, SIGNAL(accept()));
++        connect(d->nativeFileDialog.get(), SIGNAL(reject()), this, SIGNAL(reject()));
+     }
++
++    d->loop.connect(this, SIGNAL(accept()), SLOT(quit()));
++    d->loop.connect(this, SIGNAL(reject()), SLOT(quit()));
+ }
+ 
+ QXdgDesktopPortalFileDialog::~QXdgDesktopPortalFileDialog()
+@@ -177,7 +182,7 @@ void QXdgDesktopPortalFileDialog::initializeDialog()
+     setDirectory(options()->initialDirectory());
+ }
+ 
+-void QXdgDesktopPortalFileDialog::openPortal()
++void QXdgDesktopPortalFileDialog::openPortal(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent)
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+@@ -185,13 +190,13 @@ void QXdgDesktopPortalFileDialog::openPortal()
+                                                           QLatin1String("/org/freedesktop/portal/desktop"),
+                                                           QLatin1String("org.freedesktop.portal.FileChooser"),
+                                                           d->saveFile ? QLatin1String("SaveFile") : QLatin1String("OpenFile"));
+-    QString parentWindowId = QLatin1String("x11:") + QString::number(d->winId, 16);
++    QString parentWindowId = QLatin1String("x11:") + QString::number(parent ? parent->winId() : 0, 16);
+ 
+     QVariantMap options;
+     if (!d->acceptLabel.isEmpty())
+         options.insert(QLatin1String("accept_label"), d->acceptLabel);
+ 
+-    options.insert(QLatin1String("modal"), d->modal);
++    options.insert(QLatin1String("modal"), windowModality != Qt::NonModal);
+     options.insert(QLatin1String("multiple"), d->multipleFiles);
+     options.insert(QLatin1String("directory"), d->directoryMode);
+ 
+@@ -290,10 +295,18 @@ void QXdgDesktopPortalFileDialog::openPortal()
+ 
+     QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
+     QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingCall);
+-    connect(watcher, &QDBusPendingCallWatcher::finished, this, [this] (QDBusPendingCallWatcher *watcher) {
++    connect(watcher, &QDBusPendingCallWatcher::finished, this, [=] (QDBusPendingCallWatcher *watcher) {
+         QDBusPendingReply<QDBusObjectPath> reply = *watcher;
+-        if (reply.isError()) {
+-            Q_EMIT reject();
++        // Any error means the dialog is not shown and we need to fallback
++        d->failedToOpen = reply.isError();
++        if (d->failedToOpen) {
++            if (d->nativeFileDialog) {
++                d->nativeFileDialog->show(windowFlags, windowModality, parent);
++                if (d->loop.isRunning())
++                    d->nativeFileDialog->exec();
++            } else {
++                Q_EMIT reject();
++            }
+         } else {
+             QDBusConnection::sessionBus().connect(nullptr,
+                                                   reply.value().path(),
+@@ -302,6 +315,7 @@ void QXdgDesktopPortalFileDialog::openPortal()
+                                                   this,
+                                                   SLOT(gotResponse(uint,QVariantMap)));
+         }
++        watcher->deleteLater();
+     });
+ }
+ 
+@@ -326,7 +340,7 @@ QUrl QXdgDesktopPortalFileDialog::directory() const
+ {
+     Q_D(const QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog())
+         return d->nativeFileDialog->directory();
+ 
+     return d->directory;
+@@ -348,7 +362,7 @@ QList<QUrl> QXdgDesktopPortalFileDialog::selectedFiles() const
+ {
+     Q_D(const QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog())
+         return d->nativeFileDialog->selectedFiles();
+ 
+     QList<QUrl> files;
+@@ -403,16 +417,13 @@ void QXdgDesktopPortalFileDialog::exec()
+ {
+     Q_D(QXdgDesktopPortalFileDialog);
+ 
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly)) {
++    if (d->nativeFileDialog && useNativeFileDialog()) {
+         d->nativeFileDialog->exec();
+         return;
+     }
+ 
+     // HACK we have to avoid returning until we emit that the dialog was accepted or rejected
+-    QEventLoop loop;
+-    loop.connect(this, SIGNAL(accept()), SLOT(quit()));
+-    loop.connect(this, SIGNAL(reject()), SLOT(quit()));
+-    loop.exec();
++    d->loop.exec();
+ }
+ 
+ void QXdgDesktopPortalFileDialog::hide()
+@@ -429,13 +440,10 @@ bool QXdgDesktopPortalFileDialog::show(Qt::WindowFlags windowFlags, Qt::WindowMo
+ 
+     initializeDialog();
+ 
+-    d->modal = windowModality != Qt::NonModal;
+-    d->winId = parent ? parent->winId() : 0;
+-
+-    if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
++    if (d->nativeFileDialog && useNativeFileDialog(OpenFallback))
+         return d->nativeFileDialog->show(windowFlags, windowModality, parent);
+ 
+-    openPortal();
++    openPortal(windowFlags, windowModality, parent);
+ 
+     return true;
+ }
+@@ -465,4 +473,21 @@ void QXdgDesktopPortalFileDialog::gotResponse(uint response, const QVariantMap &
+     }
+ }
+ 
++bool QXdgDesktopPortalFileDialog::useNativeFileDialog(QXdgDesktopPortalFileDialog::FallbackType fallbackType) const
++{
++    Q_D(const QXdgDesktopPortalFileDialog);
++
++    if (d->failedToOpen && fallbackType != OpenFallback)
++        return true;
++
++    if (d->fileChooserPortalVersion < 3) {
++        if (options()->fileMode() == QFileDialogOptions::Directory)
++            return true;
++        else if (options()->fileMode() == QFileDialogOptions::DirectoryOnly)
++            return true;
++    }
++
++    return false;
++}
++
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
+index 4f4de96ecf..65e22a5cf2 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog_p.h
+@@ -51,6 +51,11 @@ class QXdgDesktopPortalFileDialog : public QPlatformFileDialogHelper
+     Q_OBJECT
+     Q_DECLARE_PRIVATE(QXdgDesktopPortalFileDialog)
+ public:
++    enum FallbackType {
++        GenericFallback,
++        OpenFallback
++    };
++
+     enum ConditionType : uint {
+         GlobalPattern = 0,
+         MimeType = 1
+@@ -69,7 +74,7 @@ public:
+     };
+     typedef QVector<Filter> FilterList;
+ 
+-    QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog = nullptr);
++    QXdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog = nullptr, uint fileChooserPortalVersion = 0);
+     ~QXdgDesktopPortalFileDialog();
+ 
+     bool defaultNameFilterDisables() const override;
+@@ -92,7 +97,8 @@ private Q_SLOTS:
+ 
+ private:
+     void initializeDialog();
+-    void openPortal();
++    void openPortal(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent);
++    bool useNativeFileDialog(FallbackType fallbackType = GenericFallback) const;
+ 
+     QScopedPointer<QXdgDesktopPortalFileDialogPrivate> d_ptr;
+ };
+diff --git a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
+index fb324afbd8..b809503122 100644
+--- a/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
++++ b/qtbase/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.cpp
+@@ -111,6 +111,7 @@ QXdgDesktopPortalTheme::QXdgDesktopPortalTheme()
+         if (reply.isValid()) {
+             d->fileChooserPortalVersion = reply.value().toUInt();
+         }
++        watcher->deleteLater();
+     });
+ }
+ 
+@@ -152,11 +153,12 @@ QPlatformDialogHelper* QXdgDesktopPortalTheme::createPlatformDialogHelper(Dialog
+ {
+     Q_D(const QXdgDesktopPortalTheme);
+ 
+-    if (type == FileDialog) {
++    if (type == FileDialog && d->fileChooserPortalVersion) {
+         // Older versions of FileChooser portal don't support opening directories, therefore we fallback
+         // to native file dialog opened inside the sandbox to open a directory.
+-        if (d->fileChooserPortalVersion < 3 && d->baseTheme->usePlatformNativeDialog(type))
+-            return new QXdgDesktopPortalFileDialog(static_cast<QPlatformFileDialogHelper*>(d->baseTheme->createPlatformDialogHelper(type)));
++        if (d->baseTheme->usePlatformNativeDialog(type))
++            return new QXdgDesktopPortalFileDialog(static_cast<QPlatformFileDialogHelper*>(d->baseTheme->createPlatformDialogHelper(type)),
++                                                   d->fileChooserPortalVersion);
+ 
+         return new QXdgDesktopPortalFileDialog;
+     }
+diff --git a/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp b/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
+index 43d5e119ad..1f9cbc4565 100644
+--- a/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
++++ b/qtbase/src/plugins/printsupport/cups/qcupsprintengine.cpp
+@@ -89,8 +89,10 @@ void QCupsPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &v
+         break;
+     case PPK_Duplex: {
+         QPrint::DuplexMode mode = QPrint::DuplexMode(value.toInt());
+-        if (mode != d->duplex && d->m_printDevice.supportedDuplexModes().contains(mode))
++        if (d->m_printDevice.supportedDuplexModes().contains(mode)) {
+             d->duplex = mode;
++            d->duplexRequestedExplicitly = true;
++        }
+         break;
+     }
+     case PPK_PrinterName:
+@@ -277,9 +279,12 @@ void QCupsPrintEnginePrivate::changePrinter(const QString &newPrinter)
+     m_printDevice.swap(printDevice);
+     printerName = m_printDevice.id();
+ 
+-    // Check if new printer supports current settings, otherwise us defaults
+-    if (duplex != QPrint::DuplexAuto && !m_printDevice.supportedDuplexModes().contains(duplex))
++    // in case a duplex value was explicitly set, check if new printer supports current value,
++    // otherwise use device default
++    if (!duplexRequestedExplicitly || !m_printDevice.supportedDuplexModes().contains(duplex)) {
+         duplex = m_printDevice.defaultDuplexMode();
++        duplexRequestedExplicitly = false;
++    }
+     QPrint::ColorMode colorMode = grayscale ? QPrint::GrayScale : QPrint::Color;
+     if (!m_printDevice.supportedColorModes().contains(colorMode))
+         grayscale = m_printDevice.defaultColorMode() == QPrint::GrayScale;
+diff --git a/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h b/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
+index c021b0c643..8f81fe478d 100644
+--- a/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
++++ b/qtbase/src/plugins/printsupport/cups/qcupsprintengine_p.h
+@@ -100,6 +100,7 @@ private:
+     QStringList cupsOptions;
+     QString cupsTempFile;
+     QPrint::DuplexMode duplex;
++    bool duplexRequestedExplicitly = false;
+ };
+ 
+ QT_END_NAMESPACE
+diff --git a/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp b/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
+index 67e7154fa6..40876152e5 100644
+--- a/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
++++ b/qtbase/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
+@@ -817,7 +817,7 @@ bool QIBaseResultPrivate::writeArray(int column, const QList<QVariant> &list)
+     ba.resize(int(bufLen));
+ 
+     if (list.size() > arraySize) {
+-        error = QLatin1String("Array size missmatch: size of %1 is %2, size of provided list is %3");
++        error = QLatin1String("Array size mismatch: size of %1 is %2, size of provided list is %3");
+         error = error.arg(QLatin1String(sqlname)).arg(arraySize).arg(list.size());
+         q->setLastError(QSqlError(error, QLatin1String(""), QSqlError::StatementError));
+         return false;
+diff --git a/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp b/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
+index 7ca055eea2..6bc9d46755 100644
+--- a/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
++++ b/qtbase/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
+@@ -223,7 +223,7 @@ public:
+     struct QMyField
+     {
+         char *outField = nullptr;
+-        MYSQL_FIELD *myField = nullptr;
++        const MYSQL_FIELD *myField = nullptr;
+         QMetaType::Type type = QMetaType::UnknownType;
+         my_bool nullIndicator = false;
+         ulong bufLength = 0ul;
+@@ -361,7 +361,7 @@ static bool qIsInteger(int t)
+ void QMYSQLResultPrivate::bindBlobs()
+ {
+     int i;
+-    MYSQL_FIELD *fieldInfo;
++    const MYSQL_FIELD *fieldInfo;
+     MYSQL_BIND *bind;
+ 
+     for(i = 0; i < fields.count(); ++i) {
+@@ -379,7 +379,6 @@ void QMYSQLResultPrivate::bindBlobs()
+ bool QMYSQLResultPrivate::bindInValues()
+ {
+     MYSQL_BIND *bind;
+-    char *field;
+     int i = 0;
+ 
+     if (!meta)
+@@ -392,35 +391,34 @@ bool QMYSQLResultPrivate::bindInValues()
+     inBinds = new MYSQL_BIND[fields.size()];
+     memset(inBinds, 0, fields.size() * sizeof(MYSQL_BIND));
+ 
+-    MYSQL_FIELD *fieldInfo;
++    const MYSQL_FIELD *fieldInfo;
+ 
+     while((fieldInfo = mysql_fetch_field(meta))) {
++        bind = &inBinds[i];
++
+         QMyField &f = fields[i];
+         f.myField = fieldInfo;
+-
++        bind->buffer_length = f.bufLength = fieldInfo->length + 1;
++        bind->buffer_type = fieldInfo->type;
+         f.type = qDecodeMYSQLType(fieldInfo->type, fieldInfo->flags);
+         if (qIsBlob(fieldInfo->type)) {
+             // the size of a blob-field is available as soon as we call
+             // mysql_stmt_store_result()
+             // after mysql_stmt_exec() in QMYSQLResult::exec()
+-            fieldInfo->length = 0;
++            bind->buffer_length = f.bufLength = 0;
+             hasBlobs = true;
+         } else if (qIsInteger(f.type)) {
+-            fieldInfo->length = 8;
++            bind->buffer_length = f.bufLength = 8;
+         } else {
+-            fieldInfo->type = MYSQL_TYPE_STRING;
++            bind->buffer_type = MYSQL_TYPE_STRING;
+         }
+-        bind = &inBinds[i];
+-        field = new char[fieldInfo->length + 1];
+-        memset(field, 0, fieldInfo->length + 1);
+ 
+-        bind->buffer_type = fieldInfo->type;
+-        bind->buffer = field;
+-        bind->buffer_length = f.bufLength = fieldInfo->length + 1;
+         bind->is_null = &f.nullIndicator;
+         bind->length = &f.bufLength;
+         bind->is_unsigned = fieldInfo->flags & UNSIGNED_FLAG ? 1 : 0;
+-        f.outField=field;
++
++        char *field = new char[bind->buffer_length + 1]{};
++        bind->buffer = f.outField = field;
+ 
+         ++i;
+     }
+@@ -1369,20 +1367,20 @@ bool QMYSQLDriver::open(const QString& db,
+     }
+ 
+ #if MYSQL_VERSION_ID >= 50007
+-    if (mysql_get_client_version() >= 50503 && mysql_get_server_version(d->mysql) >= 50503) {
+-        // force the communication to be utf8mb4 (only utf8mb4 supports 4-byte characters)
+-        mysql_set_character_set(d->mysql, "utf8mb4");
++    // force the communication to be utf8mb4 (only utf8mb4 supports 4-byte characters)
++    if (mysql_set_character_set(d->mysql, "utf8mb4")) {
++        // this failed, try forcing it to utf (BMP only)
++        if (mysql_set_character_set(d->mysql, "utf8"))
++            qWarning() << "MySQL: Unable to set the client character set to utf8.";
+ #if QT_CONFIG(textcodec)
+-        d->tc = QTextCodec::codecForName("UTF-8");
++        else
++            d->tc = codec(d->mysql);
+ #endif
+-    } else
+-    {
+-        // force the communication to be utf8
+-        mysql_set_character_set(d->mysql, "utf8");
++    }
+ #if QT_CONFIG(textcodec)
+-        d->tc = codec(d->mysql);
++    else
++        d->tc = QTextCodec::codecForName("UTF-8");
+ #endif
+-    }
+ #endif  // MYSQL_VERSION_ID >= 50007
+ 
+     d->preparedQuerysEnabled = checkPreparedQueries(d->mysql);
+diff --git a/qtbase/src/printsupport/dialogs/images/print-24.png b/qtbase/src/printsupport/dialogs/images/printer-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/print-24.png
+rename to src/printsupport/dialogs/images/printer-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/print-32.png b/qtbase/src/printsupport/dialogs/images/printer-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/print-32.png
+rename to src/printsupport/dialogs/images/printer-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-sided-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-facing-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-sided-24.png
+rename to src/printsupport/dialogs/images/view-pages-facing-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-sided-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-facing-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-sided-32.png
+rename to src/printsupport/dialogs/images/view-pages-facing-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-multi-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-overview-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-multi-24.png
+rename to src/printsupport/dialogs/images/view-pages-overview-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-multi-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-overview-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-multi-32.png
+rename to src/printsupport/dialogs/images/view-pages-overview-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-one-24.png b/qtbase/src/printsupport/dialogs/images/view-pages-single-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-one-24.png
+rename to src/printsupport/dialogs/images/view-pages-single-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/view-page-one-32.png b/qtbase/src/printsupport/dialogs/images/view-pages-single-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/view-page-one-32.png
+rename to src/printsupport/dialogs/images/view-pages-single-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-page-24.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-page-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-page-24.png
+rename to src/printsupport/dialogs/images/zoom-fit-page-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-page-32.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-page-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-page-32.png
+rename to src/printsupport/dialogs/images/zoom-fit-page-32.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-width-24.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-width-24.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-width-24.png
+rename to src/printsupport/dialogs/images/zoom-fit-width-24.png
+diff --git a/qtbase/src/printsupport/dialogs/images/fit-width-32.png b/qtbase/src/printsupport/dialogs/images/zoom-fit-width-32.png
+similarity index 100%
+rename from src/printsupport/dialogs/images/fit-width-32.png
+rename to src/printsupport/dialogs/images/zoom-fit-width-32.png
+diff --git a/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp b/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
+index 78e5b8d1ef..2a28516719 100644
+--- a/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
++++ b/qtbase/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
+@@ -532,6 +532,7 @@ void QPageSetupWidget::updateWidget()
+ void QPageSetupWidget::setupPrinter() const
+ {
+     m_printer->setPageLayout(m_pageLayout);
++    m_printer->setPageOrientation(m_pageLayout.orientation());
+ #if QT_CONFIG(cups)
+     QCUPSSupport::PagesPerSheet pagesPerSheet = qvariant_cast<QCUPSSupport::PagesPerSheet>(m_ui.pagesPerSheetCombo->currentData()
+ );
+diff --git a/qtbase/src/printsupport/dialogs/qprintdialog.qrc b/qtbase/src/printsupport/dialogs/qprintdialog.qrc
+index 5a579baa55..10b8e1d341 100644
+--- a/qtbase/src/printsupport/dialogs/qprintdialog.qrc
++++ b/qtbase/src/printsupport/dialogs/qprintdialog.qrc
+@@ -1,9 +1,9 @@
+ <!DOCTYPE RCC><RCC version="1.0">
+ <qresource prefix="/qt-project.org/dialogs/qprintpreviewdialog">
+-<file>images/fit-page-24.png</file>
+-<file>images/fit-page-32.png</file>
+-<file>images/fit-width-24.png</file>
+-<file>images/fit-width-32.png</file>
++<file>images/zoom-fit-page-24.png</file>
++<file>images/zoom-fit-page-32.png</file>
++<file>images/zoom-fit-width-24.png</file>
++<file>images/zoom-fit-width-32.png</file>
+ <file>images/go-first-24.png</file>
+ <file>images/go-first-32.png</file>
+ <file>images/go-last-24.png</file>
+@@ -18,14 +18,14 @@
+ <file>images/layout-portrait-32.png</file>
+ <file>images/page-setup-24.png</file>
+ <file>images/page-setup-32.png</file>
+-<file>images/print-24.png</file>
+-<file>images/print-32.png</file>
+-<file>images/view-page-multi-24.png</file>
+-<file>images/view-page-multi-32.png</file>
+-<file>images/view-page-one-24.png</file>
+-<file>images/view-page-one-32.png</file>
+-<file>images/view-page-sided-24.png</file>
+-<file>images/view-page-sided-32.png</file>
++<file>images/printer-24.png</file>
++<file>images/printer-32.png</file>
++<file>images/view-pages-overview-24.png</file>
++<file>images/view-pages-overview-32.png</file>
++<file>images/view-pages-single-24.png</file>
++<file>images/view-pages-single-32.png</file>
++<file>images/view-pages-facing-24.png</file>
++<file>images/view-pages-facing-32.png</file>
+ <file>images/zoom-in-24.png</file>
+ <file>images/zoom-in-32.png</file>
+ <file>images/zoom-out-24.png</file>
+diff --git a/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp b/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
+index c5b845f4ec..5a5ba1d0a8 100644
+--- a/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
++++ b/qtbase/src/printsupport/dialogs/qprintdialog_unix.cpp
+@@ -702,13 +702,14 @@ void QPrintDialogPrivate::selectPrinter(const QPrinter::OutputFormat outputForma
+         else
+             options.grayscale->setChecked(true);
+ 
+-        // keep duplex value explicitly set by user, if any, and selected printer supports it;
+-        // use device default otherwise
++        // duplex priorities to be as follows:
++        // 1) a user-selected duplex value in the dialog has highest prority
++        // 2) duplex value set in the QPrinter
+         QPrint::DuplexMode duplex;
+         if (explicitDuplexMode != QPrint::DuplexAuto && supportedDuplexMode.contains(explicitDuplexMode))
+             duplex = explicitDuplexMode;
+         else
+-            duplex = top->d->m_currentPrintDevice.defaultDuplexMode();
++            duplex = static_cast<QPrint::DuplexMode>(p->duplex());
+         switch (duplex) {
+         case QPrint::DuplexNone:
+             options.noDuplex->setChecked(true); break;
+@@ -1242,10 +1243,10 @@ void QUnixPrintWidgetPrivate::_q_printerChanged(int index)
+             QString filename = widget.filename->text();
+             widget.filename->setText(filename);
+             widget.lOutput->setEnabled(true);
+-            if (optionsPane)
+-                optionsPane->selectPrinter(QPrinter::PdfFormat);
+             printer->setOutputFormat(QPrinter::PdfFormat);
+             m_currentPrintDevice = QPrintDevice();
++            if (optionsPane)
++                optionsPane->selectPrinter(QPrinter::PdfFormat);
+             return;
+         }
+     }
+diff --git a/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp b/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
+index 39575d5f57..23b7e89538 100644
+--- a/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
++++ b/qtbase/src/printsupport/dialogs/qprintpreviewdialog.cpp
+@@ -352,7 +352,7 @@ void QPrintPreviewDialogPrivate::init(QPrinter *_printer)
+ static inline void qt_setupActionIcon(QAction *action, QLatin1String name)
+ {
+     QLatin1String imagePrefix(":/qt-project.org/dialogs/qprintpreviewdialog/images/");
+-    QIcon icon;
++    QIcon icon = QIcon::fromTheme(name);
+     icon.addFile(imagePrefix + name + QLatin1String("-24.png"), QSize(24, 24));
+     icon.addFile(imagePrefix + name + QLatin1String("-32.png"), QSize(32, 32));
+     action->setIcon(icon);
+@@ -383,8 +383,8 @@ void QPrintPreviewDialogPrivate::setupActions()
+     fitPageAction->setObjectName(QLatin1String("fitPageAction"));
+     fitWidthAction->setCheckable(true);
+     fitPageAction->setCheckable(true);
+-    qt_setupActionIcon(fitWidthAction, QLatin1String("fit-width"));
+-    qt_setupActionIcon(fitPageAction, QLatin1String("fit-page"));
++    qt_setupActionIcon(fitWidthAction, QLatin1String("zoom-fit-width"));
++    qt_setupActionIcon(fitPageAction, QLatin1String("zoom-fit-page"));
+     QObject::connect(fitGroup, SIGNAL(triggered(QAction*)), q, SLOT(_q_fit(QAction*)));
+ 
+     // Zoom
+@@ -410,9 +410,9 @@ void QPrintPreviewDialogPrivate::setupActions()
+     singleModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show single page"));
+     facingModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show facing pages"));
+     overviewModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show overview of all pages"));
+-    qt_setupActionIcon(singleModeAction, QLatin1String("view-page-one"));
+-    qt_setupActionIcon(facingModeAction, QLatin1String("view-page-sided"));
+-    qt_setupActionIcon(overviewModeAction, QLatin1String("view-page-multi"));
++    qt_setupActionIcon(singleModeAction, QLatin1String("view-pages-single"));
++    qt_setupActionIcon(facingModeAction, QLatin1String("view-pages-facing"));
++    qt_setupActionIcon(overviewModeAction, QLatin1String("view-pages-overview"));
+     singleModeAction->setObjectName(QLatin1String("singleModeAction"));
+     facingModeAction->setObjectName(QLatin1String("facingModeAction"));
+     overviewModeAction->setObjectName(QLatin1String("overviewModeAction"));
+@@ -426,7 +426,7 @@ void QPrintPreviewDialogPrivate::setupActions()
+     printerGroup = new QActionGroup(q);
+     printAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Print"));
+     pageSetupAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Page setup"));
+-    qt_setupActionIcon(printAction, QLatin1String("print"));
++    qt_setupActionIcon(printAction, QLatin1String("printer"));
+     qt_setupActionIcon(pageSetupAction, QLatin1String("page-setup"));
+     QObject::connect(printAction, SIGNAL(triggered(bool)), q, SLOT(_q_print()));
+     QObject::connect(pageSetupAction, SIGNAL(triggered(bool)), q, SLOT(_q_pageSetup()));
+diff --git a/qtbase/src/sql/kernel/qsqlquery.cpp b/qtbase/src/sql/kernel/qsqlquery.cpp
+index 32c6166c79..60afef10c3 100644
+--- a/qtbase/src/sql/kernel/qsqlquery.cpp
++++ b/qtbase/src/sql/kernel/qsqlquery.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2022 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtSql module of the Qt Toolkit.
+@@ -377,6 +377,10 @@ bool QSqlQuery::exec(const QString& query)
+     QElapsedTimer t;
+     t.start();
+ #endif
++    if (!driver()) {
++        qWarning("QSqlQuery::exec: called before driver has been set up");
++        return false;
++    }
+     if (d->ref.loadRelaxed() != 1) {
+         bool fo = isForwardOnly();
+         *this = QSqlQuery(driver()->createResult());
+diff --git a/qtbase/src/testlib/qabstractitemmodeltester.cpp b/qtbase/src/testlib/qabstractitemmodeltester.cpp
+index 8efb9c53d4..ce062f66d7 100644
+--- a/qtbase/src/testlib/qabstractitemmodeltester.cpp
++++ b/qtbase/src/testlib/qabstractitemmodeltester.cpp
+@@ -454,7 +454,7 @@ void QAbstractItemModelTesterPrivate::parent()
+ 
+     // Common error test #2, make sure that a second level index has a parent
+     // that is the first level index.
+-    if (model->rowCount(topIndex) > 0) {
++    if (model->rowCount(topIndex) > 0 && model->columnCount(topIndex) > 0) {
+         QModelIndex childIndex = model->index(0, 0, topIndex);
+         MODELTESTER_VERIFY(childIndex.isValid());
+         MODELTESTER_COMPARE(model->parent(childIndex), topIndex);
+diff --git a/qtbase/src/testlib/qasciikey.cpp b/qtbase/src/testlib/qasciikey.cpp
+index 9a308da2bc..93498b256f 100644
+--- a/qtbase/src/testlib/qasciikey.cpp
++++ b/qtbase/src/testlib/qasciikey.cpp
+@@ -498,6 +498,11 @@ char QTest::keyToAscii(Qt::Key key)
+     case Qt::Key_LaunchE : return 0; // = 0x10b0,
+     case Qt::Key_LaunchF : return 0; // = 0x10b1,
+ 
++    // Keypad navigation keys
++    case Qt::Key_Select : return 0; // = 0x01010000
++    case Qt::Key_Yes : return 0; // = 0x01010001
++    case Qt::Key_No : return 0; // = 0x01010002
++
+     default: QTEST_ASSERT(false); return 0;
+     }
+ }
+diff --git a/qtbase/src/testlib/qtestresult.cpp b/qtbase/src/testlib/qtestresult.cpp
+index 88028aac6e..2e89930776 100644
+--- a/qtbase/src/testlib/qtestresult.cpp
++++ b/qtbase/src/testlib/qtestresult.cpp
+@@ -251,7 +251,8 @@ bool QTestResult::verify(bool statement, const char *statementStr,
+ {
+     QTEST_ASSERT(statementStr);
+ 
+-    char msg[1024] = {'\0'};
++    char msg[1024];
++    msg[0] = '\0';
+ 
+     if (QTestLog::verboseLevel() >= 2) {
+         qsnprintf(msg, 1024, "QVERIFY(%s)", statementStr);
+@@ -309,7 +310,8 @@ static bool compareHelper(bool success, const char *failureMsg,
+                           bool hasValues = true)
+ {
+     const size_t maxMsgLen = 1024;
+-    char msg[maxMsgLen] = {'\0'};
++    char msg[maxMsgLen];
++    msg[0] = '\0';
+ 
+     QTEST_ASSERT(expected);
+     QTEST_ASSERT(actual);
+diff --git a/qtbase/src/widgets/dialogs/qcolordialog.cpp b/qtbase/src/widgets/dialogs/qcolordialog.cpp
+index 4247731275..cb325be85c 100644
+--- a/qtbase/src/widgets/dialogs/qcolordialog.cpp
++++ b/qtbase/src/widgets/dialogs/qcolordialog.cpp
+@@ -78,7 +78,10 @@
+ #include "qwindow.h"
+ 
+ #include "private/qdialog_p.h"
++#include "private/qguiapplication_p.h"
+ 
++#include <qpa/qplatformservices.h>
++#include <qpa/qplatformintegration.h>
+ #include <algorithm>
+ 
+ QT_BEGIN_NAMESPACE
+@@ -1611,6 +1614,20 @@ void QColorDialogPrivate::_q_newStandard(int r, int c)
+ void QColorDialogPrivate::_q_pickScreenColor()
+ {
+     Q_Q(QColorDialog);
++
++    auto *platformServices = QGuiApplicationPrivate::platformIntegration()->services();
++    if (platformServices->hasCapability(QPlatformServices::Capability::ColorPicking)) {
++        if (auto *colorPicker = platformServices->colorPicker(q->windowHandle())) {
++            q->connect(colorPicker, &QPlatformServiceColorPicker::colorPicked, q,
++                       [q, colorPicker](const QColor &color) {
++                           colorPicker->deleteLater();
++                           q->setCurrentColor(color);
++                       });
++            colorPicker->pickColor();
++            return;
++        }
++    }
++
+     if (!colorPickingEventFilter)
+         colorPickingEventFilter = new QColorPickingEventFilter(this, q);
+     q->installEventFilter(colorPickingEventFilter);
+diff --git a/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp b/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
+index e120817edc..8ea36b5427 100644
+--- a/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
++++ b/qtbase/src/widgets/itemviews/qabstractitemdelegate.cpp
+@@ -400,12 +400,7 @@ bool QAbstractItemDelegate::helpEvent(QHelpEvent *event,
+         const QString tooltip = index.isValid() ?
+               d->textForRole(Qt::ToolTipRole, index.data(Qt::ToolTipRole), option.locale, precision) :
+               QString();
+-        QRect rect;
+-        if (index.isValid()) {
+-            const QRect r = view->visualRect(index);
+-            rect = QRect(view->mapToGlobal(r.topLeft()), r.size());
+-        }
+-        QToolTip::showText(he->globalPos(), tooltip, view, rect);
++        QToolTip::showText(he->globalPos(), tooltip, view->viewport(), option.rect);
+         event->setAccepted(!tooltip.isEmpty());
+         break;
+         }
+diff --git a/qtbase/src/widgets/itemviews/qlistview.cpp b/qtbase/src/widgets/itemviews/qlistview.cpp
+index 2b34476642..eebfaa030e 100644
+--- a/qtbase/src/widgets/itemviews/qlistview.cpp
++++ b/qtbase/src/widgets/itemviews/qlistview.cpp
+@@ -3386,6 +3386,7 @@ void QIconModeViewBase::updateContentsSize()
+ */
+ void QListView::currentChanged(const QModelIndex &current, const QModelIndex &previous)
+ {
++    QAbstractItemView::currentChanged(current, previous);
+ #ifndef QT_NO_ACCESSIBILITY
+     if (QAccessible::isActive()) {
+         if (current.isValid()) {
+@@ -3396,7 +3397,6 @@ void QListView::currentChanged(const QModelIndex &current, const QModelIndex &pr
+         }
+     }
+ #endif
+-    QAbstractItemView::currentChanged(current, previous);
+ }
+ 
+ /*!
+diff --git a/qtbase/src/widgets/itemviews/qtableview.cpp b/qtbase/src/widgets/itemviews/qtableview.cpp
+index 934ac581b2..f79bb24249 100644
+--- a/qtbase/src/widgets/itemviews/qtableview.cpp
++++ b/qtbase/src/widgets/itemviews/qtableview.cpp
+@@ -1013,6 +1013,7 @@ void QTableViewPrivate::drawCell(QPainter *painter, const QStyleOptionViewItem &
+ int QTableViewPrivate::widthHintForIndex(const QModelIndex &index, int hint, const QStyleOptionViewItem &option) const
+ {
+     Q_Q(const QTableView);
++    const int oldHint = hint;
+     QWidget *editor = editorForIndex(index).widget.data();
+     if (editor && persistent.contains(editor)) {
+         hint = qMax(hint, editor->sizeHint().width());
+@@ -1021,6 +1022,17 @@ int QTableViewPrivate::widthHintForIndex(const QModelIndex &index, int hint, con
+         hint = qBound(min, hint, max);
+     }
+     hint = qMax(hint, q->itemDelegate(index)->sizeHint(option, index).width());
++
++    if (hasSpans()) {
++        auto span = spans.spanAt(index.column(), index.row());
++        if (span && span->m_left == index.column() && span->m_top == index.row()) {
++            // spans are screwed up when sections are moved
++            const auto left = logicalColumn(span->m_left);
++            for (int i = 1; i <= span->width(); ++i)
++               hint -= q->columnWidth(visualColumn(left + i));
++        }
++        hint = std::max(hint, oldHint);
++    }
+     return hint;
+ }
+ 
+@@ -1053,6 +1065,11 @@ int QTableViewPrivate::heightHintForIndex(const QModelIndex &index, int hint, QS
+         option.rect.setHeight(height);
+         option.rect.setX(q->columnViewportPosition(index.column()));
+         option.rect.setWidth(q->columnWidth(index.column()));
++        if (hasSpans()) {
++            auto span = spans.spanAt(index.column(), index.row());
++            if (span && span->m_left == index.column() && span->m_top == index.row())
++                option.rect.setWidth(std::max(option.rect.width(), visualSpanRect(*span).width()));
++        }
+         // 1px less space when grid is shown (see drawCell)
+         if (showGrid)
+             option.rect.setWidth(option.rect.width() - 1);
+diff --git a/qtbase/src/widgets/kernel/qaction.h b/qtbase/src/widgets/kernel/qaction.h
+index 258a1ea0a0..737c1e8285 100644
+--- a/qtbase/src/widgets/kernel/qaction.h
++++ b/qtbase/src/widgets/kernel/qaction.h
+@@ -81,7 +81,7 @@ class Q_WIDGETS_EXPORT QAction : public QObject
+     Q_PROPERTY(MenuRole menuRole READ menuRole WRITE setMenuRole NOTIFY changed)
+     Q_PROPERTY(bool iconVisibleInMenu READ isIconVisibleInMenu WRITE setIconVisibleInMenu NOTIFY changed)
+     Q_PROPERTY(bool shortcutVisibleInContextMenu READ isShortcutVisibleInContextMenu WRITE setShortcutVisibleInContextMenu NOTIFY changed)
+-    Q_PROPERTY(Priority priority READ priority WRITE setPriority)
++    Q_PROPERTY(Priority priority READ priority WRITE setPriority NOTIFY changed)
+ 
+ public:
+     // note this is copied into qplatformmenu.h, which must stay in sync
+diff --git a/qtbase/src/widgets/kernel/qwidget.cpp b/qtbase/src/widgets/kernel/qwidget.cpp
+index 9eba1e001e..26f6d27e18 100644
+--- a/qtbase/src/widgets/kernel/qwidget.cpp
++++ b/qtbase/src/widgets/kernel/qwidget.cpp
+@@ -5296,7 +5296,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
+         QWidgetEffectSourcePrivate *sourced = static_cast<QWidgetEffectSourcePrivate *>
+                                                          (source->d_func());
+         if (!sourced->context) {
+-            const QRegion effectRgn(rgn.boundingRect());
++            const QRegion effectRgn((flags & UseEffectRegionBounds) ? rgn.boundingRect() : rgn);
+             QWidgetPaintContext context(pdev, effectRgn, offset, flags, sharedPainter, repaintManager);
+             sourced->context = &context;
+             if (!sharedPainter) {
+@@ -5328,6 +5328,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
+         }
+     }
+ #endif // QT_CONFIG(graphicseffect)
++    flags = flags & ~UseEffectRegionBounds;
+ 
+     const bool alsoOnScreen = flags & DrawPaintOnScreen;
+     const bool recursive = flags & DrawRecursive;
+diff --git a/qtbase/src/widgets/kernel/qwidget_p.h b/qtbase/src/widgets/kernel/qwidget_p.h
+index eef6b8fa2c..c432f4b5d5 100644
+--- a/qtbase/src/widgets/kernel/qwidget_p.h
++++ b/qtbase/src/widgets/kernel/qwidget_p.h
+@@ -229,7 +229,8 @@ public:
+         DontSubtractOpaqueChildren = 0x10,
+         DontDrawOpaqueChildren = 0x20,
+         DontDrawNativeChildren = 0x40,
+-        DontSetCompositionMode = 0x80
++        DontSetCompositionMode = 0x80,
++        UseEffectRegionBounds = 0x100
+     };
+     Q_DECLARE_FLAGS(DrawWidgetFlags, DrawWidgetFlag)
+     Q_FLAG(DrawWidgetFlags)
+diff --git a/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp b/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
+index 02880b34da..0d44e1326d 100644
+--- a/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
++++ b/qtbase/src/widgets/kernel/qwidgetrepaintmanager.cpp
+@@ -1018,7 +1018,8 @@ void QWidgetRepaintManager::paintAndFlush()
+ 
+     // Paint the rest with composition.
+     if (repaintAllWidgets || !dirtyCopy.isEmpty()) {
+-        QWidgetPrivate::DrawWidgetFlags flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive;
++        QWidgetPrivate::DrawWidgetFlags flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive
++                | QWidgetPrivate::UseEffectRegionBounds;
+         tlw->d_func()->drawWidget(store->paintDevice(), dirtyCopy, QPoint(), flags, nullptr, this);
+     }
+ 
+diff --git a/qtbase/src/widgets/styles/qfusionstyle.cpp b/qtbase/src/widgets/styles/qfusionstyle.cpp
+index f4345d97c4..962912c838 100644
+--- a/qtbase/src/widgets/styles/qfusionstyle.cpp
++++ b/qtbase/src/widgets/styles/qfusionstyle.cpp
+@@ -1772,14 +1772,6 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio
+             proxy()->drawControl(CE_PushButtonLabel, &subopt, painter, widget);
+         }
+         break;
+-    case CE_PushButtonLabel:
+-        if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
+-            QStyleOptionButton b(*button);
+-            // no PM_ButtonShiftHorizontal and PM_ButtonShiftVertical for fusion style
+-            b.state &= ~(State_On | State_Sunken);
+-            QCommonStyle::drawControl(element, &b, painter, widget);
+-        }
+-        break;
+     case CE_MenuBarEmptyArea:
+         painter->save();
+     {
+diff --git a/qtbase/src/widgets/util/qcompleter.cpp b/qtbase/src/widgets/util/qcompleter.cpp
+index 18b24063d8..ef7207a8a3 100644
+--- a/qtbase/src/widgets/util/qcompleter.cpp
++++ b/qtbase/src/widgets/util/qcompleter.cpp
+@@ -1120,6 +1120,8 @@ void QCompleter::setModel(QAbstractItemModel *model)
+ {
+     Q_D(QCompleter);
+     QAbstractItemModel *oldModel = d->proxy->sourceModel();
++    if (oldModel == model)
++        return;
+ #if QT_CONFIG(filesystemmodel)
+     if (qobject_cast<const QFileSystemModel *>(oldModel))
+         setCompletionRole(Qt::EditRole); // QTBUG-54642, clear FileNameRole set by QFileSystemModel
+diff --git a/qtbase/src/widgets/widgets/qabstractbutton.cpp b/qtbase/src/widgets/widgets/qabstractbutton.cpp
+index a128b23950..dc40bf62fb 100644
+--- a/qtbase/src/widgets/widgets/qabstractbutton.cpp
++++ b/qtbase/src/widgets/widgets/qabstractbutton.cpp
+@@ -56,6 +56,7 @@
+ #ifndef QT_NO_ACCESSIBILITY
+ #include "qaccessible.h"
+ #endif
++#include <qpa/qplatformtheme.h>
+ 
+ #include <algorithm>
+ 
+@@ -1076,19 +1077,19 @@ void QAbstractButton::keyPressEvent(QKeyEvent *e)
+ {
+     Q_D(QAbstractButton);
+     bool next = true;
+-    switch (e->key()) {
+-    case Qt::Key_Enter:
+-    case Qt::Key_Return:
+-        e->ignore();
+-        break;
+-    case Qt::Key_Select:
+-    case Qt::Key_Space:
+-        if (!e->isAutoRepeat()) {
+-            setDown(true);
+-            repaint();
+-            d->emitPressed();
+-        }
+-        break;
++
++    const auto key = static_cast<Qt::Key>(e->key());
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(key) && !e->isAutoRepeat()) {
++        setDown(true);
++        repaint();
++        d->emitPressed();
++        return;
++    }
++
++    switch (key) {
+     case Qt::Key_Up:
+         next = false;
+         Q_FALLTHROUGH();
+@@ -1153,15 +1154,15 @@ void QAbstractButton::keyReleaseEvent(QKeyEvent *e)
+     if (!e->isAutoRepeat())
+         d->repeatTimer.stop();
+ 
+-    switch (e->key()) {
+-    case Qt::Key_Select:
+-    case Qt::Key_Space:
+-        if (!e->isAutoRepeat() && d->down)
+-            d->click();
+-        break;
+-    default:
+-        e->ignore();
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(static_cast<Qt::Key>(e->key())) && !e->isAutoRepeat() && d->down) {
++        d->click();
++        return;
+     }
++
++    e->ignore();
+ }
+ 
+ /*!\reimp
+diff --git a/qtbase/src/widgets/widgets/qcombobox.cpp b/qtbase/src/widgets/widgets/qcombobox.cpp
+index 7a496c27e0..0a3d96647b 100644
+--- a/qtbase/src/widgets/widgets/qcombobox.cpp
++++ b/qtbase/src/widgets/widgets/qcombobox.cpp
+@@ -3352,7 +3352,23 @@ void QComboBox::keyPressEvent(QKeyEvent *e)
+ 
+     Move move = NoMove;
+     int newIndex = currentIndex();
+-    switch (e->key()) {
++
++    bool pressLikeButton = !d->lineEdit;
++#ifdef QT_KEYPAD_NAVIGATION
++    pressLikeButton |= QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus();
++#endif
++    auto key = static_cast<Qt::Key>(e->key());
++    if (pressLikeButton) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(key)) {
++            showPopup();
++            return;
++        }
++    }
++
++    switch (key) {
+     case Qt::Key_Up:
+         if (e->modifiers() & Qt::ControlModifier)
+             break; // pass to line edit for auto completion
+@@ -3394,26 +3410,11 @@ void QComboBox::keyPressEvent(QKeyEvent *e)
+             return;
+         }
+         break;
+-    case Qt::Key_Space:
+-        if (!d->lineEdit) {
+-            showPopup();
+-            return;
+-        }
+-        break;
+-    case Qt::Key_Enter:
+-    case Qt::Key_Return:
+     case Qt::Key_Escape:
+         if (!d->lineEdit)
+             e->ignore();
+         break;
+ #ifdef QT_KEYPAD_NAVIGATION
+-    case Qt::Key_Select:
+-        if (QApplicationPrivate::keypadNavigationEnabled()
+-                && (!hasEditFocus() || !d->lineEdit)) {
+-            showPopup();
+-            return;
+-        }
+-        break;
+     case Qt::Key_Left:
+     case Qt::Key_Right:
+         if (QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus())
+diff --git a/qtbase/src/widgets/widgets/qdatetimeedit_p.h b/qtbase/src/widgets/widgets/qdatetimeedit_p.h
+index d36b6f8f9a..e0df5b5158 100644
+--- a/qtbase/src/widgets/widgets/qdatetimeedit_p.h
++++ b/qtbase/src/widgets/widgets/qdatetimeedit_p.h
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2018 The Qt Company Ltd.
++** Copyright (C) 2021 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the QtWidgets module of the Qt Toolkit.
+diff --git a/qtbase/src/widgets/widgets/qgroupbox.cpp b/qtbase/src/widgets/widgets/qgroupbox.cpp
+index 02a0bed325..3f3eccc370 100644
+--- a/qtbase/src/widgets/widgets/qgroupbox.cpp
++++ b/qtbase/src/widgets/widgets/qgroupbox.cpp
+@@ -54,6 +54,8 @@
+ #include "qaccessible.h"
+ #endif
+ #include <private/qwidget_p.h>
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
+ 
+ #include "qdebug.h"
+ 
+@@ -360,7 +362,10 @@ bool QGroupBox::event(QEvent *e)
+         return true;
+     case QEvent::KeyPress: {
+         QKeyEvent *k = static_cast<QKeyEvent*>(e);
+-        if (!k->isAutoRepeat() && (k->key() == Qt::Key_Select || k->key() == Qt::Key_Space)) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (!k->isAutoRepeat() && buttonPressKeys.contains(static_cast<Qt::Key>(k->key()))) {
+             d->pressedControl = QStyle::SC_GroupBoxCheckBox;
+             update(style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxCheckBox, this));
+             return true;
+@@ -369,7 +374,10 @@ bool QGroupBox::event(QEvent *e)
+     }
+     case QEvent::KeyRelease: {
+         QKeyEvent *k = static_cast<QKeyEvent*>(e);
+-        if (!k->isAutoRepeat() && (k->key() == Qt::Key_Select || k->key() == Qt::Key_Space)) {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (!k->isAutoRepeat() && buttonPressKeys.contains(static_cast<Qt::Key>(k->key()))) {
+             bool toggle = (d->pressedControl == QStyle::SC_GroupBoxLabel
+                            || d->pressedControl == QStyle::SC_GroupBoxCheckBox);
+             d->pressedControl = QStyle::SC_None;
+diff --git a/qtbase/src/widgets/widgets/qlabel.cpp b/qtbase/src/widgets/widgets/qlabel.cpp
+index 30ff80cbb0..cf2605c17c 100644
+--- a/qtbase/src/widgets/widgets/qlabel.cpp
++++ b/qtbase/src/widgets/widgets/qlabel.cpp
+@@ -421,9 +421,6 @@ void QLabel::setPixmap(const QPixmap &pixmap)
+         d->pixmap = new QPixmap(pixmap);
+     }
+ 
+-    if (d->pixmap->depth() == 1 && !d->pixmap->mask())
+-        d->pixmap->setMask(*((QBitmap *)d->pixmap));
+-
+     d->updateLabel();
+ }
+ 
+diff --git a/qtbase/src/widgets/widgets/qtoolbararealayout.cpp b/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
+index 493c094cc1..d5f4b59017 100644
+--- a/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
++++ b/qtbase/src/widgets/widgets/qtoolbararealayout.cpp
+@@ -1367,7 +1367,7 @@ bool QToolBarAreaLayout::restoreState(QDataStream &stream, const QList<QToolBar*
+                 item.widgetItem = new QWidgetItemV2(toolBar);
+                 toolBar->setOrientation(floating ? ((shown & 2) ? Qt::Vertical : Qt::Horizontal) : dock.o);
+                 toolBar->setVisible(shown & 1);
+-                toolBar->d_func()->setWindowState(floating, true, rect);
++                toolBar->d_func()->setWindowState(floating, false, rect);
+ 
+                 item.preferredSize = item.size;
+                 line.toolBarItems.append(item);
+diff --git a/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp b/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
+index 212c0a2e13..3c77b1ba0b 100644
+--- a/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
++++ b/qtbase/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp
+@@ -126,8 +126,7 @@ public:
+ 
+ void tst_QtConcurrentIterateKernel::instantiate()
+ {
+-    auto future = startThreadEngine(new PrintFor(0, 40)).startAsynchronously();
+-    future.waitForFinished();
++    startThreadEngine(new PrintFor(0, 40)).startBlocking();
+     QCOMPARE(iterations.loadRelaxed(), 40);
+ }
+ 
+@@ -166,10 +165,8 @@ void tst_QtConcurrentIterateKernel::stresstest()
+     const int times = 50;
+     for (int i = 0; i < times; ++i) {
+         counter.storeRelaxed(0);
+-        // ThreadEngine will delete f when it finishes
+-        auto f = new CountFor(0, iterations);
+-        auto future = f->startAsynchronously();
+-        future.waitForFinished();
++        CountFor f(0, iterations);
++        f.startBlocking();
+         QCOMPARE(counter.loadRelaxed(), iterations);
+     }
+ }
+@@ -177,11 +174,8 @@ void tst_QtConcurrentIterateKernel::stresstest()
+ void tst_QtConcurrentIterateKernel::noIterations()
+ {
+     const int times = 20000;
+-    for (int i = 0; i < times; ++i) {
+-        auto future = startThreadEngine(new IterateKernel<TestIterator, void>(0, 0))
+-                              .startAsynchronously();
+-        future.waitForFinished();
+-    }
++    for (int i = 0; i < times; ++i)
++        startThreadEngine(new IterateKernel<TestIterator, void>(0, 0)).startBlocking();
+ }
+ 
+ QMutex threadsMutex;
+@@ -236,10 +230,8 @@ void tst_QtConcurrentIterateKernel::throttling()
+ 
+     threads.clear();
+ 
+-    // ThreadEngine will delete f when it finishes
+-    auto f = new ThrottleFor(0, totalIterations);
+-    auto future = f->startAsynchronously();
+-    future.waitForFinished();
++    ThrottleFor f(0, totalIterations);
++    f.startBlocking();
+ 
+     QCOMPARE(iterations.loadRelaxed(), totalIterations);
+ 
+diff --git a/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp b/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
+index ac7be7acdd..81bc64c8d9 100644
+--- a/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
++++ b/qtbase/tests/auto/concurrent/qtconcurrentthreadengine/tst_qtconcurrentthreadengine.cpp
+@@ -65,9 +65,16 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::runDirectly()
+ {
+-    PrintUser *engine = new PrintUser();
+-    QFuture<void> f = engine->startAsynchronously();
+-    f.waitForFinished();
++    {
++        PrintUser engine;
++        engine.startSingleThreaded();
++        engine.startBlocking();
++    }
++    {
++        PrintUser *engine = new PrintUser();
++        QFuture<void> f = engine->startAsynchronously();
++        f.waitForFinished();
++    }
+ }
+ 
+ class StringResultUser : public ThreadEngine<QString>
+@@ -99,10 +106,8 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::result()
+ {
+-    // ThreadEngine will delete 'engine' when it finishes
+-    auto engine = new StringResultUser();
+-    auto future = engine->startAsynchronously();
+-    QCOMPARE(future.result(), QString("Foo"));
++    StringResultUser engine;
++    QCOMPARE(*engine.startBlocking(), QString("Foo"));
+ }
+ 
+ class VoidResultUser : public ThreadEngine<void>
+@@ -128,9 +133,17 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::runThroughStarter()
+ {
+-    ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
+-    QFuture<QString> f = starter.startAsynchronously();
+-    QCOMPARE(f.result(), QString("Foo"));
++    {
++        ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
++        QFuture<QString>  f = starter.startAsynchronously();
++        QCOMPARE(f.result(), QString("Foo"));
++    }
++
++    {
++        ThreadEngineStarter<QString> starter = startThreadEngine(new StringResultUser());
++        QString str = starter.startBlocking();
++        QCOMPARE(str, QString("Foo"));
++    }
+ }
+ 
+ class CancelUser : public ThreadEngine<void>
+@@ -213,6 +226,12 @@ void tst_QtConcurrentThreadEngine::throttle()
+         f.waitForFinished();
+         QCOMPARE(count.loadRelaxed(), 0);
+     }
++
++    for (int i = 0; i < repeats; ++i) {
++        ThrottleAlwaysUser t;
++        t.startBlocking();
++        QCOMPARE(count.loadRelaxed(), 0);
++    }
+ }
+ 
+ QSet<QThread *> threads;
+@@ -249,17 +268,35 @@ void tst_QtConcurrentThreadEngine::threadCount()
+ {
+     const int repeats = 10;
+     for (int i = 0; i < repeats; ++i) {
++        ThreadCountUser t;
++        t.startBlocking();
++        int count = threads.count();
++        int count_expected = QThreadPool::globalInstance()->maxThreadCount() + 1; // +1 for the main thread.
++        if (count != count_expected)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, count_expected);
++
+         (new ThreadCountUser())->startAsynchronously().waitForFinished();
+-        const auto count = threads.count();
+-        const auto maxThreadCount = QThreadPool::globalInstance()->maxThreadCount();
+-        QVERIFY(count <= maxThreadCount);
+-        QVERIFY(!threads.contains(QThread::currentThread()));
++        count = threads.count();
++        count_expected = QThreadPool::globalInstance()->maxThreadCount();
++        if (count != count_expected)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, count_expected);
+     }
+ 
+     // Set the finish flag immediately, this should give us one thread only.
+     for (int i = 0; i < repeats; ++i) {
++        ThreadCountUser t(true /*finishImmediately*/);
++        t.startBlocking();
++        int count = threads.count();
++        if (count != 1)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
++        QCOMPARE(count, 1);
++
+         (new ThreadCountUser(true /*finishImmediately*/))->startAsynchronously().waitForFinished();
+-        const auto count = threads.count();
++        count = threads.count();
++        if (count != 1)
++            QEXPECT_FAIL("", "QTBUG-23333", Abort);
+         QCOMPARE(count, 1);
+         QVERIFY(!threads.contains(QThread::currentThread()));
+     }
+@@ -400,6 +437,7 @@ public:
+ 
+ void tst_QtConcurrentThreadEngine::exceptions()
+ {
++    // Asynchronous mode:
+     {
+         bool caught = false;
+         try  {
+@@ -412,6 +450,32 @@ void tst_QtConcurrentThreadEngine::exceptions()
+         QVERIFY2(caught, "did not get exception");
+     }
+ 
++    // Blocking mode:
++    // test throwing the exception from a worker thread.
++    {
++        bool caught = false;
++        try  {
++            QtConcurrentExceptionThrower e(QThread::currentThread());
++            e.startBlocking();
++        } catch (const QException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // test throwing the exception from the main thread (different code path)
++    {
++        bool caught = false;
++        try  {
++            QtConcurrentExceptionThrower e(0);
++            e.startBlocking();
++        } catch (const QException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // Asynchronous mode:
+     {
+         bool caught = false;
+         try  {
+@@ -423,6 +487,31 @@ void tst_QtConcurrentThreadEngine::exceptions()
+         }
+         QVERIFY2(caught, "did not get exception");
+     }
++
++    // Blocking mode:
++    // test throwing the exception from a worker thread.
++    {
++        bool caught = false;
++        try  {
++            UnrelatedExceptionThrower e(QThread::currentThread());
++            e.startBlocking();
++        } catch (const QUnhandledException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
++
++    // test throwing the exception from the main thread (different code path)
++    {
++        bool caught = false;
++        try  {
++            UnrelatedExceptionThrower e(0);
++            e.startBlocking();
++        } catch (const QUnhandledException &) {
++            caught = true;
++        }
++        QVERIFY2(caught, "did not get exception");
++    }
+ }
+ 
+ #endif
+diff --git a/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp b/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
+index 4968742110..f4c3fb711d 100644
+--- a/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
++++ b/qtbase/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
+@@ -42,6 +42,7 @@ private slots:
+     void writeBlock_data();
+     void writeBlock();
+     void seek();
++    void invalidSeeks();
+     void seekTest_data();
+     void seekTest();
+     void read_rawdata();
+@@ -286,6 +287,29 @@ void tst_QBuffer::seek()
+     QCOMPARE(buffer.size(), pos);
+ }
+ 
++void tst_QBuffer::invalidSeeks()
++{
++    if constexpr (sizeof(qsizetype) == sizeof(qint64)) {
++        // sizeof(qsizetype) == sizeof(qint64), so +1 would overflow
++        QSKIP("This is a 32-bit-only test.");
++    } else {
++        QBuffer buffer;
++        buffer.open(QIODevice::WriteOnly);
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++        constexpr qint64 MaxQByteArrayCapacity = (std::numeric_limits<qsizetype>::max)();
++        // this should fail fast, not after trying to allocate nearly 2 GiB of data,
++        // potentially crashing in the process:
++        QVERIFY(!buffer.seek(2 * MaxQByteArrayCapacity - 1));
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++        // ditto:
++        QVERIFY(!buffer.seek(MaxQByteArrayCapacity + 1));
++        QCOMPARE(buffer.buffer().size(), qsizetype(0));
++        QCOMPARE(buffer.pos(), qint64(0));
++    }
++}
++
+ void tst_QBuffer::seekTest_data()
+ {
+     writeBlock_data();
+diff --git a/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp b/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
+index da5327594c..4a04e0f7c6 100644
+--- a/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
++++ b/qtbase/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
+@@ -561,7 +561,8 @@ protected:
+     qint64 readData(char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf->size() - offset));
+-        memcpy(data, buf->constData() + offset, maxSize);
++        if (maxSize > 0)
++            memcpy(data, buf->constData() + offset, maxSize);
+         offset += maxSize;
+         return maxSize;
+     }
+@@ -604,13 +605,15 @@ protected:
+     qint64 readData(char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf.size() - pos()));
+-        memcpy(data, buf.constData() + pos(), maxSize);
++        if (maxSize > 0)
++            memcpy(data, buf.constData() + pos(), maxSize);
+         return maxSize;
+     }
+     qint64 writeData(const char *data, qint64 maxSize) override
+     {
+         maxSize = qMin(maxSize, qint64(buf.size() - pos()));
+-        memcpy(buf.data() + pos(), data, maxSize);
++        if (maxSize > 0)
++            memcpy(buf.data() + pos(), data, maxSize);
+         return maxSize;
+     }
+ 
+diff --git a/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+index db60bead64..f345a44414 100644
+--- a/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
++++ b/qtbase/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+@@ -1,7 +1,8 @@
+ /****************************************************************************
+ **
+ ** Copyright (C) 2021 The Qt Company Ltd.
+-** Copyright (C) 2020 Intel Corporation.
++** Copyright (C) 2020 The Qt Company Ltd.
++** Copyright (C) 2022 Intel Corporation.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the test suite of the Qt Toolkit.
+@@ -150,6 +151,8 @@ private slots:
+     void startStopStartStopBuffers();
+     void processEventsInAReadyReadSlot_data();
+     void processEventsInAReadyReadSlot();
++    void startFromCurrentWorkingDir_data();
++    void startFromCurrentWorkingDir();
+ 
+     // keep these at the end, since they use lots of processes and sometimes
+     // caused obscure failures to occur in tests that followed them (esp. on the Mac)
+@@ -2731,5 +2734,94 @@ void tst_QProcess::finishProcessBeforeReadingDone_deprecated()
+ 
+ #endif
+ 
++enum class ChdirMode {
++    None = 0,
++    InParent,
++    InChild
++};
++Q_DECLARE_METATYPE(ChdirMode)
++
++void tst_QProcess::startFromCurrentWorkingDir_data()
++{
++    qRegisterMetaType<ChdirMode>();
++    QTest::addColumn<QString>("programPrefix");
++    QTest::addColumn<ChdirMode>("chdirMode");
++    QTest::addColumn<bool>("success");
++
++    constexpr bool IsWindows = true
++#ifdef Q_OS_UNIX
++            && false
++#endif
++            ;
++
++    // baseline: trying to execute the directory, this can't possibly succeed!
++    QTest::newRow("plain-same-cwd") << QString() << ChdirMode::None << false;
++
++    // cross-platform behavior: neither OS searches the setWorkingDirectory()
++    // dir without "./"
++    QTest::newRow("plain-child-chdir") << QString() << ChdirMode::InChild << false;
++
++    // cross-platform behavior: both OSes search the parent's CWD with "./"
++    QTest::newRow("prefixed-parent-chdir") << "./" << ChdirMode::InParent << true;
++
++    // opposite behaviors: Windows searches the parent's CWD and Unix searches
++    // the child's with "./"
++    QTest::newRow("prefixed-child-chdir") << "./" << ChdirMode::InChild << !IsWindows;
++
++    // Windows searches the parent's CWD without "./"
++    QTest::newRow("plain-parent-chdir") << QString() << ChdirMode::InParent << IsWindows;
++}
++
++void tst_QProcess::startFromCurrentWorkingDir()
++{
++    QFETCH(QString, programPrefix);
++    QFETCH(ChdirMode, chdirMode);
++    QFETCH(bool, success);
++
++    QProcess process;
++    qRegisterMetaType<QProcess::ProcessError>();
++    QSignalSpy errorSpy(&process, &QProcess::errorOccurred);
++    QVERIFY(errorSpy.isValid());
++
++    // both the dir name and the executable name
++    const QString target = QStringLiteral("testProcessNormal");
++    process.setProgram(programPrefix + target);
++
++#ifdef Q_OS_UNIX
++    // Reset PATH, to be sure it doesn't contain . or the empty path.
++    // We can't do this on Windows because DLLs are searched in PATH
++    // and Windows always searches "." anyway.
++    auto restoreEnv = qScopeGuard([old = qgetenv("PATH")] {
++        qputenv("PATH", old);
++    });
++    qputenv("PATH", "/");
++#endif
++
++    switch (chdirMode) {
++    case ChdirMode::InParent: {
++        auto restoreCwd = qScopeGuard([old = QDir::currentPath()] {
++            QDir::setCurrent(old);
++        });
++        QVERIFY(QDir::setCurrent(target));
++        process.start();
++        break;
++    }
++    case ChdirMode::InChild:
++        process.setWorkingDirectory(target);
++        Q_FALLTHROUGH();
++    case ChdirMode::None:
++        process.start();
++        break;
++    }
++
++    QCOMPARE(process.waitForStarted(), success);
++    QCOMPARE(errorSpy.count(), int(!success));
++    if (success) {
++        QVERIFY(process.waitForFinished());
++    } else {
++        QCOMPARE(process.error(), QProcess::FailedToStart);
++    }
++}
++
+ QTEST_MAIN(tst_QProcess)
+ #include "tst_qprocess.moc"
+diff --git a/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp b/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp
+index e1ea7a4552..90972caa57 100644
+--- a/qtbase/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp
++++ b/qtbase/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"
+diff --git a/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+index 9bd66c0835..ed4a0bae5d 100644
+--- a/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
++++ b/qtbase/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+@@ -158,6 +158,7 @@ private slots:
+     void nullReceiver();
+     void functorReferencesConnection();
+     void disconnectDisconnects();
++    void declarativeData();
+ };
+ 
+ struct QObjectCreatedOnShutdown
+@@ -7679,5 +7680,81 @@ void tst_QObject::disconnectDisconnects()
+ Q_STATIC_ASSERT(QtPrivate::HasQ_OBJECT_Macro<tst_QObject>::Value);
+ Q_STATIC_ASSERT(!QtPrivate::HasQ_OBJECT_Macro<SiblingDeleter>::Value);
+ 
++#ifdef QT_BUILD_INTERNAL
++/*
++    Since QObjectPrivate stores the declarativeData pointer in a union with the pointer
++    to the currently destroyed child, calls to the QtDeclarative handlers need to be
++    correctly guarded. QTBUG-105286
++*/
++namespace QtDeclarative {
++static QAbstractDeclarativeData *theData;
++
++static void destroyed(QAbstractDeclarativeData *data, QObject *)
++{
++    QCOMPARE(data, theData);
++}
++static void signalEmitted(QAbstractDeclarativeData *data, QObject *, int, void **)
++{
++    QCOMPARE(data, theData);
++}
++// we can't use QCOMPARE in the next two functions, as they don't return void
++static int receivers(QAbstractDeclarativeData *data, const QObject *, int)
++{
++    QTest::qCompare(data, theData, "data", "theData", __FILE__, __LINE__);
++    return 0;
++}
++static bool isSignalConnected(QAbstractDeclarativeData *data, const QObject *, int)
++{
++    QTest::qCompare(data, theData, "data", "theData", __FILE__, __LINE__);
++    return true;
++}
++
++class Object : public QObject
++{
++    Q_OBJECT
++public:
++    using QObject::QObject;
++    ~Object()
++    {
++        if (Object *p = static_cast<Object *>(parent()))
++            p->emitSignal();
++    }
++
++    void emitSignal()
++    {
++        emit theSignal();
++    }
++
++signals:
++    void theSignal();
++};
++
++}
++#endif
++
++void tst_QObject::declarativeData()
++{
++#ifdef QT_BUILD_INTERNAL
++    QScopedValueRollback destroyed(QAbstractDeclarativeData::destroyed,
++                                   QtDeclarative::destroyed);
++    QScopedValueRollback signalEmitted(QAbstractDeclarativeData::signalEmitted,
++                                       QtDeclarative::signalEmitted);
++    QScopedValueRollback receivers(QAbstractDeclarativeData::receivers,
++                                   QtDeclarative::receivers);
++    QScopedValueRollback isSignalConnected(QAbstractDeclarativeData::isSignalConnected,
++                                           QtDeclarative::isSignalConnected);
++
++    QtDeclarative::Object p;
++    QObjectPrivate *priv = QObjectPrivate::get(&p);
++    priv->declarativeData = QtDeclarative::theData = new QAbstractDeclarativeData;
++
++    connect(&p, &QtDeclarative::Object::theSignal, &p, []{
++    });
++
++    QtDeclarative::Object *child = new QtDeclarative::Object;
++    child->setParent(&p);
++#endif
++}
++
+ QTEST_MAIN(tst_QObject)
+ #include "tst_qobject.moc"
+diff --git a/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp b/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
+index 0ea422ecbc..1a3256534b 100644
+--- a/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
++++ b/qtbase/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
+@@ -70,15 +70,15 @@ static inline QString testSuiteWarning()
+ 
+     QString result;
+     QTextStream str(&result);
+-    str << "\nCannot find the shared-mime-info test suite\nstarting from: "
++    str << "\nCannot find the shared-mime-info test suite\nin the parent of: "
+         << QDir::toNativeSeparators(QDir::currentPath()) << "\n"
+            "cd " << QDir::toNativeSeparators(QStringLiteral("tests/auto/corelib/mimetypes/qmimedatabase")) << "\n"
+-           "wget http://cgit.freedesktop.org/xdg/shared-mime-info/snapshot/Release-1-10.zip\n"
+-           "unzip Release-1-10.zip\n";
++           "wget https://gitlab.freedesktop.org/xdg/shared-mime-info/-/archive/2.1/shared-mime-info-2.1.zip\n"
++           "unzip shared-mime-info-2.1.zip\n";
+ #ifdef Q_OS_WIN
+-    str << "mkdir testfiles\nxcopy /s Release-1-10 s-m-i\n";
++    str << "mkdir testfiles\nxcopy /s shared-mime-info-2.1 s-m-i\n";
+ #else
+-    str << "ln -s Release-1-10 s-m-i\n";
++    str << "ln -s shared-mime-info-2.1 s-m-i\n";
+ #endif
+     return result;
+ }
+@@ -154,7 +154,7 @@ void tst_QMimeDatabase::initTestCase()
+     QVERIFY2(copyResourceFile(xmlFileName, xmlTargetFileName, &errorMessage), qPrintable(errorMessage));
+ #endif
+ 
+-    m_testSuite = QFINDTESTDATA("s-m-i/tests");
++    m_testSuite = QFINDTESTDATA("s-m-i/tests/mime-detection");
+     if (m_testSuite.isEmpty())
+         qWarning("%s", qPrintable(testSuiteWarning()));
+ 
+@@ -611,7 +611,7 @@ void tst_QMimeDatabase::allMimeTypes()
+     QVERIFY(!lst.isEmpty());
+ 
+     // Hardcoding this is the only way to check both providers find the same number of mimetypes.
+-    QCOMPARE(lst.count(), 779);
++    QCOMPARE(lst.count(), 811);
+ 
+     foreach (const QMimeType &mime, lst) {
+         const QString name = mime.name();
+@@ -631,10 +631,9 @@ void tst_QMimeDatabase::suffixes_data()
+ 
+     QTest::newRow("mimetype with a single pattern") << "application/pdf" << "*.pdf" << "pdf";
+     QTest::newRow("mimetype with multiple patterns") << "application/x-kpresenter" << "*.kpr;*.kpt" << "kpr";
+-    QTest::newRow("jpeg") << "image/jpeg" << "*.jpe;*.jpg;*.jpeg" << "jpeg";
+-    //if (KMimeType::sharedMimeInfoVersion() > KDE_MAKE_VERSION(0, 60, 0)) {
+-        QTest::newRow("mimetype with many patterns") << "application/vnd.wordperfect" << "*.wp;*.wp4;*.wp5;*.wp6;*.wpd;*.wpp" << "wp";
+-    //}
++    // The preferred suffix for image/jpeg is *.jpg, as per https://bugs.kde.org/show_bug.cgi?id=176737
++    QTest::newRow("jpeg") << "image/jpeg" << "*.jpe;*.jpg;*.jpeg" << "jpg";
++    QTest::newRow("mimetype with many patterns") << "application/vnd.wordperfect" << "*.wp;*.wp4;*.wp5;*.wp6;*.wpd;*.wpp" << "wp";
+     QTest::newRow("oasis text mimetype") << "application/vnd.oasis.opendocument.text" << "*.odt" << "odt";
+     QTest::newRow("oasis presentation mimetype") << "application/vnd.oasis.opendocument.presentation" << "*.odp" << "odp";
+     QTest::newRow("mimetype with multiple patterns") << "text/plain" << "*.asc;*.txt;*,v" << "txt";
+diff --git a/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp b/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
+index 3e58dd03cc..c8f82ef5d5 100644
+--- a/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
++++ b/qtbase/tests/auto/corelib/serialization/json/tst_qtjson.cpp
+@@ -176,6 +176,8 @@ private Q_SLOTS:
+     void fromToVariantConversions_data();
+     void fromToVariantConversions();
+ 
++    void noLeakOnNameClash();
++
+ private:
+     QString testDataDir;
+ };
+@@ -3685,5 +3687,23 @@ void tst_QtJson::fromToVariantConversions()
+     }
+ }
+ 
++void tst_QtJson::noLeakOnNameClash()
++{
++    QJsonDocument doc = QJsonDocument::fromJson("{\"\":{\"\":0},\"\":0}");
++    QVERIFY(!doc.isNull());
++    const QJsonObject obj = doc.object();
++
++    // Removed the duplicate key.
++    QCOMPARE(obj.length(), 1);
++
++    // Retained the last of the duplicates.
++    const QJsonValue val = obj.begin().value();
++    QVERIFY(val.isDouble());
++    QCOMPARE(val.toDouble(), 0.0);
++
++    // It should not leak.
++    // In particular it should not forget to deref the container for the inner object.
++}
++
+ QTEST_MAIN(tst_QtJson)
+ #include "tst_qtjson.moc"
+diff --git a/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp b/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
+index a59b58d57f..241c3e84ac 100644
+--- a/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
++++ b/qtbase/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp
+@@ -63,6 +63,7 @@ private slots:
+     void isValidId_data();
+     void isValidId();
+     void malformed();
++    void serialize();
+     // Backend tests
+     void utcTest();
+     void icuTest();
+@@ -947,6 +948,33 @@ void tst_QTimeZone::malformed()
+         barf.offsetFromUtc(now);
+ }
+ 
++void tst_QTimeZone::serialize()
++{
++    int parts = 0;
++#ifndef QT_NO_DEBUG_STREAM
++    qDebug() << QTimeZone(); // to verify no crash
++    parts++;
++#endif
++#ifndef QT_NO_DATASTREAM
++    QByteArray blob;
++    {
++        QDataStream stream(&blob, QIODevice::WriteOnly);
++        stream << QTimeZone("Europe/Oslo") << QTimeZone(420) << QTimeZone() << qint64(-1);
++    }
++    QDataStream stream(&blob, QIODevice::ReadOnly);
++    QTimeZone invalid, offset, oslo;
++    qint64 minusone;
++    stream >> oslo >> offset >> invalid >> minusone;
++    QCOMPARE(oslo, QTimeZone("Europe/Oslo"));
++    QCOMPARE(offset, QTimeZone(420));
++    QVERIFY(!invalid.isValid());
++    QCOMPARE(minusone, qint64(-1));
++    parts++;
++#endif
++    if (!parts)
++        QSKIP("No serialization enabled");
++}
++
+ void tst_QTimeZone::utcTest()
+ {
+ #ifdef QT_BUILD_INTERNAL
+diff --git a/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp b/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
+index 05480c6dd2..70f4c75756 100644
+--- a/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
++++ b/qtbase/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp
+@@ -324,6 +324,13 @@ void tst_QDBusInterface::notValid()
+ 
+     QVERIFY(!interface.isValid());
+     QVERIFY(!QMetaObject::invokeMethod(&interface, "ListNames", Qt::DirectConnection));
++
++    // With a connection, but empty/null service and path specified
++    QDBusConnection con = QDBusConnection::sessionBus();
++    QVERIFY(con.isConnected());
++    QDBusInterface iface({}, {}, {}, con);
++    QVERIFY(!iface.isValid());
++    QVERIFY(!QMetaObject::invokeMethod(&interface, "ListNames", Qt::DirectConnection));
+ }
+ 
+ void tst_QDBusInterface::notValidDerived()
+diff --git a/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp b/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
+index 874468c954..04ceb4ab65 100644
+--- a/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
++++ b/qtbase/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
+@@ -507,6 +507,10 @@ void tst_QKeySequence::toStringFromKeycode_data()
+     QTest::newRow("Ctrl+Alt+Num+Del") << QKeySequence(Qt::ControlModifier | Qt::AltModifier | Qt::KeypadModifier | Qt::Key_Delete) << "Ctrl+Alt+Num+Del";
+     QTest::newRow("Ctrl+Ins") << QKeySequence(Qt::ControlModifier | Qt::Key_Insert) << "Ctrl+Ins";
+     QTest::newRow("Ctrl+Num+Ins(1)") << QKeySequence(Qt::Key_Insert | Qt::KeypadModifier | Qt::ControlModifier) << "Ctrl+Num+Ins";
++    QTest::newRow("Ctrl") << QKeySequence(Qt::Key_Control) << "Control";
++    QTest::newRow("Alt") << QKeySequence(Qt::Key_Alt) << "Alt";
++    QTest::newRow("Shift") << QKeySequence(Qt::Key_Shift) << "Shift";
++    QTest::newRow("Meta") << QKeySequence(Qt::Key_Meta) << "Meta";
+ }
+ 
+ void tst_QKeySequence::toStringFromKeycode()
+diff --git a/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp b/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+index 15e0ecadaa..b4eca74283 100644
+--- a/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
++++ b/qtbase/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+@@ -81,6 +81,8 @@ private slots:
+     void registerOpenTypePreferredNamesSystem();
+     void registerOpenTypePreferredNamesApplication();
+ 
++    void stretchRespected();
++
+ private:
+     QString m_ledFont;
+     QString m_testFont;
+@@ -355,6 +357,28 @@ static QString testString()
+     return QStringLiteral("foo bar");
+ }
+ 
++void tst_QFontDatabase::stretchRespected()
++{
++    int italicId = QFontDatabase::addApplicationFont(m_testFontItalic);
++    QVERIFY(italicId != -1);
++
++    QVERIFY(!QFontDatabase::applicationFontFamilies(italicId).isEmpty());
++
++    QString italicFontName = QFontDatabase::applicationFontFamilies(italicId).first();
++
++    QFont italicFont = QFontDatabase().font(italicFontName,
++                                            QString::fromLatin1("Italic"), 14);
++    QVERIFY(italicFont.italic());
++
++    QFont italicStretchedFont = italicFont;
++    italicStretchedFont.setStretch( 400 );
++
++    QVERIFY(QFontMetricsF(italicFont).horizontalAdvance(QStringLiteral("foobar")) <
++            QFontMetricsF(italicStretchedFont).horizontalAdvance(QStringLiteral("foobar")));
++
++    QFontDatabase::removeApplicationFont(italicId);
++}
++
+ void tst_QFontDatabase::condensedFontWidthNoFontMerging()
+ {
+     int regularFontId = QFontDatabase::addApplicationFont(m_testFont);
+diff --git a/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+index 3d4a094c43..b423e11a99 100644
+--- a/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
++++ b/qtbase/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+@@ -281,6 +281,7 @@ private Q_SLOTS:
+     void ioGetFromFileSpecial();
+     void ioGetFromFile_data();
+     void ioGetFromFile();
++    void ioGetFromFileUrl();
+     void ioGetFromFtp_data();
+     void ioGetFromFtp();
+     void ioGetFromFtpWithReuse();
+@@ -3300,6 +3301,18 @@ void tst_QNetworkReply::ioGetFromFile()
+     QCOMPARE(reader.data, data);
+ }
+ 
++void tst_QNetworkReply::ioGetFromFileUrl()
++{
++    // This immediately fails on non-windows platforms:
++    QNetworkRequest request(QUrl("file://unc-server/some/path"));
++    QNetworkReplyPtr reply(manager.get(request));
++    QSignalSpy finishedSpy(reply.get(), &QNetworkReply::finished);
++    // QTBUG-105618: This would, on non-Windows platforms, never happen because the signal
++    // was emitted before the constructor finished, leaving no chance at all to connect to the
++    // signal
++    QVERIFY(finishedSpy.wait());
++}
++
+ void tst_QNetworkReply::ioGetFromFtp_data()
+ {
+     QTest::addColumn<QString>("fileName");
+diff --git a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
+index 069fa6b341..4cc4d9a5ea 100644
+--- a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
++++ b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.cert
+@@ -1,75 +1,34 @@
+-Certificate:
+-    Data:
+-        Version: 3 (0x2)
+-        Serial Number: 0 (0x0)
+-        Signature Algorithm: sha1WithRSAEncryption
+-        Issuer: C=NO, ST=Oslo, L=Nydalen, O=Nokia Corporation and/or its subsidiary(-ies), OU=Development, CN=fluke.troll.no/emailAddress=ahanssen@trolltech.com
+-        Validity
+-            Not Before: Dec  4 01:10:32 2007 GMT
+-            Not After : Apr 21 01:10:32 2035 GMT
+-        Subject: C=NO, ST=Oslo, O=Nokia Corporation and/or its subsidiary(-ies), OU=Development, CN=fluke.troll.no
+-        Subject Public Key Info:
+-            Public Key Algorithm: rsaEncryption
+-            RSA Public Key: (1024 bit)
+-                Modulus (1024 bit):
+-                    00:a7:c8:a0:4a:c4:19:05:1b:66:ba:32:e2:d2:f1:
+-                    1c:6f:17:82:e4:39:2e:01:51:90:db:04:34:32:11:
+-                    21:c2:0d:6f:59:d8:53:90:54:3f:83:8f:a9:d3:b3:
+-                    d5:ee:1a:9b:80:ae:c3:25:c9:5e:a5:af:4b:60:05:
+-                    aa:a0:d1:91:01:1f:ca:04:83:e3:58:1c:99:32:45:
+-                    84:70:72:58:03:98:4a:63:8b:41:f5:08:49:d2:91:
+-                    02:60:6b:e4:64:fe:dd:a0:aa:74:08:e9:34:4c:91:
+-                    5f:12:3d:37:4d:54:2c:ad:7f:5b:98:60:36:02:8c:
+-                    3b:f6:45:f3:27:6a:9b:94:9d
+-                Exponent: 65537 (0x10001)
+-        X509v3 extensions:
+-            X509v3 Basic Constraints: 
+-                CA:FALSE
+-            Netscape Comment: 
+-                OpenSSL Generated Certificate
+-            X509v3 Subject Key Identifier: 
+-                21:85:04:3D:23:01:66:E5:F7:9F:1A:84:24:8A:AF:0A:79:F4:E5:AC
+-            X509v3 Authority Key Identifier: 
+-                DirName:/C=NO/ST=Oslo/L=Nydalen/O=Nokia Corporation and/or its subsidiary(-ies)/OU=Development/CN=fluke.troll.no/emailAddress=ahanssen@trolltech.com
+-                serial:8E:A8:B4:E8:91:B7:54:2E
+-
+-    Signature Algorithm: sha1WithRSAEncryption
+-        6d:57:5f:d1:05:43:f0:62:05:ec:2a:71:a5:dc:19:08:f2:c4:
+-        a6:bd:bb:25:d9:ca:89:01:0e:e4:cf:1f:c1:8c:c8:24:18:35:
+-        53:59:7b:c0:43:b4:32:e6:98:b2:a6:ef:15:05:0b:48:5f:e1:
+-        a0:0c:97:a9:a1:77:d8:35:18:30:bc:a9:8f:d3:b7:54:c7:f1:
+-        a9:9e:5d:e6:19:bf:f6:3c:5b:2b:d8:e4:3e:62:18:88:8b:d3:
+-        24:e1:40:9b:0c:e6:29:16:62:ab:ea:05:24:70:36:aa:55:93:
+-        ef:02:81:1b:23:10:a2:04:eb:56:95:75:fc:f8:94:b1:5d:42:
+-        c5:3f:36:44:85:5d:3a:2e:90:46:8a:a2:b9:6f:87:ae:0c:15:
+-        40:19:31:90:fc:3b:25:bb:ae:f1:66:13:0d:85:90:d9:49:34:
+-        8f:f2:5d:f9:7a:db:4d:5d:27:f6:76:9d:35:8c:06:a6:4c:a3:
+-        b1:b2:b6:6f:1d:d7:a3:00:fd:72:eb:9e:ea:44:a1:af:21:34:
+-        7d:c7:42:e2:49:91:19:8b:c0:ad:ba:82:80:a8:71:70:f4:35:
+-        31:91:63:84:20:95:e9:60:af:64:8b:cc:ff:3d:8a:76:74:3d:
+-        c8:55:6d:e4:8e:c3:2b:1c:e8:42:18:ae:9f:e6:6b:9c:34:06:
+-        ec:6a:f2:c3
+ -----BEGIN CERTIFICATE-----
+-MIIEEzCCAvugAwIBAgIBADANBgkqhkiG9w0BAQUFADCBnDELMAkGA1UEBhMCTk8x
+-DTALBgNVBAgTBE9zbG8xEDAOBgNVBAcTB055ZGFsZW4xFjAUBgNVBAoTDVRyb2xs
+-dGVjaCBBU0ExFDASBgNVBAsTC0RldmVsb3BtZW50MRcwFQYDVQQDEw5mbHVrZS50
+-cm9sbC5ubzElMCMGCSqGSIb3DQEJARYWYWhhbnNzZW5AdHJvbGx0ZWNoLmNvbTAe
+-Fw0wNzEyMDQwMTEwMzJaFw0zNTA0MjEwMTEwMzJaMGMxCzAJBgNVBAYTAk5PMQ0w
+-CwYDVQQIEwRPc2xvMRYwFAYDVQQKEw1Ucm9sbHRlY2ggQVNBMRQwEgYDVQQLEwtE
+-ZXZlbG9wbWVudDEXMBUGA1UEAxMOZmx1a2UudHJvbGwubm8wgZ8wDQYJKoZIhvcN
+-AQEBBQADgY0AMIGJAoGBAKfIoErEGQUbZroy4tLxHG8XguQ5LgFRkNsENDIRIcIN
+-b1nYU5BUP4OPqdOz1e4am4CuwyXJXqWvS2AFqqDRkQEfygSD41gcmTJFhHByWAOY
+-SmOLQfUISdKRAmBr5GT+3aCqdAjpNEyRXxI9N01ULK1/W5hgNgKMO/ZF8ydqm5Sd
+-AgMBAAGjggEaMIIBFjAJBgNVHRMEAjAAMCwGCWCGSAGG+EIBDQQfFh1PcGVuU1NM
+-IEdlbmVyYXRlZCBDZXJ0aWZpY2F0ZTAdBgNVHQ4EFgQUIYUEPSMBZuX3nxqEJIqv
+-Cnn05awwgbsGA1UdIwSBszCBsKGBoqSBnzCBnDELMAkGA1UEBhMCTk8xDTALBgNV
+-BAgTBE9zbG8xEDAOBgNVBAcTB055ZGFsZW4xFjAUBgNVBAoTDVRyb2xsdGVjaCBB
+-U0ExFDASBgNVBAsTC0RldmVsb3BtZW50MRcwFQYDVQQDEw5mbHVrZS50cm9sbC5u
+-bzElMCMGCSqGSIb3DQEJARYWYWhhbnNzZW5AdHJvbGx0ZWNoLmNvbYIJAI6otOiR
+-t1QuMA0GCSqGSIb3DQEBBQUAA4IBAQBtV1/RBUPwYgXsKnGl3BkI8sSmvbsl2cqJ
+-AQ7kzx/BjMgkGDVTWXvAQ7Qy5piypu8VBQtIX+GgDJepoXfYNRgwvKmP07dUx/Gp
+-nl3mGb/2PFsr2OQ+YhiIi9Mk4UCbDOYpFmKr6gUkcDaqVZPvAoEbIxCiBOtWlXX8
+-+JSxXULFPzZEhV06LpBGiqK5b4euDBVAGTGQ/Dslu67xZhMNhZDZSTSP8l35ettN
+-XSf2dp01jAamTKOxsrZvHdejAP1y657qRKGvITR9x0LiSZEZi8CtuoKAqHFw9DUx
+-kWOEIJXpYK9ki8z/PYp2dD3IVW3kjsMrHOhCGK6f5mucNAbsavLD
++MIIF6zCCA9OgAwIBAgIUfo9amJtJGWqWE6f+SkAO85zkGr4wDQYJKoZIhvcNAQEL
++BQAwgYMxCzAJBgNVBAYTAk5PMQ0wCwYDVQQIDARPc2xvMQ0wCwYDVQQHDARPc2xv
++MRcwFQYDVQQKDA5UaGUgUXQgQ29tcGFueTEMMAoGA1UECwwDUiZEMRIwEAYDVQQD
++DAlIMiBUZXN0ZXIxGzAZBgkqhkiG9w0BCQEWDG1pbmltaUBxdC5pbzAgFw0yMDEw
++MjYxMjAxMzFaGA8yMTIwMTAwMjEyMDEzMVowgYMxCzAJBgNVBAYTAk5PMQ0wCwYD
++VQQIDARPc2xvMQ0wCwYDVQQHDARPc2xvMRcwFQYDVQQKDA5UaGUgUXQgQ29tcGFu
++eTEMMAoGA1UECwwDUiZEMRIwEAYDVQQDDAlIMiBUZXN0ZXIxGzAZBgkqhkiG9w0B
++CQEWDG1pbmltaUBxdC5pbzCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIB
++AOiUp5+E4blouKH7q+rVNR8NoYX2XkBW+q+rpy1zu5ssRSzbqxAjDx9dkht7Qlnf
++VlDT00JvpOWdeuPon5915edQRsY4Unl6mKH29ra3OtUa1/yCJXsGVJTKCj7k4Bxb
++5mZzb/fTlZntMLdTIBMfUbw62FKir1WjKIcJ9fCoG8JaGeKVO4Rh5p0ezd4UUUId
++r1BXl5Nqdqy2vTMsEDnjOsD3egkv8I2SKN4O6n/C3wWYpMOWYZkGoZiKz7rJs/i/
++ez7bsV7JlwdzTlhpJzkcOSVFBP6JlEOxTNNxZ1wtKy7PtZGmsSSATq2e6+bw38Ae
++Op0XnzzqcGjtDDofBmT7OFzZWjS9VZS6+DOOe2QHWle1nCHcHyH4ku6IRlsr9xkR
++NAIlOfnvHHxqJUenoeaZ4oQDjCBKS1KXygJO/tL7BLTQVn/xK1EmPvKNnjzWk4tR
++PnibUhhs5635qpOU/YPqFBh1JjVruZbsWcDAhRcew0uxONXOa9E+4lttQ9ySYa1A
++LvWqJuAX7gu2BsBMLyqfm811YnA7CIFMyO+HlqmkLFfv5L/xIRAXR7l26YGO0VwX
++CGjMfz4NVPMMke4nB7qa9NkpXQBQKMms3Qzd5JW0Hy9Ruj5O8GPcFZmV0twjd1uJ
++PD/cAjkWLaXjdNsJ16QWc2nghQRS6HYqKRX6j+CXOxupAgMBAAGjUzBRMB0GA1Ud
++DgQWBBRSCOU58j9NJZkMamt623qyCrhN3TAfBgNVHSMEGDAWgBRSCOU58j9NJZkM
++amt623qyCrhN3TAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4ICAQCq
++q4jxsWeNDv5Nq14hJtF9HB+ZL64zcZtRjJP1YgNs0QppKICmjPOL2nIMGmI/jKrs
++0eGAL/9XXNVHPxm1OPOncvimMMmU6emZfpMdEtTfKP43+Pg9HgKRjLoQp406vGeQ
++8ki/mbBhrItVPgEm3tu2AFA02XTYi+YxCI9kRZLGkM3FbgtOuTLPl0Z9y+kiPc9F
++uCSC03anBEqv+vDSI8+wODymQ/IJ3Jyz1lxIRDfp4qAekmy0jU2c91VOHHEmOmqq
++kqygGFRdwbe99m9yP63r6q0b5K3X2UnJ6bns0hmTwThYwpVPXLU8jdaTddbMukN2
++/Ef96Tsw8nWOEOPMySHOTIPgwyZRp26b0kA9EmhLwOP401SxXVQCmSRmtwNagmtg
++jJKmZoYBN+//D45ibK8z6Q0oOm9P+Whf/uUXehcRxBxyV3xz7k0wKGQbHj/ddwcy
++IUoIN4lrAlib+lK170kTKN352PDmrpo2gmIzPEsfurKAIMSelDl6H+kih16BtZ8y
++Nz6fh9Soqrg3OSAware8pxV7k51crBMoPLN78KoRV8MFCK4K7Fddq4rRISq6hiXq
++r1nsjoEPuKM9huprmZVZe9t5YcDa2I+wb3IiE3uwpZbAdaLDyQ5n6F/qpsiIkZXn
++gtcF7oqpG5oYrwCcZ53y/ezUgUg7PlSz2XwAGvQtgg==
+ -----END CERTIFICATE-----
+diff --git a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
+index 9d1664d609..337ce541a6 100644
+--- a/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
++++ b/qtbase/tests/auto/network/ssl/qsslsocket/certs/fluke.key
+@@ -1,15 +1,52 @@
+------BEGIN RSA PRIVATE KEY-----
+-MIICXAIBAAKBgQCnyKBKxBkFG2a6MuLS8RxvF4LkOS4BUZDbBDQyESHCDW9Z2FOQ
+-VD+Dj6nTs9XuGpuArsMlyV6lr0tgBaqg0ZEBH8oEg+NYHJkyRYRwclgDmEpji0H1
+-CEnSkQJga+Rk/t2gqnQI6TRMkV8SPTdNVCytf1uYYDYCjDv2RfMnapuUnQIDAQAB
+-AoGANFzLkanTeSGNFM0uttBipFT9F4a00dqHz6JnO7zXAT26I5r8sU1pqQBb6uLz
+-/+Qz5Zwk8RUAQcsMRgJetuPQUb0JZjF6Duv24hNazqXBCu7AZzUenjafwmKC/8ri
+-KpX3fTwqzfzi//FKGgbXQ80yykSSliDL3kn/drATxsLCgQECQQDXhEFWLJ0vVZ1s
+-1Ekf+3NITE+DR16X+LQ4W6vyEHAjTbaNWtcTKdAWLA2l6N4WAAPYSi6awm+zMxx4
+-VomVTsjdAkEAx0z+e7natLeFcrrq8pbU+wa6SAP1VfhQWKitxL1e7u/QO90NCpxE
+-oQYKzMkmmpOOFjQwEMAy1dvFMbm4LHlewQJAC/ksDBaUcQHHqjktCtrUb8rVjAyW
+-A8lscckeB2fEYyG5J6dJVaY4ClNOOs5yMDS2Afk1F6H/xKvtQ/5CzInA/QJATDub
+-K+BPU8jO9q+gpuIi3VIZdupssVGmCgObVCHLakG4uO04y9IyPhV9lA9tALtoIf4c
+-VIvv5fWGXBrZ48kZAQJBAJmVCdzQxd9LZI5vxijUCj5EI4e+x5DRqVUvyP8KCZrC
+-AiNyoDP85T+hBZaSXK3aYGpVwelyj3bvo1GrTNwNWLw=
+------END RSA PRIVATE KEY-----
++-----BEGIN PRIVATE KEY-----
++MIIJQgIBADANBgkqhkiG9w0BAQEFAASCCSwwggkoAgEAAoICAQDolKefhOG5aLih
+++6vq1TUfDaGF9l5AVvqvq6ctc7ubLEUs26sQIw8fXZIbe0JZ31ZQ09NCb6TlnXrj
++6J+fdeXnUEbGOFJ5epih9va2tzrVGtf8giV7BlSUygo+5OAcW+Zmc2/305WZ7TC3
++UyATH1G8OthSoq9VoyiHCfXwqBvCWhnilTuEYeadHs3eFFFCHa9QV5eTanastr0z
++LBA54zrA93oJL/CNkijeDup/wt8FmKTDlmGZBqGYis+6ybP4v3s+27FeyZcHc05Y
++aSc5HDklRQT+iZRDsUzTcWdcLSsuz7WRprEkgE6tnuvm8N/AHjqdF5886nBo7Qw6
++HwZk+zhc2Vo0vVWUuvgzjntkB1pXtZwh3B8h+JLuiEZbK/cZETQCJTn57xx8aiVH
++p6HmmeKEA4wgSktSl8oCTv7S+wS00FZ/8StRJj7yjZ481pOLUT54m1IYbOet+aqT
++lP2D6hQYdSY1a7mW7FnAwIUXHsNLsTjVzmvRPuJbbUPckmGtQC71qibgF+4LtgbA
++TC8qn5vNdWJwOwiBTMjvh5appCxX7+S/8SEQF0e5dumBjtFcFwhozH8+DVTzDJHu
++Jwe6mvTZKV0AUCjJrN0M3eSVtB8vUbo+TvBj3BWZldLcI3dbiTw/3AI5Fi2l43Tb
++CdekFnNp4IUEUuh2KikV+o/glzsbqQIDAQABAoICAFw1q6tr5I48vY7DF+rXsuLn
++5ZUWE1IQ6fzB4lr72nJv/9EEGnMgYzt9PpMUsD6vdCpBgS2C0+6RHArFzJtNA+RM
++iHLIG7K7702veyr/xBx/MwiSlMeMv/XpkFxVI6E6skMGG2s3AMXxKvJTy5CpRx+I
++eQFyLG+Ya1X2lgJes/q+/CpAHkOjCOpcLySQC5NZ74q734V7nSdmn+Zs3tYEh+O/
++eiuwTP/j5b38Te5vVTqDxTciJPmljmXLCwa0N100lWlbcpvw8qbqiTI2Jm3XCbUE
++AzHjW9vmrF3cRS1fXxKFGShw3SRqlkbxjfeWoi8qDPUBS4m8LOr8qG9Wo5Nfon0z
++zLP4bci3zHDvVcaaZrrsUBs/yZbg+Dgka1DmX7ekmeccr2yTdKDFgPupYUyxVbTl
++a9ZLJysjFD7rgBv1ZclHonLp6Vbm+ZoTqvteo4ikAy6L9RtBWJ23XEK34PkP/+c5
++2vWZaOrnjSeBHbFce8cdJSxqWpP+eSCI5I9XbDrYFIsQ/gqKgtzDKy2ihJ2Y8STL
++yO4hyFPFjxc+Gg4/P2PpmT5CY2ty44M0BWs+JGW96CJPrrplf2lmQUQJj5LZY66X
++Z/4C9L7ZYtKZ+bs5SvU46yWugAvQZX22Xm9xLXWyVXRdx3bj+3M3fDnF9di/zdbh
++CgLx7oWPNrXc7FCajnn9AoIBAQD5FMYwRpw9NWT9WDxQwx+cSI4Icbd88ByTW63S
++LzeRwZA0J9/SfwO+aBRupzc9GkGXCiZcGMw3AGsCtig8yFlw8E5KnzN7KlftDMnM
++9NUxxzlR8VwKyLnZfG7sDTl057ZlUujnqhmt/F8F7dIy7FVO1dE/8nngA+FYTCOG
++UZdGjwyBDlDM0JJdUWGY3xslutcpCDN5mzSTKjy9drMvImAshRawxRF6WBpn7vr2
++nC6vciqfx1Mzx1vyk0Jm0ilaydDdLMADjt/iL4Nkr0BEs4k+UzQiKDwp8gu7abQ1
++eBfxd9Iar4htQa2I1Ewl6P01G/q+ZYwgHhJ9RVn4AxQXefILAoIBAQDvCouORdQX
++C8wsyp7MwXlF/3NQeNN5/+B2mhbxrBOf7PmMCXLnkRWcjwJtzypWFqJ0sqai/2+0
++bqbMcjX5maT8stT2shl3zXe/Ejt2e3TBYpc1tyuses8Kb5BMU8hu6tTd3G2CMXpD
++dT6DVemJZCTtwj9aBNIxSizvlgMolJnCpzhPnlfHSI6E+g3m/LTTo3HwbjMSw/Uq
++irgjOpI2wSBB6LZPSgjvfcYPRyWUk16L4A5uSX0cADnovDFLa5/h0wJvN/OoCSQg
++rLCXG5E18EyL5Wc58BCY1ZvxmjG3lQtgPxYu2Jwc36R/y/JKlxW5suER5ZNpbbD4
++uOyTt2VxMQ2bAoIBAQC5+MzRFqdo/AjfL5Y5JrbfVTzXCTDa09xCGd16ZU60QTWN
+++4ed/r+o1sUKqUcRFB2MzEM/2DQBjQpZB/CbEWvWa1XJWXxypXbowveZU+QqOnmN
++uQvj8WLyA3o+PNF9e9QvauwCrHpn8VpxbtPWuaYoKnUFreFZZQxHhPGxRBIS2JOZ
++eDrT8ZaWnkCkh1AZp5smQ71LOprSlmKrg4jd1GjCVMxQR5N5KXbtyv0OTCZ/UFqK
++2aRBsMPyJgkaBChkZPLRcKwc+/wlQRx1fHQb14DNTApMxoXFO7eOwqmOkpAt9iyl
++SBIwoS0UUI5ab88+bBmXNvKcuFdNuQ4nowTJUn9pAoIBADMNkILBXSvS5DeIyuO2
++Sp1tkoZUV+5NfPY3sMDK3KIibaW/+t+EOBZo4L7tKQCb8vRzl21mmsfxfgRaPDbj
++3r3tv9g0b4YLxxBy52pFscj/soXRai17SS7UZwA2QK+XzgDYbDcLNC6mIsTQG4Gx
++dsWk3/zs3KuUSQaehmwrWK+fIUK38c1pLK8v7LoxrLkqxlHwZ04RthHw8KTthH7X
++Pnl1J0LF8CSeOyfWLSuPUfkT0GEzptnNHpEbaHfQM6R6eaGhVJPF6AZme4y6YYgg
++m2ihhSt1n0XVEWpHYWjxFy3mK2mz75unFC4LM+NEY2p2zuUQoCw7NjnY3QYrfCnx
++rRMCggEAXeXsMSLFjjyuoL7iKbAxo52HD/P0fBoy58LyRcwfNVr0lvYan4pYEx+o
++KijIh9K16PqXZXKMA9v003B+ulmF8bJ7SddCZ5NGvnFhUTDe4DdTKgp2RuwQ3Bsc
++3skPIDbhVETyOLCtys34USHrq8U/0DlGY3eLRfxw9GnbKxSBGa/KEu/qQLPNUo50
++7xHZDg7GKeC3kqNJeqKM9rkp0VzIGkEnaD9127LeNDmERDfftxJzFoC/THvUBLfU
++6Sus2ZYwRE8VFvKC30Q45t/c54X3IuhYvAuiCuTmyfE4ruyzyOwKzhUkeeLq1APX
++g0veFbyfzlJ0q8qzD/iffqqIa2ZSmQ==
++-----END PRIVATE KEY-----
+diff --git a/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp b/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
+index 7ba3715e13..752aa122f6 100644
+--- a/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
++++ b/qtbase/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
+@@ -179,6 +179,7 @@ void tst_QAccessibilityLinux::initTestCase()
+     QVERIFY(!address.isEmpty());
+ 
+     m_window = new AccessibleTestWindow();
++    m_window->setObjectName("mainWindow"_L1);
+     m_window->show();
+ 
+     QVERIFY(QTest::qWaitForWindowExposed(m_window));
+@@ -236,8 +237,11 @@ bool hasState(QDBusInterface *interface, AtspiStateType state)
+ void tst_QAccessibilityLinux::testLabel()
+ {
+     QLabel *l = new QLabel(m_window);
++    l->setObjectName("theObjectName"_L1);
+     l->setText("Hello A11y");
+     m_window->addWidget(l);
++    auto a11yEmpty = new QLabel(m_window);
++    m_window->addWidget(l);
+ 
+     // Application
+     QCOMPARE(getParent(mainWindow), QLatin1String(ATSPI_DBUS_PATH_ROOT));
+@@ -249,6 +253,8 @@ void tst_QAccessibilityLinux::testLabel()
+     QCOMPARE(getChildren(labelInterface).count(), 0);
+     QCOMPARE(labelInterface->call(QDBus::Block, "GetRoleName").arguments().first().toString(), QLatin1String("label"));
+     QCOMPARE(labelInterface->call(QDBus::Block, "GetRole").arguments().first().toUInt(), 29u);
++    QCOMPARE(labelInterface->call(QDBus::Block, "GetAccessibleId").arguments().first().toString(),
++             QLatin1String("mainWindow.theObjectName"));
+     QCOMPARE(getParent(labelInterface), mainWindow->path());
+     QVERIFY(!hasState(labelInterface, ATSPI_STATE_EDITABLE));
+     QVERIFY(hasState(labelInterface, ATSPI_STATE_READ_ONLY));
+@@ -256,7 +262,12 @@ void tst_QAccessibilityLinux::testLabel()
+     l->setText("New text");
+     QCOMPARE(labelInterface->property("Name").toString(), l->text());
+ 
++    auto *a11yEmptyInterface = getInterface(children.at(1), "org.a11y.atspi.Accessible");
++    QCOMPARE(a11yEmptyInterface->call(QDBus::Block, "GetAccessibleId").arguments().first().toString(),
++             QLatin1String("mainWindow.QLabel"));
++
+     m_window->clearChildren();
++    delete a11yEmptyInterface;
+     delete labelInterface;
+ }
+ 
+diff --git a/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+index 76df61c892..6d6d65b791 100644
+--- a/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
++++ b/qtbase/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+@@ -1,6 +1,6 @@
+ /****************************************************************************
+ **
+-** Copyright (C) 2016 The Qt Company Ltd.
++** Copyright (C) 2022 The Qt Company Ltd.
+ ** Contact: https://www.qt.io/licensing/
+ **
+ ** This file is part of the test suite of the Qt Toolkit.
+@@ -68,6 +68,8 @@ private slots:
+     void query_exec();
+     void execErrorRecovery_data() { generic_data(); }
+     void execErrorRecovery();
++    void prematureExec_data() { generic_data(); }
++    void prematureExec();
+     void first_data() { generic_data(); }
+     void first();
+     void next_data() { generic_data(); }
+@@ -2770,6 +2772,35 @@ void tst_QSqlQuery::execErrorRecovery()
+     QVERIFY_SQL( q, exec() );
+ }
+ 
++void tst_QSqlQuery::prematureExec()
++{
++    QFETCH(QString, dbName);
++    // We only want the engine name, for addDatabase():
++    int cut = dbName.indexOf(QChar('@'));
++    if (cut < 0)
++        QSKIP("Failed to parse database type out of name");
++    dbName.truncate(cut);
++    cut = dbName.indexOf(QChar('_'));
++    if (cut >= 0)
++        dbName = dbName.mid(cut + 1);
++
++    auto db = QSqlDatabase::addDatabase(dbName);
++    QSqlQuery q(db);
++
++    QTest::ignoreMessage(QtWarningMsg,
++                         "QSqlDatabasePrivate::removeDatabase: connection "
++                         "'qt_sql_default_connection' is still in use, all "
++                         "queries will cease to work.");
++    QTest::ignoreMessage(QtWarningMsg,
++                         "QSqlDatabasePrivate::addDatabase: duplicate connection name "
++                         "'qt_sql_default_connection', old connection removed.");
++    auto otherDb = QSqlDatabase::addDatabase(dbName);
++
++    QTest::ignoreMessage(QtWarningMsg, "QSqlQuery::exec: called before driver has been set up");
++    // QTBUG-100037: shouldn't crash !
++    QVERIFY(!q.exec("select stuff from TheVoid"));
++}
++
+ void tst_QSqlQuery::lastInsertId()
+ {
+     QFETCH( QString, dbName );
+diff --git a/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp b/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
+index 4aa3f8d60b..d2050a61aa 100644
+--- a/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
++++ b/qtbase/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp
+@@ -115,6 +115,10 @@ void tst_QAbstractItemModelTester::standardItemModelZeroColumns()
+     // QTBUG-92886
+     model.insertRows(0, 5);
+     model.removeRows(1, 2);
++
++    const QModelIndex parentIndex = model.index(0, 0);
++    model.insertRows(0, 5, parentIndex);
++    model.removeRows(1, 2, parentIndex);
+ }
+ 
+ void tst_QAbstractItemModelTester::testInsertThroughProxy()
+diff --git a/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json b/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
+index 12a4a22a19..ce518e78fb 100644
+--- a/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
++++ b/qtbase/tests/auto/tools/moc/allmocs_baseline_in.json
+@@ -668,50 +668,6 @@
+         "inputFile": "task192552.h",
+         "outputRevision": 67
+     },
+-    {
+-        "classes": [
+-            {
+-                "className": "InlineSlotsWithThrowDeclaration",
+-                "object": true,
+-                "qualifiedClassName": "InlineSlotsWithThrowDeclaration",
+-                "slots": [
+-                    {
+-                        "access": "public",
+-                        "name": "a",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "b",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "c",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "d",
+-                        "returnType": "void"
+-                    },
+-                    {
+-                        "access": "public",
+-                        "name": "e",
+-                        "returnType": "void"
+-                    }
+-                ],
+-                "superClasses": [
+-                    {
+-                        "access": "public",
+-                        "name": "QObject"
+-                    }
+-                ]
+-            }
+-        ],
+-        "inputFile": "task189996.h",
+-        "outputRevision": 67
+-    },
+     {
+         "classes": [
+             {
+diff --git a/qtbase/tests/auto/tools/moc/moc.pro b/qtbase/tests/auto/tools/moc/moc.pro
+index c324b3a8cd..4aceb78dc0 100644
+--- a/qtbase/tests/auto/tools/moc/moc.pro
++++ b/qtbase/tests/auto/tools/moc/moc.pro
+@@ -15,7 +15,7 @@ cross_compile: DEFINES += MOC_CROSS_COMPILED
+ HEADERS += using-namespaces.h no-keywords.h task87883.h c-comments.h backslash-newlines.h oldstyle-casts.h \
+            slots-with-void-template.h qinvokable.h namespaced-flags.h trigraphs.h \
+            escapes-in-string-literals.h cstyle-enums.h qprivateslots.h gadgetwithnoenums.h \
+-           dir-in-include-path.h single_function_keyword.h task192552.h task189996.h \
++           dir-in-include-path.h single_function_keyword.h task192552.h \
+            task234909.h task240368.h pure-virtual-signals.h cxx11-enums.h \
+            cxx11-final-classes.h \
+            cxx11-explicit-override-control.h \
+diff --git a/qtbase/tests/auto/tools/moc/task189996.h b/qtbase/tests/auto/tools/moc/task189996.h
+deleted file mode 100644
+index f94a051b3a..0000000000
+--- a/qtbase/tests/auto/tools/moc/task189996.h
++++ /dev/null
+@@ -1,47 +0,0 @@
+-/****************************************************************************
+-**
+-** Copyright (C) 2016 The Qt Company Ltd.
+-** Contact: https://www.qt.io/licensing/
+-**
+-** This file is part of the test suite of the Qt Toolkit.
+-**
+-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+-** 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 General Public License Usage
+-** Alternatively, this file may be used under the terms of the GNU
+-** General Public License version 3 as published by the Free Software
+-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+-** 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-3.0.html.
+-**
+-** $QT_END_LICENSE$
+-**
+-****************************************************************************/
+-// inline functions can have throw declarations
+-
+-#ifndef TASK189996_H
+-#define TASK189996_H
+-
+-#include <QObject>
+-
+-class InlineSlotsWithThrowDeclaration : public QObject
+-{
+-    Q_OBJECT
+-
+-public slots:
+-    void a() throw() { }
+-    void b() const throw() { }
+-    void c() throw();
+-    void d() throw(int) { }
+-    void e() const throw(int,double) { }
+-};
+-
+-#endif
+diff --git a/qtbase/tests/auto/tools/moc/tst_moc.cpp b/qtbase/tests/auto/tools/moc/tst_moc.cpp
+index c716aead21..15dd9e41e5 100644
+--- a/qtbase/tests/auto/tools/moc/tst_moc.cpp
++++ b/qtbase/tests/auto/tools/moc/tst_moc.cpp
+@@ -631,7 +631,6 @@ public:
+ private slots:
+     void initTestCase();
+ 
+-    void slotWithException() throw(MyStruct);
+     void dontStripNamespaces();
+     void oldStyleCasts();
+     void warnOnExtraSignalSlotQualifiaction();
+@@ -673,7 +672,6 @@ private slots:
+     void templateGtGt();
+     void qprivateslots();
+     void qprivateproperties();
+-    void inlineSlotsWithThrowDeclaration();
+     void warnOnPropertyWithoutREAD();
+     void constructors();
+     void typenameWithUnsigned();
+@@ -784,12 +782,6 @@ void tst_Moc::initTestCase()
+ #endif
+ }
+ 
+-void tst_Moc::slotWithException() throw(MyStruct)
+-{
+-    // be happy
+-    QVERIFY(true);
+-}
+-
+ void tst_Moc::dontStripNamespaces()
+ {
+     Sender sender;
+@@ -824,7 +816,7 @@ void tst_Moc::oldStyleCasts()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-Wold-style-cast" << "-I" << "."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -894,7 +886,7 @@ void tst_Moc::inputFileNameWithDotsButNoExtension()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-I" << ".."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -1174,7 +1166,7 @@ void tst_Moc::ignoreOptionClashes()
+     QStringList gccArgs;
+     gccArgs << "-c" << "-x" << "c++" << "-I" << ".."
+          << "-I" << qtIncludePath << "-I" << includeDir << "-o" << "/dev/null"
+-         << "-fPIC" << "-std=c++11" <<  "-";
++         << "-fPIC" << "-std=c++1z" <<  "-";
+     proc.start("gcc", gccArgs);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+@@ -1593,21 +1585,6 @@ void tst_Moc::qprivateproperties()
+ 
+ }
+ 
+-#include "task189996.h"
+-
+-void InlineSlotsWithThrowDeclaration::c() throw() {}
+-
+-void tst_Moc::inlineSlotsWithThrowDeclaration()
+-{
+-    InlineSlotsWithThrowDeclaration tst;
+-    const QMetaObject *mobj = tst.metaObject();
+-    QVERIFY(mobj->indexOfSlot("a()") != -1);
+-    QVERIFY(mobj->indexOfSlot("b()") != -1);
+-    QVERIFY(mobj->indexOfSlot("c()") != -1);
+-    QVERIFY(mobj->indexOfSlot("d()") != -1);
+-    QVERIFY(mobj->indexOfSlot("e()") != -1);
+-}
+-
+ void tst_Moc::warnOnPropertyWithoutREAD()
+ {
+ #ifdef MOC_CROSS_COMPILED
+@@ -1869,7 +1846,7 @@ void tst_Moc::notifyError()
+ 
+     QStringList args;
+     args << "-c" << "-x" << "c++" << "-I" << "."
+-         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++11" << "-";
++         << "-I" << qtIncludePath << "-o" << "/dev/null" << "-fPIC" << "-std=c++1z" << "-";
+     proc.start("gcc", args);
+     QVERIFY(proc.waitForStarted());
+     proc.write(mocOut);
+diff --git a/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+index c355ee9665..88c09de8e0 100644
+--- a/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
++++ b/qtbase/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+@@ -251,6 +251,7 @@ private slots:
+     void testResetCachedSizeHint();
+     void statusTips();
+     void testRemovingColumnsViaLayoutChanged();
++    void testModelMovingColumns();
+ 
+ protected:
+     void setupTestData(bool use_reset_model = false);
+@@ -360,6 +361,12 @@ public:
+         endRemoveColumns();
+     }
+ 
++    void moveColumn(int from, int to)
++    {
++        beginMoveColumns(QModelIndex(), from, from, QModelIndex(), to);
++        endMoveColumns();
++    }
++
+     void cleanup()
+     {
+         emit layoutAboutToBeChanged();
+@@ -3627,5 +3634,18 @@ void tst_QHeaderView::testRemovingColumnsViaLayoutChanged()
+     // The main point of this test is that the section-size restoring code didn't go out of bounds.
+ }
+ 
++void tst_QHeaderView::testModelMovingColumns()
++{
++    QtTestModel model(10, 10);
++    QHeaderView hv(Qt::Horizontal);
++    hv.setModel(&model);
++    hv.resizeSections(QHeaderView::ResizeToContents);
++    hv.show();
++
++    QPersistentModelIndex index3 = model.index(0, 3);
++    model.moveColumn(3, 1);
++    QCOMPARE(index3.column(), 1);
++}
++
+ QTEST_MAIN(tst_QHeaderView)
+ #include "tst_qheaderview.moc"
+diff --git a/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+index 761357b252..06bb706074 100644
+--- a/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
++++ b/qtbase/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+@@ -397,6 +397,7 @@ private slots:
+     void checkHeaderMinSize();
+ 
+     void resizeToContents();
++    void resizeToContentsSpans();
+ 
+     void tabFocus();
+     void bigModel();
+@@ -3721,6 +3722,70 @@ void tst_QTableView::resizeToContents()
+ 
+ }
+ 
++
++class SpanModel : public QAbstractTableModel
++{
++public:
++    SpanModel(bool sectionsMoved)
++        : _sectionsMoved(sectionsMoved)
++    {}
++    int columnCount(const QModelIndex & = {}) const override { return 2; }
++    int rowCount(const QModelIndex & = {}) const override { return 1; }
++    QVariant data(const QModelIndex &idx, int role = Qt::DisplayRole) const override
++    {
++        if (role != Qt::DisplayRole)
++            return QVariant();
++        const int col = _sectionsMoved ? 1 - idx.column() : idx.column();
++        if (col == 0)
++            return "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.";
++        return QVariant();
++    }
++private:
++    bool _sectionsMoved;
++};
++
++
++void tst_QTableView::resizeToContentsSpans()
++{
++    SpanModel model1(false);
++    SpanModel model2(true);
++    QTableView view1, view2, view3;
++    view1.setModel(&model1);
++    view2.setModel(&model2);
++    view2.horizontalHeader()->moveSection(0, 1);
++    view3.setModel(&model1);
++
++    view1.setSpan(0, 0, 1, 2);
++    view2.setSpan(0, 1, 1, 2);
++    view1.show();
++    view2.show();
++    view3.show();
++    QVERIFY(QTest::qWaitForWindowExposed(&view1));
++    QVERIFY(QTest::qWaitForWindowExposed(&view2));
++    QVERIFY(QTest::qWaitForWindowExposed(&view3));
++    view1.setColumnWidth(0, 100);
++    view1.setColumnWidth(1, 100);
++    view2.setColumnWidth(0, 100);
++    view2.setColumnWidth(1, 100);
++    view3.setColumnWidth(0, 200);
++
++    view1.resizeRowToContents(0);
++    view2.resizeRowToContents(0);
++    view3.resizeRowToContents(0);
++    QCOMPARE(view1.rowHeight(0), view3.rowHeight(0));
++    QCOMPARE(view2.rowHeight(0), view3.rowHeight(0));
++
++    view3.resizeColumnToContents(0);
++    view3.resizeRowToContents(0);
++    // height should be only 1 text line for easy testing
++    view1.setRowHeight(0, view3.verticalHeader()->sectionSize(0));
++    view2.setRowHeight(0, view3.verticalHeader()->sectionSize(0));
++    view1.resizeColumnToContents(0);
++    view2.resizeColumnToContents(1);
++    QCOMPARE(view1.columnWidth(0), view3.columnWidth(0) - view1.columnWidth(1));
++    QCOMPARE(view2.columnWidth(0), view3.columnWidth(0) - view2.columnWidth(1));
++}
++
+ QT_BEGIN_NAMESPACE
+ extern bool Q_WIDGETS_EXPORT qt_tab_all_widgets(); // qapplication.cpp
+ QT_END_NAMESPACE
+diff --git a/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+index a3b8ef78d8..4955cebd5d 100644
+--- a/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
++++ b/qtbase/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+@@ -1498,7 +1498,7 @@ void tst_QApplication::desktopSettingsAware()
+     environment += QLatin1String("QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM=1");
+     testProcess.setEnvironment(environment);
+ #endif
+-    testProcess.start("desktopsettingsaware_helper");
++    testProcess.start("./desktopsettingsaware_helper");
+     QVERIFY2(testProcess.waitForStarted(),
+              qPrintable(QString::fromLatin1("Cannot start 'desktopsettingsaware_helper': %1").arg(testProcess.errorString())));
+     QVERIFY(testProcess.waitForFinished(10000));
+@@ -2452,7 +2452,7 @@ void tst_QApplication::qtbug_12673()
+ #if QT_CONFIG(process)
+     QProcess testProcess;
+     QStringList arguments;
+-    testProcess.start("modal_helper", arguments);
++    testProcess.start("./modal_helper", arguments);
+     QVERIFY2(testProcess.waitForStarted(),
+              qPrintable(QString::fromLatin1("Cannot start 'modal_helper': %1").arg(testProcess.errorString())));
+     QVERIFY(testProcess.waitForFinished(20000));
+diff --git a/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp b/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
+index eb108a40de..dca5528c1b 100644
+--- a/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qabstractbutton/tst_qabstractbutton.cpp
+@@ -41,6 +41,7 @@
+ 
+ #include <private/qguiapplication_p.h>
+ #include <qpa/qplatformintegration.h>
++#include <qpa/qplatformtheme.h>
+ 
+ class tst_QAbstractButton : public QObject
+ {
+@@ -76,6 +77,8 @@ private slots:
+     void keyNavigation();
+ #endif
+ 
++    void buttonPressKeys();
++
+ protected slots:
+     void onClicked();
+     void onToggled( bool on );
+@@ -269,7 +272,13 @@ void tst_QAbstractButton::setAutoRepeat()
+         QCOMPARE(press_count, click_count);
+         QVERIFY(click_count > 1);
+         break;
+-    case 4:
++    case 4: {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(Qt::Key_Enter)) {
++            QSKIP("platform theme has Key_Enter in ButtonPressKeys");
++        }
+         // check that pressing ENTER has no effect when autorepeat is false
+         testWidget->setDown( false );
+         testWidget->setAutoRepeat( false );
+@@ -286,7 +295,14 @@ void tst_QAbstractButton::setAutoRepeat()
+ 
+         QVERIFY( click_count == 0 );
+         break;
+-    case 5:
++    }
++    case 5: {
++        const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                             ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                             .value<QList<Qt::Key>>();
++        if (buttonPressKeys.contains(Qt::Key_Enter)) {
++            QSKIP("platform theme has Key_Enter in ButtonPressKeys");
++        }
+         // check that pressing ENTER has no effect when autorepeat is true
+         testWidget->setDown( false );
+         testWidget->setAutoRepeat( true );
+@@ -304,6 +320,7 @@ void tst_QAbstractButton::setAutoRepeat()
+ 
+         QVERIFY( click_count == 0 );
+         break;
++    }
+     case 6:
+         // verify autorepeat is off by default.
+         MyButton tmp( 0);
+@@ -651,5 +668,16 @@ void tst_QAbstractButton::keyNavigation()
+ }
+ #endif
+ 
++void tst_QAbstractButton::buttonPressKeys()
++{
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(testWidget, buttonPressKeys[i]);
++        QCOMPARE(click_count, i + 1);
++    }
++}
++
+ QTEST_MAIN(tst_QAbstractButton)
+ #include "tst_qabstractbutton.moc"
+diff --git a/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+index 32437050f5..46b5af6d63 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+@@ -168,6 +168,7 @@ private slots:
+     void checkMenuItemPosWhenStyleSheetIsSet();
+     void checkEmbeddedLineEditWhenStyleSheetIsSet();
+     void propagateStyleChanges();
++    void buttonPressKeys();
+ 
+ private:
+     PlatformInputContext m_platformInputContext;
+@@ -1682,6 +1683,16 @@ void tst_QComboBox::setModel()
+     QCOMPARE(box.rootModelIndex(), rootModelIndex);
+     box.setModel(box.model());
+     QCOMPARE(box.rootModelIndex(), rootModelIndex);
++
++    // check that setting the same model as the completer's doesn't crash
++    QCompleter *completer = new QCompleter(&box);
++    box.setEditable(true);
++    box.setCompleter(completer);
++    auto *listModel = new QStringListModel({ "one", "two" }, completer);
++    completer->setModel(listModel);
++    QCOMPARE(listModel->rowCount(), 2); // make sure it wasn't deleted
++    box.setModel(listModel);
++    QCOMPARE(listModel->rowCount(), 2); // make sure it wasn't deleted
+ }
+ 
+ void tst_QComboBox::setCustomModelAndView()
+@@ -3632,5 +3643,24 @@ void tst_QComboBox::propagateStyleChanges()
+     QVERIFY(frameStyle.inquired);
+ }
+ 
++void tst_QComboBox::buttonPressKeys()
++{
++    QComboBox comboBox;
++    comboBox.setEditable(false);
++    comboBox.addItem(QString::number(1));
++    comboBox.addItem(QString::number(2));
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(&comboBox, buttonPressKeys[i]);
++        // On some platforms, a window will not be immediately visible,
++        // but take some event-loop iterations to complete.
++        // Using QTRY_VERIFY to deal with that.
++        QTRY_VERIFY(comboBox.view()->isVisible());
++        comboBox.hidePopup();
++    }
++}
++
+ QTEST_MAIN(tst_QComboBox)
+ #include "tst_qcombobox.moc"
+diff --git a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
+index be3cfcd104..c228fdfcca 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
++++ b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/qcommandlinkbutton.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qcommandlinkbutton
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qcommandlinkbutton.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
+index 0044d33c66..4cf06296e4 100644
+--- a/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qcommandlinkbutton/tst_qcommandlinkbutton.cpp
+@@ -40,6 +40,9 @@
+ #include <QGridLayout>
+ #include <QPainter>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ class tst_QCommandLinkButton : public QObject
+ {
+     Q_OBJECT
+@@ -223,6 +226,13 @@ void tst_QCommandLinkButton::setAutoRepeat()
+     // check that pressing ENTER has no effect
+     resetCounters();
+     testWidget->setDown( false );
++    // Skip after reset if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
+     testWidget->setAutoRepeat( false );
+     QTest::keyPress( testWidget, Qt::Key_Enter );
+ 
+@@ -255,6 +265,14 @@ void tst_QCommandLinkButton::pressed()
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+ 
++    // Skip if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
++
+     QTest::keyPress( testWidget,Qt::Key_Enter );
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+diff --git a/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro b/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
+index 4a5e76ff65..a235fa1fac 100644
+--- a/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
++++ b/qtbase/tests/auto/widgets/widgets/qgroupbox/qgroupbox.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qgroupbox
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qgroupbox.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp b/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
+index 4fb5d262ca..d8d7562b73 100644
+--- a/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qgroupbox/tst_qgroupbox.cpp
+@@ -35,6 +35,9 @@
+ #include <QRadioButton>
+ #include <QDialog>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ #include "qgroupbox.h"
+ 
+ class tst_QGroupBox : public QObject
+@@ -69,6 +72,7 @@ private slots:
+     void propagateFocus();
+     void task_QTBUG_19170_ignoreMouseReleaseEvent();
+     void task_QTBUG_15519_propagateMouseEvents();
++    void buttonPressKeys();
+ 
+ private:
+     bool checked;
+@@ -610,6 +614,20 @@ void tst_QGroupBox::task_QTBUG_15519_propagateMouseEvents()
+     QCOMPARE(parent.mouseMoved, true);
+ }
+ 
++void tst_QGroupBox::buttonPressKeys()
++{
++    QGroupBox groupBox;
++    groupBox.setCheckable(true);
++    QSignalSpy clickedSpy(&groupBox, &QGroupBox::clicked);
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    for (int i = 0; i < buttonPressKeys.length(); ++i) {
++        QTest::keyClick(&groupBox, buttonPressKeys[i]);
++        QCOMPARE(clickedSpy.length(), i + 1);
++    }
++}
++
+ void tst_QGroupBox::sendMouseMoveEvent(QWidget *widget, const QPoint &localPos)
+ {
+     // Send a MouseMove event without actually moving the pointer
+diff --git a/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro b/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
+index 353ad06ca2..e55f6148f2 100644
+--- a/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
++++ b/qtbase/tests/auto/widgets/widgets/qpushbutton/qpushbutton.pro
+@@ -1,6 +1,6 @@
+ CONFIG += testcase
+ TARGET = tst_qpushbutton
+-QT += widgets testlib
++QT += widgets testlib gui-private
+ SOURCES  += tst_qpushbutton.cpp
+ 
+ 
+diff --git a/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp b/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
+index e818514a79..4043e9326a 100644
+--- a/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
++++ b/qtbase/tests/auto/widgets/widgets/qpushbutton/tst_qpushbutton.cpp
+@@ -41,6 +41,9 @@
+ #include <QStyleFactory>
+ #include <QTabWidget>
+ 
++#include <private/qguiapplication_p.h>
++#include <qpa/qplatformtheme.h>
++
+ class tst_QPushButton : public QObject
+ {
+ Q_OBJECT
+@@ -212,6 +215,13 @@ void tst_QPushButton::autoRepeat()
+     // check that pressing ENTER has no effect
+     resetCounters();
+     testWidget->setDown( false );
++    // Skip after reset if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
+     testWidget->setAutoRepeat( false );
+     QTest::keyPress( testWidget, Qt::Key_Enter );
+ 
+@@ -247,6 +257,14 @@ void tst_QPushButton::pressed()
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+ 
++    // Skip if ButtonPressKeys has Key_Enter
++    const auto buttonPressKeys = QGuiApplicationPrivate::platformTheme()
++                                         ->themeHint(QPlatformTheme::ButtonPressKeys)
++                                         .value<QList<Qt::Key>>();
++    if (buttonPressKeys.contains(Qt::Key_Enter)) {
++        return;
++    }
++
+     QTest::keyPress( testWidget,Qt::Key_Enter );
+     QCOMPARE( press_count, (uint)1 );
+     QCOMPARE( release_count, (uint)1 );
+diff --git a/qtbase/tests/manual/rhi/cubemap_render/buildshader.bat b/qtbase/tests/manual/rhi/cubemap_render/buildshader.bat
+old mode 100755
+new mode 100644
+Submodule qtconnectivity e957d481..056294c0:
+diff --git a/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp b/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
+index e2635fae..a8b8e3b9 100644
+--- a/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
++++ b/qtconnectivity/src/bluetooth/bluez/hcimanager.cpp
+@@ -563,9 +563,11 @@ void HciManager::handleHciAclPacket(const quint8 *data, int size)
+ 
+ void HciManager::handleLeMetaEvent(const quint8 *data)
+ {
+-    // Spec v4.2, Vol 2, part E, 7.7.65ff
++    // Spec v5.3, Vol 4, part E, 7.7.65.*
+     switch (*data) {
+-    case 0x1: {
++    case 0x1: // HCI_LE_Connection_Complete
++    case 0xA: // HCI_LE_Enhanced_Connection_Complete
++    {
+         const quint16 handle = bt_get_le16(data + 2);
+         emit connectionComplete(handle);
+         break;
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp b/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
+index 6a93143b..4a18cfc7 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
+@@ -320,7 +320,10 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_finishSdpScan(QBluetoothServiceD
+             for (const QBluetoothUuid &id : serviceClassUuids) {
+                 if (id.minimumSize() == 16) {
+                     serviceInfo.setServiceUuid(id);
+-                    serviceInfo.setServiceName(QBluetoothServiceDiscoveryAgent::tr("Custom Service"));
++                    if (serviceInfo.serviceName().isEmpty()) {
++                        serviceInfo.setServiceName(
++                                    QBluetoothServiceDiscoveryAgent::tr("Custom Service"));
++                    }
+                     QBluetoothServiceInfo::Sequence modSeq =
+                             serviceInfo.attribute(QBluetoothServiceInfo::ServiceClassIds).value<QBluetoothServiceInfo::Sequence>();
+                     modSeq.removeOne(QVariant::fromValue(id));
+@@ -334,8 +337,10 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_finishSdpScan(QBluetoothServiceD
+                 qCDebug(QT_BT_BLUEZ) << "Discovered services" << discoveredDevices.at(0).address().toString()
+                                      << serviceInfo.serviceName() << serviceInfo.serviceUuid()
+                                      << ">>>" << serviceInfo.serviceClassUuids();
+-
+-                emit q->serviceDiscovered(serviceInfo);
++                // Use queued connection to allow us finish the service looping; the application
++                // might call stop() when it has detected the service-of-interest.
++                QMetaObject::invokeMethod(q, "serviceDiscovered", Qt::QueuedConnection,
++                                          Q_ARG(QBluetoothServiceInfo, serviceInfo));
+             }
+         }
+     }
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp b/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
+index e4d85447..aadd4755 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothsocket.cpp
+@@ -593,7 +593,7 @@ void QBluetoothSocket::setSocketState(QBluetoothSocket::SocketState state)
+ bool QBluetoothSocket::canReadLine() const
+ {
+     Q_D(const QBluetoothSocketBase);
+-    return d->canReadLine();
++    return d->canReadLine() || QIODevice::canReadLine();
+ }
+ 
+ /*!
+diff --git a/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp b/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
+index 084aa958..d6aa17a7 100644
+--- a/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
++++ b/qtconnectivity/src/bluetooth/qbluetoothsocket_bluezdbus.cpp
+@@ -284,6 +284,10 @@ void QBluetoothSocketPrivateBluezDBus::connectToService(
+         return;
+     }
+ 
++    if (service.socketProtocol() != QBluetoothServiceInfo::Protocol::UnknownProtocol)
++        socketType = service.socketProtocol();
++    qCDebug(QT_BT_BLUEZ) << "Socket protocol used:" << socketType;
++
+     connectToService(service.device().address(), targetService, openMode);
+ }
+ 
+diff --git a/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp b/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
+index 05bc1a0f..a7b5ef1f 100644
+--- a/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
++++ b/qtconnectivity/tests/auto/qbluetoothsocket/tst_qbluetoothsocket.cpp
+@@ -142,7 +142,7 @@ void tst_QBluetoothSocket::initTestCase()
+     qDebug() << "Starting discovery";
+ 
+     sda->setUuidFilter(QBluetoothUuid(QString(TEST_SERVICE_UUID)));
+-    sda->start(QBluetoothServiceDiscoveryAgent::MinimalDiscovery);
++    sda->start(QBluetoothServiceDiscoveryAgent::FullDiscovery);
+ 
+     for (int connectTime = MaxConnectTime; !done_discovery && connectTime > 0; connectTime -= 1000)
+         QTest::qWait(1000);
+Submodule qtdeclarative f5701f0d..8defe7bf:
+diff --git a/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h b/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
+index b65b994d6c..15a8cd6878 100644
+--- a/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
++++ b/qtdeclarative/src/qml/common/qqmljsfixedpoolarray_p.h
+@@ -86,7 +86,7 @@ public:
+         if (QTypeInfo<T>::isComplex) {
+             for (int i = 0; i < count; ++i)
+                 new (data + i) T(vector.at(i));
+-        } else {
++        } else if (count) {
+             memcpy(data, static_cast<const void*>(vector.constData()), count * sizeof(T));
+         }
+     }
+diff --git a/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp b/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
+index e57cdd8278..94613598af 100644
+--- a/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
++++ b/qtdeclarative/src/qml/jsruntime/qv4qobjectwrapper.cpp
+@@ -1145,8 +1145,7 @@ void Heap::QObjectWrapper::markObjects(Heap::Base *that, QV4::MarkStack *markSta
+ void QObjectWrapper::destroyObject(bool lastCall)
+ {
+     Heap::QObjectWrapper *h = d();
+-    if (!h->internalClass)
+-        return; // destroyObject already got called
++    Q_ASSERT(h->internalClass);
+ 
+     if (h->object()) {
+         QQmlData *ddata = QQmlData::get(h->object(), false);
+@@ -1176,7 +1175,7 @@ void QObjectWrapper::destroyObject(bool lastCall)
+         }
+     }
+ 
+-    h->~Data();
++    h->destroy();
+ }
+ 
+ 
+diff --git a/qtdeclarative/src/qml/memory/qv4mm.cpp b/qtdeclarative/src/qml/memory/qv4mm.cpp
+index 06caf04e5a..da149a67c4 100644
+--- a/qtdeclarative/src/qml/memory/qv4mm.cpp
++++ b/qtdeclarative/src/qml/memory/qv4mm.cpp
+@@ -981,7 +981,7 @@ void MemoryManager::sweep(bool lastSweep, ClassDestroyStatsCallback classCountPt
+ 
+     if (MultiplyWrappedQObjectMap *multiplyWrappedQObjects = engine->m_multiplyWrappedQObjects) {
+         for (MultiplyWrappedQObjectMap::Iterator it = multiplyWrappedQObjects->begin(); it != multiplyWrappedQObjects->end();) {
+-            if (!it.value().isNullOrUndefined())
++            if (it.value().isNullOrUndefined())
+                 it = multiplyWrappedQObjects->erase(it);
+             else
+                 ++it;
+diff --git a/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp b/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
+index 2079a8ed04..a577cb2351 100644
+--- a/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
++++ b/qtdeclarative/src/qmlmodels/qqmldelegatemodel.cpp
+@@ -389,6 +389,12 @@ void QQmlDelegateModelPrivate::connectToAbstractItemModel()
+                       q,  QQmlDelegateModel, SLOT(_q_rowsRemoved(QModelIndex,int,int)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
+                       q,  QQmlDelegateModel, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsInserted(QModelIndex,int,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsInserted(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsRemoved(QModelIndex,int,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsRemoved(QModelIndex,int,int)));
++    qmlobject_connect(aim, QAbstractItemModel, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)),
++                      q, QQmlDelegateModel, SLOT(_q_columnsMoved(QModelIndex,int,int,QModelIndex,int)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
+                       q, QQmlDelegateModel, SLOT(_q_dataChanged(QModelIndex,QModelIndex,QVector<int>)));
+     qmlobject_connect(aim, QAbstractItemModel, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
+@@ -413,6 +419,12 @@ void QQmlDelegateModelPrivate::disconnectFromAbstractItemModel()
+                         q, SLOT(_q_rowsAboutToBeRemoved(QModelIndex,int,int)));
+     QObject::disconnect(aim, SIGNAL(rowsRemoved(QModelIndex,int,int)),
+                         q, SLOT(_q_rowsRemoved(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsInserted(QModelIndex,int,int)), q,
++                        SLOT(_q_columnsInserted(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsRemoved(QModelIndex,int,int)), q,
++                        SLOT(_q_columnsRemoved(QModelIndex,int,int)));
++    QObject::disconnect(aim, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)), q,
++                        SLOT(_q_columnsMoved(QModelIndex,int,int,QModelIndex,int)));
+     QObject::disconnect(aim, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
+                         q, SLOT(_q_dataChanged(QModelIndex,QModelIndex,QVector<int>)));
+     QObject::disconnect(aim, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
+@@ -1973,6 +1985,38 @@ void QQmlDelegateModel::_q_rowsMoved(
+     }
+ }
+ 
++void QQmlDelegateModel::_q_columnsInserted(const QModelIndex &parent, int begin, int end)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if (parent == d->m_adaptorModel.rootIndex && begin == 0) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
++void QQmlDelegateModel::_q_columnsRemoved(const QModelIndex &parent, int begin, int end)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if (parent == d->m_adaptorModel.rootIndex && begin == 0) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
++void QQmlDelegateModel::_q_columnsMoved(const QModelIndex &parent, int start, int end,
++                                        const QModelIndex &destination, int column)
++{
++    Q_D(QQmlDelegateModel);
++    Q_UNUSED(end);
++    if ((parent == d->m_adaptorModel.rootIndex && start == 0)
++        || (destination == d->m_adaptorModel.rootIndex && column == 0)) {
++        // mark all items as changed
++        _q_itemsChanged(0, d->m_count, QVector<int>());
++    }
++}
++
+ void QQmlDelegateModel::_q_dataChanged(const QModelIndex &begin, const QModelIndex &end, const QVector<int> &roles)
+ {
+     Q_D(QQmlDelegateModel);
+diff --git a/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h b/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
+index 8aab4badca..d140bfbaaf 100644
+--- a/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
++++ b/qtdeclarative/src/qmlmodels/qqmldelegatemodel_p.h
+@@ -152,6 +152,9 @@ private Q_SLOTS:
+     void _q_itemsMoved(int from, int to, int count);
+     void _q_modelReset();
+     void _q_rowsInserted(const QModelIndex &,int,int);
++    void _q_columnsInserted(const QModelIndex &, int, int);
++    void _q_columnsRemoved(const QModelIndex &, int, int);
++    void _q_columnsMoved(const QModelIndex &, int, int, const QModelIndex &, int);
+     void _q_rowsAboutToBeRemoved(const QModelIndex &parent, int begin, int end);
+     void _q_rowsRemoved(const QModelIndex &,int,int);
+     void _q_rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int);
+diff --git a/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp b/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
+index 85719fdc80..78e2ab302c 100644
+--- a/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
++++ b/qtdeclarative/src/quick/accessible/qaccessiblequickitem.cpp
+@@ -46,6 +46,7 @@
+ #include "QtQuick/private/qquicktextinput_p.h"
+ #include "QtQuick/private/qquickaccessibleattached_p.h"
+ #include "QtQuick/qquicktextdocument.h"
++#include "QtQuick/qquickrendercontrol.h"
+ QT_BEGIN_NAMESPACE
+ 
+ #if QT_CONFIG(accessibility)
+@@ -57,7 +58,19 @@ QAccessibleQuickItem::QAccessibleQuickItem(QQuickItem *item)
+ 
+ QWindow *QAccessibleQuickItem::window() const
+ {
+-    return item()->window();
++    QQuickWindow *window = item()->window();
++
++    // For QQuickWidget the above window will be the offscreen QQuickWindow,
++    // which is not a part of the accessibility tree. Detect this case and
++    // return the window for the QQuickWidget instead.
++    if (window && !window->handle()) {
++        if (QQuickRenderControl *renderControl = QQuickWindowPrivate::get(window)->renderControl) {
++            if (QWindow *renderWindow = renderControl->renderWindow(nullptr))
++                return renderWindow;
++        }
++    }
++
++    return window;
+ }
+ 
+ int QAccessibleQuickItem::childCount() const
+@@ -113,19 +126,15 @@ QAccessibleInterface *QAccessibleQuickItem::childAt(int x, int y) const
+ QAccessibleInterface *QAccessibleQuickItem::parent() const
+ {
+     QQuickItem *parent = item()->parentItem();
+-    QQuickWindow *window = item()->window();
+-    QQuickItem *ci = window ? window->contentItem() : nullptr;
++    QQuickWindow *itemWindow = item()->window();
++    QQuickItem *ci = itemWindow ? itemWindow->contentItem() : nullptr;
+     while (parent && !QQuickItemPrivate::get(parent)->isAccessible && parent != ci)
+         parent = parent->parentItem();
+ 
+     if (parent) {
+         if (parent == ci) {
+-            // Jump out to the scene widget if the parent is the root item.
+-            // There are two root items, QQuickWindow::rootItem and
+-            // QQuickView::declarativeRoot. The former is the true root item,
+-            // but is not a part of the accessibility tree. Check if we hit
+-            // it here and return an interface for the scene instead.
+-            return QAccessible::queryAccessibleInterface(window);
++            // Jump out to the window if the parent is the root item
++            return QAccessible::queryAccessibleInterface(window());
+         } else {
+             while (parent && !parent->d_func()->isAccessible)
+                 parent = parent->parentItem();
+@@ -188,7 +197,7 @@ QAccessible::State QAccessibleQuickItem::state() const
+     QRect viewRect_ = viewRect();
+     QRect itemRect = rect();
+ 
+-    if (viewRect_.isNull() || itemRect.isNull() || !item()->window() || !item()->window()->isVisible() ||!item()->isVisible() || qFuzzyIsNull(item()->opacity()))
++    if (viewRect_.isNull() || itemRect.isNull() || !window() || !window()->isVisible() ||!item()->isVisible() || qFuzzyIsNull(item()->opacity()))
+         state.invisible = true;
+     if (!viewRect_.intersects(itemRect))
+         state.offscreen = true;
+@@ -201,6 +210,10 @@ QAccessible::State QAccessibleQuickItem::state() const
+     if (role() == QAccessible::EditableText)
+         if (auto ti = qobject_cast<QQuickTextInput *>(item()))
+             state.passwordEdit = ti->echoMode() != QQuickTextInput::Normal;
++    if (!item()->isEnabled()) {
++        state.focusable = false;
++        state.disabled = true;
++    }
+     return state;
+ }
+ 
+diff --git a/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h b/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
+index 39ffcaf39c..8baa01330c 100644
+--- a/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
++++ b/qtdeclarative/src/quick/accessible/qaccessiblequickview_p.h
+@@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE
+ 
+ #if QT_CONFIG(accessibility)
+ 
+-class QAccessibleQuickWindow : public QAccessibleObject
++class Q_QUICK_EXPORT QAccessibleQuickWindow : public QAccessibleObject
+ {
+ public:
+     QAccessibleQuickWindow(QQuickWindow *object);
+diff --git a/qtdeclarative/src/quick/items/qquickdrag.cpp b/qtdeclarative/src/quick/items/qquickdrag.cpp
+index 8321fcfeed..383078b3b9 100644
+--- a/qtdeclarative/src/quick/items/qquickdrag.cpp
++++ b/qtdeclarative/src/quick/items/qquickdrag.cpp
+@@ -481,7 +481,9 @@ void QQuickDragAttached::setKeys(const QStringList &keys)
+     \qmlattachedproperty stringlist QtQuick::Drag::mimeData
+     \since 5.2
+ 
+-    This property holds a map of mimeData that is used during startDrag.
++    This property holds a map from mime type to data that is used during startDrag.
++    The mime data needs to be a \c string, or an \c ArrayBuffer with the data encoded
++    according to the mime type.
+ */
+ 
+ QVariantMap QQuickDragAttached::mimeData() const
+@@ -766,8 +768,12 @@ Qt::DropAction QQuickDragAttachedPrivate::startDrag(Qt::DropActions supportedAct
+     QDrag *drag = new QDrag(source ? source : q);
+     QMimeData *mimeData = new QMimeData();
+ 
+-    for (auto it = externalMimeData.cbegin(), end = externalMimeData.cend(); it != end; ++it)
+-        mimeData->setData(it.key(), it.value().toString().toUtf8());
++    for (auto it = externalMimeData.cbegin(), end = externalMimeData.cend(); it != end; ++it) {
++        if (static_cast<QMetaType::Type>(it.value().type()) == QMetaType::QByteArray)
++            mimeData->setData(it.key(), it.value().toByteArray());
++        else
++            mimeData->setData(it.key(), it.value().toString().toUtf8());
++    }
+ 
+     drag->setMimeData(mimeData);
+     if (pixmapLoader.isReady()) {
+diff --git a/qtdeclarative/src/quick/items/qquickitem.cpp b/qtdeclarative/src/quick/items/qquickitem.cpp
+index 75f1457816..dec0ae19ae 100644
+--- a/qtdeclarative/src/quick/items/qquickitem.cpp
++++ b/qtdeclarative/src/quick/items/qquickitem.cpp
+@@ -59,6 +59,7 @@
+ #include <QtCore/private/qnumeric_p.h>
+ #include <QtGui/qpa/qplatformtheme.h>
+ #include <QtCore/qloggingcategory.h>
++#include <QtCore/private/qduplicatetracker_p.h>
+ 
+ #include <private/qqmlglobal_p.h>
+ #include <private/qqmlengine_p.h>
+@@ -2326,6 +2327,7 @@ QQuickItem::QQuickItem(QQuickItemPrivate &dd, QQuickItem *parent)
+ QQuickItem::~QQuickItem()
+ {
+     Q_D(QQuickItem);
++    d->inDestructor = true;
+ 
+     if (d->windowRefCount > 1)
+         d->windowRefCount = 1; // Make sure window is set to null in next call to derefWindow().
+@@ -2526,6 +2528,7 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo
+     QQuickItem *current = item;
+     qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: startItem:" << startItem;
+     qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: firstFromItem:" << firstFromItem;
++    QDuplicateTracker<QQuickItem *> cycleDetector;
+     do {
+         qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: current:" << current;
+         qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: from:" << from;
+@@ -2592,7 +2595,10 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo
+         // traversed all of the chain (by compare the [current] item with [startItem])
+         // Since the [startItem] might be promoted to its parent if it is invisible,
+         // we still have to check [current] item with original start item
+-        if ((current == startItem || current == originalStartItem) && from == firstFromItem) {
++        // We might also run into a cycle before we reach firstFromItem again
++        // but note that we have to ignore current if we are meant to skip it
++        if (((current == startItem || current == originalStartItem) && from == firstFromItem) ||
++                (!skip && cycleDetector.hasSeen(current))) {
+             // wrapped around, avoid endless loops
+             if (item == contentItem) {
+                 qCDebug(DBG_FOCUS) << "QQuickItemPrivate::nextPrevItemInTabFocusChain: looped, return contentItem";
+@@ -2689,9 +2695,8 @@ void QQuickItem::setParentItem(QQuickItem *parentItem)
+ 
+         const bool wasVisible = isVisible();
+         op->removeChild(this);
+-        if (wasVisible) {
++        if (wasVisible && !op->inDestructor)
+             emit oldParentItem->visibleChildrenChanged();
+-        }
+     } else if (d->window) {
+         QQuickWindowPrivate::get(d->window)->parentlessItems.remove(this);
+     }
+@@ -2768,8 +2773,9 @@ void QQuickItem::setParentItem(QQuickItem *parentItem)
+ 
+     d->itemChange(ItemParentHasChanged, d->parentItem);
+ 
+-    emit parentChanged(d->parentItem);
+-    if (isVisible() && d->parentItem)
++    if (!d->inDestructor)
++        emit parentChanged(d->parentItem);
++    if (isVisible() && d->parentItem && !QQuickItemPrivate::get(d->parentItem)->inDestructor)
+         emit d->parentItem->visibleChildrenChanged();
+ }
+ 
+@@ -2965,7 +2971,8 @@ void QQuickItemPrivate::removeChild(QQuickItem *child)
+ 
+     itemChange(QQuickItem::ItemChildRemovedChange, child);
+ 
+-    emit q->childrenChanged();
++    if (!inDestructor)
++        emit q->childrenChanged();
+ }
+ 
+ void QQuickItemPrivate::refWindow(QQuickWindow *c)
+@@ -3194,6 +3201,7 @@ QQuickItemPrivate::QQuickItemPrivate()
+     , touchEnabled(false)
+ #endif
+     , hasCursorHandler(false)
++    , inDestructor(false)
+     , dirtyAttributes(0)
+     , nextDirtyItem(nullptr)
+     , prevDirtyItem(nullptr)
+@@ -5120,6 +5128,13 @@ void QQuickItem::componentComplete()
+         d->addToDirtyList();
+         QQuickWindowPrivate::get(d->window)->dirtyItem(this);
+     }
++
++#if QT_CONFIG(accessibility)
++    if (d->isAccessible && d->effectiveVisible) {
++        QAccessibleEvent ev(this, QAccessible::ObjectShow);
++        QAccessible::updateAccessibility(&ev);
++    }
++#endif
+ }
+ 
+ QQuickStateGroup *QQuickItemPrivate::_states()
+@@ -6106,9 +6121,11 @@ bool QQuickItemPrivate::setEffectiveVisibleRecur(bool newEffectiveVisible)
+         QAccessible::updateAccessibility(&ev);
+     }
+ #endif
+-    emit q->visibleChanged();
+-    if (childVisibilityChanged)
+-        emit q->visibleChildrenChanged();
++    if (!inDestructor) {
++        emit q->visibleChanged();
++        if (childVisibilityChanged)
++            emit q->visibleChildrenChanged();
++    }
+ 
+     return true;    // effective visibility DID change
+ }
+@@ -6157,6 +6174,15 @@ void QQuickItemPrivate::setEffectiveEnableRecur(QQuickItem *scope, bool newEffec
+     }
+ 
+     itemChange(QQuickItem::ItemEnabledHasChanged, effectiveEnable);
++#if QT_CONFIG(accessibility)
++    if (isAccessible) {
++        QAccessible::State changedState;
++        changedState.disabled = true;
++        changedState.focusable = true;
++        QAccessibleStateChangeEvent ev(q, changedState);
++        QAccessible::updateAccessibility(&ev);
++    }
++#endif
+     emit q->enabledChanged();
+ }
+ 
+diff --git a/qtdeclarative/src/quick/items/qquickitem_p.h b/qtdeclarative/src/quick/items/qquickitem_p.h
+index 841d91bb40..ade8fb61f2 100644
+--- a/qtdeclarative/src/quick/items/qquickitem_p.h
++++ b/qtdeclarative/src/quick/items/qquickitem_p.h
+@@ -472,6 +472,7 @@ public:
+     bool replayingPressEvent:1;
+     bool touchEnabled:1;
+     bool hasCursorHandler:1;
++    quint32 inDestructor:1; // has entered ~QQuickItem
+ 
+     enum DirtyType {
+         TransformOrigin         = 0x00000001,
+diff --git a/qtdeclarative/src/quick/items/qquickitemview.cpp b/qtdeclarative/src/quick/items/qquickitemview.cpp
+index 010a0152e1..f8ad168a17 100644
+--- a/qtdeclarative/src/quick/items/qquickitemview.cpp
++++ b/qtdeclarative/src/quick/items/qquickitemview.cpp
+@@ -1785,7 +1785,7 @@ void QQuickItemViewPrivate::refill(qreal from, qreal to)
+ 
+     do {
+         bufferPause.stop();
+-        if (currentChanges.hasPendingChanges() || bufferedChanges.hasPendingChanges()) {
++        if (currentChanges.hasPendingChanges() || bufferedChanges.hasPendingChanges() || currentChanges.active) {
+             currentChanges.reset();
+             bufferedChanges.reset();
+             releaseVisibleItems(reusableFlag);
+diff --git a/qtdeclarative/src/quick/items/qquickmousearea_p_p.h b/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
+index fba383e268..0d63618622 100644
+--- a/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
++++ b/qtdeclarative/src/quick/items/qquickmousearea_p_p.h
+@@ -61,7 +61,6 @@ QT_BEGIN_NAMESPACE
+ 
+ class QQuickMouseEvent;
+ class QQuickMouseArea;
+-class QQuickPointerMask;
+ class QQuickMouseAreaPrivate : public QQuickItemPrivate
+ {
+     Q_DECLARE_PUBLIC(QQuickMouseArea)
+@@ -100,7 +99,6 @@ public:
+ #if QT_CONFIG(quick_draganddrop)
+     QQuickDrag *drag;
+ #endif
+-    QPointer<QQuickPointerMask> mask;
+     QPointF startScene;
+     QPointF targetStartPos;
+     QPointF lastPos;
+diff --git a/qtdeclarative/src/quick/items/qquicktext.cpp b/qtdeclarative/src/quick/items/qquicktext.cpp
+index 6230186933..e823ca1095 100644
+--- a/qtdeclarative/src/quick/items/qquicktext.cpp
++++ b/qtdeclarative/src/quick/items/qquicktext.cpp
+@@ -2168,7 +2168,7 @@ void QQuickText::resetMaximumLineCount()
+     <img src="" align="top,middle,bottom" width="" height=""> - inline images
+     <ol type="">, <ul type=""> and <li> - ordered and unordered lists
+     <pre></pre> - preformatted
+-    &gt; &lt; &amp;
++    &gt; &lt; &amp; &quot; &nbsp; &apos;
+     \endcode
+ 
+     \c Text.StyledText parser is strict, requiring tags to be correctly nested.
+diff --git a/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp b/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
+index eb4db0f85e..2325a2665b 100644
+--- a/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
++++ b/qtdeclarative/src/quick/scenegraph/qsgrhidistancefieldglyphcache.cpp
+@@ -446,7 +446,7 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+         const char *textureRecord = allocatorData;
+         for (int i = 0; i < textureCount; ++i, textureRecord += Qtdf::TextureRecordSize) {
+-            if (textureRecord + Qtdf::TextureRecordSize > qtdfTableEnd) {
++            if (qtdfTableEnd - textureRecord < Qtdf::TextureRecordSize) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+@@ -462,7 +462,7 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+         const char *glyphRecord = textureRecord;
+         for (quint32 i = 0; i < glyphCount; ++i, glyphRecord += Qtdf::GlyphRecordSize) {
+-            if (glyphRecord + Qtdf::GlyphRecordSize > qtdfTableEnd) {
++            if (qtdfTableEnd - glyphRecord < Qtdf:: GlyphRecordSize) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+@@ -512,8 +512,8 @@ bool QSGRhiDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+ 
+             int width = texInfo->allocatedArea.width();
+             int height = texInfo->allocatedArea.height();
+-            qint64 size = width * height;
+-            if (reinterpret_cast<const char *>(textureData + size) > qtdfTableEnd) {
++            qint64 size = qint64(width) * height;
++            if (qtdfTableEnd - reinterpret_cast<const char *>(textureData) < size) {
+                 qWarning("qtdf table too small in font '%s'.",
+                          qPrintable(font.familyName()));
+                 return false;
+diff --git a/qtdeclarative/src/quick/util/qquickstyledtext.cpp b/qtdeclarative/src/quick/util/qquickstyledtext.cpp
+index d531fc9205..a25af90414 100644
+--- a/qtdeclarative/src/quick/util/qquickstyledtext.cpp
++++ b/qtdeclarative/src/quick/util/qquickstyledtext.cpp
+@@ -564,6 +564,8 @@ void QQuickStyledTextPrivate::parseEntity(const QChar *&ch, const QString &textI
+                 textOut += QChar(60);
+             else if (entity == QLatin1String("amp"))
+                 textOut += QChar(38);
++            else if (entity == QLatin1String("apos"))
++                textOut += QChar(39);
+             else if (entity == QLatin1String("quot"))
+                 textOut += QChar(34);
+             else if (entity == QLatin1String("nbsp"))
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp
+new file mode 100644
+index 0000000000..8a1c901880
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget.cpp
+@@ -0,0 +1,110 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include "qaccessiblequickwidget_p.h"
++
++#include "qquickwidget_p.h"
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleQuickWidget::QAccessibleQuickWidget(QQuickWidget* widget)
++: QAccessibleWidget(widget)
++, m_accessibleWindow(QQuickWidgetPrivate::get(widget)->offscreenWindow)
++{
++    // NOTE: m_accessibleWindow is a QAccessibleQuickWindow, and not a
++    // QAccessibleQuickWidgetOffscreenWindow (defined below). This means
++    // it will return the Quick item child interfaces, which is what's needed here
++    // (unlike QAccessibleQuickWidgetOffscreenWindow, which will report 0 children).
++}
++
++QAccessibleInterface *QAccessibleQuickWidget::child(int index) const
++{
++    return m_accessibleWindow.child(index);
++}
++
++int QAccessibleQuickWidget::childCount() const
++{
++    return m_accessibleWindow.childCount();
++}
++
++int QAccessibleQuickWidget::indexOfChild(const QAccessibleInterface *iface) const
++{
++    return m_accessibleWindow.indexOfChild(iface);
++}
++
++QAccessibleInterface *QAccessibleQuickWidget::childAt(int x, int y) const
++{
++    return m_accessibleWindow.childAt(x, y);
++}
++
++QAccessibleQuickWidgetOffscreenWindow::QAccessibleQuickWidgetOffscreenWindow(QQuickWindow *window)
++:QAccessibleQuickWindow(window)
++{
++
++}
++
++QAccessibleInterface *QAccessibleQuickWidgetOffscreenWindow::child(int index) const
++{
++    Q_UNUSED(index);
++    return nullptr;
++}
++
++int QAccessibleQuickWidgetOffscreenWindow::childCount() const
++{
++    return 0;
++}
++
++int QAccessibleQuickWidgetOffscreenWindow::indexOfChild(const QAccessibleInterface *iface) const
++{
++    Q_UNUSED(iface);
++    return -1;
++}
++
++QAccessibleInterface *QAccessibleQuickWidgetOffscreenWindow::QAccessibleQuickWidgetOffscreenWindow::childAt(int x, int y) const
++{
++    Q_UNUSED(x);
++    Q_UNUSED(y);
++    return nullptr;
++}
++
++#endif // accessibility
++
++QT_END_NAMESPACE
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h
+new file mode 100644
+index 0000000000..7c2ab930e0
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidget_p.h
+@@ -0,0 +1,95 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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 QACCESSIBLEQUICKWIDGET_H
++#define QACCESSIBLEQUICKWIDGET_H
++
++//
++//  W A R N I N G
++//  -------------
++//
++// This file is not part of the Qt API.  It exists purely as an
++// implementation detail.  This header file may change from version to
++// version without notice, or even be removed.
++//
++// We mean it.
++//
++
++#include "qquickwidget.h"
++#include <QtWidgets/qaccessiblewidget.h>
++
++#include <private/qaccessiblequickview_p.h>
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++// These classes implement the QQuickWiget accessibility switcharoo,
++// where the child items of the QQuickWidgetOffscreenWindow are reported
++// as child accessible interfaces of the QAccessibleQuickWidget.
++class QAccessibleQuickWidget: public QAccessibleWidget
++{
++public:
++    QAccessibleQuickWidget(QQuickWidget* widget);
++
++    QAccessibleInterface *child(int index) const override;
++    int childCount() const override;
++    int indexOfChild(const QAccessibleInterface *iface) const override;
++    QAccessibleInterface *childAt(int x, int y) const override;
++
++private:
++    QAccessibleQuickWindow m_accessibleWindow;
++    Q_DISABLE_COPY(QAccessibleQuickWidget)
++};
++
++class QAccessibleQuickWidgetOffscreenWindow: public QAccessibleQuickWindow
++{
++public:
++    QAccessibleQuickWidgetOffscreenWindow(QQuickWindow *window);
++    QAccessibleInterface *child(int index) const override;
++    int childCount() const override;
++    int indexOfChild(const QAccessibleInterface *iface) const override;
++    QAccessibleInterface *childAt(int x, int y) const override;
++};
++
++#endif // accessibility
++
++QT_END_NAMESPACE
++
++#endif
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp
+new file mode 100644
+index 0000000000..7ba88a1769
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory.cpp
+@@ -0,0 +1,60 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include "qaccessiblequickwidgetfactory_p.h"
++#include "qaccessiblequickwidget_p.h"
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleInterface *qAccessibleQuickWidgetFactory(const QString &classname, QObject *object)
++{
++    if (classname == QLatin1String("QQuickWidget")) {
++        return new QAccessibleQuickWidget(qobject_cast<QQuickWidget *>(object));
++    } else if (classname == QLatin1String("QQuickWidgetOffscreenWindow")) {
++        return new QAccessibleQuickWidgetOffscreenWindow(qobject_cast<QQuickWindow *>(object));
++    }
++    return 0;
++}
++
++#endif // accessibility
++
++QT_END_NAMESPACE
++
+diff --git a/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h
+new file mode 100644
+index 0000000000..8c63b09f81
+--- /dev/null
++++ b/qtdeclarative/src/quickwidgets/qaccessiblequickwidgetfactory_p.h
+@@ -0,0 +1,66 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the QtQuick 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$
++**
++****************************************************************************/
++
++#include <QtGui/qaccessible.h>
++
++#ifndef QACCESSIBLEQUICKWIDGETFACTORY_H
++#define QACCESSIBLEQUICKWIDGETFACTORY_H
++
++//
++//  W A R N I N G
++//  -------------
++//
++// This file is not part of the Qt API.  It exists purely as an
++// implementation detail.  This header file may change from version to
++// version without notice, or even be removed.
++//
++// We mean it.
++//
++
++QT_BEGIN_NAMESPACE
++
++#if QT_CONFIG(accessibility)
++
++QAccessibleInterface *qAccessibleQuickWidgetFactory(const QString &classname, QObject *object);
++
++#endif
++
++QT_END_NAMESPACE
++
++#endif
+diff --git a/qtdeclarative/src/quickwidgets/qquickwidget.cpp b/qtdeclarative/src/quickwidgets/qquickwidget.cpp
+index 39780f8de3..9c97b43518 100644
+--- a/qtdeclarative/src/quickwidgets/qquickwidget.cpp
++++ b/qtdeclarative/src/quickwidgets/qquickwidget.cpp
+@@ -39,6 +39,7 @@
+ 
+ #include "qquickwidget.h"
+ #include "qquickwidget_p.h"
++#include "qaccessiblequickwidgetfactory_p.h"
+ 
+ #include "private/qquickwindow_p.h"
+ #include "private/qquickitem_p.h"
+@@ -75,9 +76,16 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
++QQuickWidgetOffscreenWindow::QQuickWidgetOffscreenWindow(QQuickWindowPrivate &dd, QQuickRenderControl *control)
++:QQuickWindow(dd, control)
++{
++    setTitle(QString::fromLatin1("Offscreen"));
++    setObjectName(QString::fromLatin1("QQuickOffScreenWindow"));
++}
++
+ // override setVisble to prevent accidental offscreen window being created
+ // by base class.
+-class QQuickOffcreenWindowPrivate: public QQuickWindowPrivate {
++class QQuickWidgetOffscreenWindowPrivate: public QQuickWindowPrivate {
+ public:
+     void setVisible(bool visible) override {
+         Q_Q(QWindow);
+@@ -105,9 +113,8 @@ void QQuickWidgetPrivate::init(QQmlEngine* e)
+     Q_Q(QQuickWidget);
+ 
+     renderControl = new QQuickWidgetRenderControl(q);
+-    offscreenWindow = new QQuickWindow(*new QQuickOffcreenWindowPrivate(),renderControl);
+-    offscreenWindow->setTitle(QString::fromLatin1("Offscreen"));
+-    offscreenWindow->setObjectName(QString::fromLatin1("QQuickOffScreenWindow"));
++    offscreenWindow = new QQuickWidgetOffscreenWindow(*new QQuickWidgetOffscreenWindowPrivate(), renderControl);
++    offscreenWindow->setScreen(q->screen());
+     // Do not call create() on offscreenWindow.
+ 
+     // Check if the Software Adaptation is being used
+@@ -138,6 +145,10 @@ void QQuickWidgetPrivate::init(QQmlEngine* e)
+     QWidget::connect(offscreenWindow, &QQuickWindow::focusObjectChanged, q, &QQuickWidget::propagateFocusObjectChanged);
+     QObject::connect(renderControl, SIGNAL(renderRequested()), q, SLOT(triggerUpdate()));
+     QObject::connect(renderControl, SIGNAL(sceneChanged()), q, SLOT(triggerUpdate()));
++
++#if QT_CONFIG(accessibility)
++    QAccessible::installFactory(&qAccessibleQuickWidgetFactory);
++#endif
+ }
+ 
+ void QQuickWidgetPrivate::ensureEngine() const
+@@ -901,9 +912,7 @@ void QQuickWidgetPrivate::createContext()
+ 
+         context = new QOpenGLContext;
+         context->setFormat(offscreenWindow->requestedFormat());
+-        const QWindow *win = q->window()->windowHandle();
+-        if (win && win->screen())
+-            context->setScreen(win->screen());
++        context->setScreen(q->screen());
+         QOpenGLContext *shareContext = qt_gl_global_share_context();
+         if (!shareContext)
+             shareContext = QWidgetPrivate::get(q->window())->shareContext();
+@@ -1520,19 +1529,16 @@ bool QQuickWidget::event(QEvent *e)
+         d->handleWindowChange();
+         break;
+ 
+-    case QEvent::ScreenChangeInternal:
+-        if (QWindow *window = this->window()->windowHandle()) {
+-            QScreen *newScreen = window->screen();
+-
+-            if (d->offscreenWindow)
+-                d->offscreenWindow->setScreen(newScreen);
+-            if (d->offscreenSurface)
+-                d->offscreenSurface->setScreen(newScreen);
++    case QEvent::ScreenChangeInternal: {
++        QScreen *newScreen = screen();
++        if (d->offscreenWindow)
++            d->offscreenWindow->setScreen(newScreen);
++        if (d->offscreenSurface)
++            d->offscreenSurface->setScreen(newScreen);
+ #if QT_CONFIG(opengl)
+-            if (d->context)
+-                d->context->setScreen(newScreen);
++        if (d->context)
++            d->context->setScreen(newScreen);
+ #endif
+-        }
+ 
+         if (d->useSoftwareRenderer
+ #if QT_CONFIG(opengl)
+@@ -1545,7 +1551,7 @@ bool QQuickWidget::event(QEvent *e)
+             d->render(true);
+         }
+         break;
+-
++    }
+     case QEvent::Show:
+     case QEvent::Move:
+         d->updatePosition();
+diff --git a/qtdeclarative/src/quickwidgets/qquickwidget_p.h b/qtdeclarative/src/quickwidgets/qquickwidget_p.h
+index 881f7f9220..1a946bcc71 100644
+--- a/qtdeclarative/src/quickwidgets/qquickwidget_p.h
++++ b/qtdeclarative/src/quickwidgets/qquickwidget_p.h
+@@ -148,6 +148,14 @@ public:
+     bool forceFullUpdate;
+ };
+ 
++class QQuickWidgetOffscreenWindow: public QQuickWindow
++{
++    Q_OBJECT
++
++public:
++    QQuickWidgetOffscreenWindow(QQuickWindowPrivate &dd, QQuickRenderControl *control);
++};
++
+ QT_END_NAMESPACE
+ 
+ #endif // QQuickWidget_P_H
+diff --git a/qtdeclarative/src/quickwidgets/quickwidgets.pro b/qtdeclarative/src/quickwidgets/quickwidgets.pro
+index 2438e577ae..85d156b8a3 100644
+--- a/qtdeclarative/src/quickwidgets/quickwidgets.pro
++++ b/qtdeclarative/src/quickwidgets/quickwidgets.pro
+@@ -7,9 +7,13 @@ DEFINES   += QT_NO_URL_CAST_FROM_STRING QT_NO_INTEGER_EVENT_COORDINATES QT_NO_FO
+ HEADERS += \
+     qquickwidget.h \
+     qquickwidget_p.h \
+-    qtquickwidgetsglobal.h
++    qtquickwidgetsglobal.h \
++    qaccessiblequickwidget_p.h \
++    qaccessiblequickwidgetfactory_p.h
+ 
+ SOURCES += \
+-    qquickwidget.cpp
++    qquickwidget.cpp \
++    qaccessiblequickwidget.cpp \
++    qaccessiblequickwidgetfactory.cpp
+ 
+ load(qt_module)
+diff --git a/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+index 3b7d74df63..b75bf820d5 100644
+--- a/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
++++ b/qtdeclarative/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+@@ -102,6 +102,7 @@ private slots:
+     void valueConversion_RegularExpression();
+     void castWithMultipleInheritance();
+     void collectGarbage();
++    void collectGarbageNestedWrappersTwoEngines();
+     void gcWithNestedDataStructure();
+     void stacktrace();
+     void numberParsing_data();
+@@ -1809,6 +1810,44 @@ void tst_QJSEngine::collectGarbage()
+     QVERIFY(ptr.isNull());
+ }
+ 
++class TestObjectContainer : public QObject
++{
++    Q_OBJECT
++    Q_PROPERTY(QObject *dummy MEMBER m_dummy CONSTANT)
++
++public:
++    TestObjectContainer() : m_dummy(new QObject(this)) {}
++
++private:
++    QObject *m_dummy;
++};
++
++void tst_QJSEngine::collectGarbageNestedWrappersTwoEngines()
++{
++    QJSEngine engine1;
++    QJSEngine engine2;
++
++    TestObjectContainer container;
++    QQmlEngine::setObjectOwnership(&container, QQmlEngine::CppOwnership);
++
++    engine1.globalObject().setProperty("foobar", engine1.newQObject(&container));
++    engine2.globalObject().setProperty("foobar", engine2.newQObject(&container));
++
++    engine1.evaluate("foobar.dummy.baz = 42");
++    engine2.evaluate("foobar.dummy.baz = 43");
++
++    QCOMPARE(engine1.evaluate("foobar.dummy.baz").toInt(), 42);
++    QCOMPARE(engine2.evaluate("foobar.dummy.baz").toInt(), 43);
++
++    engine1.collectGarbage();
++    engine2.collectGarbage();
++
++    // The GC should not collect dummy object wrappers neither in engine1 nor engine2, we
++    // verify that by checking whether the baz property still has its previous value.
++    QCOMPARE(engine1.evaluate("foobar.dummy.baz").toInt(), 42);
++    QCOMPARE(engine2.evaluate("foobar.dummy.baz").toInt(), 43);
++}
++
+ void tst_QJSEngine::gcWithNestedDataStructure()
+ {
+     // The GC must be able to traverse deeply nested objects, otherwise this
+diff --git a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml
+new file mode 100644
+index 0000000000..206133bb39
+--- /dev/null
++++ b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/data/redrawUponColumnChange.qml
+@@ -0,0 +1,11 @@
++import QtQuick 2.8
++
++ListView {
++    id: root
++    width: 200
++    height: 200
++
++    delegate: Text {
++        text: display
++    }
++}
+diff --git a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
+index 35f1e2c94d..1722447830 100644
+--- a/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
++++ b/qtdeclarative/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
+@@ -27,6 +27,8 @@
+ ****************************************************************************/
+ 
+ #include <QtTest/qtest.h>
++#include <QtCore/QConcatenateTablesProxyModel>
++#include <QtGui/QStandardItemModel>
+ #include <QtQml/qqmlcomponent.h>
+ #include <QtQmlModels/private/qqmldelegatemodel_p.h>
+ #include <QtQuick/qquickview.h>
+@@ -47,6 +49,7 @@ private slots:
+     void filterOnGroup_removeWhenCompleted();
+     void qtbug_86017();
+     void contextAccessedByHandler();
++    void redrawUponColumnChange();
+ };
+ 
+ class AbstractItemModel : public QAbstractItemModel
+@@ -186,6 +189,30 @@ void tst_QQmlDelegateModel::contextAccessedByHandler()
+     QVERIFY(root->property("works").toBool());
+ }
+ 
++void tst_QQmlDelegateModel::redrawUponColumnChange()
++{
++    QStandardItemModel m1;
++    m1.appendRow({
++            new QStandardItem("Banana"),
++            new QStandardItem("Coconut"),
++    });
++
++    QQuickView view(testFileUrl("redrawUponColumnChange.qml"));
++    QCOMPARE(view.status(), QQuickView::Ready);
++    view.show();
++    QQuickItem *root = view.rootObject();
++    root->setProperty("model", QVariant::fromValue<QObject *>(&m1));
++
++    QObject *item = root->property("currentItem").value<QObject *>();
++    QVERIFY(item);
++    QCOMPARE(item->property("text").toString(), "Banana");
++
++    QVERIFY(root);
++    m1.removeColumn(0);
++
++    QCOMPARE(item->property("text").toString(), "Coconut");
++}
++
+ QTEST_MAIN(tst_QQmlDelegateModel)
+ 
+ #include "tst_qqmldelegatemodel.moc"
+diff --git a/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp b/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
+index 5d635aa63b..824fd89e5b 100644
+--- a/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
++++ b/qtdeclarative/tests/auto/qml/qv4mm/tst_qv4mm.cpp
+@@ -76,10 +76,10 @@ void tst_qv4mm::multiWrappedQObjects()
+         QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 1);
+         QCOMPARE(engine2.memoryManager->m_pendingFreedObjectWrapperValue.size(), 0);
+ 
+-        // Moves the additional WeakValue from m_multiplyWrappedQObjects to
+-        // m_pendingFreedObjectWrapperValue. It's still alive after all.
++        // The additional WeakValue from m_multiplyWrappedQObjects hasn't been moved
++        // to m_pendingFreedObjectWrapperValue yet. It's still alive after all.
+         engine1.memoryManager->runGC();
+-        QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 2);
++        QCOMPARE(engine1.memoryManager->m_pendingFreedObjectWrapperValue.size(), 1);
+ 
+         // engine2 doesn't own the object as engine1 was the first to wrap it above.
+         // Therefore, no effect here.
+diff --git a/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml b/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml
+new file mode 100644
+index 0000000000..889e480f3b
+--- /dev/null
++++ b/qtdeclarative/tests/auto/quick/qquickitem2/data/activeFocusOnTab_infiniteLoop3.qml
+@@ -0,0 +1,13 @@
++import QtQuick 2.6
++
++Item {
++    visible: true
++    Item {
++        visible: false
++        Item {
++            objectName: "hiddenChild"
++            activeFocusOnTab: true
++            focus: true
++        }
++    }
++}
+diff --git a/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp b/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+index c8f251dbe1..c8ef36ee68 100644
+--- a/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
++++ b/qtdeclarative/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+@@ -67,6 +67,7 @@ private slots:
+     void activeFocusOnTab10();
+     void activeFocusOnTab_infiniteLoop_data();
+     void activeFocusOnTab_infiniteLoop();
++    void activeFocusOnTab_infiniteLoopControls();
+ 
+     void nextItemInFocusChain();
+     void nextItemInFocusChain2();
+@@ -1057,6 +1058,17 @@ void tst_QQuickItem::activeFocusOnTab_infiniteLoop()
+     QCOMPARE(item, window->rootObject());
+ }
+ 
++
++void tst_QQuickItem::activeFocusOnTab_infiniteLoopControls()
++{
++    auto source = testFileUrl("activeFocusOnTab_infiniteLoop3.qml");
++    QScopedPointer<QQuickView>window(new QQuickView());
++    window->setSource(source);
++    window->show();
++    QVERIFY(window->errors().isEmpty());
++    QTest::keyClick(window.get(), Qt::Key_Tab); // should not hang
++}
++
+ void tst_QQuickItem::nextItemInFocusChain()
+ {
+     if (!qt_tab_all_widgets())
+Submodule qtdoc c0c7bf07...79d6ef69:
+Submodule qtimageformats 2dcf2899..abe44c0f:
+diff --git a/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp b/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
+index dde783c..1bf9074 100644
+--- a/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/icns/qicnshandler.cpp
+@@ -462,8 +462,12 @@ static bool parseIconEntryInfo(ICNSEntry &icon)
+     if (isIconCompressed(icon))
+         return true;
+     // Icon depth:
+-    if (!depth.isEmpty())
+-        icon.depth = ICNSEntry::Depth(depth.toUInt());
++    if (!depth.isEmpty()) {
++        const uint depthUInt = depth.toUInt();
++        if (depthUInt > 32)
++            return false;
++        icon.depth = ICNSEntry::Depth(depthUInt);
++    }
+     // Try mono if depth not found
+     if (icon.depth == ICNSEntry::DepthUnknown)
+         icon.depth = ICNSEntry::DepthMono;
+@@ -515,6 +519,9 @@ static bool parseIconEntryInfo(ICNSEntry &icon)
+         }
+         icon.height = icon.width;
+     }
++    // Sanity check
++    if (icon.width == 0 || icon.width > 4096)
++        return false;
+     return true;
+ }
+ 
+@@ -685,7 +692,7 @@ bool QICNSHandler::canRead() const
+ bool QICNSHandler::read(QImage *outImage)
+ {
+     QImage img;
+-    if (!ensureScanned()) {
++    if (!ensureScanned() || m_currentIconIndex >= m_icons.size()) {
+         qWarning("QICNSHandler::read(): The device wasn't parsed properly!");
+         return false;
+     }
+@@ -892,7 +899,7 @@ bool QICNSHandler::scanDevice()
+             return false;
+ 
+         const qint64 blockDataOffset = device()->pos();
+-        if (!isBlockHeaderValid(blockHeader)) {
++        if (!isBlockHeaderValid(blockHeader, ICNSBlockHeaderSize + filelength - blockDataOffset)) {
+             qWarning("QICNSHandler::scanDevice(): Failed, bad header at pos %s. OSType \"%s\", length %u",
+                      QByteArray::number(blockDataOffset).constData(),
+                      nameFromOSType(blockHeader.ostype).constData(), blockHeader.length);
+@@ -927,11 +934,14 @@ bool QICNSHandler::scanDevice()
+         case ICNSBlockHeader::TypeOdrp:
+             // Icns container seems to have an embedded icon variant container
+             // Let's start a scan for entries
+-            while (device()->pos() < nextBlockOffset) {
++            while (!stream.atEnd() && device()->pos() < nextBlockOffset) {
+                 ICNSBlockHeader icon;
+                 stream >> icon;
++                if (stream.status() != QDataStream::Ok)
++                    return false;
+                 // Check for incorrect variant entry header and stop scan
+-                if (!isBlockHeaderValid(icon, blockDataLength))
++                quint64 remaining = blockDataLength - (device()->pos() - blockDataOffset);
++                if (!isBlockHeaderValid(icon, ICNSBlockHeaderSize + remaining))
+                     break;
+                 if (!addEntry(icon, device()->pos(), blockHeader.ostype))
+                     return false;
+@@ -1003,7 +1013,7 @@ bool QICNSHandler::scanDevice()
+             break;
+         }
+     }
+-    return true;
++    return (m_icons.size() > 0);
+ }
+ 
+ const ICNSEntry &QICNSHandler::getIconMask(const ICNSEntry &icon) const
+diff --git a/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp b/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
+index 5082023..cb34374 100644
+--- a/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
++++ b/qtimageformats/src/plugins/imageformats/jp2/qjp2handler.cpp
+@@ -43,6 +43,7 @@
+ #include "qimage.h"
+ #include "qvariant.h"
+ #include "qcolor.h"
++#include "qimagereader.h"
+ 
+ #include <jasper/jasper.h>
+ #include <math.h> // for pow
+@@ -333,16 +334,46 @@ private:
+ Jpeg2000JasperReader::Jpeg2000JasperReader(QIODevice *iod, SubFormat format)
+     : jasperOk(true), ioDevice(iod), format(format), hasAlpha(false)
+ {
++#if JAS_VERSION_MAJOR < 3
+     if (jas_init()) {
+         jasperOk = false;
+         qDebug("Jasper Library initialization failed");
+     }
++#else
++    jas_conf_clear();
++#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
++    jas_conf_set_max_mem_usage(QImageReader::allocationLimit() * 1024 * 1024);
++#else
++    // 128MB seems to be enough.
++    jas_conf_set_max_mem_usage(128 * 1024 * 1024);
++#endif
++    if (jas_init_library()) {
++        jasperOk = false;
++        qDebug("Jasper library initialization failed");
++    }
++    if (jas_init_thread()) {
++        jas_cleanup_library();
++        jasperOk = false;
++        qDebug("Jasper thread initialization failed");
++    }
++#endif
+ }
+ 
+ Jpeg2000JasperReader::~Jpeg2000JasperReader()
+ {
++#if JAS_VERSION_MAJOR < 3
+     if (jasperOk)
+         jas_cleanup();
++#else
++    if (jasperOk) {
++        if (jas_cleanup_thread()) {
++            qDebug("Jasper thread cleanup failed");
++        }
++        if (jas_cleanup_library()) {
++            qDebug("Jasper library cleanup failed");
++        }
++    }
++#endif
+ }
+ 
+ /*! \internal
+@@ -857,7 +888,7 @@ bool Jpeg2000JasperReader::write(const QImage &image, int quality)
+     }
+ 
+     // Open an empty jasper stream that grows automatically
+-    jas_stream_t * memory_stream = jas_stream_memopen(0, -1);
++    jas_stream_t * memory_stream = jas_stream_memopen(0, 0);
+ 
+     // Jasper wants a non-const string.
+     char *str = qstrdup(jasperFormatString.toLatin1().constData());
+diff --git a/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp b/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
+index 1386750..ac8956c 100644
+--- a/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
+@@ -361,6 +361,8 @@ bool QTiffHandler::read(QImage *image)
+     }
+ 
+     TIFF *const tiff = d->tiff;
++    if (TIFFIsTiled(tiff) && TIFFTileSize64(tiff) > uint64_t(image->sizeInBytes())) // Corrupt image
++        return false;
+     const quint32 width = d->size.width();
+     const quint32 height = d->size.height();
+ 
+diff --git a/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp b/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
+index 82d38cb..d02eb05 100644
+--- a/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
++++ b/qtimageformats/src/plugins/imageformats/webp/qwebphandler.cpp
+@@ -45,6 +45,7 @@
+ #include <qdebug.h>
+ #include <qpainter.h>
+ #include <qvariant.h>
++#include <QtEndian>
+ 
+ static const int riffHeaderSize = 12; // RIFF_HEADER_SIZE from webp/format_constants.h
+ 
+@@ -102,21 +103,23 @@ bool QWebpHandler::ensureScanned() const
+ 
+     m_scanState = ScanError;
+ 
+-    if (device()->isSequential()) {
+-        qWarning() << "Sequential devices are not supported";
++    QWebpHandler *that = const_cast<QWebpHandler *>(this);
++    const int headerBytesNeeded = sizeof(WebPBitstreamFeatures);
++    QByteArray header = device()->peek(headerBytesNeeded);
++    if (header.size() < headerBytesNeeded)
+         return false;
+-    }
+ 
+-    qint64 oldPos = device()->pos();
+-    device()->seek(0);
+-
+-    QWebpHandler *that = const_cast<QWebpHandler *>(this);
+-    QByteArray header = device()->peek(sizeof(WebPBitstreamFeatures));
++    // We do no random access during decoding, just a readAll() of the whole image file. So if
++    // if it is all available already, we can accept a sequential device. The riff header contains
++    // the file size minus 8 bytes header
++    qint64 byteSize = qFromLittleEndian<quint32>(header.constData() + 4);
++    if (device()->isSequential() && device()->bytesAvailable() < byteSize + 8) {
++        qWarning() << "QWebpHandler: Insufficient data available in sequential device";
++        return false;
++    }
+     if (WebPGetFeatures((const uint8_t*)header.constData(), header.size(), &(that->m_features)) == VP8_STATUS_OK) {
+         if (m_features.has_animation) {
+             // For animation, we have to read and scan whole file to determine loop count and images count
+-            device()->seek(oldPos);
+-
+             if (that->ensureDemuxer()) {
+                 that->m_loop = WebPDemuxGetI(m_demuxer, WEBP_FF_LOOP_COUNT);
+                 that->m_frameCount = WebPDemuxGetI(m_demuxer, WEBP_FF_FRAME_COUNT);
+@@ -126,17 +129,13 @@ bool QWebpHandler::ensureScanned() const
+                 if (that->m_features.has_alpha)
+                     that->m_composited->fill(Qt::transparent);
+ 
+-                // We do not reset device position since we have read in all data
+                 m_scanState = ScanSuccess;
+-                return true;
+             }
+         } else {
+             m_scanState = ScanSuccess;
+         }
+     }
+ 
+-    device()->seek(oldPos);
+-
+     return m_scanState == ScanSuccess;
+ }
+ 
+@@ -159,7 +158,7 @@ bool QWebpHandler::ensureDemuxer()
+ 
+ bool QWebpHandler::read(QImage *image)
+ {
+-    if (!ensureScanned() || device()->isSequential() || !ensureDemuxer())
++    if (!ensureScanned() || !ensureDemuxer())
+         return false;
+ 
+     QRect prevFrameRect;
+Submodule qtlocation 98a5c511..f991e28c:
+diff --git a/qtlocation/src/location/configure.json b/qtlocation/src/location/configure.json
+index 6d01a9a3..d1e623a1 100644
+--- a/qtlocation/src/location/configure.json
++++ b/qtlocation/src/location/configure.json
+@@ -9,7 +9,7 @@
+             "label": "Qt.labs.location experimental QML plugin",
+             "purpose": "Provides experimental QtLocation QML types",
+             "section": "Location",
+-            "condition": "config.opengl",
++            "condition": "features.opengl",
+             "output": [ "privateFeature" ]
+         },
+         "geoservices_osm": {
+diff --git a/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp b/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
+index a978573d..11e1466f 100644
+--- a/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
++++ b/qtlocation/src/location/labs/qsg/qgeomapobjectqsgsupport.cpp
+@@ -158,7 +158,7 @@ void QGeoMapObjectQSGSupport::updateMapObjects(QSGNode *root, QQuickWindow *wind
+     if (!root)
+         return;
+ 
+-    if (m_mapObjectsRootNode && m_mapObjectsRootNode->parent())
++    if (m_mapObjectsRootNode && !m_mapObjectsRootNode->parent())
+         root->appendChildNode(m_mapObjectsRootNode.get());
+ 
+     if (!m_mapObjectsRootNode) {
+diff --git a/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
+index 5a40467e..d123c6a8 100644
+--- a/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp
+@@ -59,8 +59,10 @@ QT_BEGIN_NAMESPACE
+ static const QString kPrefixEsri(QStringLiteral("esri."));
+ static const QString kParamUserAgent(kPrefixEsri + QStringLiteral("useragent"));
+ 
+-static const QString kUrlGeocode(QStringLiteral("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates"));
+-static const QString kUrlReverseGeocode(QStringLiteral("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode"));
++static const QString kUrlGeocode(QStringLiteral("https://geocode.arcgis.com/arcgis/rest/services/"
++                                                "World/GeocodeServer/findAddressCandidates"));
++static const QString kUrlReverseGeocode(QStringLiteral(
++        "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode"));
+ 
+ static QString addressToQuery(const QGeoAddress &address)
+ {
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
+index 17492d94..96c12b1b 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutejsonparser_esri.cpp
+@@ -46,7 +46,8 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-// JSON reference: http://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
++// JSON reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
+ 
+ static const QString kErrorMessage(QStringLiteral("Error %1: %2."));
+ static const QString kErrorJson(QStringLiteral("Error: invalide JSON document."));
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
+index 8cadfb29..92b6bb13 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutereply_esri.cpp
+@@ -44,7 +44,8 @@
+ 
+ QT_BEGIN_NAMESPACE
+ 
+-// JSON reference: http://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
++// JSON reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/#/Route_service_with_synchronous_execution/02r300000036000000/
+ 
+ GeoRouteReplyEsri::GeoRouteReplyEsri(QNetworkReply *reply, const QGeoRouteRequest &request,
+                                      QObject *parent) :
+diff --git a/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
+index 0e6bc2c7..ed613f4b 100644
+--- a/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/georoutingmanagerengine_esri.cpp
+@@ -48,7 +48,8 @@ static const QString kPrefixEsri(QStringLiteral("esri."));
+ static const QString kParamUserAgent(kPrefixEsri + QStringLiteral("useragent"));
+ static const QString kParamToken(kPrefixEsri + QStringLiteral("token"));
+ 
+-static const QString kUrlRouting(QStringLiteral("http://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve"));
++static const QString kUrlRouting(QStringLiteral(
++        "https://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve"));
+ 
+ GeoRoutingManagerEngineEsri::GeoRoutingManagerEngineEsri(const QVariantMap &parameters,
+                                                          QGeoServiceProvider::Error *error,
+@@ -70,7 +71,8 @@ GeoRoutingManagerEngineEsri::~GeoRoutingManagerEngineEsri()
+ {
+ }
+ 
+-// REST reference: http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
++// REST reference:
++// https://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
+ 
+ QGeoRouteReply *GeoRoutingManagerEngineEsri::calculateRoute(const QGeoRouteRequest &request)
+ {
+@@ -125,7 +127,7 @@ void GeoRoutingManagerEngineEsri::replyError(QGeoRouteReply::Error errorCode, co
+ QString GeoRoutingManagerEngineEsri::preferedDirectionLangage()
+ {
+     // list of supported langages is defined in:
+-    // http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
++    // https://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r300000036000000
+     const QStringList supportedLanguages = {
+         "ar", // Generate directions in Arabic
+         "cs", // Generate directions in Czech
+diff --git a/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
+index 5d15835d..24148f95 100644
+--- a/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/geotiledmappingmanagerengine_esri.cpp
+@@ -230,7 +230,8 @@ QGeoMap *GeoTiledMappingManagerEngineEsri::createMap()
+ // ${y} = Y
+ // ${token} = Token
+ 
+-// template = 'http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{{z}}/{{y}}/{{x}}.png'
++// template =
++// 'https://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{{z}}/{{y}}/{{x}}.png'
+ 
+ bool GeoTiledMappingManagerEngineEsri::initializeMapSources(QGeoServiceProvider::Error *error,
+                                                             QString *errorString,
+diff --git a/qtlocation/src/plugins/geoservices/esri/maps.json b/qtlocation/src/plugins/geoservices/esri/maps.json
+index 8167ae7d..862e087d 100644
+--- a/qtlocation/src/plugins/geoservices/esri/maps.json
++++ b/qtlocation/src/plugins/geoservices/esri/maps.json
+@@ -6,8 +6,8 @@
+             "description": "ArcGIS Online World Street Map",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=3b93337983e9436f8db950e38a8629af'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=3b93337983e9436f8db950e38a8629af'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -16,8 +16,8 @@
+             "": "ArcGIS Online World Imagery",
+             "mobile": true,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -26,8 +26,8 @@
+             "description": "ArcGIS Online World Terrain Base",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=c61ad8ab017d49e1a82f580ee1298931'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=c61ad8ab017d49e1a82f580ee1298931'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -36,8 +36,8 @@
+             "description": "ArcGIS Online World Topography",
+             "mobile": true,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=30e5fe3149c34df1ba922e6f5bbf808f'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=30e5fe3149c34df1ba922e6f5bbf808f'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -46,8 +46,8 @@
+             "description": "This map presents land cover and detailed topographic maps for the United States.",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=99cd5fbd98934028802b4f797c4b1732'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=99cd5fbd98934028802b4f797c4b1732'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -56,8 +56,8 @@
+             "description": "National Geographic World Map",
+             "mobile": false,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=b9b1b422198944fbbd5250b3241691b6'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=b9b1b422198944fbbd5250b3241691b6'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -66,8 +66,8 @@
+             "description": "Thematic content providing a neutral background with minimal colors",
+             "mobile": true,
+             "night": false,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=ed712cb1db3e4bae9e85329040fb9a49'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=ed712cb1db3e4bae9e85329040fb9a49'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -76,8 +76,8 @@
+             "description": "Natural Earth physical map for the world",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=c4ec722a1cd34cf0a23904aadf8923a0'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=c4ec722a1cd34cf0a23904aadf8923a0'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -86,8 +86,8 @@
+             "description": "Portrays surface elevation as shaded relief",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=9c5370d0b54f4de1b48a3792d7377ff2'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=9c5370d0b54f4de1b48a3792d7377ff2'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -96,8 +96,8 @@
+             "description": "This map is designed to be used as a basemap by marine GIS professionals and as a reference map by anyone interested in ocean data",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=1e126e7520f9466c9ca28b8f28b5e500'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=1e126e7520f9466c9ca28b8f28b5e500'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -106,8 +106,8 @@
+             "description": "Thematic content providing a neutral background with minimal colors",
+             "mobile": false,
+             "night": true,
+-            "url": "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=a284a9b99b3446a3910d4144a50990f6'>Esri</a> contributors"
++            "url": "https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=a284a9b99b3446a3910d4144a50990f6'>Esri</a> contributors"
+         },
+ 
+         {
+@@ -116,8 +116,8 @@
+             "description": "DeLorme’s topographic basemap is a seamless global data set that portrays transportation, hydrography, jurisdiction boundaries, and major geographic features",
+             "mobile": false,
+             "night": false,
+-            "url": "http://server.arcgisonline.com/ArcGIS/rest/services/Specialty/DeLorme_World_Base_Map/MapServer",
+-            "copyrightText": "&copy; <a href='http://www.arcgis.com/home/item.html?id=b165c3df453e4be6b5ac4fdb241effbe'>Esri</a> contributors"
++            "url": "https://server.arcgisonline.com/ArcGIS/rest/services/Specialty/DeLorme_World_Base_Map/MapServer",
++            "copyrightText": "&copy; <a href='https://www.arcgis.com/home/item.html?id=b165c3df453e4be6b5ac4fdb241effbe'>Esri</a> contributors"
+         }
+     ]
+ }
+diff --git a/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp b/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
+index 3858ddf5..af66f28e 100644
+--- a/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
++++ b/qtlocation/src/plugins/geoservices/esri/placemanagerengine_esri.cpp
+@@ -63,8 +63,10 @@ static const QString kCountriesKey(QStringLiteral("detailedCountries"));
+ static const QString kLocalizedNamesKey(QStringLiteral("localizedNames"));
+ static const QString kMaxLocationsKey(QStringLiteral("maxLocations"));
+ 
+-static const QUrl kUrlGeocodeServer("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer?f=pjson");
+-static const QUrl kUrlFindAddressCandidates("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates");
++static const QUrl kUrlGeocodeServer(
++        "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer?f=pjson");
++static const QUrl kUrlFindAddressCandidates("https://geocode.arcgis.com/arcgis/rest/services/World/"
++                                            "GeocodeServer/findAddressCandidates");
+ 
+ PlaceManagerEngineEsri::PlaceManagerEngineEsri(const QVariantMap &parameters, QGeoServiceProvider::Error *error,
+                                                QString *errorString) :
+Submodule qtmultimedia f0344079..0d7cc33a:
+diff --git a/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp b/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
+index 2b5325132..b68b4af1b 100644
+--- a/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
++++ b/qtmultimedia/src/plugins/pulseaudio/qaudioinput_pulse.cpp
+@@ -402,6 +402,8 @@ int QPulseAudioInput::bytesReady() const
+ 
+ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ {
++    Q_ASSERT(data != nullptr || len == 0);
++
+     m_bytesAvailable = checkBytesReady();
+ 
+     setError(QAudio::NoError);
+@@ -411,7 +413,8 @@ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ 
+     if (!m_pullMode && !m_tempBuffer.isEmpty()) {
+         readBytes = qMin(static_cast<int>(len), m_tempBuffer.size());
+-        memcpy(data, m_tempBuffer.constData(), readBytes);
++        if (readBytes)
++            memcpy(data, m_tempBuffer.constData(), readBytes);
+         m_totalTimeValue += readBytes;
+ 
+         if (readBytes < m_tempBuffer.size()) {
+@@ -502,9 +505,10 @@ qint64 QPulseAudioInput::read(char *data, qint64 len)
+ 
+ void QPulseAudioInput::applyVolume(const void *src, void *dest, int len)
+ {
++    Q_ASSERT((src && dest) || len == 0);
+     if (m_volume < 1.f)
+         QAudioHelperInternal::qMultiplySamples(m_volume, m_format, src, dest, len);
+-    else
++    else if (len)
+         memcpy(dest, src, len);
+ }
+ 
+Submodule qtpim 02efef5e...f9a8f0fc (commits not present)
+Submodule qtquick3d b85cf622..47defc8b:
+diff --git a/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro b/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
+index ca5c499e..174a075b 100644
+--- a/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
++++ b/qtquick3d/src/plugins/assetimporters/assimp/assimp.pro
+@@ -10,7 +10,7 @@ QT_FOR_CONFIG += assetimporters-private
+ include($$OUT_PWD/../qtassetimporters-config.pri)
+ 
+ qtConfig(system-assimp):!if(cross_compile:host_build) {
+-    QMAKE_USE_PRIVATE += assimp
++    QMAKE_USE_PRIVATE += quick3d-assimp
+ } else {
+     include(../../../3rdparty/assimp/assimp.pri)
+ }
+Submodule qtquickcontrols2 3a657dc0..56ce8233:
+diff --git a/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp b/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
+index e5fe734f7..e36922775 100644
+--- a/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
++++ b/qtquickcontrols2/src/imports/platform/widgets/qwidgetplatformmenu.cpp
+@@ -38,6 +38,7 @@
+ #include "qwidgetplatformmenuitem_p.h"
+ 
+ #include <QtGui/qwindow.h>
++#include <QtGui/private/qhighdpiscaling_p.h>
+ #include <QtWidgets/qmenu.h>
+ #include <QtWidgets/qaction.h>
+ 
+@@ -145,7 +146,7 @@ void QWidgetPlatformMenu::showPopup(const QWindow *window, const QRect &targetRe
+ 
+     QPoint targetPos = targetRect.bottomLeft();
+     if (window)
+-        targetPos = window->mapToGlobal(targetPos);
++        targetPos = window->mapToGlobal(QHighDpi::fromNativeLocalPosition(targetPos, window));
+ 
+     const QWidgetPlatformMenuItem *widgetItem = qobject_cast<const QWidgetPlatformMenuItem *>(item);
+     m_menu->popup(targetPos, widgetItem ? widgetItem->action() : nullptr);
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
+index 950e4e099..b81fbea0b 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton.cpp
+@@ -387,6 +387,17 @@ void QQuickAbstractButtonPrivate::itemImplicitHeightChanged(QQuickItem *item)
+         emit q->implicitIndicatorHeightChanged();
+ }
+ 
++void QQuickAbstractButtonPrivate::itemDestroyed(QQuickItem *item)
++{
++    Q_Q(QQuickAbstractButton);
++    QQuickControlPrivate::itemDestroyed(item);
++    if (item == indicator) {
++        indicator = nullptr;
++        emit q->implicitIndicatorWidthChanged();
++        emit q->implicitIndicatorHeightChanged();
++    }
++}
++
+ QQuickAbstractButton *QQuickAbstractButtonPrivate::findCheckedButton() const
+ {
+     Q_Q(const QQuickAbstractButton);
+@@ -1176,6 +1187,12 @@ QAccessible::Role QQuickAbstractButton::accessibleRole() const
+     }
+     return QAccessible::Button;
+ }
++
++void QQuickAbstractButton::accessiblePressAction()
++{
++    Q_D(QQuickAbstractButton);
++    d->trigger();
++}
+ #endif
+ 
+ QT_END_NAMESPACE
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
+index 0fa48980e..ab66220d0 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p.h
+@@ -209,6 +209,7 @@ protected:
+ #if QT_CONFIG(accessibility)
+     void accessibilityActiveChanged(bool active) override;
+     QAccessible::Role accessibleRole() const override;
++    Q_INVOKABLE void accessiblePressAction();
+ #endif
+ 
+ private:
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
+index 9291c1a87..b729720f2 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickabstractbutton_p_p.h
+@@ -109,6 +109,7 @@ public:
+ 
+     void itemImplicitWidthChanged(QQuickItem *item) override;
+     void itemImplicitHeightChanged(QQuickItem *item) override;
++    void itemDestroyed(QQuickItem *item) override;
+ 
+     // copied from qabstractbutton.cpp
+     static const int AUTO_REPEAT_DELAY = 300;
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp b/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
+index 2041e7741..8610cdfae 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickaction.cpp
+@@ -145,7 +145,7 @@ int QQuickActionPrivate::ShortcutEntry::shortcutId() const
+ 
+ void QQuickActionPrivate::ShortcutEntry::grab(const QKeySequence &shortcut, bool enabled)
+ {
+-    if (shortcut.isEmpty())
++    if (shortcut.isEmpty() || m_shortcutId)
+         return;
+ 
+     Qt::ShortcutContext context = Qt::WindowShortcut; // TODO
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp b/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
+index f38c2b09c..6eed2a024 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontainer.cpp
+@@ -225,6 +225,7 @@ void QQuickContainerPrivate::cleanup()
+     QObject::disconnect(contentModel, &QQmlObjectModel::countChanged, q, &QQuickContainer::countChanged);
+     QObject::disconnect(contentModel, &QQmlObjectModel::childrenChanged, q, &QQuickContainer::contentChildrenChanged);
+     delete contentModel;
++    contentModel = nullptr;
+ }
+ 
+ QQuickItem *QQuickContainerPrivate::itemAt(int index) const
+@@ -436,7 +437,7 @@ void QQuickContainerPrivate::contentChildren_clear(QQmlListProperty<QQuickItem>
+ void QQuickContainerPrivate::updateContentWidth()
+ {
+     Q_Q(QQuickContainer);
+-    if (hasContentWidth || qFuzzyCompare(contentWidth, implicitContentWidth))
++    if (hasContentWidth || qFuzzyCompare(contentWidth, implicitContentWidth) || !contentModel)
+         return;
+ 
+     contentWidth = implicitContentWidth;
+@@ -446,7 +447,7 @@ void QQuickContainerPrivate::updateContentWidth()
+ void QQuickContainerPrivate::updateContentHeight()
+ {
+     Q_Q(QQuickContainer);
+-    if (hasContentHeight || qFuzzyCompare(contentHeight, implicitContentHeight))
++    if (hasContentHeight || qFuzzyCompare(contentHeight, implicitContentHeight) || !contentModel)
+         return;
+ 
+     contentHeight = implicitContentHeight;
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp b/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
+index bbbd0e622..1f4b47343 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontrol.cpp
+@@ -845,6 +845,13 @@ void QQuickControlPrivate::executeBackground(bool complete)
+         quickCompleteDeferred(q, backgroundName(), background);
+ }
+ 
++/*
++    \internal
++
++    Hides an item that was replaced by a newer one, rather than
++    deleting it, as the item is typically created in QML and hence
++    we don't own it.
++*/
+ void QQuickControlPrivate::hideOldItem(QQuickItem *item)
+ {
+     if (!item)
+@@ -863,6 +870,29 @@ void QQuickControlPrivate::hideOldItem(QQuickItem *item)
+ #endif
+ }
+ 
++/*
++    \internal
++
++    Named "unhide" because it's used for cases where an item
++    that was previously hidden by \l hideOldItem() wants to be
++    shown by a control again, such as a ScrollBar in ScrollView.
++*/
++void QQuickControlPrivate::unhideOldItem(QQuickControl *control, QQuickItem *item)
++{
++    Q_ASSERT(item);
++    qCDebug(lcItemManagement) << "unhiding old item" << item;
++
++    item->setVisible(true);
++    item->setParentItem(control);
++
++#if QT_CONFIG(accessibility)
++    // Add the item back in to the accessibility tree.
++    QQuickAccessibleAttached *accessible = accessibleAttached(item);
++    if (accessible)
++        accessible->setIgnored(false);
++#endif
++}
++
+ void QQuickControlPrivate::updateBaselineOffset()
+ {
+     Q_Q(QQuickControl);
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h b/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
+index 8e979079e..a6e624c91 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
++++ b/qtquickcontrols2/src/quicktemplates2/qquickcontrol_p_p.h
+@@ -173,6 +173,7 @@ public:
+     virtual void executeBackground(bool complete = false);
+ 
+     static void hideOldItem(QQuickItem *item);
++    static void unhideOldItem(QQuickControl *control, QQuickItem *item);
+ 
+     void updateBaselineOffset();
+ 
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp b/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
+index e6db14eb5..6197d1547 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickdialogbuttonbox.cpp
+@@ -237,7 +237,7 @@ static QRectF alignedRect(Qt::LayoutDirection direction, Qt::Alignment alignment
+ void QQuickDialogButtonBoxPrivate::resizeContent()
+ {
+     Q_Q(QQuickDialogButtonBox);
+-    if (!contentItem)
++    if (!contentItem || !contentModel)
+         return;
+ 
+     QRectF geometry = q->boundingRect().adjusted(q->leftPadding(), q->topPadding(), -q->rightPadding(), -q->bottomPadding());
+@@ -322,6 +322,9 @@ void QQuickDialogButtonBoxPrivate::updateLayout()
+ qreal QQuickDialogButtonBoxPrivate::getContentWidth() const
+ {
+     Q_Q(const QQuickDialogButtonBox);
++    if (!contentModel)
++        return 0;
++
+     const int count = contentModel->count();
+     const qreal totalSpacing = qMax(0, count - 1) * spacing;
+     qreal totalWidth = totalSpacing;
+@@ -341,6 +344,9 @@ qreal QQuickDialogButtonBoxPrivate::getContentWidth() const
+ qreal QQuickDialogButtonBoxPrivate::getContentHeight() const
+ {
+     Q_Q(const QQuickDialogButtonBox);
++    if (!contentModel)
++        return 0;
++
+     const int count = contentModel->count();
+     qreal maxHeight = 0;
+     for (int i = 0; i < count; ++i) {
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp b/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
+index 91bd59184..0ce518f84 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickoverlay.cpp
+@@ -399,8 +399,11 @@ void QQuickOverlay::itemChange(ItemChange change, const ItemChangeData &data)
+     Q_D(QQuickOverlay);
+     QQuickItem::itemChange(change, data);
+ 
+-    if (change == ItemChildAddedChange || change == ItemChildRemovedChange)
++    if (change == ItemChildAddedChange || change == ItemChildRemovedChange) {
+         setVisible(!d->allDrawers.isEmpty() || !childItems().isEmpty());
++        if (data.item->parent() == d->mouseGrabberPopup)
++            d->setMouseGrabberPopup(nullptr);
++    }
+ }
+ 
+ void QQuickOverlay::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
+diff --git a/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp b/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
+index 4e2f509db..1c4b308cd 100644
+--- a/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
++++ b/qtquickcontrols2/src/quicktemplates2/qquickscrollbar.cpp
+@@ -797,6 +797,14 @@ void QQuickScrollBarAttachedPrivate::initHorizontal()
+     if (parent && parent == flickable->parentItem())
+         horizontal->stackAfter(flickable);
+ 
++    // If a scroll bar was previously hidden (due to e.g. setting a new contentItem
++    // on a ScrollView), we need to make sure that we un-hide it.
++    // We don't bother checking if the item is actually the old one, because
++    // if it's not, all of the things the function does (setting parent, visibility, etc.)
++    // should be no-ops anyway.
++    if (auto control = qobject_cast<QQuickControl*>(q_ptr->parent()))
++        QQuickControlPrivate::unhideOldItem(control, horizontal);
++
+     layoutHorizontal();
+     horizontal->setSize(area->property("widthRatio").toReal());
+     horizontal->setPosition(area->property("xPosition").toReal());
+@@ -818,6 +826,9 @@ void QQuickScrollBarAttachedPrivate::initVertical()
+     if (parent && parent == flickable->parentItem())
+         vertical->stackAfter(flickable);
+ 
++    if (auto control = qobject_cast<QQuickControl*>(q_ptr->parent()))
++        QQuickControlPrivate::unhideOldItem(control, vertical);
++
+     layoutVertical();
+     vertical->setSize(area->property("heightRatio").toReal());
+     vertical->setPosition(area->property("yPosition").toReal());
+diff --git a/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml b/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
+index 0e8b08352..cd4931184 100644
+--- a/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
++++ b/qtquickcontrols2/tests/auto/controls/data/tst_scrollview.qml
+@@ -576,4 +576,51 @@ TestCase {
+         verify(newHorizontalScrollBar.visible)
+         verify(!oldHorizontalScrollBar.visible)
+     }
++
++    Component {
++        id: bindingToContentItemAndStandaloneFlickable
++
++        Item {
++            width: 200
++            height: 200
++
++            property alias scrollView: scrollView
++
++            ScrollView {
++                id: scrollView
++                anchors.fill: parent
++                contentItem: listView
++
++                property Item someBinding: contentItem
++            }
++            ListView {
++                id: listView
++                model: 10
++                delegate: ItemDelegate {
++                    text: modelData
++                    width: listView.width
++                }
++            }
++        }
++    }
++
++    // Tests that scroll bars show up for a ScrollView where
++    // - its contentItem is declared as a standalone, separate item
++    // - there is a binding to contentItem (which causes a default Flickable to be created)
++    function test_bindingToContentItemAndStandaloneFlickable() {
++        let root = createTemporaryObject(bindingToContentItemAndStandaloneFlickable, testCase)
++        verify(root)
++
++        let control = root.scrollView
++        let verticalScrollBar = control.ScrollBar.vertical
++        let horizontalScrollBar = control.ScrollBar.horizontal
++        compare(verticalScrollBar.parent, control)
++        compare(horizontalScrollBar.parent, control)
++        verify(verticalScrollBar.visible)
++        verify(horizontalScrollBar.visible)
++
++        mouseDrag(verticalScrollBar, verticalScrollBar.width / 2, verticalScrollBar.height / 2, 0, 50)
++        verify(verticalScrollBar.active)
++        verify(horizontalScrollBar.active)
++    }
+ }
+diff --git a/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml b/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
+index b3fab41ca..10b6baa02 100644
+--- a/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
++++ b/qtquickcontrols2/tests/auto/controls/data/tst_switch.qml
+@@ -608,4 +608,27 @@ TestCase {
+         mouseClick(control.indicator)
+         verify(control.activeFocus)
+     }
++
++    Component {
++        id: deletionOrder1
++        Item {
++            Image { id: innerImage }
++            Switch { indicator: innerImage }
++        }
++    }
++
++    Component {
++        id: deletionOrder2
++        Item {
++            Switch { indicator: innerImage }
++            Image { id: innerImage }
++        }
++    }
++
++    function test_deletionOrder() {
++        var control1 = createTemporaryObject(deletionOrder1, testCase)
++        verify(control1)
++        var control2 = createTemporaryObject(deletionOrder2, testCase)
++        verify(control2)
++    }
+ }
+diff --git a/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml b/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml
+new file mode 100644
+index 000000000..9e4598b9f
+--- /dev/null
++++ b/qtquickcontrols2/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml
+@@ -0,0 +1,78 @@
++/****************************************************************************
++**
++** Copyright (C) 2021 The Qt Company Ltd.
++** Contact: https://www.qt.io/licensing/
++**
++** This file is part of the test suite of the Qt Toolkit.
++**
++** $QT_BEGIN_LICENSE:BSD$
++** Commercial License Usage
++** Licensees holding valid commercial Qt licenses may use this file in
++** accordance with the commercial license agreement provided with the
++** Software or, alternatively, in accordance with the terms contained in
++** a written agreement between you and The Qt Company. For licensing terms
++** and conditions see https://www.qt.io/terms-conditions. For further
++** information use the contact form at https://www.qt.io/contact-us.
++**
++** BSD License Usage
++** Alternatively, you may use this file under the terms of the BSD license
++** as follows:
++**
++** "Redistribution and use in source and binary forms, with or without
++** modification, are permitted provided that the following conditions are
++** met:
++**   * Redistributions of source code must retain the above copyright
++**     notice, this list of conditions and the following disclaimer.
++**   * Redistributions in binary form must reproduce the above copyright
++**     notice, this list of conditions and the following disclaimer in
++**     the documentation and/or other materials provided with the
++**     distribution.
++**   * Neither the name of The Qt Company Ltd nor the names of its
++**     contributors may be used to endorse or promote products derived
++**     from this software without specific prior written permission.
++**
++**
++** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
++** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
++** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
++** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
++** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
++** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
++** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
++** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
++** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
++** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
++** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
++**
++** $QT_END_LICENSE$
++**
++****************************************************************************/
++
++import QtQuick 2.15
++import QtQuick.Controls 2.15
++
++ApplicationWindow {
++    id: window
++    width: 400
++    height: 400
++    title: "releaseAfterExitTransition"
++
++    property alias popup: popup
++    property alias modalPopup: modalPopup
++
++    Popup {
++        id: popup
++        y: parent.height - height
++        width: 50
++        height: 50
++    }
++
++    Popup {
++        id: modalPopup
++        modal: true
++        y: parent.height - height
++        width: 50
++        height: 50
++        exit:  Transition { PauseAnimation { duration: 100 } }
++    }
++}
+diff --git a/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp b/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
+index 54952d128..3d50e2dd4 100644
+--- a/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
++++ b/qtquickcontrols2/tests/auto/qquickpopup/tst_qquickpopup.cpp
+@@ -100,6 +100,7 @@ private slots:
+     void invisibleToolTipOpen();
+     void centerInOverlayWithinStackViewItem();
+     void destroyDuringExitTransition();
++    void releaseAfterExitTransition();
+ };
+ 
+ void tst_QQuickPopup::initTestCase()
+@@ -1575,6 +1576,34 @@ void tst_QQuickPopup::destroyDuringExitTransition()
+     QVERIFY(!button->isDown());
+ }
+ 
++void tst_QQuickPopup::releaseAfterExitTransition()
++{
++    QQuickApplicationHelper helper(this, "releaseAfterExitTransition.qml");
++    QVERIFY2(helper.ready, helper.failureMessage());
++
++    QQuickWindow *window = helper.window;
++    window->show();
++    QVERIFY(QTest::qWaitForWindowActive(window));
++
++    QQuickOverlay *overlay = QQuickOverlay::overlay(window);
++    QQuickPopup *modalPopup = window->property("modalPopup").value<QQuickPopup *>();
++    QQuickPopup *popup = window->property("popup").value<QQuickPopup *>();
++
++    modalPopup->open();
++    QTRY_VERIFY(modalPopup->isOpened());
++
++    QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++    // wait until the transition is finished and the overlay hides itself
++    QTRY_VERIFY(!overlay->isVisible());
++    QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++
++    popup->open();
++    QTRY_VERIFY(popup->isOpened());
++    QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
++    QTRY_VERIFY(!popup->isOpened());
++}
++
++
+ QTEST_QUICKCONTROLS_MAIN(tst_QQuickPopup)
+ 
+ #include "tst_qquickpopup.moc"
+Submodule qtscript 5be95f96...4d8e4bd2 (commits not present)
+Submodule qtspeech 17fc9fde..255845e2:
+diff --git a/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp b/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
+index 6eb74b8..bcc7dd1 100644
+--- a/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
++++ b/qtspeech/src/plugins/tts/speechdispatcher/qtexttospeech_speechd.cpp
+@@ -357,7 +357,9 @@ QVector<QLocale> QTextToSpeechEngineSpeechd::availableLocales() const
+ 
+ QVector<QVoice> QTextToSpeechEngineSpeechd::availableVoices() const
+ {
+-    return m_voices.values(m_currentLocale.name()).toVector();
++    QList<QVoice> resultList = m_voices.values(m_currentLocale.name());
++    std::reverse(resultList.begin(), resultList.end());
++    return resultList.toVector();
+ }
+ 
+ // We have no way of knowing our own client_id since speech-dispatcher seems to be incomplete
+Submodule qtsvg 0c05780e..a7a0f249:
+diff --git a/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp b/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
+index 561e77e..12e0574 100644
+--- a/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
++++ b/qtsvg/src/plugins/imageformats/svg/qsvgiohandler.cpp
+@@ -191,6 +191,8 @@ bool QSvgIOHandler::read(QImage *image)
+             }
+         }
+         if (!finalSize.isEmpty()) {
++            if (qMax(finalSize.width(), finalSize.height()) > 0xffff)
++                return false; // Assume corrupted file
+             image->fill(d->backColor.rgba());
+             QPainter p(image);
+             d->r.render(&p, bounds);
+diff --git a/qtsvg/src/svg/qsvghandler.cpp b/qtsvg/src/svg/qsvghandler.cpp
+index a5f877f..8dda563 100644
+--- a/qtsvg/src/svg/qsvghandler.cpp
++++ b/qtsvg/src/svg/qsvghandler.cpp
+@@ -1393,9 +1393,10 @@ static void parseFont(QSvgNode *node,
+         case FontSizeNone:
+             break;
+         case FontSizeValue: {
+-            QSvgHandler::LengthType dummy; // should always be pixel size
+-            fontStyle->setSize(qMin(parseLength(attributes.fontSize, dummy, handler),
+-                                    qreal(0xffff)));
++            QSvgHandler::LengthType type;
++            qreal fs = parseLength(attributes.fontSize, type, handler);
++            fs = convertToPixels(fs, true, type);
++            fontStyle->setSize(qMin(fs, qreal(0xffff)));
+         }
+             break;
+         default:
+@@ -2513,6 +2514,8 @@ static bool parseAnimateTransformNode(QSvgNode *parent,
+             ++s;
+         }
+     }
++    if (vals.count() % 3 != 0)
++        return false;
+ 
+     bool ok = true;
+     int begin = parseClockValue(beginStr, &ok);
+@@ -2576,6 +2579,8 @@ static QSvgNode *createCircleNode(QSvgNode *parent,
+     qreal ncx = toDouble(cx);
+     qreal ncy = toDouble(cy);
+     qreal nr  = toDouble(r);
++    if (nr < 0.0)
++        return nullptr;
+ 
+     QRectF rect(ncx-nr, ncy-nr, nr*2, nr*2);
+     QSvgNode *circle = new QSvgCircle(parent, rect);
+@@ -3046,15 +3051,16 @@ static QSvgStyleProperty *createRadialGradientNode(QSvgNode *node,
+ 
+     qreal ncx = 0.5;
+     qreal ncy = 0.5;
+-    qreal nr  = 0.5;
+     if (!cx.isEmpty())
+         ncx = toDouble(cx);
+     if (!cy.isEmpty())
+         ncy = toDouble(cy);
++
++    qreal nr = 0.0;
+     if (!r.isEmpty())
+         nr = toDouble(r);
+-    if (nr < 0.5)
+-        nr = 0.5;
++    if (nr <= 0.0)
++        return nullptr;
+ 
+     qreal nfx = ncx;
+     if (!fx.isEmpty())
+@@ -3350,7 +3356,9 @@ static QSvgNode *createTextNode(QSvgNode *parent,
+     //### editable and rotate not handled
+     QSvgHandler::LengthType type;
+     qreal nx = parseLength(x, type, handler);
++    nx = convertToPixels(nx, true, type);
+     qreal ny = parseLength(y, type, handler);
++    ny = convertToPixels(ny, true, type);
+ 
+     QSvgNode *text = new QSvgText(parent, QPointF(nx, ny));
+     return text;
+@@ -3691,9 +3699,7 @@ void QSvgHandler::parse()
+         case QXmlStreamReader::EndElement:
+             endElement(xml->name());
+             ++remainingUnfinishedElements;
+-            // if we are using somebody else's qxmlstreamreader
+-            // we should not read until the end of the stream
+-            done = !m_ownsReader && (xml->name() == QLatin1String("svg"));
++            done = (xml->name() == QLatin1String("svg"));
+             break;
+         case QXmlStreamReader::Characters:
+             characters(xml->text());
+diff --git a/qtsvg/src/svg/qsvgstructure.cpp b/qtsvg/src/svg/qsvgstructure.cpp
+index b89608b..89c9e4e 100644
+--- a/qtsvg/src/svg/qsvgstructure.cpp
++++ b/qtsvg/src/svg/qsvgstructure.cpp
+@@ -255,9 +255,13 @@ inline static bool isSupportedSvgFeature(const QString &str)
+     };
+ 
+     if (str.length() <= MAX_WORD_LENGTH && str.length() >= MIN_WORD_LENGTH) {
++        const char16_t unicode44 = str.at(44).unicode();
++        const char16_t unicode45 = str.at(45).unicode();
++        if (unicode44 >= sizeof(asso_values) || unicode45 >= sizeof(asso_values))
++            return false;
+         const int key = str.length()
+-                        + asso_values[str.at(45).unicode()]
+-                        + asso_values[str.at(44).unicode()];
++                        + asso_values[unicode45]
++                        + asso_values[unicode44];
+         if (key <= MAX_HASH_VALUE && key >= 0)
+             return str == QLatin1String(wordlist[key]);
+     }
+diff --git a/qtsvg/src/svg/qsvgtinydocument.cpp b/qtsvg/src/svg/qsvgtinydocument.cpp
+index 63d0797..19e7154 100644
+--- a/qtsvg/src/svg/qsvgtinydocument.cpp
++++ b/qtsvg/src/svg/qsvgtinydocument.cpp
+@@ -433,8 +433,16 @@ void QSvgTinyDocument::draw(QPainter *p, QSvgExtraStates &)
+     draw(p);
+ }
+ 
++static bool isValidMatrix(const QTransform &transform)
++{
++    qreal determinant = transform.determinant();
++    return qIsFinite(determinant);
++}
++
+ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect, const QRectF &sourceRect)
+ {
++    QTransform oldTransform = p->worldTransform();
++
+     QRectF target = targetRect;
+     if (target.isEmpty()) {
+         QPaintDevice *dev = p->device();
+@@ -487,6 +495,9 @@ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect,
+         }
+ #endif
+     }
++
++    if (!isValidMatrix(p->worldTransform()))
++        p->setWorldTransform(oldTransform);
+ }
+ 
+ QRectF QSvgTinyDocument::boundsOnElement(const QString &id) const
+diff --git a/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp b/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
+index 36c76ec..db71e02 100644
+--- a/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
++++ b/qtsvg/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp
+@@ -86,6 +86,8 @@ private slots:
+     void oss_fuzz_23731();
+     void oss_fuzz_24131();
+     void oss_fuzz_24738();
++    void illegalAnimateTransform_data();
++    void illegalAnimateTransform();
+ 
+ #ifndef QT_NO_COMPRESS
+     void testGzLoading();
+@@ -1646,5 +1648,22 @@ void tst_QSvgRenderer::oss_fuzz_24738()
+     QSvgRenderer().load(QByteArray("<svg><path d=\"a 2 1e-212.....\">"));
+ }
+ 
++void tst_QSvgRenderer::illegalAnimateTransform_data()
++{
++    QTest::addColumn<QByteArray>("svg");
++
++    QTest::newRow("case1") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" values=\"8,0,5,0\">");
++    QTest::newRow("case2") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" values=\"1,2\">");
++    QTest::newRow("case3") << QByteArray("<svg><animateTransform type=\"rotate\" begin=\"1\" dur=\"2\" from=\".. 5 2\" to=\"f\">");
++    QTest::newRow("case4") << QByteArray("<svg><animateTransform type=\"scale\" begin=\"1\" dur=\"2\" by=\"--,..\">");
++}
++
++void tst_QSvgRenderer::illegalAnimateTransform()
++{
++    QFETCH(QByteArray, svg);
++    QSvgRenderer renderer;
++    QVERIFY(!renderer.load(svg)); // also shouldn't assert
++}
++
+ QTEST_MAIN(tst_QSvgRenderer)
+ #include "tst_qsvgrenderer.moc"
+Submodule qttools 6914f7c8..090e526e:
+diff --git a/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp b/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
+index feab1e2d5..cbfb82507 100644
+--- a/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
++++ b/qttools/src/assistant/qhelpgenerator/helpgenerator.cpp
+@@ -445,7 +445,9 @@ bool HelpGeneratorPrivate::insertFiles(const QStringList &files, const QString &
+     if (filterSetId < 0)
+         return false;
+     ++filterSetId;
+-    for (int attId : qAsConst(filterAtts)) {
++    QList<int> attValues = filterAtts.values();
++    std::sort(attValues.begin(), attValues.end());
++    for (int attId : qAsConst(attValues)) {
+         m_query->prepare(QLatin1String("INSERT INTO FileAttributeSetTable "
+             "VALUES(?, ?)"));
+         m_query->bindValue(0, filterSetId);
+Submodule qtwayland dfb0129c..2904e1b3:
+diff --git a/qtwayland/src/client/configure.json b/qtwayland/src/client/configure.json
+index 2f424580..29222357 100644
+--- a/qtwayland/src/client/configure.json
++++ b/qtwayland/src/client/configure.json
+@@ -149,8 +149,7 @@
+                     "#endif"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "vulkan-server-buffer": {
+             "label": "Vulkan Buffer Sharing",
+@@ -168,7 +167,8 @@
+                     "exportAllocInfo.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR;",
+                     "return 0;"
+                 ]
+-            }
++            },
++            "use": "wayland-client"
+         },
+         "egl_1_5-wayland": {
+             "label": "EGL 1.5 with Wayland Platform",
+@@ -183,7 +183,7 @@
+                     "eglGetPlatformDisplay(EGL_PLATFORM_WAYLAND_EXT, (struct wl_display *)(nullptr), nullptr);"
+                 ]
+             },
+-            "use": "egl"
++            "use": "egl wayland-client"
+         }
+     },
+ 
+diff --git a/qtwayland/src/client/global/qwaylandclientextension.cpp b/qtwayland/src/client/global/qwaylandclientextension.cpp
+index 125b1e19..edccfe63 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension.cpp
++++ b/qtwayland/src/client/global/qwaylandclientextension.cpp
+@@ -74,7 +74,10 @@ void QWaylandClientExtensionPrivate::handleRegistryGlobal(void *data, ::wl_regis
+ void QWaylandClientExtension::addRegistryListener()
+ {
+     Q_D(QWaylandClientExtension);
+-    d->waylandIntegration->display()->addRegistryListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++    if (!d->registered) {
++        d->waylandIntegration->display()->addRegistryListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++        d->registered = true;
++    }
+ }
+ 
+ QWaylandClientExtension::QWaylandClientExtension(const int ver)
+@@ -88,6 +91,13 @@ QWaylandClientExtension::QWaylandClientExtension(const int ver)
+     QMetaObject::invokeMethod(this, "addRegistryListener", Qt::QueuedConnection);
+ }
+ 
++QWaylandClientExtension::~QWaylandClientExtension()
++{
++    Q_D(QWaylandClientExtension);
++    if (d->registered && !QCoreApplication::closingDown())
++        d->waylandIntegration->display()->removeListener(&QWaylandClientExtensionPrivate::handleRegistryGlobal, this);
++}
++
+ QtWaylandClient::QWaylandIntegration *QWaylandClientExtension::integration() const
+ {
+     Q_D(const QWaylandClientExtension);
+diff --git a/qtwayland/src/client/global/qwaylandclientextension.h b/qtwayland/src/client/global/qwaylandclientextension.h
+index 98272e57..5bd28398 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension.h
++++ b/qtwayland/src/client/global/qwaylandclientextension.h
+@@ -63,6 +63,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandClientExtension : public QObject
+     Q_PROPERTY(bool active READ isActive NOTIFY activeChanged)
+ public:
+     QWaylandClientExtension(const int version);
++    ~QWaylandClientExtension();
+ 
+     QtWaylandClient::QWaylandIntegration *integration() const;
+     int version() const;
+diff --git a/qtwayland/src/client/global/qwaylandclientextension_p.h b/qtwayland/src/client/global/qwaylandclientextension_p.h
+index 69cc46a0..9091efbe 100644
+--- a/qtwayland/src/client/global/qwaylandclientextension_p.h
++++ b/qtwayland/src/client/global/qwaylandclientextension_p.h
+@@ -68,6 +68,7 @@ public:
+     QtWaylandClient::QWaylandIntegration *waylandIntegration = nullptr;
+     int version = -1;
+     bool active = false;
++    bool registered = false;
+ };
+ 
+ class Q_WAYLAND_CLIENT_EXPORT QWaylandClientExtensionTemplatePrivate : public QWaylandClientExtensionPrivate
+diff --git a/qtwayland/src/client/qwaylanddatadevice.cpp b/qtwayland/src/client/qwaylanddatadevice.cpp
+index 7e2e3308..e3e60ed5 100644
+--- a/qtwayland/src/client/qwaylanddatadevice.cpp
++++ b/qtwayland/src/client/qwaylanddatadevice.cpp
+@@ -72,6 +72,8 @@ QWaylandDataDevice::QWaylandDataDevice(QWaylandDataDeviceManager *manager, QWayl
+ 
+ QWaylandDataDevice::~QWaylandDataDevice()
+ {
++    if (wl_data_device_get_version(object()) >= WL_DATA_DEVICE_RELEASE_SINCE_VERSION)
++        release();
+ }
+ 
+ QWaylandDataOffer *QWaylandDataDevice::selectionOffer() const
+@@ -110,7 +112,7 @@ QWaylandDataOffer *QWaylandDataDevice::dragOffer() const
+     return m_dragOffer.data();
+ }
+ 
+-bool QWaylandDataDevice::startDrag(QMimeData *mimeData, QWaylandWindow *icon)
++bool QWaylandDataDevice::startDrag(QMimeData *mimeData, Qt::DropActions supportedActions, QWaylandWindow *icon)
+ {
+     auto *seat = m_display->currentInputDevice();
+     auto *origin = seat->pointerFocus();
+@@ -123,7 +125,28 @@ bool QWaylandDataDevice::startDrag(QMimeData *mimeData, QWaylandWindow *icon)
+     }
+ 
+     m_dragSource.reset(new QWaylandDataSource(m_display->dndSelectionHandler(), mimeData));
++
++    if (wl_data_device_get_version(object()) >= 3)
++        m_dragSource->set_actions(dropActionsToWl(supportedActions));
++
+     connect(m_dragSource.data(), &QWaylandDataSource::cancelled, this, &QWaylandDataDevice::dragSourceCancelled);
++    connect(m_dragSource.data(), &QWaylandDataSource::dndResponseUpdated, this, [this](bool accepted, Qt::DropAction action) {
++            auto drag = static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag());
++            // in old versions drop action is not set, so we guess
++            if (wl_data_source_get_version(m_dragSource->object()) < 3) {
++                drag->setResponse(accepted);
++            } else {
++                QPlatformDropQtResponse response(accepted, action);
++                drag->setResponse(response);
++            }
++    });
++    connect(m_dragSource.data(), &QWaylandDataSource::dndDropped, this, [](bool accepted, Qt::DropAction action) {
++        QPlatformDropQtResponse response(accepted, action);
++        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setDropResponse(response);
++    });
++    connect(m_dragSource.data(), &QWaylandDataSource::finished, this, []() {
++        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag();
++    });
+ 
+     start_drag(m_dragSource->object(), origin->wlSurface(), icon->wlSurface(), m_display->currentInputDevice()->serial());
+     return true;
+@@ -152,7 +175,7 @@ void QWaylandDataDevice::data_device_drop()
+         supportedActions = drag->supportedActions();
+     } else if (m_dragOffer) {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     } else {
+         return;
+     }
+@@ -162,7 +185,11 @@ void QWaylandDataDevice::data_device_drop()
+                                                                           QGuiApplication::keyboardModifiers());
+ 
+     if (drag) {
+-        static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag(response);
++        auto drag =  static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag());
++        drag->setDropResponse(response);
++        drag->finishDrag();
++    } else if (m_dragOffer) {
++        m_dragOffer->finish();
+     }
+ }
+ 
+@@ -186,7 +213,7 @@ void QWaylandDataDevice::data_device_enter(uint32_t serial, wl_surface *surface,
+         supportedActions = drag->supportedActions();
+     } else if (m_dragOffer) {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     }
+ 
+     const QPlatformDragQtResponse &response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
+@@ -197,11 +224,7 @@ void QWaylandDataDevice::data_device_enter(uint32_t serial, wl_surface *surface,
+         static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setResponse(response);
+     }
+ 
+-    if (response.isAccepted()) {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, m_dragOffer->firstFormat().toUtf8().constData());
+-    } else {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, nullptr);
+-    }
++    sendResponse(supportedActions, response);
+ }
+ 
+ void QWaylandDataDevice::data_device_leave()
+@@ -235,10 +258,10 @@ void QWaylandDataDevice::data_device_motion(uint32_t time, wl_fixed_t x, wl_fixe
+         supportedActions = drag->supportedActions();
+     } else {
+         dragData = m_dragOffer->mimeData();
+-        supportedActions = Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
++        supportedActions = m_dragOffer->supportedActions();
+     }
+ 
+-    QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
++    const QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_dragWindow, dragData, m_dragPoint, supportedActions,
+                                                                           QGuiApplication::mouseButtons(),
+                                                                           QGuiApplication::keyboardModifiers());
+ 
+@@ -246,11 +269,7 @@ void QWaylandDataDevice::data_device_motion(uint32_t time, wl_fixed_t x, wl_fixe
+         static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->setResponse(response);
+     }
+ 
+-    if (response.isAccepted()) {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, m_dragOffer->firstFormat().toUtf8().constData());
+-    } else {
+-        wl_data_offer_accept(m_dragOffer->object(), m_enterSerial, nullptr);
+-    }
++    sendResponse(supportedActions, response);
+ }
+ #endif // QT_CONFIG(draganddrop)
+ 
+@@ -277,14 +296,10 @@ void QWaylandDataDevice::selectionSourceCancelled()
+ #if QT_CONFIG(draganddrop)
+ void QWaylandDataDevice::dragSourceCancelled()
+ {
++    static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->finishDrag();
+     m_dragSource.reset();
+ }
+ 
+-void QWaylandDataDevice::dragSourceTargetChanged(const QString &mimeType)
+-{
+-    static_cast<QWaylandDrag *>(QGuiApplicationPrivate::platformIntegration()->drag())->updateTarget(mimeType);
+-}
+-
+ QPoint QWaylandDataDevice::calculateDragPosition(int x, int y, QWindow *wnd) const
+ {
+     QPoint pnt(wl_fixed_to_int(x), wl_fixed_to_int(y));
+@@ -297,6 +312,33 @@ QPoint QWaylandDataDevice::calculateDragPosition(int x, int y, QWindow *wnd) con
+     }
+     return pnt;
+ }
++
++void QWaylandDataDevice::sendResponse(Qt::DropActions supportedActions, const QPlatformDragQtResponse &response)
++{
++    if (response.isAccepted()) {
++        if (wl_data_device_get_version(object()) >= 3)
++            m_dragOffer->set_actions(dropActionsToWl(supportedActions), dropActionsToWl(response.acceptedAction()));
++
++        m_dragOffer->accept(m_enterSerial, m_dragOffer->firstFormat());
++    } else {
++        m_dragOffer->accept(m_enterSerial, QString());
++    }
++}
++
++int QWaylandDataDevice::dropActionsToWl(Qt::DropActions actions)
++{
++
++    int wlActions = WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE;
++    if (actions & Qt::CopyAction)
++        wlActions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY;
++    if (actions & (Qt::MoveAction | Qt::TargetMoveAction))
++        wlActions |= WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE;
++
++    // wayland does not support LinkAction at the time of writing
++    return wlActions;
++}
++
++
+ #endif // QT_CONFIG(draganddrop)
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddatadevice_p.h b/qtwayland/src/client/qwaylanddatadevice_p.h
+index 16c3ad28..801dcc2c 100644
+--- a/qtwayland/src/client/qwaylanddatadevice_p.h
++++ b/qtwayland/src/client/qwaylanddatadevice_p.h
+@@ -64,6 +64,7 @@ QT_REQUIRE_CONFIG(wayland_datadevice);
+ QT_BEGIN_NAMESPACE
+ 
+ class QMimeData;
++class QPlatformDragQtResponse;
+ class QWindow;
+ 
+ namespace QtWaylandClient {
+@@ -89,7 +90,7 @@ public:
+ 
+ #if QT_CONFIG(draganddrop)
+     QWaylandDataOffer *dragOffer() const;
+-    bool startDrag(QMimeData *mimeData, QWaylandWindow *icon);
++    bool startDrag(QMimeData *mimeData, Qt::DropActions supportedActions, QWaylandWindow *icon);
+     void cancelDrag();
+ #endif
+ 
+@@ -109,13 +110,16 @@ private Q_SLOTS:
+ 
+ #if QT_CONFIG(draganddrop)
+     void dragSourceCancelled();
+-    void dragSourceTargetChanged(const QString &mimeType);
+ #endif
+ 
+ private:
+ #if QT_CONFIG(draganddrop)
+     QPoint calculateDragPosition(int x, int y, QWindow *wnd) const;
+ #endif
++    void sendResponse(Qt::DropActions supportedActions, const QPlatformDragQtResponse &response);
++
++    static int dropActionsToWl(Qt::DropActions dropActions);
++
+ 
+     QWaylandDisplay *m_display = nullptr;
+     QWaylandInputDevice *m_inputDevice = nullptr;
+diff --git a/qtwayland/src/client/qwaylanddatadevicemanager.cpp b/qtwayland/src/client/qwaylanddatadevicemanager.cpp
+index 35d67307..6dc4f77f 100644
+--- a/qtwayland/src/client/qwaylanddatadevicemanager.cpp
++++ b/qtwayland/src/client/qwaylanddatadevicemanager.cpp
+@@ -50,8 +50,8 @@ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
+-QWaylandDataDeviceManager::QWaylandDataDeviceManager(QWaylandDisplay *display, uint32_t id)
+-    : wl_data_device_manager(display->wl_registry(), id, 1)
++QWaylandDataDeviceManager::QWaylandDataDeviceManager(QWaylandDisplay *display, int version, uint32_t id)
++    : wl_data_device_manager(display->wl_registry(), id, qMin(version, 3))
+     , m_display(display)
+ {
+     // Create transfer devices for all input devices.
+diff --git a/qtwayland/src/client/qwaylanddatadevicemanager_p.h b/qtwayland/src/client/qwaylanddatadevicemanager_p.h
+index bd05c0fb..510d9be4 100644
+--- a/qtwayland/src/client/qwaylanddatadevicemanager_p.h
++++ b/qtwayland/src/client/qwaylanddatadevicemanager_p.h
+@@ -68,7 +68,7 @@ class QWaylandInputDevice;
+ class Q_WAYLAND_CLIENT_EXPORT QWaylandDataDeviceManager : public QtWayland::wl_data_device_manager
+ {
+ public:
+-    QWaylandDataDeviceManager(QWaylandDisplay *display, uint32_t id);
++    QWaylandDataDeviceManager(QWaylandDisplay *display, int version, uint32_t id);
+     ~QWaylandDataDeviceManager() override;
+ 
+     QWaylandDataDevice *getDataDevice(QWaylandInputDevice *inputDevice);
+diff --git a/qtwayland/src/client/qwaylanddataoffer.cpp b/qtwayland/src/client/qwaylanddataoffer.cpp
+index 2297e8a1..fe0ea8c9 100644
+--- a/qtwayland/src/client/qwaylanddataoffer.cpp
++++ b/qtwayland/src/client/qwaylanddataoffer.cpp
+@@ -82,6 +82,15 @@ QMimeData *QWaylandDataOffer::mimeData()
+     return m_mimeData.data();
+ }
+ 
++Qt::DropActions QWaylandDataOffer::supportedActions() const
++{
++    if (wl_data_offer_get_version(const_cast<::wl_data_offer*>(object())) < 3) {
++        return Qt::MoveAction | Qt::CopyAction;
++    }
++
++    return m_supportedActions;
++}
++
+ void QWaylandDataOffer::startReceiving(const QString &mimeType, int fd)
+ {
+     receive(mimeType, fd);
+@@ -93,6 +102,22 @@ void QWaylandDataOffer::data_offer_offer(const QString &mime_type)
+     m_mimeData->appendFormat(mime_type);
+ }
+ 
++void QWaylandDataOffer::data_offer_action(uint32_t dnd_action)
++{
++    Q_UNUSED(dnd_action);
++    // This is the compositor telling the drag target what action it should perform
++    // It does not map nicely into Qt final drop semantics, other than pretending there is only one supported action?
++}
++
++void QWaylandDataOffer::data_offer_source_actions(uint32_t source_actions)
++{
++    m_supportedActions = Qt::DropActions();
++    if (source_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
++        m_supportedActions |= Qt::MoveAction;
++    if (source_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
++        m_supportedActions |= Qt::CopyAction;
++}
++
+ QWaylandMimeData::QWaylandMimeData(QWaylandAbstractDataOffer *dataOffer)
+     : m_dataOffer(dataOffer)
+ {
+@@ -163,17 +188,18 @@ QVariant QWaylandMimeData::retrieveData_sys(const QString &mimeType, QVariant::T
+ 
+ int QWaylandMimeData::readData(int fd, QByteArray &data) const
+ {
+-    fd_set readset;
+-    FD_ZERO(&readset);
+-    FD_SET(fd, &readset);
+-    struct timeval timeout;
++    struct pollfd readset;
++    readset.fd = fd;
++    readset.events = POLLIN;
++    struct timespec timeout;
+     timeout.tv_sec = 1;
+-    timeout.tv_usec = 0;
++    timeout.tv_nsec = 0;
++
+ 
+     Q_FOREVER {
+-        int ready = select(FD_SETSIZE, &readset, nullptr, nullptr, &timeout);
++        int ready = qt_safe_poll(&readset, 1, &timeout);
+         if (ready < 0) {
+-            qWarning() << "QWaylandDataOffer: select() failed";
++            qWarning() << "QWaylandDataOffer: qt_safe_poll() failed";
+             return -1;
+         } else if (ready == 0) {
+             qWarning("QWaylandDataOffer: timeout reading from pipe");
+diff --git a/qtwayland/src/client/qwaylanddataoffer_p.h b/qtwayland/src/client/qwaylanddataoffer_p.h
+index 9cf1483c..6f667398 100644
+--- a/qtwayland/src/client/qwaylanddataoffer_p.h
++++ b/qtwayland/src/client/qwaylanddataoffer_p.h
+@@ -82,6 +82,7 @@ public:
+     explicit QWaylandDataOffer(QWaylandDisplay *display, struct ::wl_data_offer *offer);
+     ~QWaylandDataOffer() override;
+     QMimeData *mimeData() override;
++    Qt::DropActions supportedActions() const;
+ 
+     QString firstFormat() const;
+ 
+@@ -89,10 +90,13 @@ public:
+ 
+ protected:
+     void data_offer_offer(const QString &mime_type) override;
++    void data_offer_source_actions(uint32_t source_actions) override;
++    void data_offer_action(uint32_t dnd_action) override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+     QScopedPointer<QWaylandMimeData> m_mimeData;
++    Qt::DropActions m_supportedActions;
+ };
+ 
+ 
+diff --git a/qtwayland/src/client/qwaylanddatasource.cpp b/qtwayland/src/client/qwaylanddatasource.cpp
+index f45122fb..5599cbd4 100644
+--- a/qtwayland/src/client/qwaylanddatasource.cpp
++++ b/qtwayland/src/client/qwaylanddatasource.cpp
+@@ -101,7 +101,32 @@ void QWaylandDataSource::data_source_send(const QString &mime_type, int32_t fd)
+ 
+ void QWaylandDataSource::data_source_target(const QString &mime_type)
+ {
+-    Q_EMIT targetChanged(mime_type);
++    m_accepted = !mime_type.isEmpty();
++    Q_EMIT dndResponseUpdated(m_accepted, m_dropAction);
++}
++
++void QWaylandDataSource::data_source_action(uint32_t action)
++{
++    Qt::DropAction qtAction = Qt::IgnoreAction;
++
++    if (action == WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
++        qtAction = Qt::MoveAction;
++    else if (action == WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
++        qtAction = Qt::CopyAction;
++
++    m_dropAction = qtAction;
++    Q_EMIT dndResponseUpdated(m_accepted, m_dropAction);
++}
++
++void QWaylandDataSource::data_source_dnd_finished()
++{
++    Q_EMIT finished();
++}
++
++void QWaylandDataSource::data_source_dnd_drop_performed()
++{
++
++    Q_EMIT dndDropped(m_accepted, m_dropAction);
+ }
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddatasource_p.h b/qtwayland/src/client/qwaylanddatasource_p.h
+index 25afff79..96f07bc3 100644
+--- a/qtwayland/src/client/qwaylanddatasource_p.h
++++ b/qtwayland/src/client/qwaylanddatasource_p.h
+@@ -77,17 +77,25 @@ public:
+     QMimeData *mimeData() const;
+ 
+ Q_SIGNALS:
+-    void targetChanged(const QString &mime_type);
+     void cancelled();
++    void finished();
++
++    void dndResponseUpdated(bool accepted, Qt::DropAction action);
++    void dndDropped(bool accepted, Qt::DropAction action);
+ 
+ protected:
+     void data_source_cancelled() override;
+     void data_source_send(const QString &mime_type, int32_t fd) override;
+     void data_source_target(const QString &mime_type) override;
++    void data_source_dnd_drop_performed() override;
++    void data_source_dnd_finished() override;
++    void data_source_action(uint32_t action) override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+     QMimeData *m_mime_data = nullptr;
++    bool m_accepted = false;
++    Qt::DropAction m_dropAction = Qt::IgnoreAction;
+ };
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddisplay.cpp b/qtwayland/src/client/qwaylanddisplay.cpp
+index f10c1f79..c01e238b 100644
+--- a/qtwayland/src/client/qwaylanddisplay.cpp
++++ b/qtwayland/src/client/qwaylanddisplay.cpp
+@@ -85,10 +85,203 @@
+ 
+ #include <errno.h>
+ 
++#include <tuple> // for std::tie
++
++static void checkWaylandError(struct wl_display *display)
++{
++    int ecode = wl_display_get_error(display);
++    if ((ecode == EPIPE || ecode == ECONNRESET)) {
++        // special case this to provide a nicer error
++        qWarning("The Wayland connection broke. Did the Wayland compositor die?");
++    } else {
++        qWarning("The Wayland connection experienced a fatal error: %s", strerror(ecode));
++    }
++    _exit(1);
++}
++
+ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
++class EventThread : public QThread
++{
++    Q_OBJECT
++public:
++    enum OperatingMode {
++        EmitToDispatch, // Emit the signal, allow dispatching in a differnt thread.
++        SelfDispatch, // Dispatch the events inside this thread.
++    };
++
++    EventThread(struct wl_display * wl, struct wl_event_queue * ev_queue,
++                OperatingMode mode)
++        : m_fd(wl_display_get_fd(wl))
++        , m_pipefd{ -1, -1 }
++        , m_wldisplay(wl)
++        , m_wlevqueue(ev_queue)
++        , m_mode(mode)
++        , m_reading(true)
++        , m_quitting(false)
++    {
++        setObjectName(QStringLiteral("WaylandEventThread"));
++    }
++
++    void readAndDispatchEvents()
++    {
++        /*
++         * Dispatch pending events and flush the requests at least once. If the event thread
++         * is not reading, try to call _prepare_read() to allow the event thread to poll().
++         * If that fails, re-try dispatch & flush again until _prepare_read() is successful.
++         *
++         * This allow any call to readAndDispatchEvents() to start event thread's polling,
++         * not only the one issued from event thread's waitForReading(), which means functions
++         * called from dispatch_pending() can safely spin an event loop.
++         */
++        for (;;) {
++            if (dispatchQueuePending() < 0) {
++                checkWaylandError(m_wldisplay);
++                return;
++            }
++
++            wl_display_flush(m_wldisplay);
++
++            // We have to check if event thread is reading every time we dispatch
++            // something, as that may recursively call this function.
++            if (m_reading.loadAcquire())
++                break;
++
++            if (prepareReadQueue() == 0) {
++                QMutexLocker l(&m_mutex);
++                m_reading.storeRelease(true);
++                m_cond.wakeOne();
++                break;
++            }
++        }
++    }
++
++    void stop()
++    {
++        // We have to both write to the pipe and set the flag, as the thread may be
++        // either in the poll() or waiting for _prepare_read().
++        if (m_pipefd[1] != -1 && write(m_pipefd[1], "\0", 1) == -1)
++            qWarning("Failed to write to the pipe: %s.", strerror(errno));
++
++        {
++            QMutexLocker l(&m_mutex);
++            m_quitting = true;
++            m_cond.wakeOne();
++        }
++
++        wait();
++    }
++
++Q_SIGNALS:
++    void needReadAndDispatch();
++
++protected:
++    void run() override
++    {
++        // we use this pipe to make the loop exit otherwise if we simply used a flag on the loop condition, if stop() gets
++        // called while poll() is blocking the thread will never quit since there are no wayland messages coming anymore.
++        struct Pipe
++        {
++            Pipe(int *fds)
++                : fds(fds)
++            {
++                if (qt_safe_pipe(fds) != 0)
++                    qWarning("Pipe creation failed. Quitting may hang.");
++            }
++            ~Pipe()
++            {
++                if (fds[0] != -1) {
++                    close(fds[0]);
++                    close(fds[1]);
++                }
++            }
++
++            int *fds;
++        } pipe(m_pipefd);
++
++        // Make the main thread call wl_prepare_read(), dispatch the pending messages and flush the
++        // outbound ones. Wait until it's done before proceeding, unless we're told to quit.
++        while (waitForReading()) {
++            pollfd fds[2] = { { m_fd, POLLIN, 0 }, { m_pipefd[0], POLLIN, 0 } };
++            poll(fds, 2, -1);
++
++            if (fds[1].revents & POLLIN) {
++                // we don't really care to read the byte that was written here since we're closing down
++                wl_display_cancel_read(m_wldisplay);
++                break;
++            }
++
++            if (fds[0].revents & POLLIN)
++                wl_display_read_events(m_wldisplay);
++                // The polll was succesfull and the event thread did the wl_display_read_events(). On the next iteration of the loop
++                // the event sent to the main thread will cause it to dispatch the messages just read, unless the loop exits in which
++                // case we don't care anymore about them.
++            else
++                wl_display_cancel_read(m_wldisplay);
++        }
++    }
++
++private:
++    bool waitForReading()
++    {
++        Q_ASSERT(QThread::currentThread() == this);
++
++        m_reading.storeRelease(false);
++
++        if (m_mode == SelfDispatch) {
++            readAndDispatchEvents();
++        } else {
++            Q_EMIT needReadAndDispatch();
++
++            QMutexLocker lock(&m_mutex);
++            // m_reading might be set from our emit or some other invocation of
++            // readAndDispatchEvents().
++            while (!m_reading.loadRelaxed() && !m_quitting)
++                m_cond.wait(&m_mutex);
++        }
++
++        return !m_quitting;
++    }
++
++    int dispatchQueuePending()
++    {
++        if (m_wlevqueue)
++            return wl_display_dispatch_queue_pending(m_wldisplay, m_wlevqueue);
++        else
++            return wl_display_dispatch_pending(m_wldisplay);
++    }
++
++    int prepareReadQueue()
++    {
++        if (m_wlevqueue)
++            return wl_display_prepare_read_queue(m_wldisplay, m_wlevqueue);
++        else
++            return wl_display_prepare_read(m_wldisplay);
++    }
++
++    int m_fd;
++    int m_pipefd[2];
++    wl_display *m_wldisplay;
++    wl_event_queue *m_wlevqueue;
++    OperatingMode m_mode;
++
++    /* Concurrency note when operating in EmitToDispatch mode:
++     * m_reading is set to false inside event thread's waitForReading(), and is
++     * set to true inside main thread's readAndDispatchEvents().
++     * The lock is not taken when setting m_reading to false, as the main thread
++     * is not actively waiting for it to turn false. However, the lock is taken
++     * inside readAndDispatchEvents() before setting m_reading to true,
++     * as the event thread is actively waiting for it under the wait condition.
++     */
++
++    QAtomicInteger<bool> m_reading;
++    bool m_quitting;
++    QMutex m_mutex;
++    QWaitCondition m_cond;
++};
++
+ Q_LOGGING_CATEGORY(lcQpaWayland, "qt.qpa.wayland"); // for general (uncategorized) Wayland platform logging
+ 
+ struct wl_surface *QWaylandDisplay::createSurface(void *handle)
+@@ -158,17 +351,16 @@ QWaylandDisplay::QWaylandDisplay(QWaylandIntegration *waylandIntegration)
+     if (!mXkbContext)
+         qCWarning(lcQpaWayland, "failed to create xkb context");
+ #endif
+-
+-    forceRoundTrip();
+-
+-    if (!mWaitingScreens.isEmpty()) {
+-        // Give wl_output.done and zxdg_output_v1.done events a chance to arrive
+-        forceRoundTrip();
+-    }
+ }
+ 
+ QWaylandDisplay::~QWaylandDisplay(void)
+ {
++    if (m_eventThread)
++        m_eventThread->stop();
++
++    if (m_frameEventQueueThread)
++        m_frameEventQueueThread->stop();
++
+     if (mSyncCallback)
+         wl_callback_destroy(mSyncCallback);
+ 
+@@ -187,6 +379,21 @@ QWaylandDisplay::~QWaylandDisplay(void)
+ #endif
+     if (mDisplay)
+         wl_display_disconnect(mDisplay);
++
++    if (m_frameEventQueue)
++        wl_event_queue_destroy(m_frameEventQueue);
++}
++
++// Steps which is called just after constructor. This separates registry_global() out of the constructor
++// so that factory functions in integration can be overridden.
++void QWaylandDisplay::initialize()
++{
++    forceRoundTrip();
++
++    if (!mWaitingScreens.isEmpty()) {
++        // Give wl_output.done and zxdg_output_v1.done events a chance to arrive
++        forceRoundTrip();
++    }
+ }
+ 
+ void QWaylandDisplay::ensureScreen()
+@@ -203,98 +410,37 @@ void QWaylandDisplay::ensureScreen()
+ 
+ void QWaylandDisplay::checkError() const
+ {
+-    int ecode = wl_display_get_error(mDisplay);
+-    if ((ecode == EPIPE || ecode == ECONNRESET)) {
+-        // special case this to provide a nicer error
+-        qWarning("The Wayland connection broke. Did the Wayland compositor die?");
+-    } else {
+-        qWarning("The Wayland connection experienced a fatal error: %s", strerror(ecode));
+-    }
+-    _exit(1);
++    checkWaylandError(mDisplay);
+ }
+ 
++// Called in main thread, either from queued signal or directly.
+ void QWaylandDisplay::flushRequests()
+ {
+-    if (wl_display_prepare_read(mDisplay) == 0) {
+-        wl_display_read_events(mDisplay);
+-    }
+-
+-    if (wl_display_dispatch_pending(mDisplay) < 0)
+-        checkError();
+-
+-    {
+-        QReadLocker locker(&m_frameQueueLock);
+-        for (const FrameQueue &q : mExternalQueues) {
+-            QMutexLocker locker(q.mutex);
+-            while (wl_display_prepare_read_queue(mDisplay, q.queue) != 0)
+-                wl_display_dispatch_queue_pending(mDisplay, q.queue);
+-            wl_display_read_events(mDisplay);
+-            wl_display_dispatch_queue_pending(mDisplay, q.queue);
+-        }
+-    }
+-
+-    wl_display_flush(mDisplay);
+-}
+-
+-void QWaylandDisplay::blockingReadEvents()
+-{
+-    if (wl_display_dispatch(mDisplay) < 0)
+-        checkError();
+-}
+-
+-void QWaylandDisplay::destroyFrameQueue(const QWaylandDisplay::FrameQueue &q)
+-{
+-    QWriteLocker locker(&m_frameQueueLock);
+-    auto it = std::find_if(mExternalQueues.begin(),
+-                           mExternalQueues.end(),
+-                           [&q] (const QWaylandDisplay::FrameQueue &other){ return other.queue == q.queue; });
+-    Q_ASSERT(it != mExternalQueues.end());
+-    mExternalQueues.erase(it);
+-    if (q.queue != nullptr)
+-        wl_event_queue_destroy(q.queue);
+-    delete q.mutex;
++    m_eventThread->readAndDispatchEvents();
+ }
+ 
+-QWaylandDisplay::FrameQueue QWaylandDisplay::createFrameQueue()
++// We have to wait until we have an eventDispatcher before creating the eventThread,
++// otherwise forceRoundTrip() may block inside _events_read() because eventThread is
++// polling.
++void QWaylandDisplay::initEventThread()
+ {
+-    QWriteLocker locker(&m_frameQueueLock);
+-    FrameQueue q{createEventQueue()};
+-    mExternalQueues.append(q);
+-    return q;
+-}
++    m_eventThread.reset(
++            new EventThread(mDisplay, /* default queue */ nullptr, EventThread::EmitToDispatch));
++    connect(m_eventThread.get(), &EventThread::needReadAndDispatch, this,
++            &QWaylandDisplay::flushRequests, Qt::QueuedConnection);
++    m_eventThread->start();
+ 
+-wl_event_queue *QWaylandDisplay::createEventQueue()
+-{
+-    return wl_display_create_queue(mDisplay);
++    // wl_display_disconnect() free this.
++    m_frameEventQueue = wl_display_create_queue(mDisplay);
++    m_frameEventQueueThread.reset(
++            new EventThread(mDisplay, m_frameEventQueue, EventThread::SelfDispatch));
++    m_frameEventQueueThread->start();
+ }
+ 
+-void QWaylandDisplay::dispatchQueueWhile(wl_event_queue *queue, std::function<bool ()> condition, int timeout)
++void QWaylandDisplay::blockingReadEvents()
+ {
+-    if (!condition())
+-        return;
+-
+-    QElapsedTimer timer;
+-    timer.start();
+-    struct pollfd pFd = qt_make_pollfd(wl_display_get_fd(mDisplay), POLLIN);
+-    while (timeout == -1 || timer.elapsed() < timeout) {
+-        while (wl_display_prepare_read_queue(mDisplay, queue) != 0)
+-            wl_display_dispatch_queue_pending(mDisplay, queue);
+-
+-        wl_display_flush(mDisplay);
+-
+-        const int remaining = qMax(timeout - timer.elapsed(), 0ll);
+-        const int pollTimeout = timeout == -1 ? -1 : remaining;
+-        if (qt_poll_msecs(&pFd, 1, pollTimeout) > 0)
+-            wl_display_read_events(mDisplay);
+-        else
+-            wl_display_cancel_read(mDisplay);
+-
+-        if (wl_display_dispatch_queue_pending(mDisplay, queue) < 0)
+-            checkError();
+-
+-        if (!condition())
+-            break;
+-    }
++    if (wl_display_dispatch(mDisplay) < 0)
++        checkWaylandError(mDisplay);
+ }
+ 
+ QWaylandScreen *QWaylandDisplay::screenForOutput(struct wl_output *output) const
+@@ -345,7 +491,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+     if (interface == QStringLiteral("wl_output")) {
+         mWaitingScreens << new QWaylandScreen(this, version, id);
+     } else if (interface == QStringLiteral("wl_compositor")) {
+-        mCompositorVersion = qMin((int)version, 3);
++        mCompositorVersion = qMin((int)version, 4);
+         mCompositor.init(registry, id, mCompositorVersion);
+     } else if (interface == QStringLiteral("wl_shm")) {
+         mShm.reset(new QWaylandShm(this, version, id));
+@@ -354,7 +500,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+         mInputDevices.append(inputDevice);
+ #if QT_CONFIG(wayland_datadevice)
+     } else if (interface == QStringLiteral("wl_data_device_manager")) {
+-        mDndSelectionHandler.reset(new QWaylandDataDeviceManager(this, id));
++        mDndSelectionHandler.reset(new QWaylandDataDeviceManager(this, version, id));
+ #endif
+     } else if (interface == QStringLiteral("qt_surface_extension")) {
+         mWindowExtension.reset(new QtWayland::qt_surface_extension(registry, id, 1));
+@@ -369,6 +515,8 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
+ #if QT_CONFIG(wayland_client_primary_selection)
+     } else if (interface == QStringLiteral("zwp_primary_selection_device_manager_v1")) {
+         mPrimarySelectionManager.reset(new QWaylandPrimarySelectionDeviceManagerV1(this, id, 1));
++        for (QWaylandInputDevice *inputDevice : qAsConst(mInputDevices))
++            inputDevice->setPrimarySelectionDevice(mPrimarySelectionManager->createDevice(inputDevice));
+ #endif
+     } else if (interface == QStringLiteral("zwp_text_input_manager_v2") && !mClientSideInputContextRequested) {
+         mTextInputManager.reset(new QtWayland::zwp_text_input_manager_v2(registry, id, 1));
+@@ -427,6 +575,13 @@ void QWaylandDisplay::registry_global_remove(uint32_t id)
+                     inputDevice->setTextInput(nullptr);
+                 mWaylandIntegration->reconfigureInputContext();
+             }
++#if QT_CONFIG(wayland_client_primary_selection)
++            if (global.interface == QStringLiteral("zwp_primary_selection_device_manager_v1")) {
++                mPrimarySelectionManager.reset();
++                for (QWaylandInputDevice *inputDevice : qAsConst(mInputDevices))
++                    inputDevice->setPrimarySelectionDevice(nullptr);
++            }
++#endif
+             mGlobals.removeAt(i);
+             break;
+         }
+@@ -452,9 +607,10 @@ void QWaylandDisplay::addRegistryListener(RegistryListener listener, void *data)
+ 
+ void QWaylandDisplay::removeListener(RegistryListener listener, void *data)
+ {
+-    std::remove_if(mRegistryListeners.begin(), mRegistryListeners.end(), [=](Listener l){
++    auto iter = std::remove_if(mRegistryListeners.begin(), mRegistryListeners.end(), [=](Listener l){
+         return (l.listener == listener && l.data == data);
+     });
++    mRegistryListeners.erase(iter, mRegistryListeners.end());
+ }
+ 
+ uint32_t QWaylandDisplay::currentTimeMillisec()
+@@ -467,50 +623,9 @@ uint32_t QWaylandDisplay::currentTimeMillisec()
+     return 0;
+ }
+ 
+-static void
+-sync_callback(void *data, struct wl_callback *callback, uint32_t serial)
+-{
+-    Q_UNUSED(serial)
+-    bool *done = static_cast<bool *>(data);
+-
+-    *done = true;
+-
+-    // If the wl_callback done event is received after the condition check in the while loop in
+-    // forceRoundTrip(), but before the call to processEvents, the call to processEvents may block
+-    // forever if no more events are posted (eventhough the callback is handled in response to the
+-    // aboutToBlock signal). Hence, we wake up the event dispatcher so forceRoundTrip may return.
+-    // (QTBUG-64696)
+-    if (auto *dispatcher = QThread::currentThread()->eventDispatcher())
+-        dispatcher->wakeUp();
+-
+-    wl_callback_destroy(callback);
+-}
+-
+-static const struct wl_callback_listener sync_listener = {
+-    sync_callback
+-};
+-
+ void QWaylandDisplay::forceRoundTrip()
+ {
+-    // wl_display_roundtrip() works on the main queue only,
+-    // but we use a separate one, so basically reimplement it here
+-    int ret = 0;
+-    bool done = false;
+-    wl_callback *callback = wl_display_sync(mDisplay);
+-    wl_callback_add_listener(callback, &sync_listener, &done);
+-    flushRequests();
+-    if (QThread::currentThread()->eventDispatcher()) {
+-        while (!done && ret >= 0) {
+-            QThread::currentThread()->eventDispatcher()->processEvents(QEventLoop::WaitForMoreEvents);
+-            ret = wl_display_dispatch_pending(mDisplay);
+-        }
+-    } else {
+-        while (!done && ret >= 0)
+-            ret = wl_display_dispatch(mDisplay);
+-    }
+-
+-    if (ret == -1 && !done)
+-        wl_callback_destroy(callback);
++     wl_display_roundtrip(mDisplay);
+ }
+ 
+ bool QWaylandDisplay::supportsWindowDecoration() const
+@@ -574,14 +689,10 @@ void QWaylandDisplay::handleKeyboardFocusChanged(QWaylandInputDevice *inputDevic
+     if (mLastKeyboardFocus == keyboardFocus)
+         return;
+ 
+-    if (mWaylandIntegration->mShellIntegration) {
+-        mWaylandIntegration->mShellIntegration->handleKeyboardFocusChanged(keyboardFocus, mLastKeyboardFocus);
+-    } else {
+-        if (keyboardFocus)
+-            handleWindowActivated(keyboardFocus);
+-        if (mLastKeyboardFocus)
+-            handleWindowDeactivated(mLastKeyboardFocus);
+-    }
++    if (keyboardFocus)
++        handleWindowActivated(keyboardFocus);
++    if (mLastKeyboardFocus)
++        handleWindowDeactivated(mLastKeyboardFocus);
+ 
+     mLastKeyboardFocus = keyboardFocus;
+ }
+@@ -600,6 +711,19 @@ void QWaylandDisplay::handleWaylandSync()
+     QWindow *activeWindow = mActiveWindows.empty() ? nullptr : mActiveWindows.last()->window();
+     if (activeWindow != QGuiApplication::focusWindow())
+         QWindowSystemInterface::handleWindowActivated(activeWindow);
++
++    if (!activeWindow) {
++        if (lastInputDevice()) {
++#if QT_CONFIG(clipboard)
++            if (auto *dataDevice = lastInputDevice()->dataDevice())
++                dataDevice->invalidateSelectionOffer();
++#endif
++#if QT_CONFIG(wayland_client_primary_selection)
++            if (auto *device = lastInputDevice()->primarySelectionDevice())
++                device->invalidateSelectionOffer();
++#endif
++        }
++    }
+ }
+ 
+ const wl_callback_listener QWaylandDisplay::syncCallbackListener = {
+@@ -626,6 +750,13 @@ QWaylandInputDevice *QWaylandDisplay::defaultInputDevice() const
+     return mInputDevices.isEmpty() ? 0 : mInputDevices.first();
+ }
+ 
++bool QWaylandDisplay::isKeyboardAvailable() const
++{
++    return std::any_of(
++            mInputDevices.constBegin(), mInputDevices.constEnd(),
++            [this](const QWaylandInputDevice *device) { return device->keyboard() != nullptr; });
++}
++
+ #if QT_CONFIG(cursor)
+ 
+ QWaylandCursor *QWaylandDisplay::waylandCursor()
+@@ -652,4 +783,6 @@ QWaylandCursorTheme *QWaylandDisplay::loadCursorTheme(const QString &name, int p
+ 
+ } // namespace QtWaylandClient
+ 
++#include "qwaylanddisplay.moc"
++
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/client/qwaylanddisplay_p.h b/qtwayland/src/client/qwaylanddisplay_p.h
+index 3b092bc8..42bc661d 100644
+--- a/qtwayland/src/client/qwaylanddisplay_p.h
++++ b/qtwayland/src/client/qwaylanddisplay_p.h
+@@ -109,6 +109,7 @@ class QWaylandSurface;
+ class QWaylandShellIntegration;
+ class QWaylandCursor;
+ class QWaylandCursorTheme;
++class EventThread;
+ 
+ typedef void (*RegistryListener)(void *data,
+                                  struct wl_registry *registry,
+@@ -120,15 +121,11 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandDisplay : public QObject, public QtWayland
+     Q_OBJECT
+ 
+ public:
+-    struct FrameQueue {
+-        FrameQueue(wl_event_queue *q = nullptr) : queue(q), mutex(new QMutex) {}
+-        wl_event_queue *queue;
+-        QMutex *mutex;
+-    };
+-
+     QWaylandDisplay(QWaylandIntegration *waylandIntegration);
+     ~QWaylandDisplay(void) override;
+ 
++    void initialize();
++
+ #if QT_CONFIG(xkbcommon)
+     struct xkb_context *xkbContext() const { return mXkbContext.get(); }
+ #endif
+@@ -210,11 +207,11 @@ public:
+     void handleKeyboardFocusChanged(QWaylandInputDevice *inputDevice);
+     void handleWindowDestroyed(QWaylandWindow *window);
+ 
+-    wl_event_queue *createEventQueue();
+-    FrameQueue createFrameQueue();
+-    void destroyFrameQueue(const FrameQueue &q);
+-    void dispatchQueueWhile(wl_event_queue *queue, std::function<bool()> condition, int timeout = -1);
++    wl_event_queue *frameEventQueue() { return m_frameEventQueue; };
++
++    bool isKeyboardAvailable() const;
+ 
++    void initEventThread();
+ public slots:
+     void blockingReadEvents();
+     void flushRequests();
+@@ -237,6 +234,9 @@ private:
+     };
+ 
+     struct wl_display *mDisplay = nullptr;
++    QScopedPointer<EventThread> m_eventThread;
++    wl_event_queue *m_frameEventQueue = nullptr;
++    QScopedPointer<EventThread> m_frameEventQueueThread;
+     QtWayland::wl_compositor mCompositor;
+     QScopedPointer<QWaylandShm> mShm;
+     QList<QWaylandScreen *> mWaitingScreens;
+@@ -273,11 +273,9 @@ private:
+     QWaylandInputDevice *mLastInputDevice = nullptr;
+     QPointer<QWaylandWindow> mLastInputWindow;
+     QPointer<QWaylandWindow> mLastKeyboardFocus;
+-    QVector<QWaylandWindow *> mActiveWindows;
+-    QVector<FrameQueue> mExternalQueues;
++    QList<QWaylandWindow *> mActiveWindows;
+     struct wl_callback *mSyncCallback = nullptr;
+     static const wl_callback_listener syncCallbackListener;
+-    QReadWriteLock m_frameQueueLock;
+ 
+     bool mClientSideInputContextRequested = !QPlatformInputContextFactory::requested().isNull();
+ 
+diff --git a/qtwayland/src/client/qwaylanddnd.cpp b/qtwayland/src/client/qwaylanddnd.cpp
+index 6535aa16..7c53f5fa 100644
+--- a/qtwayland/src/client/qwaylanddnd.cpp
++++ b/qtwayland/src/client/qwaylanddnd.cpp
+@@ -66,7 +66,7 @@ void QWaylandDrag::startDrag()
+ {
+     QBasicDrag::startDrag();
+     QWaylandWindow *icon = static_cast<QWaylandWindow *>(shapedPixmapWindow()->handle());
+-    if (m_display->currentInputDevice()->dataDevice()->startDrag(drag()->mimeData(), icon)) {
++    if (m_display->currentInputDevice()->dataDevice()->startDrag(drag()->mimeData(), drag()->supportedActions(), icon)) {
+         icon->addAttachOffset(-drag()->hotSpot());
+     } else {
+         // Cancelling immediately does not work, since the event loop for QDrag::exec is started
+@@ -80,6 +80,9 @@ void QWaylandDrag::cancel()
+     QBasicDrag::cancel();
+ 
+     m_display->currentInputDevice()->dataDevice()->cancelDrag();
++
++    if (drag())
++        drag()->deleteLater();
+ }
+ 
+ void QWaylandDrag::move(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods)
+@@ -103,33 +106,41 @@ void QWaylandDrag::endDrag()
+     m_display->currentInputDevice()->handleEndDrag();
+ }
+ 
+-void QWaylandDrag::updateTarget(const QString &mimeType)
++void QWaylandDrag::setResponse(bool accepted)
+ {
+-    setCanDrop(!mimeType.isEmpty());
+-
+-    if (canDrop()) {
+-        updateCursor(defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers()));
+-    } else {
+-        updateCursor(Qt::IgnoreAction);
+-    }
++    // This method is used for old DataDevices where the drag action is not communicated
++    Qt::DropAction action = defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers());
++    setResponse(QPlatformDropQtResponse(accepted, action));
+ }
+ 
+-void QWaylandDrag::setResponse(const QPlatformDragQtResponse &response)
++void QWaylandDrag::setResponse(const QPlatformDropQtResponse &response)
+ {
+     setCanDrop(response.isAccepted());
+ 
+     if (canDrop()) {
+-        updateCursor(defaultAction(drag()->supportedActions(), m_display->currentInputDevice()->modifiers()));
++        updateCursor(response.acceptedAction());
+     } else {
+         updateCursor(Qt::IgnoreAction);
+     }
+ }
+ 
+-void QWaylandDrag::finishDrag(const QPlatformDropQtResponse &response)
++void QWaylandDrag::setDropResponse(const QPlatformDropQtResponse &response)
+ {
+     setExecutedDropAction(response.acceptedAction());
++}
++
++void QWaylandDrag::finishDrag()
++{
+     QKeyEvent event(QEvent::KeyPress, Qt::Key_Escape, Qt::NoModifier);
+     eventFilter(shapedPixmapWindow(), &event);
++
++    if (drag())
++        drag()->deleteLater();
++}
++
++bool QWaylandDrag::ownsDragObject() const
++{
++    return true;
+ }
+ 
+ }
+diff --git a/qtwayland/src/client/qwaylanddnd_p.h b/qtwayland/src/client/qwaylanddnd_p.h
+index 474fe2ab..46f629ac 100644
+--- a/qtwayland/src/client/qwaylanddnd_p.h
++++ b/qtwayland/src/client/qwaylanddnd_p.h
+@@ -71,9 +71,10 @@ public:
+     QWaylandDrag(QWaylandDisplay *display);
+     ~QWaylandDrag() override;
+ 
+-    void updateTarget(const QString &mimeType);
+-    void setResponse(const QPlatformDragQtResponse &response);
+-    void finishDrag(const QPlatformDropQtResponse &response);
++    void setResponse(bool accepted);
++    void setResponse(const QPlatformDropQtResponse &response);
++    void setDropResponse(const QPlatformDropQtResponse &response);
++    void finishDrag();
+ 
+ protected:
+     void startDrag() override;
+@@ -82,6 +83,7 @@ protected:
+     void drop(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods) override;
+     void endDrag() override;
+ 
++    bool ownsDragObject() const override;
+ 
+ private:
+     QWaylandDisplay *m_display = nullptr;
+diff --git a/qtwayland/src/client/qwaylandinputdevice.cpp b/qtwayland/src/client/qwaylandinputdevice.cpp
+index 613fe862..4b90de84 100644
+--- a/qtwayland/src/client/qwaylandinputdevice.cpp
++++ b/qtwayland/src/client/qwaylandinputdevice.cpp
+@@ -685,6 +685,11 @@ public:
+ 
+ void QWaylandInputDevice::Pointer::pointer_leave(uint32_t time, struct wl_surface *surface)
+ {
++    invalidateFocus();
++    mButtons = Qt::NoButton;
++
++    mParent->mTime = time;
++
+     // The event may arrive after destroying the window, indicated by
+     // a null surface.
+     if (!surface)
+@@ -696,11 +701,6 @@ void QWaylandInputDevice::Pointer::pointer_leave(uint32_t time, struct wl_surfac
+ 
+     if (!QWaylandWindow::mouseGrab())
+         setFrameEvent(new LeaveEvent(window, mSurfacePos, mGlobalPos));
+-
+-    invalidateFocus();
+-    mButtons = Qt::NoButton;
+-
+-    mParent->mTime = time;
+ }
+ 
+ class MotionEvent : public QWaylandPointerEvent
+@@ -1300,14 +1300,6 @@ void QWaylandInputDevice::Keyboard::handleFocusDestroyed()
+ void QWaylandInputDevice::Keyboard::handleFocusLost()
+ {
+     mFocus = nullptr;
+-#if QT_CONFIG(clipboard)
+-    if (auto *dataDevice = mParent->dataDevice())
+-        dataDevice->invalidateSelectionOffer();
+-#endif
+-#if QT_CONFIG(wayland_client_primary_selection)
+-    if (auto *device = mParent->primarySelectionDevice())
+-        device->invalidateSelectionOffer();
+-#endif
+     mParent->mQDisplay->handleKeyboardFocusChanged(mParent);
+     mRepeatTimer.stop();
+ }
+@@ -1396,6 +1388,7 @@ void QWaylandInputDevice::Touch::touch_cancel()
+     if (touchExt)
+         touchExt->touchCanceled();
+ 
++    mFocus = nullptr;
+     QWindowSystemInterface::handleTouchCancelEvent(nullptr, mParent->mTouchDevice);
+ }
+ 
+diff --git a/qtwayland/src/client/qwaylandintegration.cpp b/qtwayland/src/client/qwaylandintegration.cpp
+index c53ccb78..54861600 100644
+--- a/qtwayland/src/client/qwaylandintegration.cpp
++++ b/qtwayland/src/client/qwaylandintegration.cpp
+@@ -125,6 +125,9 @@ QWaylandIntegration::QWaylandIntegration()
+ #endif
+ 
+     reconfigureInputContext();
++
++    QWaylandWindow::fixedToplevelPositions =
++            !qEnvironmentVariableIsSet("QT_WAYLAND_DISABLE_FIXED_POSITIONS");
+ }
+ 
+ QWaylandIntegration::~QWaylandIntegration()
+@@ -192,14 +195,18 @@ QAbstractEventDispatcher *QWaylandIntegration::createEventDispatcher() const
+ 
+ void QWaylandIntegration::initialize()
+ {
++    mDisplay->initEventThread();
++
++    // Call after eventDispatcher is fully connected, for QWaylandDisplay::forceRoundTrip()
++    mDisplay->initialize();
++
++    // But the aboutToBlock() and awake() should be connected after initializePlatform().
++    // Otherwise the connected flushRequests() may consumes up all events before processEvents starts to wait,
++    // so that processEvents(QEventLoop::WaitForMoreEvents) may be blocked in the forceRoundTrip().
+     QAbstractEventDispatcher *dispatcher = QGuiApplicationPrivate::eventDispatcher;
+     QObject::connect(dispatcher, SIGNAL(aboutToBlock()), mDisplay.data(), SLOT(flushRequests()));
+     QObject::connect(dispatcher, SIGNAL(awake()), mDisplay.data(), SLOT(flushRequests()));
+ 
+-    int fd = wl_display_get_fd(mDisplay->wl_display());
+-    QSocketNotifier *sn = new QSocketNotifier(fd, QSocketNotifier::Read, mDisplay.data());
+-    QObject::connect(sn, SIGNAL(activated(QSocketDescriptor)), mDisplay.data(), SLOT(flushRequests()));
+-
+     // Qt does not support running with no screens
+     mDisplay->ensureScreen();
+ }
+@@ -262,6 +269,14 @@ QWaylandDisplay *QWaylandIntegration::display() const
+     return mDisplay.data();
+ }
+ 
++Qt::KeyboardModifiers QWaylandIntegration::queryKeyboardModifiers() const
++{
++    if (auto *seat = mDisplay->currentInputDevice()) {
++        return seat->modifiers();
++    }
++    return Qt::NoModifier;
++}
++
+ QList<int> QWaylandIntegration::possibleKeys(const QKeyEvent *event) const
+ {
+     if (auto *seat = mDisplay->currentInputDevice())
+@@ -479,7 +494,7 @@ void QWaylandIntegration::reconfigureInputContext()
+     }
+ #endif
+ 
+-    qCDebug(lcQpaWayland) << "using input method:" << inputContext()->metaObject()->className();
++    qCDebug(lcQpaWayland) << "using input method:" << (inputContext() ? inputContext()->metaObject()->className() : "<none>");
+ }
+ 
+ QWaylandShellIntegration *QWaylandIntegration::createShellIntegration(const QString &integrationName)
+diff --git a/qtwayland/src/client/qwaylandintegration_p.h b/qtwayland/src/client/qwaylandintegration_p.h
+index ff70ae25..73b80658 100644
+--- a/qtwayland/src/client/qwaylandintegration_p.h
++++ b/qtwayland/src/client/qwaylandintegration_p.h
+@@ -107,6 +107,8 @@ public:
+ 
+     QWaylandDisplay *display() const;
+ 
++    Qt::KeyboardModifiers queryKeyboardModifiers() const override;
++
+     QList<int> possibleKeys(const QKeyEvent *event) const override;
+ 
+     QStringList themeNames() const override;
+diff --git a/qtwayland/src/client/qwaylandprimaryselectionv1.cpp b/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
+index 832f9678..ea508771 100644
+--- a/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
++++ b/qtwayland/src/client/qwaylandprimaryselectionv1.cpp
+@@ -54,11 +54,6 @@ QWaylandPrimarySelectionDeviceManagerV1::QWaylandPrimarySelectionDeviceManagerV1
+     : zwp_primary_selection_device_manager_v1(display->wl_registry(), id, qMin(version, uint(1)))
+     , m_display(display)
+ {
+-    // Create devices for all seats.
+-    // This only works if we get the global before all devices
+-    const auto seats = m_display->inputDevices();
+-    for (auto *seat : seats)
+-        seat->setPrimarySelectionDevice(createDevice(seat));
+ }
+ 
+ QWaylandPrimarySelectionDeviceV1 *QWaylandPrimarySelectionDeviceManagerV1::createDevice(QWaylandInputDevice *seat)
+diff --git a/qtwayland/src/client/qwaylandscreen.cpp b/qtwayland/src/client/qwaylandscreen.cpp
+index 6cb337de..5537dafd 100644
+--- a/qtwayland/src/client/qwaylandscreen.cpp
++++ b/qtwayland/src/client/qwaylandscreen.cpp
+@@ -60,7 +60,7 @@ QWaylandXdgOutputManagerV1::QWaylandXdgOutputManagerV1(QWaylandDisplay* display,
+ }
+ 
+ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uint32_t id)
+-    : QtWayland::wl_output(waylandDisplay->wl_registry(), id, qMin(version, 2))
++    : QtWayland::wl_output(waylandDisplay->wl_registry(), id, qMin(version, 3))
+     , m_outputId(id)
+     , mWaylandDisplay(waylandDisplay)
+     , mOutputName(QStringLiteral("Screen%1").arg(id))
+@@ -72,7 +72,7 @@ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uin
+         qCWarning(lcQpaWayland) << "wl_output done event not supported by compositor,"
+                                 << "QScreen may not work correctly";
+         mWaylandDisplay->forceRoundTrip(); // Give the compositor a chance to send geometry etc.
+-        mOutputDone = true; // Fake the done event
++        mProcessedEvents |= OutputDoneEvent; // Fake the done event
+         maybeInitialize();
+     }
+ }
+@@ -81,16 +81,29 @@ QWaylandScreen::~QWaylandScreen()
+ {
+     if (zxdg_output_v1::isInitialized())
+         zxdg_output_v1::destroy();
++    if (wl_output::isInitialized() && wl_output_get_version(wl_output::object()) >= WL_OUTPUT_RELEASE_SINCE_VERSION)
++        wl_output::release();
++}
++
++uint QWaylandScreen::requiredEvents() const
++{
++    uint ret = OutputDoneEvent;
++
++    if (mWaylandDisplay->xdgOutputManager()) {
++        ret |= XdgOutputNameEvent;
++
++        if (mWaylandDisplay->xdgOutputManager()->version() < 3)
++            ret |= XdgOutputDoneEvent;
++    }
++    return ret;
+ }
+ 
+ void QWaylandScreen::maybeInitialize()
+ {
+     Q_ASSERT(!mInitialized);
+ 
+-    if (!mOutputDone)
+-        return;
+-
+-    if (mWaylandDisplay->xdgOutputManager() && !mXdgOutputDone)
++    const uint requiredEvents = this->requiredEvents();
++    if ((mProcessedEvents & requiredEvents) != requiredEvents)
+         return;
+ 
+     mInitialized = true;
+@@ -276,9 +289,8 @@ void QWaylandScreen::output_scale(int32_t factor)
+ 
+ void QWaylandScreen::output_done()
+ {
+-    mOutputDone = true;
+-    if (zxdg_output_v1::isInitialized() && mWaylandDisplay->xdgOutputManager()->version() >= 3)
+-        mXdgOutputDone = true;
++    mProcessedEvents |= OutputDoneEvent;
++
+     if (mInitialized) {
+         updateOutputProperties();
+         if (zxdg_output_v1::isInitialized())
+@@ -339,7 +351,7 @@ void QWaylandScreen::zxdg_output_v1_done()
+     if (Q_UNLIKELY(mWaylandDisplay->xdgOutputManager()->version() >= 3))
+         qWarning(lcQpaWayland) << "zxdg_output_v1.done received on version 3 or newer, this is most likely a bug in the compositor";
+ 
+-    mXdgOutputDone = true;
++    mProcessedEvents |= XdgOutputDoneEvent;
+     if (mInitialized)
+         updateXdgOutputProperties();
+     else
+@@ -348,7 +360,11 @@ void QWaylandScreen::zxdg_output_v1_done()
+ 
+ void QWaylandScreen::zxdg_output_v1_name(const QString &name)
+ {
++    if (Q_UNLIKELY(mInitialized))
++        qWarning(lcQpaWayland) << "zxdg_output_v1.name received after output has been initialized, this is most likely a bug in the compositor";
++
+     mOutputName = name;
++    mProcessedEvents |= XdgOutputNameEvent;
+ }
+ 
+ void QWaylandScreen::updateXdgOutputProperties()
+diff --git a/qtwayland/src/client/qwaylandscreen_p.h b/qtwayland/src/client/qwaylandscreen_p.h
+index df1c94f2..050cfdc0 100644
+--- a/qtwayland/src/client/qwaylandscreen_p.h
++++ b/qtwayland/src/client/qwaylandscreen_p.h
+@@ -116,6 +116,13 @@ public:
+     static QWaylandScreen *fromWlOutput(::wl_output *output);
+ 
+ private:
++    enum Event : uint {
++        XdgOutputDoneEvent = 0x1,
++        OutputDoneEvent = 0x2,
++        XdgOutputNameEvent = 0x4,
++    };
++    uint requiredEvents() const;
++
+     void output_mode(uint32_t flags, int width, int height, int refresh) override;
+     void output_geometry(int32_t x, int32_t y,
+                          int32_t width, int32_t height,
+@@ -148,8 +155,7 @@ private:
+     QSize mPhysicalSize;
+     QString mOutputName;
+     Qt::ScreenOrientation m_orientation = Qt::PrimaryOrientation;
+-    bool mOutputDone = false;
+-    bool mXdgOutputDone = false;
++    uint mProcessedEvents = 0;
+     bool mInitialized = false;
+ 
+ #if QT_CONFIG(cursor)
+diff --git a/qtwayland/src/client/qwaylandshmbackingstore.cpp b/qtwayland/src/client/qwaylandshmbackingstore.cpp
+index dc7ff670..41cffdf7 100644
+--- a/qtwayland/src/client/qwaylandshmbackingstore.cpp
++++ b/qtwayland/src/client/qwaylandshmbackingstore.cpp
+@@ -52,6 +52,7 @@
+ 
+ #include <QtWaylandClient/private/wayland-wayland-client-protocol.h>
+ 
++#include <fcntl.h>
+ #include <unistd.h>
+ #include <sys/mman.h>
+ 
+@@ -61,6 +62,9 @@
+ #  ifndef MFD_CLOEXEC
+ #    define MFD_CLOEXEC     0x0001U
+ #  endif
++#  ifndef MFD_ALLOW_SEALING
++#    define MFD_ALLOW_SEALING 0x0002U
++#  endif
+ #endif
+ 
+ QT_BEGIN_NAMESPACE
+@@ -74,8 +78,10 @@ QWaylandShmBuffer::QWaylandShmBuffer(QWaylandDisplay *display,
+     int alloc = stride * size.height();
+     int fd = -1;
+ 
+-#ifdef SYS_memfd_create
+-    fd = syscall(SYS_memfd_create, "wayland-shm", MFD_CLOEXEC);
++#if defined(SYS_memfd_create) && defined(F_SEAL_SEAL)
++    fd = syscall(SYS_memfd_create, "wayland-shm", MFD_CLOEXEC | MFD_ALLOW_SEALING);
++    if (fd >= 0)
++        fcntl(fd, F_ADD_SEALS, F_SEAL_SHRINK | F_SEAL_SEAL);
+ #endif
+ 
+     QScopedPointer<QFile> filePointer;
+diff --git a/qtwayland/src/client/qwaylandwindow.cpp b/qtwayland/src/client/qwaylandwindow.cpp
+index cb82857a..fb2c59dc 100644
+--- a/qtwayland/src/client/qwaylandwindow.cpp
++++ b/qtwayland/src/client/qwaylandwindow.cpp
+@@ -76,7 +76,6 @@ QWaylandWindow *QWaylandWindow::mMouseGrab = nullptr;
+ QWaylandWindow::QWaylandWindow(QWindow *window, QWaylandDisplay *display)
+     : QPlatformWindow(window)
+     , mDisplay(display)
+-    , mFrameQueue(mDisplay->createFrameQueue())
+     , mResizeAfterSwap(qEnvironmentVariableIsSet("QT_WAYLAND_RESIZE_AFTER_SWAP"))
+ {
+     {
+@@ -95,9 +94,6 @@ QWaylandWindow::QWaylandWindow(QWindow *window, QWaylandDisplay *display)
+ 
+ QWaylandWindow::~QWaylandWindow()
+ {
+-    mDisplay->destroyFrameQueue(mFrameQueue);
+-    mDisplay->handleWindowDestroyed(this);
+-
+     delete mWindowDecoration;
+ 
+     if (mSurface)
+@@ -243,6 +239,7 @@ bool QWaylandWindow::shouldCreateSubSurface() const
+ 
+ void QWaylandWindow::reset()
+ {
++    closeChildPopups();
+     delete mShellSurface;
+     mShellSurface = nullptr;
+     delete mSubSurfaceWindow;
+@@ -255,17 +252,22 @@ void QWaylandWindow::reset()
+         mSurface.reset();
+     }
+ 
+-    if (mFrameCallback) {
+-        wl_callback_destroy(mFrameCallback);
+-        mFrameCallback = nullptr;
+-    }
++    {
++        QMutexLocker lock(&mFrameSyncMutex);
++        if (mFrameCallback) {
++            wl_callback_destroy(mFrameCallback);
++            mFrameCallback = nullptr;
++        }
+ 
+-    mFrameCallbackElapsedTimer.invalidate();
+-    mWaitingForFrameCallback = false;
++        mFrameCallbackElapsedTimer.invalidate();
++        mWaitingForFrameCallback = false;
++    }
+     mFrameCallbackTimedOut = false;
+ 
+     mMask = QRegion();
+     mQueuedBuffer = nullptr;
++
++    mDisplay->handleWindowDestroyed(this);
+ }
+ 
+ QWaylandWindow *QWaylandWindow::fromWlSurface(::wl_surface *surface)
+@@ -351,19 +353,25 @@ void QWaylandWindow::setGeometry_helper(const QRect &rect)
+     }
+ }
+ 
+-void QWaylandWindow::setGeometry(const QRect &rect)
++void QWaylandWindow::setGeometry(const QRect &r)
+ {
++    auto rect = r;
++    if (fixedToplevelPositions && !QPlatformWindow::parent() && window()->type() != Qt::Popup
++        && window()->type() != Qt::ToolTip) {
++        rect.moveTo(screen()->geometry().topLeft());
++    }
+     setGeometry_helper(rect);
+ 
+     if (window()->isVisible() && rect.isValid()) {
+         if (mWindowDecoration)
+             mWindowDecoration->update();
+ 
+-        if (mResizeAfterSwap && windowType() == Egl && mSentInitialResize)
++        if (mResizeAfterSwap && windowType() == Egl && mSentInitialResize) {
++            QMutexLocker lock(&mResizeLock);
+             mResizeDirty = true;
+-        else
++        } else {
+             QWindowSystemInterface::handleGeometryChange(window(), geometry());
+-
++        }
+         mSentInitialResize = true;
+     }
+     QRect exposeGeometry(QPoint(), geometry().size());
+@@ -374,7 +382,7 @@ void QWaylandWindow::setGeometry(const QRect &rect)
+         mShellSurface->setWindowGeometry(windowContentGeometry());
+ 
+     if (isOpaque() && mMask.isEmpty())
+-        setOpaqueArea(rect);
++        setOpaqueArea(QRect(QPoint(0, 0), rect.size()));
+ }
+ 
+ void QWaylandWindow::resizeFromApplyConfigure(const QSize &sizeWithMargins, const QPoint &offset)
+@@ -399,21 +407,6 @@ void QWaylandWindow::sendExposeEvent(const QRect &rect)
+     mLastExposeGeometry = rect;
+ }
+ 
+-
+-static QVector<QPointer<QWaylandWindow>> activePopups;
+-
+-void QWaylandWindow::closePopups(QWaylandWindow *parent)
+-{
+-    while (!activePopups.isEmpty()) {
+-        auto popup = activePopups.takeLast();
+-        if (popup.isNull())
+-            continue;
+-        if (popup.data() == parent)
+-            return;
+-        popup->reset();
+-    }
+-}
+-
+ QPlatformScreen *QWaylandWindow::calculateScreenFromSurfaceEvents() const
+ {
+     QReadLocker lock(&mSurfaceLock);
+@@ -433,10 +426,7 @@ void QWaylandWindow::setVisible(bool visible)
+     lastVisible = visible;
+ 
+     if (visible) {
+-        if (window()->type() == Qt::Popup || window()->type() == Qt::ToolTip)
+-            activePopups << this;
+         initWindow();
+-        mDisplay->flushRequests();
+ 
+         setGeometry(windowGeometry());
+         // Don't flush the events here, or else the newly visible window may start drawing, but since
+@@ -444,7 +434,6 @@ void QWaylandWindow::setVisible(bool visible)
+         // QWaylandShmBackingStore::beginPaint().
+     } else {
+         sendExposeEvent(QRect());
+-        closePopups(this);
+         reset();
+     }
+ }
+@@ -556,12 +545,12 @@ void QWaylandWindow::sendRecursiveExposeEvent()
+ 
+ void QWaylandWindow::attach(QWaylandBuffer *buffer, int x, int y)
+ {
+-    Q_ASSERT(!buffer->committed());
+     QReadLocker locker(&mSurfaceLock);
+     if (mSurface == nullptr)
+         return;
+ 
+     if (buffer) {
++        Q_ASSERT(!buffer->committed());
+         handleUpdate();
+         buffer->setBusy();
+ 
+@@ -583,7 +572,11 @@ void QWaylandWindow::damage(const QRect &rect)
+     if (mSurface == nullptr)
+         return;
+ 
+-    mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    const int s = scale();
++    if (mDisplay->compositorVersion() >= 4)
++        mSurface->damage_buffer(s * rect.x(), s * rect.y(), s * rect.width(), s * rect.height());
++    else
++        mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
+ }
+ 
+ void QWaylandWindow::safeCommit(QWaylandBuffer *buffer, const QRegion &damage)
+@@ -619,8 +612,14 @@ void QWaylandWindow::commit(QWaylandBuffer *buffer, const QRegion &damage)
+         return;
+ 
+     attachOffset(buffer);
+-    for (const QRect &rect: damage)
+-        mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    if (mDisplay->compositorVersion() >= 4) {
++        const int s = scale();
++        for (const QRect &rect: damage)
++            mSurface->damage_buffer(s * rect.x(), s * rect.y(), s * rect.width(), s * rect.height());
++    } else {
++        for (const QRect &rect: damage)
++            mSurface->damage(rect.x(), rect.y(), rect.width(), rect.height());
++    }
+     Q_ASSERT(!buffer->committed());
+     buffer->setCommitted();
+     mSurface->commit();
+@@ -635,42 +634,53 @@ void QWaylandWindow::commit()
+ 
+ const wl_callback_listener QWaylandWindow::callbackListener = {
+     [](void *data, wl_callback *callback, uint32_t time) {
+-        Q_UNUSED(callback);
+         Q_UNUSED(time);
+         auto *window = static_cast<QWaylandWindow*>(data);
+-        window->handleFrameCallback();
++        window->handleFrameCallback(callback);
+     }
+ };
+ 
+-void QWaylandWindow::handleFrameCallback()
++void QWaylandWindow::handleFrameCallback(wl_callback* callback)
+ {
++    QMutexLocker locker(&mFrameSyncMutex);
++    if (!mFrameCallback) {
++        // This means the callback is already unset by QWaylandWindow::reset.
++        // The wl_callback object will be destroyed there too.
++        return;
++    }
++    Q_ASSERT(callback == mFrameCallback);
++    wl_callback_destroy(callback);
++    mFrameCallback = nullptr;
++
+     mWaitingForFrameCallback = false;
+     mFrameCallbackElapsedTimer.invalidate();
+ 
+     // The rest can wait until we can run it on the correct thread
+-    if (!mWaitingForUpdateDelivery) {
+-        auto doHandleExpose = [this]() {
+-            bool wasExposed = isExposed();
+-            mFrameCallbackTimedOut = false;
+-            if (!wasExposed && isExposed()) // Did setting mFrameCallbackTimedOut make the window exposed?
+-                sendExposeEvent(QRect(QPoint(), geometry().size()));
+-            if (wasExposed && hasPendingUpdateRequest())
+-                deliverUpdateRequest();
+-
+-            mWaitingForUpdateDelivery = false;
+-        };
++    auto doHandleExpose = [this]() {
++        mWaitingForUpdateDelivery.storeRelease(false);
++        bool wasExposed = isExposed();
++        mFrameCallbackTimedOut = false;
++        if (!wasExposed && isExposed()) // Did setting mFrameCallbackTimedOut make the window exposed?
++            sendExposeEvent(QRect(QPoint(), geometry().size()));
++        if (wasExposed && hasPendingUpdateRequest())
++            deliverUpdateRequest();
++    };
+ 
++    if (mWaitingForUpdateDelivery.testAndSetAcquire(false, true)) {
+         // Queued connection, to make sure we don't call handleUpdate() from inside waitForFrameSync()
+         // in the single-threaded case.
+-        mWaitingForUpdateDelivery = true;
+         QMetaObject::invokeMethod(this, doHandleExpose, Qt::QueuedConnection);
+     }
++
++    mFrameSyncWait.notify_all();
+ }
+ 
+ bool QWaylandWindow::waitForFrameSync(int timeout)
+ {
+-    QMutexLocker locker(mFrameQueue.mutex);
+-    mDisplay->dispatchQueueWhile(mFrameQueue.queue, [&]() { return mWaitingForFrameCallback; }, timeout);
++    QMutexLocker locker(&mFrameSyncMutex);
++
++    QDeadlineTimer deadline(timeout);
++    while (mWaitingForFrameCallback && mFrameSyncWait.wait(&mFrameSyncMutex, deadline)) { }
+ 
+     if (mWaitingForFrameCallback) {
+         qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
+@@ -868,6 +878,17 @@ bool QWaylandWindow::createDecoration()
+             subsurf->set_position(pos.x() + m.left(), pos.y() + m.top());
+         }
+         sendExposeEvent(QRect(QPoint(), geometry().size()));
++
++        // This is a special case where the buffer is recreated, but since
++        // the content rect remains the same, the widgets remain the same
++        // size and are not redrawn, leaving the new buffer empty. As a simple
++        // work-around, we trigger a full extra update whenever the client-side
++        // window decorations are toggled while the window is showing.
++        // Note: createDecoration() is sometimes called from the render thread
++        // of Qt Quick. This is essentially wrong and could potentially cause problems,
++        // but until the underlying issue has been fixed, we have to use invokeMethod()
++        // here to avoid asserts.
++        QMetaObject::invokeMethod(window(), &QWindow::requestUpdate);
+     }
+ 
+     return mWindowDecoration;
+@@ -1023,6 +1044,13 @@ void QWaylandWindow::handleScreensChanged()
+ 
+     QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->QPlatformScreen::screen());
+     mLastReportedScreen = newScreen;
++    if (fixedToplevelPositions && !QPlatformWindow::parent() && window()->type() != Qt::Popup
++        && window()->type() != Qt::ToolTip
++        && geometry().topLeft() != newScreen->geometry().topLeft()) {
++        auto geometry = this->geometry();
++        geometry.moveTo(newScreen->geometry().topLeft());
++        setGeometry(geometry);
++    }
+ 
+     int scale = newScreen->isPlaceholder() ? 1 : static_cast<QWaylandScreen *>(newScreen)->scale();
+     if (scale != mScale) {
+@@ -1094,10 +1122,18 @@ bool QWaylandWindow::setMouseGrabEnabled(bool grab)
+     return true;
+ }
+ 
++Qt::WindowStates QWaylandWindow::windowStates() const
++{
++    return mLastReportedWindowStates;
++}
++
+ void QWaylandWindow::handleWindowStatesChanged(Qt::WindowStates states)
+ {
+     createDecoration();
+-    QWindowSystemInterface::handleWindowStateChanged(window(), states, mLastReportedWindowStates);
++    Qt::WindowStates statesWithoutActive = states & ~Qt::WindowActive;
++    Qt::WindowStates lastStatesWithoutActive = mLastReportedWindowStates & ~Qt::WindowActive;
++    QWindowSystemInterface::handleWindowStateChanged(window(), statesWithoutActive,
++                                                     lastStatesWithoutActive);
+     mLastReportedWindowStates = states;
+ }
+ 
+@@ -1139,19 +1175,24 @@ void QWaylandWindow::timerEvent(QTimerEvent *event)
+     if (event->timerId() != mFrameCallbackCheckIntervalTimerId)
+         return;
+ 
+-    bool callbackTimerExpired = mFrameCallbackElapsedTimer.hasExpired(mFrameCallbackTimeout);
+-    if (!mFrameCallbackElapsedTimer.isValid() || callbackTimerExpired ) {
+-        killTimer(mFrameCallbackCheckIntervalTimerId);
+-        mFrameCallbackCheckIntervalTimerId = -1;
+-    }
+-    if (mFrameCallbackElapsedTimer.isValid() && callbackTimerExpired) {
+-        mFrameCallbackElapsedTimer.invalidate();
++    {
++        QMutexLocker lock(&mFrameSyncMutex);
+ 
+-        qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
+-        mFrameCallbackTimedOut = true;
+-        mWaitingForUpdate = false;
+-        sendExposeEvent(QRect());
++        bool callbackTimerExpired = mFrameCallbackElapsedTimer.hasExpired(mFrameCallbackTimeout);
++        if (!mFrameCallbackElapsedTimer.isValid() || callbackTimerExpired ) {
++            killTimer(mFrameCallbackCheckIntervalTimerId);
++            mFrameCallbackCheckIntervalTimerId = -1;
++        }
++        if (!mFrameCallbackElapsedTimer.isValid() || !callbackTimerExpired) {
++            return;
++        }
++        mFrameCallbackElapsedTimer.invalidate();
+     }
++
++    qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed";
++    mFrameCallbackTimedOut = true;
++    mWaitingForUpdate = false;
++    sendExposeEvent(QRect());
+ }
+ 
+ void QWaylandWindow::requestUpdate()
+@@ -1160,8 +1201,11 @@ void QWaylandWindow::requestUpdate()
+     Q_ASSERT(hasPendingUpdateRequest()); // should be set by QPA
+ 
+     // If we have a frame callback all is good and will be taken care of there
+-    if (mWaitingForFrameCallback)
+-        return;
++    {
++        QMutexLocker locker(&mFrameSyncMutex);
++        if (mWaitingForFrameCallback)
++            return;
++    }
+ 
+     // If we've already called deliverUpdateRequest(), but haven't seen any attach+commit/swap yet
+     // This is a somewhat redundant behavior and might indicate a bug in the calling code, so log
+@@ -1174,7 +1218,12 @@ void QWaylandWindow::requestUpdate()
+     // so use invokeMethod to delay the delivery a bit.
+     QMetaObject::invokeMethod(this, [this] {
+         // Things might have changed in the meantime
+-        if (hasPendingUpdateRequest() && !mWaitingForFrameCallback)
++        {
++            QMutexLocker locker(&mFrameSyncMutex);
++            if (mWaitingForFrameCallback)
++                return;
++        }
++        if (hasPendingUpdateRequest())
+             deliverUpdateRequest();
+     }, Qt::QueuedConnection);
+ }
+@@ -1185,19 +1234,18 @@ void QWaylandWindow::requestUpdate()
+ void QWaylandWindow::handleUpdate()
+ {
+     qCDebug(lcWaylandBackingstore) << "handleUpdate" << QThread::currentThread();
++
+     // TODO: Should sync subsurfaces avoid requesting frame callbacks?
+     QReadLocker lock(&mSurfaceLock);
+     if (!mSurface)
+         return;
+ 
+-    if (mFrameCallback) {
+-        wl_callback_destroy(mFrameCallback);
+-        mFrameCallback = nullptr;
+-    }
++    QMutexLocker locker(&mFrameSyncMutex);
++    if (mWaitingForFrameCallback)
++        return;
+ 
+-    QMutexLocker locker(mFrameQueue.mutex);
+     struct ::wl_surface *wrappedSurface = reinterpret_cast<struct ::wl_surface *>(wl_proxy_create_wrapper(mSurface->object()));
+-    wl_proxy_set_queue(reinterpret_cast<wl_proxy *>(wrappedSurface), mFrameQueue.queue);
++    wl_proxy_set_queue(reinterpret_cast<wl_proxy *>(wrappedSurface), mDisplay->frameEventQueue());
+     mFrameCallback = wl_surface_frame(wrappedSurface);
+     wl_proxy_wrapper_destroy(wrappedSurface);
+     wl_callback_add_listener(mFrameCallback, &QWaylandWindow::callbackListener, this);
+@@ -1207,6 +1255,8 @@ void QWaylandWindow::handleUpdate()
+     // Start a timer for handling the case when the compositor stops sending frame callbacks.
+     if (mFrameCallbackTimeout > 0) {
+         QMetaObject::invokeMethod(this, [this] {
++            QMutexLocker locker(&mFrameSyncMutex);
++
+             if (mWaitingForFrameCallback) {
+                 if (mFrameCallbackCheckIntervalTimerId < 0)
+                     mFrameCallbackCheckIntervalTimerId = startTimer(mFrameCallbackTimeout);
+@@ -1267,6 +1317,20 @@ void QWaylandWindow::setOpaqueArea(const QRegion &opaqueArea)
+     wl_region_destroy(region);
+ }
+ 
++void QWaylandWindow::addChildPopup(QWaylandWindow *surface) {
++    mChildPopups.append(surface);
++}
++
++void QWaylandWindow::removeChildPopup(QWaylandWindow *surface) {
++    mChildPopups.removeAll(surface);
++}
++
++void QWaylandWindow::closeChildPopups() {
++    while (!mChildPopups.isEmpty()) {
++        auto popup = mChildPopups.takeLast();
++        popup->reset();
++    }
++}
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/client/qwaylandwindow_p.h b/qtwayland/src/client/qwaylandwindow_p.h
+index 01337cff..2f219d8c 100644
+--- a/qtwayland/src/client/qwaylandwindow_p.h
++++ b/qtwayland/src/client/qwaylandwindow_p.h
+@@ -98,6 +98,9 @@ public:
+     QWaylandWindow(QWindow *window, QWaylandDisplay *display);
+     ~QWaylandWindow() override;
+ 
++    // Keep Toplevels position on the top left corner of their screen
++    static inline bool fixedToplevelPositions = true;
++
+     virtual WindowType windowType() const = 0;
+     virtual void ensureSize();
+     WId winId() const override;
+@@ -148,6 +151,7 @@ public:
+     void setWindowState(Qt::WindowStates states) override;
+     void setWindowFlags(Qt::WindowFlags flags) override;
+     void handleWindowStatesChanged(Qt::WindowStates states);
++    Qt::WindowStates windowStates() const;
+ 
+     void raise() override;
+     void lower() override;
+@@ -206,6 +210,10 @@ public:
+     void handleUpdate();
+     void deliverUpdateRequest() override;
+ 
++    void addChildPopup(QWaylandWindow* child);
++    void removeChildPopup(QWaylandWindow* child);
++    void closeChildPopups();
++
+ public slots:
+     void applyConfigure();
+ 
+@@ -215,7 +223,11 @@ signals:
+ 
+ protected:
+     QWaylandDisplay *mDisplay = nullptr;
++
++    // mSurface can be written by the main thread. Other threads should claim a read lock for access
++    mutable QReadWriteLock mSurfaceLock;
+     QScopedPointer<QWaylandSurface> mSurface;
++
+     QWaylandShellSurface *mShellSurface = nullptr;
+     QWaylandSubSurface *mSubSurfaceWindow = nullptr;
+     QVector<QWaylandSubSurface *> mChildren;
+@@ -225,13 +237,14 @@ protected:
+     Qt::MouseButtons mMousePressedInContentArea = Qt::NoButton;
+ 
+     WId mWindowId;
+-    bool mWaitingForFrameCallback = false;
+     bool mFrameCallbackTimedOut = false; // Whether the frame callback has timed out
+-    bool mWaitingForUpdateDelivery = false;
+     int mFrameCallbackCheckIntervalTimerId = -1;
+-    QElapsedTimer mFrameCallbackElapsedTimer;
+-    struct ::wl_callback *mFrameCallback = nullptr;
+-    QWaylandDisplay::FrameQueue mFrameQueue;
++    QAtomicInt mWaitingForUpdateDelivery = false;
++
++    bool mWaitingForFrameCallback = false; // Protected by mFrameSyncMutex
++    QElapsedTimer mFrameCallbackElapsedTimer; // Protected by mFrameSyncMutex
++    struct ::wl_callback *mFrameCallback = nullptr; // Protected by mFrameSyncMutex
++    QMutex mFrameSyncMutex;
+     QWaitCondition mFrameSyncWait;
+ 
+     // True when we have called deliverRequestUpdate, but the client has not yet attached a new buffer
+@@ -261,6 +274,8 @@ protected:
+     QWaylandBuffer *mQueuedBuffer = nullptr;
+     QRegion mQueuedBufferDamage;
+ 
++    QList<QPointer<QWaylandWindow>> mChildPopups;
++
+ private:
+     void setGeometry_helper(const QRect &rect);
+     void initWindow();
+@@ -283,12 +298,10 @@ private:
+     QRect mLastExposeGeometry;
+ 
+     static const wl_callback_listener callbackListener;
+-    void handleFrameCallback();
++    void handleFrameCallback(struct ::wl_callback* callback);
+ 
+     static QWaylandWindow *mMouseGrab;
+ 
+-    mutable QReadWriteLock mSurfaceLock;
+-
+     friend class QWaylandSubSurface;
+ };
+ 
+diff --git a/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h b/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
+index ccad0048..4cc9b3b8 100644
+--- a/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
++++ b/qtwayland/src/client/shellintegration/qwaylandshellintegration_p.h
+@@ -73,11 +73,10 @@ public:
+         return true;
+     }
+     virtual QWaylandShellSurface *createShellSurface(QWaylandWindow *window) = 0;
++    // kept for binary compat with layer-shell-qt
+     virtual void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) {
+-        if (newFocus)
+-            m_display->handleWindowActivated(newFocus);
+-        if (oldFocus)
+-            m_display->handleWindowDeactivated(oldFocus);
++        Q_UNUSED(newFocus);
++        Q_UNUSED(oldFocus);
+     }
+     virtual void *nativeResourceForWindow(const QByteArray &resource, QWindow *window) {
+         Q_UNUSED(resource);
+diff --git a/qtwayland/src/compositor/configure.json b/qtwayland/src/compositor/configure.json
+index bcfd5215..da95d07b 100644
+--- a/qtwayland/src/compositor/configure.json
++++ b/qtwayland/src/compositor/configure.json
+@@ -7,6 +7,31 @@
+     "testDir": "../../config.tests",
+ 
+     "libraries": {
++        "wayland-client": {
++            "label": "Wayland client library",
++            "headers": "wayland-version.h",
++            "test": {
++                "main": [
++                    "#if WAYLAND_VERSION_MAJOR < 1",
++                    "# error Wayland 1.8.0 or higher required",
++                    "#endif",
++                    "#if WAYLAND_VERSION_MAJOR == 1",
++                    "# if WAYLAND_VERSION_MINOR < 8",
++                    "#  error Wayland 1.8.0 or higher required",
++                    "# endif",
++                    "# if WAYLAND_VERSION_MINOR == 8",
++                    "#  if WAYLAND_VERSION_MICRO < 0",
++                    "#   error Wayland 1.8.0 or higher required",
++                    "#  endif",
++                    "# endif",
++                    "#endif"
++                 ]
++            },
++            "sources": [
++                { "type": "pkgConfig", "args": "wayland-client" },
++                "-lwayland-client"
++            ]
++        },
+         "wayland-server": {
+             "label": "wayland-server",
+             "headers": "wayland-version.h",
+@@ -151,8 +176,7 @@
+                     "#endif"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "dmabuf-client-buffer": {
+             "label": "Linux Client dma-buf Buffer Sharing",
+@@ -176,8 +200,7 @@
+                     "return 0;"
+                 ]
+             },
+-            "libs": "-ldrm",
+-            "use": "egl"
++            "use": "drm egl"
+         },
+         "vulkan-server-buffer": {
+             "label": "Vulkan Buffer Sharing",
+@@ -195,7 +218,8 @@
+                     "exportAllocInfo.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR;",
+                     "return 0;"
+                 ]
+-            }
++            },
++            "use": "wayland-client"
+         }
+     },
+ 
+diff --git a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
+index 7889f575..64140672 100644
+--- a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
++++ b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
+@@ -40,6 +40,7 @@
+ #include "qwaylandeglwindow.h"
+ 
+ #include <QtWaylandClient/private/qwaylandscreen_p.h>
++#include <QtWaylandClient/private/qwaylandsurface_p.h>
+ #include "qwaylandglcontext.h"
+ 
+ #include <QtEglSupport/private/qeglconvenience_p.h>
+@@ -124,6 +125,7 @@ void QWaylandEglWindow::updateSurface(bool create)
+         }
+         mOffset = QPoint();
+     } else {
++        QReadLocker locker(&mSurfaceLock);
+         if (m_waylandEglWindow) {
+             int current_width, current_height;
+             static bool disableResizeCheck = qgetenv("QT_WAYLAND_DISABLE_RESIZECHECK").toInt();
+@@ -131,14 +133,16 @@ void QWaylandEglWindow::updateSurface(bool create)
+             if (!disableResizeCheck) {
+                 wl_egl_window_get_attached_size(m_waylandEglWindow, &current_width, &current_height);
+             }
+-            if (disableResizeCheck || (current_width != sizeWithMargins.width() || current_height != sizeWithMargins.height())) {
++            if (disableResizeCheck || (current_width != sizeWithMargins.width() || current_height != sizeWithMargins.height()) || m_requestedSize != sizeWithMargins) {
+                 wl_egl_window_resize(m_waylandEglWindow, sizeWithMargins.width(), sizeWithMargins.height(), mOffset.x(), mOffset.y());
++                m_requestedSize = sizeWithMargins;
+                 mOffset = QPoint();
+ 
+                 m_resize = true;
+             }
+-        } else if (create && wlSurface()) {
+-            m_waylandEglWindow = wl_egl_window_create(wlSurface(), sizeWithMargins.width(), sizeWithMargins.height());
++        } else if (create && mSurface) {
++            m_waylandEglWindow = wl_egl_window_create(mSurface->object(), sizeWithMargins.width(), sizeWithMargins.height());
++            m_requestedSize = sizeWithMargins;
+         }
+ 
+         if (!m_eglSurface && m_waylandEglWindow && create) {
+diff --git a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
+index 5b1f4d56..0079dfef 100644
+--- a/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
++++ b/qtwayland/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.h
+@@ -88,6 +88,7 @@ private:
+     mutable QOpenGLFramebufferObject *m_contentFBO = nullptr;
+ 
+     QSurfaceFormat m_format;
++    QSize m_requestedSize;
+ };
+ 
+ }
+diff --git a/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h b/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
+index 56a710c3..c6a8b6c6 100644
+--- a/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
++++ b/qtwayland/src/hardwareintegration/compositor/linux-dmabuf-unstable-v1/linuxdmabuf.h
+@@ -41,6 +41,8 @@
+ #include <QtCore/QTextStream>
+ #include <QtGui/QOpenGLTexture>
+ 
++#include <array>
++
+ #include <EGL/egl.h>
+ #include <EGL/eglext.h>
+ 
+diff --git a/qtwayland/src/plugins/decorations/bradient/main.cpp b/qtwayland/src/plugins/decorations/bradient/main.cpp
+index e75fda3c..fa885143 100644
+--- a/qtwayland/src/plugins/decorations/bradient/main.cpp
++++ b/qtwayland/src/plugins/decorations/bradient/main.cpp
+@@ -164,13 +164,10 @@ void QWaylandBradientDecoration::paint(QPaintDevice *device)
+     // Window icon
+     QIcon icon = waylandWindow()->windowIcon();
+     if (!icon.isNull()) {
+-        QPixmap pixmap = icon.pixmap(QSize(128, 128));
+-        QPixmap scaled = pixmap.scaled(22, 22, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+-
+         QRectF iconRect(0, 0, 22, 22);
+-        p.drawPixmap(iconRect.adjusted(margins().left() + BUTTON_SPACING, 4,
+-                                       margins().left() + BUTTON_SPACING, 4),
+-                     scaled, iconRect);
++        iconRect.adjust(margins().left() + BUTTON_SPACING, 4,
++                        margins().left() + BUTTON_SPACING, 4),
++        icon.paint(&p, iconRect.toRect());
+     }
+ 
+     // Window title
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
+index 85d25e3c..60bdd491 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5.cpp
+@@ -47,18 +47,21 @@ QT_BEGIN_NAMESPACE
+ 
+ namespace QtWaylandClient {
+ 
+-QWaylandXdgPopupV5::QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow *window)
++QWaylandXdgPopupV5::QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow* parent, QWaylandWindow *window)
+     : QWaylandShellSurface(window)
+     , QtWayland::xdg_popup_v5(popup)
++    , m_parent(parent)
+     , m_window(window)
+ {
+     if (window->display()->windowExtension())
+         m_extendedWindow = new QWaylandExtendedSurface(window);
++    m_parent->addChildPopup(m_window);
+ }
+ 
+ QWaylandXdgPopupV5::~QWaylandXdgPopupV5()
+ {
+     xdg_popup_destroy(object());
++    m_parent->removeChildPopup(m_window);
+     delete m_extendedWindow;
+ }
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
+index 7494f6a6..d85f130b 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgpopupv5_p.h
+@@ -70,7 +70,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgPopupV5 : public QWaylandShellSurface
+ {
+     Q_OBJECT
+ public:
+-    QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow *window);
++    QWaylandXdgPopupV5(struct ::xdg_popup_v5 *popup, QWaylandWindow* parent, QWaylandWindow *window);
+     ~QWaylandXdgPopupV5() override;
+ 
+ protected:
+@@ -78,6 +78,7 @@ protected:
+ 
+ private:
+     QWaylandExtendedSurface *m_extendedWindow = nullptr;
++    QWaylandWindow *m_parent = nullptr;
+     QWaylandWindow *m_window = nullptr;
+ };
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
+index 7e242c4a..def8452a 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5.cpp
+@@ -84,7 +84,7 @@ QWaylandXdgPopupV5 *QWaylandXdgShellV5::createXdgPopup(QWaylandWindow *window, Q
+     int x = position.x() + parentWindow->frameMargins().left();
+     int y = position.y() + parentWindow->frameMargins().top();
+ 
+-    auto popup = new QWaylandXdgPopupV5(get_xdg_popup(window->wlSurface(), parentSurface, seat, m_popupSerial, x, y), window);
++    auto popup = new QWaylandXdgPopupV5(get_xdg_popup(window->wlSurface(), parentSurface, seat, m_popupSerial, x, y), parentWindow, window);
+     m_popups.append(window);
+     QObject::connect(popup, &QWaylandXdgPopupV5::destroyed, [this, window](){
+         m_popups.removeOne(window);
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
+index 4e25949f..cfc60939 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp
+@@ -85,13 +85,6 @@ QWaylandShellSurface *QWaylandXdgShellV5Integration::createShellSurface(QWayland
+     return m_xdgShell->createXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellV5Integration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) {
+-    if (newFocus && qobject_cast<QWaylandXdgPopupV5 *>(newFocus->shellSurface()))
+-        m_display->handleWindowActivated(newFocus);
+-    if (oldFocus && qobject_cast<QWaylandXdgPopupV5 *>(oldFocus->shellSurface()))
+-        m_display->handleWindowDeactivated(oldFocus);
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
+index ce6bdb9e..aed88670 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration_p.h
+@@ -67,7 +67,6 @@ public:
+     QWaylandXdgShellV5Integration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShellV5> m_xdgShell;
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
+index 8c371661..151c78e3 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6.cpp
+@@ -174,6 +174,7 @@ QWaylandXdgSurfaceV6::Popup::Popup(QWaylandXdgSurfaceV6 *xdgSurface, QWaylandXdg
+     , m_xdgSurface(xdgSurface)
+     , m_parent(parent)
+ {
++    m_parent->window()->addChildPopup(m_xdgSurface->window());
+ }
+ 
+ QWaylandXdgSurfaceV6::Popup::~Popup()
+@@ -181,6 +182,8 @@ QWaylandXdgSurfaceV6::Popup::~Popup()
+     if (isInitialized())
+         destroy();
+ 
++    m_parent->window()->removeChildPopup(m_xdgSurface->window());
++
+     if (m_grabbing) {
+         auto *shell = m_xdgSurface->m_shell;
+         Q_ASSERT(shell->m_topmostGrabbingPopup == this);
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
+index 03164316..e8da8ba1 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration.cpp
+@@ -68,20 +68,6 @@ QWaylandShellSurface *QWaylandXdgShellV6Integration::createShellSurface(QWayland
+     return m_xdgShell->getXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellV6Integration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus)
+-{
+-    if (newFocus) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurfaceV6 *>(newFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowActivated(newFocus);
+-    }
+-    if (oldFocus && qobject_cast<QWaylandXdgSurfaceV6 *>(oldFocus->shellSurface())) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurfaceV6 *>(oldFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowDeactivated(oldFocus);
+-    }
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
+index 261f8cbb..c1bcd5c6 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell-v6/qwaylandxdgshellv6integration_p.h
+@@ -65,7 +65,6 @@ public:
+     QWaylandXdgShellV6Integration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShellV6> m_xdgShell;
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
+index f3e3c330..fa6d5808 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
+@@ -67,11 +67,6 @@ QWaylandXdgSurface::Toplevel::Toplevel(QWaylandXdgSurface *xdgSurface)
+ 
+ QWaylandXdgSurface::Toplevel::~Toplevel()
+ {
+-    if (m_applied.states & Qt::WindowActive) {
+-        QWaylandWindow *window = m_xdgSurface->window();
+-        window->display()->handleWindowDeactivated(window);
+-    }
+-
+     // The protocol spec requires that the decoration object is deleted before xdg_toplevel.
+     delete m_decoration;
+     m_decoration = nullptr;
+@@ -85,16 +80,15 @@ void QWaylandXdgSurface::Toplevel::applyConfigure()
+     if (!(m_applied.states & (Qt::WindowMaximized|Qt::WindowFullScreen)))
+         m_normalSize = m_xdgSurface->m_window->windowFrameGeometry().size();
+ 
+-    if ((m_pending.states & Qt::WindowActive) && !(m_applied.states & Qt::WindowActive))
++    if ((m_pending.states & Qt::WindowActive) && !(m_applied.states & Qt::WindowActive)
++        && !m_xdgSurface->m_window->display()->isKeyboardAvailable())
+         m_xdgSurface->m_window->display()->handleWindowActivated(m_xdgSurface->m_window);
+ 
+-    if (!(m_pending.states & Qt::WindowActive) && (m_applied.states & Qt::WindowActive))
++    if (!(m_pending.states & Qt::WindowActive) && (m_applied.states & Qt::WindowActive)
++        && !m_xdgSurface->m_window->display()->isKeyboardAvailable())
+         m_xdgSurface->m_window->display()->handleWindowDeactivated(m_xdgSurface->m_window);
+ 
+-    // TODO: none of the other plugins send WindowActive either, but is it on purpose?
+-    Qt::WindowStates statesWithoutActive = m_pending.states & ~Qt::WindowActive;
+-
+-    m_xdgSurface->m_window->handleWindowStatesChanged(statesWithoutActive);
++    m_xdgSurface->m_window->handleWindowStatesChanged(m_pending.states);
+ 
+     if (m_pending.size.isEmpty()) {
+         // An empty size in the configure means it's up to the client to choose the size
+@@ -105,8 +99,6 @@ void QWaylandXdgSurface::Toplevel::applyConfigure()
+         m_xdgSurface->m_window->resizeFromApplyConfigure(m_pending.size);
+     }
+ 
+-    m_xdgSurface->setSizeHints();
+-
+     m_applied = m_pending;
+     qCDebug(lcQpaWayland) << "Applied pending xdg_toplevel configure event:" << m_applied.size << m_applied.states;
+ }
+@@ -203,12 +195,17 @@ QtWayland::xdg_toplevel::resize_edge QWaylandXdgSurface::Toplevel::convertToResi
+                 | ((edges & Qt::RightEdge) ? resize_edge_right : 0));
+ }
+ 
+-QWaylandXdgSurface::Popup::Popup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parent,
++QWaylandXdgSurface::Popup::Popup(QWaylandXdgSurface *xdgSurface, QWaylandWindow *parent,
+                                  QtWayland::xdg_positioner *positioner)
+-    : xdg_popup(xdgSurface->get_popup(parent->object(), positioner->object()))
+-    , m_xdgSurface(xdgSurface)
++    : m_xdgSurface(xdgSurface)
++    , m_parentXdgSurface(qobject_cast<QWaylandXdgSurface *>(parent->shellSurface()))
+     , m_parent(parent)
+ {
++
++    init(xdgSurface->get_popup(m_parentXdgSurface ? m_parentXdgSurface->object() : nullptr, positioner->object()));
++    if (m_parent) {
++        m_parent->addChildPopup(m_xdgSurface->window());
++    }
+ }
+ 
+ QWaylandXdgSurface::Popup::~Popup()
+@@ -216,10 +213,24 @@ QWaylandXdgSurface::Popup::~Popup()
+     if (isInitialized())
+         destroy();
+ 
++    if (m_parent) {
++        m_parent->removeChildPopup(m_xdgSurface->window());
++    }
++
+     if (m_grabbing) {
+         auto *shell = m_xdgSurface->m_shell;
+         Q_ASSERT(shell->m_topmostGrabbingPopup == this);
+-        shell->m_topmostGrabbingPopup = m_parent->m_popup;
++        shell->m_topmostGrabbingPopup = m_parentXdgSurface ? m_parentXdgSurface->m_popup : nullptr;
++        m_grabbing = false;
++
++        // Synthesize Qt enter/leave events for popup
++        QWindow *leave = nullptr;
++        if (m_xdgSurface && m_xdgSurface->window())
++            leave = m_xdgSurface->window()->window();
++        QWindowSystemInterface::handleLeaveEvent(leave);
++
++        if (QWindow *enter = QGuiApplication::topLevelAt(QCursor::pos()))
++            QWindowSystemInterface::handleEnterEvent(enter, enter->mapFromGlobal(QCursor::pos()), QCursor::pos());
+     }
+ }
+ 
+@@ -257,6 +268,7 @@ QWaylandXdgSurface::QWaylandXdgSurface(QWaylandXdgShell *shell, ::xdg_surface *s
+                 m_toplevel->set_parent(parentXdgSurface->m_toplevel->object());
+         }
+     }
++    setSizeHints();
+ }
+ 
+ QWaylandXdgSurface::~QWaylandXdgSurface()
+@@ -400,8 +412,6 @@ void QWaylandXdgSurface::setPopup(QWaylandWindow *parent)
+ {
+     Q_ASSERT(!m_toplevel && !m_popup);
+ 
+-    auto parentXdgSurface = static_cast<QWaylandXdgSurface *>(parent->shellSurface());
+-
+     auto positioner = new QtWayland::xdg_positioner(m_shell->create_positioner());
+     // set_popup expects a position relative to the parent
+     QPoint transientPos = m_window->geometry().topLeft(); // this is absolute
+@@ -414,8 +424,9 @@ void QWaylandXdgSurface::setPopup(QWaylandWindow *parent)
+     positioner->set_anchor(QtWayland::xdg_positioner::anchor_top_left);
+     positioner->set_gravity(QtWayland::xdg_positioner::gravity_bottom_right);
+     positioner->set_size(m_window->geometry().width(), m_window->geometry().height());
+-    m_popup = new Popup(this, parentXdgSurface, positioner);
++    m_popup = new Popup(this, parent, positioner);
+     positioner->destroy();
++
+     delete positioner;
+ }
+ 
+@@ -437,6 +448,23 @@ void QWaylandXdgSurface::setGrabPopup(QWaylandWindow *parent, QWaylandInputDevic
+     }
+     setPopup(parent);
+     m_popup->grab(device, serial);
++
++    // Synthesize Qt enter/leave events for popup
++    if (!parent)
++        return;
++    QWindow *current = QGuiApplication::topLevelAt(QCursor::pos());
++    QWindow *leave = parent->window();
++    if (current != leave)
++        return;
++
++    QWindowSystemInterface::handleLeaveEvent(leave);
++
++    QWindow *enter = nullptr;
++    if (m_popup && m_popup->m_xdgSurface && m_popup->m_xdgSurface->window())
++        enter = m_popup->m_xdgSurface->window()->window();
++
++    if (enter)
++        QWindowSystemInterface::handleEnterEvent(enter, enter->mapFromGlobal(QCursor::pos()), QCursor::pos());
+ }
+ 
+ void QWaylandXdgSurface::xdg_surface_configure(uint32_t serial)
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
+index 96785205..4b518f0a 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
+@@ -131,14 +131,15 @@ private:
+ 
+     class Popup : public QtWayland::xdg_popup {
+     public:
+-        Popup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parent, QtWayland::xdg_positioner *positioner);
++        Popup(QWaylandXdgSurface *xdgSurface, QWaylandWindow *parent, QtWayland::xdg_positioner *positioner);
+         ~Popup() override;
+ 
+         void grab(QWaylandInputDevice *seat, uint serial);
+         void xdg_popup_popup_done() override;
+ 
+         QWaylandXdgSurface *m_xdgSurface = nullptr;
+-        QWaylandXdgSurface *m_parent = nullptr;
++        QWaylandXdgSurface *m_parentXdgSurface = nullptr;
++        QWaylandWindow *m_parent = nullptr;
+         bool m_grabbing = false;
+     };
+ 
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
+index 8769d971..da0dd6a7 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp
+@@ -69,20 +69,6 @@ QWaylandShellSurface *QWaylandXdgShellIntegration::createShellSurface(QWaylandWi
+     return m_xdgShell->getXdgSurface(window);
+ }
+ 
+-void QWaylandXdgShellIntegration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus)
+-{
+-    if (newFocus) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurface *>(newFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowActivated(newFocus);
+-    }
+-    if (oldFocus && qobject_cast<QWaylandXdgSurface *>(oldFocus->shellSurface())) {
+-        auto *xdgSurface = qobject_cast<QWaylandXdgSurface *>(oldFocus->shellSurface());
+-        if (xdgSurface && !xdgSurface->handlesActiveState())
+-            m_display->handleWindowDeactivated(oldFocus);
+-    }
+-}
+-
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
+index b6caa6c9..2f929f98 100644
+--- a/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
++++ b/qtwayland/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h
+@@ -65,7 +65,6 @@ public:
+     QWaylandXdgShellIntegration() {}
+     bool initialize(QWaylandDisplay *display) override;
+     QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;
+-    void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override;
+ 
+ private:
+     QScopedPointer<QWaylandXdgShell> m_xdgShell;
+diff --git a/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp b/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
+index 526d0ef4..f50ccf30 100644
+--- a/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
++++ b/qtwayland/src/shared/qwaylandinputmethodeventbuilder.cpp
+@@ -39,7 +39,10 @@
+ 
+ #include "qwaylandinputmethodeventbuilder_p.h"
+ 
++#include <QBrush>
++#include <QGuiApplication>
+ #include <QInputMethod>
++#include <QPalette>
+ #include <QTextCharFormat>
+ 
+ #ifdef QT_BUILD_WAYLANDCOMPOSITOR_LIB
+@@ -81,32 +84,38 @@ void QWaylandInputMethodEventBuilder::addPreeditStyling(uint32_t index, uint32_t
+     QTextCharFormat format;
+ 
+     switch (style) {
+-    case 0:
+-    case 1:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_NONE:
++        break;
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_DEFAULT:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_UNDERLINE:
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-    case 2:
+-    case 3:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_ACTIVE:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_INACTIVE:
+         format.setFontWeight(QFont::Bold);
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-    case 4:
+-        format.setFontUnderline(true);
+-        format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+-        m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_HIGHLIGHT:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_SELECTION:
++        {
++            format.setFontUnderline(true);
++            format.setUnderlineStyle(QTextCharFormat::SingleUnderline);
++            QPalette palette = qApp->palette();
++            format.setBackground(QBrush(palette.color(QPalette::Active, QPalette::Highlight)));
++            format.setForeground(QBrush(palette.color(QPalette::Active, QPalette::HighlightedText)));
++            m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
++        }
+         break;
+-    case 5:
++    case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_INCORRECT:
+         format.setFontUnderline(true);
+         format.setUnderlineStyle(QTextCharFormat::WaveUnderline);
+         format.setUnderlineColor(QColor(Qt::red));
+         m_preeditStyles.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, index, length, format));
+         break;
+-//    case QtWayland::wl_text_input::preedit_style_selection:
+-//    case QtWayland::wl_text_input::preedit_style_none:
+     default:
+         break;
+     }
+@@ -153,7 +162,7 @@ QInputMethodEvent QWaylandInputMethodEventBuilder::buildPreedit(const QString &t
+ 
+     if (m_preeditCursor < 0) {
+         attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, 0, QVariant()));
+-    } else if (m_preeditCursor > 0) {
++    } else {
+         attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, indexFromWayland(text, m_preeditCursor), 1, QVariant()));
+     }
+ 
+diff --git a/qtwayland/src/shared/qwaylandmimehelper.cpp b/qtwayland/src/shared/qwaylandmimehelper.cpp
+index a5fdd34d..e2fe1928 100644
+--- a/qtwayland/src/shared/qwaylandmimehelper.cpp
++++ b/qtwayland/src/shared/qwaylandmimehelper.cpp
+@@ -60,7 +60,7 @@ QByteArray QWaylandMimeHelper::getByteArray(QMimeData *mimeData, const QString &
+             buf.open(QIODevice::ReadWrite);
+             QByteArray fmt = "BMP";
+             if (mimeType.startsWith(QLatin1String("image/"))) {
+-                QByteArray imgFmt = mimeType.mid(6).toUpper().toLatin1();
++                QByteArray imgFmt = mimeType.mid(6).toLower().toLatin1();
+                 if (QImageWriter::supportedImageFormats().contains(imgFmt))
+                     fmt = imgFmt;
+             }
+@@ -74,7 +74,7 @@ QByteArray QWaylandMimeHelper::getByteArray(QMimeData *mimeData, const QString &
+         QList<QUrl> urls = mimeData->urls();
+         for (int i = 0; i < urls.count(); ++i) {
+             content.append(urls.at(i).toEncoded());
+-            content.append('\n');
++            content.append("\r\n");
+         }
+     } else {
+         content = mimeData->data(mimeType);
+diff --git a/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp b/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
+index 1568b3b9..067410d0 100644
+--- a/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
++++ b/qtwayland/tests/auto/client/datadevicev1/tst_datadevicev1.cpp
+@@ -35,7 +35,7 @@
+ 
+ using namespace MockCompositor;
+ 
+-constexpr int dataDeviceVersion = 1;
++constexpr int dataDeviceVersion = 3;
+ 
+ class DataDeviceCompositor : public DefaultCompositor {
+ public:
+diff --git a/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp b/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
+index 9312c2e5..2ea382f1 100644
+--- a/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
++++ b/qtwayland/tests/auto/client/seatv5/tst_seatv5.cpp
+@@ -73,6 +73,7 @@ private slots:
+     void multiTouch();
+     void multiTouchUpAndMotionFrame();
+     void tapAndMoveInSameFrame();
++    void cancelTouch();
+ };
+ 
+ void tst_seatv5::bindsToSeat()
+@@ -646,5 +647,34 @@ void tst_seatv5::tapAndMoveInSameFrame()
+     QTRY_COMPARE(window.m_events.last().touchPoints.first().state(), Qt::TouchPointState::TouchPointReleased);
+ }
+ 
++void tst_seatv5::cancelTouch()
++{
++    TouchWindow window;
++    QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
++
++    exec([=] {
++        auto *t = touch();
++        auto *c = client();
++        t->sendDown(xdgToplevel()->surface(), {32, 32}, 1);
++        t->sendFrame(c);
++        t->sendCancel(c);
++        t->sendFrame(c);
++    });
++
++    QTRY_VERIFY(!window.m_events.empty());
++    {
++        auto e = window.m_events.takeFirst();
++        QCOMPARE(e.type, QEvent::TouchBegin);
++        QCOMPARE(e.touchPointStates, Qt::TouchPointPressed);
++        QCOMPARE(e.touchPoints.length(), 1);
++        QCOMPARE(e.touchPoints.first().pos(), QPointF(32-window.frameMargins().left(), 32-window.frameMargins().top()));
++    }
++    {
++        auto e = window.m_events.takeFirst();
++        QCOMPARE(e.type, QEvent::TouchCancel);
++        QCOMPARE(e.touchPoints.length(), 0);
++    }
++}
++
+ QCOMPOSITOR_TEST_MAIN(tst_seatv5)
+ #include "tst_seatv5.moc"
+diff --git a/qtwayland/tests/auto/client/shared/corecompositor.cpp b/qtwayland/tests/auto/client/shared/corecompositor.cpp
+index 5c6c83ba..fa9b7662 100644
+--- a/qtwayland/tests/auto/client/shared/corecompositor.cpp
++++ b/qtwayland/tests/auto/client/shared/corecompositor.cpp
+@@ -27,6 +27,7 @@
+ ****************************************************************************/
+ 
+ #include "corecompositor.h"
++#include <thread>
+ 
+ namespace MockCompositor {
+ 
+diff --git a/qtwayland/tests/auto/client/shared/coreprotocol.cpp b/qtwayland/tests/auto/client/shared/coreprotocol.cpp
+index 0d988521..d1a2e7cb 100644
+--- a/qtwayland/tests/auto/client/shared/coreprotocol.cpp
++++ b/qtwayland/tests/auto/client/shared/coreprotocol.cpp
+@@ -451,6 +451,13 @@ void Touch::sendFrame(wl_client *client)
+         send_frame(r->handle);
+ }
+ 
++void Touch::sendCancel(wl_client *client)
++{
++    const auto touchResources = resourceMap().values(client);
++    for (auto *r : touchResources)
++        send_cancel(r->handle);
++}
++
+ uint Keyboard::sendEnter(Surface *surface)
+ {
+     auto serial = m_seat->m_compositor->nextSerial();
+diff --git a/qtwayland/tests/auto/client/shared/coreprotocol.h b/qtwayland/tests/auto/client/shared/coreprotocol.h
+index a1af137a..210d8ddb 100644
+--- a/qtwayland/tests/auto/client/shared/coreprotocol.h
++++ b/qtwayland/tests/auto/client/shared/coreprotocol.h
+@@ -158,7 +158,7 @@ class WlCompositor : public Global, public QtWaylandServer::wl_compositor
+ {
+     Q_OBJECT
+ public:
+-    explicit WlCompositor(CoreCompositor *compositor, int version = 3)
++    explicit WlCompositor(CoreCompositor *compositor, int version = 4)
+         : QtWaylandServer::wl_compositor(compositor->m_display, version)
+         , m_compositor(compositor)
+     {}
+@@ -364,6 +364,7 @@ public:
+     uint sendUp(wl_client *client, int id);
+     void sendMotion(wl_client *client, const QPointF &position, int id);
+     void sendFrame(wl_client *client);
++    void sendCancel(wl_client *client);
+ 
+     Seat *m_seat = nullptr;
+ };
+diff --git a/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp b/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
+index a415cbf5..b1d3d07d 100644
+--- a/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
++++ b/qtwayland/tests/auto/client/shared_old/mockcompositor.cpp
+@@ -342,7 +342,7 @@ Compositor::Compositor(MockCompositor *mockCompositor)
+         exit(EXIT_FAILURE);
+     }
+ 
+-    wl_global_create(m_display, &wl_compositor_interface, 1, this, bindCompositor);
++    wl_global_create(m_display, &wl_compositor_interface, 4, this, bindCompositor);
+ 
+     m_data_device_manager.reset(new DataDeviceManager(this, m_display));
+ 
+diff --git a/qtwayland/tests/auto/client/shared_old/mocksurface.cpp b/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
+index e9df5f90..c3246e4a 100644
+--- a/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
++++ b/qtwayland/tests/auto/client/shared_old/mocksurface.cpp
+@@ -125,6 +125,16 @@ void Surface::surface_damage(Resource *resource,
+     Q_UNUSED(height);
+ }
+ 
++void Surface::surface_damage_buffer(Resource *resource,
++                                    int32_t x, int32_t y, int32_t width, int32_t height)
++{
++    Q_UNUSED(resource);
++    Q_UNUSED(x);
++    Q_UNUSED(y);
++    Q_UNUSED(width);
++    Q_UNUSED(height);
++}
++
+ void Surface::surface_frame(Resource *resource,
+                             uint32_t callback)
+ {
+diff --git a/qtwayland/tests/auto/client/shared_old/mocksurface.h b/qtwayland/tests/auto/client/shared_old/mocksurface.h
+index 949dc23d..d176837e 100644
+--- a/qtwayland/tests/auto/client/shared_old/mocksurface.h
++++ b/qtwayland/tests/auto/client/shared_old/mocksurface.h
+@@ -65,6 +65,8 @@ protected:
+                         struct wl_resource *buffer, int x, int y) override;
+     void surface_damage(Resource *resource,
+                         int32_t x, int32_t y, int32_t width, int32_t height) override;
++    void surface_damage_buffer(Resource *resource,
++                               int32_t x, int32_t y, int32_t width, int32_t height) override;
+     void surface_frame(Resource *resource,
+                        uint32_t callback) override;
+     void surface_commit(Resource *resource) override;
+diff --git a/qtwayland/tests/auto/client/surface/tst_surface.cpp b/qtwayland/tests/auto/client/surface/tst_surface.cpp
+index 95e4e609..60c672ce 100644
+--- a/qtwayland/tests/auto/client/surface/tst_surface.cpp
++++ b/qtwayland/tests/auto/client/surface/tst_surface.cpp
+@@ -129,6 +129,10 @@ void tst_surface::waitForFrameCallbackGl()
+     // Make sure we follow frame callbacks for some frames
+     for (int i = 0; i < 5; ++i) {
+         xdgPingAndWaitForPong(); // Make sure things have happened on the client
++        if (!qEnvironmentVariableIntValue("QT_WAYLAND_DISABLE_WINDOWDECORATION") && i == 0) {
++            QCOMPARE(bufferSpy.count(), 1);
++            bufferSpy.removeFirst();
++        }
+         exec([&] {
+             QVERIFY(bufferSpy.empty()); // Make sure no extra buffers have arrived
+             QVERIFY(!xdgToplevel()->surface()->m_waitingFrameCallbacks.empty());
+diff --git a/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp b/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
+index 2277bbb8..747875b4 100644
+--- a/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
++++ b/qtwayland/tests/auto/client/xdgshell/tst_xdgshell.cpp
+@@ -31,6 +31,7 @@
+ #include <QtGui/QOpenGLWindow>
+ #include <QtGui/qpa/qplatformnativeinterface.h>
+ #include <QtWaylandClient/private/wayland-wayland-client-protocol.h>
++#include <QtWaylandClient/private/qwaylandwindow_p.h>
+ 
+ using namespace MockCompositor;
+ 
+@@ -45,6 +46,7 @@ private slots:
+     void configureStates();
+     void popup();
+     void tooltipOnPopup();
++    void tooltipAndSiblingPopup();
+     void switchPopups();
+     void hidePopupParent();
+     void pongs();
+@@ -138,6 +140,7 @@ void tst_xdgshell::configureSize()
+ 
+ void tst_xdgshell::configureStates()
+ {
++    QVERIFY(qputenv("QT_WAYLAND_FRAME_CALLBACK_TIMEOUT", "0"));
+     QRasterWindow window;
+     window.resize(64, 48);
+     window.show();
+@@ -154,9 +157,12 @@ void tst_xdgshell::configureStates()
+     // Toplevel windows don't know their position on xdg-shell
+ //    QCOMPARE(window.frameGeometry().topLeft(), QPoint()); // TODO: this doesn't currently work when window decorations are enabled
+ 
+-//    QEXPECT_FAIL("", "configure has already been acked, we shouldn't have to wait for isActive", Continue);
+-//    QVERIFY(window.isActive());
+-    QTRY_VERIFY(window.isActive()); // Just make sure it eventually get's set correctly
++    // window.windowstate() is driven by keyboard focus, however for decorations we want to follow
++    // XDGShell this is internal to QtWayland so it is queried directly
++    auto waylandWindow = static_cast<QtWaylandClient::QWaylandWindow *>(window.handle());
++    Q_ASSERT(waylandWindow);
++    QTRY_VERIFY(waylandWindow->windowStates().testFlag(
++            Qt::WindowActive)); // Just make sure it eventually get's set correctly
+ 
+     const QSize screenSize(640, 480);
+     const uint maximizedSerial = exec([=] {
+@@ -186,6 +192,7 @@ void tst_xdgshell::configureStates()
+     QCOMPARE(window.windowStates(), Qt::WindowNoState);
+     QCOMPARE(window.frameGeometry().size(), windowedSize);
+ //    QCOMPARE(window.frameGeometry().topLeft(), QPoint()); // TODO: this doesn't currently work when window decorations are enabled
++    QVERIFY(qunsetenv("QT_WAYLAND_FRAME_CALLBACK_TIMEOUT"));
+ }
+ 
+ void tst_xdgshell::popup()
+@@ -340,6 +347,92 @@ void tst_xdgshell::tooltipOnPopup()
+     QCOMPOSITOR_TRY_COMPARE(xdgPopup(0), nullptr);
+ }
+ 
++void tst_xdgshell::tooltipAndSiblingPopup()
++{
++    class ToolTip : public QRasterWindow {
++    public:
++        explicit ToolTip(QWindow *parent) {
++            setTransientParent(parent);
++            setFlags(Qt::ToolTip);
++            resize(100, 100);
++            show();
++        }
++        void mousePressEvent(QMouseEvent *event) override {
++            QRasterWindow::mousePressEvent(event);
++            m_popup = new QRasterWindow;
++            m_popup->setTransientParent(transientParent());
++            m_popup->setFlags(Qt::Popup);
++            m_popup->resize(100, 100);
++            m_popup->show();
++        }
++
++        QRasterWindow *m_popup = nullptr;
++    };
++
++    class Window : public QRasterWindow {
++    public:
++        void mousePressEvent(QMouseEvent *event) override {
++            QRasterWindow::mousePressEvent(event);
++            m_tooltip = new ToolTip(this);
++        }
++        ToolTip *m_tooltip = nullptr;
++    };
++
++    Window window;
++    window.resize(200, 200);
++    window.show();
++
++    QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
++    exec([=] { xdgToplevel()->sendCompleteConfigure(); });
++    QCOMPOSITOR_TRY_VERIFY(xdgToplevel()->m_xdgSurface->m_committedConfigureSerial);
++
++    exec([=] {
++        auto *surface = xdgToplevel()->surface();
++        auto *p = pointer();
++        auto *c = client();
++        p->sendEnter(surface, {100, 100});
++        p->sendFrame(c);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_pressed);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_released);
++        p->sendFrame(c);
++        p->sendLeave(surface);
++        p->sendFrame(c);
++    });
++
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup());
++    exec([=] { xdgPopup()->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup()->m_xdgSurface->m_committedConfigureSerial);
++    QCOMPOSITOR_TRY_VERIFY(!xdgPopup()->m_grabbed);
++
++    exec([=] {
++        auto *surface = xdgPopup()->surface();
++        auto *p = pointer();
++        auto *c = client();
++        p->sendEnter(surface, {100, 100});
++        p->sendFrame(c);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_pressed);
++        p->sendButton(client(), BTN_LEFT, Pointer::button_state_released);
++        p->sendFrame(c);
++    });
++
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1));
++    exec([=] { xdgPopup(1)->sendCompleteConfigure(QRect(100, 100, 100, 100)); });
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1)->m_xdgSurface->m_committedConfigureSerial);
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(1)->m_grabbed);
++
++    // Close the middle tooltip (it should not close the sibling popup)
++    window.m_tooltip->close();
++
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(1), nullptr);
++    // Verify the remaining xdg surface is a grab popup..
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(0));
++    QCOMPOSITOR_TRY_VERIFY(xdgPopup(0)->m_grabbed);
++
++    window.m_tooltip->m_popup->close();
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(1), nullptr);
++    QCOMPOSITOR_TRY_COMPARE(xdgPopup(0), nullptr);
++}
++
+ // QTBUG-65680
+ void tst_xdgshell::switchPopups()
+ {
+@@ -505,7 +598,7 @@ void tst_xdgshell::minMaxSize()
+     window.show();
+     QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
+ 
+-    exec([=] { xdgToplevel()->sendCompleteConfigure(); });
++    // we don't roundtrip with our configuration the initial commit should be correct
+ 
+     QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.minSize, QSize(100, 100));
+     QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.maxSize, QSize(1000, 1000));
+Submodule qtwebchannel 618422ee..f8949655:
+diff --git a/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp b/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
+index 536eb5c..898d769 100644
+--- a/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
++++ b/qtwebchannel/src/webchannel/qmetaobjectpublisher.cpp
+@@ -186,8 +186,6 @@ Q_DECLARE_TYPEINFO(OverloadResolutionCandidate, Q_MOVABLE_TYPE);
+ QMetaObjectPublisher::QMetaObjectPublisher(QWebChannel *webChannel)
+     : QObject(webChannel)
+     , webChannel(webChannel)
+-    , signalHandler(this)
+-    , clientIsIdle(false)
+     , blockUpdates(false)
+     , propertyUpdatesInitialized(false)
+ {
+@@ -301,17 +299,17 @@ QJsonObject QMetaObjectPublisher::classInfoForObject(const QObject *object, QWeb
+     return data;
+ }
+ 
+-void QMetaObjectPublisher::setClientIsIdle(bool isIdle)
++void QMetaObjectPublisher::setClientIsIdle(bool isIdle, QWebChannelAbstractTransport *transport)
+ {
+-    if (clientIsIdle == isIdle) {
+-        return;
+-    }
+-    clientIsIdle = isIdle;
+-    if (!isIdle && timer.isActive()) {
+-        timer.stop();
+-    } else if (isIdle && !timer.isActive()) {
+-        timer.start(PROPERTY_UPDATE_INTERVAL, this);
+-    }
++    transportState[transport].clientIsIdle = isIdle;
++    if (isIdle)
++        sendEnqueuedPropertyUpdates(transport);
++}
++
++bool QMetaObjectPublisher::isClientIdle(QWebChannelAbstractTransport *transport)
++{
++    auto found = transportState.find(transport);
++    return found != transportState.end() && found.value().clientIsIdle;
+ }
+ 
+ QJsonObject QMetaObjectPublisher::initializeClient(QWebChannelAbstractTransport *transport)
+@@ -333,6 +331,7 @@ QJsonObject QMetaObjectPublisher::initializeClient(QWebChannelAbstractTransport
+ 
+ void QMetaObjectPublisher::initializePropertyUpdates(const QObject *const object, const QJsonObject &objectInfo)
+ {
++    auto *signalHandler = signalHandlerFor(object);
+     foreach (const QJsonValue &propertyInfoVar, objectInfo[KEY_PROPERTIES].toArray()) {
+         const QJsonArray &propertyInfo = propertyInfoVar.toArray();
+         if (propertyInfo.size() < 2) {
+@@ -353,19 +352,19 @@ void QMetaObjectPublisher::initializePropertyUpdates(const QObject *const object
+ 
+         // Only connect for a property update once
+         if (connectedProperties.isEmpty()) {
+-            signalHandler.connectTo(object, signalIndex);
++            signalHandler->connectTo(object, signalIndex);
+         }
+ 
+         connectedProperties.insert(propertyIndex);
+     }
+ 
+     // also always connect to destroyed signal
+-    signalHandler.connectTo(object, s_destroyedSignalIndex);
++    signalHandler->connectTo(object, s_destroyedSignalIndex);
+ }
+ 
+ void QMetaObjectPublisher::sendPendingPropertyUpdates()
+ {
+-    if (blockUpdates || !clientIsIdle || pendingPropertyUpdates.isEmpty()) {
++    if (blockUpdates) {
+         return;
+     }
+ 
+@@ -415,18 +414,19 @@ void QMetaObjectPublisher::sendPendingPropertyUpdates()
+ 
+     // data does not contain specific updates
+     if (!data.isEmpty()) {
+-        setClientIsIdle(false);
+-
+         message[KEY_DATA] = data;
+-        broadcastMessage(message);
++        enqueueBroadcastMessage(message);
+     }
+ 
+     // send every property update which is not supposed to be broadcasted
+     const QHash<QWebChannelAbstractTransport*, QJsonArray>::const_iterator suend = specificUpdates.constEnd();
+     for (QHash<QWebChannelAbstractTransport*, QJsonArray>::const_iterator it = specificUpdates.constBegin(); it != suend; ++it) {
+         message[KEY_DATA] = it.value();
+-        it.key()->sendMessage(message);
++        enqueueMessage(message, it.key());
+     }
++
++    for (auto state = transportState.begin(); state != transportState.end(); ++state)
++        sendEnqueuedPropertyUpdates(state.key());
+ }
+ 
+ QVariant QMetaObjectPublisher::invokeMethod(QObject *const object, const QMetaMethod &method,
+@@ -572,7 +572,7 @@ void QMetaObjectPublisher::signalEmitted(const QObject *object, const int signal
+         }
+     } else {
+         pendingPropertyUpdates[object][signalIndex] = arguments;
+-        if (clientIsIdle && !blockUpdates && !timer.isActive()) {
++        if (!blockUpdates && !timer.isActive()) {
+             timer.start(PROPERTY_UPDATE_INTERVAL, this);
+         }
+     }
+@@ -590,7 +590,7 @@ void QMetaObjectPublisher::objectDestroyed(const QObject *object)
+     // only remove from handler when we initialized the property updates
+     // cf: https://bugreports.qt.io/browse/QTBUG-60250
+     if (propertyUpdatesInitialized) {
+-        signalHandler.remove(object);
++        signalHandlerFor(object)->remove(object);
+         signalToPropertyMap.remove(object);
+     }
+     pendingPropertyUpdates.remove(object);
+@@ -852,6 +852,52 @@ void QMetaObjectPublisher::broadcastMessage(const QJsonObject &message) const
+     }
+ }
+ 
++void QMetaObjectPublisher::enqueueBroadcastMessage(const QJsonObject &message)
++{
++    if (webChannel->d_func()->transports.isEmpty()) {
++        qWarning("QWebChannel is not connected to any transports, cannot send message: %s",
++                 QJsonDocument(message).toJson().constData());
++        return;
++    }
++
++    for (auto *transport : webChannel->d_func()->transports) {
++        auto &state = transportState[transport];
++        state.queuedMessages.append(message);
++    }
++}
++
++void QMetaObjectPublisher::enqueueMessage(const QJsonObject &message,
++                                          QWebChannelAbstractTransport *transport)
++{
++    auto &state = transportState[transport];
++    state.queuedMessages.append(message);
++}
++
++void QMetaObjectPublisher::sendEnqueuedPropertyUpdates(QWebChannelAbstractTransport *transport)
++{
++    auto found = transportState.find(transport);
++    if (found != transportState.end() && found.value().clientIsIdle
++        && !found.value().queuedMessages.isEmpty()) {
++
++        // If the client is connected with an in-process transport, it can
++        // happen that a message triggers a subsequent property change. In
++        // that case, we need to ensure that the queued messages have already
++        // been cleared; otherwise the recursive call will send everythig again.
++        // Case in point: The qmlwebchannel tests fail if we don't clear the
++        // queued messages before sending them out.
++        // For that same reason set the client to "busy" (aka non-idle) just
++        // right before sending out the messages; otherwise a potential
++        // "Idle" type message will not correctly restore the Idle state.
++        const auto messages = std::move(found.value().queuedMessages);
++        Q_ASSERT(found.value().queuedMessages.isEmpty());
++        found.value().clientIsIdle = false;
++
++        for (const auto &message : messages) {
++            transport->sendMessage(message);
++        }
++    }
++}
++
+ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannelAbstractTransport *transport)
+ {
+     if (!webChannel->d_func()->transports.contains(transport)) {
+@@ -866,7 +912,7 @@ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannel
+ 
+     const MessageType type = toType(message.value(KEY_TYPE));
+     if (type == TypeIdle) {
+-        setClientIsIdle(true);
++        setClientIsIdle(true, transport);
+     } else if (type == TypeInit) {
+         if (!message.contains(KEY_ID)) {
+             qWarning("JSON message object is missing the id property: %s",
+@@ -913,9 +959,9 @@ void QMetaObjectPublisher::handleMessage(const QJsonObject &message, QWebChannel
+                 return;
+             transport->sendMessage(createResponse(message.value(KEY_ID), wrapResult(result, transport)));
+         } else if (type == TypeConnectToSignal) {
+-            signalHandler.connectTo(object, message.value(KEY_SIGNAL).toInt(-1));
++            signalHandlerFor(object)->connectTo(object, message.value(KEY_SIGNAL).toInt(-1));
+         } else if (type == TypeDisconnectFromSignal) {
+-            signalHandler.disconnectFrom(object, message.value(KEY_SIGNAL).toInt(-1));
++            signalHandlerFor(object)->disconnectFrom(object, message.value(KEY_SIGNAL).toInt(-1));
+         } else if (type == TypeSetProperty) {
+             setProperty(object, message.value(KEY_PROPERTY).toInt(-1),
+                         message.value(KEY_VALUE));
+@@ -931,6 +977,7 @@ void QMetaObjectPublisher::setBlockUpdates(bool block)
+     blockUpdates = block;
+ 
+     if (!blockUpdates) {
++        timer.start(PROPERTY_UPDATE_INTERVAL, this);
+         sendPendingPropertyUpdates();
+     } else if (timer.isActive()) {
+         timer.stop();
+@@ -948,4 +995,15 @@ void QMetaObjectPublisher::timerEvent(QTimerEvent *event)
+     }
+ }
+ 
++SignalHandler<QMetaObjectPublisher> *QMetaObjectPublisher::signalHandlerFor(const QObject *object)
++{
++    auto thread = object->thread();
++    auto it = signalHandlers.find(thread);
++    if (it == signalHandlers.end()) {
++        it = signalHandlers.emplace(thread, this).first;
++        it->second.moveToThread(thread);
++    }
++    return &it->second;
++}
++
+ QT_END_NAMESPACE
+diff --git a/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h b/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
+index bbd9875..4713ef1 100644
+--- a/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
++++ b/qtwebchannel/src/webchannel/qmetaobjectpublisher_p.h
+@@ -59,6 +59,9 @@
+ #include <QBasicTimer>
+ #include <QPointer>
+ #include <QJsonObject>
++#include <QQueue>
++
++#include <unordered_map>
+ 
+ #include "qwebchannelglobal.h"
+ 
+@@ -109,17 +112,36 @@ public:
+      */
+     void broadcastMessage(const QJsonObject &message) const;
+ 
++    /**
++     * Enqueue the given @p message to all known transports.
++     */
++    void enqueueBroadcastMessage(const QJsonObject &message);
++
++    /**
++     * Enqueue the given @p message to @p transport.
++     */
++    void enqueueMessage(const QJsonObject &message, QWebChannelAbstractTransport *transport);
++
++    /**
++     * If client for given @p transport is idle, send queued messaged to @p transport and then mark
++     * the client as not idle.
++     */
++    void sendEnqueuedPropertyUpdates(QWebChannelAbstractTransport *transport);
++
+     /**
+      * Serialize the QMetaObject of @p object and return it in JSON form.
+      */
+     QJsonObject classInfoForObject(const QObject *object, QWebChannelAbstractTransport *transport);
+ 
+     /**
+-     * Set the client to idle or busy, based on the value of @p isIdle.
+-     *
+-     * When the value changed, start/stop the property update timer accordingly.
++     * Set the client to idle or busy for a single @p transport, based on the value of @p isIdle.
++     */
++    void setClientIsIdle(bool isIdle, QWebChannelAbstractTransport *transport);
++
++    /**
++     * Check that client is idle for @p transport.
+      */
+-    void setClientIsIdle(bool isIdle);
++    bool isClientIdle(QWebChannelAbstractTransport *transport);
+ 
+     /**
+      * Initialize clients by sending them the class information of the registered objects.
+@@ -272,10 +294,18 @@ private:
+     friend class TestWebChannel;
+ 
+     QWebChannel *webChannel;
+-    SignalHandler<QMetaObjectPublisher> signalHandler;
++    std::unordered_map<const QThread*, SignalHandler<QMetaObjectPublisher>> signalHandlers;
++    SignalHandler<QMetaObjectPublisher> *signalHandlerFor(const QObject *object);
+ 
+-    // true when the client is idle, false otherwise
+-    bool clientIsIdle;
++    struct TransportState
++    {
++        TransportState() : clientIsIdle(false) { }
++        // true when the client is idle, false otherwise
++        bool clientIsIdle;
++        // messages to send
++        QQueue<QJsonObject> queuedMessages;
++    };
++    QHash<QWebChannelAbstractTransport *, TransportState> transportState;
+ 
+     // true when no property updates should be sent, false otherwise
+     bool blockUpdates;
+diff --git a/qtwebchannel/src/webchannel/signalhandler_p.h b/qtwebchannel/src/webchannel/signalhandler_p.h
+index 27afadb..d77373c 100644
+--- a/qtwebchannel/src/webchannel/signalhandler_p.h
++++ b/qtwebchannel/src/webchannel/signalhandler_p.h
+@@ -56,6 +56,7 @@
+ #include <QVector>
+ #include <QMetaMethod>
+ #include <QDebug>
++#include <QThread>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -71,6 +72,7 @@ static const int s_destroyedSignalIndex = QObject::staticMetaObject.indexOfMetho
+ template<class Receiver>
+ class SignalHandler : public QObject
+ {
++    Q_DISABLE_COPY(SignalHandler)
+ public:
+     SignalHandler(Receiver *receiver, QObject *parent = 0);
+ 
+@@ -268,6 +270,7 @@ int SignalHandler<Receiver>::qt_metacall(QMetaObject::Call call, int methodId, v
+     if (call == QMetaObject::InvokeMetaMethod) {
+         const QObject *object = sender();
+         Q_ASSERT(object);
++        Q_ASSERT(QThread::currentThread() == object->thread());
+         Q_ASSERT(senderSignalIndex() == methodId);
+         Q_ASSERT(m_connectionsCounter.contains(object));
+         Q_ASSERT(m_connectionsCounter.value(object).contains(methodId));
+diff --git a/qtwebchannel/tests/auto/qml/testwebchannel.cpp b/qtwebchannel/tests/auto/qml/testwebchannel.cpp
+index 9891687..3ca81c2 100644
+--- a/qtwebchannel/tests/auto/qml/testwebchannel.cpp
++++ b/qtwebchannel/tests/auto/qml/testwebchannel.cpp
+@@ -46,7 +46,11 @@ TestWebChannel::~TestWebChannel()
+ 
+ bool TestWebChannel::clientIsIdle() const
+ {
+-    return QWebChannel::d_func()->publisher->clientIsIdle;
++    for (auto *transport : QWebChannel::d_func()->transports) {
++        if (QWebChannel::d_func()->publisher->isClientIdle(transport))
++            return true;
++    }
++    return false;
+ }
+ 
+ QT_END_NAMESPACE
+diff --git a/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp b/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
+index 181da9e..37f989a 100644
+--- a/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
++++ b/qtwebchannel/tests/auto/webchannel/tst_webchannel.cpp
+@@ -785,7 +785,7 @@ void TestWebChannel::testTransportWrapObjectProperties()
+     DummyTransport *dummyTransport = new DummyTransport(this);
+     channel.connectTo(dummyTransport);
+     channel.d_func()->publisher->initializeClient(dummyTransport);
+-    channel.d_func()->publisher->setClientIsIdle(true);
++    channel.d_func()->publisher->setClientIsIdle(true, dummyTransport);
+ 
+     QCOMPARE(channel.d_func()->publisher->transportedWrappedObjects.size(), 0);
+ 
+@@ -943,8 +943,6 @@ void TestWebChannel::testInfiniteRecursion()
+ 
+ void TestWebChannel::testAsyncObject()
+ {
+-    QSKIP("This test is broken. See QTBUG-80729");
+-
+     QWebChannel channel;
+     channel.connectTo(m_dummyTransport);
+ 
+@@ -990,6 +988,50 @@ void TestWebChannel::testAsyncObject()
+     thread.wait();
+ }
+ 
++void TestWebChannel::testPropertyMultipleTransports()
++{
++    DummyTransport transport1;
++    DummyTransport transport2;
++
++    QWebChannel channel;
++    QMetaObjectPublisher *publisher = channel.d_func()->publisher;
++
++    TestObject testObj;
++    testObj.setObjectName("testObject");
++    channel.registerObject(testObj.objectName(), &testObj);
++    channel.connectTo(&transport1);
++    channel.connectTo(&transport2);
++
++    testObj.setProp("Hello");
++
++    publisher->initializeClient(&transport1);
++    publisher->initializeClient(&transport2);
++    publisher->setClientIsIdle(true, &transport1);
++    QCOMPARE(publisher->isClientIdle(&transport1), true);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++    QVERIFY(transport1.messagesSent().isEmpty());
++    QVERIFY(transport2.messagesSent().isEmpty());
++
++    testObj.setProp("World");
++    QTRY_COMPARE_WITH_TIMEOUT(transport1.messagesSent().size(), 1u, 2000);
++    QCOMPARE(transport2.messagesSent().size(), 0u);
++    publisher->setClientIsIdle(true, &transport2);
++    QTRY_COMPARE_WITH_TIMEOUT(transport2.messagesSent().size(), 1u, 2000);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++
++    testObj.setProp("!!!");
++    publisher->setClientIsIdle(true, &transport2);
++    QCOMPARE(publisher->isClientIdle(&transport2), true);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QTRY_COMPARE_WITH_TIMEOUT(transport2.messagesSent().size(), 2u, 2000);
++    QCOMPARE(transport1.messagesSent().size(), 1u);
++    publisher->setClientIsIdle(true, &transport1);
++    QTRY_COMPARE_WITH_TIMEOUT(transport1.messagesSent().size(), 2u, 2000);
++    QCOMPARE(publisher->isClientIdle(&transport1), false);
++    QCOMPARE(publisher->isClientIdle(&transport2), false);
++}
++
+ class FunctionWrapper : public QObject
+ {
+     Q_OBJECT
+@@ -1082,7 +1124,7 @@ void TestWebChannel::benchInitializeClients()
+ 
+         publisher->propertyUpdatesInitialized = false;
+         publisher->signalToPropertyMap.clear();
+-        publisher->signalHandler.clear();
++        publisher->signalHandlers.clear();
+     }
+ }
+ 
+@@ -1107,7 +1149,7 @@ void TestWebChannel::benchPropertyUpdates()
+             obj->change();
+         }
+ 
+-        channel.d_func()->publisher->clientIsIdle = true;
++        channel.d_func()->publisher->setClientIsIdle(true, m_dummyTransport);
+         channel.d_func()->publisher->sendPendingPropertyUpdates();
+     }
+ }
+diff --git a/qtwebchannel/tests/auto/webchannel/tst_webchannel.h b/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
+index eae21f4..dd4e690 100644
+--- a/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
++++ b/qtwebchannel/tests/auto/webchannel/tst_webchannel.h
+@@ -348,6 +348,7 @@ private slots:
+     void testJsonToVariant();
+     void testInfiniteRecursion();
+     void testAsyncObject();
++    void testPropertyMultipleTransports();
+     void testDeletionDuringMethodInvocation_data();
+     void testDeletionDuringMethodInvocation();
+ 
+Submodule qtwebengine f328054d...38e0df6c (commits not present)
+Submodule qtwebsockets 65850954..63fb8da1:
+diff --git a/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp b/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
+index 2affdd5..95f1194 100644
+--- a/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
++++ b/qtwebsockets/src/websockets/qwebsocketdataprocessor.cpp
+@@ -273,6 +273,7 @@ void QWebSocketDataProcessor::clear()
+     if (!m_pConverterState)
+         m_pConverterState = new QTextCodec::ConverterState(QTextCodec::ConvertInvalidToNull |
+                                                            QTextCodec::IgnoreHeader);
++    frame.clear();
+ }
+ 
+ /*!
+diff --git a/qtwebsockets/src/websockets/qwebsocketprotocol.cpp b/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
+index df87a93..d0465f1 100644
+--- a/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
++++ b/qtwebsockets/src/websockets/qwebsocketprotocol.cpp
+@@ -210,7 +210,7 @@ void QWebSocketProtocol::mask(char *payload, quint64 size, quint32 maskingKey)
+                             quint8((maskingKey & 0x0000FF00u) >> 8),
+                             quint8((maskingKey & 0x000000FFu))
+                           };
+-    int i = 0;
++    quint64 i = 0;
+     while (size-- > 0)
+         *payload++ ^= mask[i++ % 4];
+ }
diff --git a/srcpkgs/qt5/template b/srcpkgs/qt5/template
index f879df3a3e706..a0d3036af79a4 100644
--- a/srcpkgs/qt5/template
+++ b/srcpkgs/qt5/template
@@ -2,11 +2,11 @@
 #
 # revbump libqtxdg after bumping patch version
 pkgname=qt5
-version=5.15.7+20221119
+version=5.15.8
+revision=1
+build_style=meta
 # commit f8c9fb304bc3e53b3aa07f962cd74e9160decccc
 # base repo: https://invent.kde.org/qt/qt/qt5
-revision=8
-build_style=meta
 hostmakedepends="cmake clang flex perl glib-devel pkg-config
  python3 re2c ruby which"
 makedepends="SDL2-devel Vulkan-Headers alsa-lib-devel double-conversion-devel
@@ -29,9 +29,9 @@ homepage="https://qt.io/"
 # tarball is generated with `git archive-all qt5-$version.tar.gz`
 # to keep the size smaller qtwebengine, qtwebview, qtdocgallery, qtactiveqt and qtpim
 # can be marked with the export-ignore attribute
-distfiles="https://void.johnnynator.dev/distfiles/qt5-${version}.tar.gz"
-checksum=9d57af471c78029a362276b7c99108ea009f511bb9ba6ff6cb884f6ddd255e9f
-python_version=3
+distfiles="https://download.qt.io/archive/qt/5.15/${version}/single/qt-everywhere-opensource-src-${version}.tar.xz"
+checksum=776a9302c336671f9406a53bd30b8e36f825742b2ec44a57c08217bff0fa86b9
+python_version=2 #unverified
 replaces="qt5-doc<5.6.0 qt5-quick1<5.6.0 qt5-quick1-devel<5.6.0 qt5-webkit<5.6.0 qt5-webkit-devel<5.6.0
  qt5-enginio<5.7.1 qt5-enginio-devel<5.7.1 qt5-plugin-gtk<5.7.1 qt5-canvas3d<5.13.0"
 lib32mode=full
@@ -246,7 +246,6 @@ do_configure() {
 	# opts+=" -v"
 	opts+=" -skip qtwebengine"
 	opts+=" -skip qtwebview"
-	opts+=" -skip qtdocgallery"
 	opts+=" -skip qtpim"
 	opts+=" -skip qtsystems"
 	opts+=" -skip qtspeech"

From a0fc8b1d6c09156236e234d0a44c85be0a6d210e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 061/114] qtav: revbump for ffmpeg4-4.4.3

---
 srcpkgs/qtav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qtav/template b/srcpkgs/qtav/template
index 775d5a139a9ef..2d00ad104355e 100644
--- a/srcpkgs/qtav/template
+++ b/srcpkgs/qtav/template
@@ -4,7 +4,7 @@ version=1.13.0
 revision=2
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel libass-devel libopenal-devel
+makedepends="ffmpeg4-devel libass-devel libopenal-devel
  libva-glx-devel libXv-devel pulseaudio-devel
  qt5-declarative-devel qt5-svg-devel
  qt5-quickcontrols"

From a1047aa179b7555987b252d44421ed7cbe25600b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 062/114] qtox: revbump for ffmpeg-6.0

---
 srcpkgs/qtox/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qtox/template b/srcpkgs/qtox/template
index 39c643fecdb5a..bb70e7f51240a 100644
--- a/srcpkgs/qtox/template
+++ b/srcpkgs/qtox/template
@@ -1,7 +1,7 @@
 # Template file for 'qtox'
 pkgname=qtox
 version=1.17.6
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DUPDATE_CHECK=OFF
  -DGIT_DESCRIBE=${version}

From 9e74322cc48b1e881e50ab3f5e3aaebba34a230c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 063/114] retroarch: revbump for ffmpeg-6.0

---
 srcpkgs/retroarch/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroarch/template b/srcpkgs/retroarch/template
index cb3125c5dbf1a..c65c26f7bf033 100644
--- a/srcpkgs/retroarch/template
+++ b/srcpkgs/retroarch/template
@@ -1,7 +1,7 @@
 # Template file for 'retroarch'
 pkgname=retroarch
 version=1.16.0.3
-revision=3
+revision=4
 build_style=configure
 configure_args="--prefix=/usr --sysconfdir=/etc --enable-networking
  --enable-udev --disable-builtinflac --disable-builtinglslang

From d7b8033c99e475e6c6d37d55d2818e77b0d89ddf Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 064/114] scrcpy: revbump for ffmpeg-6.0

---
 srcpkgs/scrcpy/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/scrcpy/template b/srcpkgs/scrcpy/template
index ac18bc03418ce..f39a7f678ab35 100644
--- a/srcpkgs/scrcpy/template
+++ b/srcpkgs/scrcpy/template
@@ -1,7 +1,7 @@
 # Template file for 'scrcpy'
 pkgname=scrcpy
 version=2.1.1
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcompile_server=false
  -Dprebuilt_server=/usr/share/scrcpy/scrcpy-server-v${version}"

From 8569986e06fa29b943986066e97d9fe339548738 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 17 Oct 2023 08:54:11 -0400
Subject: [PATCH 065/114] New package: spex-x replaces spek-alternative for
 ffmpeg-6.0

---
 srcpkgs/spek-alternative                      |  1 +
 srcpkgs/{spek-alternative => spek-x}/template | 22 ++++++++++++-------
 2 files changed, 15 insertions(+), 8 deletions(-)
 create mode 120000 srcpkgs/spek-alternative
 rename srcpkgs/{spek-alternative => spek-x}/template (52%)

diff --git a/srcpkgs/spek-alternative b/srcpkgs/spek-alternative
new file mode 120000
index 0000000000000..76648236da701
--- /dev/null
+++ b/srcpkgs/spek-alternative
@@ -0,0 +1 @@
+spek-x
\ No newline at end of file
diff --git a/srcpkgs/spek-alternative/template b/srcpkgs/spek-x/template
similarity index 52%
rename from srcpkgs/spek-alternative/template
rename to srcpkgs/spek-x/template
index d7b55c776b1d4..3ded6c2c323e4 100644
--- a/srcpkgs/spek-alternative/template
+++ b/srcpkgs/spek-x/template
@@ -1,18 +1,18 @@
-# Template file for 'spek-alternative'
-pkgname=spek-alternative
-version=0.8.2.3
-revision=2
+# Template file for 'spek-x'
+pkgname=spek-x
+version=0.9.3
+revision=1
 build_style=gnu-configure
 hostmakedepends="automake gettext-devel intltool libtool pkg-config
  wxWidgets-common wxWidgets-gtk3-devel"
 makedepends="ffmpeg-devel wxWidgets-gtk3-devel"
 depends="ffmpeg"
 short_desc="Acoustic spectrum analyser"
-maintainer="Kartik Singh <kartik.ynwa@gmail.com>"
+maintainer="zlice <zlice555@gmail.com>"
 license="GPL-3.0-or-later"
-homepage="https://github.com/withmorten/spek-alternative"
-distfiles="https://github.com/withmorten/spek-alternative/archive/${version}.tar.gz"
-checksum="007ba4b84a310b078e378aa84c8e80783db5821437a757a488c3ecec377e6b2a"
+homepage="https://github.com/MikeWang000000/spek-x"
+distfiles="https://github.com/MikeWang000000/spek-x/archive/v${version}.tar.gz"
+checksum="7f4b109903333cdd310ab2b9176f0dc49a565891376e281a233d342cedf90ef7"
 
 CXXFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
 
@@ -22,3 +22,9 @@ export WX_CONFIG_NAME="wx-config-gtk3"
 pre_configure() {
 	NOCONFIGURE=1 ./autogen.sh
 }
+
+spek-alternative_package() {
+	depends="spek-x"
+	short_desc+=" - transitional dummy package"
+	build_style=meta
+}

From 54ddb5906254e55558de02425685cf76b34704f9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 066/114] ssr: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ssr/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ssr/template b/srcpkgs/ssr/template
index 842b2423aad10..3448ca110eb0c 100644
--- a/srcpkgs/ssr/template
+++ b/srcpkgs/ssr/template
@@ -5,7 +5,7 @@ revision=2
 build_style=cmake
 configure_args="-DWITH_QT5=ON"
 hostmakedepends="pkg-config"
-makedepends="alsa-lib-devel ffmpeg-devel glu-devel jack-devel pulseaudio-devel
+makedepends="alsa-lib-devel ffmpeg4-devel glu-devel jack-devel pulseaudio-devel
  qt5-tools-devel qt5-x11extras-devel libXinerama-devel v4l-utils-devel"
 depends="desktop-file-utils hicolor-icon-theme"
 short_desc="Simple Screen Recorder for programs and games"

From 1c11522e60ad3a5c016b3bbf605112751fa32ae2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 067/114] synfig: revbump for ffmpeg-6.0 and mlt7

---
 srcpkgs/synfig/patches/ffmpeg6.patch | 71 ++++++++++++++++++++++++++++
 srcpkgs/synfig/template              |  4 +-
 2 files changed, 73 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/synfig/patches/ffmpeg6.patch

diff --git a/srcpkgs/synfig/patches/ffmpeg6.patch b/srcpkgs/synfig/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..10780b42782f4
--- /dev/null
+++ b/srcpkgs/synfig/patches/ffmpeg6.patch
@@ -0,0 +1,71 @@
+--- a/src/modules/mod_libavcodec/trgt_av.cpp	2022-10-25 09:14:12.000000000 -0400
++++ b/src/modules/mod_libavcodec/trgt_av.cpp	2023-05-05 21:34:17.899194559 -0400
+@@ -38,6 +41,7 @@
+ extern "C"
+ {
+ #ifdef HAVE_LIBAVFORMAT_AVFORMAT_H
++#	include <libavcodec/avcodec.h>
+ #	include <libavformat/avformat.h>
+ #elif defined(HAVE_AVFORMAT_H)
+ #	include <avformat.h>
+@@ -155,11 +156,11 @@
+     }
+ 
+ 	bool open_video_stream() {
+-		if (avcodec_open2(video_context, NULL, NULL) < 0) {
++		if (avcodec_open2(video_context, nullptr, nullptr) < 0) {
+ 			synfig::error("Target_LibAVCodec: could not open video codec");
+ 			// seems the calling of avcodec_free_context after error will cause crash
+ 			// so just forget about this context
+-			video_context = NULL;
++			video_context = nullptr;
+ 			close();
+ 			return false;
+         }
+@@ -234,15 +235,21 @@
+ 		close();
+ 
+ 		if (!av_registered) {
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 			av_register_all();
++#endif
+ 			av_registered = true;
+ 		}
+ 
+ 		// guess format
+-		AVOutputFormat *format = av_guess_format(NULL, filename.c_str(), NULL);
++#if LIBAVCODEC_VERSION_MAJOR < 59 // FFMPEG < 5.0
++		AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#else
++		const AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#endif
+ 		if (!format) {
+ 			synfig::warning("Target_LibAVCodec: unable to guess the output format, defaulting to MPEG");
+-			format = av_guess_format("mpeg", NULL, NULL);
++			format = av_guess_format("mpeg", nullptr, nullptr);
+ 		}
+ 		if (!format) {
+ 			synfig::error("Target_LibAVCodec: unable to find 'mpeg' output format");
+@@ -254,6 +261,7 @@
+ 		context = avformat_alloc_context();
+ 		assert(context);
+ 		context->oformat = format;
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 		if (filename.size() + 1 > sizeof(context->filename)) {
+ 			synfig::error(
+ 				"Target_LibAVCodec: filename too long, max length is %d, filename is '%s'",
+@@ -263,6 +271,14 @@
+ 			return false;
+ 		}
+ 		memcpy(context->filename, filename.c_str(), filename.size() + 1);
++#else
++		context->url = av_strndup(filename.c_str(), filename.size());
++		if (!context->url) {
++			synfig::error("Target_LibAVCodec: cannot allocate space for filename");
++			close();
++			return false;
++		}
++#endif
+ 
+ 		packet = av_packet_alloc();
+ 		assert(packet);
diff --git a/srcpkgs/synfig/template b/srcpkgs/synfig/template
index d4d3e341a20bf..703cfd7ebac84 100644
--- a/srcpkgs/synfig/template
+++ b/srcpkgs/synfig/template
@@ -6,7 +6,7 @@ revision=4
 build_style=gnu-configure
 configure_args="--with-boost-libdir=${XBPS_CROSS_BASE}/usr/lib"
 hostmakedepends="boost-build ImageMagick pkg-config intltool"
-makedepends="ETL gettext-devel libxml++-devel mlt-devel libmagick-devel
+makedepends="ETL gettext-devel libxml++-devel mlt7-devel libmagick-devel
  libmng-devel boost-build boost-devel libopenexr-devel ffmpeg-devel"
 depends="ImageMagick"
 short_desc="CLI 2D vector and timeline-based animation software"
@@ -20,7 +20,7 @@ CXXFLAGS="-std=c++11 -DHAVE_LOCALE_H=1"
 
 synfig-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision}
-	 libopenexr-devel libxml++-devel mlt-devel"
+	 libopenexr-devel libxml++-devel mlt7-devel"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/bin/synfig-config

From 1310f1f88671edf575de60b0cd8e0d4b7d7a510b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 068/114] timg: revbump for ffmpeg-6.0

---
 srcpkgs/timg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/timg/template b/srcpkgs/timg/template
index 2a2ab763d2fdd..8fb4327535ef9 100644
--- a/srcpkgs/timg/template
+++ b/srcpkgs/timg/template
@@ -1,7 +1,7 @@
 # Template file for 'timg'
 pkgname=timg
 version=1.4.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_OPENSLIDE_SUPPORT=off -Wno-dev"
 hostmakedepends="pkg-config git"

From 5667a9803d60aa418301c8ec94fe17ba6fb301f7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 069/114] tvheadend: revbump for ffmpeg4-4.4.3

---
 srcpkgs/tvheadend/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tvheadend/template b/srcpkgs/tvheadend/template
index 9aea7de4ec705..012d31c4879ff 100644
--- a/srcpkgs/tvheadend/template
+++ b/srcpkgs/tvheadend/template
@@ -8,7 +8,7 @@ configure_args="--enable-dvbscan --disable-ffmpeg_static
 --disable-libx265_static --disable-libvpx_static --disable-libtheora_static
 --disable-libvorbis_static --disable-libfdkaac_static"
 hostmakedepends="gettext pkg-config python3 git which"
-makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg-devel"
+makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg4-devel"
 short_desc="TV streaming server"
 maintainer="lemmi <lemmi@nerd2nerd.org>"
 license="GPL-3.0-only"

From a6fab4739b961e2260fd382f177ba4abaceda4b4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 070/114] unpaper: update to 7.0.0.

---
 srcpkgs/unpaper/template | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/srcpkgs/unpaper/template b/srcpkgs/unpaper/template
index 38ed47a584016..1ff910e722afc 100644
--- a/srcpkgs/unpaper/template
+++ b/srcpkgs/unpaper/template
@@ -1,13 +1,13 @@
 # Template file for 'unpaper'
 pkgname=unpaper
-version=6.1
-revision=3
-build_style=gnu-configure
+version=7.0.0
+revision=1
+build_style=meson
+hostmakedepends="pkg-config meson libxslt"
+makedepends="ffmpeg-devel python3-Sphinx"
+short_desc="Post-processing tool for scanned sheets of paper"
 maintainer="Orphaned <orphan@voidlinux.org>"
-hostmakedepends="pkg-config libxslt"
-makedepends="ffmpeg-devel"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://www.flameeyes.eu/projects/unpaper"
-short_desc="A post-processing tool for scanned sheets of paper"
 distfiles="https://www.flameeyes.eu/files/${pkgname}-${version}.tar.xz"
-checksum=237c84f5da544b3f7709827f9f12c37c346cdf029b1128fb4633f9bafa5cb930
+checksum=2575fbbf26c22719d1cb882b59602c9900c7f747118ac130883f63419be46a80

From 4bf6bfe91afadfc48db96a019653174eca49aea0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 071/114] vba-m: revbump for ffmpeg-6.0

---
 srcpkgs/vba-m/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vba-m/template b/srcpkgs/vba-m/template
index 9c71cefe3f8dd..2223d297c31f5 100644
--- a/srcpkgs/vba-m/template
+++ b/srcpkgs/vba-m/template
@@ -2,7 +2,7 @@
 pkgname=vba-m
 reverts=1292_2
 version=2.1.7
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DENABLE_GTK=TRUE -DENABLE_FFMPEG=TRUE -DENABLE_LINK=TRUE -DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="gettext pkg-config unzip zip yasm wxWidgets-gtk3-devel"

From d49f481b08ea3039391ad181b1383086f2d3205a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 072/114] vice: revbump for ffmpeg4-4.4.3

---
 srcpkgs/vice/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vice/template b/srcpkgs/vice/template
index b1f866d35095e..4beab2c5f9ebd 100644
--- a/srcpkgs/vice/template
+++ b/srcpkgs/vice/template
@@ -26,7 +26,7 @@ makedepends="
 	$(vopt_if gtk3 gtk+3-devel)
 	$(vopt_if gtk3 pulseaudio-devel)
 	$(vopt_if gtk3 pango-devel)
-	$(vopt_if ffmpeg ffmpeg-devel)"
+	$(vopt_if ffmpeg ffmpeg4-devel)"
 short_desc="Emulator for C64, C128, CBM-II, PET, VIC20, Plus4 and C16"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"

From 7c285f7cb6b95a17e7d08d22de04e174e8d3b6ed Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 073/114] waypipe: revbump for ffmpeg-6.0

---
 srcpkgs/waypipe/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waypipe/template b/srcpkgs/waypipe/template
index 6da88b21bf2a1..4da8058400b58 100644
--- a/srcpkgs/waypipe/template
+++ b/srcpkgs/waypipe/template
@@ -1,7 +1,7 @@
 # Template file for 'waypipe'
 pkgname=waypipe
 version=0.8.6
-revision=1
+revision=2
 build_style=meson
 # lto is off because it causes linking errors in armv6l and armv7l (due to NEON)
 configure_args="-Dwerror=false -Dwith_dmabuf=enabled -Dwith_lz4=enabled

From c583c2719fede35edbee5ca79ea950a236de6b46 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 074/114] xpra: revbump for ffmpeg-6.0

---
 srcpkgs/xpra/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xpra/template b/srcpkgs/xpra/template
index 6bfe9be2db650..1eea2962bcb82 100644
--- a/srcpkgs/xpra/template
+++ b/srcpkgs/xpra/template
@@ -1,7 +1,7 @@
 # Template file for 'xpra'
 pkgname=xpra
 version=5.0.4
-revision=1
+revision=2
 build_style=python3-module
 make_build_args="--without-cuda_kernels --without-cuda_rebuild"
 make_install_args="$(vopt_with docs) ${make_build_args}"

From dd808fcf39cd9591be98654d402c60d052aba51c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:07:40 -0400
Subject: [PATCH 075/114] nv-codec-headers: update to 12.0.16.0

---
 srcpkgs/nv-codec-headers/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/nv-codec-headers/template b/srcpkgs/nv-codec-headers/template
index 3d422a61e4891..251e057f826fb 100644
--- a/srcpkgs/nv-codec-headers/template
+++ b/srcpkgs/nv-codec-headers/template
@@ -1,6 +1,6 @@
 # Template file for 'nv-codec-headers'
 pkgname=nv-codec-headers
-version=11.1.5.1
+version=12.0.16.0
 revision=1
 build_style=gnu-makefile
 short_desc="FFmpeg version of headers required to interface with Nvidias codec APIs"
@@ -8,7 +8,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="MIT"
 homepage="http://git.videolan.org/?p=ffmpeg/nv-codec-headers.git"
 distfiles="https://github.com/FFmpeg/nv-codec-headers/archive/n${version}.tar.gz"
-checksum=d095fbd56aa93772471a323be0ebe65504a0f43f06c76a30b6d25da77b06ae9c
+checksum=2a1533b65f55f9da52956faf0627ed3b74868ac0c7f269990edd21369113b48f
 
 post_install() {
 	sed -n '4,25p' include/ffnvcodec/nvEncodeAPI.h > LICENSE

From c146bf7a49b69ed9b297f5b8c5d954e6676619dd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:08:40 -0400
Subject: [PATCH 076/114] openimagedenoise: revbump for ffmpeg-6.0

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index b792813dba7c2..109deb171c3f7 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,7 +1,7 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
 version=1.4.3
-revision=1
+revision=2
 archs="x86_64*"
 build_style=cmake
 hostmakedepends="ispc python3"

From f390ca5339a26dd5f2c3bed98e2e0d365d1a8868 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:31:45 -0400
Subject: [PATCH 077/114] shotcut: revbump for ffmpeg-6.0

---
 srcpkgs/shotcut/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/shotcut/template b/srcpkgs/shotcut/template
index 33141fbd862d7..f46cb53b6bfb9 100644
--- a/srcpkgs/shotcut/template
+++ b/srcpkgs/shotcut/template
@@ -1,7 +1,7 @@
 # Template file for 'shotcut'
 pkgname=shotcut
 version=23.09.29
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSHOTCUT_VERSION=${version}"
 hostmakedepends="pkg-config qt6-tools-devel"

From 0fe153d34abf7a2c1c2363b073e3009e2b7368ab Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:30 -0400
Subject: [PATCH 078/114] shiboken2: revbump for qt5-5.15.8

---
 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch | 1 +
 srcpkgs/shiboken2/template                                 | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
 create mode 120000 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
new file mode 120000
index 0000000000000..efcf3249bd885
--- /dev/null
+++ b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1 @@
+../../python3-pyside2/patches/importlib-machinery-bypass.patch
\ No newline at end of file
diff --git a/srcpkgs/shiboken2/template b/srcpkgs/shiboken2/template
index 883d6a084d868..f3c06ec245a1f 100644
--- a/srcpkgs/shiboken2/template
+++ b/srcpkgs/shiboken2/template
@@ -1,7 +1,7 @@
 # Template file for 'shiboken2'
 pkgname=shiboken2
 version=5.15.10
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/shiboken2"
 build_style=cmake

From 400c30de2c3fb705c19ca32a95f4acb1fc100b91 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:53 -0400
Subject: [PATCH 079/114] python3-pyside2: revbump for qt5-5.15.8

---
 .../patches/importlib-machinery-bypass.patch      | 15 +++++++++++++++
 srcpkgs/python3-pyside2/template                  |  2 +-
 2 files changed, 16 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
new file mode 100644
index 0000000000000..64c429584776b
--- /dev/null
+++ b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1,15 @@
+Using this prevents an error around line 220 below it.
+"AttributeError: module 'importlib' has no attribute 'machinery'"
+The old backup logic is in place and compiles without issues.
+--- a/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:09:34.688912402 -0400
++++ b/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:10:03.395529582 -0400
+@@ -170,9 +170,6 @@
+
+     # 'zipstring_sequence' comes from signature.cpp
+     zipbytes = base64.b64decode(''.join(zipstring_sequence))
+-    if sys.version_info[0] >= 3:
+-        vzip = zipfile.ZipFile(io.BytesIO(zipbytes))
+-        return sys.meta_path, EmbeddableZipImporter(vzip)
+
+     # Old version for Python 2.7, only.
+     import os
diff --git a/srcpkgs/python3-pyside2/template b/srcpkgs/python3-pyside2/template
index 249efa9098842..52626436ce75f 100644
--- a/srcpkgs/python3-pyside2/template
+++ b/srcpkgs/python3-pyside2/template
@@ -1,7 +1,7 @@
 # Template file for 'python3-pyside2'
 pkgname=python3-pyside2
 version=5.15.10
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/pyside2"
 build_style=cmake

From 4c956e361613222bc7de870ece6e78f7dfb80f0c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:35 -0400
Subject: [PATCH 080/114] konqueror: revbump for ffmpeg-6.0

---
 srcpkgs/konqueror/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/konqueror/template b/srcpkgs/konqueror/template
index abfa59e6b7ded..3cc29c12dc1db 100644
--- a/srcpkgs/konqueror/template
+++ b/srcpkgs/konqueror/template
@@ -1,11 +1,11 @@
 # Template file for 'konqueror'
 pkgname=konqueror
 version=23.08.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DDESKTOPTOJSON_EXECUTABLE=/usr/bin/desktoptojson"
 hostmakedepends="extra-cmake-modules python3 qt5-host-tools qt5-qmake kdoctools
-kcoreaddons kconfig gettext"
+ kcoreaddons kconfig gettext"
 makedepends="qt5-devel qt5-webengine-devel qt5-declarative-devel
  qt5-webchannel-devel qt5-location-devel kcmutils-devel kdelibs4support-devel
  karchive-devel khtml-devel kdesu-devel kactivities5-devel"

From b9b6ee37e5f399c5f31ca2a2518001f562631179 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:58 -0400
Subject: [PATCH 081/114] qt5-speech: revbump for qt5-5.15.8

---
 srcpkgs/qt5-speech/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-speech/template b/srcpkgs/qt5-speech/template
index 3ecd10d50650c..2d7d4d4d24535 100644
--- a/srcpkgs/qt5-speech/template
+++ b/srcpkgs/qt5-speech/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-speech'
 pkgname=qt5-speech
 version=5.15.7
-revision=2
+revision=3
 _commit=d32f4a479d38a11f547598004b975f4356424a16
 build_style=qmake
 configure_args="-- -flite -flite-alsa -speechd"

From beb09a2184c573cfcee871deb3b236367bc394c1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 18:38:50 -0400
Subject: [PATCH 082/114] qt5-styleplugins: revbump for qt5-5.15.8

---
 srcpkgs/qt5-styleplugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-styleplugins/template b/srcpkgs/qt5-styleplugins/template
index 96ed97d12cd24..30d93660a2a4e 100644
--- a/srcpkgs/qt5-styleplugins/template
+++ b/srcpkgs/qt5-styleplugins/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-styleplugins'
 pkgname=qt5-styleplugins
 version=5.0.0
-revision=20
+revision=21
 _gitrev=335dbece103e2cbf6c7cf819ab6672c2956b17b3
 build_style=qmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From 7b92a196c7a0acf1b51938d93791ef21a0380461 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 7 May 2023 20:15:03 -0400
Subject: [PATCH 083/114] qt6-webengine: revbump for ffmpeg-6.0

---
 srcpkgs/qt6-webengine/template | 1 +
 1 file changed, 1 insertion(+)

diff --git a/srcpkgs/qt6-webengine/template b/srcpkgs/qt6-webengine/template
index 98cdc680481b3..f33a71bd2a0dc 100644
--- a/srcpkgs/qt6-webengine/template
+++ b/srcpkgs/qt6-webengine/template
@@ -158,6 +158,7 @@ pre_install() {
 }
 
 post_install() {
+	vlicense LICENSES/BSD-3-Clause.txt
 	local _file
 	find "${DESTDIR}"/usr/lib/qt6/examples \
 		-path '*/lib/qt6/**/lib/qt6/*' -type f |

From 680e0a913cfbb60768e8465be1c248e4e0f17d69 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Jun 2023 08:20:22 -0400
Subject: [PATCH 084/114] gtk4: revbump for ffmpeg-6.0

---
 srcpkgs/gtk4/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gtk4/template b/srcpkgs/gtk4/template
index 6a4e20357a86f..ec0c13d2cc5b0 100644
--- a/srcpkgs/gtk4/template
+++ b/srcpkgs/gtk4/template
@@ -1,7 +1,7 @@
 # Template file for 'gtk4'
 pkgname=gtk4
 version=4.12.3
-revision=1
+revision=2
 build_style=meson
 build_helper="gir"
 configure_args="-Dman-pages=true -Ddocumentation=true -Dbuild-tests=false

From 0c29114339bc02fe2f62ab06e206ea1d5a2fc644 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:28:26 -0400
Subject: [PATCH 085/114] siril: revbump for ffmpeg-6.0

---
 srcpkgs/siril/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/siril/template b/srcpkgs/siril/template
index 84332f79d060d..62750dd247548 100644
--- a/srcpkgs/siril/template
+++ b/srcpkgs/siril/template
@@ -1,7 +1,7 @@
 # Template file for 'siril'
 pkgname=siril
 version=0.9.12
-revision=10
+revision=11
 build_style=gnu-configure
 hostmakedepends="pkg-config intltool autoconf automake gettext-devel"
 makedepends="fftw-devel libconfig-devel libopencv-devel libffms2-devel

From 64a87b7447366cefac8e3a491a42eb99da3ea063 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 22 Jun 2023 10:25:02 -0400
Subject: [PATCH 086/114] kdenlive: revbump for ffmpeg-6.0

---
 srcpkgs/kdenlive/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kdenlive/template b/srcpkgs/kdenlive/template
index ec5fe75860948..e69ecff31f272 100644
--- a/srcpkgs/kdenlive/template
+++ b/srcpkgs/kdenlive/template
@@ -1,7 +1,7 @@
 # Template file for 'kdenlive'
 pkgname=kdenlive
 version=23.08.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="
  extra-cmake-modules kconfig kcoreaddons kdoctools pkg-config python3

From 2e4ee606511472b8dead8fb0582e2218840f4ccb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:20:59 -0400
Subject: [PATCH 087/114] tracker-miners: revbump for ffmpeg-6.0

---
 srcpkgs/tracker-miners/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tracker-miners/template b/srcpkgs/tracker-miners/template
index 0b97f47489f81..f196d2bf9e4a4 100644
--- a/srcpkgs/tracker-miners/template
+++ b/srcpkgs/tracker-miners/template
@@ -1,7 +1,7 @@
 # Template file for 'tracker-miners'
 pkgname=tracker-miners
 version=3.6.1
-revision=1
+revision=2
 build_style=meson
 build_helper=qemu
 # missing libgrss for miner_rss

From 3c5f770352f304799fef4587190913eab87468e3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:21:21 -0400
Subject: [PATCH 088/114] mpd: revbump for ffmpeg-6.0

---
 srcpkgs/mpd/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpd/template b/srcpkgs/mpd/template
index 645c1b778e407..60287cc9f6e3c 100644
--- a/srcpkgs/mpd/template
+++ b/srcpkgs/mpd/template
@@ -1,7 +1,7 @@
 # Template file for 'mpd'
 pkgname=mpd
 version=0.23.14
-revision=3
+revision=4
 build_style=meson
 configure_args="-Dopus=enabled -Dmikmod=enabled -Dneighbor=true
  -Dsoundcloud=enabled -Dpipe=true -Dtwolame=enabled -Dbzip2=enabled

From 641188b7a6f713e21088a77226011153eb440cca Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:02 -0400
Subject: [PATCH 089/114] tg_owt: revbump for ffmpeg-6.0

---
 srcpkgs/tg_owt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tg_owt/template b/srcpkgs/tg_owt/template
index 50bc8310b8859..c93262d5c5de6 100644
--- a/srcpkgs/tg_owt/template
+++ b/srcpkgs/tg_owt/template
@@ -1,7 +1,7 @@
 # Template file for 'tg_owt'
 pkgname=tg_owt
 version=0.0.0.20230921
-revision=1
+revision=2
 _commit=3bb3d757681e6cc5135aec6529a753dc3dcdcfb9
 _libyuv_commit=04821d1e7d60845525e8db55c7bcd41ef5be9406
 _abseil_commit=8c0b94e793a66495e0b1f34a5eb26bd7dc672db0

From 4b339e3a50b7695817030c58350ea737368f8407 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:44 -0400
Subject: [PATCH 090/114] telegram-desktop: revbump for ffmpeg-6.0

---
 srcpkgs/telegram-desktop/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/telegram-desktop/template b/srcpkgs/telegram-desktop/template
index 9bd94ce3781ff..d33fc62b10e38 100644
--- a/srcpkgs/telegram-desktop/template
+++ b/srcpkgs/telegram-desktop/template
@@ -1,7 +1,7 @@
 # Template file for 'telegram-desktop'
 pkgname=telegram-desktop
 version=4.11.2
-revision=1
+revision=2
 build_style=cmake
 build_helper="qemu gir"
 configure_args="-DTDESKTOP_API_ID=209235

From 05e85345f185cd4e9ad74f0c4de9af977101f89b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:11:45 -0400
Subject: [PATCH 091/114] gst-plugins-bad1: revbump for ffmpeg-6.0

---
 srcpkgs/gst-plugins-bad1/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index fcd3538cd5cde..976e2889b588e 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-plugins-bad1'
 pkgname=gst-plugins-bad1
 version=1.22.7
-revision=1
+revision=2
 build_helper="gir"
 build_style=meson
 configure_args="-Dpackage-origin=https://voidlinux.org -Ddoc=disabled

From 2b5c6d38e3511d1ae6b59ce146f4af99363bf7ac Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:12:09 -0400
Subject: [PATCH 092/114] openmw: revbump for ffmpeg-6.0

---
 srcpkgs/openmw/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openmw/template b/srcpkgs/openmw/template
index 0abf5ff7cdbec..b57180f1a4446 100644
--- a/srcpkgs/openmw/template
+++ b/srcpkgs/openmw/template
@@ -1,7 +1,7 @@
 # Template file for 'openmw'
 pkgname=openmw
 version=0.48.0
-revision=2
+revision=3
 build_style=cmake
 _recast_commit=e75adf86f91eb3082220085e42dda62679f9a3ea
 _bullet_tag=3.17

From 8620e4b0f5dfbe5a45443198488d5d09fd18c0ef Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:14:53 -0400
Subject: [PATCH 093/114] lms: revbump for ffmpeg-6.0

---
 srcpkgs/lms/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/lms/template b/srcpkgs/lms/template
index e358f75902a98..3b21c458de519 100644
--- a/srcpkgs/lms/template
+++ b/srcpkgs/lms/template
@@ -1,7 +1,7 @@
 # Template file for 'lms'
 pkgname=lms
 version=3.42.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="wt-devel ffmpeg-devel boost-devel libconfig++-devel taglib-devel pam-devel libgraphicsmagick-devel gtest-devel libarchive-devel"

From e4c2606cb0c123f7501f3017b0d7668eb4890943 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:18:18 -0400
Subject: [PATCH 094/114] freecad: revbump for qt5-5.15.8

---
 srcpkgs/freecad/patches/001-include.patch     | 112 ------------------
 .../154-revert-gui-tmp-redirect-stderr.patch  |  68 -----------
 ...d63c8c9b1280978be841d04e68a0a55cceb9.patch |  30 -----
 srcpkgs/freecad/template                      |  13 +-
 4 files changed, 7 insertions(+), 216 deletions(-)
 delete mode 100644 srcpkgs/freecad/patches/001-include.patch
 delete mode 100644 srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
 delete mode 100644 srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch

diff --git a/srcpkgs/freecad/patches/001-include.patch b/srcpkgs/freecad/patches/001-include.patch
deleted file mode 100644
index 28b5af54999b9..0000000000000
--- a/srcpkgs/freecad/patches/001-include.patch
+++ /dev/null
@@ -1,112 +0,0 @@
-From 9a41845a417189776741297c50a3827ce292bc4f Mon Sep 17 00:00:00 2001
-From: Uwe <donovaly@users.noreply.github.com>
-Date: Sun, 3 Jul 2022 22:51:16 +0200
-Subject: [PATCH] [Part] OCCError.h: remove unneeded includes
-
-- also sort includes
----
- src/Mod/Part/App/OCCError.h             | 36 +++----------------------
- src/Mod/Part/App/OffsetCurvePyImp.cpp   | 12 ++++-----
- src/Mod/Part/App/OffsetSurfacePyImp.cpp | 10 +++----
- 3 files changed, 12 insertions(+), 46 deletions(-)
-
---- a/src/Mod/Part/App/OCCError.h
-+++ b/src/Mod/Part/App/OCCError.h
-@@ -23,36 +23,8 @@
- #ifndef _OCCError_h_
- #define _OCCError_h_
- 
--# include <Standard_Version.hxx>
- # include <Standard_Failure.hxx>
--# include <Standard_AbortiveTransaction.hxx>
--# include <Standard_ConstructionError.hxx>
--# if OCC_VERSION_HEX >= 0x060500
--# include <Standard_DefineException.hxx>
--# endif
--# include <Standard_DimensionError.hxx>
--# include <Standard_DimensionMismatch.hxx>
--# include <Standard_DivideByZero.hxx>
--# include <Standard_DomainError.hxx>
--# include <Standard_ImmutableObject.hxx>
--# include <Standard_LicenseError.hxx>
--# include <Standard_LicenseNotFound.hxx>
--# include <Standard_MultiplyDefined.hxx>
--# include <Standard_NegativeValue.hxx>
--# include <Standard_NoMoreObject.hxx>
--# include <Standard_NoSuchObject.hxx>
--# include <Standard_NotImplemented.hxx>
--# include <Standard_NullObject.hxx>
--# include <Standard_NullValue.hxx>
--# include <Standard_NumericError.hxx>
--# include <Standard_OutOfMemory.hxx>
--# include <Standard_OutOfRange.hxx>
--# include <Standard_Overflow.hxx>
--# include <Standard_ProgramError.hxx>
--# include <Standard_RangeError.hxx>
--# include <Standard_TooManyUsers.hxx>
--# include <Standard_TypeMismatch.hxx>
--# include <Standard_Underflow.hxx>
-+# include <Standard_Version.hxx>
- 
- #include <Mod/Part/PartGlobal.h>
- #include <Base/Console.h>
-@@ -88,4 +60,3 @@ PartExport extern PyObject* PartExceptio
- 
- #define PY_CATCH_OCC _PY_CATCH_OCC(return(NULL))
- #endif  // _OCCError_h_
--
---- a/src/Mod/Part/App/OffsetCurvePyImp.cpp
-+++ b/src/Mod/Part/App/OffsetCurvePyImp.cpp
-@@ -20,20 +20,20 @@
-  *                                                                         *
-  ***************************************************************************/
- 
--
- #include "PreCompiled.h"
- #ifndef _PreComp_
- # include <Geom_OffsetCurve.hxx>
- #endif
- 
--#include "OCCError.h"
--#include "Geometry.h"
-+#include <Base/GeometryPyCXX.h>
-+#include <Base/Vector3D.h>
-+#include <Base/VectorPy.h>
-+
- #include "OffsetCurvePy.h"
- #include "OffsetCurvePy.cpp"
-+#include "Geometry.h"
-+#include "OCCError.h"
- 
--#include <Base/GeometryPyCXX.h>
--#include <Base/VectorPy.h>
--#include <Base/Vector3D.h>
- 
- using namespace Part;
- 
---- a/src/Mod/Part/App/OffsetSurfacePyImp.cpp
-+++ b/src/Mod/Part/App/OffsetSurfacePyImp.cpp
-@@ -20,20 +20,16 @@
-  *                                                                         *
-  ***************************************************************************/
- 
--
- #include "PreCompiled.h"
- #ifndef _PreComp_
- # include <Geom_OffsetSurface.hxx>
- # include <memory>
- #endif
- 
--#include <Base/VectorPy.h>
--#include <Base/Vector3D.h>
--
- #include "OCCError.h"
--#include "Geometry.h"
--#include <Mod/Part/App/OffsetSurfacePy.h>
--#include <Mod/Part/App/OffsetSurfacePy.cpp>
-+#include "OffsetSurfacePy.h"
-+#include "OffsetSurfacePy.cpp"
-+
- 
- using namespace Part;
- 
diff --git a/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch b/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
deleted file mode 100644
index d6a9adabdec83..0000000000000
--- a/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
+++ /dev/null
@@ -1,68 +0,0 @@
-see https://github.com/FreeCAD/FreeCAD/commit/cfe94b00d3434f3e2c8b5114d2909f628c330fa8#commitcomment-71413407
-
-upstream: yes
-
-From 7b377a216b9185960e4cee980a6504dc1a755f50 Mon Sep 17 00:00:00 2001
-From: wmayer <wmayer@users.sourceforge.net>
-Date: Wed, 29 Jun 2022 15:19:18 +0200
-Subject: [PATCH] Gui: remove workaround for spnav 0.23 due to build failure
- with musl libc
-
----
- src/Gui/3Dconnexion/GuiNativeEventLinux.cpp | 27 ---------------------
- 1 file changed, 27 deletions(-)
-
---- a/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp
-+++ b/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp
-@@ -21,42 +21,17 @@
-  ***************************************************************************/
- 
- #include <FCConfig.h>
--#include <cstdio>
- 
- #include "GuiNativeEventLinux.h"
- 
- #include "GuiApplicationNativeEventAware.h"
- #include <Base/Console.h>
--#include <Base/FileInfo.h>
- #include <QMainWindow>
- 
- #include <QSocketNotifier>
- 
- #include <spnav.h>
- 
--namespace {
--class RedirectStdErr
--{
--public:
--    RedirectStdErr()
--        : fi(Base::FileInfo::getTempFileName())
--        , file(stderr)
--    {
--        stderr = fopen(fi.filePath().c_str(), "w");
--    }
--    ~RedirectStdErr()
--    {
--        fclose(stderr);
--        fi.deleteFile();
--        stderr = file;
--    }
--
--private:
--    Base::FileInfo fi;
--    FILE* file;
--};
--}
--
- Gui::GuiNativeEvent::GuiNativeEvent(Gui::GUIApplicationNativeEventAware *app)
- : GuiAbstractNativeEvent(app)
- {
-@@ -72,8 +47,6 @@ Gui::GuiNativeEvent::~GuiNativeEvent()
- 
- void Gui::GuiNativeEvent::initSpaceball(QMainWindow *window)
- {
--    // tmp. redirect stderr to a file to suppress an error message from spnav_open()
--    RedirectStdErr err;
-     Q_UNUSED(window)
-     if (spnav_open() == -1) {
-         Base::Console().Log("Couldn't connect to spacenav daemon. Please ignore if you don't have a spacemouse.\n");
diff --git a/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch b/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch
deleted file mode 100644
index d4acf370ca0a4..0000000000000
--- a/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-From fe02d63c8c9b1280978be841d04e68a0a55cceb9 Mon Sep 17 00:00:00 2001
-From: Roy-043 <70520633+Roy-043@users.noreply.github.com>
-Date: Thu, 29 Dec 2022 23:20:38 +0100
-Subject: [PATCH] Draft: update inspect.getargspec to inspect.getfullargspec
- (#8101)
-
----
- src/Mod/Draft/draftguitools/gui_snapper.py | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
---- a/src/Mod/Draft/draftguitools/gui_snapper.py
-+++ b/src/Mod/Draft/draftguitools/gui_snapper.py
-@@ -1426,7 +1426,7 @@ class Snapper:
-             Gui.Snapper.off()
-             self.ui.offUi()
-             if callback:
--                if len(inspect.getargspec(callback).args) > 1:
-+                if len(inspect.getfullargspec(callback).args) > 1:
-                     obj = None
-                     if self.snapInfo and ("Object" in self.snapInfo) and self.snapInfo["Object"]:
-                         obj = App.ActiveDocument.getObject(self.snapInfo["Object"])
-@@ -1445,7 +1445,7 @@ class Snapper:
-             Gui.Snapper.off()
-             self.ui.offUi()
-             if callback:
--                if len(inspect.getargspec(callback).args) > 1:
-+                if len(inspect.getfullargspec(callback).args) > 1:
-                     callback(None, None)
-                 else:
-                     callback(None)
diff --git a/srcpkgs/freecad/template b/srcpkgs/freecad/template
index c135701e38b9a..f8c5b9cf906c7 100644
--- a/srcpkgs/freecad/template
+++ b/srcpkgs/freecad/template
@@ -1,7 +1,7 @@
 # Template file for 'freecad'
 pkgname=freecad
-version=0.20.2
-revision=7
+version=0.21.1
+revision=2
 build_wrksrc="FreeCAD-${version}"
 build_style=cmake
 pycompile_dirs="usr/lib/${pkgname}/Mod"
@@ -23,9 +23,10 @@ makedepends="python3-devel boost-devel libxerces-c-devel zlib-devel occt-devel
  vtk-devel hdf5-devel openmpi-devel libmed-devel eigen double-conversion-devel
  coin3-devel libshiboken2-devel libspnav-devel pyside2-tools
  liblz4-devel libpyside2-python3-devel python3-matplotlib netcdf-devel
- jsoncpp-devel qt5-devel qt5-svg-devel qt5-tools-devel qt5-webkit-devel
- qt5-xmlpatterns-devel coin3-doc glew-devel python3-pivy"
-depends="python3-matplotlib python3-pyside2-webengine python3-pivy"
+ jsoncpp-devel qt5-devel qt5-svg-devel qt5-tools-devel qt5-webengine-devel
+ qt5-xmlpatterns-devel qt5-declarative-devel qt5-webchannel-devel qt5-location-devel
+ coin3-doc glew-devel python3-pivy"
+depends="python3-matplotlib python3-pyside2-webengine python3-pivy python3-GitPython python3-Markdown"
 short_desc="General purpose 3D CAD modeler"
 maintainer="yopito <pierre.bourgin@free.fr>"
 license="LGPL-2.0-or-later"
@@ -35,7 +36,7 @@ distfiles="
  https://github.com/FreeCAD/FreeCAD/archive/${version}.tar.gz
  ${SOURCEFORGE_SITE}/cxx/pycxx-${_pycxxver}.tar.gz
 "
-checksum="46922f3a477e742e1a89cd5346692d63aebb2b67af887b3e463e094a4ae055da
+checksum="e9b1fd0323f101268c7f3be52db42e4a29222f2e306ae6c4a6fc309cb418d35a
  4b91e1e1141c23fbd5039df635c4bb6e75632168548f56b83ce177193c0c98c6"
 python_version=3
 patch_args="-Np1 -d ${build_wrksrc}"

From d88d9af8e220ef4cc03a946cdd2f89cbc948859d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:47:18 -0400
Subject: [PATCH 095/114] libopenshot: revbump for ffmpeg-6.0

---
 srcpkgs/libopenshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenshot/template b/srcpkgs/libopenshot/template
index 8e57c5f592169..7a8f4520e7892 100644
--- a/srcpkgs/libopenshot/template
+++ b/srcpkgs/libopenshot/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenshot'
 pkgname=libopenshot
 version=0.3.0
-revision=3
+revision=4
 build_style=cmake
 # Builds fail with Ruby-2.4.1
 configure_args="-DENABLE_RUBY=OFF -DUSE_SYSTEM_JSONCPP=ON"

From a07723fa7c4f43291f8ff49f882c7bf2a6f9467b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:10:30 -0500
Subject: [PATCH 096/114] openimageio: revbump for ffmpeg-6.0

---
 srcpkgs/openimageio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimageio/template b/srcpkgs/openimageio/template
index 3ce3f9e49d350..27d2131bc0a61 100644
--- a/srcpkgs/openimageio/template
+++ b/srcpkgs/openimageio/template
@@ -1,7 +1,7 @@
 # Template file for 'openimageio'
 pkgname=openimageio
 version=2.4.9.0
-revision=7
+revision=8
 build_style=cmake
 build_helper=qemu
 configure_args="-DUSE_QT=0 -DUSE_PYTHON=0 -DOIIO_BUILD_TESTS=0

From 10e8c9cc5006a43a47fd79ff2bc8cb3b2775cb7c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:11:57 -0500
Subject: [PATCH 097/114] synfigstudio: revbump for ffmpeg-6.0

---
 srcpkgs/synfigstudio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/synfigstudio/template b/srcpkgs/synfigstudio/template
index 09e442da9a680..2bc017cedca6b 100644
--- a/srcpkgs/synfigstudio/template
+++ b/srcpkgs/synfigstudio/template
@@ -2,7 +2,7 @@
 # Should be kept in sync with 'synfig' and 'ETL'
 pkgname=synfigstudio
 version=1.4.4
-revision=4
+revision=5
 build_style=gnu-configure
 configure_args="--disable-update-mimedb"
 hostmakedepends="pkg-config intltool gettext synfig"

From 3488bd117fe6bdccb40706b41aaf7428ccc39b1d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:12:32 -0500
Subject: [PATCH 098/114] gmic: revbump for ffmpeg-6.0

---
 srcpkgs/gmic/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gmic/template b/srcpkgs/gmic/template
index 808953e9b543c..d854808f86aa4 100644
--- a/srcpkgs/gmic/template
+++ b/srcpkgs/gmic/template
@@ -1,7 +1,7 @@
 # Template file for 'gmic'
 pkgname=gmic
 version=3.1.6
-revision=5
+revision=6
 _zart_hash=34ebf6cce0bafb98abe57cec83c4a02cd1abeca0
 create_wrksrc=yes
 build_wrksrc="src"

From cd4caa3852c98a4f4a81b926b7e495d14321e09d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:10 -0500
Subject: [PATCH 099/114] mixxx: revbump for ffmpeg-6.0

---
 srcpkgs/mixxx/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mixxx/template b/srcpkgs/mixxx/template
index 6921996e4e77b..6a79b328c1abf 100644
--- a/srcpkgs/mixxx/template
+++ b/srcpkgs/mixxx/template
@@ -1,7 +1,7 @@
 # Template file for 'mixxx'
 pkgname=mixxx
 version=2.3.3
-revision=6
+revision=7
 build_style=cmake
 configure_args="-DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="extra-cmake-modules pkg-config protobuf qt5-host-tools qt5-qmake"

From 8182fbb020a058a7f687df68df5eeb126e6e87a1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:28 -0500
Subject: [PATCH 100/114] musikcube: revbump for ffmpeg-6.0

---
 srcpkgs/musikcube/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/musikcube/template b/srcpkgs/musikcube/template
index d9e6186e6697b..637952d50aca3 100644
--- a/srcpkgs/musikcube/template
+++ b/srcpkgs/musikcube/template
@@ -1,7 +1,7 @@
 # Template file for 'musikcube'
 pkgname=musikcube
 version=3.0.0
-revision=3
+revision=4
 build_style=cmake
 make_cmd=make
 configure_args="-DNO_NCURSESW=1"

From 53b0e30e693d07898978957b551c53d53ba07437 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:45 -0500
Subject: [PATCH 101/114] electron24: revbump for ffmpeg-6.0

---
 srcpkgs/electron24/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron24/template b/srcpkgs/electron24/template
index a9c865c19c989..b8613e4362bc7 100644
--- a/srcpkgs/electron24/template
+++ b/srcpkgs/electron24/template
@@ -1,7 +1,7 @@
 # Template file for 'electron24'
 pkgname=electron24
 version=24.3.0
-revision=2
+revision=3
 _nodever=18.14.0
 _chromiumver=112.0.5615.165
 archs="x86_64* aarch64*"

From 7132e83b995c284f9ffa60aa9b4398a8b0e8a284 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:00 -0500
Subject: [PATCH 102/114] electron19: revbump for ffmpeg-6.0

---
 srcpkgs/electron19/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron19/template b/srcpkgs/electron19/template
index b18bc792c8221..29fb34e254eea 100644
--- a/srcpkgs/electron19/template
+++ b/srcpkgs/electron19/template
@@ -1,7 +1,7 @@
 # Template file for 'electron19'
 pkgname=electron19
 version=19.0.8
-revision=4
+revision=5
 _nodever=16.14.2
 _chromiumver=102.0.5005.125
 archs="x86_64* aarch64* ppc64le*"

From 30babd7453387254494ed80db95dc4a66554225c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:13 -0500
Subject: [PATCH 103/114] wf-recorder: revbump for ffmpeg-6.0

---
 srcpkgs/wf-recorder/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/wf-recorder/template b/srcpkgs/wf-recorder/template
index 08f986b031006..63c45cf4b814d 100644
--- a/srcpkgs/wf-recorder/template
+++ b/srcpkgs/wf-recorder/template
@@ -1,7 +1,7 @@
 # Template file for 'wf-recorder'
 pkgname=wf-recorder
 version=0.4.1
-revision=2
+revision=3
 build_style=meson
 hostmakedepends="pkg-config scdoc wayland-devel"
 makedepends="wayland-protocols wayland-devel ffmpeg-devel libgbm-devel x264-devel

From a021f5175a2ef565078c63d24e99203029b6a01d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:26 -0500
Subject: [PATCH 104/114] obs: revbump for ffmpeg-6.0

---
 srcpkgs/obs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/obs/template b/srcpkgs/obs/template
index b343f1131bfcf..a25a67433e285 100644
--- a/srcpkgs/obs/template
+++ b/srcpkgs/obs/template
@@ -1,7 +1,7 @@
 # Template file for 'obs'
 pkgname=obs
 version=30.0.0
-revision=2
+revision=3
 archs="i686* x86_64* ppc64le* aarch64* riscv64*"
 build_style=cmake
 configure_args="-DOBS_VERSION_OVERRIDE=${version} -DENABLE_JACK=ON

From 456c22cc7f18a3f447e171ea0fc088db209a409b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:36 -0500
Subject: [PATCH 105/114] mlt7: revbump for ffmpeg-6.0

---
 srcpkgs/mlt7/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mlt7/template b/srcpkgs/mlt7/template
index 98f302ad3a516..7eb8c00fa1580 100644
--- a/srcpkgs/mlt7/template
+++ b/srcpkgs/mlt7/template
@@ -1,7 +1,7 @@
 # Template file for 'mlt7'
 pkgname=mlt7
 version=7.20.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DSWIG_PYTHON=ON -DMOD_QT6=ON"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which

From 0330618499e7b2815149f9d16fa541f933ce7fa8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:48 -0500
Subject: [PATCH 106/114] qt6-multimedia: revbump for ffmpeg-6.0

---
 srcpkgs/qt6-multimedia/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-multimedia/template b/srcpkgs/qt6-multimedia/template
index 67a577e1300fe..1da626ecf515a 100644
--- a/srcpkgs/qt6-multimedia/template
+++ b/srcpkgs/qt6-multimedia/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-multimedia'
 pkgname=qt6-multimedia
 version=6.6.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DQT_FEATURE_gstreamer=ON"
 hostmakedepends="perl qt6-declarative-host-tools pkg-config qt6-shadertools"

From 5fe88b238e7d31e6bf878b87fd23f822500d77d0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:00:15 -0500
Subject: [PATCH 107/114] baresip: revbump for ffmpeg-6.0

---
 srcpkgs/baresip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/baresip/template b/srcpkgs/baresip/template
index 12c8954ef7b9b..b16b67beab8d2 100644
--- a/srcpkgs/baresip/template
+++ b/srcpkgs/baresip/template
@@ -1,7 +1,7 @@
 # Template file for 'baresip'
 pkgname=baresip
 version=3.6.0
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config glib-devel"
 makedepends="libgsm-devel libpng-devel openssl-devel libsndfile-devel

From 201c15b93d40b9a7c0bac33b2435a9ce14b9a964 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:30 -0500
Subject: [PATCH 108/114] QMPlay2: revbump for ffmpeg-6.0

---
 srcpkgs/QMPlay2/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/QMPlay2/template b/srcpkgs/QMPlay2/template
index 46c80f64a1349..942258ce60fb7 100644
--- a/srcpkgs/QMPlay2/template
+++ b/srcpkgs/QMPlay2/template
@@ -1,7 +1,7 @@
 # Template file for 'QMPlay2'
 pkgname=QMPlay2
 version=23.10.22
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools"
 makedepends="alsa-lib-devel ffmpeg-devel libass-devel libcdio-devel libgme-devel

From e3efaaec588e331c1ea10044140dd0775a306394 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:34 -0500
Subject: [PATCH 109/114] alsa-plugins: revbump for ffmpeg-6.0

---
 srcpkgs/alsa-plugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/alsa-plugins/template b/srcpkgs/alsa-plugins/template
index a5708a7d82a8f..7bfdad046c483 100644
--- a/srcpkgs/alsa-plugins/template
+++ b/srcpkgs/alsa-plugins/template
@@ -1,7 +1,7 @@
 # Template file for 'alsa-plugins'
 pkgname=alsa-plugins
 version=1.2.7.1
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--disable-maemo-plugin"
 hostmakedepends="pkg-config"

From 977ed67987639883db8ea31e7505bb1ca7e53155 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:39 -0500
Subject: [PATCH 110/114] dolphin-emu: revbump for ffmpeg-6.0

---
 srcpkgs/dolphin-emu/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/dolphin-emu/template b/srcpkgs/dolphin-emu/template
index 070993aac31d2..96edf50d3e4a1 100644
--- a/srcpkgs/dolphin-emu/template
+++ b/srcpkgs/dolphin-emu/template
@@ -1,7 +1,7 @@
 # Template file for 'dolphin-emu'
 pkgname=dolphin-emu
 version=5.0.19368
-revision=2
+revision=3
 _dolphin_commit=dadbeb4bae7e7fa23af2b46e0add4143094dc107
 _mgba_commit=44e074a15e9651481f7f652ac006a7c9d58cbeb9
 _googletest_commit=be03d00f5f0cc3a997d1a368bee8a1fe93651f48

From 2cef771ac40b75c6dd8d38b8656a58a38f6512f2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:43 -0500
Subject: [PATCH 111/114] minidlna: revbump for ffmpeg-6.0

---
 srcpkgs/minidlna/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/minidlna/template b/srcpkgs/minidlna/template
index 5fa929f3a0c12..742991ecd04af 100644
--- a/srcpkgs/minidlna/template
+++ b/srcpkgs/minidlna/template
@@ -1,7 +1,7 @@
 # Template file for 'minidlna'
 pkgname=minidlna
 version=1.3.3
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="
  --sbindir=/usr/bin

From 63fee9713f96a3c157ae6ed4263ea0c65954e1a2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 17:57:47 -0500
Subject: [PATCH 112/114] mpv: revbump for ffmpeg-6.0

---
 srcpkgs/mpv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpv/template b/srcpkgs/mpv/template
index 4948d1e332cb8..1ac1b167af189 100644
--- a/srcpkgs/mpv/template
+++ b/srcpkgs/mpv/template
@@ -1,7 +1,7 @@
 # Template file for 'mpv'
 pkgname=mpv
 version=0.36.0
-revision=4
+revision=5
 build_style=meson
 configure_args="-Dcdda=enabled -Ddvbin=enabled -Ddvdnav=enabled
  -Dlibmpv=true -Dcplugins=enabled

From ddb62ad3c17109bbd4bd391ce65323355780002d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 17:59:29 -0500
Subject: [PATCH 113/114] qimgv: revbump for ffmpeg-6.0

---
 srcpkgs/qimgv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qimgv/template b/srcpkgs/qimgv/template
index dd341dfe1bfce..8a7e1c081ef12 100644
--- a/srcpkgs/qimgv/template
+++ b/srcpkgs/qimgv/template
@@ -1,7 +1,7 @@
 # Template file for 'qimgv'
 pkgname=qimgv
 version=1.0.2
-revision=3
+revision=4
 build_style=cmake
 configure_args="$(vopt_if video -DVIDEO_SUPPORT=ON -DVIDEO_SUPPORT=OFF)
  $(vopt_if scale -DOPENCV_SUPPORT=ON -DOPENCV_SUPPORT=OFF)

From aa05890c344a1164ec9c9e2e38e6d56dc3d348ce Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 18:00:36 -0500
Subject: [PATCH 114/114] kfilemetadata5: revbump for ffmpeg-6.0

---
 srcpkgs/kfilemetadata5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kfilemetadata5/template b/srcpkgs/kfilemetadata5/template
index 28430f112ab5d..593d2723d95d1 100644
--- a/srcpkgs/kfilemetadata5/template
+++ b/srcpkgs/kfilemetadata5/template
@@ -1,7 +1,7 @@
 # Template file for 'kfilemetadata5'
 pkgname=kfilemetadata5
 version=5.112.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="kcoreaddons extra-cmake-modules pkg-config qt5-host-tools qt5-qmake
  gettext kcoreaddons python3"

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (41 preceding siblings ...)
  2023-12-03 16:45 ` [PR PATCH] [Updated] " zlice
@ 2023-12-03 16:59 ` zlice
  2023-12-05 16:30 ` mhmdanas
                   ` (54 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2023-12-03 16:59 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1229 bytes --]

New comment by zlice on void-packages repository

https://github.com/void-linux/void-packages/pull/43761#issuecomment-1837538654

Comment:
> I'd like to help move this along, is there anything I can do?

I know paper mentioned splitting things where appropriate but I made some QT(5) changes to get this to work. Sure there are some revbumps missing there. Not sure if QT stuff should be separated first.

Have not tested electronXX builds in a bit because they're long.

Have not built kodi or omxplayer, but should work fine since they're still 4.

I suspect `hedgewars` could be made to work fine with 6. I haven't checked if there's any updates or patches in a while.

Any misc packages could be tested for sanity but should work fine. I only run a few vaapi/ffmpeg things regularly: `shotcut`, `firefox(nightly)`, `discord`, `mpv`. Other packages "use" ffmpeg but for side features I never touch like `dolphin-emu` and `blender`.

The `spek-alternative` replacement idk if I did the 'remove old package' thing right.

Did not test 'depends' of packages that bring in 4, just kind of installed it and am able to remove 4 in case of reinstall conflicts. I assume that's good enough to be covered in patch notes?

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (42 preceding siblings ...)
  2023-12-03 16:59 ` zlice
@ 2023-12-05 16:30 ` mhmdanas
  2023-12-09 17:37 ` [PR PATCH] [Updated] " zlice
                   ` (53 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: mhmdanas @ 2023-12-05 16:30 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 271 bytes --]

New comment by mhmdanas on void-packages repository

https://github.com/void-linux/void-packages/pull/43761#issuecomment-1841150741

Comment:
Thanks for all the info, when I get a bit more time (hopefully in a couple weeks), I'll sift through the items you mentioned. :)

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (43 preceding siblings ...)
  2023-12-05 16:30 ` mhmdanas
@ 2023-12-09 17:37 ` zlice
  2023-12-09 17:39 ` zlice
                   ` (52 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2023-12-09 17:37 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 4019 bytes --]

There is an updated pull request by zlice against master on the void-packages repository

https://github.com/zlice/void-packages ffmpeg6-split
https://github.com/void-linux/void-packages/pull/43761

ffmpeg6 split
[ci skip]


#### Testing the changes

- I tested the changes in this PR: **YES**

main testing has been vaapi in Firefox Nightly and enc/dec in Shotcut on Intel A770

#### New package

- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**

#### Local build testing

- I built this PR locally for my native architecture, **x86_64**

#### Discussion

Continuation of https://github.com/void-linux/void-packages/pull/36315

`libavresample` is deprecated, but marked as a dependency when trying to build other packages and install `ffmpeg`(6). I think the right way to handle this is make a meta package and the add to removals?


##### Commit naming / misc

~~Commits are 'dirty' right now, running with [gstreamer 1.22.1 updates](https://github.com/void-linux/void-packages/pull/42861) and [Intel OpenCL](https://github.com/void-linux/void-packages/pull/43084). This will also make [intel packages pr](https://github.com/void-linux/void-packages/pull/41132) obsolete.~~ (see Requirements below)

Maintainer for previous ffmpeg(4) was orphaned, I can put my name in there if that matters, though I don't exactly see myself keeping up on ffmpeg.

~~This updates QT5 which looks like it is usually hosted by Johnny. Not sure if there's any reason to stay there or these sources are fine.~~ Using qt5.15.11 now, revbumps and some patches.

##### STILL FFMPEG4

These are a mix of emulators, games and/or older packages.

- attract (multiple patches in master)
- audacity (https://github.com/audacity/audacity/issues/2305 and https://sourceforge.net/p/portmedia/wiki/portsmf/ is 'beta')
- ccextractor (master patches? no release)
- vice
- kodi
- mlt (only dep left is flowblade)
- ~~synfig (mlt)~~ (work with mlt7, bump synfigstudio)
- tvheadend
- ssr
- ~~spek-alternative~~ (replace with spek-x)
- ppsspp
- olive
- moc
- mediastreamer
- libextractor
- idjc
- hedgewars
- ~~ffmpegthumbnailer~~ (patches for moviedecoder.xxx files)
- ~~ffmpegthumbs~~ (latest compiles)
- deadbeef
- omxplayer
- qtav (fork has ffmpeg 5 patch - https://github.com/cmguo/QtAV)
- `vlc` (vlc4 will support ffmpeg5, there's a patch to build 3.x with ffmpeg5 but it will lack vaapi)
- `osg` (OpenSceneGraph plus `xine-lib`)


##### HAVE NOT BUILT YET

- omxplayer (rpi only? ffmpeg4)
- kodi (big, but ffmpeg4)


##### UPDATED (for ffmpeg6)

- ~~blender: update to 3.5.1~~ ~~will be revbump with~~ https://github.com/void-linux/void-packages/pull/43992
- unpaper: update to 7.0.0.
- guvcview: update to 2.0.8.
- ~~qt5: update to 5.15.8~~ updated by another PR to 5.15.11
- ~~qt5-webengine: update to 5.18.15~~ updated by another PR to 5.15.16 (some patching for ffmpeg build)
- ~~shiboken2: revbump for qt5.15.8 (patch)~~ updated by another PR to 5.15.10
- ~~python3-pyside2: update to 5.15.8 (patch)~~ updated by another PR to 5.15.10
- New package: spex-x replaces spek-alternative for ffmpeg-6.0


##### Requirements

- ~~[gstreamer 1.22.2](https://github.com/void-linux/void-packages/pull/42861)~~ - a few packages use ffmpeg-devel and require a revbump

- ~~[Intel Packages](https://github.com/void-linux/void-packages/pull/41132) [Intel Packages v2](https://github.com/void-linux/void-packages/pull/47330) - ffmpeg4 uses different libraries than 6 (libmfx / Intel-MediaSDK vs only oneVPL that Intel is moving to), both are included here~~. Using replacement oneVPL from OBS update.

- ~~[shotcut 23.05.14](https://github.com/void-linux/void-packages/pull/44260)~~

- https://github.com/void-linux/void-packages/pull/44781 will remove from this PR

A patch file from https://github.com/void-linux/void-packages/pull/43761.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ffmpeg6-split-43761.patch --]
[-- Type: text/x-diff, Size: 220530 bytes --]

From 2a85e027e980d94ac29144bea82a63e5c7279549 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:16:56 -0400
Subject: [PATCH 001/113] ffmpeg: update to 6.0.1.

---
 common/shlibs                                 | 26 +++++---
 srcpkgs/ffmpeg/files/altivec.patch            | 60 -------------------
 .../patches/armv5tel-floating-point.patch     | 18 ------
 ...h-libavcodec-libsvtav1-ten_bit_format.diff | 40 -------------
 .../workaround-mesa-readeon-vaapi-bug.patch   | 28 ---------
 srcpkgs/ffmpeg/template                       | 38 ++++++------
 6 files changed, 37 insertions(+), 173 deletions(-)
 delete mode 100644 srcpkgs/ffmpeg/files/altivec.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 delete mode 100644 srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch

diff --git a/common/shlibs b/common/shlibs
index 863776568fb91..323152d8fd750 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -385,15 +385,23 @@ libid3tag.so.0 libid3tag-0.15.1b_1
 libgif.so.7 giflib-5.1.0_1
 libImlib2.so.1 imlib2-1.4.2_1
 libmp3lame.so.0 lame-3.98.2_1
-libavdevice.so.58 libavdevice-4.0_1
-libavformat.so.58 libavformat-4.0_1
-libswscale.so.5 libswscale-4.0_1
-libswresample.so.3 libswresample-4.0_1
-libavresample.so.4 libavresample-4.0_1
-libpostproc.so.55 libpostproc-4.0_1
-libavcodec.so.58 libavcodec-4.0_1
-libavutil.so.56 libavutil-4.0_1
-libavfilter.so.7 libavfilter-4.0_1
+libavdevice.so.60 libavdevice-6.0_1
+libavformat.so.60 libavformat-6.0_1
+libswscale.so.7 libswscale-6.0_1
+libswresample.so.4 libswresample-6.0_1
+libpostproc.so.57 libpostproc-6.0_1
+libavcodec.so.60 libavcodec-6.0_1
+libavutil.so.58 libavutil-6.0_1
+libavfilter.so.9 libavfilter-6.0_1
+libavdevice.so.58 libavdevice4-4.0_1
+libavformat.so.58 libavformat4-4.0_1
+libswscale.so.5 libswscale4-4.0_1
+libswresample.so.3 libswresample4-4.0_1
+libavresample.so.4 libavresample4-4.0_1
+libpostproc.so.55 libpostproc4-4.0_1
+libavcodec.so.58 libavcodec4-4.0_1
+libavutil.so.56 libavutil4-4.0_1
+libavfilter.so.7 libavfilter4-4.0_1
 libSDL-1.2.so.0 SDL-1.2.14_1
 libSDL_image-1.2.so.0 SDL_image-1.2.10_1
 libx264.so.157 x264-20190507.2245_1
diff --git a/srcpkgs/ffmpeg/files/altivec.patch b/srcpkgs/ffmpeg/files/altivec.patch
deleted file mode 100644
index 9c57200463320..0000000000000
--- a/srcpkgs/ffmpeg/files/altivec.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-revert some altivec specific change on all ppc* except ppc64le*
-
-q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
-conditionally, for ppc* but not ppc64le* (the new code is valid for
-POWER8 VSX which LE targets as a baseline but not BE)"
-
-
-This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
----
- libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
- 1 file changed, 20 insertions(+), 4 deletions(-)
-
-diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
-index 536545293d..c1e2852adb 100644
---- a/libswscale/ppc/yuv2rgb_altivec.c
-+++ b/libswscale/ppc/yuv2rgb_altivec.c
-@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-     vector signed short R1, G1, B1;                                           \
-     vector unsigned char R, G, B;                                             \
-                                                                               \
-+    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
-+    vector unsigned char align_perm;                                          \
-+                                                                              \
-     vector signed short lCY       = c->CY;                                    \
-     vector signed short lOY       = c->OY;                                    \
-     vector signed short lCRV      = c->CRV;                                   \
-@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
-                                                                               \
-         for (j = 0; j < w / 16; j++) {                                        \
--            y0 = vec_xl(0, y1i);                                              \
-+            y1ivP = (const vector unsigned char *) y1i;                       \
-+            y2ivP = (const vector unsigned char *) y2i;                       \
-+            uivP  = (const vector unsigned char *) ui;                        \
-+            vivP  = (const vector unsigned char *) vi;                        \
-+                                                                              \
-+            align_perm = vec_lvsl(0, y1i);                                    \
-+            y0 = (vector unsigned char)                                       \
-+                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
-                                                                               \
--            y1 = vec_xl(0, y2i);                                              \
-+            align_perm = vec_lvsl(0, y2i);                                    \
-+            y1 = (vector unsigned char)                                       \
-+                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
-                                                                               \
--            u = (vector signed char) vec_xl(0, ui);                           \
-+            align_perm = vec_lvsl(0, ui);                                     \
-+            u = (vector signed char)                                          \
-+                    vec_perm(uivP[0], uivP[1], align_perm);                   \
-                                                                               \
--            v = (vector signed char) vec_xl(0, vi);                           \
-+            align_perm = vec_lvsl(0, vi);                                     \
-+            v = (vector signed char)                                          \
-+                    vec_perm(vivP[0], vivP[1], align_perm);                   \
-                                                                               \
-             u = (vector signed char)                                          \
-                     vec_sub(u,                                                \
--- 
-2.27.0
-
diff --git a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
deleted file mode 100644
index 9a55178c74f0f..0000000000000
--- a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
-+++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
-@@ -39,6 +39,15 @@
- #endif
- #include <fenv.h>
- 
-+#if (FE_ALL_EXCEPT == 0)
-+/* E.g. ARM soft float does not define these */
-+#define FE_INVALID    0
-+#define FE_DIVBYZERO  0
-+#define FE_OVERFLOW   0
-+#define FE_UNDERFLOW  0
-+#define FE_INEXACT    0
-+#endif
-+
- #if CONFIG_LIBFONTCONFIG
- #include <fontconfig/fontconfig.h>
- #endif
diff --git a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
deleted file mode 100644
index aa948f7a8a2df..0000000000000
--- a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
+++ /dev/null
@@ -1,40 +0,0 @@
-#==================================================================================================
-# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
-# From: Christopher Degawa <christopher.degawa@intel.com>
-# Date: Thu, 20 Oct 2022 22:55:27 -0500
-# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
-#
-# compressed_ten_bit_format has been deprecated upstream and has no effect
-# and can be removed. Plus, technically it was never used in the first place
-# since it would require the app (ffmpeg) to set it and do additional
-# processing of the input frames.
-#
-# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
-#
-# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
-#==================================================================================================
---- a/libavcodec/libsvtav1.c
-+++ b/libavcodec/libsvtav1.c
-@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
- 
- static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
- {
--    const int    pack_mode_10bit =
--        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
--    const size_t luma_size_8bit  =
--        config->source_width * config->source_height * (1 << pack_mode_10bit);
--    const size_t luma_size_10bit =
--        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
-+    const size_t luma_size = config->source_width * config->source_height *
-+        (config->encoder_bit_depth > 8 ? 2 : 1);
- 
-     EbSvtIOFormat *in_data;
- 
--    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
-+    svt_enc->raw_size = luma_size * 3 / 2;
- 
-     // allocate buffer for in and out
-     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
--- 
-GitLab
-
diff --git a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
deleted file mode 100644
index 00e3f68a415b8..0000000000000
--- a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
-From: Rainer Hochecker <fernetmenta@online.de>
-Date: Sat, 26 Jan 2019 19:48:35 +0100
-Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
-
-This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
-It was hit frequently when watching h264 channels received via DVB-X.
-Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
----
- libavcodec/vaapi_h264.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
-index 5854587a255..f12fdc457a4 100644
---- a/libavcodec/vaapi_h264.c
-+++ b/libavcodec/vaapi_h264.c
-@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
-     H264SliceContext *sl = &h->slice_ctx[0];
-     int ret;
- 
-+    if (pic->nb_slices == 0) {
-+        ret = AVERROR_INVALIDDATA;
-+        goto finish;
-+    }
-+
-     ret = ff_vaapi_decode_issue(avctx, pic);
-     if (ret < 0)
-         goto finish;
diff --git a/srcpkgs/ffmpeg/template b/srcpkgs/ffmpeg/template
index 5968a09b1f12d..52fcf4d68797a 100644
--- a/srcpkgs/ffmpeg/template
+++ b/srcpkgs/ffmpeg/template
@@ -1,15 +1,15 @@
 # Template file for 'ffmpeg'
 # audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
 pkgname=ffmpeg
-version=4.4.4
-revision=5
+version=6.0.1
+revision=1
 short_desc="Decoding, encoding and streaming software"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="https://www.ffmpeg.org"
 changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
 distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
-checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+checksum=9b16b8731d78e596b4be0d720428ca42df642bb2d78342881ff7f5bc29fc9623
 
 hostmakedepends="pkg-config perl"
 makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
@@ -26,12 +26,13 @@ makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-deve
  $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
  $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
  $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
- $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers Vulkan-Tools Vulkan-ValidationLayers')
+ $(vopt_if onevpl 'oneVPL oneVPL-devel')
  $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
 depends="ffplay>=${version}_${revision}"
 
 build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
- dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec onevpl"
 build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
 desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
 desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
@@ -39,9 +40,13 @@ desc_option_sofa="Enable support for AES SOFA"
 desc_option_webp="Enable support for WebP"
 
 case "$XBPS_TARGET_MACHINE" in
-	i686*|x86_64*)
-		hostmakedepends+=" nasm"
+	i686*)
 		build_options_default+=" vaapi vdpau nvenc nvdec"
+		hostmakedepends+=" nasm"
+		;;
+	x86_64*)
+		hostmakedepends+=" nasm"
+		build_options_default+=" vaapi vdpau nvenc nvdec onevpl"
 		;;
 	ppc64*) build_options_default+=" vaapi vdpau";;
 	mips*) CFLAGS="-mnan=legacy";;
@@ -115,18 +120,19 @@ do_configure() {
 		$(vopt_enable x265 libx265) \
 		$(vopt_enable v4l2 libv4l2) \
 		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
-		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		--enable-libbs2b --enable-libvidstab \
 		$(vopt_enable dav1d libdav1d) \
 		$(vopt_enable zimg libzimg) \
 		$(vopt_enable webp libwebp) \
 		$(vopt_enable sofa libmysofa) \
 		$(vopt_enable vulkan) \
+		$(vopt_enable onevpl libvpl) \
 		$(vopt_enable drm libdrm) \
 		$(vopt_enable svtav1 libsvtav1) \
 		$(vopt_enable srt libsrt) \
 		$(vopt_enable rist librist) \
-		$(vopt_if nvenc '--enable-nvenc') \
-		$(vopt_if nvdec '--enable-nvdec')
+		$(vopt_enable nvenc nvenc) \
+		$(vopt_enable nvdec nvdec)
 }
 
 do_build() {
@@ -153,10 +159,8 @@ libavdevice_package() {
 }
 
 libavresample_package() {
-	short_desc="FFmpeg audio resampling library"
-	pkg_install() {
-		vmove "usr/lib/libavresample.so.*"
-	}
+	short_desc="Package deprecated, removal needed"
+	build_style=meta
 }
 
 libavformat_package() {
@@ -210,15 +214,13 @@ ffmpeg-devel_package() {
 		libavfilter>=${version}_${revision}
 		libpostproc>=${version}_${revision}
 		libswscale>=${version}_${revision}
-		libswresample>=${version}_${revision}
-		libavresample>=${version}_${revision}"
+		libswresample>=${version}_${revision}"
 	short_desc+=" - development files"
-
+	conflicts="ffmpeg4-devel"
 	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
 		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
 		nostrip_files="/usr/lib/libavfilter.a"
 	fi
-
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig

From 9b868b4f6bb397da72cfbdc99348fabc61a571ca Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:14 -0400
Subject: [PATCH 002/113] openshot: revbump for ffmpeg6.0

---
 srcpkgs/openshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openshot/template b/srcpkgs/openshot/template
index 8f47851eef354..affb652a9d500 100644
--- a/srcpkgs/openshot/template
+++ b/srcpkgs/openshot/template
@@ -1,7 +1,7 @@
 # Template file for 'openshot'
 pkgname=openshot
 version=3.0.0
-revision=2
+revision=3
 build_style=python3-module
 hostmakedepends="python3 python3-setuptools"
 makedepends="ffmpeg-devel python3-PyQt5"

From 7a40217f85e8aa2b09fa5010975b411a306bb13d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:36 -0400
Subject: [PATCH 003/113] sumo: revbump for ffmpeg6.0

---
 srcpkgs/sumo/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/sumo/template b/srcpkgs/sumo/template
index a3fe134aa5acc..a730afa9fafa9 100644
--- a/srcpkgs/sumo/template
+++ b/srcpkgs/sumo/template
@@ -1,7 +1,7 @@
 # Template file for 'sumo'
 pkgname=sumo
 version=1.12.0
-revision=6
+revision=7
 build_style=cmake
 hostmakedepends="libgdal-tools pkg-config swig python3-setuptools"
 makedepends="python3-devel ffmpeg-devel fox-devel gl2ps-devel libgdal-devel

From 7af395d02e415a7473e46c76bdc0fd05d00f8d06 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:56:22 -0400
Subject: [PATCH 004/113] New package: ffmpeg4-4.4.4.

---
 srcpkgs/ffmpeg4-devel                         |   1 +
 srcpkgs/ffmpeg4/files/altivec.patch           |  60 +++++
 .../patches/armv5tel-floating-point.patch     |  18 ++
 ...h-libavcodec-libsvtav1-ten_bit_format.diff |  40 +++
 .../workaround-mesa-readeon-vaapi-bug.patch   |  28 +++
 srcpkgs/ffmpeg4/template                      | 234 ++++++++++++++++++
 srcpkgs/libavcodec4                           |   1 +
 srcpkgs/libavdevice4                          |   1 +
 srcpkgs/libavfilter4                          |   1 +
 srcpkgs/libavformat4                          |   1 +
 srcpkgs/libavresample4                        |   1 +
 srcpkgs/libavutil4                            |   1 +
 srcpkgs/libpostproc4                          |   1 +
 srcpkgs/libswresample4                        |   1 +
 srcpkgs/libswscale4                           |   1 +
 15 files changed, 390 insertions(+)
 create mode 120000 srcpkgs/ffmpeg4-devel
 create mode 100644 srcpkgs/ffmpeg4/files/altivec.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 create mode 100644 srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
 create mode 100644 srcpkgs/ffmpeg4/template
 create mode 120000 srcpkgs/libavcodec4
 create mode 120000 srcpkgs/libavdevice4
 create mode 120000 srcpkgs/libavfilter4
 create mode 120000 srcpkgs/libavformat4
 create mode 120000 srcpkgs/libavresample4
 create mode 120000 srcpkgs/libavutil4
 create mode 120000 srcpkgs/libpostproc4
 create mode 120000 srcpkgs/libswresample4
 create mode 120000 srcpkgs/libswscale4

diff --git a/srcpkgs/ffmpeg4-devel b/srcpkgs/ffmpeg4-devel
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/ffmpeg4-devel
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/ffmpeg4/files/altivec.patch b/srcpkgs/ffmpeg4/files/altivec.patch
new file mode 100644
index 0000000000000..9c57200463320
--- /dev/null
+++ b/srcpkgs/ffmpeg4/files/altivec.patch
@@ -0,0 +1,60 @@
+revert some altivec specific change on all ppc* except ppc64le*
+
+q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
+conditionally, for ppc* but not ppc64le* (the new code is valid for
+POWER8 VSX which LE targets as a baseline but not BE)"
+
+
+This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
+---
+ libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
+ 1 file changed, 20 insertions(+), 4 deletions(-)
+
+diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
+index 536545293d..c1e2852adb 100644
+--- a/libswscale/ppc/yuv2rgb_altivec.c
++++ b/libswscale/ppc/yuv2rgb_altivec.c
+@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+     vector signed short R1, G1, B1;                                           \
+     vector unsigned char R, G, B;                                             \
+                                                                               \
++    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
++    vector unsigned char align_perm;                                          \
++                                                                              \
+     vector signed short lCY       = c->CY;                                    \
+     vector signed short lOY       = c->OY;                                    \
+     vector signed short lCRV      = c->CRV;                                   \
+@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
+                                                                               \
+         for (j = 0; j < w / 16; j++) {                                        \
+-            y0 = vec_xl(0, y1i);                                              \
++            y1ivP = (const vector unsigned char *) y1i;                       \
++            y2ivP = (const vector unsigned char *) y2i;                       \
++            uivP  = (const vector unsigned char *) ui;                        \
++            vivP  = (const vector unsigned char *) vi;                        \
++                                                                              \
++            align_perm = vec_lvsl(0, y1i);                                    \
++            y0 = (vector unsigned char)                                       \
++                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
+                                                                               \
+-            y1 = vec_xl(0, y2i);                                              \
++            align_perm = vec_lvsl(0, y2i);                                    \
++            y1 = (vector unsigned char)                                       \
++                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
+                                                                               \
+-            u = (vector signed char) vec_xl(0, ui);                           \
++            align_perm = vec_lvsl(0, ui);                                     \
++            u = (vector signed char)                                          \
++                    vec_perm(uivP[0], uivP[1], align_perm);                   \
+                                                                               \
+-            v = (vector signed char) vec_xl(0, vi);                           \
++            align_perm = vec_lvsl(0, vi);                                     \
++            v = (vector signed char)                                          \
++                    vec_perm(vivP[0], vivP[1], align_perm);                   \
+                                                                               \
+             u = (vector signed char)                                          \
+                     vec_sub(u,                                                \
+-- 
+2.27.0
+
diff --git a/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
new file mode 100644
index 0000000000000..9a55178c74f0f
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
@@ -0,0 +1,18 @@
+--- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
++++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
+@@ -39,6 +39,15 @@
+ #endif
+ #include <fenv.h>
+ 
++#if (FE_ALL_EXCEPT == 0)
++/* E.g. ARM soft float does not define these */
++#define FE_INVALID    0
++#define FE_DIVBYZERO  0
++#define FE_OVERFLOW   0
++#define FE_UNDERFLOW  0
++#define FE_INEXACT    0
++#endif
++
+ #if CONFIG_LIBFONTCONFIG
+ #include <fontconfig/fontconfig.h>
+ #endif
diff --git a/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
new file mode 100644
index 0000000000000..aa948f7a8a2df
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
@@ -0,0 +1,40 @@
+#==================================================================================================
+# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
+# From: Christopher Degawa <christopher.degawa@intel.com>
+# Date: Thu, 20 Oct 2022 22:55:27 -0500
+# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
+#
+# compressed_ten_bit_format has been deprecated upstream and has no effect
+# and can be removed. Plus, technically it was never used in the first place
+# since it would require the app (ffmpeg) to set it and do additional
+# processing of the input frames.
+#
+# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
+#
+# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
+#==================================================================================================
+--- a/libavcodec/libsvtav1.c
++++ b/libavcodec/libsvtav1.c
+@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
+ 
+ static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
+ {
+-    const int    pack_mode_10bit =
+-        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
+-    const size_t luma_size_8bit  =
+-        config->source_width * config->source_height * (1 << pack_mode_10bit);
+-    const size_t luma_size_10bit =
+-        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
++    const size_t luma_size = config->source_width * config->source_height *
++        (config->encoder_bit_depth > 8 ? 2 : 1);
+ 
+     EbSvtIOFormat *in_data;
+ 
+-    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
++    svt_enc->raw_size = luma_size * 3 / 2;
+ 
+     // allocate buffer for in and out
+     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
+-- 
+GitLab
+
diff --git a/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
new file mode 100644
index 0000000000000..00e3f68a415b8
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
@@ -0,0 +1,28 @@
+From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
+From: Rainer Hochecker <fernetmenta@online.de>
+Date: Sat, 26 Jan 2019 19:48:35 +0100
+Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
+
+This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
+It was hit frequently when watching h264 channels received via DVB-X.
+Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
+---
+ libavcodec/vaapi_h264.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
+index 5854587a255..f12fdc457a4 100644
+--- a/libavcodec/vaapi_h264.c
++++ b/libavcodec/vaapi_h264.c
+@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
+     H264SliceContext *sl = &h->slice_ctx[0];
+     int ret;
+ 
++    if (pic->nb_slices == 0) {
++        ret = AVERROR_INVALIDDATA;
++        goto finish;
++    }
++
+     ret = ff_vaapi_decode_issue(avctx, pic);
+     if (ret < 0)
+         goto finish;
diff --git a/srcpkgs/ffmpeg4/template b/srcpkgs/ffmpeg4/template
new file mode 100644
index 0000000000000..9ba14bdb8ddf3
--- /dev/null
+++ b/srcpkgs/ffmpeg4/template
@@ -0,0 +1,234 @@
+# Template file for 'ffmpeg4'
+# audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
+pkgname=ffmpeg4
+version=4.4.4
+revision=1
+short_desc="Decoding, encoding and streaming software - ffmpeg4 libraries only"
+maintainer="Orphaned <orphan@voidlinux.org>"
+license="GPL-3.0-or-later"
+homepage="https://www.ffmpeg.org"
+changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
+distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
+checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+
+hostmakedepends="pkg-config perl"
+makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
+ libXext-devel libXvMC-devel libxcb-devel lame-devel libtheora-devel
+ libvorbis-devel x264-devel xvidcore-devel jack-devel SDL2-devel
+ libcdio-paranoia-devel librtmp-devel libmodplug-devel gnutls-devel
+ speex-devel celt-devel harfbuzz-devel libass-devel opus-devel ocl-icd-devel
+ libbs2b-devel libvidstab-devel vmaf-devel $(vopt_if pulseaudio pulseaudio-devel)
+ $(vopt_if vaapi libva-devel) $(vopt_if vdpau libvdpau-devel)
+ $(vopt_if x265 x265-devel) $(vopt_if v4l2 v4l-utils-devel)
+ $(vopt_if fdk_aac fdk-aac-devel) $(vopt_if vpx libvpx-devel)
+ $(vopt_if aom libaom-devel) $(vopt_if sndio sndio-devel)
+ $(vopt_if dav1d libdav1d-devel) $(vopt_if zimg zimg-devel)
+ $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
+ $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
+ $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
+
+build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
+
+desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
+desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
+desc_option_sofa="Enable support for AES SOFA"
+desc_option_webp="Enable support for WebP"
+
+case "$XBPS_TARGET_MACHINE" in
+	i686*|x86_64*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau nvenc nvdec"
+			;;
+	ppc64*) build_options_default+=" vaapi vdpau";;
+	mips*) CFLAGS="-mnan=legacy";;
+esac
+
+if [ "$XBPS_TARGET_WORDSIZE" != "32" ]; then
+	build_options_default+=" svtav1"
+fi
+
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+fi
+
+_apply_patch() {
+	local args="$1" pname="$(basename $2)"
+
+	if [ ! -f ".${pname}_done" ]; then
+		patch -N $args -i $2
+		touch .${pname}_done
+	fi
+}
+
+post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64le*) ;;
+		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
+	esac
+
+	vsed -i libavfilter/vf_libvmaf.c -e 's!/usr/local/share/model/\(vmaf_v0.6.1\).pkl!/usr/share/vmaf/\1.json!'
+}
+
+do_configure() {
+	# Fix gcc on x86_64-musl only
+	if [ "$XBPS_TARGET_MACHINE" = "x86_64-musl" ]; then
+		vsed -i configure -e "s;_cflags_speed='-O3';_cflags_speed='-O2';"
+	fi
+
+	if [ "$CROSS_BUILD" ]; then
+		case "$XBPS_TARGET_MACHINE" in
+			arm*) _arch="arm";;
+			aarch64*) _arch="aarch64";;
+			mips*) _arch="mips";;
+			ppc64*) _arch="ppc64";;
+			ppc*) _arch="ppc";;
+			*) _arch="${XBPS_TARGET_MACHINE%%-musl}";;
+		esac
+
+		_args+=" --enable-cross-compile
+			--sysroot=$XBPS_CROSS_BASE
+			--cross-prefix=${XBPS_CROSS_TRIPLET}-
+			--target-os=linux --arch=${_arch}"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc|ppc-musl) _args+=" --disable-altivec";;
+	esac
+
+	if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+		_args+=" --extra-libs=-latomic"
+	fi
+
+	./configure --prefix=/usr --disable-debug --enable-gpl --enable-gnutls \
+		--disable-stripping \
+		--enable-libcdio --enable-version3 --enable-runtime-cpudetect \
+		--enable-libmp3lame --enable-libvorbis --enable-libxvid \
+		--enable-libx264 $(vopt_enable vpx libvpx) --enable-libtheora \
+		--enable-shared --enable-static --enable-libxcb \
+		$(vopt_enable pulseaudio libpulse) --enable-libfreetype --enable-libmodplug \
+		--enable-libspeex --enable-libcelt --enable-libass \
+		--enable-libopus --enable-librtmp --enable-libjack \
+		$(vopt_if fdk_aac '--enable-nonfree --enable-libfdk-aac') \
+		--disable-libopencore_amrnb --disable-libopencore_amrwb \
+		--disable-libopenjpeg \
+		--enable-postproc --enable-opencl ${_args} --enable-libvmaf ${_args} \
+		$(vopt_enable x265 libx265) \
+		$(vopt_enable v4l2 libv4l2) \
+		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
+		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		$(vopt_enable dav1d libdav1d) \
+		$(vopt_enable zimg libzimg) \
+		$(vopt_enable webp libwebp) \
+		$(vopt_enable sofa libmysofa) \
+		$(vopt_enable vulkan) \
+		$(vopt_enable drm libdrm) \
+		$(vopt_enable svtav1 libsvtav1) \
+		$(vopt_enable srt libsrt) \
+		$(vopt_enable rist librist) \
+		$(vopt_if nvenc '--enable-nvenc') \
+		$(vopt_if nvdec '--enable-nvdec')
+}
+
+do_build() {
+	make ${makejobs}
+	make doc/ff{mpeg,play}.1
+}
+
+do_install() {
+	make DESTDIR=${DESTDIR} install install-man
+	rm -rf ${DESTDIR}/usr/bin
+}
+
+libavcodec4_package() {
+	short_desc="FFmpeg codec library"
+	pkg_install() {
+		vmove "usr/lib/libavcodec.so.*"
+	}
+}
+
+libavdevice4_package() {
+	short_desc="FFmpeg device handling library"
+	pkg_install() {
+		vmove "usr/lib/libavdevice.so.*"
+	}
+}
+
+libavresample4_package() {
+	short_desc="FFmpeg audio resampling library"
+	pkg_install() {
+		vmove "usr/lib/libavresample.so.*"
+	}
+}
+
+libavformat4_package() {
+	short_desc="FFmpeg file format library"
+	pkg_install() {
+		vmove "usr/lib/libavformat.so.*"
+	}
+}
+
+libavutil4_package() {
+	short_desc="FFmpeg utility library"
+	pkg_install() {
+		vmove "usr/lib/libavutil.so.*"
+	}
+}
+
+libavfilter4_package() {
+	short_desc="FFmpeg audio/video filter library"
+	pkg_install() {
+		vmove "usr/lib/libavfilter.so.*"
+	}
+}
+
+libpostproc4_package() {
+	short_desc="FFmpeg video postprocessing library"
+	pkg_install() {
+		vmove "usr/lib/libpostproc.so.*"
+	}
+}
+
+libswscale4_package() {
+	short_desc="FFmpeg video scaling library"
+	pkg_install() {
+		vmove "usr/lib/libswscale.so.*"
+	}
+}
+
+libswresample4_package() {
+	short_desc="FFmpeg video resampling library"
+	pkg_install() {
+		vmove "usr/lib/libswresample.so.*"
+	}
+}
+
+ffmpeg4-devel_package() {
+	depends="
+		libavcodec4>=${version}_${revision}
+		libavdevice4>=${version}_${revision}
+		libavformat4>=${version}_${revision}
+		libavutil4>=${version}_${revision}
+		libavfilter4>=${version}_${revision}
+		libpostproc4>=${version}_${revision}
+		libswscale4>=${version}_${revision}
+		libswresample4>=${version}_${revision}
+		libavresample4>=${version}_${revision}"
+	short_desc+=" - development files"
+	conflicts="ffmpeg-devel"
+	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
+		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
+		nostrip_files="/usr/lib/libavfilter.a"
+	fi
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.a"
+		vmove "usr/lib/*.so"
+		vmove usr/share/ffmpeg/examples
+		vmove usr/share/man/man3
+	}
+}
diff --git a/srcpkgs/libavcodec4 b/srcpkgs/libavcodec4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavcodec4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavdevice4 b/srcpkgs/libavdevice4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavdevice4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavfilter4 b/srcpkgs/libavfilter4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavfilter4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavformat4 b/srcpkgs/libavformat4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavformat4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavresample4 b/srcpkgs/libavresample4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavutil4 b/srcpkgs/libavutil4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavutil4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libpostproc4 b/srcpkgs/libpostproc4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libpostproc4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswresample4 b/srcpkgs/libswresample4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libswresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswscale4 b/srcpkgs/libswscale4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libswscale4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file

From fc412f246b98fb4e168652f43b6b920d6e3ad9ee Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:04 -0400
Subject: [PATCH 005/113] opencv: update to 4.7.0.

---
 common/shlibs           | 104 ++++++++++++++++++++--------------------
 srcpkgs/opencv/template |   8 ++--
 2 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index 323152d8fd750..5427be6f41816 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2085,58 +2085,58 @@ libcapstone.so.5 capstone-5.0.1_1
 libhavege.so.2 libhaveged-1.9.11_1
 libnih.so.1 libnih-1.0.3_1
 libnih-dbus.so.1 libnih-1.0.3_1
-libopencv_quality.so.406 libopencv-4.6.0_1
-libopencv_reg.so.406 libopencv-4.6.0_1
-libopencv_surface_matching.so.406 libopencv-4.6.0_1
-libopencv_xphoto.so.406 libopencv-4.6.0_1
-libopencv_freetype.so.406 libopencv-4.6.0_1
-libopencv_fuzzy.so.406 libopencv-4.6.0_1
-libopencv_hfs.so.406 libopencv-4.6.0_1
-libopencv_img_hash.so.406 libopencv-4.6.0_1
-libopencv_line_descriptor.so.406 libopencv-4.6.0_1
-libopencv_saliency.so.406 libopencv-4.6.0_1
-libopencv_structured_light.so.406 libopencv-4.6.0_1
-libopencv_aruco.so.406 libopencv-4.6.0_1
-libopencv_bgsegm.so.406 libopencv-4.6.0_1
-libopencv_bioinspired.so.406 libopencv-4.6.0_1
-libopencv_ccalib.so.406 libopencv-4.6.0_1
-libopencv_face.so.406 libopencv-4.6.0_1
-libopencv_tracking.so.406 libopencv-4.6.0_1
-libopencv_xfeatures2d.so.406 libopencv-4.6.0_1
-libopencv_optflow.so.406 libopencv-4.6.0_1
-libopencv_ximgproc.so.406 libopencv-4.6.0_1
-libopencv_plot.so.406 libopencv-4.6.0_1
-libopencv_text.so.406 libopencv-4.6.0_1
-libopencv_ml.so.406 libopencv-4.6.0_1
-libopencv_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn.so.406 libopencv-4.6.0_1
-libopencv_shape.so.406 libopencv-4.6.0_1
-libopencv_stitching.so.406 libopencv-4.6.0_1
-libopencv_photo.so.406 libopencv-4.6.0_1
-libopencv_video.so.406 libopencv-4.6.0_1
-libopencv_calib3d.so.406 libopencv-4.6.0_1
-libopencv_features2d.so.406 libopencv-4.6.0_1
-libopencv_flann.so.406 libopencv-4.6.0_1
-libopencv_highgui.so.406 libopencv-4.6.0_1
-libopencv_videoio.so.406 libopencv-4.6.0_1
-libopencv_imgcodecs.so.406 libopencv-4.6.0_1
-libopencv_imgproc.so.406 libopencv-4.6.0_1
-libopencv_core.so.406 libopencv-4.6.0_1
-libopencv_superres.so.406 libopencv-4.6.0_1
-libopencv_videostab.so.406 libopencv-4.6.0_1
-libopencv_gapi.so.406 libopencv-4.6.0_1
-libopencv_xobjdetect.so.406 libopencv-4.6.0_1
-libopencv_datasets.so.406 libopencv-4.6.0_1
-libopencv_dnn_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn_superres.so.406 libopencv-4.6.0_1
-libopencv_dpm.so.406 libopencv-4.6.0_1
-libopencv_phase_unwrapping.so.406 libopencv-4.6.0_1
-libopencv_stereo.so.406 libopencv-4.6.0_1
-libopencv_rapid.so.406 libopencv-4.6.0_1
-libopencv_intensity_transform.so.406 libopencv-4.6.0_1
-libopencv_alphamat.so.406 libopencv-4.6.0_1
-libopencv_barcode.so.406 libopencv-4.6.0_1
-libopencv_mcc.so.406 libopencv-4.6.0_1
+libopencv_quality.so.407 libopencv-4.7.0_1
+libopencv_reg.so.407 libopencv-4.7.0_1
+libopencv_surface_matching.so.407 libopencv-4.7.0_1
+libopencv_xphoto.so.407 libopencv-4.7.0_1
+libopencv_freetype.so.407 libopencv-4.7.0_1
+libopencv_fuzzy.so.407 libopencv-4.7.0_1
+libopencv_hfs.so.407 libopencv-4.7.0_1
+libopencv_img_hash.so.407 libopencv-4.7.0_1
+libopencv_line_descriptor.so.407 libopencv-4.7.0_1
+libopencv_saliency.so.407 libopencv-4.7.0_1
+libopencv_structured_light.so.407 libopencv-4.7.0_1
+libopencv_aruco.so.407 libopencv-4.7.0_1
+libopencv_bgsegm.so.407 libopencv-4.7.0_1
+libopencv_bioinspired.so.407 libopencv-4.7.0_1
+libopencv_ccalib.so.407 libopencv-4.7.0_1
+libopencv_face.so.407 libopencv-4.7.0_1
+libopencv_tracking.so.407 libopencv-4.7.0_1
+libopencv_xfeatures2d.so.407 libopencv-4.7.0_1
+libopencv_optflow.so.407 libopencv-4.7.0_1
+libopencv_ximgproc.so.407 libopencv-4.7.0_1
+libopencv_plot.so.407 libopencv-4.7.0_1
+libopencv_text.so.407 libopencv-4.7.0_1
+libopencv_ml.so.407 libopencv-4.7.0_1
+libopencv_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn.so.407 libopencv-4.7.0_1
+libopencv_shape.so.407 libopencv-4.7.0_1
+libopencv_stitching.so.407 libopencv-4.7.0_1
+libopencv_photo.so.407 libopencv-4.7.0_1
+libopencv_video.so.407 libopencv-4.7.0_1
+libopencv_calib3d.so.407 libopencv-4.7.0_1
+libopencv_features2d.so.407 libopencv-4.7.0_1
+libopencv_flann.so.407 libopencv-4.7.0_1
+libopencv_highgui.so.407 libopencv-4.7.0_1
+libopencv_videoio.so.407 libopencv-4.7.0_1
+libopencv_imgcodecs.so.407 libopencv-4.7.0_1
+libopencv_imgproc.so.407 libopencv-4.7.0_1
+libopencv_core.so.407 libopencv-4.7.0_1
+libopencv_superres.so.407 libopencv-4.7.0_1
+libopencv_videostab.so.407 libopencv-4.7.0_1
+libopencv_gapi.so.407 libopencv-4.7.0_1
+libopencv_xobjdetect.so.407 libopencv-4.7.0_1
+libopencv_datasets.so.407 libopencv-4.7.0_1
+libopencv_dnn_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn_superres.so.407 libopencv-4.7.0_1
+libopencv_dpm.so.407 libopencv-4.7.0_1
+libopencv_phase_unwrapping.so.407 libopencv-4.7.0_1
+libopencv_stereo.so.407 libopencv-4.7.0_1
+libopencv_rapid.so.407 libopencv-4.7.0_1
+libopencv_intensity_transform.so.407 libopencv-4.7.0_1
+libopencv_alphamat.so.407 libopencv-4.7.0_1
+libopencv_barcode.so.407 libopencv-4.7.0_1
+libopencv_mcc.so.407 libopencv-4.7.0_1
 libuniconf.so.4.6 wvstreams-4.6.1_20
 libwvbase.so.4.6 wvstreams-4.6.1_20
 libwvutils.so.4.6 wvstreams-4.6.1_20
diff --git a/srcpkgs/opencv/template b/srcpkgs/opencv/template
index aea4bfc3a265c..ce94de9424d18 100644
--- a/srcpkgs/opencv/template
+++ b/srcpkgs/opencv/template
@@ -1,7 +1,7 @@
 # Template file for 'opencv'
 pkgname=opencv
-version=4.6.0
-revision=6
+version=4.7.0
+revision=1
 create_wrksrc=yes
 build_wrksrc=${pkgname}-${version}
 build_style=cmake
@@ -24,8 +24,8 @@ homepage="https://opencv.org"
 changelog="https://github.com/opencv/opencv/wiki/ChangeLog"
 distfiles="https://github.com/opencv/opencv/archive/${version}.tar.gz
  https://github.com/opencv/opencv_contrib/archive/${version}.tar.gz>contrib.tar.gz"
-checksum="1ec1cba65f9f20fe5a41fda1586e01c70ea0c9a6d7b67c9e13edf0cfe2239277
- 1777d5fd2b59029cf537e5fd6f8aa68d707075822f90bde683fcde086f85f7a7"
+checksum="8df0079cdbe179748a18d44731af62a245a45ebf5085223dc03133954c662973
+ 42df840cf9055e59d0e22c249cfb19f04743e1bdad113d31b1573d3934d62584"
 patch_args="-Np1 -d ${build_wrksrc}"
 # tests hang indenfinitely, even with test data included
 make_check=no

From 07d395bbc8481f004f04c5cf7c767b02ef59150a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 006/113] actiona: revbump for opencv-4.7.0

---
 srcpkgs/actiona/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/actiona/template b/srcpkgs/actiona/template
index cf5f0b7a2ae61..0d899311e6df7 100644
--- a/srcpkgs/actiona/template
+++ b/srcpkgs/actiona/template
@@ -1,7 +1,7 @@
 # Template file for 'actiona'
 pkgname=actiona
 version=3.10.1
-revision=2
+revision=3
 build_style=qmake
 configure_args="PKGCONFIG_OPENCV=opencv4"
 hostmakedepends="pkg-config qt5-plugin-mysql qt5-qmake qt5-host-tools"

From 2a2d43f67485f84324f74a9c6b9ff61f854ad126 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 007/113] retroshare: revbump for opencv-4.7.0

---
 srcpkgs/retroshare/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroshare/template b/srcpkgs/retroshare/template
index bb17569277a7f..49e2c1cbe8a53 100644
--- a/srcpkgs/retroshare/template
+++ b/srcpkgs/retroshare/template
@@ -1,7 +1,7 @@
 # Template file for 'retroshare'
 pkgname=retroshare
 version=0.6.6
-revision=3
+revision=4
 build_style=qmake
 #XXX broadcast feature requires an ancient udp-discovery-cpp which either needs
 # to be fetched+patched (FTBFS) here or packaged :/

From e5ea3f6c5d70bd5a1c59b68878385c1b0a128d67 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 008/113] waifu2x-converter-cpp: revbump for opencv-4.7.0

---
 srcpkgs/waifu2x-converter-cpp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waifu2x-converter-cpp/template b/srcpkgs/waifu2x-converter-cpp/template
index 361b8a23b9497..c5ac17eb54ea4 100644
--- a/srcpkgs/waifu2x-converter-cpp/template
+++ b/srcpkgs/waifu2x-converter-cpp/template
@@ -1,7 +1,7 @@
 # Template file for 'waifu2x-converter-cpp'
 pkgname=waifu2x-converter-cpp
 version=5.2.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DINSTALL_MODELS=ON"
 hostmakedepends="pkg-config"

From ba268f498f0e7ec133494bb74570fe3dfb594de5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:38 -0400
Subject: [PATCH 009/113] vlc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/vlc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vlc/template b/srcpkgs/vlc/template
index abc5eeba01564..5f291b1b81e23 100644
--- a/srcpkgs/vlc/template
+++ b/srcpkgs/vlc/template
@@ -25,7 +25,7 @@ lib32disabled=yes
 hostmakedepends="automake libtool pkg-config flex gettext libgcrypt-devel
  live555-devel gettext-devel $(vopt_if lua lua52) $(vopt_if chromecast protobuf)"
 makedepends="
- avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg-devel freefont-ttf
+ avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg4-devel freefont-ttf
  gnutls-devel jack-devel liba52-devel libass-devel libbluray-devel
  libcdio-devel libdca-devel libdvbpsi-devel libdvdnav-devel libmad-devel
  libmatroska-devel libmodplug-devel libmpcdec-devel libmpeg2-devel

From 4e4615a4392f57100beb4b8edb33180d037fb90f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:55 -0400
Subject: [PATCH 010/113] osg: revbump for ffmpeg4-4.4.3

---
 srcpkgs/osg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/osg/template b/srcpkgs/osg/template
index a9ebbd287933b..755793f7e11bf 100644
--- a/srcpkgs/osg/template
+++ b/srcpkgs/osg/template
@@ -8,7 +8,7 @@ build_helper="qemu"
 configure_args="-DLIB_POSTFIX="
 hostmakedepends="pkg-config xrandr"
 makedepends="MesaLib-devel gtkglext-devel libcurl-devel giflib-devel librsvg-devel
- jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg-devel xine-lib-devel
+ jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg4-devel xine-lib-devel
  SDL2-devel gst-plugins-base1-devel
  $(vopt_if openexr libopenexr-devel)
  $(vopt_if poppler poppler-glib-devel)

From 0fbcd0cc59355816e242e68e5804c0ecb160be1d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:13 -0400
Subject: [PATCH 011/113] xine-lib: revbump for ffmpeg4-4.4.3

---
 srcpkgs/xine-lib/template | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/xine-lib/template b/srcpkgs/xine-lib/template
index 3be4d08eac77a..ed6194c17d11e 100644
--- a/srcpkgs/xine-lib/template
+++ b/srcpkgs/xine-lib/template
@@ -1,14 +1,14 @@
 # Template file for 'xine-lib'
 pkgname=xine-lib
-version=1.2.12
-revision=3
+version=1.2.13
+revision=1
 build_style=gnu-configure
 configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
  --disable-oss"
 hostmakedepends="automake gettext-devel libtool pkg-config perl"
 makedepends="
  zlib-devel alsa-lib-devel libxcb-devel libSM-devel libXext-devel libXv-devel
- libXvMC-devel liba52-devel libmad-devel ffmpeg-devel pulseaudio-devel
+ libXvMC-devel liba52-devel libmad-devel ffmpeg4-devel pulseaudio-devel
  jack-devel samba-devel libflac-devel libmodplug-devel libmpcdec-devel
  speex-devel libtheora-devel libvorbis-devel libdca-devel faad2-devel
  libcdio-devel libbluray-devel aalib-devel libcaca-devel libXinerama-devel
@@ -19,7 +19,7 @@ license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="http://www.xine-project.org"
 changelog="https://sourceforge.net/projects/xine/files/xine-lib/${version}/README.txt/view"
 distfiles="${SOURCEFORGE_SITE}/xine/${pkgname}-${version}.tar.xz"
-checksum=d606270468e1540c2a89c0d7f5fdf11e17ecc0c2698cc0bcb1065ff26abee098
+checksum=5f10d6d718a4a51c17ed1b32b031d4f9b80b061e8276535b2be31e5ac4b75e6f
 
 case "$XBPS_TARGET_MACHINE" in
 	i686-musl)

From a49ea10aa3e67d0e42d0a838f75ad687f0b2adab Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 012/113] arcan: revbump for ffmpeg-6.0

---
 srcpkgs/arcan/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/arcan/template b/srcpkgs/arcan/template
index efd0afe10576d..b91e6900d42a1 100644
--- a/srcpkgs/arcan/template
+++ b/srcpkgs/arcan/template
@@ -2,7 +2,7 @@
 # !! keep synced with: acfgfs aclip aloadimage
 pkgname=arcan
 version=0.6.2.1
-revision=1
+revision=2
 create_wrksrc=yes
 build_wrksrc=arcan/src
 build_style=cmake

From 37dcdaec9ef06049794f2e23bdfa88c0fa27257a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 013/113] attract: revbump for ffmpeg4-4.4.3

---
 srcpkgs/attract/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/attract/template b/srcpkgs/attract/template
index 24017d2bacc24..e760bf0d18aec 100644
--- a/srcpkgs/attract/template
+++ b/srcpkgs/attract/template
@@ -6,7 +6,7 @@ build_style=gnu-makefile
 make_build_args="VERBOSE=1"
 make_use_env=yes
 hostmakedepends="pkg-config"
-makedepends="SFML-devel ffmpeg-devel fontconfig-devel glu-devel libarchive-devel
+makedepends="SFML-devel ffmpeg4-devel fontconfig-devel glu-devel libarchive-devel
  libcurl-devel libjpeg-turbo-devel xine-lib rapidjson libXrandr-devel"
 depends="git"
 short_desc="Attract-Mode is a graphical frontend for emulators"

From 0d0c46a8869bcae22edb089966f14ca5e4abb0b1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 014/113] aubio: revbump for ffmpeg-6.0

---
 srcpkgs/aubio/patches/ffmpeg5.patch | 25 +++++++++++++++++++++++++
 srcpkgs/aubio/template              |  2 +-
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/aubio/patches/ffmpeg5.patch

diff --git a/srcpkgs/aubio/patches/ffmpeg5.patch b/srcpkgs/aubio/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..aace41a6e6d9a
--- /dev/null
+++ b/srcpkgs/aubio/patches/ffmpeg5.patch
@@ -0,0 +1,25 @@
+From 8a05420e5dd8c7b8b2447f82dc919765876511b3 Mon Sep 17 00:00:00 2001
+From: Paul Brossier <piem@piem.org>
+Date: Tue, 25 Jan 2022 18:30:27 +0100
+Subject: [PATCH] [source_avcodec] define FF_API_LAVF_AVCTX for libavcodec >
+ 59, thx @berolinux (closes gh-353)
+
+---
+ src/io/source_avcodec.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/io/source_avcodec.c b/src/io/source_avcodec.c
+index e0ae93b5..1421bd9a 100644
+--- a/src/io/source_avcodec.c
++++ b/src/io/source_avcodec.c
+@@ -68,6 +68,10 @@
+ #define AUBIO_AVCODEC_MAX_BUFFER_SIZE AV_INPUT_BUFFER_MIN_SIZE
+ #endif
+ 
++#if LIBAVCODEC_VERSION_MAJOR >= 59
++#define FF_API_LAVF_AVCTX 1
++#endif
++
+ struct _aubio_source_avcodec_t {
+   uint_t hop_size;
+   uint_t samplerate;
diff --git a/srcpkgs/aubio/template b/srcpkgs/aubio/template
index ad1c4b2569917..7d875cc02541a 100644
--- a/srcpkgs/aubio/template
+++ b/srcpkgs/aubio/template
@@ -1,7 +1,7 @@
 # Template file for 'aubio'
 pkgname=aubio
 version=0.4.9
-revision=1
+revision=2
 build_style=waf3
 # XXX lash, pure and swig support.
 hostmakedepends="pkg-config txt2man"

From 8d4c794d946cd817429e5283997901423ca356ab Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 015/113] audacious-plugins: revbump for ffmpeg-6.0

---
 .../audacious-plugins/patches/ffmpeg5.patch   | 43 +++++++++++++++++++
 srcpkgs/audacious-plugins/template            |  2 +-
 2 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/audacious-plugins/patches/ffmpeg5.patch

diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg5.patch b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..4e5e34099d71c
--- /dev/null
+++ b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
@@ -0,0 +1,43 @@
+commit 298aa371c56c2f52c25a33d9bdec4918b11cebdc
+Author: tibequadorian <tibequadorian@posteo.de>
+Date:   Sat Mar 19 18:40:12 2022 +0100
+
+    audacious-plugins: rebuild against ffmpeg-5.0
+
+diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+new file mode 100644
+index 0000000000..617c11215b
+--- /dev/null
++++ b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+@@ -0,0 +1,31 @@
++From f60beb400eeb1e4778bbfd738bc4a4ccef3de539 Mon Sep 17 00:00:00 2001
++From: John Lindgren <john@jlindgren.net>
++Date: Sat, 5 Mar 2022 12:05:34 -0500
++Subject: [PATCH] Fix build with FFmpeg 5.0
++
++---
++ src/ffaudio/ffaudio-core.cc | 4 ++--
++ 1 file changed, 2 insertions(+), 2 deletions(-)
++
++diff --git a/src/ffaudio/ffaudio-core.cc b/src/ffaudio/ffaudio-core.cc
++index 16dc63e3a..a2b95fd6c 100644
++--- a/src/ffaudio/ffaudio-core.cc
+++++ b/src/ffaudio/ffaudio-core.cc
++@@ -274,7 +274,7 @@ static AVInputFormat * get_format_by_content (const char * name, VFSFile & file)
++         AVProbeData d = {name, buf, filled};
++         score = target;
++ 
++-        f = av_probe_input_format2 (& d, true, & score);
+++        f = (AVInputFormat *) av_probe_input_format2 (& d, true, & score);
++         if (f)
++             break;
++ 
++@@ -347,7 +347,7 @@ static bool find_codec (AVFormatContext * c, CodecInfo * cinfo)
++ #endif
++         if (stream && stream->codecpar && stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
++         {
++-            AVCodec * codec = avcodec_find_decoder (stream->codecpar->codec_id);
+++            AVCodec * codec = (AVCodec *) avcodec_find_decoder (stream->codecpar->codec_id);
++ 
++             if (codec)
++             {
diff --git a/srcpkgs/audacious-plugins/template b/srcpkgs/audacious-plugins/template
index 05e53a9adf78f..4b1968e03de78 100644
--- a/srcpkgs/audacious-plugins/template
+++ b/srcpkgs/audacious-plugins/template
@@ -2,7 +2,7 @@
 #Keep in sync with audacious!
 pkgname=audacious-plugins
 version=4.3.1
-revision=3
+revision=4
 build_style=meson
 configure_args="$(vopt_bool gtk3 gtk) $(vopt_bool gtk3)
  $(vopt_bool qt) $(vopt_bool qt qt6)"

From 5d9e784c42504319b98d30327520517dfde77507 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 016/113] audacity: revbump for ffmpeg4-4.4.3

---
 srcpkgs/audacity/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/audacity/template b/srcpkgs/audacity/template
index 7b838119ab261..fb15f782ac1f7 100644
--- a/srcpkgs/audacity/template
+++ b/srcpkgs/audacity/template
@@ -1,7 +1,7 @@
 # Template file for 'audacity'
 pkgname=audacity
 version=3.4.2
-revision=1
+revision=2
 build_style=cmake
 build_helper="cmake-wxWidgets-gtk3 qemu"
 configure_args="-Daudacity_use_ffmpeg=loaded -Daudacity_lib_preference=system
@@ -12,7 +12,7 @@ configure_args="-Daudacity_use_ffmpeg=loaded -Daudacity_lib_preference=system
  -Daudacity_has_updates_check=OFF -DAUDACITY_BUILD_LEVEL=2"
 hostmakedepends="pkg-config gettext python3"
 makedepends="wxWidgets-gtk3-devel gtk+3-devel expat-devel lame-devel
- libsoxr-devel portaudio-devel sqlite-devel ffmpeg-devel
+ libsoxr-devel portaudio-devel sqlite-devel ffmpeg4-devel
  libid3tag-devel libmad-devel vamp-plugin-sdk-devel libogg-devel
  libvorbis-devel libflac-devel lilv-devel lv2 serd-devel sord-devel
  sratom-devel suil-devel portmidi-devel soundtouch-devel twolame-devel

From c17df09283faf2fd6dddde2654037f6979552d5e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 017/113] avidemux: revbump for ffmpeg-6.0

---
 srcpkgs/avidemux/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/avidemux/template b/srcpkgs/avidemux/template
index 253a0243e2259..557285982d2b8 100644
--- a/srcpkgs/avidemux/template
+++ b/srcpkgs/avidemux/template
@@ -1,7 +1,7 @@
 # Template file for 'avidemux'
 pkgname=avidemux
 version=2.8.0
-revision=2
+revision=3
 # Can't be compiled for aarch64, arm* or mips*
 archs="x86_64* i686*"
 hostmakedepends="cmake pkg-config qt5-host-tools qt5-devel tar yasm"

From eaaba567e06220f1c2c2040ba06550153daf06d2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 018/113] blender: revbump for ffmpeg-6.0

---
 srcpkgs/blender/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index 05fdbf8f747e2..093d6d2004e95 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -9,8 +9,8 @@ configure_args="-DWITH_INSTALL_PORTABLE=OFF -DWITH_PYTHON_INSTALL=OFF
  -DWITH_JACK=ON -DWITH_CODEC_FFMPEG=ON -DWITH_CODEC_SNDFILE=ON -DWITH_OPENMP=ON
  -DWITH_FFTW3=ON -DWITH_MOD_OCEANSIM=ON -DWITH_CYCLES_EMBREE=OFF -DWITH_OPENCOLORIO=ON
  -DWITH_IMAGE_OPENEXR=ON -DWITH_IMAGE_OPENJPEG=ON -DWITH_OPENSUBDIV=ON
- -DWITH_OPENCOLLADA=ON -DWITH_SYSTEM_GLEW=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
- -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_LIBDECOR=ON
+ -DWITH_OPENCOLLADA=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
+ -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_WAYLAND_LIBDECOR=ON
  -DWITH_BUILDINFO=OFF -DPYTHON_VERSION=${py3_ver} -DPYTHON_LIBPATH=/usr/lib
  -DPYTHON_LIBRARY=python${py3_ver}${py3_abiver} -DPYTHON_INCLUDE_DIRS=/${py3_inc}
  -DWITH_SYSTEM_LZO=ON -DWITH_SYSTEM_EIGEN3=ON -DWITH_SYSTEM_FREETYPE=ON"

From 659c3f2189e20e1d131a1cd0d5d167b5ece2c721 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 019/113] cantata: revbump for ffmpeg-6.0

---
 srcpkgs/cantata/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cantata/template b/srcpkgs/cantata/template
index 4b417d80d5c2d..8a90aaa4c07a2 100644
--- a/srcpkgs/cantata/template
+++ b/srcpkgs/cantata/template
@@ -1,7 +1,7 @@
 # Template file for 'cantata'
 pkgname=cantata
 version=2.5.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools qt5-tools"
 makedepends="qt5-devel qt5-tools-devel qt5-svg-devel qt5-xmlpatterns-devel

From 4458ef8b9a381ee827ab6a2442356ce9b585946a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 020/113] ccextractor: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ccextractor/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/ccextractor/template b/srcpkgs/ccextractor/template
index 9abcd82852b27..6eccad5885af9 100644
--- a/srcpkgs/ccextractor/template
+++ b/srcpkgs/ccextractor/template
@@ -1,12 +1,12 @@
 # Template file for 'ccextractor'
 pkgname=ccextractor
 version=0.93
-revision=1
+revision=2
 build_wrksrc="linux"
 build_style=gnu-configure
 configure_args="--enable-ocr --enable-hardsubx"
 hostmakedepends="automake pkg-config"
-makedepends="leptonica-devel tesseract-ocr-devel ffmpeg-devel"
+makedepends="leptonica-devel tesseract-ocr-devel ffmpeg4-devel"
 short_desc="Extract subtitles from video streams"
 maintainer="newbluemoon <blaumolch@mailbox.org>"
 license="GPL-2.0-or-later"

From a023716ba8f2b49799d9c62be8c6dd50888209f7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 021/113] chromaprint: revbump for ffmpeg-6.0

---
 srcpkgs/chromaprint/patches/ffmpeg5.patch | 569 ++++++++++++++++++++++
 srcpkgs/chromaprint/template              |   2 +-
 2 files changed, 570 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromaprint/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromaprint/patches/ffmpeg5.patch b/srcpkgs/chromaprint/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..a9fd307a23c8a
--- /dev/null
+++ b/srcpkgs/chromaprint/patches/ffmpeg5.patch
@@ -0,0 +1,569 @@
+From 8ccad6937177b1b92e40ab8f4447ea27bac009a7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= <lalinsky@gmail.com>
+Date: Fri, 4 Nov 2022 21:47:38 +0100
+Subject: [PATCH] Use FFmpeg 5.x (#120)
+
+* Use FFmpeg 5.1.2 for CI builds
+
+* Build on Ubuntu 20.04
+
+* Upgrade code to FFmpeg 5.x APIs
+
+* Only set FFmpeg include dirs if building tools
+
+* No longer needed
+
+* Use ubuntu 20.04
+---
+ .github/workflows/build.yml                   |   6 +-
+ CMakeLists.txt                                |  16 --
+ package/build.sh                              |   4 +-
+ src/audio/ffmpeg_audio_processor.h            |   2 -
+ src/audio/ffmpeg_audio_processor_avresample.h |  72 -------
+ src/audio/ffmpeg_audio_processor_swresample.h |  18 +-
+ src/audio/ffmpeg_audio_reader.h               | 197 +++++++++---------
+ tests/CMakeLists.txt                          |   6 +
+ 8 files changed, 122 insertions(+), 199 deletions(-)
+ delete mode 100644 src/audio/ffmpeg_audio_processor_avresample.h
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index f8d6a32..4da2405 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -84,9 +84,6 @@ find_package(FFmpeg)
+ if(FFMPEG_LIBRARIES)
+ 	cmake_push_check_state(RESET)
+ 	set(CMAKE_REQUIRED_LIBRARIES ${FFMPEG_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -lm)
+-	check_function_exists(av_packet_unref HAVE_AV_PACKET_UNREF)
+-	check_function_exists(av_frame_alloc HAVE_AV_FRAME_ALLOC)
+-	check_function_exists(av_frame_free HAVE_AV_FRAME_FREE)
+ 	cmake_pop_check_state()
+ endif()
+
+@@ -163,14 +160,11 @@ message(STATUS "Using ${FFT_LIB} for FFT calculations")
+ if(NOT AUDIO_PROCESSOR_LIB)
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+ 		set(AUDIO_PROCESSOR_LIB "swresample")
+-	elseif(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(AUDIO_PROCESSOR_LIB "avresample")
+ 	endif()
+ endif()
+
+ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE OFF)
+ 		set(USE_SWRESAMPLE ON)
+ 		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBSWRESAMPLE_LIBRARIES})
+ 		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBSWRESAMPLE_INCLUDE_DIRS})
+@@ -178,16 +172,6 @@ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+ 	endif()
+ 	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+-elseif(AUDIO_PROCESSOR_LIB STREQUAL "avresample")
+-	if(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE ON)
+-		set(USE_SWRESAMPLE OFF)
+-		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBAVRESAMPLE_LIBRARIES})
+-		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBAVRESAMPLE_INCLUDE_DIRS})
+-	else()
+-		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+-	endif()
+-	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+ else()
+ 	message(STATUS "Building without audio conversion support, please install FFmpeg with libswresample")
+ endif()
+diff --git a/package/build.sh b/package/build.sh
+index da631ae..b41d36e 100755
+--- a/package/build.sh
++++ b/package/build.sh
+@@ -7,8 +7,8 @@ set -eux
+
+ BASE_DIR=$(cd $(dirname $0)/.. && pwd)
+
+-FFMPEG_VERSION=4.4.1
+-FFMPEG_BUILD_TAG=v4.4.1-1
++FFMPEG_VERSION=5.1.2
++FFMPEG_BUILD_TAG=v${FFMPEG_VERSION}-1
+
+ TMP_BUILD_DIR=$BASE_DIR/$(mktemp -d build.XXXXXXXX)
+ trap 'rm -rf $TMP_BUILD_DIR' EXIT
+diff --git a/src/audio/ffmpeg_audio_processor.h b/src/audio/ffmpeg_audio_processor.h
+index 7628fc7..39f4f6d 100644
+--- a/src/audio/ffmpeg_audio_processor.h
++++ b/src/audio/ffmpeg_audio_processor.h
+@@ -10,8 +10,6 @@
+
+ #if defined(USE_SWRESAMPLE)
+ #include "audio/ffmpeg_audio_processor_swresample.h"
+-#elif defined(USE_AVRESAMPLE)
+-#include "audio/ffmpeg_audio_processor_avresample.h"
+ #else
+ #error "no audio processing library"
+ #endif
+diff --git a/src/audio/ffmpeg_audio_processor_avresample.h b/src/audio/ffmpeg_audio_processor_avresample.h
+deleted file mode 100644
+index bd85f92..0000000
+--- a/src/audio/ffmpeg_audio_processor_avresample.h
++++ /dev/null
+@@ -1,72 +0,0 @@
+-// Copyright (C) 2016  Lukas Lalinsky
+-// Distributed under the MIT license, see the LICENSE file for details.
+-
+-#ifndef CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-#define CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-
+-extern "C" {
+-#include <libavresample/avresample.h>
+-}
+-
+-namespace chromaprint {
+-
+-class FFmpegAudioProcessor {
+-public:
+-	FFmpegAudioProcessor() {
+-		m_resample_ctx = avresample_alloc_context();
+-	}
+-
+-	~FFmpegAudioProcessor() {
+-		avresample_free(&m_resample_ctx);
+-	}
+-
+-	void SetCompatibleMode() {
+-		av_opt_set_int(m_resample_ctx, "filter_size", 16, 0);
+-		av_opt_set_int(m_resample_ctx, "phase_shift", 8, 0);
+-		av_opt_set_int(m_resample_ctx, "linear_interp", 1, 0);
+-		av_opt_set_double(m_resample_ctx, "cutoff", 0.8, 0);
+-	}
+-
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "in_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_rate", sample_rate, 0);
+-	}
+-
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "out_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_rate, 0);
+-	}
+-
+-	int Init() {
+-		return avresample_open(m_resample_ctx);
+-	}
+-
+-	int Convert(uint8_t **out, int out_count, const uint8_t **in, int in_count) {
+-		return avresample_convert(m_resample_ctx, out, 0, out_count, (uint8_t **) in, 0, in_count);
+-	}
+-
+-	int Flush(uint8_t **out, int out_count) {
+-		return avresample_read(m_resample_ctx, out, out_count);
+-	}
+-
+-private:
+-	AVAudioResampleContext *m_resample_ctx = nullptr;
+-};
+-
+-}; // namespace chromaprint
+-
+-#endif
+diff --git a/src/audio/ffmpeg_audio_processor_swresample.h b/src/audio/ffmpeg_audio_processor_swresample.h
+index b86266b..b1d4bea 100644
+--- a/src/audio/ffmpeg_audio_processor_swresample.h
++++ b/src/audio/ffmpeg_audio_processor_swresample.h
+@@ -28,30 +28,28 @@ public:
+ 		av_opt_set_double(m_swr_ctx, "cutoff", 0.8, 0);
+ 	}
+
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "icl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "ich", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetInputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "in_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "isf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "in_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "isr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "in_sample_rate", sample_rate, 0);
+ 	}
+
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "ocl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "och", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetOutputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "out_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "osf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "out_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "osr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "out_sample_rate", sample_rate, 0);
+ 	}
+
+ 	int Init() {
+diff --git a/src/audio/ffmpeg_audio_reader.h b/src/audio/ffmpeg_audio_reader.h
+index 5550164..1c6b346 100644
+--- a/src/audio/ffmpeg_audio_reader.h
++++ b/src/audio/ffmpeg_audio_reader.h
+@@ -62,7 +62,7 @@ public:
+ 	bool Read(const int16_t **data, size_t *size);
+
+ 	bool IsOpen() const { return m_opened; }
+-	bool IsFinished() const { return m_finished && !m_got_frame; }
++	bool IsFinished() const { return !m_has_more_packets && !m_has_more_frames; }
+
+ 	std::string GetError() const { return m_error; }
+ 	int GetErrorCode() const { return m_error_code; }
+@@ -74,20 +74,19 @@ private:
+ 	uint8_t *m_convert_buffer[1] = { nullptr };
+ 	int m_convert_buffer_nb_samples = 0;
+
+-	AVInputFormat *m_input_fmt = nullptr;
++	const AVInputFormat *m_input_fmt = nullptr;
+ 	AVDictionary *m_input_opts = nullptr;
+
+ 	AVFormatContext *m_format_ctx = nullptr;
+ 	AVCodecContext *m_codec_ctx = nullptr;
+-	AVFrame *m_frame = nullptr;
+ 	int m_stream_index = -1;
+ 	std::string m_error;
+ 	int m_error_code = 0;
+-	bool m_finished = false;
+ 	bool m_opened = false;
+-	int m_got_frame = 0;
+-	AVPacket m_packet;
+-	AVPacket m_packet0;
++	bool m_has_more_packets = true;
++	bool m_has_more_frames = true;
++	AVPacket *m_packet = nullptr;
++	AVFrame *m_frame = nullptr;
+
+ 	int m_output_sample_rate = 0;
+ 	int m_output_channels = 0;
+@@ -98,19 +97,12 @@ private:
+
+ inline FFmpegAudioReader::FFmpegAudioReader() {
+ 	av_log_set_level(AV_LOG_QUIET);
+-
+-	av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
+ }
+
+ inline FFmpegAudioReader::~FFmpegAudioReader() {
+ 	Close();
+ 	av_dict_free(&m_input_opts);
+ 	av_freep(&m_convert_buffer[0]);
+-	av_packet_unref(&m_packet0);
+ }
+
+ inline bool FFmpegAudioReader::SetInputFormat(const char *name) {
+@@ -135,11 +127,10 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ 	Close();
+
+-    av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
++	m_packet = av_packet_alloc();
++	if (!m_packet) {
++		return false;
++	}
+
+ 	ret = avformat_open_input(&m_format_ctx, file_name.c_str(), m_input_fmt, &m_input_opts);
+ 	if (ret < 0) {
+@@ -153,26 +144,31 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		return false;
+ 	}
+
+-	AVCodec *codec;
++	const AVCodec *codec;
+ 	ret = av_find_best_stream(m_format_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &codec, 0);
+ 	if (ret < 0) {
+ 		SetError("Could not find any audio stream in the file", ret);
+ 		return false;
+ 	}
+ 	m_stream_index = ret;
++	auto stream = m_format_ctx->streams[m_stream_index];
+
+-	m_codec_ctx = m_format_ctx->streams[m_stream_index]->codec;
++	m_codec_ctx = avcodec_alloc_context3(codec);
+ 	m_codec_ctx->request_sample_fmt = AV_SAMPLE_FMT_S16;
+
++	ret = avcodec_parameters_to_context(m_codec_ctx, stream->codecpar);
++	if (ret < 0) {
++		SetError("Could not copy the stream parameters", ret);
++		return false;
++	}
++
+ 	ret = avcodec_open2(m_codec_ctx, codec, nullptr);
+ 	if (ret < 0) {
+ 		SetError("Could not open the codec", ret);
+ 		return false;
+ 	}
+
+-	if (!m_codec_ctx->channel_layout) {
+-		m_codec_ctx->channel_layout = av_get_default_channel_layout(m_codec_ctx->channels);
+-	}
++	av_dump_format(m_format_ctx, 0, "foo", 0);
+
+ 	m_frame = av_frame_alloc();
+ 	if (!m_frame) {
+@@ -183,19 +179,23 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		m_output_sample_rate = m_codec_ctx->sample_rate;
+ 	}
+
+-	if (!m_output_channels) {
+-		m_output_channels = m_codec_ctx->channels;
++	AVChannelLayout output_channel_layout;
++	if (m_output_channels) {
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
++	} else {
++		m_output_channels = m_codec_ctx->ch_layout.nb_channels;
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
+ 	}
+
+-	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
++	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->ch_layout.nb_channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
+ 		m_converter.reset(new FFmpegAudioProcessor());
+ 		m_converter->SetCompatibleMode();
+ 		m_converter->SetInputSampleFormat(m_codec_ctx->sample_fmt);
+ 		m_converter->SetInputSampleRate(m_codec_ctx->sample_rate);
+-		m_converter->SetInputChannelLayout(m_codec_ctx->channel_layout);
++		m_converter->SetInputChannelLayout(&(m_codec_ctx->ch_layout));
+ 		m_converter->SetOutputSampleFormat(AV_SAMPLE_FMT_S16);
+ 		m_converter->SetOutputSampleRate(m_output_sample_rate);
+-		m_converter->SetOutputChannelLayout(av_get_default_channel_layout(m_output_channels));
++		m_converter->SetOutputChannelLayout(&output_channel_layout);
+ 		auto ret = m_converter->Init();
+ 		if (ret != 0) {
+ 			SetError("Could not create an audio converter instance", ret);
+@@ -203,10 +203,11 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		}
+ 	}
+
++	av_channel_layout_uninit(&output_channel_layout);
++
+ 	m_opened = true;
+-	m_finished = false;
+-	m_got_frame = 0;
+-	m_nb_packets = 0;
++	m_has_more_packets = true;
++	m_has_more_frames = true;
+ 	m_decode_error = 0;
+
+ 	return true;
+@@ -214,6 +215,7 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ inline void FFmpegAudioReader::Close() {
+ 	av_frame_free(&m_frame);
++	av_packet_free(&m_packet);
+
+ 	m_stream_index = -1;
+
+@@ -252,91 +254,98 @@ inline bool FFmpegAudioReader::Read(const int16_t **data, size_t *size) {
+ 		return false;
+ 	}
+
++	*data = nullptr;
++	*size = 0;
++
+ 	int ret;
++	bool needs_packet = false;
+ 	while (true) {
+-		while (m_packet.size <= 0) {
+-			av_packet_unref(&m_packet0);
+-			av_init_packet(&m_packet);
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			ret = av_read_frame(m_format_ctx, &m_packet);
++		while (needs_packet && m_packet->size == 0) {
++			ret = av_read_frame(m_format_ctx, m_packet);
+ 			if (ret < 0) {
+ 				if (ret == AVERROR_EOF) {
+-					m_finished = true;
++					needs_packet = false;
++					m_has_more_packets = false;
+ 					break;
+-				} else {
++				}
++				SetError("Error reading from the audio source", ret);
++				return false;
++			}
++			if (m_packet->stream_index == m_stream_index) {
++				needs_packet = false;
++			} else {
++				av_packet_unref(m_packet);
++			}
++		}
++
++		if (m_packet->size != 0) {
++			ret = avcodec_send_packet(m_codec_ctx, m_packet);
++			if (ret < 0) {
++				if (ret != AVERROR(EAGAIN)) {
+ 					SetError("Error reading from the audio source", ret);
+ 					return false;
+ 				}
+-			}
+-			m_packet0 = m_packet;
+-			if (m_packet.stream_index != m_stream_index) {
+-				m_packet.data = nullptr;
+-				m_packet.size = 0;
+ 			} else {
+-				m_nb_packets++;
++				av_packet_unref(m_packet);
+ 			}
+ 		}
+
+-		ret = avcodec_decode_audio4(m_codec_ctx, m_frame, &m_got_frame, &m_packet);
++		ret = avcodec_receive_frame(m_codec_ctx, m_frame);
+ 		if (ret < 0) {
+-			if (m_decode_error) {
+-				SetError("Error decoding audio frame", m_decode_error);
+-				return false;
++			if (ret == AVERROR_EOF) {
++				m_has_more_frames = false;
++			} else if (ret == AVERROR(EAGAIN)) {
++				if (m_has_more_packets) {
++					needs_packet = true;
++					continue;
++				} else {
++					m_has_more_frames = false;
++				}
+ 			}
+-			m_decode_error = ret;
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			continue;
++			SetError("Error decoding the audio source", ret);
++			return false;
+ 		}
+
+-		break;
+-	}
+-
+-	m_decode_error = 0;
+-
+-	const int decoded = std::min(ret, m_packet.size);
+-	m_packet.data += decoded;
+-	m_packet.size -= decoded;
+-
+-	if (m_got_frame) {
+-		if (m_converter) {
+-			if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
+-				int linsize;
+-				av_freep(&m_convert_buffer[0]);
+-				m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
+-				ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
+-				if (ret < 0) {
+-					SetError("Couldn't allocate audio converter buffer", ret);
++		if (m_frame->nb_samples > 0) {
++			if (m_converter) {
++				if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
++					int linsize;
++					av_freep(&m_convert_buffer[0]);
++					m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
++					ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->ch_layout.nb_channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
++					if (ret < 0) {
++						SetError("Couldn't allocate audio converter buffer", ret);
++						return false;
++					}
++				}
++				auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
++				if (nb_samples < 0) {
++					SetError("Couldn't convert audio", ret);
+ 					return false;
+ 				}
+-			}
+-			auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			}
+-			*data = (const int16_t *) m_convert_buffer[0];
+-			*size = nb_samples;
+-		} else {
+-			*data = (const int16_t *) m_frame->data[0];
+-			*size = m_frame->nb_samples;
+-		}
+-	} else {
+-		if (m_finished && m_converter) {
+-			auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			} else if (nb_samples > 0) {
+-				m_got_frame = 1;
+ 				*data = (const int16_t *) m_convert_buffer[0];
+ 				*size = nb_samples;
++			} else {
++				*data = (const int16_t *) m_frame->data[0];
++				*size = m_frame->nb_samples;
++			}
++		} else {
++			if (m_converter) {
++				if (IsFinished()) {
++					auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
++					if (nb_samples < 0) {
++						SetError("Couldn't convert audio", ret);
++						return false;
++					} else if (nb_samples > 0) {
++						*data = (const int16_t *) m_convert_buffer[0];
++						*size = nb_samples;
++					}
++				}
+ 			}
+ 		}
+-	}
+
+-	return true;
++		return true;
++	}
+ }
+
+ inline void FFmpegAudioReader::SetError(const char *message, int errnum) {
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index a2b517b..123e643 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -38,6 +38,12 @@ set(SRCS
+
+ if(BUILD_TOOLS)
+ 	set(SRCS ${SRCS} ../src/audio/ffmpeg_audio_reader_test.cpp)
++    include_directories(
++        ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}
++        ${AUDIO_PROCESSOR_INCLUDE_DIRS}
++    )
+ 	link_libraries(fpcalc_libs)
+ endif()
+
+-- 
+2.38.1
+
+
diff --git a/srcpkgs/chromaprint/template b/srcpkgs/chromaprint/template
index 7ef7838949f3a..1f7bbc70a22c8 100644
--- a/srcpkgs/chromaprint/template
+++ b/srcpkgs/chromaprint/template
@@ -1,7 +1,7 @@
 # Template file for 'chromaprint'
 pkgname=chromaprint
 version=1.5.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DBUILD_TOOLS=ON"
 make_check_target="check"

From 79fe6ef76d830f6c058be0c58b24f4abf1f4e23a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 022/113] chromium: revbump for ffmpeg-6.0

---
 .../patches/chromium-119-ffmpeg-4.4.patch     | 20 --------
 srcpkgs/chromium/patches/ffmpeg5.patch        | 47 +++++++++++++++++++
 srcpkgs/chromium/template                     |  2 +-
 3 files changed, 48 insertions(+), 21 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch
 create mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch b/srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch
deleted file mode 100644
index 04d04b166ba37..0000000000000
--- a/srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch
+++ /dev/null
@@ -1,20 +0,0 @@
---- a/media/filters/ffmpeg_demuxer.cc.orig
-+++ b/media/filters/ffmpeg_demuxer.cc
-@@ -390,7 +390,7 @@
- 
-   scoped_refptr<DecoderBuffer> buffer;
- 
--    size_t side_data_size = 0;
-+    int side_data_size = 0;
-     uint8_t* side_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
- 
-@@ -453,7 +453,7 @@
-                                        packet->size - data_offset);
-     }
- 
--    size_t skip_samples_size = 0;
-+    int skip_samples_size = 0;
-     const uint32_t* skip_samples_ptr =
-         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
-             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..24e2da38e34ca
--- /dev/null
+++ b/srcpkgs/chromium/patches/ffmpeg5.patch
@@ -0,0 +1,47 @@
+--- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
++++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
+@@ -92,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+-  if (stream->start_time != kNoFFmpegTimestamp)
++  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -1597,7 +1585,7 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+@@ -1618,7 +1606,7 @@
+     if (stream->type() != DemuxerStream::VIDEO)
+       continue;
+ 
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+ 
+     if (!stream->IsEnabled())
diff --git a/srcpkgs/chromium/template b/srcpkgs/chromium/template
index b023946f3ec7b..fe36a6dce20d3 100644
--- a/srcpkgs/chromium/template
+++ b/srcpkgs/chromium/template
@@ -2,7 +2,7 @@
 pkgname=chromium
 # See https://chromiumdash.appspot.com/releases?platform=Linux for the latest version
 version=119.0.6045.105
-revision=3
+revision=4
 archs="i686* x86_64* aarch64* armv7l*"
 hostmakedepends="
  $(vopt_if clang "clang lld llvm15")

From 500d4348a0ed55a0a14860283efa82626cc267e3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 023/113] cmus: revbump for ffmpeg-6.0

---
 srcpkgs/chromium/patches/ffmpeg5.patch | 47 --------------------------
 srcpkgs/cmus/patches/ffmpeg6.patch     | 12 +++++++
 srcpkgs/cmus/template                  |  2 +-
 3 files changed, 13 insertions(+), 48 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch
 create mode 100644 srcpkgs/cmus/patches/ffmpeg6.patch

diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
deleted file mode 100644
index 24e2da38e34ca..0000000000000
--- a/srcpkgs/chromium/patches/ffmpeg5.patch
+++ /dev/null
@@ -1,47 +0,0 @@
---- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
-+++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
-@@ -92,24 +92,12 @@
- 
- static base::TimeDelta ExtractStartTime(AVStream* stream) {
-   // The default start time is zero.
--  base::TimeDelta start_time;
-+  base::TimeDelta start_time = kNoTimestamp;
- 
-   // First try to use  the |start_time| value as is.
--  if (stream->start_time != kNoFFmpegTimestamp)
-+  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
-     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
- 
--  // Next try to use the first DTS value, for codecs where we know PTS == DTS
--  // (excludes all H26x codecs). The start time must be returned in PTS.
--  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
--      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
--      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
--      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
--    const base::TimeDelta first_pts =
--        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
--    if (first_pts < start_time)
--      start_time = first_pts;
--  }
--
-   return start_time;
- }
- 
-@@ -1597,7 +1585,7 @@
-   for (const auto& stream : streams_) {
-     if (!stream || stream->IsEnabled() != enabled)
-       continue;
--    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
-+    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
-       continue;
-     if (!lowest_start_time_stream ||
-         stream->start_time() < lowest_start_time_stream->start_time()) {
-@@ -1618,7 +1606,7 @@
-     if (stream->type() != DemuxerStream::VIDEO)
-       continue;
- 
--    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
-+    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
-       continue;
- 
-     if (!stream->IsEnabled())
diff --git a/srcpkgs/cmus/patches/ffmpeg6.patch b/srcpkgs/cmus/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..ffa95ab811101
--- /dev/null
+++ b/srcpkgs/cmus/patches/ffmpeg6.patch
@@ -0,0 +1,12 @@
+--- a/ip/ffmpeg.c
++++ b/ip/ffmpeg.c
+@@ -202,9 +202,6 @@ static int ffmpeg_open(struct input_plugin_data *ip_data)
+ 			break;
+ 		}
+ 
+-		if (codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+-			cc->flags |= AV_CODEC_FLAG_TRUNCATED;
+-
+ 		if (avcodec_open2(cc, codec, NULL) < 0) {
+ 			d_print("could not open codec: %d, %s\n", cc->codec_id, avcodec_get_name(cc->codec_id));
+ 			err = -IP_ERROR_UNSUPPORTED_FILE_TYPE;
diff --git a/srcpkgs/cmus/template b/srcpkgs/cmus/template
index 0d1436744f1b2..a6e4b4fa86cb8 100644
--- a/srcpkgs/cmus/template
+++ b/srcpkgs/cmus/template
@@ -1,7 +1,7 @@
 # Template file for 'cmus'
 pkgname=cmus
 version=2.10.0
-revision=3
+revision=4
 build_style=configure
 configure_args="prefix=/usr LD=$CC"
 hostmakedepends="pkg-config"

From a57c5171cd110b5717fd1a3a076c2c5c32084d3c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 024/113] cyanrip: revbump for ffmpeg-6.0

---
 srcpkgs/cyanrip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cyanrip/template b/srcpkgs/cyanrip/template
index 9796e3461601a..5db30e020d17e 100644
--- a/srcpkgs/cyanrip/template
+++ b/srcpkgs/cyanrip/template
@@ -1,7 +1,7 @@
 # Template file for 'cyanrip'
 pkgname=cyanrip
 version=0.9.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config"
 makedepends="ffmpeg-devel libcdio-devel libcdio-paranoia-devel libcurl-devel libmusicbrainz5-devel"

From bb843389b096a38b58b3fb984414856782153e7a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 025/113] deadbeef: revbump for ffmpeg4-4.4.3

---
 srcpkgs/deadbeef/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/deadbeef/template b/srcpkgs/deadbeef/template
index f5f4bf24b8cb6..7b47e615cd48e 100644
--- a/srcpkgs/deadbeef/template
+++ b/srcpkgs/deadbeef/template
@@ -1,14 +1,14 @@
 # Template file for 'deadbeef'
 pkgname=deadbeef
 version=1.8.8
-revision=3
+revision=4
 create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-oss --disable-lfm --disable-notify --disable-gtk2"
 hostmakedepends="automake libtool gettext gettext-devel intltool pkg-config
  yasm clang glib-devel"
 makedepends="
- alsa-lib-devel dbus-devel faad2-devel ffmpeg-devel gtk+3-devel imlib2-devel
+ alsa-lib-devel dbus-devel faad2-devel ffmpeg4-devel gtk+3-devel imlib2-devel
  jansson-devel libcddb-devel libcdio-devel libcurl-devel libflac-devel
  libmad-devel libpng-devel libsamplerate-devel libsndfile-devel libvorbis-devel
  libzip-devel mpg123-devel opusfile-devel pulseaudio-devel wavpack-devel"

From 00869338309f97f15ec8863389312464ae705ddc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 026/113] droidcam-obs-plugin: revbump for ffmpeg-6.0

---
 srcpkgs/droidcam-obs-plugin/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam-obs-plugin/template b/srcpkgs/droidcam-obs-plugin/template
index fc9c9bf6b9d54..fb0480754df4d 100644
--- a/srcpkgs/droidcam-obs-plugin/template
+++ b/srcpkgs/droidcam-obs-plugin/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam-obs-plugin'
 pkgname=droidcam-obs-plugin
 version=2.0.1
-revision=1
+revision=2
 build_style=gnu-makefile
 make_use_env=yes
 make_build_args="ALLOW_STATIC=no"

From ae441b88af752fbbd520a4fece3c0734d66bcf76 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 027/113] droidcam: revbump for ffmpeg-6.0

---
 srcpkgs/droidcam/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam/template b/srcpkgs/droidcam/template
index 1c3f1b8b1fc67..32a9220b79a4d 100644
--- a/srcpkgs/droidcam/template
+++ b/srcpkgs/droidcam/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam'
 pkgname=droidcam
 version=1.8.2
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="USBMUXD=-lusbmuxd-2.0 JPEG=-lturbojpeg"
 hostmakedepends="pkg-config"

From d5068ac4d3f89391bd99ed10f268757697886be8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 028/113] ffmpegthumbnailer: revbump for ffmpeg-6.0

---
 .../ffmpegthumbnailer/patches/ffmpeg6.patch   | 202 ++++++++++++++++++
 srcpkgs/ffmpegthumbnailer/template            |   6 +-
 2 files changed, 205 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch

diff --git a/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..363ff35a28419
--- /dev/null
+++ b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
@@ -0,0 +1,202 @@
+--- a/libffmpegthumbnailer/moviedecoder.cpp	2017-11-21 14:06:57.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.cpp	2023-05-05 13:14:47.946560668 -0400
+@@ -41,11 +41,6 @@
+ namespace ffmpegthumbnailer
+ {
+ 
+-struct SilenceLogLevel
+-{
+-    SilenceLogLevel() { av_log_set_level(AV_LOG_QUIET); }
+-};
+-
+ MovieDecoder::MovieDecoder(AVFormatContext* pavContext)
+ : m_VideoStream(-1)
+ , m_pFormatContext(pavContext)
+@@ -70,8 +65,6 @@
+ 
+ void MovieDecoder::initialize(const string& filename, bool preferEmbeddedMetadata)
+ {
+-    av_register_all();
+-    avcodec_register_all();
+     avformat_network_init();
+ 
+     string inputFile = filename == "-" ? "pipe:" : filename;
+@@ -97,8 +90,7 @@
+ {
+     if (m_pVideoCodecContext)
+     {
+-        avcodec_close(m_pVideoCodecContext);
+-        m_pVideoCodecContext = nullptr;
++        avcodec_free_context(&m_pVideoCodecContext);
+     }
+ 
+     if ((!m_FormatContextWasGiven) && m_pFormatContext)
+@@ -152,10 +144,10 @@
+     for (unsigned int i = 0; i < m_pFormatContext->nb_streams; ++i)
+     {
+         AVStream *stream = m_pFormatContext->streams[i];
+-        auto ctx = m_pFormatContext->streams[i]->codec;
+-        if (ctx->codec_type == AVMEDIA_TYPE_VIDEO)
++        auto par = m_pFormatContext->streams[i]->codecpar;
++        if (par->codec_type == AVMEDIA_TYPE_VIDEO)
+         {
+-            if (!preferEmbeddedMetadata || !isStillImageCodec(ctx->codec_id))
++            if (!preferEmbeddedMetadata || !isStillImageCodec(par->codec_id))
+             {
+                 videoStreams.push_back(i);
+                 continue;
+@@ -203,8 +195,7 @@
+     }
+ 
+     m_pVideoStream = m_pFormatContext->streams[m_VideoStream];
+-    m_pVideoCodecContext = m_pVideoStream->codec;
+-    m_pVideoCodec = avcodec_find_decoder(m_pVideoCodecContext->codec_id);
++    m_pVideoCodec = avcodec_find_decoder(m_pVideoStream->codecpar->codec_id);
+ 
+     if (m_pVideoCodec == nullptr)
+     {
+@@ -214,6 +205,20 @@
+         throw logic_error("Video Codec not found");
+     }
+ 
++    m_pVideoCodecContext = avcodec_alloc_context3(m_pVideoCodec);
++
++    if (m_pVideoCodecContext == nullptr)
++    {
++        destroy();
++        throw logic_error("Could not allocate video codec context");
++    }
++
++    if (avcodec_parameters_to_context(m_pVideoCodecContext, m_pVideoStream->codecpar) < 0)
++    {
++        destroy();
++        throw logic_error("Could not configure video codec context");
++    }
++
+     m_pVideoCodecContext->workaround_bugs = 1;
+ 
+     if (avcodec_open2(m_pVideoCodecContext, m_pVideoCodec, nullptr) < 0)
+@@ -386,13 +391,6 @@
+ 
+ void MovieDecoder::initializeFilterGraph(const AVRational& timeBase, const std::string& size, bool maintainAspectRatio)
+ {
+-    static const AVPixelFormat pixelFormats[] = { AV_PIX_FMT_RGB24, AV_PIX_FMT_NONE };
+-
+-    auto del = [] (AVBufferSinkParams* p) { av_freep(p); };
+-    std::unique_ptr<AVBufferSinkParams, decltype(del)> buffersinkParams(av_buffersink_params_alloc(), del);
+-
+-    avfilter_register_all();
+-
+     m_pFilterGraph = avfilter_graph_alloc();
+     assert(m_pFilterGraph);
+ 
+@@ -404,10 +402,8 @@
+ 
+     checkRc(avfilter_graph_create_filter(&m_pFilterSource, avfilter_get_by_name("buffer"), "thumb_buffer", ss.str().c_str(), nullptr, m_pFilterGraph),
+             "Failed to create filter source");
+-    buffersinkParams->pixel_fmts = pixelFormats;
+-    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, buffersinkParams.get(), m_pFilterGraph),
++    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, nullptr, m_pFilterGraph),
+             "Failed to create filter sink");
+-    buffersinkParams.release();
+ 
+     AVFilterContext* yadifFilter = nullptr;
+     if (m_pFrame->interlaced_frame != 0)
+@@ -500,15 +496,15 @@
+     }
+ 
+     checkRc(av_seek_frame(m_pFormatContext, -1, timestamp, 0), "Seeking in video failed");
+-    avcodec_flush_buffers(m_pFormatContext->streams[m_VideoStream]->codec);
++    avcodec_flush_buffers(m_pVideoCodecContext);
+ 
+     int keyFrameAttempts = 0;
+-    bool gotFrame = 0;
++    bool gotFrame;
+ 
+     do
+     {
+         int count = 0;
+-        gotFrame = 0;
++        gotFrame = false;
+ 
+         while (!gotFrame && count < 20)
+         {
+@@ -552,17 +548,33 @@
+         return false;
+     }
+ 
+-    av_frame_unref(m_pFrame);
+-
+-    int frameFinished;
++    int rc = avcodec_send_packet(m_pVideoCodecContext, m_pPacket);
++    if(rc == AVERROR(EAGAIN))
++    {
++        rc = 0;
++    }
+ 
+-    int bytesDecoded = avcodec_decode_video2(m_pVideoCodecContext, m_pFrame, &frameFinished, m_pPacket);
+-    if (bytesDecoded < 0)
++    if(rc == AVERROR_EOF)
++    {
++        return false;
++    }
++    else if(rc < 0)
+     {
+-        throw logic_error("Failed to decode video frame: bytesDecoded < 0");
++        throw logic_error("Failed to decode video frame: avcodec_send_packet() < 0");
+     }
+ 
+-    return frameFinished > 0;
++    rc = avcodec_receive_frame(m_pVideoCodecContext, m_pFrame);
++    switch(rc)
++    {
++        case 0:
++            return true;
++
++        case AVERROR(EAGAIN):
++            return false;
++
++        default:
++            throw logic_error("Failed to decode video frame: avcodec_receive_frame() < 0");
++    }
+ }
+ 
+ bool MovieDecoder::getVideoPacket()
+@@ -570,8 +582,6 @@
+     bool framesAvailable = true;
+     bool frameDecoded = false;
+ 
+-    int attempts = 0;
+-
+     if (m_pPacket)
+     {
+         av_packet_unref(m_pPacket);
+@@ -580,6 +590,7 @@
+ 
+     m_pPacket = new AVPacket();
+ 
++
+     while (framesAvailable && !frameDecoded)
+     {
+         framesAvailable = av_read_frame(m_pFormatContext, m_pPacket) >= 0;
+@@ -644,7 +655,7 @@
+ 
+ int32_t MovieDecoder::getStreamRotation()
+ {
+-    int32_t* matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
++    auto matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
+     if (matrix)
+     {
+         auto angle = lround(av_display_rotation_get(matrix));
+
+--- a/libffmpegthumbnailer/moviedecoder.h	2017-11-12 04:23:38.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.h	2023-05-05 13:26:07.095529911 -0400
+@@ -78,7 +78,7 @@
+     int                     m_VideoStream;
+     AVFormatContext*        m_pFormatContext;
+     AVCodecContext*         m_pVideoCodecContext;
+-    AVCodec*                m_pVideoCodec;
++    const AVCodec*          m_pVideoCodec;
+     AVFilterGraph*          m_pFilterGraph;
+     AVFilterContext*        m_pFilterSource;
+     AVFilterContext*        m_pFilterSink;
diff --git a/srcpkgs/ffmpegthumbnailer/template b/srcpkgs/ffmpegthumbnailer/template
index 039eea7622b39..35d546018d12a 100644
--- a/srcpkgs/ffmpegthumbnailer/template
+++ b/srcpkgs/ffmpegthumbnailer/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbnailer'
 pkgname=ffmpegthumbnailer
 version=2.2.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libpng-devel libjpeg-turbo-devel ffmpeg-devel"
@@ -9,8 +9,8 @@ depends="ffmpeg"
 short_desc="Lightweight video thumbnailer"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
-homepage="https://github.com/dirkvdb/${pkgname}"
-distfiles="${homepage}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
+homepage="https://github.com/dirkvdb"
+distfiles="${homepage}/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
 checksum=1cb24059c38223f657b300c84dd80491b7040d4b69471c4fea69be862bc99b5b
 
 post_install() {

From e92efa8082b5a1841e16101989d51ad7f7fd34d0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 029/113] ffmpegthumbs: revbump for ffmpeg-6.0

---
 srcpkgs/ffmpegthumbs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ffmpegthumbs/template b/srcpkgs/ffmpegthumbs/template
index 5f0b9414dadaf..11b88193528f4 100644
--- a/srcpkgs/ffmpegthumbs/template
+++ b/srcpkgs/ffmpegthumbs/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbs'
 pkgname=ffmpegthumbs
 version=22.12.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules kcoreaddons kconfig-devel
  pkg-config qt5-host-tools qt5-qmake gettext"

From 514d03af563641766baa78469fd9487a38188535 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 030/113] ffms2: revbump for ffmpeg-6.0

---
 srcpkgs/ffms2/patches/ffmpeg5.patch | 424 ++++++++++++++++++++++++++++
 srcpkgs/ffms2/template              |   2 +-
 2 files changed, 425 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ffms2/patches/ffmpeg5.patch

diff --git a/srcpkgs/ffms2/patches/ffmpeg5.patch b/srcpkgs/ffms2/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..1479fabcafcb4
--- /dev/null
+++ b/srcpkgs/ffms2/patches/ffmpeg5.patch
@@ -0,0 +1,424 @@
+From 45673149e9a2f5586855ad472e3059084eaa36b1 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:41:21 +0100
+Subject: [PATCH] Use auto for AVCodec
+
+The geniuses over at FFmpeg decided to constify this API, so old
+versions of the library will return AVCodec *, while new versions
+of the libary will return const AVCodec *, which, in C++, are not
+OK to convert between.
+
+Rather than use some macro hell in ffmscompat.h, we can work around
+this by using auto.
+
+Gross.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 2 +-
+ src/core/indexing.cpp    | 6 +++---
+ src/core/videosource.cpp | 2 +-
+ 3 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index e4ce97c..ac09666 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -469,7 +469,7 @@ void FFMS_AudioSource::OpenFile() {
+ 
+     LAVFOpenFile(SourceFile.c_str(), FormatContext, TrackNumber);
+ 
+-    AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
++    auto *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
+     if (Codec == nullptr)
+         throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+             "Audio codec not found");
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index e547c5a..59fb4e8 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -384,7 +384,7 @@ FFMS_TrackType FFMS_Indexer::GetTrackType(int Track) {
+ }
+ 
+ const char *FFMS_Indexer::GetTrackCodec(int Track) {
+-    AVCodec *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
++    auto *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
+     return codec ? codec->name : nullptr;
+ }
+ 
+@@ -402,7 +402,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             UseDTS);
+ 
+         if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            AVCodec *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (!VideoCodec) {
+                 FormatContext->streams[i]->discard = AVDISCARD_ALL;
+                 IndexMask.erase(i);
+@@ -433,7 +433,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 IndexMask.insert(i);
+             }
+         } else if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+-            AVCodec *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (AudioCodec == nullptr)
+                 throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_UNSUPPORTED,
+                     "Audio codec not found");
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index b889970..8956c22 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -171,7 +171,7 @@ FFMS_VideoSource::FFMS_VideoSource(const char *SourceFile, FFMS_Index &Index, in
+ 
+         LAVFOpenFile(SourceFile, FormatContext, VideoTrack);
+ 
+-        AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
++        auto *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
+         if (Codec == nullptr)
+             throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+                 "Video codec not found");
+-- 
+2.40.0
+
+From 96cbf38ea9381829a1314f432a2c60495dcefaad Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:12:41 +0100
+Subject: [PATCH] all: Update AVPacket API usage
+
+AVPackets must all be on the heap now, since it is no longer
+part of the libav* ABI.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 16 ++++++----
+ src/core/indexing.cpp    | 63 ++++++++++++++++++++++------------------
+ src/core/indexing.h      |  4 +--
+ src/core/utils.cpp       |  6 ----
+ src/core/utils.h         |  1 -
+ src/core/videosource.cpp | 30 ++++++++++---------
+ 6 files changed, 64 insertions(+), 56 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index 37cf9ae..e4ce97c 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -285,10 +285,15 @@ FFMS_AudioSource::AudioBlock *FFMS_AudioSource::CacheBlock(CacheIterator &pos) {
+ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     CurrentFrame = &Frames[PacketNumber];
+ 
+-    AVPacket Packet;
+-    if (!ReadPacket(&Packet))
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++    if (!ReadPacket(Packet)) {
++        av_packet_free(&Packet);
+         throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_UNKNOWN,
+             "ReadPacket unexpectedly failed to read a packet");
++    }
+ 
+     // ReadPacket may have changed the packet number
+     CurrentFrame = &Frames[PacketNumber];
+@@ -297,8 +302,9 @@ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     int NumberOfSamples = 0;
+     AudioBlock *CachedBlock = nullptr;
+     
+-    int Ret = avcodec_send_packet(CodecContext, &Packet);
+-    av_packet_unref(&Packet);
++    int Ret = avcodec_send_packet(CodecContext, Packet);
++    av_packet_unref(Packet);
++    av_packet_free(&Packet);
+ 
+     av_frame_unref(DecodeFrame);
+     Ret = avcodec_receive_frame(CodecContext, DecodeFrame);
+@@ -513,8 +519,6 @@ void FFMS_AudioSource::Seek() {
+ }
+ 
+ bool FFMS_AudioSource::ReadPacket(AVPacket *Packet) {
+-    InitNullPacket(*Packet);
+-
+     while (av_read_frame(FormatContext, Packet) >= 0) {
+         if (Packet->stream_index == TrackNumber) {
+             // Required because not all audio packets, especially in ogg, have a pts. Use the previous valid packet's pts instead.
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index 23fb95b..e547c5a 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -320,7 +320,7 @@ void FFMS_Indexer::CheckAudioProperties(int Track, AVCodecContext *Context) {
+     }
+ }
+ 
+-void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict,
++void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict,
+                                     int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct) {
+     if (VideoContext.Parser) {
+         uint8_t *OB;
+@@ -330,8 +330,8 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+         av_parser_parse2(VideoContext.Parser,
+             VideoContext.CodecContext,
+             &OB, &OBSize,
+-            pkt.data, pkt.size,
+-            pkt.pts, pkt.dts, pkt.pos);
++            pkt->data, pkt->size,
++            pkt->pts, pkt->dts, pkt->pos);
+ 
+         // H.264 (PAFF) and HEVC may have one field per packet, so we need to track
+         // when we have a full or half frame available, and mark one of them as
+@@ -351,15 +351,15 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+ 
+         *RepeatPict = VideoContext.Parser->repeat_pict;
+         *FrameType = VideoContext.Parser->pict_type;
+-        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt.flags & AV_PKT_FLAG_DISCARD));
++        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt->flags & AV_PKT_FLAG_DISCARD));
+     } else {
+-        *Invisible = !!(pkt.flags & AV_PKT_FLAG_DISCARD);
++        *Invisible = !!(pkt->flags & AV_PKT_FLAG_DISCARD);
+     }
+ 
+     if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP8)
+-        ParseVP8(pkt.data[0], Invisible, FrameType);
++        ParseVP8(pkt->data[0], Invisible, FrameType);
+     else if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP9)
+-        ParseVP9(pkt.data[0], Invisible, FrameType);
++        ParseVP9(pkt->data[0], Invisible, FrameType);
+ }
+ 
+ void FFMS_Indexer::Free() {
+@@ -458,32 +458,36 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+         }
+     }
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
+     std::vector<int64_t> LastValidTS(FormatContext->nb_streams, AV_NOPTS_VALUE);
+ 
+     int64_t filesize = avio_size(FormatContext->pb);
+     enum AVPictureStructure LastPicStruct = AV_PICTURE_STRUCTURE_UNKNOWN;
+-    while (av_read_frame(FormatContext, &Packet) >= 0) {
++    while (av_read_frame(FormatContext, Packet) >= 0) {
+         // Update progress
+         // FormatContext->pb can apparently be NULL when opening images.
+         if (IC && FormatContext->pb) {
+-            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate))
++            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate)) {
++                av_packet_free(&Packet);
+                 throw FFMS_Exception(FFMS_ERROR_CANCELLED, FFMS_ERROR_USER,
+                     "Cancelled by user");
++            }
+         }
+-        if (!IndexMask.count(Packet.stream_index)) {
+-            av_packet_unref(&Packet);
++        if (!IndexMask.count(Packet->stream_index)) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+-        int Track = Packet.stream_index;
++        int Track = Packet->stream_index;
+         FFMS_Track &TrackInfo = (*TrackIndices)[Track];
+-        bool KeyFrame = !!(Packet.flags & AV_PKT_FLAG_KEY);
++        bool KeyFrame = !!(Packet->flags & AV_PKT_FLAG_KEY);
+         ReadTS(Packet, LastValidTS[Track], (*TrackIndices)[Track].UseDTS);
+ 
+         if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            int64_t PTS = TrackInfo.UseDTS ? Packet.dts : Packet.pts;
++            int64_t PTS = TrackInfo.UseDTS ? Packet->dts : Packet->pts;
+             if (PTS == AV_NOPTS_VALUE) {
+                 // VPx alt-refs are output as packets which lack timestmps or durations, since
+                 // they are invisible. Currently, the timestamp mangling code in libavformat
+@@ -495,9 +499,11 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 // FFMS2 currently sorts packets by PTS, which will break decoding, otherwise.
+                 bool HasAltRefs = (FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP8 ||
+                                    FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP9);
+-                if (Packet.duration == 0 && !HasAltRefs)
++                if (Packet->duration == 0 && !HasAltRefs) {
++                    av_packet_free(&Packet);
+                     throw FFMS_Exception(FFMS_ERROR_INDEXING, FFMS_ERROR_PARSER,
+                         "Invalid packet pts, dts, and duration");
++                }
+ 
+                 if (TrackInfo.empty())
+                     PTS = 0;
+@@ -513,7 +519,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             ParseVideoPacket(AVContexts[Track], Packet, &RepeatPict, &FrameType, &Invisible, &LastPicStruct);
+ 
+             TrackInfo.AddVideoFrame(PTS, RepeatPict, KeyFrame,
+-                FrameType, Packet.pos, Invisible);
++                FrameType, Packet->pos, Invisible);
+         } else if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+             // For video seeking timestamps are used only if all packets have
+             // timestamps, while for audio they're used if any have timestamps,
+@@ -522,28 +528,29 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 TrackInfo.HasTS = true;
+ 
+             int64_t StartSample = AVContexts[Track].CurrentSample;
+-            uint32_t SampleCount = IndexAudioPacket(Track, &Packet, AVContexts[Track], *TrackIndices);
++            uint32_t SampleCount = IndexAudioPacket(Track, Packet, AVContexts[Track], *TrackIndices);
+             TrackInfo.SampleRate = AVContexts[Track].CodecContext->sample_rate;
+ 
+             TrackInfo.AddAudioFrame(LastValidTS[Track],
+-                StartSample, SampleCount, KeyFrame, Packet.pos, Packet.flags & AV_PKT_FLAG_DISCARD);
++                StartSample, SampleCount, KeyFrame, Packet->pos, Packet->flags & AV_PKT_FLAG_DISCARD);
+         }
+ 
+-        if (!(Packet.flags & AV_PKT_FLAG_DISCARD))
+-            TrackInfo.LastDuration = Packet.duration;
++        if (!(Packet->flags & AV_PKT_FLAG_DISCARD))
++            TrackInfo.LastDuration = Packet->duration;
+ 
+-        av_packet_unref(&Packet);
++        av_packet_unref(Packet);
+     }
++    av_packet_free(&Packet);
+ 
+     TrackIndices->Finalize(AVContexts, FormatContext->iformat->name);
+     return TrackIndices.release();
+ }
+ 
+-void FFMS_Indexer::ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS) {
+-    if (!UseDTS && Packet.pts != AV_NOPTS_VALUE)
+-        TS = Packet.pts;
++void FFMS_Indexer::ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS) {
++    if (!UseDTS && Packet->pts != AV_NOPTS_VALUE)
++        TS = Packet->pts;
+     if (TS == AV_NOPTS_VALUE)
+         UseDTS = true;
+-    if (UseDTS && Packet.dts != AV_NOPTS_VALUE)
+-        TS = Packet.dts;
++    if (UseDTS && Packet->dts != AV_NOPTS_VALUE)
++        TS = Packet->dts;
+ }
+diff --git a/src/core/indexing.h b/src/core/indexing.h
+index 3cfc3c3..5c06868 100644
+--- a/src/core/indexing.h
++++ b/src/core/indexing.h
+@@ -80,10 +80,10 @@ private:
+     int64_t Filesize;
+     uint8_t Digest[20];
+ 
+-    void ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS);
++    void ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS);
+     void CheckAudioProperties(int Track, AVCodecContext *Context);
+     uint32_t IndexAudioPacket(int Track, AVPacket *Packet, SharedAVContext &Context, FFMS_Index &TrackIndices);
+-    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
++    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
+     void Free();
+ public:
+     FFMS_Indexer(const char *Filename);
+diff --git a/src/core/utils.cpp b/src/core/utils.cpp
+index ce67533..8a2e997 100644
+--- a/src/core/utils.cpp
++++ b/src/core/utils.cpp
+@@ -62,12 +62,6 @@ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo) {
+     }
+ }
+ 
+-void InitNullPacket(AVPacket &pkt) {
+-    av_init_packet(&pkt);
+-    pkt.data = nullptr;
+-    pkt.size = 0;
+-}
+-
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames) {
+     AP.SampleFormat = static_cast<FFMS_SampleFormat>(av_get_packed_sample_fmt(CTX->sample_fmt));
+     AP.BitsPerSample = av_get_bytes_per_sample(CTX->sample_fmt) * 8;
+diff --git a/src/core/utils.h b/src/core/utils.h
+index 9819dc7..003ab79 100644
+--- a/src/core/utils.h
++++ b/src/core/utils.h
+@@ -58,7 +58,6 @@ std::unique_ptr<T> make_unique(Args&&... args) {
+ }
+ 
+ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo);
+-void InitNullPacket(AVPacket &pkt);
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames);
+ 
+ void LAVFOpenFile(const char *SourceFile, AVFormatContext *&FormatContext, int Track);
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index 06bd161..b889970 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -673,30 +673,34 @@ void FFMS_VideoSource::DecodeNextFrame(int64_t &AStartTime, int64_t &Pos) {
+     if (HasPendingDelayedFrames())
+         return;
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
+-
+-    while (ReadFrame(&Packet) >= 0) {
+-        if (Packet.stream_index != VideoTrack) {
+-            av_packet_unref(&Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++
++    while (ReadFrame(Packet) >= 0) {
++        if (Packet->stream_index != VideoTrack) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+         if (AStartTime < 0)
+-            AStartTime = Frames.UseDTS ? Packet.dts : Packet.pts;
++            AStartTime = Frames.UseDTS ? Packet->dts : Packet->pts;
+ 
+         if (Pos < 0)
+-            Pos = Packet.pos;
++            Pos = Packet->pos;
+ 
+-        bool FrameFinished = DecodePacket(&Packet);
+-        av_packet_unref(&Packet);
+-        if (FrameFinished)
++        bool FrameFinished = DecodePacket(Packet);
++        av_packet_unref(Packet);
++        if (FrameFinished) {
++            av_packet_free(&Packet);
+             return;
++        }
+     }
+ 
+     // Flush final frames
+-    InitNullPacket(Packet);
+-    DecodePacket(&Packet);
++    DecodePacket(Packet);
++    av_packet_free(&Packet);
+ }
+ 
+ bool FFMS_VideoSource::SeekTo(int n, int SeekOffset) {
+-- 
+2.40.0
+
+From bf9e03e9e08534c024e5a744a6437c4aac160201 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:20:47 +0100
+Subject: [PATCH 2/3] configure: Remove deprecated API use
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ configure.ac | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index b35ef80bc..d19714d0f 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -102,10 +102,10 @@ CFLAGS="$_CFLAGS $FFMPEG_CFLAGS"
+
+ AC_DEFUN([TEST_FFMPEG],
+          [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+-            #include <libavcodec/avcodec.h>
++            #include <libavformat/avformat.h>
+             #include <libswscale/swscale.h>
+             ]],[[
+-                avcodec_register_all();
++                avformat_network_init();
+                 swscale_version();
+             ]])], [eval $1=yes], [eval $1=no])
+         ])
+
diff --git a/srcpkgs/ffms2/template b/srcpkgs/ffms2/template
index 365f64d10cbab..1641ecf43be5b 100644
--- a/srcpkgs/ffms2/template
+++ b/srcpkgs/ffms2/template
@@ -1,7 +1,7 @@
 # Template file for 'ffms2'
 pkgname=ffms2
 version=2.40
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-shared --disable-static"
 hostmakedepends="pkg-config autoconf automake libtool"

From 8bf9052ede7e7e99d9b029ca31ed1e2e09fb36c4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 031/113] freerdp: revbump for ffmpeg-6.0

---
 .../freerdp/patches/ffmpeg6_aa2cb9aa.patch    | 42 +++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100644 srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch

diff --git a/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
new file mode 100644
index 0000000000000..a4324da3a8822
--- /dev/null
+++ b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
@@ -0,0 +1,42 @@
+From aa2cb9aa5ff5562433598ba168a466e0752bca0e Mon Sep 17 00:00:00 2001
+From: akallabeth <akallabeth@posteo.net>
+Date: Tue, 14 Feb 2023 07:48:54 +0100
+Subject: [PATCH] Fixed #8686: Update h264 to use new FFMPEG API
+
+---
+ channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c | 2 ++
+ libfreerdp/codec/h264_ffmpeg.c            | 2 ++
+ 2 files changed, 4 insertions(+)
+
+diff --git a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+index 339462d865f..beea80b7a1e 100644
+--- a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
++++ b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+@@ -239,8 +239,10 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYP
+ 		}
+ 	}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 	if (mdecoder->codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		mdecoder->codec_context->flags |= AV_CODEC_FLAG_TRUNCATED;
++#endif
+ 
+ 	return TRUE;
+ }
+diff --git a/libfreerdp/codec/h264_ffmpeg.c b/libfreerdp/codec/h264_ffmpeg.c
+index 8a23db2473c..896a333019b 100644
+--- a/libfreerdp/codec/h264_ffmpeg.c
++++ b/libfreerdp/codec/h264_ffmpeg.c
+@@ -615,10 +615,12 @@ static BOOL libavcodec_init(H264_CONTEXT* h264)
+ 			goto EXCEPTION;
+ 		}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 		if (sys->codecDecoder->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		{
+ 			sys->codecDecoderContext->flags |= AV_CODEC_FLAG_TRUNCATED;
+ 		}
++#endif
+ 
+ #ifdef WITH_VAAPI
+ 

From a1c41d363f946299950cfbac4399aad30903a830 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 032/113] gerbera: revbump for ffmpeg-6.0

---
 srcpkgs/gerbera/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gerbera/template b/srcpkgs/gerbera/template
index ae14f35c767c0..2dc0ac0ce03b5 100644
--- a/srcpkgs/gerbera/template
+++ b/srcpkgs/gerbera/template
@@ -1,7 +1,7 @@
 # Template file for 'gerbera'
 pkgname=gerbera
 version=1.12.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_SYSTEMD=0 -DWITH_AVCODEC=1"
 hostmakedepends="pkg-config"

From 57f5c9c37349de8bb4d1a3ba4e408b3b38359178 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 033/113] goldendict: revbump for ffmpeg-6.0

---
 srcpkgs/goldendict/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/goldendict/template b/srcpkgs/goldendict/template
index f4a05759f693d..97f44347b03a6 100644
--- a/srcpkgs/goldendict/template
+++ b/srcpkgs/goldendict/template
@@ -1,7 +1,7 @@
 # Template file for 'goldendict'
 pkgname=goldendict
 version=1.5.0
-revision=1
+revision=2
 build_style=qmake
 configure_args="CONFIG+=zim_support goldendict.pro"
 hostmakedepends="qt5-qmake pkg-config qt5-host-tools"
@@ -10,7 +10,7 @@ makedepends="tiff-devel qt5-devel libvorbis-devel zlib-devel
  qt5-webkit-devel lzo-devel bzip2-devel libao-devel qt5-svg-devel
  libeb-devel qt5-x11extras-devel ffmpeg-devel liblzma-devel
  qt5-multimedia-devel"
-short_desc="A feature-rich dictionary lookup program"
+short_desc="Feature-rich dictionary lookup program"
 maintainer="John <me@johnnynator.dev>"
 license="GPL-3.0-or-later"
 homepage="http://goldendict.org/"

From f5f721884814f55bd67079b703b327dfee7ee791 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 034/113] gst-libav: revbump for ffmpeg-6.0

---
 srcpkgs/gst-libav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index 78afeee4aefb2..f892eb2063564 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.22.7
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"

From daaac8c17b312a539bb4555245a35bbd237ded7d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 035/113] gst-rtsp-server: revbump for ffmpeg-6.0

---
 srcpkgs/gst-rtsp-server/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index 2c280c84f1514..83a2949fd9482 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
 version=1.22.7
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="glib-devel gst-plugins-bad1-devel gobject-introspection

From 423963d9a76bb1a2b2e4de6457911b5a4f07b09f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 036/113] guvcview: update to 2.0.8.

---
 srcpkgs/guvcview/patches/fix-include.patch | 10 ++++++++++
 srcpkgs/guvcview/template                  |  7 +++----
 2 files changed, 13 insertions(+), 4 deletions(-)
 create mode 100644 srcpkgs/guvcview/patches/fix-include.patch

diff --git a/srcpkgs/guvcview/patches/fix-include.patch b/srcpkgs/guvcview/patches/fix-include.patch
new file mode 100644
index 0000000000000..503c2af3b78c1
--- /dev/null
+++ b/srcpkgs/guvcview/patches/fix-include.patch
@@ -0,0 +1,10 @@
+--- a/guvcview/guvcview.c
++++ b/guvcview/guvcview.c
+@@ -28,6 +28,7 @@
+ #include <sys/stat.h>
+ #include <sys/resource.h>
+ #include <errno.h>
++#include <locale.h>
+ 
+ #include "gview.h"
+ #include "gviewv4l2core.h"
diff --git a/srcpkgs/guvcview/template b/srcpkgs/guvcview/template
index d42fd38fa4ad1..86a7fd619612c 100644
--- a/srcpkgs/guvcview/template
+++ b/srcpkgs/guvcview/template
@@ -1,8 +1,7 @@
 # Template file for 'guvcview'
 pkgname=guvcview
-version=2.0.7
-revision=2
-create_wrksrc=yes
+version=2.0.8
+revision=1
 build_style=gnu-configure
 configure_args="--disable-static --disable-debian-menu"
 hostmakedepends="pkg-config intltool autoconf automake libtool glib-devel"
@@ -14,7 +13,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="http://guvcview.sourceforge.net/"
 distfiles="${SOURCEFORGE_SITE}/${pkgname}/${pkgname}-src-${version}.tar.bz2"
-checksum=f47d51fbd06e44eeaa1a82f4a153c927527c90d94514197a70b2956028cc8ad4
+checksum=a21f4e448286666cf27bafef5290cc953a0a1796b752e5bbe521266dc1230c81
 
 post_patch() {
 	sed '31a#include <locale.h>' -i  guvcview/guvcview.c

From ee4e6196efbcbb31b56c62a20b1bccbadbe62482 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 037/113] handbrake: update to 1.6.1

---
 .../patches/fix-missing-x265-link-flag.patch    | 11 ++++++-----
 .../handbrake/patches/libhb-vpl-include.patch   | 15 +++++++++++++++
 srcpkgs/handbrake/template                      | 17 ++++++++++-------
 3 files changed, 31 insertions(+), 12 deletions(-)
 create mode 100644 srcpkgs/handbrake/patches/libhb-vpl-include.patch

diff --git a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
index 26db03867a0c8..d6bb2eda627a3 100644
--- a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
+++ b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
@@ -1,14 +1,15 @@
 --- a/gtk/configure.ac
 +++ b/gtk/configure.ac
 @@ -203,7 +203,7 @@
- 
+
  AM_CONDITIONAL([MINGW], [test "x$mingw_flag" = "xyes"])
- 
--HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg"
-+HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -ldl"
+
+-HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc"
++HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc -ldl"
  HB_CPPFLAGS="$HB_CPPFLAGS $HBINC"
- 
+
  PKG_CHECK_MODULES([x264], [x264], sys_x264=yes, sys_x264=no)
+
 --- a/test/module.defs
 +++ b/test/module.defs
 @@ -69,6 +69,9 @@
diff --git a/srcpkgs/handbrake/patches/libhb-vpl-include.patch b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
new file mode 100644
index 0000000000000..298f9f4ab28f2
--- /dev/null
+++ b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
@@ -0,0 +1,15 @@
+--- a/libhb/module.defs	2023-01-22 11:36:49.000000000 -0500
++++ b/libhb/module.defs	2023-04-03 22:37:52.395467010 -0400
+@@ -46,11 +46,7 @@
+ LIBHB.GCC.I += $(LIBHB.build/) $(CONTRIB.build/)include
+ 
+ ifeq (1,$(FEATURE.qsv))
+-    ifeq ($(HOST.system),freebsd))
+-        LIBHB.GCC.I += $(LOCALBASE)/include/vpl
+-    else
+-        LIBHB.GCC.I += $(CONTRIB.build/)include/vpl
+-    endif
++    LIBHB.GCC.I += /usr/include/vpl
+ endif
+ 
+ ifneq (,$(filter $(HOST.system),freebsd netbsd openbsd))
diff --git a/srcpkgs/handbrake/template b/srcpkgs/handbrake/template
index ca5e4571e49c3..c32cb1bfa31f4 100644
--- a/srcpkgs/handbrake/template
+++ b/srcpkgs/handbrake/template
@@ -1,10 +1,10 @@
 # Template file for 'handbrake'
 pkgname=handbrake
-version=1.5.1
+version=1.6.1
 revision=1
 build_style=gnu-configure
 configure_args="--force --disable-gtk-update-checks --disable-df-fetch --harden
- $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc)"
+ $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc) $(vopt_enable qsv)"
 make_build_args="-C ${XBPS_TRIPLET}"
 make_install_args="-C ${XBPS_TRIPLET}"
 hostmakedepends="automake cmake gettext-devel glib-devel intltool libtool m4 meson nasm pkg-config python3"
@@ -12,8 +12,11 @@ makedepends="bzip2-devel ffmpeg-devel gst-plugins-base1-devel gtk+3-devel
  jansson-devel lame-devel libass-devel libbluray-devel libdav1d-devel
  libdvdnav-devel libdvdread-devel libgudev-devel libnuma-devel
  libsamplerate-devel libtheora-devel libvorbis-devel libvpx-devel libxml2-devel
- opus-devel speex-devel x264-devel x265-devel zimg-devel
+ opus-devel speex-devel x264-devel x265-devel zimg-devel libsvt-av1-devel
  $(vopt_if fdk_aac fdk-aac-devel)
+ $(vopt_if qsv libva-devel)
+ $(vopt_if qsv libdrm-devel)
+ $(vopt_if qsv onevpl-devel)
  $(vopt_if nvenc nv-codec-headers)"
 depends="desktop-file-utils gst-plugins-good1 hicolor-icon-theme"
 short_desc="Multithreaded video transcoder"
@@ -21,15 +24,15 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-2.0-only"
 homepage="https://handbrake.fr/"
 distfiles="https://github.com/HandBrake/HandBrake/releases/download/${version}/HandBrake-${version}-source.tar.bz2"
-checksum=3999fe06d5309c819799a73a968a8ec3840e7840c2b64af8f5cdb7fd8c9430f0
+checksum=94ccfe03db917a91650000c510f7fd53f844da19f19ad4b4be1b8f6bc31a8d4c
 nocross=yes
 
-build_options="fdk_aac nvenc"
+build_options="fdk_aac nvenc qsv"
 
 case "$XBPS_TARGET_MACHINE" in
 	x86_64*|i686*)
 		CFLAGS="-msse"
-		build_options_default="nvenc"
+		build_options_default="nvenc qsv"
 		;;
 esac
 
@@ -37,7 +40,7 @@ pre_configure() {
 	# use system libraries, don't download them
 	rm -rf contrib/
 	for module in fdk-aac ffmpeg libbluray libdav1d libdvdnav libdvdread nvenc \
-		x265 zimg; do
+		x265 zimg svt-av1 libvpl; do
 	    vsed -i "/MODULES += contrib\/${module}/d" make/include/main.defs
 	done
 }

From 7576a56630cbd5afc640c170e569afaef4ca72ae Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 038/113] hedgewars: revbump for ffmpeg4-4.4.3

---
 srcpkgs/hedgewars/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/hedgewars/template b/srcpkgs/hedgewars/template
index 94b6db673b0c3..402ccfaaecbc2 100644
--- a/srcpkgs/hedgewars/template
+++ b/srcpkgs/hedgewars/template
@@ -1,13 +1,13 @@
 # Template file for 'hedgewars'
 pkgname=hedgewars
 version=1.0.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DNOSERVER=1 -DDATA_INSTALL_DIR=/usr/share/${pkgname}
  -DPHYSFS_SYSTEM=1 -DMINIMAL_FLAGS=1"
 make_cmd=make
 hostmakedepends="lua51 pkg-config qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
+makedepends="ffmpeg4-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
  SDL2_mixer-devel SDL2_net-devel SDL2_ttf-devel"
 depends="libfreeglut"
 short_desc="Funny turn-based artillery game, featuring fighting Hedgehogs!"

From eaafc69613d3fb512b1b3056f4f23d1f1795c335 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 039/113] idjc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/idjc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/idjc/template b/srcpkgs/idjc/template
index a9cde0665d55b..6f1d21c5781fd 100644
--- a/srcpkgs/idjc/template
+++ b/srcpkgs/idjc/template
@@ -5,7 +5,7 @@ revision=5
 build_style=gnu-configure
 hostmakedepends="pkg-config git python3 automake gettext-devel libtool"
 makedepends="libvorbis-devel libogg-devel jack-devel libsamplerate-devel
- libflac-devel libsndfile-devel mpg123-devel ffmpeg-devel speex-devel
+ libflac-devel libsndfile-devel mpg123-devel ffmpeg4-devel speex-devel
  glib-devel pixman-devel lame-devel python3-gobject-devel libshout-idjc-devel
  opus-devel twolame-devel python3-mutagen python3-devel"
 depends="python3-gobject python3-mutagen desktop-file-utils shared-mime-info python3-dbus jack"

From fd939e6a4ede2d974f3283f9f7ce3378b904bf05 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 040/113] kid3: revbump for ffmpeg-6.0

---
 srcpkgs/kid3/patches/ffmpeg5.patch | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 srcpkgs/kid3/patches/ffmpeg5.patch

diff --git a/srcpkgs/kid3/patches/ffmpeg5.patch b/srcpkgs/kid3/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..135fc50e07c9b
--- /dev/null
+++ b/srcpkgs/kid3/patches/ffmpeg5.patch
@@ -0,0 +1,17 @@
+# https://aur.archlinux.org/cgit/aur.git/diff/ffmpeg5.patch?h=kid3-cli&id=12410a74906612e7efc0ec8fbce739b4a0fef7e7
+diff --git a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+index e156d424..e12b9abd 100644
+--- a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
++++ b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+@@ -232,7 +232,11 @@ private:
+   friend class Format;
+   friend class Converter;
+   AVCodecContext* m_ptr;
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 0, 0)
+   AVCodec* m_impl;
++#else
++  const AVCodec* m_impl;
++#endif
+   AVFrame* m_frame;
+   bool m_opened;
+ };

From d85ebd5f81cb1b026cda91b1628826235ef2b71a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 041/113] kodi: revbump for ffmpeg4-4.4.3

---
 srcpkgs/kodi/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kodi/template b/srcpkgs/kodi/template
index aa59324258a0d..6cf64dfb27294 100644
--- a/srcpkgs/kodi/template
+++ b/srcpkgs/kodi/template
@@ -54,7 +54,7 @@ makedepends="
  libmad-devel fontconfig-devel libXinerama-devel libsamplerate-devel libmms-devel
  enca-devel boost-devel libcurl-devel libva-devel libvdpau-devel libass-devel
  libbluetooth-devel yajl-devel libplist-devel librtmp-devel tinyxml-devel
- taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg-devel
+ taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg4-devel
  giflib-devel libxslt-devel gnutls-devel libssh-devel libmicrohttpd-devel
  libcec-devel dcadec-devel flatbuffers-devel fmt-devel lcms2-devel
  libfstrcmp-devel rapidjson libcdio-paranoia spdlog libwaylandpp-devel

From a387c765b31b44b2d4c32ab39236291922de73d9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 042/113] kpipewire: revbump for ffmpeg-6.0

---
 srcpkgs/kpipewire/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kpipewire/template b/srcpkgs/kpipewire/template
index 6214a4451336e..3555348659dde 100644
--- a/srcpkgs/kpipewire/template
+++ b/srcpkgs/kpipewire/template
@@ -1,7 +1,7 @@
 # Template file for 'kpipewire'
 pkgname=kpipewire
 version=5.27.10
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules plasma-wayland-protocols gettext
  qt5-qmake qt5-host-tools pkg-config wayland-devel kcoreaddons

From 59ad0fe87fb1e7f72a3dc3e4f7c13c518dc6b04e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 043/113] libextractor: revbump for ffmpeg4-4.4.3

---
 srcpkgs/libextractor/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libextractor/template b/srcpkgs/libextractor/template
index 044c663a3a0b9..ace88ae128da5 100644
--- a/srcpkgs/libextractor/template
+++ b/srcpkgs/libextractor/template
@@ -7,7 +7,7 @@ configure_args="--disable-static"
 hostmakedepends="pkg-config"
 makedepends="zlib-devel bzip2-devel exiv2-devel tiff-devel libpng-devel
  libjpeg-turbo-devel libvorbis-devel libflac-devel giflib-devel libmpeg2-devel
- ffmpeg-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
+ ffmpeg4-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
 short_desc="Library used to extract meta data from files"
 maintainer="Martin Riese <grauehaare@gmx.de>"
 license="GPL-3.0-or-later"

From 50fd59b1ae5fa983a71a4a1d5e2ede5715492ba5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 044/113] libopenal: revbump for ffmpeg-6.0

---
 srcpkgs/libopenal/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenal/template b/srcpkgs/libopenal/template
index 88d0f11307d81..8308fca0393e3 100644
--- a/srcpkgs/libopenal/template
+++ b/srcpkgs/libopenal/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenal'
 pkgname=libopenal
 version=1.23.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DALSOFT_EXAMPLES=OFF"
 hostmakedepends="pkg-config"

From 25c598f901aaa0afc2dfc6b5acf3b22638566cdb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 045/113] loudgain: revbump for ffmpeg-6.0

---
 srcpkgs/loudgain/patches/ffmpeg5.patch | 11 +++++++++++
 srcpkgs/loudgain/template              |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/loudgain/patches/ffmpeg5.patch

diff --git a/srcpkgs/loudgain/patches/ffmpeg5.patch b/srcpkgs/loudgain/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..16d4510ee98fa
--- /dev/null
+++ b/srcpkgs/loudgain/patches/ffmpeg5.patch
@@ -0,0 +1,11 @@
+--- a/src/scan.c	2019-09-06 11:31:19.000000000 -0400
++++ b/src/scan.c	2023-03-23 11:15:40.867968521 -0400
+@@ -69,8 +69,6 @@
+ 	 * It is now useless
+ 	 * https://github.com/FFmpeg/FFmpeg/blob/70d25268c21cbee5f08304da95be1f647c630c15/doc/APIchanges#L86
+ 	 */
+-  if (avformat_version() < AV_VERSION_INT(58,9,100))
+-    av_register_all();
+ 
+ 	av_log_set_callback(scan_av_log);
+ 
diff --git a/srcpkgs/loudgain/template b/srcpkgs/loudgain/template
index da4f2d56e94c3..4d6bf29efb4fd 100644
--- a/srcpkgs/loudgain/template
+++ b/srcpkgs/loudgain/template
@@ -1,7 +1,7 @@
 # Template file for 'loudgain'
 pkgname=loudgain
 version=0.6.8
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libebur128-devel taglib-devel ffmpeg-devel"

From 31885d493365fb6e06c326ddf654ccc289d4470b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 046/113] mediastreamer: revbump for ffmpeg4-4.4.3

---
 srcpkgs/mediastreamer/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mediastreamer/template b/srcpkgs/mediastreamer/template
index 0fcffa7653d18..92ada88743a9b 100644
--- a/srcpkgs/mediastreamer/template
+++ b/srcpkgs/mediastreamer/template
@@ -5,7 +5,7 @@ revision=2
 build_style=cmake
 configure_args="-DENABLE_STRICT=0 -DENABLE_UNIT_TESTS=0"
 hostmakedepends="python3"
-makedepends="bzrtp-devel ffmpeg-devel glew-devel libXv-devel libsrtp-devel
+makedepends="bzrtp-devel ffmpeg4-devel glew-devel libXv-devel libsrtp-devel
  libupnp-devel libvpx-devel mbedtls-devel opus-devel ortp-devel pulseaudio-devel
  libtheora-devel speex-devel v4l-utils-devel bcg729-devel bcmatroska2-devel libgsm-devel
  zxing-cpp-devel"

From 9ba5d66e85358ef1f25b0b0be37b3fc205efb91a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 047/113] mgba: revbump for ffmpeg-6.0

---
 srcpkgs/mgba/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mgba/template b/srcpkgs/mgba/template
index 5513e3fd16f3f..f5c87a4893002 100644
--- a/srcpkgs/mgba/template
+++ b/srcpkgs/mgba/template
@@ -1,7 +1,7 @@
 # Template file for 'mgba'
 pkgname=mgba
 version=0.10.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake desktop-file-utils"
 makedepends="SDL2-devel ffmpeg-devel libedit-devel libepoxy-devel libmagick-devel

From 69442fdb2dd134eb4ae7d3ac01ee72a3a69aec96 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 048/113] mlt: revbump for ffmpeg4-4.4.3

---
 srcpkgs/mlt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mlt/template b/srcpkgs/mlt/template
index 73e3915aaab9a..ec5054be3b75e 100644
--- a/srcpkgs/mlt/template
+++ b/srcpkgs/mlt/template
@@ -8,7 +8,7 @@ configure_args="--prefix=/usr --libdir=/usr/lib$XBPS_TARGET_WORDSIZE
  --swig-languages=python"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which"
 # XXX: movit vid.stab
-makedepends="alsa-lib-devel ffmpeg-devel gtk+-devel jack-devel ladspa-sdk
+makedepends="alsa-lib-devel ffmpeg4-devel gtk+-devel jack-devel ladspa-sdk
  libexif-devel libsamplerate-devel libxml2-devel sox-devel SDL_image-devel
  fftw-devel frei0r-plugins python3-devel pulseaudio-devel movit-devel
  libvidstab-devel"

From 53295c11c3714284927f1643fb8d03954dd0c4a2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 049/113] moc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/moc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/moc/template b/srcpkgs/moc/template
index 3a04932c8f1e6..d8de816026b64 100644
--- a/srcpkgs/moc/template
+++ b/srcpkgs/moc/template
@@ -4,7 +4,7 @@ version=2.5.2
 revision=7
 build_style=gnu-configure
 hostmakedepends="pkg-config"
-makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg-devel
+makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg4-devel
  jack-devel alsa-lib-devel libltdl-devel libflac-devel libvorbis-devel
  libmad-devel libmpcdec-devel libmodplug-devel libid3tag-devel faad2-devel
  taglib-devel libsndfile-devel wavpack-devel speex-devel libsamplerate-devel

From 37df4714093e283d0c06e3dd34788af7215f647e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 050/113] motion: revbump for ffmpeg-6.0

---
 srcpkgs/motion/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/motion/template b/srcpkgs/motion/template
index 607ebeb3c7b24..bf63a91d9764f 100644
--- a/srcpkgs/motion/template
+++ b/srcpkgs/motion/template
@@ -1,7 +1,7 @@
 # Template file for 'motion'
 pkgname=motion
 version=4.6.0
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake pkg-config gettext-devel tar"
 makedepends="ffmpeg-devel libmicrohttpd-devel v4l-utils-devel gettext-devel"

From 74dd544a935c78aa85ce389ce35da337dfcbd281 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 051/113] notcurses: revbump for ffmpeg-6.0

---
 srcpkgs/notcurses/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/notcurses/template b/srcpkgs/notcurses/template
index 6dd8a091319f7..3110c30c9aff2 100644
--- a/srcpkgs/notcurses/template
+++ b/srcpkgs/notcurses/template
@@ -1,7 +1,7 @@
 # Template file for 'notcurses'
 pkgname=notcurses
 version=3.0.9
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DUSE_STATIC=ON $(vopt_bool man USE_PANDOC)"
 hostmakedepends="pkg-config $(vopt_if man pandoc)"

From 9adab6a1e811750b8fb38ac918bf3698d6fe6cbc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 052/113] olive: revbump for ffmpeg4-4.4.3

---
 srcpkgs/olive/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/olive/template b/srcpkgs/olive/template
index 12a46936c9900..5c2917b9c5124 100644
--- a/srcpkgs/olive/template
+++ b/srcpkgs/olive/template
@@ -1,10 +1,10 @@
 # Template file for 'olive'
 pkgname=olive
 version=0.1.2
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools pkg-config"
-makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg-devel frei0r-plugins"
+makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg4-devel frei0r-plugins"
 short_desc="Non-linear video editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"

From c38bd3b90038f1cc9e67c9c0d5ea2d7bce973309 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 053/113] omxplayer: revbump for ffmpeg4-4.4.3

---
 srcpkgs/omxplayer/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/omxplayer/template b/srcpkgs/omxplayer/template
index 9a66690c83ebb..a21b878878037 100644
--- a/srcpkgs/omxplayer/template
+++ b/srcpkgs/omxplayer/template
@@ -1,7 +1,7 @@
 # Template file for 'omxplayer'
 pkgname=omxplayer
 version=20190102
-revision=2
+revision=3
 short_desc="Commandline OMX player for the Raspberry Pi"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
@@ -15,7 +15,7 @@ checksum=af2d9450f8947842ea8c401fe9f71eec444013ebbdee29f2ac828c9c493c1329
 archs="armv6l* armv7l*"
 build_style=gnu-makefile
 hostmakedepends="ruby-ronn pkg-config"
-makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg-devel dbus-devel"
+makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg4-devel dbus-devel"
 depends="freefont-ttf"
 
 do_build() {

From 0e80ed07766526664081a495d15e05d0d82280d4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 054/113] opentoonz: revbump for ffmpeg-6.0

---
 srcpkgs/opentoonz/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/opentoonz/template b/srcpkgs/opentoonz/template
index ee9f7603f55fd..3e81834ca0edd 100644
--- a/srcpkgs/opentoonz/template
+++ b/srcpkgs/opentoonz/template
@@ -1,7 +1,7 @@
 # Template file for 'opentoonz'
 pkgname=opentoonz
 version=1.6.0
-revision=2
+revision=3
 build_wrksrc="toonz/sources"
 build_style=cmake
 make_cmd=make

From 3ecfba51f4d92b3f4307f5e0c0c006ed4190bf3a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 055/113] pianobar: revbump for ffmpeg-6.0

---
 srcpkgs/pianobar/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pianobar/template b/srcpkgs/pianobar/template
index e3febb821a451..1e3dc1bf9308e 100644
--- a/srcpkgs/pianobar/template
+++ b/srcpkgs/pianobar/template
@@ -1,7 +1,7 @@
 # Template file for 'pianobar'
 pkgname=pianobar
 version=2022.04.01
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="V=1"
 hostmakedepends="pkg-config"

From 281cf4c69dd639544a5e6da2b3debe37b600773a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 056/113] ppsspp: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ppsspp/template | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/ppsspp/template b/srcpkgs/ppsspp/template
index 2c0ded496eb98..1294ef3ae669c 100644
--- a/srcpkgs/ppsspp/template
+++ b/srcpkgs/ppsspp/template
@@ -1,7 +1,7 @@
 # Template file for 'ppsspp'
 pkgname=ppsspp
 version=1.16.6
-revision=1
+revision=2
 _glslang_commit=b34f619e1c85810dcb3c578107d2e48ba4ee2b37
 _SPIRV_Cross_commit=4212eef67ed0ca048cb726a6767185504e7695e5
 _armips_commit=7bd1ec93d4586985ba1ef420b43b5e620f68695e
@@ -15,7 +15,7 @@ configure_args="-DHEADLESS=1 -DUSE_SYSTEM_FFMPEG=1 -DUNITTEST=ON
  -DUSING_QT_UI=$(vopt_if qt ON OFF) -DUSE_SYSTEM_ZSTD=ON
  -DARMIPS_USE_STD_FILESYSTEM=ON"
 hostmakedepends="pkg-config python3 $(vopt_if qt qt5-host-tools)"
-makedepends="zlib-devel glew-devel ffmpeg-devel libzip-devel
+makedepends="zlib-devel glew-devel ffmpeg4-devel libzip-devel
  snappy-devel rapidjson libpng-devel libzstd-devel
  $(vopt_if sdl2 'SDL2_ttf-devel SDL2-devel') $(vopt_if wayland wayland-devel)
  $(vopt_if qt 'qt5-devel qt5-multimedia-devel')"
@@ -72,7 +72,7 @@ post_extract() {
         mv ${wrksrc}/rcheevos-${_rcheevos_commit} ${wrksrc}/ext/rcheevos
 }
 
-post_patch(){
+post_patch() {
 	# disable git versioning
 	vsed -e 's|find_package(Git)|# &|' -i git-version.cmake
 }
@@ -85,7 +85,6 @@ post_configure() {
 }
 
 do_install() {
-	vlicense LICENSE.TXT
 	vinstall icons/icon.svg 644 usr/share/pixmaps ppsspp.svg
 	vinstall Qt/PPSSPP.desktop 644 usr/share/applications
 	vbin build/PPSSPPHeadless ppsspp-headless

From 5d97163c840f77b15c8572dbcd62f8f8e8788374 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 057/113] pqiv: revbump for ffmpeg-6.0

---
 srcpkgs/pqiv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pqiv/template b/srcpkgs/pqiv/template
index 542fc27a2d32a..9308d949b6a1c 100644
--- a/srcpkgs/pqiv/template
+++ b/srcpkgs/pqiv/template
@@ -1,7 +1,7 @@
 # Template file for 'pqiv'
 pkgname=pqiv
 version=2.12
-revision=1
+revision=2
 build_style=gnu-makefile
 hostmakedepends="pkg-config"
 makedepends="glib-devel gtk+3-devel $(vopt_if ffmpeg ffmpeg-devel)

From 309e21698ab94c7b9f3962626432d5a52c91d5a7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 058/113] qmmp: revbump for ffmpeg-6.0

---
 srcpkgs/qmmp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qmmp/template b/srcpkgs/qmmp/template
index 53781ea3bc28a..2da07f1e87eac 100644
--- a/srcpkgs/qmmp/template
+++ b/srcpkgs/qmmp/template
@@ -1,7 +1,7 @@
 # Template file for 'qmmp'
 pkgname=qmmp
 version=1.6.1
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DUSE_HAL:BOOL=FALSE -DQMMP_DEFAULT_UI:STRING=simple"
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From 9f354422be336d43b479edd090594460e175a308 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 7 May 2023 20:15:03 -0400
Subject: [PATCH 059/113] qt6-webengine: revbump for ffmpeg-6.0

---
 srcpkgs/qt6-webengine/template | 1 +
 1 file changed, 1 insertion(+)

diff --git a/srcpkgs/qt6-webengine/template b/srcpkgs/qt6-webengine/template
index 98cdc680481b3..f33a71bd2a0dc 100644
--- a/srcpkgs/qt6-webengine/template
+++ b/srcpkgs/qt6-webengine/template
@@ -158,6 +158,7 @@ pre_install() {
 }
 
 post_install() {
+	vlicense LICENSES/BSD-3-Clause.txt
 	local _file
 	find "${DESTDIR}"/usr/lib/qt6/examples \
 		-path '*/lib/qt6/**/lib/qt6/*' -type f |

From 89687edb211760acf54321349de92e0f69a1bc23 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 060/113] qt5-webengine: revbump for ffmpeg-6.0

---
 .../chromium-media-filters-cpp14.patch        |  11 ++
 srcpkgs/qt5-webengine/patches/ffmpeg5.patch   | 179 ++++++++++++++++++
 .../qtwebengine-fix-ffmpeg5-build.patch       |  14 ++
 srcpkgs/qt5-webengine/template                |   4 +-
 4 files changed, 206 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/ffmpeg5.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch

diff --git a/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
new file mode 100644
index 0000000000000..04adc540f2cbc
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
@@ -0,0 +1,11 @@
+--- a/src/3rdparty/chromium/media/filters/BUILD.gn	2023-02-27 13:32:59.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/BUILD.gn	2023-04-02 17:21:39.204066384 -0400
+@@ -96,6 +96,8 @@
+     "//ui/gfx/geometry:geometry",
+   ]
+ 
++  cflags_cc = [ "-std=c++14" ]
++
+   libs = []
+ 
+   if (proprietary_codecs) {
diff --git a/srcpkgs/qt5-webengine/patches/ffmpeg5.patch b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..ac55e1634423a
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
@@ -0,0 +1,179 @@
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:57.732547446 -0400
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:09.486478995 -0400
+@@ -57,6 +57,8 @@
+ 
+ namespace {
+ 
++constexpr int64_t kRelativeTsBase = static_cast<int64_t>(0x7ffeffffffffffff);
++
+ void SetAVStreamDiscard(AVStream* stream, AVDiscard discard) {
+   DCHECK(stream);
+   stream->discard = discard;
+@@ -90,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+   if (stream->start_time != kNoFFmpegTimestamp)
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (stream->first_dts != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, stream->first_dts);
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -408,11 +398,11 @@
+   scoped_refptr<DecoderBuffer> buffer;
+ 
+   if (type() == DemuxerStream::TEXT) {
+-    int id_size = 0;
++    size_t id_size = 0;
+     uint8_t* id_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
+ 
+-    int settings_size = 0;
++    size_t settings_size = 0;
+     uint8_t* settings_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
+ 
+@@ -424,7 +414,7 @@
+     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
+                                      side_data.data(), side_data.size());
+   } else {
+-    int side_data_size = 0;
++    size_t side_data_size = 0;
+     uint8_t* side_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
+ 
+@@ -485,7 +475,7 @@
+                                        packet->size - data_offset);
+     }
+ 
+-    int skip_samples_size = 0;
++    size_t skip_samples_size = 0;
+     const uint32_t* skip_samples_ptr =
+         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
+             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
+@@ -1587,6 +1577,8 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++      continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+       lowest_start_time_stream = stream.get();
+@@ -1604,6 +1596,8 @@
+     if (stream && stream->type() == DemuxerStream::VIDEO &&
+         stream->IsEnabled()) {
+       video_stream = stream.get();
++      if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++        continue;
+       if (video_stream->start_time() <= seek_time) {
+         return video_stream;
+       }
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h qtwebengine-5.15.10/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h
+--- a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-07-11 22:12:47.917192788 -0500
+@@ -29,6 +29,7 @@ extern "C" {
+ #include <libavformat/avformat.h>
+ #include <libavformat/avio.h>
+ #include <libavutil/avutil.h>
++#include <libavutil/channel_layout.h>
+ #include <libavutil/imgutils.h>
+ #include <libavutil/log.h>
+ #include <libavutil/mastering_display_metadata.h>
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/audio_file_reader.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/audio_file_reader.cc
+--- a/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -85,7 +85,7 @@ bool AudioFileReader::OpenDemuxer() {
+ }
+ 
+ bool AudioFileReader::OpenDecoder() {
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (codec) {
+     // MP3 decodes to S16P which we don't support, tell it to use S16 instead.
+     if (codec_context_->sample_fmt == AV_SAMPLE_FMT_S16P)
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -329,7 +329,7 @@ bool FFmpegAudioDecoder::ConfigureDecode
+     }
+   }
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec ||
+       avcodec_open2(codec_context_.get(), codec, &codec_options) < 0) {
+     DLOG(ERROR) << "Could not initialize audio decoder: "
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -59,7 +59,6 @@ static int64_t AVIOSeekOperation(void* o
+ }
+ 
+ void FFmpegGlue::InitializeFFmpeg() {
+-  av_register_all();
+ }
+ 
+ static void LogContainer(bool is_local_file,
+@@ -95,9 +94,6 @@ FFmpegGlue::FFmpegGlue(FFmpegURLProtocol
+   // Enable fast, but inaccurate seeks for MP3.
+   format_context_->flags |= AVFMT_FLAG_FAST_SEEK;
+ 
+-  // Ensures we can read out various metadata bits like vp8 alpha.
+-  format_context_->flags |= AVFMT_FLAG_KEEP_SIDE_DATA;
+-
+   // Ensures format parsing errors will bail out. From an audit on 11/2017, all
+   // instances were real failures. Solves bugs like http://crbug.com/710791.
+   format_context_->error_recognition |= AV_EF_EXPLODE;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -391,7 +391,7 @@ bool FFmpegVideoDecoder::ConfigureDecode
+   if (decode_nalus_)
+     codec_context_->flags2 |= AV_CODEC_FLAG2_CHUNKS;
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
+     ReleaseFFmpegResources();
+     return false;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/media_file_checker.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/media_file_checker.cc
+--- a/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -68,7 +68,7 @@ bool MediaFileChecker::Start(base::TimeD
+       auto context = AVStreamToAVCodecContext(format_context->streams[i]);
+       if (!context)
+         continue;
+-      AVCodec* codec = avcodec_find_decoder(cp->codec_id);
++      const AVCodec* codec = avcodec_find_decoder(cp->codec_id);
+       if (codec && avcodec_open2(context.get(), codec, nullptr) >= 0) {
+         auto loop = std::make_unique<FFmpegDecodingLoop>(context.get());
+         stream_contexts[i] = {std::move(context), std::move(loop)};
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc qtwebengine-5.15.10/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc
+--- a/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -203,7 +203,7 @@ int32_t H264DecoderImpl::InitDecode(cons
+   // a pointer |this|.
+   av_context_->opaque = this;
+ 
+-  AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
+   if (!codec) {
+     // This is an indication that FFmpeg has not been initialized or it has not
+     // been compiled/initialized with the correct set of codecs.
diff --git a/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch b/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch
new file mode 100644
index 0000000000000..bc24d5b9a29cb
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch
@@ -0,0 +1,14 @@
+--- a/src/buildtools/configure.json	2023-12-09 11:06:01.503058569 -0500
++++ b/src/buildtools/configure.json	2023-12-09 11:06:14.982361345 -0500
+@@ -779,11 +779,6 @@
+             "type": "warning",
+             "condition": "config.ios && config.simulator && config.device && features.build-qtpdf",
+             "message": "Building fat libray with device and simulator architectures will disable NEON."
+-        },
+-        {
+-            "type": "fatal",
+-            "condition": "features.webengine-system-ffmpeg && !libs.webengine-ffmpeg-support",
+-            "message": "Unmodified ffmpeg >= 5.0 is not supported. Please configure with -qt-webengine-ffmpeg."
+         }
+     ],
+     "summary": [
diff --git a/srcpkgs/qt5-webengine/template b/srcpkgs/qt5-webengine/template
index 8d2df1b5175ba..1687a77eb8a2f 100644
--- a/srcpkgs/qt5-webengine/template
+++ b/srcpkgs/qt5-webengine/template
@@ -1,14 +1,14 @@
 # Template file for 'qt5-webengine'
 pkgname=qt5-webengine
 version=5.15.16
-revision=1
+revision=2
 _version="${version}-lts"
 _chromium_commit=207c2ac45ca3386d153770c6b0d2ea2ec21ca880
 archs="x86_64* i686* armv[67]* ppc64* aarch64*"
 create_wrksrc=yes
 build_style=qmake
 configure_args="--
- -webengine-icu -webengine-ffmpeg -webengine-opus -webengine-webp
+ -webengine-icu -system-ffmpeg -webengine-opus -webengine-webp
  -webengine-pepper-plugins -webengine-printing-and-pdf -webengine-proprietary-codecs
  -webengine-pulseaudio -webengine-spellchecker -webengine-webrtc -webengine-geolocation
  -webengine-kerberos -no-webengine-embedded-build $(vopt_if sndio '' '-no')-webengine-sndio

From 60ad78e23fd6d8fceb9dad33b79b3532b309c74f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 061/113] qt5: revbump for ffmpeg-6.0

---
 srcpkgs/qt5/template | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/srcpkgs/qt5/template b/srcpkgs/qt5/template
index ef6e437e02dbc..771872a54d67c 100644
--- a/srcpkgs/qt5/template
+++ b/srcpkgs/qt5/template
@@ -5,7 +5,7 @@ pkgname=qt5
 version=5.15.11+20231124
 # commit 4765fa1df7a837db9c1f89c4da0dd76b74bb5fab
 # base repo: https://invent.kde.org/qt/qt/qt5
-revision=1
+revision=2
 build_style=meta
 hostmakedepends="cmake clang flex perl glib-devel pkg-config
  python3 re2c ruby which"
@@ -246,7 +246,6 @@ do_configure() {
 	# opts+=" -v"
 	opts+=" -skip qtwebengine"
 	opts+=" -skip qtwebview"
-	opts+=" -skip qtdocgallery"
 	opts+=" -skip qtpim"
 	opts+=" -skip qtsystems"
 	opts+=" -skip qtspeech"

From 3d444f13696e30a8fab0a5a2086e7953706a6327 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 062/113] qtav: revbump for ffmpeg4-4.4.3

---
 srcpkgs/qtav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qtav/template b/srcpkgs/qtav/template
index 775d5a139a9ef..2d00ad104355e 100644
--- a/srcpkgs/qtav/template
+++ b/srcpkgs/qtav/template
@@ -4,7 +4,7 @@ version=1.13.0
 revision=2
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel libass-devel libopenal-devel
+makedepends="ffmpeg4-devel libass-devel libopenal-devel
  libva-glx-devel libXv-devel pulseaudio-devel
  qt5-declarative-devel qt5-svg-devel
  qt5-quickcontrols"

From 72758248379efe6696c220b6189dab2cae13a4c6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 063/113] qtox: revbump for ffmpeg-6.0

---
 srcpkgs/qtox/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qtox/template b/srcpkgs/qtox/template
index 39c643fecdb5a..bb70e7f51240a 100644
--- a/srcpkgs/qtox/template
+++ b/srcpkgs/qtox/template
@@ -1,7 +1,7 @@
 # Template file for 'qtox'
 pkgname=qtox
 version=1.17.6
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DUPDATE_CHECK=OFF
  -DGIT_DESCRIBE=${version}

From 1b962d0f90f126afe7ffbc1900cdf33426942a58 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 064/113] retroarch: revbump for ffmpeg-6.0

---
 srcpkgs/retroarch/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroarch/template b/srcpkgs/retroarch/template
index cb3125c5dbf1a..c65c26f7bf033 100644
--- a/srcpkgs/retroarch/template
+++ b/srcpkgs/retroarch/template
@@ -1,7 +1,7 @@
 # Template file for 'retroarch'
 pkgname=retroarch
 version=1.16.0.3
-revision=3
+revision=4
 build_style=configure
 configure_args="--prefix=/usr --sysconfdir=/etc --enable-networking
  --enable-udev --disable-builtinflac --disable-builtinglslang

From a7bcb193933d02c107d2f44005f10747c94da231 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 065/113] scrcpy: revbump for ffmpeg-6.0

---
 srcpkgs/scrcpy/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/scrcpy/template b/srcpkgs/scrcpy/template
index ac18bc03418ce..f39a7f678ab35 100644
--- a/srcpkgs/scrcpy/template
+++ b/srcpkgs/scrcpy/template
@@ -1,7 +1,7 @@
 # Template file for 'scrcpy'
 pkgname=scrcpy
 version=2.1.1
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcompile_server=false
  -Dprebuilt_server=/usr/share/scrcpy/scrcpy-server-v${version}"

From cc1081f77b14452297770a83784ad3ab45c3998d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 17 Oct 2023 08:54:11 -0400
Subject: [PATCH 066/113] New package: spex-x replaces spek-alternative for
 ffmpeg-6.0

---
 srcpkgs/spek-alternative                      |  1 +
 srcpkgs/{spek-alternative => spek-x}/template | 22 ++++++++++++-------
 2 files changed, 15 insertions(+), 8 deletions(-)
 create mode 120000 srcpkgs/spek-alternative
 rename srcpkgs/{spek-alternative => spek-x}/template (52%)

diff --git a/srcpkgs/spek-alternative b/srcpkgs/spek-alternative
new file mode 120000
index 0000000000000..76648236da701
--- /dev/null
+++ b/srcpkgs/spek-alternative
@@ -0,0 +1 @@
+spek-x
\ No newline at end of file
diff --git a/srcpkgs/spek-alternative/template b/srcpkgs/spek-x/template
similarity index 52%
rename from srcpkgs/spek-alternative/template
rename to srcpkgs/spek-x/template
index d7b55c776b1d4..3ded6c2c323e4 100644
--- a/srcpkgs/spek-alternative/template
+++ b/srcpkgs/spek-x/template
@@ -1,18 +1,18 @@
-# Template file for 'spek-alternative'
-pkgname=spek-alternative
-version=0.8.2.3
-revision=2
+# Template file for 'spek-x'
+pkgname=spek-x
+version=0.9.3
+revision=1
 build_style=gnu-configure
 hostmakedepends="automake gettext-devel intltool libtool pkg-config
  wxWidgets-common wxWidgets-gtk3-devel"
 makedepends="ffmpeg-devel wxWidgets-gtk3-devel"
 depends="ffmpeg"
 short_desc="Acoustic spectrum analyser"
-maintainer="Kartik Singh <kartik.ynwa@gmail.com>"
+maintainer="zlice <zlice555@gmail.com>"
 license="GPL-3.0-or-later"
-homepage="https://github.com/withmorten/spek-alternative"
-distfiles="https://github.com/withmorten/spek-alternative/archive/${version}.tar.gz"
-checksum="007ba4b84a310b078e378aa84c8e80783db5821437a757a488c3ecec377e6b2a"
+homepage="https://github.com/MikeWang000000/spek-x"
+distfiles="https://github.com/MikeWang000000/spek-x/archive/v${version}.tar.gz"
+checksum="7f4b109903333cdd310ab2b9176f0dc49a565891376e281a233d342cedf90ef7"
 
 CXXFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
 
@@ -22,3 +22,9 @@ export WX_CONFIG_NAME="wx-config-gtk3"
 pre_configure() {
 	NOCONFIGURE=1 ./autogen.sh
 }
+
+spek-alternative_package() {
+	depends="spek-x"
+	short_desc+=" - transitional dummy package"
+	build_style=meta
+}

From f7c14e4836699faea91e9414a9df5d0ada297e09 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 067/113] ssr: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ssr/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ssr/template b/srcpkgs/ssr/template
index 842b2423aad10..3448ca110eb0c 100644
--- a/srcpkgs/ssr/template
+++ b/srcpkgs/ssr/template
@@ -5,7 +5,7 @@ revision=2
 build_style=cmake
 configure_args="-DWITH_QT5=ON"
 hostmakedepends="pkg-config"
-makedepends="alsa-lib-devel ffmpeg-devel glu-devel jack-devel pulseaudio-devel
+makedepends="alsa-lib-devel ffmpeg4-devel glu-devel jack-devel pulseaudio-devel
  qt5-tools-devel qt5-x11extras-devel libXinerama-devel v4l-utils-devel"
 depends="desktop-file-utils hicolor-icon-theme"
 short_desc="Simple Screen Recorder for programs and games"

From 15138a471f8d35091e421f96c92e2d1f9f279176 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 068/113] synfig: revbump for ffmpeg-6.0 and mlt7

---
 srcpkgs/synfig/patches/ffmpeg6.patch | 71 ++++++++++++++++++++++++++++
 srcpkgs/synfig/template              |  4 +-
 2 files changed, 73 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/synfig/patches/ffmpeg6.patch

diff --git a/srcpkgs/synfig/patches/ffmpeg6.patch b/srcpkgs/synfig/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..10780b42782f4
--- /dev/null
+++ b/srcpkgs/synfig/patches/ffmpeg6.patch
@@ -0,0 +1,71 @@
+--- a/src/modules/mod_libavcodec/trgt_av.cpp	2022-10-25 09:14:12.000000000 -0400
++++ b/src/modules/mod_libavcodec/trgt_av.cpp	2023-05-05 21:34:17.899194559 -0400
+@@ -38,6 +41,7 @@
+ extern "C"
+ {
+ #ifdef HAVE_LIBAVFORMAT_AVFORMAT_H
++#	include <libavcodec/avcodec.h>
+ #	include <libavformat/avformat.h>
+ #elif defined(HAVE_AVFORMAT_H)
+ #	include <avformat.h>
+@@ -155,11 +156,11 @@
+     }
+ 
+ 	bool open_video_stream() {
+-		if (avcodec_open2(video_context, NULL, NULL) < 0) {
++		if (avcodec_open2(video_context, nullptr, nullptr) < 0) {
+ 			synfig::error("Target_LibAVCodec: could not open video codec");
+ 			// seems the calling of avcodec_free_context after error will cause crash
+ 			// so just forget about this context
+-			video_context = NULL;
++			video_context = nullptr;
+ 			close();
+ 			return false;
+         }
+@@ -234,15 +235,21 @@
+ 		close();
+ 
+ 		if (!av_registered) {
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 			av_register_all();
++#endif
+ 			av_registered = true;
+ 		}
+ 
+ 		// guess format
+-		AVOutputFormat *format = av_guess_format(NULL, filename.c_str(), NULL);
++#if LIBAVCODEC_VERSION_MAJOR < 59 // FFMPEG < 5.0
++		AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#else
++		const AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#endif
+ 		if (!format) {
+ 			synfig::warning("Target_LibAVCodec: unable to guess the output format, defaulting to MPEG");
+-			format = av_guess_format("mpeg", NULL, NULL);
++			format = av_guess_format("mpeg", nullptr, nullptr);
+ 		}
+ 		if (!format) {
+ 			synfig::error("Target_LibAVCodec: unable to find 'mpeg' output format");
+@@ -254,6 +261,7 @@
+ 		context = avformat_alloc_context();
+ 		assert(context);
+ 		context->oformat = format;
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 		if (filename.size() + 1 > sizeof(context->filename)) {
+ 			synfig::error(
+ 				"Target_LibAVCodec: filename too long, max length is %d, filename is '%s'",
+@@ -263,6 +271,14 @@
+ 			return false;
+ 		}
+ 		memcpy(context->filename, filename.c_str(), filename.size() + 1);
++#else
++		context->url = av_strndup(filename.c_str(), filename.size());
++		if (!context->url) {
++			synfig::error("Target_LibAVCodec: cannot allocate space for filename");
++			close();
++			return false;
++		}
++#endif
+ 
+ 		packet = av_packet_alloc();
+ 		assert(packet);
diff --git a/srcpkgs/synfig/template b/srcpkgs/synfig/template
index d4d3e341a20bf..703cfd7ebac84 100644
--- a/srcpkgs/synfig/template
+++ b/srcpkgs/synfig/template
@@ -6,7 +6,7 @@ revision=4
 build_style=gnu-configure
 configure_args="--with-boost-libdir=${XBPS_CROSS_BASE}/usr/lib"
 hostmakedepends="boost-build ImageMagick pkg-config intltool"
-makedepends="ETL gettext-devel libxml++-devel mlt-devel libmagick-devel
+makedepends="ETL gettext-devel libxml++-devel mlt7-devel libmagick-devel
  libmng-devel boost-build boost-devel libopenexr-devel ffmpeg-devel"
 depends="ImageMagick"
 short_desc="CLI 2D vector and timeline-based animation software"
@@ -20,7 +20,7 @@ CXXFLAGS="-std=c++11 -DHAVE_LOCALE_H=1"
 
 synfig-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision}
-	 libopenexr-devel libxml++-devel mlt-devel"
+	 libopenexr-devel libxml++-devel mlt7-devel"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/bin/synfig-config

From 8599f0b217e249f8595bd4daab74c7e781618d57 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 069/113] timg: revbump for ffmpeg-6.0

---
 srcpkgs/timg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/timg/template b/srcpkgs/timg/template
index 2a2ab763d2fdd..8fb4327535ef9 100644
--- a/srcpkgs/timg/template
+++ b/srcpkgs/timg/template
@@ -1,7 +1,7 @@
 # Template file for 'timg'
 pkgname=timg
 version=1.4.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_OPENSLIDE_SUPPORT=off -Wno-dev"
 hostmakedepends="pkg-config git"

From 7381042325605fa50aff4e7edad0484c4512d267 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 070/113] tvheadend: revbump for ffmpeg4-4.4.3

---
 srcpkgs/tvheadend/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tvheadend/template b/srcpkgs/tvheadend/template
index 9aea7de4ec705..012d31c4879ff 100644
--- a/srcpkgs/tvheadend/template
+++ b/srcpkgs/tvheadend/template
@@ -8,7 +8,7 @@ configure_args="--enable-dvbscan --disable-ffmpeg_static
 --disable-libx265_static --disable-libvpx_static --disable-libtheora_static
 --disable-libvorbis_static --disable-libfdkaac_static"
 hostmakedepends="gettext pkg-config python3 git which"
-makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg-devel"
+makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg4-devel"
 short_desc="TV streaming server"
 maintainer="lemmi <lemmi@nerd2nerd.org>"
 license="GPL-3.0-only"

From 0d29c33099deec06acb4e3f944790e479b9e8491 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 071/113] unpaper: update to 7.0.0.

---
 srcpkgs/unpaper/template | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/srcpkgs/unpaper/template b/srcpkgs/unpaper/template
index 38ed47a584016..1ff910e722afc 100644
--- a/srcpkgs/unpaper/template
+++ b/srcpkgs/unpaper/template
@@ -1,13 +1,13 @@
 # Template file for 'unpaper'
 pkgname=unpaper
-version=6.1
-revision=3
-build_style=gnu-configure
+version=7.0.0
+revision=1
+build_style=meson
+hostmakedepends="pkg-config meson libxslt"
+makedepends="ffmpeg-devel python3-Sphinx"
+short_desc="Post-processing tool for scanned sheets of paper"
 maintainer="Orphaned <orphan@voidlinux.org>"
-hostmakedepends="pkg-config libxslt"
-makedepends="ffmpeg-devel"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://www.flameeyes.eu/projects/unpaper"
-short_desc="A post-processing tool for scanned sheets of paper"
 distfiles="https://www.flameeyes.eu/files/${pkgname}-${version}.tar.xz"
-checksum=237c84f5da544b3f7709827f9f12c37c346cdf029b1128fb4633f9bafa5cb930
+checksum=2575fbbf26c22719d1cb882b59602c9900c7f747118ac130883f63419be46a80

From 3af3b0a71d36ba0ee259393dd623b471313abb90 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 072/113] vice: revbump for ffmpeg4-4.4.3

---
 srcpkgs/vice/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vice/template b/srcpkgs/vice/template
index b1f866d35095e..4beab2c5f9ebd 100644
--- a/srcpkgs/vice/template
+++ b/srcpkgs/vice/template
@@ -26,7 +26,7 @@ makedepends="
 	$(vopt_if gtk3 gtk+3-devel)
 	$(vopt_if gtk3 pulseaudio-devel)
 	$(vopt_if gtk3 pango-devel)
-	$(vopt_if ffmpeg ffmpeg-devel)"
+	$(vopt_if ffmpeg ffmpeg4-devel)"
 short_desc="Emulator for C64, C128, CBM-II, PET, VIC20, Plus4 and C16"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"

From e5328cd06b52dfdb40263daad06ab74beb298aa4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 073/113] waypipe: revbump for ffmpeg-6.0

---
 srcpkgs/waypipe/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waypipe/template b/srcpkgs/waypipe/template
index 6da88b21bf2a1..4da8058400b58 100644
--- a/srcpkgs/waypipe/template
+++ b/srcpkgs/waypipe/template
@@ -1,7 +1,7 @@
 # Template file for 'waypipe'
 pkgname=waypipe
 version=0.8.6
-revision=1
+revision=2
 build_style=meson
 # lto is off because it causes linking errors in armv6l and armv7l (due to NEON)
 configure_args="-Dwerror=false -Dwith_dmabuf=enabled -Dwith_lz4=enabled

From 2fd6f890acbce4027658b363627c0cd680df6803 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 074/113] xpra: revbump for ffmpeg-6.0

---
 srcpkgs/xpra/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xpra/template b/srcpkgs/xpra/template
index 6bfe9be2db650..1eea2962bcb82 100644
--- a/srcpkgs/xpra/template
+++ b/srcpkgs/xpra/template
@@ -1,7 +1,7 @@
 # Template file for 'xpra'
 pkgname=xpra
 version=5.0.4
-revision=1
+revision=2
 build_style=python3-module
 make_build_args="--without-cuda_kernels --without-cuda_rebuild"
 make_install_args="$(vopt_with docs) ${make_build_args}"

From 2f880efa0c25aab051ce2d18765576b51c2893d4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:07:40 -0400
Subject: [PATCH 075/113] nv-codec-headers: update to 12.0.16.0

---
 srcpkgs/nv-codec-headers/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/nv-codec-headers/template b/srcpkgs/nv-codec-headers/template
index 3d422a61e4891..251e057f826fb 100644
--- a/srcpkgs/nv-codec-headers/template
+++ b/srcpkgs/nv-codec-headers/template
@@ -1,6 +1,6 @@
 # Template file for 'nv-codec-headers'
 pkgname=nv-codec-headers
-version=11.1.5.1
+version=12.0.16.0
 revision=1
 build_style=gnu-makefile
 short_desc="FFmpeg version of headers required to interface with Nvidias codec APIs"
@@ -8,7 +8,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="MIT"
 homepage="http://git.videolan.org/?p=ffmpeg/nv-codec-headers.git"
 distfiles="https://github.com/FFmpeg/nv-codec-headers/archive/n${version}.tar.gz"
-checksum=d095fbd56aa93772471a323be0ebe65504a0f43f06c76a30b6d25da77b06ae9c
+checksum=2a1533b65f55f9da52956faf0627ed3b74868ac0c7f269990edd21369113b48f
 
 post_install() {
 	sed -n '4,25p' include/ffnvcodec/nvEncodeAPI.h > LICENSE

From 5728813506449d56390613593cc80c9df586818b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:08:40 -0400
Subject: [PATCH 076/113] openimagedenoise: revbump for ffmpeg-6.0

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index b792813dba7c2..109deb171c3f7 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,7 +1,7 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
 version=1.4.3
-revision=1
+revision=2
 archs="x86_64*"
 build_style=cmake
 hostmakedepends="ispc python3"

From 8e0d7ed40369cd0101993f33b926a77f72e0c2cc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:31:45 -0400
Subject: [PATCH 077/113] shotcut: revbump for ffmpeg-6.0

---
 srcpkgs/shotcut/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/shotcut/template b/srcpkgs/shotcut/template
index 33141fbd862d7..f46cb53b6bfb9 100644
--- a/srcpkgs/shotcut/template
+++ b/srcpkgs/shotcut/template
@@ -1,7 +1,7 @@
 # Template file for 'shotcut'
 pkgname=shotcut
 version=23.09.29
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSHOTCUT_VERSION=${version}"
 hostmakedepends="pkg-config qt6-tools-devel"

From 14dd2d048cf6f8c70eb18ee4a2d9e6f37d044bf7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:30 -0400
Subject: [PATCH 078/113] shiboken2: revbump for qt5-5.15.11

---
 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch | 1 +
 srcpkgs/shiboken2/template                                 | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
 create mode 120000 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
new file mode 120000
index 0000000000000..efcf3249bd885
--- /dev/null
+++ b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1 @@
+../../python3-pyside2/patches/importlib-machinery-bypass.patch
\ No newline at end of file
diff --git a/srcpkgs/shiboken2/template b/srcpkgs/shiboken2/template
index 883d6a084d868..f3c06ec245a1f 100644
--- a/srcpkgs/shiboken2/template
+++ b/srcpkgs/shiboken2/template
@@ -1,7 +1,7 @@
 # Template file for 'shiboken2'
 pkgname=shiboken2
 version=5.15.10
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/shiboken2"
 build_style=cmake

From 46df4bf689b0d84afe757975e2fe80e8396ac517 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:53 -0400
Subject: [PATCH 079/113] python3-pyside2: revbump for qt5-5.15.11

---
 .../patches/importlib-machinery-bypass.patch      | 15 +++++++++++++++
 srcpkgs/python3-pyside2/template                  |  2 +-
 2 files changed, 16 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
new file mode 100644
index 0000000000000..64c429584776b
--- /dev/null
+++ b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1,15 @@
+Using this prevents an error around line 220 below it.
+"AttributeError: module 'importlib' has no attribute 'machinery'"
+The old backup logic is in place and compiles without issues.
+--- a/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:09:34.688912402 -0400
++++ b/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:10:03.395529582 -0400
+@@ -170,9 +170,6 @@
+
+     # 'zipstring_sequence' comes from signature.cpp
+     zipbytes = base64.b64decode(''.join(zipstring_sequence))
+-    if sys.version_info[0] >= 3:
+-        vzip = zipfile.ZipFile(io.BytesIO(zipbytes))
+-        return sys.meta_path, EmbeddableZipImporter(vzip)
+
+     # Old version for Python 2.7, only.
+     import os
diff --git a/srcpkgs/python3-pyside2/template b/srcpkgs/python3-pyside2/template
index 249efa9098842..52626436ce75f 100644
--- a/srcpkgs/python3-pyside2/template
+++ b/srcpkgs/python3-pyside2/template
@@ -1,7 +1,7 @@
 # Template file for 'python3-pyside2'
 pkgname=python3-pyside2
 version=5.15.10
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/pyside2"
 build_style=cmake

From 2b781e7bb5d351bdfb6cb2f61da2b18da9a86b71 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:35 -0400
Subject: [PATCH 080/113] konqueror: revbump for ffmpeg-6.0

---
 srcpkgs/konqueror/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/konqueror/template b/srcpkgs/konqueror/template
index abfa59e6b7ded..3cc29c12dc1db 100644
--- a/srcpkgs/konqueror/template
+++ b/srcpkgs/konqueror/template
@@ -1,11 +1,11 @@
 # Template file for 'konqueror'
 pkgname=konqueror
 version=23.08.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DDESKTOPTOJSON_EXECUTABLE=/usr/bin/desktoptojson"
 hostmakedepends="extra-cmake-modules python3 qt5-host-tools qt5-qmake kdoctools
-kcoreaddons kconfig gettext"
+ kcoreaddons kconfig gettext"
 makedepends="qt5-devel qt5-webengine-devel qt5-declarative-devel
  qt5-webchannel-devel qt5-location-devel kcmutils-devel kdelibs4support-devel
  karchive-devel khtml-devel kdesu-devel kactivities5-devel"

From d9c03d9605e878361d16a057a66fc44152d6f73f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:58 -0400
Subject: [PATCH 081/113] qt5-speech: revbump for qt5-5.15.11

---
 srcpkgs/qt5-speech/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-speech/template b/srcpkgs/qt5-speech/template
index 3ecd10d50650c..2d7d4d4d24535 100644
--- a/srcpkgs/qt5-speech/template
+++ b/srcpkgs/qt5-speech/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-speech'
 pkgname=qt5-speech
 version=5.15.7
-revision=2
+revision=3
 _commit=d32f4a479d38a11f547598004b975f4356424a16
 build_style=qmake
 configure_args="-- -flite -flite-alsa -speechd"

From 90c7a0117b32d2d27f9943d71c454fbaacb2b889 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Jun 2023 08:20:22 -0400
Subject: [PATCH 082/113] gtk4: revbump for ffmpeg-6.0

---
 srcpkgs/gtk4/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gtk4/template b/srcpkgs/gtk4/template
index 6a4e20357a86f..ec0c13d2cc5b0 100644
--- a/srcpkgs/gtk4/template
+++ b/srcpkgs/gtk4/template
@@ -1,7 +1,7 @@
 # Template file for 'gtk4'
 pkgname=gtk4
 version=4.12.3
-revision=1
+revision=2
 build_style=meson
 build_helper="gir"
 configure_args="-Dman-pages=true -Ddocumentation=true -Dbuild-tests=false

From fe20b4842a8c44a79cdde312a7c15dd2acd90472 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:28:26 -0400
Subject: [PATCH 083/113] siril: revbump for ffmpeg-6.0

---
 srcpkgs/siril/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/siril/template b/srcpkgs/siril/template
index 84332f79d060d..62750dd247548 100644
--- a/srcpkgs/siril/template
+++ b/srcpkgs/siril/template
@@ -1,7 +1,7 @@
 # Template file for 'siril'
 pkgname=siril
 version=0.9.12
-revision=10
+revision=11
 build_style=gnu-configure
 hostmakedepends="pkg-config intltool autoconf automake gettext-devel"
 makedepends="fftw-devel libconfig-devel libopencv-devel libffms2-devel

From daa3ed45d6828bba49288b575e0ab163e2e679e9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 22 Jun 2023 10:25:02 -0400
Subject: [PATCH 084/113] kdenlive: revbump for ffmpeg-6.0

---
 srcpkgs/kdenlive/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kdenlive/template b/srcpkgs/kdenlive/template
index ec5fe75860948..e69ecff31f272 100644
--- a/srcpkgs/kdenlive/template
+++ b/srcpkgs/kdenlive/template
@@ -1,7 +1,7 @@
 # Template file for 'kdenlive'
 pkgname=kdenlive
 version=23.08.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="
  extra-cmake-modules kconfig kcoreaddons kdoctools pkg-config python3

From 35c8914d37755b3d7ff269e9b0d44d8e1f5560bd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:20:59 -0400
Subject: [PATCH 085/113] tracker-miners: revbump for ffmpeg-6.0

---
 srcpkgs/tracker-miners/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tracker-miners/template b/srcpkgs/tracker-miners/template
index 0b97f47489f81..f196d2bf9e4a4 100644
--- a/srcpkgs/tracker-miners/template
+++ b/srcpkgs/tracker-miners/template
@@ -1,7 +1,7 @@
 # Template file for 'tracker-miners'
 pkgname=tracker-miners
 version=3.6.1
-revision=1
+revision=2
 build_style=meson
 build_helper=qemu
 # missing libgrss for miner_rss

From af4b749776a519534aa29366ca24310b139dc350 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:21:21 -0400
Subject: [PATCH 086/113] mpd: revbump for ffmpeg-6.0

---
 srcpkgs/mpd/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpd/template b/srcpkgs/mpd/template
index 645c1b778e407..60287cc9f6e3c 100644
--- a/srcpkgs/mpd/template
+++ b/srcpkgs/mpd/template
@@ -1,7 +1,7 @@
 # Template file for 'mpd'
 pkgname=mpd
 version=0.23.14
-revision=3
+revision=4
 build_style=meson
 configure_args="-Dopus=enabled -Dmikmod=enabled -Dneighbor=true
  -Dsoundcloud=enabled -Dpipe=true -Dtwolame=enabled -Dbzip2=enabled

From f53466f461bc96b0ccaf219d85a6a28ef5bb6004 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:02 -0400
Subject: [PATCH 087/113] tg_owt: revbump for ffmpeg-6.0

---
 srcpkgs/tg_owt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tg_owt/template b/srcpkgs/tg_owt/template
index 50bc8310b8859..c93262d5c5de6 100644
--- a/srcpkgs/tg_owt/template
+++ b/srcpkgs/tg_owt/template
@@ -1,7 +1,7 @@
 # Template file for 'tg_owt'
 pkgname=tg_owt
 version=0.0.0.20230921
-revision=1
+revision=2
 _commit=3bb3d757681e6cc5135aec6529a753dc3dcdcfb9
 _libyuv_commit=04821d1e7d60845525e8db55c7bcd41ef5be9406
 _abseil_commit=8c0b94e793a66495e0b1f34a5eb26bd7dc672db0

From 63f9091eadf95f164c9f839b9bc9da68935cc0b4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:44 -0400
Subject: [PATCH 088/113] telegram-desktop: revbump for ffmpeg-6.0

---
 srcpkgs/telegram-desktop/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/telegram-desktop/template b/srcpkgs/telegram-desktop/template
index 9bd94ce3781ff..d33fc62b10e38 100644
--- a/srcpkgs/telegram-desktop/template
+++ b/srcpkgs/telegram-desktop/template
@@ -1,7 +1,7 @@
 # Template file for 'telegram-desktop'
 pkgname=telegram-desktop
 version=4.11.2
-revision=1
+revision=2
 build_style=cmake
 build_helper="qemu gir"
 configure_args="-DTDESKTOP_API_ID=209235

From b4ea945311db0520f01103650075134088b59593 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:11:45 -0400
Subject: [PATCH 089/113] gst-plugins-bad1: revbump for ffmpeg-6.0

---
 srcpkgs/gst-plugins-bad1/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index fcd3538cd5cde..976e2889b588e 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-plugins-bad1'
 pkgname=gst-plugins-bad1
 version=1.22.7
-revision=1
+revision=2
 build_helper="gir"
 build_style=meson
 configure_args="-Dpackage-origin=https://voidlinux.org -Ddoc=disabled

From 0d98503efacfb77b3c6c252e0ec853cdfc1f7b0b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:12:09 -0400
Subject: [PATCH 090/113] openmw: revbump for ffmpeg-6.0

---
 srcpkgs/openmw/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openmw/template b/srcpkgs/openmw/template
index 0abf5ff7cdbec..b57180f1a4446 100644
--- a/srcpkgs/openmw/template
+++ b/srcpkgs/openmw/template
@@ -1,7 +1,7 @@
 # Template file for 'openmw'
 pkgname=openmw
 version=0.48.0
-revision=2
+revision=3
 build_style=cmake
 _recast_commit=e75adf86f91eb3082220085e42dda62679f9a3ea
 _bullet_tag=3.17

From 4d9cf9f1933afedeac9cdd8b2f6ee7a829138406 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:14:53 -0400
Subject: [PATCH 091/113] lms: revbump for ffmpeg-6.0

---
 srcpkgs/lms/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/lms/template b/srcpkgs/lms/template
index e358f75902a98..3b21c458de519 100644
--- a/srcpkgs/lms/template
+++ b/srcpkgs/lms/template
@@ -1,7 +1,7 @@
 # Template file for 'lms'
 pkgname=lms
 version=3.42.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="wt-devel ffmpeg-devel boost-devel libconfig++-devel taglib-devel pam-devel libgraphicsmagick-devel gtest-devel libarchive-devel"

From 021b720060a599c0c972dfaa5774d5835fb73d4c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:18:18 -0400
Subject: [PATCH 092/113] freecad: DELETE

---
 srcpkgs/freecad/patches/001-include.patch     | 112 ------------------
 .../154-revert-gui-tmp-redirect-stderr.patch  |  68 -----------
 ...d63c8c9b1280978be841d04e68a0a55cceb9.patch |  30 -----
 srcpkgs/freecad/template                      |  12 +-
 4 files changed, 7 insertions(+), 215 deletions(-)
 delete mode 100644 srcpkgs/freecad/patches/001-include.patch
 delete mode 100644 srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
 delete mode 100644 srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch

diff --git a/srcpkgs/freecad/patches/001-include.patch b/srcpkgs/freecad/patches/001-include.patch
deleted file mode 100644
index 28b5af54999b9..0000000000000
--- a/srcpkgs/freecad/patches/001-include.patch
+++ /dev/null
@@ -1,112 +0,0 @@
-From 9a41845a417189776741297c50a3827ce292bc4f Mon Sep 17 00:00:00 2001
-From: Uwe <donovaly@users.noreply.github.com>
-Date: Sun, 3 Jul 2022 22:51:16 +0200
-Subject: [PATCH] [Part] OCCError.h: remove unneeded includes
-
-- also sort includes
----
- src/Mod/Part/App/OCCError.h             | 36 +++----------------------
- src/Mod/Part/App/OffsetCurvePyImp.cpp   | 12 ++++-----
- src/Mod/Part/App/OffsetSurfacePyImp.cpp | 10 +++----
- 3 files changed, 12 insertions(+), 46 deletions(-)
-
---- a/src/Mod/Part/App/OCCError.h
-+++ b/src/Mod/Part/App/OCCError.h
-@@ -23,36 +23,8 @@
- #ifndef _OCCError_h_
- #define _OCCError_h_
- 
--# include <Standard_Version.hxx>
- # include <Standard_Failure.hxx>
--# include <Standard_AbortiveTransaction.hxx>
--# include <Standard_ConstructionError.hxx>
--# if OCC_VERSION_HEX >= 0x060500
--# include <Standard_DefineException.hxx>
--# endif
--# include <Standard_DimensionError.hxx>
--# include <Standard_DimensionMismatch.hxx>
--# include <Standard_DivideByZero.hxx>
--# include <Standard_DomainError.hxx>
--# include <Standard_ImmutableObject.hxx>
--# include <Standard_LicenseError.hxx>
--# include <Standard_LicenseNotFound.hxx>
--# include <Standard_MultiplyDefined.hxx>
--# include <Standard_NegativeValue.hxx>
--# include <Standard_NoMoreObject.hxx>
--# include <Standard_NoSuchObject.hxx>
--# include <Standard_NotImplemented.hxx>
--# include <Standard_NullObject.hxx>
--# include <Standard_NullValue.hxx>
--# include <Standard_NumericError.hxx>
--# include <Standard_OutOfMemory.hxx>
--# include <Standard_OutOfRange.hxx>
--# include <Standard_Overflow.hxx>
--# include <Standard_ProgramError.hxx>
--# include <Standard_RangeError.hxx>
--# include <Standard_TooManyUsers.hxx>
--# include <Standard_TypeMismatch.hxx>
--# include <Standard_Underflow.hxx>
-+# include <Standard_Version.hxx>
- 
- #include <Mod/Part/PartGlobal.h>
- #include <Base/Console.h>
-@@ -88,4 +60,3 @@ PartExport extern PyObject* PartExceptio
- 
- #define PY_CATCH_OCC _PY_CATCH_OCC(return(NULL))
- #endif  // _OCCError_h_
--
---- a/src/Mod/Part/App/OffsetCurvePyImp.cpp
-+++ b/src/Mod/Part/App/OffsetCurvePyImp.cpp
-@@ -20,20 +20,20 @@
-  *                                                                         *
-  ***************************************************************************/
- 
--
- #include "PreCompiled.h"
- #ifndef _PreComp_
- # include <Geom_OffsetCurve.hxx>
- #endif
- 
--#include "OCCError.h"
--#include "Geometry.h"
-+#include <Base/GeometryPyCXX.h>
-+#include <Base/Vector3D.h>
-+#include <Base/VectorPy.h>
-+
- #include "OffsetCurvePy.h"
- #include "OffsetCurvePy.cpp"
-+#include "Geometry.h"
-+#include "OCCError.h"
- 
--#include <Base/GeometryPyCXX.h>
--#include <Base/VectorPy.h>
--#include <Base/Vector3D.h>
- 
- using namespace Part;
- 
---- a/src/Mod/Part/App/OffsetSurfacePyImp.cpp
-+++ b/src/Mod/Part/App/OffsetSurfacePyImp.cpp
-@@ -20,20 +20,16 @@
-  *                                                                         *
-  ***************************************************************************/
- 
--
- #include "PreCompiled.h"
- #ifndef _PreComp_
- # include <Geom_OffsetSurface.hxx>
- # include <memory>
- #endif
- 
--#include <Base/VectorPy.h>
--#include <Base/Vector3D.h>
--
- #include "OCCError.h"
--#include "Geometry.h"
--#include <Mod/Part/App/OffsetSurfacePy.h>
--#include <Mod/Part/App/OffsetSurfacePy.cpp>
-+#include "OffsetSurfacePy.h"
-+#include "OffsetSurfacePy.cpp"
-+
- 
- using namespace Part;
- 
diff --git a/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch b/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
deleted file mode 100644
index d6a9adabdec83..0000000000000
--- a/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
+++ /dev/null
@@ -1,68 +0,0 @@
-see https://github.com/FreeCAD/FreeCAD/commit/cfe94b00d3434f3e2c8b5114d2909f628c330fa8#commitcomment-71413407
-
-upstream: yes
-
-From 7b377a216b9185960e4cee980a6504dc1a755f50 Mon Sep 17 00:00:00 2001
-From: wmayer <wmayer@users.sourceforge.net>
-Date: Wed, 29 Jun 2022 15:19:18 +0200
-Subject: [PATCH] Gui: remove workaround for spnav 0.23 due to build failure
- with musl libc
-
----
- src/Gui/3Dconnexion/GuiNativeEventLinux.cpp | 27 ---------------------
- 1 file changed, 27 deletions(-)
-
---- a/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp
-+++ b/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp
-@@ -21,42 +21,17 @@
-  ***************************************************************************/
- 
- #include <FCConfig.h>
--#include <cstdio>
- 
- #include "GuiNativeEventLinux.h"
- 
- #include "GuiApplicationNativeEventAware.h"
- #include <Base/Console.h>
--#include <Base/FileInfo.h>
- #include <QMainWindow>
- 
- #include <QSocketNotifier>
- 
- #include <spnav.h>
- 
--namespace {
--class RedirectStdErr
--{
--public:
--    RedirectStdErr()
--        : fi(Base::FileInfo::getTempFileName())
--        , file(stderr)
--    {
--        stderr = fopen(fi.filePath().c_str(), "w");
--    }
--    ~RedirectStdErr()
--    {
--        fclose(stderr);
--        fi.deleteFile();
--        stderr = file;
--    }
--
--private:
--    Base::FileInfo fi;
--    FILE* file;
--};
--}
--
- Gui::GuiNativeEvent::GuiNativeEvent(Gui::GUIApplicationNativeEventAware *app)
- : GuiAbstractNativeEvent(app)
- {
-@@ -72,8 +47,6 @@ Gui::GuiNativeEvent::~GuiNativeEvent()
- 
- void Gui::GuiNativeEvent::initSpaceball(QMainWindow *window)
- {
--    // tmp. redirect stderr to a file to suppress an error message from spnav_open()
--    RedirectStdErr err;
-     Q_UNUSED(window)
-     if (spnav_open() == -1) {
-         Base::Console().Log("Couldn't connect to spacenav daemon. Please ignore if you don't have a spacemouse.\n");
diff --git a/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch b/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch
deleted file mode 100644
index d4acf370ca0a4..0000000000000
--- a/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-From fe02d63c8c9b1280978be841d04e68a0a55cceb9 Mon Sep 17 00:00:00 2001
-From: Roy-043 <70520633+Roy-043@users.noreply.github.com>
-Date: Thu, 29 Dec 2022 23:20:38 +0100
-Subject: [PATCH] Draft: update inspect.getargspec to inspect.getfullargspec
- (#8101)
-
----
- src/Mod/Draft/draftguitools/gui_snapper.py | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
---- a/src/Mod/Draft/draftguitools/gui_snapper.py
-+++ b/src/Mod/Draft/draftguitools/gui_snapper.py
-@@ -1426,7 +1426,7 @@ class Snapper:
-             Gui.Snapper.off()
-             self.ui.offUi()
-             if callback:
--                if len(inspect.getargspec(callback).args) > 1:
-+                if len(inspect.getfullargspec(callback).args) > 1:
-                     obj = None
-                     if self.snapInfo and ("Object" in self.snapInfo) and self.snapInfo["Object"]:
-                         obj = App.ActiveDocument.getObject(self.snapInfo["Object"])
-@@ -1445,7 +1445,7 @@ class Snapper:
-             Gui.Snapper.off()
-             self.ui.offUi()
-             if callback:
--                if len(inspect.getargspec(callback).args) > 1:
-+                if len(inspect.getfullargspec(callback).args) > 1:
-                     callback(None, None)
-                 else:
-                     callback(None)
diff --git a/srcpkgs/freecad/template b/srcpkgs/freecad/template
index c135701e38b9a..7d5165f760bab 100644
--- a/srcpkgs/freecad/template
+++ b/srcpkgs/freecad/template
@@ -1,7 +1,7 @@
 # Template file for 'freecad'
 pkgname=freecad
-version=0.20.2
-revision=7
+version=0.21.1
+revision=2
 build_wrksrc="FreeCAD-${version}"
 build_style=cmake
 pycompile_dirs="usr/lib/${pkgname}/Mod"
@@ -24,8 +24,10 @@ makedepends="python3-devel boost-devel libxerces-c-devel zlib-devel occt-devel
  coin3-devel libshiboken2-devel libspnav-devel pyside2-tools
  liblz4-devel libpyside2-python3-devel python3-matplotlib netcdf-devel
  jsoncpp-devel qt5-devel qt5-svg-devel qt5-tools-devel qt5-webkit-devel
- qt5-xmlpatterns-devel coin3-doc glew-devel python3-pivy"
-depends="python3-matplotlib python3-pyside2-webengine python3-pivy"
+ qt5-xmlpatterns-devel coin3-doc glew-devel python3-pivy qt5-webengine-devel
+ qt5-declarative-devel qt5-webchannel-devel qt5-location-devel"
+depends="python3-matplotlib python3-pyside2-webengine python3-pivy
+ python3-GitPython python3-Markdown"
 short_desc="General purpose 3D CAD modeler"
 maintainer="yopito <pierre.bourgin@free.fr>"
 license="LGPL-2.0-or-later"
@@ -35,7 +37,7 @@ distfiles="
  https://github.com/FreeCAD/FreeCAD/archive/${version}.tar.gz
  ${SOURCEFORGE_SITE}/cxx/pycxx-${_pycxxver}.tar.gz
 "
-checksum="46922f3a477e742e1a89cd5346692d63aebb2b67af887b3e463e094a4ae055da
+checksum="e9b1fd0323f101268c7f3be52db42e4a29222f2e306ae6c4a6fc309cb418d35a
  4b91e1e1141c23fbd5039df635c4bb6e75632168548f56b83ce177193c0c98c6"
 python_version=3
 patch_args="-Np1 -d ${build_wrksrc}"

From faa2b985b015d95b7d0590e358e2b753241258cd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:47:18 -0400
Subject: [PATCH 093/113] libopenshot: revbump for ffmpeg-6.0

---
 srcpkgs/libopenshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenshot/template b/srcpkgs/libopenshot/template
index 8e57c5f592169..7a8f4520e7892 100644
--- a/srcpkgs/libopenshot/template
+++ b/srcpkgs/libopenshot/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenshot'
 pkgname=libopenshot
 version=0.3.0
-revision=3
+revision=4
 build_style=cmake
 # Builds fail with Ruby-2.4.1
 configure_args="-DENABLE_RUBY=OFF -DUSE_SYSTEM_JSONCPP=ON"

From 1a81048f9fa8836cb9b6b40eeaef372ef38ee363 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:10:30 -0500
Subject: [PATCH 094/113] openimageio: revbump for ffmpeg-6.0

---
 srcpkgs/openimageio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimageio/template b/srcpkgs/openimageio/template
index 3ce3f9e49d350..27d2131bc0a61 100644
--- a/srcpkgs/openimageio/template
+++ b/srcpkgs/openimageio/template
@@ -1,7 +1,7 @@
 # Template file for 'openimageio'
 pkgname=openimageio
 version=2.4.9.0
-revision=7
+revision=8
 build_style=cmake
 build_helper=qemu
 configure_args="-DUSE_QT=0 -DUSE_PYTHON=0 -DOIIO_BUILD_TESTS=0

From 9ab408f6eb6a3fc819d6dd6372e4cabc4eeff80a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:11:57 -0500
Subject: [PATCH 095/113] synfigstudio: revbump for ffmpeg-6.0

---
 srcpkgs/synfigstudio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/synfigstudio/template b/srcpkgs/synfigstudio/template
index 09e442da9a680..2bc017cedca6b 100644
--- a/srcpkgs/synfigstudio/template
+++ b/srcpkgs/synfigstudio/template
@@ -2,7 +2,7 @@
 # Should be kept in sync with 'synfig' and 'ETL'
 pkgname=synfigstudio
 version=1.4.4
-revision=4
+revision=5
 build_style=gnu-configure
 configure_args="--disable-update-mimedb"
 hostmakedepends="pkg-config intltool gettext synfig"

From e8221af9b9ab1c51be9c4a5de1961913fd56134b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:12:32 -0500
Subject: [PATCH 096/113] gmic: revbump for ffmpeg-6.0

---
 srcpkgs/gmic/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gmic/template b/srcpkgs/gmic/template
index fa37651bb6dee..24d10147e3aba 100644
--- a/srcpkgs/gmic/template
+++ b/srcpkgs/gmic/template
@@ -1,7 +1,7 @@
 # Template file for 'gmic'
 pkgname=gmic
 version=3.1.6
-revision=5
+revision=6
 _zart_hash=34ebf6cce0bafb98abe57cec83c4a02cd1abeca0
 create_wrksrc=yes
 build_wrksrc="src"

From 3c7ad8ab7dc1c78882da33ff68eb03d2ed552516 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:10 -0500
Subject: [PATCH 097/113] mixxx: revbump for ffmpeg-6.0

---
 srcpkgs/mixxx/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mixxx/template b/srcpkgs/mixxx/template
index 6921996e4e77b..6a79b328c1abf 100644
--- a/srcpkgs/mixxx/template
+++ b/srcpkgs/mixxx/template
@@ -1,7 +1,7 @@
 # Template file for 'mixxx'
 pkgname=mixxx
 version=2.3.3
-revision=6
+revision=7
 build_style=cmake
 configure_args="-DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="extra-cmake-modules pkg-config protobuf qt5-host-tools qt5-qmake"

From 6e2892bdd3e76ec7b34f6adec589d15355d38361 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:28 -0500
Subject: [PATCH 098/113] musikcube: revbump for ffmpeg-6.0

---
 srcpkgs/musikcube/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/musikcube/template b/srcpkgs/musikcube/template
index d9e6186e6697b..637952d50aca3 100644
--- a/srcpkgs/musikcube/template
+++ b/srcpkgs/musikcube/template
@@ -1,7 +1,7 @@
 # Template file for 'musikcube'
 pkgname=musikcube
 version=3.0.0
-revision=3
+revision=4
 build_style=cmake
 make_cmd=make
 configure_args="-DNO_NCURSESW=1"

From 21ebb12ea446279c217e2726b9aaf9980446ab80 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:45 -0500
Subject: [PATCH 099/113] electron24: revbump for ffmpeg-6.0

---
 srcpkgs/electron24/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron24/template b/srcpkgs/electron24/template
index a9c865c19c989..b8613e4362bc7 100644
--- a/srcpkgs/electron24/template
+++ b/srcpkgs/electron24/template
@@ -1,7 +1,7 @@
 # Template file for 'electron24'
 pkgname=electron24
 version=24.3.0
-revision=2
+revision=3
 _nodever=18.14.0
 _chromiumver=112.0.5615.165
 archs="x86_64* aarch64*"

From 1f697d54c40fa35f44417784a483cbfaa89b123a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:00 -0500
Subject: [PATCH 100/113] electron19: revbump for ffmpeg-6.0

---
 srcpkgs/electron19/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron19/template b/srcpkgs/electron19/template
index b18bc792c8221..29fb34e254eea 100644
--- a/srcpkgs/electron19/template
+++ b/srcpkgs/electron19/template
@@ -1,7 +1,7 @@
 # Template file for 'electron19'
 pkgname=electron19
 version=19.0.8
-revision=4
+revision=5
 _nodever=16.14.2
 _chromiumver=102.0.5005.125
 archs="x86_64* aarch64* ppc64le*"

From d597a491e5b744fef11f6af871fe27b448862d7f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:13 -0500
Subject: [PATCH 101/113] wf-recorder: revbump for ffmpeg-6.0

---
 srcpkgs/wf-recorder/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/wf-recorder/template b/srcpkgs/wf-recorder/template
index 08f986b031006..63c45cf4b814d 100644
--- a/srcpkgs/wf-recorder/template
+++ b/srcpkgs/wf-recorder/template
@@ -1,7 +1,7 @@
 # Template file for 'wf-recorder'
 pkgname=wf-recorder
 version=0.4.1
-revision=2
+revision=3
 build_style=meson
 hostmakedepends="pkg-config scdoc wayland-devel"
 makedepends="wayland-protocols wayland-devel ffmpeg-devel libgbm-devel x264-devel

From 88bc3e5eab52e8a90ed925c131b84fcd1ae7fadf Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:26 -0500
Subject: [PATCH 102/113] obs: revbump for ffmpeg-6.0

---
 srcpkgs/obs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/obs/template b/srcpkgs/obs/template
index b343f1131bfcf..a25a67433e285 100644
--- a/srcpkgs/obs/template
+++ b/srcpkgs/obs/template
@@ -1,7 +1,7 @@
 # Template file for 'obs'
 pkgname=obs
 version=30.0.0
-revision=2
+revision=3
 archs="i686* x86_64* ppc64le* aarch64* riscv64*"
 build_style=cmake
 configure_args="-DOBS_VERSION_OVERRIDE=${version} -DENABLE_JACK=ON

From 00706112fc9497345d31227b538badad6e958e6d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:36 -0500
Subject: [PATCH 103/113] mlt7: revbump for ffmpeg-6.0

---
 srcpkgs/mlt7/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mlt7/template b/srcpkgs/mlt7/template
index 98f302ad3a516..7eb8c00fa1580 100644
--- a/srcpkgs/mlt7/template
+++ b/srcpkgs/mlt7/template
@@ -1,7 +1,7 @@
 # Template file for 'mlt7'
 pkgname=mlt7
 version=7.20.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DSWIG_PYTHON=ON -DMOD_QT6=ON"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which

From 575c4683516450f924bdad9481b453ff67eceac5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:48 -0500
Subject: [PATCH 104/113] qt6-multimedia: revbump for ffmpeg-6.0

---
 srcpkgs/qt6-multimedia/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-multimedia/template b/srcpkgs/qt6-multimedia/template
index 67a577e1300fe..1da626ecf515a 100644
--- a/srcpkgs/qt6-multimedia/template
+++ b/srcpkgs/qt6-multimedia/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-multimedia'
 pkgname=qt6-multimedia
 version=6.6.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DQT_FEATURE_gstreamer=ON"
 hostmakedepends="perl qt6-declarative-host-tools pkg-config qt6-shadertools"

From 152d68fb4b0267e6087bb0dd917b9a21d0598ad5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:00:15 -0500
Subject: [PATCH 105/113] baresip: revbump for ffmpeg-6.0

---
 srcpkgs/baresip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/baresip/template b/srcpkgs/baresip/template
index 12c8954ef7b9b..b16b67beab8d2 100644
--- a/srcpkgs/baresip/template
+++ b/srcpkgs/baresip/template
@@ -1,7 +1,7 @@
 # Template file for 'baresip'
 pkgname=baresip
 version=3.6.0
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config glib-devel"
 makedepends="libgsm-devel libpng-devel openssl-devel libsndfile-devel

From 63abdc5261bbcac8fe7d6e30352e6e14ff030dce Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:30 -0500
Subject: [PATCH 106/113] QMPlay2: revbump for ffmpeg-6.0

---
 srcpkgs/QMPlay2/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/QMPlay2/template b/srcpkgs/QMPlay2/template
index 46c80f64a1349..942258ce60fb7 100644
--- a/srcpkgs/QMPlay2/template
+++ b/srcpkgs/QMPlay2/template
@@ -1,7 +1,7 @@
 # Template file for 'QMPlay2'
 pkgname=QMPlay2
 version=23.10.22
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools"
 makedepends="alsa-lib-devel ffmpeg-devel libass-devel libcdio-devel libgme-devel

From b3be09bf07964c5bb063eacc41d4ea27952c547a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:34 -0500
Subject: [PATCH 107/113] alsa-plugins: revbump for ffmpeg-6.0

---
 srcpkgs/alsa-plugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/alsa-plugins/template b/srcpkgs/alsa-plugins/template
index a5708a7d82a8f..7bfdad046c483 100644
--- a/srcpkgs/alsa-plugins/template
+++ b/srcpkgs/alsa-plugins/template
@@ -1,7 +1,7 @@
 # Template file for 'alsa-plugins'
 pkgname=alsa-plugins
 version=1.2.7.1
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--disable-maemo-plugin"
 hostmakedepends="pkg-config"

From 4cce6bd0f6151103eb84ffdaf0cb14c1f4a96aee Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:43 -0500
Subject: [PATCH 108/113] minidlna: revbump for ffmpeg-6.0

---
 srcpkgs/minidlna/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/minidlna/template b/srcpkgs/minidlna/template
index 5fa929f3a0c12..742991ecd04af 100644
--- a/srcpkgs/minidlna/template
+++ b/srcpkgs/minidlna/template
@@ -1,7 +1,7 @@
 # Template file for 'minidlna'
 pkgname=minidlna
 version=1.3.3
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="
  --sbindir=/usr/bin

From 8dc8bd3b06d7f8fbcf7d7a37eb3d6cf4b4ce5a46 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 17:57:47 -0500
Subject: [PATCH 109/113] mpv: revbump for ffmpeg-6.0

---
 srcpkgs/mpv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpv/template b/srcpkgs/mpv/template
index 4948d1e332cb8..1ac1b167af189 100644
--- a/srcpkgs/mpv/template
+++ b/srcpkgs/mpv/template
@@ -1,7 +1,7 @@
 # Template file for 'mpv'
 pkgname=mpv
 version=0.36.0
-revision=4
+revision=5
 build_style=meson
 configure_args="-Dcdda=enabled -Ddvbin=enabled -Ddvdnav=enabled
  -Dlibmpv=true -Dcplugins=enabled

From 8a582a268b8b7c17f8078d15840280addc589be8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 17:59:29 -0500
Subject: [PATCH 110/113] qimgv: revbump for ffmpeg-6.0

---
 srcpkgs/qimgv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qimgv/template b/srcpkgs/qimgv/template
index dd341dfe1bfce..8a7e1c081ef12 100644
--- a/srcpkgs/qimgv/template
+++ b/srcpkgs/qimgv/template
@@ -1,7 +1,7 @@
 # Template file for 'qimgv'
 pkgname=qimgv
 version=1.0.2
-revision=3
+revision=4
 build_style=cmake
 configure_args="$(vopt_if video -DVIDEO_SUPPORT=ON -DVIDEO_SUPPORT=OFF)
  $(vopt_if scale -DOPENCV_SUPPORT=ON -DOPENCV_SUPPORT=OFF)

From b7f40946ca98267f09e51ba9f6e33d16cc5f53c3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 18:00:36 -0500
Subject: [PATCH 111/113] kfilemetadata5: revbump for ffmpeg-6.0

---
 srcpkgs/kfilemetadata5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kfilemetadata5/template b/srcpkgs/kfilemetadata5/template
index 28430f112ab5d..593d2723d95d1 100644
--- a/srcpkgs/kfilemetadata5/template
+++ b/srcpkgs/kfilemetadata5/template
@@ -1,7 +1,7 @@
 # Template file for 'kfilemetadata5'
 pkgname=kfilemetadata5
 version=5.112.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="kcoreaddons extra-cmake-modules pkg-config qt5-host-tools qt5-qmake
  gettext kcoreaddons python3"

From bae73fe13ace6d323dadb73029d8c2a548c146d8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 8 Dec 2023 11:46:01 -0500
Subject: [PATCH 112/113] vba-m: revbump for ffmpeg-6.0

---
 srcpkgs/vba-m/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vba-m/template b/srcpkgs/vba-m/template
index 2223d297c31f5..50850668477b7 100644
--- a/srcpkgs/vba-m/template
+++ b/srcpkgs/vba-m/template
@@ -2,7 +2,7 @@
 pkgname=vba-m
 reverts=1292_2
 version=2.1.7
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DENABLE_GTK=TRUE -DENABLE_FFMPEG=TRUE -DENABLE_LINK=TRUE -DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="gettext pkg-config unzip zip yasm wxWidgets-gtk3-devel"

From 8db1073c96aa1fdb172ddb7cc81d6fc5ffd2951e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 8 Dec 2023 11:46:19 -0500
Subject: [PATCH 113/113] dolphin-emu: revbump for ffmpeg-6.0

---
 srcpkgs/dolphin-emu/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/dolphin-emu/template b/srcpkgs/dolphin-emu/template
index 96edf50d3e4a1..592e5b9bb5b4d 100644
--- a/srcpkgs/dolphin-emu/template
+++ b/srcpkgs/dolphin-emu/template
@@ -1,7 +1,7 @@
 # Template file for 'dolphin-emu'
 pkgname=dolphin-emu
 version=5.0.19368
-revision=3
+revision=4
 _dolphin_commit=dadbeb4bae7e7fa23af2b46e0add4143094dc107
 _mgba_commit=44e074a15e9651481f7f652ac006a7c9d58cbeb9
 _googletest_commit=be03d00f5f0cc3a997d1a368bee8a1fe93651f48

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (44 preceding siblings ...)
  2023-12-09 17:37 ` [PR PATCH] [Updated] " zlice
@ 2023-12-09 17:39 ` zlice
  2023-12-14 18:28 ` [PR PATCH] [Updated] " zlice
                   ` (51 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2023-12-09 17:39 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 348 bytes --]

New comment by zlice on void-packages repository

https://github.com/void-linux/void-packages/pull/43761#issuecomment-1848592386

Comment:
Using QT 5.15.11 that was just updated. Revbump for qt5 and some hacky patch to build qt5-webengine by forcing `-system-ffmpeg` and knocking out the test was complaining. If that should be fixed properly lmk.

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (45 preceding siblings ...)
  2023-12-09 17:39 ` zlice
@ 2023-12-14 18:28 ` zlice
  2023-12-19 20:48 ` zlice
                   ` (50 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2023-12-14 18:28 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 4019 bytes --]

There is an updated pull request by zlice against master on the void-packages repository

https://github.com/zlice/void-packages ffmpeg6-split
https://github.com/void-linux/void-packages/pull/43761

ffmpeg6 split
[ci skip]


#### Testing the changes

- I tested the changes in this PR: **YES**

main testing has been vaapi in Firefox Nightly and enc/dec in Shotcut on Intel A770

#### New package

- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**

#### Local build testing

- I built this PR locally for my native architecture, **x86_64**

#### Discussion

Continuation of https://github.com/void-linux/void-packages/pull/36315

`libavresample` is deprecated, but marked as a dependency when trying to build other packages and install `ffmpeg`(6). I think the right way to handle this is make a meta package and the add to removals?


##### Commit naming / misc

~~Commits are 'dirty' right now, running with [gstreamer 1.22.1 updates](https://github.com/void-linux/void-packages/pull/42861) and [Intel OpenCL](https://github.com/void-linux/void-packages/pull/43084). This will also make [intel packages pr](https://github.com/void-linux/void-packages/pull/41132) obsolete.~~ (see Requirements below)

Maintainer for previous ffmpeg(4) was orphaned, I can put my name in there if that matters, though I don't exactly see myself keeping up on ffmpeg.

~~This updates QT5 which looks like it is usually hosted by Johnny. Not sure if there's any reason to stay there or these sources are fine.~~ Using qt5.15.11 now, revbumps and some patches.

##### STILL FFMPEG4

These are a mix of emulators, games and/or older packages.

- attract (multiple patches in master)
- audacity (https://github.com/audacity/audacity/issues/2305 and https://sourceforge.net/p/portmedia/wiki/portsmf/ is 'beta')
- ccextractor (master patches? no release)
- vice
- kodi
- mlt (only dep left is flowblade)
- ~~synfig (mlt)~~ (work with mlt7, bump synfigstudio)
- tvheadend
- ssr
- ~~spek-alternative~~ (replace with spek-x)
- ppsspp
- olive
- moc
- mediastreamer
- libextractor
- idjc
- hedgewars
- ~~ffmpegthumbnailer~~ (patches for moviedecoder.xxx files)
- ~~ffmpegthumbs~~ (latest compiles)
- deadbeef
- omxplayer
- qtav (fork has ffmpeg 5 patch - https://github.com/cmguo/QtAV)
- `vlc` (vlc4 will support ffmpeg5, there's a patch to build 3.x with ffmpeg5 but it will lack vaapi)
- `osg` (OpenSceneGraph plus `xine-lib`)


##### HAVE NOT BUILT YET

- omxplayer (rpi only? ffmpeg4)
- kodi (big, but ffmpeg4)


##### UPDATED (for ffmpeg6)

- ~~blender: update to 3.5.1~~ ~~will be revbump with~~ https://github.com/void-linux/void-packages/pull/43992
- unpaper: update to 7.0.0.
- guvcview: update to 2.0.8.
- ~~qt5: update to 5.15.8~~ updated by another PR to 5.15.11
- ~~qt5-webengine: update to 5.18.15~~ updated by another PR to 5.15.16 (some patching for ffmpeg build)
- ~~shiboken2: revbump for qt5.15.8 (patch)~~ updated by another PR to 5.15.10
- ~~python3-pyside2: update to 5.15.8 (patch)~~ updated by another PR to 5.15.10
- New package: spex-x replaces spek-alternative for ffmpeg-6.0


##### Requirements

- ~~[gstreamer 1.22.2](https://github.com/void-linux/void-packages/pull/42861)~~ - a few packages use ffmpeg-devel and require a revbump

- ~~[Intel Packages](https://github.com/void-linux/void-packages/pull/41132) [Intel Packages v2](https://github.com/void-linux/void-packages/pull/47330) - ffmpeg4 uses different libraries than 6 (libmfx / Intel-MediaSDK vs only oneVPL that Intel is moving to), both are included here~~. Using replacement oneVPL from OBS update.

- ~~[shotcut 23.05.14](https://github.com/void-linux/void-packages/pull/44260)~~

- https://github.com/void-linux/void-packages/pull/44781 will remove from this PR

A patch file from https://github.com/void-linux/void-packages/pull/43761.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ffmpeg6-split-43761.patch --]
[-- Type: text/x-diff, Size: 220519 bytes --]

From 9699e7f048e549dcbdf9886798509e04917e952b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:16:56 -0400
Subject: [PATCH 001/113] ffmpeg: update to 6.0.1.

---
 common/shlibs                                 | 26 +++++---
 srcpkgs/ffmpeg/files/altivec.patch            | 60 -------------------
 .../patches/armv5tel-floating-point.patch     | 18 ------
 ...h-libavcodec-libsvtav1-ten_bit_format.diff | 40 -------------
 .../workaround-mesa-readeon-vaapi-bug.patch   | 28 ---------
 srcpkgs/ffmpeg/template                       | 38 ++++++------
 6 files changed, 37 insertions(+), 173 deletions(-)
 delete mode 100644 srcpkgs/ffmpeg/files/altivec.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 delete mode 100644 srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch

diff --git a/common/shlibs b/common/shlibs
index 66d0045a2898f..734b2601c3cd5 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -385,15 +385,23 @@ libid3tag.so.0 libid3tag-0.15.1b_1
 libgif.so.7 giflib-5.1.0_1
 libImlib2.so.1 imlib2-1.4.2_1
 libmp3lame.so.0 lame-3.98.2_1
-libavdevice.so.58 libavdevice-4.0_1
-libavformat.so.58 libavformat-4.0_1
-libswscale.so.5 libswscale-4.0_1
-libswresample.so.3 libswresample-4.0_1
-libavresample.so.4 libavresample-4.0_1
-libpostproc.so.55 libpostproc-4.0_1
-libavcodec.so.58 libavcodec-4.0_1
-libavutil.so.56 libavutil-4.0_1
-libavfilter.so.7 libavfilter-4.0_1
+libavdevice.so.60 libavdevice-6.0_1
+libavformat.so.60 libavformat-6.0_1
+libswscale.so.7 libswscale-6.0_1
+libswresample.so.4 libswresample-6.0_1
+libpostproc.so.57 libpostproc-6.0_1
+libavcodec.so.60 libavcodec-6.0_1
+libavutil.so.58 libavutil-6.0_1
+libavfilter.so.9 libavfilter-6.0_1
+libavdevice.so.58 libavdevice4-4.0_1
+libavformat.so.58 libavformat4-4.0_1
+libswscale.so.5 libswscale4-4.0_1
+libswresample.so.3 libswresample4-4.0_1
+libavresample.so.4 libavresample4-4.0_1
+libpostproc.so.55 libpostproc4-4.0_1
+libavcodec.so.58 libavcodec4-4.0_1
+libavutil.so.56 libavutil4-4.0_1
+libavfilter.so.7 libavfilter4-4.0_1
 libSDL-1.2.so.0 SDL-1.2.14_1
 libSDL_image-1.2.so.0 SDL_image-1.2.10_1
 libx264.so.157 x264-20190507.2245_1
diff --git a/srcpkgs/ffmpeg/files/altivec.patch b/srcpkgs/ffmpeg/files/altivec.patch
deleted file mode 100644
index 9c57200463320..0000000000000
--- a/srcpkgs/ffmpeg/files/altivec.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-revert some altivec specific change on all ppc* except ppc64le*
-
-q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
-conditionally, for ppc* but not ppc64le* (the new code is valid for
-POWER8 VSX which LE targets as a baseline but not BE)"
-
-
-This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
----
- libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
- 1 file changed, 20 insertions(+), 4 deletions(-)
-
-diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
-index 536545293d..c1e2852adb 100644
---- a/libswscale/ppc/yuv2rgb_altivec.c
-+++ b/libswscale/ppc/yuv2rgb_altivec.c
-@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-     vector signed short R1, G1, B1;                                           \
-     vector unsigned char R, G, B;                                             \
-                                                                               \
-+    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
-+    vector unsigned char align_perm;                                          \
-+                                                                              \
-     vector signed short lCY       = c->CY;                                    \
-     vector signed short lOY       = c->OY;                                    \
-     vector signed short lCRV      = c->CRV;                                   \
-@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
-                                                                               \
-         for (j = 0; j < w / 16; j++) {                                        \
--            y0 = vec_xl(0, y1i);                                              \
-+            y1ivP = (const vector unsigned char *) y1i;                       \
-+            y2ivP = (const vector unsigned char *) y2i;                       \
-+            uivP  = (const vector unsigned char *) ui;                        \
-+            vivP  = (const vector unsigned char *) vi;                        \
-+                                                                              \
-+            align_perm = vec_lvsl(0, y1i);                                    \
-+            y0 = (vector unsigned char)                                       \
-+                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
-                                                                               \
--            y1 = vec_xl(0, y2i);                                              \
-+            align_perm = vec_lvsl(0, y2i);                                    \
-+            y1 = (vector unsigned char)                                       \
-+                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
-                                                                               \
--            u = (vector signed char) vec_xl(0, ui);                           \
-+            align_perm = vec_lvsl(0, ui);                                     \
-+            u = (vector signed char)                                          \
-+                    vec_perm(uivP[0], uivP[1], align_perm);                   \
-                                                                               \
--            v = (vector signed char) vec_xl(0, vi);                           \
-+            align_perm = vec_lvsl(0, vi);                                     \
-+            v = (vector signed char)                                          \
-+                    vec_perm(vivP[0], vivP[1], align_perm);                   \
-                                                                               \
-             u = (vector signed char)                                          \
-                     vec_sub(u,                                                \
--- 
-2.27.0
-
diff --git a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
deleted file mode 100644
index 9a55178c74f0f..0000000000000
--- a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
-+++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
-@@ -39,6 +39,15 @@
- #endif
- #include <fenv.h>
- 
-+#if (FE_ALL_EXCEPT == 0)
-+/* E.g. ARM soft float does not define these */
-+#define FE_INVALID    0
-+#define FE_DIVBYZERO  0
-+#define FE_OVERFLOW   0
-+#define FE_UNDERFLOW  0
-+#define FE_INEXACT    0
-+#endif
-+
- #if CONFIG_LIBFONTCONFIG
- #include <fontconfig/fontconfig.h>
- #endif
diff --git a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
deleted file mode 100644
index aa948f7a8a2df..0000000000000
--- a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
+++ /dev/null
@@ -1,40 +0,0 @@
-#==================================================================================================
-# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
-# From: Christopher Degawa <christopher.degawa@intel.com>
-# Date: Thu, 20 Oct 2022 22:55:27 -0500
-# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
-#
-# compressed_ten_bit_format has been deprecated upstream and has no effect
-# and can be removed. Plus, technically it was never used in the first place
-# since it would require the app (ffmpeg) to set it and do additional
-# processing of the input frames.
-#
-# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
-#
-# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
-#==================================================================================================
---- a/libavcodec/libsvtav1.c
-+++ b/libavcodec/libsvtav1.c
-@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
- 
- static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
- {
--    const int    pack_mode_10bit =
--        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
--    const size_t luma_size_8bit  =
--        config->source_width * config->source_height * (1 << pack_mode_10bit);
--    const size_t luma_size_10bit =
--        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
-+    const size_t luma_size = config->source_width * config->source_height *
-+        (config->encoder_bit_depth > 8 ? 2 : 1);
- 
-     EbSvtIOFormat *in_data;
- 
--    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
-+    svt_enc->raw_size = luma_size * 3 / 2;
- 
-     // allocate buffer for in and out
-     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
--- 
-GitLab
-
diff --git a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
deleted file mode 100644
index 00e3f68a415b8..0000000000000
--- a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
-From: Rainer Hochecker <fernetmenta@online.de>
-Date: Sat, 26 Jan 2019 19:48:35 +0100
-Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
-
-This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
-It was hit frequently when watching h264 channels received via DVB-X.
-Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
----
- libavcodec/vaapi_h264.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
-index 5854587a255..f12fdc457a4 100644
---- a/libavcodec/vaapi_h264.c
-+++ b/libavcodec/vaapi_h264.c
-@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
-     H264SliceContext *sl = &h->slice_ctx[0];
-     int ret;
- 
-+    if (pic->nb_slices == 0) {
-+        ret = AVERROR_INVALIDDATA;
-+        goto finish;
-+    }
-+
-     ret = ff_vaapi_decode_issue(avctx, pic);
-     if (ret < 0)
-         goto finish;
diff --git a/srcpkgs/ffmpeg/template b/srcpkgs/ffmpeg/template
index 5968a09b1f12d..52fcf4d68797a 100644
--- a/srcpkgs/ffmpeg/template
+++ b/srcpkgs/ffmpeg/template
@@ -1,15 +1,15 @@
 # Template file for 'ffmpeg'
 # audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
 pkgname=ffmpeg
-version=4.4.4
-revision=5
+version=6.0.1
+revision=1
 short_desc="Decoding, encoding and streaming software"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="https://www.ffmpeg.org"
 changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
 distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
-checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+checksum=9b16b8731d78e596b4be0d720428ca42df642bb2d78342881ff7f5bc29fc9623
 
 hostmakedepends="pkg-config perl"
 makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
@@ -26,12 +26,13 @@ makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-deve
  $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
  $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
  $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
- $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers Vulkan-Tools Vulkan-ValidationLayers')
+ $(vopt_if onevpl 'oneVPL oneVPL-devel')
  $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
 depends="ffplay>=${version}_${revision}"
 
 build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
- dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec onevpl"
 build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
 desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
 desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
@@ -39,9 +40,13 @@ desc_option_sofa="Enable support for AES SOFA"
 desc_option_webp="Enable support for WebP"
 
 case "$XBPS_TARGET_MACHINE" in
-	i686*|x86_64*)
-		hostmakedepends+=" nasm"
+	i686*)
 		build_options_default+=" vaapi vdpau nvenc nvdec"
+		hostmakedepends+=" nasm"
+		;;
+	x86_64*)
+		hostmakedepends+=" nasm"
+		build_options_default+=" vaapi vdpau nvenc nvdec onevpl"
 		;;
 	ppc64*) build_options_default+=" vaapi vdpau";;
 	mips*) CFLAGS="-mnan=legacy";;
@@ -115,18 +120,19 @@ do_configure() {
 		$(vopt_enable x265 libx265) \
 		$(vopt_enable v4l2 libv4l2) \
 		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
-		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		--enable-libbs2b --enable-libvidstab \
 		$(vopt_enable dav1d libdav1d) \
 		$(vopt_enable zimg libzimg) \
 		$(vopt_enable webp libwebp) \
 		$(vopt_enable sofa libmysofa) \
 		$(vopt_enable vulkan) \
+		$(vopt_enable onevpl libvpl) \
 		$(vopt_enable drm libdrm) \
 		$(vopt_enable svtav1 libsvtav1) \
 		$(vopt_enable srt libsrt) \
 		$(vopt_enable rist librist) \
-		$(vopt_if nvenc '--enable-nvenc') \
-		$(vopt_if nvdec '--enable-nvdec')
+		$(vopt_enable nvenc nvenc) \
+		$(vopt_enable nvdec nvdec)
 }
 
 do_build() {
@@ -153,10 +159,8 @@ libavdevice_package() {
 }
 
 libavresample_package() {
-	short_desc="FFmpeg audio resampling library"
-	pkg_install() {
-		vmove "usr/lib/libavresample.so.*"
-	}
+	short_desc="Package deprecated, removal needed"
+	build_style=meta
 }
 
 libavformat_package() {
@@ -210,15 +214,13 @@ ffmpeg-devel_package() {
 		libavfilter>=${version}_${revision}
 		libpostproc>=${version}_${revision}
 		libswscale>=${version}_${revision}
-		libswresample>=${version}_${revision}
-		libavresample>=${version}_${revision}"
+		libswresample>=${version}_${revision}"
 	short_desc+=" - development files"
-
+	conflicts="ffmpeg4-devel"
 	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
 		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
 		nostrip_files="/usr/lib/libavfilter.a"
 	fi
-
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig

From 715d4de5cb5d37945736167e0a0ae46d7e168270 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:14 -0400
Subject: [PATCH 002/113] openshot: revbump for ffmpeg6.0

---
 srcpkgs/openshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openshot/template b/srcpkgs/openshot/template
index 8f47851eef354..affb652a9d500 100644
--- a/srcpkgs/openshot/template
+++ b/srcpkgs/openshot/template
@@ -1,7 +1,7 @@
 # Template file for 'openshot'
 pkgname=openshot
 version=3.0.0
-revision=2
+revision=3
 build_style=python3-module
 hostmakedepends="python3 python3-setuptools"
 makedepends="ffmpeg-devel python3-PyQt5"

From e1e8dc37117f956def201285bd90757d03a574ee Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:36 -0400
Subject: [PATCH 003/113] sumo: revbump for ffmpeg6.0

---
 srcpkgs/sumo/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/sumo/template b/srcpkgs/sumo/template
index a3fe134aa5acc..a730afa9fafa9 100644
--- a/srcpkgs/sumo/template
+++ b/srcpkgs/sumo/template
@@ -1,7 +1,7 @@
 # Template file for 'sumo'
 pkgname=sumo
 version=1.12.0
-revision=6
+revision=7
 build_style=cmake
 hostmakedepends="libgdal-tools pkg-config swig python3-setuptools"
 makedepends="python3-devel ffmpeg-devel fox-devel gl2ps-devel libgdal-devel

From 1bc01be89ee5b37cc64e27d0e54336d4de617f5c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:56:22 -0400
Subject: [PATCH 004/113] New package: ffmpeg4-4.4.4.

---
 srcpkgs/ffmpeg4-devel                         |   1 +
 srcpkgs/ffmpeg4/files/altivec.patch           |  60 +++++
 .../patches/armv5tel-floating-point.patch     |  18 ++
 ...h-libavcodec-libsvtav1-ten_bit_format.diff |  40 +++
 .../workaround-mesa-readeon-vaapi-bug.patch   |  28 +++
 srcpkgs/ffmpeg4/template                      | 234 ++++++++++++++++++
 srcpkgs/libavcodec4                           |   1 +
 srcpkgs/libavdevice4                          |   1 +
 srcpkgs/libavfilter4                          |   1 +
 srcpkgs/libavformat4                          |   1 +
 srcpkgs/libavresample4                        |   1 +
 srcpkgs/libavutil4                            |   1 +
 srcpkgs/libpostproc4                          |   1 +
 srcpkgs/libswresample4                        |   1 +
 srcpkgs/libswscale4                           |   1 +
 15 files changed, 390 insertions(+)
 create mode 120000 srcpkgs/ffmpeg4-devel
 create mode 100644 srcpkgs/ffmpeg4/files/altivec.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 create mode 100644 srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
 create mode 100644 srcpkgs/ffmpeg4/template
 create mode 120000 srcpkgs/libavcodec4
 create mode 120000 srcpkgs/libavdevice4
 create mode 120000 srcpkgs/libavfilter4
 create mode 120000 srcpkgs/libavformat4
 create mode 120000 srcpkgs/libavresample4
 create mode 120000 srcpkgs/libavutil4
 create mode 120000 srcpkgs/libpostproc4
 create mode 120000 srcpkgs/libswresample4
 create mode 120000 srcpkgs/libswscale4

diff --git a/srcpkgs/ffmpeg4-devel b/srcpkgs/ffmpeg4-devel
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/ffmpeg4-devel
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/ffmpeg4/files/altivec.patch b/srcpkgs/ffmpeg4/files/altivec.patch
new file mode 100644
index 0000000000000..9c57200463320
--- /dev/null
+++ b/srcpkgs/ffmpeg4/files/altivec.patch
@@ -0,0 +1,60 @@
+revert some altivec specific change on all ppc* except ppc64le*
+
+q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
+conditionally, for ppc* but not ppc64le* (the new code is valid for
+POWER8 VSX which LE targets as a baseline but not BE)"
+
+
+This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
+---
+ libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
+ 1 file changed, 20 insertions(+), 4 deletions(-)
+
+diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
+index 536545293d..c1e2852adb 100644
+--- a/libswscale/ppc/yuv2rgb_altivec.c
++++ b/libswscale/ppc/yuv2rgb_altivec.c
+@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+     vector signed short R1, G1, B1;                                           \
+     vector unsigned char R, G, B;                                             \
+                                                                               \
++    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
++    vector unsigned char align_perm;                                          \
++                                                                              \
+     vector signed short lCY       = c->CY;                                    \
+     vector signed short lOY       = c->OY;                                    \
+     vector signed short lCRV      = c->CRV;                                   \
+@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
+                                                                               \
+         for (j = 0; j < w / 16; j++) {                                        \
+-            y0 = vec_xl(0, y1i);                                              \
++            y1ivP = (const vector unsigned char *) y1i;                       \
++            y2ivP = (const vector unsigned char *) y2i;                       \
++            uivP  = (const vector unsigned char *) ui;                        \
++            vivP  = (const vector unsigned char *) vi;                        \
++                                                                              \
++            align_perm = vec_lvsl(0, y1i);                                    \
++            y0 = (vector unsigned char)                                       \
++                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
+                                                                               \
+-            y1 = vec_xl(0, y2i);                                              \
++            align_perm = vec_lvsl(0, y2i);                                    \
++            y1 = (vector unsigned char)                                       \
++                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
+                                                                               \
+-            u = (vector signed char) vec_xl(0, ui);                           \
++            align_perm = vec_lvsl(0, ui);                                     \
++            u = (vector signed char)                                          \
++                    vec_perm(uivP[0], uivP[1], align_perm);                   \
+                                                                               \
+-            v = (vector signed char) vec_xl(0, vi);                           \
++            align_perm = vec_lvsl(0, vi);                                     \
++            v = (vector signed char)                                          \
++                    vec_perm(vivP[0], vivP[1], align_perm);                   \
+                                                                               \
+             u = (vector signed char)                                          \
+                     vec_sub(u,                                                \
+-- 
+2.27.0
+
diff --git a/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
new file mode 100644
index 0000000000000..9a55178c74f0f
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
@@ -0,0 +1,18 @@
+--- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
++++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
+@@ -39,6 +39,15 @@
+ #endif
+ #include <fenv.h>
+ 
++#if (FE_ALL_EXCEPT == 0)
++/* E.g. ARM soft float does not define these */
++#define FE_INVALID    0
++#define FE_DIVBYZERO  0
++#define FE_OVERFLOW   0
++#define FE_UNDERFLOW  0
++#define FE_INEXACT    0
++#endif
++
+ #if CONFIG_LIBFONTCONFIG
+ #include <fontconfig/fontconfig.h>
+ #endif
diff --git a/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
new file mode 100644
index 0000000000000..aa948f7a8a2df
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
@@ -0,0 +1,40 @@
+#==================================================================================================
+# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
+# From: Christopher Degawa <christopher.degawa@intel.com>
+# Date: Thu, 20 Oct 2022 22:55:27 -0500
+# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
+#
+# compressed_ten_bit_format has been deprecated upstream and has no effect
+# and can be removed. Plus, technically it was never used in the first place
+# since it would require the app (ffmpeg) to set it and do additional
+# processing of the input frames.
+#
+# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
+#
+# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
+#==================================================================================================
+--- a/libavcodec/libsvtav1.c
++++ b/libavcodec/libsvtav1.c
+@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
+ 
+ static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
+ {
+-    const int    pack_mode_10bit =
+-        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
+-    const size_t luma_size_8bit  =
+-        config->source_width * config->source_height * (1 << pack_mode_10bit);
+-    const size_t luma_size_10bit =
+-        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
++    const size_t luma_size = config->source_width * config->source_height *
++        (config->encoder_bit_depth > 8 ? 2 : 1);
+ 
+     EbSvtIOFormat *in_data;
+ 
+-    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
++    svt_enc->raw_size = luma_size * 3 / 2;
+ 
+     // allocate buffer for in and out
+     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
+-- 
+GitLab
+
diff --git a/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
new file mode 100644
index 0000000000000..00e3f68a415b8
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
@@ -0,0 +1,28 @@
+From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
+From: Rainer Hochecker <fernetmenta@online.de>
+Date: Sat, 26 Jan 2019 19:48:35 +0100
+Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
+
+This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
+It was hit frequently when watching h264 channels received via DVB-X.
+Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
+---
+ libavcodec/vaapi_h264.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
+index 5854587a255..f12fdc457a4 100644
+--- a/libavcodec/vaapi_h264.c
++++ b/libavcodec/vaapi_h264.c
+@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
+     H264SliceContext *sl = &h->slice_ctx[0];
+     int ret;
+ 
++    if (pic->nb_slices == 0) {
++        ret = AVERROR_INVALIDDATA;
++        goto finish;
++    }
++
+     ret = ff_vaapi_decode_issue(avctx, pic);
+     if (ret < 0)
+         goto finish;
diff --git a/srcpkgs/ffmpeg4/template b/srcpkgs/ffmpeg4/template
new file mode 100644
index 0000000000000..9ba14bdb8ddf3
--- /dev/null
+++ b/srcpkgs/ffmpeg4/template
@@ -0,0 +1,234 @@
+# Template file for 'ffmpeg4'
+# audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
+pkgname=ffmpeg4
+version=4.4.4
+revision=1
+short_desc="Decoding, encoding and streaming software - ffmpeg4 libraries only"
+maintainer="Orphaned <orphan@voidlinux.org>"
+license="GPL-3.0-or-later"
+homepage="https://www.ffmpeg.org"
+changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
+distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
+checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+
+hostmakedepends="pkg-config perl"
+makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
+ libXext-devel libXvMC-devel libxcb-devel lame-devel libtheora-devel
+ libvorbis-devel x264-devel xvidcore-devel jack-devel SDL2-devel
+ libcdio-paranoia-devel librtmp-devel libmodplug-devel gnutls-devel
+ speex-devel celt-devel harfbuzz-devel libass-devel opus-devel ocl-icd-devel
+ libbs2b-devel libvidstab-devel vmaf-devel $(vopt_if pulseaudio pulseaudio-devel)
+ $(vopt_if vaapi libva-devel) $(vopt_if vdpau libvdpau-devel)
+ $(vopt_if x265 x265-devel) $(vopt_if v4l2 v4l-utils-devel)
+ $(vopt_if fdk_aac fdk-aac-devel) $(vopt_if vpx libvpx-devel)
+ $(vopt_if aom libaom-devel) $(vopt_if sndio sndio-devel)
+ $(vopt_if dav1d libdav1d-devel) $(vopt_if zimg zimg-devel)
+ $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
+ $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
+ $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
+
+build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
+
+desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
+desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
+desc_option_sofa="Enable support for AES SOFA"
+desc_option_webp="Enable support for WebP"
+
+case "$XBPS_TARGET_MACHINE" in
+	i686*|x86_64*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau nvenc nvdec"
+			;;
+	ppc64*) build_options_default+=" vaapi vdpau";;
+	mips*) CFLAGS="-mnan=legacy";;
+esac
+
+if [ "$XBPS_TARGET_WORDSIZE" != "32" ]; then
+	build_options_default+=" svtav1"
+fi
+
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+fi
+
+_apply_patch() {
+	local args="$1" pname="$(basename $2)"
+
+	if [ ! -f ".${pname}_done" ]; then
+		patch -N $args -i $2
+		touch .${pname}_done
+	fi
+}
+
+post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64le*) ;;
+		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
+	esac
+
+	vsed -i libavfilter/vf_libvmaf.c -e 's!/usr/local/share/model/\(vmaf_v0.6.1\).pkl!/usr/share/vmaf/\1.json!'
+}
+
+do_configure() {
+	# Fix gcc on x86_64-musl only
+	if [ "$XBPS_TARGET_MACHINE" = "x86_64-musl" ]; then
+		vsed -i configure -e "s;_cflags_speed='-O3';_cflags_speed='-O2';"
+	fi
+
+	if [ "$CROSS_BUILD" ]; then
+		case "$XBPS_TARGET_MACHINE" in
+			arm*) _arch="arm";;
+			aarch64*) _arch="aarch64";;
+			mips*) _arch="mips";;
+			ppc64*) _arch="ppc64";;
+			ppc*) _arch="ppc";;
+			*) _arch="${XBPS_TARGET_MACHINE%%-musl}";;
+		esac
+
+		_args+=" --enable-cross-compile
+			--sysroot=$XBPS_CROSS_BASE
+			--cross-prefix=${XBPS_CROSS_TRIPLET}-
+			--target-os=linux --arch=${_arch}"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc|ppc-musl) _args+=" --disable-altivec";;
+	esac
+
+	if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+		_args+=" --extra-libs=-latomic"
+	fi
+
+	./configure --prefix=/usr --disable-debug --enable-gpl --enable-gnutls \
+		--disable-stripping \
+		--enable-libcdio --enable-version3 --enable-runtime-cpudetect \
+		--enable-libmp3lame --enable-libvorbis --enable-libxvid \
+		--enable-libx264 $(vopt_enable vpx libvpx) --enable-libtheora \
+		--enable-shared --enable-static --enable-libxcb \
+		$(vopt_enable pulseaudio libpulse) --enable-libfreetype --enable-libmodplug \
+		--enable-libspeex --enable-libcelt --enable-libass \
+		--enable-libopus --enable-librtmp --enable-libjack \
+		$(vopt_if fdk_aac '--enable-nonfree --enable-libfdk-aac') \
+		--disable-libopencore_amrnb --disable-libopencore_amrwb \
+		--disable-libopenjpeg \
+		--enable-postproc --enable-opencl ${_args} --enable-libvmaf ${_args} \
+		$(vopt_enable x265 libx265) \
+		$(vopt_enable v4l2 libv4l2) \
+		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
+		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		$(vopt_enable dav1d libdav1d) \
+		$(vopt_enable zimg libzimg) \
+		$(vopt_enable webp libwebp) \
+		$(vopt_enable sofa libmysofa) \
+		$(vopt_enable vulkan) \
+		$(vopt_enable drm libdrm) \
+		$(vopt_enable svtav1 libsvtav1) \
+		$(vopt_enable srt libsrt) \
+		$(vopt_enable rist librist) \
+		$(vopt_if nvenc '--enable-nvenc') \
+		$(vopt_if nvdec '--enable-nvdec')
+}
+
+do_build() {
+	make ${makejobs}
+	make doc/ff{mpeg,play}.1
+}
+
+do_install() {
+	make DESTDIR=${DESTDIR} install install-man
+	rm -rf ${DESTDIR}/usr/bin
+}
+
+libavcodec4_package() {
+	short_desc="FFmpeg codec library"
+	pkg_install() {
+		vmove "usr/lib/libavcodec.so.*"
+	}
+}
+
+libavdevice4_package() {
+	short_desc="FFmpeg device handling library"
+	pkg_install() {
+		vmove "usr/lib/libavdevice.so.*"
+	}
+}
+
+libavresample4_package() {
+	short_desc="FFmpeg audio resampling library"
+	pkg_install() {
+		vmove "usr/lib/libavresample.so.*"
+	}
+}
+
+libavformat4_package() {
+	short_desc="FFmpeg file format library"
+	pkg_install() {
+		vmove "usr/lib/libavformat.so.*"
+	}
+}
+
+libavutil4_package() {
+	short_desc="FFmpeg utility library"
+	pkg_install() {
+		vmove "usr/lib/libavutil.so.*"
+	}
+}
+
+libavfilter4_package() {
+	short_desc="FFmpeg audio/video filter library"
+	pkg_install() {
+		vmove "usr/lib/libavfilter.so.*"
+	}
+}
+
+libpostproc4_package() {
+	short_desc="FFmpeg video postprocessing library"
+	pkg_install() {
+		vmove "usr/lib/libpostproc.so.*"
+	}
+}
+
+libswscale4_package() {
+	short_desc="FFmpeg video scaling library"
+	pkg_install() {
+		vmove "usr/lib/libswscale.so.*"
+	}
+}
+
+libswresample4_package() {
+	short_desc="FFmpeg video resampling library"
+	pkg_install() {
+		vmove "usr/lib/libswresample.so.*"
+	}
+}
+
+ffmpeg4-devel_package() {
+	depends="
+		libavcodec4>=${version}_${revision}
+		libavdevice4>=${version}_${revision}
+		libavformat4>=${version}_${revision}
+		libavutil4>=${version}_${revision}
+		libavfilter4>=${version}_${revision}
+		libpostproc4>=${version}_${revision}
+		libswscale4>=${version}_${revision}
+		libswresample4>=${version}_${revision}
+		libavresample4>=${version}_${revision}"
+	short_desc+=" - development files"
+	conflicts="ffmpeg-devel"
+	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
+		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
+		nostrip_files="/usr/lib/libavfilter.a"
+	fi
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.a"
+		vmove "usr/lib/*.so"
+		vmove usr/share/ffmpeg/examples
+		vmove usr/share/man/man3
+	}
+}
diff --git a/srcpkgs/libavcodec4 b/srcpkgs/libavcodec4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavcodec4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavdevice4 b/srcpkgs/libavdevice4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavdevice4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavfilter4 b/srcpkgs/libavfilter4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavfilter4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavformat4 b/srcpkgs/libavformat4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavformat4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavresample4 b/srcpkgs/libavresample4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavutil4 b/srcpkgs/libavutil4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavutil4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libpostproc4 b/srcpkgs/libpostproc4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libpostproc4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswresample4 b/srcpkgs/libswresample4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libswresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswscale4 b/srcpkgs/libswscale4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libswscale4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file

From a4d34d5a91f1918a9f832fbe7f9d67d6d308d744 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:04 -0400
Subject: [PATCH 005/113] opencv: update to 4.7.0.

---
 common/shlibs           | 104 ++++++++++++++++++++--------------------
 srcpkgs/opencv/template |   8 ++--
 2 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index 734b2601c3cd5..a7e9adacbf5db 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2085,58 +2085,58 @@ libcapstone.so.5 capstone-5.0.1_1
 libhavege.so.2 libhaveged-1.9.11_1
 libnih.so.1 libnih-1.0.3_1
 libnih-dbus.so.1 libnih-1.0.3_1
-libopencv_quality.so.406 libopencv-4.6.0_1
-libopencv_reg.so.406 libopencv-4.6.0_1
-libopencv_surface_matching.so.406 libopencv-4.6.0_1
-libopencv_xphoto.so.406 libopencv-4.6.0_1
-libopencv_freetype.so.406 libopencv-4.6.0_1
-libopencv_fuzzy.so.406 libopencv-4.6.0_1
-libopencv_hfs.so.406 libopencv-4.6.0_1
-libopencv_img_hash.so.406 libopencv-4.6.0_1
-libopencv_line_descriptor.so.406 libopencv-4.6.0_1
-libopencv_saliency.so.406 libopencv-4.6.0_1
-libopencv_structured_light.so.406 libopencv-4.6.0_1
-libopencv_aruco.so.406 libopencv-4.6.0_1
-libopencv_bgsegm.so.406 libopencv-4.6.0_1
-libopencv_bioinspired.so.406 libopencv-4.6.0_1
-libopencv_ccalib.so.406 libopencv-4.6.0_1
-libopencv_face.so.406 libopencv-4.6.0_1
-libopencv_tracking.so.406 libopencv-4.6.0_1
-libopencv_xfeatures2d.so.406 libopencv-4.6.0_1
-libopencv_optflow.so.406 libopencv-4.6.0_1
-libopencv_ximgproc.so.406 libopencv-4.6.0_1
-libopencv_plot.so.406 libopencv-4.6.0_1
-libopencv_text.so.406 libopencv-4.6.0_1
-libopencv_ml.so.406 libopencv-4.6.0_1
-libopencv_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn.so.406 libopencv-4.6.0_1
-libopencv_shape.so.406 libopencv-4.6.0_1
-libopencv_stitching.so.406 libopencv-4.6.0_1
-libopencv_photo.so.406 libopencv-4.6.0_1
-libopencv_video.so.406 libopencv-4.6.0_1
-libopencv_calib3d.so.406 libopencv-4.6.0_1
-libopencv_features2d.so.406 libopencv-4.6.0_1
-libopencv_flann.so.406 libopencv-4.6.0_1
-libopencv_highgui.so.406 libopencv-4.6.0_1
-libopencv_videoio.so.406 libopencv-4.6.0_1
-libopencv_imgcodecs.so.406 libopencv-4.6.0_1
-libopencv_imgproc.so.406 libopencv-4.6.0_1
-libopencv_core.so.406 libopencv-4.6.0_1
-libopencv_superres.so.406 libopencv-4.6.0_1
-libopencv_videostab.so.406 libopencv-4.6.0_1
-libopencv_gapi.so.406 libopencv-4.6.0_1
-libopencv_xobjdetect.so.406 libopencv-4.6.0_1
-libopencv_datasets.so.406 libopencv-4.6.0_1
-libopencv_dnn_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn_superres.so.406 libopencv-4.6.0_1
-libopencv_dpm.so.406 libopencv-4.6.0_1
-libopencv_phase_unwrapping.so.406 libopencv-4.6.0_1
-libopencv_stereo.so.406 libopencv-4.6.0_1
-libopencv_rapid.so.406 libopencv-4.6.0_1
-libopencv_intensity_transform.so.406 libopencv-4.6.0_1
-libopencv_alphamat.so.406 libopencv-4.6.0_1
-libopencv_barcode.so.406 libopencv-4.6.0_1
-libopencv_mcc.so.406 libopencv-4.6.0_1
+libopencv_quality.so.407 libopencv-4.7.0_1
+libopencv_reg.so.407 libopencv-4.7.0_1
+libopencv_surface_matching.so.407 libopencv-4.7.0_1
+libopencv_xphoto.so.407 libopencv-4.7.0_1
+libopencv_freetype.so.407 libopencv-4.7.0_1
+libopencv_fuzzy.so.407 libopencv-4.7.0_1
+libopencv_hfs.so.407 libopencv-4.7.0_1
+libopencv_img_hash.so.407 libopencv-4.7.0_1
+libopencv_line_descriptor.so.407 libopencv-4.7.0_1
+libopencv_saliency.so.407 libopencv-4.7.0_1
+libopencv_structured_light.so.407 libopencv-4.7.0_1
+libopencv_aruco.so.407 libopencv-4.7.0_1
+libopencv_bgsegm.so.407 libopencv-4.7.0_1
+libopencv_bioinspired.so.407 libopencv-4.7.0_1
+libopencv_ccalib.so.407 libopencv-4.7.0_1
+libopencv_face.so.407 libopencv-4.7.0_1
+libopencv_tracking.so.407 libopencv-4.7.0_1
+libopencv_xfeatures2d.so.407 libopencv-4.7.0_1
+libopencv_optflow.so.407 libopencv-4.7.0_1
+libopencv_ximgproc.so.407 libopencv-4.7.0_1
+libopencv_plot.so.407 libopencv-4.7.0_1
+libopencv_text.so.407 libopencv-4.7.0_1
+libopencv_ml.so.407 libopencv-4.7.0_1
+libopencv_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn.so.407 libopencv-4.7.0_1
+libopencv_shape.so.407 libopencv-4.7.0_1
+libopencv_stitching.so.407 libopencv-4.7.0_1
+libopencv_photo.so.407 libopencv-4.7.0_1
+libopencv_video.so.407 libopencv-4.7.0_1
+libopencv_calib3d.so.407 libopencv-4.7.0_1
+libopencv_features2d.so.407 libopencv-4.7.0_1
+libopencv_flann.so.407 libopencv-4.7.0_1
+libopencv_highgui.so.407 libopencv-4.7.0_1
+libopencv_videoio.so.407 libopencv-4.7.0_1
+libopencv_imgcodecs.so.407 libopencv-4.7.0_1
+libopencv_imgproc.so.407 libopencv-4.7.0_1
+libopencv_core.so.407 libopencv-4.7.0_1
+libopencv_superres.so.407 libopencv-4.7.0_1
+libopencv_videostab.so.407 libopencv-4.7.0_1
+libopencv_gapi.so.407 libopencv-4.7.0_1
+libopencv_xobjdetect.so.407 libopencv-4.7.0_1
+libopencv_datasets.so.407 libopencv-4.7.0_1
+libopencv_dnn_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn_superres.so.407 libopencv-4.7.0_1
+libopencv_dpm.so.407 libopencv-4.7.0_1
+libopencv_phase_unwrapping.so.407 libopencv-4.7.0_1
+libopencv_stereo.so.407 libopencv-4.7.0_1
+libopencv_rapid.so.407 libopencv-4.7.0_1
+libopencv_intensity_transform.so.407 libopencv-4.7.0_1
+libopencv_alphamat.so.407 libopencv-4.7.0_1
+libopencv_barcode.so.407 libopencv-4.7.0_1
+libopencv_mcc.so.407 libopencv-4.7.0_1
 libuniconf.so.4.6 wvstreams-4.6.1_20
 libwvbase.so.4.6 wvstreams-4.6.1_20
 libwvutils.so.4.6 wvstreams-4.6.1_20
diff --git a/srcpkgs/opencv/template b/srcpkgs/opencv/template
index aea4bfc3a265c..ce94de9424d18 100644
--- a/srcpkgs/opencv/template
+++ b/srcpkgs/opencv/template
@@ -1,7 +1,7 @@
 # Template file for 'opencv'
 pkgname=opencv
-version=4.6.0
-revision=6
+version=4.7.0
+revision=1
 create_wrksrc=yes
 build_wrksrc=${pkgname}-${version}
 build_style=cmake
@@ -24,8 +24,8 @@ homepage="https://opencv.org"
 changelog="https://github.com/opencv/opencv/wiki/ChangeLog"
 distfiles="https://github.com/opencv/opencv/archive/${version}.tar.gz
  https://github.com/opencv/opencv_contrib/archive/${version}.tar.gz>contrib.tar.gz"
-checksum="1ec1cba65f9f20fe5a41fda1586e01c70ea0c9a6d7b67c9e13edf0cfe2239277
- 1777d5fd2b59029cf537e5fd6f8aa68d707075822f90bde683fcde086f85f7a7"
+checksum="8df0079cdbe179748a18d44731af62a245a45ebf5085223dc03133954c662973
+ 42df840cf9055e59d0e22c249cfb19f04743e1bdad113d31b1573d3934d62584"
 patch_args="-Np1 -d ${build_wrksrc}"
 # tests hang indenfinitely, even with test data included
 make_check=no

From 04cb2aa6f35651e5fd50480403a5d4a2536ac230 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 006/113] actiona: revbump for opencv-4.7.0

---
 srcpkgs/actiona/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/actiona/template b/srcpkgs/actiona/template
index cf5f0b7a2ae61..0d899311e6df7 100644
--- a/srcpkgs/actiona/template
+++ b/srcpkgs/actiona/template
@@ -1,7 +1,7 @@
 # Template file for 'actiona'
 pkgname=actiona
 version=3.10.1
-revision=2
+revision=3
 build_style=qmake
 configure_args="PKGCONFIG_OPENCV=opencv4"
 hostmakedepends="pkg-config qt5-plugin-mysql qt5-qmake qt5-host-tools"

From 502513e28a0d30fc1d59efdf548ff2ca54b01d09 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 007/113] retroshare: revbump for opencv-4.7.0

---
 srcpkgs/retroshare/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroshare/template b/srcpkgs/retroshare/template
index bb17569277a7f..49e2c1cbe8a53 100644
--- a/srcpkgs/retroshare/template
+++ b/srcpkgs/retroshare/template
@@ -1,7 +1,7 @@
 # Template file for 'retroshare'
 pkgname=retroshare
 version=0.6.6
-revision=3
+revision=4
 build_style=qmake
 #XXX broadcast feature requires an ancient udp-discovery-cpp which either needs
 # to be fetched+patched (FTBFS) here or packaged :/

From a7215f7b52f9679c6c84e69078bad77580f513b4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 008/113] waifu2x-converter-cpp: revbump for opencv-4.7.0

---
 srcpkgs/waifu2x-converter-cpp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waifu2x-converter-cpp/template b/srcpkgs/waifu2x-converter-cpp/template
index 361b8a23b9497..c5ac17eb54ea4 100644
--- a/srcpkgs/waifu2x-converter-cpp/template
+++ b/srcpkgs/waifu2x-converter-cpp/template
@@ -1,7 +1,7 @@
 # Template file for 'waifu2x-converter-cpp'
 pkgname=waifu2x-converter-cpp
 version=5.2.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DINSTALL_MODELS=ON"
 hostmakedepends="pkg-config"

From 4522dfd77d5b07b738d729e0d4edc56eb7a2848e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:38 -0400
Subject: [PATCH 009/113] vlc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/vlc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vlc/template b/srcpkgs/vlc/template
index abc5eeba01564..5f291b1b81e23 100644
--- a/srcpkgs/vlc/template
+++ b/srcpkgs/vlc/template
@@ -25,7 +25,7 @@ lib32disabled=yes
 hostmakedepends="automake libtool pkg-config flex gettext libgcrypt-devel
  live555-devel gettext-devel $(vopt_if lua lua52) $(vopt_if chromecast protobuf)"
 makedepends="
- avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg-devel freefont-ttf
+ avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg4-devel freefont-ttf
  gnutls-devel jack-devel liba52-devel libass-devel libbluray-devel
  libcdio-devel libdca-devel libdvbpsi-devel libdvdnav-devel libmad-devel
  libmatroska-devel libmodplug-devel libmpcdec-devel libmpeg2-devel

From 39ae55c2ddc3ecd5db2a14c6c8a1b2ab4b9316b7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:55 -0400
Subject: [PATCH 010/113] osg: revbump for ffmpeg4-4.4.3

---
 srcpkgs/osg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/osg/template b/srcpkgs/osg/template
index a9ebbd287933b..755793f7e11bf 100644
--- a/srcpkgs/osg/template
+++ b/srcpkgs/osg/template
@@ -8,7 +8,7 @@ build_helper="qemu"
 configure_args="-DLIB_POSTFIX="
 hostmakedepends="pkg-config xrandr"
 makedepends="MesaLib-devel gtkglext-devel libcurl-devel giflib-devel librsvg-devel
- jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg-devel xine-lib-devel
+ jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg4-devel xine-lib-devel
  SDL2-devel gst-plugins-base1-devel
  $(vopt_if openexr libopenexr-devel)
  $(vopt_if poppler poppler-glib-devel)

From 451e99ba90d945d369d111e47d4b4f524f653571 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:13 -0400
Subject: [PATCH 011/113] xine-lib: revbump for ffmpeg4-4.4.3

---
 srcpkgs/xine-lib/template | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/xine-lib/template b/srcpkgs/xine-lib/template
index 3be4d08eac77a..ed6194c17d11e 100644
--- a/srcpkgs/xine-lib/template
+++ b/srcpkgs/xine-lib/template
@@ -1,14 +1,14 @@
 # Template file for 'xine-lib'
 pkgname=xine-lib
-version=1.2.12
-revision=3
+version=1.2.13
+revision=1
 build_style=gnu-configure
 configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
  --disable-oss"
 hostmakedepends="automake gettext-devel libtool pkg-config perl"
 makedepends="
  zlib-devel alsa-lib-devel libxcb-devel libSM-devel libXext-devel libXv-devel
- libXvMC-devel liba52-devel libmad-devel ffmpeg-devel pulseaudio-devel
+ libXvMC-devel liba52-devel libmad-devel ffmpeg4-devel pulseaudio-devel
  jack-devel samba-devel libflac-devel libmodplug-devel libmpcdec-devel
  speex-devel libtheora-devel libvorbis-devel libdca-devel faad2-devel
  libcdio-devel libbluray-devel aalib-devel libcaca-devel libXinerama-devel
@@ -19,7 +19,7 @@ license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="http://www.xine-project.org"
 changelog="https://sourceforge.net/projects/xine/files/xine-lib/${version}/README.txt/view"
 distfiles="${SOURCEFORGE_SITE}/xine/${pkgname}-${version}.tar.xz"
-checksum=d606270468e1540c2a89c0d7f5fdf11e17ecc0c2698cc0bcb1065ff26abee098
+checksum=5f10d6d718a4a51c17ed1b32b031d4f9b80b061e8276535b2be31e5ac4b75e6f
 
 case "$XBPS_TARGET_MACHINE" in
 	i686-musl)

From aca5e490ec1a6fe9251c0d9a5d9d52b93523a0e0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 012/113] arcan: revbump for ffmpeg-6.0

---
 srcpkgs/arcan/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/arcan/template b/srcpkgs/arcan/template
index efd0afe10576d..b91e6900d42a1 100644
--- a/srcpkgs/arcan/template
+++ b/srcpkgs/arcan/template
@@ -2,7 +2,7 @@
 # !! keep synced with: acfgfs aclip aloadimage
 pkgname=arcan
 version=0.6.2.1
-revision=1
+revision=2
 create_wrksrc=yes
 build_wrksrc=arcan/src
 build_style=cmake

From cbe844f450b7027f46763d5d4891712e86d2ab8b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 013/113] attract: revbump for ffmpeg4-4.4.3

---
 srcpkgs/attract/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/attract/template b/srcpkgs/attract/template
index 24017d2bacc24..e760bf0d18aec 100644
--- a/srcpkgs/attract/template
+++ b/srcpkgs/attract/template
@@ -6,7 +6,7 @@ build_style=gnu-makefile
 make_build_args="VERBOSE=1"
 make_use_env=yes
 hostmakedepends="pkg-config"
-makedepends="SFML-devel ffmpeg-devel fontconfig-devel glu-devel libarchive-devel
+makedepends="SFML-devel ffmpeg4-devel fontconfig-devel glu-devel libarchive-devel
  libcurl-devel libjpeg-turbo-devel xine-lib rapidjson libXrandr-devel"
 depends="git"
 short_desc="Attract-Mode is a graphical frontend for emulators"

From 1b84e00cc2fe484393a9a900d7f0857298438bb5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 014/113] aubio: revbump for ffmpeg-6.0

---
 srcpkgs/aubio/patches/ffmpeg5.patch | 25 +++++++++++++++++++++++++
 srcpkgs/aubio/template              |  2 +-
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/aubio/patches/ffmpeg5.patch

diff --git a/srcpkgs/aubio/patches/ffmpeg5.patch b/srcpkgs/aubio/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..aace41a6e6d9a
--- /dev/null
+++ b/srcpkgs/aubio/patches/ffmpeg5.patch
@@ -0,0 +1,25 @@
+From 8a05420e5dd8c7b8b2447f82dc919765876511b3 Mon Sep 17 00:00:00 2001
+From: Paul Brossier <piem@piem.org>
+Date: Tue, 25 Jan 2022 18:30:27 +0100
+Subject: [PATCH] [source_avcodec] define FF_API_LAVF_AVCTX for libavcodec >
+ 59, thx @berolinux (closes gh-353)
+
+---
+ src/io/source_avcodec.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/io/source_avcodec.c b/src/io/source_avcodec.c
+index e0ae93b5..1421bd9a 100644
+--- a/src/io/source_avcodec.c
++++ b/src/io/source_avcodec.c
+@@ -68,6 +68,10 @@
+ #define AUBIO_AVCODEC_MAX_BUFFER_SIZE AV_INPUT_BUFFER_MIN_SIZE
+ #endif
+ 
++#if LIBAVCODEC_VERSION_MAJOR >= 59
++#define FF_API_LAVF_AVCTX 1
++#endif
++
+ struct _aubio_source_avcodec_t {
+   uint_t hop_size;
+   uint_t samplerate;
diff --git a/srcpkgs/aubio/template b/srcpkgs/aubio/template
index ad1c4b2569917..7d875cc02541a 100644
--- a/srcpkgs/aubio/template
+++ b/srcpkgs/aubio/template
@@ -1,7 +1,7 @@
 # Template file for 'aubio'
 pkgname=aubio
 version=0.4.9
-revision=1
+revision=2
 build_style=waf3
 # XXX lash, pure and swig support.
 hostmakedepends="pkg-config txt2man"

From 9b5ba88f5538b102ebc420180713aa73070ddcc8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 015/113] audacious-plugins: revbump for ffmpeg-6.0

---
 .../audacious-plugins/patches/ffmpeg5.patch   | 43 +++++++++++++++++++
 srcpkgs/audacious-plugins/template            |  2 +-
 2 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/audacious-plugins/patches/ffmpeg5.patch

diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg5.patch b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..4e5e34099d71c
--- /dev/null
+++ b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
@@ -0,0 +1,43 @@
+commit 298aa371c56c2f52c25a33d9bdec4918b11cebdc
+Author: tibequadorian <tibequadorian@posteo.de>
+Date:   Sat Mar 19 18:40:12 2022 +0100
+
+    audacious-plugins: rebuild against ffmpeg-5.0
+
+diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+new file mode 100644
+index 0000000000..617c11215b
+--- /dev/null
++++ b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+@@ -0,0 +1,31 @@
++From f60beb400eeb1e4778bbfd738bc4a4ccef3de539 Mon Sep 17 00:00:00 2001
++From: John Lindgren <john@jlindgren.net>
++Date: Sat, 5 Mar 2022 12:05:34 -0500
++Subject: [PATCH] Fix build with FFmpeg 5.0
++
++---
++ src/ffaudio/ffaudio-core.cc | 4 ++--
++ 1 file changed, 2 insertions(+), 2 deletions(-)
++
++diff --git a/src/ffaudio/ffaudio-core.cc b/src/ffaudio/ffaudio-core.cc
++index 16dc63e3a..a2b95fd6c 100644
++--- a/src/ffaudio/ffaudio-core.cc
+++++ b/src/ffaudio/ffaudio-core.cc
++@@ -274,7 +274,7 @@ static AVInputFormat * get_format_by_content (const char * name, VFSFile & file)
++         AVProbeData d = {name, buf, filled};
++         score = target;
++ 
++-        f = av_probe_input_format2 (& d, true, & score);
+++        f = (AVInputFormat *) av_probe_input_format2 (& d, true, & score);
++         if (f)
++             break;
++ 
++@@ -347,7 +347,7 @@ static bool find_codec (AVFormatContext * c, CodecInfo * cinfo)
++ #endif
++         if (stream && stream->codecpar && stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
++         {
++-            AVCodec * codec = avcodec_find_decoder (stream->codecpar->codec_id);
+++            AVCodec * codec = (AVCodec *) avcodec_find_decoder (stream->codecpar->codec_id);
++ 
++             if (codec)
++             {
diff --git a/srcpkgs/audacious-plugins/template b/srcpkgs/audacious-plugins/template
index 05e53a9adf78f..4b1968e03de78 100644
--- a/srcpkgs/audacious-plugins/template
+++ b/srcpkgs/audacious-plugins/template
@@ -2,7 +2,7 @@
 #Keep in sync with audacious!
 pkgname=audacious-plugins
 version=4.3.1
-revision=3
+revision=4
 build_style=meson
 configure_args="$(vopt_bool gtk3 gtk) $(vopt_bool gtk3)
  $(vopt_bool qt) $(vopt_bool qt qt6)"

From a1051fe50a7fe348ea3d59320b196b34fd9cf7c0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 016/113] audacity: revbump for ffmpeg4-4.4.3

---
 srcpkgs/audacity/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/audacity/template b/srcpkgs/audacity/template
index 7b838119ab261..fb15f782ac1f7 100644
--- a/srcpkgs/audacity/template
+++ b/srcpkgs/audacity/template
@@ -1,7 +1,7 @@
 # Template file for 'audacity'
 pkgname=audacity
 version=3.4.2
-revision=1
+revision=2
 build_style=cmake
 build_helper="cmake-wxWidgets-gtk3 qemu"
 configure_args="-Daudacity_use_ffmpeg=loaded -Daudacity_lib_preference=system
@@ -12,7 +12,7 @@ configure_args="-Daudacity_use_ffmpeg=loaded -Daudacity_lib_preference=system
  -Daudacity_has_updates_check=OFF -DAUDACITY_BUILD_LEVEL=2"
 hostmakedepends="pkg-config gettext python3"
 makedepends="wxWidgets-gtk3-devel gtk+3-devel expat-devel lame-devel
- libsoxr-devel portaudio-devel sqlite-devel ffmpeg-devel
+ libsoxr-devel portaudio-devel sqlite-devel ffmpeg4-devel
  libid3tag-devel libmad-devel vamp-plugin-sdk-devel libogg-devel
  libvorbis-devel libflac-devel lilv-devel lv2 serd-devel sord-devel
  sratom-devel suil-devel portmidi-devel soundtouch-devel twolame-devel

From a0ea1554626fb28bb069ba8d99497743f62d8cdf Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 017/113] avidemux: revbump for ffmpeg-6.0

---
 srcpkgs/avidemux/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/avidemux/template b/srcpkgs/avidemux/template
index 253a0243e2259..557285982d2b8 100644
--- a/srcpkgs/avidemux/template
+++ b/srcpkgs/avidemux/template
@@ -1,7 +1,7 @@
 # Template file for 'avidemux'
 pkgname=avidemux
 version=2.8.0
-revision=2
+revision=3
 # Can't be compiled for aarch64, arm* or mips*
 archs="x86_64* i686*"
 hostmakedepends="cmake pkg-config qt5-host-tools qt5-devel tar yasm"

From 518f106c5150ffb7e2f527939e9ace0319a6644c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 018/113] blender: revbump for ffmpeg-6.0

---
 srcpkgs/blender/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index 05fdbf8f747e2..093d6d2004e95 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -9,8 +9,8 @@ configure_args="-DWITH_INSTALL_PORTABLE=OFF -DWITH_PYTHON_INSTALL=OFF
  -DWITH_JACK=ON -DWITH_CODEC_FFMPEG=ON -DWITH_CODEC_SNDFILE=ON -DWITH_OPENMP=ON
  -DWITH_FFTW3=ON -DWITH_MOD_OCEANSIM=ON -DWITH_CYCLES_EMBREE=OFF -DWITH_OPENCOLORIO=ON
  -DWITH_IMAGE_OPENEXR=ON -DWITH_IMAGE_OPENJPEG=ON -DWITH_OPENSUBDIV=ON
- -DWITH_OPENCOLLADA=ON -DWITH_SYSTEM_GLEW=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
- -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_LIBDECOR=ON
+ -DWITH_OPENCOLLADA=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
+ -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_WAYLAND_LIBDECOR=ON
  -DWITH_BUILDINFO=OFF -DPYTHON_VERSION=${py3_ver} -DPYTHON_LIBPATH=/usr/lib
  -DPYTHON_LIBRARY=python${py3_ver}${py3_abiver} -DPYTHON_INCLUDE_DIRS=/${py3_inc}
  -DWITH_SYSTEM_LZO=ON -DWITH_SYSTEM_EIGEN3=ON -DWITH_SYSTEM_FREETYPE=ON"

From 80218dc3a97b346b15da1de3faf530bbe6a7867a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 019/113] cantata: revbump for ffmpeg-6.0

---
 srcpkgs/cantata/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cantata/template b/srcpkgs/cantata/template
index 4b417d80d5c2d..8a90aaa4c07a2 100644
--- a/srcpkgs/cantata/template
+++ b/srcpkgs/cantata/template
@@ -1,7 +1,7 @@
 # Template file for 'cantata'
 pkgname=cantata
 version=2.5.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools qt5-tools"
 makedepends="qt5-devel qt5-tools-devel qt5-svg-devel qt5-xmlpatterns-devel

From 3dc00c2774e66e3c79901115c9b9306d9f7a50d3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 020/113] ccextractor: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ccextractor/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/ccextractor/template b/srcpkgs/ccextractor/template
index 9abcd82852b27..6eccad5885af9 100644
--- a/srcpkgs/ccextractor/template
+++ b/srcpkgs/ccextractor/template
@@ -1,12 +1,12 @@
 # Template file for 'ccextractor'
 pkgname=ccextractor
 version=0.93
-revision=1
+revision=2
 build_wrksrc="linux"
 build_style=gnu-configure
 configure_args="--enable-ocr --enable-hardsubx"
 hostmakedepends="automake pkg-config"
-makedepends="leptonica-devel tesseract-ocr-devel ffmpeg-devel"
+makedepends="leptonica-devel tesseract-ocr-devel ffmpeg4-devel"
 short_desc="Extract subtitles from video streams"
 maintainer="newbluemoon <blaumolch@mailbox.org>"
 license="GPL-2.0-or-later"

From 3306b4ec53578120a526420a67795ed24341b63d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 021/113] chromaprint: revbump for ffmpeg-6.0

---
 srcpkgs/chromaprint/patches/ffmpeg5.patch | 569 ++++++++++++++++++++++
 srcpkgs/chromaprint/template              |   2 +-
 2 files changed, 570 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromaprint/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromaprint/patches/ffmpeg5.patch b/srcpkgs/chromaprint/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..a9fd307a23c8a
--- /dev/null
+++ b/srcpkgs/chromaprint/patches/ffmpeg5.patch
@@ -0,0 +1,569 @@
+From 8ccad6937177b1b92e40ab8f4447ea27bac009a7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= <lalinsky@gmail.com>
+Date: Fri, 4 Nov 2022 21:47:38 +0100
+Subject: [PATCH] Use FFmpeg 5.x (#120)
+
+* Use FFmpeg 5.1.2 for CI builds
+
+* Build on Ubuntu 20.04
+
+* Upgrade code to FFmpeg 5.x APIs
+
+* Only set FFmpeg include dirs if building tools
+
+* No longer needed
+
+* Use ubuntu 20.04
+---
+ .github/workflows/build.yml                   |   6 +-
+ CMakeLists.txt                                |  16 --
+ package/build.sh                              |   4 +-
+ src/audio/ffmpeg_audio_processor.h            |   2 -
+ src/audio/ffmpeg_audio_processor_avresample.h |  72 -------
+ src/audio/ffmpeg_audio_processor_swresample.h |  18 +-
+ src/audio/ffmpeg_audio_reader.h               | 197 +++++++++---------
+ tests/CMakeLists.txt                          |   6 +
+ 8 files changed, 122 insertions(+), 199 deletions(-)
+ delete mode 100644 src/audio/ffmpeg_audio_processor_avresample.h
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index f8d6a32..4da2405 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -84,9 +84,6 @@ find_package(FFmpeg)
+ if(FFMPEG_LIBRARIES)
+ 	cmake_push_check_state(RESET)
+ 	set(CMAKE_REQUIRED_LIBRARIES ${FFMPEG_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -lm)
+-	check_function_exists(av_packet_unref HAVE_AV_PACKET_UNREF)
+-	check_function_exists(av_frame_alloc HAVE_AV_FRAME_ALLOC)
+-	check_function_exists(av_frame_free HAVE_AV_FRAME_FREE)
+ 	cmake_pop_check_state()
+ endif()
+
+@@ -163,14 +160,11 @@ message(STATUS "Using ${FFT_LIB} for FFT calculations")
+ if(NOT AUDIO_PROCESSOR_LIB)
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+ 		set(AUDIO_PROCESSOR_LIB "swresample")
+-	elseif(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(AUDIO_PROCESSOR_LIB "avresample")
+ 	endif()
+ endif()
+
+ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE OFF)
+ 		set(USE_SWRESAMPLE ON)
+ 		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBSWRESAMPLE_LIBRARIES})
+ 		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBSWRESAMPLE_INCLUDE_DIRS})
+@@ -178,16 +172,6 @@ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+ 	endif()
+ 	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+-elseif(AUDIO_PROCESSOR_LIB STREQUAL "avresample")
+-	if(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE ON)
+-		set(USE_SWRESAMPLE OFF)
+-		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBAVRESAMPLE_LIBRARIES})
+-		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBAVRESAMPLE_INCLUDE_DIRS})
+-	else()
+-		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+-	endif()
+-	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+ else()
+ 	message(STATUS "Building without audio conversion support, please install FFmpeg with libswresample")
+ endif()
+diff --git a/package/build.sh b/package/build.sh
+index da631ae..b41d36e 100755
+--- a/package/build.sh
++++ b/package/build.sh
+@@ -7,8 +7,8 @@ set -eux
+
+ BASE_DIR=$(cd $(dirname $0)/.. && pwd)
+
+-FFMPEG_VERSION=4.4.1
+-FFMPEG_BUILD_TAG=v4.4.1-1
++FFMPEG_VERSION=5.1.2
++FFMPEG_BUILD_TAG=v${FFMPEG_VERSION}-1
+
+ TMP_BUILD_DIR=$BASE_DIR/$(mktemp -d build.XXXXXXXX)
+ trap 'rm -rf $TMP_BUILD_DIR' EXIT
+diff --git a/src/audio/ffmpeg_audio_processor.h b/src/audio/ffmpeg_audio_processor.h
+index 7628fc7..39f4f6d 100644
+--- a/src/audio/ffmpeg_audio_processor.h
++++ b/src/audio/ffmpeg_audio_processor.h
+@@ -10,8 +10,6 @@
+
+ #if defined(USE_SWRESAMPLE)
+ #include "audio/ffmpeg_audio_processor_swresample.h"
+-#elif defined(USE_AVRESAMPLE)
+-#include "audio/ffmpeg_audio_processor_avresample.h"
+ #else
+ #error "no audio processing library"
+ #endif
+diff --git a/src/audio/ffmpeg_audio_processor_avresample.h b/src/audio/ffmpeg_audio_processor_avresample.h
+deleted file mode 100644
+index bd85f92..0000000
+--- a/src/audio/ffmpeg_audio_processor_avresample.h
++++ /dev/null
+@@ -1,72 +0,0 @@
+-// Copyright (C) 2016  Lukas Lalinsky
+-// Distributed under the MIT license, see the LICENSE file for details.
+-
+-#ifndef CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-#define CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-
+-extern "C" {
+-#include <libavresample/avresample.h>
+-}
+-
+-namespace chromaprint {
+-
+-class FFmpegAudioProcessor {
+-public:
+-	FFmpegAudioProcessor() {
+-		m_resample_ctx = avresample_alloc_context();
+-	}
+-
+-	~FFmpegAudioProcessor() {
+-		avresample_free(&m_resample_ctx);
+-	}
+-
+-	void SetCompatibleMode() {
+-		av_opt_set_int(m_resample_ctx, "filter_size", 16, 0);
+-		av_opt_set_int(m_resample_ctx, "phase_shift", 8, 0);
+-		av_opt_set_int(m_resample_ctx, "linear_interp", 1, 0);
+-		av_opt_set_double(m_resample_ctx, "cutoff", 0.8, 0);
+-	}
+-
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "in_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_rate", sample_rate, 0);
+-	}
+-
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "out_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_rate, 0);
+-	}
+-
+-	int Init() {
+-		return avresample_open(m_resample_ctx);
+-	}
+-
+-	int Convert(uint8_t **out, int out_count, const uint8_t **in, int in_count) {
+-		return avresample_convert(m_resample_ctx, out, 0, out_count, (uint8_t **) in, 0, in_count);
+-	}
+-
+-	int Flush(uint8_t **out, int out_count) {
+-		return avresample_read(m_resample_ctx, out, out_count);
+-	}
+-
+-private:
+-	AVAudioResampleContext *m_resample_ctx = nullptr;
+-};
+-
+-}; // namespace chromaprint
+-
+-#endif
+diff --git a/src/audio/ffmpeg_audio_processor_swresample.h b/src/audio/ffmpeg_audio_processor_swresample.h
+index b86266b..b1d4bea 100644
+--- a/src/audio/ffmpeg_audio_processor_swresample.h
++++ b/src/audio/ffmpeg_audio_processor_swresample.h
+@@ -28,30 +28,28 @@ public:
+ 		av_opt_set_double(m_swr_ctx, "cutoff", 0.8, 0);
+ 	}
+
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "icl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "ich", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetInputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "in_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "isf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "in_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "isr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "in_sample_rate", sample_rate, 0);
+ 	}
+
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "ocl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "och", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetOutputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "out_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "osf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "out_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "osr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "out_sample_rate", sample_rate, 0);
+ 	}
+
+ 	int Init() {
+diff --git a/src/audio/ffmpeg_audio_reader.h b/src/audio/ffmpeg_audio_reader.h
+index 5550164..1c6b346 100644
+--- a/src/audio/ffmpeg_audio_reader.h
++++ b/src/audio/ffmpeg_audio_reader.h
+@@ -62,7 +62,7 @@ public:
+ 	bool Read(const int16_t **data, size_t *size);
+
+ 	bool IsOpen() const { return m_opened; }
+-	bool IsFinished() const { return m_finished && !m_got_frame; }
++	bool IsFinished() const { return !m_has_more_packets && !m_has_more_frames; }
+
+ 	std::string GetError() const { return m_error; }
+ 	int GetErrorCode() const { return m_error_code; }
+@@ -74,20 +74,19 @@ private:
+ 	uint8_t *m_convert_buffer[1] = { nullptr };
+ 	int m_convert_buffer_nb_samples = 0;
+
+-	AVInputFormat *m_input_fmt = nullptr;
++	const AVInputFormat *m_input_fmt = nullptr;
+ 	AVDictionary *m_input_opts = nullptr;
+
+ 	AVFormatContext *m_format_ctx = nullptr;
+ 	AVCodecContext *m_codec_ctx = nullptr;
+-	AVFrame *m_frame = nullptr;
+ 	int m_stream_index = -1;
+ 	std::string m_error;
+ 	int m_error_code = 0;
+-	bool m_finished = false;
+ 	bool m_opened = false;
+-	int m_got_frame = 0;
+-	AVPacket m_packet;
+-	AVPacket m_packet0;
++	bool m_has_more_packets = true;
++	bool m_has_more_frames = true;
++	AVPacket *m_packet = nullptr;
++	AVFrame *m_frame = nullptr;
+
+ 	int m_output_sample_rate = 0;
+ 	int m_output_channels = 0;
+@@ -98,19 +97,12 @@ private:
+
+ inline FFmpegAudioReader::FFmpegAudioReader() {
+ 	av_log_set_level(AV_LOG_QUIET);
+-
+-	av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
+ }
+
+ inline FFmpegAudioReader::~FFmpegAudioReader() {
+ 	Close();
+ 	av_dict_free(&m_input_opts);
+ 	av_freep(&m_convert_buffer[0]);
+-	av_packet_unref(&m_packet0);
+ }
+
+ inline bool FFmpegAudioReader::SetInputFormat(const char *name) {
+@@ -135,11 +127,10 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ 	Close();
+
+-    av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
++	m_packet = av_packet_alloc();
++	if (!m_packet) {
++		return false;
++	}
+
+ 	ret = avformat_open_input(&m_format_ctx, file_name.c_str(), m_input_fmt, &m_input_opts);
+ 	if (ret < 0) {
+@@ -153,26 +144,31 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		return false;
+ 	}
+
+-	AVCodec *codec;
++	const AVCodec *codec;
+ 	ret = av_find_best_stream(m_format_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &codec, 0);
+ 	if (ret < 0) {
+ 		SetError("Could not find any audio stream in the file", ret);
+ 		return false;
+ 	}
+ 	m_stream_index = ret;
++	auto stream = m_format_ctx->streams[m_stream_index];
+
+-	m_codec_ctx = m_format_ctx->streams[m_stream_index]->codec;
++	m_codec_ctx = avcodec_alloc_context3(codec);
+ 	m_codec_ctx->request_sample_fmt = AV_SAMPLE_FMT_S16;
+
++	ret = avcodec_parameters_to_context(m_codec_ctx, stream->codecpar);
++	if (ret < 0) {
++		SetError("Could not copy the stream parameters", ret);
++		return false;
++	}
++
+ 	ret = avcodec_open2(m_codec_ctx, codec, nullptr);
+ 	if (ret < 0) {
+ 		SetError("Could not open the codec", ret);
+ 		return false;
+ 	}
+
+-	if (!m_codec_ctx->channel_layout) {
+-		m_codec_ctx->channel_layout = av_get_default_channel_layout(m_codec_ctx->channels);
+-	}
++	av_dump_format(m_format_ctx, 0, "foo", 0);
+
+ 	m_frame = av_frame_alloc();
+ 	if (!m_frame) {
+@@ -183,19 +179,23 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		m_output_sample_rate = m_codec_ctx->sample_rate;
+ 	}
+
+-	if (!m_output_channels) {
+-		m_output_channels = m_codec_ctx->channels;
++	AVChannelLayout output_channel_layout;
++	if (m_output_channels) {
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
++	} else {
++		m_output_channels = m_codec_ctx->ch_layout.nb_channels;
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
+ 	}
+
+-	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
++	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->ch_layout.nb_channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
+ 		m_converter.reset(new FFmpegAudioProcessor());
+ 		m_converter->SetCompatibleMode();
+ 		m_converter->SetInputSampleFormat(m_codec_ctx->sample_fmt);
+ 		m_converter->SetInputSampleRate(m_codec_ctx->sample_rate);
+-		m_converter->SetInputChannelLayout(m_codec_ctx->channel_layout);
++		m_converter->SetInputChannelLayout(&(m_codec_ctx->ch_layout));
+ 		m_converter->SetOutputSampleFormat(AV_SAMPLE_FMT_S16);
+ 		m_converter->SetOutputSampleRate(m_output_sample_rate);
+-		m_converter->SetOutputChannelLayout(av_get_default_channel_layout(m_output_channels));
++		m_converter->SetOutputChannelLayout(&output_channel_layout);
+ 		auto ret = m_converter->Init();
+ 		if (ret != 0) {
+ 			SetError("Could not create an audio converter instance", ret);
+@@ -203,10 +203,11 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		}
+ 	}
+
++	av_channel_layout_uninit(&output_channel_layout);
++
+ 	m_opened = true;
+-	m_finished = false;
+-	m_got_frame = 0;
+-	m_nb_packets = 0;
++	m_has_more_packets = true;
++	m_has_more_frames = true;
+ 	m_decode_error = 0;
+
+ 	return true;
+@@ -214,6 +215,7 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ inline void FFmpegAudioReader::Close() {
+ 	av_frame_free(&m_frame);
++	av_packet_free(&m_packet);
+
+ 	m_stream_index = -1;
+
+@@ -252,91 +254,98 @@ inline bool FFmpegAudioReader::Read(const int16_t **data, size_t *size) {
+ 		return false;
+ 	}
+
++	*data = nullptr;
++	*size = 0;
++
+ 	int ret;
++	bool needs_packet = false;
+ 	while (true) {
+-		while (m_packet.size <= 0) {
+-			av_packet_unref(&m_packet0);
+-			av_init_packet(&m_packet);
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			ret = av_read_frame(m_format_ctx, &m_packet);
++		while (needs_packet && m_packet->size == 0) {
++			ret = av_read_frame(m_format_ctx, m_packet);
+ 			if (ret < 0) {
+ 				if (ret == AVERROR_EOF) {
+-					m_finished = true;
++					needs_packet = false;
++					m_has_more_packets = false;
+ 					break;
+-				} else {
++				}
++				SetError("Error reading from the audio source", ret);
++				return false;
++			}
++			if (m_packet->stream_index == m_stream_index) {
++				needs_packet = false;
++			} else {
++				av_packet_unref(m_packet);
++			}
++		}
++
++		if (m_packet->size != 0) {
++			ret = avcodec_send_packet(m_codec_ctx, m_packet);
++			if (ret < 0) {
++				if (ret != AVERROR(EAGAIN)) {
+ 					SetError("Error reading from the audio source", ret);
+ 					return false;
+ 				}
+-			}
+-			m_packet0 = m_packet;
+-			if (m_packet.stream_index != m_stream_index) {
+-				m_packet.data = nullptr;
+-				m_packet.size = 0;
+ 			} else {
+-				m_nb_packets++;
++				av_packet_unref(m_packet);
+ 			}
+ 		}
+
+-		ret = avcodec_decode_audio4(m_codec_ctx, m_frame, &m_got_frame, &m_packet);
++		ret = avcodec_receive_frame(m_codec_ctx, m_frame);
+ 		if (ret < 0) {
+-			if (m_decode_error) {
+-				SetError("Error decoding audio frame", m_decode_error);
+-				return false;
++			if (ret == AVERROR_EOF) {
++				m_has_more_frames = false;
++			} else if (ret == AVERROR(EAGAIN)) {
++				if (m_has_more_packets) {
++					needs_packet = true;
++					continue;
++				} else {
++					m_has_more_frames = false;
++				}
+ 			}
+-			m_decode_error = ret;
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			continue;
++			SetError("Error decoding the audio source", ret);
++			return false;
+ 		}
+
+-		break;
+-	}
+-
+-	m_decode_error = 0;
+-
+-	const int decoded = std::min(ret, m_packet.size);
+-	m_packet.data += decoded;
+-	m_packet.size -= decoded;
+-
+-	if (m_got_frame) {
+-		if (m_converter) {
+-			if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
+-				int linsize;
+-				av_freep(&m_convert_buffer[0]);
+-				m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
+-				ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
+-				if (ret < 0) {
+-					SetError("Couldn't allocate audio converter buffer", ret);
++		if (m_frame->nb_samples > 0) {
++			if (m_converter) {
++				if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
++					int linsize;
++					av_freep(&m_convert_buffer[0]);
++					m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
++					ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->ch_layout.nb_channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
++					if (ret < 0) {
++						SetError("Couldn't allocate audio converter buffer", ret);
++						return false;
++					}
++				}
++				auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
++				if (nb_samples < 0) {
++					SetError("Couldn't convert audio", ret);
+ 					return false;
+ 				}
+-			}
+-			auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			}
+-			*data = (const int16_t *) m_convert_buffer[0];
+-			*size = nb_samples;
+-		} else {
+-			*data = (const int16_t *) m_frame->data[0];
+-			*size = m_frame->nb_samples;
+-		}
+-	} else {
+-		if (m_finished && m_converter) {
+-			auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			} else if (nb_samples > 0) {
+-				m_got_frame = 1;
+ 				*data = (const int16_t *) m_convert_buffer[0];
+ 				*size = nb_samples;
++			} else {
++				*data = (const int16_t *) m_frame->data[0];
++				*size = m_frame->nb_samples;
++			}
++		} else {
++			if (m_converter) {
++				if (IsFinished()) {
++					auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
++					if (nb_samples < 0) {
++						SetError("Couldn't convert audio", ret);
++						return false;
++					} else if (nb_samples > 0) {
++						*data = (const int16_t *) m_convert_buffer[0];
++						*size = nb_samples;
++					}
++				}
+ 			}
+ 		}
+-	}
+
+-	return true;
++		return true;
++	}
+ }
+
+ inline void FFmpegAudioReader::SetError(const char *message, int errnum) {
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index a2b517b..123e643 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -38,6 +38,12 @@ set(SRCS
+
+ if(BUILD_TOOLS)
+ 	set(SRCS ${SRCS} ../src/audio/ffmpeg_audio_reader_test.cpp)
++    include_directories(
++        ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}
++        ${AUDIO_PROCESSOR_INCLUDE_DIRS}
++    )
+ 	link_libraries(fpcalc_libs)
+ endif()
+
+-- 
+2.38.1
+
+
diff --git a/srcpkgs/chromaprint/template b/srcpkgs/chromaprint/template
index 7ef7838949f3a..1f7bbc70a22c8 100644
--- a/srcpkgs/chromaprint/template
+++ b/srcpkgs/chromaprint/template
@@ -1,7 +1,7 @@
 # Template file for 'chromaprint'
 pkgname=chromaprint
 version=1.5.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DBUILD_TOOLS=ON"
 make_check_target="check"

From cfd69c1b6946597d4f4ee5a077799d07b5801d82 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 022/113] chromium: revbump for ffmpeg-6.0

---
 .../patches/chromium-119-ffmpeg-4.4.patch     | 20 --------
 srcpkgs/chromium/patches/ffmpeg5.patch        | 47 +++++++++++++++++++
 srcpkgs/chromium/template                     |  2 +-
 3 files changed, 48 insertions(+), 21 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch
 create mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch b/srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch
deleted file mode 100644
index 04d04b166ba37..0000000000000
--- a/srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch
+++ /dev/null
@@ -1,20 +0,0 @@
---- a/media/filters/ffmpeg_demuxer.cc.orig
-+++ b/media/filters/ffmpeg_demuxer.cc
-@@ -390,7 +390,7 @@
- 
-   scoped_refptr<DecoderBuffer> buffer;
- 
--    size_t side_data_size = 0;
-+    int side_data_size = 0;
-     uint8_t* side_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
- 
-@@ -453,7 +453,7 @@
-                                        packet->size - data_offset);
-     }
- 
--    size_t skip_samples_size = 0;
-+    int skip_samples_size = 0;
-     const uint32_t* skip_samples_ptr =
-         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
-             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..24e2da38e34ca
--- /dev/null
+++ b/srcpkgs/chromium/patches/ffmpeg5.patch
@@ -0,0 +1,47 @@
+--- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
++++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
+@@ -92,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+-  if (stream->start_time != kNoFFmpegTimestamp)
++  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -1597,7 +1585,7 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+@@ -1618,7 +1606,7 @@
+     if (stream->type() != DemuxerStream::VIDEO)
+       continue;
+ 
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+ 
+     if (!stream->IsEnabled())
diff --git a/srcpkgs/chromium/template b/srcpkgs/chromium/template
index b023946f3ec7b..fe36a6dce20d3 100644
--- a/srcpkgs/chromium/template
+++ b/srcpkgs/chromium/template
@@ -2,7 +2,7 @@
 pkgname=chromium
 # See https://chromiumdash.appspot.com/releases?platform=Linux for the latest version
 version=119.0.6045.105
-revision=3
+revision=4
 archs="i686* x86_64* aarch64* armv7l*"
 hostmakedepends="
  $(vopt_if clang "clang lld llvm15")

From 612a2ac2a1b354b650be7c3e29e8be9568c69203 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 023/113] cmus: revbump for ffmpeg-6.0

---
 srcpkgs/chromium/patches/ffmpeg5.patch | 47 --------------------------
 srcpkgs/cmus/patches/ffmpeg6.patch     | 12 +++++++
 srcpkgs/cmus/template                  |  2 +-
 3 files changed, 13 insertions(+), 48 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch
 create mode 100644 srcpkgs/cmus/patches/ffmpeg6.patch

diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
deleted file mode 100644
index 24e2da38e34ca..0000000000000
--- a/srcpkgs/chromium/patches/ffmpeg5.patch
+++ /dev/null
@@ -1,47 +0,0 @@
---- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
-+++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
-@@ -92,24 +92,12 @@
- 
- static base::TimeDelta ExtractStartTime(AVStream* stream) {
-   // The default start time is zero.
--  base::TimeDelta start_time;
-+  base::TimeDelta start_time = kNoTimestamp;
- 
-   // First try to use  the |start_time| value as is.
--  if (stream->start_time != kNoFFmpegTimestamp)
-+  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
-     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
- 
--  // Next try to use the first DTS value, for codecs where we know PTS == DTS
--  // (excludes all H26x codecs). The start time must be returned in PTS.
--  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
--      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
--      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
--      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
--    const base::TimeDelta first_pts =
--        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
--    if (first_pts < start_time)
--      start_time = first_pts;
--  }
--
-   return start_time;
- }
- 
-@@ -1597,7 +1585,7 @@
-   for (const auto& stream : streams_) {
-     if (!stream || stream->IsEnabled() != enabled)
-       continue;
--    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
-+    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
-       continue;
-     if (!lowest_start_time_stream ||
-         stream->start_time() < lowest_start_time_stream->start_time()) {
-@@ -1618,7 +1606,7 @@
-     if (stream->type() != DemuxerStream::VIDEO)
-       continue;
- 
--    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
-+    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
-       continue;
- 
-     if (!stream->IsEnabled())
diff --git a/srcpkgs/cmus/patches/ffmpeg6.patch b/srcpkgs/cmus/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..ffa95ab811101
--- /dev/null
+++ b/srcpkgs/cmus/patches/ffmpeg6.patch
@@ -0,0 +1,12 @@
+--- a/ip/ffmpeg.c
++++ b/ip/ffmpeg.c
+@@ -202,9 +202,6 @@ static int ffmpeg_open(struct input_plugin_data *ip_data)
+ 			break;
+ 		}
+ 
+-		if (codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+-			cc->flags |= AV_CODEC_FLAG_TRUNCATED;
+-
+ 		if (avcodec_open2(cc, codec, NULL) < 0) {
+ 			d_print("could not open codec: %d, %s\n", cc->codec_id, avcodec_get_name(cc->codec_id));
+ 			err = -IP_ERROR_UNSUPPORTED_FILE_TYPE;
diff --git a/srcpkgs/cmus/template b/srcpkgs/cmus/template
index 0d1436744f1b2..a6e4b4fa86cb8 100644
--- a/srcpkgs/cmus/template
+++ b/srcpkgs/cmus/template
@@ -1,7 +1,7 @@
 # Template file for 'cmus'
 pkgname=cmus
 version=2.10.0
-revision=3
+revision=4
 build_style=configure
 configure_args="prefix=/usr LD=$CC"
 hostmakedepends="pkg-config"

From 26436aba4239e1a76c783d913fffdf740f3c7e2c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 024/113] cyanrip: revbump for ffmpeg-6.0

---
 srcpkgs/cyanrip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cyanrip/template b/srcpkgs/cyanrip/template
index 9796e3461601a..5db30e020d17e 100644
--- a/srcpkgs/cyanrip/template
+++ b/srcpkgs/cyanrip/template
@@ -1,7 +1,7 @@
 # Template file for 'cyanrip'
 pkgname=cyanrip
 version=0.9.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config"
 makedepends="ffmpeg-devel libcdio-devel libcdio-paranoia-devel libcurl-devel libmusicbrainz5-devel"

From 027afb14d6471658af81d96065bcf93c5318f79b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 025/113] deadbeef: revbump for ffmpeg4-4.4.3

---
 srcpkgs/deadbeef/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/deadbeef/template b/srcpkgs/deadbeef/template
index f5f4bf24b8cb6..7b47e615cd48e 100644
--- a/srcpkgs/deadbeef/template
+++ b/srcpkgs/deadbeef/template
@@ -1,14 +1,14 @@
 # Template file for 'deadbeef'
 pkgname=deadbeef
 version=1.8.8
-revision=3
+revision=4
 create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-oss --disable-lfm --disable-notify --disable-gtk2"
 hostmakedepends="automake libtool gettext gettext-devel intltool pkg-config
  yasm clang glib-devel"
 makedepends="
- alsa-lib-devel dbus-devel faad2-devel ffmpeg-devel gtk+3-devel imlib2-devel
+ alsa-lib-devel dbus-devel faad2-devel ffmpeg4-devel gtk+3-devel imlib2-devel
  jansson-devel libcddb-devel libcdio-devel libcurl-devel libflac-devel
  libmad-devel libpng-devel libsamplerate-devel libsndfile-devel libvorbis-devel
  libzip-devel mpg123-devel opusfile-devel pulseaudio-devel wavpack-devel"

From e6d550b4e430ec3bbafb6d76950467646cacd52a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 026/113] droidcam-obs-plugin: revbump for ffmpeg-6.0

---
 srcpkgs/droidcam-obs-plugin/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam-obs-plugin/template b/srcpkgs/droidcam-obs-plugin/template
index fc9c9bf6b9d54..fb0480754df4d 100644
--- a/srcpkgs/droidcam-obs-plugin/template
+++ b/srcpkgs/droidcam-obs-plugin/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam-obs-plugin'
 pkgname=droidcam-obs-plugin
 version=2.0.1
-revision=1
+revision=2
 build_style=gnu-makefile
 make_use_env=yes
 make_build_args="ALLOW_STATIC=no"

From a342cddeff0deb1ecba6ba1b5b80c855db1411cd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 027/113] droidcam: revbump for ffmpeg-6.0

---
 srcpkgs/droidcam/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam/template b/srcpkgs/droidcam/template
index 1c3f1b8b1fc67..32a9220b79a4d 100644
--- a/srcpkgs/droidcam/template
+++ b/srcpkgs/droidcam/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam'
 pkgname=droidcam
 version=1.8.2
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="USBMUXD=-lusbmuxd-2.0 JPEG=-lturbojpeg"
 hostmakedepends="pkg-config"

From c6fc56f69dda912b7f5c5643c6238349feee485f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 028/113] ffmpegthumbnailer: revbump for ffmpeg-6.0

---
 .../ffmpegthumbnailer/patches/ffmpeg6.patch   | 202 ++++++++++++++++++
 srcpkgs/ffmpegthumbnailer/template            |   6 +-
 2 files changed, 205 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch

diff --git a/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..363ff35a28419
--- /dev/null
+++ b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
@@ -0,0 +1,202 @@
+--- a/libffmpegthumbnailer/moviedecoder.cpp	2017-11-21 14:06:57.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.cpp	2023-05-05 13:14:47.946560668 -0400
+@@ -41,11 +41,6 @@
+ namespace ffmpegthumbnailer
+ {
+ 
+-struct SilenceLogLevel
+-{
+-    SilenceLogLevel() { av_log_set_level(AV_LOG_QUIET); }
+-};
+-
+ MovieDecoder::MovieDecoder(AVFormatContext* pavContext)
+ : m_VideoStream(-1)
+ , m_pFormatContext(pavContext)
+@@ -70,8 +65,6 @@
+ 
+ void MovieDecoder::initialize(const string& filename, bool preferEmbeddedMetadata)
+ {
+-    av_register_all();
+-    avcodec_register_all();
+     avformat_network_init();
+ 
+     string inputFile = filename == "-" ? "pipe:" : filename;
+@@ -97,8 +90,7 @@
+ {
+     if (m_pVideoCodecContext)
+     {
+-        avcodec_close(m_pVideoCodecContext);
+-        m_pVideoCodecContext = nullptr;
++        avcodec_free_context(&m_pVideoCodecContext);
+     }
+ 
+     if ((!m_FormatContextWasGiven) && m_pFormatContext)
+@@ -152,10 +144,10 @@
+     for (unsigned int i = 0; i < m_pFormatContext->nb_streams; ++i)
+     {
+         AVStream *stream = m_pFormatContext->streams[i];
+-        auto ctx = m_pFormatContext->streams[i]->codec;
+-        if (ctx->codec_type == AVMEDIA_TYPE_VIDEO)
++        auto par = m_pFormatContext->streams[i]->codecpar;
++        if (par->codec_type == AVMEDIA_TYPE_VIDEO)
+         {
+-            if (!preferEmbeddedMetadata || !isStillImageCodec(ctx->codec_id))
++            if (!preferEmbeddedMetadata || !isStillImageCodec(par->codec_id))
+             {
+                 videoStreams.push_back(i);
+                 continue;
+@@ -203,8 +195,7 @@
+     }
+ 
+     m_pVideoStream = m_pFormatContext->streams[m_VideoStream];
+-    m_pVideoCodecContext = m_pVideoStream->codec;
+-    m_pVideoCodec = avcodec_find_decoder(m_pVideoCodecContext->codec_id);
++    m_pVideoCodec = avcodec_find_decoder(m_pVideoStream->codecpar->codec_id);
+ 
+     if (m_pVideoCodec == nullptr)
+     {
+@@ -214,6 +205,20 @@
+         throw logic_error("Video Codec not found");
+     }
+ 
++    m_pVideoCodecContext = avcodec_alloc_context3(m_pVideoCodec);
++
++    if (m_pVideoCodecContext == nullptr)
++    {
++        destroy();
++        throw logic_error("Could not allocate video codec context");
++    }
++
++    if (avcodec_parameters_to_context(m_pVideoCodecContext, m_pVideoStream->codecpar) < 0)
++    {
++        destroy();
++        throw logic_error("Could not configure video codec context");
++    }
++
+     m_pVideoCodecContext->workaround_bugs = 1;
+ 
+     if (avcodec_open2(m_pVideoCodecContext, m_pVideoCodec, nullptr) < 0)
+@@ -386,13 +391,6 @@
+ 
+ void MovieDecoder::initializeFilterGraph(const AVRational& timeBase, const std::string& size, bool maintainAspectRatio)
+ {
+-    static const AVPixelFormat pixelFormats[] = { AV_PIX_FMT_RGB24, AV_PIX_FMT_NONE };
+-
+-    auto del = [] (AVBufferSinkParams* p) { av_freep(p); };
+-    std::unique_ptr<AVBufferSinkParams, decltype(del)> buffersinkParams(av_buffersink_params_alloc(), del);
+-
+-    avfilter_register_all();
+-
+     m_pFilterGraph = avfilter_graph_alloc();
+     assert(m_pFilterGraph);
+ 
+@@ -404,10 +402,8 @@
+ 
+     checkRc(avfilter_graph_create_filter(&m_pFilterSource, avfilter_get_by_name("buffer"), "thumb_buffer", ss.str().c_str(), nullptr, m_pFilterGraph),
+             "Failed to create filter source");
+-    buffersinkParams->pixel_fmts = pixelFormats;
+-    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, buffersinkParams.get(), m_pFilterGraph),
++    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, nullptr, m_pFilterGraph),
+             "Failed to create filter sink");
+-    buffersinkParams.release();
+ 
+     AVFilterContext* yadifFilter = nullptr;
+     if (m_pFrame->interlaced_frame != 0)
+@@ -500,15 +496,15 @@
+     }
+ 
+     checkRc(av_seek_frame(m_pFormatContext, -1, timestamp, 0), "Seeking in video failed");
+-    avcodec_flush_buffers(m_pFormatContext->streams[m_VideoStream]->codec);
++    avcodec_flush_buffers(m_pVideoCodecContext);
+ 
+     int keyFrameAttempts = 0;
+-    bool gotFrame = 0;
++    bool gotFrame;
+ 
+     do
+     {
+         int count = 0;
+-        gotFrame = 0;
++        gotFrame = false;
+ 
+         while (!gotFrame && count < 20)
+         {
+@@ -552,17 +548,33 @@
+         return false;
+     }
+ 
+-    av_frame_unref(m_pFrame);
+-
+-    int frameFinished;
++    int rc = avcodec_send_packet(m_pVideoCodecContext, m_pPacket);
++    if(rc == AVERROR(EAGAIN))
++    {
++        rc = 0;
++    }
+ 
+-    int bytesDecoded = avcodec_decode_video2(m_pVideoCodecContext, m_pFrame, &frameFinished, m_pPacket);
+-    if (bytesDecoded < 0)
++    if(rc == AVERROR_EOF)
++    {
++        return false;
++    }
++    else if(rc < 0)
+     {
+-        throw logic_error("Failed to decode video frame: bytesDecoded < 0");
++        throw logic_error("Failed to decode video frame: avcodec_send_packet() < 0");
+     }
+ 
+-    return frameFinished > 0;
++    rc = avcodec_receive_frame(m_pVideoCodecContext, m_pFrame);
++    switch(rc)
++    {
++        case 0:
++            return true;
++
++        case AVERROR(EAGAIN):
++            return false;
++
++        default:
++            throw logic_error("Failed to decode video frame: avcodec_receive_frame() < 0");
++    }
+ }
+ 
+ bool MovieDecoder::getVideoPacket()
+@@ -570,8 +582,6 @@
+     bool framesAvailable = true;
+     bool frameDecoded = false;
+ 
+-    int attempts = 0;
+-
+     if (m_pPacket)
+     {
+         av_packet_unref(m_pPacket);
+@@ -580,6 +590,7 @@
+ 
+     m_pPacket = new AVPacket();
+ 
++
+     while (framesAvailable && !frameDecoded)
+     {
+         framesAvailable = av_read_frame(m_pFormatContext, m_pPacket) >= 0;
+@@ -644,7 +655,7 @@
+ 
+ int32_t MovieDecoder::getStreamRotation()
+ {
+-    int32_t* matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
++    auto matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
+     if (matrix)
+     {
+         auto angle = lround(av_display_rotation_get(matrix));
+
+--- a/libffmpegthumbnailer/moviedecoder.h	2017-11-12 04:23:38.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.h	2023-05-05 13:26:07.095529911 -0400
+@@ -78,7 +78,7 @@
+     int                     m_VideoStream;
+     AVFormatContext*        m_pFormatContext;
+     AVCodecContext*         m_pVideoCodecContext;
+-    AVCodec*                m_pVideoCodec;
++    const AVCodec*          m_pVideoCodec;
+     AVFilterGraph*          m_pFilterGraph;
+     AVFilterContext*        m_pFilterSource;
+     AVFilterContext*        m_pFilterSink;
diff --git a/srcpkgs/ffmpegthumbnailer/template b/srcpkgs/ffmpegthumbnailer/template
index 039eea7622b39..35d546018d12a 100644
--- a/srcpkgs/ffmpegthumbnailer/template
+++ b/srcpkgs/ffmpegthumbnailer/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbnailer'
 pkgname=ffmpegthumbnailer
 version=2.2.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libpng-devel libjpeg-turbo-devel ffmpeg-devel"
@@ -9,8 +9,8 @@ depends="ffmpeg"
 short_desc="Lightweight video thumbnailer"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
-homepage="https://github.com/dirkvdb/${pkgname}"
-distfiles="${homepage}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
+homepage="https://github.com/dirkvdb"
+distfiles="${homepage}/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
 checksum=1cb24059c38223f657b300c84dd80491b7040d4b69471c4fea69be862bc99b5b
 
 post_install() {

From 7f86a5d919326d9dd5f3cfb828966224bcdf731d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 029/113] ffmpegthumbs: revbump for ffmpeg-6.0

---
 srcpkgs/ffmpegthumbs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ffmpegthumbs/template b/srcpkgs/ffmpegthumbs/template
index 5f0b9414dadaf..11b88193528f4 100644
--- a/srcpkgs/ffmpegthumbs/template
+++ b/srcpkgs/ffmpegthumbs/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbs'
 pkgname=ffmpegthumbs
 version=22.12.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules kcoreaddons kconfig-devel
  pkg-config qt5-host-tools qt5-qmake gettext"

From 823d815573b1051cb6689f17a6923a5f2188fe0a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 030/113] ffms2: revbump for ffmpeg-6.0

---
 srcpkgs/ffms2/patches/ffmpeg5.patch | 424 ++++++++++++++++++++++++++++
 srcpkgs/ffms2/template              |   2 +-
 2 files changed, 425 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ffms2/patches/ffmpeg5.patch

diff --git a/srcpkgs/ffms2/patches/ffmpeg5.patch b/srcpkgs/ffms2/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..1479fabcafcb4
--- /dev/null
+++ b/srcpkgs/ffms2/patches/ffmpeg5.patch
@@ -0,0 +1,424 @@
+From 45673149e9a2f5586855ad472e3059084eaa36b1 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:41:21 +0100
+Subject: [PATCH] Use auto for AVCodec
+
+The geniuses over at FFmpeg decided to constify this API, so old
+versions of the library will return AVCodec *, while new versions
+of the libary will return const AVCodec *, which, in C++, are not
+OK to convert between.
+
+Rather than use some macro hell in ffmscompat.h, we can work around
+this by using auto.
+
+Gross.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 2 +-
+ src/core/indexing.cpp    | 6 +++---
+ src/core/videosource.cpp | 2 +-
+ 3 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index e4ce97c..ac09666 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -469,7 +469,7 @@ void FFMS_AudioSource::OpenFile() {
+ 
+     LAVFOpenFile(SourceFile.c_str(), FormatContext, TrackNumber);
+ 
+-    AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
++    auto *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
+     if (Codec == nullptr)
+         throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+             "Audio codec not found");
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index e547c5a..59fb4e8 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -384,7 +384,7 @@ FFMS_TrackType FFMS_Indexer::GetTrackType(int Track) {
+ }
+ 
+ const char *FFMS_Indexer::GetTrackCodec(int Track) {
+-    AVCodec *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
++    auto *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
+     return codec ? codec->name : nullptr;
+ }
+ 
+@@ -402,7 +402,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             UseDTS);
+ 
+         if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            AVCodec *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (!VideoCodec) {
+                 FormatContext->streams[i]->discard = AVDISCARD_ALL;
+                 IndexMask.erase(i);
+@@ -433,7 +433,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 IndexMask.insert(i);
+             }
+         } else if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+-            AVCodec *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (AudioCodec == nullptr)
+                 throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_UNSUPPORTED,
+                     "Audio codec not found");
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index b889970..8956c22 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -171,7 +171,7 @@ FFMS_VideoSource::FFMS_VideoSource(const char *SourceFile, FFMS_Index &Index, in
+ 
+         LAVFOpenFile(SourceFile, FormatContext, VideoTrack);
+ 
+-        AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
++        auto *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
+         if (Codec == nullptr)
+             throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+                 "Video codec not found");
+-- 
+2.40.0
+
+From 96cbf38ea9381829a1314f432a2c60495dcefaad Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:12:41 +0100
+Subject: [PATCH] all: Update AVPacket API usage
+
+AVPackets must all be on the heap now, since it is no longer
+part of the libav* ABI.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 16 ++++++----
+ src/core/indexing.cpp    | 63 ++++++++++++++++++++++------------------
+ src/core/indexing.h      |  4 +--
+ src/core/utils.cpp       |  6 ----
+ src/core/utils.h         |  1 -
+ src/core/videosource.cpp | 30 ++++++++++---------
+ 6 files changed, 64 insertions(+), 56 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index 37cf9ae..e4ce97c 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -285,10 +285,15 @@ FFMS_AudioSource::AudioBlock *FFMS_AudioSource::CacheBlock(CacheIterator &pos) {
+ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     CurrentFrame = &Frames[PacketNumber];
+ 
+-    AVPacket Packet;
+-    if (!ReadPacket(&Packet))
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++    if (!ReadPacket(Packet)) {
++        av_packet_free(&Packet);
+         throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_UNKNOWN,
+             "ReadPacket unexpectedly failed to read a packet");
++    }
+ 
+     // ReadPacket may have changed the packet number
+     CurrentFrame = &Frames[PacketNumber];
+@@ -297,8 +302,9 @@ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     int NumberOfSamples = 0;
+     AudioBlock *CachedBlock = nullptr;
+     
+-    int Ret = avcodec_send_packet(CodecContext, &Packet);
+-    av_packet_unref(&Packet);
++    int Ret = avcodec_send_packet(CodecContext, Packet);
++    av_packet_unref(Packet);
++    av_packet_free(&Packet);
+ 
+     av_frame_unref(DecodeFrame);
+     Ret = avcodec_receive_frame(CodecContext, DecodeFrame);
+@@ -513,8 +519,6 @@ void FFMS_AudioSource::Seek() {
+ }
+ 
+ bool FFMS_AudioSource::ReadPacket(AVPacket *Packet) {
+-    InitNullPacket(*Packet);
+-
+     while (av_read_frame(FormatContext, Packet) >= 0) {
+         if (Packet->stream_index == TrackNumber) {
+             // Required because not all audio packets, especially in ogg, have a pts. Use the previous valid packet's pts instead.
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index 23fb95b..e547c5a 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -320,7 +320,7 @@ void FFMS_Indexer::CheckAudioProperties(int Track, AVCodecContext *Context) {
+     }
+ }
+ 
+-void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict,
++void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict,
+                                     int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct) {
+     if (VideoContext.Parser) {
+         uint8_t *OB;
+@@ -330,8 +330,8 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+         av_parser_parse2(VideoContext.Parser,
+             VideoContext.CodecContext,
+             &OB, &OBSize,
+-            pkt.data, pkt.size,
+-            pkt.pts, pkt.dts, pkt.pos);
++            pkt->data, pkt->size,
++            pkt->pts, pkt->dts, pkt->pos);
+ 
+         // H.264 (PAFF) and HEVC may have one field per packet, so we need to track
+         // when we have a full or half frame available, and mark one of them as
+@@ -351,15 +351,15 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+ 
+         *RepeatPict = VideoContext.Parser->repeat_pict;
+         *FrameType = VideoContext.Parser->pict_type;
+-        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt.flags & AV_PKT_FLAG_DISCARD));
++        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt->flags & AV_PKT_FLAG_DISCARD));
+     } else {
+-        *Invisible = !!(pkt.flags & AV_PKT_FLAG_DISCARD);
++        *Invisible = !!(pkt->flags & AV_PKT_FLAG_DISCARD);
+     }
+ 
+     if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP8)
+-        ParseVP8(pkt.data[0], Invisible, FrameType);
++        ParseVP8(pkt->data[0], Invisible, FrameType);
+     else if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP9)
+-        ParseVP9(pkt.data[0], Invisible, FrameType);
++        ParseVP9(pkt->data[0], Invisible, FrameType);
+ }
+ 
+ void FFMS_Indexer::Free() {
+@@ -458,32 +458,36 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+         }
+     }
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
+     std::vector<int64_t> LastValidTS(FormatContext->nb_streams, AV_NOPTS_VALUE);
+ 
+     int64_t filesize = avio_size(FormatContext->pb);
+     enum AVPictureStructure LastPicStruct = AV_PICTURE_STRUCTURE_UNKNOWN;
+-    while (av_read_frame(FormatContext, &Packet) >= 0) {
++    while (av_read_frame(FormatContext, Packet) >= 0) {
+         // Update progress
+         // FormatContext->pb can apparently be NULL when opening images.
+         if (IC && FormatContext->pb) {
+-            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate))
++            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate)) {
++                av_packet_free(&Packet);
+                 throw FFMS_Exception(FFMS_ERROR_CANCELLED, FFMS_ERROR_USER,
+                     "Cancelled by user");
++            }
+         }
+-        if (!IndexMask.count(Packet.stream_index)) {
+-            av_packet_unref(&Packet);
++        if (!IndexMask.count(Packet->stream_index)) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+-        int Track = Packet.stream_index;
++        int Track = Packet->stream_index;
+         FFMS_Track &TrackInfo = (*TrackIndices)[Track];
+-        bool KeyFrame = !!(Packet.flags & AV_PKT_FLAG_KEY);
++        bool KeyFrame = !!(Packet->flags & AV_PKT_FLAG_KEY);
+         ReadTS(Packet, LastValidTS[Track], (*TrackIndices)[Track].UseDTS);
+ 
+         if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            int64_t PTS = TrackInfo.UseDTS ? Packet.dts : Packet.pts;
++            int64_t PTS = TrackInfo.UseDTS ? Packet->dts : Packet->pts;
+             if (PTS == AV_NOPTS_VALUE) {
+                 // VPx alt-refs are output as packets which lack timestmps or durations, since
+                 // they are invisible. Currently, the timestamp mangling code in libavformat
+@@ -495,9 +499,11 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 // FFMS2 currently sorts packets by PTS, which will break decoding, otherwise.
+                 bool HasAltRefs = (FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP8 ||
+                                    FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP9);
+-                if (Packet.duration == 0 && !HasAltRefs)
++                if (Packet->duration == 0 && !HasAltRefs) {
++                    av_packet_free(&Packet);
+                     throw FFMS_Exception(FFMS_ERROR_INDEXING, FFMS_ERROR_PARSER,
+                         "Invalid packet pts, dts, and duration");
++                }
+ 
+                 if (TrackInfo.empty())
+                     PTS = 0;
+@@ -513,7 +519,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             ParseVideoPacket(AVContexts[Track], Packet, &RepeatPict, &FrameType, &Invisible, &LastPicStruct);
+ 
+             TrackInfo.AddVideoFrame(PTS, RepeatPict, KeyFrame,
+-                FrameType, Packet.pos, Invisible);
++                FrameType, Packet->pos, Invisible);
+         } else if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+             // For video seeking timestamps are used only if all packets have
+             // timestamps, while for audio they're used if any have timestamps,
+@@ -522,28 +528,29 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 TrackInfo.HasTS = true;
+ 
+             int64_t StartSample = AVContexts[Track].CurrentSample;
+-            uint32_t SampleCount = IndexAudioPacket(Track, &Packet, AVContexts[Track], *TrackIndices);
++            uint32_t SampleCount = IndexAudioPacket(Track, Packet, AVContexts[Track], *TrackIndices);
+             TrackInfo.SampleRate = AVContexts[Track].CodecContext->sample_rate;
+ 
+             TrackInfo.AddAudioFrame(LastValidTS[Track],
+-                StartSample, SampleCount, KeyFrame, Packet.pos, Packet.flags & AV_PKT_FLAG_DISCARD);
++                StartSample, SampleCount, KeyFrame, Packet->pos, Packet->flags & AV_PKT_FLAG_DISCARD);
+         }
+ 
+-        if (!(Packet.flags & AV_PKT_FLAG_DISCARD))
+-            TrackInfo.LastDuration = Packet.duration;
++        if (!(Packet->flags & AV_PKT_FLAG_DISCARD))
++            TrackInfo.LastDuration = Packet->duration;
+ 
+-        av_packet_unref(&Packet);
++        av_packet_unref(Packet);
+     }
++    av_packet_free(&Packet);
+ 
+     TrackIndices->Finalize(AVContexts, FormatContext->iformat->name);
+     return TrackIndices.release();
+ }
+ 
+-void FFMS_Indexer::ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS) {
+-    if (!UseDTS && Packet.pts != AV_NOPTS_VALUE)
+-        TS = Packet.pts;
++void FFMS_Indexer::ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS) {
++    if (!UseDTS && Packet->pts != AV_NOPTS_VALUE)
++        TS = Packet->pts;
+     if (TS == AV_NOPTS_VALUE)
+         UseDTS = true;
+-    if (UseDTS && Packet.dts != AV_NOPTS_VALUE)
+-        TS = Packet.dts;
++    if (UseDTS && Packet->dts != AV_NOPTS_VALUE)
++        TS = Packet->dts;
+ }
+diff --git a/src/core/indexing.h b/src/core/indexing.h
+index 3cfc3c3..5c06868 100644
+--- a/src/core/indexing.h
++++ b/src/core/indexing.h
+@@ -80,10 +80,10 @@ private:
+     int64_t Filesize;
+     uint8_t Digest[20];
+ 
+-    void ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS);
++    void ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS);
+     void CheckAudioProperties(int Track, AVCodecContext *Context);
+     uint32_t IndexAudioPacket(int Track, AVPacket *Packet, SharedAVContext &Context, FFMS_Index &TrackIndices);
+-    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
++    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
+     void Free();
+ public:
+     FFMS_Indexer(const char *Filename);
+diff --git a/src/core/utils.cpp b/src/core/utils.cpp
+index ce67533..8a2e997 100644
+--- a/src/core/utils.cpp
++++ b/src/core/utils.cpp
+@@ -62,12 +62,6 @@ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo) {
+     }
+ }
+ 
+-void InitNullPacket(AVPacket &pkt) {
+-    av_init_packet(&pkt);
+-    pkt.data = nullptr;
+-    pkt.size = 0;
+-}
+-
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames) {
+     AP.SampleFormat = static_cast<FFMS_SampleFormat>(av_get_packed_sample_fmt(CTX->sample_fmt));
+     AP.BitsPerSample = av_get_bytes_per_sample(CTX->sample_fmt) * 8;
+diff --git a/src/core/utils.h b/src/core/utils.h
+index 9819dc7..003ab79 100644
+--- a/src/core/utils.h
++++ b/src/core/utils.h
+@@ -58,7 +58,6 @@ std::unique_ptr<T> make_unique(Args&&... args) {
+ }
+ 
+ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo);
+-void InitNullPacket(AVPacket &pkt);
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames);
+ 
+ void LAVFOpenFile(const char *SourceFile, AVFormatContext *&FormatContext, int Track);
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index 06bd161..b889970 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -673,30 +673,34 @@ void FFMS_VideoSource::DecodeNextFrame(int64_t &AStartTime, int64_t &Pos) {
+     if (HasPendingDelayedFrames())
+         return;
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
+-
+-    while (ReadFrame(&Packet) >= 0) {
+-        if (Packet.stream_index != VideoTrack) {
+-            av_packet_unref(&Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++
++    while (ReadFrame(Packet) >= 0) {
++        if (Packet->stream_index != VideoTrack) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+         if (AStartTime < 0)
+-            AStartTime = Frames.UseDTS ? Packet.dts : Packet.pts;
++            AStartTime = Frames.UseDTS ? Packet->dts : Packet->pts;
+ 
+         if (Pos < 0)
+-            Pos = Packet.pos;
++            Pos = Packet->pos;
+ 
+-        bool FrameFinished = DecodePacket(&Packet);
+-        av_packet_unref(&Packet);
+-        if (FrameFinished)
++        bool FrameFinished = DecodePacket(Packet);
++        av_packet_unref(Packet);
++        if (FrameFinished) {
++            av_packet_free(&Packet);
+             return;
++        }
+     }
+ 
+     // Flush final frames
+-    InitNullPacket(Packet);
+-    DecodePacket(&Packet);
++    DecodePacket(Packet);
++    av_packet_free(&Packet);
+ }
+ 
+ bool FFMS_VideoSource::SeekTo(int n, int SeekOffset) {
+-- 
+2.40.0
+
+From bf9e03e9e08534c024e5a744a6437c4aac160201 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:20:47 +0100
+Subject: [PATCH 2/3] configure: Remove deprecated API use
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ configure.ac | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index b35ef80bc..d19714d0f 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -102,10 +102,10 @@ CFLAGS="$_CFLAGS $FFMPEG_CFLAGS"
+
+ AC_DEFUN([TEST_FFMPEG],
+          [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+-            #include <libavcodec/avcodec.h>
++            #include <libavformat/avformat.h>
+             #include <libswscale/swscale.h>
+             ]],[[
+-                avcodec_register_all();
++                avformat_network_init();
+                 swscale_version();
+             ]])], [eval $1=yes], [eval $1=no])
+         ])
+
diff --git a/srcpkgs/ffms2/template b/srcpkgs/ffms2/template
index 365f64d10cbab..1641ecf43be5b 100644
--- a/srcpkgs/ffms2/template
+++ b/srcpkgs/ffms2/template
@@ -1,7 +1,7 @@
 # Template file for 'ffms2'
 pkgname=ffms2
 version=2.40
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-shared --disable-static"
 hostmakedepends="pkg-config autoconf automake libtool"

From d1b565ea30f48155f61026e843f79f00f5ef6e44 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 031/113] freerdp: revbump for ffmpeg-6.0

---
 .../freerdp/patches/ffmpeg6_aa2cb9aa.patch    | 42 +++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100644 srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch

diff --git a/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
new file mode 100644
index 0000000000000..a4324da3a8822
--- /dev/null
+++ b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
@@ -0,0 +1,42 @@
+From aa2cb9aa5ff5562433598ba168a466e0752bca0e Mon Sep 17 00:00:00 2001
+From: akallabeth <akallabeth@posteo.net>
+Date: Tue, 14 Feb 2023 07:48:54 +0100
+Subject: [PATCH] Fixed #8686: Update h264 to use new FFMPEG API
+
+---
+ channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c | 2 ++
+ libfreerdp/codec/h264_ffmpeg.c            | 2 ++
+ 2 files changed, 4 insertions(+)
+
+diff --git a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+index 339462d865f..beea80b7a1e 100644
+--- a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
++++ b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+@@ -239,8 +239,10 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYP
+ 		}
+ 	}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 	if (mdecoder->codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		mdecoder->codec_context->flags |= AV_CODEC_FLAG_TRUNCATED;
++#endif
+ 
+ 	return TRUE;
+ }
+diff --git a/libfreerdp/codec/h264_ffmpeg.c b/libfreerdp/codec/h264_ffmpeg.c
+index 8a23db2473c..896a333019b 100644
+--- a/libfreerdp/codec/h264_ffmpeg.c
++++ b/libfreerdp/codec/h264_ffmpeg.c
+@@ -615,10 +615,12 @@ static BOOL libavcodec_init(H264_CONTEXT* h264)
+ 			goto EXCEPTION;
+ 		}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 		if (sys->codecDecoder->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		{
+ 			sys->codecDecoderContext->flags |= AV_CODEC_FLAG_TRUNCATED;
+ 		}
++#endif
+ 
+ #ifdef WITH_VAAPI
+ 

From 8c74948365462f1031b6dcb2e31710126b915dec Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 032/113] gerbera: revbump for ffmpeg-6.0

---
 srcpkgs/gerbera/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gerbera/template b/srcpkgs/gerbera/template
index ae14f35c767c0..2dc0ac0ce03b5 100644
--- a/srcpkgs/gerbera/template
+++ b/srcpkgs/gerbera/template
@@ -1,7 +1,7 @@
 # Template file for 'gerbera'
 pkgname=gerbera
 version=1.12.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_SYSTEMD=0 -DWITH_AVCODEC=1"
 hostmakedepends="pkg-config"

From 10b82419bb92040a2cfdc8545601bf8111c63589 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 033/113] goldendict: revbump for ffmpeg-6.0

---
 srcpkgs/goldendict/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/goldendict/template b/srcpkgs/goldendict/template
index f4a05759f693d..97f44347b03a6 100644
--- a/srcpkgs/goldendict/template
+++ b/srcpkgs/goldendict/template
@@ -1,7 +1,7 @@
 # Template file for 'goldendict'
 pkgname=goldendict
 version=1.5.0
-revision=1
+revision=2
 build_style=qmake
 configure_args="CONFIG+=zim_support goldendict.pro"
 hostmakedepends="qt5-qmake pkg-config qt5-host-tools"
@@ -10,7 +10,7 @@ makedepends="tiff-devel qt5-devel libvorbis-devel zlib-devel
  qt5-webkit-devel lzo-devel bzip2-devel libao-devel qt5-svg-devel
  libeb-devel qt5-x11extras-devel ffmpeg-devel liblzma-devel
  qt5-multimedia-devel"
-short_desc="A feature-rich dictionary lookup program"
+short_desc="Feature-rich dictionary lookup program"
 maintainer="John <me@johnnynator.dev>"
 license="GPL-3.0-or-later"
 homepage="http://goldendict.org/"

From 18ba5b0da07d78ae6e6fde89b533f24fbc0c58ab Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 034/113] gst-libav: revbump for ffmpeg-6.0

---
 srcpkgs/gst-libav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index 78afeee4aefb2..f892eb2063564 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.22.7
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"

From c273c3872bab06e045bb43a7cb939950d05085bb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 035/113] gst-rtsp-server: revbump for ffmpeg-6.0

---
 srcpkgs/gst-rtsp-server/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index 2c280c84f1514..83a2949fd9482 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
 version=1.22.7
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="glib-devel gst-plugins-bad1-devel gobject-introspection

From 2a200c78ff9ba80615a91506b59517f86e8df080 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 036/113] guvcview: update to 2.0.8.

---
 srcpkgs/guvcview/patches/fix-include.patch | 10 ++++++++++
 srcpkgs/guvcview/template                  |  7 +++----
 2 files changed, 13 insertions(+), 4 deletions(-)
 create mode 100644 srcpkgs/guvcview/patches/fix-include.patch

diff --git a/srcpkgs/guvcview/patches/fix-include.patch b/srcpkgs/guvcview/patches/fix-include.patch
new file mode 100644
index 0000000000000..503c2af3b78c1
--- /dev/null
+++ b/srcpkgs/guvcview/patches/fix-include.patch
@@ -0,0 +1,10 @@
+--- a/guvcview/guvcview.c
++++ b/guvcview/guvcview.c
+@@ -28,6 +28,7 @@
+ #include <sys/stat.h>
+ #include <sys/resource.h>
+ #include <errno.h>
++#include <locale.h>
+ 
+ #include "gview.h"
+ #include "gviewv4l2core.h"
diff --git a/srcpkgs/guvcview/template b/srcpkgs/guvcview/template
index d42fd38fa4ad1..86a7fd619612c 100644
--- a/srcpkgs/guvcview/template
+++ b/srcpkgs/guvcview/template
@@ -1,8 +1,7 @@
 # Template file for 'guvcview'
 pkgname=guvcview
-version=2.0.7
-revision=2
-create_wrksrc=yes
+version=2.0.8
+revision=1
 build_style=gnu-configure
 configure_args="--disable-static --disable-debian-menu"
 hostmakedepends="pkg-config intltool autoconf automake libtool glib-devel"
@@ -14,7 +13,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="http://guvcview.sourceforge.net/"
 distfiles="${SOURCEFORGE_SITE}/${pkgname}/${pkgname}-src-${version}.tar.bz2"
-checksum=f47d51fbd06e44eeaa1a82f4a153c927527c90d94514197a70b2956028cc8ad4
+checksum=a21f4e448286666cf27bafef5290cc953a0a1796b752e5bbe521266dc1230c81
 
 post_patch() {
 	sed '31a#include <locale.h>' -i  guvcview/guvcview.c

From fd38c26542faa0d8c810ec73c3f90538d92f1577 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 037/113] handbrake: update to 1.6.1

---
 .../patches/fix-missing-x265-link-flag.patch    | 11 ++++++-----
 .../handbrake/patches/libhb-vpl-include.patch   | 15 +++++++++++++++
 srcpkgs/handbrake/template                      | 17 ++++++++++-------
 3 files changed, 31 insertions(+), 12 deletions(-)
 create mode 100644 srcpkgs/handbrake/patches/libhb-vpl-include.patch

diff --git a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
index 26db03867a0c8..d6bb2eda627a3 100644
--- a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
+++ b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
@@ -1,14 +1,15 @@
 --- a/gtk/configure.ac
 +++ b/gtk/configure.ac
 @@ -203,7 +203,7 @@
- 
+
  AM_CONDITIONAL([MINGW], [test "x$mingw_flag" = "xyes"])
- 
--HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg"
-+HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -ldl"
+
+-HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc"
++HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc -ldl"
  HB_CPPFLAGS="$HB_CPPFLAGS $HBINC"
- 
+
  PKG_CHECK_MODULES([x264], [x264], sys_x264=yes, sys_x264=no)
+
 --- a/test/module.defs
 +++ b/test/module.defs
 @@ -69,6 +69,9 @@
diff --git a/srcpkgs/handbrake/patches/libhb-vpl-include.patch b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
new file mode 100644
index 0000000000000..298f9f4ab28f2
--- /dev/null
+++ b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
@@ -0,0 +1,15 @@
+--- a/libhb/module.defs	2023-01-22 11:36:49.000000000 -0500
++++ b/libhb/module.defs	2023-04-03 22:37:52.395467010 -0400
+@@ -46,11 +46,7 @@
+ LIBHB.GCC.I += $(LIBHB.build/) $(CONTRIB.build/)include
+ 
+ ifeq (1,$(FEATURE.qsv))
+-    ifeq ($(HOST.system),freebsd))
+-        LIBHB.GCC.I += $(LOCALBASE)/include/vpl
+-    else
+-        LIBHB.GCC.I += $(CONTRIB.build/)include/vpl
+-    endif
++    LIBHB.GCC.I += /usr/include/vpl
+ endif
+ 
+ ifneq (,$(filter $(HOST.system),freebsd netbsd openbsd))
diff --git a/srcpkgs/handbrake/template b/srcpkgs/handbrake/template
index ca5e4571e49c3..c32cb1bfa31f4 100644
--- a/srcpkgs/handbrake/template
+++ b/srcpkgs/handbrake/template
@@ -1,10 +1,10 @@
 # Template file for 'handbrake'
 pkgname=handbrake
-version=1.5.1
+version=1.6.1
 revision=1
 build_style=gnu-configure
 configure_args="--force --disable-gtk-update-checks --disable-df-fetch --harden
- $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc)"
+ $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc) $(vopt_enable qsv)"
 make_build_args="-C ${XBPS_TRIPLET}"
 make_install_args="-C ${XBPS_TRIPLET}"
 hostmakedepends="automake cmake gettext-devel glib-devel intltool libtool m4 meson nasm pkg-config python3"
@@ -12,8 +12,11 @@ makedepends="bzip2-devel ffmpeg-devel gst-plugins-base1-devel gtk+3-devel
  jansson-devel lame-devel libass-devel libbluray-devel libdav1d-devel
  libdvdnav-devel libdvdread-devel libgudev-devel libnuma-devel
  libsamplerate-devel libtheora-devel libvorbis-devel libvpx-devel libxml2-devel
- opus-devel speex-devel x264-devel x265-devel zimg-devel
+ opus-devel speex-devel x264-devel x265-devel zimg-devel libsvt-av1-devel
  $(vopt_if fdk_aac fdk-aac-devel)
+ $(vopt_if qsv libva-devel)
+ $(vopt_if qsv libdrm-devel)
+ $(vopt_if qsv onevpl-devel)
  $(vopt_if nvenc nv-codec-headers)"
 depends="desktop-file-utils gst-plugins-good1 hicolor-icon-theme"
 short_desc="Multithreaded video transcoder"
@@ -21,15 +24,15 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-2.0-only"
 homepage="https://handbrake.fr/"
 distfiles="https://github.com/HandBrake/HandBrake/releases/download/${version}/HandBrake-${version}-source.tar.bz2"
-checksum=3999fe06d5309c819799a73a968a8ec3840e7840c2b64af8f5cdb7fd8c9430f0
+checksum=94ccfe03db917a91650000c510f7fd53f844da19f19ad4b4be1b8f6bc31a8d4c
 nocross=yes
 
-build_options="fdk_aac nvenc"
+build_options="fdk_aac nvenc qsv"
 
 case "$XBPS_TARGET_MACHINE" in
 	x86_64*|i686*)
 		CFLAGS="-msse"
-		build_options_default="nvenc"
+		build_options_default="nvenc qsv"
 		;;
 esac
 
@@ -37,7 +40,7 @@ pre_configure() {
 	# use system libraries, don't download them
 	rm -rf contrib/
 	for module in fdk-aac ffmpeg libbluray libdav1d libdvdnav libdvdread nvenc \
-		x265 zimg; do
+		x265 zimg svt-av1 libvpl; do
 	    vsed -i "/MODULES += contrib\/${module}/d" make/include/main.defs
 	done
 }

From 7f6b417812059a2c10d189861b931d1fe9e9e2f0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 038/113] hedgewars: revbump for ffmpeg4-4.4.3

---
 srcpkgs/hedgewars/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/hedgewars/template b/srcpkgs/hedgewars/template
index 94b6db673b0c3..402ccfaaecbc2 100644
--- a/srcpkgs/hedgewars/template
+++ b/srcpkgs/hedgewars/template
@@ -1,13 +1,13 @@
 # Template file for 'hedgewars'
 pkgname=hedgewars
 version=1.0.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DNOSERVER=1 -DDATA_INSTALL_DIR=/usr/share/${pkgname}
  -DPHYSFS_SYSTEM=1 -DMINIMAL_FLAGS=1"
 make_cmd=make
 hostmakedepends="lua51 pkg-config qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
+makedepends="ffmpeg4-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
  SDL2_mixer-devel SDL2_net-devel SDL2_ttf-devel"
 depends="libfreeglut"
 short_desc="Funny turn-based artillery game, featuring fighting Hedgehogs!"

From a992aa4af35521af599ae435e2d81eb1820e298f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 039/113] idjc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/idjc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/idjc/template b/srcpkgs/idjc/template
index a9cde0665d55b..6f1d21c5781fd 100644
--- a/srcpkgs/idjc/template
+++ b/srcpkgs/idjc/template
@@ -5,7 +5,7 @@ revision=5
 build_style=gnu-configure
 hostmakedepends="pkg-config git python3 automake gettext-devel libtool"
 makedepends="libvorbis-devel libogg-devel jack-devel libsamplerate-devel
- libflac-devel libsndfile-devel mpg123-devel ffmpeg-devel speex-devel
+ libflac-devel libsndfile-devel mpg123-devel ffmpeg4-devel speex-devel
  glib-devel pixman-devel lame-devel python3-gobject-devel libshout-idjc-devel
  opus-devel twolame-devel python3-mutagen python3-devel"
 depends="python3-gobject python3-mutagen desktop-file-utils shared-mime-info python3-dbus jack"

From c060b36268d2c0bc55f940244b5346834e9173c1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 040/113] kid3: revbump for ffmpeg-6.0

---
 srcpkgs/kid3/patches/ffmpeg5.patch | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 srcpkgs/kid3/patches/ffmpeg5.patch

diff --git a/srcpkgs/kid3/patches/ffmpeg5.patch b/srcpkgs/kid3/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..135fc50e07c9b
--- /dev/null
+++ b/srcpkgs/kid3/patches/ffmpeg5.patch
@@ -0,0 +1,17 @@
+# https://aur.archlinux.org/cgit/aur.git/diff/ffmpeg5.patch?h=kid3-cli&id=12410a74906612e7efc0ec8fbce739b4a0fef7e7
+diff --git a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+index e156d424..e12b9abd 100644
+--- a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
++++ b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+@@ -232,7 +232,11 @@ private:
+   friend class Format;
+   friend class Converter;
+   AVCodecContext* m_ptr;
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 0, 0)
+   AVCodec* m_impl;
++#else
++  const AVCodec* m_impl;
++#endif
+   AVFrame* m_frame;
+   bool m_opened;
+ };

From 2c2aed84b4bf65f4c1925efbf3e96f28ba8f5de7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 041/113] kodi: revbump for ffmpeg4-4.4.3

---
 srcpkgs/kodi/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kodi/template b/srcpkgs/kodi/template
index aa59324258a0d..6cf64dfb27294 100644
--- a/srcpkgs/kodi/template
+++ b/srcpkgs/kodi/template
@@ -54,7 +54,7 @@ makedepends="
  libmad-devel fontconfig-devel libXinerama-devel libsamplerate-devel libmms-devel
  enca-devel boost-devel libcurl-devel libva-devel libvdpau-devel libass-devel
  libbluetooth-devel yajl-devel libplist-devel librtmp-devel tinyxml-devel
- taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg-devel
+ taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg4-devel
  giflib-devel libxslt-devel gnutls-devel libssh-devel libmicrohttpd-devel
  libcec-devel dcadec-devel flatbuffers-devel fmt-devel lcms2-devel
  libfstrcmp-devel rapidjson libcdio-paranoia spdlog libwaylandpp-devel

From 7013ade2d930e91c11789c969739b98e28817fb7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 042/113] kpipewire: revbump for ffmpeg-6.0

---
 srcpkgs/kpipewire/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kpipewire/template b/srcpkgs/kpipewire/template
index 6214a4451336e..3555348659dde 100644
--- a/srcpkgs/kpipewire/template
+++ b/srcpkgs/kpipewire/template
@@ -1,7 +1,7 @@
 # Template file for 'kpipewire'
 pkgname=kpipewire
 version=5.27.10
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules plasma-wayland-protocols gettext
  qt5-qmake qt5-host-tools pkg-config wayland-devel kcoreaddons

From 0d55adb112a2d8e890411027ba45600fca5bba57 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 043/113] libextractor: revbump for ffmpeg4-4.4.3

---
 srcpkgs/libextractor/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libextractor/template b/srcpkgs/libextractor/template
index 044c663a3a0b9..ace88ae128da5 100644
--- a/srcpkgs/libextractor/template
+++ b/srcpkgs/libextractor/template
@@ -7,7 +7,7 @@ configure_args="--disable-static"
 hostmakedepends="pkg-config"
 makedepends="zlib-devel bzip2-devel exiv2-devel tiff-devel libpng-devel
  libjpeg-turbo-devel libvorbis-devel libflac-devel giflib-devel libmpeg2-devel
- ffmpeg-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
+ ffmpeg4-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
 short_desc="Library used to extract meta data from files"
 maintainer="Martin Riese <grauehaare@gmx.de>"
 license="GPL-3.0-or-later"

From 6505e510962364af0cb08335c53412f4fd9c90e1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 044/113] libopenal: revbump for ffmpeg-6.0

---
 srcpkgs/libopenal/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenal/template b/srcpkgs/libopenal/template
index 88d0f11307d81..8308fca0393e3 100644
--- a/srcpkgs/libopenal/template
+++ b/srcpkgs/libopenal/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenal'
 pkgname=libopenal
 version=1.23.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DALSOFT_EXAMPLES=OFF"
 hostmakedepends="pkg-config"

From 5b9a5744ddf0d4694763c87e98aaeefc5f3616d6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 045/113] loudgain: revbump for ffmpeg-6.0

---
 srcpkgs/loudgain/patches/ffmpeg5.patch | 11 +++++++++++
 srcpkgs/loudgain/template              |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/loudgain/patches/ffmpeg5.patch

diff --git a/srcpkgs/loudgain/patches/ffmpeg5.patch b/srcpkgs/loudgain/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..16d4510ee98fa
--- /dev/null
+++ b/srcpkgs/loudgain/patches/ffmpeg5.patch
@@ -0,0 +1,11 @@
+--- a/src/scan.c	2019-09-06 11:31:19.000000000 -0400
++++ b/src/scan.c	2023-03-23 11:15:40.867968521 -0400
+@@ -69,8 +69,6 @@
+ 	 * It is now useless
+ 	 * https://github.com/FFmpeg/FFmpeg/blob/70d25268c21cbee5f08304da95be1f647c630c15/doc/APIchanges#L86
+ 	 */
+-  if (avformat_version() < AV_VERSION_INT(58,9,100))
+-    av_register_all();
+ 
+ 	av_log_set_callback(scan_av_log);
+ 
diff --git a/srcpkgs/loudgain/template b/srcpkgs/loudgain/template
index da4f2d56e94c3..4d6bf29efb4fd 100644
--- a/srcpkgs/loudgain/template
+++ b/srcpkgs/loudgain/template
@@ -1,7 +1,7 @@
 # Template file for 'loudgain'
 pkgname=loudgain
 version=0.6.8
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libebur128-devel taglib-devel ffmpeg-devel"

From f811c2a620923b3677d9fc68fe521314d4fe6130 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 046/113] mediastreamer: revbump for ffmpeg4-4.4.3

---
 srcpkgs/mediastreamer/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mediastreamer/template b/srcpkgs/mediastreamer/template
index 0fcffa7653d18..92ada88743a9b 100644
--- a/srcpkgs/mediastreamer/template
+++ b/srcpkgs/mediastreamer/template
@@ -5,7 +5,7 @@ revision=2
 build_style=cmake
 configure_args="-DENABLE_STRICT=0 -DENABLE_UNIT_TESTS=0"
 hostmakedepends="python3"
-makedepends="bzrtp-devel ffmpeg-devel glew-devel libXv-devel libsrtp-devel
+makedepends="bzrtp-devel ffmpeg4-devel glew-devel libXv-devel libsrtp-devel
  libupnp-devel libvpx-devel mbedtls-devel opus-devel ortp-devel pulseaudio-devel
  libtheora-devel speex-devel v4l-utils-devel bcg729-devel bcmatroska2-devel libgsm-devel
  zxing-cpp-devel"

From d00a87eb11b08124b1c41d213becf0c478ac6bd2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 047/113] mgba: revbump for ffmpeg-6.0

---
 srcpkgs/mgba/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mgba/template b/srcpkgs/mgba/template
index 5513e3fd16f3f..f5c87a4893002 100644
--- a/srcpkgs/mgba/template
+++ b/srcpkgs/mgba/template
@@ -1,7 +1,7 @@
 # Template file for 'mgba'
 pkgname=mgba
 version=0.10.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake desktop-file-utils"
 makedepends="SDL2-devel ffmpeg-devel libedit-devel libepoxy-devel libmagick-devel

From e7f0a524b8b2c1359eb6958b9afe751ab123b974 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 048/113] mlt: revbump for ffmpeg4-4.4.3

---
 srcpkgs/mlt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mlt/template b/srcpkgs/mlt/template
index 73e3915aaab9a..ec5054be3b75e 100644
--- a/srcpkgs/mlt/template
+++ b/srcpkgs/mlt/template
@@ -8,7 +8,7 @@ configure_args="--prefix=/usr --libdir=/usr/lib$XBPS_TARGET_WORDSIZE
  --swig-languages=python"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which"
 # XXX: movit vid.stab
-makedepends="alsa-lib-devel ffmpeg-devel gtk+-devel jack-devel ladspa-sdk
+makedepends="alsa-lib-devel ffmpeg4-devel gtk+-devel jack-devel ladspa-sdk
  libexif-devel libsamplerate-devel libxml2-devel sox-devel SDL_image-devel
  fftw-devel frei0r-plugins python3-devel pulseaudio-devel movit-devel
  libvidstab-devel"

From b1bde6a381aca22cef7af0d127443a0d874b37e6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 049/113] moc: revbump for ffmpeg4-4.4.3

---
 srcpkgs/moc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/moc/template b/srcpkgs/moc/template
index 3a04932c8f1e6..d8de816026b64 100644
--- a/srcpkgs/moc/template
+++ b/srcpkgs/moc/template
@@ -4,7 +4,7 @@ version=2.5.2
 revision=7
 build_style=gnu-configure
 hostmakedepends="pkg-config"
-makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg-devel
+makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg4-devel
  jack-devel alsa-lib-devel libltdl-devel libflac-devel libvorbis-devel
  libmad-devel libmpcdec-devel libmodplug-devel libid3tag-devel faad2-devel
  taglib-devel libsndfile-devel wavpack-devel speex-devel libsamplerate-devel

From 0fa571194ff320cceab8fe0c197d28f0f76608ad Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 050/113] motion: revbump for ffmpeg-6.0

---
 srcpkgs/motion/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/motion/template b/srcpkgs/motion/template
index 607ebeb3c7b24..bf63a91d9764f 100644
--- a/srcpkgs/motion/template
+++ b/srcpkgs/motion/template
@@ -1,7 +1,7 @@
 # Template file for 'motion'
 pkgname=motion
 version=4.6.0
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake pkg-config gettext-devel tar"
 makedepends="ffmpeg-devel libmicrohttpd-devel v4l-utils-devel gettext-devel"

From d6390e8e07e8ab689a5918ec8d69d6f8d9d9b09b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 051/113] notcurses: revbump for ffmpeg-6.0

---
 srcpkgs/notcurses/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/notcurses/template b/srcpkgs/notcurses/template
index 6dd8a091319f7..3110c30c9aff2 100644
--- a/srcpkgs/notcurses/template
+++ b/srcpkgs/notcurses/template
@@ -1,7 +1,7 @@
 # Template file for 'notcurses'
 pkgname=notcurses
 version=3.0.9
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DUSE_STATIC=ON $(vopt_bool man USE_PANDOC)"
 hostmakedepends="pkg-config $(vopt_if man pandoc)"

From 62732de950ae007a1eb466ce08a86dc392494eda Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 052/113] olive: revbump for ffmpeg4-4.4.3

---
 srcpkgs/olive/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/olive/template b/srcpkgs/olive/template
index 12a46936c9900..5c2917b9c5124 100644
--- a/srcpkgs/olive/template
+++ b/srcpkgs/olive/template
@@ -1,10 +1,10 @@
 # Template file for 'olive'
 pkgname=olive
 version=0.1.2
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools pkg-config"
-makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg-devel frei0r-plugins"
+makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg4-devel frei0r-plugins"
 short_desc="Non-linear video editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"

From 8c397fab31b90938c6a8f5bf5ffc5dfe2755a40d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 053/113] omxplayer: revbump for ffmpeg4-4.4.3

---
 srcpkgs/omxplayer/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/omxplayer/template b/srcpkgs/omxplayer/template
index 9a66690c83ebb..a21b878878037 100644
--- a/srcpkgs/omxplayer/template
+++ b/srcpkgs/omxplayer/template
@@ -1,7 +1,7 @@
 # Template file for 'omxplayer'
 pkgname=omxplayer
 version=20190102
-revision=2
+revision=3
 short_desc="Commandline OMX player for the Raspberry Pi"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
@@ -15,7 +15,7 @@ checksum=af2d9450f8947842ea8c401fe9f71eec444013ebbdee29f2ac828c9c493c1329
 archs="armv6l* armv7l*"
 build_style=gnu-makefile
 hostmakedepends="ruby-ronn pkg-config"
-makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg-devel dbus-devel"
+makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg4-devel dbus-devel"
 depends="freefont-ttf"
 
 do_build() {

From af5c02308bd78ca55a933dad0926c19d38809e0f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 054/113] opentoonz: revbump for ffmpeg-6.0

---
 srcpkgs/opentoonz/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/opentoonz/template b/srcpkgs/opentoonz/template
index ee9f7603f55fd..3e81834ca0edd 100644
--- a/srcpkgs/opentoonz/template
+++ b/srcpkgs/opentoonz/template
@@ -1,7 +1,7 @@
 # Template file for 'opentoonz'
 pkgname=opentoonz
 version=1.6.0
-revision=2
+revision=3
 build_wrksrc="toonz/sources"
 build_style=cmake
 make_cmd=make

From df8da8ba9616b5021d53e2e94dcac252baa10612 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 055/113] pianobar: revbump for ffmpeg-6.0

---
 srcpkgs/pianobar/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pianobar/template b/srcpkgs/pianobar/template
index e3febb821a451..1e3dc1bf9308e 100644
--- a/srcpkgs/pianobar/template
+++ b/srcpkgs/pianobar/template
@@ -1,7 +1,7 @@
 # Template file for 'pianobar'
 pkgname=pianobar
 version=2022.04.01
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="V=1"
 hostmakedepends="pkg-config"

From dce8e7ce441ebe2ecc6a3dfd8df01b233a8c71c3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 056/113] ppsspp: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ppsspp/template | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/ppsspp/template b/srcpkgs/ppsspp/template
index 2c0ded496eb98..1294ef3ae669c 100644
--- a/srcpkgs/ppsspp/template
+++ b/srcpkgs/ppsspp/template
@@ -1,7 +1,7 @@
 # Template file for 'ppsspp'
 pkgname=ppsspp
 version=1.16.6
-revision=1
+revision=2
 _glslang_commit=b34f619e1c85810dcb3c578107d2e48ba4ee2b37
 _SPIRV_Cross_commit=4212eef67ed0ca048cb726a6767185504e7695e5
 _armips_commit=7bd1ec93d4586985ba1ef420b43b5e620f68695e
@@ -15,7 +15,7 @@ configure_args="-DHEADLESS=1 -DUSE_SYSTEM_FFMPEG=1 -DUNITTEST=ON
  -DUSING_QT_UI=$(vopt_if qt ON OFF) -DUSE_SYSTEM_ZSTD=ON
  -DARMIPS_USE_STD_FILESYSTEM=ON"
 hostmakedepends="pkg-config python3 $(vopt_if qt qt5-host-tools)"
-makedepends="zlib-devel glew-devel ffmpeg-devel libzip-devel
+makedepends="zlib-devel glew-devel ffmpeg4-devel libzip-devel
  snappy-devel rapidjson libpng-devel libzstd-devel
  $(vopt_if sdl2 'SDL2_ttf-devel SDL2-devel') $(vopt_if wayland wayland-devel)
  $(vopt_if qt 'qt5-devel qt5-multimedia-devel')"
@@ -72,7 +72,7 @@ post_extract() {
         mv ${wrksrc}/rcheevos-${_rcheevos_commit} ${wrksrc}/ext/rcheevos
 }
 
-post_patch(){
+post_patch() {
 	# disable git versioning
 	vsed -e 's|find_package(Git)|# &|' -i git-version.cmake
 }
@@ -85,7 +85,6 @@ post_configure() {
 }
 
 do_install() {
-	vlicense LICENSE.TXT
 	vinstall icons/icon.svg 644 usr/share/pixmaps ppsspp.svg
 	vinstall Qt/PPSSPP.desktop 644 usr/share/applications
 	vbin build/PPSSPPHeadless ppsspp-headless

From 810964db503ad934e036b53f866d71cb7e305092 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 057/113] pqiv: revbump for ffmpeg-6.0

---
 srcpkgs/pqiv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pqiv/template b/srcpkgs/pqiv/template
index 542fc27a2d32a..9308d949b6a1c 100644
--- a/srcpkgs/pqiv/template
+++ b/srcpkgs/pqiv/template
@@ -1,7 +1,7 @@
 # Template file for 'pqiv'
 pkgname=pqiv
 version=2.12
-revision=1
+revision=2
 build_style=gnu-makefile
 hostmakedepends="pkg-config"
 makedepends="glib-devel gtk+3-devel $(vopt_if ffmpeg ffmpeg-devel)

From 16b9024cc6cac8f09055232b446784f3e5991070 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 058/113] qmmp: revbump for ffmpeg-6.0

---
 srcpkgs/qmmp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qmmp/template b/srcpkgs/qmmp/template
index 53781ea3bc28a..2da07f1e87eac 100644
--- a/srcpkgs/qmmp/template
+++ b/srcpkgs/qmmp/template
@@ -1,7 +1,7 @@
 # Template file for 'qmmp'
 pkgname=qmmp
 version=1.6.1
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DUSE_HAL:BOOL=FALSE -DQMMP_DEFAULT_UI:STRING=simple"
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From 64a1456356eb5aed7e3c6d5ad43f9ec69ede5e24 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 14 Dec 2023 13:28:10 -0500
Subject: [PATCH 059/113] qt6-pdf: revbump for ffmpeg-6.0

---
 srcpkgs/qt6-pdf/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-pdf/template b/srcpkgs/qt6-pdf/template
index ecda84afac131..531b4e1d4fe84 100644
--- a/srcpkgs/qt6-pdf/template
+++ b/srcpkgs/qt6-pdf/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-pdf'
 pkgname=qt6-pdf
 version=6.6.0
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DQT_FEATURE_qtpdf_build=ON
  -DQT_FEATURE_qtpdf_widgets_build=ON

From cda03c8ae50176fa8caf082771fb5c4cd89506df Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 060/113] qt5-webengine: revbump for ffmpeg-6.0

---
 .../chromium-media-filters-cpp14.patch        |  11 ++
 srcpkgs/qt5-webengine/patches/ffmpeg5.patch   | 179 ++++++++++++++++++
 .../qtwebengine-fix-ffmpeg5-build.patch       |  14 ++
 srcpkgs/qt5-webengine/template                |   4 +-
 4 files changed, 206 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/ffmpeg5.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch

diff --git a/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
new file mode 100644
index 0000000000000..04adc540f2cbc
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
@@ -0,0 +1,11 @@
+--- a/src/3rdparty/chromium/media/filters/BUILD.gn	2023-02-27 13:32:59.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/BUILD.gn	2023-04-02 17:21:39.204066384 -0400
+@@ -96,6 +96,8 @@
+     "//ui/gfx/geometry:geometry",
+   ]
+ 
++  cflags_cc = [ "-std=c++14" ]
++
+   libs = []
+ 
+   if (proprietary_codecs) {
diff --git a/srcpkgs/qt5-webengine/patches/ffmpeg5.patch b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..ac55e1634423a
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
@@ -0,0 +1,179 @@
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:57.732547446 -0400
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:09.486478995 -0400
+@@ -57,6 +57,8 @@
+ 
+ namespace {
+ 
++constexpr int64_t kRelativeTsBase = static_cast<int64_t>(0x7ffeffffffffffff);
++
+ void SetAVStreamDiscard(AVStream* stream, AVDiscard discard) {
+   DCHECK(stream);
+   stream->discard = discard;
+@@ -90,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+   if (stream->start_time != kNoFFmpegTimestamp)
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (stream->first_dts != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, stream->first_dts);
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -408,11 +398,11 @@
+   scoped_refptr<DecoderBuffer> buffer;
+ 
+   if (type() == DemuxerStream::TEXT) {
+-    int id_size = 0;
++    size_t id_size = 0;
+     uint8_t* id_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
+ 
+-    int settings_size = 0;
++    size_t settings_size = 0;
+     uint8_t* settings_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
+ 
+@@ -424,7 +414,7 @@
+     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
+                                      side_data.data(), side_data.size());
+   } else {
+-    int side_data_size = 0;
++    size_t side_data_size = 0;
+     uint8_t* side_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
+ 
+@@ -485,7 +475,7 @@
+                                        packet->size - data_offset);
+     }
+ 
+-    int skip_samples_size = 0;
++    size_t skip_samples_size = 0;
+     const uint32_t* skip_samples_ptr =
+         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
+             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
+@@ -1587,6 +1577,8 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++      continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+       lowest_start_time_stream = stream.get();
+@@ -1604,6 +1596,8 @@
+     if (stream && stream->type() == DemuxerStream::VIDEO &&
+         stream->IsEnabled()) {
+       video_stream = stream.get();
++      if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++        continue;
+       if (video_stream->start_time() <= seek_time) {
+         return video_stream;
+       }
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h qtwebengine-5.15.10/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h
+--- a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-07-11 22:12:47.917192788 -0500
+@@ -29,6 +29,7 @@ extern "C" {
+ #include <libavformat/avformat.h>
+ #include <libavformat/avio.h>
+ #include <libavutil/avutil.h>
++#include <libavutil/channel_layout.h>
+ #include <libavutil/imgutils.h>
+ #include <libavutil/log.h>
+ #include <libavutil/mastering_display_metadata.h>
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/audio_file_reader.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/audio_file_reader.cc
+--- a/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -85,7 +85,7 @@ bool AudioFileReader::OpenDemuxer() {
+ }
+ 
+ bool AudioFileReader::OpenDecoder() {
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (codec) {
+     // MP3 decodes to S16P which we don't support, tell it to use S16 instead.
+     if (codec_context_->sample_fmt == AV_SAMPLE_FMT_S16P)
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -329,7 +329,7 @@ bool FFmpegAudioDecoder::ConfigureDecode
+     }
+   }
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec ||
+       avcodec_open2(codec_context_.get(), codec, &codec_options) < 0) {
+     DLOG(ERROR) << "Could not initialize audio decoder: "
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -59,7 +59,6 @@ static int64_t AVIOSeekOperation(void* o
+ }
+ 
+ void FFmpegGlue::InitializeFFmpeg() {
+-  av_register_all();
+ }
+ 
+ static void LogContainer(bool is_local_file,
+@@ -95,9 +94,6 @@ FFmpegGlue::FFmpegGlue(FFmpegURLProtocol
+   // Enable fast, but inaccurate seeks for MP3.
+   format_context_->flags |= AVFMT_FLAG_FAST_SEEK;
+ 
+-  // Ensures we can read out various metadata bits like vp8 alpha.
+-  format_context_->flags |= AVFMT_FLAG_KEEP_SIDE_DATA;
+-
+   // Ensures format parsing errors will bail out. From an audit on 11/2017, all
+   // instances were real failures. Solves bugs like http://crbug.com/710791.
+   format_context_->error_recognition |= AV_EF_EXPLODE;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -391,7 +391,7 @@ bool FFmpegVideoDecoder::ConfigureDecode
+   if (decode_nalus_)
+     codec_context_->flags2 |= AV_CODEC_FLAG2_CHUNKS;
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
+     ReleaseFFmpegResources();
+     return false;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/media_file_checker.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/media_file_checker.cc
+--- a/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -68,7 +68,7 @@ bool MediaFileChecker::Start(base::TimeD
+       auto context = AVStreamToAVCodecContext(format_context->streams[i]);
+       if (!context)
+         continue;
+-      AVCodec* codec = avcodec_find_decoder(cp->codec_id);
++      const AVCodec* codec = avcodec_find_decoder(cp->codec_id);
+       if (codec && avcodec_open2(context.get(), codec, nullptr) >= 0) {
+         auto loop = std::make_unique<FFmpegDecodingLoop>(context.get());
+         stream_contexts[i] = {std::move(context), std::move(loop)};
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc qtwebengine-5.15.10/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc
+--- a/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -203,7 +203,7 @@ int32_t H264DecoderImpl::InitDecode(cons
+   // a pointer |this|.
+   av_context_->opaque = this;
+ 
+-  AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
+   if (!codec) {
+     // This is an indication that FFmpeg has not been initialized or it has not
+     // been compiled/initialized with the correct set of codecs.
diff --git a/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch b/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch
new file mode 100644
index 0000000000000..bc24d5b9a29cb
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch
@@ -0,0 +1,14 @@
+--- a/src/buildtools/configure.json	2023-12-09 11:06:01.503058569 -0500
++++ b/src/buildtools/configure.json	2023-12-09 11:06:14.982361345 -0500
+@@ -779,11 +779,6 @@
+             "type": "warning",
+             "condition": "config.ios && config.simulator && config.device && features.build-qtpdf",
+             "message": "Building fat libray with device and simulator architectures will disable NEON."
+-        },
+-        {
+-            "type": "fatal",
+-            "condition": "features.webengine-system-ffmpeg && !libs.webengine-ffmpeg-support",
+-            "message": "Unmodified ffmpeg >= 5.0 is not supported. Please configure with -qt-webengine-ffmpeg."
+         }
+     ],
+     "summary": [
diff --git a/srcpkgs/qt5-webengine/template b/srcpkgs/qt5-webengine/template
index 8d2df1b5175ba..1687a77eb8a2f 100644
--- a/srcpkgs/qt5-webengine/template
+++ b/srcpkgs/qt5-webengine/template
@@ -1,14 +1,14 @@
 # Template file for 'qt5-webengine'
 pkgname=qt5-webengine
 version=5.15.16
-revision=1
+revision=2
 _version="${version}-lts"
 _chromium_commit=207c2ac45ca3386d153770c6b0d2ea2ec21ca880
 archs="x86_64* i686* armv[67]* ppc64* aarch64*"
 create_wrksrc=yes
 build_style=qmake
 configure_args="--
- -webengine-icu -webengine-ffmpeg -webengine-opus -webengine-webp
+ -webengine-icu -system-ffmpeg -webengine-opus -webengine-webp
  -webengine-pepper-plugins -webengine-printing-and-pdf -webengine-proprietary-codecs
  -webengine-pulseaudio -webengine-spellchecker -webengine-webrtc -webengine-geolocation
  -webengine-kerberos -no-webengine-embedded-build $(vopt_if sndio '' '-no')-webengine-sndio

From fbf626b7ac81e9e1436c941864a26c6b1c3e1b3f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 061/113] qt5: revbump for ffmpeg-6.0

---
 srcpkgs/qt5/template | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/srcpkgs/qt5/template b/srcpkgs/qt5/template
index ef6e437e02dbc..771872a54d67c 100644
--- a/srcpkgs/qt5/template
+++ b/srcpkgs/qt5/template
@@ -5,7 +5,7 @@ pkgname=qt5
 version=5.15.11+20231124
 # commit 4765fa1df7a837db9c1f89c4da0dd76b74bb5fab
 # base repo: https://invent.kde.org/qt/qt/qt5
-revision=1
+revision=2
 build_style=meta
 hostmakedepends="cmake clang flex perl glib-devel pkg-config
  python3 re2c ruby which"
@@ -246,7 +246,6 @@ do_configure() {
 	# opts+=" -v"
 	opts+=" -skip qtwebengine"
 	opts+=" -skip qtwebview"
-	opts+=" -skip qtdocgallery"
 	opts+=" -skip qtpim"
 	opts+=" -skip qtsystems"
 	opts+=" -skip qtspeech"

From 8693f4e157c6b192a60865acab1f5e8864d4176e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 062/113] qtav: revbump for ffmpeg4-4.4.3

---
 srcpkgs/qtav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qtav/template b/srcpkgs/qtav/template
index 775d5a139a9ef..2d00ad104355e 100644
--- a/srcpkgs/qtav/template
+++ b/srcpkgs/qtav/template
@@ -4,7 +4,7 @@ version=1.13.0
 revision=2
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel libass-devel libopenal-devel
+makedepends="ffmpeg4-devel libass-devel libopenal-devel
  libva-glx-devel libXv-devel pulseaudio-devel
  qt5-declarative-devel qt5-svg-devel
  qt5-quickcontrols"

From bb9061c7e26e2671dc369efce64d20eebc7a84ad Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 063/113] qtox: revbump for ffmpeg-6.0

---
 srcpkgs/qtox/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qtox/template b/srcpkgs/qtox/template
index 39c643fecdb5a..bb70e7f51240a 100644
--- a/srcpkgs/qtox/template
+++ b/srcpkgs/qtox/template
@@ -1,7 +1,7 @@
 # Template file for 'qtox'
 pkgname=qtox
 version=1.17.6
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DUPDATE_CHECK=OFF
  -DGIT_DESCRIBE=${version}

From 8e40366c8c5b19e4f1fef6b5f02739818e68efbb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 064/113] retroarch: revbump for ffmpeg-6.0

---
 srcpkgs/retroarch/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroarch/template b/srcpkgs/retroarch/template
index cb3125c5dbf1a..c65c26f7bf033 100644
--- a/srcpkgs/retroarch/template
+++ b/srcpkgs/retroarch/template
@@ -1,7 +1,7 @@
 # Template file for 'retroarch'
 pkgname=retroarch
 version=1.16.0.3
-revision=3
+revision=4
 build_style=configure
 configure_args="--prefix=/usr --sysconfdir=/etc --enable-networking
  --enable-udev --disable-builtinflac --disable-builtinglslang

From ce375175d2dd509785cc14d35de1f6826be5c1ee Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 065/113] scrcpy: revbump for ffmpeg-6.0

---
 srcpkgs/scrcpy/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/scrcpy/template b/srcpkgs/scrcpy/template
index ac18bc03418ce..f39a7f678ab35 100644
--- a/srcpkgs/scrcpy/template
+++ b/srcpkgs/scrcpy/template
@@ -1,7 +1,7 @@
 # Template file for 'scrcpy'
 pkgname=scrcpy
 version=2.1.1
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcompile_server=false
  -Dprebuilt_server=/usr/share/scrcpy/scrcpy-server-v${version}"

From e8393cb75e31e69b4e91ec36ceac59ad68334a2c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 17 Oct 2023 08:54:11 -0400
Subject: [PATCH 066/113] New package: spex-x replaces spek-alternative for
 ffmpeg-6.0

---
 srcpkgs/spek-alternative                      |  1 +
 srcpkgs/{spek-alternative => spek-x}/template | 22 ++++++++++++-------
 2 files changed, 15 insertions(+), 8 deletions(-)
 create mode 120000 srcpkgs/spek-alternative
 rename srcpkgs/{spek-alternative => spek-x}/template (52%)

diff --git a/srcpkgs/spek-alternative b/srcpkgs/spek-alternative
new file mode 120000
index 0000000000000..76648236da701
--- /dev/null
+++ b/srcpkgs/spek-alternative
@@ -0,0 +1 @@
+spek-x
\ No newline at end of file
diff --git a/srcpkgs/spek-alternative/template b/srcpkgs/spek-x/template
similarity index 52%
rename from srcpkgs/spek-alternative/template
rename to srcpkgs/spek-x/template
index d7b55c776b1d4..3ded6c2c323e4 100644
--- a/srcpkgs/spek-alternative/template
+++ b/srcpkgs/spek-x/template
@@ -1,18 +1,18 @@
-# Template file for 'spek-alternative'
-pkgname=spek-alternative
-version=0.8.2.3
-revision=2
+# Template file for 'spek-x'
+pkgname=spek-x
+version=0.9.3
+revision=1
 build_style=gnu-configure
 hostmakedepends="automake gettext-devel intltool libtool pkg-config
  wxWidgets-common wxWidgets-gtk3-devel"
 makedepends="ffmpeg-devel wxWidgets-gtk3-devel"
 depends="ffmpeg"
 short_desc="Acoustic spectrum analyser"
-maintainer="Kartik Singh <kartik.ynwa@gmail.com>"
+maintainer="zlice <zlice555@gmail.com>"
 license="GPL-3.0-or-later"
-homepage="https://github.com/withmorten/spek-alternative"
-distfiles="https://github.com/withmorten/spek-alternative/archive/${version}.tar.gz"
-checksum="007ba4b84a310b078e378aa84c8e80783db5821437a757a488c3ecec377e6b2a"
+homepage="https://github.com/MikeWang000000/spek-x"
+distfiles="https://github.com/MikeWang000000/spek-x/archive/v${version}.tar.gz"
+checksum="7f4b109903333cdd310ab2b9176f0dc49a565891376e281a233d342cedf90ef7"
 
 CXXFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
 
@@ -22,3 +22,9 @@ export WX_CONFIG_NAME="wx-config-gtk3"
 pre_configure() {
 	NOCONFIGURE=1 ./autogen.sh
 }
+
+spek-alternative_package() {
+	depends="spek-x"
+	short_desc+=" - transitional dummy package"
+	build_style=meta
+}

From 6fe6ba17e4b4e6fa1679aa1f89aeee17c48d82a1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 067/113] ssr: revbump for ffmpeg4-4.4.3

---
 srcpkgs/ssr/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ssr/template b/srcpkgs/ssr/template
index 842b2423aad10..3448ca110eb0c 100644
--- a/srcpkgs/ssr/template
+++ b/srcpkgs/ssr/template
@@ -5,7 +5,7 @@ revision=2
 build_style=cmake
 configure_args="-DWITH_QT5=ON"
 hostmakedepends="pkg-config"
-makedepends="alsa-lib-devel ffmpeg-devel glu-devel jack-devel pulseaudio-devel
+makedepends="alsa-lib-devel ffmpeg4-devel glu-devel jack-devel pulseaudio-devel
  qt5-tools-devel qt5-x11extras-devel libXinerama-devel v4l-utils-devel"
 depends="desktop-file-utils hicolor-icon-theme"
 short_desc="Simple Screen Recorder for programs and games"

From d8fbd745a8d8cdbbb4b4348bdbf1fc920b44de15 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 068/113] synfig: revbump for ffmpeg-6.0 and mlt7

---
 srcpkgs/synfig/patches/ffmpeg6.patch | 71 ++++++++++++++++++++++++++++
 srcpkgs/synfig/template              |  4 +-
 2 files changed, 73 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/synfig/patches/ffmpeg6.patch

diff --git a/srcpkgs/synfig/patches/ffmpeg6.patch b/srcpkgs/synfig/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..10780b42782f4
--- /dev/null
+++ b/srcpkgs/synfig/patches/ffmpeg6.patch
@@ -0,0 +1,71 @@
+--- a/src/modules/mod_libavcodec/trgt_av.cpp	2022-10-25 09:14:12.000000000 -0400
++++ b/src/modules/mod_libavcodec/trgt_av.cpp	2023-05-05 21:34:17.899194559 -0400
+@@ -38,6 +41,7 @@
+ extern "C"
+ {
+ #ifdef HAVE_LIBAVFORMAT_AVFORMAT_H
++#	include <libavcodec/avcodec.h>
+ #	include <libavformat/avformat.h>
+ #elif defined(HAVE_AVFORMAT_H)
+ #	include <avformat.h>
+@@ -155,11 +156,11 @@
+     }
+ 
+ 	bool open_video_stream() {
+-		if (avcodec_open2(video_context, NULL, NULL) < 0) {
++		if (avcodec_open2(video_context, nullptr, nullptr) < 0) {
+ 			synfig::error("Target_LibAVCodec: could not open video codec");
+ 			// seems the calling of avcodec_free_context after error will cause crash
+ 			// so just forget about this context
+-			video_context = NULL;
++			video_context = nullptr;
+ 			close();
+ 			return false;
+         }
+@@ -234,15 +235,21 @@
+ 		close();
+ 
+ 		if (!av_registered) {
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 			av_register_all();
++#endif
+ 			av_registered = true;
+ 		}
+ 
+ 		// guess format
+-		AVOutputFormat *format = av_guess_format(NULL, filename.c_str(), NULL);
++#if LIBAVCODEC_VERSION_MAJOR < 59 // FFMPEG < 5.0
++		AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#else
++		const AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#endif
+ 		if (!format) {
+ 			synfig::warning("Target_LibAVCodec: unable to guess the output format, defaulting to MPEG");
+-			format = av_guess_format("mpeg", NULL, NULL);
++			format = av_guess_format("mpeg", nullptr, nullptr);
+ 		}
+ 		if (!format) {
+ 			synfig::error("Target_LibAVCodec: unable to find 'mpeg' output format");
+@@ -254,6 +261,7 @@
+ 		context = avformat_alloc_context();
+ 		assert(context);
+ 		context->oformat = format;
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 		if (filename.size() + 1 > sizeof(context->filename)) {
+ 			synfig::error(
+ 				"Target_LibAVCodec: filename too long, max length is %d, filename is '%s'",
+@@ -263,6 +271,14 @@
+ 			return false;
+ 		}
+ 		memcpy(context->filename, filename.c_str(), filename.size() + 1);
++#else
++		context->url = av_strndup(filename.c_str(), filename.size());
++		if (!context->url) {
++			synfig::error("Target_LibAVCodec: cannot allocate space for filename");
++			close();
++			return false;
++		}
++#endif
+ 
+ 		packet = av_packet_alloc();
+ 		assert(packet);
diff --git a/srcpkgs/synfig/template b/srcpkgs/synfig/template
index d4d3e341a20bf..703cfd7ebac84 100644
--- a/srcpkgs/synfig/template
+++ b/srcpkgs/synfig/template
@@ -6,7 +6,7 @@ revision=4
 build_style=gnu-configure
 configure_args="--with-boost-libdir=${XBPS_CROSS_BASE}/usr/lib"
 hostmakedepends="boost-build ImageMagick pkg-config intltool"
-makedepends="ETL gettext-devel libxml++-devel mlt-devel libmagick-devel
+makedepends="ETL gettext-devel libxml++-devel mlt7-devel libmagick-devel
  libmng-devel boost-build boost-devel libopenexr-devel ffmpeg-devel"
 depends="ImageMagick"
 short_desc="CLI 2D vector and timeline-based animation software"
@@ -20,7 +20,7 @@ CXXFLAGS="-std=c++11 -DHAVE_LOCALE_H=1"
 
 synfig-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision}
-	 libopenexr-devel libxml++-devel mlt-devel"
+	 libopenexr-devel libxml++-devel mlt7-devel"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/bin/synfig-config

From a4593690fcbba99d04c2bc0eede299660719d3c0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 069/113] timg: revbump for ffmpeg-6.0

---
 srcpkgs/timg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/timg/template b/srcpkgs/timg/template
index 2a2ab763d2fdd..8fb4327535ef9 100644
--- a/srcpkgs/timg/template
+++ b/srcpkgs/timg/template
@@ -1,7 +1,7 @@
 # Template file for 'timg'
 pkgname=timg
 version=1.4.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_OPENSLIDE_SUPPORT=off -Wno-dev"
 hostmakedepends="pkg-config git"

From d41ace62dc8225b0c913f453607661a9883117b7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 070/113] tvheadend: revbump for ffmpeg4-4.4.3

---
 srcpkgs/tvheadend/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tvheadend/template b/srcpkgs/tvheadend/template
index 9aea7de4ec705..012d31c4879ff 100644
--- a/srcpkgs/tvheadend/template
+++ b/srcpkgs/tvheadend/template
@@ -8,7 +8,7 @@ configure_args="--enable-dvbscan --disable-ffmpeg_static
 --disable-libx265_static --disable-libvpx_static --disable-libtheora_static
 --disable-libvorbis_static --disable-libfdkaac_static"
 hostmakedepends="gettext pkg-config python3 git which"
-makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg-devel"
+makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg4-devel"
 short_desc="TV streaming server"
 maintainer="lemmi <lemmi@nerd2nerd.org>"
 license="GPL-3.0-only"

From 428010bb80a368840ccf974d9c2f569bc8fd3ad1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 071/113] unpaper: update to 7.0.0.

---
 srcpkgs/unpaper/template | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/srcpkgs/unpaper/template b/srcpkgs/unpaper/template
index 38ed47a584016..1ff910e722afc 100644
--- a/srcpkgs/unpaper/template
+++ b/srcpkgs/unpaper/template
@@ -1,13 +1,13 @@
 # Template file for 'unpaper'
 pkgname=unpaper
-version=6.1
-revision=3
-build_style=gnu-configure
+version=7.0.0
+revision=1
+build_style=meson
+hostmakedepends="pkg-config meson libxslt"
+makedepends="ffmpeg-devel python3-Sphinx"
+short_desc="Post-processing tool for scanned sheets of paper"
 maintainer="Orphaned <orphan@voidlinux.org>"
-hostmakedepends="pkg-config libxslt"
-makedepends="ffmpeg-devel"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://www.flameeyes.eu/projects/unpaper"
-short_desc="A post-processing tool for scanned sheets of paper"
 distfiles="https://www.flameeyes.eu/files/${pkgname}-${version}.tar.xz"
-checksum=237c84f5da544b3f7709827f9f12c37c346cdf029b1128fb4633f9bafa5cb930
+checksum=2575fbbf26c22719d1cb882b59602c9900c7f747118ac130883f63419be46a80

From 0fa4593e9b176a611999c11ed7e57232b8f7bbd8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 072/113] vice: revbump for ffmpeg4-4.4.3

---
 srcpkgs/vice/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vice/template b/srcpkgs/vice/template
index b1f866d35095e..4beab2c5f9ebd 100644
--- a/srcpkgs/vice/template
+++ b/srcpkgs/vice/template
@@ -26,7 +26,7 @@ makedepends="
 	$(vopt_if gtk3 gtk+3-devel)
 	$(vopt_if gtk3 pulseaudio-devel)
 	$(vopt_if gtk3 pango-devel)
-	$(vopt_if ffmpeg ffmpeg-devel)"
+	$(vopt_if ffmpeg ffmpeg4-devel)"
 short_desc="Emulator for C64, C128, CBM-II, PET, VIC20, Plus4 and C16"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"

From 54a7608029c990e38e6509e68b854a7fabc1243e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 073/113] waypipe: revbump for ffmpeg-6.0

---
 srcpkgs/waypipe/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waypipe/template b/srcpkgs/waypipe/template
index 6da88b21bf2a1..4da8058400b58 100644
--- a/srcpkgs/waypipe/template
+++ b/srcpkgs/waypipe/template
@@ -1,7 +1,7 @@
 # Template file for 'waypipe'
 pkgname=waypipe
 version=0.8.6
-revision=1
+revision=2
 build_style=meson
 # lto is off because it causes linking errors in armv6l and armv7l (due to NEON)
 configure_args="-Dwerror=false -Dwith_dmabuf=enabled -Dwith_lz4=enabled

From ca484d9205b2d83ec225e7e3ecca01270fb69acb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 074/113] xpra: revbump for ffmpeg-6.0

---
 srcpkgs/xpra/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xpra/template b/srcpkgs/xpra/template
index 6bfe9be2db650..1eea2962bcb82 100644
--- a/srcpkgs/xpra/template
+++ b/srcpkgs/xpra/template
@@ -1,7 +1,7 @@
 # Template file for 'xpra'
 pkgname=xpra
 version=5.0.4
-revision=1
+revision=2
 build_style=python3-module
 make_build_args="--without-cuda_kernels --without-cuda_rebuild"
 make_install_args="$(vopt_with docs) ${make_build_args}"

From 4deb3c74460d468efbeb9096db5f66407c03013b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:07:40 -0400
Subject: [PATCH 075/113] nv-codec-headers: update to 12.0.16.0

---
 srcpkgs/nv-codec-headers/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/nv-codec-headers/template b/srcpkgs/nv-codec-headers/template
index 3d422a61e4891..251e057f826fb 100644
--- a/srcpkgs/nv-codec-headers/template
+++ b/srcpkgs/nv-codec-headers/template
@@ -1,6 +1,6 @@
 # Template file for 'nv-codec-headers'
 pkgname=nv-codec-headers
-version=11.1.5.1
+version=12.0.16.0
 revision=1
 build_style=gnu-makefile
 short_desc="FFmpeg version of headers required to interface with Nvidias codec APIs"
@@ -8,7 +8,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="MIT"
 homepage="http://git.videolan.org/?p=ffmpeg/nv-codec-headers.git"
 distfiles="https://github.com/FFmpeg/nv-codec-headers/archive/n${version}.tar.gz"
-checksum=d095fbd56aa93772471a323be0ebe65504a0f43f06c76a30b6d25da77b06ae9c
+checksum=2a1533b65f55f9da52956faf0627ed3b74868ac0c7f269990edd21369113b48f
 
 post_install() {
 	sed -n '4,25p' include/ffnvcodec/nvEncodeAPI.h > LICENSE

From 1fa923a1ed631533e199a166d34f49cacbec78fd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:08:40 -0400
Subject: [PATCH 076/113] openimagedenoise: revbump for ffmpeg-6.0

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index b792813dba7c2..109deb171c3f7 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,7 +1,7 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
 version=1.4.3
-revision=1
+revision=2
 archs="x86_64*"
 build_style=cmake
 hostmakedepends="ispc python3"

From 6849f016fdc467427f1d74751bd1e78d5a93de71 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:31:45 -0400
Subject: [PATCH 077/113] shotcut: revbump for ffmpeg-6.0

---
 srcpkgs/shotcut/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/shotcut/template b/srcpkgs/shotcut/template
index 33141fbd862d7..f46cb53b6bfb9 100644
--- a/srcpkgs/shotcut/template
+++ b/srcpkgs/shotcut/template
@@ -1,7 +1,7 @@
 # Template file for 'shotcut'
 pkgname=shotcut
 version=23.09.29
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSHOTCUT_VERSION=${version}"
 hostmakedepends="pkg-config qt6-tools-devel"

From 940ff1791207af7f142309f89f2cd47fac148e55 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:30 -0400
Subject: [PATCH 078/113] shiboken2: revbump for qt5-5.15.11

---
 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch | 1 +
 srcpkgs/shiboken2/template                                 | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
 create mode 120000 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
new file mode 120000
index 0000000000000..efcf3249bd885
--- /dev/null
+++ b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1 @@
+../../python3-pyside2/patches/importlib-machinery-bypass.patch
\ No newline at end of file
diff --git a/srcpkgs/shiboken2/template b/srcpkgs/shiboken2/template
index 883d6a084d868..f3c06ec245a1f 100644
--- a/srcpkgs/shiboken2/template
+++ b/srcpkgs/shiboken2/template
@@ -1,7 +1,7 @@
 # Template file for 'shiboken2'
 pkgname=shiboken2
 version=5.15.10
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/shiboken2"
 build_style=cmake

From 1d7f5f7d8f79ae4e992c58cc8b86f66114a97664 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:53 -0400
Subject: [PATCH 079/113] python3-pyside2: revbump for qt5-5.15.11

---
 .../patches/importlib-machinery-bypass.patch      | 15 +++++++++++++++
 srcpkgs/python3-pyside2/template                  |  2 +-
 2 files changed, 16 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
new file mode 100644
index 0000000000000..64c429584776b
--- /dev/null
+++ b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1,15 @@
+Using this prevents an error around line 220 below it.
+"AttributeError: module 'importlib' has no attribute 'machinery'"
+The old backup logic is in place and compiles without issues.
+--- a/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:09:34.688912402 -0400
++++ b/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:10:03.395529582 -0400
+@@ -170,9 +170,6 @@
+
+     # 'zipstring_sequence' comes from signature.cpp
+     zipbytes = base64.b64decode(''.join(zipstring_sequence))
+-    if sys.version_info[0] >= 3:
+-        vzip = zipfile.ZipFile(io.BytesIO(zipbytes))
+-        return sys.meta_path, EmbeddableZipImporter(vzip)
+
+     # Old version for Python 2.7, only.
+     import os
diff --git a/srcpkgs/python3-pyside2/template b/srcpkgs/python3-pyside2/template
index 249efa9098842..52626436ce75f 100644
--- a/srcpkgs/python3-pyside2/template
+++ b/srcpkgs/python3-pyside2/template
@@ -1,7 +1,7 @@
 # Template file for 'python3-pyside2'
 pkgname=python3-pyside2
 version=5.15.10
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/pyside2"
 build_style=cmake

From 32fd4d9e79442d41971999dfcec3a930145f0c64 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:35 -0400
Subject: [PATCH 080/113] konqueror: revbump for ffmpeg-6.0

---
 srcpkgs/konqueror/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/konqueror/template b/srcpkgs/konqueror/template
index abfa59e6b7ded..3cc29c12dc1db 100644
--- a/srcpkgs/konqueror/template
+++ b/srcpkgs/konqueror/template
@@ -1,11 +1,11 @@
 # Template file for 'konqueror'
 pkgname=konqueror
 version=23.08.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DDESKTOPTOJSON_EXECUTABLE=/usr/bin/desktoptojson"
 hostmakedepends="extra-cmake-modules python3 qt5-host-tools qt5-qmake kdoctools
-kcoreaddons kconfig gettext"
+ kcoreaddons kconfig gettext"
 makedepends="qt5-devel qt5-webengine-devel qt5-declarative-devel
  qt5-webchannel-devel qt5-location-devel kcmutils-devel kdelibs4support-devel
  karchive-devel khtml-devel kdesu-devel kactivities5-devel"

From e81a47d86cc8b34c471521fa06efdeec083fd9e8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:58 -0400
Subject: [PATCH 081/113] qt5-speech: revbump for qt5-5.15.11

---
 srcpkgs/qt5-speech/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-speech/template b/srcpkgs/qt5-speech/template
index 3ecd10d50650c..2d7d4d4d24535 100644
--- a/srcpkgs/qt5-speech/template
+++ b/srcpkgs/qt5-speech/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-speech'
 pkgname=qt5-speech
 version=5.15.7
-revision=2
+revision=3
 _commit=d32f4a479d38a11f547598004b975f4356424a16
 build_style=qmake
 configure_args="-- -flite -flite-alsa -speechd"

From 65b460f2c1df23171f203a4f313e8f1688ed2a48 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Jun 2023 08:20:22 -0400
Subject: [PATCH 082/113] gtk4: revbump for ffmpeg-6.0

---
 srcpkgs/gtk4/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gtk4/template b/srcpkgs/gtk4/template
index 6a4e20357a86f..ec0c13d2cc5b0 100644
--- a/srcpkgs/gtk4/template
+++ b/srcpkgs/gtk4/template
@@ -1,7 +1,7 @@
 # Template file for 'gtk4'
 pkgname=gtk4
 version=4.12.3
-revision=1
+revision=2
 build_style=meson
 build_helper="gir"
 configure_args="-Dman-pages=true -Ddocumentation=true -Dbuild-tests=false

From f5d5c6ec83ecb0a9925d425b1e84607d369e1f3b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:28:26 -0400
Subject: [PATCH 083/113] siril: revbump for ffmpeg-6.0

---
 srcpkgs/siril/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/siril/template b/srcpkgs/siril/template
index 84332f79d060d..62750dd247548 100644
--- a/srcpkgs/siril/template
+++ b/srcpkgs/siril/template
@@ -1,7 +1,7 @@
 # Template file for 'siril'
 pkgname=siril
 version=0.9.12
-revision=10
+revision=11
 build_style=gnu-configure
 hostmakedepends="pkg-config intltool autoconf automake gettext-devel"
 makedepends="fftw-devel libconfig-devel libopencv-devel libffms2-devel

From 7901b1776b8f0725703b0f94f706d21c919e8ac4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 22 Jun 2023 10:25:02 -0400
Subject: [PATCH 084/113] kdenlive: revbump for ffmpeg-6.0

---
 srcpkgs/kdenlive/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kdenlive/template b/srcpkgs/kdenlive/template
index ec5fe75860948..e69ecff31f272 100644
--- a/srcpkgs/kdenlive/template
+++ b/srcpkgs/kdenlive/template
@@ -1,7 +1,7 @@
 # Template file for 'kdenlive'
 pkgname=kdenlive
 version=23.08.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="
  extra-cmake-modules kconfig kcoreaddons kdoctools pkg-config python3

From 6a7e9373e21dd489886222578061652bc2389614 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:20:59 -0400
Subject: [PATCH 085/113] tracker-miners: revbump for ffmpeg-6.0

---
 srcpkgs/tracker-miners/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tracker-miners/template b/srcpkgs/tracker-miners/template
index 0b97f47489f81..f196d2bf9e4a4 100644
--- a/srcpkgs/tracker-miners/template
+++ b/srcpkgs/tracker-miners/template
@@ -1,7 +1,7 @@
 # Template file for 'tracker-miners'
 pkgname=tracker-miners
 version=3.6.1
-revision=1
+revision=2
 build_style=meson
 build_helper=qemu
 # missing libgrss for miner_rss

From 7905278edbfac78f17bcb31d77da0f9af001d272 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:21:21 -0400
Subject: [PATCH 086/113] mpd: revbump for ffmpeg-6.0

---
 srcpkgs/mpd/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpd/template b/srcpkgs/mpd/template
index 645c1b778e407..60287cc9f6e3c 100644
--- a/srcpkgs/mpd/template
+++ b/srcpkgs/mpd/template
@@ -1,7 +1,7 @@
 # Template file for 'mpd'
 pkgname=mpd
 version=0.23.14
-revision=3
+revision=4
 build_style=meson
 configure_args="-Dopus=enabled -Dmikmod=enabled -Dneighbor=true
  -Dsoundcloud=enabled -Dpipe=true -Dtwolame=enabled -Dbzip2=enabled

From 8e2e36b2bab4546556bc6729555a066555f24a99 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:02 -0400
Subject: [PATCH 087/113] tg_owt: revbump for ffmpeg-6.0

---
 srcpkgs/tg_owt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tg_owt/template b/srcpkgs/tg_owt/template
index 50bc8310b8859..c93262d5c5de6 100644
--- a/srcpkgs/tg_owt/template
+++ b/srcpkgs/tg_owt/template
@@ -1,7 +1,7 @@
 # Template file for 'tg_owt'
 pkgname=tg_owt
 version=0.0.0.20230921
-revision=1
+revision=2
 _commit=3bb3d757681e6cc5135aec6529a753dc3dcdcfb9
 _libyuv_commit=04821d1e7d60845525e8db55c7bcd41ef5be9406
 _abseil_commit=8c0b94e793a66495e0b1f34a5eb26bd7dc672db0

From 1ac87abb58d65459da8bbe62dc6e8ba7aec032c0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:44 -0400
Subject: [PATCH 088/113] telegram-desktop: revbump for ffmpeg-6.0

---
 srcpkgs/telegram-desktop/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/telegram-desktop/template b/srcpkgs/telegram-desktop/template
index 9bd94ce3781ff..d33fc62b10e38 100644
--- a/srcpkgs/telegram-desktop/template
+++ b/srcpkgs/telegram-desktop/template
@@ -1,7 +1,7 @@
 # Template file for 'telegram-desktop'
 pkgname=telegram-desktop
 version=4.11.2
-revision=1
+revision=2
 build_style=cmake
 build_helper="qemu gir"
 configure_args="-DTDESKTOP_API_ID=209235

From 3897558ee5b3130c143db4e74e58036b62ce60fe Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:11:45 -0400
Subject: [PATCH 089/113] gst-plugins-bad1: revbump for ffmpeg-6.0

---
 srcpkgs/gst-plugins-bad1/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index fcd3538cd5cde..976e2889b588e 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-plugins-bad1'
 pkgname=gst-plugins-bad1
 version=1.22.7
-revision=1
+revision=2
 build_helper="gir"
 build_style=meson
 configure_args="-Dpackage-origin=https://voidlinux.org -Ddoc=disabled

From 4902b3e456ad63ec20d17d7d993881d929c2e64f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:12:09 -0400
Subject: [PATCH 090/113] openmw: revbump for ffmpeg-6.0

---
 srcpkgs/openmw/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openmw/template b/srcpkgs/openmw/template
index 0abf5ff7cdbec..b57180f1a4446 100644
--- a/srcpkgs/openmw/template
+++ b/srcpkgs/openmw/template
@@ -1,7 +1,7 @@
 # Template file for 'openmw'
 pkgname=openmw
 version=0.48.0
-revision=2
+revision=3
 build_style=cmake
 _recast_commit=e75adf86f91eb3082220085e42dda62679f9a3ea
 _bullet_tag=3.17

From 32698e9199c567085f3e9bfdc2dd5f29d8fbdb5a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:14:53 -0400
Subject: [PATCH 091/113] lms: revbump for ffmpeg-6.0

---
 srcpkgs/lms/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/lms/template b/srcpkgs/lms/template
index e358f75902a98..3b21c458de519 100644
--- a/srcpkgs/lms/template
+++ b/srcpkgs/lms/template
@@ -1,7 +1,7 @@
 # Template file for 'lms'
 pkgname=lms
 version=3.42.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="wt-devel ffmpeg-devel boost-devel libconfig++-devel taglib-devel pam-devel libgraphicsmagick-devel gtest-devel libarchive-devel"

From 1dcb158cb890b64a684563c612dcde64b09936c3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:18:18 -0400
Subject: [PATCH 092/113] freecad: DELETE

---
 srcpkgs/freecad/patches/001-include.patch     | 112 ------------------
 .../154-revert-gui-tmp-redirect-stderr.patch  |  68 -----------
 ...d63c8c9b1280978be841d04e68a0a55cceb9.patch |  30 -----
 srcpkgs/freecad/template                      |  12 +-
 4 files changed, 7 insertions(+), 215 deletions(-)
 delete mode 100644 srcpkgs/freecad/patches/001-include.patch
 delete mode 100644 srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
 delete mode 100644 srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch

diff --git a/srcpkgs/freecad/patches/001-include.patch b/srcpkgs/freecad/patches/001-include.patch
deleted file mode 100644
index 28b5af54999b9..0000000000000
--- a/srcpkgs/freecad/patches/001-include.patch
+++ /dev/null
@@ -1,112 +0,0 @@
-From 9a41845a417189776741297c50a3827ce292bc4f Mon Sep 17 00:00:00 2001
-From: Uwe <donovaly@users.noreply.github.com>
-Date: Sun, 3 Jul 2022 22:51:16 +0200
-Subject: [PATCH] [Part] OCCError.h: remove unneeded includes
-
-- also sort includes
----
- src/Mod/Part/App/OCCError.h             | 36 +++----------------------
- src/Mod/Part/App/OffsetCurvePyImp.cpp   | 12 ++++-----
- src/Mod/Part/App/OffsetSurfacePyImp.cpp | 10 +++----
- 3 files changed, 12 insertions(+), 46 deletions(-)
-
---- a/src/Mod/Part/App/OCCError.h
-+++ b/src/Mod/Part/App/OCCError.h
-@@ -23,36 +23,8 @@
- #ifndef _OCCError_h_
- #define _OCCError_h_
- 
--# include <Standard_Version.hxx>
- # include <Standard_Failure.hxx>
--# include <Standard_AbortiveTransaction.hxx>
--# include <Standard_ConstructionError.hxx>
--# if OCC_VERSION_HEX >= 0x060500
--# include <Standard_DefineException.hxx>
--# endif
--# include <Standard_DimensionError.hxx>
--# include <Standard_DimensionMismatch.hxx>
--# include <Standard_DivideByZero.hxx>
--# include <Standard_DomainError.hxx>
--# include <Standard_ImmutableObject.hxx>
--# include <Standard_LicenseError.hxx>
--# include <Standard_LicenseNotFound.hxx>
--# include <Standard_MultiplyDefined.hxx>
--# include <Standard_NegativeValue.hxx>
--# include <Standard_NoMoreObject.hxx>
--# include <Standard_NoSuchObject.hxx>
--# include <Standard_NotImplemented.hxx>
--# include <Standard_NullObject.hxx>
--# include <Standard_NullValue.hxx>
--# include <Standard_NumericError.hxx>
--# include <Standard_OutOfMemory.hxx>
--# include <Standard_OutOfRange.hxx>
--# include <Standard_Overflow.hxx>
--# include <Standard_ProgramError.hxx>
--# include <Standard_RangeError.hxx>
--# include <Standard_TooManyUsers.hxx>
--# include <Standard_TypeMismatch.hxx>
--# include <Standard_Underflow.hxx>
-+# include <Standard_Version.hxx>
- 
- #include <Mod/Part/PartGlobal.h>
- #include <Base/Console.h>
-@@ -88,4 +60,3 @@ PartExport extern PyObject* PartExceptio
- 
- #define PY_CATCH_OCC _PY_CATCH_OCC(return(NULL))
- #endif  // _OCCError_h_
--
---- a/src/Mod/Part/App/OffsetCurvePyImp.cpp
-+++ b/src/Mod/Part/App/OffsetCurvePyImp.cpp
-@@ -20,20 +20,20 @@
-  *                                                                         *
-  ***************************************************************************/
- 
--
- #include "PreCompiled.h"
- #ifndef _PreComp_
- # include <Geom_OffsetCurve.hxx>
- #endif
- 
--#include "OCCError.h"
--#include "Geometry.h"
-+#include <Base/GeometryPyCXX.h>
-+#include <Base/Vector3D.h>
-+#include <Base/VectorPy.h>
-+
- #include "OffsetCurvePy.h"
- #include "OffsetCurvePy.cpp"
-+#include "Geometry.h"
-+#include "OCCError.h"
- 
--#include <Base/GeometryPyCXX.h>
--#include <Base/VectorPy.h>
--#include <Base/Vector3D.h>
- 
- using namespace Part;
- 
---- a/src/Mod/Part/App/OffsetSurfacePyImp.cpp
-+++ b/src/Mod/Part/App/OffsetSurfacePyImp.cpp
-@@ -20,20 +20,16 @@
-  *                                                                         *
-  ***************************************************************************/
- 
--
- #include "PreCompiled.h"
- #ifndef _PreComp_
- # include <Geom_OffsetSurface.hxx>
- # include <memory>
- #endif
- 
--#include <Base/VectorPy.h>
--#include <Base/Vector3D.h>
--
- #include "OCCError.h"
--#include "Geometry.h"
--#include <Mod/Part/App/OffsetSurfacePy.h>
--#include <Mod/Part/App/OffsetSurfacePy.cpp>
-+#include "OffsetSurfacePy.h"
-+#include "OffsetSurfacePy.cpp"
-+
- 
- using namespace Part;
- 
diff --git a/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch b/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
deleted file mode 100644
index d6a9adabdec83..0000000000000
--- a/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
+++ /dev/null
@@ -1,68 +0,0 @@
-see https://github.com/FreeCAD/FreeCAD/commit/cfe94b00d3434f3e2c8b5114d2909f628c330fa8#commitcomment-71413407
-
-upstream: yes
-
-From 7b377a216b9185960e4cee980a6504dc1a755f50 Mon Sep 17 00:00:00 2001
-From: wmayer <wmayer@users.sourceforge.net>
-Date: Wed, 29 Jun 2022 15:19:18 +0200
-Subject: [PATCH] Gui: remove workaround for spnav 0.23 due to build failure
- with musl libc
-
----
- src/Gui/3Dconnexion/GuiNativeEventLinux.cpp | 27 ---------------------
- 1 file changed, 27 deletions(-)
-
---- a/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp
-+++ b/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp
-@@ -21,42 +21,17 @@
-  ***************************************************************************/
- 
- #include <FCConfig.h>
--#include <cstdio>
- 
- #include "GuiNativeEventLinux.h"
- 
- #include "GuiApplicationNativeEventAware.h"
- #include <Base/Console.h>
--#include <Base/FileInfo.h>
- #include <QMainWindow>
- 
- #include <QSocketNotifier>
- 
- #include <spnav.h>
- 
--namespace {
--class RedirectStdErr
--{
--public:
--    RedirectStdErr()
--        : fi(Base::FileInfo::getTempFileName())
--        , file(stderr)
--    {
--        stderr = fopen(fi.filePath().c_str(), "w");
--    }
--    ~RedirectStdErr()
--    {
--        fclose(stderr);
--        fi.deleteFile();
--        stderr = file;
--    }
--
--private:
--    Base::FileInfo fi;
--    FILE* file;
--};
--}
--
- Gui::GuiNativeEvent::GuiNativeEvent(Gui::GUIApplicationNativeEventAware *app)
- : GuiAbstractNativeEvent(app)
- {
-@@ -72,8 +47,6 @@ Gui::GuiNativeEvent::~GuiNativeEvent()
- 
- void Gui::GuiNativeEvent::initSpaceball(QMainWindow *window)
- {
--    // tmp. redirect stderr to a file to suppress an error message from spnav_open()
--    RedirectStdErr err;
-     Q_UNUSED(window)
-     if (spnav_open() == -1) {
-         Base::Console().Log("Couldn't connect to spacenav daemon. Please ignore if you don't have a spacemouse.\n");
diff --git a/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch b/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch
deleted file mode 100644
index d4acf370ca0a4..0000000000000
--- a/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-From fe02d63c8c9b1280978be841d04e68a0a55cceb9 Mon Sep 17 00:00:00 2001
-From: Roy-043 <70520633+Roy-043@users.noreply.github.com>
-Date: Thu, 29 Dec 2022 23:20:38 +0100
-Subject: [PATCH] Draft: update inspect.getargspec to inspect.getfullargspec
- (#8101)
-
----
- src/Mod/Draft/draftguitools/gui_snapper.py | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
---- a/src/Mod/Draft/draftguitools/gui_snapper.py
-+++ b/src/Mod/Draft/draftguitools/gui_snapper.py
-@@ -1426,7 +1426,7 @@ class Snapper:
-             Gui.Snapper.off()
-             self.ui.offUi()
-             if callback:
--                if len(inspect.getargspec(callback).args) > 1:
-+                if len(inspect.getfullargspec(callback).args) > 1:
-                     obj = None
-                     if self.snapInfo and ("Object" in self.snapInfo) and self.snapInfo["Object"]:
-                         obj = App.ActiveDocument.getObject(self.snapInfo["Object"])
-@@ -1445,7 +1445,7 @@ class Snapper:
-             Gui.Snapper.off()
-             self.ui.offUi()
-             if callback:
--                if len(inspect.getargspec(callback).args) > 1:
-+                if len(inspect.getfullargspec(callback).args) > 1:
-                     callback(None, None)
-                 else:
-                     callback(None)
diff --git a/srcpkgs/freecad/template b/srcpkgs/freecad/template
index c135701e38b9a..7d5165f760bab 100644
--- a/srcpkgs/freecad/template
+++ b/srcpkgs/freecad/template
@@ -1,7 +1,7 @@
 # Template file for 'freecad'
 pkgname=freecad
-version=0.20.2
-revision=7
+version=0.21.1
+revision=2
 build_wrksrc="FreeCAD-${version}"
 build_style=cmake
 pycompile_dirs="usr/lib/${pkgname}/Mod"
@@ -24,8 +24,10 @@ makedepends="python3-devel boost-devel libxerces-c-devel zlib-devel occt-devel
  coin3-devel libshiboken2-devel libspnav-devel pyside2-tools
  liblz4-devel libpyside2-python3-devel python3-matplotlib netcdf-devel
  jsoncpp-devel qt5-devel qt5-svg-devel qt5-tools-devel qt5-webkit-devel
- qt5-xmlpatterns-devel coin3-doc glew-devel python3-pivy"
-depends="python3-matplotlib python3-pyside2-webengine python3-pivy"
+ qt5-xmlpatterns-devel coin3-doc glew-devel python3-pivy qt5-webengine-devel
+ qt5-declarative-devel qt5-webchannel-devel qt5-location-devel"
+depends="python3-matplotlib python3-pyside2-webengine python3-pivy
+ python3-GitPython python3-Markdown"
 short_desc="General purpose 3D CAD modeler"
 maintainer="yopito <pierre.bourgin@free.fr>"
 license="LGPL-2.0-or-later"
@@ -35,7 +37,7 @@ distfiles="
  https://github.com/FreeCAD/FreeCAD/archive/${version}.tar.gz
  ${SOURCEFORGE_SITE}/cxx/pycxx-${_pycxxver}.tar.gz
 "
-checksum="46922f3a477e742e1a89cd5346692d63aebb2b67af887b3e463e094a4ae055da
+checksum="e9b1fd0323f101268c7f3be52db42e4a29222f2e306ae6c4a6fc309cb418d35a
  4b91e1e1141c23fbd5039df635c4bb6e75632168548f56b83ce177193c0c98c6"
 python_version=3
 patch_args="-Np1 -d ${build_wrksrc}"

From 6c710ff509c4ccd8006c04298473edea4825be8c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:47:18 -0400
Subject: [PATCH 093/113] libopenshot: revbump for ffmpeg-6.0

---
 srcpkgs/libopenshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenshot/template b/srcpkgs/libopenshot/template
index 8e57c5f592169..7a8f4520e7892 100644
--- a/srcpkgs/libopenshot/template
+++ b/srcpkgs/libopenshot/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenshot'
 pkgname=libopenshot
 version=0.3.0
-revision=3
+revision=4
 build_style=cmake
 # Builds fail with Ruby-2.4.1
 configure_args="-DENABLE_RUBY=OFF -DUSE_SYSTEM_JSONCPP=ON"

From 51486fba29f953484dccec3096cf67c1eeb2b389 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:10:30 -0500
Subject: [PATCH 094/113] openimageio: revbump for ffmpeg-6.0

---
 srcpkgs/openimageio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimageio/template b/srcpkgs/openimageio/template
index 3ce3f9e49d350..27d2131bc0a61 100644
--- a/srcpkgs/openimageio/template
+++ b/srcpkgs/openimageio/template
@@ -1,7 +1,7 @@
 # Template file for 'openimageio'
 pkgname=openimageio
 version=2.4.9.0
-revision=7
+revision=8
 build_style=cmake
 build_helper=qemu
 configure_args="-DUSE_QT=0 -DUSE_PYTHON=0 -DOIIO_BUILD_TESTS=0

From 0cc4734a8bb8805a50c8248c8b35e4a94498e773 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:11:57 -0500
Subject: [PATCH 095/113] synfigstudio: revbump for ffmpeg-6.0

---
 srcpkgs/synfigstudio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/synfigstudio/template b/srcpkgs/synfigstudio/template
index 09e442da9a680..2bc017cedca6b 100644
--- a/srcpkgs/synfigstudio/template
+++ b/srcpkgs/synfigstudio/template
@@ -2,7 +2,7 @@
 # Should be kept in sync with 'synfig' and 'ETL'
 pkgname=synfigstudio
 version=1.4.4
-revision=4
+revision=5
 build_style=gnu-configure
 configure_args="--disable-update-mimedb"
 hostmakedepends="pkg-config intltool gettext synfig"

From 866a072b9bf180aaba884f59e2fecac71c54cc86 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:12:32 -0500
Subject: [PATCH 096/113] gmic: revbump for ffmpeg-6.0

---
 srcpkgs/gmic/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gmic/template b/srcpkgs/gmic/template
index fa37651bb6dee..24d10147e3aba 100644
--- a/srcpkgs/gmic/template
+++ b/srcpkgs/gmic/template
@@ -1,7 +1,7 @@
 # Template file for 'gmic'
 pkgname=gmic
 version=3.1.6
-revision=5
+revision=6
 _zart_hash=34ebf6cce0bafb98abe57cec83c4a02cd1abeca0
 create_wrksrc=yes
 build_wrksrc="src"

From d7365b2d00db62e5f4d8f6a4252a504b736a3d8b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:10 -0500
Subject: [PATCH 097/113] mixxx: revbump for ffmpeg-6.0

---
 srcpkgs/mixxx/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mixxx/template b/srcpkgs/mixxx/template
index 6921996e4e77b..6a79b328c1abf 100644
--- a/srcpkgs/mixxx/template
+++ b/srcpkgs/mixxx/template
@@ -1,7 +1,7 @@
 # Template file for 'mixxx'
 pkgname=mixxx
 version=2.3.3
-revision=6
+revision=7
 build_style=cmake
 configure_args="-DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="extra-cmake-modules pkg-config protobuf qt5-host-tools qt5-qmake"

From d4397e8c979fed5eaf3ff0a0905fd1d9da1dee9a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:28 -0500
Subject: [PATCH 098/113] musikcube: revbump for ffmpeg-6.0

---
 srcpkgs/musikcube/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/musikcube/template b/srcpkgs/musikcube/template
index d9e6186e6697b..637952d50aca3 100644
--- a/srcpkgs/musikcube/template
+++ b/srcpkgs/musikcube/template
@@ -1,7 +1,7 @@
 # Template file for 'musikcube'
 pkgname=musikcube
 version=3.0.0
-revision=3
+revision=4
 build_style=cmake
 make_cmd=make
 configure_args="-DNO_NCURSESW=1"

From e0fbac3d2013998e6c710de25bde970ab56adb12 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:45 -0500
Subject: [PATCH 099/113] electron24: revbump for ffmpeg-6.0

---
 srcpkgs/electron24/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron24/template b/srcpkgs/electron24/template
index a9c865c19c989..b8613e4362bc7 100644
--- a/srcpkgs/electron24/template
+++ b/srcpkgs/electron24/template
@@ -1,7 +1,7 @@
 # Template file for 'electron24'
 pkgname=electron24
 version=24.3.0
-revision=2
+revision=3
 _nodever=18.14.0
 _chromiumver=112.0.5615.165
 archs="x86_64* aarch64*"

From a1b65e59a739697411654f81e8508640efcefc98 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:00 -0500
Subject: [PATCH 100/113] electron19: revbump for ffmpeg-6.0

---
 srcpkgs/electron19/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron19/template b/srcpkgs/electron19/template
index b18bc792c8221..29fb34e254eea 100644
--- a/srcpkgs/electron19/template
+++ b/srcpkgs/electron19/template
@@ -1,7 +1,7 @@
 # Template file for 'electron19'
 pkgname=electron19
 version=19.0.8
-revision=4
+revision=5
 _nodever=16.14.2
 _chromiumver=102.0.5005.125
 archs="x86_64* aarch64* ppc64le*"

From 92513e1d970e1b9e2ca60ba66279ee6fccaca17e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:13 -0500
Subject: [PATCH 101/113] wf-recorder: revbump for ffmpeg-6.0

---
 srcpkgs/wf-recorder/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/wf-recorder/template b/srcpkgs/wf-recorder/template
index 08f986b031006..63c45cf4b814d 100644
--- a/srcpkgs/wf-recorder/template
+++ b/srcpkgs/wf-recorder/template
@@ -1,7 +1,7 @@
 # Template file for 'wf-recorder'
 pkgname=wf-recorder
 version=0.4.1
-revision=2
+revision=3
 build_style=meson
 hostmakedepends="pkg-config scdoc wayland-devel"
 makedepends="wayland-protocols wayland-devel ffmpeg-devel libgbm-devel x264-devel

From baf6371d0826b95ad59ee8ae8193ed3ec3afc079 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:26 -0500
Subject: [PATCH 102/113] obs: revbump for ffmpeg-6.0

---
 srcpkgs/obs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/obs/template b/srcpkgs/obs/template
index b343f1131bfcf..a25a67433e285 100644
--- a/srcpkgs/obs/template
+++ b/srcpkgs/obs/template
@@ -1,7 +1,7 @@
 # Template file for 'obs'
 pkgname=obs
 version=30.0.0
-revision=2
+revision=3
 archs="i686* x86_64* ppc64le* aarch64* riscv64*"
 build_style=cmake
 configure_args="-DOBS_VERSION_OVERRIDE=${version} -DENABLE_JACK=ON

From 16ff80aa338fe996b33ff4653bbcde0cb56817a8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:36 -0500
Subject: [PATCH 103/113] mlt7: revbump for ffmpeg-6.0

---
 srcpkgs/mlt7/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mlt7/template b/srcpkgs/mlt7/template
index 98f302ad3a516..7eb8c00fa1580 100644
--- a/srcpkgs/mlt7/template
+++ b/srcpkgs/mlt7/template
@@ -1,7 +1,7 @@
 # Template file for 'mlt7'
 pkgname=mlt7
 version=7.20.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DSWIG_PYTHON=ON -DMOD_QT6=ON"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which

From 4d765a6ea991b2584b6b6720a9761b368c67975c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:48 -0500
Subject: [PATCH 104/113] qt6-multimedia: revbump for ffmpeg-6.0

---
 srcpkgs/qt6-multimedia/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-multimedia/template b/srcpkgs/qt6-multimedia/template
index 67a577e1300fe..1da626ecf515a 100644
--- a/srcpkgs/qt6-multimedia/template
+++ b/srcpkgs/qt6-multimedia/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-multimedia'
 pkgname=qt6-multimedia
 version=6.6.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DQT_FEATURE_gstreamer=ON"
 hostmakedepends="perl qt6-declarative-host-tools pkg-config qt6-shadertools"

From d89af5d86bc9cf4f5b44d0a76f1ac910fab71ebd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:00:15 -0500
Subject: [PATCH 105/113] baresip: revbump for ffmpeg-6.0

---
 srcpkgs/baresip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/baresip/template b/srcpkgs/baresip/template
index 12c8954ef7b9b..b16b67beab8d2 100644
--- a/srcpkgs/baresip/template
+++ b/srcpkgs/baresip/template
@@ -1,7 +1,7 @@
 # Template file for 'baresip'
 pkgname=baresip
 version=3.6.0
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config glib-devel"
 makedepends="libgsm-devel libpng-devel openssl-devel libsndfile-devel

From 1a08cef5347bf84ea9b4e998582f8e4ba0b50667 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:30 -0500
Subject: [PATCH 106/113] QMPlay2: revbump for ffmpeg-6.0

---
 srcpkgs/QMPlay2/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/QMPlay2/template b/srcpkgs/QMPlay2/template
index 46c80f64a1349..942258ce60fb7 100644
--- a/srcpkgs/QMPlay2/template
+++ b/srcpkgs/QMPlay2/template
@@ -1,7 +1,7 @@
 # Template file for 'QMPlay2'
 pkgname=QMPlay2
 version=23.10.22
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools"
 makedepends="alsa-lib-devel ffmpeg-devel libass-devel libcdio-devel libgme-devel

From 5d48eb518305a1809a07437dce87933cc0c550ee Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:34 -0500
Subject: [PATCH 107/113] alsa-plugins: revbump for ffmpeg-6.0

---
 srcpkgs/alsa-plugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/alsa-plugins/template b/srcpkgs/alsa-plugins/template
index a5708a7d82a8f..7bfdad046c483 100644
--- a/srcpkgs/alsa-plugins/template
+++ b/srcpkgs/alsa-plugins/template
@@ -1,7 +1,7 @@
 # Template file for 'alsa-plugins'
 pkgname=alsa-plugins
 version=1.2.7.1
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--disable-maemo-plugin"
 hostmakedepends="pkg-config"

From 985caaa97f07a82ac11b31fd0133bd84f2697db3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:43 -0500
Subject: [PATCH 108/113] minidlna: revbump for ffmpeg-6.0

---
 srcpkgs/minidlna/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/minidlna/template b/srcpkgs/minidlna/template
index 5fa929f3a0c12..742991ecd04af 100644
--- a/srcpkgs/minidlna/template
+++ b/srcpkgs/minidlna/template
@@ -1,7 +1,7 @@
 # Template file for 'minidlna'
 pkgname=minidlna
 version=1.3.3
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="
  --sbindir=/usr/bin

From 4565ad4196a2cb0b2e1f17abdfa92b150386c9cc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 17:57:47 -0500
Subject: [PATCH 109/113] mpv: revbump for ffmpeg-6.0

---
 srcpkgs/mpv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpv/template b/srcpkgs/mpv/template
index 4948d1e332cb8..1ac1b167af189 100644
--- a/srcpkgs/mpv/template
+++ b/srcpkgs/mpv/template
@@ -1,7 +1,7 @@
 # Template file for 'mpv'
 pkgname=mpv
 version=0.36.0
-revision=4
+revision=5
 build_style=meson
 configure_args="-Dcdda=enabled -Ddvbin=enabled -Ddvdnav=enabled
  -Dlibmpv=true -Dcplugins=enabled

From c94ce8dda34392df3011697214f387197659ccf1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 17:59:29 -0500
Subject: [PATCH 110/113] qimgv: revbump for ffmpeg-6.0

---
 srcpkgs/qimgv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qimgv/template b/srcpkgs/qimgv/template
index dd341dfe1bfce..8a7e1c081ef12 100644
--- a/srcpkgs/qimgv/template
+++ b/srcpkgs/qimgv/template
@@ -1,7 +1,7 @@
 # Template file for 'qimgv'
 pkgname=qimgv
 version=1.0.2
-revision=3
+revision=4
 build_style=cmake
 configure_args="$(vopt_if video -DVIDEO_SUPPORT=ON -DVIDEO_SUPPORT=OFF)
  $(vopt_if scale -DOPENCV_SUPPORT=ON -DOPENCV_SUPPORT=OFF)

From 272085d2c58caf7a3886515463bd98cf45fd54dd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 18:00:36 -0500
Subject: [PATCH 111/113] kfilemetadata5: revbump for ffmpeg-6.0

---
 srcpkgs/kfilemetadata5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kfilemetadata5/template b/srcpkgs/kfilemetadata5/template
index 28430f112ab5d..593d2723d95d1 100644
--- a/srcpkgs/kfilemetadata5/template
+++ b/srcpkgs/kfilemetadata5/template
@@ -1,7 +1,7 @@
 # Template file for 'kfilemetadata5'
 pkgname=kfilemetadata5
 version=5.112.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="kcoreaddons extra-cmake-modules pkg-config qt5-host-tools qt5-qmake
  gettext kcoreaddons python3"

From ce356db3ead56e99301f7cf42f9a30e26d2d8446 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 8 Dec 2023 11:46:01 -0500
Subject: [PATCH 112/113] vba-m: revbump for ffmpeg-6.0

---
 srcpkgs/vba-m/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vba-m/template b/srcpkgs/vba-m/template
index 2223d297c31f5..50850668477b7 100644
--- a/srcpkgs/vba-m/template
+++ b/srcpkgs/vba-m/template
@@ -2,7 +2,7 @@
 pkgname=vba-m
 reverts=1292_2
 version=2.1.7
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DENABLE_GTK=TRUE -DENABLE_FFMPEG=TRUE -DENABLE_LINK=TRUE -DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="gettext pkg-config unzip zip yasm wxWidgets-gtk3-devel"

From af8e8b464e39a14fd3f04b635668c46e7c64d7c0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 8 Dec 2023 11:46:19 -0500
Subject: [PATCH 113/113] dolphin-emu: revbump for ffmpeg-6.0

---
 srcpkgs/dolphin-emu/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/dolphin-emu/template b/srcpkgs/dolphin-emu/template
index 862d3ae964eec..a7ae0efb58fb7 100644
--- a/srcpkgs/dolphin-emu/template
+++ b/srcpkgs/dolphin-emu/template
@@ -1,7 +1,7 @@
 # Template file for 'dolphin-emu'
 pkgname=dolphin-emu
 version=5.0.19368
-revision=3
+revision=4
 _dolphin_commit=dadbeb4bae7e7fa23af2b46e0add4143094dc107
 _mgba_commit=44e074a15e9651481f7f652ac006a7c9d58cbeb9
 _googletest_commit=be03d00f5f0cc3a997d1a368bee8a1fe93651f48

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (46 preceding siblings ...)
  2023-12-14 18:28 ` [PR PATCH] [Updated] " zlice
@ 2023-12-19 20:48 ` zlice
  2023-12-29 17:30 ` zlice
                   ` (49 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2023-12-19 20:48 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 4019 bytes --]

There is an updated pull request by zlice against master on the void-packages repository

https://github.com/zlice/void-packages ffmpeg6-split
https://github.com/void-linux/void-packages/pull/43761

ffmpeg6 split
[ci skip]


#### Testing the changes

- I tested the changes in this PR: **YES**

main testing has been vaapi in Firefox Nightly and enc/dec in Shotcut on Intel A770

#### New package

- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**

#### Local build testing

- I built this PR locally for my native architecture, **x86_64**

#### Discussion

Continuation of https://github.com/void-linux/void-packages/pull/36315

`libavresample` is deprecated, but marked as a dependency when trying to build other packages and install `ffmpeg`(6). I think the right way to handle this is make a meta package and the add to removals?


##### Commit naming / misc

~~Commits are 'dirty' right now, running with [gstreamer 1.22.1 updates](https://github.com/void-linux/void-packages/pull/42861) and [Intel OpenCL](https://github.com/void-linux/void-packages/pull/43084). This will also make [intel packages pr](https://github.com/void-linux/void-packages/pull/41132) obsolete.~~ (see Requirements below)

Maintainer for previous ffmpeg(4) was orphaned, I can put my name in there if that matters, though I don't exactly see myself keeping up on ffmpeg.

~~This updates QT5 which looks like it is usually hosted by Johnny. Not sure if there's any reason to stay there or these sources are fine.~~ Using qt5.15.11 now, revbumps and some patches.

##### STILL FFMPEG4

These are a mix of emulators, games and/or older packages.

- attract (multiple patches in master)
- audacity (https://github.com/audacity/audacity/issues/2305 and https://sourceforge.net/p/portmedia/wiki/portsmf/ is 'beta')
- ccextractor (master patches? no release)
- vice
- kodi
- mlt (only dep left is flowblade)
- ~~synfig (mlt)~~ (work with mlt7, bump synfigstudio)
- tvheadend
- ssr
- ~~spek-alternative~~ (replace with spek-x)
- ppsspp
- olive
- moc
- mediastreamer
- libextractor
- idjc
- hedgewars
- ~~ffmpegthumbnailer~~ (patches for moviedecoder.xxx files)
- ~~ffmpegthumbs~~ (latest compiles)
- deadbeef
- omxplayer
- qtav (fork has ffmpeg 5 patch - https://github.com/cmguo/QtAV)
- `vlc` (vlc4 will support ffmpeg5, there's a patch to build 3.x with ffmpeg5 but it will lack vaapi)
- `osg` (OpenSceneGraph plus `xine-lib`)


##### HAVE NOT BUILT YET

- omxplayer (rpi only? ffmpeg4)
- kodi (big, but ffmpeg4)


##### UPDATED (for ffmpeg6)

- ~~blender: update to 3.5.1~~ ~~will be revbump with~~ https://github.com/void-linux/void-packages/pull/43992
- unpaper: update to 7.0.0.
- guvcview: update to 2.0.8.
- ~~qt5: update to 5.15.8~~ updated by another PR to 5.15.11
- ~~qt5-webengine: update to 5.18.15~~ updated by another PR to 5.15.16 (some patching for ffmpeg build)
- ~~shiboken2: revbump for qt5.15.8 (patch)~~ updated by another PR to 5.15.10
- ~~python3-pyside2: update to 5.15.8 (patch)~~ updated by another PR to 5.15.10
- New package: spex-x replaces spek-alternative for ffmpeg-6.0


##### Requirements

- ~~[gstreamer 1.22.2](https://github.com/void-linux/void-packages/pull/42861)~~ - a few packages use ffmpeg-devel and require a revbump

- ~~[Intel Packages](https://github.com/void-linux/void-packages/pull/41132) [Intel Packages v2](https://github.com/void-linux/void-packages/pull/47330) - ffmpeg4 uses different libraries than 6 (libmfx / Intel-MediaSDK vs only oneVPL that Intel is moving to), both are included here~~. Using replacement oneVPL from OBS update.

- ~~[shotcut 23.05.14](https://github.com/void-linux/void-packages/pull/44260)~~

- https://github.com/void-linux/void-packages/pull/44781 will remove from this PR

A patch file from https://github.com/void-linux/void-packages/pull/43761.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ffmpeg6-split-43761.patch --]
[-- Type: text/x-diff, Size: 220566 bytes --]

From c20b004bc2d24ae7ad2e805dab393e7a7176dbd7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:16:56 -0400
Subject: [PATCH 001/113] ffmpeg: update to 6.0.1.

---
 common/shlibs                                 | 26 +++++---
 srcpkgs/ffmpeg/files/altivec.patch            | 60 -------------------
 .../patches/armv5tel-floating-point.patch     | 18 ------
 ...h-libavcodec-libsvtav1-ten_bit_format.diff | 40 -------------
 .../workaround-mesa-readeon-vaapi-bug.patch   | 28 ---------
 srcpkgs/ffmpeg/template                       | 38 ++++++------
 6 files changed, 37 insertions(+), 173 deletions(-)
 delete mode 100644 srcpkgs/ffmpeg/files/altivec.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 delete mode 100644 srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch

diff --git a/common/shlibs b/common/shlibs
index a45654c4fa3cf..c3cfbee902a4f 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -385,15 +385,23 @@ libid3tag.so.0 libid3tag-0.15.1b_1
 libgif.so.7 giflib-5.1.0_1
 libImlib2.so.1 imlib2-1.4.2_1
 libmp3lame.so.0 lame-3.98.2_1
-libavdevice.so.58 libavdevice-4.0_1
-libavformat.so.58 libavformat-4.0_1
-libswscale.so.5 libswscale-4.0_1
-libswresample.so.3 libswresample-4.0_1
-libavresample.so.4 libavresample-4.0_1
-libpostproc.so.55 libpostproc-4.0_1
-libavcodec.so.58 libavcodec-4.0_1
-libavutil.so.56 libavutil-4.0_1
-libavfilter.so.7 libavfilter-4.0_1
+libavdevice.so.60 libavdevice-6.0_1
+libavformat.so.60 libavformat-6.0_1
+libswscale.so.7 libswscale-6.0_1
+libswresample.so.4 libswresample-6.0_1
+libpostproc.so.57 libpostproc-6.0_1
+libavcodec.so.60 libavcodec-6.0_1
+libavutil.so.58 libavutil-6.0_1
+libavfilter.so.9 libavfilter-6.0_1
+libavdevice.so.58 libavdevice4-4.0_1
+libavformat.so.58 libavformat4-4.0_1
+libswscale.so.5 libswscale4-4.0_1
+libswresample.so.3 libswresample4-4.0_1
+libavresample.so.4 libavresample4-4.0_1
+libpostproc.so.55 libpostproc4-4.0_1
+libavcodec.so.58 libavcodec4-4.0_1
+libavutil.so.56 libavutil4-4.0_1
+libavfilter.so.7 libavfilter4-4.0_1
 libSDL-1.2.so.0 SDL-1.2.14_1
 libSDL_image-1.2.so.0 SDL_image-1.2.10_1
 libx264.so.157 x264-20190507.2245_1
diff --git a/srcpkgs/ffmpeg/files/altivec.patch b/srcpkgs/ffmpeg/files/altivec.patch
deleted file mode 100644
index 9c57200463320..0000000000000
--- a/srcpkgs/ffmpeg/files/altivec.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-revert some altivec specific change on all ppc* except ppc64le*
-
-q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
-conditionally, for ppc* but not ppc64le* (the new code is valid for
-POWER8 VSX which LE targets as a baseline but not BE)"
-
-
-This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
----
- libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
- 1 file changed, 20 insertions(+), 4 deletions(-)
-
-diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
-index 536545293d..c1e2852adb 100644
---- a/libswscale/ppc/yuv2rgb_altivec.c
-+++ b/libswscale/ppc/yuv2rgb_altivec.c
-@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-     vector signed short R1, G1, B1;                                           \
-     vector unsigned char R, G, B;                                             \
-                                                                               \
-+    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
-+    vector unsigned char align_perm;                                          \
-+                                                                              \
-     vector signed short lCY       = c->CY;                                    \
-     vector signed short lOY       = c->OY;                                    \
-     vector signed short lCRV      = c->CRV;                                   \
-@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
-                                                                               \
-         for (j = 0; j < w / 16; j++) {                                        \
--            y0 = vec_xl(0, y1i);                                              \
-+            y1ivP = (const vector unsigned char *) y1i;                       \
-+            y2ivP = (const vector unsigned char *) y2i;                       \
-+            uivP  = (const vector unsigned char *) ui;                        \
-+            vivP  = (const vector unsigned char *) vi;                        \
-+                                                                              \
-+            align_perm = vec_lvsl(0, y1i);                                    \
-+            y0 = (vector unsigned char)                                       \
-+                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
-                                                                               \
--            y1 = vec_xl(0, y2i);                                              \
-+            align_perm = vec_lvsl(0, y2i);                                    \
-+            y1 = (vector unsigned char)                                       \
-+                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
-                                                                               \
--            u = (vector signed char) vec_xl(0, ui);                           \
-+            align_perm = vec_lvsl(0, ui);                                     \
-+            u = (vector signed char)                                          \
-+                    vec_perm(uivP[0], uivP[1], align_perm);                   \
-                                                                               \
--            v = (vector signed char) vec_xl(0, vi);                           \
-+            align_perm = vec_lvsl(0, vi);                                     \
-+            v = (vector signed char)                                          \
-+                    vec_perm(vivP[0], vivP[1], align_perm);                   \
-                                                                               \
-             u = (vector signed char)                                          \
-                     vec_sub(u,                                                \
--- 
-2.27.0
-
diff --git a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
deleted file mode 100644
index 9a55178c74f0f..0000000000000
--- a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
-+++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
-@@ -39,6 +39,15 @@
- #endif
- #include <fenv.h>
- 
-+#if (FE_ALL_EXCEPT == 0)
-+/* E.g. ARM soft float does not define these */
-+#define FE_INVALID    0
-+#define FE_DIVBYZERO  0
-+#define FE_OVERFLOW   0
-+#define FE_UNDERFLOW  0
-+#define FE_INEXACT    0
-+#endif
-+
- #if CONFIG_LIBFONTCONFIG
- #include <fontconfig/fontconfig.h>
- #endif
diff --git a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
deleted file mode 100644
index aa948f7a8a2df..0000000000000
--- a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
+++ /dev/null
@@ -1,40 +0,0 @@
-#==================================================================================================
-# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
-# From: Christopher Degawa <christopher.degawa@intel.com>
-# Date: Thu, 20 Oct 2022 22:55:27 -0500
-# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
-#
-# compressed_ten_bit_format has been deprecated upstream and has no effect
-# and can be removed. Plus, technically it was never used in the first place
-# since it would require the app (ffmpeg) to set it and do additional
-# processing of the input frames.
-#
-# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
-#
-# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
-#==================================================================================================
---- a/libavcodec/libsvtav1.c
-+++ b/libavcodec/libsvtav1.c
-@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
- 
- static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
- {
--    const int    pack_mode_10bit =
--        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
--    const size_t luma_size_8bit  =
--        config->source_width * config->source_height * (1 << pack_mode_10bit);
--    const size_t luma_size_10bit =
--        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
-+    const size_t luma_size = config->source_width * config->source_height *
-+        (config->encoder_bit_depth > 8 ? 2 : 1);
- 
-     EbSvtIOFormat *in_data;
- 
--    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
-+    svt_enc->raw_size = luma_size * 3 / 2;
- 
-     // allocate buffer for in and out
-     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
--- 
-GitLab
-
diff --git a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
deleted file mode 100644
index 00e3f68a415b8..0000000000000
--- a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
-From: Rainer Hochecker <fernetmenta@online.de>
-Date: Sat, 26 Jan 2019 19:48:35 +0100
-Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
-
-This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
-It was hit frequently when watching h264 channels received via DVB-X.
-Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
----
- libavcodec/vaapi_h264.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
-index 5854587a255..f12fdc457a4 100644
---- a/libavcodec/vaapi_h264.c
-+++ b/libavcodec/vaapi_h264.c
-@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
-     H264SliceContext *sl = &h->slice_ctx[0];
-     int ret;
- 
-+    if (pic->nb_slices == 0) {
-+        ret = AVERROR_INVALIDDATA;
-+        goto finish;
-+    }
-+
-     ret = ff_vaapi_decode_issue(avctx, pic);
-     if (ret < 0)
-         goto finish;
diff --git a/srcpkgs/ffmpeg/template b/srcpkgs/ffmpeg/template
index 5968a09b1f12d..52fcf4d68797a 100644
--- a/srcpkgs/ffmpeg/template
+++ b/srcpkgs/ffmpeg/template
@@ -1,15 +1,15 @@
 # Template file for 'ffmpeg'
 # audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
 pkgname=ffmpeg
-version=4.4.4
-revision=5
+version=6.0.1
+revision=1
 short_desc="Decoding, encoding and streaming software"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="https://www.ffmpeg.org"
 changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
 distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
-checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+checksum=9b16b8731d78e596b4be0d720428ca42df642bb2d78342881ff7f5bc29fc9623
 
 hostmakedepends="pkg-config perl"
 makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
@@ -26,12 +26,13 @@ makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-deve
  $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
  $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
  $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
- $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers Vulkan-Tools Vulkan-ValidationLayers')
+ $(vopt_if onevpl 'oneVPL oneVPL-devel')
  $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
 depends="ffplay>=${version}_${revision}"
 
 build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
- dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec onevpl"
 build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
 desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
 desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
@@ -39,9 +40,13 @@ desc_option_sofa="Enable support for AES SOFA"
 desc_option_webp="Enable support for WebP"
 
 case "$XBPS_TARGET_MACHINE" in
-	i686*|x86_64*)
-		hostmakedepends+=" nasm"
+	i686*)
 		build_options_default+=" vaapi vdpau nvenc nvdec"
+		hostmakedepends+=" nasm"
+		;;
+	x86_64*)
+		hostmakedepends+=" nasm"
+		build_options_default+=" vaapi vdpau nvenc nvdec onevpl"
 		;;
 	ppc64*) build_options_default+=" vaapi vdpau";;
 	mips*) CFLAGS="-mnan=legacy";;
@@ -115,18 +120,19 @@ do_configure() {
 		$(vopt_enable x265 libx265) \
 		$(vopt_enable v4l2 libv4l2) \
 		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
-		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		--enable-libbs2b --enable-libvidstab \
 		$(vopt_enable dav1d libdav1d) \
 		$(vopt_enable zimg libzimg) \
 		$(vopt_enable webp libwebp) \
 		$(vopt_enable sofa libmysofa) \
 		$(vopt_enable vulkan) \
+		$(vopt_enable onevpl libvpl) \
 		$(vopt_enable drm libdrm) \
 		$(vopt_enable svtav1 libsvtav1) \
 		$(vopt_enable srt libsrt) \
 		$(vopt_enable rist librist) \
-		$(vopt_if nvenc '--enable-nvenc') \
-		$(vopt_if nvdec '--enable-nvdec')
+		$(vopt_enable nvenc nvenc) \
+		$(vopt_enable nvdec nvdec)
 }
 
 do_build() {
@@ -153,10 +159,8 @@ libavdevice_package() {
 }
 
 libavresample_package() {
-	short_desc="FFmpeg audio resampling library"
-	pkg_install() {
-		vmove "usr/lib/libavresample.so.*"
-	}
+	short_desc="Package deprecated, removal needed"
+	build_style=meta
 }
 
 libavformat_package() {
@@ -210,15 +214,13 @@ ffmpeg-devel_package() {
 		libavfilter>=${version}_${revision}
 		libpostproc>=${version}_${revision}
 		libswscale>=${version}_${revision}
-		libswresample>=${version}_${revision}
-		libavresample>=${version}_${revision}"
+		libswresample>=${version}_${revision}"
 	short_desc+=" - development files"
-
+	conflicts="ffmpeg4-devel"
 	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
 		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
 		nostrip_files="/usr/lib/libavfilter.a"
 	fi
-
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig

From 3b1b4fb54ad0ecc7faee1ba7a01f42fb155be76e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:14 -0400
Subject: [PATCH 002/113] openshot: revbump for ffmpeg6

---
 srcpkgs/openshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openshot/template b/srcpkgs/openshot/template
index 8f47851eef354..affb652a9d500 100644
--- a/srcpkgs/openshot/template
+++ b/srcpkgs/openshot/template
@@ -1,7 +1,7 @@
 # Template file for 'openshot'
 pkgname=openshot
 version=3.0.0
-revision=2
+revision=3
 build_style=python3-module
 hostmakedepends="python3 python3-setuptools"
 makedepends="ffmpeg-devel python3-PyQt5"

From 674ec4bdb7189a45d30952866a55111fb8f86786 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:36 -0400
Subject: [PATCH 003/113] sumo: revbump for ffmpeg6

---
 srcpkgs/sumo/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/sumo/template b/srcpkgs/sumo/template
index a3fe134aa5acc..a730afa9fafa9 100644
--- a/srcpkgs/sumo/template
+++ b/srcpkgs/sumo/template
@@ -1,7 +1,7 @@
 # Template file for 'sumo'
 pkgname=sumo
 version=1.12.0
-revision=6
+revision=7
 build_style=cmake
 hostmakedepends="libgdal-tools pkg-config swig python3-setuptools"
 makedepends="python3-devel ffmpeg-devel fox-devel gl2ps-devel libgdal-devel

From d112f774c687d8aea8d15bbe45ce3efa98aed941 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:56:22 -0400
Subject: [PATCH 004/113] New package: ffmpeg4-4.4.4.

---
 srcpkgs/ffmpeg4-devel                         |   1 +
 srcpkgs/ffmpeg4/files/altivec.patch           |  60 +++++
 .../patches/armv5tel-floating-point.patch     |  18 ++
 ...h-libavcodec-libsvtav1-ten_bit_format.diff |  40 +++
 .../workaround-mesa-readeon-vaapi-bug.patch   |  28 +++
 srcpkgs/ffmpeg4/template                      | 234 ++++++++++++++++++
 srcpkgs/libavcodec4                           |   1 +
 srcpkgs/libavdevice4                          |   1 +
 srcpkgs/libavfilter4                          |   1 +
 srcpkgs/libavformat4                          |   1 +
 srcpkgs/libavresample4                        |   1 +
 srcpkgs/libavutil4                            |   1 +
 srcpkgs/libpostproc4                          |   1 +
 srcpkgs/libswresample4                        |   1 +
 srcpkgs/libswscale4                           |   1 +
 15 files changed, 390 insertions(+)
 create mode 120000 srcpkgs/ffmpeg4-devel
 create mode 100644 srcpkgs/ffmpeg4/files/altivec.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 create mode 100644 srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
 create mode 100644 srcpkgs/ffmpeg4/template
 create mode 120000 srcpkgs/libavcodec4
 create mode 120000 srcpkgs/libavdevice4
 create mode 120000 srcpkgs/libavfilter4
 create mode 120000 srcpkgs/libavformat4
 create mode 120000 srcpkgs/libavresample4
 create mode 120000 srcpkgs/libavutil4
 create mode 120000 srcpkgs/libpostproc4
 create mode 120000 srcpkgs/libswresample4
 create mode 120000 srcpkgs/libswscale4

diff --git a/srcpkgs/ffmpeg4-devel b/srcpkgs/ffmpeg4-devel
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/ffmpeg4-devel
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/ffmpeg4/files/altivec.patch b/srcpkgs/ffmpeg4/files/altivec.patch
new file mode 100644
index 0000000000000..9c57200463320
--- /dev/null
+++ b/srcpkgs/ffmpeg4/files/altivec.patch
@@ -0,0 +1,60 @@
+revert some altivec specific change on all ppc* except ppc64le*
+
+q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
+conditionally, for ppc* but not ppc64le* (the new code is valid for
+POWER8 VSX which LE targets as a baseline but not BE)"
+
+
+This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
+---
+ libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
+ 1 file changed, 20 insertions(+), 4 deletions(-)
+
+diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
+index 536545293d..c1e2852adb 100644
+--- a/libswscale/ppc/yuv2rgb_altivec.c
++++ b/libswscale/ppc/yuv2rgb_altivec.c
+@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+     vector signed short R1, G1, B1;                                           \
+     vector unsigned char R, G, B;                                             \
+                                                                               \
++    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
++    vector unsigned char align_perm;                                          \
++                                                                              \
+     vector signed short lCY       = c->CY;                                    \
+     vector signed short lOY       = c->OY;                                    \
+     vector signed short lCRV      = c->CRV;                                   \
+@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
+                                                                               \
+         for (j = 0; j < w / 16; j++) {                                        \
+-            y0 = vec_xl(0, y1i);                                              \
++            y1ivP = (const vector unsigned char *) y1i;                       \
++            y2ivP = (const vector unsigned char *) y2i;                       \
++            uivP  = (const vector unsigned char *) ui;                        \
++            vivP  = (const vector unsigned char *) vi;                        \
++                                                                              \
++            align_perm = vec_lvsl(0, y1i);                                    \
++            y0 = (vector unsigned char)                                       \
++                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
+                                                                               \
+-            y1 = vec_xl(0, y2i);                                              \
++            align_perm = vec_lvsl(0, y2i);                                    \
++            y1 = (vector unsigned char)                                       \
++                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
+                                                                               \
+-            u = (vector signed char) vec_xl(0, ui);                           \
++            align_perm = vec_lvsl(0, ui);                                     \
++            u = (vector signed char)                                          \
++                    vec_perm(uivP[0], uivP[1], align_perm);                   \
+                                                                               \
+-            v = (vector signed char) vec_xl(0, vi);                           \
++            align_perm = vec_lvsl(0, vi);                                     \
++            v = (vector signed char)                                          \
++                    vec_perm(vivP[0], vivP[1], align_perm);                   \
+                                                                               \
+             u = (vector signed char)                                          \
+                     vec_sub(u,                                                \
+-- 
+2.27.0
+
diff --git a/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
new file mode 100644
index 0000000000000..9a55178c74f0f
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
@@ -0,0 +1,18 @@
+--- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
++++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
+@@ -39,6 +39,15 @@
+ #endif
+ #include <fenv.h>
+ 
++#if (FE_ALL_EXCEPT == 0)
++/* E.g. ARM soft float does not define these */
++#define FE_INVALID    0
++#define FE_DIVBYZERO  0
++#define FE_OVERFLOW   0
++#define FE_UNDERFLOW  0
++#define FE_INEXACT    0
++#endif
++
+ #if CONFIG_LIBFONTCONFIG
+ #include <fontconfig/fontconfig.h>
+ #endif
diff --git a/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
new file mode 100644
index 0000000000000..aa948f7a8a2df
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
@@ -0,0 +1,40 @@
+#==================================================================================================
+# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
+# From: Christopher Degawa <christopher.degawa@intel.com>
+# Date: Thu, 20 Oct 2022 22:55:27 -0500
+# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
+#
+# compressed_ten_bit_format has been deprecated upstream and has no effect
+# and can be removed. Plus, technically it was never used in the first place
+# since it would require the app (ffmpeg) to set it and do additional
+# processing of the input frames.
+#
+# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
+#
+# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
+#==================================================================================================
+--- a/libavcodec/libsvtav1.c
++++ b/libavcodec/libsvtav1.c
+@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
+ 
+ static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
+ {
+-    const int    pack_mode_10bit =
+-        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
+-    const size_t luma_size_8bit  =
+-        config->source_width * config->source_height * (1 << pack_mode_10bit);
+-    const size_t luma_size_10bit =
+-        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
++    const size_t luma_size = config->source_width * config->source_height *
++        (config->encoder_bit_depth > 8 ? 2 : 1);
+ 
+     EbSvtIOFormat *in_data;
+ 
+-    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
++    svt_enc->raw_size = luma_size * 3 / 2;
+ 
+     // allocate buffer for in and out
+     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
+-- 
+GitLab
+
diff --git a/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
new file mode 100644
index 0000000000000..00e3f68a415b8
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
@@ -0,0 +1,28 @@
+From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
+From: Rainer Hochecker <fernetmenta@online.de>
+Date: Sat, 26 Jan 2019 19:48:35 +0100
+Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
+
+This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
+It was hit frequently when watching h264 channels received via DVB-X.
+Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
+---
+ libavcodec/vaapi_h264.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
+index 5854587a255..f12fdc457a4 100644
+--- a/libavcodec/vaapi_h264.c
++++ b/libavcodec/vaapi_h264.c
+@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
+     H264SliceContext *sl = &h->slice_ctx[0];
+     int ret;
+ 
++    if (pic->nb_slices == 0) {
++        ret = AVERROR_INVALIDDATA;
++        goto finish;
++    }
++
+     ret = ff_vaapi_decode_issue(avctx, pic);
+     if (ret < 0)
+         goto finish;
diff --git a/srcpkgs/ffmpeg4/template b/srcpkgs/ffmpeg4/template
new file mode 100644
index 0000000000000..9ba14bdb8ddf3
--- /dev/null
+++ b/srcpkgs/ffmpeg4/template
@@ -0,0 +1,234 @@
+# Template file for 'ffmpeg4'
+# audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
+pkgname=ffmpeg4
+version=4.4.4
+revision=1
+short_desc="Decoding, encoding and streaming software - ffmpeg4 libraries only"
+maintainer="Orphaned <orphan@voidlinux.org>"
+license="GPL-3.0-or-later"
+homepage="https://www.ffmpeg.org"
+changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
+distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
+checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+
+hostmakedepends="pkg-config perl"
+makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
+ libXext-devel libXvMC-devel libxcb-devel lame-devel libtheora-devel
+ libvorbis-devel x264-devel xvidcore-devel jack-devel SDL2-devel
+ libcdio-paranoia-devel librtmp-devel libmodplug-devel gnutls-devel
+ speex-devel celt-devel harfbuzz-devel libass-devel opus-devel ocl-icd-devel
+ libbs2b-devel libvidstab-devel vmaf-devel $(vopt_if pulseaudio pulseaudio-devel)
+ $(vopt_if vaapi libva-devel) $(vopt_if vdpau libvdpau-devel)
+ $(vopt_if x265 x265-devel) $(vopt_if v4l2 v4l-utils-devel)
+ $(vopt_if fdk_aac fdk-aac-devel) $(vopt_if vpx libvpx-devel)
+ $(vopt_if aom libaom-devel) $(vopt_if sndio sndio-devel)
+ $(vopt_if dav1d libdav1d-devel) $(vopt_if zimg zimg-devel)
+ $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
+ $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
+ $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
+
+build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
+
+desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
+desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
+desc_option_sofa="Enable support for AES SOFA"
+desc_option_webp="Enable support for WebP"
+
+case "$XBPS_TARGET_MACHINE" in
+	i686*|x86_64*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau nvenc nvdec"
+			;;
+	ppc64*) build_options_default+=" vaapi vdpau";;
+	mips*) CFLAGS="-mnan=legacy";;
+esac
+
+if [ "$XBPS_TARGET_WORDSIZE" != "32" ]; then
+	build_options_default+=" svtav1"
+fi
+
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+fi
+
+_apply_patch() {
+	local args="$1" pname="$(basename $2)"
+
+	if [ ! -f ".${pname}_done" ]; then
+		patch -N $args -i $2
+		touch .${pname}_done
+	fi
+}
+
+post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64le*) ;;
+		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
+	esac
+
+	vsed -i libavfilter/vf_libvmaf.c -e 's!/usr/local/share/model/\(vmaf_v0.6.1\).pkl!/usr/share/vmaf/\1.json!'
+}
+
+do_configure() {
+	# Fix gcc on x86_64-musl only
+	if [ "$XBPS_TARGET_MACHINE" = "x86_64-musl" ]; then
+		vsed -i configure -e "s;_cflags_speed='-O3';_cflags_speed='-O2';"
+	fi
+
+	if [ "$CROSS_BUILD" ]; then
+		case "$XBPS_TARGET_MACHINE" in
+			arm*) _arch="arm";;
+			aarch64*) _arch="aarch64";;
+			mips*) _arch="mips";;
+			ppc64*) _arch="ppc64";;
+			ppc*) _arch="ppc";;
+			*) _arch="${XBPS_TARGET_MACHINE%%-musl}";;
+		esac
+
+		_args+=" --enable-cross-compile
+			--sysroot=$XBPS_CROSS_BASE
+			--cross-prefix=${XBPS_CROSS_TRIPLET}-
+			--target-os=linux --arch=${_arch}"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc|ppc-musl) _args+=" --disable-altivec";;
+	esac
+
+	if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+		_args+=" --extra-libs=-latomic"
+	fi
+
+	./configure --prefix=/usr --disable-debug --enable-gpl --enable-gnutls \
+		--disable-stripping \
+		--enable-libcdio --enable-version3 --enable-runtime-cpudetect \
+		--enable-libmp3lame --enable-libvorbis --enable-libxvid \
+		--enable-libx264 $(vopt_enable vpx libvpx) --enable-libtheora \
+		--enable-shared --enable-static --enable-libxcb \
+		$(vopt_enable pulseaudio libpulse) --enable-libfreetype --enable-libmodplug \
+		--enable-libspeex --enable-libcelt --enable-libass \
+		--enable-libopus --enable-librtmp --enable-libjack \
+		$(vopt_if fdk_aac '--enable-nonfree --enable-libfdk-aac') \
+		--disable-libopencore_amrnb --disable-libopencore_amrwb \
+		--disable-libopenjpeg \
+		--enable-postproc --enable-opencl ${_args} --enable-libvmaf ${_args} \
+		$(vopt_enable x265 libx265) \
+		$(vopt_enable v4l2 libv4l2) \
+		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
+		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		$(vopt_enable dav1d libdav1d) \
+		$(vopt_enable zimg libzimg) \
+		$(vopt_enable webp libwebp) \
+		$(vopt_enable sofa libmysofa) \
+		$(vopt_enable vulkan) \
+		$(vopt_enable drm libdrm) \
+		$(vopt_enable svtav1 libsvtav1) \
+		$(vopt_enable srt libsrt) \
+		$(vopt_enable rist librist) \
+		$(vopt_if nvenc '--enable-nvenc') \
+		$(vopt_if nvdec '--enable-nvdec')
+}
+
+do_build() {
+	make ${makejobs}
+	make doc/ff{mpeg,play}.1
+}
+
+do_install() {
+	make DESTDIR=${DESTDIR} install install-man
+	rm -rf ${DESTDIR}/usr/bin
+}
+
+libavcodec4_package() {
+	short_desc="FFmpeg codec library"
+	pkg_install() {
+		vmove "usr/lib/libavcodec.so.*"
+	}
+}
+
+libavdevice4_package() {
+	short_desc="FFmpeg device handling library"
+	pkg_install() {
+		vmove "usr/lib/libavdevice.so.*"
+	}
+}
+
+libavresample4_package() {
+	short_desc="FFmpeg audio resampling library"
+	pkg_install() {
+		vmove "usr/lib/libavresample.so.*"
+	}
+}
+
+libavformat4_package() {
+	short_desc="FFmpeg file format library"
+	pkg_install() {
+		vmove "usr/lib/libavformat.so.*"
+	}
+}
+
+libavutil4_package() {
+	short_desc="FFmpeg utility library"
+	pkg_install() {
+		vmove "usr/lib/libavutil.so.*"
+	}
+}
+
+libavfilter4_package() {
+	short_desc="FFmpeg audio/video filter library"
+	pkg_install() {
+		vmove "usr/lib/libavfilter.so.*"
+	}
+}
+
+libpostproc4_package() {
+	short_desc="FFmpeg video postprocessing library"
+	pkg_install() {
+		vmove "usr/lib/libpostproc.so.*"
+	}
+}
+
+libswscale4_package() {
+	short_desc="FFmpeg video scaling library"
+	pkg_install() {
+		vmove "usr/lib/libswscale.so.*"
+	}
+}
+
+libswresample4_package() {
+	short_desc="FFmpeg video resampling library"
+	pkg_install() {
+		vmove "usr/lib/libswresample.so.*"
+	}
+}
+
+ffmpeg4-devel_package() {
+	depends="
+		libavcodec4>=${version}_${revision}
+		libavdevice4>=${version}_${revision}
+		libavformat4>=${version}_${revision}
+		libavutil4>=${version}_${revision}
+		libavfilter4>=${version}_${revision}
+		libpostproc4>=${version}_${revision}
+		libswscale4>=${version}_${revision}
+		libswresample4>=${version}_${revision}
+		libavresample4>=${version}_${revision}"
+	short_desc+=" - development files"
+	conflicts="ffmpeg-devel"
+	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
+		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
+		nostrip_files="/usr/lib/libavfilter.a"
+	fi
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.a"
+		vmove "usr/lib/*.so"
+		vmove usr/share/ffmpeg/examples
+		vmove usr/share/man/man3
+	}
+}
diff --git a/srcpkgs/libavcodec4 b/srcpkgs/libavcodec4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavcodec4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavdevice4 b/srcpkgs/libavdevice4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavdevice4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavfilter4 b/srcpkgs/libavfilter4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavfilter4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavformat4 b/srcpkgs/libavformat4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavformat4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavresample4 b/srcpkgs/libavresample4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavutil4 b/srcpkgs/libavutil4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavutil4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libpostproc4 b/srcpkgs/libpostproc4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libpostproc4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswresample4 b/srcpkgs/libswresample4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libswresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswscale4 b/srcpkgs/libswscale4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libswscale4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file

From d651cb95594de611b0971b350f3b55f7e70dccfb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:04 -0400
Subject: [PATCH 005/113] opencv: update to 4.7.0.

---
 common/shlibs           | 104 ++++++++++++++++++++--------------------
 srcpkgs/opencv/template |   8 ++--
 2 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index c3cfbee902a4f..3ab5b363e7adb 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2085,58 +2085,58 @@ libcapstone.so.5 capstone-5.0.1_1
 libhavege.so.2 libhaveged-1.9.11_1
 libnih.so.1 libnih-1.0.3_1
 libnih-dbus.so.1 libnih-1.0.3_1
-libopencv_quality.so.406 libopencv-4.6.0_1
-libopencv_reg.so.406 libopencv-4.6.0_1
-libopencv_surface_matching.so.406 libopencv-4.6.0_1
-libopencv_xphoto.so.406 libopencv-4.6.0_1
-libopencv_freetype.so.406 libopencv-4.6.0_1
-libopencv_fuzzy.so.406 libopencv-4.6.0_1
-libopencv_hfs.so.406 libopencv-4.6.0_1
-libopencv_img_hash.so.406 libopencv-4.6.0_1
-libopencv_line_descriptor.so.406 libopencv-4.6.0_1
-libopencv_saliency.so.406 libopencv-4.6.0_1
-libopencv_structured_light.so.406 libopencv-4.6.0_1
-libopencv_aruco.so.406 libopencv-4.6.0_1
-libopencv_bgsegm.so.406 libopencv-4.6.0_1
-libopencv_bioinspired.so.406 libopencv-4.6.0_1
-libopencv_ccalib.so.406 libopencv-4.6.0_1
-libopencv_face.so.406 libopencv-4.6.0_1
-libopencv_tracking.so.406 libopencv-4.6.0_1
-libopencv_xfeatures2d.so.406 libopencv-4.6.0_1
-libopencv_optflow.so.406 libopencv-4.6.0_1
-libopencv_ximgproc.so.406 libopencv-4.6.0_1
-libopencv_plot.so.406 libopencv-4.6.0_1
-libopencv_text.so.406 libopencv-4.6.0_1
-libopencv_ml.so.406 libopencv-4.6.0_1
-libopencv_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn.so.406 libopencv-4.6.0_1
-libopencv_shape.so.406 libopencv-4.6.0_1
-libopencv_stitching.so.406 libopencv-4.6.0_1
-libopencv_photo.so.406 libopencv-4.6.0_1
-libopencv_video.so.406 libopencv-4.6.0_1
-libopencv_calib3d.so.406 libopencv-4.6.0_1
-libopencv_features2d.so.406 libopencv-4.6.0_1
-libopencv_flann.so.406 libopencv-4.6.0_1
-libopencv_highgui.so.406 libopencv-4.6.0_1
-libopencv_videoio.so.406 libopencv-4.6.0_1
-libopencv_imgcodecs.so.406 libopencv-4.6.0_1
-libopencv_imgproc.so.406 libopencv-4.6.0_1
-libopencv_core.so.406 libopencv-4.6.0_1
-libopencv_superres.so.406 libopencv-4.6.0_1
-libopencv_videostab.so.406 libopencv-4.6.0_1
-libopencv_gapi.so.406 libopencv-4.6.0_1
-libopencv_xobjdetect.so.406 libopencv-4.6.0_1
-libopencv_datasets.so.406 libopencv-4.6.0_1
-libopencv_dnn_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn_superres.so.406 libopencv-4.6.0_1
-libopencv_dpm.so.406 libopencv-4.6.0_1
-libopencv_phase_unwrapping.so.406 libopencv-4.6.0_1
-libopencv_stereo.so.406 libopencv-4.6.0_1
-libopencv_rapid.so.406 libopencv-4.6.0_1
-libopencv_intensity_transform.so.406 libopencv-4.6.0_1
-libopencv_alphamat.so.406 libopencv-4.6.0_1
-libopencv_barcode.so.406 libopencv-4.6.0_1
-libopencv_mcc.so.406 libopencv-4.6.0_1
+libopencv_quality.so.407 libopencv-4.7.0_1
+libopencv_reg.so.407 libopencv-4.7.0_1
+libopencv_surface_matching.so.407 libopencv-4.7.0_1
+libopencv_xphoto.so.407 libopencv-4.7.0_1
+libopencv_freetype.so.407 libopencv-4.7.0_1
+libopencv_fuzzy.so.407 libopencv-4.7.0_1
+libopencv_hfs.so.407 libopencv-4.7.0_1
+libopencv_img_hash.so.407 libopencv-4.7.0_1
+libopencv_line_descriptor.so.407 libopencv-4.7.0_1
+libopencv_saliency.so.407 libopencv-4.7.0_1
+libopencv_structured_light.so.407 libopencv-4.7.0_1
+libopencv_aruco.so.407 libopencv-4.7.0_1
+libopencv_bgsegm.so.407 libopencv-4.7.0_1
+libopencv_bioinspired.so.407 libopencv-4.7.0_1
+libopencv_ccalib.so.407 libopencv-4.7.0_1
+libopencv_face.so.407 libopencv-4.7.0_1
+libopencv_tracking.so.407 libopencv-4.7.0_1
+libopencv_xfeatures2d.so.407 libopencv-4.7.0_1
+libopencv_optflow.so.407 libopencv-4.7.0_1
+libopencv_ximgproc.so.407 libopencv-4.7.0_1
+libopencv_plot.so.407 libopencv-4.7.0_1
+libopencv_text.so.407 libopencv-4.7.0_1
+libopencv_ml.so.407 libopencv-4.7.0_1
+libopencv_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn.so.407 libopencv-4.7.0_1
+libopencv_shape.so.407 libopencv-4.7.0_1
+libopencv_stitching.so.407 libopencv-4.7.0_1
+libopencv_photo.so.407 libopencv-4.7.0_1
+libopencv_video.so.407 libopencv-4.7.0_1
+libopencv_calib3d.so.407 libopencv-4.7.0_1
+libopencv_features2d.so.407 libopencv-4.7.0_1
+libopencv_flann.so.407 libopencv-4.7.0_1
+libopencv_highgui.so.407 libopencv-4.7.0_1
+libopencv_videoio.so.407 libopencv-4.7.0_1
+libopencv_imgcodecs.so.407 libopencv-4.7.0_1
+libopencv_imgproc.so.407 libopencv-4.7.0_1
+libopencv_core.so.407 libopencv-4.7.0_1
+libopencv_superres.so.407 libopencv-4.7.0_1
+libopencv_videostab.so.407 libopencv-4.7.0_1
+libopencv_gapi.so.407 libopencv-4.7.0_1
+libopencv_xobjdetect.so.407 libopencv-4.7.0_1
+libopencv_datasets.so.407 libopencv-4.7.0_1
+libopencv_dnn_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn_superres.so.407 libopencv-4.7.0_1
+libopencv_dpm.so.407 libopencv-4.7.0_1
+libopencv_phase_unwrapping.so.407 libopencv-4.7.0_1
+libopencv_stereo.so.407 libopencv-4.7.0_1
+libopencv_rapid.so.407 libopencv-4.7.0_1
+libopencv_intensity_transform.so.407 libopencv-4.7.0_1
+libopencv_alphamat.so.407 libopencv-4.7.0_1
+libopencv_barcode.so.407 libopencv-4.7.0_1
+libopencv_mcc.so.407 libopencv-4.7.0_1
 libuniconf.so.4.6 wvstreams-4.6.1_20
 libwvbase.so.4.6 wvstreams-4.6.1_20
 libwvutils.so.4.6 wvstreams-4.6.1_20
diff --git a/srcpkgs/opencv/template b/srcpkgs/opencv/template
index aea4bfc3a265c..ce94de9424d18 100644
--- a/srcpkgs/opencv/template
+++ b/srcpkgs/opencv/template
@@ -1,7 +1,7 @@
 # Template file for 'opencv'
 pkgname=opencv
-version=4.6.0
-revision=6
+version=4.7.0
+revision=1
 create_wrksrc=yes
 build_wrksrc=${pkgname}-${version}
 build_style=cmake
@@ -24,8 +24,8 @@ homepage="https://opencv.org"
 changelog="https://github.com/opencv/opencv/wiki/ChangeLog"
 distfiles="https://github.com/opencv/opencv/archive/${version}.tar.gz
  https://github.com/opencv/opencv_contrib/archive/${version}.tar.gz>contrib.tar.gz"
-checksum="1ec1cba65f9f20fe5a41fda1586e01c70ea0c9a6d7b67c9e13edf0cfe2239277
- 1777d5fd2b59029cf537e5fd6f8aa68d707075822f90bde683fcde086f85f7a7"
+checksum="8df0079cdbe179748a18d44731af62a245a45ebf5085223dc03133954c662973
+ 42df840cf9055e59d0e22c249cfb19f04743e1bdad113d31b1573d3934d62584"
 patch_args="-Np1 -d ${build_wrksrc}"
 # tests hang indenfinitely, even with test data included
 make_check=no

From 41f8430f5e8c4c8ff50645725e27a86ea52dec4b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 006/113] actiona: revbump for opencv-4.7.0

---
 srcpkgs/actiona/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/actiona/template b/srcpkgs/actiona/template
index cf5f0b7a2ae61..0d899311e6df7 100644
--- a/srcpkgs/actiona/template
+++ b/srcpkgs/actiona/template
@@ -1,7 +1,7 @@
 # Template file for 'actiona'
 pkgname=actiona
 version=3.10.1
-revision=2
+revision=3
 build_style=qmake
 configure_args="PKGCONFIG_OPENCV=opencv4"
 hostmakedepends="pkg-config qt5-plugin-mysql qt5-qmake qt5-host-tools"

From a7e4b219503010f3df5b3398884de66b29888bea Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 007/113] retroshare: revbump for opencv-4.7.0

---
 srcpkgs/retroshare/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroshare/template b/srcpkgs/retroshare/template
index bb17569277a7f..49e2c1cbe8a53 100644
--- a/srcpkgs/retroshare/template
+++ b/srcpkgs/retroshare/template
@@ -1,7 +1,7 @@
 # Template file for 'retroshare'
 pkgname=retroshare
 version=0.6.6
-revision=3
+revision=4
 build_style=qmake
 #XXX broadcast feature requires an ancient udp-discovery-cpp which either needs
 # to be fetched+patched (FTBFS) here or packaged :/

From ce82dee66ea37e2e4643819a0cc920f678d92cc0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 008/113] waifu2x-converter-cpp: revbump for opencv-4.7.0

---
 srcpkgs/waifu2x-converter-cpp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waifu2x-converter-cpp/template b/srcpkgs/waifu2x-converter-cpp/template
index 361b8a23b9497..c5ac17eb54ea4 100644
--- a/srcpkgs/waifu2x-converter-cpp/template
+++ b/srcpkgs/waifu2x-converter-cpp/template
@@ -1,7 +1,7 @@
 # Template file for 'waifu2x-converter-cpp'
 pkgname=waifu2x-converter-cpp
 version=5.2.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DINSTALL_MODELS=ON"
 hostmakedepends="pkg-config"

From 3a6715653f890bd9c4f4bdbe632d0e06ee7b9464 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:38 -0400
Subject: [PATCH 009/113] vlc: revbump for ffmpeg4

---
 srcpkgs/vlc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vlc/template b/srcpkgs/vlc/template
index abc5eeba01564..5f291b1b81e23 100644
--- a/srcpkgs/vlc/template
+++ b/srcpkgs/vlc/template
@@ -25,7 +25,7 @@ lib32disabled=yes
 hostmakedepends="automake libtool pkg-config flex gettext libgcrypt-devel
  live555-devel gettext-devel $(vopt_if lua lua52) $(vopt_if chromecast protobuf)"
 makedepends="
- avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg-devel freefont-ttf
+ avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg4-devel freefont-ttf
  gnutls-devel jack-devel liba52-devel libass-devel libbluray-devel
  libcdio-devel libdca-devel libdvbpsi-devel libdvdnav-devel libmad-devel
  libmatroska-devel libmodplug-devel libmpcdec-devel libmpeg2-devel

From 5c31511362525633400b3aefb642a4e110fc14ec Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:55 -0400
Subject: [PATCH 010/113] osg: revbump for ffmpeg4

---
 srcpkgs/osg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/osg/template b/srcpkgs/osg/template
index a9ebbd287933b..755793f7e11bf 100644
--- a/srcpkgs/osg/template
+++ b/srcpkgs/osg/template
@@ -8,7 +8,7 @@ build_helper="qemu"
 configure_args="-DLIB_POSTFIX="
 hostmakedepends="pkg-config xrandr"
 makedepends="MesaLib-devel gtkglext-devel libcurl-devel giflib-devel librsvg-devel
- jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg-devel xine-lib-devel
+ jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg4-devel xine-lib-devel
  SDL2-devel gst-plugins-base1-devel
  $(vopt_if openexr libopenexr-devel)
  $(vopt_if poppler poppler-glib-devel)

From c499d3a3166c83f070dc94eaf4573eb51d2babb6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:13 -0400
Subject: [PATCH 011/113] xine-lib: revbump for ffmpeg4

---
 srcpkgs/xine-lib/template | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/xine-lib/template b/srcpkgs/xine-lib/template
index 3be4d08eac77a..ed6194c17d11e 100644
--- a/srcpkgs/xine-lib/template
+++ b/srcpkgs/xine-lib/template
@@ -1,14 +1,14 @@
 # Template file for 'xine-lib'
 pkgname=xine-lib
-version=1.2.12
-revision=3
+version=1.2.13
+revision=1
 build_style=gnu-configure
 configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
  --disable-oss"
 hostmakedepends="automake gettext-devel libtool pkg-config perl"
 makedepends="
  zlib-devel alsa-lib-devel libxcb-devel libSM-devel libXext-devel libXv-devel
- libXvMC-devel liba52-devel libmad-devel ffmpeg-devel pulseaudio-devel
+ libXvMC-devel liba52-devel libmad-devel ffmpeg4-devel pulseaudio-devel
  jack-devel samba-devel libflac-devel libmodplug-devel libmpcdec-devel
  speex-devel libtheora-devel libvorbis-devel libdca-devel faad2-devel
  libcdio-devel libbluray-devel aalib-devel libcaca-devel libXinerama-devel
@@ -19,7 +19,7 @@ license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="http://www.xine-project.org"
 changelog="https://sourceforge.net/projects/xine/files/xine-lib/${version}/README.txt/view"
 distfiles="${SOURCEFORGE_SITE}/xine/${pkgname}-${version}.tar.xz"
-checksum=d606270468e1540c2a89c0d7f5fdf11e17ecc0c2698cc0bcb1065ff26abee098
+checksum=5f10d6d718a4a51c17ed1b32b031d4f9b80b061e8276535b2be31e5ac4b75e6f
 
 case "$XBPS_TARGET_MACHINE" in
 	i686-musl)

From 0feddcbfac6764498a74ecb3e8c73cbe008cc302 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 012/113] arcan: revbump for ffmpeg6

---
 srcpkgs/arcan/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/arcan/template b/srcpkgs/arcan/template
index efd0afe10576d..b91e6900d42a1 100644
--- a/srcpkgs/arcan/template
+++ b/srcpkgs/arcan/template
@@ -2,7 +2,7 @@
 # !! keep synced with: acfgfs aclip aloadimage
 pkgname=arcan
 version=0.6.2.1
-revision=1
+revision=2
 create_wrksrc=yes
 build_wrksrc=arcan/src
 build_style=cmake

From 0e1194d73a397e20f8c265f37f3acea1c8b6e92a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 013/113] attract: revbump for ffmpeg4

---
 srcpkgs/attract/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/attract/template b/srcpkgs/attract/template
index 24017d2bacc24..e760bf0d18aec 100644
--- a/srcpkgs/attract/template
+++ b/srcpkgs/attract/template
@@ -6,7 +6,7 @@ build_style=gnu-makefile
 make_build_args="VERBOSE=1"
 make_use_env=yes
 hostmakedepends="pkg-config"
-makedepends="SFML-devel ffmpeg-devel fontconfig-devel glu-devel libarchive-devel
+makedepends="SFML-devel ffmpeg4-devel fontconfig-devel glu-devel libarchive-devel
  libcurl-devel libjpeg-turbo-devel xine-lib rapidjson libXrandr-devel"
 depends="git"
 short_desc="Attract-Mode is a graphical frontend for emulators"

From 031696d560b902e96e26fcff096a908c461f9a18 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 014/113] aubio: revbump for ffmpeg6

---
 srcpkgs/aubio/patches/ffmpeg5.patch | 25 +++++++++++++++++++++++++
 srcpkgs/aubio/template              |  2 +-
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/aubio/patches/ffmpeg5.patch

diff --git a/srcpkgs/aubio/patches/ffmpeg5.patch b/srcpkgs/aubio/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..aace41a6e6d9a
--- /dev/null
+++ b/srcpkgs/aubio/patches/ffmpeg5.patch
@@ -0,0 +1,25 @@
+From 8a05420e5dd8c7b8b2447f82dc919765876511b3 Mon Sep 17 00:00:00 2001
+From: Paul Brossier <piem@piem.org>
+Date: Tue, 25 Jan 2022 18:30:27 +0100
+Subject: [PATCH] [source_avcodec] define FF_API_LAVF_AVCTX for libavcodec >
+ 59, thx @berolinux (closes gh-353)
+
+---
+ src/io/source_avcodec.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/io/source_avcodec.c b/src/io/source_avcodec.c
+index e0ae93b5..1421bd9a 100644
+--- a/src/io/source_avcodec.c
++++ b/src/io/source_avcodec.c
+@@ -68,6 +68,10 @@
+ #define AUBIO_AVCODEC_MAX_BUFFER_SIZE AV_INPUT_BUFFER_MIN_SIZE
+ #endif
+ 
++#if LIBAVCODEC_VERSION_MAJOR >= 59
++#define FF_API_LAVF_AVCTX 1
++#endif
++
+ struct _aubio_source_avcodec_t {
+   uint_t hop_size;
+   uint_t samplerate;
diff --git a/srcpkgs/aubio/template b/srcpkgs/aubio/template
index ad1c4b2569917..7d875cc02541a 100644
--- a/srcpkgs/aubio/template
+++ b/srcpkgs/aubio/template
@@ -1,7 +1,7 @@
 # Template file for 'aubio'
 pkgname=aubio
 version=0.4.9
-revision=1
+revision=2
 build_style=waf3
 # XXX lash, pure and swig support.
 hostmakedepends="pkg-config txt2man"

From c2469387a261b979649734529d167a92c1178300 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 015/113] audacious-plugins: revbump for ffmpeg6

---
 .../audacious-plugins/patches/ffmpeg5.patch   | 43 +++++++++++++++++++
 srcpkgs/audacious-plugins/template            |  2 +-
 2 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/audacious-plugins/patches/ffmpeg5.patch

diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg5.patch b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..4e5e34099d71c
--- /dev/null
+++ b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
@@ -0,0 +1,43 @@
+commit 298aa371c56c2f52c25a33d9bdec4918b11cebdc
+Author: tibequadorian <tibequadorian@posteo.de>
+Date:   Sat Mar 19 18:40:12 2022 +0100
+
+    audacious-plugins: rebuild against ffmpeg-5.0
+
+diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+new file mode 100644
+index 0000000000..617c11215b
+--- /dev/null
++++ b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+@@ -0,0 +1,31 @@
++From f60beb400eeb1e4778bbfd738bc4a4ccef3de539 Mon Sep 17 00:00:00 2001
++From: John Lindgren <john@jlindgren.net>
++Date: Sat, 5 Mar 2022 12:05:34 -0500
++Subject: [PATCH] Fix build with FFmpeg 5.0
++
++---
++ src/ffaudio/ffaudio-core.cc | 4 ++--
++ 1 file changed, 2 insertions(+), 2 deletions(-)
++
++diff --git a/src/ffaudio/ffaudio-core.cc b/src/ffaudio/ffaudio-core.cc
++index 16dc63e3a..a2b95fd6c 100644
++--- a/src/ffaudio/ffaudio-core.cc
+++++ b/src/ffaudio/ffaudio-core.cc
++@@ -274,7 +274,7 @@ static AVInputFormat * get_format_by_content (const char * name, VFSFile & file)
++         AVProbeData d = {name, buf, filled};
++         score = target;
++ 
++-        f = av_probe_input_format2 (& d, true, & score);
+++        f = (AVInputFormat *) av_probe_input_format2 (& d, true, & score);
++         if (f)
++             break;
++ 
++@@ -347,7 +347,7 @@ static bool find_codec (AVFormatContext * c, CodecInfo * cinfo)
++ #endif
++         if (stream && stream->codecpar && stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
++         {
++-            AVCodec * codec = avcodec_find_decoder (stream->codecpar->codec_id);
+++            AVCodec * codec = (AVCodec *) avcodec_find_decoder (stream->codecpar->codec_id);
++ 
++             if (codec)
++             {
diff --git a/srcpkgs/audacious-plugins/template b/srcpkgs/audacious-plugins/template
index 05e53a9adf78f..4b1968e03de78 100644
--- a/srcpkgs/audacious-plugins/template
+++ b/srcpkgs/audacious-plugins/template
@@ -2,7 +2,7 @@
 #Keep in sync with audacious!
 pkgname=audacious-plugins
 version=4.3.1
-revision=3
+revision=4
 build_style=meson
 configure_args="$(vopt_bool gtk3 gtk) $(vopt_bool gtk3)
  $(vopt_bool qt) $(vopt_bool qt qt6)"

From 10cfa3cfb16970dad507fcd9d65b986ee6bbba18 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 016/113] audacity: revbump for ffmpeg4

---
 srcpkgs/audacity/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/audacity/template b/srcpkgs/audacity/template
index 7b838119ab261..fb15f782ac1f7 100644
--- a/srcpkgs/audacity/template
+++ b/srcpkgs/audacity/template
@@ -1,7 +1,7 @@
 # Template file for 'audacity'
 pkgname=audacity
 version=3.4.2
-revision=1
+revision=2
 build_style=cmake
 build_helper="cmake-wxWidgets-gtk3 qemu"
 configure_args="-Daudacity_use_ffmpeg=loaded -Daudacity_lib_preference=system
@@ -12,7 +12,7 @@ configure_args="-Daudacity_use_ffmpeg=loaded -Daudacity_lib_preference=system
  -Daudacity_has_updates_check=OFF -DAUDACITY_BUILD_LEVEL=2"
 hostmakedepends="pkg-config gettext python3"
 makedepends="wxWidgets-gtk3-devel gtk+3-devel expat-devel lame-devel
- libsoxr-devel portaudio-devel sqlite-devel ffmpeg-devel
+ libsoxr-devel portaudio-devel sqlite-devel ffmpeg4-devel
  libid3tag-devel libmad-devel vamp-plugin-sdk-devel libogg-devel
  libvorbis-devel libflac-devel lilv-devel lv2 serd-devel sord-devel
  sratom-devel suil-devel portmidi-devel soundtouch-devel twolame-devel

From 684877d6521d97f022e9867b70e6f38e507b4bf4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 017/113] avidemux: revbump for ffmpeg6

---
 srcpkgs/avidemux/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/avidemux/template b/srcpkgs/avidemux/template
index 253a0243e2259..557285982d2b8 100644
--- a/srcpkgs/avidemux/template
+++ b/srcpkgs/avidemux/template
@@ -1,7 +1,7 @@
 # Template file for 'avidemux'
 pkgname=avidemux
 version=2.8.0
-revision=2
+revision=3
 # Can't be compiled for aarch64, arm* or mips*
 archs="x86_64* i686*"
 hostmakedepends="cmake pkg-config qt5-host-tools qt5-devel tar yasm"

From bfd91c8318b93a3fe758b767cd7562a7b00f60ad Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 018/113] blender: revbump for ffmpeg6

---
 srcpkgs/blender/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index 05fdbf8f747e2..093d6d2004e95 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -9,8 +9,8 @@ configure_args="-DWITH_INSTALL_PORTABLE=OFF -DWITH_PYTHON_INSTALL=OFF
  -DWITH_JACK=ON -DWITH_CODEC_FFMPEG=ON -DWITH_CODEC_SNDFILE=ON -DWITH_OPENMP=ON
  -DWITH_FFTW3=ON -DWITH_MOD_OCEANSIM=ON -DWITH_CYCLES_EMBREE=OFF -DWITH_OPENCOLORIO=ON
  -DWITH_IMAGE_OPENEXR=ON -DWITH_IMAGE_OPENJPEG=ON -DWITH_OPENSUBDIV=ON
- -DWITH_OPENCOLLADA=ON -DWITH_SYSTEM_GLEW=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
- -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_LIBDECOR=ON
+ -DWITH_OPENCOLLADA=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
+ -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_WAYLAND_LIBDECOR=ON
  -DWITH_BUILDINFO=OFF -DPYTHON_VERSION=${py3_ver} -DPYTHON_LIBPATH=/usr/lib
  -DPYTHON_LIBRARY=python${py3_ver}${py3_abiver} -DPYTHON_INCLUDE_DIRS=/${py3_inc}
  -DWITH_SYSTEM_LZO=ON -DWITH_SYSTEM_EIGEN3=ON -DWITH_SYSTEM_FREETYPE=ON"

From aa8334637fe32f1e47ba56c7a4586fdf1b26df89 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 019/113] cantata: revbump for ffmpeg6

---
 srcpkgs/cantata/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cantata/template b/srcpkgs/cantata/template
index 4b417d80d5c2d..8a90aaa4c07a2 100644
--- a/srcpkgs/cantata/template
+++ b/srcpkgs/cantata/template
@@ -1,7 +1,7 @@
 # Template file for 'cantata'
 pkgname=cantata
 version=2.5.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools qt5-tools"
 makedepends="qt5-devel qt5-tools-devel qt5-svg-devel qt5-xmlpatterns-devel

From f9a6bb223767c174eb43865995313ac7d5f142cf Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 020/113] ccextractor: revbump for ffmpeg4

---
 srcpkgs/ccextractor/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/ccextractor/template b/srcpkgs/ccextractor/template
index 9abcd82852b27..6eccad5885af9 100644
--- a/srcpkgs/ccextractor/template
+++ b/srcpkgs/ccextractor/template
@@ -1,12 +1,12 @@
 # Template file for 'ccextractor'
 pkgname=ccextractor
 version=0.93
-revision=1
+revision=2
 build_wrksrc="linux"
 build_style=gnu-configure
 configure_args="--enable-ocr --enable-hardsubx"
 hostmakedepends="automake pkg-config"
-makedepends="leptonica-devel tesseract-ocr-devel ffmpeg-devel"
+makedepends="leptonica-devel tesseract-ocr-devel ffmpeg4-devel"
 short_desc="Extract subtitles from video streams"
 maintainer="newbluemoon <blaumolch@mailbox.org>"
 license="GPL-2.0-or-later"

From f1e35602384b6b63cdc5dcd1b3ec0c00424e458f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 021/113] chromaprint: revbump for ffmpeg6

---
 srcpkgs/chromaprint/patches/ffmpeg5.patch | 569 ++++++++++++++++++++++
 srcpkgs/chromaprint/template              |   2 +-
 2 files changed, 570 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromaprint/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromaprint/patches/ffmpeg5.patch b/srcpkgs/chromaprint/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..a9fd307a23c8a
--- /dev/null
+++ b/srcpkgs/chromaprint/patches/ffmpeg5.patch
@@ -0,0 +1,569 @@
+From 8ccad6937177b1b92e40ab8f4447ea27bac009a7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= <lalinsky@gmail.com>
+Date: Fri, 4 Nov 2022 21:47:38 +0100
+Subject: [PATCH] Use FFmpeg 5.x (#120)
+
+* Use FFmpeg 5.1.2 for CI builds
+
+* Build on Ubuntu 20.04
+
+* Upgrade code to FFmpeg 5.x APIs
+
+* Only set FFmpeg include dirs if building tools
+
+* No longer needed
+
+* Use ubuntu 20.04
+---
+ .github/workflows/build.yml                   |   6 +-
+ CMakeLists.txt                                |  16 --
+ package/build.sh                              |   4 +-
+ src/audio/ffmpeg_audio_processor.h            |   2 -
+ src/audio/ffmpeg_audio_processor_avresample.h |  72 -------
+ src/audio/ffmpeg_audio_processor_swresample.h |  18 +-
+ src/audio/ffmpeg_audio_reader.h               | 197 +++++++++---------
+ tests/CMakeLists.txt                          |   6 +
+ 8 files changed, 122 insertions(+), 199 deletions(-)
+ delete mode 100644 src/audio/ffmpeg_audio_processor_avresample.h
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index f8d6a32..4da2405 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -84,9 +84,6 @@ find_package(FFmpeg)
+ if(FFMPEG_LIBRARIES)
+ 	cmake_push_check_state(RESET)
+ 	set(CMAKE_REQUIRED_LIBRARIES ${FFMPEG_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -lm)
+-	check_function_exists(av_packet_unref HAVE_AV_PACKET_UNREF)
+-	check_function_exists(av_frame_alloc HAVE_AV_FRAME_ALLOC)
+-	check_function_exists(av_frame_free HAVE_AV_FRAME_FREE)
+ 	cmake_pop_check_state()
+ endif()
+
+@@ -163,14 +160,11 @@ message(STATUS "Using ${FFT_LIB} for FFT calculations")
+ if(NOT AUDIO_PROCESSOR_LIB)
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+ 		set(AUDIO_PROCESSOR_LIB "swresample")
+-	elseif(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(AUDIO_PROCESSOR_LIB "avresample")
+ 	endif()
+ endif()
+
+ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE OFF)
+ 		set(USE_SWRESAMPLE ON)
+ 		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBSWRESAMPLE_LIBRARIES})
+ 		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBSWRESAMPLE_INCLUDE_DIRS})
+@@ -178,16 +172,6 @@ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+ 	endif()
+ 	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+-elseif(AUDIO_PROCESSOR_LIB STREQUAL "avresample")
+-	if(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE ON)
+-		set(USE_SWRESAMPLE OFF)
+-		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBAVRESAMPLE_LIBRARIES})
+-		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBAVRESAMPLE_INCLUDE_DIRS})
+-	else()
+-		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+-	endif()
+-	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+ else()
+ 	message(STATUS "Building without audio conversion support, please install FFmpeg with libswresample")
+ endif()
+diff --git a/package/build.sh b/package/build.sh
+index da631ae..b41d36e 100755
+--- a/package/build.sh
++++ b/package/build.sh
+@@ -7,8 +7,8 @@ set -eux
+
+ BASE_DIR=$(cd $(dirname $0)/.. && pwd)
+
+-FFMPEG_VERSION=4.4.1
+-FFMPEG_BUILD_TAG=v4.4.1-1
++FFMPEG_VERSION=5.1.2
++FFMPEG_BUILD_TAG=v${FFMPEG_VERSION}-1
+
+ TMP_BUILD_DIR=$BASE_DIR/$(mktemp -d build.XXXXXXXX)
+ trap 'rm -rf $TMP_BUILD_DIR' EXIT
+diff --git a/src/audio/ffmpeg_audio_processor.h b/src/audio/ffmpeg_audio_processor.h
+index 7628fc7..39f4f6d 100644
+--- a/src/audio/ffmpeg_audio_processor.h
++++ b/src/audio/ffmpeg_audio_processor.h
+@@ -10,8 +10,6 @@
+
+ #if defined(USE_SWRESAMPLE)
+ #include "audio/ffmpeg_audio_processor_swresample.h"
+-#elif defined(USE_AVRESAMPLE)
+-#include "audio/ffmpeg_audio_processor_avresample.h"
+ #else
+ #error "no audio processing library"
+ #endif
+diff --git a/src/audio/ffmpeg_audio_processor_avresample.h b/src/audio/ffmpeg_audio_processor_avresample.h
+deleted file mode 100644
+index bd85f92..0000000
+--- a/src/audio/ffmpeg_audio_processor_avresample.h
++++ /dev/null
+@@ -1,72 +0,0 @@
+-// Copyright (C) 2016  Lukas Lalinsky
+-// Distributed under the MIT license, see the LICENSE file for details.
+-
+-#ifndef CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-#define CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-
+-extern "C" {
+-#include <libavresample/avresample.h>
+-}
+-
+-namespace chromaprint {
+-
+-class FFmpegAudioProcessor {
+-public:
+-	FFmpegAudioProcessor() {
+-		m_resample_ctx = avresample_alloc_context();
+-	}
+-
+-	~FFmpegAudioProcessor() {
+-		avresample_free(&m_resample_ctx);
+-	}
+-
+-	void SetCompatibleMode() {
+-		av_opt_set_int(m_resample_ctx, "filter_size", 16, 0);
+-		av_opt_set_int(m_resample_ctx, "phase_shift", 8, 0);
+-		av_opt_set_int(m_resample_ctx, "linear_interp", 1, 0);
+-		av_opt_set_double(m_resample_ctx, "cutoff", 0.8, 0);
+-	}
+-
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "in_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_rate", sample_rate, 0);
+-	}
+-
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "out_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_rate, 0);
+-	}
+-
+-	int Init() {
+-		return avresample_open(m_resample_ctx);
+-	}
+-
+-	int Convert(uint8_t **out, int out_count, const uint8_t **in, int in_count) {
+-		return avresample_convert(m_resample_ctx, out, 0, out_count, (uint8_t **) in, 0, in_count);
+-	}
+-
+-	int Flush(uint8_t **out, int out_count) {
+-		return avresample_read(m_resample_ctx, out, out_count);
+-	}
+-
+-private:
+-	AVAudioResampleContext *m_resample_ctx = nullptr;
+-};
+-
+-}; // namespace chromaprint
+-
+-#endif
+diff --git a/src/audio/ffmpeg_audio_processor_swresample.h b/src/audio/ffmpeg_audio_processor_swresample.h
+index b86266b..b1d4bea 100644
+--- a/src/audio/ffmpeg_audio_processor_swresample.h
++++ b/src/audio/ffmpeg_audio_processor_swresample.h
+@@ -28,30 +28,28 @@ public:
+ 		av_opt_set_double(m_swr_ctx, "cutoff", 0.8, 0);
+ 	}
+
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "icl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "ich", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetInputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "in_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "isf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "in_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "isr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "in_sample_rate", sample_rate, 0);
+ 	}
+
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "ocl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "och", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetOutputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "out_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "osf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "out_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "osr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "out_sample_rate", sample_rate, 0);
+ 	}
+
+ 	int Init() {
+diff --git a/src/audio/ffmpeg_audio_reader.h b/src/audio/ffmpeg_audio_reader.h
+index 5550164..1c6b346 100644
+--- a/src/audio/ffmpeg_audio_reader.h
++++ b/src/audio/ffmpeg_audio_reader.h
+@@ -62,7 +62,7 @@ public:
+ 	bool Read(const int16_t **data, size_t *size);
+
+ 	bool IsOpen() const { return m_opened; }
+-	bool IsFinished() const { return m_finished && !m_got_frame; }
++	bool IsFinished() const { return !m_has_more_packets && !m_has_more_frames; }
+
+ 	std::string GetError() const { return m_error; }
+ 	int GetErrorCode() const { return m_error_code; }
+@@ -74,20 +74,19 @@ private:
+ 	uint8_t *m_convert_buffer[1] = { nullptr };
+ 	int m_convert_buffer_nb_samples = 0;
+
+-	AVInputFormat *m_input_fmt = nullptr;
++	const AVInputFormat *m_input_fmt = nullptr;
+ 	AVDictionary *m_input_opts = nullptr;
+
+ 	AVFormatContext *m_format_ctx = nullptr;
+ 	AVCodecContext *m_codec_ctx = nullptr;
+-	AVFrame *m_frame = nullptr;
+ 	int m_stream_index = -1;
+ 	std::string m_error;
+ 	int m_error_code = 0;
+-	bool m_finished = false;
+ 	bool m_opened = false;
+-	int m_got_frame = 0;
+-	AVPacket m_packet;
+-	AVPacket m_packet0;
++	bool m_has_more_packets = true;
++	bool m_has_more_frames = true;
++	AVPacket *m_packet = nullptr;
++	AVFrame *m_frame = nullptr;
+
+ 	int m_output_sample_rate = 0;
+ 	int m_output_channels = 0;
+@@ -98,19 +97,12 @@ private:
+
+ inline FFmpegAudioReader::FFmpegAudioReader() {
+ 	av_log_set_level(AV_LOG_QUIET);
+-
+-	av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
+ }
+
+ inline FFmpegAudioReader::~FFmpegAudioReader() {
+ 	Close();
+ 	av_dict_free(&m_input_opts);
+ 	av_freep(&m_convert_buffer[0]);
+-	av_packet_unref(&m_packet0);
+ }
+
+ inline bool FFmpegAudioReader::SetInputFormat(const char *name) {
+@@ -135,11 +127,10 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ 	Close();
+
+-    av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
++	m_packet = av_packet_alloc();
++	if (!m_packet) {
++		return false;
++	}
+
+ 	ret = avformat_open_input(&m_format_ctx, file_name.c_str(), m_input_fmt, &m_input_opts);
+ 	if (ret < 0) {
+@@ -153,26 +144,31 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		return false;
+ 	}
+
+-	AVCodec *codec;
++	const AVCodec *codec;
+ 	ret = av_find_best_stream(m_format_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &codec, 0);
+ 	if (ret < 0) {
+ 		SetError("Could not find any audio stream in the file", ret);
+ 		return false;
+ 	}
+ 	m_stream_index = ret;
++	auto stream = m_format_ctx->streams[m_stream_index];
+
+-	m_codec_ctx = m_format_ctx->streams[m_stream_index]->codec;
++	m_codec_ctx = avcodec_alloc_context3(codec);
+ 	m_codec_ctx->request_sample_fmt = AV_SAMPLE_FMT_S16;
+
++	ret = avcodec_parameters_to_context(m_codec_ctx, stream->codecpar);
++	if (ret < 0) {
++		SetError("Could not copy the stream parameters", ret);
++		return false;
++	}
++
+ 	ret = avcodec_open2(m_codec_ctx, codec, nullptr);
+ 	if (ret < 0) {
+ 		SetError("Could not open the codec", ret);
+ 		return false;
+ 	}
+
+-	if (!m_codec_ctx->channel_layout) {
+-		m_codec_ctx->channel_layout = av_get_default_channel_layout(m_codec_ctx->channels);
+-	}
++	av_dump_format(m_format_ctx, 0, "foo", 0);
+
+ 	m_frame = av_frame_alloc();
+ 	if (!m_frame) {
+@@ -183,19 +179,23 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		m_output_sample_rate = m_codec_ctx->sample_rate;
+ 	}
+
+-	if (!m_output_channels) {
+-		m_output_channels = m_codec_ctx->channels;
++	AVChannelLayout output_channel_layout;
++	if (m_output_channels) {
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
++	} else {
++		m_output_channels = m_codec_ctx->ch_layout.nb_channels;
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
+ 	}
+
+-	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
++	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->ch_layout.nb_channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
+ 		m_converter.reset(new FFmpegAudioProcessor());
+ 		m_converter->SetCompatibleMode();
+ 		m_converter->SetInputSampleFormat(m_codec_ctx->sample_fmt);
+ 		m_converter->SetInputSampleRate(m_codec_ctx->sample_rate);
+-		m_converter->SetInputChannelLayout(m_codec_ctx->channel_layout);
++		m_converter->SetInputChannelLayout(&(m_codec_ctx->ch_layout));
+ 		m_converter->SetOutputSampleFormat(AV_SAMPLE_FMT_S16);
+ 		m_converter->SetOutputSampleRate(m_output_sample_rate);
+-		m_converter->SetOutputChannelLayout(av_get_default_channel_layout(m_output_channels));
++		m_converter->SetOutputChannelLayout(&output_channel_layout);
+ 		auto ret = m_converter->Init();
+ 		if (ret != 0) {
+ 			SetError("Could not create an audio converter instance", ret);
+@@ -203,10 +203,11 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		}
+ 	}
+
++	av_channel_layout_uninit(&output_channel_layout);
++
+ 	m_opened = true;
+-	m_finished = false;
+-	m_got_frame = 0;
+-	m_nb_packets = 0;
++	m_has_more_packets = true;
++	m_has_more_frames = true;
+ 	m_decode_error = 0;
+
+ 	return true;
+@@ -214,6 +215,7 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ inline void FFmpegAudioReader::Close() {
+ 	av_frame_free(&m_frame);
++	av_packet_free(&m_packet);
+
+ 	m_stream_index = -1;
+
+@@ -252,91 +254,98 @@ inline bool FFmpegAudioReader::Read(const int16_t **data, size_t *size) {
+ 		return false;
+ 	}
+
++	*data = nullptr;
++	*size = 0;
++
+ 	int ret;
++	bool needs_packet = false;
+ 	while (true) {
+-		while (m_packet.size <= 0) {
+-			av_packet_unref(&m_packet0);
+-			av_init_packet(&m_packet);
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			ret = av_read_frame(m_format_ctx, &m_packet);
++		while (needs_packet && m_packet->size == 0) {
++			ret = av_read_frame(m_format_ctx, m_packet);
+ 			if (ret < 0) {
+ 				if (ret == AVERROR_EOF) {
+-					m_finished = true;
++					needs_packet = false;
++					m_has_more_packets = false;
+ 					break;
+-				} else {
++				}
++				SetError("Error reading from the audio source", ret);
++				return false;
++			}
++			if (m_packet->stream_index == m_stream_index) {
++				needs_packet = false;
++			} else {
++				av_packet_unref(m_packet);
++			}
++		}
++
++		if (m_packet->size != 0) {
++			ret = avcodec_send_packet(m_codec_ctx, m_packet);
++			if (ret < 0) {
++				if (ret != AVERROR(EAGAIN)) {
+ 					SetError("Error reading from the audio source", ret);
+ 					return false;
+ 				}
+-			}
+-			m_packet0 = m_packet;
+-			if (m_packet.stream_index != m_stream_index) {
+-				m_packet.data = nullptr;
+-				m_packet.size = 0;
+ 			} else {
+-				m_nb_packets++;
++				av_packet_unref(m_packet);
+ 			}
+ 		}
+
+-		ret = avcodec_decode_audio4(m_codec_ctx, m_frame, &m_got_frame, &m_packet);
++		ret = avcodec_receive_frame(m_codec_ctx, m_frame);
+ 		if (ret < 0) {
+-			if (m_decode_error) {
+-				SetError("Error decoding audio frame", m_decode_error);
+-				return false;
++			if (ret == AVERROR_EOF) {
++				m_has_more_frames = false;
++			} else if (ret == AVERROR(EAGAIN)) {
++				if (m_has_more_packets) {
++					needs_packet = true;
++					continue;
++				} else {
++					m_has_more_frames = false;
++				}
+ 			}
+-			m_decode_error = ret;
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			continue;
++			SetError("Error decoding the audio source", ret);
++			return false;
+ 		}
+
+-		break;
+-	}
+-
+-	m_decode_error = 0;
+-
+-	const int decoded = std::min(ret, m_packet.size);
+-	m_packet.data += decoded;
+-	m_packet.size -= decoded;
+-
+-	if (m_got_frame) {
+-		if (m_converter) {
+-			if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
+-				int linsize;
+-				av_freep(&m_convert_buffer[0]);
+-				m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
+-				ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
+-				if (ret < 0) {
+-					SetError("Couldn't allocate audio converter buffer", ret);
++		if (m_frame->nb_samples > 0) {
++			if (m_converter) {
++				if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
++					int linsize;
++					av_freep(&m_convert_buffer[0]);
++					m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
++					ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->ch_layout.nb_channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
++					if (ret < 0) {
++						SetError("Couldn't allocate audio converter buffer", ret);
++						return false;
++					}
++				}
++				auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
++				if (nb_samples < 0) {
++					SetError("Couldn't convert audio", ret);
+ 					return false;
+ 				}
+-			}
+-			auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			}
+-			*data = (const int16_t *) m_convert_buffer[0];
+-			*size = nb_samples;
+-		} else {
+-			*data = (const int16_t *) m_frame->data[0];
+-			*size = m_frame->nb_samples;
+-		}
+-	} else {
+-		if (m_finished && m_converter) {
+-			auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			} else if (nb_samples > 0) {
+-				m_got_frame = 1;
+ 				*data = (const int16_t *) m_convert_buffer[0];
+ 				*size = nb_samples;
++			} else {
++				*data = (const int16_t *) m_frame->data[0];
++				*size = m_frame->nb_samples;
++			}
++		} else {
++			if (m_converter) {
++				if (IsFinished()) {
++					auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
++					if (nb_samples < 0) {
++						SetError("Couldn't convert audio", ret);
++						return false;
++					} else if (nb_samples > 0) {
++						*data = (const int16_t *) m_convert_buffer[0];
++						*size = nb_samples;
++					}
++				}
+ 			}
+ 		}
+-	}
+
+-	return true;
++		return true;
++	}
+ }
+
+ inline void FFmpegAudioReader::SetError(const char *message, int errnum) {
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index a2b517b..123e643 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -38,6 +38,12 @@ set(SRCS
+
+ if(BUILD_TOOLS)
+ 	set(SRCS ${SRCS} ../src/audio/ffmpeg_audio_reader_test.cpp)
++    include_directories(
++        ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}
++        ${AUDIO_PROCESSOR_INCLUDE_DIRS}
++    )
+ 	link_libraries(fpcalc_libs)
+ endif()
+
+-- 
+2.38.1
+
+
diff --git a/srcpkgs/chromaprint/template b/srcpkgs/chromaprint/template
index 7ef7838949f3a..1f7bbc70a22c8 100644
--- a/srcpkgs/chromaprint/template
+++ b/srcpkgs/chromaprint/template
@@ -1,7 +1,7 @@
 # Template file for 'chromaprint'
 pkgname=chromaprint
 version=1.5.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DBUILD_TOOLS=ON"
 make_check_target="check"

From 57929d68125e4b0b3ef692116e42ec9cf2ccb89b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 022/113] chromium: revbump for ffmpeg6

---
 .../patches/chromium-119-ffmpeg-4.4.patch     | 20 --------
 srcpkgs/chromium/patches/ffmpeg5.patch        | 47 +++++++++++++++++++
 srcpkgs/chromium/template                     |  2 +-
 3 files changed, 48 insertions(+), 21 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch
 create mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch b/srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch
deleted file mode 100644
index 04d04b166ba37..0000000000000
--- a/srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch
+++ /dev/null
@@ -1,20 +0,0 @@
---- a/media/filters/ffmpeg_demuxer.cc.orig
-+++ b/media/filters/ffmpeg_demuxer.cc
-@@ -390,7 +390,7 @@
- 
-   scoped_refptr<DecoderBuffer> buffer;
- 
--    size_t side_data_size = 0;
-+    int side_data_size = 0;
-     uint8_t* side_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
- 
-@@ -453,7 +453,7 @@
-                                        packet->size - data_offset);
-     }
- 
--    size_t skip_samples_size = 0;
-+    int skip_samples_size = 0;
-     const uint32_t* skip_samples_ptr =
-         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
-             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..24e2da38e34ca
--- /dev/null
+++ b/srcpkgs/chromium/patches/ffmpeg5.patch
@@ -0,0 +1,47 @@
+--- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
++++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
+@@ -92,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+-  if (stream->start_time != kNoFFmpegTimestamp)
++  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -1597,7 +1585,7 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+@@ -1618,7 +1606,7 @@
+     if (stream->type() != DemuxerStream::VIDEO)
+       continue;
+ 
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+ 
+     if (!stream->IsEnabled())
diff --git a/srcpkgs/chromium/template b/srcpkgs/chromium/template
index 44cc292c3e078..629e6c007e8dc 100644
--- a/srcpkgs/chromium/template
+++ b/srcpkgs/chromium/template
@@ -2,7 +2,7 @@
 pkgname=chromium
 # See https://chromiumdash.appspot.com/releases?platform=Linux for the latest version
 version=120.0.6099.109
-revision=1
+revision=2
 archs="i686* x86_64* aarch64* armv7l*"
 hostmakedepends="
  $(vopt_if clang "clang lld llvm15")

From 07854706ad5d064d95eebb9488b0ab3d57253332 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 023/113] cmus: revbump for ffmpeg6

---
 srcpkgs/chromium/patches/ffmpeg5.patch | 47 --------------------------
 srcpkgs/cmus/patches/ffmpeg6.patch     | 12 +++++++
 srcpkgs/cmus/template                  |  2 +-
 3 files changed, 13 insertions(+), 48 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch
 create mode 100644 srcpkgs/cmus/patches/ffmpeg6.patch

diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
deleted file mode 100644
index 24e2da38e34ca..0000000000000
--- a/srcpkgs/chromium/patches/ffmpeg5.patch
+++ /dev/null
@@ -1,47 +0,0 @@
---- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
-+++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
-@@ -92,24 +92,12 @@
- 
- static base::TimeDelta ExtractStartTime(AVStream* stream) {
-   // The default start time is zero.
--  base::TimeDelta start_time;
-+  base::TimeDelta start_time = kNoTimestamp;
- 
-   // First try to use  the |start_time| value as is.
--  if (stream->start_time != kNoFFmpegTimestamp)
-+  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
-     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
- 
--  // Next try to use the first DTS value, for codecs where we know PTS == DTS
--  // (excludes all H26x codecs). The start time must be returned in PTS.
--  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
--      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
--      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
--      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
--    const base::TimeDelta first_pts =
--        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
--    if (first_pts < start_time)
--      start_time = first_pts;
--  }
--
-   return start_time;
- }
- 
-@@ -1597,7 +1585,7 @@
-   for (const auto& stream : streams_) {
-     if (!stream || stream->IsEnabled() != enabled)
-       continue;
--    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
-+    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
-       continue;
-     if (!lowest_start_time_stream ||
-         stream->start_time() < lowest_start_time_stream->start_time()) {
-@@ -1618,7 +1606,7 @@
-     if (stream->type() != DemuxerStream::VIDEO)
-       continue;
- 
--    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
-+    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
-       continue;
- 
-     if (!stream->IsEnabled())
diff --git a/srcpkgs/cmus/patches/ffmpeg6.patch b/srcpkgs/cmus/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..ffa95ab811101
--- /dev/null
+++ b/srcpkgs/cmus/patches/ffmpeg6.patch
@@ -0,0 +1,12 @@
+--- a/ip/ffmpeg.c
++++ b/ip/ffmpeg.c
+@@ -202,9 +202,6 @@ static int ffmpeg_open(struct input_plugin_data *ip_data)
+ 			break;
+ 		}
+ 
+-		if (codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+-			cc->flags |= AV_CODEC_FLAG_TRUNCATED;
+-
+ 		if (avcodec_open2(cc, codec, NULL) < 0) {
+ 			d_print("could not open codec: %d, %s\n", cc->codec_id, avcodec_get_name(cc->codec_id));
+ 			err = -IP_ERROR_UNSUPPORTED_FILE_TYPE;
diff --git a/srcpkgs/cmus/template b/srcpkgs/cmus/template
index 0d1436744f1b2..a6e4b4fa86cb8 100644
--- a/srcpkgs/cmus/template
+++ b/srcpkgs/cmus/template
@@ -1,7 +1,7 @@
 # Template file for 'cmus'
 pkgname=cmus
 version=2.10.0
-revision=3
+revision=4
 build_style=configure
 configure_args="prefix=/usr LD=$CC"
 hostmakedepends="pkg-config"

From 089bb0e8e11e929f600f68f268812357cb7f6c99 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 024/113] cyanrip: revbump for ffmpeg6

---
 srcpkgs/cyanrip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cyanrip/template b/srcpkgs/cyanrip/template
index 9796e3461601a..5db30e020d17e 100644
--- a/srcpkgs/cyanrip/template
+++ b/srcpkgs/cyanrip/template
@@ -1,7 +1,7 @@
 # Template file for 'cyanrip'
 pkgname=cyanrip
 version=0.9.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config"
 makedepends="ffmpeg-devel libcdio-devel libcdio-paranoia-devel libcurl-devel libmusicbrainz5-devel"

From 61f6d81c367d182003c427d674bab00250670150 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 025/113] deadbeef: revbump for ffmpeg4

---
 srcpkgs/deadbeef/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/deadbeef/template b/srcpkgs/deadbeef/template
index f5f4bf24b8cb6..7b47e615cd48e 100644
--- a/srcpkgs/deadbeef/template
+++ b/srcpkgs/deadbeef/template
@@ -1,14 +1,14 @@
 # Template file for 'deadbeef'
 pkgname=deadbeef
 version=1.8.8
-revision=3
+revision=4
 create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-oss --disable-lfm --disable-notify --disable-gtk2"
 hostmakedepends="automake libtool gettext gettext-devel intltool pkg-config
  yasm clang glib-devel"
 makedepends="
- alsa-lib-devel dbus-devel faad2-devel ffmpeg-devel gtk+3-devel imlib2-devel
+ alsa-lib-devel dbus-devel faad2-devel ffmpeg4-devel gtk+3-devel imlib2-devel
  jansson-devel libcddb-devel libcdio-devel libcurl-devel libflac-devel
  libmad-devel libpng-devel libsamplerate-devel libsndfile-devel libvorbis-devel
  libzip-devel mpg123-devel opusfile-devel pulseaudio-devel wavpack-devel"

From 9ff97561f5f8a6f2a0ccbe7d6a3dd975da2ad1af Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 026/113] droidcam-obs-plugin: revbump for ffmpeg6

---
 srcpkgs/droidcam-obs-plugin/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam-obs-plugin/template b/srcpkgs/droidcam-obs-plugin/template
index fc9c9bf6b9d54..fb0480754df4d 100644
--- a/srcpkgs/droidcam-obs-plugin/template
+++ b/srcpkgs/droidcam-obs-plugin/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam-obs-plugin'
 pkgname=droidcam-obs-plugin
 version=2.0.1
-revision=1
+revision=2
 build_style=gnu-makefile
 make_use_env=yes
 make_build_args="ALLOW_STATIC=no"

From 52972c0485ff79aa5072be2401016a551ee502c2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 027/113] droidcam: revbump for ffmpeg6

---
 srcpkgs/droidcam/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam/template b/srcpkgs/droidcam/template
index 1c3f1b8b1fc67..32a9220b79a4d 100644
--- a/srcpkgs/droidcam/template
+++ b/srcpkgs/droidcam/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam'
 pkgname=droidcam
 version=1.8.2
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="USBMUXD=-lusbmuxd-2.0 JPEG=-lturbojpeg"
 hostmakedepends="pkg-config"

From 5d0299b856f24aab8d34d32d14e8e579d5ae4668 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 028/113] ffmpegthumbnailer: revbump for ffmpeg6

---
 .../ffmpegthumbnailer/patches/ffmpeg6.patch   | 202 ++++++++++++++++++
 srcpkgs/ffmpegthumbnailer/template            |   6 +-
 2 files changed, 205 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch

diff --git a/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..363ff35a28419
--- /dev/null
+++ b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
@@ -0,0 +1,202 @@
+--- a/libffmpegthumbnailer/moviedecoder.cpp	2017-11-21 14:06:57.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.cpp	2023-05-05 13:14:47.946560668 -0400
+@@ -41,11 +41,6 @@
+ namespace ffmpegthumbnailer
+ {
+ 
+-struct SilenceLogLevel
+-{
+-    SilenceLogLevel() { av_log_set_level(AV_LOG_QUIET); }
+-};
+-
+ MovieDecoder::MovieDecoder(AVFormatContext* pavContext)
+ : m_VideoStream(-1)
+ , m_pFormatContext(pavContext)
+@@ -70,8 +65,6 @@
+ 
+ void MovieDecoder::initialize(const string& filename, bool preferEmbeddedMetadata)
+ {
+-    av_register_all();
+-    avcodec_register_all();
+     avformat_network_init();
+ 
+     string inputFile = filename == "-" ? "pipe:" : filename;
+@@ -97,8 +90,7 @@
+ {
+     if (m_pVideoCodecContext)
+     {
+-        avcodec_close(m_pVideoCodecContext);
+-        m_pVideoCodecContext = nullptr;
++        avcodec_free_context(&m_pVideoCodecContext);
+     }
+ 
+     if ((!m_FormatContextWasGiven) && m_pFormatContext)
+@@ -152,10 +144,10 @@
+     for (unsigned int i = 0; i < m_pFormatContext->nb_streams; ++i)
+     {
+         AVStream *stream = m_pFormatContext->streams[i];
+-        auto ctx = m_pFormatContext->streams[i]->codec;
+-        if (ctx->codec_type == AVMEDIA_TYPE_VIDEO)
++        auto par = m_pFormatContext->streams[i]->codecpar;
++        if (par->codec_type == AVMEDIA_TYPE_VIDEO)
+         {
+-            if (!preferEmbeddedMetadata || !isStillImageCodec(ctx->codec_id))
++            if (!preferEmbeddedMetadata || !isStillImageCodec(par->codec_id))
+             {
+                 videoStreams.push_back(i);
+                 continue;
+@@ -203,8 +195,7 @@
+     }
+ 
+     m_pVideoStream = m_pFormatContext->streams[m_VideoStream];
+-    m_pVideoCodecContext = m_pVideoStream->codec;
+-    m_pVideoCodec = avcodec_find_decoder(m_pVideoCodecContext->codec_id);
++    m_pVideoCodec = avcodec_find_decoder(m_pVideoStream->codecpar->codec_id);
+ 
+     if (m_pVideoCodec == nullptr)
+     {
+@@ -214,6 +205,20 @@
+         throw logic_error("Video Codec not found");
+     }
+ 
++    m_pVideoCodecContext = avcodec_alloc_context3(m_pVideoCodec);
++
++    if (m_pVideoCodecContext == nullptr)
++    {
++        destroy();
++        throw logic_error("Could not allocate video codec context");
++    }
++
++    if (avcodec_parameters_to_context(m_pVideoCodecContext, m_pVideoStream->codecpar) < 0)
++    {
++        destroy();
++        throw logic_error("Could not configure video codec context");
++    }
++
+     m_pVideoCodecContext->workaround_bugs = 1;
+ 
+     if (avcodec_open2(m_pVideoCodecContext, m_pVideoCodec, nullptr) < 0)
+@@ -386,13 +391,6 @@
+ 
+ void MovieDecoder::initializeFilterGraph(const AVRational& timeBase, const std::string& size, bool maintainAspectRatio)
+ {
+-    static const AVPixelFormat pixelFormats[] = { AV_PIX_FMT_RGB24, AV_PIX_FMT_NONE };
+-
+-    auto del = [] (AVBufferSinkParams* p) { av_freep(p); };
+-    std::unique_ptr<AVBufferSinkParams, decltype(del)> buffersinkParams(av_buffersink_params_alloc(), del);
+-
+-    avfilter_register_all();
+-
+     m_pFilterGraph = avfilter_graph_alloc();
+     assert(m_pFilterGraph);
+ 
+@@ -404,10 +402,8 @@
+ 
+     checkRc(avfilter_graph_create_filter(&m_pFilterSource, avfilter_get_by_name("buffer"), "thumb_buffer", ss.str().c_str(), nullptr, m_pFilterGraph),
+             "Failed to create filter source");
+-    buffersinkParams->pixel_fmts = pixelFormats;
+-    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, buffersinkParams.get(), m_pFilterGraph),
++    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, nullptr, m_pFilterGraph),
+             "Failed to create filter sink");
+-    buffersinkParams.release();
+ 
+     AVFilterContext* yadifFilter = nullptr;
+     if (m_pFrame->interlaced_frame != 0)
+@@ -500,15 +496,15 @@
+     }
+ 
+     checkRc(av_seek_frame(m_pFormatContext, -1, timestamp, 0), "Seeking in video failed");
+-    avcodec_flush_buffers(m_pFormatContext->streams[m_VideoStream]->codec);
++    avcodec_flush_buffers(m_pVideoCodecContext);
+ 
+     int keyFrameAttempts = 0;
+-    bool gotFrame = 0;
++    bool gotFrame;
+ 
+     do
+     {
+         int count = 0;
+-        gotFrame = 0;
++        gotFrame = false;
+ 
+         while (!gotFrame && count < 20)
+         {
+@@ -552,17 +548,33 @@
+         return false;
+     }
+ 
+-    av_frame_unref(m_pFrame);
+-
+-    int frameFinished;
++    int rc = avcodec_send_packet(m_pVideoCodecContext, m_pPacket);
++    if(rc == AVERROR(EAGAIN))
++    {
++        rc = 0;
++    }
+ 
+-    int bytesDecoded = avcodec_decode_video2(m_pVideoCodecContext, m_pFrame, &frameFinished, m_pPacket);
+-    if (bytesDecoded < 0)
++    if(rc == AVERROR_EOF)
++    {
++        return false;
++    }
++    else if(rc < 0)
+     {
+-        throw logic_error("Failed to decode video frame: bytesDecoded < 0");
++        throw logic_error("Failed to decode video frame: avcodec_send_packet() < 0");
+     }
+ 
+-    return frameFinished > 0;
++    rc = avcodec_receive_frame(m_pVideoCodecContext, m_pFrame);
++    switch(rc)
++    {
++        case 0:
++            return true;
++
++        case AVERROR(EAGAIN):
++            return false;
++
++        default:
++            throw logic_error("Failed to decode video frame: avcodec_receive_frame() < 0");
++    }
+ }
+ 
+ bool MovieDecoder::getVideoPacket()
+@@ -570,8 +582,6 @@
+     bool framesAvailable = true;
+     bool frameDecoded = false;
+ 
+-    int attempts = 0;
+-
+     if (m_pPacket)
+     {
+         av_packet_unref(m_pPacket);
+@@ -580,6 +590,7 @@
+ 
+     m_pPacket = new AVPacket();
+ 
++
+     while (framesAvailable && !frameDecoded)
+     {
+         framesAvailable = av_read_frame(m_pFormatContext, m_pPacket) >= 0;
+@@ -644,7 +655,7 @@
+ 
+ int32_t MovieDecoder::getStreamRotation()
+ {
+-    int32_t* matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
++    auto matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
+     if (matrix)
+     {
+         auto angle = lround(av_display_rotation_get(matrix));
+
+--- a/libffmpegthumbnailer/moviedecoder.h	2017-11-12 04:23:38.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.h	2023-05-05 13:26:07.095529911 -0400
+@@ -78,7 +78,7 @@
+     int                     m_VideoStream;
+     AVFormatContext*        m_pFormatContext;
+     AVCodecContext*         m_pVideoCodecContext;
+-    AVCodec*                m_pVideoCodec;
++    const AVCodec*          m_pVideoCodec;
+     AVFilterGraph*          m_pFilterGraph;
+     AVFilterContext*        m_pFilterSource;
+     AVFilterContext*        m_pFilterSink;
diff --git a/srcpkgs/ffmpegthumbnailer/template b/srcpkgs/ffmpegthumbnailer/template
index 039eea7622b39..35d546018d12a 100644
--- a/srcpkgs/ffmpegthumbnailer/template
+++ b/srcpkgs/ffmpegthumbnailer/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbnailer'
 pkgname=ffmpegthumbnailer
 version=2.2.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libpng-devel libjpeg-turbo-devel ffmpeg-devel"
@@ -9,8 +9,8 @@ depends="ffmpeg"
 short_desc="Lightweight video thumbnailer"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
-homepage="https://github.com/dirkvdb/${pkgname}"
-distfiles="${homepage}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
+homepage="https://github.com/dirkvdb"
+distfiles="${homepage}/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
 checksum=1cb24059c38223f657b300c84dd80491b7040d4b69471c4fea69be862bc99b5b
 
 post_install() {

From af77253149fa8d7064f5aa3412a678194ef13115 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 029/113] ffmpegthumbs: revbump for ffmpeg6

---
 srcpkgs/ffmpegthumbs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ffmpegthumbs/template b/srcpkgs/ffmpegthumbs/template
index 5f0b9414dadaf..11b88193528f4 100644
--- a/srcpkgs/ffmpegthumbs/template
+++ b/srcpkgs/ffmpegthumbs/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbs'
 pkgname=ffmpegthumbs
 version=22.12.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules kcoreaddons kconfig-devel
  pkg-config qt5-host-tools qt5-qmake gettext"

From ac7220f04685e4b0098a72202ecc770530512d8f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 030/113] ffms2: revbump for ffmpeg6

---
 srcpkgs/ffms2/patches/ffmpeg5.patch | 424 ++++++++++++++++++++++++++++
 srcpkgs/ffms2/template              |   2 +-
 2 files changed, 425 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ffms2/patches/ffmpeg5.patch

diff --git a/srcpkgs/ffms2/patches/ffmpeg5.patch b/srcpkgs/ffms2/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..1479fabcafcb4
--- /dev/null
+++ b/srcpkgs/ffms2/patches/ffmpeg5.patch
@@ -0,0 +1,424 @@
+From 45673149e9a2f5586855ad472e3059084eaa36b1 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:41:21 +0100
+Subject: [PATCH] Use auto for AVCodec
+
+The geniuses over at FFmpeg decided to constify this API, so old
+versions of the library will return AVCodec *, while new versions
+of the libary will return const AVCodec *, which, in C++, are not
+OK to convert between.
+
+Rather than use some macro hell in ffmscompat.h, we can work around
+this by using auto.
+
+Gross.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 2 +-
+ src/core/indexing.cpp    | 6 +++---
+ src/core/videosource.cpp | 2 +-
+ 3 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index e4ce97c..ac09666 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -469,7 +469,7 @@ void FFMS_AudioSource::OpenFile() {
+ 
+     LAVFOpenFile(SourceFile.c_str(), FormatContext, TrackNumber);
+ 
+-    AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
++    auto *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
+     if (Codec == nullptr)
+         throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+             "Audio codec not found");
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index e547c5a..59fb4e8 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -384,7 +384,7 @@ FFMS_TrackType FFMS_Indexer::GetTrackType(int Track) {
+ }
+ 
+ const char *FFMS_Indexer::GetTrackCodec(int Track) {
+-    AVCodec *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
++    auto *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
+     return codec ? codec->name : nullptr;
+ }
+ 
+@@ -402,7 +402,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             UseDTS);
+ 
+         if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            AVCodec *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (!VideoCodec) {
+                 FormatContext->streams[i]->discard = AVDISCARD_ALL;
+                 IndexMask.erase(i);
+@@ -433,7 +433,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 IndexMask.insert(i);
+             }
+         } else if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+-            AVCodec *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (AudioCodec == nullptr)
+                 throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_UNSUPPORTED,
+                     "Audio codec not found");
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index b889970..8956c22 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -171,7 +171,7 @@ FFMS_VideoSource::FFMS_VideoSource(const char *SourceFile, FFMS_Index &Index, in
+ 
+         LAVFOpenFile(SourceFile, FormatContext, VideoTrack);
+ 
+-        AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
++        auto *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
+         if (Codec == nullptr)
+             throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+                 "Video codec not found");
+-- 
+2.40.0
+
+From 96cbf38ea9381829a1314f432a2c60495dcefaad Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:12:41 +0100
+Subject: [PATCH] all: Update AVPacket API usage
+
+AVPackets must all be on the heap now, since it is no longer
+part of the libav* ABI.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 16 ++++++----
+ src/core/indexing.cpp    | 63 ++++++++++++++++++++++------------------
+ src/core/indexing.h      |  4 +--
+ src/core/utils.cpp       |  6 ----
+ src/core/utils.h         |  1 -
+ src/core/videosource.cpp | 30 ++++++++++---------
+ 6 files changed, 64 insertions(+), 56 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index 37cf9ae..e4ce97c 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -285,10 +285,15 @@ FFMS_AudioSource::AudioBlock *FFMS_AudioSource::CacheBlock(CacheIterator &pos) {
+ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     CurrentFrame = &Frames[PacketNumber];
+ 
+-    AVPacket Packet;
+-    if (!ReadPacket(&Packet))
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++    if (!ReadPacket(Packet)) {
++        av_packet_free(&Packet);
+         throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_UNKNOWN,
+             "ReadPacket unexpectedly failed to read a packet");
++    }
+ 
+     // ReadPacket may have changed the packet number
+     CurrentFrame = &Frames[PacketNumber];
+@@ -297,8 +302,9 @@ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     int NumberOfSamples = 0;
+     AudioBlock *CachedBlock = nullptr;
+     
+-    int Ret = avcodec_send_packet(CodecContext, &Packet);
+-    av_packet_unref(&Packet);
++    int Ret = avcodec_send_packet(CodecContext, Packet);
++    av_packet_unref(Packet);
++    av_packet_free(&Packet);
+ 
+     av_frame_unref(DecodeFrame);
+     Ret = avcodec_receive_frame(CodecContext, DecodeFrame);
+@@ -513,8 +519,6 @@ void FFMS_AudioSource::Seek() {
+ }
+ 
+ bool FFMS_AudioSource::ReadPacket(AVPacket *Packet) {
+-    InitNullPacket(*Packet);
+-
+     while (av_read_frame(FormatContext, Packet) >= 0) {
+         if (Packet->stream_index == TrackNumber) {
+             // Required because not all audio packets, especially in ogg, have a pts. Use the previous valid packet's pts instead.
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index 23fb95b..e547c5a 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -320,7 +320,7 @@ void FFMS_Indexer::CheckAudioProperties(int Track, AVCodecContext *Context) {
+     }
+ }
+ 
+-void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict,
++void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict,
+                                     int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct) {
+     if (VideoContext.Parser) {
+         uint8_t *OB;
+@@ -330,8 +330,8 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+         av_parser_parse2(VideoContext.Parser,
+             VideoContext.CodecContext,
+             &OB, &OBSize,
+-            pkt.data, pkt.size,
+-            pkt.pts, pkt.dts, pkt.pos);
++            pkt->data, pkt->size,
++            pkt->pts, pkt->dts, pkt->pos);
+ 
+         // H.264 (PAFF) and HEVC may have one field per packet, so we need to track
+         // when we have a full or half frame available, and mark one of them as
+@@ -351,15 +351,15 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+ 
+         *RepeatPict = VideoContext.Parser->repeat_pict;
+         *FrameType = VideoContext.Parser->pict_type;
+-        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt.flags & AV_PKT_FLAG_DISCARD));
++        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt->flags & AV_PKT_FLAG_DISCARD));
+     } else {
+-        *Invisible = !!(pkt.flags & AV_PKT_FLAG_DISCARD);
++        *Invisible = !!(pkt->flags & AV_PKT_FLAG_DISCARD);
+     }
+ 
+     if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP8)
+-        ParseVP8(pkt.data[0], Invisible, FrameType);
++        ParseVP8(pkt->data[0], Invisible, FrameType);
+     else if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP9)
+-        ParseVP9(pkt.data[0], Invisible, FrameType);
++        ParseVP9(pkt->data[0], Invisible, FrameType);
+ }
+ 
+ void FFMS_Indexer::Free() {
+@@ -458,32 +458,36 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+         }
+     }
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
+     std::vector<int64_t> LastValidTS(FormatContext->nb_streams, AV_NOPTS_VALUE);
+ 
+     int64_t filesize = avio_size(FormatContext->pb);
+     enum AVPictureStructure LastPicStruct = AV_PICTURE_STRUCTURE_UNKNOWN;
+-    while (av_read_frame(FormatContext, &Packet) >= 0) {
++    while (av_read_frame(FormatContext, Packet) >= 0) {
+         // Update progress
+         // FormatContext->pb can apparently be NULL when opening images.
+         if (IC && FormatContext->pb) {
+-            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate))
++            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate)) {
++                av_packet_free(&Packet);
+                 throw FFMS_Exception(FFMS_ERROR_CANCELLED, FFMS_ERROR_USER,
+                     "Cancelled by user");
++            }
+         }
+-        if (!IndexMask.count(Packet.stream_index)) {
+-            av_packet_unref(&Packet);
++        if (!IndexMask.count(Packet->stream_index)) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+-        int Track = Packet.stream_index;
++        int Track = Packet->stream_index;
+         FFMS_Track &TrackInfo = (*TrackIndices)[Track];
+-        bool KeyFrame = !!(Packet.flags & AV_PKT_FLAG_KEY);
++        bool KeyFrame = !!(Packet->flags & AV_PKT_FLAG_KEY);
+         ReadTS(Packet, LastValidTS[Track], (*TrackIndices)[Track].UseDTS);
+ 
+         if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            int64_t PTS = TrackInfo.UseDTS ? Packet.dts : Packet.pts;
++            int64_t PTS = TrackInfo.UseDTS ? Packet->dts : Packet->pts;
+             if (PTS == AV_NOPTS_VALUE) {
+                 // VPx alt-refs are output as packets which lack timestmps or durations, since
+                 // they are invisible. Currently, the timestamp mangling code in libavformat
+@@ -495,9 +499,11 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 // FFMS2 currently sorts packets by PTS, which will break decoding, otherwise.
+                 bool HasAltRefs = (FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP8 ||
+                                    FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP9);
+-                if (Packet.duration == 0 && !HasAltRefs)
++                if (Packet->duration == 0 && !HasAltRefs) {
++                    av_packet_free(&Packet);
+                     throw FFMS_Exception(FFMS_ERROR_INDEXING, FFMS_ERROR_PARSER,
+                         "Invalid packet pts, dts, and duration");
++                }
+ 
+                 if (TrackInfo.empty())
+                     PTS = 0;
+@@ -513,7 +519,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             ParseVideoPacket(AVContexts[Track], Packet, &RepeatPict, &FrameType, &Invisible, &LastPicStruct);
+ 
+             TrackInfo.AddVideoFrame(PTS, RepeatPict, KeyFrame,
+-                FrameType, Packet.pos, Invisible);
++                FrameType, Packet->pos, Invisible);
+         } else if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+             // For video seeking timestamps are used only if all packets have
+             // timestamps, while for audio they're used if any have timestamps,
+@@ -522,28 +528,29 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 TrackInfo.HasTS = true;
+ 
+             int64_t StartSample = AVContexts[Track].CurrentSample;
+-            uint32_t SampleCount = IndexAudioPacket(Track, &Packet, AVContexts[Track], *TrackIndices);
++            uint32_t SampleCount = IndexAudioPacket(Track, Packet, AVContexts[Track], *TrackIndices);
+             TrackInfo.SampleRate = AVContexts[Track].CodecContext->sample_rate;
+ 
+             TrackInfo.AddAudioFrame(LastValidTS[Track],
+-                StartSample, SampleCount, KeyFrame, Packet.pos, Packet.flags & AV_PKT_FLAG_DISCARD);
++                StartSample, SampleCount, KeyFrame, Packet->pos, Packet->flags & AV_PKT_FLAG_DISCARD);
+         }
+ 
+-        if (!(Packet.flags & AV_PKT_FLAG_DISCARD))
+-            TrackInfo.LastDuration = Packet.duration;
++        if (!(Packet->flags & AV_PKT_FLAG_DISCARD))
++            TrackInfo.LastDuration = Packet->duration;
+ 
+-        av_packet_unref(&Packet);
++        av_packet_unref(Packet);
+     }
++    av_packet_free(&Packet);
+ 
+     TrackIndices->Finalize(AVContexts, FormatContext->iformat->name);
+     return TrackIndices.release();
+ }
+ 
+-void FFMS_Indexer::ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS) {
+-    if (!UseDTS && Packet.pts != AV_NOPTS_VALUE)
+-        TS = Packet.pts;
++void FFMS_Indexer::ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS) {
++    if (!UseDTS && Packet->pts != AV_NOPTS_VALUE)
++        TS = Packet->pts;
+     if (TS == AV_NOPTS_VALUE)
+         UseDTS = true;
+-    if (UseDTS && Packet.dts != AV_NOPTS_VALUE)
+-        TS = Packet.dts;
++    if (UseDTS && Packet->dts != AV_NOPTS_VALUE)
++        TS = Packet->dts;
+ }
+diff --git a/src/core/indexing.h b/src/core/indexing.h
+index 3cfc3c3..5c06868 100644
+--- a/src/core/indexing.h
++++ b/src/core/indexing.h
+@@ -80,10 +80,10 @@ private:
+     int64_t Filesize;
+     uint8_t Digest[20];
+ 
+-    void ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS);
++    void ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS);
+     void CheckAudioProperties(int Track, AVCodecContext *Context);
+     uint32_t IndexAudioPacket(int Track, AVPacket *Packet, SharedAVContext &Context, FFMS_Index &TrackIndices);
+-    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
++    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
+     void Free();
+ public:
+     FFMS_Indexer(const char *Filename);
+diff --git a/src/core/utils.cpp b/src/core/utils.cpp
+index ce67533..8a2e997 100644
+--- a/src/core/utils.cpp
++++ b/src/core/utils.cpp
+@@ -62,12 +62,6 @@ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo) {
+     }
+ }
+ 
+-void InitNullPacket(AVPacket &pkt) {
+-    av_init_packet(&pkt);
+-    pkt.data = nullptr;
+-    pkt.size = 0;
+-}
+-
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames) {
+     AP.SampleFormat = static_cast<FFMS_SampleFormat>(av_get_packed_sample_fmt(CTX->sample_fmt));
+     AP.BitsPerSample = av_get_bytes_per_sample(CTX->sample_fmt) * 8;
+diff --git a/src/core/utils.h b/src/core/utils.h
+index 9819dc7..003ab79 100644
+--- a/src/core/utils.h
++++ b/src/core/utils.h
+@@ -58,7 +58,6 @@ std::unique_ptr<T> make_unique(Args&&... args) {
+ }
+ 
+ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo);
+-void InitNullPacket(AVPacket &pkt);
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames);
+ 
+ void LAVFOpenFile(const char *SourceFile, AVFormatContext *&FormatContext, int Track);
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index 06bd161..b889970 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -673,30 +673,34 @@ void FFMS_VideoSource::DecodeNextFrame(int64_t &AStartTime, int64_t &Pos) {
+     if (HasPendingDelayedFrames())
+         return;
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
+-
+-    while (ReadFrame(&Packet) >= 0) {
+-        if (Packet.stream_index != VideoTrack) {
+-            av_packet_unref(&Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++
++    while (ReadFrame(Packet) >= 0) {
++        if (Packet->stream_index != VideoTrack) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+         if (AStartTime < 0)
+-            AStartTime = Frames.UseDTS ? Packet.dts : Packet.pts;
++            AStartTime = Frames.UseDTS ? Packet->dts : Packet->pts;
+ 
+         if (Pos < 0)
+-            Pos = Packet.pos;
++            Pos = Packet->pos;
+ 
+-        bool FrameFinished = DecodePacket(&Packet);
+-        av_packet_unref(&Packet);
+-        if (FrameFinished)
++        bool FrameFinished = DecodePacket(Packet);
++        av_packet_unref(Packet);
++        if (FrameFinished) {
++            av_packet_free(&Packet);
+             return;
++        }
+     }
+ 
+     // Flush final frames
+-    InitNullPacket(Packet);
+-    DecodePacket(&Packet);
++    DecodePacket(Packet);
++    av_packet_free(&Packet);
+ }
+ 
+ bool FFMS_VideoSource::SeekTo(int n, int SeekOffset) {
+-- 
+2.40.0
+
+From bf9e03e9e08534c024e5a744a6437c4aac160201 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:20:47 +0100
+Subject: [PATCH 2/3] configure: Remove deprecated API use
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ configure.ac | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index b35ef80bc..d19714d0f 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -102,10 +102,10 @@ CFLAGS="$_CFLAGS $FFMPEG_CFLAGS"
+
+ AC_DEFUN([TEST_FFMPEG],
+          [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+-            #include <libavcodec/avcodec.h>
++            #include <libavformat/avformat.h>
+             #include <libswscale/swscale.h>
+             ]],[[
+-                avcodec_register_all();
++                avformat_network_init();
+                 swscale_version();
+             ]])], [eval $1=yes], [eval $1=no])
+         ])
+
diff --git a/srcpkgs/ffms2/template b/srcpkgs/ffms2/template
index 365f64d10cbab..1641ecf43be5b 100644
--- a/srcpkgs/ffms2/template
+++ b/srcpkgs/ffms2/template
@@ -1,7 +1,7 @@
 # Template file for 'ffms2'
 pkgname=ffms2
 version=2.40
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-shared --disable-static"
 hostmakedepends="pkg-config autoconf automake libtool"

From ec54449dae833d30fa8c6309a1c12fcc53b062d4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 031/113] freerdp: revbump for ffmpeg6

---
 .../freerdp/patches/ffmpeg6_aa2cb9aa.patch    | 42 +++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100644 srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch

diff --git a/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
new file mode 100644
index 0000000000000..a4324da3a8822
--- /dev/null
+++ b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
@@ -0,0 +1,42 @@
+From aa2cb9aa5ff5562433598ba168a466e0752bca0e Mon Sep 17 00:00:00 2001
+From: akallabeth <akallabeth@posteo.net>
+Date: Tue, 14 Feb 2023 07:48:54 +0100
+Subject: [PATCH] Fixed #8686: Update h264 to use new FFMPEG API
+
+---
+ channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c | 2 ++
+ libfreerdp/codec/h264_ffmpeg.c            | 2 ++
+ 2 files changed, 4 insertions(+)
+
+diff --git a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+index 339462d865f..beea80b7a1e 100644
+--- a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
++++ b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+@@ -239,8 +239,10 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYP
+ 		}
+ 	}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 	if (mdecoder->codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		mdecoder->codec_context->flags |= AV_CODEC_FLAG_TRUNCATED;
++#endif
+ 
+ 	return TRUE;
+ }
+diff --git a/libfreerdp/codec/h264_ffmpeg.c b/libfreerdp/codec/h264_ffmpeg.c
+index 8a23db2473c..896a333019b 100644
+--- a/libfreerdp/codec/h264_ffmpeg.c
++++ b/libfreerdp/codec/h264_ffmpeg.c
+@@ -615,10 +615,12 @@ static BOOL libavcodec_init(H264_CONTEXT* h264)
+ 			goto EXCEPTION;
+ 		}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 		if (sys->codecDecoder->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		{
+ 			sys->codecDecoderContext->flags |= AV_CODEC_FLAG_TRUNCATED;
+ 		}
++#endif
+ 
+ #ifdef WITH_VAAPI
+ 

From 11816aa8764d7c3327d561ff8b732fd10ebccc77 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 032/113] gerbera: revbump for ffmpeg6

---
 srcpkgs/gerbera/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gerbera/template b/srcpkgs/gerbera/template
index ae14f35c767c0..2dc0ac0ce03b5 100644
--- a/srcpkgs/gerbera/template
+++ b/srcpkgs/gerbera/template
@@ -1,7 +1,7 @@
 # Template file for 'gerbera'
 pkgname=gerbera
 version=1.12.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_SYSTEMD=0 -DWITH_AVCODEC=1"
 hostmakedepends="pkg-config"

From f73a965642169df471132aaffe8e62b479e96354 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 033/113] goldendict: revbump for ffmpeg6

---
 srcpkgs/goldendict/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/goldendict/template b/srcpkgs/goldendict/template
index f4a05759f693d..97f44347b03a6 100644
--- a/srcpkgs/goldendict/template
+++ b/srcpkgs/goldendict/template
@@ -1,7 +1,7 @@
 # Template file for 'goldendict'
 pkgname=goldendict
 version=1.5.0
-revision=1
+revision=2
 build_style=qmake
 configure_args="CONFIG+=zim_support goldendict.pro"
 hostmakedepends="qt5-qmake pkg-config qt5-host-tools"
@@ -10,7 +10,7 @@ makedepends="tiff-devel qt5-devel libvorbis-devel zlib-devel
  qt5-webkit-devel lzo-devel bzip2-devel libao-devel qt5-svg-devel
  libeb-devel qt5-x11extras-devel ffmpeg-devel liblzma-devel
  qt5-multimedia-devel"
-short_desc="A feature-rich dictionary lookup program"
+short_desc="Feature-rich dictionary lookup program"
 maintainer="John <me@johnnynator.dev>"
 license="GPL-3.0-or-later"
 homepage="http://goldendict.org/"

From 4491e6b0fa36619065765746d04f0144442c22fb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 034/113] gst-libav: revbump for ffmpeg6

---
 srcpkgs/gst-libav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index 78afeee4aefb2..f892eb2063564 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.22.7
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"

From 62755af2d1761b0035ad034a1b049233c2a9d635 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 035/113] gst-rtsp-server: revbump for ffmpeg6

---
 srcpkgs/gst-rtsp-server/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index 2c280c84f1514..83a2949fd9482 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
 version=1.22.7
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="glib-devel gst-plugins-bad1-devel gobject-introspection

From 34da79c9a560021cd1f239773b5f103132d9d535 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 036/113] guvcview: update to 2.0.8.

---
 srcpkgs/guvcview/patches/fix-include.patch | 10 ++++++++++
 srcpkgs/guvcview/template                  |  7 +++----
 2 files changed, 13 insertions(+), 4 deletions(-)
 create mode 100644 srcpkgs/guvcview/patches/fix-include.patch

diff --git a/srcpkgs/guvcview/patches/fix-include.patch b/srcpkgs/guvcview/patches/fix-include.patch
new file mode 100644
index 0000000000000..503c2af3b78c1
--- /dev/null
+++ b/srcpkgs/guvcview/patches/fix-include.patch
@@ -0,0 +1,10 @@
+--- a/guvcview/guvcview.c
++++ b/guvcview/guvcview.c
+@@ -28,6 +28,7 @@
+ #include <sys/stat.h>
+ #include <sys/resource.h>
+ #include <errno.h>
++#include <locale.h>
+ 
+ #include "gview.h"
+ #include "gviewv4l2core.h"
diff --git a/srcpkgs/guvcview/template b/srcpkgs/guvcview/template
index d42fd38fa4ad1..86a7fd619612c 100644
--- a/srcpkgs/guvcview/template
+++ b/srcpkgs/guvcview/template
@@ -1,8 +1,7 @@
 # Template file for 'guvcview'
 pkgname=guvcview
-version=2.0.7
-revision=2
-create_wrksrc=yes
+version=2.0.8
+revision=1
 build_style=gnu-configure
 configure_args="--disable-static --disable-debian-menu"
 hostmakedepends="pkg-config intltool autoconf automake libtool glib-devel"
@@ -14,7 +13,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="http://guvcview.sourceforge.net/"
 distfiles="${SOURCEFORGE_SITE}/${pkgname}/${pkgname}-src-${version}.tar.bz2"
-checksum=f47d51fbd06e44eeaa1a82f4a153c927527c90d94514197a70b2956028cc8ad4
+checksum=a21f4e448286666cf27bafef5290cc953a0a1796b752e5bbe521266dc1230c81
 
 post_patch() {
 	sed '31a#include <locale.h>' -i  guvcview/guvcview.c

From 781409613fc93828856645008ce62e7d026f242e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 037/113] handbrake: update to 1.6.1

---
 .../patches/fix-missing-x265-link-flag.patch    | 11 ++++++-----
 .../handbrake/patches/libhb-vpl-include.patch   | 15 +++++++++++++++
 srcpkgs/handbrake/template                      | 17 ++++++++++-------
 3 files changed, 31 insertions(+), 12 deletions(-)
 create mode 100644 srcpkgs/handbrake/patches/libhb-vpl-include.patch

diff --git a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
index 26db03867a0c8..d6bb2eda627a3 100644
--- a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
+++ b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
@@ -1,14 +1,15 @@
 --- a/gtk/configure.ac
 +++ b/gtk/configure.ac
 @@ -203,7 +203,7 @@
- 
+
  AM_CONDITIONAL([MINGW], [test "x$mingw_flag" = "xyes"])
- 
--HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg"
-+HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -ldl"
+
+-HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc"
++HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc -ldl"
  HB_CPPFLAGS="$HB_CPPFLAGS $HBINC"
- 
+
  PKG_CHECK_MODULES([x264], [x264], sys_x264=yes, sys_x264=no)
+
 --- a/test/module.defs
 +++ b/test/module.defs
 @@ -69,6 +69,9 @@
diff --git a/srcpkgs/handbrake/patches/libhb-vpl-include.patch b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
new file mode 100644
index 0000000000000..298f9f4ab28f2
--- /dev/null
+++ b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
@@ -0,0 +1,15 @@
+--- a/libhb/module.defs	2023-01-22 11:36:49.000000000 -0500
++++ b/libhb/module.defs	2023-04-03 22:37:52.395467010 -0400
+@@ -46,11 +46,7 @@
+ LIBHB.GCC.I += $(LIBHB.build/) $(CONTRIB.build/)include
+ 
+ ifeq (1,$(FEATURE.qsv))
+-    ifeq ($(HOST.system),freebsd))
+-        LIBHB.GCC.I += $(LOCALBASE)/include/vpl
+-    else
+-        LIBHB.GCC.I += $(CONTRIB.build/)include/vpl
+-    endif
++    LIBHB.GCC.I += /usr/include/vpl
+ endif
+ 
+ ifneq (,$(filter $(HOST.system),freebsd netbsd openbsd))
diff --git a/srcpkgs/handbrake/template b/srcpkgs/handbrake/template
index ca5e4571e49c3..c32cb1bfa31f4 100644
--- a/srcpkgs/handbrake/template
+++ b/srcpkgs/handbrake/template
@@ -1,10 +1,10 @@
 # Template file for 'handbrake'
 pkgname=handbrake
-version=1.5.1
+version=1.6.1
 revision=1
 build_style=gnu-configure
 configure_args="--force --disable-gtk-update-checks --disable-df-fetch --harden
- $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc)"
+ $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc) $(vopt_enable qsv)"
 make_build_args="-C ${XBPS_TRIPLET}"
 make_install_args="-C ${XBPS_TRIPLET}"
 hostmakedepends="automake cmake gettext-devel glib-devel intltool libtool m4 meson nasm pkg-config python3"
@@ -12,8 +12,11 @@ makedepends="bzip2-devel ffmpeg-devel gst-plugins-base1-devel gtk+3-devel
  jansson-devel lame-devel libass-devel libbluray-devel libdav1d-devel
  libdvdnav-devel libdvdread-devel libgudev-devel libnuma-devel
  libsamplerate-devel libtheora-devel libvorbis-devel libvpx-devel libxml2-devel
- opus-devel speex-devel x264-devel x265-devel zimg-devel
+ opus-devel speex-devel x264-devel x265-devel zimg-devel libsvt-av1-devel
  $(vopt_if fdk_aac fdk-aac-devel)
+ $(vopt_if qsv libva-devel)
+ $(vopt_if qsv libdrm-devel)
+ $(vopt_if qsv onevpl-devel)
  $(vopt_if nvenc nv-codec-headers)"
 depends="desktop-file-utils gst-plugins-good1 hicolor-icon-theme"
 short_desc="Multithreaded video transcoder"
@@ -21,15 +24,15 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-2.0-only"
 homepage="https://handbrake.fr/"
 distfiles="https://github.com/HandBrake/HandBrake/releases/download/${version}/HandBrake-${version}-source.tar.bz2"
-checksum=3999fe06d5309c819799a73a968a8ec3840e7840c2b64af8f5cdb7fd8c9430f0
+checksum=94ccfe03db917a91650000c510f7fd53f844da19f19ad4b4be1b8f6bc31a8d4c
 nocross=yes
 
-build_options="fdk_aac nvenc"
+build_options="fdk_aac nvenc qsv"
 
 case "$XBPS_TARGET_MACHINE" in
 	x86_64*|i686*)
 		CFLAGS="-msse"
-		build_options_default="nvenc"
+		build_options_default="nvenc qsv"
 		;;
 esac
 
@@ -37,7 +40,7 @@ pre_configure() {
 	# use system libraries, don't download them
 	rm -rf contrib/
 	for module in fdk-aac ffmpeg libbluray libdav1d libdvdnav libdvdread nvenc \
-		x265 zimg; do
+		x265 zimg svt-av1 libvpl; do
 	    vsed -i "/MODULES += contrib\/${module}/d" make/include/main.defs
 	done
 }

From 8b20e1c71dad4317996cb51f1a66018de73c44b6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 038/113] hedgewars: revbump for ffmpeg4

---
 srcpkgs/hedgewars/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/hedgewars/template b/srcpkgs/hedgewars/template
index 94b6db673b0c3..402ccfaaecbc2 100644
--- a/srcpkgs/hedgewars/template
+++ b/srcpkgs/hedgewars/template
@@ -1,13 +1,13 @@
 # Template file for 'hedgewars'
 pkgname=hedgewars
 version=1.0.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DNOSERVER=1 -DDATA_INSTALL_DIR=/usr/share/${pkgname}
  -DPHYSFS_SYSTEM=1 -DMINIMAL_FLAGS=1"
 make_cmd=make
 hostmakedepends="lua51 pkg-config qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
+makedepends="ffmpeg4-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
  SDL2_mixer-devel SDL2_net-devel SDL2_ttf-devel"
 depends="libfreeglut"
 short_desc="Funny turn-based artillery game, featuring fighting Hedgehogs!"

From 35ff28c65c9a7ea7e90c82572df6f8e81fa1ec2a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 039/113] idjc: revbump for ffmpeg4

---
 srcpkgs/idjc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/idjc/template b/srcpkgs/idjc/template
index a9cde0665d55b..6f1d21c5781fd 100644
--- a/srcpkgs/idjc/template
+++ b/srcpkgs/idjc/template
@@ -5,7 +5,7 @@ revision=5
 build_style=gnu-configure
 hostmakedepends="pkg-config git python3 automake gettext-devel libtool"
 makedepends="libvorbis-devel libogg-devel jack-devel libsamplerate-devel
- libflac-devel libsndfile-devel mpg123-devel ffmpeg-devel speex-devel
+ libflac-devel libsndfile-devel mpg123-devel ffmpeg4-devel speex-devel
  glib-devel pixman-devel lame-devel python3-gobject-devel libshout-idjc-devel
  opus-devel twolame-devel python3-mutagen python3-devel"
 depends="python3-gobject python3-mutagen desktop-file-utils shared-mime-info python3-dbus jack"

From 62c2a2b29aaa6e74afbe0b33e1e6c3bb6efcdc43 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 040/113] kid3: revbump for ffmpeg6

---
 srcpkgs/kid3/patches/ffmpeg5.patch | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 srcpkgs/kid3/patches/ffmpeg5.patch

diff --git a/srcpkgs/kid3/patches/ffmpeg5.patch b/srcpkgs/kid3/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..135fc50e07c9b
--- /dev/null
+++ b/srcpkgs/kid3/patches/ffmpeg5.patch
@@ -0,0 +1,17 @@
+# https://aur.archlinux.org/cgit/aur.git/diff/ffmpeg5.patch?h=kid3-cli&id=12410a74906612e7efc0ec8fbce739b4a0fef7e7
+diff --git a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+index e156d424..e12b9abd 100644
+--- a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
++++ b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+@@ -232,7 +232,11 @@ private:
+   friend class Format;
+   friend class Converter;
+   AVCodecContext* m_ptr;
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 0, 0)
+   AVCodec* m_impl;
++#else
++  const AVCodec* m_impl;
++#endif
+   AVFrame* m_frame;
+   bool m_opened;
+ };

From 013f537b918b428dc67bc77a36718a60d82372e0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 041/113] kodi: revbump for ffmpeg4

---
 srcpkgs/kodi/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kodi/template b/srcpkgs/kodi/template
index aa59324258a0d..6cf64dfb27294 100644
--- a/srcpkgs/kodi/template
+++ b/srcpkgs/kodi/template
@@ -54,7 +54,7 @@ makedepends="
  libmad-devel fontconfig-devel libXinerama-devel libsamplerate-devel libmms-devel
  enca-devel boost-devel libcurl-devel libva-devel libvdpau-devel libass-devel
  libbluetooth-devel yajl-devel libplist-devel librtmp-devel tinyxml-devel
- taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg-devel
+ taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg4-devel
  giflib-devel libxslt-devel gnutls-devel libssh-devel libmicrohttpd-devel
  libcec-devel dcadec-devel flatbuffers-devel fmt-devel lcms2-devel
  libfstrcmp-devel rapidjson libcdio-paranoia spdlog libwaylandpp-devel

From b6a5f5d27696a4f3970c5b157b3548b9dad8c642 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 042/113] kpipewire: revbump for ffmpeg6

---
 srcpkgs/kpipewire/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kpipewire/template b/srcpkgs/kpipewire/template
index 6214a4451336e..3555348659dde 100644
--- a/srcpkgs/kpipewire/template
+++ b/srcpkgs/kpipewire/template
@@ -1,7 +1,7 @@
 # Template file for 'kpipewire'
 pkgname=kpipewire
 version=5.27.10
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules plasma-wayland-protocols gettext
  qt5-qmake qt5-host-tools pkg-config wayland-devel kcoreaddons

From bb6a1ea3a27655e9f48587bbe3316e8dfd8e1e91 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 043/113] libextractor: revbump for ffmpeg4

---
 srcpkgs/libextractor/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libextractor/template b/srcpkgs/libextractor/template
index 044c663a3a0b9..ace88ae128da5 100644
--- a/srcpkgs/libextractor/template
+++ b/srcpkgs/libextractor/template
@@ -7,7 +7,7 @@ configure_args="--disable-static"
 hostmakedepends="pkg-config"
 makedepends="zlib-devel bzip2-devel exiv2-devel tiff-devel libpng-devel
  libjpeg-turbo-devel libvorbis-devel libflac-devel giflib-devel libmpeg2-devel
- ffmpeg-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
+ ffmpeg4-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
 short_desc="Library used to extract meta data from files"
 maintainer="Martin Riese <grauehaare@gmx.de>"
 license="GPL-3.0-or-later"

From 36ebef47d2df1acda1518c196a5dc86b86abdd08 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 044/113] libopenal: revbump for ffmpeg6

---
 srcpkgs/libopenal/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenal/template b/srcpkgs/libopenal/template
index 88d0f11307d81..8308fca0393e3 100644
--- a/srcpkgs/libopenal/template
+++ b/srcpkgs/libopenal/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenal'
 pkgname=libopenal
 version=1.23.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DALSOFT_EXAMPLES=OFF"
 hostmakedepends="pkg-config"

From 14260b2377f43b49b4c4a64c1a344f6cf70b35b1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 045/113] loudgain: revbump for ffmpeg6

---
 srcpkgs/loudgain/patches/ffmpeg5.patch | 11 +++++++++++
 srcpkgs/loudgain/template              |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/loudgain/patches/ffmpeg5.patch

diff --git a/srcpkgs/loudgain/patches/ffmpeg5.patch b/srcpkgs/loudgain/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..16d4510ee98fa
--- /dev/null
+++ b/srcpkgs/loudgain/patches/ffmpeg5.patch
@@ -0,0 +1,11 @@
+--- a/src/scan.c	2019-09-06 11:31:19.000000000 -0400
++++ b/src/scan.c	2023-03-23 11:15:40.867968521 -0400
+@@ -69,8 +69,6 @@
+ 	 * It is now useless
+ 	 * https://github.com/FFmpeg/FFmpeg/blob/70d25268c21cbee5f08304da95be1f647c630c15/doc/APIchanges#L86
+ 	 */
+-  if (avformat_version() < AV_VERSION_INT(58,9,100))
+-    av_register_all();
+ 
+ 	av_log_set_callback(scan_av_log);
+ 
diff --git a/srcpkgs/loudgain/template b/srcpkgs/loudgain/template
index da4f2d56e94c3..4d6bf29efb4fd 100644
--- a/srcpkgs/loudgain/template
+++ b/srcpkgs/loudgain/template
@@ -1,7 +1,7 @@
 # Template file for 'loudgain'
 pkgname=loudgain
 version=0.6.8
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libebur128-devel taglib-devel ffmpeg-devel"

From 42db05c099d812f43e7cabb8a99c4054a2fa3234 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 046/113] mediastreamer: revbump for ffmpeg4

---
 srcpkgs/mediastreamer/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mediastreamer/template b/srcpkgs/mediastreamer/template
index 0fcffa7653d18..92ada88743a9b 100644
--- a/srcpkgs/mediastreamer/template
+++ b/srcpkgs/mediastreamer/template
@@ -5,7 +5,7 @@ revision=2
 build_style=cmake
 configure_args="-DENABLE_STRICT=0 -DENABLE_UNIT_TESTS=0"
 hostmakedepends="python3"
-makedepends="bzrtp-devel ffmpeg-devel glew-devel libXv-devel libsrtp-devel
+makedepends="bzrtp-devel ffmpeg4-devel glew-devel libXv-devel libsrtp-devel
  libupnp-devel libvpx-devel mbedtls-devel opus-devel ortp-devel pulseaudio-devel
  libtheora-devel speex-devel v4l-utils-devel bcg729-devel bcmatroska2-devel libgsm-devel
  zxing-cpp-devel"

From e997d8721a0d6ff3479357efada53ff4172d587f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 047/113] mgba: revbump for ffmpeg6

---
 srcpkgs/mgba/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mgba/template b/srcpkgs/mgba/template
index 5513e3fd16f3f..f5c87a4893002 100644
--- a/srcpkgs/mgba/template
+++ b/srcpkgs/mgba/template
@@ -1,7 +1,7 @@
 # Template file for 'mgba'
 pkgname=mgba
 version=0.10.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake desktop-file-utils"
 makedepends="SDL2-devel ffmpeg-devel libedit-devel libepoxy-devel libmagick-devel

From e9d6a0e613f3ad666a17eedc2371de674ecc8863 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 048/113] mlt: revbump for ffmpeg4

---
 srcpkgs/mlt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mlt/template b/srcpkgs/mlt/template
index 73e3915aaab9a..ec5054be3b75e 100644
--- a/srcpkgs/mlt/template
+++ b/srcpkgs/mlt/template
@@ -8,7 +8,7 @@ configure_args="--prefix=/usr --libdir=/usr/lib$XBPS_TARGET_WORDSIZE
  --swig-languages=python"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which"
 # XXX: movit vid.stab
-makedepends="alsa-lib-devel ffmpeg-devel gtk+-devel jack-devel ladspa-sdk
+makedepends="alsa-lib-devel ffmpeg4-devel gtk+-devel jack-devel ladspa-sdk
  libexif-devel libsamplerate-devel libxml2-devel sox-devel SDL_image-devel
  fftw-devel frei0r-plugins python3-devel pulseaudio-devel movit-devel
  libvidstab-devel"

From 88d28ee398b2ad3fe38f2eaf85aaba873ffff65c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 049/113] moc: revbump for ffmpeg4

---
 srcpkgs/moc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/moc/template b/srcpkgs/moc/template
index 3a04932c8f1e6..d8de816026b64 100644
--- a/srcpkgs/moc/template
+++ b/srcpkgs/moc/template
@@ -4,7 +4,7 @@ version=2.5.2
 revision=7
 build_style=gnu-configure
 hostmakedepends="pkg-config"
-makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg-devel
+makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg4-devel
  jack-devel alsa-lib-devel libltdl-devel libflac-devel libvorbis-devel
  libmad-devel libmpcdec-devel libmodplug-devel libid3tag-devel faad2-devel
  taglib-devel libsndfile-devel wavpack-devel speex-devel libsamplerate-devel

From 85fcb1c45746a4218dfaf3efa7d5edf0c3f2af5b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 050/113] motion: revbump for ffmpeg6

---
 srcpkgs/motion/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/motion/template b/srcpkgs/motion/template
index 607ebeb3c7b24..bf63a91d9764f 100644
--- a/srcpkgs/motion/template
+++ b/srcpkgs/motion/template
@@ -1,7 +1,7 @@
 # Template file for 'motion'
 pkgname=motion
 version=4.6.0
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake pkg-config gettext-devel tar"
 makedepends="ffmpeg-devel libmicrohttpd-devel v4l-utils-devel gettext-devel"

From 1b47f6d54694861449de6f2c31ae3bceeebb912e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 051/113] notcurses: revbump for ffmpeg6

---
 srcpkgs/notcurses/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/notcurses/template b/srcpkgs/notcurses/template
index 6dd8a091319f7..3110c30c9aff2 100644
--- a/srcpkgs/notcurses/template
+++ b/srcpkgs/notcurses/template
@@ -1,7 +1,7 @@
 # Template file for 'notcurses'
 pkgname=notcurses
 version=3.0.9
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DUSE_STATIC=ON $(vopt_bool man USE_PANDOC)"
 hostmakedepends="pkg-config $(vopt_if man pandoc)"

From 9b789486c11c72394412c65d0200e2ead8ceea2d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 052/113] olive: revbump for ffmpeg4

---
 srcpkgs/olive/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/olive/template b/srcpkgs/olive/template
index 12a46936c9900..5c2917b9c5124 100644
--- a/srcpkgs/olive/template
+++ b/srcpkgs/olive/template
@@ -1,10 +1,10 @@
 # Template file for 'olive'
 pkgname=olive
 version=0.1.2
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools pkg-config"
-makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg-devel frei0r-plugins"
+makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg4-devel frei0r-plugins"
 short_desc="Non-linear video editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"

From 73d785d3e748ddb711d06d9c8fee920c6e5e67a3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 053/113] omxplayer: revbump for ffmpeg4

---
 srcpkgs/omxplayer/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/omxplayer/template b/srcpkgs/omxplayer/template
index 9a66690c83ebb..a21b878878037 100644
--- a/srcpkgs/omxplayer/template
+++ b/srcpkgs/omxplayer/template
@@ -1,7 +1,7 @@
 # Template file for 'omxplayer'
 pkgname=omxplayer
 version=20190102
-revision=2
+revision=3
 short_desc="Commandline OMX player for the Raspberry Pi"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
@@ -15,7 +15,7 @@ checksum=af2d9450f8947842ea8c401fe9f71eec444013ebbdee29f2ac828c9c493c1329
 archs="armv6l* armv7l*"
 build_style=gnu-makefile
 hostmakedepends="ruby-ronn pkg-config"
-makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg-devel dbus-devel"
+makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg4-devel dbus-devel"
 depends="freefont-ttf"
 
 do_build() {

From e1e423895456bf1f4ac52344e3d18633ee5b57cf Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 054/113] opentoonz: revbump for ffmpeg6

---
 srcpkgs/opentoonz/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/opentoonz/template b/srcpkgs/opentoonz/template
index ee9f7603f55fd..3e81834ca0edd 100644
--- a/srcpkgs/opentoonz/template
+++ b/srcpkgs/opentoonz/template
@@ -1,7 +1,7 @@
 # Template file for 'opentoonz'
 pkgname=opentoonz
 version=1.6.0
-revision=2
+revision=3
 build_wrksrc="toonz/sources"
 build_style=cmake
 make_cmd=make

From 8974c727c56d3f23058ca95334a3b91b1b3b4f38 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 055/113] pianobar: revbump for ffmpeg6

---
 srcpkgs/pianobar/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pianobar/template b/srcpkgs/pianobar/template
index e3febb821a451..1e3dc1bf9308e 100644
--- a/srcpkgs/pianobar/template
+++ b/srcpkgs/pianobar/template
@@ -1,7 +1,7 @@
 # Template file for 'pianobar'
 pkgname=pianobar
 version=2022.04.01
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="V=1"
 hostmakedepends="pkg-config"

From c71966907c293662ffb936de7ae4c55210dd2ba4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 056/113] ppsspp: revbump for ffmpeg4

---
 srcpkgs/ppsspp/template | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/ppsspp/template b/srcpkgs/ppsspp/template
index 2c0ded496eb98..1294ef3ae669c 100644
--- a/srcpkgs/ppsspp/template
+++ b/srcpkgs/ppsspp/template
@@ -1,7 +1,7 @@
 # Template file for 'ppsspp'
 pkgname=ppsspp
 version=1.16.6
-revision=1
+revision=2
 _glslang_commit=b34f619e1c85810dcb3c578107d2e48ba4ee2b37
 _SPIRV_Cross_commit=4212eef67ed0ca048cb726a6767185504e7695e5
 _armips_commit=7bd1ec93d4586985ba1ef420b43b5e620f68695e
@@ -15,7 +15,7 @@ configure_args="-DHEADLESS=1 -DUSE_SYSTEM_FFMPEG=1 -DUNITTEST=ON
  -DUSING_QT_UI=$(vopt_if qt ON OFF) -DUSE_SYSTEM_ZSTD=ON
  -DARMIPS_USE_STD_FILESYSTEM=ON"
 hostmakedepends="pkg-config python3 $(vopt_if qt qt5-host-tools)"
-makedepends="zlib-devel glew-devel ffmpeg-devel libzip-devel
+makedepends="zlib-devel glew-devel ffmpeg4-devel libzip-devel
  snappy-devel rapidjson libpng-devel libzstd-devel
  $(vopt_if sdl2 'SDL2_ttf-devel SDL2-devel') $(vopt_if wayland wayland-devel)
  $(vopt_if qt 'qt5-devel qt5-multimedia-devel')"
@@ -72,7 +72,7 @@ post_extract() {
         mv ${wrksrc}/rcheevos-${_rcheevos_commit} ${wrksrc}/ext/rcheevos
 }
 
-post_patch(){
+post_patch() {
 	# disable git versioning
 	vsed -e 's|find_package(Git)|# &|' -i git-version.cmake
 }
@@ -85,7 +85,6 @@ post_configure() {
 }
 
 do_install() {
-	vlicense LICENSE.TXT
 	vinstall icons/icon.svg 644 usr/share/pixmaps ppsspp.svg
 	vinstall Qt/PPSSPP.desktop 644 usr/share/applications
 	vbin build/PPSSPPHeadless ppsspp-headless

From 847f012cb57cb80f3b17deefbf6347e09e74f05c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 057/113] pqiv: revbump for ffmpeg6

---
 srcpkgs/pqiv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pqiv/template b/srcpkgs/pqiv/template
index 542fc27a2d32a..9308d949b6a1c 100644
--- a/srcpkgs/pqiv/template
+++ b/srcpkgs/pqiv/template
@@ -1,7 +1,7 @@
 # Template file for 'pqiv'
 pkgname=pqiv
 version=2.12
-revision=1
+revision=2
 build_style=gnu-makefile
 hostmakedepends="pkg-config"
 makedepends="glib-devel gtk+3-devel $(vopt_if ffmpeg ffmpeg-devel)

From 2e758417b000e433a94594726cb90eff92bfbc7f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 058/113] qmmp: revbump for ffmpeg6

---
 srcpkgs/qmmp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qmmp/template b/srcpkgs/qmmp/template
index 53781ea3bc28a..2da07f1e87eac 100644
--- a/srcpkgs/qmmp/template
+++ b/srcpkgs/qmmp/template
@@ -1,7 +1,7 @@
 # Template file for 'qmmp'
 pkgname=qmmp
 version=1.6.1
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DUSE_HAL:BOOL=FALSE -DQMMP_DEFAULT_UI:STRING=simple"
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From c721b527ff2beadbc8d2f695b878a991860b9ffa Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 14 Dec 2023 13:28:10 -0500
Subject: [PATCH 059/113] qt6-pdf: revbump for ffmpeg6

---
 srcpkgs/qt6-pdf/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-pdf/template b/srcpkgs/qt6-pdf/template
index ecda84afac131..531b4e1d4fe84 100644
--- a/srcpkgs/qt6-pdf/template
+++ b/srcpkgs/qt6-pdf/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-pdf'
 pkgname=qt6-pdf
 version=6.6.0
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DQT_FEATURE_qtpdf_build=ON
  -DQT_FEATURE_qtpdf_widgets_build=ON

From b212928399fba1ac1bae4f516f5a4a81aa813c5b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 060/113] qt5-webengine: revbump for ffmpeg6

---
 .../chromium-media-filters-cpp14.patch        |  11 ++
 srcpkgs/qt5-webengine/patches/ffmpeg5.patch   | 179 ++++++++++++++++++
 .../qtwebengine-fix-ffmpeg5-build.patch       |  14 ++
 srcpkgs/qt5-webengine/template                |   4 +-
 4 files changed, 206 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/ffmpeg5.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch

diff --git a/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
new file mode 100644
index 0000000000000..04adc540f2cbc
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
@@ -0,0 +1,11 @@
+--- a/src/3rdparty/chromium/media/filters/BUILD.gn	2023-02-27 13:32:59.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/BUILD.gn	2023-04-02 17:21:39.204066384 -0400
+@@ -96,6 +96,8 @@
+     "//ui/gfx/geometry:geometry",
+   ]
+ 
++  cflags_cc = [ "-std=c++14" ]
++
+   libs = []
+ 
+   if (proprietary_codecs) {
diff --git a/srcpkgs/qt5-webengine/patches/ffmpeg5.patch b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..ac55e1634423a
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
@@ -0,0 +1,179 @@
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:57.732547446 -0400
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:09.486478995 -0400
+@@ -57,6 +57,8 @@
+ 
+ namespace {
+ 
++constexpr int64_t kRelativeTsBase = static_cast<int64_t>(0x7ffeffffffffffff);
++
+ void SetAVStreamDiscard(AVStream* stream, AVDiscard discard) {
+   DCHECK(stream);
+   stream->discard = discard;
+@@ -90,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+   if (stream->start_time != kNoFFmpegTimestamp)
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (stream->first_dts != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, stream->first_dts);
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -408,11 +398,11 @@
+   scoped_refptr<DecoderBuffer> buffer;
+ 
+   if (type() == DemuxerStream::TEXT) {
+-    int id_size = 0;
++    size_t id_size = 0;
+     uint8_t* id_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
+ 
+-    int settings_size = 0;
++    size_t settings_size = 0;
+     uint8_t* settings_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
+ 
+@@ -424,7 +414,7 @@
+     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
+                                      side_data.data(), side_data.size());
+   } else {
+-    int side_data_size = 0;
++    size_t side_data_size = 0;
+     uint8_t* side_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
+ 
+@@ -485,7 +475,7 @@
+                                        packet->size - data_offset);
+     }
+ 
+-    int skip_samples_size = 0;
++    size_t skip_samples_size = 0;
+     const uint32_t* skip_samples_ptr =
+         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
+             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
+@@ -1587,6 +1577,8 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++      continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+       lowest_start_time_stream = stream.get();
+@@ -1604,6 +1596,8 @@
+     if (stream && stream->type() == DemuxerStream::VIDEO &&
+         stream->IsEnabled()) {
+       video_stream = stream.get();
++      if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++        continue;
+       if (video_stream->start_time() <= seek_time) {
+         return video_stream;
+       }
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h qtwebengine-5.15.10/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h
+--- a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-07-11 22:12:47.917192788 -0500
+@@ -29,6 +29,7 @@ extern "C" {
+ #include <libavformat/avformat.h>
+ #include <libavformat/avio.h>
+ #include <libavutil/avutil.h>
++#include <libavutil/channel_layout.h>
+ #include <libavutil/imgutils.h>
+ #include <libavutil/log.h>
+ #include <libavutil/mastering_display_metadata.h>
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/audio_file_reader.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/audio_file_reader.cc
+--- a/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -85,7 +85,7 @@ bool AudioFileReader::OpenDemuxer() {
+ }
+ 
+ bool AudioFileReader::OpenDecoder() {
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (codec) {
+     // MP3 decodes to S16P which we don't support, tell it to use S16 instead.
+     if (codec_context_->sample_fmt == AV_SAMPLE_FMT_S16P)
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -329,7 +329,7 @@ bool FFmpegAudioDecoder::ConfigureDecode
+     }
+   }
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec ||
+       avcodec_open2(codec_context_.get(), codec, &codec_options) < 0) {
+     DLOG(ERROR) << "Could not initialize audio decoder: "
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -59,7 +59,6 @@ static int64_t AVIOSeekOperation(void* o
+ }
+ 
+ void FFmpegGlue::InitializeFFmpeg() {
+-  av_register_all();
+ }
+ 
+ static void LogContainer(bool is_local_file,
+@@ -95,9 +94,6 @@ FFmpegGlue::FFmpegGlue(FFmpegURLProtocol
+   // Enable fast, but inaccurate seeks for MP3.
+   format_context_->flags |= AVFMT_FLAG_FAST_SEEK;
+ 
+-  // Ensures we can read out various metadata bits like vp8 alpha.
+-  format_context_->flags |= AVFMT_FLAG_KEEP_SIDE_DATA;
+-
+   // Ensures format parsing errors will bail out. From an audit on 11/2017, all
+   // instances were real failures. Solves bugs like http://crbug.com/710791.
+   format_context_->error_recognition |= AV_EF_EXPLODE;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -391,7 +391,7 @@ bool FFmpegVideoDecoder::ConfigureDecode
+   if (decode_nalus_)
+     codec_context_->flags2 |= AV_CODEC_FLAG2_CHUNKS;
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
+     ReleaseFFmpegResources();
+     return false;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/media_file_checker.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/media_file_checker.cc
+--- a/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -68,7 +68,7 @@ bool MediaFileChecker::Start(base::TimeD
+       auto context = AVStreamToAVCodecContext(format_context->streams[i]);
+       if (!context)
+         continue;
+-      AVCodec* codec = avcodec_find_decoder(cp->codec_id);
++      const AVCodec* codec = avcodec_find_decoder(cp->codec_id);
+       if (codec && avcodec_open2(context.get(), codec, nullptr) >= 0) {
+         auto loop = std::make_unique<FFmpegDecodingLoop>(context.get());
+         stream_contexts[i] = {std::move(context), std::move(loop)};
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc qtwebengine-5.15.10/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc
+--- a/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -203,7 +203,7 @@ int32_t H264DecoderImpl::InitDecode(cons
+   // a pointer |this|.
+   av_context_->opaque = this;
+ 
+-  AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
+   if (!codec) {
+     // This is an indication that FFmpeg has not been initialized or it has not
+     // been compiled/initialized with the correct set of codecs.
diff --git a/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch b/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch
new file mode 100644
index 0000000000000..bc24d5b9a29cb
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch
@@ -0,0 +1,14 @@
+--- a/src/buildtools/configure.json	2023-12-09 11:06:01.503058569 -0500
++++ b/src/buildtools/configure.json	2023-12-09 11:06:14.982361345 -0500
+@@ -779,11 +779,6 @@
+             "type": "warning",
+             "condition": "config.ios && config.simulator && config.device && features.build-qtpdf",
+             "message": "Building fat libray with device and simulator architectures will disable NEON."
+-        },
+-        {
+-            "type": "fatal",
+-            "condition": "features.webengine-system-ffmpeg && !libs.webengine-ffmpeg-support",
+-            "message": "Unmodified ffmpeg >= 5.0 is not supported. Please configure with -qt-webengine-ffmpeg."
+         }
+     ],
+     "summary": [
diff --git a/srcpkgs/qt5-webengine/template b/srcpkgs/qt5-webengine/template
index 8d2df1b5175ba..1687a77eb8a2f 100644
--- a/srcpkgs/qt5-webengine/template
+++ b/srcpkgs/qt5-webengine/template
@@ -1,14 +1,14 @@
 # Template file for 'qt5-webengine'
 pkgname=qt5-webengine
 version=5.15.16
-revision=1
+revision=2
 _version="${version}-lts"
 _chromium_commit=207c2ac45ca3386d153770c6b0d2ea2ec21ca880
 archs="x86_64* i686* armv[67]* ppc64* aarch64*"
 create_wrksrc=yes
 build_style=qmake
 configure_args="--
- -webengine-icu -webengine-ffmpeg -webengine-opus -webengine-webp
+ -webengine-icu -system-ffmpeg -webengine-opus -webengine-webp
  -webengine-pepper-plugins -webengine-printing-and-pdf -webengine-proprietary-codecs
  -webengine-pulseaudio -webengine-spellchecker -webengine-webrtc -webengine-geolocation
  -webengine-kerberos -no-webengine-embedded-build $(vopt_if sndio '' '-no')-webengine-sndio

From 61b8cc0db7db8121dc764e5e96a8521daec4509a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 061/113] qt5: revbump for ffmpeg6

---
 srcpkgs/qt5/template | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/srcpkgs/qt5/template b/srcpkgs/qt5/template
index ef6e437e02dbc..771872a54d67c 100644
--- a/srcpkgs/qt5/template
+++ b/srcpkgs/qt5/template
@@ -5,7 +5,7 @@ pkgname=qt5
 version=5.15.11+20231124
 # commit 4765fa1df7a837db9c1f89c4da0dd76b74bb5fab
 # base repo: https://invent.kde.org/qt/qt/qt5
-revision=1
+revision=2
 build_style=meta
 hostmakedepends="cmake clang flex perl glib-devel pkg-config
  python3 re2c ruby which"
@@ -246,7 +246,6 @@ do_configure() {
 	# opts+=" -v"
 	opts+=" -skip qtwebengine"
 	opts+=" -skip qtwebview"
-	opts+=" -skip qtdocgallery"
 	opts+=" -skip qtpim"
 	opts+=" -skip qtsystems"
 	opts+=" -skip qtspeech"

From d8e5354e746cb1fe556becb89b17c471e36257de Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 062/113] qtav: revbump for ffmpeg4

---
 srcpkgs/qtav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qtav/template b/srcpkgs/qtav/template
index 775d5a139a9ef..2d00ad104355e 100644
--- a/srcpkgs/qtav/template
+++ b/srcpkgs/qtav/template
@@ -4,7 +4,7 @@ version=1.13.0
 revision=2
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel libass-devel libopenal-devel
+makedepends="ffmpeg4-devel libass-devel libopenal-devel
  libva-glx-devel libXv-devel pulseaudio-devel
  qt5-declarative-devel qt5-svg-devel
  qt5-quickcontrols"

From 40d2656b14b839df42030bd7b1f7483fdbf8f52c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 063/113] retroarch: revbump for ffmpeg6

---
 srcpkgs/retroarch/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroarch/template b/srcpkgs/retroarch/template
index cb3125c5dbf1a..c65c26f7bf033 100644
--- a/srcpkgs/retroarch/template
+++ b/srcpkgs/retroarch/template
@@ -1,7 +1,7 @@
 # Template file for 'retroarch'
 pkgname=retroarch
 version=1.16.0.3
-revision=3
+revision=4
 build_style=configure
 configure_args="--prefix=/usr --sysconfdir=/etc --enable-networking
  --enable-udev --disable-builtinflac --disable-builtinglslang

From 4277518f84e2276895c08a98eb98871148528af0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 064/113] scrcpy: revbump for ffmpeg6

---
 srcpkgs/scrcpy/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/scrcpy/template b/srcpkgs/scrcpy/template
index ac18bc03418ce..f39a7f678ab35 100644
--- a/srcpkgs/scrcpy/template
+++ b/srcpkgs/scrcpy/template
@@ -1,7 +1,7 @@
 # Template file for 'scrcpy'
 pkgname=scrcpy
 version=2.1.1
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcompile_server=false
  -Dprebuilt_server=/usr/share/scrcpy/scrcpy-server-v${version}"

From 3d082f6618dbddb8477c96ebd4c98ebedd64e42e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 17 Oct 2023 08:54:11 -0400
Subject: [PATCH 065/113] New package: spex-x replaces spek-alternative for
 ffmpeg6

---
 srcpkgs/spek-alternative                      |  1 +
 srcpkgs/{spek-alternative => spek-x}/template | 22 ++++++++++++-------
 2 files changed, 15 insertions(+), 8 deletions(-)
 create mode 120000 srcpkgs/spek-alternative
 rename srcpkgs/{spek-alternative => spek-x}/template (52%)

diff --git a/srcpkgs/spek-alternative b/srcpkgs/spek-alternative
new file mode 120000
index 0000000000000..76648236da701
--- /dev/null
+++ b/srcpkgs/spek-alternative
@@ -0,0 +1 @@
+spek-x
\ No newline at end of file
diff --git a/srcpkgs/spek-alternative/template b/srcpkgs/spek-x/template
similarity index 52%
rename from srcpkgs/spek-alternative/template
rename to srcpkgs/spek-x/template
index d7b55c776b1d4..3ded6c2c323e4 100644
--- a/srcpkgs/spek-alternative/template
+++ b/srcpkgs/spek-x/template
@@ -1,18 +1,18 @@
-# Template file for 'spek-alternative'
-pkgname=spek-alternative
-version=0.8.2.3
-revision=2
+# Template file for 'spek-x'
+pkgname=spek-x
+version=0.9.3
+revision=1
 build_style=gnu-configure
 hostmakedepends="automake gettext-devel intltool libtool pkg-config
  wxWidgets-common wxWidgets-gtk3-devel"
 makedepends="ffmpeg-devel wxWidgets-gtk3-devel"
 depends="ffmpeg"
 short_desc="Acoustic spectrum analyser"
-maintainer="Kartik Singh <kartik.ynwa@gmail.com>"
+maintainer="zlice <zlice555@gmail.com>"
 license="GPL-3.0-or-later"
-homepage="https://github.com/withmorten/spek-alternative"
-distfiles="https://github.com/withmorten/spek-alternative/archive/${version}.tar.gz"
-checksum="007ba4b84a310b078e378aa84c8e80783db5821437a757a488c3ecec377e6b2a"
+homepage="https://github.com/MikeWang000000/spek-x"
+distfiles="https://github.com/MikeWang000000/spek-x/archive/v${version}.tar.gz"
+checksum="7f4b109903333cdd310ab2b9176f0dc49a565891376e281a233d342cedf90ef7"
 
 CXXFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
 
@@ -22,3 +22,9 @@ export WX_CONFIG_NAME="wx-config-gtk3"
 pre_configure() {
 	NOCONFIGURE=1 ./autogen.sh
 }
+
+spek-alternative_package() {
+	depends="spek-x"
+	short_desc+=" - transitional dummy package"
+	build_style=meta
+}

From 44c19f2934388066d9cb11612024bc69599f6d5e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 066/113] ssr: revbump for ffmpeg4

---
 srcpkgs/ssr/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ssr/template b/srcpkgs/ssr/template
index 3097754e3cbe5..fa66d5b4736d4 100644
--- a/srcpkgs/ssr/template
+++ b/srcpkgs/ssr/template
@@ -5,7 +5,7 @@ revision=2
 build_style=cmake
 configure_args="-DWITH_QT5=ON"
 hostmakedepends="pkg-config"
-makedepends="alsa-lib-devel ffmpeg-devel glu-devel jack-devel pulseaudio-devel
+makedepends="alsa-lib-devel ffmpeg4-devel glu-devel jack-devel pulseaudio-devel
  qt5-tools-devel qt5-x11extras-devel libXinerama-devel v4l-utils-devel"
 depends="desktop-file-utils hicolor-icon-theme"
 short_desc="Simple Screen Recorder for programs and games"

From a2bbab9da8efddbf01c0b2a458464c5338973043 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 067/113] synfig: revbump for ffmpeg6 and mlt7

---
 srcpkgs/synfig/patches/ffmpeg6.patch | 71 ++++++++++++++++++++++++++++
 srcpkgs/synfig/template              |  4 +-
 2 files changed, 73 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/synfig/patches/ffmpeg6.patch

diff --git a/srcpkgs/synfig/patches/ffmpeg6.patch b/srcpkgs/synfig/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..10780b42782f4
--- /dev/null
+++ b/srcpkgs/synfig/patches/ffmpeg6.patch
@@ -0,0 +1,71 @@
+--- a/src/modules/mod_libavcodec/trgt_av.cpp	2022-10-25 09:14:12.000000000 -0400
++++ b/src/modules/mod_libavcodec/trgt_av.cpp	2023-05-05 21:34:17.899194559 -0400
+@@ -38,6 +41,7 @@
+ extern "C"
+ {
+ #ifdef HAVE_LIBAVFORMAT_AVFORMAT_H
++#	include <libavcodec/avcodec.h>
+ #	include <libavformat/avformat.h>
+ #elif defined(HAVE_AVFORMAT_H)
+ #	include <avformat.h>
+@@ -155,11 +156,11 @@
+     }
+ 
+ 	bool open_video_stream() {
+-		if (avcodec_open2(video_context, NULL, NULL) < 0) {
++		if (avcodec_open2(video_context, nullptr, nullptr) < 0) {
+ 			synfig::error("Target_LibAVCodec: could not open video codec");
+ 			// seems the calling of avcodec_free_context after error will cause crash
+ 			// so just forget about this context
+-			video_context = NULL;
++			video_context = nullptr;
+ 			close();
+ 			return false;
+         }
+@@ -234,15 +235,21 @@
+ 		close();
+ 
+ 		if (!av_registered) {
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 			av_register_all();
++#endif
+ 			av_registered = true;
+ 		}
+ 
+ 		// guess format
+-		AVOutputFormat *format = av_guess_format(NULL, filename.c_str(), NULL);
++#if LIBAVCODEC_VERSION_MAJOR < 59 // FFMPEG < 5.0
++		AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#else
++		const AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#endif
+ 		if (!format) {
+ 			synfig::warning("Target_LibAVCodec: unable to guess the output format, defaulting to MPEG");
+-			format = av_guess_format("mpeg", NULL, NULL);
++			format = av_guess_format("mpeg", nullptr, nullptr);
+ 		}
+ 		if (!format) {
+ 			synfig::error("Target_LibAVCodec: unable to find 'mpeg' output format");
+@@ -254,6 +261,7 @@
+ 		context = avformat_alloc_context();
+ 		assert(context);
+ 		context->oformat = format;
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 		if (filename.size() + 1 > sizeof(context->filename)) {
+ 			synfig::error(
+ 				"Target_LibAVCodec: filename too long, max length is %d, filename is '%s'",
+@@ -263,6 +271,14 @@
+ 			return false;
+ 		}
+ 		memcpy(context->filename, filename.c_str(), filename.size() + 1);
++#else
++		context->url = av_strndup(filename.c_str(), filename.size());
++		if (!context->url) {
++			synfig::error("Target_LibAVCodec: cannot allocate space for filename");
++			close();
++			return false;
++		}
++#endif
+ 
+ 		packet = av_packet_alloc();
+ 		assert(packet);
diff --git a/srcpkgs/synfig/template b/srcpkgs/synfig/template
index d4d3e341a20bf..703cfd7ebac84 100644
--- a/srcpkgs/synfig/template
+++ b/srcpkgs/synfig/template
@@ -6,7 +6,7 @@ revision=4
 build_style=gnu-configure
 configure_args="--with-boost-libdir=${XBPS_CROSS_BASE}/usr/lib"
 hostmakedepends="boost-build ImageMagick pkg-config intltool"
-makedepends="ETL gettext-devel libxml++-devel mlt-devel libmagick-devel
+makedepends="ETL gettext-devel libxml++-devel mlt7-devel libmagick-devel
  libmng-devel boost-build boost-devel libopenexr-devel ffmpeg-devel"
 depends="ImageMagick"
 short_desc="CLI 2D vector and timeline-based animation software"
@@ -20,7 +20,7 @@ CXXFLAGS="-std=c++11 -DHAVE_LOCALE_H=1"
 
 synfig-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision}
-	 libopenexr-devel libxml++-devel mlt-devel"
+	 libopenexr-devel libxml++-devel mlt7-devel"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/bin/synfig-config

From b1a286f62b830c8a7505e4dc68e3d5a76151405d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 068/113] timg: revbump for ffmpeg6

---
 srcpkgs/timg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/timg/template b/srcpkgs/timg/template
index 2a2ab763d2fdd..8fb4327535ef9 100644
--- a/srcpkgs/timg/template
+++ b/srcpkgs/timg/template
@@ -1,7 +1,7 @@
 # Template file for 'timg'
 pkgname=timg
 version=1.4.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_OPENSLIDE_SUPPORT=off -Wno-dev"
 hostmakedepends="pkg-config git"

From ee563d8d505dea5386bd95b95aac58a2ed9cccfb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 069/113] tvheadend: revbump for ffmpeg4

---
 srcpkgs/tvheadend/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tvheadend/template b/srcpkgs/tvheadend/template
index 9aea7de4ec705..012d31c4879ff 100644
--- a/srcpkgs/tvheadend/template
+++ b/srcpkgs/tvheadend/template
@@ -8,7 +8,7 @@ configure_args="--enable-dvbscan --disable-ffmpeg_static
 --disable-libx265_static --disable-libvpx_static --disable-libtheora_static
 --disable-libvorbis_static --disable-libfdkaac_static"
 hostmakedepends="gettext pkg-config python3 git which"
-makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg-devel"
+makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg4-devel"
 short_desc="TV streaming server"
 maintainer="lemmi <lemmi@nerd2nerd.org>"
 license="GPL-3.0-only"

From 9113a4aebfba262738068f5e80f161e43c5e79f4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 070/113] unpaper: update to 7.0.0.

---
 srcpkgs/unpaper/template | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/srcpkgs/unpaper/template b/srcpkgs/unpaper/template
index 38ed47a584016..1ff910e722afc 100644
--- a/srcpkgs/unpaper/template
+++ b/srcpkgs/unpaper/template
@@ -1,13 +1,13 @@
 # Template file for 'unpaper'
 pkgname=unpaper
-version=6.1
-revision=3
-build_style=gnu-configure
+version=7.0.0
+revision=1
+build_style=meson
+hostmakedepends="pkg-config meson libxslt"
+makedepends="ffmpeg-devel python3-Sphinx"
+short_desc="Post-processing tool for scanned sheets of paper"
 maintainer="Orphaned <orphan@voidlinux.org>"
-hostmakedepends="pkg-config libxslt"
-makedepends="ffmpeg-devel"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://www.flameeyes.eu/projects/unpaper"
-short_desc="A post-processing tool for scanned sheets of paper"
 distfiles="https://www.flameeyes.eu/files/${pkgname}-${version}.tar.xz"
-checksum=237c84f5da544b3f7709827f9f12c37c346cdf029b1128fb4633f9bafa5cb930
+checksum=2575fbbf26c22719d1cb882b59602c9900c7f747118ac130883f63419be46a80

From 2cc7d6054f072bb906b44a22fe09fc0d8786fa38 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 071/113] vice: revbump for ffmpeg4

---
 srcpkgs/vice/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vice/template b/srcpkgs/vice/template
index b1f866d35095e..4beab2c5f9ebd 100644
--- a/srcpkgs/vice/template
+++ b/srcpkgs/vice/template
@@ -26,7 +26,7 @@ makedepends="
 	$(vopt_if gtk3 gtk+3-devel)
 	$(vopt_if gtk3 pulseaudio-devel)
 	$(vopt_if gtk3 pango-devel)
-	$(vopt_if ffmpeg ffmpeg-devel)"
+	$(vopt_if ffmpeg ffmpeg4-devel)"
 short_desc="Emulator for C64, C128, CBM-II, PET, VIC20, Plus4 and C16"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"

From 22298ed7a60d4815a047f13ad4e8da4d096a5a01 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 072/113] waypipe: revbump for ffmpeg6

---
 srcpkgs/waypipe/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waypipe/template b/srcpkgs/waypipe/template
index 6da88b21bf2a1..4da8058400b58 100644
--- a/srcpkgs/waypipe/template
+++ b/srcpkgs/waypipe/template
@@ -1,7 +1,7 @@
 # Template file for 'waypipe'
 pkgname=waypipe
 version=0.8.6
-revision=1
+revision=2
 build_style=meson
 # lto is off because it causes linking errors in armv6l and armv7l (due to NEON)
 configure_args="-Dwerror=false -Dwith_dmabuf=enabled -Dwith_lz4=enabled

From 75d17951bd23f611617a04c72699468dde1cbbf7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 073/113] xpra: revbump for ffmpeg6

---
 srcpkgs/xpra/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xpra/template b/srcpkgs/xpra/template
index 6bfe9be2db650..1eea2962bcb82 100644
--- a/srcpkgs/xpra/template
+++ b/srcpkgs/xpra/template
@@ -1,7 +1,7 @@
 # Template file for 'xpra'
 pkgname=xpra
 version=5.0.4
-revision=1
+revision=2
 build_style=python3-module
 make_build_args="--without-cuda_kernels --without-cuda_rebuild"
 make_install_args="$(vopt_with docs) ${make_build_args}"

From 642e8067f990dd0f0bdd55f9bba52e745843d683 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:07:40 -0400
Subject: [PATCH 074/113] nv-codec-headers: update to 12.0.16.0

---
 srcpkgs/nv-codec-headers/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/nv-codec-headers/template b/srcpkgs/nv-codec-headers/template
index 3d422a61e4891..251e057f826fb 100644
--- a/srcpkgs/nv-codec-headers/template
+++ b/srcpkgs/nv-codec-headers/template
@@ -1,6 +1,6 @@
 # Template file for 'nv-codec-headers'
 pkgname=nv-codec-headers
-version=11.1.5.1
+version=12.0.16.0
 revision=1
 build_style=gnu-makefile
 short_desc="FFmpeg version of headers required to interface with Nvidias codec APIs"
@@ -8,7 +8,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="MIT"
 homepage="http://git.videolan.org/?p=ffmpeg/nv-codec-headers.git"
 distfiles="https://github.com/FFmpeg/nv-codec-headers/archive/n${version}.tar.gz"
-checksum=d095fbd56aa93772471a323be0ebe65504a0f43f06c76a30b6d25da77b06ae9c
+checksum=2a1533b65f55f9da52956faf0627ed3b74868ac0c7f269990edd21369113b48f
 
 post_install() {
 	sed -n '4,25p' include/ffnvcodec/nvEncodeAPI.h > LICENSE

From d255a7f408e0cfe5f929c14a0969a3e28b8d0b6c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:08:40 -0400
Subject: [PATCH 075/113] openimagedenoise: revbump for ffmpeg6

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index b792813dba7c2..109deb171c3f7 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,7 +1,7 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
 version=1.4.3
-revision=1
+revision=2
 archs="x86_64*"
 build_style=cmake
 hostmakedepends="ispc python3"

From 3e384b645b150c8c5591364ff4c5b0b639801acd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:31:45 -0400
Subject: [PATCH 076/113] shotcut: revbump for ffmpeg6

---
 srcpkgs/shotcut/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/shotcut/template b/srcpkgs/shotcut/template
index 33141fbd862d7..f46cb53b6bfb9 100644
--- a/srcpkgs/shotcut/template
+++ b/srcpkgs/shotcut/template
@@ -1,7 +1,7 @@
 # Template file for 'shotcut'
 pkgname=shotcut
 version=23.09.29
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSHOTCUT_VERSION=${version}"
 hostmakedepends="pkg-config qt6-tools-devel"

From 544f6bf275cfcb7cbecfe3af1ad6142d113bebc9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:30 -0400
Subject: [PATCH 077/113] shiboken2: revbump for qt5-5.15.11

---
 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch | 1 +
 srcpkgs/shiboken2/template                                 | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
 create mode 120000 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
new file mode 120000
index 0000000000000..efcf3249bd885
--- /dev/null
+++ b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1 @@
+../../python3-pyside2/patches/importlib-machinery-bypass.patch
\ No newline at end of file
diff --git a/srcpkgs/shiboken2/template b/srcpkgs/shiboken2/template
index 883d6a084d868..f3c06ec245a1f 100644
--- a/srcpkgs/shiboken2/template
+++ b/srcpkgs/shiboken2/template
@@ -1,7 +1,7 @@
 # Template file for 'shiboken2'
 pkgname=shiboken2
 version=5.15.10
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/shiboken2"
 build_style=cmake

From d1be1a11edc2f935242b2061efd408c91f1aa59d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:53 -0400
Subject: [PATCH 078/113] python3-pyside2: revbump for qt5-5.15.11

---
 .../patches/importlib-machinery-bypass.patch      | 15 +++++++++++++++
 srcpkgs/python3-pyside2/template                  |  2 +-
 2 files changed, 16 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
new file mode 100644
index 0000000000000..64c429584776b
--- /dev/null
+++ b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1,15 @@
+Using this prevents an error around line 220 below it.
+"AttributeError: module 'importlib' has no attribute 'machinery'"
+The old backup logic is in place and compiles without issues.
+--- a/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:09:34.688912402 -0400
++++ b/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:10:03.395529582 -0400
+@@ -170,9 +170,6 @@
+
+     # 'zipstring_sequence' comes from signature.cpp
+     zipbytes = base64.b64decode(''.join(zipstring_sequence))
+-    if sys.version_info[0] >= 3:
+-        vzip = zipfile.ZipFile(io.BytesIO(zipbytes))
+-        return sys.meta_path, EmbeddableZipImporter(vzip)
+
+     # Old version for Python 2.7, only.
+     import os
diff --git a/srcpkgs/python3-pyside2/template b/srcpkgs/python3-pyside2/template
index 249efa9098842..52626436ce75f 100644
--- a/srcpkgs/python3-pyside2/template
+++ b/srcpkgs/python3-pyside2/template
@@ -1,7 +1,7 @@
 # Template file for 'python3-pyside2'
 pkgname=python3-pyside2
 version=5.15.10
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/pyside2"
 build_style=cmake

From cee039ccda92017b41408d5b160cd82013ca4b44 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:35 -0400
Subject: [PATCH 079/113] konqueror: revbump for ffmpeg6

---
 srcpkgs/konqueror/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/konqueror/template b/srcpkgs/konqueror/template
index abfa59e6b7ded..3cc29c12dc1db 100644
--- a/srcpkgs/konqueror/template
+++ b/srcpkgs/konqueror/template
@@ -1,11 +1,11 @@
 # Template file for 'konqueror'
 pkgname=konqueror
 version=23.08.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DDESKTOPTOJSON_EXECUTABLE=/usr/bin/desktoptojson"
 hostmakedepends="extra-cmake-modules python3 qt5-host-tools qt5-qmake kdoctools
-kcoreaddons kconfig gettext"
+ kcoreaddons kconfig gettext"
 makedepends="qt5-devel qt5-webengine-devel qt5-declarative-devel
  qt5-webchannel-devel qt5-location-devel kcmutils-devel kdelibs4support-devel
  karchive-devel khtml-devel kdesu-devel kactivities5-devel"

From 51fed03a37a8b15091791d81dc630ef9b182a1ad Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:58 -0400
Subject: [PATCH 080/113] qt5-speech: revbump for qt5-5.15.11

---
 srcpkgs/qt5-speech/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-speech/template b/srcpkgs/qt5-speech/template
index 3ecd10d50650c..2d7d4d4d24535 100644
--- a/srcpkgs/qt5-speech/template
+++ b/srcpkgs/qt5-speech/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-speech'
 pkgname=qt5-speech
 version=5.15.7
-revision=2
+revision=3
 _commit=d32f4a479d38a11f547598004b975f4356424a16
 build_style=qmake
 configure_args="-- -flite -flite-alsa -speechd"

From 5a3bdafc45957d2b74d28a79163826a0782d545a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Jun 2023 08:20:22 -0400
Subject: [PATCH 081/113] gtk4: revbump for ffmpeg6

---
 srcpkgs/gtk4/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gtk4/template b/srcpkgs/gtk4/template
index 6a4e20357a86f..ec0c13d2cc5b0 100644
--- a/srcpkgs/gtk4/template
+++ b/srcpkgs/gtk4/template
@@ -1,7 +1,7 @@
 # Template file for 'gtk4'
 pkgname=gtk4
 version=4.12.3
-revision=1
+revision=2
 build_style=meson
 build_helper="gir"
 configure_args="-Dman-pages=true -Ddocumentation=true -Dbuild-tests=false

From 6848a70c56dd0a057cd0a065a564bffe09f2bc7b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:28:26 -0400
Subject: [PATCH 082/113] siril: revbump for ffmpeg6

---
 srcpkgs/siril/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/siril/template b/srcpkgs/siril/template
index 84332f79d060d..62750dd247548 100644
--- a/srcpkgs/siril/template
+++ b/srcpkgs/siril/template
@@ -1,7 +1,7 @@
 # Template file for 'siril'
 pkgname=siril
 version=0.9.12
-revision=10
+revision=11
 build_style=gnu-configure
 hostmakedepends="pkg-config intltool autoconf automake gettext-devel"
 makedepends="fftw-devel libconfig-devel libopencv-devel libffms2-devel

From b16d55248bcaee17e76c1158a968e1889b9da212 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 22 Jun 2023 10:25:02 -0400
Subject: [PATCH 083/113] kdenlive: revbump for ffmpeg6

---
 srcpkgs/kdenlive/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kdenlive/template b/srcpkgs/kdenlive/template
index ec5fe75860948..e69ecff31f272 100644
--- a/srcpkgs/kdenlive/template
+++ b/srcpkgs/kdenlive/template
@@ -1,7 +1,7 @@
 # Template file for 'kdenlive'
 pkgname=kdenlive
 version=23.08.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="
  extra-cmake-modules kconfig kcoreaddons kdoctools pkg-config python3

From e8d7caf863c6402d06ff6026f31c246fdcb4d962 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:20:59 -0400
Subject: [PATCH 084/113] tracker-miners: revbump for ffmpeg6

---
 srcpkgs/tracker-miners/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tracker-miners/template b/srcpkgs/tracker-miners/template
index 0b97f47489f81..f196d2bf9e4a4 100644
--- a/srcpkgs/tracker-miners/template
+++ b/srcpkgs/tracker-miners/template
@@ -1,7 +1,7 @@
 # Template file for 'tracker-miners'
 pkgname=tracker-miners
 version=3.6.1
-revision=1
+revision=2
 build_style=meson
 build_helper=qemu
 # missing libgrss for miner_rss

From 017f1ae7436b97b8af67cd90c83736045439d831 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:21:21 -0400
Subject: [PATCH 085/113] mpd: revbump for ffmpeg6

---
 srcpkgs/mpd/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpd/template b/srcpkgs/mpd/template
index 645c1b778e407..60287cc9f6e3c 100644
--- a/srcpkgs/mpd/template
+++ b/srcpkgs/mpd/template
@@ -1,7 +1,7 @@
 # Template file for 'mpd'
 pkgname=mpd
 version=0.23.14
-revision=3
+revision=4
 build_style=meson
 configure_args="-Dopus=enabled -Dmikmod=enabled -Dneighbor=true
  -Dsoundcloud=enabled -Dpipe=true -Dtwolame=enabled -Dbzip2=enabled

From 3fa0d0c4cd15557f94025266d7def2d8408e3276 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:02 -0400
Subject: [PATCH 086/113] tg_owt: revbump for ffmpeg6

---
 srcpkgs/tg_owt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tg_owt/template b/srcpkgs/tg_owt/template
index 50bc8310b8859..c93262d5c5de6 100644
--- a/srcpkgs/tg_owt/template
+++ b/srcpkgs/tg_owt/template
@@ -1,7 +1,7 @@
 # Template file for 'tg_owt'
 pkgname=tg_owt
 version=0.0.0.20230921
-revision=1
+revision=2
 _commit=3bb3d757681e6cc5135aec6529a753dc3dcdcfb9
 _libyuv_commit=04821d1e7d60845525e8db55c7bcd41ef5be9406
 _abseil_commit=8c0b94e793a66495e0b1f34a5eb26bd7dc672db0

From bd597b26106486d6e8a8495b02f938db5fcb709f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:44 -0400
Subject: [PATCH 087/113] telegram-desktop: revbump for ffmpeg6

---
 srcpkgs/telegram-desktop/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/telegram-desktop/template b/srcpkgs/telegram-desktop/template
index 9bd94ce3781ff..d33fc62b10e38 100644
--- a/srcpkgs/telegram-desktop/template
+++ b/srcpkgs/telegram-desktop/template
@@ -1,7 +1,7 @@
 # Template file for 'telegram-desktop'
 pkgname=telegram-desktop
 version=4.11.2
-revision=1
+revision=2
 build_style=cmake
 build_helper="qemu gir"
 configure_args="-DTDESKTOP_API_ID=209235

From f19e8029b55bd2ed64fe547bb24b3255a9871f88 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:11:45 -0400
Subject: [PATCH 088/113] gst-plugins-bad1: revbump for ffmpeg6

---
 srcpkgs/gst-plugins-bad1/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index fcd3538cd5cde..976e2889b588e 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-plugins-bad1'
 pkgname=gst-plugins-bad1
 version=1.22.7
-revision=1
+revision=2
 build_helper="gir"
 build_style=meson
 configure_args="-Dpackage-origin=https://voidlinux.org -Ddoc=disabled

From f372d663181c955796052408f6e489738ea9f544 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:12:09 -0400
Subject: [PATCH 089/113] openmw: revbump for ffmpeg6

---
 srcpkgs/openmw/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openmw/template b/srcpkgs/openmw/template
index 0abf5ff7cdbec..b57180f1a4446 100644
--- a/srcpkgs/openmw/template
+++ b/srcpkgs/openmw/template
@@ -1,7 +1,7 @@
 # Template file for 'openmw'
 pkgname=openmw
 version=0.48.0
-revision=2
+revision=3
 build_style=cmake
 _recast_commit=e75adf86f91eb3082220085e42dda62679f9a3ea
 _bullet_tag=3.17

From e0b87990e8c072a23f37b93cfa428478cff65c22 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:14:53 -0400
Subject: [PATCH 090/113] lms: revbump for ffmpeg6

---
 srcpkgs/lms/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/lms/template b/srcpkgs/lms/template
index e358f75902a98..3b21c458de519 100644
--- a/srcpkgs/lms/template
+++ b/srcpkgs/lms/template
@@ -1,7 +1,7 @@
 # Template file for 'lms'
 pkgname=lms
 version=3.42.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="wt-devel ffmpeg-devel boost-devel libconfig++-devel taglib-devel pam-devel libgraphicsmagick-devel gtest-devel libarchive-devel"

From 52f6b2e283a06e356b0b551e43b0375084e168f2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:18:18 -0400
Subject: [PATCH 091/113] freecad: DELETE

---
 srcpkgs/freecad/patches/001-include.patch     | 112 ------------------
 .../154-revert-gui-tmp-redirect-stderr.patch  |  68 -----------
 ...d63c8c9b1280978be841d04e68a0a55cceb9.patch |  30 -----
 srcpkgs/freecad/template                      |  12 +-
 4 files changed, 7 insertions(+), 215 deletions(-)
 delete mode 100644 srcpkgs/freecad/patches/001-include.patch
 delete mode 100644 srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
 delete mode 100644 srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch

diff --git a/srcpkgs/freecad/patches/001-include.patch b/srcpkgs/freecad/patches/001-include.patch
deleted file mode 100644
index 28b5af54999b9..0000000000000
--- a/srcpkgs/freecad/patches/001-include.patch
+++ /dev/null
@@ -1,112 +0,0 @@
-From 9a41845a417189776741297c50a3827ce292bc4f Mon Sep 17 00:00:00 2001
-From: Uwe <donovaly@users.noreply.github.com>
-Date: Sun, 3 Jul 2022 22:51:16 +0200
-Subject: [PATCH] [Part] OCCError.h: remove unneeded includes
-
-- also sort includes
----
- src/Mod/Part/App/OCCError.h             | 36 +++----------------------
- src/Mod/Part/App/OffsetCurvePyImp.cpp   | 12 ++++-----
- src/Mod/Part/App/OffsetSurfacePyImp.cpp | 10 +++----
- 3 files changed, 12 insertions(+), 46 deletions(-)
-
---- a/src/Mod/Part/App/OCCError.h
-+++ b/src/Mod/Part/App/OCCError.h
-@@ -23,36 +23,8 @@
- #ifndef _OCCError_h_
- #define _OCCError_h_
- 
--# include <Standard_Version.hxx>
- # include <Standard_Failure.hxx>
--# include <Standard_AbortiveTransaction.hxx>
--# include <Standard_ConstructionError.hxx>
--# if OCC_VERSION_HEX >= 0x060500
--# include <Standard_DefineException.hxx>
--# endif
--# include <Standard_DimensionError.hxx>
--# include <Standard_DimensionMismatch.hxx>
--# include <Standard_DivideByZero.hxx>
--# include <Standard_DomainError.hxx>
--# include <Standard_ImmutableObject.hxx>
--# include <Standard_LicenseError.hxx>
--# include <Standard_LicenseNotFound.hxx>
--# include <Standard_MultiplyDefined.hxx>
--# include <Standard_NegativeValue.hxx>
--# include <Standard_NoMoreObject.hxx>
--# include <Standard_NoSuchObject.hxx>
--# include <Standard_NotImplemented.hxx>
--# include <Standard_NullObject.hxx>
--# include <Standard_NullValue.hxx>
--# include <Standard_NumericError.hxx>
--# include <Standard_OutOfMemory.hxx>
--# include <Standard_OutOfRange.hxx>
--# include <Standard_Overflow.hxx>
--# include <Standard_ProgramError.hxx>
--# include <Standard_RangeError.hxx>
--# include <Standard_TooManyUsers.hxx>
--# include <Standard_TypeMismatch.hxx>
--# include <Standard_Underflow.hxx>
-+# include <Standard_Version.hxx>
- 
- #include <Mod/Part/PartGlobal.h>
- #include <Base/Console.h>
-@@ -88,4 +60,3 @@ PartExport extern PyObject* PartExceptio
- 
- #define PY_CATCH_OCC _PY_CATCH_OCC(return(NULL))
- #endif  // _OCCError_h_
--
---- a/src/Mod/Part/App/OffsetCurvePyImp.cpp
-+++ b/src/Mod/Part/App/OffsetCurvePyImp.cpp
-@@ -20,20 +20,20 @@
-  *                                                                         *
-  ***************************************************************************/
- 
--
- #include "PreCompiled.h"
- #ifndef _PreComp_
- # include <Geom_OffsetCurve.hxx>
- #endif
- 
--#include "OCCError.h"
--#include "Geometry.h"
-+#include <Base/GeometryPyCXX.h>
-+#include <Base/Vector3D.h>
-+#include <Base/VectorPy.h>
-+
- #include "OffsetCurvePy.h"
- #include "OffsetCurvePy.cpp"
-+#include "Geometry.h"
-+#include "OCCError.h"
- 
--#include <Base/GeometryPyCXX.h>
--#include <Base/VectorPy.h>
--#include <Base/Vector3D.h>
- 
- using namespace Part;
- 
---- a/src/Mod/Part/App/OffsetSurfacePyImp.cpp
-+++ b/src/Mod/Part/App/OffsetSurfacePyImp.cpp
-@@ -20,20 +20,16 @@
-  *                                                                         *
-  ***************************************************************************/
- 
--
- #include "PreCompiled.h"
- #ifndef _PreComp_
- # include <Geom_OffsetSurface.hxx>
- # include <memory>
- #endif
- 
--#include <Base/VectorPy.h>
--#include <Base/Vector3D.h>
--
- #include "OCCError.h"
--#include "Geometry.h"
--#include <Mod/Part/App/OffsetSurfacePy.h>
--#include <Mod/Part/App/OffsetSurfacePy.cpp>
-+#include "OffsetSurfacePy.h"
-+#include "OffsetSurfacePy.cpp"
-+
- 
- using namespace Part;
- 
diff --git a/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch b/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
deleted file mode 100644
index d6a9adabdec83..0000000000000
--- a/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
+++ /dev/null
@@ -1,68 +0,0 @@
-see https://github.com/FreeCAD/FreeCAD/commit/cfe94b00d3434f3e2c8b5114d2909f628c330fa8#commitcomment-71413407
-
-upstream: yes
-
-From 7b377a216b9185960e4cee980a6504dc1a755f50 Mon Sep 17 00:00:00 2001
-From: wmayer <wmayer@users.sourceforge.net>
-Date: Wed, 29 Jun 2022 15:19:18 +0200
-Subject: [PATCH] Gui: remove workaround for spnav 0.23 due to build failure
- with musl libc
-
----
- src/Gui/3Dconnexion/GuiNativeEventLinux.cpp | 27 ---------------------
- 1 file changed, 27 deletions(-)
-
---- a/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp
-+++ b/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp
-@@ -21,42 +21,17 @@
-  ***************************************************************************/
- 
- #include <FCConfig.h>
--#include <cstdio>
- 
- #include "GuiNativeEventLinux.h"
- 
- #include "GuiApplicationNativeEventAware.h"
- #include <Base/Console.h>
--#include <Base/FileInfo.h>
- #include <QMainWindow>
- 
- #include <QSocketNotifier>
- 
- #include <spnav.h>
- 
--namespace {
--class RedirectStdErr
--{
--public:
--    RedirectStdErr()
--        : fi(Base::FileInfo::getTempFileName())
--        , file(stderr)
--    {
--        stderr = fopen(fi.filePath().c_str(), "w");
--    }
--    ~RedirectStdErr()
--    {
--        fclose(stderr);
--        fi.deleteFile();
--        stderr = file;
--    }
--
--private:
--    Base::FileInfo fi;
--    FILE* file;
--};
--}
--
- Gui::GuiNativeEvent::GuiNativeEvent(Gui::GUIApplicationNativeEventAware *app)
- : GuiAbstractNativeEvent(app)
- {
-@@ -72,8 +47,6 @@ Gui::GuiNativeEvent::~GuiNativeEvent()
- 
- void Gui::GuiNativeEvent::initSpaceball(QMainWindow *window)
- {
--    // tmp. redirect stderr to a file to suppress an error message from spnav_open()
--    RedirectStdErr err;
-     Q_UNUSED(window)
-     if (spnav_open() == -1) {
-         Base::Console().Log("Couldn't connect to spacenav daemon. Please ignore if you don't have a spacemouse.\n");
diff --git a/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch b/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch
deleted file mode 100644
index d4acf370ca0a4..0000000000000
--- a/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-From fe02d63c8c9b1280978be841d04e68a0a55cceb9 Mon Sep 17 00:00:00 2001
-From: Roy-043 <70520633+Roy-043@users.noreply.github.com>
-Date: Thu, 29 Dec 2022 23:20:38 +0100
-Subject: [PATCH] Draft: update inspect.getargspec to inspect.getfullargspec
- (#8101)
-
----
- src/Mod/Draft/draftguitools/gui_snapper.py | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
---- a/src/Mod/Draft/draftguitools/gui_snapper.py
-+++ b/src/Mod/Draft/draftguitools/gui_snapper.py
-@@ -1426,7 +1426,7 @@ class Snapper:
-             Gui.Snapper.off()
-             self.ui.offUi()
-             if callback:
--                if len(inspect.getargspec(callback).args) > 1:
-+                if len(inspect.getfullargspec(callback).args) > 1:
-                     obj = None
-                     if self.snapInfo and ("Object" in self.snapInfo) and self.snapInfo["Object"]:
-                         obj = App.ActiveDocument.getObject(self.snapInfo["Object"])
-@@ -1445,7 +1445,7 @@ class Snapper:
-             Gui.Snapper.off()
-             self.ui.offUi()
-             if callback:
--                if len(inspect.getargspec(callback).args) > 1:
-+                if len(inspect.getfullargspec(callback).args) > 1:
-                     callback(None, None)
-                 else:
-                     callback(None)
diff --git a/srcpkgs/freecad/template b/srcpkgs/freecad/template
index c135701e38b9a..7d5165f760bab 100644
--- a/srcpkgs/freecad/template
+++ b/srcpkgs/freecad/template
@@ -1,7 +1,7 @@
 # Template file for 'freecad'
 pkgname=freecad
-version=0.20.2
-revision=7
+version=0.21.1
+revision=2
 build_wrksrc="FreeCAD-${version}"
 build_style=cmake
 pycompile_dirs="usr/lib/${pkgname}/Mod"
@@ -24,8 +24,10 @@ makedepends="python3-devel boost-devel libxerces-c-devel zlib-devel occt-devel
  coin3-devel libshiboken2-devel libspnav-devel pyside2-tools
  liblz4-devel libpyside2-python3-devel python3-matplotlib netcdf-devel
  jsoncpp-devel qt5-devel qt5-svg-devel qt5-tools-devel qt5-webkit-devel
- qt5-xmlpatterns-devel coin3-doc glew-devel python3-pivy"
-depends="python3-matplotlib python3-pyside2-webengine python3-pivy"
+ qt5-xmlpatterns-devel coin3-doc glew-devel python3-pivy qt5-webengine-devel
+ qt5-declarative-devel qt5-webchannel-devel qt5-location-devel"
+depends="python3-matplotlib python3-pyside2-webengine python3-pivy
+ python3-GitPython python3-Markdown"
 short_desc="General purpose 3D CAD modeler"
 maintainer="yopito <pierre.bourgin@free.fr>"
 license="LGPL-2.0-or-later"
@@ -35,7 +37,7 @@ distfiles="
  https://github.com/FreeCAD/FreeCAD/archive/${version}.tar.gz
  ${SOURCEFORGE_SITE}/cxx/pycxx-${_pycxxver}.tar.gz
 "
-checksum="46922f3a477e742e1a89cd5346692d63aebb2b67af887b3e463e094a4ae055da
+checksum="e9b1fd0323f101268c7f3be52db42e4a29222f2e306ae6c4a6fc309cb418d35a
  4b91e1e1141c23fbd5039df635c4bb6e75632168548f56b83ce177193c0c98c6"
 python_version=3
 patch_args="-Np1 -d ${build_wrksrc}"

From f1f30c179bf58675511b4ccd1b57492a7a907e14 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:47:18 -0400
Subject: [PATCH 092/113] libopenshot: revbump for ffmpeg6

---
 srcpkgs/libopenshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenshot/template b/srcpkgs/libopenshot/template
index 8e57c5f592169..7a8f4520e7892 100644
--- a/srcpkgs/libopenshot/template
+++ b/srcpkgs/libopenshot/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenshot'
 pkgname=libopenshot
 version=0.3.0
-revision=3
+revision=4
 build_style=cmake
 # Builds fail with Ruby-2.4.1
 configure_args="-DENABLE_RUBY=OFF -DUSE_SYSTEM_JSONCPP=ON"

From e6ddbab5d314882b498491efe4f2fb205f6b19d6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:10:30 -0500
Subject: [PATCH 093/113] openimageio: revbump for ffmpeg6

---
 srcpkgs/openimageio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimageio/template b/srcpkgs/openimageio/template
index 3ce3f9e49d350..27d2131bc0a61 100644
--- a/srcpkgs/openimageio/template
+++ b/srcpkgs/openimageio/template
@@ -1,7 +1,7 @@
 # Template file for 'openimageio'
 pkgname=openimageio
 version=2.4.9.0
-revision=7
+revision=8
 build_style=cmake
 build_helper=qemu
 configure_args="-DUSE_QT=0 -DUSE_PYTHON=0 -DOIIO_BUILD_TESTS=0

From d7854c44221532eb63c921fdc8f557527164a5d0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:11:57 -0500
Subject: [PATCH 094/113] synfigstudio: revbump for ffmpeg6

---
 srcpkgs/synfigstudio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/synfigstudio/template b/srcpkgs/synfigstudio/template
index 09e442da9a680..2bc017cedca6b 100644
--- a/srcpkgs/synfigstudio/template
+++ b/srcpkgs/synfigstudio/template
@@ -2,7 +2,7 @@
 # Should be kept in sync with 'synfig' and 'ETL'
 pkgname=synfigstudio
 version=1.4.4
-revision=4
+revision=5
 build_style=gnu-configure
 configure_args="--disable-update-mimedb"
 hostmakedepends="pkg-config intltool gettext synfig"

From 4c539ae9750c6c866b72cb13a0e30557aff6b64b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:12:32 -0500
Subject: [PATCH 095/113] gmic: revbump for ffmpeg6

---
 srcpkgs/gmic/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gmic/template b/srcpkgs/gmic/template
index fa37651bb6dee..24d10147e3aba 100644
--- a/srcpkgs/gmic/template
+++ b/srcpkgs/gmic/template
@@ -1,7 +1,7 @@
 # Template file for 'gmic'
 pkgname=gmic
 version=3.1.6
-revision=5
+revision=6
 _zart_hash=34ebf6cce0bafb98abe57cec83c4a02cd1abeca0
 create_wrksrc=yes
 build_wrksrc="src"

From a554c6478d8ae6056fd9d1e766a0e645cf8e944c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:10 -0500
Subject: [PATCH 096/113] mixxx: revbump for ffmpeg6

---
 srcpkgs/mixxx/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mixxx/template b/srcpkgs/mixxx/template
index 6921996e4e77b..6a79b328c1abf 100644
--- a/srcpkgs/mixxx/template
+++ b/srcpkgs/mixxx/template
@@ -1,7 +1,7 @@
 # Template file for 'mixxx'
 pkgname=mixxx
 version=2.3.3
-revision=6
+revision=7
 build_style=cmake
 configure_args="-DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="extra-cmake-modules pkg-config protobuf qt5-host-tools qt5-qmake"

From 42f075cb24825e1a8da80a69ee93d4850a5b3166 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:28 -0500
Subject: [PATCH 097/113] musikcube: revbump for ffmpeg6

---
 srcpkgs/musikcube/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/musikcube/template b/srcpkgs/musikcube/template
index d9e6186e6697b..637952d50aca3 100644
--- a/srcpkgs/musikcube/template
+++ b/srcpkgs/musikcube/template
@@ -1,7 +1,7 @@
 # Template file for 'musikcube'
 pkgname=musikcube
 version=3.0.0
-revision=3
+revision=4
 build_style=cmake
 make_cmd=make
 configure_args="-DNO_NCURSESW=1"

From 885f41ec663570810d390f77bfb69dfd0155ae41 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:45 -0500
Subject: [PATCH 098/113] electron24: revbump for ffmpeg6

---
 srcpkgs/electron24/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron24/template b/srcpkgs/electron24/template
index a9c865c19c989..b8613e4362bc7 100644
--- a/srcpkgs/electron24/template
+++ b/srcpkgs/electron24/template
@@ -1,7 +1,7 @@
 # Template file for 'electron24'
 pkgname=electron24
 version=24.3.0
-revision=2
+revision=3
 _nodever=18.14.0
 _chromiumver=112.0.5615.165
 archs="x86_64* aarch64*"

From e2942ae6bc0cb28cf4ac7245e4fd3bd4f813f4ed Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:00 -0500
Subject: [PATCH 099/113] electron19: revbump for ffmpeg6

---
 srcpkgs/electron19/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron19/template b/srcpkgs/electron19/template
index b18bc792c8221..29fb34e254eea 100644
--- a/srcpkgs/electron19/template
+++ b/srcpkgs/electron19/template
@@ -1,7 +1,7 @@
 # Template file for 'electron19'
 pkgname=electron19
 version=19.0.8
-revision=4
+revision=5
 _nodever=16.14.2
 _chromiumver=102.0.5005.125
 archs="x86_64* aarch64* ppc64le*"

From 51968070d33d1764836edb46895a6e17a55dc302 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:13 -0500
Subject: [PATCH 100/113] wf-recorder: revbump for ffmpeg6

---
 srcpkgs/wf-recorder/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/wf-recorder/template b/srcpkgs/wf-recorder/template
index 08f986b031006..63c45cf4b814d 100644
--- a/srcpkgs/wf-recorder/template
+++ b/srcpkgs/wf-recorder/template
@@ -1,7 +1,7 @@
 # Template file for 'wf-recorder'
 pkgname=wf-recorder
 version=0.4.1
-revision=2
+revision=3
 build_style=meson
 hostmakedepends="pkg-config scdoc wayland-devel"
 makedepends="wayland-protocols wayland-devel ffmpeg-devel libgbm-devel x264-devel

From f7c5cbc5d682b12ab94968caea97199b288eeca0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:26 -0500
Subject: [PATCH 101/113] obs: revbump for ffmpeg6

---
 srcpkgs/obs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/obs/template b/srcpkgs/obs/template
index b343f1131bfcf..a25a67433e285 100644
--- a/srcpkgs/obs/template
+++ b/srcpkgs/obs/template
@@ -1,7 +1,7 @@
 # Template file for 'obs'
 pkgname=obs
 version=30.0.0
-revision=2
+revision=3
 archs="i686* x86_64* ppc64le* aarch64* riscv64*"
 build_style=cmake
 configure_args="-DOBS_VERSION_OVERRIDE=${version} -DENABLE_JACK=ON

From a0ed4e2381d3f117976407c45e676dc800435ea6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:36 -0500
Subject: [PATCH 102/113] mlt7: revbump for ffmpeg6

---
 srcpkgs/mlt7/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mlt7/template b/srcpkgs/mlt7/template
index 98f302ad3a516..7eb8c00fa1580 100644
--- a/srcpkgs/mlt7/template
+++ b/srcpkgs/mlt7/template
@@ -1,7 +1,7 @@
 # Template file for 'mlt7'
 pkgname=mlt7
 version=7.20.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DSWIG_PYTHON=ON -DMOD_QT6=ON"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which

From 95ae8750da90b12f512829230c1331c221456380 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:48 -0500
Subject: [PATCH 103/113] qt6-multimedia: revbump for ffmpeg6

---
 srcpkgs/qt6-multimedia/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-multimedia/template b/srcpkgs/qt6-multimedia/template
index 67a577e1300fe..1da626ecf515a 100644
--- a/srcpkgs/qt6-multimedia/template
+++ b/srcpkgs/qt6-multimedia/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-multimedia'
 pkgname=qt6-multimedia
 version=6.6.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DQT_FEATURE_gstreamer=ON"
 hostmakedepends="perl qt6-declarative-host-tools pkg-config qt6-shadertools"

From f84e143125dc83e6e8b9fe206a00a8346dbd26bd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:00:15 -0500
Subject: [PATCH 104/113] baresip: revbump for ffmpeg6

---
 srcpkgs/baresip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/baresip/template b/srcpkgs/baresip/template
index 12c8954ef7b9b..b16b67beab8d2 100644
--- a/srcpkgs/baresip/template
+++ b/srcpkgs/baresip/template
@@ -1,7 +1,7 @@
 # Template file for 'baresip'
 pkgname=baresip
 version=3.6.0
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config glib-devel"
 makedepends="libgsm-devel libpng-devel openssl-devel libsndfile-devel

From 6e97ff2a30f42d619c441c6a9854a1dfb83f6112 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:30 -0500
Subject: [PATCH 105/113] QMPlay2: revbump for ffmpeg6

---
 srcpkgs/QMPlay2/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/QMPlay2/template b/srcpkgs/QMPlay2/template
index 46c80f64a1349..942258ce60fb7 100644
--- a/srcpkgs/QMPlay2/template
+++ b/srcpkgs/QMPlay2/template
@@ -1,7 +1,7 @@
 # Template file for 'QMPlay2'
 pkgname=QMPlay2
 version=23.10.22
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools"
 makedepends="alsa-lib-devel ffmpeg-devel libass-devel libcdio-devel libgme-devel

From aa5dc11dfef03a8dc34e5de373a27a1435903177 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:34 -0500
Subject: [PATCH 106/113] alsa-plugins: revbump for ffmpeg6

---
 srcpkgs/alsa-plugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/alsa-plugins/template b/srcpkgs/alsa-plugins/template
index a5708a7d82a8f..7bfdad046c483 100644
--- a/srcpkgs/alsa-plugins/template
+++ b/srcpkgs/alsa-plugins/template
@@ -1,7 +1,7 @@
 # Template file for 'alsa-plugins'
 pkgname=alsa-plugins
 version=1.2.7.1
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--disable-maemo-plugin"
 hostmakedepends="pkg-config"

From 6cd503faf30ecf29840aa561c5babe0cc8a6a12d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:43 -0500
Subject: [PATCH 107/113] minidlna: revbump for ffmpeg6

---
 srcpkgs/minidlna/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/minidlna/template b/srcpkgs/minidlna/template
index 5fa929f3a0c12..742991ecd04af 100644
--- a/srcpkgs/minidlna/template
+++ b/srcpkgs/minidlna/template
@@ -1,7 +1,7 @@
 # Template file for 'minidlna'
 pkgname=minidlna
 version=1.3.3
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="
  --sbindir=/usr/bin

From f0d95ed791885677023fb6d4e81e67a7cae5d082 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 17:57:47 -0500
Subject: [PATCH 108/113] mpv: revbump for ffmpeg6

---
 srcpkgs/mpv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpv/template b/srcpkgs/mpv/template
index 4948d1e332cb8..1ac1b167af189 100644
--- a/srcpkgs/mpv/template
+++ b/srcpkgs/mpv/template
@@ -1,7 +1,7 @@
 # Template file for 'mpv'
 pkgname=mpv
 version=0.36.0
-revision=4
+revision=5
 build_style=meson
 configure_args="-Dcdda=enabled -Ddvbin=enabled -Ddvdnav=enabled
  -Dlibmpv=true -Dcplugins=enabled

From 6f0a44a8ce2c68d523d8477c28480e379cd27405 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 17:59:29 -0500
Subject: [PATCH 109/113] qimgv: revbump for ffmpeg6

---
 srcpkgs/qimgv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qimgv/template b/srcpkgs/qimgv/template
index dd341dfe1bfce..8a7e1c081ef12 100644
--- a/srcpkgs/qimgv/template
+++ b/srcpkgs/qimgv/template
@@ -1,7 +1,7 @@
 # Template file for 'qimgv'
 pkgname=qimgv
 version=1.0.2
-revision=3
+revision=4
 build_style=cmake
 configure_args="$(vopt_if video -DVIDEO_SUPPORT=ON -DVIDEO_SUPPORT=OFF)
  $(vopt_if scale -DOPENCV_SUPPORT=ON -DOPENCV_SUPPORT=OFF)

From 1c95fa3068ba807f46b78fe757b0a661c8c59946 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 18:00:36 -0500
Subject: [PATCH 110/113] kfilemetadata5: revbump for ffmpeg6

---
 srcpkgs/kfilemetadata5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kfilemetadata5/template b/srcpkgs/kfilemetadata5/template
index 28430f112ab5d..593d2723d95d1 100644
--- a/srcpkgs/kfilemetadata5/template
+++ b/srcpkgs/kfilemetadata5/template
@@ -1,7 +1,7 @@
 # Template file for 'kfilemetadata5'
 pkgname=kfilemetadata5
 version=5.112.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="kcoreaddons extra-cmake-modules pkg-config qt5-host-tools qt5-qmake
  gettext kcoreaddons python3"

From 48be891ed1da8d02fe44a669e6c118771ad5a45d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 8 Dec 2023 11:46:01 -0500
Subject: [PATCH 111/113] vba-m: revbump for ffmpeg6

---
 srcpkgs/vba-m/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vba-m/template b/srcpkgs/vba-m/template
index 52efeede1dcba..3e0760398905c 100644
--- a/srcpkgs/vba-m/template
+++ b/srcpkgs/vba-m/template
@@ -2,7 +2,7 @@
 pkgname=vba-m
 reverts=1292_2
 version=2.1.8
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_GTK=TRUE -DENABLE_FFMPEG=TRUE -DENABLE_LINK=TRUE -DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="gettext pkg-config unzip zip yasm wxWidgets-gtk3-devel"

From f4932a75bd31bb6f9bdd884e44c5a72418f64243 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 8 Dec 2023 11:46:19 -0500
Subject: [PATCH 112/113] dolphin-emu: revbump for ffmpeg6

---
 srcpkgs/dolphin-emu/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/dolphin-emu/template b/srcpkgs/dolphin-emu/template
index 862d3ae964eec..a7ae0efb58fb7 100644
--- a/srcpkgs/dolphin-emu/template
+++ b/srcpkgs/dolphin-emu/template
@@ -1,7 +1,7 @@
 # Template file for 'dolphin-emu'
 pkgname=dolphin-emu
 version=5.0.19368
-revision=3
+revision=4
 _dolphin_commit=dadbeb4bae7e7fa23af2b46e0add4143094dc107
 _mgba_commit=44e074a15e9651481f7f652ac006a7c9d58cbeb9
 _googletest_commit=be03d00f5f0cc3a997d1a368bee8a1fe93651f48

From cbf1456a8e03982f6267c2052dc755fef4c38cdc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 19 Dec 2023 15:38:51 -0500
Subject: [PATCH 113/113] qtox: revbump for ffmpeg4

---
 srcpkgs/qtox/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtox/template b/srcpkgs/qtox/template
index bb70e7f51240a..755e4462bc013 100644
--- a/srcpkgs/qtox/template
+++ b/srcpkgs/qtox/template
@@ -1,13 +1,13 @@
 # Template file for 'qtox'
 pkgname=qtox
 version=1.17.6
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DUPDATE_CHECK=OFF
  -DGIT_DESCRIBE=${version}
  $(vopt_if snorenotify -DDESKTOP_NOTIFICATIONS=ON)"
 hostmakedepends="pkg-config qt5-host-tools qt5-devel"
-makedepends="ffmpeg-devel libexif-devel libopenal-devel libsodium-devel
+makedepends="ffmpeg4-devel libexif-devel libopenal-devel libsodium-devel
  libvpx-devel opus-devel qrencode-devel qt5-svg-devel sonnet-devel
  sqlcipher-devel toxcore-devel
  $(vopt_if snorenotify snorenotify-devel)"

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (47 preceding siblings ...)
  2023-12-19 20:48 ` zlice
@ 2023-12-29 17:30 ` zlice
  2023-12-29 17:30 ` zlice
                   ` (48 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2023-12-29 17:30 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 194 bytes --]

New comment by zlice on void-packages repository

https://github.com/void-linux/void-packages/pull/43761#issuecomment-1872235084

Comment:
https://github.com/void-linux/void-packages/pull/46013

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (48 preceding siblings ...)
  2023-12-29 17:30 ` zlice
@ 2023-12-29 17:30 ` zlice
  2023-12-29 17:47 ` [PR PATCH] [Updated] " zlice
                   ` (47 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2023-12-29 17:30 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 219 bytes --]

New comment by zlice on void-packages repository

https://github.com/void-linux/void-packages/pull/43761#issuecomment-1872235084

Comment:
tbd: new gonic package - https://github.com/void-linux/void-packages/pull/46013

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (49 preceding siblings ...)
  2023-12-29 17:30 ` zlice
@ 2023-12-29 17:47 ` zlice
  2024-01-05 13:07 ` zlice
                   ` (46 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2023-12-29 17:47 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 4019 bytes --]

There is an updated pull request by zlice against master on the void-packages repository

https://github.com/zlice/void-packages ffmpeg6-split
https://github.com/void-linux/void-packages/pull/43761

ffmpeg6 split
[ci skip]


#### Testing the changes

- I tested the changes in this PR: **YES**

main testing has been vaapi in Firefox Nightly and enc/dec in Shotcut on Intel A770

#### New package

- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**

#### Local build testing

- I built this PR locally for my native architecture, **x86_64**

#### Discussion

Continuation of https://github.com/void-linux/void-packages/pull/36315

`libavresample` is deprecated, but marked as a dependency when trying to build other packages and install `ffmpeg`(6). I think the right way to handle this is make a meta package and the add to removals?


##### Commit naming / misc

~~Commits are 'dirty' right now, running with [gstreamer 1.22.1 updates](https://github.com/void-linux/void-packages/pull/42861) and [Intel OpenCL](https://github.com/void-linux/void-packages/pull/43084). This will also make [intel packages pr](https://github.com/void-linux/void-packages/pull/41132) obsolete.~~ (see Requirements below)

Maintainer for previous ffmpeg(4) was orphaned, I can put my name in there if that matters, though I don't exactly see myself keeping up on ffmpeg.

~~This updates QT5 which looks like it is usually hosted by Johnny. Not sure if there's any reason to stay there or these sources are fine.~~ Using qt5.15.11 now, revbumps and some patches.

##### STILL FFMPEG4

These are a mix of emulators, games and/or older packages.

- attract (multiple patches in master)
- audacity (https://github.com/audacity/audacity/issues/2305 and https://sourceforge.net/p/portmedia/wiki/portsmf/ is 'beta')
- ccextractor (master patches? no release)
- vice
- kodi
- mlt (only dep left is flowblade)
- ~~synfig (mlt)~~ (work with mlt7, bump synfigstudio)
- tvheadend
- ssr
- ~~spek-alternative~~ (replace with spek-x)
- ppsspp
- olive
- moc
- mediastreamer
- libextractor
- idjc
- hedgewars
- ~~ffmpegthumbnailer~~ (patches for moviedecoder.xxx files)
- ~~ffmpegthumbs~~ (latest compiles)
- deadbeef
- omxplayer
- qtav (fork has ffmpeg 5 patch - https://github.com/cmguo/QtAV)
- `vlc` (vlc4 will support ffmpeg5, there's a patch to build 3.x with ffmpeg5 but it will lack vaapi)
- `osg` (OpenSceneGraph plus `xine-lib`)


##### HAVE NOT BUILT YET

- omxplayer (rpi only? ffmpeg4)
- kodi (big, but ffmpeg4)


##### UPDATED (for ffmpeg6)

- ~~blender: update to 3.5.1~~ ~~will be revbump with~~ https://github.com/void-linux/void-packages/pull/43992
- unpaper: update to 7.0.0.
- guvcview: update to 2.0.8.
- ~~qt5: update to 5.15.8~~ updated by another PR to 5.15.11
- ~~qt5-webengine: update to 5.18.15~~ updated by another PR to 5.15.16 (some patching for ffmpeg build)
- ~~shiboken2: revbump for qt5.15.8 (patch)~~ updated by another PR to 5.15.10
- ~~python3-pyside2: update to 5.15.8 (patch)~~ updated by another PR to 5.15.10
- New package: spex-x replaces spek-alternative for ffmpeg-6.0


##### Requirements

- ~~[gstreamer 1.22.2](https://github.com/void-linux/void-packages/pull/42861)~~ - a few packages use ffmpeg-devel and require a revbump

- ~~[Intel Packages](https://github.com/void-linux/void-packages/pull/41132) [Intel Packages v2](https://github.com/void-linux/void-packages/pull/47330) - ffmpeg4 uses different libraries than 6 (libmfx / Intel-MediaSDK vs only oneVPL that Intel is moving to), both are included here~~. Using replacement oneVPL from OBS update.

- ~~[shotcut 23.05.14](https://github.com/void-linux/void-packages/pull/44260)~~

- https://github.com/void-linux/void-packages/pull/44781 will remove from this PR

A patch file from https://github.com/void-linux/void-packages/pull/43761.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ffmpeg6-split-43761.patch --]
[-- Type: text/x-diff, Size: 220566 bytes --]

From 50666aab1bc46edb585b112b4185b3cdd44b678a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:16:56 -0400
Subject: [PATCH 001/113] ffmpeg: update to 6.0.1.

---
 common/shlibs                                 | 26 +++++---
 srcpkgs/ffmpeg/files/altivec.patch            | 60 -------------------
 .../patches/armv5tel-floating-point.patch     | 18 ------
 ...h-libavcodec-libsvtav1-ten_bit_format.diff | 40 -------------
 .../workaround-mesa-readeon-vaapi-bug.patch   | 28 ---------
 srcpkgs/ffmpeg/template                       | 38 ++++++------
 6 files changed, 37 insertions(+), 173 deletions(-)
 delete mode 100644 srcpkgs/ffmpeg/files/altivec.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 delete mode 100644 srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch

diff --git a/common/shlibs b/common/shlibs
index cdee5382e28f6..0c0048f863b7d 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -385,15 +385,23 @@ libid3tag.so.0 libid3tag-0.15.1b_1
 libgif.so.7 giflib-5.1.0_1
 libImlib2.so.1 imlib2-1.4.2_1
 libmp3lame.so.0 lame-3.98.2_1
-libavdevice.so.58 libavdevice-4.0_1
-libavformat.so.58 libavformat-4.0_1
-libswscale.so.5 libswscale-4.0_1
-libswresample.so.3 libswresample-4.0_1
-libavresample.so.4 libavresample-4.0_1
-libpostproc.so.55 libpostproc-4.0_1
-libavcodec.so.58 libavcodec-4.0_1
-libavutil.so.56 libavutil-4.0_1
-libavfilter.so.7 libavfilter-4.0_1
+libavdevice.so.60 libavdevice-6.0_1
+libavformat.so.60 libavformat-6.0_1
+libswscale.so.7 libswscale-6.0_1
+libswresample.so.4 libswresample-6.0_1
+libpostproc.so.57 libpostproc-6.0_1
+libavcodec.so.60 libavcodec-6.0_1
+libavutil.so.58 libavutil-6.0_1
+libavfilter.so.9 libavfilter-6.0_1
+libavdevice.so.58 libavdevice4-4.0_1
+libavformat.so.58 libavformat4-4.0_1
+libswscale.so.5 libswscale4-4.0_1
+libswresample.so.3 libswresample4-4.0_1
+libavresample.so.4 libavresample4-4.0_1
+libpostproc.so.55 libpostproc4-4.0_1
+libavcodec.so.58 libavcodec4-4.0_1
+libavutil.so.56 libavutil4-4.0_1
+libavfilter.so.7 libavfilter4-4.0_1
 libSDL-1.2.so.0 SDL-1.2.14_1
 libSDL_image-1.2.so.0 SDL_image-1.2.10_1
 libx264.so.157 x264-20190507.2245_1
diff --git a/srcpkgs/ffmpeg/files/altivec.patch b/srcpkgs/ffmpeg/files/altivec.patch
deleted file mode 100644
index 9c57200463320..0000000000000
--- a/srcpkgs/ffmpeg/files/altivec.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-revert some altivec specific change on all ppc* except ppc64le*
-
-q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
-conditionally, for ppc* but not ppc64le* (the new code is valid for
-POWER8 VSX which LE targets as a baseline but not BE)"
-
-
-This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
----
- libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
- 1 file changed, 20 insertions(+), 4 deletions(-)
-
-diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
-index 536545293d..c1e2852adb 100644
---- a/libswscale/ppc/yuv2rgb_altivec.c
-+++ b/libswscale/ppc/yuv2rgb_altivec.c
-@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-     vector signed short R1, G1, B1;                                           \
-     vector unsigned char R, G, B;                                             \
-                                                                               \
-+    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
-+    vector unsigned char align_perm;                                          \
-+                                                                              \
-     vector signed short lCY       = c->CY;                                    \
-     vector signed short lOY       = c->OY;                                    \
-     vector signed short lCRV      = c->CRV;                                   \
-@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
-                                                                               \
-         for (j = 0; j < w / 16; j++) {                                        \
--            y0 = vec_xl(0, y1i);                                              \
-+            y1ivP = (const vector unsigned char *) y1i;                       \
-+            y2ivP = (const vector unsigned char *) y2i;                       \
-+            uivP  = (const vector unsigned char *) ui;                        \
-+            vivP  = (const vector unsigned char *) vi;                        \
-+                                                                              \
-+            align_perm = vec_lvsl(0, y1i);                                    \
-+            y0 = (vector unsigned char)                                       \
-+                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
-                                                                               \
--            y1 = vec_xl(0, y2i);                                              \
-+            align_perm = vec_lvsl(0, y2i);                                    \
-+            y1 = (vector unsigned char)                                       \
-+                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
-                                                                               \
--            u = (vector signed char) vec_xl(0, ui);                           \
-+            align_perm = vec_lvsl(0, ui);                                     \
-+            u = (vector signed char)                                          \
-+                    vec_perm(uivP[0], uivP[1], align_perm);                   \
-                                                                               \
--            v = (vector signed char) vec_xl(0, vi);                           \
-+            align_perm = vec_lvsl(0, vi);                                     \
-+            v = (vector signed char)                                          \
-+                    vec_perm(vivP[0], vivP[1], align_perm);                   \
-                                                                               \
-             u = (vector signed char)                                          \
-                     vec_sub(u,                                                \
--- 
-2.27.0
-
diff --git a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
deleted file mode 100644
index 9a55178c74f0f..0000000000000
--- a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
-+++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
-@@ -39,6 +39,15 @@
- #endif
- #include <fenv.h>
- 
-+#if (FE_ALL_EXCEPT == 0)
-+/* E.g. ARM soft float does not define these */
-+#define FE_INVALID    0
-+#define FE_DIVBYZERO  0
-+#define FE_OVERFLOW   0
-+#define FE_UNDERFLOW  0
-+#define FE_INEXACT    0
-+#endif
-+
- #if CONFIG_LIBFONTCONFIG
- #include <fontconfig/fontconfig.h>
- #endif
diff --git a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
deleted file mode 100644
index aa948f7a8a2df..0000000000000
--- a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
+++ /dev/null
@@ -1,40 +0,0 @@
-#==================================================================================================
-# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
-# From: Christopher Degawa <christopher.degawa@intel.com>
-# Date: Thu, 20 Oct 2022 22:55:27 -0500
-# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
-#
-# compressed_ten_bit_format has been deprecated upstream and has no effect
-# and can be removed. Plus, technically it was never used in the first place
-# since it would require the app (ffmpeg) to set it and do additional
-# processing of the input frames.
-#
-# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
-#
-# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
-#==================================================================================================
---- a/libavcodec/libsvtav1.c
-+++ b/libavcodec/libsvtav1.c
-@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
- 
- static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
- {
--    const int    pack_mode_10bit =
--        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
--    const size_t luma_size_8bit  =
--        config->source_width * config->source_height * (1 << pack_mode_10bit);
--    const size_t luma_size_10bit =
--        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
-+    const size_t luma_size = config->source_width * config->source_height *
-+        (config->encoder_bit_depth > 8 ? 2 : 1);
- 
-     EbSvtIOFormat *in_data;
- 
--    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
-+    svt_enc->raw_size = luma_size * 3 / 2;
- 
-     // allocate buffer for in and out
-     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
--- 
-GitLab
-
diff --git a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
deleted file mode 100644
index 00e3f68a415b8..0000000000000
--- a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
-From: Rainer Hochecker <fernetmenta@online.de>
-Date: Sat, 26 Jan 2019 19:48:35 +0100
-Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
-
-This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
-It was hit frequently when watching h264 channels received via DVB-X.
-Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
----
- libavcodec/vaapi_h264.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
-index 5854587a255..f12fdc457a4 100644
---- a/libavcodec/vaapi_h264.c
-+++ b/libavcodec/vaapi_h264.c
-@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
-     H264SliceContext *sl = &h->slice_ctx[0];
-     int ret;
- 
-+    if (pic->nb_slices == 0) {
-+        ret = AVERROR_INVALIDDATA;
-+        goto finish;
-+    }
-+
-     ret = ff_vaapi_decode_issue(avctx, pic);
-     if (ret < 0)
-         goto finish;
diff --git a/srcpkgs/ffmpeg/template b/srcpkgs/ffmpeg/template
index 5968a09b1f12d..52fcf4d68797a 100644
--- a/srcpkgs/ffmpeg/template
+++ b/srcpkgs/ffmpeg/template
@@ -1,15 +1,15 @@
 # Template file for 'ffmpeg'
 # audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
 pkgname=ffmpeg
-version=4.4.4
-revision=5
+version=6.0.1
+revision=1
 short_desc="Decoding, encoding and streaming software"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="https://www.ffmpeg.org"
 changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
 distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
-checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+checksum=9b16b8731d78e596b4be0d720428ca42df642bb2d78342881ff7f5bc29fc9623
 
 hostmakedepends="pkg-config perl"
 makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
@@ -26,12 +26,13 @@ makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-deve
  $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
  $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
  $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
- $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers Vulkan-Tools Vulkan-ValidationLayers')
+ $(vopt_if onevpl 'oneVPL oneVPL-devel')
  $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
 depends="ffplay>=${version}_${revision}"
 
 build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
- dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec onevpl"
 build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
 desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
 desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
@@ -39,9 +40,13 @@ desc_option_sofa="Enable support for AES SOFA"
 desc_option_webp="Enable support for WebP"
 
 case "$XBPS_TARGET_MACHINE" in
-	i686*|x86_64*)
-		hostmakedepends+=" nasm"
+	i686*)
 		build_options_default+=" vaapi vdpau nvenc nvdec"
+		hostmakedepends+=" nasm"
+		;;
+	x86_64*)
+		hostmakedepends+=" nasm"
+		build_options_default+=" vaapi vdpau nvenc nvdec onevpl"
 		;;
 	ppc64*) build_options_default+=" vaapi vdpau";;
 	mips*) CFLAGS="-mnan=legacy";;
@@ -115,18 +120,19 @@ do_configure() {
 		$(vopt_enable x265 libx265) \
 		$(vopt_enable v4l2 libv4l2) \
 		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
-		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		--enable-libbs2b --enable-libvidstab \
 		$(vopt_enable dav1d libdav1d) \
 		$(vopt_enable zimg libzimg) \
 		$(vopt_enable webp libwebp) \
 		$(vopt_enable sofa libmysofa) \
 		$(vopt_enable vulkan) \
+		$(vopt_enable onevpl libvpl) \
 		$(vopt_enable drm libdrm) \
 		$(vopt_enable svtav1 libsvtav1) \
 		$(vopt_enable srt libsrt) \
 		$(vopt_enable rist librist) \
-		$(vopt_if nvenc '--enable-nvenc') \
-		$(vopt_if nvdec '--enable-nvdec')
+		$(vopt_enable nvenc nvenc) \
+		$(vopt_enable nvdec nvdec)
 }
 
 do_build() {
@@ -153,10 +159,8 @@ libavdevice_package() {
 }
 
 libavresample_package() {
-	short_desc="FFmpeg audio resampling library"
-	pkg_install() {
-		vmove "usr/lib/libavresample.so.*"
-	}
+	short_desc="Package deprecated, removal needed"
+	build_style=meta
 }
 
 libavformat_package() {
@@ -210,15 +214,13 @@ ffmpeg-devel_package() {
 		libavfilter>=${version}_${revision}
 		libpostproc>=${version}_${revision}
 		libswscale>=${version}_${revision}
-		libswresample>=${version}_${revision}
-		libavresample>=${version}_${revision}"
+		libswresample>=${version}_${revision}"
 	short_desc+=" - development files"
-
+	conflicts="ffmpeg4-devel"
 	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
 		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
 		nostrip_files="/usr/lib/libavfilter.a"
 	fi
-
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig

From a5ae509fcebd501b3f165d6e130661255bf8cfb0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:14 -0400
Subject: [PATCH 002/113] openshot: revbump for ffmpeg6

---
 srcpkgs/openshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openshot/template b/srcpkgs/openshot/template
index 8f47851eef354..affb652a9d500 100644
--- a/srcpkgs/openshot/template
+++ b/srcpkgs/openshot/template
@@ -1,7 +1,7 @@
 # Template file for 'openshot'
 pkgname=openshot
 version=3.0.0
-revision=2
+revision=3
 build_style=python3-module
 hostmakedepends="python3 python3-setuptools"
 makedepends="ffmpeg-devel python3-PyQt5"

From 02171588029ed866023bb6d15d38991273f4d99f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:36 -0400
Subject: [PATCH 003/113] sumo: revbump for ffmpeg6

---
 srcpkgs/sumo/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/sumo/template b/srcpkgs/sumo/template
index a3fe134aa5acc..a730afa9fafa9 100644
--- a/srcpkgs/sumo/template
+++ b/srcpkgs/sumo/template
@@ -1,7 +1,7 @@
 # Template file for 'sumo'
 pkgname=sumo
 version=1.12.0
-revision=6
+revision=7
 build_style=cmake
 hostmakedepends="libgdal-tools pkg-config swig python3-setuptools"
 makedepends="python3-devel ffmpeg-devel fox-devel gl2ps-devel libgdal-devel

From f4a863c2c3fe73470269b5ee819fc51ee3e99515 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:56:22 -0400
Subject: [PATCH 004/113] New package: ffmpeg4-4.4.4.

---
 srcpkgs/ffmpeg4-devel                         |   1 +
 srcpkgs/ffmpeg4/files/altivec.patch           |  60 +++++
 .../patches/armv5tel-floating-point.patch     |  18 ++
 ...h-libavcodec-libsvtav1-ten_bit_format.diff |  40 +++
 .../workaround-mesa-readeon-vaapi-bug.patch   |  28 +++
 srcpkgs/ffmpeg4/template                      | 234 ++++++++++++++++++
 srcpkgs/libavcodec4                           |   1 +
 srcpkgs/libavdevice4                          |   1 +
 srcpkgs/libavfilter4                          |   1 +
 srcpkgs/libavformat4                          |   1 +
 srcpkgs/libavresample4                        |   1 +
 srcpkgs/libavutil4                            |   1 +
 srcpkgs/libpostproc4                          |   1 +
 srcpkgs/libswresample4                        |   1 +
 srcpkgs/libswscale4                           |   1 +
 15 files changed, 390 insertions(+)
 create mode 120000 srcpkgs/ffmpeg4-devel
 create mode 100644 srcpkgs/ffmpeg4/files/altivec.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 create mode 100644 srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
 create mode 100644 srcpkgs/ffmpeg4/template
 create mode 120000 srcpkgs/libavcodec4
 create mode 120000 srcpkgs/libavdevice4
 create mode 120000 srcpkgs/libavfilter4
 create mode 120000 srcpkgs/libavformat4
 create mode 120000 srcpkgs/libavresample4
 create mode 120000 srcpkgs/libavutil4
 create mode 120000 srcpkgs/libpostproc4
 create mode 120000 srcpkgs/libswresample4
 create mode 120000 srcpkgs/libswscale4

diff --git a/srcpkgs/ffmpeg4-devel b/srcpkgs/ffmpeg4-devel
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/ffmpeg4-devel
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/ffmpeg4/files/altivec.patch b/srcpkgs/ffmpeg4/files/altivec.patch
new file mode 100644
index 0000000000000..9c57200463320
--- /dev/null
+++ b/srcpkgs/ffmpeg4/files/altivec.patch
@@ -0,0 +1,60 @@
+revert some altivec specific change on all ppc* except ppc64le*
+
+q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
+conditionally, for ppc* but not ppc64le* (the new code is valid for
+POWER8 VSX which LE targets as a baseline but not BE)"
+
+
+This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
+---
+ libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
+ 1 file changed, 20 insertions(+), 4 deletions(-)
+
+diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
+index 536545293d..c1e2852adb 100644
+--- a/libswscale/ppc/yuv2rgb_altivec.c
++++ b/libswscale/ppc/yuv2rgb_altivec.c
+@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+     vector signed short R1, G1, B1;                                           \
+     vector unsigned char R, G, B;                                             \
+                                                                               \
++    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
++    vector unsigned char align_perm;                                          \
++                                                                              \
+     vector signed short lCY       = c->CY;                                    \
+     vector signed short lOY       = c->OY;                                    \
+     vector signed short lCRV      = c->CRV;                                   \
+@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
+                                                                               \
+         for (j = 0; j < w / 16; j++) {                                        \
+-            y0 = vec_xl(0, y1i);                                              \
++            y1ivP = (const vector unsigned char *) y1i;                       \
++            y2ivP = (const vector unsigned char *) y2i;                       \
++            uivP  = (const vector unsigned char *) ui;                        \
++            vivP  = (const vector unsigned char *) vi;                        \
++                                                                              \
++            align_perm = vec_lvsl(0, y1i);                                    \
++            y0 = (vector unsigned char)                                       \
++                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
+                                                                               \
+-            y1 = vec_xl(0, y2i);                                              \
++            align_perm = vec_lvsl(0, y2i);                                    \
++            y1 = (vector unsigned char)                                       \
++                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
+                                                                               \
+-            u = (vector signed char) vec_xl(0, ui);                           \
++            align_perm = vec_lvsl(0, ui);                                     \
++            u = (vector signed char)                                          \
++                    vec_perm(uivP[0], uivP[1], align_perm);                   \
+                                                                               \
+-            v = (vector signed char) vec_xl(0, vi);                           \
++            align_perm = vec_lvsl(0, vi);                                     \
++            v = (vector signed char)                                          \
++                    vec_perm(vivP[0], vivP[1], align_perm);                   \
+                                                                               \
+             u = (vector signed char)                                          \
+                     vec_sub(u,                                                \
+-- 
+2.27.0
+
diff --git a/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
new file mode 100644
index 0000000000000..9a55178c74f0f
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
@@ -0,0 +1,18 @@
+--- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
++++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
+@@ -39,6 +39,15 @@
+ #endif
+ #include <fenv.h>
+ 
++#if (FE_ALL_EXCEPT == 0)
++/* E.g. ARM soft float does not define these */
++#define FE_INVALID    0
++#define FE_DIVBYZERO  0
++#define FE_OVERFLOW   0
++#define FE_UNDERFLOW  0
++#define FE_INEXACT    0
++#endif
++
+ #if CONFIG_LIBFONTCONFIG
+ #include <fontconfig/fontconfig.h>
+ #endif
diff --git a/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
new file mode 100644
index 0000000000000..aa948f7a8a2df
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
@@ -0,0 +1,40 @@
+#==================================================================================================
+# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
+# From: Christopher Degawa <christopher.degawa@intel.com>
+# Date: Thu, 20 Oct 2022 22:55:27 -0500
+# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
+#
+# compressed_ten_bit_format has been deprecated upstream and has no effect
+# and can be removed. Plus, technically it was never used in the first place
+# since it would require the app (ffmpeg) to set it and do additional
+# processing of the input frames.
+#
+# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
+#
+# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
+#==================================================================================================
+--- a/libavcodec/libsvtav1.c
++++ b/libavcodec/libsvtav1.c
+@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
+ 
+ static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
+ {
+-    const int    pack_mode_10bit =
+-        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
+-    const size_t luma_size_8bit  =
+-        config->source_width * config->source_height * (1 << pack_mode_10bit);
+-    const size_t luma_size_10bit =
+-        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
++    const size_t luma_size = config->source_width * config->source_height *
++        (config->encoder_bit_depth > 8 ? 2 : 1);
+ 
+     EbSvtIOFormat *in_data;
+ 
+-    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
++    svt_enc->raw_size = luma_size * 3 / 2;
+ 
+     // allocate buffer for in and out
+     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
+-- 
+GitLab
+
diff --git a/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
new file mode 100644
index 0000000000000..00e3f68a415b8
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
@@ -0,0 +1,28 @@
+From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
+From: Rainer Hochecker <fernetmenta@online.de>
+Date: Sat, 26 Jan 2019 19:48:35 +0100
+Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
+
+This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
+It was hit frequently when watching h264 channels received via DVB-X.
+Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
+---
+ libavcodec/vaapi_h264.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
+index 5854587a255..f12fdc457a4 100644
+--- a/libavcodec/vaapi_h264.c
++++ b/libavcodec/vaapi_h264.c
+@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
+     H264SliceContext *sl = &h->slice_ctx[0];
+     int ret;
+ 
++    if (pic->nb_slices == 0) {
++        ret = AVERROR_INVALIDDATA;
++        goto finish;
++    }
++
+     ret = ff_vaapi_decode_issue(avctx, pic);
+     if (ret < 0)
+         goto finish;
diff --git a/srcpkgs/ffmpeg4/template b/srcpkgs/ffmpeg4/template
new file mode 100644
index 0000000000000..9ba14bdb8ddf3
--- /dev/null
+++ b/srcpkgs/ffmpeg4/template
@@ -0,0 +1,234 @@
+# Template file for 'ffmpeg4'
+# audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
+pkgname=ffmpeg4
+version=4.4.4
+revision=1
+short_desc="Decoding, encoding and streaming software - ffmpeg4 libraries only"
+maintainer="Orphaned <orphan@voidlinux.org>"
+license="GPL-3.0-or-later"
+homepage="https://www.ffmpeg.org"
+changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
+distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
+checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+
+hostmakedepends="pkg-config perl"
+makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
+ libXext-devel libXvMC-devel libxcb-devel lame-devel libtheora-devel
+ libvorbis-devel x264-devel xvidcore-devel jack-devel SDL2-devel
+ libcdio-paranoia-devel librtmp-devel libmodplug-devel gnutls-devel
+ speex-devel celt-devel harfbuzz-devel libass-devel opus-devel ocl-icd-devel
+ libbs2b-devel libvidstab-devel vmaf-devel $(vopt_if pulseaudio pulseaudio-devel)
+ $(vopt_if vaapi libva-devel) $(vopt_if vdpau libvdpau-devel)
+ $(vopt_if x265 x265-devel) $(vopt_if v4l2 v4l-utils-devel)
+ $(vopt_if fdk_aac fdk-aac-devel) $(vopt_if vpx libvpx-devel)
+ $(vopt_if aom libaom-devel) $(vopt_if sndio sndio-devel)
+ $(vopt_if dav1d libdav1d-devel) $(vopt_if zimg zimg-devel)
+ $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
+ $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
+ $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
+
+build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
+
+desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
+desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
+desc_option_sofa="Enable support for AES SOFA"
+desc_option_webp="Enable support for WebP"
+
+case "$XBPS_TARGET_MACHINE" in
+	i686*|x86_64*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau nvenc nvdec"
+			;;
+	ppc64*) build_options_default+=" vaapi vdpau";;
+	mips*) CFLAGS="-mnan=legacy";;
+esac
+
+if [ "$XBPS_TARGET_WORDSIZE" != "32" ]; then
+	build_options_default+=" svtav1"
+fi
+
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+fi
+
+_apply_patch() {
+	local args="$1" pname="$(basename $2)"
+
+	if [ ! -f ".${pname}_done" ]; then
+		patch -N $args -i $2
+		touch .${pname}_done
+	fi
+}
+
+post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64le*) ;;
+		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
+	esac
+
+	vsed -i libavfilter/vf_libvmaf.c -e 's!/usr/local/share/model/\(vmaf_v0.6.1\).pkl!/usr/share/vmaf/\1.json!'
+}
+
+do_configure() {
+	# Fix gcc on x86_64-musl only
+	if [ "$XBPS_TARGET_MACHINE" = "x86_64-musl" ]; then
+		vsed -i configure -e "s;_cflags_speed='-O3';_cflags_speed='-O2';"
+	fi
+
+	if [ "$CROSS_BUILD" ]; then
+		case "$XBPS_TARGET_MACHINE" in
+			arm*) _arch="arm";;
+			aarch64*) _arch="aarch64";;
+			mips*) _arch="mips";;
+			ppc64*) _arch="ppc64";;
+			ppc*) _arch="ppc";;
+			*) _arch="${XBPS_TARGET_MACHINE%%-musl}";;
+		esac
+
+		_args+=" --enable-cross-compile
+			--sysroot=$XBPS_CROSS_BASE
+			--cross-prefix=${XBPS_CROSS_TRIPLET}-
+			--target-os=linux --arch=${_arch}"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc|ppc-musl) _args+=" --disable-altivec";;
+	esac
+
+	if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+		_args+=" --extra-libs=-latomic"
+	fi
+
+	./configure --prefix=/usr --disable-debug --enable-gpl --enable-gnutls \
+		--disable-stripping \
+		--enable-libcdio --enable-version3 --enable-runtime-cpudetect \
+		--enable-libmp3lame --enable-libvorbis --enable-libxvid \
+		--enable-libx264 $(vopt_enable vpx libvpx) --enable-libtheora \
+		--enable-shared --enable-static --enable-libxcb \
+		$(vopt_enable pulseaudio libpulse) --enable-libfreetype --enable-libmodplug \
+		--enable-libspeex --enable-libcelt --enable-libass \
+		--enable-libopus --enable-librtmp --enable-libjack \
+		$(vopt_if fdk_aac '--enable-nonfree --enable-libfdk-aac') \
+		--disable-libopencore_amrnb --disable-libopencore_amrwb \
+		--disable-libopenjpeg \
+		--enable-postproc --enable-opencl ${_args} --enable-libvmaf ${_args} \
+		$(vopt_enable x265 libx265) \
+		$(vopt_enable v4l2 libv4l2) \
+		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
+		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		$(vopt_enable dav1d libdav1d) \
+		$(vopt_enable zimg libzimg) \
+		$(vopt_enable webp libwebp) \
+		$(vopt_enable sofa libmysofa) \
+		$(vopt_enable vulkan) \
+		$(vopt_enable drm libdrm) \
+		$(vopt_enable svtav1 libsvtav1) \
+		$(vopt_enable srt libsrt) \
+		$(vopt_enable rist librist) \
+		$(vopt_if nvenc '--enable-nvenc') \
+		$(vopt_if nvdec '--enable-nvdec')
+}
+
+do_build() {
+	make ${makejobs}
+	make doc/ff{mpeg,play}.1
+}
+
+do_install() {
+	make DESTDIR=${DESTDIR} install install-man
+	rm -rf ${DESTDIR}/usr/bin
+}
+
+libavcodec4_package() {
+	short_desc="FFmpeg codec library"
+	pkg_install() {
+		vmove "usr/lib/libavcodec.so.*"
+	}
+}
+
+libavdevice4_package() {
+	short_desc="FFmpeg device handling library"
+	pkg_install() {
+		vmove "usr/lib/libavdevice.so.*"
+	}
+}
+
+libavresample4_package() {
+	short_desc="FFmpeg audio resampling library"
+	pkg_install() {
+		vmove "usr/lib/libavresample.so.*"
+	}
+}
+
+libavformat4_package() {
+	short_desc="FFmpeg file format library"
+	pkg_install() {
+		vmove "usr/lib/libavformat.so.*"
+	}
+}
+
+libavutil4_package() {
+	short_desc="FFmpeg utility library"
+	pkg_install() {
+		vmove "usr/lib/libavutil.so.*"
+	}
+}
+
+libavfilter4_package() {
+	short_desc="FFmpeg audio/video filter library"
+	pkg_install() {
+		vmove "usr/lib/libavfilter.so.*"
+	}
+}
+
+libpostproc4_package() {
+	short_desc="FFmpeg video postprocessing library"
+	pkg_install() {
+		vmove "usr/lib/libpostproc.so.*"
+	}
+}
+
+libswscale4_package() {
+	short_desc="FFmpeg video scaling library"
+	pkg_install() {
+		vmove "usr/lib/libswscale.so.*"
+	}
+}
+
+libswresample4_package() {
+	short_desc="FFmpeg video resampling library"
+	pkg_install() {
+		vmove "usr/lib/libswresample.so.*"
+	}
+}
+
+ffmpeg4-devel_package() {
+	depends="
+		libavcodec4>=${version}_${revision}
+		libavdevice4>=${version}_${revision}
+		libavformat4>=${version}_${revision}
+		libavutil4>=${version}_${revision}
+		libavfilter4>=${version}_${revision}
+		libpostproc4>=${version}_${revision}
+		libswscale4>=${version}_${revision}
+		libswresample4>=${version}_${revision}
+		libavresample4>=${version}_${revision}"
+	short_desc+=" - development files"
+	conflicts="ffmpeg-devel"
+	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
+		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
+		nostrip_files="/usr/lib/libavfilter.a"
+	fi
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.a"
+		vmove "usr/lib/*.so"
+		vmove usr/share/ffmpeg/examples
+		vmove usr/share/man/man3
+	}
+}
diff --git a/srcpkgs/libavcodec4 b/srcpkgs/libavcodec4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavcodec4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavdevice4 b/srcpkgs/libavdevice4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavdevice4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavfilter4 b/srcpkgs/libavfilter4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavfilter4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavformat4 b/srcpkgs/libavformat4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavformat4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavresample4 b/srcpkgs/libavresample4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavutil4 b/srcpkgs/libavutil4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavutil4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libpostproc4 b/srcpkgs/libpostproc4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libpostproc4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswresample4 b/srcpkgs/libswresample4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libswresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswscale4 b/srcpkgs/libswscale4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libswscale4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file

From 0779ac5e5a402dc91ac9ec02db4180a5e5a63ce1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:04 -0400
Subject: [PATCH 005/113] opencv: update to 4.7.0.

---
 common/shlibs           | 104 ++++++++++++++++++++--------------------
 srcpkgs/opencv/template |   8 ++--
 2 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index 0c0048f863b7d..544dc89bb79fa 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2085,58 +2085,58 @@ libcapstone.so.5 capstone-5.0.1_1
 libhavege.so.2 libhaveged-1.9.11_1
 libnih.so.1 libnih-1.0.3_1
 libnih-dbus.so.1 libnih-1.0.3_1
-libopencv_quality.so.406 libopencv-4.6.0_1
-libopencv_reg.so.406 libopencv-4.6.0_1
-libopencv_surface_matching.so.406 libopencv-4.6.0_1
-libopencv_xphoto.so.406 libopencv-4.6.0_1
-libopencv_freetype.so.406 libopencv-4.6.0_1
-libopencv_fuzzy.so.406 libopencv-4.6.0_1
-libopencv_hfs.so.406 libopencv-4.6.0_1
-libopencv_img_hash.so.406 libopencv-4.6.0_1
-libopencv_line_descriptor.so.406 libopencv-4.6.0_1
-libopencv_saliency.so.406 libopencv-4.6.0_1
-libopencv_structured_light.so.406 libopencv-4.6.0_1
-libopencv_aruco.so.406 libopencv-4.6.0_1
-libopencv_bgsegm.so.406 libopencv-4.6.0_1
-libopencv_bioinspired.so.406 libopencv-4.6.0_1
-libopencv_ccalib.so.406 libopencv-4.6.0_1
-libopencv_face.so.406 libopencv-4.6.0_1
-libopencv_tracking.so.406 libopencv-4.6.0_1
-libopencv_xfeatures2d.so.406 libopencv-4.6.0_1
-libopencv_optflow.so.406 libopencv-4.6.0_1
-libopencv_ximgproc.so.406 libopencv-4.6.0_1
-libopencv_plot.so.406 libopencv-4.6.0_1
-libopencv_text.so.406 libopencv-4.6.0_1
-libopencv_ml.so.406 libopencv-4.6.0_1
-libopencv_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn.so.406 libopencv-4.6.0_1
-libopencv_shape.so.406 libopencv-4.6.0_1
-libopencv_stitching.so.406 libopencv-4.6.0_1
-libopencv_photo.so.406 libopencv-4.6.0_1
-libopencv_video.so.406 libopencv-4.6.0_1
-libopencv_calib3d.so.406 libopencv-4.6.0_1
-libopencv_features2d.so.406 libopencv-4.6.0_1
-libopencv_flann.so.406 libopencv-4.6.0_1
-libopencv_highgui.so.406 libopencv-4.6.0_1
-libopencv_videoio.so.406 libopencv-4.6.0_1
-libopencv_imgcodecs.so.406 libopencv-4.6.0_1
-libopencv_imgproc.so.406 libopencv-4.6.0_1
-libopencv_core.so.406 libopencv-4.6.0_1
-libopencv_superres.so.406 libopencv-4.6.0_1
-libopencv_videostab.so.406 libopencv-4.6.0_1
-libopencv_gapi.so.406 libopencv-4.6.0_1
-libopencv_xobjdetect.so.406 libopencv-4.6.0_1
-libopencv_datasets.so.406 libopencv-4.6.0_1
-libopencv_dnn_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn_superres.so.406 libopencv-4.6.0_1
-libopencv_dpm.so.406 libopencv-4.6.0_1
-libopencv_phase_unwrapping.so.406 libopencv-4.6.0_1
-libopencv_stereo.so.406 libopencv-4.6.0_1
-libopencv_rapid.so.406 libopencv-4.6.0_1
-libopencv_intensity_transform.so.406 libopencv-4.6.0_1
-libopencv_alphamat.so.406 libopencv-4.6.0_1
-libopencv_barcode.so.406 libopencv-4.6.0_1
-libopencv_mcc.so.406 libopencv-4.6.0_1
+libopencv_quality.so.407 libopencv-4.7.0_1
+libopencv_reg.so.407 libopencv-4.7.0_1
+libopencv_surface_matching.so.407 libopencv-4.7.0_1
+libopencv_xphoto.so.407 libopencv-4.7.0_1
+libopencv_freetype.so.407 libopencv-4.7.0_1
+libopencv_fuzzy.so.407 libopencv-4.7.0_1
+libopencv_hfs.so.407 libopencv-4.7.0_1
+libopencv_img_hash.so.407 libopencv-4.7.0_1
+libopencv_line_descriptor.so.407 libopencv-4.7.0_1
+libopencv_saliency.so.407 libopencv-4.7.0_1
+libopencv_structured_light.so.407 libopencv-4.7.0_1
+libopencv_aruco.so.407 libopencv-4.7.0_1
+libopencv_bgsegm.so.407 libopencv-4.7.0_1
+libopencv_bioinspired.so.407 libopencv-4.7.0_1
+libopencv_ccalib.so.407 libopencv-4.7.0_1
+libopencv_face.so.407 libopencv-4.7.0_1
+libopencv_tracking.so.407 libopencv-4.7.0_1
+libopencv_xfeatures2d.so.407 libopencv-4.7.0_1
+libopencv_optflow.so.407 libopencv-4.7.0_1
+libopencv_ximgproc.so.407 libopencv-4.7.0_1
+libopencv_plot.so.407 libopencv-4.7.0_1
+libopencv_text.so.407 libopencv-4.7.0_1
+libopencv_ml.so.407 libopencv-4.7.0_1
+libopencv_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn.so.407 libopencv-4.7.0_1
+libopencv_shape.so.407 libopencv-4.7.0_1
+libopencv_stitching.so.407 libopencv-4.7.0_1
+libopencv_photo.so.407 libopencv-4.7.0_1
+libopencv_video.so.407 libopencv-4.7.0_1
+libopencv_calib3d.so.407 libopencv-4.7.0_1
+libopencv_features2d.so.407 libopencv-4.7.0_1
+libopencv_flann.so.407 libopencv-4.7.0_1
+libopencv_highgui.so.407 libopencv-4.7.0_1
+libopencv_videoio.so.407 libopencv-4.7.0_1
+libopencv_imgcodecs.so.407 libopencv-4.7.0_1
+libopencv_imgproc.so.407 libopencv-4.7.0_1
+libopencv_core.so.407 libopencv-4.7.0_1
+libopencv_superres.so.407 libopencv-4.7.0_1
+libopencv_videostab.so.407 libopencv-4.7.0_1
+libopencv_gapi.so.407 libopencv-4.7.0_1
+libopencv_xobjdetect.so.407 libopencv-4.7.0_1
+libopencv_datasets.so.407 libopencv-4.7.0_1
+libopencv_dnn_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn_superres.so.407 libopencv-4.7.0_1
+libopencv_dpm.so.407 libopencv-4.7.0_1
+libopencv_phase_unwrapping.so.407 libopencv-4.7.0_1
+libopencv_stereo.so.407 libopencv-4.7.0_1
+libopencv_rapid.so.407 libopencv-4.7.0_1
+libopencv_intensity_transform.so.407 libopencv-4.7.0_1
+libopencv_alphamat.so.407 libopencv-4.7.0_1
+libopencv_barcode.so.407 libopencv-4.7.0_1
+libopencv_mcc.so.407 libopencv-4.7.0_1
 libuniconf.so.4.6 wvstreams-4.6.1_20
 libwvbase.so.4.6 wvstreams-4.6.1_20
 libwvutils.so.4.6 wvstreams-4.6.1_20
diff --git a/srcpkgs/opencv/template b/srcpkgs/opencv/template
index aea4bfc3a265c..ce94de9424d18 100644
--- a/srcpkgs/opencv/template
+++ b/srcpkgs/opencv/template
@@ -1,7 +1,7 @@
 # Template file for 'opencv'
 pkgname=opencv
-version=4.6.0
-revision=6
+version=4.7.0
+revision=1
 create_wrksrc=yes
 build_wrksrc=${pkgname}-${version}
 build_style=cmake
@@ -24,8 +24,8 @@ homepage="https://opencv.org"
 changelog="https://github.com/opencv/opencv/wiki/ChangeLog"
 distfiles="https://github.com/opencv/opencv/archive/${version}.tar.gz
  https://github.com/opencv/opencv_contrib/archive/${version}.tar.gz>contrib.tar.gz"
-checksum="1ec1cba65f9f20fe5a41fda1586e01c70ea0c9a6d7b67c9e13edf0cfe2239277
- 1777d5fd2b59029cf537e5fd6f8aa68d707075822f90bde683fcde086f85f7a7"
+checksum="8df0079cdbe179748a18d44731af62a245a45ebf5085223dc03133954c662973
+ 42df840cf9055e59d0e22c249cfb19f04743e1bdad113d31b1573d3934d62584"
 patch_args="-Np1 -d ${build_wrksrc}"
 # tests hang indenfinitely, even with test data included
 make_check=no

From ae583fd5bc61a0022da4fffb0036f9ae1670ca35 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 006/113] actiona: revbump for opencv-4.7.0

---
 srcpkgs/actiona/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/actiona/template b/srcpkgs/actiona/template
index cf5f0b7a2ae61..0d899311e6df7 100644
--- a/srcpkgs/actiona/template
+++ b/srcpkgs/actiona/template
@@ -1,7 +1,7 @@
 # Template file for 'actiona'
 pkgname=actiona
 version=3.10.1
-revision=2
+revision=3
 build_style=qmake
 configure_args="PKGCONFIG_OPENCV=opencv4"
 hostmakedepends="pkg-config qt5-plugin-mysql qt5-qmake qt5-host-tools"

From 529072af84fe0b2dad14a819cf91a66406d9a751 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 007/113] retroshare: revbump for opencv-4.7.0

---
 srcpkgs/retroshare/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroshare/template b/srcpkgs/retroshare/template
index bb17569277a7f..49e2c1cbe8a53 100644
--- a/srcpkgs/retroshare/template
+++ b/srcpkgs/retroshare/template
@@ -1,7 +1,7 @@
 # Template file for 'retroshare'
 pkgname=retroshare
 version=0.6.6
-revision=3
+revision=4
 build_style=qmake
 #XXX broadcast feature requires an ancient udp-discovery-cpp which either needs
 # to be fetched+patched (FTBFS) here or packaged :/

From 28713d800855e20b10868c74e021f3b4e2106e87 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 008/113] waifu2x-converter-cpp: revbump for opencv-4.7.0

---
 srcpkgs/waifu2x-converter-cpp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waifu2x-converter-cpp/template b/srcpkgs/waifu2x-converter-cpp/template
index 361b8a23b9497..c5ac17eb54ea4 100644
--- a/srcpkgs/waifu2x-converter-cpp/template
+++ b/srcpkgs/waifu2x-converter-cpp/template
@@ -1,7 +1,7 @@
 # Template file for 'waifu2x-converter-cpp'
 pkgname=waifu2x-converter-cpp
 version=5.2.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DINSTALL_MODELS=ON"
 hostmakedepends="pkg-config"

From faaea767754793fc9a00c5a2472aed4bba9cc44a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:38 -0400
Subject: [PATCH 009/113] vlc: revbump for ffmpeg4

---
 srcpkgs/vlc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vlc/template b/srcpkgs/vlc/template
index abc5eeba01564..5f291b1b81e23 100644
--- a/srcpkgs/vlc/template
+++ b/srcpkgs/vlc/template
@@ -25,7 +25,7 @@ lib32disabled=yes
 hostmakedepends="automake libtool pkg-config flex gettext libgcrypt-devel
  live555-devel gettext-devel $(vopt_if lua lua52) $(vopt_if chromecast protobuf)"
 makedepends="
- avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg-devel freefont-ttf
+ avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg4-devel freefont-ttf
  gnutls-devel jack-devel liba52-devel libass-devel libbluray-devel
  libcdio-devel libdca-devel libdvbpsi-devel libdvdnav-devel libmad-devel
  libmatroska-devel libmodplug-devel libmpcdec-devel libmpeg2-devel

From 34a02d95040c714bb124c7d734547cc073b577f4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:55 -0400
Subject: [PATCH 010/113] osg: revbump for ffmpeg4

---
 srcpkgs/osg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/osg/template b/srcpkgs/osg/template
index a9ebbd287933b..755793f7e11bf 100644
--- a/srcpkgs/osg/template
+++ b/srcpkgs/osg/template
@@ -8,7 +8,7 @@ build_helper="qemu"
 configure_args="-DLIB_POSTFIX="
 hostmakedepends="pkg-config xrandr"
 makedepends="MesaLib-devel gtkglext-devel libcurl-devel giflib-devel librsvg-devel
- jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg-devel xine-lib-devel
+ jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg4-devel xine-lib-devel
  SDL2-devel gst-plugins-base1-devel
  $(vopt_if openexr libopenexr-devel)
  $(vopt_if poppler poppler-glib-devel)

From 4aa4670777e46e8812eeae8b92e98974e876efd1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:13 -0400
Subject: [PATCH 011/113] xine-lib: revbump for ffmpeg4

---
 srcpkgs/xine-lib/template | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/xine-lib/template b/srcpkgs/xine-lib/template
index 3be4d08eac77a..ed6194c17d11e 100644
--- a/srcpkgs/xine-lib/template
+++ b/srcpkgs/xine-lib/template
@@ -1,14 +1,14 @@
 # Template file for 'xine-lib'
 pkgname=xine-lib
-version=1.2.12
-revision=3
+version=1.2.13
+revision=1
 build_style=gnu-configure
 configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
  --disable-oss"
 hostmakedepends="automake gettext-devel libtool pkg-config perl"
 makedepends="
  zlib-devel alsa-lib-devel libxcb-devel libSM-devel libXext-devel libXv-devel
- libXvMC-devel liba52-devel libmad-devel ffmpeg-devel pulseaudio-devel
+ libXvMC-devel liba52-devel libmad-devel ffmpeg4-devel pulseaudio-devel
  jack-devel samba-devel libflac-devel libmodplug-devel libmpcdec-devel
  speex-devel libtheora-devel libvorbis-devel libdca-devel faad2-devel
  libcdio-devel libbluray-devel aalib-devel libcaca-devel libXinerama-devel
@@ -19,7 +19,7 @@ license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="http://www.xine-project.org"
 changelog="https://sourceforge.net/projects/xine/files/xine-lib/${version}/README.txt/view"
 distfiles="${SOURCEFORGE_SITE}/xine/${pkgname}-${version}.tar.xz"
-checksum=d606270468e1540c2a89c0d7f5fdf11e17ecc0c2698cc0bcb1065ff26abee098
+checksum=5f10d6d718a4a51c17ed1b32b031d4f9b80b061e8276535b2be31e5ac4b75e6f
 
 case "$XBPS_TARGET_MACHINE" in
 	i686-musl)

From 7a0d955041a5ba0799eb43d7aee9da38e547d9db Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 012/113] arcan: revbump for ffmpeg6

---
 srcpkgs/arcan/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/arcan/template b/srcpkgs/arcan/template
index efd0afe10576d..b91e6900d42a1 100644
--- a/srcpkgs/arcan/template
+++ b/srcpkgs/arcan/template
@@ -2,7 +2,7 @@
 # !! keep synced with: acfgfs aclip aloadimage
 pkgname=arcan
 version=0.6.2.1
-revision=1
+revision=2
 create_wrksrc=yes
 build_wrksrc=arcan/src
 build_style=cmake

From d4dfaa2404954efde143912bfb17366d615159a8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 013/113] attract: revbump for ffmpeg4

---
 srcpkgs/attract/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/attract/template b/srcpkgs/attract/template
index 24017d2bacc24..e760bf0d18aec 100644
--- a/srcpkgs/attract/template
+++ b/srcpkgs/attract/template
@@ -6,7 +6,7 @@ build_style=gnu-makefile
 make_build_args="VERBOSE=1"
 make_use_env=yes
 hostmakedepends="pkg-config"
-makedepends="SFML-devel ffmpeg-devel fontconfig-devel glu-devel libarchive-devel
+makedepends="SFML-devel ffmpeg4-devel fontconfig-devel glu-devel libarchive-devel
  libcurl-devel libjpeg-turbo-devel xine-lib rapidjson libXrandr-devel"
 depends="git"
 short_desc="Attract-Mode is a graphical frontend for emulators"

From dc3d5025eef34ad692a410fa56e078bdf5b766a2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 014/113] aubio: revbump for ffmpeg6

---
 srcpkgs/aubio/patches/ffmpeg5.patch | 25 +++++++++++++++++++++++++
 srcpkgs/aubio/template              |  2 +-
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/aubio/patches/ffmpeg5.patch

diff --git a/srcpkgs/aubio/patches/ffmpeg5.patch b/srcpkgs/aubio/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..aace41a6e6d9a
--- /dev/null
+++ b/srcpkgs/aubio/patches/ffmpeg5.patch
@@ -0,0 +1,25 @@
+From 8a05420e5dd8c7b8b2447f82dc919765876511b3 Mon Sep 17 00:00:00 2001
+From: Paul Brossier <piem@piem.org>
+Date: Tue, 25 Jan 2022 18:30:27 +0100
+Subject: [PATCH] [source_avcodec] define FF_API_LAVF_AVCTX for libavcodec >
+ 59, thx @berolinux (closes gh-353)
+
+---
+ src/io/source_avcodec.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/io/source_avcodec.c b/src/io/source_avcodec.c
+index e0ae93b5..1421bd9a 100644
+--- a/src/io/source_avcodec.c
++++ b/src/io/source_avcodec.c
+@@ -68,6 +68,10 @@
+ #define AUBIO_AVCODEC_MAX_BUFFER_SIZE AV_INPUT_BUFFER_MIN_SIZE
+ #endif
+ 
++#if LIBAVCODEC_VERSION_MAJOR >= 59
++#define FF_API_LAVF_AVCTX 1
++#endif
++
+ struct _aubio_source_avcodec_t {
+   uint_t hop_size;
+   uint_t samplerate;
diff --git a/srcpkgs/aubio/template b/srcpkgs/aubio/template
index ad1c4b2569917..7d875cc02541a 100644
--- a/srcpkgs/aubio/template
+++ b/srcpkgs/aubio/template
@@ -1,7 +1,7 @@
 # Template file for 'aubio'
 pkgname=aubio
 version=0.4.9
-revision=1
+revision=2
 build_style=waf3
 # XXX lash, pure and swig support.
 hostmakedepends="pkg-config txt2man"

From 93a24c0ff2b7a41f9401113907c6efae58cc2bda Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 015/113] audacious-plugins: revbump for ffmpeg6

---
 .../audacious-plugins/patches/ffmpeg5.patch   | 43 +++++++++++++++++++
 srcpkgs/audacious-plugins/template            |  2 +-
 2 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/audacious-plugins/patches/ffmpeg5.patch

diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg5.patch b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..4e5e34099d71c
--- /dev/null
+++ b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
@@ -0,0 +1,43 @@
+commit 298aa371c56c2f52c25a33d9bdec4918b11cebdc
+Author: tibequadorian <tibequadorian@posteo.de>
+Date:   Sat Mar 19 18:40:12 2022 +0100
+
+    audacious-plugins: rebuild against ffmpeg-5.0
+
+diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+new file mode 100644
+index 0000000000..617c11215b
+--- /dev/null
++++ b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+@@ -0,0 +1,31 @@
++From f60beb400eeb1e4778bbfd738bc4a4ccef3de539 Mon Sep 17 00:00:00 2001
++From: John Lindgren <john@jlindgren.net>
++Date: Sat, 5 Mar 2022 12:05:34 -0500
++Subject: [PATCH] Fix build with FFmpeg 5.0
++
++---
++ src/ffaudio/ffaudio-core.cc | 4 ++--
++ 1 file changed, 2 insertions(+), 2 deletions(-)
++
++diff --git a/src/ffaudio/ffaudio-core.cc b/src/ffaudio/ffaudio-core.cc
++index 16dc63e3a..a2b95fd6c 100644
++--- a/src/ffaudio/ffaudio-core.cc
+++++ b/src/ffaudio/ffaudio-core.cc
++@@ -274,7 +274,7 @@ static AVInputFormat * get_format_by_content (const char * name, VFSFile & file)
++         AVProbeData d = {name, buf, filled};
++         score = target;
++ 
++-        f = av_probe_input_format2 (& d, true, & score);
+++        f = (AVInputFormat *) av_probe_input_format2 (& d, true, & score);
++         if (f)
++             break;
++ 
++@@ -347,7 +347,7 @@ static bool find_codec (AVFormatContext * c, CodecInfo * cinfo)
++ #endif
++         if (stream && stream->codecpar && stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
++         {
++-            AVCodec * codec = avcodec_find_decoder (stream->codecpar->codec_id);
+++            AVCodec * codec = (AVCodec *) avcodec_find_decoder (stream->codecpar->codec_id);
++ 
++             if (codec)
++             {
diff --git a/srcpkgs/audacious-plugins/template b/srcpkgs/audacious-plugins/template
index 05e53a9adf78f..4b1968e03de78 100644
--- a/srcpkgs/audacious-plugins/template
+++ b/srcpkgs/audacious-plugins/template
@@ -2,7 +2,7 @@
 #Keep in sync with audacious!
 pkgname=audacious-plugins
 version=4.3.1
-revision=3
+revision=4
 build_style=meson
 configure_args="$(vopt_bool gtk3 gtk) $(vopt_bool gtk3)
  $(vopt_bool qt) $(vopt_bool qt qt6)"

From a9aa41c552bf3eefe60d24ae2f722f9cc107c5ea Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 016/113] audacity: revbump for ffmpeg4

---
 srcpkgs/audacity/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/audacity/template b/srcpkgs/audacity/template
index 7b838119ab261..fb15f782ac1f7 100644
--- a/srcpkgs/audacity/template
+++ b/srcpkgs/audacity/template
@@ -1,7 +1,7 @@
 # Template file for 'audacity'
 pkgname=audacity
 version=3.4.2
-revision=1
+revision=2
 build_style=cmake
 build_helper="cmake-wxWidgets-gtk3 qemu"
 configure_args="-Daudacity_use_ffmpeg=loaded -Daudacity_lib_preference=system
@@ -12,7 +12,7 @@ configure_args="-Daudacity_use_ffmpeg=loaded -Daudacity_lib_preference=system
  -Daudacity_has_updates_check=OFF -DAUDACITY_BUILD_LEVEL=2"
 hostmakedepends="pkg-config gettext python3"
 makedepends="wxWidgets-gtk3-devel gtk+3-devel expat-devel lame-devel
- libsoxr-devel portaudio-devel sqlite-devel ffmpeg-devel
+ libsoxr-devel portaudio-devel sqlite-devel ffmpeg4-devel
  libid3tag-devel libmad-devel vamp-plugin-sdk-devel libogg-devel
  libvorbis-devel libflac-devel lilv-devel lv2 serd-devel sord-devel
  sratom-devel suil-devel portmidi-devel soundtouch-devel twolame-devel

From d20e5d14129485f6a766ad3c54eec18541eb8125 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 017/113] avidemux: revbump for ffmpeg6

---
 srcpkgs/avidemux/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/avidemux/template b/srcpkgs/avidemux/template
index 253a0243e2259..557285982d2b8 100644
--- a/srcpkgs/avidemux/template
+++ b/srcpkgs/avidemux/template
@@ -1,7 +1,7 @@
 # Template file for 'avidemux'
 pkgname=avidemux
 version=2.8.0
-revision=2
+revision=3
 # Can't be compiled for aarch64, arm* or mips*
 archs="x86_64* i686*"
 hostmakedepends="cmake pkg-config qt5-host-tools qt5-devel tar yasm"

From 81316c081add2115e4da8170c683a9992205354d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 018/113] blender: revbump for ffmpeg6

---
 srcpkgs/blender/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index 05fdbf8f747e2..093d6d2004e95 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -9,8 +9,8 @@ configure_args="-DWITH_INSTALL_PORTABLE=OFF -DWITH_PYTHON_INSTALL=OFF
  -DWITH_JACK=ON -DWITH_CODEC_FFMPEG=ON -DWITH_CODEC_SNDFILE=ON -DWITH_OPENMP=ON
  -DWITH_FFTW3=ON -DWITH_MOD_OCEANSIM=ON -DWITH_CYCLES_EMBREE=OFF -DWITH_OPENCOLORIO=ON
  -DWITH_IMAGE_OPENEXR=ON -DWITH_IMAGE_OPENJPEG=ON -DWITH_OPENSUBDIV=ON
- -DWITH_OPENCOLLADA=ON -DWITH_SYSTEM_GLEW=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
- -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_LIBDECOR=ON
+ -DWITH_OPENCOLLADA=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
+ -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_WAYLAND_LIBDECOR=ON
  -DWITH_BUILDINFO=OFF -DPYTHON_VERSION=${py3_ver} -DPYTHON_LIBPATH=/usr/lib
  -DPYTHON_LIBRARY=python${py3_ver}${py3_abiver} -DPYTHON_INCLUDE_DIRS=/${py3_inc}
  -DWITH_SYSTEM_LZO=ON -DWITH_SYSTEM_EIGEN3=ON -DWITH_SYSTEM_FREETYPE=ON"

From e8f2baf8b044cebfff3bc1fd3cc6018ab9c2d4eb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 019/113] cantata: revbump for ffmpeg6

---
 srcpkgs/cantata/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cantata/template b/srcpkgs/cantata/template
index 4b417d80d5c2d..8a90aaa4c07a2 100644
--- a/srcpkgs/cantata/template
+++ b/srcpkgs/cantata/template
@@ -1,7 +1,7 @@
 # Template file for 'cantata'
 pkgname=cantata
 version=2.5.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools qt5-tools"
 makedepends="qt5-devel qt5-tools-devel qt5-svg-devel qt5-xmlpatterns-devel

From e57403a498a82b4c027073b2753f86788ccf12b1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 020/113] ccextractor: revbump for ffmpeg4

---
 srcpkgs/ccextractor/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/ccextractor/template b/srcpkgs/ccextractor/template
index 9abcd82852b27..6eccad5885af9 100644
--- a/srcpkgs/ccextractor/template
+++ b/srcpkgs/ccextractor/template
@@ -1,12 +1,12 @@
 # Template file for 'ccextractor'
 pkgname=ccextractor
 version=0.93
-revision=1
+revision=2
 build_wrksrc="linux"
 build_style=gnu-configure
 configure_args="--enable-ocr --enable-hardsubx"
 hostmakedepends="automake pkg-config"
-makedepends="leptonica-devel tesseract-ocr-devel ffmpeg-devel"
+makedepends="leptonica-devel tesseract-ocr-devel ffmpeg4-devel"
 short_desc="Extract subtitles from video streams"
 maintainer="newbluemoon <blaumolch@mailbox.org>"
 license="GPL-2.0-or-later"

From ce4474bde6f78324eef8cfa18b24887f2145f32a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 021/113] chromaprint: revbump for ffmpeg6

---
 srcpkgs/chromaprint/patches/ffmpeg5.patch | 569 ++++++++++++++++++++++
 srcpkgs/chromaprint/template              |   2 +-
 2 files changed, 570 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromaprint/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromaprint/patches/ffmpeg5.patch b/srcpkgs/chromaprint/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..a9fd307a23c8a
--- /dev/null
+++ b/srcpkgs/chromaprint/patches/ffmpeg5.patch
@@ -0,0 +1,569 @@
+From 8ccad6937177b1b92e40ab8f4447ea27bac009a7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= <lalinsky@gmail.com>
+Date: Fri, 4 Nov 2022 21:47:38 +0100
+Subject: [PATCH] Use FFmpeg 5.x (#120)
+
+* Use FFmpeg 5.1.2 for CI builds
+
+* Build on Ubuntu 20.04
+
+* Upgrade code to FFmpeg 5.x APIs
+
+* Only set FFmpeg include dirs if building tools
+
+* No longer needed
+
+* Use ubuntu 20.04
+---
+ .github/workflows/build.yml                   |   6 +-
+ CMakeLists.txt                                |  16 --
+ package/build.sh                              |   4 +-
+ src/audio/ffmpeg_audio_processor.h            |   2 -
+ src/audio/ffmpeg_audio_processor_avresample.h |  72 -------
+ src/audio/ffmpeg_audio_processor_swresample.h |  18 +-
+ src/audio/ffmpeg_audio_reader.h               | 197 +++++++++---------
+ tests/CMakeLists.txt                          |   6 +
+ 8 files changed, 122 insertions(+), 199 deletions(-)
+ delete mode 100644 src/audio/ffmpeg_audio_processor_avresample.h
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index f8d6a32..4da2405 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -84,9 +84,6 @@ find_package(FFmpeg)
+ if(FFMPEG_LIBRARIES)
+ 	cmake_push_check_state(RESET)
+ 	set(CMAKE_REQUIRED_LIBRARIES ${FFMPEG_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -lm)
+-	check_function_exists(av_packet_unref HAVE_AV_PACKET_UNREF)
+-	check_function_exists(av_frame_alloc HAVE_AV_FRAME_ALLOC)
+-	check_function_exists(av_frame_free HAVE_AV_FRAME_FREE)
+ 	cmake_pop_check_state()
+ endif()
+
+@@ -163,14 +160,11 @@ message(STATUS "Using ${FFT_LIB} for FFT calculations")
+ if(NOT AUDIO_PROCESSOR_LIB)
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+ 		set(AUDIO_PROCESSOR_LIB "swresample")
+-	elseif(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(AUDIO_PROCESSOR_LIB "avresample")
+ 	endif()
+ endif()
+
+ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE OFF)
+ 		set(USE_SWRESAMPLE ON)
+ 		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBSWRESAMPLE_LIBRARIES})
+ 		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBSWRESAMPLE_INCLUDE_DIRS})
+@@ -178,16 +172,6 @@ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+ 	endif()
+ 	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+-elseif(AUDIO_PROCESSOR_LIB STREQUAL "avresample")
+-	if(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE ON)
+-		set(USE_SWRESAMPLE OFF)
+-		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBAVRESAMPLE_LIBRARIES})
+-		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBAVRESAMPLE_INCLUDE_DIRS})
+-	else()
+-		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+-	endif()
+-	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+ else()
+ 	message(STATUS "Building without audio conversion support, please install FFmpeg with libswresample")
+ endif()
+diff --git a/package/build.sh b/package/build.sh
+index da631ae..b41d36e 100755
+--- a/package/build.sh
++++ b/package/build.sh
+@@ -7,8 +7,8 @@ set -eux
+
+ BASE_DIR=$(cd $(dirname $0)/.. && pwd)
+
+-FFMPEG_VERSION=4.4.1
+-FFMPEG_BUILD_TAG=v4.4.1-1
++FFMPEG_VERSION=5.1.2
++FFMPEG_BUILD_TAG=v${FFMPEG_VERSION}-1
+
+ TMP_BUILD_DIR=$BASE_DIR/$(mktemp -d build.XXXXXXXX)
+ trap 'rm -rf $TMP_BUILD_DIR' EXIT
+diff --git a/src/audio/ffmpeg_audio_processor.h b/src/audio/ffmpeg_audio_processor.h
+index 7628fc7..39f4f6d 100644
+--- a/src/audio/ffmpeg_audio_processor.h
++++ b/src/audio/ffmpeg_audio_processor.h
+@@ -10,8 +10,6 @@
+
+ #if defined(USE_SWRESAMPLE)
+ #include "audio/ffmpeg_audio_processor_swresample.h"
+-#elif defined(USE_AVRESAMPLE)
+-#include "audio/ffmpeg_audio_processor_avresample.h"
+ #else
+ #error "no audio processing library"
+ #endif
+diff --git a/src/audio/ffmpeg_audio_processor_avresample.h b/src/audio/ffmpeg_audio_processor_avresample.h
+deleted file mode 100644
+index bd85f92..0000000
+--- a/src/audio/ffmpeg_audio_processor_avresample.h
++++ /dev/null
+@@ -1,72 +0,0 @@
+-// Copyright (C) 2016  Lukas Lalinsky
+-// Distributed under the MIT license, see the LICENSE file for details.
+-
+-#ifndef CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-#define CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-
+-extern "C" {
+-#include <libavresample/avresample.h>
+-}
+-
+-namespace chromaprint {
+-
+-class FFmpegAudioProcessor {
+-public:
+-	FFmpegAudioProcessor() {
+-		m_resample_ctx = avresample_alloc_context();
+-	}
+-
+-	~FFmpegAudioProcessor() {
+-		avresample_free(&m_resample_ctx);
+-	}
+-
+-	void SetCompatibleMode() {
+-		av_opt_set_int(m_resample_ctx, "filter_size", 16, 0);
+-		av_opt_set_int(m_resample_ctx, "phase_shift", 8, 0);
+-		av_opt_set_int(m_resample_ctx, "linear_interp", 1, 0);
+-		av_opt_set_double(m_resample_ctx, "cutoff", 0.8, 0);
+-	}
+-
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "in_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_rate", sample_rate, 0);
+-	}
+-
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "out_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_rate, 0);
+-	}
+-
+-	int Init() {
+-		return avresample_open(m_resample_ctx);
+-	}
+-
+-	int Convert(uint8_t **out, int out_count, const uint8_t **in, int in_count) {
+-		return avresample_convert(m_resample_ctx, out, 0, out_count, (uint8_t **) in, 0, in_count);
+-	}
+-
+-	int Flush(uint8_t **out, int out_count) {
+-		return avresample_read(m_resample_ctx, out, out_count);
+-	}
+-
+-private:
+-	AVAudioResampleContext *m_resample_ctx = nullptr;
+-};
+-
+-}; // namespace chromaprint
+-
+-#endif
+diff --git a/src/audio/ffmpeg_audio_processor_swresample.h b/src/audio/ffmpeg_audio_processor_swresample.h
+index b86266b..b1d4bea 100644
+--- a/src/audio/ffmpeg_audio_processor_swresample.h
++++ b/src/audio/ffmpeg_audio_processor_swresample.h
+@@ -28,30 +28,28 @@ public:
+ 		av_opt_set_double(m_swr_ctx, "cutoff", 0.8, 0);
+ 	}
+
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "icl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "ich", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetInputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "in_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "isf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "in_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "isr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "in_sample_rate", sample_rate, 0);
+ 	}
+
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "ocl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "och", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetOutputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "out_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "osf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "out_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "osr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "out_sample_rate", sample_rate, 0);
+ 	}
+
+ 	int Init() {
+diff --git a/src/audio/ffmpeg_audio_reader.h b/src/audio/ffmpeg_audio_reader.h
+index 5550164..1c6b346 100644
+--- a/src/audio/ffmpeg_audio_reader.h
++++ b/src/audio/ffmpeg_audio_reader.h
+@@ -62,7 +62,7 @@ public:
+ 	bool Read(const int16_t **data, size_t *size);
+
+ 	bool IsOpen() const { return m_opened; }
+-	bool IsFinished() const { return m_finished && !m_got_frame; }
++	bool IsFinished() const { return !m_has_more_packets && !m_has_more_frames; }
+
+ 	std::string GetError() const { return m_error; }
+ 	int GetErrorCode() const { return m_error_code; }
+@@ -74,20 +74,19 @@ private:
+ 	uint8_t *m_convert_buffer[1] = { nullptr };
+ 	int m_convert_buffer_nb_samples = 0;
+
+-	AVInputFormat *m_input_fmt = nullptr;
++	const AVInputFormat *m_input_fmt = nullptr;
+ 	AVDictionary *m_input_opts = nullptr;
+
+ 	AVFormatContext *m_format_ctx = nullptr;
+ 	AVCodecContext *m_codec_ctx = nullptr;
+-	AVFrame *m_frame = nullptr;
+ 	int m_stream_index = -1;
+ 	std::string m_error;
+ 	int m_error_code = 0;
+-	bool m_finished = false;
+ 	bool m_opened = false;
+-	int m_got_frame = 0;
+-	AVPacket m_packet;
+-	AVPacket m_packet0;
++	bool m_has_more_packets = true;
++	bool m_has_more_frames = true;
++	AVPacket *m_packet = nullptr;
++	AVFrame *m_frame = nullptr;
+
+ 	int m_output_sample_rate = 0;
+ 	int m_output_channels = 0;
+@@ -98,19 +97,12 @@ private:
+
+ inline FFmpegAudioReader::FFmpegAudioReader() {
+ 	av_log_set_level(AV_LOG_QUIET);
+-
+-	av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
+ }
+
+ inline FFmpegAudioReader::~FFmpegAudioReader() {
+ 	Close();
+ 	av_dict_free(&m_input_opts);
+ 	av_freep(&m_convert_buffer[0]);
+-	av_packet_unref(&m_packet0);
+ }
+
+ inline bool FFmpegAudioReader::SetInputFormat(const char *name) {
+@@ -135,11 +127,10 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ 	Close();
+
+-    av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
++	m_packet = av_packet_alloc();
++	if (!m_packet) {
++		return false;
++	}
+
+ 	ret = avformat_open_input(&m_format_ctx, file_name.c_str(), m_input_fmt, &m_input_opts);
+ 	if (ret < 0) {
+@@ -153,26 +144,31 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		return false;
+ 	}
+
+-	AVCodec *codec;
++	const AVCodec *codec;
+ 	ret = av_find_best_stream(m_format_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &codec, 0);
+ 	if (ret < 0) {
+ 		SetError("Could not find any audio stream in the file", ret);
+ 		return false;
+ 	}
+ 	m_stream_index = ret;
++	auto stream = m_format_ctx->streams[m_stream_index];
+
+-	m_codec_ctx = m_format_ctx->streams[m_stream_index]->codec;
++	m_codec_ctx = avcodec_alloc_context3(codec);
+ 	m_codec_ctx->request_sample_fmt = AV_SAMPLE_FMT_S16;
+
++	ret = avcodec_parameters_to_context(m_codec_ctx, stream->codecpar);
++	if (ret < 0) {
++		SetError("Could not copy the stream parameters", ret);
++		return false;
++	}
++
+ 	ret = avcodec_open2(m_codec_ctx, codec, nullptr);
+ 	if (ret < 0) {
+ 		SetError("Could not open the codec", ret);
+ 		return false;
+ 	}
+
+-	if (!m_codec_ctx->channel_layout) {
+-		m_codec_ctx->channel_layout = av_get_default_channel_layout(m_codec_ctx->channels);
+-	}
++	av_dump_format(m_format_ctx, 0, "foo", 0);
+
+ 	m_frame = av_frame_alloc();
+ 	if (!m_frame) {
+@@ -183,19 +179,23 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		m_output_sample_rate = m_codec_ctx->sample_rate;
+ 	}
+
+-	if (!m_output_channels) {
+-		m_output_channels = m_codec_ctx->channels;
++	AVChannelLayout output_channel_layout;
++	if (m_output_channels) {
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
++	} else {
++		m_output_channels = m_codec_ctx->ch_layout.nb_channels;
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
+ 	}
+
+-	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
++	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->ch_layout.nb_channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
+ 		m_converter.reset(new FFmpegAudioProcessor());
+ 		m_converter->SetCompatibleMode();
+ 		m_converter->SetInputSampleFormat(m_codec_ctx->sample_fmt);
+ 		m_converter->SetInputSampleRate(m_codec_ctx->sample_rate);
+-		m_converter->SetInputChannelLayout(m_codec_ctx->channel_layout);
++		m_converter->SetInputChannelLayout(&(m_codec_ctx->ch_layout));
+ 		m_converter->SetOutputSampleFormat(AV_SAMPLE_FMT_S16);
+ 		m_converter->SetOutputSampleRate(m_output_sample_rate);
+-		m_converter->SetOutputChannelLayout(av_get_default_channel_layout(m_output_channels));
++		m_converter->SetOutputChannelLayout(&output_channel_layout);
+ 		auto ret = m_converter->Init();
+ 		if (ret != 0) {
+ 			SetError("Could not create an audio converter instance", ret);
+@@ -203,10 +203,11 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		}
+ 	}
+
++	av_channel_layout_uninit(&output_channel_layout);
++
+ 	m_opened = true;
+-	m_finished = false;
+-	m_got_frame = 0;
+-	m_nb_packets = 0;
++	m_has_more_packets = true;
++	m_has_more_frames = true;
+ 	m_decode_error = 0;
+
+ 	return true;
+@@ -214,6 +215,7 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ inline void FFmpegAudioReader::Close() {
+ 	av_frame_free(&m_frame);
++	av_packet_free(&m_packet);
+
+ 	m_stream_index = -1;
+
+@@ -252,91 +254,98 @@ inline bool FFmpegAudioReader::Read(const int16_t **data, size_t *size) {
+ 		return false;
+ 	}
+
++	*data = nullptr;
++	*size = 0;
++
+ 	int ret;
++	bool needs_packet = false;
+ 	while (true) {
+-		while (m_packet.size <= 0) {
+-			av_packet_unref(&m_packet0);
+-			av_init_packet(&m_packet);
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			ret = av_read_frame(m_format_ctx, &m_packet);
++		while (needs_packet && m_packet->size == 0) {
++			ret = av_read_frame(m_format_ctx, m_packet);
+ 			if (ret < 0) {
+ 				if (ret == AVERROR_EOF) {
+-					m_finished = true;
++					needs_packet = false;
++					m_has_more_packets = false;
+ 					break;
+-				} else {
++				}
++				SetError("Error reading from the audio source", ret);
++				return false;
++			}
++			if (m_packet->stream_index == m_stream_index) {
++				needs_packet = false;
++			} else {
++				av_packet_unref(m_packet);
++			}
++		}
++
++		if (m_packet->size != 0) {
++			ret = avcodec_send_packet(m_codec_ctx, m_packet);
++			if (ret < 0) {
++				if (ret != AVERROR(EAGAIN)) {
+ 					SetError("Error reading from the audio source", ret);
+ 					return false;
+ 				}
+-			}
+-			m_packet0 = m_packet;
+-			if (m_packet.stream_index != m_stream_index) {
+-				m_packet.data = nullptr;
+-				m_packet.size = 0;
+ 			} else {
+-				m_nb_packets++;
++				av_packet_unref(m_packet);
+ 			}
+ 		}
+
+-		ret = avcodec_decode_audio4(m_codec_ctx, m_frame, &m_got_frame, &m_packet);
++		ret = avcodec_receive_frame(m_codec_ctx, m_frame);
+ 		if (ret < 0) {
+-			if (m_decode_error) {
+-				SetError("Error decoding audio frame", m_decode_error);
+-				return false;
++			if (ret == AVERROR_EOF) {
++				m_has_more_frames = false;
++			} else if (ret == AVERROR(EAGAIN)) {
++				if (m_has_more_packets) {
++					needs_packet = true;
++					continue;
++				} else {
++					m_has_more_frames = false;
++				}
+ 			}
+-			m_decode_error = ret;
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			continue;
++			SetError("Error decoding the audio source", ret);
++			return false;
+ 		}
+
+-		break;
+-	}
+-
+-	m_decode_error = 0;
+-
+-	const int decoded = std::min(ret, m_packet.size);
+-	m_packet.data += decoded;
+-	m_packet.size -= decoded;
+-
+-	if (m_got_frame) {
+-		if (m_converter) {
+-			if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
+-				int linsize;
+-				av_freep(&m_convert_buffer[0]);
+-				m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
+-				ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
+-				if (ret < 0) {
+-					SetError("Couldn't allocate audio converter buffer", ret);
++		if (m_frame->nb_samples > 0) {
++			if (m_converter) {
++				if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
++					int linsize;
++					av_freep(&m_convert_buffer[0]);
++					m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
++					ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->ch_layout.nb_channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
++					if (ret < 0) {
++						SetError("Couldn't allocate audio converter buffer", ret);
++						return false;
++					}
++				}
++				auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
++				if (nb_samples < 0) {
++					SetError("Couldn't convert audio", ret);
+ 					return false;
+ 				}
+-			}
+-			auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			}
+-			*data = (const int16_t *) m_convert_buffer[0];
+-			*size = nb_samples;
+-		} else {
+-			*data = (const int16_t *) m_frame->data[0];
+-			*size = m_frame->nb_samples;
+-		}
+-	} else {
+-		if (m_finished && m_converter) {
+-			auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			} else if (nb_samples > 0) {
+-				m_got_frame = 1;
+ 				*data = (const int16_t *) m_convert_buffer[0];
+ 				*size = nb_samples;
++			} else {
++				*data = (const int16_t *) m_frame->data[0];
++				*size = m_frame->nb_samples;
++			}
++		} else {
++			if (m_converter) {
++				if (IsFinished()) {
++					auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
++					if (nb_samples < 0) {
++						SetError("Couldn't convert audio", ret);
++						return false;
++					} else if (nb_samples > 0) {
++						*data = (const int16_t *) m_convert_buffer[0];
++						*size = nb_samples;
++					}
++				}
+ 			}
+ 		}
+-	}
+
+-	return true;
++		return true;
++	}
+ }
+
+ inline void FFmpegAudioReader::SetError(const char *message, int errnum) {
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index a2b517b..123e643 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -38,6 +38,12 @@ set(SRCS
+
+ if(BUILD_TOOLS)
+ 	set(SRCS ${SRCS} ../src/audio/ffmpeg_audio_reader_test.cpp)
++    include_directories(
++        ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}
++        ${AUDIO_PROCESSOR_INCLUDE_DIRS}
++    )
+ 	link_libraries(fpcalc_libs)
+ endif()
+
+-- 
+2.38.1
+
+
diff --git a/srcpkgs/chromaprint/template b/srcpkgs/chromaprint/template
index 7ef7838949f3a..1f7bbc70a22c8 100644
--- a/srcpkgs/chromaprint/template
+++ b/srcpkgs/chromaprint/template
@@ -1,7 +1,7 @@
 # Template file for 'chromaprint'
 pkgname=chromaprint
 version=1.5.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DBUILD_TOOLS=ON"
 make_check_target="check"

From da677ef20f3b481bed33d1ff92fbd6b7b2710ac9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 022/113] chromium: revbump for ffmpeg6

---
 .../patches/chromium-119-ffmpeg-4.4.patch     | 20 --------
 srcpkgs/chromium/patches/ffmpeg5.patch        | 47 +++++++++++++++++++
 srcpkgs/chromium/template                     |  2 +-
 3 files changed, 48 insertions(+), 21 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch
 create mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch b/srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch
deleted file mode 100644
index 04d04b166ba37..0000000000000
--- a/srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch
+++ /dev/null
@@ -1,20 +0,0 @@
---- a/media/filters/ffmpeg_demuxer.cc.orig
-+++ b/media/filters/ffmpeg_demuxer.cc
-@@ -390,7 +390,7 @@
- 
-   scoped_refptr<DecoderBuffer> buffer;
- 
--    size_t side_data_size = 0;
-+    int side_data_size = 0;
-     uint8_t* side_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
- 
-@@ -453,7 +453,7 @@
-                                        packet->size - data_offset);
-     }
- 
--    size_t skip_samples_size = 0;
-+    int skip_samples_size = 0;
-     const uint32_t* skip_samples_ptr =
-         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
-             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..24e2da38e34ca
--- /dev/null
+++ b/srcpkgs/chromium/patches/ffmpeg5.patch
@@ -0,0 +1,47 @@
+--- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
++++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
+@@ -92,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+-  if (stream->start_time != kNoFFmpegTimestamp)
++  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -1597,7 +1585,7 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+@@ -1618,7 +1606,7 @@
+     if (stream->type() != DemuxerStream::VIDEO)
+       continue;
+ 
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+ 
+     if (!stream->IsEnabled())
diff --git a/srcpkgs/chromium/template b/srcpkgs/chromium/template
index 5613fa3813822..cd386c8a84ae6 100644
--- a/srcpkgs/chromium/template
+++ b/srcpkgs/chromium/template
@@ -2,7 +2,7 @@
 pkgname=chromium
 # See https://chromiumdash.appspot.com/releases?platform=Linux for the latest version
 version=120.0.6099.129
-revision=1
+revision=2
 archs="i686* x86_64* aarch64* armv7l*"
 hostmakedepends="
  $(vopt_if clang "clang lld llvm15")

From 0851c23dd973b36941a9e3a482fcf10e73d3edd8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 023/113] cmus: revbump for ffmpeg6

---
 srcpkgs/chromium/patches/ffmpeg5.patch | 47 --------------------------
 srcpkgs/cmus/patches/ffmpeg6.patch     | 12 +++++++
 srcpkgs/cmus/template                  |  2 +-
 3 files changed, 13 insertions(+), 48 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch
 create mode 100644 srcpkgs/cmus/patches/ffmpeg6.patch

diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
deleted file mode 100644
index 24e2da38e34ca..0000000000000
--- a/srcpkgs/chromium/patches/ffmpeg5.patch
+++ /dev/null
@@ -1,47 +0,0 @@
---- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
-+++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
-@@ -92,24 +92,12 @@
- 
- static base::TimeDelta ExtractStartTime(AVStream* stream) {
-   // The default start time is zero.
--  base::TimeDelta start_time;
-+  base::TimeDelta start_time = kNoTimestamp;
- 
-   // First try to use  the |start_time| value as is.
--  if (stream->start_time != kNoFFmpegTimestamp)
-+  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
-     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
- 
--  // Next try to use the first DTS value, for codecs where we know PTS == DTS
--  // (excludes all H26x codecs). The start time must be returned in PTS.
--  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
--      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
--      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
--      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
--    const base::TimeDelta first_pts =
--        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
--    if (first_pts < start_time)
--      start_time = first_pts;
--  }
--
-   return start_time;
- }
- 
-@@ -1597,7 +1585,7 @@
-   for (const auto& stream : streams_) {
-     if (!stream || stream->IsEnabled() != enabled)
-       continue;
--    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
-+    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
-       continue;
-     if (!lowest_start_time_stream ||
-         stream->start_time() < lowest_start_time_stream->start_time()) {
-@@ -1618,7 +1606,7 @@
-     if (stream->type() != DemuxerStream::VIDEO)
-       continue;
- 
--    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
-+    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
-       continue;
- 
-     if (!stream->IsEnabled())
diff --git a/srcpkgs/cmus/patches/ffmpeg6.patch b/srcpkgs/cmus/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..ffa95ab811101
--- /dev/null
+++ b/srcpkgs/cmus/patches/ffmpeg6.patch
@@ -0,0 +1,12 @@
+--- a/ip/ffmpeg.c
++++ b/ip/ffmpeg.c
+@@ -202,9 +202,6 @@ static int ffmpeg_open(struct input_plugin_data *ip_data)
+ 			break;
+ 		}
+ 
+-		if (codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+-			cc->flags |= AV_CODEC_FLAG_TRUNCATED;
+-
+ 		if (avcodec_open2(cc, codec, NULL) < 0) {
+ 			d_print("could not open codec: %d, %s\n", cc->codec_id, avcodec_get_name(cc->codec_id));
+ 			err = -IP_ERROR_UNSUPPORTED_FILE_TYPE;
diff --git a/srcpkgs/cmus/template b/srcpkgs/cmus/template
index 0d1436744f1b2..a6e4b4fa86cb8 100644
--- a/srcpkgs/cmus/template
+++ b/srcpkgs/cmus/template
@@ -1,7 +1,7 @@
 # Template file for 'cmus'
 pkgname=cmus
 version=2.10.0
-revision=3
+revision=4
 build_style=configure
 configure_args="prefix=/usr LD=$CC"
 hostmakedepends="pkg-config"

From a6363da116f2b2fbc890ff415125a57c4baf48ff Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 024/113] cyanrip: revbump for ffmpeg6

---
 srcpkgs/cyanrip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cyanrip/template b/srcpkgs/cyanrip/template
index 9796e3461601a..5db30e020d17e 100644
--- a/srcpkgs/cyanrip/template
+++ b/srcpkgs/cyanrip/template
@@ -1,7 +1,7 @@
 # Template file for 'cyanrip'
 pkgname=cyanrip
 version=0.9.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config"
 makedepends="ffmpeg-devel libcdio-devel libcdio-paranoia-devel libcurl-devel libmusicbrainz5-devel"

From e1d4e0e1080cd027c1addc649f40e6a91f87cae8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 025/113] deadbeef: revbump for ffmpeg4

---
 srcpkgs/deadbeef/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/deadbeef/template b/srcpkgs/deadbeef/template
index f5f4bf24b8cb6..7b47e615cd48e 100644
--- a/srcpkgs/deadbeef/template
+++ b/srcpkgs/deadbeef/template
@@ -1,14 +1,14 @@
 # Template file for 'deadbeef'
 pkgname=deadbeef
 version=1.8.8
-revision=3
+revision=4
 create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-oss --disable-lfm --disable-notify --disable-gtk2"
 hostmakedepends="automake libtool gettext gettext-devel intltool pkg-config
  yasm clang glib-devel"
 makedepends="
- alsa-lib-devel dbus-devel faad2-devel ffmpeg-devel gtk+3-devel imlib2-devel
+ alsa-lib-devel dbus-devel faad2-devel ffmpeg4-devel gtk+3-devel imlib2-devel
  jansson-devel libcddb-devel libcdio-devel libcurl-devel libflac-devel
  libmad-devel libpng-devel libsamplerate-devel libsndfile-devel libvorbis-devel
  libzip-devel mpg123-devel opusfile-devel pulseaudio-devel wavpack-devel"

From fbad7db56a3cb763684f755272e57dd22b02c69e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 026/113] droidcam-obs-plugin: revbump for ffmpeg6

---
 srcpkgs/droidcam-obs-plugin/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam-obs-plugin/template b/srcpkgs/droidcam-obs-plugin/template
index fc9c9bf6b9d54..fb0480754df4d 100644
--- a/srcpkgs/droidcam-obs-plugin/template
+++ b/srcpkgs/droidcam-obs-plugin/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam-obs-plugin'
 pkgname=droidcam-obs-plugin
 version=2.0.1
-revision=1
+revision=2
 build_style=gnu-makefile
 make_use_env=yes
 make_build_args="ALLOW_STATIC=no"

From c09f0da5b7eb2104bc8d72ff24bc8b2fb6d17a22 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 027/113] droidcam: revbump for ffmpeg6

---
 srcpkgs/droidcam/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam/template b/srcpkgs/droidcam/template
index 1c3f1b8b1fc67..32a9220b79a4d 100644
--- a/srcpkgs/droidcam/template
+++ b/srcpkgs/droidcam/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam'
 pkgname=droidcam
 version=1.8.2
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="USBMUXD=-lusbmuxd-2.0 JPEG=-lturbojpeg"
 hostmakedepends="pkg-config"

From bbf3945c913344ba8b2f2376aa576c83616a4cc8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 028/113] ffmpegthumbnailer: revbump for ffmpeg6

---
 .../ffmpegthumbnailer/patches/ffmpeg6.patch   | 202 ++++++++++++++++++
 srcpkgs/ffmpegthumbnailer/template            |   6 +-
 2 files changed, 205 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch

diff --git a/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..363ff35a28419
--- /dev/null
+++ b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
@@ -0,0 +1,202 @@
+--- a/libffmpegthumbnailer/moviedecoder.cpp	2017-11-21 14:06:57.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.cpp	2023-05-05 13:14:47.946560668 -0400
+@@ -41,11 +41,6 @@
+ namespace ffmpegthumbnailer
+ {
+ 
+-struct SilenceLogLevel
+-{
+-    SilenceLogLevel() { av_log_set_level(AV_LOG_QUIET); }
+-};
+-
+ MovieDecoder::MovieDecoder(AVFormatContext* pavContext)
+ : m_VideoStream(-1)
+ , m_pFormatContext(pavContext)
+@@ -70,8 +65,6 @@
+ 
+ void MovieDecoder::initialize(const string& filename, bool preferEmbeddedMetadata)
+ {
+-    av_register_all();
+-    avcodec_register_all();
+     avformat_network_init();
+ 
+     string inputFile = filename == "-" ? "pipe:" : filename;
+@@ -97,8 +90,7 @@
+ {
+     if (m_pVideoCodecContext)
+     {
+-        avcodec_close(m_pVideoCodecContext);
+-        m_pVideoCodecContext = nullptr;
++        avcodec_free_context(&m_pVideoCodecContext);
+     }
+ 
+     if ((!m_FormatContextWasGiven) && m_pFormatContext)
+@@ -152,10 +144,10 @@
+     for (unsigned int i = 0; i < m_pFormatContext->nb_streams; ++i)
+     {
+         AVStream *stream = m_pFormatContext->streams[i];
+-        auto ctx = m_pFormatContext->streams[i]->codec;
+-        if (ctx->codec_type == AVMEDIA_TYPE_VIDEO)
++        auto par = m_pFormatContext->streams[i]->codecpar;
++        if (par->codec_type == AVMEDIA_TYPE_VIDEO)
+         {
+-            if (!preferEmbeddedMetadata || !isStillImageCodec(ctx->codec_id))
++            if (!preferEmbeddedMetadata || !isStillImageCodec(par->codec_id))
+             {
+                 videoStreams.push_back(i);
+                 continue;
+@@ -203,8 +195,7 @@
+     }
+ 
+     m_pVideoStream = m_pFormatContext->streams[m_VideoStream];
+-    m_pVideoCodecContext = m_pVideoStream->codec;
+-    m_pVideoCodec = avcodec_find_decoder(m_pVideoCodecContext->codec_id);
++    m_pVideoCodec = avcodec_find_decoder(m_pVideoStream->codecpar->codec_id);
+ 
+     if (m_pVideoCodec == nullptr)
+     {
+@@ -214,6 +205,20 @@
+         throw logic_error("Video Codec not found");
+     }
+ 
++    m_pVideoCodecContext = avcodec_alloc_context3(m_pVideoCodec);
++
++    if (m_pVideoCodecContext == nullptr)
++    {
++        destroy();
++        throw logic_error("Could not allocate video codec context");
++    }
++
++    if (avcodec_parameters_to_context(m_pVideoCodecContext, m_pVideoStream->codecpar) < 0)
++    {
++        destroy();
++        throw logic_error("Could not configure video codec context");
++    }
++
+     m_pVideoCodecContext->workaround_bugs = 1;
+ 
+     if (avcodec_open2(m_pVideoCodecContext, m_pVideoCodec, nullptr) < 0)
+@@ -386,13 +391,6 @@
+ 
+ void MovieDecoder::initializeFilterGraph(const AVRational& timeBase, const std::string& size, bool maintainAspectRatio)
+ {
+-    static const AVPixelFormat pixelFormats[] = { AV_PIX_FMT_RGB24, AV_PIX_FMT_NONE };
+-
+-    auto del = [] (AVBufferSinkParams* p) { av_freep(p); };
+-    std::unique_ptr<AVBufferSinkParams, decltype(del)> buffersinkParams(av_buffersink_params_alloc(), del);
+-
+-    avfilter_register_all();
+-
+     m_pFilterGraph = avfilter_graph_alloc();
+     assert(m_pFilterGraph);
+ 
+@@ -404,10 +402,8 @@
+ 
+     checkRc(avfilter_graph_create_filter(&m_pFilterSource, avfilter_get_by_name("buffer"), "thumb_buffer", ss.str().c_str(), nullptr, m_pFilterGraph),
+             "Failed to create filter source");
+-    buffersinkParams->pixel_fmts = pixelFormats;
+-    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, buffersinkParams.get(), m_pFilterGraph),
++    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, nullptr, m_pFilterGraph),
+             "Failed to create filter sink");
+-    buffersinkParams.release();
+ 
+     AVFilterContext* yadifFilter = nullptr;
+     if (m_pFrame->interlaced_frame != 0)
+@@ -500,15 +496,15 @@
+     }
+ 
+     checkRc(av_seek_frame(m_pFormatContext, -1, timestamp, 0), "Seeking in video failed");
+-    avcodec_flush_buffers(m_pFormatContext->streams[m_VideoStream]->codec);
++    avcodec_flush_buffers(m_pVideoCodecContext);
+ 
+     int keyFrameAttempts = 0;
+-    bool gotFrame = 0;
++    bool gotFrame;
+ 
+     do
+     {
+         int count = 0;
+-        gotFrame = 0;
++        gotFrame = false;
+ 
+         while (!gotFrame && count < 20)
+         {
+@@ -552,17 +548,33 @@
+         return false;
+     }
+ 
+-    av_frame_unref(m_pFrame);
+-
+-    int frameFinished;
++    int rc = avcodec_send_packet(m_pVideoCodecContext, m_pPacket);
++    if(rc == AVERROR(EAGAIN))
++    {
++        rc = 0;
++    }
+ 
+-    int bytesDecoded = avcodec_decode_video2(m_pVideoCodecContext, m_pFrame, &frameFinished, m_pPacket);
+-    if (bytesDecoded < 0)
++    if(rc == AVERROR_EOF)
++    {
++        return false;
++    }
++    else if(rc < 0)
+     {
+-        throw logic_error("Failed to decode video frame: bytesDecoded < 0");
++        throw logic_error("Failed to decode video frame: avcodec_send_packet() < 0");
+     }
+ 
+-    return frameFinished > 0;
++    rc = avcodec_receive_frame(m_pVideoCodecContext, m_pFrame);
++    switch(rc)
++    {
++        case 0:
++            return true;
++
++        case AVERROR(EAGAIN):
++            return false;
++
++        default:
++            throw logic_error("Failed to decode video frame: avcodec_receive_frame() < 0");
++    }
+ }
+ 
+ bool MovieDecoder::getVideoPacket()
+@@ -570,8 +582,6 @@
+     bool framesAvailable = true;
+     bool frameDecoded = false;
+ 
+-    int attempts = 0;
+-
+     if (m_pPacket)
+     {
+         av_packet_unref(m_pPacket);
+@@ -580,6 +590,7 @@
+ 
+     m_pPacket = new AVPacket();
+ 
++
+     while (framesAvailable && !frameDecoded)
+     {
+         framesAvailable = av_read_frame(m_pFormatContext, m_pPacket) >= 0;
+@@ -644,7 +655,7 @@
+ 
+ int32_t MovieDecoder::getStreamRotation()
+ {
+-    int32_t* matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
++    auto matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
+     if (matrix)
+     {
+         auto angle = lround(av_display_rotation_get(matrix));
+
+--- a/libffmpegthumbnailer/moviedecoder.h	2017-11-12 04:23:38.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.h	2023-05-05 13:26:07.095529911 -0400
+@@ -78,7 +78,7 @@
+     int                     m_VideoStream;
+     AVFormatContext*        m_pFormatContext;
+     AVCodecContext*         m_pVideoCodecContext;
+-    AVCodec*                m_pVideoCodec;
++    const AVCodec*          m_pVideoCodec;
+     AVFilterGraph*          m_pFilterGraph;
+     AVFilterContext*        m_pFilterSource;
+     AVFilterContext*        m_pFilterSink;
diff --git a/srcpkgs/ffmpegthumbnailer/template b/srcpkgs/ffmpegthumbnailer/template
index 039eea7622b39..35d546018d12a 100644
--- a/srcpkgs/ffmpegthumbnailer/template
+++ b/srcpkgs/ffmpegthumbnailer/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbnailer'
 pkgname=ffmpegthumbnailer
 version=2.2.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libpng-devel libjpeg-turbo-devel ffmpeg-devel"
@@ -9,8 +9,8 @@ depends="ffmpeg"
 short_desc="Lightweight video thumbnailer"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
-homepage="https://github.com/dirkvdb/${pkgname}"
-distfiles="${homepage}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
+homepage="https://github.com/dirkvdb"
+distfiles="${homepage}/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
 checksum=1cb24059c38223f657b300c84dd80491b7040d4b69471c4fea69be862bc99b5b
 
 post_install() {

From 1e6a6843ee2593d27028b769337dfed53ed4105e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 029/113] ffmpegthumbs: revbump for ffmpeg6

---
 srcpkgs/ffmpegthumbs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ffmpegthumbs/template b/srcpkgs/ffmpegthumbs/template
index 5f0b9414dadaf..11b88193528f4 100644
--- a/srcpkgs/ffmpegthumbs/template
+++ b/srcpkgs/ffmpegthumbs/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbs'
 pkgname=ffmpegthumbs
 version=22.12.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules kcoreaddons kconfig-devel
  pkg-config qt5-host-tools qt5-qmake gettext"

From dbd147e6a8ee709eac54061345c549a8a06db686 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 030/113] ffms2: revbump for ffmpeg6

---
 srcpkgs/ffms2/patches/ffmpeg5.patch | 424 ++++++++++++++++++++++++++++
 srcpkgs/ffms2/template              |   2 +-
 2 files changed, 425 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ffms2/patches/ffmpeg5.patch

diff --git a/srcpkgs/ffms2/patches/ffmpeg5.patch b/srcpkgs/ffms2/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..1479fabcafcb4
--- /dev/null
+++ b/srcpkgs/ffms2/patches/ffmpeg5.patch
@@ -0,0 +1,424 @@
+From 45673149e9a2f5586855ad472e3059084eaa36b1 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:41:21 +0100
+Subject: [PATCH] Use auto for AVCodec
+
+The geniuses over at FFmpeg decided to constify this API, so old
+versions of the library will return AVCodec *, while new versions
+of the libary will return const AVCodec *, which, in C++, are not
+OK to convert between.
+
+Rather than use some macro hell in ffmscompat.h, we can work around
+this by using auto.
+
+Gross.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 2 +-
+ src/core/indexing.cpp    | 6 +++---
+ src/core/videosource.cpp | 2 +-
+ 3 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index e4ce97c..ac09666 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -469,7 +469,7 @@ void FFMS_AudioSource::OpenFile() {
+ 
+     LAVFOpenFile(SourceFile.c_str(), FormatContext, TrackNumber);
+ 
+-    AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
++    auto *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
+     if (Codec == nullptr)
+         throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+             "Audio codec not found");
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index e547c5a..59fb4e8 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -384,7 +384,7 @@ FFMS_TrackType FFMS_Indexer::GetTrackType(int Track) {
+ }
+ 
+ const char *FFMS_Indexer::GetTrackCodec(int Track) {
+-    AVCodec *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
++    auto *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
+     return codec ? codec->name : nullptr;
+ }
+ 
+@@ -402,7 +402,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             UseDTS);
+ 
+         if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            AVCodec *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (!VideoCodec) {
+                 FormatContext->streams[i]->discard = AVDISCARD_ALL;
+                 IndexMask.erase(i);
+@@ -433,7 +433,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 IndexMask.insert(i);
+             }
+         } else if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+-            AVCodec *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (AudioCodec == nullptr)
+                 throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_UNSUPPORTED,
+                     "Audio codec not found");
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index b889970..8956c22 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -171,7 +171,7 @@ FFMS_VideoSource::FFMS_VideoSource(const char *SourceFile, FFMS_Index &Index, in
+ 
+         LAVFOpenFile(SourceFile, FormatContext, VideoTrack);
+ 
+-        AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
++        auto *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
+         if (Codec == nullptr)
+             throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+                 "Video codec not found");
+-- 
+2.40.0
+
+From 96cbf38ea9381829a1314f432a2c60495dcefaad Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:12:41 +0100
+Subject: [PATCH] all: Update AVPacket API usage
+
+AVPackets must all be on the heap now, since it is no longer
+part of the libav* ABI.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 16 ++++++----
+ src/core/indexing.cpp    | 63 ++++++++++++++++++++++------------------
+ src/core/indexing.h      |  4 +--
+ src/core/utils.cpp       |  6 ----
+ src/core/utils.h         |  1 -
+ src/core/videosource.cpp | 30 ++++++++++---------
+ 6 files changed, 64 insertions(+), 56 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index 37cf9ae..e4ce97c 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -285,10 +285,15 @@ FFMS_AudioSource::AudioBlock *FFMS_AudioSource::CacheBlock(CacheIterator &pos) {
+ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     CurrentFrame = &Frames[PacketNumber];
+ 
+-    AVPacket Packet;
+-    if (!ReadPacket(&Packet))
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++    if (!ReadPacket(Packet)) {
++        av_packet_free(&Packet);
+         throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_UNKNOWN,
+             "ReadPacket unexpectedly failed to read a packet");
++    }
+ 
+     // ReadPacket may have changed the packet number
+     CurrentFrame = &Frames[PacketNumber];
+@@ -297,8 +302,9 @@ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     int NumberOfSamples = 0;
+     AudioBlock *CachedBlock = nullptr;
+     
+-    int Ret = avcodec_send_packet(CodecContext, &Packet);
+-    av_packet_unref(&Packet);
++    int Ret = avcodec_send_packet(CodecContext, Packet);
++    av_packet_unref(Packet);
++    av_packet_free(&Packet);
+ 
+     av_frame_unref(DecodeFrame);
+     Ret = avcodec_receive_frame(CodecContext, DecodeFrame);
+@@ -513,8 +519,6 @@ void FFMS_AudioSource::Seek() {
+ }
+ 
+ bool FFMS_AudioSource::ReadPacket(AVPacket *Packet) {
+-    InitNullPacket(*Packet);
+-
+     while (av_read_frame(FormatContext, Packet) >= 0) {
+         if (Packet->stream_index == TrackNumber) {
+             // Required because not all audio packets, especially in ogg, have a pts. Use the previous valid packet's pts instead.
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index 23fb95b..e547c5a 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -320,7 +320,7 @@ void FFMS_Indexer::CheckAudioProperties(int Track, AVCodecContext *Context) {
+     }
+ }
+ 
+-void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict,
++void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict,
+                                     int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct) {
+     if (VideoContext.Parser) {
+         uint8_t *OB;
+@@ -330,8 +330,8 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+         av_parser_parse2(VideoContext.Parser,
+             VideoContext.CodecContext,
+             &OB, &OBSize,
+-            pkt.data, pkt.size,
+-            pkt.pts, pkt.dts, pkt.pos);
++            pkt->data, pkt->size,
++            pkt->pts, pkt->dts, pkt->pos);
+ 
+         // H.264 (PAFF) and HEVC may have one field per packet, so we need to track
+         // when we have a full or half frame available, and mark one of them as
+@@ -351,15 +351,15 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+ 
+         *RepeatPict = VideoContext.Parser->repeat_pict;
+         *FrameType = VideoContext.Parser->pict_type;
+-        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt.flags & AV_PKT_FLAG_DISCARD));
++        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt->flags & AV_PKT_FLAG_DISCARD));
+     } else {
+-        *Invisible = !!(pkt.flags & AV_PKT_FLAG_DISCARD);
++        *Invisible = !!(pkt->flags & AV_PKT_FLAG_DISCARD);
+     }
+ 
+     if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP8)
+-        ParseVP8(pkt.data[0], Invisible, FrameType);
++        ParseVP8(pkt->data[0], Invisible, FrameType);
+     else if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP9)
+-        ParseVP9(pkt.data[0], Invisible, FrameType);
++        ParseVP9(pkt->data[0], Invisible, FrameType);
+ }
+ 
+ void FFMS_Indexer::Free() {
+@@ -458,32 +458,36 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+         }
+     }
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
+     std::vector<int64_t> LastValidTS(FormatContext->nb_streams, AV_NOPTS_VALUE);
+ 
+     int64_t filesize = avio_size(FormatContext->pb);
+     enum AVPictureStructure LastPicStruct = AV_PICTURE_STRUCTURE_UNKNOWN;
+-    while (av_read_frame(FormatContext, &Packet) >= 0) {
++    while (av_read_frame(FormatContext, Packet) >= 0) {
+         // Update progress
+         // FormatContext->pb can apparently be NULL when opening images.
+         if (IC && FormatContext->pb) {
+-            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate))
++            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate)) {
++                av_packet_free(&Packet);
+                 throw FFMS_Exception(FFMS_ERROR_CANCELLED, FFMS_ERROR_USER,
+                     "Cancelled by user");
++            }
+         }
+-        if (!IndexMask.count(Packet.stream_index)) {
+-            av_packet_unref(&Packet);
++        if (!IndexMask.count(Packet->stream_index)) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+-        int Track = Packet.stream_index;
++        int Track = Packet->stream_index;
+         FFMS_Track &TrackInfo = (*TrackIndices)[Track];
+-        bool KeyFrame = !!(Packet.flags & AV_PKT_FLAG_KEY);
++        bool KeyFrame = !!(Packet->flags & AV_PKT_FLAG_KEY);
+         ReadTS(Packet, LastValidTS[Track], (*TrackIndices)[Track].UseDTS);
+ 
+         if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            int64_t PTS = TrackInfo.UseDTS ? Packet.dts : Packet.pts;
++            int64_t PTS = TrackInfo.UseDTS ? Packet->dts : Packet->pts;
+             if (PTS == AV_NOPTS_VALUE) {
+                 // VPx alt-refs are output as packets which lack timestmps or durations, since
+                 // they are invisible. Currently, the timestamp mangling code in libavformat
+@@ -495,9 +499,11 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 // FFMS2 currently sorts packets by PTS, which will break decoding, otherwise.
+                 bool HasAltRefs = (FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP8 ||
+                                    FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP9);
+-                if (Packet.duration == 0 && !HasAltRefs)
++                if (Packet->duration == 0 && !HasAltRefs) {
++                    av_packet_free(&Packet);
+                     throw FFMS_Exception(FFMS_ERROR_INDEXING, FFMS_ERROR_PARSER,
+                         "Invalid packet pts, dts, and duration");
++                }
+ 
+                 if (TrackInfo.empty())
+                     PTS = 0;
+@@ -513,7 +519,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             ParseVideoPacket(AVContexts[Track], Packet, &RepeatPict, &FrameType, &Invisible, &LastPicStruct);
+ 
+             TrackInfo.AddVideoFrame(PTS, RepeatPict, KeyFrame,
+-                FrameType, Packet.pos, Invisible);
++                FrameType, Packet->pos, Invisible);
+         } else if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+             // For video seeking timestamps are used only if all packets have
+             // timestamps, while for audio they're used if any have timestamps,
+@@ -522,28 +528,29 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 TrackInfo.HasTS = true;
+ 
+             int64_t StartSample = AVContexts[Track].CurrentSample;
+-            uint32_t SampleCount = IndexAudioPacket(Track, &Packet, AVContexts[Track], *TrackIndices);
++            uint32_t SampleCount = IndexAudioPacket(Track, Packet, AVContexts[Track], *TrackIndices);
+             TrackInfo.SampleRate = AVContexts[Track].CodecContext->sample_rate;
+ 
+             TrackInfo.AddAudioFrame(LastValidTS[Track],
+-                StartSample, SampleCount, KeyFrame, Packet.pos, Packet.flags & AV_PKT_FLAG_DISCARD);
++                StartSample, SampleCount, KeyFrame, Packet->pos, Packet->flags & AV_PKT_FLAG_DISCARD);
+         }
+ 
+-        if (!(Packet.flags & AV_PKT_FLAG_DISCARD))
+-            TrackInfo.LastDuration = Packet.duration;
++        if (!(Packet->flags & AV_PKT_FLAG_DISCARD))
++            TrackInfo.LastDuration = Packet->duration;
+ 
+-        av_packet_unref(&Packet);
++        av_packet_unref(Packet);
+     }
++    av_packet_free(&Packet);
+ 
+     TrackIndices->Finalize(AVContexts, FormatContext->iformat->name);
+     return TrackIndices.release();
+ }
+ 
+-void FFMS_Indexer::ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS) {
+-    if (!UseDTS && Packet.pts != AV_NOPTS_VALUE)
+-        TS = Packet.pts;
++void FFMS_Indexer::ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS) {
++    if (!UseDTS && Packet->pts != AV_NOPTS_VALUE)
++        TS = Packet->pts;
+     if (TS == AV_NOPTS_VALUE)
+         UseDTS = true;
+-    if (UseDTS && Packet.dts != AV_NOPTS_VALUE)
+-        TS = Packet.dts;
++    if (UseDTS && Packet->dts != AV_NOPTS_VALUE)
++        TS = Packet->dts;
+ }
+diff --git a/src/core/indexing.h b/src/core/indexing.h
+index 3cfc3c3..5c06868 100644
+--- a/src/core/indexing.h
++++ b/src/core/indexing.h
+@@ -80,10 +80,10 @@ private:
+     int64_t Filesize;
+     uint8_t Digest[20];
+ 
+-    void ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS);
++    void ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS);
+     void CheckAudioProperties(int Track, AVCodecContext *Context);
+     uint32_t IndexAudioPacket(int Track, AVPacket *Packet, SharedAVContext &Context, FFMS_Index &TrackIndices);
+-    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
++    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
+     void Free();
+ public:
+     FFMS_Indexer(const char *Filename);
+diff --git a/src/core/utils.cpp b/src/core/utils.cpp
+index ce67533..8a2e997 100644
+--- a/src/core/utils.cpp
++++ b/src/core/utils.cpp
+@@ -62,12 +62,6 @@ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo) {
+     }
+ }
+ 
+-void InitNullPacket(AVPacket &pkt) {
+-    av_init_packet(&pkt);
+-    pkt.data = nullptr;
+-    pkt.size = 0;
+-}
+-
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames) {
+     AP.SampleFormat = static_cast<FFMS_SampleFormat>(av_get_packed_sample_fmt(CTX->sample_fmt));
+     AP.BitsPerSample = av_get_bytes_per_sample(CTX->sample_fmt) * 8;
+diff --git a/src/core/utils.h b/src/core/utils.h
+index 9819dc7..003ab79 100644
+--- a/src/core/utils.h
++++ b/src/core/utils.h
+@@ -58,7 +58,6 @@ std::unique_ptr<T> make_unique(Args&&... args) {
+ }
+ 
+ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo);
+-void InitNullPacket(AVPacket &pkt);
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames);
+ 
+ void LAVFOpenFile(const char *SourceFile, AVFormatContext *&FormatContext, int Track);
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index 06bd161..b889970 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -673,30 +673,34 @@ void FFMS_VideoSource::DecodeNextFrame(int64_t &AStartTime, int64_t &Pos) {
+     if (HasPendingDelayedFrames())
+         return;
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
+-
+-    while (ReadFrame(&Packet) >= 0) {
+-        if (Packet.stream_index != VideoTrack) {
+-            av_packet_unref(&Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++
++    while (ReadFrame(Packet) >= 0) {
++        if (Packet->stream_index != VideoTrack) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+         if (AStartTime < 0)
+-            AStartTime = Frames.UseDTS ? Packet.dts : Packet.pts;
++            AStartTime = Frames.UseDTS ? Packet->dts : Packet->pts;
+ 
+         if (Pos < 0)
+-            Pos = Packet.pos;
++            Pos = Packet->pos;
+ 
+-        bool FrameFinished = DecodePacket(&Packet);
+-        av_packet_unref(&Packet);
+-        if (FrameFinished)
++        bool FrameFinished = DecodePacket(Packet);
++        av_packet_unref(Packet);
++        if (FrameFinished) {
++            av_packet_free(&Packet);
+             return;
++        }
+     }
+ 
+     // Flush final frames
+-    InitNullPacket(Packet);
+-    DecodePacket(&Packet);
++    DecodePacket(Packet);
++    av_packet_free(&Packet);
+ }
+ 
+ bool FFMS_VideoSource::SeekTo(int n, int SeekOffset) {
+-- 
+2.40.0
+
+From bf9e03e9e08534c024e5a744a6437c4aac160201 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:20:47 +0100
+Subject: [PATCH 2/3] configure: Remove deprecated API use
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ configure.ac | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index b35ef80bc..d19714d0f 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -102,10 +102,10 @@ CFLAGS="$_CFLAGS $FFMPEG_CFLAGS"
+
+ AC_DEFUN([TEST_FFMPEG],
+          [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+-            #include <libavcodec/avcodec.h>
++            #include <libavformat/avformat.h>
+             #include <libswscale/swscale.h>
+             ]],[[
+-                avcodec_register_all();
++                avformat_network_init();
+                 swscale_version();
+             ]])], [eval $1=yes], [eval $1=no])
+         ])
+
diff --git a/srcpkgs/ffms2/template b/srcpkgs/ffms2/template
index 365f64d10cbab..1641ecf43be5b 100644
--- a/srcpkgs/ffms2/template
+++ b/srcpkgs/ffms2/template
@@ -1,7 +1,7 @@
 # Template file for 'ffms2'
 pkgname=ffms2
 version=2.40
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-shared --disable-static"
 hostmakedepends="pkg-config autoconf automake libtool"

From ffc77f5d5dad3d0ecc826ca2a8f5eb538e9c18d1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 031/113] freerdp: revbump for ffmpeg6

---
 .../freerdp/patches/ffmpeg6_aa2cb9aa.patch    | 42 +++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100644 srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch

diff --git a/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
new file mode 100644
index 0000000000000..a4324da3a8822
--- /dev/null
+++ b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
@@ -0,0 +1,42 @@
+From aa2cb9aa5ff5562433598ba168a466e0752bca0e Mon Sep 17 00:00:00 2001
+From: akallabeth <akallabeth@posteo.net>
+Date: Tue, 14 Feb 2023 07:48:54 +0100
+Subject: [PATCH] Fixed #8686: Update h264 to use new FFMPEG API
+
+---
+ channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c | 2 ++
+ libfreerdp/codec/h264_ffmpeg.c            | 2 ++
+ 2 files changed, 4 insertions(+)
+
+diff --git a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+index 339462d865f..beea80b7a1e 100644
+--- a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
++++ b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+@@ -239,8 +239,10 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYP
+ 		}
+ 	}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 	if (mdecoder->codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		mdecoder->codec_context->flags |= AV_CODEC_FLAG_TRUNCATED;
++#endif
+ 
+ 	return TRUE;
+ }
+diff --git a/libfreerdp/codec/h264_ffmpeg.c b/libfreerdp/codec/h264_ffmpeg.c
+index 8a23db2473c..896a333019b 100644
+--- a/libfreerdp/codec/h264_ffmpeg.c
++++ b/libfreerdp/codec/h264_ffmpeg.c
+@@ -615,10 +615,12 @@ static BOOL libavcodec_init(H264_CONTEXT* h264)
+ 			goto EXCEPTION;
+ 		}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 		if (sys->codecDecoder->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		{
+ 			sys->codecDecoderContext->flags |= AV_CODEC_FLAG_TRUNCATED;
+ 		}
++#endif
+ 
+ #ifdef WITH_VAAPI
+ 

From a603bf774edc340a56a17a2737e6847fdead050f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 032/113] gerbera: revbump for ffmpeg6

---
 srcpkgs/gerbera/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gerbera/template b/srcpkgs/gerbera/template
index ae14f35c767c0..2dc0ac0ce03b5 100644
--- a/srcpkgs/gerbera/template
+++ b/srcpkgs/gerbera/template
@@ -1,7 +1,7 @@
 # Template file for 'gerbera'
 pkgname=gerbera
 version=1.12.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_SYSTEMD=0 -DWITH_AVCODEC=1"
 hostmakedepends="pkg-config"

From 5c5ac333ada583961b60f26891fd17b16d9c9022 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 033/113] goldendict: revbump for ffmpeg6

---
 srcpkgs/goldendict/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/goldendict/template b/srcpkgs/goldendict/template
index f4a05759f693d..97f44347b03a6 100644
--- a/srcpkgs/goldendict/template
+++ b/srcpkgs/goldendict/template
@@ -1,7 +1,7 @@
 # Template file for 'goldendict'
 pkgname=goldendict
 version=1.5.0
-revision=1
+revision=2
 build_style=qmake
 configure_args="CONFIG+=zim_support goldendict.pro"
 hostmakedepends="qt5-qmake pkg-config qt5-host-tools"
@@ -10,7 +10,7 @@ makedepends="tiff-devel qt5-devel libvorbis-devel zlib-devel
  qt5-webkit-devel lzo-devel bzip2-devel libao-devel qt5-svg-devel
  libeb-devel qt5-x11extras-devel ffmpeg-devel liblzma-devel
  qt5-multimedia-devel"
-short_desc="A feature-rich dictionary lookup program"
+short_desc="Feature-rich dictionary lookup program"
 maintainer="John <me@johnnynator.dev>"
 license="GPL-3.0-or-later"
 homepage="http://goldendict.org/"

From 9513927e4bd739d0e2f47efb84746dde5589ca31 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 034/113] gst-libav: revbump for ffmpeg6

---
 srcpkgs/gst-libav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index 78afeee4aefb2..f892eb2063564 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.22.7
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"

From 46832688ee1ce517fca23d21c60a38b4f2f71bc5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 035/113] gst-rtsp-server: revbump for ffmpeg6

---
 srcpkgs/gst-rtsp-server/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index 2c280c84f1514..83a2949fd9482 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
 version=1.22.7
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="glib-devel gst-plugins-bad1-devel gobject-introspection

From 93de59c908ed3959dbd5ca7c782fcc18ead9d9f0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 036/113] guvcview: update to 2.0.8.

---
 srcpkgs/guvcview/patches/fix-include.patch | 10 ++++++++++
 srcpkgs/guvcview/template                  |  7 +++----
 2 files changed, 13 insertions(+), 4 deletions(-)
 create mode 100644 srcpkgs/guvcview/patches/fix-include.patch

diff --git a/srcpkgs/guvcview/patches/fix-include.patch b/srcpkgs/guvcview/patches/fix-include.patch
new file mode 100644
index 0000000000000..503c2af3b78c1
--- /dev/null
+++ b/srcpkgs/guvcview/patches/fix-include.patch
@@ -0,0 +1,10 @@
+--- a/guvcview/guvcview.c
++++ b/guvcview/guvcview.c
+@@ -28,6 +28,7 @@
+ #include <sys/stat.h>
+ #include <sys/resource.h>
+ #include <errno.h>
++#include <locale.h>
+ 
+ #include "gview.h"
+ #include "gviewv4l2core.h"
diff --git a/srcpkgs/guvcview/template b/srcpkgs/guvcview/template
index d42fd38fa4ad1..86a7fd619612c 100644
--- a/srcpkgs/guvcview/template
+++ b/srcpkgs/guvcview/template
@@ -1,8 +1,7 @@
 # Template file for 'guvcview'
 pkgname=guvcview
-version=2.0.7
-revision=2
-create_wrksrc=yes
+version=2.0.8
+revision=1
 build_style=gnu-configure
 configure_args="--disable-static --disable-debian-menu"
 hostmakedepends="pkg-config intltool autoconf automake libtool glib-devel"
@@ -14,7 +13,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="http://guvcview.sourceforge.net/"
 distfiles="${SOURCEFORGE_SITE}/${pkgname}/${pkgname}-src-${version}.tar.bz2"
-checksum=f47d51fbd06e44eeaa1a82f4a153c927527c90d94514197a70b2956028cc8ad4
+checksum=a21f4e448286666cf27bafef5290cc953a0a1796b752e5bbe521266dc1230c81
 
 post_patch() {
 	sed '31a#include <locale.h>' -i  guvcview/guvcview.c

From 218a66b5f9bcd2f7f01bdc05e2fa1683c6d7ddd9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 037/113] handbrake: update to 1.6.1

---
 .../patches/fix-missing-x265-link-flag.patch    | 11 ++++++-----
 .../handbrake/patches/libhb-vpl-include.patch   | 15 +++++++++++++++
 srcpkgs/handbrake/template                      | 17 ++++++++++-------
 3 files changed, 31 insertions(+), 12 deletions(-)
 create mode 100644 srcpkgs/handbrake/patches/libhb-vpl-include.patch

diff --git a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
index 26db03867a0c8..d6bb2eda627a3 100644
--- a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
+++ b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
@@ -1,14 +1,15 @@
 --- a/gtk/configure.ac
 +++ b/gtk/configure.ac
 @@ -203,7 +203,7 @@
- 
+
  AM_CONDITIONAL([MINGW], [test "x$mingw_flag" = "xyes"])
- 
--HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg"
-+HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -ldl"
+
+-HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc"
++HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc -ldl"
  HB_CPPFLAGS="$HB_CPPFLAGS $HBINC"
- 
+
  PKG_CHECK_MODULES([x264], [x264], sys_x264=yes, sys_x264=no)
+
 --- a/test/module.defs
 +++ b/test/module.defs
 @@ -69,6 +69,9 @@
diff --git a/srcpkgs/handbrake/patches/libhb-vpl-include.patch b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
new file mode 100644
index 0000000000000..298f9f4ab28f2
--- /dev/null
+++ b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
@@ -0,0 +1,15 @@
+--- a/libhb/module.defs	2023-01-22 11:36:49.000000000 -0500
++++ b/libhb/module.defs	2023-04-03 22:37:52.395467010 -0400
+@@ -46,11 +46,7 @@
+ LIBHB.GCC.I += $(LIBHB.build/) $(CONTRIB.build/)include
+ 
+ ifeq (1,$(FEATURE.qsv))
+-    ifeq ($(HOST.system),freebsd))
+-        LIBHB.GCC.I += $(LOCALBASE)/include/vpl
+-    else
+-        LIBHB.GCC.I += $(CONTRIB.build/)include/vpl
+-    endif
++    LIBHB.GCC.I += /usr/include/vpl
+ endif
+ 
+ ifneq (,$(filter $(HOST.system),freebsd netbsd openbsd))
diff --git a/srcpkgs/handbrake/template b/srcpkgs/handbrake/template
index ca5e4571e49c3..c32cb1bfa31f4 100644
--- a/srcpkgs/handbrake/template
+++ b/srcpkgs/handbrake/template
@@ -1,10 +1,10 @@
 # Template file for 'handbrake'
 pkgname=handbrake
-version=1.5.1
+version=1.6.1
 revision=1
 build_style=gnu-configure
 configure_args="--force --disable-gtk-update-checks --disable-df-fetch --harden
- $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc)"
+ $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc) $(vopt_enable qsv)"
 make_build_args="-C ${XBPS_TRIPLET}"
 make_install_args="-C ${XBPS_TRIPLET}"
 hostmakedepends="automake cmake gettext-devel glib-devel intltool libtool m4 meson nasm pkg-config python3"
@@ -12,8 +12,11 @@ makedepends="bzip2-devel ffmpeg-devel gst-plugins-base1-devel gtk+3-devel
  jansson-devel lame-devel libass-devel libbluray-devel libdav1d-devel
  libdvdnav-devel libdvdread-devel libgudev-devel libnuma-devel
  libsamplerate-devel libtheora-devel libvorbis-devel libvpx-devel libxml2-devel
- opus-devel speex-devel x264-devel x265-devel zimg-devel
+ opus-devel speex-devel x264-devel x265-devel zimg-devel libsvt-av1-devel
  $(vopt_if fdk_aac fdk-aac-devel)
+ $(vopt_if qsv libva-devel)
+ $(vopt_if qsv libdrm-devel)
+ $(vopt_if qsv onevpl-devel)
  $(vopt_if nvenc nv-codec-headers)"
 depends="desktop-file-utils gst-plugins-good1 hicolor-icon-theme"
 short_desc="Multithreaded video transcoder"
@@ -21,15 +24,15 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-2.0-only"
 homepage="https://handbrake.fr/"
 distfiles="https://github.com/HandBrake/HandBrake/releases/download/${version}/HandBrake-${version}-source.tar.bz2"
-checksum=3999fe06d5309c819799a73a968a8ec3840e7840c2b64af8f5cdb7fd8c9430f0
+checksum=94ccfe03db917a91650000c510f7fd53f844da19f19ad4b4be1b8f6bc31a8d4c
 nocross=yes
 
-build_options="fdk_aac nvenc"
+build_options="fdk_aac nvenc qsv"
 
 case "$XBPS_TARGET_MACHINE" in
 	x86_64*|i686*)
 		CFLAGS="-msse"
-		build_options_default="nvenc"
+		build_options_default="nvenc qsv"
 		;;
 esac
 
@@ -37,7 +40,7 @@ pre_configure() {
 	# use system libraries, don't download them
 	rm -rf contrib/
 	for module in fdk-aac ffmpeg libbluray libdav1d libdvdnav libdvdread nvenc \
-		x265 zimg; do
+		x265 zimg svt-av1 libvpl; do
 	    vsed -i "/MODULES += contrib\/${module}/d" make/include/main.defs
 	done
 }

From f0f859ce4cca710c0383fcd06c92892ee9a2bf4f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 038/113] hedgewars: revbump for ffmpeg4

---
 srcpkgs/hedgewars/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/hedgewars/template b/srcpkgs/hedgewars/template
index 94b6db673b0c3..402ccfaaecbc2 100644
--- a/srcpkgs/hedgewars/template
+++ b/srcpkgs/hedgewars/template
@@ -1,13 +1,13 @@
 # Template file for 'hedgewars'
 pkgname=hedgewars
 version=1.0.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DNOSERVER=1 -DDATA_INSTALL_DIR=/usr/share/${pkgname}
  -DPHYSFS_SYSTEM=1 -DMINIMAL_FLAGS=1"
 make_cmd=make
 hostmakedepends="lua51 pkg-config qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
+makedepends="ffmpeg4-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
  SDL2_mixer-devel SDL2_net-devel SDL2_ttf-devel"
 depends="libfreeglut"
 short_desc="Funny turn-based artillery game, featuring fighting Hedgehogs!"

From 55b34da80ccc1e26c31fe304dc72fd5cdb9ce528 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 039/113] idjc: revbump for ffmpeg4

---
 srcpkgs/idjc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/idjc/template b/srcpkgs/idjc/template
index a9cde0665d55b..6f1d21c5781fd 100644
--- a/srcpkgs/idjc/template
+++ b/srcpkgs/idjc/template
@@ -5,7 +5,7 @@ revision=5
 build_style=gnu-configure
 hostmakedepends="pkg-config git python3 automake gettext-devel libtool"
 makedepends="libvorbis-devel libogg-devel jack-devel libsamplerate-devel
- libflac-devel libsndfile-devel mpg123-devel ffmpeg-devel speex-devel
+ libflac-devel libsndfile-devel mpg123-devel ffmpeg4-devel speex-devel
  glib-devel pixman-devel lame-devel python3-gobject-devel libshout-idjc-devel
  opus-devel twolame-devel python3-mutagen python3-devel"
 depends="python3-gobject python3-mutagen desktop-file-utils shared-mime-info python3-dbus jack"

From e16ddeaf2b0663c15d16be696d4d2d511df91d6b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 040/113] kid3: revbump for ffmpeg6

---
 srcpkgs/kid3/patches/ffmpeg5.patch | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 srcpkgs/kid3/patches/ffmpeg5.patch

diff --git a/srcpkgs/kid3/patches/ffmpeg5.patch b/srcpkgs/kid3/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..135fc50e07c9b
--- /dev/null
+++ b/srcpkgs/kid3/patches/ffmpeg5.patch
@@ -0,0 +1,17 @@
+# https://aur.archlinux.org/cgit/aur.git/diff/ffmpeg5.patch?h=kid3-cli&id=12410a74906612e7efc0ec8fbce739b4a0fef7e7
+diff --git a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+index e156d424..e12b9abd 100644
+--- a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
++++ b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+@@ -232,7 +232,11 @@ private:
+   friend class Format;
+   friend class Converter;
+   AVCodecContext* m_ptr;
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 0, 0)
+   AVCodec* m_impl;
++#else
++  const AVCodec* m_impl;
++#endif
+   AVFrame* m_frame;
+   bool m_opened;
+ };

From b0731df8a9babb1d72ef558a33436ed882882d51 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 041/113] kodi: revbump for ffmpeg4

---
 srcpkgs/kodi/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kodi/template b/srcpkgs/kodi/template
index d37a5918cd675..536ee1fc83a7d 100644
--- a/srcpkgs/kodi/template
+++ b/srcpkgs/kodi/template
@@ -54,7 +54,7 @@ makedepends="
  libmad-devel fontconfig-devel libXinerama-devel libsamplerate-devel libmms-devel
  enca-devel boost-devel libcurl-devel libva-devel libvdpau-devel libass-devel
  libbluetooth-devel yajl-devel libplist-devel librtmp-devel tinyxml-devel
- taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg-devel
+ taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg4-devel
  giflib-devel libxslt-devel gnutls-devel libssh-devel libmicrohttpd-devel
  libcec-devel dcadec-devel flatbuffers-devel fmt-devel lcms2-devel
  libfstrcmp-devel rapidjson libcdio-paranoia spdlog libwaylandpp-devel

From b9d9f4b9a4c5c98a8e754f76ffd6103ba36821ac Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 042/113] kpipewire: revbump for ffmpeg6

---
 srcpkgs/kpipewire/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kpipewire/template b/srcpkgs/kpipewire/template
index 6214a4451336e..3555348659dde 100644
--- a/srcpkgs/kpipewire/template
+++ b/srcpkgs/kpipewire/template
@@ -1,7 +1,7 @@
 # Template file for 'kpipewire'
 pkgname=kpipewire
 version=5.27.10
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules plasma-wayland-protocols gettext
  qt5-qmake qt5-host-tools pkg-config wayland-devel kcoreaddons

From 2c379564c6634b170e788de7139fed49b56ddec8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 043/113] libextractor: revbump for ffmpeg4

---
 srcpkgs/libextractor/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libextractor/template b/srcpkgs/libextractor/template
index 044c663a3a0b9..ace88ae128da5 100644
--- a/srcpkgs/libextractor/template
+++ b/srcpkgs/libextractor/template
@@ -7,7 +7,7 @@ configure_args="--disable-static"
 hostmakedepends="pkg-config"
 makedepends="zlib-devel bzip2-devel exiv2-devel tiff-devel libpng-devel
  libjpeg-turbo-devel libvorbis-devel libflac-devel giflib-devel libmpeg2-devel
- ffmpeg-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
+ ffmpeg4-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
 short_desc="Library used to extract meta data from files"
 maintainer="Martin Riese <grauehaare@gmx.de>"
 license="GPL-3.0-or-later"

From 5b72633c11edfe5ca8a5da8b29d2350c7018babf Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 044/113] libopenal: revbump for ffmpeg6

---
 srcpkgs/libopenal/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenal/template b/srcpkgs/libopenal/template
index 88d0f11307d81..8308fca0393e3 100644
--- a/srcpkgs/libopenal/template
+++ b/srcpkgs/libopenal/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenal'
 pkgname=libopenal
 version=1.23.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DALSOFT_EXAMPLES=OFF"
 hostmakedepends="pkg-config"

From 83a7406cb283d0672cdd8363a5328cce8473e62a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 045/113] loudgain: revbump for ffmpeg6

---
 srcpkgs/loudgain/patches/ffmpeg5.patch | 11 +++++++++++
 srcpkgs/loudgain/template              |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/loudgain/patches/ffmpeg5.patch

diff --git a/srcpkgs/loudgain/patches/ffmpeg5.patch b/srcpkgs/loudgain/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..16d4510ee98fa
--- /dev/null
+++ b/srcpkgs/loudgain/patches/ffmpeg5.patch
@@ -0,0 +1,11 @@
+--- a/src/scan.c	2019-09-06 11:31:19.000000000 -0400
++++ b/src/scan.c	2023-03-23 11:15:40.867968521 -0400
+@@ -69,8 +69,6 @@
+ 	 * It is now useless
+ 	 * https://github.com/FFmpeg/FFmpeg/blob/70d25268c21cbee5f08304da95be1f647c630c15/doc/APIchanges#L86
+ 	 */
+-  if (avformat_version() < AV_VERSION_INT(58,9,100))
+-    av_register_all();
+ 
+ 	av_log_set_callback(scan_av_log);
+ 
diff --git a/srcpkgs/loudgain/template b/srcpkgs/loudgain/template
index da4f2d56e94c3..4d6bf29efb4fd 100644
--- a/srcpkgs/loudgain/template
+++ b/srcpkgs/loudgain/template
@@ -1,7 +1,7 @@
 # Template file for 'loudgain'
 pkgname=loudgain
 version=0.6.8
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libebur128-devel taglib-devel ffmpeg-devel"

From 80366b7db13d57dcd83323df39b28dc52657e3b2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 046/113] mediastreamer: revbump for ffmpeg4

---
 srcpkgs/mediastreamer/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mediastreamer/template b/srcpkgs/mediastreamer/template
index 0fcffa7653d18..92ada88743a9b 100644
--- a/srcpkgs/mediastreamer/template
+++ b/srcpkgs/mediastreamer/template
@@ -5,7 +5,7 @@ revision=2
 build_style=cmake
 configure_args="-DENABLE_STRICT=0 -DENABLE_UNIT_TESTS=0"
 hostmakedepends="python3"
-makedepends="bzrtp-devel ffmpeg-devel glew-devel libXv-devel libsrtp-devel
+makedepends="bzrtp-devel ffmpeg4-devel glew-devel libXv-devel libsrtp-devel
  libupnp-devel libvpx-devel mbedtls-devel opus-devel ortp-devel pulseaudio-devel
  libtheora-devel speex-devel v4l-utils-devel bcg729-devel bcmatroska2-devel libgsm-devel
  zxing-cpp-devel"

From 34407482e32dc536585d14863bd1d945bfacffa5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 047/113] mgba: revbump for ffmpeg6

---
 srcpkgs/mgba/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mgba/template b/srcpkgs/mgba/template
index 5513e3fd16f3f..f5c87a4893002 100644
--- a/srcpkgs/mgba/template
+++ b/srcpkgs/mgba/template
@@ -1,7 +1,7 @@
 # Template file for 'mgba'
 pkgname=mgba
 version=0.10.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake desktop-file-utils"
 makedepends="SDL2-devel ffmpeg-devel libedit-devel libepoxy-devel libmagick-devel

From f9de65de09ab3887b7e8e222b6fa3fabb3da93ac Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 048/113] mlt: revbump for ffmpeg4

---
 srcpkgs/mlt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mlt/template b/srcpkgs/mlt/template
index 73e3915aaab9a..ec5054be3b75e 100644
--- a/srcpkgs/mlt/template
+++ b/srcpkgs/mlt/template
@@ -8,7 +8,7 @@ configure_args="--prefix=/usr --libdir=/usr/lib$XBPS_TARGET_WORDSIZE
  --swig-languages=python"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which"
 # XXX: movit vid.stab
-makedepends="alsa-lib-devel ffmpeg-devel gtk+-devel jack-devel ladspa-sdk
+makedepends="alsa-lib-devel ffmpeg4-devel gtk+-devel jack-devel ladspa-sdk
  libexif-devel libsamplerate-devel libxml2-devel sox-devel SDL_image-devel
  fftw-devel frei0r-plugins python3-devel pulseaudio-devel movit-devel
  libvidstab-devel"

From ba0303ec591588bf1e1c233fe521329cef1d2ab7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 049/113] moc: revbump for ffmpeg4

---
 srcpkgs/moc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/moc/template b/srcpkgs/moc/template
index 3a04932c8f1e6..d8de816026b64 100644
--- a/srcpkgs/moc/template
+++ b/srcpkgs/moc/template
@@ -4,7 +4,7 @@ version=2.5.2
 revision=7
 build_style=gnu-configure
 hostmakedepends="pkg-config"
-makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg-devel
+makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg4-devel
  jack-devel alsa-lib-devel libltdl-devel libflac-devel libvorbis-devel
  libmad-devel libmpcdec-devel libmodplug-devel libid3tag-devel faad2-devel
  taglib-devel libsndfile-devel wavpack-devel speex-devel libsamplerate-devel

From 67b13611b7900ba1435af7bc6f081ab439eb4df2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 050/113] motion: revbump for ffmpeg6

---
 srcpkgs/motion/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/motion/template b/srcpkgs/motion/template
index 607ebeb3c7b24..bf63a91d9764f 100644
--- a/srcpkgs/motion/template
+++ b/srcpkgs/motion/template
@@ -1,7 +1,7 @@
 # Template file for 'motion'
 pkgname=motion
 version=4.6.0
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake pkg-config gettext-devel tar"
 makedepends="ffmpeg-devel libmicrohttpd-devel v4l-utils-devel gettext-devel"

From b97fd056ff8484fdb2b3771638b3b78ce921ed65 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 051/113] notcurses: revbump for ffmpeg6

---
 srcpkgs/notcurses/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/notcurses/template b/srcpkgs/notcurses/template
index 6dd8a091319f7..3110c30c9aff2 100644
--- a/srcpkgs/notcurses/template
+++ b/srcpkgs/notcurses/template
@@ -1,7 +1,7 @@
 # Template file for 'notcurses'
 pkgname=notcurses
 version=3.0.9
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DUSE_STATIC=ON $(vopt_bool man USE_PANDOC)"
 hostmakedepends="pkg-config $(vopt_if man pandoc)"

From b85b3ff63b9b000f999856ee152d7cffc1243a42 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 052/113] olive: revbump for ffmpeg4

---
 srcpkgs/olive/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/olive/template b/srcpkgs/olive/template
index 12a46936c9900..5c2917b9c5124 100644
--- a/srcpkgs/olive/template
+++ b/srcpkgs/olive/template
@@ -1,10 +1,10 @@
 # Template file for 'olive'
 pkgname=olive
 version=0.1.2
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools pkg-config"
-makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg-devel frei0r-plugins"
+makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg4-devel frei0r-plugins"
 short_desc="Non-linear video editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"

From 563bb3129e47936375669c0a8657da6f309f8e36 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 053/113] omxplayer: revbump for ffmpeg4

---
 srcpkgs/omxplayer/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/omxplayer/template b/srcpkgs/omxplayer/template
index 9a66690c83ebb..a21b878878037 100644
--- a/srcpkgs/omxplayer/template
+++ b/srcpkgs/omxplayer/template
@@ -1,7 +1,7 @@
 # Template file for 'omxplayer'
 pkgname=omxplayer
 version=20190102
-revision=2
+revision=3
 short_desc="Commandline OMX player for the Raspberry Pi"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
@@ -15,7 +15,7 @@ checksum=af2d9450f8947842ea8c401fe9f71eec444013ebbdee29f2ac828c9c493c1329
 archs="armv6l* armv7l*"
 build_style=gnu-makefile
 hostmakedepends="ruby-ronn pkg-config"
-makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg-devel dbus-devel"
+makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg4-devel dbus-devel"
 depends="freefont-ttf"
 
 do_build() {

From 3c982aa937475dd7f92b42763f4899e8dba4d578 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 054/113] opentoonz: revbump for ffmpeg6

---
 srcpkgs/opentoonz/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/opentoonz/template b/srcpkgs/opentoonz/template
index ee9f7603f55fd..3e81834ca0edd 100644
--- a/srcpkgs/opentoonz/template
+++ b/srcpkgs/opentoonz/template
@@ -1,7 +1,7 @@
 # Template file for 'opentoonz'
 pkgname=opentoonz
 version=1.6.0
-revision=2
+revision=3
 build_wrksrc="toonz/sources"
 build_style=cmake
 make_cmd=make

From 98b8bb87510d7e2031620bc4cae53acd1d084c75 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 055/113] pianobar: revbump for ffmpeg6

---
 srcpkgs/pianobar/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pianobar/template b/srcpkgs/pianobar/template
index e3febb821a451..1e3dc1bf9308e 100644
--- a/srcpkgs/pianobar/template
+++ b/srcpkgs/pianobar/template
@@ -1,7 +1,7 @@
 # Template file for 'pianobar'
 pkgname=pianobar
 version=2022.04.01
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="V=1"
 hostmakedepends="pkg-config"

From e8b5fbcc987274a46898a7ebbd8fabc9fcadbb29 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 056/113] ppsspp: revbump for ffmpeg4

---
 srcpkgs/ppsspp/template | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/ppsspp/template b/srcpkgs/ppsspp/template
index 2c0ded496eb98..1294ef3ae669c 100644
--- a/srcpkgs/ppsspp/template
+++ b/srcpkgs/ppsspp/template
@@ -1,7 +1,7 @@
 # Template file for 'ppsspp'
 pkgname=ppsspp
 version=1.16.6
-revision=1
+revision=2
 _glslang_commit=b34f619e1c85810dcb3c578107d2e48ba4ee2b37
 _SPIRV_Cross_commit=4212eef67ed0ca048cb726a6767185504e7695e5
 _armips_commit=7bd1ec93d4586985ba1ef420b43b5e620f68695e
@@ -15,7 +15,7 @@ configure_args="-DHEADLESS=1 -DUSE_SYSTEM_FFMPEG=1 -DUNITTEST=ON
  -DUSING_QT_UI=$(vopt_if qt ON OFF) -DUSE_SYSTEM_ZSTD=ON
  -DARMIPS_USE_STD_FILESYSTEM=ON"
 hostmakedepends="pkg-config python3 $(vopt_if qt qt5-host-tools)"
-makedepends="zlib-devel glew-devel ffmpeg-devel libzip-devel
+makedepends="zlib-devel glew-devel ffmpeg4-devel libzip-devel
  snappy-devel rapidjson libpng-devel libzstd-devel
  $(vopt_if sdl2 'SDL2_ttf-devel SDL2-devel') $(vopt_if wayland wayland-devel)
  $(vopt_if qt 'qt5-devel qt5-multimedia-devel')"
@@ -72,7 +72,7 @@ post_extract() {
         mv ${wrksrc}/rcheevos-${_rcheevos_commit} ${wrksrc}/ext/rcheevos
 }
 
-post_patch(){
+post_patch() {
 	# disable git versioning
 	vsed -e 's|find_package(Git)|# &|' -i git-version.cmake
 }
@@ -85,7 +85,6 @@ post_configure() {
 }
 
 do_install() {
-	vlicense LICENSE.TXT
 	vinstall icons/icon.svg 644 usr/share/pixmaps ppsspp.svg
 	vinstall Qt/PPSSPP.desktop 644 usr/share/applications
 	vbin build/PPSSPPHeadless ppsspp-headless

From 1101526c9d8be46c1cb21247acca18af94c4b9fd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 057/113] pqiv: revbump for ffmpeg6

---
 srcpkgs/pqiv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pqiv/template b/srcpkgs/pqiv/template
index 542fc27a2d32a..9308d949b6a1c 100644
--- a/srcpkgs/pqiv/template
+++ b/srcpkgs/pqiv/template
@@ -1,7 +1,7 @@
 # Template file for 'pqiv'
 pkgname=pqiv
 version=2.12
-revision=1
+revision=2
 build_style=gnu-makefile
 hostmakedepends="pkg-config"
 makedepends="glib-devel gtk+3-devel $(vopt_if ffmpeg ffmpeg-devel)

From fc8f1c25b00604583886f385ea0de31a4c6a97b7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 058/113] qmmp: revbump for ffmpeg6

---
 srcpkgs/qmmp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qmmp/template b/srcpkgs/qmmp/template
index 53781ea3bc28a..2da07f1e87eac 100644
--- a/srcpkgs/qmmp/template
+++ b/srcpkgs/qmmp/template
@@ -1,7 +1,7 @@
 # Template file for 'qmmp'
 pkgname=qmmp
 version=1.6.1
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DUSE_HAL:BOOL=FALSE -DQMMP_DEFAULT_UI:STRING=simple"
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From 7d8b21448d0789fe1067637d80249b4a8be873eb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 14 Dec 2023 13:28:10 -0500
Subject: [PATCH 059/113] qt6-pdf: revbump for ffmpeg6

---
 srcpkgs/qt6-pdf/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-pdf/template b/srcpkgs/qt6-pdf/template
index ecda84afac131..531b4e1d4fe84 100644
--- a/srcpkgs/qt6-pdf/template
+++ b/srcpkgs/qt6-pdf/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-pdf'
 pkgname=qt6-pdf
 version=6.6.0
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DQT_FEATURE_qtpdf_build=ON
  -DQT_FEATURE_qtpdf_widgets_build=ON

From 9a54fc8d670ec70e57ede9f77f7bc6af53c7f351 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 060/113] qt5-webengine: revbump for ffmpeg6

---
 .../chromium-media-filters-cpp14.patch        |  11 ++
 srcpkgs/qt5-webengine/patches/ffmpeg5.patch   | 179 ++++++++++++++++++
 .../qtwebengine-fix-ffmpeg5-build.patch       |  14 ++
 srcpkgs/qt5-webengine/template                |   4 +-
 4 files changed, 206 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/ffmpeg5.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch

diff --git a/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
new file mode 100644
index 0000000000000..04adc540f2cbc
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
@@ -0,0 +1,11 @@
+--- a/src/3rdparty/chromium/media/filters/BUILD.gn	2023-02-27 13:32:59.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/BUILD.gn	2023-04-02 17:21:39.204066384 -0400
+@@ -96,6 +96,8 @@
+     "//ui/gfx/geometry:geometry",
+   ]
+ 
++  cflags_cc = [ "-std=c++14" ]
++
+   libs = []
+ 
+   if (proprietary_codecs) {
diff --git a/srcpkgs/qt5-webengine/patches/ffmpeg5.patch b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..ac55e1634423a
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
@@ -0,0 +1,179 @@
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:57.732547446 -0400
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:09.486478995 -0400
+@@ -57,6 +57,8 @@
+ 
+ namespace {
+ 
++constexpr int64_t kRelativeTsBase = static_cast<int64_t>(0x7ffeffffffffffff);
++
+ void SetAVStreamDiscard(AVStream* stream, AVDiscard discard) {
+   DCHECK(stream);
+   stream->discard = discard;
+@@ -90,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+   if (stream->start_time != kNoFFmpegTimestamp)
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (stream->first_dts != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, stream->first_dts);
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -408,11 +398,11 @@
+   scoped_refptr<DecoderBuffer> buffer;
+ 
+   if (type() == DemuxerStream::TEXT) {
+-    int id_size = 0;
++    size_t id_size = 0;
+     uint8_t* id_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
+ 
+-    int settings_size = 0;
++    size_t settings_size = 0;
+     uint8_t* settings_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
+ 
+@@ -424,7 +414,7 @@
+     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
+                                      side_data.data(), side_data.size());
+   } else {
+-    int side_data_size = 0;
++    size_t side_data_size = 0;
+     uint8_t* side_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
+ 
+@@ -485,7 +475,7 @@
+                                        packet->size - data_offset);
+     }
+ 
+-    int skip_samples_size = 0;
++    size_t skip_samples_size = 0;
+     const uint32_t* skip_samples_ptr =
+         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
+             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
+@@ -1587,6 +1577,8 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++      continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+       lowest_start_time_stream = stream.get();
+@@ -1604,6 +1596,8 @@
+     if (stream && stream->type() == DemuxerStream::VIDEO &&
+         stream->IsEnabled()) {
+       video_stream = stream.get();
++      if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++        continue;
+       if (video_stream->start_time() <= seek_time) {
+         return video_stream;
+       }
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h qtwebengine-5.15.10/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h
+--- a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-07-11 22:12:47.917192788 -0500
+@@ -29,6 +29,7 @@ extern "C" {
+ #include <libavformat/avformat.h>
+ #include <libavformat/avio.h>
+ #include <libavutil/avutil.h>
++#include <libavutil/channel_layout.h>
+ #include <libavutil/imgutils.h>
+ #include <libavutil/log.h>
+ #include <libavutil/mastering_display_metadata.h>
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/audio_file_reader.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/audio_file_reader.cc
+--- a/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -85,7 +85,7 @@ bool AudioFileReader::OpenDemuxer() {
+ }
+ 
+ bool AudioFileReader::OpenDecoder() {
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (codec) {
+     // MP3 decodes to S16P which we don't support, tell it to use S16 instead.
+     if (codec_context_->sample_fmt == AV_SAMPLE_FMT_S16P)
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -329,7 +329,7 @@ bool FFmpegAudioDecoder::ConfigureDecode
+     }
+   }
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec ||
+       avcodec_open2(codec_context_.get(), codec, &codec_options) < 0) {
+     DLOG(ERROR) << "Could not initialize audio decoder: "
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -59,7 +59,6 @@ static int64_t AVIOSeekOperation(void* o
+ }
+ 
+ void FFmpegGlue::InitializeFFmpeg() {
+-  av_register_all();
+ }
+ 
+ static void LogContainer(bool is_local_file,
+@@ -95,9 +94,6 @@ FFmpegGlue::FFmpegGlue(FFmpegURLProtocol
+   // Enable fast, but inaccurate seeks for MP3.
+   format_context_->flags |= AVFMT_FLAG_FAST_SEEK;
+ 
+-  // Ensures we can read out various metadata bits like vp8 alpha.
+-  format_context_->flags |= AVFMT_FLAG_KEEP_SIDE_DATA;
+-
+   // Ensures format parsing errors will bail out. From an audit on 11/2017, all
+   // instances were real failures. Solves bugs like http://crbug.com/710791.
+   format_context_->error_recognition |= AV_EF_EXPLODE;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -391,7 +391,7 @@ bool FFmpegVideoDecoder::ConfigureDecode
+   if (decode_nalus_)
+     codec_context_->flags2 |= AV_CODEC_FLAG2_CHUNKS;
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
+     ReleaseFFmpegResources();
+     return false;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/media_file_checker.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/media_file_checker.cc
+--- a/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -68,7 +68,7 @@ bool MediaFileChecker::Start(base::TimeD
+       auto context = AVStreamToAVCodecContext(format_context->streams[i]);
+       if (!context)
+         continue;
+-      AVCodec* codec = avcodec_find_decoder(cp->codec_id);
++      const AVCodec* codec = avcodec_find_decoder(cp->codec_id);
+       if (codec && avcodec_open2(context.get(), codec, nullptr) >= 0) {
+         auto loop = std::make_unique<FFmpegDecodingLoop>(context.get());
+         stream_contexts[i] = {std::move(context), std::move(loop)};
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc qtwebengine-5.15.10/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc
+--- a/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -203,7 +203,7 @@ int32_t H264DecoderImpl::InitDecode(cons
+   // a pointer |this|.
+   av_context_->opaque = this;
+ 
+-  AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
+   if (!codec) {
+     // This is an indication that FFmpeg has not been initialized or it has not
+     // been compiled/initialized with the correct set of codecs.
diff --git a/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch b/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch
new file mode 100644
index 0000000000000..bc24d5b9a29cb
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch
@@ -0,0 +1,14 @@
+--- a/src/buildtools/configure.json	2023-12-09 11:06:01.503058569 -0500
++++ b/src/buildtools/configure.json	2023-12-09 11:06:14.982361345 -0500
+@@ -779,11 +779,6 @@
+             "type": "warning",
+             "condition": "config.ios && config.simulator && config.device && features.build-qtpdf",
+             "message": "Building fat libray with device and simulator architectures will disable NEON."
+-        },
+-        {
+-            "type": "fatal",
+-            "condition": "features.webengine-system-ffmpeg && !libs.webengine-ffmpeg-support",
+-            "message": "Unmodified ffmpeg >= 5.0 is not supported. Please configure with -qt-webengine-ffmpeg."
+         }
+     ],
+     "summary": [
diff --git a/srcpkgs/qt5-webengine/template b/srcpkgs/qt5-webengine/template
index 8d2df1b5175ba..1687a77eb8a2f 100644
--- a/srcpkgs/qt5-webengine/template
+++ b/srcpkgs/qt5-webengine/template
@@ -1,14 +1,14 @@
 # Template file for 'qt5-webengine'
 pkgname=qt5-webengine
 version=5.15.16
-revision=1
+revision=2
 _version="${version}-lts"
 _chromium_commit=207c2ac45ca3386d153770c6b0d2ea2ec21ca880
 archs="x86_64* i686* armv[67]* ppc64* aarch64*"
 create_wrksrc=yes
 build_style=qmake
 configure_args="--
- -webengine-icu -webengine-ffmpeg -webengine-opus -webengine-webp
+ -webengine-icu -system-ffmpeg -webengine-opus -webengine-webp
  -webengine-pepper-plugins -webengine-printing-and-pdf -webengine-proprietary-codecs
  -webengine-pulseaudio -webengine-spellchecker -webengine-webrtc -webengine-geolocation
  -webengine-kerberos -no-webengine-embedded-build $(vopt_if sndio '' '-no')-webengine-sndio

From 954e35f6f452558e0fd600649f518812e946a737 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 061/113] qt5: revbump for ffmpeg6

---
 srcpkgs/qt5/template | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/srcpkgs/qt5/template b/srcpkgs/qt5/template
index ef6e437e02dbc..771872a54d67c 100644
--- a/srcpkgs/qt5/template
+++ b/srcpkgs/qt5/template
@@ -5,7 +5,7 @@ pkgname=qt5
 version=5.15.11+20231124
 # commit 4765fa1df7a837db9c1f89c4da0dd76b74bb5fab
 # base repo: https://invent.kde.org/qt/qt/qt5
-revision=1
+revision=2
 build_style=meta
 hostmakedepends="cmake clang flex perl glib-devel pkg-config
  python3 re2c ruby which"
@@ -246,7 +246,6 @@ do_configure() {
 	# opts+=" -v"
 	opts+=" -skip qtwebengine"
 	opts+=" -skip qtwebview"
-	opts+=" -skip qtdocgallery"
 	opts+=" -skip qtpim"
 	opts+=" -skip qtsystems"
 	opts+=" -skip qtspeech"

From 8e7bdc5d7bfe607d739ca624b9a74fef7a88a5d7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 062/113] qtav: revbump for ffmpeg4

---
 srcpkgs/qtav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qtav/template b/srcpkgs/qtav/template
index 775d5a139a9ef..2d00ad104355e 100644
--- a/srcpkgs/qtav/template
+++ b/srcpkgs/qtav/template
@@ -4,7 +4,7 @@ version=1.13.0
 revision=2
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel libass-devel libopenal-devel
+makedepends="ffmpeg4-devel libass-devel libopenal-devel
  libva-glx-devel libXv-devel pulseaudio-devel
  qt5-declarative-devel qt5-svg-devel
  qt5-quickcontrols"

From 8c56045e4bcc9f525ff5dd7e04a5216f3151dc35 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 063/113] retroarch: revbump for ffmpeg6

---
 srcpkgs/retroarch/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroarch/template b/srcpkgs/retroarch/template
index cb3125c5dbf1a..c65c26f7bf033 100644
--- a/srcpkgs/retroarch/template
+++ b/srcpkgs/retroarch/template
@@ -1,7 +1,7 @@
 # Template file for 'retroarch'
 pkgname=retroarch
 version=1.16.0.3
-revision=3
+revision=4
 build_style=configure
 configure_args="--prefix=/usr --sysconfdir=/etc --enable-networking
  --enable-udev --disable-builtinflac --disable-builtinglslang

From c04d5d0563e7e7109ff9f74f6303c05fafabb451 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 064/113] scrcpy: revbump for ffmpeg6

---
 srcpkgs/scrcpy/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/scrcpy/template b/srcpkgs/scrcpy/template
index ac18bc03418ce..f39a7f678ab35 100644
--- a/srcpkgs/scrcpy/template
+++ b/srcpkgs/scrcpy/template
@@ -1,7 +1,7 @@
 # Template file for 'scrcpy'
 pkgname=scrcpy
 version=2.1.1
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcompile_server=false
  -Dprebuilt_server=/usr/share/scrcpy/scrcpy-server-v${version}"

From d957a84f602665d9255e55a88a901cb50017ef24 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 17 Oct 2023 08:54:11 -0400
Subject: [PATCH 065/113] New package: spex-x replaces spek-alternative for
 ffmpeg6

---
 srcpkgs/spek-alternative                      |  1 +
 srcpkgs/{spek-alternative => spek-x}/template | 22 ++++++++++++-------
 2 files changed, 15 insertions(+), 8 deletions(-)
 create mode 120000 srcpkgs/spek-alternative
 rename srcpkgs/{spek-alternative => spek-x}/template (52%)

diff --git a/srcpkgs/spek-alternative b/srcpkgs/spek-alternative
new file mode 120000
index 0000000000000..76648236da701
--- /dev/null
+++ b/srcpkgs/spek-alternative
@@ -0,0 +1 @@
+spek-x
\ No newline at end of file
diff --git a/srcpkgs/spek-alternative/template b/srcpkgs/spek-x/template
similarity index 52%
rename from srcpkgs/spek-alternative/template
rename to srcpkgs/spek-x/template
index d7b55c776b1d4..3ded6c2c323e4 100644
--- a/srcpkgs/spek-alternative/template
+++ b/srcpkgs/spek-x/template
@@ -1,18 +1,18 @@
-# Template file for 'spek-alternative'
-pkgname=spek-alternative
-version=0.8.2.3
-revision=2
+# Template file for 'spek-x'
+pkgname=spek-x
+version=0.9.3
+revision=1
 build_style=gnu-configure
 hostmakedepends="automake gettext-devel intltool libtool pkg-config
  wxWidgets-common wxWidgets-gtk3-devel"
 makedepends="ffmpeg-devel wxWidgets-gtk3-devel"
 depends="ffmpeg"
 short_desc="Acoustic spectrum analyser"
-maintainer="Kartik Singh <kartik.ynwa@gmail.com>"
+maintainer="zlice <zlice555@gmail.com>"
 license="GPL-3.0-or-later"
-homepage="https://github.com/withmorten/spek-alternative"
-distfiles="https://github.com/withmorten/spek-alternative/archive/${version}.tar.gz"
-checksum="007ba4b84a310b078e378aa84c8e80783db5821437a757a488c3ecec377e6b2a"
+homepage="https://github.com/MikeWang000000/spek-x"
+distfiles="https://github.com/MikeWang000000/spek-x/archive/v${version}.tar.gz"
+checksum="7f4b109903333cdd310ab2b9176f0dc49a565891376e281a233d342cedf90ef7"
 
 CXXFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
 
@@ -22,3 +22,9 @@ export WX_CONFIG_NAME="wx-config-gtk3"
 pre_configure() {
 	NOCONFIGURE=1 ./autogen.sh
 }
+
+spek-alternative_package() {
+	depends="spek-x"
+	short_desc+=" - transitional dummy package"
+	build_style=meta
+}

From ea30adf1478e393e5a8d92c325803dedb70903cc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 066/113] ssr: revbump for ffmpeg4

---
 srcpkgs/ssr/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ssr/template b/srcpkgs/ssr/template
index 3097754e3cbe5..fa66d5b4736d4 100644
--- a/srcpkgs/ssr/template
+++ b/srcpkgs/ssr/template
@@ -5,7 +5,7 @@ revision=2
 build_style=cmake
 configure_args="-DWITH_QT5=ON"
 hostmakedepends="pkg-config"
-makedepends="alsa-lib-devel ffmpeg-devel glu-devel jack-devel pulseaudio-devel
+makedepends="alsa-lib-devel ffmpeg4-devel glu-devel jack-devel pulseaudio-devel
  qt5-tools-devel qt5-x11extras-devel libXinerama-devel v4l-utils-devel"
 depends="desktop-file-utils hicolor-icon-theme"
 short_desc="Simple Screen Recorder for programs and games"

From f178fde8f22a86cca84c023367b0c46a6e529975 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 067/113] synfig: revbump for ffmpeg6 and mlt7

---
 srcpkgs/synfig/patches/ffmpeg6.patch | 71 ++++++++++++++++++++++++++++
 srcpkgs/synfig/template              |  4 +-
 2 files changed, 73 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/synfig/patches/ffmpeg6.patch

diff --git a/srcpkgs/synfig/patches/ffmpeg6.patch b/srcpkgs/synfig/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..10780b42782f4
--- /dev/null
+++ b/srcpkgs/synfig/patches/ffmpeg6.patch
@@ -0,0 +1,71 @@
+--- a/src/modules/mod_libavcodec/trgt_av.cpp	2022-10-25 09:14:12.000000000 -0400
++++ b/src/modules/mod_libavcodec/trgt_av.cpp	2023-05-05 21:34:17.899194559 -0400
+@@ -38,6 +41,7 @@
+ extern "C"
+ {
+ #ifdef HAVE_LIBAVFORMAT_AVFORMAT_H
++#	include <libavcodec/avcodec.h>
+ #	include <libavformat/avformat.h>
+ #elif defined(HAVE_AVFORMAT_H)
+ #	include <avformat.h>
+@@ -155,11 +156,11 @@
+     }
+ 
+ 	bool open_video_stream() {
+-		if (avcodec_open2(video_context, NULL, NULL) < 0) {
++		if (avcodec_open2(video_context, nullptr, nullptr) < 0) {
+ 			synfig::error("Target_LibAVCodec: could not open video codec");
+ 			// seems the calling of avcodec_free_context after error will cause crash
+ 			// so just forget about this context
+-			video_context = NULL;
++			video_context = nullptr;
+ 			close();
+ 			return false;
+         }
+@@ -234,15 +235,21 @@
+ 		close();
+ 
+ 		if (!av_registered) {
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 			av_register_all();
++#endif
+ 			av_registered = true;
+ 		}
+ 
+ 		// guess format
+-		AVOutputFormat *format = av_guess_format(NULL, filename.c_str(), NULL);
++#if LIBAVCODEC_VERSION_MAJOR < 59 // FFMPEG < 5.0
++		AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#else
++		const AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#endif
+ 		if (!format) {
+ 			synfig::warning("Target_LibAVCodec: unable to guess the output format, defaulting to MPEG");
+-			format = av_guess_format("mpeg", NULL, NULL);
++			format = av_guess_format("mpeg", nullptr, nullptr);
+ 		}
+ 		if (!format) {
+ 			synfig::error("Target_LibAVCodec: unable to find 'mpeg' output format");
+@@ -254,6 +261,7 @@
+ 		context = avformat_alloc_context();
+ 		assert(context);
+ 		context->oformat = format;
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 		if (filename.size() + 1 > sizeof(context->filename)) {
+ 			synfig::error(
+ 				"Target_LibAVCodec: filename too long, max length is %d, filename is '%s'",
+@@ -263,6 +271,14 @@
+ 			return false;
+ 		}
+ 		memcpy(context->filename, filename.c_str(), filename.size() + 1);
++#else
++		context->url = av_strndup(filename.c_str(), filename.size());
++		if (!context->url) {
++			synfig::error("Target_LibAVCodec: cannot allocate space for filename");
++			close();
++			return false;
++		}
++#endif
+ 
+ 		packet = av_packet_alloc();
+ 		assert(packet);
diff --git a/srcpkgs/synfig/template b/srcpkgs/synfig/template
index d4d3e341a20bf..703cfd7ebac84 100644
--- a/srcpkgs/synfig/template
+++ b/srcpkgs/synfig/template
@@ -6,7 +6,7 @@ revision=4
 build_style=gnu-configure
 configure_args="--with-boost-libdir=${XBPS_CROSS_BASE}/usr/lib"
 hostmakedepends="boost-build ImageMagick pkg-config intltool"
-makedepends="ETL gettext-devel libxml++-devel mlt-devel libmagick-devel
+makedepends="ETL gettext-devel libxml++-devel mlt7-devel libmagick-devel
  libmng-devel boost-build boost-devel libopenexr-devel ffmpeg-devel"
 depends="ImageMagick"
 short_desc="CLI 2D vector and timeline-based animation software"
@@ -20,7 +20,7 @@ CXXFLAGS="-std=c++11 -DHAVE_LOCALE_H=1"
 
 synfig-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision}
-	 libopenexr-devel libxml++-devel mlt-devel"
+	 libopenexr-devel libxml++-devel mlt7-devel"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/bin/synfig-config

From 00f28741859ea65ce3cce6748f36ae4d521d60c6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 068/113] timg: revbump for ffmpeg6

---
 srcpkgs/timg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/timg/template b/srcpkgs/timg/template
index 2a2ab763d2fdd..8fb4327535ef9 100644
--- a/srcpkgs/timg/template
+++ b/srcpkgs/timg/template
@@ -1,7 +1,7 @@
 # Template file for 'timg'
 pkgname=timg
 version=1.4.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_OPENSLIDE_SUPPORT=off -Wno-dev"
 hostmakedepends="pkg-config git"

From e92d20186438d46654bb18c7e1a3fa49409f214d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 069/113] tvheadend: revbump for ffmpeg4

---
 srcpkgs/tvheadend/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tvheadend/template b/srcpkgs/tvheadend/template
index 9aea7de4ec705..012d31c4879ff 100644
--- a/srcpkgs/tvheadend/template
+++ b/srcpkgs/tvheadend/template
@@ -8,7 +8,7 @@ configure_args="--enable-dvbscan --disable-ffmpeg_static
 --disable-libx265_static --disable-libvpx_static --disable-libtheora_static
 --disable-libvorbis_static --disable-libfdkaac_static"
 hostmakedepends="gettext pkg-config python3 git which"
-makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg-devel"
+makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg4-devel"
 short_desc="TV streaming server"
 maintainer="lemmi <lemmi@nerd2nerd.org>"
 license="GPL-3.0-only"

From 8c09b06209b5ce5b4306d6b5e0a9ad8ad7ae59de Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 070/113] unpaper: update to 7.0.0.

---
 srcpkgs/unpaper/template | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/srcpkgs/unpaper/template b/srcpkgs/unpaper/template
index 38ed47a584016..1ff910e722afc 100644
--- a/srcpkgs/unpaper/template
+++ b/srcpkgs/unpaper/template
@@ -1,13 +1,13 @@
 # Template file for 'unpaper'
 pkgname=unpaper
-version=6.1
-revision=3
-build_style=gnu-configure
+version=7.0.0
+revision=1
+build_style=meson
+hostmakedepends="pkg-config meson libxslt"
+makedepends="ffmpeg-devel python3-Sphinx"
+short_desc="Post-processing tool for scanned sheets of paper"
 maintainer="Orphaned <orphan@voidlinux.org>"
-hostmakedepends="pkg-config libxslt"
-makedepends="ffmpeg-devel"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://www.flameeyes.eu/projects/unpaper"
-short_desc="A post-processing tool for scanned sheets of paper"
 distfiles="https://www.flameeyes.eu/files/${pkgname}-${version}.tar.xz"
-checksum=237c84f5da544b3f7709827f9f12c37c346cdf029b1128fb4633f9bafa5cb930
+checksum=2575fbbf26c22719d1cb882b59602c9900c7f747118ac130883f63419be46a80

From 9f77de9d27949eee5df2dfb41f381f98eeb6b2f7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 071/113] vice: revbump for ffmpeg4

---
 srcpkgs/vice/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vice/template b/srcpkgs/vice/template
index b1f866d35095e..4beab2c5f9ebd 100644
--- a/srcpkgs/vice/template
+++ b/srcpkgs/vice/template
@@ -26,7 +26,7 @@ makedepends="
 	$(vopt_if gtk3 gtk+3-devel)
 	$(vopt_if gtk3 pulseaudio-devel)
 	$(vopt_if gtk3 pango-devel)
-	$(vopt_if ffmpeg ffmpeg-devel)"
+	$(vopt_if ffmpeg ffmpeg4-devel)"
 short_desc="Emulator for C64, C128, CBM-II, PET, VIC20, Plus4 and C16"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"

From 3b8978ff0561ce0620afeec49ed56a6100989192 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 072/113] waypipe: revbump for ffmpeg6

---
 srcpkgs/waypipe/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waypipe/template b/srcpkgs/waypipe/template
index 6da88b21bf2a1..4da8058400b58 100644
--- a/srcpkgs/waypipe/template
+++ b/srcpkgs/waypipe/template
@@ -1,7 +1,7 @@
 # Template file for 'waypipe'
 pkgname=waypipe
 version=0.8.6
-revision=1
+revision=2
 build_style=meson
 # lto is off because it causes linking errors in armv6l and armv7l (due to NEON)
 configure_args="-Dwerror=false -Dwith_dmabuf=enabled -Dwith_lz4=enabled

From a807bb48a626be9a5a8bfb3907771522f4db8c2e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 073/113] xpra: revbump for ffmpeg6

---
 srcpkgs/xpra/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xpra/template b/srcpkgs/xpra/template
index 6bfe9be2db650..1eea2962bcb82 100644
--- a/srcpkgs/xpra/template
+++ b/srcpkgs/xpra/template
@@ -1,7 +1,7 @@
 # Template file for 'xpra'
 pkgname=xpra
 version=5.0.4
-revision=1
+revision=2
 build_style=python3-module
 make_build_args="--without-cuda_kernels --without-cuda_rebuild"
 make_install_args="$(vopt_with docs) ${make_build_args}"

From 253ecbb0d82f3665b60dbb9123026304178fe8dc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:07:40 -0400
Subject: [PATCH 074/113] nv-codec-headers: update to 12.0.16.0

---
 srcpkgs/nv-codec-headers/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/nv-codec-headers/template b/srcpkgs/nv-codec-headers/template
index 3d422a61e4891..251e057f826fb 100644
--- a/srcpkgs/nv-codec-headers/template
+++ b/srcpkgs/nv-codec-headers/template
@@ -1,6 +1,6 @@
 # Template file for 'nv-codec-headers'
 pkgname=nv-codec-headers
-version=11.1.5.1
+version=12.0.16.0
 revision=1
 build_style=gnu-makefile
 short_desc="FFmpeg version of headers required to interface with Nvidias codec APIs"
@@ -8,7 +8,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="MIT"
 homepage="http://git.videolan.org/?p=ffmpeg/nv-codec-headers.git"
 distfiles="https://github.com/FFmpeg/nv-codec-headers/archive/n${version}.tar.gz"
-checksum=d095fbd56aa93772471a323be0ebe65504a0f43f06c76a30b6d25da77b06ae9c
+checksum=2a1533b65f55f9da52956faf0627ed3b74868ac0c7f269990edd21369113b48f
 
 post_install() {
 	sed -n '4,25p' include/ffnvcodec/nvEncodeAPI.h > LICENSE

From 83d101eeafeb1f1689126724cbcbebdc2ab8b03b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:08:40 -0400
Subject: [PATCH 075/113] openimagedenoise: revbump for ffmpeg6

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index b792813dba7c2..109deb171c3f7 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,7 +1,7 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
 version=1.4.3
-revision=1
+revision=2
 archs="x86_64*"
 build_style=cmake
 hostmakedepends="ispc python3"

From f9697cd9206a899cffb0709f1fdef8883b611fb7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:31:45 -0400
Subject: [PATCH 076/113] shotcut: revbump for ffmpeg6

---
 srcpkgs/shotcut/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/shotcut/template b/srcpkgs/shotcut/template
index 33141fbd862d7..f46cb53b6bfb9 100644
--- a/srcpkgs/shotcut/template
+++ b/srcpkgs/shotcut/template
@@ -1,7 +1,7 @@
 # Template file for 'shotcut'
 pkgname=shotcut
 version=23.09.29
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSHOTCUT_VERSION=${version}"
 hostmakedepends="pkg-config qt6-tools-devel"

From fe68ec5e54b6d297640552624bc623f81baf9a44 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:30 -0400
Subject: [PATCH 077/113] shiboken2: revbump for qt5-5.15.11

---
 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch | 1 +
 srcpkgs/shiboken2/template                                 | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
 create mode 120000 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
new file mode 120000
index 0000000000000..efcf3249bd885
--- /dev/null
+++ b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1 @@
+../../python3-pyside2/patches/importlib-machinery-bypass.patch
\ No newline at end of file
diff --git a/srcpkgs/shiboken2/template b/srcpkgs/shiboken2/template
index 883d6a084d868..f3c06ec245a1f 100644
--- a/srcpkgs/shiboken2/template
+++ b/srcpkgs/shiboken2/template
@@ -1,7 +1,7 @@
 # Template file for 'shiboken2'
 pkgname=shiboken2
 version=5.15.10
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/shiboken2"
 build_style=cmake

From 262eaf0fb9727035790f27165d840e2ebfa549ec Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:53 -0400
Subject: [PATCH 078/113] python3-pyside2: revbump for qt5-5.15.11

---
 .../patches/importlib-machinery-bypass.patch      | 15 +++++++++++++++
 srcpkgs/python3-pyside2/template                  |  2 +-
 2 files changed, 16 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
new file mode 100644
index 0000000000000..64c429584776b
--- /dev/null
+++ b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1,15 @@
+Using this prevents an error around line 220 below it.
+"AttributeError: module 'importlib' has no attribute 'machinery'"
+The old backup logic is in place and compiles without issues.
+--- a/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:09:34.688912402 -0400
++++ b/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:10:03.395529582 -0400
+@@ -170,9 +170,6 @@
+
+     # 'zipstring_sequence' comes from signature.cpp
+     zipbytes = base64.b64decode(''.join(zipstring_sequence))
+-    if sys.version_info[0] >= 3:
+-        vzip = zipfile.ZipFile(io.BytesIO(zipbytes))
+-        return sys.meta_path, EmbeddableZipImporter(vzip)
+
+     # Old version for Python 2.7, only.
+     import os
diff --git a/srcpkgs/python3-pyside2/template b/srcpkgs/python3-pyside2/template
index 249efa9098842..52626436ce75f 100644
--- a/srcpkgs/python3-pyside2/template
+++ b/srcpkgs/python3-pyside2/template
@@ -1,7 +1,7 @@
 # Template file for 'python3-pyside2'
 pkgname=python3-pyside2
 version=5.15.10
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/pyside2"
 build_style=cmake

From 1d381c8fb04bc117cf732fa0df872f493c02c1fa Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:35 -0400
Subject: [PATCH 079/113] konqueror: revbump for ffmpeg6

---
 srcpkgs/konqueror/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/konqueror/template b/srcpkgs/konqueror/template
index 044dafa605ba6..63dd01fafc780 100644
--- a/srcpkgs/konqueror/template
+++ b/srcpkgs/konqueror/template
@@ -1,11 +1,11 @@
 # Template file for 'konqueror'
 pkgname=konqueror
 version=23.08.4
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DDESKTOPTOJSON_EXECUTABLE=/usr/bin/desktoptojson"
 hostmakedepends="extra-cmake-modules python3 qt5-host-tools qt5-qmake kdoctools
-kcoreaddons kconfig gettext"
+ kcoreaddons kconfig gettext"
 makedepends="qt5-devel qt5-webengine-devel qt5-declarative-devel
  qt5-webchannel-devel qt5-location-devel kcmutils-devel kdelibs4support-devel
  karchive-devel khtml-devel kdesu-devel kactivities5-devel"

From 1ae518f90e677a24509a315438359db4d5e25cbf Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:58 -0400
Subject: [PATCH 080/113] qt5-speech: revbump for qt5-5.15.11

---
 srcpkgs/qt5-speech/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-speech/template b/srcpkgs/qt5-speech/template
index 3ecd10d50650c..2d7d4d4d24535 100644
--- a/srcpkgs/qt5-speech/template
+++ b/srcpkgs/qt5-speech/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-speech'
 pkgname=qt5-speech
 version=5.15.7
-revision=2
+revision=3
 _commit=d32f4a479d38a11f547598004b975f4356424a16
 build_style=qmake
 configure_args="-- -flite -flite-alsa -speechd"

From 7efe5acbee46bdb2cd2561068a3b597f26f238dd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Jun 2023 08:20:22 -0400
Subject: [PATCH 081/113] gtk4: revbump for ffmpeg6

---
 srcpkgs/gtk4/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gtk4/template b/srcpkgs/gtk4/template
index 6a4e20357a86f..ec0c13d2cc5b0 100644
--- a/srcpkgs/gtk4/template
+++ b/srcpkgs/gtk4/template
@@ -1,7 +1,7 @@
 # Template file for 'gtk4'
 pkgname=gtk4
 version=4.12.3
-revision=1
+revision=2
 build_style=meson
 build_helper="gir"
 configure_args="-Dman-pages=true -Ddocumentation=true -Dbuild-tests=false

From 865a6149de7878de7e803127d109e0cd1b4ff417 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:28:26 -0400
Subject: [PATCH 082/113] siril: revbump for ffmpeg6

---
 srcpkgs/siril/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/siril/template b/srcpkgs/siril/template
index 84332f79d060d..62750dd247548 100644
--- a/srcpkgs/siril/template
+++ b/srcpkgs/siril/template
@@ -1,7 +1,7 @@
 # Template file for 'siril'
 pkgname=siril
 version=0.9.12
-revision=10
+revision=11
 build_style=gnu-configure
 hostmakedepends="pkg-config intltool autoconf automake gettext-devel"
 makedepends="fftw-devel libconfig-devel libopencv-devel libffms2-devel

From 1765e331fa5c13673e877f7df7c830b32d78935d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 22 Jun 2023 10:25:02 -0400
Subject: [PATCH 083/113] kdenlive: revbump for ffmpeg6

---
 srcpkgs/kdenlive/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kdenlive/template b/srcpkgs/kdenlive/template
index a0f3615c9c530..d63166f95c4d7 100644
--- a/srcpkgs/kdenlive/template
+++ b/srcpkgs/kdenlive/template
@@ -1,7 +1,7 @@
 # Template file for 'kdenlive'
 pkgname=kdenlive
 version=23.08.4
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="
  extra-cmake-modules kconfig kcoreaddons kdoctools pkg-config python3

From 23903a4a0af0d7d235f27be9dfb2810e4e23a8a2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:20:59 -0400
Subject: [PATCH 084/113] tracker-miners: revbump for ffmpeg6

---
 srcpkgs/tracker-miners/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tracker-miners/template b/srcpkgs/tracker-miners/template
index 0b97f47489f81..f196d2bf9e4a4 100644
--- a/srcpkgs/tracker-miners/template
+++ b/srcpkgs/tracker-miners/template
@@ -1,7 +1,7 @@
 # Template file for 'tracker-miners'
 pkgname=tracker-miners
 version=3.6.1
-revision=1
+revision=2
 build_style=meson
 build_helper=qemu
 # missing libgrss for miner_rss

From d7c550b2dd8b049847ded21f50b06e742881a097 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:21:21 -0400
Subject: [PATCH 085/113] mpd: revbump for ffmpeg6

---
 srcpkgs/mpd/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpd/template b/srcpkgs/mpd/template
index 4fd32b7be8c53..b8e2bd4c1b59c 100644
--- a/srcpkgs/mpd/template
+++ b/srcpkgs/mpd/template
@@ -1,7 +1,7 @@
 # Template file for 'mpd'
 pkgname=mpd
 version=0.23.15
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dopus=enabled -Dmikmod=enabled -Dneighbor=true
  -Dsoundcloud=enabled -Dpipe=true -Dtwolame=enabled -Dbzip2=enabled

From 151953f352181df5b777077368616e471554ea58 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:02 -0400
Subject: [PATCH 086/113] tg_owt: revbump for ffmpeg6

---
 srcpkgs/tg_owt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tg_owt/template b/srcpkgs/tg_owt/template
index 50bc8310b8859..c93262d5c5de6 100644
--- a/srcpkgs/tg_owt/template
+++ b/srcpkgs/tg_owt/template
@@ -1,7 +1,7 @@
 # Template file for 'tg_owt'
 pkgname=tg_owt
 version=0.0.0.20230921
-revision=1
+revision=2
 _commit=3bb3d757681e6cc5135aec6529a753dc3dcdcfb9
 _libyuv_commit=04821d1e7d60845525e8db55c7bcd41ef5be9406
 _abseil_commit=8c0b94e793a66495e0b1f34a5eb26bd7dc672db0

From d1a970d71e02c1ad4c6dbffe8e297448aea143cf Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:44 -0400
Subject: [PATCH 087/113] telegram-desktop: revbump for ffmpeg6

---
 srcpkgs/telegram-desktop/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/telegram-desktop/template b/srcpkgs/telegram-desktop/template
index 9bd94ce3781ff..d33fc62b10e38 100644
--- a/srcpkgs/telegram-desktop/template
+++ b/srcpkgs/telegram-desktop/template
@@ -1,7 +1,7 @@
 # Template file for 'telegram-desktop'
 pkgname=telegram-desktop
 version=4.11.2
-revision=1
+revision=2
 build_style=cmake
 build_helper="qemu gir"
 configure_args="-DTDESKTOP_API_ID=209235

From 0ccec09dcc1ac4608c7e035aa6b5fc5bdfbbab0e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:11:45 -0400
Subject: [PATCH 088/113] gst-plugins-bad1: revbump for ffmpeg6

---
 srcpkgs/gst-plugins-bad1/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index fcd3538cd5cde..976e2889b588e 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-plugins-bad1'
 pkgname=gst-plugins-bad1
 version=1.22.7
-revision=1
+revision=2
 build_helper="gir"
 build_style=meson
 configure_args="-Dpackage-origin=https://voidlinux.org -Ddoc=disabled

From 4d6e3a771d65d3be966ccae6ccf067ac532f5e86 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:12:09 -0400
Subject: [PATCH 089/113] openmw: revbump for ffmpeg6

---
 srcpkgs/openmw/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openmw/template b/srcpkgs/openmw/template
index 0abf5ff7cdbec..b57180f1a4446 100644
--- a/srcpkgs/openmw/template
+++ b/srcpkgs/openmw/template
@@ -1,7 +1,7 @@
 # Template file for 'openmw'
 pkgname=openmw
 version=0.48.0
-revision=2
+revision=3
 build_style=cmake
 _recast_commit=e75adf86f91eb3082220085e42dda62679f9a3ea
 _bullet_tag=3.17

From 985bc843dfcb6f21d8c394bb450061ddd63a06f0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:14:53 -0400
Subject: [PATCH 090/113] lms: revbump for ffmpeg6

---
 srcpkgs/lms/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/lms/template b/srcpkgs/lms/template
index e358f75902a98..3b21c458de519 100644
--- a/srcpkgs/lms/template
+++ b/srcpkgs/lms/template
@@ -1,7 +1,7 @@
 # Template file for 'lms'
 pkgname=lms
 version=3.42.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="wt-devel ffmpeg-devel boost-devel libconfig++-devel taglib-devel pam-devel libgraphicsmagick-devel gtest-devel libarchive-devel"

From e5c718eac4180a5c10669a1117baba361c0db146 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:18:18 -0400
Subject: [PATCH 091/113] freecad: DELETE

---
 srcpkgs/freecad/patches/001-include.patch     | 112 ------------------
 .../154-revert-gui-tmp-redirect-stderr.patch  |  68 -----------
 ...d63c8c9b1280978be841d04e68a0a55cceb9.patch |  30 -----
 srcpkgs/freecad/template                      |  12 +-
 4 files changed, 7 insertions(+), 215 deletions(-)
 delete mode 100644 srcpkgs/freecad/patches/001-include.patch
 delete mode 100644 srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
 delete mode 100644 srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch

diff --git a/srcpkgs/freecad/patches/001-include.patch b/srcpkgs/freecad/patches/001-include.patch
deleted file mode 100644
index 28b5af54999b9..0000000000000
--- a/srcpkgs/freecad/patches/001-include.patch
+++ /dev/null
@@ -1,112 +0,0 @@
-From 9a41845a417189776741297c50a3827ce292bc4f Mon Sep 17 00:00:00 2001
-From: Uwe <donovaly@users.noreply.github.com>
-Date: Sun, 3 Jul 2022 22:51:16 +0200
-Subject: [PATCH] [Part] OCCError.h: remove unneeded includes
-
-- also sort includes
----
- src/Mod/Part/App/OCCError.h             | 36 +++----------------------
- src/Mod/Part/App/OffsetCurvePyImp.cpp   | 12 ++++-----
- src/Mod/Part/App/OffsetSurfacePyImp.cpp | 10 +++----
- 3 files changed, 12 insertions(+), 46 deletions(-)
-
---- a/src/Mod/Part/App/OCCError.h
-+++ b/src/Mod/Part/App/OCCError.h
-@@ -23,36 +23,8 @@
- #ifndef _OCCError_h_
- #define _OCCError_h_
- 
--# include <Standard_Version.hxx>
- # include <Standard_Failure.hxx>
--# include <Standard_AbortiveTransaction.hxx>
--# include <Standard_ConstructionError.hxx>
--# if OCC_VERSION_HEX >= 0x060500
--# include <Standard_DefineException.hxx>
--# endif
--# include <Standard_DimensionError.hxx>
--# include <Standard_DimensionMismatch.hxx>
--# include <Standard_DivideByZero.hxx>
--# include <Standard_DomainError.hxx>
--# include <Standard_ImmutableObject.hxx>
--# include <Standard_LicenseError.hxx>
--# include <Standard_LicenseNotFound.hxx>
--# include <Standard_MultiplyDefined.hxx>
--# include <Standard_NegativeValue.hxx>
--# include <Standard_NoMoreObject.hxx>
--# include <Standard_NoSuchObject.hxx>
--# include <Standard_NotImplemented.hxx>
--# include <Standard_NullObject.hxx>
--# include <Standard_NullValue.hxx>
--# include <Standard_NumericError.hxx>
--# include <Standard_OutOfMemory.hxx>
--# include <Standard_OutOfRange.hxx>
--# include <Standard_Overflow.hxx>
--# include <Standard_ProgramError.hxx>
--# include <Standard_RangeError.hxx>
--# include <Standard_TooManyUsers.hxx>
--# include <Standard_TypeMismatch.hxx>
--# include <Standard_Underflow.hxx>
-+# include <Standard_Version.hxx>
- 
- #include <Mod/Part/PartGlobal.h>
- #include <Base/Console.h>
-@@ -88,4 +60,3 @@ PartExport extern PyObject* PartExceptio
- 
- #define PY_CATCH_OCC _PY_CATCH_OCC(return(NULL))
- #endif  // _OCCError_h_
--
---- a/src/Mod/Part/App/OffsetCurvePyImp.cpp
-+++ b/src/Mod/Part/App/OffsetCurvePyImp.cpp
-@@ -20,20 +20,20 @@
-  *                                                                         *
-  ***************************************************************************/
- 
--
- #include "PreCompiled.h"
- #ifndef _PreComp_
- # include <Geom_OffsetCurve.hxx>
- #endif
- 
--#include "OCCError.h"
--#include "Geometry.h"
-+#include <Base/GeometryPyCXX.h>
-+#include <Base/Vector3D.h>
-+#include <Base/VectorPy.h>
-+
- #include "OffsetCurvePy.h"
- #include "OffsetCurvePy.cpp"
-+#include "Geometry.h"
-+#include "OCCError.h"
- 
--#include <Base/GeometryPyCXX.h>
--#include <Base/VectorPy.h>
--#include <Base/Vector3D.h>
- 
- using namespace Part;
- 
---- a/src/Mod/Part/App/OffsetSurfacePyImp.cpp
-+++ b/src/Mod/Part/App/OffsetSurfacePyImp.cpp
-@@ -20,20 +20,16 @@
-  *                                                                         *
-  ***************************************************************************/
- 
--
- #include "PreCompiled.h"
- #ifndef _PreComp_
- # include <Geom_OffsetSurface.hxx>
- # include <memory>
- #endif
- 
--#include <Base/VectorPy.h>
--#include <Base/Vector3D.h>
--
- #include "OCCError.h"
--#include "Geometry.h"
--#include <Mod/Part/App/OffsetSurfacePy.h>
--#include <Mod/Part/App/OffsetSurfacePy.cpp>
-+#include "OffsetSurfacePy.h"
-+#include "OffsetSurfacePy.cpp"
-+
- 
- using namespace Part;
- 
diff --git a/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch b/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
deleted file mode 100644
index d6a9adabdec83..0000000000000
--- a/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
+++ /dev/null
@@ -1,68 +0,0 @@
-see https://github.com/FreeCAD/FreeCAD/commit/cfe94b00d3434f3e2c8b5114d2909f628c330fa8#commitcomment-71413407
-
-upstream: yes
-
-From 7b377a216b9185960e4cee980a6504dc1a755f50 Mon Sep 17 00:00:00 2001
-From: wmayer <wmayer@users.sourceforge.net>
-Date: Wed, 29 Jun 2022 15:19:18 +0200
-Subject: [PATCH] Gui: remove workaround for spnav 0.23 due to build failure
- with musl libc
-
----
- src/Gui/3Dconnexion/GuiNativeEventLinux.cpp | 27 ---------------------
- 1 file changed, 27 deletions(-)
-
---- a/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp
-+++ b/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp
-@@ -21,42 +21,17 @@
-  ***************************************************************************/
- 
- #include <FCConfig.h>
--#include <cstdio>
- 
- #include "GuiNativeEventLinux.h"
- 
- #include "GuiApplicationNativeEventAware.h"
- #include <Base/Console.h>
--#include <Base/FileInfo.h>
- #include <QMainWindow>
- 
- #include <QSocketNotifier>
- 
- #include <spnav.h>
- 
--namespace {
--class RedirectStdErr
--{
--public:
--    RedirectStdErr()
--        : fi(Base::FileInfo::getTempFileName())
--        , file(stderr)
--    {
--        stderr = fopen(fi.filePath().c_str(), "w");
--    }
--    ~RedirectStdErr()
--    {
--        fclose(stderr);
--        fi.deleteFile();
--        stderr = file;
--    }
--
--private:
--    Base::FileInfo fi;
--    FILE* file;
--};
--}
--
- Gui::GuiNativeEvent::GuiNativeEvent(Gui::GUIApplicationNativeEventAware *app)
- : GuiAbstractNativeEvent(app)
- {
-@@ -72,8 +47,6 @@ Gui::GuiNativeEvent::~GuiNativeEvent()
- 
- void Gui::GuiNativeEvent::initSpaceball(QMainWindow *window)
- {
--    // tmp. redirect stderr to a file to suppress an error message from spnav_open()
--    RedirectStdErr err;
-     Q_UNUSED(window)
-     if (spnav_open() == -1) {
-         Base::Console().Log("Couldn't connect to spacenav daemon. Please ignore if you don't have a spacemouse.\n");
diff --git a/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch b/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch
deleted file mode 100644
index d4acf370ca0a4..0000000000000
--- a/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-From fe02d63c8c9b1280978be841d04e68a0a55cceb9 Mon Sep 17 00:00:00 2001
-From: Roy-043 <70520633+Roy-043@users.noreply.github.com>
-Date: Thu, 29 Dec 2022 23:20:38 +0100
-Subject: [PATCH] Draft: update inspect.getargspec to inspect.getfullargspec
- (#8101)
-
----
- src/Mod/Draft/draftguitools/gui_snapper.py | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
---- a/src/Mod/Draft/draftguitools/gui_snapper.py
-+++ b/src/Mod/Draft/draftguitools/gui_snapper.py
-@@ -1426,7 +1426,7 @@ class Snapper:
-             Gui.Snapper.off()
-             self.ui.offUi()
-             if callback:
--                if len(inspect.getargspec(callback).args) > 1:
-+                if len(inspect.getfullargspec(callback).args) > 1:
-                     obj = None
-                     if self.snapInfo and ("Object" in self.snapInfo) and self.snapInfo["Object"]:
-                         obj = App.ActiveDocument.getObject(self.snapInfo["Object"])
-@@ -1445,7 +1445,7 @@ class Snapper:
-             Gui.Snapper.off()
-             self.ui.offUi()
-             if callback:
--                if len(inspect.getargspec(callback).args) > 1:
-+                if len(inspect.getfullargspec(callback).args) > 1:
-                     callback(None, None)
-                 else:
-                     callback(None)
diff --git a/srcpkgs/freecad/template b/srcpkgs/freecad/template
index c135701e38b9a..7d5165f760bab 100644
--- a/srcpkgs/freecad/template
+++ b/srcpkgs/freecad/template
@@ -1,7 +1,7 @@
 # Template file for 'freecad'
 pkgname=freecad
-version=0.20.2
-revision=7
+version=0.21.1
+revision=2
 build_wrksrc="FreeCAD-${version}"
 build_style=cmake
 pycompile_dirs="usr/lib/${pkgname}/Mod"
@@ -24,8 +24,10 @@ makedepends="python3-devel boost-devel libxerces-c-devel zlib-devel occt-devel
  coin3-devel libshiboken2-devel libspnav-devel pyside2-tools
  liblz4-devel libpyside2-python3-devel python3-matplotlib netcdf-devel
  jsoncpp-devel qt5-devel qt5-svg-devel qt5-tools-devel qt5-webkit-devel
- qt5-xmlpatterns-devel coin3-doc glew-devel python3-pivy"
-depends="python3-matplotlib python3-pyside2-webengine python3-pivy"
+ qt5-xmlpatterns-devel coin3-doc glew-devel python3-pivy qt5-webengine-devel
+ qt5-declarative-devel qt5-webchannel-devel qt5-location-devel"
+depends="python3-matplotlib python3-pyside2-webengine python3-pivy
+ python3-GitPython python3-Markdown"
 short_desc="General purpose 3D CAD modeler"
 maintainer="yopito <pierre.bourgin@free.fr>"
 license="LGPL-2.0-or-later"
@@ -35,7 +37,7 @@ distfiles="
  https://github.com/FreeCAD/FreeCAD/archive/${version}.tar.gz
  ${SOURCEFORGE_SITE}/cxx/pycxx-${_pycxxver}.tar.gz
 "
-checksum="46922f3a477e742e1a89cd5346692d63aebb2b67af887b3e463e094a4ae055da
+checksum="e9b1fd0323f101268c7f3be52db42e4a29222f2e306ae6c4a6fc309cb418d35a
  4b91e1e1141c23fbd5039df635c4bb6e75632168548f56b83ce177193c0c98c6"
 python_version=3
 patch_args="-Np1 -d ${build_wrksrc}"

From ed28d527b0fa3822eff0e6b34de247dd71cac038 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:47:18 -0400
Subject: [PATCH 092/113] libopenshot: revbump for ffmpeg6

---
 srcpkgs/libopenshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenshot/template b/srcpkgs/libopenshot/template
index 8e57c5f592169..7a8f4520e7892 100644
--- a/srcpkgs/libopenshot/template
+++ b/srcpkgs/libopenshot/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenshot'
 pkgname=libopenshot
 version=0.3.0
-revision=3
+revision=4
 build_style=cmake
 # Builds fail with Ruby-2.4.1
 configure_args="-DENABLE_RUBY=OFF -DUSE_SYSTEM_JSONCPP=ON"

From d5d6ab02c97b26507827f2c8b42f5b76f1245680 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:10:30 -0500
Subject: [PATCH 093/113] openimageio: revbump for ffmpeg6

---
 srcpkgs/openimageio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimageio/template b/srcpkgs/openimageio/template
index 3ce3f9e49d350..27d2131bc0a61 100644
--- a/srcpkgs/openimageio/template
+++ b/srcpkgs/openimageio/template
@@ -1,7 +1,7 @@
 # Template file for 'openimageio'
 pkgname=openimageio
 version=2.4.9.0
-revision=7
+revision=8
 build_style=cmake
 build_helper=qemu
 configure_args="-DUSE_QT=0 -DUSE_PYTHON=0 -DOIIO_BUILD_TESTS=0

From 302728444b9b2c083cacb381004f6ec2a7177207 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:11:57 -0500
Subject: [PATCH 094/113] synfigstudio: revbump for ffmpeg6

---
 srcpkgs/synfigstudio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/synfigstudio/template b/srcpkgs/synfigstudio/template
index 09e442da9a680..2bc017cedca6b 100644
--- a/srcpkgs/synfigstudio/template
+++ b/srcpkgs/synfigstudio/template
@@ -2,7 +2,7 @@
 # Should be kept in sync with 'synfig' and 'ETL'
 pkgname=synfigstudio
 version=1.4.4
-revision=4
+revision=5
 build_style=gnu-configure
 configure_args="--disable-update-mimedb"
 hostmakedepends="pkg-config intltool gettext synfig"

From 52a6cd7ff74c23cecc3b014a9552a6f046a06ff4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:12:32 -0500
Subject: [PATCH 095/113] gmic: revbump for ffmpeg6

---
 srcpkgs/gmic/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gmic/template b/srcpkgs/gmic/template
index fa37651bb6dee..24d10147e3aba 100644
--- a/srcpkgs/gmic/template
+++ b/srcpkgs/gmic/template
@@ -1,7 +1,7 @@
 # Template file for 'gmic'
 pkgname=gmic
 version=3.1.6
-revision=5
+revision=6
 _zart_hash=34ebf6cce0bafb98abe57cec83c4a02cd1abeca0
 create_wrksrc=yes
 build_wrksrc="src"

From 56fe73ae38b74c8870b2564f3215562f92f00ba8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:10 -0500
Subject: [PATCH 096/113] mixxx: revbump for ffmpeg6

---
 srcpkgs/mixxx/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mixxx/template b/srcpkgs/mixxx/template
index 6921996e4e77b..6a79b328c1abf 100644
--- a/srcpkgs/mixxx/template
+++ b/srcpkgs/mixxx/template
@@ -1,7 +1,7 @@
 # Template file for 'mixxx'
 pkgname=mixxx
 version=2.3.3
-revision=6
+revision=7
 build_style=cmake
 configure_args="-DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="extra-cmake-modules pkg-config protobuf qt5-host-tools qt5-qmake"

From 2783e80c834e491976609d7441c1110a0c4149b8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:28 -0500
Subject: [PATCH 097/113] musikcube: revbump for ffmpeg6

---
 srcpkgs/musikcube/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/musikcube/template b/srcpkgs/musikcube/template
index d9e6186e6697b..637952d50aca3 100644
--- a/srcpkgs/musikcube/template
+++ b/srcpkgs/musikcube/template
@@ -1,7 +1,7 @@
 # Template file for 'musikcube'
 pkgname=musikcube
 version=3.0.0
-revision=3
+revision=4
 build_style=cmake
 make_cmd=make
 configure_args="-DNO_NCURSESW=1"

From d352b3ddb0aaccfca7cfcfe269bf60453a5fbdad Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:45 -0500
Subject: [PATCH 098/113] electron24: revbump for ffmpeg6

---
 srcpkgs/electron24/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron24/template b/srcpkgs/electron24/template
index a9c865c19c989..b8613e4362bc7 100644
--- a/srcpkgs/electron24/template
+++ b/srcpkgs/electron24/template
@@ -1,7 +1,7 @@
 # Template file for 'electron24'
 pkgname=electron24
 version=24.3.0
-revision=2
+revision=3
 _nodever=18.14.0
 _chromiumver=112.0.5615.165
 archs="x86_64* aarch64*"

From 4af6f327c7544149fe1be2aee5668005dfad3315 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:00 -0500
Subject: [PATCH 099/113] electron19: revbump for ffmpeg6

---
 srcpkgs/electron19/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron19/template b/srcpkgs/electron19/template
index b18bc792c8221..29fb34e254eea 100644
--- a/srcpkgs/electron19/template
+++ b/srcpkgs/electron19/template
@@ -1,7 +1,7 @@
 # Template file for 'electron19'
 pkgname=electron19
 version=19.0.8
-revision=4
+revision=5
 _nodever=16.14.2
 _chromiumver=102.0.5005.125
 archs="x86_64* aarch64* ppc64le*"

From d873f2a43471e29d31dc1b27de59a8d8887101df Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:13 -0500
Subject: [PATCH 100/113] wf-recorder: revbump for ffmpeg6

---
 srcpkgs/wf-recorder/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/wf-recorder/template b/srcpkgs/wf-recorder/template
index 08f986b031006..63c45cf4b814d 100644
--- a/srcpkgs/wf-recorder/template
+++ b/srcpkgs/wf-recorder/template
@@ -1,7 +1,7 @@
 # Template file for 'wf-recorder'
 pkgname=wf-recorder
 version=0.4.1
-revision=2
+revision=3
 build_style=meson
 hostmakedepends="pkg-config scdoc wayland-devel"
 makedepends="wayland-protocols wayland-devel ffmpeg-devel libgbm-devel x264-devel

From 5be2ffbe823b91c5ab61eef86822532a7d39d3c8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:26 -0500
Subject: [PATCH 101/113] obs: revbump for ffmpeg6

---
 srcpkgs/obs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/obs/template b/srcpkgs/obs/template
index b343f1131bfcf..a25a67433e285 100644
--- a/srcpkgs/obs/template
+++ b/srcpkgs/obs/template
@@ -1,7 +1,7 @@
 # Template file for 'obs'
 pkgname=obs
 version=30.0.0
-revision=2
+revision=3
 archs="i686* x86_64* ppc64le* aarch64* riscv64*"
 build_style=cmake
 configure_args="-DOBS_VERSION_OVERRIDE=${version} -DENABLE_JACK=ON

From 58f2b9f404edf13492a26443486652700782e8fb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:36 -0500
Subject: [PATCH 102/113] mlt7: revbump for ffmpeg6

---
 srcpkgs/mlt7/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mlt7/template b/srcpkgs/mlt7/template
index 98f302ad3a516..7eb8c00fa1580 100644
--- a/srcpkgs/mlt7/template
+++ b/srcpkgs/mlt7/template
@@ -1,7 +1,7 @@
 # Template file for 'mlt7'
 pkgname=mlt7
 version=7.20.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DSWIG_PYTHON=ON -DMOD_QT6=ON"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which

From 05bd55f024441423de15e44dc8bc2999ebcd4b04 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:48 -0500
Subject: [PATCH 103/113] qt6-multimedia: revbump for ffmpeg6

---
 srcpkgs/qt6-multimedia/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-multimedia/template b/srcpkgs/qt6-multimedia/template
index 67a577e1300fe..1da626ecf515a 100644
--- a/srcpkgs/qt6-multimedia/template
+++ b/srcpkgs/qt6-multimedia/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-multimedia'
 pkgname=qt6-multimedia
 version=6.6.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DQT_FEATURE_gstreamer=ON"
 hostmakedepends="perl qt6-declarative-host-tools pkg-config qt6-shadertools"

From 3894eedf87f30b1380cf4a3e85aa4bae88e9e293 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:00:15 -0500
Subject: [PATCH 104/113] baresip: revbump for ffmpeg6

---
 srcpkgs/baresip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/baresip/template b/srcpkgs/baresip/template
index 12c8954ef7b9b..b16b67beab8d2 100644
--- a/srcpkgs/baresip/template
+++ b/srcpkgs/baresip/template
@@ -1,7 +1,7 @@
 # Template file for 'baresip'
 pkgname=baresip
 version=3.6.0
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config glib-devel"
 makedepends="libgsm-devel libpng-devel openssl-devel libsndfile-devel

From 030d6940e5b59e6412b495a986e2bcdfeff8ba74 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:30 -0500
Subject: [PATCH 105/113] QMPlay2: revbump for ffmpeg6

---
 srcpkgs/QMPlay2/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/QMPlay2/template b/srcpkgs/QMPlay2/template
index 46c80f64a1349..942258ce60fb7 100644
--- a/srcpkgs/QMPlay2/template
+++ b/srcpkgs/QMPlay2/template
@@ -1,7 +1,7 @@
 # Template file for 'QMPlay2'
 pkgname=QMPlay2
 version=23.10.22
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools"
 makedepends="alsa-lib-devel ffmpeg-devel libass-devel libcdio-devel libgme-devel

From 3bda07b71ac0a5fcaace092b50162ae61983f316 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:34 -0500
Subject: [PATCH 106/113] alsa-plugins: revbump for ffmpeg6

---
 srcpkgs/alsa-plugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/alsa-plugins/template b/srcpkgs/alsa-plugins/template
index a5708a7d82a8f..7bfdad046c483 100644
--- a/srcpkgs/alsa-plugins/template
+++ b/srcpkgs/alsa-plugins/template
@@ -1,7 +1,7 @@
 # Template file for 'alsa-plugins'
 pkgname=alsa-plugins
 version=1.2.7.1
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--disable-maemo-plugin"
 hostmakedepends="pkg-config"

From dac47bcfb98d7b8693b6d672976d9a0b425163e8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:43 -0500
Subject: [PATCH 107/113] minidlna: revbump for ffmpeg6

---
 srcpkgs/minidlna/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/minidlna/template b/srcpkgs/minidlna/template
index 5fa929f3a0c12..742991ecd04af 100644
--- a/srcpkgs/minidlna/template
+++ b/srcpkgs/minidlna/template
@@ -1,7 +1,7 @@
 # Template file for 'minidlna'
 pkgname=minidlna
 version=1.3.3
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="
  --sbindir=/usr/bin

From 3ce8757ed5ef9c23b57af48058ecd10244b2d64d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 17:57:47 -0500
Subject: [PATCH 108/113] mpv: revbump for ffmpeg6

---
 srcpkgs/mpv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpv/template b/srcpkgs/mpv/template
index 4948d1e332cb8..1ac1b167af189 100644
--- a/srcpkgs/mpv/template
+++ b/srcpkgs/mpv/template
@@ -1,7 +1,7 @@
 # Template file for 'mpv'
 pkgname=mpv
 version=0.36.0
-revision=4
+revision=5
 build_style=meson
 configure_args="-Dcdda=enabled -Ddvbin=enabled -Ddvdnav=enabled
  -Dlibmpv=true -Dcplugins=enabled

From 9c30484fb352e583ac6a16c164240a40d6e98049 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 17:59:29 -0500
Subject: [PATCH 109/113] qimgv: revbump for ffmpeg6

---
 srcpkgs/qimgv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qimgv/template b/srcpkgs/qimgv/template
index dd341dfe1bfce..8a7e1c081ef12 100644
--- a/srcpkgs/qimgv/template
+++ b/srcpkgs/qimgv/template
@@ -1,7 +1,7 @@
 # Template file for 'qimgv'
 pkgname=qimgv
 version=1.0.2
-revision=3
+revision=4
 build_style=cmake
 configure_args="$(vopt_if video -DVIDEO_SUPPORT=ON -DVIDEO_SUPPORT=OFF)
  $(vopt_if scale -DOPENCV_SUPPORT=ON -DOPENCV_SUPPORT=OFF)

From 282c4a387351a0a52bac690cd93dabb842d133e7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 18:00:36 -0500
Subject: [PATCH 110/113] kfilemetadata5: revbump for ffmpeg6

---
 srcpkgs/kfilemetadata5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kfilemetadata5/template b/srcpkgs/kfilemetadata5/template
index 28430f112ab5d..593d2723d95d1 100644
--- a/srcpkgs/kfilemetadata5/template
+++ b/srcpkgs/kfilemetadata5/template
@@ -1,7 +1,7 @@
 # Template file for 'kfilemetadata5'
 pkgname=kfilemetadata5
 version=5.112.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="kcoreaddons extra-cmake-modules pkg-config qt5-host-tools qt5-qmake
  gettext kcoreaddons python3"

From 67940586728b0a7e38da739dfff7308ed32e27ee Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 8 Dec 2023 11:46:01 -0500
Subject: [PATCH 111/113] vba-m: revbump for ffmpeg6

---
 srcpkgs/vba-m/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vba-m/template b/srcpkgs/vba-m/template
index 52efeede1dcba..3e0760398905c 100644
--- a/srcpkgs/vba-m/template
+++ b/srcpkgs/vba-m/template
@@ -2,7 +2,7 @@
 pkgname=vba-m
 reverts=1292_2
 version=2.1.8
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_GTK=TRUE -DENABLE_FFMPEG=TRUE -DENABLE_LINK=TRUE -DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="gettext pkg-config unzip zip yasm wxWidgets-gtk3-devel"

From bbe63e7a58eb535639ad949ba17f058d47c4f7dc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 8 Dec 2023 11:46:19 -0500
Subject: [PATCH 112/113] dolphin-emu: revbump for ffmpeg6

---
 srcpkgs/dolphin-emu/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/dolphin-emu/template b/srcpkgs/dolphin-emu/template
index 862d3ae964eec..a7ae0efb58fb7 100644
--- a/srcpkgs/dolphin-emu/template
+++ b/srcpkgs/dolphin-emu/template
@@ -1,7 +1,7 @@
 # Template file for 'dolphin-emu'
 pkgname=dolphin-emu
 version=5.0.19368
-revision=3
+revision=4
 _dolphin_commit=dadbeb4bae7e7fa23af2b46e0add4143094dc107
 _mgba_commit=44e074a15e9651481f7f652ac006a7c9d58cbeb9
 _googletest_commit=be03d00f5f0cc3a997d1a368bee8a1fe93651f48

From c3e5f8a3bfc83905ac210dc06c850a2a96efc27c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 19 Dec 2023 15:38:51 -0500
Subject: [PATCH 113/113] qtox: revbump for ffmpeg4

---
 srcpkgs/qtox/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtox/template b/srcpkgs/qtox/template
index bb70e7f51240a..755e4462bc013 100644
--- a/srcpkgs/qtox/template
+++ b/srcpkgs/qtox/template
@@ -1,13 +1,13 @@
 # Template file for 'qtox'
 pkgname=qtox
 version=1.17.6
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DUPDATE_CHECK=OFF
  -DGIT_DESCRIBE=${version}
  $(vopt_if snorenotify -DDESKTOP_NOTIFICATIONS=ON)"
 hostmakedepends="pkg-config qt5-host-tools qt5-devel"
-makedepends="ffmpeg-devel libexif-devel libopenal-devel libsodium-devel
+makedepends="ffmpeg4-devel libexif-devel libopenal-devel libsodium-devel
  libvpx-devel opus-devel qrencode-devel qt5-svg-devel sonnet-devel
  sqlcipher-devel toxcore-devel
  $(vopt_if snorenotify snorenotify-devel)"

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (50 preceding siblings ...)
  2023-12-29 17:47 ` [PR PATCH] [Updated] " zlice
@ 2024-01-05 13:07 ` zlice
  2024-01-11 16:52 ` zlice
                   ` (45 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2024-01-05 13:07 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 4019 bytes --]

There is an updated pull request by zlice against master on the void-packages repository

https://github.com/zlice/void-packages ffmpeg6-split
https://github.com/void-linux/void-packages/pull/43761

ffmpeg6 split
[ci skip]


#### Testing the changes

- I tested the changes in this PR: **YES**

main testing has been vaapi in Firefox Nightly and enc/dec in Shotcut on Intel A770

#### New package

- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**

#### Local build testing

- I built this PR locally for my native architecture, **x86_64**

#### Discussion

Continuation of https://github.com/void-linux/void-packages/pull/36315

`libavresample` is deprecated, but marked as a dependency when trying to build other packages and install `ffmpeg`(6). I think the right way to handle this is make a meta package and the add to removals?


##### Commit naming / misc

~~Commits are 'dirty' right now, running with [gstreamer 1.22.1 updates](https://github.com/void-linux/void-packages/pull/42861) and [Intel OpenCL](https://github.com/void-linux/void-packages/pull/43084). This will also make [intel packages pr](https://github.com/void-linux/void-packages/pull/41132) obsolete.~~ (see Requirements below)

Maintainer for previous ffmpeg(4) was orphaned, I can put my name in there if that matters, though I don't exactly see myself keeping up on ffmpeg.

~~This updates QT5 which looks like it is usually hosted by Johnny. Not sure if there's any reason to stay there or these sources are fine.~~ Using qt5.15.11 now, revbumps and some patches.

##### STILL FFMPEG4

These are a mix of emulators, games and/or older packages.

- attract (multiple patches in master)
- audacity (https://github.com/audacity/audacity/issues/2305 and https://sourceforge.net/p/portmedia/wiki/portsmf/ is 'beta')
- ccextractor (master patches? no release)
- vice
- kodi
- mlt (only dep left is flowblade)
- ~~synfig (mlt)~~ (work with mlt7, bump synfigstudio)
- tvheadend
- ssr
- ~~spek-alternative~~ (replace with spek-x)
- ppsspp
- olive
- moc
- mediastreamer
- libextractor
- idjc
- hedgewars
- ~~ffmpegthumbnailer~~ (patches for moviedecoder.xxx files)
- ~~ffmpegthumbs~~ (latest compiles)
- deadbeef
- omxplayer
- qtav (fork has ffmpeg 5 patch - https://github.com/cmguo/QtAV)
- `vlc` (vlc4 will support ffmpeg5, there's a patch to build 3.x with ffmpeg5 but it will lack vaapi)
- `osg` (OpenSceneGraph plus `xine-lib`)


##### HAVE NOT BUILT YET

- omxplayer (rpi only? ffmpeg4)
- kodi (big, but ffmpeg4)


##### UPDATED (for ffmpeg6)

- ~~blender: update to 3.5.1~~ ~~will be revbump with~~ https://github.com/void-linux/void-packages/pull/43992
- unpaper: update to 7.0.0.
- guvcview: update to 2.0.8.
- ~~qt5: update to 5.15.8~~ updated by another PR to 5.15.11
- ~~qt5-webengine: update to 5.18.15~~ updated by another PR to 5.15.16 (some patching for ffmpeg build)
- ~~shiboken2: revbump for qt5.15.8 (patch)~~ updated by another PR to 5.15.10
- ~~python3-pyside2: update to 5.15.8 (patch)~~ updated by another PR to 5.15.10
- New package: spex-x replaces spek-alternative for ffmpeg-6.0


##### Requirements

- ~~[gstreamer 1.22.2](https://github.com/void-linux/void-packages/pull/42861)~~ - a few packages use ffmpeg-devel and require a revbump

- ~~[Intel Packages](https://github.com/void-linux/void-packages/pull/41132) [Intel Packages v2](https://github.com/void-linux/void-packages/pull/47330) - ffmpeg4 uses different libraries than 6 (libmfx / Intel-MediaSDK vs only oneVPL that Intel is moving to), both are included here~~. Using replacement oneVPL from OBS update.

- ~~[shotcut 23.05.14](https://github.com/void-linux/void-packages/pull/44260)~~

- https://github.com/void-linux/void-packages/pull/44781 will remove from this PR

A patch file from https://github.com/void-linux/void-packages/pull/43761.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ffmpeg6-split-43761.patch --]
[-- Type: text/x-diff, Size: 220896 bytes --]

From ec4080e9934bd4e3f36db20608d40619962b811c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:16:56 -0400
Subject: [PATCH 001/113] ffmpeg: update to 6.0.1.

---
 common/shlibs                                 | 26 +++++---
 srcpkgs/ffmpeg/files/altivec.patch            | 60 -------------------
 .../patches/armv5tel-floating-point.patch     | 18 ------
 ...h-libavcodec-libsvtav1-ten_bit_format.diff | 40 -------------
 .../workaround-mesa-readeon-vaapi-bug.patch   | 28 ---------
 srcpkgs/ffmpeg/template                       | 38 ++++++------
 6 files changed, 37 insertions(+), 173 deletions(-)
 delete mode 100644 srcpkgs/ffmpeg/files/altivec.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 delete mode 100644 srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch

diff --git a/common/shlibs b/common/shlibs
index 9d46b9376971b..c1d7e79ab4d55 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -386,15 +386,23 @@ libid3tag.so.0 libid3tag-0.15.1b_1
 libgif.so.7 giflib-5.1.0_1
 libImlib2.so.1 imlib2-1.4.2_1
 libmp3lame.so.0 lame-3.98.2_1
-libavdevice.so.58 libavdevice-4.0_1
-libavformat.so.58 libavformat-4.0_1
-libswscale.so.5 libswscale-4.0_1
-libswresample.so.3 libswresample-4.0_1
-libavresample.so.4 libavresample-4.0_1
-libpostproc.so.55 libpostproc-4.0_1
-libavcodec.so.58 libavcodec-4.0_1
-libavutil.so.56 libavutil-4.0_1
-libavfilter.so.7 libavfilter-4.0_1
+libavdevice.so.60 libavdevice-6.0_1
+libavformat.so.60 libavformat-6.0_1
+libswscale.so.7 libswscale-6.0_1
+libswresample.so.4 libswresample-6.0_1
+libpostproc.so.57 libpostproc-6.0_1
+libavcodec.so.60 libavcodec-6.0_1
+libavutil.so.58 libavutil-6.0_1
+libavfilter.so.9 libavfilter-6.0_1
+libavdevice.so.58 libavdevice4-4.0_1
+libavformat.so.58 libavformat4-4.0_1
+libswscale.so.5 libswscale4-4.0_1
+libswresample.so.3 libswresample4-4.0_1
+libavresample.so.4 libavresample4-4.0_1
+libpostproc.so.55 libpostproc4-4.0_1
+libavcodec.so.58 libavcodec4-4.0_1
+libavutil.so.56 libavutil4-4.0_1
+libavfilter.so.7 libavfilter4-4.0_1
 libSDL-1.2.so.0 SDL-1.2.14_1
 libSDL_image-1.2.so.0 SDL_image-1.2.10_1
 libx264.so.157 x264-20190507.2245_1
diff --git a/srcpkgs/ffmpeg/files/altivec.patch b/srcpkgs/ffmpeg/files/altivec.patch
deleted file mode 100644
index 9c57200463320..0000000000000
--- a/srcpkgs/ffmpeg/files/altivec.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-revert some altivec specific change on all ppc* except ppc64le*
-
-q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
-conditionally, for ppc* but not ppc64le* (the new code is valid for
-POWER8 VSX which LE targets as a baseline but not BE)"
-
-
-This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
----
- libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
- 1 file changed, 20 insertions(+), 4 deletions(-)
-
-diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
-index 536545293d..c1e2852adb 100644
---- a/libswscale/ppc/yuv2rgb_altivec.c
-+++ b/libswscale/ppc/yuv2rgb_altivec.c
-@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-     vector signed short R1, G1, B1;                                           \
-     vector unsigned char R, G, B;                                             \
-                                                                               \
-+    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
-+    vector unsigned char align_perm;                                          \
-+                                                                              \
-     vector signed short lCY       = c->CY;                                    \
-     vector signed short lOY       = c->OY;                                    \
-     vector signed short lCRV      = c->CRV;                                   \
-@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
-                                                                               \
-         for (j = 0; j < w / 16; j++) {                                        \
--            y0 = vec_xl(0, y1i);                                              \
-+            y1ivP = (const vector unsigned char *) y1i;                       \
-+            y2ivP = (const vector unsigned char *) y2i;                       \
-+            uivP  = (const vector unsigned char *) ui;                        \
-+            vivP  = (const vector unsigned char *) vi;                        \
-+                                                                              \
-+            align_perm = vec_lvsl(0, y1i);                                    \
-+            y0 = (vector unsigned char)                                       \
-+                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
-                                                                               \
--            y1 = vec_xl(0, y2i);                                              \
-+            align_perm = vec_lvsl(0, y2i);                                    \
-+            y1 = (vector unsigned char)                                       \
-+                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
-                                                                               \
--            u = (vector signed char) vec_xl(0, ui);                           \
-+            align_perm = vec_lvsl(0, ui);                                     \
-+            u = (vector signed char)                                          \
-+                    vec_perm(uivP[0], uivP[1], align_perm);                   \
-                                                                               \
--            v = (vector signed char) vec_xl(0, vi);                           \
-+            align_perm = vec_lvsl(0, vi);                                     \
-+            v = (vector signed char)                                          \
-+                    vec_perm(vivP[0], vivP[1], align_perm);                   \
-                                                                               \
-             u = (vector signed char)                                          \
-                     vec_sub(u,                                                \
--- 
-2.27.0
-
diff --git a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
deleted file mode 100644
index 9a55178c74f0f..0000000000000
--- a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
-+++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
-@@ -39,6 +39,15 @@
- #endif
- #include <fenv.h>
- 
-+#if (FE_ALL_EXCEPT == 0)
-+/* E.g. ARM soft float does not define these */
-+#define FE_INVALID    0
-+#define FE_DIVBYZERO  0
-+#define FE_OVERFLOW   0
-+#define FE_UNDERFLOW  0
-+#define FE_INEXACT    0
-+#endif
-+
- #if CONFIG_LIBFONTCONFIG
- #include <fontconfig/fontconfig.h>
- #endif
diff --git a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
deleted file mode 100644
index aa948f7a8a2df..0000000000000
--- a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
+++ /dev/null
@@ -1,40 +0,0 @@
-#==================================================================================================
-# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
-# From: Christopher Degawa <christopher.degawa@intel.com>
-# Date: Thu, 20 Oct 2022 22:55:27 -0500
-# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
-#
-# compressed_ten_bit_format has been deprecated upstream and has no effect
-# and can be removed. Plus, technically it was never used in the first place
-# since it would require the app (ffmpeg) to set it and do additional
-# processing of the input frames.
-#
-# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
-#
-# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
-#==================================================================================================
---- a/libavcodec/libsvtav1.c
-+++ b/libavcodec/libsvtav1.c
-@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
- 
- static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
- {
--    const int    pack_mode_10bit =
--        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
--    const size_t luma_size_8bit  =
--        config->source_width * config->source_height * (1 << pack_mode_10bit);
--    const size_t luma_size_10bit =
--        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
-+    const size_t luma_size = config->source_width * config->source_height *
-+        (config->encoder_bit_depth > 8 ? 2 : 1);
- 
-     EbSvtIOFormat *in_data;
- 
--    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
-+    svt_enc->raw_size = luma_size * 3 / 2;
- 
-     // allocate buffer for in and out
-     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
--- 
-GitLab
-
diff --git a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
deleted file mode 100644
index 00e3f68a415b8..0000000000000
--- a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
-From: Rainer Hochecker <fernetmenta@online.de>
-Date: Sat, 26 Jan 2019 19:48:35 +0100
-Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
-
-This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
-It was hit frequently when watching h264 channels received via DVB-X.
-Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
----
- libavcodec/vaapi_h264.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
-index 5854587a255..f12fdc457a4 100644
---- a/libavcodec/vaapi_h264.c
-+++ b/libavcodec/vaapi_h264.c
-@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
-     H264SliceContext *sl = &h->slice_ctx[0];
-     int ret;
- 
-+    if (pic->nb_slices == 0) {
-+        ret = AVERROR_INVALIDDATA;
-+        goto finish;
-+    }
-+
-     ret = ff_vaapi_decode_issue(avctx, pic);
-     if (ret < 0)
-         goto finish;
diff --git a/srcpkgs/ffmpeg/template b/srcpkgs/ffmpeg/template
index 5968a09b1f12d..52fcf4d68797a 100644
--- a/srcpkgs/ffmpeg/template
+++ b/srcpkgs/ffmpeg/template
@@ -1,15 +1,15 @@
 # Template file for 'ffmpeg'
 # audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
 pkgname=ffmpeg
-version=4.4.4
-revision=5
+version=6.0.1
+revision=1
 short_desc="Decoding, encoding and streaming software"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="https://www.ffmpeg.org"
 changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
 distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
-checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+checksum=9b16b8731d78e596b4be0d720428ca42df642bb2d78342881ff7f5bc29fc9623
 
 hostmakedepends="pkg-config perl"
 makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
@@ -26,12 +26,13 @@ makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-deve
  $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
  $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
  $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
- $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers Vulkan-Tools Vulkan-ValidationLayers')
+ $(vopt_if onevpl 'oneVPL oneVPL-devel')
  $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
 depends="ffplay>=${version}_${revision}"
 
 build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
- dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec onevpl"
 build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
 desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
 desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
@@ -39,9 +40,13 @@ desc_option_sofa="Enable support for AES SOFA"
 desc_option_webp="Enable support for WebP"
 
 case "$XBPS_TARGET_MACHINE" in
-	i686*|x86_64*)
-		hostmakedepends+=" nasm"
+	i686*)
 		build_options_default+=" vaapi vdpau nvenc nvdec"
+		hostmakedepends+=" nasm"
+		;;
+	x86_64*)
+		hostmakedepends+=" nasm"
+		build_options_default+=" vaapi vdpau nvenc nvdec onevpl"
 		;;
 	ppc64*) build_options_default+=" vaapi vdpau";;
 	mips*) CFLAGS="-mnan=legacy";;
@@ -115,18 +120,19 @@ do_configure() {
 		$(vopt_enable x265 libx265) \
 		$(vopt_enable v4l2 libv4l2) \
 		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
-		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		--enable-libbs2b --enable-libvidstab \
 		$(vopt_enable dav1d libdav1d) \
 		$(vopt_enable zimg libzimg) \
 		$(vopt_enable webp libwebp) \
 		$(vopt_enable sofa libmysofa) \
 		$(vopt_enable vulkan) \
+		$(vopt_enable onevpl libvpl) \
 		$(vopt_enable drm libdrm) \
 		$(vopt_enable svtav1 libsvtav1) \
 		$(vopt_enable srt libsrt) \
 		$(vopt_enable rist librist) \
-		$(vopt_if nvenc '--enable-nvenc') \
-		$(vopt_if nvdec '--enable-nvdec')
+		$(vopt_enable nvenc nvenc) \
+		$(vopt_enable nvdec nvdec)
 }
 
 do_build() {
@@ -153,10 +159,8 @@ libavdevice_package() {
 }
 
 libavresample_package() {
-	short_desc="FFmpeg audio resampling library"
-	pkg_install() {
-		vmove "usr/lib/libavresample.so.*"
-	}
+	short_desc="Package deprecated, removal needed"
+	build_style=meta
 }
 
 libavformat_package() {
@@ -210,15 +214,13 @@ ffmpeg-devel_package() {
 		libavfilter>=${version}_${revision}
 		libpostproc>=${version}_${revision}
 		libswscale>=${version}_${revision}
-		libswresample>=${version}_${revision}
-		libavresample>=${version}_${revision}"
+		libswresample>=${version}_${revision}"
 	short_desc+=" - development files"
-
+	conflicts="ffmpeg4-devel"
 	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
 		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
 		nostrip_files="/usr/lib/libavfilter.a"
 	fi
-
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig

From 14c8cf935338e2feb5dada7cb27231dd60f41e1a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:14 -0400
Subject: [PATCH 002/113] openshot: revbump for ffmpeg6

---
 srcpkgs/openshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openshot/template b/srcpkgs/openshot/template
index 8f47851eef354..affb652a9d500 100644
--- a/srcpkgs/openshot/template
+++ b/srcpkgs/openshot/template
@@ -1,7 +1,7 @@
 # Template file for 'openshot'
 pkgname=openshot
 version=3.0.0
-revision=2
+revision=3
 build_style=python3-module
 hostmakedepends="python3 python3-setuptools"
 makedepends="ffmpeg-devel python3-PyQt5"

From ecb2e8c7418e3968e6642373d5ab0de6ac9172e5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:36 -0400
Subject: [PATCH 003/113] sumo: revbump for ffmpeg6

---
 srcpkgs/sumo/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/sumo/template b/srcpkgs/sumo/template
index a3fe134aa5acc..a730afa9fafa9 100644
--- a/srcpkgs/sumo/template
+++ b/srcpkgs/sumo/template
@@ -1,7 +1,7 @@
 # Template file for 'sumo'
 pkgname=sumo
 version=1.12.0
-revision=6
+revision=7
 build_style=cmake
 hostmakedepends="libgdal-tools pkg-config swig python3-setuptools"
 makedepends="python3-devel ffmpeg-devel fox-devel gl2ps-devel libgdal-devel

From d882c6eba0e2ff5cae4fbb84b0f10240e203140f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:56:22 -0400
Subject: [PATCH 004/113] New package: ffmpeg4-4.4.4.

---
 srcpkgs/ffmpeg4-devel                         |   1 +
 srcpkgs/ffmpeg4/files/altivec.patch           |  60 +++++
 .../patches/armv5tel-floating-point.patch     |  18 ++
 ...h-libavcodec-libsvtav1-ten_bit_format.diff |  40 +++
 .../workaround-mesa-readeon-vaapi-bug.patch   |  28 +++
 srcpkgs/ffmpeg4/template                      | 234 ++++++++++++++++++
 srcpkgs/libavcodec4                           |   1 +
 srcpkgs/libavdevice4                          |   1 +
 srcpkgs/libavfilter4                          |   1 +
 srcpkgs/libavformat4                          |   1 +
 srcpkgs/libavresample4                        |   1 +
 srcpkgs/libavutil4                            |   1 +
 srcpkgs/libpostproc4                          |   1 +
 srcpkgs/libswresample4                        |   1 +
 srcpkgs/libswscale4                           |   1 +
 15 files changed, 390 insertions(+)
 create mode 120000 srcpkgs/ffmpeg4-devel
 create mode 100644 srcpkgs/ffmpeg4/files/altivec.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 create mode 100644 srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
 create mode 100644 srcpkgs/ffmpeg4/template
 create mode 120000 srcpkgs/libavcodec4
 create mode 120000 srcpkgs/libavdevice4
 create mode 120000 srcpkgs/libavfilter4
 create mode 120000 srcpkgs/libavformat4
 create mode 120000 srcpkgs/libavresample4
 create mode 120000 srcpkgs/libavutil4
 create mode 120000 srcpkgs/libpostproc4
 create mode 120000 srcpkgs/libswresample4
 create mode 120000 srcpkgs/libswscale4

diff --git a/srcpkgs/ffmpeg4-devel b/srcpkgs/ffmpeg4-devel
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/ffmpeg4-devel
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/ffmpeg4/files/altivec.patch b/srcpkgs/ffmpeg4/files/altivec.patch
new file mode 100644
index 0000000000000..9c57200463320
--- /dev/null
+++ b/srcpkgs/ffmpeg4/files/altivec.patch
@@ -0,0 +1,60 @@
+revert some altivec specific change on all ppc* except ppc64le*
+
+q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
+conditionally, for ppc* but not ppc64le* (the new code is valid for
+POWER8 VSX which LE targets as a baseline but not BE)"
+
+
+This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
+---
+ libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
+ 1 file changed, 20 insertions(+), 4 deletions(-)
+
+diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
+index 536545293d..c1e2852adb 100644
+--- a/libswscale/ppc/yuv2rgb_altivec.c
++++ b/libswscale/ppc/yuv2rgb_altivec.c
+@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+     vector signed short R1, G1, B1;                                           \
+     vector unsigned char R, G, B;                                             \
+                                                                               \
++    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
++    vector unsigned char align_perm;                                          \
++                                                                              \
+     vector signed short lCY       = c->CY;                                    \
+     vector signed short lOY       = c->OY;                                    \
+     vector signed short lCRV      = c->CRV;                                   \
+@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
+                                                                               \
+         for (j = 0; j < w / 16; j++) {                                        \
+-            y0 = vec_xl(0, y1i);                                              \
++            y1ivP = (const vector unsigned char *) y1i;                       \
++            y2ivP = (const vector unsigned char *) y2i;                       \
++            uivP  = (const vector unsigned char *) ui;                        \
++            vivP  = (const vector unsigned char *) vi;                        \
++                                                                              \
++            align_perm = vec_lvsl(0, y1i);                                    \
++            y0 = (vector unsigned char)                                       \
++                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
+                                                                               \
+-            y1 = vec_xl(0, y2i);                                              \
++            align_perm = vec_lvsl(0, y2i);                                    \
++            y1 = (vector unsigned char)                                       \
++                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
+                                                                               \
+-            u = (vector signed char) vec_xl(0, ui);                           \
++            align_perm = vec_lvsl(0, ui);                                     \
++            u = (vector signed char)                                          \
++                    vec_perm(uivP[0], uivP[1], align_perm);                   \
+                                                                               \
+-            v = (vector signed char) vec_xl(0, vi);                           \
++            align_perm = vec_lvsl(0, vi);                                     \
++            v = (vector signed char)                                          \
++                    vec_perm(vivP[0], vivP[1], align_perm);                   \
+                                                                               \
+             u = (vector signed char)                                          \
+                     vec_sub(u,                                                \
+-- 
+2.27.0
+
diff --git a/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
new file mode 100644
index 0000000000000..9a55178c74f0f
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
@@ -0,0 +1,18 @@
+--- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
++++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
+@@ -39,6 +39,15 @@
+ #endif
+ #include <fenv.h>
+ 
++#if (FE_ALL_EXCEPT == 0)
++/* E.g. ARM soft float does not define these */
++#define FE_INVALID    0
++#define FE_DIVBYZERO  0
++#define FE_OVERFLOW   0
++#define FE_UNDERFLOW  0
++#define FE_INEXACT    0
++#endif
++
+ #if CONFIG_LIBFONTCONFIG
+ #include <fontconfig/fontconfig.h>
+ #endif
diff --git a/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
new file mode 100644
index 0000000000000..aa948f7a8a2df
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
@@ -0,0 +1,40 @@
+#==================================================================================================
+# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
+# From: Christopher Degawa <christopher.degawa@intel.com>
+# Date: Thu, 20 Oct 2022 22:55:27 -0500
+# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
+#
+# compressed_ten_bit_format has been deprecated upstream and has no effect
+# and can be removed. Plus, technically it was never used in the first place
+# since it would require the app (ffmpeg) to set it and do additional
+# processing of the input frames.
+#
+# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
+#
+# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
+#==================================================================================================
+--- a/libavcodec/libsvtav1.c
++++ b/libavcodec/libsvtav1.c
+@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
+ 
+ static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
+ {
+-    const int    pack_mode_10bit =
+-        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
+-    const size_t luma_size_8bit  =
+-        config->source_width * config->source_height * (1 << pack_mode_10bit);
+-    const size_t luma_size_10bit =
+-        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
++    const size_t luma_size = config->source_width * config->source_height *
++        (config->encoder_bit_depth > 8 ? 2 : 1);
+ 
+     EbSvtIOFormat *in_data;
+ 
+-    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
++    svt_enc->raw_size = luma_size * 3 / 2;
+ 
+     // allocate buffer for in and out
+     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
+-- 
+GitLab
+
diff --git a/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
new file mode 100644
index 0000000000000..00e3f68a415b8
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
@@ -0,0 +1,28 @@
+From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
+From: Rainer Hochecker <fernetmenta@online.de>
+Date: Sat, 26 Jan 2019 19:48:35 +0100
+Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
+
+This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
+It was hit frequently when watching h264 channels received via DVB-X.
+Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
+---
+ libavcodec/vaapi_h264.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
+index 5854587a255..f12fdc457a4 100644
+--- a/libavcodec/vaapi_h264.c
++++ b/libavcodec/vaapi_h264.c
+@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
+     H264SliceContext *sl = &h->slice_ctx[0];
+     int ret;
+ 
++    if (pic->nb_slices == 0) {
++        ret = AVERROR_INVALIDDATA;
++        goto finish;
++    }
++
+     ret = ff_vaapi_decode_issue(avctx, pic);
+     if (ret < 0)
+         goto finish;
diff --git a/srcpkgs/ffmpeg4/template b/srcpkgs/ffmpeg4/template
new file mode 100644
index 0000000000000..9ba14bdb8ddf3
--- /dev/null
+++ b/srcpkgs/ffmpeg4/template
@@ -0,0 +1,234 @@
+# Template file for 'ffmpeg4'
+# audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
+pkgname=ffmpeg4
+version=4.4.4
+revision=1
+short_desc="Decoding, encoding and streaming software - ffmpeg4 libraries only"
+maintainer="Orphaned <orphan@voidlinux.org>"
+license="GPL-3.0-or-later"
+homepage="https://www.ffmpeg.org"
+changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
+distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
+checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+
+hostmakedepends="pkg-config perl"
+makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
+ libXext-devel libXvMC-devel libxcb-devel lame-devel libtheora-devel
+ libvorbis-devel x264-devel xvidcore-devel jack-devel SDL2-devel
+ libcdio-paranoia-devel librtmp-devel libmodplug-devel gnutls-devel
+ speex-devel celt-devel harfbuzz-devel libass-devel opus-devel ocl-icd-devel
+ libbs2b-devel libvidstab-devel vmaf-devel $(vopt_if pulseaudio pulseaudio-devel)
+ $(vopt_if vaapi libva-devel) $(vopt_if vdpau libvdpau-devel)
+ $(vopt_if x265 x265-devel) $(vopt_if v4l2 v4l-utils-devel)
+ $(vopt_if fdk_aac fdk-aac-devel) $(vopt_if vpx libvpx-devel)
+ $(vopt_if aom libaom-devel) $(vopt_if sndio sndio-devel)
+ $(vopt_if dav1d libdav1d-devel) $(vopt_if zimg zimg-devel)
+ $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
+ $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
+ $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
+
+build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
+
+desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
+desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
+desc_option_sofa="Enable support for AES SOFA"
+desc_option_webp="Enable support for WebP"
+
+case "$XBPS_TARGET_MACHINE" in
+	i686*|x86_64*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau nvenc nvdec"
+			;;
+	ppc64*) build_options_default+=" vaapi vdpau";;
+	mips*) CFLAGS="-mnan=legacy";;
+esac
+
+if [ "$XBPS_TARGET_WORDSIZE" != "32" ]; then
+	build_options_default+=" svtav1"
+fi
+
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+fi
+
+_apply_patch() {
+	local args="$1" pname="$(basename $2)"
+
+	if [ ! -f ".${pname}_done" ]; then
+		patch -N $args -i $2
+		touch .${pname}_done
+	fi
+}
+
+post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64le*) ;;
+		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
+	esac
+
+	vsed -i libavfilter/vf_libvmaf.c -e 's!/usr/local/share/model/\(vmaf_v0.6.1\).pkl!/usr/share/vmaf/\1.json!'
+}
+
+do_configure() {
+	# Fix gcc on x86_64-musl only
+	if [ "$XBPS_TARGET_MACHINE" = "x86_64-musl" ]; then
+		vsed -i configure -e "s;_cflags_speed='-O3';_cflags_speed='-O2';"
+	fi
+
+	if [ "$CROSS_BUILD" ]; then
+		case "$XBPS_TARGET_MACHINE" in
+			arm*) _arch="arm";;
+			aarch64*) _arch="aarch64";;
+			mips*) _arch="mips";;
+			ppc64*) _arch="ppc64";;
+			ppc*) _arch="ppc";;
+			*) _arch="${XBPS_TARGET_MACHINE%%-musl}";;
+		esac
+
+		_args+=" --enable-cross-compile
+			--sysroot=$XBPS_CROSS_BASE
+			--cross-prefix=${XBPS_CROSS_TRIPLET}-
+			--target-os=linux --arch=${_arch}"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc|ppc-musl) _args+=" --disable-altivec";;
+	esac
+
+	if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+		_args+=" --extra-libs=-latomic"
+	fi
+
+	./configure --prefix=/usr --disable-debug --enable-gpl --enable-gnutls \
+		--disable-stripping \
+		--enable-libcdio --enable-version3 --enable-runtime-cpudetect \
+		--enable-libmp3lame --enable-libvorbis --enable-libxvid \
+		--enable-libx264 $(vopt_enable vpx libvpx) --enable-libtheora \
+		--enable-shared --enable-static --enable-libxcb \
+		$(vopt_enable pulseaudio libpulse) --enable-libfreetype --enable-libmodplug \
+		--enable-libspeex --enable-libcelt --enable-libass \
+		--enable-libopus --enable-librtmp --enable-libjack \
+		$(vopt_if fdk_aac '--enable-nonfree --enable-libfdk-aac') \
+		--disable-libopencore_amrnb --disable-libopencore_amrwb \
+		--disable-libopenjpeg \
+		--enable-postproc --enable-opencl ${_args} --enable-libvmaf ${_args} \
+		$(vopt_enable x265 libx265) \
+		$(vopt_enable v4l2 libv4l2) \
+		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
+		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		$(vopt_enable dav1d libdav1d) \
+		$(vopt_enable zimg libzimg) \
+		$(vopt_enable webp libwebp) \
+		$(vopt_enable sofa libmysofa) \
+		$(vopt_enable vulkan) \
+		$(vopt_enable drm libdrm) \
+		$(vopt_enable svtav1 libsvtav1) \
+		$(vopt_enable srt libsrt) \
+		$(vopt_enable rist librist) \
+		$(vopt_if nvenc '--enable-nvenc') \
+		$(vopt_if nvdec '--enable-nvdec')
+}
+
+do_build() {
+	make ${makejobs}
+	make doc/ff{mpeg,play}.1
+}
+
+do_install() {
+	make DESTDIR=${DESTDIR} install install-man
+	rm -rf ${DESTDIR}/usr/bin
+}
+
+libavcodec4_package() {
+	short_desc="FFmpeg codec library"
+	pkg_install() {
+		vmove "usr/lib/libavcodec.so.*"
+	}
+}
+
+libavdevice4_package() {
+	short_desc="FFmpeg device handling library"
+	pkg_install() {
+		vmove "usr/lib/libavdevice.so.*"
+	}
+}
+
+libavresample4_package() {
+	short_desc="FFmpeg audio resampling library"
+	pkg_install() {
+		vmove "usr/lib/libavresample.so.*"
+	}
+}
+
+libavformat4_package() {
+	short_desc="FFmpeg file format library"
+	pkg_install() {
+		vmove "usr/lib/libavformat.so.*"
+	}
+}
+
+libavutil4_package() {
+	short_desc="FFmpeg utility library"
+	pkg_install() {
+		vmove "usr/lib/libavutil.so.*"
+	}
+}
+
+libavfilter4_package() {
+	short_desc="FFmpeg audio/video filter library"
+	pkg_install() {
+		vmove "usr/lib/libavfilter.so.*"
+	}
+}
+
+libpostproc4_package() {
+	short_desc="FFmpeg video postprocessing library"
+	pkg_install() {
+		vmove "usr/lib/libpostproc.so.*"
+	}
+}
+
+libswscale4_package() {
+	short_desc="FFmpeg video scaling library"
+	pkg_install() {
+		vmove "usr/lib/libswscale.so.*"
+	}
+}
+
+libswresample4_package() {
+	short_desc="FFmpeg video resampling library"
+	pkg_install() {
+		vmove "usr/lib/libswresample.so.*"
+	}
+}
+
+ffmpeg4-devel_package() {
+	depends="
+		libavcodec4>=${version}_${revision}
+		libavdevice4>=${version}_${revision}
+		libavformat4>=${version}_${revision}
+		libavutil4>=${version}_${revision}
+		libavfilter4>=${version}_${revision}
+		libpostproc4>=${version}_${revision}
+		libswscale4>=${version}_${revision}
+		libswresample4>=${version}_${revision}
+		libavresample4>=${version}_${revision}"
+	short_desc+=" - development files"
+	conflicts="ffmpeg-devel"
+	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
+		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
+		nostrip_files="/usr/lib/libavfilter.a"
+	fi
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.a"
+		vmove "usr/lib/*.so"
+		vmove usr/share/ffmpeg/examples
+		vmove usr/share/man/man3
+	}
+}
diff --git a/srcpkgs/libavcodec4 b/srcpkgs/libavcodec4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavcodec4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavdevice4 b/srcpkgs/libavdevice4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavdevice4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavfilter4 b/srcpkgs/libavfilter4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavfilter4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavformat4 b/srcpkgs/libavformat4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavformat4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavresample4 b/srcpkgs/libavresample4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavutil4 b/srcpkgs/libavutil4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavutil4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libpostproc4 b/srcpkgs/libpostproc4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libpostproc4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswresample4 b/srcpkgs/libswresample4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libswresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswscale4 b/srcpkgs/libswscale4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libswscale4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file

From 174142e0cc34ea5d452b2213c8dfa66c285d2739 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:04 -0400
Subject: [PATCH 005/113] opencv: update to 4.7.0.

---
 common/shlibs           | 104 ++++++++++++++++++++--------------------
 srcpkgs/opencv/template |   8 ++--
 2 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index c1d7e79ab4d55..09f7c60c61c82 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2084,58 +2084,58 @@ libcapstone.so.5 capstone-5.0.1_1
 libhavege.so.2 libhaveged-1.9.11_1
 libnih.so.1 libnih-1.0.3_1
 libnih-dbus.so.1 libnih-1.0.3_1
-libopencv_quality.so.406 libopencv-4.6.0_1
-libopencv_reg.so.406 libopencv-4.6.0_1
-libopencv_surface_matching.so.406 libopencv-4.6.0_1
-libopencv_xphoto.so.406 libopencv-4.6.0_1
-libopencv_freetype.so.406 libopencv-4.6.0_1
-libopencv_fuzzy.so.406 libopencv-4.6.0_1
-libopencv_hfs.so.406 libopencv-4.6.0_1
-libopencv_img_hash.so.406 libopencv-4.6.0_1
-libopencv_line_descriptor.so.406 libopencv-4.6.0_1
-libopencv_saliency.so.406 libopencv-4.6.0_1
-libopencv_structured_light.so.406 libopencv-4.6.0_1
-libopencv_aruco.so.406 libopencv-4.6.0_1
-libopencv_bgsegm.so.406 libopencv-4.6.0_1
-libopencv_bioinspired.so.406 libopencv-4.6.0_1
-libopencv_ccalib.so.406 libopencv-4.6.0_1
-libopencv_face.so.406 libopencv-4.6.0_1
-libopencv_tracking.so.406 libopencv-4.6.0_1
-libopencv_xfeatures2d.so.406 libopencv-4.6.0_1
-libopencv_optflow.so.406 libopencv-4.6.0_1
-libopencv_ximgproc.so.406 libopencv-4.6.0_1
-libopencv_plot.so.406 libopencv-4.6.0_1
-libopencv_text.so.406 libopencv-4.6.0_1
-libopencv_ml.so.406 libopencv-4.6.0_1
-libopencv_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn.so.406 libopencv-4.6.0_1
-libopencv_shape.so.406 libopencv-4.6.0_1
-libopencv_stitching.so.406 libopencv-4.6.0_1
-libopencv_photo.so.406 libopencv-4.6.0_1
-libopencv_video.so.406 libopencv-4.6.0_1
-libopencv_calib3d.so.406 libopencv-4.6.0_1
-libopencv_features2d.so.406 libopencv-4.6.0_1
-libopencv_flann.so.406 libopencv-4.6.0_1
-libopencv_highgui.so.406 libopencv-4.6.0_1
-libopencv_videoio.so.406 libopencv-4.6.0_1
-libopencv_imgcodecs.so.406 libopencv-4.6.0_1
-libopencv_imgproc.so.406 libopencv-4.6.0_1
-libopencv_core.so.406 libopencv-4.6.0_1
-libopencv_superres.so.406 libopencv-4.6.0_1
-libopencv_videostab.so.406 libopencv-4.6.0_1
-libopencv_gapi.so.406 libopencv-4.6.0_1
-libopencv_xobjdetect.so.406 libopencv-4.6.0_1
-libopencv_datasets.so.406 libopencv-4.6.0_1
-libopencv_dnn_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn_superres.so.406 libopencv-4.6.0_1
-libopencv_dpm.so.406 libopencv-4.6.0_1
-libopencv_phase_unwrapping.so.406 libopencv-4.6.0_1
-libopencv_stereo.so.406 libopencv-4.6.0_1
-libopencv_rapid.so.406 libopencv-4.6.0_1
-libopencv_intensity_transform.so.406 libopencv-4.6.0_1
-libopencv_alphamat.so.406 libopencv-4.6.0_1
-libopencv_barcode.so.406 libopencv-4.6.0_1
-libopencv_mcc.so.406 libopencv-4.6.0_1
+libopencv_quality.so.407 libopencv-4.7.0_1
+libopencv_reg.so.407 libopencv-4.7.0_1
+libopencv_surface_matching.so.407 libopencv-4.7.0_1
+libopencv_xphoto.so.407 libopencv-4.7.0_1
+libopencv_freetype.so.407 libopencv-4.7.0_1
+libopencv_fuzzy.so.407 libopencv-4.7.0_1
+libopencv_hfs.so.407 libopencv-4.7.0_1
+libopencv_img_hash.so.407 libopencv-4.7.0_1
+libopencv_line_descriptor.so.407 libopencv-4.7.0_1
+libopencv_saliency.so.407 libopencv-4.7.0_1
+libopencv_structured_light.so.407 libopencv-4.7.0_1
+libopencv_aruco.so.407 libopencv-4.7.0_1
+libopencv_bgsegm.so.407 libopencv-4.7.0_1
+libopencv_bioinspired.so.407 libopencv-4.7.0_1
+libopencv_ccalib.so.407 libopencv-4.7.0_1
+libopencv_face.so.407 libopencv-4.7.0_1
+libopencv_tracking.so.407 libopencv-4.7.0_1
+libopencv_xfeatures2d.so.407 libopencv-4.7.0_1
+libopencv_optflow.so.407 libopencv-4.7.0_1
+libopencv_ximgproc.so.407 libopencv-4.7.0_1
+libopencv_plot.so.407 libopencv-4.7.0_1
+libopencv_text.so.407 libopencv-4.7.0_1
+libopencv_ml.so.407 libopencv-4.7.0_1
+libopencv_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn.so.407 libopencv-4.7.0_1
+libopencv_shape.so.407 libopencv-4.7.0_1
+libopencv_stitching.so.407 libopencv-4.7.0_1
+libopencv_photo.so.407 libopencv-4.7.0_1
+libopencv_video.so.407 libopencv-4.7.0_1
+libopencv_calib3d.so.407 libopencv-4.7.0_1
+libopencv_features2d.so.407 libopencv-4.7.0_1
+libopencv_flann.so.407 libopencv-4.7.0_1
+libopencv_highgui.so.407 libopencv-4.7.0_1
+libopencv_videoio.so.407 libopencv-4.7.0_1
+libopencv_imgcodecs.so.407 libopencv-4.7.0_1
+libopencv_imgproc.so.407 libopencv-4.7.0_1
+libopencv_core.so.407 libopencv-4.7.0_1
+libopencv_superres.so.407 libopencv-4.7.0_1
+libopencv_videostab.so.407 libopencv-4.7.0_1
+libopencv_gapi.so.407 libopencv-4.7.0_1
+libopencv_xobjdetect.so.407 libopencv-4.7.0_1
+libopencv_datasets.so.407 libopencv-4.7.0_1
+libopencv_dnn_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn_superres.so.407 libopencv-4.7.0_1
+libopencv_dpm.so.407 libopencv-4.7.0_1
+libopencv_phase_unwrapping.so.407 libopencv-4.7.0_1
+libopencv_stereo.so.407 libopencv-4.7.0_1
+libopencv_rapid.so.407 libopencv-4.7.0_1
+libopencv_intensity_transform.so.407 libopencv-4.7.0_1
+libopencv_alphamat.so.407 libopencv-4.7.0_1
+libopencv_barcode.so.407 libopencv-4.7.0_1
+libopencv_mcc.so.407 libopencv-4.7.0_1
 libuniconf.so.4.6 wvstreams-4.6.1_20
 libwvbase.so.4.6 wvstreams-4.6.1_20
 libwvutils.so.4.6 wvstreams-4.6.1_20
diff --git a/srcpkgs/opencv/template b/srcpkgs/opencv/template
index aea4bfc3a265c..ce94de9424d18 100644
--- a/srcpkgs/opencv/template
+++ b/srcpkgs/opencv/template
@@ -1,7 +1,7 @@
 # Template file for 'opencv'
 pkgname=opencv
-version=4.6.0
-revision=6
+version=4.7.0
+revision=1
 create_wrksrc=yes
 build_wrksrc=${pkgname}-${version}
 build_style=cmake
@@ -24,8 +24,8 @@ homepage="https://opencv.org"
 changelog="https://github.com/opencv/opencv/wiki/ChangeLog"
 distfiles="https://github.com/opencv/opencv/archive/${version}.tar.gz
  https://github.com/opencv/opencv_contrib/archive/${version}.tar.gz>contrib.tar.gz"
-checksum="1ec1cba65f9f20fe5a41fda1586e01c70ea0c9a6d7b67c9e13edf0cfe2239277
- 1777d5fd2b59029cf537e5fd6f8aa68d707075822f90bde683fcde086f85f7a7"
+checksum="8df0079cdbe179748a18d44731af62a245a45ebf5085223dc03133954c662973
+ 42df840cf9055e59d0e22c249cfb19f04743e1bdad113d31b1573d3934d62584"
 patch_args="-Np1 -d ${build_wrksrc}"
 # tests hang indenfinitely, even with test data included
 make_check=no

From e91d769a5b74b6e42529a8d5e5009faeb5b681d5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 006/113] actiona: revbump for opencv-4.7.0

---
 srcpkgs/actiona/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/actiona/template b/srcpkgs/actiona/template
index cf5f0b7a2ae61..0d899311e6df7 100644
--- a/srcpkgs/actiona/template
+++ b/srcpkgs/actiona/template
@@ -1,7 +1,7 @@
 # Template file for 'actiona'
 pkgname=actiona
 version=3.10.1
-revision=2
+revision=3
 build_style=qmake
 configure_args="PKGCONFIG_OPENCV=opencv4"
 hostmakedepends="pkg-config qt5-plugin-mysql qt5-qmake qt5-host-tools"

From 2dc79552b5b6ea5eda4b86f9c23e5cd932ca5165 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 007/113] retroshare: revbump for opencv-4.7.0

---
 srcpkgs/retroshare/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroshare/template b/srcpkgs/retroshare/template
index bb17569277a7f..49e2c1cbe8a53 100644
--- a/srcpkgs/retroshare/template
+++ b/srcpkgs/retroshare/template
@@ -1,7 +1,7 @@
 # Template file for 'retroshare'
 pkgname=retroshare
 version=0.6.6
-revision=3
+revision=4
 build_style=qmake
 #XXX broadcast feature requires an ancient udp-discovery-cpp which either needs
 # to be fetched+patched (FTBFS) here or packaged :/

From cd94b5a38591bcc8d388196d8763c0443a52be33 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 008/113] waifu2x-converter-cpp: revbump for opencv-4.7.0

---
 srcpkgs/waifu2x-converter-cpp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waifu2x-converter-cpp/template b/srcpkgs/waifu2x-converter-cpp/template
index 361b8a23b9497..c5ac17eb54ea4 100644
--- a/srcpkgs/waifu2x-converter-cpp/template
+++ b/srcpkgs/waifu2x-converter-cpp/template
@@ -1,7 +1,7 @@
 # Template file for 'waifu2x-converter-cpp'
 pkgname=waifu2x-converter-cpp
 version=5.2.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DINSTALL_MODELS=ON"
 hostmakedepends="pkg-config"

From 82af379f88046f70ac0e1b5fc7190b47a1ffc776 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:38 -0400
Subject: [PATCH 009/113] vlc: revbump for ffmpeg4

---
 srcpkgs/vlc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vlc/template b/srcpkgs/vlc/template
index abc5eeba01564..5f291b1b81e23 100644
--- a/srcpkgs/vlc/template
+++ b/srcpkgs/vlc/template
@@ -25,7 +25,7 @@ lib32disabled=yes
 hostmakedepends="automake libtool pkg-config flex gettext libgcrypt-devel
  live555-devel gettext-devel $(vopt_if lua lua52) $(vopt_if chromecast protobuf)"
 makedepends="
- avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg-devel freefont-ttf
+ avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg4-devel freefont-ttf
  gnutls-devel jack-devel liba52-devel libass-devel libbluray-devel
  libcdio-devel libdca-devel libdvbpsi-devel libdvdnav-devel libmad-devel
  libmatroska-devel libmodplug-devel libmpcdec-devel libmpeg2-devel

From e8ec34b0ca5e440a8548291b0ba562c359286c9e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:55 -0400
Subject: [PATCH 010/113] osg: revbump for ffmpeg4

---
 srcpkgs/osg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/osg/template b/srcpkgs/osg/template
index a9ebbd287933b..755793f7e11bf 100644
--- a/srcpkgs/osg/template
+++ b/srcpkgs/osg/template
@@ -8,7 +8,7 @@ build_helper="qemu"
 configure_args="-DLIB_POSTFIX="
 hostmakedepends="pkg-config xrandr"
 makedepends="MesaLib-devel gtkglext-devel libcurl-devel giflib-devel librsvg-devel
- jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg-devel xine-lib-devel
+ jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg4-devel xine-lib-devel
  SDL2-devel gst-plugins-base1-devel
  $(vopt_if openexr libopenexr-devel)
  $(vopt_if poppler poppler-glib-devel)

From e3cf8602f708cfdc3edfd53a72e9ee2ebc6030ba Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:13 -0400
Subject: [PATCH 011/113] xine-lib: revbump for ffmpeg4

---
 srcpkgs/xine-lib/template | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/xine-lib/template b/srcpkgs/xine-lib/template
index 3be4d08eac77a..ed6194c17d11e 100644
--- a/srcpkgs/xine-lib/template
+++ b/srcpkgs/xine-lib/template
@@ -1,14 +1,14 @@
 # Template file for 'xine-lib'
 pkgname=xine-lib
-version=1.2.12
-revision=3
+version=1.2.13
+revision=1
 build_style=gnu-configure
 configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
  --disable-oss"
 hostmakedepends="automake gettext-devel libtool pkg-config perl"
 makedepends="
  zlib-devel alsa-lib-devel libxcb-devel libSM-devel libXext-devel libXv-devel
- libXvMC-devel liba52-devel libmad-devel ffmpeg-devel pulseaudio-devel
+ libXvMC-devel liba52-devel libmad-devel ffmpeg4-devel pulseaudio-devel
  jack-devel samba-devel libflac-devel libmodplug-devel libmpcdec-devel
  speex-devel libtheora-devel libvorbis-devel libdca-devel faad2-devel
  libcdio-devel libbluray-devel aalib-devel libcaca-devel libXinerama-devel
@@ -19,7 +19,7 @@ license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="http://www.xine-project.org"
 changelog="https://sourceforge.net/projects/xine/files/xine-lib/${version}/README.txt/view"
 distfiles="${SOURCEFORGE_SITE}/xine/${pkgname}-${version}.tar.xz"
-checksum=d606270468e1540c2a89c0d7f5fdf11e17ecc0c2698cc0bcb1065ff26abee098
+checksum=5f10d6d718a4a51c17ed1b32b031d4f9b80b061e8276535b2be31e5ac4b75e6f
 
 case "$XBPS_TARGET_MACHINE" in
 	i686-musl)

From 18d9c6744a4d3302dd342bef37e0f4bcfcfcf7de Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 012/113] arcan: revbump for ffmpeg6

---
 srcpkgs/arcan/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/arcan/template b/srcpkgs/arcan/template
index efd0afe10576d..b91e6900d42a1 100644
--- a/srcpkgs/arcan/template
+++ b/srcpkgs/arcan/template
@@ -2,7 +2,7 @@
 # !! keep synced with: acfgfs aclip aloadimage
 pkgname=arcan
 version=0.6.2.1
-revision=1
+revision=2
 create_wrksrc=yes
 build_wrksrc=arcan/src
 build_style=cmake

From 939170a37a599f0e35e334afd0b6e7f484c5fe09 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 013/113] attract: revbump for ffmpeg4

---
 srcpkgs/attract/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/attract/template b/srcpkgs/attract/template
index 24017d2bacc24..e760bf0d18aec 100644
--- a/srcpkgs/attract/template
+++ b/srcpkgs/attract/template
@@ -6,7 +6,7 @@ build_style=gnu-makefile
 make_build_args="VERBOSE=1"
 make_use_env=yes
 hostmakedepends="pkg-config"
-makedepends="SFML-devel ffmpeg-devel fontconfig-devel glu-devel libarchive-devel
+makedepends="SFML-devel ffmpeg4-devel fontconfig-devel glu-devel libarchive-devel
  libcurl-devel libjpeg-turbo-devel xine-lib rapidjson libXrandr-devel"
 depends="git"
 short_desc="Attract-Mode is a graphical frontend for emulators"

From 942547324a5bec90e16b532e2f8cc333a4ac6fab Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 014/113] aubio: revbump for ffmpeg6

---
 srcpkgs/aubio/patches/ffmpeg5.patch | 25 +++++++++++++++++++++++++
 srcpkgs/aubio/template              |  2 +-
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/aubio/patches/ffmpeg5.patch

diff --git a/srcpkgs/aubio/patches/ffmpeg5.patch b/srcpkgs/aubio/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..aace41a6e6d9a
--- /dev/null
+++ b/srcpkgs/aubio/patches/ffmpeg5.patch
@@ -0,0 +1,25 @@
+From 8a05420e5dd8c7b8b2447f82dc919765876511b3 Mon Sep 17 00:00:00 2001
+From: Paul Brossier <piem@piem.org>
+Date: Tue, 25 Jan 2022 18:30:27 +0100
+Subject: [PATCH] [source_avcodec] define FF_API_LAVF_AVCTX for libavcodec >
+ 59, thx @berolinux (closes gh-353)
+
+---
+ src/io/source_avcodec.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/io/source_avcodec.c b/src/io/source_avcodec.c
+index e0ae93b5..1421bd9a 100644
+--- a/src/io/source_avcodec.c
++++ b/src/io/source_avcodec.c
+@@ -68,6 +68,10 @@
+ #define AUBIO_AVCODEC_MAX_BUFFER_SIZE AV_INPUT_BUFFER_MIN_SIZE
+ #endif
+ 
++#if LIBAVCODEC_VERSION_MAJOR >= 59
++#define FF_API_LAVF_AVCTX 1
++#endif
++
+ struct _aubio_source_avcodec_t {
+   uint_t hop_size;
+   uint_t samplerate;
diff --git a/srcpkgs/aubio/template b/srcpkgs/aubio/template
index ad1c4b2569917..7d875cc02541a 100644
--- a/srcpkgs/aubio/template
+++ b/srcpkgs/aubio/template
@@ -1,7 +1,7 @@
 # Template file for 'aubio'
 pkgname=aubio
 version=0.4.9
-revision=1
+revision=2
 build_style=waf3
 # XXX lash, pure and swig support.
 hostmakedepends="pkg-config txt2man"

From 57e82a11e686ee4a014846a2011a2d0d88d99acb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 015/113] audacious-plugins: revbump for ffmpeg6

---
 .../audacious-plugins/patches/ffmpeg5.patch   | 43 +++++++++++++++++++
 srcpkgs/audacious-plugins/template            |  2 +-
 2 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/audacious-plugins/patches/ffmpeg5.patch

diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg5.patch b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..4e5e34099d71c
--- /dev/null
+++ b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
@@ -0,0 +1,43 @@
+commit 298aa371c56c2f52c25a33d9bdec4918b11cebdc
+Author: tibequadorian <tibequadorian@posteo.de>
+Date:   Sat Mar 19 18:40:12 2022 +0100
+
+    audacious-plugins: rebuild against ffmpeg-5.0
+
+diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+new file mode 100644
+index 0000000000..617c11215b
+--- /dev/null
++++ b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+@@ -0,0 +1,31 @@
++From f60beb400eeb1e4778bbfd738bc4a4ccef3de539 Mon Sep 17 00:00:00 2001
++From: John Lindgren <john@jlindgren.net>
++Date: Sat, 5 Mar 2022 12:05:34 -0500
++Subject: [PATCH] Fix build with FFmpeg 5.0
++
++---
++ src/ffaudio/ffaudio-core.cc | 4 ++--
++ 1 file changed, 2 insertions(+), 2 deletions(-)
++
++diff --git a/src/ffaudio/ffaudio-core.cc b/src/ffaudio/ffaudio-core.cc
++index 16dc63e3a..a2b95fd6c 100644
++--- a/src/ffaudio/ffaudio-core.cc
+++++ b/src/ffaudio/ffaudio-core.cc
++@@ -274,7 +274,7 @@ static AVInputFormat * get_format_by_content (const char * name, VFSFile & file)
++         AVProbeData d = {name, buf, filled};
++         score = target;
++ 
++-        f = av_probe_input_format2 (& d, true, & score);
+++        f = (AVInputFormat *) av_probe_input_format2 (& d, true, & score);
++         if (f)
++             break;
++ 
++@@ -347,7 +347,7 @@ static bool find_codec (AVFormatContext * c, CodecInfo * cinfo)
++ #endif
++         if (stream && stream->codecpar && stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
++         {
++-            AVCodec * codec = avcodec_find_decoder (stream->codecpar->codec_id);
+++            AVCodec * codec = (AVCodec *) avcodec_find_decoder (stream->codecpar->codec_id);
++ 
++             if (codec)
++             {
diff --git a/srcpkgs/audacious-plugins/template b/srcpkgs/audacious-plugins/template
index 05e53a9adf78f..4b1968e03de78 100644
--- a/srcpkgs/audacious-plugins/template
+++ b/srcpkgs/audacious-plugins/template
@@ -2,7 +2,7 @@
 #Keep in sync with audacious!
 pkgname=audacious-plugins
 version=4.3.1
-revision=3
+revision=4
 build_style=meson
 configure_args="$(vopt_bool gtk3 gtk) $(vopt_bool gtk3)
  $(vopt_bool qt) $(vopt_bool qt qt6)"

From e60650d2881c40dee5908b5750fc2aa5680db0aa Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 016/113] audacity: revbump for ffmpeg4

---
 srcpkgs/audacity/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/audacity/template b/srcpkgs/audacity/template
index 7b838119ab261..fb15f782ac1f7 100644
--- a/srcpkgs/audacity/template
+++ b/srcpkgs/audacity/template
@@ -1,7 +1,7 @@
 # Template file for 'audacity'
 pkgname=audacity
 version=3.4.2
-revision=1
+revision=2
 build_style=cmake
 build_helper="cmake-wxWidgets-gtk3 qemu"
 configure_args="-Daudacity_use_ffmpeg=loaded -Daudacity_lib_preference=system
@@ -12,7 +12,7 @@ configure_args="-Daudacity_use_ffmpeg=loaded -Daudacity_lib_preference=system
  -Daudacity_has_updates_check=OFF -DAUDACITY_BUILD_LEVEL=2"
 hostmakedepends="pkg-config gettext python3"
 makedepends="wxWidgets-gtk3-devel gtk+3-devel expat-devel lame-devel
- libsoxr-devel portaudio-devel sqlite-devel ffmpeg-devel
+ libsoxr-devel portaudio-devel sqlite-devel ffmpeg4-devel
  libid3tag-devel libmad-devel vamp-plugin-sdk-devel libogg-devel
  libvorbis-devel libflac-devel lilv-devel lv2 serd-devel sord-devel
  sratom-devel suil-devel portmidi-devel soundtouch-devel twolame-devel

From 8f9605c3d08b1478904182f50a668a3a64090d76 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 017/113] avidemux: revbump for ffmpeg6

---
 srcpkgs/avidemux/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/avidemux/template b/srcpkgs/avidemux/template
index 253a0243e2259..557285982d2b8 100644
--- a/srcpkgs/avidemux/template
+++ b/srcpkgs/avidemux/template
@@ -1,7 +1,7 @@
 # Template file for 'avidemux'
 pkgname=avidemux
 version=2.8.0
-revision=2
+revision=3
 # Can't be compiled for aarch64, arm* or mips*
 archs="x86_64* i686*"
 hostmakedepends="cmake pkg-config qt5-host-tools qt5-devel tar yasm"

From 4dffdf89cc67951c3755e55aec720e46a07021ca Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 018/113] blender: revbump for ffmpeg6

---
 srcpkgs/blender/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index 05fdbf8f747e2..093d6d2004e95 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -9,8 +9,8 @@ configure_args="-DWITH_INSTALL_PORTABLE=OFF -DWITH_PYTHON_INSTALL=OFF
  -DWITH_JACK=ON -DWITH_CODEC_FFMPEG=ON -DWITH_CODEC_SNDFILE=ON -DWITH_OPENMP=ON
  -DWITH_FFTW3=ON -DWITH_MOD_OCEANSIM=ON -DWITH_CYCLES_EMBREE=OFF -DWITH_OPENCOLORIO=ON
  -DWITH_IMAGE_OPENEXR=ON -DWITH_IMAGE_OPENJPEG=ON -DWITH_OPENSUBDIV=ON
- -DWITH_OPENCOLLADA=ON -DWITH_SYSTEM_GLEW=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
- -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_LIBDECOR=ON
+ -DWITH_OPENCOLLADA=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
+ -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_WAYLAND_LIBDECOR=ON
  -DWITH_BUILDINFO=OFF -DPYTHON_VERSION=${py3_ver} -DPYTHON_LIBPATH=/usr/lib
  -DPYTHON_LIBRARY=python${py3_ver}${py3_abiver} -DPYTHON_INCLUDE_DIRS=/${py3_inc}
  -DWITH_SYSTEM_LZO=ON -DWITH_SYSTEM_EIGEN3=ON -DWITH_SYSTEM_FREETYPE=ON"

From 3641b57ba82193d738c499b2fabb2f4a4ee84a14 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 019/113] cantata: revbump for ffmpeg6

---
 srcpkgs/cantata/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cantata/template b/srcpkgs/cantata/template
index 4b417d80d5c2d..8a90aaa4c07a2 100644
--- a/srcpkgs/cantata/template
+++ b/srcpkgs/cantata/template
@@ -1,7 +1,7 @@
 # Template file for 'cantata'
 pkgname=cantata
 version=2.5.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools qt5-tools"
 makedepends="qt5-devel qt5-tools-devel qt5-svg-devel qt5-xmlpatterns-devel

From 6e73c1e6853708b85caba276aa3e5361a127a017 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 020/113] ccextractor: revbump for ffmpeg4

---
 srcpkgs/ccextractor/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/ccextractor/template b/srcpkgs/ccextractor/template
index 9abcd82852b27..6eccad5885af9 100644
--- a/srcpkgs/ccextractor/template
+++ b/srcpkgs/ccextractor/template
@@ -1,12 +1,12 @@
 # Template file for 'ccextractor'
 pkgname=ccextractor
 version=0.93
-revision=1
+revision=2
 build_wrksrc="linux"
 build_style=gnu-configure
 configure_args="--enable-ocr --enable-hardsubx"
 hostmakedepends="automake pkg-config"
-makedepends="leptonica-devel tesseract-ocr-devel ffmpeg-devel"
+makedepends="leptonica-devel tesseract-ocr-devel ffmpeg4-devel"
 short_desc="Extract subtitles from video streams"
 maintainer="newbluemoon <blaumolch@mailbox.org>"
 license="GPL-2.0-or-later"

From 438075e4b58312c71aa2f2871b56b1f4b9142a70 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 021/113] chromaprint: revbump for ffmpeg6

---
 srcpkgs/chromaprint/patches/ffmpeg5.patch | 569 ++++++++++++++++++++++
 srcpkgs/chromaprint/template              |   2 +-
 2 files changed, 570 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromaprint/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromaprint/patches/ffmpeg5.patch b/srcpkgs/chromaprint/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..a9fd307a23c8a
--- /dev/null
+++ b/srcpkgs/chromaprint/patches/ffmpeg5.patch
@@ -0,0 +1,569 @@
+From 8ccad6937177b1b92e40ab8f4447ea27bac009a7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= <lalinsky@gmail.com>
+Date: Fri, 4 Nov 2022 21:47:38 +0100
+Subject: [PATCH] Use FFmpeg 5.x (#120)
+
+* Use FFmpeg 5.1.2 for CI builds
+
+* Build on Ubuntu 20.04
+
+* Upgrade code to FFmpeg 5.x APIs
+
+* Only set FFmpeg include dirs if building tools
+
+* No longer needed
+
+* Use ubuntu 20.04
+---
+ .github/workflows/build.yml                   |   6 +-
+ CMakeLists.txt                                |  16 --
+ package/build.sh                              |   4 +-
+ src/audio/ffmpeg_audio_processor.h            |   2 -
+ src/audio/ffmpeg_audio_processor_avresample.h |  72 -------
+ src/audio/ffmpeg_audio_processor_swresample.h |  18 +-
+ src/audio/ffmpeg_audio_reader.h               | 197 +++++++++---------
+ tests/CMakeLists.txt                          |   6 +
+ 8 files changed, 122 insertions(+), 199 deletions(-)
+ delete mode 100644 src/audio/ffmpeg_audio_processor_avresample.h
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index f8d6a32..4da2405 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -84,9 +84,6 @@ find_package(FFmpeg)
+ if(FFMPEG_LIBRARIES)
+ 	cmake_push_check_state(RESET)
+ 	set(CMAKE_REQUIRED_LIBRARIES ${FFMPEG_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -lm)
+-	check_function_exists(av_packet_unref HAVE_AV_PACKET_UNREF)
+-	check_function_exists(av_frame_alloc HAVE_AV_FRAME_ALLOC)
+-	check_function_exists(av_frame_free HAVE_AV_FRAME_FREE)
+ 	cmake_pop_check_state()
+ endif()
+
+@@ -163,14 +160,11 @@ message(STATUS "Using ${FFT_LIB} for FFT calculations")
+ if(NOT AUDIO_PROCESSOR_LIB)
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+ 		set(AUDIO_PROCESSOR_LIB "swresample")
+-	elseif(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(AUDIO_PROCESSOR_LIB "avresample")
+ 	endif()
+ endif()
+
+ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE OFF)
+ 		set(USE_SWRESAMPLE ON)
+ 		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBSWRESAMPLE_LIBRARIES})
+ 		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBSWRESAMPLE_INCLUDE_DIRS})
+@@ -178,16 +172,6 @@ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+ 	endif()
+ 	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+-elseif(AUDIO_PROCESSOR_LIB STREQUAL "avresample")
+-	if(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE ON)
+-		set(USE_SWRESAMPLE OFF)
+-		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBAVRESAMPLE_LIBRARIES})
+-		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBAVRESAMPLE_INCLUDE_DIRS})
+-	else()
+-		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+-	endif()
+-	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+ else()
+ 	message(STATUS "Building without audio conversion support, please install FFmpeg with libswresample")
+ endif()
+diff --git a/package/build.sh b/package/build.sh
+index da631ae..b41d36e 100755
+--- a/package/build.sh
++++ b/package/build.sh
+@@ -7,8 +7,8 @@ set -eux
+
+ BASE_DIR=$(cd $(dirname $0)/.. && pwd)
+
+-FFMPEG_VERSION=4.4.1
+-FFMPEG_BUILD_TAG=v4.4.1-1
++FFMPEG_VERSION=5.1.2
++FFMPEG_BUILD_TAG=v${FFMPEG_VERSION}-1
+
+ TMP_BUILD_DIR=$BASE_DIR/$(mktemp -d build.XXXXXXXX)
+ trap 'rm -rf $TMP_BUILD_DIR' EXIT
+diff --git a/src/audio/ffmpeg_audio_processor.h b/src/audio/ffmpeg_audio_processor.h
+index 7628fc7..39f4f6d 100644
+--- a/src/audio/ffmpeg_audio_processor.h
++++ b/src/audio/ffmpeg_audio_processor.h
+@@ -10,8 +10,6 @@
+
+ #if defined(USE_SWRESAMPLE)
+ #include "audio/ffmpeg_audio_processor_swresample.h"
+-#elif defined(USE_AVRESAMPLE)
+-#include "audio/ffmpeg_audio_processor_avresample.h"
+ #else
+ #error "no audio processing library"
+ #endif
+diff --git a/src/audio/ffmpeg_audio_processor_avresample.h b/src/audio/ffmpeg_audio_processor_avresample.h
+deleted file mode 100644
+index bd85f92..0000000
+--- a/src/audio/ffmpeg_audio_processor_avresample.h
++++ /dev/null
+@@ -1,72 +0,0 @@
+-// Copyright (C) 2016  Lukas Lalinsky
+-// Distributed under the MIT license, see the LICENSE file for details.
+-
+-#ifndef CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-#define CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-
+-extern "C" {
+-#include <libavresample/avresample.h>
+-}
+-
+-namespace chromaprint {
+-
+-class FFmpegAudioProcessor {
+-public:
+-	FFmpegAudioProcessor() {
+-		m_resample_ctx = avresample_alloc_context();
+-	}
+-
+-	~FFmpegAudioProcessor() {
+-		avresample_free(&m_resample_ctx);
+-	}
+-
+-	void SetCompatibleMode() {
+-		av_opt_set_int(m_resample_ctx, "filter_size", 16, 0);
+-		av_opt_set_int(m_resample_ctx, "phase_shift", 8, 0);
+-		av_opt_set_int(m_resample_ctx, "linear_interp", 1, 0);
+-		av_opt_set_double(m_resample_ctx, "cutoff", 0.8, 0);
+-	}
+-
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "in_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_rate", sample_rate, 0);
+-	}
+-
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "out_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_rate, 0);
+-	}
+-
+-	int Init() {
+-		return avresample_open(m_resample_ctx);
+-	}
+-
+-	int Convert(uint8_t **out, int out_count, const uint8_t **in, int in_count) {
+-		return avresample_convert(m_resample_ctx, out, 0, out_count, (uint8_t **) in, 0, in_count);
+-	}
+-
+-	int Flush(uint8_t **out, int out_count) {
+-		return avresample_read(m_resample_ctx, out, out_count);
+-	}
+-
+-private:
+-	AVAudioResampleContext *m_resample_ctx = nullptr;
+-};
+-
+-}; // namespace chromaprint
+-
+-#endif
+diff --git a/src/audio/ffmpeg_audio_processor_swresample.h b/src/audio/ffmpeg_audio_processor_swresample.h
+index b86266b..b1d4bea 100644
+--- a/src/audio/ffmpeg_audio_processor_swresample.h
++++ b/src/audio/ffmpeg_audio_processor_swresample.h
+@@ -28,30 +28,28 @@ public:
+ 		av_opt_set_double(m_swr_ctx, "cutoff", 0.8, 0);
+ 	}
+
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "icl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "ich", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetInputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "in_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "isf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "in_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "isr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "in_sample_rate", sample_rate, 0);
+ 	}
+
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "ocl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "och", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetOutputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "out_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "osf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "out_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "osr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "out_sample_rate", sample_rate, 0);
+ 	}
+
+ 	int Init() {
+diff --git a/src/audio/ffmpeg_audio_reader.h b/src/audio/ffmpeg_audio_reader.h
+index 5550164..1c6b346 100644
+--- a/src/audio/ffmpeg_audio_reader.h
++++ b/src/audio/ffmpeg_audio_reader.h
+@@ -62,7 +62,7 @@ public:
+ 	bool Read(const int16_t **data, size_t *size);
+
+ 	bool IsOpen() const { return m_opened; }
+-	bool IsFinished() const { return m_finished && !m_got_frame; }
++	bool IsFinished() const { return !m_has_more_packets && !m_has_more_frames; }
+
+ 	std::string GetError() const { return m_error; }
+ 	int GetErrorCode() const { return m_error_code; }
+@@ -74,20 +74,19 @@ private:
+ 	uint8_t *m_convert_buffer[1] = { nullptr };
+ 	int m_convert_buffer_nb_samples = 0;
+
+-	AVInputFormat *m_input_fmt = nullptr;
++	const AVInputFormat *m_input_fmt = nullptr;
+ 	AVDictionary *m_input_opts = nullptr;
+
+ 	AVFormatContext *m_format_ctx = nullptr;
+ 	AVCodecContext *m_codec_ctx = nullptr;
+-	AVFrame *m_frame = nullptr;
+ 	int m_stream_index = -1;
+ 	std::string m_error;
+ 	int m_error_code = 0;
+-	bool m_finished = false;
+ 	bool m_opened = false;
+-	int m_got_frame = 0;
+-	AVPacket m_packet;
+-	AVPacket m_packet0;
++	bool m_has_more_packets = true;
++	bool m_has_more_frames = true;
++	AVPacket *m_packet = nullptr;
++	AVFrame *m_frame = nullptr;
+
+ 	int m_output_sample_rate = 0;
+ 	int m_output_channels = 0;
+@@ -98,19 +97,12 @@ private:
+
+ inline FFmpegAudioReader::FFmpegAudioReader() {
+ 	av_log_set_level(AV_LOG_QUIET);
+-
+-	av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
+ }
+
+ inline FFmpegAudioReader::~FFmpegAudioReader() {
+ 	Close();
+ 	av_dict_free(&m_input_opts);
+ 	av_freep(&m_convert_buffer[0]);
+-	av_packet_unref(&m_packet0);
+ }
+
+ inline bool FFmpegAudioReader::SetInputFormat(const char *name) {
+@@ -135,11 +127,10 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ 	Close();
+
+-    av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
++	m_packet = av_packet_alloc();
++	if (!m_packet) {
++		return false;
++	}
+
+ 	ret = avformat_open_input(&m_format_ctx, file_name.c_str(), m_input_fmt, &m_input_opts);
+ 	if (ret < 0) {
+@@ -153,26 +144,31 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		return false;
+ 	}
+
+-	AVCodec *codec;
++	const AVCodec *codec;
+ 	ret = av_find_best_stream(m_format_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &codec, 0);
+ 	if (ret < 0) {
+ 		SetError("Could not find any audio stream in the file", ret);
+ 		return false;
+ 	}
+ 	m_stream_index = ret;
++	auto stream = m_format_ctx->streams[m_stream_index];
+
+-	m_codec_ctx = m_format_ctx->streams[m_stream_index]->codec;
++	m_codec_ctx = avcodec_alloc_context3(codec);
+ 	m_codec_ctx->request_sample_fmt = AV_SAMPLE_FMT_S16;
+
++	ret = avcodec_parameters_to_context(m_codec_ctx, stream->codecpar);
++	if (ret < 0) {
++		SetError("Could not copy the stream parameters", ret);
++		return false;
++	}
++
+ 	ret = avcodec_open2(m_codec_ctx, codec, nullptr);
+ 	if (ret < 0) {
+ 		SetError("Could not open the codec", ret);
+ 		return false;
+ 	}
+
+-	if (!m_codec_ctx->channel_layout) {
+-		m_codec_ctx->channel_layout = av_get_default_channel_layout(m_codec_ctx->channels);
+-	}
++	av_dump_format(m_format_ctx, 0, "foo", 0);
+
+ 	m_frame = av_frame_alloc();
+ 	if (!m_frame) {
+@@ -183,19 +179,23 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		m_output_sample_rate = m_codec_ctx->sample_rate;
+ 	}
+
+-	if (!m_output_channels) {
+-		m_output_channels = m_codec_ctx->channels;
++	AVChannelLayout output_channel_layout;
++	if (m_output_channels) {
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
++	} else {
++		m_output_channels = m_codec_ctx->ch_layout.nb_channels;
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
+ 	}
+
+-	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
++	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->ch_layout.nb_channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
+ 		m_converter.reset(new FFmpegAudioProcessor());
+ 		m_converter->SetCompatibleMode();
+ 		m_converter->SetInputSampleFormat(m_codec_ctx->sample_fmt);
+ 		m_converter->SetInputSampleRate(m_codec_ctx->sample_rate);
+-		m_converter->SetInputChannelLayout(m_codec_ctx->channel_layout);
++		m_converter->SetInputChannelLayout(&(m_codec_ctx->ch_layout));
+ 		m_converter->SetOutputSampleFormat(AV_SAMPLE_FMT_S16);
+ 		m_converter->SetOutputSampleRate(m_output_sample_rate);
+-		m_converter->SetOutputChannelLayout(av_get_default_channel_layout(m_output_channels));
++		m_converter->SetOutputChannelLayout(&output_channel_layout);
+ 		auto ret = m_converter->Init();
+ 		if (ret != 0) {
+ 			SetError("Could not create an audio converter instance", ret);
+@@ -203,10 +203,11 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		}
+ 	}
+
++	av_channel_layout_uninit(&output_channel_layout);
++
+ 	m_opened = true;
+-	m_finished = false;
+-	m_got_frame = 0;
+-	m_nb_packets = 0;
++	m_has_more_packets = true;
++	m_has_more_frames = true;
+ 	m_decode_error = 0;
+
+ 	return true;
+@@ -214,6 +215,7 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ inline void FFmpegAudioReader::Close() {
+ 	av_frame_free(&m_frame);
++	av_packet_free(&m_packet);
+
+ 	m_stream_index = -1;
+
+@@ -252,91 +254,98 @@ inline bool FFmpegAudioReader::Read(const int16_t **data, size_t *size) {
+ 		return false;
+ 	}
+
++	*data = nullptr;
++	*size = 0;
++
+ 	int ret;
++	bool needs_packet = false;
+ 	while (true) {
+-		while (m_packet.size <= 0) {
+-			av_packet_unref(&m_packet0);
+-			av_init_packet(&m_packet);
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			ret = av_read_frame(m_format_ctx, &m_packet);
++		while (needs_packet && m_packet->size == 0) {
++			ret = av_read_frame(m_format_ctx, m_packet);
+ 			if (ret < 0) {
+ 				if (ret == AVERROR_EOF) {
+-					m_finished = true;
++					needs_packet = false;
++					m_has_more_packets = false;
+ 					break;
+-				} else {
++				}
++				SetError("Error reading from the audio source", ret);
++				return false;
++			}
++			if (m_packet->stream_index == m_stream_index) {
++				needs_packet = false;
++			} else {
++				av_packet_unref(m_packet);
++			}
++		}
++
++		if (m_packet->size != 0) {
++			ret = avcodec_send_packet(m_codec_ctx, m_packet);
++			if (ret < 0) {
++				if (ret != AVERROR(EAGAIN)) {
+ 					SetError("Error reading from the audio source", ret);
+ 					return false;
+ 				}
+-			}
+-			m_packet0 = m_packet;
+-			if (m_packet.stream_index != m_stream_index) {
+-				m_packet.data = nullptr;
+-				m_packet.size = 0;
+ 			} else {
+-				m_nb_packets++;
++				av_packet_unref(m_packet);
+ 			}
+ 		}
+
+-		ret = avcodec_decode_audio4(m_codec_ctx, m_frame, &m_got_frame, &m_packet);
++		ret = avcodec_receive_frame(m_codec_ctx, m_frame);
+ 		if (ret < 0) {
+-			if (m_decode_error) {
+-				SetError("Error decoding audio frame", m_decode_error);
+-				return false;
++			if (ret == AVERROR_EOF) {
++				m_has_more_frames = false;
++			} else if (ret == AVERROR(EAGAIN)) {
++				if (m_has_more_packets) {
++					needs_packet = true;
++					continue;
++				} else {
++					m_has_more_frames = false;
++				}
+ 			}
+-			m_decode_error = ret;
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			continue;
++			SetError("Error decoding the audio source", ret);
++			return false;
+ 		}
+
+-		break;
+-	}
+-
+-	m_decode_error = 0;
+-
+-	const int decoded = std::min(ret, m_packet.size);
+-	m_packet.data += decoded;
+-	m_packet.size -= decoded;
+-
+-	if (m_got_frame) {
+-		if (m_converter) {
+-			if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
+-				int linsize;
+-				av_freep(&m_convert_buffer[0]);
+-				m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
+-				ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
+-				if (ret < 0) {
+-					SetError("Couldn't allocate audio converter buffer", ret);
++		if (m_frame->nb_samples > 0) {
++			if (m_converter) {
++				if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
++					int linsize;
++					av_freep(&m_convert_buffer[0]);
++					m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
++					ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->ch_layout.nb_channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
++					if (ret < 0) {
++						SetError("Couldn't allocate audio converter buffer", ret);
++						return false;
++					}
++				}
++				auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
++				if (nb_samples < 0) {
++					SetError("Couldn't convert audio", ret);
+ 					return false;
+ 				}
+-			}
+-			auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			}
+-			*data = (const int16_t *) m_convert_buffer[0];
+-			*size = nb_samples;
+-		} else {
+-			*data = (const int16_t *) m_frame->data[0];
+-			*size = m_frame->nb_samples;
+-		}
+-	} else {
+-		if (m_finished && m_converter) {
+-			auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			} else if (nb_samples > 0) {
+-				m_got_frame = 1;
+ 				*data = (const int16_t *) m_convert_buffer[0];
+ 				*size = nb_samples;
++			} else {
++				*data = (const int16_t *) m_frame->data[0];
++				*size = m_frame->nb_samples;
++			}
++		} else {
++			if (m_converter) {
++				if (IsFinished()) {
++					auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
++					if (nb_samples < 0) {
++						SetError("Couldn't convert audio", ret);
++						return false;
++					} else if (nb_samples > 0) {
++						*data = (const int16_t *) m_convert_buffer[0];
++						*size = nb_samples;
++					}
++				}
+ 			}
+ 		}
+-	}
+
+-	return true;
++		return true;
++	}
+ }
+
+ inline void FFmpegAudioReader::SetError(const char *message, int errnum) {
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index a2b517b..123e643 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -38,6 +38,12 @@ set(SRCS
+
+ if(BUILD_TOOLS)
+ 	set(SRCS ${SRCS} ../src/audio/ffmpeg_audio_reader_test.cpp)
++    include_directories(
++        ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}
++        ${AUDIO_PROCESSOR_INCLUDE_DIRS}
++    )
+ 	link_libraries(fpcalc_libs)
+ endif()
+
+-- 
+2.38.1
+
+
diff --git a/srcpkgs/chromaprint/template b/srcpkgs/chromaprint/template
index 7ef7838949f3a..1f7bbc70a22c8 100644
--- a/srcpkgs/chromaprint/template
+++ b/srcpkgs/chromaprint/template
@@ -1,7 +1,7 @@
 # Template file for 'chromaprint'
 pkgname=chromaprint
 version=1.5.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DBUILD_TOOLS=ON"
 make_check_target="check"

From fa97811358208ef90f9605dff0ce17ebcfb6cea2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 022/113] chromium: revbump for ffmpeg6

---
 .../patches/chromium-119-ffmpeg-4.4.patch     | 20 --------
 srcpkgs/chromium/patches/ffmpeg5.patch        | 47 +++++++++++++++++++
 srcpkgs/chromium/template                     |  2 +-
 3 files changed, 48 insertions(+), 21 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch
 create mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch b/srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch
deleted file mode 100644
index 04d04b166ba37..0000000000000
--- a/srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch
+++ /dev/null
@@ -1,20 +0,0 @@
---- a/media/filters/ffmpeg_demuxer.cc.orig
-+++ b/media/filters/ffmpeg_demuxer.cc
-@@ -390,7 +390,7 @@
- 
-   scoped_refptr<DecoderBuffer> buffer;
- 
--    size_t side_data_size = 0;
-+    int side_data_size = 0;
-     uint8_t* side_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
- 
-@@ -453,7 +453,7 @@
-                                        packet->size - data_offset);
-     }
- 
--    size_t skip_samples_size = 0;
-+    int skip_samples_size = 0;
-     const uint32_t* skip_samples_ptr =
-         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
-             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..24e2da38e34ca
--- /dev/null
+++ b/srcpkgs/chromium/patches/ffmpeg5.patch
@@ -0,0 +1,47 @@
+--- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
++++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
+@@ -92,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+-  if (stream->start_time != kNoFFmpegTimestamp)
++  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -1597,7 +1585,7 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+@@ -1618,7 +1606,7 @@
+     if (stream->type() != DemuxerStream::VIDEO)
+       continue;
+ 
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+ 
+     if (!stream->IsEnabled())
diff --git a/srcpkgs/chromium/template b/srcpkgs/chromium/template
index 5613fa3813822..cd386c8a84ae6 100644
--- a/srcpkgs/chromium/template
+++ b/srcpkgs/chromium/template
@@ -2,7 +2,7 @@
 pkgname=chromium
 # See https://chromiumdash.appspot.com/releases?platform=Linux for the latest version
 version=120.0.6099.129
-revision=1
+revision=2
 archs="i686* x86_64* aarch64* armv7l*"
 hostmakedepends="
  $(vopt_if clang "clang lld llvm15")

From 6cbf53087d9c5c8bb701330c82e8bd60e934d10d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 023/113] cmus: revbump for ffmpeg6

---
 srcpkgs/chromium/patches/ffmpeg5.patch | 47 --------------------------
 srcpkgs/cmus/patches/ffmpeg6.patch     | 12 +++++++
 srcpkgs/cmus/template                  |  2 +-
 3 files changed, 13 insertions(+), 48 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch
 create mode 100644 srcpkgs/cmus/patches/ffmpeg6.patch

diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
deleted file mode 100644
index 24e2da38e34ca..0000000000000
--- a/srcpkgs/chromium/patches/ffmpeg5.patch
+++ /dev/null
@@ -1,47 +0,0 @@
---- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
-+++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
-@@ -92,24 +92,12 @@
- 
- static base::TimeDelta ExtractStartTime(AVStream* stream) {
-   // The default start time is zero.
--  base::TimeDelta start_time;
-+  base::TimeDelta start_time = kNoTimestamp;
- 
-   // First try to use  the |start_time| value as is.
--  if (stream->start_time != kNoFFmpegTimestamp)
-+  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
-     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
- 
--  // Next try to use the first DTS value, for codecs where we know PTS == DTS
--  // (excludes all H26x codecs). The start time must be returned in PTS.
--  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
--      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
--      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
--      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
--    const base::TimeDelta first_pts =
--        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
--    if (first_pts < start_time)
--      start_time = first_pts;
--  }
--
-   return start_time;
- }
- 
-@@ -1597,7 +1585,7 @@
-   for (const auto& stream : streams_) {
-     if (!stream || stream->IsEnabled() != enabled)
-       continue;
--    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
-+    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
-       continue;
-     if (!lowest_start_time_stream ||
-         stream->start_time() < lowest_start_time_stream->start_time()) {
-@@ -1618,7 +1606,7 @@
-     if (stream->type() != DemuxerStream::VIDEO)
-       continue;
- 
--    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
-+    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
-       continue;
- 
-     if (!stream->IsEnabled())
diff --git a/srcpkgs/cmus/patches/ffmpeg6.patch b/srcpkgs/cmus/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..ffa95ab811101
--- /dev/null
+++ b/srcpkgs/cmus/patches/ffmpeg6.patch
@@ -0,0 +1,12 @@
+--- a/ip/ffmpeg.c
++++ b/ip/ffmpeg.c
+@@ -202,9 +202,6 @@ static int ffmpeg_open(struct input_plugin_data *ip_data)
+ 			break;
+ 		}
+ 
+-		if (codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+-			cc->flags |= AV_CODEC_FLAG_TRUNCATED;
+-
+ 		if (avcodec_open2(cc, codec, NULL) < 0) {
+ 			d_print("could not open codec: %d, %s\n", cc->codec_id, avcodec_get_name(cc->codec_id));
+ 			err = -IP_ERROR_UNSUPPORTED_FILE_TYPE;
diff --git a/srcpkgs/cmus/template b/srcpkgs/cmus/template
index 0d1436744f1b2..a6e4b4fa86cb8 100644
--- a/srcpkgs/cmus/template
+++ b/srcpkgs/cmus/template
@@ -1,7 +1,7 @@
 # Template file for 'cmus'
 pkgname=cmus
 version=2.10.0
-revision=3
+revision=4
 build_style=configure
 configure_args="prefix=/usr LD=$CC"
 hostmakedepends="pkg-config"

From 2bf167e2c64bc3a365a7da76ff2dc8fa80c29156 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 024/113] cyanrip: revbump for ffmpeg6

---
 srcpkgs/cyanrip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cyanrip/template b/srcpkgs/cyanrip/template
index 9796e3461601a..5db30e020d17e 100644
--- a/srcpkgs/cyanrip/template
+++ b/srcpkgs/cyanrip/template
@@ -1,7 +1,7 @@
 # Template file for 'cyanrip'
 pkgname=cyanrip
 version=0.9.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config"
 makedepends="ffmpeg-devel libcdio-devel libcdio-paranoia-devel libcurl-devel libmusicbrainz5-devel"

From db79e558885c8b4623d0f85f45b43676494fe7f9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 025/113] deadbeef: revbump for ffmpeg4

---
 srcpkgs/deadbeef/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/deadbeef/template b/srcpkgs/deadbeef/template
index f5f4bf24b8cb6..7b47e615cd48e 100644
--- a/srcpkgs/deadbeef/template
+++ b/srcpkgs/deadbeef/template
@@ -1,14 +1,14 @@
 # Template file for 'deadbeef'
 pkgname=deadbeef
 version=1.8.8
-revision=3
+revision=4
 create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-oss --disable-lfm --disable-notify --disable-gtk2"
 hostmakedepends="automake libtool gettext gettext-devel intltool pkg-config
  yasm clang glib-devel"
 makedepends="
- alsa-lib-devel dbus-devel faad2-devel ffmpeg-devel gtk+3-devel imlib2-devel
+ alsa-lib-devel dbus-devel faad2-devel ffmpeg4-devel gtk+3-devel imlib2-devel
  jansson-devel libcddb-devel libcdio-devel libcurl-devel libflac-devel
  libmad-devel libpng-devel libsamplerate-devel libsndfile-devel libvorbis-devel
  libzip-devel mpg123-devel opusfile-devel pulseaudio-devel wavpack-devel"

From 475efa21862a5713ed14f5cab4d9f4a60db3027d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 026/113] droidcam-obs-plugin: revbump for ffmpeg6

---
 srcpkgs/droidcam-obs-plugin/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam-obs-plugin/template b/srcpkgs/droidcam-obs-plugin/template
index fc9c9bf6b9d54..fb0480754df4d 100644
--- a/srcpkgs/droidcam-obs-plugin/template
+++ b/srcpkgs/droidcam-obs-plugin/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam-obs-plugin'
 pkgname=droidcam-obs-plugin
 version=2.0.1
-revision=1
+revision=2
 build_style=gnu-makefile
 make_use_env=yes
 make_build_args="ALLOW_STATIC=no"

From fd4640f594c2f1f3725142758437aa6f5c78ac52 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 027/113] droidcam: revbump for ffmpeg6

---
 srcpkgs/droidcam/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam/template b/srcpkgs/droidcam/template
index 1c3f1b8b1fc67..32a9220b79a4d 100644
--- a/srcpkgs/droidcam/template
+++ b/srcpkgs/droidcam/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam'
 pkgname=droidcam
 version=1.8.2
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="USBMUXD=-lusbmuxd-2.0 JPEG=-lturbojpeg"
 hostmakedepends="pkg-config"

From c18ac496500de6fd0d253f96c837a3b381043cf4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 028/113] ffmpegthumbnailer: revbump for ffmpeg6

---
 .../ffmpegthumbnailer/patches/ffmpeg6.patch   | 202 ++++++++++++++++++
 srcpkgs/ffmpegthumbnailer/template            |   6 +-
 2 files changed, 205 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch

diff --git a/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..363ff35a28419
--- /dev/null
+++ b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
@@ -0,0 +1,202 @@
+--- a/libffmpegthumbnailer/moviedecoder.cpp	2017-11-21 14:06:57.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.cpp	2023-05-05 13:14:47.946560668 -0400
+@@ -41,11 +41,6 @@
+ namespace ffmpegthumbnailer
+ {
+ 
+-struct SilenceLogLevel
+-{
+-    SilenceLogLevel() { av_log_set_level(AV_LOG_QUIET); }
+-};
+-
+ MovieDecoder::MovieDecoder(AVFormatContext* pavContext)
+ : m_VideoStream(-1)
+ , m_pFormatContext(pavContext)
+@@ -70,8 +65,6 @@
+ 
+ void MovieDecoder::initialize(const string& filename, bool preferEmbeddedMetadata)
+ {
+-    av_register_all();
+-    avcodec_register_all();
+     avformat_network_init();
+ 
+     string inputFile = filename == "-" ? "pipe:" : filename;
+@@ -97,8 +90,7 @@
+ {
+     if (m_pVideoCodecContext)
+     {
+-        avcodec_close(m_pVideoCodecContext);
+-        m_pVideoCodecContext = nullptr;
++        avcodec_free_context(&m_pVideoCodecContext);
+     }
+ 
+     if ((!m_FormatContextWasGiven) && m_pFormatContext)
+@@ -152,10 +144,10 @@
+     for (unsigned int i = 0; i < m_pFormatContext->nb_streams; ++i)
+     {
+         AVStream *stream = m_pFormatContext->streams[i];
+-        auto ctx = m_pFormatContext->streams[i]->codec;
+-        if (ctx->codec_type == AVMEDIA_TYPE_VIDEO)
++        auto par = m_pFormatContext->streams[i]->codecpar;
++        if (par->codec_type == AVMEDIA_TYPE_VIDEO)
+         {
+-            if (!preferEmbeddedMetadata || !isStillImageCodec(ctx->codec_id))
++            if (!preferEmbeddedMetadata || !isStillImageCodec(par->codec_id))
+             {
+                 videoStreams.push_back(i);
+                 continue;
+@@ -203,8 +195,7 @@
+     }
+ 
+     m_pVideoStream = m_pFormatContext->streams[m_VideoStream];
+-    m_pVideoCodecContext = m_pVideoStream->codec;
+-    m_pVideoCodec = avcodec_find_decoder(m_pVideoCodecContext->codec_id);
++    m_pVideoCodec = avcodec_find_decoder(m_pVideoStream->codecpar->codec_id);
+ 
+     if (m_pVideoCodec == nullptr)
+     {
+@@ -214,6 +205,20 @@
+         throw logic_error("Video Codec not found");
+     }
+ 
++    m_pVideoCodecContext = avcodec_alloc_context3(m_pVideoCodec);
++
++    if (m_pVideoCodecContext == nullptr)
++    {
++        destroy();
++        throw logic_error("Could not allocate video codec context");
++    }
++
++    if (avcodec_parameters_to_context(m_pVideoCodecContext, m_pVideoStream->codecpar) < 0)
++    {
++        destroy();
++        throw logic_error("Could not configure video codec context");
++    }
++
+     m_pVideoCodecContext->workaround_bugs = 1;
+ 
+     if (avcodec_open2(m_pVideoCodecContext, m_pVideoCodec, nullptr) < 0)
+@@ -386,13 +391,6 @@
+ 
+ void MovieDecoder::initializeFilterGraph(const AVRational& timeBase, const std::string& size, bool maintainAspectRatio)
+ {
+-    static const AVPixelFormat pixelFormats[] = { AV_PIX_FMT_RGB24, AV_PIX_FMT_NONE };
+-
+-    auto del = [] (AVBufferSinkParams* p) { av_freep(p); };
+-    std::unique_ptr<AVBufferSinkParams, decltype(del)> buffersinkParams(av_buffersink_params_alloc(), del);
+-
+-    avfilter_register_all();
+-
+     m_pFilterGraph = avfilter_graph_alloc();
+     assert(m_pFilterGraph);
+ 
+@@ -404,10 +402,8 @@
+ 
+     checkRc(avfilter_graph_create_filter(&m_pFilterSource, avfilter_get_by_name("buffer"), "thumb_buffer", ss.str().c_str(), nullptr, m_pFilterGraph),
+             "Failed to create filter source");
+-    buffersinkParams->pixel_fmts = pixelFormats;
+-    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, buffersinkParams.get(), m_pFilterGraph),
++    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, nullptr, m_pFilterGraph),
+             "Failed to create filter sink");
+-    buffersinkParams.release();
+ 
+     AVFilterContext* yadifFilter = nullptr;
+     if (m_pFrame->interlaced_frame != 0)
+@@ -500,15 +496,15 @@
+     }
+ 
+     checkRc(av_seek_frame(m_pFormatContext, -1, timestamp, 0), "Seeking in video failed");
+-    avcodec_flush_buffers(m_pFormatContext->streams[m_VideoStream]->codec);
++    avcodec_flush_buffers(m_pVideoCodecContext);
+ 
+     int keyFrameAttempts = 0;
+-    bool gotFrame = 0;
++    bool gotFrame;
+ 
+     do
+     {
+         int count = 0;
+-        gotFrame = 0;
++        gotFrame = false;
+ 
+         while (!gotFrame && count < 20)
+         {
+@@ -552,17 +548,33 @@
+         return false;
+     }
+ 
+-    av_frame_unref(m_pFrame);
+-
+-    int frameFinished;
++    int rc = avcodec_send_packet(m_pVideoCodecContext, m_pPacket);
++    if(rc == AVERROR(EAGAIN))
++    {
++        rc = 0;
++    }
+ 
+-    int bytesDecoded = avcodec_decode_video2(m_pVideoCodecContext, m_pFrame, &frameFinished, m_pPacket);
+-    if (bytesDecoded < 0)
++    if(rc == AVERROR_EOF)
++    {
++        return false;
++    }
++    else if(rc < 0)
+     {
+-        throw logic_error("Failed to decode video frame: bytesDecoded < 0");
++        throw logic_error("Failed to decode video frame: avcodec_send_packet() < 0");
+     }
+ 
+-    return frameFinished > 0;
++    rc = avcodec_receive_frame(m_pVideoCodecContext, m_pFrame);
++    switch(rc)
++    {
++        case 0:
++            return true;
++
++        case AVERROR(EAGAIN):
++            return false;
++
++        default:
++            throw logic_error("Failed to decode video frame: avcodec_receive_frame() < 0");
++    }
+ }
+ 
+ bool MovieDecoder::getVideoPacket()
+@@ -570,8 +582,6 @@
+     bool framesAvailable = true;
+     bool frameDecoded = false;
+ 
+-    int attempts = 0;
+-
+     if (m_pPacket)
+     {
+         av_packet_unref(m_pPacket);
+@@ -580,6 +590,7 @@
+ 
+     m_pPacket = new AVPacket();
+ 
++
+     while (framesAvailable && !frameDecoded)
+     {
+         framesAvailable = av_read_frame(m_pFormatContext, m_pPacket) >= 0;
+@@ -644,7 +655,7 @@
+ 
+ int32_t MovieDecoder::getStreamRotation()
+ {
+-    int32_t* matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
++    auto matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
+     if (matrix)
+     {
+         auto angle = lround(av_display_rotation_get(matrix));
+
+--- a/libffmpegthumbnailer/moviedecoder.h	2017-11-12 04:23:38.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.h	2023-05-05 13:26:07.095529911 -0400
+@@ -78,7 +78,7 @@
+     int                     m_VideoStream;
+     AVFormatContext*        m_pFormatContext;
+     AVCodecContext*         m_pVideoCodecContext;
+-    AVCodec*                m_pVideoCodec;
++    const AVCodec*          m_pVideoCodec;
+     AVFilterGraph*          m_pFilterGraph;
+     AVFilterContext*        m_pFilterSource;
+     AVFilterContext*        m_pFilterSink;
diff --git a/srcpkgs/ffmpegthumbnailer/template b/srcpkgs/ffmpegthumbnailer/template
index 039eea7622b39..35d546018d12a 100644
--- a/srcpkgs/ffmpegthumbnailer/template
+++ b/srcpkgs/ffmpegthumbnailer/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbnailer'
 pkgname=ffmpegthumbnailer
 version=2.2.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libpng-devel libjpeg-turbo-devel ffmpeg-devel"
@@ -9,8 +9,8 @@ depends="ffmpeg"
 short_desc="Lightweight video thumbnailer"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
-homepage="https://github.com/dirkvdb/${pkgname}"
-distfiles="${homepage}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
+homepage="https://github.com/dirkvdb"
+distfiles="${homepage}/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
 checksum=1cb24059c38223f657b300c84dd80491b7040d4b69471c4fea69be862bc99b5b
 
 post_install() {

From 46fde90401bff8fccc0d5ffd92c75663fae23d0d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 029/113] ffmpegthumbs: revbump for ffmpeg6

---
 srcpkgs/ffmpegthumbs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ffmpegthumbs/template b/srcpkgs/ffmpegthumbs/template
index 5f0b9414dadaf..11b88193528f4 100644
--- a/srcpkgs/ffmpegthumbs/template
+++ b/srcpkgs/ffmpegthumbs/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbs'
 pkgname=ffmpegthumbs
 version=22.12.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules kcoreaddons kconfig-devel
  pkg-config qt5-host-tools qt5-qmake gettext"

From 6523b16bcf7fd89326667a6b3673dd5308009257 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 030/113] ffms2: revbump for ffmpeg6

---
 srcpkgs/ffms2/patches/ffmpeg5.patch | 424 ++++++++++++++++++++++++++++
 srcpkgs/ffms2/template              |   2 +-
 2 files changed, 425 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ffms2/patches/ffmpeg5.patch

diff --git a/srcpkgs/ffms2/patches/ffmpeg5.patch b/srcpkgs/ffms2/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..1479fabcafcb4
--- /dev/null
+++ b/srcpkgs/ffms2/patches/ffmpeg5.patch
@@ -0,0 +1,424 @@
+From 45673149e9a2f5586855ad472e3059084eaa36b1 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:41:21 +0100
+Subject: [PATCH] Use auto for AVCodec
+
+The geniuses over at FFmpeg decided to constify this API, so old
+versions of the library will return AVCodec *, while new versions
+of the libary will return const AVCodec *, which, in C++, are not
+OK to convert between.
+
+Rather than use some macro hell in ffmscompat.h, we can work around
+this by using auto.
+
+Gross.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 2 +-
+ src/core/indexing.cpp    | 6 +++---
+ src/core/videosource.cpp | 2 +-
+ 3 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index e4ce97c..ac09666 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -469,7 +469,7 @@ void FFMS_AudioSource::OpenFile() {
+ 
+     LAVFOpenFile(SourceFile.c_str(), FormatContext, TrackNumber);
+ 
+-    AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
++    auto *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
+     if (Codec == nullptr)
+         throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+             "Audio codec not found");
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index e547c5a..59fb4e8 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -384,7 +384,7 @@ FFMS_TrackType FFMS_Indexer::GetTrackType(int Track) {
+ }
+ 
+ const char *FFMS_Indexer::GetTrackCodec(int Track) {
+-    AVCodec *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
++    auto *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
+     return codec ? codec->name : nullptr;
+ }
+ 
+@@ -402,7 +402,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             UseDTS);
+ 
+         if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            AVCodec *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (!VideoCodec) {
+                 FormatContext->streams[i]->discard = AVDISCARD_ALL;
+                 IndexMask.erase(i);
+@@ -433,7 +433,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 IndexMask.insert(i);
+             }
+         } else if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+-            AVCodec *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (AudioCodec == nullptr)
+                 throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_UNSUPPORTED,
+                     "Audio codec not found");
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index b889970..8956c22 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -171,7 +171,7 @@ FFMS_VideoSource::FFMS_VideoSource(const char *SourceFile, FFMS_Index &Index, in
+ 
+         LAVFOpenFile(SourceFile, FormatContext, VideoTrack);
+ 
+-        AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
++        auto *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
+         if (Codec == nullptr)
+             throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+                 "Video codec not found");
+-- 
+2.40.0
+
+From 96cbf38ea9381829a1314f432a2c60495dcefaad Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:12:41 +0100
+Subject: [PATCH] all: Update AVPacket API usage
+
+AVPackets must all be on the heap now, since it is no longer
+part of the libav* ABI.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 16 ++++++----
+ src/core/indexing.cpp    | 63 ++++++++++++++++++++++------------------
+ src/core/indexing.h      |  4 +--
+ src/core/utils.cpp       |  6 ----
+ src/core/utils.h         |  1 -
+ src/core/videosource.cpp | 30 ++++++++++---------
+ 6 files changed, 64 insertions(+), 56 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index 37cf9ae..e4ce97c 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -285,10 +285,15 @@ FFMS_AudioSource::AudioBlock *FFMS_AudioSource::CacheBlock(CacheIterator &pos) {
+ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     CurrentFrame = &Frames[PacketNumber];
+ 
+-    AVPacket Packet;
+-    if (!ReadPacket(&Packet))
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++    if (!ReadPacket(Packet)) {
++        av_packet_free(&Packet);
+         throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_UNKNOWN,
+             "ReadPacket unexpectedly failed to read a packet");
++    }
+ 
+     // ReadPacket may have changed the packet number
+     CurrentFrame = &Frames[PacketNumber];
+@@ -297,8 +302,9 @@ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     int NumberOfSamples = 0;
+     AudioBlock *CachedBlock = nullptr;
+     
+-    int Ret = avcodec_send_packet(CodecContext, &Packet);
+-    av_packet_unref(&Packet);
++    int Ret = avcodec_send_packet(CodecContext, Packet);
++    av_packet_unref(Packet);
++    av_packet_free(&Packet);
+ 
+     av_frame_unref(DecodeFrame);
+     Ret = avcodec_receive_frame(CodecContext, DecodeFrame);
+@@ -513,8 +519,6 @@ void FFMS_AudioSource::Seek() {
+ }
+ 
+ bool FFMS_AudioSource::ReadPacket(AVPacket *Packet) {
+-    InitNullPacket(*Packet);
+-
+     while (av_read_frame(FormatContext, Packet) >= 0) {
+         if (Packet->stream_index == TrackNumber) {
+             // Required because not all audio packets, especially in ogg, have a pts. Use the previous valid packet's pts instead.
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index 23fb95b..e547c5a 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -320,7 +320,7 @@ void FFMS_Indexer::CheckAudioProperties(int Track, AVCodecContext *Context) {
+     }
+ }
+ 
+-void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict,
++void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict,
+                                     int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct) {
+     if (VideoContext.Parser) {
+         uint8_t *OB;
+@@ -330,8 +330,8 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+         av_parser_parse2(VideoContext.Parser,
+             VideoContext.CodecContext,
+             &OB, &OBSize,
+-            pkt.data, pkt.size,
+-            pkt.pts, pkt.dts, pkt.pos);
++            pkt->data, pkt->size,
++            pkt->pts, pkt->dts, pkt->pos);
+ 
+         // H.264 (PAFF) and HEVC may have one field per packet, so we need to track
+         // when we have a full or half frame available, and mark one of them as
+@@ -351,15 +351,15 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+ 
+         *RepeatPict = VideoContext.Parser->repeat_pict;
+         *FrameType = VideoContext.Parser->pict_type;
+-        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt.flags & AV_PKT_FLAG_DISCARD));
++        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt->flags & AV_PKT_FLAG_DISCARD));
+     } else {
+-        *Invisible = !!(pkt.flags & AV_PKT_FLAG_DISCARD);
++        *Invisible = !!(pkt->flags & AV_PKT_FLAG_DISCARD);
+     }
+ 
+     if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP8)
+-        ParseVP8(pkt.data[0], Invisible, FrameType);
++        ParseVP8(pkt->data[0], Invisible, FrameType);
+     else if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP9)
+-        ParseVP9(pkt.data[0], Invisible, FrameType);
++        ParseVP9(pkt->data[0], Invisible, FrameType);
+ }
+ 
+ void FFMS_Indexer::Free() {
+@@ -458,32 +458,36 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+         }
+     }
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
+     std::vector<int64_t> LastValidTS(FormatContext->nb_streams, AV_NOPTS_VALUE);
+ 
+     int64_t filesize = avio_size(FormatContext->pb);
+     enum AVPictureStructure LastPicStruct = AV_PICTURE_STRUCTURE_UNKNOWN;
+-    while (av_read_frame(FormatContext, &Packet) >= 0) {
++    while (av_read_frame(FormatContext, Packet) >= 0) {
+         // Update progress
+         // FormatContext->pb can apparently be NULL when opening images.
+         if (IC && FormatContext->pb) {
+-            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate))
++            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate)) {
++                av_packet_free(&Packet);
+                 throw FFMS_Exception(FFMS_ERROR_CANCELLED, FFMS_ERROR_USER,
+                     "Cancelled by user");
++            }
+         }
+-        if (!IndexMask.count(Packet.stream_index)) {
+-            av_packet_unref(&Packet);
++        if (!IndexMask.count(Packet->stream_index)) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+-        int Track = Packet.stream_index;
++        int Track = Packet->stream_index;
+         FFMS_Track &TrackInfo = (*TrackIndices)[Track];
+-        bool KeyFrame = !!(Packet.flags & AV_PKT_FLAG_KEY);
++        bool KeyFrame = !!(Packet->flags & AV_PKT_FLAG_KEY);
+         ReadTS(Packet, LastValidTS[Track], (*TrackIndices)[Track].UseDTS);
+ 
+         if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            int64_t PTS = TrackInfo.UseDTS ? Packet.dts : Packet.pts;
++            int64_t PTS = TrackInfo.UseDTS ? Packet->dts : Packet->pts;
+             if (PTS == AV_NOPTS_VALUE) {
+                 // VPx alt-refs are output as packets which lack timestmps or durations, since
+                 // they are invisible. Currently, the timestamp mangling code in libavformat
+@@ -495,9 +499,11 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 // FFMS2 currently sorts packets by PTS, which will break decoding, otherwise.
+                 bool HasAltRefs = (FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP8 ||
+                                    FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP9);
+-                if (Packet.duration == 0 && !HasAltRefs)
++                if (Packet->duration == 0 && !HasAltRefs) {
++                    av_packet_free(&Packet);
+                     throw FFMS_Exception(FFMS_ERROR_INDEXING, FFMS_ERROR_PARSER,
+                         "Invalid packet pts, dts, and duration");
++                }
+ 
+                 if (TrackInfo.empty())
+                     PTS = 0;
+@@ -513,7 +519,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             ParseVideoPacket(AVContexts[Track], Packet, &RepeatPict, &FrameType, &Invisible, &LastPicStruct);
+ 
+             TrackInfo.AddVideoFrame(PTS, RepeatPict, KeyFrame,
+-                FrameType, Packet.pos, Invisible);
++                FrameType, Packet->pos, Invisible);
+         } else if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+             // For video seeking timestamps are used only if all packets have
+             // timestamps, while for audio they're used if any have timestamps,
+@@ -522,28 +528,29 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 TrackInfo.HasTS = true;
+ 
+             int64_t StartSample = AVContexts[Track].CurrentSample;
+-            uint32_t SampleCount = IndexAudioPacket(Track, &Packet, AVContexts[Track], *TrackIndices);
++            uint32_t SampleCount = IndexAudioPacket(Track, Packet, AVContexts[Track], *TrackIndices);
+             TrackInfo.SampleRate = AVContexts[Track].CodecContext->sample_rate;
+ 
+             TrackInfo.AddAudioFrame(LastValidTS[Track],
+-                StartSample, SampleCount, KeyFrame, Packet.pos, Packet.flags & AV_PKT_FLAG_DISCARD);
++                StartSample, SampleCount, KeyFrame, Packet->pos, Packet->flags & AV_PKT_FLAG_DISCARD);
+         }
+ 
+-        if (!(Packet.flags & AV_PKT_FLAG_DISCARD))
+-            TrackInfo.LastDuration = Packet.duration;
++        if (!(Packet->flags & AV_PKT_FLAG_DISCARD))
++            TrackInfo.LastDuration = Packet->duration;
+ 
+-        av_packet_unref(&Packet);
++        av_packet_unref(Packet);
+     }
++    av_packet_free(&Packet);
+ 
+     TrackIndices->Finalize(AVContexts, FormatContext->iformat->name);
+     return TrackIndices.release();
+ }
+ 
+-void FFMS_Indexer::ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS) {
+-    if (!UseDTS && Packet.pts != AV_NOPTS_VALUE)
+-        TS = Packet.pts;
++void FFMS_Indexer::ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS) {
++    if (!UseDTS && Packet->pts != AV_NOPTS_VALUE)
++        TS = Packet->pts;
+     if (TS == AV_NOPTS_VALUE)
+         UseDTS = true;
+-    if (UseDTS && Packet.dts != AV_NOPTS_VALUE)
+-        TS = Packet.dts;
++    if (UseDTS && Packet->dts != AV_NOPTS_VALUE)
++        TS = Packet->dts;
+ }
+diff --git a/src/core/indexing.h b/src/core/indexing.h
+index 3cfc3c3..5c06868 100644
+--- a/src/core/indexing.h
++++ b/src/core/indexing.h
+@@ -80,10 +80,10 @@ private:
+     int64_t Filesize;
+     uint8_t Digest[20];
+ 
+-    void ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS);
++    void ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS);
+     void CheckAudioProperties(int Track, AVCodecContext *Context);
+     uint32_t IndexAudioPacket(int Track, AVPacket *Packet, SharedAVContext &Context, FFMS_Index &TrackIndices);
+-    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
++    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
+     void Free();
+ public:
+     FFMS_Indexer(const char *Filename);
+diff --git a/src/core/utils.cpp b/src/core/utils.cpp
+index ce67533..8a2e997 100644
+--- a/src/core/utils.cpp
++++ b/src/core/utils.cpp
+@@ -62,12 +62,6 @@ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo) {
+     }
+ }
+ 
+-void InitNullPacket(AVPacket &pkt) {
+-    av_init_packet(&pkt);
+-    pkt.data = nullptr;
+-    pkt.size = 0;
+-}
+-
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames) {
+     AP.SampleFormat = static_cast<FFMS_SampleFormat>(av_get_packed_sample_fmt(CTX->sample_fmt));
+     AP.BitsPerSample = av_get_bytes_per_sample(CTX->sample_fmt) * 8;
+diff --git a/src/core/utils.h b/src/core/utils.h
+index 9819dc7..003ab79 100644
+--- a/src/core/utils.h
++++ b/src/core/utils.h
+@@ -58,7 +58,6 @@ std::unique_ptr<T> make_unique(Args&&... args) {
+ }
+ 
+ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo);
+-void InitNullPacket(AVPacket &pkt);
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames);
+ 
+ void LAVFOpenFile(const char *SourceFile, AVFormatContext *&FormatContext, int Track);
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index 06bd161..b889970 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -673,30 +673,34 @@ void FFMS_VideoSource::DecodeNextFrame(int64_t &AStartTime, int64_t &Pos) {
+     if (HasPendingDelayedFrames())
+         return;
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
+-
+-    while (ReadFrame(&Packet) >= 0) {
+-        if (Packet.stream_index != VideoTrack) {
+-            av_packet_unref(&Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++
++    while (ReadFrame(Packet) >= 0) {
++        if (Packet->stream_index != VideoTrack) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+         if (AStartTime < 0)
+-            AStartTime = Frames.UseDTS ? Packet.dts : Packet.pts;
++            AStartTime = Frames.UseDTS ? Packet->dts : Packet->pts;
+ 
+         if (Pos < 0)
+-            Pos = Packet.pos;
++            Pos = Packet->pos;
+ 
+-        bool FrameFinished = DecodePacket(&Packet);
+-        av_packet_unref(&Packet);
+-        if (FrameFinished)
++        bool FrameFinished = DecodePacket(Packet);
++        av_packet_unref(Packet);
++        if (FrameFinished) {
++            av_packet_free(&Packet);
+             return;
++        }
+     }
+ 
+     // Flush final frames
+-    InitNullPacket(Packet);
+-    DecodePacket(&Packet);
++    DecodePacket(Packet);
++    av_packet_free(&Packet);
+ }
+ 
+ bool FFMS_VideoSource::SeekTo(int n, int SeekOffset) {
+-- 
+2.40.0
+
+From bf9e03e9e08534c024e5a744a6437c4aac160201 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:20:47 +0100
+Subject: [PATCH 2/3] configure: Remove deprecated API use
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ configure.ac | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index b35ef80bc..d19714d0f 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -102,10 +102,10 @@ CFLAGS="$_CFLAGS $FFMPEG_CFLAGS"
+
+ AC_DEFUN([TEST_FFMPEG],
+          [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+-            #include <libavcodec/avcodec.h>
++            #include <libavformat/avformat.h>
+             #include <libswscale/swscale.h>
+             ]],[[
+-                avcodec_register_all();
++                avformat_network_init();
+                 swscale_version();
+             ]])], [eval $1=yes], [eval $1=no])
+         ])
+
diff --git a/srcpkgs/ffms2/template b/srcpkgs/ffms2/template
index 365f64d10cbab..1641ecf43be5b 100644
--- a/srcpkgs/ffms2/template
+++ b/srcpkgs/ffms2/template
@@ -1,7 +1,7 @@
 # Template file for 'ffms2'
 pkgname=ffms2
 version=2.40
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-shared --disable-static"
 hostmakedepends="pkg-config autoconf automake libtool"

From d1efd693c87d63a306f201d98f4279448f3bbbd1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 031/113] freerdp: revbump for ffmpeg6

---
 .../freerdp/patches/ffmpeg6_aa2cb9aa.patch    | 42 +++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100644 srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch

diff --git a/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
new file mode 100644
index 0000000000000..a4324da3a8822
--- /dev/null
+++ b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
@@ -0,0 +1,42 @@
+From aa2cb9aa5ff5562433598ba168a466e0752bca0e Mon Sep 17 00:00:00 2001
+From: akallabeth <akallabeth@posteo.net>
+Date: Tue, 14 Feb 2023 07:48:54 +0100
+Subject: [PATCH] Fixed #8686: Update h264 to use new FFMPEG API
+
+---
+ channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c | 2 ++
+ libfreerdp/codec/h264_ffmpeg.c            | 2 ++
+ 2 files changed, 4 insertions(+)
+
+diff --git a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+index 339462d865f..beea80b7a1e 100644
+--- a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
++++ b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+@@ -239,8 +239,10 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYP
+ 		}
+ 	}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 	if (mdecoder->codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		mdecoder->codec_context->flags |= AV_CODEC_FLAG_TRUNCATED;
++#endif
+ 
+ 	return TRUE;
+ }
+diff --git a/libfreerdp/codec/h264_ffmpeg.c b/libfreerdp/codec/h264_ffmpeg.c
+index 8a23db2473c..896a333019b 100644
+--- a/libfreerdp/codec/h264_ffmpeg.c
++++ b/libfreerdp/codec/h264_ffmpeg.c
+@@ -615,10 +615,12 @@ static BOOL libavcodec_init(H264_CONTEXT* h264)
+ 			goto EXCEPTION;
+ 		}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 		if (sys->codecDecoder->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		{
+ 			sys->codecDecoderContext->flags |= AV_CODEC_FLAG_TRUNCATED;
+ 		}
++#endif
+ 
+ #ifdef WITH_VAAPI
+ 

From f2d509dd21270198b196afcd07a0263aa24dc96f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 032/113] gerbera: revbump for ffmpeg6

---
 srcpkgs/gerbera/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gerbera/template b/srcpkgs/gerbera/template
index ae14f35c767c0..2dc0ac0ce03b5 100644
--- a/srcpkgs/gerbera/template
+++ b/srcpkgs/gerbera/template
@@ -1,7 +1,7 @@
 # Template file for 'gerbera'
 pkgname=gerbera
 version=1.12.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_SYSTEMD=0 -DWITH_AVCODEC=1"
 hostmakedepends="pkg-config"

From 795baba9283a1cd09db18974fe8d18a850b96a63 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 033/113] goldendict: revbump for ffmpeg6

---
 srcpkgs/goldendict/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/goldendict/template b/srcpkgs/goldendict/template
index f4a05759f693d..97f44347b03a6 100644
--- a/srcpkgs/goldendict/template
+++ b/srcpkgs/goldendict/template
@@ -1,7 +1,7 @@
 # Template file for 'goldendict'
 pkgname=goldendict
 version=1.5.0
-revision=1
+revision=2
 build_style=qmake
 configure_args="CONFIG+=zim_support goldendict.pro"
 hostmakedepends="qt5-qmake pkg-config qt5-host-tools"
@@ -10,7 +10,7 @@ makedepends="tiff-devel qt5-devel libvorbis-devel zlib-devel
  qt5-webkit-devel lzo-devel bzip2-devel libao-devel qt5-svg-devel
  libeb-devel qt5-x11extras-devel ffmpeg-devel liblzma-devel
  qt5-multimedia-devel"
-short_desc="A feature-rich dictionary lookup program"
+short_desc="Feature-rich dictionary lookup program"
 maintainer="John <me@johnnynator.dev>"
 license="GPL-3.0-or-later"
 homepage="http://goldendict.org/"

From 62b2f7f6201f4d0fead6d8399e37aea61c8187a2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 034/113] gst-libav: revbump for ffmpeg6

---
 srcpkgs/gst-libav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index 78afeee4aefb2..f892eb2063564 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.22.7
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"

From aa1cc8b8a2f33311c44a82fafad9ddeea630ab87 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 035/113] gst-rtsp-server: revbump for ffmpeg6

---
 srcpkgs/gst-rtsp-server/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index 2c280c84f1514..83a2949fd9482 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
 version=1.22.7
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="glib-devel gst-plugins-bad1-devel gobject-introspection

From f1005a206753a4acbb33ba6a508217eec61b747f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 036/113] guvcview: update to 2.0.8.

---
 srcpkgs/guvcview/patches/fix-include.patch | 10 ++++++++++
 srcpkgs/guvcview/template                  |  7 +++----
 2 files changed, 13 insertions(+), 4 deletions(-)
 create mode 100644 srcpkgs/guvcview/patches/fix-include.patch

diff --git a/srcpkgs/guvcview/patches/fix-include.patch b/srcpkgs/guvcview/patches/fix-include.patch
new file mode 100644
index 0000000000000..503c2af3b78c1
--- /dev/null
+++ b/srcpkgs/guvcview/patches/fix-include.patch
@@ -0,0 +1,10 @@
+--- a/guvcview/guvcview.c
++++ b/guvcview/guvcview.c
+@@ -28,6 +28,7 @@
+ #include <sys/stat.h>
+ #include <sys/resource.h>
+ #include <errno.h>
++#include <locale.h>
+ 
+ #include "gview.h"
+ #include "gviewv4l2core.h"
diff --git a/srcpkgs/guvcview/template b/srcpkgs/guvcview/template
index d42fd38fa4ad1..86a7fd619612c 100644
--- a/srcpkgs/guvcview/template
+++ b/srcpkgs/guvcview/template
@@ -1,8 +1,7 @@
 # Template file for 'guvcview'
 pkgname=guvcview
-version=2.0.7
-revision=2
-create_wrksrc=yes
+version=2.0.8
+revision=1
 build_style=gnu-configure
 configure_args="--disable-static --disable-debian-menu"
 hostmakedepends="pkg-config intltool autoconf automake libtool glib-devel"
@@ -14,7 +13,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="http://guvcview.sourceforge.net/"
 distfiles="${SOURCEFORGE_SITE}/${pkgname}/${pkgname}-src-${version}.tar.bz2"
-checksum=f47d51fbd06e44eeaa1a82f4a153c927527c90d94514197a70b2956028cc8ad4
+checksum=a21f4e448286666cf27bafef5290cc953a0a1796b752e5bbe521266dc1230c81
 
 post_patch() {
 	sed '31a#include <locale.h>' -i  guvcview/guvcview.c

From 702e22d7ce5722bd08075694f98c183908e14d68 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 037/113] handbrake: update to 1.6.1

---
 .../patches/fix-missing-x265-link-flag.patch    | 11 ++++++-----
 .../handbrake/patches/libhb-vpl-include.patch   | 15 +++++++++++++++
 srcpkgs/handbrake/template                      | 17 ++++++++++-------
 3 files changed, 31 insertions(+), 12 deletions(-)
 create mode 100644 srcpkgs/handbrake/patches/libhb-vpl-include.patch

diff --git a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
index 26db03867a0c8..d6bb2eda627a3 100644
--- a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
+++ b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
@@ -1,14 +1,15 @@
 --- a/gtk/configure.ac
 +++ b/gtk/configure.ac
 @@ -203,7 +203,7 @@
- 
+
  AM_CONDITIONAL([MINGW], [test "x$mingw_flag" = "xyes"])
- 
--HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg"
-+HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -ldl"
+
+-HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc"
++HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc -ldl"
  HB_CPPFLAGS="$HB_CPPFLAGS $HBINC"
- 
+
  PKG_CHECK_MODULES([x264], [x264], sys_x264=yes, sys_x264=no)
+
 --- a/test/module.defs
 +++ b/test/module.defs
 @@ -69,6 +69,9 @@
diff --git a/srcpkgs/handbrake/patches/libhb-vpl-include.patch b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
new file mode 100644
index 0000000000000..298f9f4ab28f2
--- /dev/null
+++ b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
@@ -0,0 +1,15 @@
+--- a/libhb/module.defs	2023-01-22 11:36:49.000000000 -0500
++++ b/libhb/module.defs	2023-04-03 22:37:52.395467010 -0400
+@@ -46,11 +46,7 @@
+ LIBHB.GCC.I += $(LIBHB.build/) $(CONTRIB.build/)include
+ 
+ ifeq (1,$(FEATURE.qsv))
+-    ifeq ($(HOST.system),freebsd))
+-        LIBHB.GCC.I += $(LOCALBASE)/include/vpl
+-    else
+-        LIBHB.GCC.I += $(CONTRIB.build/)include/vpl
+-    endif
++    LIBHB.GCC.I += /usr/include/vpl
+ endif
+ 
+ ifneq (,$(filter $(HOST.system),freebsd netbsd openbsd))
diff --git a/srcpkgs/handbrake/template b/srcpkgs/handbrake/template
index ca5e4571e49c3..c32cb1bfa31f4 100644
--- a/srcpkgs/handbrake/template
+++ b/srcpkgs/handbrake/template
@@ -1,10 +1,10 @@
 # Template file for 'handbrake'
 pkgname=handbrake
-version=1.5.1
+version=1.6.1
 revision=1
 build_style=gnu-configure
 configure_args="--force --disable-gtk-update-checks --disable-df-fetch --harden
- $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc)"
+ $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc) $(vopt_enable qsv)"
 make_build_args="-C ${XBPS_TRIPLET}"
 make_install_args="-C ${XBPS_TRIPLET}"
 hostmakedepends="automake cmake gettext-devel glib-devel intltool libtool m4 meson nasm pkg-config python3"
@@ -12,8 +12,11 @@ makedepends="bzip2-devel ffmpeg-devel gst-plugins-base1-devel gtk+3-devel
  jansson-devel lame-devel libass-devel libbluray-devel libdav1d-devel
  libdvdnav-devel libdvdread-devel libgudev-devel libnuma-devel
  libsamplerate-devel libtheora-devel libvorbis-devel libvpx-devel libxml2-devel
- opus-devel speex-devel x264-devel x265-devel zimg-devel
+ opus-devel speex-devel x264-devel x265-devel zimg-devel libsvt-av1-devel
  $(vopt_if fdk_aac fdk-aac-devel)
+ $(vopt_if qsv libva-devel)
+ $(vopt_if qsv libdrm-devel)
+ $(vopt_if qsv onevpl-devel)
  $(vopt_if nvenc nv-codec-headers)"
 depends="desktop-file-utils gst-plugins-good1 hicolor-icon-theme"
 short_desc="Multithreaded video transcoder"
@@ -21,15 +24,15 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-2.0-only"
 homepage="https://handbrake.fr/"
 distfiles="https://github.com/HandBrake/HandBrake/releases/download/${version}/HandBrake-${version}-source.tar.bz2"
-checksum=3999fe06d5309c819799a73a968a8ec3840e7840c2b64af8f5cdb7fd8c9430f0
+checksum=94ccfe03db917a91650000c510f7fd53f844da19f19ad4b4be1b8f6bc31a8d4c
 nocross=yes
 
-build_options="fdk_aac nvenc"
+build_options="fdk_aac nvenc qsv"
 
 case "$XBPS_TARGET_MACHINE" in
 	x86_64*|i686*)
 		CFLAGS="-msse"
-		build_options_default="nvenc"
+		build_options_default="nvenc qsv"
 		;;
 esac
 
@@ -37,7 +40,7 @@ pre_configure() {
 	# use system libraries, don't download them
 	rm -rf contrib/
 	for module in fdk-aac ffmpeg libbluray libdav1d libdvdnav libdvdread nvenc \
-		x265 zimg; do
+		x265 zimg svt-av1 libvpl; do
 	    vsed -i "/MODULES += contrib\/${module}/d" make/include/main.defs
 	done
 }

From 1ccc2e055144b156fc595c3eac9e3a4e4f0a6db0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 038/113] hedgewars: revbump for ffmpeg4

---
 srcpkgs/hedgewars/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/hedgewars/template b/srcpkgs/hedgewars/template
index 94b6db673b0c3..402ccfaaecbc2 100644
--- a/srcpkgs/hedgewars/template
+++ b/srcpkgs/hedgewars/template
@@ -1,13 +1,13 @@
 # Template file for 'hedgewars'
 pkgname=hedgewars
 version=1.0.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DNOSERVER=1 -DDATA_INSTALL_DIR=/usr/share/${pkgname}
  -DPHYSFS_SYSTEM=1 -DMINIMAL_FLAGS=1"
 make_cmd=make
 hostmakedepends="lua51 pkg-config qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
+makedepends="ffmpeg4-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
  SDL2_mixer-devel SDL2_net-devel SDL2_ttf-devel"
 depends="libfreeglut"
 short_desc="Funny turn-based artillery game, featuring fighting Hedgehogs!"

From 4ac0d4de03c9244a7c3d8773c35d19543d6558c7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 039/113] idjc: revbump for ffmpeg4

---
 srcpkgs/idjc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/idjc/template b/srcpkgs/idjc/template
index a9cde0665d55b..6f1d21c5781fd 100644
--- a/srcpkgs/idjc/template
+++ b/srcpkgs/idjc/template
@@ -5,7 +5,7 @@ revision=5
 build_style=gnu-configure
 hostmakedepends="pkg-config git python3 automake gettext-devel libtool"
 makedepends="libvorbis-devel libogg-devel jack-devel libsamplerate-devel
- libflac-devel libsndfile-devel mpg123-devel ffmpeg-devel speex-devel
+ libflac-devel libsndfile-devel mpg123-devel ffmpeg4-devel speex-devel
  glib-devel pixman-devel lame-devel python3-gobject-devel libshout-idjc-devel
  opus-devel twolame-devel python3-mutagen python3-devel"
 depends="python3-gobject python3-mutagen desktop-file-utils shared-mime-info python3-dbus jack"

From 1c98bf861b06acd915ad9540499eb73db98ae5d1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 040/113] kid3: revbump for ffmpeg6

---
 srcpkgs/kid3/patches/ffmpeg5.patch | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 srcpkgs/kid3/patches/ffmpeg5.patch

diff --git a/srcpkgs/kid3/patches/ffmpeg5.patch b/srcpkgs/kid3/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..135fc50e07c9b
--- /dev/null
+++ b/srcpkgs/kid3/patches/ffmpeg5.patch
@@ -0,0 +1,17 @@
+# https://aur.archlinux.org/cgit/aur.git/diff/ffmpeg5.patch?h=kid3-cli&id=12410a74906612e7efc0ec8fbce739b4a0fef7e7
+diff --git a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+index e156d424..e12b9abd 100644
+--- a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
++++ b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+@@ -232,7 +232,11 @@ private:
+   friend class Format;
+   friend class Converter;
+   AVCodecContext* m_ptr;
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 0, 0)
+   AVCodec* m_impl;
++#else
++  const AVCodec* m_impl;
++#endif
+   AVFrame* m_frame;
+   bool m_opened;
+ };

From b248620464d03a0dba23933d1461909e82665911 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 041/113] kodi: revbump for ffmpeg4

---
 srcpkgs/kodi/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kodi/template b/srcpkgs/kodi/template
index d37a5918cd675..536ee1fc83a7d 100644
--- a/srcpkgs/kodi/template
+++ b/srcpkgs/kodi/template
@@ -54,7 +54,7 @@ makedepends="
  libmad-devel fontconfig-devel libXinerama-devel libsamplerate-devel libmms-devel
  enca-devel boost-devel libcurl-devel libva-devel libvdpau-devel libass-devel
  libbluetooth-devel yajl-devel libplist-devel librtmp-devel tinyxml-devel
- taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg-devel
+ taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg4-devel
  giflib-devel libxslt-devel gnutls-devel libssh-devel libmicrohttpd-devel
  libcec-devel dcadec-devel flatbuffers-devel fmt-devel lcms2-devel
  libfstrcmp-devel rapidjson libcdio-paranoia spdlog libwaylandpp-devel

From 05d1c569ce13c69a3f821ff8acc9d9a6aa55f4ae Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 042/113] kpipewire: revbump for ffmpeg6

---
 srcpkgs/kpipewire/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kpipewire/template b/srcpkgs/kpipewire/template
index 6214a4451336e..3555348659dde 100644
--- a/srcpkgs/kpipewire/template
+++ b/srcpkgs/kpipewire/template
@@ -1,7 +1,7 @@
 # Template file for 'kpipewire'
 pkgname=kpipewire
 version=5.27.10
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules plasma-wayland-protocols gettext
  qt5-qmake qt5-host-tools pkg-config wayland-devel kcoreaddons

From c849d9bd81aa68067053444d37aa8866b91a3554 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 043/113] libextractor: revbump for ffmpeg4

---
 srcpkgs/libextractor/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libextractor/template b/srcpkgs/libextractor/template
index 044c663a3a0b9..ace88ae128da5 100644
--- a/srcpkgs/libextractor/template
+++ b/srcpkgs/libextractor/template
@@ -7,7 +7,7 @@ configure_args="--disable-static"
 hostmakedepends="pkg-config"
 makedepends="zlib-devel bzip2-devel exiv2-devel tiff-devel libpng-devel
  libjpeg-turbo-devel libvorbis-devel libflac-devel giflib-devel libmpeg2-devel
- ffmpeg-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
+ ffmpeg4-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
 short_desc="Library used to extract meta data from files"
 maintainer="Martin Riese <grauehaare@gmx.de>"
 license="GPL-3.0-or-later"

From 82b88094e8696a2795349a1bd118a0d0c1520879 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 044/113] libopenal: revbump for ffmpeg6

---
 srcpkgs/libopenal/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenal/template b/srcpkgs/libopenal/template
index 88d0f11307d81..8308fca0393e3 100644
--- a/srcpkgs/libopenal/template
+++ b/srcpkgs/libopenal/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenal'
 pkgname=libopenal
 version=1.23.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DALSOFT_EXAMPLES=OFF"
 hostmakedepends="pkg-config"

From 086dde64c2030271208631f181eb37f74593bd31 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 045/113] loudgain: revbump for ffmpeg6

---
 srcpkgs/loudgain/patches/ffmpeg5.patch | 11 +++++++++++
 srcpkgs/loudgain/template              |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/loudgain/patches/ffmpeg5.patch

diff --git a/srcpkgs/loudgain/patches/ffmpeg5.patch b/srcpkgs/loudgain/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..16d4510ee98fa
--- /dev/null
+++ b/srcpkgs/loudgain/patches/ffmpeg5.patch
@@ -0,0 +1,11 @@
+--- a/src/scan.c	2019-09-06 11:31:19.000000000 -0400
++++ b/src/scan.c	2023-03-23 11:15:40.867968521 -0400
+@@ -69,8 +69,6 @@
+ 	 * It is now useless
+ 	 * https://github.com/FFmpeg/FFmpeg/blob/70d25268c21cbee5f08304da95be1f647c630c15/doc/APIchanges#L86
+ 	 */
+-  if (avformat_version() < AV_VERSION_INT(58,9,100))
+-    av_register_all();
+ 
+ 	av_log_set_callback(scan_av_log);
+ 
diff --git a/srcpkgs/loudgain/template b/srcpkgs/loudgain/template
index da4f2d56e94c3..4d6bf29efb4fd 100644
--- a/srcpkgs/loudgain/template
+++ b/srcpkgs/loudgain/template
@@ -1,7 +1,7 @@
 # Template file for 'loudgain'
 pkgname=loudgain
 version=0.6.8
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libebur128-devel taglib-devel ffmpeg-devel"

From e08a12cc529fe34ef5ccdceb12c4f80366fb2438 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 046/113] mediastreamer: revbump for ffmpeg4

---
 srcpkgs/mediastreamer/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mediastreamer/template b/srcpkgs/mediastreamer/template
index 0fcffa7653d18..92ada88743a9b 100644
--- a/srcpkgs/mediastreamer/template
+++ b/srcpkgs/mediastreamer/template
@@ -5,7 +5,7 @@ revision=2
 build_style=cmake
 configure_args="-DENABLE_STRICT=0 -DENABLE_UNIT_TESTS=0"
 hostmakedepends="python3"
-makedepends="bzrtp-devel ffmpeg-devel glew-devel libXv-devel libsrtp-devel
+makedepends="bzrtp-devel ffmpeg4-devel glew-devel libXv-devel libsrtp-devel
  libupnp-devel libvpx-devel mbedtls-devel opus-devel ortp-devel pulseaudio-devel
  libtheora-devel speex-devel v4l-utils-devel bcg729-devel bcmatroska2-devel libgsm-devel
  zxing-cpp-devel"

From f56ec21dc8d3c834b8a8e3cf1cb90449c947265d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 047/113] mgba: revbump for ffmpeg6

---
 srcpkgs/mgba/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mgba/template b/srcpkgs/mgba/template
index 5513e3fd16f3f..f5c87a4893002 100644
--- a/srcpkgs/mgba/template
+++ b/srcpkgs/mgba/template
@@ -1,7 +1,7 @@
 # Template file for 'mgba'
 pkgname=mgba
 version=0.10.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake desktop-file-utils"
 makedepends="SDL2-devel ffmpeg-devel libedit-devel libepoxy-devel libmagick-devel

From d8ec3b51281a0354f2a8ee2bdac016c69486c93c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 048/113] mlt: revbump for ffmpeg4

---
 srcpkgs/mlt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mlt/template b/srcpkgs/mlt/template
index 73e3915aaab9a..ec5054be3b75e 100644
--- a/srcpkgs/mlt/template
+++ b/srcpkgs/mlt/template
@@ -8,7 +8,7 @@ configure_args="--prefix=/usr --libdir=/usr/lib$XBPS_TARGET_WORDSIZE
  --swig-languages=python"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which"
 # XXX: movit vid.stab
-makedepends="alsa-lib-devel ffmpeg-devel gtk+-devel jack-devel ladspa-sdk
+makedepends="alsa-lib-devel ffmpeg4-devel gtk+-devel jack-devel ladspa-sdk
  libexif-devel libsamplerate-devel libxml2-devel sox-devel SDL_image-devel
  fftw-devel frei0r-plugins python3-devel pulseaudio-devel movit-devel
  libvidstab-devel"

From c73e9c965974584bfaf4fa32c2a0c824e88ff837 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 049/113] moc: revbump for ffmpeg4

---
 srcpkgs/moc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/moc/template b/srcpkgs/moc/template
index 3a04932c8f1e6..d8de816026b64 100644
--- a/srcpkgs/moc/template
+++ b/srcpkgs/moc/template
@@ -4,7 +4,7 @@ version=2.5.2
 revision=7
 build_style=gnu-configure
 hostmakedepends="pkg-config"
-makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg-devel
+makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg4-devel
  jack-devel alsa-lib-devel libltdl-devel libflac-devel libvorbis-devel
  libmad-devel libmpcdec-devel libmodplug-devel libid3tag-devel faad2-devel
  taglib-devel libsndfile-devel wavpack-devel speex-devel libsamplerate-devel

From 94d46040051eca26e3853b2ac512bda295c0dea8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 050/113] motion: revbump for ffmpeg6

---
 srcpkgs/motion/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/motion/template b/srcpkgs/motion/template
index 607ebeb3c7b24..bf63a91d9764f 100644
--- a/srcpkgs/motion/template
+++ b/srcpkgs/motion/template
@@ -1,7 +1,7 @@
 # Template file for 'motion'
 pkgname=motion
 version=4.6.0
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake pkg-config gettext-devel tar"
 makedepends="ffmpeg-devel libmicrohttpd-devel v4l-utils-devel gettext-devel"

From f315793544ced496c56b26f3d335bf3039a7f429 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 051/113] notcurses: revbump for ffmpeg6

---
 srcpkgs/notcurses/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/notcurses/template b/srcpkgs/notcurses/template
index 6dd8a091319f7..3110c30c9aff2 100644
--- a/srcpkgs/notcurses/template
+++ b/srcpkgs/notcurses/template
@@ -1,7 +1,7 @@
 # Template file for 'notcurses'
 pkgname=notcurses
 version=3.0.9
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DUSE_STATIC=ON $(vopt_bool man USE_PANDOC)"
 hostmakedepends="pkg-config $(vopt_if man pandoc)"

From 57a4c52b5cd2900803c521e40c07c7eef097c329 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 052/113] olive: revbump for ffmpeg4

---
 srcpkgs/olive/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/olive/template b/srcpkgs/olive/template
index 12a46936c9900..5c2917b9c5124 100644
--- a/srcpkgs/olive/template
+++ b/srcpkgs/olive/template
@@ -1,10 +1,10 @@
 # Template file for 'olive'
 pkgname=olive
 version=0.1.2
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools pkg-config"
-makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg-devel frei0r-plugins"
+makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg4-devel frei0r-plugins"
 short_desc="Non-linear video editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"

From 9dc36dd89fb6315defe73c6e5218f8cdf15f6b17 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 053/113] omxplayer: revbump for ffmpeg4

---
 srcpkgs/omxplayer/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/omxplayer/template b/srcpkgs/omxplayer/template
index 9a66690c83ebb..a21b878878037 100644
--- a/srcpkgs/omxplayer/template
+++ b/srcpkgs/omxplayer/template
@@ -1,7 +1,7 @@
 # Template file for 'omxplayer'
 pkgname=omxplayer
 version=20190102
-revision=2
+revision=3
 short_desc="Commandline OMX player for the Raspberry Pi"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
@@ -15,7 +15,7 @@ checksum=af2d9450f8947842ea8c401fe9f71eec444013ebbdee29f2ac828c9c493c1329
 archs="armv6l* armv7l*"
 build_style=gnu-makefile
 hostmakedepends="ruby-ronn pkg-config"
-makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg-devel dbus-devel"
+makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg4-devel dbus-devel"
 depends="freefont-ttf"
 
 do_build() {

From 498444f672c625a85c4ebbba74f4aaed0b611bb9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 054/113] opentoonz: revbump for ffmpeg6

---
 srcpkgs/opentoonz/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/opentoonz/template b/srcpkgs/opentoonz/template
index ee9f7603f55fd..3e81834ca0edd 100644
--- a/srcpkgs/opentoonz/template
+++ b/srcpkgs/opentoonz/template
@@ -1,7 +1,7 @@
 # Template file for 'opentoonz'
 pkgname=opentoonz
 version=1.6.0
-revision=2
+revision=3
 build_wrksrc="toonz/sources"
 build_style=cmake
 make_cmd=make

From 4745a0c173f3c7665f3d107c3f1c15b51303b906 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 055/113] pianobar: revbump for ffmpeg6

---
 srcpkgs/pianobar/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pianobar/template b/srcpkgs/pianobar/template
index e3febb821a451..1e3dc1bf9308e 100644
--- a/srcpkgs/pianobar/template
+++ b/srcpkgs/pianobar/template
@@ -1,7 +1,7 @@
 # Template file for 'pianobar'
 pkgname=pianobar
 version=2022.04.01
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="V=1"
 hostmakedepends="pkg-config"

From fe2cdb6a0ab16aeb3767083ce82ab1fbd27fba59 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 056/113] ppsspp: revbump for ffmpeg4

---
 srcpkgs/ppsspp/template | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/srcpkgs/ppsspp/template b/srcpkgs/ppsspp/template
index 2c0ded496eb98..8bf55f65198cd 100644
--- a/srcpkgs/ppsspp/template
+++ b/srcpkgs/ppsspp/template
@@ -1,7 +1,7 @@
 # Template file for 'ppsspp'
 pkgname=ppsspp
 version=1.16.6
-revision=1
+revision=2
 _glslang_commit=b34f619e1c85810dcb3c578107d2e48ba4ee2b37
 _SPIRV_Cross_commit=4212eef67ed0ca048cb726a6767185504e7695e5
 _armips_commit=7bd1ec93d4586985ba1ef420b43b5e620f68695e
@@ -15,7 +15,7 @@ configure_args="-DHEADLESS=1 -DUSE_SYSTEM_FFMPEG=1 -DUNITTEST=ON
  -DUSING_QT_UI=$(vopt_if qt ON OFF) -DUSE_SYSTEM_ZSTD=ON
  -DARMIPS_USE_STD_FILESYSTEM=ON"
 hostmakedepends="pkg-config python3 $(vopt_if qt qt5-host-tools)"
-makedepends="zlib-devel glew-devel ffmpeg-devel libzip-devel
+makedepends="zlib-devel glew-devel ffmpeg4-devel libzip-devel
  snappy-devel rapidjson libpng-devel libzstd-devel
  $(vopt_if sdl2 'SDL2_ttf-devel SDL2-devel') $(vopt_if wayland wayland-devel)
  $(vopt_if qt 'qt5-devel qt5-multimedia-devel')"
@@ -69,10 +69,10 @@ post_extract() {
 	rmdir -v ${wrksrc}/ext/cpu_features
 	mv ${wrksrc}/cpu_features-${_cpu_features_commit} ${wrksrc}/ext/cpu_features
 	rmdir -v ${wrksrc}/ext/rcheevos
-        mv ${wrksrc}/rcheevos-${_rcheevos_commit} ${wrksrc}/ext/rcheevos
+	mv ${wrksrc}/rcheevos-${_rcheevos_commit} ${wrksrc}/ext/rcheevos
 }
 
-post_patch(){
+post_patch() {
 	# disable git versioning
 	vsed -e 's|find_package(Git)|# &|' -i git-version.cmake
 }
@@ -85,7 +85,6 @@ post_configure() {
 }
 
 do_install() {
-	vlicense LICENSE.TXT
 	vinstall icons/icon.svg 644 usr/share/pixmaps ppsspp.svg
 	vinstall Qt/PPSSPP.desktop 644 usr/share/applications
 	vbin build/PPSSPPHeadless ppsspp-headless

From cd4990db9410349563de643cee4258cd36c30f03 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 057/113] pqiv: revbump for ffmpeg6

---
 srcpkgs/pqiv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pqiv/template b/srcpkgs/pqiv/template
index 542fc27a2d32a..9308d949b6a1c 100644
--- a/srcpkgs/pqiv/template
+++ b/srcpkgs/pqiv/template
@@ -1,7 +1,7 @@
 # Template file for 'pqiv'
 pkgname=pqiv
 version=2.12
-revision=1
+revision=2
 build_style=gnu-makefile
 hostmakedepends="pkg-config"
 makedepends="glib-devel gtk+3-devel $(vopt_if ffmpeg ffmpeg-devel)

From 63a2aa5567f2d0f287c4ca59e28eecc503a5648b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 058/113] qmmp: revbump for ffmpeg6

---
 srcpkgs/qmmp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qmmp/template b/srcpkgs/qmmp/template
index 53781ea3bc28a..2da07f1e87eac 100644
--- a/srcpkgs/qmmp/template
+++ b/srcpkgs/qmmp/template
@@ -1,7 +1,7 @@
 # Template file for 'qmmp'
 pkgname=qmmp
 version=1.6.1
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DUSE_HAL:BOOL=FALSE -DQMMP_DEFAULT_UI:STRING=simple"
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From 1b5c75f43104192b6b0319d3dfb5485047337f07 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 14 Dec 2023 13:28:10 -0500
Subject: [PATCH 059/113] qt6-pdf: revbump for ffmpeg6

---
 srcpkgs/qt6-pdf/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-pdf/template b/srcpkgs/qt6-pdf/template
index ecda84afac131..531b4e1d4fe84 100644
--- a/srcpkgs/qt6-pdf/template
+++ b/srcpkgs/qt6-pdf/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-pdf'
 pkgname=qt6-pdf
 version=6.6.0
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DQT_FEATURE_qtpdf_build=ON
  -DQT_FEATURE_qtpdf_widgets_build=ON

From ca103e1f3330a4c3feafb51c880c2bdbf6914d90 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 060/113] qt5-webengine: revbump for ffmpeg6

---
 .../chromium-media-filters-cpp14.patch        |  11 ++
 srcpkgs/qt5-webengine/patches/ffmpeg5.patch   | 179 ++++++++++++++++++
 .../qtwebengine-fix-ffmpeg5-build.patch       |  14 ++
 srcpkgs/qt5-webengine/template                |   4 +-
 4 files changed, 206 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/ffmpeg5.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch

diff --git a/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
new file mode 100644
index 0000000000000..04adc540f2cbc
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
@@ -0,0 +1,11 @@
+--- a/src/3rdparty/chromium/media/filters/BUILD.gn	2023-02-27 13:32:59.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/BUILD.gn	2023-04-02 17:21:39.204066384 -0400
+@@ -96,6 +96,8 @@
+     "//ui/gfx/geometry:geometry",
+   ]
+ 
++  cflags_cc = [ "-std=c++14" ]
++
+   libs = []
+ 
+   if (proprietary_codecs) {
diff --git a/srcpkgs/qt5-webengine/patches/ffmpeg5.patch b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..ac55e1634423a
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
@@ -0,0 +1,179 @@
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:57.732547446 -0400
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:09.486478995 -0400
+@@ -57,6 +57,8 @@
+ 
+ namespace {
+ 
++constexpr int64_t kRelativeTsBase = static_cast<int64_t>(0x7ffeffffffffffff);
++
+ void SetAVStreamDiscard(AVStream* stream, AVDiscard discard) {
+   DCHECK(stream);
+   stream->discard = discard;
+@@ -90,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+   if (stream->start_time != kNoFFmpegTimestamp)
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (stream->first_dts != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, stream->first_dts);
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -408,11 +398,11 @@
+   scoped_refptr<DecoderBuffer> buffer;
+ 
+   if (type() == DemuxerStream::TEXT) {
+-    int id_size = 0;
++    size_t id_size = 0;
+     uint8_t* id_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
+ 
+-    int settings_size = 0;
++    size_t settings_size = 0;
+     uint8_t* settings_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
+ 
+@@ -424,7 +414,7 @@
+     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
+                                      side_data.data(), side_data.size());
+   } else {
+-    int side_data_size = 0;
++    size_t side_data_size = 0;
+     uint8_t* side_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
+ 
+@@ -485,7 +475,7 @@
+                                        packet->size - data_offset);
+     }
+ 
+-    int skip_samples_size = 0;
++    size_t skip_samples_size = 0;
+     const uint32_t* skip_samples_ptr =
+         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
+             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
+@@ -1587,6 +1577,8 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++      continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+       lowest_start_time_stream = stream.get();
+@@ -1604,6 +1596,8 @@
+     if (stream && stream->type() == DemuxerStream::VIDEO &&
+         stream->IsEnabled()) {
+       video_stream = stream.get();
++      if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++        continue;
+       if (video_stream->start_time() <= seek_time) {
+         return video_stream;
+       }
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h qtwebengine-5.15.10/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h
+--- a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-07-11 22:12:47.917192788 -0500
+@@ -29,6 +29,7 @@ extern "C" {
+ #include <libavformat/avformat.h>
+ #include <libavformat/avio.h>
+ #include <libavutil/avutil.h>
++#include <libavutil/channel_layout.h>
+ #include <libavutil/imgutils.h>
+ #include <libavutil/log.h>
+ #include <libavutil/mastering_display_metadata.h>
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/audio_file_reader.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/audio_file_reader.cc
+--- a/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -85,7 +85,7 @@ bool AudioFileReader::OpenDemuxer() {
+ }
+ 
+ bool AudioFileReader::OpenDecoder() {
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (codec) {
+     // MP3 decodes to S16P which we don't support, tell it to use S16 instead.
+     if (codec_context_->sample_fmt == AV_SAMPLE_FMT_S16P)
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -329,7 +329,7 @@ bool FFmpegAudioDecoder::ConfigureDecode
+     }
+   }
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec ||
+       avcodec_open2(codec_context_.get(), codec, &codec_options) < 0) {
+     DLOG(ERROR) << "Could not initialize audio decoder: "
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -59,7 +59,6 @@ static int64_t AVIOSeekOperation(void* o
+ }
+ 
+ void FFmpegGlue::InitializeFFmpeg() {
+-  av_register_all();
+ }
+ 
+ static void LogContainer(bool is_local_file,
+@@ -95,9 +94,6 @@ FFmpegGlue::FFmpegGlue(FFmpegURLProtocol
+   // Enable fast, but inaccurate seeks for MP3.
+   format_context_->flags |= AVFMT_FLAG_FAST_SEEK;
+ 
+-  // Ensures we can read out various metadata bits like vp8 alpha.
+-  format_context_->flags |= AVFMT_FLAG_KEEP_SIDE_DATA;
+-
+   // Ensures format parsing errors will bail out. From an audit on 11/2017, all
+   // instances were real failures. Solves bugs like http://crbug.com/710791.
+   format_context_->error_recognition |= AV_EF_EXPLODE;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -391,7 +391,7 @@ bool FFmpegVideoDecoder::ConfigureDecode
+   if (decode_nalus_)
+     codec_context_->flags2 |= AV_CODEC_FLAG2_CHUNKS;
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
+     ReleaseFFmpegResources();
+     return false;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/media_file_checker.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/media_file_checker.cc
+--- a/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -68,7 +68,7 @@ bool MediaFileChecker::Start(base::TimeD
+       auto context = AVStreamToAVCodecContext(format_context->streams[i]);
+       if (!context)
+         continue;
+-      AVCodec* codec = avcodec_find_decoder(cp->codec_id);
++      const AVCodec* codec = avcodec_find_decoder(cp->codec_id);
+       if (codec && avcodec_open2(context.get(), codec, nullptr) >= 0) {
+         auto loop = std::make_unique<FFmpegDecodingLoop>(context.get());
+         stream_contexts[i] = {std::move(context), std::move(loop)};
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc qtwebengine-5.15.10/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc
+--- a/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -203,7 +203,7 @@ int32_t H264DecoderImpl::InitDecode(cons
+   // a pointer |this|.
+   av_context_->opaque = this;
+ 
+-  AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
+   if (!codec) {
+     // This is an indication that FFmpeg has not been initialized or it has not
+     // been compiled/initialized with the correct set of codecs.
diff --git a/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch b/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch
new file mode 100644
index 0000000000000..bc24d5b9a29cb
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch
@@ -0,0 +1,14 @@
+--- a/src/buildtools/configure.json	2023-12-09 11:06:01.503058569 -0500
++++ b/src/buildtools/configure.json	2023-12-09 11:06:14.982361345 -0500
+@@ -779,11 +779,6 @@
+             "type": "warning",
+             "condition": "config.ios && config.simulator && config.device && features.build-qtpdf",
+             "message": "Building fat libray with device and simulator architectures will disable NEON."
+-        },
+-        {
+-            "type": "fatal",
+-            "condition": "features.webengine-system-ffmpeg && !libs.webengine-ffmpeg-support",
+-            "message": "Unmodified ffmpeg >= 5.0 is not supported. Please configure with -qt-webengine-ffmpeg."
+         }
+     ],
+     "summary": [
diff --git a/srcpkgs/qt5-webengine/template b/srcpkgs/qt5-webengine/template
index 8d2df1b5175ba..1687a77eb8a2f 100644
--- a/srcpkgs/qt5-webengine/template
+++ b/srcpkgs/qt5-webengine/template
@@ -1,14 +1,14 @@
 # Template file for 'qt5-webengine'
 pkgname=qt5-webengine
 version=5.15.16
-revision=1
+revision=2
 _version="${version}-lts"
 _chromium_commit=207c2ac45ca3386d153770c6b0d2ea2ec21ca880
 archs="x86_64* i686* armv[67]* ppc64* aarch64*"
 create_wrksrc=yes
 build_style=qmake
 configure_args="--
- -webengine-icu -webengine-ffmpeg -webengine-opus -webengine-webp
+ -webengine-icu -system-ffmpeg -webengine-opus -webengine-webp
  -webengine-pepper-plugins -webengine-printing-and-pdf -webengine-proprietary-codecs
  -webengine-pulseaudio -webengine-spellchecker -webengine-webrtc -webengine-geolocation
  -webengine-kerberos -no-webengine-embedded-build $(vopt_if sndio '' '-no')-webengine-sndio

From 3f3a9ed61b8d1eb7ee0b9a40974789f49f536dfb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 061/113] qt5: revbump for ffmpeg6

---
 srcpkgs/qt5/template | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/srcpkgs/qt5/template b/srcpkgs/qt5/template
index ef6e437e02dbc..97b7818cc37d8 100644
--- a/srcpkgs/qt5/template
+++ b/srcpkgs/qt5/template
@@ -3,9 +3,9 @@
 # revbump libqtxdg after bumping patch version
 pkgname=qt5
 version=5.15.11+20231124
+revision=2
 # commit 4765fa1df7a837db9c1f89c4da0dd76b74bb5fab
 # base repo: https://invent.kde.org/qt/qt/qt5
-revision=1
 build_style=meta
 hostmakedepends="cmake clang flex perl glib-devel pkg-config
  python3 re2c ruby which"
@@ -246,7 +246,6 @@ do_configure() {
 	# opts+=" -v"
 	opts+=" -skip qtwebengine"
 	opts+=" -skip qtwebview"
-	opts+=" -skip qtdocgallery"
 	opts+=" -skip qtpim"
 	opts+=" -skip qtsystems"
 	opts+=" -skip qtspeech"

From c060d6d1afc4b75c4b8d22b8c7d42acb42a48e47 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 062/113] qtav: revbump for ffmpeg4

---
 srcpkgs/qtav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qtav/template b/srcpkgs/qtav/template
index 775d5a139a9ef..2d00ad104355e 100644
--- a/srcpkgs/qtav/template
+++ b/srcpkgs/qtav/template
@@ -4,7 +4,7 @@ version=1.13.0
 revision=2
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel libass-devel libopenal-devel
+makedepends="ffmpeg4-devel libass-devel libopenal-devel
  libva-glx-devel libXv-devel pulseaudio-devel
  qt5-declarative-devel qt5-svg-devel
  qt5-quickcontrols"

From a93e75ca38109bbac29bfae92d70dd494919cb93 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 063/113] retroarch: revbump for ffmpeg6

---
 srcpkgs/retroarch/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroarch/template b/srcpkgs/retroarch/template
index cb3125c5dbf1a..c65c26f7bf033 100644
--- a/srcpkgs/retroarch/template
+++ b/srcpkgs/retroarch/template
@@ -1,7 +1,7 @@
 # Template file for 'retroarch'
 pkgname=retroarch
 version=1.16.0.3
-revision=3
+revision=4
 build_style=configure
 configure_args="--prefix=/usr --sysconfdir=/etc --enable-networking
  --enable-udev --disable-builtinflac --disable-builtinglslang

From e47a9333b9cd198cecbe00a99c27d337dedf2cf1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 064/113] scrcpy: revbump for ffmpeg6

---
 srcpkgs/scrcpy/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/scrcpy/template b/srcpkgs/scrcpy/template
index ac18bc03418ce..f39a7f678ab35 100644
--- a/srcpkgs/scrcpy/template
+++ b/srcpkgs/scrcpy/template
@@ -1,7 +1,7 @@
 # Template file for 'scrcpy'
 pkgname=scrcpy
 version=2.1.1
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcompile_server=false
  -Dprebuilt_server=/usr/share/scrcpy/scrcpy-server-v${version}"

From 5eb053f3c9d604810506015b4298c9462d0af791 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 17 Oct 2023 08:54:11 -0400
Subject: [PATCH 065/113] New package: spex-x replaces spek-alternative for
 ffmpeg6

---
 srcpkgs/spek-alternative                      |  1 +
 srcpkgs/{spek-alternative => spek-x}/template | 22 ++++++++++++-------
 2 files changed, 15 insertions(+), 8 deletions(-)
 create mode 120000 srcpkgs/spek-alternative
 rename srcpkgs/{spek-alternative => spek-x}/template (52%)

diff --git a/srcpkgs/spek-alternative b/srcpkgs/spek-alternative
new file mode 120000
index 0000000000000..76648236da701
--- /dev/null
+++ b/srcpkgs/spek-alternative
@@ -0,0 +1 @@
+spek-x
\ No newline at end of file
diff --git a/srcpkgs/spek-alternative/template b/srcpkgs/spek-x/template
similarity index 52%
rename from srcpkgs/spek-alternative/template
rename to srcpkgs/spek-x/template
index d7b55c776b1d4..3ded6c2c323e4 100644
--- a/srcpkgs/spek-alternative/template
+++ b/srcpkgs/spek-x/template
@@ -1,18 +1,18 @@
-# Template file for 'spek-alternative'
-pkgname=spek-alternative
-version=0.8.2.3
-revision=2
+# Template file for 'spek-x'
+pkgname=spek-x
+version=0.9.3
+revision=1
 build_style=gnu-configure
 hostmakedepends="automake gettext-devel intltool libtool pkg-config
  wxWidgets-common wxWidgets-gtk3-devel"
 makedepends="ffmpeg-devel wxWidgets-gtk3-devel"
 depends="ffmpeg"
 short_desc="Acoustic spectrum analyser"
-maintainer="Kartik Singh <kartik.ynwa@gmail.com>"
+maintainer="zlice <zlice555@gmail.com>"
 license="GPL-3.0-or-later"
-homepage="https://github.com/withmorten/spek-alternative"
-distfiles="https://github.com/withmorten/spek-alternative/archive/${version}.tar.gz"
-checksum="007ba4b84a310b078e378aa84c8e80783db5821437a757a488c3ecec377e6b2a"
+homepage="https://github.com/MikeWang000000/spek-x"
+distfiles="https://github.com/MikeWang000000/spek-x/archive/v${version}.tar.gz"
+checksum="7f4b109903333cdd310ab2b9176f0dc49a565891376e281a233d342cedf90ef7"
 
 CXXFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
 
@@ -22,3 +22,9 @@ export WX_CONFIG_NAME="wx-config-gtk3"
 pre_configure() {
 	NOCONFIGURE=1 ./autogen.sh
 }
+
+spek-alternative_package() {
+	depends="spek-x"
+	short_desc+=" - transitional dummy package"
+	build_style=meta
+}

From bfdcf48e03114f9a4992f6c239dc65d9164fe10e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 066/113] ssr: revbump for ffmpeg4

---
 srcpkgs/ssr/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ssr/template b/srcpkgs/ssr/template
index 3097754e3cbe5..fa66d5b4736d4 100644
--- a/srcpkgs/ssr/template
+++ b/srcpkgs/ssr/template
@@ -5,7 +5,7 @@ revision=2
 build_style=cmake
 configure_args="-DWITH_QT5=ON"
 hostmakedepends="pkg-config"
-makedepends="alsa-lib-devel ffmpeg-devel glu-devel jack-devel pulseaudio-devel
+makedepends="alsa-lib-devel ffmpeg4-devel glu-devel jack-devel pulseaudio-devel
  qt5-tools-devel qt5-x11extras-devel libXinerama-devel v4l-utils-devel"
 depends="desktop-file-utils hicolor-icon-theme"
 short_desc="Simple Screen Recorder for programs and games"

From 06819d30ae599278ac57455da7aa1b3e805824ce Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 067/113] synfig: revbump for ffmpeg6 and mlt7

---
 srcpkgs/synfig/patches/ffmpeg6.patch | 71 ++++++++++++++++++++++++++++
 srcpkgs/synfig/template              |  4 +-
 2 files changed, 73 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/synfig/patches/ffmpeg6.patch

diff --git a/srcpkgs/synfig/patches/ffmpeg6.patch b/srcpkgs/synfig/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..10780b42782f4
--- /dev/null
+++ b/srcpkgs/synfig/patches/ffmpeg6.patch
@@ -0,0 +1,71 @@
+--- a/src/modules/mod_libavcodec/trgt_av.cpp	2022-10-25 09:14:12.000000000 -0400
++++ b/src/modules/mod_libavcodec/trgt_av.cpp	2023-05-05 21:34:17.899194559 -0400
+@@ -38,6 +41,7 @@
+ extern "C"
+ {
+ #ifdef HAVE_LIBAVFORMAT_AVFORMAT_H
++#	include <libavcodec/avcodec.h>
+ #	include <libavformat/avformat.h>
+ #elif defined(HAVE_AVFORMAT_H)
+ #	include <avformat.h>
+@@ -155,11 +156,11 @@
+     }
+ 
+ 	bool open_video_stream() {
+-		if (avcodec_open2(video_context, NULL, NULL) < 0) {
++		if (avcodec_open2(video_context, nullptr, nullptr) < 0) {
+ 			synfig::error("Target_LibAVCodec: could not open video codec");
+ 			// seems the calling of avcodec_free_context after error will cause crash
+ 			// so just forget about this context
+-			video_context = NULL;
++			video_context = nullptr;
+ 			close();
+ 			return false;
+         }
+@@ -234,15 +235,21 @@
+ 		close();
+ 
+ 		if (!av_registered) {
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 			av_register_all();
++#endif
+ 			av_registered = true;
+ 		}
+ 
+ 		// guess format
+-		AVOutputFormat *format = av_guess_format(NULL, filename.c_str(), NULL);
++#if LIBAVCODEC_VERSION_MAJOR < 59 // FFMPEG < 5.0
++		AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#else
++		const AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#endif
+ 		if (!format) {
+ 			synfig::warning("Target_LibAVCodec: unable to guess the output format, defaulting to MPEG");
+-			format = av_guess_format("mpeg", NULL, NULL);
++			format = av_guess_format("mpeg", nullptr, nullptr);
+ 		}
+ 		if (!format) {
+ 			synfig::error("Target_LibAVCodec: unable to find 'mpeg' output format");
+@@ -254,6 +261,7 @@
+ 		context = avformat_alloc_context();
+ 		assert(context);
+ 		context->oformat = format;
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 		if (filename.size() + 1 > sizeof(context->filename)) {
+ 			synfig::error(
+ 				"Target_LibAVCodec: filename too long, max length is %d, filename is '%s'",
+@@ -263,6 +271,14 @@
+ 			return false;
+ 		}
+ 		memcpy(context->filename, filename.c_str(), filename.size() + 1);
++#else
++		context->url = av_strndup(filename.c_str(), filename.size());
++		if (!context->url) {
++			synfig::error("Target_LibAVCodec: cannot allocate space for filename");
++			close();
++			return false;
++		}
++#endif
+ 
+ 		packet = av_packet_alloc();
+ 		assert(packet);
diff --git a/srcpkgs/synfig/template b/srcpkgs/synfig/template
index d4d3e341a20bf..703cfd7ebac84 100644
--- a/srcpkgs/synfig/template
+++ b/srcpkgs/synfig/template
@@ -6,7 +6,7 @@ revision=4
 build_style=gnu-configure
 configure_args="--with-boost-libdir=${XBPS_CROSS_BASE}/usr/lib"
 hostmakedepends="boost-build ImageMagick pkg-config intltool"
-makedepends="ETL gettext-devel libxml++-devel mlt-devel libmagick-devel
+makedepends="ETL gettext-devel libxml++-devel mlt7-devel libmagick-devel
  libmng-devel boost-build boost-devel libopenexr-devel ffmpeg-devel"
 depends="ImageMagick"
 short_desc="CLI 2D vector and timeline-based animation software"
@@ -20,7 +20,7 @@ CXXFLAGS="-std=c++11 -DHAVE_LOCALE_H=1"
 
 synfig-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision}
-	 libopenexr-devel libxml++-devel mlt-devel"
+	 libopenexr-devel libxml++-devel mlt7-devel"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/bin/synfig-config

From 9c928749ccba0332bd95095d35952c32b671eebd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 068/113] timg: revbump for ffmpeg6

---
 srcpkgs/timg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/timg/template b/srcpkgs/timg/template
index 2a2ab763d2fdd..8fb4327535ef9 100644
--- a/srcpkgs/timg/template
+++ b/srcpkgs/timg/template
@@ -1,7 +1,7 @@
 # Template file for 'timg'
 pkgname=timg
 version=1.4.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_OPENSLIDE_SUPPORT=off -Wno-dev"
 hostmakedepends="pkg-config git"

From b2ba65659853a1553cc64ed6451a5bb3a3f82dd6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 069/113] tvheadend: revbump for ffmpeg4

---
 srcpkgs/tvheadend/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tvheadend/template b/srcpkgs/tvheadend/template
index 9aea7de4ec705..012d31c4879ff 100644
--- a/srcpkgs/tvheadend/template
+++ b/srcpkgs/tvheadend/template
@@ -8,7 +8,7 @@ configure_args="--enable-dvbscan --disable-ffmpeg_static
 --disable-libx265_static --disable-libvpx_static --disable-libtheora_static
 --disable-libvorbis_static --disable-libfdkaac_static"
 hostmakedepends="gettext pkg-config python3 git which"
-makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg-devel"
+makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg4-devel"
 short_desc="TV streaming server"
 maintainer="lemmi <lemmi@nerd2nerd.org>"
 license="GPL-3.0-only"

From 95d21f88852260f407aea616762ba1cc684ea19b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 070/113] unpaper: update to 7.0.0.

---
 srcpkgs/unpaper/template | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/srcpkgs/unpaper/template b/srcpkgs/unpaper/template
index 38ed47a584016..1ff910e722afc 100644
--- a/srcpkgs/unpaper/template
+++ b/srcpkgs/unpaper/template
@@ -1,13 +1,13 @@
 # Template file for 'unpaper'
 pkgname=unpaper
-version=6.1
-revision=3
-build_style=gnu-configure
+version=7.0.0
+revision=1
+build_style=meson
+hostmakedepends="pkg-config meson libxslt"
+makedepends="ffmpeg-devel python3-Sphinx"
+short_desc="Post-processing tool for scanned sheets of paper"
 maintainer="Orphaned <orphan@voidlinux.org>"
-hostmakedepends="pkg-config libxslt"
-makedepends="ffmpeg-devel"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://www.flameeyes.eu/projects/unpaper"
-short_desc="A post-processing tool for scanned sheets of paper"
 distfiles="https://www.flameeyes.eu/files/${pkgname}-${version}.tar.xz"
-checksum=237c84f5da544b3f7709827f9f12c37c346cdf029b1128fb4633f9bafa5cb930
+checksum=2575fbbf26c22719d1cb882b59602c9900c7f747118ac130883f63419be46a80

From 6bf5b37608e0f21680abb02c272a30f3306580ab Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 071/113] vice: revbump for ffmpeg4

---
 srcpkgs/vice/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vice/template b/srcpkgs/vice/template
index b1f866d35095e..4beab2c5f9ebd 100644
--- a/srcpkgs/vice/template
+++ b/srcpkgs/vice/template
@@ -26,7 +26,7 @@ makedepends="
 	$(vopt_if gtk3 gtk+3-devel)
 	$(vopt_if gtk3 pulseaudio-devel)
 	$(vopt_if gtk3 pango-devel)
-	$(vopt_if ffmpeg ffmpeg-devel)"
+	$(vopt_if ffmpeg ffmpeg4-devel)"
 short_desc="Emulator for C64, C128, CBM-II, PET, VIC20, Plus4 and C16"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"

From 6ac3e1f6b275ee804694cf6fd493a9d1bf81ea22 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 072/113] waypipe: revbump for ffmpeg6

---
 srcpkgs/waypipe/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waypipe/template b/srcpkgs/waypipe/template
index 6da88b21bf2a1..4da8058400b58 100644
--- a/srcpkgs/waypipe/template
+++ b/srcpkgs/waypipe/template
@@ -1,7 +1,7 @@
 # Template file for 'waypipe'
 pkgname=waypipe
 version=0.8.6
-revision=1
+revision=2
 build_style=meson
 # lto is off because it causes linking errors in armv6l and armv7l (due to NEON)
 configure_args="-Dwerror=false -Dwith_dmabuf=enabled -Dwith_lz4=enabled

From d88028d191741dd931537b0e045868fd9411cf3b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 073/113] xpra: revbump for ffmpeg6

---
 srcpkgs/xpra/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xpra/template b/srcpkgs/xpra/template
index 6bfe9be2db650..1eea2962bcb82 100644
--- a/srcpkgs/xpra/template
+++ b/srcpkgs/xpra/template
@@ -1,7 +1,7 @@
 # Template file for 'xpra'
 pkgname=xpra
 version=5.0.4
-revision=1
+revision=2
 build_style=python3-module
 make_build_args="--without-cuda_kernels --without-cuda_rebuild"
 make_install_args="$(vopt_with docs) ${make_build_args}"

From 922f70ea66e344b889337feee50b3934aab7cde4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:07:40 -0400
Subject: [PATCH 074/113] nv-codec-headers: update to 12.0.16.0

---
 srcpkgs/nv-codec-headers/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/nv-codec-headers/template b/srcpkgs/nv-codec-headers/template
index 3d422a61e4891..251e057f826fb 100644
--- a/srcpkgs/nv-codec-headers/template
+++ b/srcpkgs/nv-codec-headers/template
@@ -1,6 +1,6 @@
 # Template file for 'nv-codec-headers'
 pkgname=nv-codec-headers
-version=11.1.5.1
+version=12.0.16.0
 revision=1
 build_style=gnu-makefile
 short_desc="FFmpeg version of headers required to interface with Nvidias codec APIs"
@@ -8,7 +8,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="MIT"
 homepage="http://git.videolan.org/?p=ffmpeg/nv-codec-headers.git"
 distfiles="https://github.com/FFmpeg/nv-codec-headers/archive/n${version}.tar.gz"
-checksum=d095fbd56aa93772471a323be0ebe65504a0f43f06c76a30b6d25da77b06ae9c
+checksum=2a1533b65f55f9da52956faf0627ed3b74868ac0c7f269990edd21369113b48f
 
 post_install() {
 	sed -n '4,25p' include/ffnvcodec/nvEncodeAPI.h > LICENSE

From 68055e2d1e2d3f63d5400845f312c76566049710 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:08:40 -0400
Subject: [PATCH 075/113] openimagedenoise: revbump for ffmpeg6

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index b792813dba7c2..109deb171c3f7 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,7 +1,7 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
 version=1.4.3
-revision=1
+revision=2
 archs="x86_64*"
 build_style=cmake
 hostmakedepends="ispc python3"

From 0bc1db32ff6df6dc4cd6127e87cdaa28d15c511b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:31:45 -0400
Subject: [PATCH 076/113] shotcut: revbump for ffmpeg6

---
 srcpkgs/shotcut/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/shotcut/template b/srcpkgs/shotcut/template
index 33141fbd862d7..f46cb53b6bfb9 100644
--- a/srcpkgs/shotcut/template
+++ b/srcpkgs/shotcut/template
@@ -1,7 +1,7 @@
 # Template file for 'shotcut'
 pkgname=shotcut
 version=23.09.29
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSHOTCUT_VERSION=${version}"
 hostmakedepends="pkg-config qt6-tools-devel"

From 40ead4a85c1b95e6fcbec6a89b5fc1a997e559af Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:30 -0400
Subject: [PATCH 077/113] shiboken2: revbump for qt5-5.15.11

---
 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch | 1 +
 srcpkgs/shiboken2/template                                 | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
 create mode 120000 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
new file mode 120000
index 0000000000000..efcf3249bd885
--- /dev/null
+++ b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1 @@
+../../python3-pyside2/patches/importlib-machinery-bypass.patch
\ No newline at end of file
diff --git a/srcpkgs/shiboken2/template b/srcpkgs/shiboken2/template
index 883d6a084d868..f3c06ec245a1f 100644
--- a/srcpkgs/shiboken2/template
+++ b/srcpkgs/shiboken2/template
@@ -1,7 +1,7 @@
 # Template file for 'shiboken2'
 pkgname=shiboken2
 version=5.15.10
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/shiboken2"
 build_style=cmake

From 4b04bdb3bcd409bcd7fc5655fe8e53f44024b31c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:53 -0400
Subject: [PATCH 078/113] python3-pyside2: revbump for qt5-5.15.11

---
 .../patches/importlib-machinery-bypass.patch      | 15 +++++++++++++++
 srcpkgs/python3-pyside2/template                  |  2 +-
 2 files changed, 16 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
new file mode 100644
index 0000000000000..64c429584776b
--- /dev/null
+++ b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1,15 @@
+Using this prevents an error around line 220 below it.
+"AttributeError: module 'importlib' has no attribute 'machinery'"
+The old backup logic is in place and compiles without issues.
+--- a/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:09:34.688912402 -0400
++++ b/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:10:03.395529582 -0400
+@@ -170,9 +170,6 @@
+
+     # 'zipstring_sequence' comes from signature.cpp
+     zipbytes = base64.b64decode(''.join(zipstring_sequence))
+-    if sys.version_info[0] >= 3:
+-        vzip = zipfile.ZipFile(io.BytesIO(zipbytes))
+-        return sys.meta_path, EmbeddableZipImporter(vzip)
+
+     # Old version for Python 2.7, only.
+     import os
diff --git a/srcpkgs/python3-pyside2/template b/srcpkgs/python3-pyside2/template
index 249efa9098842..52626436ce75f 100644
--- a/srcpkgs/python3-pyside2/template
+++ b/srcpkgs/python3-pyside2/template
@@ -1,7 +1,7 @@
 # Template file for 'python3-pyside2'
 pkgname=python3-pyside2
 version=5.15.10
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/pyside2"
 build_style=cmake

From 3f2bfaac0eaf73f47461b034d5c8e745d86f6c59 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:35 -0400
Subject: [PATCH 079/113] konqueror: revbump for ffmpeg6

---
 srcpkgs/konqueror/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/konqueror/template b/srcpkgs/konqueror/template
index 044dafa605ba6..63dd01fafc780 100644
--- a/srcpkgs/konqueror/template
+++ b/srcpkgs/konqueror/template
@@ -1,11 +1,11 @@
 # Template file for 'konqueror'
 pkgname=konqueror
 version=23.08.4
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DDESKTOPTOJSON_EXECUTABLE=/usr/bin/desktoptojson"
 hostmakedepends="extra-cmake-modules python3 qt5-host-tools qt5-qmake kdoctools
-kcoreaddons kconfig gettext"
+ kcoreaddons kconfig gettext"
 makedepends="qt5-devel qt5-webengine-devel qt5-declarative-devel
  qt5-webchannel-devel qt5-location-devel kcmutils-devel kdelibs4support-devel
  karchive-devel khtml-devel kdesu-devel kactivities5-devel"

From e0971ecb8547069ffdf973bc3e670856cef0ba25 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:58 -0400
Subject: [PATCH 080/113] qt5-speech: revbump for qt5-5.15.11

---
 srcpkgs/qt5-speech/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-speech/template b/srcpkgs/qt5-speech/template
index 3ecd10d50650c..2d7d4d4d24535 100644
--- a/srcpkgs/qt5-speech/template
+++ b/srcpkgs/qt5-speech/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-speech'
 pkgname=qt5-speech
 version=5.15.7
-revision=2
+revision=3
 _commit=d32f4a479d38a11f547598004b975f4356424a16
 build_style=qmake
 configure_args="-- -flite -flite-alsa -speechd"

From 5c934fa10a970ac6d2f71135a8a2fb2fe794782b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Jun 2023 08:20:22 -0400
Subject: [PATCH 081/113] gtk4: revbump for ffmpeg6

---
 srcpkgs/gtk4/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gtk4/template b/srcpkgs/gtk4/template
index 6a4e20357a86f..ec0c13d2cc5b0 100644
--- a/srcpkgs/gtk4/template
+++ b/srcpkgs/gtk4/template
@@ -1,7 +1,7 @@
 # Template file for 'gtk4'
 pkgname=gtk4
 version=4.12.3
-revision=1
+revision=2
 build_style=meson
 build_helper="gir"
 configure_args="-Dman-pages=true -Ddocumentation=true -Dbuild-tests=false

From dd7f8505c5ab592bfb1cae563808bdf48412d953 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:28:26 -0400
Subject: [PATCH 082/113] siril: revbump for ffmpeg6

---
 srcpkgs/siril/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/siril/template b/srcpkgs/siril/template
index 84332f79d060d..62750dd247548 100644
--- a/srcpkgs/siril/template
+++ b/srcpkgs/siril/template
@@ -1,7 +1,7 @@
 # Template file for 'siril'
 pkgname=siril
 version=0.9.12
-revision=10
+revision=11
 build_style=gnu-configure
 hostmakedepends="pkg-config intltool autoconf automake gettext-devel"
 makedepends="fftw-devel libconfig-devel libopencv-devel libffms2-devel

From 82d6d5a89746be7096ac81ebdbd7c335f871e66f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 22 Jun 2023 10:25:02 -0400
Subject: [PATCH 083/113] kdenlive: revbump for ffmpeg6

---
 srcpkgs/kdenlive/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kdenlive/template b/srcpkgs/kdenlive/template
index a0f3615c9c530..d63166f95c4d7 100644
--- a/srcpkgs/kdenlive/template
+++ b/srcpkgs/kdenlive/template
@@ -1,7 +1,7 @@
 # Template file for 'kdenlive'
 pkgname=kdenlive
 version=23.08.4
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="
  extra-cmake-modules kconfig kcoreaddons kdoctools pkg-config python3

From 35b4383f7bb0a103ee6dea33bb858f2a42899968 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:20:59 -0400
Subject: [PATCH 084/113] tracker-miners: revbump for ffmpeg6

---
 srcpkgs/tracker-miners/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tracker-miners/template b/srcpkgs/tracker-miners/template
index 0b97f47489f81..f196d2bf9e4a4 100644
--- a/srcpkgs/tracker-miners/template
+++ b/srcpkgs/tracker-miners/template
@@ -1,7 +1,7 @@
 # Template file for 'tracker-miners'
 pkgname=tracker-miners
 version=3.6.1
-revision=1
+revision=2
 build_style=meson
 build_helper=qemu
 # missing libgrss for miner_rss

From cf42948f844b35c69800a59b0b96cd9e16dd9da3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:21:21 -0400
Subject: [PATCH 085/113] mpd: revbump for ffmpeg6

---
 srcpkgs/mpd/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpd/template b/srcpkgs/mpd/template
index 4fd32b7be8c53..b8e2bd4c1b59c 100644
--- a/srcpkgs/mpd/template
+++ b/srcpkgs/mpd/template
@@ -1,7 +1,7 @@
 # Template file for 'mpd'
 pkgname=mpd
 version=0.23.15
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dopus=enabled -Dmikmod=enabled -Dneighbor=true
  -Dsoundcloud=enabled -Dpipe=true -Dtwolame=enabled -Dbzip2=enabled

From 6e9c6edcde730153e074ffab3edbe82b7bb4f01a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:02 -0400
Subject: [PATCH 086/113] tg_owt: revbump for ffmpeg6

---
 srcpkgs/tg_owt/template | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/srcpkgs/tg_owt/template b/srcpkgs/tg_owt/template
index aee8d35d08ffb..563ed9a5835c4 100644
--- a/srcpkgs/tg_owt/template
+++ b/srcpkgs/tg_owt/template
@@ -1,8 +1,7 @@
 # Template file for 'tg_owt'
 pkgname=tg_owt
 version=0.0.0.20231221
-revision=1
-_commit=afd9d5d31798d3eacf9ed6c30601e91d0f1e4d60
+revision=2
 _libyuv_commit=04821d1e7d60845525e8db55c7bcd41ef5be9406
 _abseil_commit=8c0b94e793a66495e0b1f34a5eb26bd7dc672db0
 _crc32c_commit=21fc8ef30415a635e7351ffa0e5d5367943d4a94

From 2e39cf660abb21cfdd625bd4303544231611715f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:44 -0400
Subject: [PATCH 087/113] telegram-desktop: revbump for ffmpeg6

---
 srcpkgs/telegram-desktop/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/telegram-desktop/template b/srcpkgs/telegram-desktop/template
index 48ccb9a9d840a..c8756611e2b3b 100644
--- a/srcpkgs/telegram-desktop/template
+++ b/srcpkgs/telegram-desktop/template
@@ -1,7 +1,7 @@
 # Template file for 'telegram-desktop'
 pkgname=telegram-desktop
 version=4.14.2
-revision=1
+revision=2
 build_style=cmake
 build_helper="qemu gir"
 configure_args="-DTDESKTOP_API_ID=209235

From 20f1c7101e3e213b964b4178fa14f6a982f1c161 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:11:45 -0400
Subject: [PATCH 088/113] gst-plugins-bad1: revbump for ffmpeg6

---
 srcpkgs/gst-plugins-bad1/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index fcd3538cd5cde..976e2889b588e 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-plugins-bad1'
 pkgname=gst-plugins-bad1
 version=1.22.7
-revision=1
+revision=2
 build_helper="gir"
 build_style=meson
 configure_args="-Dpackage-origin=https://voidlinux.org -Ddoc=disabled

From 6e11f90f8786bcb66aaad753f60e2251dda5fd29 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:12:09 -0400
Subject: [PATCH 089/113] openmw: revbump for ffmpeg6

---
 srcpkgs/openmw/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openmw/template b/srcpkgs/openmw/template
index 0abf5ff7cdbec..b57180f1a4446 100644
--- a/srcpkgs/openmw/template
+++ b/srcpkgs/openmw/template
@@ -1,7 +1,7 @@
 # Template file for 'openmw'
 pkgname=openmw
 version=0.48.0
-revision=2
+revision=3
 build_style=cmake
 _recast_commit=e75adf86f91eb3082220085e42dda62679f9a3ea
 _bullet_tag=3.17

From f80b5c1ecb2480c0ed97d5e3457713ae3bc59a2a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:14:53 -0400
Subject: [PATCH 090/113] lms: revbump for ffmpeg6

---
 srcpkgs/lms/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/lms/template b/srcpkgs/lms/template
index e358f75902a98..3b21c458de519 100644
--- a/srcpkgs/lms/template
+++ b/srcpkgs/lms/template
@@ -1,7 +1,7 @@
 # Template file for 'lms'
 pkgname=lms
 version=3.42.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="wt-devel ffmpeg-devel boost-devel libconfig++-devel taglib-devel pam-devel libgraphicsmagick-devel gtest-devel libarchive-devel"

From 2057443e05ecd365ed8dfb27afde9ab3adaf698a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:18:18 -0400
Subject: [PATCH 091/113] freecad: DELETE

---
 srcpkgs/freecad/patches/001-include.patch     | 112 ------------------
 .../154-revert-gui-tmp-redirect-stderr.patch  |  68 -----------
 ...d63c8c9b1280978be841d04e68a0a55cceb9.patch |  30 -----
 srcpkgs/freecad/template                      |  12 +-
 4 files changed, 7 insertions(+), 215 deletions(-)
 delete mode 100644 srcpkgs/freecad/patches/001-include.patch
 delete mode 100644 srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
 delete mode 100644 srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch

diff --git a/srcpkgs/freecad/patches/001-include.patch b/srcpkgs/freecad/patches/001-include.patch
deleted file mode 100644
index 28b5af54999b9..0000000000000
--- a/srcpkgs/freecad/patches/001-include.patch
+++ /dev/null
@@ -1,112 +0,0 @@
-From 9a41845a417189776741297c50a3827ce292bc4f Mon Sep 17 00:00:00 2001
-From: Uwe <donovaly@users.noreply.github.com>
-Date: Sun, 3 Jul 2022 22:51:16 +0200
-Subject: [PATCH] [Part] OCCError.h: remove unneeded includes
-
-- also sort includes
----
- src/Mod/Part/App/OCCError.h             | 36 +++----------------------
- src/Mod/Part/App/OffsetCurvePyImp.cpp   | 12 ++++-----
- src/Mod/Part/App/OffsetSurfacePyImp.cpp | 10 +++----
- 3 files changed, 12 insertions(+), 46 deletions(-)
-
---- a/src/Mod/Part/App/OCCError.h
-+++ b/src/Mod/Part/App/OCCError.h
-@@ -23,36 +23,8 @@
- #ifndef _OCCError_h_
- #define _OCCError_h_
- 
--# include <Standard_Version.hxx>
- # include <Standard_Failure.hxx>
--# include <Standard_AbortiveTransaction.hxx>
--# include <Standard_ConstructionError.hxx>
--# if OCC_VERSION_HEX >= 0x060500
--# include <Standard_DefineException.hxx>
--# endif
--# include <Standard_DimensionError.hxx>
--# include <Standard_DimensionMismatch.hxx>
--# include <Standard_DivideByZero.hxx>
--# include <Standard_DomainError.hxx>
--# include <Standard_ImmutableObject.hxx>
--# include <Standard_LicenseError.hxx>
--# include <Standard_LicenseNotFound.hxx>
--# include <Standard_MultiplyDefined.hxx>
--# include <Standard_NegativeValue.hxx>
--# include <Standard_NoMoreObject.hxx>
--# include <Standard_NoSuchObject.hxx>
--# include <Standard_NotImplemented.hxx>
--# include <Standard_NullObject.hxx>
--# include <Standard_NullValue.hxx>
--# include <Standard_NumericError.hxx>
--# include <Standard_OutOfMemory.hxx>
--# include <Standard_OutOfRange.hxx>
--# include <Standard_Overflow.hxx>
--# include <Standard_ProgramError.hxx>
--# include <Standard_RangeError.hxx>
--# include <Standard_TooManyUsers.hxx>
--# include <Standard_TypeMismatch.hxx>
--# include <Standard_Underflow.hxx>
-+# include <Standard_Version.hxx>
- 
- #include <Mod/Part/PartGlobal.h>
- #include <Base/Console.h>
-@@ -88,4 +60,3 @@ PartExport extern PyObject* PartExceptio
- 
- #define PY_CATCH_OCC _PY_CATCH_OCC(return(NULL))
- #endif  // _OCCError_h_
--
---- a/src/Mod/Part/App/OffsetCurvePyImp.cpp
-+++ b/src/Mod/Part/App/OffsetCurvePyImp.cpp
-@@ -20,20 +20,20 @@
-  *                                                                         *
-  ***************************************************************************/
- 
--
- #include "PreCompiled.h"
- #ifndef _PreComp_
- # include <Geom_OffsetCurve.hxx>
- #endif
- 
--#include "OCCError.h"
--#include "Geometry.h"
-+#include <Base/GeometryPyCXX.h>
-+#include <Base/Vector3D.h>
-+#include <Base/VectorPy.h>
-+
- #include "OffsetCurvePy.h"
- #include "OffsetCurvePy.cpp"
-+#include "Geometry.h"
-+#include "OCCError.h"
- 
--#include <Base/GeometryPyCXX.h>
--#include <Base/VectorPy.h>
--#include <Base/Vector3D.h>
- 
- using namespace Part;
- 
---- a/src/Mod/Part/App/OffsetSurfacePyImp.cpp
-+++ b/src/Mod/Part/App/OffsetSurfacePyImp.cpp
-@@ -20,20 +20,16 @@
-  *                                                                         *
-  ***************************************************************************/
- 
--
- #include "PreCompiled.h"
- #ifndef _PreComp_
- # include <Geom_OffsetSurface.hxx>
- # include <memory>
- #endif
- 
--#include <Base/VectorPy.h>
--#include <Base/Vector3D.h>
--
- #include "OCCError.h"
--#include "Geometry.h"
--#include <Mod/Part/App/OffsetSurfacePy.h>
--#include <Mod/Part/App/OffsetSurfacePy.cpp>
-+#include "OffsetSurfacePy.h"
-+#include "OffsetSurfacePy.cpp"
-+
- 
- using namespace Part;
- 
diff --git a/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch b/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
deleted file mode 100644
index d6a9adabdec83..0000000000000
--- a/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
+++ /dev/null
@@ -1,68 +0,0 @@
-see https://github.com/FreeCAD/FreeCAD/commit/cfe94b00d3434f3e2c8b5114d2909f628c330fa8#commitcomment-71413407
-
-upstream: yes
-
-From 7b377a216b9185960e4cee980a6504dc1a755f50 Mon Sep 17 00:00:00 2001
-From: wmayer <wmayer@users.sourceforge.net>
-Date: Wed, 29 Jun 2022 15:19:18 +0200
-Subject: [PATCH] Gui: remove workaround for spnav 0.23 due to build failure
- with musl libc
-
----
- src/Gui/3Dconnexion/GuiNativeEventLinux.cpp | 27 ---------------------
- 1 file changed, 27 deletions(-)
-
---- a/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp
-+++ b/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp
-@@ -21,42 +21,17 @@
-  ***************************************************************************/
- 
- #include <FCConfig.h>
--#include <cstdio>
- 
- #include "GuiNativeEventLinux.h"
- 
- #include "GuiApplicationNativeEventAware.h"
- #include <Base/Console.h>
--#include <Base/FileInfo.h>
- #include <QMainWindow>
- 
- #include <QSocketNotifier>
- 
- #include <spnav.h>
- 
--namespace {
--class RedirectStdErr
--{
--public:
--    RedirectStdErr()
--        : fi(Base::FileInfo::getTempFileName())
--        , file(stderr)
--    {
--        stderr = fopen(fi.filePath().c_str(), "w");
--    }
--    ~RedirectStdErr()
--    {
--        fclose(stderr);
--        fi.deleteFile();
--        stderr = file;
--    }
--
--private:
--    Base::FileInfo fi;
--    FILE* file;
--};
--}
--
- Gui::GuiNativeEvent::GuiNativeEvent(Gui::GUIApplicationNativeEventAware *app)
- : GuiAbstractNativeEvent(app)
- {
-@@ -72,8 +47,6 @@ Gui::GuiNativeEvent::~GuiNativeEvent()
- 
- void Gui::GuiNativeEvent::initSpaceball(QMainWindow *window)
- {
--    // tmp. redirect stderr to a file to suppress an error message from spnav_open()
--    RedirectStdErr err;
-     Q_UNUSED(window)
-     if (spnav_open() == -1) {
-         Base::Console().Log("Couldn't connect to spacenav daemon. Please ignore if you don't have a spacemouse.\n");
diff --git a/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch b/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch
deleted file mode 100644
index d4acf370ca0a4..0000000000000
--- a/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-From fe02d63c8c9b1280978be841d04e68a0a55cceb9 Mon Sep 17 00:00:00 2001
-From: Roy-043 <70520633+Roy-043@users.noreply.github.com>
-Date: Thu, 29 Dec 2022 23:20:38 +0100
-Subject: [PATCH] Draft: update inspect.getargspec to inspect.getfullargspec
- (#8101)
-
----
- src/Mod/Draft/draftguitools/gui_snapper.py | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
---- a/src/Mod/Draft/draftguitools/gui_snapper.py
-+++ b/src/Mod/Draft/draftguitools/gui_snapper.py
-@@ -1426,7 +1426,7 @@ class Snapper:
-             Gui.Snapper.off()
-             self.ui.offUi()
-             if callback:
--                if len(inspect.getargspec(callback).args) > 1:
-+                if len(inspect.getfullargspec(callback).args) > 1:
-                     obj = None
-                     if self.snapInfo and ("Object" in self.snapInfo) and self.snapInfo["Object"]:
-                         obj = App.ActiveDocument.getObject(self.snapInfo["Object"])
-@@ -1445,7 +1445,7 @@ class Snapper:
-             Gui.Snapper.off()
-             self.ui.offUi()
-             if callback:
--                if len(inspect.getargspec(callback).args) > 1:
-+                if len(inspect.getfullargspec(callback).args) > 1:
-                     callback(None, None)
-                 else:
-                     callback(None)
diff --git a/srcpkgs/freecad/template b/srcpkgs/freecad/template
index c135701e38b9a..7d5165f760bab 100644
--- a/srcpkgs/freecad/template
+++ b/srcpkgs/freecad/template
@@ -1,7 +1,7 @@
 # Template file for 'freecad'
 pkgname=freecad
-version=0.20.2
-revision=7
+version=0.21.1
+revision=2
 build_wrksrc="FreeCAD-${version}"
 build_style=cmake
 pycompile_dirs="usr/lib/${pkgname}/Mod"
@@ -24,8 +24,10 @@ makedepends="python3-devel boost-devel libxerces-c-devel zlib-devel occt-devel
  coin3-devel libshiboken2-devel libspnav-devel pyside2-tools
  liblz4-devel libpyside2-python3-devel python3-matplotlib netcdf-devel
  jsoncpp-devel qt5-devel qt5-svg-devel qt5-tools-devel qt5-webkit-devel
- qt5-xmlpatterns-devel coin3-doc glew-devel python3-pivy"
-depends="python3-matplotlib python3-pyside2-webengine python3-pivy"
+ qt5-xmlpatterns-devel coin3-doc glew-devel python3-pivy qt5-webengine-devel
+ qt5-declarative-devel qt5-webchannel-devel qt5-location-devel"
+depends="python3-matplotlib python3-pyside2-webengine python3-pivy
+ python3-GitPython python3-Markdown"
 short_desc="General purpose 3D CAD modeler"
 maintainer="yopito <pierre.bourgin@free.fr>"
 license="LGPL-2.0-or-later"
@@ -35,7 +37,7 @@ distfiles="
  https://github.com/FreeCAD/FreeCAD/archive/${version}.tar.gz
  ${SOURCEFORGE_SITE}/cxx/pycxx-${_pycxxver}.tar.gz
 "
-checksum="46922f3a477e742e1a89cd5346692d63aebb2b67af887b3e463e094a4ae055da
+checksum="e9b1fd0323f101268c7f3be52db42e4a29222f2e306ae6c4a6fc309cb418d35a
  4b91e1e1141c23fbd5039df635c4bb6e75632168548f56b83ce177193c0c98c6"
 python_version=3
 patch_args="-Np1 -d ${build_wrksrc}"

From 979f507982f317ee90b70f61d36b7acf921997f0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:47:18 -0400
Subject: [PATCH 092/113] libopenshot: revbump for ffmpeg6

---
 srcpkgs/libopenshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenshot/template b/srcpkgs/libopenshot/template
index 8e57c5f592169..7a8f4520e7892 100644
--- a/srcpkgs/libopenshot/template
+++ b/srcpkgs/libopenshot/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenshot'
 pkgname=libopenshot
 version=0.3.0
-revision=3
+revision=4
 build_style=cmake
 # Builds fail with Ruby-2.4.1
 configure_args="-DENABLE_RUBY=OFF -DUSE_SYSTEM_JSONCPP=ON"

From 6659bfbd25cb764986b45c987dd48a6beaaf7511 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:10:30 -0500
Subject: [PATCH 093/113] openimageio: revbump for ffmpeg6

---
 srcpkgs/openimageio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimageio/template b/srcpkgs/openimageio/template
index 3ce3f9e49d350..27d2131bc0a61 100644
--- a/srcpkgs/openimageio/template
+++ b/srcpkgs/openimageio/template
@@ -1,7 +1,7 @@
 # Template file for 'openimageio'
 pkgname=openimageio
 version=2.4.9.0
-revision=7
+revision=8
 build_style=cmake
 build_helper=qemu
 configure_args="-DUSE_QT=0 -DUSE_PYTHON=0 -DOIIO_BUILD_TESTS=0

From 8a49fa040a096bc93da34830476b95761f34fcc5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:11:57 -0500
Subject: [PATCH 094/113] synfigstudio: revbump for ffmpeg6

---
 srcpkgs/synfigstudio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/synfigstudio/template b/srcpkgs/synfigstudio/template
index 09e442da9a680..2bc017cedca6b 100644
--- a/srcpkgs/synfigstudio/template
+++ b/srcpkgs/synfigstudio/template
@@ -2,7 +2,7 @@
 # Should be kept in sync with 'synfig' and 'ETL'
 pkgname=synfigstudio
 version=1.4.4
-revision=4
+revision=5
 build_style=gnu-configure
 configure_args="--disable-update-mimedb"
 hostmakedepends="pkg-config intltool gettext synfig"

From 59cb75f0b5a3c1e7c06642334eb9dee31c63c002 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:12:32 -0500
Subject: [PATCH 095/113] gmic: revbump for ffmpeg6

---
 srcpkgs/gmic/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gmic/template b/srcpkgs/gmic/template
index fa37651bb6dee..24d10147e3aba 100644
--- a/srcpkgs/gmic/template
+++ b/srcpkgs/gmic/template
@@ -1,7 +1,7 @@
 # Template file for 'gmic'
 pkgname=gmic
 version=3.1.6
-revision=5
+revision=6
 _zart_hash=34ebf6cce0bafb98abe57cec83c4a02cd1abeca0
 create_wrksrc=yes
 build_wrksrc="src"

From 456f6f595a5b33467fcface6d7d7b3676aa84e6e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:10 -0500
Subject: [PATCH 096/113] mixxx: revbump for ffmpeg6

---
 srcpkgs/mixxx/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mixxx/template b/srcpkgs/mixxx/template
index 6921996e4e77b..6a79b328c1abf 100644
--- a/srcpkgs/mixxx/template
+++ b/srcpkgs/mixxx/template
@@ -1,7 +1,7 @@
 # Template file for 'mixxx'
 pkgname=mixxx
 version=2.3.3
-revision=6
+revision=7
 build_style=cmake
 configure_args="-DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="extra-cmake-modules pkg-config protobuf qt5-host-tools qt5-qmake"

From 8b3165cb5479535d10cc46de4702c44243efdea3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:28 -0500
Subject: [PATCH 097/113] musikcube: revbump for ffmpeg6

---
 srcpkgs/musikcube/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/musikcube/template b/srcpkgs/musikcube/template
index d9e6186e6697b..637952d50aca3 100644
--- a/srcpkgs/musikcube/template
+++ b/srcpkgs/musikcube/template
@@ -1,7 +1,7 @@
 # Template file for 'musikcube'
 pkgname=musikcube
 version=3.0.0
-revision=3
+revision=4
 build_style=cmake
 make_cmd=make
 configure_args="-DNO_NCURSESW=1"

From 323f2a680cb1a893424ed241c26986ff98cc0f4d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:45 -0500
Subject: [PATCH 098/113] electron24: revbump for ffmpeg6

---
 srcpkgs/electron24/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron24/template b/srcpkgs/electron24/template
index a9c865c19c989..b8613e4362bc7 100644
--- a/srcpkgs/electron24/template
+++ b/srcpkgs/electron24/template
@@ -1,7 +1,7 @@
 # Template file for 'electron24'
 pkgname=electron24
 version=24.3.0
-revision=2
+revision=3
 _nodever=18.14.0
 _chromiumver=112.0.5615.165
 archs="x86_64* aarch64*"

From 36f55176904b48be73236a8c9198afa53c94518c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:00 -0500
Subject: [PATCH 099/113] electron19: revbump for ffmpeg6

---
 srcpkgs/electron19/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron19/template b/srcpkgs/electron19/template
index b18bc792c8221..29fb34e254eea 100644
--- a/srcpkgs/electron19/template
+++ b/srcpkgs/electron19/template
@@ -1,7 +1,7 @@
 # Template file for 'electron19'
 pkgname=electron19
 version=19.0.8
-revision=4
+revision=5
 _nodever=16.14.2
 _chromiumver=102.0.5005.125
 archs="x86_64* aarch64* ppc64le*"

From 947a8de98c40590ee4dbe62c065bcc66264aabc7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:13 -0500
Subject: [PATCH 100/113] wf-recorder: revbump for ffmpeg6

---
 srcpkgs/wf-recorder/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/wf-recorder/template b/srcpkgs/wf-recorder/template
index 08f986b031006..63c45cf4b814d 100644
--- a/srcpkgs/wf-recorder/template
+++ b/srcpkgs/wf-recorder/template
@@ -1,7 +1,7 @@
 # Template file for 'wf-recorder'
 pkgname=wf-recorder
 version=0.4.1
-revision=2
+revision=3
 build_style=meson
 hostmakedepends="pkg-config scdoc wayland-devel"
 makedepends="wayland-protocols wayland-devel ffmpeg-devel libgbm-devel x264-devel

From c9ef402801d67c5f8b7b342ac2d9688827d80b53 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:26 -0500
Subject: [PATCH 101/113] obs: revbump for ffmpeg6

---
 srcpkgs/obs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/obs/template b/srcpkgs/obs/template
index b343f1131bfcf..a25a67433e285 100644
--- a/srcpkgs/obs/template
+++ b/srcpkgs/obs/template
@@ -1,7 +1,7 @@
 # Template file for 'obs'
 pkgname=obs
 version=30.0.0
-revision=2
+revision=3
 archs="i686* x86_64* ppc64le* aarch64* riscv64*"
 build_style=cmake
 configure_args="-DOBS_VERSION_OVERRIDE=${version} -DENABLE_JACK=ON

From 23b980ea1e56d4342ac4aaa94d27d746f6af08f3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:36 -0500
Subject: [PATCH 102/113] mlt7: revbump for ffmpeg6

---
 srcpkgs/mlt7/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mlt7/template b/srcpkgs/mlt7/template
index 98f302ad3a516..7eb8c00fa1580 100644
--- a/srcpkgs/mlt7/template
+++ b/srcpkgs/mlt7/template
@@ -1,7 +1,7 @@
 # Template file for 'mlt7'
 pkgname=mlt7
 version=7.20.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DSWIG_PYTHON=ON -DMOD_QT6=ON"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which

From 5e208f3f96e2998d2de675adc6c8f3b72ede6b92 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:48 -0500
Subject: [PATCH 103/113] qt6-multimedia: revbump for ffmpeg6

---
 srcpkgs/qt6-multimedia/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-multimedia/template b/srcpkgs/qt6-multimedia/template
index 67a577e1300fe..1da626ecf515a 100644
--- a/srcpkgs/qt6-multimedia/template
+++ b/srcpkgs/qt6-multimedia/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-multimedia'
 pkgname=qt6-multimedia
 version=6.6.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DQT_FEATURE_gstreamer=ON"
 hostmakedepends="perl qt6-declarative-host-tools pkg-config qt6-shadertools"

From 5d75934ab258c230b4ed25e2d8c70bf291eb296b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:00:15 -0500
Subject: [PATCH 104/113] baresip: revbump for ffmpeg6

---
 srcpkgs/baresip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/baresip/template b/srcpkgs/baresip/template
index 12c8954ef7b9b..b16b67beab8d2 100644
--- a/srcpkgs/baresip/template
+++ b/srcpkgs/baresip/template
@@ -1,7 +1,7 @@
 # Template file for 'baresip'
 pkgname=baresip
 version=3.6.0
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config glib-devel"
 makedepends="libgsm-devel libpng-devel openssl-devel libsndfile-devel

From 576d28bd8dd4e9468aa67e6439af860018a07940 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:30 -0500
Subject: [PATCH 105/113] QMPlay2: revbump for ffmpeg6

---
 srcpkgs/QMPlay2/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/QMPlay2/template b/srcpkgs/QMPlay2/template
index 46c80f64a1349..942258ce60fb7 100644
--- a/srcpkgs/QMPlay2/template
+++ b/srcpkgs/QMPlay2/template
@@ -1,7 +1,7 @@
 # Template file for 'QMPlay2'
 pkgname=QMPlay2
 version=23.10.22
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools"
 makedepends="alsa-lib-devel ffmpeg-devel libass-devel libcdio-devel libgme-devel

From d26dff5ebf74f5b77c2c9bbb803022f48cabbee8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:34 -0500
Subject: [PATCH 106/113] alsa-plugins: revbump for ffmpeg6

---
 srcpkgs/alsa-plugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/alsa-plugins/template b/srcpkgs/alsa-plugins/template
index a5708a7d82a8f..7bfdad046c483 100644
--- a/srcpkgs/alsa-plugins/template
+++ b/srcpkgs/alsa-plugins/template
@@ -1,7 +1,7 @@
 # Template file for 'alsa-plugins'
 pkgname=alsa-plugins
 version=1.2.7.1
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--disable-maemo-plugin"
 hostmakedepends="pkg-config"

From 5cc62605d04b63465e1c2db97ea5b20fa134bf37 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:43 -0500
Subject: [PATCH 107/113] minidlna: revbump for ffmpeg6

---
 srcpkgs/minidlna/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/minidlna/template b/srcpkgs/minidlna/template
index 5fa929f3a0c12..742991ecd04af 100644
--- a/srcpkgs/minidlna/template
+++ b/srcpkgs/minidlna/template
@@ -1,7 +1,7 @@
 # Template file for 'minidlna'
 pkgname=minidlna
 version=1.3.3
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="
  --sbindir=/usr/bin

From 2d2b4996d7547519ed071a001913372a475a2796 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 17:57:47 -0500
Subject: [PATCH 108/113] mpv: revbump for ffmpeg6

---
 srcpkgs/mpv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpv/template b/srcpkgs/mpv/template
index 4948d1e332cb8..1ac1b167af189 100644
--- a/srcpkgs/mpv/template
+++ b/srcpkgs/mpv/template
@@ -1,7 +1,7 @@
 # Template file for 'mpv'
 pkgname=mpv
 version=0.36.0
-revision=4
+revision=5
 build_style=meson
 configure_args="-Dcdda=enabled -Ddvbin=enabled -Ddvdnav=enabled
  -Dlibmpv=true -Dcplugins=enabled

From 78e84a372cbfb832c19db64cb2144f39c7cbdb4a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 17:59:29 -0500
Subject: [PATCH 109/113] qimgv: revbump for ffmpeg6

---
 srcpkgs/qimgv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qimgv/template b/srcpkgs/qimgv/template
index dd341dfe1bfce..8a7e1c081ef12 100644
--- a/srcpkgs/qimgv/template
+++ b/srcpkgs/qimgv/template
@@ -1,7 +1,7 @@
 # Template file for 'qimgv'
 pkgname=qimgv
 version=1.0.2
-revision=3
+revision=4
 build_style=cmake
 configure_args="$(vopt_if video -DVIDEO_SUPPORT=ON -DVIDEO_SUPPORT=OFF)
  $(vopt_if scale -DOPENCV_SUPPORT=ON -DOPENCV_SUPPORT=OFF)

From 0a5cbb24c979ab2977578a8416d536530ec31c3f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 18:00:36 -0500
Subject: [PATCH 110/113] kfilemetadata5: revbump for ffmpeg6

---
 srcpkgs/kfilemetadata5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kfilemetadata5/template b/srcpkgs/kfilemetadata5/template
index 51fd6fec8c1c0..ad229b4c2e241 100644
--- a/srcpkgs/kfilemetadata5/template
+++ b/srcpkgs/kfilemetadata5/template
@@ -1,7 +1,7 @@
 # Template file for 'kfilemetadata5'
 pkgname=kfilemetadata5
 version=5.113.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="kcoreaddons extra-cmake-modules pkg-config qt5-host-tools qt5-qmake
  gettext kcoreaddons python3"

From a4bde70fdd783bd316bd56c071a094ecb67a4fe0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 8 Dec 2023 11:46:01 -0500
Subject: [PATCH 111/113] vba-m: revbump for ffmpeg6

---
 srcpkgs/vba-m/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vba-m/template b/srcpkgs/vba-m/template
index 52efeede1dcba..3e0760398905c 100644
--- a/srcpkgs/vba-m/template
+++ b/srcpkgs/vba-m/template
@@ -2,7 +2,7 @@
 pkgname=vba-m
 reverts=1292_2
 version=2.1.8
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_GTK=TRUE -DENABLE_FFMPEG=TRUE -DENABLE_LINK=TRUE -DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="gettext pkg-config unzip zip yasm wxWidgets-gtk3-devel"

From 404c6486ac6319829b1bd516b7253ad9d8434da8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 8 Dec 2023 11:46:19 -0500
Subject: [PATCH 112/113] dolphin-emu: revbump for ffmpeg6

---
 srcpkgs/dolphin-emu/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/dolphin-emu/template b/srcpkgs/dolphin-emu/template
index 862d3ae964eec..a7ae0efb58fb7 100644
--- a/srcpkgs/dolphin-emu/template
+++ b/srcpkgs/dolphin-emu/template
@@ -1,7 +1,7 @@
 # Template file for 'dolphin-emu'
 pkgname=dolphin-emu
 version=5.0.19368
-revision=3
+revision=4
 _dolphin_commit=dadbeb4bae7e7fa23af2b46e0add4143094dc107
 _mgba_commit=44e074a15e9651481f7f652ac006a7c9d58cbeb9
 _googletest_commit=be03d00f5f0cc3a997d1a368bee8a1fe93651f48

From ee9a843f69d13ba8cded4f524543623385132fe4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 19 Dec 2023 15:38:51 -0500
Subject: [PATCH 113/113] qtox: revbump for ffmpeg4

---
 srcpkgs/qtox/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtox/template b/srcpkgs/qtox/template
index bb70e7f51240a..755e4462bc013 100644
--- a/srcpkgs/qtox/template
+++ b/srcpkgs/qtox/template
@@ -1,13 +1,13 @@
 # Template file for 'qtox'
 pkgname=qtox
 version=1.17.6
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DUPDATE_CHECK=OFF
  -DGIT_DESCRIBE=${version}
  $(vopt_if snorenotify -DDESKTOP_NOTIFICATIONS=ON)"
 hostmakedepends="pkg-config qt5-host-tools qt5-devel"
-makedepends="ffmpeg-devel libexif-devel libopenal-devel libsodium-devel
+makedepends="ffmpeg4-devel libexif-devel libopenal-devel libsodium-devel
  libvpx-devel opus-devel qrencode-devel qt5-svg-devel sonnet-devel
  sqlcipher-devel toxcore-devel
  $(vopt_if snorenotify snorenotify-devel)"

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (51 preceding siblings ...)
  2024-01-05 13:07 ` zlice
@ 2024-01-11 16:52 ` zlice
  2024-01-17 22:35 ` zlice
                   ` (44 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2024-01-11 16:52 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 4019 bytes --]

There is an updated pull request by zlice against master on the void-packages repository

https://github.com/zlice/void-packages ffmpeg6-split
https://github.com/void-linux/void-packages/pull/43761

ffmpeg6 split
[ci skip]


#### Testing the changes

- I tested the changes in this PR: **YES**

main testing has been vaapi in Firefox Nightly and enc/dec in Shotcut on Intel A770

#### New package

- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**

#### Local build testing

- I built this PR locally for my native architecture, **x86_64**

#### Discussion

Continuation of https://github.com/void-linux/void-packages/pull/36315

`libavresample` is deprecated, but marked as a dependency when trying to build other packages and install `ffmpeg`(6). I think the right way to handle this is make a meta package and the add to removals?


##### Commit naming / misc

~~Commits are 'dirty' right now, running with [gstreamer 1.22.1 updates](https://github.com/void-linux/void-packages/pull/42861) and [Intel OpenCL](https://github.com/void-linux/void-packages/pull/43084). This will also make [intel packages pr](https://github.com/void-linux/void-packages/pull/41132) obsolete.~~ (see Requirements below)

Maintainer for previous ffmpeg(4) was orphaned, I can put my name in there if that matters, though I don't exactly see myself keeping up on ffmpeg.

~~This updates QT5 which looks like it is usually hosted by Johnny. Not sure if there's any reason to stay there or these sources are fine.~~ Using qt5.15.11 now, revbumps and some patches.

##### STILL FFMPEG4

These are a mix of emulators, games and/or older packages.

- attract (multiple patches in master)
- audacity (https://github.com/audacity/audacity/issues/2305 and https://sourceforge.net/p/portmedia/wiki/portsmf/ is 'beta')
- ccextractor (master patches? no release)
- vice
- kodi
- mlt (only dep left is flowblade)
- ~~synfig (mlt)~~ (work with mlt7, bump synfigstudio)
- tvheadend
- ssr
- ~~spek-alternative~~ (replace with spek-x)
- ppsspp
- olive
- moc
- mediastreamer
- libextractor
- idjc
- hedgewars
- ~~ffmpegthumbnailer~~ (patches for moviedecoder.xxx files)
- ~~ffmpegthumbs~~ (latest compiles)
- deadbeef
- omxplayer
- qtav (fork has ffmpeg 5 patch - https://github.com/cmguo/QtAV)
- `vlc` (vlc4 will support ffmpeg5, there's a patch to build 3.x with ffmpeg5 but it will lack vaapi)
- `osg` (OpenSceneGraph plus `xine-lib`)


##### HAVE NOT BUILT YET

- omxplayer (rpi only? ffmpeg4)
- kodi (big, but ffmpeg4)


##### UPDATED (for ffmpeg6)

- ~~blender: update to 3.5.1~~ ~~will be revbump with~~ https://github.com/void-linux/void-packages/pull/43992
- unpaper: update to 7.0.0.
- guvcview: update to 2.0.8.
- ~~qt5: update to 5.15.8~~ updated by another PR to 5.15.11
- ~~qt5-webengine: update to 5.18.15~~ updated by another PR to 5.15.16 (some patching for ffmpeg build)
- ~~shiboken2: revbump for qt5.15.8 (patch)~~ updated by another PR to 5.15.10
- ~~python3-pyside2: update to 5.15.8 (patch)~~ updated by another PR to 5.15.10
- New package: spex-x replaces spek-alternative for ffmpeg-6.0


##### Requirements

- ~~[gstreamer 1.22.2](https://github.com/void-linux/void-packages/pull/42861)~~ - a few packages use ffmpeg-devel and require a revbump

- ~~[Intel Packages](https://github.com/void-linux/void-packages/pull/41132) [Intel Packages v2](https://github.com/void-linux/void-packages/pull/47330) - ffmpeg4 uses different libraries than 6 (libmfx / Intel-MediaSDK vs only oneVPL that Intel is moving to), both are included here~~. Using replacement oneVPL from OBS update.

- ~~[shotcut 23.05.14](https://github.com/void-linux/void-packages/pull/44260)~~

- https://github.com/void-linux/void-packages/pull/44781 will remove from this PR

A patch file from https://github.com/void-linux/void-packages/pull/43761.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ffmpeg6-split-43761.patch --]
[-- Type: text/x-diff, Size: 220815 bytes --]

From 0d7b7de3de1d567c10b0fd8e73ca64e9521c1d06 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:16:56 -0400
Subject: [PATCH 001/113] ffmpeg: update to 6.0.1.

---
 common/shlibs                                 | 26 +++++---
 srcpkgs/ffmpeg/files/altivec.patch            | 60 -------------------
 .../patches/armv5tel-floating-point.patch     | 18 ------
 ...h-libavcodec-libsvtav1-ten_bit_format.diff | 40 -------------
 .../workaround-mesa-readeon-vaapi-bug.patch   | 28 ---------
 srcpkgs/ffmpeg/template                       | 38 ++++++------
 6 files changed, 37 insertions(+), 173 deletions(-)
 delete mode 100644 srcpkgs/ffmpeg/files/altivec.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 delete mode 100644 srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch

diff --git a/common/shlibs b/common/shlibs
index d3e2fafb0e0f4..1c27fd124f090 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -388,15 +388,23 @@ libid3tag.so.0 libid3tag-0.15.1b_1
 libgif.so.7 giflib-5.1.0_1
 libImlib2.so.1 imlib2-1.4.2_1
 libmp3lame.so.0 lame-3.98.2_1
-libavdevice.so.58 libavdevice-4.0_1
-libavformat.so.58 libavformat-4.0_1
-libswscale.so.5 libswscale-4.0_1
-libswresample.so.3 libswresample-4.0_1
-libavresample.so.4 libavresample-4.0_1
-libpostproc.so.55 libpostproc-4.0_1
-libavcodec.so.58 libavcodec-4.0_1
-libavutil.so.56 libavutil-4.0_1
-libavfilter.so.7 libavfilter-4.0_1
+libavdevice.so.60 libavdevice-6.0_1
+libavformat.so.60 libavformat-6.0_1
+libswscale.so.7 libswscale-6.0_1
+libswresample.so.4 libswresample-6.0_1
+libpostproc.so.57 libpostproc-6.0_1
+libavcodec.so.60 libavcodec-6.0_1
+libavutil.so.58 libavutil-6.0_1
+libavfilter.so.9 libavfilter-6.0_1
+libavdevice.so.58 libavdevice4-4.0_1
+libavformat.so.58 libavformat4-4.0_1
+libswscale.so.5 libswscale4-4.0_1
+libswresample.so.3 libswresample4-4.0_1
+libavresample.so.4 libavresample4-4.0_1
+libpostproc.so.55 libpostproc4-4.0_1
+libavcodec.so.58 libavcodec4-4.0_1
+libavutil.so.56 libavutil4-4.0_1
+libavfilter.so.7 libavfilter4-4.0_1
 libSDL-1.2.so.0 SDL-1.2.14_1
 libSDL_image-1.2.so.0 SDL_image-1.2.10_1
 libx264.so.157 x264-20190507.2245_1
diff --git a/srcpkgs/ffmpeg/files/altivec.patch b/srcpkgs/ffmpeg/files/altivec.patch
deleted file mode 100644
index 9c57200463320..0000000000000
--- a/srcpkgs/ffmpeg/files/altivec.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-revert some altivec specific change on all ppc* except ppc64le*
-
-q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
-conditionally, for ppc* but not ppc64le* (the new code is valid for
-POWER8 VSX which LE targets as a baseline but not BE)"
-
-
-This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
----
- libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
- 1 file changed, 20 insertions(+), 4 deletions(-)
-
-diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
-index 536545293d..c1e2852adb 100644
---- a/libswscale/ppc/yuv2rgb_altivec.c
-+++ b/libswscale/ppc/yuv2rgb_altivec.c
-@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-     vector signed short R1, G1, B1;                                           \
-     vector unsigned char R, G, B;                                             \
-                                                                               \
-+    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
-+    vector unsigned char align_perm;                                          \
-+                                                                              \
-     vector signed short lCY       = c->CY;                                    \
-     vector signed short lOY       = c->OY;                                    \
-     vector signed short lCRV      = c->CRV;                                   \
-@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
-                                                                               \
-         for (j = 0; j < w / 16; j++) {                                        \
--            y0 = vec_xl(0, y1i);                                              \
-+            y1ivP = (const vector unsigned char *) y1i;                       \
-+            y2ivP = (const vector unsigned char *) y2i;                       \
-+            uivP  = (const vector unsigned char *) ui;                        \
-+            vivP  = (const vector unsigned char *) vi;                        \
-+                                                                              \
-+            align_perm = vec_lvsl(0, y1i);                                    \
-+            y0 = (vector unsigned char)                                       \
-+                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
-                                                                               \
--            y1 = vec_xl(0, y2i);                                              \
-+            align_perm = vec_lvsl(0, y2i);                                    \
-+            y1 = (vector unsigned char)                                       \
-+                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
-                                                                               \
--            u = (vector signed char) vec_xl(0, ui);                           \
-+            align_perm = vec_lvsl(0, ui);                                     \
-+            u = (vector signed char)                                          \
-+                    vec_perm(uivP[0], uivP[1], align_perm);                   \
-                                                                               \
--            v = (vector signed char) vec_xl(0, vi);                           \
-+            align_perm = vec_lvsl(0, vi);                                     \
-+            v = (vector signed char)                                          \
-+                    vec_perm(vivP[0], vivP[1], align_perm);                   \
-                                                                               \
-             u = (vector signed char)                                          \
-                     vec_sub(u,                                                \
--- 
-2.27.0
-
diff --git a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
deleted file mode 100644
index 9a55178c74f0f..0000000000000
--- a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
-+++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
-@@ -39,6 +39,15 @@
- #endif
- #include <fenv.h>
- 
-+#if (FE_ALL_EXCEPT == 0)
-+/* E.g. ARM soft float does not define these */
-+#define FE_INVALID    0
-+#define FE_DIVBYZERO  0
-+#define FE_OVERFLOW   0
-+#define FE_UNDERFLOW  0
-+#define FE_INEXACT    0
-+#endif
-+
- #if CONFIG_LIBFONTCONFIG
- #include <fontconfig/fontconfig.h>
- #endif
diff --git a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
deleted file mode 100644
index aa948f7a8a2df..0000000000000
--- a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
+++ /dev/null
@@ -1,40 +0,0 @@
-#==================================================================================================
-# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
-# From: Christopher Degawa <christopher.degawa@intel.com>
-# Date: Thu, 20 Oct 2022 22:55:27 -0500
-# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
-#
-# compressed_ten_bit_format has been deprecated upstream and has no effect
-# and can be removed. Plus, technically it was never used in the first place
-# since it would require the app (ffmpeg) to set it and do additional
-# processing of the input frames.
-#
-# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
-#
-# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
-#==================================================================================================
---- a/libavcodec/libsvtav1.c
-+++ b/libavcodec/libsvtav1.c
-@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
- 
- static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
- {
--    const int    pack_mode_10bit =
--        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
--    const size_t luma_size_8bit  =
--        config->source_width * config->source_height * (1 << pack_mode_10bit);
--    const size_t luma_size_10bit =
--        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
-+    const size_t luma_size = config->source_width * config->source_height *
-+        (config->encoder_bit_depth > 8 ? 2 : 1);
- 
-     EbSvtIOFormat *in_data;
- 
--    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
-+    svt_enc->raw_size = luma_size * 3 / 2;
- 
-     // allocate buffer for in and out
-     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
--- 
-GitLab
-
diff --git a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
deleted file mode 100644
index 00e3f68a415b8..0000000000000
--- a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
-From: Rainer Hochecker <fernetmenta@online.de>
-Date: Sat, 26 Jan 2019 19:48:35 +0100
-Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
-
-This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
-It was hit frequently when watching h264 channels received via DVB-X.
-Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
----
- libavcodec/vaapi_h264.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
-index 5854587a255..f12fdc457a4 100644
---- a/libavcodec/vaapi_h264.c
-+++ b/libavcodec/vaapi_h264.c
-@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
-     H264SliceContext *sl = &h->slice_ctx[0];
-     int ret;
- 
-+    if (pic->nb_slices == 0) {
-+        ret = AVERROR_INVALIDDATA;
-+        goto finish;
-+    }
-+
-     ret = ff_vaapi_decode_issue(avctx, pic);
-     if (ret < 0)
-         goto finish;
diff --git a/srcpkgs/ffmpeg/template b/srcpkgs/ffmpeg/template
index 5968a09b1f12d..52fcf4d68797a 100644
--- a/srcpkgs/ffmpeg/template
+++ b/srcpkgs/ffmpeg/template
@@ -1,15 +1,15 @@
 # Template file for 'ffmpeg'
 # audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
 pkgname=ffmpeg
-version=4.4.4
-revision=5
+version=6.0.1
+revision=1
 short_desc="Decoding, encoding and streaming software"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="https://www.ffmpeg.org"
 changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
 distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
-checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+checksum=9b16b8731d78e596b4be0d720428ca42df642bb2d78342881ff7f5bc29fc9623
 
 hostmakedepends="pkg-config perl"
 makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
@@ -26,12 +26,13 @@ makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-deve
  $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
  $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
  $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
- $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers Vulkan-Tools Vulkan-ValidationLayers')
+ $(vopt_if onevpl 'oneVPL oneVPL-devel')
  $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
 depends="ffplay>=${version}_${revision}"
 
 build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
- dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec onevpl"
 build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
 desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
 desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
@@ -39,9 +40,13 @@ desc_option_sofa="Enable support for AES SOFA"
 desc_option_webp="Enable support for WebP"
 
 case "$XBPS_TARGET_MACHINE" in
-	i686*|x86_64*)
-		hostmakedepends+=" nasm"
+	i686*)
 		build_options_default+=" vaapi vdpau nvenc nvdec"
+		hostmakedepends+=" nasm"
+		;;
+	x86_64*)
+		hostmakedepends+=" nasm"
+		build_options_default+=" vaapi vdpau nvenc nvdec onevpl"
 		;;
 	ppc64*) build_options_default+=" vaapi vdpau";;
 	mips*) CFLAGS="-mnan=legacy";;
@@ -115,18 +120,19 @@ do_configure() {
 		$(vopt_enable x265 libx265) \
 		$(vopt_enable v4l2 libv4l2) \
 		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
-		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		--enable-libbs2b --enable-libvidstab \
 		$(vopt_enable dav1d libdav1d) \
 		$(vopt_enable zimg libzimg) \
 		$(vopt_enable webp libwebp) \
 		$(vopt_enable sofa libmysofa) \
 		$(vopt_enable vulkan) \
+		$(vopt_enable onevpl libvpl) \
 		$(vopt_enable drm libdrm) \
 		$(vopt_enable svtav1 libsvtav1) \
 		$(vopt_enable srt libsrt) \
 		$(vopt_enable rist librist) \
-		$(vopt_if nvenc '--enable-nvenc') \
-		$(vopt_if nvdec '--enable-nvdec')
+		$(vopt_enable nvenc nvenc) \
+		$(vopt_enable nvdec nvdec)
 }
 
 do_build() {
@@ -153,10 +159,8 @@ libavdevice_package() {
 }
 
 libavresample_package() {
-	short_desc="FFmpeg audio resampling library"
-	pkg_install() {
-		vmove "usr/lib/libavresample.so.*"
-	}
+	short_desc="Package deprecated, removal needed"
+	build_style=meta
 }
 
 libavformat_package() {
@@ -210,15 +214,13 @@ ffmpeg-devel_package() {
 		libavfilter>=${version}_${revision}
 		libpostproc>=${version}_${revision}
 		libswscale>=${version}_${revision}
-		libswresample>=${version}_${revision}
-		libavresample>=${version}_${revision}"
+		libswresample>=${version}_${revision}"
 	short_desc+=" - development files"
-
+	conflicts="ffmpeg4-devel"
 	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
 		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
 		nostrip_files="/usr/lib/libavfilter.a"
 	fi
-
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig

From f7dcac2cfab7c86313113575c299b9e8b349cdd6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:14 -0400
Subject: [PATCH 002/113] openshot: revbump for ffmpeg6

---
 srcpkgs/openshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openshot/template b/srcpkgs/openshot/template
index 8f47851eef354..affb652a9d500 100644
--- a/srcpkgs/openshot/template
+++ b/srcpkgs/openshot/template
@@ -1,7 +1,7 @@
 # Template file for 'openshot'
 pkgname=openshot
 version=3.0.0
-revision=2
+revision=3
 build_style=python3-module
 hostmakedepends="python3 python3-setuptools"
 makedepends="ffmpeg-devel python3-PyQt5"

From 519e286e73fb0f57085f5fb63a6110e5308fc24b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:36 -0400
Subject: [PATCH 003/113] sumo: revbump for ffmpeg6

---
 srcpkgs/sumo/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/sumo/template b/srcpkgs/sumo/template
index a3fe134aa5acc..a730afa9fafa9 100644
--- a/srcpkgs/sumo/template
+++ b/srcpkgs/sumo/template
@@ -1,7 +1,7 @@
 # Template file for 'sumo'
 pkgname=sumo
 version=1.12.0
-revision=6
+revision=7
 build_style=cmake
 hostmakedepends="libgdal-tools pkg-config swig python3-setuptools"
 makedepends="python3-devel ffmpeg-devel fox-devel gl2ps-devel libgdal-devel

From 2f694d8a2d26317c1448f2f04beb09473b9c4ff1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:56:22 -0400
Subject: [PATCH 004/113] New package: ffmpeg4-4.4.4.

---
 srcpkgs/ffmpeg4-devel                         |   1 +
 srcpkgs/ffmpeg4/files/altivec.patch           |  60 +++++
 .../patches/armv5tel-floating-point.patch     |  18 ++
 ...h-libavcodec-libsvtav1-ten_bit_format.diff |  40 +++
 .../workaround-mesa-readeon-vaapi-bug.patch   |  28 +++
 srcpkgs/ffmpeg4/template                      | 234 ++++++++++++++++++
 srcpkgs/libavcodec4                           |   1 +
 srcpkgs/libavdevice4                          |   1 +
 srcpkgs/libavfilter4                          |   1 +
 srcpkgs/libavformat4                          |   1 +
 srcpkgs/libavresample4                        |   1 +
 srcpkgs/libavutil4                            |   1 +
 srcpkgs/libpostproc4                          |   1 +
 srcpkgs/libswresample4                        |   1 +
 srcpkgs/libswscale4                           |   1 +
 15 files changed, 390 insertions(+)
 create mode 120000 srcpkgs/ffmpeg4-devel
 create mode 100644 srcpkgs/ffmpeg4/files/altivec.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 create mode 100644 srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
 create mode 100644 srcpkgs/ffmpeg4/template
 create mode 120000 srcpkgs/libavcodec4
 create mode 120000 srcpkgs/libavdevice4
 create mode 120000 srcpkgs/libavfilter4
 create mode 120000 srcpkgs/libavformat4
 create mode 120000 srcpkgs/libavresample4
 create mode 120000 srcpkgs/libavutil4
 create mode 120000 srcpkgs/libpostproc4
 create mode 120000 srcpkgs/libswresample4
 create mode 120000 srcpkgs/libswscale4

diff --git a/srcpkgs/ffmpeg4-devel b/srcpkgs/ffmpeg4-devel
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/ffmpeg4-devel
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/ffmpeg4/files/altivec.patch b/srcpkgs/ffmpeg4/files/altivec.patch
new file mode 100644
index 0000000000000..9c57200463320
--- /dev/null
+++ b/srcpkgs/ffmpeg4/files/altivec.patch
@@ -0,0 +1,60 @@
+revert some altivec specific change on all ppc* except ppc64le*
+
+q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
+conditionally, for ppc* but not ppc64le* (the new code is valid for
+POWER8 VSX which LE targets as a baseline but not BE)"
+
+
+This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
+---
+ libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
+ 1 file changed, 20 insertions(+), 4 deletions(-)
+
+diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
+index 536545293d..c1e2852adb 100644
+--- a/libswscale/ppc/yuv2rgb_altivec.c
++++ b/libswscale/ppc/yuv2rgb_altivec.c
+@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+     vector signed short R1, G1, B1;                                           \
+     vector unsigned char R, G, B;                                             \
+                                                                               \
++    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
++    vector unsigned char align_perm;                                          \
++                                                                              \
+     vector signed short lCY       = c->CY;                                    \
+     vector signed short lOY       = c->OY;                                    \
+     vector signed short lCRV      = c->CRV;                                   \
+@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
+                                                                               \
+         for (j = 0; j < w / 16; j++) {                                        \
+-            y0 = vec_xl(0, y1i);                                              \
++            y1ivP = (const vector unsigned char *) y1i;                       \
++            y2ivP = (const vector unsigned char *) y2i;                       \
++            uivP  = (const vector unsigned char *) ui;                        \
++            vivP  = (const vector unsigned char *) vi;                        \
++                                                                              \
++            align_perm = vec_lvsl(0, y1i);                                    \
++            y0 = (vector unsigned char)                                       \
++                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
+                                                                               \
+-            y1 = vec_xl(0, y2i);                                              \
++            align_perm = vec_lvsl(0, y2i);                                    \
++            y1 = (vector unsigned char)                                       \
++                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
+                                                                               \
+-            u = (vector signed char) vec_xl(0, ui);                           \
++            align_perm = vec_lvsl(0, ui);                                     \
++            u = (vector signed char)                                          \
++                    vec_perm(uivP[0], uivP[1], align_perm);                   \
+                                                                               \
+-            v = (vector signed char) vec_xl(0, vi);                           \
++            align_perm = vec_lvsl(0, vi);                                     \
++            v = (vector signed char)                                          \
++                    vec_perm(vivP[0], vivP[1], align_perm);                   \
+                                                                               \
+             u = (vector signed char)                                          \
+                     vec_sub(u,                                                \
+-- 
+2.27.0
+
diff --git a/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
new file mode 100644
index 0000000000000..9a55178c74f0f
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
@@ -0,0 +1,18 @@
+--- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
++++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
+@@ -39,6 +39,15 @@
+ #endif
+ #include <fenv.h>
+ 
++#if (FE_ALL_EXCEPT == 0)
++/* E.g. ARM soft float does not define these */
++#define FE_INVALID    0
++#define FE_DIVBYZERO  0
++#define FE_OVERFLOW   0
++#define FE_UNDERFLOW  0
++#define FE_INEXACT    0
++#endif
++
+ #if CONFIG_LIBFONTCONFIG
+ #include <fontconfig/fontconfig.h>
+ #endif
diff --git a/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
new file mode 100644
index 0000000000000..aa948f7a8a2df
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
@@ -0,0 +1,40 @@
+#==================================================================================================
+# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
+# From: Christopher Degawa <christopher.degawa@intel.com>
+# Date: Thu, 20 Oct 2022 22:55:27 -0500
+# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
+#
+# compressed_ten_bit_format has been deprecated upstream and has no effect
+# and can be removed. Plus, technically it was never used in the first place
+# since it would require the app (ffmpeg) to set it and do additional
+# processing of the input frames.
+#
+# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
+#
+# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
+#==================================================================================================
+--- a/libavcodec/libsvtav1.c
++++ b/libavcodec/libsvtav1.c
+@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
+ 
+ static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
+ {
+-    const int    pack_mode_10bit =
+-        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
+-    const size_t luma_size_8bit  =
+-        config->source_width * config->source_height * (1 << pack_mode_10bit);
+-    const size_t luma_size_10bit =
+-        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
++    const size_t luma_size = config->source_width * config->source_height *
++        (config->encoder_bit_depth > 8 ? 2 : 1);
+ 
+     EbSvtIOFormat *in_data;
+ 
+-    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
++    svt_enc->raw_size = luma_size * 3 / 2;
+ 
+     // allocate buffer for in and out
+     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
+-- 
+GitLab
+
diff --git a/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
new file mode 100644
index 0000000000000..00e3f68a415b8
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
@@ -0,0 +1,28 @@
+From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
+From: Rainer Hochecker <fernetmenta@online.de>
+Date: Sat, 26 Jan 2019 19:48:35 +0100
+Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
+
+This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
+It was hit frequently when watching h264 channels received via DVB-X.
+Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
+---
+ libavcodec/vaapi_h264.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
+index 5854587a255..f12fdc457a4 100644
+--- a/libavcodec/vaapi_h264.c
++++ b/libavcodec/vaapi_h264.c
+@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
+     H264SliceContext *sl = &h->slice_ctx[0];
+     int ret;
+ 
++    if (pic->nb_slices == 0) {
++        ret = AVERROR_INVALIDDATA;
++        goto finish;
++    }
++
+     ret = ff_vaapi_decode_issue(avctx, pic);
+     if (ret < 0)
+         goto finish;
diff --git a/srcpkgs/ffmpeg4/template b/srcpkgs/ffmpeg4/template
new file mode 100644
index 0000000000000..9ba14bdb8ddf3
--- /dev/null
+++ b/srcpkgs/ffmpeg4/template
@@ -0,0 +1,234 @@
+# Template file for 'ffmpeg4'
+# audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
+pkgname=ffmpeg4
+version=4.4.4
+revision=1
+short_desc="Decoding, encoding and streaming software - ffmpeg4 libraries only"
+maintainer="Orphaned <orphan@voidlinux.org>"
+license="GPL-3.0-or-later"
+homepage="https://www.ffmpeg.org"
+changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
+distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
+checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+
+hostmakedepends="pkg-config perl"
+makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
+ libXext-devel libXvMC-devel libxcb-devel lame-devel libtheora-devel
+ libvorbis-devel x264-devel xvidcore-devel jack-devel SDL2-devel
+ libcdio-paranoia-devel librtmp-devel libmodplug-devel gnutls-devel
+ speex-devel celt-devel harfbuzz-devel libass-devel opus-devel ocl-icd-devel
+ libbs2b-devel libvidstab-devel vmaf-devel $(vopt_if pulseaudio pulseaudio-devel)
+ $(vopt_if vaapi libva-devel) $(vopt_if vdpau libvdpau-devel)
+ $(vopt_if x265 x265-devel) $(vopt_if v4l2 v4l-utils-devel)
+ $(vopt_if fdk_aac fdk-aac-devel) $(vopt_if vpx libvpx-devel)
+ $(vopt_if aom libaom-devel) $(vopt_if sndio sndio-devel)
+ $(vopt_if dav1d libdav1d-devel) $(vopt_if zimg zimg-devel)
+ $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
+ $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
+ $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
+
+build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
+
+desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
+desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
+desc_option_sofa="Enable support for AES SOFA"
+desc_option_webp="Enable support for WebP"
+
+case "$XBPS_TARGET_MACHINE" in
+	i686*|x86_64*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau nvenc nvdec"
+			;;
+	ppc64*) build_options_default+=" vaapi vdpau";;
+	mips*) CFLAGS="-mnan=legacy";;
+esac
+
+if [ "$XBPS_TARGET_WORDSIZE" != "32" ]; then
+	build_options_default+=" svtav1"
+fi
+
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+fi
+
+_apply_patch() {
+	local args="$1" pname="$(basename $2)"
+
+	if [ ! -f ".${pname}_done" ]; then
+		patch -N $args -i $2
+		touch .${pname}_done
+	fi
+}
+
+post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64le*) ;;
+		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
+	esac
+
+	vsed -i libavfilter/vf_libvmaf.c -e 's!/usr/local/share/model/\(vmaf_v0.6.1\).pkl!/usr/share/vmaf/\1.json!'
+}
+
+do_configure() {
+	# Fix gcc on x86_64-musl only
+	if [ "$XBPS_TARGET_MACHINE" = "x86_64-musl" ]; then
+		vsed -i configure -e "s;_cflags_speed='-O3';_cflags_speed='-O2';"
+	fi
+
+	if [ "$CROSS_BUILD" ]; then
+		case "$XBPS_TARGET_MACHINE" in
+			arm*) _arch="arm";;
+			aarch64*) _arch="aarch64";;
+			mips*) _arch="mips";;
+			ppc64*) _arch="ppc64";;
+			ppc*) _arch="ppc";;
+			*) _arch="${XBPS_TARGET_MACHINE%%-musl}";;
+		esac
+
+		_args+=" --enable-cross-compile
+			--sysroot=$XBPS_CROSS_BASE
+			--cross-prefix=${XBPS_CROSS_TRIPLET}-
+			--target-os=linux --arch=${_arch}"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc|ppc-musl) _args+=" --disable-altivec";;
+	esac
+
+	if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+		_args+=" --extra-libs=-latomic"
+	fi
+
+	./configure --prefix=/usr --disable-debug --enable-gpl --enable-gnutls \
+		--disable-stripping \
+		--enable-libcdio --enable-version3 --enable-runtime-cpudetect \
+		--enable-libmp3lame --enable-libvorbis --enable-libxvid \
+		--enable-libx264 $(vopt_enable vpx libvpx) --enable-libtheora \
+		--enable-shared --enable-static --enable-libxcb \
+		$(vopt_enable pulseaudio libpulse) --enable-libfreetype --enable-libmodplug \
+		--enable-libspeex --enable-libcelt --enable-libass \
+		--enable-libopus --enable-librtmp --enable-libjack \
+		$(vopt_if fdk_aac '--enable-nonfree --enable-libfdk-aac') \
+		--disable-libopencore_amrnb --disable-libopencore_amrwb \
+		--disable-libopenjpeg \
+		--enable-postproc --enable-opencl ${_args} --enable-libvmaf ${_args} \
+		$(vopt_enable x265 libx265) \
+		$(vopt_enable v4l2 libv4l2) \
+		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
+		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		$(vopt_enable dav1d libdav1d) \
+		$(vopt_enable zimg libzimg) \
+		$(vopt_enable webp libwebp) \
+		$(vopt_enable sofa libmysofa) \
+		$(vopt_enable vulkan) \
+		$(vopt_enable drm libdrm) \
+		$(vopt_enable svtav1 libsvtav1) \
+		$(vopt_enable srt libsrt) \
+		$(vopt_enable rist librist) \
+		$(vopt_if nvenc '--enable-nvenc') \
+		$(vopt_if nvdec '--enable-nvdec')
+}
+
+do_build() {
+	make ${makejobs}
+	make doc/ff{mpeg,play}.1
+}
+
+do_install() {
+	make DESTDIR=${DESTDIR} install install-man
+	rm -rf ${DESTDIR}/usr/bin
+}
+
+libavcodec4_package() {
+	short_desc="FFmpeg codec library"
+	pkg_install() {
+		vmove "usr/lib/libavcodec.so.*"
+	}
+}
+
+libavdevice4_package() {
+	short_desc="FFmpeg device handling library"
+	pkg_install() {
+		vmove "usr/lib/libavdevice.so.*"
+	}
+}
+
+libavresample4_package() {
+	short_desc="FFmpeg audio resampling library"
+	pkg_install() {
+		vmove "usr/lib/libavresample.so.*"
+	}
+}
+
+libavformat4_package() {
+	short_desc="FFmpeg file format library"
+	pkg_install() {
+		vmove "usr/lib/libavformat.so.*"
+	}
+}
+
+libavutil4_package() {
+	short_desc="FFmpeg utility library"
+	pkg_install() {
+		vmove "usr/lib/libavutil.so.*"
+	}
+}
+
+libavfilter4_package() {
+	short_desc="FFmpeg audio/video filter library"
+	pkg_install() {
+		vmove "usr/lib/libavfilter.so.*"
+	}
+}
+
+libpostproc4_package() {
+	short_desc="FFmpeg video postprocessing library"
+	pkg_install() {
+		vmove "usr/lib/libpostproc.so.*"
+	}
+}
+
+libswscale4_package() {
+	short_desc="FFmpeg video scaling library"
+	pkg_install() {
+		vmove "usr/lib/libswscale.so.*"
+	}
+}
+
+libswresample4_package() {
+	short_desc="FFmpeg video resampling library"
+	pkg_install() {
+		vmove "usr/lib/libswresample.so.*"
+	}
+}
+
+ffmpeg4-devel_package() {
+	depends="
+		libavcodec4>=${version}_${revision}
+		libavdevice4>=${version}_${revision}
+		libavformat4>=${version}_${revision}
+		libavutil4>=${version}_${revision}
+		libavfilter4>=${version}_${revision}
+		libpostproc4>=${version}_${revision}
+		libswscale4>=${version}_${revision}
+		libswresample4>=${version}_${revision}
+		libavresample4>=${version}_${revision}"
+	short_desc+=" - development files"
+	conflicts="ffmpeg-devel"
+	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
+		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
+		nostrip_files="/usr/lib/libavfilter.a"
+	fi
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.a"
+		vmove "usr/lib/*.so"
+		vmove usr/share/ffmpeg/examples
+		vmove usr/share/man/man3
+	}
+}
diff --git a/srcpkgs/libavcodec4 b/srcpkgs/libavcodec4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavcodec4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavdevice4 b/srcpkgs/libavdevice4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavdevice4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavfilter4 b/srcpkgs/libavfilter4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavfilter4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavformat4 b/srcpkgs/libavformat4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavformat4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavresample4 b/srcpkgs/libavresample4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavutil4 b/srcpkgs/libavutil4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavutil4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libpostproc4 b/srcpkgs/libpostproc4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libpostproc4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswresample4 b/srcpkgs/libswresample4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libswresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswscale4 b/srcpkgs/libswscale4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libswscale4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file

From dc1a80891d3ec5edc763f32908e66a2cc09f23a8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:04 -0400
Subject: [PATCH 005/113] opencv: update to 4.7.0.

---
 common/shlibs           | 104 ++++++++++++++++++++--------------------
 srcpkgs/opencv/template |   8 ++--
 2 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index 1c27fd124f090..c732fa489e06f 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2087,58 +2087,58 @@ libcapstone.so.5 capstone-5.0.1_1
 libhavege.so.2 libhaveged-1.9.11_1
 libnih.so.1 libnih-1.0.3_1
 libnih-dbus.so.1 libnih-1.0.3_1
-libopencv_quality.so.406 libopencv-4.6.0_1
-libopencv_reg.so.406 libopencv-4.6.0_1
-libopencv_surface_matching.so.406 libopencv-4.6.0_1
-libopencv_xphoto.so.406 libopencv-4.6.0_1
-libopencv_freetype.so.406 libopencv-4.6.0_1
-libopencv_fuzzy.so.406 libopencv-4.6.0_1
-libopencv_hfs.so.406 libopencv-4.6.0_1
-libopencv_img_hash.so.406 libopencv-4.6.0_1
-libopencv_line_descriptor.so.406 libopencv-4.6.0_1
-libopencv_saliency.so.406 libopencv-4.6.0_1
-libopencv_structured_light.so.406 libopencv-4.6.0_1
-libopencv_aruco.so.406 libopencv-4.6.0_1
-libopencv_bgsegm.so.406 libopencv-4.6.0_1
-libopencv_bioinspired.so.406 libopencv-4.6.0_1
-libopencv_ccalib.so.406 libopencv-4.6.0_1
-libopencv_face.so.406 libopencv-4.6.0_1
-libopencv_tracking.so.406 libopencv-4.6.0_1
-libopencv_xfeatures2d.so.406 libopencv-4.6.0_1
-libopencv_optflow.so.406 libopencv-4.6.0_1
-libopencv_ximgproc.so.406 libopencv-4.6.0_1
-libopencv_plot.so.406 libopencv-4.6.0_1
-libopencv_text.so.406 libopencv-4.6.0_1
-libopencv_ml.so.406 libopencv-4.6.0_1
-libopencv_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn.so.406 libopencv-4.6.0_1
-libopencv_shape.so.406 libopencv-4.6.0_1
-libopencv_stitching.so.406 libopencv-4.6.0_1
-libopencv_photo.so.406 libopencv-4.6.0_1
-libopencv_video.so.406 libopencv-4.6.0_1
-libopencv_calib3d.so.406 libopencv-4.6.0_1
-libopencv_features2d.so.406 libopencv-4.6.0_1
-libopencv_flann.so.406 libopencv-4.6.0_1
-libopencv_highgui.so.406 libopencv-4.6.0_1
-libopencv_videoio.so.406 libopencv-4.6.0_1
-libopencv_imgcodecs.so.406 libopencv-4.6.0_1
-libopencv_imgproc.so.406 libopencv-4.6.0_1
-libopencv_core.so.406 libopencv-4.6.0_1
-libopencv_superres.so.406 libopencv-4.6.0_1
-libopencv_videostab.so.406 libopencv-4.6.0_1
-libopencv_gapi.so.406 libopencv-4.6.0_1
-libopencv_xobjdetect.so.406 libopencv-4.6.0_1
-libopencv_datasets.so.406 libopencv-4.6.0_1
-libopencv_dnn_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn_superres.so.406 libopencv-4.6.0_1
-libopencv_dpm.so.406 libopencv-4.6.0_1
-libopencv_phase_unwrapping.so.406 libopencv-4.6.0_1
-libopencv_stereo.so.406 libopencv-4.6.0_1
-libopencv_rapid.so.406 libopencv-4.6.0_1
-libopencv_intensity_transform.so.406 libopencv-4.6.0_1
-libopencv_alphamat.so.406 libopencv-4.6.0_1
-libopencv_barcode.so.406 libopencv-4.6.0_1
-libopencv_mcc.so.406 libopencv-4.6.0_1
+libopencv_quality.so.407 libopencv-4.7.0_1
+libopencv_reg.so.407 libopencv-4.7.0_1
+libopencv_surface_matching.so.407 libopencv-4.7.0_1
+libopencv_xphoto.so.407 libopencv-4.7.0_1
+libopencv_freetype.so.407 libopencv-4.7.0_1
+libopencv_fuzzy.so.407 libopencv-4.7.0_1
+libopencv_hfs.so.407 libopencv-4.7.0_1
+libopencv_img_hash.so.407 libopencv-4.7.0_1
+libopencv_line_descriptor.so.407 libopencv-4.7.0_1
+libopencv_saliency.so.407 libopencv-4.7.0_1
+libopencv_structured_light.so.407 libopencv-4.7.0_1
+libopencv_aruco.so.407 libopencv-4.7.0_1
+libopencv_bgsegm.so.407 libopencv-4.7.0_1
+libopencv_bioinspired.so.407 libopencv-4.7.0_1
+libopencv_ccalib.so.407 libopencv-4.7.0_1
+libopencv_face.so.407 libopencv-4.7.0_1
+libopencv_tracking.so.407 libopencv-4.7.0_1
+libopencv_xfeatures2d.so.407 libopencv-4.7.0_1
+libopencv_optflow.so.407 libopencv-4.7.0_1
+libopencv_ximgproc.so.407 libopencv-4.7.0_1
+libopencv_plot.so.407 libopencv-4.7.0_1
+libopencv_text.so.407 libopencv-4.7.0_1
+libopencv_ml.so.407 libopencv-4.7.0_1
+libopencv_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn.so.407 libopencv-4.7.0_1
+libopencv_shape.so.407 libopencv-4.7.0_1
+libopencv_stitching.so.407 libopencv-4.7.0_1
+libopencv_photo.so.407 libopencv-4.7.0_1
+libopencv_video.so.407 libopencv-4.7.0_1
+libopencv_calib3d.so.407 libopencv-4.7.0_1
+libopencv_features2d.so.407 libopencv-4.7.0_1
+libopencv_flann.so.407 libopencv-4.7.0_1
+libopencv_highgui.so.407 libopencv-4.7.0_1
+libopencv_videoio.so.407 libopencv-4.7.0_1
+libopencv_imgcodecs.so.407 libopencv-4.7.0_1
+libopencv_imgproc.so.407 libopencv-4.7.0_1
+libopencv_core.so.407 libopencv-4.7.0_1
+libopencv_superres.so.407 libopencv-4.7.0_1
+libopencv_videostab.so.407 libopencv-4.7.0_1
+libopencv_gapi.so.407 libopencv-4.7.0_1
+libopencv_xobjdetect.so.407 libopencv-4.7.0_1
+libopencv_datasets.so.407 libopencv-4.7.0_1
+libopencv_dnn_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn_superres.so.407 libopencv-4.7.0_1
+libopencv_dpm.so.407 libopencv-4.7.0_1
+libopencv_phase_unwrapping.so.407 libopencv-4.7.0_1
+libopencv_stereo.so.407 libopencv-4.7.0_1
+libopencv_rapid.so.407 libopencv-4.7.0_1
+libopencv_intensity_transform.so.407 libopencv-4.7.0_1
+libopencv_alphamat.so.407 libopencv-4.7.0_1
+libopencv_barcode.so.407 libopencv-4.7.0_1
+libopencv_mcc.so.407 libopencv-4.7.0_1
 libuniconf.so.4.6 wvstreams-4.6.1_20
 libwvbase.so.4.6 wvstreams-4.6.1_20
 libwvutils.so.4.6 wvstreams-4.6.1_20
diff --git a/srcpkgs/opencv/template b/srcpkgs/opencv/template
index aea4bfc3a265c..ce94de9424d18 100644
--- a/srcpkgs/opencv/template
+++ b/srcpkgs/opencv/template
@@ -1,7 +1,7 @@
 # Template file for 'opencv'
 pkgname=opencv
-version=4.6.0
-revision=6
+version=4.7.0
+revision=1
 create_wrksrc=yes
 build_wrksrc=${pkgname}-${version}
 build_style=cmake
@@ -24,8 +24,8 @@ homepage="https://opencv.org"
 changelog="https://github.com/opencv/opencv/wiki/ChangeLog"
 distfiles="https://github.com/opencv/opencv/archive/${version}.tar.gz
  https://github.com/opencv/opencv_contrib/archive/${version}.tar.gz>contrib.tar.gz"
-checksum="1ec1cba65f9f20fe5a41fda1586e01c70ea0c9a6d7b67c9e13edf0cfe2239277
- 1777d5fd2b59029cf537e5fd6f8aa68d707075822f90bde683fcde086f85f7a7"
+checksum="8df0079cdbe179748a18d44731af62a245a45ebf5085223dc03133954c662973
+ 42df840cf9055e59d0e22c249cfb19f04743e1bdad113d31b1573d3934d62584"
 patch_args="-Np1 -d ${build_wrksrc}"
 # tests hang indenfinitely, even with test data included
 make_check=no

From 7647e7a29bc9f5dc759524fc97bc776aa236041e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 006/113] actiona: revbump for opencv-4.7.0

---
 srcpkgs/actiona/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/actiona/template b/srcpkgs/actiona/template
index cf5f0b7a2ae61..0d899311e6df7 100644
--- a/srcpkgs/actiona/template
+++ b/srcpkgs/actiona/template
@@ -1,7 +1,7 @@
 # Template file for 'actiona'
 pkgname=actiona
 version=3.10.1
-revision=2
+revision=3
 build_style=qmake
 configure_args="PKGCONFIG_OPENCV=opencv4"
 hostmakedepends="pkg-config qt5-plugin-mysql qt5-qmake qt5-host-tools"

From 4a79f92e85872eb58fdd1e4f692bacc529147454 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 007/113] retroshare: revbump for opencv-4.7.0

---
 srcpkgs/retroshare/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroshare/template b/srcpkgs/retroshare/template
index bb17569277a7f..49e2c1cbe8a53 100644
--- a/srcpkgs/retroshare/template
+++ b/srcpkgs/retroshare/template
@@ -1,7 +1,7 @@
 # Template file for 'retroshare'
 pkgname=retroshare
 version=0.6.6
-revision=3
+revision=4
 build_style=qmake
 #XXX broadcast feature requires an ancient udp-discovery-cpp which either needs
 # to be fetched+patched (FTBFS) here or packaged :/

From 49f3862683bf89d8c1bc6742902a76fa403e873b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 008/113] waifu2x-converter-cpp: revbump for opencv-4.7.0

---
 srcpkgs/waifu2x-converter-cpp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waifu2x-converter-cpp/template b/srcpkgs/waifu2x-converter-cpp/template
index 361b8a23b9497..c5ac17eb54ea4 100644
--- a/srcpkgs/waifu2x-converter-cpp/template
+++ b/srcpkgs/waifu2x-converter-cpp/template
@@ -1,7 +1,7 @@
 # Template file for 'waifu2x-converter-cpp'
 pkgname=waifu2x-converter-cpp
 version=5.2.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DINSTALL_MODELS=ON"
 hostmakedepends="pkg-config"

From 6c992733c987cd0a91bb1410b21a1fe90f9cd389 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:38 -0400
Subject: [PATCH 009/113] vlc: revbump for ffmpeg4

---
 srcpkgs/vlc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vlc/template b/srcpkgs/vlc/template
index abc5eeba01564..5f291b1b81e23 100644
--- a/srcpkgs/vlc/template
+++ b/srcpkgs/vlc/template
@@ -25,7 +25,7 @@ lib32disabled=yes
 hostmakedepends="automake libtool pkg-config flex gettext libgcrypt-devel
  live555-devel gettext-devel $(vopt_if lua lua52) $(vopt_if chromecast protobuf)"
 makedepends="
- avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg-devel freefont-ttf
+ avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg4-devel freefont-ttf
  gnutls-devel jack-devel liba52-devel libass-devel libbluray-devel
  libcdio-devel libdca-devel libdvbpsi-devel libdvdnav-devel libmad-devel
  libmatroska-devel libmodplug-devel libmpcdec-devel libmpeg2-devel

From b794ac0156de5107a68bff4f290cb78461968cfe Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:55 -0400
Subject: [PATCH 010/113] osg: revbump for ffmpeg4

---
 srcpkgs/osg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/osg/template b/srcpkgs/osg/template
index a9ebbd287933b..755793f7e11bf 100644
--- a/srcpkgs/osg/template
+++ b/srcpkgs/osg/template
@@ -8,7 +8,7 @@ build_helper="qemu"
 configure_args="-DLIB_POSTFIX="
 hostmakedepends="pkg-config xrandr"
 makedepends="MesaLib-devel gtkglext-devel libcurl-devel giflib-devel librsvg-devel
- jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg-devel xine-lib-devel
+ jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg4-devel xine-lib-devel
  SDL2-devel gst-plugins-base1-devel
  $(vopt_if openexr libopenexr-devel)
  $(vopt_if poppler poppler-glib-devel)

From c3f2e9aa4e3fe58b0bdd6e5d8eeaf3dd4bc500ac Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:13 -0400
Subject: [PATCH 011/113] xine-lib: revbump for ffmpeg4

---
 srcpkgs/xine-lib/template | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/xine-lib/template b/srcpkgs/xine-lib/template
index 3be4d08eac77a..ed6194c17d11e 100644
--- a/srcpkgs/xine-lib/template
+++ b/srcpkgs/xine-lib/template
@@ -1,14 +1,14 @@
 # Template file for 'xine-lib'
 pkgname=xine-lib
-version=1.2.12
-revision=3
+version=1.2.13
+revision=1
 build_style=gnu-configure
 configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
  --disable-oss"
 hostmakedepends="automake gettext-devel libtool pkg-config perl"
 makedepends="
  zlib-devel alsa-lib-devel libxcb-devel libSM-devel libXext-devel libXv-devel
- libXvMC-devel liba52-devel libmad-devel ffmpeg-devel pulseaudio-devel
+ libXvMC-devel liba52-devel libmad-devel ffmpeg4-devel pulseaudio-devel
  jack-devel samba-devel libflac-devel libmodplug-devel libmpcdec-devel
  speex-devel libtheora-devel libvorbis-devel libdca-devel faad2-devel
  libcdio-devel libbluray-devel aalib-devel libcaca-devel libXinerama-devel
@@ -19,7 +19,7 @@ license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="http://www.xine-project.org"
 changelog="https://sourceforge.net/projects/xine/files/xine-lib/${version}/README.txt/view"
 distfiles="${SOURCEFORGE_SITE}/xine/${pkgname}-${version}.tar.xz"
-checksum=d606270468e1540c2a89c0d7f5fdf11e17ecc0c2698cc0bcb1065ff26abee098
+checksum=5f10d6d718a4a51c17ed1b32b031d4f9b80b061e8276535b2be31e5ac4b75e6f
 
 case "$XBPS_TARGET_MACHINE" in
 	i686-musl)

From 838bce7048d25e95af4525756df4740292983b06 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 012/113] attract: revbump for ffmpeg4

---
 srcpkgs/attract/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/attract/template b/srcpkgs/attract/template
index 24017d2bacc24..e760bf0d18aec 100644
--- a/srcpkgs/attract/template
+++ b/srcpkgs/attract/template
@@ -6,7 +6,7 @@ build_style=gnu-makefile
 make_build_args="VERBOSE=1"
 make_use_env=yes
 hostmakedepends="pkg-config"
-makedepends="SFML-devel ffmpeg-devel fontconfig-devel glu-devel libarchive-devel
+makedepends="SFML-devel ffmpeg4-devel fontconfig-devel glu-devel libarchive-devel
  libcurl-devel libjpeg-turbo-devel xine-lib rapidjson libXrandr-devel"
 depends="git"
 short_desc="Attract-Mode is a graphical frontend for emulators"

From 2b99836227a4bb5035951445a8ae9c99c22e2fff Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 013/113] aubio: revbump for ffmpeg6

---
 srcpkgs/aubio/patches/ffmpeg5.patch | 25 +++++++++++++++++++++++++
 srcpkgs/aubio/template              |  2 +-
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/aubio/patches/ffmpeg5.patch

diff --git a/srcpkgs/aubio/patches/ffmpeg5.patch b/srcpkgs/aubio/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..aace41a6e6d9a
--- /dev/null
+++ b/srcpkgs/aubio/patches/ffmpeg5.patch
@@ -0,0 +1,25 @@
+From 8a05420e5dd8c7b8b2447f82dc919765876511b3 Mon Sep 17 00:00:00 2001
+From: Paul Brossier <piem@piem.org>
+Date: Tue, 25 Jan 2022 18:30:27 +0100
+Subject: [PATCH] [source_avcodec] define FF_API_LAVF_AVCTX for libavcodec >
+ 59, thx @berolinux (closes gh-353)
+
+---
+ src/io/source_avcodec.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/io/source_avcodec.c b/src/io/source_avcodec.c
+index e0ae93b5..1421bd9a 100644
+--- a/src/io/source_avcodec.c
++++ b/src/io/source_avcodec.c
+@@ -68,6 +68,10 @@
+ #define AUBIO_AVCODEC_MAX_BUFFER_SIZE AV_INPUT_BUFFER_MIN_SIZE
+ #endif
+ 
++#if LIBAVCODEC_VERSION_MAJOR >= 59
++#define FF_API_LAVF_AVCTX 1
++#endif
++
+ struct _aubio_source_avcodec_t {
+   uint_t hop_size;
+   uint_t samplerate;
diff --git a/srcpkgs/aubio/template b/srcpkgs/aubio/template
index ad1c4b2569917..7d875cc02541a 100644
--- a/srcpkgs/aubio/template
+++ b/srcpkgs/aubio/template
@@ -1,7 +1,7 @@
 # Template file for 'aubio'
 pkgname=aubio
 version=0.4.9
-revision=1
+revision=2
 build_style=waf3
 # XXX lash, pure and swig support.
 hostmakedepends="pkg-config txt2man"

From c83a728cb316353de2364723cfc34d7022935b87 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 014/113] audacious-plugins: revbump for ffmpeg6

---
 .../audacious-plugins/patches/ffmpeg5.patch   | 43 +++++++++++++++++++
 srcpkgs/audacious-plugins/template            |  2 +-
 2 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/audacious-plugins/patches/ffmpeg5.patch

diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg5.patch b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..4e5e34099d71c
--- /dev/null
+++ b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
@@ -0,0 +1,43 @@
+commit 298aa371c56c2f52c25a33d9bdec4918b11cebdc
+Author: tibequadorian <tibequadorian@posteo.de>
+Date:   Sat Mar 19 18:40:12 2022 +0100
+
+    audacious-plugins: rebuild against ffmpeg-5.0
+
+diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+new file mode 100644
+index 0000000000..617c11215b
+--- /dev/null
++++ b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+@@ -0,0 +1,31 @@
++From f60beb400eeb1e4778bbfd738bc4a4ccef3de539 Mon Sep 17 00:00:00 2001
++From: John Lindgren <john@jlindgren.net>
++Date: Sat, 5 Mar 2022 12:05:34 -0500
++Subject: [PATCH] Fix build with FFmpeg 5.0
++
++---
++ src/ffaudio/ffaudio-core.cc | 4 ++--
++ 1 file changed, 2 insertions(+), 2 deletions(-)
++
++diff --git a/src/ffaudio/ffaudio-core.cc b/src/ffaudio/ffaudio-core.cc
++index 16dc63e3a..a2b95fd6c 100644
++--- a/src/ffaudio/ffaudio-core.cc
+++++ b/src/ffaudio/ffaudio-core.cc
++@@ -274,7 +274,7 @@ static AVInputFormat * get_format_by_content (const char * name, VFSFile & file)
++         AVProbeData d = {name, buf, filled};
++         score = target;
++ 
++-        f = av_probe_input_format2 (& d, true, & score);
+++        f = (AVInputFormat *) av_probe_input_format2 (& d, true, & score);
++         if (f)
++             break;
++ 
++@@ -347,7 +347,7 @@ static bool find_codec (AVFormatContext * c, CodecInfo * cinfo)
++ #endif
++         if (stream && stream->codecpar && stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
++         {
++-            AVCodec * codec = avcodec_find_decoder (stream->codecpar->codec_id);
+++            AVCodec * codec = (AVCodec *) avcodec_find_decoder (stream->codecpar->codec_id);
++ 
++             if (codec)
++             {
diff --git a/srcpkgs/audacious-plugins/template b/srcpkgs/audacious-plugins/template
index 05e53a9adf78f..4b1968e03de78 100644
--- a/srcpkgs/audacious-plugins/template
+++ b/srcpkgs/audacious-plugins/template
@@ -2,7 +2,7 @@
 #Keep in sync with audacious!
 pkgname=audacious-plugins
 version=4.3.1
-revision=3
+revision=4
 build_style=meson
 configure_args="$(vopt_bool gtk3 gtk) $(vopt_bool gtk3)
  $(vopt_bool qt) $(vopt_bool qt qt6)"

From efd9282bd447ca77cc49000624b518d8d798c22c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 015/113] audacity: revbump for ffmpeg4

---
 srcpkgs/audacity/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/audacity/template b/srcpkgs/audacity/template
index 7b838119ab261..fb15f782ac1f7 100644
--- a/srcpkgs/audacity/template
+++ b/srcpkgs/audacity/template
@@ -1,7 +1,7 @@
 # Template file for 'audacity'
 pkgname=audacity
 version=3.4.2
-revision=1
+revision=2
 build_style=cmake
 build_helper="cmake-wxWidgets-gtk3 qemu"
 configure_args="-Daudacity_use_ffmpeg=loaded -Daudacity_lib_preference=system
@@ -12,7 +12,7 @@ configure_args="-Daudacity_use_ffmpeg=loaded -Daudacity_lib_preference=system
  -Daudacity_has_updates_check=OFF -DAUDACITY_BUILD_LEVEL=2"
 hostmakedepends="pkg-config gettext python3"
 makedepends="wxWidgets-gtk3-devel gtk+3-devel expat-devel lame-devel
- libsoxr-devel portaudio-devel sqlite-devel ffmpeg-devel
+ libsoxr-devel portaudio-devel sqlite-devel ffmpeg4-devel
  libid3tag-devel libmad-devel vamp-plugin-sdk-devel libogg-devel
  libvorbis-devel libflac-devel lilv-devel lv2 serd-devel sord-devel
  sratom-devel suil-devel portmidi-devel soundtouch-devel twolame-devel

From 16e89ca4b00930f269dfe28e8a9a8d126bbe2191 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 016/113] avidemux: revbump for ffmpeg6

---
 srcpkgs/avidemux/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/avidemux/template b/srcpkgs/avidemux/template
index 253a0243e2259..557285982d2b8 100644
--- a/srcpkgs/avidemux/template
+++ b/srcpkgs/avidemux/template
@@ -1,7 +1,7 @@
 # Template file for 'avidemux'
 pkgname=avidemux
 version=2.8.0
-revision=2
+revision=3
 # Can't be compiled for aarch64, arm* or mips*
 archs="x86_64* i686*"
 hostmakedepends="cmake pkg-config qt5-host-tools qt5-devel tar yasm"

From 1b491d84ce0483f47ba48273810fbeb4de5a8cfd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 017/113] blender: revbump for ffmpeg6

---
 srcpkgs/blender/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index 1dc61ec9d29d8..be35fac744876 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -9,8 +9,8 @@ configure_args="-DWITH_INSTALL_PORTABLE=OFF -DWITH_PYTHON_INSTALL=OFF
  -DWITH_JACK=ON -DWITH_CODEC_FFMPEG=ON -DWITH_CODEC_SNDFILE=ON -DWITH_OPENMP=ON
  -DWITH_FFTW3=ON -DWITH_MOD_OCEANSIM=ON -DWITH_CYCLES_EMBREE=OFF -DWITH_OPENCOLORIO=ON
  -DWITH_IMAGE_OPENEXR=ON -DWITH_IMAGE_OPENJPEG=ON -DWITH_OPENSUBDIV=ON
- -DWITH_OPENCOLLADA=ON -DWITH_SYSTEM_GLEW=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
- -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_LIBDECOR=ON
+ -DWITH_OPENCOLLADA=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
+ -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_WAYLAND_LIBDECOR=ON
  -DWITH_BUILDINFO=OFF -DPYTHON_VERSION=${py3_ver} -DPYTHON_LIBPATH=/usr/lib
  -DPYTHON_LIBRARY=python${py3_ver}${py3_abiver} -DPYTHON_INCLUDE_DIRS=/${py3_inc}
  -DWITH_SYSTEM_LZO=ON -DWITH_SYSTEM_EIGEN3=ON -DWITH_SYSTEM_FREETYPE=ON"

From 3148e13fb1b746823c2e34de8ac784dab43e31d5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 018/113] cantata: revbump for ffmpeg6

---
 srcpkgs/cantata/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cantata/template b/srcpkgs/cantata/template
index 4b417d80d5c2d..8a90aaa4c07a2 100644
--- a/srcpkgs/cantata/template
+++ b/srcpkgs/cantata/template
@@ -1,7 +1,7 @@
 # Template file for 'cantata'
 pkgname=cantata
 version=2.5.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools qt5-tools"
 makedepends="qt5-devel qt5-tools-devel qt5-svg-devel qt5-xmlpatterns-devel

From d52835c336ec33a6eadc0736d7e69ceb050a2d5a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 019/113] ccextractor: revbump for ffmpeg4

---
 srcpkgs/ccextractor/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ccextractor/template b/srcpkgs/ccextractor/template
index 84059ffd02398..3ca8ec45d6989 100644
--- a/srcpkgs/ccextractor/template
+++ b/srcpkgs/ccextractor/template
@@ -6,7 +6,7 @@ build_wrksrc="linux"
 build_style=gnu-configure
 configure_args="--enable-ocr --enable-hardsubx"
 hostmakedepends="automake pkg-config"
-makedepends="leptonica-devel tesseract-ocr-devel ffmpeg-devel"
+makedepends="leptonica-devel tesseract-ocr-devel ffmpeg4-devel"
 short_desc="Extract subtitles from video streams"
 maintainer="newbluemoon <blaumolch@mailbox.org>"
 license="GPL-2.0-or-later"

From b844e3339a6913e3c50e1e2546b3589dacc78772 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 020/113] chromaprint: revbump for ffmpeg6

---
 srcpkgs/chromaprint/patches/ffmpeg5.patch | 569 ++++++++++++++++++++++
 srcpkgs/chromaprint/template              |   2 +-
 2 files changed, 570 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromaprint/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromaprint/patches/ffmpeg5.patch b/srcpkgs/chromaprint/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..a9fd307a23c8a
--- /dev/null
+++ b/srcpkgs/chromaprint/patches/ffmpeg5.patch
@@ -0,0 +1,569 @@
+From 8ccad6937177b1b92e40ab8f4447ea27bac009a7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= <lalinsky@gmail.com>
+Date: Fri, 4 Nov 2022 21:47:38 +0100
+Subject: [PATCH] Use FFmpeg 5.x (#120)
+
+* Use FFmpeg 5.1.2 for CI builds
+
+* Build on Ubuntu 20.04
+
+* Upgrade code to FFmpeg 5.x APIs
+
+* Only set FFmpeg include dirs if building tools
+
+* No longer needed
+
+* Use ubuntu 20.04
+---
+ .github/workflows/build.yml                   |   6 +-
+ CMakeLists.txt                                |  16 --
+ package/build.sh                              |   4 +-
+ src/audio/ffmpeg_audio_processor.h            |   2 -
+ src/audio/ffmpeg_audio_processor_avresample.h |  72 -------
+ src/audio/ffmpeg_audio_processor_swresample.h |  18 +-
+ src/audio/ffmpeg_audio_reader.h               | 197 +++++++++---------
+ tests/CMakeLists.txt                          |   6 +
+ 8 files changed, 122 insertions(+), 199 deletions(-)
+ delete mode 100644 src/audio/ffmpeg_audio_processor_avresample.h
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index f8d6a32..4da2405 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -84,9 +84,6 @@ find_package(FFmpeg)
+ if(FFMPEG_LIBRARIES)
+ 	cmake_push_check_state(RESET)
+ 	set(CMAKE_REQUIRED_LIBRARIES ${FFMPEG_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -lm)
+-	check_function_exists(av_packet_unref HAVE_AV_PACKET_UNREF)
+-	check_function_exists(av_frame_alloc HAVE_AV_FRAME_ALLOC)
+-	check_function_exists(av_frame_free HAVE_AV_FRAME_FREE)
+ 	cmake_pop_check_state()
+ endif()
+
+@@ -163,14 +160,11 @@ message(STATUS "Using ${FFT_LIB} for FFT calculations")
+ if(NOT AUDIO_PROCESSOR_LIB)
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+ 		set(AUDIO_PROCESSOR_LIB "swresample")
+-	elseif(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(AUDIO_PROCESSOR_LIB "avresample")
+ 	endif()
+ endif()
+
+ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE OFF)
+ 		set(USE_SWRESAMPLE ON)
+ 		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBSWRESAMPLE_LIBRARIES})
+ 		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBSWRESAMPLE_INCLUDE_DIRS})
+@@ -178,16 +172,6 @@ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+ 	endif()
+ 	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+-elseif(AUDIO_PROCESSOR_LIB STREQUAL "avresample")
+-	if(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE ON)
+-		set(USE_SWRESAMPLE OFF)
+-		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBAVRESAMPLE_LIBRARIES})
+-		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBAVRESAMPLE_INCLUDE_DIRS})
+-	else()
+-		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+-	endif()
+-	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+ else()
+ 	message(STATUS "Building without audio conversion support, please install FFmpeg with libswresample")
+ endif()
+diff --git a/package/build.sh b/package/build.sh
+index da631ae..b41d36e 100755
+--- a/package/build.sh
++++ b/package/build.sh
+@@ -7,8 +7,8 @@ set -eux
+
+ BASE_DIR=$(cd $(dirname $0)/.. && pwd)
+
+-FFMPEG_VERSION=4.4.1
+-FFMPEG_BUILD_TAG=v4.4.1-1
++FFMPEG_VERSION=5.1.2
++FFMPEG_BUILD_TAG=v${FFMPEG_VERSION}-1
+
+ TMP_BUILD_DIR=$BASE_DIR/$(mktemp -d build.XXXXXXXX)
+ trap 'rm -rf $TMP_BUILD_DIR' EXIT
+diff --git a/src/audio/ffmpeg_audio_processor.h b/src/audio/ffmpeg_audio_processor.h
+index 7628fc7..39f4f6d 100644
+--- a/src/audio/ffmpeg_audio_processor.h
++++ b/src/audio/ffmpeg_audio_processor.h
+@@ -10,8 +10,6 @@
+
+ #if defined(USE_SWRESAMPLE)
+ #include "audio/ffmpeg_audio_processor_swresample.h"
+-#elif defined(USE_AVRESAMPLE)
+-#include "audio/ffmpeg_audio_processor_avresample.h"
+ #else
+ #error "no audio processing library"
+ #endif
+diff --git a/src/audio/ffmpeg_audio_processor_avresample.h b/src/audio/ffmpeg_audio_processor_avresample.h
+deleted file mode 100644
+index bd85f92..0000000
+--- a/src/audio/ffmpeg_audio_processor_avresample.h
++++ /dev/null
+@@ -1,72 +0,0 @@
+-// Copyright (C) 2016  Lukas Lalinsky
+-// Distributed under the MIT license, see the LICENSE file for details.
+-
+-#ifndef CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-#define CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-
+-extern "C" {
+-#include <libavresample/avresample.h>
+-}
+-
+-namespace chromaprint {
+-
+-class FFmpegAudioProcessor {
+-public:
+-	FFmpegAudioProcessor() {
+-		m_resample_ctx = avresample_alloc_context();
+-	}
+-
+-	~FFmpegAudioProcessor() {
+-		avresample_free(&m_resample_ctx);
+-	}
+-
+-	void SetCompatibleMode() {
+-		av_opt_set_int(m_resample_ctx, "filter_size", 16, 0);
+-		av_opt_set_int(m_resample_ctx, "phase_shift", 8, 0);
+-		av_opt_set_int(m_resample_ctx, "linear_interp", 1, 0);
+-		av_opt_set_double(m_resample_ctx, "cutoff", 0.8, 0);
+-	}
+-
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "in_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_rate", sample_rate, 0);
+-	}
+-
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "out_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_rate, 0);
+-	}
+-
+-	int Init() {
+-		return avresample_open(m_resample_ctx);
+-	}
+-
+-	int Convert(uint8_t **out, int out_count, const uint8_t **in, int in_count) {
+-		return avresample_convert(m_resample_ctx, out, 0, out_count, (uint8_t **) in, 0, in_count);
+-	}
+-
+-	int Flush(uint8_t **out, int out_count) {
+-		return avresample_read(m_resample_ctx, out, out_count);
+-	}
+-
+-private:
+-	AVAudioResampleContext *m_resample_ctx = nullptr;
+-};
+-
+-}; // namespace chromaprint
+-
+-#endif
+diff --git a/src/audio/ffmpeg_audio_processor_swresample.h b/src/audio/ffmpeg_audio_processor_swresample.h
+index b86266b..b1d4bea 100644
+--- a/src/audio/ffmpeg_audio_processor_swresample.h
++++ b/src/audio/ffmpeg_audio_processor_swresample.h
+@@ -28,30 +28,28 @@ public:
+ 		av_opt_set_double(m_swr_ctx, "cutoff", 0.8, 0);
+ 	}
+
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "icl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "ich", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetInputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "in_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "isf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "in_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "isr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "in_sample_rate", sample_rate, 0);
+ 	}
+
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "ocl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "och", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetOutputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "out_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "osf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "out_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "osr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "out_sample_rate", sample_rate, 0);
+ 	}
+
+ 	int Init() {
+diff --git a/src/audio/ffmpeg_audio_reader.h b/src/audio/ffmpeg_audio_reader.h
+index 5550164..1c6b346 100644
+--- a/src/audio/ffmpeg_audio_reader.h
++++ b/src/audio/ffmpeg_audio_reader.h
+@@ -62,7 +62,7 @@ public:
+ 	bool Read(const int16_t **data, size_t *size);
+
+ 	bool IsOpen() const { return m_opened; }
+-	bool IsFinished() const { return m_finished && !m_got_frame; }
++	bool IsFinished() const { return !m_has_more_packets && !m_has_more_frames; }
+
+ 	std::string GetError() const { return m_error; }
+ 	int GetErrorCode() const { return m_error_code; }
+@@ -74,20 +74,19 @@ private:
+ 	uint8_t *m_convert_buffer[1] = { nullptr };
+ 	int m_convert_buffer_nb_samples = 0;
+
+-	AVInputFormat *m_input_fmt = nullptr;
++	const AVInputFormat *m_input_fmt = nullptr;
+ 	AVDictionary *m_input_opts = nullptr;
+
+ 	AVFormatContext *m_format_ctx = nullptr;
+ 	AVCodecContext *m_codec_ctx = nullptr;
+-	AVFrame *m_frame = nullptr;
+ 	int m_stream_index = -1;
+ 	std::string m_error;
+ 	int m_error_code = 0;
+-	bool m_finished = false;
+ 	bool m_opened = false;
+-	int m_got_frame = 0;
+-	AVPacket m_packet;
+-	AVPacket m_packet0;
++	bool m_has_more_packets = true;
++	bool m_has_more_frames = true;
++	AVPacket *m_packet = nullptr;
++	AVFrame *m_frame = nullptr;
+
+ 	int m_output_sample_rate = 0;
+ 	int m_output_channels = 0;
+@@ -98,19 +97,12 @@ private:
+
+ inline FFmpegAudioReader::FFmpegAudioReader() {
+ 	av_log_set_level(AV_LOG_QUIET);
+-
+-	av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
+ }
+
+ inline FFmpegAudioReader::~FFmpegAudioReader() {
+ 	Close();
+ 	av_dict_free(&m_input_opts);
+ 	av_freep(&m_convert_buffer[0]);
+-	av_packet_unref(&m_packet0);
+ }
+
+ inline bool FFmpegAudioReader::SetInputFormat(const char *name) {
+@@ -135,11 +127,10 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ 	Close();
+
+-    av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
++	m_packet = av_packet_alloc();
++	if (!m_packet) {
++		return false;
++	}
+
+ 	ret = avformat_open_input(&m_format_ctx, file_name.c_str(), m_input_fmt, &m_input_opts);
+ 	if (ret < 0) {
+@@ -153,26 +144,31 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		return false;
+ 	}
+
+-	AVCodec *codec;
++	const AVCodec *codec;
+ 	ret = av_find_best_stream(m_format_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &codec, 0);
+ 	if (ret < 0) {
+ 		SetError("Could not find any audio stream in the file", ret);
+ 		return false;
+ 	}
+ 	m_stream_index = ret;
++	auto stream = m_format_ctx->streams[m_stream_index];
+
+-	m_codec_ctx = m_format_ctx->streams[m_stream_index]->codec;
++	m_codec_ctx = avcodec_alloc_context3(codec);
+ 	m_codec_ctx->request_sample_fmt = AV_SAMPLE_FMT_S16;
+
++	ret = avcodec_parameters_to_context(m_codec_ctx, stream->codecpar);
++	if (ret < 0) {
++		SetError("Could not copy the stream parameters", ret);
++		return false;
++	}
++
+ 	ret = avcodec_open2(m_codec_ctx, codec, nullptr);
+ 	if (ret < 0) {
+ 		SetError("Could not open the codec", ret);
+ 		return false;
+ 	}
+
+-	if (!m_codec_ctx->channel_layout) {
+-		m_codec_ctx->channel_layout = av_get_default_channel_layout(m_codec_ctx->channels);
+-	}
++	av_dump_format(m_format_ctx, 0, "foo", 0);
+
+ 	m_frame = av_frame_alloc();
+ 	if (!m_frame) {
+@@ -183,19 +179,23 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		m_output_sample_rate = m_codec_ctx->sample_rate;
+ 	}
+
+-	if (!m_output_channels) {
+-		m_output_channels = m_codec_ctx->channels;
++	AVChannelLayout output_channel_layout;
++	if (m_output_channels) {
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
++	} else {
++		m_output_channels = m_codec_ctx->ch_layout.nb_channels;
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
+ 	}
+
+-	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
++	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->ch_layout.nb_channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
+ 		m_converter.reset(new FFmpegAudioProcessor());
+ 		m_converter->SetCompatibleMode();
+ 		m_converter->SetInputSampleFormat(m_codec_ctx->sample_fmt);
+ 		m_converter->SetInputSampleRate(m_codec_ctx->sample_rate);
+-		m_converter->SetInputChannelLayout(m_codec_ctx->channel_layout);
++		m_converter->SetInputChannelLayout(&(m_codec_ctx->ch_layout));
+ 		m_converter->SetOutputSampleFormat(AV_SAMPLE_FMT_S16);
+ 		m_converter->SetOutputSampleRate(m_output_sample_rate);
+-		m_converter->SetOutputChannelLayout(av_get_default_channel_layout(m_output_channels));
++		m_converter->SetOutputChannelLayout(&output_channel_layout);
+ 		auto ret = m_converter->Init();
+ 		if (ret != 0) {
+ 			SetError("Could not create an audio converter instance", ret);
+@@ -203,10 +203,11 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		}
+ 	}
+
++	av_channel_layout_uninit(&output_channel_layout);
++
+ 	m_opened = true;
+-	m_finished = false;
+-	m_got_frame = 0;
+-	m_nb_packets = 0;
++	m_has_more_packets = true;
++	m_has_more_frames = true;
+ 	m_decode_error = 0;
+
+ 	return true;
+@@ -214,6 +215,7 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ inline void FFmpegAudioReader::Close() {
+ 	av_frame_free(&m_frame);
++	av_packet_free(&m_packet);
+
+ 	m_stream_index = -1;
+
+@@ -252,91 +254,98 @@ inline bool FFmpegAudioReader::Read(const int16_t **data, size_t *size) {
+ 		return false;
+ 	}
+
++	*data = nullptr;
++	*size = 0;
++
+ 	int ret;
++	bool needs_packet = false;
+ 	while (true) {
+-		while (m_packet.size <= 0) {
+-			av_packet_unref(&m_packet0);
+-			av_init_packet(&m_packet);
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			ret = av_read_frame(m_format_ctx, &m_packet);
++		while (needs_packet && m_packet->size == 0) {
++			ret = av_read_frame(m_format_ctx, m_packet);
+ 			if (ret < 0) {
+ 				if (ret == AVERROR_EOF) {
+-					m_finished = true;
++					needs_packet = false;
++					m_has_more_packets = false;
+ 					break;
+-				} else {
++				}
++				SetError("Error reading from the audio source", ret);
++				return false;
++			}
++			if (m_packet->stream_index == m_stream_index) {
++				needs_packet = false;
++			} else {
++				av_packet_unref(m_packet);
++			}
++		}
++
++		if (m_packet->size != 0) {
++			ret = avcodec_send_packet(m_codec_ctx, m_packet);
++			if (ret < 0) {
++				if (ret != AVERROR(EAGAIN)) {
+ 					SetError("Error reading from the audio source", ret);
+ 					return false;
+ 				}
+-			}
+-			m_packet0 = m_packet;
+-			if (m_packet.stream_index != m_stream_index) {
+-				m_packet.data = nullptr;
+-				m_packet.size = 0;
+ 			} else {
+-				m_nb_packets++;
++				av_packet_unref(m_packet);
+ 			}
+ 		}
+
+-		ret = avcodec_decode_audio4(m_codec_ctx, m_frame, &m_got_frame, &m_packet);
++		ret = avcodec_receive_frame(m_codec_ctx, m_frame);
+ 		if (ret < 0) {
+-			if (m_decode_error) {
+-				SetError("Error decoding audio frame", m_decode_error);
+-				return false;
++			if (ret == AVERROR_EOF) {
++				m_has_more_frames = false;
++			} else if (ret == AVERROR(EAGAIN)) {
++				if (m_has_more_packets) {
++					needs_packet = true;
++					continue;
++				} else {
++					m_has_more_frames = false;
++				}
+ 			}
+-			m_decode_error = ret;
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			continue;
++			SetError("Error decoding the audio source", ret);
++			return false;
+ 		}
+
+-		break;
+-	}
+-
+-	m_decode_error = 0;
+-
+-	const int decoded = std::min(ret, m_packet.size);
+-	m_packet.data += decoded;
+-	m_packet.size -= decoded;
+-
+-	if (m_got_frame) {
+-		if (m_converter) {
+-			if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
+-				int linsize;
+-				av_freep(&m_convert_buffer[0]);
+-				m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
+-				ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
+-				if (ret < 0) {
+-					SetError("Couldn't allocate audio converter buffer", ret);
++		if (m_frame->nb_samples > 0) {
++			if (m_converter) {
++				if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
++					int linsize;
++					av_freep(&m_convert_buffer[0]);
++					m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
++					ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->ch_layout.nb_channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
++					if (ret < 0) {
++						SetError("Couldn't allocate audio converter buffer", ret);
++						return false;
++					}
++				}
++				auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
++				if (nb_samples < 0) {
++					SetError("Couldn't convert audio", ret);
+ 					return false;
+ 				}
+-			}
+-			auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			}
+-			*data = (const int16_t *) m_convert_buffer[0];
+-			*size = nb_samples;
+-		} else {
+-			*data = (const int16_t *) m_frame->data[0];
+-			*size = m_frame->nb_samples;
+-		}
+-	} else {
+-		if (m_finished && m_converter) {
+-			auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			} else if (nb_samples > 0) {
+-				m_got_frame = 1;
+ 				*data = (const int16_t *) m_convert_buffer[0];
+ 				*size = nb_samples;
++			} else {
++				*data = (const int16_t *) m_frame->data[0];
++				*size = m_frame->nb_samples;
++			}
++		} else {
++			if (m_converter) {
++				if (IsFinished()) {
++					auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
++					if (nb_samples < 0) {
++						SetError("Couldn't convert audio", ret);
++						return false;
++					} else if (nb_samples > 0) {
++						*data = (const int16_t *) m_convert_buffer[0];
++						*size = nb_samples;
++					}
++				}
+ 			}
+ 		}
+-	}
+
+-	return true;
++		return true;
++	}
+ }
+
+ inline void FFmpegAudioReader::SetError(const char *message, int errnum) {
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index a2b517b..123e643 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -38,6 +38,12 @@ set(SRCS
+
+ if(BUILD_TOOLS)
+ 	set(SRCS ${SRCS} ../src/audio/ffmpeg_audio_reader_test.cpp)
++    include_directories(
++        ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}
++        ${AUDIO_PROCESSOR_INCLUDE_DIRS}
++    )
+ 	link_libraries(fpcalc_libs)
+ endif()
+
+-- 
+2.38.1
+
+
diff --git a/srcpkgs/chromaprint/template b/srcpkgs/chromaprint/template
index 7ef7838949f3a..1f7bbc70a22c8 100644
--- a/srcpkgs/chromaprint/template
+++ b/srcpkgs/chromaprint/template
@@ -1,7 +1,7 @@
 # Template file for 'chromaprint'
 pkgname=chromaprint
 version=1.5.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DBUILD_TOOLS=ON"
 make_check_target="check"

From 2d3f6395ac10dd7fb462e1d18b0bbdb70a3f36f2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 021/113] chromium: revbump for ffmpeg6

---
 .../patches/chromium-119-ffmpeg-4.4.patch     | 20 --------
 srcpkgs/chromium/patches/ffmpeg5.patch        | 47 +++++++++++++++++++
 srcpkgs/chromium/template                     |  2 +-
 3 files changed, 48 insertions(+), 21 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch
 create mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch b/srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch
deleted file mode 100644
index 04d04b166ba37..0000000000000
--- a/srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch
+++ /dev/null
@@ -1,20 +0,0 @@
---- a/media/filters/ffmpeg_demuxer.cc.orig
-+++ b/media/filters/ffmpeg_demuxer.cc
-@@ -390,7 +390,7 @@
- 
-   scoped_refptr<DecoderBuffer> buffer;
- 
--    size_t side_data_size = 0;
-+    int side_data_size = 0;
-     uint8_t* side_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
- 
-@@ -453,7 +453,7 @@
-                                        packet->size - data_offset);
-     }
- 
--    size_t skip_samples_size = 0;
-+    int skip_samples_size = 0;
-     const uint32_t* skip_samples_ptr =
-         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
-             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..24e2da38e34ca
--- /dev/null
+++ b/srcpkgs/chromium/patches/ffmpeg5.patch
@@ -0,0 +1,47 @@
+--- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
++++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
+@@ -92,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+-  if (stream->start_time != kNoFFmpegTimestamp)
++  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -1597,7 +1585,7 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+@@ -1618,7 +1606,7 @@
+     if (stream->type() != DemuxerStream::VIDEO)
+       continue;
+ 
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+ 
+     if (!stream->IsEnabled())
diff --git a/srcpkgs/chromium/template b/srcpkgs/chromium/template
index 5613fa3813822..cd386c8a84ae6 100644
--- a/srcpkgs/chromium/template
+++ b/srcpkgs/chromium/template
@@ -2,7 +2,7 @@
 pkgname=chromium
 # See https://chromiumdash.appspot.com/releases?platform=Linux for the latest version
 version=120.0.6099.129
-revision=1
+revision=2
 archs="i686* x86_64* aarch64* armv7l*"
 hostmakedepends="
  $(vopt_if clang "clang lld llvm15")

From c61a36bf2a02213779c858a6cec01409ad214ace Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 022/113] cmus: revbump for ffmpeg6

---
 srcpkgs/chromium/patches/ffmpeg5.patch | 47 --------------------------
 srcpkgs/cmus/patches/ffmpeg6.patch     | 12 +++++++
 srcpkgs/cmus/template                  |  2 +-
 3 files changed, 13 insertions(+), 48 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch
 create mode 100644 srcpkgs/cmus/patches/ffmpeg6.patch

diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
deleted file mode 100644
index 24e2da38e34ca..0000000000000
--- a/srcpkgs/chromium/patches/ffmpeg5.patch
+++ /dev/null
@@ -1,47 +0,0 @@
---- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
-+++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
-@@ -92,24 +92,12 @@
- 
- static base::TimeDelta ExtractStartTime(AVStream* stream) {
-   // The default start time is zero.
--  base::TimeDelta start_time;
-+  base::TimeDelta start_time = kNoTimestamp;
- 
-   // First try to use  the |start_time| value as is.
--  if (stream->start_time != kNoFFmpegTimestamp)
-+  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
-     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
- 
--  // Next try to use the first DTS value, for codecs where we know PTS == DTS
--  // (excludes all H26x codecs). The start time must be returned in PTS.
--  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
--      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
--      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
--      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
--    const base::TimeDelta first_pts =
--        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
--    if (first_pts < start_time)
--      start_time = first_pts;
--  }
--
-   return start_time;
- }
- 
-@@ -1597,7 +1585,7 @@
-   for (const auto& stream : streams_) {
-     if (!stream || stream->IsEnabled() != enabled)
-       continue;
--    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
-+    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
-       continue;
-     if (!lowest_start_time_stream ||
-         stream->start_time() < lowest_start_time_stream->start_time()) {
-@@ -1618,7 +1606,7 @@
-     if (stream->type() != DemuxerStream::VIDEO)
-       continue;
- 
--    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
-+    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
-       continue;
- 
-     if (!stream->IsEnabled())
diff --git a/srcpkgs/cmus/patches/ffmpeg6.patch b/srcpkgs/cmus/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..ffa95ab811101
--- /dev/null
+++ b/srcpkgs/cmus/patches/ffmpeg6.patch
@@ -0,0 +1,12 @@
+--- a/ip/ffmpeg.c
++++ b/ip/ffmpeg.c
+@@ -202,9 +202,6 @@ static int ffmpeg_open(struct input_plugin_data *ip_data)
+ 			break;
+ 		}
+ 
+-		if (codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+-			cc->flags |= AV_CODEC_FLAG_TRUNCATED;
+-
+ 		if (avcodec_open2(cc, codec, NULL) < 0) {
+ 			d_print("could not open codec: %d, %s\n", cc->codec_id, avcodec_get_name(cc->codec_id));
+ 			err = -IP_ERROR_UNSUPPORTED_FILE_TYPE;
diff --git a/srcpkgs/cmus/template b/srcpkgs/cmus/template
index 0d1436744f1b2..a6e4b4fa86cb8 100644
--- a/srcpkgs/cmus/template
+++ b/srcpkgs/cmus/template
@@ -1,7 +1,7 @@
 # Template file for 'cmus'
 pkgname=cmus
 version=2.10.0
-revision=3
+revision=4
 build_style=configure
 configure_args="prefix=/usr LD=$CC"
 hostmakedepends="pkg-config"

From 25f3874186b83b72e66835cfebe32997a2261335 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 023/113] cyanrip: revbump for ffmpeg6

---
 srcpkgs/cyanrip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cyanrip/template b/srcpkgs/cyanrip/template
index 9796e3461601a..5db30e020d17e 100644
--- a/srcpkgs/cyanrip/template
+++ b/srcpkgs/cyanrip/template
@@ -1,7 +1,7 @@
 # Template file for 'cyanrip'
 pkgname=cyanrip
 version=0.9.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config"
 makedepends="ffmpeg-devel libcdio-devel libcdio-paranoia-devel libcurl-devel libmusicbrainz5-devel"

From f9b5cdf1ad90d5b93b7df4b09427c742d455971f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 024/113] deadbeef: revbump for ffmpeg4

---
 srcpkgs/deadbeef/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/deadbeef/template b/srcpkgs/deadbeef/template
index f5f4bf24b8cb6..7b47e615cd48e 100644
--- a/srcpkgs/deadbeef/template
+++ b/srcpkgs/deadbeef/template
@@ -1,14 +1,14 @@
 # Template file for 'deadbeef'
 pkgname=deadbeef
 version=1.8.8
-revision=3
+revision=4
 create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-oss --disable-lfm --disable-notify --disable-gtk2"
 hostmakedepends="automake libtool gettext gettext-devel intltool pkg-config
  yasm clang glib-devel"
 makedepends="
- alsa-lib-devel dbus-devel faad2-devel ffmpeg-devel gtk+3-devel imlib2-devel
+ alsa-lib-devel dbus-devel faad2-devel ffmpeg4-devel gtk+3-devel imlib2-devel
  jansson-devel libcddb-devel libcdio-devel libcurl-devel libflac-devel
  libmad-devel libpng-devel libsamplerate-devel libsndfile-devel libvorbis-devel
  libzip-devel mpg123-devel opusfile-devel pulseaudio-devel wavpack-devel"

From a785f5636bb375c154f323696d63ae04de467597 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 025/113] droidcam-obs-plugin: revbump for ffmpeg6

---
 srcpkgs/droidcam-obs-plugin/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam-obs-plugin/template b/srcpkgs/droidcam-obs-plugin/template
index fc9c9bf6b9d54..fb0480754df4d 100644
--- a/srcpkgs/droidcam-obs-plugin/template
+++ b/srcpkgs/droidcam-obs-plugin/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam-obs-plugin'
 pkgname=droidcam-obs-plugin
 version=2.0.1
-revision=1
+revision=2
 build_style=gnu-makefile
 make_use_env=yes
 make_build_args="ALLOW_STATIC=no"

From 2d73e08d7b427a0346d5d9641232adcca43d5389 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 026/113] droidcam: revbump for ffmpeg6

---
 srcpkgs/droidcam/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam/template b/srcpkgs/droidcam/template
index 1c3f1b8b1fc67..32a9220b79a4d 100644
--- a/srcpkgs/droidcam/template
+++ b/srcpkgs/droidcam/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam'
 pkgname=droidcam
 version=1.8.2
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="USBMUXD=-lusbmuxd-2.0 JPEG=-lturbojpeg"
 hostmakedepends="pkg-config"

From 1f3b53838c8834a69b3f9377b4626a6698a054dd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 027/113] ffmpegthumbnailer: revbump for ffmpeg6

---
 .../ffmpegthumbnailer/patches/ffmpeg6.patch   | 202 ++++++++++++++++++
 srcpkgs/ffmpegthumbnailer/template            |   6 +-
 2 files changed, 205 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch

diff --git a/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..363ff35a28419
--- /dev/null
+++ b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
@@ -0,0 +1,202 @@
+--- a/libffmpegthumbnailer/moviedecoder.cpp	2017-11-21 14:06:57.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.cpp	2023-05-05 13:14:47.946560668 -0400
+@@ -41,11 +41,6 @@
+ namespace ffmpegthumbnailer
+ {
+ 
+-struct SilenceLogLevel
+-{
+-    SilenceLogLevel() { av_log_set_level(AV_LOG_QUIET); }
+-};
+-
+ MovieDecoder::MovieDecoder(AVFormatContext* pavContext)
+ : m_VideoStream(-1)
+ , m_pFormatContext(pavContext)
+@@ -70,8 +65,6 @@
+ 
+ void MovieDecoder::initialize(const string& filename, bool preferEmbeddedMetadata)
+ {
+-    av_register_all();
+-    avcodec_register_all();
+     avformat_network_init();
+ 
+     string inputFile = filename == "-" ? "pipe:" : filename;
+@@ -97,8 +90,7 @@
+ {
+     if (m_pVideoCodecContext)
+     {
+-        avcodec_close(m_pVideoCodecContext);
+-        m_pVideoCodecContext = nullptr;
++        avcodec_free_context(&m_pVideoCodecContext);
+     }
+ 
+     if ((!m_FormatContextWasGiven) && m_pFormatContext)
+@@ -152,10 +144,10 @@
+     for (unsigned int i = 0; i < m_pFormatContext->nb_streams; ++i)
+     {
+         AVStream *stream = m_pFormatContext->streams[i];
+-        auto ctx = m_pFormatContext->streams[i]->codec;
+-        if (ctx->codec_type == AVMEDIA_TYPE_VIDEO)
++        auto par = m_pFormatContext->streams[i]->codecpar;
++        if (par->codec_type == AVMEDIA_TYPE_VIDEO)
+         {
+-            if (!preferEmbeddedMetadata || !isStillImageCodec(ctx->codec_id))
++            if (!preferEmbeddedMetadata || !isStillImageCodec(par->codec_id))
+             {
+                 videoStreams.push_back(i);
+                 continue;
+@@ -203,8 +195,7 @@
+     }
+ 
+     m_pVideoStream = m_pFormatContext->streams[m_VideoStream];
+-    m_pVideoCodecContext = m_pVideoStream->codec;
+-    m_pVideoCodec = avcodec_find_decoder(m_pVideoCodecContext->codec_id);
++    m_pVideoCodec = avcodec_find_decoder(m_pVideoStream->codecpar->codec_id);
+ 
+     if (m_pVideoCodec == nullptr)
+     {
+@@ -214,6 +205,20 @@
+         throw logic_error("Video Codec not found");
+     }
+ 
++    m_pVideoCodecContext = avcodec_alloc_context3(m_pVideoCodec);
++
++    if (m_pVideoCodecContext == nullptr)
++    {
++        destroy();
++        throw logic_error("Could not allocate video codec context");
++    }
++
++    if (avcodec_parameters_to_context(m_pVideoCodecContext, m_pVideoStream->codecpar) < 0)
++    {
++        destroy();
++        throw logic_error("Could not configure video codec context");
++    }
++
+     m_pVideoCodecContext->workaround_bugs = 1;
+ 
+     if (avcodec_open2(m_pVideoCodecContext, m_pVideoCodec, nullptr) < 0)
+@@ -386,13 +391,6 @@
+ 
+ void MovieDecoder::initializeFilterGraph(const AVRational& timeBase, const std::string& size, bool maintainAspectRatio)
+ {
+-    static const AVPixelFormat pixelFormats[] = { AV_PIX_FMT_RGB24, AV_PIX_FMT_NONE };
+-
+-    auto del = [] (AVBufferSinkParams* p) { av_freep(p); };
+-    std::unique_ptr<AVBufferSinkParams, decltype(del)> buffersinkParams(av_buffersink_params_alloc(), del);
+-
+-    avfilter_register_all();
+-
+     m_pFilterGraph = avfilter_graph_alloc();
+     assert(m_pFilterGraph);
+ 
+@@ -404,10 +402,8 @@
+ 
+     checkRc(avfilter_graph_create_filter(&m_pFilterSource, avfilter_get_by_name("buffer"), "thumb_buffer", ss.str().c_str(), nullptr, m_pFilterGraph),
+             "Failed to create filter source");
+-    buffersinkParams->pixel_fmts = pixelFormats;
+-    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, buffersinkParams.get(), m_pFilterGraph),
++    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, nullptr, m_pFilterGraph),
+             "Failed to create filter sink");
+-    buffersinkParams.release();
+ 
+     AVFilterContext* yadifFilter = nullptr;
+     if (m_pFrame->interlaced_frame != 0)
+@@ -500,15 +496,15 @@
+     }
+ 
+     checkRc(av_seek_frame(m_pFormatContext, -1, timestamp, 0), "Seeking in video failed");
+-    avcodec_flush_buffers(m_pFormatContext->streams[m_VideoStream]->codec);
++    avcodec_flush_buffers(m_pVideoCodecContext);
+ 
+     int keyFrameAttempts = 0;
+-    bool gotFrame = 0;
++    bool gotFrame;
+ 
+     do
+     {
+         int count = 0;
+-        gotFrame = 0;
++        gotFrame = false;
+ 
+         while (!gotFrame && count < 20)
+         {
+@@ -552,17 +548,33 @@
+         return false;
+     }
+ 
+-    av_frame_unref(m_pFrame);
+-
+-    int frameFinished;
++    int rc = avcodec_send_packet(m_pVideoCodecContext, m_pPacket);
++    if(rc == AVERROR(EAGAIN))
++    {
++        rc = 0;
++    }
+ 
+-    int bytesDecoded = avcodec_decode_video2(m_pVideoCodecContext, m_pFrame, &frameFinished, m_pPacket);
+-    if (bytesDecoded < 0)
++    if(rc == AVERROR_EOF)
++    {
++        return false;
++    }
++    else if(rc < 0)
+     {
+-        throw logic_error("Failed to decode video frame: bytesDecoded < 0");
++        throw logic_error("Failed to decode video frame: avcodec_send_packet() < 0");
+     }
+ 
+-    return frameFinished > 0;
++    rc = avcodec_receive_frame(m_pVideoCodecContext, m_pFrame);
++    switch(rc)
++    {
++        case 0:
++            return true;
++
++        case AVERROR(EAGAIN):
++            return false;
++
++        default:
++            throw logic_error("Failed to decode video frame: avcodec_receive_frame() < 0");
++    }
+ }
+ 
+ bool MovieDecoder::getVideoPacket()
+@@ -570,8 +582,6 @@
+     bool framesAvailable = true;
+     bool frameDecoded = false;
+ 
+-    int attempts = 0;
+-
+     if (m_pPacket)
+     {
+         av_packet_unref(m_pPacket);
+@@ -580,6 +590,7 @@
+ 
+     m_pPacket = new AVPacket();
+ 
++
+     while (framesAvailable && !frameDecoded)
+     {
+         framesAvailable = av_read_frame(m_pFormatContext, m_pPacket) >= 0;
+@@ -644,7 +655,7 @@
+ 
+ int32_t MovieDecoder::getStreamRotation()
+ {
+-    int32_t* matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
++    auto matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
+     if (matrix)
+     {
+         auto angle = lround(av_display_rotation_get(matrix));
+
+--- a/libffmpegthumbnailer/moviedecoder.h	2017-11-12 04:23:38.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.h	2023-05-05 13:26:07.095529911 -0400
+@@ -78,7 +78,7 @@
+     int                     m_VideoStream;
+     AVFormatContext*        m_pFormatContext;
+     AVCodecContext*         m_pVideoCodecContext;
+-    AVCodec*                m_pVideoCodec;
++    const AVCodec*          m_pVideoCodec;
+     AVFilterGraph*          m_pFilterGraph;
+     AVFilterContext*        m_pFilterSource;
+     AVFilterContext*        m_pFilterSink;
diff --git a/srcpkgs/ffmpegthumbnailer/template b/srcpkgs/ffmpegthumbnailer/template
index 039eea7622b39..35d546018d12a 100644
--- a/srcpkgs/ffmpegthumbnailer/template
+++ b/srcpkgs/ffmpegthumbnailer/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbnailer'
 pkgname=ffmpegthumbnailer
 version=2.2.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libpng-devel libjpeg-turbo-devel ffmpeg-devel"
@@ -9,8 +9,8 @@ depends="ffmpeg"
 short_desc="Lightweight video thumbnailer"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
-homepage="https://github.com/dirkvdb/${pkgname}"
-distfiles="${homepage}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
+homepage="https://github.com/dirkvdb"
+distfiles="${homepage}/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
 checksum=1cb24059c38223f657b300c84dd80491b7040d4b69471c4fea69be862bc99b5b
 
 post_install() {

From 7beee8b4bdb77f5b634d8b2fb1002ab0caa741c8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 028/113] ffmpegthumbs: revbump for ffmpeg6

---
 srcpkgs/ffmpegthumbs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ffmpegthumbs/template b/srcpkgs/ffmpegthumbs/template
index 5f0b9414dadaf..11b88193528f4 100644
--- a/srcpkgs/ffmpegthumbs/template
+++ b/srcpkgs/ffmpegthumbs/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbs'
 pkgname=ffmpegthumbs
 version=22.12.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules kcoreaddons kconfig-devel
  pkg-config qt5-host-tools qt5-qmake gettext"

From 9a6e801175ee9997ddd905a84717ed23011c16cb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 029/113] ffms2: revbump for ffmpeg6

---
 srcpkgs/ffms2/patches/ffmpeg5.patch | 424 ++++++++++++++++++++++++++++
 srcpkgs/ffms2/template              |   2 +-
 2 files changed, 425 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ffms2/patches/ffmpeg5.patch

diff --git a/srcpkgs/ffms2/patches/ffmpeg5.patch b/srcpkgs/ffms2/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..1479fabcafcb4
--- /dev/null
+++ b/srcpkgs/ffms2/patches/ffmpeg5.patch
@@ -0,0 +1,424 @@
+From 45673149e9a2f5586855ad472e3059084eaa36b1 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:41:21 +0100
+Subject: [PATCH] Use auto for AVCodec
+
+The geniuses over at FFmpeg decided to constify this API, so old
+versions of the library will return AVCodec *, while new versions
+of the libary will return const AVCodec *, which, in C++, are not
+OK to convert between.
+
+Rather than use some macro hell in ffmscompat.h, we can work around
+this by using auto.
+
+Gross.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 2 +-
+ src/core/indexing.cpp    | 6 +++---
+ src/core/videosource.cpp | 2 +-
+ 3 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index e4ce97c..ac09666 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -469,7 +469,7 @@ void FFMS_AudioSource::OpenFile() {
+ 
+     LAVFOpenFile(SourceFile.c_str(), FormatContext, TrackNumber);
+ 
+-    AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
++    auto *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
+     if (Codec == nullptr)
+         throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+             "Audio codec not found");
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index e547c5a..59fb4e8 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -384,7 +384,7 @@ FFMS_TrackType FFMS_Indexer::GetTrackType(int Track) {
+ }
+ 
+ const char *FFMS_Indexer::GetTrackCodec(int Track) {
+-    AVCodec *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
++    auto *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
+     return codec ? codec->name : nullptr;
+ }
+ 
+@@ -402,7 +402,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             UseDTS);
+ 
+         if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            AVCodec *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (!VideoCodec) {
+                 FormatContext->streams[i]->discard = AVDISCARD_ALL;
+                 IndexMask.erase(i);
+@@ -433,7 +433,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 IndexMask.insert(i);
+             }
+         } else if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+-            AVCodec *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (AudioCodec == nullptr)
+                 throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_UNSUPPORTED,
+                     "Audio codec not found");
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index b889970..8956c22 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -171,7 +171,7 @@ FFMS_VideoSource::FFMS_VideoSource(const char *SourceFile, FFMS_Index &Index, in
+ 
+         LAVFOpenFile(SourceFile, FormatContext, VideoTrack);
+ 
+-        AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
++        auto *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
+         if (Codec == nullptr)
+             throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+                 "Video codec not found");
+-- 
+2.40.0
+
+From 96cbf38ea9381829a1314f432a2c60495dcefaad Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:12:41 +0100
+Subject: [PATCH] all: Update AVPacket API usage
+
+AVPackets must all be on the heap now, since it is no longer
+part of the libav* ABI.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 16 ++++++----
+ src/core/indexing.cpp    | 63 ++++++++++++++++++++++------------------
+ src/core/indexing.h      |  4 +--
+ src/core/utils.cpp       |  6 ----
+ src/core/utils.h         |  1 -
+ src/core/videosource.cpp | 30 ++++++++++---------
+ 6 files changed, 64 insertions(+), 56 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index 37cf9ae..e4ce97c 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -285,10 +285,15 @@ FFMS_AudioSource::AudioBlock *FFMS_AudioSource::CacheBlock(CacheIterator &pos) {
+ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     CurrentFrame = &Frames[PacketNumber];
+ 
+-    AVPacket Packet;
+-    if (!ReadPacket(&Packet))
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++    if (!ReadPacket(Packet)) {
++        av_packet_free(&Packet);
+         throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_UNKNOWN,
+             "ReadPacket unexpectedly failed to read a packet");
++    }
+ 
+     // ReadPacket may have changed the packet number
+     CurrentFrame = &Frames[PacketNumber];
+@@ -297,8 +302,9 @@ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     int NumberOfSamples = 0;
+     AudioBlock *CachedBlock = nullptr;
+     
+-    int Ret = avcodec_send_packet(CodecContext, &Packet);
+-    av_packet_unref(&Packet);
++    int Ret = avcodec_send_packet(CodecContext, Packet);
++    av_packet_unref(Packet);
++    av_packet_free(&Packet);
+ 
+     av_frame_unref(DecodeFrame);
+     Ret = avcodec_receive_frame(CodecContext, DecodeFrame);
+@@ -513,8 +519,6 @@ void FFMS_AudioSource::Seek() {
+ }
+ 
+ bool FFMS_AudioSource::ReadPacket(AVPacket *Packet) {
+-    InitNullPacket(*Packet);
+-
+     while (av_read_frame(FormatContext, Packet) >= 0) {
+         if (Packet->stream_index == TrackNumber) {
+             // Required because not all audio packets, especially in ogg, have a pts. Use the previous valid packet's pts instead.
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index 23fb95b..e547c5a 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -320,7 +320,7 @@ void FFMS_Indexer::CheckAudioProperties(int Track, AVCodecContext *Context) {
+     }
+ }
+ 
+-void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict,
++void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict,
+                                     int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct) {
+     if (VideoContext.Parser) {
+         uint8_t *OB;
+@@ -330,8 +330,8 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+         av_parser_parse2(VideoContext.Parser,
+             VideoContext.CodecContext,
+             &OB, &OBSize,
+-            pkt.data, pkt.size,
+-            pkt.pts, pkt.dts, pkt.pos);
++            pkt->data, pkt->size,
++            pkt->pts, pkt->dts, pkt->pos);
+ 
+         // H.264 (PAFF) and HEVC may have one field per packet, so we need to track
+         // when we have a full or half frame available, and mark one of them as
+@@ -351,15 +351,15 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+ 
+         *RepeatPict = VideoContext.Parser->repeat_pict;
+         *FrameType = VideoContext.Parser->pict_type;
+-        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt.flags & AV_PKT_FLAG_DISCARD));
++        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt->flags & AV_PKT_FLAG_DISCARD));
+     } else {
+-        *Invisible = !!(pkt.flags & AV_PKT_FLAG_DISCARD);
++        *Invisible = !!(pkt->flags & AV_PKT_FLAG_DISCARD);
+     }
+ 
+     if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP8)
+-        ParseVP8(pkt.data[0], Invisible, FrameType);
++        ParseVP8(pkt->data[0], Invisible, FrameType);
+     else if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP9)
+-        ParseVP9(pkt.data[0], Invisible, FrameType);
++        ParseVP9(pkt->data[0], Invisible, FrameType);
+ }
+ 
+ void FFMS_Indexer::Free() {
+@@ -458,32 +458,36 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+         }
+     }
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
+     std::vector<int64_t> LastValidTS(FormatContext->nb_streams, AV_NOPTS_VALUE);
+ 
+     int64_t filesize = avio_size(FormatContext->pb);
+     enum AVPictureStructure LastPicStruct = AV_PICTURE_STRUCTURE_UNKNOWN;
+-    while (av_read_frame(FormatContext, &Packet) >= 0) {
++    while (av_read_frame(FormatContext, Packet) >= 0) {
+         // Update progress
+         // FormatContext->pb can apparently be NULL when opening images.
+         if (IC && FormatContext->pb) {
+-            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate))
++            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate)) {
++                av_packet_free(&Packet);
+                 throw FFMS_Exception(FFMS_ERROR_CANCELLED, FFMS_ERROR_USER,
+                     "Cancelled by user");
++            }
+         }
+-        if (!IndexMask.count(Packet.stream_index)) {
+-            av_packet_unref(&Packet);
++        if (!IndexMask.count(Packet->stream_index)) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+-        int Track = Packet.stream_index;
++        int Track = Packet->stream_index;
+         FFMS_Track &TrackInfo = (*TrackIndices)[Track];
+-        bool KeyFrame = !!(Packet.flags & AV_PKT_FLAG_KEY);
++        bool KeyFrame = !!(Packet->flags & AV_PKT_FLAG_KEY);
+         ReadTS(Packet, LastValidTS[Track], (*TrackIndices)[Track].UseDTS);
+ 
+         if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            int64_t PTS = TrackInfo.UseDTS ? Packet.dts : Packet.pts;
++            int64_t PTS = TrackInfo.UseDTS ? Packet->dts : Packet->pts;
+             if (PTS == AV_NOPTS_VALUE) {
+                 // VPx alt-refs are output as packets which lack timestmps or durations, since
+                 // they are invisible. Currently, the timestamp mangling code in libavformat
+@@ -495,9 +499,11 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 // FFMS2 currently sorts packets by PTS, which will break decoding, otherwise.
+                 bool HasAltRefs = (FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP8 ||
+                                    FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP9);
+-                if (Packet.duration == 0 && !HasAltRefs)
++                if (Packet->duration == 0 && !HasAltRefs) {
++                    av_packet_free(&Packet);
+                     throw FFMS_Exception(FFMS_ERROR_INDEXING, FFMS_ERROR_PARSER,
+                         "Invalid packet pts, dts, and duration");
++                }
+ 
+                 if (TrackInfo.empty())
+                     PTS = 0;
+@@ -513,7 +519,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             ParseVideoPacket(AVContexts[Track], Packet, &RepeatPict, &FrameType, &Invisible, &LastPicStruct);
+ 
+             TrackInfo.AddVideoFrame(PTS, RepeatPict, KeyFrame,
+-                FrameType, Packet.pos, Invisible);
++                FrameType, Packet->pos, Invisible);
+         } else if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+             // For video seeking timestamps are used only if all packets have
+             // timestamps, while for audio they're used if any have timestamps,
+@@ -522,28 +528,29 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 TrackInfo.HasTS = true;
+ 
+             int64_t StartSample = AVContexts[Track].CurrentSample;
+-            uint32_t SampleCount = IndexAudioPacket(Track, &Packet, AVContexts[Track], *TrackIndices);
++            uint32_t SampleCount = IndexAudioPacket(Track, Packet, AVContexts[Track], *TrackIndices);
+             TrackInfo.SampleRate = AVContexts[Track].CodecContext->sample_rate;
+ 
+             TrackInfo.AddAudioFrame(LastValidTS[Track],
+-                StartSample, SampleCount, KeyFrame, Packet.pos, Packet.flags & AV_PKT_FLAG_DISCARD);
++                StartSample, SampleCount, KeyFrame, Packet->pos, Packet->flags & AV_PKT_FLAG_DISCARD);
+         }
+ 
+-        if (!(Packet.flags & AV_PKT_FLAG_DISCARD))
+-            TrackInfo.LastDuration = Packet.duration;
++        if (!(Packet->flags & AV_PKT_FLAG_DISCARD))
++            TrackInfo.LastDuration = Packet->duration;
+ 
+-        av_packet_unref(&Packet);
++        av_packet_unref(Packet);
+     }
++    av_packet_free(&Packet);
+ 
+     TrackIndices->Finalize(AVContexts, FormatContext->iformat->name);
+     return TrackIndices.release();
+ }
+ 
+-void FFMS_Indexer::ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS) {
+-    if (!UseDTS && Packet.pts != AV_NOPTS_VALUE)
+-        TS = Packet.pts;
++void FFMS_Indexer::ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS) {
++    if (!UseDTS && Packet->pts != AV_NOPTS_VALUE)
++        TS = Packet->pts;
+     if (TS == AV_NOPTS_VALUE)
+         UseDTS = true;
+-    if (UseDTS && Packet.dts != AV_NOPTS_VALUE)
+-        TS = Packet.dts;
++    if (UseDTS && Packet->dts != AV_NOPTS_VALUE)
++        TS = Packet->dts;
+ }
+diff --git a/src/core/indexing.h b/src/core/indexing.h
+index 3cfc3c3..5c06868 100644
+--- a/src/core/indexing.h
++++ b/src/core/indexing.h
+@@ -80,10 +80,10 @@ private:
+     int64_t Filesize;
+     uint8_t Digest[20];
+ 
+-    void ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS);
++    void ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS);
+     void CheckAudioProperties(int Track, AVCodecContext *Context);
+     uint32_t IndexAudioPacket(int Track, AVPacket *Packet, SharedAVContext &Context, FFMS_Index &TrackIndices);
+-    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
++    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
+     void Free();
+ public:
+     FFMS_Indexer(const char *Filename);
+diff --git a/src/core/utils.cpp b/src/core/utils.cpp
+index ce67533..8a2e997 100644
+--- a/src/core/utils.cpp
++++ b/src/core/utils.cpp
+@@ -62,12 +62,6 @@ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo) {
+     }
+ }
+ 
+-void InitNullPacket(AVPacket &pkt) {
+-    av_init_packet(&pkt);
+-    pkt.data = nullptr;
+-    pkt.size = 0;
+-}
+-
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames) {
+     AP.SampleFormat = static_cast<FFMS_SampleFormat>(av_get_packed_sample_fmt(CTX->sample_fmt));
+     AP.BitsPerSample = av_get_bytes_per_sample(CTX->sample_fmt) * 8;
+diff --git a/src/core/utils.h b/src/core/utils.h
+index 9819dc7..003ab79 100644
+--- a/src/core/utils.h
++++ b/src/core/utils.h
+@@ -58,7 +58,6 @@ std::unique_ptr<T> make_unique(Args&&... args) {
+ }
+ 
+ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo);
+-void InitNullPacket(AVPacket &pkt);
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames);
+ 
+ void LAVFOpenFile(const char *SourceFile, AVFormatContext *&FormatContext, int Track);
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index 06bd161..b889970 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -673,30 +673,34 @@ void FFMS_VideoSource::DecodeNextFrame(int64_t &AStartTime, int64_t &Pos) {
+     if (HasPendingDelayedFrames())
+         return;
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
+-
+-    while (ReadFrame(&Packet) >= 0) {
+-        if (Packet.stream_index != VideoTrack) {
+-            av_packet_unref(&Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++
++    while (ReadFrame(Packet) >= 0) {
++        if (Packet->stream_index != VideoTrack) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+         if (AStartTime < 0)
+-            AStartTime = Frames.UseDTS ? Packet.dts : Packet.pts;
++            AStartTime = Frames.UseDTS ? Packet->dts : Packet->pts;
+ 
+         if (Pos < 0)
+-            Pos = Packet.pos;
++            Pos = Packet->pos;
+ 
+-        bool FrameFinished = DecodePacket(&Packet);
+-        av_packet_unref(&Packet);
+-        if (FrameFinished)
++        bool FrameFinished = DecodePacket(Packet);
++        av_packet_unref(Packet);
++        if (FrameFinished) {
++            av_packet_free(&Packet);
+             return;
++        }
+     }
+ 
+     // Flush final frames
+-    InitNullPacket(Packet);
+-    DecodePacket(&Packet);
++    DecodePacket(Packet);
++    av_packet_free(&Packet);
+ }
+ 
+ bool FFMS_VideoSource::SeekTo(int n, int SeekOffset) {
+-- 
+2.40.0
+
+From bf9e03e9e08534c024e5a744a6437c4aac160201 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:20:47 +0100
+Subject: [PATCH 2/3] configure: Remove deprecated API use
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ configure.ac | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index b35ef80bc..d19714d0f 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -102,10 +102,10 @@ CFLAGS="$_CFLAGS $FFMPEG_CFLAGS"
+
+ AC_DEFUN([TEST_FFMPEG],
+          [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+-            #include <libavcodec/avcodec.h>
++            #include <libavformat/avformat.h>
+             #include <libswscale/swscale.h>
+             ]],[[
+-                avcodec_register_all();
++                avformat_network_init();
+                 swscale_version();
+             ]])], [eval $1=yes], [eval $1=no])
+         ])
+
diff --git a/srcpkgs/ffms2/template b/srcpkgs/ffms2/template
index 365f64d10cbab..1641ecf43be5b 100644
--- a/srcpkgs/ffms2/template
+++ b/srcpkgs/ffms2/template
@@ -1,7 +1,7 @@
 # Template file for 'ffms2'
 pkgname=ffms2
 version=2.40
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-shared --disable-static"
 hostmakedepends="pkg-config autoconf automake libtool"

From 947d8afcce9c14a19dd9fea004effdcf586b8407 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 030/113] freerdp: revbump for ffmpeg6

---
 .../freerdp/patches/ffmpeg6_aa2cb9aa.patch    | 42 +++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100644 srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch

diff --git a/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
new file mode 100644
index 0000000000000..a4324da3a8822
--- /dev/null
+++ b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
@@ -0,0 +1,42 @@
+From aa2cb9aa5ff5562433598ba168a466e0752bca0e Mon Sep 17 00:00:00 2001
+From: akallabeth <akallabeth@posteo.net>
+Date: Tue, 14 Feb 2023 07:48:54 +0100
+Subject: [PATCH] Fixed #8686: Update h264 to use new FFMPEG API
+
+---
+ channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c | 2 ++
+ libfreerdp/codec/h264_ffmpeg.c            | 2 ++
+ 2 files changed, 4 insertions(+)
+
+diff --git a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+index 339462d865f..beea80b7a1e 100644
+--- a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
++++ b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+@@ -239,8 +239,10 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYP
+ 		}
+ 	}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 	if (mdecoder->codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		mdecoder->codec_context->flags |= AV_CODEC_FLAG_TRUNCATED;
++#endif
+ 
+ 	return TRUE;
+ }
+diff --git a/libfreerdp/codec/h264_ffmpeg.c b/libfreerdp/codec/h264_ffmpeg.c
+index 8a23db2473c..896a333019b 100644
+--- a/libfreerdp/codec/h264_ffmpeg.c
++++ b/libfreerdp/codec/h264_ffmpeg.c
+@@ -615,10 +615,12 @@ static BOOL libavcodec_init(H264_CONTEXT* h264)
+ 			goto EXCEPTION;
+ 		}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 		if (sys->codecDecoder->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		{
+ 			sys->codecDecoderContext->flags |= AV_CODEC_FLAG_TRUNCATED;
+ 		}
++#endif
+ 
+ #ifdef WITH_VAAPI
+ 

From 7ad3e23f9cfab3e6cf33bb3d0202f202fcd75290 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 031/113] gerbera: revbump for ffmpeg6

---
 srcpkgs/gerbera/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gerbera/template b/srcpkgs/gerbera/template
index ae14f35c767c0..2dc0ac0ce03b5 100644
--- a/srcpkgs/gerbera/template
+++ b/srcpkgs/gerbera/template
@@ -1,7 +1,7 @@
 # Template file for 'gerbera'
 pkgname=gerbera
 version=1.12.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_SYSTEMD=0 -DWITH_AVCODEC=1"
 hostmakedepends="pkg-config"

From 02dc18aa00058d6f383179fb57f8c5451ee1c4e5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 032/113] goldendict: revbump for ffmpeg6

---
 srcpkgs/goldendict/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/goldendict/template b/srcpkgs/goldendict/template
index f4a05759f693d..97f44347b03a6 100644
--- a/srcpkgs/goldendict/template
+++ b/srcpkgs/goldendict/template
@@ -1,7 +1,7 @@
 # Template file for 'goldendict'
 pkgname=goldendict
 version=1.5.0
-revision=1
+revision=2
 build_style=qmake
 configure_args="CONFIG+=zim_support goldendict.pro"
 hostmakedepends="qt5-qmake pkg-config qt5-host-tools"
@@ -10,7 +10,7 @@ makedepends="tiff-devel qt5-devel libvorbis-devel zlib-devel
  qt5-webkit-devel lzo-devel bzip2-devel libao-devel qt5-svg-devel
  libeb-devel qt5-x11extras-devel ffmpeg-devel liblzma-devel
  qt5-multimedia-devel"
-short_desc="A feature-rich dictionary lookup program"
+short_desc="Feature-rich dictionary lookup program"
 maintainer="John <me@johnnynator.dev>"
 license="GPL-3.0-or-later"
 homepage="http://goldendict.org/"

From cfe9488acc42ee555f313e0d5032459126147cbf Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 033/113] gst-libav: revbump for ffmpeg6

---
 srcpkgs/gst-libav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index 78afeee4aefb2..f892eb2063564 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.22.7
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"

From 518b123707fa3f98ea22baff4b288abf8e48a0ae Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 034/113] gst-rtsp-server: revbump for ffmpeg6

---
 srcpkgs/gst-rtsp-server/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index 2c280c84f1514..83a2949fd9482 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
 version=1.22.7
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="glib-devel gst-plugins-bad1-devel gobject-introspection

From d0dc1707b437a3f0211da62e8b4fa70f8a45ae5a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 035/113] guvcview: update to 2.0.8.

---
 srcpkgs/guvcview/patches/fix-include.patch | 10 ++++++++++
 srcpkgs/guvcview/template                  |  7 +++----
 2 files changed, 13 insertions(+), 4 deletions(-)
 create mode 100644 srcpkgs/guvcview/patches/fix-include.patch

diff --git a/srcpkgs/guvcview/patches/fix-include.patch b/srcpkgs/guvcview/patches/fix-include.patch
new file mode 100644
index 0000000000000..503c2af3b78c1
--- /dev/null
+++ b/srcpkgs/guvcview/patches/fix-include.patch
@@ -0,0 +1,10 @@
+--- a/guvcview/guvcview.c
++++ b/guvcview/guvcview.c
+@@ -28,6 +28,7 @@
+ #include <sys/stat.h>
+ #include <sys/resource.h>
+ #include <errno.h>
++#include <locale.h>
+ 
+ #include "gview.h"
+ #include "gviewv4l2core.h"
diff --git a/srcpkgs/guvcview/template b/srcpkgs/guvcview/template
index d42fd38fa4ad1..86a7fd619612c 100644
--- a/srcpkgs/guvcview/template
+++ b/srcpkgs/guvcview/template
@@ -1,8 +1,7 @@
 # Template file for 'guvcview'
 pkgname=guvcview
-version=2.0.7
-revision=2
-create_wrksrc=yes
+version=2.0.8
+revision=1
 build_style=gnu-configure
 configure_args="--disable-static --disable-debian-menu"
 hostmakedepends="pkg-config intltool autoconf automake libtool glib-devel"
@@ -14,7 +13,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="http://guvcview.sourceforge.net/"
 distfiles="${SOURCEFORGE_SITE}/${pkgname}/${pkgname}-src-${version}.tar.bz2"
-checksum=f47d51fbd06e44eeaa1a82f4a153c927527c90d94514197a70b2956028cc8ad4
+checksum=a21f4e448286666cf27bafef5290cc953a0a1796b752e5bbe521266dc1230c81
 
 post_patch() {
 	sed '31a#include <locale.h>' -i  guvcview/guvcview.c

From 96ab0db4470073a73ad65d3f251fe7f5c67e544e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 036/113] handbrake: update to 1.6.1

---
 .../patches/fix-missing-x265-link-flag.patch    | 11 ++++++-----
 .../handbrake/patches/libhb-vpl-include.patch   | 15 +++++++++++++++
 srcpkgs/handbrake/template                      | 17 ++++++++++-------
 3 files changed, 31 insertions(+), 12 deletions(-)
 create mode 100644 srcpkgs/handbrake/patches/libhb-vpl-include.patch

diff --git a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
index 26db03867a0c8..d6bb2eda627a3 100644
--- a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
+++ b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
@@ -1,14 +1,15 @@
 --- a/gtk/configure.ac
 +++ b/gtk/configure.ac
 @@ -203,7 +203,7 @@
- 
+
  AM_CONDITIONAL([MINGW], [test "x$mingw_flag" = "xyes"])
- 
--HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg"
-+HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -ldl"
+
+-HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc"
++HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc -ldl"
  HB_CPPFLAGS="$HB_CPPFLAGS $HBINC"
- 
+
  PKG_CHECK_MODULES([x264], [x264], sys_x264=yes, sys_x264=no)
+
 --- a/test/module.defs
 +++ b/test/module.defs
 @@ -69,6 +69,9 @@
diff --git a/srcpkgs/handbrake/patches/libhb-vpl-include.patch b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
new file mode 100644
index 0000000000000..298f9f4ab28f2
--- /dev/null
+++ b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
@@ -0,0 +1,15 @@
+--- a/libhb/module.defs	2023-01-22 11:36:49.000000000 -0500
++++ b/libhb/module.defs	2023-04-03 22:37:52.395467010 -0400
+@@ -46,11 +46,7 @@
+ LIBHB.GCC.I += $(LIBHB.build/) $(CONTRIB.build/)include
+ 
+ ifeq (1,$(FEATURE.qsv))
+-    ifeq ($(HOST.system),freebsd))
+-        LIBHB.GCC.I += $(LOCALBASE)/include/vpl
+-    else
+-        LIBHB.GCC.I += $(CONTRIB.build/)include/vpl
+-    endif
++    LIBHB.GCC.I += /usr/include/vpl
+ endif
+ 
+ ifneq (,$(filter $(HOST.system),freebsd netbsd openbsd))
diff --git a/srcpkgs/handbrake/template b/srcpkgs/handbrake/template
index ca5e4571e49c3..c32cb1bfa31f4 100644
--- a/srcpkgs/handbrake/template
+++ b/srcpkgs/handbrake/template
@@ -1,10 +1,10 @@
 # Template file for 'handbrake'
 pkgname=handbrake
-version=1.5.1
+version=1.6.1
 revision=1
 build_style=gnu-configure
 configure_args="--force --disable-gtk-update-checks --disable-df-fetch --harden
- $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc)"
+ $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc) $(vopt_enable qsv)"
 make_build_args="-C ${XBPS_TRIPLET}"
 make_install_args="-C ${XBPS_TRIPLET}"
 hostmakedepends="automake cmake gettext-devel glib-devel intltool libtool m4 meson nasm pkg-config python3"
@@ -12,8 +12,11 @@ makedepends="bzip2-devel ffmpeg-devel gst-plugins-base1-devel gtk+3-devel
  jansson-devel lame-devel libass-devel libbluray-devel libdav1d-devel
  libdvdnav-devel libdvdread-devel libgudev-devel libnuma-devel
  libsamplerate-devel libtheora-devel libvorbis-devel libvpx-devel libxml2-devel
- opus-devel speex-devel x264-devel x265-devel zimg-devel
+ opus-devel speex-devel x264-devel x265-devel zimg-devel libsvt-av1-devel
  $(vopt_if fdk_aac fdk-aac-devel)
+ $(vopt_if qsv libva-devel)
+ $(vopt_if qsv libdrm-devel)
+ $(vopt_if qsv onevpl-devel)
  $(vopt_if nvenc nv-codec-headers)"
 depends="desktop-file-utils gst-plugins-good1 hicolor-icon-theme"
 short_desc="Multithreaded video transcoder"
@@ -21,15 +24,15 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-2.0-only"
 homepage="https://handbrake.fr/"
 distfiles="https://github.com/HandBrake/HandBrake/releases/download/${version}/HandBrake-${version}-source.tar.bz2"
-checksum=3999fe06d5309c819799a73a968a8ec3840e7840c2b64af8f5cdb7fd8c9430f0
+checksum=94ccfe03db917a91650000c510f7fd53f844da19f19ad4b4be1b8f6bc31a8d4c
 nocross=yes
 
-build_options="fdk_aac nvenc"
+build_options="fdk_aac nvenc qsv"
 
 case "$XBPS_TARGET_MACHINE" in
 	x86_64*|i686*)
 		CFLAGS="-msse"
-		build_options_default="nvenc"
+		build_options_default="nvenc qsv"
 		;;
 esac
 
@@ -37,7 +40,7 @@ pre_configure() {
 	# use system libraries, don't download them
 	rm -rf contrib/
 	for module in fdk-aac ffmpeg libbluray libdav1d libdvdnav libdvdread nvenc \
-		x265 zimg; do
+		x265 zimg svt-av1 libvpl; do
 	    vsed -i "/MODULES += contrib\/${module}/d" make/include/main.defs
 	done
 }

From cdd99c71756c31a4e63b7c7a926b1593db7934f2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 037/113] hedgewars: revbump for ffmpeg4

---
 srcpkgs/hedgewars/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/hedgewars/template b/srcpkgs/hedgewars/template
index 94b6db673b0c3..402ccfaaecbc2 100644
--- a/srcpkgs/hedgewars/template
+++ b/srcpkgs/hedgewars/template
@@ -1,13 +1,13 @@
 # Template file for 'hedgewars'
 pkgname=hedgewars
 version=1.0.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DNOSERVER=1 -DDATA_INSTALL_DIR=/usr/share/${pkgname}
  -DPHYSFS_SYSTEM=1 -DMINIMAL_FLAGS=1"
 make_cmd=make
 hostmakedepends="lua51 pkg-config qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
+makedepends="ffmpeg4-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
  SDL2_mixer-devel SDL2_net-devel SDL2_ttf-devel"
 depends="libfreeglut"
 short_desc="Funny turn-based artillery game, featuring fighting Hedgehogs!"

From 4ba5dbf0bfbdd4d51b234be00c5360cdd194a3fb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 038/113] idjc: revbump for ffmpeg4

---
 srcpkgs/idjc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/idjc/template b/srcpkgs/idjc/template
index a9cde0665d55b..6f1d21c5781fd 100644
--- a/srcpkgs/idjc/template
+++ b/srcpkgs/idjc/template
@@ -5,7 +5,7 @@ revision=5
 build_style=gnu-configure
 hostmakedepends="pkg-config git python3 automake gettext-devel libtool"
 makedepends="libvorbis-devel libogg-devel jack-devel libsamplerate-devel
- libflac-devel libsndfile-devel mpg123-devel ffmpeg-devel speex-devel
+ libflac-devel libsndfile-devel mpg123-devel ffmpeg4-devel speex-devel
  glib-devel pixman-devel lame-devel python3-gobject-devel libshout-idjc-devel
  opus-devel twolame-devel python3-mutagen python3-devel"
 depends="python3-gobject python3-mutagen desktop-file-utils shared-mime-info python3-dbus jack"

From de5d623ab0ef969f9ced74ae3bd1ed17888b34bb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 039/113] kid3: revbump for ffmpeg6

---
 srcpkgs/kid3/patches/ffmpeg5.patch | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 srcpkgs/kid3/patches/ffmpeg5.patch

diff --git a/srcpkgs/kid3/patches/ffmpeg5.patch b/srcpkgs/kid3/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..135fc50e07c9b
--- /dev/null
+++ b/srcpkgs/kid3/patches/ffmpeg5.patch
@@ -0,0 +1,17 @@
+# https://aur.archlinux.org/cgit/aur.git/diff/ffmpeg5.patch?h=kid3-cli&id=12410a74906612e7efc0ec8fbce739b4a0fef7e7
+diff --git a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+index e156d424..e12b9abd 100644
+--- a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
++++ b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+@@ -232,7 +232,11 @@ private:
+   friend class Format;
+   friend class Converter;
+   AVCodecContext* m_ptr;
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 0, 0)
+   AVCodec* m_impl;
++#else
++  const AVCodec* m_impl;
++#endif
+   AVFrame* m_frame;
+   bool m_opened;
+ };

From 3256b39db572b6a2f964279796ae014507e25b15 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 040/113] kodi: revbump for ffmpeg4

---
 srcpkgs/kodi/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kodi/template b/srcpkgs/kodi/template
index d37a5918cd675..536ee1fc83a7d 100644
--- a/srcpkgs/kodi/template
+++ b/srcpkgs/kodi/template
@@ -54,7 +54,7 @@ makedepends="
  libmad-devel fontconfig-devel libXinerama-devel libsamplerate-devel libmms-devel
  enca-devel boost-devel libcurl-devel libva-devel libvdpau-devel libass-devel
  libbluetooth-devel yajl-devel libplist-devel librtmp-devel tinyxml-devel
- taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg-devel
+ taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg4-devel
  giflib-devel libxslt-devel gnutls-devel libssh-devel libmicrohttpd-devel
  libcec-devel dcadec-devel flatbuffers-devel fmt-devel lcms2-devel
  libfstrcmp-devel rapidjson libcdio-paranoia spdlog libwaylandpp-devel

From 3ea98d70916da25e74e00af257a8ff9893156dcb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 041/113] kpipewire: revbump for ffmpeg6

---
 srcpkgs/kpipewire/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kpipewire/template b/srcpkgs/kpipewire/template
index 6214a4451336e..3555348659dde 100644
--- a/srcpkgs/kpipewire/template
+++ b/srcpkgs/kpipewire/template
@@ -1,7 +1,7 @@
 # Template file for 'kpipewire'
 pkgname=kpipewire
 version=5.27.10
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules plasma-wayland-protocols gettext
  qt5-qmake qt5-host-tools pkg-config wayland-devel kcoreaddons

From 6fbc5735215c6fb66af22b94c45fd526baa95110 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 042/113] libextractor: revbump for ffmpeg4

---
 srcpkgs/libextractor/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libextractor/template b/srcpkgs/libextractor/template
index 044c663a3a0b9..ace88ae128da5 100644
--- a/srcpkgs/libextractor/template
+++ b/srcpkgs/libextractor/template
@@ -7,7 +7,7 @@ configure_args="--disable-static"
 hostmakedepends="pkg-config"
 makedepends="zlib-devel bzip2-devel exiv2-devel tiff-devel libpng-devel
  libjpeg-turbo-devel libvorbis-devel libflac-devel giflib-devel libmpeg2-devel
- ffmpeg-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
+ ffmpeg4-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
 short_desc="Library used to extract meta data from files"
 maintainer="Martin Riese <grauehaare@gmx.de>"
 license="GPL-3.0-or-later"

From b51c692b6e9182ca9ea9c6488f4d539bbe2dbe95 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 043/113] libopenal: revbump for ffmpeg6

---
 srcpkgs/libopenal/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenal/template b/srcpkgs/libopenal/template
index 88d0f11307d81..8308fca0393e3 100644
--- a/srcpkgs/libopenal/template
+++ b/srcpkgs/libopenal/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenal'
 pkgname=libopenal
 version=1.23.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DALSOFT_EXAMPLES=OFF"
 hostmakedepends="pkg-config"

From 157a85e749c962171f07180937e2615ebeeb3b56 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 044/113] loudgain: revbump for ffmpeg6

---
 srcpkgs/loudgain/patches/ffmpeg5.patch | 11 +++++++++++
 srcpkgs/loudgain/template              |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/loudgain/patches/ffmpeg5.patch

diff --git a/srcpkgs/loudgain/patches/ffmpeg5.patch b/srcpkgs/loudgain/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..16d4510ee98fa
--- /dev/null
+++ b/srcpkgs/loudgain/patches/ffmpeg5.patch
@@ -0,0 +1,11 @@
+--- a/src/scan.c	2019-09-06 11:31:19.000000000 -0400
++++ b/src/scan.c	2023-03-23 11:15:40.867968521 -0400
+@@ -69,8 +69,6 @@
+ 	 * It is now useless
+ 	 * https://github.com/FFmpeg/FFmpeg/blob/70d25268c21cbee5f08304da95be1f647c630c15/doc/APIchanges#L86
+ 	 */
+-  if (avformat_version() < AV_VERSION_INT(58,9,100))
+-    av_register_all();
+ 
+ 	av_log_set_callback(scan_av_log);
+ 
diff --git a/srcpkgs/loudgain/template b/srcpkgs/loudgain/template
index da4f2d56e94c3..4d6bf29efb4fd 100644
--- a/srcpkgs/loudgain/template
+++ b/srcpkgs/loudgain/template
@@ -1,7 +1,7 @@
 # Template file for 'loudgain'
 pkgname=loudgain
 version=0.6.8
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libebur128-devel taglib-devel ffmpeg-devel"

From 3ad9302a204f1bcbdbf74d5833f9b34429b43c6f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 045/113] mediastreamer: revbump for ffmpeg4

---
 srcpkgs/mediastreamer/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mediastreamer/template b/srcpkgs/mediastreamer/template
index 0fcffa7653d18..92ada88743a9b 100644
--- a/srcpkgs/mediastreamer/template
+++ b/srcpkgs/mediastreamer/template
@@ -5,7 +5,7 @@ revision=2
 build_style=cmake
 configure_args="-DENABLE_STRICT=0 -DENABLE_UNIT_TESTS=0"
 hostmakedepends="python3"
-makedepends="bzrtp-devel ffmpeg-devel glew-devel libXv-devel libsrtp-devel
+makedepends="bzrtp-devel ffmpeg4-devel glew-devel libXv-devel libsrtp-devel
  libupnp-devel libvpx-devel mbedtls-devel opus-devel ortp-devel pulseaudio-devel
  libtheora-devel speex-devel v4l-utils-devel bcg729-devel bcmatroska2-devel libgsm-devel
  zxing-cpp-devel"

From d0249f8a0bd460b015da9d8a6a1c438ce41a34d9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 046/113] mgba: revbump for ffmpeg6

---
 srcpkgs/mgba/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mgba/template b/srcpkgs/mgba/template
index 5513e3fd16f3f..f5c87a4893002 100644
--- a/srcpkgs/mgba/template
+++ b/srcpkgs/mgba/template
@@ -1,7 +1,7 @@
 # Template file for 'mgba'
 pkgname=mgba
 version=0.10.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake desktop-file-utils"
 makedepends="SDL2-devel ffmpeg-devel libedit-devel libepoxy-devel libmagick-devel

From 64341824447ad920a8e4014a9f6cfa7455d80b23 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 047/113] mlt: revbump for ffmpeg4

---
 srcpkgs/mlt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mlt/template b/srcpkgs/mlt/template
index 73e3915aaab9a..ec5054be3b75e 100644
--- a/srcpkgs/mlt/template
+++ b/srcpkgs/mlt/template
@@ -8,7 +8,7 @@ configure_args="--prefix=/usr --libdir=/usr/lib$XBPS_TARGET_WORDSIZE
  --swig-languages=python"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which"
 # XXX: movit vid.stab
-makedepends="alsa-lib-devel ffmpeg-devel gtk+-devel jack-devel ladspa-sdk
+makedepends="alsa-lib-devel ffmpeg4-devel gtk+-devel jack-devel ladspa-sdk
  libexif-devel libsamplerate-devel libxml2-devel sox-devel SDL_image-devel
  fftw-devel frei0r-plugins python3-devel pulseaudio-devel movit-devel
  libvidstab-devel"

From 8116d7f53e165c75f354a92832cd65d3344fc782 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 048/113] moc: revbump for ffmpeg4

---
 srcpkgs/moc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/moc/template b/srcpkgs/moc/template
index 3a04932c8f1e6..d8de816026b64 100644
--- a/srcpkgs/moc/template
+++ b/srcpkgs/moc/template
@@ -4,7 +4,7 @@ version=2.5.2
 revision=7
 build_style=gnu-configure
 hostmakedepends="pkg-config"
-makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg-devel
+makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg4-devel
  jack-devel alsa-lib-devel libltdl-devel libflac-devel libvorbis-devel
  libmad-devel libmpcdec-devel libmodplug-devel libid3tag-devel faad2-devel
  taglib-devel libsndfile-devel wavpack-devel speex-devel libsamplerate-devel

From 6ffff3d423ad66e96073ac2ef2a803bf4d24e719 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 049/113] motion: revbump for ffmpeg6

---
 srcpkgs/motion/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/motion/template b/srcpkgs/motion/template
index 607ebeb3c7b24..bf63a91d9764f 100644
--- a/srcpkgs/motion/template
+++ b/srcpkgs/motion/template
@@ -1,7 +1,7 @@
 # Template file for 'motion'
 pkgname=motion
 version=4.6.0
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake pkg-config gettext-devel tar"
 makedepends="ffmpeg-devel libmicrohttpd-devel v4l-utils-devel gettext-devel"

From 028016b8607b34483e46f4ba90d08a2edbef0d76 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 050/113] olive: revbump for ffmpeg4

---
 srcpkgs/olive/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/olive/template b/srcpkgs/olive/template
index 12a46936c9900..5c2917b9c5124 100644
--- a/srcpkgs/olive/template
+++ b/srcpkgs/olive/template
@@ -1,10 +1,10 @@
 # Template file for 'olive'
 pkgname=olive
 version=0.1.2
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools pkg-config"
-makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg-devel frei0r-plugins"
+makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg4-devel frei0r-plugins"
 short_desc="Non-linear video editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"

From 6a5f63c8ee4fb3e92b0fd1c5c7bd718bcabd1d77 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 051/113] omxplayer: revbump for ffmpeg4

---
 srcpkgs/omxplayer/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/omxplayer/template b/srcpkgs/omxplayer/template
index 9a66690c83ebb..a21b878878037 100644
--- a/srcpkgs/omxplayer/template
+++ b/srcpkgs/omxplayer/template
@@ -1,7 +1,7 @@
 # Template file for 'omxplayer'
 pkgname=omxplayer
 version=20190102
-revision=2
+revision=3
 short_desc="Commandline OMX player for the Raspberry Pi"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
@@ -15,7 +15,7 @@ checksum=af2d9450f8947842ea8c401fe9f71eec444013ebbdee29f2ac828c9c493c1329
 archs="armv6l* armv7l*"
 build_style=gnu-makefile
 hostmakedepends="ruby-ronn pkg-config"
-makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg-devel dbus-devel"
+makedepends="alsa-lib-devel rpi-userland-devel pcre-devel boost-devel freetype-devel ffmpeg4-devel dbus-devel"
 depends="freefont-ttf"
 
 do_build() {

From f6fab77032b59548b2df1314c25c8ef247b2cf4a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 052/113] opentoonz: revbump for ffmpeg6

---
 srcpkgs/opentoonz/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/opentoonz/template b/srcpkgs/opentoonz/template
index ee9f7603f55fd..3e81834ca0edd 100644
--- a/srcpkgs/opentoonz/template
+++ b/srcpkgs/opentoonz/template
@@ -1,7 +1,7 @@
 # Template file for 'opentoonz'
 pkgname=opentoonz
 version=1.6.0
-revision=2
+revision=3
 build_wrksrc="toonz/sources"
 build_style=cmake
 make_cmd=make

From 37a22333e72c40d92c0138261ab9ff6735ab7199 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 053/113] pianobar: revbump for ffmpeg6

---
 srcpkgs/pianobar/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pianobar/template b/srcpkgs/pianobar/template
index e3febb821a451..1e3dc1bf9308e 100644
--- a/srcpkgs/pianobar/template
+++ b/srcpkgs/pianobar/template
@@ -1,7 +1,7 @@
 # Template file for 'pianobar'
 pkgname=pianobar
 version=2022.04.01
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="V=1"
 hostmakedepends="pkg-config"

From 218fbedc622411efbdabfeb03165453ecfb7e3d6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 054/113] ppsspp: revbump for ffmpeg4

---
 srcpkgs/ppsspp/template | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/srcpkgs/ppsspp/template b/srcpkgs/ppsspp/template
index 2c0ded496eb98..8bf55f65198cd 100644
--- a/srcpkgs/ppsspp/template
+++ b/srcpkgs/ppsspp/template
@@ -1,7 +1,7 @@
 # Template file for 'ppsspp'
 pkgname=ppsspp
 version=1.16.6
-revision=1
+revision=2
 _glslang_commit=b34f619e1c85810dcb3c578107d2e48ba4ee2b37
 _SPIRV_Cross_commit=4212eef67ed0ca048cb726a6767185504e7695e5
 _armips_commit=7bd1ec93d4586985ba1ef420b43b5e620f68695e
@@ -15,7 +15,7 @@ configure_args="-DHEADLESS=1 -DUSE_SYSTEM_FFMPEG=1 -DUNITTEST=ON
  -DUSING_QT_UI=$(vopt_if qt ON OFF) -DUSE_SYSTEM_ZSTD=ON
  -DARMIPS_USE_STD_FILESYSTEM=ON"
 hostmakedepends="pkg-config python3 $(vopt_if qt qt5-host-tools)"
-makedepends="zlib-devel glew-devel ffmpeg-devel libzip-devel
+makedepends="zlib-devel glew-devel ffmpeg4-devel libzip-devel
  snappy-devel rapidjson libpng-devel libzstd-devel
  $(vopt_if sdl2 'SDL2_ttf-devel SDL2-devel') $(vopt_if wayland wayland-devel)
  $(vopt_if qt 'qt5-devel qt5-multimedia-devel')"
@@ -69,10 +69,10 @@ post_extract() {
 	rmdir -v ${wrksrc}/ext/cpu_features
 	mv ${wrksrc}/cpu_features-${_cpu_features_commit} ${wrksrc}/ext/cpu_features
 	rmdir -v ${wrksrc}/ext/rcheevos
-        mv ${wrksrc}/rcheevos-${_rcheevos_commit} ${wrksrc}/ext/rcheevos
+	mv ${wrksrc}/rcheevos-${_rcheevos_commit} ${wrksrc}/ext/rcheevos
 }
 
-post_patch(){
+post_patch() {
 	# disable git versioning
 	vsed -e 's|find_package(Git)|# &|' -i git-version.cmake
 }
@@ -85,7 +85,6 @@ post_configure() {
 }
 
 do_install() {
-	vlicense LICENSE.TXT
 	vinstall icons/icon.svg 644 usr/share/pixmaps ppsspp.svg
 	vinstall Qt/PPSSPP.desktop 644 usr/share/applications
 	vbin build/PPSSPPHeadless ppsspp-headless

From 3767955ac34c90fd4ee2652ec1453a201aebbde9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 055/113] pqiv: revbump for ffmpeg6

---
 srcpkgs/pqiv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pqiv/template b/srcpkgs/pqiv/template
index 542fc27a2d32a..9308d949b6a1c 100644
--- a/srcpkgs/pqiv/template
+++ b/srcpkgs/pqiv/template
@@ -1,7 +1,7 @@
 # Template file for 'pqiv'
 pkgname=pqiv
 version=2.12
-revision=1
+revision=2
 build_style=gnu-makefile
 hostmakedepends="pkg-config"
 makedepends="glib-devel gtk+3-devel $(vopt_if ffmpeg ffmpeg-devel)

From fe933519763f5a0560239726df5da8b30debe1ee Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 056/113] qmmp: revbump for ffmpeg6

---
 srcpkgs/qmmp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qmmp/template b/srcpkgs/qmmp/template
index 53781ea3bc28a..2da07f1e87eac 100644
--- a/srcpkgs/qmmp/template
+++ b/srcpkgs/qmmp/template
@@ -1,7 +1,7 @@
 # Template file for 'qmmp'
 pkgname=qmmp
 version=1.6.1
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DUSE_HAL:BOOL=FALSE -DQMMP_DEFAULT_UI:STRING=simple"
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From ec72fa3ae123a6b94ffbc9d73d0c0da4fa7e0120 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 14 Dec 2023 13:28:10 -0500
Subject: [PATCH 057/113] qt6-pdf: revbump for ffmpeg6

---
 srcpkgs/qt6-pdf/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-pdf/template b/srcpkgs/qt6-pdf/template
index ecda84afac131..531b4e1d4fe84 100644
--- a/srcpkgs/qt6-pdf/template
+++ b/srcpkgs/qt6-pdf/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-pdf'
 pkgname=qt6-pdf
 version=6.6.0
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DQT_FEATURE_qtpdf_build=ON
  -DQT_FEATURE_qtpdf_widgets_build=ON

From 9d7a840c9d89bc4ca0a4794049ef106eb2b58d14 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 058/113] qt5-webengine: revbump for ffmpeg6

---
 .../chromium-media-filters-cpp14.patch        |  11 ++
 srcpkgs/qt5-webengine/patches/ffmpeg5.patch   | 179 ++++++++++++++++++
 .../qtwebengine-fix-ffmpeg5-build.patch       |  14 ++
 srcpkgs/qt5-webengine/template                |   4 +-
 4 files changed, 206 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/ffmpeg5.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch

diff --git a/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
new file mode 100644
index 0000000000000..04adc540f2cbc
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
@@ -0,0 +1,11 @@
+--- a/src/3rdparty/chromium/media/filters/BUILD.gn	2023-02-27 13:32:59.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/BUILD.gn	2023-04-02 17:21:39.204066384 -0400
+@@ -96,6 +96,8 @@
+     "//ui/gfx/geometry:geometry",
+   ]
+ 
++  cflags_cc = [ "-std=c++14" ]
++
+   libs = []
+ 
+   if (proprietary_codecs) {
diff --git a/srcpkgs/qt5-webengine/patches/ffmpeg5.patch b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..ac55e1634423a
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
@@ -0,0 +1,179 @@
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:57.732547446 -0400
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:09.486478995 -0400
+@@ -57,6 +57,8 @@
+ 
+ namespace {
+ 
++constexpr int64_t kRelativeTsBase = static_cast<int64_t>(0x7ffeffffffffffff);
++
+ void SetAVStreamDiscard(AVStream* stream, AVDiscard discard) {
+   DCHECK(stream);
+   stream->discard = discard;
+@@ -90,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+   if (stream->start_time != kNoFFmpegTimestamp)
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (stream->first_dts != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, stream->first_dts);
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -408,11 +398,11 @@
+   scoped_refptr<DecoderBuffer> buffer;
+ 
+   if (type() == DemuxerStream::TEXT) {
+-    int id_size = 0;
++    size_t id_size = 0;
+     uint8_t* id_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
+ 
+-    int settings_size = 0;
++    size_t settings_size = 0;
+     uint8_t* settings_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
+ 
+@@ -424,7 +414,7 @@
+     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
+                                      side_data.data(), side_data.size());
+   } else {
+-    int side_data_size = 0;
++    size_t side_data_size = 0;
+     uint8_t* side_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
+ 
+@@ -485,7 +475,7 @@
+                                        packet->size - data_offset);
+     }
+ 
+-    int skip_samples_size = 0;
++    size_t skip_samples_size = 0;
+     const uint32_t* skip_samples_ptr =
+         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
+             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
+@@ -1587,6 +1577,8 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++      continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+       lowest_start_time_stream = stream.get();
+@@ -1604,6 +1596,8 @@
+     if (stream && stream->type() == DemuxerStream::VIDEO &&
+         stream->IsEnabled()) {
+       video_stream = stream.get();
++      if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++        continue;
+       if (video_stream->start_time() <= seek_time) {
+         return video_stream;
+       }
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h qtwebengine-5.15.10/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h
+--- a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-07-11 22:12:47.917192788 -0500
+@@ -29,6 +29,7 @@ extern "C" {
+ #include <libavformat/avformat.h>
+ #include <libavformat/avio.h>
+ #include <libavutil/avutil.h>
++#include <libavutil/channel_layout.h>
+ #include <libavutil/imgutils.h>
+ #include <libavutil/log.h>
+ #include <libavutil/mastering_display_metadata.h>
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/audio_file_reader.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/audio_file_reader.cc
+--- a/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -85,7 +85,7 @@ bool AudioFileReader::OpenDemuxer() {
+ }
+ 
+ bool AudioFileReader::OpenDecoder() {
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (codec) {
+     // MP3 decodes to S16P which we don't support, tell it to use S16 instead.
+     if (codec_context_->sample_fmt == AV_SAMPLE_FMT_S16P)
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -329,7 +329,7 @@ bool FFmpegAudioDecoder::ConfigureDecode
+     }
+   }
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec ||
+       avcodec_open2(codec_context_.get(), codec, &codec_options) < 0) {
+     DLOG(ERROR) << "Could not initialize audio decoder: "
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -59,7 +59,6 @@ static int64_t AVIOSeekOperation(void* o
+ }
+ 
+ void FFmpegGlue::InitializeFFmpeg() {
+-  av_register_all();
+ }
+ 
+ static void LogContainer(bool is_local_file,
+@@ -95,9 +94,6 @@ FFmpegGlue::FFmpegGlue(FFmpegURLProtocol
+   // Enable fast, but inaccurate seeks for MP3.
+   format_context_->flags |= AVFMT_FLAG_FAST_SEEK;
+ 
+-  // Ensures we can read out various metadata bits like vp8 alpha.
+-  format_context_->flags |= AVFMT_FLAG_KEEP_SIDE_DATA;
+-
+   // Ensures format parsing errors will bail out. From an audit on 11/2017, all
+   // instances were real failures. Solves bugs like http://crbug.com/710791.
+   format_context_->error_recognition |= AV_EF_EXPLODE;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -391,7 +391,7 @@ bool FFmpegVideoDecoder::ConfigureDecode
+   if (decode_nalus_)
+     codec_context_->flags2 |= AV_CODEC_FLAG2_CHUNKS;
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
+     ReleaseFFmpegResources();
+     return false;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/media_file_checker.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/media_file_checker.cc
+--- a/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -68,7 +68,7 @@ bool MediaFileChecker::Start(base::TimeD
+       auto context = AVStreamToAVCodecContext(format_context->streams[i]);
+       if (!context)
+         continue;
+-      AVCodec* codec = avcodec_find_decoder(cp->codec_id);
++      const AVCodec* codec = avcodec_find_decoder(cp->codec_id);
+       if (codec && avcodec_open2(context.get(), codec, nullptr) >= 0) {
+         auto loop = std::make_unique<FFmpegDecodingLoop>(context.get());
+         stream_contexts[i] = {std::move(context), std::move(loop)};
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc qtwebengine-5.15.10/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc
+--- a/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -203,7 +203,7 @@ int32_t H264DecoderImpl::InitDecode(cons
+   // a pointer |this|.
+   av_context_->opaque = this;
+ 
+-  AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
+   if (!codec) {
+     // This is an indication that FFmpeg has not been initialized or it has not
+     // been compiled/initialized with the correct set of codecs.
diff --git a/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch b/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch
new file mode 100644
index 0000000000000..bc24d5b9a29cb
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch
@@ -0,0 +1,14 @@
+--- a/src/buildtools/configure.json	2023-12-09 11:06:01.503058569 -0500
++++ b/src/buildtools/configure.json	2023-12-09 11:06:14.982361345 -0500
+@@ -779,11 +779,6 @@
+             "type": "warning",
+             "condition": "config.ios && config.simulator && config.device && features.build-qtpdf",
+             "message": "Building fat libray with device and simulator architectures will disable NEON."
+-        },
+-        {
+-            "type": "fatal",
+-            "condition": "features.webengine-system-ffmpeg && !libs.webengine-ffmpeg-support",
+-            "message": "Unmodified ffmpeg >= 5.0 is not supported. Please configure with -qt-webengine-ffmpeg."
+         }
+     ],
+     "summary": [
diff --git a/srcpkgs/qt5-webengine/template b/srcpkgs/qt5-webengine/template
index 8d2df1b5175ba..1687a77eb8a2f 100644
--- a/srcpkgs/qt5-webengine/template
+++ b/srcpkgs/qt5-webengine/template
@@ -1,14 +1,14 @@
 # Template file for 'qt5-webengine'
 pkgname=qt5-webengine
 version=5.15.16
-revision=1
+revision=2
 _version="${version}-lts"
 _chromium_commit=207c2ac45ca3386d153770c6b0d2ea2ec21ca880
 archs="x86_64* i686* armv[67]* ppc64* aarch64*"
 create_wrksrc=yes
 build_style=qmake
 configure_args="--
- -webengine-icu -webengine-ffmpeg -webengine-opus -webengine-webp
+ -webengine-icu -system-ffmpeg -webengine-opus -webengine-webp
  -webengine-pepper-plugins -webengine-printing-and-pdf -webengine-proprietary-codecs
  -webengine-pulseaudio -webengine-spellchecker -webengine-webrtc -webengine-geolocation
  -webengine-kerberos -no-webengine-embedded-build $(vopt_if sndio '' '-no')-webengine-sndio

From e88961c753894c1a1287ee818b4afc4ef3195afb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 059/113] qt5: revbump for ffmpeg6

---
 srcpkgs/qt5/template | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/srcpkgs/qt5/template b/srcpkgs/qt5/template
index ef6e437e02dbc..97b7818cc37d8 100644
--- a/srcpkgs/qt5/template
+++ b/srcpkgs/qt5/template
@@ -3,9 +3,9 @@
 # revbump libqtxdg after bumping patch version
 pkgname=qt5
 version=5.15.11+20231124
+revision=2
 # commit 4765fa1df7a837db9c1f89c4da0dd76b74bb5fab
 # base repo: https://invent.kde.org/qt/qt/qt5
-revision=1
 build_style=meta
 hostmakedepends="cmake clang flex perl glib-devel pkg-config
  python3 re2c ruby which"
@@ -246,7 +246,6 @@ do_configure() {
 	# opts+=" -v"
 	opts+=" -skip qtwebengine"
 	opts+=" -skip qtwebview"
-	opts+=" -skip qtdocgallery"
 	opts+=" -skip qtpim"
 	opts+=" -skip qtsystems"
 	opts+=" -skip qtspeech"

From 5292c7a31e078cdf4edec114b0f74b973579c0b9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 060/113] qtav: revbump for ffmpeg4

---
 srcpkgs/qtav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qtav/template b/srcpkgs/qtav/template
index 775d5a139a9ef..2d00ad104355e 100644
--- a/srcpkgs/qtav/template
+++ b/srcpkgs/qtav/template
@@ -4,7 +4,7 @@ version=1.13.0
 revision=2
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel libass-devel libopenal-devel
+makedepends="ffmpeg4-devel libass-devel libopenal-devel
  libva-glx-devel libXv-devel pulseaudio-devel
  qt5-declarative-devel qt5-svg-devel
  qt5-quickcontrols"

From 02a95898cbcbd0403f8472d088016656063701f0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 061/113] retroarch: revbump for ffmpeg6

---
 srcpkgs/retroarch/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroarch/template b/srcpkgs/retroarch/template
index cb3125c5dbf1a..c65c26f7bf033 100644
--- a/srcpkgs/retroarch/template
+++ b/srcpkgs/retroarch/template
@@ -1,7 +1,7 @@
 # Template file for 'retroarch'
 pkgname=retroarch
 version=1.16.0.3
-revision=3
+revision=4
 build_style=configure
 configure_args="--prefix=/usr --sysconfdir=/etc --enable-networking
  --enable-udev --disable-builtinflac --disable-builtinglslang

From 64d71e415192fa5b95df41a24c22befbb421c174 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 062/113] scrcpy: revbump for ffmpeg6

---
 srcpkgs/scrcpy/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/scrcpy/template b/srcpkgs/scrcpy/template
index ac18bc03418ce..f39a7f678ab35 100644
--- a/srcpkgs/scrcpy/template
+++ b/srcpkgs/scrcpy/template
@@ -1,7 +1,7 @@
 # Template file for 'scrcpy'
 pkgname=scrcpy
 version=2.1.1
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcompile_server=false
  -Dprebuilt_server=/usr/share/scrcpy/scrcpy-server-v${version}"

From bc179d8911c638b4d3f09954732b9fa5d22b9337 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 17 Oct 2023 08:54:11 -0400
Subject: [PATCH 063/113] New package: spex-x replaces spek-alternative for
 ffmpeg6

---
 srcpkgs/spek-alternative                      |  1 +
 srcpkgs/{spek-alternative => spek-x}/template | 22 ++++++++++++-------
 2 files changed, 15 insertions(+), 8 deletions(-)
 create mode 120000 srcpkgs/spek-alternative
 rename srcpkgs/{spek-alternative => spek-x}/template (52%)

diff --git a/srcpkgs/spek-alternative b/srcpkgs/spek-alternative
new file mode 120000
index 0000000000000..76648236da701
--- /dev/null
+++ b/srcpkgs/spek-alternative
@@ -0,0 +1 @@
+spek-x
\ No newline at end of file
diff --git a/srcpkgs/spek-alternative/template b/srcpkgs/spek-x/template
similarity index 52%
rename from srcpkgs/spek-alternative/template
rename to srcpkgs/spek-x/template
index d7b55c776b1d4..3ded6c2c323e4 100644
--- a/srcpkgs/spek-alternative/template
+++ b/srcpkgs/spek-x/template
@@ -1,18 +1,18 @@
-# Template file for 'spek-alternative'
-pkgname=spek-alternative
-version=0.8.2.3
-revision=2
+# Template file for 'spek-x'
+pkgname=spek-x
+version=0.9.3
+revision=1
 build_style=gnu-configure
 hostmakedepends="automake gettext-devel intltool libtool pkg-config
  wxWidgets-common wxWidgets-gtk3-devel"
 makedepends="ffmpeg-devel wxWidgets-gtk3-devel"
 depends="ffmpeg"
 short_desc="Acoustic spectrum analyser"
-maintainer="Kartik Singh <kartik.ynwa@gmail.com>"
+maintainer="zlice <zlice555@gmail.com>"
 license="GPL-3.0-or-later"
-homepage="https://github.com/withmorten/spek-alternative"
-distfiles="https://github.com/withmorten/spek-alternative/archive/${version}.tar.gz"
-checksum="007ba4b84a310b078e378aa84c8e80783db5821437a757a488c3ecec377e6b2a"
+homepage="https://github.com/MikeWang000000/spek-x"
+distfiles="https://github.com/MikeWang000000/spek-x/archive/v${version}.tar.gz"
+checksum="7f4b109903333cdd310ab2b9176f0dc49a565891376e281a233d342cedf90ef7"
 
 CXXFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
 
@@ -22,3 +22,9 @@ export WX_CONFIG_NAME="wx-config-gtk3"
 pre_configure() {
 	NOCONFIGURE=1 ./autogen.sh
 }
+
+spek-alternative_package() {
+	depends="spek-x"
+	short_desc+=" - transitional dummy package"
+	build_style=meta
+}

From 0ce88ee0f0222a9c6503f810e3068d6764cb1601 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 064/113] ssr: revbump for ffmpeg4

---
 srcpkgs/ssr/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ssr/template b/srcpkgs/ssr/template
index 3097754e3cbe5..fa66d5b4736d4 100644
--- a/srcpkgs/ssr/template
+++ b/srcpkgs/ssr/template
@@ -5,7 +5,7 @@ revision=2
 build_style=cmake
 configure_args="-DWITH_QT5=ON"
 hostmakedepends="pkg-config"
-makedepends="alsa-lib-devel ffmpeg-devel glu-devel jack-devel pulseaudio-devel
+makedepends="alsa-lib-devel ffmpeg4-devel glu-devel jack-devel pulseaudio-devel
  qt5-tools-devel qt5-x11extras-devel libXinerama-devel v4l-utils-devel"
 depends="desktop-file-utils hicolor-icon-theme"
 short_desc="Simple Screen Recorder for programs and games"

From ae561fb72e9685f3492ed733104b93cbe84d6dbf Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 065/113] synfig: revbump for ffmpeg6 and mlt7

---
 srcpkgs/synfig/patches/ffmpeg6.patch | 71 ++++++++++++++++++++++++++++
 srcpkgs/synfig/template              |  4 +-
 2 files changed, 73 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/synfig/patches/ffmpeg6.patch

diff --git a/srcpkgs/synfig/patches/ffmpeg6.patch b/srcpkgs/synfig/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..10780b42782f4
--- /dev/null
+++ b/srcpkgs/synfig/patches/ffmpeg6.patch
@@ -0,0 +1,71 @@
+--- a/src/modules/mod_libavcodec/trgt_av.cpp	2022-10-25 09:14:12.000000000 -0400
++++ b/src/modules/mod_libavcodec/trgt_av.cpp	2023-05-05 21:34:17.899194559 -0400
+@@ -38,6 +41,7 @@
+ extern "C"
+ {
+ #ifdef HAVE_LIBAVFORMAT_AVFORMAT_H
++#	include <libavcodec/avcodec.h>
+ #	include <libavformat/avformat.h>
+ #elif defined(HAVE_AVFORMAT_H)
+ #	include <avformat.h>
+@@ -155,11 +156,11 @@
+     }
+ 
+ 	bool open_video_stream() {
+-		if (avcodec_open2(video_context, NULL, NULL) < 0) {
++		if (avcodec_open2(video_context, nullptr, nullptr) < 0) {
+ 			synfig::error("Target_LibAVCodec: could not open video codec");
+ 			// seems the calling of avcodec_free_context after error will cause crash
+ 			// so just forget about this context
+-			video_context = NULL;
++			video_context = nullptr;
+ 			close();
+ 			return false;
+         }
+@@ -234,15 +235,21 @@
+ 		close();
+ 
+ 		if (!av_registered) {
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 			av_register_all();
++#endif
+ 			av_registered = true;
+ 		}
+ 
+ 		// guess format
+-		AVOutputFormat *format = av_guess_format(NULL, filename.c_str(), NULL);
++#if LIBAVCODEC_VERSION_MAJOR < 59 // FFMPEG < 5.0
++		AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#else
++		const AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#endif
+ 		if (!format) {
+ 			synfig::warning("Target_LibAVCodec: unable to guess the output format, defaulting to MPEG");
+-			format = av_guess_format("mpeg", NULL, NULL);
++			format = av_guess_format("mpeg", nullptr, nullptr);
+ 		}
+ 		if (!format) {
+ 			synfig::error("Target_LibAVCodec: unable to find 'mpeg' output format");
+@@ -254,6 +261,7 @@
+ 		context = avformat_alloc_context();
+ 		assert(context);
+ 		context->oformat = format;
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 		if (filename.size() + 1 > sizeof(context->filename)) {
+ 			synfig::error(
+ 				"Target_LibAVCodec: filename too long, max length is %d, filename is '%s'",
+@@ -263,6 +271,14 @@
+ 			return false;
+ 		}
+ 		memcpy(context->filename, filename.c_str(), filename.size() + 1);
++#else
++		context->url = av_strndup(filename.c_str(), filename.size());
++		if (!context->url) {
++			synfig::error("Target_LibAVCodec: cannot allocate space for filename");
++			close();
++			return false;
++		}
++#endif
+ 
+ 		packet = av_packet_alloc();
+ 		assert(packet);
diff --git a/srcpkgs/synfig/template b/srcpkgs/synfig/template
index d4d3e341a20bf..703cfd7ebac84 100644
--- a/srcpkgs/synfig/template
+++ b/srcpkgs/synfig/template
@@ -6,7 +6,7 @@ revision=4
 build_style=gnu-configure
 configure_args="--with-boost-libdir=${XBPS_CROSS_BASE}/usr/lib"
 hostmakedepends="boost-build ImageMagick pkg-config intltool"
-makedepends="ETL gettext-devel libxml++-devel mlt-devel libmagick-devel
+makedepends="ETL gettext-devel libxml++-devel mlt7-devel libmagick-devel
  libmng-devel boost-build boost-devel libopenexr-devel ffmpeg-devel"
 depends="ImageMagick"
 short_desc="CLI 2D vector and timeline-based animation software"
@@ -20,7 +20,7 @@ CXXFLAGS="-std=c++11 -DHAVE_LOCALE_H=1"
 
 synfig-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision}
-	 libopenexr-devel libxml++-devel mlt-devel"
+	 libopenexr-devel libxml++-devel mlt7-devel"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/bin/synfig-config

From 6203b95662ffc2d75bd8668ab8daee4f696ddd88 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 066/113] timg: revbump for ffmpeg6

---
 srcpkgs/timg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/timg/template b/srcpkgs/timg/template
index 2a2ab763d2fdd..8fb4327535ef9 100644
--- a/srcpkgs/timg/template
+++ b/srcpkgs/timg/template
@@ -1,7 +1,7 @@
 # Template file for 'timg'
 pkgname=timg
 version=1.4.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_OPENSLIDE_SUPPORT=off -Wno-dev"
 hostmakedepends="pkg-config git"

From bf0bb81f65b15e37325c382a7a275a991a9f3c5f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 067/113] tvheadend: revbump for ffmpeg4

---
 srcpkgs/tvheadend/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tvheadend/template b/srcpkgs/tvheadend/template
index 9aea7de4ec705..012d31c4879ff 100644
--- a/srcpkgs/tvheadend/template
+++ b/srcpkgs/tvheadend/template
@@ -8,7 +8,7 @@ configure_args="--enable-dvbscan --disable-ffmpeg_static
 --disable-libx265_static --disable-libvpx_static --disable-libtheora_static
 --disable-libvorbis_static --disable-libfdkaac_static"
 hostmakedepends="gettext pkg-config python3 git which"
-makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg-devel"
+makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg4-devel"
 short_desc="TV streaming server"
 maintainer="lemmi <lemmi@nerd2nerd.org>"
 license="GPL-3.0-only"

From cc967e52333e42641cf32dc6f62affe7d180ad98 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 068/113] unpaper: update to 7.0.0.

---
 srcpkgs/unpaper/template | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/srcpkgs/unpaper/template b/srcpkgs/unpaper/template
index 38ed47a584016..1ff910e722afc 100644
--- a/srcpkgs/unpaper/template
+++ b/srcpkgs/unpaper/template
@@ -1,13 +1,13 @@
 # Template file for 'unpaper'
 pkgname=unpaper
-version=6.1
-revision=3
-build_style=gnu-configure
+version=7.0.0
+revision=1
+build_style=meson
+hostmakedepends="pkg-config meson libxslt"
+makedepends="ffmpeg-devel python3-Sphinx"
+short_desc="Post-processing tool for scanned sheets of paper"
 maintainer="Orphaned <orphan@voidlinux.org>"
-hostmakedepends="pkg-config libxslt"
-makedepends="ffmpeg-devel"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://www.flameeyes.eu/projects/unpaper"
-short_desc="A post-processing tool for scanned sheets of paper"
 distfiles="https://www.flameeyes.eu/files/${pkgname}-${version}.tar.xz"
-checksum=237c84f5da544b3f7709827f9f12c37c346cdf029b1128fb4633f9bafa5cb930
+checksum=2575fbbf26c22719d1cb882b59602c9900c7f747118ac130883f63419be46a80

From e888a09125bbdfc762ebfbd336a6c742328d11fe Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 069/113] vice: revbump for ffmpeg4

---
 srcpkgs/vice/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vice/template b/srcpkgs/vice/template
index b1f866d35095e..4beab2c5f9ebd 100644
--- a/srcpkgs/vice/template
+++ b/srcpkgs/vice/template
@@ -26,7 +26,7 @@ makedepends="
 	$(vopt_if gtk3 gtk+3-devel)
 	$(vopt_if gtk3 pulseaudio-devel)
 	$(vopt_if gtk3 pango-devel)
-	$(vopt_if ffmpeg ffmpeg-devel)"
+	$(vopt_if ffmpeg ffmpeg4-devel)"
 short_desc="Emulator for C64, C128, CBM-II, PET, VIC20, Plus4 and C16"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"

From 9630553f7cd8e1cec99482924511dfe151fd817f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 070/113] waypipe: revbump for ffmpeg6

---
 srcpkgs/waypipe/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waypipe/template b/srcpkgs/waypipe/template
index 6da88b21bf2a1..4da8058400b58 100644
--- a/srcpkgs/waypipe/template
+++ b/srcpkgs/waypipe/template
@@ -1,7 +1,7 @@
 # Template file for 'waypipe'
 pkgname=waypipe
 version=0.8.6
-revision=1
+revision=2
 build_style=meson
 # lto is off because it causes linking errors in armv6l and armv7l (due to NEON)
 configure_args="-Dwerror=false -Dwith_dmabuf=enabled -Dwith_lz4=enabled

From 07c29af41dfe0cbc29ee1fd9cafea3880100b7fd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 071/113] xpra: revbump for ffmpeg6

---
 srcpkgs/xpra/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xpra/template b/srcpkgs/xpra/template
index 6bfe9be2db650..1eea2962bcb82 100644
--- a/srcpkgs/xpra/template
+++ b/srcpkgs/xpra/template
@@ -1,7 +1,7 @@
 # Template file for 'xpra'
 pkgname=xpra
 version=5.0.4
-revision=1
+revision=2
 build_style=python3-module
 make_build_args="--without-cuda_kernels --without-cuda_rebuild"
 make_install_args="$(vopt_with docs) ${make_build_args}"

From a29206fe6ee234cf4e9cc1fdbe8feff0b90e614b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:07:40 -0400
Subject: [PATCH 072/113] nv-codec-headers: update to 12.0.16.0

---
 srcpkgs/nv-codec-headers/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/nv-codec-headers/template b/srcpkgs/nv-codec-headers/template
index 3d422a61e4891..251e057f826fb 100644
--- a/srcpkgs/nv-codec-headers/template
+++ b/srcpkgs/nv-codec-headers/template
@@ -1,6 +1,6 @@
 # Template file for 'nv-codec-headers'
 pkgname=nv-codec-headers
-version=11.1.5.1
+version=12.0.16.0
 revision=1
 build_style=gnu-makefile
 short_desc="FFmpeg version of headers required to interface with Nvidias codec APIs"
@@ -8,7 +8,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="MIT"
 homepage="http://git.videolan.org/?p=ffmpeg/nv-codec-headers.git"
 distfiles="https://github.com/FFmpeg/nv-codec-headers/archive/n${version}.tar.gz"
-checksum=d095fbd56aa93772471a323be0ebe65504a0f43f06c76a30b6d25da77b06ae9c
+checksum=2a1533b65f55f9da52956faf0627ed3b74868ac0c7f269990edd21369113b48f
 
 post_install() {
 	sed -n '4,25p' include/ffnvcodec/nvEncodeAPI.h > LICENSE

From 7ad65d0f36a9a87491ce632767bcd56a8f838950 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:08:40 -0400
Subject: [PATCH 073/113] openimagedenoise: revbump for ffmpeg6

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index b792813dba7c2..109deb171c3f7 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,7 +1,7 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
 version=1.4.3
-revision=1
+revision=2
 archs="x86_64*"
 build_style=cmake
 hostmakedepends="ispc python3"

From 7e7f062454d517552bf335e5d2f7010a9de4c190 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:31:45 -0400
Subject: [PATCH 074/113] shotcut: revbump for ffmpeg6

---
 srcpkgs/shotcut/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/shotcut/template b/srcpkgs/shotcut/template
index 33141fbd862d7..f46cb53b6bfb9 100644
--- a/srcpkgs/shotcut/template
+++ b/srcpkgs/shotcut/template
@@ -1,7 +1,7 @@
 # Template file for 'shotcut'
 pkgname=shotcut
 version=23.09.29
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSHOTCUT_VERSION=${version}"
 hostmakedepends="pkg-config qt6-tools-devel"

From f22d9bb28bf9a391af6fe93e0287c38ee49ca757 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:30 -0400
Subject: [PATCH 075/113] shiboken2: revbump for qt5-5.15.11

---
 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch | 1 +
 srcpkgs/shiboken2/template                                 | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
 create mode 120000 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
new file mode 120000
index 0000000000000..efcf3249bd885
--- /dev/null
+++ b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1 @@
+../../python3-pyside2/patches/importlib-machinery-bypass.patch
\ No newline at end of file
diff --git a/srcpkgs/shiboken2/template b/srcpkgs/shiboken2/template
index 883d6a084d868..f3c06ec245a1f 100644
--- a/srcpkgs/shiboken2/template
+++ b/srcpkgs/shiboken2/template
@@ -1,7 +1,7 @@
 # Template file for 'shiboken2'
 pkgname=shiboken2
 version=5.15.10
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/shiboken2"
 build_style=cmake

From 8ce974b71c6aeb4406df10da40b05b4203800c85 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:53 -0400
Subject: [PATCH 076/113] python3-pyside2: revbump for qt5-5.15.11

---
 .../patches/importlib-machinery-bypass.patch      | 15 +++++++++++++++
 srcpkgs/python3-pyside2/template                  |  2 +-
 2 files changed, 16 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
new file mode 100644
index 0000000000000..64c429584776b
--- /dev/null
+++ b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1,15 @@
+Using this prevents an error around line 220 below it.
+"AttributeError: module 'importlib' has no attribute 'machinery'"
+The old backup logic is in place and compiles without issues.
+--- a/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:09:34.688912402 -0400
++++ b/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:10:03.395529582 -0400
+@@ -170,9 +170,6 @@
+
+     # 'zipstring_sequence' comes from signature.cpp
+     zipbytes = base64.b64decode(''.join(zipstring_sequence))
+-    if sys.version_info[0] >= 3:
+-        vzip = zipfile.ZipFile(io.BytesIO(zipbytes))
+-        return sys.meta_path, EmbeddableZipImporter(vzip)
+
+     # Old version for Python 2.7, only.
+     import os
diff --git a/srcpkgs/python3-pyside2/template b/srcpkgs/python3-pyside2/template
index 249efa9098842..52626436ce75f 100644
--- a/srcpkgs/python3-pyside2/template
+++ b/srcpkgs/python3-pyside2/template
@@ -1,7 +1,7 @@
 # Template file for 'python3-pyside2'
 pkgname=python3-pyside2
 version=5.15.10
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/pyside2"
 build_style=cmake

From 1b51946e1927ab50b587d794477e8108bc000cba Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:35 -0400
Subject: [PATCH 077/113] konqueror: revbump for ffmpeg6

---
 srcpkgs/konqueror/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/konqueror/template b/srcpkgs/konqueror/template
index 044dafa605ba6..63dd01fafc780 100644
--- a/srcpkgs/konqueror/template
+++ b/srcpkgs/konqueror/template
@@ -1,11 +1,11 @@
 # Template file for 'konqueror'
 pkgname=konqueror
 version=23.08.4
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DDESKTOPTOJSON_EXECUTABLE=/usr/bin/desktoptojson"
 hostmakedepends="extra-cmake-modules python3 qt5-host-tools qt5-qmake kdoctools
-kcoreaddons kconfig gettext"
+ kcoreaddons kconfig gettext"
 makedepends="qt5-devel qt5-webengine-devel qt5-declarative-devel
  qt5-webchannel-devel qt5-location-devel kcmutils-devel kdelibs4support-devel
  karchive-devel khtml-devel kdesu-devel kactivities5-devel"

From b5050dfd3160aab4d9c8010176c5bb1848816188 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:58 -0400
Subject: [PATCH 078/113] qt5-speech: revbump for qt5-5.15.11

---
 srcpkgs/qt5-speech/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-speech/template b/srcpkgs/qt5-speech/template
index 1228bb60c41db..27a7da1dbdb91 100644
--- a/srcpkgs/qt5-speech/template
+++ b/srcpkgs/qt5-speech/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-speech'
 pkgname=qt5-speech
 version=5.15.11
-revision=1
+revision=2
 _commit=d32f4a479d38a11f547598004b975f4356424a16
 build_style=qmake
 configure_args="-- -flite -flite-alsa -speechd"

From 5bd68e26c274add3b7d0550a70d11eb6a849c9d8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Jun 2023 08:20:22 -0400
Subject: [PATCH 079/113] gtk4: revbump for ffmpeg6

---
 srcpkgs/gtk4/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gtk4/template b/srcpkgs/gtk4/template
index d8ee60abe06f7..55bff6e33849a 100644
--- a/srcpkgs/gtk4/template
+++ b/srcpkgs/gtk4/template
@@ -1,7 +1,7 @@
 # Template file for 'gtk4'
 pkgname=gtk4
 version=4.12.3
-revision=1
+revision=2
 build_style=meson
 build_helper="gir"
 configure_args="-Dman-pages=true -Ddocumentation=true -Dbuild-tests=false

From b03c792ca55c95c190aa8f17d41574811b3a4954 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:28:26 -0400
Subject: [PATCH 080/113] siril: revbump for ffmpeg6

---
 srcpkgs/siril/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/siril/template b/srcpkgs/siril/template
index 84332f79d060d..62750dd247548 100644
--- a/srcpkgs/siril/template
+++ b/srcpkgs/siril/template
@@ -1,7 +1,7 @@
 # Template file for 'siril'
 pkgname=siril
 version=0.9.12
-revision=10
+revision=11
 build_style=gnu-configure
 hostmakedepends="pkg-config intltool autoconf automake gettext-devel"
 makedepends="fftw-devel libconfig-devel libopencv-devel libffms2-devel

From a73c4c88f471afc2f54d7e8da4a91aa0f045de30 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 22 Jun 2023 10:25:02 -0400
Subject: [PATCH 081/113] kdenlive: revbump for ffmpeg6

---
 srcpkgs/kdenlive/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kdenlive/template b/srcpkgs/kdenlive/template
index a0f3615c9c530..d63166f95c4d7 100644
--- a/srcpkgs/kdenlive/template
+++ b/srcpkgs/kdenlive/template
@@ -1,7 +1,7 @@
 # Template file for 'kdenlive'
 pkgname=kdenlive
 version=23.08.4
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="
  extra-cmake-modules kconfig kcoreaddons kdoctools pkg-config python3

From 898fb8ec13000c557a8978abbb53efe4b29cd5b1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:20:59 -0400
Subject: [PATCH 082/113] tracker-miners: revbump for ffmpeg6

---
 srcpkgs/tracker-miners/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tracker-miners/template b/srcpkgs/tracker-miners/template
index 0b97f47489f81..f196d2bf9e4a4 100644
--- a/srcpkgs/tracker-miners/template
+++ b/srcpkgs/tracker-miners/template
@@ -1,7 +1,7 @@
 # Template file for 'tracker-miners'
 pkgname=tracker-miners
 version=3.6.1
-revision=1
+revision=2
 build_style=meson
 build_helper=qemu
 # missing libgrss for miner_rss

From 09bf14ce7fb7adbf537b8a7e984e41655487646f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:21:21 -0400
Subject: [PATCH 083/113] mpd: revbump for ffmpeg6

---
 srcpkgs/mpd/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpd/template b/srcpkgs/mpd/template
index 4fd32b7be8c53..b8e2bd4c1b59c 100644
--- a/srcpkgs/mpd/template
+++ b/srcpkgs/mpd/template
@@ -1,7 +1,7 @@
 # Template file for 'mpd'
 pkgname=mpd
 version=0.23.15
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dopus=enabled -Dmikmod=enabled -Dneighbor=true
  -Dsoundcloud=enabled -Dpipe=true -Dtwolame=enabled -Dbzip2=enabled

From 8a1f243318e40ad92f8ba233ccf5d00186b133d8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:02 -0400
Subject: [PATCH 084/113] tg_owt: revbump for ffmpeg6

---
 srcpkgs/tg_owt/template | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/srcpkgs/tg_owt/template b/srcpkgs/tg_owt/template
index aee8d35d08ffb..563ed9a5835c4 100644
--- a/srcpkgs/tg_owt/template
+++ b/srcpkgs/tg_owt/template
@@ -1,8 +1,7 @@
 # Template file for 'tg_owt'
 pkgname=tg_owt
 version=0.0.0.20231221
-revision=1
-_commit=afd9d5d31798d3eacf9ed6c30601e91d0f1e4d60
+revision=2
 _libyuv_commit=04821d1e7d60845525e8db55c7bcd41ef5be9406
 _abseil_commit=8c0b94e793a66495e0b1f34a5eb26bd7dc672db0
 _crc32c_commit=21fc8ef30415a635e7351ffa0e5d5367943d4a94

From 7575c2bebd950ec56f7da9f3b824224d5c0610db Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:44 -0400
Subject: [PATCH 085/113] telegram-desktop: revbump for ffmpeg6

---
 srcpkgs/telegram-desktop/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/telegram-desktop/template b/srcpkgs/telegram-desktop/template
index 48ccb9a9d840a..c8756611e2b3b 100644
--- a/srcpkgs/telegram-desktop/template
+++ b/srcpkgs/telegram-desktop/template
@@ -1,7 +1,7 @@
 # Template file for 'telegram-desktop'
 pkgname=telegram-desktop
 version=4.14.2
-revision=1
+revision=2
 build_style=cmake
 build_helper="qemu gir"
 configure_args="-DTDESKTOP_API_ID=209235

From eee8c433f03135adc6ec8b386f8739d12e07cdee Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:11:45 -0400
Subject: [PATCH 086/113] gst-plugins-bad1: revbump for ffmpeg6

---
 srcpkgs/gst-plugins-bad1/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index fcd3538cd5cde..976e2889b588e 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-plugins-bad1'
 pkgname=gst-plugins-bad1
 version=1.22.7
-revision=1
+revision=2
 build_helper="gir"
 build_style=meson
 configure_args="-Dpackage-origin=https://voidlinux.org -Ddoc=disabled

From 96130033e5869e4e2fe86fe7bd712961364718c3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:12:09 -0400
Subject: [PATCH 087/113] openmw: revbump for ffmpeg6

---
 srcpkgs/openmw/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openmw/template b/srcpkgs/openmw/template
index 0abf5ff7cdbec..b57180f1a4446 100644
--- a/srcpkgs/openmw/template
+++ b/srcpkgs/openmw/template
@@ -1,7 +1,7 @@
 # Template file for 'openmw'
 pkgname=openmw
 version=0.48.0
-revision=2
+revision=3
 build_style=cmake
 _recast_commit=e75adf86f91eb3082220085e42dda62679f9a3ea
 _bullet_tag=3.17

From 06248611b41257b37fd30b9588dada501ec703eb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:14:53 -0400
Subject: [PATCH 088/113] lms: revbump for ffmpeg6

---
 srcpkgs/lms/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/lms/template b/srcpkgs/lms/template
index e358f75902a98..3b21c458de519 100644
--- a/srcpkgs/lms/template
+++ b/srcpkgs/lms/template
@@ -1,7 +1,7 @@
 # Template file for 'lms'
 pkgname=lms
 version=3.42.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="wt-devel ffmpeg-devel boost-devel libconfig++-devel taglib-devel pam-devel libgraphicsmagick-devel gtest-devel libarchive-devel"

From 536b202a3b3c3d8cb8882a1cad48a37ac81043b9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:18:18 -0400
Subject: [PATCH 089/113] freecad: DELETE

---
 srcpkgs/freecad/patches/001-include.patch     | 112 ------------------
 .../154-revert-gui-tmp-redirect-stderr.patch  |  68 -----------
 ...d63c8c9b1280978be841d04e68a0a55cceb9.patch |  30 -----
 srcpkgs/freecad/template                      |  12 +-
 4 files changed, 7 insertions(+), 215 deletions(-)
 delete mode 100644 srcpkgs/freecad/patches/001-include.patch
 delete mode 100644 srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
 delete mode 100644 srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch

diff --git a/srcpkgs/freecad/patches/001-include.patch b/srcpkgs/freecad/patches/001-include.patch
deleted file mode 100644
index 28b5af54999b9..0000000000000
--- a/srcpkgs/freecad/patches/001-include.patch
+++ /dev/null
@@ -1,112 +0,0 @@
-From 9a41845a417189776741297c50a3827ce292bc4f Mon Sep 17 00:00:00 2001
-From: Uwe <donovaly@users.noreply.github.com>
-Date: Sun, 3 Jul 2022 22:51:16 +0200
-Subject: [PATCH] [Part] OCCError.h: remove unneeded includes
-
-- also sort includes
----
- src/Mod/Part/App/OCCError.h             | 36 +++----------------------
- src/Mod/Part/App/OffsetCurvePyImp.cpp   | 12 ++++-----
- src/Mod/Part/App/OffsetSurfacePyImp.cpp | 10 +++----
- 3 files changed, 12 insertions(+), 46 deletions(-)
-
---- a/src/Mod/Part/App/OCCError.h
-+++ b/src/Mod/Part/App/OCCError.h
-@@ -23,36 +23,8 @@
- #ifndef _OCCError_h_
- #define _OCCError_h_
- 
--# include <Standard_Version.hxx>
- # include <Standard_Failure.hxx>
--# include <Standard_AbortiveTransaction.hxx>
--# include <Standard_ConstructionError.hxx>
--# if OCC_VERSION_HEX >= 0x060500
--# include <Standard_DefineException.hxx>
--# endif
--# include <Standard_DimensionError.hxx>
--# include <Standard_DimensionMismatch.hxx>
--# include <Standard_DivideByZero.hxx>
--# include <Standard_DomainError.hxx>
--# include <Standard_ImmutableObject.hxx>
--# include <Standard_LicenseError.hxx>
--# include <Standard_LicenseNotFound.hxx>
--# include <Standard_MultiplyDefined.hxx>
--# include <Standard_NegativeValue.hxx>
--# include <Standard_NoMoreObject.hxx>
--# include <Standard_NoSuchObject.hxx>
--# include <Standard_NotImplemented.hxx>
--# include <Standard_NullObject.hxx>
--# include <Standard_NullValue.hxx>
--# include <Standard_NumericError.hxx>
--# include <Standard_OutOfMemory.hxx>
--# include <Standard_OutOfRange.hxx>
--# include <Standard_Overflow.hxx>
--# include <Standard_ProgramError.hxx>
--# include <Standard_RangeError.hxx>
--# include <Standard_TooManyUsers.hxx>
--# include <Standard_TypeMismatch.hxx>
--# include <Standard_Underflow.hxx>
-+# include <Standard_Version.hxx>
- 
- #include <Mod/Part/PartGlobal.h>
- #include <Base/Console.h>
-@@ -88,4 +60,3 @@ PartExport extern PyObject* PartExceptio
- 
- #define PY_CATCH_OCC _PY_CATCH_OCC(return(NULL))
- #endif  // _OCCError_h_
--
---- a/src/Mod/Part/App/OffsetCurvePyImp.cpp
-+++ b/src/Mod/Part/App/OffsetCurvePyImp.cpp
-@@ -20,20 +20,20 @@
-  *                                                                         *
-  ***************************************************************************/
- 
--
- #include "PreCompiled.h"
- #ifndef _PreComp_
- # include <Geom_OffsetCurve.hxx>
- #endif
- 
--#include "OCCError.h"
--#include "Geometry.h"
-+#include <Base/GeometryPyCXX.h>
-+#include <Base/Vector3D.h>
-+#include <Base/VectorPy.h>
-+
- #include "OffsetCurvePy.h"
- #include "OffsetCurvePy.cpp"
-+#include "Geometry.h"
-+#include "OCCError.h"
- 
--#include <Base/GeometryPyCXX.h>
--#include <Base/VectorPy.h>
--#include <Base/Vector3D.h>
- 
- using namespace Part;
- 
---- a/src/Mod/Part/App/OffsetSurfacePyImp.cpp
-+++ b/src/Mod/Part/App/OffsetSurfacePyImp.cpp
-@@ -20,20 +20,16 @@
-  *                                                                         *
-  ***************************************************************************/
- 
--
- #include "PreCompiled.h"
- #ifndef _PreComp_
- # include <Geom_OffsetSurface.hxx>
- # include <memory>
- #endif
- 
--#include <Base/VectorPy.h>
--#include <Base/Vector3D.h>
--
- #include "OCCError.h"
--#include "Geometry.h"
--#include <Mod/Part/App/OffsetSurfacePy.h>
--#include <Mod/Part/App/OffsetSurfacePy.cpp>
-+#include "OffsetSurfacePy.h"
-+#include "OffsetSurfacePy.cpp"
-+
- 
- using namespace Part;
- 
diff --git a/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch b/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
deleted file mode 100644
index d6a9adabdec83..0000000000000
--- a/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
+++ /dev/null
@@ -1,68 +0,0 @@
-see https://github.com/FreeCAD/FreeCAD/commit/cfe94b00d3434f3e2c8b5114d2909f628c330fa8#commitcomment-71413407
-
-upstream: yes
-
-From 7b377a216b9185960e4cee980a6504dc1a755f50 Mon Sep 17 00:00:00 2001
-From: wmayer <wmayer@users.sourceforge.net>
-Date: Wed, 29 Jun 2022 15:19:18 +0200
-Subject: [PATCH] Gui: remove workaround for spnav 0.23 due to build failure
- with musl libc
-
----
- src/Gui/3Dconnexion/GuiNativeEventLinux.cpp | 27 ---------------------
- 1 file changed, 27 deletions(-)
-
---- a/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp
-+++ b/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp
-@@ -21,42 +21,17 @@
-  ***************************************************************************/
- 
- #include <FCConfig.h>
--#include <cstdio>
- 
- #include "GuiNativeEventLinux.h"
- 
- #include "GuiApplicationNativeEventAware.h"
- #include <Base/Console.h>
--#include <Base/FileInfo.h>
- #include <QMainWindow>
- 
- #include <QSocketNotifier>
- 
- #include <spnav.h>
- 
--namespace {
--class RedirectStdErr
--{
--public:
--    RedirectStdErr()
--        : fi(Base::FileInfo::getTempFileName())
--        , file(stderr)
--    {
--        stderr = fopen(fi.filePath().c_str(), "w");
--    }
--    ~RedirectStdErr()
--    {
--        fclose(stderr);
--        fi.deleteFile();
--        stderr = file;
--    }
--
--private:
--    Base::FileInfo fi;
--    FILE* file;
--};
--}
--
- Gui::GuiNativeEvent::GuiNativeEvent(Gui::GUIApplicationNativeEventAware *app)
- : GuiAbstractNativeEvent(app)
- {
-@@ -72,8 +47,6 @@ Gui::GuiNativeEvent::~GuiNativeEvent()
- 
- void Gui::GuiNativeEvent::initSpaceball(QMainWindow *window)
- {
--    // tmp. redirect stderr to a file to suppress an error message from spnav_open()
--    RedirectStdErr err;
-     Q_UNUSED(window)
-     if (spnav_open() == -1) {
-         Base::Console().Log("Couldn't connect to spacenav daemon. Please ignore if you don't have a spacemouse.\n");
diff --git a/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch b/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch
deleted file mode 100644
index d4acf370ca0a4..0000000000000
--- a/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-From fe02d63c8c9b1280978be841d04e68a0a55cceb9 Mon Sep 17 00:00:00 2001
-From: Roy-043 <70520633+Roy-043@users.noreply.github.com>
-Date: Thu, 29 Dec 2022 23:20:38 +0100
-Subject: [PATCH] Draft: update inspect.getargspec to inspect.getfullargspec
- (#8101)
-
----
- src/Mod/Draft/draftguitools/gui_snapper.py | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
---- a/src/Mod/Draft/draftguitools/gui_snapper.py
-+++ b/src/Mod/Draft/draftguitools/gui_snapper.py
-@@ -1426,7 +1426,7 @@ class Snapper:
-             Gui.Snapper.off()
-             self.ui.offUi()
-             if callback:
--                if len(inspect.getargspec(callback).args) > 1:
-+                if len(inspect.getfullargspec(callback).args) > 1:
-                     obj = None
-                     if self.snapInfo and ("Object" in self.snapInfo) and self.snapInfo["Object"]:
-                         obj = App.ActiveDocument.getObject(self.snapInfo["Object"])
-@@ -1445,7 +1445,7 @@ class Snapper:
-             Gui.Snapper.off()
-             self.ui.offUi()
-             if callback:
--                if len(inspect.getargspec(callback).args) > 1:
-+                if len(inspect.getfullargspec(callback).args) > 1:
-                     callback(None, None)
-                 else:
-                     callback(None)
diff --git a/srcpkgs/freecad/template b/srcpkgs/freecad/template
index c135701e38b9a..7d5165f760bab 100644
--- a/srcpkgs/freecad/template
+++ b/srcpkgs/freecad/template
@@ -1,7 +1,7 @@
 # Template file for 'freecad'
 pkgname=freecad
-version=0.20.2
-revision=7
+version=0.21.1
+revision=2
 build_wrksrc="FreeCAD-${version}"
 build_style=cmake
 pycompile_dirs="usr/lib/${pkgname}/Mod"
@@ -24,8 +24,10 @@ makedepends="python3-devel boost-devel libxerces-c-devel zlib-devel occt-devel
  coin3-devel libshiboken2-devel libspnav-devel pyside2-tools
  liblz4-devel libpyside2-python3-devel python3-matplotlib netcdf-devel
  jsoncpp-devel qt5-devel qt5-svg-devel qt5-tools-devel qt5-webkit-devel
- qt5-xmlpatterns-devel coin3-doc glew-devel python3-pivy"
-depends="python3-matplotlib python3-pyside2-webengine python3-pivy"
+ qt5-xmlpatterns-devel coin3-doc glew-devel python3-pivy qt5-webengine-devel
+ qt5-declarative-devel qt5-webchannel-devel qt5-location-devel"
+depends="python3-matplotlib python3-pyside2-webengine python3-pivy
+ python3-GitPython python3-Markdown"
 short_desc="General purpose 3D CAD modeler"
 maintainer="yopito <pierre.bourgin@free.fr>"
 license="LGPL-2.0-or-later"
@@ -35,7 +37,7 @@ distfiles="
  https://github.com/FreeCAD/FreeCAD/archive/${version}.tar.gz
  ${SOURCEFORGE_SITE}/cxx/pycxx-${_pycxxver}.tar.gz
 "
-checksum="46922f3a477e742e1a89cd5346692d63aebb2b67af887b3e463e094a4ae055da
+checksum="e9b1fd0323f101268c7f3be52db42e4a29222f2e306ae6c4a6fc309cb418d35a
  4b91e1e1141c23fbd5039df635c4bb6e75632168548f56b83ce177193c0c98c6"
 python_version=3
 patch_args="-Np1 -d ${build_wrksrc}"

From d2073baae3c2497a70161591163151909a08092f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:47:18 -0400
Subject: [PATCH 090/113] libopenshot: revbump for ffmpeg6

---
 srcpkgs/libopenshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenshot/template b/srcpkgs/libopenshot/template
index 8e57c5f592169..7a8f4520e7892 100644
--- a/srcpkgs/libopenshot/template
+++ b/srcpkgs/libopenshot/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenshot'
 pkgname=libopenshot
 version=0.3.0
-revision=3
+revision=4
 build_style=cmake
 # Builds fail with Ruby-2.4.1
 configure_args="-DENABLE_RUBY=OFF -DUSE_SYSTEM_JSONCPP=ON"

From e14b617da898bde328cf8e322b8f874614023d55 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:10:30 -0500
Subject: [PATCH 091/113] openimageio: revbump for ffmpeg6

---
 srcpkgs/openimageio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimageio/template b/srcpkgs/openimageio/template
index 3ce3f9e49d350..27d2131bc0a61 100644
--- a/srcpkgs/openimageio/template
+++ b/srcpkgs/openimageio/template
@@ -1,7 +1,7 @@
 # Template file for 'openimageio'
 pkgname=openimageio
 version=2.4.9.0
-revision=7
+revision=8
 build_style=cmake
 build_helper=qemu
 configure_args="-DUSE_QT=0 -DUSE_PYTHON=0 -DOIIO_BUILD_TESTS=0

From ac5fe1d983669fac0f264b3ab1df9f28e42c5f80 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:11:57 -0500
Subject: [PATCH 092/113] synfigstudio: revbump for ffmpeg6

---
 srcpkgs/synfigstudio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/synfigstudio/template b/srcpkgs/synfigstudio/template
index 09e442da9a680..2bc017cedca6b 100644
--- a/srcpkgs/synfigstudio/template
+++ b/srcpkgs/synfigstudio/template
@@ -2,7 +2,7 @@
 # Should be kept in sync with 'synfig' and 'ETL'
 pkgname=synfigstudio
 version=1.4.4
-revision=4
+revision=5
 build_style=gnu-configure
 configure_args="--disable-update-mimedb"
 hostmakedepends="pkg-config intltool gettext synfig"

From 5f99789ba24bcbc6ed4776c54c98ff808f1cb9af Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:12:32 -0500
Subject: [PATCH 093/113] gmic: revbump for ffmpeg6

---
 srcpkgs/gmic/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gmic/template b/srcpkgs/gmic/template
index fa37651bb6dee..24d10147e3aba 100644
--- a/srcpkgs/gmic/template
+++ b/srcpkgs/gmic/template
@@ -1,7 +1,7 @@
 # Template file for 'gmic'
 pkgname=gmic
 version=3.1.6
-revision=5
+revision=6
 _zart_hash=34ebf6cce0bafb98abe57cec83c4a02cd1abeca0
 create_wrksrc=yes
 build_wrksrc="src"

From eac87cbaab36ce8347757034fd7290277e591bff Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:10 -0500
Subject: [PATCH 094/113] mixxx: revbump for ffmpeg6

---
 srcpkgs/mixxx/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mixxx/template b/srcpkgs/mixxx/template
index 6921996e4e77b..6a79b328c1abf 100644
--- a/srcpkgs/mixxx/template
+++ b/srcpkgs/mixxx/template
@@ -1,7 +1,7 @@
 # Template file for 'mixxx'
 pkgname=mixxx
 version=2.3.3
-revision=6
+revision=7
 build_style=cmake
 configure_args="-DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="extra-cmake-modules pkg-config protobuf qt5-host-tools qt5-qmake"

From a1812b492c2ef174352afaa8bd3671213c631d2d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:28 -0500
Subject: [PATCH 095/113] musikcube: revbump for ffmpeg6

---
 srcpkgs/musikcube/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/musikcube/template b/srcpkgs/musikcube/template
index d9e6186e6697b..637952d50aca3 100644
--- a/srcpkgs/musikcube/template
+++ b/srcpkgs/musikcube/template
@@ -1,7 +1,7 @@
 # Template file for 'musikcube'
 pkgname=musikcube
 version=3.0.0
-revision=3
+revision=4
 build_style=cmake
 make_cmd=make
 configure_args="-DNO_NCURSESW=1"

From 0e76c92d7685549710afc1688c85e18f22ff1408 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:45 -0500
Subject: [PATCH 096/113] electron24: revbump for ffmpeg6

---
 srcpkgs/electron24/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron24/template b/srcpkgs/electron24/template
index a9c865c19c989..b8613e4362bc7 100644
--- a/srcpkgs/electron24/template
+++ b/srcpkgs/electron24/template
@@ -1,7 +1,7 @@
 # Template file for 'electron24'
 pkgname=electron24
 version=24.3.0
-revision=2
+revision=3
 _nodever=18.14.0
 _chromiumver=112.0.5615.165
 archs="x86_64* aarch64*"

From 91d62500cb85b33fdd02734126dd4f10dd521290 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:00 -0500
Subject: [PATCH 097/113] electron19: revbump for ffmpeg6

---
 srcpkgs/electron19/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron19/template b/srcpkgs/electron19/template
index b18bc792c8221..29fb34e254eea 100644
--- a/srcpkgs/electron19/template
+++ b/srcpkgs/electron19/template
@@ -1,7 +1,7 @@
 # Template file for 'electron19'
 pkgname=electron19
 version=19.0.8
-revision=4
+revision=5
 _nodever=16.14.2
 _chromiumver=102.0.5005.125
 archs="x86_64* aarch64* ppc64le*"

From 41d122b48e6c848af06f48b3a6a800767692860d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:13 -0500
Subject: [PATCH 098/113] wf-recorder: revbump for ffmpeg6

---
 srcpkgs/wf-recorder/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/wf-recorder/template b/srcpkgs/wf-recorder/template
index 08f986b031006..63c45cf4b814d 100644
--- a/srcpkgs/wf-recorder/template
+++ b/srcpkgs/wf-recorder/template
@@ -1,7 +1,7 @@
 # Template file for 'wf-recorder'
 pkgname=wf-recorder
 version=0.4.1
-revision=2
+revision=3
 build_style=meson
 hostmakedepends="pkg-config scdoc wayland-devel"
 makedepends="wayland-protocols wayland-devel ffmpeg-devel libgbm-devel x264-devel

From 2911a050845cdf7c26c6a9c273d2125ee64a72be Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:26 -0500
Subject: [PATCH 099/113] obs: revbump for ffmpeg6

---
 srcpkgs/obs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/obs/template b/srcpkgs/obs/template
index b343f1131bfcf..a25a67433e285 100644
--- a/srcpkgs/obs/template
+++ b/srcpkgs/obs/template
@@ -1,7 +1,7 @@
 # Template file for 'obs'
 pkgname=obs
 version=30.0.0
-revision=2
+revision=3
 archs="i686* x86_64* ppc64le* aarch64* riscv64*"
 build_style=cmake
 configure_args="-DOBS_VERSION_OVERRIDE=${version} -DENABLE_JACK=ON

From ec8b65140695092440a9ad31951557046c4f78da Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:36 -0500
Subject: [PATCH 100/113] mlt7: revbump for ffmpeg6

---
 srcpkgs/mlt7/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mlt7/template b/srcpkgs/mlt7/template
index 98f302ad3a516..7eb8c00fa1580 100644
--- a/srcpkgs/mlt7/template
+++ b/srcpkgs/mlt7/template
@@ -1,7 +1,7 @@
 # Template file for 'mlt7'
 pkgname=mlt7
 version=7.20.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DSWIG_PYTHON=ON -DMOD_QT6=ON"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which

From d98ebfef1bf0f28426dde051f6113713108425da Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:48 -0500
Subject: [PATCH 101/113] qt6-multimedia: revbump for ffmpeg6

---
 srcpkgs/qt6-multimedia/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-multimedia/template b/srcpkgs/qt6-multimedia/template
index 67a577e1300fe..1da626ecf515a 100644
--- a/srcpkgs/qt6-multimedia/template
+++ b/srcpkgs/qt6-multimedia/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-multimedia'
 pkgname=qt6-multimedia
 version=6.6.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DQT_FEATURE_gstreamer=ON"
 hostmakedepends="perl qt6-declarative-host-tools pkg-config qt6-shadertools"

From d2daa40723e4c12c1b8396816de889c7d6352352 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:00:15 -0500
Subject: [PATCH 102/113] baresip: revbump for ffmpeg6

---
 srcpkgs/baresip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/baresip/template b/srcpkgs/baresip/template
index 12c8954ef7b9b..b16b67beab8d2 100644
--- a/srcpkgs/baresip/template
+++ b/srcpkgs/baresip/template
@@ -1,7 +1,7 @@
 # Template file for 'baresip'
 pkgname=baresip
 version=3.6.0
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config glib-devel"
 makedepends="libgsm-devel libpng-devel openssl-devel libsndfile-devel

From 97d1f29dab61c66a753034d29174313f7f12595a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:30 -0500
Subject: [PATCH 103/113] QMPlay2: revbump for ffmpeg6

---
 srcpkgs/QMPlay2/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/QMPlay2/template b/srcpkgs/QMPlay2/template
index 46c80f64a1349..942258ce60fb7 100644
--- a/srcpkgs/QMPlay2/template
+++ b/srcpkgs/QMPlay2/template
@@ -1,7 +1,7 @@
 # Template file for 'QMPlay2'
 pkgname=QMPlay2
 version=23.10.22
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools"
 makedepends="alsa-lib-devel ffmpeg-devel libass-devel libcdio-devel libgme-devel

From 8813cc5604ec19983c45b2f4a378ed6cdb9ca460 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:34 -0500
Subject: [PATCH 104/113] alsa-plugins: revbump for ffmpeg6

---
 srcpkgs/alsa-plugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/alsa-plugins/template b/srcpkgs/alsa-plugins/template
index a5708a7d82a8f..7bfdad046c483 100644
--- a/srcpkgs/alsa-plugins/template
+++ b/srcpkgs/alsa-plugins/template
@@ -1,7 +1,7 @@
 # Template file for 'alsa-plugins'
 pkgname=alsa-plugins
 version=1.2.7.1
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--disable-maemo-plugin"
 hostmakedepends="pkg-config"

From 12c39998d4ac14a4b3f3c12f2d0ba14534b2631f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:43 -0500
Subject: [PATCH 105/113] minidlna: revbump for ffmpeg6

---
 srcpkgs/minidlna/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/minidlna/template b/srcpkgs/minidlna/template
index 5fa929f3a0c12..742991ecd04af 100644
--- a/srcpkgs/minidlna/template
+++ b/srcpkgs/minidlna/template
@@ -1,7 +1,7 @@
 # Template file for 'minidlna'
 pkgname=minidlna
 version=1.3.3
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="
  --sbindir=/usr/bin

From 6fe5aa2b9a8671efeb28d3468fd4f59ab591a987 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 17:57:47 -0500
Subject: [PATCH 106/113] mpv: revbump for ffmpeg6

---
 srcpkgs/mpv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpv/template b/srcpkgs/mpv/template
index 4948d1e332cb8..1ac1b167af189 100644
--- a/srcpkgs/mpv/template
+++ b/srcpkgs/mpv/template
@@ -1,7 +1,7 @@
 # Template file for 'mpv'
 pkgname=mpv
 version=0.36.0
-revision=4
+revision=5
 build_style=meson
 configure_args="-Dcdda=enabled -Ddvbin=enabled -Ddvdnav=enabled
  -Dlibmpv=true -Dcplugins=enabled

From 9868b39e3ee01fbe6d1e15e5518a3551713468b3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 17:59:29 -0500
Subject: [PATCH 107/113] qimgv: revbump for ffmpeg6

---
 srcpkgs/qimgv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qimgv/template b/srcpkgs/qimgv/template
index dd341dfe1bfce..8a7e1c081ef12 100644
--- a/srcpkgs/qimgv/template
+++ b/srcpkgs/qimgv/template
@@ -1,7 +1,7 @@
 # Template file for 'qimgv'
 pkgname=qimgv
 version=1.0.2
-revision=3
+revision=4
 build_style=cmake
 configure_args="$(vopt_if video -DVIDEO_SUPPORT=ON -DVIDEO_SUPPORT=OFF)
  $(vopt_if scale -DOPENCV_SUPPORT=ON -DOPENCV_SUPPORT=OFF)

From 3ab5456779b2f072f37679bd8f81b30f4e15ad15 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 18:00:36 -0500
Subject: [PATCH 108/113] kfilemetadata5: revbump for ffmpeg6

---
 srcpkgs/kfilemetadata5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kfilemetadata5/template b/srcpkgs/kfilemetadata5/template
index 51fd6fec8c1c0..ad229b4c2e241 100644
--- a/srcpkgs/kfilemetadata5/template
+++ b/srcpkgs/kfilemetadata5/template
@@ -1,7 +1,7 @@
 # Template file for 'kfilemetadata5'
 pkgname=kfilemetadata5
 version=5.113.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="kcoreaddons extra-cmake-modules pkg-config qt5-host-tools qt5-qmake
  gettext kcoreaddons python3"

From e692ed7a1d3f44421269a22262f99b5a86ff8000 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 8 Dec 2023 11:46:01 -0500
Subject: [PATCH 109/113] vba-m: revbump for ffmpeg6

---
 srcpkgs/vba-m/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vba-m/template b/srcpkgs/vba-m/template
index 52efeede1dcba..3e0760398905c 100644
--- a/srcpkgs/vba-m/template
+++ b/srcpkgs/vba-m/template
@@ -2,7 +2,7 @@
 pkgname=vba-m
 reverts=1292_2
 version=2.1.8
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_GTK=TRUE -DENABLE_FFMPEG=TRUE -DENABLE_LINK=TRUE -DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="gettext pkg-config unzip zip yasm wxWidgets-gtk3-devel"

From 43bd47511d6f3bf2e1b63e8f0761e1a20cd55192 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 8 Dec 2023 11:46:19 -0500
Subject: [PATCH 110/113] dolphin-emu: revbump for ffmpeg6

---
 srcpkgs/dolphin-emu/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/dolphin-emu/template b/srcpkgs/dolphin-emu/template
index 862d3ae964eec..a7ae0efb58fb7 100644
--- a/srcpkgs/dolphin-emu/template
+++ b/srcpkgs/dolphin-emu/template
@@ -1,7 +1,7 @@
 # Template file for 'dolphin-emu'
 pkgname=dolphin-emu
 version=5.0.19368
-revision=3
+revision=4
 _dolphin_commit=dadbeb4bae7e7fa23af2b46e0add4143094dc107
 _mgba_commit=44e074a15e9651481f7f652ac006a7c9d58cbeb9
 _googletest_commit=be03d00f5f0cc3a997d1a368bee8a1fe93651f48

From 8e6ab07a1cc69245fdad9de6c5ae8689a347654f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 19 Dec 2023 15:38:51 -0500
Subject: [PATCH 111/113] qtox: revbump for ffmpeg4

---
 srcpkgs/qtox/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtox/template b/srcpkgs/qtox/template
index bb70e7f51240a..755e4462bc013 100644
--- a/srcpkgs/qtox/template
+++ b/srcpkgs/qtox/template
@@ -1,13 +1,13 @@
 # Template file for 'qtox'
 pkgname=qtox
 version=1.17.6
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DUPDATE_CHECK=OFF
  -DGIT_DESCRIBE=${version}
  $(vopt_if snorenotify -DDESKTOP_NOTIFICATIONS=ON)"
 hostmakedepends="pkg-config qt5-host-tools qt5-devel"
-makedepends="ffmpeg-devel libexif-devel libopenal-devel libsodium-devel
+makedepends="ffmpeg4-devel libexif-devel libopenal-devel libsodium-devel
  libvpx-devel opus-devel qrencode-devel qt5-svg-devel sonnet-devel
  sqlcipher-devel toxcore-devel
  $(vopt_if snorenotify snorenotify-devel)"

From cdb7797257e0dfa36a5aed4a2f83c6bced41f120 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 11 Jan 2024 11:52:00 -0500
Subject: [PATCH 112/113] arcan: revbump for ffmpeg6

---
 srcpkgs/arcan/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/arcan/template b/srcpkgs/arcan/template
index ff9091f90ebb1..030091a6cc9d0 100644
--- a/srcpkgs/arcan/template
+++ b/srcpkgs/arcan/template
@@ -2,7 +2,7 @@
 # !! keep synced with: acfgfs aclip aloadimage
 pkgname=arcan
 version=0.6.2.1
-revision=2
+revision=3
 create_wrksrc=yes
 build_wrksrc=arcan/src
 build_style=cmake

From 17fb0dd0152a5fa6c810d606de83e228953f602b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 11 Jan 2024 11:52:10 -0500
Subject: [PATCH 113/113] notcurses: revbump for ffmpeg6

---
 srcpkgs/notcurses/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/notcurses/template b/srcpkgs/notcurses/template
index 48a7463cb68eb..515f316ab4576 100644
--- a/srcpkgs/notcurses/template
+++ b/srcpkgs/notcurses/template
@@ -1,7 +1,7 @@
 # Template file for 'notcurses'
 pkgname=notcurses
 version=3.0.9
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DUSE_STATIC=ON -DUSE_QRCODEGEN=On $(vopt_bool man USE_PANDOC)"
 hostmakedepends="pkg-config $(vopt_if man pandoc)"

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (52 preceding siblings ...)
  2024-01-11 16:52 ` zlice
@ 2024-01-17 22:35 ` zlice
  2024-01-17 22:50 ` zlice
                   ` (43 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2024-01-17 22:35 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 4019 bytes --]

There is an updated pull request by zlice against master on the void-packages repository

https://github.com/zlice/void-packages ffmpeg6-split
https://github.com/void-linux/void-packages/pull/43761

ffmpeg6 split
[ci skip]


#### Testing the changes

- I tested the changes in this PR: **YES**

main testing has been vaapi in Firefox Nightly and enc/dec in Shotcut on Intel A770

#### New package

- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**

#### Local build testing

- I built this PR locally for my native architecture, **x86_64**

#### Discussion

Continuation of https://github.com/void-linux/void-packages/pull/36315

`libavresample` is deprecated, but marked as a dependency when trying to build other packages and install `ffmpeg`(6). I think the right way to handle this is make a meta package and the add to removals?


##### Commit naming / misc

~~Commits are 'dirty' right now, running with [gstreamer 1.22.1 updates](https://github.com/void-linux/void-packages/pull/42861) and [Intel OpenCL](https://github.com/void-linux/void-packages/pull/43084). This will also make [intel packages pr](https://github.com/void-linux/void-packages/pull/41132) obsolete.~~ (see Requirements below)

Maintainer for previous ffmpeg(4) was orphaned, I can put my name in there if that matters, though I don't exactly see myself keeping up on ffmpeg.

~~This updates QT5 which looks like it is usually hosted by Johnny. Not sure if there's any reason to stay there or these sources are fine.~~ Using qt5.15.11 now, revbumps and some patches.

##### STILL FFMPEG4

These are a mix of emulators, games and/or older packages.

- attract (multiple patches in master)
- audacity (https://github.com/audacity/audacity/issues/2305 and https://sourceforge.net/p/portmedia/wiki/portsmf/ is 'beta')
- ccextractor (master patches? no release)
- vice
- kodi
- mlt (only dep left is flowblade)
- ~~synfig (mlt)~~ (work with mlt7, bump synfigstudio)
- tvheadend
- ssr
- ~~spek-alternative~~ (replace with spek-x)
- ppsspp
- olive
- moc
- mediastreamer
- libextractor
- idjc
- hedgewars
- ~~ffmpegthumbnailer~~ (patches for moviedecoder.xxx files)
- ~~ffmpegthumbs~~ (latest compiles)
- deadbeef
- omxplayer
- qtav (fork has ffmpeg 5 patch - https://github.com/cmguo/QtAV)
- `vlc` (vlc4 will support ffmpeg5, there's a patch to build 3.x with ffmpeg5 but it will lack vaapi)
- `osg` (OpenSceneGraph plus `xine-lib`)


##### HAVE NOT BUILT YET

- omxplayer (rpi only? ffmpeg4)
- kodi (big, but ffmpeg4)


##### UPDATED (for ffmpeg6)

- ~~blender: update to 3.5.1~~ ~~will be revbump with~~ https://github.com/void-linux/void-packages/pull/43992
- unpaper: update to 7.0.0.
- guvcview: update to 2.0.8.
- ~~qt5: update to 5.15.8~~ updated by another PR to 5.15.11
- ~~qt5-webengine: update to 5.18.15~~ updated by another PR to 5.15.16 (some patching for ffmpeg build)
- ~~shiboken2: revbump for qt5.15.8 (patch)~~ updated by another PR to 5.15.10
- ~~python3-pyside2: update to 5.15.8 (patch)~~ updated by another PR to 5.15.10
- New package: spex-x replaces spek-alternative for ffmpeg-6.0


##### Requirements

- ~~[gstreamer 1.22.2](https://github.com/void-linux/void-packages/pull/42861)~~ - a few packages use ffmpeg-devel and require a revbump

- ~~[Intel Packages](https://github.com/void-linux/void-packages/pull/41132) [Intel Packages v2](https://github.com/void-linux/void-packages/pull/47330) - ffmpeg4 uses different libraries than 6 (libmfx / Intel-MediaSDK vs only oneVPL that Intel is moving to), both are included here~~. Using replacement oneVPL from OBS update.

- ~~[shotcut 23.05.14](https://github.com/void-linux/void-packages/pull/44260)~~

- https://github.com/void-linux/void-packages/pull/44781 will remove from this PR

A patch file from https://github.com/void-linux/void-packages/pull/43761.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ffmpeg6-split-43761.patch --]
[-- Type: text/x-diff, Size: 219659 bytes --]

From eddb78657b1d6615cdc80cd8a0465041334302b6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:16:56 -0400
Subject: [PATCH 001/112] ffmpeg: update to 6.0.1.

---
 common/shlibs                                 | 26 +++++---
 srcpkgs/ffmpeg/files/altivec.patch            | 60 -------------------
 .../patches/armv5tel-floating-point.patch     | 18 ------
 ...h-libavcodec-libsvtav1-ten_bit_format.diff | 40 -------------
 .../workaround-mesa-readeon-vaapi-bug.patch   | 28 ---------
 srcpkgs/ffmpeg/template                       | 38 ++++++------
 6 files changed, 37 insertions(+), 173 deletions(-)
 delete mode 100644 srcpkgs/ffmpeg/files/altivec.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 delete mode 100644 srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch

diff --git a/common/shlibs b/common/shlibs
index 9e6d29c73341e..177934cf6cc2d 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -385,15 +385,23 @@ libid3tag.so.0 libid3tag-0.15.1b_1
 libgif.so.7 giflib-5.1.0_1
 libImlib2.so.1 imlib2-1.4.2_1
 libmp3lame.so.0 lame-3.98.2_1
-libavdevice.so.58 libavdevice-4.0_1
-libavformat.so.58 libavformat-4.0_1
-libswscale.so.5 libswscale-4.0_1
-libswresample.so.3 libswresample-4.0_1
-libavresample.so.4 libavresample-4.0_1
-libpostproc.so.55 libpostproc-4.0_1
-libavcodec.so.58 libavcodec-4.0_1
-libavutil.so.56 libavutil-4.0_1
-libavfilter.so.7 libavfilter-4.0_1
+libavdevice.so.60 libavdevice-6.0_1
+libavformat.so.60 libavformat-6.0_1
+libswscale.so.7 libswscale-6.0_1
+libswresample.so.4 libswresample-6.0_1
+libpostproc.so.57 libpostproc-6.0_1
+libavcodec.so.60 libavcodec-6.0_1
+libavutil.so.58 libavutil-6.0_1
+libavfilter.so.9 libavfilter-6.0_1
+libavdevice.so.58 libavdevice4-4.0_1
+libavformat.so.58 libavformat4-4.0_1
+libswscale.so.5 libswscale4-4.0_1
+libswresample.so.3 libswresample4-4.0_1
+libavresample.so.4 libavresample4-4.0_1
+libpostproc.so.55 libpostproc4-4.0_1
+libavcodec.so.58 libavcodec4-4.0_1
+libavutil.so.56 libavutil4-4.0_1
+libavfilter.so.7 libavfilter4-4.0_1
 libSDL-1.2.so.0 SDL-1.2.14_1
 libSDL_image-1.2.so.0 SDL_image-1.2.10_1
 libx264.so.157 x264-20190507.2245_1
diff --git a/srcpkgs/ffmpeg/files/altivec.patch b/srcpkgs/ffmpeg/files/altivec.patch
deleted file mode 100644
index 9c57200463320..0000000000000
--- a/srcpkgs/ffmpeg/files/altivec.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-revert some altivec specific change on all ppc* except ppc64le*
-
-q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
-conditionally, for ppc* but not ppc64le* (the new code is valid for
-POWER8 VSX which LE targets as a baseline but not BE)"
-
-
-This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
----
- libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
- 1 file changed, 20 insertions(+), 4 deletions(-)
-
-diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
-index 536545293d..c1e2852adb 100644
---- a/libswscale/ppc/yuv2rgb_altivec.c
-+++ b/libswscale/ppc/yuv2rgb_altivec.c
-@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-     vector signed short R1, G1, B1;                                           \
-     vector unsigned char R, G, B;                                             \
-                                                                               \
-+    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
-+    vector unsigned char align_perm;                                          \
-+                                                                              \
-     vector signed short lCY       = c->CY;                                    \
-     vector signed short lOY       = c->OY;                                    \
-     vector signed short lCRV      = c->CRV;                                   \
-@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
-                                                                               \
-         for (j = 0; j < w / 16; j++) {                                        \
--            y0 = vec_xl(0, y1i);                                              \
-+            y1ivP = (const vector unsigned char *) y1i;                       \
-+            y2ivP = (const vector unsigned char *) y2i;                       \
-+            uivP  = (const vector unsigned char *) ui;                        \
-+            vivP  = (const vector unsigned char *) vi;                        \
-+                                                                              \
-+            align_perm = vec_lvsl(0, y1i);                                    \
-+            y0 = (vector unsigned char)                                       \
-+                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
-                                                                               \
--            y1 = vec_xl(0, y2i);                                              \
-+            align_perm = vec_lvsl(0, y2i);                                    \
-+            y1 = (vector unsigned char)                                       \
-+                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
-                                                                               \
--            u = (vector signed char) vec_xl(0, ui);                           \
-+            align_perm = vec_lvsl(0, ui);                                     \
-+            u = (vector signed char)                                          \
-+                    vec_perm(uivP[0], uivP[1], align_perm);                   \
-                                                                               \
--            v = (vector signed char) vec_xl(0, vi);                           \
-+            align_perm = vec_lvsl(0, vi);                                     \
-+            v = (vector signed char)                                          \
-+                    vec_perm(vivP[0], vivP[1], align_perm);                   \
-                                                                               \
-             u = (vector signed char)                                          \
-                     vec_sub(u,                                                \
--- 
-2.27.0
-
diff --git a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
deleted file mode 100644
index 9a55178c74f0f..0000000000000
--- a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
-+++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
-@@ -39,6 +39,15 @@
- #endif
- #include <fenv.h>
- 
-+#if (FE_ALL_EXCEPT == 0)
-+/* E.g. ARM soft float does not define these */
-+#define FE_INVALID    0
-+#define FE_DIVBYZERO  0
-+#define FE_OVERFLOW   0
-+#define FE_UNDERFLOW  0
-+#define FE_INEXACT    0
-+#endif
-+
- #if CONFIG_LIBFONTCONFIG
- #include <fontconfig/fontconfig.h>
- #endif
diff --git a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
deleted file mode 100644
index aa948f7a8a2df..0000000000000
--- a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
+++ /dev/null
@@ -1,40 +0,0 @@
-#==================================================================================================
-# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
-# From: Christopher Degawa <christopher.degawa@intel.com>
-# Date: Thu, 20 Oct 2022 22:55:27 -0500
-# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
-#
-# compressed_ten_bit_format has been deprecated upstream and has no effect
-# and can be removed. Plus, technically it was never used in the first place
-# since it would require the app (ffmpeg) to set it and do additional
-# processing of the input frames.
-#
-# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
-#
-# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
-#==================================================================================================
---- a/libavcodec/libsvtav1.c
-+++ b/libavcodec/libsvtav1.c
-@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
- 
- static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
- {
--    const int    pack_mode_10bit =
--        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
--    const size_t luma_size_8bit  =
--        config->source_width * config->source_height * (1 << pack_mode_10bit);
--    const size_t luma_size_10bit =
--        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
-+    const size_t luma_size = config->source_width * config->source_height *
-+        (config->encoder_bit_depth > 8 ? 2 : 1);
- 
-     EbSvtIOFormat *in_data;
- 
--    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
-+    svt_enc->raw_size = luma_size * 3 / 2;
- 
-     // allocate buffer for in and out
-     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
--- 
-GitLab
-
diff --git a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
deleted file mode 100644
index 00e3f68a415b8..0000000000000
--- a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
-From: Rainer Hochecker <fernetmenta@online.de>
-Date: Sat, 26 Jan 2019 19:48:35 +0100
-Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
-
-This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
-It was hit frequently when watching h264 channels received via DVB-X.
-Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
----
- libavcodec/vaapi_h264.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
-index 5854587a255..f12fdc457a4 100644
---- a/libavcodec/vaapi_h264.c
-+++ b/libavcodec/vaapi_h264.c
-@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
-     H264SliceContext *sl = &h->slice_ctx[0];
-     int ret;
- 
-+    if (pic->nb_slices == 0) {
-+        ret = AVERROR_INVALIDDATA;
-+        goto finish;
-+    }
-+
-     ret = ff_vaapi_decode_issue(avctx, pic);
-     if (ret < 0)
-         goto finish;
diff --git a/srcpkgs/ffmpeg/template b/srcpkgs/ffmpeg/template
index 5968a09b1f12d..52fcf4d68797a 100644
--- a/srcpkgs/ffmpeg/template
+++ b/srcpkgs/ffmpeg/template
@@ -1,15 +1,15 @@
 # Template file for 'ffmpeg'
 # audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
 pkgname=ffmpeg
-version=4.4.4
-revision=5
+version=6.0.1
+revision=1
 short_desc="Decoding, encoding and streaming software"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="https://www.ffmpeg.org"
 changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
 distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
-checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+checksum=9b16b8731d78e596b4be0d720428ca42df642bb2d78342881ff7f5bc29fc9623
 
 hostmakedepends="pkg-config perl"
 makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
@@ -26,12 +26,13 @@ makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-deve
  $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
  $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
  $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
- $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers Vulkan-Tools Vulkan-ValidationLayers')
+ $(vopt_if onevpl 'oneVPL oneVPL-devel')
  $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
 depends="ffplay>=${version}_${revision}"
 
 build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
- dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec onevpl"
 build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
 desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
 desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
@@ -39,9 +40,13 @@ desc_option_sofa="Enable support for AES SOFA"
 desc_option_webp="Enable support for WebP"
 
 case "$XBPS_TARGET_MACHINE" in
-	i686*|x86_64*)
-		hostmakedepends+=" nasm"
+	i686*)
 		build_options_default+=" vaapi vdpau nvenc nvdec"
+		hostmakedepends+=" nasm"
+		;;
+	x86_64*)
+		hostmakedepends+=" nasm"
+		build_options_default+=" vaapi vdpau nvenc nvdec onevpl"
 		;;
 	ppc64*) build_options_default+=" vaapi vdpau";;
 	mips*) CFLAGS="-mnan=legacy";;
@@ -115,18 +120,19 @@ do_configure() {
 		$(vopt_enable x265 libx265) \
 		$(vopt_enable v4l2 libv4l2) \
 		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
-		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		--enable-libbs2b --enable-libvidstab \
 		$(vopt_enable dav1d libdav1d) \
 		$(vopt_enable zimg libzimg) \
 		$(vopt_enable webp libwebp) \
 		$(vopt_enable sofa libmysofa) \
 		$(vopt_enable vulkan) \
+		$(vopt_enable onevpl libvpl) \
 		$(vopt_enable drm libdrm) \
 		$(vopt_enable svtav1 libsvtav1) \
 		$(vopt_enable srt libsrt) \
 		$(vopt_enable rist librist) \
-		$(vopt_if nvenc '--enable-nvenc') \
-		$(vopt_if nvdec '--enable-nvdec')
+		$(vopt_enable nvenc nvenc) \
+		$(vopt_enable nvdec nvdec)
 }
 
 do_build() {
@@ -153,10 +159,8 @@ libavdevice_package() {
 }
 
 libavresample_package() {
-	short_desc="FFmpeg audio resampling library"
-	pkg_install() {
-		vmove "usr/lib/libavresample.so.*"
-	}
+	short_desc="Package deprecated, removal needed"
+	build_style=meta
 }
 
 libavformat_package() {
@@ -210,15 +214,13 @@ ffmpeg-devel_package() {
 		libavfilter>=${version}_${revision}
 		libpostproc>=${version}_${revision}
 		libswscale>=${version}_${revision}
-		libswresample>=${version}_${revision}
-		libavresample>=${version}_${revision}"
+		libswresample>=${version}_${revision}"
 	short_desc+=" - development files"
-
+	conflicts="ffmpeg4-devel"
 	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
 		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
 		nostrip_files="/usr/lib/libavfilter.a"
 	fi
-
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig

From 94d57cda9b53e141fcf69d40332154c3964c330c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:14 -0400
Subject: [PATCH 002/112] openshot: revbump for ffmpeg6

---
 srcpkgs/openshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openshot/template b/srcpkgs/openshot/template
index 8f47851eef354..affb652a9d500 100644
--- a/srcpkgs/openshot/template
+++ b/srcpkgs/openshot/template
@@ -1,7 +1,7 @@
 # Template file for 'openshot'
 pkgname=openshot
 version=3.0.0
-revision=2
+revision=3
 build_style=python3-module
 hostmakedepends="python3 python3-setuptools"
 makedepends="ffmpeg-devel python3-PyQt5"

From 0998ddccd28c8d38e7cfa7d6802d22822c0646ef Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:36 -0400
Subject: [PATCH 003/112] sumo: revbump for ffmpeg6

---
 srcpkgs/sumo/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/sumo/template b/srcpkgs/sumo/template
index a3fe134aa5acc..a730afa9fafa9 100644
--- a/srcpkgs/sumo/template
+++ b/srcpkgs/sumo/template
@@ -1,7 +1,7 @@
 # Template file for 'sumo'
 pkgname=sumo
 version=1.12.0
-revision=6
+revision=7
 build_style=cmake
 hostmakedepends="libgdal-tools pkg-config swig python3-setuptools"
 makedepends="python3-devel ffmpeg-devel fox-devel gl2ps-devel libgdal-devel

From 4922f6b739cb4c472c7b732320ff044d0fc103fe Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:56:22 -0400
Subject: [PATCH 004/112] New package: ffmpeg4-4.4.4.

---
 srcpkgs/ffmpeg4-devel                         |   1 +
 srcpkgs/ffmpeg4/files/altivec.patch           |  60 +++++
 .../patches/armv5tel-floating-point.patch     |  18 ++
 ...h-libavcodec-libsvtav1-ten_bit_format.diff |  40 +++
 .../workaround-mesa-readeon-vaapi-bug.patch   |  28 +++
 srcpkgs/ffmpeg4/template                      | 234 ++++++++++++++++++
 srcpkgs/libavcodec4                           |   1 +
 srcpkgs/libavdevice4                          |   1 +
 srcpkgs/libavfilter4                          |   1 +
 srcpkgs/libavformat4                          |   1 +
 srcpkgs/libavresample4                        |   1 +
 srcpkgs/libavutil4                            |   1 +
 srcpkgs/libpostproc4                          |   1 +
 srcpkgs/libswresample4                        |   1 +
 srcpkgs/libswscale4                           |   1 +
 15 files changed, 390 insertions(+)
 create mode 120000 srcpkgs/ffmpeg4-devel
 create mode 100644 srcpkgs/ffmpeg4/files/altivec.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 create mode 100644 srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
 create mode 100644 srcpkgs/ffmpeg4/template
 create mode 120000 srcpkgs/libavcodec4
 create mode 120000 srcpkgs/libavdevice4
 create mode 120000 srcpkgs/libavfilter4
 create mode 120000 srcpkgs/libavformat4
 create mode 120000 srcpkgs/libavresample4
 create mode 120000 srcpkgs/libavutil4
 create mode 120000 srcpkgs/libpostproc4
 create mode 120000 srcpkgs/libswresample4
 create mode 120000 srcpkgs/libswscale4

diff --git a/srcpkgs/ffmpeg4-devel b/srcpkgs/ffmpeg4-devel
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/ffmpeg4-devel
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/ffmpeg4/files/altivec.patch b/srcpkgs/ffmpeg4/files/altivec.patch
new file mode 100644
index 0000000000000..9c57200463320
--- /dev/null
+++ b/srcpkgs/ffmpeg4/files/altivec.patch
@@ -0,0 +1,60 @@
+revert some altivec specific change on all ppc* except ppc64le*
+
+q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
+conditionally, for ppc* but not ppc64le* (the new code is valid for
+POWER8 VSX which LE targets as a baseline but not BE)"
+
+
+This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
+---
+ libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
+ 1 file changed, 20 insertions(+), 4 deletions(-)
+
+diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
+index 536545293d..c1e2852adb 100644
+--- a/libswscale/ppc/yuv2rgb_altivec.c
++++ b/libswscale/ppc/yuv2rgb_altivec.c
+@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+     vector signed short R1, G1, B1;                                           \
+     vector unsigned char R, G, B;                                             \
+                                                                               \
++    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
++    vector unsigned char align_perm;                                          \
++                                                                              \
+     vector signed short lCY       = c->CY;                                    \
+     vector signed short lOY       = c->OY;                                    \
+     vector signed short lCRV      = c->CRV;                                   \
+@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
+                                                                               \
+         for (j = 0; j < w / 16; j++) {                                        \
+-            y0 = vec_xl(0, y1i);                                              \
++            y1ivP = (const vector unsigned char *) y1i;                       \
++            y2ivP = (const vector unsigned char *) y2i;                       \
++            uivP  = (const vector unsigned char *) ui;                        \
++            vivP  = (const vector unsigned char *) vi;                        \
++                                                                              \
++            align_perm = vec_lvsl(0, y1i);                                    \
++            y0 = (vector unsigned char)                                       \
++                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
+                                                                               \
+-            y1 = vec_xl(0, y2i);                                              \
++            align_perm = vec_lvsl(0, y2i);                                    \
++            y1 = (vector unsigned char)                                       \
++                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
+                                                                               \
+-            u = (vector signed char) vec_xl(0, ui);                           \
++            align_perm = vec_lvsl(0, ui);                                     \
++            u = (vector signed char)                                          \
++                    vec_perm(uivP[0], uivP[1], align_perm);                   \
+                                                                               \
+-            v = (vector signed char) vec_xl(0, vi);                           \
++            align_perm = vec_lvsl(0, vi);                                     \
++            v = (vector signed char)                                          \
++                    vec_perm(vivP[0], vivP[1], align_perm);                   \
+                                                                               \
+             u = (vector signed char)                                          \
+                     vec_sub(u,                                                \
+-- 
+2.27.0
+
diff --git a/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
new file mode 100644
index 0000000000000..9a55178c74f0f
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
@@ -0,0 +1,18 @@
+--- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
++++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
+@@ -39,6 +39,15 @@
+ #endif
+ #include <fenv.h>
+ 
++#if (FE_ALL_EXCEPT == 0)
++/* E.g. ARM soft float does not define these */
++#define FE_INVALID    0
++#define FE_DIVBYZERO  0
++#define FE_OVERFLOW   0
++#define FE_UNDERFLOW  0
++#define FE_INEXACT    0
++#endif
++
+ #if CONFIG_LIBFONTCONFIG
+ #include <fontconfig/fontconfig.h>
+ #endif
diff --git a/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
new file mode 100644
index 0000000000000..aa948f7a8a2df
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
@@ -0,0 +1,40 @@
+#==================================================================================================
+# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
+# From: Christopher Degawa <christopher.degawa@intel.com>
+# Date: Thu, 20 Oct 2022 22:55:27 -0500
+# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
+#
+# compressed_ten_bit_format has been deprecated upstream and has no effect
+# and can be removed. Plus, technically it was never used in the first place
+# since it would require the app (ffmpeg) to set it and do additional
+# processing of the input frames.
+#
+# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
+#
+# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
+#==================================================================================================
+--- a/libavcodec/libsvtav1.c
++++ b/libavcodec/libsvtav1.c
+@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
+ 
+ static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
+ {
+-    const int    pack_mode_10bit =
+-        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
+-    const size_t luma_size_8bit  =
+-        config->source_width * config->source_height * (1 << pack_mode_10bit);
+-    const size_t luma_size_10bit =
+-        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
++    const size_t luma_size = config->source_width * config->source_height *
++        (config->encoder_bit_depth > 8 ? 2 : 1);
+ 
+     EbSvtIOFormat *in_data;
+ 
+-    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
++    svt_enc->raw_size = luma_size * 3 / 2;
+ 
+     // allocate buffer for in and out
+     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
+-- 
+GitLab
+
diff --git a/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
new file mode 100644
index 0000000000000..00e3f68a415b8
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
@@ -0,0 +1,28 @@
+From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
+From: Rainer Hochecker <fernetmenta@online.de>
+Date: Sat, 26 Jan 2019 19:48:35 +0100
+Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
+
+This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
+It was hit frequently when watching h264 channels received via DVB-X.
+Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
+---
+ libavcodec/vaapi_h264.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
+index 5854587a255..f12fdc457a4 100644
+--- a/libavcodec/vaapi_h264.c
++++ b/libavcodec/vaapi_h264.c
+@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
+     H264SliceContext *sl = &h->slice_ctx[0];
+     int ret;
+ 
++    if (pic->nb_slices == 0) {
++        ret = AVERROR_INVALIDDATA;
++        goto finish;
++    }
++
+     ret = ff_vaapi_decode_issue(avctx, pic);
+     if (ret < 0)
+         goto finish;
diff --git a/srcpkgs/ffmpeg4/template b/srcpkgs/ffmpeg4/template
new file mode 100644
index 0000000000000..9ba14bdb8ddf3
--- /dev/null
+++ b/srcpkgs/ffmpeg4/template
@@ -0,0 +1,234 @@
+# Template file for 'ffmpeg4'
+# audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
+pkgname=ffmpeg4
+version=4.4.4
+revision=1
+short_desc="Decoding, encoding and streaming software - ffmpeg4 libraries only"
+maintainer="Orphaned <orphan@voidlinux.org>"
+license="GPL-3.0-or-later"
+homepage="https://www.ffmpeg.org"
+changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
+distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
+checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+
+hostmakedepends="pkg-config perl"
+makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
+ libXext-devel libXvMC-devel libxcb-devel lame-devel libtheora-devel
+ libvorbis-devel x264-devel xvidcore-devel jack-devel SDL2-devel
+ libcdio-paranoia-devel librtmp-devel libmodplug-devel gnutls-devel
+ speex-devel celt-devel harfbuzz-devel libass-devel opus-devel ocl-icd-devel
+ libbs2b-devel libvidstab-devel vmaf-devel $(vopt_if pulseaudio pulseaudio-devel)
+ $(vopt_if vaapi libva-devel) $(vopt_if vdpau libvdpau-devel)
+ $(vopt_if x265 x265-devel) $(vopt_if v4l2 v4l-utils-devel)
+ $(vopt_if fdk_aac fdk-aac-devel) $(vopt_if vpx libvpx-devel)
+ $(vopt_if aom libaom-devel) $(vopt_if sndio sndio-devel)
+ $(vopt_if dav1d libdav1d-devel) $(vopt_if zimg zimg-devel)
+ $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
+ $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
+ $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
+
+build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
+
+desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
+desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
+desc_option_sofa="Enable support for AES SOFA"
+desc_option_webp="Enable support for WebP"
+
+case "$XBPS_TARGET_MACHINE" in
+	i686*|x86_64*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau nvenc nvdec"
+			;;
+	ppc64*) build_options_default+=" vaapi vdpau";;
+	mips*) CFLAGS="-mnan=legacy";;
+esac
+
+if [ "$XBPS_TARGET_WORDSIZE" != "32" ]; then
+	build_options_default+=" svtav1"
+fi
+
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+fi
+
+_apply_patch() {
+	local args="$1" pname="$(basename $2)"
+
+	if [ ! -f ".${pname}_done" ]; then
+		patch -N $args -i $2
+		touch .${pname}_done
+	fi
+}
+
+post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64le*) ;;
+		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
+	esac
+
+	vsed -i libavfilter/vf_libvmaf.c -e 's!/usr/local/share/model/\(vmaf_v0.6.1\).pkl!/usr/share/vmaf/\1.json!'
+}
+
+do_configure() {
+	# Fix gcc on x86_64-musl only
+	if [ "$XBPS_TARGET_MACHINE" = "x86_64-musl" ]; then
+		vsed -i configure -e "s;_cflags_speed='-O3';_cflags_speed='-O2';"
+	fi
+
+	if [ "$CROSS_BUILD" ]; then
+		case "$XBPS_TARGET_MACHINE" in
+			arm*) _arch="arm";;
+			aarch64*) _arch="aarch64";;
+			mips*) _arch="mips";;
+			ppc64*) _arch="ppc64";;
+			ppc*) _arch="ppc";;
+			*) _arch="${XBPS_TARGET_MACHINE%%-musl}";;
+		esac
+
+		_args+=" --enable-cross-compile
+			--sysroot=$XBPS_CROSS_BASE
+			--cross-prefix=${XBPS_CROSS_TRIPLET}-
+			--target-os=linux --arch=${_arch}"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc|ppc-musl) _args+=" --disable-altivec";;
+	esac
+
+	if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+		_args+=" --extra-libs=-latomic"
+	fi
+
+	./configure --prefix=/usr --disable-debug --enable-gpl --enable-gnutls \
+		--disable-stripping \
+		--enable-libcdio --enable-version3 --enable-runtime-cpudetect \
+		--enable-libmp3lame --enable-libvorbis --enable-libxvid \
+		--enable-libx264 $(vopt_enable vpx libvpx) --enable-libtheora \
+		--enable-shared --enable-static --enable-libxcb \
+		$(vopt_enable pulseaudio libpulse) --enable-libfreetype --enable-libmodplug \
+		--enable-libspeex --enable-libcelt --enable-libass \
+		--enable-libopus --enable-librtmp --enable-libjack \
+		$(vopt_if fdk_aac '--enable-nonfree --enable-libfdk-aac') \
+		--disable-libopencore_amrnb --disable-libopencore_amrwb \
+		--disable-libopenjpeg \
+		--enable-postproc --enable-opencl ${_args} --enable-libvmaf ${_args} \
+		$(vopt_enable x265 libx265) \
+		$(vopt_enable v4l2 libv4l2) \
+		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
+		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		$(vopt_enable dav1d libdav1d) \
+		$(vopt_enable zimg libzimg) \
+		$(vopt_enable webp libwebp) \
+		$(vopt_enable sofa libmysofa) \
+		$(vopt_enable vulkan) \
+		$(vopt_enable drm libdrm) \
+		$(vopt_enable svtav1 libsvtav1) \
+		$(vopt_enable srt libsrt) \
+		$(vopt_enable rist librist) \
+		$(vopt_if nvenc '--enable-nvenc') \
+		$(vopt_if nvdec '--enable-nvdec')
+}
+
+do_build() {
+	make ${makejobs}
+	make doc/ff{mpeg,play}.1
+}
+
+do_install() {
+	make DESTDIR=${DESTDIR} install install-man
+	rm -rf ${DESTDIR}/usr/bin
+}
+
+libavcodec4_package() {
+	short_desc="FFmpeg codec library"
+	pkg_install() {
+		vmove "usr/lib/libavcodec.so.*"
+	}
+}
+
+libavdevice4_package() {
+	short_desc="FFmpeg device handling library"
+	pkg_install() {
+		vmove "usr/lib/libavdevice.so.*"
+	}
+}
+
+libavresample4_package() {
+	short_desc="FFmpeg audio resampling library"
+	pkg_install() {
+		vmove "usr/lib/libavresample.so.*"
+	}
+}
+
+libavformat4_package() {
+	short_desc="FFmpeg file format library"
+	pkg_install() {
+		vmove "usr/lib/libavformat.so.*"
+	}
+}
+
+libavutil4_package() {
+	short_desc="FFmpeg utility library"
+	pkg_install() {
+		vmove "usr/lib/libavutil.so.*"
+	}
+}
+
+libavfilter4_package() {
+	short_desc="FFmpeg audio/video filter library"
+	pkg_install() {
+		vmove "usr/lib/libavfilter.so.*"
+	}
+}
+
+libpostproc4_package() {
+	short_desc="FFmpeg video postprocessing library"
+	pkg_install() {
+		vmove "usr/lib/libpostproc.so.*"
+	}
+}
+
+libswscale4_package() {
+	short_desc="FFmpeg video scaling library"
+	pkg_install() {
+		vmove "usr/lib/libswscale.so.*"
+	}
+}
+
+libswresample4_package() {
+	short_desc="FFmpeg video resampling library"
+	pkg_install() {
+		vmove "usr/lib/libswresample.so.*"
+	}
+}
+
+ffmpeg4-devel_package() {
+	depends="
+		libavcodec4>=${version}_${revision}
+		libavdevice4>=${version}_${revision}
+		libavformat4>=${version}_${revision}
+		libavutil4>=${version}_${revision}
+		libavfilter4>=${version}_${revision}
+		libpostproc4>=${version}_${revision}
+		libswscale4>=${version}_${revision}
+		libswresample4>=${version}_${revision}
+		libavresample4>=${version}_${revision}"
+	short_desc+=" - development files"
+	conflicts="ffmpeg-devel"
+	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
+		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
+		nostrip_files="/usr/lib/libavfilter.a"
+	fi
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.a"
+		vmove "usr/lib/*.so"
+		vmove usr/share/ffmpeg/examples
+		vmove usr/share/man/man3
+	}
+}
diff --git a/srcpkgs/libavcodec4 b/srcpkgs/libavcodec4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavcodec4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavdevice4 b/srcpkgs/libavdevice4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavdevice4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavfilter4 b/srcpkgs/libavfilter4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavfilter4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavformat4 b/srcpkgs/libavformat4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavformat4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavresample4 b/srcpkgs/libavresample4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavutil4 b/srcpkgs/libavutil4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavutil4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libpostproc4 b/srcpkgs/libpostproc4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libpostproc4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswresample4 b/srcpkgs/libswresample4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libswresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswscale4 b/srcpkgs/libswscale4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libswscale4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file

From 34b49866605a95bf2c98917a577509fd17a1c987 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:04 -0400
Subject: [PATCH 005/112] opencv: update to 4.7.0.

---
 common/shlibs           | 104 ++++++++++++++++++++--------------------
 srcpkgs/opencv/template |   8 ++--
 2 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index 177934cf6cc2d..165560a0af583 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2068,58 +2068,58 @@ libcapstone.so.5 capstone-5.0.1_1
 libhavege.so.2 libhaveged-1.9.11_1
 libnih.so.1 libnih-1.0.3_1
 libnih-dbus.so.1 libnih-1.0.3_1
-libopencv_quality.so.406 libopencv-4.6.0_1
-libopencv_reg.so.406 libopencv-4.6.0_1
-libopencv_surface_matching.so.406 libopencv-4.6.0_1
-libopencv_xphoto.so.406 libopencv-4.6.0_1
-libopencv_freetype.so.406 libopencv-4.6.0_1
-libopencv_fuzzy.so.406 libopencv-4.6.0_1
-libopencv_hfs.so.406 libopencv-4.6.0_1
-libopencv_img_hash.so.406 libopencv-4.6.0_1
-libopencv_line_descriptor.so.406 libopencv-4.6.0_1
-libopencv_saliency.so.406 libopencv-4.6.0_1
-libopencv_structured_light.so.406 libopencv-4.6.0_1
-libopencv_aruco.so.406 libopencv-4.6.0_1
-libopencv_bgsegm.so.406 libopencv-4.6.0_1
-libopencv_bioinspired.so.406 libopencv-4.6.0_1
-libopencv_ccalib.so.406 libopencv-4.6.0_1
-libopencv_face.so.406 libopencv-4.6.0_1
-libopencv_tracking.so.406 libopencv-4.6.0_1
-libopencv_xfeatures2d.so.406 libopencv-4.6.0_1
-libopencv_optflow.so.406 libopencv-4.6.0_1
-libopencv_ximgproc.so.406 libopencv-4.6.0_1
-libopencv_plot.so.406 libopencv-4.6.0_1
-libopencv_text.so.406 libopencv-4.6.0_1
-libopencv_ml.so.406 libopencv-4.6.0_1
-libopencv_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn.so.406 libopencv-4.6.0_1
-libopencv_shape.so.406 libopencv-4.6.0_1
-libopencv_stitching.so.406 libopencv-4.6.0_1
-libopencv_photo.so.406 libopencv-4.6.0_1
-libopencv_video.so.406 libopencv-4.6.0_1
-libopencv_calib3d.so.406 libopencv-4.6.0_1
-libopencv_features2d.so.406 libopencv-4.6.0_1
-libopencv_flann.so.406 libopencv-4.6.0_1
-libopencv_highgui.so.406 libopencv-4.6.0_1
-libopencv_videoio.so.406 libopencv-4.6.0_1
-libopencv_imgcodecs.so.406 libopencv-4.6.0_1
-libopencv_imgproc.so.406 libopencv-4.6.0_1
-libopencv_core.so.406 libopencv-4.6.0_1
-libopencv_superres.so.406 libopencv-4.6.0_1
-libopencv_videostab.so.406 libopencv-4.6.0_1
-libopencv_gapi.so.406 libopencv-4.6.0_1
-libopencv_xobjdetect.so.406 libopencv-4.6.0_1
-libopencv_datasets.so.406 libopencv-4.6.0_1
-libopencv_dnn_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn_superres.so.406 libopencv-4.6.0_1
-libopencv_dpm.so.406 libopencv-4.6.0_1
-libopencv_phase_unwrapping.so.406 libopencv-4.6.0_1
-libopencv_stereo.so.406 libopencv-4.6.0_1
-libopencv_rapid.so.406 libopencv-4.6.0_1
-libopencv_intensity_transform.so.406 libopencv-4.6.0_1
-libopencv_alphamat.so.406 libopencv-4.6.0_1
-libopencv_barcode.so.406 libopencv-4.6.0_1
-libopencv_mcc.so.406 libopencv-4.6.0_1
+libopencv_quality.so.407 libopencv-4.7.0_1
+libopencv_reg.so.407 libopencv-4.7.0_1
+libopencv_surface_matching.so.407 libopencv-4.7.0_1
+libopencv_xphoto.so.407 libopencv-4.7.0_1
+libopencv_freetype.so.407 libopencv-4.7.0_1
+libopencv_fuzzy.so.407 libopencv-4.7.0_1
+libopencv_hfs.so.407 libopencv-4.7.0_1
+libopencv_img_hash.so.407 libopencv-4.7.0_1
+libopencv_line_descriptor.so.407 libopencv-4.7.0_1
+libopencv_saliency.so.407 libopencv-4.7.0_1
+libopencv_structured_light.so.407 libopencv-4.7.0_1
+libopencv_aruco.so.407 libopencv-4.7.0_1
+libopencv_bgsegm.so.407 libopencv-4.7.0_1
+libopencv_bioinspired.so.407 libopencv-4.7.0_1
+libopencv_ccalib.so.407 libopencv-4.7.0_1
+libopencv_face.so.407 libopencv-4.7.0_1
+libopencv_tracking.so.407 libopencv-4.7.0_1
+libopencv_xfeatures2d.so.407 libopencv-4.7.0_1
+libopencv_optflow.so.407 libopencv-4.7.0_1
+libopencv_ximgproc.so.407 libopencv-4.7.0_1
+libopencv_plot.so.407 libopencv-4.7.0_1
+libopencv_text.so.407 libopencv-4.7.0_1
+libopencv_ml.so.407 libopencv-4.7.0_1
+libopencv_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn.so.407 libopencv-4.7.0_1
+libopencv_shape.so.407 libopencv-4.7.0_1
+libopencv_stitching.so.407 libopencv-4.7.0_1
+libopencv_photo.so.407 libopencv-4.7.0_1
+libopencv_video.so.407 libopencv-4.7.0_1
+libopencv_calib3d.so.407 libopencv-4.7.0_1
+libopencv_features2d.so.407 libopencv-4.7.0_1
+libopencv_flann.so.407 libopencv-4.7.0_1
+libopencv_highgui.so.407 libopencv-4.7.0_1
+libopencv_videoio.so.407 libopencv-4.7.0_1
+libopencv_imgcodecs.so.407 libopencv-4.7.0_1
+libopencv_imgproc.so.407 libopencv-4.7.0_1
+libopencv_core.so.407 libopencv-4.7.0_1
+libopencv_superres.so.407 libopencv-4.7.0_1
+libopencv_videostab.so.407 libopencv-4.7.0_1
+libopencv_gapi.so.407 libopencv-4.7.0_1
+libopencv_xobjdetect.so.407 libopencv-4.7.0_1
+libopencv_datasets.so.407 libopencv-4.7.0_1
+libopencv_dnn_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn_superres.so.407 libopencv-4.7.0_1
+libopencv_dpm.so.407 libopencv-4.7.0_1
+libopencv_phase_unwrapping.so.407 libopencv-4.7.0_1
+libopencv_stereo.so.407 libopencv-4.7.0_1
+libopencv_rapid.so.407 libopencv-4.7.0_1
+libopencv_intensity_transform.so.407 libopencv-4.7.0_1
+libopencv_alphamat.so.407 libopencv-4.7.0_1
+libopencv_barcode.so.407 libopencv-4.7.0_1
+libopencv_mcc.so.407 libopencv-4.7.0_1
 libuniconf.so.4.6 wvstreams-4.6.1_20
 libwvbase.so.4.6 wvstreams-4.6.1_20
 libwvutils.so.4.6 wvstreams-4.6.1_20
diff --git a/srcpkgs/opencv/template b/srcpkgs/opencv/template
index aea4bfc3a265c..ce94de9424d18 100644
--- a/srcpkgs/opencv/template
+++ b/srcpkgs/opencv/template
@@ -1,7 +1,7 @@
 # Template file for 'opencv'
 pkgname=opencv
-version=4.6.0
-revision=6
+version=4.7.0
+revision=1
 create_wrksrc=yes
 build_wrksrc=${pkgname}-${version}
 build_style=cmake
@@ -24,8 +24,8 @@ homepage="https://opencv.org"
 changelog="https://github.com/opencv/opencv/wiki/ChangeLog"
 distfiles="https://github.com/opencv/opencv/archive/${version}.tar.gz
  https://github.com/opencv/opencv_contrib/archive/${version}.tar.gz>contrib.tar.gz"
-checksum="1ec1cba65f9f20fe5a41fda1586e01c70ea0c9a6d7b67c9e13edf0cfe2239277
- 1777d5fd2b59029cf537e5fd6f8aa68d707075822f90bde683fcde086f85f7a7"
+checksum="8df0079cdbe179748a18d44731af62a245a45ebf5085223dc03133954c662973
+ 42df840cf9055e59d0e22c249cfb19f04743e1bdad113d31b1573d3934d62584"
 patch_args="-Np1 -d ${build_wrksrc}"
 # tests hang indenfinitely, even with test data included
 make_check=no

From a5a0848e0ee981494821f235c59551a9a6226e74 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 006/112] actiona: revbump for opencv-4.7.0

---
 srcpkgs/actiona/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/actiona/template b/srcpkgs/actiona/template
index cf5f0b7a2ae61..0d899311e6df7 100644
--- a/srcpkgs/actiona/template
+++ b/srcpkgs/actiona/template
@@ -1,7 +1,7 @@
 # Template file for 'actiona'
 pkgname=actiona
 version=3.10.1
-revision=2
+revision=3
 build_style=qmake
 configure_args="PKGCONFIG_OPENCV=opencv4"
 hostmakedepends="pkg-config qt5-plugin-mysql qt5-qmake qt5-host-tools"

From ec01bea533a4780f69427846e2e6a48fff6714da Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 007/112] retroshare: revbump for opencv-4.7.0

---
 srcpkgs/retroshare/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroshare/template b/srcpkgs/retroshare/template
index bb17569277a7f..49e2c1cbe8a53 100644
--- a/srcpkgs/retroshare/template
+++ b/srcpkgs/retroshare/template
@@ -1,7 +1,7 @@
 # Template file for 'retroshare'
 pkgname=retroshare
 version=0.6.6
-revision=3
+revision=4
 build_style=qmake
 #XXX broadcast feature requires an ancient udp-discovery-cpp which either needs
 # to be fetched+patched (FTBFS) here or packaged :/

From 1b42ee2016867a1e32943229aa1c2b2347280102 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 008/112] waifu2x-converter-cpp: revbump for opencv-4.7.0

---
 srcpkgs/waifu2x-converter-cpp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waifu2x-converter-cpp/template b/srcpkgs/waifu2x-converter-cpp/template
index 361b8a23b9497..c5ac17eb54ea4 100644
--- a/srcpkgs/waifu2x-converter-cpp/template
+++ b/srcpkgs/waifu2x-converter-cpp/template
@@ -1,7 +1,7 @@
 # Template file for 'waifu2x-converter-cpp'
 pkgname=waifu2x-converter-cpp
 version=5.2.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DINSTALL_MODELS=ON"
 hostmakedepends="pkg-config"

From 205a1b23433bb5f6db7e2b940fd685a861d08329 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:38 -0400
Subject: [PATCH 009/112] vlc: revbump for ffmpeg4

---
 srcpkgs/vlc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vlc/template b/srcpkgs/vlc/template
index fa46c57cba2fa..434c40c67df93 100644
--- a/srcpkgs/vlc/template
+++ b/srcpkgs/vlc/template
@@ -25,7 +25,7 @@ lib32disabled=yes
 hostmakedepends="automake libtool pkg-config flex gettext libgcrypt-devel
  live555-devel gettext-devel $(vopt_if lua lua52) $(vopt_if chromecast protobuf)"
 makedepends="
- avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg-devel freefont-ttf
+ avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg4-devel freefont-ttf
  gnutls-devel jack-devel liba52-devel libass-devel libbluray-devel
  libcdio-devel libdca-devel libdvbpsi-devel libdvdnav-devel libmad-devel
  libmatroska-devel libmodplug-devel libmpcdec-devel libmpeg2-devel

From 931bedfb8e3c14f656d16052b15808135ab09ea4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:55 -0400
Subject: [PATCH 010/112] osg: revbump for ffmpeg4

---
 srcpkgs/osg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/osg/template b/srcpkgs/osg/template
index a9ebbd287933b..755793f7e11bf 100644
--- a/srcpkgs/osg/template
+++ b/srcpkgs/osg/template
@@ -8,7 +8,7 @@ build_helper="qemu"
 configure_args="-DLIB_POSTFIX="
 hostmakedepends="pkg-config xrandr"
 makedepends="MesaLib-devel gtkglext-devel libcurl-devel giflib-devel librsvg-devel
- jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg-devel xine-lib-devel
+ jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg4-devel xine-lib-devel
  SDL2-devel gst-plugins-base1-devel
  $(vopt_if openexr libopenexr-devel)
  $(vopt_if poppler poppler-glib-devel)

From 9ac9eef4af17b567f8042936126a5b3d24fa1d7e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:13 -0400
Subject: [PATCH 011/112] xine-lib: revbump for ffmpeg4

---
 srcpkgs/xine-lib/template | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/xine-lib/template b/srcpkgs/xine-lib/template
index 3be4d08eac77a..ed6194c17d11e 100644
--- a/srcpkgs/xine-lib/template
+++ b/srcpkgs/xine-lib/template
@@ -1,14 +1,14 @@
 # Template file for 'xine-lib'
 pkgname=xine-lib
-version=1.2.12
-revision=3
+version=1.2.13
+revision=1
 build_style=gnu-configure
 configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
  --disable-oss"
 hostmakedepends="automake gettext-devel libtool pkg-config perl"
 makedepends="
  zlib-devel alsa-lib-devel libxcb-devel libSM-devel libXext-devel libXv-devel
- libXvMC-devel liba52-devel libmad-devel ffmpeg-devel pulseaudio-devel
+ libXvMC-devel liba52-devel libmad-devel ffmpeg4-devel pulseaudio-devel
  jack-devel samba-devel libflac-devel libmodplug-devel libmpcdec-devel
  speex-devel libtheora-devel libvorbis-devel libdca-devel faad2-devel
  libcdio-devel libbluray-devel aalib-devel libcaca-devel libXinerama-devel
@@ -19,7 +19,7 @@ license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="http://www.xine-project.org"
 changelog="https://sourceforge.net/projects/xine/files/xine-lib/${version}/README.txt/view"
 distfiles="${SOURCEFORGE_SITE}/xine/${pkgname}-${version}.tar.xz"
-checksum=d606270468e1540c2a89c0d7f5fdf11e17ecc0c2698cc0bcb1065ff26abee098
+checksum=5f10d6d718a4a51c17ed1b32b031d4f9b80b061e8276535b2be31e5ac4b75e6f
 
 case "$XBPS_TARGET_MACHINE" in
 	i686-musl)

From bf338ca390968b2875513004de6a011c8125b7b9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 012/112] attract: revbump for ffmpeg4

---
 srcpkgs/attract/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/attract/template b/srcpkgs/attract/template
index 24017d2bacc24..e760bf0d18aec 100644
--- a/srcpkgs/attract/template
+++ b/srcpkgs/attract/template
@@ -6,7 +6,7 @@ build_style=gnu-makefile
 make_build_args="VERBOSE=1"
 make_use_env=yes
 hostmakedepends="pkg-config"
-makedepends="SFML-devel ffmpeg-devel fontconfig-devel glu-devel libarchive-devel
+makedepends="SFML-devel ffmpeg4-devel fontconfig-devel glu-devel libarchive-devel
  libcurl-devel libjpeg-turbo-devel xine-lib rapidjson libXrandr-devel"
 depends="git"
 short_desc="Attract-Mode is a graphical frontend for emulators"

From d2b2ee943f71a219807b3d7848dc853b72f31b44 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 013/112] aubio: revbump for ffmpeg6

---
 srcpkgs/aubio/patches/ffmpeg5.patch | 25 +++++++++++++++++++++++++
 srcpkgs/aubio/template              |  2 +-
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/aubio/patches/ffmpeg5.patch

diff --git a/srcpkgs/aubio/patches/ffmpeg5.patch b/srcpkgs/aubio/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..aace41a6e6d9a
--- /dev/null
+++ b/srcpkgs/aubio/patches/ffmpeg5.patch
@@ -0,0 +1,25 @@
+From 8a05420e5dd8c7b8b2447f82dc919765876511b3 Mon Sep 17 00:00:00 2001
+From: Paul Brossier <piem@piem.org>
+Date: Tue, 25 Jan 2022 18:30:27 +0100
+Subject: [PATCH] [source_avcodec] define FF_API_LAVF_AVCTX for libavcodec >
+ 59, thx @berolinux (closes gh-353)
+
+---
+ src/io/source_avcodec.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/io/source_avcodec.c b/src/io/source_avcodec.c
+index e0ae93b5..1421bd9a 100644
+--- a/src/io/source_avcodec.c
++++ b/src/io/source_avcodec.c
+@@ -68,6 +68,10 @@
+ #define AUBIO_AVCODEC_MAX_BUFFER_SIZE AV_INPUT_BUFFER_MIN_SIZE
+ #endif
+ 
++#if LIBAVCODEC_VERSION_MAJOR >= 59
++#define FF_API_LAVF_AVCTX 1
++#endif
++
+ struct _aubio_source_avcodec_t {
+   uint_t hop_size;
+   uint_t samplerate;
diff --git a/srcpkgs/aubio/template b/srcpkgs/aubio/template
index ad1c4b2569917..7d875cc02541a 100644
--- a/srcpkgs/aubio/template
+++ b/srcpkgs/aubio/template
@@ -1,7 +1,7 @@
 # Template file for 'aubio'
 pkgname=aubio
 version=0.4.9
-revision=1
+revision=2
 build_style=waf3
 # XXX lash, pure and swig support.
 hostmakedepends="pkg-config txt2man"

From 1166cf6663d687d1de20e748c403fae80014f8de Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 014/112] audacious-plugins: revbump for ffmpeg6

---
 .../audacious-plugins/patches/ffmpeg5.patch   | 43 +++++++++++++++++++
 srcpkgs/audacious-plugins/template            |  2 +-
 2 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/audacious-plugins/patches/ffmpeg5.patch

diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg5.patch b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..4e5e34099d71c
--- /dev/null
+++ b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
@@ -0,0 +1,43 @@
+commit 298aa371c56c2f52c25a33d9bdec4918b11cebdc
+Author: tibequadorian <tibequadorian@posteo.de>
+Date:   Sat Mar 19 18:40:12 2022 +0100
+
+    audacious-plugins: rebuild against ffmpeg-5.0
+
+diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+new file mode 100644
+index 0000000000..617c11215b
+--- /dev/null
++++ b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+@@ -0,0 +1,31 @@
++From f60beb400eeb1e4778bbfd738bc4a4ccef3de539 Mon Sep 17 00:00:00 2001
++From: John Lindgren <john@jlindgren.net>
++Date: Sat, 5 Mar 2022 12:05:34 -0500
++Subject: [PATCH] Fix build with FFmpeg 5.0
++
++---
++ src/ffaudio/ffaudio-core.cc | 4 ++--
++ 1 file changed, 2 insertions(+), 2 deletions(-)
++
++diff --git a/src/ffaudio/ffaudio-core.cc b/src/ffaudio/ffaudio-core.cc
++index 16dc63e3a..a2b95fd6c 100644
++--- a/src/ffaudio/ffaudio-core.cc
+++++ b/src/ffaudio/ffaudio-core.cc
++@@ -274,7 +274,7 @@ static AVInputFormat * get_format_by_content (const char * name, VFSFile & file)
++         AVProbeData d = {name, buf, filled};
++         score = target;
++ 
++-        f = av_probe_input_format2 (& d, true, & score);
+++        f = (AVInputFormat *) av_probe_input_format2 (& d, true, & score);
++         if (f)
++             break;
++ 
++@@ -347,7 +347,7 @@ static bool find_codec (AVFormatContext * c, CodecInfo * cinfo)
++ #endif
++         if (stream && stream->codecpar && stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
++         {
++-            AVCodec * codec = avcodec_find_decoder (stream->codecpar->codec_id);
+++            AVCodec * codec = (AVCodec *) avcodec_find_decoder (stream->codecpar->codec_id);
++ 
++             if (codec)
++             {
diff --git a/srcpkgs/audacious-plugins/template b/srcpkgs/audacious-plugins/template
index 05e53a9adf78f..4b1968e03de78 100644
--- a/srcpkgs/audacious-plugins/template
+++ b/srcpkgs/audacious-plugins/template
@@ -2,7 +2,7 @@
 #Keep in sync with audacious!
 pkgname=audacious-plugins
 version=4.3.1
-revision=3
+revision=4
 build_style=meson
 configure_args="$(vopt_bool gtk3 gtk) $(vopt_bool gtk3)
  $(vopt_bool qt) $(vopt_bool qt qt6)"

From a3dd6f4cbca52315f82e65241227c14786fdb355 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 015/112] audacity: revbump for ffmpeg4

---
 srcpkgs/audacity/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/audacity/template b/srcpkgs/audacity/template
index 7b838119ab261..fb15f782ac1f7 100644
--- a/srcpkgs/audacity/template
+++ b/srcpkgs/audacity/template
@@ -1,7 +1,7 @@
 # Template file for 'audacity'
 pkgname=audacity
 version=3.4.2
-revision=1
+revision=2
 build_style=cmake
 build_helper="cmake-wxWidgets-gtk3 qemu"
 configure_args="-Daudacity_use_ffmpeg=loaded -Daudacity_lib_preference=system
@@ -12,7 +12,7 @@ configure_args="-Daudacity_use_ffmpeg=loaded -Daudacity_lib_preference=system
  -Daudacity_has_updates_check=OFF -DAUDACITY_BUILD_LEVEL=2"
 hostmakedepends="pkg-config gettext python3"
 makedepends="wxWidgets-gtk3-devel gtk+3-devel expat-devel lame-devel
- libsoxr-devel portaudio-devel sqlite-devel ffmpeg-devel
+ libsoxr-devel portaudio-devel sqlite-devel ffmpeg4-devel
  libid3tag-devel libmad-devel vamp-plugin-sdk-devel libogg-devel
  libvorbis-devel libflac-devel lilv-devel lv2 serd-devel sord-devel
  sratom-devel suil-devel portmidi-devel soundtouch-devel twolame-devel

From 4918167d8317a959036685243f7bd121adc1d38d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 016/112] avidemux: revbump for ffmpeg6

---
 srcpkgs/avidemux/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/avidemux/template b/srcpkgs/avidemux/template
index 253a0243e2259..557285982d2b8 100644
--- a/srcpkgs/avidemux/template
+++ b/srcpkgs/avidemux/template
@@ -1,7 +1,7 @@
 # Template file for 'avidemux'
 pkgname=avidemux
 version=2.8.0
-revision=2
+revision=3
 # Can't be compiled for aarch64, arm* or mips*
 archs="x86_64* i686*"
 hostmakedepends="cmake pkg-config qt5-host-tools qt5-devel tar yasm"

From 28c85e97880ee61c7b235430556ddee6d4cb69fc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 017/112] blender: revbump for ffmpeg6

---
 srcpkgs/blender/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index 1dc61ec9d29d8..be35fac744876 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -9,8 +9,8 @@ configure_args="-DWITH_INSTALL_PORTABLE=OFF -DWITH_PYTHON_INSTALL=OFF
  -DWITH_JACK=ON -DWITH_CODEC_FFMPEG=ON -DWITH_CODEC_SNDFILE=ON -DWITH_OPENMP=ON
  -DWITH_FFTW3=ON -DWITH_MOD_OCEANSIM=ON -DWITH_CYCLES_EMBREE=OFF -DWITH_OPENCOLORIO=ON
  -DWITH_IMAGE_OPENEXR=ON -DWITH_IMAGE_OPENJPEG=ON -DWITH_OPENSUBDIV=ON
- -DWITH_OPENCOLLADA=ON -DWITH_SYSTEM_GLEW=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
- -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_LIBDECOR=ON
+ -DWITH_OPENCOLLADA=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
+ -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_WAYLAND_LIBDECOR=ON
  -DWITH_BUILDINFO=OFF -DPYTHON_VERSION=${py3_ver} -DPYTHON_LIBPATH=/usr/lib
  -DPYTHON_LIBRARY=python${py3_ver}${py3_abiver} -DPYTHON_INCLUDE_DIRS=/${py3_inc}
  -DWITH_SYSTEM_LZO=ON -DWITH_SYSTEM_EIGEN3=ON -DWITH_SYSTEM_FREETYPE=ON"

From 4adddee6b290bc325ad9dfad4961a2fd2ad6739e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 018/112] cantata: revbump for ffmpeg6

---
 srcpkgs/cantata/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cantata/template b/srcpkgs/cantata/template
index 4b417d80d5c2d..8a90aaa4c07a2 100644
--- a/srcpkgs/cantata/template
+++ b/srcpkgs/cantata/template
@@ -1,7 +1,7 @@
 # Template file for 'cantata'
 pkgname=cantata
 version=2.5.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools qt5-tools"
 makedepends="qt5-devel qt5-tools-devel qt5-svg-devel qt5-xmlpatterns-devel

From 680bfb0c23ddd07840d871acce85003515b69a17 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 019/112] ccextractor: revbump for ffmpeg4

---
 srcpkgs/ccextractor/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ccextractor/template b/srcpkgs/ccextractor/template
index 84059ffd02398..3ca8ec45d6989 100644
--- a/srcpkgs/ccextractor/template
+++ b/srcpkgs/ccextractor/template
@@ -6,7 +6,7 @@ build_wrksrc="linux"
 build_style=gnu-configure
 configure_args="--enable-ocr --enable-hardsubx"
 hostmakedepends="automake pkg-config"
-makedepends="leptonica-devel tesseract-ocr-devel ffmpeg-devel"
+makedepends="leptonica-devel tesseract-ocr-devel ffmpeg4-devel"
 short_desc="Extract subtitles from video streams"
 maintainer="newbluemoon <blaumolch@mailbox.org>"
 license="GPL-2.0-or-later"

From 2f944c6bf2936814dc9189b4ed798c88c7dfe599 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 020/112] chromaprint: revbump for ffmpeg6

---
 srcpkgs/chromaprint/patches/ffmpeg5.patch | 569 ++++++++++++++++++++++
 srcpkgs/chromaprint/template              |   2 +-
 2 files changed, 570 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromaprint/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromaprint/patches/ffmpeg5.patch b/srcpkgs/chromaprint/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..a9fd307a23c8a
--- /dev/null
+++ b/srcpkgs/chromaprint/patches/ffmpeg5.patch
@@ -0,0 +1,569 @@
+From 8ccad6937177b1b92e40ab8f4447ea27bac009a7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= <lalinsky@gmail.com>
+Date: Fri, 4 Nov 2022 21:47:38 +0100
+Subject: [PATCH] Use FFmpeg 5.x (#120)
+
+* Use FFmpeg 5.1.2 for CI builds
+
+* Build on Ubuntu 20.04
+
+* Upgrade code to FFmpeg 5.x APIs
+
+* Only set FFmpeg include dirs if building tools
+
+* No longer needed
+
+* Use ubuntu 20.04
+---
+ .github/workflows/build.yml                   |   6 +-
+ CMakeLists.txt                                |  16 --
+ package/build.sh                              |   4 +-
+ src/audio/ffmpeg_audio_processor.h            |   2 -
+ src/audio/ffmpeg_audio_processor_avresample.h |  72 -------
+ src/audio/ffmpeg_audio_processor_swresample.h |  18 +-
+ src/audio/ffmpeg_audio_reader.h               | 197 +++++++++---------
+ tests/CMakeLists.txt                          |   6 +
+ 8 files changed, 122 insertions(+), 199 deletions(-)
+ delete mode 100644 src/audio/ffmpeg_audio_processor_avresample.h
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index f8d6a32..4da2405 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -84,9 +84,6 @@ find_package(FFmpeg)
+ if(FFMPEG_LIBRARIES)
+ 	cmake_push_check_state(RESET)
+ 	set(CMAKE_REQUIRED_LIBRARIES ${FFMPEG_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -lm)
+-	check_function_exists(av_packet_unref HAVE_AV_PACKET_UNREF)
+-	check_function_exists(av_frame_alloc HAVE_AV_FRAME_ALLOC)
+-	check_function_exists(av_frame_free HAVE_AV_FRAME_FREE)
+ 	cmake_pop_check_state()
+ endif()
+
+@@ -163,14 +160,11 @@ message(STATUS "Using ${FFT_LIB} for FFT calculations")
+ if(NOT AUDIO_PROCESSOR_LIB)
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+ 		set(AUDIO_PROCESSOR_LIB "swresample")
+-	elseif(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(AUDIO_PROCESSOR_LIB "avresample")
+ 	endif()
+ endif()
+
+ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE OFF)
+ 		set(USE_SWRESAMPLE ON)
+ 		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBSWRESAMPLE_LIBRARIES})
+ 		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBSWRESAMPLE_INCLUDE_DIRS})
+@@ -178,16 +172,6 @@ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+ 	endif()
+ 	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+-elseif(AUDIO_PROCESSOR_LIB STREQUAL "avresample")
+-	if(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE ON)
+-		set(USE_SWRESAMPLE OFF)
+-		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBAVRESAMPLE_LIBRARIES})
+-		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBAVRESAMPLE_INCLUDE_DIRS})
+-	else()
+-		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+-	endif()
+-	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+ else()
+ 	message(STATUS "Building without audio conversion support, please install FFmpeg with libswresample")
+ endif()
+diff --git a/package/build.sh b/package/build.sh
+index da631ae..b41d36e 100755
+--- a/package/build.sh
++++ b/package/build.sh
+@@ -7,8 +7,8 @@ set -eux
+
+ BASE_DIR=$(cd $(dirname $0)/.. && pwd)
+
+-FFMPEG_VERSION=4.4.1
+-FFMPEG_BUILD_TAG=v4.4.1-1
++FFMPEG_VERSION=5.1.2
++FFMPEG_BUILD_TAG=v${FFMPEG_VERSION}-1
+
+ TMP_BUILD_DIR=$BASE_DIR/$(mktemp -d build.XXXXXXXX)
+ trap 'rm -rf $TMP_BUILD_DIR' EXIT
+diff --git a/src/audio/ffmpeg_audio_processor.h b/src/audio/ffmpeg_audio_processor.h
+index 7628fc7..39f4f6d 100644
+--- a/src/audio/ffmpeg_audio_processor.h
++++ b/src/audio/ffmpeg_audio_processor.h
+@@ -10,8 +10,6 @@
+
+ #if defined(USE_SWRESAMPLE)
+ #include "audio/ffmpeg_audio_processor_swresample.h"
+-#elif defined(USE_AVRESAMPLE)
+-#include "audio/ffmpeg_audio_processor_avresample.h"
+ #else
+ #error "no audio processing library"
+ #endif
+diff --git a/src/audio/ffmpeg_audio_processor_avresample.h b/src/audio/ffmpeg_audio_processor_avresample.h
+deleted file mode 100644
+index bd85f92..0000000
+--- a/src/audio/ffmpeg_audio_processor_avresample.h
++++ /dev/null
+@@ -1,72 +0,0 @@
+-// Copyright (C) 2016  Lukas Lalinsky
+-// Distributed under the MIT license, see the LICENSE file for details.
+-
+-#ifndef CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-#define CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-
+-extern "C" {
+-#include <libavresample/avresample.h>
+-}
+-
+-namespace chromaprint {
+-
+-class FFmpegAudioProcessor {
+-public:
+-	FFmpegAudioProcessor() {
+-		m_resample_ctx = avresample_alloc_context();
+-	}
+-
+-	~FFmpegAudioProcessor() {
+-		avresample_free(&m_resample_ctx);
+-	}
+-
+-	void SetCompatibleMode() {
+-		av_opt_set_int(m_resample_ctx, "filter_size", 16, 0);
+-		av_opt_set_int(m_resample_ctx, "phase_shift", 8, 0);
+-		av_opt_set_int(m_resample_ctx, "linear_interp", 1, 0);
+-		av_opt_set_double(m_resample_ctx, "cutoff", 0.8, 0);
+-	}
+-
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "in_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_rate", sample_rate, 0);
+-	}
+-
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "out_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_rate, 0);
+-	}
+-
+-	int Init() {
+-		return avresample_open(m_resample_ctx);
+-	}
+-
+-	int Convert(uint8_t **out, int out_count, const uint8_t **in, int in_count) {
+-		return avresample_convert(m_resample_ctx, out, 0, out_count, (uint8_t **) in, 0, in_count);
+-	}
+-
+-	int Flush(uint8_t **out, int out_count) {
+-		return avresample_read(m_resample_ctx, out, out_count);
+-	}
+-
+-private:
+-	AVAudioResampleContext *m_resample_ctx = nullptr;
+-};
+-
+-}; // namespace chromaprint
+-
+-#endif
+diff --git a/src/audio/ffmpeg_audio_processor_swresample.h b/src/audio/ffmpeg_audio_processor_swresample.h
+index b86266b..b1d4bea 100644
+--- a/src/audio/ffmpeg_audio_processor_swresample.h
++++ b/src/audio/ffmpeg_audio_processor_swresample.h
+@@ -28,30 +28,28 @@ public:
+ 		av_opt_set_double(m_swr_ctx, "cutoff", 0.8, 0);
+ 	}
+
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "icl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "ich", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetInputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "in_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "isf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "in_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "isr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "in_sample_rate", sample_rate, 0);
+ 	}
+
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "ocl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "och", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetOutputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "out_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "osf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "out_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "osr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "out_sample_rate", sample_rate, 0);
+ 	}
+
+ 	int Init() {
+diff --git a/src/audio/ffmpeg_audio_reader.h b/src/audio/ffmpeg_audio_reader.h
+index 5550164..1c6b346 100644
+--- a/src/audio/ffmpeg_audio_reader.h
++++ b/src/audio/ffmpeg_audio_reader.h
+@@ -62,7 +62,7 @@ public:
+ 	bool Read(const int16_t **data, size_t *size);
+
+ 	bool IsOpen() const { return m_opened; }
+-	bool IsFinished() const { return m_finished && !m_got_frame; }
++	bool IsFinished() const { return !m_has_more_packets && !m_has_more_frames; }
+
+ 	std::string GetError() const { return m_error; }
+ 	int GetErrorCode() const { return m_error_code; }
+@@ -74,20 +74,19 @@ private:
+ 	uint8_t *m_convert_buffer[1] = { nullptr };
+ 	int m_convert_buffer_nb_samples = 0;
+
+-	AVInputFormat *m_input_fmt = nullptr;
++	const AVInputFormat *m_input_fmt = nullptr;
+ 	AVDictionary *m_input_opts = nullptr;
+
+ 	AVFormatContext *m_format_ctx = nullptr;
+ 	AVCodecContext *m_codec_ctx = nullptr;
+-	AVFrame *m_frame = nullptr;
+ 	int m_stream_index = -1;
+ 	std::string m_error;
+ 	int m_error_code = 0;
+-	bool m_finished = false;
+ 	bool m_opened = false;
+-	int m_got_frame = 0;
+-	AVPacket m_packet;
+-	AVPacket m_packet0;
++	bool m_has_more_packets = true;
++	bool m_has_more_frames = true;
++	AVPacket *m_packet = nullptr;
++	AVFrame *m_frame = nullptr;
+
+ 	int m_output_sample_rate = 0;
+ 	int m_output_channels = 0;
+@@ -98,19 +97,12 @@ private:
+
+ inline FFmpegAudioReader::FFmpegAudioReader() {
+ 	av_log_set_level(AV_LOG_QUIET);
+-
+-	av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
+ }
+
+ inline FFmpegAudioReader::~FFmpegAudioReader() {
+ 	Close();
+ 	av_dict_free(&m_input_opts);
+ 	av_freep(&m_convert_buffer[0]);
+-	av_packet_unref(&m_packet0);
+ }
+
+ inline bool FFmpegAudioReader::SetInputFormat(const char *name) {
+@@ -135,11 +127,10 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ 	Close();
+
+-    av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
++	m_packet = av_packet_alloc();
++	if (!m_packet) {
++		return false;
++	}
+
+ 	ret = avformat_open_input(&m_format_ctx, file_name.c_str(), m_input_fmt, &m_input_opts);
+ 	if (ret < 0) {
+@@ -153,26 +144,31 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		return false;
+ 	}
+
+-	AVCodec *codec;
++	const AVCodec *codec;
+ 	ret = av_find_best_stream(m_format_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &codec, 0);
+ 	if (ret < 0) {
+ 		SetError("Could not find any audio stream in the file", ret);
+ 		return false;
+ 	}
+ 	m_stream_index = ret;
++	auto stream = m_format_ctx->streams[m_stream_index];
+
+-	m_codec_ctx = m_format_ctx->streams[m_stream_index]->codec;
++	m_codec_ctx = avcodec_alloc_context3(codec);
+ 	m_codec_ctx->request_sample_fmt = AV_SAMPLE_FMT_S16;
+
++	ret = avcodec_parameters_to_context(m_codec_ctx, stream->codecpar);
++	if (ret < 0) {
++		SetError("Could not copy the stream parameters", ret);
++		return false;
++	}
++
+ 	ret = avcodec_open2(m_codec_ctx, codec, nullptr);
+ 	if (ret < 0) {
+ 		SetError("Could not open the codec", ret);
+ 		return false;
+ 	}
+
+-	if (!m_codec_ctx->channel_layout) {
+-		m_codec_ctx->channel_layout = av_get_default_channel_layout(m_codec_ctx->channels);
+-	}
++	av_dump_format(m_format_ctx, 0, "foo", 0);
+
+ 	m_frame = av_frame_alloc();
+ 	if (!m_frame) {
+@@ -183,19 +179,23 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		m_output_sample_rate = m_codec_ctx->sample_rate;
+ 	}
+
+-	if (!m_output_channels) {
+-		m_output_channels = m_codec_ctx->channels;
++	AVChannelLayout output_channel_layout;
++	if (m_output_channels) {
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
++	} else {
++		m_output_channels = m_codec_ctx->ch_layout.nb_channels;
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
+ 	}
+
+-	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
++	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->ch_layout.nb_channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
+ 		m_converter.reset(new FFmpegAudioProcessor());
+ 		m_converter->SetCompatibleMode();
+ 		m_converter->SetInputSampleFormat(m_codec_ctx->sample_fmt);
+ 		m_converter->SetInputSampleRate(m_codec_ctx->sample_rate);
+-		m_converter->SetInputChannelLayout(m_codec_ctx->channel_layout);
++		m_converter->SetInputChannelLayout(&(m_codec_ctx->ch_layout));
+ 		m_converter->SetOutputSampleFormat(AV_SAMPLE_FMT_S16);
+ 		m_converter->SetOutputSampleRate(m_output_sample_rate);
+-		m_converter->SetOutputChannelLayout(av_get_default_channel_layout(m_output_channels));
++		m_converter->SetOutputChannelLayout(&output_channel_layout);
+ 		auto ret = m_converter->Init();
+ 		if (ret != 0) {
+ 			SetError("Could not create an audio converter instance", ret);
+@@ -203,10 +203,11 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		}
+ 	}
+
++	av_channel_layout_uninit(&output_channel_layout);
++
+ 	m_opened = true;
+-	m_finished = false;
+-	m_got_frame = 0;
+-	m_nb_packets = 0;
++	m_has_more_packets = true;
++	m_has_more_frames = true;
+ 	m_decode_error = 0;
+
+ 	return true;
+@@ -214,6 +215,7 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ inline void FFmpegAudioReader::Close() {
+ 	av_frame_free(&m_frame);
++	av_packet_free(&m_packet);
+
+ 	m_stream_index = -1;
+
+@@ -252,91 +254,98 @@ inline bool FFmpegAudioReader::Read(const int16_t **data, size_t *size) {
+ 		return false;
+ 	}
+
++	*data = nullptr;
++	*size = 0;
++
+ 	int ret;
++	bool needs_packet = false;
+ 	while (true) {
+-		while (m_packet.size <= 0) {
+-			av_packet_unref(&m_packet0);
+-			av_init_packet(&m_packet);
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			ret = av_read_frame(m_format_ctx, &m_packet);
++		while (needs_packet && m_packet->size == 0) {
++			ret = av_read_frame(m_format_ctx, m_packet);
+ 			if (ret < 0) {
+ 				if (ret == AVERROR_EOF) {
+-					m_finished = true;
++					needs_packet = false;
++					m_has_more_packets = false;
+ 					break;
+-				} else {
++				}
++				SetError("Error reading from the audio source", ret);
++				return false;
++			}
++			if (m_packet->stream_index == m_stream_index) {
++				needs_packet = false;
++			} else {
++				av_packet_unref(m_packet);
++			}
++		}
++
++		if (m_packet->size != 0) {
++			ret = avcodec_send_packet(m_codec_ctx, m_packet);
++			if (ret < 0) {
++				if (ret != AVERROR(EAGAIN)) {
+ 					SetError("Error reading from the audio source", ret);
+ 					return false;
+ 				}
+-			}
+-			m_packet0 = m_packet;
+-			if (m_packet.stream_index != m_stream_index) {
+-				m_packet.data = nullptr;
+-				m_packet.size = 0;
+ 			} else {
+-				m_nb_packets++;
++				av_packet_unref(m_packet);
+ 			}
+ 		}
+
+-		ret = avcodec_decode_audio4(m_codec_ctx, m_frame, &m_got_frame, &m_packet);
++		ret = avcodec_receive_frame(m_codec_ctx, m_frame);
+ 		if (ret < 0) {
+-			if (m_decode_error) {
+-				SetError("Error decoding audio frame", m_decode_error);
+-				return false;
++			if (ret == AVERROR_EOF) {
++				m_has_more_frames = false;
++			} else if (ret == AVERROR(EAGAIN)) {
++				if (m_has_more_packets) {
++					needs_packet = true;
++					continue;
++				} else {
++					m_has_more_frames = false;
++				}
+ 			}
+-			m_decode_error = ret;
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			continue;
++			SetError("Error decoding the audio source", ret);
++			return false;
+ 		}
+
+-		break;
+-	}
+-
+-	m_decode_error = 0;
+-
+-	const int decoded = std::min(ret, m_packet.size);
+-	m_packet.data += decoded;
+-	m_packet.size -= decoded;
+-
+-	if (m_got_frame) {
+-		if (m_converter) {
+-			if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
+-				int linsize;
+-				av_freep(&m_convert_buffer[0]);
+-				m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
+-				ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
+-				if (ret < 0) {
+-					SetError("Couldn't allocate audio converter buffer", ret);
++		if (m_frame->nb_samples > 0) {
++			if (m_converter) {
++				if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
++					int linsize;
++					av_freep(&m_convert_buffer[0]);
++					m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
++					ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->ch_layout.nb_channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
++					if (ret < 0) {
++						SetError("Couldn't allocate audio converter buffer", ret);
++						return false;
++					}
++				}
++				auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
++				if (nb_samples < 0) {
++					SetError("Couldn't convert audio", ret);
+ 					return false;
+ 				}
+-			}
+-			auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			}
+-			*data = (const int16_t *) m_convert_buffer[0];
+-			*size = nb_samples;
+-		} else {
+-			*data = (const int16_t *) m_frame->data[0];
+-			*size = m_frame->nb_samples;
+-		}
+-	} else {
+-		if (m_finished && m_converter) {
+-			auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			} else if (nb_samples > 0) {
+-				m_got_frame = 1;
+ 				*data = (const int16_t *) m_convert_buffer[0];
+ 				*size = nb_samples;
++			} else {
++				*data = (const int16_t *) m_frame->data[0];
++				*size = m_frame->nb_samples;
++			}
++		} else {
++			if (m_converter) {
++				if (IsFinished()) {
++					auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
++					if (nb_samples < 0) {
++						SetError("Couldn't convert audio", ret);
++						return false;
++					} else if (nb_samples > 0) {
++						*data = (const int16_t *) m_convert_buffer[0];
++						*size = nb_samples;
++					}
++				}
+ 			}
+ 		}
+-	}
+
+-	return true;
++		return true;
++	}
+ }
+
+ inline void FFmpegAudioReader::SetError(const char *message, int errnum) {
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index a2b517b..123e643 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -38,6 +38,12 @@ set(SRCS
+
+ if(BUILD_TOOLS)
+ 	set(SRCS ${SRCS} ../src/audio/ffmpeg_audio_reader_test.cpp)
++    include_directories(
++        ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}
++        ${AUDIO_PROCESSOR_INCLUDE_DIRS}
++    )
+ 	link_libraries(fpcalc_libs)
+ endif()
+
+-- 
+2.38.1
+
+
diff --git a/srcpkgs/chromaprint/template b/srcpkgs/chromaprint/template
index 7ef7838949f3a..1f7bbc70a22c8 100644
--- a/srcpkgs/chromaprint/template
+++ b/srcpkgs/chromaprint/template
@@ -1,7 +1,7 @@
 # Template file for 'chromaprint'
 pkgname=chromaprint
 version=1.5.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DBUILD_TOOLS=ON"
 make_check_target="check"

From 203a7654bac17d4b0fa8f71112906fe5e1687e2b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 021/112] chromium: revbump for ffmpeg6

---
 .../patches/chromium-119-ffmpeg-4.4.patch     | 20 --------
 srcpkgs/chromium/patches/ffmpeg5.patch        | 47 +++++++++++++++++++
 srcpkgs/chromium/template                     |  2 +-
 3 files changed, 48 insertions(+), 21 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch
 create mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch b/srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch
deleted file mode 100644
index 04d04b166ba37..0000000000000
--- a/srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch
+++ /dev/null
@@ -1,20 +0,0 @@
---- a/media/filters/ffmpeg_demuxer.cc.orig
-+++ b/media/filters/ffmpeg_demuxer.cc
-@@ -390,7 +390,7 @@
- 
-   scoped_refptr<DecoderBuffer> buffer;
- 
--    size_t side_data_size = 0;
-+    int side_data_size = 0;
-     uint8_t* side_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
- 
-@@ -453,7 +453,7 @@
-                                        packet->size - data_offset);
-     }
- 
--    size_t skip_samples_size = 0;
-+    int skip_samples_size = 0;
-     const uint32_t* skip_samples_ptr =
-         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
-             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..24e2da38e34ca
--- /dev/null
+++ b/srcpkgs/chromium/patches/ffmpeg5.patch
@@ -0,0 +1,47 @@
+--- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
++++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
+@@ -92,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+-  if (stream->start_time != kNoFFmpegTimestamp)
++  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -1597,7 +1585,7 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+@@ -1618,7 +1606,7 @@
+     if (stream->type() != DemuxerStream::VIDEO)
+       continue;
+ 
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+ 
+     if (!stream->IsEnabled())
diff --git a/srcpkgs/chromium/template b/srcpkgs/chromium/template
index 5613fa3813822..cd386c8a84ae6 100644
--- a/srcpkgs/chromium/template
+++ b/srcpkgs/chromium/template
@@ -2,7 +2,7 @@
 pkgname=chromium
 # See https://chromiumdash.appspot.com/releases?platform=Linux for the latest version
 version=120.0.6099.129
-revision=1
+revision=2
 archs="i686* x86_64* aarch64* armv7l*"
 hostmakedepends="
  $(vopt_if clang "clang lld llvm15")

From b75a6be05350b65481646b71a434aec8a3ce64f1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 022/112] cmus: revbump for ffmpeg6

---
 srcpkgs/chromium/patches/ffmpeg5.patch | 47 --------------------------
 srcpkgs/cmus/patches/ffmpeg6.patch     | 12 +++++++
 srcpkgs/cmus/template                  |  2 +-
 3 files changed, 13 insertions(+), 48 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch
 create mode 100644 srcpkgs/cmus/patches/ffmpeg6.patch

diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
deleted file mode 100644
index 24e2da38e34ca..0000000000000
--- a/srcpkgs/chromium/patches/ffmpeg5.patch
+++ /dev/null
@@ -1,47 +0,0 @@
---- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
-+++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
-@@ -92,24 +92,12 @@
- 
- static base::TimeDelta ExtractStartTime(AVStream* stream) {
-   // The default start time is zero.
--  base::TimeDelta start_time;
-+  base::TimeDelta start_time = kNoTimestamp;
- 
-   // First try to use  the |start_time| value as is.
--  if (stream->start_time != kNoFFmpegTimestamp)
-+  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
-     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
- 
--  // Next try to use the first DTS value, for codecs where we know PTS == DTS
--  // (excludes all H26x codecs). The start time must be returned in PTS.
--  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
--      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
--      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
--      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
--    const base::TimeDelta first_pts =
--        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
--    if (first_pts < start_time)
--      start_time = first_pts;
--  }
--
-   return start_time;
- }
- 
-@@ -1597,7 +1585,7 @@
-   for (const auto& stream : streams_) {
-     if (!stream || stream->IsEnabled() != enabled)
-       continue;
--    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
-+    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
-       continue;
-     if (!lowest_start_time_stream ||
-         stream->start_time() < lowest_start_time_stream->start_time()) {
-@@ -1618,7 +1606,7 @@
-     if (stream->type() != DemuxerStream::VIDEO)
-       continue;
- 
--    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
-+    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
-       continue;
- 
-     if (!stream->IsEnabled())
diff --git a/srcpkgs/cmus/patches/ffmpeg6.patch b/srcpkgs/cmus/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..ffa95ab811101
--- /dev/null
+++ b/srcpkgs/cmus/patches/ffmpeg6.patch
@@ -0,0 +1,12 @@
+--- a/ip/ffmpeg.c
++++ b/ip/ffmpeg.c
+@@ -202,9 +202,6 @@ static int ffmpeg_open(struct input_plugin_data *ip_data)
+ 			break;
+ 		}
+ 
+-		if (codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+-			cc->flags |= AV_CODEC_FLAG_TRUNCATED;
+-
+ 		if (avcodec_open2(cc, codec, NULL) < 0) {
+ 			d_print("could not open codec: %d, %s\n", cc->codec_id, avcodec_get_name(cc->codec_id));
+ 			err = -IP_ERROR_UNSUPPORTED_FILE_TYPE;
diff --git a/srcpkgs/cmus/template b/srcpkgs/cmus/template
index 0d1436744f1b2..a6e4b4fa86cb8 100644
--- a/srcpkgs/cmus/template
+++ b/srcpkgs/cmus/template
@@ -1,7 +1,7 @@
 # Template file for 'cmus'
 pkgname=cmus
 version=2.10.0
-revision=3
+revision=4
 build_style=configure
 configure_args="prefix=/usr LD=$CC"
 hostmakedepends="pkg-config"

From 1a9c2ae78d2abb0f2bc76c1cd9185d7f4ae54f42 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 023/112] cyanrip: revbump for ffmpeg6

---
 srcpkgs/cyanrip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cyanrip/template b/srcpkgs/cyanrip/template
index 9796e3461601a..5db30e020d17e 100644
--- a/srcpkgs/cyanrip/template
+++ b/srcpkgs/cyanrip/template
@@ -1,7 +1,7 @@
 # Template file for 'cyanrip'
 pkgname=cyanrip
 version=0.9.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config"
 makedepends="ffmpeg-devel libcdio-devel libcdio-paranoia-devel libcurl-devel libmusicbrainz5-devel"

From d4cdd2f5fe65f976506bb3b95795aa79cf5173d2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 024/112] deadbeef: revbump for ffmpeg4

---
 srcpkgs/deadbeef/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/deadbeef/template b/srcpkgs/deadbeef/template
index f5f4bf24b8cb6..7b47e615cd48e 100644
--- a/srcpkgs/deadbeef/template
+++ b/srcpkgs/deadbeef/template
@@ -1,14 +1,14 @@
 # Template file for 'deadbeef'
 pkgname=deadbeef
 version=1.8.8
-revision=3
+revision=4
 create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-oss --disable-lfm --disable-notify --disable-gtk2"
 hostmakedepends="automake libtool gettext gettext-devel intltool pkg-config
  yasm clang glib-devel"
 makedepends="
- alsa-lib-devel dbus-devel faad2-devel ffmpeg-devel gtk+3-devel imlib2-devel
+ alsa-lib-devel dbus-devel faad2-devel ffmpeg4-devel gtk+3-devel imlib2-devel
  jansson-devel libcddb-devel libcdio-devel libcurl-devel libflac-devel
  libmad-devel libpng-devel libsamplerate-devel libsndfile-devel libvorbis-devel
  libzip-devel mpg123-devel opusfile-devel pulseaudio-devel wavpack-devel"

From ce2542448074da38f344d736dcb7203fc1ad764b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 025/112] droidcam-obs-plugin: revbump for ffmpeg6

---
 srcpkgs/droidcam-obs-plugin/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam-obs-plugin/template b/srcpkgs/droidcam-obs-plugin/template
index fc9c9bf6b9d54..fb0480754df4d 100644
--- a/srcpkgs/droidcam-obs-plugin/template
+++ b/srcpkgs/droidcam-obs-plugin/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam-obs-plugin'
 pkgname=droidcam-obs-plugin
 version=2.0.1
-revision=1
+revision=2
 build_style=gnu-makefile
 make_use_env=yes
 make_build_args="ALLOW_STATIC=no"

From 8619e2ed8184b58c4dac226c275eb2c6a1cc8d3b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 026/112] droidcam: revbump for ffmpeg6

---
 srcpkgs/droidcam/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam/template b/srcpkgs/droidcam/template
index 1c3f1b8b1fc67..32a9220b79a4d 100644
--- a/srcpkgs/droidcam/template
+++ b/srcpkgs/droidcam/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam'
 pkgname=droidcam
 version=1.8.2
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="USBMUXD=-lusbmuxd-2.0 JPEG=-lturbojpeg"
 hostmakedepends="pkg-config"

From fb44cd8a5141ef98f5ddcac4c7f7eb42817521e5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 027/112] ffmpegthumbnailer: revbump for ffmpeg6

---
 .../ffmpegthumbnailer/patches/ffmpeg6.patch   | 202 ++++++++++++++++++
 srcpkgs/ffmpegthumbnailer/template            |   6 +-
 2 files changed, 205 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch

diff --git a/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..363ff35a28419
--- /dev/null
+++ b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
@@ -0,0 +1,202 @@
+--- a/libffmpegthumbnailer/moviedecoder.cpp	2017-11-21 14:06:57.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.cpp	2023-05-05 13:14:47.946560668 -0400
+@@ -41,11 +41,6 @@
+ namespace ffmpegthumbnailer
+ {
+ 
+-struct SilenceLogLevel
+-{
+-    SilenceLogLevel() { av_log_set_level(AV_LOG_QUIET); }
+-};
+-
+ MovieDecoder::MovieDecoder(AVFormatContext* pavContext)
+ : m_VideoStream(-1)
+ , m_pFormatContext(pavContext)
+@@ -70,8 +65,6 @@
+ 
+ void MovieDecoder::initialize(const string& filename, bool preferEmbeddedMetadata)
+ {
+-    av_register_all();
+-    avcodec_register_all();
+     avformat_network_init();
+ 
+     string inputFile = filename == "-" ? "pipe:" : filename;
+@@ -97,8 +90,7 @@
+ {
+     if (m_pVideoCodecContext)
+     {
+-        avcodec_close(m_pVideoCodecContext);
+-        m_pVideoCodecContext = nullptr;
++        avcodec_free_context(&m_pVideoCodecContext);
+     }
+ 
+     if ((!m_FormatContextWasGiven) && m_pFormatContext)
+@@ -152,10 +144,10 @@
+     for (unsigned int i = 0; i < m_pFormatContext->nb_streams; ++i)
+     {
+         AVStream *stream = m_pFormatContext->streams[i];
+-        auto ctx = m_pFormatContext->streams[i]->codec;
+-        if (ctx->codec_type == AVMEDIA_TYPE_VIDEO)
++        auto par = m_pFormatContext->streams[i]->codecpar;
++        if (par->codec_type == AVMEDIA_TYPE_VIDEO)
+         {
+-            if (!preferEmbeddedMetadata || !isStillImageCodec(ctx->codec_id))
++            if (!preferEmbeddedMetadata || !isStillImageCodec(par->codec_id))
+             {
+                 videoStreams.push_back(i);
+                 continue;
+@@ -203,8 +195,7 @@
+     }
+ 
+     m_pVideoStream = m_pFormatContext->streams[m_VideoStream];
+-    m_pVideoCodecContext = m_pVideoStream->codec;
+-    m_pVideoCodec = avcodec_find_decoder(m_pVideoCodecContext->codec_id);
++    m_pVideoCodec = avcodec_find_decoder(m_pVideoStream->codecpar->codec_id);
+ 
+     if (m_pVideoCodec == nullptr)
+     {
+@@ -214,6 +205,20 @@
+         throw logic_error("Video Codec not found");
+     }
+ 
++    m_pVideoCodecContext = avcodec_alloc_context3(m_pVideoCodec);
++
++    if (m_pVideoCodecContext == nullptr)
++    {
++        destroy();
++        throw logic_error("Could not allocate video codec context");
++    }
++
++    if (avcodec_parameters_to_context(m_pVideoCodecContext, m_pVideoStream->codecpar) < 0)
++    {
++        destroy();
++        throw logic_error("Could not configure video codec context");
++    }
++
+     m_pVideoCodecContext->workaround_bugs = 1;
+ 
+     if (avcodec_open2(m_pVideoCodecContext, m_pVideoCodec, nullptr) < 0)
+@@ -386,13 +391,6 @@
+ 
+ void MovieDecoder::initializeFilterGraph(const AVRational& timeBase, const std::string& size, bool maintainAspectRatio)
+ {
+-    static const AVPixelFormat pixelFormats[] = { AV_PIX_FMT_RGB24, AV_PIX_FMT_NONE };
+-
+-    auto del = [] (AVBufferSinkParams* p) { av_freep(p); };
+-    std::unique_ptr<AVBufferSinkParams, decltype(del)> buffersinkParams(av_buffersink_params_alloc(), del);
+-
+-    avfilter_register_all();
+-
+     m_pFilterGraph = avfilter_graph_alloc();
+     assert(m_pFilterGraph);
+ 
+@@ -404,10 +402,8 @@
+ 
+     checkRc(avfilter_graph_create_filter(&m_pFilterSource, avfilter_get_by_name("buffer"), "thumb_buffer", ss.str().c_str(), nullptr, m_pFilterGraph),
+             "Failed to create filter source");
+-    buffersinkParams->pixel_fmts = pixelFormats;
+-    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, buffersinkParams.get(), m_pFilterGraph),
++    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, nullptr, m_pFilterGraph),
+             "Failed to create filter sink");
+-    buffersinkParams.release();
+ 
+     AVFilterContext* yadifFilter = nullptr;
+     if (m_pFrame->interlaced_frame != 0)
+@@ -500,15 +496,15 @@
+     }
+ 
+     checkRc(av_seek_frame(m_pFormatContext, -1, timestamp, 0), "Seeking in video failed");
+-    avcodec_flush_buffers(m_pFormatContext->streams[m_VideoStream]->codec);
++    avcodec_flush_buffers(m_pVideoCodecContext);
+ 
+     int keyFrameAttempts = 0;
+-    bool gotFrame = 0;
++    bool gotFrame;
+ 
+     do
+     {
+         int count = 0;
+-        gotFrame = 0;
++        gotFrame = false;
+ 
+         while (!gotFrame && count < 20)
+         {
+@@ -552,17 +548,33 @@
+         return false;
+     }
+ 
+-    av_frame_unref(m_pFrame);
+-
+-    int frameFinished;
++    int rc = avcodec_send_packet(m_pVideoCodecContext, m_pPacket);
++    if(rc == AVERROR(EAGAIN))
++    {
++        rc = 0;
++    }
+ 
+-    int bytesDecoded = avcodec_decode_video2(m_pVideoCodecContext, m_pFrame, &frameFinished, m_pPacket);
+-    if (bytesDecoded < 0)
++    if(rc == AVERROR_EOF)
++    {
++        return false;
++    }
++    else if(rc < 0)
+     {
+-        throw logic_error("Failed to decode video frame: bytesDecoded < 0");
++        throw logic_error("Failed to decode video frame: avcodec_send_packet() < 0");
+     }
+ 
+-    return frameFinished > 0;
++    rc = avcodec_receive_frame(m_pVideoCodecContext, m_pFrame);
++    switch(rc)
++    {
++        case 0:
++            return true;
++
++        case AVERROR(EAGAIN):
++            return false;
++
++        default:
++            throw logic_error("Failed to decode video frame: avcodec_receive_frame() < 0");
++    }
+ }
+ 
+ bool MovieDecoder::getVideoPacket()
+@@ -570,8 +582,6 @@
+     bool framesAvailable = true;
+     bool frameDecoded = false;
+ 
+-    int attempts = 0;
+-
+     if (m_pPacket)
+     {
+         av_packet_unref(m_pPacket);
+@@ -580,6 +590,7 @@
+ 
+     m_pPacket = new AVPacket();
+ 
++
+     while (framesAvailable && !frameDecoded)
+     {
+         framesAvailable = av_read_frame(m_pFormatContext, m_pPacket) >= 0;
+@@ -644,7 +655,7 @@
+ 
+ int32_t MovieDecoder::getStreamRotation()
+ {
+-    int32_t* matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
++    auto matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
+     if (matrix)
+     {
+         auto angle = lround(av_display_rotation_get(matrix));
+
+--- a/libffmpegthumbnailer/moviedecoder.h	2017-11-12 04:23:38.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.h	2023-05-05 13:26:07.095529911 -0400
+@@ -78,7 +78,7 @@
+     int                     m_VideoStream;
+     AVFormatContext*        m_pFormatContext;
+     AVCodecContext*         m_pVideoCodecContext;
+-    AVCodec*                m_pVideoCodec;
++    const AVCodec*          m_pVideoCodec;
+     AVFilterGraph*          m_pFilterGraph;
+     AVFilterContext*        m_pFilterSource;
+     AVFilterContext*        m_pFilterSink;
diff --git a/srcpkgs/ffmpegthumbnailer/template b/srcpkgs/ffmpegthumbnailer/template
index 039eea7622b39..35d546018d12a 100644
--- a/srcpkgs/ffmpegthumbnailer/template
+++ b/srcpkgs/ffmpegthumbnailer/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbnailer'
 pkgname=ffmpegthumbnailer
 version=2.2.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libpng-devel libjpeg-turbo-devel ffmpeg-devel"
@@ -9,8 +9,8 @@ depends="ffmpeg"
 short_desc="Lightweight video thumbnailer"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
-homepage="https://github.com/dirkvdb/${pkgname}"
-distfiles="${homepage}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
+homepage="https://github.com/dirkvdb"
+distfiles="${homepage}/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
 checksum=1cb24059c38223f657b300c84dd80491b7040d4b69471c4fea69be862bc99b5b
 
 post_install() {

From 80dca760a5bd42524e64e2d81707a60274d02ff1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 028/112] ffmpegthumbs: revbump for ffmpeg6

---
 srcpkgs/ffmpegthumbs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ffmpegthumbs/template b/srcpkgs/ffmpegthumbs/template
index 5f0b9414dadaf..11b88193528f4 100644
--- a/srcpkgs/ffmpegthumbs/template
+++ b/srcpkgs/ffmpegthumbs/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbs'
 pkgname=ffmpegthumbs
 version=22.12.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules kcoreaddons kconfig-devel
  pkg-config qt5-host-tools qt5-qmake gettext"

From 82aa89352a247b22e42ae60ee6f39799cdeb1f0f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 029/112] ffms2: revbump for ffmpeg6

---
 srcpkgs/ffms2/patches/ffmpeg5.patch | 424 ++++++++++++++++++++++++++++
 srcpkgs/ffms2/template              |   2 +-
 2 files changed, 425 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ffms2/patches/ffmpeg5.patch

diff --git a/srcpkgs/ffms2/patches/ffmpeg5.patch b/srcpkgs/ffms2/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..1479fabcafcb4
--- /dev/null
+++ b/srcpkgs/ffms2/patches/ffmpeg5.patch
@@ -0,0 +1,424 @@
+From 45673149e9a2f5586855ad472e3059084eaa36b1 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:41:21 +0100
+Subject: [PATCH] Use auto for AVCodec
+
+The geniuses over at FFmpeg decided to constify this API, so old
+versions of the library will return AVCodec *, while new versions
+of the libary will return const AVCodec *, which, in C++, are not
+OK to convert between.
+
+Rather than use some macro hell in ffmscompat.h, we can work around
+this by using auto.
+
+Gross.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 2 +-
+ src/core/indexing.cpp    | 6 +++---
+ src/core/videosource.cpp | 2 +-
+ 3 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index e4ce97c..ac09666 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -469,7 +469,7 @@ void FFMS_AudioSource::OpenFile() {
+ 
+     LAVFOpenFile(SourceFile.c_str(), FormatContext, TrackNumber);
+ 
+-    AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
++    auto *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
+     if (Codec == nullptr)
+         throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+             "Audio codec not found");
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index e547c5a..59fb4e8 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -384,7 +384,7 @@ FFMS_TrackType FFMS_Indexer::GetTrackType(int Track) {
+ }
+ 
+ const char *FFMS_Indexer::GetTrackCodec(int Track) {
+-    AVCodec *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
++    auto *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
+     return codec ? codec->name : nullptr;
+ }
+ 
+@@ -402,7 +402,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             UseDTS);
+ 
+         if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            AVCodec *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (!VideoCodec) {
+                 FormatContext->streams[i]->discard = AVDISCARD_ALL;
+                 IndexMask.erase(i);
+@@ -433,7 +433,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 IndexMask.insert(i);
+             }
+         } else if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+-            AVCodec *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (AudioCodec == nullptr)
+                 throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_UNSUPPORTED,
+                     "Audio codec not found");
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index b889970..8956c22 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -171,7 +171,7 @@ FFMS_VideoSource::FFMS_VideoSource(const char *SourceFile, FFMS_Index &Index, in
+ 
+         LAVFOpenFile(SourceFile, FormatContext, VideoTrack);
+ 
+-        AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
++        auto *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
+         if (Codec == nullptr)
+             throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+                 "Video codec not found");
+-- 
+2.40.0
+
+From 96cbf38ea9381829a1314f432a2c60495dcefaad Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:12:41 +0100
+Subject: [PATCH] all: Update AVPacket API usage
+
+AVPackets must all be on the heap now, since it is no longer
+part of the libav* ABI.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 16 ++++++----
+ src/core/indexing.cpp    | 63 ++++++++++++++++++++++------------------
+ src/core/indexing.h      |  4 +--
+ src/core/utils.cpp       |  6 ----
+ src/core/utils.h         |  1 -
+ src/core/videosource.cpp | 30 ++++++++++---------
+ 6 files changed, 64 insertions(+), 56 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index 37cf9ae..e4ce97c 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -285,10 +285,15 @@ FFMS_AudioSource::AudioBlock *FFMS_AudioSource::CacheBlock(CacheIterator &pos) {
+ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     CurrentFrame = &Frames[PacketNumber];
+ 
+-    AVPacket Packet;
+-    if (!ReadPacket(&Packet))
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++    if (!ReadPacket(Packet)) {
++        av_packet_free(&Packet);
+         throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_UNKNOWN,
+             "ReadPacket unexpectedly failed to read a packet");
++    }
+ 
+     // ReadPacket may have changed the packet number
+     CurrentFrame = &Frames[PacketNumber];
+@@ -297,8 +302,9 @@ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     int NumberOfSamples = 0;
+     AudioBlock *CachedBlock = nullptr;
+     
+-    int Ret = avcodec_send_packet(CodecContext, &Packet);
+-    av_packet_unref(&Packet);
++    int Ret = avcodec_send_packet(CodecContext, Packet);
++    av_packet_unref(Packet);
++    av_packet_free(&Packet);
+ 
+     av_frame_unref(DecodeFrame);
+     Ret = avcodec_receive_frame(CodecContext, DecodeFrame);
+@@ -513,8 +519,6 @@ void FFMS_AudioSource::Seek() {
+ }
+ 
+ bool FFMS_AudioSource::ReadPacket(AVPacket *Packet) {
+-    InitNullPacket(*Packet);
+-
+     while (av_read_frame(FormatContext, Packet) >= 0) {
+         if (Packet->stream_index == TrackNumber) {
+             // Required because not all audio packets, especially in ogg, have a pts. Use the previous valid packet's pts instead.
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index 23fb95b..e547c5a 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -320,7 +320,7 @@ void FFMS_Indexer::CheckAudioProperties(int Track, AVCodecContext *Context) {
+     }
+ }
+ 
+-void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict,
++void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict,
+                                     int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct) {
+     if (VideoContext.Parser) {
+         uint8_t *OB;
+@@ -330,8 +330,8 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+         av_parser_parse2(VideoContext.Parser,
+             VideoContext.CodecContext,
+             &OB, &OBSize,
+-            pkt.data, pkt.size,
+-            pkt.pts, pkt.dts, pkt.pos);
++            pkt->data, pkt->size,
++            pkt->pts, pkt->dts, pkt->pos);
+ 
+         // H.264 (PAFF) and HEVC may have one field per packet, so we need to track
+         // when we have a full or half frame available, and mark one of them as
+@@ -351,15 +351,15 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+ 
+         *RepeatPict = VideoContext.Parser->repeat_pict;
+         *FrameType = VideoContext.Parser->pict_type;
+-        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt.flags & AV_PKT_FLAG_DISCARD));
++        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt->flags & AV_PKT_FLAG_DISCARD));
+     } else {
+-        *Invisible = !!(pkt.flags & AV_PKT_FLAG_DISCARD);
++        *Invisible = !!(pkt->flags & AV_PKT_FLAG_DISCARD);
+     }
+ 
+     if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP8)
+-        ParseVP8(pkt.data[0], Invisible, FrameType);
++        ParseVP8(pkt->data[0], Invisible, FrameType);
+     else if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP9)
+-        ParseVP9(pkt.data[0], Invisible, FrameType);
++        ParseVP9(pkt->data[0], Invisible, FrameType);
+ }
+ 
+ void FFMS_Indexer::Free() {
+@@ -458,32 +458,36 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+         }
+     }
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
+     std::vector<int64_t> LastValidTS(FormatContext->nb_streams, AV_NOPTS_VALUE);
+ 
+     int64_t filesize = avio_size(FormatContext->pb);
+     enum AVPictureStructure LastPicStruct = AV_PICTURE_STRUCTURE_UNKNOWN;
+-    while (av_read_frame(FormatContext, &Packet) >= 0) {
++    while (av_read_frame(FormatContext, Packet) >= 0) {
+         // Update progress
+         // FormatContext->pb can apparently be NULL when opening images.
+         if (IC && FormatContext->pb) {
+-            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate))
++            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate)) {
++                av_packet_free(&Packet);
+                 throw FFMS_Exception(FFMS_ERROR_CANCELLED, FFMS_ERROR_USER,
+                     "Cancelled by user");
++            }
+         }
+-        if (!IndexMask.count(Packet.stream_index)) {
+-            av_packet_unref(&Packet);
++        if (!IndexMask.count(Packet->stream_index)) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+-        int Track = Packet.stream_index;
++        int Track = Packet->stream_index;
+         FFMS_Track &TrackInfo = (*TrackIndices)[Track];
+-        bool KeyFrame = !!(Packet.flags & AV_PKT_FLAG_KEY);
++        bool KeyFrame = !!(Packet->flags & AV_PKT_FLAG_KEY);
+         ReadTS(Packet, LastValidTS[Track], (*TrackIndices)[Track].UseDTS);
+ 
+         if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            int64_t PTS = TrackInfo.UseDTS ? Packet.dts : Packet.pts;
++            int64_t PTS = TrackInfo.UseDTS ? Packet->dts : Packet->pts;
+             if (PTS == AV_NOPTS_VALUE) {
+                 // VPx alt-refs are output as packets which lack timestmps or durations, since
+                 // they are invisible. Currently, the timestamp mangling code in libavformat
+@@ -495,9 +499,11 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 // FFMS2 currently sorts packets by PTS, which will break decoding, otherwise.
+                 bool HasAltRefs = (FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP8 ||
+                                    FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP9);
+-                if (Packet.duration == 0 && !HasAltRefs)
++                if (Packet->duration == 0 && !HasAltRefs) {
++                    av_packet_free(&Packet);
+                     throw FFMS_Exception(FFMS_ERROR_INDEXING, FFMS_ERROR_PARSER,
+                         "Invalid packet pts, dts, and duration");
++                }
+ 
+                 if (TrackInfo.empty())
+                     PTS = 0;
+@@ -513,7 +519,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             ParseVideoPacket(AVContexts[Track], Packet, &RepeatPict, &FrameType, &Invisible, &LastPicStruct);
+ 
+             TrackInfo.AddVideoFrame(PTS, RepeatPict, KeyFrame,
+-                FrameType, Packet.pos, Invisible);
++                FrameType, Packet->pos, Invisible);
+         } else if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+             // For video seeking timestamps are used only if all packets have
+             // timestamps, while for audio they're used if any have timestamps,
+@@ -522,28 +528,29 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 TrackInfo.HasTS = true;
+ 
+             int64_t StartSample = AVContexts[Track].CurrentSample;
+-            uint32_t SampleCount = IndexAudioPacket(Track, &Packet, AVContexts[Track], *TrackIndices);
++            uint32_t SampleCount = IndexAudioPacket(Track, Packet, AVContexts[Track], *TrackIndices);
+             TrackInfo.SampleRate = AVContexts[Track].CodecContext->sample_rate;
+ 
+             TrackInfo.AddAudioFrame(LastValidTS[Track],
+-                StartSample, SampleCount, KeyFrame, Packet.pos, Packet.flags & AV_PKT_FLAG_DISCARD);
++                StartSample, SampleCount, KeyFrame, Packet->pos, Packet->flags & AV_PKT_FLAG_DISCARD);
+         }
+ 
+-        if (!(Packet.flags & AV_PKT_FLAG_DISCARD))
+-            TrackInfo.LastDuration = Packet.duration;
++        if (!(Packet->flags & AV_PKT_FLAG_DISCARD))
++            TrackInfo.LastDuration = Packet->duration;
+ 
+-        av_packet_unref(&Packet);
++        av_packet_unref(Packet);
+     }
++    av_packet_free(&Packet);
+ 
+     TrackIndices->Finalize(AVContexts, FormatContext->iformat->name);
+     return TrackIndices.release();
+ }
+ 
+-void FFMS_Indexer::ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS) {
+-    if (!UseDTS && Packet.pts != AV_NOPTS_VALUE)
+-        TS = Packet.pts;
++void FFMS_Indexer::ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS) {
++    if (!UseDTS && Packet->pts != AV_NOPTS_VALUE)
++        TS = Packet->pts;
+     if (TS == AV_NOPTS_VALUE)
+         UseDTS = true;
+-    if (UseDTS && Packet.dts != AV_NOPTS_VALUE)
+-        TS = Packet.dts;
++    if (UseDTS && Packet->dts != AV_NOPTS_VALUE)
++        TS = Packet->dts;
+ }
+diff --git a/src/core/indexing.h b/src/core/indexing.h
+index 3cfc3c3..5c06868 100644
+--- a/src/core/indexing.h
++++ b/src/core/indexing.h
+@@ -80,10 +80,10 @@ private:
+     int64_t Filesize;
+     uint8_t Digest[20];
+ 
+-    void ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS);
++    void ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS);
+     void CheckAudioProperties(int Track, AVCodecContext *Context);
+     uint32_t IndexAudioPacket(int Track, AVPacket *Packet, SharedAVContext &Context, FFMS_Index &TrackIndices);
+-    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
++    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
+     void Free();
+ public:
+     FFMS_Indexer(const char *Filename);
+diff --git a/src/core/utils.cpp b/src/core/utils.cpp
+index ce67533..8a2e997 100644
+--- a/src/core/utils.cpp
++++ b/src/core/utils.cpp
+@@ -62,12 +62,6 @@ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo) {
+     }
+ }
+ 
+-void InitNullPacket(AVPacket &pkt) {
+-    av_init_packet(&pkt);
+-    pkt.data = nullptr;
+-    pkt.size = 0;
+-}
+-
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames) {
+     AP.SampleFormat = static_cast<FFMS_SampleFormat>(av_get_packed_sample_fmt(CTX->sample_fmt));
+     AP.BitsPerSample = av_get_bytes_per_sample(CTX->sample_fmt) * 8;
+diff --git a/src/core/utils.h b/src/core/utils.h
+index 9819dc7..003ab79 100644
+--- a/src/core/utils.h
++++ b/src/core/utils.h
+@@ -58,7 +58,6 @@ std::unique_ptr<T> make_unique(Args&&... args) {
+ }
+ 
+ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo);
+-void InitNullPacket(AVPacket &pkt);
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames);
+ 
+ void LAVFOpenFile(const char *SourceFile, AVFormatContext *&FormatContext, int Track);
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index 06bd161..b889970 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -673,30 +673,34 @@ void FFMS_VideoSource::DecodeNextFrame(int64_t &AStartTime, int64_t &Pos) {
+     if (HasPendingDelayedFrames())
+         return;
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
+-
+-    while (ReadFrame(&Packet) >= 0) {
+-        if (Packet.stream_index != VideoTrack) {
+-            av_packet_unref(&Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++
++    while (ReadFrame(Packet) >= 0) {
++        if (Packet->stream_index != VideoTrack) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+         if (AStartTime < 0)
+-            AStartTime = Frames.UseDTS ? Packet.dts : Packet.pts;
++            AStartTime = Frames.UseDTS ? Packet->dts : Packet->pts;
+ 
+         if (Pos < 0)
+-            Pos = Packet.pos;
++            Pos = Packet->pos;
+ 
+-        bool FrameFinished = DecodePacket(&Packet);
+-        av_packet_unref(&Packet);
+-        if (FrameFinished)
++        bool FrameFinished = DecodePacket(Packet);
++        av_packet_unref(Packet);
++        if (FrameFinished) {
++            av_packet_free(&Packet);
+             return;
++        }
+     }
+ 
+     // Flush final frames
+-    InitNullPacket(Packet);
+-    DecodePacket(&Packet);
++    DecodePacket(Packet);
++    av_packet_free(&Packet);
+ }
+ 
+ bool FFMS_VideoSource::SeekTo(int n, int SeekOffset) {
+-- 
+2.40.0
+
+From bf9e03e9e08534c024e5a744a6437c4aac160201 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:20:47 +0100
+Subject: [PATCH 2/3] configure: Remove deprecated API use
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ configure.ac | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index b35ef80bc..d19714d0f 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -102,10 +102,10 @@ CFLAGS="$_CFLAGS $FFMPEG_CFLAGS"
+
+ AC_DEFUN([TEST_FFMPEG],
+          [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+-            #include <libavcodec/avcodec.h>
++            #include <libavformat/avformat.h>
+             #include <libswscale/swscale.h>
+             ]],[[
+-                avcodec_register_all();
++                avformat_network_init();
+                 swscale_version();
+             ]])], [eval $1=yes], [eval $1=no])
+         ])
+
diff --git a/srcpkgs/ffms2/template b/srcpkgs/ffms2/template
index 365f64d10cbab..1641ecf43be5b 100644
--- a/srcpkgs/ffms2/template
+++ b/srcpkgs/ffms2/template
@@ -1,7 +1,7 @@
 # Template file for 'ffms2'
 pkgname=ffms2
 version=2.40
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-shared --disable-static"
 hostmakedepends="pkg-config autoconf automake libtool"

From a5ba123139637704b4dd9d72a8f95c9bf6cc8155 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 030/112] freerdp: revbump for ffmpeg6

---
 .../freerdp/patches/ffmpeg6_aa2cb9aa.patch    | 42 +++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100644 srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch

diff --git a/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
new file mode 100644
index 0000000000000..a4324da3a8822
--- /dev/null
+++ b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
@@ -0,0 +1,42 @@
+From aa2cb9aa5ff5562433598ba168a466e0752bca0e Mon Sep 17 00:00:00 2001
+From: akallabeth <akallabeth@posteo.net>
+Date: Tue, 14 Feb 2023 07:48:54 +0100
+Subject: [PATCH] Fixed #8686: Update h264 to use new FFMPEG API
+
+---
+ channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c | 2 ++
+ libfreerdp/codec/h264_ffmpeg.c            | 2 ++
+ 2 files changed, 4 insertions(+)
+
+diff --git a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+index 339462d865f..beea80b7a1e 100644
+--- a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
++++ b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+@@ -239,8 +239,10 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYP
+ 		}
+ 	}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 	if (mdecoder->codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		mdecoder->codec_context->flags |= AV_CODEC_FLAG_TRUNCATED;
++#endif
+ 
+ 	return TRUE;
+ }
+diff --git a/libfreerdp/codec/h264_ffmpeg.c b/libfreerdp/codec/h264_ffmpeg.c
+index 8a23db2473c..896a333019b 100644
+--- a/libfreerdp/codec/h264_ffmpeg.c
++++ b/libfreerdp/codec/h264_ffmpeg.c
+@@ -615,10 +615,12 @@ static BOOL libavcodec_init(H264_CONTEXT* h264)
+ 			goto EXCEPTION;
+ 		}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 		if (sys->codecDecoder->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		{
+ 			sys->codecDecoderContext->flags |= AV_CODEC_FLAG_TRUNCATED;
+ 		}
++#endif
+ 
+ #ifdef WITH_VAAPI
+ 

From 6f95df30c7649f7263415b868496cc25e2c8ec4a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 031/112] gerbera: revbump for ffmpeg6

---
 srcpkgs/gerbera/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gerbera/template b/srcpkgs/gerbera/template
index ae14f35c767c0..2dc0ac0ce03b5 100644
--- a/srcpkgs/gerbera/template
+++ b/srcpkgs/gerbera/template
@@ -1,7 +1,7 @@
 # Template file for 'gerbera'
 pkgname=gerbera
 version=1.12.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_SYSTEMD=0 -DWITH_AVCODEC=1"
 hostmakedepends="pkg-config"

From acf5850e004de48c6cbc75a4aa3c97d186e25af4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 032/112] goldendict: revbump for ffmpeg6

---
 srcpkgs/goldendict/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/goldendict/template b/srcpkgs/goldendict/template
index f4a05759f693d..97f44347b03a6 100644
--- a/srcpkgs/goldendict/template
+++ b/srcpkgs/goldendict/template
@@ -1,7 +1,7 @@
 # Template file for 'goldendict'
 pkgname=goldendict
 version=1.5.0
-revision=1
+revision=2
 build_style=qmake
 configure_args="CONFIG+=zim_support goldendict.pro"
 hostmakedepends="qt5-qmake pkg-config qt5-host-tools"
@@ -10,7 +10,7 @@ makedepends="tiff-devel qt5-devel libvorbis-devel zlib-devel
  qt5-webkit-devel lzo-devel bzip2-devel libao-devel qt5-svg-devel
  libeb-devel qt5-x11extras-devel ffmpeg-devel liblzma-devel
  qt5-multimedia-devel"
-short_desc="A feature-rich dictionary lookup program"
+short_desc="Feature-rich dictionary lookup program"
 maintainer="John <me@johnnynator.dev>"
 license="GPL-3.0-or-later"
 homepage="http://goldendict.org/"

From c567c80cfb6e234bd7156a9f2377d3c7f1d3c8ba Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 033/112] gst-libav: revbump for ffmpeg6

---
 srcpkgs/gst-libav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index 78afeee4aefb2..f892eb2063564 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.22.7
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"

From 7e2097258b3ee614adc00e468dbbc7b1d0bd811b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 034/112] gst-rtsp-server: revbump for ffmpeg6

---
 srcpkgs/gst-rtsp-server/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index 2c280c84f1514..83a2949fd9482 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
 version=1.22.7
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="glib-devel gst-plugins-bad1-devel gobject-introspection

From da99bdfb195f641167eb739811629361bd01c2ee Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 035/112] guvcview: update to 2.0.8.

---
 srcpkgs/guvcview/patches/fix-include.patch | 10 ++++++++++
 srcpkgs/guvcview/template                  |  7 +++----
 2 files changed, 13 insertions(+), 4 deletions(-)
 create mode 100644 srcpkgs/guvcview/patches/fix-include.patch

diff --git a/srcpkgs/guvcview/patches/fix-include.patch b/srcpkgs/guvcview/patches/fix-include.patch
new file mode 100644
index 0000000000000..503c2af3b78c1
--- /dev/null
+++ b/srcpkgs/guvcview/patches/fix-include.patch
@@ -0,0 +1,10 @@
+--- a/guvcview/guvcview.c
++++ b/guvcview/guvcview.c
+@@ -28,6 +28,7 @@
+ #include <sys/stat.h>
+ #include <sys/resource.h>
+ #include <errno.h>
++#include <locale.h>
+ 
+ #include "gview.h"
+ #include "gviewv4l2core.h"
diff --git a/srcpkgs/guvcview/template b/srcpkgs/guvcview/template
index d42fd38fa4ad1..86a7fd619612c 100644
--- a/srcpkgs/guvcview/template
+++ b/srcpkgs/guvcview/template
@@ -1,8 +1,7 @@
 # Template file for 'guvcview'
 pkgname=guvcview
-version=2.0.7
-revision=2
-create_wrksrc=yes
+version=2.0.8
+revision=1
 build_style=gnu-configure
 configure_args="--disable-static --disable-debian-menu"
 hostmakedepends="pkg-config intltool autoconf automake libtool glib-devel"
@@ -14,7 +13,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="http://guvcview.sourceforge.net/"
 distfiles="${SOURCEFORGE_SITE}/${pkgname}/${pkgname}-src-${version}.tar.bz2"
-checksum=f47d51fbd06e44eeaa1a82f4a153c927527c90d94514197a70b2956028cc8ad4
+checksum=a21f4e448286666cf27bafef5290cc953a0a1796b752e5bbe521266dc1230c81
 
 post_patch() {
 	sed '31a#include <locale.h>' -i  guvcview/guvcview.c

From bec2564fd1ec1e4bd56b9adc2bc1d15ade877452 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 036/112] handbrake: update to 1.6.1

---
 .../patches/fix-missing-x265-link-flag.patch    | 11 ++++++-----
 .../handbrake/patches/libhb-vpl-include.patch   | 15 +++++++++++++++
 srcpkgs/handbrake/template                      | 17 ++++++++++-------
 3 files changed, 31 insertions(+), 12 deletions(-)
 create mode 100644 srcpkgs/handbrake/patches/libhb-vpl-include.patch

diff --git a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
index 26db03867a0c8..d6bb2eda627a3 100644
--- a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
+++ b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
@@ -1,14 +1,15 @@
 --- a/gtk/configure.ac
 +++ b/gtk/configure.ac
 @@ -203,7 +203,7 @@
- 
+
  AM_CONDITIONAL([MINGW], [test "x$mingw_flag" = "xyes"])
- 
--HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg"
-+HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -ldl"
+
+-HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc"
++HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc -ldl"
  HB_CPPFLAGS="$HB_CPPFLAGS $HBINC"
- 
+
  PKG_CHECK_MODULES([x264], [x264], sys_x264=yes, sys_x264=no)
+
 --- a/test/module.defs
 +++ b/test/module.defs
 @@ -69,6 +69,9 @@
diff --git a/srcpkgs/handbrake/patches/libhb-vpl-include.patch b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
new file mode 100644
index 0000000000000..298f9f4ab28f2
--- /dev/null
+++ b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
@@ -0,0 +1,15 @@
+--- a/libhb/module.defs	2023-01-22 11:36:49.000000000 -0500
++++ b/libhb/module.defs	2023-04-03 22:37:52.395467010 -0400
+@@ -46,11 +46,7 @@
+ LIBHB.GCC.I += $(LIBHB.build/) $(CONTRIB.build/)include
+ 
+ ifeq (1,$(FEATURE.qsv))
+-    ifeq ($(HOST.system),freebsd))
+-        LIBHB.GCC.I += $(LOCALBASE)/include/vpl
+-    else
+-        LIBHB.GCC.I += $(CONTRIB.build/)include/vpl
+-    endif
++    LIBHB.GCC.I += /usr/include/vpl
+ endif
+ 
+ ifneq (,$(filter $(HOST.system),freebsd netbsd openbsd))
diff --git a/srcpkgs/handbrake/template b/srcpkgs/handbrake/template
index ca5e4571e49c3..c32cb1bfa31f4 100644
--- a/srcpkgs/handbrake/template
+++ b/srcpkgs/handbrake/template
@@ -1,10 +1,10 @@
 # Template file for 'handbrake'
 pkgname=handbrake
-version=1.5.1
+version=1.6.1
 revision=1
 build_style=gnu-configure
 configure_args="--force --disable-gtk-update-checks --disable-df-fetch --harden
- $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc)"
+ $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc) $(vopt_enable qsv)"
 make_build_args="-C ${XBPS_TRIPLET}"
 make_install_args="-C ${XBPS_TRIPLET}"
 hostmakedepends="automake cmake gettext-devel glib-devel intltool libtool m4 meson nasm pkg-config python3"
@@ -12,8 +12,11 @@ makedepends="bzip2-devel ffmpeg-devel gst-plugins-base1-devel gtk+3-devel
  jansson-devel lame-devel libass-devel libbluray-devel libdav1d-devel
  libdvdnav-devel libdvdread-devel libgudev-devel libnuma-devel
  libsamplerate-devel libtheora-devel libvorbis-devel libvpx-devel libxml2-devel
- opus-devel speex-devel x264-devel x265-devel zimg-devel
+ opus-devel speex-devel x264-devel x265-devel zimg-devel libsvt-av1-devel
  $(vopt_if fdk_aac fdk-aac-devel)
+ $(vopt_if qsv libva-devel)
+ $(vopt_if qsv libdrm-devel)
+ $(vopt_if qsv onevpl-devel)
  $(vopt_if nvenc nv-codec-headers)"
 depends="desktop-file-utils gst-plugins-good1 hicolor-icon-theme"
 short_desc="Multithreaded video transcoder"
@@ -21,15 +24,15 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-2.0-only"
 homepage="https://handbrake.fr/"
 distfiles="https://github.com/HandBrake/HandBrake/releases/download/${version}/HandBrake-${version}-source.tar.bz2"
-checksum=3999fe06d5309c819799a73a968a8ec3840e7840c2b64af8f5cdb7fd8c9430f0
+checksum=94ccfe03db917a91650000c510f7fd53f844da19f19ad4b4be1b8f6bc31a8d4c
 nocross=yes
 
-build_options="fdk_aac nvenc"
+build_options="fdk_aac nvenc qsv"
 
 case "$XBPS_TARGET_MACHINE" in
 	x86_64*|i686*)
 		CFLAGS="-msse"
-		build_options_default="nvenc"
+		build_options_default="nvenc qsv"
 		;;
 esac
 
@@ -37,7 +40,7 @@ pre_configure() {
 	# use system libraries, don't download them
 	rm -rf contrib/
 	for module in fdk-aac ffmpeg libbluray libdav1d libdvdnav libdvdread nvenc \
-		x265 zimg; do
+		x265 zimg svt-av1 libvpl; do
 	    vsed -i "/MODULES += contrib\/${module}/d" make/include/main.defs
 	done
 }

From c03321545961af2a62d7532d9cc4e46e35e963dd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 037/112] hedgewars: revbump for ffmpeg4

---
 srcpkgs/hedgewars/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/hedgewars/template b/srcpkgs/hedgewars/template
index 94b6db673b0c3..402ccfaaecbc2 100644
--- a/srcpkgs/hedgewars/template
+++ b/srcpkgs/hedgewars/template
@@ -1,13 +1,13 @@
 # Template file for 'hedgewars'
 pkgname=hedgewars
 version=1.0.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DNOSERVER=1 -DDATA_INSTALL_DIR=/usr/share/${pkgname}
  -DPHYSFS_SYSTEM=1 -DMINIMAL_FLAGS=1"
 make_cmd=make
 hostmakedepends="lua51 pkg-config qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
+makedepends="ffmpeg4-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
  SDL2_mixer-devel SDL2_net-devel SDL2_ttf-devel"
 depends="libfreeglut"
 short_desc="Funny turn-based artillery game, featuring fighting Hedgehogs!"

From 4e50b3ba69866b04de149e14328ba35e3cb9eefa Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 038/112] idjc: revbump for ffmpeg4

---
 srcpkgs/idjc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/idjc/template b/srcpkgs/idjc/template
index a9cde0665d55b..6f1d21c5781fd 100644
--- a/srcpkgs/idjc/template
+++ b/srcpkgs/idjc/template
@@ -5,7 +5,7 @@ revision=5
 build_style=gnu-configure
 hostmakedepends="pkg-config git python3 automake gettext-devel libtool"
 makedepends="libvorbis-devel libogg-devel jack-devel libsamplerate-devel
- libflac-devel libsndfile-devel mpg123-devel ffmpeg-devel speex-devel
+ libflac-devel libsndfile-devel mpg123-devel ffmpeg4-devel speex-devel
  glib-devel pixman-devel lame-devel python3-gobject-devel libshout-idjc-devel
  opus-devel twolame-devel python3-mutagen python3-devel"
 depends="python3-gobject python3-mutagen desktop-file-utils shared-mime-info python3-dbus jack"

From 10eec6485959d8b21b2ee7ff2cea877d7cc00f35 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 039/112] kid3: revbump for ffmpeg6

---
 srcpkgs/kid3/patches/ffmpeg5.patch | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 srcpkgs/kid3/patches/ffmpeg5.patch

diff --git a/srcpkgs/kid3/patches/ffmpeg5.patch b/srcpkgs/kid3/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..135fc50e07c9b
--- /dev/null
+++ b/srcpkgs/kid3/patches/ffmpeg5.patch
@@ -0,0 +1,17 @@
+# https://aur.archlinux.org/cgit/aur.git/diff/ffmpeg5.patch?h=kid3-cli&id=12410a74906612e7efc0ec8fbce739b4a0fef7e7
+diff --git a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+index e156d424..e12b9abd 100644
+--- a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
++++ b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+@@ -232,7 +232,11 @@ private:
+   friend class Format;
+   friend class Converter;
+   AVCodecContext* m_ptr;
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 0, 0)
+   AVCodec* m_impl;
++#else
++  const AVCodec* m_impl;
++#endif
+   AVFrame* m_frame;
+   bool m_opened;
+ };

From 5238e37f0aa6f4a5c3f0086408a9ef7844895044 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 040/112] kodi: revbump for ffmpeg4

---
 srcpkgs/kodi/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kodi/template b/srcpkgs/kodi/template
index d37a5918cd675..536ee1fc83a7d 100644
--- a/srcpkgs/kodi/template
+++ b/srcpkgs/kodi/template
@@ -54,7 +54,7 @@ makedepends="
  libmad-devel fontconfig-devel libXinerama-devel libsamplerate-devel libmms-devel
  enca-devel boost-devel libcurl-devel libva-devel libvdpau-devel libass-devel
  libbluetooth-devel yajl-devel libplist-devel librtmp-devel tinyxml-devel
- taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg-devel
+ taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg4-devel
  giflib-devel libxslt-devel gnutls-devel libssh-devel libmicrohttpd-devel
  libcec-devel dcadec-devel flatbuffers-devel fmt-devel lcms2-devel
  libfstrcmp-devel rapidjson libcdio-paranoia spdlog libwaylandpp-devel

From fe84ca0f1746768432a66adae283d634ebd11011 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 041/112] kpipewire: revbump for ffmpeg6

---
 srcpkgs/kpipewire/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kpipewire/template b/srcpkgs/kpipewire/template
index 6214a4451336e..3555348659dde 100644
--- a/srcpkgs/kpipewire/template
+++ b/srcpkgs/kpipewire/template
@@ -1,7 +1,7 @@
 # Template file for 'kpipewire'
 pkgname=kpipewire
 version=5.27.10
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules plasma-wayland-protocols gettext
  qt5-qmake qt5-host-tools pkg-config wayland-devel kcoreaddons

From 35ca88842067bbb2289dc2e95604602daa4f7e86 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 042/112] libextractor: revbump for ffmpeg4

---
 srcpkgs/libextractor/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libextractor/template b/srcpkgs/libextractor/template
index 044c663a3a0b9..ace88ae128da5 100644
--- a/srcpkgs/libextractor/template
+++ b/srcpkgs/libextractor/template
@@ -7,7 +7,7 @@ configure_args="--disable-static"
 hostmakedepends="pkg-config"
 makedepends="zlib-devel bzip2-devel exiv2-devel tiff-devel libpng-devel
  libjpeg-turbo-devel libvorbis-devel libflac-devel giflib-devel libmpeg2-devel
- ffmpeg-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
+ ffmpeg4-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
 short_desc="Library used to extract meta data from files"
 maintainer="Martin Riese <grauehaare@gmx.de>"
 license="GPL-3.0-or-later"

From 275e3f94d4750ba743f588a358dc0fe786dc5586 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 043/112] libopenal: revbump for ffmpeg6

---
 srcpkgs/libopenal/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenal/template b/srcpkgs/libopenal/template
index 88d0f11307d81..8308fca0393e3 100644
--- a/srcpkgs/libopenal/template
+++ b/srcpkgs/libopenal/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenal'
 pkgname=libopenal
 version=1.23.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DALSOFT_EXAMPLES=OFF"
 hostmakedepends="pkg-config"

From f861c11909b448c8fb2c39e845cdd7c0cebfcceb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 044/112] loudgain: revbump for ffmpeg6

---
 srcpkgs/loudgain/patches/ffmpeg5.patch | 11 +++++++++++
 srcpkgs/loudgain/template              |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/loudgain/patches/ffmpeg5.patch

diff --git a/srcpkgs/loudgain/patches/ffmpeg5.patch b/srcpkgs/loudgain/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..16d4510ee98fa
--- /dev/null
+++ b/srcpkgs/loudgain/patches/ffmpeg5.patch
@@ -0,0 +1,11 @@
+--- a/src/scan.c	2019-09-06 11:31:19.000000000 -0400
++++ b/src/scan.c	2023-03-23 11:15:40.867968521 -0400
+@@ -69,8 +69,6 @@
+ 	 * It is now useless
+ 	 * https://github.com/FFmpeg/FFmpeg/blob/70d25268c21cbee5f08304da95be1f647c630c15/doc/APIchanges#L86
+ 	 */
+-  if (avformat_version() < AV_VERSION_INT(58,9,100))
+-    av_register_all();
+ 
+ 	av_log_set_callback(scan_av_log);
+ 
diff --git a/srcpkgs/loudgain/template b/srcpkgs/loudgain/template
index da4f2d56e94c3..4d6bf29efb4fd 100644
--- a/srcpkgs/loudgain/template
+++ b/srcpkgs/loudgain/template
@@ -1,7 +1,7 @@
 # Template file for 'loudgain'
 pkgname=loudgain
 version=0.6.8
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libebur128-devel taglib-devel ffmpeg-devel"

From 5312b97e3808b1f56cb9a1ae3d89aca5c6c2cb5f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 045/112] mediastreamer: revbump for ffmpeg4

---
 srcpkgs/mediastreamer/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mediastreamer/template b/srcpkgs/mediastreamer/template
index 0fcffa7653d18..92ada88743a9b 100644
--- a/srcpkgs/mediastreamer/template
+++ b/srcpkgs/mediastreamer/template
@@ -5,7 +5,7 @@ revision=2
 build_style=cmake
 configure_args="-DENABLE_STRICT=0 -DENABLE_UNIT_TESTS=0"
 hostmakedepends="python3"
-makedepends="bzrtp-devel ffmpeg-devel glew-devel libXv-devel libsrtp-devel
+makedepends="bzrtp-devel ffmpeg4-devel glew-devel libXv-devel libsrtp-devel
  libupnp-devel libvpx-devel mbedtls-devel opus-devel ortp-devel pulseaudio-devel
  libtheora-devel speex-devel v4l-utils-devel bcg729-devel bcmatroska2-devel libgsm-devel
  zxing-cpp-devel"

From 748c43fdfbf719b9150af577ec72715baec4f3ff Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 046/112] mgba: revbump for ffmpeg6

---
 srcpkgs/mgba/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mgba/template b/srcpkgs/mgba/template
index 5513e3fd16f3f..f5c87a4893002 100644
--- a/srcpkgs/mgba/template
+++ b/srcpkgs/mgba/template
@@ -1,7 +1,7 @@
 # Template file for 'mgba'
 pkgname=mgba
 version=0.10.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake desktop-file-utils"
 makedepends="SDL2-devel ffmpeg-devel libedit-devel libepoxy-devel libmagick-devel

From a4eb15ae1a001fb156b1a10a1748224432e80d43 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 047/112] mlt: revbump for ffmpeg4

---
 srcpkgs/mlt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mlt/template b/srcpkgs/mlt/template
index 73e3915aaab9a..ec5054be3b75e 100644
--- a/srcpkgs/mlt/template
+++ b/srcpkgs/mlt/template
@@ -8,7 +8,7 @@ configure_args="--prefix=/usr --libdir=/usr/lib$XBPS_TARGET_WORDSIZE
  --swig-languages=python"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which"
 # XXX: movit vid.stab
-makedepends="alsa-lib-devel ffmpeg-devel gtk+-devel jack-devel ladspa-sdk
+makedepends="alsa-lib-devel ffmpeg4-devel gtk+-devel jack-devel ladspa-sdk
  libexif-devel libsamplerate-devel libxml2-devel sox-devel SDL_image-devel
  fftw-devel frei0r-plugins python3-devel pulseaudio-devel movit-devel
  libvidstab-devel"

From ab8197447eee4706610c034a5d6561cdae32a906 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 048/112] moc: revbump for ffmpeg4

---
 srcpkgs/moc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/moc/template b/srcpkgs/moc/template
index 3a04932c8f1e6..d8de816026b64 100644
--- a/srcpkgs/moc/template
+++ b/srcpkgs/moc/template
@@ -4,7 +4,7 @@ version=2.5.2
 revision=7
 build_style=gnu-configure
 hostmakedepends="pkg-config"
-makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg-devel
+makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg4-devel
  jack-devel alsa-lib-devel libltdl-devel libflac-devel libvorbis-devel
  libmad-devel libmpcdec-devel libmodplug-devel libid3tag-devel faad2-devel
  taglib-devel libsndfile-devel wavpack-devel speex-devel libsamplerate-devel

From 98655c66c727c21ebc6f79508281fec9f3f58652 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 049/112] motion: revbump for ffmpeg6

---
 srcpkgs/motion/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/motion/template b/srcpkgs/motion/template
index 607ebeb3c7b24..bf63a91d9764f 100644
--- a/srcpkgs/motion/template
+++ b/srcpkgs/motion/template
@@ -1,7 +1,7 @@
 # Template file for 'motion'
 pkgname=motion
 version=4.6.0
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake pkg-config gettext-devel tar"
 makedepends="ffmpeg-devel libmicrohttpd-devel v4l-utils-devel gettext-devel"

From a385ce03d64c548016f7aafaa4128364fb206880 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 050/112] olive: revbump for ffmpeg4

---
 srcpkgs/olive/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/olive/template b/srcpkgs/olive/template
index 12a46936c9900..5c2917b9c5124 100644
--- a/srcpkgs/olive/template
+++ b/srcpkgs/olive/template
@@ -1,10 +1,10 @@
 # Template file for 'olive'
 pkgname=olive
 version=0.1.2
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools pkg-config"
-makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg-devel frei0r-plugins"
+makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg4-devel frei0r-plugins"
 short_desc="Non-linear video editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"

From 99640eb35e1b9b2f84374cf77674506599941911 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 051/112] opentoonz: revbump for ffmpeg6

---
 srcpkgs/opentoonz/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/opentoonz/template b/srcpkgs/opentoonz/template
index ee9f7603f55fd..3e81834ca0edd 100644
--- a/srcpkgs/opentoonz/template
+++ b/srcpkgs/opentoonz/template
@@ -1,7 +1,7 @@
 # Template file for 'opentoonz'
 pkgname=opentoonz
 version=1.6.0
-revision=2
+revision=3
 build_wrksrc="toonz/sources"
 build_style=cmake
 make_cmd=make

From 59a83cffd9079936682df5240e225861efe1f0bc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 052/112] pianobar: revbump for ffmpeg6

---
 srcpkgs/pianobar/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pianobar/template b/srcpkgs/pianobar/template
index e3febb821a451..1e3dc1bf9308e 100644
--- a/srcpkgs/pianobar/template
+++ b/srcpkgs/pianobar/template
@@ -1,7 +1,7 @@
 # Template file for 'pianobar'
 pkgname=pianobar
 version=2022.04.01
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="V=1"
 hostmakedepends="pkg-config"

From a9fb57b647cbd58262efba730c5c9555a14b2068 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 053/112] ppsspp: revbump for ffmpeg4

---
 srcpkgs/ppsspp/template | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/srcpkgs/ppsspp/template b/srcpkgs/ppsspp/template
index 2c0ded496eb98..8bf55f65198cd 100644
--- a/srcpkgs/ppsspp/template
+++ b/srcpkgs/ppsspp/template
@@ -1,7 +1,7 @@
 # Template file for 'ppsspp'
 pkgname=ppsspp
 version=1.16.6
-revision=1
+revision=2
 _glslang_commit=b34f619e1c85810dcb3c578107d2e48ba4ee2b37
 _SPIRV_Cross_commit=4212eef67ed0ca048cb726a6767185504e7695e5
 _armips_commit=7bd1ec93d4586985ba1ef420b43b5e620f68695e
@@ -15,7 +15,7 @@ configure_args="-DHEADLESS=1 -DUSE_SYSTEM_FFMPEG=1 -DUNITTEST=ON
  -DUSING_QT_UI=$(vopt_if qt ON OFF) -DUSE_SYSTEM_ZSTD=ON
  -DARMIPS_USE_STD_FILESYSTEM=ON"
 hostmakedepends="pkg-config python3 $(vopt_if qt qt5-host-tools)"
-makedepends="zlib-devel glew-devel ffmpeg-devel libzip-devel
+makedepends="zlib-devel glew-devel ffmpeg4-devel libzip-devel
  snappy-devel rapidjson libpng-devel libzstd-devel
  $(vopt_if sdl2 'SDL2_ttf-devel SDL2-devel') $(vopt_if wayland wayland-devel)
  $(vopt_if qt 'qt5-devel qt5-multimedia-devel')"
@@ -69,10 +69,10 @@ post_extract() {
 	rmdir -v ${wrksrc}/ext/cpu_features
 	mv ${wrksrc}/cpu_features-${_cpu_features_commit} ${wrksrc}/ext/cpu_features
 	rmdir -v ${wrksrc}/ext/rcheevos
-        mv ${wrksrc}/rcheevos-${_rcheevos_commit} ${wrksrc}/ext/rcheevos
+	mv ${wrksrc}/rcheevos-${_rcheevos_commit} ${wrksrc}/ext/rcheevos
 }
 
-post_patch(){
+post_patch() {
 	# disable git versioning
 	vsed -e 's|find_package(Git)|# &|' -i git-version.cmake
 }
@@ -85,7 +85,6 @@ post_configure() {
 }
 
 do_install() {
-	vlicense LICENSE.TXT
 	vinstall icons/icon.svg 644 usr/share/pixmaps ppsspp.svg
 	vinstall Qt/PPSSPP.desktop 644 usr/share/applications
 	vbin build/PPSSPPHeadless ppsspp-headless

From 2429b81d8b32de5e18f46abdc9a67eba391abc9c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 054/112] pqiv: revbump for ffmpeg6

---
 srcpkgs/pqiv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pqiv/template b/srcpkgs/pqiv/template
index 542fc27a2d32a..9308d949b6a1c 100644
--- a/srcpkgs/pqiv/template
+++ b/srcpkgs/pqiv/template
@@ -1,7 +1,7 @@
 # Template file for 'pqiv'
 pkgname=pqiv
 version=2.12
-revision=1
+revision=2
 build_style=gnu-makefile
 hostmakedepends="pkg-config"
 makedepends="glib-devel gtk+3-devel $(vopt_if ffmpeg ffmpeg-devel)

From 0c4f53dd0a908c0dbb9db5b0a4162b2786b1ee51 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 055/112] qmmp: revbump for ffmpeg6

---
 srcpkgs/qmmp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qmmp/template b/srcpkgs/qmmp/template
index 53781ea3bc28a..2da07f1e87eac 100644
--- a/srcpkgs/qmmp/template
+++ b/srcpkgs/qmmp/template
@@ -1,7 +1,7 @@
 # Template file for 'qmmp'
 pkgname=qmmp
 version=1.6.1
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DUSE_HAL:BOOL=FALSE -DQMMP_DEFAULT_UI:STRING=simple"
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From 023b4a3a02aac109760c4e388cf72a6caf0dbe69 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 14 Dec 2023 13:28:10 -0500
Subject: [PATCH 056/112] qt6-pdf: revbump for ffmpeg6

---
 srcpkgs/qt6-pdf/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-pdf/template b/srcpkgs/qt6-pdf/template
index ecda84afac131..531b4e1d4fe84 100644
--- a/srcpkgs/qt6-pdf/template
+++ b/srcpkgs/qt6-pdf/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-pdf'
 pkgname=qt6-pdf
 version=6.6.0
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DQT_FEATURE_qtpdf_build=ON
  -DQT_FEATURE_qtpdf_widgets_build=ON

From bfcd9d0aef354538d69e9f4cde9acec8d04d9738 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 057/112] qt5-webengine: revbump for ffmpeg6

---
 .../chromium-media-filters-cpp14.patch        |  11 ++
 srcpkgs/qt5-webengine/patches/ffmpeg5.patch   | 179 ++++++++++++++++++
 .../qtwebengine-fix-ffmpeg5-build.patch       |  14 ++
 srcpkgs/qt5-webengine/template                |   4 +-
 4 files changed, 206 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/ffmpeg5.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch

diff --git a/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
new file mode 100644
index 0000000000000..04adc540f2cbc
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
@@ -0,0 +1,11 @@
+--- a/src/3rdparty/chromium/media/filters/BUILD.gn	2023-02-27 13:32:59.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/BUILD.gn	2023-04-02 17:21:39.204066384 -0400
+@@ -96,6 +96,8 @@
+     "//ui/gfx/geometry:geometry",
+   ]
+ 
++  cflags_cc = [ "-std=c++14" ]
++
+   libs = []
+ 
+   if (proprietary_codecs) {
diff --git a/srcpkgs/qt5-webengine/patches/ffmpeg5.patch b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..ac55e1634423a
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
@@ -0,0 +1,179 @@
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:57.732547446 -0400
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:09.486478995 -0400
+@@ -57,6 +57,8 @@
+ 
+ namespace {
+ 
++constexpr int64_t kRelativeTsBase = static_cast<int64_t>(0x7ffeffffffffffff);
++
+ void SetAVStreamDiscard(AVStream* stream, AVDiscard discard) {
+   DCHECK(stream);
+   stream->discard = discard;
+@@ -90,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+   if (stream->start_time != kNoFFmpegTimestamp)
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (stream->first_dts != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, stream->first_dts);
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -408,11 +398,11 @@
+   scoped_refptr<DecoderBuffer> buffer;
+ 
+   if (type() == DemuxerStream::TEXT) {
+-    int id_size = 0;
++    size_t id_size = 0;
+     uint8_t* id_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
+ 
+-    int settings_size = 0;
++    size_t settings_size = 0;
+     uint8_t* settings_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
+ 
+@@ -424,7 +414,7 @@
+     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
+                                      side_data.data(), side_data.size());
+   } else {
+-    int side_data_size = 0;
++    size_t side_data_size = 0;
+     uint8_t* side_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
+ 
+@@ -485,7 +475,7 @@
+                                        packet->size - data_offset);
+     }
+ 
+-    int skip_samples_size = 0;
++    size_t skip_samples_size = 0;
+     const uint32_t* skip_samples_ptr =
+         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
+             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
+@@ -1587,6 +1577,8 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++      continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+       lowest_start_time_stream = stream.get();
+@@ -1604,6 +1596,8 @@
+     if (stream && stream->type() == DemuxerStream::VIDEO &&
+         stream->IsEnabled()) {
+       video_stream = stream.get();
++      if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++        continue;
+       if (video_stream->start_time() <= seek_time) {
+         return video_stream;
+       }
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h qtwebengine-5.15.10/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h
+--- a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-07-11 22:12:47.917192788 -0500
+@@ -29,6 +29,7 @@ extern "C" {
+ #include <libavformat/avformat.h>
+ #include <libavformat/avio.h>
+ #include <libavutil/avutil.h>
++#include <libavutil/channel_layout.h>
+ #include <libavutil/imgutils.h>
+ #include <libavutil/log.h>
+ #include <libavutil/mastering_display_metadata.h>
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/audio_file_reader.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/audio_file_reader.cc
+--- a/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -85,7 +85,7 @@ bool AudioFileReader::OpenDemuxer() {
+ }
+ 
+ bool AudioFileReader::OpenDecoder() {
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (codec) {
+     // MP3 decodes to S16P which we don't support, tell it to use S16 instead.
+     if (codec_context_->sample_fmt == AV_SAMPLE_FMT_S16P)
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -329,7 +329,7 @@ bool FFmpegAudioDecoder::ConfigureDecode
+     }
+   }
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec ||
+       avcodec_open2(codec_context_.get(), codec, &codec_options) < 0) {
+     DLOG(ERROR) << "Could not initialize audio decoder: "
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -59,7 +59,6 @@ static int64_t AVIOSeekOperation(void* o
+ }
+ 
+ void FFmpegGlue::InitializeFFmpeg() {
+-  av_register_all();
+ }
+ 
+ static void LogContainer(bool is_local_file,
+@@ -95,9 +94,6 @@ FFmpegGlue::FFmpegGlue(FFmpegURLProtocol
+   // Enable fast, but inaccurate seeks for MP3.
+   format_context_->flags |= AVFMT_FLAG_FAST_SEEK;
+ 
+-  // Ensures we can read out various metadata bits like vp8 alpha.
+-  format_context_->flags |= AVFMT_FLAG_KEEP_SIDE_DATA;
+-
+   // Ensures format parsing errors will bail out. From an audit on 11/2017, all
+   // instances were real failures. Solves bugs like http://crbug.com/710791.
+   format_context_->error_recognition |= AV_EF_EXPLODE;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -391,7 +391,7 @@ bool FFmpegVideoDecoder::ConfigureDecode
+   if (decode_nalus_)
+     codec_context_->flags2 |= AV_CODEC_FLAG2_CHUNKS;
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
+     ReleaseFFmpegResources();
+     return false;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/media_file_checker.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/media_file_checker.cc
+--- a/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -68,7 +68,7 @@ bool MediaFileChecker::Start(base::TimeD
+       auto context = AVStreamToAVCodecContext(format_context->streams[i]);
+       if (!context)
+         continue;
+-      AVCodec* codec = avcodec_find_decoder(cp->codec_id);
++      const AVCodec* codec = avcodec_find_decoder(cp->codec_id);
+       if (codec && avcodec_open2(context.get(), codec, nullptr) >= 0) {
+         auto loop = std::make_unique<FFmpegDecodingLoop>(context.get());
+         stream_contexts[i] = {std::move(context), std::move(loop)};
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc qtwebengine-5.15.10/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc
+--- a/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -203,7 +203,7 @@ int32_t H264DecoderImpl::InitDecode(cons
+   // a pointer |this|.
+   av_context_->opaque = this;
+ 
+-  AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
+   if (!codec) {
+     // This is an indication that FFmpeg has not been initialized or it has not
+     // been compiled/initialized with the correct set of codecs.
diff --git a/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch b/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch
new file mode 100644
index 0000000000000..bc24d5b9a29cb
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch
@@ -0,0 +1,14 @@
+--- a/src/buildtools/configure.json	2023-12-09 11:06:01.503058569 -0500
++++ b/src/buildtools/configure.json	2023-12-09 11:06:14.982361345 -0500
+@@ -779,11 +779,6 @@
+             "type": "warning",
+             "condition": "config.ios && config.simulator && config.device && features.build-qtpdf",
+             "message": "Building fat libray with device and simulator architectures will disable NEON."
+-        },
+-        {
+-            "type": "fatal",
+-            "condition": "features.webengine-system-ffmpeg && !libs.webengine-ffmpeg-support",
+-            "message": "Unmodified ffmpeg >= 5.0 is not supported. Please configure with -qt-webengine-ffmpeg."
+         }
+     ],
+     "summary": [
diff --git a/srcpkgs/qt5-webengine/template b/srcpkgs/qt5-webengine/template
index 8d2df1b5175ba..1687a77eb8a2f 100644
--- a/srcpkgs/qt5-webengine/template
+++ b/srcpkgs/qt5-webengine/template
@@ -1,14 +1,14 @@
 # Template file for 'qt5-webengine'
 pkgname=qt5-webengine
 version=5.15.16
-revision=1
+revision=2
 _version="${version}-lts"
 _chromium_commit=207c2ac45ca3386d153770c6b0d2ea2ec21ca880
 archs="x86_64* i686* armv[67]* ppc64* aarch64*"
 create_wrksrc=yes
 build_style=qmake
 configure_args="--
- -webengine-icu -webengine-ffmpeg -webengine-opus -webengine-webp
+ -webengine-icu -system-ffmpeg -webengine-opus -webengine-webp
  -webengine-pepper-plugins -webengine-printing-and-pdf -webengine-proprietary-codecs
  -webengine-pulseaudio -webengine-spellchecker -webengine-webrtc -webengine-geolocation
  -webengine-kerberos -no-webengine-embedded-build $(vopt_if sndio '' '-no')-webengine-sndio

From b39ca2c42aa535ff32d130953cc3e8b7c30132c1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 058/112] qt5: revbump for ffmpeg6

---
 srcpkgs/qt5/template | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/srcpkgs/qt5/template b/srcpkgs/qt5/template
index ef6e437e02dbc..97b7818cc37d8 100644
--- a/srcpkgs/qt5/template
+++ b/srcpkgs/qt5/template
@@ -3,9 +3,9 @@
 # revbump libqtxdg after bumping patch version
 pkgname=qt5
 version=5.15.11+20231124
+revision=2
 # commit 4765fa1df7a837db9c1f89c4da0dd76b74bb5fab
 # base repo: https://invent.kde.org/qt/qt/qt5
-revision=1
 build_style=meta
 hostmakedepends="cmake clang flex perl glib-devel pkg-config
  python3 re2c ruby which"
@@ -246,7 +246,6 @@ do_configure() {
 	# opts+=" -v"
 	opts+=" -skip qtwebengine"
 	opts+=" -skip qtwebview"
-	opts+=" -skip qtdocgallery"
 	opts+=" -skip qtpim"
 	opts+=" -skip qtsystems"
 	opts+=" -skip qtspeech"

From af6a1864b192153550deb5da9212e5aa3deff731 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 059/112] qtav: revbump for ffmpeg4

---
 srcpkgs/qtav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qtav/template b/srcpkgs/qtav/template
index 775d5a139a9ef..2d00ad104355e 100644
--- a/srcpkgs/qtav/template
+++ b/srcpkgs/qtav/template
@@ -4,7 +4,7 @@ version=1.13.0
 revision=2
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel libass-devel libopenal-devel
+makedepends="ffmpeg4-devel libass-devel libopenal-devel
  libva-glx-devel libXv-devel pulseaudio-devel
  qt5-declarative-devel qt5-svg-devel
  qt5-quickcontrols"

From 7e40d58248012f350c74c835b3be0d510f42fd28 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 060/112] retroarch: revbump for ffmpeg6

---
 srcpkgs/retroarch/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroarch/template b/srcpkgs/retroarch/template
index cb3125c5dbf1a..c65c26f7bf033 100644
--- a/srcpkgs/retroarch/template
+++ b/srcpkgs/retroarch/template
@@ -1,7 +1,7 @@
 # Template file for 'retroarch'
 pkgname=retroarch
 version=1.16.0.3
-revision=3
+revision=4
 build_style=configure
 configure_args="--prefix=/usr --sysconfdir=/etc --enable-networking
  --enable-udev --disable-builtinflac --disable-builtinglslang

From b4c5acf194a1a3b2fa93b85cc2e4bf3218110d4b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 061/112] scrcpy: revbump for ffmpeg6

---
 srcpkgs/scrcpy/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/scrcpy/template b/srcpkgs/scrcpy/template
index ac18bc03418ce..f39a7f678ab35 100644
--- a/srcpkgs/scrcpy/template
+++ b/srcpkgs/scrcpy/template
@@ -1,7 +1,7 @@
 # Template file for 'scrcpy'
 pkgname=scrcpy
 version=2.1.1
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcompile_server=false
  -Dprebuilt_server=/usr/share/scrcpy/scrcpy-server-v${version}"

From 2c7e7cfa62d33f63a695f59705d927f952ab922e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 17 Oct 2023 08:54:11 -0400
Subject: [PATCH 062/112] New package: spex-x replaces spek-alternative for
 ffmpeg6

---
 srcpkgs/spek-alternative                      |  1 +
 srcpkgs/{spek-alternative => spek-x}/template | 22 ++++++++++++-------
 2 files changed, 15 insertions(+), 8 deletions(-)
 create mode 120000 srcpkgs/spek-alternative
 rename srcpkgs/{spek-alternative => spek-x}/template (52%)

diff --git a/srcpkgs/spek-alternative b/srcpkgs/spek-alternative
new file mode 120000
index 0000000000000..76648236da701
--- /dev/null
+++ b/srcpkgs/spek-alternative
@@ -0,0 +1 @@
+spek-x
\ No newline at end of file
diff --git a/srcpkgs/spek-alternative/template b/srcpkgs/spek-x/template
similarity index 52%
rename from srcpkgs/spek-alternative/template
rename to srcpkgs/spek-x/template
index d7b55c776b1d4..3ded6c2c323e4 100644
--- a/srcpkgs/spek-alternative/template
+++ b/srcpkgs/spek-x/template
@@ -1,18 +1,18 @@
-# Template file for 'spek-alternative'
-pkgname=spek-alternative
-version=0.8.2.3
-revision=2
+# Template file for 'spek-x'
+pkgname=spek-x
+version=0.9.3
+revision=1
 build_style=gnu-configure
 hostmakedepends="automake gettext-devel intltool libtool pkg-config
  wxWidgets-common wxWidgets-gtk3-devel"
 makedepends="ffmpeg-devel wxWidgets-gtk3-devel"
 depends="ffmpeg"
 short_desc="Acoustic spectrum analyser"
-maintainer="Kartik Singh <kartik.ynwa@gmail.com>"
+maintainer="zlice <zlice555@gmail.com>"
 license="GPL-3.0-or-later"
-homepage="https://github.com/withmorten/spek-alternative"
-distfiles="https://github.com/withmorten/spek-alternative/archive/${version}.tar.gz"
-checksum="007ba4b84a310b078e378aa84c8e80783db5821437a757a488c3ecec377e6b2a"
+homepage="https://github.com/MikeWang000000/spek-x"
+distfiles="https://github.com/MikeWang000000/spek-x/archive/v${version}.tar.gz"
+checksum="7f4b109903333cdd310ab2b9176f0dc49a565891376e281a233d342cedf90ef7"
 
 CXXFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
 
@@ -22,3 +22,9 @@ export WX_CONFIG_NAME="wx-config-gtk3"
 pre_configure() {
 	NOCONFIGURE=1 ./autogen.sh
 }
+
+spek-alternative_package() {
+	depends="spek-x"
+	short_desc+=" - transitional dummy package"
+	build_style=meta
+}

From 27180d94d1ab0e52fe87904669d51e34d9135d5e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 063/112] ssr: revbump for ffmpeg4

---
 srcpkgs/ssr/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ssr/template b/srcpkgs/ssr/template
index 3097754e3cbe5..fa66d5b4736d4 100644
--- a/srcpkgs/ssr/template
+++ b/srcpkgs/ssr/template
@@ -5,7 +5,7 @@ revision=2
 build_style=cmake
 configure_args="-DWITH_QT5=ON"
 hostmakedepends="pkg-config"
-makedepends="alsa-lib-devel ffmpeg-devel glu-devel jack-devel pulseaudio-devel
+makedepends="alsa-lib-devel ffmpeg4-devel glu-devel jack-devel pulseaudio-devel
  qt5-tools-devel qt5-x11extras-devel libXinerama-devel v4l-utils-devel"
 depends="desktop-file-utils hicolor-icon-theme"
 short_desc="Simple Screen Recorder for programs and games"

From 788632d60d8f116cddab11420e0fe933411e5b35 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 064/112] synfig: revbump for ffmpeg6 and mlt7

---
 srcpkgs/synfig/patches/ffmpeg6.patch | 71 ++++++++++++++++++++++++++++
 srcpkgs/synfig/template              |  4 +-
 2 files changed, 73 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/synfig/patches/ffmpeg6.patch

diff --git a/srcpkgs/synfig/patches/ffmpeg6.patch b/srcpkgs/synfig/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..10780b42782f4
--- /dev/null
+++ b/srcpkgs/synfig/patches/ffmpeg6.patch
@@ -0,0 +1,71 @@
+--- a/src/modules/mod_libavcodec/trgt_av.cpp	2022-10-25 09:14:12.000000000 -0400
++++ b/src/modules/mod_libavcodec/trgt_av.cpp	2023-05-05 21:34:17.899194559 -0400
+@@ -38,6 +41,7 @@
+ extern "C"
+ {
+ #ifdef HAVE_LIBAVFORMAT_AVFORMAT_H
++#	include <libavcodec/avcodec.h>
+ #	include <libavformat/avformat.h>
+ #elif defined(HAVE_AVFORMAT_H)
+ #	include <avformat.h>
+@@ -155,11 +156,11 @@
+     }
+ 
+ 	bool open_video_stream() {
+-		if (avcodec_open2(video_context, NULL, NULL) < 0) {
++		if (avcodec_open2(video_context, nullptr, nullptr) < 0) {
+ 			synfig::error("Target_LibAVCodec: could not open video codec");
+ 			// seems the calling of avcodec_free_context after error will cause crash
+ 			// so just forget about this context
+-			video_context = NULL;
++			video_context = nullptr;
+ 			close();
+ 			return false;
+         }
+@@ -234,15 +235,21 @@
+ 		close();
+ 
+ 		if (!av_registered) {
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 			av_register_all();
++#endif
+ 			av_registered = true;
+ 		}
+ 
+ 		// guess format
+-		AVOutputFormat *format = av_guess_format(NULL, filename.c_str(), NULL);
++#if LIBAVCODEC_VERSION_MAJOR < 59 // FFMPEG < 5.0
++		AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#else
++		const AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#endif
+ 		if (!format) {
+ 			synfig::warning("Target_LibAVCodec: unable to guess the output format, defaulting to MPEG");
+-			format = av_guess_format("mpeg", NULL, NULL);
++			format = av_guess_format("mpeg", nullptr, nullptr);
+ 		}
+ 		if (!format) {
+ 			synfig::error("Target_LibAVCodec: unable to find 'mpeg' output format");
+@@ -254,6 +261,7 @@
+ 		context = avformat_alloc_context();
+ 		assert(context);
+ 		context->oformat = format;
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 		if (filename.size() + 1 > sizeof(context->filename)) {
+ 			synfig::error(
+ 				"Target_LibAVCodec: filename too long, max length is %d, filename is '%s'",
+@@ -263,6 +271,14 @@
+ 			return false;
+ 		}
+ 		memcpy(context->filename, filename.c_str(), filename.size() + 1);
++#else
++		context->url = av_strndup(filename.c_str(), filename.size());
++		if (!context->url) {
++			synfig::error("Target_LibAVCodec: cannot allocate space for filename");
++			close();
++			return false;
++		}
++#endif
+ 
+ 		packet = av_packet_alloc();
+ 		assert(packet);
diff --git a/srcpkgs/synfig/template b/srcpkgs/synfig/template
index d4d3e341a20bf..703cfd7ebac84 100644
--- a/srcpkgs/synfig/template
+++ b/srcpkgs/synfig/template
@@ -6,7 +6,7 @@ revision=4
 build_style=gnu-configure
 configure_args="--with-boost-libdir=${XBPS_CROSS_BASE}/usr/lib"
 hostmakedepends="boost-build ImageMagick pkg-config intltool"
-makedepends="ETL gettext-devel libxml++-devel mlt-devel libmagick-devel
+makedepends="ETL gettext-devel libxml++-devel mlt7-devel libmagick-devel
  libmng-devel boost-build boost-devel libopenexr-devel ffmpeg-devel"
 depends="ImageMagick"
 short_desc="CLI 2D vector and timeline-based animation software"
@@ -20,7 +20,7 @@ CXXFLAGS="-std=c++11 -DHAVE_LOCALE_H=1"
 
 synfig-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision}
-	 libopenexr-devel libxml++-devel mlt-devel"
+	 libopenexr-devel libxml++-devel mlt7-devel"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/bin/synfig-config

From 9fca18ae23b27e6e46f11889091a02c63d17cc09 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 065/112] timg: revbump for ffmpeg6

---
 srcpkgs/timg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/timg/template b/srcpkgs/timg/template
index 2a2ab763d2fdd..8fb4327535ef9 100644
--- a/srcpkgs/timg/template
+++ b/srcpkgs/timg/template
@@ -1,7 +1,7 @@
 # Template file for 'timg'
 pkgname=timg
 version=1.4.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_OPENSLIDE_SUPPORT=off -Wno-dev"
 hostmakedepends="pkg-config git"

From cb1273fa0f320bb7f87ec800b01dd8a7bd758619 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 066/112] tvheadend: revbump for ffmpeg4

---
 srcpkgs/tvheadend/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tvheadend/template b/srcpkgs/tvheadend/template
index 9aea7de4ec705..012d31c4879ff 100644
--- a/srcpkgs/tvheadend/template
+++ b/srcpkgs/tvheadend/template
@@ -8,7 +8,7 @@ configure_args="--enable-dvbscan --disable-ffmpeg_static
 --disable-libx265_static --disable-libvpx_static --disable-libtheora_static
 --disable-libvorbis_static --disable-libfdkaac_static"
 hostmakedepends="gettext pkg-config python3 git which"
-makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg-devel"
+makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg4-devel"
 short_desc="TV streaming server"
 maintainer="lemmi <lemmi@nerd2nerd.org>"
 license="GPL-3.0-only"

From 52f1b32a732373918cb8a9933db7e16672915df6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 067/112] unpaper: update to 7.0.0.

---
 srcpkgs/unpaper/template | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/srcpkgs/unpaper/template b/srcpkgs/unpaper/template
index 38ed47a584016..1ff910e722afc 100644
--- a/srcpkgs/unpaper/template
+++ b/srcpkgs/unpaper/template
@@ -1,13 +1,13 @@
 # Template file for 'unpaper'
 pkgname=unpaper
-version=6.1
-revision=3
-build_style=gnu-configure
+version=7.0.0
+revision=1
+build_style=meson
+hostmakedepends="pkg-config meson libxslt"
+makedepends="ffmpeg-devel python3-Sphinx"
+short_desc="Post-processing tool for scanned sheets of paper"
 maintainer="Orphaned <orphan@voidlinux.org>"
-hostmakedepends="pkg-config libxslt"
-makedepends="ffmpeg-devel"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://www.flameeyes.eu/projects/unpaper"
-short_desc="A post-processing tool for scanned sheets of paper"
 distfiles="https://www.flameeyes.eu/files/${pkgname}-${version}.tar.xz"
-checksum=237c84f5da544b3f7709827f9f12c37c346cdf029b1128fb4633f9bafa5cb930
+checksum=2575fbbf26c22719d1cb882b59602c9900c7f747118ac130883f63419be46a80

From 2cecd4b7c7d15399c2deee1d63e5e990e2fee099 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 068/112] vice: revbump for ffmpeg4

---
 srcpkgs/vice/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vice/template b/srcpkgs/vice/template
index b1f866d35095e..4beab2c5f9ebd 100644
--- a/srcpkgs/vice/template
+++ b/srcpkgs/vice/template
@@ -26,7 +26,7 @@ makedepends="
 	$(vopt_if gtk3 gtk+3-devel)
 	$(vopt_if gtk3 pulseaudio-devel)
 	$(vopt_if gtk3 pango-devel)
-	$(vopt_if ffmpeg ffmpeg-devel)"
+	$(vopt_if ffmpeg ffmpeg4-devel)"
 short_desc="Emulator for C64, C128, CBM-II, PET, VIC20, Plus4 and C16"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"

From a62714b17f317803b01ab970e879949d0a078a64 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 069/112] waypipe: revbump for ffmpeg6

---
 srcpkgs/waypipe/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waypipe/template b/srcpkgs/waypipe/template
index 6da88b21bf2a1..4da8058400b58 100644
--- a/srcpkgs/waypipe/template
+++ b/srcpkgs/waypipe/template
@@ -1,7 +1,7 @@
 # Template file for 'waypipe'
 pkgname=waypipe
 version=0.8.6
-revision=1
+revision=2
 build_style=meson
 # lto is off because it causes linking errors in armv6l and armv7l (due to NEON)
 configure_args="-Dwerror=false -Dwith_dmabuf=enabled -Dwith_lz4=enabled

From b963ccd093b78bdc055bc973c12e681ce674bb3e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 070/112] xpra: revbump for ffmpeg6

---
 srcpkgs/xpra/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xpra/template b/srcpkgs/xpra/template
index 6bfe9be2db650..1eea2962bcb82 100644
--- a/srcpkgs/xpra/template
+++ b/srcpkgs/xpra/template
@@ -1,7 +1,7 @@
 # Template file for 'xpra'
 pkgname=xpra
 version=5.0.4
-revision=1
+revision=2
 build_style=python3-module
 make_build_args="--without-cuda_kernels --without-cuda_rebuild"
 make_install_args="$(vopt_with docs) ${make_build_args}"

From fc37b056afe673c041c9d173a4c122adf18c9639 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:07:40 -0400
Subject: [PATCH 071/112] nv-codec-headers: update to 12.0.16.0

---
 srcpkgs/nv-codec-headers/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/nv-codec-headers/template b/srcpkgs/nv-codec-headers/template
index 3d422a61e4891..251e057f826fb 100644
--- a/srcpkgs/nv-codec-headers/template
+++ b/srcpkgs/nv-codec-headers/template
@@ -1,6 +1,6 @@
 # Template file for 'nv-codec-headers'
 pkgname=nv-codec-headers
-version=11.1.5.1
+version=12.0.16.0
 revision=1
 build_style=gnu-makefile
 short_desc="FFmpeg version of headers required to interface with Nvidias codec APIs"
@@ -8,7 +8,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="MIT"
 homepage="http://git.videolan.org/?p=ffmpeg/nv-codec-headers.git"
 distfiles="https://github.com/FFmpeg/nv-codec-headers/archive/n${version}.tar.gz"
-checksum=d095fbd56aa93772471a323be0ebe65504a0f43f06c76a30b6d25da77b06ae9c
+checksum=2a1533b65f55f9da52956faf0627ed3b74868ac0c7f269990edd21369113b48f
 
 post_install() {
 	sed -n '4,25p' include/ffnvcodec/nvEncodeAPI.h > LICENSE

From 0fd64b3f9267f8d1315b88118eb9673cfb912e91 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:08:40 -0400
Subject: [PATCH 072/112] openimagedenoise: revbump for ffmpeg6

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index b792813dba7c2..109deb171c3f7 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,7 +1,7 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
 version=1.4.3
-revision=1
+revision=2
 archs="x86_64*"
 build_style=cmake
 hostmakedepends="ispc python3"

From ea4ead83e3172e88239a32d4f3ba0630fea1aaf0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:31:45 -0400
Subject: [PATCH 073/112] shotcut: revbump for ffmpeg6

---
 srcpkgs/shotcut/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/shotcut/template b/srcpkgs/shotcut/template
index 33141fbd862d7..f46cb53b6bfb9 100644
--- a/srcpkgs/shotcut/template
+++ b/srcpkgs/shotcut/template
@@ -1,7 +1,7 @@
 # Template file for 'shotcut'
 pkgname=shotcut
 version=23.09.29
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSHOTCUT_VERSION=${version}"
 hostmakedepends="pkg-config qt6-tools-devel"

From bdd1703886bdef8ac0ad4cfc2e022385fd2f279e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:30 -0400
Subject: [PATCH 074/112] shiboken2: revbump for qt5-5.15.11

---
 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch | 1 +
 srcpkgs/shiboken2/template                                 | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
 create mode 120000 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
new file mode 120000
index 0000000000000..efcf3249bd885
--- /dev/null
+++ b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1 @@
+../../python3-pyside2/patches/importlib-machinery-bypass.patch
\ No newline at end of file
diff --git a/srcpkgs/shiboken2/template b/srcpkgs/shiboken2/template
index 883d6a084d868..f3c06ec245a1f 100644
--- a/srcpkgs/shiboken2/template
+++ b/srcpkgs/shiboken2/template
@@ -1,7 +1,7 @@
 # Template file for 'shiboken2'
 pkgname=shiboken2
 version=5.15.10
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/shiboken2"
 build_style=cmake

From d6ef4f4cab2a497d09211187c94771dc1d957f25 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:53 -0400
Subject: [PATCH 075/112] python3-pyside2: revbump for qt5-5.15.11

---
 .../patches/importlib-machinery-bypass.patch      | 15 +++++++++++++++
 srcpkgs/python3-pyside2/template                  |  2 +-
 2 files changed, 16 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
new file mode 100644
index 0000000000000..64c429584776b
--- /dev/null
+++ b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1,15 @@
+Using this prevents an error around line 220 below it.
+"AttributeError: module 'importlib' has no attribute 'machinery'"
+The old backup logic is in place and compiles without issues.
+--- a/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:09:34.688912402 -0400
++++ b/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:10:03.395529582 -0400
+@@ -170,9 +170,6 @@
+
+     # 'zipstring_sequence' comes from signature.cpp
+     zipbytes = base64.b64decode(''.join(zipstring_sequence))
+-    if sys.version_info[0] >= 3:
+-        vzip = zipfile.ZipFile(io.BytesIO(zipbytes))
+-        return sys.meta_path, EmbeddableZipImporter(vzip)
+
+     # Old version for Python 2.7, only.
+     import os
diff --git a/srcpkgs/python3-pyside2/template b/srcpkgs/python3-pyside2/template
index 249efa9098842..52626436ce75f 100644
--- a/srcpkgs/python3-pyside2/template
+++ b/srcpkgs/python3-pyside2/template
@@ -1,7 +1,7 @@
 # Template file for 'python3-pyside2'
 pkgname=python3-pyside2
 version=5.15.10
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/pyside2"
 build_style=cmake

From b5e87c969e0f94d7e9fbcd49ba8ac5ee093fe860 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:35 -0400
Subject: [PATCH 076/112] konqueror: revbump for ffmpeg6

---
 srcpkgs/konqueror/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/konqueror/template b/srcpkgs/konqueror/template
index 044dafa605ba6..63dd01fafc780 100644
--- a/srcpkgs/konqueror/template
+++ b/srcpkgs/konqueror/template
@@ -1,11 +1,11 @@
 # Template file for 'konqueror'
 pkgname=konqueror
 version=23.08.4
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DDESKTOPTOJSON_EXECUTABLE=/usr/bin/desktoptojson"
 hostmakedepends="extra-cmake-modules python3 qt5-host-tools qt5-qmake kdoctools
-kcoreaddons kconfig gettext"
+ kcoreaddons kconfig gettext"
 makedepends="qt5-devel qt5-webengine-devel qt5-declarative-devel
  qt5-webchannel-devel qt5-location-devel kcmutils-devel kdelibs4support-devel
  karchive-devel khtml-devel kdesu-devel kactivities5-devel"

From 5a22d046d8e5937f166f8f2f25b6a6af15ba4b41 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:58 -0400
Subject: [PATCH 077/112] qt5-speech: revbump for qt5-5.15.11

---
 srcpkgs/qt5-speech/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-speech/template b/srcpkgs/qt5-speech/template
index 1228bb60c41db..27a7da1dbdb91 100644
--- a/srcpkgs/qt5-speech/template
+++ b/srcpkgs/qt5-speech/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-speech'
 pkgname=qt5-speech
 version=5.15.11
-revision=1
+revision=2
 _commit=d32f4a479d38a11f547598004b975f4356424a16
 build_style=qmake
 configure_args="-- -flite -flite-alsa -speechd"

From 46e116da72de31beb813741c6f9ae836d17ed551 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Jun 2023 08:20:22 -0400
Subject: [PATCH 078/112] gtk4: revbump for ffmpeg6

---
 srcpkgs/gtk4/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gtk4/template b/srcpkgs/gtk4/template
index d8ee60abe06f7..55bff6e33849a 100644
--- a/srcpkgs/gtk4/template
+++ b/srcpkgs/gtk4/template
@@ -1,7 +1,7 @@
 # Template file for 'gtk4'
 pkgname=gtk4
 version=4.12.3
-revision=1
+revision=2
 build_style=meson
 build_helper="gir"
 configure_args="-Dman-pages=true -Ddocumentation=true -Dbuild-tests=false

From 9ffa3bef63e737c936a98b5e9f1cf3d0ca509e8f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:28:26 -0400
Subject: [PATCH 079/112] siril: revbump for ffmpeg6

---
 srcpkgs/siril/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/siril/template b/srcpkgs/siril/template
index 84332f79d060d..62750dd247548 100644
--- a/srcpkgs/siril/template
+++ b/srcpkgs/siril/template
@@ -1,7 +1,7 @@
 # Template file for 'siril'
 pkgname=siril
 version=0.9.12
-revision=10
+revision=11
 build_style=gnu-configure
 hostmakedepends="pkg-config intltool autoconf automake gettext-devel"
 makedepends="fftw-devel libconfig-devel libopencv-devel libffms2-devel

From f516742c0ac38967f835f47bebe68c1ec2c6bb02 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 22 Jun 2023 10:25:02 -0400
Subject: [PATCH 080/112] kdenlive: revbump for ffmpeg6

---
 srcpkgs/kdenlive/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kdenlive/template b/srcpkgs/kdenlive/template
index a0f3615c9c530..d63166f95c4d7 100644
--- a/srcpkgs/kdenlive/template
+++ b/srcpkgs/kdenlive/template
@@ -1,7 +1,7 @@
 # Template file for 'kdenlive'
 pkgname=kdenlive
 version=23.08.4
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="
  extra-cmake-modules kconfig kcoreaddons kdoctools pkg-config python3

From f2dd47ff5d0d41593cc4e478a0c5d0f878e21743 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:20:59 -0400
Subject: [PATCH 081/112] tracker-miners: revbump for ffmpeg6

---
 srcpkgs/tracker-miners/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tracker-miners/template b/srcpkgs/tracker-miners/template
index 0b97f47489f81..f196d2bf9e4a4 100644
--- a/srcpkgs/tracker-miners/template
+++ b/srcpkgs/tracker-miners/template
@@ -1,7 +1,7 @@
 # Template file for 'tracker-miners'
 pkgname=tracker-miners
 version=3.6.1
-revision=1
+revision=2
 build_style=meson
 build_helper=qemu
 # missing libgrss for miner_rss

From ce1a2267c1bada8dc21984afed6a0c705bd74a5b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:21:21 -0400
Subject: [PATCH 082/112] mpd: revbump for ffmpeg6

---
 srcpkgs/mpd/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpd/template b/srcpkgs/mpd/template
index 4fd32b7be8c53..b8e2bd4c1b59c 100644
--- a/srcpkgs/mpd/template
+++ b/srcpkgs/mpd/template
@@ -1,7 +1,7 @@
 # Template file for 'mpd'
 pkgname=mpd
 version=0.23.15
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dopus=enabled -Dmikmod=enabled -Dneighbor=true
  -Dsoundcloud=enabled -Dpipe=true -Dtwolame=enabled -Dbzip2=enabled

From 1246ed5db7c3b67eaaeda3ffe73a38ef9f16ecf6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:02 -0400
Subject: [PATCH 083/112] tg_owt: revbump for ffmpeg6

---
 srcpkgs/tg_owt/template | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/srcpkgs/tg_owt/template b/srcpkgs/tg_owt/template
index aee8d35d08ffb..563ed9a5835c4 100644
--- a/srcpkgs/tg_owt/template
+++ b/srcpkgs/tg_owt/template
@@ -1,8 +1,7 @@
 # Template file for 'tg_owt'
 pkgname=tg_owt
 version=0.0.0.20231221
-revision=1
-_commit=afd9d5d31798d3eacf9ed6c30601e91d0f1e4d60
+revision=2
 _libyuv_commit=04821d1e7d60845525e8db55c7bcd41ef5be9406
 _abseil_commit=8c0b94e793a66495e0b1f34a5eb26bd7dc672db0
 _crc32c_commit=21fc8ef30415a635e7351ffa0e5d5367943d4a94

From 5b9ac602da75e5c59918783b71280006c24b84c2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:44 -0400
Subject: [PATCH 084/112] telegram-desktop: revbump for ffmpeg6

---
 srcpkgs/telegram-desktop/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/telegram-desktop/template b/srcpkgs/telegram-desktop/template
index 48ccb9a9d840a..c8756611e2b3b 100644
--- a/srcpkgs/telegram-desktop/template
+++ b/srcpkgs/telegram-desktop/template
@@ -1,7 +1,7 @@
 # Template file for 'telegram-desktop'
 pkgname=telegram-desktop
 version=4.14.2
-revision=1
+revision=2
 build_style=cmake
 build_helper="qemu gir"
 configure_args="-DTDESKTOP_API_ID=209235

From df342a27e213ec9226a321169f6c563fb3072141 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:11:45 -0400
Subject: [PATCH 085/112] gst-plugins-bad1: revbump for ffmpeg6

---
 srcpkgs/gst-plugins-bad1/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index fcd3538cd5cde..976e2889b588e 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-plugins-bad1'
 pkgname=gst-plugins-bad1
 version=1.22.7
-revision=1
+revision=2
 build_helper="gir"
 build_style=meson
 configure_args="-Dpackage-origin=https://voidlinux.org -Ddoc=disabled

From 1a87d1a89b1aeac3681b0a8130dbf9df3d477ece Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:12:09 -0400
Subject: [PATCH 086/112] openmw: revbump for ffmpeg6

---
 srcpkgs/openmw/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openmw/template b/srcpkgs/openmw/template
index 0abf5ff7cdbec..b57180f1a4446 100644
--- a/srcpkgs/openmw/template
+++ b/srcpkgs/openmw/template
@@ -1,7 +1,7 @@
 # Template file for 'openmw'
 pkgname=openmw
 version=0.48.0
-revision=2
+revision=3
 build_style=cmake
 _recast_commit=e75adf86f91eb3082220085e42dda62679f9a3ea
 _bullet_tag=3.17

From 254d03a912a6db8d80514143f475ce77f73d2ad3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:14:53 -0400
Subject: [PATCH 087/112] lms: revbump for ffmpeg6

---
 srcpkgs/lms/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/lms/template b/srcpkgs/lms/template
index e358f75902a98..3b21c458de519 100644
--- a/srcpkgs/lms/template
+++ b/srcpkgs/lms/template
@@ -1,7 +1,7 @@
 # Template file for 'lms'
 pkgname=lms
 version=3.42.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="wt-devel ffmpeg-devel boost-devel libconfig++-devel taglib-devel pam-devel libgraphicsmagick-devel gtest-devel libarchive-devel"

From 57dc318d48db11da65cd101ded85f8993d8f2d6f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:18:18 -0400
Subject: [PATCH 088/112] freecad: DELETE

---
 srcpkgs/freecad/patches/001-include.patch     | 112 ------------------
 .../154-revert-gui-tmp-redirect-stderr.patch  |  68 -----------
 ...d63c8c9b1280978be841d04e68a0a55cceb9.patch |  30 -----
 srcpkgs/freecad/template                      |  12 +-
 4 files changed, 7 insertions(+), 215 deletions(-)
 delete mode 100644 srcpkgs/freecad/patches/001-include.patch
 delete mode 100644 srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
 delete mode 100644 srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch

diff --git a/srcpkgs/freecad/patches/001-include.patch b/srcpkgs/freecad/patches/001-include.patch
deleted file mode 100644
index 28b5af54999b9..0000000000000
--- a/srcpkgs/freecad/patches/001-include.patch
+++ /dev/null
@@ -1,112 +0,0 @@
-From 9a41845a417189776741297c50a3827ce292bc4f Mon Sep 17 00:00:00 2001
-From: Uwe <donovaly@users.noreply.github.com>
-Date: Sun, 3 Jul 2022 22:51:16 +0200
-Subject: [PATCH] [Part] OCCError.h: remove unneeded includes
-
-- also sort includes
----
- src/Mod/Part/App/OCCError.h             | 36 +++----------------------
- src/Mod/Part/App/OffsetCurvePyImp.cpp   | 12 ++++-----
- src/Mod/Part/App/OffsetSurfacePyImp.cpp | 10 +++----
- 3 files changed, 12 insertions(+), 46 deletions(-)
-
---- a/src/Mod/Part/App/OCCError.h
-+++ b/src/Mod/Part/App/OCCError.h
-@@ -23,36 +23,8 @@
- #ifndef _OCCError_h_
- #define _OCCError_h_
- 
--# include <Standard_Version.hxx>
- # include <Standard_Failure.hxx>
--# include <Standard_AbortiveTransaction.hxx>
--# include <Standard_ConstructionError.hxx>
--# if OCC_VERSION_HEX >= 0x060500
--# include <Standard_DefineException.hxx>
--# endif
--# include <Standard_DimensionError.hxx>
--# include <Standard_DimensionMismatch.hxx>
--# include <Standard_DivideByZero.hxx>
--# include <Standard_DomainError.hxx>
--# include <Standard_ImmutableObject.hxx>
--# include <Standard_LicenseError.hxx>
--# include <Standard_LicenseNotFound.hxx>
--# include <Standard_MultiplyDefined.hxx>
--# include <Standard_NegativeValue.hxx>
--# include <Standard_NoMoreObject.hxx>
--# include <Standard_NoSuchObject.hxx>
--# include <Standard_NotImplemented.hxx>
--# include <Standard_NullObject.hxx>
--# include <Standard_NullValue.hxx>
--# include <Standard_NumericError.hxx>
--# include <Standard_OutOfMemory.hxx>
--# include <Standard_OutOfRange.hxx>
--# include <Standard_Overflow.hxx>
--# include <Standard_ProgramError.hxx>
--# include <Standard_RangeError.hxx>
--# include <Standard_TooManyUsers.hxx>
--# include <Standard_TypeMismatch.hxx>
--# include <Standard_Underflow.hxx>
-+# include <Standard_Version.hxx>
- 
- #include <Mod/Part/PartGlobal.h>
- #include <Base/Console.h>
-@@ -88,4 +60,3 @@ PartExport extern PyObject* PartExceptio
- 
- #define PY_CATCH_OCC _PY_CATCH_OCC(return(NULL))
- #endif  // _OCCError_h_
--
---- a/src/Mod/Part/App/OffsetCurvePyImp.cpp
-+++ b/src/Mod/Part/App/OffsetCurvePyImp.cpp
-@@ -20,20 +20,20 @@
-  *                                                                         *
-  ***************************************************************************/
- 
--
- #include "PreCompiled.h"
- #ifndef _PreComp_
- # include <Geom_OffsetCurve.hxx>
- #endif
- 
--#include "OCCError.h"
--#include "Geometry.h"
-+#include <Base/GeometryPyCXX.h>
-+#include <Base/Vector3D.h>
-+#include <Base/VectorPy.h>
-+
- #include "OffsetCurvePy.h"
- #include "OffsetCurvePy.cpp"
-+#include "Geometry.h"
-+#include "OCCError.h"
- 
--#include <Base/GeometryPyCXX.h>
--#include <Base/VectorPy.h>
--#include <Base/Vector3D.h>
- 
- using namespace Part;
- 
---- a/src/Mod/Part/App/OffsetSurfacePyImp.cpp
-+++ b/src/Mod/Part/App/OffsetSurfacePyImp.cpp
-@@ -20,20 +20,16 @@
-  *                                                                         *
-  ***************************************************************************/
- 
--
- #include "PreCompiled.h"
- #ifndef _PreComp_
- # include <Geom_OffsetSurface.hxx>
- # include <memory>
- #endif
- 
--#include <Base/VectorPy.h>
--#include <Base/Vector3D.h>
--
- #include "OCCError.h"
--#include "Geometry.h"
--#include <Mod/Part/App/OffsetSurfacePy.h>
--#include <Mod/Part/App/OffsetSurfacePy.cpp>
-+#include "OffsetSurfacePy.h"
-+#include "OffsetSurfacePy.cpp"
-+
- 
- using namespace Part;
- 
diff --git a/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch b/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
deleted file mode 100644
index d6a9adabdec83..0000000000000
--- a/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
+++ /dev/null
@@ -1,68 +0,0 @@
-see https://github.com/FreeCAD/FreeCAD/commit/cfe94b00d3434f3e2c8b5114d2909f628c330fa8#commitcomment-71413407
-
-upstream: yes
-
-From 7b377a216b9185960e4cee980a6504dc1a755f50 Mon Sep 17 00:00:00 2001
-From: wmayer <wmayer@users.sourceforge.net>
-Date: Wed, 29 Jun 2022 15:19:18 +0200
-Subject: [PATCH] Gui: remove workaround for spnav 0.23 due to build failure
- with musl libc
-
----
- src/Gui/3Dconnexion/GuiNativeEventLinux.cpp | 27 ---------------------
- 1 file changed, 27 deletions(-)
-
---- a/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp
-+++ b/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp
-@@ -21,42 +21,17 @@
-  ***************************************************************************/
- 
- #include <FCConfig.h>
--#include <cstdio>
- 
- #include "GuiNativeEventLinux.h"
- 
- #include "GuiApplicationNativeEventAware.h"
- #include <Base/Console.h>
--#include <Base/FileInfo.h>
- #include <QMainWindow>
- 
- #include <QSocketNotifier>
- 
- #include <spnav.h>
- 
--namespace {
--class RedirectStdErr
--{
--public:
--    RedirectStdErr()
--        : fi(Base::FileInfo::getTempFileName())
--        , file(stderr)
--    {
--        stderr = fopen(fi.filePath().c_str(), "w");
--    }
--    ~RedirectStdErr()
--    {
--        fclose(stderr);
--        fi.deleteFile();
--        stderr = file;
--    }
--
--private:
--    Base::FileInfo fi;
--    FILE* file;
--};
--}
--
- Gui::GuiNativeEvent::GuiNativeEvent(Gui::GUIApplicationNativeEventAware *app)
- : GuiAbstractNativeEvent(app)
- {
-@@ -72,8 +47,6 @@ Gui::GuiNativeEvent::~GuiNativeEvent()
- 
- void Gui::GuiNativeEvent::initSpaceball(QMainWindow *window)
- {
--    // tmp. redirect stderr to a file to suppress an error message from spnav_open()
--    RedirectStdErr err;
-     Q_UNUSED(window)
-     if (spnav_open() == -1) {
-         Base::Console().Log("Couldn't connect to spacenav daemon. Please ignore if you don't have a spacemouse.\n");
diff --git a/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch b/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch
deleted file mode 100644
index d4acf370ca0a4..0000000000000
--- a/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-From fe02d63c8c9b1280978be841d04e68a0a55cceb9 Mon Sep 17 00:00:00 2001
-From: Roy-043 <70520633+Roy-043@users.noreply.github.com>
-Date: Thu, 29 Dec 2022 23:20:38 +0100
-Subject: [PATCH] Draft: update inspect.getargspec to inspect.getfullargspec
- (#8101)
-
----
- src/Mod/Draft/draftguitools/gui_snapper.py | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
---- a/src/Mod/Draft/draftguitools/gui_snapper.py
-+++ b/src/Mod/Draft/draftguitools/gui_snapper.py
-@@ -1426,7 +1426,7 @@ class Snapper:
-             Gui.Snapper.off()
-             self.ui.offUi()
-             if callback:
--                if len(inspect.getargspec(callback).args) > 1:
-+                if len(inspect.getfullargspec(callback).args) > 1:
-                     obj = None
-                     if self.snapInfo and ("Object" in self.snapInfo) and self.snapInfo["Object"]:
-                         obj = App.ActiveDocument.getObject(self.snapInfo["Object"])
-@@ -1445,7 +1445,7 @@ class Snapper:
-             Gui.Snapper.off()
-             self.ui.offUi()
-             if callback:
--                if len(inspect.getargspec(callback).args) > 1:
-+                if len(inspect.getfullargspec(callback).args) > 1:
-                     callback(None, None)
-                 else:
-                     callback(None)
diff --git a/srcpkgs/freecad/template b/srcpkgs/freecad/template
index c135701e38b9a..7d5165f760bab 100644
--- a/srcpkgs/freecad/template
+++ b/srcpkgs/freecad/template
@@ -1,7 +1,7 @@
 # Template file for 'freecad'
 pkgname=freecad
-version=0.20.2
-revision=7
+version=0.21.1
+revision=2
 build_wrksrc="FreeCAD-${version}"
 build_style=cmake
 pycompile_dirs="usr/lib/${pkgname}/Mod"
@@ -24,8 +24,10 @@ makedepends="python3-devel boost-devel libxerces-c-devel zlib-devel occt-devel
  coin3-devel libshiboken2-devel libspnav-devel pyside2-tools
  liblz4-devel libpyside2-python3-devel python3-matplotlib netcdf-devel
  jsoncpp-devel qt5-devel qt5-svg-devel qt5-tools-devel qt5-webkit-devel
- qt5-xmlpatterns-devel coin3-doc glew-devel python3-pivy"
-depends="python3-matplotlib python3-pyside2-webengine python3-pivy"
+ qt5-xmlpatterns-devel coin3-doc glew-devel python3-pivy qt5-webengine-devel
+ qt5-declarative-devel qt5-webchannel-devel qt5-location-devel"
+depends="python3-matplotlib python3-pyside2-webengine python3-pivy
+ python3-GitPython python3-Markdown"
 short_desc="General purpose 3D CAD modeler"
 maintainer="yopito <pierre.bourgin@free.fr>"
 license="LGPL-2.0-or-later"
@@ -35,7 +37,7 @@ distfiles="
  https://github.com/FreeCAD/FreeCAD/archive/${version}.tar.gz
  ${SOURCEFORGE_SITE}/cxx/pycxx-${_pycxxver}.tar.gz
 "
-checksum="46922f3a477e742e1a89cd5346692d63aebb2b67af887b3e463e094a4ae055da
+checksum="e9b1fd0323f101268c7f3be52db42e4a29222f2e306ae6c4a6fc309cb418d35a
  4b91e1e1141c23fbd5039df635c4bb6e75632168548f56b83ce177193c0c98c6"
 python_version=3
 patch_args="-Np1 -d ${build_wrksrc}"

From e75fe5718a57d8d826484bcec08a5a56924f517b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:47:18 -0400
Subject: [PATCH 089/112] libopenshot: revbump for ffmpeg6

---
 srcpkgs/libopenshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenshot/template b/srcpkgs/libopenshot/template
index 8e57c5f592169..7a8f4520e7892 100644
--- a/srcpkgs/libopenshot/template
+++ b/srcpkgs/libopenshot/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenshot'
 pkgname=libopenshot
 version=0.3.0
-revision=3
+revision=4
 build_style=cmake
 # Builds fail with Ruby-2.4.1
 configure_args="-DENABLE_RUBY=OFF -DUSE_SYSTEM_JSONCPP=ON"

From 9aad0799beb72308ad1cd40479f82a80e12e1326 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:10:30 -0500
Subject: [PATCH 090/112] openimageio: revbump for ffmpeg6

---
 srcpkgs/openimageio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimageio/template b/srcpkgs/openimageio/template
index 3ce3f9e49d350..27d2131bc0a61 100644
--- a/srcpkgs/openimageio/template
+++ b/srcpkgs/openimageio/template
@@ -1,7 +1,7 @@
 # Template file for 'openimageio'
 pkgname=openimageio
 version=2.4.9.0
-revision=7
+revision=8
 build_style=cmake
 build_helper=qemu
 configure_args="-DUSE_QT=0 -DUSE_PYTHON=0 -DOIIO_BUILD_TESTS=0

From a9a89c5ba8bed0dd67e208c8cad466c7e529000d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:11:57 -0500
Subject: [PATCH 091/112] synfigstudio: revbump for ffmpeg6

---
 srcpkgs/synfigstudio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/synfigstudio/template b/srcpkgs/synfigstudio/template
index 09e442da9a680..2bc017cedca6b 100644
--- a/srcpkgs/synfigstudio/template
+++ b/srcpkgs/synfigstudio/template
@@ -2,7 +2,7 @@
 # Should be kept in sync with 'synfig' and 'ETL'
 pkgname=synfigstudio
 version=1.4.4
-revision=4
+revision=5
 build_style=gnu-configure
 configure_args="--disable-update-mimedb"
 hostmakedepends="pkg-config intltool gettext synfig"

From 94e3a793c196c6263e9d9a8705c08d7dae188252 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:12:32 -0500
Subject: [PATCH 092/112] gmic: revbump for ffmpeg6

---
 srcpkgs/gmic/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gmic/template b/srcpkgs/gmic/template
index fa37651bb6dee..24d10147e3aba 100644
--- a/srcpkgs/gmic/template
+++ b/srcpkgs/gmic/template
@@ -1,7 +1,7 @@
 # Template file for 'gmic'
 pkgname=gmic
 version=3.1.6
-revision=5
+revision=6
 _zart_hash=34ebf6cce0bafb98abe57cec83c4a02cd1abeca0
 create_wrksrc=yes
 build_wrksrc="src"

From 32285d0beebe2c7142ae88965533d7fca07b844d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:10 -0500
Subject: [PATCH 093/112] mixxx: revbump for ffmpeg6

---
 srcpkgs/mixxx/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mixxx/template b/srcpkgs/mixxx/template
index 6921996e4e77b..6a79b328c1abf 100644
--- a/srcpkgs/mixxx/template
+++ b/srcpkgs/mixxx/template
@@ -1,7 +1,7 @@
 # Template file for 'mixxx'
 pkgname=mixxx
 version=2.3.3
-revision=6
+revision=7
 build_style=cmake
 configure_args="-DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="extra-cmake-modules pkg-config protobuf qt5-host-tools qt5-qmake"

From aff928d456056894278a39737e79732d8a0fb869 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:28 -0500
Subject: [PATCH 094/112] musikcube: revbump for ffmpeg6

---
 srcpkgs/musikcube/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/musikcube/template b/srcpkgs/musikcube/template
index d9e6186e6697b..637952d50aca3 100644
--- a/srcpkgs/musikcube/template
+++ b/srcpkgs/musikcube/template
@@ -1,7 +1,7 @@
 # Template file for 'musikcube'
 pkgname=musikcube
 version=3.0.0
-revision=3
+revision=4
 build_style=cmake
 make_cmd=make
 configure_args="-DNO_NCURSESW=1"

From daf4ba75987a667f72c9e91f77f1d1d0fbf1f6df Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:45 -0500
Subject: [PATCH 095/112] electron24: revbump for ffmpeg6

---
 srcpkgs/electron24/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron24/template b/srcpkgs/electron24/template
index a9c865c19c989..b8613e4362bc7 100644
--- a/srcpkgs/electron24/template
+++ b/srcpkgs/electron24/template
@@ -1,7 +1,7 @@
 # Template file for 'electron24'
 pkgname=electron24
 version=24.3.0
-revision=2
+revision=3
 _nodever=18.14.0
 _chromiumver=112.0.5615.165
 archs="x86_64* aarch64*"

From cbe835e59a40acaab41a259b6f70714dd23a6d76 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:00 -0500
Subject: [PATCH 096/112] electron19: revbump for ffmpeg6

---
 srcpkgs/electron19/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron19/template b/srcpkgs/electron19/template
index b18bc792c8221..29fb34e254eea 100644
--- a/srcpkgs/electron19/template
+++ b/srcpkgs/electron19/template
@@ -1,7 +1,7 @@
 # Template file for 'electron19'
 pkgname=electron19
 version=19.0.8
-revision=4
+revision=5
 _nodever=16.14.2
 _chromiumver=102.0.5005.125
 archs="x86_64* aarch64* ppc64le*"

From 39bebc66f329053f10c1eeaebf8dbf5e56a7b991 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:13 -0500
Subject: [PATCH 097/112] wf-recorder: revbump for ffmpeg6

---
 srcpkgs/wf-recorder/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/wf-recorder/template b/srcpkgs/wf-recorder/template
index 08f986b031006..63c45cf4b814d 100644
--- a/srcpkgs/wf-recorder/template
+++ b/srcpkgs/wf-recorder/template
@@ -1,7 +1,7 @@
 # Template file for 'wf-recorder'
 pkgname=wf-recorder
 version=0.4.1
-revision=2
+revision=3
 build_style=meson
 hostmakedepends="pkg-config scdoc wayland-devel"
 makedepends="wayland-protocols wayland-devel ffmpeg-devel libgbm-devel x264-devel

From c7fc74f32abdf8303f1a7b682f44c2627f76ecff Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:26 -0500
Subject: [PATCH 098/112] obs: revbump for ffmpeg6

---
 srcpkgs/obs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/obs/template b/srcpkgs/obs/template
index b343f1131bfcf..a25a67433e285 100644
--- a/srcpkgs/obs/template
+++ b/srcpkgs/obs/template
@@ -1,7 +1,7 @@
 # Template file for 'obs'
 pkgname=obs
 version=30.0.0
-revision=2
+revision=3
 archs="i686* x86_64* ppc64le* aarch64* riscv64*"
 build_style=cmake
 configure_args="-DOBS_VERSION_OVERRIDE=${version} -DENABLE_JACK=ON

From 94e820c26a9c26f7629c897baf032aa454d5ab40 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:36 -0500
Subject: [PATCH 099/112] mlt7: revbump for ffmpeg6

---
 srcpkgs/mlt7/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mlt7/template b/srcpkgs/mlt7/template
index 98f302ad3a516..7eb8c00fa1580 100644
--- a/srcpkgs/mlt7/template
+++ b/srcpkgs/mlt7/template
@@ -1,7 +1,7 @@
 # Template file for 'mlt7'
 pkgname=mlt7
 version=7.20.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DSWIG_PYTHON=ON -DMOD_QT6=ON"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which

From 3869ca0778671e1a482a0a7883511b84bd261f8b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:48 -0500
Subject: [PATCH 100/112] qt6-multimedia: revbump for ffmpeg6

---
 srcpkgs/qt6-multimedia/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-multimedia/template b/srcpkgs/qt6-multimedia/template
index 67a577e1300fe..1da626ecf515a 100644
--- a/srcpkgs/qt6-multimedia/template
+++ b/srcpkgs/qt6-multimedia/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-multimedia'
 pkgname=qt6-multimedia
 version=6.6.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DQT_FEATURE_gstreamer=ON"
 hostmakedepends="perl qt6-declarative-host-tools pkg-config qt6-shadertools"

From 5b2f3ba122cdae7ae54c6501510452f407816726 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:00:15 -0500
Subject: [PATCH 101/112] baresip: revbump for ffmpeg6

---
 srcpkgs/baresip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/baresip/template b/srcpkgs/baresip/template
index 12c8954ef7b9b..b16b67beab8d2 100644
--- a/srcpkgs/baresip/template
+++ b/srcpkgs/baresip/template
@@ -1,7 +1,7 @@
 # Template file for 'baresip'
 pkgname=baresip
 version=3.6.0
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config glib-devel"
 makedepends="libgsm-devel libpng-devel openssl-devel libsndfile-devel

From 65d00520661064b050d00cb22be008264cf348b2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:30 -0500
Subject: [PATCH 102/112] QMPlay2: revbump for ffmpeg6

---
 srcpkgs/QMPlay2/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/QMPlay2/template b/srcpkgs/QMPlay2/template
index 46c80f64a1349..942258ce60fb7 100644
--- a/srcpkgs/QMPlay2/template
+++ b/srcpkgs/QMPlay2/template
@@ -1,7 +1,7 @@
 # Template file for 'QMPlay2'
 pkgname=QMPlay2
 version=23.10.22
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools"
 makedepends="alsa-lib-devel ffmpeg-devel libass-devel libcdio-devel libgme-devel

From 8d0fa50b878e2d620cb27fe9a7a43486189e600c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:34 -0500
Subject: [PATCH 103/112] alsa-plugins: revbump for ffmpeg6

---
 srcpkgs/alsa-plugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/alsa-plugins/template b/srcpkgs/alsa-plugins/template
index a5708a7d82a8f..7bfdad046c483 100644
--- a/srcpkgs/alsa-plugins/template
+++ b/srcpkgs/alsa-plugins/template
@@ -1,7 +1,7 @@
 # Template file for 'alsa-plugins'
 pkgname=alsa-plugins
 version=1.2.7.1
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--disable-maemo-plugin"
 hostmakedepends="pkg-config"

From 9c9aa67ca3cfa39b5ea1dbfde1eccaa34a5d6716 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:43 -0500
Subject: [PATCH 104/112] minidlna: revbump for ffmpeg6

---
 srcpkgs/minidlna/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/minidlna/template b/srcpkgs/minidlna/template
index 5fa929f3a0c12..742991ecd04af 100644
--- a/srcpkgs/minidlna/template
+++ b/srcpkgs/minidlna/template
@@ -1,7 +1,7 @@
 # Template file for 'minidlna'
 pkgname=minidlna
 version=1.3.3
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="
  --sbindir=/usr/bin

From 6e1d3de69f11de68ef68c5786c76e1ee7d26b8e2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 17:57:47 -0500
Subject: [PATCH 105/112] mpv: revbump for ffmpeg6

---
 srcpkgs/mpv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpv/template b/srcpkgs/mpv/template
index 4948d1e332cb8..1ac1b167af189 100644
--- a/srcpkgs/mpv/template
+++ b/srcpkgs/mpv/template
@@ -1,7 +1,7 @@
 # Template file for 'mpv'
 pkgname=mpv
 version=0.36.0
-revision=4
+revision=5
 build_style=meson
 configure_args="-Dcdda=enabled -Ddvbin=enabled -Ddvdnav=enabled
  -Dlibmpv=true -Dcplugins=enabled

From a73449be02e1708ea734b80b7051d831a36e438d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 17:59:29 -0500
Subject: [PATCH 106/112] qimgv: revbump for ffmpeg6

---
 srcpkgs/qimgv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qimgv/template b/srcpkgs/qimgv/template
index dd341dfe1bfce..8a7e1c081ef12 100644
--- a/srcpkgs/qimgv/template
+++ b/srcpkgs/qimgv/template
@@ -1,7 +1,7 @@
 # Template file for 'qimgv'
 pkgname=qimgv
 version=1.0.2
-revision=3
+revision=4
 build_style=cmake
 configure_args="$(vopt_if video -DVIDEO_SUPPORT=ON -DVIDEO_SUPPORT=OFF)
  $(vopt_if scale -DOPENCV_SUPPORT=ON -DOPENCV_SUPPORT=OFF)

From 2fcd0cd0ec07886543d07233c087bf5852ad854e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 18:00:36 -0500
Subject: [PATCH 107/112] kfilemetadata5: revbump for ffmpeg6

---
 srcpkgs/kfilemetadata5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kfilemetadata5/template b/srcpkgs/kfilemetadata5/template
index 51fd6fec8c1c0..ad229b4c2e241 100644
--- a/srcpkgs/kfilemetadata5/template
+++ b/srcpkgs/kfilemetadata5/template
@@ -1,7 +1,7 @@
 # Template file for 'kfilemetadata5'
 pkgname=kfilemetadata5
 version=5.113.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="kcoreaddons extra-cmake-modules pkg-config qt5-host-tools qt5-qmake
  gettext kcoreaddons python3"

From 308c685b3725ab00e10f314523e460e0efc1ce80 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 8 Dec 2023 11:46:01 -0500
Subject: [PATCH 108/112] vba-m: revbump for ffmpeg6

---
 srcpkgs/vba-m/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vba-m/template b/srcpkgs/vba-m/template
index 52efeede1dcba..3e0760398905c 100644
--- a/srcpkgs/vba-m/template
+++ b/srcpkgs/vba-m/template
@@ -2,7 +2,7 @@
 pkgname=vba-m
 reverts=1292_2
 version=2.1.8
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_GTK=TRUE -DENABLE_FFMPEG=TRUE -DENABLE_LINK=TRUE -DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="gettext pkg-config unzip zip yasm wxWidgets-gtk3-devel"

From 76968cf2cd0dc04606a2ea72f8ba49dcb944a462 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 8 Dec 2023 11:46:19 -0500
Subject: [PATCH 109/112] dolphin-emu: revbump for ffmpeg6

---
 srcpkgs/dolphin-emu/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/dolphin-emu/template b/srcpkgs/dolphin-emu/template
index 862d3ae964eec..a7ae0efb58fb7 100644
--- a/srcpkgs/dolphin-emu/template
+++ b/srcpkgs/dolphin-emu/template
@@ -1,7 +1,7 @@
 # Template file for 'dolphin-emu'
 pkgname=dolphin-emu
 version=5.0.19368
-revision=3
+revision=4
 _dolphin_commit=dadbeb4bae7e7fa23af2b46e0add4143094dc107
 _mgba_commit=44e074a15e9651481f7f652ac006a7c9d58cbeb9
 _googletest_commit=be03d00f5f0cc3a997d1a368bee8a1fe93651f48

From 49de4a9f1f595d7dfcd167e5404f4b9f2a3c3408 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 19 Dec 2023 15:38:51 -0500
Subject: [PATCH 110/112] qtox: revbump for ffmpeg4

---
 srcpkgs/qtox/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtox/template b/srcpkgs/qtox/template
index bb70e7f51240a..755e4462bc013 100644
--- a/srcpkgs/qtox/template
+++ b/srcpkgs/qtox/template
@@ -1,13 +1,13 @@
 # Template file for 'qtox'
 pkgname=qtox
 version=1.17.6
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DUPDATE_CHECK=OFF
  -DGIT_DESCRIBE=${version}
  $(vopt_if snorenotify -DDESKTOP_NOTIFICATIONS=ON)"
 hostmakedepends="pkg-config qt5-host-tools qt5-devel"
-makedepends="ffmpeg-devel libexif-devel libopenal-devel libsodium-devel
+makedepends="ffmpeg4-devel libexif-devel libopenal-devel libsodium-devel
  libvpx-devel opus-devel qrencode-devel qt5-svg-devel sonnet-devel
  sqlcipher-devel toxcore-devel
  $(vopt_if snorenotify snorenotify-devel)"

From bdef6a7e111906b3f5e19ef83a7c002d04c47bf2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 11 Jan 2024 11:52:00 -0500
Subject: [PATCH 111/112] arcan: revbump for ffmpeg6

---
 srcpkgs/arcan/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/arcan/template b/srcpkgs/arcan/template
index ff9091f90ebb1..030091a6cc9d0 100644
--- a/srcpkgs/arcan/template
+++ b/srcpkgs/arcan/template
@@ -2,7 +2,7 @@
 # !! keep synced with: acfgfs aclip aloadimage
 pkgname=arcan
 version=0.6.2.1
-revision=2
+revision=3
 create_wrksrc=yes
 build_wrksrc=arcan/src
 build_style=cmake

From e3d9e1251b80b94edbf55e09fa4d2401314bce73 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 11 Jan 2024 11:52:10 -0500
Subject: [PATCH 112/112] notcurses: revbump for ffmpeg6

---
 srcpkgs/notcurses/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/notcurses/template b/srcpkgs/notcurses/template
index 48a7463cb68eb..515f316ab4576 100644
--- a/srcpkgs/notcurses/template
+++ b/srcpkgs/notcurses/template
@@ -1,7 +1,7 @@
 # Template file for 'notcurses'
 pkgname=notcurses
 version=3.0.9
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DUSE_STATIC=ON -DUSE_QRCODEGEN=On $(vopt_bool man USE_PANDOC)"
 hostmakedepends="pkg-config $(vopt_if man pandoc)"

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (53 preceding siblings ...)
  2024-01-17 22:35 ` zlice
@ 2024-01-17 22:50 ` zlice
  2024-01-28 18:46 ` zlice
                   ` (42 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2024-01-17 22:50 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 4019 bytes --]

There is an updated pull request by zlice against master on the void-packages repository

https://github.com/zlice/void-packages ffmpeg6-split
https://github.com/void-linux/void-packages/pull/43761

ffmpeg6 split
[ci skip]


#### Testing the changes

- I tested the changes in this PR: **YES**

main testing has been vaapi in Firefox Nightly and enc/dec in Shotcut on Intel A770

#### New package

- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**

#### Local build testing

- I built this PR locally for my native architecture, **x86_64**

#### Discussion

Continuation of https://github.com/void-linux/void-packages/pull/36315

`libavresample` is deprecated, but marked as a dependency when trying to build other packages and install `ffmpeg`(6). I think the right way to handle this is make a meta package and the add to removals?


##### Commit naming / misc

~~Commits are 'dirty' right now, running with [gstreamer 1.22.1 updates](https://github.com/void-linux/void-packages/pull/42861) and [Intel OpenCL](https://github.com/void-linux/void-packages/pull/43084). This will also make [intel packages pr](https://github.com/void-linux/void-packages/pull/41132) obsolete.~~ (see Requirements below)

Maintainer for previous ffmpeg(4) was orphaned, I can put my name in there if that matters, though I don't exactly see myself keeping up on ffmpeg.

~~This updates QT5 which looks like it is usually hosted by Johnny. Not sure if there's any reason to stay there or these sources are fine.~~ Using qt5.15.11 now, revbumps and some patches.

##### STILL FFMPEG4

These are a mix of emulators, games and/or older packages.

- attract (multiple patches in master)
- audacity (https://github.com/audacity/audacity/issues/2305 and https://sourceforge.net/p/portmedia/wiki/portsmf/ is 'beta')
- ccextractor (master patches? no release)
- vice
- kodi
- mlt (only dep left is flowblade)
- ~~synfig (mlt)~~ (work with mlt7, bump synfigstudio)
- tvheadend
- ssr
- ~~spek-alternative~~ (replace with spek-x)
- ppsspp
- olive
- moc
- mediastreamer
- libextractor
- idjc
- hedgewars
- ~~ffmpegthumbnailer~~ (patches for moviedecoder.xxx files)
- ~~ffmpegthumbs~~ (latest compiles)
- deadbeef
- omxplayer
- qtav (fork has ffmpeg 5 patch - https://github.com/cmguo/QtAV)
- `vlc` (vlc4 will support ffmpeg5, there's a patch to build 3.x with ffmpeg5 but it will lack vaapi)
- `osg` (OpenSceneGraph plus `xine-lib`)


##### HAVE NOT BUILT YET

- omxplayer (rpi only? ffmpeg4)
- kodi (big, but ffmpeg4)


##### UPDATED (for ffmpeg6)

- ~~blender: update to 3.5.1~~ ~~will be revbump with~~ https://github.com/void-linux/void-packages/pull/43992
- unpaper: update to 7.0.0.
- guvcview: update to 2.0.8.
- ~~qt5: update to 5.15.8~~ updated by another PR to 5.15.11
- ~~qt5-webengine: update to 5.18.15~~ updated by another PR to 5.15.16 (some patching for ffmpeg build)
- ~~shiboken2: revbump for qt5.15.8 (patch)~~ updated by another PR to 5.15.10
- ~~python3-pyside2: update to 5.15.8 (patch)~~ updated by another PR to 5.15.10
- New package: spex-x replaces spek-alternative for ffmpeg-6.0


##### Requirements

- ~~[gstreamer 1.22.2](https://github.com/void-linux/void-packages/pull/42861)~~ - a few packages use ffmpeg-devel and require a revbump

- ~~[Intel Packages](https://github.com/void-linux/void-packages/pull/41132) [Intel Packages v2](https://github.com/void-linux/void-packages/pull/47330) - ffmpeg4 uses different libraries than 6 (libmfx / Intel-MediaSDK vs only oneVPL that Intel is moving to), both are included here~~. Using replacement oneVPL from OBS update.

- ~~[shotcut 23.05.14](https://github.com/void-linux/void-packages/pull/44260)~~

- https://github.com/void-linux/void-packages/pull/44781 will remove from this PR

A patch file from https://github.com/void-linux/void-packages/pull/43761.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ffmpeg6-split-43761.patch --]
[-- Type: text/x-diff, Size: 219058 bytes --]

From eddb78657b1d6615cdc80cd8a0465041334302b6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:16:56 -0400
Subject: [PATCH 001/112] ffmpeg: update to 6.0.1.

---
 common/shlibs                                 | 26 +++++---
 srcpkgs/ffmpeg/files/altivec.patch            | 60 -------------------
 .../patches/armv5tel-floating-point.patch     | 18 ------
 ...h-libavcodec-libsvtav1-ten_bit_format.diff | 40 -------------
 .../workaround-mesa-readeon-vaapi-bug.patch   | 28 ---------
 srcpkgs/ffmpeg/template                       | 38 ++++++------
 6 files changed, 37 insertions(+), 173 deletions(-)
 delete mode 100644 srcpkgs/ffmpeg/files/altivec.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 delete mode 100644 srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch

diff --git a/common/shlibs b/common/shlibs
index 9e6d29c73341e..177934cf6cc2d 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -385,15 +385,23 @@ libid3tag.so.0 libid3tag-0.15.1b_1
 libgif.so.7 giflib-5.1.0_1
 libImlib2.so.1 imlib2-1.4.2_1
 libmp3lame.so.0 lame-3.98.2_1
-libavdevice.so.58 libavdevice-4.0_1
-libavformat.so.58 libavformat-4.0_1
-libswscale.so.5 libswscale-4.0_1
-libswresample.so.3 libswresample-4.0_1
-libavresample.so.4 libavresample-4.0_1
-libpostproc.so.55 libpostproc-4.0_1
-libavcodec.so.58 libavcodec-4.0_1
-libavutil.so.56 libavutil-4.0_1
-libavfilter.so.7 libavfilter-4.0_1
+libavdevice.so.60 libavdevice-6.0_1
+libavformat.so.60 libavformat-6.0_1
+libswscale.so.7 libswscale-6.0_1
+libswresample.so.4 libswresample-6.0_1
+libpostproc.so.57 libpostproc-6.0_1
+libavcodec.so.60 libavcodec-6.0_1
+libavutil.so.58 libavutil-6.0_1
+libavfilter.so.9 libavfilter-6.0_1
+libavdevice.so.58 libavdevice4-4.0_1
+libavformat.so.58 libavformat4-4.0_1
+libswscale.so.5 libswscale4-4.0_1
+libswresample.so.3 libswresample4-4.0_1
+libavresample.so.4 libavresample4-4.0_1
+libpostproc.so.55 libpostproc4-4.0_1
+libavcodec.so.58 libavcodec4-4.0_1
+libavutil.so.56 libavutil4-4.0_1
+libavfilter.so.7 libavfilter4-4.0_1
 libSDL-1.2.so.0 SDL-1.2.14_1
 libSDL_image-1.2.so.0 SDL_image-1.2.10_1
 libx264.so.157 x264-20190507.2245_1
diff --git a/srcpkgs/ffmpeg/files/altivec.patch b/srcpkgs/ffmpeg/files/altivec.patch
deleted file mode 100644
index 9c57200463320..0000000000000
--- a/srcpkgs/ffmpeg/files/altivec.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-revert some altivec specific change on all ppc* except ppc64le*
-
-q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
-conditionally, for ppc* but not ppc64le* (the new code is valid for
-POWER8 VSX which LE targets as a baseline but not BE)"
-
-
-This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
----
- libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
- 1 file changed, 20 insertions(+), 4 deletions(-)
-
-diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
-index 536545293d..c1e2852adb 100644
---- a/libswscale/ppc/yuv2rgb_altivec.c
-+++ b/libswscale/ppc/yuv2rgb_altivec.c
-@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-     vector signed short R1, G1, B1;                                           \
-     vector unsigned char R, G, B;                                             \
-                                                                               \
-+    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
-+    vector unsigned char align_perm;                                          \
-+                                                                              \
-     vector signed short lCY       = c->CY;                                    \
-     vector signed short lOY       = c->OY;                                    \
-     vector signed short lCRV      = c->CRV;                                   \
-@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
-                                                                               \
-         for (j = 0; j < w / 16; j++) {                                        \
--            y0 = vec_xl(0, y1i);                                              \
-+            y1ivP = (const vector unsigned char *) y1i;                       \
-+            y2ivP = (const vector unsigned char *) y2i;                       \
-+            uivP  = (const vector unsigned char *) ui;                        \
-+            vivP  = (const vector unsigned char *) vi;                        \
-+                                                                              \
-+            align_perm = vec_lvsl(0, y1i);                                    \
-+            y0 = (vector unsigned char)                                       \
-+                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
-                                                                               \
--            y1 = vec_xl(0, y2i);                                              \
-+            align_perm = vec_lvsl(0, y2i);                                    \
-+            y1 = (vector unsigned char)                                       \
-+                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
-                                                                               \
--            u = (vector signed char) vec_xl(0, ui);                           \
-+            align_perm = vec_lvsl(0, ui);                                     \
-+            u = (vector signed char)                                          \
-+                    vec_perm(uivP[0], uivP[1], align_perm);                   \
-                                                                               \
--            v = (vector signed char) vec_xl(0, vi);                           \
-+            align_perm = vec_lvsl(0, vi);                                     \
-+            v = (vector signed char)                                          \
-+                    vec_perm(vivP[0], vivP[1], align_perm);                   \
-                                                                               \
-             u = (vector signed char)                                          \
-                     vec_sub(u,                                                \
--- 
-2.27.0
-
diff --git a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
deleted file mode 100644
index 9a55178c74f0f..0000000000000
--- a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
-+++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
-@@ -39,6 +39,15 @@
- #endif
- #include <fenv.h>
- 
-+#if (FE_ALL_EXCEPT == 0)
-+/* E.g. ARM soft float does not define these */
-+#define FE_INVALID    0
-+#define FE_DIVBYZERO  0
-+#define FE_OVERFLOW   0
-+#define FE_UNDERFLOW  0
-+#define FE_INEXACT    0
-+#endif
-+
- #if CONFIG_LIBFONTCONFIG
- #include <fontconfig/fontconfig.h>
- #endif
diff --git a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
deleted file mode 100644
index aa948f7a8a2df..0000000000000
--- a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
+++ /dev/null
@@ -1,40 +0,0 @@
-#==================================================================================================
-# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
-# From: Christopher Degawa <christopher.degawa@intel.com>
-# Date: Thu, 20 Oct 2022 22:55:27 -0500
-# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
-#
-# compressed_ten_bit_format has been deprecated upstream and has no effect
-# and can be removed. Plus, technically it was never used in the first place
-# since it would require the app (ffmpeg) to set it and do additional
-# processing of the input frames.
-#
-# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
-#
-# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
-#==================================================================================================
---- a/libavcodec/libsvtav1.c
-+++ b/libavcodec/libsvtav1.c
-@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
- 
- static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
- {
--    const int    pack_mode_10bit =
--        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
--    const size_t luma_size_8bit  =
--        config->source_width * config->source_height * (1 << pack_mode_10bit);
--    const size_t luma_size_10bit =
--        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
-+    const size_t luma_size = config->source_width * config->source_height *
-+        (config->encoder_bit_depth > 8 ? 2 : 1);
- 
-     EbSvtIOFormat *in_data;
- 
--    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
-+    svt_enc->raw_size = luma_size * 3 / 2;
- 
-     // allocate buffer for in and out
-     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
--- 
-GitLab
-
diff --git a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
deleted file mode 100644
index 00e3f68a415b8..0000000000000
--- a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
-From: Rainer Hochecker <fernetmenta@online.de>
-Date: Sat, 26 Jan 2019 19:48:35 +0100
-Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
-
-This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
-It was hit frequently when watching h264 channels received via DVB-X.
-Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
----
- libavcodec/vaapi_h264.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
-index 5854587a255..f12fdc457a4 100644
---- a/libavcodec/vaapi_h264.c
-+++ b/libavcodec/vaapi_h264.c
-@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
-     H264SliceContext *sl = &h->slice_ctx[0];
-     int ret;
- 
-+    if (pic->nb_slices == 0) {
-+        ret = AVERROR_INVALIDDATA;
-+        goto finish;
-+    }
-+
-     ret = ff_vaapi_decode_issue(avctx, pic);
-     if (ret < 0)
-         goto finish;
diff --git a/srcpkgs/ffmpeg/template b/srcpkgs/ffmpeg/template
index 5968a09b1f12d..52fcf4d68797a 100644
--- a/srcpkgs/ffmpeg/template
+++ b/srcpkgs/ffmpeg/template
@@ -1,15 +1,15 @@
 # Template file for 'ffmpeg'
 # audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
 pkgname=ffmpeg
-version=4.4.4
-revision=5
+version=6.0.1
+revision=1
 short_desc="Decoding, encoding and streaming software"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="https://www.ffmpeg.org"
 changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
 distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
-checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+checksum=9b16b8731d78e596b4be0d720428ca42df642bb2d78342881ff7f5bc29fc9623
 
 hostmakedepends="pkg-config perl"
 makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
@@ -26,12 +26,13 @@ makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-deve
  $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
  $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
  $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
- $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers Vulkan-Tools Vulkan-ValidationLayers')
+ $(vopt_if onevpl 'oneVPL oneVPL-devel')
  $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
 depends="ffplay>=${version}_${revision}"
 
 build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
- dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec onevpl"
 build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
 desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
 desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
@@ -39,9 +40,13 @@ desc_option_sofa="Enable support for AES SOFA"
 desc_option_webp="Enable support for WebP"
 
 case "$XBPS_TARGET_MACHINE" in
-	i686*|x86_64*)
-		hostmakedepends+=" nasm"
+	i686*)
 		build_options_default+=" vaapi vdpau nvenc nvdec"
+		hostmakedepends+=" nasm"
+		;;
+	x86_64*)
+		hostmakedepends+=" nasm"
+		build_options_default+=" vaapi vdpau nvenc nvdec onevpl"
 		;;
 	ppc64*) build_options_default+=" vaapi vdpau";;
 	mips*) CFLAGS="-mnan=legacy";;
@@ -115,18 +120,19 @@ do_configure() {
 		$(vopt_enable x265 libx265) \
 		$(vopt_enable v4l2 libv4l2) \
 		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
-		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		--enable-libbs2b --enable-libvidstab \
 		$(vopt_enable dav1d libdav1d) \
 		$(vopt_enable zimg libzimg) \
 		$(vopt_enable webp libwebp) \
 		$(vopt_enable sofa libmysofa) \
 		$(vopt_enable vulkan) \
+		$(vopt_enable onevpl libvpl) \
 		$(vopt_enable drm libdrm) \
 		$(vopt_enable svtav1 libsvtav1) \
 		$(vopt_enable srt libsrt) \
 		$(vopt_enable rist librist) \
-		$(vopt_if nvenc '--enable-nvenc') \
-		$(vopt_if nvdec '--enable-nvdec')
+		$(vopt_enable nvenc nvenc) \
+		$(vopt_enable nvdec nvdec)
 }
 
 do_build() {
@@ -153,10 +159,8 @@ libavdevice_package() {
 }
 
 libavresample_package() {
-	short_desc="FFmpeg audio resampling library"
-	pkg_install() {
-		vmove "usr/lib/libavresample.so.*"
-	}
+	short_desc="Package deprecated, removal needed"
+	build_style=meta
 }
 
 libavformat_package() {
@@ -210,15 +214,13 @@ ffmpeg-devel_package() {
 		libavfilter>=${version}_${revision}
 		libpostproc>=${version}_${revision}
 		libswscale>=${version}_${revision}
-		libswresample>=${version}_${revision}
-		libavresample>=${version}_${revision}"
+		libswresample>=${version}_${revision}"
 	short_desc+=" - development files"
-
+	conflicts="ffmpeg4-devel"
 	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
 		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
 		nostrip_files="/usr/lib/libavfilter.a"
 	fi
-
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig

From 94d57cda9b53e141fcf69d40332154c3964c330c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:14 -0400
Subject: [PATCH 002/112] openshot: revbump for ffmpeg6

---
 srcpkgs/openshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openshot/template b/srcpkgs/openshot/template
index 8f47851eef354..affb652a9d500 100644
--- a/srcpkgs/openshot/template
+++ b/srcpkgs/openshot/template
@@ -1,7 +1,7 @@
 # Template file for 'openshot'
 pkgname=openshot
 version=3.0.0
-revision=2
+revision=3
 build_style=python3-module
 hostmakedepends="python3 python3-setuptools"
 makedepends="ffmpeg-devel python3-PyQt5"

From 0998ddccd28c8d38e7cfa7d6802d22822c0646ef Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:36 -0400
Subject: [PATCH 003/112] sumo: revbump for ffmpeg6

---
 srcpkgs/sumo/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/sumo/template b/srcpkgs/sumo/template
index a3fe134aa5acc..a730afa9fafa9 100644
--- a/srcpkgs/sumo/template
+++ b/srcpkgs/sumo/template
@@ -1,7 +1,7 @@
 # Template file for 'sumo'
 pkgname=sumo
 version=1.12.0
-revision=6
+revision=7
 build_style=cmake
 hostmakedepends="libgdal-tools pkg-config swig python3-setuptools"
 makedepends="python3-devel ffmpeg-devel fox-devel gl2ps-devel libgdal-devel

From 4922f6b739cb4c472c7b732320ff044d0fc103fe Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:56:22 -0400
Subject: [PATCH 004/112] New package: ffmpeg4-4.4.4.

---
 srcpkgs/ffmpeg4-devel                         |   1 +
 srcpkgs/ffmpeg4/files/altivec.patch           |  60 +++++
 .../patches/armv5tel-floating-point.patch     |  18 ++
 ...h-libavcodec-libsvtav1-ten_bit_format.diff |  40 +++
 .../workaround-mesa-readeon-vaapi-bug.patch   |  28 +++
 srcpkgs/ffmpeg4/template                      | 234 ++++++++++++++++++
 srcpkgs/libavcodec4                           |   1 +
 srcpkgs/libavdevice4                          |   1 +
 srcpkgs/libavfilter4                          |   1 +
 srcpkgs/libavformat4                          |   1 +
 srcpkgs/libavresample4                        |   1 +
 srcpkgs/libavutil4                            |   1 +
 srcpkgs/libpostproc4                          |   1 +
 srcpkgs/libswresample4                        |   1 +
 srcpkgs/libswscale4                           |   1 +
 15 files changed, 390 insertions(+)
 create mode 120000 srcpkgs/ffmpeg4-devel
 create mode 100644 srcpkgs/ffmpeg4/files/altivec.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 create mode 100644 srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
 create mode 100644 srcpkgs/ffmpeg4/template
 create mode 120000 srcpkgs/libavcodec4
 create mode 120000 srcpkgs/libavdevice4
 create mode 120000 srcpkgs/libavfilter4
 create mode 120000 srcpkgs/libavformat4
 create mode 120000 srcpkgs/libavresample4
 create mode 120000 srcpkgs/libavutil4
 create mode 120000 srcpkgs/libpostproc4
 create mode 120000 srcpkgs/libswresample4
 create mode 120000 srcpkgs/libswscale4

diff --git a/srcpkgs/ffmpeg4-devel b/srcpkgs/ffmpeg4-devel
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/ffmpeg4-devel
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/ffmpeg4/files/altivec.patch b/srcpkgs/ffmpeg4/files/altivec.patch
new file mode 100644
index 0000000000000..9c57200463320
--- /dev/null
+++ b/srcpkgs/ffmpeg4/files/altivec.patch
@@ -0,0 +1,60 @@
+revert some altivec specific change on all ppc* except ppc64le*
+
+q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
+conditionally, for ppc* but not ppc64le* (the new code is valid for
+POWER8 VSX which LE targets as a baseline but not BE)"
+
+
+This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
+---
+ libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
+ 1 file changed, 20 insertions(+), 4 deletions(-)
+
+diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
+index 536545293d..c1e2852adb 100644
+--- a/libswscale/ppc/yuv2rgb_altivec.c
++++ b/libswscale/ppc/yuv2rgb_altivec.c
+@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+     vector signed short R1, G1, B1;                                           \
+     vector unsigned char R, G, B;                                             \
+                                                                               \
++    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
++    vector unsigned char align_perm;                                          \
++                                                                              \
+     vector signed short lCY       = c->CY;                                    \
+     vector signed short lOY       = c->OY;                                    \
+     vector signed short lCRV      = c->CRV;                                   \
+@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
+                                                                               \
+         for (j = 0; j < w / 16; j++) {                                        \
+-            y0 = vec_xl(0, y1i);                                              \
++            y1ivP = (const vector unsigned char *) y1i;                       \
++            y2ivP = (const vector unsigned char *) y2i;                       \
++            uivP  = (const vector unsigned char *) ui;                        \
++            vivP  = (const vector unsigned char *) vi;                        \
++                                                                              \
++            align_perm = vec_lvsl(0, y1i);                                    \
++            y0 = (vector unsigned char)                                       \
++                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
+                                                                               \
+-            y1 = vec_xl(0, y2i);                                              \
++            align_perm = vec_lvsl(0, y2i);                                    \
++            y1 = (vector unsigned char)                                       \
++                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
+                                                                               \
+-            u = (vector signed char) vec_xl(0, ui);                           \
++            align_perm = vec_lvsl(0, ui);                                     \
++            u = (vector signed char)                                          \
++                    vec_perm(uivP[0], uivP[1], align_perm);                   \
+                                                                               \
+-            v = (vector signed char) vec_xl(0, vi);                           \
++            align_perm = vec_lvsl(0, vi);                                     \
++            v = (vector signed char)                                          \
++                    vec_perm(vivP[0], vivP[1], align_perm);                   \
+                                                                               \
+             u = (vector signed char)                                          \
+                     vec_sub(u,                                                \
+-- 
+2.27.0
+
diff --git a/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
new file mode 100644
index 0000000000000..9a55178c74f0f
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
@@ -0,0 +1,18 @@
+--- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
++++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
+@@ -39,6 +39,15 @@
+ #endif
+ #include <fenv.h>
+ 
++#if (FE_ALL_EXCEPT == 0)
++/* E.g. ARM soft float does not define these */
++#define FE_INVALID    0
++#define FE_DIVBYZERO  0
++#define FE_OVERFLOW   0
++#define FE_UNDERFLOW  0
++#define FE_INEXACT    0
++#endif
++
+ #if CONFIG_LIBFONTCONFIG
+ #include <fontconfig/fontconfig.h>
+ #endif
diff --git a/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
new file mode 100644
index 0000000000000..aa948f7a8a2df
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
@@ -0,0 +1,40 @@
+#==================================================================================================
+# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
+# From: Christopher Degawa <christopher.degawa@intel.com>
+# Date: Thu, 20 Oct 2022 22:55:27 -0500
+# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
+#
+# compressed_ten_bit_format has been deprecated upstream and has no effect
+# and can be removed. Plus, technically it was never used in the first place
+# since it would require the app (ffmpeg) to set it and do additional
+# processing of the input frames.
+#
+# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
+#
+# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
+#==================================================================================================
+--- a/libavcodec/libsvtav1.c
++++ b/libavcodec/libsvtav1.c
+@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
+ 
+ static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
+ {
+-    const int    pack_mode_10bit =
+-        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
+-    const size_t luma_size_8bit  =
+-        config->source_width * config->source_height * (1 << pack_mode_10bit);
+-    const size_t luma_size_10bit =
+-        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
++    const size_t luma_size = config->source_width * config->source_height *
++        (config->encoder_bit_depth > 8 ? 2 : 1);
+ 
+     EbSvtIOFormat *in_data;
+ 
+-    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
++    svt_enc->raw_size = luma_size * 3 / 2;
+ 
+     // allocate buffer for in and out
+     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
+-- 
+GitLab
+
diff --git a/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
new file mode 100644
index 0000000000000..00e3f68a415b8
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
@@ -0,0 +1,28 @@
+From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
+From: Rainer Hochecker <fernetmenta@online.de>
+Date: Sat, 26 Jan 2019 19:48:35 +0100
+Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
+
+This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
+It was hit frequently when watching h264 channels received via DVB-X.
+Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
+---
+ libavcodec/vaapi_h264.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
+index 5854587a255..f12fdc457a4 100644
+--- a/libavcodec/vaapi_h264.c
++++ b/libavcodec/vaapi_h264.c
+@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
+     H264SliceContext *sl = &h->slice_ctx[0];
+     int ret;
+ 
++    if (pic->nb_slices == 0) {
++        ret = AVERROR_INVALIDDATA;
++        goto finish;
++    }
++
+     ret = ff_vaapi_decode_issue(avctx, pic);
+     if (ret < 0)
+         goto finish;
diff --git a/srcpkgs/ffmpeg4/template b/srcpkgs/ffmpeg4/template
new file mode 100644
index 0000000000000..9ba14bdb8ddf3
--- /dev/null
+++ b/srcpkgs/ffmpeg4/template
@@ -0,0 +1,234 @@
+# Template file for 'ffmpeg4'
+# audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
+pkgname=ffmpeg4
+version=4.4.4
+revision=1
+short_desc="Decoding, encoding and streaming software - ffmpeg4 libraries only"
+maintainer="Orphaned <orphan@voidlinux.org>"
+license="GPL-3.0-or-later"
+homepage="https://www.ffmpeg.org"
+changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
+distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
+checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+
+hostmakedepends="pkg-config perl"
+makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
+ libXext-devel libXvMC-devel libxcb-devel lame-devel libtheora-devel
+ libvorbis-devel x264-devel xvidcore-devel jack-devel SDL2-devel
+ libcdio-paranoia-devel librtmp-devel libmodplug-devel gnutls-devel
+ speex-devel celt-devel harfbuzz-devel libass-devel opus-devel ocl-icd-devel
+ libbs2b-devel libvidstab-devel vmaf-devel $(vopt_if pulseaudio pulseaudio-devel)
+ $(vopt_if vaapi libva-devel) $(vopt_if vdpau libvdpau-devel)
+ $(vopt_if x265 x265-devel) $(vopt_if v4l2 v4l-utils-devel)
+ $(vopt_if fdk_aac fdk-aac-devel) $(vopt_if vpx libvpx-devel)
+ $(vopt_if aom libaom-devel) $(vopt_if sndio sndio-devel)
+ $(vopt_if dav1d libdav1d-devel) $(vopt_if zimg zimg-devel)
+ $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
+ $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
+ $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
+
+build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
+
+desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
+desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
+desc_option_sofa="Enable support for AES SOFA"
+desc_option_webp="Enable support for WebP"
+
+case "$XBPS_TARGET_MACHINE" in
+	i686*|x86_64*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau nvenc nvdec"
+			;;
+	ppc64*) build_options_default+=" vaapi vdpau";;
+	mips*) CFLAGS="-mnan=legacy";;
+esac
+
+if [ "$XBPS_TARGET_WORDSIZE" != "32" ]; then
+	build_options_default+=" svtav1"
+fi
+
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+fi
+
+_apply_patch() {
+	local args="$1" pname="$(basename $2)"
+
+	if [ ! -f ".${pname}_done" ]; then
+		patch -N $args -i $2
+		touch .${pname}_done
+	fi
+}
+
+post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64le*) ;;
+		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
+	esac
+
+	vsed -i libavfilter/vf_libvmaf.c -e 's!/usr/local/share/model/\(vmaf_v0.6.1\).pkl!/usr/share/vmaf/\1.json!'
+}
+
+do_configure() {
+	# Fix gcc on x86_64-musl only
+	if [ "$XBPS_TARGET_MACHINE" = "x86_64-musl" ]; then
+		vsed -i configure -e "s;_cflags_speed='-O3';_cflags_speed='-O2';"
+	fi
+
+	if [ "$CROSS_BUILD" ]; then
+		case "$XBPS_TARGET_MACHINE" in
+			arm*) _arch="arm";;
+			aarch64*) _arch="aarch64";;
+			mips*) _arch="mips";;
+			ppc64*) _arch="ppc64";;
+			ppc*) _arch="ppc";;
+			*) _arch="${XBPS_TARGET_MACHINE%%-musl}";;
+		esac
+
+		_args+=" --enable-cross-compile
+			--sysroot=$XBPS_CROSS_BASE
+			--cross-prefix=${XBPS_CROSS_TRIPLET}-
+			--target-os=linux --arch=${_arch}"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc|ppc-musl) _args+=" --disable-altivec";;
+	esac
+
+	if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+		_args+=" --extra-libs=-latomic"
+	fi
+
+	./configure --prefix=/usr --disable-debug --enable-gpl --enable-gnutls \
+		--disable-stripping \
+		--enable-libcdio --enable-version3 --enable-runtime-cpudetect \
+		--enable-libmp3lame --enable-libvorbis --enable-libxvid \
+		--enable-libx264 $(vopt_enable vpx libvpx) --enable-libtheora \
+		--enable-shared --enable-static --enable-libxcb \
+		$(vopt_enable pulseaudio libpulse) --enable-libfreetype --enable-libmodplug \
+		--enable-libspeex --enable-libcelt --enable-libass \
+		--enable-libopus --enable-librtmp --enable-libjack \
+		$(vopt_if fdk_aac '--enable-nonfree --enable-libfdk-aac') \
+		--disable-libopencore_amrnb --disable-libopencore_amrwb \
+		--disable-libopenjpeg \
+		--enable-postproc --enable-opencl ${_args} --enable-libvmaf ${_args} \
+		$(vopt_enable x265 libx265) \
+		$(vopt_enable v4l2 libv4l2) \
+		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
+		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		$(vopt_enable dav1d libdav1d) \
+		$(vopt_enable zimg libzimg) \
+		$(vopt_enable webp libwebp) \
+		$(vopt_enable sofa libmysofa) \
+		$(vopt_enable vulkan) \
+		$(vopt_enable drm libdrm) \
+		$(vopt_enable svtav1 libsvtav1) \
+		$(vopt_enable srt libsrt) \
+		$(vopt_enable rist librist) \
+		$(vopt_if nvenc '--enable-nvenc') \
+		$(vopt_if nvdec '--enable-nvdec')
+}
+
+do_build() {
+	make ${makejobs}
+	make doc/ff{mpeg,play}.1
+}
+
+do_install() {
+	make DESTDIR=${DESTDIR} install install-man
+	rm -rf ${DESTDIR}/usr/bin
+}
+
+libavcodec4_package() {
+	short_desc="FFmpeg codec library"
+	pkg_install() {
+		vmove "usr/lib/libavcodec.so.*"
+	}
+}
+
+libavdevice4_package() {
+	short_desc="FFmpeg device handling library"
+	pkg_install() {
+		vmove "usr/lib/libavdevice.so.*"
+	}
+}
+
+libavresample4_package() {
+	short_desc="FFmpeg audio resampling library"
+	pkg_install() {
+		vmove "usr/lib/libavresample.so.*"
+	}
+}
+
+libavformat4_package() {
+	short_desc="FFmpeg file format library"
+	pkg_install() {
+		vmove "usr/lib/libavformat.so.*"
+	}
+}
+
+libavutil4_package() {
+	short_desc="FFmpeg utility library"
+	pkg_install() {
+		vmove "usr/lib/libavutil.so.*"
+	}
+}
+
+libavfilter4_package() {
+	short_desc="FFmpeg audio/video filter library"
+	pkg_install() {
+		vmove "usr/lib/libavfilter.so.*"
+	}
+}
+
+libpostproc4_package() {
+	short_desc="FFmpeg video postprocessing library"
+	pkg_install() {
+		vmove "usr/lib/libpostproc.so.*"
+	}
+}
+
+libswscale4_package() {
+	short_desc="FFmpeg video scaling library"
+	pkg_install() {
+		vmove "usr/lib/libswscale.so.*"
+	}
+}
+
+libswresample4_package() {
+	short_desc="FFmpeg video resampling library"
+	pkg_install() {
+		vmove "usr/lib/libswresample.so.*"
+	}
+}
+
+ffmpeg4-devel_package() {
+	depends="
+		libavcodec4>=${version}_${revision}
+		libavdevice4>=${version}_${revision}
+		libavformat4>=${version}_${revision}
+		libavutil4>=${version}_${revision}
+		libavfilter4>=${version}_${revision}
+		libpostproc4>=${version}_${revision}
+		libswscale4>=${version}_${revision}
+		libswresample4>=${version}_${revision}
+		libavresample4>=${version}_${revision}"
+	short_desc+=" - development files"
+	conflicts="ffmpeg-devel"
+	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
+		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
+		nostrip_files="/usr/lib/libavfilter.a"
+	fi
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.a"
+		vmove "usr/lib/*.so"
+		vmove usr/share/ffmpeg/examples
+		vmove usr/share/man/man3
+	}
+}
diff --git a/srcpkgs/libavcodec4 b/srcpkgs/libavcodec4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavcodec4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavdevice4 b/srcpkgs/libavdevice4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavdevice4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavfilter4 b/srcpkgs/libavfilter4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavfilter4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavformat4 b/srcpkgs/libavformat4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavformat4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavresample4 b/srcpkgs/libavresample4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavutil4 b/srcpkgs/libavutil4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavutil4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libpostproc4 b/srcpkgs/libpostproc4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libpostproc4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswresample4 b/srcpkgs/libswresample4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libswresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswscale4 b/srcpkgs/libswscale4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libswscale4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file

From 34b49866605a95bf2c98917a577509fd17a1c987 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:04 -0400
Subject: [PATCH 005/112] opencv: update to 4.7.0.

---
 common/shlibs           | 104 ++++++++++++++++++++--------------------
 srcpkgs/opencv/template |   8 ++--
 2 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index 177934cf6cc2d..165560a0af583 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2068,58 +2068,58 @@ libcapstone.so.5 capstone-5.0.1_1
 libhavege.so.2 libhaveged-1.9.11_1
 libnih.so.1 libnih-1.0.3_1
 libnih-dbus.so.1 libnih-1.0.3_1
-libopencv_quality.so.406 libopencv-4.6.0_1
-libopencv_reg.so.406 libopencv-4.6.0_1
-libopencv_surface_matching.so.406 libopencv-4.6.0_1
-libopencv_xphoto.so.406 libopencv-4.6.0_1
-libopencv_freetype.so.406 libopencv-4.6.0_1
-libopencv_fuzzy.so.406 libopencv-4.6.0_1
-libopencv_hfs.so.406 libopencv-4.6.0_1
-libopencv_img_hash.so.406 libopencv-4.6.0_1
-libopencv_line_descriptor.so.406 libopencv-4.6.0_1
-libopencv_saliency.so.406 libopencv-4.6.0_1
-libopencv_structured_light.so.406 libopencv-4.6.0_1
-libopencv_aruco.so.406 libopencv-4.6.0_1
-libopencv_bgsegm.so.406 libopencv-4.6.0_1
-libopencv_bioinspired.so.406 libopencv-4.6.0_1
-libopencv_ccalib.so.406 libopencv-4.6.0_1
-libopencv_face.so.406 libopencv-4.6.0_1
-libopencv_tracking.so.406 libopencv-4.6.0_1
-libopencv_xfeatures2d.so.406 libopencv-4.6.0_1
-libopencv_optflow.so.406 libopencv-4.6.0_1
-libopencv_ximgproc.so.406 libopencv-4.6.0_1
-libopencv_plot.so.406 libopencv-4.6.0_1
-libopencv_text.so.406 libopencv-4.6.0_1
-libopencv_ml.so.406 libopencv-4.6.0_1
-libopencv_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn.so.406 libopencv-4.6.0_1
-libopencv_shape.so.406 libopencv-4.6.0_1
-libopencv_stitching.so.406 libopencv-4.6.0_1
-libopencv_photo.so.406 libopencv-4.6.0_1
-libopencv_video.so.406 libopencv-4.6.0_1
-libopencv_calib3d.so.406 libopencv-4.6.0_1
-libopencv_features2d.so.406 libopencv-4.6.0_1
-libopencv_flann.so.406 libopencv-4.6.0_1
-libopencv_highgui.so.406 libopencv-4.6.0_1
-libopencv_videoio.so.406 libopencv-4.6.0_1
-libopencv_imgcodecs.so.406 libopencv-4.6.0_1
-libopencv_imgproc.so.406 libopencv-4.6.0_1
-libopencv_core.so.406 libopencv-4.6.0_1
-libopencv_superres.so.406 libopencv-4.6.0_1
-libopencv_videostab.so.406 libopencv-4.6.0_1
-libopencv_gapi.so.406 libopencv-4.6.0_1
-libopencv_xobjdetect.so.406 libopencv-4.6.0_1
-libopencv_datasets.so.406 libopencv-4.6.0_1
-libopencv_dnn_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn_superres.so.406 libopencv-4.6.0_1
-libopencv_dpm.so.406 libopencv-4.6.0_1
-libopencv_phase_unwrapping.so.406 libopencv-4.6.0_1
-libopencv_stereo.so.406 libopencv-4.6.0_1
-libopencv_rapid.so.406 libopencv-4.6.0_1
-libopencv_intensity_transform.so.406 libopencv-4.6.0_1
-libopencv_alphamat.so.406 libopencv-4.6.0_1
-libopencv_barcode.so.406 libopencv-4.6.0_1
-libopencv_mcc.so.406 libopencv-4.6.0_1
+libopencv_quality.so.407 libopencv-4.7.0_1
+libopencv_reg.so.407 libopencv-4.7.0_1
+libopencv_surface_matching.so.407 libopencv-4.7.0_1
+libopencv_xphoto.so.407 libopencv-4.7.0_1
+libopencv_freetype.so.407 libopencv-4.7.0_1
+libopencv_fuzzy.so.407 libopencv-4.7.0_1
+libopencv_hfs.so.407 libopencv-4.7.0_1
+libopencv_img_hash.so.407 libopencv-4.7.0_1
+libopencv_line_descriptor.so.407 libopencv-4.7.0_1
+libopencv_saliency.so.407 libopencv-4.7.0_1
+libopencv_structured_light.so.407 libopencv-4.7.0_1
+libopencv_aruco.so.407 libopencv-4.7.0_1
+libopencv_bgsegm.so.407 libopencv-4.7.0_1
+libopencv_bioinspired.so.407 libopencv-4.7.0_1
+libopencv_ccalib.so.407 libopencv-4.7.0_1
+libopencv_face.so.407 libopencv-4.7.0_1
+libopencv_tracking.so.407 libopencv-4.7.0_1
+libopencv_xfeatures2d.so.407 libopencv-4.7.0_1
+libopencv_optflow.so.407 libopencv-4.7.0_1
+libopencv_ximgproc.so.407 libopencv-4.7.0_1
+libopencv_plot.so.407 libopencv-4.7.0_1
+libopencv_text.so.407 libopencv-4.7.0_1
+libopencv_ml.so.407 libopencv-4.7.0_1
+libopencv_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn.so.407 libopencv-4.7.0_1
+libopencv_shape.so.407 libopencv-4.7.0_1
+libopencv_stitching.so.407 libopencv-4.7.0_1
+libopencv_photo.so.407 libopencv-4.7.0_1
+libopencv_video.so.407 libopencv-4.7.0_1
+libopencv_calib3d.so.407 libopencv-4.7.0_1
+libopencv_features2d.so.407 libopencv-4.7.0_1
+libopencv_flann.so.407 libopencv-4.7.0_1
+libopencv_highgui.so.407 libopencv-4.7.0_1
+libopencv_videoio.so.407 libopencv-4.7.0_1
+libopencv_imgcodecs.so.407 libopencv-4.7.0_1
+libopencv_imgproc.so.407 libopencv-4.7.0_1
+libopencv_core.so.407 libopencv-4.7.0_1
+libopencv_superres.so.407 libopencv-4.7.0_1
+libopencv_videostab.so.407 libopencv-4.7.0_1
+libopencv_gapi.so.407 libopencv-4.7.0_1
+libopencv_xobjdetect.so.407 libopencv-4.7.0_1
+libopencv_datasets.so.407 libopencv-4.7.0_1
+libopencv_dnn_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn_superres.so.407 libopencv-4.7.0_1
+libopencv_dpm.so.407 libopencv-4.7.0_1
+libopencv_phase_unwrapping.so.407 libopencv-4.7.0_1
+libopencv_stereo.so.407 libopencv-4.7.0_1
+libopencv_rapid.so.407 libopencv-4.7.0_1
+libopencv_intensity_transform.so.407 libopencv-4.7.0_1
+libopencv_alphamat.so.407 libopencv-4.7.0_1
+libopencv_barcode.so.407 libopencv-4.7.0_1
+libopencv_mcc.so.407 libopencv-4.7.0_1
 libuniconf.so.4.6 wvstreams-4.6.1_20
 libwvbase.so.4.6 wvstreams-4.6.1_20
 libwvutils.so.4.6 wvstreams-4.6.1_20
diff --git a/srcpkgs/opencv/template b/srcpkgs/opencv/template
index aea4bfc3a265c..ce94de9424d18 100644
--- a/srcpkgs/opencv/template
+++ b/srcpkgs/opencv/template
@@ -1,7 +1,7 @@
 # Template file for 'opencv'
 pkgname=opencv
-version=4.6.0
-revision=6
+version=4.7.0
+revision=1
 create_wrksrc=yes
 build_wrksrc=${pkgname}-${version}
 build_style=cmake
@@ -24,8 +24,8 @@ homepage="https://opencv.org"
 changelog="https://github.com/opencv/opencv/wiki/ChangeLog"
 distfiles="https://github.com/opencv/opencv/archive/${version}.tar.gz
  https://github.com/opencv/opencv_contrib/archive/${version}.tar.gz>contrib.tar.gz"
-checksum="1ec1cba65f9f20fe5a41fda1586e01c70ea0c9a6d7b67c9e13edf0cfe2239277
- 1777d5fd2b59029cf537e5fd6f8aa68d707075822f90bde683fcde086f85f7a7"
+checksum="8df0079cdbe179748a18d44731af62a245a45ebf5085223dc03133954c662973
+ 42df840cf9055e59d0e22c249cfb19f04743e1bdad113d31b1573d3934d62584"
 patch_args="-Np1 -d ${build_wrksrc}"
 # tests hang indenfinitely, even with test data included
 make_check=no

From a5a0848e0ee981494821f235c59551a9a6226e74 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 006/112] actiona: revbump for opencv-4.7.0

---
 srcpkgs/actiona/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/actiona/template b/srcpkgs/actiona/template
index cf5f0b7a2ae61..0d899311e6df7 100644
--- a/srcpkgs/actiona/template
+++ b/srcpkgs/actiona/template
@@ -1,7 +1,7 @@
 # Template file for 'actiona'
 pkgname=actiona
 version=3.10.1
-revision=2
+revision=3
 build_style=qmake
 configure_args="PKGCONFIG_OPENCV=opencv4"
 hostmakedepends="pkg-config qt5-plugin-mysql qt5-qmake qt5-host-tools"

From ec01bea533a4780f69427846e2e6a48fff6714da Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 007/112] retroshare: revbump for opencv-4.7.0

---
 srcpkgs/retroshare/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroshare/template b/srcpkgs/retroshare/template
index bb17569277a7f..49e2c1cbe8a53 100644
--- a/srcpkgs/retroshare/template
+++ b/srcpkgs/retroshare/template
@@ -1,7 +1,7 @@
 # Template file for 'retroshare'
 pkgname=retroshare
 version=0.6.6
-revision=3
+revision=4
 build_style=qmake
 #XXX broadcast feature requires an ancient udp-discovery-cpp which either needs
 # to be fetched+patched (FTBFS) here or packaged :/

From 1b42ee2016867a1e32943229aa1c2b2347280102 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 008/112] waifu2x-converter-cpp: revbump for opencv-4.7.0

---
 srcpkgs/waifu2x-converter-cpp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waifu2x-converter-cpp/template b/srcpkgs/waifu2x-converter-cpp/template
index 361b8a23b9497..c5ac17eb54ea4 100644
--- a/srcpkgs/waifu2x-converter-cpp/template
+++ b/srcpkgs/waifu2x-converter-cpp/template
@@ -1,7 +1,7 @@
 # Template file for 'waifu2x-converter-cpp'
 pkgname=waifu2x-converter-cpp
 version=5.2.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DINSTALL_MODELS=ON"
 hostmakedepends="pkg-config"

From 205a1b23433bb5f6db7e2b940fd685a861d08329 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:38 -0400
Subject: [PATCH 009/112] vlc: revbump for ffmpeg4

---
 srcpkgs/vlc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vlc/template b/srcpkgs/vlc/template
index fa46c57cba2fa..434c40c67df93 100644
--- a/srcpkgs/vlc/template
+++ b/srcpkgs/vlc/template
@@ -25,7 +25,7 @@ lib32disabled=yes
 hostmakedepends="automake libtool pkg-config flex gettext libgcrypt-devel
  live555-devel gettext-devel $(vopt_if lua lua52) $(vopt_if chromecast protobuf)"
 makedepends="
- avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg-devel freefont-ttf
+ avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg4-devel freefont-ttf
  gnutls-devel jack-devel liba52-devel libass-devel libbluray-devel
  libcdio-devel libdca-devel libdvbpsi-devel libdvdnav-devel libmad-devel
  libmatroska-devel libmodplug-devel libmpcdec-devel libmpeg2-devel

From 931bedfb8e3c14f656d16052b15808135ab09ea4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:55 -0400
Subject: [PATCH 010/112] osg: revbump for ffmpeg4

---
 srcpkgs/osg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/osg/template b/srcpkgs/osg/template
index a9ebbd287933b..755793f7e11bf 100644
--- a/srcpkgs/osg/template
+++ b/srcpkgs/osg/template
@@ -8,7 +8,7 @@ build_helper="qemu"
 configure_args="-DLIB_POSTFIX="
 hostmakedepends="pkg-config xrandr"
 makedepends="MesaLib-devel gtkglext-devel libcurl-devel giflib-devel librsvg-devel
- jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg-devel xine-lib-devel
+ jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg4-devel xine-lib-devel
  SDL2-devel gst-plugins-base1-devel
  $(vopt_if openexr libopenexr-devel)
  $(vopt_if poppler poppler-glib-devel)

From 9ac9eef4af17b567f8042936126a5b3d24fa1d7e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:13 -0400
Subject: [PATCH 011/112] xine-lib: revbump for ffmpeg4

---
 srcpkgs/xine-lib/template | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/xine-lib/template b/srcpkgs/xine-lib/template
index 3be4d08eac77a..ed6194c17d11e 100644
--- a/srcpkgs/xine-lib/template
+++ b/srcpkgs/xine-lib/template
@@ -1,14 +1,14 @@
 # Template file for 'xine-lib'
 pkgname=xine-lib
-version=1.2.12
-revision=3
+version=1.2.13
+revision=1
 build_style=gnu-configure
 configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
  --disable-oss"
 hostmakedepends="automake gettext-devel libtool pkg-config perl"
 makedepends="
  zlib-devel alsa-lib-devel libxcb-devel libSM-devel libXext-devel libXv-devel
- libXvMC-devel liba52-devel libmad-devel ffmpeg-devel pulseaudio-devel
+ libXvMC-devel liba52-devel libmad-devel ffmpeg4-devel pulseaudio-devel
  jack-devel samba-devel libflac-devel libmodplug-devel libmpcdec-devel
  speex-devel libtheora-devel libvorbis-devel libdca-devel faad2-devel
  libcdio-devel libbluray-devel aalib-devel libcaca-devel libXinerama-devel
@@ -19,7 +19,7 @@ license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="http://www.xine-project.org"
 changelog="https://sourceforge.net/projects/xine/files/xine-lib/${version}/README.txt/view"
 distfiles="${SOURCEFORGE_SITE}/xine/${pkgname}-${version}.tar.xz"
-checksum=d606270468e1540c2a89c0d7f5fdf11e17ecc0c2698cc0bcb1065ff26abee098
+checksum=5f10d6d718a4a51c17ed1b32b031d4f9b80b061e8276535b2be31e5ac4b75e6f
 
 case "$XBPS_TARGET_MACHINE" in
 	i686-musl)

From bf338ca390968b2875513004de6a011c8125b7b9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 012/112] attract: revbump for ffmpeg4

---
 srcpkgs/attract/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/attract/template b/srcpkgs/attract/template
index 24017d2bacc24..e760bf0d18aec 100644
--- a/srcpkgs/attract/template
+++ b/srcpkgs/attract/template
@@ -6,7 +6,7 @@ build_style=gnu-makefile
 make_build_args="VERBOSE=1"
 make_use_env=yes
 hostmakedepends="pkg-config"
-makedepends="SFML-devel ffmpeg-devel fontconfig-devel glu-devel libarchive-devel
+makedepends="SFML-devel ffmpeg4-devel fontconfig-devel glu-devel libarchive-devel
  libcurl-devel libjpeg-turbo-devel xine-lib rapidjson libXrandr-devel"
 depends="git"
 short_desc="Attract-Mode is a graphical frontend for emulators"

From d2b2ee943f71a219807b3d7848dc853b72f31b44 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 013/112] aubio: revbump for ffmpeg6

---
 srcpkgs/aubio/patches/ffmpeg5.patch | 25 +++++++++++++++++++++++++
 srcpkgs/aubio/template              |  2 +-
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/aubio/patches/ffmpeg5.patch

diff --git a/srcpkgs/aubio/patches/ffmpeg5.patch b/srcpkgs/aubio/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..aace41a6e6d9a
--- /dev/null
+++ b/srcpkgs/aubio/patches/ffmpeg5.patch
@@ -0,0 +1,25 @@
+From 8a05420e5dd8c7b8b2447f82dc919765876511b3 Mon Sep 17 00:00:00 2001
+From: Paul Brossier <piem@piem.org>
+Date: Tue, 25 Jan 2022 18:30:27 +0100
+Subject: [PATCH] [source_avcodec] define FF_API_LAVF_AVCTX for libavcodec >
+ 59, thx @berolinux (closes gh-353)
+
+---
+ src/io/source_avcodec.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/io/source_avcodec.c b/src/io/source_avcodec.c
+index e0ae93b5..1421bd9a 100644
+--- a/src/io/source_avcodec.c
++++ b/src/io/source_avcodec.c
+@@ -68,6 +68,10 @@
+ #define AUBIO_AVCODEC_MAX_BUFFER_SIZE AV_INPUT_BUFFER_MIN_SIZE
+ #endif
+ 
++#if LIBAVCODEC_VERSION_MAJOR >= 59
++#define FF_API_LAVF_AVCTX 1
++#endif
++
+ struct _aubio_source_avcodec_t {
+   uint_t hop_size;
+   uint_t samplerate;
diff --git a/srcpkgs/aubio/template b/srcpkgs/aubio/template
index ad1c4b2569917..7d875cc02541a 100644
--- a/srcpkgs/aubio/template
+++ b/srcpkgs/aubio/template
@@ -1,7 +1,7 @@
 # Template file for 'aubio'
 pkgname=aubio
 version=0.4.9
-revision=1
+revision=2
 build_style=waf3
 # XXX lash, pure and swig support.
 hostmakedepends="pkg-config txt2man"

From 1166cf6663d687d1de20e748c403fae80014f8de Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 014/112] audacious-plugins: revbump for ffmpeg6

---
 .../audacious-plugins/patches/ffmpeg5.patch   | 43 +++++++++++++++++++
 srcpkgs/audacious-plugins/template            |  2 +-
 2 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/audacious-plugins/patches/ffmpeg5.patch

diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg5.patch b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..4e5e34099d71c
--- /dev/null
+++ b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
@@ -0,0 +1,43 @@
+commit 298aa371c56c2f52c25a33d9bdec4918b11cebdc
+Author: tibequadorian <tibequadorian@posteo.de>
+Date:   Sat Mar 19 18:40:12 2022 +0100
+
+    audacious-plugins: rebuild against ffmpeg-5.0
+
+diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+new file mode 100644
+index 0000000000..617c11215b
+--- /dev/null
++++ b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+@@ -0,0 +1,31 @@
++From f60beb400eeb1e4778bbfd738bc4a4ccef3de539 Mon Sep 17 00:00:00 2001
++From: John Lindgren <john@jlindgren.net>
++Date: Sat, 5 Mar 2022 12:05:34 -0500
++Subject: [PATCH] Fix build with FFmpeg 5.0
++
++---
++ src/ffaudio/ffaudio-core.cc | 4 ++--
++ 1 file changed, 2 insertions(+), 2 deletions(-)
++
++diff --git a/src/ffaudio/ffaudio-core.cc b/src/ffaudio/ffaudio-core.cc
++index 16dc63e3a..a2b95fd6c 100644
++--- a/src/ffaudio/ffaudio-core.cc
+++++ b/src/ffaudio/ffaudio-core.cc
++@@ -274,7 +274,7 @@ static AVInputFormat * get_format_by_content (const char * name, VFSFile & file)
++         AVProbeData d = {name, buf, filled};
++         score = target;
++ 
++-        f = av_probe_input_format2 (& d, true, & score);
+++        f = (AVInputFormat *) av_probe_input_format2 (& d, true, & score);
++         if (f)
++             break;
++ 
++@@ -347,7 +347,7 @@ static bool find_codec (AVFormatContext * c, CodecInfo * cinfo)
++ #endif
++         if (stream && stream->codecpar && stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
++         {
++-            AVCodec * codec = avcodec_find_decoder (stream->codecpar->codec_id);
+++            AVCodec * codec = (AVCodec *) avcodec_find_decoder (stream->codecpar->codec_id);
++ 
++             if (codec)
++             {
diff --git a/srcpkgs/audacious-plugins/template b/srcpkgs/audacious-plugins/template
index 05e53a9adf78f..4b1968e03de78 100644
--- a/srcpkgs/audacious-plugins/template
+++ b/srcpkgs/audacious-plugins/template
@@ -2,7 +2,7 @@
 #Keep in sync with audacious!
 pkgname=audacious-plugins
 version=4.3.1
-revision=3
+revision=4
 build_style=meson
 configure_args="$(vopt_bool gtk3 gtk) $(vopt_bool gtk3)
  $(vopt_bool qt) $(vopt_bool qt qt6)"

From dd7d40c4cbde6ca87c9f12cd16537aea24ed17a6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 015/112] audacity: revbump for ffmpeg6

---
 srcpkgs/audacity/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/audacity/template b/srcpkgs/audacity/template
index 7b838119ab261..84b49305edcef 100644
--- a/srcpkgs/audacity/template
+++ b/srcpkgs/audacity/template
@@ -1,7 +1,7 @@
 # Template file for 'audacity'
 pkgname=audacity
 version=3.4.2
-revision=1
+revision=2
 build_style=cmake
 build_helper="cmake-wxWidgets-gtk3 qemu"
 configure_args="-Daudacity_use_ffmpeg=loaded -Daudacity_lib_preference=system

From d96359a1670023e7bd4073ccd0a20b6bb70f0b56 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 016/112] avidemux: revbump for ffmpeg6

---
 srcpkgs/avidemux/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/avidemux/template b/srcpkgs/avidemux/template
index 253a0243e2259..557285982d2b8 100644
--- a/srcpkgs/avidemux/template
+++ b/srcpkgs/avidemux/template
@@ -1,7 +1,7 @@
 # Template file for 'avidemux'
 pkgname=avidemux
 version=2.8.0
-revision=2
+revision=3
 # Can't be compiled for aarch64, arm* or mips*
 archs="x86_64* i686*"
 hostmakedepends="cmake pkg-config qt5-host-tools qt5-devel tar yasm"

From f832374f98dc91a2b5cb053afc6f82e667de5c63 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 017/112] blender: revbump for ffmpeg6

---
 srcpkgs/blender/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index 1dc61ec9d29d8..be35fac744876 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -9,8 +9,8 @@ configure_args="-DWITH_INSTALL_PORTABLE=OFF -DWITH_PYTHON_INSTALL=OFF
  -DWITH_JACK=ON -DWITH_CODEC_FFMPEG=ON -DWITH_CODEC_SNDFILE=ON -DWITH_OPENMP=ON
  -DWITH_FFTW3=ON -DWITH_MOD_OCEANSIM=ON -DWITH_CYCLES_EMBREE=OFF -DWITH_OPENCOLORIO=ON
  -DWITH_IMAGE_OPENEXR=ON -DWITH_IMAGE_OPENJPEG=ON -DWITH_OPENSUBDIV=ON
- -DWITH_OPENCOLLADA=ON -DWITH_SYSTEM_GLEW=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
- -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_LIBDECOR=ON
+ -DWITH_OPENCOLLADA=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
+ -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_WAYLAND_LIBDECOR=ON
  -DWITH_BUILDINFO=OFF -DPYTHON_VERSION=${py3_ver} -DPYTHON_LIBPATH=/usr/lib
  -DPYTHON_LIBRARY=python${py3_ver}${py3_abiver} -DPYTHON_INCLUDE_DIRS=/${py3_inc}
  -DWITH_SYSTEM_LZO=ON -DWITH_SYSTEM_EIGEN3=ON -DWITH_SYSTEM_FREETYPE=ON"

From 0ff764868804d340d6337fe4c665dd744e75ebb0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 018/112] cantata: revbump for ffmpeg6

---
 srcpkgs/cantata/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cantata/template b/srcpkgs/cantata/template
index 4b417d80d5c2d..8a90aaa4c07a2 100644
--- a/srcpkgs/cantata/template
+++ b/srcpkgs/cantata/template
@@ -1,7 +1,7 @@
 # Template file for 'cantata'
 pkgname=cantata
 version=2.5.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools qt5-tools"
 makedepends="qt5-devel qt5-tools-devel qt5-svg-devel qt5-xmlpatterns-devel

From 4f23abe86d19f096ed796e09090ac8e8ad5b213f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 019/112] ccextractor: revbump for ffmpeg4

---
 srcpkgs/ccextractor/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ccextractor/template b/srcpkgs/ccextractor/template
index 84059ffd02398..3ca8ec45d6989 100644
--- a/srcpkgs/ccextractor/template
+++ b/srcpkgs/ccextractor/template
@@ -6,7 +6,7 @@ build_wrksrc="linux"
 build_style=gnu-configure
 configure_args="--enable-ocr --enable-hardsubx"
 hostmakedepends="automake pkg-config"
-makedepends="leptonica-devel tesseract-ocr-devel ffmpeg-devel"
+makedepends="leptonica-devel tesseract-ocr-devel ffmpeg4-devel"
 short_desc="Extract subtitles from video streams"
 maintainer="newbluemoon <blaumolch@mailbox.org>"
 license="GPL-2.0-or-later"

From 734e9f9b70e0b8afa36e0443d2dedcd9f988892f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 020/112] chromaprint: revbump for ffmpeg6

---
 srcpkgs/chromaprint/patches/ffmpeg5.patch | 569 ++++++++++++++++++++++
 srcpkgs/chromaprint/template              |   2 +-
 2 files changed, 570 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromaprint/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromaprint/patches/ffmpeg5.patch b/srcpkgs/chromaprint/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..a9fd307a23c8a
--- /dev/null
+++ b/srcpkgs/chromaprint/patches/ffmpeg5.patch
@@ -0,0 +1,569 @@
+From 8ccad6937177b1b92e40ab8f4447ea27bac009a7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= <lalinsky@gmail.com>
+Date: Fri, 4 Nov 2022 21:47:38 +0100
+Subject: [PATCH] Use FFmpeg 5.x (#120)
+
+* Use FFmpeg 5.1.2 for CI builds
+
+* Build on Ubuntu 20.04
+
+* Upgrade code to FFmpeg 5.x APIs
+
+* Only set FFmpeg include dirs if building tools
+
+* No longer needed
+
+* Use ubuntu 20.04
+---
+ .github/workflows/build.yml                   |   6 +-
+ CMakeLists.txt                                |  16 --
+ package/build.sh                              |   4 +-
+ src/audio/ffmpeg_audio_processor.h            |   2 -
+ src/audio/ffmpeg_audio_processor_avresample.h |  72 -------
+ src/audio/ffmpeg_audio_processor_swresample.h |  18 +-
+ src/audio/ffmpeg_audio_reader.h               | 197 +++++++++---------
+ tests/CMakeLists.txt                          |   6 +
+ 8 files changed, 122 insertions(+), 199 deletions(-)
+ delete mode 100644 src/audio/ffmpeg_audio_processor_avresample.h
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index f8d6a32..4da2405 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -84,9 +84,6 @@ find_package(FFmpeg)
+ if(FFMPEG_LIBRARIES)
+ 	cmake_push_check_state(RESET)
+ 	set(CMAKE_REQUIRED_LIBRARIES ${FFMPEG_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -lm)
+-	check_function_exists(av_packet_unref HAVE_AV_PACKET_UNREF)
+-	check_function_exists(av_frame_alloc HAVE_AV_FRAME_ALLOC)
+-	check_function_exists(av_frame_free HAVE_AV_FRAME_FREE)
+ 	cmake_pop_check_state()
+ endif()
+
+@@ -163,14 +160,11 @@ message(STATUS "Using ${FFT_LIB} for FFT calculations")
+ if(NOT AUDIO_PROCESSOR_LIB)
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+ 		set(AUDIO_PROCESSOR_LIB "swresample")
+-	elseif(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(AUDIO_PROCESSOR_LIB "avresample")
+ 	endif()
+ endif()
+
+ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE OFF)
+ 		set(USE_SWRESAMPLE ON)
+ 		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBSWRESAMPLE_LIBRARIES})
+ 		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBSWRESAMPLE_INCLUDE_DIRS})
+@@ -178,16 +172,6 @@ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+ 	endif()
+ 	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+-elseif(AUDIO_PROCESSOR_LIB STREQUAL "avresample")
+-	if(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE ON)
+-		set(USE_SWRESAMPLE OFF)
+-		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBAVRESAMPLE_LIBRARIES})
+-		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBAVRESAMPLE_INCLUDE_DIRS})
+-	else()
+-		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+-	endif()
+-	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+ else()
+ 	message(STATUS "Building without audio conversion support, please install FFmpeg with libswresample")
+ endif()
+diff --git a/package/build.sh b/package/build.sh
+index da631ae..b41d36e 100755
+--- a/package/build.sh
++++ b/package/build.sh
+@@ -7,8 +7,8 @@ set -eux
+
+ BASE_DIR=$(cd $(dirname $0)/.. && pwd)
+
+-FFMPEG_VERSION=4.4.1
+-FFMPEG_BUILD_TAG=v4.4.1-1
++FFMPEG_VERSION=5.1.2
++FFMPEG_BUILD_TAG=v${FFMPEG_VERSION}-1
+
+ TMP_BUILD_DIR=$BASE_DIR/$(mktemp -d build.XXXXXXXX)
+ trap 'rm -rf $TMP_BUILD_DIR' EXIT
+diff --git a/src/audio/ffmpeg_audio_processor.h b/src/audio/ffmpeg_audio_processor.h
+index 7628fc7..39f4f6d 100644
+--- a/src/audio/ffmpeg_audio_processor.h
++++ b/src/audio/ffmpeg_audio_processor.h
+@@ -10,8 +10,6 @@
+
+ #if defined(USE_SWRESAMPLE)
+ #include "audio/ffmpeg_audio_processor_swresample.h"
+-#elif defined(USE_AVRESAMPLE)
+-#include "audio/ffmpeg_audio_processor_avresample.h"
+ #else
+ #error "no audio processing library"
+ #endif
+diff --git a/src/audio/ffmpeg_audio_processor_avresample.h b/src/audio/ffmpeg_audio_processor_avresample.h
+deleted file mode 100644
+index bd85f92..0000000
+--- a/src/audio/ffmpeg_audio_processor_avresample.h
++++ /dev/null
+@@ -1,72 +0,0 @@
+-// Copyright (C) 2016  Lukas Lalinsky
+-// Distributed under the MIT license, see the LICENSE file for details.
+-
+-#ifndef CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-#define CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-
+-extern "C" {
+-#include <libavresample/avresample.h>
+-}
+-
+-namespace chromaprint {
+-
+-class FFmpegAudioProcessor {
+-public:
+-	FFmpegAudioProcessor() {
+-		m_resample_ctx = avresample_alloc_context();
+-	}
+-
+-	~FFmpegAudioProcessor() {
+-		avresample_free(&m_resample_ctx);
+-	}
+-
+-	void SetCompatibleMode() {
+-		av_opt_set_int(m_resample_ctx, "filter_size", 16, 0);
+-		av_opt_set_int(m_resample_ctx, "phase_shift", 8, 0);
+-		av_opt_set_int(m_resample_ctx, "linear_interp", 1, 0);
+-		av_opt_set_double(m_resample_ctx, "cutoff", 0.8, 0);
+-	}
+-
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "in_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_rate", sample_rate, 0);
+-	}
+-
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "out_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_rate, 0);
+-	}
+-
+-	int Init() {
+-		return avresample_open(m_resample_ctx);
+-	}
+-
+-	int Convert(uint8_t **out, int out_count, const uint8_t **in, int in_count) {
+-		return avresample_convert(m_resample_ctx, out, 0, out_count, (uint8_t **) in, 0, in_count);
+-	}
+-
+-	int Flush(uint8_t **out, int out_count) {
+-		return avresample_read(m_resample_ctx, out, out_count);
+-	}
+-
+-private:
+-	AVAudioResampleContext *m_resample_ctx = nullptr;
+-};
+-
+-}; // namespace chromaprint
+-
+-#endif
+diff --git a/src/audio/ffmpeg_audio_processor_swresample.h b/src/audio/ffmpeg_audio_processor_swresample.h
+index b86266b..b1d4bea 100644
+--- a/src/audio/ffmpeg_audio_processor_swresample.h
++++ b/src/audio/ffmpeg_audio_processor_swresample.h
+@@ -28,30 +28,28 @@ public:
+ 		av_opt_set_double(m_swr_ctx, "cutoff", 0.8, 0);
+ 	}
+
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "icl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "ich", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetInputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "in_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "isf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "in_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "isr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "in_sample_rate", sample_rate, 0);
+ 	}
+
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "ocl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "och", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetOutputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "out_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "osf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "out_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "osr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "out_sample_rate", sample_rate, 0);
+ 	}
+
+ 	int Init() {
+diff --git a/src/audio/ffmpeg_audio_reader.h b/src/audio/ffmpeg_audio_reader.h
+index 5550164..1c6b346 100644
+--- a/src/audio/ffmpeg_audio_reader.h
++++ b/src/audio/ffmpeg_audio_reader.h
+@@ -62,7 +62,7 @@ public:
+ 	bool Read(const int16_t **data, size_t *size);
+
+ 	bool IsOpen() const { return m_opened; }
+-	bool IsFinished() const { return m_finished && !m_got_frame; }
++	bool IsFinished() const { return !m_has_more_packets && !m_has_more_frames; }
+
+ 	std::string GetError() const { return m_error; }
+ 	int GetErrorCode() const { return m_error_code; }
+@@ -74,20 +74,19 @@ private:
+ 	uint8_t *m_convert_buffer[1] = { nullptr };
+ 	int m_convert_buffer_nb_samples = 0;
+
+-	AVInputFormat *m_input_fmt = nullptr;
++	const AVInputFormat *m_input_fmt = nullptr;
+ 	AVDictionary *m_input_opts = nullptr;
+
+ 	AVFormatContext *m_format_ctx = nullptr;
+ 	AVCodecContext *m_codec_ctx = nullptr;
+-	AVFrame *m_frame = nullptr;
+ 	int m_stream_index = -1;
+ 	std::string m_error;
+ 	int m_error_code = 0;
+-	bool m_finished = false;
+ 	bool m_opened = false;
+-	int m_got_frame = 0;
+-	AVPacket m_packet;
+-	AVPacket m_packet0;
++	bool m_has_more_packets = true;
++	bool m_has_more_frames = true;
++	AVPacket *m_packet = nullptr;
++	AVFrame *m_frame = nullptr;
+
+ 	int m_output_sample_rate = 0;
+ 	int m_output_channels = 0;
+@@ -98,19 +97,12 @@ private:
+
+ inline FFmpegAudioReader::FFmpegAudioReader() {
+ 	av_log_set_level(AV_LOG_QUIET);
+-
+-	av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
+ }
+
+ inline FFmpegAudioReader::~FFmpegAudioReader() {
+ 	Close();
+ 	av_dict_free(&m_input_opts);
+ 	av_freep(&m_convert_buffer[0]);
+-	av_packet_unref(&m_packet0);
+ }
+
+ inline bool FFmpegAudioReader::SetInputFormat(const char *name) {
+@@ -135,11 +127,10 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ 	Close();
+
+-    av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
++	m_packet = av_packet_alloc();
++	if (!m_packet) {
++		return false;
++	}
+
+ 	ret = avformat_open_input(&m_format_ctx, file_name.c_str(), m_input_fmt, &m_input_opts);
+ 	if (ret < 0) {
+@@ -153,26 +144,31 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		return false;
+ 	}
+
+-	AVCodec *codec;
++	const AVCodec *codec;
+ 	ret = av_find_best_stream(m_format_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &codec, 0);
+ 	if (ret < 0) {
+ 		SetError("Could not find any audio stream in the file", ret);
+ 		return false;
+ 	}
+ 	m_stream_index = ret;
++	auto stream = m_format_ctx->streams[m_stream_index];
+
+-	m_codec_ctx = m_format_ctx->streams[m_stream_index]->codec;
++	m_codec_ctx = avcodec_alloc_context3(codec);
+ 	m_codec_ctx->request_sample_fmt = AV_SAMPLE_FMT_S16;
+
++	ret = avcodec_parameters_to_context(m_codec_ctx, stream->codecpar);
++	if (ret < 0) {
++		SetError("Could not copy the stream parameters", ret);
++		return false;
++	}
++
+ 	ret = avcodec_open2(m_codec_ctx, codec, nullptr);
+ 	if (ret < 0) {
+ 		SetError("Could not open the codec", ret);
+ 		return false;
+ 	}
+
+-	if (!m_codec_ctx->channel_layout) {
+-		m_codec_ctx->channel_layout = av_get_default_channel_layout(m_codec_ctx->channels);
+-	}
++	av_dump_format(m_format_ctx, 0, "foo", 0);
+
+ 	m_frame = av_frame_alloc();
+ 	if (!m_frame) {
+@@ -183,19 +179,23 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		m_output_sample_rate = m_codec_ctx->sample_rate;
+ 	}
+
+-	if (!m_output_channels) {
+-		m_output_channels = m_codec_ctx->channels;
++	AVChannelLayout output_channel_layout;
++	if (m_output_channels) {
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
++	} else {
++		m_output_channels = m_codec_ctx->ch_layout.nb_channels;
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
+ 	}
+
+-	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
++	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->ch_layout.nb_channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
+ 		m_converter.reset(new FFmpegAudioProcessor());
+ 		m_converter->SetCompatibleMode();
+ 		m_converter->SetInputSampleFormat(m_codec_ctx->sample_fmt);
+ 		m_converter->SetInputSampleRate(m_codec_ctx->sample_rate);
+-		m_converter->SetInputChannelLayout(m_codec_ctx->channel_layout);
++		m_converter->SetInputChannelLayout(&(m_codec_ctx->ch_layout));
+ 		m_converter->SetOutputSampleFormat(AV_SAMPLE_FMT_S16);
+ 		m_converter->SetOutputSampleRate(m_output_sample_rate);
+-		m_converter->SetOutputChannelLayout(av_get_default_channel_layout(m_output_channels));
++		m_converter->SetOutputChannelLayout(&output_channel_layout);
+ 		auto ret = m_converter->Init();
+ 		if (ret != 0) {
+ 			SetError("Could not create an audio converter instance", ret);
+@@ -203,10 +203,11 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		}
+ 	}
+
++	av_channel_layout_uninit(&output_channel_layout);
++
+ 	m_opened = true;
+-	m_finished = false;
+-	m_got_frame = 0;
+-	m_nb_packets = 0;
++	m_has_more_packets = true;
++	m_has_more_frames = true;
+ 	m_decode_error = 0;
+
+ 	return true;
+@@ -214,6 +215,7 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ inline void FFmpegAudioReader::Close() {
+ 	av_frame_free(&m_frame);
++	av_packet_free(&m_packet);
+
+ 	m_stream_index = -1;
+
+@@ -252,91 +254,98 @@ inline bool FFmpegAudioReader::Read(const int16_t **data, size_t *size) {
+ 		return false;
+ 	}
+
++	*data = nullptr;
++	*size = 0;
++
+ 	int ret;
++	bool needs_packet = false;
+ 	while (true) {
+-		while (m_packet.size <= 0) {
+-			av_packet_unref(&m_packet0);
+-			av_init_packet(&m_packet);
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			ret = av_read_frame(m_format_ctx, &m_packet);
++		while (needs_packet && m_packet->size == 0) {
++			ret = av_read_frame(m_format_ctx, m_packet);
+ 			if (ret < 0) {
+ 				if (ret == AVERROR_EOF) {
+-					m_finished = true;
++					needs_packet = false;
++					m_has_more_packets = false;
+ 					break;
+-				} else {
++				}
++				SetError("Error reading from the audio source", ret);
++				return false;
++			}
++			if (m_packet->stream_index == m_stream_index) {
++				needs_packet = false;
++			} else {
++				av_packet_unref(m_packet);
++			}
++		}
++
++		if (m_packet->size != 0) {
++			ret = avcodec_send_packet(m_codec_ctx, m_packet);
++			if (ret < 0) {
++				if (ret != AVERROR(EAGAIN)) {
+ 					SetError("Error reading from the audio source", ret);
+ 					return false;
+ 				}
+-			}
+-			m_packet0 = m_packet;
+-			if (m_packet.stream_index != m_stream_index) {
+-				m_packet.data = nullptr;
+-				m_packet.size = 0;
+ 			} else {
+-				m_nb_packets++;
++				av_packet_unref(m_packet);
+ 			}
+ 		}
+
+-		ret = avcodec_decode_audio4(m_codec_ctx, m_frame, &m_got_frame, &m_packet);
++		ret = avcodec_receive_frame(m_codec_ctx, m_frame);
+ 		if (ret < 0) {
+-			if (m_decode_error) {
+-				SetError("Error decoding audio frame", m_decode_error);
+-				return false;
++			if (ret == AVERROR_EOF) {
++				m_has_more_frames = false;
++			} else if (ret == AVERROR(EAGAIN)) {
++				if (m_has_more_packets) {
++					needs_packet = true;
++					continue;
++				} else {
++					m_has_more_frames = false;
++				}
+ 			}
+-			m_decode_error = ret;
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			continue;
++			SetError("Error decoding the audio source", ret);
++			return false;
+ 		}
+
+-		break;
+-	}
+-
+-	m_decode_error = 0;
+-
+-	const int decoded = std::min(ret, m_packet.size);
+-	m_packet.data += decoded;
+-	m_packet.size -= decoded;
+-
+-	if (m_got_frame) {
+-		if (m_converter) {
+-			if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
+-				int linsize;
+-				av_freep(&m_convert_buffer[0]);
+-				m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
+-				ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
+-				if (ret < 0) {
+-					SetError("Couldn't allocate audio converter buffer", ret);
++		if (m_frame->nb_samples > 0) {
++			if (m_converter) {
++				if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
++					int linsize;
++					av_freep(&m_convert_buffer[0]);
++					m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
++					ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->ch_layout.nb_channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
++					if (ret < 0) {
++						SetError("Couldn't allocate audio converter buffer", ret);
++						return false;
++					}
++				}
++				auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
++				if (nb_samples < 0) {
++					SetError("Couldn't convert audio", ret);
+ 					return false;
+ 				}
+-			}
+-			auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			}
+-			*data = (const int16_t *) m_convert_buffer[0];
+-			*size = nb_samples;
+-		} else {
+-			*data = (const int16_t *) m_frame->data[0];
+-			*size = m_frame->nb_samples;
+-		}
+-	} else {
+-		if (m_finished && m_converter) {
+-			auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			} else if (nb_samples > 0) {
+-				m_got_frame = 1;
+ 				*data = (const int16_t *) m_convert_buffer[0];
+ 				*size = nb_samples;
++			} else {
++				*data = (const int16_t *) m_frame->data[0];
++				*size = m_frame->nb_samples;
++			}
++		} else {
++			if (m_converter) {
++				if (IsFinished()) {
++					auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
++					if (nb_samples < 0) {
++						SetError("Couldn't convert audio", ret);
++						return false;
++					} else if (nb_samples > 0) {
++						*data = (const int16_t *) m_convert_buffer[0];
++						*size = nb_samples;
++					}
++				}
+ 			}
+ 		}
+-	}
+
+-	return true;
++		return true;
++	}
+ }
+
+ inline void FFmpegAudioReader::SetError(const char *message, int errnum) {
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index a2b517b..123e643 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -38,6 +38,12 @@ set(SRCS
+
+ if(BUILD_TOOLS)
+ 	set(SRCS ${SRCS} ../src/audio/ffmpeg_audio_reader_test.cpp)
++    include_directories(
++        ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}
++        ${AUDIO_PROCESSOR_INCLUDE_DIRS}
++    )
+ 	link_libraries(fpcalc_libs)
+ endif()
+
+-- 
+2.38.1
+
+
diff --git a/srcpkgs/chromaprint/template b/srcpkgs/chromaprint/template
index 7ef7838949f3a..1f7bbc70a22c8 100644
--- a/srcpkgs/chromaprint/template
+++ b/srcpkgs/chromaprint/template
@@ -1,7 +1,7 @@
 # Template file for 'chromaprint'
 pkgname=chromaprint
 version=1.5.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DBUILD_TOOLS=ON"
 make_check_target="check"

From 3f1834b2e74416005fd65bf1f9c71e721d24c27c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 021/112] chromium: revbump for ffmpeg6

---
 .../patches/chromium-119-ffmpeg-4.4.patch     | 20 --------
 srcpkgs/chromium/patches/ffmpeg5.patch        | 47 +++++++++++++++++++
 srcpkgs/chromium/template                     |  2 +-
 3 files changed, 48 insertions(+), 21 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch
 create mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch b/srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch
deleted file mode 100644
index 04d04b166ba37..0000000000000
--- a/srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch
+++ /dev/null
@@ -1,20 +0,0 @@
---- a/media/filters/ffmpeg_demuxer.cc.orig
-+++ b/media/filters/ffmpeg_demuxer.cc
-@@ -390,7 +390,7 @@
- 
-   scoped_refptr<DecoderBuffer> buffer;
- 
--    size_t side_data_size = 0;
-+    int side_data_size = 0;
-     uint8_t* side_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
- 
-@@ -453,7 +453,7 @@
-                                        packet->size - data_offset);
-     }
- 
--    size_t skip_samples_size = 0;
-+    int skip_samples_size = 0;
-     const uint32_t* skip_samples_ptr =
-         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
-             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..24e2da38e34ca
--- /dev/null
+++ b/srcpkgs/chromium/patches/ffmpeg5.patch
@@ -0,0 +1,47 @@
+--- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
++++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
+@@ -92,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+-  if (stream->start_time != kNoFFmpegTimestamp)
++  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -1597,7 +1585,7 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+@@ -1618,7 +1606,7 @@
+     if (stream->type() != DemuxerStream::VIDEO)
+       continue;
+ 
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+ 
+     if (!stream->IsEnabled())
diff --git a/srcpkgs/chromium/template b/srcpkgs/chromium/template
index 5613fa3813822..cd386c8a84ae6 100644
--- a/srcpkgs/chromium/template
+++ b/srcpkgs/chromium/template
@@ -2,7 +2,7 @@
 pkgname=chromium
 # See https://chromiumdash.appspot.com/releases?platform=Linux for the latest version
 version=120.0.6099.129
-revision=1
+revision=2
 archs="i686* x86_64* aarch64* armv7l*"
 hostmakedepends="
  $(vopt_if clang "clang lld llvm15")

From 643075e546f1d711d060796c9be975d2bd672388 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 022/112] cmus: revbump for ffmpeg6

---
 srcpkgs/chromium/patches/ffmpeg5.patch | 47 --------------------------
 srcpkgs/cmus/patches/ffmpeg6.patch     | 12 +++++++
 srcpkgs/cmus/template                  |  2 +-
 3 files changed, 13 insertions(+), 48 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch
 create mode 100644 srcpkgs/cmus/patches/ffmpeg6.patch

diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
deleted file mode 100644
index 24e2da38e34ca..0000000000000
--- a/srcpkgs/chromium/patches/ffmpeg5.patch
+++ /dev/null
@@ -1,47 +0,0 @@
---- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
-+++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
-@@ -92,24 +92,12 @@
- 
- static base::TimeDelta ExtractStartTime(AVStream* stream) {
-   // The default start time is zero.
--  base::TimeDelta start_time;
-+  base::TimeDelta start_time = kNoTimestamp;
- 
-   // First try to use  the |start_time| value as is.
--  if (stream->start_time != kNoFFmpegTimestamp)
-+  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
-     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
- 
--  // Next try to use the first DTS value, for codecs where we know PTS == DTS
--  // (excludes all H26x codecs). The start time must be returned in PTS.
--  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
--      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
--      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
--      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
--    const base::TimeDelta first_pts =
--        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
--    if (first_pts < start_time)
--      start_time = first_pts;
--  }
--
-   return start_time;
- }
- 
-@@ -1597,7 +1585,7 @@
-   for (const auto& stream : streams_) {
-     if (!stream || stream->IsEnabled() != enabled)
-       continue;
--    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
-+    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
-       continue;
-     if (!lowest_start_time_stream ||
-         stream->start_time() < lowest_start_time_stream->start_time()) {
-@@ -1618,7 +1606,7 @@
-     if (stream->type() != DemuxerStream::VIDEO)
-       continue;
- 
--    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
-+    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
-       continue;
- 
-     if (!stream->IsEnabled())
diff --git a/srcpkgs/cmus/patches/ffmpeg6.patch b/srcpkgs/cmus/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..ffa95ab811101
--- /dev/null
+++ b/srcpkgs/cmus/patches/ffmpeg6.patch
@@ -0,0 +1,12 @@
+--- a/ip/ffmpeg.c
++++ b/ip/ffmpeg.c
+@@ -202,9 +202,6 @@ static int ffmpeg_open(struct input_plugin_data *ip_data)
+ 			break;
+ 		}
+ 
+-		if (codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+-			cc->flags |= AV_CODEC_FLAG_TRUNCATED;
+-
+ 		if (avcodec_open2(cc, codec, NULL) < 0) {
+ 			d_print("could not open codec: %d, %s\n", cc->codec_id, avcodec_get_name(cc->codec_id));
+ 			err = -IP_ERROR_UNSUPPORTED_FILE_TYPE;
diff --git a/srcpkgs/cmus/template b/srcpkgs/cmus/template
index 0d1436744f1b2..a6e4b4fa86cb8 100644
--- a/srcpkgs/cmus/template
+++ b/srcpkgs/cmus/template
@@ -1,7 +1,7 @@
 # Template file for 'cmus'
 pkgname=cmus
 version=2.10.0
-revision=3
+revision=4
 build_style=configure
 configure_args="prefix=/usr LD=$CC"
 hostmakedepends="pkg-config"

From 9c3842ac89565f21ca4be47154e015b3e86f811c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 023/112] cyanrip: revbump for ffmpeg6

---
 srcpkgs/cyanrip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cyanrip/template b/srcpkgs/cyanrip/template
index 9796e3461601a..5db30e020d17e 100644
--- a/srcpkgs/cyanrip/template
+++ b/srcpkgs/cyanrip/template
@@ -1,7 +1,7 @@
 # Template file for 'cyanrip'
 pkgname=cyanrip
 version=0.9.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config"
 makedepends="ffmpeg-devel libcdio-devel libcdio-paranoia-devel libcurl-devel libmusicbrainz5-devel"

From 42f5ab027cf5eb540c5521efb42f9152f0b7ab0e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 024/112] deadbeef: revbump for ffmpeg4

---
 srcpkgs/deadbeef/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/deadbeef/template b/srcpkgs/deadbeef/template
index f5f4bf24b8cb6..7b47e615cd48e 100644
--- a/srcpkgs/deadbeef/template
+++ b/srcpkgs/deadbeef/template
@@ -1,14 +1,14 @@
 # Template file for 'deadbeef'
 pkgname=deadbeef
 version=1.8.8
-revision=3
+revision=4
 create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-oss --disable-lfm --disable-notify --disable-gtk2"
 hostmakedepends="automake libtool gettext gettext-devel intltool pkg-config
  yasm clang glib-devel"
 makedepends="
- alsa-lib-devel dbus-devel faad2-devel ffmpeg-devel gtk+3-devel imlib2-devel
+ alsa-lib-devel dbus-devel faad2-devel ffmpeg4-devel gtk+3-devel imlib2-devel
  jansson-devel libcddb-devel libcdio-devel libcurl-devel libflac-devel
  libmad-devel libpng-devel libsamplerate-devel libsndfile-devel libvorbis-devel
  libzip-devel mpg123-devel opusfile-devel pulseaudio-devel wavpack-devel"

From 9c9650a89ac78bf693abd3db65e8c858277c7506 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 025/112] droidcam-obs-plugin: revbump for ffmpeg6

---
 srcpkgs/droidcam-obs-plugin/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam-obs-plugin/template b/srcpkgs/droidcam-obs-plugin/template
index fc9c9bf6b9d54..fb0480754df4d 100644
--- a/srcpkgs/droidcam-obs-plugin/template
+++ b/srcpkgs/droidcam-obs-plugin/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam-obs-plugin'
 pkgname=droidcam-obs-plugin
 version=2.0.1
-revision=1
+revision=2
 build_style=gnu-makefile
 make_use_env=yes
 make_build_args="ALLOW_STATIC=no"

From fd1b04415bcfed25d8bbe777e8d0909b890fd70a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 026/112] droidcam: revbump for ffmpeg6

---
 srcpkgs/droidcam/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam/template b/srcpkgs/droidcam/template
index 1c3f1b8b1fc67..32a9220b79a4d 100644
--- a/srcpkgs/droidcam/template
+++ b/srcpkgs/droidcam/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam'
 pkgname=droidcam
 version=1.8.2
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="USBMUXD=-lusbmuxd-2.0 JPEG=-lturbojpeg"
 hostmakedepends="pkg-config"

From b46878135136b2211ad6474773b215ff3a629f72 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 027/112] ffmpegthumbnailer: revbump for ffmpeg6

---
 .../ffmpegthumbnailer/patches/ffmpeg6.patch   | 202 ++++++++++++++++++
 srcpkgs/ffmpegthumbnailer/template            |   6 +-
 2 files changed, 205 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch

diff --git a/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..363ff35a28419
--- /dev/null
+++ b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
@@ -0,0 +1,202 @@
+--- a/libffmpegthumbnailer/moviedecoder.cpp	2017-11-21 14:06:57.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.cpp	2023-05-05 13:14:47.946560668 -0400
+@@ -41,11 +41,6 @@
+ namespace ffmpegthumbnailer
+ {
+ 
+-struct SilenceLogLevel
+-{
+-    SilenceLogLevel() { av_log_set_level(AV_LOG_QUIET); }
+-};
+-
+ MovieDecoder::MovieDecoder(AVFormatContext* pavContext)
+ : m_VideoStream(-1)
+ , m_pFormatContext(pavContext)
+@@ -70,8 +65,6 @@
+ 
+ void MovieDecoder::initialize(const string& filename, bool preferEmbeddedMetadata)
+ {
+-    av_register_all();
+-    avcodec_register_all();
+     avformat_network_init();
+ 
+     string inputFile = filename == "-" ? "pipe:" : filename;
+@@ -97,8 +90,7 @@
+ {
+     if (m_pVideoCodecContext)
+     {
+-        avcodec_close(m_pVideoCodecContext);
+-        m_pVideoCodecContext = nullptr;
++        avcodec_free_context(&m_pVideoCodecContext);
+     }
+ 
+     if ((!m_FormatContextWasGiven) && m_pFormatContext)
+@@ -152,10 +144,10 @@
+     for (unsigned int i = 0; i < m_pFormatContext->nb_streams; ++i)
+     {
+         AVStream *stream = m_pFormatContext->streams[i];
+-        auto ctx = m_pFormatContext->streams[i]->codec;
+-        if (ctx->codec_type == AVMEDIA_TYPE_VIDEO)
++        auto par = m_pFormatContext->streams[i]->codecpar;
++        if (par->codec_type == AVMEDIA_TYPE_VIDEO)
+         {
+-            if (!preferEmbeddedMetadata || !isStillImageCodec(ctx->codec_id))
++            if (!preferEmbeddedMetadata || !isStillImageCodec(par->codec_id))
+             {
+                 videoStreams.push_back(i);
+                 continue;
+@@ -203,8 +195,7 @@
+     }
+ 
+     m_pVideoStream = m_pFormatContext->streams[m_VideoStream];
+-    m_pVideoCodecContext = m_pVideoStream->codec;
+-    m_pVideoCodec = avcodec_find_decoder(m_pVideoCodecContext->codec_id);
++    m_pVideoCodec = avcodec_find_decoder(m_pVideoStream->codecpar->codec_id);
+ 
+     if (m_pVideoCodec == nullptr)
+     {
+@@ -214,6 +205,20 @@
+         throw logic_error("Video Codec not found");
+     }
+ 
++    m_pVideoCodecContext = avcodec_alloc_context3(m_pVideoCodec);
++
++    if (m_pVideoCodecContext == nullptr)
++    {
++        destroy();
++        throw logic_error("Could not allocate video codec context");
++    }
++
++    if (avcodec_parameters_to_context(m_pVideoCodecContext, m_pVideoStream->codecpar) < 0)
++    {
++        destroy();
++        throw logic_error("Could not configure video codec context");
++    }
++
+     m_pVideoCodecContext->workaround_bugs = 1;
+ 
+     if (avcodec_open2(m_pVideoCodecContext, m_pVideoCodec, nullptr) < 0)
+@@ -386,13 +391,6 @@
+ 
+ void MovieDecoder::initializeFilterGraph(const AVRational& timeBase, const std::string& size, bool maintainAspectRatio)
+ {
+-    static const AVPixelFormat pixelFormats[] = { AV_PIX_FMT_RGB24, AV_PIX_FMT_NONE };
+-
+-    auto del = [] (AVBufferSinkParams* p) { av_freep(p); };
+-    std::unique_ptr<AVBufferSinkParams, decltype(del)> buffersinkParams(av_buffersink_params_alloc(), del);
+-
+-    avfilter_register_all();
+-
+     m_pFilterGraph = avfilter_graph_alloc();
+     assert(m_pFilterGraph);
+ 
+@@ -404,10 +402,8 @@
+ 
+     checkRc(avfilter_graph_create_filter(&m_pFilterSource, avfilter_get_by_name("buffer"), "thumb_buffer", ss.str().c_str(), nullptr, m_pFilterGraph),
+             "Failed to create filter source");
+-    buffersinkParams->pixel_fmts = pixelFormats;
+-    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, buffersinkParams.get(), m_pFilterGraph),
++    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, nullptr, m_pFilterGraph),
+             "Failed to create filter sink");
+-    buffersinkParams.release();
+ 
+     AVFilterContext* yadifFilter = nullptr;
+     if (m_pFrame->interlaced_frame != 0)
+@@ -500,15 +496,15 @@
+     }
+ 
+     checkRc(av_seek_frame(m_pFormatContext, -1, timestamp, 0), "Seeking in video failed");
+-    avcodec_flush_buffers(m_pFormatContext->streams[m_VideoStream]->codec);
++    avcodec_flush_buffers(m_pVideoCodecContext);
+ 
+     int keyFrameAttempts = 0;
+-    bool gotFrame = 0;
++    bool gotFrame;
+ 
+     do
+     {
+         int count = 0;
+-        gotFrame = 0;
++        gotFrame = false;
+ 
+         while (!gotFrame && count < 20)
+         {
+@@ -552,17 +548,33 @@
+         return false;
+     }
+ 
+-    av_frame_unref(m_pFrame);
+-
+-    int frameFinished;
++    int rc = avcodec_send_packet(m_pVideoCodecContext, m_pPacket);
++    if(rc == AVERROR(EAGAIN))
++    {
++        rc = 0;
++    }
+ 
+-    int bytesDecoded = avcodec_decode_video2(m_pVideoCodecContext, m_pFrame, &frameFinished, m_pPacket);
+-    if (bytesDecoded < 0)
++    if(rc == AVERROR_EOF)
++    {
++        return false;
++    }
++    else if(rc < 0)
+     {
+-        throw logic_error("Failed to decode video frame: bytesDecoded < 0");
++        throw logic_error("Failed to decode video frame: avcodec_send_packet() < 0");
+     }
+ 
+-    return frameFinished > 0;
++    rc = avcodec_receive_frame(m_pVideoCodecContext, m_pFrame);
++    switch(rc)
++    {
++        case 0:
++            return true;
++
++        case AVERROR(EAGAIN):
++            return false;
++
++        default:
++            throw logic_error("Failed to decode video frame: avcodec_receive_frame() < 0");
++    }
+ }
+ 
+ bool MovieDecoder::getVideoPacket()
+@@ -570,8 +582,6 @@
+     bool framesAvailable = true;
+     bool frameDecoded = false;
+ 
+-    int attempts = 0;
+-
+     if (m_pPacket)
+     {
+         av_packet_unref(m_pPacket);
+@@ -580,6 +590,7 @@
+ 
+     m_pPacket = new AVPacket();
+ 
++
+     while (framesAvailable && !frameDecoded)
+     {
+         framesAvailable = av_read_frame(m_pFormatContext, m_pPacket) >= 0;
+@@ -644,7 +655,7 @@
+ 
+ int32_t MovieDecoder::getStreamRotation()
+ {
+-    int32_t* matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
++    auto matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
+     if (matrix)
+     {
+         auto angle = lround(av_display_rotation_get(matrix));
+
+--- a/libffmpegthumbnailer/moviedecoder.h	2017-11-12 04:23:38.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.h	2023-05-05 13:26:07.095529911 -0400
+@@ -78,7 +78,7 @@
+     int                     m_VideoStream;
+     AVFormatContext*        m_pFormatContext;
+     AVCodecContext*         m_pVideoCodecContext;
+-    AVCodec*                m_pVideoCodec;
++    const AVCodec*          m_pVideoCodec;
+     AVFilterGraph*          m_pFilterGraph;
+     AVFilterContext*        m_pFilterSource;
+     AVFilterContext*        m_pFilterSink;
diff --git a/srcpkgs/ffmpegthumbnailer/template b/srcpkgs/ffmpegthumbnailer/template
index 039eea7622b39..35d546018d12a 100644
--- a/srcpkgs/ffmpegthumbnailer/template
+++ b/srcpkgs/ffmpegthumbnailer/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbnailer'
 pkgname=ffmpegthumbnailer
 version=2.2.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libpng-devel libjpeg-turbo-devel ffmpeg-devel"
@@ -9,8 +9,8 @@ depends="ffmpeg"
 short_desc="Lightweight video thumbnailer"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
-homepage="https://github.com/dirkvdb/${pkgname}"
-distfiles="${homepage}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
+homepage="https://github.com/dirkvdb"
+distfiles="${homepage}/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
 checksum=1cb24059c38223f657b300c84dd80491b7040d4b69471c4fea69be862bc99b5b
 
 post_install() {

From f484e8bcc90c82e974622e2fda2d86e4f64668fa Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 028/112] ffmpegthumbs: revbump for ffmpeg6

---
 srcpkgs/ffmpegthumbs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ffmpegthumbs/template b/srcpkgs/ffmpegthumbs/template
index 5f0b9414dadaf..11b88193528f4 100644
--- a/srcpkgs/ffmpegthumbs/template
+++ b/srcpkgs/ffmpegthumbs/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbs'
 pkgname=ffmpegthumbs
 version=22.12.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules kcoreaddons kconfig-devel
  pkg-config qt5-host-tools qt5-qmake gettext"

From 01710b79bce43871e845dbfef2eda09487123e87 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 029/112] ffms2: revbump for ffmpeg6

---
 srcpkgs/ffms2/patches/ffmpeg5.patch | 424 ++++++++++++++++++++++++++++
 srcpkgs/ffms2/template              |   2 +-
 2 files changed, 425 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ffms2/patches/ffmpeg5.patch

diff --git a/srcpkgs/ffms2/patches/ffmpeg5.patch b/srcpkgs/ffms2/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..1479fabcafcb4
--- /dev/null
+++ b/srcpkgs/ffms2/patches/ffmpeg5.patch
@@ -0,0 +1,424 @@
+From 45673149e9a2f5586855ad472e3059084eaa36b1 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:41:21 +0100
+Subject: [PATCH] Use auto for AVCodec
+
+The geniuses over at FFmpeg decided to constify this API, so old
+versions of the library will return AVCodec *, while new versions
+of the libary will return const AVCodec *, which, in C++, are not
+OK to convert between.
+
+Rather than use some macro hell in ffmscompat.h, we can work around
+this by using auto.
+
+Gross.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 2 +-
+ src/core/indexing.cpp    | 6 +++---
+ src/core/videosource.cpp | 2 +-
+ 3 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index e4ce97c..ac09666 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -469,7 +469,7 @@ void FFMS_AudioSource::OpenFile() {
+ 
+     LAVFOpenFile(SourceFile.c_str(), FormatContext, TrackNumber);
+ 
+-    AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
++    auto *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
+     if (Codec == nullptr)
+         throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+             "Audio codec not found");
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index e547c5a..59fb4e8 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -384,7 +384,7 @@ FFMS_TrackType FFMS_Indexer::GetTrackType(int Track) {
+ }
+ 
+ const char *FFMS_Indexer::GetTrackCodec(int Track) {
+-    AVCodec *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
++    auto *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
+     return codec ? codec->name : nullptr;
+ }
+ 
+@@ -402,7 +402,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             UseDTS);
+ 
+         if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            AVCodec *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (!VideoCodec) {
+                 FormatContext->streams[i]->discard = AVDISCARD_ALL;
+                 IndexMask.erase(i);
+@@ -433,7 +433,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 IndexMask.insert(i);
+             }
+         } else if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+-            AVCodec *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (AudioCodec == nullptr)
+                 throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_UNSUPPORTED,
+                     "Audio codec not found");
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index b889970..8956c22 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -171,7 +171,7 @@ FFMS_VideoSource::FFMS_VideoSource(const char *SourceFile, FFMS_Index &Index, in
+ 
+         LAVFOpenFile(SourceFile, FormatContext, VideoTrack);
+ 
+-        AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
++        auto *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
+         if (Codec == nullptr)
+             throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+                 "Video codec not found");
+-- 
+2.40.0
+
+From 96cbf38ea9381829a1314f432a2c60495dcefaad Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:12:41 +0100
+Subject: [PATCH] all: Update AVPacket API usage
+
+AVPackets must all be on the heap now, since it is no longer
+part of the libav* ABI.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 16 ++++++----
+ src/core/indexing.cpp    | 63 ++++++++++++++++++++++------------------
+ src/core/indexing.h      |  4 +--
+ src/core/utils.cpp       |  6 ----
+ src/core/utils.h         |  1 -
+ src/core/videosource.cpp | 30 ++++++++++---------
+ 6 files changed, 64 insertions(+), 56 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index 37cf9ae..e4ce97c 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -285,10 +285,15 @@ FFMS_AudioSource::AudioBlock *FFMS_AudioSource::CacheBlock(CacheIterator &pos) {
+ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     CurrentFrame = &Frames[PacketNumber];
+ 
+-    AVPacket Packet;
+-    if (!ReadPacket(&Packet))
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++    if (!ReadPacket(Packet)) {
++        av_packet_free(&Packet);
+         throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_UNKNOWN,
+             "ReadPacket unexpectedly failed to read a packet");
++    }
+ 
+     // ReadPacket may have changed the packet number
+     CurrentFrame = &Frames[PacketNumber];
+@@ -297,8 +302,9 @@ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     int NumberOfSamples = 0;
+     AudioBlock *CachedBlock = nullptr;
+     
+-    int Ret = avcodec_send_packet(CodecContext, &Packet);
+-    av_packet_unref(&Packet);
++    int Ret = avcodec_send_packet(CodecContext, Packet);
++    av_packet_unref(Packet);
++    av_packet_free(&Packet);
+ 
+     av_frame_unref(DecodeFrame);
+     Ret = avcodec_receive_frame(CodecContext, DecodeFrame);
+@@ -513,8 +519,6 @@ void FFMS_AudioSource::Seek() {
+ }
+ 
+ bool FFMS_AudioSource::ReadPacket(AVPacket *Packet) {
+-    InitNullPacket(*Packet);
+-
+     while (av_read_frame(FormatContext, Packet) >= 0) {
+         if (Packet->stream_index == TrackNumber) {
+             // Required because not all audio packets, especially in ogg, have a pts. Use the previous valid packet's pts instead.
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index 23fb95b..e547c5a 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -320,7 +320,7 @@ void FFMS_Indexer::CheckAudioProperties(int Track, AVCodecContext *Context) {
+     }
+ }
+ 
+-void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict,
++void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict,
+                                     int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct) {
+     if (VideoContext.Parser) {
+         uint8_t *OB;
+@@ -330,8 +330,8 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+         av_parser_parse2(VideoContext.Parser,
+             VideoContext.CodecContext,
+             &OB, &OBSize,
+-            pkt.data, pkt.size,
+-            pkt.pts, pkt.dts, pkt.pos);
++            pkt->data, pkt->size,
++            pkt->pts, pkt->dts, pkt->pos);
+ 
+         // H.264 (PAFF) and HEVC may have one field per packet, so we need to track
+         // when we have a full or half frame available, and mark one of them as
+@@ -351,15 +351,15 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+ 
+         *RepeatPict = VideoContext.Parser->repeat_pict;
+         *FrameType = VideoContext.Parser->pict_type;
+-        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt.flags & AV_PKT_FLAG_DISCARD));
++        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt->flags & AV_PKT_FLAG_DISCARD));
+     } else {
+-        *Invisible = !!(pkt.flags & AV_PKT_FLAG_DISCARD);
++        *Invisible = !!(pkt->flags & AV_PKT_FLAG_DISCARD);
+     }
+ 
+     if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP8)
+-        ParseVP8(pkt.data[0], Invisible, FrameType);
++        ParseVP8(pkt->data[0], Invisible, FrameType);
+     else if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP9)
+-        ParseVP9(pkt.data[0], Invisible, FrameType);
++        ParseVP9(pkt->data[0], Invisible, FrameType);
+ }
+ 
+ void FFMS_Indexer::Free() {
+@@ -458,32 +458,36 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+         }
+     }
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
+     std::vector<int64_t> LastValidTS(FormatContext->nb_streams, AV_NOPTS_VALUE);
+ 
+     int64_t filesize = avio_size(FormatContext->pb);
+     enum AVPictureStructure LastPicStruct = AV_PICTURE_STRUCTURE_UNKNOWN;
+-    while (av_read_frame(FormatContext, &Packet) >= 0) {
++    while (av_read_frame(FormatContext, Packet) >= 0) {
+         // Update progress
+         // FormatContext->pb can apparently be NULL when opening images.
+         if (IC && FormatContext->pb) {
+-            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate))
++            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate)) {
++                av_packet_free(&Packet);
+                 throw FFMS_Exception(FFMS_ERROR_CANCELLED, FFMS_ERROR_USER,
+                     "Cancelled by user");
++            }
+         }
+-        if (!IndexMask.count(Packet.stream_index)) {
+-            av_packet_unref(&Packet);
++        if (!IndexMask.count(Packet->stream_index)) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+-        int Track = Packet.stream_index;
++        int Track = Packet->stream_index;
+         FFMS_Track &TrackInfo = (*TrackIndices)[Track];
+-        bool KeyFrame = !!(Packet.flags & AV_PKT_FLAG_KEY);
++        bool KeyFrame = !!(Packet->flags & AV_PKT_FLAG_KEY);
+         ReadTS(Packet, LastValidTS[Track], (*TrackIndices)[Track].UseDTS);
+ 
+         if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            int64_t PTS = TrackInfo.UseDTS ? Packet.dts : Packet.pts;
++            int64_t PTS = TrackInfo.UseDTS ? Packet->dts : Packet->pts;
+             if (PTS == AV_NOPTS_VALUE) {
+                 // VPx alt-refs are output as packets which lack timestmps or durations, since
+                 // they are invisible. Currently, the timestamp mangling code in libavformat
+@@ -495,9 +499,11 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 // FFMS2 currently sorts packets by PTS, which will break decoding, otherwise.
+                 bool HasAltRefs = (FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP8 ||
+                                    FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP9);
+-                if (Packet.duration == 0 && !HasAltRefs)
++                if (Packet->duration == 0 && !HasAltRefs) {
++                    av_packet_free(&Packet);
+                     throw FFMS_Exception(FFMS_ERROR_INDEXING, FFMS_ERROR_PARSER,
+                         "Invalid packet pts, dts, and duration");
++                }
+ 
+                 if (TrackInfo.empty())
+                     PTS = 0;
+@@ -513,7 +519,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             ParseVideoPacket(AVContexts[Track], Packet, &RepeatPict, &FrameType, &Invisible, &LastPicStruct);
+ 
+             TrackInfo.AddVideoFrame(PTS, RepeatPict, KeyFrame,
+-                FrameType, Packet.pos, Invisible);
++                FrameType, Packet->pos, Invisible);
+         } else if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+             // For video seeking timestamps are used only if all packets have
+             // timestamps, while for audio they're used if any have timestamps,
+@@ -522,28 +528,29 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 TrackInfo.HasTS = true;
+ 
+             int64_t StartSample = AVContexts[Track].CurrentSample;
+-            uint32_t SampleCount = IndexAudioPacket(Track, &Packet, AVContexts[Track], *TrackIndices);
++            uint32_t SampleCount = IndexAudioPacket(Track, Packet, AVContexts[Track], *TrackIndices);
+             TrackInfo.SampleRate = AVContexts[Track].CodecContext->sample_rate;
+ 
+             TrackInfo.AddAudioFrame(LastValidTS[Track],
+-                StartSample, SampleCount, KeyFrame, Packet.pos, Packet.flags & AV_PKT_FLAG_DISCARD);
++                StartSample, SampleCount, KeyFrame, Packet->pos, Packet->flags & AV_PKT_FLAG_DISCARD);
+         }
+ 
+-        if (!(Packet.flags & AV_PKT_FLAG_DISCARD))
+-            TrackInfo.LastDuration = Packet.duration;
++        if (!(Packet->flags & AV_PKT_FLAG_DISCARD))
++            TrackInfo.LastDuration = Packet->duration;
+ 
+-        av_packet_unref(&Packet);
++        av_packet_unref(Packet);
+     }
++    av_packet_free(&Packet);
+ 
+     TrackIndices->Finalize(AVContexts, FormatContext->iformat->name);
+     return TrackIndices.release();
+ }
+ 
+-void FFMS_Indexer::ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS) {
+-    if (!UseDTS && Packet.pts != AV_NOPTS_VALUE)
+-        TS = Packet.pts;
++void FFMS_Indexer::ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS) {
++    if (!UseDTS && Packet->pts != AV_NOPTS_VALUE)
++        TS = Packet->pts;
+     if (TS == AV_NOPTS_VALUE)
+         UseDTS = true;
+-    if (UseDTS && Packet.dts != AV_NOPTS_VALUE)
+-        TS = Packet.dts;
++    if (UseDTS && Packet->dts != AV_NOPTS_VALUE)
++        TS = Packet->dts;
+ }
+diff --git a/src/core/indexing.h b/src/core/indexing.h
+index 3cfc3c3..5c06868 100644
+--- a/src/core/indexing.h
++++ b/src/core/indexing.h
+@@ -80,10 +80,10 @@ private:
+     int64_t Filesize;
+     uint8_t Digest[20];
+ 
+-    void ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS);
++    void ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS);
+     void CheckAudioProperties(int Track, AVCodecContext *Context);
+     uint32_t IndexAudioPacket(int Track, AVPacket *Packet, SharedAVContext &Context, FFMS_Index &TrackIndices);
+-    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
++    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
+     void Free();
+ public:
+     FFMS_Indexer(const char *Filename);
+diff --git a/src/core/utils.cpp b/src/core/utils.cpp
+index ce67533..8a2e997 100644
+--- a/src/core/utils.cpp
++++ b/src/core/utils.cpp
+@@ -62,12 +62,6 @@ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo) {
+     }
+ }
+ 
+-void InitNullPacket(AVPacket &pkt) {
+-    av_init_packet(&pkt);
+-    pkt.data = nullptr;
+-    pkt.size = 0;
+-}
+-
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames) {
+     AP.SampleFormat = static_cast<FFMS_SampleFormat>(av_get_packed_sample_fmt(CTX->sample_fmt));
+     AP.BitsPerSample = av_get_bytes_per_sample(CTX->sample_fmt) * 8;
+diff --git a/src/core/utils.h b/src/core/utils.h
+index 9819dc7..003ab79 100644
+--- a/src/core/utils.h
++++ b/src/core/utils.h
+@@ -58,7 +58,6 @@ std::unique_ptr<T> make_unique(Args&&... args) {
+ }
+ 
+ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo);
+-void InitNullPacket(AVPacket &pkt);
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames);
+ 
+ void LAVFOpenFile(const char *SourceFile, AVFormatContext *&FormatContext, int Track);
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index 06bd161..b889970 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -673,30 +673,34 @@ void FFMS_VideoSource::DecodeNextFrame(int64_t &AStartTime, int64_t &Pos) {
+     if (HasPendingDelayedFrames())
+         return;
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
+-
+-    while (ReadFrame(&Packet) >= 0) {
+-        if (Packet.stream_index != VideoTrack) {
+-            av_packet_unref(&Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++
++    while (ReadFrame(Packet) >= 0) {
++        if (Packet->stream_index != VideoTrack) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+         if (AStartTime < 0)
+-            AStartTime = Frames.UseDTS ? Packet.dts : Packet.pts;
++            AStartTime = Frames.UseDTS ? Packet->dts : Packet->pts;
+ 
+         if (Pos < 0)
+-            Pos = Packet.pos;
++            Pos = Packet->pos;
+ 
+-        bool FrameFinished = DecodePacket(&Packet);
+-        av_packet_unref(&Packet);
+-        if (FrameFinished)
++        bool FrameFinished = DecodePacket(Packet);
++        av_packet_unref(Packet);
++        if (FrameFinished) {
++            av_packet_free(&Packet);
+             return;
++        }
+     }
+ 
+     // Flush final frames
+-    InitNullPacket(Packet);
+-    DecodePacket(&Packet);
++    DecodePacket(Packet);
++    av_packet_free(&Packet);
+ }
+ 
+ bool FFMS_VideoSource::SeekTo(int n, int SeekOffset) {
+-- 
+2.40.0
+
+From bf9e03e9e08534c024e5a744a6437c4aac160201 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:20:47 +0100
+Subject: [PATCH 2/3] configure: Remove deprecated API use
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ configure.ac | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index b35ef80bc..d19714d0f 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -102,10 +102,10 @@ CFLAGS="$_CFLAGS $FFMPEG_CFLAGS"
+
+ AC_DEFUN([TEST_FFMPEG],
+          [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+-            #include <libavcodec/avcodec.h>
++            #include <libavformat/avformat.h>
+             #include <libswscale/swscale.h>
+             ]],[[
+-                avcodec_register_all();
++                avformat_network_init();
+                 swscale_version();
+             ]])], [eval $1=yes], [eval $1=no])
+         ])
+
diff --git a/srcpkgs/ffms2/template b/srcpkgs/ffms2/template
index 365f64d10cbab..1641ecf43be5b 100644
--- a/srcpkgs/ffms2/template
+++ b/srcpkgs/ffms2/template
@@ -1,7 +1,7 @@
 # Template file for 'ffms2'
 pkgname=ffms2
 version=2.40
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-shared --disable-static"
 hostmakedepends="pkg-config autoconf automake libtool"

From 153b99cbaeb2c4cf26736754bbac13eb34e04e9a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 030/112] freerdp: revbump for ffmpeg6

---
 .../freerdp/patches/ffmpeg6_aa2cb9aa.patch    | 42 +++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100644 srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch

diff --git a/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
new file mode 100644
index 0000000000000..a4324da3a8822
--- /dev/null
+++ b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
@@ -0,0 +1,42 @@
+From aa2cb9aa5ff5562433598ba168a466e0752bca0e Mon Sep 17 00:00:00 2001
+From: akallabeth <akallabeth@posteo.net>
+Date: Tue, 14 Feb 2023 07:48:54 +0100
+Subject: [PATCH] Fixed #8686: Update h264 to use new FFMPEG API
+
+---
+ channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c | 2 ++
+ libfreerdp/codec/h264_ffmpeg.c            | 2 ++
+ 2 files changed, 4 insertions(+)
+
+diff --git a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+index 339462d865f..beea80b7a1e 100644
+--- a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
++++ b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+@@ -239,8 +239,10 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYP
+ 		}
+ 	}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 	if (mdecoder->codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		mdecoder->codec_context->flags |= AV_CODEC_FLAG_TRUNCATED;
++#endif
+ 
+ 	return TRUE;
+ }
+diff --git a/libfreerdp/codec/h264_ffmpeg.c b/libfreerdp/codec/h264_ffmpeg.c
+index 8a23db2473c..896a333019b 100644
+--- a/libfreerdp/codec/h264_ffmpeg.c
++++ b/libfreerdp/codec/h264_ffmpeg.c
+@@ -615,10 +615,12 @@ static BOOL libavcodec_init(H264_CONTEXT* h264)
+ 			goto EXCEPTION;
+ 		}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 		if (sys->codecDecoder->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		{
+ 			sys->codecDecoderContext->flags |= AV_CODEC_FLAG_TRUNCATED;
+ 		}
++#endif
+ 
+ #ifdef WITH_VAAPI
+ 

From ccc124632b30bc148bbb9b174aba4bbc4df31c07 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 031/112] gerbera: revbump for ffmpeg6

---
 srcpkgs/gerbera/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gerbera/template b/srcpkgs/gerbera/template
index ae14f35c767c0..2dc0ac0ce03b5 100644
--- a/srcpkgs/gerbera/template
+++ b/srcpkgs/gerbera/template
@@ -1,7 +1,7 @@
 # Template file for 'gerbera'
 pkgname=gerbera
 version=1.12.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_SYSTEMD=0 -DWITH_AVCODEC=1"
 hostmakedepends="pkg-config"

From d867f6e977837924da062e1fb89ad7633566db61 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 032/112] goldendict: revbump for ffmpeg6

---
 srcpkgs/goldendict/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/goldendict/template b/srcpkgs/goldendict/template
index f4a05759f693d..97f44347b03a6 100644
--- a/srcpkgs/goldendict/template
+++ b/srcpkgs/goldendict/template
@@ -1,7 +1,7 @@
 # Template file for 'goldendict'
 pkgname=goldendict
 version=1.5.0
-revision=1
+revision=2
 build_style=qmake
 configure_args="CONFIG+=zim_support goldendict.pro"
 hostmakedepends="qt5-qmake pkg-config qt5-host-tools"
@@ -10,7 +10,7 @@ makedepends="tiff-devel qt5-devel libvorbis-devel zlib-devel
  qt5-webkit-devel lzo-devel bzip2-devel libao-devel qt5-svg-devel
  libeb-devel qt5-x11extras-devel ffmpeg-devel liblzma-devel
  qt5-multimedia-devel"
-short_desc="A feature-rich dictionary lookup program"
+short_desc="Feature-rich dictionary lookup program"
 maintainer="John <me@johnnynator.dev>"
 license="GPL-3.0-or-later"
 homepage="http://goldendict.org/"

From 8a3eebaa29073c62136071f1097b8314cb2bd3f9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 033/112] gst-libav: revbump for ffmpeg6

---
 srcpkgs/gst-libav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index 78afeee4aefb2..f892eb2063564 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.22.7
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"

From ae790d17fa127772635d329deb1fca0bca74d321 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 034/112] gst-rtsp-server: revbump for ffmpeg6

---
 srcpkgs/gst-rtsp-server/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index 2c280c84f1514..83a2949fd9482 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
 version=1.22.7
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="glib-devel gst-plugins-bad1-devel gobject-introspection

From cd2f9baa1e1bfa2d8ea7a12acac4441e3d9c4978 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 035/112] guvcview: update to 2.0.8.

---
 srcpkgs/guvcview/patches/fix-include.patch | 10 ++++++++++
 srcpkgs/guvcview/template                  |  7 +++----
 2 files changed, 13 insertions(+), 4 deletions(-)
 create mode 100644 srcpkgs/guvcview/patches/fix-include.patch

diff --git a/srcpkgs/guvcview/patches/fix-include.patch b/srcpkgs/guvcview/patches/fix-include.patch
new file mode 100644
index 0000000000000..503c2af3b78c1
--- /dev/null
+++ b/srcpkgs/guvcview/patches/fix-include.patch
@@ -0,0 +1,10 @@
+--- a/guvcview/guvcview.c
++++ b/guvcview/guvcview.c
+@@ -28,6 +28,7 @@
+ #include <sys/stat.h>
+ #include <sys/resource.h>
+ #include <errno.h>
++#include <locale.h>
+ 
+ #include "gview.h"
+ #include "gviewv4l2core.h"
diff --git a/srcpkgs/guvcview/template b/srcpkgs/guvcview/template
index d42fd38fa4ad1..86a7fd619612c 100644
--- a/srcpkgs/guvcview/template
+++ b/srcpkgs/guvcview/template
@@ -1,8 +1,7 @@
 # Template file for 'guvcview'
 pkgname=guvcview
-version=2.0.7
-revision=2
-create_wrksrc=yes
+version=2.0.8
+revision=1
 build_style=gnu-configure
 configure_args="--disable-static --disable-debian-menu"
 hostmakedepends="pkg-config intltool autoconf automake libtool glib-devel"
@@ -14,7 +13,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="http://guvcview.sourceforge.net/"
 distfiles="${SOURCEFORGE_SITE}/${pkgname}/${pkgname}-src-${version}.tar.bz2"
-checksum=f47d51fbd06e44eeaa1a82f4a153c927527c90d94514197a70b2956028cc8ad4
+checksum=a21f4e448286666cf27bafef5290cc953a0a1796b752e5bbe521266dc1230c81
 
 post_patch() {
 	sed '31a#include <locale.h>' -i  guvcview/guvcview.c

From 4f5cff00202189a0dadf5188f1041a8989bf3eb8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 036/112] handbrake: update to 1.6.1

---
 .../patches/fix-missing-x265-link-flag.patch    | 11 ++++++-----
 .../handbrake/patches/libhb-vpl-include.patch   | 15 +++++++++++++++
 srcpkgs/handbrake/template                      | 17 ++++++++++-------
 3 files changed, 31 insertions(+), 12 deletions(-)
 create mode 100644 srcpkgs/handbrake/patches/libhb-vpl-include.patch

diff --git a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
index 26db03867a0c8..d6bb2eda627a3 100644
--- a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
+++ b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
@@ -1,14 +1,15 @@
 --- a/gtk/configure.ac
 +++ b/gtk/configure.ac
 @@ -203,7 +203,7 @@
- 
+
  AM_CONDITIONAL([MINGW], [test "x$mingw_flag" = "xyes"])
- 
--HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg"
-+HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -ldl"
+
+-HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc"
++HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc -ldl"
  HB_CPPFLAGS="$HB_CPPFLAGS $HBINC"
- 
+
  PKG_CHECK_MODULES([x264], [x264], sys_x264=yes, sys_x264=no)
+
 --- a/test/module.defs
 +++ b/test/module.defs
 @@ -69,6 +69,9 @@
diff --git a/srcpkgs/handbrake/patches/libhb-vpl-include.patch b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
new file mode 100644
index 0000000000000..298f9f4ab28f2
--- /dev/null
+++ b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
@@ -0,0 +1,15 @@
+--- a/libhb/module.defs	2023-01-22 11:36:49.000000000 -0500
++++ b/libhb/module.defs	2023-04-03 22:37:52.395467010 -0400
+@@ -46,11 +46,7 @@
+ LIBHB.GCC.I += $(LIBHB.build/) $(CONTRIB.build/)include
+ 
+ ifeq (1,$(FEATURE.qsv))
+-    ifeq ($(HOST.system),freebsd))
+-        LIBHB.GCC.I += $(LOCALBASE)/include/vpl
+-    else
+-        LIBHB.GCC.I += $(CONTRIB.build/)include/vpl
+-    endif
++    LIBHB.GCC.I += /usr/include/vpl
+ endif
+ 
+ ifneq (,$(filter $(HOST.system),freebsd netbsd openbsd))
diff --git a/srcpkgs/handbrake/template b/srcpkgs/handbrake/template
index ca5e4571e49c3..c32cb1bfa31f4 100644
--- a/srcpkgs/handbrake/template
+++ b/srcpkgs/handbrake/template
@@ -1,10 +1,10 @@
 # Template file for 'handbrake'
 pkgname=handbrake
-version=1.5.1
+version=1.6.1
 revision=1
 build_style=gnu-configure
 configure_args="--force --disable-gtk-update-checks --disable-df-fetch --harden
- $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc)"
+ $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc) $(vopt_enable qsv)"
 make_build_args="-C ${XBPS_TRIPLET}"
 make_install_args="-C ${XBPS_TRIPLET}"
 hostmakedepends="automake cmake gettext-devel glib-devel intltool libtool m4 meson nasm pkg-config python3"
@@ -12,8 +12,11 @@ makedepends="bzip2-devel ffmpeg-devel gst-plugins-base1-devel gtk+3-devel
  jansson-devel lame-devel libass-devel libbluray-devel libdav1d-devel
  libdvdnav-devel libdvdread-devel libgudev-devel libnuma-devel
  libsamplerate-devel libtheora-devel libvorbis-devel libvpx-devel libxml2-devel
- opus-devel speex-devel x264-devel x265-devel zimg-devel
+ opus-devel speex-devel x264-devel x265-devel zimg-devel libsvt-av1-devel
  $(vopt_if fdk_aac fdk-aac-devel)
+ $(vopt_if qsv libva-devel)
+ $(vopt_if qsv libdrm-devel)
+ $(vopt_if qsv onevpl-devel)
  $(vopt_if nvenc nv-codec-headers)"
 depends="desktop-file-utils gst-plugins-good1 hicolor-icon-theme"
 short_desc="Multithreaded video transcoder"
@@ -21,15 +24,15 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-2.0-only"
 homepage="https://handbrake.fr/"
 distfiles="https://github.com/HandBrake/HandBrake/releases/download/${version}/HandBrake-${version}-source.tar.bz2"
-checksum=3999fe06d5309c819799a73a968a8ec3840e7840c2b64af8f5cdb7fd8c9430f0
+checksum=94ccfe03db917a91650000c510f7fd53f844da19f19ad4b4be1b8f6bc31a8d4c
 nocross=yes
 
-build_options="fdk_aac nvenc"
+build_options="fdk_aac nvenc qsv"
 
 case "$XBPS_TARGET_MACHINE" in
 	x86_64*|i686*)
 		CFLAGS="-msse"
-		build_options_default="nvenc"
+		build_options_default="nvenc qsv"
 		;;
 esac
 
@@ -37,7 +40,7 @@ pre_configure() {
 	# use system libraries, don't download them
 	rm -rf contrib/
 	for module in fdk-aac ffmpeg libbluray libdav1d libdvdnav libdvdread nvenc \
-		x265 zimg; do
+		x265 zimg svt-av1 libvpl; do
 	    vsed -i "/MODULES += contrib\/${module}/d" make/include/main.defs
 	done
 }

From 398b537899c8e9462b182644d0c5ffa4d9a746e6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 037/112] hedgewars: revbump for ffmpeg4

---
 srcpkgs/hedgewars/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/hedgewars/template b/srcpkgs/hedgewars/template
index 94b6db673b0c3..402ccfaaecbc2 100644
--- a/srcpkgs/hedgewars/template
+++ b/srcpkgs/hedgewars/template
@@ -1,13 +1,13 @@
 # Template file for 'hedgewars'
 pkgname=hedgewars
 version=1.0.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DNOSERVER=1 -DDATA_INSTALL_DIR=/usr/share/${pkgname}
  -DPHYSFS_SYSTEM=1 -DMINIMAL_FLAGS=1"
 make_cmd=make
 hostmakedepends="lua51 pkg-config qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
+makedepends="ffmpeg4-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
  SDL2_mixer-devel SDL2_net-devel SDL2_ttf-devel"
 depends="libfreeglut"
 short_desc="Funny turn-based artillery game, featuring fighting Hedgehogs!"

From 66d97c951b798a17ff8947bcbaebaa420f2f2aca Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 038/112] idjc: revbump for ffmpeg4

---
 srcpkgs/idjc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/idjc/template b/srcpkgs/idjc/template
index a9cde0665d55b..6f1d21c5781fd 100644
--- a/srcpkgs/idjc/template
+++ b/srcpkgs/idjc/template
@@ -5,7 +5,7 @@ revision=5
 build_style=gnu-configure
 hostmakedepends="pkg-config git python3 automake gettext-devel libtool"
 makedepends="libvorbis-devel libogg-devel jack-devel libsamplerate-devel
- libflac-devel libsndfile-devel mpg123-devel ffmpeg-devel speex-devel
+ libflac-devel libsndfile-devel mpg123-devel ffmpeg4-devel speex-devel
  glib-devel pixman-devel lame-devel python3-gobject-devel libshout-idjc-devel
  opus-devel twolame-devel python3-mutagen python3-devel"
 depends="python3-gobject python3-mutagen desktop-file-utils shared-mime-info python3-dbus jack"

From 8d5a53ff6b0577095acbd28a8768e8f624974804 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 039/112] kid3: revbump for ffmpeg6

---
 srcpkgs/kid3/patches/ffmpeg5.patch | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 srcpkgs/kid3/patches/ffmpeg5.patch

diff --git a/srcpkgs/kid3/patches/ffmpeg5.patch b/srcpkgs/kid3/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..135fc50e07c9b
--- /dev/null
+++ b/srcpkgs/kid3/patches/ffmpeg5.patch
@@ -0,0 +1,17 @@
+# https://aur.archlinux.org/cgit/aur.git/diff/ffmpeg5.patch?h=kid3-cli&id=12410a74906612e7efc0ec8fbce739b4a0fef7e7
+diff --git a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+index e156d424..e12b9abd 100644
+--- a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
++++ b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+@@ -232,7 +232,11 @@ private:
+   friend class Format;
+   friend class Converter;
+   AVCodecContext* m_ptr;
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 0, 0)
+   AVCodec* m_impl;
++#else
++  const AVCodec* m_impl;
++#endif
+   AVFrame* m_frame;
+   bool m_opened;
+ };

From 0b5832e3d7a030c2ef81df096a7a8647fbde4264 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 040/112] kodi: revbump for ffmpeg4

---
 srcpkgs/kodi/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kodi/template b/srcpkgs/kodi/template
index d37a5918cd675..536ee1fc83a7d 100644
--- a/srcpkgs/kodi/template
+++ b/srcpkgs/kodi/template
@@ -54,7 +54,7 @@ makedepends="
  libmad-devel fontconfig-devel libXinerama-devel libsamplerate-devel libmms-devel
  enca-devel boost-devel libcurl-devel libva-devel libvdpau-devel libass-devel
  libbluetooth-devel yajl-devel libplist-devel librtmp-devel tinyxml-devel
- taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg-devel
+ taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg4-devel
  giflib-devel libxslt-devel gnutls-devel libssh-devel libmicrohttpd-devel
  libcec-devel dcadec-devel flatbuffers-devel fmt-devel lcms2-devel
  libfstrcmp-devel rapidjson libcdio-paranoia spdlog libwaylandpp-devel

From 113e62ddb23a466c07d6f8a6cc5dcc428eac1d7e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 041/112] kpipewire: revbump for ffmpeg6

---
 srcpkgs/kpipewire/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kpipewire/template b/srcpkgs/kpipewire/template
index 6214a4451336e..3555348659dde 100644
--- a/srcpkgs/kpipewire/template
+++ b/srcpkgs/kpipewire/template
@@ -1,7 +1,7 @@
 # Template file for 'kpipewire'
 pkgname=kpipewire
 version=5.27.10
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules plasma-wayland-protocols gettext
  qt5-qmake qt5-host-tools pkg-config wayland-devel kcoreaddons

From ce3b84aeefa4b2248c036f5046e5a3fa84093d85 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 042/112] libextractor: revbump for ffmpeg4

---
 srcpkgs/libextractor/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libextractor/template b/srcpkgs/libextractor/template
index 044c663a3a0b9..ace88ae128da5 100644
--- a/srcpkgs/libextractor/template
+++ b/srcpkgs/libextractor/template
@@ -7,7 +7,7 @@ configure_args="--disable-static"
 hostmakedepends="pkg-config"
 makedepends="zlib-devel bzip2-devel exiv2-devel tiff-devel libpng-devel
  libjpeg-turbo-devel libvorbis-devel libflac-devel giflib-devel libmpeg2-devel
- ffmpeg-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
+ ffmpeg4-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
 short_desc="Library used to extract meta data from files"
 maintainer="Martin Riese <grauehaare@gmx.de>"
 license="GPL-3.0-or-later"

From ba1160e907e352f1dc0cfab745bfab5a398d2e08 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 043/112] libopenal: revbump for ffmpeg6

---
 srcpkgs/libopenal/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenal/template b/srcpkgs/libopenal/template
index 88d0f11307d81..8308fca0393e3 100644
--- a/srcpkgs/libopenal/template
+++ b/srcpkgs/libopenal/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenal'
 pkgname=libopenal
 version=1.23.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DALSOFT_EXAMPLES=OFF"
 hostmakedepends="pkg-config"

From 286afd10c8866f8dd8fabfc8cb92828811b791e6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 044/112] loudgain: revbump for ffmpeg6

---
 srcpkgs/loudgain/patches/ffmpeg5.patch | 11 +++++++++++
 srcpkgs/loudgain/template              |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/loudgain/patches/ffmpeg5.patch

diff --git a/srcpkgs/loudgain/patches/ffmpeg5.patch b/srcpkgs/loudgain/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..16d4510ee98fa
--- /dev/null
+++ b/srcpkgs/loudgain/patches/ffmpeg5.patch
@@ -0,0 +1,11 @@
+--- a/src/scan.c	2019-09-06 11:31:19.000000000 -0400
++++ b/src/scan.c	2023-03-23 11:15:40.867968521 -0400
+@@ -69,8 +69,6 @@
+ 	 * It is now useless
+ 	 * https://github.com/FFmpeg/FFmpeg/blob/70d25268c21cbee5f08304da95be1f647c630c15/doc/APIchanges#L86
+ 	 */
+-  if (avformat_version() < AV_VERSION_INT(58,9,100))
+-    av_register_all();
+ 
+ 	av_log_set_callback(scan_av_log);
+ 
diff --git a/srcpkgs/loudgain/template b/srcpkgs/loudgain/template
index da4f2d56e94c3..4d6bf29efb4fd 100644
--- a/srcpkgs/loudgain/template
+++ b/srcpkgs/loudgain/template
@@ -1,7 +1,7 @@
 # Template file for 'loudgain'
 pkgname=loudgain
 version=0.6.8
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libebur128-devel taglib-devel ffmpeg-devel"

From 56ebe28bc989bef7536a23fbe441a7d98ce70095 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 045/112] mediastreamer: revbump for ffmpeg4

---
 srcpkgs/mediastreamer/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mediastreamer/template b/srcpkgs/mediastreamer/template
index 0fcffa7653d18..92ada88743a9b 100644
--- a/srcpkgs/mediastreamer/template
+++ b/srcpkgs/mediastreamer/template
@@ -5,7 +5,7 @@ revision=2
 build_style=cmake
 configure_args="-DENABLE_STRICT=0 -DENABLE_UNIT_TESTS=0"
 hostmakedepends="python3"
-makedepends="bzrtp-devel ffmpeg-devel glew-devel libXv-devel libsrtp-devel
+makedepends="bzrtp-devel ffmpeg4-devel glew-devel libXv-devel libsrtp-devel
  libupnp-devel libvpx-devel mbedtls-devel opus-devel ortp-devel pulseaudio-devel
  libtheora-devel speex-devel v4l-utils-devel bcg729-devel bcmatroska2-devel libgsm-devel
  zxing-cpp-devel"

From 9377de53eb936d80c230a6ed7123288b3ebf3090 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 046/112] mgba: revbump for ffmpeg6

---
 srcpkgs/mgba/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mgba/template b/srcpkgs/mgba/template
index 5513e3fd16f3f..f5c87a4893002 100644
--- a/srcpkgs/mgba/template
+++ b/srcpkgs/mgba/template
@@ -1,7 +1,7 @@
 # Template file for 'mgba'
 pkgname=mgba
 version=0.10.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake desktop-file-utils"
 makedepends="SDL2-devel ffmpeg-devel libedit-devel libepoxy-devel libmagick-devel

From 52fe0d30171e5acd1b7bba732aaf05c0db1685fb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 047/112] mlt: revbump for ffmpeg4

---
 srcpkgs/mlt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mlt/template b/srcpkgs/mlt/template
index 73e3915aaab9a..ec5054be3b75e 100644
--- a/srcpkgs/mlt/template
+++ b/srcpkgs/mlt/template
@@ -8,7 +8,7 @@ configure_args="--prefix=/usr --libdir=/usr/lib$XBPS_TARGET_WORDSIZE
  --swig-languages=python"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which"
 # XXX: movit vid.stab
-makedepends="alsa-lib-devel ffmpeg-devel gtk+-devel jack-devel ladspa-sdk
+makedepends="alsa-lib-devel ffmpeg4-devel gtk+-devel jack-devel ladspa-sdk
  libexif-devel libsamplerate-devel libxml2-devel sox-devel SDL_image-devel
  fftw-devel frei0r-plugins python3-devel pulseaudio-devel movit-devel
  libvidstab-devel"

From b88d92762f73640dd1d126322076527fb4bd9170 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 048/112] moc: revbump for ffmpeg4

---
 srcpkgs/moc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/moc/template b/srcpkgs/moc/template
index 3a04932c8f1e6..d8de816026b64 100644
--- a/srcpkgs/moc/template
+++ b/srcpkgs/moc/template
@@ -4,7 +4,7 @@ version=2.5.2
 revision=7
 build_style=gnu-configure
 hostmakedepends="pkg-config"
-makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg-devel
+makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg4-devel
  jack-devel alsa-lib-devel libltdl-devel libflac-devel libvorbis-devel
  libmad-devel libmpcdec-devel libmodplug-devel libid3tag-devel faad2-devel
  taglib-devel libsndfile-devel wavpack-devel speex-devel libsamplerate-devel

From bb4c0aefecd58148be84001d79c8268982cc5494 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 049/112] motion: revbump for ffmpeg6

---
 srcpkgs/motion/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/motion/template b/srcpkgs/motion/template
index 607ebeb3c7b24..bf63a91d9764f 100644
--- a/srcpkgs/motion/template
+++ b/srcpkgs/motion/template
@@ -1,7 +1,7 @@
 # Template file for 'motion'
 pkgname=motion
 version=4.6.0
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake pkg-config gettext-devel tar"
 makedepends="ffmpeg-devel libmicrohttpd-devel v4l-utils-devel gettext-devel"

From 2b360b98f4e7ae7a5a4db314afd3e16b03d87ac7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 050/112] olive: revbump for ffmpeg4

---
 srcpkgs/olive/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/olive/template b/srcpkgs/olive/template
index 12a46936c9900..5c2917b9c5124 100644
--- a/srcpkgs/olive/template
+++ b/srcpkgs/olive/template
@@ -1,10 +1,10 @@
 # Template file for 'olive'
 pkgname=olive
 version=0.1.2
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools pkg-config"
-makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg-devel frei0r-plugins"
+makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg4-devel frei0r-plugins"
 short_desc="Non-linear video editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"

From 71395b8573217bd330ef0bab49ae8feb10525fd3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 051/112] opentoonz: revbump for ffmpeg6

---
 srcpkgs/opentoonz/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/opentoonz/template b/srcpkgs/opentoonz/template
index ee9f7603f55fd..3e81834ca0edd 100644
--- a/srcpkgs/opentoonz/template
+++ b/srcpkgs/opentoonz/template
@@ -1,7 +1,7 @@
 # Template file for 'opentoonz'
 pkgname=opentoonz
 version=1.6.0
-revision=2
+revision=3
 build_wrksrc="toonz/sources"
 build_style=cmake
 make_cmd=make

From 7ec85acdb9ce016be8ca7b5d5a16440031cbcb56 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 052/112] pianobar: revbump for ffmpeg6

---
 srcpkgs/pianobar/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pianobar/template b/srcpkgs/pianobar/template
index e3febb821a451..1e3dc1bf9308e 100644
--- a/srcpkgs/pianobar/template
+++ b/srcpkgs/pianobar/template
@@ -1,7 +1,7 @@
 # Template file for 'pianobar'
 pkgname=pianobar
 version=2022.04.01
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="V=1"
 hostmakedepends="pkg-config"

From 805f247f15748e83d96254e4cb70eb9f09f580f3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 053/112] ppsspp: revbump for ffmpeg4

---
 srcpkgs/ppsspp/template | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/srcpkgs/ppsspp/template b/srcpkgs/ppsspp/template
index 2c0ded496eb98..8bf55f65198cd 100644
--- a/srcpkgs/ppsspp/template
+++ b/srcpkgs/ppsspp/template
@@ -1,7 +1,7 @@
 # Template file for 'ppsspp'
 pkgname=ppsspp
 version=1.16.6
-revision=1
+revision=2
 _glslang_commit=b34f619e1c85810dcb3c578107d2e48ba4ee2b37
 _SPIRV_Cross_commit=4212eef67ed0ca048cb726a6767185504e7695e5
 _armips_commit=7bd1ec93d4586985ba1ef420b43b5e620f68695e
@@ -15,7 +15,7 @@ configure_args="-DHEADLESS=1 -DUSE_SYSTEM_FFMPEG=1 -DUNITTEST=ON
  -DUSING_QT_UI=$(vopt_if qt ON OFF) -DUSE_SYSTEM_ZSTD=ON
  -DARMIPS_USE_STD_FILESYSTEM=ON"
 hostmakedepends="pkg-config python3 $(vopt_if qt qt5-host-tools)"
-makedepends="zlib-devel glew-devel ffmpeg-devel libzip-devel
+makedepends="zlib-devel glew-devel ffmpeg4-devel libzip-devel
  snappy-devel rapidjson libpng-devel libzstd-devel
  $(vopt_if sdl2 'SDL2_ttf-devel SDL2-devel') $(vopt_if wayland wayland-devel)
  $(vopt_if qt 'qt5-devel qt5-multimedia-devel')"
@@ -69,10 +69,10 @@ post_extract() {
 	rmdir -v ${wrksrc}/ext/cpu_features
 	mv ${wrksrc}/cpu_features-${_cpu_features_commit} ${wrksrc}/ext/cpu_features
 	rmdir -v ${wrksrc}/ext/rcheevos
-        mv ${wrksrc}/rcheevos-${_rcheevos_commit} ${wrksrc}/ext/rcheevos
+	mv ${wrksrc}/rcheevos-${_rcheevos_commit} ${wrksrc}/ext/rcheevos
 }
 
-post_patch(){
+post_patch() {
 	# disable git versioning
 	vsed -e 's|find_package(Git)|# &|' -i git-version.cmake
 }
@@ -85,7 +85,6 @@ post_configure() {
 }
 
 do_install() {
-	vlicense LICENSE.TXT
 	vinstall icons/icon.svg 644 usr/share/pixmaps ppsspp.svg
 	vinstall Qt/PPSSPP.desktop 644 usr/share/applications
 	vbin build/PPSSPPHeadless ppsspp-headless

From 7b4c757b4148754ebeebac60045ed9166a8b9422 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 054/112] pqiv: revbump for ffmpeg6

---
 srcpkgs/pqiv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pqiv/template b/srcpkgs/pqiv/template
index 542fc27a2d32a..9308d949b6a1c 100644
--- a/srcpkgs/pqiv/template
+++ b/srcpkgs/pqiv/template
@@ -1,7 +1,7 @@
 # Template file for 'pqiv'
 pkgname=pqiv
 version=2.12
-revision=1
+revision=2
 build_style=gnu-makefile
 hostmakedepends="pkg-config"
 makedepends="glib-devel gtk+3-devel $(vopt_if ffmpeg ffmpeg-devel)

From 1f74041c68c0b59239aec7e4da5d082b29d71809 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 055/112] qmmp: revbump for ffmpeg6

---
 srcpkgs/qmmp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qmmp/template b/srcpkgs/qmmp/template
index 53781ea3bc28a..2da07f1e87eac 100644
--- a/srcpkgs/qmmp/template
+++ b/srcpkgs/qmmp/template
@@ -1,7 +1,7 @@
 # Template file for 'qmmp'
 pkgname=qmmp
 version=1.6.1
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DUSE_HAL:BOOL=FALSE -DQMMP_DEFAULT_UI:STRING=simple"
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From cc006cf40d8869d87fb40c4b379e90c10730214f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 14 Dec 2023 13:28:10 -0500
Subject: [PATCH 056/112] qt6-pdf: revbump for ffmpeg6

---
 srcpkgs/qt6-pdf/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-pdf/template b/srcpkgs/qt6-pdf/template
index ecda84afac131..531b4e1d4fe84 100644
--- a/srcpkgs/qt6-pdf/template
+++ b/srcpkgs/qt6-pdf/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-pdf'
 pkgname=qt6-pdf
 version=6.6.0
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DQT_FEATURE_qtpdf_build=ON
  -DQT_FEATURE_qtpdf_widgets_build=ON

From aa50e1130a0bf2c7099f9072ab6f86d72873cc16 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 057/112] qt5-webengine: revbump for ffmpeg6

---
 .../chromium-media-filters-cpp14.patch        |  11 ++
 srcpkgs/qt5-webengine/patches/ffmpeg5.patch   | 179 ++++++++++++++++++
 .../qtwebengine-fix-ffmpeg5-build.patch       |  14 ++
 srcpkgs/qt5-webengine/template                |   4 +-
 4 files changed, 206 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/ffmpeg5.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch

diff --git a/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
new file mode 100644
index 0000000000000..04adc540f2cbc
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
@@ -0,0 +1,11 @@
+--- a/src/3rdparty/chromium/media/filters/BUILD.gn	2023-02-27 13:32:59.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/BUILD.gn	2023-04-02 17:21:39.204066384 -0400
+@@ -96,6 +96,8 @@
+     "//ui/gfx/geometry:geometry",
+   ]
+ 
++  cflags_cc = [ "-std=c++14" ]
++
+   libs = []
+ 
+   if (proprietary_codecs) {
diff --git a/srcpkgs/qt5-webengine/patches/ffmpeg5.patch b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..ac55e1634423a
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
@@ -0,0 +1,179 @@
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:57.732547446 -0400
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:09.486478995 -0400
+@@ -57,6 +57,8 @@
+ 
+ namespace {
+ 
++constexpr int64_t kRelativeTsBase = static_cast<int64_t>(0x7ffeffffffffffff);
++
+ void SetAVStreamDiscard(AVStream* stream, AVDiscard discard) {
+   DCHECK(stream);
+   stream->discard = discard;
+@@ -90,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+   if (stream->start_time != kNoFFmpegTimestamp)
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (stream->first_dts != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, stream->first_dts);
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -408,11 +398,11 @@
+   scoped_refptr<DecoderBuffer> buffer;
+ 
+   if (type() == DemuxerStream::TEXT) {
+-    int id_size = 0;
++    size_t id_size = 0;
+     uint8_t* id_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
+ 
+-    int settings_size = 0;
++    size_t settings_size = 0;
+     uint8_t* settings_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
+ 
+@@ -424,7 +414,7 @@
+     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
+                                      side_data.data(), side_data.size());
+   } else {
+-    int side_data_size = 0;
++    size_t side_data_size = 0;
+     uint8_t* side_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
+ 
+@@ -485,7 +475,7 @@
+                                        packet->size - data_offset);
+     }
+ 
+-    int skip_samples_size = 0;
++    size_t skip_samples_size = 0;
+     const uint32_t* skip_samples_ptr =
+         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
+             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
+@@ -1587,6 +1577,8 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++      continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+       lowest_start_time_stream = stream.get();
+@@ -1604,6 +1596,8 @@
+     if (stream && stream->type() == DemuxerStream::VIDEO &&
+         stream->IsEnabled()) {
+       video_stream = stream.get();
++      if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++        continue;
+       if (video_stream->start_time() <= seek_time) {
+         return video_stream;
+       }
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h qtwebengine-5.15.10/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h
+--- a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-07-11 22:12:47.917192788 -0500
+@@ -29,6 +29,7 @@ extern "C" {
+ #include <libavformat/avformat.h>
+ #include <libavformat/avio.h>
+ #include <libavutil/avutil.h>
++#include <libavutil/channel_layout.h>
+ #include <libavutil/imgutils.h>
+ #include <libavutil/log.h>
+ #include <libavutil/mastering_display_metadata.h>
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/audio_file_reader.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/audio_file_reader.cc
+--- a/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -85,7 +85,7 @@ bool AudioFileReader::OpenDemuxer() {
+ }
+ 
+ bool AudioFileReader::OpenDecoder() {
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (codec) {
+     // MP3 decodes to S16P which we don't support, tell it to use S16 instead.
+     if (codec_context_->sample_fmt == AV_SAMPLE_FMT_S16P)
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -329,7 +329,7 @@ bool FFmpegAudioDecoder::ConfigureDecode
+     }
+   }
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec ||
+       avcodec_open2(codec_context_.get(), codec, &codec_options) < 0) {
+     DLOG(ERROR) << "Could not initialize audio decoder: "
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -59,7 +59,6 @@ static int64_t AVIOSeekOperation(void* o
+ }
+ 
+ void FFmpegGlue::InitializeFFmpeg() {
+-  av_register_all();
+ }
+ 
+ static void LogContainer(bool is_local_file,
+@@ -95,9 +94,6 @@ FFmpegGlue::FFmpegGlue(FFmpegURLProtocol
+   // Enable fast, but inaccurate seeks for MP3.
+   format_context_->flags |= AVFMT_FLAG_FAST_SEEK;
+ 
+-  // Ensures we can read out various metadata bits like vp8 alpha.
+-  format_context_->flags |= AVFMT_FLAG_KEEP_SIDE_DATA;
+-
+   // Ensures format parsing errors will bail out. From an audit on 11/2017, all
+   // instances were real failures. Solves bugs like http://crbug.com/710791.
+   format_context_->error_recognition |= AV_EF_EXPLODE;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -391,7 +391,7 @@ bool FFmpegVideoDecoder::ConfigureDecode
+   if (decode_nalus_)
+     codec_context_->flags2 |= AV_CODEC_FLAG2_CHUNKS;
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
+     ReleaseFFmpegResources();
+     return false;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/media_file_checker.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/media_file_checker.cc
+--- a/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -68,7 +68,7 @@ bool MediaFileChecker::Start(base::TimeD
+       auto context = AVStreamToAVCodecContext(format_context->streams[i]);
+       if (!context)
+         continue;
+-      AVCodec* codec = avcodec_find_decoder(cp->codec_id);
++      const AVCodec* codec = avcodec_find_decoder(cp->codec_id);
+       if (codec && avcodec_open2(context.get(), codec, nullptr) >= 0) {
+         auto loop = std::make_unique<FFmpegDecodingLoop>(context.get());
+         stream_contexts[i] = {std::move(context), std::move(loop)};
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc qtwebengine-5.15.10/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc
+--- a/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -203,7 +203,7 @@ int32_t H264DecoderImpl::InitDecode(cons
+   // a pointer |this|.
+   av_context_->opaque = this;
+ 
+-  AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
+   if (!codec) {
+     // This is an indication that FFmpeg has not been initialized or it has not
+     // been compiled/initialized with the correct set of codecs.
diff --git a/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch b/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch
new file mode 100644
index 0000000000000..bc24d5b9a29cb
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch
@@ -0,0 +1,14 @@
+--- a/src/buildtools/configure.json	2023-12-09 11:06:01.503058569 -0500
++++ b/src/buildtools/configure.json	2023-12-09 11:06:14.982361345 -0500
+@@ -779,11 +779,6 @@
+             "type": "warning",
+             "condition": "config.ios && config.simulator && config.device && features.build-qtpdf",
+             "message": "Building fat libray with device and simulator architectures will disable NEON."
+-        },
+-        {
+-            "type": "fatal",
+-            "condition": "features.webengine-system-ffmpeg && !libs.webengine-ffmpeg-support",
+-            "message": "Unmodified ffmpeg >= 5.0 is not supported. Please configure with -qt-webengine-ffmpeg."
+         }
+     ],
+     "summary": [
diff --git a/srcpkgs/qt5-webengine/template b/srcpkgs/qt5-webengine/template
index 8d2df1b5175ba..1687a77eb8a2f 100644
--- a/srcpkgs/qt5-webengine/template
+++ b/srcpkgs/qt5-webengine/template
@@ -1,14 +1,14 @@
 # Template file for 'qt5-webengine'
 pkgname=qt5-webengine
 version=5.15.16
-revision=1
+revision=2
 _version="${version}-lts"
 _chromium_commit=207c2ac45ca3386d153770c6b0d2ea2ec21ca880
 archs="x86_64* i686* armv[67]* ppc64* aarch64*"
 create_wrksrc=yes
 build_style=qmake
 configure_args="--
- -webengine-icu -webengine-ffmpeg -webengine-opus -webengine-webp
+ -webengine-icu -system-ffmpeg -webengine-opus -webengine-webp
  -webengine-pepper-plugins -webengine-printing-and-pdf -webengine-proprietary-codecs
  -webengine-pulseaudio -webengine-spellchecker -webengine-webrtc -webengine-geolocation
  -webengine-kerberos -no-webengine-embedded-build $(vopt_if sndio '' '-no')-webengine-sndio

From 35a356756325d0e909785613ef51101f5f72de05 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 058/112] qt5: revbump for ffmpeg6

---
 srcpkgs/qt5/template | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/srcpkgs/qt5/template b/srcpkgs/qt5/template
index ef6e437e02dbc..97b7818cc37d8 100644
--- a/srcpkgs/qt5/template
+++ b/srcpkgs/qt5/template
@@ -3,9 +3,9 @@
 # revbump libqtxdg after bumping patch version
 pkgname=qt5
 version=5.15.11+20231124
+revision=2
 # commit 4765fa1df7a837db9c1f89c4da0dd76b74bb5fab
 # base repo: https://invent.kde.org/qt/qt/qt5
-revision=1
 build_style=meta
 hostmakedepends="cmake clang flex perl glib-devel pkg-config
  python3 re2c ruby which"
@@ -246,7 +246,6 @@ do_configure() {
 	# opts+=" -v"
 	opts+=" -skip qtwebengine"
 	opts+=" -skip qtwebview"
-	opts+=" -skip qtdocgallery"
 	opts+=" -skip qtpim"
 	opts+=" -skip qtsystems"
 	opts+=" -skip qtspeech"

From 035e28e512ca5e810028165b90fbde9b0a301b5d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 059/112] qtav: revbump for ffmpeg4

---
 srcpkgs/qtav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qtav/template b/srcpkgs/qtav/template
index 775d5a139a9ef..2d00ad104355e 100644
--- a/srcpkgs/qtav/template
+++ b/srcpkgs/qtav/template
@@ -4,7 +4,7 @@ version=1.13.0
 revision=2
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel libass-devel libopenal-devel
+makedepends="ffmpeg4-devel libass-devel libopenal-devel
  libva-glx-devel libXv-devel pulseaudio-devel
  qt5-declarative-devel qt5-svg-devel
  qt5-quickcontrols"

From d6b09bd8530d5676c27824dbcace58bac134578f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 060/112] retroarch: revbump for ffmpeg6

---
 srcpkgs/retroarch/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroarch/template b/srcpkgs/retroarch/template
index cb3125c5dbf1a..c65c26f7bf033 100644
--- a/srcpkgs/retroarch/template
+++ b/srcpkgs/retroarch/template
@@ -1,7 +1,7 @@
 # Template file for 'retroarch'
 pkgname=retroarch
 version=1.16.0.3
-revision=3
+revision=4
 build_style=configure
 configure_args="--prefix=/usr --sysconfdir=/etc --enable-networking
  --enable-udev --disable-builtinflac --disable-builtinglslang

From f211dd3887854420c70357eeedfa7c05625ab0ea Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 061/112] scrcpy: revbump for ffmpeg6

---
 srcpkgs/scrcpy/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/scrcpy/template b/srcpkgs/scrcpy/template
index ac18bc03418ce..f39a7f678ab35 100644
--- a/srcpkgs/scrcpy/template
+++ b/srcpkgs/scrcpy/template
@@ -1,7 +1,7 @@
 # Template file for 'scrcpy'
 pkgname=scrcpy
 version=2.1.1
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcompile_server=false
  -Dprebuilt_server=/usr/share/scrcpy/scrcpy-server-v${version}"

From b6fbe47993f3b2dcd83f58eeb2bb23affcd6ca28 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 17 Oct 2023 08:54:11 -0400
Subject: [PATCH 062/112] New package: spex-x replaces spek-alternative for
 ffmpeg6

---
 srcpkgs/spek-alternative                      |  1 +
 srcpkgs/{spek-alternative => spek-x}/template | 22 ++++++++++++-------
 2 files changed, 15 insertions(+), 8 deletions(-)
 create mode 120000 srcpkgs/spek-alternative
 rename srcpkgs/{spek-alternative => spek-x}/template (52%)

diff --git a/srcpkgs/spek-alternative b/srcpkgs/spek-alternative
new file mode 120000
index 0000000000000..76648236da701
--- /dev/null
+++ b/srcpkgs/spek-alternative
@@ -0,0 +1 @@
+spek-x
\ No newline at end of file
diff --git a/srcpkgs/spek-alternative/template b/srcpkgs/spek-x/template
similarity index 52%
rename from srcpkgs/spek-alternative/template
rename to srcpkgs/spek-x/template
index d7b55c776b1d4..3ded6c2c323e4 100644
--- a/srcpkgs/spek-alternative/template
+++ b/srcpkgs/spek-x/template
@@ -1,18 +1,18 @@
-# Template file for 'spek-alternative'
-pkgname=spek-alternative
-version=0.8.2.3
-revision=2
+# Template file for 'spek-x'
+pkgname=spek-x
+version=0.9.3
+revision=1
 build_style=gnu-configure
 hostmakedepends="automake gettext-devel intltool libtool pkg-config
  wxWidgets-common wxWidgets-gtk3-devel"
 makedepends="ffmpeg-devel wxWidgets-gtk3-devel"
 depends="ffmpeg"
 short_desc="Acoustic spectrum analyser"
-maintainer="Kartik Singh <kartik.ynwa@gmail.com>"
+maintainer="zlice <zlice555@gmail.com>"
 license="GPL-3.0-or-later"
-homepage="https://github.com/withmorten/spek-alternative"
-distfiles="https://github.com/withmorten/spek-alternative/archive/${version}.tar.gz"
-checksum="007ba4b84a310b078e378aa84c8e80783db5821437a757a488c3ecec377e6b2a"
+homepage="https://github.com/MikeWang000000/spek-x"
+distfiles="https://github.com/MikeWang000000/spek-x/archive/v${version}.tar.gz"
+checksum="7f4b109903333cdd310ab2b9176f0dc49a565891376e281a233d342cedf90ef7"
 
 CXXFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
 
@@ -22,3 +22,9 @@ export WX_CONFIG_NAME="wx-config-gtk3"
 pre_configure() {
 	NOCONFIGURE=1 ./autogen.sh
 }
+
+spek-alternative_package() {
+	depends="spek-x"
+	short_desc+=" - transitional dummy package"
+	build_style=meta
+}

From c943dddf4f116d8d99bff8cab268a021197314a6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 063/112] ssr: revbump for ffmpeg4

---
 srcpkgs/ssr/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ssr/template b/srcpkgs/ssr/template
index 3097754e3cbe5..fa66d5b4736d4 100644
--- a/srcpkgs/ssr/template
+++ b/srcpkgs/ssr/template
@@ -5,7 +5,7 @@ revision=2
 build_style=cmake
 configure_args="-DWITH_QT5=ON"
 hostmakedepends="pkg-config"
-makedepends="alsa-lib-devel ffmpeg-devel glu-devel jack-devel pulseaudio-devel
+makedepends="alsa-lib-devel ffmpeg4-devel glu-devel jack-devel pulseaudio-devel
  qt5-tools-devel qt5-x11extras-devel libXinerama-devel v4l-utils-devel"
 depends="desktop-file-utils hicolor-icon-theme"
 short_desc="Simple Screen Recorder for programs and games"

From 2c0d7b727292a28cbfba0f8043fa6ec2d5fb64b8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 064/112] synfig: revbump for ffmpeg6 and mlt7

---
 srcpkgs/synfig/patches/ffmpeg6.patch | 71 ++++++++++++++++++++++++++++
 srcpkgs/synfig/template              |  4 +-
 2 files changed, 73 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/synfig/patches/ffmpeg6.patch

diff --git a/srcpkgs/synfig/patches/ffmpeg6.patch b/srcpkgs/synfig/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..10780b42782f4
--- /dev/null
+++ b/srcpkgs/synfig/patches/ffmpeg6.patch
@@ -0,0 +1,71 @@
+--- a/src/modules/mod_libavcodec/trgt_av.cpp	2022-10-25 09:14:12.000000000 -0400
++++ b/src/modules/mod_libavcodec/trgt_av.cpp	2023-05-05 21:34:17.899194559 -0400
+@@ -38,6 +41,7 @@
+ extern "C"
+ {
+ #ifdef HAVE_LIBAVFORMAT_AVFORMAT_H
++#	include <libavcodec/avcodec.h>
+ #	include <libavformat/avformat.h>
+ #elif defined(HAVE_AVFORMAT_H)
+ #	include <avformat.h>
+@@ -155,11 +156,11 @@
+     }
+ 
+ 	bool open_video_stream() {
+-		if (avcodec_open2(video_context, NULL, NULL) < 0) {
++		if (avcodec_open2(video_context, nullptr, nullptr) < 0) {
+ 			synfig::error("Target_LibAVCodec: could not open video codec");
+ 			// seems the calling of avcodec_free_context after error will cause crash
+ 			// so just forget about this context
+-			video_context = NULL;
++			video_context = nullptr;
+ 			close();
+ 			return false;
+         }
+@@ -234,15 +235,21 @@
+ 		close();
+ 
+ 		if (!av_registered) {
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 			av_register_all();
++#endif
+ 			av_registered = true;
+ 		}
+ 
+ 		// guess format
+-		AVOutputFormat *format = av_guess_format(NULL, filename.c_str(), NULL);
++#if LIBAVCODEC_VERSION_MAJOR < 59 // FFMPEG < 5.0
++		AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#else
++		const AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#endif
+ 		if (!format) {
+ 			synfig::warning("Target_LibAVCodec: unable to guess the output format, defaulting to MPEG");
+-			format = av_guess_format("mpeg", NULL, NULL);
++			format = av_guess_format("mpeg", nullptr, nullptr);
+ 		}
+ 		if (!format) {
+ 			synfig::error("Target_LibAVCodec: unable to find 'mpeg' output format");
+@@ -254,6 +261,7 @@
+ 		context = avformat_alloc_context();
+ 		assert(context);
+ 		context->oformat = format;
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 		if (filename.size() + 1 > sizeof(context->filename)) {
+ 			synfig::error(
+ 				"Target_LibAVCodec: filename too long, max length is %d, filename is '%s'",
+@@ -263,6 +271,14 @@
+ 			return false;
+ 		}
+ 		memcpy(context->filename, filename.c_str(), filename.size() + 1);
++#else
++		context->url = av_strndup(filename.c_str(), filename.size());
++		if (!context->url) {
++			synfig::error("Target_LibAVCodec: cannot allocate space for filename");
++			close();
++			return false;
++		}
++#endif
+ 
+ 		packet = av_packet_alloc();
+ 		assert(packet);
diff --git a/srcpkgs/synfig/template b/srcpkgs/synfig/template
index d4d3e341a20bf..703cfd7ebac84 100644
--- a/srcpkgs/synfig/template
+++ b/srcpkgs/synfig/template
@@ -6,7 +6,7 @@ revision=4
 build_style=gnu-configure
 configure_args="--with-boost-libdir=${XBPS_CROSS_BASE}/usr/lib"
 hostmakedepends="boost-build ImageMagick pkg-config intltool"
-makedepends="ETL gettext-devel libxml++-devel mlt-devel libmagick-devel
+makedepends="ETL gettext-devel libxml++-devel mlt7-devel libmagick-devel
  libmng-devel boost-build boost-devel libopenexr-devel ffmpeg-devel"
 depends="ImageMagick"
 short_desc="CLI 2D vector and timeline-based animation software"
@@ -20,7 +20,7 @@ CXXFLAGS="-std=c++11 -DHAVE_LOCALE_H=1"
 
 synfig-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision}
-	 libopenexr-devel libxml++-devel mlt-devel"
+	 libopenexr-devel libxml++-devel mlt7-devel"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/bin/synfig-config

From 2401fdae6dcf0e2c064a7eb6c6bfe47955a2a7b9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 065/112] timg: revbump for ffmpeg6

---
 srcpkgs/timg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/timg/template b/srcpkgs/timg/template
index 2a2ab763d2fdd..8fb4327535ef9 100644
--- a/srcpkgs/timg/template
+++ b/srcpkgs/timg/template
@@ -1,7 +1,7 @@
 # Template file for 'timg'
 pkgname=timg
 version=1.4.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_OPENSLIDE_SUPPORT=off -Wno-dev"
 hostmakedepends="pkg-config git"

From 7ea703b66bbdd0365cba942591a6a3b3a4d75b97 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 066/112] tvheadend: revbump for ffmpeg4

---
 srcpkgs/tvheadend/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tvheadend/template b/srcpkgs/tvheadend/template
index 9aea7de4ec705..012d31c4879ff 100644
--- a/srcpkgs/tvheadend/template
+++ b/srcpkgs/tvheadend/template
@@ -8,7 +8,7 @@ configure_args="--enable-dvbscan --disable-ffmpeg_static
 --disable-libx265_static --disable-libvpx_static --disable-libtheora_static
 --disable-libvorbis_static --disable-libfdkaac_static"
 hostmakedepends="gettext pkg-config python3 git which"
-makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg-devel"
+makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg4-devel"
 short_desc="TV streaming server"
 maintainer="lemmi <lemmi@nerd2nerd.org>"
 license="GPL-3.0-only"

From b41c083d0f7f33217f657d32cc11e36686ac7e91 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 067/112] unpaper: update to 7.0.0.

---
 srcpkgs/unpaper/template | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/srcpkgs/unpaper/template b/srcpkgs/unpaper/template
index 38ed47a584016..1ff910e722afc 100644
--- a/srcpkgs/unpaper/template
+++ b/srcpkgs/unpaper/template
@@ -1,13 +1,13 @@
 # Template file for 'unpaper'
 pkgname=unpaper
-version=6.1
-revision=3
-build_style=gnu-configure
+version=7.0.0
+revision=1
+build_style=meson
+hostmakedepends="pkg-config meson libxslt"
+makedepends="ffmpeg-devel python3-Sphinx"
+short_desc="Post-processing tool for scanned sheets of paper"
 maintainer="Orphaned <orphan@voidlinux.org>"
-hostmakedepends="pkg-config libxslt"
-makedepends="ffmpeg-devel"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://www.flameeyes.eu/projects/unpaper"
-short_desc="A post-processing tool for scanned sheets of paper"
 distfiles="https://www.flameeyes.eu/files/${pkgname}-${version}.tar.xz"
-checksum=237c84f5da544b3f7709827f9f12c37c346cdf029b1128fb4633f9bafa5cb930
+checksum=2575fbbf26c22719d1cb882b59602c9900c7f747118ac130883f63419be46a80

From bc3f1ffadcc6782fa22e6fcbe6c95f94676fe896 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 068/112] vice: revbump for ffmpeg4

---
 srcpkgs/vice/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vice/template b/srcpkgs/vice/template
index b1f866d35095e..4beab2c5f9ebd 100644
--- a/srcpkgs/vice/template
+++ b/srcpkgs/vice/template
@@ -26,7 +26,7 @@ makedepends="
 	$(vopt_if gtk3 gtk+3-devel)
 	$(vopt_if gtk3 pulseaudio-devel)
 	$(vopt_if gtk3 pango-devel)
-	$(vopt_if ffmpeg ffmpeg-devel)"
+	$(vopt_if ffmpeg ffmpeg4-devel)"
 short_desc="Emulator for C64, C128, CBM-II, PET, VIC20, Plus4 and C16"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"

From b3db4c523985a38254900ea79ed6103e846314be Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 069/112] waypipe: revbump for ffmpeg6

---
 srcpkgs/waypipe/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waypipe/template b/srcpkgs/waypipe/template
index 6da88b21bf2a1..4da8058400b58 100644
--- a/srcpkgs/waypipe/template
+++ b/srcpkgs/waypipe/template
@@ -1,7 +1,7 @@
 # Template file for 'waypipe'
 pkgname=waypipe
 version=0.8.6
-revision=1
+revision=2
 build_style=meson
 # lto is off because it causes linking errors in armv6l and armv7l (due to NEON)
 configure_args="-Dwerror=false -Dwith_dmabuf=enabled -Dwith_lz4=enabled

From 92797da285bc8e5ddaf8c9c86d5731513106a3ba Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 070/112] xpra: revbump for ffmpeg6

---
 srcpkgs/xpra/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xpra/template b/srcpkgs/xpra/template
index 6bfe9be2db650..1eea2962bcb82 100644
--- a/srcpkgs/xpra/template
+++ b/srcpkgs/xpra/template
@@ -1,7 +1,7 @@
 # Template file for 'xpra'
 pkgname=xpra
 version=5.0.4
-revision=1
+revision=2
 build_style=python3-module
 make_build_args="--without-cuda_kernels --without-cuda_rebuild"
 make_install_args="$(vopt_with docs) ${make_build_args}"

From 912d5a9fa421d1a2e8d5fce9d75d563970b068b2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:07:40 -0400
Subject: [PATCH 071/112] nv-codec-headers: update to 12.0.16.0

---
 srcpkgs/nv-codec-headers/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/nv-codec-headers/template b/srcpkgs/nv-codec-headers/template
index 3d422a61e4891..251e057f826fb 100644
--- a/srcpkgs/nv-codec-headers/template
+++ b/srcpkgs/nv-codec-headers/template
@@ -1,6 +1,6 @@
 # Template file for 'nv-codec-headers'
 pkgname=nv-codec-headers
-version=11.1.5.1
+version=12.0.16.0
 revision=1
 build_style=gnu-makefile
 short_desc="FFmpeg version of headers required to interface with Nvidias codec APIs"
@@ -8,7 +8,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="MIT"
 homepage="http://git.videolan.org/?p=ffmpeg/nv-codec-headers.git"
 distfiles="https://github.com/FFmpeg/nv-codec-headers/archive/n${version}.tar.gz"
-checksum=d095fbd56aa93772471a323be0ebe65504a0f43f06c76a30b6d25da77b06ae9c
+checksum=2a1533b65f55f9da52956faf0627ed3b74868ac0c7f269990edd21369113b48f
 
 post_install() {
 	sed -n '4,25p' include/ffnvcodec/nvEncodeAPI.h > LICENSE

From 4683dbc78564962bebdf6ae8303f34086c114830 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:08:40 -0400
Subject: [PATCH 072/112] openimagedenoise: revbump for ffmpeg6

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index b792813dba7c2..109deb171c3f7 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,7 +1,7 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
 version=1.4.3
-revision=1
+revision=2
 archs="x86_64*"
 build_style=cmake
 hostmakedepends="ispc python3"

From 2a5847cc72c7cf935df6e8b63736406441b1f685 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:31:45 -0400
Subject: [PATCH 073/112] shotcut: revbump for ffmpeg6

---
 srcpkgs/shotcut/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/shotcut/template b/srcpkgs/shotcut/template
index 33141fbd862d7..f46cb53b6bfb9 100644
--- a/srcpkgs/shotcut/template
+++ b/srcpkgs/shotcut/template
@@ -1,7 +1,7 @@
 # Template file for 'shotcut'
 pkgname=shotcut
 version=23.09.29
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSHOTCUT_VERSION=${version}"
 hostmakedepends="pkg-config qt6-tools-devel"

From 5433f1417fc056918f2345f21e9f062d6d9c96b6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:30 -0400
Subject: [PATCH 074/112] shiboken2: revbump for qt5-5.15.11

---
 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch | 1 +
 srcpkgs/shiboken2/template                                 | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
 create mode 120000 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
new file mode 120000
index 0000000000000..efcf3249bd885
--- /dev/null
+++ b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1 @@
+../../python3-pyside2/patches/importlib-machinery-bypass.patch
\ No newline at end of file
diff --git a/srcpkgs/shiboken2/template b/srcpkgs/shiboken2/template
index 883d6a084d868..f3c06ec245a1f 100644
--- a/srcpkgs/shiboken2/template
+++ b/srcpkgs/shiboken2/template
@@ -1,7 +1,7 @@
 # Template file for 'shiboken2'
 pkgname=shiboken2
 version=5.15.10
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/shiboken2"
 build_style=cmake

From b622745ba336b9fd5387f83e3ff38b99d20b5037 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:53 -0400
Subject: [PATCH 075/112] python3-pyside2: revbump for qt5-5.15.11

---
 .../patches/importlib-machinery-bypass.patch      | 15 +++++++++++++++
 srcpkgs/python3-pyside2/template                  |  2 +-
 2 files changed, 16 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
new file mode 100644
index 0000000000000..64c429584776b
--- /dev/null
+++ b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1,15 @@
+Using this prevents an error around line 220 below it.
+"AttributeError: module 'importlib' has no attribute 'machinery'"
+The old backup logic is in place and compiles without issues.
+--- a/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:09:34.688912402 -0400
++++ b/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:10:03.395529582 -0400
+@@ -170,9 +170,6 @@
+
+     # 'zipstring_sequence' comes from signature.cpp
+     zipbytes = base64.b64decode(''.join(zipstring_sequence))
+-    if sys.version_info[0] >= 3:
+-        vzip = zipfile.ZipFile(io.BytesIO(zipbytes))
+-        return sys.meta_path, EmbeddableZipImporter(vzip)
+
+     # Old version for Python 2.7, only.
+     import os
diff --git a/srcpkgs/python3-pyside2/template b/srcpkgs/python3-pyside2/template
index 249efa9098842..52626436ce75f 100644
--- a/srcpkgs/python3-pyside2/template
+++ b/srcpkgs/python3-pyside2/template
@@ -1,7 +1,7 @@
 # Template file for 'python3-pyside2'
 pkgname=python3-pyside2
 version=5.15.10
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/pyside2"
 build_style=cmake

From 7691d90118872e160d69afe195227d9c6022d8b6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:35 -0400
Subject: [PATCH 076/112] konqueror: revbump for ffmpeg6

---
 srcpkgs/konqueror/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/konqueror/template b/srcpkgs/konqueror/template
index 044dafa605ba6..63dd01fafc780 100644
--- a/srcpkgs/konqueror/template
+++ b/srcpkgs/konqueror/template
@@ -1,11 +1,11 @@
 # Template file for 'konqueror'
 pkgname=konqueror
 version=23.08.4
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DDESKTOPTOJSON_EXECUTABLE=/usr/bin/desktoptojson"
 hostmakedepends="extra-cmake-modules python3 qt5-host-tools qt5-qmake kdoctools
-kcoreaddons kconfig gettext"
+ kcoreaddons kconfig gettext"
 makedepends="qt5-devel qt5-webengine-devel qt5-declarative-devel
  qt5-webchannel-devel qt5-location-devel kcmutils-devel kdelibs4support-devel
  karchive-devel khtml-devel kdesu-devel kactivities5-devel"

From 4eac8e60b05702c88ec486afad090d14a71ed163 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:58 -0400
Subject: [PATCH 077/112] qt5-speech: revbump for qt5-5.15.11

---
 srcpkgs/qt5-speech/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-speech/template b/srcpkgs/qt5-speech/template
index 1228bb60c41db..27a7da1dbdb91 100644
--- a/srcpkgs/qt5-speech/template
+++ b/srcpkgs/qt5-speech/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-speech'
 pkgname=qt5-speech
 version=5.15.11
-revision=1
+revision=2
 _commit=d32f4a479d38a11f547598004b975f4356424a16
 build_style=qmake
 configure_args="-- -flite -flite-alsa -speechd"

From b7b3f1f96fcf60ddc92da9e0277e159a895c92a4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Jun 2023 08:20:22 -0400
Subject: [PATCH 078/112] gtk4: revbump for ffmpeg6

---
 srcpkgs/gtk4/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gtk4/template b/srcpkgs/gtk4/template
index d8ee60abe06f7..55bff6e33849a 100644
--- a/srcpkgs/gtk4/template
+++ b/srcpkgs/gtk4/template
@@ -1,7 +1,7 @@
 # Template file for 'gtk4'
 pkgname=gtk4
 version=4.12.3
-revision=1
+revision=2
 build_style=meson
 build_helper="gir"
 configure_args="-Dman-pages=true -Ddocumentation=true -Dbuild-tests=false

From e4216b27895e23c92167b8a760048069153b8918 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:28:26 -0400
Subject: [PATCH 079/112] siril: revbump for ffmpeg6

---
 srcpkgs/siril/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/siril/template b/srcpkgs/siril/template
index 84332f79d060d..62750dd247548 100644
--- a/srcpkgs/siril/template
+++ b/srcpkgs/siril/template
@@ -1,7 +1,7 @@
 # Template file for 'siril'
 pkgname=siril
 version=0.9.12
-revision=10
+revision=11
 build_style=gnu-configure
 hostmakedepends="pkg-config intltool autoconf automake gettext-devel"
 makedepends="fftw-devel libconfig-devel libopencv-devel libffms2-devel

From fb998dd56e0b063d4eb5be390e03474a5a1eb66f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 22 Jun 2023 10:25:02 -0400
Subject: [PATCH 080/112] kdenlive: revbump for ffmpeg6

---
 srcpkgs/kdenlive/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kdenlive/template b/srcpkgs/kdenlive/template
index a0f3615c9c530..d63166f95c4d7 100644
--- a/srcpkgs/kdenlive/template
+++ b/srcpkgs/kdenlive/template
@@ -1,7 +1,7 @@
 # Template file for 'kdenlive'
 pkgname=kdenlive
 version=23.08.4
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="
  extra-cmake-modules kconfig kcoreaddons kdoctools pkg-config python3

From 6c539d23560a9c1a55a52c65568d1d74e988b6e5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:20:59 -0400
Subject: [PATCH 081/112] tracker-miners: revbump for ffmpeg6

---
 srcpkgs/tracker-miners/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tracker-miners/template b/srcpkgs/tracker-miners/template
index 0b97f47489f81..f196d2bf9e4a4 100644
--- a/srcpkgs/tracker-miners/template
+++ b/srcpkgs/tracker-miners/template
@@ -1,7 +1,7 @@
 # Template file for 'tracker-miners'
 pkgname=tracker-miners
 version=3.6.1
-revision=1
+revision=2
 build_style=meson
 build_helper=qemu
 # missing libgrss for miner_rss

From a749e35d4babf1090ee5f457798124b48c90e1a7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:21:21 -0400
Subject: [PATCH 082/112] mpd: revbump for ffmpeg6

---
 srcpkgs/mpd/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpd/template b/srcpkgs/mpd/template
index 4fd32b7be8c53..b8e2bd4c1b59c 100644
--- a/srcpkgs/mpd/template
+++ b/srcpkgs/mpd/template
@@ -1,7 +1,7 @@
 # Template file for 'mpd'
 pkgname=mpd
 version=0.23.15
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dopus=enabled -Dmikmod=enabled -Dneighbor=true
  -Dsoundcloud=enabled -Dpipe=true -Dtwolame=enabled -Dbzip2=enabled

From 19f8e25901379810370c1d7392c2e8266148f1c4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:02 -0400
Subject: [PATCH 083/112] tg_owt: revbump for ffmpeg6

---
 srcpkgs/tg_owt/template | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/srcpkgs/tg_owt/template b/srcpkgs/tg_owt/template
index aee8d35d08ffb..563ed9a5835c4 100644
--- a/srcpkgs/tg_owt/template
+++ b/srcpkgs/tg_owt/template
@@ -1,8 +1,7 @@
 # Template file for 'tg_owt'
 pkgname=tg_owt
 version=0.0.0.20231221
-revision=1
-_commit=afd9d5d31798d3eacf9ed6c30601e91d0f1e4d60
+revision=2
 _libyuv_commit=04821d1e7d60845525e8db55c7bcd41ef5be9406
 _abseil_commit=8c0b94e793a66495e0b1f34a5eb26bd7dc672db0
 _crc32c_commit=21fc8ef30415a635e7351ffa0e5d5367943d4a94

From 6184fc85bcf694ff317718c3ea1d9ecb2bc7ee42 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:44 -0400
Subject: [PATCH 084/112] telegram-desktop: revbump for ffmpeg6

---
 srcpkgs/telegram-desktop/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/telegram-desktop/template b/srcpkgs/telegram-desktop/template
index 48ccb9a9d840a..c8756611e2b3b 100644
--- a/srcpkgs/telegram-desktop/template
+++ b/srcpkgs/telegram-desktop/template
@@ -1,7 +1,7 @@
 # Template file for 'telegram-desktop'
 pkgname=telegram-desktop
 version=4.14.2
-revision=1
+revision=2
 build_style=cmake
 build_helper="qemu gir"
 configure_args="-DTDESKTOP_API_ID=209235

From f8a7c278e41bbc8fa352eb63db6ccda100b45dc2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:11:45 -0400
Subject: [PATCH 085/112] gst-plugins-bad1: revbump for ffmpeg6

---
 srcpkgs/gst-plugins-bad1/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index fcd3538cd5cde..976e2889b588e 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-plugins-bad1'
 pkgname=gst-plugins-bad1
 version=1.22.7
-revision=1
+revision=2
 build_helper="gir"
 build_style=meson
 configure_args="-Dpackage-origin=https://voidlinux.org -Ddoc=disabled

From baf346ceedd9aebf8e21015b1e0b827f3d4a9fec Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:12:09 -0400
Subject: [PATCH 086/112] openmw: revbump for ffmpeg6

---
 srcpkgs/openmw/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openmw/template b/srcpkgs/openmw/template
index 0abf5ff7cdbec..b57180f1a4446 100644
--- a/srcpkgs/openmw/template
+++ b/srcpkgs/openmw/template
@@ -1,7 +1,7 @@
 # Template file for 'openmw'
 pkgname=openmw
 version=0.48.0
-revision=2
+revision=3
 build_style=cmake
 _recast_commit=e75adf86f91eb3082220085e42dda62679f9a3ea
 _bullet_tag=3.17

From f21583e8ff4b97e9fcfa9fd47467d6df6e28f54f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:14:53 -0400
Subject: [PATCH 087/112] lms: revbump for ffmpeg6

---
 srcpkgs/lms/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/lms/template b/srcpkgs/lms/template
index e358f75902a98..3b21c458de519 100644
--- a/srcpkgs/lms/template
+++ b/srcpkgs/lms/template
@@ -1,7 +1,7 @@
 # Template file for 'lms'
 pkgname=lms
 version=3.42.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="wt-devel ffmpeg-devel boost-devel libconfig++-devel taglib-devel pam-devel libgraphicsmagick-devel gtest-devel libarchive-devel"

From 5ab08c44b8cae32463cc442ecb9c0b96bbaa5818 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:18:18 -0400
Subject: [PATCH 088/112] freecad: DELETE

---
 srcpkgs/freecad/patches/001-include.patch     | 112 ------------------
 .../154-revert-gui-tmp-redirect-stderr.patch  |  68 -----------
 ...d63c8c9b1280978be841d04e68a0a55cceb9.patch |  30 -----
 srcpkgs/freecad/template                      |  12 +-
 4 files changed, 7 insertions(+), 215 deletions(-)
 delete mode 100644 srcpkgs/freecad/patches/001-include.patch
 delete mode 100644 srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
 delete mode 100644 srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch

diff --git a/srcpkgs/freecad/patches/001-include.patch b/srcpkgs/freecad/patches/001-include.patch
deleted file mode 100644
index 28b5af54999b9..0000000000000
--- a/srcpkgs/freecad/patches/001-include.patch
+++ /dev/null
@@ -1,112 +0,0 @@
-From 9a41845a417189776741297c50a3827ce292bc4f Mon Sep 17 00:00:00 2001
-From: Uwe <donovaly@users.noreply.github.com>
-Date: Sun, 3 Jul 2022 22:51:16 +0200
-Subject: [PATCH] [Part] OCCError.h: remove unneeded includes
-
-- also sort includes
----
- src/Mod/Part/App/OCCError.h             | 36 +++----------------------
- src/Mod/Part/App/OffsetCurvePyImp.cpp   | 12 ++++-----
- src/Mod/Part/App/OffsetSurfacePyImp.cpp | 10 +++----
- 3 files changed, 12 insertions(+), 46 deletions(-)
-
---- a/src/Mod/Part/App/OCCError.h
-+++ b/src/Mod/Part/App/OCCError.h
-@@ -23,36 +23,8 @@
- #ifndef _OCCError_h_
- #define _OCCError_h_
- 
--# include <Standard_Version.hxx>
- # include <Standard_Failure.hxx>
--# include <Standard_AbortiveTransaction.hxx>
--# include <Standard_ConstructionError.hxx>
--# if OCC_VERSION_HEX >= 0x060500
--# include <Standard_DefineException.hxx>
--# endif
--# include <Standard_DimensionError.hxx>
--# include <Standard_DimensionMismatch.hxx>
--# include <Standard_DivideByZero.hxx>
--# include <Standard_DomainError.hxx>
--# include <Standard_ImmutableObject.hxx>
--# include <Standard_LicenseError.hxx>
--# include <Standard_LicenseNotFound.hxx>
--# include <Standard_MultiplyDefined.hxx>
--# include <Standard_NegativeValue.hxx>
--# include <Standard_NoMoreObject.hxx>
--# include <Standard_NoSuchObject.hxx>
--# include <Standard_NotImplemented.hxx>
--# include <Standard_NullObject.hxx>
--# include <Standard_NullValue.hxx>
--# include <Standard_NumericError.hxx>
--# include <Standard_OutOfMemory.hxx>
--# include <Standard_OutOfRange.hxx>
--# include <Standard_Overflow.hxx>
--# include <Standard_ProgramError.hxx>
--# include <Standard_RangeError.hxx>
--# include <Standard_TooManyUsers.hxx>
--# include <Standard_TypeMismatch.hxx>
--# include <Standard_Underflow.hxx>
-+# include <Standard_Version.hxx>
- 
- #include <Mod/Part/PartGlobal.h>
- #include <Base/Console.h>
-@@ -88,4 +60,3 @@ PartExport extern PyObject* PartExceptio
- 
- #define PY_CATCH_OCC _PY_CATCH_OCC(return(NULL))
- #endif  // _OCCError_h_
--
---- a/src/Mod/Part/App/OffsetCurvePyImp.cpp
-+++ b/src/Mod/Part/App/OffsetCurvePyImp.cpp
-@@ -20,20 +20,20 @@
-  *                                                                         *
-  ***************************************************************************/
- 
--
- #include "PreCompiled.h"
- #ifndef _PreComp_
- # include <Geom_OffsetCurve.hxx>
- #endif
- 
--#include "OCCError.h"
--#include "Geometry.h"
-+#include <Base/GeometryPyCXX.h>
-+#include <Base/Vector3D.h>
-+#include <Base/VectorPy.h>
-+
- #include "OffsetCurvePy.h"
- #include "OffsetCurvePy.cpp"
-+#include "Geometry.h"
-+#include "OCCError.h"
- 
--#include <Base/GeometryPyCXX.h>
--#include <Base/VectorPy.h>
--#include <Base/Vector3D.h>
- 
- using namespace Part;
- 
---- a/src/Mod/Part/App/OffsetSurfacePyImp.cpp
-+++ b/src/Mod/Part/App/OffsetSurfacePyImp.cpp
-@@ -20,20 +20,16 @@
-  *                                                                         *
-  ***************************************************************************/
- 
--
- #include "PreCompiled.h"
- #ifndef _PreComp_
- # include <Geom_OffsetSurface.hxx>
- # include <memory>
- #endif
- 
--#include <Base/VectorPy.h>
--#include <Base/Vector3D.h>
--
- #include "OCCError.h"
--#include "Geometry.h"
--#include <Mod/Part/App/OffsetSurfacePy.h>
--#include <Mod/Part/App/OffsetSurfacePy.cpp>
-+#include "OffsetSurfacePy.h"
-+#include "OffsetSurfacePy.cpp"
-+
- 
- using namespace Part;
- 
diff --git a/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch b/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
deleted file mode 100644
index d6a9adabdec83..0000000000000
--- a/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
+++ /dev/null
@@ -1,68 +0,0 @@
-see https://github.com/FreeCAD/FreeCAD/commit/cfe94b00d3434f3e2c8b5114d2909f628c330fa8#commitcomment-71413407
-
-upstream: yes
-
-From 7b377a216b9185960e4cee980a6504dc1a755f50 Mon Sep 17 00:00:00 2001
-From: wmayer <wmayer@users.sourceforge.net>
-Date: Wed, 29 Jun 2022 15:19:18 +0200
-Subject: [PATCH] Gui: remove workaround for spnav 0.23 due to build failure
- with musl libc
-
----
- src/Gui/3Dconnexion/GuiNativeEventLinux.cpp | 27 ---------------------
- 1 file changed, 27 deletions(-)
-
---- a/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp
-+++ b/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp
-@@ -21,42 +21,17 @@
-  ***************************************************************************/
- 
- #include <FCConfig.h>
--#include <cstdio>
- 
- #include "GuiNativeEventLinux.h"
- 
- #include "GuiApplicationNativeEventAware.h"
- #include <Base/Console.h>
--#include <Base/FileInfo.h>
- #include <QMainWindow>
- 
- #include <QSocketNotifier>
- 
- #include <spnav.h>
- 
--namespace {
--class RedirectStdErr
--{
--public:
--    RedirectStdErr()
--        : fi(Base::FileInfo::getTempFileName())
--        , file(stderr)
--    {
--        stderr = fopen(fi.filePath().c_str(), "w");
--    }
--    ~RedirectStdErr()
--    {
--        fclose(stderr);
--        fi.deleteFile();
--        stderr = file;
--    }
--
--private:
--    Base::FileInfo fi;
--    FILE* file;
--};
--}
--
- Gui::GuiNativeEvent::GuiNativeEvent(Gui::GUIApplicationNativeEventAware *app)
- : GuiAbstractNativeEvent(app)
- {
-@@ -72,8 +47,6 @@ Gui::GuiNativeEvent::~GuiNativeEvent()
- 
- void Gui::GuiNativeEvent::initSpaceball(QMainWindow *window)
- {
--    // tmp. redirect stderr to a file to suppress an error message from spnav_open()
--    RedirectStdErr err;
-     Q_UNUSED(window)
-     if (spnav_open() == -1) {
-         Base::Console().Log("Couldn't connect to spacenav daemon. Please ignore if you don't have a spacemouse.\n");
diff --git a/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch b/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch
deleted file mode 100644
index d4acf370ca0a4..0000000000000
--- a/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-From fe02d63c8c9b1280978be841d04e68a0a55cceb9 Mon Sep 17 00:00:00 2001
-From: Roy-043 <70520633+Roy-043@users.noreply.github.com>
-Date: Thu, 29 Dec 2022 23:20:38 +0100
-Subject: [PATCH] Draft: update inspect.getargspec to inspect.getfullargspec
- (#8101)
-
----
- src/Mod/Draft/draftguitools/gui_snapper.py | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
---- a/src/Mod/Draft/draftguitools/gui_snapper.py
-+++ b/src/Mod/Draft/draftguitools/gui_snapper.py
-@@ -1426,7 +1426,7 @@ class Snapper:
-             Gui.Snapper.off()
-             self.ui.offUi()
-             if callback:
--                if len(inspect.getargspec(callback).args) > 1:
-+                if len(inspect.getfullargspec(callback).args) > 1:
-                     obj = None
-                     if self.snapInfo and ("Object" in self.snapInfo) and self.snapInfo["Object"]:
-                         obj = App.ActiveDocument.getObject(self.snapInfo["Object"])
-@@ -1445,7 +1445,7 @@ class Snapper:
-             Gui.Snapper.off()
-             self.ui.offUi()
-             if callback:
--                if len(inspect.getargspec(callback).args) > 1:
-+                if len(inspect.getfullargspec(callback).args) > 1:
-                     callback(None, None)
-                 else:
-                     callback(None)
diff --git a/srcpkgs/freecad/template b/srcpkgs/freecad/template
index c135701e38b9a..7d5165f760bab 100644
--- a/srcpkgs/freecad/template
+++ b/srcpkgs/freecad/template
@@ -1,7 +1,7 @@
 # Template file for 'freecad'
 pkgname=freecad
-version=0.20.2
-revision=7
+version=0.21.1
+revision=2
 build_wrksrc="FreeCAD-${version}"
 build_style=cmake
 pycompile_dirs="usr/lib/${pkgname}/Mod"
@@ -24,8 +24,10 @@ makedepends="python3-devel boost-devel libxerces-c-devel zlib-devel occt-devel
  coin3-devel libshiboken2-devel libspnav-devel pyside2-tools
  liblz4-devel libpyside2-python3-devel python3-matplotlib netcdf-devel
  jsoncpp-devel qt5-devel qt5-svg-devel qt5-tools-devel qt5-webkit-devel
- qt5-xmlpatterns-devel coin3-doc glew-devel python3-pivy"
-depends="python3-matplotlib python3-pyside2-webengine python3-pivy"
+ qt5-xmlpatterns-devel coin3-doc glew-devel python3-pivy qt5-webengine-devel
+ qt5-declarative-devel qt5-webchannel-devel qt5-location-devel"
+depends="python3-matplotlib python3-pyside2-webengine python3-pivy
+ python3-GitPython python3-Markdown"
 short_desc="General purpose 3D CAD modeler"
 maintainer="yopito <pierre.bourgin@free.fr>"
 license="LGPL-2.0-or-later"
@@ -35,7 +37,7 @@ distfiles="
  https://github.com/FreeCAD/FreeCAD/archive/${version}.tar.gz
  ${SOURCEFORGE_SITE}/cxx/pycxx-${_pycxxver}.tar.gz
 "
-checksum="46922f3a477e742e1a89cd5346692d63aebb2b67af887b3e463e094a4ae055da
+checksum="e9b1fd0323f101268c7f3be52db42e4a29222f2e306ae6c4a6fc309cb418d35a
  4b91e1e1141c23fbd5039df635c4bb6e75632168548f56b83ce177193c0c98c6"
 python_version=3
 patch_args="-Np1 -d ${build_wrksrc}"

From 2733d0bb8e5654ac3b7767199dabc9964e828c90 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:47:18 -0400
Subject: [PATCH 089/112] libopenshot: revbump for ffmpeg6

---
 srcpkgs/libopenshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenshot/template b/srcpkgs/libopenshot/template
index 8e57c5f592169..7a8f4520e7892 100644
--- a/srcpkgs/libopenshot/template
+++ b/srcpkgs/libopenshot/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenshot'
 pkgname=libopenshot
 version=0.3.0
-revision=3
+revision=4
 build_style=cmake
 # Builds fail with Ruby-2.4.1
 configure_args="-DENABLE_RUBY=OFF -DUSE_SYSTEM_JSONCPP=ON"

From 715215e8d6244453c9f31fd722d9fb96cc6370e0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:10:30 -0500
Subject: [PATCH 090/112] openimageio: revbump for ffmpeg6

---
 srcpkgs/openimageio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimageio/template b/srcpkgs/openimageio/template
index 3ce3f9e49d350..27d2131bc0a61 100644
--- a/srcpkgs/openimageio/template
+++ b/srcpkgs/openimageio/template
@@ -1,7 +1,7 @@
 # Template file for 'openimageio'
 pkgname=openimageio
 version=2.4.9.0
-revision=7
+revision=8
 build_style=cmake
 build_helper=qemu
 configure_args="-DUSE_QT=0 -DUSE_PYTHON=0 -DOIIO_BUILD_TESTS=0

From 72171cc14c403b065acd1c6ea81291d21d6a4258 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:11:57 -0500
Subject: [PATCH 091/112] synfigstudio: revbump for ffmpeg6

---
 srcpkgs/synfigstudio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/synfigstudio/template b/srcpkgs/synfigstudio/template
index 09e442da9a680..2bc017cedca6b 100644
--- a/srcpkgs/synfigstudio/template
+++ b/srcpkgs/synfigstudio/template
@@ -2,7 +2,7 @@
 # Should be kept in sync with 'synfig' and 'ETL'
 pkgname=synfigstudio
 version=1.4.4
-revision=4
+revision=5
 build_style=gnu-configure
 configure_args="--disable-update-mimedb"
 hostmakedepends="pkg-config intltool gettext synfig"

From 818fb670fe3647dfd4e43d618a8459d0b4050dad Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:12:32 -0500
Subject: [PATCH 092/112] gmic: revbump for ffmpeg6

---
 srcpkgs/gmic/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gmic/template b/srcpkgs/gmic/template
index fa37651bb6dee..24d10147e3aba 100644
--- a/srcpkgs/gmic/template
+++ b/srcpkgs/gmic/template
@@ -1,7 +1,7 @@
 # Template file for 'gmic'
 pkgname=gmic
 version=3.1.6
-revision=5
+revision=6
 _zart_hash=34ebf6cce0bafb98abe57cec83c4a02cd1abeca0
 create_wrksrc=yes
 build_wrksrc="src"

From 3feba07bd24fffd2f0712e8832355056cbde081e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:10 -0500
Subject: [PATCH 093/112] mixxx: revbump for ffmpeg6

---
 srcpkgs/mixxx/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mixxx/template b/srcpkgs/mixxx/template
index 6921996e4e77b..6a79b328c1abf 100644
--- a/srcpkgs/mixxx/template
+++ b/srcpkgs/mixxx/template
@@ -1,7 +1,7 @@
 # Template file for 'mixxx'
 pkgname=mixxx
 version=2.3.3
-revision=6
+revision=7
 build_style=cmake
 configure_args="-DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="extra-cmake-modules pkg-config protobuf qt5-host-tools qt5-qmake"

From e4102fa3acec3d23043c72fc27e158a9dc943d35 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:28 -0500
Subject: [PATCH 094/112] musikcube: revbump for ffmpeg6

---
 srcpkgs/musikcube/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/musikcube/template b/srcpkgs/musikcube/template
index d9e6186e6697b..637952d50aca3 100644
--- a/srcpkgs/musikcube/template
+++ b/srcpkgs/musikcube/template
@@ -1,7 +1,7 @@
 # Template file for 'musikcube'
 pkgname=musikcube
 version=3.0.0
-revision=3
+revision=4
 build_style=cmake
 make_cmd=make
 configure_args="-DNO_NCURSESW=1"

From b56acc4fff972417faa692aecd9ab109c23a0d6b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:45 -0500
Subject: [PATCH 095/112] electron24: revbump for ffmpeg6

---
 srcpkgs/electron24/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron24/template b/srcpkgs/electron24/template
index a9c865c19c989..b8613e4362bc7 100644
--- a/srcpkgs/electron24/template
+++ b/srcpkgs/electron24/template
@@ -1,7 +1,7 @@
 # Template file for 'electron24'
 pkgname=electron24
 version=24.3.0
-revision=2
+revision=3
 _nodever=18.14.0
 _chromiumver=112.0.5615.165
 archs="x86_64* aarch64*"

From f32df0f948633066e25186640d9b0d572d2d9228 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:00 -0500
Subject: [PATCH 096/112] electron19: revbump for ffmpeg6

---
 srcpkgs/electron19/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron19/template b/srcpkgs/electron19/template
index b18bc792c8221..29fb34e254eea 100644
--- a/srcpkgs/electron19/template
+++ b/srcpkgs/electron19/template
@@ -1,7 +1,7 @@
 # Template file for 'electron19'
 pkgname=electron19
 version=19.0.8
-revision=4
+revision=5
 _nodever=16.14.2
 _chromiumver=102.0.5005.125
 archs="x86_64* aarch64* ppc64le*"

From 422743ca41b84401b13e36cedbebffe7beede819 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:13 -0500
Subject: [PATCH 097/112] wf-recorder: revbump for ffmpeg6

---
 srcpkgs/wf-recorder/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/wf-recorder/template b/srcpkgs/wf-recorder/template
index 08f986b031006..63c45cf4b814d 100644
--- a/srcpkgs/wf-recorder/template
+++ b/srcpkgs/wf-recorder/template
@@ -1,7 +1,7 @@
 # Template file for 'wf-recorder'
 pkgname=wf-recorder
 version=0.4.1
-revision=2
+revision=3
 build_style=meson
 hostmakedepends="pkg-config scdoc wayland-devel"
 makedepends="wayland-protocols wayland-devel ffmpeg-devel libgbm-devel x264-devel

From ec7ea2a87134300450dd6024ab6d8982a5464b64 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:26 -0500
Subject: [PATCH 098/112] obs: revbump for ffmpeg6

---
 srcpkgs/obs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/obs/template b/srcpkgs/obs/template
index b343f1131bfcf..a25a67433e285 100644
--- a/srcpkgs/obs/template
+++ b/srcpkgs/obs/template
@@ -1,7 +1,7 @@
 # Template file for 'obs'
 pkgname=obs
 version=30.0.0
-revision=2
+revision=3
 archs="i686* x86_64* ppc64le* aarch64* riscv64*"
 build_style=cmake
 configure_args="-DOBS_VERSION_OVERRIDE=${version} -DENABLE_JACK=ON

From c48c61d21bc40a0eb3f8fd3ae4353e4232adf201 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:36 -0500
Subject: [PATCH 099/112] mlt7: revbump for ffmpeg6

---
 srcpkgs/mlt7/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mlt7/template b/srcpkgs/mlt7/template
index 98f302ad3a516..7eb8c00fa1580 100644
--- a/srcpkgs/mlt7/template
+++ b/srcpkgs/mlt7/template
@@ -1,7 +1,7 @@
 # Template file for 'mlt7'
 pkgname=mlt7
 version=7.20.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DSWIG_PYTHON=ON -DMOD_QT6=ON"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which

From 690857171172bdbdf85ad5198720407ad85ce373 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:48 -0500
Subject: [PATCH 100/112] qt6-multimedia: revbump for ffmpeg6

---
 srcpkgs/qt6-multimedia/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-multimedia/template b/srcpkgs/qt6-multimedia/template
index 67a577e1300fe..1da626ecf515a 100644
--- a/srcpkgs/qt6-multimedia/template
+++ b/srcpkgs/qt6-multimedia/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-multimedia'
 pkgname=qt6-multimedia
 version=6.6.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DQT_FEATURE_gstreamer=ON"
 hostmakedepends="perl qt6-declarative-host-tools pkg-config qt6-shadertools"

From 2f47df55c050646214b010d82a220c8704fb7990 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:00:15 -0500
Subject: [PATCH 101/112] baresip: revbump for ffmpeg6

---
 srcpkgs/baresip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/baresip/template b/srcpkgs/baresip/template
index 12c8954ef7b9b..b16b67beab8d2 100644
--- a/srcpkgs/baresip/template
+++ b/srcpkgs/baresip/template
@@ -1,7 +1,7 @@
 # Template file for 'baresip'
 pkgname=baresip
 version=3.6.0
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config glib-devel"
 makedepends="libgsm-devel libpng-devel openssl-devel libsndfile-devel

From 5cecd4ba4fc1443797455981ab2e0258406f423c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:30 -0500
Subject: [PATCH 102/112] QMPlay2: revbump for ffmpeg6

---
 srcpkgs/QMPlay2/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/QMPlay2/template b/srcpkgs/QMPlay2/template
index 46c80f64a1349..942258ce60fb7 100644
--- a/srcpkgs/QMPlay2/template
+++ b/srcpkgs/QMPlay2/template
@@ -1,7 +1,7 @@
 # Template file for 'QMPlay2'
 pkgname=QMPlay2
 version=23.10.22
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools"
 makedepends="alsa-lib-devel ffmpeg-devel libass-devel libcdio-devel libgme-devel

From df7aaed86ae4c014ea30a37f0ccacea9582fb12d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:34 -0500
Subject: [PATCH 103/112] alsa-plugins: revbump for ffmpeg6

---
 srcpkgs/alsa-plugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/alsa-plugins/template b/srcpkgs/alsa-plugins/template
index a5708a7d82a8f..7bfdad046c483 100644
--- a/srcpkgs/alsa-plugins/template
+++ b/srcpkgs/alsa-plugins/template
@@ -1,7 +1,7 @@
 # Template file for 'alsa-plugins'
 pkgname=alsa-plugins
 version=1.2.7.1
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--disable-maemo-plugin"
 hostmakedepends="pkg-config"

From 1aa609a3f3528babc2ead862f0d865f87f4f7530 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:43 -0500
Subject: [PATCH 104/112] minidlna: revbump for ffmpeg6

---
 srcpkgs/minidlna/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/minidlna/template b/srcpkgs/minidlna/template
index 5fa929f3a0c12..742991ecd04af 100644
--- a/srcpkgs/minidlna/template
+++ b/srcpkgs/minidlna/template
@@ -1,7 +1,7 @@
 # Template file for 'minidlna'
 pkgname=minidlna
 version=1.3.3
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="
  --sbindir=/usr/bin

From a40f3655d728be5ff8a82ad067ac04c762159a5b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 17:57:47 -0500
Subject: [PATCH 105/112] mpv: revbump for ffmpeg6

---
 srcpkgs/mpv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpv/template b/srcpkgs/mpv/template
index 4948d1e332cb8..1ac1b167af189 100644
--- a/srcpkgs/mpv/template
+++ b/srcpkgs/mpv/template
@@ -1,7 +1,7 @@
 # Template file for 'mpv'
 pkgname=mpv
 version=0.36.0
-revision=4
+revision=5
 build_style=meson
 configure_args="-Dcdda=enabled -Ddvbin=enabled -Ddvdnav=enabled
  -Dlibmpv=true -Dcplugins=enabled

From d24698dfb7629f0fb0f456b825665f3a83dcc8df Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 17:59:29 -0500
Subject: [PATCH 106/112] qimgv: revbump for ffmpeg6

---
 srcpkgs/qimgv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qimgv/template b/srcpkgs/qimgv/template
index dd341dfe1bfce..8a7e1c081ef12 100644
--- a/srcpkgs/qimgv/template
+++ b/srcpkgs/qimgv/template
@@ -1,7 +1,7 @@
 # Template file for 'qimgv'
 pkgname=qimgv
 version=1.0.2
-revision=3
+revision=4
 build_style=cmake
 configure_args="$(vopt_if video -DVIDEO_SUPPORT=ON -DVIDEO_SUPPORT=OFF)
  $(vopt_if scale -DOPENCV_SUPPORT=ON -DOPENCV_SUPPORT=OFF)

From ace77cb323a58d2b947ffd74fa3b6b2177576eba Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 18:00:36 -0500
Subject: [PATCH 107/112] kfilemetadata5: revbump for ffmpeg6

---
 srcpkgs/kfilemetadata5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kfilemetadata5/template b/srcpkgs/kfilemetadata5/template
index 51fd6fec8c1c0..ad229b4c2e241 100644
--- a/srcpkgs/kfilemetadata5/template
+++ b/srcpkgs/kfilemetadata5/template
@@ -1,7 +1,7 @@
 # Template file for 'kfilemetadata5'
 pkgname=kfilemetadata5
 version=5.113.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="kcoreaddons extra-cmake-modules pkg-config qt5-host-tools qt5-qmake
  gettext kcoreaddons python3"

From 77eb0ccfc9b67d1ed66b7195cbee2bca0a3bdd31 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 8 Dec 2023 11:46:01 -0500
Subject: [PATCH 108/112] vba-m: revbump for ffmpeg6

---
 srcpkgs/vba-m/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vba-m/template b/srcpkgs/vba-m/template
index 52efeede1dcba..3e0760398905c 100644
--- a/srcpkgs/vba-m/template
+++ b/srcpkgs/vba-m/template
@@ -2,7 +2,7 @@
 pkgname=vba-m
 reverts=1292_2
 version=2.1.8
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_GTK=TRUE -DENABLE_FFMPEG=TRUE -DENABLE_LINK=TRUE -DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="gettext pkg-config unzip zip yasm wxWidgets-gtk3-devel"

From b4f9a43f855e1d855d02ae985d710cf3b80b41a4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 8 Dec 2023 11:46:19 -0500
Subject: [PATCH 109/112] dolphin-emu: revbump for ffmpeg6

---
 srcpkgs/dolphin-emu/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/dolphin-emu/template b/srcpkgs/dolphin-emu/template
index 862d3ae964eec..a7ae0efb58fb7 100644
--- a/srcpkgs/dolphin-emu/template
+++ b/srcpkgs/dolphin-emu/template
@@ -1,7 +1,7 @@
 # Template file for 'dolphin-emu'
 pkgname=dolphin-emu
 version=5.0.19368
-revision=3
+revision=4
 _dolphin_commit=dadbeb4bae7e7fa23af2b46e0add4143094dc107
 _mgba_commit=44e074a15e9651481f7f652ac006a7c9d58cbeb9
 _googletest_commit=be03d00f5f0cc3a997d1a368bee8a1fe93651f48

From 99f7f69d153e0900aacde332b6f4341180fc6965 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 19 Dec 2023 15:38:51 -0500
Subject: [PATCH 110/112] qtox: revbump for ffmpeg4

---
 srcpkgs/qtox/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtox/template b/srcpkgs/qtox/template
index bb70e7f51240a..755e4462bc013 100644
--- a/srcpkgs/qtox/template
+++ b/srcpkgs/qtox/template
@@ -1,13 +1,13 @@
 # Template file for 'qtox'
 pkgname=qtox
 version=1.17.6
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DUPDATE_CHECK=OFF
  -DGIT_DESCRIBE=${version}
  $(vopt_if snorenotify -DDESKTOP_NOTIFICATIONS=ON)"
 hostmakedepends="pkg-config qt5-host-tools qt5-devel"
-makedepends="ffmpeg-devel libexif-devel libopenal-devel libsodium-devel
+makedepends="ffmpeg4-devel libexif-devel libopenal-devel libsodium-devel
  libvpx-devel opus-devel qrencode-devel qt5-svg-devel sonnet-devel
  sqlcipher-devel toxcore-devel
  $(vopt_if snorenotify snorenotify-devel)"

From 3f7f2f661efa3b8ac6321835b97d14389f1955e3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 11 Jan 2024 11:52:00 -0500
Subject: [PATCH 111/112] arcan: revbump for ffmpeg6

---
 srcpkgs/arcan/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/arcan/template b/srcpkgs/arcan/template
index ff9091f90ebb1..030091a6cc9d0 100644
--- a/srcpkgs/arcan/template
+++ b/srcpkgs/arcan/template
@@ -2,7 +2,7 @@
 # !! keep synced with: acfgfs aclip aloadimage
 pkgname=arcan
 version=0.6.2.1
-revision=2
+revision=3
 create_wrksrc=yes
 build_wrksrc=arcan/src
 build_style=cmake

From a53ae5cde2494e2bb52b1b24955120b3903783d7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 11 Jan 2024 11:52:10 -0500
Subject: [PATCH 112/112] notcurses: revbump for ffmpeg6

---
 srcpkgs/notcurses/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/notcurses/template b/srcpkgs/notcurses/template
index 48a7463cb68eb..515f316ab4576 100644
--- a/srcpkgs/notcurses/template
+++ b/srcpkgs/notcurses/template
@@ -1,7 +1,7 @@
 # Template file for 'notcurses'
 pkgname=notcurses
 version=3.0.9
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DUSE_STATIC=ON -DUSE_QRCODEGEN=On $(vopt_bool man USE_PANDOC)"
 hostmakedepends="pkg-config $(vopt_if man pandoc)"

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (54 preceding siblings ...)
  2024-01-17 22:50 ` zlice
@ 2024-01-28 18:46 ` zlice
  2024-02-02 22:44 ` zlice
                   ` (41 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2024-01-28 18:46 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 4127 bytes --]

There is an updated pull request by zlice against master on the void-packages repository

https://github.com/zlice/void-packages ffmpeg6-split
https://github.com/void-linux/void-packages/pull/43761

ffmpeg6 split
[ci skip]


#### Testing the changes

- I tested the changes in this PR: **YES**

main testing has been vaapi in Firefox Nightly and enc/dec in Shotcut on Intel A770

#### New package

- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**

#### Local build testing

- I built this PR locally for my native architecture, **x86_64**

#### Discussion

Continuation of https://github.com/void-linux/void-packages/pull/36315

`libavresample` is deprecated, but marked as a dependency when trying to build other packages and install `ffmpeg`(6). I think the right way to handle this is make a meta package and the add to removals?


##### Commit naming / misc

~~Commits are 'dirty' right now, running with [gstreamer 1.22.1 updates](https://github.com/void-linux/void-packages/pull/42861) and [Intel OpenCL](https://github.com/void-linux/void-packages/pull/43084). This will also make [intel packages pr](https://github.com/void-linux/void-packages/pull/41132) obsolete.~~ (see Requirements below)

Maintainer for previous ffmpeg(4) was orphaned, I can put my name in there if that matters, though I don't exactly see myself keeping up on ffmpeg.

~~This updates QT5 which looks like it is usually hosted by Johnny. Not sure if there's any reason to stay there or these sources are fine.~~ Using qt5.15.11 now, revbumps and some patches.

##### STILL FFMPEG4

These are a mix of emulators, games and/or older packages.

- attract (multiple patches in master)
- ~~audacity (https://github.com/audacity/audacity/issues/2305 and https://sourceforge.net/p/portmedia/wiki/portsmf/ is 'beta')~~ (updated to 3.x, compiles with ffmpeg6)
- ccextractor (master patches? no release)
- vice
- kodi
- mlt (only dep left is flowblade)
- ~~synfig (mlt)~~ (work with mlt7, bump synfigstudio)
- tvheadend
- ssr
- ~~spek-alternative~~ (replace with spek-x)
- ppsspp
- olive
- moc
- mediastreamer
- libextractor
- idjc
- hedgewars
- ~~ffmpegthumbnailer~~ (patches for moviedecoder.xxx files)
- ~~ffmpegthumbs~~ (latest compiles)
- deadbeef
- ~~omxplayer~~ (package removed, deprecated in favor of vlc)
- qtav (fork has ffmpeg 5 patch - https://github.com/cmguo/QtAV)
- `vlc` (vlc4 will support ffmpeg5, there's a patch to build 3.x with ffmpeg5 but it will lack vaapi)
- `osg` (OpenSceneGraph plus `xine-lib`)


##### HAVE NOT BUILT YET

- ~~omxplayer (rpi only? ffmpeg4)~~ (removed)
- kodi (big, but ffmpeg4)


##### UPDATED (for ffmpeg6)

- ~~blender: update to 3.5.1~~ ~~will be revbump with~~ https://github.com/void-linux/void-packages/pull/43992
- unpaper: update to 7.0.0.
- guvcview: update to 2.0.8.
- ~~qt5: update to 5.15.8~~ updated by another PR to 5.15.11
- ~~qt5-webengine: update to 5.18.15~~ updated by another PR to 5.15.16 (some patching for ffmpeg build)
- ~~shiboken2: revbump for qt5.15.8 (patch)~~ updated by another PR to 5.15.10
- ~~python3-pyside2: update to 5.15.8 (patch)~~ updated by another PR to 5.15.10
- New package: spex-x replaces spek-alternative for ffmpeg-6.0


##### Requirements

- ~~[gstreamer 1.22.2](https://github.com/void-linux/void-packages/pull/42861)~~ - a few packages use ffmpeg-devel and require a revbump

- ~~[Intel Packages](https://github.com/void-linux/void-packages/pull/41132) [Intel Packages v2](https://github.com/void-linux/void-packages/pull/47330) - ffmpeg4 uses different libraries than 6 (libmfx / Intel-MediaSDK vs only oneVPL that Intel is moving to), both are included here~~. Using replacement oneVPL from OBS update.

- ~~[shotcut 23.05.14](https://github.com/void-linux/void-packages/pull/44260)~~

- https://github.com/void-linux/void-packages/pull/44781 will remove from this PR

A patch file from https://github.com/void-linux/void-packages/pull/43761.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ffmpeg6-split-43761.patch --]
[-- Type: text/x-diff, Size: 224207 bytes --]

From 6be228de2a098eef51e00fad2f0f2f95f985f497 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:16:56 -0400
Subject: [PATCH 001/112] ffmpeg: update to 6.0.1.

---
 common/shlibs                                 | 26 ++++---
 srcpkgs/ffmpeg/files/altivec.patch            | 60 ---------------
 .../patches/armv5tel-floating-point.patch     | 18 -----
 srcpkgs/ffmpeg/patches/binutils-2.41.patch    | 73 -------------------
 ...h-libavcodec-libsvtav1-ten_bit_format.diff | 40 ----------
 .../workaround-mesa-readeon-vaapi-bug.patch   | 28 -------
 srcpkgs/ffmpeg/template                       | 38 +++++-----
 7 files changed, 37 insertions(+), 246 deletions(-)
 delete mode 100644 srcpkgs/ffmpeg/files/altivec.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/binutils-2.41.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 delete mode 100644 srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch

diff --git a/common/shlibs b/common/shlibs
index 71f172740e5c6..c1c79647f63ca 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -389,15 +389,23 @@ libid3tag.so.0 libid3tag-0.15.1b_1
 libgif.so.7 giflib-5.1.0_1
 libImlib2.so.1 imlib2-1.4.2_1
 libmp3lame.so.0 lame-3.98.2_1
-libavdevice.so.58 libavdevice-4.0_1
-libavformat.so.58 libavformat-4.0_1
-libswscale.so.5 libswscale-4.0_1
-libswresample.so.3 libswresample-4.0_1
-libavresample.so.4 libavresample-4.0_1
-libpostproc.so.55 libpostproc-4.0_1
-libavcodec.so.58 libavcodec-4.0_1
-libavutil.so.56 libavutil-4.0_1
-libavfilter.so.7 libavfilter-4.0_1
+libavdevice.so.60 libavdevice-6.0_1
+libavformat.so.60 libavformat-6.0_1
+libswscale.so.7 libswscale-6.0_1
+libswresample.so.4 libswresample-6.0_1
+libpostproc.so.57 libpostproc-6.0_1
+libavcodec.so.60 libavcodec-6.0_1
+libavutil.so.58 libavutil-6.0_1
+libavfilter.so.9 libavfilter-6.0_1
+libavdevice.so.58 libavdevice4-4.0_1
+libavformat.so.58 libavformat4-4.0_1
+libswscale.so.5 libswscale4-4.0_1
+libswresample.so.3 libswresample4-4.0_1
+libavresample.so.4 libavresample4-4.0_1
+libpostproc.so.55 libpostproc4-4.0_1
+libavcodec.so.58 libavcodec4-4.0_1
+libavutil.so.56 libavutil4-4.0_1
+libavfilter.so.7 libavfilter4-4.0_1
 libSDL-1.2.so.0 SDL-1.2.14_1
 libSDL_image-1.2.so.0 SDL_image-1.2.10_1
 libx264.so.157 x264-20190507.2245_1
diff --git a/srcpkgs/ffmpeg/files/altivec.patch b/srcpkgs/ffmpeg/files/altivec.patch
deleted file mode 100644
index 9c57200463320..0000000000000
--- a/srcpkgs/ffmpeg/files/altivec.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-revert some altivec specific change on all ppc* except ppc64le*
-
-q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
-conditionally, for ppc* but not ppc64le* (the new code is valid for
-POWER8 VSX which LE targets as a baseline but not BE)"
-
-
-This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
----
- libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
- 1 file changed, 20 insertions(+), 4 deletions(-)
-
-diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
-index 536545293d..c1e2852adb 100644
---- a/libswscale/ppc/yuv2rgb_altivec.c
-+++ b/libswscale/ppc/yuv2rgb_altivec.c
-@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-     vector signed short R1, G1, B1;                                           \
-     vector unsigned char R, G, B;                                             \
-                                                                               \
-+    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
-+    vector unsigned char align_perm;                                          \
-+                                                                              \
-     vector signed short lCY       = c->CY;                                    \
-     vector signed short lOY       = c->OY;                                    \
-     vector signed short lCRV      = c->CRV;                                   \
-@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
-                                                                               \
-         for (j = 0; j < w / 16; j++) {                                        \
--            y0 = vec_xl(0, y1i);                                              \
-+            y1ivP = (const vector unsigned char *) y1i;                       \
-+            y2ivP = (const vector unsigned char *) y2i;                       \
-+            uivP  = (const vector unsigned char *) ui;                        \
-+            vivP  = (const vector unsigned char *) vi;                        \
-+                                                                              \
-+            align_perm = vec_lvsl(0, y1i);                                    \
-+            y0 = (vector unsigned char)                                       \
-+                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
-                                                                               \
--            y1 = vec_xl(0, y2i);                                              \
-+            align_perm = vec_lvsl(0, y2i);                                    \
-+            y1 = (vector unsigned char)                                       \
-+                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
-                                                                               \
--            u = (vector signed char) vec_xl(0, ui);                           \
-+            align_perm = vec_lvsl(0, ui);                                     \
-+            u = (vector signed char)                                          \
-+                    vec_perm(uivP[0], uivP[1], align_perm);                   \
-                                                                               \
--            v = (vector signed char) vec_xl(0, vi);                           \
-+            align_perm = vec_lvsl(0, vi);                                     \
-+            v = (vector signed char)                                          \
-+                    vec_perm(vivP[0], vivP[1], align_perm);                   \
-                                                                               \
-             u = (vector signed char)                                          \
-                     vec_sub(u,                                                \
--- 
-2.27.0
-
diff --git a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
deleted file mode 100644
index 9a55178c74f0f..0000000000000
--- a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
-+++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
-@@ -39,6 +39,15 @@
- #endif
- #include <fenv.h>
- 
-+#if (FE_ALL_EXCEPT == 0)
-+/* E.g. ARM soft float does not define these */
-+#define FE_INVALID    0
-+#define FE_DIVBYZERO  0
-+#define FE_OVERFLOW   0
-+#define FE_UNDERFLOW  0
-+#define FE_INEXACT    0
-+#endif
-+
- #if CONFIG_LIBFONTCONFIG
- #include <fontconfig/fontconfig.h>
- #endif
diff --git a/srcpkgs/ffmpeg/patches/binutils-2.41.patch b/srcpkgs/ffmpeg/patches/binutils-2.41.patch
deleted file mode 100644
index 53a596d0ee7d4..0000000000000
--- a/srcpkgs/ffmpeg/patches/binutils-2.41.patch
+++ /dev/null
@@ -1,73 +0,0 @@
-From effadce6c756247ea8bae32dc13bb3e6f464f0eb Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= <remi@remlab.net>
-Date: Sun, 16 Jul 2023 18:18:02 +0300
-Subject: [PATCH] avcodec/x86/mathops: clip constants used with shift
- instructions within inline assembly
-
-Fixes assembling with binutil as >= 2.41
-
-Signed-off-by: James Almer <jamrial@gmail.com>
----
- libavcodec/x86/mathops.h | 26 +++++++++++++++++++++++---
- 1 file changed, 23 insertions(+), 3 deletions(-)
-
-diff --git a/libavcodec/x86/mathops.h b/libavcodec/x86/mathops.h
-index 6298f5ed1983b..ca7e2dffc1076 100644
---- a/libavcodec/x86/mathops.h
-+++ b/libavcodec/x86/mathops.h
-@@ -35,12 +35,20 @@
- static av_always_inline av_const int MULL(int a, int b, unsigned shift)
- {
-     int rt, dummy;
-+    if (__builtin_constant_p(shift))
-     __asm__ (
-         "imull %3               \n\t"
-         "shrdl %4, %%edx, %%eax \n\t"
-         :"=a"(rt), "=d"(dummy)
--        :"a"(a), "rm"(b), "ci"((uint8_t)shift)
-+        :"a"(a), "rm"(b), "i"(shift & 0x1F)
-     );
-+    else
-+        __asm__ (
-+            "imull %3               \n\t"
-+            "shrdl %4, %%edx, %%eax \n\t"
-+            :"=a"(rt), "=d"(dummy)
-+            :"a"(a), "rm"(b), "c"((uint8_t)shift)
-+        );
-     return rt;
- }
- 
-@@ -113,19 +121,31 @@ __asm__ volatile(\
- // avoid +32 for shift optimization (gcc should do that ...)
- #define NEG_SSR32 NEG_SSR32
- static inline  int32_t NEG_SSR32( int32_t a, int8_t s){
-+    if (__builtin_constant_p(s))
-     __asm__ ("sarl %1, %0\n\t"
-          : "+r" (a)
--         : "ic" ((uint8_t)(-s))
-+         : "i" (-s & 0x1F)
-     );
-+    else
-+        __asm__ ("sarl %1, %0\n\t"
-+               : "+r" (a)
-+               : "c" ((uint8_t)(-s))
-+        );
-     return a;
- }
- 
- #define NEG_USR32 NEG_USR32
- static inline uint32_t NEG_USR32(uint32_t a, int8_t s){
-+    if (__builtin_constant_p(s))
-     __asm__ ("shrl %1, %0\n\t"
-          : "+r" (a)
--         : "ic" ((uint8_t)(-s))
-+         : "i" (-s & 0x1F)
-     );
-+    else
-+        __asm__ ("shrl %1, %0\n\t"
-+               : "+r" (a)
-+               : "c" ((uint8_t)(-s))
-+        );
-     return a;
- }
- 
diff --git a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
deleted file mode 100644
index aa948f7a8a2df..0000000000000
--- a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
+++ /dev/null
@@ -1,40 +0,0 @@
-#==================================================================================================
-# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
-# From: Christopher Degawa <christopher.degawa@intel.com>
-# Date: Thu, 20 Oct 2022 22:55:27 -0500
-# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
-#
-# compressed_ten_bit_format has been deprecated upstream and has no effect
-# and can be removed. Plus, technically it was never used in the first place
-# since it would require the app (ffmpeg) to set it and do additional
-# processing of the input frames.
-#
-# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
-#
-# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
-#==================================================================================================
---- a/libavcodec/libsvtav1.c
-+++ b/libavcodec/libsvtav1.c
-@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
- 
- static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
- {
--    const int    pack_mode_10bit =
--        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
--    const size_t luma_size_8bit  =
--        config->source_width * config->source_height * (1 << pack_mode_10bit);
--    const size_t luma_size_10bit =
--        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
-+    const size_t luma_size = config->source_width * config->source_height *
-+        (config->encoder_bit_depth > 8 ? 2 : 1);
- 
-     EbSvtIOFormat *in_data;
- 
--    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
-+    svt_enc->raw_size = luma_size * 3 / 2;
- 
-     // allocate buffer for in and out
-     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
--- 
-GitLab
-
diff --git a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
deleted file mode 100644
index 00e3f68a415b8..0000000000000
--- a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
-From: Rainer Hochecker <fernetmenta@online.de>
-Date: Sat, 26 Jan 2019 19:48:35 +0100
-Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
-
-This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
-It was hit frequently when watching h264 channels received via DVB-X.
-Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
----
- libavcodec/vaapi_h264.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
-index 5854587a255..f12fdc457a4 100644
---- a/libavcodec/vaapi_h264.c
-+++ b/libavcodec/vaapi_h264.c
-@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
-     H264SliceContext *sl = &h->slice_ctx[0];
-     int ret;
- 
-+    if (pic->nb_slices == 0) {
-+        ret = AVERROR_INVALIDDATA;
-+        goto finish;
-+    }
-+
-     ret = ff_vaapi_decode_issue(avctx, pic);
-     if (ret < 0)
-         goto finish;
diff --git a/srcpkgs/ffmpeg/template b/srcpkgs/ffmpeg/template
index 1ebb436135938..52fcf4d68797a 100644
--- a/srcpkgs/ffmpeg/template
+++ b/srcpkgs/ffmpeg/template
@@ -1,15 +1,15 @@
 # Template file for 'ffmpeg'
 # audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
 pkgname=ffmpeg
-version=4.4.4
-revision=6
+version=6.0.1
+revision=1
 short_desc="Decoding, encoding and streaming software"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="https://www.ffmpeg.org"
 changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
 distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
-checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+checksum=9b16b8731d78e596b4be0d720428ca42df642bb2d78342881ff7f5bc29fc9623
 
 hostmakedepends="pkg-config perl"
 makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
@@ -26,12 +26,13 @@ makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-deve
  $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
  $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
  $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
- $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers Vulkan-Tools Vulkan-ValidationLayers')
+ $(vopt_if onevpl 'oneVPL oneVPL-devel')
  $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
 depends="ffplay>=${version}_${revision}"
 
 build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
- dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec onevpl"
 build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
 desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
 desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
@@ -39,9 +40,13 @@ desc_option_sofa="Enable support for AES SOFA"
 desc_option_webp="Enable support for WebP"
 
 case "$XBPS_TARGET_MACHINE" in
-	i686*|x86_64*)
-		hostmakedepends+=" nasm"
+	i686*)
 		build_options_default+=" vaapi vdpau nvenc nvdec"
+		hostmakedepends+=" nasm"
+		;;
+	x86_64*)
+		hostmakedepends+=" nasm"
+		build_options_default+=" vaapi vdpau nvenc nvdec onevpl"
 		;;
 	ppc64*) build_options_default+=" vaapi vdpau";;
 	mips*) CFLAGS="-mnan=legacy";;
@@ -115,18 +120,19 @@ do_configure() {
 		$(vopt_enable x265 libx265) \
 		$(vopt_enable v4l2 libv4l2) \
 		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
-		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		--enable-libbs2b --enable-libvidstab \
 		$(vopt_enable dav1d libdav1d) \
 		$(vopt_enable zimg libzimg) \
 		$(vopt_enable webp libwebp) \
 		$(vopt_enable sofa libmysofa) \
 		$(vopt_enable vulkan) \
+		$(vopt_enable onevpl libvpl) \
 		$(vopt_enable drm libdrm) \
 		$(vopt_enable svtav1 libsvtav1) \
 		$(vopt_enable srt libsrt) \
 		$(vopt_enable rist librist) \
-		$(vopt_if nvenc '--enable-nvenc') \
-		$(vopt_if nvdec '--enable-nvdec')
+		$(vopt_enable nvenc nvenc) \
+		$(vopt_enable nvdec nvdec)
 }
 
 do_build() {
@@ -153,10 +159,8 @@ libavdevice_package() {
 }
 
 libavresample_package() {
-	short_desc="FFmpeg audio resampling library"
-	pkg_install() {
-		vmove "usr/lib/libavresample.so.*"
-	}
+	short_desc="Package deprecated, removal needed"
+	build_style=meta
 }
 
 libavformat_package() {
@@ -210,15 +214,13 @@ ffmpeg-devel_package() {
 		libavfilter>=${version}_${revision}
 		libpostproc>=${version}_${revision}
 		libswscale>=${version}_${revision}
-		libswresample>=${version}_${revision}
-		libavresample>=${version}_${revision}"
+		libswresample>=${version}_${revision}"
 	short_desc+=" - development files"
-
+	conflicts="ffmpeg4-devel"
 	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
 		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
 		nostrip_files="/usr/lib/libavfilter.a"
 	fi
-
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig

From 338ec786e4c4e6d4c0350c460092cc0b2b3cb60a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:14 -0400
Subject: [PATCH 002/112] openshot: revbump for ffmpeg6

---
 srcpkgs/openshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openshot/template b/srcpkgs/openshot/template
index 8f47851eef354..affb652a9d500 100644
--- a/srcpkgs/openshot/template
+++ b/srcpkgs/openshot/template
@@ -1,7 +1,7 @@
 # Template file for 'openshot'
 pkgname=openshot
 version=3.0.0
-revision=2
+revision=3
 build_style=python3-module
 hostmakedepends="python3 python3-setuptools"
 makedepends="ffmpeg-devel python3-PyQt5"

From 13502c02bfa6613635ef521fcd312d4e70e79098 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:36 -0400
Subject: [PATCH 003/112] sumo: revbump for ffmpeg6

---
 srcpkgs/sumo/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/sumo/template b/srcpkgs/sumo/template
index a3fe134aa5acc..a730afa9fafa9 100644
--- a/srcpkgs/sumo/template
+++ b/srcpkgs/sumo/template
@@ -1,7 +1,7 @@
 # Template file for 'sumo'
 pkgname=sumo
 version=1.12.0
-revision=6
+revision=7
 build_style=cmake
 hostmakedepends="libgdal-tools pkg-config swig python3-setuptools"
 makedepends="python3-devel ffmpeg-devel fox-devel gl2ps-devel libgdal-devel

From 7fd0ce818bb9f589f986f06859dc2bb928c34d3b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:56:22 -0400
Subject: [PATCH 004/112] New package: ffmpeg4-4.4.4.

---
 srcpkgs/ffmpeg4-devel                         |   1 +
 srcpkgs/ffmpeg4/files/altivec.patch           |  60 +++++
 .../patches/armv5tel-floating-point.patch     |  18 ++
 srcpkgs/ffmpeg4/patches/binutils-2.41.patch   |  73 ++++++
 ...h-libavcodec-libsvtav1-ten_bit_format.diff |  40 +++
 .../workaround-mesa-readeon-vaapi-bug.patch   |  28 +++
 srcpkgs/ffmpeg4/template                      | 234 ++++++++++++++++++
 srcpkgs/libavcodec4                           |   1 +
 srcpkgs/libavdevice4                          |   1 +
 srcpkgs/libavfilter4                          |   1 +
 srcpkgs/libavformat4                          |   1 +
 srcpkgs/libavresample4                        |   1 +
 srcpkgs/libavutil4                            |   1 +
 srcpkgs/libpostproc4                          |   1 +
 srcpkgs/libswresample4                        |   1 +
 srcpkgs/libswscale4                           |   1 +
 16 files changed, 463 insertions(+)
 create mode 120000 srcpkgs/ffmpeg4-devel
 create mode 100644 srcpkgs/ffmpeg4/files/altivec.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/binutils-2.41.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 create mode 100644 srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
 create mode 100644 srcpkgs/ffmpeg4/template
 create mode 120000 srcpkgs/libavcodec4
 create mode 120000 srcpkgs/libavdevice4
 create mode 120000 srcpkgs/libavfilter4
 create mode 120000 srcpkgs/libavformat4
 create mode 120000 srcpkgs/libavresample4
 create mode 120000 srcpkgs/libavutil4
 create mode 120000 srcpkgs/libpostproc4
 create mode 120000 srcpkgs/libswresample4
 create mode 120000 srcpkgs/libswscale4

diff --git a/srcpkgs/ffmpeg4-devel b/srcpkgs/ffmpeg4-devel
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/ffmpeg4-devel
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/ffmpeg4/files/altivec.patch b/srcpkgs/ffmpeg4/files/altivec.patch
new file mode 100644
index 0000000000000..9c57200463320
--- /dev/null
+++ b/srcpkgs/ffmpeg4/files/altivec.patch
@@ -0,0 +1,60 @@
+revert some altivec specific change on all ppc* except ppc64le*
+
+q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
+conditionally, for ppc* but not ppc64le* (the new code is valid for
+POWER8 VSX which LE targets as a baseline but not BE)"
+
+
+This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
+---
+ libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
+ 1 file changed, 20 insertions(+), 4 deletions(-)
+
+diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
+index 536545293d..c1e2852adb 100644
+--- a/libswscale/ppc/yuv2rgb_altivec.c
++++ b/libswscale/ppc/yuv2rgb_altivec.c
+@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+     vector signed short R1, G1, B1;                                           \
+     vector unsigned char R, G, B;                                             \
+                                                                               \
++    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
++    vector unsigned char align_perm;                                          \
++                                                                              \
+     vector signed short lCY       = c->CY;                                    \
+     vector signed short lOY       = c->OY;                                    \
+     vector signed short lCRV      = c->CRV;                                   \
+@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
+                                                                               \
+         for (j = 0; j < w / 16; j++) {                                        \
+-            y0 = vec_xl(0, y1i);                                              \
++            y1ivP = (const vector unsigned char *) y1i;                       \
++            y2ivP = (const vector unsigned char *) y2i;                       \
++            uivP  = (const vector unsigned char *) ui;                        \
++            vivP  = (const vector unsigned char *) vi;                        \
++                                                                              \
++            align_perm = vec_lvsl(0, y1i);                                    \
++            y0 = (vector unsigned char)                                       \
++                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
+                                                                               \
+-            y1 = vec_xl(0, y2i);                                              \
++            align_perm = vec_lvsl(0, y2i);                                    \
++            y1 = (vector unsigned char)                                       \
++                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
+                                                                               \
+-            u = (vector signed char) vec_xl(0, ui);                           \
++            align_perm = vec_lvsl(0, ui);                                     \
++            u = (vector signed char)                                          \
++                    vec_perm(uivP[0], uivP[1], align_perm);                   \
+                                                                               \
+-            v = (vector signed char) vec_xl(0, vi);                           \
++            align_perm = vec_lvsl(0, vi);                                     \
++            v = (vector signed char)                                          \
++                    vec_perm(vivP[0], vivP[1], align_perm);                   \
+                                                                               \
+             u = (vector signed char)                                          \
+                     vec_sub(u,                                                \
+-- 
+2.27.0
+
diff --git a/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
new file mode 100644
index 0000000000000..9a55178c74f0f
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
@@ -0,0 +1,18 @@
+--- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
++++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
+@@ -39,6 +39,15 @@
+ #endif
+ #include <fenv.h>
+ 
++#if (FE_ALL_EXCEPT == 0)
++/* E.g. ARM soft float does not define these */
++#define FE_INVALID    0
++#define FE_DIVBYZERO  0
++#define FE_OVERFLOW   0
++#define FE_UNDERFLOW  0
++#define FE_INEXACT    0
++#endif
++
+ #if CONFIG_LIBFONTCONFIG
+ #include <fontconfig/fontconfig.h>
+ #endif
diff --git a/srcpkgs/ffmpeg4/patches/binutils-2.41.patch b/srcpkgs/ffmpeg4/patches/binutils-2.41.patch
new file mode 100644
index 0000000000000..53a596d0ee7d4
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/binutils-2.41.patch
@@ -0,0 +1,73 @@
+From effadce6c756247ea8bae32dc13bb3e6f464f0eb Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= <remi@remlab.net>
+Date: Sun, 16 Jul 2023 18:18:02 +0300
+Subject: [PATCH] avcodec/x86/mathops: clip constants used with shift
+ instructions within inline assembly
+
+Fixes assembling with binutil as >= 2.41
+
+Signed-off-by: James Almer <jamrial@gmail.com>
+---
+ libavcodec/x86/mathops.h | 26 +++++++++++++++++++++++---
+ 1 file changed, 23 insertions(+), 3 deletions(-)
+
+diff --git a/libavcodec/x86/mathops.h b/libavcodec/x86/mathops.h
+index 6298f5ed1983b..ca7e2dffc1076 100644
+--- a/libavcodec/x86/mathops.h
++++ b/libavcodec/x86/mathops.h
+@@ -35,12 +35,20 @@
+ static av_always_inline av_const int MULL(int a, int b, unsigned shift)
+ {
+     int rt, dummy;
++    if (__builtin_constant_p(shift))
+     __asm__ (
+         "imull %3               \n\t"
+         "shrdl %4, %%edx, %%eax \n\t"
+         :"=a"(rt), "=d"(dummy)
+-        :"a"(a), "rm"(b), "ci"((uint8_t)shift)
++        :"a"(a), "rm"(b), "i"(shift & 0x1F)
+     );
++    else
++        __asm__ (
++            "imull %3               \n\t"
++            "shrdl %4, %%edx, %%eax \n\t"
++            :"=a"(rt), "=d"(dummy)
++            :"a"(a), "rm"(b), "c"((uint8_t)shift)
++        );
+     return rt;
+ }
+ 
+@@ -113,19 +121,31 @@ __asm__ volatile(\
+ // avoid +32 for shift optimization (gcc should do that ...)
+ #define NEG_SSR32 NEG_SSR32
+ static inline  int32_t NEG_SSR32( int32_t a, int8_t s){
++    if (__builtin_constant_p(s))
+     __asm__ ("sarl %1, %0\n\t"
+          : "+r" (a)
+-         : "ic" ((uint8_t)(-s))
++         : "i" (-s & 0x1F)
+     );
++    else
++        __asm__ ("sarl %1, %0\n\t"
++               : "+r" (a)
++               : "c" ((uint8_t)(-s))
++        );
+     return a;
+ }
+ 
+ #define NEG_USR32 NEG_USR32
+ static inline uint32_t NEG_USR32(uint32_t a, int8_t s){
++    if (__builtin_constant_p(s))
+     __asm__ ("shrl %1, %0\n\t"
+          : "+r" (a)
+-         : "ic" ((uint8_t)(-s))
++         : "i" (-s & 0x1F)
+     );
++    else
++        __asm__ ("shrl %1, %0\n\t"
++               : "+r" (a)
++               : "c" ((uint8_t)(-s))
++        );
+     return a;
+ }
+ 
diff --git a/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
new file mode 100644
index 0000000000000..aa948f7a8a2df
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
@@ -0,0 +1,40 @@
+#==================================================================================================
+# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
+# From: Christopher Degawa <christopher.degawa@intel.com>
+# Date: Thu, 20 Oct 2022 22:55:27 -0500
+# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
+#
+# compressed_ten_bit_format has been deprecated upstream and has no effect
+# and can be removed. Plus, technically it was never used in the first place
+# since it would require the app (ffmpeg) to set it and do additional
+# processing of the input frames.
+#
+# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
+#
+# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
+#==================================================================================================
+--- a/libavcodec/libsvtav1.c
++++ b/libavcodec/libsvtav1.c
+@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
+ 
+ static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
+ {
+-    const int    pack_mode_10bit =
+-        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
+-    const size_t luma_size_8bit  =
+-        config->source_width * config->source_height * (1 << pack_mode_10bit);
+-    const size_t luma_size_10bit =
+-        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
++    const size_t luma_size = config->source_width * config->source_height *
++        (config->encoder_bit_depth > 8 ? 2 : 1);
+ 
+     EbSvtIOFormat *in_data;
+ 
+-    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
++    svt_enc->raw_size = luma_size * 3 / 2;
+ 
+     // allocate buffer for in and out
+     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
+-- 
+GitLab
+
diff --git a/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
new file mode 100644
index 0000000000000..00e3f68a415b8
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
@@ -0,0 +1,28 @@
+From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
+From: Rainer Hochecker <fernetmenta@online.de>
+Date: Sat, 26 Jan 2019 19:48:35 +0100
+Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
+
+This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
+It was hit frequently when watching h264 channels received via DVB-X.
+Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
+---
+ libavcodec/vaapi_h264.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
+index 5854587a255..f12fdc457a4 100644
+--- a/libavcodec/vaapi_h264.c
++++ b/libavcodec/vaapi_h264.c
+@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
+     H264SliceContext *sl = &h->slice_ctx[0];
+     int ret;
+ 
++    if (pic->nb_slices == 0) {
++        ret = AVERROR_INVALIDDATA;
++        goto finish;
++    }
++
+     ret = ff_vaapi_decode_issue(avctx, pic);
+     if (ret < 0)
+         goto finish;
diff --git a/srcpkgs/ffmpeg4/template b/srcpkgs/ffmpeg4/template
new file mode 100644
index 0000000000000..9ba14bdb8ddf3
--- /dev/null
+++ b/srcpkgs/ffmpeg4/template
@@ -0,0 +1,234 @@
+# Template file for 'ffmpeg4'
+# audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
+pkgname=ffmpeg4
+version=4.4.4
+revision=1
+short_desc="Decoding, encoding and streaming software - ffmpeg4 libraries only"
+maintainer="Orphaned <orphan@voidlinux.org>"
+license="GPL-3.0-or-later"
+homepage="https://www.ffmpeg.org"
+changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
+distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
+checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+
+hostmakedepends="pkg-config perl"
+makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
+ libXext-devel libXvMC-devel libxcb-devel lame-devel libtheora-devel
+ libvorbis-devel x264-devel xvidcore-devel jack-devel SDL2-devel
+ libcdio-paranoia-devel librtmp-devel libmodplug-devel gnutls-devel
+ speex-devel celt-devel harfbuzz-devel libass-devel opus-devel ocl-icd-devel
+ libbs2b-devel libvidstab-devel vmaf-devel $(vopt_if pulseaudio pulseaudio-devel)
+ $(vopt_if vaapi libva-devel) $(vopt_if vdpau libvdpau-devel)
+ $(vopt_if x265 x265-devel) $(vopt_if v4l2 v4l-utils-devel)
+ $(vopt_if fdk_aac fdk-aac-devel) $(vopt_if vpx libvpx-devel)
+ $(vopt_if aom libaom-devel) $(vopt_if sndio sndio-devel)
+ $(vopt_if dav1d libdav1d-devel) $(vopt_if zimg zimg-devel)
+ $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
+ $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
+ $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
+
+build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
+
+desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
+desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
+desc_option_sofa="Enable support for AES SOFA"
+desc_option_webp="Enable support for WebP"
+
+case "$XBPS_TARGET_MACHINE" in
+	i686*|x86_64*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau nvenc nvdec"
+			;;
+	ppc64*) build_options_default+=" vaapi vdpau";;
+	mips*) CFLAGS="-mnan=legacy";;
+esac
+
+if [ "$XBPS_TARGET_WORDSIZE" != "32" ]; then
+	build_options_default+=" svtav1"
+fi
+
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+fi
+
+_apply_patch() {
+	local args="$1" pname="$(basename $2)"
+
+	if [ ! -f ".${pname}_done" ]; then
+		patch -N $args -i $2
+		touch .${pname}_done
+	fi
+}
+
+post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64le*) ;;
+		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
+	esac
+
+	vsed -i libavfilter/vf_libvmaf.c -e 's!/usr/local/share/model/\(vmaf_v0.6.1\).pkl!/usr/share/vmaf/\1.json!'
+}
+
+do_configure() {
+	# Fix gcc on x86_64-musl only
+	if [ "$XBPS_TARGET_MACHINE" = "x86_64-musl" ]; then
+		vsed -i configure -e "s;_cflags_speed='-O3';_cflags_speed='-O2';"
+	fi
+
+	if [ "$CROSS_BUILD" ]; then
+		case "$XBPS_TARGET_MACHINE" in
+			arm*) _arch="arm";;
+			aarch64*) _arch="aarch64";;
+			mips*) _arch="mips";;
+			ppc64*) _arch="ppc64";;
+			ppc*) _arch="ppc";;
+			*) _arch="${XBPS_TARGET_MACHINE%%-musl}";;
+		esac
+
+		_args+=" --enable-cross-compile
+			--sysroot=$XBPS_CROSS_BASE
+			--cross-prefix=${XBPS_CROSS_TRIPLET}-
+			--target-os=linux --arch=${_arch}"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc|ppc-musl) _args+=" --disable-altivec";;
+	esac
+
+	if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+		_args+=" --extra-libs=-latomic"
+	fi
+
+	./configure --prefix=/usr --disable-debug --enable-gpl --enable-gnutls \
+		--disable-stripping \
+		--enable-libcdio --enable-version3 --enable-runtime-cpudetect \
+		--enable-libmp3lame --enable-libvorbis --enable-libxvid \
+		--enable-libx264 $(vopt_enable vpx libvpx) --enable-libtheora \
+		--enable-shared --enable-static --enable-libxcb \
+		$(vopt_enable pulseaudio libpulse) --enable-libfreetype --enable-libmodplug \
+		--enable-libspeex --enable-libcelt --enable-libass \
+		--enable-libopus --enable-librtmp --enable-libjack \
+		$(vopt_if fdk_aac '--enable-nonfree --enable-libfdk-aac') \
+		--disable-libopencore_amrnb --disable-libopencore_amrwb \
+		--disable-libopenjpeg \
+		--enable-postproc --enable-opencl ${_args} --enable-libvmaf ${_args} \
+		$(vopt_enable x265 libx265) \
+		$(vopt_enable v4l2 libv4l2) \
+		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
+		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		$(vopt_enable dav1d libdav1d) \
+		$(vopt_enable zimg libzimg) \
+		$(vopt_enable webp libwebp) \
+		$(vopt_enable sofa libmysofa) \
+		$(vopt_enable vulkan) \
+		$(vopt_enable drm libdrm) \
+		$(vopt_enable svtav1 libsvtav1) \
+		$(vopt_enable srt libsrt) \
+		$(vopt_enable rist librist) \
+		$(vopt_if nvenc '--enable-nvenc') \
+		$(vopt_if nvdec '--enable-nvdec')
+}
+
+do_build() {
+	make ${makejobs}
+	make doc/ff{mpeg,play}.1
+}
+
+do_install() {
+	make DESTDIR=${DESTDIR} install install-man
+	rm -rf ${DESTDIR}/usr/bin
+}
+
+libavcodec4_package() {
+	short_desc="FFmpeg codec library"
+	pkg_install() {
+		vmove "usr/lib/libavcodec.so.*"
+	}
+}
+
+libavdevice4_package() {
+	short_desc="FFmpeg device handling library"
+	pkg_install() {
+		vmove "usr/lib/libavdevice.so.*"
+	}
+}
+
+libavresample4_package() {
+	short_desc="FFmpeg audio resampling library"
+	pkg_install() {
+		vmove "usr/lib/libavresample.so.*"
+	}
+}
+
+libavformat4_package() {
+	short_desc="FFmpeg file format library"
+	pkg_install() {
+		vmove "usr/lib/libavformat.so.*"
+	}
+}
+
+libavutil4_package() {
+	short_desc="FFmpeg utility library"
+	pkg_install() {
+		vmove "usr/lib/libavutil.so.*"
+	}
+}
+
+libavfilter4_package() {
+	short_desc="FFmpeg audio/video filter library"
+	pkg_install() {
+		vmove "usr/lib/libavfilter.so.*"
+	}
+}
+
+libpostproc4_package() {
+	short_desc="FFmpeg video postprocessing library"
+	pkg_install() {
+		vmove "usr/lib/libpostproc.so.*"
+	}
+}
+
+libswscale4_package() {
+	short_desc="FFmpeg video scaling library"
+	pkg_install() {
+		vmove "usr/lib/libswscale.so.*"
+	}
+}
+
+libswresample4_package() {
+	short_desc="FFmpeg video resampling library"
+	pkg_install() {
+		vmove "usr/lib/libswresample.so.*"
+	}
+}
+
+ffmpeg4-devel_package() {
+	depends="
+		libavcodec4>=${version}_${revision}
+		libavdevice4>=${version}_${revision}
+		libavformat4>=${version}_${revision}
+		libavutil4>=${version}_${revision}
+		libavfilter4>=${version}_${revision}
+		libpostproc4>=${version}_${revision}
+		libswscale4>=${version}_${revision}
+		libswresample4>=${version}_${revision}
+		libavresample4>=${version}_${revision}"
+	short_desc+=" - development files"
+	conflicts="ffmpeg-devel"
+	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
+		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
+		nostrip_files="/usr/lib/libavfilter.a"
+	fi
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.a"
+		vmove "usr/lib/*.so"
+		vmove usr/share/ffmpeg/examples
+		vmove usr/share/man/man3
+	}
+}
diff --git a/srcpkgs/libavcodec4 b/srcpkgs/libavcodec4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavcodec4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavdevice4 b/srcpkgs/libavdevice4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavdevice4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavfilter4 b/srcpkgs/libavfilter4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavfilter4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavformat4 b/srcpkgs/libavformat4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavformat4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavresample4 b/srcpkgs/libavresample4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavutil4 b/srcpkgs/libavutil4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavutil4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libpostproc4 b/srcpkgs/libpostproc4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libpostproc4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswresample4 b/srcpkgs/libswresample4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libswresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswscale4 b/srcpkgs/libswscale4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libswscale4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file

From 686e7bfbd1b25cb6dbdd447a22f3fbfb23495907 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:04 -0400
Subject: [PATCH 005/112] opencv: update to 4.7.0.

---
 common/shlibs           | 104 ++++++++++++++++++++--------------------
 srcpkgs/opencv/template |   8 ++--
 2 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index c1c79647f63ca..e8b9e5e974fe7 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2070,58 +2070,58 @@ libcapstone.so.5 capstone-5.0.1_1
 libhavege.so.2 libhaveged-1.9.11_1
 libnih.so.1 libnih-1.0.3_1
 libnih-dbus.so.1 libnih-1.0.3_1
-libopencv_quality.so.406 libopencv-4.6.0_1
-libopencv_reg.so.406 libopencv-4.6.0_1
-libopencv_surface_matching.so.406 libopencv-4.6.0_1
-libopencv_xphoto.so.406 libopencv-4.6.0_1
-libopencv_freetype.so.406 libopencv-4.6.0_1
-libopencv_fuzzy.so.406 libopencv-4.6.0_1
-libopencv_hfs.so.406 libopencv-4.6.0_1
-libopencv_img_hash.so.406 libopencv-4.6.0_1
-libopencv_line_descriptor.so.406 libopencv-4.6.0_1
-libopencv_saliency.so.406 libopencv-4.6.0_1
-libopencv_structured_light.so.406 libopencv-4.6.0_1
-libopencv_aruco.so.406 libopencv-4.6.0_1
-libopencv_bgsegm.so.406 libopencv-4.6.0_1
-libopencv_bioinspired.so.406 libopencv-4.6.0_1
-libopencv_ccalib.so.406 libopencv-4.6.0_1
-libopencv_face.so.406 libopencv-4.6.0_1
-libopencv_tracking.so.406 libopencv-4.6.0_1
-libopencv_xfeatures2d.so.406 libopencv-4.6.0_1
-libopencv_optflow.so.406 libopencv-4.6.0_1
-libopencv_ximgproc.so.406 libopencv-4.6.0_1
-libopencv_plot.so.406 libopencv-4.6.0_1
-libopencv_text.so.406 libopencv-4.6.0_1
-libopencv_ml.so.406 libopencv-4.6.0_1
-libopencv_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn.so.406 libopencv-4.6.0_1
-libopencv_shape.so.406 libopencv-4.6.0_1
-libopencv_stitching.so.406 libopencv-4.6.0_1
-libopencv_photo.so.406 libopencv-4.6.0_1
-libopencv_video.so.406 libopencv-4.6.0_1
-libopencv_calib3d.so.406 libopencv-4.6.0_1
-libopencv_features2d.so.406 libopencv-4.6.0_1
-libopencv_flann.so.406 libopencv-4.6.0_1
-libopencv_highgui.so.406 libopencv-4.6.0_1
-libopencv_videoio.so.406 libopencv-4.6.0_1
-libopencv_imgcodecs.so.406 libopencv-4.6.0_1
-libopencv_imgproc.so.406 libopencv-4.6.0_1
-libopencv_core.so.406 libopencv-4.6.0_1
-libopencv_superres.so.406 libopencv-4.6.0_1
-libopencv_videostab.so.406 libopencv-4.6.0_1
-libopencv_gapi.so.406 libopencv-4.6.0_1
-libopencv_xobjdetect.so.406 libopencv-4.6.0_1
-libopencv_datasets.so.406 libopencv-4.6.0_1
-libopencv_dnn_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn_superres.so.406 libopencv-4.6.0_1
-libopencv_dpm.so.406 libopencv-4.6.0_1
-libopencv_phase_unwrapping.so.406 libopencv-4.6.0_1
-libopencv_stereo.so.406 libopencv-4.6.0_1
-libopencv_rapid.so.406 libopencv-4.6.0_1
-libopencv_intensity_transform.so.406 libopencv-4.6.0_1
-libopencv_alphamat.so.406 libopencv-4.6.0_1
-libopencv_barcode.so.406 libopencv-4.6.0_1
-libopencv_mcc.so.406 libopencv-4.6.0_1
+libopencv_quality.so.407 libopencv-4.7.0_1
+libopencv_reg.so.407 libopencv-4.7.0_1
+libopencv_surface_matching.so.407 libopencv-4.7.0_1
+libopencv_xphoto.so.407 libopencv-4.7.0_1
+libopencv_freetype.so.407 libopencv-4.7.0_1
+libopencv_fuzzy.so.407 libopencv-4.7.0_1
+libopencv_hfs.so.407 libopencv-4.7.0_1
+libopencv_img_hash.so.407 libopencv-4.7.0_1
+libopencv_line_descriptor.so.407 libopencv-4.7.0_1
+libopencv_saliency.so.407 libopencv-4.7.0_1
+libopencv_structured_light.so.407 libopencv-4.7.0_1
+libopencv_aruco.so.407 libopencv-4.7.0_1
+libopencv_bgsegm.so.407 libopencv-4.7.0_1
+libopencv_bioinspired.so.407 libopencv-4.7.0_1
+libopencv_ccalib.so.407 libopencv-4.7.0_1
+libopencv_face.so.407 libopencv-4.7.0_1
+libopencv_tracking.so.407 libopencv-4.7.0_1
+libopencv_xfeatures2d.so.407 libopencv-4.7.0_1
+libopencv_optflow.so.407 libopencv-4.7.0_1
+libopencv_ximgproc.so.407 libopencv-4.7.0_1
+libopencv_plot.so.407 libopencv-4.7.0_1
+libopencv_text.so.407 libopencv-4.7.0_1
+libopencv_ml.so.407 libopencv-4.7.0_1
+libopencv_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn.so.407 libopencv-4.7.0_1
+libopencv_shape.so.407 libopencv-4.7.0_1
+libopencv_stitching.so.407 libopencv-4.7.0_1
+libopencv_photo.so.407 libopencv-4.7.0_1
+libopencv_video.so.407 libopencv-4.7.0_1
+libopencv_calib3d.so.407 libopencv-4.7.0_1
+libopencv_features2d.so.407 libopencv-4.7.0_1
+libopencv_flann.so.407 libopencv-4.7.0_1
+libopencv_highgui.so.407 libopencv-4.7.0_1
+libopencv_videoio.so.407 libopencv-4.7.0_1
+libopencv_imgcodecs.so.407 libopencv-4.7.0_1
+libopencv_imgproc.so.407 libopencv-4.7.0_1
+libopencv_core.so.407 libopencv-4.7.0_1
+libopencv_superres.so.407 libopencv-4.7.0_1
+libopencv_videostab.so.407 libopencv-4.7.0_1
+libopencv_gapi.so.407 libopencv-4.7.0_1
+libopencv_xobjdetect.so.407 libopencv-4.7.0_1
+libopencv_datasets.so.407 libopencv-4.7.0_1
+libopencv_dnn_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn_superres.so.407 libopencv-4.7.0_1
+libopencv_dpm.so.407 libopencv-4.7.0_1
+libopencv_phase_unwrapping.so.407 libopencv-4.7.0_1
+libopencv_stereo.so.407 libopencv-4.7.0_1
+libopencv_rapid.so.407 libopencv-4.7.0_1
+libopencv_intensity_transform.so.407 libopencv-4.7.0_1
+libopencv_alphamat.so.407 libopencv-4.7.0_1
+libopencv_barcode.so.407 libopencv-4.7.0_1
+libopencv_mcc.so.407 libopencv-4.7.0_1
 libuniconf.so.4.6 wvstreams-4.6.1_20
 libwvbase.so.4.6 wvstreams-4.6.1_20
 libwvutils.so.4.6 wvstreams-4.6.1_20
diff --git a/srcpkgs/opencv/template b/srcpkgs/opencv/template
index aea4bfc3a265c..ce94de9424d18 100644
--- a/srcpkgs/opencv/template
+++ b/srcpkgs/opencv/template
@@ -1,7 +1,7 @@
 # Template file for 'opencv'
 pkgname=opencv
-version=4.6.0
-revision=6
+version=4.7.0
+revision=1
 create_wrksrc=yes
 build_wrksrc=${pkgname}-${version}
 build_style=cmake
@@ -24,8 +24,8 @@ homepage="https://opencv.org"
 changelog="https://github.com/opencv/opencv/wiki/ChangeLog"
 distfiles="https://github.com/opencv/opencv/archive/${version}.tar.gz
  https://github.com/opencv/opencv_contrib/archive/${version}.tar.gz>contrib.tar.gz"
-checksum="1ec1cba65f9f20fe5a41fda1586e01c70ea0c9a6d7b67c9e13edf0cfe2239277
- 1777d5fd2b59029cf537e5fd6f8aa68d707075822f90bde683fcde086f85f7a7"
+checksum="8df0079cdbe179748a18d44731af62a245a45ebf5085223dc03133954c662973
+ 42df840cf9055e59d0e22c249cfb19f04743e1bdad113d31b1573d3934d62584"
 patch_args="-Np1 -d ${build_wrksrc}"
 # tests hang indenfinitely, even with test data included
 make_check=no

From 9e143ad23881e6a2cb40da2a9525e3e522eaf2c3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 006/112] actiona: revbump for opencv-4.7.0

---
 srcpkgs/actiona/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/actiona/template b/srcpkgs/actiona/template
index cf5f0b7a2ae61..0d899311e6df7 100644
--- a/srcpkgs/actiona/template
+++ b/srcpkgs/actiona/template
@@ -1,7 +1,7 @@
 # Template file for 'actiona'
 pkgname=actiona
 version=3.10.1
-revision=2
+revision=3
 build_style=qmake
 configure_args="PKGCONFIG_OPENCV=opencv4"
 hostmakedepends="pkg-config qt5-plugin-mysql qt5-qmake qt5-host-tools"

From 2b0bd3c555d5df6b69394b2afa2fcf60363dd084 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 007/112] retroshare: revbump for opencv-4.7.0

---
 srcpkgs/retroshare/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroshare/template b/srcpkgs/retroshare/template
index bb17569277a7f..49e2c1cbe8a53 100644
--- a/srcpkgs/retroshare/template
+++ b/srcpkgs/retroshare/template
@@ -1,7 +1,7 @@
 # Template file for 'retroshare'
 pkgname=retroshare
 version=0.6.6
-revision=3
+revision=4
 build_style=qmake
 #XXX broadcast feature requires an ancient udp-discovery-cpp which either needs
 # to be fetched+patched (FTBFS) here or packaged :/

From e55c5fafeded4f9c03ae9ec2e342a3bd8e96b5e1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 008/112] waifu2x-converter-cpp: revbump for opencv-4.7.0

---
 srcpkgs/waifu2x-converter-cpp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waifu2x-converter-cpp/template b/srcpkgs/waifu2x-converter-cpp/template
index 361b8a23b9497..c5ac17eb54ea4 100644
--- a/srcpkgs/waifu2x-converter-cpp/template
+++ b/srcpkgs/waifu2x-converter-cpp/template
@@ -1,7 +1,7 @@
 # Template file for 'waifu2x-converter-cpp'
 pkgname=waifu2x-converter-cpp
 version=5.2.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DINSTALL_MODELS=ON"
 hostmakedepends="pkg-config"

From 397a1bb4e035539d7a2803033d24dfe5a7615d1e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:38 -0400
Subject: [PATCH 009/112] vlc: revbump for ffmpeg4

---
 srcpkgs/vlc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vlc/template b/srcpkgs/vlc/template
index bdd0cc414dc1a..d2afcc6c22129 100644
--- a/srcpkgs/vlc/template
+++ b/srcpkgs/vlc/template
@@ -25,7 +25,7 @@ lib32disabled=yes
 hostmakedepends="automake libtool pkg-config flex gettext libgcrypt-devel
  live555-devel gettext-devel $(vopt_if lua lua52) $(vopt_if chromecast protobuf)"
 makedepends="
- avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg-devel freefont-ttf
+ avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg4-devel freefont-ttf
  gnutls-devel jack-devel liba52-devel libass-devel libbluray-devel
  libcdio-devel libdca-devel libdvbpsi-devel libdvdnav-devel libmad-devel
  libmatroska-devel libmodplug-devel libmpcdec-devel libmpeg2-devel

From 4141d81bfb135fa9ec940b9fb851761f8b7a1825 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:55 -0400
Subject: [PATCH 010/112] osg: revbump for ffmpeg4

---
 srcpkgs/osg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/osg/template b/srcpkgs/osg/template
index a9ebbd287933b..755793f7e11bf 100644
--- a/srcpkgs/osg/template
+++ b/srcpkgs/osg/template
@@ -8,7 +8,7 @@ build_helper="qemu"
 configure_args="-DLIB_POSTFIX="
 hostmakedepends="pkg-config xrandr"
 makedepends="MesaLib-devel gtkglext-devel libcurl-devel giflib-devel librsvg-devel
- jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg-devel xine-lib-devel
+ jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg4-devel xine-lib-devel
  SDL2-devel gst-plugins-base1-devel
  $(vopt_if openexr libopenexr-devel)
  $(vopt_if poppler poppler-glib-devel)

From 0177c25657755196c2203ff994ef636b33127c57 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:13 -0400
Subject: [PATCH 011/112] xine-lib: revbump for ffmpeg4

---
 srcpkgs/xine-lib/template | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/xine-lib/template b/srcpkgs/xine-lib/template
index 3be4d08eac77a..ed6194c17d11e 100644
--- a/srcpkgs/xine-lib/template
+++ b/srcpkgs/xine-lib/template
@@ -1,14 +1,14 @@
 # Template file for 'xine-lib'
 pkgname=xine-lib
-version=1.2.12
-revision=3
+version=1.2.13
+revision=1
 build_style=gnu-configure
 configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
  --disable-oss"
 hostmakedepends="automake gettext-devel libtool pkg-config perl"
 makedepends="
  zlib-devel alsa-lib-devel libxcb-devel libSM-devel libXext-devel libXv-devel
- libXvMC-devel liba52-devel libmad-devel ffmpeg-devel pulseaudio-devel
+ libXvMC-devel liba52-devel libmad-devel ffmpeg4-devel pulseaudio-devel
  jack-devel samba-devel libflac-devel libmodplug-devel libmpcdec-devel
  speex-devel libtheora-devel libvorbis-devel libdca-devel faad2-devel
  libcdio-devel libbluray-devel aalib-devel libcaca-devel libXinerama-devel
@@ -19,7 +19,7 @@ license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="http://www.xine-project.org"
 changelog="https://sourceforge.net/projects/xine/files/xine-lib/${version}/README.txt/view"
 distfiles="${SOURCEFORGE_SITE}/xine/${pkgname}-${version}.tar.xz"
-checksum=d606270468e1540c2a89c0d7f5fdf11e17ecc0c2698cc0bcb1065ff26abee098
+checksum=5f10d6d718a4a51c17ed1b32b031d4f9b80b061e8276535b2be31e5ac4b75e6f
 
 case "$XBPS_TARGET_MACHINE" in
 	i686-musl)

From 120bf097895dfe148a583c09e89314f6efb0fafa Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 012/112] attract: revbump for ffmpeg4

---
 srcpkgs/attract/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/attract/template b/srcpkgs/attract/template
index 24017d2bacc24..e760bf0d18aec 100644
--- a/srcpkgs/attract/template
+++ b/srcpkgs/attract/template
@@ -6,7 +6,7 @@ build_style=gnu-makefile
 make_build_args="VERBOSE=1"
 make_use_env=yes
 hostmakedepends="pkg-config"
-makedepends="SFML-devel ffmpeg-devel fontconfig-devel glu-devel libarchive-devel
+makedepends="SFML-devel ffmpeg4-devel fontconfig-devel glu-devel libarchive-devel
  libcurl-devel libjpeg-turbo-devel xine-lib rapidjson libXrandr-devel"
 depends="git"
 short_desc="Attract-Mode is a graphical frontend for emulators"

From e2164608743848e98e0e9a4f2d3144680194f851 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 013/112] aubio: revbump for ffmpeg6

---
 srcpkgs/aubio/patches/ffmpeg5.patch | 25 +++++++++++++++++++++++++
 srcpkgs/aubio/template              |  2 +-
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/aubio/patches/ffmpeg5.patch

diff --git a/srcpkgs/aubio/patches/ffmpeg5.patch b/srcpkgs/aubio/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..aace41a6e6d9a
--- /dev/null
+++ b/srcpkgs/aubio/patches/ffmpeg5.patch
@@ -0,0 +1,25 @@
+From 8a05420e5dd8c7b8b2447f82dc919765876511b3 Mon Sep 17 00:00:00 2001
+From: Paul Brossier <piem@piem.org>
+Date: Tue, 25 Jan 2022 18:30:27 +0100
+Subject: [PATCH] [source_avcodec] define FF_API_LAVF_AVCTX for libavcodec >
+ 59, thx @berolinux (closes gh-353)
+
+---
+ src/io/source_avcodec.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/io/source_avcodec.c b/src/io/source_avcodec.c
+index e0ae93b5..1421bd9a 100644
+--- a/src/io/source_avcodec.c
++++ b/src/io/source_avcodec.c
+@@ -68,6 +68,10 @@
+ #define AUBIO_AVCODEC_MAX_BUFFER_SIZE AV_INPUT_BUFFER_MIN_SIZE
+ #endif
+ 
++#if LIBAVCODEC_VERSION_MAJOR >= 59
++#define FF_API_LAVF_AVCTX 1
++#endif
++
+ struct _aubio_source_avcodec_t {
+   uint_t hop_size;
+   uint_t samplerate;
diff --git a/srcpkgs/aubio/template b/srcpkgs/aubio/template
index ad1c4b2569917..7d875cc02541a 100644
--- a/srcpkgs/aubio/template
+++ b/srcpkgs/aubio/template
@@ -1,7 +1,7 @@
 # Template file for 'aubio'
 pkgname=aubio
 version=0.4.9
-revision=1
+revision=2
 build_style=waf3
 # XXX lash, pure and swig support.
 hostmakedepends="pkg-config txt2man"

From 37ee80253736a81258c9b0a057473fbe05f344fc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 014/112] audacious-plugins: revbump for ffmpeg6

---
 .../audacious-plugins/patches/ffmpeg5.patch   | 43 +++++++++++++++++++
 srcpkgs/audacious-plugins/template            |  2 +-
 2 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/audacious-plugins/patches/ffmpeg5.patch

diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg5.patch b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..4e5e34099d71c
--- /dev/null
+++ b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
@@ -0,0 +1,43 @@
+commit 298aa371c56c2f52c25a33d9bdec4918b11cebdc
+Author: tibequadorian <tibequadorian@posteo.de>
+Date:   Sat Mar 19 18:40:12 2022 +0100
+
+    audacious-plugins: rebuild against ffmpeg-5.0
+
+diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+new file mode 100644
+index 0000000000..617c11215b
+--- /dev/null
++++ b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+@@ -0,0 +1,31 @@
++From f60beb400eeb1e4778bbfd738bc4a4ccef3de539 Mon Sep 17 00:00:00 2001
++From: John Lindgren <john@jlindgren.net>
++Date: Sat, 5 Mar 2022 12:05:34 -0500
++Subject: [PATCH] Fix build with FFmpeg 5.0
++
++---
++ src/ffaudio/ffaudio-core.cc | 4 ++--
++ 1 file changed, 2 insertions(+), 2 deletions(-)
++
++diff --git a/src/ffaudio/ffaudio-core.cc b/src/ffaudio/ffaudio-core.cc
++index 16dc63e3a..a2b95fd6c 100644
++--- a/src/ffaudio/ffaudio-core.cc
+++++ b/src/ffaudio/ffaudio-core.cc
++@@ -274,7 +274,7 @@ static AVInputFormat * get_format_by_content (const char * name, VFSFile & file)
++         AVProbeData d = {name, buf, filled};
++         score = target;
++ 
++-        f = av_probe_input_format2 (& d, true, & score);
+++        f = (AVInputFormat *) av_probe_input_format2 (& d, true, & score);
++         if (f)
++             break;
++ 
++@@ -347,7 +347,7 @@ static bool find_codec (AVFormatContext * c, CodecInfo * cinfo)
++ #endif
++         if (stream && stream->codecpar && stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
++         {
++-            AVCodec * codec = avcodec_find_decoder (stream->codecpar->codec_id);
+++            AVCodec * codec = (AVCodec *) avcodec_find_decoder (stream->codecpar->codec_id);
++ 
++             if (codec)
++             {
diff --git a/srcpkgs/audacious-plugins/template b/srcpkgs/audacious-plugins/template
index 05e53a9adf78f..4b1968e03de78 100644
--- a/srcpkgs/audacious-plugins/template
+++ b/srcpkgs/audacious-plugins/template
@@ -2,7 +2,7 @@
 #Keep in sync with audacious!
 pkgname=audacious-plugins
 version=4.3.1
-revision=3
+revision=4
 build_style=meson
 configure_args="$(vopt_bool gtk3 gtk) $(vopt_bool gtk3)
  $(vopt_bool qt) $(vopt_bool qt qt6)"

From 23876fc6b190de4485bb063a8e17fd5e1dd2362f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 015/112] audacity: revbump for ffmpeg6

---
 srcpkgs/audacity/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/audacity/template b/srcpkgs/audacity/template
index 7b838119ab261..84b49305edcef 100644
--- a/srcpkgs/audacity/template
+++ b/srcpkgs/audacity/template
@@ -1,7 +1,7 @@
 # Template file for 'audacity'
 pkgname=audacity
 version=3.4.2
-revision=1
+revision=2
 build_style=cmake
 build_helper="cmake-wxWidgets-gtk3 qemu"
 configure_args="-Daudacity_use_ffmpeg=loaded -Daudacity_lib_preference=system

From 0f7d43ef41f41ceaf9e8993d42bba29ca0786fd3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 016/112] avidemux: revbump for ffmpeg6

---
 srcpkgs/avidemux/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/avidemux/template b/srcpkgs/avidemux/template
index 253a0243e2259..557285982d2b8 100644
--- a/srcpkgs/avidemux/template
+++ b/srcpkgs/avidemux/template
@@ -1,7 +1,7 @@
 # Template file for 'avidemux'
 pkgname=avidemux
 version=2.8.0
-revision=2
+revision=3
 # Can't be compiled for aarch64, arm* or mips*
 archs="x86_64* i686*"
 hostmakedepends="cmake pkg-config qt5-host-tools qt5-devel tar yasm"

From 8bded515257a0e2315254d4f5b92f0d39c6c9266 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 017/112] blender: revbump for ffmpeg6

---
 srcpkgs/blender/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index 1dc61ec9d29d8..be35fac744876 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -9,8 +9,8 @@ configure_args="-DWITH_INSTALL_PORTABLE=OFF -DWITH_PYTHON_INSTALL=OFF
  -DWITH_JACK=ON -DWITH_CODEC_FFMPEG=ON -DWITH_CODEC_SNDFILE=ON -DWITH_OPENMP=ON
  -DWITH_FFTW3=ON -DWITH_MOD_OCEANSIM=ON -DWITH_CYCLES_EMBREE=OFF -DWITH_OPENCOLORIO=ON
  -DWITH_IMAGE_OPENEXR=ON -DWITH_IMAGE_OPENJPEG=ON -DWITH_OPENSUBDIV=ON
- -DWITH_OPENCOLLADA=ON -DWITH_SYSTEM_GLEW=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
- -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_LIBDECOR=ON
+ -DWITH_OPENCOLLADA=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
+ -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_WAYLAND_LIBDECOR=ON
  -DWITH_BUILDINFO=OFF -DPYTHON_VERSION=${py3_ver} -DPYTHON_LIBPATH=/usr/lib
  -DPYTHON_LIBRARY=python${py3_ver}${py3_abiver} -DPYTHON_INCLUDE_DIRS=/${py3_inc}
  -DWITH_SYSTEM_LZO=ON -DWITH_SYSTEM_EIGEN3=ON -DWITH_SYSTEM_FREETYPE=ON"

From cbbb0b937b005db039b43425cd1f1c19ccb776bf Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 018/112] cantata: revbump for ffmpeg6

---
 srcpkgs/cantata/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cantata/template b/srcpkgs/cantata/template
index 4b417d80d5c2d..8a90aaa4c07a2 100644
--- a/srcpkgs/cantata/template
+++ b/srcpkgs/cantata/template
@@ -1,7 +1,7 @@
 # Template file for 'cantata'
 pkgname=cantata
 version=2.5.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools qt5-tools"
 makedepends="qt5-devel qt5-tools-devel qt5-svg-devel qt5-xmlpatterns-devel

From 4eca4f80d0c863907d76a6b7ecefb681c885562b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 019/112] ccextractor: revbump for ffmpeg4

---
 srcpkgs/ccextractor/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ccextractor/template b/srcpkgs/ccextractor/template
index 84059ffd02398..3ca8ec45d6989 100644
--- a/srcpkgs/ccextractor/template
+++ b/srcpkgs/ccextractor/template
@@ -6,7 +6,7 @@ build_wrksrc="linux"
 build_style=gnu-configure
 configure_args="--enable-ocr --enable-hardsubx"
 hostmakedepends="automake pkg-config"
-makedepends="leptonica-devel tesseract-ocr-devel ffmpeg-devel"
+makedepends="leptonica-devel tesseract-ocr-devel ffmpeg4-devel"
 short_desc="Extract subtitles from video streams"
 maintainer="newbluemoon <blaumolch@mailbox.org>"
 license="GPL-2.0-or-later"

From a2be12f655c6a4f7e909234f0b3b7b0652396781 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 020/112] chromaprint: revbump for ffmpeg6

---
 srcpkgs/chromaprint/patches/ffmpeg5.patch | 569 ++++++++++++++++++++++
 srcpkgs/chromaprint/template              |   2 +-
 2 files changed, 570 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromaprint/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromaprint/patches/ffmpeg5.patch b/srcpkgs/chromaprint/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..a9fd307a23c8a
--- /dev/null
+++ b/srcpkgs/chromaprint/patches/ffmpeg5.patch
@@ -0,0 +1,569 @@
+From 8ccad6937177b1b92e40ab8f4447ea27bac009a7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= <lalinsky@gmail.com>
+Date: Fri, 4 Nov 2022 21:47:38 +0100
+Subject: [PATCH] Use FFmpeg 5.x (#120)
+
+* Use FFmpeg 5.1.2 for CI builds
+
+* Build on Ubuntu 20.04
+
+* Upgrade code to FFmpeg 5.x APIs
+
+* Only set FFmpeg include dirs if building tools
+
+* No longer needed
+
+* Use ubuntu 20.04
+---
+ .github/workflows/build.yml                   |   6 +-
+ CMakeLists.txt                                |  16 --
+ package/build.sh                              |   4 +-
+ src/audio/ffmpeg_audio_processor.h            |   2 -
+ src/audio/ffmpeg_audio_processor_avresample.h |  72 -------
+ src/audio/ffmpeg_audio_processor_swresample.h |  18 +-
+ src/audio/ffmpeg_audio_reader.h               | 197 +++++++++---------
+ tests/CMakeLists.txt                          |   6 +
+ 8 files changed, 122 insertions(+), 199 deletions(-)
+ delete mode 100644 src/audio/ffmpeg_audio_processor_avresample.h
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index f8d6a32..4da2405 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -84,9 +84,6 @@ find_package(FFmpeg)
+ if(FFMPEG_LIBRARIES)
+ 	cmake_push_check_state(RESET)
+ 	set(CMAKE_REQUIRED_LIBRARIES ${FFMPEG_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -lm)
+-	check_function_exists(av_packet_unref HAVE_AV_PACKET_UNREF)
+-	check_function_exists(av_frame_alloc HAVE_AV_FRAME_ALLOC)
+-	check_function_exists(av_frame_free HAVE_AV_FRAME_FREE)
+ 	cmake_pop_check_state()
+ endif()
+
+@@ -163,14 +160,11 @@ message(STATUS "Using ${FFT_LIB} for FFT calculations")
+ if(NOT AUDIO_PROCESSOR_LIB)
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+ 		set(AUDIO_PROCESSOR_LIB "swresample")
+-	elseif(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(AUDIO_PROCESSOR_LIB "avresample")
+ 	endif()
+ endif()
+
+ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE OFF)
+ 		set(USE_SWRESAMPLE ON)
+ 		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBSWRESAMPLE_LIBRARIES})
+ 		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBSWRESAMPLE_INCLUDE_DIRS})
+@@ -178,16 +172,6 @@ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+ 	endif()
+ 	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+-elseif(AUDIO_PROCESSOR_LIB STREQUAL "avresample")
+-	if(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE ON)
+-		set(USE_SWRESAMPLE OFF)
+-		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBAVRESAMPLE_LIBRARIES})
+-		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBAVRESAMPLE_INCLUDE_DIRS})
+-	else()
+-		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+-	endif()
+-	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+ else()
+ 	message(STATUS "Building without audio conversion support, please install FFmpeg with libswresample")
+ endif()
+diff --git a/package/build.sh b/package/build.sh
+index da631ae..b41d36e 100755
+--- a/package/build.sh
++++ b/package/build.sh
+@@ -7,8 +7,8 @@ set -eux
+
+ BASE_DIR=$(cd $(dirname $0)/.. && pwd)
+
+-FFMPEG_VERSION=4.4.1
+-FFMPEG_BUILD_TAG=v4.4.1-1
++FFMPEG_VERSION=5.1.2
++FFMPEG_BUILD_TAG=v${FFMPEG_VERSION}-1
+
+ TMP_BUILD_DIR=$BASE_DIR/$(mktemp -d build.XXXXXXXX)
+ trap 'rm -rf $TMP_BUILD_DIR' EXIT
+diff --git a/src/audio/ffmpeg_audio_processor.h b/src/audio/ffmpeg_audio_processor.h
+index 7628fc7..39f4f6d 100644
+--- a/src/audio/ffmpeg_audio_processor.h
++++ b/src/audio/ffmpeg_audio_processor.h
+@@ -10,8 +10,6 @@
+
+ #if defined(USE_SWRESAMPLE)
+ #include "audio/ffmpeg_audio_processor_swresample.h"
+-#elif defined(USE_AVRESAMPLE)
+-#include "audio/ffmpeg_audio_processor_avresample.h"
+ #else
+ #error "no audio processing library"
+ #endif
+diff --git a/src/audio/ffmpeg_audio_processor_avresample.h b/src/audio/ffmpeg_audio_processor_avresample.h
+deleted file mode 100644
+index bd85f92..0000000
+--- a/src/audio/ffmpeg_audio_processor_avresample.h
++++ /dev/null
+@@ -1,72 +0,0 @@
+-// Copyright (C) 2016  Lukas Lalinsky
+-// Distributed under the MIT license, see the LICENSE file for details.
+-
+-#ifndef CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-#define CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-
+-extern "C" {
+-#include <libavresample/avresample.h>
+-}
+-
+-namespace chromaprint {
+-
+-class FFmpegAudioProcessor {
+-public:
+-	FFmpegAudioProcessor() {
+-		m_resample_ctx = avresample_alloc_context();
+-	}
+-
+-	~FFmpegAudioProcessor() {
+-		avresample_free(&m_resample_ctx);
+-	}
+-
+-	void SetCompatibleMode() {
+-		av_opt_set_int(m_resample_ctx, "filter_size", 16, 0);
+-		av_opt_set_int(m_resample_ctx, "phase_shift", 8, 0);
+-		av_opt_set_int(m_resample_ctx, "linear_interp", 1, 0);
+-		av_opt_set_double(m_resample_ctx, "cutoff", 0.8, 0);
+-	}
+-
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "in_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_rate", sample_rate, 0);
+-	}
+-
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "out_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_rate, 0);
+-	}
+-
+-	int Init() {
+-		return avresample_open(m_resample_ctx);
+-	}
+-
+-	int Convert(uint8_t **out, int out_count, const uint8_t **in, int in_count) {
+-		return avresample_convert(m_resample_ctx, out, 0, out_count, (uint8_t **) in, 0, in_count);
+-	}
+-
+-	int Flush(uint8_t **out, int out_count) {
+-		return avresample_read(m_resample_ctx, out, out_count);
+-	}
+-
+-private:
+-	AVAudioResampleContext *m_resample_ctx = nullptr;
+-};
+-
+-}; // namespace chromaprint
+-
+-#endif
+diff --git a/src/audio/ffmpeg_audio_processor_swresample.h b/src/audio/ffmpeg_audio_processor_swresample.h
+index b86266b..b1d4bea 100644
+--- a/src/audio/ffmpeg_audio_processor_swresample.h
++++ b/src/audio/ffmpeg_audio_processor_swresample.h
+@@ -28,30 +28,28 @@ public:
+ 		av_opt_set_double(m_swr_ctx, "cutoff", 0.8, 0);
+ 	}
+
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "icl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "ich", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetInputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "in_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "isf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "in_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "isr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "in_sample_rate", sample_rate, 0);
+ 	}
+
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "ocl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "och", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetOutputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "out_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "osf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "out_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "osr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "out_sample_rate", sample_rate, 0);
+ 	}
+
+ 	int Init() {
+diff --git a/src/audio/ffmpeg_audio_reader.h b/src/audio/ffmpeg_audio_reader.h
+index 5550164..1c6b346 100644
+--- a/src/audio/ffmpeg_audio_reader.h
++++ b/src/audio/ffmpeg_audio_reader.h
+@@ -62,7 +62,7 @@ public:
+ 	bool Read(const int16_t **data, size_t *size);
+
+ 	bool IsOpen() const { return m_opened; }
+-	bool IsFinished() const { return m_finished && !m_got_frame; }
++	bool IsFinished() const { return !m_has_more_packets && !m_has_more_frames; }
+
+ 	std::string GetError() const { return m_error; }
+ 	int GetErrorCode() const { return m_error_code; }
+@@ -74,20 +74,19 @@ private:
+ 	uint8_t *m_convert_buffer[1] = { nullptr };
+ 	int m_convert_buffer_nb_samples = 0;
+
+-	AVInputFormat *m_input_fmt = nullptr;
++	const AVInputFormat *m_input_fmt = nullptr;
+ 	AVDictionary *m_input_opts = nullptr;
+
+ 	AVFormatContext *m_format_ctx = nullptr;
+ 	AVCodecContext *m_codec_ctx = nullptr;
+-	AVFrame *m_frame = nullptr;
+ 	int m_stream_index = -1;
+ 	std::string m_error;
+ 	int m_error_code = 0;
+-	bool m_finished = false;
+ 	bool m_opened = false;
+-	int m_got_frame = 0;
+-	AVPacket m_packet;
+-	AVPacket m_packet0;
++	bool m_has_more_packets = true;
++	bool m_has_more_frames = true;
++	AVPacket *m_packet = nullptr;
++	AVFrame *m_frame = nullptr;
+
+ 	int m_output_sample_rate = 0;
+ 	int m_output_channels = 0;
+@@ -98,19 +97,12 @@ private:
+
+ inline FFmpegAudioReader::FFmpegAudioReader() {
+ 	av_log_set_level(AV_LOG_QUIET);
+-
+-	av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
+ }
+
+ inline FFmpegAudioReader::~FFmpegAudioReader() {
+ 	Close();
+ 	av_dict_free(&m_input_opts);
+ 	av_freep(&m_convert_buffer[0]);
+-	av_packet_unref(&m_packet0);
+ }
+
+ inline bool FFmpegAudioReader::SetInputFormat(const char *name) {
+@@ -135,11 +127,10 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ 	Close();
+
+-    av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
++	m_packet = av_packet_alloc();
++	if (!m_packet) {
++		return false;
++	}
+
+ 	ret = avformat_open_input(&m_format_ctx, file_name.c_str(), m_input_fmt, &m_input_opts);
+ 	if (ret < 0) {
+@@ -153,26 +144,31 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		return false;
+ 	}
+
+-	AVCodec *codec;
++	const AVCodec *codec;
+ 	ret = av_find_best_stream(m_format_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &codec, 0);
+ 	if (ret < 0) {
+ 		SetError("Could not find any audio stream in the file", ret);
+ 		return false;
+ 	}
+ 	m_stream_index = ret;
++	auto stream = m_format_ctx->streams[m_stream_index];
+
+-	m_codec_ctx = m_format_ctx->streams[m_stream_index]->codec;
++	m_codec_ctx = avcodec_alloc_context3(codec);
+ 	m_codec_ctx->request_sample_fmt = AV_SAMPLE_FMT_S16;
+
++	ret = avcodec_parameters_to_context(m_codec_ctx, stream->codecpar);
++	if (ret < 0) {
++		SetError("Could not copy the stream parameters", ret);
++		return false;
++	}
++
+ 	ret = avcodec_open2(m_codec_ctx, codec, nullptr);
+ 	if (ret < 0) {
+ 		SetError("Could not open the codec", ret);
+ 		return false;
+ 	}
+
+-	if (!m_codec_ctx->channel_layout) {
+-		m_codec_ctx->channel_layout = av_get_default_channel_layout(m_codec_ctx->channels);
+-	}
++	av_dump_format(m_format_ctx, 0, "foo", 0);
+
+ 	m_frame = av_frame_alloc();
+ 	if (!m_frame) {
+@@ -183,19 +179,23 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		m_output_sample_rate = m_codec_ctx->sample_rate;
+ 	}
+
+-	if (!m_output_channels) {
+-		m_output_channels = m_codec_ctx->channels;
++	AVChannelLayout output_channel_layout;
++	if (m_output_channels) {
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
++	} else {
++		m_output_channels = m_codec_ctx->ch_layout.nb_channels;
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
+ 	}
+
+-	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
++	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->ch_layout.nb_channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
+ 		m_converter.reset(new FFmpegAudioProcessor());
+ 		m_converter->SetCompatibleMode();
+ 		m_converter->SetInputSampleFormat(m_codec_ctx->sample_fmt);
+ 		m_converter->SetInputSampleRate(m_codec_ctx->sample_rate);
+-		m_converter->SetInputChannelLayout(m_codec_ctx->channel_layout);
++		m_converter->SetInputChannelLayout(&(m_codec_ctx->ch_layout));
+ 		m_converter->SetOutputSampleFormat(AV_SAMPLE_FMT_S16);
+ 		m_converter->SetOutputSampleRate(m_output_sample_rate);
+-		m_converter->SetOutputChannelLayout(av_get_default_channel_layout(m_output_channels));
++		m_converter->SetOutputChannelLayout(&output_channel_layout);
+ 		auto ret = m_converter->Init();
+ 		if (ret != 0) {
+ 			SetError("Could not create an audio converter instance", ret);
+@@ -203,10 +203,11 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		}
+ 	}
+
++	av_channel_layout_uninit(&output_channel_layout);
++
+ 	m_opened = true;
+-	m_finished = false;
+-	m_got_frame = 0;
+-	m_nb_packets = 0;
++	m_has_more_packets = true;
++	m_has_more_frames = true;
+ 	m_decode_error = 0;
+
+ 	return true;
+@@ -214,6 +215,7 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ inline void FFmpegAudioReader::Close() {
+ 	av_frame_free(&m_frame);
++	av_packet_free(&m_packet);
+
+ 	m_stream_index = -1;
+
+@@ -252,91 +254,98 @@ inline bool FFmpegAudioReader::Read(const int16_t **data, size_t *size) {
+ 		return false;
+ 	}
+
++	*data = nullptr;
++	*size = 0;
++
+ 	int ret;
++	bool needs_packet = false;
+ 	while (true) {
+-		while (m_packet.size <= 0) {
+-			av_packet_unref(&m_packet0);
+-			av_init_packet(&m_packet);
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			ret = av_read_frame(m_format_ctx, &m_packet);
++		while (needs_packet && m_packet->size == 0) {
++			ret = av_read_frame(m_format_ctx, m_packet);
+ 			if (ret < 0) {
+ 				if (ret == AVERROR_EOF) {
+-					m_finished = true;
++					needs_packet = false;
++					m_has_more_packets = false;
+ 					break;
+-				} else {
++				}
++				SetError("Error reading from the audio source", ret);
++				return false;
++			}
++			if (m_packet->stream_index == m_stream_index) {
++				needs_packet = false;
++			} else {
++				av_packet_unref(m_packet);
++			}
++		}
++
++		if (m_packet->size != 0) {
++			ret = avcodec_send_packet(m_codec_ctx, m_packet);
++			if (ret < 0) {
++				if (ret != AVERROR(EAGAIN)) {
+ 					SetError("Error reading from the audio source", ret);
+ 					return false;
+ 				}
+-			}
+-			m_packet0 = m_packet;
+-			if (m_packet.stream_index != m_stream_index) {
+-				m_packet.data = nullptr;
+-				m_packet.size = 0;
+ 			} else {
+-				m_nb_packets++;
++				av_packet_unref(m_packet);
+ 			}
+ 		}
+
+-		ret = avcodec_decode_audio4(m_codec_ctx, m_frame, &m_got_frame, &m_packet);
++		ret = avcodec_receive_frame(m_codec_ctx, m_frame);
+ 		if (ret < 0) {
+-			if (m_decode_error) {
+-				SetError("Error decoding audio frame", m_decode_error);
+-				return false;
++			if (ret == AVERROR_EOF) {
++				m_has_more_frames = false;
++			} else if (ret == AVERROR(EAGAIN)) {
++				if (m_has_more_packets) {
++					needs_packet = true;
++					continue;
++				} else {
++					m_has_more_frames = false;
++				}
+ 			}
+-			m_decode_error = ret;
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			continue;
++			SetError("Error decoding the audio source", ret);
++			return false;
+ 		}
+
+-		break;
+-	}
+-
+-	m_decode_error = 0;
+-
+-	const int decoded = std::min(ret, m_packet.size);
+-	m_packet.data += decoded;
+-	m_packet.size -= decoded;
+-
+-	if (m_got_frame) {
+-		if (m_converter) {
+-			if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
+-				int linsize;
+-				av_freep(&m_convert_buffer[0]);
+-				m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
+-				ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
+-				if (ret < 0) {
+-					SetError("Couldn't allocate audio converter buffer", ret);
++		if (m_frame->nb_samples > 0) {
++			if (m_converter) {
++				if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
++					int linsize;
++					av_freep(&m_convert_buffer[0]);
++					m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
++					ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->ch_layout.nb_channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
++					if (ret < 0) {
++						SetError("Couldn't allocate audio converter buffer", ret);
++						return false;
++					}
++				}
++				auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
++				if (nb_samples < 0) {
++					SetError("Couldn't convert audio", ret);
+ 					return false;
+ 				}
+-			}
+-			auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			}
+-			*data = (const int16_t *) m_convert_buffer[0];
+-			*size = nb_samples;
+-		} else {
+-			*data = (const int16_t *) m_frame->data[0];
+-			*size = m_frame->nb_samples;
+-		}
+-	} else {
+-		if (m_finished && m_converter) {
+-			auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			} else if (nb_samples > 0) {
+-				m_got_frame = 1;
+ 				*data = (const int16_t *) m_convert_buffer[0];
+ 				*size = nb_samples;
++			} else {
++				*data = (const int16_t *) m_frame->data[0];
++				*size = m_frame->nb_samples;
++			}
++		} else {
++			if (m_converter) {
++				if (IsFinished()) {
++					auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
++					if (nb_samples < 0) {
++						SetError("Couldn't convert audio", ret);
++						return false;
++					} else if (nb_samples > 0) {
++						*data = (const int16_t *) m_convert_buffer[0];
++						*size = nb_samples;
++					}
++				}
+ 			}
+ 		}
+-	}
+
+-	return true;
++		return true;
++	}
+ }
+
+ inline void FFmpegAudioReader::SetError(const char *message, int errnum) {
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index a2b517b..123e643 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -38,6 +38,12 @@ set(SRCS
+
+ if(BUILD_TOOLS)
+ 	set(SRCS ${SRCS} ../src/audio/ffmpeg_audio_reader_test.cpp)
++    include_directories(
++        ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}
++        ${AUDIO_PROCESSOR_INCLUDE_DIRS}
++    )
+ 	link_libraries(fpcalc_libs)
+ endif()
+
+-- 
+2.38.1
+
+
diff --git a/srcpkgs/chromaprint/template b/srcpkgs/chromaprint/template
index 7ef7838949f3a..1f7bbc70a22c8 100644
--- a/srcpkgs/chromaprint/template
+++ b/srcpkgs/chromaprint/template
@@ -1,7 +1,7 @@
 # Template file for 'chromaprint'
 pkgname=chromaprint
 version=1.5.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DBUILD_TOOLS=ON"
 make_check_target="check"

From d50bec131ecb0dea5043143bc7df0c025225e749 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 021/112] chromium: revbump for ffmpeg6

---
 .../patches/chromium-119-ffmpeg-4.4.patch     | 20 --------
 srcpkgs/chromium/patches/ffmpeg5.patch        | 47 +++++++++++++++++++
 srcpkgs/chromium/template                     |  2 +-
 3 files changed, 48 insertions(+), 21 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch
 create mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch b/srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch
deleted file mode 100644
index 04d04b166ba37..0000000000000
--- a/srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch
+++ /dev/null
@@ -1,20 +0,0 @@
---- a/media/filters/ffmpeg_demuxer.cc.orig
-+++ b/media/filters/ffmpeg_demuxer.cc
-@@ -390,7 +390,7 @@
- 
-   scoped_refptr<DecoderBuffer> buffer;
- 
--    size_t side_data_size = 0;
-+    int side_data_size = 0;
-     uint8_t* side_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
- 
-@@ -453,7 +453,7 @@
-                                        packet->size - data_offset);
-     }
- 
--    size_t skip_samples_size = 0;
-+    int skip_samples_size = 0;
-     const uint32_t* skip_samples_ptr =
-         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
-             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..24e2da38e34ca
--- /dev/null
+++ b/srcpkgs/chromium/patches/ffmpeg5.patch
@@ -0,0 +1,47 @@
+--- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
++++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
+@@ -92,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+-  if (stream->start_time != kNoFFmpegTimestamp)
++  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -1597,7 +1585,7 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+@@ -1618,7 +1606,7 @@
+     if (stream->type() != DemuxerStream::VIDEO)
+       continue;
+ 
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+ 
+     if (!stream->IsEnabled())
diff --git a/srcpkgs/chromium/template b/srcpkgs/chromium/template
index 5613fa3813822..cd386c8a84ae6 100644
--- a/srcpkgs/chromium/template
+++ b/srcpkgs/chromium/template
@@ -2,7 +2,7 @@
 pkgname=chromium
 # See https://chromiumdash.appspot.com/releases?platform=Linux for the latest version
 version=120.0.6099.129
-revision=1
+revision=2
 archs="i686* x86_64* aarch64* armv7l*"
 hostmakedepends="
  $(vopt_if clang "clang lld llvm15")

From bc62312716aef3819575f3635d64bd31584dafb8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 022/112] cmus: revbump for ffmpeg6

---
 srcpkgs/chromium/patches/ffmpeg5.patch | 47 --------------------------
 srcpkgs/cmus/patches/ffmpeg6.patch     | 12 +++++++
 srcpkgs/cmus/template                  |  2 +-
 3 files changed, 13 insertions(+), 48 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch
 create mode 100644 srcpkgs/cmus/patches/ffmpeg6.patch

diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
deleted file mode 100644
index 24e2da38e34ca..0000000000000
--- a/srcpkgs/chromium/patches/ffmpeg5.patch
+++ /dev/null
@@ -1,47 +0,0 @@
---- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
-+++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
-@@ -92,24 +92,12 @@
- 
- static base::TimeDelta ExtractStartTime(AVStream* stream) {
-   // The default start time is zero.
--  base::TimeDelta start_time;
-+  base::TimeDelta start_time = kNoTimestamp;
- 
-   // First try to use  the |start_time| value as is.
--  if (stream->start_time != kNoFFmpegTimestamp)
-+  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
-     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
- 
--  // Next try to use the first DTS value, for codecs where we know PTS == DTS
--  // (excludes all H26x codecs). The start time must be returned in PTS.
--  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
--      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
--      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
--      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
--    const base::TimeDelta first_pts =
--        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
--    if (first_pts < start_time)
--      start_time = first_pts;
--  }
--
-   return start_time;
- }
- 
-@@ -1597,7 +1585,7 @@
-   for (const auto& stream : streams_) {
-     if (!stream || stream->IsEnabled() != enabled)
-       continue;
--    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
-+    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
-       continue;
-     if (!lowest_start_time_stream ||
-         stream->start_time() < lowest_start_time_stream->start_time()) {
-@@ -1618,7 +1606,7 @@
-     if (stream->type() != DemuxerStream::VIDEO)
-       continue;
- 
--    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
-+    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
-       continue;
- 
-     if (!stream->IsEnabled())
diff --git a/srcpkgs/cmus/patches/ffmpeg6.patch b/srcpkgs/cmus/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..ffa95ab811101
--- /dev/null
+++ b/srcpkgs/cmus/patches/ffmpeg6.patch
@@ -0,0 +1,12 @@
+--- a/ip/ffmpeg.c
++++ b/ip/ffmpeg.c
+@@ -202,9 +202,6 @@ static int ffmpeg_open(struct input_plugin_data *ip_data)
+ 			break;
+ 		}
+ 
+-		if (codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+-			cc->flags |= AV_CODEC_FLAG_TRUNCATED;
+-
+ 		if (avcodec_open2(cc, codec, NULL) < 0) {
+ 			d_print("could not open codec: %d, %s\n", cc->codec_id, avcodec_get_name(cc->codec_id));
+ 			err = -IP_ERROR_UNSUPPORTED_FILE_TYPE;
diff --git a/srcpkgs/cmus/template b/srcpkgs/cmus/template
index 0d1436744f1b2..a6e4b4fa86cb8 100644
--- a/srcpkgs/cmus/template
+++ b/srcpkgs/cmus/template
@@ -1,7 +1,7 @@
 # Template file for 'cmus'
 pkgname=cmus
 version=2.10.0
-revision=3
+revision=4
 build_style=configure
 configure_args="prefix=/usr LD=$CC"
 hostmakedepends="pkg-config"

From 68a919d1b8b7052a676fed18453ab60ed9e01c7b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 023/112] cyanrip: revbump for ffmpeg6

---
 srcpkgs/cyanrip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cyanrip/template b/srcpkgs/cyanrip/template
index 9796e3461601a..5db30e020d17e 100644
--- a/srcpkgs/cyanrip/template
+++ b/srcpkgs/cyanrip/template
@@ -1,7 +1,7 @@
 # Template file for 'cyanrip'
 pkgname=cyanrip
 version=0.9.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config"
 makedepends="ffmpeg-devel libcdio-devel libcdio-paranoia-devel libcurl-devel libmusicbrainz5-devel"

From a787b85cb6632ec4805e4c1c4ec8980f86857c8e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 024/112] deadbeef: revbump for ffmpeg4

---
 srcpkgs/deadbeef/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/deadbeef/template b/srcpkgs/deadbeef/template
index f5f4bf24b8cb6..7b47e615cd48e 100644
--- a/srcpkgs/deadbeef/template
+++ b/srcpkgs/deadbeef/template
@@ -1,14 +1,14 @@
 # Template file for 'deadbeef'
 pkgname=deadbeef
 version=1.8.8
-revision=3
+revision=4
 create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-oss --disable-lfm --disable-notify --disable-gtk2"
 hostmakedepends="automake libtool gettext gettext-devel intltool pkg-config
  yasm clang glib-devel"
 makedepends="
- alsa-lib-devel dbus-devel faad2-devel ffmpeg-devel gtk+3-devel imlib2-devel
+ alsa-lib-devel dbus-devel faad2-devel ffmpeg4-devel gtk+3-devel imlib2-devel
  jansson-devel libcddb-devel libcdio-devel libcurl-devel libflac-devel
  libmad-devel libpng-devel libsamplerate-devel libsndfile-devel libvorbis-devel
  libzip-devel mpg123-devel opusfile-devel pulseaudio-devel wavpack-devel"

From f694b055a802822e830ea4201d7c7e631475f79e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 025/112] droidcam-obs-plugin: revbump for ffmpeg6

---
 srcpkgs/droidcam-obs-plugin/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam-obs-plugin/template b/srcpkgs/droidcam-obs-plugin/template
index fc9c9bf6b9d54..fb0480754df4d 100644
--- a/srcpkgs/droidcam-obs-plugin/template
+++ b/srcpkgs/droidcam-obs-plugin/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam-obs-plugin'
 pkgname=droidcam-obs-plugin
 version=2.0.1
-revision=1
+revision=2
 build_style=gnu-makefile
 make_use_env=yes
 make_build_args="ALLOW_STATIC=no"

From 87575248074a6e15bd3c227141b66834b840f95a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 026/112] droidcam: revbump for ffmpeg6

---
 srcpkgs/droidcam/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam/template b/srcpkgs/droidcam/template
index 1c3f1b8b1fc67..32a9220b79a4d 100644
--- a/srcpkgs/droidcam/template
+++ b/srcpkgs/droidcam/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam'
 pkgname=droidcam
 version=1.8.2
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="USBMUXD=-lusbmuxd-2.0 JPEG=-lturbojpeg"
 hostmakedepends="pkg-config"

From f6a53739d0c25acefccb7867523fd298273bda56 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 027/112] ffmpegthumbnailer: revbump for ffmpeg6

---
 .../ffmpegthumbnailer/patches/ffmpeg6.patch   | 202 ++++++++++++++++++
 srcpkgs/ffmpegthumbnailer/template            |   6 +-
 2 files changed, 205 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch

diff --git a/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..363ff35a28419
--- /dev/null
+++ b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
@@ -0,0 +1,202 @@
+--- a/libffmpegthumbnailer/moviedecoder.cpp	2017-11-21 14:06:57.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.cpp	2023-05-05 13:14:47.946560668 -0400
+@@ -41,11 +41,6 @@
+ namespace ffmpegthumbnailer
+ {
+ 
+-struct SilenceLogLevel
+-{
+-    SilenceLogLevel() { av_log_set_level(AV_LOG_QUIET); }
+-};
+-
+ MovieDecoder::MovieDecoder(AVFormatContext* pavContext)
+ : m_VideoStream(-1)
+ , m_pFormatContext(pavContext)
+@@ -70,8 +65,6 @@
+ 
+ void MovieDecoder::initialize(const string& filename, bool preferEmbeddedMetadata)
+ {
+-    av_register_all();
+-    avcodec_register_all();
+     avformat_network_init();
+ 
+     string inputFile = filename == "-" ? "pipe:" : filename;
+@@ -97,8 +90,7 @@
+ {
+     if (m_pVideoCodecContext)
+     {
+-        avcodec_close(m_pVideoCodecContext);
+-        m_pVideoCodecContext = nullptr;
++        avcodec_free_context(&m_pVideoCodecContext);
+     }
+ 
+     if ((!m_FormatContextWasGiven) && m_pFormatContext)
+@@ -152,10 +144,10 @@
+     for (unsigned int i = 0; i < m_pFormatContext->nb_streams; ++i)
+     {
+         AVStream *stream = m_pFormatContext->streams[i];
+-        auto ctx = m_pFormatContext->streams[i]->codec;
+-        if (ctx->codec_type == AVMEDIA_TYPE_VIDEO)
++        auto par = m_pFormatContext->streams[i]->codecpar;
++        if (par->codec_type == AVMEDIA_TYPE_VIDEO)
+         {
+-            if (!preferEmbeddedMetadata || !isStillImageCodec(ctx->codec_id))
++            if (!preferEmbeddedMetadata || !isStillImageCodec(par->codec_id))
+             {
+                 videoStreams.push_back(i);
+                 continue;
+@@ -203,8 +195,7 @@
+     }
+ 
+     m_pVideoStream = m_pFormatContext->streams[m_VideoStream];
+-    m_pVideoCodecContext = m_pVideoStream->codec;
+-    m_pVideoCodec = avcodec_find_decoder(m_pVideoCodecContext->codec_id);
++    m_pVideoCodec = avcodec_find_decoder(m_pVideoStream->codecpar->codec_id);
+ 
+     if (m_pVideoCodec == nullptr)
+     {
+@@ -214,6 +205,20 @@
+         throw logic_error("Video Codec not found");
+     }
+ 
++    m_pVideoCodecContext = avcodec_alloc_context3(m_pVideoCodec);
++
++    if (m_pVideoCodecContext == nullptr)
++    {
++        destroy();
++        throw logic_error("Could not allocate video codec context");
++    }
++
++    if (avcodec_parameters_to_context(m_pVideoCodecContext, m_pVideoStream->codecpar) < 0)
++    {
++        destroy();
++        throw logic_error("Could not configure video codec context");
++    }
++
+     m_pVideoCodecContext->workaround_bugs = 1;
+ 
+     if (avcodec_open2(m_pVideoCodecContext, m_pVideoCodec, nullptr) < 0)
+@@ -386,13 +391,6 @@
+ 
+ void MovieDecoder::initializeFilterGraph(const AVRational& timeBase, const std::string& size, bool maintainAspectRatio)
+ {
+-    static const AVPixelFormat pixelFormats[] = { AV_PIX_FMT_RGB24, AV_PIX_FMT_NONE };
+-
+-    auto del = [] (AVBufferSinkParams* p) { av_freep(p); };
+-    std::unique_ptr<AVBufferSinkParams, decltype(del)> buffersinkParams(av_buffersink_params_alloc(), del);
+-
+-    avfilter_register_all();
+-
+     m_pFilterGraph = avfilter_graph_alloc();
+     assert(m_pFilterGraph);
+ 
+@@ -404,10 +402,8 @@
+ 
+     checkRc(avfilter_graph_create_filter(&m_pFilterSource, avfilter_get_by_name("buffer"), "thumb_buffer", ss.str().c_str(), nullptr, m_pFilterGraph),
+             "Failed to create filter source");
+-    buffersinkParams->pixel_fmts = pixelFormats;
+-    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, buffersinkParams.get(), m_pFilterGraph),
++    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, nullptr, m_pFilterGraph),
+             "Failed to create filter sink");
+-    buffersinkParams.release();
+ 
+     AVFilterContext* yadifFilter = nullptr;
+     if (m_pFrame->interlaced_frame != 0)
+@@ -500,15 +496,15 @@
+     }
+ 
+     checkRc(av_seek_frame(m_pFormatContext, -1, timestamp, 0), "Seeking in video failed");
+-    avcodec_flush_buffers(m_pFormatContext->streams[m_VideoStream]->codec);
++    avcodec_flush_buffers(m_pVideoCodecContext);
+ 
+     int keyFrameAttempts = 0;
+-    bool gotFrame = 0;
++    bool gotFrame;
+ 
+     do
+     {
+         int count = 0;
+-        gotFrame = 0;
++        gotFrame = false;
+ 
+         while (!gotFrame && count < 20)
+         {
+@@ -552,17 +548,33 @@
+         return false;
+     }
+ 
+-    av_frame_unref(m_pFrame);
+-
+-    int frameFinished;
++    int rc = avcodec_send_packet(m_pVideoCodecContext, m_pPacket);
++    if(rc == AVERROR(EAGAIN))
++    {
++        rc = 0;
++    }
+ 
+-    int bytesDecoded = avcodec_decode_video2(m_pVideoCodecContext, m_pFrame, &frameFinished, m_pPacket);
+-    if (bytesDecoded < 0)
++    if(rc == AVERROR_EOF)
++    {
++        return false;
++    }
++    else if(rc < 0)
+     {
+-        throw logic_error("Failed to decode video frame: bytesDecoded < 0");
++        throw logic_error("Failed to decode video frame: avcodec_send_packet() < 0");
+     }
+ 
+-    return frameFinished > 0;
++    rc = avcodec_receive_frame(m_pVideoCodecContext, m_pFrame);
++    switch(rc)
++    {
++        case 0:
++            return true;
++
++        case AVERROR(EAGAIN):
++            return false;
++
++        default:
++            throw logic_error("Failed to decode video frame: avcodec_receive_frame() < 0");
++    }
+ }
+ 
+ bool MovieDecoder::getVideoPacket()
+@@ -570,8 +582,6 @@
+     bool framesAvailable = true;
+     bool frameDecoded = false;
+ 
+-    int attempts = 0;
+-
+     if (m_pPacket)
+     {
+         av_packet_unref(m_pPacket);
+@@ -580,6 +590,7 @@
+ 
+     m_pPacket = new AVPacket();
+ 
++
+     while (framesAvailable && !frameDecoded)
+     {
+         framesAvailable = av_read_frame(m_pFormatContext, m_pPacket) >= 0;
+@@ -644,7 +655,7 @@
+ 
+ int32_t MovieDecoder::getStreamRotation()
+ {
+-    int32_t* matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
++    auto matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
+     if (matrix)
+     {
+         auto angle = lround(av_display_rotation_get(matrix));
+
+--- a/libffmpegthumbnailer/moviedecoder.h	2017-11-12 04:23:38.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.h	2023-05-05 13:26:07.095529911 -0400
+@@ -78,7 +78,7 @@
+     int                     m_VideoStream;
+     AVFormatContext*        m_pFormatContext;
+     AVCodecContext*         m_pVideoCodecContext;
+-    AVCodec*                m_pVideoCodec;
++    const AVCodec*          m_pVideoCodec;
+     AVFilterGraph*          m_pFilterGraph;
+     AVFilterContext*        m_pFilterSource;
+     AVFilterContext*        m_pFilterSink;
diff --git a/srcpkgs/ffmpegthumbnailer/template b/srcpkgs/ffmpegthumbnailer/template
index 039eea7622b39..35d546018d12a 100644
--- a/srcpkgs/ffmpegthumbnailer/template
+++ b/srcpkgs/ffmpegthumbnailer/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbnailer'
 pkgname=ffmpegthumbnailer
 version=2.2.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libpng-devel libjpeg-turbo-devel ffmpeg-devel"
@@ -9,8 +9,8 @@ depends="ffmpeg"
 short_desc="Lightweight video thumbnailer"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
-homepage="https://github.com/dirkvdb/${pkgname}"
-distfiles="${homepage}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
+homepage="https://github.com/dirkvdb"
+distfiles="${homepage}/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
 checksum=1cb24059c38223f657b300c84dd80491b7040d4b69471c4fea69be862bc99b5b
 
 post_install() {

From 24a4d8e8bfd60c405ab69aa403c62c8638a214fe Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 028/112] ffmpegthumbs: revbump for ffmpeg6

---
 srcpkgs/ffmpegthumbs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ffmpegthumbs/template b/srcpkgs/ffmpegthumbs/template
index 5f0b9414dadaf..11b88193528f4 100644
--- a/srcpkgs/ffmpegthumbs/template
+++ b/srcpkgs/ffmpegthumbs/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbs'
 pkgname=ffmpegthumbs
 version=22.12.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules kcoreaddons kconfig-devel
  pkg-config qt5-host-tools qt5-qmake gettext"

From 3238c1ad79c86345a8b1557c1165a5802ebbeff7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 029/112] ffms2: revbump for ffmpeg6

---
 srcpkgs/ffms2/patches/ffmpeg5.patch | 424 ++++++++++++++++++++++++++++
 srcpkgs/ffms2/template              |   2 +-
 2 files changed, 425 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ffms2/patches/ffmpeg5.patch

diff --git a/srcpkgs/ffms2/patches/ffmpeg5.patch b/srcpkgs/ffms2/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..1479fabcafcb4
--- /dev/null
+++ b/srcpkgs/ffms2/patches/ffmpeg5.patch
@@ -0,0 +1,424 @@
+From 45673149e9a2f5586855ad472e3059084eaa36b1 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:41:21 +0100
+Subject: [PATCH] Use auto for AVCodec
+
+The geniuses over at FFmpeg decided to constify this API, so old
+versions of the library will return AVCodec *, while new versions
+of the libary will return const AVCodec *, which, in C++, are not
+OK to convert between.
+
+Rather than use some macro hell in ffmscompat.h, we can work around
+this by using auto.
+
+Gross.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 2 +-
+ src/core/indexing.cpp    | 6 +++---
+ src/core/videosource.cpp | 2 +-
+ 3 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index e4ce97c..ac09666 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -469,7 +469,7 @@ void FFMS_AudioSource::OpenFile() {
+ 
+     LAVFOpenFile(SourceFile.c_str(), FormatContext, TrackNumber);
+ 
+-    AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
++    auto *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
+     if (Codec == nullptr)
+         throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+             "Audio codec not found");
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index e547c5a..59fb4e8 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -384,7 +384,7 @@ FFMS_TrackType FFMS_Indexer::GetTrackType(int Track) {
+ }
+ 
+ const char *FFMS_Indexer::GetTrackCodec(int Track) {
+-    AVCodec *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
++    auto *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
+     return codec ? codec->name : nullptr;
+ }
+ 
+@@ -402,7 +402,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             UseDTS);
+ 
+         if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            AVCodec *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (!VideoCodec) {
+                 FormatContext->streams[i]->discard = AVDISCARD_ALL;
+                 IndexMask.erase(i);
+@@ -433,7 +433,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 IndexMask.insert(i);
+             }
+         } else if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+-            AVCodec *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (AudioCodec == nullptr)
+                 throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_UNSUPPORTED,
+                     "Audio codec not found");
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index b889970..8956c22 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -171,7 +171,7 @@ FFMS_VideoSource::FFMS_VideoSource(const char *SourceFile, FFMS_Index &Index, in
+ 
+         LAVFOpenFile(SourceFile, FormatContext, VideoTrack);
+ 
+-        AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
++        auto *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
+         if (Codec == nullptr)
+             throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+                 "Video codec not found");
+-- 
+2.40.0
+
+From 96cbf38ea9381829a1314f432a2c60495dcefaad Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:12:41 +0100
+Subject: [PATCH] all: Update AVPacket API usage
+
+AVPackets must all be on the heap now, since it is no longer
+part of the libav* ABI.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 16 ++++++----
+ src/core/indexing.cpp    | 63 ++++++++++++++++++++++------------------
+ src/core/indexing.h      |  4 +--
+ src/core/utils.cpp       |  6 ----
+ src/core/utils.h         |  1 -
+ src/core/videosource.cpp | 30 ++++++++++---------
+ 6 files changed, 64 insertions(+), 56 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index 37cf9ae..e4ce97c 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -285,10 +285,15 @@ FFMS_AudioSource::AudioBlock *FFMS_AudioSource::CacheBlock(CacheIterator &pos) {
+ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     CurrentFrame = &Frames[PacketNumber];
+ 
+-    AVPacket Packet;
+-    if (!ReadPacket(&Packet))
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++    if (!ReadPacket(Packet)) {
++        av_packet_free(&Packet);
+         throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_UNKNOWN,
+             "ReadPacket unexpectedly failed to read a packet");
++    }
+ 
+     // ReadPacket may have changed the packet number
+     CurrentFrame = &Frames[PacketNumber];
+@@ -297,8 +302,9 @@ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     int NumberOfSamples = 0;
+     AudioBlock *CachedBlock = nullptr;
+     
+-    int Ret = avcodec_send_packet(CodecContext, &Packet);
+-    av_packet_unref(&Packet);
++    int Ret = avcodec_send_packet(CodecContext, Packet);
++    av_packet_unref(Packet);
++    av_packet_free(&Packet);
+ 
+     av_frame_unref(DecodeFrame);
+     Ret = avcodec_receive_frame(CodecContext, DecodeFrame);
+@@ -513,8 +519,6 @@ void FFMS_AudioSource::Seek() {
+ }
+ 
+ bool FFMS_AudioSource::ReadPacket(AVPacket *Packet) {
+-    InitNullPacket(*Packet);
+-
+     while (av_read_frame(FormatContext, Packet) >= 0) {
+         if (Packet->stream_index == TrackNumber) {
+             // Required because not all audio packets, especially in ogg, have a pts. Use the previous valid packet's pts instead.
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index 23fb95b..e547c5a 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -320,7 +320,7 @@ void FFMS_Indexer::CheckAudioProperties(int Track, AVCodecContext *Context) {
+     }
+ }
+ 
+-void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict,
++void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict,
+                                     int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct) {
+     if (VideoContext.Parser) {
+         uint8_t *OB;
+@@ -330,8 +330,8 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+         av_parser_parse2(VideoContext.Parser,
+             VideoContext.CodecContext,
+             &OB, &OBSize,
+-            pkt.data, pkt.size,
+-            pkt.pts, pkt.dts, pkt.pos);
++            pkt->data, pkt->size,
++            pkt->pts, pkt->dts, pkt->pos);
+ 
+         // H.264 (PAFF) and HEVC may have one field per packet, so we need to track
+         // when we have a full or half frame available, and mark one of them as
+@@ -351,15 +351,15 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+ 
+         *RepeatPict = VideoContext.Parser->repeat_pict;
+         *FrameType = VideoContext.Parser->pict_type;
+-        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt.flags & AV_PKT_FLAG_DISCARD));
++        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt->flags & AV_PKT_FLAG_DISCARD));
+     } else {
+-        *Invisible = !!(pkt.flags & AV_PKT_FLAG_DISCARD);
++        *Invisible = !!(pkt->flags & AV_PKT_FLAG_DISCARD);
+     }
+ 
+     if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP8)
+-        ParseVP8(pkt.data[0], Invisible, FrameType);
++        ParseVP8(pkt->data[0], Invisible, FrameType);
+     else if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP9)
+-        ParseVP9(pkt.data[0], Invisible, FrameType);
++        ParseVP9(pkt->data[0], Invisible, FrameType);
+ }
+ 
+ void FFMS_Indexer::Free() {
+@@ -458,32 +458,36 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+         }
+     }
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
+     std::vector<int64_t> LastValidTS(FormatContext->nb_streams, AV_NOPTS_VALUE);
+ 
+     int64_t filesize = avio_size(FormatContext->pb);
+     enum AVPictureStructure LastPicStruct = AV_PICTURE_STRUCTURE_UNKNOWN;
+-    while (av_read_frame(FormatContext, &Packet) >= 0) {
++    while (av_read_frame(FormatContext, Packet) >= 0) {
+         // Update progress
+         // FormatContext->pb can apparently be NULL when opening images.
+         if (IC && FormatContext->pb) {
+-            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate))
++            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate)) {
++                av_packet_free(&Packet);
+                 throw FFMS_Exception(FFMS_ERROR_CANCELLED, FFMS_ERROR_USER,
+                     "Cancelled by user");
++            }
+         }
+-        if (!IndexMask.count(Packet.stream_index)) {
+-            av_packet_unref(&Packet);
++        if (!IndexMask.count(Packet->stream_index)) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+-        int Track = Packet.stream_index;
++        int Track = Packet->stream_index;
+         FFMS_Track &TrackInfo = (*TrackIndices)[Track];
+-        bool KeyFrame = !!(Packet.flags & AV_PKT_FLAG_KEY);
++        bool KeyFrame = !!(Packet->flags & AV_PKT_FLAG_KEY);
+         ReadTS(Packet, LastValidTS[Track], (*TrackIndices)[Track].UseDTS);
+ 
+         if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            int64_t PTS = TrackInfo.UseDTS ? Packet.dts : Packet.pts;
++            int64_t PTS = TrackInfo.UseDTS ? Packet->dts : Packet->pts;
+             if (PTS == AV_NOPTS_VALUE) {
+                 // VPx alt-refs are output as packets which lack timestmps or durations, since
+                 // they are invisible. Currently, the timestamp mangling code in libavformat
+@@ -495,9 +499,11 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 // FFMS2 currently sorts packets by PTS, which will break decoding, otherwise.
+                 bool HasAltRefs = (FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP8 ||
+                                    FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP9);
+-                if (Packet.duration == 0 && !HasAltRefs)
++                if (Packet->duration == 0 && !HasAltRefs) {
++                    av_packet_free(&Packet);
+                     throw FFMS_Exception(FFMS_ERROR_INDEXING, FFMS_ERROR_PARSER,
+                         "Invalid packet pts, dts, and duration");
++                }
+ 
+                 if (TrackInfo.empty())
+                     PTS = 0;
+@@ -513,7 +519,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             ParseVideoPacket(AVContexts[Track], Packet, &RepeatPict, &FrameType, &Invisible, &LastPicStruct);
+ 
+             TrackInfo.AddVideoFrame(PTS, RepeatPict, KeyFrame,
+-                FrameType, Packet.pos, Invisible);
++                FrameType, Packet->pos, Invisible);
+         } else if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+             // For video seeking timestamps are used only if all packets have
+             // timestamps, while for audio they're used if any have timestamps,
+@@ -522,28 +528,29 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 TrackInfo.HasTS = true;
+ 
+             int64_t StartSample = AVContexts[Track].CurrentSample;
+-            uint32_t SampleCount = IndexAudioPacket(Track, &Packet, AVContexts[Track], *TrackIndices);
++            uint32_t SampleCount = IndexAudioPacket(Track, Packet, AVContexts[Track], *TrackIndices);
+             TrackInfo.SampleRate = AVContexts[Track].CodecContext->sample_rate;
+ 
+             TrackInfo.AddAudioFrame(LastValidTS[Track],
+-                StartSample, SampleCount, KeyFrame, Packet.pos, Packet.flags & AV_PKT_FLAG_DISCARD);
++                StartSample, SampleCount, KeyFrame, Packet->pos, Packet->flags & AV_PKT_FLAG_DISCARD);
+         }
+ 
+-        if (!(Packet.flags & AV_PKT_FLAG_DISCARD))
+-            TrackInfo.LastDuration = Packet.duration;
++        if (!(Packet->flags & AV_PKT_FLAG_DISCARD))
++            TrackInfo.LastDuration = Packet->duration;
+ 
+-        av_packet_unref(&Packet);
++        av_packet_unref(Packet);
+     }
++    av_packet_free(&Packet);
+ 
+     TrackIndices->Finalize(AVContexts, FormatContext->iformat->name);
+     return TrackIndices.release();
+ }
+ 
+-void FFMS_Indexer::ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS) {
+-    if (!UseDTS && Packet.pts != AV_NOPTS_VALUE)
+-        TS = Packet.pts;
++void FFMS_Indexer::ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS) {
++    if (!UseDTS && Packet->pts != AV_NOPTS_VALUE)
++        TS = Packet->pts;
+     if (TS == AV_NOPTS_VALUE)
+         UseDTS = true;
+-    if (UseDTS && Packet.dts != AV_NOPTS_VALUE)
+-        TS = Packet.dts;
++    if (UseDTS && Packet->dts != AV_NOPTS_VALUE)
++        TS = Packet->dts;
+ }
+diff --git a/src/core/indexing.h b/src/core/indexing.h
+index 3cfc3c3..5c06868 100644
+--- a/src/core/indexing.h
++++ b/src/core/indexing.h
+@@ -80,10 +80,10 @@ private:
+     int64_t Filesize;
+     uint8_t Digest[20];
+ 
+-    void ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS);
++    void ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS);
+     void CheckAudioProperties(int Track, AVCodecContext *Context);
+     uint32_t IndexAudioPacket(int Track, AVPacket *Packet, SharedAVContext &Context, FFMS_Index &TrackIndices);
+-    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
++    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
+     void Free();
+ public:
+     FFMS_Indexer(const char *Filename);
+diff --git a/src/core/utils.cpp b/src/core/utils.cpp
+index ce67533..8a2e997 100644
+--- a/src/core/utils.cpp
++++ b/src/core/utils.cpp
+@@ -62,12 +62,6 @@ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo) {
+     }
+ }
+ 
+-void InitNullPacket(AVPacket &pkt) {
+-    av_init_packet(&pkt);
+-    pkt.data = nullptr;
+-    pkt.size = 0;
+-}
+-
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames) {
+     AP.SampleFormat = static_cast<FFMS_SampleFormat>(av_get_packed_sample_fmt(CTX->sample_fmt));
+     AP.BitsPerSample = av_get_bytes_per_sample(CTX->sample_fmt) * 8;
+diff --git a/src/core/utils.h b/src/core/utils.h
+index 9819dc7..003ab79 100644
+--- a/src/core/utils.h
++++ b/src/core/utils.h
+@@ -58,7 +58,6 @@ std::unique_ptr<T> make_unique(Args&&... args) {
+ }
+ 
+ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo);
+-void InitNullPacket(AVPacket &pkt);
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames);
+ 
+ void LAVFOpenFile(const char *SourceFile, AVFormatContext *&FormatContext, int Track);
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index 06bd161..b889970 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -673,30 +673,34 @@ void FFMS_VideoSource::DecodeNextFrame(int64_t &AStartTime, int64_t &Pos) {
+     if (HasPendingDelayedFrames())
+         return;
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
+-
+-    while (ReadFrame(&Packet) >= 0) {
+-        if (Packet.stream_index != VideoTrack) {
+-            av_packet_unref(&Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++
++    while (ReadFrame(Packet) >= 0) {
++        if (Packet->stream_index != VideoTrack) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+         if (AStartTime < 0)
+-            AStartTime = Frames.UseDTS ? Packet.dts : Packet.pts;
++            AStartTime = Frames.UseDTS ? Packet->dts : Packet->pts;
+ 
+         if (Pos < 0)
+-            Pos = Packet.pos;
++            Pos = Packet->pos;
+ 
+-        bool FrameFinished = DecodePacket(&Packet);
+-        av_packet_unref(&Packet);
+-        if (FrameFinished)
++        bool FrameFinished = DecodePacket(Packet);
++        av_packet_unref(Packet);
++        if (FrameFinished) {
++            av_packet_free(&Packet);
+             return;
++        }
+     }
+ 
+     // Flush final frames
+-    InitNullPacket(Packet);
+-    DecodePacket(&Packet);
++    DecodePacket(Packet);
++    av_packet_free(&Packet);
+ }
+ 
+ bool FFMS_VideoSource::SeekTo(int n, int SeekOffset) {
+-- 
+2.40.0
+
+From bf9e03e9e08534c024e5a744a6437c4aac160201 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:20:47 +0100
+Subject: [PATCH 2/3] configure: Remove deprecated API use
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ configure.ac | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index b35ef80bc..d19714d0f 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -102,10 +102,10 @@ CFLAGS="$_CFLAGS $FFMPEG_CFLAGS"
+
+ AC_DEFUN([TEST_FFMPEG],
+          [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+-            #include <libavcodec/avcodec.h>
++            #include <libavformat/avformat.h>
+             #include <libswscale/swscale.h>
+             ]],[[
+-                avcodec_register_all();
++                avformat_network_init();
+                 swscale_version();
+             ]])], [eval $1=yes], [eval $1=no])
+         ])
+
diff --git a/srcpkgs/ffms2/template b/srcpkgs/ffms2/template
index 365f64d10cbab..1641ecf43be5b 100644
--- a/srcpkgs/ffms2/template
+++ b/srcpkgs/ffms2/template
@@ -1,7 +1,7 @@
 # Template file for 'ffms2'
 pkgname=ffms2
 version=2.40
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-shared --disable-static"
 hostmakedepends="pkg-config autoconf automake libtool"

From 0d9d42afe00e9f95a722adcec25085437470f834 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 030/112] freerdp: revbump for ffmpeg6

---
 .../freerdp/patches/ffmpeg6_aa2cb9aa.patch    | 42 +++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100644 srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch

diff --git a/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
new file mode 100644
index 0000000000000..a4324da3a8822
--- /dev/null
+++ b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
@@ -0,0 +1,42 @@
+From aa2cb9aa5ff5562433598ba168a466e0752bca0e Mon Sep 17 00:00:00 2001
+From: akallabeth <akallabeth@posteo.net>
+Date: Tue, 14 Feb 2023 07:48:54 +0100
+Subject: [PATCH] Fixed #8686: Update h264 to use new FFMPEG API
+
+---
+ channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c | 2 ++
+ libfreerdp/codec/h264_ffmpeg.c            | 2 ++
+ 2 files changed, 4 insertions(+)
+
+diff --git a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+index 339462d865f..beea80b7a1e 100644
+--- a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
++++ b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+@@ -239,8 +239,10 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYP
+ 		}
+ 	}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 	if (mdecoder->codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		mdecoder->codec_context->flags |= AV_CODEC_FLAG_TRUNCATED;
++#endif
+ 
+ 	return TRUE;
+ }
+diff --git a/libfreerdp/codec/h264_ffmpeg.c b/libfreerdp/codec/h264_ffmpeg.c
+index 8a23db2473c..896a333019b 100644
+--- a/libfreerdp/codec/h264_ffmpeg.c
++++ b/libfreerdp/codec/h264_ffmpeg.c
+@@ -615,10 +615,12 @@ static BOOL libavcodec_init(H264_CONTEXT* h264)
+ 			goto EXCEPTION;
+ 		}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 		if (sys->codecDecoder->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		{
+ 			sys->codecDecoderContext->flags |= AV_CODEC_FLAG_TRUNCATED;
+ 		}
++#endif
+ 
+ #ifdef WITH_VAAPI
+ 

From da743bb31ce19adfe85ca7a8bd791fa42bc18d29 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 031/112] gerbera: revbump for ffmpeg6

---
 srcpkgs/gerbera/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gerbera/template b/srcpkgs/gerbera/template
index ae14f35c767c0..2dc0ac0ce03b5 100644
--- a/srcpkgs/gerbera/template
+++ b/srcpkgs/gerbera/template
@@ -1,7 +1,7 @@
 # Template file for 'gerbera'
 pkgname=gerbera
 version=1.12.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_SYSTEMD=0 -DWITH_AVCODEC=1"
 hostmakedepends="pkg-config"

From 6d7b30a11aa09a57816df4adff9e818d4565ac24 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 032/112] goldendict: revbump for ffmpeg6

---
 srcpkgs/goldendict/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/goldendict/template b/srcpkgs/goldendict/template
index f4a05759f693d..97f44347b03a6 100644
--- a/srcpkgs/goldendict/template
+++ b/srcpkgs/goldendict/template
@@ -1,7 +1,7 @@
 # Template file for 'goldendict'
 pkgname=goldendict
 version=1.5.0
-revision=1
+revision=2
 build_style=qmake
 configure_args="CONFIG+=zim_support goldendict.pro"
 hostmakedepends="qt5-qmake pkg-config qt5-host-tools"
@@ -10,7 +10,7 @@ makedepends="tiff-devel qt5-devel libvorbis-devel zlib-devel
  qt5-webkit-devel lzo-devel bzip2-devel libao-devel qt5-svg-devel
  libeb-devel qt5-x11extras-devel ffmpeg-devel liblzma-devel
  qt5-multimedia-devel"
-short_desc="A feature-rich dictionary lookup program"
+short_desc="Feature-rich dictionary lookup program"
 maintainer="John <me@johnnynator.dev>"
 license="GPL-3.0-or-later"
 homepage="http://goldendict.org/"

From b6704968891029df748263ed4b3b15a4c3ebbdd8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 033/112] gst-libav: revbump for ffmpeg6

---
 srcpkgs/gst-libav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index 78afeee4aefb2..f892eb2063564 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.22.7
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"

From b5c84d54b2bbc7394785c8819028fb1faa6501ea Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 034/112] gst-rtsp-server: revbump for ffmpeg6

---
 srcpkgs/gst-rtsp-server/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index 2c280c84f1514..83a2949fd9482 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
 version=1.22.7
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="glib-devel gst-plugins-bad1-devel gobject-introspection

From 8caaa121d394ae6c8b0d4ef05427a7dd9e65e461 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 035/112] guvcview: update to 2.0.8.

---
 srcpkgs/guvcview/patches/fix-include.patch | 10 ++++++++++
 srcpkgs/guvcview/template                  |  7 +++----
 2 files changed, 13 insertions(+), 4 deletions(-)
 create mode 100644 srcpkgs/guvcview/patches/fix-include.patch

diff --git a/srcpkgs/guvcview/patches/fix-include.patch b/srcpkgs/guvcview/patches/fix-include.patch
new file mode 100644
index 0000000000000..503c2af3b78c1
--- /dev/null
+++ b/srcpkgs/guvcview/patches/fix-include.patch
@@ -0,0 +1,10 @@
+--- a/guvcview/guvcview.c
++++ b/guvcview/guvcview.c
+@@ -28,6 +28,7 @@
+ #include <sys/stat.h>
+ #include <sys/resource.h>
+ #include <errno.h>
++#include <locale.h>
+ 
+ #include "gview.h"
+ #include "gviewv4l2core.h"
diff --git a/srcpkgs/guvcview/template b/srcpkgs/guvcview/template
index d42fd38fa4ad1..86a7fd619612c 100644
--- a/srcpkgs/guvcview/template
+++ b/srcpkgs/guvcview/template
@@ -1,8 +1,7 @@
 # Template file for 'guvcview'
 pkgname=guvcview
-version=2.0.7
-revision=2
-create_wrksrc=yes
+version=2.0.8
+revision=1
 build_style=gnu-configure
 configure_args="--disable-static --disable-debian-menu"
 hostmakedepends="pkg-config intltool autoconf automake libtool glib-devel"
@@ -14,7 +13,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="http://guvcview.sourceforge.net/"
 distfiles="${SOURCEFORGE_SITE}/${pkgname}/${pkgname}-src-${version}.tar.bz2"
-checksum=f47d51fbd06e44eeaa1a82f4a153c927527c90d94514197a70b2956028cc8ad4
+checksum=a21f4e448286666cf27bafef5290cc953a0a1796b752e5bbe521266dc1230c81
 
 post_patch() {
 	sed '31a#include <locale.h>' -i  guvcview/guvcview.c

From 0055960a389878aa2be8c1eeb23915a6d30aff50 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 036/112] handbrake: update to 1.6.1

---
 .../patches/fix-missing-x265-link-flag.patch    | 11 ++++++-----
 .../handbrake/patches/libhb-vpl-include.patch   | 15 +++++++++++++++
 srcpkgs/handbrake/template                      | 17 ++++++++++-------
 3 files changed, 31 insertions(+), 12 deletions(-)
 create mode 100644 srcpkgs/handbrake/patches/libhb-vpl-include.patch

diff --git a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
index 26db03867a0c8..d6bb2eda627a3 100644
--- a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
+++ b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
@@ -1,14 +1,15 @@
 --- a/gtk/configure.ac
 +++ b/gtk/configure.ac
 @@ -203,7 +203,7 @@
- 
+
  AM_CONDITIONAL([MINGW], [test "x$mingw_flag" = "xyes"])
- 
--HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg"
-+HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -ldl"
+
+-HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc"
++HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc -ldl"
  HB_CPPFLAGS="$HB_CPPFLAGS $HBINC"
- 
+
  PKG_CHECK_MODULES([x264], [x264], sys_x264=yes, sys_x264=no)
+
 --- a/test/module.defs
 +++ b/test/module.defs
 @@ -69,6 +69,9 @@
diff --git a/srcpkgs/handbrake/patches/libhb-vpl-include.patch b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
new file mode 100644
index 0000000000000..298f9f4ab28f2
--- /dev/null
+++ b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
@@ -0,0 +1,15 @@
+--- a/libhb/module.defs	2023-01-22 11:36:49.000000000 -0500
++++ b/libhb/module.defs	2023-04-03 22:37:52.395467010 -0400
+@@ -46,11 +46,7 @@
+ LIBHB.GCC.I += $(LIBHB.build/) $(CONTRIB.build/)include
+ 
+ ifeq (1,$(FEATURE.qsv))
+-    ifeq ($(HOST.system),freebsd))
+-        LIBHB.GCC.I += $(LOCALBASE)/include/vpl
+-    else
+-        LIBHB.GCC.I += $(CONTRIB.build/)include/vpl
+-    endif
++    LIBHB.GCC.I += /usr/include/vpl
+ endif
+ 
+ ifneq (,$(filter $(HOST.system),freebsd netbsd openbsd))
diff --git a/srcpkgs/handbrake/template b/srcpkgs/handbrake/template
index ca5e4571e49c3..c32cb1bfa31f4 100644
--- a/srcpkgs/handbrake/template
+++ b/srcpkgs/handbrake/template
@@ -1,10 +1,10 @@
 # Template file for 'handbrake'
 pkgname=handbrake
-version=1.5.1
+version=1.6.1
 revision=1
 build_style=gnu-configure
 configure_args="--force --disable-gtk-update-checks --disable-df-fetch --harden
- $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc)"
+ $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc) $(vopt_enable qsv)"
 make_build_args="-C ${XBPS_TRIPLET}"
 make_install_args="-C ${XBPS_TRIPLET}"
 hostmakedepends="automake cmake gettext-devel glib-devel intltool libtool m4 meson nasm pkg-config python3"
@@ -12,8 +12,11 @@ makedepends="bzip2-devel ffmpeg-devel gst-plugins-base1-devel gtk+3-devel
  jansson-devel lame-devel libass-devel libbluray-devel libdav1d-devel
  libdvdnav-devel libdvdread-devel libgudev-devel libnuma-devel
  libsamplerate-devel libtheora-devel libvorbis-devel libvpx-devel libxml2-devel
- opus-devel speex-devel x264-devel x265-devel zimg-devel
+ opus-devel speex-devel x264-devel x265-devel zimg-devel libsvt-av1-devel
  $(vopt_if fdk_aac fdk-aac-devel)
+ $(vopt_if qsv libva-devel)
+ $(vopt_if qsv libdrm-devel)
+ $(vopt_if qsv onevpl-devel)
  $(vopt_if nvenc nv-codec-headers)"
 depends="desktop-file-utils gst-plugins-good1 hicolor-icon-theme"
 short_desc="Multithreaded video transcoder"
@@ -21,15 +24,15 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-2.0-only"
 homepage="https://handbrake.fr/"
 distfiles="https://github.com/HandBrake/HandBrake/releases/download/${version}/HandBrake-${version}-source.tar.bz2"
-checksum=3999fe06d5309c819799a73a968a8ec3840e7840c2b64af8f5cdb7fd8c9430f0
+checksum=94ccfe03db917a91650000c510f7fd53f844da19f19ad4b4be1b8f6bc31a8d4c
 nocross=yes
 
-build_options="fdk_aac nvenc"
+build_options="fdk_aac nvenc qsv"
 
 case "$XBPS_TARGET_MACHINE" in
 	x86_64*|i686*)
 		CFLAGS="-msse"
-		build_options_default="nvenc"
+		build_options_default="nvenc qsv"
 		;;
 esac
 
@@ -37,7 +40,7 @@ pre_configure() {
 	# use system libraries, don't download them
 	rm -rf contrib/
 	for module in fdk-aac ffmpeg libbluray libdav1d libdvdnav libdvdread nvenc \
-		x265 zimg; do
+		x265 zimg svt-av1 libvpl; do
 	    vsed -i "/MODULES += contrib\/${module}/d" make/include/main.defs
 	done
 }

From 869ff82ba5bf2ffb1f41ab0062e3bbd82e739d09 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 037/112] hedgewars: revbump for ffmpeg4

---
 srcpkgs/hedgewars/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/hedgewars/template b/srcpkgs/hedgewars/template
index 94b6db673b0c3..402ccfaaecbc2 100644
--- a/srcpkgs/hedgewars/template
+++ b/srcpkgs/hedgewars/template
@@ -1,13 +1,13 @@
 # Template file for 'hedgewars'
 pkgname=hedgewars
 version=1.0.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DNOSERVER=1 -DDATA_INSTALL_DIR=/usr/share/${pkgname}
  -DPHYSFS_SYSTEM=1 -DMINIMAL_FLAGS=1"
 make_cmd=make
 hostmakedepends="lua51 pkg-config qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
+makedepends="ffmpeg4-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
  SDL2_mixer-devel SDL2_net-devel SDL2_ttf-devel"
 depends="libfreeglut"
 short_desc="Funny turn-based artillery game, featuring fighting Hedgehogs!"

From 310b1f8b8f91e03d19b8947494cd54528f9c6948 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 038/112] idjc: revbump for ffmpeg4

---
 srcpkgs/idjc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/idjc/template b/srcpkgs/idjc/template
index a9cde0665d55b..6f1d21c5781fd 100644
--- a/srcpkgs/idjc/template
+++ b/srcpkgs/idjc/template
@@ -5,7 +5,7 @@ revision=5
 build_style=gnu-configure
 hostmakedepends="pkg-config git python3 automake gettext-devel libtool"
 makedepends="libvorbis-devel libogg-devel jack-devel libsamplerate-devel
- libflac-devel libsndfile-devel mpg123-devel ffmpeg-devel speex-devel
+ libflac-devel libsndfile-devel mpg123-devel ffmpeg4-devel speex-devel
  glib-devel pixman-devel lame-devel python3-gobject-devel libshout-idjc-devel
  opus-devel twolame-devel python3-mutagen python3-devel"
 depends="python3-gobject python3-mutagen desktop-file-utils shared-mime-info python3-dbus jack"

From 5313b883fe450a15c73378e573ed029d4e92888f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 039/112] kid3: revbump for ffmpeg6

---
 srcpkgs/kid3/patches/ffmpeg5.patch | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 srcpkgs/kid3/patches/ffmpeg5.patch

diff --git a/srcpkgs/kid3/patches/ffmpeg5.patch b/srcpkgs/kid3/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..135fc50e07c9b
--- /dev/null
+++ b/srcpkgs/kid3/patches/ffmpeg5.patch
@@ -0,0 +1,17 @@
+# https://aur.archlinux.org/cgit/aur.git/diff/ffmpeg5.patch?h=kid3-cli&id=12410a74906612e7efc0ec8fbce739b4a0fef7e7
+diff --git a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+index e156d424..e12b9abd 100644
+--- a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
++++ b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+@@ -232,7 +232,11 @@ private:
+   friend class Format;
+   friend class Converter;
+   AVCodecContext* m_ptr;
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 0, 0)
+   AVCodec* m_impl;
++#else
++  const AVCodec* m_impl;
++#endif
+   AVFrame* m_frame;
+   bool m_opened;
+ };

From d16950d69eb420209560a48934d286f601d31b11 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 040/112] kodi: revbump for ffmpeg4

---
 srcpkgs/kodi/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kodi/template b/srcpkgs/kodi/template
index d37a5918cd675..536ee1fc83a7d 100644
--- a/srcpkgs/kodi/template
+++ b/srcpkgs/kodi/template
@@ -54,7 +54,7 @@ makedepends="
  libmad-devel fontconfig-devel libXinerama-devel libsamplerate-devel libmms-devel
  enca-devel boost-devel libcurl-devel libva-devel libvdpau-devel libass-devel
  libbluetooth-devel yajl-devel libplist-devel librtmp-devel tinyxml-devel
- taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg-devel
+ taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg4-devel
  giflib-devel libxslt-devel gnutls-devel libssh-devel libmicrohttpd-devel
  libcec-devel dcadec-devel flatbuffers-devel fmt-devel lcms2-devel
  libfstrcmp-devel rapidjson libcdio-paranoia spdlog libwaylandpp-devel

From 8a088fb88f08d40d0ed2c7c36ef0575d9b4eee21 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 041/112] kpipewire: revbump for ffmpeg6

---
 srcpkgs/kpipewire/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kpipewire/template b/srcpkgs/kpipewire/template
index 6214a4451336e..3555348659dde 100644
--- a/srcpkgs/kpipewire/template
+++ b/srcpkgs/kpipewire/template
@@ -1,7 +1,7 @@
 # Template file for 'kpipewire'
 pkgname=kpipewire
 version=5.27.10
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules plasma-wayland-protocols gettext
  qt5-qmake qt5-host-tools pkg-config wayland-devel kcoreaddons

From fef46622e31f79cd934e0095be51d3d0e4c7e295 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 042/112] libextractor: revbump for ffmpeg4

---
 srcpkgs/libextractor/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libextractor/template b/srcpkgs/libextractor/template
index 044c663a3a0b9..ace88ae128da5 100644
--- a/srcpkgs/libextractor/template
+++ b/srcpkgs/libextractor/template
@@ -7,7 +7,7 @@ configure_args="--disable-static"
 hostmakedepends="pkg-config"
 makedepends="zlib-devel bzip2-devel exiv2-devel tiff-devel libpng-devel
  libjpeg-turbo-devel libvorbis-devel libflac-devel giflib-devel libmpeg2-devel
- ffmpeg-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
+ ffmpeg4-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
 short_desc="Library used to extract meta data from files"
 maintainer="Martin Riese <grauehaare@gmx.de>"
 license="GPL-3.0-or-later"

From 2e8641f4c8ae93fa2e8d7adf952b59b7ba40e594 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 043/112] libopenal: revbump for ffmpeg6

---
 srcpkgs/libopenal/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenal/template b/srcpkgs/libopenal/template
index 88d0f11307d81..8308fca0393e3 100644
--- a/srcpkgs/libopenal/template
+++ b/srcpkgs/libopenal/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenal'
 pkgname=libopenal
 version=1.23.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DALSOFT_EXAMPLES=OFF"
 hostmakedepends="pkg-config"

From 33c89275ca52e22aed5dc2fe63d455fec10e93e5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 044/112] loudgain: revbump for ffmpeg6

---
 srcpkgs/loudgain/patches/ffmpeg5.patch | 11 +++++++++++
 srcpkgs/loudgain/template              |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/loudgain/patches/ffmpeg5.patch

diff --git a/srcpkgs/loudgain/patches/ffmpeg5.patch b/srcpkgs/loudgain/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..16d4510ee98fa
--- /dev/null
+++ b/srcpkgs/loudgain/patches/ffmpeg5.patch
@@ -0,0 +1,11 @@
+--- a/src/scan.c	2019-09-06 11:31:19.000000000 -0400
++++ b/src/scan.c	2023-03-23 11:15:40.867968521 -0400
+@@ -69,8 +69,6 @@
+ 	 * It is now useless
+ 	 * https://github.com/FFmpeg/FFmpeg/blob/70d25268c21cbee5f08304da95be1f647c630c15/doc/APIchanges#L86
+ 	 */
+-  if (avformat_version() < AV_VERSION_INT(58,9,100))
+-    av_register_all();
+ 
+ 	av_log_set_callback(scan_av_log);
+ 
diff --git a/srcpkgs/loudgain/template b/srcpkgs/loudgain/template
index da4f2d56e94c3..4d6bf29efb4fd 100644
--- a/srcpkgs/loudgain/template
+++ b/srcpkgs/loudgain/template
@@ -1,7 +1,7 @@
 # Template file for 'loudgain'
 pkgname=loudgain
 version=0.6.8
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libebur128-devel taglib-devel ffmpeg-devel"

From 78cdc510fdf379e193c8daf301da571cbedc210c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 045/112] mediastreamer: revbump for ffmpeg4

---
 srcpkgs/mediastreamer/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mediastreamer/template b/srcpkgs/mediastreamer/template
index 0fcffa7653d18..92ada88743a9b 100644
--- a/srcpkgs/mediastreamer/template
+++ b/srcpkgs/mediastreamer/template
@@ -5,7 +5,7 @@ revision=2
 build_style=cmake
 configure_args="-DENABLE_STRICT=0 -DENABLE_UNIT_TESTS=0"
 hostmakedepends="python3"
-makedepends="bzrtp-devel ffmpeg-devel glew-devel libXv-devel libsrtp-devel
+makedepends="bzrtp-devel ffmpeg4-devel glew-devel libXv-devel libsrtp-devel
  libupnp-devel libvpx-devel mbedtls-devel opus-devel ortp-devel pulseaudio-devel
  libtheora-devel speex-devel v4l-utils-devel bcg729-devel bcmatroska2-devel libgsm-devel
  zxing-cpp-devel"

From 3452fcc41b0681b76cb926495c5e2258082b1355 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 046/112] mgba: revbump for ffmpeg6

---
 srcpkgs/mgba/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mgba/template b/srcpkgs/mgba/template
index 5513e3fd16f3f..f5c87a4893002 100644
--- a/srcpkgs/mgba/template
+++ b/srcpkgs/mgba/template
@@ -1,7 +1,7 @@
 # Template file for 'mgba'
 pkgname=mgba
 version=0.10.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake desktop-file-utils"
 makedepends="SDL2-devel ffmpeg-devel libedit-devel libepoxy-devel libmagick-devel

From a4d8e3e78437191142ead1e7fcb6d3426dc5ed82 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 047/112] mlt: revbump for ffmpeg4

---
 srcpkgs/mlt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mlt/template b/srcpkgs/mlt/template
index 73e3915aaab9a..ec5054be3b75e 100644
--- a/srcpkgs/mlt/template
+++ b/srcpkgs/mlt/template
@@ -8,7 +8,7 @@ configure_args="--prefix=/usr --libdir=/usr/lib$XBPS_TARGET_WORDSIZE
  --swig-languages=python"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which"
 # XXX: movit vid.stab
-makedepends="alsa-lib-devel ffmpeg-devel gtk+-devel jack-devel ladspa-sdk
+makedepends="alsa-lib-devel ffmpeg4-devel gtk+-devel jack-devel ladspa-sdk
  libexif-devel libsamplerate-devel libxml2-devel sox-devel SDL_image-devel
  fftw-devel frei0r-plugins python3-devel pulseaudio-devel movit-devel
  libvidstab-devel"

From 170b2ea04aad88fb2ace83484f03132969fd972a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 048/112] moc: revbump for ffmpeg4

---
 srcpkgs/moc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/moc/template b/srcpkgs/moc/template
index 3a04932c8f1e6..d8de816026b64 100644
--- a/srcpkgs/moc/template
+++ b/srcpkgs/moc/template
@@ -4,7 +4,7 @@ version=2.5.2
 revision=7
 build_style=gnu-configure
 hostmakedepends="pkg-config"
-makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg-devel
+makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg4-devel
  jack-devel alsa-lib-devel libltdl-devel libflac-devel libvorbis-devel
  libmad-devel libmpcdec-devel libmodplug-devel libid3tag-devel faad2-devel
  taglib-devel libsndfile-devel wavpack-devel speex-devel libsamplerate-devel

From cd3da57fb5df58e1f06cfaa8dea64df060234137 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 049/112] motion: revbump for ffmpeg6

---
 srcpkgs/motion/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/motion/template b/srcpkgs/motion/template
index 607ebeb3c7b24..bf63a91d9764f 100644
--- a/srcpkgs/motion/template
+++ b/srcpkgs/motion/template
@@ -1,7 +1,7 @@
 # Template file for 'motion'
 pkgname=motion
 version=4.6.0
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake pkg-config gettext-devel tar"
 makedepends="ffmpeg-devel libmicrohttpd-devel v4l-utils-devel gettext-devel"

From b58074a9c8e1455c8a1ef5f2fcde60046f7092cc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 050/112] olive: revbump for ffmpeg4

---
 srcpkgs/olive/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/olive/template b/srcpkgs/olive/template
index 12a46936c9900..5c2917b9c5124 100644
--- a/srcpkgs/olive/template
+++ b/srcpkgs/olive/template
@@ -1,10 +1,10 @@
 # Template file for 'olive'
 pkgname=olive
 version=0.1.2
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools pkg-config"
-makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg-devel frei0r-plugins"
+makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg4-devel frei0r-plugins"
 short_desc="Non-linear video editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"

From e83e9c622c12fd89f6deee586601c67182b6599a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 051/112] opentoonz: revbump for ffmpeg6

---
 srcpkgs/opentoonz/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/opentoonz/template b/srcpkgs/opentoonz/template
index ee9f7603f55fd..3e81834ca0edd 100644
--- a/srcpkgs/opentoonz/template
+++ b/srcpkgs/opentoonz/template
@@ -1,7 +1,7 @@
 # Template file for 'opentoonz'
 pkgname=opentoonz
 version=1.6.0
-revision=2
+revision=3
 build_wrksrc="toonz/sources"
 build_style=cmake
 make_cmd=make

From 7d505d2c074bfb8e27991074b966496e51594755 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 052/112] pianobar: revbump for ffmpeg6

---
 srcpkgs/pianobar/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pianobar/template b/srcpkgs/pianobar/template
index e3febb821a451..1e3dc1bf9308e 100644
--- a/srcpkgs/pianobar/template
+++ b/srcpkgs/pianobar/template
@@ -1,7 +1,7 @@
 # Template file for 'pianobar'
 pkgname=pianobar
 version=2022.04.01
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="V=1"
 hostmakedepends="pkg-config"

From b91fa530761fec4ddba63acfd1138d4e4d173bfe Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 053/112] ppsspp: revbump for ffmpeg4

---
 srcpkgs/ppsspp/template | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/srcpkgs/ppsspp/template b/srcpkgs/ppsspp/template
index 2c0ded496eb98..8bf55f65198cd 100644
--- a/srcpkgs/ppsspp/template
+++ b/srcpkgs/ppsspp/template
@@ -1,7 +1,7 @@
 # Template file for 'ppsspp'
 pkgname=ppsspp
 version=1.16.6
-revision=1
+revision=2
 _glslang_commit=b34f619e1c85810dcb3c578107d2e48ba4ee2b37
 _SPIRV_Cross_commit=4212eef67ed0ca048cb726a6767185504e7695e5
 _armips_commit=7bd1ec93d4586985ba1ef420b43b5e620f68695e
@@ -15,7 +15,7 @@ configure_args="-DHEADLESS=1 -DUSE_SYSTEM_FFMPEG=1 -DUNITTEST=ON
  -DUSING_QT_UI=$(vopt_if qt ON OFF) -DUSE_SYSTEM_ZSTD=ON
  -DARMIPS_USE_STD_FILESYSTEM=ON"
 hostmakedepends="pkg-config python3 $(vopt_if qt qt5-host-tools)"
-makedepends="zlib-devel glew-devel ffmpeg-devel libzip-devel
+makedepends="zlib-devel glew-devel ffmpeg4-devel libzip-devel
  snappy-devel rapidjson libpng-devel libzstd-devel
  $(vopt_if sdl2 'SDL2_ttf-devel SDL2-devel') $(vopt_if wayland wayland-devel)
  $(vopt_if qt 'qt5-devel qt5-multimedia-devel')"
@@ -69,10 +69,10 @@ post_extract() {
 	rmdir -v ${wrksrc}/ext/cpu_features
 	mv ${wrksrc}/cpu_features-${_cpu_features_commit} ${wrksrc}/ext/cpu_features
 	rmdir -v ${wrksrc}/ext/rcheevos
-        mv ${wrksrc}/rcheevos-${_rcheevos_commit} ${wrksrc}/ext/rcheevos
+	mv ${wrksrc}/rcheevos-${_rcheevos_commit} ${wrksrc}/ext/rcheevos
 }
 
-post_patch(){
+post_patch() {
 	# disable git versioning
 	vsed -e 's|find_package(Git)|# &|' -i git-version.cmake
 }
@@ -85,7 +85,6 @@ post_configure() {
 }
 
 do_install() {
-	vlicense LICENSE.TXT
 	vinstall icons/icon.svg 644 usr/share/pixmaps ppsspp.svg
 	vinstall Qt/PPSSPP.desktop 644 usr/share/applications
 	vbin build/PPSSPPHeadless ppsspp-headless

From c1a50f50a210a50f9efbc5f281c9acb9445c92a3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 054/112] pqiv: revbump for ffmpeg6

---
 srcpkgs/pqiv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pqiv/template b/srcpkgs/pqiv/template
index 542fc27a2d32a..9308d949b6a1c 100644
--- a/srcpkgs/pqiv/template
+++ b/srcpkgs/pqiv/template
@@ -1,7 +1,7 @@
 # Template file for 'pqiv'
 pkgname=pqiv
 version=2.12
-revision=1
+revision=2
 build_style=gnu-makefile
 hostmakedepends="pkg-config"
 makedepends="glib-devel gtk+3-devel $(vopt_if ffmpeg ffmpeg-devel)

From 5b1841bd6068c370e18ec670833b6f420f4e1c56 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 055/112] qmmp: revbump for ffmpeg6

---
 srcpkgs/qmmp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qmmp/template b/srcpkgs/qmmp/template
index 53781ea3bc28a..2da07f1e87eac 100644
--- a/srcpkgs/qmmp/template
+++ b/srcpkgs/qmmp/template
@@ -1,7 +1,7 @@
 # Template file for 'qmmp'
 pkgname=qmmp
 version=1.6.1
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DUSE_HAL:BOOL=FALSE -DQMMP_DEFAULT_UI:STRING=simple"
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From 50c5af7f7b048170fd0d66fe499902d7dde8e9da Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 14 Dec 2023 13:28:10 -0500
Subject: [PATCH 056/112] qt6-pdf: revbump for ffmpeg6

---
 srcpkgs/qt6-pdf/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-pdf/template b/srcpkgs/qt6-pdf/template
index ecda84afac131..531b4e1d4fe84 100644
--- a/srcpkgs/qt6-pdf/template
+++ b/srcpkgs/qt6-pdf/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-pdf'
 pkgname=qt6-pdf
 version=6.6.0
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DQT_FEATURE_qtpdf_build=ON
  -DQT_FEATURE_qtpdf_widgets_build=ON

From 03d3d2455a79d7f9ee0e425c407c6ab7c3db7ec6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 057/112] qt5-webengine: revbump for ffmpeg6

---
 .../chromium-media-filters-cpp14.patch        |  11 ++
 srcpkgs/qt5-webengine/patches/ffmpeg5.patch   | 179 ++++++++++++++++++
 .../qtwebengine-fix-ffmpeg5-build.patch       |  14 ++
 srcpkgs/qt5-webengine/template                |   4 +-
 4 files changed, 206 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/ffmpeg5.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch

diff --git a/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
new file mode 100644
index 0000000000000..04adc540f2cbc
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
@@ -0,0 +1,11 @@
+--- a/src/3rdparty/chromium/media/filters/BUILD.gn	2023-02-27 13:32:59.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/BUILD.gn	2023-04-02 17:21:39.204066384 -0400
+@@ -96,6 +96,8 @@
+     "//ui/gfx/geometry:geometry",
+   ]
+ 
++  cflags_cc = [ "-std=c++14" ]
++
+   libs = []
+ 
+   if (proprietary_codecs) {
diff --git a/srcpkgs/qt5-webengine/patches/ffmpeg5.patch b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..ac55e1634423a
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
@@ -0,0 +1,179 @@
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:57.732547446 -0400
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:09.486478995 -0400
+@@ -57,6 +57,8 @@
+ 
+ namespace {
+ 
++constexpr int64_t kRelativeTsBase = static_cast<int64_t>(0x7ffeffffffffffff);
++
+ void SetAVStreamDiscard(AVStream* stream, AVDiscard discard) {
+   DCHECK(stream);
+   stream->discard = discard;
+@@ -90,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+   if (stream->start_time != kNoFFmpegTimestamp)
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (stream->first_dts != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, stream->first_dts);
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -408,11 +398,11 @@
+   scoped_refptr<DecoderBuffer> buffer;
+ 
+   if (type() == DemuxerStream::TEXT) {
+-    int id_size = 0;
++    size_t id_size = 0;
+     uint8_t* id_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
+ 
+-    int settings_size = 0;
++    size_t settings_size = 0;
+     uint8_t* settings_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
+ 
+@@ -424,7 +414,7 @@
+     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
+                                      side_data.data(), side_data.size());
+   } else {
+-    int side_data_size = 0;
++    size_t side_data_size = 0;
+     uint8_t* side_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
+ 
+@@ -485,7 +475,7 @@
+                                        packet->size - data_offset);
+     }
+ 
+-    int skip_samples_size = 0;
++    size_t skip_samples_size = 0;
+     const uint32_t* skip_samples_ptr =
+         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
+             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
+@@ -1587,6 +1577,8 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++      continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+       lowest_start_time_stream = stream.get();
+@@ -1604,6 +1596,8 @@
+     if (stream && stream->type() == DemuxerStream::VIDEO &&
+         stream->IsEnabled()) {
+       video_stream = stream.get();
++      if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++        continue;
+       if (video_stream->start_time() <= seek_time) {
+         return video_stream;
+       }
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h qtwebengine-5.15.10/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h
+--- a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-07-11 22:12:47.917192788 -0500
+@@ -29,6 +29,7 @@ extern "C" {
+ #include <libavformat/avformat.h>
+ #include <libavformat/avio.h>
+ #include <libavutil/avutil.h>
++#include <libavutil/channel_layout.h>
+ #include <libavutil/imgutils.h>
+ #include <libavutil/log.h>
+ #include <libavutil/mastering_display_metadata.h>
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/audio_file_reader.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/audio_file_reader.cc
+--- a/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -85,7 +85,7 @@ bool AudioFileReader::OpenDemuxer() {
+ }
+ 
+ bool AudioFileReader::OpenDecoder() {
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (codec) {
+     // MP3 decodes to S16P which we don't support, tell it to use S16 instead.
+     if (codec_context_->sample_fmt == AV_SAMPLE_FMT_S16P)
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -329,7 +329,7 @@ bool FFmpegAudioDecoder::ConfigureDecode
+     }
+   }
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec ||
+       avcodec_open2(codec_context_.get(), codec, &codec_options) < 0) {
+     DLOG(ERROR) << "Could not initialize audio decoder: "
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -59,7 +59,6 @@ static int64_t AVIOSeekOperation(void* o
+ }
+ 
+ void FFmpegGlue::InitializeFFmpeg() {
+-  av_register_all();
+ }
+ 
+ static void LogContainer(bool is_local_file,
+@@ -95,9 +94,6 @@ FFmpegGlue::FFmpegGlue(FFmpegURLProtocol
+   // Enable fast, but inaccurate seeks for MP3.
+   format_context_->flags |= AVFMT_FLAG_FAST_SEEK;
+ 
+-  // Ensures we can read out various metadata bits like vp8 alpha.
+-  format_context_->flags |= AVFMT_FLAG_KEEP_SIDE_DATA;
+-
+   // Ensures format parsing errors will bail out. From an audit on 11/2017, all
+   // instances were real failures. Solves bugs like http://crbug.com/710791.
+   format_context_->error_recognition |= AV_EF_EXPLODE;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -391,7 +391,7 @@ bool FFmpegVideoDecoder::ConfigureDecode
+   if (decode_nalus_)
+     codec_context_->flags2 |= AV_CODEC_FLAG2_CHUNKS;
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
+     ReleaseFFmpegResources();
+     return false;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/media_file_checker.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/media_file_checker.cc
+--- a/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -68,7 +68,7 @@ bool MediaFileChecker::Start(base::TimeD
+       auto context = AVStreamToAVCodecContext(format_context->streams[i]);
+       if (!context)
+         continue;
+-      AVCodec* codec = avcodec_find_decoder(cp->codec_id);
++      const AVCodec* codec = avcodec_find_decoder(cp->codec_id);
+       if (codec && avcodec_open2(context.get(), codec, nullptr) >= 0) {
+         auto loop = std::make_unique<FFmpegDecodingLoop>(context.get());
+         stream_contexts[i] = {std::move(context), std::move(loop)};
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc qtwebengine-5.15.10/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc
+--- a/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -203,7 +203,7 @@ int32_t H264DecoderImpl::InitDecode(cons
+   // a pointer |this|.
+   av_context_->opaque = this;
+ 
+-  AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
+   if (!codec) {
+     // This is an indication that FFmpeg has not been initialized or it has not
+     // been compiled/initialized with the correct set of codecs.
diff --git a/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch b/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch
new file mode 100644
index 0000000000000..bc24d5b9a29cb
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch
@@ -0,0 +1,14 @@
+--- a/src/buildtools/configure.json	2023-12-09 11:06:01.503058569 -0500
++++ b/src/buildtools/configure.json	2023-12-09 11:06:14.982361345 -0500
+@@ -779,11 +779,6 @@
+             "type": "warning",
+             "condition": "config.ios && config.simulator && config.device && features.build-qtpdf",
+             "message": "Building fat libray with device and simulator architectures will disable NEON."
+-        },
+-        {
+-            "type": "fatal",
+-            "condition": "features.webengine-system-ffmpeg && !libs.webengine-ffmpeg-support",
+-            "message": "Unmodified ffmpeg >= 5.0 is not supported. Please configure with -qt-webengine-ffmpeg."
+         }
+     ],
+     "summary": [
diff --git a/srcpkgs/qt5-webengine/template b/srcpkgs/qt5-webengine/template
index 8d2df1b5175ba..1687a77eb8a2f 100644
--- a/srcpkgs/qt5-webengine/template
+++ b/srcpkgs/qt5-webengine/template
@@ -1,14 +1,14 @@
 # Template file for 'qt5-webengine'
 pkgname=qt5-webengine
 version=5.15.16
-revision=1
+revision=2
 _version="${version}-lts"
 _chromium_commit=207c2ac45ca3386d153770c6b0d2ea2ec21ca880
 archs="x86_64* i686* armv[67]* ppc64* aarch64*"
 create_wrksrc=yes
 build_style=qmake
 configure_args="--
- -webengine-icu -webengine-ffmpeg -webengine-opus -webengine-webp
+ -webengine-icu -system-ffmpeg -webengine-opus -webengine-webp
  -webengine-pepper-plugins -webengine-printing-and-pdf -webengine-proprietary-codecs
  -webengine-pulseaudio -webengine-spellchecker -webengine-webrtc -webengine-geolocation
  -webengine-kerberos -no-webengine-embedded-build $(vopt_if sndio '' '-no')-webengine-sndio

From 8f5b0e3de36312a58545aee62ee97799b8a5b03f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 058/112] qt5: revbump for ffmpeg6

---
 srcpkgs/qt5/template | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/srcpkgs/qt5/template b/srcpkgs/qt5/template
index ef6e437e02dbc..97b7818cc37d8 100644
--- a/srcpkgs/qt5/template
+++ b/srcpkgs/qt5/template
@@ -3,9 +3,9 @@
 # revbump libqtxdg after bumping patch version
 pkgname=qt5
 version=5.15.11+20231124
+revision=2
 # commit 4765fa1df7a837db9c1f89c4da0dd76b74bb5fab
 # base repo: https://invent.kde.org/qt/qt/qt5
-revision=1
 build_style=meta
 hostmakedepends="cmake clang flex perl glib-devel pkg-config
  python3 re2c ruby which"
@@ -246,7 +246,6 @@ do_configure() {
 	# opts+=" -v"
 	opts+=" -skip qtwebengine"
 	opts+=" -skip qtwebview"
-	opts+=" -skip qtdocgallery"
 	opts+=" -skip qtpim"
 	opts+=" -skip qtsystems"
 	opts+=" -skip qtspeech"

From 3dbd5929de6bb27ffd9e346d81ca4030258fd841 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 059/112] qtav: revbump for ffmpeg4

---
 srcpkgs/qtav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qtav/template b/srcpkgs/qtav/template
index 775d5a139a9ef..2d00ad104355e 100644
--- a/srcpkgs/qtav/template
+++ b/srcpkgs/qtav/template
@@ -4,7 +4,7 @@ version=1.13.0
 revision=2
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel libass-devel libopenal-devel
+makedepends="ffmpeg4-devel libass-devel libopenal-devel
  libva-glx-devel libXv-devel pulseaudio-devel
  qt5-declarative-devel qt5-svg-devel
  qt5-quickcontrols"

From 03533ac47bda935d7e242c1841e51e3fb5d64598 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 060/112] retroarch: revbump for ffmpeg6

---
 srcpkgs/retroarch/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroarch/template b/srcpkgs/retroarch/template
index cb3125c5dbf1a..c65c26f7bf033 100644
--- a/srcpkgs/retroarch/template
+++ b/srcpkgs/retroarch/template
@@ -1,7 +1,7 @@
 # Template file for 'retroarch'
 pkgname=retroarch
 version=1.16.0.3
-revision=3
+revision=4
 build_style=configure
 configure_args="--prefix=/usr --sysconfdir=/etc --enable-networking
  --enable-udev --disable-builtinflac --disable-builtinglslang

From f99391b632b21e4ffc4b88d12751e7816ac0e9f6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 061/112] scrcpy: revbump for ffmpeg6

---
 srcpkgs/scrcpy/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/scrcpy/template b/srcpkgs/scrcpy/template
index ac18bc03418ce..f39a7f678ab35 100644
--- a/srcpkgs/scrcpy/template
+++ b/srcpkgs/scrcpy/template
@@ -1,7 +1,7 @@
 # Template file for 'scrcpy'
 pkgname=scrcpy
 version=2.1.1
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcompile_server=false
  -Dprebuilt_server=/usr/share/scrcpy/scrcpy-server-v${version}"

From 7a1bf453593cede854a930601fe24a72660ed3b5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 17 Oct 2023 08:54:11 -0400
Subject: [PATCH 062/112] New package: spex-x replaces spek-alternative for
 ffmpeg6

---
 srcpkgs/spek-alternative                      |  1 +
 srcpkgs/{spek-alternative => spek-x}/template | 22 ++++++++++++-------
 2 files changed, 15 insertions(+), 8 deletions(-)
 create mode 120000 srcpkgs/spek-alternative
 rename srcpkgs/{spek-alternative => spek-x}/template (52%)

diff --git a/srcpkgs/spek-alternative b/srcpkgs/spek-alternative
new file mode 120000
index 0000000000000..76648236da701
--- /dev/null
+++ b/srcpkgs/spek-alternative
@@ -0,0 +1 @@
+spek-x
\ No newline at end of file
diff --git a/srcpkgs/spek-alternative/template b/srcpkgs/spek-x/template
similarity index 52%
rename from srcpkgs/spek-alternative/template
rename to srcpkgs/spek-x/template
index d7b55c776b1d4..3ded6c2c323e4 100644
--- a/srcpkgs/spek-alternative/template
+++ b/srcpkgs/spek-x/template
@@ -1,18 +1,18 @@
-# Template file for 'spek-alternative'
-pkgname=spek-alternative
-version=0.8.2.3
-revision=2
+# Template file for 'spek-x'
+pkgname=spek-x
+version=0.9.3
+revision=1
 build_style=gnu-configure
 hostmakedepends="automake gettext-devel intltool libtool pkg-config
  wxWidgets-common wxWidgets-gtk3-devel"
 makedepends="ffmpeg-devel wxWidgets-gtk3-devel"
 depends="ffmpeg"
 short_desc="Acoustic spectrum analyser"
-maintainer="Kartik Singh <kartik.ynwa@gmail.com>"
+maintainer="zlice <zlice555@gmail.com>"
 license="GPL-3.0-or-later"
-homepage="https://github.com/withmorten/spek-alternative"
-distfiles="https://github.com/withmorten/spek-alternative/archive/${version}.tar.gz"
-checksum="007ba4b84a310b078e378aa84c8e80783db5821437a757a488c3ecec377e6b2a"
+homepage="https://github.com/MikeWang000000/spek-x"
+distfiles="https://github.com/MikeWang000000/spek-x/archive/v${version}.tar.gz"
+checksum="7f4b109903333cdd310ab2b9176f0dc49a565891376e281a233d342cedf90ef7"
 
 CXXFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
 
@@ -22,3 +22,9 @@ export WX_CONFIG_NAME="wx-config-gtk3"
 pre_configure() {
 	NOCONFIGURE=1 ./autogen.sh
 }
+
+spek-alternative_package() {
+	depends="spek-x"
+	short_desc+=" - transitional dummy package"
+	build_style=meta
+}

From 8d595847d8c50a87c748db6785e2ed603026e680 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 063/112] ssr: revbump for ffmpeg4

---
 srcpkgs/ssr/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ssr/template b/srcpkgs/ssr/template
index 3097754e3cbe5..fa66d5b4736d4 100644
--- a/srcpkgs/ssr/template
+++ b/srcpkgs/ssr/template
@@ -5,7 +5,7 @@ revision=2
 build_style=cmake
 configure_args="-DWITH_QT5=ON"
 hostmakedepends="pkg-config"
-makedepends="alsa-lib-devel ffmpeg-devel glu-devel jack-devel pulseaudio-devel
+makedepends="alsa-lib-devel ffmpeg4-devel glu-devel jack-devel pulseaudio-devel
  qt5-tools-devel qt5-x11extras-devel libXinerama-devel v4l-utils-devel"
 depends="desktop-file-utils hicolor-icon-theme"
 short_desc="Simple Screen Recorder for programs and games"

From fa455a565e7561d98c6248e598e2d4bb8414165e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 064/112] synfig: revbump for ffmpeg6 and mlt7

---
 srcpkgs/synfig/patches/ffmpeg6.patch | 71 ++++++++++++++++++++++++++++
 srcpkgs/synfig/template              |  4 +-
 2 files changed, 73 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/synfig/patches/ffmpeg6.patch

diff --git a/srcpkgs/synfig/patches/ffmpeg6.patch b/srcpkgs/synfig/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..10780b42782f4
--- /dev/null
+++ b/srcpkgs/synfig/patches/ffmpeg6.patch
@@ -0,0 +1,71 @@
+--- a/src/modules/mod_libavcodec/trgt_av.cpp	2022-10-25 09:14:12.000000000 -0400
++++ b/src/modules/mod_libavcodec/trgt_av.cpp	2023-05-05 21:34:17.899194559 -0400
+@@ -38,6 +41,7 @@
+ extern "C"
+ {
+ #ifdef HAVE_LIBAVFORMAT_AVFORMAT_H
++#	include <libavcodec/avcodec.h>
+ #	include <libavformat/avformat.h>
+ #elif defined(HAVE_AVFORMAT_H)
+ #	include <avformat.h>
+@@ -155,11 +156,11 @@
+     }
+ 
+ 	bool open_video_stream() {
+-		if (avcodec_open2(video_context, NULL, NULL) < 0) {
++		if (avcodec_open2(video_context, nullptr, nullptr) < 0) {
+ 			synfig::error("Target_LibAVCodec: could not open video codec");
+ 			// seems the calling of avcodec_free_context after error will cause crash
+ 			// so just forget about this context
+-			video_context = NULL;
++			video_context = nullptr;
+ 			close();
+ 			return false;
+         }
+@@ -234,15 +235,21 @@
+ 		close();
+ 
+ 		if (!av_registered) {
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 			av_register_all();
++#endif
+ 			av_registered = true;
+ 		}
+ 
+ 		// guess format
+-		AVOutputFormat *format = av_guess_format(NULL, filename.c_str(), NULL);
++#if LIBAVCODEC_VERSION_MAJOR < 59 // FFMPEG < 5.0
++		AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#else
++		const AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#endif
+ 		if (!format) {
+ 			synfig::warning("Target_LibAVCodec: unable to guess the output format, defaulting to MPEG");
+-			format = av_guess_format("mpeg", NULL, NULL);
++			format = av_guess_format("mpeg", nullptr, nullptr);
+ 		}
+ 		if (!format) {
+ 			synfig::error("Target_LibAVCodec: unable to find 'mpeg' output format");
+@@ -254,6 +261,7 @@
+ 		context = avformat_alloc_context();
+ 		assert(context);
+ 		context->oformat = format;
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 		if (filename.size() + 1 > sizeof(context->filename)) {
+ 			synfig::error(
+ 				"Target_LibAVCodec: filename too long, max length is %d, filename is '%s'",
+@@ -263,6 +271,14 @@
+ 			return false;
+ 		}
+ 		memcpy(context->filename, filename.c_str(), filename.size() + 1);
++#else
++		context->url = av_strndup(filename.c_str(), filename.size());
++		if (!context->url) {
++			synfig::error("Target_LibAVCodec: cannot allocate space for filename");
++			close();
++			return false;
++		}
++#endif
+ 
+ 		packet = av_packet_alloc();
+ 		assert(packet);
diff --git a/srcpkgs/synfig/template b/srcpkgs/synfig/template
index d4d3e341a20bf..703cfd7ebac84 100644
--- a/srcpkgs/synfig/template
+++ b/srcpkgs/synfig/template
@@ -6,7 +6,7 @@ revision=4
 build_style=gnu-configure
 configure_args="--with-boost-libdir=${XBPS_CROSS_BASE}/usr/lib"
 hostmakedepends="boost-build ImageMagick pkg-config intltool"
-makedepends="ETL gettext-devel libxml++-devel mlt-devel libmagick-devel
+makedepends="ETL gettext-devel libxml++-devel mlt7-devel libmagick-devel
  libmng-devel boost-build boost-devel libopenexr-devel ffmpeg-devel"
 depends="ImageMagick"
 short_desc="CLI 2D vector and timeline-based animation software"
@@ -20,7 +20,7 @@ CXXFLAGS="-std=c++11 -DHAVE_LOCALE_H=1"
 
 synfig-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision}
-	 libopenexr-devel libxml++-devel mlt-devel"
+	 libopenexr-devel libxml++-devel mlt7-devel"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/bin/synfig-config

From 694fbd3ae35cb5790c5efac01713afa9a18f4084 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 065/112] timg: revbump for ffmpeg6

---
 srcpkgs/timg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/timg/template b/srcpkgs/timg/template
index 2a2ab763d2fdd..8fb4327535ef9 100644
--- a/srcpkgs/timg/template
+++ b/srcpkgs/timg/template
@@ -1,7 +1,7 @@
 # Template file for 'timg'
 pkgname=timg
 version=1.4.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_OPENSLIDE_SUPPORT=off -Wno-dev"
 hostmakedepends="pkg-config git"

From 5598d11bdf6b8fea09c850f51de4f57d0ddfe465 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 066/112] tvheadend: revbump for ffmpeg4

---
 srcpkgs/tvheadend/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tvheadend/template b/srcpkgs/tvheadend/template
index 9aea7de4ec705..012d31c4879ff 100644
--- a/srcpkgs/tvheadend/template
+++ b/srcpkgs/tvheadend/template
@@ -8,7 +8,7 @@ configure_args="--enable-dvbscan --disable-ffmpeg_static
 --disable-libx265_static --disable-libvpx_static --disable-libtheora_static
 --disable-libvorbis_static --disable-libfdkaac_static"
 hostmakedepends="gettext pkg-config python3 git which"
-makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg-devel"
+makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg4-devel"
 short_desc="TV streaming server"
 maintainer="lemmi <lemmi@nerd2nerd.org>"
 license="GPL-3.0-only"

From 869b5b4a50a7e444e2c3862773cb8c1449740205 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 067/112] unpaper: update to 7.0.0.

---
 srcpkgs/unpaper/template | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/srcpkgs/unpaper/template b/srcpkgs/unpaper/template
index 38ed47a584016..1ff910e722afc 100644
--- a/srcpkgs/unpaper/template
+++ b/srcpkgs/unpaper/template
@@ -1,13 +1,13 @@
 # Template file for 'unpaper'
 pkgname=unpaper
-version=6.1
-revision=3
-build_style=gnu-configure
+version=7.0.0
+revision=1
+build_style=meson
+hostmakedepends="pkg-config meson libxslt"
+makedepends="ffmpeg-devel python3-Sphinx"
+short_desc="Post-processing tool for scanned sheets of paper"
 maintainer="Orphaned <orphan@voidlinux.org>"
-hostmakedepends="pkg-config libxslt"
-makedepends="ffmpeg-devel"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://www.flameeyes.eu/projects/unpaper"
-short_desc="A post-processing tool for scanned sheets of paper"
 distfiles="https://www.flameeyes.eu/files/${pkgname}-${version}.tar.xz"
-checksum=237c84f5da544b3f7709827f9f12c37c346cdf029b1128fb4633f9bafa5cb930
+checksum=2575fbbf26c22719d1cb882b59602c9900c7f747118ac130883f63419be46a80

From d4ca0e4abbc29fc068ddf6182dc389880bffbc00 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 068/112] vice: revbump for ffmpeg4

---
 srcpkgs/vice/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vice/template b/srcpkgs/vice/template
index b1f866d35095e..4beab2c5f9ebd 100644
--- a/srcpkgs/vice/template
+++ b/srcpkgs/vice/template
@@ -26,7 +26,7 @@ makedepends="
 	$(vopt_if gtk3 gtk+3-devel)
 	$(vopt_if gtk3 pulseaudio-devel)
 	$(vopt_if gtk3 pango-devel)
-	$(vopt_if ffmpeg ffmpeg-devel)"
+	$(vopt_if ffmpeg ffmpeg4-devel)"
 short_desc="Emulator for C64, C128, CBM-II, PET, VIC20, Plus4 and C16"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"

From f8cae278a2e9455efd5197441278685024234bb4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 069/112] waypipe: revbump for ffmpeg6

---
 srcpkgs/waypipe/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waypipe/template b/srcpkgs/waypipe/template
index 6da88b21bf2a1..4da8058400b58 100644
--- a/srcpkgs/waypipe/template
+++ b/srcpkgs/waypipe/template
@@ -1,7 +1,7 @@
 # Template file for 'waypipe'
 pkgname=waypipe
 version=0.8.6
-revision=1
+revision=2
 build_style=meson
 # lto is off because it causes linking errors in armv6l and armv7l (due to NEON)
 configure_args="-Dwerror=false -Dwith_dmabuf=enabled -Dwith_lz4=enabled

From fecbcaf9c5e798f9e82b179834295001b547631f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 070/112] xpra: revbump for ffmpeg6

---
 srcpkgs/xpra/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xpra/template b/srcpkgs/xpra/template
index 6bfe9be2db650..1eea2962bcb82 100644
--- a/srcpkgs/xpra/template
+++ b/srcpkgs/xpra/template
@@ -1,7 +1,7 @@
 # Template file for 'xpra'
 pkgname=xpra
 version=5.0.4
-revision=1
+revision=2
 build_style=python3-module
 make_build_args="--without-cuda_kernels --without-cuda_rebuild"
 make_install_args="$(vopt_with docs) ${make_build_args}"

From c474b5aa60946ce21b7938188cee1618a59a371e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:07:40 -0400
Subject: [PATCH 071/112] nv-codec-headers: update to 12.0.16.0

---
 srcpkgs/nv-codec-headers/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/nv-codec-headers/template b/srcpkgs/nv-codec-headers/template
index 3d422a61e4891..251e057f826fb 100644
--- a/srcpkgs/nv-codec-headers/template
+++ b/srcpkgs/nv-codec-headers/template
@@ -1,6 +1,6 @@
 # Template file for 'nv-codec-headers'
 pkgname=nv-codec-headers
-version=11.1.5.1
+version=12.0.16.0
 revision=1
 build_style=gnu-makefile
 short_desc="FFmpeg version of headers required to interface with Nvidias codec APIs"
@@ -8,7 +8,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="MIT"
 homepage="http://git.videolan.org/?p=ffmpeg/nv-codec-headers.git"
 distfiles="https://github.com/FFmpeg/nv-codec-headers/archive/n${version}.tar.gz"
-checksum=d095fbd56aa93772471a323be0ebe65504a0f43f06c76a30b6d25da77b06ae9c
+checksum=2a1533b65f55f9da52956faf0627ed3b74868ac0c7f269990edd21369113b48f
 
 post_install() {
 	sed -n '4,25p' include/ffnvcodec/nvEncodeAPI.h > LICENSE

From be96b35f071777fe9698165bad5822fad04fac87 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:08:40 -0400
Subject: [PATCH 072/112] openimagedenoise: revbump for ffmpeg6

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index b792813dba7c2..109deb171c3f7 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,7 +1,7 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
 version=1.4.3
-revision=1
+revision=2
 archs="x86_64*"
 build_style=cmake
 hostmakedepends="ispc python3"

From ca2ddb6c14bd3d2691653cece3fc22a734dbac65 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:31:45 -0400
Subject: [PATCH 073/112] shotcut: revbump for ffmpeg6

---
 srcpkgs/shotcut/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/shotcut/template b/srcpkgs/shotcut/template
index 33141fbd862d7..f46cb53b6bfb9 100644
--- a/srcpkgs/shotcut/template
+++ b/srcpkgs/shotcut/template
@@ -1,7 +1,7 @@
 # Template file for 'shotcut'
 pkgname=shotcut
 version=23.09.29
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSHOTCUT_VERSION=${version}"
 hostmakedepends="pkg-config qt6-tools-devel"

From bc60ad1c4bc5178e962f5dc26f76ed529839b136 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:30 -0400
Subject: [PATCH 074/112] shiboken2: revbump for qt5-5.15.11

---
 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch | 1 +
 srcpkgs/shiboken2/template                                 | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
 create mode 120000 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
new file mode 120000
index 0000000000000..efcf3249bd885
--- /dev/null
+++ b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1 @@
+../../python3-pyside2/patches/importlib-machinery-bypass.patch
\ No newline at end of file
diff --git a/srcpkgs/shiboken2/template b/srcpkgs/shiboken2/template
index 883d6a084d868..f3c06ec245a1f 100644
--- a/srcpkgs/shiboken2/template
+++ b/srcpkgs/shiboken2/template
@@ -1,7 +1,7 @@
 # Template file for 'shiboken2'
 pkgname=shiboken2
 version=5.15.10
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/shiboken2"
 build_style=cmake

From 7c6cc15eee375f1fc3053736645eb11801fb3c73 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:53 -0400
Subject: [PATCH 075/112] python3-pyside2: revbump for qt5-5.15.11

---
 .../patches/importlib-machinery-bypass.patch      | 15 +++++++++++++++
 srcpkgs/python3-pyside2/template                  |  2 +-
 2 files changed, 16 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
new file mode 100644
index 0000000000000..64c429584776b
--- /dev/null
+++ b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1,15 @@
+Using this prevents an error around line 220 below it.
+"AttributeError: module 'importlib' has no attribute 'machinery'"
+The old backup logic is in place and compiles without issues.
+--- a/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:09:34.688912402 -0400
++++ b/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:10:03.395529582 -0400
+@@ -170,9 +170,6 @@
+
+     # 'zipstring_sequence' comes from signature.cpp
+     zipbytes = base64.b64decode(''.join(zipstring_sequence))
+-    if sys.version_info[0] >= 3:
+-        vzip = zipfile.ZipFile(io.BytesIO(zipbytes))
+-        return sys.meta_path, EmbeddableZipImporter(vzip)
+
+     # Old version for Python 2.7, only.
+     import os
diff --git a/srcpkgs/python3-pyside2/template b/srcpkgs/python3-pyside2/template
index 249efa9098842..52626436ce75f 100644
--- a/srcpkgs/python3-pyside2/template
+++ b/srcpkgs/python3-pyside2/template
@@ -1,7 +1,7 @@
 # Template file for 'python3-pyside2'
 pkgname=python3-pyside2
 version=5.15.10
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/pyside2"
 build_style=cmake

From 762fad8e90a7254905263a8b449bbf6b8797097d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:35 -0400
Subject: [PATCH 076/112] konqueror: revbump for ffmpeg6

---
 srcpkgs/konqueror/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/konqueror/template b/srcpkgs/konqueror/template
index 044dafa605ba6..63dd01fafc780 100644
--- a/srcpkgs/konqueror/template
+++ b/srcpkgs/konqueror/template
@@ -1,11 +1,11 @@
 # Template file for 'konqueror'
 pkgname=konqueror
 version=23.08.4
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DDESKTOPTOJSON_EXECUTABLE=/usr/bin/desktoptojson"
 hostmakedepends="extra-cmake-modules python3 qt5-host-tools qt5-qmake kdoctools
-kcoreaddons kconfig gettext"
+ kcoreaddons kconfig gettext"
 makedepends="qt5-devel qt5-webengine-devel qt5-declarative-devel
  qt5-webchannel-devel qt5-location-devel kcmutils-devel kdelibs4support-devel
  karchive-devel khtml-devel kdesu-devel kactivities5-devel"

From f0589c8dea7249ccd594f9aa8d5bb12d46adb372 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:58 -0400
Subject: [PATCH 077/112] qt5-speech: revbump for qt5-5.15.11

---
 srcpkgs/qt5-speech/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-speech/template b/srcpkgs/qt5-speech/template
index 1228bb60c41db..27a7da1dbdb91 100644
--- a/srcpkgs/qt5-speech/template
+++ b/srcpkgs/qt5-speech/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-speech'
 pkgname=qt5-speech
 version=5.15.11
-revision=1
+revision=2
 _commit=d32f4a479d38a11f547598004b975f4356424a16
 build_style=qmake
 configure_args="-- -flite -flite-alsa -speechd"

From 8a8fd7a3e65e823c7c6e2fb80461a847ae8ca8cf Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Jun 2023 08:20:22 -0400
Subject: [PATCH 078/112] gtk4: revbump for ffmpeg6

---
 srcpkgs/gtk4/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gtk4/template b/srcpkgs/gtk4/template
index d8ee60abe06f7..55bff6e33849a 100644
--- a/srcpkgs/gtk4/template
+++ b/srcpkgs/gtk4/template
@@ -1,7 +1,7 @@
 # Template file for 'gtk4'
 pkgname=gtk4
 version=4.12.3
-revision=1
+revision=2
 build_style=meson
 build_helper="gir"
 configure_args="-Dman-pages=true -Ddocumentation=true -Dbuild-tests=false

From aaae51cb7797d58e5a5407f5c5d2cda66a859e6a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:28:26 -0400
Subject: [PATCH 079/112] siril: revbump for ffmpeg6

---
 srcpkgs/siril/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/siril/template b/srcpkgs/siril/template
index 84332f79d060d..62750dd247548 100644
--- a/srcpkgs/siril/template
+++ b/srcpkgs/siril/template
@@ -1,7 +1,7 @@
 # Template file for 'siril'
 pkgname=siril
 version=0.9.12
-revision=10
+revision=11
 build_style=gnu-configure
 hostmakedepends="pkg-config intltool autoconf automake gettext-devel"
 makedepends="fftw-devel libconfig-devel libopencv-devel libffms2-devel

From 834e53a31b464ad9d9ad507f9843333275fc9b98 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 22 Jun 2023 10:25:02 -0400
Subject: [PATCH 080/112] kdenlive: revbump for ffmpeg6

---
 srcpkgs/kdenlive/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kdenlive/template b/srcpkgs/kdenlive/template
index a0f3615c9c530..d63166f95c4d7 100644
--- a/srcpkgs/kdenlive/template
+++ b/srcpkgs/kdenlive/template
@@ -1,7 +1,7 @@
 # Template file for 'kdenlive'
 pkgname=kdenlive
 version=23.08.4
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="
  extra-cmake-modules kconfig kcoreaddons kdoctools pkg-config python3

From 5cc6c662ae967080831a2a10525e8d16fcdbb17e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:20:59 -0400
Subject: [PATCH 081/112] tracker-miners: revbump for ffmpeg6

---
 srcpkgs/tracker-miners/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tracker-miners/template b/srcpkgs/tracker-miners/template
index 0b97f47489f81..f196d2bf9e4a4 100644
--- a/srcpkgs/tracker-miners/template
+++ b/srcpkgs/tracker-miners/template
@@ -1,7 +1,7 @@
 # Template file for 'tracker-miners'
 pkgname=tracker-miners
 version=3.6.1
-revision=1
+revision=2
 build_style=meson
 build_helper=qemu
 # missing libgrss for miner_rss

From 2d52288311d16cf1aceda84db9c51e3639334f35 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:21:21 -0400
Subject: [PATCH 082/112] mpd: revbump for ffmpeg6

---
 srcpkgs/mpd/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpd/template b/srcpkgs/mpd/template
index 4fd32b7be8c53..b8e2bd4c1b59c 100644
--- a/srcpkgs/mpd/template
+++ b/srcpkgs/mpd/template
@@ -1,7 +1,7 @@
 # Template file for 'mpd'
 pkgname=mpd
 version=0.23.15
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dopus=enabled -Dmikmod=enabled -Dneighbor=true
  -Dsoundcloud=enabled -Dpipe=true -Dtwolame=enabled -Dbzip2=enabled

From ad44b7c4d84441f0e1c13bc77f492a43bda9f2ff Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:02 -0400
Subject: [PATCH 083/112] tg_owt: revbump for ffmpeg6

---
 srcpkgs/tg_owt/template | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/srcpkgs/tg_owt/template b/srcpkgs/tg_owt/template
index aee8d35d08ffb..563ed9a5835c4 100644
--- a/srcpkgs/tg_owt/template
+++ b/srcpkgs/tg_owt/template
@@ -1,8 +1,7 @@
 # Template file for 'tg_owt'
 pkgname=tg_owt
 version=0.0.0.20231221
-revision=1
-_commit=afd9d5d31798d3eacf9ed6c30601e91d0f1e4d60
+revision=2
 _libyuv_commit=04821d1e7d60845525e8db55c7bcd41ef5be9406
 _abseil_commit=8c0b94e793a66495e0b1f34a5eb26bd7dc672db0
 _crc32c_commit=21fc8ef30415a635e7351ffa0e5d5367943d4a94

From e5a0f60b3a0012b40fde172b5625b669ade0281e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:44 -0400
Subject: [PATCH 084/112] telegram-desktop: revbump for ffmpeg6

---
 srcpkgs/telegram-desktop/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/telegram-desktop/template b/srcpkgs/telegram-desktop/template
index 48ccb9a9d840a..c8756611e2b3b 100644
--- a/srcpkgs/telegram-desktop/template
+++ b/srcpkgs/telegram-desktop/template
@@ -1,7 +1,7 @@
 # Template file for 'telegram-desktop'
 pkgname=telegram-desktop
 version=4.14.2
-revision=1
+revision=2
 build_style=cmake
 build_helper="qemu gir"
 configure_args="-DTDESKTOP_API_ID=209235

From 6b439f22feeb188a4692465819d80deb0fb94159 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:11:45 -0400
Subject: [PATCH 085/112] gst-plugins-bad1: revbump for ffmpeg6

---
 srcpkgs/gst-plugins-bad1/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index fcd3538cd5cde..976e2889b588e 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-plugins-bad1'
 pkgname=gst-plugins-bad1
 version=1.22.7
-revision=1
+revision=2
 build_helper="gir"
 build_style=meson
 configure_args="-Dpackage-origin=https://voidlinux.org -Ddoc=disabled

From 9057cbc3effc45b29d2cfe365e266818b1002a8f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:12:09 -0400
Subject: [PATCH 086/112] openmw: revbump for ffmpeg6

---
 srcpkgs/openmw/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openmw/template b/srcpkgs/openmw/template
index 0abf5ff7cdbec..b57180f1a4446 100644
--- a/srcpkgs/openmw/template
+++ b/srcpkgs/openmw/template
@@ -1,7 +1,7 @@
 # Template file for 'openmw'
 pkgname=openmw
 version=0.48.0
-revision=2
+revision=3
 build_style=cmake
 _recast_commit=e75adf86f91eb3082220085e42dda62679f9a3ea
 _bullet_tag=3.17

From 029faec89d83913536b566bc006be62a7ab3a98f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:14:53 -0400
Subject: [PATCH 087/112] lms: revbump for ffmpeg6

---
 srcpkgs/lms/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/lms/template b/srcpkgs/lms/template
index e358f75902a98..3b21c458de519 100644
--- a/srcpkgs/lms/template
+++ b/srcpkgs/lms/template
@@ -1,7 +1,7 @@
 # Template file for 'lms'
 pkgname=lms
 version=3.42.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="wt-devel ffmpeg-devel boost-devel libconfig++-devel taglib-devel pam-devel libgraphicsmagick-devel gtest-devel libarchive-devel"

From 5c5c5ea62d60f8a6a3e1e74cde6e9c2102330f63 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:18:18 -0400
Subject: [PATCH 088/112] freecad: DELETE

---
 srcpkgs/freecad/patches/001-include.patch     | 112 ------------------
 .../154-revert-gui-tmp-redirect-stderr.patch  |  68 -----------
 ...d63c8c9b1280978be841d04e68a0a55cceb9.patch |  30 -----
 srcpkgs/freecad/template                      |  12 +-
 4 files changed, 7 insertions(+), 215 deletions(-)
 delete mode 100644 srcpkgs/freecad/patches/001-include.patch
 delete mode 100644 srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
 delete mode 100644 srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch

diff --git a/srcpkgs/freecad/patches/001-include.patch b/srcpkgs/freecad/patches/001-include.patch
deleted file mode 100644
index 28b5af54999b9..0000000000000
--- a/srcpkgs/freecad/patches/001-include.patch
+++ /dev/null
@@ -1,112 +0,0 @@
-From 9a41845a417189776741297c50a3827ce292bc4f Mon Sep 17 00:00:00 2001
-From: Uwe <donovaly@users.noreply.github.com>
-Date: Sun, 3 Jul 2022 22:51:16 +0200
-Subject: [PATCH] [Part] OCCError.h: remove unneeded includes
-
-- also sort includes
----
- src/Mod/Part/App/OCCError.h             | 36 +++----------------------
- src/Mod/Part/App/OffsetCurvePyImp.cpp   | 12 ++++-----
- src/Mod/Part/App/OffsetSurfacePyImp.cpp | 10 +++----
- 3 files changed, 12 insertions(+), 46 deletions(-)
-
---- a/src/Mod/Part/App/OCCError.h
-+++ b/src/Mod/Part/App/OCCError.h
-@@ -23,36 +23,8 @@
- #ifndef _OCCError_h_
- #define _OCCError_h_
- 
--# include <Standard_Version.hxx>
- # include <Standard_Failure.hxx>
--# include <Standard_AbortiveTransaction.hxx>
--# include <Standard_ConstructionError.hxx>
--# if OCC_VERSION_HEX >= 0x060500
--# include <Standard_DefineException.hxx>
--# endif
--# include <Standard_DimensionError.hxx>
--# include <Standard_DimensionMismatch.hxx>
--# include <Standard_DivideByZero.hxx>
--# include <Standard_DomainError.hxx>
--# include <Standard_ImmutableObject.hxx>
--# include <Standard_LicenseError.hxx>
--# include <Standard_LicenseNotFound.hxx>
--# include <Standard_MultiplyDefined.hxx>
--# include <Standard_NegativeValue.hxx>
--# include <Standard_NoMoreObject.hxx>
--# include <Standard_NoSuchObject.hxx>
--# include <Standard_NotImplemented.hxx>
--# include <Standard_NullObject.hxx>
--# include <Standard_NullValue.hxx>
--# include <Standard_NumericError.hxx>
--# include <Standard_OutOfMemory.hxx>
--# include <Standard_OutOfRange.hxx>
--# include <Standard_Overflow.hxx>
--# include <Standard_ProgramError.hxx>
--# include <Standard_RangeError.hxx>
--# include <Standard_TooManyUsers.hxx>
--# include <Standard_TypeMismatch.hxx>
--# include <Standard_Underflow.hxx>
-+# include <Standard_Version.hxx>
- 
- #include <Mod/Part/PartGlobal.h>
- #include <Base/Console.h>
-@@ -88,4 +60,3 @@ PartExport extern PyObject* PartExceptio
- 
- #define PY_CATCH_OCC _PY_CATCH_OCC(return(NULL))
- #endif  // _OCCError_h_
--
---- a/src/Mod/Part/App/OffsetCurvePyImp.cpp
-+++ b/src/Mod/Part/App/OffsetCurvePyImp.cpp
-@@ -20,20 +20,20 @@
-  *                                                                         *
-  ***************************************************************************/
- 
--
- #include "PreCompiled.h"
- #ifndef _PreComp_
- # include <Geom_OffsetCurve.hxx>
- #endif
- 
--#include "OCCError.h"
--#include "Geometry.h"
-+#include <Base/GeometryPyCXX.h>
-+#include <Base/Vector3D.h>
-+#include <Base/VectorPy.h>
-+
- #include "OffsetCurvePy.h"
- #include "OffsetCurvePy.cpp"
-+#include "Geometry.h"
-+#include "OCCError.h"
- 
--#include <Base/GeometryPyCXX.h>
--#include <Base/VectorPy.h>
--#include <Base/Vector3D.h>
- 
- using namespace Part;
- 
---- a/src/Mod/Part/App/OffsetSurfacePyImp.cpp
-+++ b/src/Mod/Part/App/OffsetSurfacePyImp.cpp
-@@ -20,20 +20,16 @@
-  *                                                                         *
-  ***************************************************************************/
- 
--
- #include "PreCompiled.h"
- #ifndef _PreComp_
- # include <Geom_OffsetSurface.hxx>
- # include <memory>
- #endif
- 
--#include <Base/VectorPy.h>
--#include <Base/Vector3D.h>
--
- #include "OCCError.h"
--#include "Geometry.h"
--#include <Mod/Part/App/OffsetSurfacePy.h>
--#include <Mod/Part/App/OffsetSurfacePy.cpp>
-+#include "OffsetSurfacePy.h"
-+#include "OffsetSurfacePy.cpp"
-+
- 
- using namespace Part;
- 
diff --git a/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch b/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
deleted file mode 100644
index d6a9adabdec83..0000000000000
--- a/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
+++ /dev/null
@@ -1,68 +0,0 @@
-see https://github.com/FreeCAD/FreeCAD/commit/cfe94b00d3434f3e2c8b5114d2909f628c330fa8#commitcomment-71413407
-
-upstream: yes
-
-From 7b377a216b9185960e4cee980a6504dc1a755f50 Mon Sep 17 00:00:00 2001
-From: wmayer <wmayer@users.sourceforge.net>
-Date: Wed, 29 Jun 2022 15:19:18 +0200
-Subject: [PATCH] Gui: remove workaround for spnav 0.23 due to build failure
- with musl libc
-
----
- src/Gui/3Dconnexion/GuiNativeEventLinux.cpp | 27 ---------------------
- 1 file changed, 27 deletions(-)
-
---- a/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp
-+++ b/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp
-@@ -21,42 +21,17 @@
-  ***************************************************************************/
- 
- #include <FCConfig.h>
--#include <cstdio>
- 
- #include "GuiNativeEventLinux.h"
- 
- #include "GuiApplicationNativeEventAware.h"
- #include <Base/Console.h>
--#include <Base/FileInfo.h>
- #include <QMainWindow>
- 
- #include <QSocketNotifier>
- 
- #include <spnav.h>
- 
--namespace {
--class RedirectStdErr
--{
--public:
--    RedirectStdErr()
--        : fi(Base::FileInfo::getTempFileName())
--        , file(stderr)
--    {
--        stderr = fopen(fi.filePath().c_str(), "w");
--    }
--    ~RedirectStdErr()
--    {
--        fclose(stderr);
--        fi.deleteFile();
--        stderr = file;
--    }
--
--private:
--    Base::FileInfo fi;
--    FILE* file;
--};
--}
--
- Gui::GuiNativeEvent::GuiNativeEvent(Gui::GUIApplicationNativeEventAware *app)
- : GuiAbstractNativeEvent(app)
- {
-@@ -72,8 +47,6 @@ Gui::GuiNativeEvent::~GuiNativeEvent()
- 
- void Gui::GuiNativeEvent::initSpaceball(QMainWindow *window)
- {
--    // tmp. redirect stderr to a file to suppress an error message from spnav_open()
--    RedirectStdErr err;
-     Q_UNUSED(window)
-     if (spnav_open() == -1) {
-         Base::Console().Log("Couldn't connect to spacenav daemon. Please ignore if you don't have a spacemouse.\n");
diff --git a/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch b/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch
deleted file mode 100644
index d4acf370ca0a4..0000000000000
--- a/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-From fe02d63c8c9b1280978be841d04e68a0a55cceb9 Mon Sep 17 00:00:00 2001
-From: Roy-043 <70520633+Roy-043@users.noreply.github.com>
-Date: Thu, 29 Dec 2022 23:20:38 +0100
-Subject: [PATCH] Draft: update inspect.getargspec to inspect.getfullargspec
- (#8101)
-
----
- src/Mod/Draft/draftguitools/gui_snapper.py | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
---- a/src/Mod/Draft/draftguitools/gui_snapper.py
-+++ b/src/Mod/Draft/draftguitools/gui_snapper.py
-@@ -1426,7 +1426,7 @@ class Snapper:
-             Gui.Snapper.off()
-             self.ui.offUi()
-             if callback:
--                if len(inspect.getargspec(callback).args) > 1:
-+                if len(inspect.getfullargspec(callback).args) > 1:
-                     obj = None
-                     if self.snapInfo and ("Object" in self.snapInfo) and self.snapInfo["Object"]:
-                         obj = App.ActiveDocument.getObject(self.snapInfo["Object"])
-@@ -1445,7 +1445,7 @@ class Snapper:
-             Gui.Snapper.off()
-             self.ui.offUi()
-             if callback:
--                if len(inspect.getargspec(callback).args) > 1:
-+                if len(inspect.getfullargspec(callback).args) > 1:
-                     callback(None, None)
-                 else:
-                     callback(None)
diff --git a/srcpkgs/freecad/template b/srcpkgs/freecad/template
index c135701e38b9a..7d5165f760bab 100644
--- a/srcpkgs/freecad/template
+++ b/srcpkgs/freecad/template
@@ -1,7 +1,7 @@
 # Template file for 'freecad'
 pkgname=freecad
-version=0.20.2
-revision=7
+version=0.21.1
+revision=2
 build_wrksrc="FreeCAD-${version}"
 build_style=cmake
 pycompile_dirs="usr/lib/${pkgname}/Mod"
@@ -24,8 +24,10 @@ makedepends="python3-devel boost-devel libxerces-c-devel zlib-devel occt-devel
  coin3-devel libshiboken2-devel libspnav-devel pyside2-tools
  liblz4-devel libpyside2-python3-devel python3-matplotlib netcdf-devel
  jsoncpp-devel qt5-devel qt5-svg-devel qt5-tools-devel qt5-webkit-devel
- qt5-xmlpatterns-devel coin3-doc glew-devel python3-pivy"
-depends="python3-matplotlib python3-pyside2-webengine python3-pivy"
+ qt5-xmlpatterns-devel coin3-doc glew-devel python3-pivy qt5-webengine-devel
+ qt5-declarative-devel qt5-webchannel-devel qt5-location-devel"
+depends="python3-matplotlib python3-pyside2-webengine python3-pivy
+ python3-GitPython python3-Markdown"
 short_desc="General purpose 3D CAD modeler"
 maintainer="yopito <pierre.bourgin@free.fr>"
 license="LGPL-2.0-or-later"
@@ -35,7 +37,7 @@ distfiles="
  https://github.com/FreeCAD/FreeCAD/archive/${version}.tar.gz
  ${SOURCEFORGE_SITE}/cxx/pycxx-${_pycxxver}.tar.gz
 "
-checksum="46922f3a477e742e1a89cd5346692d63aebb2b67af887b3e463e094a4ae055da
+checksum="e9b1fd0323f101268c7f3be52db42e4a29222f2e306ae6c4a6fc309cb418d35a
  4b91e1e1141c23fbd5039df635c4bb6e75632168548f56b83ce177193c0c98c6"
 python_version=3
 patch_args="-Np1 -d ${build_wrksrc}"

From d670e99097344d02dc6230b1ecfd491efc1bcc1e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:47:18 -0400
Subject: [PATCH 089/112] libopenshot: revbump for ffmpeg6

---
 srcpkgs/libopenshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenshot/template b/srcpkgs/libopenshot/template
index 8e57c5f592169..7a8f4520e7892 100644
--- a/srcpkgs/libopenshot/template
+++ b/srcpkgs/libopenshot/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenshot'
 pkgname=libopenshot
 version=0.3.0
-revision=3
+revision=4
 build_style=cmake
 # Builds fail with Ruby-2.4.1
 configure_args="-DENABLE_RUBY=OFF -DUSE_SYSTEM_JSONCPP=ON"

From 5a548b98b1547bffc90b37431e9e8f76d7e505c6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:10:30 -0500
Subject: [PATCH 090/112] openimageio: revbump for ffmpeg6

---
 srcpkgs/openimageio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimageio/template b/srcpkgs/openimageio/template
index 3ce3f9e49d350..27d2131bc0a61 100644
--- a/srcpkgs/openimageio/template
+++ b/srcpkgs/openimageio/template
@@ -1,7 +1,7 @@
 # Template file for 'openimageio'
 pkgname=openimageio
 version=2.4.9.0
-revision=7
+revision=8
 build_style=cmake
 build_helper=qemu
 configure_args="-DUSE_QT=0 -DUSE_PYTHON=0 -DOIIO_BUILD_TESTS=0

From 55c69e11ba9d132a25ab9f73b5123c880a351c50 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:11:57 -0500
Subject: [PATCH 091/112] synfigstudio: revbump for ffmpeg6

---
 srcpkgs/synfigstudio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/synfigstudio/template b/srcpkgs/synfigstudio/template
index 09e442da9a680..2bc017cedca6b 100644
--- a/srcpkgs/synfigstudio/template
+++ b/srcpkgs/synfigstudio/template
@@ -2,7 +2,7 @@
 # Should be kept in sync with 'synfig' and 'ETL'
 pkgname=synfigstudio
 version=1.4.4
-revision=4
+revision=5
 build_style=gnu-configure
 configure_args="--disable-update-mimedb"
 hostmakedepends="pkg-config intltool gettext synfig"

From 6de63c0ce3d429ba588a976be192addc53f27dc2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:12:32 -0500
Subject: [PATCH 092/112] gmic: revbump for ffmpeg6

---
 srcpkgs/gmic/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gmic/template b/srcpkgs/gmic/template
index fa37651bb6dee..24d10147e3aba 100644
--- a/srcpkgs/gmic/template
+++ b/srcpkgs/gmic/template
@@ -1,7 +1,7 @@
 # Template file for 'gmic'
 pkgname=gmic
 version=3.1.6
-revision=5
+revision=6
 _zart_hash=34ebf6cce0bafb98abe57cec83c4a02cd1abeca0
 create_wrksrc=yes
 build_wrksrc="src"

From 51037535b18dccae74db30b608a64994d0ef27cc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:10 -0500
Subject: [PATCH 093/112] mixxx: revbump for ffmpeg6

---
 srcpkgs/mixxx/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mixxx/template b/srcpkgs/mixxx/template
index 6921996e4e77b..6a79b328c1abf 100644
--- a/srcpkgs/mixxx/template
+++ b/srcpkgs/mixxx/template
@@ -1,7 +1,7 @@
 # Template file for 'mixxx'
 pkgname=mixxx
 version=2.3.3
-revision=6
+revision=7
 build_style=cmake
 configure_args="-DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="extra-cmake-modules pkg-config protobuf qt5-host-tools qt5-qmake"

From 7dc8f59907dd7dab774b68af2e8e1fe7625f849f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:28 -0500
Subject: [PATCH 094/112] musikcube: revbump for ffmpeg6

---
 srcpkgs/musikcube/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/musikcube/template b/srcpkgs/musikcube/template
index 8c4a51840859e..fb60dd2049089 100644
--- a/srcpkgs/musikcube/template
+++ b/srcpkgs/musikcube/template
@@ -1,7 +1,7 @@
 # Template file for 'musikcube'
 pkgname=musikcube
 version=3.0.0
-revision=3
+revision=4
 build_style=cmake
 make_cmd=make
 configure_args="-DNO_NCURSESW=1"

From 90c4f610f63a7d7ad9153701306505b6cdf8557c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:45 -0500
Subject: [PATCH 095/112] electron24: revbump for ffmpeg6

---
 srcpkgs/electron24/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron24/template b/srcpkgs/electron24/template
index 7b4e28812f483..1ca93fde97a85 100644
--- a/srcpkgs/electron24/template
+++ b/srcpkgs/electron24/template
@@ -1,7 +1,7 @@
 # Template file for 'electron24'
 pkgname=electron24
 version=24.3.0
-revision=2
+revision=3
 _nodever=18.14.0
 _chromiumver=112.0.5615.165
 archs="x86_64* aarch64*"

From acdb8832ccfbb43991a87d7478db2fb2e7e7137b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:00 -0500
Subject: [PATCH 096/112] electron19: revbump for ffmpeg6

---
 srcpkgs/electron19/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron19/template b/srcpkgs/electron19/template
index 0ef959125cb08..5371c0b354604 100644
--- a/srcpkgs/electron19/template
+++ b/srcpkgs/electron19/template
@@ -1,7 +1,7 @@
 # Template file for 'electron19'
 pkgname=electron19
 version=19.0.8
-revision=4
+revision=5
 _nodever=16.14.2
 _chromiumver=102.0.5005.125
 archs="x86_64* aarch64* ppc64le*"

From ff73dd76e75078320d44146015d3b27483b3f35a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:13 -0500
Subject: [PATCH 097/112] wf-recorder: revbump for ffmpeg6

---
 srcpkgs/wf-recorder/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/wf-recorder/template b/srcpkgs/wf-recorder/template
index 08f986b031006..63c45cf4b814d 100644
--- a/srcpkgs/wf-recorder/template
+++ b/srcpkgs/wf-recorder/template
@@ -1,7 +1,7 @@
 # Template file for 'wf-recorder'
 pkgname=wf-recorder
 version=0.4.1
-revision=2
+revision=3
 build_style=meson
 hostmakedepends="pkg-config scdoc wayland-devel"
 makedepends="wayland-protocols wayland-devel ffmpeg-devel libgbm-devel x264-devel

From 74e2a61dc856bdd2dd76716934e64378202fa961 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:26 -0500
Subject: [PATCH 098/112] obs: revbump for ffmpeg6

---
 srcpkgs/obs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/obs/template b/srcpkgs/obs/template
index b343f1131bfcf..a25a67433e285 100644
--- a/srcpkgs/obs/template
+++ b/srcpkgs/obs/template
@@ -1,7 +1,7 @@
 # Template file for 'obs'
 pkgname=obs
 version=30.0.0
-revision=2
+revision=3
 archs="i686* x86_64* ppc64le* aarch64* riscv64*"
 build_style=cmake
 configure_args="-DOBS_VERSION_OVERRIDE=${version} -DENABLE_JACK=ON

From 28023035946d4d9ff5d489cfaabe8e682682dbf7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:36 -0500
Subject: [PATCH 099/112] mlt7: revbump for ffmpeg6

---
 srcpkgs/mlt7/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mlt7/template b/srcpkgs/mlt7/template
index 98f302ad3a516..7eb8c00fa1580 100644
--- a/srcpkgs/mlt7/template
+++ b/srcpkgs/mlt7/template
@@ -1,7 +1,7 @@
 # Template file for 'mlt7'
 pkgname=mlt7
 version=7.20.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DSWIG_PYTHON=ON -DMOD_QT6=ON"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which

From 26b69340c2e20bbae802d6c6d2d83e7c94e985ef Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:48 -0500
Subject: [PATCH 100/112] qt6-multimedia: revbump for ffmpeg6

---
 srcpkgs/qt6-multimedia/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-multimedia/template b/srcpkgs/qt6-multimedia/template
index 67a577e1300fe..1da626ecf515a 100644
--- a/srcpkgs/qt6-multimedia/template
+++ b/srcpkgs/qt6-multimedia/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-multimedia'
 pkgname=qt6-multimedia
 version=6.6.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DQT_FEATURE_gstreamer=ON"
 hostmakedepends="perl qt6-declarative-host-tools pkg-config qt6-shadertools"

From 91acb65dc059b5dd7d3424b510fa4156570ecc61 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:00:15 -0500
Subject: [PATCH 101/112] baresip: revbump for ffmpeg6

---
 srcpkgs/baresip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/baresip/template b/srcpkgs/baresip/template
index 12c8954ef7b9b..b16b67beab8d2 100644
--- a/srcpkgs/baresip/template
+++ b/srcpkgs/baresip/template
@@ -1,7 +1,7 @@
 # Template file for 'baresip'
 pkgname=baresip
 version=3.6.0
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config glib-devel"
 makedepends="libgsm-devel libpng-devel openssl-devel libsndfile-devel

From 7d065f12dd4c99d4fed1afbb15cae4c14f45f4c0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:30 -0500
Subject: [PATCH 102/112] QMPlay2: revbump for ffmpeg6

---
 srcpkgs/QMPlay2/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/QMPlay2/template b/srcpkgs/QMPlay2/template
index 46c80f64a1349..942258ce60fb7 100644
--- a/srcpkgs/QMPlay2/template
+++ b/srcpkgs/QMPlay2/template
@@ -1,7 +1,7 @@
 # Template file for 'QMPlay2'
 pkgname=QMPlay2
 version=23.10.22
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools"
 makedepends="alsa-lib-devel ffmpeg-devel libass-devel libcdio-devel libgme-devel

From 3d2ad6cb00dd720b138873eb2fc2c6e739d69b0f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:34 -0500
Subject: [PATCH 103/112] alsa-plugins: revbump for ffmpeg6

---
 srcpkgs/alsa-plugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/alsa-plugins/template b/srcpkgs/alsa-plugins/template
index a5708a7d82a8f..7bfdad046c483 100644
--- a/srcpkgs/alsa-plugins/template
+++ b/srcpkgs/alsa-plugins/template
@@ -1,7 +1,7 @@
 # Template file for 'alsa-plugins'
 pkgname=alsa-plugins
 version=1.2.7.1
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--disable-maemo-plugin"
 hostmakedepends="pkg-config"

From cd5cf3a2d19e7736abcd52ff19b745b6fa09f80f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:43 -0500
Subject: [PATCH 104/112] minidlna: revbump for ffmpeg6

---
 srcpkgs/minidlna/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/minidlna/template b/srcpkgs/minidlna/template
index 5fa929f3a0c12..742991ecd04af 100644
--- a/srcpkgs/minidlna/template
+++ b/srcpkgs/minidlna/template
@@ -1,7 +1,7 @@
 # Template file for 'minidlna'
 pkgname=minidlna
 version=1.3.3
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="
  --sbindir=/usr/bin

From c0691d1ecaf5499a69f01ea7eee1700f2c5ed3b1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 17:57:47 -0500
Subject: [PATCH 105/112] mpv: revbump for ffmpeg6

---
 srcpkgs/mpv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpv/template b/srcpkgs/mpv/template
index 4948d1e332cb8..1ac1b167af189 100644
--- a/srcpkgs/mpv/template
+++ b/srcpkgs/mpv/template
@@ -1,7 +1,7 @@
 # Template file for 'mpv'
 pkgname=mpv
 version=0.36.0
-revision=4
+revision=5
 build_style=meson
 configure_args="-Dcdda=enabled -Ddvbin=enabled -Ddvdnav=enabled
  -Dlibmpv=true -Dcplugins=enabled

From 1ad77fd7dd732f4e674f5b35292401f1a74058c2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 17:59:29 -0500
Subject: [PATCH 106/112] qimgv: revbump for ffmpeg6

---
 srcpkgs/qimgv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qimgv/template b/srcpkgs/qimgv/template
index dd341dfe1bfce..8a7e1c081ef12 100644
--- a/srcpkgs/qimgv/template
+++ b/srcpkgs/qimgv/template
@@ -1,7 +1,7 @@
 # Template file for 'qimgv'
 pkgname=qimgv
 version=1.0.2
-revision=3
+revision=4
 build_style=cmake
 configure_args="$(vopt_if video -DVIDEO_SUPPORT=ON -DVIDEO_SUPPORT=OFF)
  $(vopt_if scale -DOPENCV_SUPPORT=ON -DOPENCV_SUPPORT=OFF)

From 24b458449bcbc406b6b15c788baad048e74f9a8f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 18:00:36 -0500
Subject: [PATCH 107/112] kfilemetadata5: revbump for ffmpeg6

---
 srcpkgs/kfilemetadata5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kfilemetadata5/template b/srcpkgs/kfilemetadata5/template
index 51fd6fec8c1c0..ad229b4c2e241 100644
--- a/srcpkgs/kfilemetadata5/template
+++ b/srcpkgs/kfilemetadata5/template
@@ -1,7 +1,7 @@
 # Template file for 'kfilemetadata5'
 pkgname=kfilemetadata5
 version=5.113.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="kcoreaddons extra-cmake-modules pkg-config qt5-host-tools qt5-qmake
  gettext kcoreaddons python3"

From 5e4bd77e76be34c6c7bb1072d5dd8487c516555a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 8 Dec 2023 11:46:01 -0500
Subject: [PATCH 108/112] vba-m: revbump for ffmpeg6

---
 srcpkgs/vba-m/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vba-m/template b/srcpkgs/vba-m/template
index 52efeede1dcba..3e0760398905c 100644
--- a/srcpkgs/vba-m/template
+++ b/srcpkgs/vba-m/template
@@ -2,7 +2,7 @@
 pkgname=vba-m
 reverts=1292_2
 version=2.1.8
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_GTK=TRUE -DENABLE_FFMPEG=TRUE -DENABLE_LINK=TRUE -DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="gettext pkg-config unzip zip yasm wxWidgets-gtk3-devel"

From f2403add3b8b3c3916f31f4f5eef156ffd7bd0a3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 8 Dec 2023 11:46:19 -0500
Subject: [PATCH 109/112] dolphin-emu: revbump for ffmpeg6

---
 srcpkgs/dolphin-emu/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/dolphin-emu/template b/srcpkgs/dolphin-emu/template
index 862d3ae964eec..a7ae0efb58fb7 100644
--- a/srcpkgs/dolphin-emu/template
+++ b/srcpkgs/dolphin-emu/template
@@ -1,7 +1,7 @@
 # Template file for 'dolphin-emu'
 pkgname=dolphin-emu
 version=5.0.19368
-revision=3
+revision=4
 _dolphin_commit=dadbeb4bae7e7fa23af2b46e0add4143094dc107
 _mgba_commit=44e074a15e9651481f7f652ac006a7c9d58cbeb9
 _googletest_commit=be03d00f5f0cc3a997d1a368bee8a1fe93651f48

From a188928269e58b2256f068536962aa038e51dbbc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 19 Dec 2023 15:38:51 -0500
Subject: [PATCH 110/112] qtox: revbump for ffmpeg4

---
 srcpkgs/qtox/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtox/template b/srcpkgs/qtox/template
index bb70e7f51240a..755e4462bc013 100644
--- a/srcpkgs/qtox/template
+++ b/srcpkgs/qtox/template
@@ -1,13 +1,13 @@
 # Template file for 'qtox'
 pkgname=qtox
 version=1.17.6
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DUPDATE_CHECK=OFF
  -DGIT_DESCRIBE=${version}
  $(vopt_if snorenotify -DDESKTOP_NOTIFICATIONS=ON)"
 hostmakedepends="pkg-config qt5-host-tools qt5-devel"
-makedepends="ffmpeg-devel libexif-devel libopenal-devel libsodium-devel
+makedepends="ffmpeg4-devel libexif-devel libopenal-devel libsodium-devel
  libvpx-devel opus-devel qrencode-devel qt5-svg-devel sonnet-devel
  sqlcipher-devel toxcore-devel
  $(vopt_if snorenotify snorenotify-devel)"

From f29f43c91bb4cf8d6e1a2f65629b4df2f80ba1ea Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 11 Jan 2024 11:52:00 -0500
Subject: [PATCH 111/112] arcan: revbump for ffmpeg6

---
 srcpkgs/arcan/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/arcan/template b/srcpkgs/arcan/template
index ff9091f90ebb1..030091a6cc9d0 100644
--- a/srcpkgs/arcan/template
+++ b/srcpkgs/arcan/template
@@ -2,7 +2,7 @@
 # !! keep synced with: acfgfs aclip aloadimage
 pkgname=arcan
 version=0.6.2.1
-revision=2
+revision=3
 create_wrksrc=yes
 build_wrksrc=arcan/src
 build_style=cmake

From 34914b346eddde6d0664eeb259355cb68aa38994 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 11 Jan 2024 11:52:10 -0500
Subject: [PATCH 112/112] notcurses: revbump for ffmpeg6

---
 srcpkgs/notcurses/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/notcurses/template b/srcpkgs/notcurses/template
index 48a7463cb68eb..515f316ab4576 100644
--- a/srcpkgs/notcurses/template
+++ b/srcpkgs/notcurses/template
@@ -1,7 +1,7 @@
 # Template file for 'notcurses'
 pkgname=notcurses
 version=3.0.9
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DUSE_STATIC=ON -DUSE_QRCODEGEN=On $(vopt_bool man USE_PANDOC)"
 hostmakedepends="pkg-config $(vopt_if man pandoc)"

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (55 preceding siblings ...)
  2024-01-28 18:46 ` zlice
@ 2024-02-02 22:44 ` zlice
  2024-02-02 22:46 ` zlice
                   ` (40 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2024-02-02 22:44 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 4558 bytes --]

There is an updated pull request by zlice against master on the void-packages repository

https://github.com/zlice/void-packages ffmpeg6-split
https://github.com/void-linux/void-packages/pull/43761

ffmpeg6 split
[ci skip]


#### Testing the changes

- I tested the changes in this PR: **YES**

main testing has been vaapi in Firefox Nightly and enc/dec in Shotcut on Intel A770

#### New package

- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**

#### Local build testing

- I built this PR locally for my native architecture, **x86_64**

#### Discussion

Continuation of https://github.com/void-linux/void-packages/pull/36315

`libavresample` is deprecated, but marked as a dependency when trying to build other packages and install `ffmpeg`(6). I think the right way to handle this is make a meta package and the add to removals?


##### Commit naming / misc

~~Commits are 'dirty' right now, running with [gstreamer 1.22.1 updates](https://github.com/void-linux/void-packages/pull/42861) and [Intel OpenCL](https://github.com/void-linux/void-packages/pull/43084). This will also make [intel packages pr](https://github.com/void-linux/void-packages/pull/41132) obsolete.~~ (see Requirements below)

Maintainer for previous ffmpeg(4) was orphaned, I can put my name in there if that matters, though I don't exactly see myself keeping up on ffmpeg.

~~This updates QT5 which looks like it is usually hosted by Johnny. Not sure if there's any reason to stay there or these sources are fine.~~ Using qt5.15.11 now, revbumps and some patches.

##### STILL FFMPEG4

These are a mix of emulators, games and/or older packages.

- attract (multiple patches in master)
- ~~audacity (https://github.com/audacity/audacity/issues/2305 and https://sourceforge.net/p/portmedia/wiki/portsmf/ is 'beta')~~ (updated to 3.x, compiles with ffmpeg6)
- ccextractor (master patches? no release)
- vice (3.8 compiles, needs makedepends libcurl-devel)
- kodi
- mlt (only dep left is flowblade - flowblade 2.12.0.2 with mlt7-python3 can 'render' videos with cpu and gpu)
- ~~synfig (mlt)~~ (work with mlt7, bump synfigstudio)
- tvheadend
- ssr
- ~~spek-alternative~~ (replace with spek-x)
- ppsspp
- olive
- moc
- mediastreamer (linphone links are dead, changed to github belladonne. their stuff never worked for me but there are updates if someone wants to give it a try)
- libextractor (1.13 compiles, remove exiv2 patch)
- idjc (0.9.8 compiles, remove python3.10 patch, needs makedepends libebur128-devel and libshout-idjc 2.4.6 with '-r1' for distfile)
- hedgewars
- ~~ffmpegthumbnailer~~ (patches for moviedecoder.xxx files)
- ~~ffmpegthumbs~~ (latest compiles)
- deadbeef
- ~~omxplayer~~ (package removed, deprecated in favor of vlc)
- qtav (fork has ffmpeg 5 patch - https://github.com/cmguo/QtAV)
- `vlc` (vlc4 will support ffmpeg5, there's a patch to build 3.x with ffmpeg5 but it will lack vaapi)
- `osg` (OpenSceneGraph plus `xine-lib`)


##### HAVE NOT BUILT YET

- ~~omxplayer (rpi only? ffmpeg4)~~ (removed)
- kodi (big, but ffmpeg4)


##### UPDATED (for ffmpeg6)

- ~~blender: update to 3.5.1~~ ~~will be revbump with~~ https://github.com/void-linux/void-packages/pull/43992
- unpaper: update to 7.0.0.
- guvcview: update to 2.0.8.
- ~~qt5: update to 5.15.8~~ updated by another PR to 5.15.11
- ~~qt5-webengine: update to 5.18.15~~ updated by another PR to 5.15.16 (some patching for ffmpeg build)
- ~~shiboken2: revbump for qt5.15.8 (patch)~~ updated by another PR to 5.15.10
- ~~python3-pyside2: update to 5.15.8 (patch)~~ updated by another PR to 5.15.10
- New package: spex-x replaces spek-alternative for ffmpeg-6.0


##### Requirements

- ~~[gstreamer 1.22.2](https://github.com/void-linux/void-packages/pull/42861)~~ - a few packages use ffmpeg-devel and require a revbump

- ~~[Intel Packages](https://github.com/void-linux/void-packages/pull/41132) [Intel Packages v2](https://github.com/void-linux/void-packages/pull/47330) - ffmpeg4 uses different libraries than 6 (libmfx / Intel-MediaSDK vs only oneVPL that Intel is moving to), both are included here~~. Using replacement oneVPL from OBS update.

- ~~[shotcut 23.05.14](https://github.com/void-linux/void-packages/pull/44260)~~

- https://github.com/void-linux/void-packages/pull/44781 will remove from this PR

A patch file from https://github.com/void-linux/void-packages/pull/43761.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ffmpeg6-split-43761.patch --]
[-- Type: text/x-diff, Size: 223831 bytes --]

From a3c60b2ad35df66d6aa3a1ca0810e6701cc6d41c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:16:56 -0400
Subject: [PATCH 001/111] ffmpeg: update to 6.0.1.

---
 common/shlibs                                 | 26 ++++---
 srcpkgs/ffmpeg/files/altivec.patch            | 60 ---------------
 .../patches/armv5tel-floating-point.patch     | 18 -----
 srcpkgs/ffmpeg/patches/binutils-2.41.patch    | 73 -------------------
 ...h-libavcodec-libsvtav1-ten_bit_format.diff | 40 ----------
 .../workaround-mesa-readeon-vaapi-bug.patch   | 28 -------
 srcpkgs/ffmpeg/template                       | 40 +++++-----
 7 files changed, 37 insertions(+), 248 deletions(-)
 delete mode 100644 srcpkgs/ffmpeg/files/altivec.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/binutils-2.41.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 delete mode 100644 srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch

diff --git a/common/shlibs b/common/shlibs
index 71f172740e5c6..c1c79647f63ca 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -389,15 +389,23 @@ libid3tag.so.0 libid3tag-0.15.1b_1
 libgif.so.7 giflib-5.1.0_1
 libImlib2.so.1 imlib2-1.4.2_1
 libmp3lame.so.0 lame-3.98.2_1
-libavdevice.so.58 libavdevice-4.0_1
-libavformat.so.58 libavformat-4.0_1
-libswscale.so.5 libswscale-4.0_1
-libswresample.so.3 libswresample-4.0_1
-libavresample.so.4 libavresample-4.0_1
-libpostproc.so.55 libpostproc-4.0_1
-libavcodec.so.58 libavcodec-4.0_1
-libavutil.so.56 libavutil-4.0_1
-libavfilter.so.7 libavfilter-4.0_1
+libavdevice.so.60 libavdevice-6.0_1
+libavformat.so.60 libavformat-6.0_1
+libswscale.so.7 libswscale-6.0_1
+libswresample.so.4 libswresample-6.0_1
+libpostproc.so.57 libpostproc-6.0_1
+libavcodec.so.60 libavcodec-6.0_1
+libavutil.so.58 libavutil-6.0_1
+libavfilter.so.9 libavfilter-6.0_1
+libavdevice.so.58 libavdevice4-4.0_1
+libavformat.so.58 libavformat4-4.0_1
+libswscale.so.5 libswscale4-4.0_1
+libswresample.so.3 libswresample4-4.0_1
+libavresample.so.4 libavresample4-4.0_1
+libpostproc.so.55 libpostproc4-4.0_1
+libavcodec.so.58 libavcodec4-4.0_1
+libavutil.so.56 libavutil4-4.0_1
+libavfilter.so.7 libavfilter4-4.0_1
 libSDL-1.2.so.0 SDL-1.2.14_1
 libSDL_image-1.2.so.0 SDL_image-1.2.10_1
 libx264.so.157 x264-20190507.2245_1
diff --git a/srcpkgs/ffmpeg/files/altivec.patch b/srcpkgs/ffmpeg/files/altivec.patch
deleted file mode 100644
index 9c57200463320..0000000000000
--- a/srcpkgs/ffmpeg/files/altivec.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-revert some altivec specific change on all ppc* except ppc64le*
-
-q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
-conditionally, for ppc* but not ppc64le* (the new code is valid for
-POWER8 VSX which LE targets as a baseline but not BE)"
-
-
-This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
----
- libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
- 1 file changed, 20 insertions(+), 4 deletions(-)
-
-diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
-index 536545293d..c1e2852adb 100644
---- a/libswscale/ppc/yuv2rgb_altivec.c
-+++ b/libswscale/ppc/yuv2rgb_altivec.c
-@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-     vector signed short R1, G1, B1;                                           \
-     vector unsigned char R, G, B;                                             \
-                                                                               \
-+    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
-+    vector unsigned char align_perm;                                          \
-+                                                                              \
-     vector signed short lCY       = c->CY;                                    \
-     vector signed short lOY       = c->OY;                                    \
-     vector signed short lCRV      = c->CRV;                                   \
-@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
-                                                                               \
-         for (j = 0; j < w / 16; j++) {                                        \
--            y0 = vec_xl(0, y1i);                                              \
-+            y1ivP = (const vector unsigned char *) y1i;                       \
-+            y2ivP = (const vector unsigned char *) y2i;                       \
-+            uivP  = (const vector unsigned char *) ui;                        \
-+            vivP  = (const vector unsigned char *) vi;                        \
-+                                                                              \
-+            align_perm = vec_lvsl(0, y1i);                                    \
-+            y0 = (vector unsigned char)                                       \
-+                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
-                                                                               \
--            y1 = vec_xl(0, y2i);                                              \
-+            align_perm = vec_lvsl(0, y2i);                                    \
-+            y1 = (vector unsigned char)                                       \
-+                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
-                                                                               \
--            u = (vector signed char) vec_xl(0, ui);                           \
-+            align_perm = vec_lvsl(0, ui);                                     \
-+            u = (vector signed char)                                          \
-+                    vec_perm(uivP[0], uivP[1], align_perm);                   \
-                                                                               \
--            v = (vector signed char) vec_xl(0, vi);                           \
-+            align_perm = vec_lvsl(0, vi);                                     \
-+            v = (vector signed char)                                          \
-+                    vec_perm(vivP[0], vivP[1], align_perm);                   \
-                                                                               \
-             u = (vector signed char)                                          \
-                     vec_sub(u,                                                \
--- 
-2.27.0
-
diff --git a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
deleted file mode 100644
index 9a55178c74f0f..0000000000000
--- a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
-+++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
-@@ -39,6 +39,15 @@
- #endif
- #include <fenv.h>
- 
-+#if (FE_ALL_EXCEPT == 0)
-+/* E.g. ARM soft float does not define these */
-+#define FE_INVALID    0
-+#define FE_DIVBYZERO  0
-+#define FE_OVERFLOW   0
-+#define FE_UNDERFLOW  0
-+#define FE_INEXACT    0
-+#endif
-+
- #if CONFIG_LIBFONTCONFIG
- #include <fontconfig/fontconfig.h>
- #endif
diff --git a/srcpkgs/ffmpeg/patches/binutils-2.41.patch b/srcpkgs/ffmpeg/patches/binutils-2.41.patch
deleted file mode 100644
index 53a596d0ee7d4..0000000000000
--- a/srcpkgs/ffmpeg/patches/binutils-2.41.patch
+++ /dev/null
@@ -1,73 +0,0 @@
-From effadce6c756247ea8bae32dc13bb3e6f464f0eb Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= <remi@remlab.net>
-Date: Sun, 16 Jul 2023 18:18:02 +0300
-Subject: [PATCH] avcodec/x86/mathops: clip constants used with shift
- instructions within inline assembly
-
-Fixes assembling with binutil as >= 2.41
-
-Signed-off-by: James Almer <jamrial@gmail.com>
----
- libavcodec/x86/mathops.h | 26 +++++++++++++++++++++++---
- 1 file changed, 23 insertions(+), 3 deletions(-)
-
-diff --git a/libavcodec/x86/mathops.h b/libavcodec/x86/mathops.h
-index 6298f5ed1983b..ca7e2dffc1076 100644
---- a/libavcodec/x86/mathops.h
-+++ b/libavcodec/x86/mathops.h
-@@ -35,12 +35,20 @@
- static av_always_inline av_const int MULL(int a, int b, unsigned shift)
- {
-     int rt, dummy;
-+    if (__builtin_constant_p(shift))
-     __asm__ (
-         "imull %3               \n\t"
-         "shrdl %4, %%edx, %%eax \n\t"
-         :"=a"(rt), "=d"(dummy)
--        :"a"(a), "rm"(b), "ci"((uint8_t)shift)
-+        :"a"(a), "rm"(b), "i"(shift & 0x1F)
-     );
-+    else
-+        __asm__ (
-+            "imull %3               \n\t"
-+            "shrdl %4, %%edx, %%eax \n\t"
-+            :"=a"(rt), "=d"(dummy)
-+            :"a"(a), "rm"(b), "c"((uint8_t)shift)
-+        );
-     return rt;
- }
- 
-@@ -113,19 +121,31 @@ __asm__ volatile(\
- // avoid +32 for shift optimization (gcc should do that ...)
- #define NEG_SSR32 NEG_SSR32
- static inline  int32_t NEG_SSR32( int32_t a, int8_t s){
-+    if (__builtin_constant_p(s))
-     __asm__ ("sarl %1, %0\n\t"
-          : "+r" (a)
--         : "ic" ((uint8_t)(-s))
-+         : "i" (-s & 0x1F)
-     );
-+    else
-+        __asm__ ("sarl %1, %0\n\t"
-+               : "+r" (a)
-+               : "c" ((uint8_t)(-s))
-+        );
-     return a;
- }
- 
- #define NEG_USR32 NEG_USR32
- static inline uint32_t NEG_USR32(uint32_t a, int8_t s){
-+    if (__builtin_constant_p(s))
-     __asm__ ("shrl %1, %0\n\t"
-          : "+r" (a)
--         : "ic" ((uint8_t)(-s))
-+         : "i" (-s & 0x1F)
-     );
-+    else
-+        __asm__ ("shrl %1, %0\n\t"
-+               : "+r" (a)
-+               : "c" ((uint8_t)(-s))
-+        );
-     return a;
- }
- 
diff --git a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
deleted file mode 100644
index aa948f7a8a2df..0000000000000
--- a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
+++ /dev/null
@@ -1,40 +0,0 @@
-#==================================================================================================
-# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
-# From: Christopher Degawa <christopher.degawa@intel.com>
-# Date: Thu, 20 Oct 2022 22:55:27 -0500
-# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
-#
-# compressed_ten_bit_format has been deprecated upstream and has no effect
-# and can be removed. Plus, technically it was never used in the first place
-# since it would require the app (ffmpeg) to set it and do additional
-# processing of the input frames.
-#
-# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
-#
-# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
-#==================================================================================================
---- a/libavcodec/libsvtav1.c
-+++ b/libavcodec/libsvtav1.c
-@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
- 
- static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
- {
--    const int    pack_mode_10bit =
--        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
--    const size_t luma_size_8bit  =
--        config->source_width * config->source_height * (1 << pack_mode_10bit);
--    const size_t luma_size_10bit =
--        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
-+    const size_t luma_size = config->source_width * config->source_height *
-+        (config->encoder_bit_depth > 8 ? 2 : 1);
- 
-     EbSvtIOFormat *in_data;
- 
--    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
-+    svt_enc->raw_size = luma_size * 3 / 2;
- 
-     // allocate buffer for in and out
-     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
--- 
-GitLab
-
diff --git a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
deleted file mode 100644
index 00e3f68a415b8..0000000000000
--- a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
-From: Rainer Hochecker <fernetmenta@online.de>
-Date: Sat, 26 Jan 2019 19:48:35 +0100
-Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
-
-This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
-It was hit frequently when watching h264 channels received via DVB-X.
-Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
----
- libavcodec/vaapi_h264.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
-index 5854587a255..f12fdc457a4 100644
---- a/libavcodec/vaapi_h264.c
-+++ b/libavcodec/vaapi_h264.c
-@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
-     H264SliceContext *sl = &h->slice_ctx[0];
-     int ret;
- 
-+    if (pic->nb_slices == 0) {
-+        ret = AVERROR_INVALIDDATA;
-+        goto finish;
-+    }
-+
-     ret = ff_vaapi_decode_issue(avctx, pic);
-     if (ret < 0)
-         goto finish;
diff --git a/srcpkgs/ffmpeg/template b/srcpkgs/ffmpeg/template
index 1ebb436135938..f1e4712c41d08 100644
--- a/srcpkgs/ffmpeg/template
+++ b/srcpkgs/ffmpeg/template
@@ -1,15 +1,15 @@
 # Template file for 'ffmpeg'
 # audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
 pkgname=ffmpeg
-version=4.4.4
-revision=6
+version=6.0.1
+revision=1
 short_desc="Decoding, encoding and streaming software"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="https://www.ffmpeg.org"
 changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
 distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
-checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+checksum=9b16b8731d78e596b4be0d720428ca42df642bb2d78342881ff7f5bc29fc9623
 
 hostmakedepends="pkg-config perl"
 makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
@@ -26,12 +26,13 @@ makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-deve
  $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
  $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
  $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
- $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers Vulkan-Tools Vulkan-ValidationLayers')
+ $(vopt_if onevpl 'oneVPL oneVPL-devel')
  $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
 depends="ffplay>=${version}_${revision}"
 
 build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
- dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec onevpl"
 build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
 desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
 desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
@@ -39,9 +40,13 @@ desc_option_sofa="Enable support for AES SOFA"
 desc_option_webp="Enable support for WebP"
 
 case "$XBPS_TARGET_MACHINE" in
-	i686*|x86_64*)
-		hostmakedepends+=" nasm"
+	i686*)
 		build_options_default+=" vaapi vdpau nvenc nvdec"
+		hostmakedepends+=" nasm"
+		;;
+	x86_64*)
+		hostmakedepends+=" nasm"
+		build_options_default+=" vaapi vdpau nvenc nvdec onevpl"
 		;;
 	ppc64*) build_options_default+=" vaapi vdpau";;
 	mips*) CFLAGS="-mnan=legacy";;
@@ -65,8 +70,6 @@ post_patch() {
 		ppc64le*) ;;
 		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
 	esac
-
-	vsed -i libavfilter/vf_libvmaf.c -e 's!/usr/local/share/model/\(vmaf_v0.6.1\).pkl!/usr/share/vmaf/\1.json!'
 }
 
 do_configure() {
@@ -115,18 +118,19 @@ do_configure() {
 		$(vopt_enable x265 libx265) \
 		$(vopt_enable v4l2 libv4l2) \
 		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
-		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		--enable-libbs2b --enable-libvidstab \
 		$(vopt_enable dav1d libdav1d) \
 		$(vopt_enable zimg libzimg) \
 		$(vopt_enable webp libwebp) \
 		$(vopt_enable sofa libmysofa) \
 		$(vopt_enable vulkan) \
+		$(vopt_enable onevpl libvpl) \
 		$(vopt_enable drm libdrm) \
 		$(vopt_enable svtav1 libsvtav1) \
 		$(vopt_enable srt libsrt) \
 		$(vopt_enable rist librist) \
-		$(vopt_if nvenc '--enable-nvenc') \
-		$(vopt_if nvdec '--enable-nvdec')
+		$(vopt_enable nvenc nvenc) \
+		$(vopt_enable nvdec nvdec)
 }
 
 do_build() {
@@ -153,10 +157,8 @@ libavdevice_package() {
 }
 
 libavresample_package() {
-	short_desc="FFmpeg audio resampling library"
-	pkg_install() {
-		vmove "usr/lib/libavresample.so.*"
-	}
+	short_desc="Package deprecated, removal needed"
+	build_style=meta
 }
 
 libavformat_package() {
@@ -210,15 +212,13 @@ ffmpeg-devel_package() {
 		libavfilter>=${version}_${revision}
 		libpostproc>=${version}_${revision}
 		libswscale>=${version}_${revision}
-		libswresample>=${version}_${revision}
-		libavresample>=${version}_${revision}"
+		libswresample>=${version}_${revision}"
 	short_desc+=" - development files"
-
+	conflicts="ffmpeg4-devel"
 	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
 		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
 		nostrip_files="/usr/lib/libavfilter.a"
 	fi
-
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig

From 3777cd88eb6e96892bd6ff2037bd5fad8365399a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:14 -0400
Subject: [PATCH 002/111] openshot: revbump for ffmpeg6

---
 srcpkgs/openshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openshot/template b/srcpkgs/openshot/template
index 8f47851eef354..affb652a9d500 100644
--- a/srcpkgs/openshot/template
+++ b/srcpkgs/openshot/template
@@ -1,7 +1,7 @@
 # Template file for 'openshot'
 pkgname=openshot
 version=3.0.0
-revision=2
+revision=3
 build_style=python3-module
 hostmakedepends="python3 python3-setuptools"
 makedepends="ffmpeg-devel python3-PyQt5"

From d2009a52e3136aa8230f6ec702074d0aa2006eeb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:36 -0400
Subject: [PATCH 003/111] sumo: revbump for ffmpeg6

---
 srcpkgs/sumo/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/sumo/template b/srcpkgs/sumo/template
index a3fe134aa5acc..a730afa9fafa9 100644
--- a/srcpkgs/sumo/template
+++ b/srcpkgs/sumo/template
@@ -1,7 +1,7 @@
 # Template file for 'sumo'
 pkgname=sumo
 version=1.12.0
-revision=6
+revision=7
 build_style=cmake
 hostmakedepends="libgdal-tools pkg-config swig python3-setuptools"
 makedepends="python3-devel ffmpeg-devel fox-devel gl2ps-devel libgdal-devel

From ab1fd15c6db3ba5b5275699db920312f05318c12 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:56:22 -0400
Subject: [PATCH 004/111] New package: ffmpeg4-4.4.4.

---
 srcpkgs/ffmpeg4-devel                         |   1 +
 srcpkgs/ffmpeg4/files/altivec.patch           |  60 +++++
 .../patches/armv5tel-floating-point.patch     |  18 ++
 srcpkgs/ffmpeg4/patches/binutils-2.41.patch   |  73 ++++++
 ...h-libavcodec-libsvtav1-ten_bit_format.diff |  40 +++
 .../workaround-mesa-readeon-vaapi-bug.patch   |  28 +++
 srcpkgs/ffmpeg4/template                      | 234 ++++++++++++++++++
 srcpkgs/libavcodec4                           |   1 +
 srcpkgs/libavdevice4                          |   1 +
 srcpkgs/libavfilter4                          |   1 +
 srcpkgs/libavformat4                          |   1 +
 srcpkgs/libavresample4                        |   1 +
 srcpkgs/libavutil4                            |   1 +
 srcpkgs/libpostproc4                          |   1 +
 srcpkgs/libswresample4                        |   1 +
 srcpkgs/libswscale4                           |   1 +
 16 files changed, 463 insertions(+)
 create mode 120000 srcpkgs/ffmpeg4-devel
 create mode 100644 srcpkgs/ffmpeg4/files/altivec.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/binutils-2.41.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 create mode 100644 srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
 create mode 100644 srcpkgs/ffmpeg4/template
 create mode 120000 srcpkgs/libavcodec4
 create mode 120000 srcpkgs/libavdevice4
 create mode 120000 srcpkgs/libavfilter4
 create mode 120000 srcpkgs/libavformat4
 create mode 120000 srcpkgs/libavresample4
 create mode 120000 srcpkgs/libavutil4
 create mode 120000 srcpkgs/libpostproc4
 create mode 120000 srcpkgs/libswresample4
 create mode 120000 srcpkgs/libswscale4

diff --git a/srcpkgs/ffmpeg4-devel b/srcpkgs/ffmpeg4-devel
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/ffmpeg4-devel
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/ffmpeg4/files/altivec.patch b/srcpkgs/ffmpeg4/files/altivec.patch
new file mode 100644
index 0000000000000..9c57200463320
--- /dev/null
+++ b/srcpkgs/ffmpeg4/files/altivec.patch
@@ -0,0 +1,60 @@
+revert some altivec specific change on all ppc* except ppc64le*
+
+q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
+conditionally, for ppc* but not ppc64le* (the new code is valid for
+POWER8 VSX which LE targets as a baseline but not BE)"
+
+
+This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
+---
+ libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
+ 1 file changed, 20 insertions(+), 4 deletions(-)
+
+diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
+index 536545293d..c1e2852adb 100644
+--- a/libswscale/ppc/yuv2rgb_altivec.c
++++ b/libswscale/ppc/yuv2rgb_altivec.c
+@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+     vector signed short R1, G1, B1;                                           \
+     vector unsigned char R, G, B;                                             \
+                                                                               \
++    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
++    vector unsigned char align_perm;                                          \
++                                                                              \
+     vector signed short lCY       = c->CY;                                    \
+     vector signed short lOY       = c->OY;                                    \
+     vector signed short lCRV      = c->CRV;                                   \
+@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
+                                                                               \
+         for (j = 0; j < w / 16; j++) {                                        \
+-            y0 = vec_xl(0, y1i);                                              \
++            y1ivP = (const vector unsigned char *) y1i;                       \
++            y2ivP = (const vector unsigned char *) y2i;                       \
++            uivP  = (const vector unsigned char *) ui;                        \
++            vivP  = (const vector unsigned char *) vi;                        \
++                                                                              \
++            align_perm = vec_lvsl(0, y1i);                                    \
++            y0 = (vector unsigned char)                                       \
++                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
+                                                                               \
+-            y1 = vec_xl(0, y2i);                                              \
++            align_perm = vec_lvsl(0, y2i);                                    \
++            y1 = (vector unsigned char)                                       \
++                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
+                                                                               \
+-            u = (vector signed char) vec_xl(0, ui);                           \
++            align_perm = vec_lvsl(0, ui);                                     \
++            u = (vector signed char)                                          \
++                    vec_perm(uivP[0], uivP[1], align_perm);                   \
+                                                                               \
+-            v = (vector signed char) vec_xl(0, vi);                           \
++            align_perm = vec_lvsl(0, vi);                                     \
++            v = (vector signed char)                                          \
++                    vec_perm(vivP[0], vivP[1], align_perm);                   \
+                                                                               \
+             u = (vector signed char)                                          \
+                     vec_sub(u,                                                \
+-- 
+2.27.0
+
diff --git a/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
new file mode 100644
index 0000000000000..9a55178c74f0f
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
@@ -0,0 +1,18 @@
+--- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
++++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
+@@ -39,6 +39,15 @@
+ #endif
+ #include <fenv.h>
+ 
++#if (FE_ALL_EXCEPT == 0)
++/* E.g. ARM soft float does not define these */
++#define FE_INVALID    0
++#define FE_DIVBYZERO  0
++#define FE_OVERFLOW   0
++#define FE_UNDERFLOW  0
++#define FE_INEXACT    0
++#endif
++
+ #if CONFIG_LIBFONTCONFIG
+ #include <fontconfig/fontconfig.h>
+ #endif
diff --git a/srcpkgs/ffmpeg4/patches/binutils-2.41.patch b/srcpkgs/ffmpeg4/patches/binutils-2.41.patch
new file mode 100644
index 0000000000000..53a596d0ee7d4
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/binutils-2.41.patch
@@ -0,0 +1,73 @@
+From effadce6c756247ea8bae32dc13bb3e6f464f0eb Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= <remi@remlab.net>
+Date: Sun, 16 Jul 2023 18:18:02 +0300
+Subject: [PATCH] avcodec/x86/mathops: clip constants used with shift
+ instructions within inline assembly
+
+Fixes assembling with binutil as >= 2.41
+
+Signed-off-by: James Almer <jamrial@gmail.com>
+---
+ libavcodec/x86/mathops.h | 26 +++++++++++++++++++++++---
+ 1 file changed, 23 insertions(+), 3 deletions(-)
+
+diff --git a/libavcodec/x86/mathops.h b/libavcodec/x86/mathops.h
+index 6298f5ed1983b..ca7e2dffc1076 100644
+--- a/libavcodec/x86/mathops.h
++++ b/libavcodec/x86/mathops.h
+@@ -35,12 +35,20 @@
+ static av_always_inline av_const int MULL(int a, int b, unsigned shift)
+ {
+     int rt, dummy;
++    if (__builtin_constant_p(shift))
+     __asm__ (
+         "imull %3               \n\t"
+         "shrdl %4, %%edx, %%eax \n\t"
+         :"=a"(rt), "=d"(dummy)
+-        :"a"(a), "rm"(b), "ci"((uint8_t)shift)
++        :"a"(a), "rm"(b), "i"(shift & 0x1F)
+     );
++    else
++        __asm__ (
++            "imull %3               \n\t"
++            "shrdl %4, %%edx, %%eax \n\t"
++            :"=a"(rt), "=d"(dummy)
++            :"a"(a), "rm"(b), "c"((uint8_t)shift)
++        );
+     return rt;
+ }
+ 
+@@ -113,19 +121,31 @@ __asm__ volatile(\
+ // avoid +32 for shift optimization (gcc should do that ...)
+ #define NEG_SSR32 NEG_SSR32
+ static inline  int32_t NEG_SSR32( int32_t a, int8_t s){
++    if (__builtin_constant_p(s))
+     __asm__ ("sarl %1, %0\n\t"
+          : "+r" (a)
+-         : "ic" ((uint8_t)(-s))
++         : "i" (-s & 0x1F)
+     );
++    else
++        __asm__ ("sarl %1, %0\n\t"
++               : "+r" (a)
++               : "c" ((uint8_t)(-s))
++        );
+     return a;
+ }
+ 
+ #define NEG_USR32 NEG_USR32
+ static inline uint32_t NEG_USR32(uint32_t a, int8_t s){
++    if (__builtin_constant_p(s))
+     __asm__ ("shrl %1, %0\n\t"
+          : "+r" (a)
+-         : "ic" ((uint8_t)(-s))
++         : "i" (-s & 0x1F)
+     );
++    else
++        __asm__ ("shrl %1, %0\n\t"
++               : "+r" (a)
++               : "c" ((uint8_t)(-s))
++        );
+     return a;
+ }
+ 
diff --git a/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
new file mode 100644
index 0000000000000..aa948f7a8a2df
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
@@ -0,0 +1,40 @@
+#==================================================================================================
+# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
+# From: Christopher Degawa <christopher.degawa@intel.com>
+# Date: Thu, 20 Oct 2022 22:55:27 -0500
+# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
+#
+# compressed_ten_bit_format has been deprecated upstream and has no effect
+# and can be removed. Plus, technically it was never used in the first place
+# since it would require the app (ffmpeg) to set it and do additional
+# processing of the input frames.
+#
+# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
+#
+# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
+#==================================================================================================
+--- a/libavcodec/libsvtav1.c
++++ b/libavcodec/libsvtav1.c
+@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
+ 
+ static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
+ {
+-    const int    pack_mode_10bit =
+-        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
+-    const size_t luma_size_8bit  =
+-        config->source_width * config->source_height * (1 << pack_mode_10bit);
+-    const size_t luma_size_10bit =
+-        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
++    const size_t luma_size = config->source_width * config->source_height *
++        (config->encoder_bit_depth > 8 ? 2 : 1);
+ 
+     EbSvtIOFormat *in_data;
+ 
+-    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
++    svt_enc->raw_size = luma_size * 3 / 2;
+ 
+     // allocate buffer for in and out
+     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
+-- 
+GitLab
+
diff --git a/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
new file mode 100644
index 0000000000000..00e3f68a415b8
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
@@ -0,0 +1,28 @@
+From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
+From: Rainer Hochecker <fernetmenta@online.de>
+Date: Sat, 26 Jan 2019 19:48:35 +0100
+Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
+
+This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
+It was hit frequently when watching h264 channels received via DVB-X.
+Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
+---
+ libavcodec/vaapi_h264.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
+index 5854587a255..f12fdc457a4 100644
+--- a/libavcodec/vaapi_h264.c
++++ b/libavcodec/vaapi_h264.c
+@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
+     H264SliceContext *sl = &h->slice_ctx[0];
+     int ret;
+ 
++    if (pic->nb_slices == 0) {
++        ret = AVERROR_INVALIDDATA;
++        goto finish;
++    }
++
+     ret = ff_vaapi_decode_issue(avctx, pic);
+     if (ret < 0)
+         goto finish;
diff --git a/srcpkgs/ffmpeg4/template b/srcpkgs/ffmpeg4/template
new file mode 100644
index 0000000000000..9ba14bdb8ddf3
--- /dev/null
+++ b/srcpkgs/ffmpeg4/template
@@ -0,0 +1,234 @@
+# Template file for 'ffmpeg4'
+# audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
+pkgname=ffmpeg4
+version=4.4.4
+revision=1
+short_desc="Decoding, encoding and streaming software - ffmpeg4 libraries only"
+maintainer="Orphaned <orphan@voidlinux.org>"
+license="GPL-3.0-or-later"
+homepage="https://www.ffmpeg.org"
+changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
+distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
+checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+
+hostmakedepends="pkg-config perl"
+makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
+ libXext-devel libXvMC-devel libxcb-devel lame-devel libtheora-devel
+ libvorbis-devel x264-devel xvidcore-devel jack-devel SDL2-devel
+ libcdio-paranoia-devel librtmp-devel libmodplug-devel gnutls-devel
+ speex-devel celt-devel harfbuzz-devel libass-devel opus-devel ocl-icd-devel
+ libbs2b-devel libvidstab-devel vmaf-devel $(vopt_if pulseaudio pulseaudio-devel)
+ $(vopt_if vaapi libva-devel) $(vopt_if vdpau libvdpau-devel)
+ $(vopt_if x265 x265-devel) $(vopt_if v4l2 v4l-utils-devel)
+ $(vopt_if fdk_aac fdk-aac-devel) $(vopt_if vpx libvpx-devel)
+ $(vopt_if aom libaom-devel) $(vopt_if sndio sndio-devel)
+ $(vopt_if dav1d libdav1d-devel) $(vopt_if zimg zimg-devel)
+ $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
+ $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
+ $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
+
+build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
+
+desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
+desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
+desc_option_sofa="Enable support for AES SOFA"
+desc_option_webp="Enable support for WebP"
+
+case "$XBPS_TARGET_MACHINE" in
+	i686*|x86_64*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau nvenc nvdec"
+			;;
+	ppc64*) build_options_default+=" vaapi vdpau";;
+	mips*) CFLAGS="-mnan=legacy";;
+esac
+
+if [ "$XBPS_TARGET_WORDSIZE" != "32" ]; then
+	build_options_default+=" svtav1"
+fi
+
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+fi
+
+_apply_patch() {
+	local args="$1" pname="$(basename $2)"
+
+	if [ ! -f ".${pname}_done" ]; then
+		patch -N $args -i $2
+		touch .${pname}_done
+	fi
+}
+
+post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64le*) ;;
+		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
+	esac
+
+	vsed -i libavfilter/vf_libvmaf.c -e 's!/usr/local/share/model/\(vmaf_v0.6.1\).pkl!/usr/share/vmaf/\1.json!'
+}
+
+do_configure() {
+	# Fix gcc on x86_64-musl only
+	if [ "$XBPS_TARGET_MACHINE" = "x86_64-musl" ]; then
+		vsed -i configure -e "s;_cflags_speed='-O3';_cflags_speed='-O2';"
+	fi
+
+	if [ "$CROSS_BUILD" ]; then
+		case "$XBPS_TARGET_MACHINE" in
+			arm*) _arch="arm";;
+			aarch64*) _arch="aarch64";;
+			mips*) _arch="mips";;
+			ppc64*) _arch="ppc64";;
+			ppc*) _arch="ppc";;
+			*) _arch="${XBPS_TARGET_MACHINE%%-musl}";;
+		esac
+
+		_args+=" --enable-cross-compile
+			--sysroot=$XBPS_CROSS_BASE
+			--cross-prefix=${XBPS_CROSS_TRIPLET}-
+			--target-os=linux --arch=${_arch}"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc|ppc-musl) _args+=" --disable-altivec";;
+	esac
+
+	if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+		_args+=" --extra-libs=-latomic"
+	fi
+
+	./configure --prefix=/usr --disable-debug --enable-gpl --enable-gnutls \
+		--disable-stripping \
+		--enable-libcdio --enable-version3 --enable-runtime-cpudetect \
+		--enable-libmp3lame --enable-libvorbis --enable-libxvid \
+		--enable-libx264 $(vopt_enable vpx libvpx) --enable-libtheora \
+		--enable-shared --enable-static --enable-libxcb \
+		$(vopt_enable pulseaudio libpulse) --enable-libfreetype --enable-libmodplug \
+		--enable-libspeex --enable-libcelt --enable-libass \
+		--enable-libopus --enable-librtmp --enable-libjack \
+		$(vopt_if fdk_aac '--enable-nonfree --enable-libfdk-aac') \
+		--disable-libopencore_amrnb --disable-libopencore_amrwb \
+		--disable-libopenjpeg \
+		--enable-postproc --enable-opencl ${_args} --enable-libvmaf ${_args} \
+		$(vopt_enable x265 libx265) \
+		$(vopt_enable v4l2 libv4l2) \
+		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
+		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		$(vopt_enable dav1d libdav1d) \
+		$(vopt_enable zimg libzimg) \
+		$(vopt_enable webp libwebp) \
+		$(vopt_enable sofa libmysofa) \
+		$(vopt_enable vulkan) \
+		$(vopt_enable drm libdrm) \
+		$(vopt_enable svtav1 libsvtav1) \
+		$(vopt_enable srt libsrt) \
+		$(vopt_enable rist librist) \
+		$(vopt_if nvenc '--enable-nvenc') \
+		$(vopt_if nvdec '--enable-nvdec')
+}
+
+do_build() {
+	make ${makejobs}
+	make doc/ff{mpeg,play}.1
+}
+
+do_install() {
+	make DESTDIR=${DESTDIR} install install-man
+	rm -rf ${DESTDIR}/usr/bin
+}
+
+libavcodec4_package() {
+	short_desc="FFmpeg codec library"
+	pkg_install() {
+		vmove "usr/lib/libavcodec.so.*"
+	}
+}
+
+libavdevice4_package() {
+	short_desc="FFmpeg device handling library"
+	pkg_install() {
+		vmove "usr/lib/libavdevice.so.*"
+	}
+}
+
+libavresample4_package() {
+	short_desc="FFmpeg audio resampling library"
+	pkg_install() {
+		vmove "usr/lib/libavresample.so.*"
+	}
+}
+
+libavformat4_package() {
+	short_desc="FFmpeg file format library"
+	pkg_install() {
+		vmove "usr/lib/libavformat.so.*"
+	}
+}
+
+libavutil4_package() {
+	short_desc="FFmpeg utility library"
+	pkg_install() {
+		vmove "usr/lib/libavutil.so.*"
+	}
+}
+
+libavfilter4_package() {
+	short_desc="FFmpeg audio/video filter library"
+	pkg_install() {
+		vmove "usr/lib/libavfilter.so.*"
+	}
+}
+
+libpostproc4_package() {
+	short_desc="FFmpeg video postprocessing library"
+	pkg_install() {
+		vmove "usr/lib/libpostproc.so.*"
+	}
+}
+
+libswscale4_package() {
+	short_desc="FFmpeg video scaling library"
+	pkg_install() {
+		vmove "usr/lib/libswscale.so.*"
+	}
+}
+
+libswresample4_package() {
+	short_desc="FFmpeg video resampling library"
+	pkg_install() {
+		vmove "usr/lib/libswresample.so.*"
+	}
+}
+
+ffmpeg4-devel_package() {
+	depends="
+		libavcodec4>=${version}_${revision}
+		libavdevice4>=${version}_${revision}
+		libavformat4>=${version}_${revision}
+		libavutil4>=${version}_${revision}
+		libavfilter4>=${version}_${revision}
+		libpostproc4>=${version}_${revision}
+		libswscale4>=${version}_${revision}
+		libswresample4>=${version}_${revision}
+		libavresample4>=${version}_${revision}"
+	short_desc+=" - development files"
+	conflicts="ffmpeg-devel"
+	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
+		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
+		nostrip_files="/usr/lib/libavfilter.a"
+	fi
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.a"
+		vmove "usr/lib/*.so"
+		vmove usr/share/ffmpeg/examples
+		vmove usr/share/man/man3
+	}
+}
diff --git a/srcpkgs/libavcodec4 b/srcpkgs/libavcodec4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavcodec4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavdevice4 b/srcpkgs/libavdevice4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavdevice4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavfilter4 b/srcpkgs/libavfilter4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavfilter4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavformat4 b/srcpkgs/libavformat4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavformat4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavresample4 b/srcpkgs/libavresample4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavutil4 b/srcpkgs/libavutil4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavutil4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libpostproc4 b/srcpkgs/libpostproc4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libpostproc4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswresample4 b/srcpkgs/libswresample4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libswresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswscale4 b/srcpkgs/libswscale4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libswscale4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file

From 93f6955ab3e9e41ec8d5ebdc46632ae9de472e4a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:04 -0400
Subject: [PATCH 005/111] opencv: update to 4.7.0.

---
 common/shlibs           | 104 ++++++++++++++++++++--------------------
 srcpkgs/opencv/template |   8 ++--
 2 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index c1c79647f63ca..e8b9e5e974fe7 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2070,58 +2070,58 @@ libcapstone.so.5 capstone-5.0.1_1
 libhavege.so.2 libhaveged-1.9.11_1
 libnih.so.1 libnih-1.0.3_1
 libnih-dbus.so.1 libnih-1.0.3_1
-libopencv_quality.so.406 libopencv-4.6.0_1
-libopencv_reg.so.406 libopencv-4.6.0_1
-libopencv_surface_matching.so.406 libopencv-4.6.0_1
-libopencv_xphoto.so.406 libopencv-4.6.0_1
-libopencv_freetype.so.406 libopencv-4.6.0_1
-libopencv_fuzzy.so.406 libopencv-4.6.0_1
-libopencv_hfs.so.406 libopencv-4.6.0_1
-libopencv_img_hash.so.406 libopencv-4.6.0_1
-libopencv_line_descriptor.so.406 libopencv-4.6.0_1
-libopencv_saliency.so.406 libopencv-4.6.0_1
-libopencv_structured_light.so.406 libopencv-4.6.0_1
-libopencv_aruco.so.406 libopencv-4.6.0_1
-libopencv_bgsegm.so.406 libopencv-4.6.0_1
-libopencv_bioinspired.so.406 libopencv-4.6.0_1
-libopencv_ccalib.so.406 libopencv-4.6.0_1
-libopencv_face.so.406 libopencv-4.6.0_1
-libopencv_tracking.so.406 libopencv-4.6.0_1
-libopencv_xfeatures2d.so.406 libopencv-4.6.0_1
-libopencv_optflow.so.406 libopencv-4.6.0_1
-libopencv_ximgproc.so.406 libopencv-4.6.0_1
-libopencv_plot.so.406 libopencv-4.6.0_1
-libopencv_text.so.406 libopencv-4.6.0_1
-libopencv_ml.so.406 libopencv-4.6.0_1
-libopencv_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn.so.406 libopencv-4.6.0_1
-libopencv_shape.so.406 libopencv-4.6.0_1
-libopencv_stitching.so.406 libopencv-4.6.0_1
-libopencv_photo.so.406 libopencv-4.6.0_1
-libopencv_video.so.406 libopencv-4.6.0_1
-libopencv_calib3d.so.406 libopencv-4.6.0_1
-libopencv_features2d.so.406 libopencv-4.6.0_1
-libopencv_flann.so.406 libopencv-4.6.0_1
-libopencv_highgui.so.406 libopencv-4.6.0_1
-libopencv_videoio.so.406 libopencv-4.6.0_1
-libopencv_imgcodecs.so.406 libopencv-4.6.0_1
-libopencv_imgproc.so.406 libopencv-4.6.0_1
-libopencv_core.so.406 libopencv-4.6.0_1
-libopencv_superres.so.406 libopencv-4.6.0_1
-libopencv_videostab.so.406 libopencv-4.6.0_1
-libopencv_gapi.so.406 libopencv-4.6.0_1
-libopencv_xobjdetect.so.406 libopencv-4.6.0_1
-libopencv_datasets.so.406 libopencv-4.6.0_1
-libopencv_dnn_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn_superres.so.406 libopencv-4.6.0_1
-libopencv_dpm.so.406 libopencv-4.6.0_1
-libopencv_phase_unwrapping.so.406 libopencv-4.6.0_1
-libopencv_stereo.so.406 libopencv-4.6.0_1
-libopencv_rapid.so.406 libopencv-4.6.0_1
-libopencv_intensity_transform.so.406 libopencv-4.6.0_1
-libopencv_alphamat.so.406 libopencv-4.6.0_1
-libopencv_barcode.so.406 libopencv-4.6.0_1
-libopencv_mcc.so.406 libopencv-4.6.0_1
+libopencv_quality.so.407 libopencv-4.7.0_1
+libopencv_reg.so.407 libopencv-4.7.0_1
+libopencv_surface_matching.so.407 libopencv-4.7.0_1
+libopencv_xphoto.so.407 libopencv-4.7.0_1
+libopencv_freetype.so.407 libopencv-4.7.0_1
+libopencv_fuzzy.so.407 libopencv-4.7.0_1
+libopencv_hfs.so.407 libopencv-4.7.0_1
+libopencv_img_hash.so.407 libopencv-4.7.0_1
+libopencv_line_descriptor.so.407 libopencv-4.7.0_1
+libopencv_saliency.so.407 libopencv-4.7.0_1
+libopencv_structured_light.so.407 libopencv-4.7.0_1
+libopencv_aruco.so.407 libopencv-4.7.0_1
+libopencv_bgsegm.so.407 libopencv-4.7.0_1
+libopencv_bioinspired.so.407 libopencv-4.7.0_1
+libopencv_ccalib.so.407 libopencv-4.7.0_1
+libopencv_face.so.407 libopencv-4.7.0_1
+libopencv_tracking.so.407 libopencv-4.7.0_1
+libopencv_xfeatures2d.so.407 libopencv-4.7.0_1
+libopencv_optflow.so.407 libopencv-4.7.0_1
+libopencv_ximgproc.so.407 libopencv-4.7.0_1
+libopencv_plot.so.407 libopencv-4.7.0_1
+libopencv_text.so.407 libopencv-4.7.0_1
+libopencv_ml.so.407 libopencv-4.7.0_1
+libopencv_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn.so.407 libopencv-4.7.0_1
+libopencv_shape.so.407 libopencv-4.7.0_1
+libopencv_stitching.so.407 libopencv-4.7.0_1
+libopencv_photo.so.407 libopencv-4.7.0_1
+libopencv_video.so.407 libopencv-4.7.0_1
+libopencv_calib3d.so.407 libopencv-4.7.0_1
+libopencv_features2d.so.407 libopencv-4.7.0_1
+libopencv_flann.so.407 libopencv-4.7.0_1
+libopencv_highgui.so.407 libopencv-4.7.0_1
+libopencv_videoio.so.407 libopencv-4.7.0_1
+libopencv_imgcodecs.so.407 libopencv-4.7.0_1
+libopencv_imgproc.so.407 libopencv-4.7.0_1
+libopencv_core.so.407 libopencv-4.7.0_1
+libopencv_superres.so.407 libopencv-4.7.0_1
+libopencv_videostab.so.407 libopencv-4.7.0_1
+libopencv_gapi.so.407 libopencv-4.7.0_1
+libopencv_xobjdetect.so.407 libopencv-4.7.0_1
+libopencv_datasets.so.407 libopencv-4.7.0_1
+libopencv_dnn_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn_superres.so.407 libopencv-4.7.0_1
+libopencv_dpm.so.407 libopencv-4.7.0_1
+libopencv_phase_unwrapping.so.407 libopencv-4.7.0_1
+libopencv_stereo.so.407 libopencv-4.7.0_1
+libopencv_rapid.so.407 libopencv-4.7.0_1
+libopencv_intensity_transform.so.407 libopencv-4.7.0_1
+libopencv_alphamat.so.407 libopencv-4.7.0_1
+libopencv_barcode.so.407 libopencv-4.7.0_1
+libopencv_mcc.so.407 libopencv-4.7.0_1
 libuniconf.so.4.6 wvstreams-4.6.1_20
 libwvbase.so.4.6 wvstreams-4.6.1_20
 libwvutils.so.4.6 wvstreams-4.6.1_20
diff --git a/srcpkgs/opencv/template b/srcpkgs/opencv/template
index aea4bfc3a265c..ce94de9424d18 100644
--- a/srcpkgs/opencv/template
+++ b/srcpkgs/opencv/template
@@ -1,7 +1,7 @@
 # Template file for 'opencv'
 pkgname=opencv
-version=4.6.0
-revision=6
+version=4.7.0
+revision=1
 create_wrksrc=yes
 build_wrksrc=${pkgname}-${version}
 build_style=cmake
@@ -24,8 +24,8 @@ homepage="https://opencv.org"
 changelog="https://github.com/opencv/opencv/wiki/ChangeLog"
 distfiles="https://github.com/opencv/opencv/archive/${version}.tar.gz
  https://github.com/opencv/opencv_contrib/archive/${version}.tar.gz>contrib.tar.gz"
-checksum="1ec1cba65f9f20fe5a41fda1586e01c70ea0c9a6d7b67c9e13edf0cfe2239277
- 1777d5fd2b59029cf537e5fd6f8aa68d707075822f90bde683fcde086f85f7a7"
+checksum="8df0079cdbe179748a18d44731af62a245a45ebf5085223dc03133954c662973
+ 42df840cf9055e59d0e22c249cfb19f04743e1bdad113d31b1573d3934d62584"
 patch_args="-Np1 -d ${build_wrksrc}"
 # tests hang indenfinitely, even with test data included
 make_check=no

From e9bbfb34c5f9c052bf076d98c70411bfc884122c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 006/111] actiona: revbump for opencv-4.7.0

---
 srcpkgs/actiona/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/actiona/template b/srcpkgs/actiona/template
index cf5f0b7a2ae61..0d899311e6df7 100644
--- a/srcpkgs/actiona/template
+++ b/srcpkgs/actiona/template
@@ -1,7 +1,7 @@
 # Template file for 'actiona'
 pkgname=actiona
 version=3.10.1
-revision=2
+revision=3
 build_style=qmake
 configure_args="PKGCONFIG_OPENCV=opencv4"
 hostmakedepends="pkg-config qt5-plugin-mysql qt5-qmake qt5-host-tools"

From 153e8ffd758e1d2bf5b4b9b5b5c3b4a84a61b1ff Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 007/111] retroshare: revbump for opencv-4.7.0

---
 srcpkgs/retroshare/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroshare/template b/srcpkgs/retroshare/template
index bb17569277a7f..49e2c1cbe8a53 100644
--- a/srcpkgs/retroshare/template
+++ b/srcpkgs/retroshare/template
@@ -1,7 +1,7 @@
 # Template file for 'retroshare'
 pkgname=retroshare
 version=0.6.6
-revision=3
+revision=4
 build_style=qmake
 #XXX broadcast feature requires an ancient udp-discovery-cpp which either needs
 # to be fetched+patched (FTBFS) here or packaged :/

From 360f392dab24f2b478437eaa267beb57cfa6fd2b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 008/111] waifu2x-converter-cpp: revbump for opencv-4.7.0

---
 srcpkgs/waifu2x-converter-cpp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waifu2x-converter-cpp/template b/srcpkgs/waifu2x-converter-cpp/template
index 361b8a23b9497..c5ac17eb54ea4 100644
--- a/srcpkgs/waifu2x-converter-cpp/template
+++ b/srcpkgs/waifu2x-converter-cpp/template
@@ -1,7 +1,7 @@
 # Template file for 'waifu2x-converter-cpp'
 pkgname=waifu2x-converter-cpp
 version=5.2.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DINSTALL_MODELS=ON"
 hostmakedepends="pkg-config"

From 12c1b834dbb3356d67ecf030aba883e374037ebf Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:38 -0400
Subject: [PATCH 009/111] vlc: revbump for ffmpeg4

---
 srcpkgs/vlc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vlc/template b/srcpkgs/vlc/template
index bdd0cc414dc1a..d2afcc6c22129 100644
--- a/srcpkgs/vlc/template
+++ b/srcpkgs/vlc/template
@@ -25,7 +25,7 @@ lib32disabled=yes
 hostmakedepends="automake libtool pkg-config flex gettext libgcrypt-devel
  live555-devel gettext-devel $(vopt_if lua lua52) $(vopt_if chromecast protobuf)"
 makedepends="
- avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg-devel freefont-ttf
+ avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg4-devel freefont-ttf
  gnutls-devel jack-devel liba52-devel libass-devel libbluray-devel
  libcdio-devel libdca-devel libdvbpsi-devel libdvdnav-devel libmad-devel
  libmatroska-devel libmodplug-devel libmpcdec-devel libmpeg2-devel

From efa56349fc217a2ff48880d3b7f46c01498c6aa1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:55 -0400
Subject: [PATCH 010/111] osg: revbump for ffmpeg4

---
 srcpkgs/osg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/osg/template b/srcpkgs/osg/template
index a9ebbd287933b..755793f7e11bf 100644
--- a/srcpkgs/osg/template
+++ b/srcpkgs/osg/template
@@ -8,7 +8,7 @@ build_helper="qemu"
 configure_args="-DLIB_POSTFIX="
 hostmakedepends="pkg-config xrandr"
 makedepends="MesaLib-devel gtkglext-devel libcurl-devel giflib-devel librsvg-devel
- jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg-devel xine-lib-devel
+ jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg4-devel xine-lib-devel
  SDL2-devel gst-plugins-base1-devel
  $(vopt_if openexr libopenexr-devel)
  $(vopt_if poppler poppler-glib-devel)

From 1bd4a3c3b26be8a3dbf93446ab49ee0fade544fc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:13 -0400
Subject: [PATCH 011/111] xine-lib: revbump for ffmpeg4

---
 srcpkgs/xine-lib/template | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/xine-lib/template b/srcpkgs/xine-lib/template
index 3be4d08eac77a..ed6194c17d11e 100644
--- a/srcpkgs/xine-lib/template
+++ b/srcpkgs/xine-lib/template
@@ -1,14 +1,14 @@
 # Template file for 'xine-lib'
 pkgname=xine-lib
-version=1.2.12
-revision=3
+version=1.2.13
+revision=1
 build_style=gnu-configure
 configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
  --disable-oss"
 hostmakedepends="automake gettext-devel libtool pkg-config perl"
 makedepends="
  zlib-devel alsa-lib-devel libxcb-devel libSM-devel libXext-devel libXv-devel
- libXvMC-devel liba52-devel libmad-devel ffmpeg-devel pulseaudio-devel
+ libXvMC-devel liba52-devel libmad-devel ffmpeg4-devel pulseaudio-devel
  jack-devel samba-devel libflac-devel libmodplug-devel libmpcdec-devel
  speex-devel libtheora-devel libvorbis-devel libdca-devel faad2-devel
  libcdio-devel libbluray-devel aalib-devel libcaca-devel libXinerama-devel
@@ -19,7 +19,7 @@ license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="http://www.xine-project.org"
 changelog="https://sourceforge.net/projects/xine/files/xine-lib/${version}/README.txt/view"
 distfiles="${SOURCEFORGE_SITE}/xine/${pkgname}-${version}.tar.xz"
-checksum=d606270468e1540c2a89c0d7f5fdf11e17ecc0c2698cc0bcb1065ff26abee098
+checksum=5f10d6d718a4a51c17ed1b32b031d4f9b80b061e8276535b2be31e5ac4b75e6f
 
 case "$XBPS_TARGET_MACHINE" in
 	i686-musl)

From 4974ca9897f9b8e969f736eac137e0239b66070c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 012/111] attract: revbump for ffmpeg4

---
 srcpkgs/attract/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/attract/template b/srcpkgs/attract/template
index 24017d2bacc24..e760bf0d18aec 100644
--- a/srcpkgs/attract/template
+++ b/srcpkgs/attract/template
@@ -6,7 +6,7 @@ build_style=gnu-makefile
 make_build_args="VERBOSE=1"
 make_use_env=yes
 hostmakedepends="pkg-config"
-makedepends="SFML-devel ffmpeg-devel fontconfig-devel glu-devel libarchive-devel
+makedepends="SFML-devel ffmpeg4-devel fontconfig-devel glu-devel libarchive-devel
  libcurl-devel libjpeg-turbo-devel xine-lib rapidjson libXrandr-devel"
 depends="git"
 short_desc="Attract-Mode is a graphical frontend for emulators"

From 90845de27adb374d2dab631744d83aed3d87f831 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 013/111] aubio: revbump for ffmpeg6

---
 srcpkgs/aubio/patches/ffmpeg5.patch | 25 +++++++++++++++++++++++++
 srcpkgs/aubio/template              |  2 +-
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/aubio/patches/ffmpeg5.patch

diff --git a/srcpkgs/aubio/patches/ffmpeg5.patch b/srcpkgs/aubio/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..aace41a6e6d9a
--- /dev/null
+++ b/srcpkgs/aubio/patches/ffmpeg5.patch
@@ -0,0 +1,25 @@
+From 8a05420e5dd8c7b8b2447f82dc919765876511b3 Mon Sep 17 00:00:00 2001
+From: Paul Brossier <piem@piem.org>
+Date: Tue, 25 Jan 2022 18:30:27 +0100
+Subject: [PATCH] [source_avcodec] define FF_API_LAVF_AVCTX for libavcodec >
+ 59, thx @berolinux (closes gh-353)
+
+---
+ src/io/source_avcodec.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/io/source_avcodec.c b/src/io/source_avcodec.c
+index e0ae93b5..1421bd9a 100644
+--- a/src/io/source_avcodec.c
++++ b/src/io/source_avcodec.c
+@@ -68,6 +68,10 @@
+ #define AUBIO_AVCODEC_MAX_BUFFER_SIZE AV_INPUT_BUFFER_MIN_SIZE
+ #endif
+ 
++#if LIBAVCODEC_VERSION_MAJOR >= 59
++#define FF_API_LAVF_AVCTX 1
++#endif
++
+ struct _aubio_source_avcodec_t {
+   uint_t hop_size;
+   uint_t samplerate;
diff --git a/srcpkgs/aubio/template b/srcpkgs/aubio/template
index ad1c4b2569917..7d875cc02541a 100644
--- a/srcpkgs/aubio/template
+++ b/srcpkgs/aubio/template
@@ -1,7 +1,7 @@
 # Template file for 'aubio'
 pkgname=aubio
 version=0.4.9
-revision=1
+revision=2
 build_style=waf3
 # XXX lash, pure and swig support.
 hostmakedepends="pkg-config txt2man"

From 1e360690b4f01bf9925fa01f4d85d90001dd677b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 014/111] audacious-plugins: revbump for ffmpeg6

---
 .../audacious-plugins/patches/ffmpeg5.patch   | 43 +++++++++++++++++++
 srcpkgs/audacious-plugins/template            |  2 +-
 2 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/audacious-plugins/patches/ffmpeg5.patch

diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg5.patch b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..4e5e34099d71c
--- /dev/null
+++ b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
@@ -0,0 +1,43 @@
+commit 298aa371c56c2f52c25a33d9bdec4918b11cebdc
+Author: tibequadorian <tibequadorian@posteo.de>
+Date:   Sat Mar 19 18:40:12 2022 +0100
+
+    audacious-plugins: rebuild against ffmpeg-5.0
+
+diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+new file mode 100644
+index 0000000000..617c11215b
+--- /dev/null
++++ b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+@@ -0,0 +1,31 @@
++From f60beb400eeb1e4778bbfd738bc4a4ccef3de539 Mon Sep 17 00:00:00 2001
++From: John Lindgren <john@jlindgren.net>
++Date: Sat, 5 Mar 2022 12:05:34 -0500
++Subject: [PATCH] Fix build with FFmpeg 5.0
++
++---
++ src/ffaudio/ffaudio-core.cc | 4 ++--
++ 1 file changed, 2 insertions(+), 2 deletions(-)
++
++diff --git a/src/ffaudio/ffaudio-core.cc b/src/ffaudio/ffaudio-core.cc
++index 16dc63e3a..a2b95fd6c 100644
++--- a/src/ffaudio/ffaudio-core.cc
+++++ b/src/ffaudio/ffaudio-core.cc
++@@ -274,7 +274,7 @@ static AVInputFormat * get_format_by_content (const char * name, VFSFile & file)
++         AVProbeData d = {name, buf, filled};
++         score = target;
++ 
++-        f = av_probe_input_format2 (& d, true, & score);
+++        f = (AVInputFormat *) av_probe_input_format2 (& d, true, & score);
++         if (f)
++             break;
++ 
++@@ -347,7 +347,7 @@ static bool find_codec (AVFormatContext * c, CodecInfo * cinfo)
++ #endif
++         if (stream && stream->codecpar && stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
++         {
++-            AVCodec * codec = avcodec_find_decoder (stream->codecpar->codec_id);
+++            AVCodec * codec = (AVCodec *) avcodec_find_decoder (stream->codecpar->codec_id);
++ 
++             if (codec)
++             {
diff --git a/srcpkgs/audacious-plugins/template b/srcpkgs/audacious-plugins/template
index 05e53a9adf78f..4b1968e03de78 100644
--- a/srcpkgs/audacious-plugins/template
+++ b/srcpkgs/audacious-plugins/template
@@ -2,7 +2,7 @@
 #Keep in sync with audacious!
 pkgname=audacious-plugins
 version=4.3.1
-revision=3
+revision=4
 build_style=meson
 configure_args="$(vopt_bool gtk3 gtk) $(vopt_bool gtk3)
  $(vopt_bool qt) $(vopt_bool qt qt6)"

From 851835abfcbbcb582aed97c07d6ccc9d815f07a0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 015/111] audacity: revbump for ffmpeg6

---
 srcpkgs/audacity/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/audacity/template b/srcpkgs/audacity/template
index 7b838119ab261..84b49305edcef 100644
--- a/srcpkgs/audacity/template
+++ b/srcpkgs/audacity/template
@@ -1,7 +1,7 @@
 # Template file for 'audacity'
 pkgname=audacity
 version=3.4.2
-revision=1
+revision=2
 build_style=cmake
 build_helper="cmake-wxWidgets-gtk3 qemu"
 configure_args="-Daudacity_use_ffmpeg=loaded -Daudacity_lib_preference=system

From 6ca579b6fb3cf21c5338fd7e6c727a4c99c176e4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 016/111] avidemux: revbump for ffmpeg6

---
 srcpkgs/avidemux/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/avidemux/template b/srcpkgs/avidemux/template
index 253a0243e2259..557285982d2b8 100644
--- a/srcpkgs/avidemux/template
+++ b/srcpkgs/avidemux/template
@@ -1,7 +1,7 @@
 # Template file for 'avidemux'
 pkgname=avidemux
 version=2.8.0
-revision=2
+revision=3
 # Can't be compiled for aarch64, arm* or mips*
 archs="x86_64* i686*"
 hostmakedepends="cmake pkg-config qt5-host-tools qt5-devel tar yasm"

From 8ac60b884cfb6739826056967e0a1225c7c5f0a5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 017/111] blender: revbump for ffmpeg6

---
 srcpkgs/blender/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index 1dc61ec9d29d8..be35fac744876 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -9,8 +9,8 @@ configure_args="-DWITH_INSTALL_PORTABLE=OFF -DWITH_PYTHON_INSTALL=OFF
  -DWITH_JACK=ON -DWITH_CODEC_FFMPEG=ON -DWITH_CODEC_SNDFILE=ON -DWITH_OPENMP=ON
  -DWITH_FFTW3=ON -DWITH_MOD_OCEANSIM=ON -DWITH_CYCLES_EMBREE=OFF -DWITH_OPENCOLORIO=ON
  -DWITH_IMAGE_OPENEXR=ON -DWITH_IMAGE_OPENJPEG=ON -DWITH_OPENSUBDIV=ON
- -DWITH_OPENCOLLADA=ON -DWITH_SYSTEM_GLEW=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
- -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_LIBDECOR=ON
+ -DWITH_OPENCOLLADA=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
+ -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_WAYLAND_LIBDECOR=ON
  -DWITH_BUILDINFO=OFF -DPYTHON_VERSION=${py3_ver} -DPYTHON_LIBPATH=/usr/lib
  -DPYTHON_LIBRARY=python${py3_ver}${py3_abiver} -DPYTHON_INCLUDE_DIRS=/${py3_inc}
  -DWITH_SYSTEM_LZO=ON -DWITH_SYSTEM_EIGEN3=ON -DWITH_SYSTEM_FREETYPE=ON"

From bc77a73df441bf546fb298df8a422b25014c3f91 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 018/111] cantata: revbump for ffmpeg6

---
 srcpkgs/cantata/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cantata/template b/srcpkgs/cantata/template
index 4b417d80d5c2d..8a90aaa4c07a2 100644
--- a/srcpkgs/cantata/template
+++ b/srcpkgs/cantata/template
@@ -1,7 +1,7 @@
 # Template file for 'cantata'
 pkgname=cantata
 version=2.5.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools qt5-tools"
 makedepends="qt5-devel qt5-tools-devel qt5-svg-devel qt5-xmlpatterns-devel

From d90db20c37fed902c1204ad3737755011668c54b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 019/111] ccextractor: revbump for ffmpeg4

---
 srcpkgs/ccextractor/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ccextractor/template b/srcpkgs/ccextractor/template
index 84059ffd02398..3ca8ec45d6989 100644
--- a/srcpkgs/ccextractor/template
+++ b/srcpkgs/ccextractor/template
@@ -6,7 +6,7 @@ build_wrksrc="linux"
 build_style=gnu-configure
 configure_args="--enable-ocr --enable-hardsubx"
 hostmakedepends="automake pkg-config"
-makedepends="leptonica-devel tesseract-ocr-devel ffmpeg-devel"
+makedepends="leptonica-devel tesseract-ocr-devel ffmpeg4-devel"
 short_desc="Extract subtitles from video streams"
 maintainer="newbluemoon <blaumolch@mailbox.org>"
 license="GPL-2.0-or-later"

From a26e5bb1db18ba3f5480af7fe180da305e2b36fc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 020/111] chromaprint: revbump for ffmpeg6

---
 srcpkgs/chromaprint/patches/ffmpeg5.patch | 569 ++++++++++++++++++++++
 srcpkgs/chromaprint/template              |   2 +-
 2 files changed, 570 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromaprint/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromaprint/patches/ffmpeg5.patch b/srcpkgs/chromaprint/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..a9fd307a23c8a
--- /dev/null
+++ b/srcpkgs/chromaprint/patches/ffmpeg5.patch
@@ -0,0 +1,569 @@
+From 8ccad6937177b1b92e40ab8f4447ea27bac009a7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= <lalinsky@gmail.com>
+Date: Fri, 4 Nov 2022 21:47:38 +0100
+Subject: [PATCH] Use FFmpeg 5.x (#120)
+
+* Use FFmpeg 5.1.2 for CI builds
+
+* Build on Ubuntu 20.04
+
+* Upgrade code to FFmpeg 5.x APIs
+
+* Only set FFmpeg include dirs if building tools
+
+* No longer needed
+
+* Use ubuntu 20.04
+---
+ .github/workflows/build.yml                   |   6 +-
+ CMakeLists.txt                                |  16 --
+ package/build.sh                              |   4 +-
+ src/audio/ffmpeg_audio_processor.h            |   2 -
+ src/audio/ffmpeg_audio_processor_avresample.h |  72 -------
+ src/audio/ffmpeg_audio_processor_swresample.h |  18 +-
+ src/audio/ffmpeg_audio_reader.h               | 197 +++++++++---------
+ tests/CMakeLists.txt                          |   6 +
+ 8 files changed, 122 insertions(+), 199 deletions(-)
+ delete mode 100644 src/audio/ffmpeg_audio_processor_avresample.h
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index f8d6a32..4da2405 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -84,9 +84,6 @@ find_package(FFmpeg)
+ if(FFMPEG_LIBRARIES)
+ 	cmake_push_check_state(RESET)
+ 	set(CMAKE_REQUIRED_LIBRARIES ${FFMPEG_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -lm)
+-	check_function_exists(av_packet_unref HAVE_AV_PACKET_UNREF)
+-	check_function_exists(av_frame_alloc HAVE_AV_FRAME_ALLOC)
+-	check_function_exists(av_frame_free HAVE_AV_FRAME_FREE)
+ 	cmake_pop_check_state()
+ endif()
+
+@@ -163,14 +160,11 @@ message(STATUS "Using ${FFT_LIB} for FFT calculations")
+ if(NOT AUDIO_PROCESSOR_LIB)
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+ 		set(AUDIO_PROCESSOR_LIB "swresample")
+-	elseif(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(AUDIO_PROCESSOR_LIB "avresample")
+ 	endif()
+ endif()
+
+ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE OFF)
+ 		set(USE_SWRESAMPLE ON)
+ 		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBSWRESAMPLE_LIBRARIES})
+ 		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBSWRESAMPLE_INCLUDE_DIRS})
+@@ -178,16 +172,6 @@ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+ 	endif()
+ 	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+-elseif(AUDIO_PROCESSOR_LIB STREQUAL "avresample")
+-	if(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE ON)
+-		set(USE_SWRESAMPLE OFF)
+-		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBAVRESAMPLE_LIBRARIES})
+-		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBAVRESAMPLE_INCLUDE_DIRS})
+-	else()
+-		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+-	endif()
+-	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+ else()
+ 	message(STATUS "Building without audio conversion support, please install FFmpeg with libswresample")
+ endif()
+diff --git a/package/build.sh b/package/build.sh
+index da631ae..b41d36e 100755
+--- a/package/build.sh
++++ b/package/build.sh
+@@ -7,8 +7,8 @@ set -eux
+
+ BASE_DIR=$(cd $(dirname $0)/.. && pwd)
+
+-FFMPEG_VERSION=4.4.1
+-FFMPEG_BUILD_TAG=v4.4.1-1
++FFMPEG_VERSION=5.1.2
++FFMPEG_BUILD_TAG=v${FFMPEG_VERSION}-1
+
+ TMP_BUILD_DIR=$BASE_DIR/$(mktemp -d build.XXXXXXXX)
+ trap 'rm -rf $TMP_BUILD_DIR' EXIT
+diff --git a/src/audio/ffmpeg_audio_processor.h b/src/audio/ffmpeg_audio_processor.h
+index 7628fc7..39f4f6d 100644
+--- a/src/audio/ffmpeg_audio_processor.h
++++ b/src/audio/ffmpeg_audio_processor.h
+@@ -10,8 +10,6 @@
+
+ #if defined(USE_SWRESAMPLE)
+ #include "audio/ffmpeg_audio_processor_swresample.h"
+-#elif defined(USE_AVRESAMPLE)
+-#include "audio/ffmpeg_audio_processor_avresample.h"
+ #else
+ #error "no audio processing library"
+ #endif
+diff --git a/src/audio/ffmpeg_audio_processor_avresample.h b/src/audio/ffmpeg_audio_processor_avresample.h
+deleted file mode 100644
+index bd85f92..0000000
+--- a/src/audio/ffmpeg_audio_processor_avresample.h
++++ /dev/null
+@@ -1,72 +0,0 @@
+-// Copyright (C) 2016  Lukas Lalinsky
+-// Distributed under the MIT license, see the LICENSE file for details.
+-
+-#ifndef CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-#define CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-
+-extern "C" {
+-#include <libavresample/avresample.h>
+-}
+-
+-namespace chromaprint {
+-
+-class FFmpegAudioProcessor {
+-public:
+-	FFmpegAudioProcessor() {
+-		m_resample_ctx = avresample_alloc_context();
+-	}
+-
+-	~FFmpegAudioProcessor() {
+-		avresample_free(&m_resample_ctx);
+-	}
+-
+-	void SetCompatibleMode() {
+-		av_opt_set_int(m_resample_ctx, "filter_size", 16, 0);
+-		av_opt_set_int(m_resample_ctx, "phase_shift", 8, 0);
+-		av_opt_set_int(m_resample_ctx, "linear_interp", 1, 0);
+-		av_opt_set_double(m_resample_ctx, "cutoff", 0.8, 0);
+-	}
+-
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "in_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_rate", sample_rate, 0);
+-	}
+-
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "out_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_rate, 0);
+-	}
+-
+-	int Init() {
+-		return avresample_open(m_resample_ctx);
+-	}
+-
+-	int Convert(uint8_t **out, int out_count, const uint8_t **in, int in_count) {
+-		return avresample_convert(m_resample_ctx, out, 0, out_count, (uint8_t **) in, 0, in_count);
+-	}
+-
+-	int Flush(uint8_t **out, int out_count) {
+-		return avresample_read(m_resample_ctx, out, out_count);
+-	}
+-
+-private:
+-	AVAudioResampleContext *m_resample_ctx = nullptr;
+-};
+-
+-}; // namespace chromaprint
+-
+-#endif
+diff --git a/src/audio/ffmpeg_audio_processor_swresample.h b/src/audio/ffmpeg_audio_processor_swresample.h
+index b86266b..b1d4bea 100644
+--- a/src/audio/ffmpeg_audio_processor_swresample.h
++++ b/src/audio/ffmpeg_audio_processor_swresample.h
+@@ -28,30 +28,28 @@ public:
+ 		av_opt_set_double(m_swr_ctx, "cutoff", 0.8, 0);
+ 	}
+
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "icl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "ich", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetInputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "in_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "isf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "in_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "isr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "in_sample_rate", sample_rate, 0);
+ 	}
+
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "ocl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "och", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetOutputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "out_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "osf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "out_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "osr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "out_sample_rate", sample_rate, 0);
+ 	}
+
+ 	int Init() {
+diff --git a/src/audio/ffmpeg_audio_reader.h b/src/audio/ffmpeg_audio_reader.h
+index 5550164..1c6b346 100644
+--- a/src/audio/ffmpeg_audio_reader.h
++++ b/src/audio/ffmpeg_audio_reader.h
+@@ -62,7 +62,7 @@ public:
+ 	bool Read(const int16_t **data, size_t *size);
+
+ 	bool IsOpen() const { return m_opened; }
+-	bool IsFinished() const { return m_finished && !m_got_frame; }
++	bool IsFinished() const { return !m_has_more_packets && !m_has_more_frames; }
+
+ 	std::string GetError() const { return m_error; }
+ 	int GetErrorCode() const { return m_error_code; }
+@@ -74,20 +74,19 @@ private:
+ 	uint8_t *m_convert_buffer[1] = { nullptr };
+ 	int m_convert_buffer_nb_samples = 0;
+
+-	AVInputFormat *m_input_fmt = nullptr;
++	const AVInputFormat *m_input_fmt = nullptr;
+ 	AVDictionary *m_input_opts = nullptr;
+
+ 	AVFormatContext *m_format_ctx = nullptr;
+ 	AVCodecContext *m_codec_ctx = nullptr;
+-	AVFrame *m_frame = nullptr;
+ 	int m_stream_index = -1;
+ 	std::string m_error;
+ 	int m_error_code = 0;
+-	bool m_finished = false;
+ 	bool m_opened = false;
+-	int m_got_frame = 0;
+-	AVPacket m_packet;
+-	AVPacket m_packet0;
++	bool m_has_more_packets = true;
++	bool m_has_more_frames = true;
++	AVPacket *m_packet = nullptr;
++	AVFrame *m_frame = nullptr;
+
+ 	int m_output_sample_rate = 0;
+ 	int m_output_channels = 0;
+@@ -98,19 +97,12 @@ private:
+
+ inline FFmpegAudioReader::FFmpegAudioReader() {
+ 	av_log_set_level(AV_LOG_QUIET);
+-
+-	av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
+ }
+
+ inline FFmpegAudioReader::~FFmpegAudioReader() {
+ 	Close();
+ 	av_dict_free(&m_input_opts);
+ 	av_freep(&m_convert_buffer[0]);
+-	av_packet_unref(&m_packet0);
+ }
+
+ inline bool FFmpegAudioReader::SetInputFormat(const char *name) {
+@@ -135,11 +127,10 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ 	Close();
+
+-    av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
++	m_packet = av_packet_alloc();
++	if (!m_packet) {
++		return false;
++	}
+
+ 	ret = avformat_open_input(&m_format_ctx, file_name.c_str(), m_input_fmt, &m_input_opts);
+ 	if (ret < 0) {
+@@ -153,26 +144,31 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		return false;
+ 	}
+
+-	AVCodec *codec;
++	const AVCodec *codec;
+ 	ret = av_find_best_stream(m_format_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &codec, 0);
+ 	if (ret < 0) {
+ 		SetError("Could not find any audio stream in the file", ret);
+ 		return false;
+ 	}
+ 	m_stream_index = ret;
++	auto stream = m_format_ctx->streams[m_stream_index];
+
+-	m_codec_ctx = m_format_ctx->streams[m_stream_index]->codec;
++	m_codec_ctx = avcodec_alloc_context3(codec);
+ 	m_codec_ctx->request_sample_fmt = AV_SAMPLE_FMT_S16;
+
++	ret = avcodec_parameters_to_context(m_codec_ctx, stream->codecpar);
++	if (ret < 0) {
++		SetError("Could not copy the stream parameters", ret);
++		return false;
++	}
++
+ 	ret = avcodec_open2(m_codec_ctx, codec, nullptr);
+ 	if (ret < 0) {
+ 		SetError("Could not open the codec", ret);
+ 		return false;
+ 	}
+
+-	if (!m_codec_ctx->channel_layout) {
+-		m_codec_ctx->channel_layout = av_get_default_channel_layout(m_codec_ctx->channels);
+-	}
++	av_dump_format(m_format_ctx, 0, "foo", 0);
+
+ 	m_frame = av_frame_alloc();
+ 	if (!m_frame) {
+@@ -183,19 +179,23 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		m_output_sample_rate = m_codec_ctx->sample_rate;
+ 	}
+
+-	if (!m_output_channels) {
+-		m_output_channels = m_codec_ctx->channels;
++	AVChannelLayout output_channel_layout;
++	if (m_output_channels) {
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
++	} else {
++		m_output_channels = m_codec_ctx->ch_layout.nb_channels;
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
+ 	}
+
+-	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
++	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->ch_layout.nb_channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
+ 		m_converter.reset(new FFmpegAudioProcessor());
+ 		m_converter->SetCompatibleMode();
+ 		m_converter->SetInputSampleFormat(m_codec_ctx->sample_fmt);
+ 		m_converter->SetInputSampleRate(m_codec_ctx->sample_rate);
+-		m_converter->SetInputChannelLayout(m_codec_ctx->channel_layout);
++		m_converter->SetInputChannelLayout(&(m_codec_ctx->ch_layout));
+ 		m_converter->SetOutputSampleFormat(AV_SAMPLE_FMT_S16);
+ 		m_converter->SetOutputSampleRate(m_output_sample_rate);
+-		m_converter->SetOutputChannelLayout(av_get_default_channel_layout(m_output_channels));
++		m_converter->SetOutputChannelLayout(&output_channel_layout);
+ 		auto ret = m_converter->Init();
+ 		if (ret != 0) {
+ 			SetError("Could not create an audio converter instance", ret);
+@@ -203,10 +203,11 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		}
+ 	}
+
++	av_channel_layout_uninit(&output_channel_layout);
++
+ 	m_opened = true;
+-	m_finished = false;
+-	m_got_frame = 0;
+-	m_nb_packets = 0;
++	m_has_more_packets = true;
++	m_has_more_frames = true;
+ 	m_decode_error = 0;
+
+ 	return true;
+@@ -214,6 +215,7 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ inline void FFmpegAudioReader::Close() {
+ 	av_frame_free(&m_frame);
++	av_packet_free(&m_packet);
+
+ 	m_stream_index = -1;
+
+@@ -252,91 +254,98 @@ inline bool FFmpegAudioReader::Read(const int16_t **data, size_t *size) {
+ 		return false;
+ 	}
+
++	*data = nullptr;
++	*size = 0;
++
+ 	int ret;
++	bool needs_packet = false;
+ 	while (true) {
+-		while (m_packet.size <= 0) {
+-			av_packet_unref(&m_packet0);
+-			av_init_packet(&m_packet);
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			ret = av_read_frame(m_format_ctx, &m_packet);
++		while (needs_packet && m_packet->size == 0) {
++			ret = av_read_frame(m_format_ctx, m_packet);
+ 			if (ret < 0) {
+ 				if (ret == AVERROR_EOF) {
+-					m_finished = true;
++					needs_packet = false;
++					m_has_more_packets = false;
+ 					break;
+-				} else {
++				}
++				SetError("Error reading from the audio source", ret);
++				return false;
++			}
++			if (m_packet->stream_index == m_stream_index) {
++				needs_packet = false;
++			} else {
++				av_packet_unref(m_packet);
++			}
++		}
++
++		if (m_packet->size != 0) {
++			ret = avcodec_send_packet(m_codec_ctx, m_packet);
++			if (ret < 0) {
++				if (ret != AVERROR(EAGAIN)) {
+ 					SetError("Error reading from the audio source", ret);
+ 					return false;
+ 				}
+-			}
+-			m_packet0 = m_packet;
+-			if (m_packet.stream_index != m_stream_index) {
+-				m_packet.data = nullptr;
+-				m_packet.size = 0;
+ 			} else {
+-				m_nb_packets++;
++				av_packet_unref(m_packet);
+ 			}
+ 		}
+
+-		ret = avcodec_decode_audio4(m_codec_ctx, m_frame, &m_got_frame, &m_packet);
++		ret = avcodec_receive_frame(m_codec_ctx, m_frame);
+ 		if (ret < 0) {
+-			if (m_decode_error) {
+-				SetError("Error decoding audio frame", m_decode_error);
+-				return false;
++			if (ret == AVERROR_EOF) {
++				m_has_more_frames = false;
++			} else if (ret == AVERROR(EAGAIN)) {
++				if (m_has_more_packets) {
++					needs_packet = true;
++					continue;
++				} else {
++					m_has_more_frames = false;
++				}
+ 			}
+-			m_decode_error = ret;
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			continue;
++			SetError("Error decoding the audio source", ret);
++			return false;
+ 		}
+
+-		break;
+-	}
+-
+-	m_decode_error = 0;
+-
+-	const int decoded = std::min(ret, m_packet.size);
+-	m_packet.data += decoded;
+-	m_packet.size -= decoded;
+-
+-	if (m_got_frame) {
+-		if (m_converter) {
+-			if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
+-				int linsize;
+-				av_freep(&m_convert_buffer[0]);
+-				m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
+-				ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
+-				if (ret < 0) {
+-					SetError("Couldn't allocate audio converter buffer", ret);
++		if (m_frame->nb_samples > 0) {
++			if (m_converter) {
++				if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
++					int linsize;
++					av_freep(&m_convert_buffer[0]);
++					m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
++					ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->ch_layout.nb_channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
++					if (ret < 0) {
++						SetError("Couldn't allocate audio converter buffer", ret);
++						return false;
++					}
++				}
++				auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
++				if (nb_samples < 0) {
++					SetError("Couldn't convert audio", ret);
+ 					return false;
+ 				}
+-			}
+-			auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			}
+-			*data = (const int16_t *) m_convert_buffer[0];
+-			*size = nb_samples;
+-		} else {
+-			*data = (const int16_t *) m_frame->data[0];
+-			*size = m_frame->nb_samples;
+-		}
+-	} else {
+-		if (m_finished && m_converter) {
+-			auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			} else if (nb_samples > 0) {
+-				m_got_frame = 1;
+ 				*data = (const int16_t *) m_convert_buffer[0];
+ 				*size = nb_samples;
++			} else {
++				*data = (const int16_t *) m_frame->data[0];
++				*size = m_frame->nb_samples;
++			}
++		} else {
++			if (m_converter) {
++				if (IsFinished()) {
++					auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
++					if (nb_samples < 0) {
++						SetError("Couldn't convert audio", ret);
++						return false;
++					} else if (nb_samples > 0) {
++						*data = (const int16_t *) m_convert_buffer[0];
++						*size = nb_samples;
++					}
++				}
+ 			}
+ 		}
+-	}
+
+-	return true;
++		return true;
++	}
+ }
+
+ inline void FFmpegAudioReader::SetError(const char *message, int errnum) {
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index a2b517b..123e643 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -38,6 +38,12 @@ set(SRCS
+
+ if(BUILD_TOOLS)
+ 	set(SRCS ${SRCS} ../src/audio/ffmpeg_audio_reader_test.cpp)
++    include_directories(
++        ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}
++        ${AUDIO_PROCESSOR_INCLUDE_DIRS}
++    )
+ 	link_libraries(fpcalc_libs)
+ endif()
+
+-- 
+2.38.1
+
+
diff --git a/srcpkgs/chromaprint/template b/srcpkgs/chromaprint/template
index 7ef7838949f3a..1f7bbc70a22c8 100644
--- a/srcpkgs/chromaprint/template
+++ b/srcpkgs/chromaprint/template
@@ -1,7 +1,7 @@
 # Template file for 'chromaprint'
 pkgname=chromaprint
 version=1.5.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DBUILD_TOOLS=ON"
 make_check_target="check"

From 7999c86e4cfa6d96144329d698fbecc0efa0b6eb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 021/111] chromium: revbump for ffmpeg6

---
 .../patches/chromium-119-ffmpeg-4.4.patch     | 20 --------
 srcpkgs/chromium/patches/ffmpeg5.patch        | 47 +++++++++++++++++++
 srcpkgs/chromium/template                     |  2 +-
 3 files changed, 48 insertions(+), 21 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch
 create mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch b/srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch
deleted file mode 100644
index 04d04b166ba37..0000000000000
--- a/srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch
+++ /dev/null
@@ -1,20 +0,0 @@
---- a/media/filters/ffmpeg_demuxer.cc.orig
-+++ b/media/filters/ffmpeg_demuxer.cc
-@@ -390,7 +390,7 @@
- 
-   scoped_refptr<DecoderBuffer> buffer;
- 
--    size_t side_data_size = 0;
-+    int side_data_size = 0;
-     uint8_t* side_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
- 
-@@ -453,7 +453,7 @@
-                                        packet->size - data_offset);
-     }
- 
--    size_t skip_samples_size = 0;
-+    int skip_samples_size = 0;
-     const uint32_t* skip_samples_ptr =
-         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
-             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..24e2da38e34ca
--- /dev/null
+++ b/srcpkgs/chromium/patches/ffmpeg5.patch
@@ -0,0 +1,47 @@
+--- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
++++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
+@@ -92,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+-  if (stream->start_time != kNoFFmpegTimestamp)
++  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -1597,7 +1585,7 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+@@ -1618,7 +1606,7 @@
+     if (stream->type() != DemuxerStream::VIDEO)
+       continue;
+ 
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+ 
+     if (!stream->IsEnabled())
diff --git a/srcpkgs/chromium/template b/srcpkgs/chromium/template
index 5613fa3813822..cd386c8a84ae6 100644
--- a/srcpkgs/chromium/template
+++ b/srcpkgs/chromium/template
@@ -2,7 +2,7 @@
 pkgname=chromium
 # See https://chromiumdash.appspot.com/releases?platform=Linux for the latest version
 version=120.0.6099.129
-revision=1
+revision=2
 archs="i686* x86_64* aarch64* armv7l*"
 hostmakedepends="
  $(vopt_if clang "clang lld llvm15")

From 7f23fd0fc886ab5e292619ea9a1943d93b554a6a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 022/111] cmus: revbump for ffmpeg6

---
 srcpkgs/chromium/patches/ffmpeg5.patch | 47 --------------------------
 srcpkgs/cmus/patches/ffmpeg6.patch     | 12 +++++++
 srcpkgs/cmus/template                  |  2 +-
 3 files changed, 13 insertions(+), 48 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch
 create mode 100644 srcpkgs/cmus/patches/ffmpeg6.patch

diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
deleted file mode 100644
index 24e2da38e34ca..0000000000000
--- a/srcpkgs/chromium/patches/ffmpeg5.patch
+++ /dev/null
@@ -1,47 +0,0 @@
---- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
-+++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
-@@ -92,24 +92,12 @@
- 
- static base::TimeDelta ExtractStartTime(AVStream* stream) {
-   // The default start time is zero.
--  base::TimeDelta start_time;
-+  base::TimeDelta start_time = kNoTimestamp;
- 
-   // First try to use  the |start_time| value as is.
--  if (stream->start_time != kNoFFmpegTimestamp)
-+  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
-     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
- 
--  // Next try to use the first DTS value, for codecs where we know PTS == DTS
--  // (excludes all H26x codecs). The start time must be returned in PTS.
--  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
--      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
--      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
--      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
--    const base::TimeDelta first_pts =
--        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
--    if (first_pts < start_time)
--      start_time = first_pts;
--  }
--
-   return start_time;
- }
- 
-@@ -1597,7 +1585,7 @@
-   for (const auto& stream : streams_) {
-     if (!stream || stream->IsEnabled() != enabled)
-       continue;
--    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
-+    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
-       continue;
-     if (!lowest_start_time_stream ||
-         stream->start_time() < lowest_start_time_stream->start_time()) {
-@@ -1618,7 +1606,7 @@
-     if (stream->type() != DemuxerStream::VIDEO)
-       continue;
- 
--    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
-+    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
-       continue;
- 
-     if (!stream->IsEnabled())
diff --git a/srcpkgs/cmus/patches/ffmpeg6.patch b/srcpkgs/cmus/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..ffa95ab811101
--- /dev/null
+++ b/srcpkgs/cmus/patches/ffmpeg6.patch
@@ -0,0 +1,12 @@
+--- a/ip/ffmpeg.c
++++ b/ip/ffmpeg.c
+@@ -202,9 +202,6 @@ static int ffmpeg_open(struct input_plugin_data *ip_data)
+ 			break;
+ 		}
+ 
+-		if (codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+-			cc->flags |= AV_CODEC_FLAG_TRUNCATED;
+-
+ 		if (avcodec_open2(cc, codec, NULL) < 0) {
+ 			d_print("could not open codec: %d, %s\n", cc->codec_id, avcodec_get_name(cc->codec_id));
+ 			err = -IP_ERROR_UNSUPPORTED_FILE_TYPE;
diff --git a/srcpkgs/cmus/template b/srcpkgs/cmus/template
index 0d1436744f1b2..a6e4b4fa86cb8 100644
--- a/srcpkgs/cmus/template
+++ b/srcpkgs/cmus/template
@@ -1,7 +1,7 @@
 # Template file for 'cmus'
 pkgname=cmus
 version=2.10.0
-revision=3
+revision=4
 build_style=configure
 configure_args="prefix=/usr LD=$CC"
 hostmakedepends="pkg-config"

From 127eba389b9148c3e8478b4c84364affacb6e6ca Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 023/111] cyanrip: revbump for ffmpeg6

---
 srcpkgs/cyanrip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cyanrip/template b/srcpkgs/cyanrip/template
index 9796e3461601a..5db30e020d17e 100644
--- a/srcpkgs/cyanrip/template
+++ b/srcpkgs/cyanrip/template
@@ -1,7 +1,7 @@
 # Template file for 'cyanrip'
 pkgname=cyanrip
 version=0.9.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config"
 makedepends="ffmpeg-devel libcdio-devel libcdio-paranoia-devel libcurl-devel libmusicbrainz5-devel"

From 483a40cffb19c49baa4f1ad306fef1bb202dfbdf Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 024/111] deadbeef: revbump for ffmpeg4

---
 srcpkgs/deadbeef/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/deadbeef/template b/srcpkgs/deadbeef/template
index f5f4bf24b8cb6..7b47e615cd48e 100644
--- a/srcpkgs/deadbeef/template
+++ b/srcpkgs/deadbeef/template
@@ -1,14 +1,14 @@
 # Template file for 'deadbeef'
 pkgname=deadbeef
 version=1.8.8
-revision=3
+revision=4
 create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-oss --disable-lfm --disable-notify --disable-gtk2"
 hostmakedepends="automake libtool gettext gettext-devel intltool pkg-config
  yasm clang glib-devel"
 makedepends="
- alsa-lib-devel dbus-devel faad2-devel ffmpeg-devel gtk+3-devel imlib2-devel
+ alsa-lib-devel dbus-devel faad2-devel ffmpeg4-devel gtk+3-devel imlib2-devel
  jansson-devel libcddb-devel libcdio-devel libcurl-devel libflac-devel
  libmad-devel libpng-devel libsamplerate-devel libsndfile-devel libvorbis-devel
  libzip-devel mpg123-devel opusfile-devel pulseaudio-devel wavpack-devel"

From 9ced5fec4c92efe5abcb0d911394bb91b9191f5b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 025/111] droidcam-obs-plugin: revbump for ffmpeg6

---
 srcpkgs/droidcam-obs-plugin/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam-obs-plugin/template b/srcpkgs/droidcam-obs-plugin/template
index fc9c9bf6b9d54..fb0480754df4d 100644
--- a/srcpkgs/droidcam-obs-plugin/template
+++ b/srcpkgs/droidcam-obs-plugin/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam-obs-plugin'
 pkgname=droidcam-obs-plugin
 version=2.0.1
-revision=1
+revision=2
 build_style=gnu-makefile
 make_use_env=yes
 make_build_args="ALLOW_STATIC=no"

From 3c89e184cf82fc9d12a7cf33d0eec0c5edd5b285 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 026/111] droidcam: revbump for ffmpeg6

---
 srcpkgs/droidcam/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam/template b/srcpkgs/droidcam/template
index 1c3f1b8b1fc67..32a9220b79a4d 100644
--- a/srcpkgs/droidcam/template
+++ b/srcpkgs/droidcam/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam'
 pkgname=droidcam
 version=1.8.2
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="USBMUXD=-lusbmuxd-2.0 JPEG=-lturbojpeg"
 hostmakedepends="pkg-config"

From 1a779696a8853e59d94daef78d15d6c187e1d466 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 027/111] ffmpegthumbnailer: revbump for ffmpeg6

---
 .../ffmpegthumbnailer/patches/ffmpeg6.patch   | 202 ++++++++++++++++++
 srcpkgs/ffmpegthumbnailer/template            |   6 +-
 2 files changed, 205 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch

diff --git a/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..363ff35a28419
--- /dev/null
+++ b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
@@ -0,0 +1,202 @@
+--- a/libffmpegthumbnailer/moviedecoder.cpp	2017-11-21 14:06:57.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.cpp	2023-05-05 13:14:47.946560668 -0400
+@@ -41,11 +41,6 @@
+ namespace ffmpegthumbnailer
+ {
+ 
+-struct SilenceLogLevel
+-{
+-    SilenceLogLevel() { av_log_set_level(AV_LOG_QUIET); }
+-};
+-
+ MovieDecoder::MovieDecoder(AVFormatContext* pavContext)
+ : m_VideoStream(-1)
+ , m_pFormatContext(pavContext)
+@@ -70,8 +65,6 @@
+ 
+ void MovieDecoder::initialize(const string& filename, bool preferEmbeddedMetadata)
+ {
+-    av_register_all();
+-    avcodec_register_all();
+     avformat_network_init();
+ 
+     string inputFile = filename == "-" ? "pipe:" : filename;
+@@ -97,8 +90,7 @@
+ {
+     if (m_pVideoCodecContext)
+     {
+-        avcodec_close(m_pVideoCodecContext);
+-        m_pVideoCodecContext = nullptr;
++        avcodec_free_context(&m_pVideoCodecContext);
+     }
+ 
+     if ((!m_FormatContextWasGiven) && m_pFormatContext)
+@@ -152,10 +144,10 @@
+     for (unsigned int i = 0; i < m_pFormatContext->nb_streams; ++i)
+     {
+         AVStream *stream = m_pFormatContext->streams[i];
+-        auto ctx = m_pFormatContext->streams[i]->codec;
+-        if (ctx->codec_type == AVMEDIA_TYPE_VIDEO)
++        auto par = m_pFormatContext->streams[i]->codecpar;
++        if (par->codec_type == AVMEDIA_TYPE_VIDEO)
+         {
+-            if (!preferEmbeddedMetadata || !isStillImageCodec(ctx->codec_id))
++            if (!preferEmbeddedMetadata || !isStillImageCodec(par->codec_id))
+             {
+                 videoStreams.push_back(i);
+                 continue;
+@@ -203,8 +195,7 @@
+     }
+ 
+     m_pVideoStream = m_pFormatContext->streams[m_VideoStream];
+-    m_pVideoCodecContext = m_pVideoStream->codec;
+-    m_pVideoCodec = avcodec_find_decoder(m_pVideoCodecContext->codec_id);
++    m_pVideoCodec = avcodec_find_decoder(m_pVideoStream->codecpar->codec_id);
+ 
+     if (m_pVideoCodec == nullptr)
+     {
+@@ -214,6 +205,20 @@
+         throw logic_error("Video Codec not found");
+     }
+ 
++    m_pVideoCodecContext = avcodec_alloc_context3(m_pVideoCodec);
++
++    if (m_pVideoCodecContext == nullptr)
++    {
++        destroy();
++        throw logic_error("Could not allocate video codec context");
++    }
++
++    if (avcodec_parameters_to_context(m_pVideoCodecContext, m_pVideoStream->codecpar) < 0)
++    {
++        destroy();
++        throw logic_error("Could not configure video codec context");
++    }
++
+     m_pVideoCodecContext->workaround_bugs = 1;
+ 
+     if (avcodec_open2(m_pVideoCodecContext, m_pVideoCodec, nullptr) < 0)
+@@ -386,13 +391,6 @@
+ 
+ void MovieDecoder::initializeFilterGraph(const AVRational& timeBase, const std::string& size, bool maintainAspectRatio)
+ {
+-    static const AVPixelFormat pixelFormats[] = { AV_PIX_FMT_RGB24, AV_PIX_FMT_NONE };
+-
+-    auto del = [] (AVBufferSinkParams* p) { av_freep(p); };
+-    std::unique_ptr<AVBufferSinkParams, decltype(del)> buffersinkParams(av_buffersink_params_alloc(), del);
+-
+-    avfilter_register_all();
+-
+     m_pFilterGraph = avfilter_graph_alloc();
+     assert(m_pFilterGraph);
+ 
+@@ -404,10 +402,8 @@
+ 
+     checkRc(avfilter_graph_create_filter(&m_pFilterSource, avfilter_get_by_name("buffer"), "thumb_buffer", ss.str().c_str(), nullptr, m_pFilterGraph),
+             "Failed to create filter source");
+-    buffersinkParams->pixel_fmts = pixelFormats;
+-    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, buffersinkParams.get(), m_pFilterGraph),
++    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, nullptr, m_pFilterGraph),
+             "Failed to create filter sink");
+-    buffersinkParams.release();
+ 
+     AVFilterContext* yadifFilter = nullptr;
+     if (m_pFrame->interlaced_frame != 0)
+@@ -500,15 +496,15 @@
+     }
+ 
+     checkRc(av_seek_frame(m_pFormatContext, -1, timestamp, 0), "Seeking in video failed");
+-    avcodec_flush_buffers(m_pFormatContext->streams[m_VideoStream]->codec);
++    avcodec_flush_buffers(m_pVideoCodecContext);
+ 
+     int keyFrameAttempts = 0;
+-    bool gotFrame = 0;
++    bool gotFrame;
+ 
+     do
+     {
+         int count = 0;
+-        gotFrame = 0;
++        gotFrame = false;
+ 
+         while (!gotFrame && count < 20)
+         {
+@@ -552,17 +548,33 @@
+         return false;
+     }
+ 
+-    av_frame_unref(m_pFrame);
+-
+-    int frameFinished;
++    int rc = avcodec_send_packet(m_pVideoCodecContext, m_pPacket);
++    if(rc == AVERROR(EAGAIN))
++    {
++        rc = 0;
++    }
+ 
+-    int bytesDecoded = avcodec_decode_video2(m_pVideoCodecContext, m_pFrame, &frameFinished, m_pPacket);
+-    if (bytesDecoded < 0)
++    if(rc == AVERROR_EOF)
++    {
++        return false;
++    }
++    else if(rc < 0)
+     {
+-        throw logic_error("Failed to decode video frame: bytesDecoded < 0");
++        throw logic_error("Failed to decode video frame: avcodec_send_packet() < 0");
+     }
+ 
+-    return frameFinished > 0;
++    rc = avcodec_receive_frame(m_pVideoCodecContext, m_pFrame);
++    switch(rc)
++    {
++        case 0:
++            return true;
++
++        case AVERROR(EAGAIN):
++            return false;
++
++        default:
++            throw logic_error("Failed to decode video frame: avcodec_receive_frame() < 0");
++    }
+ }
+ 
+ bool MovieDecoder::getVideoPacket()
+@@ -570,8 +582,6 @@
+     bool framesAvailable = true;
+     bool frameDecoded = false;
+ 
+-    int attempts = 0;
+-
+     if (m_pPacket)
+     {
+         av_packet_unref(m_pPacket);
+@@ -580,6 +590,7 @@
+ 
+     m_pPacket = new AVPacket();
+ 
++
+     while (framesAvailable && !frameDecoded)
+     {
+         framesAvailable = av_read_frame(m_pFormatContext, m_pPacket) >= 0;
+@@ -644,7 +655,7 @@
+ 
+ int32_t MovieDecoder::getStreamRotation()
+ {
+-    int32_t* matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
++    auto matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
+     if (matrix)
+     {
+         auto angle = lround(av_display_rotation_get(matrix));
+
+--- a/libffmpegthumbnailer/moviedecoder.h	2017-11-12 04:23:38.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.h	2023-05-05 13:26:07.095529911 -0400
+@@ -78,7 +78,7 @@
+     int                     m_VideoStream;
+     AVFormatContext*        m_pFormatContext;
+     AVCodecContext*         m_pVideoCodecContext;
+-    AVCodec*                m_pVideoCodec;
++    const AVCodec*          m_pVideoCodec;
+     AVFilterGraph*          m_pFilterGraph;
+     AVFilterContext*        m_pFilterSource;
+     AVFilterContext*        m_pFilterSink;
diff --git a/srcpkgs/ffmpegthumbnailer/template b/srcpkgs/ffmpegthumbnailer/template
index 039eea7622b39..35d546018d12a 100644
--- a/srcpkgs/ffmpegthumbnailer/template
+++ b/srcpkgs/ffmpegthumbnailer/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbnailer'
 pkgname=ffmpegthumbnailer
 version=2.2.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libpng-devel libjpeg-turbo-devel ffmpeg-devel"
@@ -9,8 +9,8 @@ depends="ffmpeg"
 short_desc="Lightweight video thumbnailer"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
-homepage="https://github.com/dirkvdb/${pkgname}"
-distfiles="${homepage}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
+homepage="https://github.com/dirkvdb"
+distfiles="${homepage}/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
 checksum=1cb24059c38223f657b300c84dd80491b7040d4b69471c4fea69be862bc99b5b
 
 post_install() {

From fc5e45c2ced2a7bf5f783292e97c7e4c164bc1c6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 028/111] ffmpegthumbs: revbump for ffmpeg6

---
 srcpkgs/ffmpegthumbs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ffmpegthumbs/template b/srcpkgs/ffmpegthumbs/template
index 5f0b9414dadaf..11b88193528f4 100644
--- a/srcpkgs/ffmpegthumbs/template
+++ b/srcpkgs/ffmpegthumbs/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbs'
 pkgname=ffmpegthumbs
 version=22.12.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules kcoreaddons kconfig-devel
  pkg-config qt5-host-tools qt5-qmake gettext"

From bd3035d591000ecd42e86bd48c984cec4cbf32e6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 029/111] ffms2: revbump for ffmpeg6

---
 srcpkgs/ffms2/patches/ffmpeg5.patch | 424 ++++++++++++++++++++++++++++
 srcpkgs/ffms2/template              |   2 +-
 2 files changed, 425 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ffms2/patches/ffmpeg5.patch

diff --git a/srcpkgs/ffms2/patches/ffmpeg5.patch b/srcpkgs/ffms2/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..1479fabcafcb4
--- /dev/null
+++ b/srcpkgs/ffms2/patches/ffmpeg5.patch
@@ -0,0 +1,424 @@
+From 45673149e9a2f5586855ad472e3059084eaa36b1 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:41:21 +0100
+Subject: [PATCH] Use auto for AVCodec
+
+The geniuses over at FFmpeg decided to constify this API, so old
+versions of the library will return AVCodec *, while new versions
+of the libary will return const AVCodec *, which, in C++, are not
+OK to convert between.
+
+Rather than use some macro hell in ffmscompat.h, we can work around
+this by using auto.
+
+Gross.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 2 +-
+ src/core/indexing.cpp    | 6 +++---
+ src/core/videosource.cpp | 2 +-
+ 3 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index e4ce97c..ac09666 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -469,7 +469,7 @@ void FFMS_AudioSource::OpenFile() {
+ 
+     LAVFOpenFile(SourceFile.c_str(), FormatContext, TrackNumber);
+ 
+-    AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
++    auto *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
+     if (Codec == nullptr)
+         throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+             "Audio codec not found");
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index e547c5a..59fb4e8 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -384,7 +384,7 @@ FFMS_TrackType FFMS_Indexer::GetTrackType(int Track) {
+ }
+ 
+ const char *FFMS_Indexer::GetTrackCodec(int Track) {
+-    AVCodec *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
++    auto *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
+     return codec ? codec->name : nullptr;
+ }
+ 
+@@ -402,7 +402,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             UseDTS);
+ 
+         if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            AVCodec *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (!VideoCodec) {
+                 FormatContext->streams[i]->discard = AVDISCARD_ALL;
+                 IndexMask.erase(i);
+@@ -433,7 +433,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 IndexMask.insert(i);
+             }
+         } else if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+-            AVCodec *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (AudioCodec == nullptr)
+                 throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_UNSUPPORTED,
+                     "Audio codec not found");
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index b889970..8956c22 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -171,7 +171,7 @@ FFMS_VideoSource::FFMS_VideoSource(const char *SourceFile, FFMS_Index &Index, in
+ 
+         LAVFOpenFile(SourceFile, FormatContext, VideoTrack);
+ 
+-        AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
++        auto *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
+         if (Codec == nullptr)
+             throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+                 "Video codec not found");
+-- 
+2.40.0
+
+From 96cbf38ea9381829a1314f432a2c60495dcefaad Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:12:41 +0100
+Subject: [PATCH] all: Update AVPacket API usage
+
+AVPackets must all be on the heap now, since it is no longer
+part of the libav* ABI.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 16 ++++++----
+ src/core/indexing.cpp    | 63 ++++++++++++++++++++++------------------
+ src/core/indexing.h      |  4 +--
+ src/core/utils.cpp       |  6 ----
+ src/core/utils.h         |  1 -
+ src/core/videosource.cpp | 30 ++++++++++---------
+ 6 files changed, 64 insertions(+), 56 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index 37cf9ae..e4ce97c 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -285,10 +285,15 @@ FFMS_AudioSource::AudioBlock *FFMS_AudioSource::CacheBlock(CacheIterator &pos) {
+ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     CurrentFrame = &Frames[PacketNumber];
+ 
+-    AVPacket Packet;
+-    if (!ReadPacket(&Packet))
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++    if (!ReadPacket(Packet)) {
++        av_packet_free(&Packet);
+         throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_UNKNOWN,
+             "ReadPacket unexpectedly failed to read a packet");
++    }
+ 
+     // ReadPacket may have changed the packet number
+     CurrentFrame = &Frames[PacketNumber];
+@@ -297,8 +302,9 @@ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     int NumberOfSamples = 0;
+     AudioBlock *CachedBlock = nullptr;
+     
+-    int Ret = avcodec_send_packet(CodecContext, &Packet);
+-    av_packet_unref(&Packet);
++    int Ret = avcodec_send_packet(CodecContext, Packet);
++    av_packet_unref(Packet);
++    av_packet_free(&Packet);
+ 
+     av_frame_unref(DecodeFrame);
+     Ret = avcodec_receive_frame(CodecContext, DecodeFrame);
+@@ -513,8 +519,6 @@ void FFMS_AudioSource::Seek() {
+ }
+ 
+ bool FFMS_AudioSource::ReadPacket(AVPacket *Packet) {
+-    InitNullPacket(*Packet);
+-
+     while (av_read_frame(FormatContext, Packet) >= 0) {
+         if (Packet->stream_index == TrackNumber) {
+             // Required because not all audio packets, especially in ogg, have a pts. Use the previous valid packet's pts instead.
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index 23fb95b..e547c5a 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -320,7 +320,7 @@ void FFMS_Indexer::CheckAudioProperties(int Track, AVCodecContext *Context) {
+     }
+ }
+ 
+-void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict,
++void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict,
+                                     int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct) {
+     if (VideoContext.Parser) {
+         uint8_t *OB;
+@@ -330,8 +330,8 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+         av_parser_parse2(VideoContext.Parser,
+             VideoContext.CodecContext,
+             &OB, &OBSize,
+-            pkt.data, pkt.size,
+-            pkt.pts, pkt.dts, pkt.pos);
++            pkt->data, pkt->size,
++            pkt->pts, pkt->dts, pkt->pos);
+ 
+         // H.264 (PAFF) and HEVC may have one field per packet, so we need to track
+         // when we have a full or half frame available, and mark one of them as
+@@ -351,15 +351,15 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+ 
+         *RepeatPict = VideoContext.Parser->repeat_pict;
+         *FrameType = VideoContext.Parser->pict_type;
+-        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt.flags & AV_PKT_FLAG_DISCARD));
++        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt->flags & AV_PKT_FLAG_DISCARD));
+     } else {
+-        *Invisible = !!(pkt.flags & AV_PKT_FLAG_DISCARD);
++        *Invisible = !!(pkt->flags & AV_PKT_FLAG_DISCARD);
+     }
+ 
+     if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP8)
+-        ParseVP8(pkt.data[0], Invisible, FrameType);
++        ParseVP8(pkt->data[0], Invisible, FrameType);
+     else if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP9)
+-        ParseVP9(pkt.data[0], Invisible, FrameType);
++        ParseVP9(pkt->data[0], Invisible, FrameType);
+ }
+ 
+ void FFMS_Indexer::Free() {
+@@ -458,32 +458,36 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+         }
+     }
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
+     std::vector<int64_t> LastValidTS(FormatContext->nb_streams, AV_NOPTS_VALUE);
+ 
+     int64_t filesize = avio_size(FormatContext->pb);
+     enum AVPictureStructure LastPicStruct = AV_PICTURE_STRUCTURE_UNKNOWN;
+-    while (av_read_frame(FormatContext, &Packet) >= 0) {
++    while (av_read_frame(FormatContext, Packet) >= 0) {
+         // Update progress
+         // FormatContext->pb can apparently be NULL when opening images.
+         if (IC && FormatContext->pb) {
+-            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate))
++            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate)) {
++                av_packet_free(&Packet);
+                 throw FFMS_Exception(FFMS_ERROR_CANCELLED, FFMS_ERROR_USER,
+                     "Cancelled by user");
++            }
+         }
+-        if (!IndexMask.count(Packet.stream_index)) {
+-            av_packet_unref(&Packet);
++        if (!IndexMask.count(Packet->stream_index)) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+-        int Track = Packet.stream_index;
++        int Track = Packet->stream_index;
+         FFMS_Track &TrackInfo = (*TrackIndices)[Track];
+-        bool KeyFrame = !!(Packet.flags & AV_PKT_FLAG_KEY);
++        bool KeyFrame = !!(Packet->flags & AV_PKT_FLAG_KEY);
+         ReadTS(Packet, LastValidTS[Track], (*TrackIndices)[Track].UseDTS);
+ 
+         if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            int64_t PTS = TrackInfo.UseDTS ? Packet.dts : Packet.pts;
++            int64_t PTS = TrackInfo.UseDTS ? Packet->dts : Packet->pts;
+             if (PTS == AV_NOPTS_VALUE) {
+                 // VPx alt-refs are output as packets which lack timestmps or durations, since
+                 // they are invisible. Currently, the timestamp mangling code in libavformat
+@@ -495,9 +499,11 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 // FFMS2 currently sorts packets by PTS, which will break decoding, otherwise.
+                 bool HasAltRefs = (FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP8 ||
+                                    FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP9);
+-                if (Packet.duration == 0 && !HasAltRefs)
++                if (Packet->duration == 0 && !HasAltRefs) {
++                    av_packet_free(&Packet);
+                     throw FFMS_Exception(FFMS_ERROR_INDEXING, FFMS_ERROR_PARSER,
+                         "Invalid packet pts, dts, and duration");
++                }
+ 
+                 if (TrackInfo.empty())
+                     PTS = 0;
+@@ -513,7 +519,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             ParseVideoPacket(AVContexts[Track], Packet, &RepeatPict, &FrameType, &Invisible, &LastPicStruct);
+ 
+             TrackInfo.AddVideoFrame(PTS, RepeatPict, KeyFrame,
+-                FrameType, Packet.pos, Invisible);
++                FrameType, Packet->pos, Invisible);
+         } else if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+             // For video seeking timestamps are used only if all packets have
+             // timestamps, while for audio they're used if any have timestamps,
+@@ -522,28 +528,29 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 TrackInfo.HasTS = true;
+ 
+             int64_t StartSample = AVContexts[Track].CurrentSample;
+-            uint32_t SampleCount = IndexAudioPacket(Track, &Packet, AVContexts[Track], *TrackIndices);
++            uint32_t SampleCount = IndexAudioPacket(Track, Packet, AVContexts[Track], *TrackIndices);
+             TrackInfo.SampleRate = AVContexts[Track].CodecContext->sample_rate;
+ 
+             TrackInfo.AddAudioFrame(LastValidTS[Track],
+-                StartSample, SampleCount, KeyFrame, Packet.pos, Packet.flags & AV_PKT_FLAG_DISCARD);
++                StartSample, SampleCount, KeyFrame, Packet->pos, Packet->flags & AV_PKT_FLAG_DISCARD);
+         }
+ 
+-        if (!(Packet.flags & AV_PKT_FLAG_DISCARD))
+-            TrackInfo.LastDuration = Packet.duration;
++        if (!(Packet->flags & AV_PKT_FLAG_DISCARD))
++            TrackInfo.LastDuration = Packet->duration;
+ 
+-        av_packet_unref(&Packet);
++        av_packet_unref(Packet);
+     }
++    av_packet_free(&Packet);
+ 
+     TrackIndices->Finalize(AVContexts, FormatContext->iformat->name);
+     return TrackIndices.release();
+ }
+ 
+-void FFMS_Indexer::ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS) {
+-    if (!UseDTS && Packet.pts != AV_NOPTS_VALUE)
+-        TS = Packet.pts;
++void FFMS_Indexer::ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS) {
++    if (!UseDTS && Packet->pts != AV_NOPTS_VALUE)
++        TS = Packet->pts;
+     if (TS == AV_NOPTS_VALUE)
+         UseDTS = true;
+-    if (UseDTS && Packet.dts != AV_NOPTS_VALUE)
+-        TS = Packet.dts;
++    if (UseDTS && Packet->dts != AV_NOPTS_VALUE)
++        TS = Packet->dts;
+ }
+diff --git a/src/core/indexing.h b/src/core/indexing.h
+index 3cfc3c3..5c06868 100644
+--- a/src/core/indexing.h
++++ b/src/core/indexing.h
+@@ -80,10 +80,10 @@ private:
+     int64_t Filesize;
+     uint8_t Digest[20];
+ 
+-    void ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS);
++    void ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS);
+     void CheckAudioProperties(int Track, AVCodecContext *Context);
+     uint32_t IndexAudioPacket(int Track, AVPacket *Packet, SharedAVContext &Context, FFMS_Index &TrackIndices);
+-    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
++    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
+     void Free();
+ public:
+     FFMS_Indexer(const char *Filename);
+diff --git a/src/core/utils.cpp b/src/core/utils.cpp
+index ce67533..8a2e997 100644
+--- a/src/core/utils.cpp
++++ b/src/core/utils.cpp
+@@ -62,12 +62,6 @@ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo) {
+     }
+ }
+ 
+-void InitNullPacket(AVPacket &pkt) {
+-    av_init_packet(&pkt);
+-    pkt.data = nullptr;
+-    pkt.size = 0;
+-}
+-
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames) {
+     AP.SampleFormat = static_cast<FFMS_SampleFormat>(av_get_packed_sample_fmt(CTX->sample_fmt));
+     AP.BitsPerSample = av_get_bytes_per_sample(CTX->sample_fmt) * 8;
+diff --git a/src/core/utils.h b/src/core/utils.h
+index 9819dc7..003ab79 100644
+--- a/src/core/utils.h
++++ b/src/core/utils.h
+@@ -58,7 +58,6 @@ std::unique_ptr<T> make_unique(Args&&... args) {
+ }
+ 
+ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo);
+-void InitNullPacket(AVPacket &pkt);
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames);
+ 
+ void LAVFOpenFile(const char *SourceFile, AVFormatContext *&FormatContext, int Track);
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index 06bd161..b889970 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -673,30 +673,34 @@ void FFMS_VideoSource::DecodeNextFrame(int64_t &AStartTime, int64_t &Pos) {
+     if (HasPendingDelayedFrames())
+         return;
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
+-
+-    while (ReadFrame(&Packet) >= 0) {
+-        if (Packet.stream_index != VideoTrack) {
+-            av_packet_unref(&Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++
++    while (ReadFrame(Packet) >= 0) {
++        if (Packet->stream_index != VideoTrack) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+         if (AStartTime < 0)
+-            AStartTime = Frames.UseDTS ? Packet.dts : Packet.pts;
++            AStartTime = Frames.UseDTS ? Packet->dts : Packet->pts;
+ 
+         if (Pos < 0)
+-            Pos = Packet.pos;
++            Pos = Packet->pos;
+ 
+-        bool FrameFinished = DecodePacket(&Packet);
+-        av_packet_unref(&Packet);
+-        if (FrameFinished)
++        bool FrameFinished = DecodePacket(Packet);
++        av_packet_unref(Packet);
++        if (FrameFinished) {
++            av_packet_free(&Packet);
+             return;
++        }
+     }
+ 
+     // Flush final frames
+-    InitNullPacket(Packet);
+-    DecodePacket(&Packet);
++    DecodePacket(Packet);
++    av_packet_free(&Packet);
+ }
+ 
+ bool FFMS_VideoSource::SeekTo(int n, int SeekOffset) {
+-- 
+2.40.0
+
+From bf9e03e9e08534c024e5a744a6437c4aac160201 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:20:47 +0100
+Subject: [PATCH 2/3] configure: Remove deprecated API use
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ configure.ac | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index b35ef80bc..d19714d0f 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -102,10 +102,10 @@ CFLAGS="$_CFLAGS $FFMPEG_CFLAGS"
+
+ AC_DEFUN([TEST_FFMPEG],
+          [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+-            #include <libavcodec/avcodec.h>
++            #include <libavformat/avformat.h>
+             #include <libswscale/swscale.h>
+             ]],[[
+-                avcodec_register_all();
++                avformat_network_init();
+                 swscale_version();
+             ]])], [eval $1=yes], [eval $1=no])
+         ])
+
diff --git a/srcpkgs/ffms2/template b/srcpkgs/ffms2/template
index 365f64d10cbab..1641ecf43be5b 100644
--- a/srcpkgs/ffms2/template
+++ b/srcpkgs/ffms2/template
@@ -1,7 +1,7 @@
 # Template file for 'ffms2'
 pkgname=ffms2
 version=2.40
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-shared --disable-static"
 hostmakedepends="pkg-config autoconf automake libtool"

From 0d77dec4dcd1d0137d9dcb7541793751ce205214 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 030/111] freerdp: revbump for ffmpeg6

---
 .../freerdp/patches/ffmpeg6_aa2cb9aa.patch    | 42 +++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100644 srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch

diff --git a/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
new file mode 100644
index 0000000000000..a4324da3a8822
--- /dev/null
+++ b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
@@ -0,0 +1,42 @@
+From aa2cb9aa5ff5562433598ba168a466e0752bca0e Mon Sep 17 00:00:00 2001
+From: akallabeth <akallabeth@posteo.net>
+Date: Tue, 14 Feb 2023 07:48:54 +0100
+Subject: [PATCH] Fixed #8686: Update h264 to use new FFMPEG API
+
+---
+ channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c | 2 ++
+ libfreerdp/codec/h264_ffmpeg.c            | 2 ++
+ 2 files changed, 4 insertions(+)
+
+diff --git a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+index 339462d865f..beea80b7a1e 100644
+--- a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
++++ b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+@@ -239,8 +239,10 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYP
+ 		}
+ 	}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 	if (mdecoder->codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		mdecoder->codec_context->flags |= AV_CODEC_FLAG_TRUNCATED;
++#endif
+ 
+ 	return TRUE;
+ }
+diff --git a/libfreerdp/codec/h264_ffmpeg.c b/libfreerdp/codec/h264_ffmpeg.c
+index 8a23db2473c..896a333019b 100644
+--- a/libfreerdp/codec/h264_ffmpeg.c
++++ b/libfreerdp/codec/h264_ffmpeg.c
+@@ -615,10 +615,12 @@ static BOOL libavcodec_init(H264_CONTEXT* h264)
+ 			goto EXCEPTION;
+ 		}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 		if (sys->codecDecoder->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		{
+ 			sys->codecDecoderContext->flags |= AV_CODEC_FLAG_TRUNCATED;
+ 		}
++#endif
+ 
+ #ifdef WITH_VAAPI
+ 

From 51239ce4531c2e97357e10a4b7455e04f9333802 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 031/111] gerbera: revbump for ffmpeg6

---
 srcpkgs/gerbera/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gerbera/template b/srcpkgs/gerbera/template
index ae14f35c767c0..2dc0ac0ce03b5 100644
--- a/srcpkgs/gerbera/template
+++ b/srcpkgs/gerbera/template
@@ -1,7 +1,7 @@
 # Template file for 'gerbera'
 pkgname=gerbera
 version=1.12.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_SYSTEMD=0 -DWITH_AVCODEC=1"
 hostmakedepends="pkg-config"

From 6819de65ba58bc9bcd059841a6d0e95b917c3e57 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 032/111] goldendict: revbump for ffmpeg6

---
 srcpkgs/goldendict/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/goldendict/template b/srcpkgs/goldendict/template
index f4a05759f693d..97f44347b03a6 100644
--- a/srcpkgs/goldendict/template
+++ b/srcpkgs/goldendict/template
@@ -1,7 +1,7 @@
 # Template file for 'goldendict'
 pkgname=goldendict
 version=1.5.0
-revision=1
+revision=2
 build_style=qmake
 configure_args="CONFIG+=zim_support goldendict.pro"
 hostmakedepends="qt5-qmake pkg-config qt5-host-tools"
@@ -10,7 +10,7 @@ makedepends="tiff-devel qt5-devel libvorbis-devel zlib-devel
  qt5-webkit-devel lzo-devel bzip2-devel libao-devel qt5-svg-devel
  libeb-devel qt5-x11extras-devel ffmpeg-devel liblzma-devel
  qt5-multimedia-devel"
-short_desc="A feature-rich dictionary lookup program"
+short_desc="Feature-rich dictionary lookup program"
 maintainer="John <me@johnnynator.dev>"
 license="GPL-3.0-or-later"
 homepage="http://goldendict.org/"

From 1f5c2000647a446db3b028e08512db209a9b5f37 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 033/111] gst-libav: revbump for ffmpeg6

---
 srcpkgs/gst-libav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index b24be23fc1a6d..0f9350a251bf6 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.22.9
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"

From 63fd42c7e7e15218469c7b7698e2e3aed6690f74 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 034/111] gst-rtsp-server: revbump for ffmpeg6

---
 srcpkgs/gst-rtsp-server/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index bc2a0dea6ac15..f77026c618eb6 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
 version=1.22.9
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="glib-devel gst-plugins-bad1-devel gobject-introspection

From ca185f5adcdd033360ffca3a32b7439e7462dbf5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 035/111] guvcview: update to 2.0.8.

---
 srcpkgs/guvcview/patches/fix-include.patch | 10 ++++++++++
 srcpkgs/guvcview/template                  |  7 +++----
 2 files changed, 13 insertions(+), 4 deletions(-)
 create mode 100644 srcpkgs/guvcview/patches/fix-include.patch

diff --git a/srcpkgs/guvcview/patches/fix-include.patch b/srcpkgs/guvcview/patches/fix-include.patch
new file mode 100644
index 0000000000000..503c2af3b78c1
--- /dev/null
+++ b/srcpkgs/guvcview/patches/fix-include.patch
@@ -0,0 +1,10 @@
+--- a/guvcview/guvcview.c
++++ b/guvcview/guvcview.c
+@@ -28,6 +28,7 @@
+ #include <sys/stat.h>
+ #include <sys/resource.h>
+ #include <errno.h>
++#include <locale.h>
+ 
+ #include "gview.h"
+ #include "gviewv4l2core.h"
diff --git a/srcpkgs/guvcview/template b/srcpkgs/guvcview/template
index d42fd38fa4ad1..86a7fd619612c 100644
--- a/srcpkgs/guvcview/template
+++ b/srcpkgs/guvcview/template
@@ -1,8 +1,7 @@
 # Template file for 'guvcview'
 pkgname=guvcview
-version=2.0.7
-revision=2
-create_wrksrc=yes
+version=2.0.8
+revision=1
 build_style=gnu-configure
 configure_args="--disable-static --disable-debian-menu"
 hostmakedepends="pkg-config intltool autoconf automake libtool glib-devel"
@@ -14,7 +13,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="http://guvcview.sourceforge.net/"
 distfiles="${SOURCEFORGE_SITE}/${pkgname}/${pkgname}-src-${version}.tar.bz2"
-checksum=f47d51fbd06e44eeaa1a82f4a153c927527c90d94514197a70b2956028cc8ad4
+checksum=a21f4e448286666cf27bafef5290cc953a0a1796b752e5bbe521266dc1230c81
 
 post_patch() {
 	sed '31a#include <locale.h>' -i  guvcview/guvcview.c

From ea934b880583029274ad6c47a8ba09ee24ed8083 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 036/111] handbrake: update to 1.6.1

---
 .../patches/fix-missing-x265-link-flag.patch    | 11 ++++++-----
 .../handbrake/patches/libhb-vpl-include.patch   | 15 +++++++++++++++
 srcpkgs/handbrake/template                      | 17 ++++++++++-------
 3 files changed, 31 insertions(+), 12 deletions(-)
 create mode 100644 srcpkgs/handbrake/patches/libhb-vpl-include.patch

diff --git a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
index 26db03867a0c8..d6bb2eda627a3 100644
--- a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
+++ b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
@@ -1,14 +1,15 @@
 --- a/gtk/configure.ac
 +++ b/gtk/configure.ac
 @@ -203,7 +203,7 @@
- 
+
  AM_CONDITIONAL([MINGW], [test "x$mingw_flag" = "xyes"])
- 
--HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg"
-+HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -ldl"
+
+-HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc"
++HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc -ldl"
  HB_CPPFLAGS="$HB_CPPFLAGS $HBINC"
- 
+
  PKG_CHECK_MODULES([x264], [x264], sys_x264=yes, sys_x264=no)
+
 --- a/test/module.defs
 +++ b/test/module.defs
 @@ -69,6 +69,9 @@
diff --git a/srcpkgs/handbrake/patches/libhb-vpl-include.patch b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
new file mode 100644
index 0000000000000..298f9f4ab28f2
--- /dev/null
+++ b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
@@ -0,0 +1,15 @@
+--- a/libhb/module.defs	2023-01-22 11:36:49.000000000 -0500
++++ b/libhb/module.defs	2023-04-03 22:37:52.395467010 -0400
+@@ -46,11 +46,7 @@
+ LIBHB.GCC.I += $(LIBHB.build/) $(CONTRIB.build/)include
+ 
+ ifeq (1,$(FEATURE.qsv))
+-    ifeq ($(HOST.system),freebsd))
+-        LIBHB.GCC.I += $(LOCALBASE)/include/vpl
+-    else
+-        LIBHB.GCC.I += $(CONTRIB.build/)include/vpl
+-    endif
++    LIBHB.GCC.I += /usr/include/vpl
+ endif
+ 
+ ifneq (,$(filter $(HOST.system),freebsd netbsd openbsd))
diff --git a/srcpkgs/handbrake/template b/srcpkgs/handbrake/template
index ca5e4571e49c3..c32cb1bfa31f4 100644
--- a/srcpkgs/handbrake/template
+++ b/srcpkgs/handbrake/template
@@ -1,10 +1,10 @@
 # Template file for 'handbrake'
 pkgname=handbrake
-version=1.5.1
+version=1.6.1
 revision=1
 build_style=gnu-configure
 configure_args="--force --disable-gtk-update-checks --disable-df-fetch --harden
- $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc)"
+ $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc) $(vopt_enable qsv)"
 make_build_args="-C ${XBPS_TRIPLET}"
 make_install_args="-C ${XBPS_TRIPLET}"
 hostmakedepends="automake cmake gettext-devel glib-devel intltool libtool m4 meson nasm pkg-config python3"
@@ -12,8 +12,11 @@ makedepends="bzip2-devel ffmpeg-devel gst-plugins-base1-devel gtk+3-devel
  jansson-devel lame-devel libass-devel libbluray-devel libdav1d-devel
  libdvdnav-devel libdvdread-devel libgudev-devel libnuma-devel
  libsamplerate-devel libtheora-devel libvorbis-devel libvpx-devel libxml2-devel
- opus-devel speex-devel x264-devel x265-devel zimg-devel
+ opus-devel speex-devel x264-devel x265-devel zimg-devel libsvt-av1-devel
  $(vopt_if fdk_aac fdk-aac-devel)
+ $(vopt_if qsv libva-devel)
+ $(vopt_if qsv libdrm-devel)
+ $(vopt_if qsv onevpl-devel)
  $(vopt_if nvenc nv-codec-headers)"
 depends="desktop-file-utils gst-plugins-good1 hicolor-icon-theme"
 short_desc="Multithreaded video transcoder"
@@ -21,15 +24,15 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-2.0-only"
 homepage="https://handbrake.fr/"
 distfiles="https://github.com/HandBrake/HandBrake/releases/download/${version}/HandBrake-${version}-source.tar.bz2"
-checksum=3999fe06d5309c819799a73a968a8ec3840e7840c2b64af8f5cdb7fd8c9430f0
+checksum=94ccfe03db917a91650000c510f7fd53f844da19f19ad4b4be1b8f6bc31a8d4c
 nocross=yes
 
-build_options="fdk_aac nvenc"
+build_options="fdk_aac nvenc qsv"
 
 case "$XBPS_TARGET_MACHINE" in
 	x86_64*|i686*)
 		CFLAGS="-msse"
-		build_options_default="nvenc"
+		build_options_default="nvenc qsv"
 		;;
 esac
 
@@ -37,7 +40,7 @@ pre_configure() {
 	# use system libraries, don't download them
 	rm -rf contrib/
 	for module in fdk-aac ffmpeg libbluray libdav1d libdvdnav libdvdread nvenc \
-		x265 zimg; do
+		x265 zimg svt-av1 libvpl; do
 	    vsed -i "/MODULES += contrib\/${module}/d" make/include/main.defs
 	done
 }

From 5185fed39ed3bedd44efd7694157de9dbb7c9bd5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 037/111] hedgewars: revbump for ffmpeg4

---
 srcpkgs/hedgewars/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/hedgewars/template b/srcpkgs/hedgewars/template
index 94b6db673b0c3..402ccfaaecbc2 100644
--- a/srcpkgs/hedgewars/template
+++ b/srcpkgs/hedgewars/template
@@ -1,13 +1,13 @@
 # Template file for 'hedgewars'
 pkgname=hedgewars
 version=1.0.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DNOSERVER=1 -DDATA_INSTALL_DIR=/usr/share/${pkgname}
  -DPHYSFS_SYSTEM=1 -DMINIMAL_FLAGS=1"
 make_cmd=make
 hostmakedepends="lua51 pkg-config qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
+makedepends="ffmpeg4-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
  SDL2_mixer-devel SDL2_net-devel SDL2_ttf-devel"
 depends="libfreeglut"
 short_desc="Funny turn-based artillery game, featuring fighting Hedgehogs!"

From 7564f6b5b51c5c4db49cd9456900171424f4bc59 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 038/111] idjc: revbump for ffmpeg4

---
 srcpkgs/idjc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/idjc/template b/srcpkgs/idjc/template
index a9cde0665d55b..6f1d21c5781fd 100644
--- a/srcpkgs/idjc/template
+++ b/srcpkgs/idjc/template
@@ -5,7 +5,7 @@ revision=5
 build_style=gnu-configure
 hostmakedepends="pkg-config git python3 automake gettext-devel libtool"
 makedepends="libvorbis-devel libogg-devel jack-devel libsamplerate-devel
- libflac-devel libsndfile-devel mpg123-devel ffmpeg-devel speex-devel
+ libflac-devel libsndfile-devel mpg123-devel ffmpeg4-devel speex-devel
  glib-devel pixman-devel lame-devel python3-gobject-devel libshout-idjc-devel
  opus-devel twolame-devel python3-mutagen python3-devel"
 depends="python3-gobject python3-mutagen desktop-file-utils shared-mime-info python3-dbus jack"

From 9108c8d4ddeb130305ea891b98828761d5a230e8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 039/111] kid3: revbump for ffmpeg6

---
 srcpkgs/kid3/patches/ffmpeg5.patch | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 srcpkgs/kid3/patches/ffmpeg5.patch

diff --git a/srcpkgs/kid3/patches/ffmpeg5.patch b/srcpkgs/kid3/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..135fc50e07c9b
--- /dev/null
+++ b/srcpkgs/kid3/patches/ffmpeg5.patch
@@ -0,0 +1,17 @@
+# https://aur.archlinux.org/cgit/aur.git/diff/ffmpeg5.patch?h=kid3-cli&id=12410a74906612e7efc0ec8fbce739b4a0fef7e7
+diff --git a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+index e156d424..e12b9abd 100644
+--- a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
++++ b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+@@ -232,7 +232,11 @@ private:
+   friend class Format;
+   friend class Converter;
+   AVCodecContext* m_ptr;
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 0, 0)
+   AVCodec* m_impl;
++#else
++  const AVCodec* m_impl;
++#endif
+   AVFrame* m_frame;
+   bool m_opened;
+ };

From 7e0312d12144a71722af8d3b6378ec56172a42fe Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 040/111] kodi: revbump for ffmpeg4

---
 srcpkgs/kodi/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kodi/template b/srcpkgs/kodi/template
index d37a5918cd675..536ee1fc83a7d 100644
--- a/srcpkgs/kodi/template
+++ b/srcpkgs/kodi/template
@@ -54,7 +54,7 @@ makedepends="
  libmad-devel fontconfig-devel libXinerama-devel libsamplerate-devel libmms-devel
  enca-devel boost-devel libcurl-devel libva-devel libvdpau-devel libass-devel
  libbluetooth-devel yajl-devel libplist-devel librtmp-devel tinyxml-devel
- taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg-devel
+ taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg4-devel
  giflib-devel libxslt-devel gnutls-devel libssh-devel libmicrohttpd-devel
  libcec-devel dcadec-devel flatbuffers-devel fmt-devel lcms2-devel
  libfstrcmp-devel rapidjson libcdio-paranoia spdlog libwaylandpp-devel

From abfa3a0a4aaf463a97e94f4890bad5461b28b5d5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 041/111] kpipewire: revbump for ffmpeg6

---
 srcpkgs/kpipewire/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kpipewire/template b/srcpkgs/kpipewire/template
index 6214a4451336e..3555348659dde 100644
--- a/srcpkgs/kpipewire/template
+++ b/srcpkgs/kpipewire/template
@@ -1,7 +1,7 @@
 # Template file for 'kpipewire'
 pkgname=kpipewire
 version=5.27.10
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules plasma-wayland-protocols gettext
  qt5-qmake qt5-host-tools pkg-config wayland-devel kcoreaddons

From 1c215f67113808eaf0ea4c914509da16a1ddd701 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 042/111] libextractor: revbump for ffmpeg4

---
 srcpkgs/libextractor/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libextractor/template b/srcpkgs/libextractor/template
index 044c663a3a0b9..ace88ae128da5 100644
--- a/srcpkgs/libextractor/template
+++ b/srcpkgs/libextractor/template
@@ -7,7 +7,7 @@ configure_args="--disable-static"
 hostmakedepends="pkg-config"
 makedepends="zlib-devel bzip2-devel exiv2-devel tiff-devel libpng-devel
  libjpeg-turbo-devel libvorbis-devel libflac-devel giflib-devel libmpeg2-devel
- ffmpeg-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
+ ffmpeg4-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
 short_desc="Library used to extract meta data from files"
 maintainer="Martin Riese <grauehaare@gmx.de>"
 license="GPL-3.0-or-later"

From d6fb6b1283df23676783528292f280725f90f71e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 043/111] libopenal: revbump for ffmpeg6

---
 srcpkgs/libopenal/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenal/template b/srcpkgs/libopenal/template
index 88d0f11307d81..8308fca0393e3 100644
--- a/srcpkgs/libopenal/template
+++ b/srcpkgs/libopenal/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenal'
 pkgname=libopenal
 version=1.23.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DALSOFT_EXAMPLES=OFF"
 hostmakedepends="pkg-config"

From a261cc2f3e773ef63eb9f4887e53dcf499bc8772 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 044/111] loudgain: revbump for ffmpeg6

---
 srcpkgs/loudgain/patches/ffmpeg5.patch | 11 +++++++++++
 srcpkgs/loudgain/template              |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/loudgain/patches/ffmpeg5.patch

diff --git a/srcpkgs/loudgain/patches/ffmpeg5.patch b/srcpkgs/loudgain/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..16d4510ee98fa
--- /dev/null
+++ b/srcpkgs/loudgain/patches/ffmpeg5.patch
@@ -0,0 +1,11 @@
+--- a/src/scan.c	2019-09-06 11:31:19.000000000 -0400
++++ b/src/scan.c	2023-03-23 11:15:40.867968521 -0400
+@@ -69,8 +69,6 @@
+ 	 * It is now useless
+ 	 * https://github.com/FFmpeg/FFmpeg/blob/70d25268c21cbee5f08304da95be1f647c630c15/doc/APIchanges#L86
+ 	 */
+-  if (avformat_version() < AV_VERSION_INT(58,9,100))
+-    av_register_all();
+ 
+ 	av_log_set_callback(scan_av_log);
+ 
diff --git a/srcpkgs/loudgain/template b/srcpkgs/loudgain/template
index da4f2d56e94c3..4d6bf29efb4fd 100644
--- a/srcpkgs/loudgain/template
+++ b/srcpkgs/loudgain/template
@@ -1,7 +1,7 @@
 # Template file for 'loudgain'
 pkgname=loudgain
 version=0.6.8
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libebur128-devel taglib-devel ffmpeg-devel"

From 883d689bb0c35ce3fbc64fb6eaeb33b47f02348e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 045/111] mediastreamer: revbump for ffmpeg4

---
 srcpkgs/mediastreamer/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mediastreamer/template b/srcpkgs/mediastreamer/template
index 0fcffa7653d18..92ada88743a9b 100644
--- a/srcpkgs/mediastreamer/template
+++ b/srcpkgs/mediastreamer/template
@@ -5,7 +5,7 @@ revision=2
 build_style=cmake
 configure_args="-DENABLE_STRICT=0 -DENABLE_UNIT_TESTS=0"
 hostmakedepends="python3"
-makedepends="bzrtp-devel ffmpeg-devel glew-devel libXv-devel libsrtp-devel
+makedepends="bzrtp-devel ffmpeg4-devel glew-devel libXv-devel libsrtp-devel
  libupnp-devel libvpx-devel mbedtls-devel opus-devel ortp-devel pulseaudio-devel
  libtheora-devel speex-devel v4l-utils-devel bcg729-devel bcmatroska2-devel libgsm-devel
  zxing-cpp-devel"

From 880f95e509eba4ea4e25796c47ecb4cddf5ecad6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 046/111] mgba: revbump for ffmpeg6

---
 srcpkgs/mgba/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mgba/template b/srcpkgs/mgba/template
index 6cd6565031254..93401adb618bd 100644
--- a/srcpkgs/mgba/template
+++ b/srcpkgs/mgba/template
@@ -1,7 +1,7 @@
 # Template file for 'mgba'
 pkgname=mgba
 version=0.10.3
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake desktop-file-utils"
 makedepends="SDL2-devel ffmpeg-devel libedit-devel libepoxy-devel libmagick-devel

From 32c24ee33e01c372eb8d86251c943fee28a36c95 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 047/111] mlt: revbump for ffmpeg4

---
 srcpkgs/mlt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mlt/template b/srcpkgs/mlt/template
index 73e3915aaab9a..ec5054be3b75e 100644
--- a/srcpkgs/mlt/template
+++ b/srcpkgs/mlt/template
@@ -8,7 +8,7 @@ configure_args="--prefix=/usr --libdir=/usr/lib$XBPS_TARGET_WORDSIZE
  --swig-languages=python"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which"
 # XXX: movit vid.stab
-makedepends="alsa-lib-devel ffmpeg-devel gtk+-devel jack-devel ladspa-sdk
+makedepends="alsa-lib-devel ffmpeg4-devel gtk+-devel jack-devel ladspa-sdk
  libexif-devel libsamplerate-devel libxml2-devel sox-devel SDL_image-devel
  fftw-devel frei0r-plugins python3-devel pulseaudio-devel movit-devel
  libvidstab-devel"

From c649419595e22b47b36e21cbe30734b3d1b873f2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 048/111] moc: revbump for ffmpeg4

---
 srcpkgs/moc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/moc/template b/srcpkgs/moc/template
index 3a04932c8f1e6..d8de816026b64 100644
--- a/srcpkgs/moc/template
+++ b/srcpkgs/moc/template
@@ -4,7 +4,7 @@ version=2.5.2
 revision=7
 build_style=gnu-configure
 hostmakedepends="pkg-config"
-makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg-devel
+makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg4-devel
  jack-devel alsa-lib-devel libltdl-devel libflac-devel libvorbis-devel
  libmad-devel libmpcdec-devel libmodplug-devel libid3tag-devel faad2-devel
  taglib-devel libsndfile-devel wavpack-devel speex-devel libsamplerate-devel

From 97ef0e49c55344c1cd9b255dfbf1f1e5c1cdcc0a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 049/111] motion: revbump for ffmpeg6

---
 srcpkgs/motion/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/motion/template b/srcpkgs/motion/template
index 607ebeb3c7b24..bf63a91d9764f 100644
--- a/srcpkgs/motion/template
+++ b/srcpkgs/motion/template
@@ -1,7 +1,7 @@
 # Template file for 'motion'
 pkgname=motion
 version=4.6.0
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake pkg-config gettext-devel tar"
 makedepends="ffmpeg-devel libmicrohttpd-devel v4l-utils-devel gettext-devel"

From 15f906b6aa0a17355fc300306ace8da94d3ef98a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 050/111] olive: revbump for ffmpeg4

---
 srcpkgs/olive/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/olive/template b/srcpkgs/olive/template
index 12a46936c9900..5c2917b9c5124 100644
--- a/srcpkgs/olive/template
+++ b/srcpkgs/olive/template
@@ -1,10 +1,10 @@
 # Template file for 'olive'
 pkgname=olive
 version=0.1.2
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools pkg-config"
-makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg-devel frei0r-plugins"
+makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg4-devel frei0r-plugins"
 short_desc="Non-linear video editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"

From a4fefba273aaa388849e523653b9110ff01ab24c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 051/111] opentoonz: revbump for ffmpeg6

---
 srcpkgs/opentoonz/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/opentoonz/template b/srcpkgs/opentoonz/template
index ee9f7603f55fd..3e81834ca0edd 100644
--- a/srcpkgs/opentoonz/template
+++ b/srcpkgs/opentoonz/template
@@ -1,7 +1,7 @@
 # Template file for 'opentoonz'
 pkgname=opentoonz
 version=1.6.0
-revision=2
+revision=3
 build_wrksrc="toonz/sources"
 build_style=cmake
 make_cmd=make

From 5115bed89bc648e30b64bf4753d8b5807dafb192 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 052/111] pianobar: revbump for ffmpeg6

---
 srcpkgs/pianobar/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pianobar/template b/srcpkgs/pianobar/template
index e3febb821a451..1e3dc1bf9308e 100644
--- a/srcpkgs/pianobar/template
+++ b/srcpkgs/pianobar/template
@@ -1,7 +1,7 @@
 # Template file for 'pianobar'
 pkgname=pianobar
 version=2022.04.01
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="V=1"
 hostmakedepends="pkg-config"

From 9d1e6d7d0d49f94b7878b8346b7d69a82d06ef8d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 053/111] ppsspp: revbump for ffmpeg4

---
 srcpkgs/ppsspp/template | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/srcpkgs/ppsspp/template b/srcpkgs/ppsspp/template
index 2c0ded496eb98..8bf55f65198cd 100644
--- a/srcpkgs/ppsspp/template
+++ b/srcpkgs/ppsspp/template
@@ -1,7 +1,7 @@
 # Template file for 'ppsspp'
 pkgname=ppsspp
 version=1.16.6
-revision=1
+revision=2
 _glslang_commit=b34f619e1c85810dcb3c578107d2e48ba4ee2b37
 _SPIRV_Cross_commit=4212eef67ed0ca048cb726a6767185504e7695e5
 _armips_commit=7bd1ec93d4586985ba1ef420b43b5e620f68695e
@@ -15,7 +15,7 @@ configure_args="-DHEADLESS=1 -DUSE_SYSTEM_FFMPEG=1 -DUNITTEST=ON
  -DUSING_QT_UI=$(vopt_if qt ON OFF) -DUSE_SYSTEM_ZSTD=ON
  -DARMIPS_USE_STD_FILESYSTEM=ON"
 hostmakedepends="pkg-config python3 $(vopt_if qt qt5-host-tools)"
-makedepends="zlib-devel glew-devel ffmpeg-devel libzip-devel
+makedepends="zlib-devel glew-devel ffmpeg4-devel libzip-devel
  snappy-devel rapidjson libpng-devel libzstd-devel
  $(vopt_if sdl2 'SDL2_ttf-devel SDL2-devel') $(vopt_if wayland wayland-devel)
  $(vopt_if qt 'qt5-devel qt5-multimedia-devel')"
@@ -69,10 +69,10 @@ post_extract() {
 	rmdir -v ${wrksrc}/ext/cpu_features
 	mv ${wrksrc}/cpu_features-${_cpu_features_commit} ${wrksrc}/ext/cpu_features
 	rmdir -v ${wrksrc}/ext/rcheevos
-        mv ${wrksrc}/rcheevos-${_rcheevos_commit} ${wrksrc}/ext/rcheevos
+	mv ${wrksrc}/rcheevos-${_rcheevos_commit} ${wrksrc}/ext/rcheevos
 }
 
-post_patch(){
+post_patch() {
 	# disable git versioning
 	vsed -e 's|find_package(Git)|# &|' -i git-version.cmake
 }
@@ -85,7 +85,6 @@ post_configure() {
 }
 
 do_install() {
-	vlicense LICENSE.TXT
 	vinstall icons/icon.svg 644 usr/share/pixmaps ppsspp.svg
 	vinstall Qt/PPSSPP.desktop 644 usr/share/applications
 	vbin build/PPSSPPHeadless ppsspp-headless

From 3855539300039b951f678942171205c3805333b7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 054/111] pqiv: revbump for ffmpeg6

---
 srcpkgs/pqiv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pqiv/template b/srcpkgs/pqiv/template
index 542fc27a2d32a..9308d949b6a1c 100644
--- a/srcpkgs/pqiv/template
+++ b/srcpkgs/pqiv/template
@@ -1,7 +1,7 @@
 # Template file for 'pqiv'
 pkgname=pqiv
 version=2.12
-revision=1
+revision=2
 build_style=gnu-makefile
 hostmakedepends="pkg-config"
 makedepends="glib-devel gtk+3-devel $(vopt_if ffmpeg ffmpeg-devel)

From f94b86084f24fc5fd6f670ec7e292163a6ca9d23 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 055/111] qmmp: revbump for ffmpeg6

---
 srcpkgs/qmmp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qmmp/template b/srcpkgs/qmmp/template
index 53781ea3bc28a..2da07f1e87eac 100644
--- a/srcpkgs/qmmp/template
+++ b/srcpkgs/qmmp/template
@@ -1,7 +1,7 @@
 # Template file for 'qmmp'
 pkgname=qmmp
 version=1.6.1
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DUSE_HAL:BOOL=FALSE -DQMMP_DEFAULT_UI:STRING=simple"
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From cae05a1a300209cd92a792403bfcde89040d6fe3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 14 Dec 2023 13:28:10 -0500
Subject: [PATCH 056/111] qt6-pdf: revbump for ffmpeg6

---
 srcpkgs/qt6-pdf/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-pdf/template b/srcpkgs/qt6-pdf/template
index ecda84afac131..531b4e1d4fe84 100644
--- a/srcpkgs/qt6-pdf/template
+++ b/srcpkgs/qt6-pdf/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-pdf'
 pkgname=qt6-pdf
 version=6.6.0
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DQT_FEATURE_qtpdf_build=ON
  -DQT_FEATURE_qtpdf_widgets_build=ON

From cf618838554111d73d116af9ccfd8c0e2ee99774 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 057/111] qt5-webengine: revbump for ffmpeg6

---
 .../chromium-media-filters-cpp14.patch        |  11 ++
 srcpkgs/qt5-webengine/patches/ffmpeg5.patch   | 179 ++++++++++++++++++
 .../qtwebengine-fix-ffmpeg5-build.patch       |  14 ++
 srcpkgs/qt5-webengine/template                |   4 +-
 4 files changed, 206 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/ffmpeg5.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch

diff --git a/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
new file mode 100644
index 0000000000000..04adc540f2cbc
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
@@ -0,0 +1,11 @@
+--- a/src/3rdparty/chromium/media/filters/BUILD.gn	2023-02-27 13:32:59.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/BUILD.gn	2023-04-02 17:21:39.204066384 -0400
+@@ -96,6 +96,8 @@
+     "//ui/gfx/geometry:geometry",
+   ]
+ 
++  cflags_cc = [ "-std=c++14" ]
++
+   libs = []
+ 
+   if (proprietary_codecs) {
diff --git a/srcpkgs/qt5-webengine/patches/ffmpeg5.patch b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..ac55e1634423a
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
@@ -0,0 +1,179 @@
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:57.732547446 -0400
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:09.486478995 -0400
+@@ -57,6 +57,8 @@
+ 
+ namespace {
+ 
++constexpr int64_t kRelativeTsBase = static_cast<int64_t>(0x7ffeffffffffffff);
++
+ void SetAVStreamDiscard(AVStream* stream, AVDiscard discard) {
+   DCHECK(stream);
+   stream->discard = discard;
+@@ -90,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+   if (stream->start_time != kNoFFmpegTimestamp)
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (stream->first_dts != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, stream->first_dts);
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -408,11 +398,11 @@
+   scoped_refptr<DecoderBuffer> buffer;
+ 
+   if (type() == DemuxerStream::TEXT) {
+-    int id_size = 0;
++    size_t id_size = 0;
+     uint8_t* id_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
+ 
+-    int settings_size = 0;
++    size_t settings_size = 0;
+     uint8_t* settings_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
+ 
+@@ -424,7 +414,7 @@
+     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
+                                      side_data.data(), side_data.size());
+   } else {
+-    int side_data_size = 0;
++    size_t side_data_size = 0;
+     uint8_t* side_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
+ 
+@@ -485,7 +475,7 @@
+                                        packet->size - data_offset);
+     }
+ 
+-    int skip_samples_size = 0;
++    size_t skip_samples_size = 0;
+     const uint32_t* skip_samples_ptr =
+         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
+             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
+@@ -1587,6 +1577,8 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++      continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+       lowest_start_time_stream = stream.get();
+@@ -1604,6 +1596,8 @@
+     if (stream && stream->type() == DemuxerStream::VIDEO &&
+         stream->IsEnabled()) {
+       video_stream = stream.get();
++      if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++        continue;
+       if (video_stream->start_time() <= seek_time) {
+         return video_stream;
+       }
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h qtwebengine-5.15.10/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h
+--- a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-07-11 22:12:47.917192788 -0500
+@@ -29,6 +29,7 @@ extern "C" {
+ #include <libavformat/avformat.h>
+ #include <libavformat/avio.h>
+ #include <libavutil/avutil.h>
++#include <libavutil/channel_layout.h>
+ #include <libavutil/imgutils.h>
+ #include <libavutil/log.h>
+ #include <libavutil/mastering_display_metadata.h>
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/audio_file_reader.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/audio_file_reader.cc
+--- a/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -85,7 +85,7 @@ bool AudioFileReader::OpenDemuxer() {
+ }
+ 
+ bool AudioFileReader::OpenDecoder() {
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (codec) {
+     // MP3 decodes to S16P which we don't support, tell it to use S16 instead.
+     if (codec_context_->sample_fmt == AV_SAMPLE_FMT_S16P)
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -329,7 +329,7 @@ bool FFmpegAudioDecoder::ConfigureDecode
+     }
+   }
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec ||
+       avcodec_open2(codec_context_.get(), codec, &codec_options) < 0) {
+     DLOG(ERROR) << "Could not initialize audio decoder: "
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -59,7 +59,6 @@ static int64_t AVIOSeekOperation(void* o
+ }
+ 
+ void FFmpegGlue::InitializeFFmpeg() {
+-  av_register_all();
+ }
+ 
+ static void LogContainer(bool is_local_file,
+@@ -95,9 +94,6 @@ FFmpegGlue::FFmpegGlue(FFmpegURLProtocol
+   // Enable fast, but inaccurate seeks for MP3.
+   format_context_->flags |= AVFMT_FLAG_FAST_SEEK;
+ 
+-  // Ensures we can read out various metadata bits like vp8 alpha.
+-  format_context_->flags |= AVFMT_FLAG_KEEP_SIDE_DATA;
+-
+   // Ensures format parsing errors will bail out. From an audit on 11/2017, all
+   // instances were real failures. Solves bugs like http://crbug.com/710791.
+   format_context_->error_recognition |= AV_EF_EXPLODE;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -391,7 +391,7 @@ bool FFmpegVideoDecoder::ConfigureDecode
+   if (decode_nalus_)
+     codec_context_->flags2 |= AV_CODEC_FLAG2_CHUNKS;
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
+     ReleaseFFmpegResources();
+     return false;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/media_file_checker.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/media_file_checker.cc
+--- a/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -68,7 +68,7 @@ bool MediaFileChecker::Start(base::TimeD
+       auto context = AVStreamToAVCodecContext(format_context->streams[i]);
+       if (!context)
+         continue;
+-      AVCodec* codec = avcodec_find_decoder(cp->codec_id);
++      const AVCodec* codec = avcodec_find_decoder(cp->codec_id);
+       if (codec && avcodec_open2(context.get(), codec, nullptr) >= 0) {
+         auto loop = std::make_unique<FFmpegDecodingLoop>(context.get());
+         stream_contexts[i] = {std::move(context), std::move(loop)};
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc qtwebengine-5.15.10/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc
+--- a/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -203,7 +203,7 @@ int32_t H264DecoderImpl::InitDecode(cons
+   // a pointer |this|.
+   av_context_->opaque = this;
+ 
+-  AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
+   if (!codec) {
+     // This is an indication that FFmpeg has not been initialized or it has not
+     // been compiled/initialized with the correct set of codecs.
diff --git a/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch b/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch
new file mode 100644
index 0000000000000..bc24d5b9a29cb
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch
@@ -0,0 +1,14 @@
+--- a/src/buildtools/configure.json	2023-12-09 11:06:01.503058569 -0500
++++ b/src/buildtools/configure.json	2023-12-09 11:06:14.982361345 -0500
+@@ -779,11 +779,6 @@
+             "type": "warning",
+             "condition": "config.ios && config.simulator && config.device && features.build-qtpdf",
+             "message": "Building fat libray with device and simulator architectures will disable NEON."
+-        },
+-        {
+-            "type": "fatal",
+-            "condition": "features.webengine-system-ffmpeg && !libs.webengine-ffmpeg-support",
+-            "message": "Unmodified ffmpeg >= 5.0 is not supported. Please configure with -qt-webengine-ffmpeg."
+         }
+     ],
+     "summary": [
diff --git a/srcpkgs/qt5-webengine/template b/srcpkgs/qt5-webengine/template
index 8d2df1b5175ba..1687a77eb8a2f 100644
--- a/srcpkgs/qt5-webengine/template
+++ b/srcpkgs/qt5-webengine/template
@@ -1,14 +1,14 @@
 # Template file for 'qt5-webengine'
 pkgname=qt5-webengine
 version=5.15.16
-revision=1
+revision=2
 _version="${version}-lts"
 _chromium_commit=207c2ac45ca3386d153770c6b0d2ea2ec21ca880
 archs="x86_64* i686* armv[67]* ppc64* aarch64*"
 create_wrksrc=yes
 build_style=qmake
 configure_args="--
- -webengine-icu -webengine-ffmpeg -webengine-opus -webengine-webp
+ -webengine-icu -system-ffmpeg -webengine-opus -webengine-webp
  -webengine-pepper-plugins -webengine-printing-and-pdf -webengine-proprietary-codecs
  -webengine-pulseaudio -webengine-spellchecker -webengine-webrtc -webengine-geolocation
  -webengine-kerberos -no-webengine-embedded-build $(vopt_if sndio '' '-no')-webengine-sndio

From dd5cd5814164c51166acbf5840a2d8b61a652173 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 058/111] qt5: revbump for ffmpeg6

---
 srcpkgs/qt5/template | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/srcpkgs/qt5/template b/srcpkgs/qt5/template
index ef6e437e02dbc..97b7818cc37d8 100644
--- a/srcpkgs/qt5/template
+++ b/srcpkgs/qt5/template
@@ -3,9 +3,9 @@
 # revbump libqtxdg after bumping patch version
 pkgname=qt5
 version=5.15.11+20231124
+revision=2
 # commit 4765fa1df7a837db9c1f89c4da0dd76b74bb5fab
 # base repo: https://invent.kde.org/qt/qt/qt5
-revision=1
 build_style=meta
 hostmakedepends="cmake clang flex perl glib-devel pkg-config
  python3 re2c ruby which"
@@ -246,7 +246,6 @@ do_configure() {
 	# opts+=" -v"
 	opts+=" -skip qtwebengine"
 	opts+=" -skip qtwebview"
-	opts+=" -skip qtdocgallery"
 	opts+=" -skip qtpim"
 	opts+=" -skip qtsystems"
 	opts+=" -skip qtspeech"

From 974e95dc6a6ef7792343f842b077b3355630c8dd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 059/111] qtav: revbump for ffmpeg4

---
 srcpkgs/qtav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qtav/template b/srcpkgs/qtav/template
index 775d5a139a9ef..2d00ad104355e 100644
--- a/srcpkgs/qtav/template
+++ b/srcpkgs/qtav/template
@@ -4,7 +4,7 @@ version=1.13.0
 revision=2
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel libass-devel libopenal-devel
+makedepends="ffmpeg4-devel libass-devel libopenal-devel
  libva-glx-devel libXv-devel pulseaudio-devel
  qt5-declarative-devel qt5-svg-devel
  qt5-quickcontrols"

From 9d48ca3420a0df3da6260f6231c1ccf126e97839 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 060/111] retroarch: revbump for ffmpeg6

---
 srcpkgs/retroarch/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroarch/template b/srcpkgs/retroarch/template
index cb3125c5dbf1a..c65c26f7bf033 100644
--- a/srcpkgs/retroarch/template
+++ b/srcpkgs/retroarch/template
@@ -1,7 +1,7 @@
 # Template file for 'retroarch'
 pkgname=retroarch
 version=1.16.0.3
-revision=3
+revision=4
 build_style=configure
 configure_args="--prefix=/usr --sysconfdir=/etc --enable-networking
  --enable-udev --disable-builtinflac --disable-builtinglslang

From 59da9e782d3723d31ff7023d6ce1127c047fab26 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 061/111] scrcpy: revbump for ffmpeg6

---
 srcpkgs/scrcpy/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/scrcpy/template b/srcpkgs/scrcpy/template
index ac18bc03418ce..f39a7f678ab35 100644
--- a/srcpkgs/scrcpy/template
+++ b/srcpkgs/scrcpy/template
@@ -1,7 +1,7 @@
 # Template file for 'scrcpy'
 pkgname=scrcpy
 version=2.1.1
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcompile_server=false
  -Dprebuilt_server=/usr/share/scrcpy/scrcpy-server-v${version}"

From ceed8f1fdaef5d0c8686ec6253c1b702006a34d7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 17 Oct 2023 08:54:11 -0400
Subject: [PATCH 062/111] New package: spex-x replaces spek-alternative for
 ffmpeg6

---
 srcpkgs/spek-alternative                      |  1 +
 srcpkgs/{spek-alternative => spek-x}/template | 22 ++++++++++++-------
 2 files changed, 15 insertions(+), 8 deletions(-)
 create mode 120000 srcpkgs/spek-alternative
 rename srcpkgs/{spek-alternative => spek-x}/template (52%)

diff --git a/srcpkgs/spek-alternative b/srcpkgs/spek-alternative
new file mode 120000
index 0000000000000..76648236da701
--- /dev/null
+++ b/srcpkgs/spek-alternative
@@ -0,0 +1 @@
+spek-x
\ No newline at end of file
diff --git a/srcpkgs/spek-alternative/template b/srcpkgs/spek-x/template
similarity index 52%
rename from srcpkgs/spek-alternative/template
rename to srcpkgs/spek-x/template
index d7b55c776b1d4..3ded6c2c323e4 100644
--- a/srcpkgs/spek-alternative/template
+++ b/srcpkgs/spek-x/template
@@ -1,18 +1,18 @@
-# Template file for 'spek-alternative'
-pkgname=spek-alternative
-version=0.8.2.3
-revision=2
+# Template file for 'spek-x'
+pkgname=spek-x
+version=0.9.3
+revision=1
 build_style=gnu-configure
 hostmakedepends="automake gettext-devel intltool libtool pkg-config
  wxWidgets-common wxWidgets-gtk3-devel"
 makedepends="ffmpeg-devel wxWidgets-gtk3-devel"
 depends="ffmpeg"
 short_desc="Acoustic spectrum analyser"
-maintainer="Kartik Singh <kartik.ynwa@gmail.com>"
+maintainer="zlice <zlice555@gmail.com>"
 license="GPL-3.0-or-later"
-homepage="https://github.com/withmorten/spek-alternative"
-distfiles="https://github.com/withmorten/spek-alternative/archive/${version}.tar.gz"
-checksum="007ba4b84a310b078e378aa84c8e80783db5821437a757a488c3ecec377e6b2a"
+homepage="https://github.com/MikeWang000000/spek-x"
+distfiles="https://github.com/MikeWang000000/spek-x/archive/v${version}.tar.gz"
+checksum="7f4b109903333cdd310ab2b9176f0dc49a565891376e281a233d342cedf90ef7"
 
 CXXFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
 
@@ -22,3 +22,9 @@ export WX_CONFIG_NAME="wx-config-gtk3"
 pre_configure() {
 	NOCONFIGURE=1 ./autogen.sh
 }
+
+spek-alternative_package() {
+	depends="spek-x"
+	short_desc+=" - transitional dummy package"
+	build_style=meta
+}

From a7342886d43814a730c13fc00f6b81b0c64ae82e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 063/111] ssr: revbump for ffmpeg4

---
 srcpkgs/ssr/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ssr/template b/srcpkgs/ssr/template
index 3097754e3cbe5..fa66d5b4736d4 100644
--- a/srcpkgs/ssr/template
+++ b/srcpkgs/ssr/template
@@ -5,7 +5,7 @@ revision=2
 build_style=cmake
 configure_args="-DWITH_QT5=ON"
 hostmakedepends="pkg-config"
-makedepends="alsa-lib-devel ffmpeg-devel glu-devel jack-devel pulseaudio-devel
+makedepends="alsa-lib-devel ffmpeg4-devel glu-devel jack-devel pulseaudio-devel
  qt5-tools-devel qt5-x11extras-devel libXinerama-devel v4l-utils-devel"
 depends="desktop-file-utils hicolor-icon-theme"
 short_desc="Simple Screen Recorder for programs and games"

From 968aee87dbc70b205c2f49129d4df30107d33205 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 064/111] synfig: revbump for ffmpeg6 and mlt7

---
 srcpkgs/synfig/patches/ffmpeg6.patch | 71 ++++++++++++++++++++++++++++
 srcpkgs/synfig/template              |  4 +-
 2 files changed, 73 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/synfig/patches/ffmpeg6.patch

diff --git a/srcpkgs/synfig/patches/ffmpeg6.patch b/srcpkgs/synfig/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..10780b42782f4
--- /dev/null
+++ b/srcpkgs/synfig/patches/ffmpeg6.patch
@@ -0,0 +1,71 @@
+--- a/src/modules/mod_libavcodec/trgt_av.cpp	2022-10-25 09:14:12.000000000 -0400
++++ b/src/modules/mod_libavcodec/trgt_av.cpp	2023-05-05 21:34:17.899194559 -0400
+@@ -38,6 +41,7 @@
+ extern "C"
+ {
+ #ifdef HAVE_LIBAVFORMAT_AVFORMAT_H
++#	include <libavcodec/avcodec.h>
+ #	include <libavformat/avformat.h>
+ #elif defined(HAVE_AVFORMAT_H)
+ #	include <avformat.h>
+@@ -155,11 +156,11 @@
+     }
+ 
+ 	bool open_video_stream() {
+-		if (avcodec_open2(video_context, NULL, NULL) < 0) {
++		if (avcodec_open2(video_context, nullptr, nullptr) < 0) {
+ 			synfig::error("Target_LibAVCodec: could not open video codec");
+ 			// seems the calling of avcodec_free_context after error will cause crash
+ 			// so just forget about this context
+-			video_context = NULL;
++			video_context = nullptr;
+ 			close();
+ 			return false;
+         }
+@@ -234,15 +235,21 @@
+ 		close();
+ 
+ 		if (!av_registered) {
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 			av_register_all();
++#endif
+ 			av_registered = true;
+ 		}
+ 
+ 		// guess format
+-		AVOutputFormat *format = av_guess_format(NULL, filename.c_str(), NULL);
++#if LIBAVCODEC_VERSION_MAJOR < 59 // FFMPEG < 5.0
++		AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#else
++		const AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#endif
+ 		if (!format) {
+ 			synfig::warning("Target_LibAVCodec: unable to guess the output format, defaulting to MPEG");
+-			format = av_guess_format("mpeg", NULL, NULL);
++			format = av_guess_format("mpeg", nullptr, nullptr);
+ 		}
+ 		if (!format) {
+ 			synfig::error("Target_LibAVCodec: unable to find 'mpeg' output format");
+@@ -254,6 +261,7 @@
+ 		context = avformat_alloc_context();
+ 		assert(context);
+ 		context->oformat = format;
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 		if (filename.size() + 1 > sizeof(context->filename)) {
+ 			synfig::error(
+ 				"Target_LibAVCodec: filename too long, max length is %d, filename is '%s'",
+@@ -263,6 +271,14 @@
+ 			return false;
+ 		}
+ 		memcpy(context->filename, filename.c_str(), filename.size() + 1);
++#else
++		context->url = av_strndup(filename.c_str(), filename.size());
++		if (!context->url) {
++			synfig::error("Target_LibAVCodec: cannot allocate space for filename");
++			close();
++			return false;
++		}
++#endif
+ 
+ 		packet = av_packet_alloc();
+ 		assert(packet);
diff --git a/srcpkgs/synfig/template b/srcpkgs/synfig/template
index d4d3e341a20bf..703cfd7ebac84 100644
--- a/srcpkgs/synfig/template
+++ b/srcpkgs/synfig/template
@@ -6,7 +6,7 @@ revision=4
 build_style=gnu-configure
 configure_args="--with-boost-libdir=${XBPS_CROSS_BASE}/usr/lib"
 hostmakedepends="boost-build ImageMagick pkg-config intltool"
-makedepends="ETL gettext-devel libxml++-devel mlt-devel libmagick-devel
+makedepends="ETL gettext-devel libxml++-devel mlt7-devel libmagick-devel
  libmng-devel boost-build boost-devel libopenexr-devel ffmpeg-devel"
 depends="ImageMagick"
 short_desc="CLI 2D vector and timeline-based animation software"
@@ -20,7 +20,7 @@ CXXFLAGS="-std=c++11 -DHAVE_LOCALE_H=1"
 
 synfig-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision}
-	 libopenexr-devel libxml++-devel mlt-devel"
+	 libopenexr-devel libxml++-devel mlt7-devel"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/bin/synfig-config

From 3ccb170386d2bf7d5c53006fd67edcfbfa1f6518 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 065/111] timg: revbump for ffmpeg6

---
 srcpkgs/timg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/timg/template b/srcpkgs/timg/template
index 2a2ab763d2fdd..8fb4327535ef9 100644
--- a/srcpkgs/timg/template
+++ b/srcpkgs/timg/template
@@ -1,7 +1,7 @@
 # Template file for 'timg'
 pkgname=timg
 version=1.4.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_OPENSLIDE_SUPPORT=off -Wno-dev"
 hostmakedepends="pkg-config git"

From 8971db423c1bc809328a109ffa0b2402a828334d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 066/111] tvheadend: revbump for ffmpeg4

---
 srcpkgs/tvheadend/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tvheadend/template b/srcpkgs/tvheadend/template
index 9aea7de4ec705..012d31c4879ff 100644
--- a/srcpkgs/tvheadend/template
+++ b/srcpkgs/tvheadend/template
@@ -8,7 +8,7 @@ configure_args="--enable-dvbscan --disable-ffmpeg_static
 --disable-libx265_static --disable-libvpx_static --disable-libtheora_static
 --disable-libvorbis_static --disable-libfdkaac_static"
 hostmakedepends="gettext pkg-config python3 git which"
-makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg-devel"
+makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg4-devel"
 short_desc="TV streaming server"
 maintainer="lemmi <lemmi@nerd2nerd.org>"
 license="GPL-3.0-only"

From 0fc84288f283f5270873751a67d281743d5cfdc3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 067/111] unpaper: update to 7.0.0.

---
 srcpkgs/unpaper/template | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/srcpkgs/unpaper/template b/srcpkgs/unpaper/template
index 38ed47a584016..1ff910e722afc 100644
--- a/srcpkgs/unpaper/template
+++ b/srcpkgs/unpaper/template
@@ -1,13 +1,13 @@
 # Template file for 'unpaper'
 pkgname=unpaper
-version=6.1
-revision=3
-build_style=gnu-configure
+version=7.0.0
+revision=1
+build_style=meson
+hostmakedepends="pkg-config meson libxslt"
+makedepends="ffmpeg-devel python3-Sphinx"
+short_desc="Post-processing tool for scanned sheets of paper"
 maintainer="Orphaned <orphan@voidlinux.org>"
-hostmakedepends="pkg-config libxslt"
-makedepends="ffmpeg-devel"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://www.flameeyes.eu/projects/unpaper"
-short_desc="A post-processing tool for scanned sheets of paper"
 distfiles="https://www.flameeyes.eu/files/${pkgname}-${version}.tar.xz"
-checksum=237c84f5da544b3f7709827f9f12c37c346cdf029b1128fb4633f9bafa5cb930
+checksum=2575fbbf26c22719d1cb882b59602c9900c7f747118ac130883f63419be46a80

From ce208f9a98a93d98b8a5916e798c8a7ef1501c58 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 068/111] vice: revbump for ffmpeg4

---
 srcpkgs/vice/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vice/template b/srcpkgs/vice/template
index b1f866d35095e..4beab2c5f9ebd 100644
--- a/srcpkgs/vice/template
+++ b/srcpkgs/vice/template
@@ -26,7 +26,7 @@ makedepends="
 	$(vopt_if gtk3 gtk+3-devel)
 	$(vopt_if gtk3 pulseaudio-devel)
 	$(vopt_if gtk3 pango-devel)
-	$(vopt_if ffmpeg ffmpeg-devel)"
+	$(vopt_if ffmpeg ffmpeg4-devel)"
 short_desc="Emulator for C64, C128, CBM-II, PET, VIC20, Plus4 and C16"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"

From 70771849a11a2b1b44da8165e2ed88e07d1a4ad1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 069/111] waypipe: revbump for ffmpeg6

---
 srcpkgs/waypipe/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waypipe/template b/srcpkgs/waypipe/template
index 6da88b21bf2a1..4da8058400b58 100644
--- a/srcpkgs/waypipe/template
+++ b/srcpkgs/waypipe/template
@@ -1,7 +1,7 @@
 # Template file for 'waypipe'
 pkgname=waypipe
 version=0.8.6
-revision=1
+revision=2
 build_style=meson
 # lto is off because it causes linking errors in armv6l and armv7l (due to NEON)
 configure_args="-Dwerror=false -Dwith_dmabuf=enabled -Dwith_lz4=enabled

From f7606e95e9712070bbb07cd42a6edd11acdf612c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 070/111] xpra: revbump for ffmpeg6

---
 srcpkgs/xpra/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xpra/template b/srcpkgs/xpra/template
index 6bfe9be2db650..1eea2962bcb82 100644
--- a/srcpkgs/xpra/template
+++ b/srcpkgs/xpra/template
@@ -1,7 +1,7 @@
 # Template file for 'xpra'
 pkgname=xpra
 version=5.0.4
-revision=1
+revision=2
 build_style=python3-module
 make_build_args="--without-cuda_kernels --without-cuda_rebuild"
 make_install_args="$(vopt_with docs) ${make_build_args}"

From 6653e3ab969db23bb190521138484a65647e6704 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:07:40 -0400
Subject: [PATCH 071/111] nv-codec-headers: update to 12.0.16.0

---
 srcpkgs/nv-codec-headers/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/nv-codec-headers/template b/srcpkgs/nv-codec-headers/template
index 3d422a61e4891..251e057f826fb 100644
--- a/srcpkgs/nv-codec-headers/template
+++ b/srcpkgs/nv-codec-headers/template
@@ -1,6 +1,6 @@
 # Template file for 'nv-codec-headers'
 pkgname=nv-codec-headers
-version=11.1.5.1
+version=12.0.16.0
 revision=1
 build_style=gnu-makefile
 short_desc="FFmpeg version of headers required to interface with Nvidias codec APIs"
@@ -8,7 +8,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="MIT"
 homepage="http://git.videolan.org/?p=ffmpeg/nv-codec-headers.git"
 distfiles="https://github.com/FFmpeg/nv-codec-headers/archive/n${version}.tar.gz"
-checksum=d095fbd56aa93772471a323be0ebe65504a0f43f06c76a30b6d25da77b06ae9c
+checksum=2a1533b65f55f9da52956faf0627ed3b74868ac0c7f269990edd21369113b48f
 
 post_install() {
 	sed -n '4,25p' include/ffnvcodec/nvEncodeAPI.h > LICENSE

From 5ee0d1c6f8930eb83a8de9b4c22e26f5037b3f44 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:08:40 -0400
Subject: [PATCH 072/111] openimagedenoise: revbump for ffmpeg6

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index b792813dba7c2..109deb171c3f7 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,7 +1,7 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
 version=1.4.3
-revision=1
+revision=2
 archs="x86_64*"
 build_style=cmake
 hostmakedepends="ispc python3"

From 4b944c0c8e4fc22494f3ea785fec349a518cd825 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:31:45 -0400
Subject: [PATCH 073/111] shotcut: revbump for ffmpeg6

---
 srcpkgs/shotcut/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/shotcut/template b/srcpkgs/shotcut/template
index 33141fbd862d7..f46cb53b6bfb9 100644
--- a/srcpkgs/shotcut/template
+++ b/srcpkgs/shotcut/template
@@ -1,7 +1,7 @@
 # Template file for 'shotcut'
 pkgname=shotcut
 version=23.09.29
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSHOTCUT_VERSION=${version}"
 hostmakedepends="pkg-config qt6-tools-devel"

From d3ce7d827d12193f33d9940a97666b0b7646873f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:30 -0400
Subject: [PATCH 074/111] shiboken2: revbump for qt5-5.15.11

---
 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch | 1 +
 srcpkgs/shiboken2/template                                 | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
 create mode 120000 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
new file mode 120000
index 0000000000000..efcf3249bd885
--- /dev/null
+++ b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1 @@
+../../python3-pyside2/patches/importlib-machinery-bypass.patch
\ No newline at end of file
diff --git a/srcpkgs/shiboken2/template b/srcpkgs/shiboken2/template
index 883d6a084d868..f3c06ec245a1f 100644
--- a/srcpkgs/shiboken2/template
+++ b/srcpkgs/shiboken2/template
@@ -1,7 +1,7 @@
 # Template file for 'shiboken2'
 pkgname=shiboken2
 version=5.15.10
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/shiboken2"
 build_style=cmake

From 60231e2f6c46d94551041b40fb6250cff24fc343 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:53 -0400
Subject: [PATCH 075/111] python3-pyside2: revbump for qt5-5.15.11

---
 .../patches/importlib-machinery-bypass.patch      | 15 +++++++++++++++
 srcpkgs/python3-pyside2/template                  |  2 +-
 2 files changed, 16 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
new file mode 100644
index 0000000000000..64c429584776b
--- /dev/null
+++ b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1,15 @@
+Using this prevents an error around line 220 below it.
+"AttributeError: module 'importlib' has no attribute 'machinery'"
+The old backup logic is in place and compiles without issues.
+--- a/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:09:34.688912402 -0400
++++ b/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:10:03.395529582 -0400
+@@ -170,9 +170,6 @@
+
+     # 'zipstring_sequence' comes from signature.cpp
+     zipbytes = base64.b64decode(''.join(zipstring_sequence))
+-    if sys.version_info[0] >= 3:
+-        vzip = zipfile.ZipFile(io.BytesIO(zipbytes))
+-        return sys.meta_path, EmbeddableZipImporter(vzip)
+
+     # Old version for Python 2.7, only.
+     import os
diff --git a/srcpkgs/python3-pyside2/template b/srcpkgs/python3-pyside2/template
index 249efa9098842..52626436ce75f 100644
--- a/srcpkgs/python3-pyside2/template
+++ b/srcpkgs/python3-pyside2/template
@@ -1,7 +1,7 @@
 # Template file for 'python3-pyside2'
 pkgname=python3-pyside2
 version=5.15.10
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/pyside2"
 build_style=cmake

From 2e1f95184d0bc59731c19164e8b992fcc80941a9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:35 -0400
Subject: [PATCH 076/111] konqueror: revbump for ffmpeg6

---
 srcpkgs/konqueror/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/konqueror/template b/srcpkgs/konqueror/template
index 044dafa605ba6..63dd01fafc780 100644
--- a/srcpkgs/konqueror/template
+++ b/srcpkgs/konqueror/template
@@ -1,11 +1,11 @@
 # Template file for 'konqueror'
 pkgname=konqueror
 version=23.08.4
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DDESKTOPTOJSON_EXECUTABLE=/usr/bin/desktoptojson"
 hostmakedepends="extra-cmake-modules python3 qt5-host-tools qt5-qmake kdoctools
-kcoreaddons kconfig gettext"
+ kcoreaddons kconfig gettext"
 makedepends="qt5-devel qt5-webengine-devel qt5-declarative-devel
  qt5-webchannel-devel qt5-location-devel kcmutils-devel kdelibs4support-devel
  karchive-devel khtml-devel kdesu-devel kactivities5-devel"

From c09bbdc375a0a6332b2f5787a841b93d19437d9f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:58 -0400
Subject: [PATCH 077/111] qt5-speech: revbump for qt5-5.15.11

---
 srcpkgs/qt5-speech/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-speech/template b/srcpkgs/qt5-speech/template
index 1228bb60c41db..27a7da1dbdb91 100644
--- a/srcpkgs/qt5-speech/template
+++ b/srcpkgs/qt5-speech/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-speech'
 pkgname=qt5-speech
 version=5.15.11
-revision=1
+revision=2
 _commit=d32f4a479d38a11f547598004b975f4356424a16
 build_style=qmake
 configure_args="-- -flite -flite-alsa -speechd"

From 4dd5f290536eeeaa6688985d06dc207a9fa9fe3e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Jun 2023 08:20:22 -0400
Subject: [PATCH 078/111] gtk4: revbump for ffmpeg6

---
 srcpkgs/gtk4/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gtk4/template b/srcpkgs/gtk4/template
index d8ee60abe06f7..55bff6e33849a 100644
--- a/srcpkgs/gtk4/template
+++ b/srcpkgs/gtk4/template
@@ -1,7 +1,7 @@
 # Template file for 'gtk4'
 pkgname=gtk4
 version=4.12.3
-revision=1
+revision=2
 build_style=meson
 build_helper="gir"
 configure_args="-Dman-pages=true -Ddocumentation=true -Dbuild-tests=false

From 59fd7e6a86834a43e1fd16c754d3c22f1dd04e7c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:28:26 -0400
Subject: [PATCH 079/111] siril: revbump for ffmpeg6

---
 srcpkgs/siril/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/siril/template b/srcpkgs/siril/template
index 84332f79d060d..62750dd247548 100644
--- a/srcpkgs/siril/template
+++ b/srcpkgs/siril/template
@@ -1,7 +1,7 @@
 # Template file for 'siril'
 pkgname=siril
 version=0.9.12
-revision=10
+revision=11
 build_style=gnu-configure
 hostmakedepends="pkg-config intltool autoconf automake gettext-devel"
 makedepends="fftw-devel libconfig-devel libopencv-devel libffms2-devel

From efb0954b6f4be27bd868c06547ae9f458f6730c3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 22 Jun 2023 10:25:02 -0400
Subject: [PATCH 080/111] kdenlive: revbump for ffmpeg6

---
 srcpkgs/kdenlive/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kdenlive/template b/srcpkgs/kdenlive/template
index a0f3615c9c530..d63166f95c4d7 100644
--- a/srcpkgs/kdenlive/template
+++ b/srcpkgs/kdenlive/template
@@ -1,7 +1,7 @@
 # Template file for 'kdenlive'
 pkgname=kdenlive
 version=23.08.4
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="
  extra-cmake-modules kconfig kcoreaddons kdoctools pkg-config python3

From 42f4884fbaed988bbee86d8b636ff32a6e776377 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:20:59 -0400
Subject: [PATCH 081/111] tracker-miners: revbump for ffmpeg6

---
 srcpkgs/tracker-miners/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tracker-miners/template b/srcpkgs/tracker-miners/template
index 0b97f47489f81..f196d2bf9e4a4 100644
--- a/srcpkgs/tracker-miners/template
+++ b/srcpkgs/tracker-miners/template
@@ -1,7 +1,7 @@
 # Template file for 'tracker-miners'
 pkgname=tracker-miners
 version=3.6.1
-revision=1
+revision=2
 build_style=meson
 build_helper=qemu
 # missing libgrss for miner_rss

From 29a80f228c8ae9df95a85c2696743f67dd44a654 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:21:21 -0400
Subject: [PATCH 082/111] mpd: revbump for ffmpeg6

---
 srcpkgs/mpd/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpd/template b/srcpkgs/mpd/template
index 4fd32b7be8c53..b8e2bd4c1b59c 100644
--- a/srcpkgs/mpd/template
+++ b/srcpkgs/mpd/template
@@ -1,7 +1,7 @@
 # Template file for 'mpd'
 pkgname=mpd
 version=0.23.15
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dopus=enabled -Dmikmod=enabled -Dneighbor=true
  -Dsoundcloud=enabled -Dpipe=true -Dtwolame=enabled -Dbzip2=enabled

From 3922a53c3c4474492b677b19469deccf12bb624d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:02 -0400
Subject: [PATCH 083/111] tg_owt: revbump for ffmpeg6

---
 srcpkgs/tg_owt/template | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/srcpkgs/tg_owt/template b/srcpkgs/tg_owt/template
index aee8d35d08ffb..563ed9a5835c4 100644
--- a/srcpkgs/tg_owt/template
+++ b/srcpkgs/tg_owt/template
@@ -1,8 +1,7 @@
 # Template file for 'tg_owt'
 pkgname=tg_owt
 version=0.0.0.20231221
-revision=1
-_commit=afd9d5d31798d3eacf9ed6c30601e91d0f1e4d60
+revision=2
 _libyuv_commit=04821d1e7d60845525e8db55c7bcd41ef5be9406
 _abseil_commit=8c0b94e793a66495e0b1f34a5eb26bd7dc672db0
 _crc32c_commit=21fc8ef30415a635e7351ffa0e5d5367943d4a94

From 0b5d4a934c1c9ea28ff34cc971bcd585d11d6167 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:44 -0400
Subject: [PATCH 084/111] telegram-desktop: revbump for ffmpeg6

---
 srcpkgs/telegram-desktop/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/telegram-desktop/template b/srcpkgs/telegram-desktop/template
index d00b273b7b738..d20b87b5182db 100644
--- a/srcpkgs/telegram-desktop/template
+++ b/srcpkgs/telegram-desktop/template
@@ -1,7 +1,7 @@
 # Template file for 'telegram-desktop'
 pkgname=telegram-desktop
 version=4.14.9
-revision=1
+revision=2
 build_style=cmake
 build_helper="qemu gir"
 configure_args="-DTDESKTOP_API_ID=209235

From dd679c61eb02c9e362a2470a95d5f91f70705d08 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:11:45 -0400
Subject: [PATCH 085/111] gst-plugins-bad1: revbump for ffmpeg6

---
 srcpkgs/gst-plugins-bad1/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index 4fe7053c359c3..9df84a44a0f34 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-plugins-bad1'
 pkgname=gst-plugins-bad1
 version=1.22.9
-revision=1
+revision=2
 build_helper="gir"
 build_style=meson
 configure_args="-Dpackage-origin=https://voidlinux.org -Ddoc=disabled

From 145506a95f72c245c4ca9438e74ce06a0a86470c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:12:09 -0400
Subject: [PATCH 086/111] openmw: revbump for ffmpeg6

---
 srcpkgs/openmw/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openmw/template b/srcpkgs/openmw/template
index 0abf5ff7cdbec..b57180f1a4446 100644
--- a/srcpkgs/openmw/template
+++ b/srcpkgs/openmw/template
@@ -1,7 +1,7 @@
 # Template file for 'openmw'
 pkgname=openmw
 version=0.48.0
-revision=2
+revision=3
 build_style=cmake
 _recast_commit=e75adf86f91eb3082220085e42dda62679f9a3ea
 _bullet_tag=3.17

From f6714e2442122305171c23360dfdce05193b88e5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:14:53 -0400
Subject: [PATCH 087/111] lms: revbump for ffmpeg6

---
 srcpkgs/lms/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/lms/template b/srcpkgs/lms/template
index e358f75902a98..3b21c458de519 100644
--- a/srcpkgs/lms/template
+++ b/srcpkgs/lms/template
@@ -1,7 +1,7 @@
 # Template file for 'lms'
 pkgname=lms
 version=3.42.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="wt-devel ffmpeg-devel boost-devel libconfig++-devel taglib-devel pam-devel libgraphicsmagick-devel gtest-devel libarchive-devel"

From e1fa969a0d5bd05f70efe284d6a74c08800f37b8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:18:18 -0400
Subject: [PATCH 088/111] freecad: DELETE

---
 srcpkgs/freecad/patches/001-include.patch     | 112 ------------------
 .../154-revert-gui-tmp-redirect-stderr.patch  |  68 -----------
 ...d63c8c9b1280978be841d04e68a0a55cceb9.patch |  30 -----
 srcpkgs/freecad/template                      |  12 +-
 4 files changed, 7 insertions(+), 215 deletions(-)
 delete mode 100644 srcpkgs/freecad/patches/001-include.patch
 delete mode 100644 srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
 delete mode 100644 srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch

diff --git a/srcpkgs/freecad/patches/001-include.patch b/srcpkgs/freecad/patches/001-include.patch
deleted file mode 100644
index 28b5af54999b9..0000000000000
--- a/srcpkgs/freecad/patches/001-include.patch
+++ /dev/null
@@ -1,112 +0,0 @@
-From 9a41845a417189776741297c50a3827ce292bc4f Mon Sep 17 00:00:00 2001
-From: Uwe <donovaly@users.noreply.github.com>
-Date: Sun, 3 Jul 2022 22:51:16 +0200
-Subject: [PATCH] [Part] OCCError.h: remove unneeded includes
-
-- also sort includes
----
- src/Mod/Part/App/OCCError.h             | 36 +++----------------------
- src/Mod/Part/App/OffsetCurvePyImp.cpp   | 12 ++++-----
- src/Mod/Part/App/OffsetSurfacePyImp.cpp | 10 +++----
- 3 files changed, 12 insertions(+), 46 deletions(-)
-
---- a/src/Mod/Part/App/OCCError.h
-+++ b/src/Mod/Part/App/OCCError.h
-@@ -23,36 +23,8 @@
- #ifndef _OCCError_h_
- #define _OCCError_h_
- 
--# include <Standard_Version.hxx>
- # include <Standard_Failure.hxx>
--# include <Standard_AbortiveTransaction.hxx>
--# include <Standard_ConstructionError.hxx>
--# if OCC_VERSION_HEX >= 0x060500
--# include <Standard_DefineException.hxx>
--# endif
--# include <Standard_DimensionError.hxx>
--# include <Standard_DimensionMismatch.hxx>
--# include <Standard_DivideByZero.hxx>
--# include <Standard_DomainError.hxx>
--# include <Standard_ImmutableObject.hxx>
--# include <Standard_LicenseError.hxx>
--# include <Standard_LicenseNotFound.hxx>
--# include <Standard_MultiplyDefined.hxx>
--# include <Standard_NegativeValue.hxx>
--# include <Standard_NoMoreObject.hxx>
--# include <Standard_NoSuchObject.hxx>
--# include <Standard_NotImplemented.hxx>
--# include <Standard_NullObject.hxx>
--# include <Standard_NullValue.hxx>
--# include <Standard_NumericError.hxx>
--# include <Standard_OutOfMemory.hxx>
--# include <Standard_OutOfRange.hxx>
--# include <Standard_Overflow.hxx>
--# include <Standard_ProgramError.hxx>
--# include <Standard_RangeError.hxx>
--# include <Standard_TooManyUsers.hxx>
--# include <Standard_TypeMismatch.hxx>
--# include <Standard_Underflow.hxx>
-+# include <Standard_Version.hxx>
- 
- #include <Mod/Part/PartGlobal.h>
- #include <Base/Console.h>
-@@ -88,4 +60,3 @@ PartExport extern PyObject* PartExceptio
- 
- #define PY_CATCH_OCC _PY_CATCH_OCC(return(NULL))
- #endif  // _OCCError_h_
--
---- a/src/Mod/Part/App/OffsetCurvePyImp.cpp
-+++ b/src/Mod/Part/App/OffsetCurvePyImp.cpp
-@@ -20,20 +20,20 @@
-  *                                                                         *
-  ***************************************************************************/
- 
--
- #include "PreCompiled.h"
- #ifndef _PreComp_
- # include <Geom_OffsetCurve.hxx>
- #endif
- 
--#include "OCCError.h"
--#include "Geometry.h"
-+#include <Base/GeometryPyCXX.h>
-+#include <Base/Vector3D.h>
-+#include <Base/VectorPy.h>
-+
- #include "OffsetCurvePy.h"
- #include "OffsetCurvePy.cpp"
-+#include "Geometry.h"
-+#include "OCCError.h"
- 
--#include <Base/GeometryPyCXX.h>
--#include <Base/VectorPy.h>
--#include <Base/Vector3D.h>
- 
- using namespace Part;
- 
---- a/src/Mod/Part/App/OffsetSurfacePyImp.cpp
-+++ b/src/Mod/Part/App/OffsetSurfacePyImp.cpp
-@@ -20,20 +20,16 @@
-  *                                                                         *
-  ***************************************************************************/
- 
--
- #include "PreCompiled.h"
- #ifndef _PreComp_
- # include <Geom_OffsetSurface.hxx>
- # include <memory>
- #endif
- 
--#include <Base/VectorPy.h>
--#include <Base/Vector3D.h>
--
- #include "OCCError.h"
--#include "Geometry.h"
--#include <Mod/Part/App/OffsetSurfacePy.h>
--#include <Mod/Part/App/OffsetSurfacePy.cpp>
-+#include "OffsetSurfacePy.h"
-+#include "OffsetSurfacePy.cpp"
-+
- 
- using namespace Part;
- 
diff --git a/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch b/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
deleted file mode 100644
index d6a9adabdec83..0000000000000
--- a/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
+++ /dev/null
@@ -1,68 +0,0 @@
-see https://github.com/FreeCAD/FreeCAD/commit/cfe94b00d3434f3e2c8b5114d2909f628c330fa8#commitcomment-71413407
-
-upstream: yes
-
-From 7b377a216b9185960e4cee980a6504dc1a755f50 Mon Sep 17 00:00:00 2001
-From: wmayer <wmayer@users.sourceforge.net>
-Date: Wed, 29 Jun 2022 15:19:18 +0200
-Subject: [PATCH] Gui: remove workaround for spnav 0.23 due to build failure
- with musl libc
-
----
- src/Gui/3Dconnexion/GuiNativeEventLinux.cpp | 27 ---------------------
- 1 file changed, 27 deletions(-)
-
---- a/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp
-+++ b/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp
-@@ -21,42 +21,17 @@
-  ***************************************************************************/
- 
- #include <FCConfig.h>
--#include <cstdio>
- 
- #include "GuiNativeEventLinux.h"
- 
- #include "GuiApplicationNativeEventAware.h"
- #include <Base/Console.h>
--#include <Base/FileInfo.h>
- #include <QMainWindow>
- 
- #include <QSocketNotifier>
- 
- #include <spnav.h>
- 
--namespace {
--class RedirectStdErr
--{
--public:
--    RedirectStdErr()
--        : fi(Base::FileInfo::getTempFileName())
--        , file(stderr)
--    {
--        stderr = fopen(fi.filePath().c_str(), "w");
--    }
--    ~RedirectStdErr()
--    {
--        fclose(stderr);
--        fi.deleteFile();
--        stderr = file;
--    }
--
--private:
--    Base::FileInfo fi;
--    FILE* file;
--};
--}
--
- Gui::GuiNativeEvent::GuiNativeEvent(Gui::GUIApplicationNativeEventAware *app)
- : GuiAbstractNativeEvent(app)
- {
-@@ -72,8 +47,6 @@ Gui::GuiNativeEvent::~GuiNativeEvent()
- 
- void Gui::GuiNativeEvent::initSpaceball(QMainWindow *window)
- {
--    // tmp. redirect stderr to a file to suppress an error message from spnav_open()
--    RedirectStdErr err;
-     Q_UNUSED(window)
-     if (spnav_open() == -1) {
-         Base::Console().Log("Couldn't connect to spacenav daemon. Please ignore if you don't have a spacemouse.\n");
diff --git a/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch b/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch
deleted file mode 100644
index d4acf370ca0a4..0000000000000
--- a/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-From fe02d63c8c9b1280978be841d04e68a0a55cceb9 Mon Sep 17 00:00:00 2001
-From: Roy-043 <70520633+Roy-043@users.noreply.github.com>
-Date: Thu, 29 Dec 2022 23:20:38 +0100
-Subject: [PATCH] Draft: update inspect.getargspec to inspect.getfullargspec
- (#8101)
-
----
- src/Mod/Draft/draftguitools/gui_snapper.py | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
---- a/src/Mod/Draft/draftguitools/gui_snapper.py
-+++ b/src/Mod/Draft/draftguitools/gui_snapper.py
-@@ -1426,7 +1426,7 @@ class Snapper:
-             Gui.Snapper.off()
-             self.ui.offUi()
-             if callback:
--                if len(inspect.getargspec(callback).args) > 1:
-+                if len(inspect.getfullargspec(callback).args) > 1:
-                     obj = None
-                     if self.snapInfo and ("Object" in self.snapInfo) and self.snapInfo["Object"]:
-                         obj = App.ActiveDocument.getObject(self.snapInfo["Object"])
-@@ -1445,7 +1445,7 @@ class Snapper:
-             Gui.Snapper.off()
-             self.ui.offUi()
-             if callback:
--                if len(inspect.getargspec(callback).args) > 1:
-+                if len(inspect.getfullargspec(callback).args) > 1:
-                     callback(None, None)
-                 else:
-                     callback(None)
diff --git a/srcpkgs/freecad/template b/srcpkgs/freecad/template
index c135701e38b9a..7d5165f760bab 100644
--- a/srcpkgs/freecad/template
+++ b/srcpkgs/freecad/template
@@ -1,7 +1,7 @@
 # Template file for 'freecad'
 pkgname=freecad
-version=0.20.2
-revision=7
+version=0.21.1
+revision=2
 build_wrksrc="FreeCAD-${version}"
 build_style=cmake
 pycompile_dirs="usr/lib/${pkgname}/Mod"
@@ -24,8 +24,10 @@ makedepends="python3-devel boost-devel libxerces-c-devel zlib-devel occt-devel
  coin3-devel libshiboken2-devel libspnav-devel pyside2-tools
  liblz4-devel libpyside2-python3-devel python3-matplotlib netcdf-devel
  jsoncpp-devel qt5-devel qt5-svg-devel qt5-tools-devel qt5-webkit-devel
- qt5-xmlpatterns-devel coin3-doc glew-devel python3-pivy"
-depends="python3-matplotlib python3-pyside2-webengine python3-pivy"
+ qt5-xmlpatterns-devel coin3-doc glew-devel python3-pivy qt5-webengine-devel
+ qt5-declarative-devel qt5-webchannel-devel qt5-location-devel"
+depends="python3-matplotlib python3-pyside2-webengine python3-pivy
+ python3-GitPython python3-Markdown"
 short_desc="General purpose 3D CAD modeler"
 maintainer="yopito <pierre.bourgin@free.fr>"
 license="LGPL-2.0-or-later"
@@ -35,7 +37,7 @@ distfiles="
  https://github.com/FreeCAD/FreeCAD/archive/${version}.tar.gz
  ${SOURCEFORGE_SITE}/cxx/pycxx-${_pycxxver}.tar.gz
 "
-checksum="46922f3a477e742e1a89cd5346692d63aebb2b67af887b3e463e094a4ae055da
+checksum="e9b1fd0323f101268c7f3be52db42e4a29222f2e306ae6c4a6fc309cb418d35a
  4b91e1e1141c23fbd5039df635c4bb6e75632168548f56b83ce177193c0c98c6"
 python_version=3
 patch_args="-Np1 -d ${build_wrksrc}"

From 877ecb236cdff10ce8a8acf9fa1acf5d26ebc840 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:47:18 -0400
Subject: [PATCH 089/111] libopenshot: revbump for ffmpeg6

---
 srcpkgs/libopenshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenshot/template b/srcpkgs/libopenshot/template
index 8e57c5f592169..7a8f4520e7892 100644
--- a/srcpkgs/libopenshot/template
+++ b/srcpkgs/libopenshot/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenshot'
 pkgname=libopenshot
 version=0.3.0
-revision=3
+revision=4
 build_style=cmake
 # Builds fail with Ruby-2.4.1
 configure_args="-DENABLE_RUBY=OFF -DUSE_SYSTEM_JSONCPP=ON"

From 9b230c6dd5041c067059ef8c36cd913ecdb61de5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:10:30 -0500
Subject: [PATCH 090/111] openimageio: revbump for ffmpeg6

---
 srcpkgs/openimageio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimageio/template b/srcpkgs/openimageio/template
index 3ce3f9e49d350..27d2131bc0a61 100644
--- a/srcpkgs/openimageio/template
+++ b/srcpkgs/openimageio/template
@@ -1,7 +1,7 @@
 # Template file for 'openimageio'
 pkgname=openimageio
 version=2.4.9.0
-revision=7
+revision=8
 build_style=cmake
 build_helper=qemu
 configure_args="-DUSE_QT=0 -DUSE_PYTHON=0 -DOIIO_BUILD_TESTS=0

From 1876a42c550ab6430e76d36ff8446e87dce37e32 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:11:57 -0500
Subject: [PATCH 091/111] synfigstudio: revbump for ffmpeg6

---
 srcpkgs/synfigstudio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/synfigstudio/template b/srcpkgs/synfigstudio/template
index 09e442da9a680..2bc017cedca6b 100644
--- a/srcpkgs/synfigstudio/template
+++ b/srcpkgs/synfigstudio/template
@@ -2,7 +2,7 @@
 # Should be kept in sync with 'synfig' and 'ETL'
 pkgname=synfigstudio
 version=1.4.4
-revision=4
+revision=5
 build_style=gnu-configure
 configure_args="--disable-update-mimedb"
 hostmakedepends="pkg-config intltool gettext synfig"

From 886d10857043a51103bf64292398e1b830b9963c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:10 -0500
Subject: [PATCH 092/111] mixxx: revbump for ffmpeg6

---
 srcpkgs/mixxx/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mixxx/template b/srcpkgs/mixxx/template
index 6921996e4e77b..6a79b328c1abf 100644
--- a/srcpkgs/mixxx/template
+++ b/srcpkgs/mixxx/template
@@ -1,7 +1,7 @@
 # Template file for 'mixxx'
 pkgname=mixxx
 version=2.3.3
-revision=6
+revision=7
 build_style=cmake
 configure_args="-DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="extra-cmake-modules pkg-config protobuf qt5-host-tools qt5-qmake"

From 102128b6ffe65eeea3ca7548efd089219139b044 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:28 -0500
Subject: [PATCH 093/111] musikcube: revbump for ffmpeg6

---
 srcpkgs/musikcube/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/musikcube/template b/srcpkgs/musikcube/template
index 8c4a51840859e..fb60dd2049089 100644
--- a/srcpkgs/musikcube/template
+++ b/srcpkgs/musikcube/template
@@ -1,7 +1,7 @@
 # Template file for 'musikcube'
 pkgname=musikcube
 version=3.0.0
-revision=3
+revision=4
 build_style=cmake
 make_cmd=make
 configure_args="-DNO_NCURSESW=1"

From 67eb79f1a0b74971a6f55b852cf7b16b33d08be0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:45 -0500
Subject: [PATCH 094/111] electron24: revbump for ffmpeg6

---
 srcpkgs/electron24/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron24/template b/srcpkgs/electron24/template
index 7b4e28812f483..1ca93fde97a85 100644
--- a/srcpkgs/electron24/template
+++ b/srcpkgs/electron24/template
@@ -1,7 +1,7 @@
 # Template file for 'electron24'
 pkgname=electron24
 version=24.3.0
-revision=2
+revision=3
 _nodever=18.14.0
 _chromiumver=112.0.5615.165
 archs="x86_64* aarch64*"

From 642d2ba40df1b830f483e83913c7bc2bb17ce415 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:00 -0500
Subject: [PATCH 095/111] electron19: revbump for ffmpeg6

---
 srcpkgs/electron19/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron19/template b/srcpkgs/electron19/template
index 0ef959125cb08..5371c0b354604 100644
--- a/srcpkgs/electron19/template
+++ b/srcpkgs/electron19/template
@@ -1,7 +1,7 @@
 # Template file for 'electron19'
 pkgname=electron19
 version=19.0.8
-revision=4
+revision=5
 _nodever=16.14.2
 _chromiumver=102.0.5005.125
 archs="x86_64* aarch64* ppc64le*"

From 5d2e2a7574ba36e93f5918199fbea05bdcb5711c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:13 -0500
Subject: [PATCH 096/111] wf-recorder: revbump for ffmpeg6

---
 srcpkgs/wf-recorder/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/wf-recorder/template b/srcpkgs/wf-recorder/template
index 08f986b031006..63c45cf4b814d 100644
--- a/srcpkgs/wf-recorder/template
+++ b/srcpkgs/wf-recorder/template
@@ -1,7 +1,7 @@
 # Template file for 'wf-recorder'
 pkgname=wf-recorder
 version=0.4.1
-revision=2
+revision=3
 build_style=meson
 hostmakedepends="pkg-config scdoc wayland-devel"
 makedepends="wayland-protocols wayland-devel ffmpeg-devel libgbm-devel x264-devel

From 95da491a153e741f182dfa5de0623344f25c6fb6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:26 -0500
Subject: [PATCH 097/111] obs: revbump for ffmpeg6

---
 srcpkgs/obs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/obs/template b/srcpkgs/obs/template
index b343f1131bfcf..a25a67433e285 100644
--- a/srcpkgs/obs/template
+++ b/srcpkgs/obs/template
@@ -1,7 +1,7 @@
 # Template file for 'obs'
 pkgname=obs
 version=30.0.0
-revision=2
+revision=3
 archs="i686* x86_64* ppc64le* aarch64* riscv64*"
 build_style=cmake
 configure_args="-DOBS_VERSION_OVERRIDE=${version} -DENABLE_JACK=ON

From 9596b9e62866aa26205a88f96eb3fce5dd8b43be Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:36 -0500
Subject: [PATCH 098/111] mlt7: revbump for ffmpeg6

---
 srcpkgs/mlt7/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mlt7/template b/srcpkgs/mlt7/template
index 98f302ad3a516..7eb8c00fa1580 100644
--- a/srcpkgs/mlt7/template
+++ b/srcpkgs/mlt7/template
@@ -1,7 +1,7 @@
 # Template file for 'mlt7'
 pkgname=mlt7
 version=7.20.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DSWIG_PYTHON=ON -DMOD_QT6=ON"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which

From d41232a485478a502920725b30d0982dac923cfd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:48 -0500
Subject: [PATCH 099/111] qt6-multimedia: revbump for ffmpeg6

---
 srcpkgs/qt6-multimedia/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-multimedia/template b/srcpkgs/qt6-multimedia/template
index 67a577e1300fe..1da626ecf515a 100644
--- a/srcpkgs/qt6-multimedia/template
+++ b/srcpkgs/qt6-multimedia/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-multimedia'
 pkgname=qt6-multimedia
 version=6.6.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DQT_FEATURE_gstreamer=ON"
 hostmakedepends="perl qt6-declarative-host-tools pkg-config qt6-shadertools"

From f8e0cd8ecf6f3a5bd030c1c6e4f316b10f8877b9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:00:15 -0500
Subject: [PATCH 100/111] baresip: revbump for ffmpeg6

---
 srcpkgs/baresip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/baresip/template b/srcpkgs/baresip/template
index 12c8954ef7b9b..b16b67beab8d2 100644
--- a/srcpkgs/baresip/template
+++ b/srcpkgs/baresip/template
@@ -1,7 +1,7 @@
 # Template file for 'baresip'
 pkgname=baresip
 version=3.6.0
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config glib-devel"
 makedepends="libgsm-devel libpng-devel openssl-devel libsndfile-devel

From 61533416ec27084ecf4c2c392bd998f18e60a093 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:30 -0500
Subject: [PATCH 101/111] QMPlay2: revbump for ffmpeg6

---
 srcpkgs/QMPlay2/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/QMPlay2/template b/srcpkgs/QMPlay2/template
index 46c80f64a1349..942258ce60fb7 100644
--- a/srcpkgs/QMPlay2/template
+++ b/srcpkgs/QMPlay2/template
@@ -1,7 +1,7 @@
 # Template file for 'QMPlay2'
 pkgname=QMPlay2
 version=23.10.22
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools"
 makedepends="alsa-lib-devel ffmpeg-devel libass-devel libcdio-devel libgme-devel

From 24e845eb36e3365f0125d18c839270e5af303bf0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:34 -0500
Subject: [PATCH 102/111] alsa-plugins: revbump for ffmpeg6

---
 srcpkgs/alsa-plugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/alsa-plugins/template b/srcpkgs/alsa-plugins/template
index a5708a7d82a8f..7bfdad046c483 100644
--- a/srcpkgs/alsa-plugins/template
+++ b/srcpkgs/alsa-plugins/template
@@ -1,7 +1,7 @@
 # Template file for 'alsa-plugins'
 pkgname=alsa-plugins
 version=1.2.7.1
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--disable-maemo-plugin"
 hostmakedepends="pkg-config"

From c6f7b9a0edc4f21b577a8c8d0445878a2bdd373c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:43 -0500
Subject: [PATCH 103/111] minidlna: revbump for ffmpeg6

---
 srcpkgs/minidlna/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/minidlna/template b/srcpkgs/minidlna/template
index 5fa929f3a0c12..742991ecd04af 100644
--- a/srcpkgs/minidlna/template
+++ b/srcpkgs/minidlna/template
@@ -1,7 +1,7 @@
 # Template file for 'minidlna'
 pkgname=minidlna
 version=1.3.3
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="
  --sbindir=/usr/bin

From 348e0a831ee5816ab78e9af4d4c5b75d2d6b2c72 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 17:57:47 -0500
Subject: [PATCH 104/111] mpv: revbump for ffmpeg6

---
 srcpkgs/mpv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpv/template b/srcpkgs/mpv/template
index 4948d1e332cb8..1ac1b167af189 100644
--- a/srcpkgs/mpv/template
+++ b/srcpkgs/mpv/template
@@ -1,7 +1,7 @@
 # Template file for 'mpv'
 pkgname=mpv
 version=0.36.0
-revision=4
+revision=5
 build_style=meson
 configure_args="-Dcdda=enabled -Ddvbin=enabled -Ddvdnav=enabled
  -Dlibmpv=true -Dcplugins=enabled

From 03ad940a7c9cdbd307c777253ca29d9793c8f0a0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 17:59:29 -0500
Subject: [PATCH 105/111] qimgv: revbump for ffmpeg6

---
 srcpkgs/qimgv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qimgv/template b/srcpkgs/qimgv/template
index dd341dfe1bfce..8a7e1c081ef12 100644
--- a/srcpkgs/qimgv/template
+++ b/srcpkgs/qimgv/template
@@ -1,7 +1,7 @@
 # Template file for 'qimgv'
 pkgname=qimgv
 version=1.0.2
-revision=3
+revision=4
 build_style=cmake
 configure_args="$(vopt_if video -DVIDEO_SUPPORT=ON -DVIDEO_SUPPORT=OFF)
  $(vopt_if scale -DOPENCV_SUPPORT=ON -DOPENCV_SUPPORT=OFF)

From d58e8e0c15cb99d0446db43353cdda61d7e22a2b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 18:00:36 -0500
Subject: [PATCH 106/111] kfilemetadata5: revbump for ffmpeg6

---
 srcpkgs/kfilemetadata5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kfilemetadata5/template b/srcpkgs/kfilemetadata5/template
index 51fd6fec8c1c0..ad229b4c2e241 100644
--- a/srcpkgs/kfilemetadata5/template
+++ b/srcpkgs/kfilemetadata5/template
@@ -1,7 +1,7 @@
 # Template file for 'kfilemetadata5'
 pkgname=kfilemetadata5
 version=5.113.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="kcoreaddons extra-cmake-modules pkg-config qt5-host-tools qt5-qmake
  gettext kcoreaddons python3"

From d58f9d13edbadcf6e15661f22f053a6471f3f856 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 8 Dec 2023 11:46:01 -0500
Subject: [PATCH 107/111] vba-m: revbump for ffmpeg6

---
 srcpkgs/vba-m/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vba-m/template b/srcpkgs/vba-m/template
index 52efeede1dcba..3e0760398905c 100644
--- a/srcpkgs/vba-m/template
+++ b/srcpkgs/vba-m/template
@@ -2,7 +2,7 @@
 pkgname=vba-m
 reverts=1292_2
 version=2.1.8
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_GTK=TRUE -DENABLE_FFMPEG=TRUE -DENABLE_LINK=TRUE -DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="gettext pkg-config unzip zip yasm wxWidgets-gtk3-devel"

From 592995d2313ec64809b40797bc6bdbd32f5f4a87 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 8 Dec 2023 11:46:19 -0500
Subject: [PATCH 108/111] dolphin-emu: revbump for ffmpeg6

---
 srcpkgs/dolphin-emu/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/dolphin-emu/template b/srcpkgs/dolphin-emu/template
index 862d3ae964eec..a7ae0efb58fb7 100644
--- a/srcpkgs/dolphin-emu/template
+++ b/srcpkgs/dolphin-emu/template
@@ -1,7 +1,7 @@
 # Template file for 'dolphin-emu'
 pkgname=dolphin-emu
 version=5.0.19368
-revision=3
+revision=4
 _dolphin_commit=dadbeb4bae7e7fa23af2b46e0add4143094dc107
 _mgba_commit=44e074a15e9651481f7f652ac006a7c9d58cbeb9
 _googletest_commit=be03d00f5f0cc3a997d1a368bee8a1fe93651f48

From 609ce0396056a63267068e3af1893da4ac514fbf Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 19 Dec 2023 15:38:51 -0500
Subject: [PATCH 109/111] qtox: revbump for ffmpeg4

---
 srcpkgs/qtox/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtox/template b/srcpkgs/qtox/template
index bb70e7f51240a..755e4462bc013 100644
--- a/srcpkgs/qtox/template
+++ b/srcpkgs/qtox/template
@@ -1,13 +1,13 @@
 # Template file for 'qtox'
 pkgname=qtox
 version=1.17.6
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DUPDATE_CHECK=OFF
  -DGIT_DESCRIBE=${version}
  $(vopt_if snorenotify -DDESKTOP_NOTIFICATIONS=ON)"
 hostmakedepends="pkg-config qt5-host-tools qt5-devel"
-makedepends="ffmpeg-devel libexif-devel libopenal-devel libsodium-devel
+makedepends="ffmpeg4-devel libexif-devel libopenal-devel libsodium-devel
  libvpx-devel opus-devel qrencode-devel qt5-svg-devel sonnet-devel
  sqlcipher-devel toxcore-devel
  $(vopt_if snorenotify snorenotify-devel)"

From 15c7bda6ef5b6bebb847d0e567694a3e96966599 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 11 Jan 2024 11:52:00 -0500
Subject: [PATCH 110/111] arcan: revbump for ffmpeg6

---
 srcpkgs/arcan/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/arcan/template b/srcpkgs/arcan/template
index ff9091f90ebb1..030091a6cc9d0 100644
--- a/srcpkgs/arcan/template
+++ b/srcpkgs/arcan/template
@@ -2,7 +2,7 @@
 # !! keep synced with: acfgfs aclip aloadimage
 pkgname=arcan
 version=0.6.2.1
-revision=2
+revision=3
 create_wrksrc=yes
 build_wrksrc=arcan/src
 build_style=cmake

From 6c9947b9b9fa6e2ea85f341f4ff4fb0dd4e9e2f3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 11 Jan 2024 11:52:10 -0500
Subject: [PATCH 111/111] notcurses: revbump for ffmpeg6

---
 srcpkgs/notcurses/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/notcurses/template b/srcpkgs/notcurses/template
index 48a7463cb68eb..515f316ab4576 100644
--- a/srcpkgs/notcurses/template
+++ b/srcpkgs/notcurses/template
@@ -1,7 +1,7 @@
 # Template file for 'notcurses'
 pkgname=notcurses
 version=3.0.9
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DUSE_STATIC=ON -DUSE_QRCODEGEN=On $(vopt_bool man USE_PANDOC)"
 hostmakedepends="pkg-config $(vopt_if man pandoc)"

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (56 preceding siblings ...)
  2024-02-02 22:44 ` zlice
@ 2024-02-02 22:46 ` zlice
  2024-02-02 22:48 ` zlice
                   ` (39 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2024-02-02 22:46 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 438 bytes --]

New comment by zlice on void-packages repository

https://github.com/void-linux/void-packages/pull/43761#issuecomment-1924842347

Comment:
updated comments for ffmpeg4 packages. flowblade seems to work for me and should allow for removal of mlt and can use mlt7.

vice, libextractor and idjc i wouldn't know how to test. mediastreamer is linphone based so i didn't check beyond seeing a new version (complained about optr cmake files?)

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (57 preceding siblings ...)
  2024-02-02 22:46 ` zlice
@ 2024-02-02 22:48 ` zlice
  2024-02-03 20:31 ` [PR PATCH] [Updated] " zlice
                   ` (38 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2024-02-02 22:48 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 468 bytes --]

New comment by zlice on void-packages repository

https://github.com/void-linux/void-packages/pull/43761#issuecomment-1924842347

Comment:
updated comments for ffmpeg4 packages. flowblade seems to work for me with mlt7-python3, should be the last user of mlt (6), so mlt may be good to remove

vice, libextractor and idjc i wouldn't know how to test. mediastreamer is linphone based so i didn't check beyond seeing a new version (complained about optr cmake files?)

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (58 preceding siblings ...)
  2024-02-02 22:48 ` zlice
@ 2024-02-03 20:31 ` zlice
  2024-02-03 20:38 ` zlice
                   ` (37 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2024-02-03 20:31 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 4558 bytes --]

There is an updated pull request by zlice against master on the void-packages repository

https://github.com/zlice/void-packages ffmpeg6-split
https://github.com/void-linux/void-packages/pull/43761

ffmpeg6 split
[ci skip]


#### Testing the changes

- I tested the changes in this PR: **YES**

main testing has been vaapi in Firefox Nightly and enc/dec in Shotcut on Intel A770

#### New package

- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**

#### Local build testing

- I built this PR locally for my native architecture, **x86_64**

#### Discussion

Continuation of https://github.com/void-linux/void-packages/pull/36315

`libavresample` is deprecated, but marked as a dependency when trying to build other packages and install `ffmpeg`(6). I think the right way to handle this is make a meta package and the add to removals?


##### Commit naming / misc

~~Commits are 'dirty' right now, running with [gstreamer 1.22.1 updates](https://github.com/void-linux/void-packages/pull/42861) and [Intel OpenCL](https://github.com/void-linux/void-packages/pull/43084). This will also make [intel packages pr](https://github.com/void-linux/void-packages/pull/41132) obsolete.~~ (see Requirements below)

Maintainer for previous ffmpeg(4) was orphaned, I can put my name in there if that matters, though I don't exactly see myself keeping up on ffmpeg.

~~This updates QT5 which looks like it is usually hosted by Johnny. Not sure if there's any reason to stay there or these sources are fine.~~ Using qt5.15.11 now, revbumps and some patches.

##### STILL FFMPEG4

These are a mix of emulators, games and/or older packages.

- attract (multiple patches in master)
- ~~audacity (https://github.com/audacity/audacity/issues/2305 and https://sourceforge.net/p/portmedia/wiki/portsmf/ is 'beta')~~ (updated to 3.x, compiles with ffmpeg6)
- ccextractor (master patches? no release)
- vice (3.8 compiles, needs makedepends libcurl-devel)
- kodi
- mlt (only dep left is flowblade - flowblade 2.12.0.2 with mlt7-python3 can 'render' videos with cpu and gpu)
- ~~synfig (mlt)~~ (work with mlt7, bump synfigstudio)
- tvheadend
- ssr
- ~~spek-alternative~~ (replace with spek-x)
- ppsspp
- olive
- moc
- mediastreamer (linphone links are dead, changed to github belladonne. their stuff never worked for me but there are updates if someone wants to give it a try)
- libextractor (1.13 compiles, remove exiv2 patch)
- idjc (0.9.8 compiles, remove python3.10 patch, needs makedepends libebur128-devel and libshout-idjc 2.4.6 with '-r1' for distfile)
- hedgewars
- ~~ffmpegthumbnailer~~ (patches for moviedecoder.xxx files)
- ~~ffmpegthumbs~~ (latest compiles)
- deadbeef
- ~~omxplayer~~ (package removed, deprecated in favor of vlc)
- qtav (fork has ffmpeg 5 patch - https://github.com/cmguo/QtAV)
- `vlc` (vlc4 will support ffmpeg5, there's a patch to build 3.x with ffmpeg5 but it will lack vaapi)
- `osg` (OpenSceneGraph plus `xine-lib`)


##### HAVE NOT BUILT YET

- ~~omxplayer (rpi only? ffmpeg4)~~ (removed)
- kodi (big, but ffmpeg4)


##### UPDATED (for ffmpeg6)

- ~~blender: update to 3.5.1~~ ~~will be revbump with~~ https://github.com/void-linux/void-packages/pull/43992
- unpaper: update to 7.0.0.
- guvcview: update to 2.0.8.
- ~~qt5: update to 5.15.8~~ updated by another PR to 5.15.11
- ~~qt5-webengine: update to 5.18.15~~ updated by another PR to 5.15.16 (some patching for ffmpeg build)
- ~~shiboken2: revbump for qt5.15.8 (patch)~~ updated by another PR to 5.15.10
- ~~python3-pyside2: update to 5.15.8 (patch)~~ updated by another PR to 5.15.10
- New package: spex-x replaces spek-alternative for ffmpeg-6.0


##### Requirements

- ~~[gstreamer 1.22.2](https://github.com/void-linux/void-packages/pull/42861)~~ - a few packages use ffmpeg-devel and require a revbump

- ~~[Intel Packages](https://github.com/void-linux/void-packages/pull/41132) [Intel Packages v2](https://github.com/void-linux/void-packages/pull/47330) - ffmpeg4 uses different libraries than 6 (libmfx / Intel-MediaSDK vs only oneVPL that Intel is moving to), both are included here~~. Using replacement oneVPL from OBS update.

- ~~[shotcut 23.05.14](https://github.com/void-linux/void-packages/pull/44260)~~

- https://github.com/void-linux/void-packages/pull/44781 will remove from this PR

A patch file from https://github.com/void-linux/void-packages/pull/43761.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ffmpeg6-split-43761.patch --]
[-- Type: text/x-diff, Size: 228505 bytes --]

From a3c60b2ad35df66d6aa3a1ca0810e6701cc6d41c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:16:56 -0400
Subject: [PATCH 001/113] ffmpeg: update to 6.0.1.

---
 common/shlibs                                 | 26 ++++---
 srcpkgs/ffmpeg/files/altivec.patch            | 60 ---------------
 .../patches/armv5tel-floating-point.patch     | 18 -----
 srcpkgs/ffmpeg/patches/binutils-2.41.patch    | 73 -------------------
 ...h-libavcodec-libsvtav1-ten_bit_format.diff | 40 ----------
 .../workaround-mesa-readeon-vaapi-bug.patch   | 28 -------
 srcpkgs/ffmpeg/template                       | 40 +++++-----
 7 files changed, 37 insertions(+), 248 deletions(-)
 delete mode 100644 srcpkgs/ffmpeg/files/altivec.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/binutils-2.41.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 delete mode 100644 srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch

diff --git a/common/shlibs b/common/shlibs
index 71f172740e5c61..c1c79647f63cac 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -389,15 +389,23 @@ libid3tag.so.0 libid3tag-0.15.1b_1
 libgif.so.7 giflib-5.1.0_1
 libImlib2.so.1 imlib2-1.4.2_1
 libmp3lame.so.0 lame-3.98.2_1
-libavdevice.so.58 libavdevice-4.0_1
-libavformat.so.58 libavformat-4.0_1
-libswscale.so.5 libswscale-4.0_1
-libswresample.so.3 libswresample-4.0_1
-libavresample.so.4 libavresample-4.0_1
-libpostproc.so.55 libpostproc-4.0_1
-libavcodec.so.58 libavcodec-4.0_1
-libavutil.so.56 libavutil-4.0_1
-libavfilter.so.7 libavfilter-4.0_1
+libavdevice.so.60 libavdevice-6.0_1
+libavformat.so.60 libavformat-6.0_1
+libswscale.so.7 libswscale-6.0_1
+libswresample.so.4 libswresample-6.0_1
+libpostproc.so.57 libpostproc-6.0_1
+libavcodec.so.60 libavcodec-6.0_1
+libavutil.so.58 libavutil-6.0_1
+libavfilter.so.9 libavfilter-6.0_1
+libavdevice.so.58 libavdevice4-4.0_1
+libavformat.so.58 libavformat4-4.0_1
+libswscale.so.5 libswscale4-4.0_1
+libswresample.so.3 libswresample4-4.0_1
+libavresample.so.4 libavresample4-4.0_1
+libpostproc.so.55 libpostproc4-4.0_1
+libavcodec.so.58 libavcodec4-4.0_1
+libavutil.so.56 libavutil4-4.0_1
+libavfilter.so.7 libavfilter4-4.0_1
 libSDL-1.2.so.0 SDL-1.2.14_1
 libSDL_image-1.2.so.0 SDL_image-1.2.10_1
 libx264.so.157 x264-20190507.2245_1
diff --git a/srcpkgs/ffmpeg/files/altivec.patch b/srcpkgs/ffmpeg/files/altivec.patch
deleted file mode 100644
index 9c57200463320e..00000000000000
--- a/srcpkgs/ffmpeg/files/altivec.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-revert some altivec specific change on all ppc* except ppc64le*
-
-q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
-conditionally, for ppc* but not ppc64le* (the new code is valid for
-POWER8 VSX which LE targets as a baseline but not BE)"
-
-
-This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
----
- libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
- 1 file changed, 20 insertions(+), 4 deletions(-)
-
-diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
-index 536545293d..c1e2852adb 100644
---- a/libswscale/ppc/yuv2rgb_altivec.c
-+++ b/libswscale/ppc/yuv2rgb_altivec.c
-@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-     vector signed short R1, G1, B1;                                           \
-     vector unsigned char R, G, B;                                             \
-                                                                               \
-+    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
-+    vector unsigned char align_perm;                                          \
-+                                                                              \
-     vector signed short lCY       = c->CY;                                    \
-     vector signed short lOY       = c->OY;                                    \
-     vector signed short lCRV      = c->CRV;                                   \
-@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
-                                                                               \
-         for (j = 0; j < w / 16; j++) {                                        \
--            y0 = vec_xl(0, y1i);                                              \
-+            y1ivP = (const vector unsigned char *) y1i;                       \
-+            y2ivP = (const vector unsigned char *) y2i;                       \
-+            uivP  = (const vector unsigned char *) ui;                        \
-+            vivP  = (const vector unsigned char *) vi;                        \
-+                                                                              \
-+            align_perm = vec_lvsl(0, y1i);                                    \
-+            y0 = (vector unsigned char)                                       \
-+                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
-                                                                               \
--            y1 = vec_xl(0, y2i);                                              \
-+            align_perm = vec_lvsl(0, y2i);                                    \
-+            y1 = (vector unsigned char)                                       \
-+                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
-                                                                               \
--            u = (vector signed char) vec_xl(0, ui);                           \
-+            align_perm = vec_lvsl(0, ui);                                     \
-+            u = (vector signed char)                                          \
-+                    vec_perm(uivP[0], uivP[1], align_perm);                   \
-                                                                               \
--            v = (vector signed char) vec_xl(0, vi);                           \
-+            align_perm = vec_lvsl(0, vi);                                     \
-+            v = (vector signed char)                                          \
-+                    vec_perm(vivP[0], vivP[1], align_perm);                   \
-                                                                               \
-             u = (vector signed char)                                          \
-                     vec_sub(u,                                                \
--- 
-2.27.0
-
diff --git a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
deleted file mode 100644
index 9a55178c74f0fd..00000000000000
--- a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
-+++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
-@@ -39,6 +39,15 @@
- #endif
- #include <fenv.h>
- 
-+#if (FE_ALL_EXCEPT == 0)
-+/* E.g. ARM soft float does not define these */
-+#define FE_INVALID    0
-+#define FE_DIVBYZERO  0
-+#define FE_OVERFLOW   0
-+#define FE_UNDERFLOW  0
-+#define FE_INEXACT    0
-+#endif
-+
- #if CONFIG_LIBFONTCONFIG
- #include <fontconfig/fontconfig.h>
- #endif
diff --git a/srcpkgs/ffmpeg/patches/binutils-2.41.patch b/srcpkgs/ffmpeg/patches/binutils-2.41.patch
deleted file mode 100644
index 53a596d0ee7d4e..00000000000000
--- a/srcpkgs/ffmpeg/patches/binutils-2.41.patch
+++ /dev/null
@@ -1,73 +0,0 @@
-From effadce6c756247ea8bae32dc13bb3e6f464f0eb Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= <remi@remlab.net>
-Date: Sun, 16 Jul 2023 18:18:02 +0300
-Subject: [PATCH] avcodec/x86/mathops: clip constants used with shift
- instructions within inline assembly
-
-Fixes assembling with binutil as >= 2.41
-
-Signed-off-by: James Almer <jamrial@gmail.com>
----
- libavcodec/x86/mathops.h | 26 +++++++++++++++++++++++---
- 1 file changed, 23 insertions(+), 3 deletions(-)
-
-diff --git a/libavcodec/x86/mathops.h b/libavcodec/x86/mathops.h
-index 6298f5ed1983b..ca7e2dffc1076 100644
---- a/libavcodec/x86/mathops.h
-+++ b/libavcodec/x86/mathops.h
-@@ -35,12 +35,20 @@
- static av_always_inline av_const int MULL(int a, int b, unsigned shift)
- {
-     int rt, dummy;
-+    if (__builtin_constant_p(shift))
-     __asm__ (
-         "imull %3               \n\t"
-         "shrdl %4, %%edx, %%eax \n\t"
-         :"=a"(rt), "=d"(dummy)
--        :"a"(a), "rm"(b), "ci"((uint8_t)shift)
-+        :"a"(a), "rm"(b), "i"(shift & 0x1F)
-     );
-+    else
-+        __asm__ (
-+            "imull %3               \n\t"
-+            "shrdl %4, %%edx, %%eax \n\t"
-+            :"=a"(rt), "=d"(dummy)
-+            :"a"(a), "rm"(b), "c"((uint8_t)shift)
-+        );
-     return rt;
- }
- 
-@@ -113,19 +121,31 @@ __asm__ volatile(\
- // avoid +32 for shift optimization (gcc should do that ...)
- #define NEG_SSR32 NEG_SSR32
- static inline  int32_t NEG_SSR32( int32_t a, int8_t s){
-+    if (__builtin_constant_p(s))
-     __asm__ ("sarl %1, %0\n\t"
-          : "+r" (a)
--         : "ic" ((uint8_t)(-s))
-+         : "i" (-s & 0x1F)
-     );
-+    else
-+        __asm__ ("sarl %1, %0\n\t"
-+               : "+r" (a)
-+               : "c" ((uint8_t)(-s))
-+        );
-     return a;
- }
- 
- #define NEG_USR32 NEG_USR32
- static inline uint32_t NEG_USR32(uint32_t a, int8_t s){
-+    if (__builtin_constant_p(s))
-     __asm__ ("shrl %1, %0\n\t"
-          : "+r" (a)
--         : "ic" ((uint8_t)(-s))
-+         : "i" (-s & 0x1F)
-     );
-+    else
-+        __asm__ ("shrl %1, %0\n\t"
-+               : "+r" (a)
-+               : "c" ((uint8_t)(-s))
-+        );
-     return a;
- }
- 
diff --git a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
deleted file mode 100644
index aa948f7a8a2dfb..00000000000000
--- a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
+++ /dev/null
@@ -1,40 +0,0 @@
-#==================================================================================================
-# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
-# From: Christopher Degawa <christopher.degawa@intel.com>
-# Date: Thu, 20 Oct 2022 22:55:27 -0500
-# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
-#
-# compressed_ten_bit_format has been deprecated upstream and has no effect
-# and can be removed. Plus, technically it was never used in the first place
-# since it would require the app (ffmpeg) to set it and do additional
-# processing of the input frames.
-#
-# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
-#
-# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
-#==================================================================================================
---- a/libavcodec/libsvtav1.c
-+++ b/libavcodec/libsvtav1.c
-@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
- 
- static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
- {
--    const int    pack_mode_10bit =
--        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
--    const size_t luma_size_8bit  =
--        config->source_width * config->source_height * (1 << pack_mode_10bit);
--    const size_t luma_size_10bit =
--        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
-+    const size_t luma_size = config->source_width * config->source_height *
-+        (config->encoder_bit_depth > 8 ? 2 : 1);
- 
-     EbSvtIOFormat *in_data;
- 
--    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
-+    svt_enc->raw_size = luma_size * 3 / 2;
- 
-     // allocate buffer for in and out
-     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
--- 
-GitLab
-
diff --git a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
deleted file mode 100644
index 00e3f68a415b84..00000000000000
--- a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
-From: Rainer Hochecker <fernetmenta@online.de>
-Date: Sat, 26 Jan 2019 19:48:35 +0100
-Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
-
-This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
-It was hit frequently when watching h264 channels received via DVB-X.
-Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
----
- libavcodec/vaapi_h264.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
-index 5854587a255..f12fdc457a4 100644
---- a/libavcodec/vaapi_h264.c
-+++ b/libavcodec/vaapi_h264.c
-@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
-     H264SliceContext *sl = &h->slice_ctx[0];
-     int ret;
- 
-+    if (pic->nb_slices == 0) {
-+        ret = AVERROR_INVALIDDATA;
-+        goto finish;
-+    }
-+
-     ret = ff_vaapi_decode_issue(avctx, pic);
-     if (ret < 0)
-         goto finish;
diff --git a/srcpkgs/ffmpeg/template b/srcpkgs/ffmpeg/template
index 1ebb436135938d..f1e4712c41d087 100644
--- a/srcpkgs/ffmpeg/template
+++ b/srcpkgs/ffmpeg/template
@@ -1,15 +1,15 @@
 # Template file for 'ffmpeg'
 # audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
 pkgname=ffmpeg
-version=4.4.4
-revision=6
+version=6.0.1
+revision=1
 short_desc="Decoding, encoding and streaming software"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="https://www.ffmpeg.org"
 changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
 distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
-checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+checksum=9b16b8731d78e596b4be0d720428ca42df642bb2d78342881ff7f5bc29fc9623
 
 hostmakedepends="pkg-config perl"
 makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
@@ -26,12 +26,13 @@ makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-deve
  $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
  $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
  $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
- $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers Vulkan-Tools Vulkan-ValidationLayers')
+ $(vopt_if onevpl 'oneVPL oneVPL-devel')
  $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
 depends="ffplay>=${version}_${revision}"
 
 build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
- dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec onevpl"
 build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
 desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
 desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
@@ -39,9 +40,13 @@ desc_option_sofa="Enable support for AES SOFA"
 desc_option_webp="Enable support for WebP"
 
 case "$XBPS_TARGET_MACHINE" in
-	i686*|x86_64*)
-		hostmakedepends+=" nasm"
+	i686*)
 		build_options_default+=" vaapi vdpau nvenc nvdec"
+		hostmakedepends+=" nasm"
+		;;
+	x86_64*)
+		hostmakedepends+=" nasm"
+		build_options_default+=" vaapi vdpau nvenc nvdec onevpl"
 		;;
 	ppc64*) build_options_default+=" vaapi vdpau";;
 	mips*) CFLAGS="-mnan=legacy";;
@@ -65,8 +70,6 @@ post_patch() {
 		ppc64le*) ;;
 		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
 	esac
-
-	vsed -i libavfilter/vf_libvmaf.c -e 's!/usr/local/share/model/\(vmaf_v0.6.1\).pkl!/usr/share/vmaf/\1.json!'
 }
 
 do_configure() {
@@ -115,18 +118,19 @@ do_configure() {
 		$(vopt_enable x265 libx265) \
 		$(vopt_enable v4l2 libv4l2) \
 		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
-		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		--enable-libbs2b --enable-libvidstab \
 		$(vopt_enable dav1d libdav1d) \
 		$(vopt_enable zimg libzimg) \
 		$(vopt_enable webp libwebp) \
 		$(vopt_enable sofa libmysofa) \
 		$(vopt_enable vulkan) \
+		$(vopt_enable onevpl libvpl) \
 		$(vopt_enable drm libdrm) \
 		$(vopt_enable svtav1 libsvtav1) \
 		$(vopt_enable srt libsrt) \
 		$(vopt_enable rist librist) \
-		$(vopt_if nvenc '--enable-nvenc') \
-		$(vopt_if nvdec '--enable-nvdec')
+		$(vopt_enable nvenc nvenc) \
+		$(vopt_enable nvdec nvdec)
 }
 
 do_build() {
@@ -153,10 +157,8 @@ libavdevice_package() {
 }
 
 libavresample_package() {
-	short_desc="FFmpeg audio resampling library"
-	pkg_install() {
-		vmove "usr/lib/libavresample.so.*"
-	}
+	short_desc="Package deprecated, removal needed"
+	build_style=meta
 }
 
 libavformat_package() {
@@ -210,15 +212,13 @@ ffmpeg-devel_package() {
 		libavfilter>=${version}_${revision}
 		libpostproc>=${version}_${revision}
 		libswscale>=${version}_${revision}
-		libswresample>=${version}_${revision}
-		libavresample>=${version}_${revision}"
+		libswresample>=${version}_${revision}"
 	short_desc+=" - development files"
-
+	conflicts="ffmpeg4-devel"
 	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
 		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
 		nostrip_files="/usr/lib/libavfilter.a"
 	fi
-
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig

From 3777cd88eb6e96892bd6ff2037bd5fad8365399a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:14 -0400
Subject: [PATCH 002/113] openshot: revbump for ffmpeg6

---
 srcpkgs/openshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openshot/template b/srcpkgs/openshot/template
index 8f47851eef354f..affb652a9d500a 100644
--- a/srcpkgs/openshot/template
+++ b/srcpkgs/openshot/template
@@ -1,7 +1,7 @@
 # Template file for 'openshot'
 pkgname=openshot
 version=3.0.0
-revision=2
+revision=3
 build_style=python3-module
 hostmakedepends="python3 python3-setuptools"
 makedepends="ffmpeg-devel python3-PyQt5"

From d2009a52e3136aa8230f6ec702074d0aa2006eeb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:36 -0400
Subject: [PATCH 003/113] sumo: revbump for ffmpeg6

---
 srcpkgs/sumo/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/sumo/template b/srcpkgs/sumo/template
index a3fe134aa5acc2..a730afa9fafa92 100644
--- a/srcpkgs/sumo/template
+++ b/srcpkgs/sumo/template
@@ -1,7 +1,7 @@
 # Template file for 'sumo'
 pkgname=sumo
 version=1.12.0
-revision=6
+revision=7
 build_style=cmake
 hostmakedepends="libgdal-tools pkg-config swig python3-setuptools"
 makedepends="python3-devel ffmpeg-devel fox-devel gl2ps-devel libgdal-devel

From ab1fd15c6db3ba5b5275699db920312f05318c12 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:56:22 -0400
Subject: [PATCH 004/113] New package: ffmpeg4-4.4.4.

---
 srcpkgs/ffmpeg4-devel                         |   1 +
 srcpkgs/ffmpeg4/files/altivec.patch           |  60 +++++
 .../patches/armv5tel-floating-point.patch     |  18 ++
 srcpkgs/ffmpeg4/patches/binutils-2.41.patch   |  73 ++++++
 ...h-libavcodec-libsvtav1-ten_bit_format.diff |  40 +++
 .../workaround-mesa-readeon-vaapi-bug.patch   |  28 +++
 srcpkgs/ffmpeg4/template                      | 234 ++++++++++++++++++
 srcpkgs/libavcodec4                           |   1 +
 srcpkgs/libavdevice4                          |   1 +
 srcpkgs/libavfilter4                          |   1 +
 srcpkgs/libavformat4                          |   1 +
 srcpkgs/libavresample4                        |   1 +
 srcpkgs/libavutil4                            |   1 +
 srcpkgs/libpostproc4                          |   1 +
 srcpkgs/libswresample4                        |   1 +
 srcpkgs/libswscale4                           |   1 +
 16 files changed, 463 insertions(+)
 create mode 120000 srcpkgs/ffmpeg4-devel
 create mode 100644 srcpkgs/ffmpeg4/files/altivec.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/binutils-2.41.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 create mode 100644 srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
 create mode 100644 srcpkgs/ffmpeg4/template
 create mode 120000 srcpkgs/libavcodec4
 create mode 120000 srcpkgs/libavdevice4
 create mode 120000 srcpkgs/libavfilter4
 create mode 120000 srcpkgs/libavformat4
 create mode 120000 srcpkgs/libavresample4
 create mode 120000 srcpkgs/libavutil4
 create mode 120000 srcpkgs/libpostproc4
 create mode 120000 srcpkgs/libswresample4
 create mode 120000 srcpkgs/libswscale4

diff --git a/srcpkgs/ffmpeg4-devel b/srcpkgs/ffmpeg4-devel
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/ffmpeg4-devel
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/ffmpeg4/files/altivec.patch b/srcpkgs/ffmpeg4/files/altivec.patch
new file mode 100644
index 00000000000000..9c57200463320e
--- /dev/null
+++ b/srcpkgs/ffmpeg4/files/altivec.patch
@@ -0,0 +1,60 @@
+revert some altivec specific change on all ppc* except ppc64le*
+
+q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
+conditionally, for ppc* but not ppc64le* (the new code is valid for
+POWER8 VSX which LE targets as a baseline but not BE)"
+
+
+This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
+---
+ libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
+ 1 file changed, 20 insertions(+), 4 deletions(-)
+
+diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
+index 536545293d..c1e2852adb 100644
+--- a/libswscale/ppc/yuv2rgb_altivec.c
++++ b/libswscale/ppc/yuv2rgb_altivec.c
+@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+     vector signed short R1, G1, B1;                                           \
+     vector unsigned char R, G, B;                                             \
+                                                                               \
++    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
++    vector unsigned char align_perm;                                          \
++                                                                              \
+     vector signed short lCY       = c->CY;                                    \
+     vector signed short lOY       = c->OY;                                    \
+     vector signed short lCRV      = c->CRV;                                   \
+@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
+                                                                               \
+         for (j = 0; j < w / 16; j++) {                                        \
+-            y0 = vec_xl(0, y1i);                                              \
++            y1ivP = (const vector unsigned char *) y1i;                       \
++            y2ivP = (const vector unsigned char *) y2i;                       \
++            uivP  = (const vector unsigned char *) ui;                        \
++            vivP  = (const vector unsigned char *) vi;                        \
++                                                                              \
++            align_perm = vec_lvsl(0, y1i);                                    \
++            y0 = (vector unsigned char)                                       \
++                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
+                                                                               \
+-            y1 = vec_xl(0, y2i);                                              \
++            align_perm = vec_lvsl(0, y2i);                                    \
++            y1 = (vector unsigned char)                                       \
++                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
+                                                                               \
+-            u = (vector signed char) vec_xl(0, ui);                           \
++            align_perm = vec_lvsl(0, ui);                                     \
++            u = (vector signed char)                                          \
++                    vec_perm(uivP[0], uivP[1], align_perm);                   \
+                                                                               \
+-            v = (vector signed char) vec_xl(0, vi);                           \
++            align_perm = vec_lvsl(0, vi);                                     \
++            v = (vector signed char)                                          \
++                    vec_perm(vivP[0], vivP[1], align_perm);                   \
+                                                                               \
+             u = (vector signed char)                                          \
+                     vec_sub(u,                                                \
+-- 
+2.27.0
+
diff --git a/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
new file mode 100644
index 00000000000000..9a55178c74f0fd
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
@@ -0,0 +1,18 @@
+--- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
++++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
+@@ -39,6 +39,15 @@
+ #endif
+ #include <fenv.h>
+ 
++#if (FE_ALL_EXCEPT == 0)
++/* E.g. ARM soft float does not define these */
++#define FE_INVALID    0
++#define FE_DIVBYZERO  0
++#define FE_OVERFLOW   0
++#define FE_UNDERFLOW  0
++#define FE_INEXACT    0
++#endif
++
+ #if CONFIG_LIBFONTCONFIG
+ #include <fontconfig/fontconfig.h>
+ #endif
diff --git a/srcpkgs/ffmpeg4/patches/binutils-2.41.patch b/srcpkgs/ffmpeg4/patches/binutils-2.41.patch
new file mode 100644
index 00000000000000..53a596d0ee7d4e
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/binutils-2.41.patch
@@ -0,0 +1,73 @@
+From effadce6c756247ea8bae32dc13bb3e6f464f0eb Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= <remi@remlab.net>
+Date: Sun, 16 Jul 2023 18:18:02 +0300
+Subject: [PATCH] avcodec/x86/mathops: clip constants used with shift
+ instructions within inline assembly
+
+Fixes assembling with binutil as >= 2.41
+
+Signed-off-by: James Almer <jamrial@gmail.com>
+---
+ libavcodec/x86/mathops.h | 26 +++++++++++++++++++++++---
+ 1 file changed, 23 insertions(+), 3 deletions(-)
+
+diff --git a/libavcodec/x86/mathops.h b/libavcodec/x86/mathops.h
+index 6298f5ed1983b..ca7e2dffc1076 100644
+--- a/libavcodec/x86/mathops.h
++++ b/libavcodec/x86/mathops.h
+@@ -35,12 +35,20 @@
+ static av_always_inline av_const int MULL(int a, int b, unsigned shift)
+ {
+     int rt, dummy;
++    if (__builtin_constant_p(shift))
+     __asm__ (
+         "imull %3               \n\t"
+         "shrdl %4, %%edx, %%eax \n\t"
+         :"=a"(rt), "=d"(dummy)
+-        :"a"(a), "rm"(b), "ci"((uint8_t)shift)
++        :"a"(a), "rm"(b), "i"(shift & 0x1F)
+     );
++    else
++        __asm__ (
++            "imull %3               \n\t"
++            "shrdl %4, %%edx, %%eax \n\t"
++            :"=a"(rt), "=d"(dummy)
++            :"a"(a), "rm"(b), "c"((uint8_t)shift)
++        );
+     return rt;
+ }
+ 
+@@ -113,19 +121,31 @@ __asm__ volatile(\
+ // avoid +32 for shift optimization (gcc should do that ...)
+ #define NEG_SSR32 NEG_SSR32
+ static inline  int32_t NEG_SSR32( int32_t a, int8_t s){
++    if (__builtin_constant_p(s))
+     __asm__ ("sarl %1, %0\n\t"
+          : "+r" (a)
+-         : "ic" ((uint8_t)(-s))
++         : "i" (-s & 0x1F)
+     );
++    else
++        __asm__ ("sarl %1, %0\n\t"
++               : "+r" (a)
++               : "c" ((uint8_t)(-s))
++        );
+     return a;
+ }
+ 
+ #define NEG_USR32 NEG_USR32
+ static inline uint32_t NEG_USR32(uint32_t a, int8_t s){
++    if (__builtin_constant_p(s))
+     __asm__ ("shrl %1, %0\n\t"
+          : "+r" (a)
+-         : "ic" ((uint8_t)(-s))
++         : "i" (-s & 0x1F)
+     );
++    else
++        __asm__ ("shrl %1, %0\n\t"
++               : "+r" (a)
++               : "c" ((uint8_t)(-s))
++        );
+     return a;
+ }
+ 
diff --git a/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
new file mode 100644
index 00000000000000..aa948f7a8a2dfb
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
@@ -0,0 +1,40 @@
+#==================================================================================================
+# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
+# From: Christopher Degawa <christopher.degawa@intel.com>
+# Date: Thu, 20 Oct 2022 22:55:27 -0500
+# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
+#
+# compressed_ten_bit_format has been deprecated upstream and has no effect
+# and can be removed. Plus, technically it was never used in the first place
+# since it would require the app (ffmpeg) to set it and do additional
+# processing of the input frames.
+#
+# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
+#
+# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
+#==================================================================================================
+--- a/libavcodec/libsvtav1.c
++++ b/libavcodec/libsvtav1.c
+@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
+ 
+ static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
+ {
+-    const int    pack_mode_10bit =
+-        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
+-    const size_t luma_size_8bit  =
+-        config->source_width * config->source_height * (1 << pack_mode_10bit);
+-    const size_t luma_size_10bit =
+-        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
++    const size_t luma_size = config->source_width * config->source_height *
++        (config->encoder_bit_depth > 8 ? 2 : 1);
+ 
+     EbSvtIOFormat *in_data;
+ 
+-    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
++    svt_enc->raw_size = luma_size * 3 / 2;
+ 
+     // allocate buffer for in and out
+     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
+-- 
+GitLab
+
diff --git a/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
new file mode 100644
index 00000000000000..00e3f68a415b84
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
@@ -0,0 +1,28 @@
+From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
+From: Rainer Hochecker <fernetmenta@online.de>
+Date: Sat, 26 Jan 2019 19:48:35 +0100
+Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
+
+This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
+It was hit frequently when watching h264 channels received via DVB-X.
+Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
+---
+ libavcodec/vaapi_h264.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
+index 5854587a255..f12fdc457a4 100644
+--- a/libavcodec/vaapi_h264.c
++++ b/libavcodec/vaapi_h264.c
+@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
+     H264SliceContext *sl = &h->slice_ctx[0];
+     int ret;
+ 
++    if (pic->nb_slices == 0) {
++        ret = AVERROR_INVALIDDATA;
++        goto finish;
++    }
++
+     ret = ff_vaapi_decode_issue(avctx, pic);
+     if (ret < 0)
+         goto finish;
diff --git a/srcpkgs/ffmpeg4/template b/srcpkgs/ffmpeg4/template
new file mode 100644
index 00000000000000..9ba14bdb8ddf32
--- /dev/null
+++ b/srcpkgs/ffmpeg4/template
@@ -0,0 +1,234 @@
+# Template file for 'ffmpeg4'
+# audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
+pkgname=ffmpeg4
+version=4.4.4
+revision=1
+short_desc="Decoding, encoding and streaming software - ffmpeg4 libraries only"
+maintainer="Orphaned <orphan@voidlinux.org>"
+license="GPL-3.0-or-later"
+homepage="https://www.ffmpeg.org"
+changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
+distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
+checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+
+hostmakedepends="pkg-config perl"
+makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
+ libXext-devel libXvMC-devel libxcb-devel lame-devel libtheora-devel
+ libvorbis-devel x264-devel xvidcore-devel jack-devel SDL2-devel
+ libcdio-paranoia-devel librtmp-devel libmodplug-devel gnutls-devel
+ speex-devel celt-devel harfbuzz-devel libass-devel opus-devel ocl-icd-devel
+ libbs2b-devel libvidstab-devel vmaf-devel $(vopt_if pulseaudio pulseaudio-devel)
+ $(vopt_if vaapi libva-devel) $(vopt_if vdpau libvdpau-devel)
+ $(vopt_if x265 x265-devel) $(vopt_if v4l2 v4l-utils-devel)
+ $(vopt_if fdk_aac fdk-aac-devel) $(vopt_if vpx libvpx-devel)
+ $(vopt_if aom libaom-devel) $(vopt_if sndio sndio-devel)
+ $(vopt_if dav1d libdav1d-devel) $(vopt_if zimg zimg-devel)
+ $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
+ $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
+ $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
+
+build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
+
+desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
+desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
+desc_option_sofa="Enable support for AES SOFA"
+desc_option_webp="Enable support for WebP"
+
+case "$XBPS_TARGET_MACHINE" in
+	i686*|x86_64*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau nvenc nvdec"
+			;;
+	ppc64*) build_options_default+=" vaapi vdpau";;
+	mips*) CFLAGS="-mnan=legacy";;
+esac
+
+if [ "$XBPS_TARGET_WORDSIZE" != "32" ]; then
+	build_options_default+=" svtav1"
+fi
+
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+fi
+
+_apply_patch() {
+	local args="$1" pname="$(basename $2)"
+
+	if [ ! -f ".${pname}_done" ]; then
+		patch -N $args -i $2
+		touch .${pname}_done
+	fi
+}
+
+post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64le*) ;;
+		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
+	esac
+
+	vsed -i libavfilter/vf_libvmaf.c -e 's!/usr/local/share/model/\(vmaf_v0.6.1\).pkl!/usr/share/vmaf/\1.json!'
+}
+
+do_configure() {
+	# Fix gcc on x86_64-musl only
+	if [ "$XBPS_TARGET_MACHINE" = "x86_64-musl" ]; then
+		vsed -i configure -e "s;_cflags_speed='-O3';_cflags_speed='-O2';"
+	fi
+
+	if [ "$CROSS_BUILD" ]; then
+		case "$XBPS_TARGET_MACHINE" in
+			arm*) _arch="arm";;
+			aarch64*) _arch="aarch64";;
+			mips*) _arch="mips";;
+			ppc64*) _arch="ppc64";;
+			ppc*) _arch="ppc";;
+			*) _arch="${XBPS_TARGET_MACHINE%%-musl}";;
+		esac
+
+		_args+=" --enable-cross-compile
+			--sysroot=$XBPS_CROSS_BASE
+			--cross-prefix=${XBPS_CROSS_TRIPLET}-
+			--target-os=linux --arch=${_arch}"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc|ppc-musl) _args+=" --disable-altivec";;
+	esac
+
+	if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+		_args+=" --extra-libs=-latomic"
+	fi
+
+	./configure --prefix=/usr --disable-debug --enable-gpl --enable-gnutls \
+		--disable-stripping \
+		--enable-libcdio --enable-version3 --enable-runtime-cpudetect \
+		--enable-libmp3lame --enable-libvorbis --enable-libxvid \
+		--enable-libx264 $(vopt_enable vpx libvpx) --enable-libtheora \
+		--enable-shared --enable-static --enable-libxcb \
+		$(vopt_enable pulseaudio libpulse) --enable-libfreetype --enable-libmodplug \
+		--enable-libspeex --enable-libcelt --enable-libass \
+		--enable-libopus --enable-librtmp --enable-libjack \
+		$(vopt_if fdk_aac '--enable-nonfree --enable-libfdk-aac') \
+		--disable-libopencore_amrnb --disable-libopencore_amrwb \
+		--disable-libopenjpeg \
+		--enable-postproc --enable-opencl ${_args} --enable-libvmaf ${_args} \
+		$(vopt_enable x265 libx265) \
+		$(vopt_enable v4l2 libv4l2) \
+		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
+		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		$(vopt_enable dav1d libdav1d) \
+		$(vopt_enable zimg libzimg) \
+		$(vopt_enable webp libwebp) \
+		$(vopt_enable sofa libmysofa) \
+		$(vopt_enable vulkan) \
+		$(vopt_enable drm libdrm) \
+		$(vopt_enable svtav1 libsvtav1) \
+		$(vopt_enable srt libsrt) \
+		$(vopt_enable rist librist) \
+		$(vopt_if nvenc '--enable-nvenc') \
+		$(vopt_if nvdec '--enable-nvdec')
+}
+
+do_build() {
+	make ${makejobs}
+	make doc/ff{mpeg,play}.1
+}
+
+do_install() {
+	make DESTDIR=${DESTDIR} install install-man
+	rm -rf ${DESTDIR}/usr/bin
+}
+
+libavcodec4_package() {
+	short_desc="FFmpeg codec library"
+	pkg_install() {
+		vmove "usr/lib/libavcodec.so.*"
+	}
+}
+
+libavdevice4_package() {
+	short_desc="FFmpeg device handling library"
+	pkg_install() {
+		vmove "usr/lib/libavdevice.so.*"
+	}
+}
+
+libavresample4_package() {
+	short_desc="FFmpeg audio resampling library"
+	pkg_install() {
+		vmove "usr/lib/libavresample.so.*"
+	}
+}
+
+libavformat4_package() {
+	short_desc="FFmpeg file format library"
+	pkg_install() {
+		vmove "usr/lib/libavformat.so.*"
+	}
+}
+
+libavutil4_package() {
+	short_desc="FFmpeg utility library"
+	pkg_install() {
+		vmove "usr/lib/libavutil.so.*"
+	}
+}
+
+libavfilter4_package() {
+	short_desc="FFmpeg audio/video filter library"
+	pkg_install() {
+		vmove "usr/lib/libavfilter.so.*"
+	}
+}
+
+libpostproc4_package() {
+	short_desc="FFmpeg video postprocessing library"
+	pkg_install() {
+		vmove "usr/lib/libpostproc.so.*"
+	}
+}
+
+libswscale4_package() {
+	short_desc="FFmpeg video scaling library"
+	pkg_install() {
+		vmove "usr/lib/libswscale.so.*"
+	}
+}
+
+libswresample4_package() {
+	short_desc="FFmpeg video resampling library"
+	pkg_install() {
+		vmove "usr/lib/libswresample.so.*"
+	}
+}
+
+ffmpeg4-devel_package() {
+	depends="
+		libavcodec4>=${version}_${revision}
+		libavdevice4>=${version}_${revision}
+		libavformat4>=${version}_${revision}
+		libavutil4>=${version}_${revision}
+		libavfilter4>=${version}_${revision}
+		libpostproc4>=${version}_${revision}
+		libswscale4>=${version}_${revision}
+		libswresample4>=${version}_${revision}
+		libavresample4>=${version}_${revision}"
+	short_desc+=" - development files"
+	conflicts="ffmpeg-devel"
+	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
+		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
+		nostrip_files="/usr/lib/libavfilter.a"
+	fi
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.a"
+		vmove "usr/lib/*.so"
+		vmove usr/share/ffmpeg/examples
+		vmove usr/share/man/man3
+	}
+}
diff --git a/srcpkgs/libavcodec4 b/srcpkgs/libavcodec4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavcodec4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavdevice4 b/srcpkgs/libavdevice4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavdevice4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavfilter4 b/srcpkgs/libavfilter4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavfilter4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavformat4 b/srcpkgs/libavformat4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavformat4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavresample4 b/srcpkgs/libavresample4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavutil4 b/srcpkgs/libavutil4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavutil4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libpostproc4 b/srcpkgs/libpostproc4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libpostproc4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswresample4 b/srcpkgs/libswresample4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libswresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswscale4 b/srcpkgs/libswscale4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libswscale4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file

From 93f6955ab3e9e41ec8d5ebdc46632ae9de472e4a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:04 -0400
Subject: [PATCH 005/113] opencv: update to 4.7.0.

---
 common/shlibs           | 104 ++++++++++++++++++++--------------------
 srcpkgs/opencv/template |   8 ++--
 2 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index c1c79647f63cac..e8b9e5e974fe73 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2070,58 +2070,58 @@ libcapstone.so.5 capstone-5.0.1_1
 libhavege.so.2 libhaveged-1.9.11_1
 libnih.so.1 libnih-1.0.3_1
 libnih-dbus.so.1 libnih-1.0.3_1
-libopencv_quality.so.406 libopencv-4.6.0_1
-libopencv_reg.so.406 libopencv-4.6.0_1
-libopencv_surface_matching.so.406 libopencv-4.6.0_1
-libopencv_xphoto.so.406 libopencv-4.6.0_1
-libopencv_freetype.so.406 libopencv-4.6.0_1
-libopencv_fuzzy.so.406 libopencv-4.6.0_1
-libopencv_hfs.so.406 libopencv-4.6.0_1
-libopencv_img_hash.so.406 libopencv-4.6.0_1
-libopencv_line_descriptor.so.406 libopencv-4.6.0_1
-libopencv_saliency.so.406 libopencv-4.6.0_1
-libopencv_structured_light.so.406 libopencv-4.6.0_1
-libopencv_aruco.so.406 libopencv-4.6.0_1
-libopencv_bgsegm.so.406 libopencv-4.6.0_1
-libopencv_bioinspired.so.406 libopencv-4.6.0_1
-libopencv_ccalib.so.406 libopencv-4.6.0_1
-libopencv_face.so.406 libopencv-4.6.0_1
-libopencv_tracking.so.406 libopencv-4.6.0_1
-libopencv_xfeatures2d.so.406 libopencv-4.6.0_1
-libopencv_optflow.so.406 libopencv-4.6.0_1
-libopencv_ximgproc.so.406 libopencv-4.6.0_1
-libopencv_plot.so.406 libopencv-4.6.0_1
-libopencv_text.so.406 libopencv-4.6.0_1
-libopencv_ml.so.406 libopencv-4.6.0_1
-libopencv_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn.so.406 libopencv-4.6.0_1
-libopencv_shape.so.406 libopencv-4.6.0_1
-libopencv_stitching.so.406 libopencv-4.6.0_1
-libopencv_photo.so.406 libopencv-4.6.0_1
-libopencv_video.so.406 libopencv-4.6.0_1
-libopencv_calib3d.so.406 libopencv-4.6.0_1
-libopencv_features2d.so.406 libopencv-4.6.0_1
-libopencv_flann.so.406 libopencv-4.6.0_1
-libopencv_highgui.so.406 libopencv-4.6.0_1
-libopencv_videoio.so.406 libopencv-4.6.0_1
-libopencv_imgcodecs.so.406 libopencv-4.6.0_1
-libopencv_imgproc.so.406 libopencv-4.6.0_1
-libopencv_core.so.406 libopencv-4.6.0_1
-libopencv_superres.so.406 libopencv-4.6.0_1
-libopencv_videostab.so.406 libopencv-4.6.0_1
-libopencv_gapi.so.406 libopencv-4.6.0_1
-libopencv_xobjdetect.so.406 libopencv-4.6.0_1
-libopencv_datasets.so.406 libopencv-4.6.0_1
-libopencv_dnn_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn_superres.so.406 libopencv-4.6.0_1
-libopencv_dpm.so.406 libopencv-4.6.0_1
-libopencv_phase_unwrapping.so.406 libopencv-4.6.0_1
-libopencv_stereo.so.406 libopencv-4.6.0_1
-libopencv_rapid.so.406 libopencv-4.6.0_1
-libopencv_intensity_transform.so.406 libopencv-4.6.0_1
-libopencv_alphamat.so.406 libopencv-4.6.0_1
-libopencv_barcode.so.406 libopencv-4.6.0_1
-libopencv_mcc.so.406 libopencv-4.6.0_1
+libopencv_quality.so.407 libopencv-4.7.0_1
+libopencv_reg.so.407 libopencv-4.7.0_1
+libopencv_surface_matching.so.407 libopencv-4.7.0_1
+libopencv_xphoto.so.407 libopencv-4.7.0_1
+libopencv_freetype.so.407 libopencv-4.7.0_1
+libopencv_fuzzy.so.407 libopencv-4.7.0_1
+libopencv_hfs.so.407 libopencv-4.7.0_1
+libopencv_img_hash.so.407 libopencv-4.7.0_1
+libopencv_line_descriptor.so.407 libopencv-4.7.0_1
+libopencv_saliency.so.407 libopencv-4.7.0_1
+libopencv_structured_light.so.407 libopencv-4.7.0_1
+libopencv_aruco.so.407 libopencv-4.7.0_1
+libopencv_bgsegm.so.407 libopencv-4.7.0_1
+libopencv_bioinspired.so.407 libopencv-4.7.0_1
+libopencv_ccalib.so.407 libopencv-4.7.0_1
+libopencv_face.so.407 libopencv-4.7.0_1
+libopencv_tracking.so.407 libopencv-4.7.0_1
+libopencv_xfeatures2d.so.407 libopencv-4.7.0_1
+libopencv_optflow.so.407 libopencv-4.7.0_1
+libopencv_ximgproc.so.407 libopencv-4.7.0_1
+libopencv_plot.so.407 libopencv-4.7.0_1
+libopencv_text.so.407 libopencv-4.7.0_1
+libopencv_ml.so.407 libopencv-4.7.0_1
+libopencv_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn.so.407 libopencv-4.7.0_1
+libopencv_shape.so.407 libopencv-4.7.0_1
+libopencv_stitching.so.407 libopencv-4.7.0_1
+libopencv_photo.so.407 libopencv-4.7.0_1
+libopencv_video.so.407 libopencv-4.7.0_1
+libopencv_calib3d.so.407 libopencv-4.7.0_1
+libopencv_features2d.so.407 libopencv-4.7.0_1
+libopencv_flann.so.407 libopencv-4.7.0_1
+libopencv_highgui.so.407 libopencv-4.7.0_1
+libopencv_videoio.so.407 libopencv-4.7.0_1
+libopencv_imgcodecs.so.407 libopencv-4.7.0_1
+libopencv_imgproc.so.407 libopencv-4.7.0_1
+libopencv_core.so.407 libopencv-4.7.0_1
+libopencv_superres.so.407 libopencv-4.7.0_1
+libopencv_videostab.so.407 libopencv-4.7.0_1
+libopencv_gapi.so.407 libopencv-4.7.0_1
+libopencv_xobjdetect.so.407 libopencv-4.7.0_1
+libopencv_datasets.so.407 libopencv-4.7.0_1
+libopencv_dnn_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn_superres.so.407 libopencv-4.7.0_1
+libopencv_dpm.so.407 libopencv-4.7.0_1
+libopencv_phase_unwrapping.so.407 libopencv-4.7.0_1
+libopencv_stereo.so.407 libopencv-4.7.0_1
+libopencv_rapid.so.407 libopencv-4.7.0_1
+libopencv_intensity_transform.so.407 libopencv-4.7.0_1
+libopencv_alphamat.so.407 libopencv-4.7.0_1
+libopencv_barcode.so.407 libopencv-4.7.0_1
+libopencv_mcc.so.407 libopencv-4.7.0_1
 libuniconf.so.4.6 wvstreams-4.6.1_20
 libwvbase.so.4.6 wvstreams-4.6.1_20
 libwvutils.so.4.6 wvstreams-4.6.1_20
diff --git a/srcpkgs/opencv/template b/srcpkgs/opencv/template
index aea4bfc3a265cf..ce94de9424d18d 100644
--- a/srcpkgs/opencv/template
+++ b/srcpkgs/opencv/template
@@ -1,7 +1,7 @@
 # Template file for 'opencv'
 pkgname=opencv
-version=4.6.0
-revision=6
+version=4.7.0
+revision=1
 create_wrksrc=yes
 build_wrksrc=${pkgname}-${version}
 build_style=cmake
@@ -24,8 +24,8 @@ homepage="https://opencv.org"
 changelog="https://github.com/opencv/opencv/wiki/ChangeLog"
 distfiles="https://github.com/opencv/opencv/archive/${version}.tar.gz
  https://github.com/opencv/opencv_contrib/archive/${version}.tar.gz>contrib.tar.gz"
-checksum="1ec1cba65f9f20fe5a41fda1586e01c70ea0c9a6d7b67c9e13edf0cfe2239277
- 1777d5fd2b59029cf537e5fd6f8aa68d707075822f90bde683fcde086f85f7a7"
+checksum="8df0079cdbe179748a18d44731af62a245a45ebf5085223dc03133954c662973
+ 42df840cf9055e59d0e22c249cfb19f04743e1bdad113d31b1573d3934d62584"
 patch_args="-Np1 -d ${build_wrksrc}"
 # tests hang indenfinitely, even with test data included
 make_check=no

From e9bbfb34c5f9c052bf076d98c70411bfc884122c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 006/113] actiona: revbump for opencv-4.7.0

---
 srcpkgs/actiona/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/actiona/template b/srcpkgs/actiona/template
index cf5f0b7a2ae610..0d899311e6df75 100644
--- a/srcpkgs/actiona/template
+++ b/srcpkgs/actiona/template
@@ -1,7 +1,7 @@
 # Template file for 'actiona'
 pkgname=actiona
 version=3.10.1
-revision=2
+revision=3
 build_style=qmake
 configure_args="PKGCONFIG_OPENCV=opencv4"
 hostmakedepends="pkg-config qt5-plugin-mysql qt5-qmake qt5-host-tools"

From 153e8ffd758e1d2bf5b4b9b5b5c3b4a84a61b1ff Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 007/113] retroshare: revbump for opencv-4.7.0

---
 srcpkgs/retroshare/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroshare/template b/srcpkgs/retroshare/template
index bb17569277a7f3..49e2c1cbe8a531 100644
--- a/srcpkgs/retroshare/template
+++ b/srcpkgs/retroshare/template
@@ -1,7 +1,7 @@
 # Template file for 'retroshare'
 pkgname=retroshare
 version=0.6.6
-revision=3
+revision=4
 build_style=qmake
 #XXX broadcast feature requires an ancient udp-discovery-cpp which either needs
 # to be fetched+patched (FTBFS) here or packaged :/

From 360f392dab24f2b478437eaa267beb57cfa6fd2b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 008/113] waifu2x-converter-cpp: revbump for opencv-4.7.0

---
 srcpkgs/waifu2x-converter-cpp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waifu2x-converter-cpp/template b/srcpkgs/waifu2x-converter-cpp/template
index 361b8a23b94977..c5ac17eb54ea4c 100644
--- a/srcpkgs/waifu2x-converter-cpp/template
+++ b/srcpkgs/waifu2x-converter-cpp/template
@@ -1,7 +1,7 @@
 # Template file for 'waifu2x-converter-cpp'
 pkgname=waifu2x-converter-cpp
 version=5.2.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DINSTALL_MODELS=ON"
 hostmakedepends="pkg-config"

From ebc4e576ffcb3fd0ea2860a7ada26449eafdc6a5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:38 -0400
Subject: [PATCH 009/113] vlc: revbump for ffmpeg4

---
 srcpkgs/vlc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/vlc/template b/srcpkgs/vlc/template
index bdd0cc414dc1a0..7d245a7b0019c0 100644
--- a/srcpkgs/vlc/template
+++ b/srcpkgs/vlc/template
@@ -1,7 +1,7 @@
 # Template file for 'vlc'
 pkgname=vlc
 version=3.0.20
-revision=3
+revision=4
 build_style=gnu-configure
 configure_args="--disable-gme --disable-libtar --enable-jack
  --enable-live555 --disable-fluidsynth --enable-dvdread
@@ -25,7 +25,7 @@ lib32disabled=yes
 hostmakedepends="automake libtool pkg-config flex gettext libgcrypt-devel
  live555-devel gettext-devel $(vopt_if lua lua52) $(vopt_if chromecast protobuf)"
 makedepends="
- avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg-devel freefont-ttf
+ avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg4-devel freefont-ttf
  gnutls-devel jack-devel liba52-devel libass-devel libbluray-devel
  libcdio-devel libdca-devel libdvbpsi-devel libdvdnav-devel libmad-devel
  libmatroska-devel libmodplug-devel libmpcdec-devel libmpeg2-devel

From 72db5b3bb337723ee320177f76a8c88ff226232d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:55 -0400
Subject: [PATCH 010/113] osg: revbump for ffmpeg4

---
 srcpkgs/osg/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/osg/template b/srcpkgs/osg/template
index a9ebbd287933bd..a131ceaf7a867b 100644
--- a/srcpkgs/osg/template
+++ b/srcpkgs/osg/template
@@ -1,14 +1,14 @@
 # Template file for 'osg'
 pkgname=osg
 version=3.6.5
-revision=2
+revision=3
 build_style=cmake
 build_helper="qemu"
 # don't use /usr/lib64 on 64bit platforms
 configure_args="-DLIB_POSTFIX="
 hostmakedepends="pkg-config xrandr"
 makedepends="MesaLib-devel gtkglext-devel libcurl-devel giflib-devel librsvg-devel
- jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg-devel xine-lib-devel
+ jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg4-devel xine-lib-devel
  SDL2-devel gst-plugins-base1-devel
  $(vopt_if openexr libopenexr-devel)
  $(vopt_if poppler poppler-glib-devel)

From a9a23d96ce2653c4071563bf2b990d29314cf2b7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:13 -0400
Subject: [PATCH 011/113] xine-lib: revbump for ffmpeg4

---
 srcpkgs/xine-lib/template | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/xine-lib/template b/srcpkgs/xine-lib/template
index 3be4d08eac77a3..ed6194c17d11e8 100644
--- a/srcpkgs/xine-lib/template
+++ b/srcpkgs/xine-lib/template
@@ -1,14 +1,14 @@
 # Template file for 'xine-lib'
 pkgname=xine-lib
-version=1.2.12
-revision=3
+version=1.2.13
+revision=1
 build_style=gnu-configure
 configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
  --disable-oss"
 hostmakedepends="automake gettext-devel libtool pkg-config perl"
 makedepends="
  zlib-devel alsa-lib-devel libxcb-devel libSM-devel libXext-devel libXv-devel
- libXvMC-devel liba52-devel libmad-devel ffmpeg-devel pulseaudio-devel
+ libXvMC-devel liba52-devel libmad-devel ffmpeg4-devel pulseaudio-devel
  jack-devel samba-devel libflac-devel libmodplug-devel libmpcdec-devel
  speex-devel libtheora-devel libvorbis-devel libdca-devel faad2-devel
  libcdio-devel libbluray-devel aalib-devel libcaca-devel libXinerama-devel
@@ -19,7 +19,7 @@ license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="http://www.xine-project.org"
 changelog="https://sourceforge.net/projects/xine/files/xine-lib/${version}/README.txt/view"
 distfiles="${SOURCEFORGE_SITE}/xine/${pkgname}-${version}.tar.xz"
-checksum=d606270468e1540c2a89c0d7f5fdf11e17ecc0c2698cc0bcb1065ff26abee098
+checksum=5f10d6d718a4a51c17ed1b32b031d4f9b80b061e8276535b2be31e5ac4b75e6f
 
 case "$XBPS_TARGET_MACHINE" in
 	i686-musl)

From a274e0c032182d62783573a221ede3fccc03f99b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 012/113] attract: revbump for ffmpeg4

---
 srcpkgs/attract/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/attract/template b/srcpkgs/attract/template
index 24017d2bacc24d..0edc2a16a2e611 100644
--- a/srcpkgs/attract/template
+++ b/srcpkgs/attract/template
@@ -1,12 +1,12 @@
 # Template file for 'attract'
 pkgname=attract
 version=2.6.2
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="VERBOSE=1"
 make_use_env=yes
 hostmakedepends="pkg-config"
-makedepends="SFML-devel ffmpeg-devel fontconfig-devel glu-devel libarchive-devel
+makedepends="SFML-devel ffmpeg4-devel fontconfig-devel glu-devel libarchive-devel
  libcurl-devel libjpeg-turbo-devel xine-lib rapidjson libXrandr-devel"
 depends="git"
 short_desc="Attract-Mode is a graphical frontend for emulators"

From 95ee024965cc24a231bb430ba1bf6ae5e78e5752 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 013/113] aubio: revbump for ffmpeg6

---
 srcpkgs/aubio/patches/ffmpeg5.patch | 25 +++++++++++++++++++++++++
 srcpkgs/aubio/template              |  2 +-
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/aubio/patches/ffmpeg5.patch

diff --git a/srcpkgs/aubio/patches/ffmpeg5.patch b/srcpkgs/aubio/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..aace41a6e6d9a4
--- /dev/null
+++ b/srcpkgs/aubio/patches/ffmpeg5.patch
@@ -0,0 +1,25 @@
+From 8a05420e5dd8c7b8b2447f82dc919765876511b3 Mon Sep 17 00:00:00 2001
+From: Paul Brossier <piem@piem.org>
+Date: Tue, 25 Jan 2022 18:30:27 +0100
+Subject: [PATCH] [source_avcodec] define FF_API_LAVF_AVCTX for libavcodec >
+ 59, thx @berolinux (closes gh-353)
+
+---
+ src/io/source_avcodec.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/io/source_avcodec.c b/src/io/source_avcodec.c
+index e0ae93b5..1421bd9a 100644
+--- a/src/io/source_avcodec.c
++++ b/src/io/source_avcodec.c
+@@ -68,6 +68,10 @@
+ #define AUBIO_AVCODEC_MAX_BUFFER_SIZE AV_INPUT_BUFFER_MIN_SIZE
+ #endif
+ 
++#if LIBAVCODEC_VERSION_MAJOR >= 59
++#define FF_API_LAVF_AVCTX 1
++#endif
++
+ struct _aubio_source_avcodec_t {
+   uint_t hop_size;
+   uint_t samplerate;
diff --git a/srcpkgs/aubio/template b/srcpkgs/aubio/template
index ad1c4b25699178..7d875cc02541a7 100644
--- a/srcpkgs/aubio/template
+++ b/srcpkgs/aubio/template
@@ -1,7 +1,7 @@
 # Template file for 'aubio'
 pkgname=aubio
 version=0.4.9
-revision=1
+revision=2
 build_style=waf3
 # XXX lash, pure and swig support.
 hostmakedepends="pkg-config txt2man"

From 79a26422f68492780f1170f36457127b9840d730 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 014/113] audacious-plugins: revbump for ffmpeg6

---
 .../audacious-plugins/patches/ffmpeg5.patch   | 43 +++++++++++++++++++
 srcpkgs/audacious-plugins/template            |  2 +-
 2 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/audacious-plugins/patches/ffmpeg5.patch

diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg5.patch b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..4e5e34099d71c4
--- /dev/null
+++ b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
@@ -0,0 +1,43 @@
+commit 298aa371c56c2f52c25a33d9bdec4918b11cebdc
+Author: tibequadorian <tibequadorian@posteo.de>
+Date:   Sat Mar 19 18:40:12 2022 +0100
+
+    audacious-plugins: rebuild against ffmpeg-5.0
+
+diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+new file mode 100644
+index 0000000000..617c11215b
+--- /dev/null
++++ b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+@@ -0,0 +1,31 @@
++From f60beb400eeb1e4778bbfd738bc4a4ccef3de539 Mon Sep 17 00:00:00 2001
++From: John Lindgren <john@jlindgren.net>
++Date: Sat, 5 Mar 2022 12:05:34 -0500
++Subject: [PATCH] Fix build with FFmpeg 5.0
++
++---
++ src/ffaudio/ffaudio-core.cc | 4 ++--
++ 1 file changed, 2 insertions(+), 2 deletions(-)
++
++diff --git a/src/ffaudio/ffaudio-core.cc b/src/ffaudio/ffaudio-core.cc
++index 16dc63e3a..a2b95fd6c 100644
++--- a/src/ffaudio/ffaudio-core.cc
+++++ b/src/ffaudio/ffaudio-core.cc
++@@ -274,7 +274,7 @@ static AVInputFormat * get_format_by_content (const char * name, VFSFile & file)
++         AVProbeData d = {name, buf, filled};
++         score = target;
++ 
++-        f = av_probe_input_format2 (& d, true, & score);
+++        f = (AVInputFormat *) av_probe_input_format2 (& d, true, & score);
++         if (f)
++             break;
++ 
++@@ -347,7 +347,7 @@ static bool find_codec (AVFormatContext * c, CodecInfo * cinfo)
++ #endif
++         if (stream && stream->codecpar && stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
++         {
++-            AVCodec * codec = avcodec_find_decoder (stream->codecpar->codec_id);
+++            AVCodec * codec = (AVCodec *) avcodec_find_decoder (stream->codecpar->codec_id);
++ 
++             if (codec)
++             {
diff --git a/srcpkgs/audacious-plugins/template b/srcpkgs/audacious-plugins/template
index 05e53a9adf78ff..4b1968e03de781 100644
--- a/srcpkgs/audacious-plugins/template
+++ b/srcpkgs/audacious-plugins/template
@@ -2,7 +2,7 @@
 #Keep in sync with audacious!
 pkgname=audacious-plugins
 version=4.3.1
-revision=3
+revision=4
 build_style=meson
 configure_args="$(vopt_bool gtk3 gtk) $(vopt_bool gtk3)
  $(vopt_bool qt) $(vopt_bool qt qt6)"

From 314569394aa63f4358c71bd7980cd12e4be04f97 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 015/113] audacity: revbump for ffmpeg6

---
 srcpkgs/audacity/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/audacity/template b/srcpkgs/audacity/template
index 7b838119ab2611..84b49305edcef1 100644
--- a/srcpkgs/audacity/template
+++ b/srcpkgs/audacity/template
@@ -1,7 +1,7 @@
 # Template file for 'audacity'
 pkgname=audacity
 version=3.4.2
-revision=1
+revision=2
 build_style=cmake
 build_helper="cmake-wxWidgets-gtk3 qemu"
 configure_args="-Daudacity_use_ffmpeg=loaded -Daudacity_lib_preference=system

From c6b346fcdaaebfb119f41e88210203bd6b163a2c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 016/113] avidemux: revbump for ffmpeg6

---
 srcpkgs/avidemux/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/avidemux/template b/srcpkgs/avidemux/template
index 253a0243e22599..557285982d2b8f 100644
--- a/srcpkgs/avidemux/template
+++ b/srcpkgs/avidemux/template
@@ -1,7 +1,7 @@
 # Template file for 'avidemux'
 pkgname=avidemux
 version=2.8.0
-revision=2
+revision=3
 # Can't be compiled for aarch64, arm* or mips*
 archs="x86_64* i686*"
 hostmakedepends="cmake pkg-config qt5-host-tools qt5-devel tar yasm"

From 30fda1b1ff8a1470f2f52fb32974a4292e64fda7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 017/113] blender: revbump for ffmpeg6

---
 srcpkgs/blender/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index 1dc61ec9d29d84..e238717ac8c729 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -1,7 +1,7 @@
 # Template file for 'blender'
 pkgname=blender
 version=4.0.2
-revision=1
+revision=2
 archs="x86_64* ppc64*"
 build_style="cmake"
 pycompile_dirs="usr/share/blender/${version%.*}/scripts"
@@ -9,8 +9,8 @@ configure_args="-DWITH_INSTALL_PORTABLE=OFF -DWITH_PYTHON_INSTALL=OFF
  -DWITH_JACK=ON -DWITH_CODEC_FFMPEG=ON -DWITH_CODEC_SNDFILE=ON -DWITH_OPENMP=ON
  -DWITH_FFTW3=ON -DWITH_MOD_OCEANSIM=ON -DWITH_CYCLES_EMBREE=OFF -DWITH_OPENCOLORIO=ON
  -DWITH_IMAGE_OPENEXR=ON -DWITH_IMAGE_OPENJPEG=ON -DWITH_OPENSUBDIV=ON
- -DWITH_OPENCOLLADA=ON -DWITH_SYSTEM_GLEW=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
- -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_LIBDECOR=ON
+ -DWITH_OPENCOLLADA=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
+ -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_WAYLAND_LIBDECOR=ON
  -DWITH_BUILDINFO=OFF -DPYTHON_VERSION=${py3_ver} -DPYTHON_LIBPATH=/usr/lib
  -DPYTHON_LIBRARY=python${py3_ver}${py3_abiver} -DPYTHON_INCLUDE_DIRS=/${py3_inc}
  -DWITH_SYSTEM_LZO=ON -DWITH_SYSTEM_EIGEN3=ON -DWITH_SYSTEM_FREETYPE=ON"

From 8b32fa7bc0c609e01fb497261cc8e52eaf06e605 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 018/113] cantata: revbump for ffmpeg6

---
 srcpkgs/cantata/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cantata/template b/srcpkgs/cantata/template
index 4b417d80d5c2da..8a90aaa4c07a2a 100644
--- a/srcpkgs/cantata/template
+++ b/srcpkgs/cantata/template
@@ -1,7 +1,7 @@
 # Template file for 'cantata'
 pkgname=cantata
 version=2.5.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools qt5-tools"
 makedepends="qt5-devel qt5-tools-devel qt5-svg-devel qt5-xmlpatterns-devel

From 2833ad816cd9e59237481acd99ff1c372b618b6a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 019/113] ccextractor: revbump for ffmpeg4

---
 srcpkgs/ccextractor/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/ccextractor/template b/srcpkgs/ccextractor/template
index 84059ffd02398a..28239189a6e3cf 100644
--- a/srcpkgs/ccextractor/template
+++ b/srcpkgs/ccextractor/template
@@ -1,12 +1,12 @@
 # Template file for 'ccextractor'
 pkgname=ccextractor
 version=0.93
-revision=2
+revision=3
 build_wrksrc="linux"
 build_style=gnu-configure
 configure_args="--enable-ocr --enable-hardsubx"
 hostmakedepends="automake pkg-config"
-makedepends="leptonica-devel tesseract-ocr-devel ffmpeg-devel"
+makedepends="leptonica-devel tesseract-ocr-devel ffmpeg4-devel"
 short_desc="Extract subtitles from video streams"
 maintainer="newbluemoon <blaumolch@mailbox.org>"
 license="GPL-2.0-or-later"

From bb086f481a4d9445ee49f5edb1dd810638bfedab Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 020/113] chromaprint: revbump for ffmpeg6

---
 srcpkgs/chromaprint/patches/ffmpeg5.patch | 569 ++++++++++++++++++++++
 srcpkgs/chromaprint/template              |   2 +-
 2 files changed, 570 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromaprint/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromaprint/patches/ffmpeg5.patch b/srcpkgs/chromaprint/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..a9fd307a23c8a4
--- /dev/null
+++ b/srcpkgs/chromaprint/patches/ffmpeg5.patch
@@ -0,0 +1,569 @@
+From 8ccad6937177b1b92e40ab8f4447ea27bac009a7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= <lalinsky@gmail.com>
+Date: Fri, 4 Nov 2022 21:47:38 +0100
+Subject: [PATCH] Use FFmpeg 5.x (#120)
+
+* Use FFmpeg 5.1.2 for CI builds
+
+* Build on Ubuntu 20.04
+
+* Upgrade code to FFmpeg 5.x APIs
+
+* Only set FFmpeg include dirs if building tools
+
+* No longer needed
+
+* Use ubuntu 20.04
+---
+ .github/workflows/build.yml                   |   6 +-
+ CMakeLists.txt                                |  16 --
+ package/build.sh                              |   4 +-
+ src/audio/ffmpeg_audio_processor.h            |   2 -
+ src/audio/ffmpeg_audio_processor_avresample.h |  72 -------
+ src/audio/ffmpeg_audio_processor_swresample.h |  18 +-
+ src/audio/ffmpeg_audio_reader.h               | 197 +++++++++---------
+ tests/CMakeLists.txt                          |   6 +
+ 8 files changed, 122 insertions(+), 199 deletions(-)
+ delete mode 100644 src/audio/ffmpeg_audio_processor_avresample.h
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index f8d6a32..4da2405 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -84,9 +84,6 @@ find_package(FFmpeg)
+ if(FFMPEG_LIBRARIES)
+ 	cmake_push_check_state(RESET)
+ 	set(CMAKE_REQUIRED_LIBRARIES ${FFMPEG_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -lm)
+-	check_function_exists(av_packet_unref HAVE_AV_PACKET_UNREF)
+-	check_function_exists(av_frame_alloc HAVE_AV_FRAME_ALLOC)
+-	check_function_exists(av_frame_free HAVE_AV_FRAME_FREE)
+ 	cmake_pop_check_state()
+ endif()
+
+@@ -163,14 +160,11 @@ message(STATUS "Using ${FFT_LIB} for FFT calculations")
+ if(NOT AUDIO_PROCESSOR_LIB)
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+ 		set(AUDIO_PROCESSOR_LIB "swresample")
+-	elseif(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(AUDIO_PROCESSOR_LIB "avresample")
+ 	endif()
+ endif()
+
+ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE OFF)
+ 		set(USE_SWRESAMPLE ON)
+ 		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBSWRESAMPLE_LIBRARIES})
+ 		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBSWRESAMPLE_INCLUDE_DIRS})
+@@ -178,16 +172,6 @@ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+ 	endif()
+ 	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+-elseif(AUDIO_PROCESSOR_LIB STREQUAL "avresample")
+-	if(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE ON)
+-		set(USE_SWRESAMPLE OFF)
+-		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBAVRESAMPLE_LIBRARIES})
+-		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBAVRESAMPLE_INCLUDE_DIRS})
+-	else()
+-		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+-	endif()
+-	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+ else()
+ 	message(STATUS "Building without audio conversion support, please install FFmpeg with libswresample")
+ endif()
+diff --git a/package/build.sh b/package/build.sh
+index da631ae..b41d36e 100755
+--- a/package/build.sh
++++ b/package/build.sh
+@@ -7,8 +7,8 @@ set -eux
+
+ BASE_DIR=$(cd $(dirname $0)/.. && pwd)
+
+-FFMPEG_VERSION=4.4.1
+-FFMPEG_BUILD_TAG=v4.4.1-1
++FFMPEG_VERSION=5.1.2
++FFMPEG_BUILD_TAG=v${FFMPEG_VERSION}-1
+
+ TMP_BUILD_DIR=$BASE_DIR/$(mktemp -d build.XXXXXXXX)
+ trap 'rm -rf $TMP_BUILD_DIR' EXIT
+diff --git a/src/audio/ffmpeg_audio_processor.h b/src/audio/ffmpeg_audio_processor.h
+index 7628fc7..39f4f6d 100644
+--- a/src/audio/ffmpeg_audio_processor.h
++++ b/src/audio/ffmpeg_audio_processor.h
+@@ -10,8 +10,6 @@
+
+ #if defined(USE_SWRESAMPLE)
+ #include "audio/ffmpeg_audio_processor_swresample.h"
+-#elif defined(USE_AVRESAMPLE)
+-#include "audio/ffmpeg_audio_processor_avresample.h"
+ #else
+ #error "no audio processing library"
+ #endif
+diff --git a/src/audio/ffmpeg_audio_processor_avresample.h b/src/audio/ffmpeg_audio_processor_avresample.h
+deleted file mode 100644
+index bd85f92..0000000
+--- a/src/audio/ffmpeg_audio_processor_avresample.h
++++ /dev/null
+@@ -1,72 +0,0 @@
+-// Copyright (C) 2016  Lukas Lalinsky
+-// Distributed under the MIT license, see the LICENSE file for details.
+-
+-#ifndef CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-#define CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-
+-extern "C" {
+-#include <libavresample/avresample.h>
+-}
+-
+-namespace chromaprint {
+-
+-class FFmpegAudioProcessor {
+-public:
+-	FFmpegAudioProcessor() {
+-		m_resample_ctx = avresample_alloc_context();
+-	}
+-
+-	~FFmpegAudioProcessor() {
+-		avresample_free(&m_resample_ctx);
+-	}
+-
+-	void SetCompatibleMode() {
+-		av_opt_set_int(m_resample_ctx, "filter_size", 16, 0);
+-		av_opt_set_int(m_resample_ctx, "phase_shift", 8, 0);
+-		av_opt_set_int(m_resample_ctx, "linear_interp", 1, 0);
+-		av_opt_set_double(m_resample_ctx, "cutoff", 0.8, 0);
+-	}
+-
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "in_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_rate", sample_rate, 0);
+-	}
+-
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "out_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_rate, 0);
+-	}
+-
+-	int Init() {
+-		return avresample_open(m_resample_ctx);
+-	}
+-
+-	int Convert(uint8_t **out, int out_count, const uint8_t **in, int in_count) {
+-		return avresample_convert(m_resample_ctx, out, 0, out_count, (uint8_t **) in, 0, in_count);
+-	}
+-
+-	int Flush(uint8_t **out, int out_count) {
+-		return avresample_read(m_resample_ctx, out, out_count);
+-	}
+-
+-private:
+-	AVAudioResampleContext *m_resample_ctx = nullptr;
+-};
+-
+-}; // namespace chromaprint
+-
+-#endif
+diff --git a/src/audio/ffmpeg_audio_processor_swresample.h b/src/audio/ffmpeg_audio_processor_swresample.h
+index b86266b..b1d4bea 100644
+--- a/src/audio/ffmpeg_audio_processor_swresample.h
++++ b/src/audio/ffmpeg_audio_processor_swresample.h
+@@ -28,30 +28,28 @@ public:
+ 		av_opt_set_double(m_swr_ctx, "cutoff", 0.8, 0);
+ 	}
+
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "icl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "ich", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetInputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "in_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "isf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "in_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "isr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "in_sample_rate", sample_rate, 0);
+ 	}
+
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "ocl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "och", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetOutputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "out_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "osf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "out_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "osr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "out_sample_rate", sample_rate, 0);
+ 	}
+
+ 	int Init() {
+diff --git a/src/audio/ffmpeg_audio_reader.h b/src/audio/ffmpeg_audio_reader.h
+index 5550164..1c6b346 100644
+--- a/src/audio/ffmpeg_audio_reader.h
++++ b/src/audio/ffmpeg_audio_reader.h
+@@ -62,7 +62,7 @@ public:
+ 	bool Read(const int16_t **data, size_t *size);
+
+ 	bool IsOpen() const { return m_opened; }
+-	bool IsFinished() const { return m_finished && !m_got_frame; }
++	bool IsFinished() const { return !m_has_more_packets && !m_has_more_frames; }
+
+ 	std::string GetError() const { return m_error; }
+ 	int GetErrorCode() const { return m_error_code; }
+@@ -74,20 +74,19 @@ private:
+ 	uint8_t *m_convert_buffer[1] = { nullptr };
+ 	int m_convert_buffer_nb_samples = 0;
+
+-	AVInputFormat *m_input_fmt = nullptr;
++	const AVInputFormat *m_input_fmt = nullptr;
+ 	AVDictionary *m_input_opts = nullptr;
+
+ 	AVFormatContext *m_format_ctx = nullptr;
+ 	AVCodecContext *m_codec_ctx = nullptr;
+-	AVFrame *m_frame = nullptr;
+ 	int m_stream_index = -1;
+ 	std::string m_error;
+ 	int m_error_code = 0;
+-	bool m_finished = false;
+ 	bool m_opened = false;
+-	int m_got_frame = 0;
+-	AVPacket m_packet;
+-	AVPacket m_packet0;
++	bool m_has_more_packets = true;
++	bool m_has_more_frames = true;
++	AVPacket *m_packet = nullptr;
++	AVFrame *m_frame = nullptr;
+
+ 	int m_output_sample_rate = 0;
+ 	int m_output_channels = 0;
+@@ -98,19 +97,12 @@ private:
+
+ inline FFmpegAudioReader::FFmpegAudioReader() {
+ 	av_log_set_level(AV_LOG_QUIET);
+-
+-	av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
+ }
+
+ inline FFmpegAudioReader::~FFmpegAudioReader() {
+ 	Close();
+ 	av_dict_free(&m_input_opts);
+ 	av_freep(&m_convert_buffer[0]);
+-	av_packet_unref(&m_packet0);
+ }
+
+ inline bool FFmpegAudioReader::SetInputFormat(const char *name) {
+@@ -135,11 +127,10 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ 	Close();
+
+-    av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
++	m_packet = av_packet_alloc();
++	if (!m_packet) {
++		return false;
++	}
+
+ 	ret = avformat_open_input(&m_format_ctx, file_name.c_str(), m_input_fmt, &m_input_opts);
+ 	if (ret < 0) {
+@@ -153,26 +144,31 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		return false;
+ 	}
+
+-	AVCodec *codec;
++	const AVCodec *codec;
+ 	ret = av_find_best_stream(m_format_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &codec, 0);
+ 	if (ret < 0) {
+ 		SetError("Could not find any audio stream in the file", ret);
+ 		return false;
+ 	}
+ 	m_stream_index = ret;
++	auto stream = m_format_ctx->streams[m_stream_index];
+
+-	m_codec_ctx = m_format_ctx->streams[m_stream_index]->codec;
++	m_codec_ctx = avcodec_alloc_context3(codec);
+ 	m_codec_ctx->request_sample_fmt = AV_SAMPLE_FMT_S16;
+
++	ret = avcodec_parameters_to_context(m_codec_ctx, stream->codecpar);
++	if (ret < 0) {
++		SetError("Could not copy the stream parameters", ret);
++		return false;
++	}
++
+ 	ret = avcodec_open2(m_codec_ctx, codec, nullptr);
+ 	if (ret < 0) {
+ 		SetError("Could not open the codec", ret);
+ 		return false;
+ 	}
+
+-	if (!m_codec_ctx->channel_layout) {
+-		m_codec_ctx->channel_layout = av_get_default_channel_layout(m_codec_ctx->channels);
+-	}
++	av_dump_format(m_format_ctx, 0, "foo", 0);
+
+ 	m_frame = av_frame_alloc();
+ 	if (!m_frame) {
+@@ -183,19 +179,23 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		m_output_sample_rate = m_codec_ctx->sample_rate;
+ 	}
+
+-	if (!m_output_channels) {
+-		m_output_channels = m_codec_ctx->channels;
++	AVChannelLayout output_channel_layout;
++	if (m_output_channels) {
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
++	} else {
++		m_output_channels = m_codec_ctx->ch_layout.nb_channels;
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
+ 	}
+
+-	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
++	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->ch_layout.nb_channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
+ 		m_converter.reset(new FFmpegAudioProcessor());
+ 		m_converter->SetCompatibleMode();
+ 		m_converter->SetInputSampleFormat(m_codec_ctx->sample_fmt);
+ 		m_converter->SetInputSampleRate(m_codec_ctx->sample_rate);
+-		m_converter->SetInputChannelLayout(m_codec_ctx->channel_layout);
++		m_converter->SetInputChannelLayout(&(m_codec_ctx->ch_layout));
+ 		m_converter->SetOutputSampleFormat(AV_SAMPLE_FMT_S16);
+ 		m_converter->SetOutputSampleRate(m_output_sample_rate);
+-		m_converter->SetOutputChannelLayout(av_get_default_channel_layout(m_output_channels));
++		m_converter->SetOutputChannelLayout(&output_channel_layout);
+ 		auto ret = m_converter->Init();
+ 		if (ret != 0) {
+ 			SetError("Could not create an audio converter instance", ret);
+@@ -203,10 +203,11 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		}
+ 	}
+
++	av_channel_layout_uninit(&output_channel_layout);
++
+ 	m_opened = true;
+-	m_finished = false;
+-	m_got_frame = 0;
+-	m_nb_packets = 0;
++	m_has_more_packets = true;
++	m_has_more_frames = true;
+ 	m_decode_error = 0;
+
+ 	return true;
+@@ -214,6 +215,7 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ inline void FFmpegAudioReader::Close() {
+ 	av_frame_free(&m_frame);
++	av_packet_free(&m_packet);
+
+ 	m_stream_index = -1;
+
+@@ -252,91 +254,98 @@ inline bool FFmpegAudioReader::Read(const int16_t **data, size_t *size) {
+ 		return false;
+ 	}
+
++	*data = nullptr;
++	*size = 0;
++
+ 	int ret;
++	bool needs_packet = false;
+ 	while (true) {
+-		while (m_packet.size <= 0) {
+-			av_packet_unref(&m_packet0);
+-			av_init_packet(&m_packet);
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			ret = av_read_frame(m_format_ctx, &m_packet);
++		while (needs_packet && m_packet->size == 0) {
++			ret = av_read_frame(m_format_ctx, m_packet);
+ 			if (ret < 0) {
+ 				if (ret == AVERROR_EOF) {
+-					m_finished = true;
++					needs_packet = false;
++					m_has_more_packets = false;
+ 					break;
+-				} else {
++				}
++				SetError("Error reading from the audio source", ret);
++				return false;
++			}
++			if (m_packet->stream_index == m_stream_index) {
++				needs_packet = false;
++			} else {
++				av_packet_unref(m_packet);
++			}
++		}
++
++		if (m_packet->size != 0) {
++			ret = avcodec_send_packet(m_codec_ctx, m_packet);
++			if (ret < 0) {
++				if (ret != AVERROR(EAGAIN)) {
+ 					SetError("Error reading from the audio source", ret);
+ 					return false;
+ 				}
+-			}
+-			m_packet0 = m_packet;
+-			if (m_packet.stream_index != m_stream_index) {
+-				m_packet.data = nullptr;
+-				m_packet.size = 0;
+ 			} else {
+-				m_nb_packets++;
++				av_packet_unref(m_packet);
+ 			}
+ 		}
+
+-		ret = avcodec_decode_audio4(m_codec_ctx, m_frame, &m_got_frame, &m_packet);
++		ret = avcodec_receive_frame(m_codec_ctx, m_frame);
+ 		if (ret < 0) {
+-			if (m_decode_error) {
+-				SetError("Error decoding audio frame", m_decode_error);
+-				return false;
++			if (ret == AVERROR_EOF) {
++				m_has_more_frames = false;
++			} else if (ret == AVERROR(EAGAIN)) {
++				if (m_has_more_packets) {
++					needs_packet = true;
++					continue;
++				} else {
++					m_has_more_frames = false;
++				}
+ 			}
+-			m_decode_error = ret;
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			continue;
++			SetError("Error decoding the audio source", ret);
++			return false;
+ 		}
+
+-		break;
+-	}
+-
+-	m_decode_error = 0;
+-
+-	const int decoded = std::min(ret, m_packet.size);
+-	m_packet.data += decoded;
+-	m_packet.size -= decoded;
+-
+-	if (m_got_frame) {
+-		if (m_converter) {
+-			if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
+-				int linsize;
+-				av_freep(&m_convert_buffer[0]);
+-				m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
+-				ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
+-				if (ret < 0) {
+-					SetError("Couldn't allocate audio converter buffer", ret);
++		if (m_frame->nb_samples > 0) {
++			if (m_converter) {
++				if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
++					int linsize;
++					av_freep(&m_convert_buffer[0]);
++					m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
++					ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->ch_layout.nb_channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
++					if (ret < 0) {
++						SetError("Couldn't allocate audio converter buffer", ret);
++						return false;
++					}
++				}
++				auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
++				if (nb_samples < 0) {
++					SetError("Couldn't convert audio", ret);
+ 					return false;
+ 				}
+-			}
+-			auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			}
+-			*data = (const int16_t *) m_convert_buffer[0];
+-			*size = nb_samples;
+-		} else {
+-			*data = (const int16_t *) m_frame->data[0];
+-			*size = m_frame->nb_samples;
+-		}
+-	} else {
+-		if (m_finished && m_converter) {
+-			auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			} else if (nb_samples > 0) {
+-				m_got_frame = 1;
+ 				*data = (const int16_t *) m_convert_buffer[0];
+ 				*size = nb_samples;
++			} else {
++				*data = (const int16_t *) m_frame->data[0];
++				*size = m_frame->nb_samples;
++			}
++		} else {
++			if (m_converter) {
++				if (IsFinished()) {
++					auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
++					if (nb_samples < 0) {
++						SetError("Couldn't convert audio", ret);
++						return false;
++					} else if (nb_samples > 0) {
++						*data = (const int16_t *) m_convert_buffer[0];
++						*size = nb_samples;
++					}
++				}
+ 			}
+ 		}
+-	}
+
+-	return true;
++		return true;
++	}
+ }
+
+ inline void FFmpegAudioReader::SetError(const char *message, int errnum) {
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index a2b517b..123e643 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -38,6 +38,12 @@ set(SRCS
+
+ if(BUILD_TOOLS)
+ 	set(SRCS ${SRCS} ../src/audio/ffmpeg_audio_reader_test.cpp)
++    include_directories(
++        ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}
++        ${AUDIO_PROCESSOR_INCLUDE_DIRS}
++    )
+ 	link_libraries(fpcalc_libs)
+ endif()
+
+-- 
+2.38.1
+
+
diff --git a/srcpkgs/chromaprint/template b/srcpkgs/chromaprint/template
index 7ef7838949f3a3..1f7bbc70a22c80 100644
--- a/srcpkgs/chromaprint/template
+++ b/srcpkgs/chromaprint/template
@@ -1,7 +1,7 @@
 # Template file for 'chromaprint'
 pkgname=chromaprint
 version=1.5.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DBUILD_TOOLS=ON"
 make_check_target="check"

From 1df3de63f9e1e27934a08ddf489f035dd0733364 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 021/113] chromium: revbump for ffmpeg6

---
 .../patches/chromium-119-ffmpeg-4.4.patch     | 20 --------
 srcpkgs/chromium/patches/ffmpeg5.patch        | 47 +++++++++++++++++++
 srcpkgs/chromium/template                     |  2 +-
 3 files changed, 48 insertions(+), 21 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch
 create mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch b/srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch
deleted file mode 100644
index 04d04b166ba377..00000000000000
--- a/srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch
+++ /dev/null
@@ -1,20 +0,0 @@
---- a/media/filters/ffmpeg_demuxer.cc.orig
-+++ b/media/filters/ffmpeg_demuxer.cc
-@@ -390,7 +390,7 @@
- 
-   scoped_refptr<DecoderBuffer> buffer;
- 
--    size_t side_data_size = 0;
-+    int side_data_size = 0;
-     uint8_t* side_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
- 
-@@ -453,7 +453,7 @@
-                                        packet->size - data_offset);
-     }
- 
--    size_t skip_samples_size = 0;
-+    int skip_samples_size = 0;
-     const uint32_t* skip_samples_ptr =
-         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
-             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..24e2da38e34ca2
--- /dev/null
+++ b/srcpkgs/chromium/patches/ffmpeg5.patch
@@ -0,0 +1,47 @@
+--- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
++++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
+@@ -92,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+-  if (stream->start_time != kNoFFmpegTimestamp)
++  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -1597,7 +1585,7 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+@@ -1618,7 +1606,7 @@
+     if (stream->type() != DemuxerStream::VIDEO)
+       continue;
+ 
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+ 
+     if (!stream->IsEnabled())
diff --git a/srcpkgs/chromium/template b/srcpkgs/chromium/template
index 5613fa38138221..cd386c8a84ae6c 100644
--- a/srcpkgs/chromium/template
+++ b/srcpkgs/chromium/template
@@ -2,7 +2,7 @@
 pkgname=chromium
 # See https://chromiumdash.appspot.com/releases?platform=Linux for the latest version
 version=120.0.6099.129
-revision=1
+revision=2
 archs="i686* x86_64* aarch64* armv7l*"
 hostmakedepends="
  $(vopt_if clang "clang lld llvm15")

From 3f23c6f537e4c9cbedd282349115c6d1afd1394e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 022/113] cmus: revbump for ffmpeg6

---
 srcpkgs/chromium/patches/ffmpeg5.patch | 47 --------------------------
 srcpkgs/cmus/patches/ffmpeg6.patch     | 12 +++++++
 srcpkgs/cmus/template                  |  2 +-
 3 files changed, 13 insertions(+), 48 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch
 create mode 100644 srcpkgs/cmus/patches/ffmpeg6.patch

diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
deleted file mode 100644
index 24e2da38e34ca2..00000000000000
--- a/srcpkgs/chromium/patches/ffmpeg5.patch
+++ /dev/null
@@ -1,47 +0,0 @@
---- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
-+++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
-@@ -92,24 +92,12 @@
- 
- static base::TimeDelta ExtractStartTime(AVStream* stream) {
-   // The default start time is zero.
--  base::TimeDelta start_time;
-+  base::TimeDelta start_time = kNoTimestamp;
- 
-   // First try to use  the |start_time| value as is.
--  if (stream->start_time != kNoFFmpegTimestamp)
-+  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
-     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
- 
--  // Next try to use the first DTS value, for codecs where we know PTS == DTS
--  // (excludes all H26x codecs). The start time must be returned in PTS.
--  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
--      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
--      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
--      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
--    const base::TimeDelta first_pts =
--        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
--    if (first_pts < start_time)
--      start_time = first_pts;
--  }
--
-   return start_time;
- }
- 
-@@ -1597,7 +1585,7 @@
-   for (const auto& stream : streams_) {
-     if (!stream || stream->IsEnabled() != enabled)
-       continue;
--    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
-+    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
-       continue;
-     if (!lowest_start_time_stream ||
-         stream->start_time() < lowest_start_time_stream->start_time()) {
-@@ -1618,7 +1606,7 @@
-     if (stream->type() != DemuxerStream::VIDEO)
-       continue;
- 
--    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
-+    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
-       continue;
- 
-     if (!stream->IsEnabled())
diff --git a/srcpkgs/cmus/patches/ffmpeg6.patch b/srcpkgs/cmus/patches/ffmpeg6.patch
new file mode 100644
index 00000000000000..ffa95ab811101b
--- /dev/null
+++ b/srcpkgs/cmus/patches/ffmpeg6.patch
@@ -0,0 +1,12 @@
+--- a/ip/ffmpeg.c
++++ b/ip/ffmpeg.c
+@@ -202,9 +202,6 @@ static int ffmpeg_open(struct input_plugin_data *ip_data)
+ 			break;
+ 		}
+ 
+-		if (codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+-			cc->flags |= AV_CODEC_FLAG_TRUNCATED;
+-
+ 		if (avcodec_open2(cc, codec, NULL) < 0) {
+ 			d_print("could not open codec: %d, %s\n", cc->codec_id, avcodec_get_name(cc->codec_id));
+ 			err = -IP_ERROR_UNSUPPORTED_FILE_TYPE;
diff --git a/srcpkgs/cmus/template b/srcpkgs/cmus/template
index 0d1436744f1b2c..a6e4b4fa86cb83 100644
--- a/srcpkgs/cmus/template
+++ b/srcpkgs/cmus/template
@@ -1,7 +1,7 @@
 # Template file for 'cmus'
 pkgname=cmus
 version=2.10.0
-revision=3
+revision=4
 build_style=configure
 configure_args="prefix=/usr LD=$CC"
 hostmakedepends="pkg-config"

From 9ea917b4e8167088405502dcfb23631eeff05647 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 023/113] cyanrip: revbump for ffmpeg6

---
 srcpkgs/cyanrip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cyanrip/template b/srcpkgs/cyanrip/template
index 9796e3461601a7..5db30e020d17ee 100644
--- a/srcpkgs/cyanrip/template
+++ b/srcpkgs/cyanrip/template
@@ -1,7 +1,7 @@
 # Template file for 'cyanrip'
 pkgname=cyanrip
 version=0.9.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config"
 makedepends="ffmpeg-devel libcdio-devel libcdio-paranoia-devel libcurl-devel libmusicbrainz5-devel"

From eb3d45a91e59fc9b71d0c498ddd98d275e4d22e4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 024/113] deadbeef: revbump for ffmpeg4

---
 srcpkgs/deadbeef/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/deadbeef/template b/srcpkgs/deadbeef/template
index f5f4bf24b8cb6d..7b47e615cd48ef 100644
--- a/srcpkgs/deadbeef/template
+++ b/srcpkgs/deadbeef/template
@@ -1,14 +1,14 @@
 # Template file for 'deadbeef'
 pkgname=deadbeef
 version=1.8.8
-revision=3
+revision=4
 create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-oss --disable-lfm --disable-notify --disable-gtk2"
 hostmakedepends="automake libtool gettext gettext-devel intltool pkg-config
  yasm clang glib-devel"
 makedepends="
- alsa-lib-devel dbus-devel faad2-devel ffmpeg-devel gtk+3-devel imlib2-devel
+ alsa-lib-devel dbus-devel faad2-devel ffmpeg4-devel gtk+3-devel imlib2-devel
  jansson-devel libcddb-devel libcdio-devel libcurl-devel libflac-devel
  libmad-devel libpng-devel libsamplerate-devel libsndfile-devel libvorbis-devel
  libzip-devel mpg123-devel opusfile-devel pulseaudio-devel wavpack-devel"

From b194dd8dc94eb367adaeb2f6a93f2e2159f9922e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 025/113] droidcam-obs-plugin: revbump for ffmpeg6

---
 srcpkgs/droidcam-obs-plugin/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam-obs-plugin/template b/srcpkgs/droidcam-obs-plugin/template
index fc9c9bf6b9d54c..fb0480754df4de 100644
--- a/srcpkgs/droidcam-obs-plugin/template
+++ b/srcpkgs/droidcam-obs-plugin/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam-obs-plugin'
 pkgname=droidcam-obs-plugin
 version=2.0.1
-revision=1
+revision=2
 build_style=gnu-makefile
 make_use_env=yes
 make_build_args="ALLOW_STATIC=no"

From 67e42d6f97dcf51fc681b27b86639befc6c28083 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 026/113] droidcam: revbump for ffmpeg6

---
 srcpkgs/droidcam/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam/template b/srcpkgs/droidcam/template
index 1c3f1b8b1fc676..32a9220b79a4d1 100644
--- a/srcpkgs/droidcam/template
+++ b/srcpkgs/droidcam/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam'
 pkgname=droidcam
 version=1.8.2
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="USBMUXD=-lusbmuxd-2.0 JPEG=-lturbojpeg"
 hostmakedepends="pkg-config"

From c2ce442cede3c3d322b4012a384660e69bc913b2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 027/113] ffmpegthumbnailer: revbump for ffmpeg6

---
 .../ffmpegthumbnailer/patches/ffmpeg6.patch   | 202 ++++++++++++++++++
 srcpkgs/ffmpegthumbnailer/template            |   6 +-
 2 files changed, 205 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch

diff --git a/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
new file mode 100644
index 00000000000000..363ff35a28419d
--- /dev/null
+++ b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
@@ -0,0 +1,202 @@
+--- a/libffmpegthumbnailer/moviedecoder.cpp	2017-11-21 14:06:57.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.cpp	2023-05-05 13:14:47.946560668 -0400
+@@ -41,11 +41,6 @@
+ namespace ffmpegthumbnailer
+ {
+ 
+-struct SilenceLogLevel
+-{
+-    SilenceLogLevel() { av_log_set_level(AV_LOG_QUIET); }
+-};
+-
+ MovieDecoder::MovieDecoder(AVFormatContext* pavContext)
+ : m_VideoStream(-1)
+ , m_pFormatContext(pavContext)
+@@ -70,8 +65,6 @@
+ 
+ void MovieDecoder::initialize(const string& filename, bool preferEmbeddedMetadata)
+ {
+-    av_register_all();
+-    avcodec_register_all();
+     avformat_network_init();
+ 
+     string inputFile = filename == "-" ? "pipe:" : filename;
+@@ -97,8 +90,7 @@
+ {
+     if (m_pVideoCodecContext)
+     {
+-        avcodec_close(m_pVideoCodecContext);
+-        m_pVideoCodecContext = nullptr;
++        avcodec_free_context(&m_pVideoCodecContext);
+     }
+ 
+     if ((!m_FormatContextWasGiven) && m_pFormatContext)
+@@ -152,10 +144,10 @@
+     for (unsigned int i = 0; i < m_pFormatContext->nb_streams; ++i)
+     {
+         AVStream *stream = m_pFormatContext->streams[i];
+-        auto ctx = m_pFormatContext->streams[i]->codec;
+-        if (ctx->codec_type == AVMEDIA_TYPE_VIDEO)
++        auto par = m_pFormatContext->streams[i]->codecpar;
++        if (par->codec_type == AVMEDIA_TYPE_VIDEO)
+         {
+-            if (!preferEmbeddedMetadata || !isStillImageCodec(ctx->codec_id))
++            if (!preferEmbeddedMetadata || !isStillImageCodec(par->codec_id))
+             {
+                 videoStreams.push_back(i);
+                 continue;
+@@ -203,8 +195,7 @@
+     }
+ 
+     m_pVideoStream = m_pFormatContext->streams[m_VideoStream];
+-    m_pVideoCodecContext = m_pVideoStream->codec;
+-    m_pVideoCodec = avcodec_find_decoder(m_pVideoCodecContext->codec_id);
++    m_pVideoCodec = avcodec_find_decoder(m_pVideoStream->codecpar->codec_id);
+ 
+     if (m_pVideoCodec == nullptr)
+     {
+@@ -214,6 +205,20 @@
+         throw logic_error("Video Codec not found");
+     }
+ 
++    m_pVideoCodecContext = avcodec_alloc_context3(m_pVideoCodec);
++
++    if (m_pVideoCodecContext == nullptr)
++    {
++        destroy();
++        throw logic_error("Could not allocate video codec context");
++    }
++
++    if (avcodec_parameters_to_context(m_pVideoCodecContext, m_pVideoStream->codecpar) < 0)
++    {
++        destroy();
++        throw logic_error("Could not configure video codec context");
++    }
++
+     m_pVideoCodecContext->workaround_bugs = 1;
+ 
+     if (avcodec_open2(m_pVideoCodecContext, m_pVideoCodec, nullptr) < 0)
+@@ -386,13 +391,6 @@
+ 
+ void MovieDecoder::initializeFilterGraph(const AVRational& timeBase, const std::string& size, bool maintainAspectRatio)
+ {
+-    static const AVPixelFormat pixelFormats[] = { AV_PIX_FMT_RGB24, AV_PIX_FMT_NONE };
+-
+-    auto del = [] (AVBufferSinkParams* p) { av_freep(p); };
+-    std::unique_ptr<AVBufferSinkParams, decltype(del)> buffersinkParams(av_buffersink_params_alloc(), del);
+-
+-    avfilter_register_all();
+-
+     m_pFilterGraph = avfilter_graph_alloc();
+     assert(m_pFilterGraph);
+ 
+@@ -404,10 +402,8 @@
+ 
+     checkRc(avfilter_graph_create_filter(&m_pFilterSource, avfilter_get_by_name("buffer"), "thumb_buffer", ss.str().c_str(), nullptr, m_pFilterGraph),
+             "Failed to create filter source");
+-    buffersinkParams->pixel_fmts = pixelFormats;
+-    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, buffersinkParams.get(), m_pFilterGraph),
++    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, nullptr, m_pFilterGraph),
+             "Failed to create filter sink");
+-    buffersinkParams.release();
+ 
+     AVFilterContext* yadifFilter = nullptr;
+     if (m_pFrame->interlaced_frame != 0)
+@@ -500,15 +496,15 @@
+     }
+ 
+     checkRc(av_seek_frame(m_pFormatContext, -1, timestamp, 0), "Seeking in video failed");
+-    avcodec_flush_buffers(m_pFormatContext->streams[m_VideoStream]->codec);
++    avcodec_flush_buffers(m_pVideoCodecContext);
+ 
+     int keyFrameAttempts = 0;
+-    bool gotFrame = 0;
++    bool gotFrame;
+ 
+     do
+     {
+         int count = 0;
+-        gotFrame = 0;
++        gotFrame = false;
+ 
+         while (!gotFrame && count < 20)
+         {
+@@ -552,17 +548,33 @@
+         return false;
+     }
+ 
+-    av_frame_unref(m_pFrame);
+-
+-    int frameFinished;
++    int rc = avcodec_send_packet(m_pVideoCodecContext, m_pPacket);
++    if(rc == AVERROR(EAGAIN))
++    {
++        rc = 0;
++    }
+ 
+-    int bytesDecoded = avcodec_decode_video2(m_pVideoCodecContext, m_pFrame, &frameFinished, m_pPacket);
+-    if (bytesDecoded < 0)
++    if(rc == AVERROR_EOF)
++    {
++        return false;
++    }
++    else if(rc < 0)
+     {
+-        throw logic_error("Failed to decode video frame: bytesDecoded < 0");
++        throw logic_error("Failed to decode video frame: avcodec_send_packet() < 0");
+     }
+ 
+-    return frameFinished > 0;
++    rc = avcodec_receive_frame(m_pVideoCodecContext, m_pFrame);
++    switch(rc)
++    {
++        case 0:
++            return true;
++
++        case AVERROR(EAGAIN):
++            return false;
++
++        default:
++            throw logic_error("Failed to decode video frame: avcodec_receive_frame() < 0");
++    }
+ }
+ 
+ bool MovieDecoder::getVideoPacket()
+@@ -570,8 +582,6 @@
+     bool framesAvailable = true;
+     bool frameDecoded = false;
+ 
+-    int attempts = 0;
+-
+     if (m_pPacket)
+     {
+         av_packet_unref(m_pPacket);
+@@ -580,6 +590,7 @@
+ 
+     m_pPacket = new AVPacket();
+ 
++
+     while (framesAvailable && !frameDecoded)
+     {
+         framesAvailable = av_read_frame(m_pFormatContext, m_pPacket) >= 0;
+@@ -644,7 +655,7 @@
+ 
+ int32_t MovieDecoder::getStreamRotation()
+ {
+-    int32_t* matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
++    auto matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
+     if (matrix)
+     {
+         auto angle = lround(av_display_rotation_get(matrix));
+
+--- a/libffmpegthumbnailer/moviedecoder.h	2017-11-12 04:23:38.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.h	2023-05-05 13:26:07.095529911 -0400
+@@ -78,7 +78,7 @@
+     int                     m_VideoStream;
+     AVFormatContext*        m_pFormatContext;
+     AVCodecContext*         m_pVideoCodecContext;
+-    AVCodec*                m_pVideoCodec;
++    const AVCodec*          m_pVideoCodec;
+     AVFilterGraph*          m_pFilterGraph;
+     AVFilterContext*        m_pFilterSource;
+     AVFilterContext*        m_pFilterSink;
diff --git a/srcpkgs/ffmpegthumbnailer/template b/srcpkgs/ffmpegthumbnailer/template
index 039eea7622b391..35d546018d12af 100644
--- a/srcpkgs/ffmpegthumbnailer/template
+++ b/srcpkgs/ffmpegthumbnailer/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbnailer'
 pkgname=ffmpegthumbnailer
 version=2.2.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libpng-devel libjpeg-turbo-devel ffmpeg-devel"
@@ -9,8 +9,8 @@ depends="ffmpeg"
 short_desc="Lightweight video thumbnailer"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
-homepage="https://github.com/dirkvdb/${pkgname}"
-distfiles="${homepage}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
+homepage="https://github.com/dirkvdb"
+distfiles="${homepage}/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
 checksum=1cb24059c38223f657b300c84dd80491b7040d4b69471c4fea69be862bc99b5b
 
 post_install() {

From 51342c22ef2df8c5060e42b1c7f13ec48bfd24cb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 028/113] ffmpegthumbs: revbump for ffmpeg6

---
 srcpkgs/ffmpegthumbs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ffmpegthumbs/template b/srcpkgs/ffmpegthumbs/template
index 5f0b9414dadaf5..11b88193528f4b 100644
--- a/srcpkgs/ffmpegthumbs/template
+++ b/srcpkgs/ffmpegthumbs/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbs'
 pkgname=ffmpegthumbs
 version=22.12.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules kcoreaddons kconfig-devel
  pkg-config qt5-host-tools qt5-qmake gettext"

From ae4d5da775636593f43c072b27e3135b14f33b2e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 029/113] ffms2: revbump for ffmpeg6

---
 srcpkgs/ffms2/patches/ffmpeg5.patch | 424 ++++++++++++++++++++++++++++
 srcpkgs/ffms2/template              |   2 +-
 2 files changed, 425 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ffms2/patches/ffmpeg5.patch

diff --git a/srcpkgs/ffms2/patches/ffmpeg5.patch b/srcpkgs/ffms2/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..1479fabcafcb4e
--- /dev/null
+++ b/srcpkgs/ffms2/patches/ffmpeg5.patch
@@ -0,0 +1,424 @@
+From 45673149e9a2f5586855ad472e3059084eaa36b1 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:41:21 +0100
+Subject: [PATCH] Use auto for AVCodec
+
+The geniuses over at FFmpeg decided to constify this API, so old
+versions of the library will return AVCodec *, while new versions
+of the libary will return const AVCodec *, which, in C++, are not
+OK to convert between.
+
+Rather than use some macro hell in ffmscompat.h, we can work around
+this by using auto.
+
+Gross.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 2 +-
+ src/core/indexing.cpp    | 6 +++---
+ src/core/videosource.cpp | 2 +-
+ 3 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index e4ce97c..ac09666 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -469,7 +469,7 @@ void FFMS_AudioSource::OpenFile() {
+ 
+     LAVFOpenFile(SourceFile.c_str(), FormatContext, TrackNumber);
+ 
+-    AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
++    auto *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
+     if (Codec == nullptr)
+         throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+             "Audio codec not found");
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index e547c5a..59fb4e8 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -384,7 +384,7 @@ FFMS_TrackType FFMS_Indexer::GetTrackType(int Track) {
+ }
+ 
+ const char *FFMS_Indexer::GetTrackCodec(int Track) {
+-    AVCodec *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
++    auto *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
+     return codec ? codec->name : nullptr;
+ }
+ 
+@@ -402,7 +402,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             UseDTS);
+ 
+         if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            AVCodec *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (!VideoCodec) {
+                 FormatContext->streams[i]->discard = AVDISCARD_ALL;
+                 IndexMask.erase(i);
+@@ -433,7 +433,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 IndexMask.insert(i);
+             }
+         } else if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+-            AVCodec *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (AudioCodec == nullptr)
+                 throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_UNSUPPORTED,
+                     "Audio codec not found");
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index b889970..8956c22 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -171,7 +171,7 @@ FFMS_VideoSource::FFMS_VideoSource(const char *SourceFile, FFMS_Index &Index, in
+ 
+         LAVFOpenFile(SourceFile, FormatContext, VideoTrack);
+ 
+-        AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
++        auto *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
+         if (Codec == nullptr)
+             throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+                 "Video codec not found");
+-- 
+2.40.0
+
+From 96cbf38ea9381829a1314f432a2c60495dcefaad Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:12:41 +0100
+Subject: [PATCH] all: Update AVPacket API usage
+
+AVPackets must all be on the heap now, since it is no longer
+part of the libav* ABI.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 16 ++++++----
+ src/core/indexing.cpp    | 63 ++++++++++++++++++++++------------------
+ src/core/indexing.h      |  4 +--
+ src/core/utils.cpp       |  6 ----
+ src/core/utils.h         |  1 -
+ src/core/videosource.cpp | 30 ++++++++++---------
+ 6 files changed, 64 insertions(+), 56 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index 37cf9ae..e4ce97c 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -285,10 +285,15 @@ FFMS_AudioSource::AudioBlock *FFMS_AudioSource::CacheBlock(CacheIterator &pos) {
+ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     CurrentFrame = &Frames[PacketNumber];
+ 
+-    AVPacket Packet;
+-    if (!ReadPacket(&Packet))
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++    if (!ReadPacket(Packet)) {
++        av_packet_free(&Packet);
+         throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_UNKNOWN,
+             "ReadPacket unexpectedly failed to read a packet");
++    }
+ 
+     // ReadPacket may have changed the packet number
+     CurrentFrame = &Frames[PacketNumber];
+@@ -297,8 +302,9 @@ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     int NumberOfSamples = 0;
+     AudioBlock *CachedBlock = nullptr;
+     
+-    int Ret = avcodec_send_packet(CodecContext, &Packet);
+-    av_packet_unref(&Packet);
++    int Ret = avcodec_send_packet(CodecContext, Packet);
++    av_packet_unref(Packet);
++    av_packet_free(&Packet);
+ 
+     av_frame_unref(DecodeFrame);
+     Ret = avcodec_receive_frame(CodecContext, DecodeFrame);
+@@ -513,8 +519,6 @@ void FFMS_AudioSource::Seek() {
+ }
+ 
+ bool FFMS_AudioSource::ReadPacket(AVPacket *Packet) {
+-    InitNullPacket(*Packet);
+-
+     while (av_read_frame(FormatContext, Packet) >= 0) {
+         if (Packet->stream_index == TrackNumber) {
+             // Required because not all audio packets, especially in ogg, have a pts. Use the previous valid packet's pts instead.
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index 23fb95b..e547c5a 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -320,7 +320,7 @@ void FFMS_Indexer::CheckAudioProperties(int Track, AVCodecContext *Context) {
+     }
+ }
+ 
+-void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict,
++void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict,
+                                     int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct) {
+     if (VideoContext.Parser) {
+         uint8_t *OB;
+@@ -330,8 +330,8 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+         av_parser_parse2(VideoContext.Parser,
+             VideoContext.CodecContext,
+             &OB, &OBSize,
+-            pkt.data, pkt.size,
+-            pkt.pts, pkt.dts, pkt.pos);
++            pkt->data, pkt->size,
++            pkt->pts, pkt->dts, pkt->pos);
+ 
+         // H.264 (PAFF) and HEVC may have one field per packet, so we need to track
+         // when we have a full or half frame available, and mark one of them as
+@@ -351,15 +351,15 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+ 
+         *RepeatPict = VideoContext.Parser->repeat_pict;
+         *FrameType = VideoContext.Parser->pict_type;
+-        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt.flags & AV_PKT_FLAG_DISCARD));
++        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt->flags & AV_PKT_FLAG_DISCARD));
+     } else {
+-        *Invisible = !!(pkt.flags & AV_PKT_FLAG_DISCARD);
++        *Invisible = !!(pkt->flags & AV_PKT_FLAG_DISCARD);
+     }
+ 
+     if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP8)
+-        ParseVP8(pkt.data[0], Invisible, FrameType);
++        ParseVP8(pkt->data[0], Invisible, FrameType);
+     else if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP9)
+-        ParseVP9(pkt.data[0], Invisible, FrameType);
++        ParseVP9(pkt->data[0], Invisible, FrameType);
+ }
+ 
+ void FFMS_Indexer::Free() {
+@@ -458,32 +458,36 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+         }
+     }
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
+     std::vector<int64_t> LastValidTS(FormatContext->nb_streams, AV_NOPTS_VALUE);
+ 
+     int64_t filesize = avio_size(FormatContext->pb);
+     enum AVPictureStructure LastPicStruct = AV_PICTURE_STRUCTURE_UNKNOWN;
+-    while (av_read_frame(FormatContext, &Packet) >= 0) {
++    while (av_read_frame(FormatContext, Packet) >= 0) {
+         // Update progress
+         // FormatContext->pb can apparently be NULL when opening images.
+         if (IC && FormatContext->pb) {
+-            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate))
++            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate)) {
++                av_packet_free(&Packet);
+                 throw FFMS_Exception(FFMS_ERROR_CANCELLED, FFMS_ERROR_USER,
+                     "Cancelled by user");
++            }
+         }
+-        if (!IndexMask.count(Packet.stream_index)) {
+-            av_packet_unref(&Packet);
++        if (!IndexMask.count(Packet->stream_index)) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+-        int Track = Packet.stream_index;
++        int Track = Packet->stream_index;
+         FFMS_Track &TrackInfo = (*TrackIndices)[Track];
+-        bool KeyFrame = !!(Packet.flags & AV_PKT_FLAG_KEY);
++        bool KeyFrame = !!(Packet->flags & AV_PKT_FLAG_KEY);
+         ReadTS(Packet, LastValidTS[Track], (*TrackIndices)[Track].UseDTS);
+ 
+         if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            int64_t PTS = TrackInfo.UseDTS ? Packet.dts : Packet.pts;
++            int64_t PTS = TrackInfo.UseDTS ? Packet->dts : Packet->pts;
+             if (PTS == AV_NOPTS_VALUE) {
+                 // VPx alt-refs are output as packets which lack timestmps or durations, since
+                 // they are invisible. Currently, the timestamp mangling code in libavformat
+@@ -495,9 +499,11 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 // FFMS2 currently sorts packets by PTS, which will break decoding, otherwise.
+                 bool HasAltRefs = (FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP8 ||
+                                    FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP9);
+-                if (Packet.duration == 0 && !HasAltRefs)
++                if (Packet->duration == 0 && !HasAltRefs) {
++                    av_packet_free(&Packet);
+                     throw FFMS_Exception(FFMS_ERROR_INDEXING, FFMS_ERROR_PARSER,
+                         "Invalid packet pts, dts, and duration");
++                }
+ 
+                 if (TrackInfo.empty())
+                     PTS = 0;
+@@ -513,7 +519,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             ParseVideoPacket(AVContexts[Track], Packet, &RepeatPict, &FrameType, &Invisible, &LastPicStruct);
+ 
+             TrackInfo.AddVideoFrame(PTS, RepeatPict, KeyFrame,
+-                FrameType, Packet.pos, Invisible);
++                FrameType, Packet->pos, Invisible);
+         } else if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+             // For video seeking timestamps are used only if all packets have
+             // timestamps, while for audio they're used if any have timestamps,
+@@ -522,28 +528,29 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 TrackInfo.HasTS = true;
+ 
+             int64_t StartSample = AVContexts[Track].CurrentSample;
+-            uint32_t SampleCount = IndexAudioPacket(Track, &Packet, AVContexts[Track], *TrackIndices);
++            uint32_t SampleCount = IndexAudioPacket(Track, Packet, AVContexts[Track], *TrackIndices);
+             TrackInfo.SampleRate = AVContexts[Track].CodecContext->sample_rate;
+ 
+             TrackInfo.AddAudioFrame(LastValidTS[Track],
+-                StartSample, SampleCount, KeyFrame, Packet.pos, Packet.flags & AV_PKT_FLAG_DISCARD);
++                StartSample, SampleCount, KeyFrame, Packet->pos, Packet->flags & AV_PKT_FLAG_DISCARD);
+         }
+ 
+-        if (!(Packet.flags & AV_PKT_FLAG_DISCARD))
+-            TrackInfo.LastDuration = Packet.duration;
++        if (!(Packet->flags & AV_PKT_FLAG_DISCARD))
++            TrackInfo.LastDuration = Packet->duration;
+ 
+-        av_packet_unref(&Packet);
++        av_packet_unref(Packet);
+     }
++    av_packet_free(&Packet);
+ 
+     TrackIndices->Finalize(AVContexts, FormatContext->iformat->name);
+     return TrackIndices.release();
+ }
+ 
+-void FFMS_Indexer::ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS) {
+-    if (!UseDTS && Packet.pts != AV_NOPTS_VALUE)
+-        TS = Packet.pts;
++void FFMS_Indexer::ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS) {
++    if (!UseDTS && Packet->pts != AV_NOPTS_VALUE)
++        TS = Packet->pts;
+     if (TS == AV_NOPTS_VALUE)
+         UseDTS = true;
+-    if (UseDTS && Packet.dts != AV_NOPTS_VALUE)
+-        TS = Packet.dts;
++    if (UseDTS && Packet->dts != AV_NOPTS_VALUE)
++        TS = Packet->dts;
+ }
+diff --git a/src/core/indexing.h b/src/core/indexing.h
+index 3cfc3c3..5c06868 100644
+--- a/src/core/indexing.h
++++ b/src/core/indexing.h
+@@ -80,10 +80,10 @@ private:
+     int64_t Filesize;
+     uint8_t Digest[20];
+ 
+-    void ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS);
++    void ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS);
+     void CheckAudioProperties(int Track, AVCodecContext *Context);
+     uint32_t IndexAudioPacket(int Track, AVPacket *Packet, SharedAVContext &Context, FFMS_Index &TrackIndices);
+-    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
++    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
+     void Free();
+ public:
+     FFMS_Indexer(const char *Filename);
+diff --git a/src/core/utils.cpp b/src/core/utils.cpp
+index ce67533..8a2e997 100644
+--- a/src/core/utils.cpp
++++ b/src/core/utils.cpp
+@@ -62,12 +62,6 @@ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo) {
+     }
+ }
+ 
+-void InitNullPacket(AVPacket &pkt) {
+-    av_init_packet(&pkt);
+-    pkt.data = nullptr;
+-    pkt.size = 0;
+-}
+-
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames) {
+     AP.SampleFormat = static_cast<FFMS_SampleFormat>(av_get_packed_sample_fmt(CTX->sample_fmt));
+     AP.BitsPerSample = av_get_bytes_per_sample(CTX->sample_fmt) * 8;
+diff --git a/src/core/utils.h b/src/core/utils.h
+index 9819dc7..003ab79 100644
+--- a/src/core/utils.h
++++ b/src/core/utils.h
+@@ -58,7 +58,6 @@ std::unique_ptr<T> make_unique(Args&&... args) {
+ }
+ 
+ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo);
+-void InitNullPacket(AVPacket &pkt);
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames);
+ 
+ void LAVFOpenFile(const char *SourceFile, AVFormatContext *&FormatContext, int Track);
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index 06bd161..b889970 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -673,30 +673,34 @@ void FFMS_VideoSource::DecodeNextFrame(int64_t &AStartTime, int64_t &Pos) {
+     if (HasPendingDelayedFrames())
+         return;
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
+-
+-    while (ReadFrame(&Packet) >= 0) {
+-        if (Packet.stream_index != VideoTrack) {
+-            av_packet_unref(&Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++
++    while (ReadFrame(Packet) >= 0) {
++        if (Packet->stream_index != VideoTrack) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+         if (AStartTime < 0)
+-            AStartTime = Frames.UseDTS ? Packet.dts : Packet.pts;
++            AStartTime = Frames.UseDTS ? Packet->dts : Packet->pts;
+ 
+         if (Pos < 0)
+-            Pos = Packet.pos;
++            Pos = Packet->pos;
+ 
+-        bool FrameFinished = DecodePacket(&Packet);
+-        av_packet_unref(&Packet);
+-        if (FrameFinished)
++        bool FrameFinished = DecodePacket(Packet);
++        av_packet_unref(Packet);
++        if (FrameFinished) {
++            av_packet_free(&Packet);
+             return;
++        }
+     }
+ 
+     // Flush final frames
+-    InitNullPacket(Packet);
+-    DecodePacket(&Packet);
++    DecodePacket(Packet);
++    av_packet_free(&Packet);
+ }
+ 
+ bool FFMS_VideoSource::SeekTo(int n, int SeekOffset) {
+-- 
+2.40.0
+
+From bf9e03e9e08534c024e5a744a6437c4aac160201 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:20:47 +0100
+Subject: [PATCH 2/3] configure: Remove deprecated API use
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ configure.ac | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index b35ef80bc..d19714d0f 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -102,10 +102,10 @@ CFLAGS="$_CFLAGS $FFMPEG_CFLAGS"
+
+ AC_DEFUN([TEST_FFMPEG],
+          [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+-            #include <libavcodec/avcodec.h>
++            #include <libavformat/avformat.h>
+             #include <libswscale/swscale.h>
+             ]],[[
+-                avcodec_register_all();
++                avformat_network_init();
+                 swscale_version();
+             ]])], [eval $1=yes], [eval $1=no])
+         ])
+
diff --git a/srcpkgs/ffms2/template b/srcpkgs/ffms2/template
index 365f64d10cbabf..1641ecf43be5bb 100644
--- a/srcpkgs/ffms2/template
+++ b/srcpkgs/ffms2/template
@@ -1,7 +1,7 @@
 # Template file for 'ffms2'
 pkgname=ffms2
 version=2.40
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-shared --disable-static"
 hostmakedepends="pkg-config autoconf automake libtool"

From cf63602dca34d2d07a96abb82231f96f7743e5b0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 030/113] freerdp: revbump for ffmpeg6

---
 .../freerdp/patches/ffmpeg6_aa2cb9aa.patch    | 42 +++++++++++++++++++
 srcpkgs/freerdp/template                      |  2 +-
 2 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch

diff --git a/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
new file mode 100644
index 00000000000000..a4324da3a8822b
--- /dev/null
+++ b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
@@ -0,0 +1,42 @@
+From aa2cb9aa5ff5562433598ba168a466e0752bca0e Mon Sep 17 00:00:00 2001
+From: akallabeth <akallabeth@posteo.net>
+Date: Tue, 14 Feb 2023 07:48:54 +0100
+Subject: [PATCH] Fixed #8686: Update h264 to use new FFMPEG API
+
+---
+ channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c | 2 ++
+ libfreerdp/codec/h264_ffmpeg.c            | 2 ++
+ 2 files changed, 4 insertions(+)
+
+diff --git a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+index 339462d865f..beea80b7a1e 100644
+--- a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
++++ b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+@@ -239,8 +239,10 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYP
+ 		}
+ 	}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 	if (mdecoder->codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		mdecoder->codec_context->flags |= AV_CODEC_FLAG_TRUNCATED;
++#endif
+ 
+ 	return TRUE;
+ }
+diff --git a/libfreerdp/codec/h264_ffmpeg.c b/libfreerdp/codec/h264_ffmpeg.c
+index 8a23db2473c..896a333019b 100644
+--- a/libfreerdp/codec/h264_ffmpeg.c
++++ b/libfreerdp/codec/h264_ffmpeg.c
+@@ -615,10 +615,12 @@ static BOOL libavcodec_init(H264_CONTEXT* h264)
+ 			goto EXCEPTION;
+ 		}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 		if (sys->codecDecoder->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		{
+ 			sys->codecDecoderContext->flags |= AV_CODEC_FLAG_TRUNCATED;
+ 		}
++#endif
+ 
+ #ifdef WITH_VAAPI
+ 
diff --git a/srcpkgs/freerdp/template b/srcpkgs/freerdp/template
index f36c38ca885b39..97b1d5ea519cda 100644
--- a/srcpkgs/freerdp/template
+++ b/srcpkgs/freerdp/template
@@ -1,7 +1,7 @@
 # Template file for 'freerdp'
 pkgname=freerdp
 version=2.10.0
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DWITH_ALSA=ON -DWITH_CUPS=OFF -DWITH_FFMPEG=ON
  -DWITH_GSTREAMER_0_10=OFF -DWITH_GSTREAMER_1_0=OFF -DWITH_JPEG=ON

From 85b7434c5e982c623f8e66395ab57fb2e495976c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 031/113] gerbera: revbump for ffmpeg6

---
 srcpkgs/gerbera/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gerbera/template b/srcpkgs/gerbera/template
index ae14f35c767c03..2dc0ac0ce03b55 100644
--- a/srcpkgs/gerbera/template
+++ b/srcpkgs/gerbera/template
@@ -1,7 +1,7 @@
 # Template file for 'gerbera'
 pkgname=gerbera
 version=1.12.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_SYSTEMD=0 -DWITH_AVCODEC=1"
 hostmakedepends="pkg-config"

From 6e9a4d3c77680b00b5bf3a4e956c7cba3718dd2d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 032/113] goldendict: revbump for ffmpeg6

---
 srcpkgs/goldendict/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/goldendict/template b/srcpkgs/goldendict/template
index f4a05759f693d3..97f44347b03a6a 100644
--- a/srcpkgs/goldendict/template
+++ b/srcpkgs/goldendict/template
@@ -1,7 +1,7 @@
 # Template file for 'goldendict'
 pkgname=goldendict
 version=1.5.0
-revision=1
+revision=2
 build_style=qmake
 configure_args="CONFIG+=zim_support goldendict.pro"
 hostmakedepends="qt5-qmake pkg-config qt5-host-tools"
@@ -10,7 +10,7 @@ makedepends="tiff-devel qt5-devel libvorbis-devel zlib-devel
  qt5-webkit-devel lzo-devel bzip2-devel libao-devel qt5-svg-devel
  libeb-devel qt5-x11extras-devel ffmpeg-devel liblzma-devel
  qt5-multimedia-devel"
-short_desc="A feature-rich dictionary lookup program"
+short_desc="Feature-rich dictionary lookup program"
 maintainer="John <me@johnnynator.dev>"
 license="GPL-3.0-or-later"
 homepage="http://goldendict.org/"

From 4279697ee6bbf9ab4c39fd71e5bee56e3df634ca Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 033/113] gst-libav: revbump for ffmpeg6

---
 srcpkgs/gst-libav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index b24be23fc1a6d2..0f9350a251bf67 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.22.9
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"

From 6b7841b8d5bb11416d975afca88f583bfe0d1845 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Feb 2024 01:52:46 -0500
Subject: [PATCH 034/113] gst-bad: revbump for ffmpeg6

---
 srcpkgs/gst-plugins-bad1/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index 4fe7053c359c36..63200e74f99a7f 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -27,7 +27,7 @@ makedepends="alsa-lib-devel celt-devel openssl-devel exempi-devel
  fdk-aac-devel flite-devel fluidsynth-devel liblrdf-devel ladspa-sdk
  lilv-devel lv2 libopenjpeg2-devel sbc-devel spandsp-devel vulkan-loader
  Vulkan-Headers webrtc-audio-processing-devel libzbar-devel ffmpeg-devel
- srt-devel libva-devel
+ srt-devel libva-devel oneVPL-devel
  $(vopt_if gme libgme-devel)"
 depends="gst-plugins-base1>=${version}"
 short_desc="GStreamer plugins from the bad set (v1.x)"

From 4a0d3466c7c1adb5bc8159cf88cef313b6582a1a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 035/113] gst-rtsp-server: revbump for ffmpeg6

---
 srcpkgs/gst-rtsp-server/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index bc2a0dea6ac152..f77026c618eb69 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
 version=1.22.9
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="glib-devel gst-plugins-bad1-devel gobject-introspection

From 51fec718c7d1f28840e8956579e145c4eb0f5975 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 036/113] guvcview: update to 2.0.8.

---
 srcpkgs/guvcview/patches/fix-include.patch | 10 ++++++++++
 srcpkgs/guvcview/template                  |  7 +++----
 2 files changed, 13 insertions(+), 4 deletions(-)
 create mode 100644 srcpkgs/guvcview/patches/fix-include.patch

diff --git a/srcpkgs/guvcview/patches/fix-include.patch b/srcpkgs/guvcview/patches/fix-include.patch
new file mode 100644
index 00000000000000..503c2af3b78c1a
--- /dev/null
+++ b/srcpkgs/guvcview/patches/fix-include.patch
@@ -0,0 +1,10 @@
+--- a/guvcview/guvcview.c
++++ b/guvcview/guvcview.c
+@@ -28,6 +28,7 @@
+ #include <sys/stat.h>
+ #include <sys/resource.h>
+ #include <errno.h>
++#include <locale.h>
+ 
+ #include "gview.h"
+ #include "gviewv4l2core.h"
diff --git a/srcpkgs/guvcview/template b/srcpkgs/guvcview/template
index d42fd38fa4ad12..86a7fd619612c8 100644
--- a/srcpkgs/guvcview/template
+++ b/srcpkgs/guvcview/template
@@ -1,8 +1,7 @@
 # Template file for 'guvcview'
 pkgname=guvcview
-version=2.0.7
-revision=2
-create_wrksrc=yes
+version=2.0.8
+revision=1
 build_style=gnu-configure
 configure_args="--disable-static --disable-debian-menu"
 hostmakedepends="pkg-config intltool autoconf automake libtool glib-devel"
@@ -14,7 +13,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="http://guvcview.sourceforge.net/"
 distfiles="${SOURCEFORGE_SITE}/${pkgname}/${pkgname}-src-${version}.tar.bz2"
-checksum=f47d51fbd06e44eeaa1a82f4a153c927527c90d94514197a70b2956028cc8ad4
+checksum=a21f4e448286666cf27bafef5290cc953a0a1796b752e5bbe521266dc1230c81
 
 post_patch() {
 	sed '31a#include <locale.h>' -i  guvcview/guvcview.c

From 10a4db6b27ee2ec36dd09fb566040fd70305a7d7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 037/113] handbrake: update to 1.6.1

---
 .../patches/fix-missing-x265-link-flag.patch    | 11 ++++++-----
 .../handbrake/patches/libhb-vpl-include.patch   | 15 +++++++++++++++
 srcpkgs/handbrake/template                      | 17 ++++++++++-------
 3 files changed, 31 insertions(+), 12 deletions(-)
 create mode 100644 srcpkgs/handbrake/patches/libhb-vpl-include.patch

diff --git a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
index 26db03867a0c83..d6bb2eda627a36 100644
--- a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
+++ b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
@@ -1,14 +1,15 @@
 --- a/gtk/configure.ac
 +++ b/gtk/configure.ac
 @@ -203,7 +203,7 @@
- 
+
  AM_CONDITIONAL([MINGW], [test "x$mingw_flag" = "xyes"])
- 
--HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg"
-+HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -ldl"
+
+-HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc"
++HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc -ldl"
  HB_CPPFLAGS="$HB_CPPFLAGS $HBINC"
- 
+
  PKG_CHECK_MODULES([x264], [x264], sys_x264=yes, sys_x264=no)
+
 --- a/test/module.defs
 +++ b/test/module.defs
 @@ -69,6 +69,9 @@
diff --git a/srcpkgs/handbrake/patches/libhb-vpl-include.patch b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
new file mode 100644
index 00000000000000..298f9f4ab28f2a
--- /dev/null
+++ b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
@@ -0,0 +1,15 @@
+--- a/libhb/module.defs	2023-01-22 11:36:49.000000000 -0500
++++ b/libhb/module.defs	2023-04-03 22:37:52.395467010 -0400
+@@ -46,11 +46,7 @@
+ LIBHB.GCC.I += $(LIBHB.build/) $(CONTRIB.build/)include
+ 
+ ifeq (1,$(FEATURE.qsv))
+-    ifeq ($(HOST.system),freebsd))
+-        LIBHB.GCC.I += $(LOCALBASE)/include/vpl
+-    else
+-        LIBHB.GCC.I += $(CONTRIB.build/)include/vpl
+-    endif
++    LIBHB.GCC.I += /usr/include/vpl
+ endif
+ 
+ ifneq (,$(filter $(HOST.system),freebsd netbsd openbsd))
diff --git a/srcpkgs/handbrake/template b/srcpkgs/handbrake/template
index ca5e4571e49c37..c32cb1bfa31f4b 100644
--- a/srcpkgs/handbrake/template
+++ b/srcpkgs/handbrake/template
@@ -1,10 +1,10 @@
 # Template file for 'handbrake'
 pkgname=handbrake
-version=1.5.1
+version=1.6.1
 revision=1
 build_style=gnu-configure
 configure_args="--force --disable-gtk-update-checks --disable-df-fetch --harden
- $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc)"
+ $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc) $(vopt_enable qsv)"
 make_build_args="-C ${XBPS_TRIPLET}"
 make_install_args="-C ${XBPS_TRIPLET}"
 hostmakedepends="automake cmake gettext-devel glib-devel intltool libtool m4 meson nasm pkg-config python3"
@@ -12,8 +12,11 @@ makedepends="bzip2-devel ffmpeg-devel gst-plugins-base1-devel gtk+3-devel
  jansson-devel lame-devel libass-devel libbluray-devel libdav1d-devel
  libdvdnav-devel libdvdread-devel libgudev-devel libnuma-devel
  libsamplerate-devel libtheora-devel libvorbis-devel libvpx-devel libxml2-devel
- opus-devel speex-devel x264-devel x265-devel zimg-devel
+ opus-devel speex-devel x264-devel x265-devel zimg-devel libsvt-av1-devel
  $(vopt_if fdk_aac fdk-aac-devel)
+ $(vopt_if qsv libva-devel)
+ $(vopt_if qsv libdrm-devel)
+ $(vopt_if qsv onevpl-devel)
  $(vopt_if nvenc nv-codec-headers)"
 depends="desktop-file-utils gst-plugins-good1 hicolor-icon-theme"
 short_desc="Multithreaded video transcoder"
@@ -21,15 +24,15 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-2.0-only"
 homepage="https://handbrake.fr/"
 distfiles="https://github.com/HandBrake/HandBrake/releases/download/${version}/HandBrake-${version}-source.tar.bz2"
-checksum=3999fe06d5309c819799a73a968a8ec3840e7840c2b64af8f5cdb7fd8c9430f0
+checksum=94ccfe03db917a91650000c510f7fd53f844da19f19ad4b4be1b8f6bc31a8d4c
 nocross=yes
 
-build_options="fdk_aac nvenc"
+build_options="fdk_aac nvenc qsv"
 
 case "$XBPS_TARGET_MACHINE" in
 	x86_64*|i686*)
 		CFLAGS="-msse"
-		build_options_default="nvenc"
+		build_options_default="nvenc qsv"
 		;;
 esac
 
@@ -37,7 +40,7 @@ pre_configure() {
 	# use system libraries, don't download them
 	rm -rf contrib/
 	for module in fdk-aac ffmpeg libbluray libdav1d libdvdnav libdvdread nvenc \
-		x265 zimg; do
+		x265 zimg svt-av1 libvpl; do
 	    vsed -i "/MODULES += contrib\/${module}/d" make/include/main.defs
 	done
 }

From 5e282b49121f6b5d1c1e0ec0073dec9bf564b267 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 038/113] hedgewars: revbump for ffmpeg4

---
 srcpkgs/hedgewars/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/hedgewars/template b/srcpkgs/hedgewars/template
index 94b6db673b0c3a..402ccfaaecbc2d 100644
--- a/srcpkgs/hedgewars/template
+++ b/srcpkgs/hedgewars/template
@@ -1,13 +1,13 @@
 # Template file for 'hedgewars'
 pkgname=hedgewars
 version=1.0.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DNOSERVER=1 -DDATA_INSTALL_DIR=/usr/share/${pkgname}
  -DPHYSFS_SYSTEM=1 -DMINIMAL_FLAGS=1"
 make_cmd=make
 hostmakedepends="lua51 pkg-config qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
+makedepends="ffmpeg4-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
  SDL2_mixer-devel SDL2_net-devel SDL2_ttf-devel"
 depends="libfreeglut"
 short_desc="Funny turn-based artillery game, featuring fighting Hedgehogs!"

From 827ab58188bb74903d256eb663d38301e0e607ef Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 039/113] idjc: revbump for ffmpeg4

---
 srcpkgs/idjc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/idjc/template b/srcpkgs/idjc/template
index a9cde0665d55b1..f41e1e4fabbae7 100644
--- a/srcpkgs/idjc/template
+++ b/srcpkgs/idjc/template
@@ -1,11 +1,11 @@
 # Template file for 'idjc'
 pkgname=idjc
 version=0.9.1
-revision=5
+revision=6
 build_style=gnu-configure
 hostmakedepends="pkg-config git python3 automake gettext-devel libtool"
 makedepends="libvorbis-devel libogg-devel jack-devel libsamplerate-devel
- libflac-devel libsndfile-devel mpg123-devel ffmpeg-devel speex-devel
+ libflac-devel libsndfile-devel mpg123-devel ffmpeg4-devel speex-devel
  glib-devel pixman-devel lame-devel python3-gobject-devel libshout-idjc-devel
  opus-devel twolame-devel python3-mutagen python3-devel"
 depends="python3-gobject python3-mutagen desktop-file-utils shared-mime-info python3-dbus jack"

From 445d18f7b0c37827438b20e5909000d1bed0551d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 040/113] kid3: revbump for ffmpeg6

---
 srcpkgs/kid3/patches/ffmpeg5.patch | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 srcpkgs/kid3/patches/ffmpeg5.patch

diff --git a/srcpkgs/kid3/patches/ffmpeg5.patch b/srcpkgs/kid3/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..135fc50e07c9ba
--- /dev/null
+++ b/srcpkgs/kid3/patches/ffmpeg5.patch
@@ -0,0 +1,17 @@
+# https://aur.archlinux.org/cgit/aur.git/diff/ffmpeg5.patch?h=kid3-cli&id=12410a74906612e7efc0ec8fbce739b4a0fef7e7
+diff --git a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+index e156d424..e12b9abd 100644
+--- a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
++++ b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+@@ -232,7 +232,11 @@ private:
+   friend class Format;
+   friend class Converter;
+   AVCodecContext* m_ptr;
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 0, 0)
+   AVCodec* m_impl;
++#else
++  const AVCodec* m_impl;
++#endif
+   AVFrame* m_frame;
+   bool m_opened;
+ };

From e903c736e1bf2f3fb1e0019f94eae40696c19e05 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 041/113] kodi: revbump for ffmpeg4

---
 srcpkgs/kodi/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/kodi/template b/srcpkgs/kodi/template
index d37a5918cd6758..ea78e0aca0fe3e 100644
--- a/srcpkgs/kodi/template
+++ b/srcpkgs/kodi/template
@@ -1,7 +1,7 @@
 # Template file for 'kodi'
 pkgname=kodi
 version=19.4
-revision=9
+revision=10
 _codename="Matrix"
 build_style=cmake
 configure_args="-DWITH_FFMPEG=/usr -DENABLE_LDGOLD=OFF
@@ -54,7 +54,7 @@ makedepends="
  libmad-devel fontconfig-devel libXinerama-devel libsamplerate-devel libmms-devel
  enca-devel boost-devel libcurl-devel libva-devel libvdpau-devel libass-devel
  libbluetooth-devel yajl-devel libplist-devel librtmp-devel tinyxml-devel
- taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg-devel
+ taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg4-devel
  giflib-devel libxslt-devel gnutls-devel libssh-devel libmicrohttpd-devel
  libcec-devel dcadec-devel flatbuffers-devel fmt-devel lcms2-devel
  libfstrcmp-devel rapidjson libcdio-paranoia spdlog libwaylandpp-devel

From 901b0e52360bf0a52387cfd3c193c2a20357245d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 042/113] kpipewire: revbump for ffmpeg6

---
 srcpkgs/kpipewire/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kpipewire/template b/srcpkgs/kpipewire/template
index 6214a4451336e7..3555348659dded 100644
--- a/srcpkgs/kpipewire/template
+++ b/srcpkgs/kpipewire/template
@@ -1,7 +1,7 @@
 # Template file for 'kpipewire'
 pkgname=kpipewire
 version=5.27.10
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules plasma-wayland-protocols gettext
  qt5-qmake qt5-host-tools pkg-config wayland-devel kcoreaddons

From ffb6af8fb0e9a2769046149362099d6b471bb5e9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 043/113] libextractor: revbump for ffmpeg4

---
 srcpkgs/libextractor/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/libextractor/template b/srcpkgs/libextractor/template
index 044c663a3a0b92..06e63bc3189d5e 100644
--- a/srcpkgs/libextractor/template
+++ b/srcpkgs/libextractor/template
@@ -1,13 +1,13 @@
 # Template file for 'libextractor'
 pkgname=libextractor
 version=1.11
-revision=4
+revision=5
 build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="pkg-config"
 makedepends="zlib-devel bzip2-devel exiv2-devel tiff-devel libpng-devel
  libjpeg-turbo-devel libvorbis-devel libflac-devel giflib-devel libmpeg2-devel
- ffmpeg-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
+ ffmpeg4-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
 short_desc="Library used to extract meta data from files"
 maintainer="Martin Riese <grauehaare@gmx.de>"
 license="GPL-3.0-or-later"

From b5470632aea407536739d0c7153b9ee78155e67e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 044/113] libopenal: revbump for ffmpeg6

---
 srcpkgs/libopenal/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenal/template b/srcpkgs/libopenal/template
index 88d0f11307d81a..8308fca0393e33 100644
--- a/srcpkgs/libopenal/template
+++ b/srcpkgs/libopenal/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenal'
 pkgname=libopenal
 version=1.23.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DALSOFT_EXAMPLES=OFF"
 hostmakedepends="pkg-config"

From c67bd474a61c4d2f3cf10cf5589d6721f504d2f1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 045/113] loudgain: revbump for ffmpeg6

---
 srcpkgs/loudgain/patches/ffmpeg5.patch | 11 +++++++++++
 srcpkgs/loudgain/template              |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/loudgain/patches/ffmpeg5.patch

diff --git a/srcpkgs/loudgain/patches/ffmpeg5.patch b/srcpkgs/loudgain/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..16d4510ee98faa
--- /dev/null
+++ b/srcpkgs/loudgain/patches/ffmpeg5.patch
@@ -0,0 +1,11 @@
+--- a/src/scan.c	2019-09-06 11:31:19.000000000 -0400
++++ b/src/scan.c	2023-03-23 11:15:40.867968521 -0400
+@@ -69,8 +69,6 @@
+ 	 * It is now useless
+ 	 * https://github.com/FFmpeg/FFmpeg/blob/70d25268c21cbee5f08304da95be1f647c630c15/doc/APIchanges#L86
+ 	 */
+-  if (avformat_version() < AV_VERSION_INT(58,9,100))
+-    av_register_all();
+ 
+ 	av_log_set_callback(scan_av_log);
+ 
diff --git a/srcpkgs/loudgain/template b/srcpkgs/loudgain/template
index da4f2d56e94c3d..4d6bf29efb4fdd 100644
--- a/srcpkgs/loudgain/template
+++ b/srcpkgs/loudgain/template
@@ -1,7 +1,7 @@
 # Template file for 'loudgain'
 pkgname=loudgain
 version=0.6.8
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libebur128-devel taglib-devel ffmpeg-devel"

From 654bdde7bc0adabb832f45ef065b8a794303dc41 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 046/113] mediastreamer: revbump for ffmpeg4

---
 srcpkgs/mediastreamer/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mediastreamer/template b/srcpkgs/mediastreamer/template
index 0fcffa7653d18e..e888626b945e55 100644
--- a/srcpkgs/mediastreamer/template
+++ b/srcpkgs/mediastreamer/template
@@ -1,11 +1,11 @@
 # Template file for 'mediastreamer'
 pkgname=mediastreamer
 version=5.2.111
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DENABLE_STRICT=0 -DENABLE_UNIT_TESTS=0"
 hostmakedepends="python3"
-makedepends="bzrtp-devel ffmpeg-devel glew-devel libXv-devel libsrtp-devel
+makedepends="bzrtp-devel ffmpeg4-devel glew-devel libXv-devel libsrtp-devel
  libupnp-devel libvpx-devel mbedtls-devel opus-devel ortp-devel pulseaudio-devel
  libtheora-devel speex-devel v4l-utils-devel bcg729-devel bcmatroska2-devel libgsm-devel
  zxing-cpp-devel"

From c37ec6050a1aee51df858782b46d507fb424da26 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 047/113] mgba: revbump for ffmpeg6

---
 srcpkgs/mgba/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mgba/template b/srcpkgs/mgba/template
index 6cd65650312543..93401adb618bd8 100644
--- a/srcpkgs/mgba/template
+++ b/srcpkgs/mgba/template
@@ -1,7 +1,7 @@
 # Template file for 'mgba'
 pkgname=mgba
 version=0.10.3
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake desktop-file-utils"
 makedepends="SDL2-devel ffmpeg-devel libedit-devel libepoxy-devel libmagick-devel

From 5620569f1eecfe762562bc7ed1c6d55254fefa2e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 048/113] mlt: revbump for ffmpeg4

---
 srcpkgs/mlt/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mlt/template b/srcpkgs/mlt/template
index 73e3915aaab9ac..d7ed4c4b30a868 100644
--- a/srcpkgs/mlt/template
+++ b/srcpkgs/mlt/template
@@ -1,14 +1,14 @@
 # Template file for 'mlt'
 pkgname=mlt
 version=6.26.1
-revision=3
+revision=4
 build_style=configure
 configure_args="--prefix=/usr --libdir=/usr/lib$XBPS_TARGET_WORDSIZE
  --enable-gpl --enable-gpl3 --disable-swfdec --without-kde
  --swig-languages=python"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which"
 # XXX: movit vid.stab
-makedepends="alsa-lib-devel ffmpeg-devel gtk+-devel jack-devel ladspa-sdk
+makedepends="alsa-lib-devel ffmpeg4-devel gtk+-devel jack-devel ladspa-sdk
  libexif-devel libsamplerate-devel libxml2-devel sox-devel SDL_image-devel
  fftw-devel frei0r-plugins python3-devel pulseaudio-devel movit-devel
  libvidstab-devel"

From ce3d7719236ec68c7e9c4d4f803cbc451ed38cbb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 049/113] moc: revbump for ffmpeg4

---
 srcpkgs/moc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/moc/template b/srcpkgs/moc/template
index 3a04932c8f1e61..838755f88db09e 100644
--- a/srcpkgs/moc/template
+++ b/srcpkgs/moc/template
@@ -1,10 +1,10 @@
 # Template file for 'moc'
 pkgname=moc
 version=2.5.2
-revision=7
+revision=8
 build_style=gnu-configure
 hostmakedepends="pkg-config"
-makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg-devel
+makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg4-devel
  jack-devel alsa-lib-devel libltdl-devel libflac-devel libvorbis-devel
  libmad-devel libmpcdec-devel libmodplug-devel libid3tag-devel faad2-devel
  taglib-devel libsndfile-devel wavpack-devel speex-devel libsamplerate-devel

From 9eab37b03ad1c98beb52a332ea7d32735fa21f01 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 050/113] motion: revbump for ffmpeg6

---
 srcpkgs/motion/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/motion/template b/srcpkgs/motion/template
index 607ebeb3c7b242..bf63a91d9764f6 100644
--- a/srcpkgs/motion/template
+++ b/srcpkgs/motion/template
@@ -1,7 +1,7 @@
 # Template file for 'motion'
 pkgname=motion
 version=4.6.0
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake pkg-config gettext-devel tar"
 makedepends="ffmpeg-devel libmicrohttpd-devel v4l-utils-devel gettext-devel"

From f6ebdd2125efcee1d44f6dae5c78307b42c8633e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 051/113] olive: revbump for ffmpeg4

---
 srcpkgs/olive/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/olive/template b/srcpkgs/olive/template
index 12a46936c99003..5c2917b9c51245 100644
--- a/srcpkgs/olive/template
+++ b/srcpkgs/olive/template
@@ -1,10 +1,10 @@
 # Template file for 'olive'
 pkgname=olive
 version=0.1.2
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools pkg-config"
-makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg-devel frei0r-plugins"
+makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg4-devel frei0r-plugins"
 short_desc="Non-linear video editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"

From 838ea4fbb1e09cf58d90dd2e3cd1aab4df048e52 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 052/113] opentoonz: revbump for ffmpeg6

---
 srcpkgs/opentoonz/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/opentoonz/template b/srcpkgs/opentoonz/template
index ee9f7603f55fd8..3e81834ca0eddf 100644
--- a/srcpkgs/opentoonz/template
+++ b/srcpkgs/opentoonz/template
@@ -1,7 +1,7 @@
 # Template file for 'opentoonz'
 pkgname=opentoonz
 version=1.6.0
-revision=2
+revision=3
 build_wrksrc="toonz/sources"
 build_style=cmake
 make_cmd=make

From f10d68d8a3540d5be0eb55f4a181661165dc8713 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 053/113] pianobar: revbump for ffmpeg6

---
 srcpkgs/pianobar/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pianobar/template b/srcpkgs/pianobar/template
index e3febb821a4510..1e3dc1bf9308ee 100644
--- a/srcpkgs/pianobar/template
+++ b/srcpkgs/pianobar/template
@@ -1,7 +1,7 @@
 # Template file for 'pianobar'
 pkgname=pianobar
 version=2022.04.01
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="V=1"
 hostmakedepends="pkg-config"

From 1914bb12aeec45381f6d0c2ea1f6b863736234f8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 054/113] ppsspp: revbump for ffmpeg4

---
 srcpkgs/ppsspp/template | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/srcpkgs/ppsspp/template b/srcpkgs/ppsspp/template
index 2c0ded496eb981..8bf55f65198cdc 100644
--- a/srcpkgs/ppsspp/template
+++ b/srcpkgs/ppsspp/template
@@ -1,7 +1,7 @@
 # Template file for 'ppsspp'
 pkgname=ppsspp
 version=1.16.6
-revision=1
+revision=2
 _glslang_commit=b34f619e1c85810dcb3c578107d2e48ba4ee2b37
 _SPIRV_Cross_commit=4212eef67ed0ca048cb726a6767185504e7695e5
 _armips_commit=7bd1ec93d4586985ba1ef420b43b5e620f68695e
@@ -15,7 +15,7 @@ configure_args="-DHEADLESS=1 -DUSE_SYSTEM_FFMPEG=1 -DUNITTEST=ON
  -DUSING_QT_UI=$(vopt_if qt ON OFF) -DUSE_SYSTEM_ZSTD=ON
  -DARMIPS_USE_STD_FILESYSTEM=ON"
 hostmakedepends="pkg-config python3 $(vopt_if qt qt5-host-tools)"
-makedepends="zlib-devel glew-devel ffmpeg-devel libzip-devel
+makedepends="zlib-devel glew-devel ffmpeg4-devel libzip-devel
  snappy-devel rapidjson libpng-devel libzstd-devel
  $(vopt_if sdl2 'SDL2_ttf-devel SDL2-devel') $(vopt_if wayland wayland-devel)
  $(vopt_if qt 'qt5-devel qt5-multimedia-devel')"
@@ -69,10 +69,10 @@ post_extract() {
 	rmdir -v ${wrksrc}/ext/cpu_features
 	mv ${wrksrc}/cpu_features-${_cpu_features_commit} ${wrksrc}/ext/cpu_features
 	rmdir -v ${wrksrc}/ext/rcheevos
-        mv ${wrksrc}/rcheevos-${_rcheevos_commit} ${wrksrc}/ext/rcheevos
+	mv ${wrksrc}/rcheevos-${_rcheevos_commit} ${wrksrc}/ext/rcheevos
 }
 
-post_patch(){
+post_patch() {
 	# disable git versioning
 	vsed -e 's|find_package(Git)|# &|' -i git-version.cmake
 }
@@ -85,7 +85,6 @@ post_configure() {
 }
 
 do_install() {
-	vlicense LICENSE.TXT
 	vinstall icons/icon.svg 644 usr/share/pixmaps ppsspp.svg
 	vinstall Qt/PPSSPP.desktop 644 usr/share/applications
 	vbin build/PPSSPPHeadless ppsspp-headless

From 11375209e81b24688e32daa60b6c14a879beb0a2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 055/113] pqiv: revbump for ffmpeg6

---
 srcpkgs/pqiv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pqiv/template b/srcpkgs/pqiv/template
index 542fc27a2d32a4..9308d949b6a1c7 100644
--- a/srcpkgs/pqiv/template
+++ b/srcpkgs/pqiv/template
@@ -1,7 +1,7 @@
 # Template file for 'pqiv'
 pkgname=pqiv
 version=2.12
-revision=1
+revision=2
 build_style=gnu-makefile
 hostmakedepends="pkg-config"
 makedepends="glib-devel gtk+3-devel $(vopt_if ffmpeg ffmpeg-devel)

From 977ef291009072702e32b367def2768b0ce2520e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 056/113] qmmp: revbump for ffmpeg6

---
 srcpkgs/qmmp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qmmp/template b/srcpkgs/qmmp/template
index 53781ea3bc28ad..2da07f1e87eac0 100644
--- a/srcpkgs/qmmp/template
+++ b/srcpkgs/qmmp/template
@@ -1,7 +1,7 @@
 # Template file for 'qmmp'
 pkgname=qmmp
 version=1.6.1
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DUSE_HAL:BOOL=FALSE -DQMMP_DEFAULT_UI:STRING=simple"
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From acb84f917961e7cc3a3e016a68e0844eabe90e78 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 14 Dec 2023 13:28:10 -0500
Subject: [PATCH 057/113] qt6-pdf: revbump for ffmpeg6

---
 srcpkgs/qt6-pdf/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-pdf/template b/srcpkgs/qt6-pdf/template
index ecda84afac1310..531b4e1d4fe84d 100644
--- a/srcpkgs/qt6-pdf/template
+++ b/srcpkgs/qt6-pdf/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-pdf'
 pkgname=qt6-pdf
 version=6.6.0
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DQT_FEATURE_qtpdf_build=ON
  -DQT_FEATURE_qtpdf_widgets_build=ON

From d4558524b71ba7da5d4d31da867567caafb426b9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 058/113] qt5-webengine: revbump for ffmpeg6

---
 .../chromium-media-filters-cpp14.patch        |  11 ++
 srcpkgs/qt5-webengine/patches/ffmpeg5.patch   | 179 ++++++++++++++++++
 .../qtwebengine-fix-ffmpeg5-build.patch       |  14 ++
 srcpkgs/qt5-webengine/template                |   4 +-
 4 files changed, 206 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/ffmpeg5.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch

diff --git a/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
new file mode 100644
index 00000000000000..04adc540f2cbc0
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
@@ -0,0 +1,11 @@
+--- a/src/3rdparty/chromium/media/filters/BUILD.gn	2023-02-27 13:32:59.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/BUILD.gn	2023-04-02 17:21:39.204066384 -0400
+@@ -96,6 +96,8 @@
+     "//ui/gfx/geometry:geometry",
+   ]
+ 
++  cflags_cc = [ "-std=c++14" ]
++
+   libs = []
+ 
+   if (proprietary_codecs) {
diff --git a/srcpkgs/qt5-webengine/patches/ffmpeg5.patch b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..ac55e1634423a9
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
@@ -0,0 +1,179 @@
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:57.732547446 -0400
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:09.486478995 -0400
+@@ -57,6 +57,8 @@
+ 
+ namespace {
+ 
++constexpr int64_t kRelativeTsBase = static_cast<int64_t>(0x7ffeffffffffffff);
++
+ void SetAVStreamDiscard(AVStream* stream, AVDiscard discard) {
+   DCHECK(stream);
+   stream->discard = discard;
+@@ -90,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+   if (stream->start_time != kNoFFmpegTimestamp)
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (stream->first_dts != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, stream->first_dts);
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -408,11 +398,11 @@
+   scoped_refptr<DecoderBuffer> buffer;
+ 
+   if (type() == DemuxerStream::TEXT) {
+-    int id_size = 0;
++    size_t id_size = 0;
+     uint8_t* id_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
+ 
+-    int settings_size = 0;
++    size_t settings_size = 0;
+     uint8_t* settings_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
+ 
+@@ -424,7 +414,7 @@
+     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
+                                      side_data.data(), side_data.size());
+   } else {
+-    int side_data_size = 0;
++    size_t side_data_size = 0;
+     uint8_t* side_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
+ 
+@@ -485,7 +475,7 @@
+                                        packet->size - data_offset);
+     }
+ 
+-    int skip_samples_size = 0;
++    size_t skip_samples_size = 0;
+     const uint32_t* skip_samples_ptr =
+         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
+             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
+@@ -1587,6 +1577,8 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++      continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+       lowest_start_time_stream = stream.get();
+@@ -1604,6 +1596,8 @@
+     if (stream && stream->type() == DemuxerStream::VIDEO &&
+         stream->IsEnabled()) {
+       video_stream = stream.get();
++      if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++        continue;
+       if (video_stream->start_time() <= seek_time) {
+         return video_stream;
+       }
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h qtwebengine-5.15.10/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h
+--- a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-07-11 22:12:47.917192788 -0500
+@@ -29,6 +29,7 @@ extern "C" {
+ #include <libavformat/avformat.h>
+ #include <libavformat/avio.h>
+ #include <libavutil/avutil.h>
++#include <libavutil/channel_layout.h>
+ #include <libavutil/imgutils.h>
+ #include <libavutil/log.h>
+ #include <libavutil/mastering_display_metadata.h>
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/audio_file_reader.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/audio_file_reader.cc
+--- a/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -85,7 +85,7 @@ bool AudioFileReader::OpenDemuxer() {
+ }
+ 
+ bool AudioFileReader::OpenDecoder() {
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (codec) {
+     // MP3 decodes to S16P which we don't support, tell it to use S16 instead.
+     if (codec_context_->sample_fmt == AV_SAMPLE_FMT_S16P)
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -329,7 +329,7 @@ bool FFmpegAudioDecoder::ConfigureDecode
+     }
+   }
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec ||
+       avcodec_open2(codec_context_.get(), codec, &codec_options) < 0) {
+     DLOG(ERROR) << "Could not initialize audio decoder: "
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -59,7 +59,6 @@ static int64_t AVIOSeekOperation(void* o
+ }
+ 
+ void FFmpegGlue::InitializeFFmpeg() {
+-  av_register_all();
+ }
+ 
+ static void LogContainer(bool is_local_file,
+@@ -95,9 +94,6 @@ FFmpegGlue::FFmpegGlue(FFmpegURLProtocol
+   // Enable fast, but inaccurate seeks for MP3.
+   format_context_->flags |= AVFMT_FLAG_FAST_SEEK;
+ 
+-  // Ensures we can read out various metadata bits like vp8 alpha.
+-  format_context_->flags |= AVFMT_FLAG_KEEP_SIDE_DATA;
+-
+   // Ensures format parsing errors will bail out. From an audit on 11/2017, all
+   // instances were real failures. Solves bugs like http://crbug.com/710791.
+   format_context_->error_recognition |= AV_EF_EXPLODE;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -391,7 +391,7 @@ bool FFmpegVideoDecoder::ConfigureDecode
+   if (decode_nalus_)
+     codec_context_->flags2 |= AV_CODEC_FLAG2_CHUNKS;
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
+     ReleaseFFmpegResources();
+     return false;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/media_file_checker.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/media_file_checker.cc
+--- a/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -68,7 +68,7 @@ bool MediaFileChecker::Start(base::TimeD
+       auto context = AVStreamToAVCodecContext(format_context->streams[i]);
+       if (!context)
+         continue;
+-      AVCodec* codec = avcodec_find_decoder(cp->codec_id);
++      const AVCodec* codec = avcodec_find_decoder(cp->codec_id);
+       if (codec && avcodec_open2(context.get(), codec, nullptr) >= 0) {
+         auto loop = std::make_unique<FFmpegDecodingLoop>(context.get());
+         stream_contexts[i] = {std::move(context), std::move(loop)};
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc qtwebengine-5.15.10/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc
+--- a/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -203,7 +203,7 @@ int32_t H264DecoderImpl::InitDecode(cons
+   // a pointer |this|.
+   av_context_->opaque = this;
+ 
+-  AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
+   if (!codec) {
+     // This is an indication that FFmpeg has not been initialized or it has not
+     // been compiled/initialized with the correct set of codecs.
diff --git a/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch b/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch
new file mode 100644
index 00000000000000..bc24d5b9a29cb5
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch
@@ -0,0 +1,14 @@
+--- a/src/buildtools/configure.json	2023-12-09 11:06:01.503058569 -0500
++++ b/src/buildtools/configure.json	2023-12-09 11:06:14.982361345 -0500
+@@ -779,11 +779,6 @@
+             "type": "warning",
+             "condition": "config.ios && config.simulator && config.device && features.build-qtpdf",
+             "message": "Building fat libray with device and simulator architectures will disable NEON."
+-        },
+-        {
+-            "type": "fatal",
+-            "condition": "features.webengine-system-ffmpeg && !libs.webengine-ffmpeg-support",
+-            "message": "Unmodified ffmpeg >= 5.0 is not supported. Please configure with -qt-webengine-ffmpeg."
+         }
+     ],
+     "summary": [
diff --git a/srcpkgs/qt5-webengine/template b/srcpkgs/qt5-webengine/template
index 8d2df1b5175bad..1687a77eb8a2f5 100644
--- a/srcpkgs/qt5-webengine/template
+++ b/srcpkgs/qt5-webengine/template
@@ -1,14 +1,14 @@
 # Template file for 'qt5-webengine'
 pkgname=qt5-webengine
 version=5.15.16
-revision=1
+revision=2
 _version="${version}-lts"
 _chromium_commit=207c2ac45ca3386d153770c6b0d2ea2ec21ca880
 archs="x86_64* i686* armv[67]* ppc64* aarch64*"
 create_wrksrc=yes
 build_style=qmake
 configure_args="--
- -webengine-icu -webengine-ffmpeg -webengine-opus -webengine-webp
+ -webengine-icu -system-ffmpeg -webengine-opus -webengine-webp
  -webengine-pepper-plugins -webengine-printing-and-pdf -webengine-proprietary-codecs
  -webengine-pulseaudio -webengine-spellchecker -webengine-webrtc -webengine-geolocation
  -webengine-kerberos -no-webengine-embedded-build $(vopt_if sndio '' '-no')-webengine-sndio

From df8d5c8d3cf7d88316cd6b61099ffc491ca50999 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 059/113] qt5: revbump for ffmpeg6

---
 srcpkgs/qt5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5/template b/srcpkgs/qt5/template
index ef6e437e02dbc5..6f6aacb663b26a 100644
--- a/srcpkgs/qt5/template
+++ b/srcpkgs/qt5/template
@@ -3,9 +3,9 @@
 # revbump libqtxdg after bumping patch version
 pkgname=qt5
 version=5.15.11+20231124
+revision=2
 # commit 4765fa1df7a837db9c1f89c4da0dd76b74bb5fab
 # base repo: https://invent.kde.org/qt/qt/qt5
-revision=1
 build_style=meta
 hostmakedepends="cmake clang flex perl glib-devel pkg-config
  python3 re2c ruby which"

From 1f864f70ab531c4c0d5d0ffb3bfe201fb2398f87 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 060/113] qtav: revbump for ffmpeg4

---
 srcpkgs/qtav/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtav/template b/srcpkgs/qtav/template
index 775d5a139a9efa..aa69e213c984b0 100644
--- a/srcpkgs/qtav/template
+++ b/srcpkgs/qtav/template
@@ -1,10 +1,10 @@
 # Template file for 'qtav'
 pkgname=qtav
 version=1.13.0
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel libass-devel libopenal-devel
+makedepends="ffmpeg4-devel libass-devel libopenal-devel
  libva-glx-devel libXv-devel pulseaudio-devel
  qt5-declarative-devel qt5-svg-devel
  qt5-quickcontrols"

From 9b055f582742cc80b3f156364dda88a618ddeabc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 061/113] retroarch: revbump for ffmpeg6

---
 srcpkgs/retroarch/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroarch/template b/srcpkgs/retroarch/template
index cb3125c5dbf1ae..c65c26f7bf0332 100644
--- a/srcpkgs/retroarch/template
+++ b/srcpkgs/retroarch/template
@@ -1,7 +1,7 @@
 # Template file for 'retroarch'
 pkgname=retroarch
 version=1.16.0.3
-revision=3
+revision=4
 build_style=configure
 configure_args="--prefix=/usr --sysconfdir=/etc --enable-networking
  --enable-udev --disable-builtinflac --disable-builtinglslang

From 1446a8aa1ce3ca44bb960a7c690e26bf2e4326ae Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 062/113] scrcpy: revbump for ffmpeg6

---
 srcpkgs/scrcpy/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/scrcpy/template b/srcpkgs/scrcpy/template
index ac18bc03418ce7..f39a7f678ab359 100644
--- a/srcpkgs/scrcpy/template
+++ b/srcpkgs/scrcpy/template
@@ -1,7 +1,7 @@
 # Template file for 'scrcpy'
 pkgname=scrcpy
 version=2.1.1
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcompile_server=false
  -Dprebuilt_server=/usr/share/scrcpy/scrcpy-server-v${version}"

From da666e6ee0b1404c0dd477a40b24d4888553b77c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 17 Oct 2023 08:54:11 -0400
Subject: [PATCH 063/113] New package: spex-x replaces spek-alternative for
 ffmpeg6

---
 srcpkgs/spek-alternative                      |  1 +
 srcpkgs/{spek-alternative => spek-x}/template | 22 ++++++++++++-------
 2 files changed, 15 insertions(+), 8 deletions(-)
 create mode 120000 srcpkgs/spek-alternative
 rename srcpkgs/{spek-alternative => spek-x}/template (52%)

diff --git a/srcpkgs/spek-alternative b/srcpkgs/spek-alternative
new file mode 120000
index 00000000000000..76648236da7017
--- /dev/null
+++ b/srcpkgs/spek-alternative
@@ -0,0 +1 @@
+spek-x
\ No newline at end of file
diff --git a/srcpkgs/spek-alternative/template b/srcpkgs/spek-x/template
similarity index 52%
rename from srcpkgs/spek-alternative/template
rename to srcpkgs/spek-x/template
index d7b55c776b1d43..3ded6c2c323e4f 100644
--- a/srcpkgs/spek-alternative/template
+++ b/srcpkgs/spek-x/template
@@ -1,18 +1,18 @@
-# Template file for 'spek-alternative'
-pkgname=spek-alternative
-version=0.8.2.3
-revision=2
+# Template file for 'spek-x'
+pkgname=spek-x
+version=0.9.3
+revision=1
 build_style=gnu-configure
 hostmakedepends="automake gettext-devel intltool libtool pkg-config
  wxWidgets-common wxWidgets-gtk3-devel"
 makedepends="ffmpeg-devel wxWidgets-gtk3-devel"
 depends="ffmpeg"
 short_desc="Acoustic spectrum analyser"
-maintainer="Kartik Singh <kartik.ynwa@gmail.com>"
+maintainer="zlice <zlice555@gmail.com>"
 license="GPL-3.0-or-later"
-homepage="https://github.com/withmorten/spek-alternative"
-distfiles="https://github.com/withmorten/spek-alternative/archive/${version}.tar.gz"
-checksum="007ba4b84a310b078e378aa84c8e80783db5821437a757a488c3ecec377e6b2a"
+homepage="https://github.com/MikeWang000000/spek-x"
+distfiles="https://github.com/MikeWang000000/spek-x/archive/v${version}.tar.gz"
+checksum="7f4b109903333cdd310ab2b9176f0dc49a565891376e281a233d342cedf90ef7"
 
 CXXFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
 
@@ -22,3 +22,9 @@ export WX_CONFIG_NAME="wx-config-gtk3"
 pre_configure() {
 	NOCONFIGURE=1 ./autogen.sh
 }
+
+spek-alternative_package() {
+	depends="spek-x"
+	short_desc+=" - transitional dummy package"
+	build_style=meta
+}

From 32f8ac617bc7494a31b5256a578e2248bfbb67c4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 064/113] ssr: revbump for ffmpeg4

---
 srcpkgs/ssr/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/ssr/template b/srcpkgs/ssr/template
index 3097754e3cbe54..6609c16c4ed8e8 100644
--- a/srcpkgs/ssr/template
+++ b/srcpkgs/ssr/template
@@ -1,11 +1,11 @@
 # Template file for 'ssr'
 pkgname=ssr
 version=0.4.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DWITH_QT5=ON"
 hostmakedepends="pkg-config"
-makedepends="alsa-lib-devel ffmpeg-devel glu-devel jack-devel pulseaudio-devel
+makedepends="alsa-lib-devel ffmpeg4-devel glu-devel jack-devel pulseaudio-devel
  qt5-tools-devel qt5-x11extras-devel libXinerama-devel v4l-utils-devel"
 depends="desktop-file-utils hicolor-icon-theme"
 short_desc="Simple Screen Recorder for programs and games"

From 312e0b48380799c1c2253c47c646a0e3a8f699dd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 065/113] synfig: revbump for ffmpeg6 and mlt7

---
 srcpkgs/synfig/patches/ffmpeg6.patch | 71 ++++++++++++++++++++++++++++
 srcpkgs/synfig/template              |  6 +--
 2 files changed, 74 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/synfig/patches/ffmpeg6.patch

diff --git a/srcpkgs/synfig/patches/ffmpeg6.patch b/srcpkgs/synfig/patches/ffmpeg6.patch
new file mode 100644
index 00000000000000..10780b42782f4b
--- /dev/null
+++ b/srcpkgs/synfig/patches/ffmpeg6.patch
@@ -0,0 +1,71 @@
+--- a/src/modules/mod_libavcodec/trgt_av.cpp	2022-10-25 09:14:12.000000000 -0400
++++ b/src/modules/mod_libavcodec/trgt_av.cpp	2023-05-05 21:34:17.899194559 -0400
+@@ -38,6 +41,7 @@
+ extern "C"
+ {
+ #ifdef HAVE_LIBAVFORMAT_AVFORMAT_H
++#	include <libavcodec/avcodec.h>
+ #	include <libavformat/avformat.h>
+ #elif defined(HAVE_AVFORMAT_H)
+ #	include <avformat.h>
+@@ -155,11 +156,11 @@
+     }
+ 
+ 	bool open_video_stream() {
+-		if (avcodec_open2(video_context, NULL, NULL) < 0) {
++		if (avcodec_open2(video_context, nullptr, nullptr) < 0) {
+ 			synfig::error("Target_LibAVCodec: could not open video codec");
+ 			// seems the calling of avcodec_free_context after error will cause crash
+ 			// so just forget about this context
+-			video_context = NULL;
++			video_context = nullptr;
+ 			close();
+ 			return false;
+         }
+@@ -234,15 +235,21 @@
+ 		close();
+ 
+ 		if (!av_registered) {
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 			av_register_all();
++#endif
+ 			av_registered = true;
+ 		}
+ 
+ 		// guess format
+-		AVOutputFormat *format = av_guess_format(NULL, filename.c_str(), NULL);
++#if LIBAVCODEC_VERSION_MAJOR < 59 // FFMPEG < 5.0
++		AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#else
++		const AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#endif
+ 		if (!format) {
+ 			synfig::warning("Target_LibAVCodec: unable to guess the output format, defaulting to MPEG");
+-			format = av_guess_format("mpeg", NULL, NULL);
++			format = av_guess_format("mpeg", nullptr, nullptr);
+ 		}
+ 		if (!format) {
+ 			synfig::error("Target_LibAVCodec: unable to find 'mpeg' output format");
+@@ -254,6 +261,7 @@
+ 		context = avformat_alloc_context();
+ 		assert(context);
+ 		context->oformat = format;
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 		if (filename.size() + 1 > sizeof(context->filename)) {
+ 			synfig::error(
+ 				"Target_LibAVCodec: filename too long, max length is %d, filename is '%s'",
+@@ -263,6 +271,14 @@
+ 			return false;
+ 		}
+ 		memcpy(context->filename, filename.c_str(), filename.size() + 1);
++#else
++		context->url = av_strndup(filename.c_str(), filename.size());
++		if (!context->url) {
++			synfig::error("Target_LibAVCodec: cannot allocate space for filename");
++			close();
++			return false;
++		}
++#endif
+ 
+ 		packet = av_packet_alloc();
+ 		assert(packet);
diff --git a/srcpkgs/synfig/template b/srcpkgs/synfig/template
index d4d3e341a20bf8..828b5cb32956ee 100644
--- a/srcpkgs/synfig/template
+++ b/srcpkgs/synfig/template
@@ -2,11 +2,11 @@
 # Should be kept in sync with 'synfigstudio' and 'ETL'
 pkgname=synfig
 version=1.4.4
-revision=4
+revision=5
 build_style=gnu-configure
 configure_args="--with-boost-libdir=${XBPS_CROSS_BASE}/usr/lib"
 hostmakedepends="boost-build ImageMagick pkg-config intltool"
-makedepends="ETL gettext-devel libxml++-devel mlt-devel libmagick-devel
+makedepends="ETL gettext-devel libxml++-devel mlt7-devel libmagick-devel
  libmng-devel boost-build boost-devel libopenexr-devel ffmpeg-devel"
 depends="ImageMagick"
 short_desc="CLI 2D vector and timeline-based animation software"
@@ -20,7 +20,7 @@ CXXFLAGS="-std=c++11 -DHAVE_LOCALE_H=1"
 
 synfig-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision}
-	 libopenexr-devel libxml++-devel mlt-devel"
+	 libopenexr-devel libxml++-devel mlt7-devel"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/bin/synfig-config

From deee0e37a5f959dd66bb80495a089834ee1178f3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 066/113] timg: revbump for ffmpeg6

---
 srcpkgs/timg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/timg/template b/srcpkgs/timg/template
index 2a2ab763d2fddf..8fb4327535ef93 100644
--- a/srcpkgs/timg/template
+++ b/srcpkgs/timg/template
@@ -1,7 +1,7 @@
 # Template file for 'timg'
 pkgname=timg
 version=1.4.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_OPENSLIDE_SUPPORT=off -Wno-dev"
 hostmakedepends="pkg-config git"

From 73291bf1dda167389331b2d710ded271df8733f9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 067/113] tvheadend: revbump for ffmpeg4

---
 srcpkgs/tvheadend/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tvheadend/template b/srcpkgs/tvheadend/template
index 9aea7de4ec7057..012d31c4879ff1 100644
--- a/srcpkgs/tvheadend/template
+++ b/srcpkgs/tvheadend/template
@@ -8,7 +8,7 @@ configure_args="--enable-dvbscan --disable-ffmpeg_static
 --disable-libx265_static --disable-libvpx_static --disable-libtheora_static
 --disable-libvorbis_static --disable-libfdkaac_static"
 hostmakedepends="gettext pkg-config python3 git which"
-makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg-devel"
+makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg4-devel"
 short_desc="TV streaming server"
 maintainer="lemmi <lemmi@nerd2nerd.org>"
 license="GPL-3.0-only"

From e538439daaad316b8da6f9816fe6db62196d65e5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 068/113] unpaper: update to 7.0.0.

---
 srcpkgs/unpaper/template | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/srcpkgs/unpaper/template b/srcpkgs/unpaper/template
index 38ed47a5840165..1ff910e722afc8 100644
--- a/srcpkgs/unpaper/template
+++ b/srcpkgs/unpaper/template
@@ -1,13 +1,13 @@
 # Template file for 'unpaper'
 pkgname=unpaper
-version=6.1
-revision=3
-build_style=gnu-configure
+version=7.0.0
+revision=1
+build_style=meson
+hostmakedepends="pkg-config meson libxslt"
+makedepends="ffmpeg-devel python3-Sphinx"
+short_desc="Post-processing tool for scanned sheets of paper"
 maintainer="Orphaned <orphan@voidlinux.org>"
-hostmakedepends="pkg-config libxslt"
-makedepends="ffmpeg-devel"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://www.flameeyes.eu/projects/unpaper"
-short_desc="A post-processing tool for scanned sheets of paper"
 distfiles="https://www.flameeyes.eu/files/${pkgname}-${version}.tar.xz"
-checksum=237c84f5da544b3f7709827f9f12c37c346cdf029b1128fb4633f9bafa5cb930
+checksum=2575fbbf26c22719d1cb882b59602c9900c7f747118ac130883f63419be46a80

From fd2c9ad0d001f650fb43596378d7017d49795d8e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 069/113] vice: revbump for ffmpeg4

---
 srcpkgs/vice/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/vice/template b/srcpkgs/vice/template
index b1f866d35095e7..43f79243a1da11 100644
--- a/srcpkgs/vice/template
+++ b/srcpkgs/vice/template
@@ -1,7 +1,7 @@
 # Template file for 'vice'
 pkgname=vice
 version=3.7.1
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="
 	$(vopt_enable sdl2 sdlui2)
@@ -26,7 +26,7 @@ makedepends="
 	$(vopt_if gtk3 gtk+3-devel)
 	$(vopt_if gtk3 pulseaudio-devel)
 	$(vopt_if gtk3 pango-devel)
-	$(vopt_if ffmpeg ffmpeg-devel)"
+	$(vopt_if ffmpeg ffmpeg4-devel)"
 short_desc="Emulator for C64, C128, CBM-II, PET, VIC20, Plus4 and C16"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"

From 6e7b89aacb4a7132e320c8900d987037243a0079 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 070/113] waypipe: revbump for ffmpeg6

---
 srcpkgs/waypipe/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waypipe/template b/srcpkgs/waypipe/template
index 6da88b21bf2a19..4da8058400b588 100644
--- a/srcpkgs/waypipe/template
+++ b/srcpkgs/waypipe/template
@@ -1,7 +1,7 @@
 # Template file for 'waypipe'
 pkgname=waypipe
 version=0.8.6
-revision=1
+revision=2
 build_style=meson
 # lto is off because it causes linking errors in armv6l and armv7l (due to NEON)
 configure_args="-Dwerror=false -Dwith_dmabuf=enabled -Dwith_lz4=enabled

From 4f47b5765de6a05be4079a82ed0c171a0959eccb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 071/113] xpra: revbump for ffmpeg6

---
 srcpkgs/xpra/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xpra/template b/srcpkgs/xpra/template
index 6bfe9be2db6502..1eea2962bcb825 100644
--- a/srcpkgs/xpra/template
+++ b/srcpkgs/xpra/template
@@ -1,7 +1,7 @@
 # Template file for 'xpra'
 pkgname=xpra
 version=5.0.4
-revision=1
+revision=2
 build_style=python3-module
 make_build_args="--without-cuda_kernels --without-cuda_rebuild"
 make_install_args="$(vopt_with docs) ${make_build_args}"

From ced5f044f4f06bf382f10763e3ee48f3a529d10c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:07:40 -0400
Subject: [PATCH 072/113] nv-codec-headers: update to 12.0.16.0

---
 srcpkgs/nv-codec-headers/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/nv-codec-headers/template b/srcpkgs/nv-codec-headers/template
index 3d422a61e48917..251e057f826fb8 100644
--- a/srcpkgs/nv-codec-headers/template
+++ b/srcpkgs/nv-codec-headers/template
@@ -1,6 +1,6 @@
 # Template file for 'nv-codec-headers'
 pkgname=nv-codec-headers
-version=11.1.5.1
+version=12.0.16.0
 revision=1
 build_style=gnu-makefile
 short_desc="FFmpeg version of headers required to interface with Nvidias codec APIs"
@@ -8,7 +8,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="MIT"
 homepage="http://git.videolan.org/?p=ffmpeg/nv-codec-headers.git"
 distfiles="https://github.com/FFmpeg/nv-codec-headers/archive/n${version}.tar.gz"
-checksum=d095fbd56aa93772471a323be0ebe65504a0f43f06c76a30b6d25da77b06ae9c
+checksum=2a1533b65f55f9da52956faf0627ed3b74868ac0c7f269990edd21369113b48f
 
 post_install() {
 	sed -n '4,25p' include/ffnvcodec/nvEncodeAPI.h > LICENSE

From 9931d187d6c6069cca749426cf7993229a0966ea Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:08:40 -0400
Subject: [PATCH 073/113] openimagedenoise: revbump for ffmpeg6

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index b792813dba7c29..109deb171c3f75 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,7 +1,7 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
 version=1.4.3
-revision=1
+revision=2
 archs="x86_64*"
 build_style=cmake
 hostmakedepends="ispc python3"

From 2191d862ff3ff7d69491b8cd1f7fa75bfc83ce8d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:31:45 -0400
Subject: [PATCH 074/113] shotcut: revbump for ffmpeg6

---
 srcpkgs/shotcut/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/shotcut/template b/srcpkgs/shotcut/template
index 33141fbd862d7a..f46cb53b6bfb92 100644
--- a/srcpkgs/shotcut/template
+++ b/srcpkgs/shotcut/template
@@ -1,7 +1,7 @@
 # Template file for 'shotcut'
 pkgname=shotcut
 version=23.09.29
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSHOTCUT_VERSION=${version}"
 hostmakedepends="pkg-config qt6-tools-devel"

From da743f1030fd47e040abd7fa85c8d9635c2128ce Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:30 -0400
Subject: [PATCH 075/113] shiboken2: revbump for qt5-5.15.11

---
 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch | 1 +
 srcpkgs/shiboken2/template                                 | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
 create mode 120000 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
new file mode 120000
index 00000000000000..efcf3249bd8854
--- /dev/null
+++ b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1 @@
+../../python3-pyside2/patches/importlib-machinery-bypass.patch
\ No newline at end of file
diff --git a/srcpkgs/shiboken2/template b/srcpkgs/shiboken2/template
index 883d6a084d8687..f3c06ec245a1fd 100644
--- a/srcpkgs/shiboken2/template
+++ b/srcpkgs/shiboken2/template
@@ -1,7 +1,7 @@
 # Template file for 'shiboken2'
 pkgname=shiboken2
 version=5.15.10
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/shiboken2"
 build_style=cmake

From ccf9910206eef95db2d9fa014380dd7d3a439507 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:53 -0400
Subject: [PATCH 076/113] python3-pyside2: revbump for qt5-5.15.11

---
 .../patches/importlib-machinery-bypass.patch      | 15 +++++++++++++++
 srcpkgs/python3-pyside2/template                  |  2 +-
 2 files changed, 16 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
new file mode 100644
index 00000000000000..64c429584776b5
--- /dev/null
+++ b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1,15 @@
+Using this prevents an error around line 220 below it.
+"AttributeError: module 'importlib' has no attribute 'machinery'"
+The old backup logic is in place and compiles without issues.
+--- a/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:09:34.688912402 -0400
++++ b/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:10:03.395529582 -0400
+@@ -170,9 +170,6 @@
+
+     # 'zipstring_sequence' comes from signature.cpp
+     zipbytes = base64.b64decode(''.join(zipstring_sequence))
+-    if sys.version_info[0] >= 3:
+-        vzip = zipfile.ZipFile(io.BytesIO(zipbytes))
+-        return sys.meta_path, EmbeddableZipImporter(vzip)
+
+     # Old version for Python 2.7, only.
+     import os
diff --git a/srcpkgs/python3-pyside2/template b/srcpkgs/python3-pyside2/template
index 249efa90988425..52626436ce75f2 100644
--- a/srcpkgs/python3-pyside2/template
+++ b/srcpkgs/python3-pyside2/template
@@ -1,7 +1,7 @@
 # Template file for 'python3-pyside2'
 pkgname=python3-pyside2
 version=5.15.10
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/pyside2"
 build_style=cmake

From 4de8bd9f0e4af8f1e3f4baf431022cdaa10dc9d1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:35 -0400
Subject: [PATCH 077/113] konqueror: revbump for ffmpeg6

---
 srcpkgs/konqueror/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/konqueror/template b/srcpkgs/konqueror/template
index 044dafa605ba65..63dd01fafc7802 100644
--- a/srcpkgs/konqueror/template
+++ b/srcpkgs/konqueror/template
@@ -1,11 +1,11 @@
 # Template file for 'konqueror'
 pkgname=konqueror
 version=23.08.4
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DDESKTOPTOJSON_EXECUTABLE=/usr/bin/desktoptojson"
 hostmakedepends="extra-cmake-modules python3 qt5-host-tools qt5-qmake kdoctools
-kcoreaddons kconfig gettext"
+ kcoreaddons kconfig gettext"
 makedepends="qt5-devel qt5-webengine-devel qt5-declarative-devel
  qt5-webchannel-devel qt5-location-devel kcmutils-devel kdelibs4support-devel
  karchive-devel khtml-devel kdesu-devel kactivities5-devel"

From 0420ac1abcd3cd9b56b077643d59238b71070358 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:58 -0400
Subject: [PATCH 078/113] qt5-speech: revbump for qt5-5.15.11

---
 srcpkgs/qt5-speech/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-speech/template b/srcpkgs/qt5-speech/template
index 1228bb60c41db4..27a7da1dbdb91b 100644
--- a/srcpkgs/qt5-speech/template
+++ b/srcpkgs/qt5-speech/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-speech'
 pkgname=qt5-speech
 version=5.15.11
-revision=1
+revision=2
 _commit=d32f4a479d38a11f547598004b975f4356424a16
 build_style=qmake
 configure_args="-- -flite -flite-alsa -speechd"

From c84c7a80b7299795e29e34c86b12a7c8982d3399 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Jun 2023 08:20:22 -0400
Subject: [PATCH 079/113] gtk4: revbump for ffmpeg6

---
 srcpkgs/gtk4/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gtk4/template b/srcpkgs/gtk4/template
index d8ee60abe06f71..55bff6e33849ac 100644
--- a/srcpkgs/gtk4/template
+++ b/srcpkgs/gtk4/template
@@ -1,7 +1,7 @@
 # Template file for 'gtk4'
 pkgname=gtk4
 version=4.12.3
-revision=1
+revision=2
 build_style=meson
 build_helper="gir"
 configure_args="-Dman-pages=true -Ddocumentation=true -Dbuild-tests=false

From b2055b4e67c9dde8d5bfdbb24d6eea25cf15fd14 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:28:26 -0400
Subject: [PATCH 080/113] siril: revbump for ffmpeg6

---
 srcpkgs/siril/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/siril/template b/srcpkgs/siril/template
index 84332f79d060d2..62750dd247548f 100644
--- a/srcpkgs/siril/template
+++ b/srcpkgs/siril/template
@@ -1,7 +1,7 @@
 # Template file for 'siril'
 pkgname=siril
 version=0.9.12
-revision=10
+revision=11
 build_style=gnu-configure
 hostmakedepends="pkg-config intltool autoconf automake gettext-devel"
 makedepends="fftw-devel libconfig-devel libopencv-devel libffms2-devel

From 4ab0b63c9d0c80b0765c2a6ec3db8059c0857901 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 22 Jun 2023 10:25:02 -0400
Subject: [PATCH 081/113] kdenlive: revbump for ffmpeg6

---
 srcpkgs/kdenlive/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kdenlive/template b/srcpkgs/kdenlive/template
index a0f3615c9c530c..d63166f95c4d78 100644
--- a/srcpkgs/kdenlive/template
+++ b/srcpkgs/kdenlive/template
@@ -1,7 +1,7 @@
 # Template file for 'kdenlive'
 pkgname=kdenlive
 version=23.08.4
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="
  extra-cmake-modules kconfig kcoreaddons kdoctools pkg-config python3

From fac1d93681d30319e0da8dbda327cc8cbd9b42b8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:20:59 -0400
Subject: [PATCH 082/113] tracker-miners: revbump for ffmpeg6

---
 srcpkgs/tracker-miners/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tracker-miners/template b/srcpkgs/tracker-miners/template
index 0b97f47489f817..f196d2bf9e4a4c 100644
--- a/srcpkgs/tracker-miners/template
+++ b/srcpkgs/tracker-miners/template
@@ -1,7 +1,7 @@
 # Template file for 'tracker-miners'
 pkgname=tracker-miners
 version=3.6.1
-revision=1
+revision=2
 build_style=meson
 build_helper=qemu
 # missing libgrss for miner_rss

From 965226c60696128d15f0f94d45485333165df41f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:21:21 -0400
Subject: [PATCH 083/113] mpd: revbump for ffmpeg6

---
 srcpkgs/mpd/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpd/template b/srcpkgs/mpd/template
index 4fd32b7be8c537..b8e2bd4c1b59c8 100644
--- a/srcpkgs/mpd/template
+++ b/srcpkgs/mpd/template
@@ -1,7 +1,7 @@
 # Template file for 'mpd'
 pkgname=mpd
 version=0.23.15
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dopus=enabled -Dmikmod=enabled -Dneighbor=true
  -Dsoundcloud=enabled -Dpipe=true -Dtwolame=enabled -Dbzip2=enabled

From b569aa810f0d717050a1c53f3433ae764257bb66 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:02 -0400
Subject: [PATCH 084/113] tg_owt: revbump for ffmpeg6

---
 srcpkgs/tg_owt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tg_owt/template b/srcpkgs/tg_owt/template
index aee8d35d08ffbe..34e8fef0540569 100644
--- a/srcpkgs/tg_owt/template
+++ b/srcpkgs/tg_owt/template
@@ -1,7 +1,7 @@
 # Template file for 'tg_owt'
 pkgname=tg_owt
 version=0.0.0.20231221
-revision=1
+revision=2
 _commit=afd9d5d31798d3eacf9ed6c30601e91d0f1e4d60
 _libyuv_commit=04821d1e7d60845525e8db55c7bcd41ef5be9406
 _abseil_commit=8c0b94e793a66495e0b1f34a5eb26bd7dc672db0

From a54d92288f96e48ce6d5929a671ad75add958590 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:44 -0400
Subject: [PATCH 085/113] telegram-desktop: revbump for ffmpeg6

---
 srcpkgs/telegram-desktop/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/telegram-desktop/template b/srcpkgs/telegram-desktop/template
index d00b273b7b7386..d20b87b5182db8 100644
--- a/srcpkgs/telegram-desktop/template
+++ b/srcpkgs/telegram-desktop/template
@@ -1,7 +1,7 @@
 # Template file for 'telegram-desktop'
 pkgname=telegram-desktop
 version=4.14.9
-revision=1
+revision=2
 build_style=cmake
 build_helper="qemu gir"
 configure_args="-DTDESKTOP_API_ID=209235

From 25d95fd8cd45acab7e685eeadeb810a7f45126c9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:11:45 -0400
Subject: [PATCH 086/113] gst-plugins-bad1: revbump for ffmpeg6

---
 srcpkgs/gst-plugins-bad1/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index 63200e74f99a7f..644758cb187a19 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-plugins-bad1'
 pkgname=gst-plugins-bad1
 version=1.22.9
-revision=1
+revision=2
 build_helper="gir"
 build_style=meson
 configure_args="-Dpackage-origin=https://voidlinux.org -Ddoc=disabled

From 43b70726e0c2c9bc02040ac34e51d8c861a81556 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:12:09 -0400
Subject: [PATCH 087/113] openmw: revbump for ffmpeg6

---
 srcpkgs/openmw/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openmw/template b/srcpkgs/openmw/template
index 0abf5ff7cdbecc..b57180f1a4446f 100644
--- a/srcpkgs/openmw/template
+++ b/srcpkgs/openmw/template
@@ -1,7 +1,7 @@
 # Template file for 'openmw'
 pkgname=openmw
 version=0.48.0
-revision=2
+revision=3
 build_style=cmake
 _recast_commit=e75adf86f91eb3082220085e42dda62679f9a3ea
 _bullet_tag=3.17

From 4847d77efdb6f369cce7749c278091d00aec918a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:14:53 -0400
Subject: [PATCH 088/113] lms: revbump for ffmpeg6

---
 srcpkgs/lms/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/lms/template b/srcpkgs/lms/template
index e358f75902a986..3b21c458de5199 100644
--- a/srcpkgs/lms/template
+++ b/srcpkgs/lms/template
@@ -1,7 +1,7 @@
 # Template file for 'lms'
 pkgname=lms
 version=3.42.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="wt-devel ffmpeg-devel boost-devel libconfig++-devel taglib-devel pam-devel libgraphicsmagick-devel gtest-devel libarchive-devel"

From f45ea0dab436df220fb648c5aeb0138248079151 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:18:18 -0400
Subject: [PATCH 089/113] freecad: DELETE

---
 srcpkgs/freecad/patches/001-include.patch     | 112 ------------------
 .../154-revert-gui-tmp-redirect-stderr.patch  |  68 -----------
 ...d63c8c9b1280978be841d04e68a0a55cceb9.patch |  30 -----
 srcpkgs/freecad/template                      |  12 +-
 4 files changed, 7 insertions(+), 215 deletions(-)
 delete mode 100644 srcpkgs/freecad/patches/001-include.patch
 delete mode 100644 srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
 delete mode 100644 srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch

diff --git a/srcpkgs/freecad/patches/001-include.patch b/srcpkgs/freecad/patches/001-include.patch
deleted file mode 100644
index 28b5af54999b96..00000000000000
--- a/srcpkgs/freecad/patches/001-include.patch
+++ /dev/null
@@ -1,112 +0,0 @@
-From 9a41845a417189776741297c50a3827ce292bc4f Mon Sep 17 00:00:00 2001
-From: Uwe <donovaly@users.noreply.github.com>
-Date: Sun, 3 Jul 2022 22:51:16 +0200
-Subject: [PATCH] [Part] OCCError.h: remove unneeded includes
-
-- also sort includes
----
- src/Mod/Part/App/OCCError.h             | 36 +++----------------------
- src/Mod/Part/App/OffsetCurvePyImp.cpp   | 12 ++++-----
- src/Mod/Part/App/OffsetSurfacePyImp.cpp | 10 +++----
- 3 files changed, 12 insertions(+), 46 deletions(-)
-
---- a/src/Mod/Part/App/OCCError.h
-+++ b/src/Mod/Part/App/OCCError.h
-@@ -23,36 +23,8 @@
- #ifndef _OCCError_h_
- #define _OCCError_h_
- 
--# include <Standard_Version.hxx>
- # include <Standard_Failure.hxx>
--# include <Standard_AbortiveTransaction.hxx>
--# include <Standard_ConstructionError.hxx>
--# if OCC_VERSION_HEX >= 0x060500
--# include <Standard_DefineException.hxx>
--# endif
--# include <Standard_DimensionError.hxx>
--# include <Standard_DimensionMismatch.hxx>
--# include <Standard_DivideByZero.hxx>
--# include <Standard_DomainError.hxx>
--# include <Standard_ImmutableObject.hxx>
--# include <Standard_LicenseError.hxx>
--# include <Standard_LicenseNotFound.hxx>
--# include <Standard_MultiplyDefined.hxx>
--# include <Standard_NegativeValue.hxx>
--# include <Standard_NoMoreObject.hxx>
--# include <Standard_NoSuchObject.hxx>
--# include <Standard_NotImplemented.hxx>
--# include <Standard_NullObject.hxx>
--# include <Standard_NullValue.hxx>
--# include <Standard_NumericError.hxx>
--# include <Standard_OutOfMemory.hxx>
--# include <Standard_OutOfRange.hxx>
--# include <Standard_Overflow.hxx>
--# include <Standard_ProgramError.hxx>
--# include <Standard_RangeError.hxx>
--# include <Standard_TooManyUsers.hxx>
--# include <Standard_TypeMismatch.hxx>
--# include <Standard_Underflow.hxx>
-+# include <Standard_Version.hxx>
- 
- #include <Mod/Part/PartGlobal.h>
- #include <Base/Console.h>
-@@ -88,4 +60,3 @@ PartExport extern PyObject* PartExceptio
- 
- #define PY_CATCH_OCC _PY_CATCH_OCC(return(NULL))
- #endif  // _OCCError_h_
--
---- a/src/Mod/Part/App/OffsetCurvePyImp.cpp
-+++ b/src/Mod/Part/App/OffsetCurvePyImp.cpp
-@@ -20,20 +20,20 @@
-  *                                                                         *
-  ***************************************************************************/
- 
--
- #include "PreCompiled.h"
- #ifndef _PreComp_
- # include <Geom_OffsetCurve.hxx>
- #endif
- 
--#include "OCCError.h"
--#include "Geometry.h"
-+#include <Base/GeometryPyCXX.h>
-+#include <Base/Vector3D.h>
-+#include <Base/VectorPy.h>
-+
- #include "OffsetCurvePy.h"
- #include "OffsetCurvePy.cpp"
-+#include "Geometry.h"
-+#include "OCCError.h"
- 
--#include <Base/GeometryPyCXX.h>
--#include <Base/VectorPy.h>
--#include <Base/Vector3D.h>
- 
- using namespace Part;
- 
---- a/src/Mod/Part/App/OffsetSurfacePyImp.cpp
-+++ b/src/Mod/Part/App/OffsetSurfacePyImp.cpp
-@@ -20,20 +20,16 @@
-  *                                                                         *
-  ***************************************************************************/
- 
--
- #include "PreCompiled.h"
- #ifndef _PreComp_
- # include <Geom_OffsetSurface.hxx>
- # include <memory>
- #endif
- 
--#include <Base/VectorPy.h>
--#include <Base/Vector3D.h>
--
- #include "OCCError.h"
--#include "Geometry.h"
--#include <Mod/Part/App/OffsetSurfacePy.h>
--#include <Mod/Part/App/OffsetSurfacePy.cpp>
-+#include "OffsetSurfacePy.h"
-+#include "OffsetSurfacePy.cpp"
-+
- 
- using namespace Part;
- 
diff --git a/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch b/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
deleted file mode 100644
index d6a9adabdec830..00000000000000
--- a/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
+++ /dev/null
@@ -1,68 +0,0 @@
-see https://github.com/FreeCAD/FreeCAD/commit/cfe94b00d3434f3e2c8b5114d2909f628c330fa8#commitcomment-71413407
-
-upstream: yes
-
-From 7b377a216b9185960e4cee980a6504dc1a755f50 Mon Sep 17 00:00:00 2001
-From: wmayer <wmayer@users.sourceforge.net>
-Date: Wed, 29 Jun 2022 15:19:18 +0200
-Subject: [PATCH] Gui: remove workaround for spnav 0.23 due to build failure
- with musl libc
-
----
- src/Gui/3Dconnexion/GuiNativeEventLinux.cpp | 27 ---------------------
- 1 file changed, 27 deletions(-)
-
---- a/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp
-+++ b/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp
-@@ -21,42 +21,17 @@
-  ***************************************************************************/
- 
- #include <FCConfig.h>
--#include <cstdio>
- 
- #include "GuiNativeEventLinux.h"
- 
- #include "GuiApplicationNativeEventAware.h"
- #include <Base/Console.h>
--#include <Base/FileInfo.h>
- #include <QMainWindow>
- 
- #include <QSocketNotifier>
- 
- #include <spnav.h>
- 
--namespace {
--class RedirectStdErr
--{
--public:
--    RedirectStdErr()
--        : fi(Base::FileInfo::getTempFileName())
--        , file(stderr)
--    {
--        stderr = fopen(fi.filePath().c_str(), "w");
--    }
--    ~RedirectStdErr()
--    {
--        fclose(stderr);
--        fi.deleteFile();
--        stderr = file;
--    }
--
--private:
--    Base::FileInfo fi;
--    FILE* file;
--};
--}
--
- Gui::GuiNativeEvent::GuiNativeEvent(Gui::GUIApplicationNativeEventAware *app)
- : GuiAbstractNativeEvent(app)
- {
-@@ -72,8 +47,6 @@ Gui::GuiNativeEvent::~GuiNativeEvent()
- 
- void Gui::GuiNativeEvent::initSpaceball(QMainWindow *window)
- {
--    // tmp. redirect stderr to a file to suppress an error message from spnav_open()
--    RedirectStdErr err;
-     Q_UNUSED(window)
-     if (spnav_open() == -1) {
-         Base::Console().Log("Couldn't connect to spacenav daemon. Please ignore if you don't have a spacemouse.\n");
diff --git a/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch b/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch
deleted file mode 100644
index d4acf370ca0a42..00000000000000
--- a/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-From fe02d63c8c9b1280978be841d04e68a0a55cceb9 Mon Sep 17 00:00:00 2001
-From: Roy-043 <70520633+Roy-043@users.noreply.github.com>
-Date: Thu, 29 Dec 2022 23:20:38 +0100
-Subject: [PATCH] Draft: update inspect.getargspec to inspect.getfullargspec
- (#8101)
-
----
- src/Mod/Draft/draftguitools/gui_snapper.py | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
---- a/src/Mod/Draft/draftguitools/gui_snapper.py
-+++ b/src/Mod/Draft/draftguitools/gui_snapper.py
-@@ -1426,7 +1426,7 @@ class Snapper:
-             Gui.Snapper.off()
-             self.ui.offUi()
-             if callback:
--                if len(inspect.getargspec(callback).args) > 1:
-+                if len(inspect.getfullargspec(callback).args) > 1:
-                     obj = None
-                     if self.snapInfo and ("Object" in self.snapInfo) and self.snapInfo["Object"]:
-                         obj = App.ActiveDocument.getObject(self.snapInfo["Object"])
-@@ -1445,7 +1445,7 @@ class Snapper:
-             Gui.Snapper.off()
-             self.ui.offUi()
-             if callback:
--                if len(inspect.getargspec(callback).args) > 1:
-+                if len(inspect.getfullargspec(callback).args) > 1:
-                     callback(None, None)
-                 else:
-                     callback(None)
diff --git a/srcpkgs/freecad/template b/srcpkgs/freecad/template
index c135701e38b9ad..7d5165f760bab9 100644
--- a/srcpkgs/freecad/template
+++ b/srcpkgs/freecad/template
@@ -1,7 +1,7 @@
 # Template file for 'freecad'
 pkgname=freecad
-version=0.20.2
-revision=7
+version=0.21.1
+revision=2
 build_wrksrc="FreeCAD-${version}"
 build_style=cmake
 pycompile_dirs="usr/lib/${pkgname}/Mod"
@@ -24,8 +24,10 @@ makedepends="python3-devel boost-devel libxerces-c-devel zlib-devel occt-devel
  coin3-devel libshiboken2-devel libspnav-devel pyside2-tools
  liblz4-devel libpyside2-python3-devel python3-matplotlib netcdf-devel
  jsoncpp-devel qt5-devel qt5-svg-devel qt5-tools-devel qt5-webkit-devel
- qt5-xmlpatterns-devel coin3-doc glew-devel python3-pivy"
-depends="python3-matplotlib python3-pyside2-webengine python3-pivy"
+ qt5-xmlpatterns-devel coin3-doc glew-devel python3-pivy qt5-webengine-devel
+ qt5-declarative-devel qt5-webchannel-devel qt5-location-devel"
+depends="python3-matplotlib python3-pyside2-webengine python3-pivy
+ python3-GitPython python3-Markdown"
 short_desc="General purpose 3D CAD modeler"
 maintainer="yopito <pierre.bourgin@free.fr>"
 license="LGPL-2.0-or-later"
@@ -35,7 +37,7 @@ distfiles="
  https://github.com/FreeCAD/FreeCAD/archive/${version}.tar.gz
  ${SOURCEFORGE_SITE}/cxx/pycxx-${_pycxxver}.tar.gz
 "
-checksum="46922f3a477e742e1a89cd5346692d63aebb2b67af887b3e463e094a4ae055da
+checksum="e9b1fd0323f101268c7f3be52db42e4a29222f2e306ae6c4a6fc309cb418d35a
  4b91e1e1141c23fbd5039df635c4bb6e75632168548f56b83ce177193c0c98c6"
 python_version=3
 patch_args="-Np1 -d ${build_wrksrc}"

From 7de578b26208f6e493fb7109469c7b13e7c8cd8e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:47:18 -0400
Subject: [PATCH 090/113] libopenshot: revbump for ffmpeg6

---
 srcpkgs/libopenshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenshot/template b/srcpkgs/libopenshot/template
index 8e57c5f592169c..7a8f4520e78925 100644
--- a/srcpkgs/libopenshot/template
+++ b/srcpkgs/libopenshot/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenshot'
 pkgname=libopenshot
 version=0.3.0
-revision=3
+revision=4
 build_style=cmake
 # Builds fail with Ruby-2.4.1
 configure_args="-DENABLE_RUBY=OFF -DUSE_SYSTEM_JSONCPP=ON"

From 22c5f61c80084347453aee7b57ad3476319df375 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:10:30 -0500
Subject: [PATCH 091/113] openimageio: revbump for ffmpeg6

---
 srcpkgs/openimageio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimageio/template b/srcpkgs/openimageio/template
index 3ce3f9e49d350c..27d2131bc0a61a 100644
--- a/srcpkgs/openimageio/template
+++ b/srcpkgs/openimageio/template
@@ -1,7 +1,7 @@
 # Template file for 'openimageio'
 pkgname=openimageio
 version=2.4.9.0
-revision=7
+revision=8
 build_style=cmake
 build_helper=qemu
 configure_args="-DUSE_QT=0 -DUSE_PYTHON=0 -DOIIO_BUILD_TESTS=0

From f4568239288eb9478f9fc38233a00b4c656b4460 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:11:57 -0500
Subject: [PATCH 092/113] synfigstudio: revbump for ffmpeg6

---
 srcpkgs/synfigstudio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/synfigstudio/template b/srcpkgs/synfigstudio/template
index 09e442da9a6805..2bc017cedca6b8 100644
--- a/srcpkgs/synfigstudio/template
+++ b/srcpkgs/synfigstudio/template
@@ -2,7 +2,7 @@
 # Should be kept in sync with 'synfig' and 'ETL'
 pkgname=synfigstudio
 version=1.4.4
-revision=4
+revision=5
 build_style=gnu-configure
 configure_args="--disable-update-mimedb"
 hostmakedepends="pkg-config intltool gettext synfig"

From d478a1059e85edc2bdbcc68b38e3dccf2573dcd9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:10 -0500
Subject: [PATCH 093/113] mixxx: revbump for ffmpeg6

---
 srcpkgs/mixxx/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mixxx/template b/srcpkgs/mixxx/template
index 6921996e4e77b3..6a79b328c1abf0 100644
--- a/srcpkgs/mixxx/template
+++ b/srcpkgs/mixxx/template
@@ -1,7 +1,7 @@
 # Template file for 'mixxx'
 pkgname=mixxx
 version=2.3.3
-revision=6
+revision=7
 build_style=cmake
 configure_args="-DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="extra-cmake-modules pkg-config protobuf qt5-host-tools qt5-qmake"

From 84e101e80de1ef3828f0d4bb0b4a018dfc919998 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:28 -0500
Subject: [PATCH 094/113] musikcube: revbump for ffmpeg6

---
 srcpkgs/musikcube/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/musikcube/template b/srcpkgs/musikcube/template
index 8c4a51840859ec..fb60dd2049089a 100644
--- a/srcpkgs/musikcube/template
+++ b/srcpkgs/musikcube/template
@@ -1,7 +1,7 @@
 # Template file for 'musikcube'
 pkgname=musikcube
 version=3.0.0
-revision=3
+revision=4
 build_style=cmake
 make_cmd=make
 configure_args="-DNO_NCURSESW=1"

From dc9927c891858e00480c0fb9033a1bf4b3343eb4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:45 -0500
Subject: [PATCH 095/113] electron24: revbump for ffmpeg6

---
 srcpkgs/electron24/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron24/template b/srcpkgs/electron24/template
index 7b4e28812f483e..1ca93fde97a854 100644
--- a/srcpkgs/electron24/template
+++ b/srcpkgs/electron24/template
@@ -1,7 +1,7 @@
 # Template file for 'electron24'
 pkgname=electron24
 version=24.3.0
-revision=2
+revision=3
 _nodever=18.14.0
 _chromiumver=112.0.5615.165
 archs="x86_64* aarch64*"

From 982655687030b8a40323ca6c18d3232070cb048a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:00 -0500
Subject: [PATCH 096/113] electron19: revbump for ffmpeg6

---
 srcpkgs/electron19/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron19/template b/srcpkgs/electron19/template
index 0ef959125cb085..5371c0b354604f 100644
--- a/srcpkgs/electron19/template
+++ b/srcpkgs/electron19/template
@@ -1,7 +1,7 @@
 # Template file for 'electron19'
 pkgname=electron19
 version=19.0.8
-revision=4
+revision=5
 _nodever=16.14.2
 _chromiumver=102.0.5005.125
 archs="x86_64* aarch64* ppc64le*"

From 9e427d7693f2142c68f13da8f7f85c10b853de29 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:13 -0500
Subject: [PATCH 097/113] wf-recorder: revbump for ffmpeg6

---
 srcpkgs/wf-recorder/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/wf-recorder/template b/srcpkgs/wf-recorder/template
index 08f986b0310067..63c45cf4b814d7 100644
--- a/srcpkgs/wf-recorder/template
+++ b/srcpkgs/wf-recorder/template
@@ -1,7 +1,7 @@
 # Template file for 'wf-recorder'
 pkgname=wf-recorder
 version=0.4.1
-revision=2
+revision=3
 build_style=meson
 hostmakedepends="pkg-config scdoc wayland-devel"
 makedepends="wayland-protocols wayland-devel ffmpeg-devel libgbm-devel x264-devel

From e537c940a31081a563d7c71a09a00ec997d296b0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:26 -0500
Subject: [PATCH 098/113] obs: revbump for ffmpeg6

---
 srcpkgs/obs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/obs/template b/srcpkgs/obs/template
index b343f1131bfcf6..a25a67433e285e 100644
--- a/srcpkgs/obs/template
+++ b/srcpkgs/obs/template
@@ -1,7 +1,7 @@
 # Template file for 'obs'
 pkgname=obs
 version=30.0.0
-revision=2
+revision=3
 archs="i686* x86_64* ppc64le* aarch64* riscv64*"
 build_style=cmake
 configure_args="-DOBS_VERSION_OVERRIDE=${version} -DENABLE_JACK=ON

From 467a23397a663ea860ce6d451db6e2e24ca2dfc2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:36 -0500
Subject: [PATCH 099/113] mlt7: revbump for ffmpeg6

---
 srcpkgs/mlt7/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mlt7/template b/srcpkgs/mlt7/template
index 98f302ad3a5167..7eb8c00fa1580c 100644
--- a/srcpkgs/mlt7/template
+++ b/srcpkgs/mlt7/template
@@ -1,7 +1,7 @@
 # Template file for 'mlt7'
 pkgname=mlt7
 version=7.20.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DSWIG_PYTHON=ON -DMOD_QT6=ON"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which

From b241d252c883e09443a89f53022d6033df8e68cf Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:48 -0500
Subject: [PATCH 100/113] qt6-multimedia: revbump for ffmpeg6

---
 srcpkgs/qt6-multimedia/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-multimedia/template b/srcpkgs/qt6-multimedia/template
index 67a577e1300fea..1da626ecf515a8 100644
--- a/srcpkgs/qt6-multimedia/template
+++ b/srcpkgs/qt6-multimedia/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-multimedia'
 pkgname=qt6-multimedia
 version=6.6.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DQT_FEATURE_gstreamer=ON"
 hostmakedepends="perl qt6-declarative-host-tools pkg-config qt6-shadertools"

From 502406f5a1b97d699e51105ba5babf871f9e6296 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:00:15 -0500
Subject: [PATCH 101/113] baresip: revbump for ffmpeg6

---
 srcpkgs/baresip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/baresip/template b/srcpkgs/baresip/template
index 12c8954ef7b9b7..b16b67beab8d2b 100644
--- a/srcpkgs/baresip/template
+++ b/srcpkgs/baresip/template
@@ -1,7 +1,7 @@
 # Template file for 'baresip'
 pkgname=baresip
 version=3.6.0
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config glib-devel"
 makedepends="libgsm-devel libpng-devel openssl-devel libsndfile-devel

From eae93303ff91cd41f05b84cda01ed6ee256706c9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:30 -0500
Subject: [PATCH 102/113] QMPlay2: revbump for ffmpeg6

---
 srcpkgs/QMPlay2/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/QMPlay2/template b/srcpkgs/QMPlay2/template
index 46c80f64a13497..942258ce60fb7e 100644
--- a/srcpkgs/QMPlay2/template
+++ b/srcpkgs/QMPlay2/template
@@ -1,7 +1,7 @@
 # Template file for 'QMPlay2'
 pkgname=QMPlay2
 version=23.10.22
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools"
 makedepends="alsa-lib-devel ffmpeg-devel libass-devel libcdio-devel libgme-devel

From ba392c5ef101ce3b270f949ca3b5c2b3c7280ddc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:34 -0500
Subject: [PATCH 103/113] alsa-plugins: revbump for ffmpeg6

---
 srcpkgs/alsa-plugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/alsa-plugins/template b/srcpkgs/alsa-plugins/template
index a5708a7d82a8f0..7bfdad046c4830 100644
--- a/srcpkgs/alsa-plugins/template
+++ b/srcpkgs/alsa-plugins/template
@@ -1,7 +1,7 @@
 # Template file for 'alsa-plugins'
 pkgname=alsa-plugins
 version=1.2.7.1
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--disable-maemo-plugin"
 hostmakedepends="pkg-config"

From 7905af6a1571c231dfd849c5a45cdf98704933d1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:43 -0500
Subject: [PATCH 104/113] minidlna: revbump for ffmpeg6

---
 srcpkgs/minidlna/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/minidlna/template b/srcpkgs/minidlna/template
index 5fa929f3a0c124..742991ecd04afc 100644
--- a/srcpkgs/minidlna/template
+++ b/srcpkgs/minidlna/template
@@ -1,7 +1,7 @@
 # Template file for 'minidlna'
 pkgname=minidlna
 version=1.3.3
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="
  --sbindir=/usr/bin

From 100cac184e5aed7b220c5dd45c57a93d69c6e3ed Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 17:57:47 -0500
Subject: [PATCH 105/113] mpv: revbump for ffmpeg6

---
 srcpkgs/mpv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpv/template b/srcpkgs/mpv/template
index 4948d1e332cb8b..1ac1b167af189c 100644
--- a/srcpkgs/mpv/template
+++ b/srcpkgs/mpv/template
@@ -1,7 +1,7 @@
 # Template file for 'mpv'
 pkgname=mpv
 version=0.36.0
-revision=4
+revision=5
 build_style=meson
 configure_args="-Dcdda=enabled -Ddvbin=enabled -Ddvdnav=enabled
  -Dlibmpv=true -Dcplugins=enabled

From 04f85b307295077256089d553733a8dc1ca3cf6d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 17:59:29 -0500
Subject: [PATCH 106/113] qimgv: revbump for ffmpeg6

---
 srcpkgs/qimgv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qimgv/template b/srcpkgs/qimgv/template
index dd341dfe1bfce8..8a7e1c081ef12f 100644
--- a/srcpkgs/qimgv/template
+++ b/srcpkgs/qimgv/template
@@ -1,7 +1,7 @@
 # Template file for 'qimgv'
 pkgname=qimgv
 version=1.0.2
-revision=3
+revision=4
 build_style=cmake
 configure_args="$(vopt_if video -DVIDEO_SUPPORT=ON -DVIDEO_SUPPORT=OFF)
  $(vopt_if scale -DOPENCV_SUPPORT=ON -DOPENCV_SUPPORT=OFF)

From 7bb4a816c1a5d93d4f50c450cac22df37628d46d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 18:00:36 -0500
Subject: [PATCH 107/113] kfilemetadata5: revbump for ffmpeg6

---
 srcpkgs/kfilemetadata5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kfilemetadata5/template b/srcpkgs/kfilemetadata5/template
index 51fd6fec8c1c01..ad229b4c2e241d 100644
--- a/srcpkgs/kfilemetadata5/template
+++ b/srcpkgs/kfilemetadata5/template
@@ -1,7 +1,7 @@
 # Template file for 'kfilemetadata5'
 pkgname=kfilemetadata5
 version=5.113.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="kcoreaddons extra-cmake-modules pkg-config qt5-host-tools qt5-qmake
  gettext kcoreaddons python3"

From 5ab024cc09187c5e5ccadf043368517b011d9d89 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 8 Dec 2023 11:46:01 -0500
Subject: [PATCH 108/113] vba-m: revbump for ffmpeg6

---
 srcpkgs/vba-m/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vba-m/template b/srcpkgs/vba-m/template
index 52efeede1dcba2..3e0760398905c6 100644
--- a/srcpkgs/vba-m/template
+++ b/srcpkgs/vba-m/template
@@ -2,7 +2,7 @@
 pkgname=vba-m
 reverts=1292_2
 version=2.1.8
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_GTK=TRUE -DENABLE_FFMPEG=TRUE -DENABLE_LINK=TRUE -DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="gettext pkg-config unzip zip yasm wxWidgets-gtk3-devel"

From d6743aa44452c82314eb0880ad2b32ef698ceb9b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 8 Dec 2023 11:46:19 -0500
Subject: [PATCH 109/113] dolphin-emu: revbump for ffmpeg6

---
 srcpkgs/dolphin-emu/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/dolphin-emu/template b/srcpkgs/dolphin-emu/template
index 862d3ae964eec4..a7ae0efb58fb75 100644
--- a/srcpkgs/dolphin-emu/template
+++ b/srcpkgs/dolphin-emu/template
@@ -1,7 +1,7 @@
 # Template file for 'dolphin-emu'
 pkgname=dolphin-emu
 version=5.0.19368
-revision=3
+revision=4
 _dolphin_commit=dadbeb4bae7e7fa23af2b46e0add4143094dc107
 _mgba_commit=44e074a15e9651481f7f652ac006a7c9d58cbeb9
 _googletest_commit=be03d00f5f0cc3a997d1a368bee8a1fe93651f48

From acf86831837ae0bfbfd510c82f299733b70aeee3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 19 Dec 2023 15:38:51 -0500
Subject: [PATCH 110/113] qtox: revbump for ffmpeg4

---
 srcpkgs/qtox/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtox/template b/srcpkgs/qtox/template
index bb70e7f51240a4..755e4462bc0137 100644
--- a/srcpkgs/qtox/template
+++ b/srcpkgs/qtox/template
@@ -1,13 +1,13 @@
 # Template file for 'qtox'
 pkgname=qtox
 version=1.17.6
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DUPDATE_CHECK=OFF
  -DGIT_DESCRIBE=${version}
  $(vopt_if snorenotify -DDESKTOP_NOTIFICATIONS=ON)"
 hostmakedepends="pkg-config qt5-host-tools qt5-devel"
-makedepends="ffmpeg-devel libexif-devel libopenal-devel libsodium-devel
+makedepends="ffmpeg4-devel libexif-devel libopenal-devel libsodium-devel
  libvpx-devel opus-devel qrencode-devel qt5-svg-devel sonnet-devel
  sqlcipher-devel toxcore-devel
  $(vopt_if snorenotify snorenotify-devel)"

From f6080acdb277442eb9ab8d6a07a08c612913bb8f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 11 Jan 2024 11:52:00 -0500
Subject: [PATCH 111/113] arcan: revbump for ffmpeg6

---
 srcpkgs/arcan/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/arcan/template b/srcpkgs/arcan/template
index ff9091f90ebb10..030091a6cc9d0c 100644
--- a/srcpkgs/arcan/template
+++ b/srcpkgs/arcan/template
@@ -2,7 +2,7 @@
 # !! keep synced with: acfgfs aclip aloadimage
 pkgname=arcan
 version=0.6.2.1
-revision=2
+revision=3
 create_wrksrc=yes
 build_wrksrc=arcan/src
 build_style=cmake

From acf8b1c9c246abc8a6278fb903cf091931ad9180 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 11 Jan 2024 11:52:10 -0500
Subject: [PATCH 112/113] notcurses: revbump for ffmpeg6

---
 srcpkgs/notcurses/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/notcurses/template b/srcpkgs/notcurses/template
index 48a7463cb68eb9..515f316ab4576c 100644
--- a/srcpkgs/notcurses/template
+++ b/srcpkgs/notcurses/template
@@ -1,7 +1,7 @@
 # Template file for 'notcurses'
 pkgname=notcurses
 version=3.0.9
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DUSE_STATIC=ON -DUSE_QRCODEGEN=On $(vopt_bool man USE_PANDOC)"
 hostmakedepends="pkg-config $(vopt_if man pandoc)"

From 30876d6132349b334a5f6bde023d53b83afea5f1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Feb 2024 14:28:38 -0500
Subject: [PATCH 113/113] New package: oneVPL-intel-gpu-2.4.3

---
 srcpkgs/oneVPL-intel-gpu/template | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
 create mode 100644 srcpkgs/oneVPL-intel-gpu/template

diff --git a/srcpkgs/oneVPL-intel-gpu/template b/srcpkgs/oneVPL-intel-gpu/template
new file mode 100644
index 00000000000000..ed0ee9e140e474
--- /dev/null
+++ b/srcpkgs/oneVPL-intel-gpu/template
@@ -0,0 +1,18 @@
+# Template file for 'oneVPL-intel-gpu'
+pkgname=oneVPL-intel-gpu
+version=23.4.3
+revision=1
+build_style=cmake
+hostmakedepends="pkg-config"
+makedepends="libva-devel libdrm-devel"
+short_desc="Intel oneVPL GPU Runtime"
+maintainer="zlice <zlice555@gmail.com>"
+license="MIT"
+homepage="https://github.com/oneapi-src/oneVPL-intel-gpu"
+changelog="https://github.com/oneapi-src/oneVPL-intel-gpu/blob/main/CHANGELOG.md"
+distfiles="https://github.com/oneapi-src/oneVPL-intel-gpu/archive/refs/tags/intel-onevpl-${version}.tar.gz"
+checksum=c61a6866f4ea3c8378330e98cc3e03586c8059061c2642ee69ed8f91df41e939
+
+post_install() {
+	vlicense LICENSE
+}

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (59 preceding siblings ...)
  2024-02-03 20:31 ` [PR PATCH] [Updated] " zlice
@ 2024-02-03 20:38 ` zlice
  2024-02-03 22:46 ` [PR PATCH] [Updated] " zlice
                   ` (36 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2024-02-03 20:38 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 207 bytes --]

New comment by zlice on void-packages repository

https://github.com/void-linux/void-packages/pull/43761#issuecomment-1925449766

Comment:
I'm about to make all revisions 99 until this is about to merge x-x

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (60 preceding siblings ...)
  2024-02-03 20:38 ` zlice
@ 2024-02-03 22:46 ` zlice
  2024-02-06  5:34 ` Luciogi
                   ` (35 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2024-02-03 22:46 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 4558 bytes --]

There is an updated pull request by zlice against master on the void-packages repository

https://github.com/zlice/void-packages ffmpeg6-split
https://github.com/void-linux/void-packages/pull/43761

ffmpeg6 split
[ci skip]


#### Testing the changes

- I tested the changes in this PR: **YES**

main testing has been vaapi in Firefox Nightly and enc/dec in Shotcut on Intel A770

#### New package

- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**

#### Local build testing

- I built this PR locally for my native architecture, **x86_64**

#### Discussion

Continuation of https://github.com/void-linux/void-packages/pull/36315

`libavresample` is deprecated, but marked as a dependency when trying to build other packages and install `ffmpeg`(6). I think the right way to handle this is make a meta package and the add to removals?


##### Commit naming / misc

~~Commits are 'dirty' right now, running with [gstreamer 1.22.1 updates](https://github.com/void-linux/void-packages/pull/42861) and [Intel OpenCL](https://github.com/void-linux/void-packages/pull/43084). This will also make [intel packages pr](https://github.com/void-linux/void-packages/pull/41132) obsolete.~~ (see Requirements below)

Maintainer for previous ffmpeg(4) was orphaned, I can put my name in there if that matters, though I don't exactly see myself keeping up on ffmpeg.

~~This updates QT5 which looks like it is usually hosted by Johnny. Not sure if there's any reason to stay there or these sources are fine.~~ Using qt5.15.11 now, revbumps and some patches.

##### STILL FFMPEG4

These are a mix of emulators, games and/or older packages.

- attract (multiple patches in master)
- ~~audacity (https://github.com/audacity/audacity/issues/2305 and https://sourceforge.net/p/portmedia/wiki/portsmf/ is 'beta')~~ (updated to 3.x, compiles with ffmpeg6)
- ccextractor (master patches? no release)
- vice (3.8 compiles, needs makedepends libcurl-devel)
- kodi
- mlt (only dep left is flowblade - flowblade 2.12.0.2 with mlt7-python3 can 'render' videos with cpu and gpu)
- ~~synfig (mlt)~~ (work with mlt7, bump synfigstudio)
- tvheadend
- ssr
- ~~spek-alternative~~ (replace with spek-x)
- ppsspp
- olive
- moc
- mediastreamer (linphone links are dead, changed to github belladonne. their stuff never worked for me but there are updates if someone wants to give it a try)
- libextractor (1.13 compiles, remove exiv2 patch)
- idjc (0.9.8 compiles, remove python3.10 patch, needs makedepends libebur128-devel and libshout-idjc 2.4.6 with '-r1' for distfile)
- hedgewars
- ~~ffmpegthumbnailer~~ (patches for moviedecoder.xxx files)
- ~~ffmpegthumbs~~ (latest compiles)
- deadbeef
- ~~omxplayer~~ (package removed, deprecated in favor of vlc)
- qtav (fork has ffmpeg 5 patch - https://github.com/cmguo/QtAV)
- `vlc` (vlc4 will support ffmpeg5, there's a patch to build 3.x with ffmpeg5 but it will lack vaapi)
- `osg` (OpenSceneGraph plus `xine-lib`)


##### HAVE NOT BUILT YET

- ~~omxplayer (rpi only? ffmpeg4)~~ (removed)
- kodi (big, but ffmpeg4)


##### UPDATED (for ffmpeg6)

- ~~blender: update to 3.5.1~~ ~~will be revbump with~~ https://github.com/void-linux/void-packages/pull/43992
- unpaper: update to 7.0.0.
- guvcview: update to 2.0.8.
- ~~qt5: update to 5.15.8~~ updated by another PR to 5.15.11
- ~~qt5-webengine: update to 5.18.15~~ updated by another PR to 5.15.16 (some patching for ffmpeg build)
- ~~shiboken2: revbump for qt5.15.8 (patch)~~ updated by another PR to 5.15.10
- ~~python3-pyside2: update to 5.15.8 (patch)~~ updated by another PR to 5.15.10
- New package: spex-x replaces spek-alternative for ffmpeg-6.0


##### Requirements

- ~~[gstreamer 1.22.2](https://github.com/void-linux/void-packages/pull/42861)~~ - a few packages use ffmpeg-devel and require a revbump

- ~~[Intel Packages](https://github.com/void-linux/void-packages/pull/41132) [Intel Packages v2](https://github.com/void-linux/void-packages/pull/47330) - ffmpeg4 uses different libraries than 6 (libmfx / Intel-MediaSDK vs only oneVPL that Intel is moving to), both are included here~~. Using replacement oneVPL from OBS update.

- ~~[shotcut 23.05.14](https://github.com/void-linux/void-packages/pull/44260)~~

- https://github.com/void-linux/void-packages/pull/44781 will remove from this PR

A patch file from https://github.com/void-linux/void-packages/pull/43761.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ffmpeg6-split-43761.patch --]
[-- Type: text/x-diff, Size: 228188 bytes --]

From a3c60b2ad35df66d6aa3a1ca0810e6701cc6d41c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:16:56 -0400
Subject: [PATCH 001/113] ffmpeg: update to 6.0.1.

---
 common/shlibs                                 | 26 ++++---
 srcpkgs/ffmpeg/files/altivec.patch            | 60 ---------------
 .../patches/armv5tel-floating-point.patch     | 18 -----
 srcpkgs/ffmpeg/patches/binutils-2.41.patch    | 73 -------------------
 ...h-libavcodec-libsvtav1-ten_bit_format.diff | 40 ----------
 .../workaround-mesa-readeon-vaapi-bug.patch   | 28 -------
 srcpkgs/ffmpeg/template                       | 40 +++++-----
 7 files changed, 37 insertions(+), 248 deletions(-)
 delete mode 100644 srcpkgs/ffmpeg/files/altivec.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/binutils-2.41.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 delete mode 100644 srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch

diff --git a/common/shlibs b/common/shlibs
index 71f172740e5c6..c1c79647f63ca 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -389,15 +389,23 @@ libid3tag.so.0 libid3tag-0.15.1b_1
 libgif.so.7 giflib-5.1.0_1
 libImlib2.so.1 imlib2-1.4.2_1
 libmp3lame.so.0 lame-3.98.2_1
-libavdevice.so.58 libavdevice-4.0_1
-libavformat.so.58 libavformat-4.0_1
-libswscale.so.5 libswscale-4.0_1
-libswresample.so.3 libswresample-4.0_1
-libavresample.so.4 libavresample-4.0_1
-libpostproc.so.55 libpostproc-4.0_1
-libavcodec.so.58 libavcodec-4.0_1
-libavutil.so.56 libavutil-4.0_1
-libavfilter.so.7 libavfilter-4.0_1
+libavdevice.so.60 libavdevice-6.0_1
+libavformat.so.60 libavformat-6.0_1
+libswscale.so.7 libswscale-6.0_1
+libswresample.so.4 libswresample-6.0_1
+libpostproc.so.57 libpostproc-6.0_1
+libavcodec.so.60 libavcodec-6.0_1
+libavutil.so.58 libavutil-6.0_1
+libavfilter.so.9 libavfilter-6.0_1
+libavdevice.so.58 libavdevice4-4.0_1
+libavformat.so.58 libavformat4-4.0_1
+libswscale.so.5 libswscale4-4.0_1
+libswresample.so.3 libswresample4-4.0_1
+libavresample.so.4 libavresample4-4.0_1
+libpostproc.so.55 libpostproc4-4.0_1
+libavcodec.so.58 libavcodec4-4.0_1
+libavutil.so.56 libavutil4-4.0_1
+libavfilter.so.7 libavfilter4-4.0_1
 libSDL-1.2.so.0 SDL-1.2.14_1
 libSDL_image-1.2.so.0 SDL_image-1.2.10_1
 libx264.so.157 x264-20190507.2245_1
diff --git a/srcpkgs/ffmpeg/files/altivec.patch b/srcpkgs/ffmpeg/files/altivec.patch
deleted file mode 100644
index 9c57200463320..0000000000000
--- a/srcpkgs/ffmpeg/files/altivec.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-revert some altivec specific change on all ppc* except ppc64le*
-
-q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
-conditionally, for ppc* but not ppc64le* (the new code is valid for
-POWER8 VSX which LE targets as a baseline but not BE)"
-
-
-This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
----
- libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
- 1 file changed, 20 insertions(+), 4 deletions(-)
-
-diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
-index 536545293d..c1e2852adb 100644
---- a/libswscale/ppc/yuv2rgb_altivec.c
-+++ b/libswscale/ppc/yuv2rgb_altivec.c
-@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-     vector signed short R1, G1, B1;                                           \
-     vector unsigned char R, G, B;                                             \
-                                                                               \
-+    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
-+    vector unsigned char align_perm;                                          \
-+                                                                              \
-     vector signed short lCY       = c->CY;                                    \
-     vector signed short lOY       = c->OY;                                    \
-     vector signed short lCRV      = c->CRV;                                   \
-@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
-                                                                               \
-         for (j = 0; j < w / 16; j++) {                                        \
--            y0 = vec_xl(0, y1i);                                              \
-+            y1ivP = (const vector unsigned char *) y1i;                       \
-+            y2ivP = (const vector unsigned char *) y2i;                       \
-+            uivP  = (const vector unsigned char *) ui;                        \
-+            vivP  = (const vector unsigned char *) vi;                        \
-+                                                                              \
-+            align_perm = vec_lvsl(0, y1i);                                    \
-+            y0 = (vector unsigned char)                                       \
-+                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
-                                                                               \
--            y1 = vec_xl(0, y2i);                                              \
-+            align_perm = vec_lvsl(0, y2i);                                    \
-+            y1 = (vector unsigned char)                                       \
-+                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
-                                                                               \
--            u = (vector signed char) vec_xl(0, ui);                           \
-+            align_perm = vec_lvsl(0, ui);                                     \
-+            u = (vector signed char)                                          \
-+                    vec_perm(uivP[0], uivP[1], align_perm);                   \
-                                                                               \
--            v = (vector signed char) vec_xl(0, vi);                           \
-+            align_perm = vec_lvsl(0, vi);                                     \
-+            v = (vector signed char)                                          \
-+                    vec_perm(vivP[0], vivP[1], align_perm);                   \
-                                                                               \
-             u = (vector signed char)                                          \
-                     vec_sub(u,                                                \
--- 
-2.27.0
-
diff --git a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
deleted file mode 100644
index 9a55178c74f0f..0000000000000
--- a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
-+++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
-@@ -39,6 +39,15 @@
- #endif
- #include <fenv.h>
- 
-+#if (FE_ALL_EXCEPT == 0)
-+/* E.g. ARM soft float does not define these */
-+#define FE_INVALID    0
-+#define FE_DIVBYZERO  0
-+#define FE_OVERFLOW   0
-+#define FE_UNDERFLOW  0
-+#define FE_INEXACT    0
-+#endif
-+
- #if CONFIG_LIBFONTCONFIG
- #include <fontconfig/fontconfig.h>
- #endif
diff --git a/srcpkgs/ffmpeg/patches/binutils-2.41.patch b/srcpkgs/ffmpeg/patches/binutils-2.41.patch
deleted file mode 100644
index 53a596d0ee7d4..0000000000000
--- a/srcpkgs/ffmpeg/patches/binutils-2.41.patch
+++ /dev/null
@@ -1,73 +0,0 @@
-From effadce6c756247ea8bae32dc13bb3e6f464f0eb Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= <remi@remlab.net>
-Date: Sun, 16 Jul 2023 18:18:02 +0300
-Subject: [PATCH] avcodec/x86/mathops: clip constants used with shift
- instructions within inline assembly
-
-Fixes assembling with binutil as >= 2.41
-
-Signed-off-by: James Almer <jamrial@gmail.com>
----
- libavcodec/x86/mathops.h | 26 +++++++++++++++++++++++---
- 1 file changed, 23 insertions(+), 3 deletions(-)
-
-diff --git a/libavcodec/x86/mathops.h b/libavcodec/x86/mathops.h
-index 6298f5ed1983b..ca7e2dffc1076 100644
---- a/libavcodec/x86/mathops.h
-+++ b/libavcodec/x86/mathops.h
-@@ -35,12 +35,20 @@
- static av_always_inline av_const int MULL(int a, int b, unsigned shift)
- {
-     int rt, dummy;
-+    if (__builtin_constant_p(shift))
-     __asm__ (
-         "imull %3               \n\t"
-         "shrdl %4, %%edx, %%eax \n\t"
-         :"=a"(rt), "=d"(dummy)
--        :"a"(a), "rm"(b), "ci"((uint8_t)shift)
-+        :"a"(a), "rm"(b), "i"(shift & 0x1F)
-     );
-+    else
-+        __asm__ (
-+            "imull %3               \n\t"
-+            "shrdl %4, %%edx, %%eax \n\t"
-+            :"=a"(rt), "=d"(dummy)
-+            :"a"(a), "rm"(b), "c"((uint8_t)shift)
-+        );
-     return rt;
- }
- 
-@@ -113,19 +121,31 @@ __asm__ volatile(\
- // avoid +32 for shift optimization (gcc should do that ...)
- #define NEG_SSR32 NEG_SSR32
- static inline  int32_t NEG_SSR32( int32_t a, int8_t s){
-+    if (__builtin_constant_p(s))
-     __asm__ ("sarl %1, %0\n\t"
-          : "+r" (a)
--         : "ic" ((uint8_t)(-s))
-+         : "i" (-s & 0x1F)
-     );
-+    else
-+        __asm__ ("sarl %1, %0\n\t"
-+               : "+r" (a)
-+               : "c" ((uint8_t)(-s))
-+        );
-     return a;
- }
- 
- #define NEG_USR32 NEG_USR32
- static inline uint32_t NEG_USR32(uint32_t a, int8_t s){
-+    if (__builtin_constant_p(s))
-     __asm__ ("shrl %1, %0\n\t"
-          : "+r" (a)
--         : "ic" ((uint8_t)(-s))
-+         : "i" (-s & 0x1F)
-     );
-+    else
-+        __asm__ ("shrl %1, %0\n\t"
-+               : "+r" (a)
-+               : "c" ((uint8_t)(-s))
-+        );
-     return a;
- }
- 
diff --git a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
deleted file mode 100644
index aa948f7a8a2df..0000000000000
--- a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
+++ /dev/null
@@ -1,40 +0,0 @@
-#==================================================================================================
-# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
-# From: Christopher Degawa <christopher.degawa@intel.com>
-# Date: Thu, 20 Oct 2022 22:55:27 -0500
-# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
-#
-# compressed_ten_bit_format has been deprecated upstream and has no effect
-# and can be removed. Plus, technically it was never used in the first place
-# since it would require the app (ffmpeg) to set it and do additional
-# processing of the input frames.
-#
-# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
-#
-# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
-#==================================================================================================
---- a/libavcodec/libsvtav1.c
-+++ b/libavcodec/libsvtav1.c
-@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
- 
- static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
- {
--    const int    pack_mode_10bit =
--        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
--    const size_t luma_size_8bit  =
--        config->source_width * config->source_height * (1 << pack_mode_10bit);
--    const size_t luma_size_10bit =
--        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
-+    const size_t luma_size = config->source_width * config->source_height *
-+        (config->encoder_bit_depth > 8 ? 2 : 1);
- 
-     EbSvtIOFormat *in_data;
- 
--    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
-+    svt_enc->raw_size = luma_size * 3 / 2;
- 
-     // allocate buffer for in and out
-     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
--- 
-GitLab
-
diff --git a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
deleted file mode 100644
index 00e3f68a415b8..0000000000000
--- a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
-From: Rainer Hochecker <fernetmenta@online.de>
-Date: Sat, 26 Jan 2019 19:48:35 +0100
-Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
-
-This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
-It was hit frequently when watching h264 channels received via DVB-X.
-Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
----
- libavcodec/vaapi_h264.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
-index 5854587a255..f12fdc457a4 100644
---- a/libavcodec/vaapi_h264.c
-+++ b/libavcodec/vaapi_h264.c
-@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
-     H264SliceContext *sl = &h->slice_ctx[0];
-     int ret;
- 
-+    if (pic->nb_slices == 0) {
-+        ret = AVERROR_INVALIDDATA;
-+        goto finish;
-+    }
-+
-     ret = ff_vaapi_decode_issue(avctx, pic);
-     if (ret < 0)
-         goto finish;
diff --git a/srcpkgs/ffmpeg/template b/srcpkgs/ffmpeg/template
index 1ebb436135938..f1e4712c41d08 100644
--- a/srcpkgs/ffmpeg/template
+++ b/srcpkgs/ffmpeg/template
@@ -1,15 +1,15 @@
 # Template file for 'ffmpeg'
 # audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
 pkgname=ffmpeg
-version=4.4.4
-revision=6
+version=6.0.1
+revision=1
 short_desc="Decoding, encoding and streaming software"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="https://www.ffmpeg.org"
 changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
 distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
-checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+checksum=9b16b8731d78e596b4be0d720428ca42df642bb2d78342881ff7f5bc29fc9623
 
 hostmakedepends="pkg-config perl"
 makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
@@ -26,12 +26,13 @@ makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-deve
  $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
  $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
  $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
- $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers Vulkan-Tools Vulkan-ValidationLayers')
+ $(vopt_if onevpl 'oneVPL oneVPL-devel')
  $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
 depends="ffplay>=${version}_${revision}"
 
 build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
- dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec onevpl"
 build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
 desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
 desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
@@ -39,9 +40,13 @@ desc_option_sofa="Enable support for AES SOFA"
 desc_option_webp="Enable support for WebP"
 
 case "$XBPS_TARGET_MACHINE" in
-	i686*|x86_64*)
-		hostmakedepends+=" nasm"
+	i686*)
 		build_options_default+=" vaapi vdpau nvenc nvdec"
+		hostmakedepends+=" nasm"
+		;;
+	x86_64*)
+		hostmakedepends+=" nasm"
+		build_options_default+=" vaapi vdpau nvenc nvdec onevpl"
 		;;
 	ppc64*) build_options_default+=" vaapi vdpau";;
 	mips*) CFLAGS="-mnan=legacy";;
@@ -65,8 +70,6 @@ post_patch() {
 		ppc64le*) ;;
 		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
 	esac
-
-	vsed -i libavfilter/vf_libvmaf.c -e 's!/usr/local/share/model/\(vmaf_v0.6.1\).pkl!/usr/share/vmaf/\1.json!'
 }
 
 do_configure() {
@@ -115,18 +118,19 @@ do_configure() {
 		$(vopt_enable x265 libx265) \
 		$(vopt_enable v4l2 libv4l2) \
 		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
-		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		--enable-libbs2b --enable-libvidstab \
 		$(vopt_enable dav1d libdav1d) \
 		$(vopt_enable zimg libzimg) \
 		$(vopt_enable webp libwebp) \
 		$(vopt_enable sofa libmysofa) \
 		$(vopt_enable vulkan) \
+		$(vopt_enable onevpl libvpl) \
 		$(vopt_enable drm libdrm) \
 		$(vopt_enable svtav1 libsvtav1) \
 		$(vopt_enable srt libsrt) \
 		$(vopt_enable rist librist) \
-		$(vopt_if nvenc '--enable-nvenc') \
-		$(vopt_if nvdec '--enable-nvdec')
+		$(vopt_enable nvenc nvenc) \
+		$(vopt_enable nvdec nvdec)
 }
 
 do_build() {
@@ -153,10 +157,8 @@ libavdevice_package() {
 }
 
 libavresample_package() {
-	short_desc="FFmpeg audio resampling library"
-	pkg_install() {
-		vmove "usr/lib/libavresample.so.*"
-	}
+	short_desc="Package deprecated, removal needed"
+	build_style=meta
 }
 
 libavformat_package() {
@@ -210,15 +212,13 @@ ffmpeg-devel_package() {
 		libavfilter>=${version}_${revision}
 		libpostproc>=${version}_${revision}
 		libswscale>=${version}_${revision}
-		libswresample>=${version}_${revision}
-		libavresample>=${version}_${revision}"
+		libswresample>=${version}_${revision}"
 	short_desc+=" - development files"
-
+	conflicts="ffmpeg4-devel"
 	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
 		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
 		nostrip_files="/usr/lib/libavfilter.a"
 	fi
-
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig

From 3777cd88eb6e96892bd6ff2037bd5fad8365399a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:14 -0400
Subject: [PATCH 002/113] openshot: revbump for ffmpeg6

---
 srcpkgs/openshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openshot/template b/srcpkgs/openshot/template
index 8f47851eef354..affb652a9d500 100644
--- a/srcpkgs/openshot/template
+++ b/srcpkgs/openshot/template
@@ -1,7 +1,7 @@
 # Template file for 'openshot'
 pkgname=openshot
 version=3.0.0
-revision=2
+revision=3
 build_style=python3-module
 hostmakedepends="python3 python3-setuptools"
 makedepends="ffmpeg-devel python3-PyQt5"

From d2009a52e3136aa8230f6ec702074d0aa2006eeb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:36 -0400
Subject: [PATCH 003/113] sumo: revbump for ffmpeg6

---
 srcpkgs/sumo/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/sumo/template b/srcpkgs/sumo/template
index a3fe134aa5acc..a730afa9fafa9 100644
--- a/srcpkgs/sumo/template
+++ b/srcpkgs/sumo/template
@@ -1,7 +1,7 @@
 # Template file for 'sumo'
 pkgname=sumo
 version=1.12.0
-revision=6
+revision=7
 build_style=cmake
 hostmakedepends="libgdal-tools pkg-config swig python3-setuptools"
 makedepends="python3-devel ffmpeg-devel fox-devel gl2ps-devel libgdal-devel

From ab1fd15c6db3ba5b5275699db920312f05318c12 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:56:22 -0400
Subject: [PATCH 004/113] New package: ffmpeg4-4.4.4.

---
 srcpkgs/ffmpeg4-devel                         |   1 +
 srcpkgs/ffmpeg4/files/altivec.patch           |  60 +++++
 .../patches/armv5tel-floating-point.patch     |  18 ++
 srcpkgs/ffmpeg4/patches/binutils-2.41.patch   |  73 ++++++
 ...h-libavcodec-libsvtav1-ten_bit_format.diff |  40 +++
 .../workaround-mesa-readeon-vaapi-bug.patch   |  28 +++
 srcpkgs/ffmpeg4/template                      | 234 ++++++++++++++++++
 srcpkgs/libavcodec4                           |   1 +
 srcpkgs/libavdevice4                          |   1 +
 srcpkgs/libavfilter4                          |   1 +
 srcpkgs/libavformat4                          |   1 +
 srcpkgs/libavresample4                        |   1 +
 srcpkgs/libavutil4                            |   1 +
 srcpkgs/libpostproc4                          |   1 +
 srcpkgs/libswresample4                        |   1 +
 srcpkgs/libswscale4                           |   1 +
 16 files changed, 463 insertions(+)
 create mode 120000 srcpkgs/ffmpeg4-devel
 create mode 100644 srcpkgs/ffmpeg4/files/altivec.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/binutils-2.41.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 create mode 100644 srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
 create mode 100644 srcpkgs/ffmpeg4/template
 create mode 120000 srcpkgs/libavcodec4
 create mode 120000 srcpkgs/libavdevice4
 create mode 120000 srcpkgs/libavfilter4
 create mode 120000 srcpkgs/libavformat4
 create mode 120000 srcpkgs/libavresample4
 create mode 120000 srcpkgs/libavutil4
 create mode 120000 srcpkgs/libpostproc4
 create mode 120000 srcpkgs/libswresample4
 create mode 120000 srcpkgs/libswscale4

diff --git a/srcpkgs/ffmpeg4-devel b/srcpkgs/ffmpeg4-devel
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/ffmpeg4-devel
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/ffmpeg4/files/altivec.patch b/srcpkgs/ffmpeg4/files/altivec.patch
new file mode 100644
index 0000000000000..9c57200463320
--- /dev/null
+++ b/srcpkgs/ffmpeg4/files/altivec.patch
@@ -0,0 +1,60 @@
+revert some altivec specific change on all ppc* except ppc64le*
+
+q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
+conditionally, for ppc* but not ppc64le* (the new code is valid for
+POWER8 VSX which LE targets as a baseline but not BE)"
+
+
+This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
+---
+ libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
+ 1 file changed, 20 insertions(+), 4 deletions(-)
+
+diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
+index 536545293d..c1e2852adb 100644
+--- a/libswscale/ppc/yuv2rgb_altivec.c
++++ b/libswscale/ppc/yuv2rgb_altivec.c
+@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+     vector signed short R1, G1, B1;                                           \
+     vector unsigned char R, G, B;                                             \
+                                                                               \
++    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
++    vector unsigned char align_perm;                                          \
++                                                                              \
+     vector signed short lCY       = c->CY;                                    \
+     vector signed short lOY       = c->OY;                                    \
+     vector signed short lCRV      = c->CRV;                                   \
+@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
+                                                                               \
+         for (j = 0; j < w / 16; j++) {                                        \
+-            y0 = vec_xl(0, y1i);                                              \
++            y1ivP = (const vector unsigned char *) y1i;                       \
++            y2ivP = (const vector unsigned char *) y2i;                       \
++            uivP  = (const vector unsigned char *) ui;                        \
++            vivP  = (const vector unsigned char *) vi;                        \
++                                                                              \
++            align_perm = vec_lvsl(0, y1i);                                    \
++            y0 = (vector unsigned char)                                       \
++                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
+                                                                               \
+-            y1 = vec_xl(0, y2i);                                              \
++            align_perm = vec_lvsl(0, y2i);                                    \
++            y1 = (vector unsigned char)                                       \
++                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
+                                                                               \
+-            u = (vector signed char) vec_xl(0, ui);                           \
++            align_perm = vec_lvsl(0, ui);                                     \
++            u = (vector signed char)                                          \
++                    vec_perm(uivP[0], uivP[1], align_perm);                   \
+                                                                               \
+-            v = (vector signed char) vec_xl(0, vi);                           \
++            align_perm = vec_lvsl(0, vi);                                     \
++            v = (vector signed char)                                          \
++                    vec_perm(vivP[0], vivP[1], align_perm);                   \
+                                                                               \
+             u = (vector signed char)                                          \
+                     vec_sub(u,                                                \
+-- 
+2.27.0
+
diff --git a/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
new file mode 100644
index 0000000000000..9a55178c74f0f
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
@@ -0,0 +1,18 @@
+--- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
++++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
+@@ -39,6 +39,15 @@
+ #endif
+ #include <fenv.h>
+ 
++#if (FE_ALL_EXCEPT == 0)
++/* E.g. ARM soft float does not define these */
++#define FE_INVALID    0
++#define FE_DIVBYZERO  0
++#define FE_OVERFLOW   0
++#define FE_UNDERFLOW  0
++#define FE_INEXACT    0
++#endif
++
+ #if CONFIG_LIBFONTCONFIG
+ #include <fontconfig/fontconfig.h>
+ #endif
diff --git a/srcpkgs/ffmpeg4/patches/binutils-2.41.patch b/srcpkgs/ffmpeg4/patches/binutils-2.41.patch
new file mode 100644
index 0000000000000..53a596d0ee7d4
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/binutils-2.41.patch
@@ -0,0 +1,73 @@
+From effadce6c756247ea8bae32dc13bb3e6f464f0eb Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= <remi@remlab.net>
+Date: Sun, 16 Jul 2023 18:18:02 +0300
+Subject: [PATCH] avcodec/x86/mathops: clip constants used with shift
+ instructions within inline assembly
+
+Fixes assembling with binutil as >= 2.41
+
+Signed-off-by: James Almer <jamrial@gmail.com>
+---
+ libavcodec/x86/mathops.h | 26 +++++++++++++++++++++++---
+ 1 file changed, 23 insertions(+), 3 deletions(-)
+
+diff --git a/libavcodec/x86/mathops.h b/libavcodec/x86/mathops.h
+index 6298f5ed1983b..ca7e2dffc1076 100644
+--- a/libavcodec/x86/mathops.h
++++ b/libavcodec/x86/mathops.h
+@@ -35,12 +35,20 @@
+ static av_always_inline av_const int MULL(int a, int b, unsigned shift)
+ {
+     int rt, dummy;
++    if (__builtin_constant_p(shift))
+     __asm__ (
+         "imull %3               \n\t"
+         "shrdl %4, %%edx, %%eax \n\t"
+         :"=a"(rt), "=d"(dummy)
+-        :"a"(a), "rm"(b), "ci"((uint8_t)shift)
++        :"a"(a), "rm"(b), "i"(shift & 0x1F)
+     );
++    else
++        __asm__ (
++            "imull %3               \n\t"
++            "shrdl %4, %%edx, %%eax \n\t"
++            :"=a"(rt), "=d"(dummy)
++            :"a"(a), "rm"(b), "c"((uint8_t)shift)
++        );
+     return rt;
+ }
+ 
+@@ -113,19 +121,31 @@ __asm__ volatile(\
+ // avoid +32 for shift optimization (gcc should do that ...)
+ #define NEG_SSR32 NEG_SSR32
+ static inline  int32_t NEG_SSR32( int32_t a, int8_t s){
++    if (__builtin_constant_p(s))
+     __asm__ ("sarl %1, %0\n\t"
+          : "+r" (a)
+-         : "ic" ((uint8_t)(-s))
++         : "i" (-s & 0x1F)
+     );
++    else
++        __asm__ ("sarl %1, %0\n\t"
++               : "+r" (a)
++               : "c" ((uint8_t)(-s))
++        );
+     return a;
+ }
+ 
+ #define NEG_USR32 NEG_USR32
+ static inline uint32_t NEG_USR32(uint32_t a, int8_t s){
++    if (__builtin_constant_p(s))
+     __asm__ ("shrl %1, %0\n\t"
+          : "+r" (a)
+-         : "ic" ((uint8_t)(-s))
++         : "i" (-s & 0x1F)
+     );
++    else
++        __asm__ ("shrl %1, %0\n\t"
++               : "+r" (a)
++               : "c" ((uint8_t)(-s))
++        );
+     return a;
+ }
+ 
diff --git a/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
new file mode 100644
index 0000000000000..aa948f7a8a2df
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
@@ -0,0 +1,40 @@
+#==================================================================================================
+# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
+# From: Christopher Degawa <christopher.degawa@intel.com>
+# Date: Thu, 20 Oct 2022 22:55:27 -0500
+# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
+#
+# compressed_ten_bit_format has been deprecated upstream and has no effect
+# and can be removed. Plus, technically it was never used in the first place
+# since it would require the app (ffmpeg) to set it and do additional
+# processing of the input frames.
+#
+# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
+#
+# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
+#==================================================================================================
+--- a/libavcodec/libsvtav1.c
++++ b/libavcodec/libsvtav1.c
+@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
+ 
+ static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
+ {
+-    const int    pack_mode_10bit =
+-        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
+-    const size_t luma_size_8bit  =
+-        config->source_width * config->source_height * (1 << pack_mode_10bit);
+-    const size_t luma_size_10bit =
+-        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
++    const size_t luma_size = config->source_width * config->source_height *
++        (config->encoder_bit_depth > 8 ? 2 : 1);
+ 
+     EbSvtIOFormat *in_data;
+ 
+-    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
++    svt_enc->raw_size = luma_size * 3 / 2;
+ 
+     // allocate buffer for in and out
+     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
+-- 
+GitLab
+
diff --git a/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
new file mode 100644
index 0000000000000..00e3f68a415b8
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
@@ -0,0 +1,28 @@
+From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
+From: Rainer Hochecker <fernetmenta@online.de>
+Date: Sat, 26 Jan 2019 19:48:35 +0100
+Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
+
+This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
+It was hit frequently when watching h264 channels received via DVB-X.
+Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
+---
+ libavcodec/vaapi_h264.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
+index 5854587a255..f12fdc457a4 100644
+--- a/libavcodec/vaapi_h264.c
++++ b/libavcodec/vaapi_h264.c
+@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
+     H264SliceContext *sl = &h->slice_ctx[0];
+     int ret;
+ 
++    if (pic->nb_slices == 0) {
++        ret = AVERROR_INVALIDDATA;
++        goto finish;
++    }
++
+     ret = ff_vaapi_decode_issue(avctx, pic);
+     if (ret < 0)
+         goto finish;
diff --git a/srcpkgs/ffmpeg4/template b/srcpkgs/ffmpeg4/template
new file mode 100644
index 0000000000000..9ba14bdb8ddf3
--- /dev/null
+++ b/srcpkgs/ffmpeg4/template
@@ -0,0 +1,234 @@
+# Template file for 'ffmpeg4'
+# audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
+pkgname=ffmpeg4
+version=4.4.4
+revision=1
+short_desc="Decoding, encoding and streaming software - ffmpeg4 libraries only"
+maintainer="Orphaned <orphan@voidlinux.org>"
+license="GPL-3.0-or-later"
+homepage="https://www.ffmpeg.org"
+changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
+distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
+checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+
+hostmakedepends="pkg-config perl"
+makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
+ libXext-devel libXvMC-devel libxcb-devel lame-devel libtheora-devel
+ libvorbis-devel x264-devel xvidcore-devel jack-devel SDL2-devel
+ libcdio-paranoia-devel librtmp-devel libmodplug-devel gnutls-devel
+ speex-devel celt-devel harfbuzz-devel libass-devel opus-devel ocl-icd-devel
+ libbs2b-devel libvidstab-devel vmaf-devel $(vopt_if pulseaudio pulseaudio-devel)
+ $(vopt_if vaapi libva-devel) $(vopt_if vdpau libvdpau-devel)
+ $(vopt_if x265 x265-devel) $(vopt_if v4l2 v4l-utils-devel)
+ $(vopt_if fdk_aac fdk-aac-devel) $(vopt_if vpx libvpx-devel)
+ $(vopt_if aom libaom-devel) $(vopt_if sndio sndio-devel)
+ $(vopt_if dav1d libdav1d-devel) $(vopt_if zimg zimg-devel)
+ $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
+ $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
+ $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
+
+build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
+
+desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
+desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
+desc_option_sofa="Enable support for AES SOFA"
+desc_option_webp="Enable support for WebP"
+
+case "$XBPS_TARGET_MACHINE" in
+	i686*|x86_64*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau nvenc nvdec"
+			;;
+	ppc64*) build_options_default+=" vaapi vdpau";;
+	mips*) CFLAGS="-mnan=legacy";;
+esac
+
+if [ "$XBPS_TARGET_WORDSIZE" != "32" ]; then
+	build_options_default+=" svtav1"
+fi
+
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+fi
+
+_apply_patch() {
+	local args="$1" pname="$(basename $2)"
+
+	if [ ! -f ".${pname}_done" ]; then
+		patch -N $args -i $2
+		touch .${pname}_done
+	fi
+}
+
+post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64le*) ;;
+		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
+	esac
+
+	vsed -i libavfilter/vf_libvmaf.c -e 's!/usr/local/share/model/\(vmaf_v0.6.1\).pkl!/usr/share/vmaf/\1.json!'
+}
+
+do_configure() {
+	# Fix gcc on x86_64-musl only
+	if [ "$XBPS_TARGET_MACHINE" = "x86_64-musl" ]; then
+		vsed -i configure -e "s;_cflags_speed='-O3';_cflags_speed='-O2';"
+	fi
+
+	if [ "$CROSS_BUILD" ]; then
+		case "$XBPS_TARGET_MACHINE" in
+			arm*) _arch="arm";;
+			aarch64*) _arch="aarch64";;
+			mips*) _arch="mips";;
+			ppc64*) _arch="ppc64";;
+			ppc*) _arch="ppc";;
+			*) _arch="${XBPS_TARGET_MACHINE%%-musl}";;
+		esac
+
+		_args+=" --enable-cross-compile
+			--sysroot=$XBPS_CROSS_BASE
+			--cross-prefix=${XBPS_CROSS_TRIPLET}-
+			--target-os=linux --arch=${_arch}"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc|ppc-musl) _args+=" --disable-altivec";;
+	esac
+
+	if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+		_args+=" --extra-libs=-latomic"
+	fi
+
+	./configure --prefix=/usr --disable-debug --enable-gpl --enable-gnutls \
+		--disable-stripping \
+		--enable-libcdio --enable-version3 --enable-runtime-cpudetect \
+		--enable-libmp3lame --enable-libvorbis --enable-libxvid \
+		--enable-libx264 $(vopt_enable vpx libvpx) --enable-libtheora \
+		--enable-shared --enable-static --enable-libxcb \
+		$(vopt_enable pulseaudio libpulse) --enable-libfreetype --enable-libmodplug \
+		--enable-libspeex --enable-libcelt --enable-libass \
+		--enable-libopus --enable-librtmp --enable-libjack \
+		$(vopt_if fdk_aac '--enable-nonfree --enable-libfdk-aac') \
+		--disable-libopencore_amrnb --disable-libopencore_amrwb \
+		--disable-libopenjpeg \
+		--enable-postproc --enable-opencl ${_args} --enable-libvmaf ${_args} \
+		$(vopt_enable x265 libx265) \
+		$(vopt_enable v4l2 libv4l2) \
+		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
+		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		$(vopt_enable dav1d libdav1d) \
+		$(vopt_enable zimg libzimg) \
+		$(vopt_enable webp libwebp) \
+		$(vopt_enable sofa libmysofa) \
+		$(vopt_enable vulkan) \
+		$(vopt_enable drm libdrm) \
+		$(vopt_enable svtav1 libsvtav1) \
+		$(vopt_enable srt libsrt) \
+		$(vopt_enable rist librist) \
+		$(vopt_if nvenc '--enable-nvenc') \
+		$(vopt_if nvdec '--enable-nvdec')
+}
+
+do_build() {
+	make ${makejobs}
+	make doc/ff{mpeg,play}.1
+}
+
+do_install() {
+	make DESTDIR=${DESTDIR} install install-man
+	rm -rf ${DESTDIR}/usr/bin
+}
+
+libavcodec4_package() {
+	short_desc="FFmpeg codec library"
+	pkg_install() {
+		vmove "usr/lib/libavcodec.so.*"
+	}
+}
+
+libavdevice4_package() {
+	short_desc="FFmpeg device handling library"
+	pkg_install() {
+		vmove "usr/lib/libavdevice.so.*"
+	}
+}
+
+libavresample4_package() {
+	short_desc="FFmpeg audio resampling library"
+	pkg_install() {
+		vmove "usr/lib/libavresample.so.*"
+	}
+}
+
+libavformat4_package() {
+	short_desc="FFmpeg file format library"
+	pkg_install() {
+		vmove "usr/lib/libavformat.so.*"
+	}
+}
+
+libavutil4_package() {
+	short_desc="FFmpeg utility library"
+	pkg_install() {
+		vmove "usr/lib/libavutil.so.*"
+	}
+}
+
+libavfilter4_package() {
+	short_desc="FFmpeg audio/video filter library"
+	pkg_install() {
+		vmove "usr/lib/libavfilter.so.*"
+	}
+}
+
+libpostproc4_package() {
+	short_desc="FFmpeg video postprocessing library"
+	pkg_install() {
+		vmove "usr/lib/libpostproc.so.*"
+	}
+}
+
+libswscale4_package() {
+	short_desc="FFmpeg video scaling library"
+	pkg_install() {
+		vmove "usr/lib/libswscale.so.*"
+	}
+}
+
+libswresample4_package() {
+	short_desc="FFmpeg video resampling library"
+	pkg_install() {
+		vmove "usr/lib/libswresample.so.*"
+	}
+}
+
+ffmpeg4-devel_package() {
+	depends="
+		libavcodec4>=${version}_${revision}
+		libavdevice4>=${version}_${revision}
+		libavformat4>=${version}_${revision}
+		libavutil4>=${version}_${revision}
+		libavfilter4>=${version}_${revision}
+		libpostproc4>=${version}_${revision}
+		libswscale4>=${version}_${revision}
+		libswresample4>=${version}_${revision}
+		libavresample4>=${version}_${revision}"
+	short_desc+=" - development files"
+	conflicts="ffmpeg-devel"
+	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
+		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
+		nostrip_files="/usr/lib/libavfilter.a"
+	fi
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.a"
+		vmove "usr/lib/*.so"
+		vmove usr/share/ffmpeg/examples
+		vmove usr/share/man/man3
+	}
+}
diff --git a/srcpkgs/libavcodec4 b/srcpkgs/libavcodec4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavcodec4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavdevice4 b/srcpkgs/libavdevice4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavdevice4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavfilter4 b/srcpkgs/libavfilter4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavfilter4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavformat4 b/srcpkgs/libavformat4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavformat4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavresample4 b/srcpkgs/libavresample4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavutil4 b/srcpkgs/libavutil4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavutil4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libpostproc4 b/srcpkgs/libpostproc4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libpostproc4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswresample4 b/srcpkgs/libswresample4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libswresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswscale4 b/srcpkgs/libswscale4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libswscale4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file

From 93f6955ab3e9e41ec8d5ebdc46632ae9de472e4a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:04 -0400
Subject: [PATCH 005/113] opencv: update to 4.7.0.

---
 common/shlibs           | 104 ++++++++++++++++++++--------------------
 srcpkgs/opencv/template |   8 ++--
 2 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index c1c79647f63ca..e8b9e5e974fe7 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2070,58 +2070,58 @@ libcapstone.so.5 capstone-5.0.1_1
 libhavege.so.2 libhaveged-1.9.11_1
 libnih.so.1 libnih-1.0.3_1
 libnih-dbus.so.1 libnih-1.0.3_1
-libopencv_quality.so.406 libopencv-4.6.0_1
-libopencv_reg.so.406 libopencv-4.6.0_1
-libopencv_surface_matching.so.406 libopencv-4.6.0_1
-libopencv_xphoto.so.406 libopencv-4.6.0_1
-libopencv_freetype.so.406 libopencv-4.6.0_1
-libopencv_fuzzy.so.406 libopencv-4.6.0_1
-libopencv_hfs.so.406 libopencv-4.6.0_1
-libopencv_img_hash.so.406 libopencv-4.6.0_1
-libopencv_line_descriptor.so.406 libopencv-4.6.0_1
-libopencv_saliency.so.406 libopencv-4.6.0_1
-libopencv_structured_light.so.406 libopencv-4.6.0_1
-libopencv_aruco.so.406 libopencv-4.6.0_1
-libopencv_bgsegm.so.406 libopencv-4.6.0_1
-libopencv_bioinspired.so.406 libopencv-4.6.0_1
-libopencv_ccalib.so.406 libopencv-4.6.0_1
-libopencv_face.so.406 libopencv-4.6.0_1
-libopencv_tracking.so.406 libopencv-4.6.0_1
-libopencv_xfeatures2d.so.406 libopencv-4.6.0_1
-libopencv_optflow.so.406 libopencv-4.6.0_1
-libopencv_ximgproc.so.406 libopencv-4.6.0_1
-libopencv_plot.so.406 libopencv-4.6.0_1
-libopencv_text.so.406 libopencv-4.6.0_1
-libopencv_ml.so.406 libopencv-4.6.0_1
-libopencv_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn.so.406 libopencv-4.6.0_1
-libopencv_shape.so.406 libopencv-4.6.0_1
-libopencv_stitching.so.406 libopencv-4.6.0_1
-libopencv_photo.so.406 libopencv-4.6.0_1
-libopencv_video.so.406 libopencv-4.6.0_1
-libopencv_calib3d.so.406 libopencv-4.6.0_1
-libopencv_features2d.so.406 libopencv-4.6.0_1
-libopencv_flann.so.406 libopencv-4.6.0_1
-libopencv_highgui.so.406 libopencv-4.6.0_1
-libopencv_videoio.so.406 libopencv-4.6.0_1
-libopencv_imgcodecs.so.406 libopencv-4.6.0_1
-libopencv_imgproc.so.406 libopencv-4.6.0_1
-libopencv_core.so.406 libopencv-4.6.0_1
-libopencv_superres.so.406 libopencv-4.6.0_1
-libopencv_videostab.so.406 libopencv-4.6.0_1
-libopencv_gapi.so.406 libopencv-4.6.0_1
-libopencv_xobjdetect.so.406 libopencv-4.6.0_1
-libopencv_datasets.so.406 libopencv-4.6.0_1
-libopencv_dnn_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn_superres.so.406 libopencv-4.6.0_1
-libopencv_dpm.so.406 libopencv-4.6.0_1
-libopencv_phase_unwrapping.so.406 libopencv-4.6.0_1
-libopencv_stereo.so.406 libopencv-4.6.0_1
-libopencv_rapid.so.406 libopencv-4.6.0_1
-libopencv_intensity_transform.so.406 libopencv-4.6.0_1
-libopencv_alphamat.so.406 libopencv-4.6.0_1
-libopencv_barcode.so.406 libopencv-4.6.0_1
-libopencv_mcc.so.406 libopencv-4.6.0_1
+libopencv_quality.so.407 libopencv-4.7.0_1
+libopencv_reg.so.407 libopencv-4.7.0_1
+libopencv_surface_matching.so.407 libopencv-4.7.0_1
+libopencv_xphoto.so.407 libopencv-4.7.0_1
+libopencv_freetype.so.407 libopencv-4.7.0_1
+libopencv_fuzzy.so.407 libopencv-4.7.0_1
+libopencv_hfs.so.407 libopencv-4.7.0_1
+libopencv_img_hash.so.407 libopencv-4.7.0_1
+libopencv_line_descriptor.so.407 libopencv-4.7.0_1
+libopencv_saliency.so.407 libopencv-4.7.0_1
+libopencv_structured_light.so.407 libopencv-4.7.0_1
+libopencv_aruco.so.407 libopencv-4.7.0_1
+libopencv_bgsegm.so.407 libopencv-4.7.0_1
+libopencv_bioinspired.so.407 libopencv-4.7.0_1
+libopencv_ccalib.so.407 libopencv-4.7.0_1
+libopencv_face.so.407 libopencv-4.7.0_1
+libopencv_tracking.so.407 libopencv-4.7.0_1
+libopencv_xfeatures2d.so.407 libopencv-4.7.0_1
+libopencv_optflow.so.407 libopencv-4.7.0_1
+libopencv_ximgproc.so.407 libopencv-4.7.0_1
+libopencv_plot.so.407 libopencv-4.7.0_1
+libopencv_text.so.407 libopencv-4.7.0_1
+libopencv_ml.so.407 libopencv-4.7.0_1
+libopencv_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn.so.407 libopencv-4.7.0_1
+libopencv_shape.so.407 libopencv-4.7.0_1
+libopencv_stitching.so.407 libopencv-4.7.0_1
+libopencv_photo.so.407 libopencv-4.7.0_1
+libopencv_video.so.407 libopencv-4.7.0_1
+libopencv_calib3d.so.407 libopencv-4.7.0_1
+libopencv_features2d.so.407 libopencv-4.7.0_1
+libopencv_flann.so.407 libopencv-4.7.0_1
+libopencv_highgui.so.407 libopencv-4.7.0_1
+libopencv_videoio.so.407 libopencv-4.7.0_1
+libopencv_imgcodecs.so.407 libopencv-4.7.0_1
+libopencv_imgproc.so.407 libopencv-4.7.0_1
+libopencv_core.so.407 libopencv-4.7.0_1
+libopencv_superres.so.407 libopencv-4.7.0_1
+libopencv_videostab.so.407 libopencv-4.7.0_1
+libopencv_gapi.so.407 libopencv-4.7.0_1
+libopencv_xobjdetect.so.407 libopencv-4.7.0_1
+libopencv_datasets.so.407 libopencv-4.7.0_1
+libopencv_dnn_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn_superres.so.407 libopencv-4.7.0_1
+libopencv_dpm.so.407 libopencv-4.7.0_1
+libopencv_phase_unwrapping.so.407 libopencv-4.7.0_1
+libopencv_stereo.so.407 libopencv-4.7.0_1
+libopencv_rapid.so.407 libopencv-4.7.0_1
+libopencv_intensity_transform.so.407 libopencv-4.7.0_1
+libopencv_alphamat.so.407 libopencv-4.7.0_1
+libopencv_barcode.so.407 libopencv-4.7.0_1
+libopencv_mcc.so.407 libopencv-4.7.0_1
 libuniconf.so.4.6 wvstreams-4.6.1_20
 libwvbase.so.4.6 wvstreams-4.6.1_20
 libwvutils.so.4.6 wvstreams-4.6.1_20
diff --git a/srcpkgs/opencv/template b/srcpkgs/opencv/template
index aea4bfc3a265c..ce94de9424d18 100644
--- a/srcpkgs/opencv/template
+++ b/srcpkgs/opencv/template
@@ -1,7 +1,7 @@
 # Template file for 'opencv'
 pkgname=opencv
-version=4.6.0
-revision=6
+version=4.7.0
+revision=1
 create_wrksrc=yes
 build_wrksrc=${pkgname}-${version}
 build_style=cmake
@@ -24,8 +24,8 @@ homepage="https://opencv.org"
 changelog="https://github.com/opencv/opencv/wiki/ChangeLog"
 distfiles="https://github.com/opencv/opencv/archive/${version}.tar.gz
  https://github.com/opencv/opencv_contrib/archive/${version}.tar.gz>contrib.tar.gz"
-checksum="1ec1cba65f9f20fe5a41fda1586e01c70ea0c9a6d7b67c9e13edf0cfe2239277
- 1777d5fd2b59029cf537e5fd6f8aa68d707075822f90bde683fcde086f85f7a7"
+checksum="8df0079cdbe179748a18d44731af62a245a45ebf5085223dc03133954c662973
+ 42df840cf9055e59d0e22c249cfb19f04743e1bdad113d31b1573d3934d62584"
 patch_args="-Np1 -d ${build_wrksrc}"
 # tests hang indenfinitely, even with test data included
 make_check=no

From e9bbfb34c5f9c052bf076d98c70411bfc884122c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 006/113] actiona: revbump for opencv-4.7.0

---
 srcpkgs/actiona/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/actiona/template b/srcpkgs/actiona/template
index cf5f0b7a2ae61..0d899311e6df7 100644
--- a/srcpkgs/actiona/template
+++ b/srcpkgs/actiona/template
@@ -1,7 +1,7 @@
 # Template file for 'actiona'
 pkgname=actiona
 version=3.10.1
-revision=2
+revision=3
 build_style=qmake
 configure_args="PKGCONFIG_OPENCV=opencv4"
 hostmakedepends="pkg-config qt5-plugin-mysql qt5-qmake qt5-host-tools"

From 153e8ffd758e1d2bf5b4b9b5b5c3b4a84a61b1ff Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 007/113] retroshare: revbump for opencv-4.7.0

---
 srcpkgs/retroshare/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroshare/template b/srcpkgs/retroshare/template
index bb17569277a7f..49e2c1cbe8a53 100644
--- a/srcpkgs/retroshare/template
+++ b/srcpkgs/retroshare/template
@@ -1,7 +1,7 @@
 # Template file for 'retroshare'
 pkgname=retroshare
 version=0.6.6
-revision=3
+revision=4
 build_style=qmake
 #XXX broadcast feature requires an ancient udp-discovery-cpp which either needs
 # to be fetched+patched (FTBFS) here or packaged :/

From 360f392dab24f2b478437eaa267beb57cfa6fd2b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 008/113] waifu2x-converter-cpp: revbump for opencv-4.7.0

---
 srcpkgs/waifu2x-converter-cpp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waifu2x-converter-cpp/template b/srcpkgs/waifu2x-converter-cpp/template
index 361b8a23b9497..c5ac17eb54ea4 100644
--- a/srcpkgs/waifu2x-converter-cpp/template
+++ b/srcpkgs/waifu2x-converter-cpp/template
@@ -1,7 +1,7 @@
 # Template file for 'waifu2x-converter-cpp'
 pkgname=waifu2x-converter-cpp
 version=5.2.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DINSTALL_MODELS=ON"
 hostmakedepends="pkg-config"

From ebc4e576ffcb3fd0ea2860a7ada26449eafdc6a5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:38 -0400
Subject: [PATCH 009/113] vlc: revbump for ffmpeg4

---
 srcpkgs/vlc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/vlc/template b/srcpkgs/vlc/template
index bdd0cc414dc1a..7d245a7b0019c 100644
--- a/srcpkgs/vlc/template
+++ b/srcpkgs/vlc/template
@@ -1,7 +1,7 @@
 # Template file for 'vlc'
 pkgname=vlc
 version=3.0.20
-revision=3
+revision=4
 build_style=gnu-configure
 configure_args="--disable-gme --disable-libtar --enable-jack
  --enable-live555 --disable-fluidsynth --enable-dvdread
@@ -25,7 +25,7 @@ lib32disabled=yes
 hostmakedepends="automake libtool pkg-config flex gettext libgcrypt-devel
  live555-devel gettext-devel $(vopt_if lua lua52) $(vopt_if chromecast protobuf)"
 makedepends="
- avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg-devel freefont-ttf
+ avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg4-devel freefont-ttf
  gnutls-devel jack-devel liba52-devel libass-devel libbluray-devel
  libcdio-devel libdca-devel libdvbpsi-devel libdvdnav-devel libmad-devel
  libmatroska-devel libmodplug-devel libmpcdec-devel libmpeg2-devel

From 72db5b3bb337723ee320177f76a8c88ff226232d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:55 -0400
Subject: [PATCH 010/113] osg: revbump for ffmpeg4

---
 srcpkgs/osg/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/osg/template b/srcpkgs/osg/template
index a9ebbd287933b..a131ceaf7a867 100644
--- a/srcpkgs/osg/template
+++ b/srcpkgs/osg/template
@@ -1,14 +1,14 @@
 # Template file for 'osg'
 pkgname=osg
 version=3.6.5
-revision=2
+revision=3
 build_style=cmake
 build_helper="qemu"
 # don't use /usr/lib64 on 64bit platforms
 configure_args="-DLIB_POSTFIX="
 hostmakedepends="pkg-config xrandr"
 makedepends="MesaLib-devel gtkglext-devel libcurl-devel giflib-devel librsvg-devel
- jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg-devel xine-lib-devel
+ jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg4-devel xine-lib-devel
  SDL2-devel gst-plugins-base1-devel
  $(vopt_if openexr libopenexr-devel)
  $(vopt_if poppler poppler-glib-devel)

From a9a23d96ce2653c4071563bf2b990d29314cf2b7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:13 -0400
Subject: [PATCH 011/113] xine-lib: revbump for ffmpeg4

---
 srcpkgs/xine-lib/template | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/xine-lib/template b/srcpkgs/xine-lib/template
index 3be4d08eac77a..ed6194c17d11e 100644
--- a/srcpkgs/xine-lib/template
+++ b/srcpkgs/xine-lib/template
@@ -1,14 +1,14 @@
 # Template file for 'xine-lib'
 pkgname=xine-lib
-version=1.2.12
-revision=3
+version=1.2.13
+revision=1
 build_style=gnu-configure
 configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
  --disable-oss"
 hostmakedepends="automake gettext-devel libtool pkg-config perl"
 makedepends="
  zlib-devel alsa-lib-devel libxcb-devel libSM-devel libXext-devel libXv-devel
- libXvMC-devel liba52-devel libmad-devel ffmpeg-devel pulseaudio-devel
+ libXvMC-devel liba52-devel libmad-devel ffmpeg4-devel pulseaudio-devel
  jack-devel samba-devel libflac-devel libmodplug-devel libmpcdec-devel
  speex-devel libtheora-devel libvorbis-devel libdca-devel faad2-devel
  libcdio-devel libbluray-devel aalib-devel libcaca-devel libXinerama-devel
@@ -19,7 +19,7 @@ license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="http://www.xine-project.org"
 changelog="https://sourceforge.net/projects/xine/files/xine-lib/${version}/README.txt/view"
 distfiles="${SOURCEFORGE_SITE}/xine/${pkgname}-${version}.tar.xz"
-checksum=d606270468e1540c2a89c0d7f5fdf11e17ecc0c2698cc0bcb1065ff26abee098
+checksum=5f10d6d718a4a51c17ed1b32b031d4f9b80b061e8276535b2be31e5ac4b75e6f
 
 case "$XBPS_TARGET_MACHINE" in
 	i686-musl)

From a274e0c032182d62783573a221ede3fccc03f99b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 012/113] attract: revbump for ffmpeg4

---
 srcpkgs/attract/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/attract/template b/srcpkgs/attract/template
index 24017d2bacc24..0edc2a16a2e61 100644
--- a/srcpkgs/attract/template
+++ b/srcpkgs/attract/template
@@ -1,12 +1,12 @@
 # Template file for 'attract'
 pkgname=attract
 version=2.6.2
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="VERBOSE=1"
 make_use_env=yes
 hostmakedepends="pkg-config"
-makedepends="SFML-devel ffmpeg-devel fontconfig-devel glu-devel libarchive-devel
+makedepends="SFML-devel ffmpeg4-devel fontconfig-devel glu-devel libarchive-devel
  libcurl-devel libjpeg-turbo-devel xine-lib rapidjson libXrandr-devel"
 depends="git"
 short_desc="Attract-Mode is a graphical frontend for emulators"

From 95ee024965cc24a231bb430ba1bf6ae5e78e5752 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 013/113] aubio: revbump for ffmpeg6

---
 srcpkgs/aubio/patches/ffmpeg5.patch | 25 +++++++++++++++++++++++++
 srcpkgs/aubio/template              |  2 +-
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/aubio/patches/ffmpeg5.patch

diff --git a/srcpkgs/aubio/patches/ffmpeg5.patch b/srcpkgs/aubio/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..aace41a6e6d9a
--- /dev/null
+++ b/srcpkgs/aubio/patches/ffmpeg5.patch
@@ -0,0 +1,25 @@
+From 8a05420e5dd8c7b8b2447f82dc919765876511b3 Mon Sep 17 00:00:00 2001
+From: Paul Brossier <piem@piem.org>
+Date: Tue, 25 Jan 2022 18:30:27 +0100
+Subject: [PATCH] [source_avcodec] define FF_API_LAVF_AVCTX for libavcodec >
+ 59, thx @berolinux (closes gh-353)
+
+---
+ src/io/source_avcodec.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/io/source_avcodec.c b/src/io/source_avcodec.c
+index e0ae93b5..1421bd9a 100644
+--- a/src/io/source_avcodec.c
++++ b/src/io/source_avcodec.c
+@@ -68,6 +68,10 @@
+ #define AUBIO_AVCODEC_MAX_BUFFER_SIZE AV_INPUT_BUFFER_MIN_SIZE
+ #endif
+ 
++#if LIBAVCODEC_VERSION_MAJOR >= 59
++#define FF_API_LAVF_AVCTX 1
++#endif
++
+ struct _aubio_source_avcodec_t {
+   uint_t hop_size;
+   uint_t samplerate;
diff --git a/srcpkgs/aubio/template b/srcpkgs/aubio/template
index ad1c4b2569917..7d875cc02541a 100644
--- a/srcpkgs/aubio/template
+++ b/srcpkgs/aubio/template
@@ -1,7 +1,7 @@
 # Template file for 'aubio'
 pkgname=aubio
 version=0.4.9
-revision=1
+revision=2
 build_style=waf3
 # XXX lash, pure and swig support.
 hostmakedepends="pkg-config txt2man"

From 79a26422f68492780f1170f36457127b9840d730 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 014/113] audacious-plugins: revbump for ffmpeg6

---
 .../audacious-plugins/patches/ffmpeg5.patch   | 43 +++++++++++++++++++
 srcpkgs/audacious-plugins/template            |  2 +-
 2 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/audacious-plugins/patches/ffmpeg5.patch

diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg5.patch b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..4e5e34099d71c
--- /dev/null
+++ b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
@@ -0,0 +1,43 @@
+commit 298aa371c56c2f52c25a33d9bdec4918b11cebdc
+Author: tibequadorian <tibequadorian@posteo.de>
+Date:   Sat Mar 19 18:40:12 2022 +0100
+
+    audacious-plugins: rebuild against ffmpeg-5.0
+
+diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+new file mode 100644
+index 0000000000..617c11215b
+--- /dev/null
++++ b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+@@ -0,0 +1,31 @@
++From f60beb400eeb1e4778bbfd738bc4a4ccef3de539 Mon Sep 17 00:00:00 2001
++From: John Lindgren <john@jlindgren.net>
++Date: Sat, 5 Mar 2022 12:05:34 -0500
++Subject: [PATCH] Fix build with FFmpeg 5.0
++
++---
++ src/ffaudio/ffaudio-core.cc | 4 ++--
++ 1 file changed, 2 insertions(+), 2 deletions(-)
++
++diff --git a/src/ffaudio/ffaudio-core.cc b/src/ffaudio/ffaudio-core.cc
++index 16dc63e3a..a2b95fd6c 100644
++--- a/src/ffaudio/ffaudio-core.cc
+++++ b/src/ffaudio/ffaudio-core.cc
++@@ -274,7 +274,7 @@ static AVInputFormat * get_format_by_content (const char * name, VFSFile & file)
++         AVProbeData d = {name, buf, filled};
++         score = target;
++ 
++-        f = av_probe_input_format2 (& d, true, & score);
+++        f = (AVInputFormat *) av_probe_input_format2 (& d, true, & score);
++         if (f)
++             break;
++ 
++@@ -347,7 +347,7 @@ static bool find_codec (AVFormatContext * c, CodecInfo * cinfo)
++ #endif
++         if (stream && stream->codecpar && stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
++         {
++-            AVCodec * codec = avcodec_find_decoder (stream->codecpar->codec_id);
+++            AVCodec * codec = (AVCodec *) avcodec_find_decoder (stream->codecpar->codec_id);
++ 
++             if (codec)
++             {
diff --git a/srcpkgs/audacious-plugins/template b/srcpkgs/audacious-plugins/template
index 05e53a9adf78f..4b1968e03de78 100644
--- a/srcpkgs/audacious-plugins/template
+++ b/srcpkgs/audacious-plugins/template
@@ -2,7 +2,7 @@
 #Keep in sync with audacious!
 pkgname=audacious-plugins
 version=4.3.1
-revision=3
+revision=4
 build_style=meson
 configure_args="$(vopt_bool gtk3 gtk) $(vopt_bool gtk3)
  $(vopt_bool qt) $(vopt_bool qt qt6)"

From 314569394aa63f4358c71bd7980cd12e4be04f97 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 015/113] audacity: revbump for ffmpeg6

---
 srcpkgs/audacity/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/audacity/template b/srcpkgs/audacity/template
index 7b838119ab261..84b49305edcef 100644
--- a/srcpkgs/audacity/template
+++ b/srcpkgs/audacity/template
@@ -1,7 +1,7 @@
 # Template file for 'audacity'
 pkgname=audacity
 version=3.4.2
-revision=1
+revision=2
 build_style=cmake
 build_helper="cmake-wxWidgets-gtk3 qemu"
 configure_args="-Daudacity_use_ffmpeg=loaded -Daudacity_lib_preference=system

From c6b346fcdaaebfb119f41e88210203bd6b163a2c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 016/113] avidemux: revbump for ffmpeg6

---
 srcpkgs/avidemux/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/avidemux/template b/srcpkgs/avidemux/template
index 253a0243e2259..557285982d2b8 100644
--- a/srcpkgs/avidemux/template
+++ b/srcpkgs/avidemux/template
@@ -1,7 +1,7 @@
 # Template file for 'avidemux'
 pkgname=avidemux
 version=2.8.0
-revision=2
+revision=3
 # Can't be compiled for aarch64, arm* or mips*
 archs="x86_64* i686*"
 hostmakedepends="cmake pkg-config qt5-host-tools qt5-devel tar yasm"

From 30fda1b1ff8a1470f2f52fb32974a4292e64fda7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 017/113] blender: revbump for ffmpeg6

---
 srcpkgs/blender/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index 1dc61ec9d29d8..e238717ac8c72 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -1,7 +1,7 @@
 # Template file for 'blender'
 pkgname=blender
 version=4.0.2
-revision=1
+revision=2
 archs="x86_64* ppc64*"
 build_style="cmake"
 pycompile_dirs="usr/share/blender/${version%.*}/scripts"
@@ -9,8 +9,8 @@ configure_args="-DWITH_INSTALL_PORTABLE=OFF -DWITH_PYTHON_INSTALL=OFF
  -DWITH_JACK=ON -DWITH_CODEC_FFMPEG=ON -DWITH_CODEC_SNDFILE=ON -DWITH_OPENMP=ON
  -DWITH_FFTW3=ON -DWITH_MOD_OCEANSIM=ON -DWITH_CYCLES_EMBREE=OFF -DWITH_OPENCOLORIO=ON
  -DWITH_IMAGE_OPENEXR=ON -DWITH_IMAGE_OPENJPEG=ON -DWITH_OPENSUBDIV=ON
- -DWITH_OPENCOLLADA=ON -DWITH_SYSTEM_GLEW=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
- -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_LIBDECOR=ON
+ -DWITH_OPENCOLLADA=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
+ -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_WAYLAND_LIBDECOR=ON
  -DWITH_BUILDINFO=OFF -DPYTHON_VERSION=${py3_ver} -DPYTHON_LIBPATH=/usr/lib
  -DPYTHON_LIBRARY=python${py3_ver}${py3_abiver} -DPYTHON_INCLUDE_DIRS=/${py3_inc}
  -DWITH_SYSTEM_LZO=ON -DWITH_SYSTEM_EIGEN3=ON -DWITH_SYSTEM_FREETYPE=ON"

From 8b32fa7bc0c609e01fb497261cc8e52eaf06e605 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 018/113] cantata: revbump for ffmpeg6

---
 srcpkgs/cantata/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cantata/template b/srcpkgs/cantata/template
index 4b417d80d5c2d..8a90aaa4c07a2 100644
--- a/srcpkgs/cantata/template
+++ b/srcpkgs/cantata/template
@@ -1,7 +1,7 @@
 # Template file for 'cantata'
 pkgname=cantata
 version=2.5.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools qt5-tools"
 makedepends="qt5-devel qt5-tools-devel qt5-svg-devel qt5-xmlpatterns-devel

From 2833ad816cd9e59237481acd99ff1c372b618b6a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 019/113] ccextractor: revbump for ffmpeg4

---
 srcpkgs/ccextractor/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/ccextractor/template b/srcpkgs/ccextractor/template
index 84059ffd02398..28239189a6e3c 100644
--- a/srcpkgs/ccextractor/template
+++ b/srcpkgs/ccextractor/template
@@ -1,12 +1,12 @@
 # Template file for 'ccextractor'
 pkgname=ccextractor
 version=0.93
-revision=2
+revision=3
 build_wrksrc="linux"
 build_style=gnu-configure
 configure_args="--enable-ocr --enable-hardsubx"
 hostmakedepends="automake pkg-config"
-makedepends="leptonica-devel tesseract-ocr-devel ffmpeg-devel"
+makedepends="leptonica-devel tesseract-ocr-devel ffmpeg4-devel"
 short_desc="Extract subtitles from video streams"
 maintainer="newbluemoon <blaumolch@mailbox.org>"
 license="GPL-2.0-or-later"

From bb086f481a4d9445ee49f5edb1dd810638bfedab Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 020/113] chromaprint: revbump for ffmpeg6

---
 srcpkgs/chromaprint/patches/ffmpeg5.patch | 569 ++++++++++++++++++++++
 srcpkgs/chromaprint/template              |   2 +-
 2 files changed, 570 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromaprint/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromaprint/patches/ffmpeg5.patch b/srcpkgs/chromaprint/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..a9fd307a23c8a
--- /dev/null
+++ b/srcpkgs/chromaprint/patches/ffmpeg5.patch
@@ -0,0 +1,569 @@
+From 8ccad6937177b1b92e40ab8f4447ea27bac009a7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= <lalinsky@gmail.com>
+Date: Fri, 4 Nov 2022 21:47:38 +0100
+Subject: [PATCH] Use FFmpeg 5.x (#120)
+
+* Use FFmpeg 5.1.2 for CI builds
+
+* Build on Ubuntu 20.04
+
+* Upgrade code to FFmpeg 5.x APIs
+
+* Only set FFmpeg include dirs if building tools
+
+* No longer needed
+
+* Use ubuntu 20.04
+---
+ .github/workflows/build.yml                   |   6 +-
+ CMakeLists.txt                                |  16 --
+ package/build.sh                              |   4 +-
+ src/audio/ffmpeg_audio_processor.h            |   2 -
+ src/audio/ffmpeg_audio_processor_avresample.h |  72 -------
+ src/audio/ffmpeg_audio_processor_swresample.h |  18 +-
+ src/audio/ffmpeg_audio_reader.h               | 197 +++++++++---------
+ tests/CMakeLists.txt                          |   6 +
+ 8 files changed, 122 insertions(+), 199 deletions(-)
+ delete mode 100644 src/audio/ffmpeg_audio_processor_avresample.h
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index f8d6a32..4da2405 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -84,9 +84,6 @@ find_package(FFmpeg)
+ if(FFMPEG_LIBRARIES)
+ 	cmake_push_check_state(RESET)
+ 	set(CMAKE_REQUIRED_LIBRARIES ${FFMPEG_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -lm)
+-	check_function_exists(av_packet_unref HAVE_AV_PACKET_UNREF)
+-	check_function_exists(av_frame_alloc HAVE_AV_FRAME_ALLOC)
+-	check_function_exists(av_frame_free HAVE_AV_FRAME_FREE)
+ 	cmake_pop_check_state()
+ endif()
+
+@@ -163,14 +160,11 @@ message(STATUS "Using ${FFT_LIB} for FFT calculations")
+ if(NOT AUDIO_PROCESSOR_LIB)
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+ 		set(AUDIO_PROCESSOR_LIB "swresample")
+-	elseif(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(AUDIO_PROCESSOR_LIB "avresample")
+ 	endif()
+ endif()
+
+ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE OFF)
+ 		set(USE_SWRESAMPLE ON)
+ 		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBSWRESAMPLE_LIBRARIES})
+ 		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBSWRESAMPLE_INCLUDE_DIRS})
+@@ -178,16 +172,6 @@ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+ 	endif()
+ 	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+-elseif(AUDIO_PROCESSOR_LIB STREQUAL "avresample")
+-	if(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE ON)
+-		set(USE_SWRESAMPLE OFF)
+-		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBAVRESAMPLE_LIBRARIES})
+-		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBAVRESAMPLE_INCLUDE_DIRS})
+-	else()
+-		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+-	endif()
+-	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+ else()
+ 	message(STATUS "Building without audio conversion support, please install FFmpeg with libswresample")
+ endif()
+diff --git a/package/build.sh b/package/build.sh
+index da631ae..b41d36e 100755
+--- a/package/build.sh
++++ b/package/build.sh
+@@ -7,8 +7,8 @@ set -eux
+
+ BASE_DIR=$(cd $(dirname $0)/.. && pwd)
+
+-FFMPEG_VERSION=4.4.1
+-FFMPEG_BUILD_TAG=v4.4.1-1
++FFMPEG_VERSION=5.1.2
++FFMPEG_BUILD_TAG=v${FFMPEG_VERSION}-1
+
+ TMP_BUILD_DIR=$BASE_DIR/$(mktemp -d build.XXXXXXXX)
+ trap 'rm -rf $TMP_BUILD_DIR' EXIT
+diff --git a/src/audio/ffmpeg_audio_processor.h b/src/audio/ffmpeg_audio_processor.h
+index 7628fc7..39f4f6d 100644
+--- a/src/audio/ffmpeg_audio_processor.h
++++ b/src/audio/ffmpeg_audio_processor.h
+@@ -10,8 +10,6 @@
+
+ #if defined(USE_SWRESAMPLE)
+ #include "audio/ffmpeg_audio_processor_swresample.h"
+-#elif defined(USE_AVRESAMPLE)
+-#include "audio/ffmpeg_audio_processor_avresample.h"
+ #else
+ #error "no audio processing library"
+ #endif
+diff --git a/src/audio/ffmpeg_audio_processor_avresample.h b/src/audio/ffmpeg_audio_processor_avresample.h
+deleted file mode 100644
+index bd85f92..0000000
+--- a/src/audio/ffmpeg_audio_processor_avresample.h
++++ /dev/null
+@@ -1,72 +0,0 @@
+-// Copyright (C) 2016  Lukas Lalinsky
+-// Distributed under the MIT license, see the LICENSE file for details.
+-
+-#ifndef CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-#define CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-
+-extern "C" {
+-#include <libavresample/avresample.h>
+-}
+-
+-namespace chromaprint {
+-
+-class FFmpegAudioProcessor {
+-public:
+-	FFmpegAudioProcessor() {
+-		m_resample_ctx = avresample_alloc_context();
+-	}
+-
+-	~FFmpegAudioProcessor() {
+-		avresample_free(&m_resample_ctx);
+-	}
+-
+-	void SetCompatibleMode() {
+-		av_opt_set_int(m_resample_ctx, "filter_size", 16, 0);
+-		av_opt_set_int(m_resample_ctx, "phase_shift", 8, 0);
+-		av_opt_set_int(m_resample_ctx, "linear_interp", 1, 0);
+-		av_opt_set_double(m_resample_ctx, "cutoff", 0.8, 0);
+-	}
+-
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "in_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_rate", sample_rate, 0);
+-	}
+-
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "out_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_rate, 0);
+-	}
+-
+-	int Init() {
+-		return avresample_open(m_resample_ctx);
+-	}
+-
+-	int Convert(uint8_t **out, int out_count, const uint8_t **in, int in_count) {
+-		return avresample_convert(m_resample_ctx, out, 0, out_count, (uint8_t **) in, 0, in_count);
+-	}
+-
+-	int Flush(uint8_t **out, int out_count) {
+-		return avresample_read(m_resample_ctx, out, out_count);
+-	}
+-
+-private:
+-	AVAudioResampleContext *m_resample_ctx = nullptr;
+-};
+-
+-}; // namespace chromaprint
+-
+-#endif
+diff --git a/src/audio/ffmpeg_audio_processor_swresample.h b/src/audio/ffmpeg_audio_processor_swresample.h
+index b86266b..b1d4bea 100644
+--- a/src/audio/ffmpeg_audio_processor_swresample.h
++++ b/src/audio/ffmpeg_audio_processor_swresample.h
+@@ -28,30 +28,28 @@ public:
+ 		av_opt_set_double(m_swr_ctx, "cutoff", 0.8, 0);
+ 	}
+
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "icl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "ich", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetInputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "in_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "isf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "in_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "isr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "in_sample_rate", sample_rate, 0);
+ 	}
+
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "ocl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "och", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetOutputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "out_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "osf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "out_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "osr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "out_sample_rate", sample_rate, 0);
+ 	}
+
+ 	int Init() {
+diff --git a/src/audio/ffmpeg_audio_reader.h b/src/audio/ffmpeg_audio_reader.h
+index 5550164..1c6b346 100644
+--- a/src/audio/ffmpeg_audio_reader.h
++++ b/src/audio/ffmpeg_audio_reader.h
+@@ -62,7 +62,7 @@ public:
+ 	bool Read(const int16_t **data, size_t *size);
+
+ 	bool IsOpen() const { return m_opened; }
+-	bool IsFinished() const { return m_finished && !m_got_frame; }
++	bool IsFinished() const { return !m_has_more_packets && !m_has_more_frames; }
+
+ 	std::string GetError() const { return m_error; }
+ 	int GetErrorCode() const { return m_error_code; }
+@@ -74,20 +74,19 @@ private:
+ 	uint8_t *m_convert_buffer[1] = { nullptr };
+ 	int m_convert_buffer_nb_samples = 0;
+
+-	AVInputFormat *m_input_fmt = nullptr;
++	const AVInputFormat *m_input_fmt = nullptr;
+ 	AVDictionary *m_input_opts = nullptr;
+
+ 	AVFormatContext *m_format_ctx = nullptr;
+ 	AVCodecContext *m_codec_ctx = nullptr;
+-	AVFrame *m_frame = nullptr;
+ 	int m_stream_index = -1;
+ 	std::string m_error;
+ 	int m_error_code = 0;
+-	bool m_finished = false;
+ 	bool m_opened = false;
+-	int m_got_frame = 0;
+-	AVPacket m_packet;
+-	AVPacket m_packet0;
++	bool m_has_more_packets = true;
++	bool m_has_more_frames = true;
++	AVPacket *m_packet = nullptr;
++	AVFrame *m_frame = nullptr;
+
+ 	int m_output_sample_rate = 0;
+ 	int m_output_channels = 0;
+@@ -98,19 +97,12 @@ private:
+
+ inline FFmpegAudioReader::FFmpegAudioReader() {
+ 	av_log_set_level(AV_LOG_QUIET);
+-
+-	av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
+ }
+
+ inline FFmpegAudioReader::~FFmpegAudioReader() {
+ 	Close();
+ 	av_dict_free(&m_input_opts);
+ 	av_freep(&m_convert_buffer[0]);
+-	av_packet_unref(&m_packet0);
+ }
+
+ inline bool FFmpegAudioReader::SetInputFormat(const char *name) {
+@@ -135,11 +127,10 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ 	Close();
+
+-    av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
++	m_packet = av_packet_alloc();
++	if (!m_packet) {
++		return false;
++	}
+
+ 	ret = avformat_open_input(&m_format_ctx, file_name.c_str(), m_input_fmt, &m_input_opts);
+ 	if (ret < 0) {
+@@ -153,26 +144,31 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		return false;
+ 	}
+
+-	AVCodec *codec;
++	const AVCodec *codec;
+ 	ret = av_find_best_stream(m_format_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &codec, 0);
+ 	if (ret < 0) {
+ 		SetError("Could not find any audio stream in the file", ret);
+ 		return false;
+ 	}
+ 	m_stream_index = ret;
++	auto stream = m_format_ctx->streams[m_stream_index];
+
+-	m_codec_ctx = m_format_ctx->streams[m_stream_index]->codec;
++	m_codec_ctx = avcodec_alloc_context3(codec);
+ 	m_codec_ctx->request_sample_fmt = AV_SAMPLE_FMT_S16;
+
++	ret = avcodec_parameters_to_context(m_codec_ctx, stream->codecpar);
++	if (ret < 0) {
++		SetError("Could not copy the stream parameters", ret);
++		return false;
++	}
++
+ 	ret = avcodec_open2(m_codec_ctx, codec, nullptr);
+ 	if (ret < 0) {
+ 		SetError("Could not open the codec", ret);
+ 		return false;
+ 	}
+
+-	if (!m_codec_ctx->channel_layout) {
+-		m_codec_ctx->channel_layout = av_get_default_channel_layout(m_codec_ctx->channels);
+-	}
++	av_dump_format(m_format_ctx, 0, "foo", 0);
+
+ 	m_frame = av_frame_alloc();
+ 	if (!m_frame) {
+@@ -183,19 +179,23 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		m_output_sample_rate = m_codec_ctx->sample_rate;
+ 	}
+
+-	if (!m_output_channels) {
+-		m_output_channels = m_codec_ctx->channels;
++	AVChannelLayout output_channel_layout;
++	if (m_output_channels) {
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
++	} else {
++		m_output_channels = m_codec_ctx->ch_layout.nb_channels;
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
+ 	}
+
+-	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
++	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->ch_layout.nb_channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
+ 		m_converter.reset(new FFmpegAudioProcessor());
+ 		m_converter->SetCompatibleMode();
+ 		m_converter->SetInputSampleFormat(m_codec_ctx->sample_fmt);
+ 		m_converter->SetInputSampleRate(m_codec_ctx->sample_rate);
+-		m_converter->SetInputChannelLayout(m_codec_ctx->channel_layout);
++		m_converter->SetInputChannelLayout(&(m_codec_ctx->ch_layout));
+ 		m_converter->SetOutputSampleFormat(AV_SAMPLE_FMT_S16);
+ 		m_converter->SetOutputSampleRate(m_output_sample_rate);
+-		m_converter->SetOutputChannelLayout(av_get_default_channel_layout(m_output_channels));
++		m_converter->SetOutputChannelLayout(&output_channel_layout);
+ 		auto ret = m_converter->Init();
+ 		if (ret != 0) {
+ 			SetError("Could not create an audio converter instance", ret);
+@@ -203,10 +203,11 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		}
+ 	}
+
++	av_channel_layout_uninit(&output_channel_layout);
++
+ 	m_opened = true;
+-	m_finished = false;
+-	m_got_frame = 0;
+-	m_nb_packets = 0;
++	m_has_more_packets = true;
++	m_has_more_frames = true;
+ 	m_decode_error = 0;
+
+ 	return true;
+@@ -214,6 +215,7 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ inline void FFmpegAudioReader::Close() {
+ 	av_frame_free(&m_frame);
++	av_packet_free(&m_packet);
+
+ 	m_stream_index = -1;
+
+@@ -252,91 +254,98 @@ inline bool FFmpegAudioReader::Read(const int16_t **data, size_t *size) {
+ 		return false;
+ 	}
+
++	*data = nullptr;
++	*size = 0;
++
+ 	int ret;
++	bool needs_packet = false;
+ 	while (true) {
+-		while (m_packet.size <= 0) {
+-			av_packet_unref(&m_packet0);
+-			av_init_packet(&m_packet);
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			ret = av_read_frame(m_format_ctx, &m_packet);
++		while (needs_packet && m_packet->size == 0) {
++			ret = av_read_frame(m_format_ctx, m_packet);
+ 			if (ret < 0) {
+ 				if (ret == AVERROR_EOF) {
+-					m_finished = true;
++					needs_packet = false;
++					m_has_more_packets = false;
+ 					break;
+-				} else {
++				}
++				SetError("Error reading from the audio source", ret);
++				return false;
++			}
++			if (m_packet->stream_index == m_stream_index) {
++				needs_packet = false;
++			} else {
++				av_packet_unref(m_packet);
++			}
++		}
++
++		if (m_packet->size != 0) {
++			ret = avcodec_send_packet(m_codec_ctx, m_packet);
++			if (ret < 0) {
++				if (ret != AVERROR(EAGAIN)) {
+ 					SetError("Error reading from the audio source", ret);
+ 					return false;
+ 				}
+-			}
+-			m_packet0 = m_packet;
+-			if (m_packet.stream_index != m_stream_index) {
+-				m_packet.data = nullptr;
+-				m_packet.size = 0;
+ 			} else {
+-				m_nb_packets++;
++				av_packet_unref(m_packet);
+ 			}
+ 		}
+
+-		ret = avcodec_decode_audio4(m_codec_ctx, m_frame, &m_got_frame, &m_packet);
++		ret = avcodec_receive_frame(m_codec_ctx, m_frame);
+ 		if (ret < 0) {
+-			if (m_decode_error) {
+-				SetError("Error decoding audio frame", m_decode_error);
+-				return false;
++			if (ret == AVERROR_EOF) {
++				m_has_more_frames = false;
++			} else if (ret == AVERROR(EAGAIN)) {
++				if (m_has_more_packets) {
++					needs_packet = true;
++					continue;
++				} else {
++					m_has_more_frames = false;
++				}
+ 			}
+-			m_decode_error = ret;
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			continue;
++			SetError("Error decoding the audio source", ret);
++			return false;
+ 		}
+
+-		break;
+-	}
+-
+-	m_decode_error = 0;
+-
+-	const int decoded = std::min(ret, m_packet.size);
+-	m_packet.data += decoded;
+-	m_packet.size -= decoded;
+-
+-	if (m_got_frame) {
+-		if (m_converter) {
+-			if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
+-				int linsize;
+-				av_freep(&m_convert_buffer[0]);
+-				m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
+-				ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
+-				if (ret < 0) {
+-					SetError("Couldn't allocate audio converter buffer", ret);
++		if (m_frame->nb_samples > 0) {
++			if (m_converter) {
++				if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
++					int linsize;
++					av_freep(&m_convert_buffer[0]);
++					m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
++					ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->ch_layout.nb_channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
++					if (ret < 0) {
++						SetError("Couldn't allocate audio converter buffer", ret);
++						return false;
++					}
++				}
++				auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
++				if (nb_samples < 0) {
++					SetError("Couldn't convert audio", ret);
+ 					return false;
+ 				}
+-			}
+-			auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			}
+-			*data = (const int16_t *) m_convert_buffer[0];
+-			*size = nb_samples;
+-		} else {
+-			*data = (const int16_t *) m_frame->data[0];
+-			*size = m_frame->nb_samples;
+-		}
+-	} else {
+-		if (m_finished && m_converter) {
+-			auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			} else if (nb_samples > 0) {
+-				m_got_frame = 1;
+ 				*data = (const int16_t *) m_convert_buffer[0];
+ 				*size = nb_samples;
++			} else {
++				*data = (const int16_t *) m_frame->data[0];
++				*size = m_frame->nb_samples;
++			}
++		} else {
++			if (m_converter) {
++				if (IsFinished()) {
++					auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
++					if (nb_samples < 0) {
++						SetError("Couldn't convert audio", ret);
++						return false;
++					} else if (nb_samples > 0) {
++						*data = (const int16_t *) m_convert_buffer[0];
++						*size = nb_samples;
++					}
++				}
+ 			}
+ 		}
+-	}
+
+-	return true;
++		return true;
++	}
+ }
+
+ inline void FFmpegAudioReader::SetError(const char *message, int errnum) {
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index a2b517b..123e643 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -38,6 +38,12 @@ set(SRCS
+
+ if(BUILD_TOOLS)
+ 	set(SRCS ${SRCS} ../src/audio/ffmpeg_audio_reader_test.cpp)
++    include_directories(
++        ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}
++        ${AUDIO_PROCESSOR_INCLUDE_DIRS}
++    )
+ 	link_libraries(fpcalc_libs)
+ endif()
+
+-- 
+2.38.1
+
+
diff --git a/srcpkgs/chromaprint/template b/srcpkgs/chromaprint/template
index 7ef7838949f3a..1f7bbc70a22c8 100644
--- a/srcpkgs/chromaprint/template
+++ b/srcpkgs/chromaprint/template
@@ -1,7 +1,7 @@
 # Template file for 'chromaprint'
 pkgname=chromaprint
 version=1.5.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DBUILD_TOOLS=ON"
 make_check_target="check"

From 1df3de63f9e1e27934a08ddf489f035dd0733364 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 021/113] chromium: revbump for ffmpeg6

---
 .../patches/chromium-119-ffmpeg-4.4.patch     | 20 --------
 srcpkgs/chromium/patches/ffmpeg5.patch        | 47 +++++++++++++++++++
 srcpkgs/chromium/template                     |  2 +-
 3 files changed, 48 insertions(+), 21 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch
 create mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch b/srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch
deleted file mode 100644
index 04d04b166ba37..0000000000000
--- a/srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch
+++ /dev/null
@@ -1,20 +0,0 @@
---- a/media/filters/ffmpeg_demuxer.cc.orig
-+++ b/media/filters/ffmpeg_demuxer.cc
-@@ -390,7 +390,7 @@
- 
-   scoped_refptr<DecoderBuffer> buffer;
- 
--    size_t side_data_size = 0;
-+    int side_data_size = 0;
-     uint8_t* side_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
- 
-@@ -453,7 +453,7 @@
-                                        packet->size - data_offset);
-     }
- 
--    size_t skip_samples_size = 0;
-+    int skip_samples_size = 0;
-     const uint32_t* skip_samples_ptr =
-         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
-             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..24e2da38e34ca
--- /dev/null
+++ b/srcpkgs/chromium/patches/ffmpeg5.patch
@@ -0,0 +1,47 @@
+--- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
++++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
+@@ -92,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+-  if (stream->start_time != kNoFFmpegTimestamp)
++  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -1597,7 +1585,7 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+@@ -1618,7 +1606,7 @@
+     if (stream->type() != DemuxerStream::VIDEO)
+       continue;
+ 
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+ 
+     if (!stream->IsEnabled())
diff --git a/srcpkgs/chromium/template b/srcpkgs/chromium/template
index 5613fa3813822..cd386c8a84ae6 100644
--- a/srcpkgs/chromium/template
+++ b/srcpkgs/chromium/template
@@ -2,7 +2,7 @@
 pkgname=chromium
 # See https://chromiumdash.appspot.com/releases?platform=Linux for the latest version
 version=120.0.6099.129
-revision=1
+revision=2
 archs="i686* x86_64* aarch64* armv7l*"
 hostmakedepends="
  $(vopt_if clang "clang lld llvm15")

From 3f23c6f537e4c9cbedd282349115c6d1afd1394e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 022/113] cmus: revbump for ffmpeg6

---
 srcpkgs/chromium/patches/ffmpeg5.patch | 47 --------------------------
 srcpkgs/cmus/patches/ffmpeg6.patch     | 12 +++++++
 srcpkgs/cmus/template                  |  2 +-
 3 files changed, 13 insertions(+), 48 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch
 create mode 100644 srcpkgs/cmus/patches/ffmpeg6.patch

diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
deleted file mode 100644
index 24e2da38e34ca..0000000000000
--- a/srcpkgs/chromium/patches/ffmpeg5.patch
+++ /dev/null
@@ -1,47 +0,0 @@
---- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
-+++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
-@@ -92,24 +92,12 @@
- 
- static base::TimeDelta ExtractStartTime(AVStream* stream) {
-   // The default start time is zero.
--  base::TimeDelta start_time;
-+  base::TimeDelta start_time = kNoTimestamp;
- 
-   // First try to use  the |start_time| value as is.
--  if (stream->start_time != kNoFFmpegTimestamp)
-+  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
-     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
- 
--  // Next try to use the first DTS value, for codecs where we know PTS == DTS
--  // (excludes all H26x codecs). The start time must be returned in PTS.
--  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
--      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
--      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
--      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
--    const base::TimeDelta first_pts =
--        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
--    if (first_pts < start_time)
--      start_time = first_pts;
--  }
--
-   return start_time;
- }
- 
-@@ -1597,7 +1585,7 @@
-   for (const auto& stream : streams_) {
-     if (!stream || stream->IsEnabled() != enabled)
-       continue;
--    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
-+    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
-       continue;
-     if (!lowest_start_time_stream ||
-         stream->start_time() < lowest_start_time_stream->start_time()) {
-@@ -1618,7 +1606,7 @@
-     if (stream->type() != DemuxerStream::VIDEO)
-       continue;
- 
--    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
-+    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
-       continue;
- 
-     if (!stream->IsEnabled())
diff --git a/srcpkgs/cmus/patches/ffmpeg6.patch b/srcpkgs/cmus/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..ffa95ab811101
--- /dev/null
+++ b/srcpkgs/cmus/patches/ffmpeg6.patch
@@ -0,0 +1,12 @@
+--- a/ip/ffmpeg.c
++++ b/ip/ffmpeg.c
+@@ -202,9 +202,6 @@ static int ffmpeg_open(struct input_plugin_data *ip_data)
+ 			break;
+ 		}
+ 
+-		if (codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+-			cc->flags |= AV_CODEC_FLAG_TRUNCATED;
+-
+ 		if (avcodec_open2(cc, codec, NULL) < 0) {
+ 			d_print("could not open codec: %d, %s\n", cc->codec_id, avcodec_get_name(cc->codec_id));
+ 			err = -IP_ERROR_UNSUPPORTED_FILE_TYPE;
diff --git a/srcpkgs/cmus/template b/srcpkgs/cmus/template
index 0d1436744f1b2..a6e4b4fa86cb8 100644
--- a/srcpkgs/cmus/template
+++ b/srcpkgs/cmus/template
@@ -1,7 +1,7 @@
 # Template file for 'cmus'
 pkgname=cmus
 version=2.10.0
-revision=3
+revision=4
 build_style=configure
 configure_args="prefix=/usr LD=$CC"
 hostmakedepends="pkg-config"

From 9ea917b4e8167088405502dcfb23631eeff05647 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 023/113] cyanrip: revbump for ffmpeg6

---
 srcpkgs/cyanrip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cyanrip/template b/srcpkgs/cyanrip/template
index 9796e3461601a..5db30e020d17e 100644
--- a/srcpkgs/cyanrip/template
+++ b/srcpkgs/cyanrip/template
@@ -1,7 +1,7 @@
 # Template file for 'cyanrip'
 pkgname=cyanrip
 version=0.9.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config"
 makedepends="ffmpeg-devel libcdio-devel libcdio-paranoia-devel libcurl-devel libmusicbrainz5-devel"

From eb3d45a91e59fc9b71d0c498ddd98d275e4d22e4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 024/113] deadbeef: revbump for ffmpeg4

---
 srcpkgs/deadbeef/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/deadbeef/template b/srcpkgs/deadbeef/template
index f5f4bf24b8cb6..7b47e615cd48e 100644
--- a/srcpkgs/deadbeef/template
+++ b/srcpkgs/deadbeef/template
@@ -1,14 +1,14 @@
 # Template file for 'deadbeef'
 pkgname=deadbeef
 version=1.8.8
-revision=3
+revision=4
 create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-oss --disable-lfm --disable-notify --disable-gtk2"
 hostmakedepends="automake libtool gettext gettext-devel intltool pkg-config
  yasm clang glib-devel"
 makedepends="
- alsa-lib-devel dbus-devel faad2-devel ffmpeg-devel gtk+3-devel imlib2-devel
+ alsa-lib-devel dbus-devel faad2-devel ffmpeg4-devel gtk+3-devel imlib2-devel
  jansson-devel libcddb-devel libcdio-devel libcurl-devel libflac-devel
  libmad-devel libpng-devel libsamplerate-devel libsndfile-devel libvorbis-devel
  libzip-devel mpg123-devel opusfile-devel pulseaudio-devel wavpack-devel"

From b194dd8dc94eb367adaeb2f6a93f2e2159f9922e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 025/113] droidcam-obs-plugin: revbump for ffmpeg6

---
 srcpkgs/droidcam-obs-plugin/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam-obs-plugin/template b/srcpkgs/droidcam-obs-plugin/template
index fc9c9bf6b9d54..fb0480754df4d 100644
--- a/srcpkgs/droidcam-obs-plugin/template
+++ b/srcpkgs/droidcam-obs-plugin/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam-obs-plugin'
 pkgname=droidcam-obs-plugin
 version=2.0.1
-revision=1
+revision=2
 build_style=gnu-makefile
 make_use_env=yes
 make_build_args="ALLOW_STATIC=no"

From 67e42d6f97dcf51fc681b27b86639befc6c28083 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 026/113] droidcam: revbump for ffmpeg6

---
 srcpkgs/droidcam/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam/template b/srcpkgs/droidcam/template
index 1c3f1b8b1fc67..32a9220b79a4d 100644
--- a/srcpkgs/droidcam/template
+++ b/srcpkgs/droidcam/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam'
 pkgname=droidcam
 version=1.8.2
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="USBMUXD=-lusbmuxd-2.0 JPEG=-lturbojpeg"
 hostmakedepends="pkg-config"

From c2ce442cede3c3d322b4012a384660e69bc913b2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 027/113] ffmpegthumbnailer: revbump for ffmpeg6

---
 .../ffmpegthumbnailer/patches/ffmpeg6.patch   | 202 ++++++++++++++++++
 srcpkgs/ffmpegthumbnailer/template            |   6 +-
 2 files changed, 205 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch

diff --git a/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..363ff35a28419
--- /dev/null
+++ b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
@@ -0,0 +1,202 @@
+--- a/libffmpegthumbnailer/moviedecoder.cpp	2017-11-21 14:06:57.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.cpp	2023-05-05 13:14:47.946560668 -0400
+@@ -41,11 +41,6 @@
+ namespace ffmpegthumbnailer
+ {
+ 
+-struct SilenceLogLevel
+-{
+-    SilenceLogLevel() { av_log_set_level(AV_LOG_QUIET); }
+-};
+-
+ MovieDecoder::MovieDecoder(AVFormatContext* pavContext)
+ : m_VideoStream(-1)
+ , m_pFormatContext(pavContext)
+@@ -70,8 +65,6 @@
+ 
+ void MovieDecoder::initialize(const string& filename, bool preferEmbeddedMetadata)
+ {
+-    av_register_all();
+-    avcodec_register_all();
+     avformat_network_init();
+ 
+     string inputFile = filename == "-" ? "pipe:" : filename;
+@@ -97,8 +90,7 @@
+ {
+     if (m_pVideoCodecContext)
+     {
+-        avcodec_close(m_pVideoCodecContext);
+-        m_pVideoCodecContext = nullptr;
++        avcodec_free_context(&m_pVideoCodecContext);
+     }
+ 
+     if ((!m_FormatContextWasGiven) && m_pFormatContext)
+@@ -152,10 +144,10 @@
+     for (unsigned int i = 0; i < m_pFormatContext->nb_streams; ++i)
+     {
+         AVStream *stream = m_pFormatContext->streams[i];
+-        auto ctx = m_pFormatContext->streams[i]->codec;
+-        if (ctx->codec_type == AVMEDIA_TYPE_VIDEO)
++        auto par = m_pFormatContext->streams[i]->codecpar;
++        if (par->codec_type == AVMEDIA_TYPE_VIDEO)
+         {
+-            if (!preferEmbeddedMetadata || !isStillImageCodec(ctx->codec_id))
++            if (!preferEmbeddedMetadata || !isStillImageCodec(par->codec_id))
+             {
+                 videoStreams.push_back(i);
+                 continue;
+@@ -203,8 +195,7 @@
+     }
+ 
+     m_pVideoStream = m_pFormatContext->streams[m_VideoStream];
+-    m_pVideoCodecContext = m_pVideoStream->codec;
+-    m_pVideoCodec = avcodec_find_decoder(m_pVideoCodecContext->codec_id);
++    m_pVideoCodec = avcodec_find_decoder(m_pVideoStream->codecpar->codec_id);
+ 
+     if (m_pVideoCodec == nullptr)
+     {
+@@ -214,6 +205,20 @@
+         throw logic_error("Video Codec not found");
+     }
+ 
++    m_pVideoCodecContext = avcodec_alloc_context3(m_pVideoCodec);
++
++    if (m_pVideoCodecContext == nullptr)
++    {
++        destroy();
++        throw logic_error("Could not allocate video codec context");
++    }
++
++    if (avcodec_parameters_to_context(m_pVideoCodecContext, m_pVideoStream->codecpar) < 0)
++    {
++        destroy();
++        throw logic_error("Could not configure video codec context");
++    }
++
+     m_pVideoCodecContext->workaround_bugs = 1;
+ 
+     if (avcodec_open2(m_pVideoCodecContext, m_pVideoCodec, nullptr) < 0)
+@@ -386,13 +391,6 @@
+ 
+ void MovieDecoder::initializeFilterGraph(const AVRational& timeBase, const std::string& size, bool maintainAspectRatio)
+ {
+-    static const AVPixelFormat pixelFormats[] = { AV_PIX_FMT_RGB24, AV_PIX_FMT_NONE };
+-
+-    auto del = [] (AVBufferSinkParams* p) { av_freep(p); };
+-    std::unique_ptr<AVBufferSinkParams, decltype(del)> buffersinkParams(av_buffersink_params_alloc(), del);
+-
+-    avfilter_register_all();
+-
+     m_pFilterGraph = avfilter_graph_alloc();
+     assert(m_pFilterGraph);
+ 
+@@ -404,10 +402,8 @@
+ 
+     checkRc(avfilter_graph_create_filter(&m_pFilterSource, avfilter_get_by_name("buffer"), "thumb_buffer", ss.str().c_str(), nullptr, m_pFilterGraph),
+             "Failed to create filter source");
+-    buffersinkParams->pixel_fmts = pixelFormats;
+-    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, buffersinkParams.get(), m_pFilterGraph),
++    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, nullptr, m_pFilterGraph),
+             "Failed to create filter sink");
+-    buffersinkParams.release();
+ 
+     AVFilterContext* yadifFilter = nullptr;
+     if (m_pFrame->interlaced_frame != 0)
+@@ -500,15 +496,15 @@
+     }
+ 
+     checkRc(av_seek_frame(m_pFormatContext, -1, timestamp, 0), "Seeking in video failed");
+-    avcodec_flush_buffers(m_pFormatContext->streams[m_VideoStream]->codec);
++    avcodec_flush_buffers(m_pVideoCodecContext);
+ 
+     int keyFrameAttempts = 0;
+-    bool gotFrame = 0;
++    bool gotFrame;
+ 
+     do
+     {
+         int count = 0;
+-        gotFrame = 0;
++        gotFrame = false;
+ 
+         while (!gotFrame && count < 20)
+         {
+@@ -552,17 +548,33 @@
+         return false;
+     }
+ 
+-    av_frame_unref(m_pFrame);
+-
+-    int frameFinished;
++    int rc = avcodec_send_packet(m_pVideoCodecContext, m_pPacket);
++    if(rc == AVERROR(EAGAIN))
++    {
++        rc = 0;
++    }
+ 
+-    int bytesDecoded = avcodec_decode_video2(m_pVideoCodecContext, m_pFrame, &frameFinished, m_pPacket);
+-    if (bytesDecoded < 0)
++    if(rc == AVERROR_EOF)
++    {
++        return false;
++    }
++    else if(rc < 0)
+     {
+-        throw logic_error("Failed to decode video frame: bytesDecoded < 0");
++        throw logic_error("Failed to decode video frame: avcodec_send_packet() < 0");
+     }
+ 
+-    return frameFinished > 0;
++    rc = avcodec_receive_frame(m_pVideoCodecContext, m_pFrame);
++    switch(rc)
++    {
++        case 0:
++            return true;
++
++        case AVERROR(EAGAIN):
++            return false;
++
++        default:
++            throw logic_error("Failed to decode video frame: avcodec_receive_frame() < 0");
++    }
+ }
+ 
+ bool MovieDecoder::getVideoPacket()
+@@ -570,8 +582,6 @@
+     bool framesAvailable = true;
+     bool frameDecoded = false;
+ 
+-    int attempts = 0;
+-
+     if (m_pPacket)
+     {
+         av_packet_unref(m_pPacket);
+@@ -580,6 +590,7 @@
+ 
+     m_pPacket = new AVPacket();
+ 
++
+     while (framesAvailable && !frameDecoded)
+     {
+         framesAvailable = av_read_frame(m_pFormatContext, m_pPacket) >= 0;
+@@ -644,7 +655,7 @@
+ 
+ int32_t MovieDecoder::getStreamRotation()
+ {
+-    int32_t* matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
++    auto matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
+     if (matrix)
+     {
+         auto angle = lround(av_display_rotation_get(matrix));
+
+--- a/libffmpegthumbnailer/moviedecoder.h	2017-11-12 04:23:38.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.h	2023-05-05 13:26:07.095529911 -0400
+@@ -78,7 +78,7 @@
+     int                     m_VideoStream;
+     AVFormatContext*        m_pFormatContext;
+     AVCodecContext*         m_pVideoCodecContext;
+-    AVCodec*                m_pVideoCodec;
++    const AVCodec*          m_pVideoCodec;
+     AVFilterGraph*          m_pFilterGraph;
+     AVFilterContext*        m_pFilterSource;
+     AVFilterContext*        m_pFilterSink;
diff --git a/srcpkgs/ffmpegthumbnailer/template b/srcpkgs/ffmpegthumbnailer/template
index 039eea7622b39..35d546018d12a 100644
--- a/srcpkgs/ffmpegthumbnailer/template
+++ b/srcpkgs/ffmpegthumbnailer/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbnailer'
 pkgname=ffmpegthumbnailer
 version=2.2.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libpng-devel libjpeg-turbo-devel ffmpeg-devel"
@@ -9,8 +9,8 @@ depends="ffmpeg"
 short_desc="Lightweight video thumbnailer"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
-homepage="https://github.com/dirkvdb/${pkgname}"
-distfiles="${homepage}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
+homepage="https://github.com/dirkvdb"
+distfiles="${homepage}/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
 checksum=1cb24059c38223f657b300c84dd80491b7040d4b69471c4fea69be862bc99b5b
 
 post_install() {

From 51342c22ef2df8c5060e42b1c7f13ec48bfd24cb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 028/113] ffmpegthumbs: revbump for ffmpeg6

---
 srcpkgs/ffmpegthumbs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ffmpegthumbs/template b/srcpkgs/ffmpegthumbs/template
index 5f0b9414dadaf..11b88193528f4 100644
--- a/srcpkgs/ffmpegthumbs/template
+++ b/srcpkgs/ffmpegthumbs/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbs'
 pkgname=ffmpegthumbs
 version=22.12.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules kcoreaddons kconfig-devel
  pkg-config qt5-host-tools qt5-qmake gettext"

From ae4d5da775636593f43c072b27e3135b14f33b2e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 029/113] ffms2: revbump for ffmpeg6

---
 srcpkgs/ffms2/patches/ffmpeg5.patch | 424 ++++++++++++++++++++++++++++
 srcpkgs/ffms2/template              |   2 +-
 2 files changed, 425 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ffms2/patches/ffmpeg5.patch

diff --git a/srcpkgs/ffms2/patches/ffmpeg5.patch b/srcpkgs/ffms2/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..1479fabcafcb4
--- /dev/null
+++ b/srcpkgs/ffms2/patches/ffmpeg5.patch
@@ -0,0 +1,424 @@
+From 45673149e9a2f5586855ad472e3059084eaa36b1 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:41:21 +0100
+Subject: [PATCH] Use auto for AVCodec
+
+The geniuses over at FFmpeg decided to constify this API, so old
+versions of the library will return AVCodec *, while new versions
+of the libary will return const AVCodec *, which, in C++, are not
+OK to convert between.
+
+Rather than use some macro hell in ffmscompat.h, we can work around
+this by using auto.
+
+Gross.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 2 +-
+ src/core/indexing.cpp    | 6 +++---
+ src/core/videosource.cpp | 2 +-
+ 3 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index e4ce97c..ac09666 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -469,7 +469,7 @@ void FFMS_AudioSource::OpenFile() {
+ 
+     LAVFOpenFile(SourceFile.c_str(), FormatContext, TrackNumber);
+ 
+-    AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
++    auto *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
+     if (Codec == nullptr)
+         throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+             "Audio codec not found");
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index e547c5a..59fb4e8 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -384,7 +384,7 @@ FFMS_TrackType FFMS_Indexer::GetTrackType(int Track) {
+ }
+ 
+ const char *FFMS_Indexer::GetTrackCodec(int Track) {
+-    AVCodec *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
++    auto *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
+     return codec ? codec->name : nullptr;
+ }
+ 
+@@ -402,7 +402,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             UseDTS);
+ 
+         if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            AVCodec *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (!VideoCodec) {
+                 FormatContext->streams[i]->discard = AVDISCARD_ALL;
+                 IndexMask.erase(i);
+@@ -433,7 +433,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 IndexMask.insert(i);
+             }
+         } else if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+-            AVCodec *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (AudioCodec == nullptr)
+                 throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_UNSUPPORTED,
+                     "Audio codec not found");
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index b889970..8956c22 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -171,7 +171,7 @@ FFMS_VideoSource::FFMS_VideoSource(const char *SourceFile, FFMS_Index &Index, in
+ 
+         LAVFOpenFile(SourceFile, FormatContext, VideoTrack);
+ 
+-        AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
++        auto *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
+         if (Codec == nullptr)
+             throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+                 "Video codec not found");
+-- 
+2.40.0
+
+From 96cbf38ea9381829a1314f432a2c60495dcefaad Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:12:41 +0100
+Subject: [PATCH] all: Update AVPacket API usage
+
+AVPackets must all be on the heap now, since it is no longer
+part of the libav* ABI.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 16 ++++++----
+ src/core/indexing.cpp    | 63 ++++++++++++++++++++++------------------
+ src/core/indexing.h      |  4 +--
+ src/core/utils.cpp       |  6 ----
+ src/core/utils.h         |  1 -
+ src/core/videosource.cpp | 30 ++++++++++---------
+ 6 files changed, 64 insertions(+), 56 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index 37cf9ae..e4ce97c 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -285,10 +285,15 @@ FFMS_AudioSource::AudioBlock *FFMS_AudioSource::CacheBlock(CacheIterator &pos) {
+ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     CurrentFrame = &Frames[PacketNumber];
+ 
+-    AVPacket Packet;
+-    if (!ReadPacket(&Packet))
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++    if (!ReadPacket(Packet)) {
++        av_packet_free(&Packet);
+         throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_UNKNOWN,
+             "ReadPacket unexpectedly failed to read a packet");
++    }
+ 
+     // ReadPacket may have changed the packet number
+     CurrentFrame = &Frames[PacketNumber];
+@@ -297,8 +302,9 @@ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     int NumberOfSamples = 0;
+     AudioBlock *CachedBlock = nullptr;
+     
+-    int Ret = avcodec_send_packet(CodecContext, &Packet);
+-    av_packet_unref(&Packet);
++    int Ret = avcodec_send_packet(CodecContext, Packet);
++    av_packet_unref(Packet);
++    av_packet_free(&Packet);
+ 
+     av_frame_unref(DecodeFrame);
+     Ret = avcodec_receive_frame(CodecContext, DecodeFrame);
+@@ -513,8 +519,6 @@ void FFMS_AudioSource::Seek() {
+ }
+ 
+ bool FFMS_AudioSource::ReadPacket(AVPacket *Packet) {
+-    InitNullPacket(*Packet);
+-
+     while (av_read_frame(FormatContext, Packet) >= 0) {
+         if (Packet->stream_index == TrackNumber) {
+             // Required because not all audio packets, especially in ogg, have a pts. Use the previous valid packet's pts instead.
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index 23fb95b..e547c5a 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -320,7 +320,7 @@ void FFMS_Indexer::CheckAudioProperties(int Track, AVCodecContext *Context) {
+     }
+ }
+ 
+-void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict,
++void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict,
+                                     int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct) {
+     if (VideoContext.Parser) {
+         uint8_t *OB;
+@@ -330,8 +330,8 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+         av_parser_parse2(VideoContext.Parser,
+             VideoContext.CodecContext,
+             &OB, &OBSize,
+-            pkt.data, pkt.size,
+-            pkt.pts, pkt.dts, pkt.pos);
++            pkt->data, pkt->size,
++            pkt->pts, pkt->dts, pkt->pos);
+ 
+         // H.264 (PAFF) and HEVC may have one field per packet, so we need to track
+         // when we have a full or half frame available, and mark one of them as
+@@ -351,15 +351,15 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+ 
+         *RepeatPict = VideoContext.Parser->repeat_pict;
+         *FrameType = VideoContext.Parser->pict_type;
+-        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt.flags & AV_PKT_FLAG_DISCARD));
++        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt->flags & AV_PKT_FLAG_DISCARD));
+     } else {
+-        *Invisible = !!(pkt.flags & AV_PKT_FLAG_DISCARD);
++        *Invisible = !!(pkt->flags & AV_PKT_FLAG_DISCARD);
+     }
+ 
+     if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP8)
+-        ParseVP8(pkt.data[0], Invisible, FrameType);
++        ParseVP8(pkt->data[0], Invisible, FrameType);
+     else if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP9)
+-        ParseVP9(pkt.data[0], Invisible, FrameType);
++        ParseVP9(pkt->data[0], Invisible, FrameType);
+ }
+ 
+ void FFMS_Indexer::Free() {
+@@ -458,32 +458,36 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+         }
+     }
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
+     std::vector<int64_t> LastValidTS(FormatContext->nb_streams, AV_NOPTS_VALUE);
+ 
+     int64_t filesize = avio_size(FormatContext->pb);
+     enum AVPictureStructure LastPicStruct = AV_PICTURE_STRUCTURE_UNKNOWN;
+-    while (av_read_frame(FormatContext, &Packet) >= 0) {
++    while (av_read_frame(FormatContext, Packet) >= 0) {
+         // Update progress
+         // FormatContext->pb can apparently be NULL when opening images.
+         if (IC && FormatContext->pb) {
+-            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate))
++            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate)) {
++                av_packet_free(&Packet);
+                 throw FFMS_Exception(FFMS_ERROR_CANCELLED, FFMS_ERROR_USER,
+                     "Cancelled by user");
++            }
+         }
+-        if (!IndexMask.count(Packet.stream_index)) {
+-            av_packet_unref(&Packet);
++        if (!IndexMask.count(Packet->stream_index)) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+-        int Track = Packet.stream_index;
++        int Track = Packet->stream_index;
+         FFMS_Track &TrackInfo = (*TrackIndices)[Track];
+-        bool KeyFrame = !!(Packet.flags & AV_PKT_FLAG_KEY);
++        bool KeyFrame = !!(Packet->flags & AV_PKT_FLAG_KEY);
+         ReadTS(Packet, LastValidTS[Track], (*TrackIndices)[Track].UseDTS);
+ 
+         if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            int64_t PTS = TrackInfo.UseDTS ? Packet.dts : Packet.pts;
++            int64_t PTS = TrackInfo.UseDTS ? Packet->dts : Packet->pts;
+             if (PTS == AV_NOPTS_VALUE) {
+                 // VPx alt-refs are output as packets which lack timestmps or durations, since
+                 // they are invisible. Currently, the timestamp mangling code in libavformat
+@@ -495,9 +499,11 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 // FFMS2 currently sorts packets by PTS, which will break decoding, otherwise.
+                 bool HasAltRefs = (FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP8 ||
+                                    FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP9);
+-                if (Packet.duration == 0 && !HasAltRefs)
++                if (Packet->duration == 0 && !HasAltRefs) {
++                    av_packet_free(&Packet);
+                     throw FFMS_Exception(FFMS_ERROR_INDEXING, FFMS_ERROR_PARSER,
+                         "Invalid packet pts, dts, and duration");
++                }
+ 
+                 if (TrackInfo.empty())
+                     PTS = 0;
+@@ -513,7 +519,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             ParseVideoPacket(AVContexts[Track], Packet, &RepeatPict, &FrameType, &Invisible, &LastPicStruct);
+ 
+             TrackInfo.AddVideoFrame(PTS, RepeatPict, KeyFrame,
+-                FrameType, Packet.pos, Invisible);
++                FrameType, Packet->pos, Invisible);
+         } else if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+             // For video seeking timestamps are used only if all packets have
+             // timestamps, while for audio they're used if any have timestamps,
+@@ -522,28 +528,29 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 TrackInfo.HasTS = true;
+ 
+             int64_t StartSample = AVContexts[Track].CurrentSample;
+-            uint32_t SampleCount = IndexAudioPacket(Track, &Packet, AVContexts[Track], *TrackIndices);
++            uint32_t SampleCount = IndexAudioPacket(Track, Packet, AVContexts[Track], *TrackIndices);
+             TrackInfo.SampleRate = AVContexts[Track].CodecContext->sample_rate;
+ 
+             TrackInfo.AddAudioFrame(LastValidTS[Track],
+-                StartSample, SampleCount, KeyFrame, Packet.pos, Packet.flags & AV_PKT_FLAG_DISCARD);
++                StartSample, SampleCount, KeyFrame, Packet->pos, Packet->flags & AV_PKT_FLAG_DISCARD);
+         }
+ 
+-        if (!(Packet.flags & AV_PKT_FLAG_DISCARD))
+-            TrackInfo.LastDuration = Packet.duration;
++        if (!(Packet->flags & AV_PKT_FLAG_DISCARD))
++            TrackInfo.LastDuration = Packet->duration;
+ 
+-        av_packet_unref(&Packet);
++        av_packet_unref(Packet);
+     }
++    av_packet_free(&Packet);
+ 
+     TrackIndices->Finalize(AVContexts, FormatContext->iformat->name);
+     return TrackIndices.release();
+ }
+ 
+-void FFMS_Indexer::ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS) {
+-    if (!UseDTS && Packet.pts != AV_NOPTS_VALUE)
+-        TS = Packet.pts;
++void FFMS_Indexer::ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS) {
++    if (!UseDTS && Packet->pts != AV_NOPTS_VALUE)
++        TS = Packet->pts;
+     if (TS == AV_NOPTS_VALUE)
+         UseDTS = true;
+-    if (UseDTS && Packet.dts != AV_NOPTS_VALUE)
+-        TS = Packet.dts;
++    if (UseDTS && Packet->dts != AV_NOPTS_VALUE)
++        TS = Packet->dts;
+ }
+diff --git a/src/core/indexing.h b/src/core/indexing.h
+index 3cfc3c3..5c06868 100644
+--- a/src/core/indexing.h
++++ b/src/core/indexing.h
+@@ -80,10 +80,10 @@ private:
+     int64_t Filesize;
+     uint8_t Digest[20];
+ 
+-    void ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS);
++    void ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS);
+     void CheckAudioProperties(int Track, AVCodecContext *Context);
+     uint32_t IndexAudioPacket(int Track, AVPacket *Packet, SharedAVContext &Context, FFMS_Index &TrackIndices);
+-    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
++    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
+     void Free();
+ public:
+     FFMS_Indexer(const char *Filename);
+diff --git a/src/core/utils.cpp b/src/core/utils.cpp
+index ce67533..8a2e997 100644
+--- a/src/core/utils.cpp
++++ b/src/core/utils.cpp
+@@ -62,12 +62,6 @@ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo) {
+     }
+ }
+ 
+-void InitNullPacket(AVPacket &pkt) {
+-    av_init_packet(&pkt);
+-    pkt.data = nullptr;
+-    pkt.size = 0;
+-}
+-
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames) {
+     AP.SampleFormat = static_cast<FFMS_SampleFormat>(av_get_packed_sample_fmt(CTX->sample_fmt));
+     AP.BitsPerSample = av_get_bytes_per_sample(CTX->sample_fmt) * 8;
+diff --git a/src/core/utils.h b/src/core/utils.h
+index 9819dc7..003ab79 100644
+--- a/src/core/utils.h
++++ b/src/core/utils.h
+@@ -58,7 +58,6 @@ std::unique_ptr<T> make_unique(Args&&... args) {
+ }
+ 
+ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo);
+-void InitNullPacket(AVPacket &pkt);
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames);
+ 
+ void LAVFOpenFile(const char *SourceFile, AVFormatContext *&FormatContext, int Track);
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index 06bd161..b889970 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -673,30 +673,34 @@ void FFMS_VideoSource::DecodeNextFrame(int64_t &AStartTime, int64_t &Pos) {
+     if (HasPendingDelayedFrames())
+         return;
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
+-
+-    while (ReadFrame(&Packet) >= 0) {
+-        if (Packet.stream_index != VideoTrack) {
+-            av_packet_unref(&Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++
++    while (ReadFrame(Packet) >= 0) {
++        if (Packet->stream_index != VideoTrack) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+         if (AStartTime < 0)
+-            AStartTime = Frames.UseDTS ? Packet.dts : Packet.pts;
++            AStartTime = Frames.UseDTS ? Packet->dts : Packet->pts;
+ 
+         if (Pos < 0)
+-            Pos = Packet.pos;
++            Pos = Packet->pos;
+ 
+-        bool FrameFinished = DecodePacket(&Packet);
+-        av_packet_unref(&Packet);
+-        if (FrameFinished)
++        bool FrameFinished = DecodePacket(Packet);
++        av_packet_unref(Packet);
++        if (FrameFinished) {
++            av_packet_free(&Packet);
+             return;
++        }
+     }
+ 
+     // Flush final frames
+-    InitNullPacket(Packet);
+-    DecodePacket(&Packet);
++    DecodePacket(Packet);
++    av_packet_free(&Packet);
+ }
+ 
+ bool FFMS_VideoSource::SeekTo(int n, int SeekOffset) {
+-- 
+2.40.0
+
+From bf9e03e9e08534c024e5a744a6437c4aac160201 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:20:47 +0100
+Subject: [PATCH 2/3] configure: Remove deprecated API use
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ configure.ac | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index b35ef80bc..d19714d0f 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -102,10 +102,10 @@ CFLAGS="$_CFLAGS $FFMPEG_CFLAGS"
+
+ AC_DEFUN([TEST_FFMPEG],
+          [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+-            #include <libavcodec/avcodec.h>
++            #include <libavformat/avformat.h>
+             #include <libswscale/swscale.h>
+             ]],[[
+-                avcodec_register_all();
++                avformat_network_init();
+                 swscale_version();
+             ]])], [eval $1=yes], [eval $1=no])
+         ])
+
diff --git a/srcpkgs/ffms2/template b/srcpkgs/ffms2/template
index 365f64d10cbab..1641ecf43be5b 100644
--- a/srcpkgs/ffms2/template
+++ b/srcpkgs/ffms2/template
@@ -1,7 +1,7 @@
 # Template file for 'ffms2'
 pkgname=ffms2
 version=2.40
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-shared --disable-static"
 hostmakedepends="pkg-config autoconf automake libtool"

From cf63602dca34d2d07a96abb82231f96f7743e5b0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 030/113] freerdp: revbump for ffmpeg6

---
 .../freerdp/patches/ffmpeg6_aa2cb9aa.patch    | 42 +++++++++++++++++++
 srcpkgs/freerdp/template                      |  2 +-
 2 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch

diff --git a/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
new file mode 100644
index 0000000000000..a4324da3a8822
--- /dev/null
+++ b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
@@ -0,0 +1,42 @@
+From aa2cb9aa5ff5562433598ba168a466e0752bca0e Mon Sep 17 00:00:00 2001
+From: akallabeth <akallabeth@posteo.net>
+Date: Tue, 14 Feb 2023 07:48:54 +0100
+Subject: [PATCH] Fixed #8686: Update h264 to use new FFMPEG API
+
+---
+ channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c | 2 ++
+ libfreerdp/codec/h264_ffmpeg.c            | 2 ++
+ 2 files changed, 4 insertions(+)
+
+diff --git a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+index 339462d865f..beea80b7a1e 100644
+--- a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
++++ b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+@@ -239,8 +239,10 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYP
+ 		}
+ 	}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 	if (mdecoder->codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		mdecoder->codec_context->flags |= AV_CODEC_FLAG_TRUNCATED;
++#endif
+ 
+ 	return TRUE;
+ }
+diff --git a/libfreerdp/codec/h264_ffmpeg.c b/libfreerdp/codec/h264_ffmpeg.c
+index 8a23db2473c..896a333019b 100644
+--- a/libfreerdp/codec/h264_ffmpeg.c
++++ b/libfreerdp/codec/h264_ffmpeg.c
+@@ -615,10 +615,12 @@ static BOOL libavcodec_init(H264_CONTEXT* h264)
+ 			goto EXCEPTION;
+ 		}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 		if (sys->codecDecoder->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		{
+ 			sys->codecDecoderContext->flags |= AV_CODEC_FLAG_TRUNCATED;
+ 		}
++#endif
+ 
+ #ifdef WITH_VAAPI
+ 
diff --git a/srcpkgs/freerdp/template b/srcpkgs/freerdp/template
index f36c38ca885b3..97b1d5ea519cd 100644
--- a/srcpkgs/freerdp/template
+++ b/srcpkgs/freerdp/template
@@ -1,7 +1,7 @@
 # Template file for 'freerdp'
 pkgname=freerdp
 version=2.10.0
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DWITH_ALSA=ON -DWITH_CUPS=OFF -DWITH_FFMPEG=ON
  -DWITH_GSTREAMER_0_10=OFF -DWITH_GSTREAMER_1_0=OFF -DWITH_JPEG=ON

From 85b7434c5e982c623f8e66395ab57fb2e495976c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 031/113] gerbera: revbump for ffmpeg6

---
 srcpkgs/gerbera/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gerbera/template b/srcpkgs/gerbera/template
index ae14f35c767c0..2dc0ac0ce03b5 100644
--- a/srcpkgs/gerbera/template
+++ b/srcpkgs/gerbera/template
@@ -1,7 +1,7 @@
 # Template file for 'gerbera'
 pkgname=gerbera
 version=1.12.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_SYSTEMD=0 -DWITH_AVCODEC=1"
 hostmakedepends="pkg-config"

From 6e9a4d3c77680b00b5bf3a4e956c7cba3718dd2d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 032/113] goldendict: revbump for ffmpeg6

---
 srcpkgs/goldendict/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/goldendict/template b/srcpkgs/goldendict/template
index f4a05759f693d..97f44347b03a6 100644
--- a/srcpkgs/goldendict/template
+++ b/srcpkgs/goldendict/template
@@ -1,7 +1,7 @@
 # Template file for 'goldendict'
 pkgname=goldendict
 version=1.5.0
-revision=1
+revision=2
 build_style=qmake
 configure_args="CONFIG+=zim_support goldendict.pro"
 hostmakedepends="qt5-qmake pkg-config qt5-host-tools"
@@ -10,7 +10,7 @@ makedepends="tiff-devel qt5-devel libvorbis-devel zlib-devel
  qt5-webkit-devel lzo-devel bzip2-devel libao-devel qt5-svg-devel
  libeb-devel qt5-x11extras-devel ffmpeg-devel liblzma-devel
  qt5-multimedia-devel"
-short_desc="A feature-rich dictionary lookup program"
+short_desc="Feature-rich dictionary lookup program"
 maintainer="John <me@johnnynator.dev>"
 license="GPL-3.0-or-later"
 homepage="http://goldendict.org/"

From 4279697ee6bbf9ab4c39fd71e5bee56e3df634ca Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 033/113] gst-libav: revbump for ffmpeg6

---
 srcpkgs/gst-libav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index b24be23fc1a6d..0f9350a251bf6 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.22.9
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"

From 6b7841b8d5bb11416d975afca88f583bfe0d1845 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Feb 2024 01:52:46 -0500
Subject: [PATCH 034/113] gst-bad: revbump for ffmpeg6

---
 srcpkgs/gst-plugins-bad1/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index 4fe7053c359c3..63200e74f99a7 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -27,7 +27,7 @@ makedepends="alsa-lib-devel celt-devel openssl-devel exempi-devel
  fdk-aac-devel flite-devel fluidsynth-devel liblrdf-devel ladspa-sdk
  lilv-devel lv2 libopenjpeg2-devel sbc-devel spandsp-devel vulkan-loader
  Vulkan-Headers webrtc-audio-processing-devel libzbar-devel ffmpeg-devel
- srt-devel libva-devel
+ srt-devel libva-devel oneVPL-devel
  $(vopt_if gme libgme-devel)"
 depends="gst-plugins-base1>=${version}"
 short_desc="GStreamer plugins from the bad set (v1.x)"

From 4a0d3466c7c1adb5bc8159cf88cef313b6582a1a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 035/113] gst-rtsp-server: revbump for ffmpeg6

---
 srcpkgs/gst-rtsp-server/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index bc2a0dea6ac15..f77026c618eb6 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
 version=1.22.9
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="glib-devel gst-plugins-bad1-devel gobject-introspection

From 51fec718c7d1f28840e8956579e145c4eb0f5975 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 036/113] guvcview: update to 2.0.8.

---
 srcpkgs/guvcview/patches/fix-include.patch | 10 ++++++++++
 srcpkgs/guvcview/template                  |  7 +++----
 2 files changed, 13 insertions(+), 4 deletions(-)
 create mode 100644 srcpkgs/guvcview/patches/fix-include.patch

diff --git a/srcpkgs/guvcview/patches/fix-include.patch b/srcpkgs/guvcview/patches/fix-include.patch
new file mode 100644
index 0000000000000..503c2af3b78c1
--- /dev/null
+++ b/srcpkgs/guvcview/patches/fix-include.patch
@@ -0,0 +1,10 @@
+--- a/guvcview/guvcview.c
++++ b/guvcview/guvcview.c
+@@ -28,6 +28,7 @@
+ #include <sys/stat.h>
+ #include <sys/resource.h>
+ #include <errno.h>
++#include <locale.h>
+ 
+ #include "gview.h"
+ #include "gviewv4l2core.h"
diff --git a/srcpkgs/guvcview/template b/srcpkgs/guvcview/template
index d42fd38fa4ad1..86a7fd619612c 100644
--- a/srcpkgs/guvcview/template
+++ b/srcpkgs/guvcview/template
@@ -1,8 +1,7 @@
 # Template file for 'guvcview'
 pkgname=guvcview
-version=2.0.7
-revision=2
-create_wrksrc=yes
+version=2.0.8
+revision=1
 build_style=gnu-configure
 configure_args="--disable-static --disable-debian-menu"
 hostmakedepends="pkg-config intltool autoconf automake libtool glib-devel"
@@ -14,7 +13,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="http://guvcview.sourceforge.net/"
 distfiles="${SOURCEFORGE_SITE}/${pkgname}/${pkgname}-src-${version}.tar.bz2"
-checksum=f47d51fbd06e44eeaa1a82f4a153c927527c90d94514197a70b2956028cc8ad4
+checksum=a21f4e448286666cf27bafef5290cc953a0a1796b752e5bbe521266dc1230c81
 
 post_patch() {
 	sed '31a#include <locale.h>' -i  guvcview/guvcview.c

From 10a4db6b27ee2ec36dd09fb566040fd70305a7d7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 037/113] handbrake: update to 1.6.1

---
 .../patches/fix-missing-x265-link-flag.patch    | 11 ++++++-----
 .../handbrake/patches/libhb-vpl-include.patch   | 15 +++++++++++++++
 srcpkgs/handbrake/template                      | 17 ++++++++++-------
 3 files changed, 31 insertions(+), 12 deletions(-)
 create mode 100644 srcpkgs/handbrake/patches/libhb-vpl-include.patch

diff --git a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
index 26db03867a0c8..d6bb2eda627a3 100644
--- a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
+++ b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
@@ -1,14 +1,15 @@
 --- a/gtk/configure.ac
 +++ b/gtk/configure.ac
 @@ -203,7 +203,7 @@
- 
+
  AM_CONDITIONAL([MINGW], [test "x$mingw_flag" = "xyes"])
- 
--HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg"
-+HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -ldl"
+
+-HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc"
++HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc -ldl"
  HB_CPPFLAGS="$HB_CPPFLAGS $HBINC"
- 
+
  PKG_CHECK_MODULES([x264], [x264], sys_x264=yes, sys_x264=no)
+
 --- a/test/module.defs
 +++ b/test/module.defs
 @@ -69,6 +69,9 @@
diff --git a/srcpkgs/handbrake/patches/libhb-vpl-include.patch b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
new file mode 100644
index 0000000000000..298f9f4ab28f2
--- /dev/null
+++ b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
@@ -0,0 +1,15 @@
+--- a/libhb/module.defs	2023-01-22 11:36:49.000000000 -0500
++++ b/libhb/module.defs	2023-04-03 22:37:52.395467010 -0400
+@@ -46,11 +46,7 @@
+ LIBHB.GCC.I += $(LIBHB.build/) $(CONTRIB.build/)include
+ 
+ ifeq (1,$(FEATURE.qsv))
+-    ifeq ($(HOST.system),freebsd))
+-        LIBHB.GCC.I += $(LOCALBASE)/include/vpl
+-    else
+-        LIBHB.GCC.I += $(CONTRIB.build/)include/vpl
+-    endif
++    LIBHB.GCC.I += /usr/include/vpl
+ endif
+ 
+ ifneq (,$(filter $(HOST.system),freebsd netbsd openbsd))
diff --git a/srcpkgs/handbrake/template b/srcpkgs/handbrake/template
index ca5e4571e49c3..c32cb1bfa31f4 100644
--- a/srcpkgs/handbrake/template
+++ b/srcpkgs/handbrake/template
@@ -1,10 +1,10 @@
 # Template file for 'handbrake'
 pkgname=handbrake
-version=1.5.1
+version=1.6.1
 revision=1
 build_style=gnu-configure
 configure_args="--force --disable-gtk-update-checks --disable-df-fetch --harden
- $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc)"
+ $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc) $(vopt_enable qsv)"
 make_build_args="-C ${XBPS_TRIPLET}"
 make_install_args="-C ${XBPS_TRIPLET}"
 hostmakedepends="automake cmake gettext-devel glib-devel intltool libtool m4 meson nasm pkg-config python3"
@@ -12,8 +12,11 @@ makedepends="bzip2-devel ffmpeg-devel gst-plugins-base1-devel gtk+3-devel
  jansson-devel lame-devel libass-devel libbluray-devel libdav1d-devel
  libdvdnav-devel libdvdread-devel libgudev-devel libnuma-devel
  libsamplerate-devel libtheora-devel libvorbis-devel libvpx-devel libxml2-devel
- opus-devel speex-devel x264-devel x265-devel zimg-devel
+ opus-devel speex-devel x264-devel x265-devel zimg-devel libsvt-av1-devel
  $(vopt_if fdk_aac fdk-aac-devel)
+ $(vopt_if qsv libva-devel)
+ $(vopt_if qsv libdrm-devel)
+ $(vopt_if qsv onevpl-devel)
  $(vopt_if nvenc nv-codec-headers)"
 depends="desktop-file-utils gst-plugins-good1 hicolor-icon-theme"
 short_desc="Multithreaded video transcoder"
@@ -21,15 +24,15 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-2.0-only"
 homepage="https://handbrake.fr/"
 distfiles="https://github.com/HandBrake/HandBrake/releases/download/${version}/HandBrake-${version}-source.tar.bz2"
-checksum=3999fe06d5309c819799a73a968a8ec3840e7840c2b64af8f5cdb7fd8c9430f0
+checksum=94ccfe03db917a91650000c510f7fd53f844da19f19ad4b4be1b8f6bc31a8d4c
 nocross=yes
 
-build_options="fdk_aac nvenc"
+build_options="fdk_aac nvenc qsv"
 
 case "$XBPS_TARGET_MACHINE" in
 	x86_64*|i686*)
 		CFLAGS="-msse"
-		build_options_default="nvenc"
+		build_options_default="nvenc qsv"
 		;;
 esac
 
@@ -37,7 +40,7 @@ pre_configure() {
 	# use system libraries, don't download them
 	rm -rf contrib/
 	for module in fdk-aac ffmpeg libbluray libdav1d libdvdnav libdvdread nvenc \
-		x265 zimg; do
+		x265 zimg svt-av1 libvpl; do
 	    vsed -i "/MODULES += contrib\/${module}/d" make/include/main.defs
 	done
 }

From 5e282b49121f6b5d1c1e0ec0073dec9bf564b267 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 038/113] hedgewars: revbump for ffmpeg4

---
 srcpkgs/hedgewars/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/hedgewars/template b/srcpkgs/hedgewars/template
index 94b6db673b0c3..402ccfaaecbc2 100644
--- a/srcpkgs/hedgewars/template
+++ b/srcpkgs/hedgewars/template
@@ -1,13 +1,13 @@
 # Template file for 'hedgewars'
 pkgname=hedgewars
 version=1.0.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DNOSERVER=1 -DDATA_INSTALL_DIR=/usr/share/${pkgname}
  -DPHYSFS_SYSTEM=1 -DMINIMAL_FLAGS=1"
 make_cmd=make
 hostmakedepends="lua51 pkg-config qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
+makedepends="ffmpeg4-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
  SDL2_mixer-devel SDL2_net-devel SDL2_ttf-devel"
 depends="libfreeglut"
 short_desc="Funny turn-based artillery game, featuring fighting Hedgehogs!"

From 827ab58188bb74903d256eb663d38301e0e607ef Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 039/113] idjc: revbump for ffmpeg4

---
 srcpkgs/idjc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/idjc/template b/srcpkgs/idjc/template
index a9cde0665d55b..f41e1e4fabbae 100644
--- a/srcpkgs/idjc/template
+++ b/srcpkgs/idjc/template
@@ -1,11 +1,11 @@
 # Template file for 'idjc'
 pkgname=idjc
 version=0.9.1
-revision=5
+revision=6
 build_style=gnu-configure
 hostmakedepends="pkg-config git python3 automake gettext-devel libtool"
 makedepends="libvorbis-devel libogg-devel jack-devel libsamplerate-devel
- libflac-devel libsndfile-devel mpg123-devel ffmpeg-devel speex-devel
+ libflac-devel libsndfile-devel mpg123-devel ffmpeg4-devel speex-devel
  glib-devel pixman-devel lame-devel python3-gobject-devel libshout-idjc-devel
  opus-devel twolame-devel python3-mutagen python3-devel"
 depends="python3-gobject python3-mutagen desktop-file-utils shared-mime-info python3-dbus jack"

From 445d18f7b0c37827438b20e5909000d1bed0551d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 040/113] kid3: revbump for ffmpeg6

---
 srcpkgs/kid3/patches/ffmpeg5.patch | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 srcpkgs/kid3/patches/ffmpeg5.patch

diff --git a/srcpkgs/kid3/patches/ffmpeg5.patch b/srcpkgs/kid3/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..135fc50e07c9b
--- /dev/null
+++ b/srcpkgs/kid3/patches/ffmpeg5.patch
@@ -0,0 +1,17 @@
+# https://aur.archlinux.org/cgit/aur.git/diff/ffmpeg5.patch?h=kid3-cli&id=12410a74906612e7efc0ec8fbce739b4a0fef7e7
+diff --git a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+index e156d424..e12b9abd 100644
+--- a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
++++ b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+@@ -232,7 +232,11 @@ private:
+   friend class Format;
+   friend class Converter;
+   AVCodecContext* m_ptr;
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 0, 0)
+   AVCodec* m_impl;
++#else
++  const AVCodec* m_impl;
++#endif
+   AVFrame* m_frame;
+   bool m_opened;
+ };

From e903c736e1bf2f3fb1e0019f94eae40696c19e05 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 041/113] kodi: revbump for ffmpeg4

---
 srcpkgs/kodi/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/kodi/template b/srcpkgs/kodi/template
index d37a5918cd675..ea78e0aca0fe3 100644
--- a/srcpkgs/kodi/template
+++ b/srcpkgs/kodi/template
@@ -1,7 +1,7 @@
 # Template file for 'kodi'
 pkgname=kodi
 version=19.4
-revision=9
+revision=10
 _codename="Matrix"
 build_style=cmake
 configure_args="-DWITH_FFMPEG=/usr -DENABLE_LDGOLD=OFF
@@ -54,7 +54,7 @@ makedepends="
  libmad-devel fontconfig-devel libXinerama-devel libsamplerate-devel libmms-devel
  enca-devel boost-devel libcurl-devel libva-devel libvdpau-devel libass-devel
  libbluetooth-devel yajl-devel libplist-devel librtmp-devel tinyxml-devel
- taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg-devel
+ taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg4-devel
  giflib-devel libxslt-devel gnutls-devel libssh-devel libmicrohttpd-devel
  libcec-devel dcadec-devel flatbuffers-devel fmt-devel lcms2-devel
  libfstrcmp-devel rapidjson libcdio-paranoia spdlog libwaylandpp-devel

From 901b0e52360bf0a52387cfd3c193c2a20357245d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 042/113] kpipewire: revbump for ffmpeg6

---
 srcpkgs/kpipewire/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kpipewire/template b/srcpkgs/kpipewire/template
index 6214a4451336e..3555348659dde 100644
--- a/srcpkgs/kpipewire/template
+++ b/srcpkgs/kpipewire/template
@@ -1,7 +1,7 @@
 # Template file for 'kpipewire'
 pkgname=kpipewire
 version=5.27.10
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules plasma-wayland-protocols gettext
  qt5-qmake qt5-host-tools pkg-config wayland-devel kcoreaddons

From ffb6af8fb0e9a2769046149362099d6b471bb5e9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 043/113] libextractor: revbump for ffmpeg4

---
 srcpkgs/libextractor/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/libextractor/template b/srcpkgs/libextractor/template
index 044c663a3a0b9..06e63bc3189d5 100644
--- a/srcpkgs/libextractor/template
+++ b/srcpkgs/libextractor/template
@@ -1,13 +1,13 @@
 # Template file for 'libextractor'
 pkgname=libextractor
 version=1.11
-revision=4
+revision=5
 build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="pkg-config"
 makedepends="zlib-devel bzip2-devel exiv2-devel tiff-devel libpng-devel
  libjpeg-turbo-devel libvorbis-devel libflac-devel giflib-devel libmpeg2-devel
- ffmpeg-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
+ ffmpeg4-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
 short_desc="Library used to extract meta data from files"
 maintainer="Martin Riese <grauehaare@gmx.de>"
 license="GPL-3.0-or-later"

From b5470632aea407536739d0c7153b9ee78155e67e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 044/113] libopenal: revbump for ffmpeg6

---
 srcpkgs/libopenal/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenal/template b/srcpkgs/libopenal/template
index 88d0f11307d81..8308fca0393e3 100644
--- a/srcpkgs/libopenal/template
+++ b/srcpkgs/libopenal/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenal'
 pkgname=libopenal
 version=1.23.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DALSOFT_EXAMPLES=OFF"
 hostmakedepends="pkg-config"

From c67bd474a61c4d2f3cf10cf5589d6721f504d2f1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 045/113] loudgain: revbump for ffmpeg6

---
 srcpkgs/loudgain/patches/ffmpeg5.patch | 11 +++++++++++
 srcpkgs/loudgain/template              |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/loudgain/patches/ffmpeg5.patch

diff --git a/srcpkgs/loudgain/patches/ffmpeg5.patch b/srcpkgs/loudgain/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..16d4510ee98fa
--- /dev/null
+++ b/srcpkgs/loudgain/patches/ffmpeg5.patch
@@ -0,0 +1,11 @@
+--- a/src/scan.c	2019-09-06 11:31:19.000000000 -0400
++++ b/src/scan.c	2023-03-23 11:15:40.867968521 -0400
+@@ -69,8 +69,6 @@
+ 	 * It is now useless
+ 	 * https://github.com/FFmpeg/FFmpeg/blob/70d25268c21cbee5f08304da95be1f647c630c15/doc/APIchanges#L86
+ 	 */
+-  if (avformat_version() < AV_VERSION_INT(58,9,100))
+-    av_register_all();
+ 
+ 	av_log_set_callback(scan_av_log);
+ 
diff --git a/srcpkgs/loudgain/template b/srcpkgs/loudgain/template
index da4f2d56e94c3..4d6bf29efb4fd 100644
--- a/srcpkgs/loudgain/template
+++ b/srcpkgs/loudgain/template
@@ -1,7 +1,7 @@
 # Template file for 'loudgain'
 pkgname=loudgain
 version=0.6.8
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libebur128-devel taglib-devel ffmpeg-devel"

From 654bdde7bc0adabb832f45ef065b8a794303dc41 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 046/113] mediastreamer: revbump for ffmpeg4

---
 srcpkgs/mediastreamer/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mediastreamer/template b/srcpkgs/mediastreamer/template
index 0fcffa7653d18..e888626b945e5 100644
--- a/srcpkgs/mediastreamer/template
+++ b/srcpkgs/mediastreamer/template
@@ -1,11 +1,11 @@
 # Template file for 'mediastreamer'
 pkgname=mediastreamer
 version=5.2.111
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DENABLE_STRICT=0 -DENABLE_UNIT_TESTS=0"
 hostmakedepends="python3"
-makedepends="bzrtp-devel ffmpeg-devel glew-devel libXv-devel libsrtp-devel
+makedepends="bzrtp-devel ffmpeg4-devel glew-devel libXv-devel libsrtp-devel
  libupnp-devel libvpx-devel mbedtls-devel opus-devel ortp-devel pulseaudio-devel
  libtheora-devel speex-devel v4l-utils-devel bcg729-devel bcmatroska2-devel libgsm-devel
  zxing-cpp-devel"

From c37ec6050a1aee51df858782b46d507fb424da26 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 047/113] mgba: revbump for ffmpeg6

---
 srcpkgs/mgba/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mgba/template b/srcpkgs/mgba/template
index 6cd6565031254..93401adb618bd 100644
--- a/srcpkgs/mgba/template
+++ b/srcpkgs/mgba/template
@@ -1,7 +1,7 @@
 # Template file for 'mgba'
 pkgname=mgba
 version=0.10.3
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake desktop-file-utils"
 makedepends="SDL2-devel ffmpeg-devel libedit-devel libepoxy-devel libmagick-devel

From 5620569f1eecfe762562bc7ed1c6d55254fefa2e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 048/113] mlt: revbump for ffmpeg4

---
 srcpkgs/mlt/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mlt/template b/srcpkgs/mlt/template
index 73e3915aaab9a..d7ed4c4b30a86 100644
--- a/srcpkgs/mlt/template
+++ b/srcpkgs/mlt/template
@@ -1,14 +1,14 @@
 # Template file for 'mlt'
 pkgname=mlt
 version=6.26.1
-revision=3
+revision=4
 build_style=configure
 configure_args="--prefix=/usr --libdir=/usr/lib$XBPS_TARGET_WORDSIZE
  --enable-gpl --enable-gpl3 --disable-swfdec --without-kde
  --swig-languages=python"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which"
 # XXX: movit vid.stab
-makedepends="alsa-lib-devel ffmpeg-devel gtk+-devel jack-devel ladspa-sdk
+makedepends="alsa-lib-devel ffmpeg4-devel gtk+-devel jack-devel ladspa-sdk
  libexif-devel libsamplerate-devel libxml2-devel sox-devel SDL_image-devel
  fftw-devel frei0r-plugins python3-devel pulseaudio-devel movit-devel
  libvidstab-devel"

From ce3d7719236ec68c7e9c4d4f803cbc451ed38cbb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 049/113] moc: revbump for ffmpeg4

---
 srcpkgs/moc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/moc/template b/srcpkgs/moc/template
index 3a04932c8f1e6..838755f88db09 100644
--- a/srcpkgs/moc/template
+++ b/srcpkgs/moc/template
@@ -1,10 +1,10 @@
 # Template file for 'moc'
 pkgname=moc
 version=2.5.2
-revision=7
+revision=8
 build_style=gnu-configure
 hostmakedepends="pkg-config"
-makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg-devel
+makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg4-devel
  jack-devel alsa-lib-devel libltdl-devel libflac-devel libvorbis-devel
  libmad-devel libmpcdec-devel libmodplug-devel libid3tag-devel faad2-devel
  taglib-devel libsndfile-devel wavpack-devel speex-devel libsamplerate-devel

From 9eab37b03ad1c98beb52a332ea7d32735fa21f01 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 050/113] motion: revbump for ffmpeg6

---
 srcpkgs/motion/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/motion/template b/srcpkgs/motion/template
index 607ebeb3c7b24..bf63a91d9764f 100644
--- a/srcpkgs/motion/template
+++ b/srcpkgs/motion/template
@@ -1,7 +1,7 @@
 # Template file for 'motion'
 pkgname=motion
 version=4.6.0
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake pkg-config gettext-devel tar"
 makedepends="ffmpeg-devel libmicrohttpd-devel v4l-utils-devel gettext-devel"

From f6ebdd2125efcee1d44f6dae5c78307b42c8633e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 051/113] olive: revbump for ffmpeg4

---
 srcpkgs/olive/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/olive/template b/srcpkgs/olive/template
index 12a46936c9900..5c2917b9c5124 100644
--- a/srcpkgs/olive/template
+++ b/srcpkgs/olive/template
@@ -1,10 +1,10 @@
 # Template file for 'olive'
 pkgname=olive
 version=0.1.2
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools pkg-config"
-makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg-devel frei0r-plugins"
+makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg4-devel frei0r-plugins"
 short_desc="Non-linear video editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"

From 838ea4fbb1e09cf58d90dd2e3cd1aab4df048e52 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 052/113] opentoonz: revbump for ffmpeg6

---
 srcpkgs/opentoonz/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/opentoonz/template b/srcpkgs/opentoonz/template
index ee9f7603f55fd..3e81834ca0edd 100644
--- a/srcpkgs/opentoonz/template
+++ b/srcpkgs/opentoonz/template
@@ -1,7 +1,7 @@
 # Template file for 'opentoonz'
 pkgname=opentoonz
 version=1.6.0
-revision=2
+revision=3
 build_wrksrc="toonz/sources"
 build_style=cmake
 make_cmd=make

From f10d68d8a3540d5be0eb55f4a181661165dc8713 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 053/113] pianobar: revbump for ffmpeg6

---
 srcpkgs/pianobar/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pianobar/template b/srcpkgs/pianobar/template
index e3febb821a451..1e3dc1bf9308e 100644
--- a/srcpkgs/pianobar/template
+++ b/srcpkgs/pianobar/template
@@ -1,7 +1,7 @@
 # Template file for 'pianobar'
 pkgname=pianobar
 version=2022.04.01
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="V=1"
 hostmakedepends="pkg-config"

From 1914bb12aeec45381f6d0c2ea1f6b863736234f8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 054/113] ppsspp: revbump for ffmpeg4

---
 srcpkgs/ppsspp/template | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/srcpkgs/ppsspp/template b/srcpkgs/ppsspp/template
index 2c0ded496eb98..8bf55f65198cd 100644
--- a/srcpkgs/ppsspp/template
+++ b/srcpkgs/ppsspp/template
@@ -1,7 +1,7 @@
 # Template file for 'ppsspp'
 pkgname=ppsspp
 version=1.16.6
-revision=1
+revision=2
 _glslang_commit=b34f619e1c85810dcb3c578107d2e48ba4ee2b37
 _SPIRV_Cross_commit=4212eef67ed0ca048cb726a6767185504e7695e5
 _armips_commit=7bd1ec93d4586985ba1ef420b43b5e620f68695e
@@ -15,7 +15,7 @@ configure_args="-DHEADLESS=1 -DUSE_SYSTEM_FFMPEG=1 -DUNITTEST=ON
  -DUSING_QT_UI=$(vopt_if qt ON OFF) -DUSE_SYSTEM_ZSTD=ON
  -DARMIPS_USE_STD_FILESYSTEM=ON"
 hostmakedepends="pkg-config python3 $(vopt_if qt qt5-host-tools)"
-makedepends="zlib-devel glew-devel ffmpeg-devel libzip-devel
+makedepends="zlib-devel glew-devel ffmpeg4-devel libzip-devel
  snappy-devel rapidjson libpng-devel libzstd-devel
  $(vopt_if sdl2 'SDL2_ttf-devel SDL2-devel') $(vopt_if wayland wayland-devel)
  $(vopt_if qt 'qt5-devel qt5-multimedia-devel')"
@@ -69,10 +69,10 @@ post_extract() {
 	rmdir -v ${wrksrc}/ext/cpu_features
 	mv ${wrksrc}/cpu_features-${_cpu_features_commit} ${wrksrc}/ext/cpu_features
 	rmdir -v ${wrksrc}/ext/rcheevos
-        mv ${wrksrc}/rcheevos-${_rcheevos_commit} ${wrksrc}/ext/rcheevos
+	mv ${wrksrc}/rcheevos-${_rcheevos_commit} ${wrksrc}/ext/rcheevos
 }
 
-post_patch(){
+post_patch() {
 	# disable git versioning
 	vsed -e 's|find_package(Git)|# &|' -i git-version.cmake
 }
@@ -85,7 +85,6 @@ post_configure() {
 }
 
 do_install() {
-	vlicense LICENSE.TXT
 	vinstall icons/icon.svg 644 usr/share/pixmaps ppsspp.svg
 	vinstall Qt/PPSSPP.desktop 644 usr/share/applications
 	vbin build/PPSSPPHeadless ppsspp-headless

From 11375209e81b24688e32daa60b6c14a879beb0a2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 055/113] pqiv: revbump for ffmpeg6

---
 srcpkgs/pqiv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pqiv/template b/srcpkgs/pqiv/template
index 542fc27a2d32a..9308d949b6a1c 100644
--- a/srcpkgs/pqiv/template
+++ b/srcpkgs/pqiv/template
@@ -1,7 +1,7 @@
 # Template file for 'pqiv'
 pkgname=pqiv
 version=2.12
-revision=1
+revision=2
 build_style=gnu-makefile
 hostmakedepends="pkg-config"
 makedepends="glib-devel gtk+3-devel $(vopt_if ffmpeg ffmpeg-devel)

From 977ef291009072702e32b367def2768b0ce2520e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 056/113] qmmp: revbump for ffmpeg6

---
 srcpkgs/qmmp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qmmp/template b/srcpkgs/qmmp/template
index 53781ea3bc28a..2da07f1e87eac 100644
--- a/srcpkgs/qmmp/template
+++ b/srcpkgs/qmmp/template
@@ -1,7 +1,7 @@
 # Template file for 'qmmp'
 pkgname=qmmp
 version=1.6.1
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DUSE_HAL:BOOL=FALSE -DQMMP_DEFAULT_UI:STRING=simple"
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From acb84f917961e7cc3a3e016a68e0844eabe90e78 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 14 Dec 2023 13:28:10 -0500
Subject: [PATCH 057/113] qt6-pdf: revbump for ffmpeg6

---
 srcpkgs/qt6-pdf/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-pdf/template b/srcpkgs/qt6-pdf/template
index ecda84afac131..531b4e1d4fe84 100644
--- a/srcpkgs/qt6-pdf/template
+++ b/srcpkgs/qt6-pdf/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-pdf'
 pkgname=qt6-pdf
 version=6.6.0
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DQT_FEATURE_qtpdf_build=ON
  -DQT_FEATURE_qtpdf_widgets_build=ON

From d4558524b71ba7da5d4d31da867567caafb426b9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 058/113] qt5-webengine: revbump for ffmpeg6

---
 .../chromium-media-filters-cpp14.patch        |  11 ++
 srcpkgs/qt5-webengine/patches/ffmpeg5.patch   | 179 ++++++++++++++++++
 .../qtwebengine-fix-ffmpeg5-build.patch       |  14 ++
 srcpkgs/qt5-webengine/template                |   4 +-
 4 files changed, 206 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/ffmpeg5.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch

diff --git a/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
new file mode 100644
index 0000000000000..04adc540f2cbc
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
@@ -0,0 +1,11 @@
+--- a/src/3rdparty/chromium/media/filters/BUILD.gn	2023-02-27 13:32:59.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/BUILD.gn	2023-04-02 17:21:39.204066384 -0400
+@@ -96,6 +96,8 @@
+     "//ui/gfx/geometry:geometry",
+   ]
+ 
++  cflags_cc = [ "-std=c++14" ]
++
+   libs = []
+ 
+   if (proprietary_codecs) {
diff --git a/srcpkgs/qt5-webengine/patches/ffmpeg5.patch b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..ac55e1634423a
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
@@ -0,0 +1,179 @@
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:57.732547446 -0400
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:09.486478995 -0400
+@@ -57,6 +57,8 @@
+ 
+ namespace {
+ 
++constexpr int64_t kRelativeTsBase = static_cast<int64_t>(0x7ffeffffffffffff);
++
+ void SetAVStreamDiscard(AVStream* stream, AVDiscard discard) {
+   DCHECK(stream);
+   stream->discard = discard;
+@@ -90,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+   if (stream->start_time != kNoFFmpegTimestamp)
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (stream->first_dts != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, stream->first_dts);
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -408,11 +398,11 @@
+   scoped_refptr<DecoderBuffer> buffer;
+ 
+   if (type() == DemuxerStream::TEXT) {
+-    int id_size = 0;
++    size_t id_size = 0;
+     uint8_t* id_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
+ 
+-    int settings_size = 0;
++    size_t settings_size = 0;
+     uint8_t* settings_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
+ 
+@@ -424,7 +414,7 @@
+     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
+                                      side_data.data(), side_data.size());
+   } else {
+-    int side_data_size = 0;
++    size_t side_data_size = 0;
+     uint8_t* side_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
+ 
+@@ -485,7 +475,7 @@
+                                        packet->size - data_offset);
+     }
+ 
+-    int skip_samples_size = 0;
++    size_t skip_samples_size = 0;
+     const uint32_t* skip_samples_ptr =
+         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
+             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
+@@ -1587,6 +1577,8 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++      continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+       lowest_start_time_stream = stream.get();
+@@ -1604,6 +1596,8 @@
+     if (stream && stream->type() == DemuxerStream::VIDEO &&
+         stream->IsEnabled()) {
+       video_stream = stream.get();
++      if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++        continue;
+       if (video_stream->start_time() <= seek_time) {
+         return video_stream;
+       }
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h qtwebengine-5.15.10/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h
+--- a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-07-11 22:12:47.917192788 -0500
+@@ -29,6 +29,7 @@ extern "C" {
+ #include <libavformat/avformat.h>
+ #include <libavformat/avio.h>
+ #include <libavutil/avutil.h>
++#include <libavutil/channel_layout.h>
+ #include <libavutil/imgutils.h>
+ #include <libavutil/log.h>
+ #include <libavutil/mastering_display_metadata.h>
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/audio_file_reader.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/audio_file_reader.cc
+--- a/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -85,7 +85,7 @@ bool AudioFileReader::OpenDemuxer() {
+ }
+ 
+ bool AudioFileReader::OpenDecoder() {
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (codec) {
+     // MP3 decodes to S16P which we don't support, tell it to use S16 instead.
+     if (codec_context_->sample_fmt == AV_SAMPLE_FMT_S16P)
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -329,7 +329,7 @@ bool FFmpegAudioDecoder::ConfigureDecode
+     }
+   }
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec ||
+       avcodec_open2(codec_context_.get(), codec, &codec_options) < 0) {
+     DLOG(ERROR) << "Could not initialize audio decoder: "
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -59,7 +59,6 @@ static int64_t AVIOSeekOperation(void* o
+ }
+ 
+ void FFmpegGlue::InitializeFFmpeg() {
+-  av_register_all();
+ }
+ 
+ static void LogContainer(bool is_local_file,
+@@ -95,9 +94,6 @@ FFmpegGlue::FFmpegGlue(FFmpegURLProtocol
+   // Enable fast, but inaccurate seeks for MP3.
+   format_context_->flags |= AVFMT_FLAG_FAST_SEEK;
+ 
+-  // Ensures we can read out various metadata bits like vp8 alpha.
+-  format_context_->flags |= AVFMT_FLAG_KEEP_SIDE_DATA;
+-
+   // Ensures format parsing errors will bail out. From an audit on 11/2017, all
+   // instances were real failures. Solves bugs like http://crbug.com/710791.
+   format_context_->error_recognition |= AV_EF_EXPLODE;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -391,7 +391,7 @@ bool FFmpegVideoDecoder::ConfigureDecode
+   if (decode_nalus_)
+     codec_context_->flags2 |= AV_CODEC_FLAG2_CHUNKS;
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
+     ReleaseFFmpegResources();
+     return false;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/media_file_checker.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/media_file_checker.cc
+--- a/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -68,7 +68,7 @@ bool MediaFileChecker::Start(base::TimeD
+       auto context = AVStreamToAVCodecContext(format_context->streams[i]);
+       if (!context)
+         continue;
+-      AVCodec* codec = avcodec_find_decoder(cp->codec_id);
++      const AVCodec* codec = avcodec_find_decoder(cp->codec_id);
+       if (codec && avcodec_open2(context.get(), codec, nullptr) >= 0) {
+         auto loop = std::make_unique<FFmpegDecodingLoop>(context.get());
+         stream_contexts[i] = {std::move(context), std::move(loop)};
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc qtwebengine-5.15.10/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc
+--- a/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -203,7 +203,7 @@ int32_t H264DecoderImpl::InitDecode(cons
+   // a pointer |this|.
+   av_context_->opaque = this;
+ 
+-  AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
+   if (!codec) {
+     // This is an indication that FFmpeg has not been initialized or it has not
+     // been compiled/initialized with the correct set of codecs.
diff --git a/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch b/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch
new file mode 100644
index 0000000000000..bc24d5b9a29cb
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch
@@ -0,0 +1,14 @@
+--- a/src/buildtools/configure.json	2023-12-09 11:06:01.503058569 -0500
++++ b/src/buildtools/configure.json	2023-12-09 11:06:14.982361345 -0500
+@@ -779,11 +779,6 @@
+             "type": "warning",
+             "condition": "config.ios && config.simulator && config.device && features.build-qtpdf",
+             "message": "Building fat libray with device and simulator architectures will disable NEON."
+-        },
+-        {
+-            "type": "fatal",
+-            "condition": "features.webengine-system-ffmpeg && !libs.webengine-ffmpeg-support",
+-            "message": "Unmodified ffmpeg >= 5.0 is not supported. Please configure with -qt-webengine-ffmpeg."
+         }
+     ],
+     "summary": [
diff --git a/srcpkgs/qt5-webengine/template b/srcpkgs/qt5-webengine/template
index 8d2df1b5175ba..1687a77eb8a2f 100644
--- a/srcpkgs/qt5-webengine/template
+++ b/srcpkgs/qt5-webengine/template
@@ -1,14 +1,14 @@
 # Template file for 'qt5-webengine'
 pkgname=qt5-webengine
 version=5.15.16
-revision=1
+revision=2
 _version="${version}-lts"
 _chromium_commit=207c2ac45ca3386d153770c6b0d2ea2ec21ca880
 archs="x86_64* i686* armv[67]* ppc64* aarch64*"
 create_wrksrc=yes
 build_style=qmake
 configure_args="--
- -webengine-icu -webengine-ffmpeg -webengine-opus -webengine-webp
+ -webengine-icu -system-ffmpeg -webengine-opus -webengine-webp
  -webengine-pepper-plugins -webengine-printing-and-pdf -webengine-proprietary-codecs
  -webengine-pulseaudio -webengine-spellchecker -webengine-webrtc -webengine-geolocation
  -webengine-kerberos -no-webengine-embedded-build $(vopt_if sndio '' '-no')-webengine-sndio

From df8d5c8d3cf7d88316cd6b61099ffc491ca50999 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 059/113] qt5: revbump for ffmpeg6

---
 srcpkgs/qt5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5/template b/srcpkgs/qt5/template
index ef6e437e02dbc..6f6aacb663b26 100644
--- a/srcpkgs/qt5/template
+++ b/srcpkgs/qt5/template
@@ -3,9 +3,9 @@
 # revbump libqtxdg after bumping patch version
 pkgname=qt5
 version=5.15.11+20231124
+revision=2
 # commit 4765fa1df7a837db9c1f89c4da0dd76b74bb5fab
 # base repo: https://invent.kde.org/qt/qt/qt5
-revision=1
 build_style=meta
 hostmakedepends="cmake clang flex perl glib-devel pkg-config
  python3 re2c ruby which"

From 1f864f70ab531c4c0d5d0ffb3bfe201fb2398f87 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 060/113] qtav: revbump for ffmpeg4

---
 srcpkgs/qtav/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtav/template b/srcpkgs/qtav/template
index 775d5a139a9ef..aa69e213c984b 100644
--- a/srcpkgs/qtav/template
+++ b/srcpkgs/qtav/template
@@ -1,10 +1,10 @@
 # Template file for 'qtav'
 pkgname=qtav
 version=1.13.0
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel libass-devel libopenal-devel
+makedepends="ffmpeg4-devel libass-devel libopenal-devel
  libva-glx-devel libXv-devel pulseaudio-devel
  qt5-declarative-devel qt5-svg-devel
  qt5-quickcontrols"

From 9b055f582742cc80b3f156364dda88a618ddeabc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 061/113] retroarch: revbump for ffmpeg6

---
 srcpkgs/retroarch/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroarch/template b/srcpkgs/retroarch/template
index cb3125c5dbf1a..c65c26f7bf033 100644
--- a/srcpkgs/retroarch/template
+++ b/srcpkgs/retroarch/template
@@ -1,7 +1,7 @@
 # Template file for 'retroarch'
 pkgname=retroarch
 version=1.16.0.3
-revision=3
+revision=4
 build_style=configure
 configure_args="--prefix=/usr --sysconfdir=/etc --enable-networking
  --enable-udev --disable-builtinflac --disable-builtinglslang

From 1446a8aa1ce3ca44bb960a7c690e26bf2e4326ae Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 062/113] scrcpy: revbump for ffmpeg6

---
 srcpkgs/scrcpy/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/scrcpy/template b/srcpkgs/scrcpy/template
index ac18bc03418ce..f39a7f678ab35 100644
--- a/srcpkgs/scrcpy/template
+++ b/srcpkgs/scrcpy/template
@@ -1,7 +1,7 @@
 # Template file for 'scrcpy'
 pkgname=scrcpy
 version=2.1.1
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcompile_server=false
  -Dprebuilt_server=/usr/share/scrcpy/scrcpy-server-v${version}"

From da666e6ee0b1404c0dd477a40b24d4888553b77c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 17 Oct 2023 08:54:11 -0400
Subject: [PATCH 063/113] New package: spex-x replaces spek-alternative for
 ffmpeg6

---
 srcpkgs/spek-alternative                      |  1 +
 srcpkgs/{spek-alternative => spek-x}/template | 22 ++++++++++++-------
 2 files changed, 15 insertions(+), 8 deletions(-)
 create mode 120000 srcpkgs/spek-alternative
 rename srcpkgs/{spek-alternative => spek-x}/template (52%)

diff --git a/srcpkgs/spek-alternative b/srcpkgs/spek-alternative
new file mode 120000
index 0000000000000..76648236da701
--- /dev/null
+++ b/srcpkgs/spek-alternative
@@ -0,0 +1 @@
+spek-x
\ No newline at end of file
diff --git a/srcpkgs/spek-alternative/template b/srcpkgs/spek-x/template
similarity index 52%
rename from srcpkgs/spek-alternative/template
rename to srcpkgs/spek-x/template
index d7b55c776b1d4..3ded6c2c323e4 100644
--- a/srcpkgs/spek-alternative/template
+++ b/srcpkgs/spek-x/template
@@ -1,18 +1,18 @@
-# Template file for 'spek-alternative'
-pkgname=spek-alternative
-version=0.8.2.3
-revision=2
+# Template file for 'spek-x'
+pkgname=spek-x
+version=0.9.3
+revision=1
 build_style=gnu-configure
 hostmakedepends="automake gettext-devel intltool libtool pkg-config
  wxWidgets-common wxWidgets-gtk3-devel"
 makedepends="ffmpeg-devel wxWidgets-gtk3-devel"
 depends="ffmpeg"
 short_desc="Acoustic spectrum analyser"
-maintainer="Kartik Singh <kartik.ynwa@gmail.com>"
+maintainer="zlice <zlice555@gmail.com>"
 license="GPL-3.0-or-later"
-homepage="https://github.com/withmorten/spek-alternative"
-distfiles="https://github.com/withmorten/spek-alternative/archive/${version}.tar.gz"
-checksum="007ba4b84a310b078e378aa84c8e80783db5821437a757a488c3ecec377e6b2a"
+homepage="https://github.com/MikeWang000000/spek-x"
+distfiles="https://github.com/MikeWang000000/spek-x/archive/v${version}.tar.gz"
+checksum="7f4b109903333cdd310ab2b9176f0dc49a565891376e281a233d342cedf90ef7"
 
 CXXFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
 
@@ -22,3 +22,9 @@ export WX_CONFIG_NAME="wx-config-gtk3"
 pre_configure() {
 	NOCONFIGURE=1 ./autogen.sh
 }
+
+spek-alternative_package() {
+	depends="spek-x"
+	short_desc+=" - transitional dummy package"
+	build_style=meta
+}

From 32f8ac617bc7494a31b5256a578e2248bfbb67c4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 064/113] ssr: revbump for ffmpeg4

---
 srcpkgs/ssr/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/ssr/template b/srcpkgs/ssr/template
index 3097754e3cbe5..6609c16c4ed8e 100644
--- a/srcpkgs/ssr/template
+++ b/srcpkgs/ssr/template
@@ -1,11 +1,11 @@
 # Template file for 'ssr'
 pkgname=ssr
 version=0.4.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DWITH_QT5=ON"
 hostmakedepends="pkg-config"
-makedepends="alsa-lib-devel ffmpeg-devel glu-devel jack-devel pulseaudio-devel
+makedepends="alsa-lib-devel ffmpeg4-devel glu-devel jack-devel pulseaudio-devel
  qt5-tools-devel qt5-x11extras-devel libXinerama-devel v4l-utils-devel"
 depends="desktop-file-utils hicolor-icon-theme"
 short_desc="Simple Screen Recorder for programs and games"

From 312e0b48380799c1c2253c47c646a0e3a8f699dd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 065/113] synfig: revbump for ffmpeg6 and mlt7

---
 srcpkgs/synfig/patches/ffmpeg6.patch | 71 ++++++++++++++++++++++++++++
 srcpkgs/synfig/template              |  6 +--
 2 files changed, 74 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/synfig/patches/ffmpeg6.patch

diff --git a/srcpkgs/synfig/patches/ffmpeg6.patch b/srcpkgs/synfig/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..10780b42782f4
--- /dev/null
+++ b/srcpkgs/synfig/patches/ffmpeg6.patch
@@ -0,0 +1,71 @@
+--- a/src/modules/mod_libavcodec/trgt_av.cpp	2022-10-25 09:14:12.000000000 -0400
++++ b/src/modules/mod_libavcodec/trgt_av.cpp	2023-05-05 21:34:17.899194559 -0400
+@@ -38,6 +41,7 @@
+ extern "C"
+ {
+ #ifdef HAVE_LIBAVFORMAT_AVFORMAT_H
++#	include <libavcodec/avcodec.h>
+ #	include <libavformat/avformat.h>
+ #elif defined(HAVE_AVFORMAT_H)
+ #	include <avformat.h>
+@@ -155,11 +156,11 @@
+     }
+ 
+ 	bool open_video_stream() {
+-		if (avcodec_open2(video_context, NULL, NULL) < 0) {
++		if (avcodec_open2(video_context, nullptr, nullptr) < 0) {
+ 			synfig::error("Target_LibAVCodec: could not open video codec");
+ 			// seems the calling of avcodec_free_context after error will cause crash
+ 			// so just forget about this context
+-			video_context = NULL;
++			video_context = nullptr;
+ 			close();
+ 			return false;
+         }
+@@ -234,15 +235,21 @@
+ 		close();
+ 
+ 		if (!av_registered) {
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 			av_register_all();
++#endif
+ 			av_registered = true;
+ 		}
+ 
+ 		// guess format
+-		AVOutputFormat *format = av_guess_format(NULL, filename.c_str(), NULL);
++#if LIBAVCODEC_VERSION_MAJOR < 59 // FFMPEG < 5.0
++		AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#else
++		const AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#endif
+ 		if (!format) {
+ 			synfig::warning("Target_LibAVCodec: unable to guess the output format, defaulting to MPEG");
+-			format = av_guess_format("mpeg", NULL, NULL);
++			format = av_guess_format("mpeg", nullptr, nullptr);
+ 		}
+ 		if (!format) {
+ 			synfig::error("Target_LibAVCodec: unable to find 'mpeg' output format");
+@@ -254,6 +261,7 @@
+ 		context = avformat_alloc_context();
+ 		assert(context);
+ 		context->oformat = format;
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 		if (filename.size() + 1 > sizeof(context->filename)) {
+ 			synfig::error(
+ 				"Target_LibAVCodec: filename too long, max length is %d, filename is '%s'",
+@@ -263,6 +271,14 @@
+ 			return false;
+ 		}
+ 		memcpy(context->filename, filename.c_str(), filename.size() + 1);
++#else
++		context->url = av_strndup(filename.c_str(), filename.size());
++		if (!context->url) {
++			synfig::error("Target_LibAVCodec: cannot allocate space for filename");
++			close();
++			return false;
++		}
++#endif
+ 
+ 		packet = av_packet_alloc();
+ 		assert(packet);
diff --git a/srcpkgs/synfig/template b/srcpkgs/synfig/template
index d4d3e341a20bf..828b5cb32956e 100644
--- a/srcpkgs/synfig/template
+++ b/srcpkgs/synfig/template
@@ -2,11 +2,11 @@
 # Should be kept in sync with 'synfigstudio' and 'ETL'
 pkgname=synfig
 version=1.4.4
-revision=4
+revision=5
 build_style=gnu-configure
 configure_args="--with-boost-libdir=${XBPS_CROSS_BASE}/usr/lib"
 hostmakedepends="boost-build ImageMagick pkg-config intltool"
-makedepends="ETL gettext-devel libxml++-devel mlt-devel libmagick-devel
+makedepends="ETL gettext-devel libxml++-devel mlt7-devel libmagick-devel
  libmng-devel boost-build boost-devel libopenexr-devel ffmpeg-devel"
 depends="ImageMagick"
 short_desc="CLI 2D vector and timeline-based animation software"
@@ -20,7 +20,7 @@ CXXFLAGS="-std=c++11 -DHAVE_LOCALE_H=1"
 
 synfig-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision}
-	 libopenexr-devel libxml++-devel mlt-devel"
+	 libopenexr-devel libxml++-devel mlt7-devel"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/bin/synfig-config

From deee0e37a5f959dd66bb80495a089834ee1178f3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 066/113] timg: revbump for ffmpeg6

---
 srcpkgs/timg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/timg/template b/srcpkgs/timg/template
index 2a2ab763d2fdd..8fb4327535ef9 100644
--- a/srcpkgs/timg/template
+++ b/srcpkgs/timg/template
@@ -1,7 +1,7 @@
 # Template file for 'timg'
 pkgname=timg
 version=1.4.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_OPENSLIDE_SUPPORT=off -Wno-dev"
 hostmakedepends="pkg-config git"

From 73291bf1dda167389331b2d710ded271df8733f9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 067/113] tvheadend: revbump for ffmpeg4

---
 srcpkgs/tvheadend/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tvheadend/template b/srcpkgs/tvheadend/template
index 9aea7de4ec705..012d31c4879ff 100644
--- a/srcpkgs/tvheadend/template
+++ b/srcpkgs/tvheadend/template
@@ -8,7 +8,7 @@ configure_args="--enable-dvbscan --disable-ffmpeg_static
 --disable-libx265_static --disable-libvpx_static --disable-libtheora_static
 --disable-libvorbis_static --disable-libfdkaac_static"
 hostmakedepends="gettext pkg-config python3 git which"
-makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg-devel"
+makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg4-devel"
 short_desc="TV streaming server"
 maintainer="lemmi <lemmi@nerd2nerd.org>"
 license="GPL-3.0-only"

From e538439daaad316b8da6f9816fe6db62196d65e5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 068/113] unpaper: update to 7.0.0.

---
 srcpkgs/unpaper/template | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/srcpkgs/unpaper/template b/srcpkgs/unpaper/template
index 38ed47a584016..1ff910e722afc 100644
--- a/srcpkgs/unpaper/template
+++ b/srcpkgs/unpaper/template
@@ -1,13 +1,13 @@
 # Template file for 'unpaper'
 pkgname=unpaper
-version=6.1
-revision=3
-build_style=gnu-configure
+version=7.0.0
+revision=1
+build_style=meson
+hostmakedepends="pkg-config meson libxslt"
+makedepends="ffmpeg-devel python3-Sphinx"
+short_desc="Post-processing tool for scanned sheets of paper"
 maintainer="Orphaned <orphan@voidlinux.org>"
-hostmakedepends="pkg-config libxslt"
-makedepends="ffmpeg-devel"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://www.flameeyes.eu/projects/unpaper"
-short_desc="A post-processing tool for scanned sheets of paper"
 distfiles="https://www.flameeyes.eu/files/${pkgname}-${version}.tar.xz"
-checksum=237c84f5da544b3f7709827f9f12c37c346cdf029b1128fb4633f9bafa5cb930
+checksum=2575fbbf26c22719d1cb882b59602c9900c7f747118ac130883f63419be46a80

From fd2c9ad0d001f650fb43596378d7017d49795d8e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 069/113] vice: revbump for ffmpeg4

---
 srcpkgs/vice/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/vice/template b/srcpkgs/vice/template
index b1f866d35095e..43f79243a1da1 100644
--- a/srcpkgs/vice/template
+++ b/srcpkgs/vice/template
@@ -1,7 +1,7 @@
 # Template file for 'vice'
 pkgname=vice
 version=3.7.1
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="
 	$(vopt_enable sdl2 sdlui2)
@@ -26,7 +26,7 @@ makedepends="
 	$(vopt_if gtk3 gtk+3-devel)
 	$(vopt_if gtk3 pulseaudio-devel)
 	$(vopt_if gtk3 pango-devel)
-	$(vopt_if ffmpeg ffmpeg-devel)"
+	$(vopt_if ffmpeg ffmpeg4-devel)"
 short_desc="Emulator for C64, C128, CBM-II, PET, VIC20, Plus4 and C16"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"

From 6e7b89aacb4a7132e320c8900d987037243a0079 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 070/113] waypipe: revbump for ffmpeg6

---
 srcpkgs/waypipe/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waypipe/template b/srcpkgs/waypipe/template
index 6da88b21bf2a1..4da8058400b58 100644
--- a/srcpkgs/waypipe/template
+++ b/srcpkgs/waypipe/template
@@ -1,7 +1,7 @@
 # Template file for 'waypipe'
 pkgname=waypipe
 version=0.8.6
-revision=1
+revision=2
 build_style=meson
 # lto is off because it causes linking errors in armv6l and armv7l (due to NEON)
 configure_args="-Dwerror=false -Dwith_dmabuf=enabled -Dwith_lz4=enabled

From 4f47b5765de6a05be4079a82ed0c171a0959eccb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 071/113] xpra: revbump for ffmpeg6

---
 srcpkgs/xpra/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xpra/template b/srcpkgs/xpra/template
index 6bfe9be2db650..1eea2962bcb82 100644
--- a/srcpkgs/xpra/template
+++ b/srcpkgs/xpra/template
@@ -1,7 +1,7 @@
 # Template file for 'xpra'
 pkgname=xpra
 version=5.0.4
-revision=1
+revision=2
 build_style=python3-module
 make_build_args="--without-cuda_kernels --without-cuda_rebuild"
 make_install_args="$(vopt_with docs) ${make_build_args}"

From ced5f044f4f06bf382f10763e3ee48f3a529d10c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:07:40 -0400
Subject: [PATCH 072/113] nv-codec-headers: update to 12.0.16.0

---
 srcpkgs/nv-codec-headers/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/nv-codec-headers/template b/srcpkgs/nv-codec-headers/template
index 3d422a61e4891..251e057f826fb 100644
--- a/srcpkgs/nv-codec-headers/template
+++ b/srcpkgs/nv-codec-headers/template
@@ -1,6 +1,6 @@
 # Template file for 'nv-codec-headers'
 pkgname=nv-codec-headers
-version=11.1.5.1
+version=12.0.16.0
 revision=1
 build_style=gnu-makefile
 short_desc="FFmpeg version of headers required to interface with Nvidias codec APIs"
@@ -8,7 +8,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="MIT"
 homepage="http://git.videolan.org/?p=ffmpeg/nv-codec-headers.git"
 distfiles="https://github.com/FFmpeg/nv-codec-headers/archive/n${version}.tar.gz"
-checksum=d095fbd56aa93772471a323be0ebe65504a0f43f06c76a30b6d25da77b06ae9c
+checksum=2a1533b65f55f9da52956faf0627ed3b74868ac0c7f269990edd21369113b48f
 
 post_install() {
 	sed -n '4,25p' include/ffnvcodec/nvEncodeAPI.h > LICENSE

From 9931d187d6c6069cca749426cf7993229a0966ea Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:08:40 -0400
Subject: [PATCH 073/113] openimagedenoise: revbump for ffmpeg6

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index b792813dba7c2..109deb171c3f7 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,7 +1,7 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
 version=1.4.3
-revision=1
+revision=2
 archs="x86_64*"
 build_style=cmake
 hostmakedepends="ispc python3"

From 2191d862ff3ff7d69491b8cd1f7fa75bfc83ce8d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:31:45 -0400
Subject: [PATCH 074/113] shotcut: revbump for ffmpeg6

---
 srcpkgs/shotcut/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/shotcut/template b/srcpkgs/shotcut/template
index 33141fbd862d7..f46cb53b6bfb9 100644
--- a/srcpkgs/shotcut/template
+++ b/srcpkgs/shotcut/template
@@ -1,7 +1,7 @@
 # Template file for 'shotcut'
 pkgname=shotcut
 version=23.09.29
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSHOTCUT_VERSION=${version}"
 hostmakedepends="pkg-config qt6-tools-devel"

From da743f1030fd47e040abd7fa85c8d9635c2128ce Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:30 -0400
Subject: [PATCH 075/113] shiboken2: revbump for qt5-5.15.11

---
 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch | 1 +
 srcpkgs/shiboken2/template                                 | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
 create mode 120000 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
new file mode 120000
index 0000000000000..efcf3249bd885
--- /dev/null
+++ b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1 @@
+../../python3-pyside2/patches/importlib-machinery-bypass.patch
\ No newline at end of file
diff --git a/srcpkgs/shiboken2/template b/srcpkgs/shiboken2/template
index 883d6a084d868..f3c06ec245a1f 100644
--- a/srcpkgs/shiboken2/template
+++ b/srcpkgs/shiboken2/template
@@ -1,7 +1,7 @@
 # Template file for 'shiboken2'
 pkgname=shiboken2
 version=5.15.10
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/shiboken2"
 build_style=cmake

From ccf9910206eef95db2d9fa014380dd7d3a439507 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:53 -0400
Subject: [PATCH 076/113] python3-pyside2: revbump for qt5-5.15.11

---
 .../patches/importlib-machinery-bypass.patch      | 15 +++++++++++++++
 srcpkgs/python3-pyside2/template                  |  2 +-
 2 files changed, 16 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
new file mode 100644
index 0000000000000..64c429584776b
--- /dev/null
+++ b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1,15 @@
+Using this prevents an error around line 220 below it.
+"AttributeError: module 'importlib' has no attribute 'machinery'"
+The old backup logic is in place and compiles without issues.
+--- a/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:09:34.688912402 -0400
++++ b/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:10:03.395529582 -0400
+@@ -170,9 +170,6 @@
+
+     # 'zipstring_sequence' comes from signature.cpp
+     zipbytes = base64.b64decode(''.join(zipstring_sequence))
+-    if sys.version_info[0] >= 3:
+-        vzip = zipfile.ZipFile(io.BytesIO(zipbytes))
+-        return sys.meta_path, EmbeddableZipImporter(vzip)
+
+     # Old version for Python 2.7, only.
+     import os
diff --git a/srcpkgs/python3-pyside2/template b/srcpkgs/python3-pyside2/template
index 249efa9098842..52626436ce75f 100644
--- a/srcpkgs/python3-pyside2/template
+++ b/srcpkgs/python3-pyside2/template
@@ -1,7 +1,7 @@
 # Template file for 'python3-pyside2'
 pkgname=python3-pyside2
 version=5.15.10
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/pyside2"
 build_style=cmake

From 4de8bd9f0e4af8f1e3f4baf431022cdaa10dc9d1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:35 -0400
Subject: [PATCH 077/113] konqueror: revbump for ffmpeg6

---
 srcpkgs/konqueror/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/konqueror/template b/srcpkgs/konqueror/template
index 044dafa605ba6..63dd01fafc780 100644
--- a/srcpkgs/konqueror/template
+++ b/srcpkgs/konqueror/template
@@ -1,11 +1,11 @@
 # Template file for 'konqueror'
 pkgname=konqueror
 version=23.08.4
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DDESKTOPTOJSON_EXECUTABLE=/usr/bin/desktoptojson"
 hostmakedepends="extra-cmake-modules python3 qt5-host-tools qt5-qmake kdoctools
-kcoreaddons kconfig gettext"
+ kcoreaddons kconfig gettext"
 makedepends="qt5-devel qt5-webengine-devel qt5-declarative-devel
  qt5-webchannel-devel qt5-location-devel kcmutils-devel kdelibs4support-devel
  karchive-devel khtml-devel kdesu-devel kactivities5-devel"

From 0420ac1abcd3cd9b56b077643d59238b71070358 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:58 -0400
Subject: [PATCH 078/113] qt5-speech: revbump for qt5-5.15.11

---
 srcpkgs/qt5-speech/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-speech/template b/srcpkgs/qt5-speech/template
index 1228bb60c41db..27a7da1dbdb91 100644
--- a/srcpkgs/qt5-speech/template
+++ b/srcpkgs/qt5-speech/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-speech'
 pkgname=qt5-speech
 version=5.15.11
-revision=1
+revision=2
 _commit=d32f4a479d38a11f547598004b975f4356424a16
 build_style=qmake
 configure_args="-- -flite -flite-alsa -speechd"

From c84c7a80b7299795e29e34c86b12a7c8982d3399 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Jun 2023 08:20:22 -0400
Subject: [PATCH 079/113] gtk4: revbump for ffmpeg6

---
 srcpkgs/gtk4/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gtk4/template b/srcpkgs/gtk4/template
index d8ee60abe06f7..55bff6e33849a 100644
--- a/srcpkgs/gtk4/template
+++ b/srcpkgs/gtk4/template
@@ -1,7 +1,7 @@
 # Template file for 'gtk4'
 pkgname=gtk4
 version=4.12.3
-revision=1
+revision=2
 build_style=meson
 build_helper="gir"
 configure_args="-Dman-pages=true -Ddocumentation=true -Dbuild-tests=false

From b2055b4e67c9dde8d5bfdbb24d6eea25cf15fd14 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:28:26 -0400
Subject: [PATCH 080/113] siril: revbump for ffmpeg6

---
 srcpkgs/siril/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/siril/template b/srcpkgs/siril/template
index 84332f79d060d..62750dd247548 100644
--- a/srcpkgs/siril/template
+++ b/srcpkgs/siril/template
@@ -1,7 +1,7 @@
 # Template file for 'siril'
 pkgname=siril
 version=0.9.12
-revision=10
+revision=11
 build_style=gnu-configure
 hostmakedepends="pkg-config intltool autoconf automake gettext-devel"
 makedepends="fftw-devel libconfig-devel libopencv-devel libffms2-devel

From 4ab0b63c9d0c80b0765c2a6ec3db8059c0857901 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 22 Jun 2023 10:25:02 -0400
Subject: [PATCH 081/113] kdenlive: revbump for ffmpeg6

---
 srcpkgs/kdenlive/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kdenlive/template b/srcpkgs/kdenlive/template
index a0f3615c9c530..d63166f95c4d7 100644
--- a/srcpkgs/kdenlive/template
+++ b/srcpkgs/kdenlive/template
@@ -1,7 +1,7 @@
 # Template file for 'kdenlive'
 pkgname=kdenlive
 version=23.08.4
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="
  extra-cmake-modules kconfig kcoreaddons kdoctools pkg-config python3

From fac1d93681d30319e0da8dbda327cc8cbd9b42b8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:20:59 -0400
Subject: [PATCH 082/113] tracker-miners: revbump for ffmpeg6

---
 srcpkgs/tracker-miners/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tracker-miners/template b/srcpkgs/tracker-miners/template
index 0b97f47489f81..f196d2bf9e4a4 100644
--- a/srcpkgs/tracker-miners/template
+++ b/srcpkgs/tracker-miners/template
@@ -1,7 +1,7 @@
 # Template file for 'tracker-miners'
 pkgname=tracker-miners
 version=3.6.1
-revision=1
+revision=2
 build_style=meson
 build_helper=qemu
 # missing libgrss for miner_rss

From 965226c60696128d15f0f94d45485333165df41f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:21:21 -0400
Subject: [PATCH 083/113] mpd: revbump for ffmpeg6

---
 srcpkgs/mpd/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpd/template b/srcpkgs/mpd/template
index 4fd32b7be8c53..b8e2bd4c1b59c 100644
--- a/srcpkgs/mpd/template
+++ b/srcpkgs/mpd/template
@@ -1,7 +1,7 @@
 # Template file for 'mpd'
 pkgname=mpd
 version=0.23.15
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dopus=enabled -Dmikmod=enabled -Dneighbor=true
  -Dsoundcloud=enabled -Dpipe=true -Dtwolame=enabled -Dbzip2=enabled

From b569aa810f0d717050a1c53f3433ae764257bb66 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:02 -0400
Subject: [PATCH 084/113] tg_owt: revbump for ffmpeg6

---
 srcpkgs/tg_owt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tg_owt/template b/srcpkgs/tg_owt/template
index aee8d35d08ffb..34e8fef054056 100644
--- a/srcpkgs/tg_owt/template
+++ b/srcpkgs/tg_owt/template
@@ -1,7 +1,7 @@
 # Template file for 'tg_owt'
 pkgname=tg_owt
 version=0.0.0.20231221
-revision=1
+revision=2
 _commit=afd9d5d31798d3eacf9ed6c30601e91d0f1e4d60
 _libyuv_commit=04821d1e7d60845525e8db55c7bcd41ef5be9406
 _abseil_commit=8c0b94e793a66495e0b1f34a5eb26bd7dc672db0

From a54d92288f96e48ce6d5929a671ad75add958590 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:44 -0400
Subject: [PATCH 085/113] telegram-desktop: revbump for ffmpeg6

---
 srcpkgs/telegram-desktop/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/telegram-desktop/template b/srcpkgs/telegram-desktop/template
index d00b273b7b738..d20b87b5182db 100644
--- a/srcpkgs/telegram-desktop/template
+++ b/srcpkgs/telegram-desktop/template
@@ -1,7 +1,7 @@
 # Template file for 'telegram-desktop'
 pkgname=telegram-desktop
 version=4.14.9
-revision=1
+revision=2
 build_style=cmake
 build_helper="qemu gir"
 configure_args="-DTDESKTOP_API_ID=209235

From 25d95fd8cd45acab7e685eeadeb810a7f45126c9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:11:45 -0400
Subject: [PATCH 086/113] gst-plugins-bad1: revbump for ffmpeg6

---
 srcpkgs/gst-plugins-bad1/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index 63200e74f99a7..644758cb187a1 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-plugins-bad1'
 pkgname=gst-plugins-bad1
 version=1.22.9
-revision=1
+revision=2
 build_helper="gir"
 build_style=meson
 configure_args="-Dpackage-origin=https://voidlinux.org -Ddoc=disabled

From 43b70726e0c2c9bc02040ac34e51d8c861a81556 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:12:09 -0400
Subject: [PATCH 087/113] openmw: revbump for ffmpeg6

---
 srcpkgs/openmw/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openmw/template b/srcpkgs/openmw/template
index 0abf5ff7cdbec..b57180f1a4446 100644
--- a/srcpkgs/openmw/template
+++ b/srcpkgs/openmw/template
@@ -1,7 +1,7 @@
 # Template file for 'openmw'
 pkgname=openmw
 version=0.48.0
-revision=2
+revision=3
 build_style=cmake
 _recast_commit=e75adf86f91eb3082220085e42dda62679f9a3ea
 _bullet_tag=3.17

From 4847d77efdb6f369cce7749c278091d00aec918a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:14:53 -0400
Subject: [PATCH 088/113] lms: revbump for ffmpeg6

---
 srcpkgs/lms/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/lms/template b/srcpkgs/lms/template
index e358f75902a98..3b21c458de519 100644
--- a/srcpkgs/lms/template
+++ b/srcpkgs/lms/template
@@ -1,7 +1,7 @@
 # Template file for 'lms'
 pkgname=lms
 version=3.42.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="wt-devel ffmpeg-devel boost-devel libconfig++-devel taglib-devel pam-devel libgraphicsmagick-devel gtest-devel libarchive-devel"

From f45ea0dab436df220fb648c5aeb0138248079151 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:18:18 -0400
Subject: [PATCH 089/113] freecad: DELETE

---
 srcpkgs/freecad/patches/001-include.patch     | 112 ------------------
 .../154-revert-gui-tmp-redirect-stderr.patch  |  68 -----------
 ...d63c8c9b1280978be841d04e68a0a55cceb9.patch |  30 -----
 srcpkgs/freecad/template                      |  12 +-
 4 files changed, 7 insertions(+), 215 deletions(-)
 delete mode 100644 srcpkgs/freecad/patches/001-include.patch
 delete mode 100644 srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
 delete mode 100644 srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch

diff --git a/srcpkgs/freecad/patches/001-include.patch b/srcpkgs/freecad/patches/001-include.patch
deleted file mode 100644
index 28b5af54999b9..0000000000000
--- a/srcpkgs/freecad/patches/001-include.patch
+++ /dev/null
@@ -1,112 +0,0 @@
-From 9a41845a417189776741297c50a3827ce292bc4f Mon Sep 17 00:00:00 2001
-From: Uwe <donovaly@users.noreply.github.com>
-Date: Sun, 3 Jul 2022 22:51:16 +0200
-Subject: [PATCH] [Part] OCCError.h: remove unneeded includes
-
-- also sort includes
----
- src/Mod/Part/App/OCCError.h             | 36 +++----------------------
- src/Mod/Part/App/OffsetCurvePyImp.cpp   | 12 ++++-----
- src/Mod/Part/App/OffsetSurfacePyImp.cpp | 10 +++----
- 3 files changed, 12 insertions(+), 46 deletions(-)
-
---- a/src/Mod/Part/App/OCCError.h
-+++ b/src/Mod/Part/App/OCCError.h
-@@ -23,36 +23,8 @@
- #ifndef _OCCError_h_
- #define _OCCError_h_
- 
--# include <Standard_Version.hxx>
- # include <Standard_Failure.hxx>
--# include <Standard_AbortiveTransaction.hxx>
--# include <Standard_ConstructionError.hxx>
--# if OCC_VERSION_HEX >= 0x060500
--# include <Standard_DefineException.hxx>
--# endif
--# include <Standard_DimensionError.hxx>
--# include <Standard_DimensionMismatch.hxx>
--# include <Standard_DivideByZero.hxx>
--# include <Standard_DomainError.hxx>
--# include <Standard_ImmutableObject.hxx>
--# include <Standard_LicenseError.hxx>
--# include <Standard_LicenseNotFound.hxx>
--# include <Standard_MultiplyDefined.hxx>
--# include <Standard_NegativeValue.hxx>
--# include <Standard_NoMoreObject.hxx>
--# include <Standard_NoSuchObject.hxx>
--# include <Standard_NotImplemented.hxx>
--# include <Standard_NullObject.hxx>
--# include <Standard_NullValue.hxx>
--# include <Standard_NumericError.hxx>
--# include <Standard_OutOfMemory.hxx>
--# include <Standard_OutOfRange.hxx>
--# include <Standard_Overflow.hxx>
--# include <Standard_ProgramError.hxx>
--# include <Standard_RangeError.hxx>
--# include <Standard_TooManyUsers.hxx>
--# include <Standard_TypeMismatch.hxx>
--# include <Standard_Underflow.hxx>
-+# include <Standard_Version.hxx>
- 
- #include <Mod/Part/PartGlobal.h>
- #include <Base/Console.h>
-@@ -88,4 +60,3 @@ PartExport extern PyObject* PartExceptio
- 
- #define PY_CATCH_OCC _PY_CATCH_OCC(return(NULL))
- #endif  // _OCCError_h_
--
---- a/src/Mod/Part/App/OffsetCurvePyImp.cpp
-+++ b/src/Mod/Part/App/OffsetCurvePyImp.cpp
-@@ -20,20 +20,20 @@
-  *                                                                         *
-  ***************************************************************************/
- 
--
- #include "PreCompiled.h"
- #ifndef _PreComp_
- # include <Geom_OffsetCurve.hxx>
- #endif
- 
--#include "OCCError.h"
--#include "Geometry.h"
-+#include <Base/GeometryPyCXX.h>
-+#include <Base/Vector3D.h>
-+#include <Base/VectorPy.h>
-+
- #include "OffsetCurvePy.h"
- #include "OffsetCurvePy.cpp"
-+#include "Geometry.h"
-+#include "OCCError.h"
- 
--#include <Base/GeometryPyCXX.h>
--#include <Base/VectorPy.h>
--#include <Base/Vector3D.h>
- 
- using namespace Part;
- 
---- a/src/Mod/Part/App/OffsetSurfacePyImp.cpp
-+++ b/src/Mod/Part/App/OffsetSurfacePyImp.cpp
-@@ -20,20 +20,16 @@
-  *                                                                         *
-  ***************************************************************************/
- 
--
- #include "PreCompiled.h"
- #ifndef _PreComp_
- # include <Geom_OffsetSurface.hxx>
- # include <memory>
- #endif
- 
--#include <Base/VectorPy.h>
--#include <Base/Vector3D.h>
--
- #include "OCCError.h"
--#include "Geometry.h"
--#include <Mod/Part/App/OffsetSurfacePy.h>
--#include <Mod/Part/App/OffsetSurfacePy.cpp>
-+#include "OffsetSurfacePy.h"
-+#include "OffsetSurfacePy.cpp"
-+
- 
- using namespace Part;
- 
diff --git a/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch b/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
deleted file mode 100644
index d6a9adabdec83..0000000000000
--- a/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
+++ /dev/null
@@ -1,68 +0,0 @@
-see https://github.com/FreeCAD/FreeCAD/commit/cfe94b00d3434f3e2c8b5114d2909f628c330fa8#commitcomment-71413407
-
-upstream: yes
-
-From 7b377a216b9185960e4cee980a6504dc1a755f50 Mon Sep 17 00:00:00 2001
-From: wmayer <wmayer@users.sourceforge.net>
-Date: Wed, 29 Jun 2022 15:19:18 +0200
-Subject: [PATCH] Gui: remove workaround for spnav 0.23 due to build failure
- with musl libc
-
----
- src/Gui/3Dconnexion/GuiNativeEventLinux.cpp | 27 ---------------------
- 1 file changed, 27 deletions(-)
-
---- a/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp
-+++ b/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp
-@@ -21,42 +21,17 @@
-  ***************************************************************************/
- 
- #include <FCConfig.h>
--#include <cstdio>
- 
- #include "GuiNativeEventLinux.h"
- 
- #include "GuiApplicationNativeEventAware.h"
- #include <Base/Console.h>
--#include <Base/FileInfo.h>
- #include <QMainWindow>
- 
- #include <QSocketNotifier>
- 
- #include <spnav.h>
- 
--namespace {
--class RedirectStdErr
--{
--public:
--    RedirectStdErr()
--        : fi(Base::FileInfo::getTempFileName())
--        , file(stderr)
--    {
--        stderr = fopen(fi.filePath().c_str(), "w");
--    }
--    ~RedirectStdErr()
--    {
--        fclose(stderr);
--        fi.deleteFile();
--        stderr = file;
--    }
--
--private:
--    Base::FileInfo fi;
--    FILE* file;
--};
--}
--
- Gui::GuiNativeEvent::GuiNativeEvent(Gui::GUIApplicationNativeEventAware *app)
- : GuiAbstractNativeEvent(app)
- {
-@@ -72,8 +47,6 @@ Gui::GuiNativeEvent::~GuiNativeEvent()
- 
- void Gui::GuiNativeEvent::initSpaceball(QMainWindow *window)
- {
--    // tmp. redirect stderr to a file to suppress an error message from spnav_open()
--    RedirectStdErr err;
-     Q_UNUSED(window)
-     if (spnav_open() == -1) {
-         Base::Console().Log("Couldn't connect to spacenav daemon. Please ignore if you don't have a spacemouse.\n");
diff --git a/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch b/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch
deleted file mode 100644
index d4acf370ca0a4..0000000000000
--- a/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-From fe02d63c8c9b1280978be841d04e68a0a55cceb9 Mon Sep 17 00:00:00 2001
-From: Roy-043 <70520633+Roy-043@users.noreply.github.com>
-Date: Thu, 29 Dec 2022 23:20:38 +0100
-Subject: [PATCH] Draft: update inspect.getargspec to inspect.getfullargspec
- (#8101)
-
----
- src/Mod/Draft/draftguitools/gui_snapper.py | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
---- a/src/Mod/Draft/draftguitools/gui_snapper.py
-+++ b/src/Mod/Draft/draftguitools/gui_snapper.py
-@@ -1426,7 +1426,7 @@ class Snapper:
-             Gui.Snapper.off()
-             self.ui.offUi()
-             if callback:
--                if len(inspect.getargspec(callback).args) > 1:
-+                if len(inspect.getfullargspec(callback).args) > 1:
-                     obj = None
-                     if self.snapInfo and ("Object" in self.snapInfo) and self.snapInfo["Object"]:
-                         obj = App.ActiveDocument.getObject(self.snapInfo["Object"])
-@@ -1445,7 +1445,7 @@ class Snapper:
-             Gui.Snapper.off()
-             self.ui.offUi()
-             if callback:
--                if len(inspect.getargspec(callback).args) > 1:
-+                if len(inspect.getfullargspec(callback).args) > 1:
-                     callback(None, None)
-                 else:
-                     callback(None)
diff --git a/srcpkgs/freecad/template b/srcpkgs/freecad/template
index c135701e38b9a..7d5165f760bab 100644
--- a/srcpkgs/freecad/template
+++ b/srcpkgs/freecad/template
@@ -1,7 +1,7 @@
 # Template file for 'freecad'
 pkgname=freecad
-version=0.20.2
-revision=7
+version=0.21.1
+revision=2
 build_wrksrc="FreeCAD-${version}"
 build_style=cmake
 pycompile_dirs="usr/lib/${pkgname}/Mod"
@@ -24,8 +24,10 @@ makedepends="python3-devel boost-devel libxerces-c-devel zlib-devel occt-devel
  coin3-devel libshiboken2-devel libspnav-devel pyside2-tools
  liblz4-devel libpyside2-python3-devel python3-matplotlib netcdf-devel
  jsoncpp-devel qt5-devel qt5-svg-devel qt5-tools-devel qt5-webkit-devel
- qt5-xmlpatterns-devel coin3-doc glew-devel python3-pivy"
-depends="python3-matplotlib python3-pyside2-webengine python3-pivy"
+ qt5-xmlpatterns-devel coin3-doc glew-devel python3-pivy qt5-webengine-devel
+ qt5-declarative-devel qt5-webchannel-devel qt5-location-devel"
+depends="python3-matplotlib python3-pyside2-webengine python3-pivy
+ python3-GitPython python3-Markdown"
 short_desc="General purpose 3D CAD modeler"
 maintainer="yopito <pierre.bourgin@free.fr>"
 license="LGPL-2.0-or-later"
@@ -35,7 +37,7 @@ distfiles="
  https://github.com/FreeCAD/FreeCAD/archive/${version}.tar.gz
  ${SOURCEFORGE_SITE}/cxx/pycxx-${_pycxxver}.tar.gz
 "
-checksum="46922f3a477e742e1a89cd5346692d63aebb2b67af887b3e463e094a4ae055da
+checksum="e9b1fd0323f101268c7f3be52db42e4a29222f2e306ae6c4a6fc309cb418d35a
  4b91e1e1141c23fbd5039df635c4bb6e75632168548f56b83ce177193c0c98c6"
 python_version=3
 patch_args="-Np1 -d ${build_wrksrc}"

From 7de578b26208f6e493fb7109469c7b13e7c8cd8e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:47:18 -0400
Subject: [PATCH 090/113] libopenshot: revbump for ffmpeg6

---
 srcpkgs/libopenshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenshot/template b/srcpkgs/libopenshot/template
index 8e57c5f592169..7a8f4520e7892 100644
--- a/srcpkgs/libopenshot/template
+++ b/srcpkgs/libopenshot/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenshot'
 pkgname=libopenshot
 version=0.3.0
-revision=3
+revision=4
 build_style=cmake
 # Builds fail with Ruby-2.4.1
 configure_args="-DENABLE_RUBY=OFF -DUSE_SYSTEM_JSONCPP=ON"

From 22c5f61c80084347453aee7b57ad3476319df375 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:10:30 -0500
Subject: [PATCH 091/113] openimageio: revbump for ffmpeg6

---
 srcpkgs/openimageio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimageio/template b/srcpkgs/openimageio/template
index 3ce3f9e49d350..27d2131bc0a61 100644
--- a/srcpkgs/openimageio/template
+++ b/srcpkgs/openimageio/template
@@ -1,7 +1,7 @@
 # Template file for 'openimageio'
 pkgname=openimageio
 version=2.4.9.0
-revision=7
+revision=8
 build_style=cmake
 build_helper=qemu
 configure_args="-DUSE_QT=0 -DUSE_PYTHON=0 -DOIIO_BUILD_TESTS=0

From f4568239288eb9478f9fc38233a00b4c656b4460 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:11:57 -0500
Subject: [PATCH 092/113] synfigstudio: revbump for ffmpeg6

---
 srcpkgs/synfigstudio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/synfigstudio/template b/srcpkgs/synfigstudio/template
index 09e442da9a680..2bc017cedca6b 100644
--- a/srcpkgs/synfigstudio/template
+++ b/srcpkgs/synfigstudio/template
@@ -2,7 +2,7 @@
 # Should be kept in sync with 'synfig' and 'ETL'
 pkgname=synfigstudio
 version=1.4.4
-revision=4
+revision=5
 build_style=gnu-configure
 configure_args="--disable-update-mimedb"
 hostmakedepends="pkg-config intltool gettext synfig"

From d478a1059e85edc2bdbcc68b38e3dccf2573dcd9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:10 -0500
Subject: [PATCH 093/113] mixxx: revbump for ffmpeg6

---
 srcpkgs/mixxx/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mixxx/template b/srcpkgs/mixxx/template
index 6921996e4e77b..6a79b328c1abf 100644
--- a/srcpkgs/mixxx/template
+++ b/srcpkgs/mixxx/template
@@ -1,7 +1,7 @@
 # Template file for 'mixxx'
 pkgname=mixxx
 version=2.3.3
-revision=6
+revision=7
 build_style=cmake
 configure_args="-DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="extra-cmake-modules pkg-config protobuf qt5-host-tools qt5-qmake"

From 84e101e80de1ef3828f0d4bb0b4a018dfc919998 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:28 -0500
Subject: [PATCH 094/113] musikcube: revbump for ffmpeg6

---
 srcpkgs/musikcube/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/musikcube/template b/srcpkgs/musikcube/template
index 8c4a51840859e..fb60dd2049089 100644
--- a/srcpkgs/musikcube/template
+++ b/srcpkgs/musikcube/template
@@ -1,7 +1,7 @@
 # Template file for 'musikcube'
 pkgname=musikcube
 version=3.0.0
-revision=3
+revision=4
 build_style=cmake
 make_cmd=make
 configure_args="-DNO_NCURSESW=1"

From dc9927c891858e00480c0fb9033a1bf4b3343eb4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:45 -0500
Subject: [PATCH 095/113] electron24: revbump for ffmpeg6

---
 srcpkgs/electron24/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron24/template b/srcpkgs/electron24/template
index 7b4e28812f483..1ca93fde97a85 100644
--- a/srcpkgs/electron24/template
+++ b/srcpkgs/electron24/template
@@ -1,7 +1,7 @@
 # Template file for 'electron24'
 pkgname=electron24
 version=24.3.0
-revision=2
+revision=3
 _nodever=18.14.0
 _chromiumver=112.0.5615.165
 archs="x86_64* aarch64*"

From 982655687030b8a40323ca6c18d3232070cb048a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:00 -0500
Subject: [PATCH 096/113] electron19: revbump for ffmpeg6

---
 srcpkgs/electron19/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron19/template b/srcpkgs/electron19/template
index 0ef959125cb08..5371c0b354604 100644
--- a/srcpkgs/electron19/template
+++ b/srcpkgs/electron19/template
@@ -1,7 +1,7 @@
 # Template file for 'electron19'
 pkgname=electron19
 version=19.0.8
-revision=4
+revision=5
 _nodever=16.14.2
 _chromiumver=102.0.5005.125
 archs="x86_64* aarch64* ppc64le*"

From 9e427d7693f2142c68f13da8f7f85c10b853de29 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:13 -0500
Subject: [PATCH 097/113] wf-recorder: revbump for ffmpeg6

---
 srcpkgs/wf-recorder/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/wf-recorder/template b/srcpkgs/wf-recorder/template
index 08f986b031006..63c45cf4b814d 100644
--- a/srcpkgs/wf-recorder/template
+++ b/srcpkgs/wf-recorder/template
@@ -1,7 +1,7 @@
 # Template file for 'wf-recorder'
 pkgname=wf-recorder
 version=0.4.1
-revision=2
+revision=3
 build_style=meson
 hostmakedepends="pkg-config scdoc wayland-devel"
 makedepends="wayland-protocols wayland-devel ffmpeg-devel libgbm-devel x264-devel

From e537c940a31081a563d7c71a09a00ec997d296b0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:26 -0500
Subject: [PATCH 098/113] obs: revbump for ffmpeg6

---
 srcpkgs/obs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/obs/template b/srcpkgs/obs/template
index b343f1131bfcf..a25a67433e285 100644
--- a/srcpkgs/obs/template
+++ b/srcpkgs/obs/template
@@ -1,7 +1,7 @@
 # Template file for 'obs'
 pkgname=obs
 version=30.0.0
-revision=2
+revision=3
 archs="i686* x86_64* ppc64le* aarch64* riscv64*"
 build_style=cmake
 configure_args="-DOBS_VERSION_OVERRIDE=${version} -DENABLE_JACK=ON

From 467a23397a663ea860ce6d451db6e2e24ca2dfc2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:36 -0500
Subject: [PATCH 099/113] mlt7: revbump for ffmpeg6

---
 srcpkgs/mlt7/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mlt7/template b/srcpkgs/mlt7/template
index 98f302ad3a516..7eb8c00fa1580 100644
--- a/srcpkgs/mlt7/template
+++ b/srcpkgs/mlt7/template
@@ -1,7 +1,7 @@
 # Template file for 'mlt7'
 pkgname=mlt7
 version=7.20.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DSWIG_PYTHON=ON -DMOD_QT6=ON"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which

From b241d252c883e09443a89f53022d6033df8e68cf Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:48 -0500
Subject: [PATCH 100/113] qt6-multimedia: revbump for ffmpeg6

---
 srcpkgs/qt6-multimedia/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-multimedia/template b/srcpkgs/qt6-multimedia/template
index 67a577e1300fe..1da626ecf515a 100644
--- a/srcpkgs/qt6-multimedia/template
+++ b/srcpkgs/qt6-multimedia/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-multimedia'
 pkgname=qt6-multimedia
 version=6.6.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DQT_FEATURE_gstreamer=ON"
 hostmakedepends="perl qt6-declarative-host-tools pkg-config qt6-shadertools"

From 502406f5a1b97d699e51105ba5babf871f9e6296 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:00:15 -0500
Subject: [PATCH 101/113] baresip: revbump for ffmpeg6

---
 srcpkgs/baresip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/baresip/template b/srcpkgs/baresip/template
index 12c8954ef7b9b..b16b67beab8d2 100644
--- a/srcpkgs/baresip/template
+++ b/srcpkgs/baresip/template
@@ -1,7 +1,7 @@
 # Template file for 'baresip'
 pkgname=baresip
 version=3.6.0
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config glib-devel"
 makedepends="libgsm-devel libpng-devel openssl-devel libsndfile-devel

From eae93303ff91cd41f05b84cda01ed6ee256706c9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:30 -0500
Subject: [PATCH 102/113] QMPlay2: revbump for ffmpeg6

---
 srcpkgs/QMPlay2/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/QMPlay2/template b/srcpkgs/QMPlay2/template
index 46c80f64a1349..942258ce60fb7 100644
--- a/srcpkgs/QMPlay2/template
+++ b/srcpkgs/QMPlay2/template
@@ -1,7 +1,7 @@
 # Template file for 'QMPlay2'
 pkgname=QMPlay2
 version=23.10.22
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools"
 makedepends="alsa-lib-devel ffmpeg-devel libass-devel libcdio-devel libgme-devel

From ba392c5ef101ce3b270f949ca3b5c2b3c7280ddc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:34 -0500
Subject: [PATCH 103/113] alsa-plugins: revbump for ffmpeg6

---
 srcpkgs/alsa-plugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/alsa-plugins/template b/srcpkgs/alsa-plugins/template
index a5708a7d82a8f..7bfdad046c483 100644
--- a/srcpkgs/alsa-plugins/template
+++ b/srcpkgs/alsa-plugins/template
@@ -1,7 +1,7 @@
 # Template file for 'alsa-plugins'
 pkgname=alsa-plugins
 version=1.2.7.1
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--disable-maemo-plugin"
 hostmakedepends="pkg-config"

From 7905af6a1571c231dfd849c5a45cdf98704933d1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:43 -0500
Subject: [PATCH 104/113] minidlna: revbump for ffmpeg6

---
 srcpkgs/minidlna/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/minidlna/template b/srcpkgs/minidlna/template
index 5fa929f3a0c12..742991ecd04af 100644
--- a/srcpkgs/minidlna/template
+++ b/srcpkgs/minidlna/template
@@ -1,7 +1,7 @@
 # Template file for 'minidlna'
 pkgname=minidlna
 version=1.3.3
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="
  --sbindir=/usr/bin

From 100cac184e5aed7b220c5dd45c57a93d69c6e3ed Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 17:57:47 -0500
Subject: [PATCH 105/113] mpv: revbump for ffmpeg6

---
 srcpkgs/mpv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpv/template b/srcpkgs/mpv/template
index 4948d1e332cb8..1ac1b167af189 100644
--- a/srcpkgs/mpv/template
+++ b/srcpkgs/mpv/template
@@ -1,7 +1,7 @@
 # Template file for 'mpv'
 pkgname=mpv
 version=0.36.0
-revision=4
+revision=5
 build_style=meson
 configure_args="-Dcdda=enabled -Ddvbin=enabled -Ddvdnav=enabled
  -Dlibmpv=true -Dcplugins=enabled

From 04f85b307295077256089d553733a8dc1ca3cf6d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 17:59:29 -0500
Subject: [PATCH 106/113] qimgv: revbump for ffmpeg6

---
 srcpkgs/qimgv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qimgv/template b/srcpkgs/qimgv/template
index dd341dfe1bfce..8a7e1c081ef12 100644
--- a/srcpkgs/qimgv/template
+++ b/srcpkgs/qimgv/template
@@ -1,7 +1,7 @@
 # Template file for 'qimgv'
 pkgname=qimgv
 version=1.0.2
-revision=3
+revision=4
 build_style=cmake
 configure_args="$(vopt_if video -DVIDEO_SUPPORT=ON -DVIDEO_SUPPORT=OFF)
  $(vopt_if scale -DOPENCV_SUPPORT=ON -DOPENCV_SUPPORT=OFF)

From 7bb4a816c1a5d93d4f50c450cac22df37628d46d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 18:00:36 -0500
Subject: [PATCH 107/113] kfilemetadata5: revbump for ffmpeg6

---
 srcpkgs/kfilemetadata5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kfilemetadata5/template b/srcpkgs/kfilemetadata5/template
index 51fd6fec8c1c0..ad229b4c2e241 100644
--- a/srcpkgs/kfilemetadata5/template
+++ b/srcpkgs/kfilemetadata5/template
@@ -1,7 +1,7 @@
 # Template file for 'kfilemetadata5'
 pkgname=kfilemetadata5
 version=5.113.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="kcoreaddons extra-cmake-modules pkg-config qt5-host-tools qt5-qmake
  gettext kcoreaddons python3"

From 5ab024cc09187c5e5ccadf043368517b011d9d89 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 8 Dec 2023 11:46:01 -0500
Subject: [PATCH 108/113] vba-m: revbump for ffmpeg6

---
 srcpkgs/vba-m/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vba-m/template b/srcpkgs/vba-m/template
index 52efeede1dcba..3e0760398905c 100644
--- a/srcpkgs/vba-m/template
+++ b/srcpkgs/vba-m/template
@@ -2,7 +2,7 @@
 pkgname=vba-m
 reverts=1292_2
 version=2.1.8
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_GTK=TRUE -DENABLE_FFMPEG=TRUE -DENABLE_LINK=TRUE -DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="gettext pkg-config unzip zip yasm wxWidgets-gtk3-devel"

From d6743aa44452c82314eb0880ad2b32ef698ceb9b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 8 Dec 2023 11:46:19 -0500
Subject: [PATCH 109/113] dolphin-emu: revbump for ffmpeg6

---
 srcpkgs/dolphin-emu/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/dolphin-emu/template b/srcpkgs/dolphin-emu/template
index 862d3ae964eec..a7ae0efb58fb7 100644
--- a/srcpkgs/dolphin-emu/template
+++ b/srcpkgs/dolphin-emu/template
@@ -1,7 +1,7 @@
 # Template file for 'dolphin-emu'
 pkgname=dolphin-emu
 version=5.0.19368
-revision=3
+revision=4
 _dolphin_commit=dadbeb4bae7e7fa23af2b46e0add4143094dc107
 _mgba_commit=44e074a15e9651481f7f652ac006a7c9d58cbeb9
 _googletest_commit=be03d00f5f0cc3a997d1a368bee8a1fe93651f48

From acf86831837ae0bfbfd510c82f299733b70aeee3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 19 Dec 2023 15:38:51 -0500
Subject: [PATCH 110/113] qtox: revbump for ffmpeg4

---
 srcpkgs/qtox/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtox/template b/srcpkgs/qtox/template
index bb70e7f51240a..755e4462bc013 100644
--- a/srcpkgs/qtox/template
+++ b/srcpkgs/qtox/template
@@ -1,13 +1,13 @@
 # Template file for 'qtox'
 pkgname=qtox
 version=1.17.6
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DUPDATE_CHECK=OFF
  -DGIT_DESCRIBE=${version}
  $(vopt_if snorenotify -DDESKTOP_NOTIFICATIONS=ON)"
 hostmakedepends="pkg-config qt5-host-tools qt5-devel"
-makedepends="ffmpeg-devel libexif-devel libopenal-devel libsodium-devel
+makedepends="ffmpeg4-devel libexif-devel libopenal-devel libsodium-devel
  libvpx-devel opus-devel qrencode-devel qt5-svg-devel sonnet-devel
  sqlcipher-devel toxcore-devel
  $(vopt_if snorenotify snorenotify-devel)"

From f6080acdb277442eb9ab8d6a07a08c612913bb8f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 11 Jan 2024 11:52:00 -0500
Subject: [PATCH 111/113] arcan: revbump for ffmpeg6

---
 srcpkgs/arcan/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/arcan/template b/srcpkgs/arcan/template
index ff9091f90ebb1..030091a6cc9d0 100644
--- a/srcpkgs/arcan/template
+++ b/srcpkgs/arcan/template
@@ -2,7 +2,7 @@
 # !! keep synced with: acfgfs aclip aloadimage
 pkgname=arcan
 version=0.6.2.1
-revision=2
+revision=3
 create_wrksrc=yes
 build_wrksrc=arcan/src
 build_style=cmake

From acf8b1c9c246abc8a6278fb903cf091931ad9180 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 11 Jan 2024 11:52:10 -0500
Subject: [PATCH 112/113] notcurses: revbump for ffmpeg6

---
 srcpkgs/notcurses/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/notcurses/template b/srcpkgs/notcurses/template
index 48a7463cb68eb..515f316ab4576 100644
--- a/srcpkgs/notcurses/template
+++ b/srcpkgs/notcurses/template
@@ -1,7 +1,7 @@
 # Template file for 'notcurses'
 pkgname=notcurses
 version=3.0.9
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DUSE_STATIC=ON -DUSE_QRCODEGEN=On $(vopt_bool man USE_PANDOC)"
 hostmakedepends="pkg-config $(vopt_if man pandoc)"

From d00768759c9570afa9845c7f77953b1242bddb9e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Feb 2024 14:28:38 -0500
Subject: [PATCH 113/113] New package: oneVPL-intel-gpu-24.1.3

---
 srcpkgs/oneVPL-intel-gpu/template | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
 create mode 100644 srcpkgs/oneVPL-intel-gpu/template

diff --git a/srcpkgs/oneVPL-intel-gpu/template b/srcpkgs/oneVPL-intel-gpu/template
new file mode 100644
index 0000000000000..8b93cfabf7fc8
--- /dev/null
+++ b/srcpkgs/oneVPL-intel-gpu/template
@@ -0,0 +1,18 @@
+# Template file for 'oneVPL-intel-gpu'
+pkgname=oneVPL-intel-gpu
+version=24.1.3
+revision=1
+build_style=cmake
+hostmakedepends="pkg-config"
+makedepends="libva-devel libdrm-devel"
+short_desc="Intel oneVPL GPU Runtime"
+maintainer="zlice <zlice555@gmail.com>"
+license="MIT"
+homepage="https://github.com/oneapi-src/oneVPL-intel-gpu"
+changelog="https://github.com/oneapi-src/oneVPL-intel-gpu/blob/main/CHANGELOG.md"
+distfiles="https://github.com/oneapi-src/oneVPL-intel-gpu/archive/refs/tags/intel-onevpl-${version}.tar.gz"
+checksum=15d34e4304d7aeb5ea5e529b6f51171109cef42525113321f675bc14e56c697e
+
+post_install() {
+	vlicense LICENSE
+}

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (61 preceding siblings ...)
  2024-02-03 22:46 ` [PR PATCH] [Updated] " zlice
@ 2024-02-06  5:34 ` Luciogi
  2024-02-11 17:28 ` [PR PATCH] [Updated] " zlice
                   ` (34 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: Luciogi @ 2024-02-06  5:34 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 219 bytes --]

New comment by Luciogi on void-packages repository

https://github.com/void-linux/void-packages/pull/43761#issuecomment-1928817136

Comment:
add flowblade PR link: https://github.com/void-linux/void-packages/pull/47195

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (62 preceding siblings ...)
  2024-02-06  5:34 ` Luciogi
@ 2024-02-11 17:28 ` zlice
  2024-02-11 22:49 ` zlice
                   ` (33 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2024-02-11 17:28 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 4558 bytes --]

There is an updated pull request by zlice against master on the void-packages repository

https://github.com/zlice/void-packages ffmpeg6-split
https://github.com/void-linux/void-packages/pull/43761

ffmpeg6 split
[ci skip]


#### Testing the changes

- I tested the changes in this PR: **YES**

main testing has been vaapi in Firefox Nightly and enc/dec in Shotcut on Intel A770

#### New package

- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**

#### Local build testing

- I built this PR locally for my native architecture, **x86_64**

#### Discussion

Continuation of https://github.com/void-linux/void-packages/pull/36315

`libavresample` is deprecated, but marked as a dependency when trying to build other packages and install `ffmpeg`(6). I think the right way to handle this is make a meta package and the add to removals?


##### Commit naming / misc

~~Commits are 'dirty' right now, running with [gstreamer 1.22.1 updates](https://github.com/void-linux/void-packages/pull/42861) and [Intel OpenCL](https://github.com/void-linux/void-packages/pull/43084). This will also make [intel packages pr](https://github.com/void-linux/void-packages/pull/41132) obsolete.~~ (see Requirements below)

Maintainer for previous ffmpeg(4) was orphaned, I can put my name in there if that matters, though I don't exactly see myself keeping up on ffmpeg.

~~This updates QT5 which looks like it is usually hosted by Johnny. Not sure if there's any reason to stay there or these sources are fine.~~ Using qt5.15.11 now, revbumps and some patches.

##### STILL FFMPEG4

These are a mix of emulators, games and/or older packages.

- attract (multiple patches in master)
- ~~audacity (https://github.com/audacity/audacity/issues/2305 and https://sourceforge.net/p/portmedia/wiki/portsmf/ is 'beta')~~ (updated to 3.x, compiles with ffmpeg6)
- ccextractor (master patches? no release)
- vice (3.8 compiles, needs makedepends libcurl-devel)
- kodi
- mlt (only dep left is flowblade - flowblade 2.12.0.2 with mlt7-python3 can 'render' videos with cpu and gpu)
- ~~synfig (mlt)~~ (work with mlt7, bump synfigstudio)
- tvheadend
- ssr
- ~~spek-alternative~~ (replace with spek-x)
- ppsspp
- olive
- moc
- mediastreamer (linphone links are dead, changed to github belladonne. their stuff never worked for me but there are updates if someone wants to give it a try)
- libextractor (1.13 compiles, remove exiv2 patch)
- idjc (0.9.8 compiles, remove python3.10 patch, needs makedepends libebur128-devel and libshout-idjc 2.4.6 with '-r1' for distfile)
- hedgewars
- ~~ffmpegthumbnailer~~ (patches for moviedecoder.xxx files)
- ~~ffmpegthumbs~~ (latest compiles)
- deadbeef
- ~~omxplayer~~ (package removed, deprecated in favor of vlc)
- qtav (fork has ffmpeg 5 patch - https://github.com/cmguo/QtAV)
- `vlc` (vlc4 will support ffmpeg5, there's a patch to build 3.x with ffmpeg5 but it will lack vaapi)
- `osg` (OpenSceneGraph plus `xine-lib`)


##### HAVE NOT BUILT YET

- ~~omxplayer (rpi only? ffmpeg4)~~ (removed)
- kodi (big, but ffmpeg4)


##### UPDATED (for ffmpeg6)

- ~~blender: update to 3.5.1~~ ~~will be revbump with~~ https://github.com/void-linux/void-packages/pull/43992
- unpaper: update to 7.0.0.
- guvcview: update to 2.0.8.
- ~~qt5: update to 5.15.8~~ updated by another PR to 5.15.11
- ~~qt5-webengine: update to 5.18.15~~ updated by another PR to 5.15.16 (some patching for ffmpeg build)
- ~~shiboken2: revbump for qt5.15.8 (patch)~~ updated by another PR to 5.15.10
- ~~python3-pyside2: update to 5.15.8 (patch)~~ updated by another PR to 5.15.10
- New package: spex-x replaces spek-alternative for ffmpeg-6.0


##### Requirements

- ~~[gstreamer 1.22.2](https://github.com/void-linux/void-packages/pull/42861)~~ - a few packages use ffmpeg-devel and require a revbump

- ~~[Intel Packages](https://github.com/void-linux/void-packages/pull/41132) [Intel Packages v2](https://github.com/void-linux/void-packages/pull/47330) - ffmpeg4 uses different libraries than 6 (libmfx / Intel-MediaSDK vs only oneVPL that Intel is moving to), both are included here~~. Using replacement oneVPL from OBS update.

- ~~[shotcut 23.05.14](https://github.com/void-linux/void-packages/pull/44260)~~

- https://github.com/void-linux/void-packages/pull/44781 will remove from this PR

A patch file from https://github.com/void-linux/void-packages/pull/43761.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ffmpeg6-split-43761.patch --]
[-- Type: text/x-diff, Size: 228032 bytes --]

From f87f27a3d911115eb002c1576de4b89fed1b47da Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:16:56 -0400
Subject: [PATCH 001/113] ffmpeg: update to 6.0.1.

---
 common/shlibs                                 | 26 ++++---
 srcpkgs/ffmpeg/files/altivec.patch            | 60 ---------------
 .../patches/armv5tel-floating-point.patch     | 18 -----
 srcpkgs/ffmpeg/patches/binutils-2.41.patch    | 73 -------------------
 ...h-libavcodec-libsvtav1-ten_bit_format.diff | 40 ----------
 .../workaround-mesa-readeon-vaapi-bug.patch   | 28 -------
 srcpkgs/ffmpeg/template                       | 40 +++++-----
 7 files changed, 37 insertions(+), 248 deletions(-)
 delete mode 100644 srcpkgs/ffmpeg/files/altivec.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/binutils-2.41.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 delete mode 100644 srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch

diff --git a/common/shlibs b/common/shlibs
index 93fb4b26087297..7987d854066aba 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -389,15 +389,23 @@ libid3tag.so.0 libid3tag-0.15.1b_1
 libgif.so.7 giflib-5.1.0_1
 libImlib2.so.1 imlib2-1.4.2_1
 libmp3lame.so.0 lame-3.98.2_1
-libavdevice.so.58 libavdevice-4.0_1
-libavformat.so.58 libavformat-4.0_1
-libswscale.so.5 libswscale-4.0_1
-libswresample.so.3 libswresample-4.0_1
-libavresample.so.4 libavresample-4.0_1
-libpostproc.so.55 libpostproc-4.0_1
-libavcodec.so.58 libavcodec-4.0_1
-libavutil.so.56 libavutil-4.0_1
-libavfilter.so.7 libavfilter-4.0_1
+libavdevice.so.60 libavdevice-6.0_1
+libavformat.so.60 libavformat-6.0_1
+libswscale.so.7 libswscale-6.0_1
+libswresample.so.4 libswresample-6.0_1
+libpostproc.so.57 libpostproc-6.0_1
+libavcodec.so.60 libavcodec-6.0_1
+libavutil.so.58 libavutil-6.0_1
+libavfilter.so.9 libavfilter-6.0_1
+libavdevice.so.58 libavdevice4-4.0_1
+libavformat.so.58 libavformat4-4.0_1
+libswscale.so.5 libswscale4-4.0_1
+libswresample.so.3 libswresample4-4.0_1
+libavresample.so.4 libavresample4-4.0_1
+libpostproc.so.55 libpostproc4-4.0_1
+libavcodec.so.58 libavcodec4-4.0_1
+libavutil.so.56 libavutil4-4.0_1
+libavfilter.so.7 libavfilter4-4.0_1
 libSDL-1.2.so.0 SDL-1.2.14_1
 libSDL_image-1.2.so.0 SDL_image-1.2.10_1
 libx264.so.157 x264-20190507.2245_1
diff --git a/srcpkgs/ffmpeg/files/altivec.patch b/srcpkgs/ffmpeg/files/altivec.patch
deleted file mode 100644
index 9c57200463320e..00000000000000
--- a/srcpkgs/ffmpeg/files/altivec.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-revert some altivec specific change on all ppc* except ppc64le*
-
-q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
-conditionally, for ppc* but not ppc64le* (the new code is valid for
-POWER8 VSX which LE targets as a baseline but not BE)"
-
-
-This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
----
- libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
- 1 file changed, 20 insertions(+), 4 deletions(-)
-
-diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
-index 536545293d..c1e2852adb 100644
---- a/libswscale/ppc/yuv2rgb_altivec.c
-+++ b/libswscale/ppc/yuv2rgb_altivec.c
-@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-     vector signed short R1, G1, B1;                                           \
-     vector unsigned char R, G, B;                                             \
-                                                                               \
-+    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
-+    vector unsigned char align_perm;                                          \
-+                                                                              \
-     vector signed short lCY       = c->CY;                                    \
-     vector signed short lOY       = c->OY;                                    \
-     vector signed short lCRV      = c->CRV;                                   \
-@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
-                                                                               \
-         for (j = 0; j < w / 16; j++) {                                        \
--            y0 = vec_xl(0, y1i);                                              \
-+            y1ivP = (const vector unsigned char *) y1i;                       \
-+            y2ivP = (const vector unsigned char *) y2i;                       \
-+            uivP  = (const vector unsigned char *) ui;                        \
-+            vivP  = (const vector unsigned char *) vi;                        \
-+                                                                              \
-+            align_perm = vec_lvsl(0, y1i);                                    \
-+            y0 = (vector unsigned char)                                       \
-+                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
-                                                                               \
--            y1 = vec_xl(0, y2i);                                              \
-+            align_perm = vec_lvsl(0, y2i);                                    \
-+            y1 = (vector unsigned char)                                       \
-+                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
-                                                                               \
--            u = (vector signed char) vec_xl(0, ui);                           \
-+            align_perm = vec_lvsl(0, ui);                                     \
-+            u = (vector signed char)                                          \
-+                    vec_perm(uivP[0], uivP[1], align_perm);                   \
-                                                                               \
--            v = (vector signed char) vec_xl(0, vi);                           \
-+            align_perm = vec_lvsl(0, vi);                                     \
-+            v = (vector signed char)                                          \
-+                    vec_perm(vivP[0], vivP[1], align_perm);                   \
-                                                                               \
-             u = (vector signed char)                                          \
-                     vec_sub(u,                                                \
--- 
-2.27.0
-
diff --git a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
deleted file mode 100644
index 9a55178c74f0fd..00000000000000
--- a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
-+++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
-@@ -39,6 +39,15 @@
- #endif
- #include <fenv.h>
- 
-+#if (FE_ALL_EXCEPT == 0)
-+/* E.g. ARM soft float does not define these */
-+#define FE_INVALID    0
-+#define FE_DIVBYZERO  0
-+#define FE_OVERFLOW   0
-+#define FE_UNDERFLOW  0
-+#define FE_INEXACT    0
-+#endif
-+
- #if CONFIG_LIBFONTCONFIG
- #include <fontconfig/fontconfig.h>
- #endif
diff --git a/srcpkgs/ffmpeg/patches/binutils-2.41.patch b/srcpkgs/ffmpeg/patches/binutils-2.41.patch
deleted file mode 100644
index 53a596d0ee7d4e..00000000000000
--- a/srcpkgs/ffmpeg/patches/binutils-2.41.patch
+++ /dev/null
@@ -1,73 +0,0 @@
-From effadce6c756247ea8bae32dc13bb3e6f464f0eb Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= <remi@remlab.net>
-Date: Sun, 16 Jul 2023 18:18:02 +0300
-Subject: [PATCH] avcodec/x86/mathops: clip constants used with shift
- instructions within inline assembly
-
-Fixes assembling with binutil as >= 2.41
-
-Signed-off-by: James Almer <jamrial@gmail.com>
----
- libavcodec/x86/mathops.h | 26 +++++++++++++++++++++++---
- 1 file changed, 23 insertions(+), 3 deletions(-)
-
-diff --git a/libavcodec/x86/mathops.h b/libavcodec/x86/mathops.h
-index 6298f5ed1983b..ca7e2dffc1076 100644
---- a/libavcodec/x86/mathops.h
-+++ b/libavcodec/x86/mathops.h
-@@ -35,12 +35,20 @@
- static av_always_inline av_const int MULL(int a, int b, unsigned shift)
- {
-     int rt, dummy;
-+    if (__builtin_constant_p(shift))
-     __asm__ (
-         "imull %3               \n\t"
-         "shrdl %4, %%edx, %%eax \n\t"
-         :"=a"(rt), "=d"(dummy)
--        :"a"(a), "rm"(b), "ci"((uint8_t)shift)
-+        :"a"(a), "rm"(b), "i"(shift & 0x1F)
-     );
-+    else
-+        __asm__ (
-+            "imull %3               \n\t"
-+            "shrdl %4, %%edx, %%eax \n\t"
-+            :"=a"(rt), "=d"(dummy)
-+            :"a"(a), "rm"(b), "c"((uint8_t)shift)
-+        );
-     return rt;
- }
- 
-@@ -113,19 +121,31 @@ __asm__ volatile(\
- // avoid +32 for shift optimization (gcc should do that ...)
- #define NEG_SSR32 NEG_SSR32
- static inline  int32_t NEG_SSR32( int32_t a, int8_t s){
-+    if (__builtin_constant_p(s))
-     __asm__ ("sarl %1, %0\n\t"
-          : "+r" (a)
--         : "ic" ((uint8_t)(-s))
-+         : "i" (-s & 0x1F)
-     );
-+    else
-+        __asm__ ("sarl %1, %0\n\t"
-+               : "+r" (a)
-+               : "c" ((uint8_t)(-s))
-+        );
-     return a;
- }
- 
- #define NEG_USR32 NEG_USR32
- static inline uint32_t NEG_USR32(uint32_t a, int8_t s){
-+    if (__builtin_constant_p(s))
-     __asm__ ("shrl %1, %0\n\t"
-          : "+r" (a)
--         : "ic" ((uint8_t)(-s))
-+         : "i" (-s & 0x1F)
-     );
-+    else
-+        __asm__ ("shrl %1, %0\n\t"
-+               : "+r" (a)
-+               : "c" ((uint8_t)(-s))
-+        );
-     return a;
- }
- 
diff --git a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
deleted file mode 100644
index aa948f7a8a2dfb..00000000000000
--- a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
+++ /dev/null
@@ -1,40 +0,0 @@
-#==================================================================================================
-# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
-# From: Christopher Degawa <christopher.degawa@intel.com>
-# Date: Thu, 20 Oct 2022 22:55:27 -0500
-# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
-#
-# compressed_ten_bit_format has been deprecated upstream and has no effect
-# and can be removed. Plus, technically it was never used in the first place
-# since it would require the app (ffmpeg) to set it and do additional
-# processing of the input frames.
-#
-# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
-#
-# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
-#==================================================================================================
---- a/libavcodec/libsvtav1.c
-+++ b/libavcodec/libsvtav1.c
-@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
- 
- static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
- {
--    const int    pack_mode_10bit =
--        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
--    const size_t luma_size_8bit  =
--        config->source_width * config->source_height * (1 << pack_mode_10bit);
--    const size_t luma_size_10bit =
--        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
-+    const size_t luma_size = config->source_width * config->source_height *
-+        (config->encoder_bit_depth > 8 ? 2 : 1);
- 
-     EbSvtIOFormat *in_data;
- 
--    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
-+    svt_enc->raw_size = luma_size * 3 / 2;
- 
-     // allocate buffer for in and out
-     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
--- 
-GitLab
-
diff --git a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
deleted file mode 100644
index 00e3f68a415b84..00000000000000
--- a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
-From: Rainer Hochecker <fernetmenta@online.de>
-Date: Sat, 26 Jan 2019 19:48:35 +0100
-Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
-
-This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
-It was hit frequently when watching h264 channels received via DVB-X.
-Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
----
- libavcodec/vaapi_h264.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
-index 5854587a255..f12fdc457a4 100644
---- a/libavcodec/vaapi_h264.c
-+++ b/libavcodec/vaapi_h264.c
-@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
-     H264SliceContext *sl = &h->slice_ctx[0];
-     int ret;
- 
-+    if (pic->nb_slices == 0) {
-+        ret = AVERROR_INVALIDDATA;
-+        goto finish;
-+    }
-+
-     ret = ff_vaapi_decode_issue(avctx, pic);
-     if (ret < 0)
-         goto finish;
diff --git a/srcpkgs/ffmpeg/template b/srcpkgs/ffmpeg/template
index 1ebb436135938d..f1e4712c41d087 100644
--- a/srcpkgs/ffmpeg/template
+++ b/srcpkgs/ffmpeg/template
@@ -1,15 +1,15 @@
 # Template file for 'ffmpeg'
 # audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
 pkgname=ffmpeg
-version=4.4.4
-revision=6
+version=6.0.1
+revision=1
 short_desc="Decoding, encoding and streaming software"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="https://www.ffmpeg.org"
 changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
 distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
-checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+checksum=9b16b8731d78e596b4be0d720428ca42df642bb2d78342881ff7f5bc29fc9623
 
 hostmakedepends="pkg-config perl"
 makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
@@ -26,12 +26,13 @@ makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-deve
  $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
  $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
  $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
- $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers Vulkan-Tools Vulkan-ValidationLayers')
+ $(vopt_if onevpl 'oneVPL oneVPL-devel')
  $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
 depends="ffplay>=${version}_${revision}"
 
 build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
- dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec onevpl"
 build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
 desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
 desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
@@ -39,9 +40,13 @@ desc_option_sofa="Enable support for AES SOFA"
 desc_option_webp="Enable support for WebP"
 
 case "$XBPS_TARGET_MACHINE" in
-	i686*|x86_64*)
-		hostmakedepends+=" nasm"
+	i686*)
 		build_options_default+=" vaapi vdpau nvenc nvdec"
+		hostmakedepends+=" nasm"
+		;;
+	x86_64*)
+		hostmakedepends+=" nasm"
+		build_options_default+=" vaapi vdpau nvenc nvdec onevpl"
 		;;
 	ppc64*) build_options_default+=" vaapi vdpau";;
 	mips*) CFLAGS="-mnan=legacy";;
@@ -65,8 +70,6 @@ post_patch() {
 		ppc64le*) ;;
 		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
 	esac
-
-	vsed -i libavfilter/vf_libvmaf.c -e 's!/usr/local/share/model/\(vmaf_v0.6.1\).pkl!/usr/share/vmaf/\1.json!'
 }
 
 do_configure() {
@@ -115,18 +118,19 @@ do_configure() {
 		$(vopt_enable x265 libx265) \
 		$(vopt_enable v4l2 libv4l2) \
 		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
-		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		--enable-libbs2b --enable-libvidstab \
 		$(vopt_enable dav1d libdav1d) \
 		$(vopt_enable zimg libzimg) \
 		$(vopt_enable webp libwebp) \
 		$(vopt_enable sofa libmysofa) \
 		$(vopt_enable vulkan) \
+		$(vopt_enable onevpl libvpl) \
 		$(vopt_enable drm libdrm) \
 		$(vopt_enable svtav1 libsvtav1) \
 		$(vopt_enable srt libsrt) \
 		$(vopt_enable rist librist) \
-		$(vopt_if nvenc '--enable-nvenc') \
-		$(vopt_if nvdec '--enable-nvdec')
+		$(vopt_enable nvenc nvenc) \
+		$(vopt_enable nvdec nvdec)
 }
 
 do_build() {
@@ -153,10 +157,8 @@ libavdevice_package() {
 }
 
 libavresample_package() {
-	short_desc="FFmpeg audio resampling library"
-	pkg_install() {
-		vmove "usr/lib/libavresample.so.*"
-	}
+	short_desc="Package deprecated, removal needed"
+	build_style=meta
 }
 
 libavformat_package() {
@@ -210,15 +212,13 @@ ffmpeg-devel_package() {
 		libavfilter>=${version}_${revision}
 		libpostproc>=${version}_${revision}
 		libswscale>=${version}_${revision}
-		libswresample>=${version}_${revision}
-		libavresample>=${version}_${revision}"
+		libswresample>=${version}_${revision}"
 	short_desc+=" - development files"
-
+	conflicts="ffmpeg4-devel"
 	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
 		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
 		nostrip_files="/usr/lib/libavfilter.a"
 	fi
-
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig

From 5eace62fcc8a24373a50cd02bac7bdba766d2d7f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:14 -0400
Subject: [PATCH 002/113] openshot: revbump for ffmpeg6

---
 srcpkgs/openshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openshot/template b/srcpkgs/openshot/template
index 8f47851eef354f..affb652a9d500a 100644
--- a/srcpkgs/openshot/template
+++ b/srcpkgs/openshot/template
@@ -1,7 +1,7 @@
 # Template file for 'openshot'
 pkgname=openshot
 version=3.0.0
-revision=2
+revision=3
 build_style=python3-module
 hostmakedepends="python3 python3-setuptools"
 makedepends="ffmpeg-devel python3-PyQt5"

From c86e7fd0fa30949be9555a936195402d40a061dd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:36 -0400
Subject: [PATCH 003/113] sumo: revbump for ffmpeg6

---
 srcpkgs/sumo/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/sumo/template b/srcpkgs/sumo/template
index a3fe134aa5acc2..a730afa9fafa92 100644
--- a/srcpkgs/sumo/template
+++ b/srcpkgs/sumo/template
@@ -1,7 +1,7 @@
 # Template file for 'sumo'
 pkgname=sumo
 version=1.12.0
-revision=6
+revision=7
 build_style=cmake
 hostmakedepends="libgdal-tools pkg-config swig python3-setuptools"
 makedepends="python3-devel ffmpeg-devel fox-devel gl2ps-devel libgdal-devel

From 05f4a46223d32f2711d18c5c7a2a36de4eeaf148 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:56:22 -0400
Subject: [PATCH 004/113] New package: ffmpeg4-4.4.4.

---
 srcpkgs/ffmpeg4-devel                         |   1 +
 srcpkgs/ffmpeg4/files/altivec.patch           |  60 +++++
 .../patches/armv5tel-floating-point.patch     |  18 ++
 srcpkgs/ffmpeg4/patches/binutils-2.41.patch   |  73 ++++++
 ...h-libavcodec-libsvtav1-ten_bit_format.diff |  40 +++
 .../workaround-mesa-readeon-vaapi-bug.patch   |  28 +++
 srcpkgs/ffmpeg4/template                      | 234 ++++++++++++++++++
 srcpkgs/libavcodec4                           |   1 +
 srcpkgs/libavdevice4                          |   1 +
 srcpkgs/libavfilter4                          |   1 +
 srcpkgs/libavformat4                          |   1 +
 srcpkgs/libavresample4                        |   1 +
 srcpkgs/libavutil4                            |   1 +
 srcpkgs/libpostproc4                          |   1 +
 srcpkgs/libswresample4                        |   1 +
 srcpkgs/libswscale4                           |   1 +
 16 files changed, 463 insertions(+)
 create mode 120000 srcpkgs/ffmpeg4-devel
 create mode 100644 srcpkgs/ffmpeg4/files/altivec.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/binutils-2.41.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 create mode 100644 srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
 create mode 100644 srcpkgs/ffmpeg4/template
 create mode 120000 srcpkgs/libavcodec4
 create mode 120000 srcpkgs/libavdevice4
 create mode 120000 srcpkgs/libavfilter4
 create mode 120000 srcpkgs/libavformat4
 create mode 120000 srcpkgs/libavresample4
 create mode 120000 srcpkgs/libavutil4
 create mode 120000 srcpkgs/libpostproc4
 create mode 120000 srcpkgs/libswresample4
 create mode 120000 srcpkgs/libswscale4

diff --git a/srcpkgs/ffmpeg4-devel b/srcpkgs/ffmpeg4-devel
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/ffmpeg4-devel
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/ffmpeg4/files/altivec.patch b/srcpkgs/ffmpeg4/files/altivec.patch
new file mode 100644
index 00000000000000..9c57200463320e
--- /dev/null
+++ b/srcpkgs/ffmpeg4/files/altivec.patch
@@ -0,0 +1,60 @@
+revert some altivec specific change on all ppc* except ppc64le*
+
+q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
+conditionally, for ppc* but not ppc64le* (the new code is valid for
+POWER8 VSX which LE targets as a baseline but not BE)"
+
+
+This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
+---
+ libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
+ 1 file changed, 20 insertions(+), 4 deletions(-)
+
+diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
+index 536545293d..c1e2852adb 100644
+--- a/libswscale/ppc/yuv2rgb_altivec.c
++++ b/libswscale/ppc/yuv2rgb_altivec.c
+@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+     vector signed short R1, G1, B1;                                           \
+     vector unsigned char R, G, B;                                             \
+                                                                               \
++    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
++    vector unsigned char align_perm;                                          \
++                                                                              \
+     vector signed short lCY       = c->CY;                                    \
+     vector signed short lOY       = c->OY;                                    \
+     vector signed short lCRV      = c->CRV;                                   \
+@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
+                                                                               \
+         for (j = 0; j < w / 16; j++) {                                        \
+-            y0 = vec_xl(0, y1i);                                              \
++            y1ivP = (const vector unsigned char *) y1i;                       \
++            y2ivP = (const vector unsigned char *) y2i;                       \
++            uivP  = (const vector unsigned char *) ui;                        \
++            vivP  = (const vector unsigned char *) vi;                        \
++                                                                              \
++            align_perm = vec_lvsl(0, y1i);                                    \
++            y0 = (vector unsigned char)                                       \
++                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
+                                                                               \
+-            y1 = vec_xl(0, y2i);                                              \
++            align_perm = vec_lvsl(0, y2i);                                    \
++            y1 = (vector unsigned char)                                       \
++                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
+                                                                               \
+-            u = (vector signed char) vec_xl(0, ui);                           \
++            align_perm = vec_lvsl(0, ui);                                     \
++            u = (vector signed char)                                          \
++                    vec_perm(uivP[0], uivP[1], align_perm);                   \
+                                                                               \
+-            v = (vector signed char) vec_xl(0, vi);                           \
++            align_perm = vec_lvsl(0, vi);                                     \
++            v = (vector signed char)                                          \
++                    vec_perm(vivP[0], vivP[1], align_perm);                   \
+                                                                               \
+             u = (vector signed char)                                          \
+                     vec_sub(u,                                                \
+-- 
+2.27.0
+
diff --git a/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
new file mode 100644
index 00000000000000..9a55178c74f0fd
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
@@ -0,0 +1,18 @@
+--- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
++++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
+@@ -39,6 +39,15 @@
+ #endif
+ #include <fenv.h>
+ 
++#if (FE_ALL_EXCEPT == 0)
++/* E.g. ARM soft float does not define these */
++#define FE_INVALID    0
++#define FE_DIVBYZERO  0
++#define FE_OVERFLOW   0
++#define FE_UNDERFLOW  0
++#define FE_INEXACT    0
++#endif
++
+ #if CONFIG_LIBFONTCONFIG
+ #include <fontconfig/fontconfig.h>
+ #endif
diff --git a/srcpkgs/ffmpeg4/patches/binutils-2.41.patch b/srcpkgs/ffmpeg4/patches/binutils-2.41.patch
new file mode 100644
index 00000000000000..53a596d0ee7d4e
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/binutils-2.41.patch
@@ -0,0 +1,73 @@
+From effadce6c756247ea8bae32dc13bb3e6f464f0eb Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= <remi@remlab.net>
+Date: Sun, 16 Jul 2023 18:18:02 +0300
+Subject: [PATCH] avcodec/x86/mathops: clip constants used with shift
+ instructions within inline assembly
+
+Fixes assembling with binutil as >= 2.41
+
+Signed-off-by: James Almer <jamrial@gmail.com>
+---
+ libavcodec/x86/mathops.h | 26 +++++++++++++++++++++++---
+ 1 file changed, 23 insertions(+), 3 deletions(-)
+
+diff --git a/libavcodec/x86/mathops.h b/libavcodec/x86/mathops.h
+index 6298f5ed1983b..ca7e2dffc1076 100644
+--- a/libavcodec/x86/mathops.h
++++ b/libavcodec/x86/mathops.h
+@@ -35,12 +35,20 @@
+ static av_always_inline av_const int MULL(int a, int b, unsigned shift)
+ {
+     int rt, dummy;
++    if (__builtin_constant_p(shift))
+     __asm__ (
+         "imull %3               \n\t"
+         "shrdl %4, %%edx, %%eax \n\t"
+         :"=a"(rt), "=d"(dummy)
+-        :"a"(a), "rm"(b), "ci"((uint8_t)shift)
++        :"a"(a), "rm"(b), "i"(shift & 0x1F)
+     );
++    else
++        __asm__ (
++            "imull %3               \n\t"
++            "shrdl %4, %%edx, %%eax \n\t"
++            :"=a"(rt), "=d"(dummy)
++            :"a"(a), "rm"(b), "c"((uint8_t)shift)
++        );
+     return rt;
+ }
+ 
+@@ -113,19 +121,31 @@ __asm__ volatile(\
+ // avoid +32 for shift optimization (gcc should do that ...)
+ #define NEG_SSR32 NEG_SSR32
+ static inline  int32_t NEG_SSR32( int32_t a, int8_t s){
++    if (__builtin_constant_p(s))
+     __asm__ ("sarl %1, %0\n\t"
+          : "+r" (a)
+-         : "ic" ((uint8_t)(-s))
++         : "i" (-s & 0x1F)
+     );
++    else
++        __asm__ ("sarl %1, %0\n\t"
++               : "+r" (a)
++               : "c" ((uint8_t)(-s))
++        );
+     return a;
+ }
+ 
+ #define NEG_USR32 NEG_USR32
+ static inline uint32_t NEG_USR32(uint32_t a, int8_t s){
++    if (__builtin_constant_p(s))
+     __asm__ ("shrl %1, %0\n\t"
+          : "+r" (a)
+-         : "ic" ((uint8_t)(-s))
++         : "i" (-s & 0x1F)
+     );
++    else
++        __asm__ ("shrl %1, %0\n\t"
++               : "+r" (a)
++               : "c" ((uint8_t)(-s))
++        );
+     return a;
+ }
+ 
diff --git a/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
new file mode 100644
index 00000000000000..aa948f7a8a2dfb
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
@@ -0,0 +1,40 @@
+#==================================================================================================
+# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
+# From: Christopher Degawa <christopher.degawa@intel.com>
+# Date: Thu, 20 Oct 2022 22:55:27 -0500
+# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
+#
+# compressed_ten_bit_format has been deprecated upstream and has no effect
+# and can be removed. Plus, technically it was never used in the first place
+# since it would require the app (ffmpeg) to set it and do additional
+# processing of the input frames.
+#
+# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
+#
+# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
+#==================================================================================================
+--- a/libavcodec/libsvtav1.c
++++ b/libavcodec/libsvtav1.c
+@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
+ 
+ static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
+ {
+-    const int    pack_mode_10bit =
+-        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
+-    const size_t luma_size_8bit  =
+-        config->source_width * config->source_height * (1 << pack_mode_10bit);
+-    const size_t luma_size_10bit =
+-        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
++    const size_t luma_size = config->source_width * config->source_height *
++        (config->encoder_bit_depth > 8 ? 2 : 1);
+ 
+     EbSvtIOFormat *in_data;
+ 
+-    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
++    svt_enc->raw_size = luma_size * 3 / 2;
+ 
+     // allocate buffer for in and out
+     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
+-- 
+GitLab
+
diff --git a/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
new file mode 100644
index 00000000000000..00e3f68a415b84
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
@@ -0,0 +1,28 @@
+From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
+From: Rainer Hochecker <fernetmenta@online.de>
+Date: Sat, 26 Jan 2019 19:48:35 +0100
+Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
+
+This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
+It was hit frequently when watching h264 channels received via DVB-X.
+Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
+---
+ libavcodec/vaapi_h264.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
+index 5854587a255..f12fdc457a4 100644
+--- a/libavcodec/vaapi_h264.c
++++ b/libavcodec/vaapi_h264.c
+@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
+     H264SliceContext *sl = &h->slice_ctx[0];
+     int ret;
+ 
++    if (pic->nb_slices == 0) {
++        ret = AVERROR_INVALIDDATA;
++        goto finish;
++    }
++
+     ret = ff_vaapi_decode_issue(avctx, pic);
+     if (ret < 0)
+         goto finish;
diff --git a/srcpkgs/ffmpeg4/template b/srcpkgs/ffmpeg4/template
new file mode 100644
index 00000000000000..9ba14bdb8ddf32
--- /dev/null
+++ b/srcpkgs/ffmpeg4/template
@@ -0,0 +1,234 @@
+# Template file for 'ffmpeg4'
+# audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
+pkgname=ffmpeg4
+version=4.4.4
+revision=1
+short_desc="Decoding, encoding and streaming software - ffmpeg4 libraries only"
+maintainer="Orphaned <orphan@voidlinux.org>"
+license="GPL-3.0-or-later"
+homepage="https://www.ffmpeg.org"
+changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
+distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
+checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+
+hostmakedepends="pkg-config perl"
+makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
+ libXext-devel libXvMC-devel libxcb-devel lame-devel libtheora-devel
+ libvorbis-devel x264-devel xvidcore-devel jack-devel SDL2-devel
+ libcdio-paranoia-devel librtmp-devel libmodplug-devel gnutls-devel
+ speex-devel celt-devel harfbuzz-devel libass-devel opus-devel ocl-icd-devel
+ libbs2b-devel libvidstab-devel vmaf-devel $(vopt_if pulseaudio pulseaudio-devel)
+ $(vopt_if vaapi libva-devel) $(vopt_if vdpau libvdpau-devel)
+ $(vopt_if x265 x265-devel) $(vopt_if v4l2 v4l-utils-devel)
+ $(vopt_if fdk_aac fdk-aac-devel) $(vopt_if vpx libvpx-devel)
+ $(vopt_if aom libaom-devel) $(vopt_if sndio sndio-devel)
+ $(vopt_if dav1d libdav1d-devel) $(vopt_if zimg zimg-devel)
+ $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
+ $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
+ $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
+
+build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
+
+desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
+desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
+desc_option_sofa="Enable support for AES SOFA"
+desc_option_webp="Enable support for WebP"
+
+case "$XBPS_TARGET_MACHINE" in
+	i686*|x86_64*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau nvenc nvdec"
+			;;
+	ppc64*) build_options_default+=" vaapi vdpau";;
+	mips*) CFLAGS="-mnan=legacy";;
+esac
+
+if [ "$XBPS_TARGET_WORDSIZE" != "32" ]; then
+	build_options_default+=" svtav1"
+fi
+
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+fi
+
+_apply_patch() {
+	local args="$1" pname="$(basename $2)"
+
+	if [ ! -f ".${pname}_done" ]; then
+		patch -N $args -i $2
+		touch .${pname}_done
+	fi
+}
+
+post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64le*) ;;
+		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
+	esac
+
+	vsed -i libavfilter/vf_libvmaf.c -e 's!/usr/local/share/model/\(vmaf_v0.6.1\).pkl!/usr/share/vmaf/\1.json!'
+}
+
+do_configure() {
+	# Fix gcc on x86_64-musl only
+	if [ "$XBPS_TARGET_MACHINE" = "x86_64-musl" ]; then
+		vsed -i configure -e "s;_cflags_speed='-O3';_cflags_speed='-O2';"
+	fi
+
+	if [ "$CROSS_BUILD" ]; then
+		case "$XBPS_TARGET_MACHINE" in
+			arm*) _arch="arm";;
+			aarch64*) _arch="aarch64";;
+			mips*) _arch="mips";;
+			ppc64*) _arch="ppc64";;
+			ppc*) _arch="ppc";;
+			*) _arch="${XBPS_TARGET_MACHINE%%-musl}";;
+		esac
+
+		_args+=" --enable-cross-compile
+			--sysroot=$XBPS_CROSS_BASE
+			--cross-prefix=${XBPS_CROSS_TRIPLET}-
+			--target-os=linux --arch=${_arch}"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc|ppc-musl) _args+=" --disable-altivec";;
+	esac
+
+	if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+		_args+=" --extra-libs=-latomic"
+	fi
+
+	./configure --prefix=/usr --disable-debug --enable-gpl --enable-gnutls \
+		--disable-stripping \
+		--enable-libcdio --enable-version3 --enable-runtime-cpudetect \
+		--enable-libmp3lame --enable-libvorbis --enable-libxvid \
+		--enable-libx264 $(vopt_enable vpx libvpx) --enable-libtheora \
+		--enable-shared --enable-static --enable-libxcb \
+		$(vopt_enable pulseaudio libpulse) --enable-libfreetype --enable-libmodplug \
+		--enable-libspeex --enable-libcelt --enable-libass \
+		--enable-libopus --enable-librtmp --enable-libjack \
+		$(vopt_if fdk_aac '--enable-nonfree --enable-libfdk-aac') \
+		--disable-libopencore_amrnb --disable-libopencore_amrwb \
+		--disable-libopenjpeg \
+		--enable-postproc --enable-opencl ${_args} --enable-libvmaf ${_args} \
+		$(vopt_enable x265 libx265) \
+		$(vopt_enable v4l2 libv4l2) \
+		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
+		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		$(vopt_enable dav1d libdav1d) \
+		$(vopt_enable zimg libzimg) \
+		$(vopt_enable webp libwebp) \
+		$(vopt_enable sofa libmysofa) \
+		$(vopt_enable vulkan) \
+		$(vopt_enable drm libdrm) \
+		$(vopt_enable svtav1 libsvtav1) \
+		$(vopt_enable srt libsrt) \
+		$(vopt_enable rist librist) \
+		$(vopt_if nvenc '--enable-nvenc') \
+		$(vopt_if nvdec '--enable-nvdec')
+}
+
+do_build() {
+	make ${makejobs}
+	make doc/ff{mpeg,play}.1
+}
+
+do_install() {
+	make DESTDIR=${DESTDIR} install install-man
+	rm -rf ${DESTDIR}/usr/bin
+}
+
+libavcodec4_package() {
+	short_desc="FFmpeg codec library"
+	pkg_install() {
+		vmove "usr/lib/libavcodec.so.*"
+	}
+}
+
+libavdevice4_package() {
+	short_desc="FFmpeg device handling library"
+	pkg_install() {
+		vmove "usr/lib/libavdevice.so.*"
+	}
+}
+
+libavresample4_package() {
+	short_desc="FFmpeg audio resampling library"
+	pkg_install() {
+		vmove "usr/lib/libavresample.so.*"
+	}
+}
+
+libavformat4_package() {
+	short_desc="FFmpeg file format library"
+	pkg_install() {
+		vmove "usr/lib/libavformat.so.*"
+	}
+}
+
+libavutil4_package() {
+	short_desc="FFmpeg utility library"
+	pkg_install() {
+		vmove "usr/lib/libavutil.so.*"
+	}
+}
+
+libavfilter4_package() {
+	short_desc="FFmpeg audio/video filter library"
+	pkg_install() {
+		vmove "usr/lib/libavfilter.so.*"
+	}
+}
+
+libpostproc4_package() {
+	short_desc="FFmpeg video postprocessing library"
+	pkg_install() {
+		vmove "usr/lib/libpostproc.so.*"
+	}
+}
+
+libswscale4_package() {
+	short_desc="FFmpeg video scaling library"
+	pkg_install() {
+		vmove "usr/lib/libswscale.so.*"
+	}
+}
+
+libswresample4_package() {
+	short_desc="FFmpeg video resampling library"
+	pkg_install() {
+		vmove "usr/lib/libswresample.so.*"
+	}
+}
+
+ffmpeg4-devel_package() {
+	depends="
+		libavcodec4>=${version}_${revision}
+		libavdevice4>=${version}_${revision}
+		libavformat4>=${version}_${revision}
+		libavutil4>=${version}_${revision}
+		libavfilter4>=${version}_${revision}
+		libpostproc4>=${version}_${revision}
+		libswscale4>=${version}_${revision}
+		libswresample4>=${version}_${revision}
+		libavresample4>=${version}_${revision}"
+	short_desc+=" - development files"
+	conflicts="ffmpeg-devel"
+	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
+		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
+		nostrip_files="/usr/lib/libavfilter.a"
+	fi
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.a"
+		vmove "usr/lib/*.so"
+		vmove usr/share/ffmpeg/examples
+		vmove usr/share/man/man3
+	}
+}
diff --git a/srcpkgs/libavcodec4 b/srcpkgs/libavcodec4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavcodec4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavdevice4 b/srcpkgs/libavdevice4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavdevice4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavfilter4 b/srcpkgs/libavfilter4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavfilter4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavformat4 b/srcpkgs/libavformat4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavformat4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavresample4 b/srcpkgs/libavresample4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavutil4 b/srcpkgs/libavutil4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavutil4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libpostproc4 b/srcpkgs/libpostproc4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libpostproc4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswresample4 b/srcpkgs/libswresample4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libswresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswscale4 b/srcpkgs/libswscale4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libswscale4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file

From 61d48649123028b25de8ea07292d1b63528e5cdb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:04 -0400
Subject: [PATCH 005/113] opencv: update to 4.7.0.

---
 common/shlibs           | 104 ++++++++++++++++++++--------------------
 srcpkgs/opencv/template |   8 ++--
 2 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index 7987d854066aba..cb85f934e8a040 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2074,58 +2074,58 @@ libcapstone.so.5 capstone-5.0.1_1
 libhavege.so.2 libhaveged-1.9.11_1
 libnih.so.1 libnih-1.0.3_1
 libnih-dbus.so.1 libnih-1.0.3_1
-libopencv_quality.so.406 libopencv-4.6.0_1
-libopencv_reg.so.406 libopencv-4.6.0_1
-libopencv_surface_matching.so.406 libopencv-4.6.0_1
-libopencv_xphoto.so.406 libopencv-4.6.0_1
-libopencv_freetype.so.406 libopencv-4.6.0_1
-libopencv_fuzzy.so.406 libopencv-4.6.0_1
-libopencv_hfs.so.406 libopencv-4.6.0_1
-libopencv_img_hash.so.406 libopencv-4.6.0_1
-libopencv_line_descriptor.so.406 libopencv-4.6.0_1
-libopencv_saliency.so.406 libopencv-4.6.0_1
-libopencv_structured_light.so.406 libopencv-4.6.0_1
-libopencv_aruco.so.406 libopencv-4.6.0_1
-libopencv_bgsegm.so.406 libopencv-4.6.0_1
-libopencv_bioinspired.so.406 libopencv-4.6.0_1
-libopencv_ccalib.so.406 libopencv-4.6.0_1
-libopencv_face.so.406 libopencv-4.6.0_1
-libopencv_tracking.so.406 libopencv-4.6.0_1
-libopencv_xfeatures2d.so.406 libopencv-4.6.0_1
-libopencv_optflow.so.406 libopencv-4.6.0_1
-libopencv_ximgproc.so.406 libopencv-4.6.0_1
-libopencv_plot.so.406 libopencv-4.6.0_1
-libopencv_text.so.406 libopencv-4.6.0_1
-libopencv_ml.so.406 libopencv-4.6.0_1
-libopencv_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn.so.406 libopencv-4.6.0_1
-libopencv_shape.so.406 libopencv-4.6.0_1
-libopencv_stitching.so.406 libopencv-4.6.0_1
-libopencv_photo.so.406 libopencv-4.6.0_1
-libopencv_video.so.406 libopencv-4.6.0_1
-libopencv_calib3d.so.406 libopencv-4.6.0_1
-libopencv_features2d.so.406 libopencv-4.6.0_1
-libopencv_flann.so.406 libopencv-4.6.0_1
-libopencv_highgui.so.406 libopencv-4.6.0_1
-libopencv_videoio.so.406 libopencv-4.6.0_1
-libopencv_imgcodecs.so.406 libopencv-4.6.0_1
-libopencv_imgproc.so.406 libopencv-4.6.0_1
-libopencv_core.so.406 libopencv-4.6.0_1
-libopencv_superres.so.406 libopencv-4.6.0_1
-libopencv_videostab.so.406 libopencv-4.6.0_1
-libopencv_gapi.so.406 libopencv-4.6.0_1
-libopencv_xobjdetect.so.406 libopencv-4.6.0_1
-libopencv_datasets.so.406 libopencv-4.6.0_1
-libopencv_dnn_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn_superres.so.406 libopencv-4.6.0_1
-libopencv_dpm.so.406 libopencv-4.6.0_1
-libopencv_phase_unwrapping.so.406 libopencv-4.6.0_1
-libopencv_stereo.so.406 libopencv-4.6.0_1
-libopencv_rapid.so.406 libopencv-4.6.0_1
-libopencv_intensity_transform.so.406 libopencv-4.6.0_1
-libopencv_alphamat.so.406 libopencv-4.6.0_1
-libopencv_barcode.so.406 libopencv-4.6.0_1
-libopencv_mcc.so.406 libopencv-4.6.0_1
+libopencv_quality.so.407 libopencv-4.7.0_1
+libopencv_reg.so.407 libopencv-4.7.0_1
+libopencv_surface_matching.so.407 libopencv-4.7.0_1
+libopencv_xphoto.so.407 libopencv-4.7.0_1
+libopencv_freetype.so.407 libopencv-4.7.0_1
+libopencv_fuzzy.so.407 libopencv-4.7.0_1
+libopencv_hfs.so.407 libopencv-4.7.0_1
+libopencv_img_hash.so.407 libopencv-4.7.0_1
+libopencv_line_descriptor.so.407 libopencv-4.7.0_1
+libopencv_saliency.so.407 libopencv-4.7.0_1
+libopencv_structured_light.so.407 libopencv-4.7.0_1
+libopencv_aruco.so.407 libopencv-4.7.0_1
+libopencv_bgsegm.so.407 libopencv-4.7.0_1
+libopencv_bioinspired.so.407 libopencv-4.7.0_1
+libopencv_ccalib.so.407 libopencv-4.7.0_1
+libopencv_face.so.407 libopencv-4.7.0_1
+libopencv_tracking.so.407 libopencv-4.7.0_1
+libopencv_xfeatures2d.so.407 libopencv-4.7.0_1
+libopencv_optflow.so.407 libopencv-4.7.0_1
+libopencv_ximgproc.so.407 libopencv-4.7.0_1
+libopencv_plot.so.407 libopencv-4.7.0_1
+libopencv_text.so.407 libopencv-4.7.0_1
+libopencv_ml.so.407 libopencv-4.7.0_1
+libopencv_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn.so.407 libopencv-4.7.0_1
+libopencv_shape.so.407 libopencv-4.7.0_1
+libopencv_stitching.so.407 libopencv-4.7.0_1
+libopencv_photo.so.407 libopencv-4.7.0_1
+libopencv_video.so.407 libopencv-4.7.0_1
+libopencv_calib3d.so.407 libopencv-4.7.0_1
+libopencv_features2d.so.407 libopencv-4.7.0_1
+libopencv_flann.so.407 libopencv-4.7.0_1
+libopencv_highgui.so.407 libopencv-4.7.0_1
+libopencv_videoio.so.407 libopencv-4.7.0_1
+libopencv_imgcodecs.so.407 libopencv-4.7.0_1
+libopencv_imgproc.so.407 libopencv-4.7.0_1
+libopencv_core.so.407 libopencv-4.7.0_1
+libopencv_superres.so.407 libopencv-4.7.0_1
+libopencv_videostab.so.407 libopencv-4.7.0_1
+libopencv_gapi.so.407 libopencv-4.7.0_1
+libopencv_xobjdetect.so.407 libopencv-4.7.0_1
+libopencv_datasets.so.407 libopencv-4.7.0_1
+libopencv_dnn_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn_superres.so.407 libopencv-4.7.0_1
+libopencv_dpm.so.407 libopencv-4.7.0_1
+libopencv_phase_unwrapping.so.407 libopencv-4.7.0_1
+libopencv_stereo.so.407 libopencv-4.7.0_1
+libopencv_rapid.so.407 libopencv-4.7.0_1
+libopencv_intensity_transform.so.407 libopencv-4.7.0_1
+libopencv_alphamat.so.407 libopencv-4.7.0_1
+libopencv_barcode.so.407 libopencv-4.7.0_1
+libopencv_mcc.so.407 libopencv-4.7.0_1
 libuniconf.so.4.6 wvstreams-4.6.1_20
 libwvbase.so.4.6 wvstreams-4.6.1_20
 libwvutils.so.4.6 wvstreams-4.6.1_20
diff --git a/srcpkgs/opencv/template b/srcpkgs/opencv/template
index aea4bfc3a265cf..ce94de9424d18d 100644
--- a/srcpkgs/opencv/template
+++ b/srcpkgs/opencv/template
@@ -1,7 +1,7 @@
 # Template file for 'opencv'
 pkgname=opencv
-version=4.6.0
-revision=6
+version=4.7.0
+revision=1
 create_wrksrc=yes
 build_wrksrc=${pkgname}-${version}
 build_style=cmake
@@ -24,8 +24,8 @@ homepage="https://opencv.org"
 changelog="https://github.com/opencv/opencv/wiki/ChangeLog"
 distfiles="https://github.com/opencv/opencv/archive/${version}.tar.gz
  https://github.com/opencv/opencv_contrib/archive/${version}.tar.gz>contrib.tar.gz"
-checksum="1ec1cba65f9f20fe5a41fda1586e01c70ea0c9a6d7b67c9e13edf0cfe2239277
- 1777d5fd2b59029cf537e5fd6f8aa68d707075822f90bde683fcde086f85f7a7"
+checksum="8df0079cdbe179748a18d44731af62a245a45ebf5085223dc03133954c662973
+ 42df840cf9055e59d0e22c249cfb19f04743e1bdad113d31b1573d3934d62584"
 patch_args="-Np1 -d ${build_wrksrc}"
 # tests hang indenfinitely, even with test data included
 make_check=no

From a02afaf317cd42636474e47d441d0915b438ee41 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 006/113] actiona: revbump for opencv-4.7.0

---
 srcpkgs/actiona/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/actiona/template b/srcpkgs/actiona/template
index cf5f0b7a2ae610..0d899311e6df75 100644
--- a/srcpkgs/actiona/template
+++ b/srcpkgs/actiona/template
@@ -1,7 +1,7 @@
 # Template file for 'actiona'
 pkgname=actiona
 version=3.10.1
-revision=2
+revision=3
 build_style=qmake
 configure_args="PKGCONFIG_OPENCV=opencv4"
 hostmakedepends="pkg-config qt5-plugin-mysql qt5-qmake qt5-host-tools"

From 1392de2d8811850c0d048f98b222d7bbf77b20fe Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 007/113] retroshare: revbump for opencv-4.7.0

---
 srcpkgs/retroshare/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroshare/template b/srcpkgs/retroshare/template
index bb17569277a7f3..49e2c1cbe8a531 100644
--- a/srcpkgs/retroshare/template
+++ b/srcpkgs/retroshare/template
@@ -1,7 +1,7 @@
 # Template file for 'retroshare'
 pkgname=retroshare
 version=0.6.6
-revision=3
+revision=4
 build_style=qmake
 #XXX broadcast feature requires an ancient udp-discovery-cpp which either needs
 # to be fetched+patched (FTBFS) here or packaged :/

From 974e0c6877f8875fef54a5314c3ff169cf9fd54d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 008/113] waifu2x-converter-cpp: revbump for opencv-4.7.0

---
 srcpkgs/waifu2x-converter-cpp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waifu2x-converter-cpp/template b/srcpkgs/waifu2x-converter-cpp/template
index 361b8a23b94977..c5ac17eb54ea4c 100644
--- a/srcpkgs/waifu2x-converter-cpp/template
+++ b/srcpkgs/waifu2x-converter-cpp/template
@@ -1,7 +1,7 @@
 # Template file for 'waifu2x-converter-cpp'
 pkgname=waifu2x-converter-cpp
 version=5.2.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DINSTALL_MODELS=ON"
 hostmakedepends="pkg-config"

From 61d39acba8a9d152862ee2269b74e9254ca4b319 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:38 -0400
Subject: [PATCH 009/113] vlc: revbump for ffmpeg4

---
 srcpkgs/vlc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/vlc/template b/srcpkgs/vlc/template
index bdd0cc414dc1a0..7d245a7b0019c0 100644
--- a/srcpkgs/vlc/template
+++ b/srcpkgs/vlc/template
@@ -1,7 +1,7 @@
 # Template file for 'vlc'
 pkgname=vlc
 version=3.0.20
-revision=3
+revision=4
 build_style=gnu-configure
 configure_args="--disable-gme --disable-libtar --enable-jack
  --enable-live555 --disable-fluidsynth --enable-dvdread
@@ -25,7 +25,7 @@ lib32disabled=yes
 hostmakedepends="automake libtool pkg-config flex gettext libgcrypt-devel
  live555-devel gettext-devel $(vopt_if lua lua52) $(vopt_if chromecast protobuf)"
 makedepends="
- avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg-devel freefont-ttf
+ avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg4-devel freefont-ttf
  gnutls-devel jack-devel liba52-devel libass-devel libbluray-devel
  libcdio-devel libdca-devel libdvbpsi-devel libdvdnav-devel libmad-devel
  libmatroska-devel libmodplug-devel libmpcdec-devel libmpeg2-devel

From e8c322ca1f5b7b808aeb4fbd1550a4fa69221eec Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:55 -0400
Subject: [PATCH 010/113] osg: revbump for ffmpeg4

---
 srcpkgs/osg/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/osg/template b/srcpkgs/osg/template
index a9ebbd287933bd..a131ceaf7a867b 100644
--- a/srcpkgs/osg/template
+++ b/srcpkgs/osg/template
@@ -1,14 +1,14 @@
 # Template file for 'osg'
 pkgname=osg
 version=3.6.5
-revision=2
+revision=3
 build_style=cmake
 build_helper="qemu"
 # don't use /usr/lib64 on 64bit platforms
 configure_args="-DLIB_POSTFIX="
 hostmakedepends="pkg-config xrandr"
 makedepends="MesaLib-devel gtkglext-devel libcurl-devel giflib-devel librsvg-devel
- jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg-devel xine-lib-devel
+ jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg4-devel xine-lib-devel
  SDL2-devel gst-plugins-base1-devel
  $(vopt_if openexr libopenexr-devel)
  $(vopt_if poppler poppler-glib-devel)

From e9af79f4e43272d5953abbc3c824a98eccac6983 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:13 -0400
Subject: [PATCH 011/113] xine-lib: revbump for ffmpeg4

---
 srcpkgs/xine-lib/template | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/xine-lib/template b/srcpkgs/xine-lib/template
index 3be4d08eac77a3..ed6194c17d11e8 100644
--- a/srcpkgs/xine-lib/template
+++ b/srcpkgs/xine-lib/template
@@ -1,14 +1,14 @@
 # Template file for 'xine-lib'
 pkgname=xine-lib
-version=1.2.12
-revision=3
+version=1.2.13
+revision=1
 build_style=gnu-configure
 configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
  --disable-oss"
 hostmakedepends="automake gettext-devel libtool pkg-config perl"
 makedepends="
  zlib-devel alsa-lib-devel libxcb-devel libSM-devel libXext-devel libXv-devel
- libXvMC-devel liba52-devel libmad-devel ffmpeg-devel pulseaudio-devel
+ libXvMC-devel liba52-devel libmad-devel ffmpeg4-devel pulseaudio-devel
  jack-devel samba-devel libflac-devel libmodplug-devel libmpcdec-devel
  speex-devel libtheora-devel libvorbis-devel libdca-devel faad2-devel
  libcdio-devel libbluray-devel aalib-devel libcaca-devel libXinerama-devel
@@ -19,7 +19,7 @@ license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="http://www.xine-project.org"
 changelog="https://sourceforge.net/projects/xine/files/xine-lib/${version}/README.txt/view"
 distfiles="${SOURCEFORGE_SITE}/xine/${pkgname}-${version}.tar.xz"
-checksum=d606270468e1540c2a89c0d7f5fdf11e17ecc0c2698cc0bcb1065ff26abee098
+checksum=5f10d6d718a4a51c17ed1b32b031d4f9b80b061e8276535b2be31e5ac4b75e6f
 
 case "$XBPS_TARGET_MACHINE" in
 	i686-musl)

From 892267353ec401cd4eef8224effda8f1bd6f4810 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 012/113] attract: revbump for ffmpeg4

---
 srcpkgs/attract/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/attract/template b/srcpkgs/attract/template
index 24017d2bacc24d..0edc2a16a2e611 100644
--- a/srcpkgs/attract/template
+++ b/srcpkgs/attract/template
@@ -1,12 +1,12 @@
 # Template file for 'attract'
 pkgname=attract
 version=2.6.2
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="VERBOSE=1"
 make_use_env=yes
 hostmakedepends="pkg-config"
-makedepends="SFML-devel ffmpeg-devel fontconfig-devel glu-devel libarchive-devel
+makedepends="SFML-devel ffmpeg4-devel fontconfig-devel glu-devel libarchive-devel
  libcurl-devel libjpeg-turbo-devel xine-lib rapidjson libXrandr-devel"
 depends="git"
 short_desc="Attract-Mode is a graphical frontend for emulators"

From 4b29c068d77bc23243c704794b924077c78c825b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 013/113] aubio: revbump for ffmpeg6

---
 srcpkgs/aubio/patches/ffmpeg5.patch | 25 +++++++++++++++++++++++++
 srcpkgs/aubio/template              |  2 +-
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/aubio/patches/ffmpeg5.patch

diff --git a/srcpkgs/aubio/patches/ffmpeg5.patch b/srcpkgs/aubio/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..aace41a6e6d9a4
--- /dev/null
+++ b/srcpkgs/aubio/patches/ffmpeg5.patch
@@ -0,0 +1,25 @@
+From 8a05420e5dd8c7b8b2447f82dc919765876511b3 Mon Sep 17 00:00:00 2001
+From: Paul Brossier <piem@piem.org>
+Date: Tue, 25 Jan 2022 18:30:27 +0100
+Subject: [PATCH] [source_avcodec] define FF_API_LAVF_AVCTX for libavcodec >
+ 59, thx @berolinux (closes gh-353)
+
+---
+ src/io/source_avcodec.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/io/source_avcodec.c b/src/io/source_avcodec.c
+index e0ae93b5..1421bd9a 100644
+--- a/src/io/source_avcodec.c
++++ b/src/io/source_avcodec.c
+@@ -68,6 +68,10 @@
+ #define AUBIO_AVCODEC_MAX_BUFFER_SIZE AV_INPUT_BUFFER_MIN_SIZE
+ #endif
+ 
++#if LIBAVCODEC_VERSION_MAJOR >= 59
++#define FF_API_LAVF_AVCTX 1
++#endif
++
+ struct _aubio_source_avcodec_t {
+   uint_t hop_size;
+   uint_t samplerate;
diff --git a/srcpkgs/aubio/template b/srcpkgs/aubio/template
index ad1c4b25699178..7d875cc02541a7 100644
--- a/srcpkgs/aubio/template
+++ b/srcpkgs/aubio/template
@@ -1,7 +1,7 @@
 # Template file for 'aubio'
 pkgname=aubio
 version=0.4.9
-revision=1
+revision=2
 build_style=waf3
 # XXX lash, pure and swig support.
 hostmakedepends="pkg-config txt2man"

From 6cf7e69b71145ec00803c39902861effe6d653e5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 014/113] audacious-plugins: revbump for ffmpeg6

---
 .../audacious-plugins/patches/ffmpeg5.patch   | 43 +++++++++++++++++++
 srcpkgs/audacious-plugins/template            |  2 +-
 2 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/audacious-plugins/patches/ffmpeg5.patch

diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg5.patch b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..4e5e34099d71c4
--- /dev/null
+++ b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
@@ -0,0 +1,43 @@
+commit 298aa371c56c2f52c25a33d9bdec4918b11cebdc
+Author: tibequadorian <tibequadorian@posteo.de>
+Date:   Sat Mar 19 18:40:12 2022 +0100
+
+    audacious-plugins: rebuild against ffmpeg-5.0
+
+diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+new file mode 100644
+index 0000000000..617c11215b
+--- /dev/null
++++ b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+@@ -0,0 +1,31 @@
++From f60beb400eeb1e4778bbfd738bc4a4ccef3de539 Mon Sep 17 00:00:00 2001
++From: John Lindgren <john@jlindgren.net>
++Date: Sat, 5 Mar 2022 12:05:34 -0500
++Subject: [PATCH] Fix build with FFmpeg 5.0
++
++---
++ src/ffaudio/ffaudio-core.cc | 4 ++--
++ 1 file changed, 2 insertions(+), 2 deletions(-)
++
++diff --git a/src/ffaudio/ffaudio-core.cc b/src/ffaudio/ffaudio-core.cc
++index 16dc63e3a..a2b95fd6c 100644
++--- a/src/ffaudio/ffaudio-core.cc
+++++ b/src/ffaudio/ffaudio-core.cc
++@@ -274,7 +274,7 @@ static AVInputFormat * get_format_by_content (const char * name, VFSFile & file)
++         AVProbeData d = {name, buf, filled};
++         score = target;
++ 
++-        f = av_probe_input_format2 (& d, true, & score);
+++        f = (AVInputFormat *) av_probe_input_format2 (& d, true, & score);
++         if (f)
++             break;
++ 
++@@ -347,7 +347,7 @@ static bool find_codec (AVFormatContext * c, CodecInfo * cinfo)
++ #endif
++         if (stream && stream->codecpar && stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
++         {
++-            AVCodec * codec = avcodec_find_decoder (stream->codecpar->codec_id);
+++            AVCodec * codec = (AVCodec *) avcodec_find_decoder (stream->codecpar->codec_id);
++ 
++             if (codec)
++             {
diff --git a/srcpkgs/audacious-plugins/template b/srcpkgs/audacious-plugins/template
index 05e53a9adf78ff..4b1968e03de781 100644
--- a/srcpkgs/audacious-plugins/template
+++ b/srcpkgs/audacious-plugins/template
@@ -2,7 +2,7 @@
 #Keep in sync with audacious!
 pkgname=audacious-plugins
 version=4.3.1
-revision=3
+revision=4
 build_style=meson
 configure_args="$(vopt_bool gtk3 gtk) $(vopt_bool gtk3)
  $(vopt_bool qt) $(vopt_bool qt qt6)"

From 4d554da78809a775c9d5c16f21ae5519b9594f71 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 015/113] audacity: revbump for ffmpeg6

---
 srcpkgs/audacity/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/audacity/template b/srcpkgs/audacity/template
index 7b838119ab2611..84b49305edcef1 100644
--- a/srcpkgs/audacity/template
+++ b/srcpkgs/audacity/template
@@ -1,7 +1,7 @@
 # Template file for 'audacity'
 pkgname=audacity
 version=3.4.2
-revision=1
+revision=2
 build_style=cmake
 build_helper="cmake-wxWidgets-gtk3 qemu"
 configure_args="-Daudacity_use_ffmpeg=loaded -Daudacity_lib_preference=system

From 825de6f7283905da481fdeb071acd16f9ae081d2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 016/113] avidemux: revbump for ffmpeg6

---
 srcpkgs/avidemux/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/avidemux/template b/srcpkgs/avidemux/template
index 253a0243e22599..557285982d2b8f 100644
--- a/srcpkgs/avidemux/template
+++ b/srcpkgs/avidemux/template
@@ -1,7 +1,7 @@
 # Template file for 'avidemux'
 pkgname=avidemux
 version=2.8.0
-revision=2
+revision=3
 # Can't be compiled for aarch64, arm* or mips*
 archs="x86_64* i686*"
 hostmakedepends="cmake pkg-config qt5-host-tools qt5-devel tar yasm"

From 8600cc85fc94a85ee04c83adf7fa3016e02d277c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 017/113] blender: revbump for ffmpeg6

---
 srcpkgs/blender/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index 1dc61ec9d29d84..e238717ac8c729 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -1,7 +1,7 @@
 # Template file for 'blender'
 pkgname=blender
 version=4.0.2
-revision=1
+revision=2
 archs="x86_64* ppc64*"
 build_style="cmake"
 pycompile_dirs="usr/share/blender/${version%.*}/scripts"
@@ -9,8 +9,8 @@ configure_args="-DWITH_INSTALL_PORTABLE=OFF -DWITH_PYTHON_INSTALL=OFF
  -DWITH_JACK=ON -DWITH_CODEC_FFMPEG=ON -DWITH_CODEC_SNDFILE=ON -DWITH_OPENMP=ON
  -DWITH_FFTW3=ON -DWITH_MOD_OCEANSIM=ON -DWITH_CYCLES_EMBREE=OFF -DWITH_OPENCOLORIO=ON
  -DWITH_IMAGE_OPENEXR=ON -DWITH_IMAGE_OPENJPEG=ON -DWITH_OPENSUBDIV=ON
- -DWITH_OPENCOLLADA=ON -DWITH_SYSTEM_GLEW=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
- -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_LIBDECOR=ON
+ -DWITH_OPENCOLLADA=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
+ -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_WAYLAND_LIBDECOR=ON
  -DWITH_BUILDINFO=OFF -DPYTHON_VERSION=${py3_ver} -DPYTHON_LIBPATH=/usr/lib
  -DPYTHON_LIBRARY=python${py3_ver}${py3_abiver} -DPYTHON_INCLUDE_DIRS=/${py3_inc}
  -DWITH_SYSTEM_LZO=ON -DWITH_SYSTEM_EIGEN3=ON -DWITH_SYSTEM_FREETYPE=ON"

From d2117c5c688d5b4e5bf0c8f60bc44115dd124da0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 018/113] cantata: revbump for ffmpeg6

---
 srcpkgs/cantata/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cantata/template b/srcpkgs/cantata/template
index 4b417d80d5c2da..8a90aaa4c07a2a 100644
--- a/srcpkgs/cantata/template
+++ b/srcpkgs/cantata/template
@@ -1,7 +1,7 @@
 # Template file for 'cantata'
 pkgname=cantata
 version=2.5.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools qt5-tools"
 makedepends="qt5-devel qt5-tools-devel qt5-svg-devel qt5-xmlpatterns-devel

From 9693a352871f087b4cd2b3b728ecdd232b1a3625 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 019/113] ccextractor: revbump for ffmpeg4

---
 srcpkgs/ccextractor/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/ccextractor/template b/srcpkgs/ccextractor/template
index 84059ffd02398a..28239189a6e3cf 100644
--- a/srcpkgs/ccextractor/template
+++ b/srcpkgs/ccextractor/template
@@ -1,12 +1,12 @@
 # Template file for 'ccextractor'
 pkgname=ccextractor
 version=0.93
-revision=2
+revision=3
 build_wrksrc="linux"
 build_style=gnu-configure
 configure_args="--enable-ocr --enable-hardsubx"
 hostmakedepends="automake pkg-config"
-makedepends="leptonica-devel tesseract-ocr-devel ffmpeg-devel"
+makedepends="leptonica-devel tesseract-ocr-devel ffmpeg4-devel"
 short_desc="Extract subtitles from video streams"
 maintainer="newbluemoon <blaumolch@mailbox.org>"
 license="GPL-2.0-or-later"

From 4fbf16a482260a5f3c2727bbb44de02b0873bd72 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 020/113] chromaprint: revbump for ffmpeg6

---
 srcpkgs/chromaprint/patches/ffmpeg5.patch | 569 ++++++++++++++++++++++
 srcpkgs/chromaprint/template              |   2 +-
 2 files changed, 570 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromaprint/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromaprint/patches/ffmpeg5.patch b/srcpkgs/chromaprint/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..a9fd307a23c8a4
--- /dev/null
+++ b/srcpkgs/chromaprint/patches/ffmpeg5.patch
@@ -0,0 +1,569 @@
+From 8ccad6937177b1b92e40ab8f4447ea27bac009a7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= <lalinsky@gmail.com>
+Date: Fri, 4 Nov 2022 21:47:38 +0100
+Subject: [PATCH] Use FFmpeg 5.x (#120)
+
+* Use FFmpeg 5.1.2 for CI builds
+
+* Build on Ubuntu 20.04
+
+* Upgrade code to FFmpeg 5.x APIs
+
+* Only set FFmpeg include dirs if building tools
+
+* No longer needed
+
+* Use ubuntu 20.04
+---
+ .github/workflows/build.yml                   |   6 +-
+ CMakeLists.txt                                |  16 --
+ package/build.sh                              |   4 +-
+ src/audio/ffmpeg_audio_processor.h            |   2 -
+ src/audio/ffmpeg_audio_processor_avresample.h |  72 -------
+ src/audio/ffmpeg_audio_processor_swresample.h |  18 +-
+ src/audio/ffmpeg_audio_reader.h               | 197 +++++++++---------
+ tests/CMakeLists.txt                          |   6 +
+ 8 files changed, 122 insertions(+), 199 deletions(-)
+ delete mode 100644 src/audio/ffmpeg_audio_processor_avresample.h
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index f8d6a32..4da2405 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -84,9 +84,6 @@ find_package(FFmpeg)
+ if(FFMPEG_LIBRARIES)
+ 	cmake_push_check_state(RESET)
+ 	set(CMAKE_REQUIRED_LIBRARIES ${FFMPEG_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -lm)
+-	check_function_exists(av_packet_unref HAVE_AV_PACKET_UNREF)
+-	check_function_exists(av_frame_alloc HAVE_AV_FRAME_ALLOC)
+-	check_function_exists(av_frame_free HAVE_AV_FRAME_FREE)
+ 	cmake_pop_check_state()
+ endif()
+
+@@ -163,14 +160,11 @@ message(STATUS "Using ${FFT_LIB} for FFT calculations")
+ if(NOT AUDIO_PROCESSOR_LIB)
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+ 		set(AUDIO_PROCESSOR_LIB "swresample")
+-	elseif(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(AUDIO_PROCESSOR_LIB "avresample")
+ 	endif()
+ endif()
+
+ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE OFF)
+ 		set(USE_SWRESAMPLE ON)
+ 		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBSWRESAMPLE_LIBRARIES})
+ 		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBSWRESAMPLE_INCLUDE_DIRS})
+@@ -178,16 +172,6 @@ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+ 	endif()
+ 	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+-elseif(AUDIO_PROCESSOR_LIB STREQUAL "avresample")
+-	if(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE ON)
+-		set(USE_SWRESAMPLE OFF)
+-		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBAVRESAMPLE_LIBRARIES})
+-		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBAVRESAMPLE_INCLUDE_DIRS})
+-	else()
+-		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+-	endif()
+-	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+ else()
+ 	message(STATUS "Building without audio conversion support, please install FFmpeg with libswresample")
+ endif()
+diff --git a/package/build.sh b/package/build.sh
+index da631ae..b41d36e 100755
+--- a/package/build.sh
++++ b/package/build.sh
+@@ -7,8 +7,8 @@ set -eux
+
+ BASE_DIR=$(cd $(dirname $0)/.. && pwd)
+
+-FFMPEG_VERSION=4.4.1
+-FFMPEG_BUILD_TAG=v4.4.1-1
++FFMPEG_VERSION=5.1.2
++FFMPEG_BUILD_TAG=v${FFMPEG_VERSION}-1
+
+ TMP_BUILD_DIR=$BASE_DIR/$(mktemp -d build.XXXXXXXX)
+ trap 'rm -rf $TMP_BUILD_DIR' EXIT
+diff --git a/src/audio/ffmpeg_audio_processor.h b/src/audio/ffmpeg_audio_processor.h
+index 7628fc7..39f4f6d 100644
+--- a/src/audio/ffmpeg_audio_processor.h
++++ b/src/audio/ffmpeg_audio_processor.h
+@@ -10,8 +10,6 @@
+
+ #if defined(USE_SWRESAMPLE)
+ #include "audio/ffmpeg_audio_processor_swresample.h"
+-#elif defined(USE_AVRESAMPLE)
+-#include "audio/ffmpeg_audio_processor_avresample.h"
+ #else
+ #error "no audio processing library"
+ #endif
+diff --git a/src/audio/ffmpeg_audio_processor_avresample.h b/src/audio/ffmpeg_audio_processor_avresample.h
+deleted file mode 100644
+index bd85f92..0000000
+--- a/src/audio/ffmpeg_audio_processor_avresample.h
++++ /dev/null
+@@ -1,72 +0,0 @@
+-// Copyright (C) 2016  Lukas Lalinsky
+-// Distributed under the MIT license, see the LICENSE file for details.
+-
+-#ifndef CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-#define CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-
+-extern "C" {
+-#include <libavresample/avresample.h>
+-}
+-
+-namespace chromaprint {
+-
+-class FFmpegAudioProcessor {
+-public:
+-	FFmpegAudioProcessor() {
+-		m_resample_ctx = avresample_alloc_context();
+-	}
+-
+-	~FFmpegAudioProcessor() {
+-		avresample_free(&m_resample_ctx);
+-	}
+-
+-	void SetCompatibleMode() {
+-		av_opt_set_int(m_resample_ctx, "filter_size", 16, 0);
+-		av_opt_set_int(m_resample_ctx, "phase_shift", 8, 0);
+-		av_opt_set_int(m_resample_ctx, "linear_interp", 1, 0);
+-		av_opt_set_double(m_resample_ctx, "cutoff", 0.8, 0);
+-	}
+-
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "in_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_rate", sample_rate, 0);
+-	}
+-
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "out_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_rate, 0);
+-	}
+-
+-	int Init() {
+-		return avresample_open(m_resample_ctx);
+-	}
+-
+-	int Convert(uint8_t **out, int out_count, const uint8_t **in, int in_count) {
+-		return avresample_convert(m_resample_ctx, out, 0, out_count, (uint8_t **) in, 0, in_count);
+-	}
+-
+-	int Flush(uint8_t **out, int out_count) {
+-		return avresample_read(m_resample_ctx, out, out_count);
+-	}
+-
+-private:
+-	AVAudioResampleContext *m_resample_ctx = nullptr;
+-};
+-
+-}; // namespace chromaprint
+-
+-#endif
+diff --git a/src/audio/ffmpeg_audio_processor_swresample.h b/src/audio/ffmpeg_audio_processor_swresample.h
+index b86266b..b1d4bea 100644
+--- a/src/audio/ffmpeg_audio_processor_swresample.h
++++ b/src/audio/ffmpeg_audio_processor_swresample.h
+@@ -28,30 +28,28 @@ public:
+ 		av_opt_set_double(m_swr_ctx, "cutoff", 0.8, 0);
+ 	}
+
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "icl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "ich", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetInputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "in_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "isf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "in_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "isr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "in_sample_rate", sample_rate, 0);
+ 	}
+
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "ocl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "och", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetOutputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "out_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "osf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "out_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "osr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "out_sample_rate", sample_rate, 0);
+ 	}
+
+ 	int Init() {
+diff --git a/src/audio/ffmpeg_audio_reader.h b/src/audio/ffmpeg_audio_reader.h
+index 5550164..1c6b346 100644
+--- a/src/audio/ffmpeg_audio_reader.h
++++ b/src/audio/ffmpeg_audio_reader.h
+@@ -62,7 +62,7 @@ public:
+ 	bool Read(const int16_t **data, size_t *size);
+
+ 	bool IsOpen() const { return m_opened; }
+-	bool IsFinished() const { return m_finished && !m_got_frame; }
++	bool IsFinished() const { return !m_has_more_packets && !m_has_more_frames; }
+
+ 	std::string GetError() const { return m_error; }
+ 	int GetErrorCode() const { return m_error_code; }
+@@ -74,20 +74,19 @@ private:
+ 	uint8_t *m_convert_buffer[1] = { nullptr };
+ 	int m_convert_buffer_nb_samples = 0;
+
+-	AVInputFormat *m_input_fmt = nullptr;
++	const AVInputFormat *m_input_fmt = nullptr;
+ 	AVDictionary *m_input_opts = nullptr;
+
+ 	AVFormatContext *m_format_ctx = nullptr;
+ 	AVCodecContext *m_codec_ctx = nullptr;
+-	AVFrame *m_frame = nullptr;
+ 	int m_stream_index = -1;
+ 	std::string m_error;
+ 	int m_error_code = 0;
+-	bool m_finished = false;
+ 	bool m_opened = false;
+-	int m_got_frame = 0;
+-	AVPacket m_packet;
+-	AVPacket m_packet0;
++	bool m_has_more_packets = true;
++	bool m_has_more_frames = true;
++	AVPacket *m_packet = nullptr;
++	AVFrame *m_frame = nullptr;
+
+ 	int m_output_sample_rate = 0;
+ 	int m_output_channels = 0;
+@@ -98,19 +97,12 @@ private:
+
+ inline FFmpegAudioReader::FFmpegAudioReader() {
+ 	av_log_set_level(AV_LOG_QUIET);
+-
+-	av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
+ }
+
+ inline FFmpegAudioReader::~FFmpegAudioReader() {
+ 	Close();
+ 	av_dict_free(&m_input_opts);
+ 	av_freep(&m_convert_buffer[0]);
+-	av_packet_unref(&m_packet0);
+ }
+
+ inline bool FFmpegAudioReader::SetInputFormat(const char *name) {
+@@ -135,11 +127,10 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ 	Close();
+
+-    av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
++	m_packet = av_packet_alloc();
++	if (!m_packet) {
++		return false;
++	}
+
+ 	ret = avformat_open_input(&m_format_ctx, file_name.c_str(), m_input_fmt, &m_input_opts);
+ 	if (ret < 0) {
+@@ -153,26 +144,31 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		return false;
+ 	}
+
+-	AVCodec *codec;
++	const AVCodec *codec;
+ 	ret = av_find_best_stream(m_format_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &codec, 0);
+ 	if (ret < 0) {
+ 		SetError("Could not find any audio stream in the file", ret);
+ 		return false;
+ 	}
+ 	m_stream_index = ret;
++	auto stream = m_format_ctx->streams[m_stream_index];
+
+-	m_codec_ctx = m_format_ctx->streams[m_stream_index]->codec;
++	m_codec_ctx = avcodec_alloc_context3(codec);
+ 	m_codec_ctx->request_sample_fmt = AV_SAMPLE_FMT_S16;
+
++	ret = avcodec_parameters_to_context(m_codec_ctx, stream->codecpar);
++	if (ret < 0) {
++		SetError("Could not copy the stream parameters", ret);
++		return false;
++	}
++
+ 	ret = avcodec_open2(m_codec_ctx, codec, nullptr);
+ 	if (ret < 0) {
+ 		SetError("Could not open the codec", ret);
+ 		return false;
+ 	}
+
+-	if (!m_codec_ctx->channel_layout) {
+-		m_codec_ctx->channel_layout = av_get_default_channel_layout(m_codec_ctx->channels);
+-	}
++	av_dump_format(m_format_ctx, 0, "foo", 0);
+
+ 	m_frame = av_frame_alloc();
+ 	if (!m_frame) {
+@@ -183,19 +179,23 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		m_output_sample_rate = m_codec_ctx->sample_rate;
+ 	}
+
+-	if (!m_output_channels) {
+-		m_output_channels = m_codec_ctx->channels;
++	AVChannelLayout output_channel_layout;
++	if (m_output_channels) {
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
++	} else {
++		m_output_channels = m_codec_ctx->ch_layout.nb_channels;
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
+ 	}
+
+-	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
++	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->ch_layout.nb_channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
+ 		m_converter.reset(new FFmpegAudioProcessor());
+ 		m_converter->SetCompatibleMode();
+ 		m_converter->SetInputSampleFormat(m_codec_ctx->sample_fmt);
+ 		m_converter->SetInputSampleRate(m_codec_ctx->sample_rate);
+-		m_converter->SetInputChannelLayout(m_codec_ctx->channel_layout);
++		m_converter->SetInputChannelLayout(&(m_codec_ctx->ch_layout));
+ 		m_converter->SetOutputSampleFormat(AV_SAMPLE_FMT_S16);
+ 		m_converter->SetOutputSampleRate(m_output_sample_rate);
+-		m_converter->SetOutputChannelLayout(av_get_default_channel_layout(m_output_channels));
++		m_converter->SetOutputChannelLayout(&output_channel_layout);
+ 		auto ret = m_converter->Init();
+ 		if (ret != 0) {
+ 			SetError("Could not create an audio converter instance", ret);
+@@ -203,10 +203,11 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		}
+ 	}
+
++	av_channel_layout_uninit(&output_channel_layout);
++
+ 	m_opened = true;
+-	m_finished = false;
+-	m_got_frame = 0;
+-	m_nb_packets = 0;
++	m_has_more_packets = true;
++	m_has_more_frames = true;
+ 	m_decode_error = 0;
+
+ 	return true;
+@@ -214,6 +215,7 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ inline void FFmpegAudioReader::Close() {
+ 	av_frame_free(&m_frame);
++	av_packet_free(&m_packet);
+
+ 	m_stream_index = -1;
+
+@@ -252,91 +254,98 @@ inline bool FFmpegAudioReader::Read(const int16_t **data, size_t *size) {
+ 		return false;
+ 	}
+
++	*data = nullptr;
++	*size = 0;
++
+ 	int ret;
++	bool needs_packet = false;
+ 	while (true) {
+-		while (m_packet.size <= 0) {
+-			av_packet_unref(&m_packet0);
+-			av_init_packet(&m_packet);
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			ret = av_read_frame(m_format_ctx, &m_packet);
++		while (needs_packet && m_packet->size == 0) {
++			ret = av_read_frame(m_format_ctx, m_packet);
+ 			if (ret < 0) {
+ 				if (ret == AVERROR_EOF) {
+-					m_finished = true;
++					needs_packet = false;
++					m_has_more_packets = false;
+ 					break;
+-				} else {
++				}
++				SetError("Error reading from the audio source", ret);
++				return false;
++			}
++			if (m_packet->stream_index == m_stream_index) {
++				needs_packet = false;
++			} else {
++				av_packet_unref(m_packet);
++			}
++		}
++
++		if (m_packet->size != 0) {
++			ret = avcodec_send_packet(m_codec_ctx, m_packet);
++			if (ret < 0) {
++				if (ret != AVERROR(EAGAIN)) {
+ 					SetError("Error reading from the audio source", ret);
+ 					return false;
+ 				}
+-			}
+-			m_packet0 = m_packet;
+-			if (m_packet.stream_index != m_stream_index) {
+-				m_packet.data = nullptr;
+-				m_packet.size = 0;
+ 			} else {
+-				m_nb_packets++;
++				av_packet_unref(m_packet);
+ 			}
+ 		}
+
+-		ret = avcodec_decode_audio4(m_codec_ctx, m_frame, &m_got_frame, &m_packet);
++		ret = avcodec_receive_frame(m_codec_ctx, m_frame);
+ 		if (ret < 0) {
+-			if (m_decode_error) {
+-				SetError("Error decoding audio frame", m_decode_error);
+-				return false;
++			if (ret == AVERROR_EOF) {
++				m_has_more_frames = false;
++			} else if (ret == AVERROR(EAGAIN)) {
++				if (m_has_more_packets) {
++					needs_packet = true;
++					continue;
++				} else {
++					m_has_more_frames = false;
++				}
+ 			}
+-			m_decode_error = ret;
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			continue;
++			SetError("Error decoding the audio source", ret);
++			return false;
+ 		}
+
+-		break;
+-	}
+-
+-	m_decode_error = 0;
+-
+-	const int decoded = std::min(ret, m_packet.size);
+-	m_packet.data += decoded;
+-	m_packet.size -= decoded;
+-
+-	if (m_got_frame) {
+-		if (m_converter) {
+-			if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
+-				int linsize;
+-				av_freep(&m_convert_buffer[0]);
+-				m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
+-				ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
+-				if (ret < 0) {
+-					SetError("Couldn't allocate audio converter buffer", ret);
++		if (m_frame->nb_samples > 0) {
++			if (m_converter) {
++				if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
++					int linsize;
++					av_freep(&m_convert_buffer[0]);
++					m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
++					ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->ch_layout.nb_channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
++					if (ret < 0) {
++						SetError("Couldn't allocate audio converter buffer", ret);
++						return false;
++					}
++				}
++				auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
++				if (nb_samples < 0) {
++					SetError("Couldn't convert audio", ret);
+ 					return false;
+ 				}
+-			}
+-			auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			}
+-			*data = (const int16_t *) m_convert_buffer[0];
+-			*size = nb_samples;
+-		} else {
+-			*data = (const int16_t *) m_frame->data[0];
+-			*size = m_frame->nb_samples;
+-		}
+-	} else {
+-		if (m_finished && m_converter) {
+-			auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			} else if (nb_samples > 0) {
+-				m_got_frame = 1;
+ 				*data = (const int16_t *) m_convert_buffer[0];
+ 				*size = nb_samples;
++			} else {
++				*data = (const int16_t *) m_frame->data[0];
++				*size = m_frame->nb_samples;
++			}
++		} else {
++			if (m_converter) {
++				if (IsFinished()) {
++					auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
++					if (nb_samples < 0) {
++						SetError("Couldn't convert audio", ret);
++						return false;
++					} else if (nb_samples > 0) {
++						*data = (const int16_t *) m_convert_buffer[0];
++						*size = nb_samples;
++					}
++				}
+ 			}
+ 		}
+-	}
+
+-	return true;
++		return true;
++	}
+ }
+
+ inline void FFmpegAudioReader::SetError(const char *message, int errnum) {
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index a2b517b..123e643 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -38,6 +38,12 @@ set(SRCS
+
+ if(BUILD_TOOLS)
+ 	set(SRCS ${SRCS} ../src/audio/ffmpeg_audio_reader_test.cpp)
++    include_directories(
++        ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}
++        ${AUDIO_PROCESSOR_INCLUDE_DIRS}
++    )
+ 	link_libraries(fpcalc_libs)
+ endif()
+
+-- 
+2.38.1
+
+
diff --git a/srcpkgs/chromaprint/template b/srcpkgs/chromaprint/template
index 7ef7838949f3a3..1f7bbc70a22c80 100644
--- a/srcpkgs/chromaprint/template
+++ b/srcpkgs/chromaprint/template
@@ -1,7 +1,7 @@
 # Template file for 'chromaprint'
 pkgname=chromaprint
 version=1.5.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DBUILD_TOOLS=ON"
 make_check_target="check"

From f289bebbf36550ef5b9696c349e0fc1e04ad2fa3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 021/113] chromium: revbump for ffmpeg6

---
 .../patches/chromium-119-ffmpeg-4.4.patch     | 20 --------
 srcpkgs/chromium/patches/ffmpeg5.patch        | 47 +++++++++++++++++++
 srcpkgs/chromium/template                     |  2 +-
 3 files changed, 48 insertions(+), 21 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch
 create mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch b/srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch
deleted file mode 100644
index 04d04b166ba377..00000000000000
--- a/srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch
+++ /dev/null
@@ -1,20 +0,0 @@
---- a/media/filters/ffmpeg_demuxer.cc.orig
-+++ b/media/filters/ffmpeg_demuxer.cc
-@@ -390,7 +390,7 @@
- 
-   scoped_refptr<DecoderBuffer> buffer;
- 
--    size_t side_data_size = 0;
-+    int side_data_size = 0;
-     uint8_t* side_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
- 
-@@ -453,7 +453,7 @@
-                                        packet->size - data_offset);
-     }
- 
--    size_t skip_samples_size = 0;
-+    int skip_samples_size = 0;
-     const uint32_t* skip_samples_ptr =
-         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
-             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..24e2da38e34ca2
--- /dev/null
+++ b/srcpkgs/chromium/patches/ffmpeg5.patch
@@ -0,0 +1,47 @@
+--- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
++++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
+@@ -92,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+-  if (stream->start_time != kNoFFmpegTimestamp)
++  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -1597,7 +1585,7 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+@@ -1618,7 +1606,7 @@
+     if (stream->type() != DemuxerStream::VIDEO)
+       continue;
+ 
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+ 
+     if (!stream->IsEnabled())
diff --git a/srcpkgs/chromium/template b/srcpkgs/chromium/template
index 5613fa38138221..cd386c8a84ae6c 100644
--- a/srcpkgs/chromium/template
+++ b/srcpkgs/chromium/template
@@ -2,7 +2,7 @@
 pkgname=chromium
 # See https://chromiumdash.appspot.com/releases?platform=Linux for the latest version
 version=120.0.6099.129
-revision=1
+revision=2
 archs="i686* x86_64* aarch64* armv7l*"
 hostmakedepends="
  $(vopt_if clang "clang lld llvm15")

From c6704c9337654a979540e99aabb6d80cdfb289d7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 022/113] cmus: revbump for ffmpeg6

---
 srcpkgs/chromium/patches/ffmpeg5.patch | 47 --------------------------
 srcpkgs/cmus/patches/ffmpeg6.patch     | 12 +++++++
 srcpkgs/cmus/template                  |  2 +-
 3 files changed, 13 insertions(+), 48 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch
 create mode 100644 srcpkgs/cmus/patches/ffmpeg6.patch

diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
deleted file mode 100644
index 24e2da38e34ca2..00000000000000
--- a/srcpkgs/chromium/patches/ffmpeg5.patch
+++ /dev/null
@@ -1,47 +0,0 @@
---- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
-+++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
-@@ -92,24 +92,12 @@
- 
- static base::TimeDelta ExtractStartTime(AVStream* stream) {
-   // The default start time is zero.
--  base::TimeDelta start_time;
-+  base::TimeDelta start_time = kNoTimestamp;
- 
-   // First try to use  the |start_time| value as is.
--  if (stream->start_time != kNoFFmpegTimestamp)
-+  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
-     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
- 
--  // Next try to use the first DTS value, for codecs where we know PTS == DTS
--  // (excludes all H26x codecs). The start time must be returned in PTS.
--  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
--      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
--      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
--      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
--    const base::TimeDelta first_pts =
--        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
--    if (first_pts < start_time)
--      start_time = first_pts;
--  }
--
-   return start_time;
- }
- 
-@@ -1597,7 +1585,7 @@
-   for (const auto& stream : streams_) {
-     if (!stream || stream->IsEnabled() != enabled)
-       continue;
--    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
-+    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
-       continue;
-     if (!lowest_start_time_stream ||
-         stream->start_time() < lowest_start_time_stream->start_time()) {
-@@ -1618,7 +1606,7 @@
-     if (stream->type() != DemuxerStream::VIDEO)
-       continue;
- 
--    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
-+    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
-       continue;
- 
-     if (!stream->IsEnabled())
diff --git a/srcpkgs/cmus/patches/ffmpeg6.patch b/srcpkgs/cmus/patches/ffmpeg6.patch
new file mode 100644
index 00000000000000..ffa95ab811101b
--- /dev/null
+++ b/srcpkgs/cmus/patches/ffmpeg6.patch
@@ -0,0 +1,12 @@
+--- a/ip/ffmpeg.c
++++ b/ip/ffmpeg.c
+@@ -202,9 +202,6 @@ static int ffmpeg_open(struct input_plugin_data *ip_data)
+ 			break;
+ 		}
+ 
+-		if (codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+-			cc->flags |= AV_CODEC_FLAG_TRUNCATED;
+-
+ 		if (avcodec_open2(cc, codec, NULL) < 0) {
+ 			d_print("could not open codec: %d, %s\n", cc->codec_id, avcodec_get_name(cc->codec_id));
+ 			err = -IP_ERROR_UNSUPPORTED_FILE_TYPE;
diff --git a/srcpkgs/cmus/template b/srcpkgs/cmus/template
index 0d1436744f1b2c..a6e4b4fa86cb83 100644
--- a/srcpkgs/cmus/template
+++ b/srcpkgs/cmus/template
@@ -1,7 +1,7 @@
 # Template file for 'cmus'
 pkgname=cmus
 version=2.10.0
-revision=3
+revision=4
 build_style=configure
 configure_args="prefix=/usr LD=$CC"
 hostmakedepends="pkg-config"

From b18ec94e3bc0d8558bd2309a0970b0d5fcde4c69 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 023/113] cyanrip: revbump for ffmpeg6

---
 srcpkgs/cyanrip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cyanrip/template b/srcpkgs/cyanrip/template
index 9796e3461601a7..5db30e020d17ee 100644
--- a/srcpkgs/cyanrip/template
+++ b/srcpkgs/cyanrip/template
@@ -1,7 +1,7 @@
 # Template file for 'cyanrip'
 pkgname=cyanrip
 version=0.9.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config"
 makedepends="ffmpeg-devel libcdio-devel libcdio-paranoia-devel libcurl-devel libmusicbrainz5-devel"

From 70d6ce9bf99586669cafec154dab205e4b36dc1a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 024/113] deadbeef: revbump for ffmpeg4

---
 srcpkgs/deadbeef/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/deadbeef/template b/srcpkgs/deadbeef/template
index f5f4bf24b8cb6d..7b47e615cd48ef 100644
--- a/srcpkgs/deadbeef/template
+++ b/srcpkgs/deadbeef/template
@@ -1,14 +1,14 @@
 # Template file for 'deadbeef'
 pkgname=deadbeef
 version=1.8.8
-revision=3
+revision=4
 create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-oss --disable-lfm --disable-notify --disable-gtk2"
 hostmakedepends="automake libtool gettext gettext-devel intltool pkg-config
  yasm clang glib-devel"
 makedepends="
- alsa-lib-devel dbus-devel faad2-devel ffmpeg-devel gtk+3-devel imlib2-devel
+ alsa-lib-devel dbus-devel faad2-devel ffmpeg4-devel gtk+3-devel imlib2-devel
  jansson-devel libcddb-devel libcdio-devel libcurl-devel libflac-devel
  libmad-devel libpng-devel libsamplerate-devel libsndfile-devel libvorbis-devel
  libzip-devel mpg123-devel opusfile-devel pulseaudio-devel wavpack-devel"

From 186d331e214bdeb2b95755e088accd88eec81868 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 025/113] droidcam-obs-plugin: revbump for ffmpeg6

---
 srcpkgs/droidcam-obs-plugin/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam-obs-plugin/template b/srcpkgs/droidcam-obs-plugin/template
index fc9c9bf6b9d54c..fb0480754df4de 100644
--- a/srcpkgs/droidcam-obs-plugin/template
+++ b/srcpkgs/droidcam-obs-plugin/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam-obs-plugin'
 pkgname=droidcam-obs-plugin
 version=2.0.1
-revision=1
+revision=2
 build_style=gnu-makefile
 make_use_env=yes
 make_build_args="ALLOW_STATIC=no"

From 4a548b4ee98cbdc343a364e1547ff7f963a3473f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 026/113] droidcam: revbump for ffmpeg6

---
 srcpkgs/droidcam/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam/template b/srcpkgs/droidcam/template
index 1c3f1b8b1fc676..32a9220b79a4d1 100644
--- a/srcpkgs/droidcam/template
+++ b/srcpkgs/droidcam/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam'
 pkgname=droidcam
 version=1.8.2
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="USBMUXD=-lusbmuxd-2.0 JPEG=-lturbojpeg"
 hostmakedepends="pkg-config"

From 30355ed184cf6641e77fd546c05172103efae286 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 027/113] ffmpegthumbnailer: revbump for ffmpeg6

---
 .../ffmpegthumbnailer/patches/ffmpeg6.patch   | 202 ++++++++++++++++++
 srcpkgs/ffmpegthumbnailer/template            |   6 +-
 2 files changed, 205 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch

diff --git a/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
new file mode 100644
index 00000000000000..363ff35a28419d
--- /dev/null
+++ b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
@@ -0,0 +1,202 @@
+--- a/libffmpegthumbnailer/moviedecoder.cpp	2017-11-21 14:06:57.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.cpp	2023-05-05 13:14:47.946560668 -0400
+@@ -41,11 +41,6 @@
+ namespace ffmpegthumbnailer
+ {
+ 
+-struct SilenceLogLevel
+-{
+-    SilenceLogLevel() { av_log_set_level(AV_LOG_QUIET); }
+-};
+-
+ MovieDecoder::MovieDecoder(AVFormatContext* pavContext)
+ : m_VideoStream(-1)
+ , m_pFormatContext(pavContext)
+@@ -70,8 +65,6 @@
+ 
+ void MovieDecoder::initialize(const string& filename, bool preferEmbeddedMetadata)
+ {
+-    av_register_all();
+-    avcodec_register_all();
+     avformat_network_init();
+ 
+     string inputFile = filename == "-" ? "pipe:" : filename;
+@@ -97,8 +90,7 @@
+ {
+     if (m_pVideoCodecContext)
+     {
+-        avcodec_close(m_pVideoCodecContext);
+-        m_pVideoCodecContext = nullptr;
++        avcodec_free_context(&m_pVideoCodecContext);
+     }
+ 
+     if ((!m_FormatContextWasGiven) && m_pFormatContext)
+@@ -152,10 +144,10 @@
+     for (unsigned int i = 0; i < m_pFormatContext->nb_streams; ++i)
+     {
+         AVStream *stream = m_pFormatContext->streams[i];
+-        auto ctx = m_pFormatContext->streams[i]->codec;
+-        if (ctx->codec_type == AVMEDIA_TYPE_VIDEO)
++        auto par = m_pFormatContext->streams[i]->codecpar;
++        if (par->codec_type == AVMEDIA_TYPE_VIDEO)
+         {
+-            if (!preferEmbeddedMetadata || !isStillImageCodec(ctx->codec_id))
++            if (!preferEmbeddedMetadata || !isStillImageCodec(par->codec_id))
+             {
+                 videoStreams.push_back(i);
+                 continue;
+@@ -203,8 +195,7 @@
+     }
+ 
+     m_pVideoStream = m_pFormatContext->streams[m_VideoStream];
+-    m_pVideoCodecContext = m_pVideoStream->codec;
+-    m_pVideoCodec = avcodec_find_decoder(m_pVideoCodecContext->codec_id);
++    m_pVideoCodec = avcodec_find_decoder(m_pVideoStream->codecpar->codec_id);
+ 
+     if (m_pVideoCodec == nullptr)
+     {
+@@ -214,6 +205,20 @@
+         throw logic_error("Video Codec not found");
+     }
+ 
++    m_pVideoCodecContext = avcodec_alloc_context3(m_pVideoCodec);
++
++    if (m_pVideoCodecContext == nullptr)
++    {
++        destroy();
++        throw logic_error("Could not allocate video codec context");
++    }
++
++    if (avcodec_parameters_to_context(m_pVideoCodecContext, m_pVideoStream->codecpar) < 0)
++    {
++        destroy();
++        throw logic_error("Could not configure video codec context");
++    }
++
+     m_pVideoCodecContext->workaround_bugs = 1;
+ 
+     if (avcodec_open2(m_pVideoCodecContext, m_pVideoCodec, nullptr) < 0)
+@@ -386,13 +391,6 @@
+ 
+ void MovieDecoder::initializeFilterGraph(const AVRational& timeBase, const std::string& size, bool maintainAspectRatio)
+ {
+-    static const AVPixelFormat pixelFormats[] = { AV_PIX_FMT_RGB24, AV_PIX_FMT_NONE };
+-
+-    auto del = [] (AVBufferSinkParams* p) { av_freep(p); };
+-    std::unique_ptr<AVBufferSinkParams, decltype(del)> buffersinkParams(av_buffersink_params_alloc(), del);
+-
+-    avfilter_register_all();
+-
+     m_pFilterGraph = avfilter_graph_alloc();
+     assert(m_pFilterGraph);
+ 
+@@ -404,10 +402,8 @@
+ 
+     checkRc(avfilter_graph_create_filter(&m_pFilterSource, avfilter_get_by_name("buffer"), "thumb_buffer", ss.str().c_str(), nullptr, m_pFilterGraph),
+             "Failed to create filter source");
+-    buffersinkParams->pixel_fmts = pixelFormats;
+-    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, buffersinkParams.get(), m_pFilterGraph),
++    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, nullptr, m_pFilterGraph),
+             "Failed to create filter sink");
+-    buffersinkParams.release();
+ 
+     AVFilterContext* yadifFilter = nullptr;
+     if (m_pFrame->interlaced_frame != 0)
+@@ -500,15 +496,15 @@
+     }
+ 
+     checkRc(av_seek_frame(m_pFormatContext, -1, timestamp, 0), "Seeking in video failed");
+-    avcodec_flush_buffers(m_pFormatContext->streams[m_VideoStream]->codec);
++    avcodec_flush_buffers(m_pVideoCodecContext);
+ 
+     int keyFrameAttempts = 0;
+-    bool gotFrame = 0;
++    bool gotFrame;
+ 
+     do
+     {
+         int count = 0;
+-        gotFrame = 0;
++        gotFrame = false;
+ 
+         while (!gotFrame && count < 20)
+         {
+@@ -552,17 +548,33 @@
+         return false;
+     }
+ 
+-    av_frame_unref(m_pFrame);
+-
+-    int frameFinished;
++    int rc = avcodec_send_packet(m_pVideoCodecContext, m_pPacket);
++    if(rc == AVERROR(EAGAIN))
++    {
++        rc = 0;
++    }
+ 
+-    int bytesDecoded = avcodec_decode_video2(m_pVideoCodecContext, m_pFrame, &frameFinished, m_pPacket);
+-    if (bytesDecoded < 0)
++    if(rc == AVERROR_EOF)
++    {
++        return false;
++    }
++    else if(rc < 0)
+     {
+-        throw logic_error("Failed to decode video frame: bytesDecoded < 0");
++        throw logic_error("Failed to decode video frame: avcodec_send_packet() < 0");
+     }
+ 
+-    return frameFinished > 0;
++    rc = avcodec_receive_frame(m_pVideoCodecContext, m_pFrame);
++    switch(rc)
++    {
++        case 0:
++            return true;
++
++        case AVERROR(EAGAIN):
++            return false;
++
++        default:
++            throw logic_error("Failed to decode video frame: avcodec_receive_frame() < 0");
++    }
+ }
+ 
+ bool MovieDecoder::getVideoPacket()
+@@ -570,8 +582,6 @@
+     bool framesAvailable = true;
+     bool frameDecoded = false;
+ 
+-    int attempts = 0;
+-
+     if (m_pPacket)
+     {
+         av_packet_unref(m_pPacket);
+@@ -580,6 +590,7 @@
+ 
+     m_pPacket = new AVPacket();
+ 
++
+     while (framesAvailable && !frameDecoded)
+     {
+         framesAvailable = av_read_frame(m_pFormatContext, m_pPacket) >= 0;
+@@ -644,7 +655,7 @@
+ 
+ int32_t MovieDecoder::getStreamRotation()
+ {
+-    int32_t* matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
++    auto matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
+     if (matrix)
+     {
+         auto angle = lround(av_display_rotation_get(matrix));
+
+--- a/libffmpegthumbnailer/moviedecoder.h	2017-11-12 04:23:38.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.h	2023-05-05 13:26:07.095529911 -0400
+@@ -78,7 +78,7 @@
+     int                     m_VideoStream;
+     AVFormatContext*        m_pFormatContext;
+     AVCodecContext*         m_pVideoCodecContext;
+-    AVCodec*                m_pVideoCodec;
++    const AVCodec*          m_pVideoCodec;
+     AVFilterGraph*          m_pFilterGraph;
+     AVFilterContext*        m_pFilterSource;
+     AVFilterContext*        m_pFilterSink;
diff --git a/srcpkgs/ffmpegthumbnailer/template b/srcpkgs/ffmpegthumbnailer/template
index 039eea7622b391..35d546018d12af 100644
--- a/srcpkgs/ffmpegthumbnailer/template
+++ b/srcpkgs/ffmpegthumbnailer/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbnailer'
 pkgname=ffmpegthumbnailer
 version=2.2.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libpng-devel libjpeg-turbo-devel ffmpeg-devel"
@@ -9,8 +9,8 @@ depends="ffmpeg"
 short_desc="Lightweight video thumbnailer"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
-homepage="https://github.com/dirkvdb/${pkgname}"
-distfiles="${homepage}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
+homepage="https://github.com/dirkvdb"
+distfiles="${homepage}/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
 checksum=1cb24059c38223f657b300c84dd80491b7040d4b69471c4fea69be862bc99b5b
 
 post_install() {

From e49296712eff853f21b668de390366391d498531 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 028/113] ffmpegthumbs: revbump for ffmpeg6

---
 srcpkgs/ffmpegthumbs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ffmpegthumbs/template b/srcpkgs/ffmpegthumbs/template
index 5f0b9414dadaf5..11b88193528f4b 100644
--- a/srcpkgs/ffmpegthumbs/template
+++ b/srcpkgs/ffmpegthumbs/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbs'
 pkgname=ffmpegthumbs
 version=22.12.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules kcoreaddons kconfig-devel
  pkg-config qt5-host-tools qt5-qmake gettext"

From d86fe475bddf37924fb14449aa57b5d54d16570e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 029/113] ffms2: revbump for ffmpeg6

---
 srcpkgs/ffms2/patches/ffmpeg5.patch | 424 ++++++++++++++++++++++++++++
 srcpkgs/ffms2/template              |   2 +-
 2 files changed, 425 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ffms2/patches/ffmpeg5.patch

diff --git a/srcpkgs/ffms2/patches/ffmpeg5.patch b/srcpkgs/ffms2/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..1479fabcafcb4e
--- /dev/null
+++ b/srcpkgs/ffms2/patches/ffmpeg5.patch
@@ -0,0 +1,424 @@
+From 45673149e9a2f5586855ad472e3059084eaa36b1 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:41:21 +0100
+Subject: [PATCH] Use auto for AVCodec
+
+The geniuses over at FFmpeg decided to constify this API, so old
+versions of the library will return AVCodec *, while new versions
+of the libary will return const AVCodec *, which, in C++, are not
+OK to convert between.
+
+Rather than use some macro hell in ffmscompat.h, we can work around
+this by using auto.
+
+Gross.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 2 +-
+ src/core/indexing.cpp    | 6 +++---
+ src/core/videosource.cpp | 2 +-
+ 3 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index e4ce97c..ac09666 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -469,7 +469,7 @@ void FFMS_AudioSource::OpenFile() {
+ 
+     LAVFOpenFile(SourceFile.c_str(), FormatContext, TrackNumber);
+ 
+-    AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
++    auto *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
+     if (Codec == nullptr)
+         throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+             "Audio codec not found");
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index e547c5a..59fb4e8 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -384,7 +384,7 @@ FFMS_TrackType FFMS_Indexer::GetTrackType(int Track) {
+ }
+ 
+ const char *FFMS_Indexer::GetTrackCodec(int Track) {
+-    AVCodec *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
++    auto *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
+     return codec ? codec->name : nullptr;
+ }
+ 
+@@ -402,7 +402,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             UseDTS);
+ 
+         if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            AVCodec *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (!VideoCodec) {
+                 FormatContext->streams[i]->discard = AVDISCARD_ALL;
+                 IndexMask.erase(i);
+@@ -433,7 +433,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 IndexMask.insert(i);
+             }
+         } else if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+-            AVCodec *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (AudioCodec == nullptr)
+                 throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_UNSUPPORTED,
+                     "Audio codec not found");
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index b889970..8956c22 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -171,7 +171,7 @@ FFMS_VideoSource::FFMS_VideoSource(const char *SourceFile, FFMS_Index &Index, in
+ 
+         LAVFOpenFile(SourceFile, FormatContext, VideoTrack);
+ 
+-        AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
++        auto *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
+         if (Codec == nullptr)
+             throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+                 "Video codec not found");
+-- 
+2.40.0
+
+From 96cbf38ea9381829a1314f432a2c60495dcefaad Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:12:41 +0100
+Subject: [PATCH] all: Update AVPacket API usage
+
+AVPackets must all be on the heap now, since it is no longer
+part of the libav* ABI.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 16 ++++++----
+ src/core/indexing.cpp    | 63 ++++++++++++++++++++++------------------
+ src/core/indexing.h      |  4 +--
+ src/core/utils.cpp       |  6 ----
+ src/core/utils.h         |  1 -
+ src/core/videosource.cpp | 30 ++++++++++---------
+ 6 files changed, 64 insertions(+), 56 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index 37cf9ae..e4ce97c 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -285,10 +285,15 @@ FFMS_AudioSource::AudioBlock *FFMS_AudioSource::CacheBlock(CacheIterator &pos) {
+ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     CurrentFrame = &Frames[PacketNumber];
+ 
+-    AVPacket Packet;
+-    if (!ReadPacket(&Packet))
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++    if (!ReadPacket(Packet)) {
++        av_packet_free(&Packet);
+         throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_UNKNOWN,
+             "ReadPacket unexpectedly failed to read a packet");
++    }
+ 
+     // ReadPacket may have changed the packet number
+     CurrentFrame = &Frames[PacketNumber];
+@@ -297,8 +302,9 @@ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     int NumberOfSamples = 0;
+     AudioBlock *CachedBlock = nullptr;
+     
+-    int Ret = avcodec_send_packet(CodecContext, &Packet);
+-    av_packet_unref(&Packet);
++    int Ret = avcodec_send_packet(CodecContext, Packet);
++    av_packet_unref(Packet);
++    av_packet_free(&Packet);
+ 
+     av_frame_unref(DecodeFrame);
+     Ret = avcodec_receive_frame(CodecContext, DecodeFrame);
+@@ -513,8 +519,6 @@ void FFMS_AudioSource::Seek() {
+ }
+ 
+ bool FFMS_AudioSource::ReadPacket(AVPacket *Packet) {
+-    InitNullPacket(*Packet);
+-
+     while (av_read_frame(FormatContext, Packet) >= 0) {
+         if (Packet->stream_index == TrackNumber) {
+             // Required because not all audio packets, especially in ogg, have a pts. Use the previous valid packet's pts instead.
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index 23fb95b..e547c5a 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -320,7 +320,7 @@ void FFMS_Indexer::CheckAudioProperties(int Track, AVCodecContext *Context) {
+     }
+ }
+ 
+-void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict,
++void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict,
+                                     int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct) {
+     if (VideoContext.Parser) {
+         uint8_t *OB;
+@@ -330,8 +330,8 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+         av_parser_parse2(VideoContext.Parser,
+             VideoContext.CodecContext,
+             &OB, &OBSize,
+-            pkt.data, pkt.size,
+-            pkt.pts, pkt.dts, pkt.pos);
++            pkt->data, pkt->size,
++            pkt->pts, pkt->dts, pkt->pos);
+ 
+         // H.264 (PAFF) and HEVC may have one field per packet, so we need to track
+         // when we have a full or half frame available, and mark one of them as
+@@ -351,15 +351,15 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+ 
+         *RepeatPict = VideoContext.Parser->repeat_pict;
+         *FrameType = VideoContext.Parser->pict_type;
+-        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt.flags & AV_PKT_FLAG_DISCARD));
++        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt->flags & AV_PKT_FLAG_DISCARD));
+     } else {
+-        *Invisible = !!(pkt.flags & AV_PKT_FLAG_DISCARD);
++        *Invisible = !!(pkt->flags & AV_PKT_FLAG_DISCARD);
+     }
+ 
+     if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP8)
+-        ParseVP8(pkt.data[0], Invisible, FrameType);
++        ParseVP8(pkt->data[0], Invisible, FrameType);
+     else if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP9)
+-        ParseVP9(pkt.data[0], Invisible, FrameType);
++        ParseVP9(pkt->data[0], Invisible, FrameType);
+ }
+ 
+ void FFMS_Indexer::Free() {
+@@ -458,32 +458,36 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+         }
+     }
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
+     std::vector<int64_t> LastValidTS(FormatContext->nb_streams, AV_NOPTS_VALUE);
+ 
+     int64_t filesize = avio_size(FormatContext->pb);
+     enum AVPictureStructure LastPicStruct = AV_PICTURE_STRUCTURE_UNKNOWN;
+-    while (av_read_frame(FormatContext, &Packet) >= 0) {
++    while (av_read_frame(FormatContext, Packet) >= 0) {
+         // Update progress
+         // FormatContext->pb can apparently be NULL when opening images.
+         if (IC && FormatContext->pb) {
+-            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate))
++            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate)) {
++                av_packet_free(&Packet);
+                 throw FFMS_Exception(FFMS_ERROR_CANCELLED, FFMS_ERROR_USER,
+                     "Cancelled by user");
++            }
+         }
+-        if (!IndexMask.count(Packet.stream_index)) {
+-            av_packet_unref(&Packet);
++        if (!IndexMask.count(Packet->stream_index)) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+-        int Track = Packet.stream_index;
++        int Track = Packet->stream_index;
+         FFMS_Track &TrackInfo = (*TrackIndices)[Track];
+-        bool KeyFrame = !!(Packet.flags & AV_PKT_FLAG_KEY);
++        bool KeyFrame = !!(Packet->flags & AV_PKT_FLAG_KEY);
+         ReadTS(Packet, LastValidTS[Track], (*TrackIndices)[Track].UseDTS);
+ 
+         if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            int64_t PTS = TrackInfo.UseDTS ? Packet.dts : Packet.pts;
++            int64_t PTS = TrackInfo.UseDTS ? Packet->dts : Packet->pts;
+             if (PTS == AV_NOPTS_VALUE) {
+                 // VPx alt-refs are output as packets which lack timestmps or durations, since
+                 // they are invisible. Currently, the timestamp mangling code in libavformat
+@@ -495,9 +499,11 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 // FFMS2 currently sorts packets by PTS, which will break decoding, otherwise.
+                 bool HasAltRefs = (FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP8 ||
+                                    FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP9);
+-                if (Packet.duration == 0 && !HasAltRefs)
++                if (Packet->duration == 0 && !HasAltRefs) {
++                    av_packet_free(&Packet);
+                     throw FFMS_Exception(FFMS_ERROR_INDEXING, FFMS_ERROR_PARSER,
+                         "Invalid packet pts, dts, and duration");
++                }
+ 
+                 if (TrackInfo.empty())
+                     PTS = 0;
+@@ -513,7 +519,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             ParseVideoPacket(AVContexts[Track], Packet, &RepeatPict, &FrameType, &Invisible, &LastPicStruct);
+ 
+             TrackInfo.AddVideoFrame(PTS, RepeatPict, KeyFrame,
+-                FrameType, Packet.pos, Invisible);
++                FrameType, Packet->pos, Invisible);
+         } else if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+             // For video seeking timestamps are used only if all packets have
+             // timestamps, while for audio they're used if any have timestamps,
+@@ -522,28 +528,29 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 TrackInfo.HasTS = true;
+ 
+             int64_t StartSample = AVContexts[Track].CurrentSample;
+-            uint32_t SampleCount = IndexAudioPacket(Track, &Packet, AVContexts[Track], *TrackIndices);
++            uint32_t SampleCount = IndexAudioPacket(Track, Packet, AVContexts[Track], *TrackIndices);
+             TrackInfo.SampleRate = AVContexts[Track].CodecContext->sample_rate;
+ 
+             TrackInfo.AddAudioFrame(LastValidTS[Track],
+-                StartSample, SampleCount, KeyFrame, Packet.pos, Packet.flags & AV_PKT_FLAG_DISCARD);
++                StartSample, SampleCount, KeyFrame, Packet->pos, Packet->flags & AV_PKT_FLAG_DISCARD);
+         }
+ 
+-        if (!(Packet.flags & AV_PKT_FLAG_DISCARD))
+-            TrackInfo.LastDuration = Packet.duration;
++        if (!(Packet->flags & AV_PKT_FLAG_DISCARD))
++            TrackInfo.LastDuration = Packet->duration;
+ 
+-        av_packet_unref(&Packet);
++        av_packet_unref(Packet);
+     }
++    av_packet_free(&Packet);
+ 
+     TrackIndices->Finalize(AVContexts, FormatContext->iformat->name);
+     return TrackIndices.release();
+ }
+ 
+-void FFMS_Indexer::ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS) {
+-    if (!UseDTS && Packet.pts != AV_NOPTS_VALUE)
+-        TS = Packet.pts;
++void FFMS_Indexer::ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS) {
++    if (!UseDTS && Packet->pts != AV_NOPTS_VALUE)
++        TS = Packet->pts;
+     if (TS == AV_NOPTS_VALUE)
+         UseDTS = true;
+-    if (UseDTS && Packet.dts != AV_NOPTS_VALUE)
+-        TS = Packet.dts;
++    if (UseDTS && Packet->dts != AV_NOPTS_VALUE)
++        TS = Packet->dts;
+ }
+diff --git a/src/core/indexing.h b/src/core/indexing.h
+index 3cfc3c3..5c06868 100644
+--- a/src/core/indexing.h
++++ b/src/core/indexing.h
+@@ -80,10 +80,10 @@ private:
+     int64_t Filesize;
+     uint8_t Digest[20];
+ 
+-    void ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS);
++    void ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS);
+     void CheckAudioProperties(int Track, AVCodecContext *Context);
+     uint32_t IndexAudioPacket(int Track, AVPacket *Packet, SharedAVContext &Context, FFMS_Index &TrackIndices);
+-    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
++    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
+     void Free();
+ public:
+     FFMS_Indexer(const char *Filename);
+diff --git a/src/core/utils.cpp b/src/core/utils.cpp
+index ce67533..8a2e997 100644
+--- a/src/core/utils.cpp
++++ b/src/core/utils.cpp
+@@ -62,12 +62,6 @@ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo) {
+     }
+ }
+ 
+-void InitNullPacket(AVPacket &pkt) {
+-    av_init_packet(&pkt);
+-    pkt.data = nullptr;
+-    pkt.size = 0;
+-}
+-
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames) {
+     AP.SampleFormat = static_cast<FFMS_SampleFormat>(av_get_packed_sample_fmt(CTX->sample_fmt));
+     AP.BitsPerSample = av_get_bytes_per_sample(CTX->sample_fmt) * 8;
+diff --git a/src/core/utils.h b/src/core/utils.h
+index 9819dc7..003ab79 100644
+--- a/src/core/utils.h
++++ b/src/core/utils.h
+@@ -58,7 +58,6 @@ std::unique_ptr<T> make_unique(Args&&... args) {
+ }
+ 
+ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo);
+-void InitNullPacket(AVPacket &pkt);
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames);
+ 
+ void LAVFOpenFile(const char *SourceFile, AVFormatContext *&FormatContext, int Track);
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index 06bd161..b889970 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -673,30 +673,34 @@ void FFMS_VideoSource::DecodeNextFrame(int64_t &AStartTime, int64_t &Pos) {
+     if (HasPendingDelayedFrames())
+         return;
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
+-
+-    while (ReadFrame(&Packet) >= 0) {
+-        if (Packet.stream_index != VideoTrack) {
+-            av_packet_unref(&Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++
++    while (ReadFrame(Packet) >= 0) {
++        if (Packet->stream_index != VideoTrack) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+         if (AStartTime < 0)
+-            AStartTime = Frames.UseDTS ? Packet.dts : Packet.pts;
++            AStartTime = Frames.UseDTS ? Packet->dts : Packet->pts;
+ 
+         if (Pos < 0)
+-            Pos = Packet.pos;
++            Pos = Packet->pos;
+ 
+-        bool FrameFinished = DecodePacket(&Packet);
+-        av_packet_unref(&Packet);
+-        if (FrameFinished)
++        bool FrameFinished = DecodePacket(Packet);
++        av_packet_unref(Packet);
++        if (FrameFinished) {
++            av_packet_free(&Packet);
+             return;
++        }
+     }
+ 
+     // Flush final frames
+-    InitNullPacket(Packet);
+-    DecodePacket(&Packet);
++    DecodePacket(Packet);
++    av_packet_free(&Packet);
+ }
+ 
+ bool FFMS_VideoSource::SeekTo(int n, int SeekOffset) {
+-- 
+2.40.0
+
+From bf9e03e9e08534c024e5a744a6437c4aac160201 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:20:47 +0100
+Subject: [PATCH 2/3] configure: Remove deprecated API use
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ configure.ac | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index b35ef80bc..d19714d0f 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -102,10 +102,10 @@ CFLAGS="$_CFLAGS $FFMPEG_CFLAGS"
+
+ AC_DEFUN([TEST_FFMPEG],
+          [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+-            #include <libavcodec/avcodec.h>
++            #include <libavformat/avformat.h>
+             #include <libswscale/swscale.h>
+             ]],[[
+-                avcodec_register_all();
++                avformat_network_init();
+                 swscale_version();
+             ]])], [eval $1=yes], [eval $1=no])
+         ])
+
diff --git a/srcpkgs/ffms2/template b/srcpkgs/ffms2/template
index 365f64d10cbabf..1641ecf43be5bb 100644
--- a/srcpkgs/ffms2/template
+++ b/srcpkgs/ffms2/template
@@ -1,7 +1,7 @@
 # Template file for 'ffms2'
 pkgname=ffms2
 version=2.40
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-shared --disable-static"
 hostmakedepends="pkg-config autoconf automake libtool"

From c70d3b4a5e8907f5f92cb546c2099e706dcd2fce Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 030/113] freerdp: revbump for ffmpeg6

---
 .../freerdp/patches/ffmpeg6_aa2cb9aa.patch    | 42 +++++++++++++++++++
 srcpkgs/freerdp/template                      |  2 +-
 2 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch

diff --git a/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
new file mode 100644
index 00000000000000..a4324da3a8822b
--- /dev/null
+++ b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
@@ -0,0 +1,42 @@
+From aa2cb9aa5ff5562433598ba168a466e0752bca0e Mon Sep 17 00:00:00 2001
+From: akallabeth <akallabeth@posteo.net>
+Date: Tue, 14 Feb 2023 07:48:54 +0100
+Subject: [PATCH] Fixed #8686: Update h264 to use new FFMPEG API
+
+---
+ channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c | 2 ++
+ libfreerdp/codec/h264_ffmpeg.c            | 2 ++
+ 2 files changed, 4 insertions(+)
+
+diff --git a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+index 339462d865f..beea80b7a1e 100644
+--- a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
++++ b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+@@ -239,8 +239,10 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYP
+ 		}
+ 	}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 	if (mdecoder->codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		mdecoder->codec_context->flags |= AV_CODEC_FLAG_TRUNCATED;
++#endif
+ 
+ 	return TRUE;
+ }
+diff --git a/libfreerdp/codec/h264_ffmpeg.c b/libfreerdp/codec/h264_ffmpeg.c
+index 8a23db2473c..896a333019b 100644
+--- a/libfreerdp/codec/h264_ffmpeg.c
++++ b/libfreerdp/codec/h264_ffmpeg.c
+@@ -615,10 +615,12 @@ static BOOL libavcodec_init(H264_CONTEXT* h264)
+ 			goto EXCEPTION;
+ 		}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 		if (sys->codecDecoder->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		{
+ 			sys->codecDecoderContext->flags |= AV_CODEC_FLAG_TRUNCATED;
+ 		}
++#endif
+ 
+ #ifdef WITH_VAAPI
+ 
diff --git a/srcpkgs/freerdp/template b/srcpkgs/freerdp/template
index f36c38ca885b39..97b1d5ea519cda 100644
--- a/srcpkgs/freerdp/template
+++ b/srcpkgs/freerdp/template
@@ -1,7 +1,7 @@
 # Template file for 'freerdp'
 pkgname=freerdp
 version=2.10.0
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DWITH_ALSA=ON -DWITH_CUPS=OFF -DWITH_FFMPEG=ON
  -DWITH_GSTREAMER_0_10=OFF -DWITH_GSTREAMER_1_0=OFF -DWITH_JPEG=ON

From e5a32d3de422064b18f279622cdccffc229676f4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 031/113] gerbera: revbump for ffmpeg6

---
 srcpkgs/gerbera/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gerbera/template b/srcpkgs/gerbera/template
index ae14f35c767c03..2dc0ac0ce03b55 100644
--- a/srcpkgs/gerbera/template
+++ b/srcpkgs/gerbera/template
@@ -1,7 +1,7 @@
 # Template file for 'gerbera'
 pkgname=gerbera
 version=1.12.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_SYSTEMD=0 -DWITH_AVCODEC=1"
 hostmakedepends="pkg-config"

From 2acc328be335c29caea728f8a1e6c5a158b532ae Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 032/113] goldendict: revbump for ffmpeg6

---
 srcpkgs/goldendict/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/goldendict/template b/srcpkgs/goldendict/template
index f4a05759f693d3..97f44347b03a6a 100644
--- a/srcpkgs/goldendict/template
+++ b/srcpkgs/goldendict/template
@@ -1,7 +1,7 @@
 # Template file for 'goldendict'
 pkgname=goldendict
 version=1.5.0
-revision=1
+revision=2
 build_style=qmake
 configure_args="CONFIG+=zim_support goldendict.pro"
 hostmakedepends="qt5-qmake pkg-config qt5-host-tools"
@@ -10,7 +10,7 @@ makedepends="tiff-devel qt5-devel libvorbis-devel zlib-devel
  qt5-webkit-devel lzo-devel bzip2-devel libao-devel qt5-svg-devel
  libeb-devel qt5-x11extras-devel ffmpeg-devel liblzma-devel
  qt5-multimedia-devel"
-short_desc="A feature-rich dictionary lookup program"
+short_desc="Feature-rich dictionary lookup program"
 maintainer="John <me@johnnynator.dev>"
 license="GPL-3.0-or-later"
 homepage="http://goldendict.org/"

From db947a876923bfb121571044215cfaf9506d8d50 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 033/113] gst-libav: revbump for ffmpeg6

---
 srcpkgs/gst-libav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index b24be23fc1a6d2..0f9350a251bf67 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.22.9
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"

From bea3802b1642807547be54a126d14bda4f8f51e9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Feb 2024 01:52:46 -0500
Subject: [PATCH 034/113] gst-bad: revbump for ffmpeg6

---
 srcpkgs/gst-plugins-bad1/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index 4fe7053c359c36..63200e74f99a7f 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -27,7 +27,7 @@ makedepends="alsa-lib-devel celt-devel openssl-devel exempi-devel
  fdk-aac-devel flite-devel fluidsynth-devel liblrdf-devel ladspa-sdk
  lilv-devel lv2 libopenjpeg2-devel sbc-devel spandsp-devel vulkan-loader
  Vulkan-Headers webrtc-audio-processing-devel libzbar-devel ffmpeg-devel
- srt-devel libva-devel
+ srt-devel libva-devel oneVPL-devel
  $(vopt_if gme libgme-devel)"
 depends="gst-plugins-base1>=${version}"
 short_desc="GStreamer plugins from the bad set (v1.x)"

From 86e5b0f52ac3d07f498a4c1cdbc1fe8d2299b5e3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 035/113] gst-rtsp-server: revbump for ffmpeg6

---
 srcpkgs/gst-rtsp-server/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index bc2a0dea6ac152..f77026c618eb69 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
 version=1.22.9
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="glib-devel gst-plugins-bad1-devel gobject-introspection

From 7f64c06833c3f462191a9b03d41aa221b4a66da4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 036/113] guvcview: update to 2.0.8.

---
 srcpkgs/guvcview/patches/fix-include.patch | 10 ++++++++++
 srcpkgs/guvcview/template                  |  7 +++----
 2 files changed, 13 insertions(+), 4 deletions(-)
 create mode 100644 srcpkgs/guvcview/patches/fix-include.patch

diff --git a/srcpkgs/guvcview/patches/fix-include.patch b/srcpkgs/guvcview/patches/fix-include.patch
new file mode 100644
index 00000000000000..503c2af3b78c1a
--- /dev/null
+++ b/srcpkgs/guvcview/patches/fix-include.patch
@@ -0,0 +1,10 @@
+--- a/guvcview/guvcview.c
++++ b/guvcview/guvcview.c
+@@ -28,6 +28,7 @@
+ #include <sys/stat.h>
+ #include <sys/resource.h>
+ #include <errno.h>
++#include <locale.h>
+ 
+ #include "gview.h"
+ #include "gviewv4l2core.h"
diff --git a/srcpkgs/guvcview/template b/srcpkgs/guvcview/template
index d42fd38fa4ad12..86a7fd619612c8 100644
--- a/srcpkgs/guvcview/template
+++ b/srcpkgs/guvcview/template
@@ -1,8 +1,7 @@
 # Template file for 'guvcview'
 pkgname=guvcview
-version=2.0.7
-revision=2
-create_wrksrc=yes
+version=2.0.8
+revision=1
 build_style=gnu-configure
 configure_args="--disable-static --disable-debian-menu"
 hostmakedepends="pkg-config intltool autoconf automake libtool glib-devel"
@@ -14,7 +13,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="http://guvcview.sourceforge.net/"
 distfiles="${SOURCEFORGE_SITE}/${pkgname}/${pkgname}-src-${version}.tar.bz2"
-checksum=f47d51fbd06e44eeaa1a82f4a153c927527c90d94514197a70b2956028cc8ad4
+checksum=a21f4e448286666cf27bafef5290cc953a0a1796b752e5bbe521266dc1230c81
 
 post_patch() {
 	sed '31a#include <locale.h>' -i  guvcview/guvcview.c

From 491b4d1843a7c39ef2e32b5722010c63505ddd4a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 037/113] handbrake: update to 1.6.1

---
 .../patches/fix-missing-x265-link-flag.patch    | 11 ++++++-----
 .../handbrake/patches/libhb-vpl-include.patch   | 15 +++++++++++++++
 srcpkgs/handbrake/template                      | 17 ++++++++++-------
 3 files changed, 31 insertions(+), 12 deletions(-)
 create mode 100644 srcpkgs/handbrake/patches/libhb-vpl-include.patch

diff --git a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
index 26db03867a0c83..d6bb2eda627a36 100644
--- a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
+++ b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
@@ -1,14 +1,15 @@
 --- a/gtk/configure.ac
 +++ b/gtk/configure.ac
 @@ -203,7 +203,7 @@
- 
+
  AM_CONDITIONAL([MINGW], [test "x$mingw_flag" = "xyes"])
- 
--HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg"
-+HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -ldl"
+
+-HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc"
++HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc -ldl"
  HB_CPPFLAGS="$HB_CPPFLAGS $HBINC"
- 
+
  PKG_CHECK_MODULES([x264], [x264], sys_x264=yes, sys_x264=no)
+
 --- a/test/module.defs
 +++ b/test/module.defs
 @@ -69,6 +69,9 @@
diff --git a/srcpkgs/handbrake/patches/libhb-vpl-include.patch b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
new file mode 100644
index 00000000000000..298f9f4ab28f2a
--- /dev/null
+++ b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
@@ -0,0 +1,15 @@
+--- a/libhb/module.defs	2023-01-22 11:36:49.000000000 -0500
++++ b/libhb/module.defs	2023-04-03 22:37:52.395467010 -0400
+@@ -46,11 +46,7 @@
+ LIBHB.GCC.I += $(LIBHB.build/) $(CONTRIB.build/)include
+ 
+ ifeq (1,$(FEATURE.qsv))
+-    ifeq ($(HOST.system),freebsd))
+-        LIBHB.GCC.I += $(LOCALBASE)/include/vpl
+-    else
+-        LIBHB.GCC.I += $(CONTRIB.build/)include/vpl
+-    endif
++    LIBHB.GCC.I += /usr/include/vpl
+ endif
+ 
+ ifneq (,$(filter $(HOST.system),freebsd netbsd openbsd))
diff --git a/srcpkgs/handbrake/template b/srcpkgs/handbrake/template
index ca5e4571e49c37..c32cb1bfa31f4b 100644
--- a/srcpkgs/handbrake/template
+++ b/srcpkgs/handbrake/template
@@ -1,10 +1,10 @@
 # Template file for 'handbrake'
 pkgname=handbrake
-version=1.5.1
+version=1.6.1
 revision=1
 build_style=gnu-configure
 configure_args="--force --disable-gtk-update-checks --disable-df-fetch --harden
- $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc)"
+ $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc) $(vopt_enable qsv)"
 make_build_args="-C ${XBPS_TRIPLET}"
 make_install_args="-C ${XBPS_TRIPLET}"
 hostmakedepends="automake cmake gettext-devel glib-devel intltool libtool m4 meson nasm pkg-config python3"
@@ -12,8 +12,11 @@ makedepends="bzip2-devel ffmpeg-devel gst-plugins-base1-devel gtk+3-devel
  jansson-devel lame-devel libass-devel libbluray-devel libdav1d-devel
  libdvdnav-devel libdvdread-devel libgudev-devel libnuma-devel
  libsamplerate-devel libtheora-devel libvorbis-devel libvpx-devel libxml2-devel
- opus-devel speex-devel x264-devel x265-devel zimg-devel
+ opus-devel speex-devel x264-devel x265-devel zimg-devel libsvt-av1-devel
  $(vopt_if fdk_aac fdk-aac-devel)
+ $(vopt_if qsv libva-devel)
+ $(vopt_if qsv libdrm-devel)
+ $(vopt_if qsv onevpl-devel)
  $(vopt_if nvenc nv-codec-headers)"
 depends="desktop-file-utils gst-plugins-good1 hicolor-icon-theme"
 short_desc="Multithreaded video transcoder"
@@ -21,15 +24,15 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-2.0-only"
 homepage="https://handbrake.fr/"
 distfiles="https://github.com/HandBrake/HandBrake/releases/download/${version}/HandBrake-${version}-source.tar.bz2"
-checksum=3999fe06d5309c819799a73a968a8ec3840e7840c2b64af8f5cdb7fd8c9430f0
+checksum=94ccfe03db917a91650000c510f7fd53f844da19f19ad4b4be1b8f6bc31a8d4c
 nocross=yes
 
-build_options="fdk_aac nvenc"
+build_options="fdk_aac nvenc qsv"
 
 case "$XBPS_TARGET_MACHINE" in
 	x86_64*|i686*)
 		CFLAGS="-msse"
-		build_options_default="nvenc"
+		build_options_default="nvenc qsv"
 		;;
 esac
 
@@ -37,7 +40,7 @@ pre_configure() {
 	# use system libraries, don't download them
 	rm -rf contrib/
 	for module in fdk-aac ffmpeg libbluray libdav1d libdvdnav libdvdread nvenc \
-		x265 zimg; do
+		x265 zimg svt-av1 libvpl; do
 	    vsed -i "/MODULES += contrib\/${module}/d" make/include/main.defs
 	done
 }

From e6de69a8416e550bbcdf8e407b2e64773b0a45b6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 038/113] hedgewars: revbump for ffmpeg4

---
 srcpkgs/hedgewars/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/hedgewars/template b/srcpkgs/hedgewars/template
index 94b6db673b0c3a..402ccfaaecbc2d 100644
--- a/srcpkgs/hedgewars/template
+++ b/srcpkgs/hedgewars/template
@@ -1,13 +1,13 @@
 # Template file for 'hedgewars'
 pkgname=hedgewars
 version=1.0.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DNOSERVER=1 -DDATA_INSTALL_DIR=/usr/share/${pkgname}
  -DPHYSFS_SYSTEM=1 -DMINIMAL_FLAGS=1"
 make_cmd=make
 hostmakedepends="lua51 pkg-config qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
+makedepends="ffmpeg4-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
  SDL2_mixer-devel SDL2_net-devel SDL2_ttf-devel"
 depends="libfreeglut"
 short_desc="Funny turn-based artillery game, featuring fighting Hedgehogs!"

From 82b33e22941a344c1bc7afa162ebec4470de17bd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 039/113] idjc: revbump for ffmpeg4

---
 srcpkgs/idjc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/idjc/template b/srcpkgs/idjc/template
index a9cde0665d55b1..f41e1e4fabbae7 100644
--- a/srcpkgs/idjc/template
+++ b/srcpkgs/idjc/template
@@ -1,11 +1,11 @@
 # Template file for 'idjc'
 pkgname=idjc
 version=0.9.1
-revision=5
+revision=6
 build_style=gnu-configure
 hostmakedepends="pkg-config git python3 automake gettext-devel libtool"
 makedepends="libvorbis-devel libogg-devel jack-devel libsamplerate-devel
- libflac-devel libsndfile-devel mpg123-devel ffmpeg-devel speex-devel
+ libflac-devel libsndfile-devel mpg123-devel ffmpeg4-devel speex-devel
  glib-devel pixman-devel lame-devel python3-gobject-devel libshout-idjc-devel
  opus-devel twolame-devel python3-mutagen python3-devel"
 depends="python3-gobject python3-mutagen desktop-file-utils shared-mime-info python3-dbus jack"

From 0b6ea405dfb914c678194bfa5df377b422de121d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 040/113] kid3: revbump for ffmpeg6

---
 srcpkgs/kid3/patches/ffmpeg5.patch | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 srcpkgs/kid3/patches/ffmpeg5.patch

diff --git a/srcpkgs/kid3/patches/ffmpeg5.patch b/srcpkgs/kid3/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..135fc50e07c9ba
--- /dev/null
+++ b/srcpkgs/kid3/patches/ffmpeg5.patch
@@ -0,0 +1,17 @@
+# https://aur.archlinux.org/cgit/aur.git/diff/ffmpeg5.patch?h=kid3-cli&id=12410a74906612e7efc0ec8fbce739b4a0fef7e7
+diff --git a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+index e156d424..e12b9abd 100644
+--- a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
++++ b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+@@ -232,7 +232,11 @@ private:
+   friend class Format;
+   friend class Converter;
+   AVCodecContext* m_ptr;
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 0, 0)
+   AVCodec* m_impl;
++#else
++  const AVCodec* m_impl;
++#endif
+   AVFrame* m_frame;
+   bool m_opened;
+ };

From a12a955f0807fa521dc31142719976eeaabadbb1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 041/113] kodi: revbump for ffmpeg4

---
 srcpkgs/kodi/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/kodi/template b/srcpkgs/kodi/template
index d37a5918cd6758..ea78e0aca0fe3e 100644
--- a/srcpkgs/kodi/template
+++ b/srcpkgs/kodi/template
@@ -1,7 +1,7 @@
 # Template file for 'kodi'
 pkgname=kodi
 version=19.4
-revision=9
+revision=10
 _codename="Matrix"
 build_style=cmake
 configure_args="-DWITH_FFMPEG=/usr -DENABLE_LDGOLD=OFF
@@ -54,7 +54,7 @@ makedepends="
  libmad-devel fontconfig-devel libXinerama-devel libsamplerate-devel libmms-devel
  enca-devel boost-devel libcurl-devel libva-devel libvdpau-devel libass-devel
  libbluetooth-devel yajl-devel libplist-devel librtmp-devel tinyxml-devel
- taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg-devel
+ taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg4-devel
  giflib-devel libxslt-devel gnutls-devel libssh-devel libmicrohttpd-devel
  libcec-devel dcadec-devel flatbuffers-devel fmt-devel lcms2-devel
  libfstrcmp-devel rapidjson libcdio-paranoia spdlog libwaylandpp-devel

From ef4c69d13c4e6ed3931291dc594c2c69b5171651 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 042/113] kpipewire: revbump for ffmpeg6

---
 srcpkgs/kpipewire/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kpipewire/template b/srcpkgs/kpipewire/template
index 6214a4451336e7..3555348659dded 100644
--- a/srcpkgs/kpipewire/template
+++ b/srcpkgs/kpipewire/template
@@ -1,7 +1,7 @@
 # Template file for 'kpipewire'
 pkgname=kpipewire
 version=5.27.10
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules plasma-wayland-protocols gettext
  qt5-qmake qt5-host-tools pkg-config wayland-devel kcoreaddons

From f6b163277e7a7107abed1c4322bb1e79d26ee6ce Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 043/113] libextractor: revbump for ffmpeg4

---
 srcpkgs/libextractor/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/libextractor/template b/srcpkgs/libextractor/template
index 044c663a3a0b92..06e63bc3189d5e 100644
--- a/srcpkgs/libextractor/template
+++ b/srcpkgs/libextractor/template
@@ -1,13 +1,13 @@
 # Template file for 'libextractor'
 pkgname=libextractor
 version=1.11
-revision=4
+revision=5
 build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="pkg-config"
 makedepends="zlib-devel bzip2-devel exiv2-devel tiff-devel libpng-devel
  libjpeg-turbo-devel libvorbis-devel libflac-devel giflib-devel libmpeg2-devel
- ffmpeg-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
+ ffmpeg4-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
 short_desc="Library used to extract meta data from files"
 maintainer="Martin Riese <grauehaare@gmx.de>"
 license="GPL-3.0-or-later"

From 35df1670a46ae2f2610d5f2dc9c5322e9a21c7fe Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 044/113] libopenal: revbump for ffmpeg6

---
 srcpkgs/libopenal/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenal/template b/srcpkgs/libopenal/template
index 88d0f11307d81a..8308fca0393e33 100644
--- a/srcpkgs/libopenal/template
+++ b/srcpkgs/libopenal/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenal'
 pkgname=libopenal
 version=1.23.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DALSOFT_EXAMPLES=OFF"
 hostmakedepends="pkg-config"

From d118b374920eafeeae4e693769d16ae2d2208548 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 045/113] loudgain: revbump for ffmpeg6

---
 srcpkgs/loudgain/patches/ffmpeg5.patch | 11 +++++++++++
 srcpkgs/loudgain/template              |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/loudgain/patches/ffmpeg5.patch

diff --git a/srcpkgs/loudgain/patches/ffmpeg5.patch b/srcpkgs/loudgain/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..16d4510ee98faa
--- /dev/null
+++ b/srcpkgs/loudgain/patches/ffmpeg5.patch
@@ -0,0 +1,11 @@
+--- a/src/scan.c	2019-09-06 11:31:19.000000000 -0400
++++ b/src/scan.c	2023-03-23 11:15:40.867968521 -0400
+@@ -69,8 +69,6 @@
+ 	 * It is now useless
+ 	 * https://github.com/FFmpeg/FFmpeg/blob/70d25268c21cbee5f08304da95be1f647c630c15/doc/APIchanges#L86
+ 	 */
+-  if (avformat_version() < AV_VERSION_INT(58,9,100))
+-    av_register_all();
+ 
+ 	av_log_set_callback(scan_av_log);
+ 
diff --git a/srcpkgs/loudgain/template b/srcpkgs/loudgain/template
index da4f2d56e94c3d..4d6bf29efb4fdd 100644
--- a/srcpkgs/loudgain/template
+++ b/srcpkgs/loudgain/template
@@ -1,7 +1,7 @@
 # Template file for 'loudgain'
 pkgname=loudgain
 version=0.6.8
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libebur128-devel taglib-devel ffmpeg-devel"

From 031c46cb583cb38aa25fb56c1ded541988146e4d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 046/113] mediastreamer: revbump for ffmpeg4

---
 srcpkgs/mediastreamer/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mediastreamer/template b/srcpkgs/mediastreamer/template
index 0fcffa7653d18e..e888626b945e55 100644
--- a/srcpkgs/mediastreamer/template
+++ b/srcpkgs/mediastreamer/template
@@ -1,11 +1,11 @@
 # Template file for 'mediastreamer'
 pkgname=mediastreamer
 version=5.2.111
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DENABLE_STRICT=0 -DENABLE_UNIT_TESTS=0"
 hostmakedepends="python3"
-makedepends="bzrtp-devel ffmpeg-devel glew-devel libXv-devel libsrtp-devel
+makedepends="bzrtp-devel ffmpeg4-devel glew-devel libXv-devel libsrtp-devel
  libupnp-devel libvpx-devel mbedtls-devel opus-devel ortp-devel pulseaudio-devel
  libtheora-devel speex-devel v4l-utils-devel bcg729-devel bcmatroska2-devel libgsm-devel
  zxing-cpp-devel"

From 4ea22577f183512527c8e265b93f02d55ce36206 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 047/113] mgba: revbump for ffmpeg6

---
 srcpkgs/mgba/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mgba/template b/srcpkgs/mgba/template
index 6cd65650312543..93401adb618bd8 100644
--- a/srcpkgs/mgba/template
+++ b/srcpkgs/mgba/template
@@ -1,7 +1,7 @@
 # Template file for 'mgba'
 pkgname=mgba
 version=0.10.3
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake desktop-file-utils"
 makedepends="SDL2-devel ffmpeg-devel libedit-devel libepoxy-devel libmagick-devel

From 26e9106f794a5c72ffddaf25a65de85afd5b8703 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 048/113] mlt: revbump for ffmpeg4

---
 srcpkgs/mlt/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mlt/template b/srcpkgs/mlt/template
index 73e3915aaab9ac..d7ed4c4b30a868 100644
--- a/srcpkgs/mlt/template
+++ b/srcpkgs/mlt/template
@@ -1,14 +1,14 @@
 # Template file for 'mlt'
 pkgname=mlt
 version=6.26.1
-revision=3
+revision=4
 build_style=configure
 configure_args="--prefix=/usr --libdir=/usr/lib$XBPS_TARGET_WORDSIZE
  --enable-gpl --enable-gpl3 --disable-swfdec --without-kde
  --swig-languages=python"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which"
 # XXX: movit vid.stab
-makedepends="alsa-lib-devel ffmpeg-devel gtk+-devel jack-devel ladspa-sdk
+makedepends="alsa-lib-devel ffmpeg4-devel gtk+-devel jack-devel ladspa-sdk
  libexif-devel libsamplerate-devel libxml2-devel sox-devel SDL_image-devel
  fftw-devel frei0r-plugins python3-devel pulseaudio-devel movit-devel
  libvidstab-devel"

From 1c09533d8cd5c77d59194266450f0c7871f30758 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 049/113] moc: revbump for ffmpeg4

---
 srcpkgs/moc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/moc/template b/srcpkgs/moc/template
index 3a04932c8f1e61..838755f88db09e 100644
--- a/srcpkgs/moc/template
+++ b/srcpkgs/moc/template
@@ -1,10 +1,10 @@
 # Template file for 'moc'
 pkgname=moc
 version=2.5.2
-revision=7
+revision=8
 build_style=gnu-configure
 hostmakedepends="pkg-config"
-makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg-devel
+makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg4-devel
  jack-devel alsa-lib-devel libltdl-devel libflac-devel libvorbis-devel
  libmad-devel libmpcdec-devel libmodplug-devel libid3tag-devel faad2-devel
  taglib-devel libsndfile-devel wavpack-devel speex-devel libsamplerate-devel

From bb720a5926b6af747e87f82072fbda1e6008cd57 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 050/113] motion: revbump for ffmpeg6

---
 srcpkgs/motion/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/motion/template b/srcpkgs/motion/template
index 607ebeb3c7b242..bf63a91d9764f6 100644
--- a/srcpkgs/motion/template
+++ b/srcpkgs/motion/template
@@ -1,7 +1,7 @@
 # Template file for 'motion'
 pkgname=motion
 version=4.6.0
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake pkg-config gettext-devel tar"
 makedepends="ffmpeg-devel libmicrohttpd-devel v4l-utils-devel gettext-devel"

From 41c452142596ff7b2a2c19e2675878014dd63218 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 051/113] olive: revbump for ffmpeg4

---
 srcpkgs/olive/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/olive/template b/srcpkgs/olive/template
index 12a46936c99003..5c2917b9c51245 100644
--- a/srcpkgs/olive/template
+++ b/srcpkgs/olive/template
@@ -1,10 +1,10 @@
 # Template file for 'olive'
 pkgname=olive
 version=0.1.2
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools pkg-config"
-makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg-devel frei0r-plugins"
+makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg4-devel frei0r-plugins"
 short_desc="Non-linear video editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"

From 0317739ace377c57e55b3f847cc5dae8e4029765 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 052/113] opentoonz: revbump for ffmpeg6

---
 srcpkgs/opentoonz/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/opentoonz/template b/srcpkgs/opentoonz/template
index ee9f7603f55fd8..3e81834ca0eddf 100644
--- a/srcpkgs/opentoonz/template
+++ b/srcpkgs/opentoonz/template
@@ -1,7 +1,7 @@
 # Template file for 'opentoonz'
 pkgname=opentoonz
 version=1.6.0
-revision=2
+revision=3
 build_wrksrc="toonz/sources"
 build_style=cmake
 make_cmd=make

From 4e79dbee7124f0715a15a2bf147dd563ce371cc8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 053/113] pianobar: revbump for ffmpeg6

---
 srcpkgs/pianobar/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pianobar/template b/srcpkgs/pianobar/template
index e3febb821a4510..1e3dc1bf9308ee 100644
--- a/srcpkgs/pianobar/template
+++ b/srcpkgs/pianobar/template
@@ -1,7 +1,7 @@
 # Template file for 'pianobar'
 pkgname=pianobar
 version=2022.04.01
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="V=1"
 hostmakedepends="pkg-config"

From e1451e16aa0b1720bab08c9e1f79ca611b1c4ef0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 054/113] ppsspp: revbump for ffmpeg4

---
 srcpkgs/ppsspp/template | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/srcpkgs/ppsspp/template b/srcpkgs/ppsspp/template
index 2c0ded496eb981..8bf55f65198cdc 100644
--- a/srcpkgs/ppsspp/template
+++ b/srcpkgs/ppsspp/template
@@ -1,7 +1,7 @@
 # Template file for 'ppsspp'
 pkgname=ppsspp
 version=1.16.6
-revision=1
+revision=2
 _glslang_commit=b34f619e1c85810dcb3c578107d2e48ba4ee2b37
 _SPIRV_Cross_commit=4212eef67ed0ca048cb726a6767185504e7695e5
 _armips_commit=7bd1ec93d4586985ba1ef420b43b5e620f68695e
@@ -15,7 +15,7 @@ configure_args="-DHEADLESS=1 -DUSE_SYSTEM_FFMPEG=1 -DUNITTEST=ON
  -DUSING_QT_UI=$(vopt_if qt ON OFF) -DUSE_SYSTEM_ZSTD=ON
  -DARMIPS_USE_STD_FILESYSTEM=ON"
 hostmakedepends="pkg-config python3 $(vopt_if qt qt5-host-tools)"
-makedepends="zlib-devel glew-devel ffmpeg-devel libzip-devel
+makedepends="zlib-devel glew-devel ffmpeg4-devel libzip-devel
  snappy-devel rapidjson libpng-devel libzstd-devel
  $(vopt_if sdl2 'SDL2_ttf-devel SDL2-devel') $(vopt_if wayland wayland-devel)
  $(vopt_if qt 'qt5-devel qt5-multimedia-devel')"
@@ -69,10 +69,10 @@ post_extract() {
 	rmdir -v ${wrksrc}/ext/cpu_features
 	mv ${wrksrc}/cpu_features-${_cpu_features_commit} ${wrksrc}/ext/cpu_features
 	rmdir -v ${wrksrc}/ext/rcheevos
-        mv ${wrksrc}/rcheevos-${_rcheevos_commit} ${wrksrc}/ext/rcheevos
+	mv ${wrksrc}/rcheevos-${_rcheevos_commit} ${wrksrc}/ext/rcheevos
 }
 
-post_patch(){
+post_patch() {
 	# disable git versioning
 	vsed -e 's|find_package(Git)|# &|' -i git-version.cmake
 }
@@ -85,7 +85,6 @@ post_configure() {
 }
 
 do_install() {
-	vlicense LICENSE.TXT
 	vinstall icons/icon.svg 644 usr/share/pixmaps ppsspp.svg
 	vinstall Qt/PPSSPP.desktop 644 usr/share/applications
 	vbin build/PPSSPPHeadless ppsspp-headless

From a4af21853f0945c8707f5cf910b20d9b4cffd8f7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 055/113] pqiv: revbump for ffmpeg6

---
 srcpkgs/pqiv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pqiv/template b/srcpkgs/pqiv/template
index 542fc27a2d32a4..9308d949b6a1c7 100644
--- a/srcpkgs/pqiv/template
+++ b/srcpkgs/pqiv/template
@@ -1,7 +1,7 @@
 # Template file for 'pqiv'
 pkgname=pqiv
 version=2.12
-revision=1
+revision=2
 build_style=gnu-makefile
 hostmakedepends="pkg-config"
 makedepends="glib-devel gtk+3-devel $(vopt_if ffmpeg ffmpeg-devel)

From fcc2373ffbe81267825ad4c3f46789d7d9234068 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 056/113] qmmp: revbump for ffmpeg6

---
 srcpkgs/qmmp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qmmp/template b/srcpkgs/qmmp/template
index 53781ea3bc28ad..2da07f1e87eac0 100644
--- a/srcpkgs/qmmp/template
+++ b/srcpkgs/qmmp/template
@@ -1,7 +1,7 @@
 # Template file for 'qmmp'
 pkgname=qmmp
 version=1.6.1
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DUSE_HAL:BOOL=FALSE -DQMMP_DEFAULT_UI:STRING=simple"
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From 3f45d82c6cbec35f943bc3e8abe7c7aacb1d768c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 14 Dec 2023 13:28:10 -0500
Subject: [PATCH 057/113] qt6-pdf: revbump for ffmpeg6

---
 srcpkgs/qt6-pdf/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-pdf/template b/srcpkgs/qt6-pdf/template
index ecda84afac1310..531b4e1d4fe84d 100644
--- a/srcpkgs/qt6-pdf/template
+++ b/srcpkgs/qt6-pdf/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-pdf'
 pkgname=qt6-pdf
 version=6.6.0
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DQT_FEATURE_qtpdf_build=ON
  -DQT_FEATURE_qtpdf_widgets_build=ON

From a300bb4d5f6bf435b2db5da6277a5c3a10885a10 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 058/113] qt5-webengine: revbump for ffmpeg6

---
 .../chromium-media-filters-cpp14.patch        |  11 ++
 srcpkgs/qt5-webengine/patches/ffmpeg5.patch   | 179 ++++++++++++++++++
 .../qtwebengine-fix-ffmpeg5-build.patch       |  14 ++
 srcpkgs/qt5-webengine/template                |   4 +-
 4 files changed, 206 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/ffmpeg5.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch

diff --git a/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
new file mode 100644
index 00000000000000..04adc540f2cbc0
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
@@ -0,0 +1,11 @@
+--- a/src/3rdparty/chromium/media/filters/BUILD.gn	2023-02-27 13:32:59.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/BUILD.gn	2023-04-02 17:21:39.204066384 -0400
+@@ -96,6 +96,8 @@
+     "//ui/gfx/geometry:geometry",
+   ]
+ 
++  cflags_cc = [ "-std=c++14" ]
++
+   libs = []
+ 
+   if (proprietary_codecs) {
diff --git a/srcpkgs/qt5-webengine/patches/ffmpeg5.patch b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..ac55e1634423a9
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
@@ -0,0 +1,179 @@
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:57.732547446 -0400
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:09.486478995 -0400
+@@ -57,6 +57,8 @@
+ 
+ namespace {
+ 
++constexpr int64_t kRelativeTsBase = static_cast<int64_t>(0x7ffeffffffffffff);
++
+ void SetAVStreamDiscard(AVStream* stream, AVDiscard discard) {
+   DCHECK(stream);
+   stream->discard = discard;
+@@ -90,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+   if (stream->start_time != kNoFFmpegTimestamp)
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (stream->first_dts != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, stream->first_dts);
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -408,11 +398,11 @@
+   scoped_refptr<DecoderBuffer> buffer;
+ 
+   if (type() == DemuxerStream::TEXT) {
+-    int id_size = 0;
++    size_t id_size = 0;
+     uint8_t* id_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
+ 
+-    int settings_size = 0;
++    size_t settings_size = 0;
+     uint8_t* settings_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
+ 
+@@ -424,7 +414,7 @@
+     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
+                                      side_data.data(), side_data.size());
+   } else {
+-    int side_data_size = 0;
++    size_t side_data_size = 0;
+     uint8_t* side_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
+ 
+@@ -485,7 +475,7 @@
+                                        packet->size - data_offset);
+     }
+ 
+-    int skip_samples_size = 0;
++    size_t skip_samples_size = 0;
+     const uint32_t* skip_samples_ptr =
+         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
+             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
+@@ -1587,6 +1577,8 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++      continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+       lowest_start_time_stream = stream.get();
+@@ -1604,6 +1596,8 @@
+     if (stream && stream->type() == DemuxerStream::VIDEO &&
+         stream->IsEnabled()) {
+       video_stream = stream.get();
++      if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++        continue;
+       if (video_stream->start_time() <= seek_time) {
+         return video_stream;
+       }
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h qtwebengine-5.15.10/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h
+--- a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-07-11 22:12:47.917192788 -0500
+@@ -29,6 +29,7 @@ extern "C" {
+ #include <libavformat/avformat.h>
+ #include <libavformat/avio.h>
+ #include <libavutil/avutil.h>
++#include <libavutil/channel_layout.h>
+ #include <libavutil/imgutils.h>
+ #include <libavutil/log.h>
+ #include <libavutil/mastering_display_metadata.h>
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/audio_file_reader.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/audio_file_reader.cc
+--- a/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -85,7 +85,7 @@ bool AudioFileReader::OpenDemuxer() {
+ }
+ 
+ bool AudioFileReader::OpenDecoder() {
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (codec) {
+     // MP3 decodes to S16P which we don't support, tell it to use S16 instead.
+     if (codec_context_->sample_fmt == AV_SAMPLE_FMT_S16P)
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -329,7 +329,7 @@ bool FFmpegAudioDecoder::ConfigureDecode
+     }
+   }
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec ||
+       avcodec_open2(codec_context_.get(), codec, &codec_options) < 0) {
+     DLOG(ERROR) << "Could not initialize audio decoder: "
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -59,7 +59,6 @@ static int64_t AVIOSeekOperation(void* o
+ }
+ 
+ void FFmpegGlue::InitializeFFmpeg() {
+-  av_register_all();
+ }
+ 
+ static void LogContainer(bool is_local_file,
+@@ -95,9 +94,6 @@ FFmpegGlue::FFmpegGlue(FFmpegURLProtocol
+   // Enable fast, but inaccurate seeks for MP3.
+   format_context_->flags |= AVFMT_FLAG_FAST_SEEK;
+ 
+-  // Ensures we can read out various metadata bits like vp8 alpha.
+-  format_context_->flags |= AVFMT_FLAG_KEEP_SIDE_DATA;
+-
+   // Ensures format parsing errors will bail out. From an audit on 11/2017, all
+   // instances were real failures. Solves bugs like http://crbug.com/710791.
+   format_context_->error_recognition |= AV_EF_EXPLODE;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -391,7 +391,7 @@ bool FFmpegVideoDecoder::ConfigureDecode
+   if (decode_nalus_)
+     codec_context_->flags2 |= AV_CODEC_FLAG2_CHUNKS;
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
+     ReleaseFFmpegResources();
+     return false;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/media_file_checker.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/media_file_checker.cc
+--- a/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -68,7 +68,7 @@ bool MediaFileChecker::Start(base::TimeD
+       auto context = AVStreamToAVCodecContext(format_context->streams[i]);
+       if (!context)
+         continue;
+-      AVCodec* codec = avcodec_find_decoder(cp->codec_id);
++      const AVCodec* codec = avcodec_find_decoder(cp->codec_id);
+       if (codec && avcodec_open2(context.get(), codec, nullptr) >= 0) {
+         auto loop = std::make_unique<FFmpegDecodingLoop>(context.get());
+         stream_contexts[i] = {std::move(context), std::move(loop)};
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc qtwebengine-5.15.10/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc
+--- a/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -203,7 +203,7 @@ int32_t H264DecoderImpl::InitDecode(cons
+   // a pointer |this|.
+   av_context_->opaque = this;
+ 
+-  AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
+   if (!codec) {
+     // This is an indication that FFmpeg has not been initialized or it has not
+     // been compiled/initialized with the correct set of codecs.
diff --git a/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch b/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch
new file mode 100644
index 00000000000000..bc24d5b9a29cb5
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch
@@ -0,0 +1,14 @@
+--- a/src/buildtools/configure.json	2023-12-09 11:06:01.503058569 -0500
++++ b/src/buildtools/configure.json	2023-12-09 11:06:14.982361345 -0500
+@@ -779,11 +779,6 @@
+             "type": "warning",
+             "condition": "config.ios && config.simulator && config.device && features.build-qtpdf",
+             "message": "Building fat libray with device and simulator architectures will disable NEON."
+-        },
+-        {
+-            "type": "fatal",
+-            "condition": "features.webengine-system-ffmpeg && !libs.webengine-ffmpeg-support",
+-            "message": "Unmodified ffmpeg >= 5.0 is not supported. Please configure with -qt-webengine-ffmpeg."
+         }
+     ],
+     "summary": [
diff --git a/srcpkgs/qt5-webengine/template b/srcpkgs/qt5-webengine/template
index 8d2df1b5175bad..1687a77eb8a2f5 100644
--- a/srcpkgs/qt5-webengine/template
+++ b/srcpkgs/qt5-webengine/template
@@ -1,14 +1,14 @@
 # Template file for 'qt5-webengine'
 pkgname=qt5-webengine
 version=5.15.16
-revision=1
+revision=2
 _version="${version}-lts"
 _chromium_commit=207c2ac45ca3386d153770c6b0d2ea2ec21ca880
 archs="x86_64* i686* armv[67]* ppc64* aarch64*"
 create_wrksrc=yes
 build_style=qmake
 configure_args="--
- -webengine-icu -webengine-ffmpeg -webengine-opus -webengine-webp
+ -webengine-icu -system-ffmpeg -webengine-opus -webengine-webp
  -webengine-pepper-plugins -webengine-printing-and-pdf -webengine-proprietary-codecs
  -webengine-pulseaudio -webengine-spellchecker -webengine-webrtc -webengine-geolocation
  -webengine-kerberos -no-webengine-embedded-build $(vopt_if sndio '' '-no')-webengine-sndio

From 024a7036f04abbd70a3d52d93425293522c33602 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 059/113] qt5: revbump for ffmpeg6

---
 srcpkgs/qt5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5/template b/srcpkgs/qt5/template
index 3efb7e42d5fd3f..27f6d5388cd15c 100644
--- a/srcpkgs/qt5/template
+++ b/srcpkgs/qt5/template
@@ -3,9 +3,9 @@
 # revbump libqtxdg after bumping patch version
 pkgname=qt5
 version=5.15.11+20231124
+revision=3
 # commit 4765fa1df7a837db9c1f89c4da0dd76b74bb5fab
 # base repo: https://invent.kde.org/qt/qt/qt5
-revision=2
 build_style=meta
 hostmakedepends="cmake clang17 flex perl glib-devel pkg-config
  python3 re2c ruby which"

From c4683f3e39515eb370c7fc88203e83ef675a49fb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 060/113] qtav: revbump for ffmpeg4

---
 srcpkgs/qtav/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtav/template b/srcpkgs/qtav/template
index 775d5a139a9efa..aa69e213c984b0 100644
--- a/srcpkgs/qtav/template
+++ b/srcpkgs/qtav/template
@@ -1,10 +1,10 @@
 # Template file for 'qtav'
 pkgname=qtav
 version=1.13.0
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel libass-devel libopenal-devel
+makedepends="ffmpeg4-devel libass-devel libopenal-devel
  libva-glx-devel libXv-devel pulseaudio-devel
  qt5-declarative-devel qt5-svg-devel
  qt5-quickcontrols"

From b623c073366c4d4df3ad692a28ea4a05c8807ac1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 061/113] retroarch: revbump for ffmpeg6

---
 srcpkgs/retroarch/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroarch/template b/srcpkgs/retroarch/template
index cb3125c5dbf1ae..c65c26f7bf0332 100644
--- a/srcpkgs/retroarch/template
+++ b/srcpkgs/retroarch/template
@@ -1,7 +1,7 @@
 # Template file for 'retroarch'
 pkgname=retroarch
 version=1.16.0.3
-revision=3
+revision=4
 build_style=configure
 configure_args="--prefix=/usr --sysconfdir=/etc --enable-networking
  --enable-udev --disable-builtinflac --disable-builtinglslang

From b704406b5a6ae6039d0dbdd0866dc52f98b2ccec Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 062/113] scrcpy: revbump for ffmpeg6

---
 srcpkgs/scrcpy/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/scrcpy/template b/srcpkgs/scrcpy/template
index ac18bc03418ce7..f39a7f678ab359 100644
--- a/srcpkgs/scrcpy/template
+++ b/srcpkgs/scrcpy/template
@@ -1,7 +1,7 @@
 # Template file for 'scrcpy'
 pkgname=scrcpy
 version=2.1.1
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcompile_server=false
  -Dprebuilt_server=/usr/share/scrcpy/scrcpy-server-v${version}"

From da3364a972b7c39eee08fdfdb7cc0fa8dc89741b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 17 Oct 2023 08:54:11 -0400
Subject: [PATCH 063/113] New package: spex-x replaces spek-alternative for
 ffmpeg6

---
 srcpkgs/spek-alternative                      |  1 +
 srcpkgs/{spek-alternative => spek-x}/template | 22 ++++++++++++-------
 2 files changed, 15 insertions(+), 8 deletions(-)
 create mode 120000 srcpkgs/spek-alternative
 rename srcpkgs/{spek-alternative => spek-x}/template (52%)

diff --git a/srcpkgs/spek-alternative b/srcpkgs/spek-alternative
new file mode 120000
index 00000000000000..76648236da7017
--- /dev/null
+++ b/srcpkgs/spek-alternative
@@ -0,0 +1 @@
+spek-x
\ No newline at end of file
diff --git a/srcpkgs/spek-alternative/template b/srcpkgs/spek-x/template
similarity index 52%
rename from srcpkgs/spek-alternative/template
rename to srcpkgs/spek-x/template
index d7b55c776b1d43..3ded6c2c323e4f 100644
--- a/srcpkgs/spek-alternative/template
+++ b/srcpkgs/spek-x/template
@@ -1,18 +1,18 @@
-# Template file for 'spek-alternative'
-pkgname=spek-alternative
-version=0.8.2.3
-revision=2
+# Template file for 'spek-x'
+pkgname=spek-x
+version=0.9.3
+revision=1
 build_style=gnu-configure
 hostmakedepends="automake gettext-devel intltool libtool pkg-config
  wxWidgets-common wxWidgets-gtk3-devel"
 makedepends="ffmpeg-devel wxWidgets-gtk3-devel"
 depends="ffmpeg"
 short_desc="Acoustic spectrum analyser"
-maintainer="Kartik Singh <kartik.ynwa@gmail.com>"
+maintainer="zlice <zlice555@gmail.com>"
 license="GPL-3.0-or-later"
-homepage="https://github.com/withmorten/spek-alternative"
-distfiles="https://github.com/withmorten/spek-alternative/archive/${version}.tar.gz"
-checksum="007ba4b84a310b078e378aa84c8e80783db5821437a757a488c3ecec377e6b2a"
+homepage="https://github.com/MikeWang000000/spek-x"
+distfiles="https://github.com/MikeWang000000/spek-x/archive/v${version}.tar.gz"
+checksum="7f4b109903333cdd310ab2b9176f0dc49a565891376e281a233d342cedf90ef7"
 
 CXXFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
 
@@ -22,3 +22,9 @@ export WX_CONFIG_NAME="wx-config-gtk3"
 pre_configure() {
 	NOCONFIGURE=1 ./autogen.sh
 }
+
+spek-alternative_package() {
+	depends="spek-x"
+	short_desc+=" - transitional dummy package"
+	build_style=meta
+}

From dbf27b89b48013c9df386fae9a66483defffc4e4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 064/113] ssr: revbump for ffmpeg4

---
 srcpkgs/ssr/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/ssr/template b/srcpkgs/ssr/template
index 3097754e3cbe54..6609c16c4ed8e8 100644
--- a/srcpkgs/ssr/template
+++ b/srcpkgs/ssr/template
@@ -1,11 +1,11 @@
 # Template file for 'ssr'
 pkgname=ssr
 version=0.4.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DWITH_QT5=ON"
 hostmakedepends="pkg-config"
-makedepends="alsa-lib-devel ffmpeg-devel glu-devel jack-devel pulseaudio-devel
+makedepends="alsa-lib-devel ffmpeg4-devel glu-devel jack-devel pulseaudio-devel
  qt5-tools-devel qt5-x11extras-devel libXinerama-devel v4l-utils-devel"
 depends="desktop-file-utils hicolor-icon-theme"
 short_desc="Simple Screen Recorder for programs and games"

From b3b14d908397c7a5b3a836e94ccc5f0ce3720101 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 065/113] synfig: revbump for ffmpeg6 and mlt7

---
 srcpkgs/synfig/patches/ffmpeg6.patch | 71 ++++++++++++++++++++++++++++
 srcpkgs/synfig/template              |  6 +--
 2 files changed, 74 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/synfig/patches/ffmpeg6.patch

diff --git a/srcpkgs/synfig/patches/ffmpeg6.patch b/srcpkgs/synfig/patches/ffmpeg6.patch
new file mode 100644
index 00000000000000..10780b42782f4b
--- /dev/null
+++ b/srcpkgs/synfig/patches/ffmpeg6.patch
@@ -0,0 +1,71 @@
+--- a/src/modules/mod_libavcodec/trgt_av.cpp	2022-10-25 09:14:12.000000000 -0400
++++ b/src/modules/mod_libavcodec/trgt_av.cpp	2023-05-05 21:34:17.899194559 -0400
+@@ -38,6 +41,7 @@
+ extern "C"
+ {
+ #ifdef HAVE_LIBAVFORMAT_AVFORMAT_H
++#	include <libavcodec/avcodec.h>
+ #	include <libavformat/avformat.h>
+ #elif defined(HAVE_AVFORMAT_H)
+ #	include <avformat.h>
+@@ -155,11 +156,11 @@
+     }
+ 
+ 	bool open_video_stream() {
+-		if (avcodec_open2(video_context, NULL, NULL) < 0) {
++		if (avcodec_open2(video_context, nullptr, nullptr) < 0) {
+ 			synfig::error("Target_LibAVCodec: could not open video codec");
+ 			// seems the calling of avcodec_free_context after error will cause crash
+ 			// so just forget about this context
+-			video_context = NULL;
++			video_context = nullptr;
+ 			close();
+ 			return false;
+         }
+@@ -234,15 +235,21 @@
+ 		close();
+ 
+ 		if (!av_registered) {
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 			av_register_all();
++#endif
+ 			av_registered = true;
+ 		}
+ 
+ 		// guess format
+-		AVOutputFormat *format = av_guess_format(NULL, filename.c_str(), NULL);
++#if LIBAVCODEC_VERSION_MAJOR < 59 // FFMPEG < 5.0
++		AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#else
++		const AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#endif
+ 		if (!format) {
+ 			synfig::warning("Target_LibAVCodec: unable to guess the output format, defaulting to MPEG");
+-			format = av_guess_format("mpeg", NULL, NULL);
++			format = av_guess_format("mpeg", nullptr, nullptr);
+ 		}
+ 		if (!format) {
+ 			synfig::error("Target_LibAVCodec: unable to find 'mpeg' output format");
+@@ -254,6 +261,7 @@
+ 		context = avformat_alloc_context();
+ 		assert(context);
+ 		context->oformat = format;
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 		if (filename.size() + 1 > sizeof(context->filename)) {
+ 			synfig::error(
+ 				"Target_LibAVCodec: filename too long, max length is %d, filename is '%s'",
+@@ -263,6 +271,14 @@
+ 			return false;
+ 		}
+ 		memcpy(context->filename, filename.c_str(), filename.size() + 1);
++#else
++		context->url = av_strndup(filename.c_str(), filename.size());
++		if (!context->url) {
++			synfig::error("Target_LibAVCodec: cannot allocate space for filename");
++			close();
++			return false;
++		}
++#endif
+ 
+ 		packet = av_packet_alloc();
+ 		assert(packet);
diff --git a/srcpkgs/synfig/template b/srcpkgs/synfig/template
index d4d3e341a20bf8..828b5cb32956ee 100644
--- a/srcpkgs/synfig/template
+++ b/srcpkgs/synfig/template
@@ -2,11 +2,11 @@
 # Should be kept in sync with 'synfigstudio' and 'ETL'
 pkgname=synfig
 version=1.4.4
-revision=4
+revision=5
 build_style=gnu-configure
 configure_args="--with-boost-libdir=${XBPS_CROSS_BASE}/usr/lib"
 hostmakedepends="boost-build ImageMagick pkg-config intltool"
-makedepends="ETL gettext-devel libxml++-devel mlt-devel libmagick-devel
+makedepends="ETL gettext-devel libxml++-devel mlt7-devel libmagick-devel
  libmng-devel boost-build boost-devel libopenexr-devel ffmpeg-devel"
 depends="ImageMagick"
 short_desc="CLI 2D vector and timeline-based animation software"
@@ -20,7 +20,7 @@ CXXFLAGS="-std=c++11 -DHAVE_LOCALE_H=1"
 
 synfig-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision}
-	 libopenexr-devel libxml++-devel mlt-devel"
+	 libopenexr-devel libxml++-devel mlt7-devel"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/bin/synfig-config

From 8bd182612df10d8de40adc61b4fc92440e137b5a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 066/113] timg: revbump for ffmpeg6

---
 srcpkgs/timg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/timg/template b/srcpkgs/timg/template
index 2a2ab763d2fddf..8fb4327535ef93 100644
--- a/srcpkgs/timg/template
+++ b/srcpkgs/timg/template
@@ -1,7 +1,7 @@
 # Template file for 'timg'
 pkgname=timg
 version=1.4.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_OPENSLIDE_SUPPORT=off -Wno-dev"
 hostmakedepends="pkg-config git"

From 1f366572075cd1af7b8f69a5df5e33ce4eecdaf8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 067/113] tvheadend: revbump for ffmpeg4

---
 srcpkgs/tvheadend/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tvheadend/template b/srcpkgs/tvheadend/template
index 9aea7de4ec7057..012d31c4879ff1 100644
--- a/srcpkgs/tvheadend/template
+++ b/srcpkgs/tvheadend/template
@@ -8,7 +8,7 @@ configure_args="--enable-dvbscan --disable-ffmpeg_static
 --disable-libx265_static --disable-libvpx_static --disable-libtheora_static
 --disable-libvorbis_static --disable-libfdkaac_static"
 hostmakedepends="gettext pkg-config python3 git which"
-makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg-devel"
+makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg4-devel"
 short_desc="TV streaming server"
 maintainer="lemmi <lemmi@nerd2nerd.org>"
 license="GPL-3.0-only"

From 3d2e60f2ab2e9cd19dc2a27c86e17dae38f5290b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 068/113] unpaper: update to 7.0.0.

---
 srcpkgs/unpaper/template | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/srcpkgs/unpaper/template b/srcpkgs/unpaper/template
index 38ed47a5840165..1ff910e722afc8 100644
--- a/srcpkgs/unpaper/template
+++ b/srcpkgs/unpaper/template
@@ -1,13 +1,13 @@
 # Template file for 'unpaper'
 pkgname=unpaper
-version=6.1
-revision=3
-build_style=gnu-configure
+version=7.0.0
+revision=1
+build_style=meson
+hostmakedepends="pkg-config meson libxslt"
+makedepends="ffmpeg-devel python3-Sphinx"
+short_desc="Post-processing tool for scanned sheets of paper"
 maintainer="Orphaned <orphan@voidlinux.org>"
-hostmakedepends="pkg-config libxslt"
-makedepends="ffmpeg-devel"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://www.flameeyes.eu/projects/unpaper"
-short_desc="A post-processing tool for scanned sheets of paper"
 distfiles="https://www.flameeyes.eu/files/${pkgname}-${version}.tar.xz"
-checksum=237c84f5da544b3f7709827f9f12c37c346cdf029b1128fb4633f9bafa5cb930
+checksum=2575fbbf26c22719d1cb882b59602c9900c7f747118ac130883f63419be46a80

From 5c7ebdb75aaeff683156f008c5aa9b2aeb55e722 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 069/113] vice: revbump for ffmpeg4

---
 srcpkgs/vice/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/vice/template b/srcpkgs/vice/template
index b1f866d35095e7..43f79243a1da11 100644
--- a/srcpkgs/vice/template
+++ b/srcpkgs/vice/template
@@ -1,7 +1,7 @@
 # Template file for 'vice'
 pkgname=vice
 version=3.7.1
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="
 	$(vopt_enable sdl2 sdlui2)
@@ -26,7 +26,7 @@ makedepends="
 	$(vopt_if gtk3 gtk+3-devel)
 	$(vopt_if gtk3 pulseaudio-devel)
 	$(vopt_if gtk3 pango-devel)
-	$(vopt_if ffmpeg ffmpeg-devel)"
+	$(vopt_if ffmpeg ffmpeg4-devel)"
 short_desc="Emulator for C64, C128, CBM-II, PET, VIC20, Plus4 and C16"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"

From 58d31dda4ef9a0bebea16210a65f8ea8eafe650f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 070/113] waypipe: revbump for ffmpeg6

---
 srcpkgs/waypipe/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waypipe/template b/srcpkgs/waypipe/template
index 6da88b21bf2a19..4da8058400b588 100644
--- a/srcpkgs/waypipe/template
+++ b/srcpkgs/waypipe/template
@@ -1,7 +1,7 @@
 # Template file for 'waypipe'
 pkgname=waypipe
 version=0.8.6
-revision=1
+revision=2
 build_style=meson
 # lto is off because it causes linking errors in armv6l and armv7l (due to NEON)
 configure_args="-Dwerror=false -Dwith_dmabuf=enabled -Dwith_lz4=enabled

From 9e823c33934f122307bcbdaa881f17dddc4bf96a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 071/113] xpra: revbump for ffmpeg6

---
 srcpkgs/xpra/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xpra/template b/srcpkgs/xpra/template
index f4a44ea814867a..c0f66c9483d494 100644
--- a/srcpkgs/xpra/template
+++ b/srcpkgs/xpra/template
@@ -1,7 +1,7 @@
 # Template file for 'xpra'
 pkgname=xpra
 version=5.0.5
-revision=1
+revision=2
 build_style=python3-module
 make_build_args="--without-cuda_kernels --without-cuda_rebuild"
 make_install_args="$(vopt_with docs) ${make_build_args}"

From 35f7c26d8308e7bff4d13c949bef4283d30f2e3e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:07:40 -0400
Subject: [PATCH 072/113] nv-codec-headers: update to 12.0.16.0

---
 srcpkgs/nv-codec-headers/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/nv-codec-headers/template b/srcpkgs/nv-codec-headers/template
index 3d422a61e48917..251e057f826fb8 100644
--- a/srcpkgs/nv-codec-headers/template
+++ b/srcpkgs/nv-codec-headers/template
@@ -1,6 +1,6 @@
 # Template file for 'nv-codec-headers'
 pkgname=nv-codec-headers
-version=11.1.5.1
+version=12.0.16.0
 revision=1
 build_style=gnu-makefile
 short_desc="FFmpeg version of headers required to interface with Nvidias codec APIs"
@@ -8,7 +8,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="MIT"
 homepage="http://git.videolan.org/?p=ffmpeg/nv-codec-headers.git"
 distfiles="https://github.com/FFmpeg/nv-codec-headers/archive/n${version}.tar.gz"
-checksum=d095fbd56aa93772471a323be0ebe65504a0f43f06c76a30b6d25da77b06ae9c
+checksum=2a1533b65f55f9da52956faf0627ed3b74868ac0c7f269990edd21369113b48f
 
 post_install() {
 	sed -n '4,25p' include/ffnvcodec/nvEncodeAPI.h > LICENSE

From 535d0f42ed39bec233b5c78dd471ef2206a6257f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:08:40 -0400
Subject: [PATCH 073/113] openimagedenoise: revbump for ffmpeg6

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index b792813dba7c29..109deb171c3f75 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,7 +1,7 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
 version=1.4.3
-revision=1
+revision=2
 archs="x86_64*"
 build_style=cmake
 hostmakedepends="ispc python3"

From fc13af57c71bbef484dfb2cbea72be7c45ea5307 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:31:45 -0400
Subject: [PATCH 074/113] shotcut: revbump for ffmpeg6

---
 srcpkgs/shotcut/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/shotcut/template b/srcpkgs/shotcut/template
index 33141fbd862d7a..f46cb53b6bfb92 100644
--- a/srcpkgs/shotcut/template
+++ b/srcpkgs/shotcut/template
@@ -1,7 +1,7 @@
 # Template file for 'shotcut'
 pkgname=shotcut
 version=23.09.29
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSHOTCUT_VERSION=${version}"
 hostmakedepends="pkg-config qt6-tools-devel"

From b3a95c17b8836cc80efd5e4b4b98a600737b12f9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:30 -0400
Subject: [PATCH 075/113] shiboken2: revbump for qt5-5.15.11

---
 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch | 1 +
 1 file changed, 1 insertion(+)
 create mode 120000 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
new file mode 120000
index 00000000000000..efcf3249bd8854
--- /dev/null
+++ b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1 @@
+../../python3-pyside2/patches/importlib-machinery-bypass.patch
\ No newline at end of file

From fbdf919059d9c6cd99bbcd56cb3bea86b6da665d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:53 -0400
Subject: [PATCH 076/113] python3-pyside2: revbump for qt5-5.15.11

---
 .../patches/importlib-machinery-bypass.patch      | 15 +++++++++++++++
 srcpkgs/python3-pyside2/template                  |  2 +-
 2 files changed, 16 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
new file mode 100644
index 00000000000000..64c429584776b5
--- /dev/null
+++ b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1,15 @@
+Using this prevents an error around line 220 below it.
+"AttributeError: module 'importlib' has no attribute 'machinery'"
+The old backup logic is in place and compiles without issues.
+--- a/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:09:34.688912402 -0400
++++ b/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:10:03.395529582 -0400
+@@ -170,9 +170,6 @@
+
+     # 'zipstring_sequence' comes from signature.cpp
+     zipbytes = base64.b64decode(''.join(zipstring_sequence))
+-    if sys.version_info[0] >= 3:
+-        vzip = zipfile.ZipFile(io.BytesIO(zipbytes))
+-        return sys.meta_path, EmbeddableZipImporter(vzip)
+
+     # Old version for Python 2.7, only.
+     import os
diff --git a/srcpkgs/python3-pyside2/template b/srcpkgs/python3-pyside2/template
index 249efa90988425..52626436ce75f2 100644
--- a/srcpkgs/python3-pyside2/template
+++ b/srcpkgs/python3-pyside2/template
@@ -1,7 +1,7 @@
 # Template file for 'python3-pyside2'
 pkgname=python3-pyside2
 version=5.15.10
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/pyside2"
 build_style=cmake

From 9a4b5e1e41836064ce794e1c3d6c7a1e006bc1d0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:35 -0400
Subject: [PATCH 077/113] konqueror: revbump for ffmpeg6

---
 srcpkgs/konqueror/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/konqueror/template b/srcpkgs/konqueror/template
index 044dafa605ba65..63dd01fafc7802 100644
--- a/srcpkgs/konqueror/template
+++ b/srcpkgs/konqueror/template
@@ -1,11 +1,11 @@
 # Template file for 'konqueror'
 pkgname=konqueror
 version=23.08.4
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DDESKTOPTOJSON_EXECUTABLE=/usr/bin/desktoptojson"
 hostmakedepends="extra-cmake-modules python3 qt5-host-tools qt5-qmake kdoctools
-kcoreaddons kconfig gettext"
+ kcoreaddons kconfig gettext"
 makedepends="qt5-devel qt5-webengine-devel qt5-declarative-devel
  qt5-webchannel-devel qt5-location-devel kcmutils-devel kdelibs4support-devel
  karchive-devel khtml-devel kdesu-devel kactivities5-devel"

From 5081bafdcf9152723bf89dcab4a85c6b94b3a3c8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:58 -0400
Subject: [PATCH 078/113] qt5-speech: revbump for qt5-5.15.11

---
 srcpkgs/qt5-speech/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-speech/template b/srcpkgs/qt5-speech/template
index 1228bb60c41db4..27a7da1dbdb91b 100644
--- a/srcpkgs/qt5-speech/template
+++ b/srcpkgs/qt5-speech/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-speech'
 pkgname=qt5-speech
 version=5.15.11
-revision=1
+revision=2
 _commit=d32f4a479d38a11f547598004b975f4356424a16
 build_style=qmake
 configure_args="-- -flite -flite-alsa -speechd"

From 5fb90f920e6bb1363c5b453c2bad1477a03e4748 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Jun 2023 08:20:22 -0400
Subject: [PATCH 079/113] gtk4: revbump for ffmpeg6

---
 srcpkgs/gtk4/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gtk4/template b/srcpkgs/gtk4/template
index d8ee60abe06f71..55bff6e33849ac 100644
--- a/srcpkgs/gtk4/template
+++ b/srcpkgs/gtk4/template
@@ -1,7 +1,7 @@
 # Template file for 'gtk4'
 pkgname=gtk4
 version=4.12.3
-revision=1
+revision=2
 build_style=meson
 build_helper="gir"
 configure_args="-Dman-pages=true -Ddocumentation=true -Dbuild-tests=false

From 8da25c07c509d9b98bdd2308e70104d2e8173008 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:28:26 -0400
Subject: [PATCH 080/113] siril: revbump for ffmpeg6

---
 srcpkgs/siril/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/siril/template b/srcpkgs/siril/template
index 84332f79d060d2..62750dd247548f 100644
--- a/srcpkgs/siril/template
+++ b/srcpkgs/siril/template
@@ -1,7 +1,7 @@
 # Template file for 'siril'
 pkgname=siril
 version=0.9.12
-revision=10
+revision=11
 build_style=gnu-configure
 hostmakedepends="pkg-config intltool autoconf automake gettext-devel"
 makedepends="fftw-devel libconfig-devel libopencv-devel libffms2-devel

From b0b0c2a64c039012c13cf3582ab2ffc4d5e30344 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 22 Jun 2023 10:25:02 -0400
Subject: [PATCH 081/113] kdenlive: revbump for ffmpeg6

---
 srcpkgs/kdenlive/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kdenlive/template b/srcpkgs/kdenlive/template
index a0f3615c9c530c..d63166f95c4d78 100644
--- a/srcpkgs/kdenlive/template
+++ b/srcpkgs/kdenlive/template
@@ -1,7 +1,7 @@
 # Template file for 'kdenlive'
 pkgname=kdenlive
 version=23.08.4
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="
  extra-cmake-modules kconfig kcoreaddons kdoctools pkg-config python3

From c7c8f4f9f510860acc501757de71d2e0d7ab0b6f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:20:59 -0400
Subject: [PATCH 082/113] tracker-miners: revbump for ffmpeg6

---
 srcpkgs/tracker-miners/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tracker-miners/template b/srcpkgs/tracker-miners/template
index 0b97f47489f817..f196d2bf9e4a4c 100644
--- a/srcpkgs/tracker-miners/template
+++ b/srcpkgs/tracker-miners/template
@@ -1,7 +1,7 @@
 # Template file for 'tracker-miners'
 pkgname=tracker-miners
 version=3.6.1
-revision=1
+revision=2
 build_style=meson
 build_helper=qemu
 # missing libgrss for miner_rss

From 2f5bf8b47ebdba66435cf46e783c3a8dbb6209c2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:21:21 -0400
Subject: [PATCH 083/113] mpd: revbump for ffmpeg6

---
 srcpkgs/mpd/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpd/template b/srcpkgs/mpd/template
index 4fd32b7be8c537..b8e2bd4c1b59c8 100644
--- a/srcpkgs/mpd/template
+++ b/srcpkgs/mpd/template
@@ -1,7 +1,7 @@
 # Template file for 'mpd'
 pkgname=mpd
 version=0.23.15
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dopus=enabled -Dmikmod=enabled -Dneighbor=true
  -Dsoundcloud=enabled -Dpipe=true -Dtwolame=enabled -Dbzip2=enabled

From ab5f2a0d7cf64be2a9c8a7dbefa55505d876f43f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:02 -0400
Subject: [PATCH 084/113] tg_owt: revbump for ffmpeg6

---
 srcpkgs/tg_owt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tg_owt/template b/srcpkgs/tg_owt/template
index aee8d35d08ffbe..34e8fef0540569 100644
--- a/srcpkgs/tg_owt/template
+++ b/srcpkgs/tg_owt/template
@@ -1,7 +1,7 @@
 # Template file for 'tg_owt'
 pkgname=tg_owt
 version=0.0.0.20231221
-revision=1
+revision=2
 _commit=afd9d5d31798d3eacf9ed6c30601e91d0f1e4d60
 _libyuv_commit=04821d1e7d60845525e8db55c7bcd41ef5be9406
 _abseil_commit=8c0b94e793a66495e0b1f34a5eb26bd7dc672db0

From 41c97d2fc856d40208f6db55a1e014fbc65133b2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:44 -0400
Subject: [PATCH 085/113] telegram-desktop: revbump for ffmpeg6

---
 srcpkgs/telegram-desktop/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/telegram-desktop/template b/srcpkgs/telegram-desktop/template
index d00b273b7b7386..d20b87b5182db8 100644
--- a/srcpkgs/telegram-desktop/template
+++ b/srcpkgs/telegram-desktop/template
@@ -1,7 +1,7 @@
 # Template file for 'telegram-desktop'
 pkgname=telegram-desktop
 version=4.14.9
-revision=1
+revision=2
 build_style=cmake
 build_helper="qemu gir"
 configure_args="-DTDESKTOP_API_ID=209235

From b4fcf6c15c868f7bf3b8b20fe934a1a2be2db750 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:11:45 -0400
Subject: [PATCH 086/113] gst-plugins-bad1: revbump for ffmpeg6

---
 srcpkgs/gst-plugins-bad1/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index 63200e74f99a7f..644758cb187a19 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-plugins-bad1'
 pkgname=gst-plugins-bad1
 version=1.22.9
-revision=1
+revision=2
 build_helper="gir"
 build_style=meson
 configure_args="-Dpackage-origin=https://voidlinux.org -Ddoc=disabled

From 8471881858b02e60ff6d21a5e345c886e0dd5878 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:12:09 -0400
Subject: [PATCH 087/113] openmw: revbump for ffmpeg6

---
 srcpkgs/openmw/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openmw/template b/srcpkgs/openmw/template
index 0abf5ff7cdbecc..b57180f1a4446f 100644
--- a/srcpkgs/openmw/template
+++ b/srcpkgs/openmw/template
@@ -1,7 +1,7 @@
 # Template file for 'openmw'
 pkgname=openmw
 version=0.48.0
-revision=2
+revision=3
 build_style=cmake
 _recast_commit=e75adf86f91eb3082220085e42dda62679f9a3ea
 _bullet_tag=3.17

From 69d9b185384a44171f5b5f45ad7d435e1e8bd1d1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:14:53 -0400
Subject: [PATCH 088/113] lms: revbump for ffmpeg6

---
 srcpkgs/lms/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/lms/template b/srcpkgs/lms/template
index e358f75902a986..3b21c458de5199 100644
--- a/srcpkgs/lms/template
+++ b/srcpkgs/lms/template
@@ -1,7 +1,7 @@
 # Template file for 'lms'
 pkgname=lms
 version=3.42.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="wt-devel ffmpeg-devel boost-devel libconfig++-devel taglib-devel pam-devel libgraphicsmagick-devel gtest-devel libarchive-devel"

From 11c502a146b76c257b89a3943ad5427867e71c91 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:18:18 -0400
Subject: [PATCH 089/113] freecad: DELETE

---
 srcpkgs/freecad/patches/001-include.patch     | 112 ------------------
 .../154-revert-gui-tmp-redirect-stderr.patch  |  68 -----------
 ...d63c8c9b1280978be841d04e68a0a55cceb9.patch |  30 -----
 srcpkgs/freecad/template                      |  12 +-
 4 files changed, 7 insertions(+), 215 deletions(-)
 delete mode 100644 srcpkgs/freecad/patches/001-include.patch
 delete mode 100644 srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
 delete mode 100644 srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch

diff --git a/srcpkgs/freecad/patches/001-include.patch b/srcpkgs/freecad/patches/001-include.patch
deleted file mode 100644
index 28b5af54999b96..00000000000000
--- a/srcpkgs/freecad/patches/001-include.patch
+++ /dev/null
@@ -1,112 +0,0 @@
-From 9a41845a417189776741297c50a3827ce292bc4f Mon Sep 17 00:00:00 2001
-From: Uwe <donovaly@users.noreply.github.com>
-Date: Sun, 3 Jul 2022 22:51:16 +0200
-Subject: [PATCH] [Part] OCCError.h: remove unneeded includes
-
-- also sort includes
----
- src/Mod/Part/App/OCCError.h             | 36 +++----------------------
- src/Mod/Part/App/OffsetCurvePyImp.cpp   | 12 ++++-----
- src/Mod/Part/App/OffsetSurfacePyImp.cpp | 10 +++----
- 3 files changed, 12 insertions(+), 46 deletions(-)
-
---- a/src/Mod/Part/App/OCCError.h
-+++ b/src/Mod/Part/App/OCCError.h
-@@ -23,36 +23,8 @@
- #ifndef _OCCError_h_
- #define _OCCError_h_
- 
--# include <Standard_Version.hxx>
- # include <Standard_Failure.hxx>
--# include <Standard_AbortiveTransaction.hxx>
--# include <Standard_ConstructionError.hxx>
--# if OCC_VERSION_HEX >= 0x060500
--# include <Standard_DefineException.hxx>
--# endif
--# include <Standard_DimensionError.hxx>
--# include <Standard_DimensionMismatch.hxx>
--# include <Standard_DivideByZero.hxx>
--# include <Standard_DomainError.hxx>
--# include <Standard_ImmutableObject.hxx>
--# include <Standard_LicenseError.hxx>
--# include <Standard_LicenseNotFound.hxx>
--# include <Standard_MultiplyDefined.hxx>
--# include <Standard_NegativeValue.hxx>
--# include <Standard_NoMoreObject.hxx>
--# include <Standard_NoSuchObject.hxx>
--# include <Standard_NotImplemented.hxx>
--# include <Standard_NullObject.hxx>
--# include <Standard_NullValue.hxx>
--# include <Standard_NumericError.hxx>
--# include <Standard_OutOfMemory.hxx>
--# include <Standard_OutOfRange.hxx>
--# include <Standard_Overflow.hxx>
--# include <Standard_ProgramError.hxx>
--# include <Standard_RangeError.hxx>
--# include <Standard_TooManyUsers.hxx>
--# include <Standard_TypeMismatch.hxx>
--# include <Standard_Underflow.hxx>
-+# include <Standard_Version.hxx>
- 
- #include <Mod/Part/PartGlobal.h>
- #include <Base/Console.h>
-@@ -88,4 +60,3 @@ PartExport extern PyObject* PartExceptio
- 
- #define PY_CATCH_OCC _PY_CATCH_OCC(return(NULL))
- #endif  // _OCCError_h_
--
---- a/src/Mod/Part/App/OffsetCurvePyImp.cpp
-+++ b/src/Mod/Part/App/OffsetCurvePyImp.cpp
-@@ -20,20 +20,20 @@
-  *                                                                         *
-  ***************************************************************************/
- 
--
- #include "PreCompiled.h"
- #ifndef _PreComp_
- # include <Geom_OffsetCurve.hxx>
- #endif
- 
--#include "OCCError.h"
--#include "Geometry.h"
-+#include <Base/GeometryPyCXX.h>
-+#include <Base/Vector3D.h>
-+#include <Base/VectorPy.h>
-+
- #include "OffsetCurvePy.h"
- #include "OffsetCurvePy.cpp"
-+#include "Geometry.h"
-+#include "OCCError.h"
- 
--#include <Base/GeometryPyCXX.h>
--#include <Base/VectorPy.h>
--#include <Base/Vector3D.h>
- 
- using namespace Part;
- 
---- a/src/Mod/Part/App/OffsetSurfacePyImp.cpp
-+++ b/src/Mod/Part/App/OffsetSurfacePyImp.cpp
-@@ -20,20 +20,16 @@
-  *                                                                         *
-  ***************************************************************************/
- 
--
- #include "PreCompiled.h"
- #ifndef _PreComp_
- # include <Geom_OffsetSurface.hxx>
- # include <memory>
- #endif
- 
--#include <Base/VectorPy.h>
--#include <Base/Vector3D.h>
--
- #include "OCCError.h"
--#include "Geometry.h"
--#include <Mod/Part/App/OffsetSurfacePy.h>
--#include <Mod/Part/App/OffsetSurfacePy.cpp>
-+#include "OffsetSurfacePy.h"
-+#include "OffsetSurfacePy.cpp"
-+
- 
- using namespace Part;
- 
diff --git a/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch b/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
deleted file mode 100644
index d6a9adabdec830..00000000000000
--- a/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
+++ /dev/null
@@ -1,68 +0,0 @@
-see https://github.com/FreeCAD/FreeCAD/commit/cfe94b00d3434f3e2c8b5114d2909f628c330fa8#commitcomment-71413407
-
-upstream: yes
-
-From 7b377a216b9185960e4cee980a6504dc1a755f50 Mon Sep 17 00:00:00 2001
-From: wmayer <wmayer@users.sourceforge.net>
-Date: Wed, 29 Jun 2022 15:19:18 +0200
-Subject: [PATCH] Gui: remove workaround for spnav 0.23 due to build failure
- with musl libc
-
----
- src/Gui/3Dconnexion/GuiNativeEventLinux.cpp | 27 ---------------------
- 1 file changed, 27 deletions(-)
-
---- a/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp
-+++ b/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp
-@@ -21,42 +21,17 @@
-  ***************************************************************************/
- 
- #include <FCConfig.h>
--#include <cstdio>
- 
- #include "GuiNativeEventLinux.h"
- 
- #include "GuiApplicationNativeEventAware.h"
- #include <Base/Console.h>
--#include <Base/FileInfo.h>
- #include <QMainWindow>
- 
- #include <QSocketNotifier>
- 
- #include <spnav.h>
- 
--namespace {
--class RedirectStdErr
--{
--public:
--    RedirectStdErr()
--        : fi(Base::FileInfo::getTempFileName())
--        , file(stderr)
--    {
--        stderr = fopen(fi.filePath().c_str(), "w");
--    }
--    ~RedirectStdErr()
--    {
--        fclose(stderr);
--        fi.deleteFile();
--        stderr = file;
--    }
--
--private:
--    Base::FileInfo fi;
--    FILE* file;
--};
--}
--
- Gui::GuiNativeEvent::GuiNativeEvent(Gui::GUIApplicationNativeEventAware *app)
- : GuiAbstractNativeEvent(app)
- {
-@@ -72,8 +47,6 @@ Gui::GuiNativeEvent::~GuiNativeEvent()
- 
- void Gui::GuiNativeEvent::initSpaceball(QMainWindow *window)
- {
--    // tmp. redirect stderr to a file to suppress an error message from spnav_open()
--    RedirectStdErr err;
-     Q_UNUSED(window)
-     if (spnav_open() == -1) {
-         Base::Console().Log("Couldn't connect to spacenav daemon. Please ignore if you don't have a spacemouse.\n");
diff --git a/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch b/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch
deleted file mode 100644
index d4acf370ca0a42..00000000000000
--- a/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-From fe02d63c8c9b1280978be841d04e68a0a55cceb9 Mon Sep 17 00:00:00 2001
-From: Roy-043 <70520633+Roy-043@users.noreply.github.com>
-Date: Thu, 29 Dec 2022 23:20:38 +0100
-Subject: [PATCH] Draft: update inspect.getargspec to inspect.getfullargspec
- (#8101)
-
----
- src/Mod/Draft/draftguitools/gui_snapper.py | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
---- a/src/Mod/Draft/draftguitools/gui_snapper.py
-+++ b/src/Mod/Draft/draftguitools/gui_snapper.py
-@@ -1426,7 +1426,7 @@ class Snapper:
-             Gui.Snapper.off()
-             self.ui.offUi()
-             if callback:
--                if len(inspect.getargspec(callback).args) > 1:
-+                if len(inspect.getfullargspec(callback).args) > 1:
-                     obj = None
-                     if self.snapInfo and ("Object" in self.snapInfo) and self.snapInfo["Object"]:
-                         obj = App.ActiveDocument.getObject(self.snapInfo["Object"])
-@@ -1445,7 +1445,7 @@ class Snapper:
-             Gui.Snapper.off()
-             self.ui.offUi()
-             if callback:
--                if len(inspect.getargspec(callback).args) > 1:
-+                if len(inspect.getfullargspec(callback).args) > 1:
-                     callback(None, None)
-                 else:
-                     callback(None)
diff --git a/srcpkgs/freecad/template b/srcpkgs/freecad/template
index c135701e38b9ad..7d5165f760bab9 100644
--- a/srcpkgs/freecad/template
+++ b/srcpkgs/freecad/template
@@ -1,7 +1,7 @@
 # Template file for 'freecad'
 pkgname=freecad
-version=0.20.2
-revision=7
+version=0.21.1
+revision=2
 build_wrksrc="FreeCAD-${version}"
 build_style=cmake
 pycompile_dirs="usr/lib/${pkgname}/Mod"
@@ -24,8 +24,10 @@ makedepends="python3-devel boost-devel libxerces-c-devel zlib-devel occt-devel
  coin3-devel libshiboken2-devel libspnav-devel pyside2-tools
  liblz4-devel libpyside2-python3-devel python3-matplotlib netcdf-devel
  jsoncpp-devel qt5-devel qt5-svg-devel qt5-tools-devel qt5-webkit-devel
- qt5-xmlpatterns-devel coin3-doc glew-devel python3-pivy"
-depends="python3-matplotlib python3-pyside2-webengine python3-pivy"
+ qt5-xmlpatterns-devel coin3-doc glew-devel python3-pivy qt5-webengine-devel
+ qt5-declarative-devel qt5-webchannel-devel qt5-location-devel"
+depends="python3-matplotlib python3-pyside2-webengine python3-pivy
+ python3-GitPython python3-Markdown"
 short_desc="General purpose 3D CAD modeler"
 maintainer="yopito <pierre.bourgin@free.fr>"
 license="LGPL-2.0-or-later"
@@ -35,7 +37,7 @@ distfiles="
  https://github.com/FreeCAD/FreeCAD/archive/${version}.tar.gz
  ${SOURCEFORGE_SITE}/cxx/pycxx-${_pycxxver}.tar.gz
 "
-checksum="46922f3a477e742e1a89cd5346692d63aebb2b67af887b3e463e094a4ae055da
+checksum="e9b1fd0323f101268c7f3be52db42e4a29222f2e306ae6c4a6fc309cb418d35a
  4b91e1e1141c23fbd5039df635c4bb6e75632168548f56b83ce177193c0c98c6"
 python_version=3
 patch_args="-Np1 -d ${build_wrksrc}"

From bd1bcec99698215199d2ec99261a919a0a45552d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:47:18 -0400
Subject: [PATCH 090/113] libopenshot: revbump for ffmpeg6

---
 srcpkgs/libopenshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenshot/template b/srcpkgs/libopenshot/template
index 8e57c5f592169c..7a8f4520e78925 100644
--- a/srcpkgs/libopenshot/template
+++ b/srcpkgs/libopenshot/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenshot'
 pkgname=libopenshot
 version=0.3.0
-revision=3
+revision=4
 build_style=cmake
 # Builds fail with Ruby-2.4.1
 configure_args="-DENABLE_RUBY=OFF -DUSE_SYSTEM_JSONCPP=ON"

From a5ce4efe153b50a52cf7b2a20ba7715ac0143dc9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:10:30 -0500
Subject: [PATCH 091/113] openimageio: revbump for ffmpeg6

---
 srcpkgs/openimageio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimageio/template b/srcpkgs/openimageio/template
index 3ce3f9e49d350c..27d2131bc0a61a 100644
--- a/srcpkgs/openimageio/template
+++ b/srcpkgs/openimageio/template
@@ -1,7 +1,7 @@
 # Template file for 'openimageio'
 pkgname=openimageio
 version=2.4.9.0
-revision=7
+revision=8
 build_style=cmake
 build_helper=qemu
 configure_args="-DUSE_QT=0 -DUSE_PYTHON=0 -DOIIO_BUILD_TESTS=0

From 1640e7c860813a48e4e7a6ca2c40e88625965cc5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:11:57 -0500
Subject: [PATCH 092/113] synfigstudio: revbump for ffmpeg6

---
 srcpkgs/synfigstudio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/synfigstudio/template b/srcpkgs/synfigstudio/template
index 09e442da9a6805..2bc017cedca6b8 100644
--- a/srcpkgs/synfigstudio/template
+++ b/srcpkgs/synfigstudio/template
@@ -2,7 +2,7 @@
 # Should be kept in sync with 'synfig' and 'ETL'
 pkgname=synfigstudio
 version=1.4.4
-revision=4
+revision=5
 build_style=gnu-configure
 configure_args="--disable-update-mimedb"
 hostmakedepends="pkg-config intltool gettext synfig"

From b7c4d3da20ef10ab5661e8375957f2cc32537b85 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:10 -0500
Subject: [PATCH 093/113] mixxx: revbump for ffmpeg6

---
 srcpkgs/mixxx/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mixxx/template b/srcpkgs/mixxx/template
index 6921996e4e77b3..6a79b328c1abf0 100644
--- a/srcpkgs/mixxx/template
+++ b/srcpkgs/mixxx/template
@@ -1,7 +1,7 @@
 # Template file for 'mixxx'
 pkgname=mixxx
 version=2.3.3
-revision=6
+revision=7
 build_style=cmake
 configure_args="-DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="extra-cmake-modules pkg-config protobuf qt5-host-tools qt5-qmake"

From d0736abca5da25b5f7e8864cff8e32190738c69e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:28 -0500
Subject: [PATCH 094/113] musikcube: revbump for ffmpeg6

---
 srcpkgs/musikcube/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/musikcube/template b/srcpkgs/musikcube/template
index 8c4a51840859ec..fb60dd2049089a 100644
--- a/srcpkgs/musikcube/template
+++ b/srcpkgs/musikcube/template
@@ -1,7 +1,7 @@
 # Template file for 'musikcube'
 pkgname=musikcube
 version=3.0.0
-revision=3
+revision=4
 build_style=cmake
 make_cmd=make
 configure_args="-DNO_NCURSESW=1"

From e741b301204142e609db412e1d0f2fdc5d27096c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:45 -0500
Subject: [PATCH 095/113] electron24: revbump for ffmpeg6

---
 srcpkgs/electron24/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron24/template b/srcpkgs/electron24/template
index 7b4e28812f483e..1ca93fde97a854 100644
--- a/srcpkgs/electron24/template
+++ b/srcpkgs/electron24/template
@@ -1,7 +1,7 @@
 # Template file for 'electron24'
 pkgname=electron24
 version=24.3.0
-revision=2
+revision=3
 _nodever=18.14.0
 _chromiumver=112.0.5615.165
 archs="x86_64* aarch64*"

From c10d8ddda32d79695d5d8c911162f1a9503b786f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:00 -0500
Subject: [PATCH 096/113] electron19: revbump for ffmpeg6

---
 srcpkgs/electron19/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron19/template b/srcpkgs/electron19/template
index 0ef959125cb085..5371c0b354604f 100644
--- a/srcpkgs/electron19/template
+++ b/srcpkgs/electron19/template
@@ -1,7 +1,7 @@
 # Template file for 'electron19'
 pkgname=electron19
 version=19.0.8
-revision=4
+revision=5
 _nodever=16.14.2
 _chromiumver=102.0.5005.125
 archs="x86_64* aarch64* ppc64le*"

From 00ac2056fd5facbb0e7cb6f1e4c1af6b0ec77a9b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:13 -0500
Subject: [PATCH 097/113] wf-recorder: revbump for ffmpeg6

---
 srcpkgs/wf-recorder/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/wf-recorder/template b/srcpkgs/wf-recorder/template
index 08f986b0310067..63c45cf4b814d7 100644
--- a/srcpkgs/wf-recorder/template
+++ b/srcpkgs/wf-recorder/template
@@ -1,7 +1,7 @@
 # Template file for 'wf-recorder'
 pkgname=wf-recorder
 version=0.4.1
-revision=2
+revision=3
 build_style=meson
 hostmakedepends="pkg-config scdoc wayland-devel"
 makedepends="wayland-protocols wayland-devel ffmpeg-devel libgbm-devel x264-devel

From 24f7c7284f2e88a85bddc8c712cd75ec7e3f9c08 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:26 -0500
Subject: [PATCH 098/113] obs: revbump for ffmpeg6

---
 srcpkgs/obs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/obs/template b/srcpkgs/obs/template
index b343f1131bfcf6..a25a67433e285e 100644
--- a/srcpkgs/obs/template
+++ b/srcpkgs/obs/template
@@ -1,7 +1,7 @@
 # Template file for 'obs'
 pkgname=obs
 version=30.0.0
-revision=2
+revision=3
 archs="i686* x86_64* ppc64le* aarch64* riscv64*"
 build_style=cmake
 configure_args="-DOBS_VERSION_OVERRIDE=${version} -DENABLE_JACK=ON

From 840f4b070eaafc99e4229328d6c3c14831ac90ed Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:36 -0500
Subject: [PATCH 099/113] mlt7: revbump for ffmpeg6

---
 srcpkgs/mlt7/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mlt7/template b/srcpkgs/mlt7/template
index 98f302ad3a5167..7eb8c00fa1580c 100644
--- a/srcpkgs/mlt7/template
+++ b/srcpkgs/mlt7/template
@@ -1,7 +1,7 @@
 # Template file for 'mlt7'
 pkgname=mlt7
 version=7.20.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DSWIG_PYTHON=ON -DMOD_QT6=ON"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which

From 3ab127f2642ad245eeb160781bb28081221c06cd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:48 -0500
Subject: [PATCH 100/113] qt6-multimedia: revbump for ffmpeg6

---
 srcpkgs/qt6-multimedia/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-multimedia/template b/srcpkgs/qt6-multimedia/template
index 67a577e1300fea..1da626ecf515a8 100644
--- a/srcpkgs/qt6-multimedia/template
+++ b/srcpkgs/qt6-multimedia/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-multimedia'
 pkgname=qt6-multimedia
 version=6.6.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DQT_FEATURE_gstreamer=ON"
 hostmakedepends="perl qt6-declarative-host-tools pkg-config qt6-shadertools"

From 8f1aefd9c4006ebb30c8eafcff0959e53b9ee2b6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:00:15 -0500
Subject: [PATCH 101/113] baresip: revbump for ffmpeg6

---
 srcpkgs/baresip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/baresip/template b/srcpkgs/baresip/template
index 12c8954ef7b9b7..b16b67beab8d2b 100644
--- a/srcpkgs/baresip/template
+++ b/srcpkgs/baresip/template
@@ -1,7 +1,7 @@
 # Template file for 'baresip'
 pkgname=baresip
 version=3.6.0
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config glib-devel"
 makedepends="libgsm-devel libpng-devel openssl-devel libsndfile-devel

From 543eb99d6b0d775439afb9da9d07608478cdb695 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:30 -0500
Subject: [PATCH 102/113] QMPlay2: revbump for ffmpeg6

---
 srcpkgs/QMPlay2/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/QMPlay2/template b/srcpkgs/QMPlay2/template
index 46c80f64a13497..942258ce60fb7e 100644
--- a/srcpkgs/QMPlay2/template
+++ b/srcpkgs/QMPlay2/template
@@ -1,7 +1,7 @@
 # Template file for 'QMPlay2'
 pkgname=QMPlay2
 version=23.10.22
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools"
 makedepends="alsa-lib-devel ffmpeg-devel libass-devel libcdio-devel libgme-devel

From e6bebc555a7d4284e44cadef4940db004b3b9c63 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:34 -0500
Subject: [PATCH 103/113] alsa-plugins: revbump for ffmpeg6

---
 srcpkgs/alsa-plugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/alsa-plugins/template b/srcpkgs/alsa-plugins/template
index a5708a7d82a8f0..7bfdad046c4830 100644
--- a/srcpkgs/alsa-plugins/template
+++ b/srcpkgs/alsa-plugins/template
@@ -1,7 +1,7 @@
 # Template file for 'alsa-plugins'
 pkgname=alsa-plugins
 version=1.2.7.1
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--disable-maemo-plugin"
 hostmakedepends="pkg-config"

From d35da8a7fb7f5e9753df0a13a0da66e47b6e398e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:43 -0500
Subject: [PATCH 104/113] minidlna: revbump for ffmpeg6

---
 srcpkgs/minidlna/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/minidlna/template b/srcpkgs/minidlna/template
index 5fa929f3a0c124..742991ecd04afc 100644
--- a/srcpkgs/minidlna/template
+++ b/srcpkgs/minidlna/template
@@ -1,7 +1,7 @@
 # Template file for 'minidlna'
 pkgname=minidlna
 version=1.3.3
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="
  --sbindir=/usr/bin

From b6aa6f464c5e14572d12f3f6ed26a5a6455c7583 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 17:57:47 -0500
Subject: [PATCH 105/113] mpv: revbump for ffmpeg6

---
 srcpkgs/mpv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpv/template b/srcpkgs/mpv/template
index 4948d1e332cb8b..1ac1b167af189c 100644
--- a/srcpkgs/mpv/template
+++ b/srcpkgs/mpv/template
@@ -1,7 +1,7 @@
 # Template file for 'mpv'
 pkgname=mpv
 version=0.36.0
-revision=4
+revision=5
 build_style=meson
 configure_args="-Dcdda=enabled -Ddvbin=enabled -Ddvdnav=enabled
  -Dlibmpv=true -Dcplugins=enabled

From e03e356f1c356a83d4e6d497f8e47b6dcb818769 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 17:59:29 -0500
Subject: [PATCH 106/113] qimgv: revbump for ffmpeg6

---
 srcpkgs/qimgv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qimgv/template b/srcpkgs/qimgv/template
index dd341dfe1bfce8..8a7e1c081ef12f 100644
--- a/srcpkgs/qimgv/template
+++ b/srcpkgs/qimgv/template
@@ -1,7 +1,7 @@
 # Template file for 'qimgv'
 pkgname=qimgv
 version=1.0.2
-revision=3
+revision=4
 build_style=cmake
 configure_args="$(vopt_if video -DVIDEO_SUPPORT=ON -DVIDEO_SUPPORT=OFF)
  $(vopt_if scale -DOPENCV_SUPPORT=ON -DOPENCV_SUPPORT=OFF)

From 5032fc3aecf4ec83d8d9a9d79dcae59e54ba486d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 18:00:36 -0500
Subject: [PATCH 107/113] kfilemetadata5: revbump for ffmpeg6

---
 srcpkgs/kfilemetadata5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kfilemetadata5/template b/srcpkgs/kfilemetadata5/template
index 51fd6fec8c1c01..ad229b4c2e241d 100644
--- a/srcpkgs/kfilemetadata5/template
+++ b/srcpkgs/kfilemetadata5/template
@@ -1,7 +1,7 @@
 # Template file for 'kfilemetadata5'
 pkgname=kfilemetadata5
 version=5.113.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="kcoreaddons extra-cmake-modules pkg-config qt5-host-tools qt5-qmake
  gettext kcoreaddons python3"

From d149853b08d7943d56fe2ee153322891880b85e9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 8 Dec 2023 11:46:01 -0500
Subject: [PATCH 108/113] vba-m: revbump for ffmpeg6

---
 srcpkgs/vba-m/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vba-m/template b/srcpkgs/vba-m/template
index 3d135efa1d0b69..3c5a20db0fa984 100644
--- a/srcpkgs/vba-m/template
+++ b/srcpkgs/vba-m/template
@@ -2,7 +2,7 @@
 pkgname=vba-m
 reverts=1292_2
 version=2.1.9
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_GTK=TRUE -DENABLE_FFMPEG=TRUE -DENABLE_LINK=TRUE -DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="gettext pkg-config unzip zip yasm wxWidgets-gtk3-devel"

From a123d1884e114de7012cb2724bef7542ba9a5b8b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 8 Dec 2023 11:46:19 -0500
Subject: [PATCH 109/113] dolphin-emu: revbump for ffmpeg6

---
 srcpkgs/dolphin-emu/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/dolphin-emu/template b/srcpkgs/dolphin-emu/template
index 862d3ae964eec4..a7ae0efb58fb75 100644
--- a/srcpkgs/dolphin-emu/template
+++ b/srcpkgs/dolphin-emu/template
@@ -1,7 +1,7 @@
 # Template file for 'dolphin-emu'
 pkgname=dolphin-emu
 version=5.0.19368
-revision=3
+revision=4
 _dolphin_commit=dadbeb4bae7e7fa23af2b46e0add4143094dc107
 _mgba_commit=44e074a15e9651481f7f652ac006a7c9d58cbeb9
 _googletest_commit=be03d00f5f0cc3a997d1a368bee8a1fe93651f48

From 9b589cae0df9eaa6f2cd894ac87717c9cf87e1ee Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 19 Dec 2023 15:38:51 -0500
Subject: [PATCH 110/113] qtox: revbump for ffmpeg4

---
 srcpkgs/qtox/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtox/template b/srcpkgs/qtox/template
index bb70e7f51240a4..755e4462bc0137 100644
--- a/srcpkgs/qtox/template
+++ b/srcpkgs/qtox/template
@@ -1,13 +1,13 @@
 # Template file for 'qtox'
 pkgname=qtox
 version=1.17.6
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DUPDATE_CHECK=OFF
  -DGIT_DESCRIBE=${version}
  $(vopt_if snorenotify -DDESKTOP_NOTIFICATIONS=ON)"
 hostmakedepends="pkg-config qt5-host-tools qt5-devel"
-makedepends="ffmpeg-devel libexif-devel libopenal-devel libsodium-devel
+makedepends="ffmpeg4-devel libexif-devel libopenal-devel libsodium-devel
  libvpx-devel opus-devel qrencode-devel qt5-svg-devel sonnet-devel
  sqlcipher-devel toxcore-devel
  $(vopt_if snorenotify snorenotify-devel)"

From aefa52a8d2c5fc83d0749b4e48135890193ee1e6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 11 Jan 2024 11:52:00 -0500
Subject: [PATCH 111/113] arcan: revbump for ffmpeg6

---
 srcpkgs/arcan/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/arcan/template b/srcpkgs/arcan/template
index ff9091f90ebb10..030091a6cc9d0c 100644
--- a/srcpkgs/arcan/template
+++ b/srcpkgs/arcan/template
@@ -2,7 +2,7 @@
 # !! keep synced with: acfgfs aclip aloadimage
 pkgname=arcan
 version=0.6.2.1
-revision=2
+revision=3
 create_wrksrc=yes
 build_wrksrc=arcan/src
 build_style=cmake

From a26b975554ff2e1d932ffd62bf95b32130d1e3e0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 11 Jan 2024 11:52:10 -0500
Subject: [PATCH 112/113] notcurses: revbump for ffmpeg6

---
 srcpkgs/notcurses/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/notcurses/template b/srcpkgs/notcurses/template
index 48a7463cb68eb9..515f316ab4576c 100644
--- a/srcpkgs/notcurses/template
+++ b/srcpkgs/notcurses/template
@@ -1,7 +1,7 @@
 # Template file for 'notcurses'
 pkgname=notcurses
 version=3.0.9
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DUSE_STATIC=ON -DUSE_QRCODEGEN=On $(vopt_bool man USE_PANDOC)"
 hostmakedepends="pkg-config $(vopt_if man pandoc)"

From aaf359f03c8a1a48bfee37a8b8e6a925fb352493 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Feb 2024 14:28:38 -0500
Subject: [PATCH 113/113] New package: oneVPL-intel-gpu-24.1.3

---
 srcpkgs/oneVPL-intel-gpu/template | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
 create mode 100644 srcpkgs/oneVPL-intel-gpu/template

diff --git a/srcpkgs/oneVPL-intel-gpu/template b/srcpkgs/oneVPL-intel-gpu/template
new file mode 100644
index 00000000000000..8b93cfabf7fc8c
--- /dev/null
+++ b/srcpkgs/oneVPL-intel-gpu/template
@@ -0,0 +1,18 @@
+# Template file for 'oneVPL-intel-gpu'
+pkgname=oneVPL-intel-gpu
+version=24.1.3
+revision=1
+build_style=cmake
+hostmakedepends="pkg-config"
+makedepends="libva-devel libdrm-devel"
+short_desc="Intel oneVPL GPU Runtime"
+maintainer="zlice <zlice555@gmail.com>"
+license="MIT"
+homepage="https://github.com/oneapi-src/oneVPL-intel-gpu"
+changelog="https://github.com/oneapi-src/oneVPL-intel-gpu/blob/main/CHANGELOG.md"
+distfiles="https://github.com/oneapi-src/oneVPL-intel-gpu/archive/refs/tags/intel-onevpl-${version}.tar.gz"
+checksum=15d34e4304d7aeb5ea5e529b6f51171109cef42525113321f675bc14e56c697e
+
+post_install() {
+	vlicense LICENSE
+}

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (63 preceding siblings ...)
  2024-02-11 17:28 ` [PR PATCH] [Updated] " zlice
@ 2024-02-11 22:49 ` zlice
  2024-02-15 19:52 ` zlice
                   ` (32 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2024-02-11 22:49 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 4558 bytes --]

There is an updated pull request by zlice against master on the void-packages repository

https://github.com/zlice/void-packages ffmpeg6-split
https://github.com/void-linux/void-packages/pull/43761

ffmpeg6 split
[ci skip]


#### Testing the changes

- I tested the changes in this PR: **YES**

main testing has been vaapi in Firefox Nightly and enc/dec in Shotcut on Intel A770

#### New package

- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**

#### Local build testing

- I built this PR locally for my native architecture, **x86_64**

#### Discussion

Continuation of https://github.com/void-linux/void-packages/pull/36315

`libavresample` is deprecated, but marked as a dependency when trying to build other packages and install `ffmpeg`(6). I think the right way to handle this is make a meta package and the add to removals?


##### Commit naming / misc

~~Commits are 'dirty' right now, running with [gstreamer 1.22.1 updates](https://github.com/void-linux/void-packages/pull/42861) and [Intel OpenCL](https://github.com/void-linux/void-packages/pull/43084). This will also make [intel packages pr](https://github.com/void-linux/void-packages/pull/41132) obsolete.~~ (see Requirements below)

Maintainer for previous ffmpeg(4) was orphaned, I can put my name in there if that matters, though I don't exactly see myself keeping up on ffmpeg.

~~This updates QT5 which looks like it is usually hosted by Johnny. Not sure if there's any reason to stay there or these sources are fine.~~ Using qt5.15.11 now, revbumps and some patches.

##### STILL FFMPEG4

These are a mix of emulators, games and/or older packages.

- attract (multiple patches in master)
- ~~audacity (https://github.com/audacity/audacity/issues/2305 and https://sourceforge.net/p/portmedia/wiki/portsmf/ is 'beta')~~ (updated to 3.x, compiles with ffmpeg6)
- ccextractor (master patches? no release)
- vice (3.8 compiles, needs makedepends libcurl-devel)
- kodi
- mlt (only dep left is flowblade - flowblade 2.12.0.2 with mlt7-python3 can 'render' videos with cpu and gpu)
- ~~synfig (mlt)~~ (work with mlt7, bump synfigstudio)
- tvheadend
- ssr
- ~~spek-alternative~~ (replace with spek-x)
- ppsspp
- olive
- moc
- mediastreamer (linphone links are dead, changed to github belladonne. their stuff never worked for me but there are updates if someone wants to give it a try)
- libextractor (1.13 compiles, remove exiv2 patch)
- idjc (0.9.8 compiles, remove python3.10 patch, needs makedepends libebur128-devel and libshout-idjc 2.4.6 with '-r1' for distfile)
- hedgewars
- ~~ffmpegthumbnailer~~ (patches for moviedecoder.xxx files)
- ~~ffmpegthumbs~~ (latest compiles)
- deadbeef
- ~~omxplayer~~ (package removed, deprecated in favor of vlc)
- qtav (fork has ffmpeg 5 patch - https://github.com/cmguo/QtAV)
- `vlc` (vlc4 will support ffmpeg5, there's a patch to build 3.x with ffmpeg5 but it will lack vaapi)
- `osg` (OpenSceneGraph plus `xine-lib`)


##### HAVE NOT BUILT YET

- ~~omxplayer (rpi only? ffmpeg4)~~ (removed)
- kodi (big, but ffmpeg4)


##### UPDATED (for ffmpeg6)

- ~~blender: update to 3.5.1~~ ~~will be revbump with~~ https://github.com/void-linux/void-packages/pull/43992
- unpaper: update to 7.0.0.
- guvcview: update to 2.0.8.
- ~~qt5: update to 5.15.8~~ updated by another PR to 5.15.11
- ~~qt5-webengine: update to 5.18.15~~ updated by another PR to 5.15.16 (some patching for ffmpeg build)
- ~~shiboken2: revbump for qt5.15.8 (patch)~~ updated by another PR to 5.15.10
- ~~python3-pyside2: update to 5.15.8 (patch)~~ updated by another PR to 5.15.10
- New package: spex-x replaces spek-alternative for ffmpeg-6.0


##### Requirements

- ~~[gstreamer 1.22.2](https://github.com/void-linux/void-packages/pull/42861)~~ - a few packages use ffmpeg-devel and require a revbump

- ~~[Intel Packages](https://github.com/void-linux/void-packages/pull/41132) [Intel Packages v2](https://github.com/void-linux/void-packages/pull/47330) - ffmpeg4 uses different libraries than 6 (libmfx / Intel-MediaSDK vs only oneVPL that Intel is moving to), both are included here~~. Using replacement oneVPL from OBS update.

- ~~[shotcut 23.05.14](https://github.com/void-linux/void-packages/pull/44260)~~

- https://github.com/void-linux/void-packages/pull/44781 will remove from this PR

A patch file from https://github.com/void-linux/void-packages/pull/43761.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ffmpeg6-split-43761.patch --]
[-- Type: text/x-diff, Size: 247399 bytes --]

From 8c2119a931c310f40609f6d8b70325d1499a0c1b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:16:56 -0400
Subject: [PATCH 001/113] ffmpeg: update to 6.0.1.

---
 common/shlibs                                 | 26 ++++---
 srcpkgs/ffmpeg/files/altivec.patch            | 60 ---------------
 .../patches/armv5tel-floating-point.patch     | 18 -----
 srcpkgs/ffmpeg/patches/binutils-2.41.patch    | 73 -------------------
 ...h-libavcodec-libsvtav1-ten_bit_format.diff | 40 ----------
 .../workaround-mesa-readeon-vaapi-bug.patch   | 28 -------
 srcpkgs/ffmpeg/template                       | 40 +++++-----
 7 files changed, 37 insertions(+), 248 deletions(-)
 delete mode 100644 srcpkgs/ffmpeg/files/altivec.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/binutils-2.41.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 delete mode 100644 srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch

diff --git a/common/shlibs b/common/shlibs
index 93fb4b2608729..7987d854066ab 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -389,15 +389,23 @@ libid3tag.so.0 libid3tag-0.15.1b_1
 libgif.so.7 giflib-5.1.0_1
 libImlib2.so.1 imlib2-1.4.2_1
 libmp3lame.so.0 lame-3.98.2_1
-libavdevice.so.58 libavdevice-4.0_1
-libavformat.so.58 libavformat-4.0_1
-libswscale.so.5 libswscale-4.0_1
-libswresample.so.3 libswresample-4.0_1
-libavresample.so.4 libavresample-4.0_1
-libpostproc.so.55 libpostproc-4.0_1
-libavcodec.so.58 libavcodec-4.0_1
-libavutil.so.56 libavutil-4.0_1
-libavfilter.so.7 libavfilter-4.0_1
+libavdevice.so.60 libavdevice-6.0_1
+libavformat.so.60 libavformat-6.0_1
+libswscale.so.7 libswscale-6.0_1
+libswresample.so.4 libswresample-6.0_1
+libpostproc.so.57 libpostproc-6.0_1
+libavcodec.so.60 libavcodec-6.0_1
+libavutil.so.58 libavutil-6.0_1
+libavfilter.so.9 libavfilter-6.0_1
+libavdevice.so.58 libavdevice4-4.0_1
+libavformat.so.58 libavformat4-4.0_1
+libswscale.so.5 libswscale4-4.0_1
+libswresample.so.3 libswresample4-4.0_1
+libavresample.so.4 libavresample4-4.0_1
+libpostproc.so.55 libpostproc4-4.0_1
+libavcodec.so.58 libavcodec4-4.0_1
+libavutil.so.56 libavutil4-4.0_1
+libavfilter.so.7 libavfilter4-4.0_1
 libSDL-1.2.so.0 SDL-1.2.14_1
 libSDL_image-1.2.so.0 SDL_image-1.2.10_1
 libx264.so.157 x264-20190507.2245_1
diff --git a/srcpkgs/ffmpeg/files/altivec.patch b/srcpkgs/ffmpeg/files/altivec.patch
deleted file mode 100644
index 9c57200463320..0000000000000
--- a/srcpkgs/ffmpeg/files/altivec.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-revert some altivec specific change on all ppc* except ppc64le*
-
-q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
-conditionally, for ppc* but not ppc64le* (the new code is valid for
-POWER8 VSX which LE targets as a baseline but not BE)"
-
-
-This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
----
- libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
- 1 file changed, 20 insertions(+), 4 deletions(-)
-
-diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
-index 536545293d..c1e2852adb 100644
---- a/libswscale/ppc/yuv2rgb_altivec.c
-+++ b/libswscale/ppc/yuv2rgb_altivec.c
-@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-     vector signed short R1, G1, B1;                                           \
-     vector unsigned char R, G, B;                                             \
-                                                                               \
-+    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
-+    vector unsigned char align_perm;                                          \
-+                                                                              \
-     vector signed short lCY       = c->CY;                                    \
-     vector signed short lOY       = c->OY;                                    \
-     vector signed short lCRV      = c->CRV;                                   \
-@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
-                                                                               \
-         for (j = 0; j < w / 16; j++) {                                        \
--            y0 = vec_xl(0, y1i);                                              \
-+            y1ivP = (const vector unsigned char *) y1i;                       \
-+            y2ivP = (const vector unsigned char *) y2i;                       \
-+            uivP  = (const vector unsigned char *) ui;                        \
-+            vivP  = (const vector unsigned char *) vi;                        \
-+                                                                              \
-+            align_perm = vec_lvsl(0, y1i);                                    \
-+            y0 = (vector unsigned char)                                       \
-+                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
-                                                                               \
--            y1 = vec_xl(0, y2i);                                              \
-+            align_perm = vec_lvsl(0, y2i);                                    \
-+            y1 = (vector unsigned char)                                       \
-+                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
-                                                                               \
--            u = (vector signed char) vec_xl(0, ui);                           \
-+            align_perm = vec_lvsl(0, ui);                                     \
-+            u = (vector signed char)                                          \
-+                    vec_perm(uivP[0], uivP[1], align_perm);                   \
-                                                                               \
--            v = (vector signed char) vec_xl(0, vi);                           \
-+            align_perm = vec_lvsl(0, vi);                                     \
-+            v = (vector signed char)                                          \
-+                    vec_perm(vivP[0], vivP[1], align_perm);                   \
-                                                                               \
-             u = (vector signed char)                                          \
-                     vec_sub(u,                                                \
--- 
-2.27.0
-
diff --git a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
deleted file mode 100644
index 9a55178c74f0f..0000000000000
--- a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
-+++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
-@@ -39,6 +39,15 @@
- #endif
- #include <fenv.h>
- 
-+#if (FE_ALL_EXCEPT == 0)
-+/* E.g. ARM soft float does not define these */
-+#define FE_INVALID    0
-+#define FE_DIVBYZERO  0
-+#define FE_OVERFLOW   0
-+#define FE_UNDERFLOW  0
-+#define FE_INEXACT    0
-+#endif
-+
- #if CONFIG_LIBFONTCONFIG
- #include <fontconfig/fontconfig.h>
- #endif
diff --git a/srcpkgs/ffmpeg/patches/binutils-2.41.patch b/srcpkgs/ffmpeg/patches/binutils-2.41.patch
deleted file mode 100644
index 53a596d0ee7d4..0000000000000
--- a/srcpkgs/ffmpeg/patches/binutils-2.41.patch
+++ /dev/null
@@ -1,73 +0,0 @@
-From effadce6c756247ea8bae32dc13bb3e6f464f0eb Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= <remi@remlab.net>
-Date: Sun, 16 Jul 2023 18:18:02 +0300
-Subject: [PATCH] avcodec/x86/mathops: clip constants used with shift
- instructions within inline assembly
-
-Fixes assembling with binutil as >= 2.41
-
-Signed-off-by: James Almer <jamrial@gmail.com>
----
- libavcodec/x86/mathops.h | 26 +++++++++++++++++++++++---
- 1 file changed, 23 insertions(+), 3 deletions(-)
-
-diff --git a/libavcodec/x86/mathops.h b/libavcodec/x86/mathops.h
-index 6298f5ed1983b..ca7e2dffc1076 100644
---- a/libavcodec/x86/mathops.h
-+++ b/libavcodec/x86/mathops.h
-@@ -35,12 +35,20 @@
- static av_always_inline av_const int MULL(int a, int b, unsigned shift)
- {
-     int rt, dummy;
-+    if (__builtin_constant_p(shift))
-     __asm__ (
-         "imull %3               \n\t"
-         "shrdl %4, %%edx, %%eax \n\t"
-         :"=a"(rt), "=d"(dummy)
--        :"a"(a), "rm"(b), "ci"((uint8_t)shift)
-+        :"a"(a), "rm"(b), "i"(shift & 0x1F)
-     );
-+    else
-+        __asm__ (
-+            "imull %3               \n\t"
-+            "shrdl %4, %%edx, %%eax \n\t"
-+            :"=a"(rt), "=d"(dummy)
-+            :"a"(a), "rm"(b), "c"((uint8_t)shift)
-+        );
-     return rt;
- }
- 
-@@ -113,19 +121,31 @@ __asm__ volatile(\
- // avoid +32 for shift optimization (gcc should do that ...)
- #define NEG_SSR32 NEG_SSR32
- static inline  int32_t NEG_SSR32( int32_t a, int8_t s){
-+    if (__builtin_constant_p(s))
-     __asm__ ("sarl %1, %0\n\t"
-          : "+r" (a)
--         : "ic" ((uint8_t)(-s))
-+         : "i" (-s & 0x1F)
-     );
-+    else
-+        __asm__ ("sarl %1, %0\n\t"
-+               : "+r" (a)
-+               : "c" ((uint8_t)(-s))
-+        );
-     return a;
- }
- 
- #define NEG_USR32 NEG_USR32
- static inline uint32_t NEG_USR32(uint32_t a, int8_t s){
-+    if (__builtin_constant_p(s))
-     __asm__ ("shrl %1, %0\n\t"
-          : "+r" (a)
--         : "ic" ((uint8_t)(-s))
-+         : "i" (-s & 0x1F)
-     );
-+    else
-+        __asm__ ("shrl %1, %0\n\t"
-+               : "+r" (a)
-+               : "c" ((uint8_t)(-s))
-+        );
-     return a;
- }
- 
diff --git a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
deleted file mode 100644
index aa948f7a8a2df..0000000000000
--- a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
+++ /dev/null
@@ -1,40 +0,0 @@
-#==================================================================================================
-# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
-# From: Christopher Degawa <christopher.degawa@intel.com>
-# Date: Thu, 20 Oct 2022 22:55:27 -0500
-# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
-#
-# compressed_ten_bit_format has been deprecated upstream and has no effect
-# and can be removed. Plus, technically it was never used in the first place
-# since it would require the app (ffmpeg) to set it and do additional
-# processing of the input frames.
-#
-# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
-#
-# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
-#==================================================================================================
---- a/libavcodec/libsvtav1.c
-+++ b/libavcodec/libsvtav1.c
-@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
- 
- static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
- {
--    const int    pack_mode_10bit =
--        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
--    const size_t luma_size_8bit  =
--        config->source_width * config->source_height * (1 << pack_mode_10bit);
--    const size_t luma_size_10bit =
--        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
-+    const size_t luma_size = config->source_width * config->source_height *
-+        (config->encoder_bit_depth > 8 ? 2 : 1);
- 
-     EbSvtIOFormat *in_data;
- 
--    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
-+    svt_enc->raw_size = luma_size * 3 / 2;
- 
-     // allocate buffer for in and out
-     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
--- 
-GitLab
-
diff --git a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
deleted file mode 100644
index 00e3f68a415b8..0000000000000
--- a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
-From: Rainer Hochecker <fernetmenta@online.de>
-Date: Sat, 26 Jan 2019 19:48:35 +0100
-Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
-
-This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
-It was hit frequently when watching h264 channels received via DVB-X.
-Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
----
- libavcodec/vaapi_h264.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
-index 5854587a255..f12fdc457a4 100644
---- a/libavcodec/vaapi_h264.c
-+++ b/libavcodec/vaapi_h264.c
-@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
-     H264SliceContext *sl = &h->slice_ctx[0];
-     int ret;
- 
-+    if (pic->nb_slices == 0) {
-+        ret = AVERROR_INVALIDDATA;
-+        goto finish;
-+    }
-+
-     ret = ff_vaapi_decode_issue(avctx, pic);
-     if (ret < 0)
-         goto finish;
diff --git a/srcpkgs/ffmpeg/template b/srcpkgs/ffmpeg/template
index 1ebb436135938..f1e4712c41d08 100644
--- a/srcpkgs/ffmpeg/template
+++ b/srcpkgs/ffmpeg/template
@@ -1,15 +1,15 @@
 # Template file for 'ffmpeg'
 # audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
 pkgname=ffmpeg
-version=4.4.4
-revision=6
+version=6.0.1
+revision=1
 short_desc="Decoding, encoding and streaming software"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="https://www.ffmpeg.org"
 changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
 distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
-checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+checksum=9b16b8731d78e596b4be0d720428ca42df642bb2d78342881ff7f5bc29fc9623
 
 hostmakedepends="pkg-config perl"
 makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
@@ -26,12 +26,13 @@ makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-deve
  $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
  $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
  $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
- $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers Vulkan-Tools Vulkan-ValidationLayers')
+ $(vopt_if onevpl 'oneVPL oneVPL-devel')
  $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
 depends="ffplay>=${version}_${revision}"
 
 build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
- dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec onevpl"
 build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
 desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
 desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
@@ -39,9 +40,13 @@ desc_option_sofa="Enable support for AES SOFA"
 desc_option_webp="Enable support for WebP"
 
 case "$XBPS_TARGET_MACHINE" in
-	i686*|x86_64*)
-		hostmakedepends+=" nasm"
+	i686*)
 		build_options_default+=" vaapi vdpau nvenc nvdec"
+		hostmakedepends+=" nasm"
+		;;
+	x86_64*)
+		hostmakedepends+=" nasm"
+		build_options_default+=" vaapi vdpau nvenc nvdec onevpl"
 		;;
 	ppc64*) build_options_default+=" vaapi vdpau";;
 	mips*) CFLAGS="-mnan=legacy";;
@@ -65,8 +70,6 @@ post_patch() {
 		ppc64le*) ;;
 		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
 	esac
-
-	vsed -i libavfilter/vf_libvmaf.c -e 's!/usr/local/share/model/\(vmaf_v0.6.1\).pkl!/usr/share/vmaf/\1.json!'
 }
 
 do_configure() {
@@ -115,18 +118,19 @@ do_configure() {
 		$(vopt_enable x265 libx265) \
 		$(vopt_enable v4l2 libv4l2) \
 		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
-		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		--enable-libbs2b --enable-libvidstab \
 		$(vopt_enable dav1d libdav1d) \
 		$(vopt_enable zimg libzimg) \
 		$(vopt_enable webp libwebp) \
 		$(vopt_enable sofa libmysofa) \
 		$(vopt_enable vulkan) \
+		$(vopt_enable onevpl libvpl) \
 		$(vopt_enable drm libdrm) \
 		$(vopt_enable svtav1 libsvtav1) \
 		$(vopt_enable srt libsrt) \
 		$(vopt_enable rist librist) \
-		$(vopt_if nvenc '--enable-nvenc') \
-		$(vopt_if nvdec '--enable-nvdec')
+		$(vopt_enable nvenc nvenc) \
+		$(vopt_enable nvdec nvdec)
 }
 
 do_build() {
@@ -153,10 +157,8 @@ libavdevice_package() {
 }
 
 libavresample_package() {
-	short_desc="FFmpeg audio resampling library"
-	pkg_install() {
-		vmove "usr/lib/libavresample.so.*"
-	}
+	short_desc="Package deprecated, removal needed"
+	build_style=meta
 }
 
 libavformat_package() {
@@ -210,15 +212,13 @@ ffmpeg-devel_package() {
 		libavfilter>=${version}_${revision}
 		libpostproc>=${version}_${revision}
 		libswscale>=${version}_${revision}
-		libswresample>=${version}_${revision}
-		libavresample>=${version}_${revision}"
+		libswresample>=${version}_${revision}"
 	short_desc+=" - development files"
-
+	conflicts="ffmpeg4-devel"
 	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
 		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
 		nostrip_files="/usr/lib/libavfilter.a"
 	fi
-
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig

From 7bda7569067b3dfcd2c4fe0c65909cde6ac2630c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:14 -0400
Subject: [PATCH 002/113] openshot: revbump for ffmpeg6

---
 srcpkgs/openshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openshot/template b/srcpkgs/openshot/template
index 8f47851eef354..affb652a9d500 100644
--- a/srcpkgs/openshot/template
+++ b/srcpkgs/openshot/template
@@ -1,7 +1,7 @@
 # Template file for 'openshot'
 pkgname=openshot
 version=3.0.0
-revision=2
+revision=3
 build_style=python3-module
 hostmakedepends="python3 python3-setuptools"
 makedepends="ffmpeg-devel python3-PyQt5"

From 3ad4887c3cc6d7c4bc3f66585486668650d9d92f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:36 -0400
Subject: [PATCH 003/113] sumo: revbump for ffmpeg6

---
 srcpkgs/sumo/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/sumo/template b/srcpkgs/sumo/template
index a3fe134aa5acc..a730afa9fafa9 100644
--- a/srcpkgs/sumo/template
+++ b/srcpkgs/sumo/template
@@ -1,7 +1,7 @@
 # Template file for 'sumo'
 pkgname=sumo
 version=1.12.0
-revision=6
+revision=7
 build_style=cmake
 hostmakedepends="libgdal-tools pkg-config swig python3-setuptools"
 makedepends="python3-devel ffmpeg-devel fox-devel gl2ps-devel libgdal-devel

From 5ee89c7ed61e11fba16822028f7326a1e3edd08d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:56:22 -0400
Subject: [PATCH 004/113] New package: ffmpeg4-4.4.4.

---
 srcpkgs/ffmpeg4-devel                         |   1 +
 srcpkgs/ffmpeg4/files/altivec.patch           |  60 +++++
 .../patches/armv5tel-floating-point.patch     |  18 ++
 srcpkgs/ffmpeg4/patches/binutils-2.41.patch   |  73 ++++++
 ...h-libavcodec-libsvtav1-ten_bit_format.diff |  40 +++
 .../workaround-mesa-readeon-vaapi-bug.patch   |  28 +++
 srcpkgs/ffmpeg4/template                      | 234 ++++++++++++++++++
 srcpkgs/libavcodec4                           |   1 +
 srcpkgs/libavdevice4                          |   1 +
 srcpkgs/libavfilter4                          |   1 +
 srcpkgs/libavformat4                          |   1 +
 srcpkgs/libavresample4                        |   1 +
 srcpkgs/libavutil4                            |   1 +
 srcpkgs/libpostproc4                          |   1 +
 srcpkgs/libswresample4                        |   1 +
 srcpkgs/libswscale4                           |   1 +
 16 files changed, 463 insertions(+)
 create mode 120000 srcpkgs/ffmpeg4-devel
 create mode 100644 srcpkgs/ffmpeg4/files/altivec.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/binutils-2.41.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 create mode 100644 srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
 create mode 100644 srcpkgs/ffmpeg4/template
 create mode 120000 srcpkgs/libavcodec4
 create mode 120000 srcpkgs/libavdevice4
 create mode 120000 srcpkgs/libavfilter4
 create mode 120000 srcpkgs/libavformat4
 create mode 120000 srcpkgs/libavresample4
 create mode 120000 srcpkgs/libavutil4
 create mode 120000 srcpkgs/libpostproc4
 create mode 120000 srcpkgs/libswresample4
 create mode 120000 srcpkgs/libswscale4

diff --git a/srcpkgs/ffmpeg4-devel b/srcpkgs/ffmpeg4-devel
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/ffmpeg4-devel
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/ffmpeg4/files/altivec.patch b/srcpkgs/ffmpeg4/files/altivec.patch
new file mode 100644
index 0000000000000..9c57200463320
--- /dev/null
+++ b/srcpkgs/ffmpeg4/files/altivec.patch
@@ -0,0 +1,60 @@
+revert some altivec specific change on all ppc* except ppc64le*
+
+q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
+conditionally, for ppc* but not ppc64le* (the new code is valid for
+POWER8 VSX which LE targets as a baseline but not BE)"
+
+
+This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
+---
+ libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
+ 1 file changed, 20 insertions(+), 4 deletions(-)
+
+diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
+index 536545293d..c1e2852adb 100644
+--- a/libswscale/ppc/yuv2rgb_altivec.c
++++ b/libswscale/ppc/yuv2rgb_altivec.c
+@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+     vector signed short R1, G1, B1;                                           \
+     vector unsigned char R, G, B;                                             \
+                                                                               \
++    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
++    vector unsigned char align_perm;                                          \
++                                                                              \
+     vector signed short lCY       = c->CY;                                    \
+     vector signed short lOY       = c->OY;                                    \
+     vector signed short lCRV      = c->CRV;                                   \
+@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
+                                                                               \
+         for (j = 0; j < w / 16; j++) {                                        \
+-            y0 = vec_xl(0, y1i);                                              \
++            y1ivP = (const vector unsigned char *) y1i;                       \
++            y2ivP = (const vector unsigned char *) y2i;                       \
++            uivP  = (const vector unsigned char *) ui;                        \
++            vivP  = (const vector unsigned char *) vi;                        \
++                                                                              \
++            align_perm = vec_lvsl(0, y1i);                                    \
++            y0 = (vector unsigned char)                                       \
++                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
+                                                                               \
+-            y1 = vec_xl(0, y2i);                                              \
++            align_perm = vec_lvsl(0, y2i);                                    \
++            y1 = (vector unsigned char)                                       \
++                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
+                                                                               \
+-            u = (vector signed char) vec_xl(0, ui);                           \
++            align_perm = vec_lvsl(0, ui);                                     \
++            u = (vector signed char)                                          \
++                    vec_perm(uivP[0], uivP[1], align_perm);                   \
+                                                                               \
+-            v = (vector signed char) vec_xl(0, vi);                           \
++            align_perm = vec_lvsl(0, vi);                                     \
++            v = (vector signed char)                                          \
++                    vec_perm(vivP[0], vivP[1], align_perm);                   \
+                                                                               \
+             u = (vector signed char)                                          \
+                     vec_sub(u,                                                \
+-- 
+2.27.0
+
diff --git a/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
new file mode 100644
index 0000000000000..9a55178c74f0f
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
@@ -0,0 +1,18 @@
+--- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
++++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
+@@ -39,6 +39,15 @@
+ #endif
+ #include <fenv.h>
+ 
++#if (FE_ALL_EXCEPT == 0)
++/* E.g. ARM soft float does not define these */
++#define FE_INVALID    0
++#define FE_DIVBYZERO  0
++#define FE_OVERFLOW   0
++#define FE_UNDERFLOW  0
++#define FE_INEXACT    0
++#endif
++
+ #if CONFIG_LIBFONTCONFIG
+ #include <fontconfig/fontconfig.h>
+ #endif
diff --git a/srcpkgs/ffmpeg4/patches/binutils-2.41.patch b/srcpkgs/ffmpeg4/patches/binutils-2.41.patch
new file mode 100644
index 0000000000000..53a596d0ee7d4
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/binutils-2.41.patch
@@ -0,0 +1,73 @@
+From effadce6c756247ea8bae32dc13bb3e6f464f0eb Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= <remi@remlab.net>
+Date: Sun, 16 Jul 2023 18:18:02 +0300
+Subject: [PATCH] avcodec/x86/mathops: clip constants used with shift
+ instructions within inline assembly
+
+Fixes assembling with binutil as >= 2.41
+
+Signed-off-by: James Almer <jamrial@gmail.com>
+---
+ libavcodec/x86/mathops.h | 26 +++++++++++++++++++++++---
+ 1 file changed, 23 insertions(+), 3 deletions(-)
+
+diff --git a/libavcodec/x86/mathops.h b/libavcodec/x86/mathops.h
+index 6298f5ed1983b..ca7e2dffc1076 100644
+--- a/libavcodec/x86/mathops.h
++++ b/libavcodec/x86/mathops.h
+@@ -35,12 +35,20 @@
+ static av_always_inline av_const int MULL(int a, int b, unsigned shift)
+ {
+     int rt, dummy;
++    if (__builtin_constant_p(shift))
+     __asm__ (
+         "imull %3               \n\t"
+         "shrdl %4, %%edx, %%eax \n\t"
+         :"=a"(rt), "=d"(dummy)
+-        :"a"(a), "rm"(b), "ci"((uint8_t)shift)
++        :"a"(a), "rm"(b), "i"(shift & 0x1F)
+     );
++    else
++        __asm__ (
++            "imull %3               \n\t"
++            "shrdl %4, %%edx, %%eax \n\t"
++            :"=a"(rt), "=d"(dummy)
++            :"a"(a), "rm"(b), "c"((uint8_t)shift)
++        );
+     return rt;
+ }
+ 
+@@ -113,19 +121,31 @@ __asm__ volatile(\
+ // avoid +32 for shift optimization (gcc should do that ...)
+ #define NEG_SSR32 NEG_SSR32
+ static inline  int32_t NEG_SSR32( int32_t a, int8_t s){
++    if (__builtin_constant_p(s))
+     __asm__ ("sarl %1, %0\n\t"
+          : "+r" (a)
+-         : "ic" ((uint8_t)(-s))
++         : "i" (-s & 0x1F)
+     );
++    else
++        __asm__ ("sarl %1, %0\n\t"
++               : "+r" (a)
++               : "c" ((uint8_t)(-s))
++        );
+     return a;
+ }
+ 
+ #define NEG_USR32 NEG_USR32
+ static inline uint32_t NEG_USR32(uint32_t a, int8_t s){
++    if (__builtin_constant_p(s))
+     __asm__ ("shrl %1, %0\n\t"
+          : "+r" (a)
+-         : "ic" ((uint8_t)(-s))
++         : "i" (-s & 0x1F)
+     );
++    else
++        __asm__ ("shrl %1, %0\n\t"
++               : "+r" (a)
++               : "c" ((uint8_t)(-s))
++        );
+     return a;
+ }
+ 
diff --git a/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
new file mode 100644
index 0000000000000..aa948f7a8a2df
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
@@ -0,0 +1,40 @@
+#==================================================================================================
+# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
+# From: Christopher Degawa <christopher.degawa@intel.com>
+# Date: Thu, 20 Oct 2022 22:55:27 -0500
+# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
+#
+# compressed_ten_bit_format has been deprecated upstream and has no effect
+# and can be removed. Plus, technically it was never used in the first place
+# since it would require the app (ffmpeg) to set it and do additional
+# processing of the input frames.
+#
+# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
+#
+# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
+#==================================================================================================
+--- a/libavcodec/libsvtav1.c
++++ b/libavcodec/libsvtav1.c
+@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
+ 
+ static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
+ {
+-    const int    pack_mode_10bit =
+-        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
+-    const size_t luma_size_8bit  =
+-        config->source_width * config->source_height * (1 << pack_mode_10bit);
+-    const size_t luma_size_10bit =
+-        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
++    const size_t luma_size = config->source_width * config->source_height *
++        (config->encoder_bit_depth > 8 ? 2 : 1);
+ 
+     EbSvtIOFormat *in_data;
+ 
+-    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
++    svt_enc->raw_size = luma_size * 3 / 2;
+ 
+     // allocate buffer for in and out
+     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
+-- 
+GitLab
+
diff --git a/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
new file mode 100644
index 0000000000000..00e3f68a415b8
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
@@ -0,0 +1,28 @@
+From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
+From: Rainer Hochecker <fernetmenta@online.de>
+Date: Sat, 26 Jan 2019 19:48:35 +0100
+Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
+
+This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
+It was hit frequently when watching h264 channels received via DVB-X.
+Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
+---
+ libavcodec/vaapi_h264.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
+index 5854587a255..f12fdc457a4 100644
+--- a/libavcodec/vaapi_h264.c
++++ b/libavcodec/vaapi_h264.c
+@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
+     H264SliceContext *sl = &h->slice_ctx[0];
+     int ret;
+ 
++    if (pic->nb_slices == 0) {
++        ret = AVERROR_INVALIDDATA;
++        goto finish;
++    }
++
+     ret = ff_vaapi_decode_issue(avctx, pic);
+     if (ret < 0)
+         goto finish;
diff --git a/srcpkgs/ffmpeg4/template b/srcpkgs/ffmpeg4/template
new file mode 100644
index 0000000000000..9ba14bdb8ddf3
--- /dev/null
+++ b/srcpkgs/ffmpeg4/template
@@ -0,0 +1,234 @@
+# Template file for 'ffmpeg4'
+# audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
+pkgname=ffmpeg4
+version=4.4.4
+revision=1
+short_desc="Decoding, encoding and streaming software - ffmpeg4 libraries only"
+maintainer="Orphaned <orphan@voidlinux.org>"
+license="GPL-3.0-or-later"
+homepage="https://www.ffmpeg.org"
+changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
+distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
+checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+
+hostmakedepends="pkg-config perl"
+makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
+ libXext-devel libXvMC-devel libxcb-devel lame-devel libtheora-devel
+ libvorbis-devel x264-devel xvidcore-devel jack-devel SDL2-devel
+ libcdio-paranoia-devel librtmp-devel libmodplug-devel gnutls-devel
+ speex-devel celt-devel harfbuzz-devel libass-devel opus-devel ocl-icd-devel
+ libbs2b-devel libvidstab-devel vmaf-devel $(vopt_if pulseaudio pulseaudio-devel)
+ $(vopt_if vaapi libva-devel) $(vopt_if vdpau libvdpau-devel)
+ $(vopt_if x265 x265-devel) $(vopt_if v4l2 v4l-utils-devel)
+ $(vopt_if fdk_aac fdk-aac-devel) $(vopt_if vpx libvpx-devel)
+ $(vopt_if aom libaom-devel) $(vopt_if sndio sndio-devel)
+ $(vopt_if dav1d libdav1d-devel) $(vopt_if zimg zimg-devel)
+ $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
+ $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
+ $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
+
+build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
+
+desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
+desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
+desc_option_sofa="Enable support for AES SOFA"
+desc_option_webp="Enable support for WebP"
+
+case "$XBPS_TARGET_MACHINE" in
+	i686*|x86_64*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau nvenc nvdec"
+			;;
+	ppc64*) build_options_default+=" vaapi vdpau";;
+	mips*) CFLAGS="-mnan=legacy";;
+esac
+
+if [ "$XBPS_TARGET_WORDSIZE" != "32" ]; then
+	build_options_default+=" svtav1"
+fi
+
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+fi
+
+_apply_patch() {
+	local args="$1" pname="$(basename $2)"
+
+	if [ ! -f ".${pname}_done" ]; then
+		patch -N $args -i $2
+		touch .${pname}_done
+	fi
+}
+
+post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64le*) ;;
+		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
+	esac
+
+	vsed -i libavfilter/vf_libvmaf.c -e 's!/usr/local/share/model/\(vmaf_v0.6.1\).pkl!/usr/share/vmaf/\1.json!'
+}
+
+do_configure() {
+	# Fix gcc on x86_64-musl only
+	if [ "$XBPS_TARGET_MACHINE" = "x86_64-musl" ]; then
+		vsed -i configure -e "s;_cflags_speed='-O3';_cflags_speed='-O2';"
+	fi
+
+	if [ "$CROSS_BUILD" ]; then
+		case "$XBPS_TARGET_MACHINE" in
+			arm*) _arch="arm";;
+			aarch64*) _arch="aarch64";;
+			mips*) _arch="mips";;
+			ppc64*) _arch="ppc64";;
+			ppc*) _arch="ppc";;
+			*) _arch="${XBPS_TARGET_MACHINE%%-musl}";;
+		esac
+
+		_args+=" --enable-cross-compile
+			--sysroot=$XBPS_CROSS_BASE
+			--cross-prefix=${XBPS_CROSS_TRIPLET}-
+			--target-os=linux --arch=${_arch}"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc|ppc-musl) _args+=" --disable-altivec";;
+	esac
+
+	if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+		_args+=" --extra-libs=-latomic"
+	fi
+
+	./configure --prefix=/usr --disable-debug --enable-gpl --enable-gnutls \
+		--disable-stripping \
+		--enable-libcdio --enable-version3 --enable-runtime-cpudetect \
+		--enable-libmp3lame --enable-libvorbis --enable-libxvid \
+		--enable-libx264 $(vopt_enable vpx libvpx) --enable-libtheora \
+		--enable-shared --enable-static --enable-libxcb \
+		$(vopt_enable pulseaudio libpulse) --enable-libfreetype --enable-libmodplug \
+		--enable-libspeex --enable-libcelt --enable-libass \
+		--enable-libopus --enable-librtmp --enable-libjack \
+		$(vopt_if fdk_aac '--enable-nonfree --enable-libfdk-aac') \
+		--disable-libopencore_amrnb --disable-libopencore_amrwb \
+		--disable-libopenjpeg \
+		--enable-postproc --enable-opencl ${_args} --enable-libvmaf ${_args} \
+		$(vopt_enable x265 libx265) \
+		$(vopt_enable v4l2 libv4l2) \
+		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
+		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		$(vopt_enable dav1d libdav1d) \
+		$(vopt_enable zimg libzimg) \
+		$(vopt_enable webp libwebp) \
+		$(vopt_enable sofa libmysofa) \
+		$(vopt_enable vulkan) \
+		$(vopt_enable drm libdrm) \
+		$(vopt_enable svtav1 libsvtav1) \
+		$(vopt_enable srt libsrt) \
+		$(vopt_enable rist librist) \
+		$(vopt_if nvenc '--enable-nvenc') \
+		$(vopt_if nvdec '--enable-nvdec')
+}
+
+do_build() {
+	make ${makejobs}
+	make doc/ff{mpeg,play}.1
+}
+
+do_install() {
+	make DESTDIR=${DESTDIR} install install-man
+	rm -rf ${DESTDIR}/usr/bin
+}
+
+libavcodec4_package() {
+	short_desc="FFmpeg codec library"
+	pkg_install() {
+		vmove "usr/lib/libavcodec.so.*"
+	}
+}
+
+libavdevice4_package() {
+	short_desc="FFmpeg device handling library"
+	pkg_install() {
+		vmove "usr/lib/libavdevice.so.*"
+	}
+}
+
+libavresample4_package() {
+	short_desc="FFmpeg audio resampling library"
+	pkg_install() {
+		vmove "usr/lib/libavresample.so.*"
+	}
+}
+
+libavformat4_package() {
+	short_desc="FFmpeg file format library"
+	pkg_install() {
+		vmove "usr/lib/libavformat.so.*"
+	}
+}
+
+libavutil4_package() {
+	short_desc="FFmpeg utility library"
+	pkg_install() {
+		vmove "usr/lib/libavutil.so.*"
+	}
+}
+
+libavfilter4_package() {
+	short_desc="FFmpeg audio/video filter library"
+	pkg_install() {
+		vmove "usr/lib/libavfilter.so.*"
+	}
+}
+
+libpostproc4_package() {
+	short_desc="FFmpeg video postprocessing library"
+	pkg_install() {
+		vmove "usr/lib/libpostproc.so.*"
+	}
+}
+
+libswscale4_package() {
+	short_desc="FFmpeg video scaling library"
+	pkg_install() {
+		vmove "usr/lib/libswscale.so.*"
+	}
+}
+
+libswresample4_package() {
+	short_desc="FFmpeg video resampling library"
+	pkg_install() {
+		vmove "usr/lib/libswresample.so.*"
+	}
+}
+
+ffmpeg4-devel_package() {
+	depends="
+		libavcodec4>=${version}_${revision}
+		libavdevice4>=${version}_${revision}
+		libavformat4>=${version}_${revision}
+		libavutil4>=${version}_${revision}
+		libavfilter4>=${version}_${revision}
+		libpostproc4>=${version}_${revision}
+		libswscale4>=${version}_${revision}
+		libswresample4>=${version}_${revision}
+		libavresample4>=${version}_${revision}"
+	short_desc+=" - development files"
+	conflicts="ffmpeg-devel"
+	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
+		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
+		nostrip_files="/usr/lib/libavfilter.a"
+	fi
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.a"
+		vmove "usr/lib/*.so"
+		vmove usr/share/ffmpeg/examples
+		vmove usr/share/man/man3
+	}
+}
diff --git a/srcpkgs/libavcodec4 b/srcpkgs/libavcodec4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavcodec4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavdevice4 b/srcpkgs/libavdevice4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavdevice4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavfilter4 b/srcpkgs/libavfilter4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavfilter4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavformat4 b/srcpkgs/libavformat4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavformat4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavresample4 b/srcpkgs/libavresample4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavutil4 b/srcpkgs/libavutil4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavutil4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libpostproc4 b/srcpkgs/libpostproc4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libpostproc4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswresample4 b/srcpkgs/libswresample4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libswresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswscale4 b/srcpkgs/libswscale4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libswscale4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file

From 7cb70e99dc02bb38acdc67c2ff897303f269b05e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:04 -0400
Subject: [PATCH 005/113] opencv: update to 4.7.0.

---
 common/shlibs           | 104 ++++++++++++++++++++--------------------
 srcpkgs/opencv/template |   8 ++--
 2 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index 7987d854066ab..cb85f934e8a04 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2074,58 +2074,58 @@ libcapstone.so.5 capstone-5.0.1_1
 libhavege.so.2 libhaveged-1.9.11_1
 libnih.so.1 libnih-1.0.3_1
 libnih-dbus.so.1 libnih-1.0.3_1
-libopencv_quality.so.406 libopencv-4.6.0_1
-libopencv_reg.so.406 libopencv-4.6.0_1
-libopencv_surface_matching.so.406 libopencv-4.6.0_1
-libopencv_xphoto.so.406 libopencv-4.6.0_1
-libopencv_freetype.so.406 libopencv-4.6.0_1
-libopencv_fuzzy.so.406 libopencv-4.6.0_1
-libopencv_hfs.so.406 libopencv-4.6.0_1
-libopencv_img_hash.so.406 libopencv-4.6.0_1
-libopencv_line_descriptor.so.406 libopencv-4.6.0_1
-libopencv_saliency.so.406 libopencv-4.6.0_1
-libopencv_structured_light.so.406 libopencv-4.6.0_1
-libopencv_aruco.so.406 libopencv-4.6.0_1
-libopencv_bgsegm.so.406 libopencv-4.6.0_1
-libopencv_bioinspired.so.406 libopencv-4.6.0_1
-libopencv_ccalib.so.406 libopencv-4.6.0_1
-libopencv_face.so.406 libopencv-4.6.0_1
-libopencv_tracking.so.406 libopencv-4.6.0_1
-libopencv_xfeatures2d.so.406 libopencv-4.6.0_1
-libopencv_optflow.so.406 libopencv-4.6.0_1
-libopencv_ximgproc.so.406 libopencv-4.6.0_1
-libopencv_plot.so.406 libopencv-4.6.0_1
-libopencv_text.so.406 libopencv-4.6.0_1
-libopencv_ml.so.406 libopencv-4.6.0_1
-libopencv_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn.so.406 libopencv-4.6.0_1
-libopencv_shape.so.406 libopencv-4.6.0_1
-libopencv_stitching.so.406 libopencv-4.6.0_1
-libopencv_photo.so.406 libopencv-4.6.0_1
-libopencv_video.so.406 libopencv-4.6.0_1
-libopencv_calib3d.so.406 libopencv-4.6.0_1
-libopencv_features2d.so.406 libopencv-4.6.0_1
-libopencv_flann.so.406 libopencv-4.6.0_1
-libopencv_highgui.so.406 libopencv-4.6.0_1
-libopencv_videoio.so.406 libopencv-4.6.0_1
-libopencv_imgcodecs.so.406 libopencv-4.6.0_1
-libopencv_imgproc.so.406 libopencv-4.6.0_1
-libopencv_core.so.406 libopencv-4.6.0_1
-libopencv_superres.so.406 libopencv-4.6.0_1
-libopencv_videostab.so.406 libopencv-4.6.0_1
-libopencv_gapi.so.406 libopencv-4.6.0_1
-libopencv_xobjdetect.so.406 libopencv-4.6.0_1
-libopencv_datasets.so.406 libopencv-4.6.0_1
-libopencv_dnn_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn_superres.so.406 libopencv-4.6.0_1
-libopencv_dpm.so.406 libopencv-4.6.0_1
-libopencv_phase_unwrapping.so.406 libopencv-4.6.0_1
-libopencv_stereo.so.406 libopencv-4.6.0_1
-libopencv_rapid.so.406 libopencv-4.6.0_1
-libopencv_intensity_transform.so.406 libopencv-4.6.0_1
-libopencv_alphamat.so.406 libopencv-4.6.0_1
-libopencv_barcode.so.406 libopencv-4.6.0_1
-libopencv_mcc.so.406 libopencv-4.6.0_1
+libopencv_quality.so.407 libopencv-4.7.0_1
+libopencv_reg.so.407 libopencv-4.7.0_1
+libopencv_surface_matching.so.407 libopencv-4.7.0_1
+libopencv_xphoto.so.407 libopencv-4.7.0_1
+libopencv_freetype.so.407 libopencv-4.7.0_1
+libopencv_fuzzy.so.407 libopencv-4.7.0_1
+libopencv_hfs.so.407 libopencv-4.7.0_1
+libopencv_img_hash.so.407 libopencv-4.7.0_1
+libopencv_line_descriptor.so.407 libopencv-4.7.0_1
+libopencv_saliency.so.407 libopencv-4.7.0_1
+libopencv_structured_light.so.407 libopencv-4.7.0_1
+libopencv_aruco.so.407 libopencv-4.7.0_1
+libopencv_bgsegm.so.407 libopencv-4.7.0_1
+libopencv_bioinspired.so.407 libopencv-4.7.0_1
+libopencv_ccalib.so.407 libopencv-4.7.0_1
+libopencv_face.so.407 libopencv-4.7.0_1
+libopencv_tracking.so.407 libopencv-4.7.0_1
+libopencv_xfeatures2d.so.407 libopencv-4.7.0_1
+libopencv_optflow.so.407 libopencv-4.7.0_1
+libopencv_ximgproc.so.407 libopencv-4.7.0_1
+libopencv_plot.so.407 libopencv-4.7.0_1
+libopencv_text.so.407 libopencv-4.7.0_1
+libopencv_ml.so.407 libopencv-4.7.0_1
+libopencv_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn.so.407 libopencv-4.7.0_1
+libopencv_shape.so.407 libopencv-4.7.0_1
+libopencv_stitching.so.407 libopencv-4.7.0_1
+libopencv_photo.so.407 libopencv-4.7.0_1
+libopencv_video.so.407 libopencv-4.7.0_1
+libopencv_calib3d.so.407 libopencv-4.7.0_1
+libopencv_features2d.so.407 libopencv-4.7.0_1
+libopencv_flann.so.407 libopencv-4.7.0_1
+libopencv_highgui.so.407 libopencv-4.7.0_1
+libopencv_videoio.so.407 libopencv-4.7.0_1
+libopencv_imgcodecs.so.407 libopencv-4.7.0_1
+libopencv_imgproc.so.407 libopencv-4.7.0_1
+libopencv_core.so.407 libopencv-4.7.0_1
+libopencv_superres.so.407 libopencv-4.7.0_1
+libopencv_videostab.so.407 libopencv-4.7.0_1
+libopencv_gapi.so.407 libopencv-4.7.0_1
+libopencv_xobjdetect.so.407 libopencv-4.7.0_1
+libopencv_datasets.so.407 libopencv-4.7.0_1
+libopencv_dnn_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn_superres.so.407 libopencv-4.7.0_1
+libopencv_dpm.so.407 libopencv-4.7.0_1
+libopencv_phase_unwrapping.so.407 libopencv-4.7.0_1
+libopencv_stereo.so.407 libopencv-4.7.0_1
+libopencv_rapid.so.407 libopencv-4.7.0_1
+libopencv_intensity_transform.so.407 libopencv-4.7.0_1
+libopencv_alphamat.so.407 libopencv-4.7.0_1
+libopencv_barcode.so.407 libopencv-4.7.0_1
+libopencv_mcc.so.407 libopencv-4.7.0_1
 libuniconf.so.4.6 wvstreams-4.6.1_20
 libwvbase.so.4.6 wvstreams-4.6.1_20
 libwvutils.so.4.6 wvstreams-4.6.1_20
diff --git a/srcpkgs/opencv/template b/srcpkgs/opencv/template
index aea4bfc3a265c..ce94de9424d18 100644
--- a/srcpkgs/opencv/template
+++ b/srcpkgs/opencv/template
@@ -1,7 +1,7 @@
 # Template file for 'opencv'
 pkgname=opencv
-version=4.6.0
-revision=6
+version=4.7.0
+revision=1
 create_wrksrc=yes
 build_wrksrc=${pkgname}-${version}
 build_style=cmake
@@ -24,8 +24,8 @@ homepage="https://opencv.org"
 changelog="https://github.com/opencv/opencv/wiki/ChangeLog"
 distfiles="https://github.com/opencv/opencv/archive/${version}.tar.gz
  https://github.com/opencv/opencv_contrib/archive/${version}.tar.gz>contrib.tar.gz"
-checksum="1ec1cba65f9f20fe5a41fda1586e01c70ea0c9a6d7b67c9e13edf0cfe2239277
- 1777d5fd2b59029cf537e5fd6f8aa68d707075822f90bde683fcde086f85f7a7"
+checksum="8df0079cdbe179748a18d44731af62a245a45ebf5085223dc03133954c662973
+ 42df840cf9055e59d0e22c249cfb19f04743e1bdad113d31b1573d3934d62584"
 patch_args="-Np1 -d ${build_wrksrc}"
 # tests hang indenfinitely, even with test data included
 make_check=no

From c2367e7667bd76880a35d824003bb9c99f29776b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 006/113] actiona: revbump for opencv-4.7.0

---
 srcpkgs/actiona/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/actiona/template b/srcpkgs/actiona/template
index cf5f0b7a2ae61..0d899311e6df7 100644
--- a/srcpkgs/actiona/template
+++ b/srcpkgs/actiona/template
@@ -1,7 +1,7 @@
 # Template file for 'actiona'
 pkgname=actiona
 version=3.10.1
-revision=2
+revision=3
 build_style=qmake
 configure_args="PKGCONFIG_OPENCV=opencv4"
 hostmakedepends="pkg-config qt5-plugin-mysql qt5-qmake qt5-host-tools"

From 9d41c1404fc4324eb04c239c1d1fef6662381d16 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 007/113] retroshare: revbump for opencv-4.7.0

---
 srcpkgs/retroshare/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroshare/template b/srcpkgs/retroshare/template
index bb17569277a7f..49e2c1cbe8a53 100644
--- a/srcpkgs/retroshare/template
+++ b/srcpkgs/retroshare/template
@@ -1,7 +1,7 @@
 # Template file for 'retroshare'
 pkgname=retroshare
 version=0.6.6
-revision=3
+revision=4
 build_style=qmake
 #XXX broadcast feature requires an ancient udp-discovery-cpp which either needs
 # to be fetched+patched (FTBFS) here or packaged :/

From 0188b980cfd98a6abb23f4bb56c973ed6d5a4445 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 008/113] waifu2x-converter-cpp: revbump for opencv-4.7.0

---
 srcpkgs/waifu2x-converter-cpp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waifu2x-converter-cpp/template b/srcpkgs/waifu2x-converter-cpp/template
index 361b8a23b9497..c5ac17eb54ea4 100644
--- a/srcpkgs/waifu2x-converter-cpp/template
+++ b/srcpkgs/waifu2x-converter-cpp/template
@@ -1,7 +1,7 @@
 # Template file for 'waifu2x-converter-cpp'
 pkgname=waifu2x-converter-cpp
 version=5.2.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DINSTALL_MODELS=ON"
 hostmakedepends="pkg-config"

From 773c3d00520b197526d1f7d114745faa519406f8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:38 -0400
Subject: [PATCH 009/113] vlc: revbump for ffmpeg4

---
 srcpkgs/vlc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/vlc/template b/srcpkgs/vlc/template
index bdd0cc414dc1a..7d245a7b0019c 100644
--- a/srcpkgs/vlc/template
+++ b/srcpkgs/vlc/template
@@ -1,7 +1,7 @@
 # Template file for 'vlc'
 pkgname=vlc
 version=3.0.20
-revision=3
+revision=4
 build_style=gnu-configure
 configure_args="--disable-gme --disable-libtar --enable-jack
  --enable-live555 --disable-fluidsynth --enable-dvdread
@@ -25,7 +25,7 @@ lib32disabled=yes
 hostmakedepends="automake libtool pkg-config flex gettext libgcrypt-devel
  live555-devel gettext-devel $(vopt_if lua lua52) $(vopt_if chromecast protobuf)"
 makedepends="
- avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg-devel freefont-ttf
+ avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg4-devel freefont-ttf
  gnutls-devel jack-devel liba52-devel libass-devel libbluray-devel
  libcdio-devel libdca-devel libdvbpsi-devel libdvdnav-devel libmad-devel
  libmatroska-devel libmodplug-devel libmpcdec-devel libmpeg2-devel

From de0f50a27272fd4d15114c557af30b3f977bf8f0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:55 -0400
Subject: [PATCH 010/113] osg: revbump for ffmpeg4

---
 srcpkgs/osg/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/osg/template b/srcpkgs/osg/template
index a9ebbd287933b..a131ceaf7a867 100644
--- a/srcpkgs/osg/template
+++ b/srcpkgs/osg/template
@@ -1,14 +1,14 @@
 # Template file for 'osg'
 pkgname=osg
 version=3.6.5
-revision=2
+revision=3
 build_style=cmake
 build_helper="qemu"
 # don't use /usr/lib64 on 64bit platforms
 configure_args="-DLIB_POSTFIX="
 hostmakedepends="pkg-config xrandr"
 makedepends="MesaLib-devel gtkglext-devel libcurl-devel giflib-devel librsvg-devel
- jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg-devel xine-lib-devel
+ jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg4-devel xine-lib-devel
  SDL2-devel gst-plugins-base1-devel
  $(vopt_if openexr libopenexr-devel)
  $(vopt_if poppler poppler-glib-devel)

From b239fbaf7f17733459f7b705a9c3839738235979 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:13 -0400
Subject: [PATCH 011/113] xine-lib: revbump for ffmpeg4

---
 srcpkgs/xine-lib/template | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/xine-lib/template b/srcpkgs/xine-lib/template
index 3be4d08eac77a..ed6194c17d11e 100644
--- a/srcpkgs/xine-lib/template
+++ b/srcpkgs/xine-lib/template
@@ -1,14 +1,14 @@
 # Template file for 'xine-lib'
 pkgname=xine-lib
-version=1.2.12
-revision=3
+version=1.2.13
+revision=1
 build_style=gnu-configure
 configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
  --disable-oss"
 hostmakedepends="automake gettext-devel libtool pkg-config perl"
 makedepends="
  zlib-devel alsa-lib-devel libxcb-devel libSM-devel libXext-devel libXv-devel
- libXvMC-devel liba52-devel libmad-devel ffmpeg-devel pulseaudio-devel
+ libXvMC-devel liba52-devel libmad-devel ffmpeg4-devel pulseaudio-devel
  jack-devel samba-devel libflac-devel libmodplug-devel libmpcdec-devel
  speex-devel libtheora-devel libvorbis-devel libdca-devel faad2-devel
  libcdio-devel libbluray-devel aalib-devel libcaca-devel libXinerama-devel
@@ -19,7 +19,7 @@ license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="http://www.xine-project.org"
 changelog="https://sourceforge.net/projects/xine/files/xine-lib/${version}/README.txt/view"
 distfiles="${SOURCEFORGE_SITE}/xine/${pkgname}-${version}.tar.xz"
-checksum=d606270468e1540c2a89c0d7f5fdf11e17ecc0c2698cc0bcb1065ff26abee098
+checksum=5f10d6d718a4a51c17ed1b32b031d4f9b80b061e8276535b2be31e5ac4b75e6f
 
 case "$XBPS_TARGET_MACHINE" in
 	i686-musl)

From 093fefda4dfd9073eb92d6a254f7d2da1fba415b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 012/113] attract: revbump for ffmpeg6

---
 srcpkgs/attract/patches/Makefile.patch | 33 --------------------------
 srcpkgs/attract/patches/fe_net.patch   | 10 ++++++++
 srcpkgs/attract/template               |  6 ++---
 3 files changed, 13 insertions(+), 36 deletions(-)
 delete mode 100644 srcpkgs/attract/patches/Makefile.patch
 create mode 100644 srcpkgs/attract/patches/fe_net.patch

diff --git a/srcpkgs/attract/patches/Makefile.patch b/srcpkgs/attract/patches/Makefile.patch
deleted file mode 100644
index 77ae06268e2ac..0000000000000
--- a/srcpkgs/attract/patches/Makefile.patch
+++ /dev/null
@@ -1,33 +0,0 @@
---- a/Makefile	2016-12-06 21:40:22.715155552 +0100
-+++ b/Makefile	2016-12-06 21:41:39.523155740 +0100
-@@ -50,12 +50,8 @@
- 
- FE_VERSION=v2.2.0
- 
--CC=gcc
--CXX=g++
- CFLAGS=$(EXTRA_CFLAGS)
--STRIP=strip
- PKG_CONFIG=pkg-config
--AR=ar
- ARFLAGS=rc
- RM=rm -f
- MD=mkdir -p
-@@ -84,7 +84,7 @@
- override WINDRES := $(TOOLCHAIN)-$(WINDRES)
- endif
- 
--prefix=/usr/local
-+prefix=/usr
- datarootdir=$(prefix)/share
- datadir=$(datarootdir)
- exec_prefix=$(prefix)
-@@ -414,7 +414,7 @@
- 
- $(EXE): $(OBJ) $(EXPAT) $(SQUIRREL) $(AUDIO)
- 	$(EXE_MSG)
--	$(SILENT)$(CXX) -o $@ $^ $(CFLAGS) $(FE_FLAGS) $(LIBS)
-+	$(SILENT)$(CXX) -o $@ $^ $(LDFLAGS) $(CFLAGS) $(FE_FLAGS) $(LIBS)
- ifneq ($(FE_DEBUG),1)
- 	$(SILENT)$(STRIP) $@
- endif
diff --git a/srcpkgs/attract/patches/fe_net.patch b/srcpkgs/attract/patches/fe_net.patch
new file mode 100644
index 0000000000000..ab676952bb614
--- /dev/null
+++ b/srcpkgs/attract/patches/fe_net.patch
@@ -0,0 +1,10 @@
+--- a/src/fe_net.hpp	2023-06-10 15:32:15.000000000 -0400
++++ b/src/fe_net.hpp	2024-02-11 17:26:26.198496103 -0500
+@@ -27,6 +27,7 @@
+ #include <thread>
+ #include <deque>
+ #include <queue>
++#include <string>
+ 
+ class FeNetWorker;
+
diff --git a/srcpkgs/attract/template b/srcpkgs/attract/template
index 24017d2bacc24..d65d8717dc20a 100644
--- a/srcpkgs/attract/template
+++ b/srcpkgs/attract/template
@@ -1,7 +1,7 @@
 # Template file for 'attract'
 pkgname=attract
-version=2.6.2
-revision=2
+version=2.7.0
+revision=1
 build_style=gnu-makefile
 make_build_args="VERBOSE=1"
 make_use_env=yes
@@ -14,4 +14,4 @@ maintainer="Pedro Narciso García Revington <p.revington@gmail.com>"
 license="GPL-3.0-or-later"
 homepage="http://attractmode.org/"
 distfiles="https://github.com/mickelson/attract/archive/v${version}.tar.gz"
-checksum=0412722c9ff186b5f7081027eb04751ee38f89c318d159f2559d0c4ac3246376
+checksum=497bc9d4d5846cb0eee71eaed2352d2350f789df3a913f423a3d6eed9ba428e8

From a17ca1458971bea588c0db3561f26ecc715bbefc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 013/113] aubio: revbump for ffmpeg6

---
 srcpkgs/aubio/patches/ffmpeg5.patch | 25 +++++++++++++++++++++++++
 srcpkgs/aubio/template              |  2 +-
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/aubio/patches/ffmpeg5.patch

diff --git a/srcpkgs/aubio/patches/ffmpeg5.patch b/srcpkgs/aubio/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..aace41a6e6d9a
--- /dev/null
+++ b/srcpkgs/aubio/patches/ffmpeg5.patch
@@ -0,0 +1,25 @@
+From 8a05420e5dd8c7b8b2447f82dc919765876511b3 Mon Sep 17 00:00:00 2001
+From: Paul Brossier <piem@piem.org>
+Date: Tue, 25 Jan 2022 18:30:27 +0100
+Subject: [PATCH] [source_avcodec] define FF_API_LAVF_AVCTX for libavcodec >
+ 59, thx @berolinux (closes gh-353)
+
+---
+ src/io/source_avcodec.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/io/source_avcodec.c b/src/io/source_avcodec.c
+index e0ae93b5..1421bd9a 100644
+--- a/src/io/source_avcodec.c
++++ b/src/io/source_avcodec.c
+@@ -68,6 +68,10 @@
+ #define AUBIO_AVCODEC_MAX_BUFFER_SIZE AV_INPUT_BUFFER_MIN_SIZE
+ #endif
+ 
++#if LIBAVCODEC_VERSION_MAJOR >= 59
++#define FF_API_LAVF_AVCTX 1
++#endif
++
+ struct _aubio_source_avcodec_t {
+   uint_t hop_size;
+   uint_t samplerate;
diff --git a/srcpkgs/aubio/template b/srcpkgs/aubio/template
index ad1c4b2569917..7d875cc02541a 100644
--- a/srcpkgs/aubio/template
+++ b/srcpkgs/aubio/template
@@ -1,7 +1,7 @@
 # Template file for 'aubio'
 pkgname=aubio
 version=0.4.9
-revision=1
+revision=2
 build_style=waf3
 # XXX lash, pure and swig support.
 hostmakedepends="pkg-config txt2man"

From b299b7948b59ed97bd642cb09e39d31f4595cfc2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 014/113] audacious-plugins: revbump for ffmpeg6

---
 .../audacious-plugins/patches/ffmpeg5.patch   | 43 +++++++++++++++++++
 srcpkgs/audacious-plugins/template            |  2 +-
 2 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/audacious-plugins/patches/ffmpeg5.patch

diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg5.patch b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..4e5e34099d71c
--- /dev/null
+++ b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
@@ -0,0 +1,43 @@
+commit 298aa371c56c2f52c25a33d9bdec4918b11cebdc
+Author: tibequadorian <tibequadorian@posteo.de>
+Date:   Sat Mar 19 18:40:12 2022 +0100
+
+    audacious-plugins: rebuild against ffmpeg-5.0
+
+diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+new file mode 100644
+index 0000000000..617c11215b
+--- /dev/null
++++ b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+@@ -0,0 +1,31 @@
++From f60beb400eeb1e4778bbfd738bc4a4ccef3de539 Mon Sep 17 00:00:00 2001
++From: John Lindgren <john@jlindgren.net>
++Date: Sat, 5 Mar 2022 12:05:34 -0500
++Subject: [PATCH] Fix build with FFmpeg 5.0
++
++---
++ src/ffaudio/ffaudio-core.cc | 4 ++--
++ 1 file changed, 2 insertions(+), 2 deletions(-)
++
++diff --git a/src/ffaudio/ffaudio-core.cc b/src/ffaudio/ffaudio-core.cc
++index 16dc63e3a..a2b95fd6c 100644
++--- a/src/ffaudio/ffaudio-core.cc
+++++ b/src/ffaudio/ffaudio-core.cc
++@@ -274,7 +274,7 @@ static AVInputFormat * get_format_by_content (const char * name, VFSFile & file)
++         AVProbeData d = {name, buf, filled};
++         score = target;
++ 
++-        f = av_probe_input_format2 (& d, true, & score);
+++        f = (AVInputFormat *) av_probe_input_format2 (& d, true, & score);
++         if (f)
++             break;
++ 
++@@ -347,7 +347,7 @@ static bool find_codec (AVFormatContext * c, CodecInfo * cinfo)
++ #endif
++         if (stream && stream->codecpar && stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
++         {
++-            AVCodec * codec = avcodec_find_decoder (stream->codecpar->codec_id);
+++            AVCodec * codec = (AVCodec *) avcodec_find_decoder (stream->codecpar->codec_id);
++ 
++             if (codec)
++             {
diff --git a/srcpkgs/audacious-plugins/template b/srcpkgs/audacious-plugins/template
index 05e53a9adf78f..4b1968e03de78 100644
--- a/srcpkgs/audacious-plugins/template
+++ b/srcpkgs/audacious-plugins/template
@@ -2,7 +2,7 @@
 #Keep in sync with audacious!
 pkgname=audacious-plugins
 version=4.3.1
-revision=3
+revision=4
 build_style=meson
 configure_args="$(vopt_bool gtk3 gtk) $(vopt_bool gtk3)
  $(vopt_bool qt) $(vopt_bool qt qt6)"

From a101f8c77822843f4b7eb8a13f57f6a8144577b4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 015/113] audacity: revbump for ffmpeg6

---
 srcpkgs/audacity/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/audacity/template b/srcpkgs/audacity/template
index 7b838119ab261..84b49305edcef 100644
--- a/srcpkgs/audacity/template
+++ b/srcpkgs/audacity/template
@@ -1,7 +1,7 @@
 # Template file for 'audacity'
 pkgname=audacity
 version=3.4.2
-revision=1
+revision=2
 build_style=cmake
 build_helper="cmake-wxWidgets-gtk3 qemu"
 configure_args="-Daudacity_use_ffmpeg=loaded -Daudacity_lib_preference=system

From 253987bac83b82f8a9f1d0fdd809dd9955e5a5c9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 016/113] avidemux: revbump for ffmpeg6

---
 srcpkgs/avidemux/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/avidemux/template b/srcpkgs/avidemux/template
index 253a0243e2259..557285982d2b8 100644
--- a/srcpkgs/avidemux/template
+++ b/srcpkgs/avidemux/template
@@ -1,7 +1,7 @@
 # Template file for 'avidemux'
 pkgname=avidemux
 version=2.8.0
-revision=2
+revision=3
 # Can't be compiled for aarch64, arm* or mips*
 archs="x86_64* i686*"
 hostmakedepends="cmake pkg-config qt5-host-tools qt5-devel tar yasm"

From a08c8fb77837606b52c8d2132753ab00c03430e0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 017/113] blender: revbump for ffmpeg6

---
 srcpkgs/blender/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index 1dc61ec9d29d8..e238717ac8c72 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -1,7 +1,7 @@
 # Template file for 'blender'
 pkgname=blender
 version=4.0.2
-revision=1
+revision=2
 archs="x86_64* ppc64*"
 build_style="cmake"
 pycompile_dirs="usr/share/blender/${version%.*}/scripts"
@@ -9,8 +9,8 @@ configure_args="-DWITH_INSTALL_PORTABLE=OFF -DWITH_PYTHON_INSTALL=OFF
  -DWITH_JACK=ON -DWITH_CODEC_FFMPEG=ON -DWITH_CODEC_SNDFILE=ON -DWITH_OPENMP=ON
  -DWITH_FFTW3=ON -DWITH_MOD_OCEANSIM=ON -DWITH_CYCLES_EMBREE=OFF -DWITH_OPENCOLORIO=ON
  -DWITH_IMAGE_OPENEXR=ON -DWITH_IMAGE_OPENJPEG=ON -DWITH_OPENSUBDIV=ON
- -DWITH_OPENCOLLADA=ON -DWITH_SYSTEM_GLEW=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
- -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_LIBDECOR=ON
+ -DWITH_OPENCOLLADA=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
+ -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_WAYLAND_LIBDECOR=ON
  -DWITH_BUILDINFO=OFF -DPYTHON_VERSION=${py3_ver} -DPYTHON_LIBPATH=/usr/lib
  -DPYTHON_LIBRARY=python${py3_ver}${py3_abiver} -DPYTHON_INCLUDE_DIRS=/${py3_inc}
  -DWITH_SYSTEM_LZO=ON -DWITH_SYSTEM_EIGEN3=ON -DWITH_SYSTEM_FREETYPE=ON"

From 576cefd100074464178a6705b0704784eb881434 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 018/113] cantata: revbump for ffmpeg6

---
 srcpkgs/cantata/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cantata/template b/srcpkgs/cantata/template
index 4b417d80d5c2d..8a90aaa4c07a2 100644
--- a/srcpkgs/cantata/template
+++ b/srcpkgs/cantata/template
@@ -1,7 +1,7 @@
 # Template file for 'cantata'
 pkgname=cantata
 version=2.5.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools qt5-tools"
 makedepends="qt5-devel qt5-tools-devel qt5-svg-devel qt5-xmlpatterns-devel

From 4ac08e8523f59eee03cd7c793077c148bb9fc26a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 019/113] ccextractor: revbump for ffmpeg6

---
 ...5-and-tesseract-5-compatibility-1479.patch | 168 ++++++++++++++++++
 srcpkgs/ccextractor/template                  |   2 +-
 2 files changed, 169 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ccextractor/patches/0001-fix-ffmpeg-5-and-tesseract-5-compatibility-1479.patch

diff --git a/srcpkgs/ccextractor/patches/0001-fix-ffmpeg-5-and-tesseract-5-compatibility-1479.patch b/srcpkgs/ccextractor/patches/0001-fix-ffmpeg-5-and-tesseract-5-compatibility-1479.patch
new file mode 100644
index 0000000000000..bcab4890554b9
--- /dev/null
+++ b/srcpkgs/ccextractor/patches/0001-fix-ffmpeg-5-and-tesseract-5-compatibility-1479.patch
@@ -0,0 +1,168 @@
+From b1cbfcea9b9c687143bf0d80bc179b563e99d025 Mon Sep 17 00:00:00 2001
+From: Prateek Sunal <prtksunal@gmail.com>
+Date: Thu, 9 Mar 2023 01:44:53 +0530
+Subject: [PATCH] fix: ffmpeg 5 and tesseract 5 compatibility (#1479)
+
+* fix: replace deprecated `codec` property with `codecpar`
+
+* fix: replace deprecated method `avcodec_decode_video2` with `avcodec_receive_frame` and `avcodec_send_packet`
+
+* Update CHANGES.TXT
+
+* fix: remove deprecated `av_register_all` function
+
+* fix: formatting
+
+* fix: add support for tesseract 5
+
+* fix: tesseract v5
+
+* fix: hardsubx codec context error
+
+* fix: lint const warning
+---
+ docs/CHANGES.TXT               |  1 +
+ src/lib_ccx/ffmpeg_intgr.c     |  7 +++---
+ src/lib_ccx/hardsubx.c         | 25 ++++++++++++------
+ src/lib_ccx/hardsubx_decoder.c | 27 ++++++++------------
+ src/lib_ccx/ocr.c              | 46 ++++++++++++----------------------
+ 5 files changed, 47 insertions(+), 59 deletions(-)
+
+diff --git a/src/lib_ccx/ffmpeg_intgr.c b/src/lib_ccx/ffmpeg_intgr.c
+index be988890..e6f21e20 100644
+--- a/src/lib_ccx/ffmpeg_intgr.c
++++ b/src/lib_ccx/ffmpeg_intgr.c
+@@ -66,7 +66,6 @@ void *init_ffmpeg(const char *path)
+ 	struct ffmpeg_ctx *ctx;
+ 	AVCodec *dec = NULL;
+ 	avcodec_register_all();
+-	av_register_all();
+ 
+ 	if (ccx_options.debug_mask & CCX_DMT_VERBOSE)
+ 		av_log_set_level(AV_LOG_INFO);
+@@ -133,7 +132,6 @@ int ff_get_ccframe(void *arg, unsigned char *data, int maxlen)
+ 	struct ffmpeg_ctx *ctx = arg;
+ 	int len = 0;
+ 	int ret = 0;
+-	int got_frame;
+ 	AVPacket packet;
+ 
+ 	ret = av_read_frame(ctx->ifmt, &packet);
+@@ -151,12 +149,13 @@ int ff_get_ccframe(void *arg, unsigned char *data, int maxlen)
+ 		return AVERROR(EAGAIN);
+ 	}
+ 
+-	ret = avcodec_decode_video2(ctx->dec_ctx, ctx->frame, &got_frame, &packet);
++	avcodec_send_packet(ctx->codec_ctx, &ctx->packet);
++	ret = avcodec_receive_frame(ctx->dec_ctx, ctx->frame);
+ 	if (ret < 0)
+ 	{
+ 		av_log(NULL, AV_LOG_ERROR, "unable to decode packet\n");
+ 	}
+-	else if (!got_frame)
++	else if (ret != 0)
+ 	{
+ 		return AVERROR(EAGAIN);
+ 	}
+diff --git a/src/lib_ccx/hardsubx.c b/src/lib_ccx/hardsubx.c
+index 411377f9..fb844c91 100644
+--- a/src/lib_ccx/hardsubx.c
++++ b/src/lib_ccx/hardsubx.c
+@@ -12,9 +12,6 @@
+
+ int hardsubx_process_data(struct lib_hardsubx_ctx *ctx)
+ {
+-	// Get the required media attributes and initialize structures
+-	av_register_all();
+-
+ 	if (avformat_open_input(&ctx->format_ctx, ctx->inputfile[0], NULL, NULL) != 0)
+ 	{
+ 		fatal(EXIT_READ_ERROR, "Error reading input file!\n");
+@@ -32,7 +29,7 @@
+ 	ctx->video_stream_id = -1;
+ 	for (int i = 0; i < ctx->format_ctx->nb_streams; i++)
+ 	{
+-		if (ctx->format_ctx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO)
++		if (ctx->format_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
+ 		{
+ 			ctx->video_stream_id = i;
+ 			break;
+@@ -43,8 +40,21 @@
+ 		fatal(EXIT_READ_ERROR, "Video Stream not found!\n");
+ 	}
+
+-	ctx->codec_ctx = ctx->format_ctx->streams[ctx->video_stream_id]->codec;
+-	ctx->codec = avcodec_find_decoder(ctx->codec_ctx->codec_id);
++	ctx->codec_ctx = avcodec_alloc_context3(NULL);
++	if (!ctx->codec_ctx)
++	{
++		    fatal(EXIT_NOT_ENOUGH_MEMORY, "Could not allocate codec context!\n");
++	}
++
++	// Assign codec parameters to codec context
++	if (avcodec_parameters_to_context(ctx->codec_ctx, ctx->format_ctx->streams[ctx->video_stream_id]->codecpar) < 0)
++	{
++		    fatal(EXIT_READ_ERROR, "Could not initialize codec context!\n");
++	}
++
++	// Find decoder for the codec context
++	ctx->codec = (AVCodec *)avcodec_find_decoder(ctx->codec_ctx->codec_id);
++
+ 	if (ctx->codec == NULL)
+ 	{
+ 		fatal(EXIT_READ_ERROR, "Input codec is not supported!\n");
+diff --git a/src/lib_ccx/hardsubx_decoder.c b/src/lib_ccx/hardsubx_decoder.c
+index bd9b0980..b5dfaec4 100644
+--- a/src/lib_ccx/hardsubx_decoder.c
++++ b/src/lib_ccx/hardsubx_decoder.c
+@@ -371,7 +371,6 @@
+ int hardsubx_process_frames_tickertext(struct lib_hardsubx_ctx *ctx, struct encoder_ctx *enc_ctx)
+ {
+ 	// Search for ticker text at the bottom of the screen, such as in Russia TV1 or stock prices
+-	int got_frame;
+ 	int cur_sec = 0, total_sec, progress;
+ 	int frame_number = 0;
+ 	char *ticker_text = NULL;
+@@ -382,8 +381,8 @@
+ 		{
+ 			frame_number++;
+ 			//Decode the video stream packet
+-			avcodec_decode_video2(ctx->codec_ctx, ctx->frame, &got_frame, &ctx->packet);
+-			if (got_frame && frame_number % 1000 == 0)
++      avcodec_send_packet(ctx->codec_ctx, &ctx->packet);
++      if (avcodec_receive_frame(ctx->codec_ctx, ctx->frame) == 0 && frame_number % 1000 == 0)
+ 			{
+ 				// sws_scale is used to convert the pixel format to RGB24 from all other cases
+ 				sws_scale(
+@@ -434,9 +433,8 @@
+ 			frame_number++;
+
+ 			//Decode the video stream packet
+-			avcodec_decode_video2(ctx->codec_ctx, ctx->frame, &got_frame, &ctx->packet);
+-
+-			if (got_frame && frame_number % 25 == 0)
++			avcodec_send_packet(ctx->codec_ctx, &ctx->packet);
++      if (avcodec_receive_frame(ctx->codec_ctx, ctx->frame) == 0 && frame_number % 25 == 0)
+ 			{
+ 				float diff = (float)convert_pts_to_ms(ctx->packet.pts - prev_packet_pts, ctx->format_ctx->streams[ctx->video_stream_id]->time_base);
+ 				if (fabsf(diff) < 1000 * ctx->min_sub_duration) //If the minimum duration of a subtitle line is exceeded, process packet
+@@ -548,7 +546,6 @@
+ {
+ 	// Do a binary search over the input video for faster processing
+ 	// printf("Duration: %d\n", (int)ctx->format_ctx->duration);
+-	int got_frame;
+ 	int seconds_time = 0;
+ 	for (seconds_time = 0; seconds_time < 20; seconds_time++)
+ 	{
+@@ -568,8 +565,9 @@
+ 			{
+ 				if (ctx->packet.stream_index == ctx->video_stream_id)
+ 				{
+-					avcodec_decode_video2(ctx->codec_ctx, ctx->frame, &got_frame, &ctx->packet);
+-					if (got_frame)
++          avcodec_send_packet(ctx->codec_ctx, &ctx->packet);
++          if (avcodec_receive_frame(ctx->codec_ctx, ctx->frame) == 0)
++
+ 					{
+ 						// printf("%d\n", seek_time);
+ 						if (ctx->packet.pts < seek_time)
diff --git a/srcpkgs/ccextractor/template b/srcpkgs/ccextractor/template
index 84059ffd02398..a670758bcbe41 100644
--- a/srcpkgs/ccextractor/template
+++ b/srcpkgs/ccextractor/template
@@ -1,7 +1,7 @@
 # Template file for 'ccextractor'
 pkgname=ccextractor
 version=0.93
-revision=2
+revision=3
 build_wrksrc="linux"
 build_style=gnu-configure
 configure_args="--enable-ocr --enable-hardsubx"

From a138c7c32ef3f60aa52356d2da2e676edfb3b472 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 020/113] chromaprint: revbump for ffmpeg6

---
 srcpkgs/chromaprint/patches/ffmpeg5.patch | 569 ++++++++++++++++++++++
 srcpkgs/chromaprint/template              |   2 +-
 2 files changed, 570 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromaprint/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromaprint/patches/ffmpeg5.patch b/srcpkgs/chromaprint/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..a9fd307a23c8a
--- /dev/null
+++ b/srcpkgs/chromaprint/patches/ffmpeg5.patch
@@ -0,0 +1,569 @@
+From 8ccad6937177b1b92e40ab8f4447ea27bac009a7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= <lalinsky@gmail.com>
+Date: Fri, 4 Nov 2022 21:47:38 +0100
+Subject: [PATCH] Use FFmpeg 5.x (#120)
+
+* Use FFmpeg 5.1.2 for CI builds
+
+* Build on Ubuntu 20.04
+
+* Upgrade code to FFmpeg 5.x APIs
+
+* Only set FFmpeg include dirs if building tools
+
+* No longer needed
+
+* Use ubuntu 20.04
+---
+ .github/workflows/build.yml                   |   6 +-
+ CMakeLists.txt                                |  16 --
+ package/build.sh                              |   4 +-
+ src/audio/ffmpeg_audio_processor.h            |   2 -
+ src/audio/ffmpeg_audio_processor_avresample.h |  72 -------
+ src/audio/ffmpeg_audio_processor_swresample.h |  18 +-
+ src/audio/ffmpeg_audio_reader.h               | 197 +++++++++---------
+ tests/CMakeLists.txt                          |   6 +
+ 8 files changed, 122 insertions(+), 199 deletions(-)
+ delete mode 100644 src/audio/ffmpeg_audio_processor_avresample.h
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index f8d6a32..4da2405 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -84,9 +84,6 @@ find_package(FFmpeg)
+ if(FFMPEG_LIBRARIES)
+ 	cmake_push_check_state(RESET)
+ 	set(CMAKE_REQUIRED_LIBRARIES ${FFMPEG_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -lm)
+-	check_function_exists(av_packet_unref HAVE_AV_PACKET_UNREF)
+-	check_function_exists(av_frame_alloc HAVE_AV_FRAME_ALLOC)
+-	check_function_exists(av_frame_free HAVE_AV_FRAME_FREE)
+ 	cmake_pop_check_state()
+ endif()
+
+@@ -163,14 +160,11 @@ message(STATUS "Using ${FFT_LIB} for FFT calculations")
+ if(NOT AUDIO_PROCESSOR_LIB)
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+ 		set(AUDIO_PROCESSOR_LIB "swresample")
+-	elseif(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(AUDIO_PROCESSOR_LIB "avresample")
+ 	endif()
+ endif()
+
+ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE OFF)
+ 		set(USE_SWRESAMPLE ON)
+ 		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBSWRESAMPLE_LIBRARIES})
+ 		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBSWRESAMPLE_INCLUDE_DIRS})
+@@ -178,16 +172,6 @@ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+ 	endif()
+ 	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+-elseif(AUDIO_PROCESSOR_LIB STREQUAL "avresample")
+-	if(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE ON)
+-		set(USE_SWRESAMPLE OFF)
+-		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBAVRESAMPLE_LIBRARIES})
+-		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBAVRESAMPLE_INCLUDE_DIRS})
+-	else()
+-		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+-	endif()
+-	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+ else()
+ 	message(STATUS "Building without audio conversion support, please install FFmpeg with libswresample")
+ endif()
+diff --git a/package/build.sh b/package/build.sh
+index da631ae..b41d36e 100755
+--- a/package/build.sh
++++ b/package/build.sh
+@@ -7,8 +7,8 @@ set -eux
+
+ BASE_DIR=$(cd $(dirname $0)/.. && pwd)
+
+-FFMPEG_VERSION=4.4.1
+-FFMPEG_BUILD_TAG=v4.4.1-1
++FFMPEG_VERSION=5.1.2
++FFMPEG_BUILD_TAG=v${FFMPEG_VERSION}-1
+
+ TMP_BUILD_DIR=$BASE_DIR/$(mktemp -d build.XXXXXXXX)
+ trap 'rm -rf $TMP_BUILD_DIR' EXIT
+diff --git a/src/audio/ffmpeg_audio_processor.h b/src/audio/ffmpeg_audio_processor.h
+index 7628fc7..39f4f6d 100644
+--- a/src/audio/ffmpeg_audio_processor.h
++++ b/src/audio/ffmpeg_audio_processor.h
+@@ -10,8 +10,6 @@
+
+ #if defined(USE_SWRESAMPLE)
+ #include "audio/ffmpeg_audio_processor_swresample.h"
+-#elif defined(USE_AVRESAMPLE)
+-#include "audio/ffmpeg_audio_processor_avresample.h"
+ #else
+ #error "no audio processing library"
+ #endif
+diff --git a/src/audio/ffmpeg_audio_processor_avresample.h b/src/audio/ffmpeg_audio_processor_avresample.h
+deleted file mode 100644
+index bd85f92..0000000
+--- a/src/audio/ffmpeg_audio_processor_avresample.h
++++ /dev/null
+@@ -1,72 +0,0 @@
+-// Copyright (C) 2016  Lukas Lalinsky
+-// Distributed under the MIT license, see the LICENSE file for details.
+-
+-#ifndef CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-#define CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-
+-extern "C" {
+-#include <libavresample/avresample.h>
+-}
+-
+-namespace chromaprint {
+-
+-class FFmpegAudioProcessor {
+-public:
+-	FFmpegAudioProcessor() {
+-		m_resample_ctx = avresample_alloc_context();
+-	}
+-
+-	~FFmpegAudioProcessor() {
+-		avresample_free(&m_resample_ctx);
+-	}
+-
+-	void SetCompatibleMode() {
+-		av_opt_set_int(m_resample_ctx, "filter_size", 16, 0);
+-		av_opt_set_int(m_resample_ctx, "phase_shift", 8, 0);
+-		av_opt_set_int(m_resample_ctx, "linear_interp", 1, 0);
+-		av_opt_set_double(m_resample_ctx, "cutoff", 0.8, 0);
+-	}
+-
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "in_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_rate", sample_rate, 0);
+-	}
+-
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "out_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_rate, 0);
+-	}
+-
+-	int Init() {
+-		return avresample_open(m_resample_ctx);
+-	}
+-
+-	int Convert(uint8_t **out, int out_count, const uint8_t **in, int in_count) {
+-		return avresample_convert(m_resample_ctx, out, 0, out_count, (uint8_t **) in, 0, in_count);
+-	}
+-
+-	int Flush(uint8_t **out, int out_count) {
+-		return avresample_read(m_resample_ctx, out, out_count);
+-	}
+-
+-private:
+-	AVAudioResampleContext *m_resample_ctx = nullptr;
+-};
+-
+-}; // namespace chromaprint
+-
+-#endif
+diff --git a/src/audio/ffmpeg_audio_processor_swresample.h b/src/audio/ffmpeg_audio_processor_swresample.h
+index b86266b..b1d4bea 100644
+--- a/src/audio/ffmpeg_audio_processor_swresample.h
++++ b/src/audio/ffmpeg_audio_processor_swresample.h
+@@ -28,30 +28,28 @@ public:
+ 		av_opt_set_double(m_swr_ctx, "cutoff", 0.8, 0);
+ 	}
+
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "icl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "ich", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetInputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "in_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "isf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "in_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "isr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "in_sample_rate", sample_rate, 0);
+ 	}
+
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "ocl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "och", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetOutputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "out_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "osf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "out_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "osr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "out_sample_rate", sample_rate, 0);
+ 	}
+
+ 	int Init() {
+diff --git a/src/audio/ffmpeg_audio_reader.h b/src/audio/ffmpeg_audio_reader.h
+index 5550164..1c6b346 100644
+--- a/src/audio/ffmpeg_audio_reader.h
++++ b/src/audio/ffmpeg_audio_reader.h
+@@ -62,7 +62,7 @@ public:
+ 	bool Read(const int16_t **data, size_t *size);
+
+ 	bool IsOpen() const { return m_opened; }
+-	bool IsFinished() const { return m_finished && !m_got_frame; }
++	bool IsFinished() const { return !m_has_more_packets && !m_has_more_frames; }
+
+ 	std::string GetError() const { return m_error; }
+ 	int GetErrorCode() const { return m_error_code; }
+@@ -74,20 +74,19 @@ private:
+ 	uint8_t *m_convert_buffer[1] = { nullptr };
+ 	int m_convert_buffer_nb_samples = 0;
+
+-	AVInputFormat *m_input_fmt = nullptr;
++	const AVInputFormat *m_input_fmt = nullptr;
+ 	AVDictionary *m_input_opts = nullptr;
+
+ 	AVFormatContext *m_format_ctx = nullptr;
+ 	AVCodecContext *m_codec_ctx = nullptr;
+-	AVFrame *m_frame = nullptr;
+ 	int m_stream_index = -1;
+ 	std::string m_error;
+ 	int m_error_code = 0;
+-	bool m_finished = false;
+ 	bool m_opened = false;
+-	int m_got_frame = 0;
+-	AVPacket m_packet;
+-	AVPacket m_packet0;
++	bool m_has_more_packets = true;
++	bool m_has_more_frames = true;
++	AVPacket *m_packet = nullptr;
++	AVFrame *m_frame = nullptr;
+
+ 	int m_output_sample_rate = 0;
+ 	int m_output_channels = 0;
+@@ -98,19 +97,12 @@ private:
+
+ inline FFmpegAudioReader::FFmpegAudioReader() {
+ 	av_log_set_level(AV_LOG_QUIET);
+-
+-	av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
+ }
+
+ inline FFmpegAudioReader::~FFmpegAudioReader() {
+ 	Close();
+ 	av_dict_free(&m_input_opts);
+ 	av_freep(&m_convert_buffer[0]);
+-	av_packet_unref(&m_packet0);
+ }
+
+ inline bool FFmpegAudioReader::SetInputFormat(const char *name) {
+@@ -135,11 +127,10 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ 	Close();
+
+-    av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
++	m_packet = av_packet_alloc();
++	if (!m_packet) {
++		return false;
++	}
+
+ 	ret = avformat_open_input(&m_format_ctx, file_name.c_str(), m_input_fmt, &m_input_opts);
+ 	if (ret < 0) {
+@@ -153,26 +144,31 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		return false;
+ 	}
+
+-	AVCodec *codec;
++	const AVCodec *codec;
+ 	ret = av_find_best_stream(m_format_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &codec, 0);
+ 	if (ret < 0) {
+ 		SetError("Could not find any audio stream in the file", ret);
+ 		return false;
+ 	}
+ 	m_stream_index = ret;
++	auto stream = m_format_ctx->streams[m_stream_index];
+
+-	m_codec_ctx = m_format_ctx->streams[m_stream_index]->codec;
++	m_codec_ctx = avcodec_alloc_context3(codec);
+ 	m_codec_ctx->request_sample_fmt = AV_SAMPLE_FMT_S16;
+
++	ret = avcodec_parameters_to_context(m_codec_ctx, stream->codecpar);
++	if (ret < 0) {
++		SetError("Could not copy the stream parameters", ret);
++		return false;
++	}
++
+ 	ret = avcodec_open2(m_codec_ctx, codec, nullptr);
+ 	if (ret < 0) {
+ 		SetError("Could not open the codec", ret);
+ 		return false;
+ 	}
+
+-	if (!m_codec_ctx->channel_layout) {
+-		m_codec_ctx->channel_layout = av_get_default_channel_layout(m_codec_ctx->channels);
+-	}
++	av_dump_format(m_format_ctx, 0, "foo", 0);
+
+ 	m_frame = av_frame_alloc();
+ 	if (!m_frame) {
+@@ -183,19 +179,23 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		m_output_sample_rate = m_codec_ctx->sample_rate;
+ 	}
+
+-	if (!m_output_channels) {
+-		m_output_channels = m_codec_ctx->channels;
++	AVChannelLayout output_channel_layout;
++	if (m_output_channels) {
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
++	} else {
++		m_output_channels = m_codec_ctx->ch_layout.nb_channels;
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
+ 	}
+
+-	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
++	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->ch_layout.nb_channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
+ 		m_converter.reset(new FFmpegAudioProcessor());
+ 		m_converter->SetCompatibleMode();
+ 		m_converter->SetInputSampleFormat(m_codec_ctx->sample_fmt);
+ 		m_converter->SetInputSampleRate(m_codec_ctx->sample_rate);
+-		m_converter->SetInputChannelLayout(m_codec_ctx->channel_layout);
++		m_converter->SetInputChannelLayout(&(m_codec_ctx->ch_layout));
+ 		m_converter->SetOutputSampleFormat(AV_SAMPLE_FMT_S16);
+ 		m_converter->SetOutputSampleRate(m_output_sample_rate);
+-		m_converter->SetOutputChannelLayout(av_get_default_channel_layout(m_output_channels));
++		m_converter->SetOutputChannelLayout(&output_channel_layout);
+ 		auto ret = m_converter->Init();
+ 		if (ret != 0) {
+ 			SetError("Could not create an audio converter instance", ret);
+@@ -203,10 +203,11 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		}
+ 	}
+
++	av_channel_layout_uninit(&output_channel_layout);
++
+ 	m_opened = true;
+-	m_finished = false;
+-	m_got_frame = 0;
+-	m_nb_packets = 0;
++	m_has_more_packets = true;
++	m_has_more_frames = true;
+ 	m_decode_error = 0;
+
+ 	return true;
+@@ -214,6 +215,7 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ inline void FFmpegAudioReader::Close() {
+ 	av_frame_free(&m_frame);
++	av_packet_free(&m_packet);
+
+ 	m_stream_index = -1;
+
+@@ -252,91 +254,98 @@ inline bool FFmpegAudioReader::Read(const int16_t **data, size_t *size) {
+ 		return false;
+ 	}
+
++	*data = nullptr;
++	*size = 0;
++
+ 	int ret;
++	bool needs_packet = false;
+ 	while (true) {
+-		while (m_packet.size <= 0) {
+-			av_packet_unref(&m_packet0);
+-			av_init_packet(&m_packet);
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			ret = av_read_frame(m_format_ctx, &m_packet);
++		while (needs_packet && m_packet->size == 0) {
++			ret = av_read_frame(m_format_ctx, m_packet);
+ 			if (ret < 0) {
+ 				if (ret == AVERROR_EOF) {
+-					m_finished = true;
++					needs_packet = false;
++					m_has_more_packets = false;
+ 					break;
+-				} else {
++				}
++				SetError("Error reading from the audio source", ret);
++				return false;
++			}
++			if (m_packet->stream_index == m_stream_index) {
++				needs_packet = false;
++			} else {
++				av_packet_unref(m_packet);
++			}
++		}
++
++		if (m_packet->size != 0) {
++			ret = avcodec_send_packet(m_codec_ctx, m_packet);
++			if (ret < 0) {
++				if (ret != AVERROR(EAGAIN)) {
+ 					SetError("Error reading from the audio source", ret);
+ 					return false;
+ 				}
+-			}
+-			m_packet0 = m_packet;
+-			if (m_packet.stream_index != m_stream_index) {
+-				m_packet.data = nullptr;
+-				m_packet.size = 0;
+ 			} else {
+-				m_nb_packets++;
++				av_packet_unref(m_packet);
+ 			}
+ 		}
+
+-		ret = avcodec_decode_audio4(m_codec_ctx, m_frame, &m_got_frame, &m_packet);
++		ret = avcodec_receive_frame(m_codec_ctx, m_frame);
+ 		if (ret < 0) {
+-			if (m_decode_error) {
+-				SetError("Error decoding audio frame", m_decode_error);
+-				return false;
++			if (ret == AVERROR_EOF) {
++				m_has_more_frames = false;
++			} else if (ret == AVERROR(EAGAIN)) {
++				if (m_has_more_packets) {
++					needs_packet = true;
++					continue;
++				} else {
++					m_has_more_frames = false;
++				}
+ 			}
+-			m_decode_error = ret;
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			continue;
++			SetError("Error decoding the audio source", ret);
++			return false;
+ 		}
+
+-		break;
+-	}
+-
+-	m_decode_error = 0;
+-
+-	const int decoded = std::min(ret, m_packet.size);
+-	m_packet.data += decoded;
+-	m_packet.size -= decoded;
+-
+-	if (m_got_frame) {
+-		if (m_converter) {
+-			if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
+-				int linsize;
+-				av_freep(&m_convert_buffer[0]);
+-				m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
+-				ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
+-				if (ret < 0) {
+-					SetError("Couldn't allocate audio converter buffer", ret);
++		if (m_frame->nb_samples > 0) {
++			if (m_converter) {
++				if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
++					int linsize;
++					av_freep(&m_convert_buffer[0]);
++					m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
++					ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->ch_layout.nb_channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
++					if (ret < 0) {
++						SetError("Couldn't allocate audio converter buffer", ret);
++						return false;
++					}
++				}
++				auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
++				if (nb_samples < 0) {
++					SetError("Couldn't convert audio", ret);
+ 					return false;
+ 				}
+-			}
+-			auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			}
+-			*data = (const int16_t *) m_convert_buffer[0];
+-			*size = nb_samples;
+-		} else {
+-			*data = (const int16_t *) m_frame->data[0];
+-			*size = m_frame->nb_samples;
+-		}
+-	} else {
+-		if (m_finished && m_converter) {
+-			auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			} else if (nb_samples > 0) {
+-				m_got_frame = 1;
+ 				*data = (const int16_t *) m_convert_buffer[0];
+ 				*size = nb_samples;
++			} else {
++				*data = (const int16_t *) m_frame->data[0];
++				*size = m_frame->nb_samples;
++			}
++		} else {
++			if (m_converter) {
++				if (IsFinished()) {
++					auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
++					if (nb_samples < 0) {
++						SetError("Couldn't convert audio", ret);
++						return false;
++					} else if (nb_samples > 0) {
++						*data = (const int16_t *) m_convert_buffer[0];
++						*size = nb_samples;
++					}
++				}
+ 			}
+ 		}
+-	}
+
+-	return true;
++		return true;
++	}
+ }
+
+ inline void FFmpegAudioReader::SetError(const char *message, int errnum) {
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index a2b517b..123e643 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -38,6 +38,12 @@ set(SRCS
+
+ if(BUILD_TOOLS)
+ 	set(SRCS ${SRCS} ../src/audio/ffmpeg_audio_reader_test.cpp)
++    include_directories(
++        ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}
++        ${AUDIO_PROCESSOR_INCLUDE_DIRS}
++    )
+ 	link_libraries(fpcalc_libs)
+ endif()
+
+-- 
+2.38.1
+
+
diff --git a/srcpkgs/chromaprint/template b/srcpkgs/chromaprint/template
index 7ef7838949f3a..1f7bbc70a22c8 100644
--- a/srcpkgs/chromaprint/template
+++ b/srcpkgs/chromaprint/template
@@ -1,7 +1,7 @@
 # Template file for 'chromaprint'
 pkgname=chromaprint
 version=1.5.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DBUILD_TOOLS=ON"
 make_check_target="check"

From b332fd67bd09f673006a04fb6babfe972911447e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 021/113] chromium: revbump for ffmpeg6

---
 .../patches/chromium-119-ffmpeg-4.4.patch     | 20 --------
 srcpkgs/chromium/patches/ffmpeg5.patch        | 47 +++++++++++++++++++
 srcpkgs/chromium/template                     |  2 +-
 3 files changed, 48 insertions(+), 21 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch
 create mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch b/srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch
deleted file mode 100644
index 04d04b166ba37..0000000000000
--- a/srcpkgs/chromium/patches/chromium-119-ffmpeg-4.4.patch
+++ /dev/null
@@ -1,20 +0,0 @@
---- a/media/filters/ffmpeg_demuxer.cc.orig
-+++ b/media/filters/ffmpeg_demuxer.cc
-@@ -390,7 +390,7 @@
- 
-   scoped_refptr<DecoderBuffer> buffer;
- 
--    size_t side_data_size = 0;
-+    int side_data_size = 0;
-     uint8_t* side_data = av_packet_get_side_data(
-         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
- 
-@@ -453,7 +453,7 @@
-                                        packet->size - data_offset);
-     }
- 
--    size_t skip_samples_size = 0;
-+    int skip_samples_size = 0;
-     const uint32_t* skip_samples_ptr =
-         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
-             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..24e2da38e34ca
--- /dev/null
+++ b/srcpkgs/chromium/patches/ffmpeg5.patch
@@ -0,0 +1,47 @@
+--- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
++++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
+@@ -92,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+-  if (stream->start_time != kNoFFmpegTimestamp)
++  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -1597,7 +1585,7 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+@@ -1618,7 +1606,7 @@
+     if (stream->type() != DemuxerStream::VIDEO)
+       continue;
+ 
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+ 
+     if (!stream->IsEnabled())
diff --git a/srcpkgs/chromium/template b/srcpkgs/chromium/template
index 5613fa3813822..cd386c8a84ae6 100644
--- a/srcpkgs/chromium/template
+++ b/srcpkgs/chromium/template
@@ -2,7 +2,7 @@
 pkgname=chromium
 # See https://chromiumdash.appspot.com/releases?platform=Linux for the latest version
 version=120.0.6099.129
-revision=1
+revision=2
 archs="i686* x86_64* aarch64* armv7l*"
 hostmakedepends="
  $(vopt_if clang "clang lld llvm15")

From 692af5b0793410877e515dd107a34459e97eaeee Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 022/113] cmus: revbump for ffmpeg6

---
 srcpkgs/chromium/patches/ffmpeg5.patch | 47 --------------------------
 srcpkgs/cmus/patches/ffmpeg6.patch     | 12 +++++++
 srcpkgs/cmus/template                  |  2 +-
 3 files changed, 13 insertions(+), 48 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch
 create mode 100644 srcpkgs/cmus/patches/ffmpeg6.patch

diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
deleted file mode 100644
index 24e2da38e34ca..0000000000000
--- a/srcpkgs/chromium/patches/ffmpeg5.patch
+++ /dev/null
@@ -1,47 +0,0 @@
---- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
-+++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
-@@ -92,24 +92,12 @@
- 
- static base::TimeDelta ExtractStartTime(AVStream* stream) {
-   // The default start time is zero.
--  base::TimeDelta start_time;
-+  base::TimeDelta start_time = kNoTimestamp;
- 
-   // First try to use  the |start_time| value as is.
--  if (stream->start_time != kNoFFmpegTimestamp)
-+  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
-     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
- 
--  // Next try to use the first DTS value, for codecs where we know PTS == DTS
--  // (excludes all H26x codecs). The start time must be returned in PTS.
--  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
--      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
--      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
--      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
--    const base::TimeDelta first_pts =
--        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
--    if (first_pts < start_time)
--      start_time = first_pts;
--  }
--
-   return start_time;
- }
- 
-@@ -1597,7 +1585,7 @@
-   for (const auto& stream : streams_) {
-     if (!stream || stream->IsEnabled() != enabled)
-       continue;
--    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
-+    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
-       continue;
-     if (!lowest_start_time_stream ||
-         stream->start_time() < lowest_start_time_stream->start_time()) {
-@@ -1618,7 +1606,7 @@
-     if (stream->type() != DemuxerStream::VIDEO)
-       continue;
- 
--    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
-+    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
-       continue;
- 
-     if (!stream->IsEnabled())
diff --git a/srcpkgs/cmus/patches/ffmpeg6.patch b/srcpkgs/cmus/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..ffa95ab811101
--- /dev/null
+++ b/srcpkgs/cmus/patches/ffmpeg6.patch
@@ -0,0 +1,12 @@
+--- a/ip/ffmpeg.c
++++ b/ip/ffmpeg.c
+@@ -202,9 +202,6 @@ static int ffmpeg_open(struct input_plugin_data *ip_data)
+ 			break;
+ 		}
+ 
+-		if (codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+-			cc->flags |= AV_CODEC_FLAG_TRUNCATED;
+-
+ 		if (avcodec_open2(cc, codec, NULL) < 0) {
+ 			d_print("could not open codec: %d, %s\n", cc->codec_id, avcodec_get_name(cc->codec_id));
+ 			err = -IP_ERROR_UNSUPPORTED_FILE_TYPE;
diff --git a/srcpkgs/cmus/template b/srcpkgs/cmus/template
index 0d1436744f1b2..a6e4b4fa86cb8 100644
--- a/srcpkgs/cmus/template
+++ b/srcpkgs/cmus/template
@@ -1,7 +1,7 @@
 # Template file for 'cmus'
 pkgname=cmus
 version=2.10.0
-revision=3
+revision=4
 build_style=configure
 configure_args="prefix=/usr LD=$CC"
 hostmakedepends="pkg-config"

From 9cc3328d4d778ce72aa9246b0775fdd48edaab45 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 023/113] cyanrip: revbump for ffmpeg6

---
 srcpkgs/cyanrip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cyanrip/template b/srcpkgs/cyanrip/template
index 9796e3461601a..5db30e020d17e 100644
--- a/srcpkgs/cyanrip/template
+++ b/srcpkgs/cyanrip/template
@@ -1,7 +1,7 @@
 # Template file for 'cyanrip'
 pkgname=cyanrip
 version=0.9.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config"
 makedepends="ffmpeg-devel libcdio-devel libcdio-paranoia-devel libcurl-devel libmusicbrainz5-devel"

From df46361a67f2b707f21b1cb36558b3f6410a055d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 024/113] deadbeef: revbump for ffmpeg4

---
 srcpkgs/deadbeef/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/deadbeef/template b/srcpkgs/deadbeef/template
index f5f4bf24b8cb6..7b47e615cd48e 100644
--- a/srcpkgs/deadbeef/template
+++ b/srcpkgs/deadbeef/template
@@ -1,14 +1,14 @@
 # Template file for 'deadbeef'
 pkgname=deadbeef
 version=1.8.8
-revision=3
+revision=4
 create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-oss --disable-lfm --disable-notify --disable-gtk2"
 hostmakedepends="automake libtool gettext gettext-devel intltool pkg-config
  yasm clang glib-devel"
 makedepends="
- alsa-lib-devel dbus-devel faad2-devel ffmpeg-devel gtk+3-devel imlib2-devel
+ alsa-lib-devel dbus-devel faad2-devel ffmpeg4-devel gtk+3-devel imlib2-devel
  jansson-devel libcddb-devel libcdio-devel libcurl-devel libflac-devel
  libmad-devel libpng-devel libsamplerate-devel libsndfile-devel libvorbis-devel
  libzip-devel mpg123-devel opusfile-devel pulseaudio-devel wavpack-devel"

From 00c7bffac3082be6f72e19b245dbfa69a7471f90 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 025/113] droidcam-obs-plugin: revbump for ffmpeg6

---
 srcpkgs/droidcam-obs-plugin/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam-obs-plugin/template b/srcpkgs/droidcam-obs-plugin/template
index fc9c9bf6b9d54..fb0480754df4d 100644
--- a/srcpkgs/droidcam-obs-plugin/template
+++ b/srcpkgs/droidcam-obs-plugin/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam-obs-plugin'
 pkgname=droidcam-obs-plugin
 version=2.0.1
-revision=1
+revision=2
 build_style=gnu-makefile
 make_use_env=yes
 make_build_args="ALLOW_STATIC=no"

From 1eb2d525159aa4f761c46a7d0e03f0c573313e63 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 026/113] droidcam: revbump for ffmpeg6

---
 srcpkgs/droidcam/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam/template b/srcpkgs/droidcam/template
index 1c3f1b8b1fc67..32a9220b79a4d 100644
--- a/srcpkgs/droidcam/template
+++ b/srcpkgs/droidcam/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam'
 pkgname=droidcam
 version=1.8.2
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="USBMUXD=-lusbmuxd-2.0 JPEG=-lturbojpeg"
 hostmakedepends="pkg-config"

From e3901a12d1bb9c247ce48208bba007b746600448 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 027/113] ffmpegthumbnailer: revbump for ffmpeg6

---
 .../ffmpegthumbnailer/patches/ffmpeg6.patch   | 202 ++++++++++++++++++
 srcpkgs/ffmpegthumbnailer/template            |   6 +-
 2 files changed, 205 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch

diff --git a/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..363ff35a28419
--- /dev/null
+++ b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
@@ -0,0 +1,202 @@
+--- a/libffmpegthumbnailer/moviedecoder.cpp	2017-11-21 14:06:57.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.cpp	2023-05-05 13:14:47.946560668 -0400
+@@ -41,11 +41,6 @@
+ namespace ffmpegthumbnailer
+ {
+ 
+-struct SilenceLogLevel
+-{
+-    SilenceLogLevel() { av_log_set_level(AV_LOG_QUIET); }
+-};
+-
+ MovieDecoder::MovieDecoder(AVFormatContext* pavContext)
+ : m_VideoStream(-1)
+ , m_pFormatContext(pavContext)
+@@ -70,8 +65,6 @@
+ 
+ void MovieDecoder::initialize(const string& filename, bool preferEmbeddedMetadata)
+ {
+-    av_register_all();
+-    avcodec_register_all();
+     avformat_network_init();
+ 
+     string inputFile = filename == "-" ? "pipe:" : filename;
+@@ -97,8 +90,7 @@
+ {
+     if (m_pVideoCodecContext)
+     {
+-        avcodec_close(m_pVideoCodecContext);
+-        m_pVideoCodecContext = nullptr;
++        avcodec_free_context(&m_pVideoCodecContext);
+     }
+ 
+     if ((!m_FormatContextWasGiven) && m_pFormatContext)
+@@ -152,10 +144,10 @@
+     for (unsigned int i = 0; i < m_pFormatContext->nb_streams; ++i)
+     {
+         AVStream *stream = m_pFormatContext->streams[i];
+-        auto ctx = m_pFormatContext->streams[i]->codec;
+-        if (ctx->codec_type == AVMEDIA_TYPE_VIDEO)
++        auto par = m_pFormatContext->streams[i]->codecpar;
++        if (par->codec_type == AVMEDIA_TYPE_VIDEO)
+         {
+-            if (!preferEmbeddedMetadata || !isStillImageCodec(ctx->codec_id))
++            if (!preferEmbeddedMetadata || !isStillImageCodec(par->codec_id))
+             {
+                 videoStreams.push_back(i);
+                 continue;
+@@ -203,8 +195,7 @@
+     }
+ 
+     m_pVideoStream = m_pFormatContext->streams[m_VideoStream];
+-    m_pVideoCodecContext = m_pVideoStream->codec;
+-    m_pVideoCodec = avcodec_find_decoder(m_pVideoCodecContext->codec_id);
++    m_pVideoCodec = avcodec_find_decoder(m_pVideoStream->codecpar->codec_id);
+ 
+     if (m_pVideoCodec == nullptr)
+     {
+@@ -214,6 +205,20 @@
+         throw logic_error("Video Codec not found");
+     }
+ 
++    m_pVideoCodecContext = avcodec_alloc_context3(m_pVideoCodec);
++
++    if (m_pVideoCodecContext == nullptr)
++    {
++        destroy();
++        throw logic_error("Could not allocate video codec context");
++    }
++
++    if (avcodec_parameters_to_context(m_pVideoCodecContext, m_pVideoStream->codecpar) < 0)
++    {
++        destroy();
++        throw logic_error("Could not configure video codec context");
++    }
++
+     m_pVideoCodecContext->workaround_bugs = 1;
+ 
+     if (avcodec_open2(m_pVideoCodecContext, m_pVideoCodec, nullptr) < 0)
+@@ -386,13 +391,6 @@
+ 
+ void MovieDecoder::initializeFilterGraph(const AVRational& timeBase, const std::string& size, bool maintainAspectRatio)
+ {
+-    static const AVPixelFormat pixelFormats[] = { AV_PIX_FMT_RGB24, AV_PIX_FMT_NONE };
+-
+-    auto del = [] (AVBufferSinkParams* p) { av_freep(p); };
+-    std::unique_ptr<AVBufferSinkParams, decltype(del)> buffersinkParams(av_buffersink_params_alloc(), del);
+-
+-    avfilter_register_all();
+-
+     m_pFilterGraph = avfilter_graph_alloc();
+     assert(m_pFilterGraph);
+ 
+@@ -404,10 +402,8 @@
+ 
+     checkRc(avfilter_graph_create_filter(&m_pFilterSource, avfilter_get_by_name("buffer"), "thumb_buffer", ss.str().c_str(), nullptr, m_pFilterGraph),
+             "Failed to create filter source");
+-    buffersinkParams->pixel_fmts = pixelFormats;
+-    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, buffersinkParams.get(), m_pFilterGraph),
++    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, nullptr, m_pFilterGraph),
+             "Failed to create filter sink");
+-    buffersinkParams.release();
+ 
+     AVFilterContext* yadifFilter = nullptr;
+     if (m_pFrame->interlaced_frame != 0)
+@@ -500,15 +496,15 @@
+     }
+ 
+     checkRc(av_seek_frame(m_pFormatContext, -1, timestamp, 0), "Seeking in video failed");
+-    avcodec_flush_buffers(m_pFormatContext->streams[m_VideoStream]->codec);
++    avcodec_flush_buffers(m_pVideoCodecContext);
+ 
+     int keyFrameAttempts = 0;
+-    bool gotFrame = 0;
++    bool gotFrame;
+ 
+     do
+     {
+         int count = 0;
+-        gotFrame = 0;
++        gotFrame = false;
+ 
+         while (!gotFrame && count < 20)
+         {
+@@ -552,17 +548,33 @@
+         return false;
+     }
+ 
+-    av_frame_unref(m_pFrame);
+-
+-    int frameFinished;
++    int rc = avcodec_send_packet(m_pVideoCodecContext, m_pPacket);
++    if(rc == AVERROR(EAGAIN))
++    {
++        rc = 0;
++    }
+ 
+-    int bytesDecoded = avcodec_decode_video2(m_pVideoCodecContext, m_pFrame, &frameFinished, m_pPacket);
+-    if (bytesDecoded < 0)
++    if(rc == AVERROR_EOF)
++    {
++        return false;
++    }
++    else if(rc < 0)
+     {
+-        throw logic_error("Failed to decode video frame: bytesDecoded < 0");
++        throw logic_error("Failed to decode video frame: avcodec_send_packet() < 0");
+     }
+ 
+-    return frameFinished > 0;
++    rc = avcodec_receive_frame(m_pVideoCodecContext, m_pFrame);
++    switch(rc)
++    {
++        case 0:
++            return true;
++
++        case AVERROR(EAGAIN):
++            return false;
++
++        default:
++            throw logic_error("Failed to decode video frame: avcodec_receive_frame() < 0");
++    }
+ }
+ 
+ bool MovieDecoder::getVideoPacket()
+@@ -570,8 +582,6 @@
+     bool framesAvailable = true;
+     bool frameDecoded = false;
+ 
+-    int attempts = 0;
+-
+     if (m_pPacket)
+     {
+         av_packet_unref(m_pPacket);
+@@ -580,6 +590,7 @@
+ 
+     m_pPacket = new AVPacket();
+ 
++
+     while (framesAvailable && !frameDecoded)
+     {
+         framesAvailable = av_read_frame(m_pFormatContext, m_pPacket) >= 0;
+@@ -644,7 +655,7 @@
+ 
+ int32_t MovieDecoder::getStreamRotation()
+ {
+-    int32_t* matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
++    auto matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
+     if (matrix)
+     {
+         auto angle = lround(av_display_rotation_get(matrix));
+
+--- a/libffmpegthumbnailer/moviedecoder.h	2017-11-12 04:23:38.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.h	2023-05-05 13:26:07.095529911 -0400
+@@ -78,7 +78,7 @@
+     int                     m_VideoStream;
+     AVFormatContext*        m_pFormatContext;
+     AVCodecContext*         m_pVideoCodecContext;
+-    AVCodec*                m_pVideoCodec;
++    const AVCodec*          m_pVideoCodec;
+     AVFilterGraph*          m_pFilterGraph;
+     AVFilterContext*        m_pFilterSource;
+     AVFilterContext*        m_pFilterSink;
diff --git a/srcpkgs/ffmpegthumbnailer/template b/srcpkgs/ffmpegthumbnailer/template
index 039eea7622b39..35d546018d12a 100644
--- a/srcpkgs/ffmpegthumbnailer/template
+++ b/srcpkgs/ffmpegthumbnailer/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbnailer'
 pkgname=ffmpegthumbnailer
 version=2.2.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libpng-devel libjpeg-turbo-devel ffmpeg-devel"
@@ -9,8 +9,8 @@ depends="ffmpeg"
 short_desc="Lightweight video thumbnailer"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
-homepage="https://github.com/dirkvdb/${pkgname}"
-distfiles="${homepage}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
+homepage="https://github.com/dirkvdb"
+distfiles="${homepage}/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
 checksum=1cb24059c38223f657b300c84dd80491b7040d4b69471c4fea69be862bc99b5b
 
 post_install() {

From fd34c4970287d94c78c46b1a6f6a3a39fadfd392 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 028/113] ffmpegthumbs: revbump for ffmpeg6

---
 srcpkgs/ffmpegthumbs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ffmpegthumbs/template b/srcpkgs/ffmpegthumbs/template
index 5f0b9414dadaf..11b88193528f4 100644
--- a/srcpkgs/ffmpegthumbs/template
+++ b/srcpkgs/ffmpegthumbs/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbs'
 pkgname=ffmpegthumbs
 version=22.12.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules kcoreaddons kconfig-devel
  pkg-config qt5-host-tools qt5-qmake gettext"

From 0b69e20273935cd5312407a659b57fdf28100119 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 029/113] ffms2: revbump for ffmpeg6

---
 srcpkgs/ffms2/patches/ffmpeg5.patch | 424 ++++++++++++++++++++++++++++
 srcpkgs/ffms2/template              |   2 +-
 2 files changed, 425 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ffms2/patches/ffmpeg5.patch

diff --git a/srcpkgs/ffms2/patches/ffmpeg5.patch b/srcpkgs/ffms2/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..1479fabcafcb4
--- /dev/null
+++ b/srcpkgs/ffms2/patches/ffmpeg5.patch
@@ -0,0 +1,424 @@
+From 45673149e9a2f5586855ad472e3059084eaa36b1 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:41:21 +0100
+Subject: [PATCH] Use auto for AVCodec
+
+The geniuses over at FFmpeg decided to constify this API, so old
+versions of the library will return AVCodec *, while new versions
+of the libary will return const AVCodec *, which, in C++, are not
+OK to convert between.
+
+Rather than use some macro hell in ffmscompat.h, we can work around
+this by using auto.
+
+Gross.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 2 +-
+ src/core/indexing.cpp    | 6 +++---
+ src/core/videosource.cpp | 2 +-
+ 3 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index e4ce97c..ac09666 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -469,7 +469,7 @@ void FFMS_AudioSource::OpenFile() {
+ 
+     LAVFOpenFile(SourceFile.c_str(), FormatContext, TrackNumber);
+ 
+-    AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
++    auto *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
+     if (Codec == nullptr)
+         throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+             "Audio codec not found");
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index e547c5a..59fb4e8 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -384,7 +384,7 @@ FFMS_TrackType FFMS_Indexer::GetTrackType(int Track) {
+ }
+ 
+ const char *FFMS_Indexer::GetTrackCodec(int Track) {
+-    AVCodec *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
++    auto *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
+     return codec ? codec->name : nullptr;
+ }
+ 
+@@ -402,7 +402,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             UseDTS);
+ 
+         if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            AVCodec *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (!VideoCodec) {
+                 FormatContext->streams[i]->discard = AVDISCARD_ALL;
+                 IndexMask.erase(i);
+@@ -433,7 +433,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 IndexMask.insert(i);
+             }
+         } else if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+-            AVCodec *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (AudioCodec == nullptr)
+                 throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_UNSUPPORTED,
+                     "Audio codec not found");
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index b889970..8956c22 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -171,7 +171,7 @@ FFMS_VideoSource::FFMS_VideoSource(const char *SourceFile, FFMS_Index &Index, in
+ 
+         LAVFOpenFile(SourceFile, FormatContext, VideoTrack);
+ 
+-        AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
++        auto *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
+         if (Codec == nullptr)
+             throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+                 "Video codec not found");
+-- 
+2.40.0
+
+From 96cbf38ea9381829a1314f432a2c60495dcefaad Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:12:41 +0100
+Subject: [PATCH] all: Update AVPacket API usage
+
+AVPackets must all be on the heap now, since it is no longer
+part of the libav* ABI.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 16 ++++++----
+ src/core/indexing.cpp    | 63 ++++++++++++++++++++++------------------
+ src/core/indexing.h      |  4 +--
+ src/core/utils.cpp       |  6 ----
+ src/core/utils.h         |  1 -
+ src/core/videosource.cpp | 30 ++++++++++---------
+ 6 files changed, 64 insertions(+), 56 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index 37cf9ae..e4ce97c 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -285,10 +285,15 @@ FFMS_AudioSource::AudioBlock *FFMS_AudioSource::CacheBlock(CacheIterator &pos) {
+ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     CurrentFrame = &Frames[PacketNumber];
+ 
+-    AVPacket Packet;
+-    if (!ReadPacket(&Packet))
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++    if (!ReadPacket(Packet)) {
++        av_packet_free(&Packet);
+         throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_UNKNOWN,
+             "ReadPacket unexpectedly failed to read a packet");
++    }
+ 
+     // ReadPacket may have changed the packet number
+     CurrentFrame = &Frames[PacketNumber];
+@@ -297,8 +302,9 @@ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     int NumberOfSamples = 0;
+     AudioBlock *CachedBlock = nullptr;
+     
+-    int Ret = avcodec_send_packet(CodecContext, &Packet);
+-    av_packet_unref(&Packet);
++    int Ret = avcodec_send_packet(CodecContext, Packet);
++    av_packet_unref(Packet);
++    av_packet_free(&Packet);
+ 
+     av_frame_unref(DecodeFrame);
+     Ret = avcodec_receive_frame(CodecContext, DecodeFrame);
+@@ -513,8 +519,6 @@ void FFMS_AudioSource::Seek() {
+ }
+ 
+ bool FFMS_AudioSource::ReadPacket(AVPacket *Packet) {
+-    InitNullPacket(*Packet);
+-
+     while (av_read_frame(FormatContext, Packet) >= 0) {
+         if (Packet->stream_index == TrackNumber) {
+             // Required because not all audio packets, especially in ogg, have a pts. Use the previous valid packet's pts instead.
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index 23fb95b..e547c5a 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -320,7 +320,7 @@ void FFMS_Indexer::CheckAudioProperties(int Track, AVCodecContext *Context) {
+     }
+ }
+ 
+-void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict,
++void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict,
+                                     int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct) {
+     if (VideoContext.Parser) {
+         uint8_t *OB;
+@@ -330,8 +330,8 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+         av_parser_parse2(VideoContext.Parser,
+             VideoContext.CodecContext,
+             &OB, &OBSize,
+-            pkt.data, pkt.size,
+-            pkt.pts, pkt.dts, pkt.pos);
++            pkt->data, pkt->size,
++            pkt->pts, pkt->dts, pkt->pos);
+ 
+         // H.264 (PAFF) and HEVC may have one field per packet, so we need to track
+         // when we have a full or half frame available, and mark one of them as
+@@ -351,15 +351,15 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+ 
+         *RepeatPict = VideoContext.Parser->repeat_pict;
+         *FrameType = VideoContext.Parser->pict_type;
+-        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt.flags & AV_PKT_FLAG_DISCARD));
++        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt->flags & AV_PKT_FLAG_DISCARD));
+     } else {
+-        *Invisible = !!(pkt.flags & AV_PKT_FLAG_DISCARD);
++        *Invisible = !!(pkt->flags & AV_PKT_FLAG_DISCARD);
+     }
+ 
+     if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP8)
+-        ParseVP8(pkt.data[0], Invisible, FrameType);
++        ParseVP8(pkt->data[0], Invisible, FrameType);
+     else if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP9)
+-        ParseVP9(pkt.data[0], Invisible, FrameType);
++        ParseVP9(pkt->data[0], Invisible, FrameType);
+ }
+ 
+ void FFMS_Indexer::Free() {
+@@ -458,32 +458,36 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+         }
+     }
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
+     std::vector<int64_t> LastValidTS(FormatContext->nb_streams, AV_NOPTS_VALUE);
+ 
+     int64_t filesize = avio_size(FormatContext->pb);
+     enum AVPictureStructure LastPicStruct = AV_PICTURE_STRUCTURE_UNKNOWN;
+-    while (av_read_frame(FormatContext, &Packet) >= 0) {
++    while (av_read_frame(FormatContext, Packet) >= 0) {
+         // Update progress
+         // FormatContext->pb can apparently be NULL when opening images.
+         if (IC && FormatContext->pb) {
+-            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate))
++            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate)) {
++                av_packet_free(&Packet);
+                 throw FFMS_Exception(FFMS_ERROR_CANCELLED, FFMS_ERROR_USER,
+                     "Cancelled by user");
++            }
+         }
+-        if (!IndexMask.count(Packet.stream_index)) {
+-            av_packet_unref(&Packet);
++        if (!IndexMask.count(Packet->stream_index)) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+-        int Track = Packet.stream_index;
++        int Track = Packet->stream_index;
+         FFMS_Track &TrackInfo = (*TrackIndices)[Track];
+-        bool KeyFrame = !!(Packet.flags & AV_PKT_FLAG_KEY);
++        bool KeyFrame = !!(Packet->flags & AV_PKT_FLAG_KEY);
+         ReadTS(Packet, LastValidTS[Track], (*TrackIndices)[Track].UseDTS);
+ 
+         if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            int64_t PTS = TrackInfo.UseDTS ? Packet.dts : Packet.pts;
++            int64_t PTS = TrackInfo.UseDTS ? Packet->dts : Packet->pts;
+             if (PTS == AV_NOPTS_VALUE) {
+                 // VPx alt-refs are output as packets which lack timestmps or durations, since
+                 // they are invisible. Currently, the timestamp mangling code in libavformat
+@@ -495,9 +499,11 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 // FFMS2 currently sorts packets by PTS, which will break decoding, otherwise.
+                 bool HasAltRefs = (FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP8 ||
+                                    FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP9);
+-                if (Packet.duration == 0 && !HasAltRefs)
++                if (Packet->duration == 0 && !HasAltRefs) {
++                    av_packet_free(&Packet);
+                     throw FFMS_Exception(FFMS_ERROR_INDEXING, FFMS_ERROR_PARSER,
+                         "Invalid packet pts, dts, and duration");
++                }
+ 
+                 if (TrackInfo.empty())
+                     PTS = 0;
+@@ -513,7 +519,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             ParseVideoPacket(AVContexts[Track], Packet, &RepeatPict, &FrameType, &Invisible, &LastPicStruct);
+ 
+             TrackInfo.AddVideoFrame(PTS, RepeatPict, KeyFrame,
+-                FrameType, Packet.pos, Invisible);
++                FrameType, Packet->pos, Invisible);
+         } else if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+             // For video seeking timestamps are used only if all packets have
+             // timestamps, while for audio they're used if any have timestamps,
+@@ -522,28 +528,29 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 TrackInfo.HasTS = true;
+ 
+             int64_t StartSample = AVContexts[Track].CurrentSample;
+-            uint32_t SampleCount = IndexAudioPacket(Track, &Packet, AVContexts[Track], *TrackIndices);
++            uint32_t SampleCount = IndexAudioPacket(Track, Packet, AVContexts[Track], *TrackIndices);
+             TrackInfo.SampleRate = AVContexts[Track].CodecContext->sample_rate;
+ 
+             TrackInfo.AddAudioFrame(LastValidTS[Track],
+-                StartSample, SampleCount, KeyFrame, Packet.pos, Packet.flags & AV_PKT_FLAG_DISCARD);
++                StartSample, SampleCount, KeyFrame, Packet->pos, Packet->flags & AV_PKT_FLAG_DISCARD);
+         }
+ 
+-        if (!(Packet.flags & AV_PKT_FLAG_DISCARD))
+-            TrackInfo.LastDuration = Packet.duration;
++        if (!(Packet->flags & AV_PKT_FLAG_DISCARD))
++            TrackInfo.LastDuration = Packet->duration;
+ 
+-        av_packet_unref(&Packet);
++        av_packet_unref(Packet);
+     }
++    av_packet_free(&Packet);
+ 
+     TrackIndices->Finalize(AVContexts, FormatContext->iformat->name);
+     return TrackIndices.release();
+ }
+ 
+-void FFMS_Indexer::ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS) {
+-    if (!UseDTS && Packet.pts != AV_NOPTS_VALUE)
+-        TS = Packet.pts;
++void FFMS_Indexer::ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS) {
++    if (!UseDTS && Packet->pts != AV_NOPTS_VALUE)
++        TS = Packet->pts;
+     if (TS == AV_NOPTS_VALUE)
+         UseDTS = true;
+-    if (UseDTS && Packet.dts != AV_NOPTS_VALUE)
+-        TS = Packet.dts;
++    if (UseDTS && Packet->dts != AV_NOPTS_VALUE)
++        TS = Packet->dts;
+ }
+diff --git a/src/core/indexing.h b/src/core/indexing.h
+index 3cfc3c3..5c06868 100644
+--- a/src/core/indexing.h
++++ b/src/core/indexing.h
+@@ -80,10 +80,10 @@ private:
+     int64_t Filesize;
+     uint8_t Digest[20];
+ 
+-    void ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS);
++    void ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS);
+     void CheckAudioProperties(int Track, AVCodecContext *Context);
+     uint32_t IndexAudioPacket(int Track, AVPacket *Packet, SharedAVContext &Context, FFMS_Index &TrackIndices);
+-    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
++    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
+     void Free();
+ public:
+     FFMS_Indexer(const char *Filename);
+diff --git a/src/core/utils.cpp b/src/core/utils.cpp
+index ce67533..8a2e997 100644
+--- a/src/core/utils.cpp
++++ b/src/core/utils.cpp
+@@ -62,12 +62,6 @@ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo) {
+     }
+ }
+ 
+-void InitNullPacket(AVPacket &pkt) {
+-    av_init_packet(&pkt);
+-    pkt.data = nullptr;
+-    pkt.size = 0;
+-}
+-
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames) {
+     AP.SampleFormat = static_cast<FFMS_SampleFormat>(av_get_packed_sample_fmt(CTX->sample_fmt));
+     AP.BitsPerSample = av_get_bytes_per_sample(CTX->sample_fmt) * 8;
+diff --git a/src/core/utils.h b/src/core/utils.h
+index 9819dc7..003ab79 100644
+--- a/src/core/utils.h
++++ b/src/core/utils.h
+@@ -58,7 +58,6 @@ std::unique_ptr<T> make_unique(Args&&... args) {
+ }
+ 
+ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo);
+-void InitNullPacket(AVPacket &pkt);
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames);
+ 
+ void LAVFOpenFile(const char *SourceFile, AVFormatContext *&FormatContext, int Track);
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index 06bd161..b889970 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -673,30 +673,34 @@ void FFMS_VideoSource::DecodeNextFrame(int64_t &AStartTime, int64_t &Pos) {
+     if (HasPendingDelayedFrames())
+         return;
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
+-
+-    while (ReadFrame(&Packet) >= 0) {
+-        if (Packet.stream_index != VideoTrack) {
+-            av_packet_unref(&Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++
++    while (ReadFrame(Packet) >= 0) {
++        if (Packet->stream_index != VideoTrack) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+         if (AStartTime < 0)
+-            AStartTime = Frames.UseDTS ? Packet.dts : Packet.pts;
++            AStartTime = Frames.UseDTS ? Packet->dts : Packet->pts;
+ 
+         if (Pos < 0)
+-            Pos = Packet.pos;
++            Pos = Packet->pos;
+ 
+-        bool FrameFinished = DecodePacket(&Packet);
+-        av_packet_unref(&Packet);
+-        if (FrameFinished)
++        bool FrameFinished = DecodePacket(Packet);
++        av_packet_unref(Packet);
++        if (FrameFinished) {
++            av_packet_free(&Packet);
+             return;
++        }
+     }
+ 
+     // Flush final frames
+-    InitNullPacket(Packet);
+-    DecodePacket(&Packet);
++    DecodePacket(Packet);
++    av_packet_free(&Packet);
+ }
+ 
+ bool FFMS_VideoSource::SeekTo(int n, int SeekOffset) {
+-- 
+2.40.0
+
+From bf9e03e9e08534c024e5a744a6437c4aac160201 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:20:47 +0100
+Subject: [PATCH 2/3] configure: Remove deprecated API use
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ configure.ac | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index b35ef80bc..d19714d0f 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -102,10 +102,10 @@ CFLAGS="$_CFLAGS $FFMPEG_CFLAGS"
+
+ AC_DEFUN([TEST_FFMPEG],
+          [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+-            #include <libavcodec/avcodec.h>
++            #include <libavformat/avformat.h>
+             #include <libswscale/swscale.h>
+             ]],[[
+-                avcodec_register_all();
++                avformat_network_init();
+                 swscale_version();
+             ]])], [eval $1=yes], [eval $1=no])
+         ])
+
diff --git a/srcpkgs/ffms2/template b/srcpkgs/ffms2/template
index 365f64d10cbab..1641ecf43be5b 100644
--- a/srcpkgs/ffms2/template
+++ b/srcpkgs/ffms2/template
@@ -1,7 +1,7 @@
 # Template file for 'ffms2'
 pkgname=ffms2
 version=2.40
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-shared --disable-static"
 hostmakedepends="pkg-config autoconf automake libtool"

From 935a0eac310382df95fe9cd4176c9bebac573e1b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 030/113] freerdp: revbump for ffmpeg6

---
 .../freerdp/patches/ffmpeg6_aa2cb9aa.patch    | 42 +++++++++++++++++++
 srcpkgs/freerdp/template                      |  2 +-
 2 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch

diff --git a/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
new file mode 100644
index 0000000000000..a4324da3a8822
--- /dev/null
+++ b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
@@ -0,0 +1,42 @@
+From aa2cb9aa5ff5562433598ba168a466e0752bca0e Mon Sep 17 00:00:00 2001
+From: akallabeth <akallabeth@posteo.net>
+Date: Tue, 14 Feb 2023 07:48:54 +0100
+Subject: [PATCH] Fixed #8686: Update h264 to use new FFMPEG API
+
+---
+ channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c | 2 ++
+ libfreerdp/codec/h264_ffmpeg.c            | 2 ++
+ 2 files changed, 4 insertions(+)
+
+diff --git a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+index 339462d865f..beea80b7a1e 100644
+--- a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
++++ b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+@@ -239,8 +239,10 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYP
+ 		}
+ 	}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 	if (mdecoder->codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		mdecoder->codec_context->flags |= AV_CODEC_FLAG_TRUNCATED;
++#endif
+ 
+ 	return TRUE;
+ }
+diff --git a/libfreerdp/codec/h264_ffmpeg.c b/libfreerdp/codec/h264_ffmpeg.c
+index 8a23db2473c..896a333019b 100644
+--- a/libfreerdp/codec/h264_ffmpeg.c
++++ b/libfreerdp/codec/h264_ffmpeg.c
+@@ -615,10 +615,12 @@ static BOOL libavcodec_init(H264_CONTEXT* h264)
+ 			goto EXCEPTION;
+ 		}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 		if (sys->codecDecoder->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		{
+ 			sys->codecDecoderContext->flags |= AV_CODEC_FLAG_TRUNCATED;
+ 		}
++#endif
+ 
+ #ifdef WITH_VAAPI
+ 
diff --git a/srcpkgs/freerdp/template b/srcpkgs/freerdp/template
index f36c38ca885b3..97b1d5ea519cd 100644
--- a/srcpkgs/freerdp/template
+++ b/srcpkgs/freerdp/template
@@ -1,7 +1,7 @@
 # Template file for 'freerdp'
 pkgname=freerdp
 version=2.10.0
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DWITH_ALSA=ON -DWITH_CUPS=OFF -DWITH_FFMPEG=ON
  -DWITH_GSTREAMER_0_10=OFF -DWITH_GSTREAMER_1_0=OFF -DWITH_JPEG=ON

From 2386707009eeccd13bba1623183c039e0bdd29cd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 031/113] gerbera: revbump for ffmpeg6

---
 srcpkgs/gerbera/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gerbera/template b/srcpkgs/gerbera/template
index ae14f35c767c0..2dc0ac0ce03b5 100644
--- a/srcpkgs/gerbera/template
+++ b/srcpkgs/gerbera/template
@@ -1,7 +1,7 @@
 # Template file for 'gerbera'
 pkgname=gerbera
 version=1.12.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_SYSTEMD=0 -DWITH_AVCODEC=1"
 hostmakedepends="pkg-config"

From 8cdb1421934ebe66ac4b95ab6df3ee979c8bed09 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 032/113] goldendict: revbump for ffmpeg6

---
 srcpkgs/goldendict/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/goldendict/template b/srcpkgs/goldendict/template
index f4a05759f693d..97f44347b03a6 100644
--- a/srcpkgs/goldendict/template
+++ b/srcpkgs/goldendict/template
@@ -1,7 +1,7 @@
 # Template file for 'goldendict'
 pkgname=goldendict
 version=1.5.0
-revision=1
+revision=2
 build_style=qmake
 configure_args="CONFIG+=zim_support goldendict.pro"
 hostmakedepends="qt5-qmake pkg-config qt5-host-tools"
@@ -10,7 +10,7 @@ makedepends="tiff-devel qt5-devel libvorbis-devel zlib-devel
  qt5-webkit-devel lzo-devel bzip2-devel libao-devel qt5-svg-devel
  libeb-devel qt5-x11extras-devel ffmpeg-devel liblzma-devel
  qt5-multimedia-devel"
-short_desc="A feature-rich dictionary lookup program"
+short_desc="Feature-rich dictionary lookup program"
 maintainer="John <me@johnnynator.dev>"
 license="GPL-3.0-or-later"
 homepage="http://goldendict.org/"

From 4caf7399d852b4a0bb3e7de33e5c9af36133df0a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 033/113] gst-libav: revbump for ffmpeg6

---
 srcpkgs/gst-libav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index b24be23fc1a6d..0f9350a251bf6 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.22.9
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"

From 69e6f3e715f90a00ba8971e06b8feb4c80484e6a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Feb 2024 01:52:46 -0500
Subject: [PATCH 034/113] gst-bad: revbump for ffmpeg6

---
 srcpkgs/gst-plugins-bad1/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index 4fe7053c359c3..63200e74f99a7 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -27,7 +27,7 @@ makedepends="alsa-lib-devel celt-devel openssl-devel exempi-devel
  fdk-aac-devel flite-devel fluidsynth-devel liblrdf-devel ladspa-sdk
  lilv-devel lv2 libopenjpeg2-devel sbc-devel spandsp-devel vulkan-loader
  Vulkan-Headers webrtc-audio-processing-devel libzbar-devel ffmpeg-devel
- srt-devel libva-devel
+ srt-devel libva-devel oneVPL-devel
  $(vopt_if gme libgme-devel)"
 depends="gst-plugins-base1>=${version}"
 short_desc="GStreamer plugins from the bad set (v1.x)"

From 041d8473caae2e02acbadbed4ad69e0fecd0dee3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 035/113] gst-rtsp-server: revbump for ffmpeg6

---
 srcpkgs/gst-rtsp-server/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index bc2a0dea6ac15..f77026c618eb6 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
 version=1.22.9
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="glib-devel gst-plugins-bad1-devel gobject-introspection

From 25bb3d4825f98033ba214766dac9f0c25b4d3c6a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 036/113] guvcview: update to 2.0.8.

---
 srcpkgs/guvcview/patches/fix-include.patch | 10 ++++++++++
 srcpkgs/guvcview/template                  |  7 +++----
 2 files changed, 13 insertions(+), 4 deletions(-)
 create mode 100644 srcpkgs/guvcview/patches/fix-include.patch

diff --git a/srcpkgs/guvcview/patches/fix-include.patch b/srcpkgs/guvcview/patches/fix-include.patch
new file mode 100644
index 0000000000000..503c2af3b78c1
--- /dev/null
+++ b/srcpkgs/guvcview/patches/fix-include.patch
@@ -0,0 +1,10 @@
+--- a/guvcview/guvcview.c
++++ b/guvcview/guvcview.c
+@@ -28,6 +28,7 @@
+ #include <sys/stat.h>
+ #include <sys/resource.h>
+ #include <errno.h>
++#include <locale.h>
+ 
+ #include "gview.h"
+ #include "gviewv4l2core.h"
diff --git a/srcpkgs/guvcview/template b/srcpkgs/guvcview/template
index d42fd38fa4ad1..86a7fd619612c 100644
--- a/srcpkgs/guvcview/template
+++ b/srcpkgs/guvcview/template
@@ -1,8 +1,7 @@
 # Template file for 'guvcview'
 pkgname=guvcview
-version=2.0.7
-revision=2
-create_wrksrc=yes
+version=2.0.8
+revision=1
 build_style=gnu-configure
 configure_args="--disable-static --disable-debian-menu"
 hostmakedepends="pkg-config intltool autoconf automake libtool glib-devel"
@@ -14,7 +13,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="http://guvcview.sourceforge.net/"
 distfiles="${SOURCEFORGE_SITE}/${pkgname}/${pkgname}-src-${version}.tar.bz2"
-checksum=f47d51fbd06e44eeaa1a82f4a153c927527c90d94514197a70b2956028cc8ad4
+checksum=a21f4e448286666cf27bafef5290cc953a0a1796b752e5bbe521266dc1230c81
 
 post_patch() {
 	sed '31a#include <locale.h>' -i  guvcview/guvcview.c

From bb63dd1b7f3a3db311c0c026b958cd96e224ee00 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 037/113] handbrake: update to 1.6.1

---
 .../patches/fix-missing-x265-link-flag.patch    | 11 ++++++-----
 .../handbrake/patches/libhb-vpl-include.patch   | 15 +++++++++++++++
 srcpkgs/handbrake/template                      | 17 ++++++++++-------
 3 files changed, 31 insertions(+), 12 deletions(-)
 create mode 100644 srcpkgs/handbrake/patches/libhb-vpl-include.patch

diff --git a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
index 26db03867a0c8..d6bb2eda627a3 100644
--- a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
+++ b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
@@ -1,14 +1,15 @@
 --- a/gtk/configure.ac
 +++ b/gtk/configure.ac
 @@ -203,7 +203,7 @@
- 
+
  AM_CONDITIONAL([MINGW], [test "x$mingw_flag" = "xyes"])
- 
--HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg"
-+HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -ldl"
+
+-HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc"
++HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc -ldl"
  HB_CPPFLAGS="$HB_CPPFLAGS $HBINC"
- 
+
  PKG_CHECK_MODULES([x264], [x264], sys_x264=yes, sys_x264=no)
+
 --- a/test/module.defs
 +++ b/test/module.defs
 @@ -69,6 +69,9 @@
diff --git a/srcpkgs/handbrake/patches/libhb-vpl-include.patch b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
new file mode 100644
index 0000000000000..298f9f4ab28f2
--- /dev/null
+++ b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
@@ -0,0 +1,15 @@
+--- a/libhb/module.defs	2023-01-22 11:36:49.000000000 -0500
++++ b/libhb/module.defs	2023-04-03 22:37:52.395467010 -0400
+@@ -46,11 +46,7 @@
+ LIBHB.GCC.I += $(LIBHB.build/) $(CONTRIB.build/)include
+ 
+ ifeq (1,$(FEATURE.qsv))
+-    ifeq ($(HOST.system),freebsd))
+-        LIBHB.GCC.I += $(LOCALBASE)/include/vpl
+-    else
+-        LIBHB.GCC.I += $(CONTRIB.build/)include/vpl
+-    endif
++    LIBHB.GCC.I += /usr/include/vpl
+ endif
+ 
+ ifneq (,$(filter $(HOST.system),freebsd netbsd openbsd))
diff --git a/srcpkgs/handbrake/template b/srcpkgs/handbrake/template
index ca5e4571e49c3..c32cb1bfa31f4 100644
--- a/srcpkgs/handbrake/template
+++ b/srcpkgs/handbrake/template
@@ -1,10 +1,10 @@
 # Template file for 'handbrake'
 pkgname=handbrake
-version=1.5.1
+version=1.6.1
 revision=1
 build_style=gnu-configure
 configure_args="--force --disable-gtk-update-checks --disable-df-fetch --harden
- $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc)"
+ $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc) $(vopt_enable qsv)"
 make_build_args="-C ${XBPS_TRIPLET}"
 make_install_args="-C ${XBPS_TRIPLET}"
 hostmakedepends="automake cmake gettext-devel glib-devel intltool libtool m4 meson nasm pkg-config python3"
@@ -12,8 +12,11 @@ makedepends="bzip2-devel ffmpeg-devel gst-plugins-base1-devel gtk+3-devel
  jansson-devel lame-devel libass-devel libbluray-devel libdav1d-devel
  libdvdnav-devel libdvdread-devel libgudev-devel libnuma-devel
  libsamplerate-devel libtheora-devel libvorbis-devel libvpx-devel libxml2-devel
- opus-devel speex-devel x264-devel x265-devel zimg-devel
+ opus-devel speex-devel x264-devel x265-devel zimg-devel libsvt-av1-devel
  $(vopt_if fdk_aac fdk-aac-devel)
+ $(vopt_if qsv libva-devel)
+ $(vopt_if qsv libdrm-devel)
+ $(vopt_if qsv onevpl-devel)
  $(vopt_if nvenc nv-codec-headers)"
 depends="desktop-file-utils gst-plugins-good1 hicolor-icon-theme"
 short_desc="Multithreaded video transcoder"
@@ -21,15 +24,15 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-2.0-only"
 homepage="https://handbrake.fr/"
 distfiles="https://github.com/HandBrake/HandBrake/releases/download/${version}/HandBrake-${version}-source.tar.bz2"
-checksum=3999fe06d5309c819799a73a968a8ec3840e7840c2b64af8f5cdb7fd8c9430f0
+checksum=94ccfe03db917a91650000c510f7fd53f844da19f19ad4b4be1b8f6bc31a8d4c
 nocross=yes
 
-build_options="fdk_aac nvenc"
+build_options="fdk_aac nvenc qsv"
 
 case "$XBPS_TARGET_MACHINE" in
 	x86_64*|i686*)
 		CFLAGS="-msse"
-		build_options_default="nvenc"
+		build_options_default="nvenc qsv"
 		;;
 esac
 
@@ -37,7 +40,7 @@ pre_configure() {
 	# use system libraries, don't download them
 	rm -rf contrib/
 	for module in fdk-aac ffmpeg libbluray libdav1d libdvdnav libdvdread nvenc \
-		x265 zimg; do
+		x265 zimg svt-av1 libvpl; do
 	    vsed -i "/MODULES += contrib\/${module}/d" make/include/main.defs
 	done
 }

From 5b236905436909ce5ca4b5750f45776e202877ce Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 038/113] hedgewars: revbump for ffmpeg4

---
 srcpkgs/hedgewars/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/hedgewars/template b/srcpkgs/hedgewars/template
index 94b6db673b0c3..402ccfaaecbc2 100644
--- a/srcpkgs/hedgewars/template
+++ b/srcpkgs/hedgewars/template
@@ -1,13 +1,13 @@
 # Template file for 'hedgewars'
 pkgname=hedgewars
 version=1.0.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DNOSERVER=1 -DDATA_INSTALL_DIR=/usr/share/${pkgname}
  -DPHYSFS_SYSTEM=1 -DMINIMAL_FLAGS=1"
 make_cmd=make
 hostmakedepends="lua51 pkg-config qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
+makedepends="ffmpeg4-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
  SDL2_mixer-devel SDL2_net-devel SDL2_ttf-devel"
 depends="libfreeglut"
 short_desc="Funny turn-based artillery game, featuring fighting Hedgehogs!"

From 974e2cbe863dfc9c8b778528716c3dde4342b54c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 039/113] idjc: revbump for ffmpeg4

---
 srcpkgs/idjc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/idjc/template b/srcpkgs/idjc/template
index a9cde0665d55b..f41e1e4fabbae 100644
--- a/srcpkgs/idjc/template
+++ b/srcpkgs/idjc/template
@@ -1,11 +1,11 @@
 # Template file for 'idjc'
 pkgname=idjc
 version=0.9.1
-revision=5
+revision=6
 build_style=gnu-configure
 hostmakedepends="pkg-config git python3 automake gettext-devel libtool"
 makedepends="libvorbis-devel libogg-devel jack-devel libsamplerate-devel
- libflac-devel libsndfile-devel mpg123-devel ffmpeg-devel speex-devel
+ libflac-devel libsndfile-devel mpg123-devel ffmpeg4-devel speex-devel
  glib-devel pixman-devel lame-devel python3-gobject-devel libshout-idjc-devel
  opus-devel twolame-devel python3-mutagen python3-devel"
 depends="python3-gobject python3-mutagen desktop-file-utils shared-mime-info python3-dbus jack"

From 8f83cf37d0e9c49f8ad8373eef24c25f0b2b8b15 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 040/113] kid3: revbump for ffmpeg6

---
 srcpkgs/kid3/patches/ffmpeg5.patch | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 srcpkgs/kid3/patches/ffmpeg5.patch

diff --git a/srcpkgs/kid3/patches/ffmpeg5.patch b/srcpkgs/kid3/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..135fc50e07c9b
--- /dev/null
+++ b/srcpkgs/kid3/patches/ffmpeg5.patch
@@ -0,0 +1,17 @@
+# https://aur.archlinux.org/cgit/aur.git/diff/ffmpeg5.patch?h=kid3-cli&id=12410a74906612e7efc0ec8fbce739b4a0fef7e7
+diff --git a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+index e156d424..e12b9abd 100644
+--- a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
++++ b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+@@ -232,7 +232,11 @@ private:
+   friend class Format;
+   friend class Converter;
+   AVCodecContext* m_ptr;
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 0, 0)
+   AVCodec* m_impl;
++#else
++  const AVCodec* m_impl;
++#endif
+   AVFrame* m_frame;
+   bool m_opened;
+ };

From 31f8210421d1eceea66bf01c657b4946d238516a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 041/113] kodi: revbump for ffmpeg4

---
 srcpkgs/kodi/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/kodi/template b/srcpkgs/kodi/template
index d37a5918cd675..ea78e0aca0fe3 100644
--- a/srcpkgs/kodi/template
+++ b/srcpkgs/kodi/template
@@ -1,7 +1,7 @@
 # Template file for 'kodi'
 pkgname=kodi
 version=19.4
-revision=9
+revision=10
 _codename="Matrix"
 build_style=cmake
 configure_args="-DWITH_FFMPEG=/usr -DENABLE_LDGOLD=OFF
@@ -54,7 +54,7 @@ makedepends="
  libmad-devel fontconfig-devel libXinerama-devel libsamplerate-devel libmms-devel
  enca-devel boost-devel libcurl-devel libva-devel libvdpau-devel libass-devel
  libbluetooth-devel yajl-devel libplist-devel librtmp-devel tinyxml-devel
- taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg-devel
+ taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg4-devel
  giflib-devel libxslt-devel gnutls-devel libssh-devel libmicrohttpd-devel
  libcec-devel dcadec-devel flatbuffers-devel fmt-devel lcms2-devel
  libfstrcmp-devel rapidjson libcdio-paranoia spdlog libwaylandpp-devel

From 858710473623cb9f23954f541b0476a84394f199 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 042/113] kpipewire: revbump for ffmpeg6

---
 srcpkgs/kpipewire/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kpipewire/template b/srcpkgs/kpipewire/template
index 6214a4451336e..3555348659dde 100644
--- a/srcpkgs/kpipewire/template
+++ b/srcpkgs/kpipewire/template
@@ -1,7 +1,7 @@
 # Template file for 'kpipewire'
 pkgname=kpipewire
 version=5.27.10
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules plasma-wayland-protocols gettext
  qt5-qmake qt5-host-tools pkg-config wayland-devel kcoreaddons

From 71cff05a9a8e3bded44d6bd671584345bdf587ca Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 043/113] libextractor: revbump for ffmpeg4

---
 srcpkgs/libextractor/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/libextractor/template b/srcpkgs/libextractor/template
index 044c663a3a0b9..06e63bc3189d5 100644
--- a/srcpkgs/libextractor/template
+++ b/srcpkgs/libextractor/template
@@ -1,13 +1,13 @@
 # Template file for 'libextractor'
 pkgname=libextractor
 version=1.11
-revision=4
+revision=5
 build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="pkg-config"
 makedepends="zlib-devel bzip2-devel exiv2-devel tiff-devel libpng-devel
  libjpeg-turbo-devel libvorbis-devel libflac-devel giflib-devel libmpeg2-devel
- ffmpeg-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
+ ffmpeg4-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
 short_desc="Library used to extract meta data from files"
 maintainer="Martin Riese <grauehaare@gmx.de>"
 license="GPL-3.0-or-later"

From 004dba4235283209769cecba3488fca5a346ef4c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 044/113] libopenal: revbump for ffmpeg6

---
 srcpkgs/libopenal/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenal/template b/srcpkgs/libopenal/template
index 88d0f11307d81..8308fca0393e3 100644
--- a/srcpkgs/libopenal/template
+++ b/srcpkgs/libopenal/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenal'
 pkgname=libopenal
 version=1.23.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DALSOFT_EXAMPLES=OFF"
 hostmakedepends="pkg-config"

From b7ec43e68e840a584b7c6f215029801c94f5394b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 045/113] loudgain: revbump for ffmpeg6

---
 srcpkgs/loudgain/patches/ffmpeg5.patch | 11 +++++++++++
 srcpkgs/loudgain/template              |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/loudgain/patches/ffmpeg5.patch

diff --git a/srcpkgs/loudgain/patches/ffmpeg5.patch b/srcpkgs/loudgain/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..16d4510ee98fa
--- /dev/null
+++ b/srcpkgs/loudgain/patches/ffmpeg5.patch
@@ -0,0 +1,11 @@
+--- a/src/scan.c	2019-09-06 11:31:19.000000000 -0400
++++ b/src/scan.c	2023-03-23 11:15:40.867968521 -0400
+@@ -69,8 +69,6 @@
+ 	 * It is now useless
+ 	 * https://github.com/FFmpeg/FFmpeg/blob/70d25268c21cbee5f08304da95be1f647c630c15/doc/APIchanges#L86
+ 	 */
+-  if (avformat_version() < AV_VERSION_INT(58,9,100))
+-    av_register_all();
+ 
+ 	av_log_set_callback(scan_av_log);
+ 
diff --git a/srcpkgs/loudgain/template b/srcpkgs/loudgain/template
index da4f2d56e94c3..4d6bf29efb4fd 100644
--- a/srcpkgs/loudgain/template
+++ b/srcpkgs/loudgain/template
@@ -1,7 +1,7 @@
 # Template file for 'loudgain'
 pkgname=loudgain
 version=0.6.8
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libebur128-devel taglib-devel ffmpeg-devel"

From 7b20a9aa7718f54b95a5a2bed4259ad8f99e8fb8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 046/113] mediastreamer: revbump for ffmpeg4

---
 srcpkgs/mediastreamer/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mediastreamer/template b/srcpkgs/mediastreamer/template
index 0fcffa7653d18..e888626b945e5 100644
--- a/srcpkgs/mediastreamer/template
+++ b/srcpkgs/mediastreamer/template
@@ -1,11 +1,11 @@
 # Template file for 'mediastreamer'
 pkgname=mediastreamer
 version=5.2.111
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DENABLE_STRICT=0 -DENABLE_UNIT_TESTS=0"
 hostmakedepends="python3"
-makedepends="bzrtp-devel ffmpeg-devel glew-devel libXv-devel libsrtp-devel
+makedepends="bzrtp-devel ffmpeg4-devel glew-devel libXv-devel libsrtp-devel
  libupnp-devel libvpx-devel mbedtls-devel opus-devel ortp-devel pulseaudio-devel
  libtheora-devel speex-devel v4l-utils-devel bcg729-devel bcmatroska2-devel libgsm-devel
  zxing-cpp-devel"

From 86a1713041d30f2d8c174c32af4601634dc85277 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 047/113] mgba: revbump for ffmpeg6

---
 srcpkgs/mgba/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mgba/template b/srcpkgs/mgba/template
index 6cd6565031254..93401adb618bd 100644
--- a/srcpkgs/mgba/template
+++ b/srcpkgs/mgba/template
@@ -1,7 +1,7 @@
 # Template file for 'mgba'
 pkgname=mgba
 version=0.10.3
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake desktop-file-utils"
 makedepends="SDL2-devel ffmpeg-devel libedit-devel libepoxy-devel libmagick-devel

From d1dcf4e4f47b2d11e0d1767dc7dc7f330d2616da Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 048/113] mlt: revbump for ffmpeg4

---
 srcpkgs/mlt/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mlt/template b/srcpkgs/mlt/template
index 73e3915aaab9a..d7ed4c4b30a86 100644
--- a/srcpkgs/mlt/template
+++ b/srcpkgs/mlt/template
@@ -1,14 +1,14 @@
 # Template file for 'mlt'
 pkgname=mlt
 version=6.26.1
-revision=3
+revision=4
 build_style=configure
 configure_args="--prefix=/usr --libdir=/usr/lib$XBPS_TARGET_WORDSIZE
  --enable-gpl --enable-gpl3 --disable-swfdec --without-kde
  --swig-languages=python"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which"
 # XXX: movit vid.stab
-makedepends="alsa-lib-devel ffmpeg-devel gtk+-devel jack-devel ladspa-sdk
+makedepends="alsa-lib-devel ffmpeg4-devel gtk+-devel jack-devel ladspa-sdk
  libexif-devel libsamplerate-devel libxml2-devel sox-devel SDL_image-devel
  fftw-devel frei0r-plugins python3-devel pulseaudio-devel movit-devel
  libvidstab-devel"

From 0d13d78301e55e7e5fc7b407fb495f28a66e06eb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 049/113] moc: revbump for ffmpeg4

---
 srcpkgs/moc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/moc/template b/srcpkgs/moc/template
index 3a04932c8f1e6..838755f88db09 100644
--- a/srcpkgs/moc/template
+++ b/srcpkgs/moc/template
@@ -1,10 +1,10 @@
 # Template file for 'moc'
 pkgname=moc
 version=2.5.2
-revision=7
+revision=8
 build_style=gnu-configure
 hostmakedepends="pkg-config"
-makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg-devel
+makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg4-devel
  jack-devel alsa-lib-devel libltdl-devel libflac-devel libvorbis-devel
  libmad-devel libmpcdec-devel libmodplug-devel libid3tag-devel faad2-devel
  taglib-devel libsndfile-devel wavpack-devel speex-devel libsamplerate-devel

From d09cccbef646ffd97b7b37fc36dbe51fcf9d389e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 050/113] motion: revbump for ffmpeg6

---
 srcpkgs/motion/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/motion/template b/srcpkgs/motion/template
index 607ebeb3c7b24..bf63a91d9764f 100644
--- a/srcpkgs/motion/template
+++ b/srcpkgs/motion/template
@@ -1,7 +1,7 @@
 # Template file for 'motion'
 pkgname=motion
 version=4.6.0
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake pkg-config gettext-devel tar"
 makedepends="ffmpeg-devel libmicrohttpd-devel v4l-utils-devel gettext-devel"

From cb3a6e5b077947477ca4b9adf1dd0c82150cf1d0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 051/113] olive: revbump for ffmpeg4

---
 srcpkgs/olive/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/olive/template b/srcpkgs/olive/template
index 12a46936c9900..5c2917b9c5124 100644
--- a/srcpkgs/olive/template
+++ b/srcpkgs/olive/template
@@ -1,10 +1,10 @@
 # Template file for 'olive'
 pkgname=olive
 version=0.1.2
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools pkg-config"
-makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg-devel frei0r-plugins"
+makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg4-devel frei0r-plugins"
 short_desc="Non-linear video editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"

From 185d156673011224d92c38db8223e0df2713a27e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 052/113] opentoonz: revbump for ffmpeg6

---
 srcpkgs/opentoonz/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/opentoonz/template b/srcpkgs/opentoonz/template
index ee9f7603f55fd..3e81834ca0edd 100644
--- a/srcpkgs/opentoonz/template
+++ b/srcpkgs/opentoonz/template
@@ -1,7 +1,7 @@
 # Template file for 'opentoonz'
 pkgname=opentoonz
 version=1.6.0
-revision=2
+revision=3
 build_wrksrc="toonz/sources"
 build_style=cmake
 make_cmd=make

From 2e1af81e7d81bff1f626979c918c3ecb09e800fc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 053/113] pianobar: revbump for ffmpeg6

---
 srcpkgs/pianobar/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pianobar/template b/srcpkgs/pianobar/template
index e3febb821a451..1e3dc1bf9308e 100644
--- a/srcpkgs/pianobar/template
+++ b/srcpkgs/pianobar/template
@@ -1,7 +1,7 @@
 # Template file for 'pianobar'
 pkgname=pianobar
 version=2022.04.01
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="V=1"
 hostmakedepends="pkg-config"

From 3d4828c31688149168fceba5ab36c7f7093182fe Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 054/113] ppsspp: revbump for ffmpeg4

---
 srcpkgs/ppsspp/template | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/srcpkgs/ppsspp/template b/srcpkgs/ppsspp/template
index 2c0ded496eb98..8bf55f65198cd 100644
--- a/srcpkgs/ppsspp/template
+++ b/srcpkgs/ppsspp/template
@@ -1,7 +1,7 @@
 # Template file for 'ppsspp'
 pkgname=ppsspp
 version=1.16.6
-revision=1
+revision=2
 _glslang_commit=b34f619e1c85810dcb3c578107d2e48ba4ee2b37
 _SPIRV_Cross_commit=4212eef67ed0ca048cb726a6767185504e7695e5
 _armips_commit=7bd1ec93d4586985ba1ef420b43b5e620f68695e
@@ -15,7 +15,7 @@ configure_args="-DHEADLESS=1 -DUSE_SYSTEM_FFMPEG=1 -DUNITTEST=ON
  -DUSING_QT_UI=$(vopt_if qt ON OFF) -DUSE_SYSTEM_ZSTD=ON
  -DARMIPS_USE_STD_FILESYSTEM=ON"
 hostmakedepends="pkg-config python3 $(vopt_if qt qt5-host-tools)"
-makedepends="zlib-devel glew-devel ffmpeg-devel libzip-devel
+makedepends="zlib-devel glew-devel ffmpeg4-devel libzip-devel
  snappy-devel rapidjson libpng-devel libzstd-devel
  $(vopt_if sdl2 'SDL2_ttf-devel SDL2-devel') $(vopt_if wayland wayland-devel)
  $(vopt_if qt 'qt5-devel qt5-multimedia-devel')"
@@ -69,10 +69,10 @@ post_extract() {
 	rmdir -v ${wrksrc}/ext/cpu_features
 	mv ${wrksrc}/cpu_features-${_cpu_features_commit} ${wrksrc}/ext/cpu_features
 	rmdir -v ${wrksrc}/ext/rcheevos
-        mv ${wrksrc}/rcheevos-${_rcheevos_commit} ${wrksrc}/ext/rcheevos
+	mv ${wrksrc}/rcheevos-${_rcheevos_commit} ${wrksrc}/ext/rcheevos
 }
 
-post_patch(){
+post_patch() {
 	# disable git versioning
 	vsed -e 's|find_package(Git)|# &|' -i git-version.cmake
 }
@@ -85,7 +85,6 @@ post_configure() {
 }
 
 do_install() {
-	vlicense LICENSE.TXT
 	vinstall icons/icon.svg 644 usr/share/pixmaps ppsspp.svg
 	vinstall Qt/PPSSPP.desktop 644 usr/share/applications
 	vbin build/PPSSPPHeadless ppsspp-headless

From 5d94e12aa154939221102a5bdfe31d8f2cf35f37 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 055/113] pqiv: revbump for ffmpeg6

---
 srcpkgs/pqiv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pqiv/template b/srcpkgs/pqiv/template
index 542fc27a2d32a..9308d949b6a1c 100644
--- a/srcpkgs/pqiv/template
+++ b/srcpkgs/pqiv/template
@@ -1,7 +1,7 @@
 # Template file for 'pqiv'
 pkgname=pqiv
 version=2.12
-revision=1
+revision=2
 build_style=gnu-makefile
 hostmakedepends="pkg-config"
 makedepends="glib-devel gtk+3-devel $(vopt_if ffmpeg ffmpeg-devel)

From 6eb5d080f3e4285400598113e7a95b53617ee69e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 056/113] qmmp: revbump for ffmpeg6

---
 srcpkgs/qmmp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qmmp/template b/srcpkgs/qmmp/template
index 53781ea3bc28a..2da07f1e87eac 100644
--- a/srcpkgs/qmmp/template
+++ b/srcpkgs/qmmp/template
@@ -1,7 +1,7 @@
 # Template file for 'qmmp'
 pkgname=qmmp
 version=1.6.1
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DUSE_HAL:BOOL=FALSE -DQMMP_DEFAULT_UI:STRING=simple"
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From a7940042b7852d2c934b25b23160ee8c3217a20a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 14 Dec 2023 13:28:10 -0500
Subject: [PATCH 057/113] qt6-pdf: revbump for ffmpeg6

---
 srcpkgs/qt6-pdf/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-pdf/template b/srcpkgs/qt6-pdf/template
index ecda84afac131..531b4e1d4fe84 100644
--- a/srcpkgs/qt6-pdf/template
+++ b/srcpkgs/qt6-pdf/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-pdf'
 pkgname=qt6-pdf
 version=6.6.0
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DQT_FEATURE_qtpdf_build=ON
  -DQT_FEATURE_qtpdf_widgets_build=ON

From 4047fcea6d1130bf484594adb797dc488de8c0aa Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 058/113] qt5-webengine: revbump for ffmpeg6

---
 .../chromium-media-filters-cpp14.patch        |  11 ++
 srcpkgs/qt5-webengine/patches/ffmpeg5.patch   | 179 ++++++++++++++++++
 .../qtwebengine-fix-ffmpeg5-build.patch       |  14 ++
 srcpkgs/qt5-webengine/template                |   4 +-
 4 files changed, 206 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/ffmpeg5.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch

diff --git a/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
new file mode 100644
index 0000000000000..04adc540f2cbc
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
@@ -0,0 +1,11 @@
+--- a/src/3rdparty/chromium/media/filters/BUILD.gn	2023-02-27 13:32:59.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/BUILD.gn	2023-04-02 17:21:39.204066384 -0400
+@@ -96,6 +96,8 @@
+     "//ui/gfx/geometry:geometry",
+   ]
+ 
++  cflags_cc = [ "-std=c++14" ]
++
+   libs = []
+ 
+   if (proprietary_codecs) {
diff --git a/srcpkgs/qt5-webengine/patches/ffmpeg5.patch b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..ac55e1634423a
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
@@ -0,0 +1,179 @@
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:57.732547446 -0400
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:09.486478995 -0400
+@@ -57,6 +57,8 @@
+ 
+ namespace {
+ 
++constexpr int64_t kRelativeTsBase = static_cast<int64_t>(0x7ffeffffffffffff);
++
+ void SetAVStreamDiscard(AVStream* stream, AVDiscard discard) {
+   DCHECK(stream);
+   stream->discard = discard;
+@@ -90,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+   if (stream->start_time != kNoFFmpegTimestamp)
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (stream->first_dts != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, stream->first_dts);
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -408,11 +398,11 @@
+   scoped_refptr<DecoderBuffer> buffer;
+ 
+   if (type() == DemuxerStream::TEXT) {
+-    int id_size = 0;
++    size_t id_size = 0;
+     uint8_t* id_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
+ 
+-    int settings_size = 0;
++    size_t settings_size = 0;
+     uint8_t* settings_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
+ 
+@@ -424,7 +414,7 @@
+     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
+                                      side_data.data(), side_data.size());
+   } else {
+-    int side_data_size = 0;
++    size_t side_data_size = 0;
+     uint8_t* side_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
+ 
+@@ -485,7 +475,7 @@
+                                        packet->size - data_offset);
+     }
+ 
+-    int skip_samples_size = 0;
++    size_t skip_samples_size = 0;
+     const uint32_t* skip_samples_ptr =
+         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
+             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
+@@ -1587,6 +1577,8 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++      continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+       lowest_start_time_stream = stream.get();
+@@ -1604,6 +1596,8 @@
+     if (stream && stream->type() == DemuxerStream::VIDEO &&
+         stream->IsEnabled()) {
+       video_stream = stream.get();
++      if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++        continue;
+       if (video_stream->start_time() <= seek_time) {
+         return video_stream;
+       }
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h qtwebengine-5.15.10/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h
+--- a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-07-11 22:12:47.917192788 -0500
+@@ -29,6 +29,7 @@ extern "C" {
+ #include <libavformat/avformat.h>
+ #include <libavformat/avio.h>
+ #include <libavutil/avutil.h>
++#include <libavutil/channel_layout.h>
+ #include <libavutil/imgutils.h>
+ #include <libavutil/log.h>
+ #include <libavutil/mastering_display_metadata.h>
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/audio_file_reader.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/audio_file_reader.cc
+--- a/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -85,7 +85,7 @@ bool AudioFileReader::OpenDemuxer() {
+ }
+ 
+ bool AudioFileReader::OpenDecoder() {
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (codec) {
+     // MP3 decodes to S16P which we don't support, tell it to use S16 instead.
+     if (codec_context_->sample_fmt == AV_SAMPLE_FMT_S16P)
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -329,7 +329,7 @@ bool FFmpegAudioDecoder::ConfigureDecode
+     }
+   }
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec ||
+       avcodec_open2(codec_context_.get(), codec, &codec_options) < 0) {
+     DLOG(ERROR) << "Could not initialize audio decoder: "
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -59,7 +59,6 @@ static int64_t AVIOSeekOperation(void* o
+ }
+ 
+ void FFmpegGlue::InitializeFFmpeg() {
+-  av_register_all();
+ }
+ 
+ static void LogContainer(bool is_local_file,
+@@ -95,9 +94,6 @@ FFmpegGlue::FFmpegGlue(FFmpegURLProtocol
+   // Enable fast, but inaccurate seeks for MP3.
+   format_context_->flags |= AVFMT_FLAG_FAST_SEEK;
+ 
+-  // Ensures we can read out various metadata bits like vp8 alpha.
+-  format_context_->flags |= AVFMT_FLAG_KEEP_SIDE_DATA;
+-
+   // Ensures format parsing errors will bail out. From an audit on 11/2017, all
+   // instances were real failures. Solves bugs like http://crbug.com/710791.
+   format_context_->error_recognition |= AV_EF_EXPLODE;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -391,7 +391,7 @@ bool FFmpegVideoDecoder::ConfigureDecode
+   if (decode_nalus_)
+     codec_context_->flags2 |= AV_CODEC_FLAG2_CHUNKS;
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
+     ReleaseFFmpegResources();
+     return false;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/media_file_checker.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/media_file_checker.cc
+--- a/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -68,7 +68,7 @@ bool MediaFileChecker::Start(base::TimeD
+       auto context = AVStreamToAVCodecContext(format_context->streams[i]);
+       if (!context)
+         continue;
+-      AVCodec* codec = avcodec_find_decoder(cp->codec_id);
++      const AVCodec* codec = avcodec_find_decoder(cp->codec_id);
+       if (codec && avcodec_open2(context.get(), codec, nullptr) >= 0) {
+         auto loop = std::make_unique<FFmpegDecodingLoop>(context.get());
+         stream_contexts[i] = {std::move(context), std::move(loop)};
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc qtwebengine-5.15.10/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc
+--- a/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -203,7 +203,7 @@ int32_t H264DecoderImpl::InitDecode(cons
+   // a pointer |this|.
+   av_context_->opaque = this;
+ 
+-  AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
+   if (!codec) {
+     // This is an indication that FFmpeg has not been initialized or it has not
+     // been compiled/initialized with the correct set of codecs.
diff --git a/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch b/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch
new file mode 100644
index 0000000000000..bc24d5b9a29cb
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch
@@ -0,0 +1,14 @@
+--- a/src/buildtools/configure.json	2023-12-09 11:06:01.503058569 -0500
++++ b/src/buildtools/configure.json	2023-12-09 11:06:14.982361345 -0500
+@@ -779,11 +779,6 @@
+             "type": "warning",
+             "condition": "config.ios && config.simulator && config.device && features.build-qtpdf",
+             "message": "Building fat libray with device and simulator architectures will disable NEON."
+-        },
+-        {
+-            "type": "fatal",
+-            "condition": "features.webengine-system-ffmpeg && !libs.webengine-ffmpeg-support",
+-            "message": "Unmodified ffmpeg >= 5.0 is not supported. Please configure with -qt-webengine-ffmpeg."
+         }
+     ],
+     "summary": [
diff --git a/srcpkgs/qt5-webengine/template b/srcpkgs/qt5-webengine/template
index 8d2df1b5175ba..1687a77eb8a2f 100644
--- a/srcpkgs/qt5-webengine/template
+++ b/srcpkgs/qt5-webengine/template
@@ -1,14 +1,14 @@
 # Template file for 'qt5-webengine'
 pkgname=qt5-webengine
 version=5.15.16
-revision=1
+revision=2
 _version="${version}-lts"
 _chromium_commit=207c2ac45ca3386d153770c6b0d2ea2ec21ca880
 archs="x86_64* i686* armv[67]* ppc64* aarch64*"
 create_wrksrc=yes
 build_style=qmake
 configure_args="--
- -webengine-icu -webengine-ffmpeg -webengine-opus -webengine-webp
+ -webengine-icu -system-ffmpeg -webengine-opus -webengine-webp
  -webengine-pepper-plugins -webengine-printing-and-pdf -webengine-proprietary-codecs
  -webengine-pulseaudio -webengine-spellchecker -webengine-webrtc -webengine-geolocation
  -webengine-kerberos -no-webengine-embedded-build $(vopt_if sndio '' '-no')-webengine-sndio

From 6cd5f92c21ed525c52fb90c1022b36f5d3a70fa2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 059/113] qt5: revbump for ffmpeg6

---
 srcpkgs/qt5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5/template b/srcpkgs/qt5/template
index 3efb7e42d5fd3..27f6d5388cd15 100644
--- a/srcpkgs/qt5/template
+++ b/srcpkgs/qt5/template
@@ -3,9 +3,9 @@
 # revbump libqtxdg after bumping patch version
 pkgname=qt5
 version=5.15.11+20231124
+revision=3
 # commit 4765fa1df7a837db9c1f89c4da0dd76b74bb5fab
 # base repo: https://invent.kde.org/qt/qt/qt5
-revision=2
 build_style=meta
 hostmakedepends="cmake clang17 flex perl glib-devel pkg-config
  python3 re2c ruby which"

From bb1a10255ce9841fc68d5c2293ccaa902294da8d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 060/113] qtav: revbump for ffmpeg4

---
 srcpkgs/qtav/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtav/template b/srcpkgs/qtav/template
index 775d5a139a9ef..aa69e213c984b 100644
--- a/srcpkgs/qtav/template
+++ b/srcpkgs/qtav/template
@@ -1,10 +1,10 @@
 # Template file for 'qtav'
 pkgname=qtav
 version=1.13.0
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel libass-devel libopenal-devel
+makedepends="ffmpeg4-devel libass-devel libopenal-devel
  libva-glx-devel libXv-devel pulseaudio-devel
  qt5-declarative-devel qt5-svg-devel
  qt5-quickcontrols"

From c5a1e8d656742447a1481c1da0512b9c087997d6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 061/113] retroarch: revbump for ffmpeg6

---
 srcpkgs/retroarch/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroarch/template b/srcpkgs/retroarch/template
index cb3125c5dbf1a..c65c26f7bf033 100644
--- a/srcpkgs/retroarch/template
+++ b/srcpkgs/retroarch/template
@@ -1,7 +1,7 @@
 # Template file for 'retroarch'
 pkgname=retroarch
 version=1.16.0.3
-revision=3
+revision=4
 build_style=configure
 configure_args="--prefix=/usr --sysconfdir=/etc --enable-networking
  --enable-udev --disable-builtinflac --disable-builtinglslang

From c5989e5d3f55176e2af0ab878cde9eaf01ce84e7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 062/113] scrcpy: revbump for ffmpeg6

---
 srcpkgs/scrcpy/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/scrcpy/template b/srcpkgs/scrcpy/template
index ac18bc03418ce..f39a7f678ab35 100644
--- a/srcpkgs/scrcpy/template
+++ b/srcpkgs/scrcpy/template
@@ -1,7 +1,7 @@
 # Template file for 'scrcpy'
 pkgname=scrcpy
 version=2.1.1
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcompile_server=false
  -Dprebuilt_server=/usr/share/scrcpy/scrcpy-server-v${version}"

From 26dbd0e56c12ce271a3c86380ea785f1e5fc8557 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 17 Oct 2023 08:54:11 -0400
Subject: [PATCH 063/113] New package: spex-x replaces spek-alternative for
 ffmpeg6

---
 srcpkgs/spek-alternative                      |  1 +
 srcpkgs/{spek-alternative => spek-x}/template | 22 ++++++++++++-------
 2 files changed, 15 insertions(+), 8 deletions(-)
 create mode 120000 srcpkgs/spek-alternative
 rename srcpkgs/{spek-alternative => spek-x}/template (52%)

diff --git a/srcpkgs/spek-alternative b/srcpkgs/spek-alternative
new file mode 120000
index 0000000000000..76648236da701
--- /dev/null
+++ b/srcpkgs/spek-alternative
@@ -0,0 +1 @@
+spek-x
\ No newline at end of file
diff --git a/srcpkgs/spek-alternative/template b/srcpkgs/spek-x/template
similarity index 52%
rename from srcpkgs/spek-alternative/template
rename to srcpkgs/spek-x/template
index d7b55c776b1d4..3ded6c2c323e4 100644
--- a/srcpkgs/spek-alternative/template
+++ b/srcpkgs/spek-x/template
@@ -1,18 +1,18 @@
-# Template file for 'spek-alternative'
-pkgname=spek-alternative
-version=0.8.2.3
-revision=2
+# Template file for 'spek-x'
+pkgname=spek-x
+version=0.9.3
+revision=1
 build_style=gnu-configure
 hostmakedepends="automake gettext-devel intltool libtool pkg-config
  wxWidgets-common wxWidgets-gtk3-devel"
 makedepends="ffmpeg-devel wxWidgets-gtk3-devel"
 depends="ffmpeg"
 short_desc="Acoustic spectrum analyser"
-maintainer="Kartik Singh <kartik.ynwa@gmail.com>"
+maintainer="zlice <zlice555@gmail.com>"
 license="GPL-3.0-or-later"
-homepage="https://github.com/withmorten/spek-alternative"
-distfiles="https://github.com/withmorten/spek-alternative/archive/${version}.tar.gz"
-checksum="007ba4b84a310b078e378aa84c8e80783db5821437a757a488c3ecec377e6b2a"
+homepage="https://github.com/MikeWang000000/spek-x"
+distfiles="https://github.com/MikeWang000000/spek-x/archive/v${version}.tar.gz"
+checksum="7f4b109903333cdd310ab2b9176f0dc49a565891376e281a233d342cedf90ef7"
 
 CXXFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
 
@@ -22,3 +22,9 @@ export WX_CONFIG_NAME="wx-config-gtk3"
 pre_configure() {
 	NOCONFIGURE=1 ./autogen.sh
 }
+
+spek-alternative_package() {
+	depends="spek-x"
+	short_desc+=" - transitional dummy package"
+	build_style=meta
+}

From c6030c0e345b65837567b892c148aa9973d46f78 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 064/113] ssr: revbump for ffmpeg6

---
 .../0001-Fix-build-with-ffmpeg-5.0.patch      | 241 ++++++++++++++++++
 srcpkgs/ssr/template                          |   2 +-
 2 files changed, 242 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ssr/patches/0001-Fix-build-with-ffmpeg-5.0.patch

diff --git a/srcpkgs/ssr/patches/0001-Fix-build-with-ffmpeg-5.0.patch b/srcpkgs/ssr/patches/0001-Fix-build-with-ffmpeg-5.0.patch
new file mode 100644
index 0000000000000..4c069b5a9fc46
--- /dev/null
+++ b/srcpkgs/ssr/patches/0001-Fix-build-with-ffmpeg-5.0.patch
@@ -0,0 +1,241 @@
+From f4cbde38021d9330dc73d2e3dfa8a70da3ff5721 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Bernhard=20Rosenkr=C3=A4nzer?= <bero@lindev.ch>
+Date: Sun, 16 Jan 2022 02:40:04 +0100
+Subject: [PATCH] Fix build with ffmpeg 5.0
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Adapt to ffmpeg 5.0 requiring more const-ness for AVCodec.
+
+Signed-off-by: Bernhard Rosenkränzer <bero@lindev.ch>
+---
+ src/AV/Output/AudioEncoder.cpp |  6 +++---
+ src/AV/Output/AudioEncoder.h   |  4 ++--
+ src/AV/Output/BaseEncoder.cpp  |  4 ++--
+ src/AV/Output/BaseEncoder.h    |  4 ++--
+ src/AV/Output/Muxer.cpp        | 12 ++++++------
+ src/AV/Output/Muxer.h          |  4 ++--
+ src/AV/Output/VideoEncoder.cpp |  6 +++---
+ src/AV/Output/VideoEncoder.h   |  4 ++--
+ 8 files changed, 22 insertions(+), 22 deletions(-)
+
+diff --git a/src/AV/Output/AudioEncoder.cpp b/src/AV/Output/AudioEncoder.cpp
+index 34d015c..cefc2e0 100644
+--- a/src/AV/Output/AudioEncoder.cpp
++++ b/src/AV/Output/AudioEncoder.cpp
+@@ -34,7 +34,7 @@ const std::vector<AudioEncoder::SampleFormatData> AudioEncoder::SUPPORTED_SAMPLE
+ 
+ const unsigned int AudioEncoder::DEFAULT_FRAME_SAMPLES = 1024;
+ 
+-AudioEncoder::AudioEncoder(Muxer* muxer, AVStream* stream, AVCodecContext *codec_context, AVCodec* codec, AVDictionary** options)
++AudioEncoder::AudioEncoder(Muxer* muxer, AVStream* stream, AVCodecContext *codec_context, const AVCodec* codec, AVDictionary** options)
+ 	: BaseEncoder(muxer, stream, codec_context, codec, options) {
+ 
+ #if !SSR_USE_AVCODEC_ENCODE_AUDIO2
+@@ -77,7 +77,7 @@ unsigned int AudioEncoder::GetSampleRate() {
+ }
+ 
+ bool AudioEncoder::AVCodecIsSupported(const QString& codec_name) {
+-	AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
++	const AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
+ 	if(codec == NULL)
+ 		return false;
+ 	if(!av_codec_is_encoder(codec))
+@@ -93,7 +93,7 @@ bool AudioEncoder::AVCodecIsSupported(const QString& codec_name) {
+ 	return false;
+ }
+ 
+-void AudioEncoder::PrepareStream(AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
++void AudioEncoder::PrepareStream(AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
+ 								 unsigned int bit_rate, unsigned int channels, unsigned int sample_rate) {
+ 
+ 	if(channels == 0) {
+diff --git a/src/AV/Output/AudioEncoder.h b/src/AV/Output/AudioEncoder.h
+index c93278c..ae9c82e 100644
+--- a/src/AV/Output/AudioEncoder.h
++++ b/src/AV/Output/AudioEncoder.h
+@@ -40,7 +40,7 @@ private:
+ #endif
+ 
+ public:
+-	AudioEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options);
++	AudioEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options);
+ 	~AudioEncoder();
+ 
+ 	// Returns the required frame size, i.e. the number of samples (for each channel).
+@@ -57,7 +57,7 @@ public:
+ 
+ public:
+ 	static bool AVCodecIsSupported(const QString& codec_name);
+-	static void PrepareStream(AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
++	static void PrepareStream(AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
+ 							  unsigned int bit_rate, unsigned int channels, unsigned int sample_rate);
+ 
+ private:
+diff --git a/src/AV/Output/BaseEncoder.cpp b/src/AV/Output/BaseEncoder.cpp
+index 7c01ef3..4780aaf 100644
+--- a/src/AV/Output/BaseEncoder.cpp
++++ b/src/AV/Output/BaseEncoder.cpp
+@@ -42,7 +42,7 @@ double ParseCodecOptionDouble(const QString& key, const QString& value, double m
+ 	return clamp(value_double, min, max) * multiply;
+ }
+ 
+-BaseEncoder::BaseEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options) {
++BaseEncoder::BaseEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options) {
+ 
+ 	m_muxer = muxer;
+ 	m_stream = stream;
+@@ -157,7 +157,7 @@ void BaseEncoder::IncrementPacketCounter() {
+ 	++lock->m_total_packets;
+ }
+ 
+-void BaseEncoder::Init(AVCodec* codec, AVDictionary** options) {
++void BaseEncoder::Init(const AVCodec* codec, AVDictionary** options) {
+ 
+ 	// open codec
+ 	if(avcodec_open2(m_codec_context, codec, options) < 0) {
+diff --git a/src/AV/Output/BaseEncoder.h b/src/AV/Output/BaseEncoder.h
+index 3d92f29..7f02bbd 100644
+--- a/src/AV/Output/BaseEncoder.h
++++ b/src/AV/Output/BaseEncoder.h
+@@ -51,7 +51,7 @@ private:
+ 	std::atomic<bool> m_should_stop, m_should_finish, m_is_done, m_error_occurred;
+ 
+ protected:
+-	BaseEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options);
++	BaseEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options);
+ 
+ public:
+ 	virtual ~BaseEncoder(); // encoders will be deleted by Muxer, don't delete them yourself!
+@@ -117,7 +117,7 @@ protected:
+ 	void IncrementPacketCounter();
+ 
+ private:
+-	void Init(AVCodec* codec, AVDictionary** options);
++	void Init(const AVCodec* codec, AVDictionary** options);
+ 	void Free();
+ 
+ 	void EncoderThread();
+diff --git a/src/AV/Output/Muxer.cpp b/src/AV/Output/Muxer.cpp
+index ad58380..14650b0 100644
+--- a/src/AV/Output/Muxer.cpp
++++ b/src/AV/Output/Muxer.cpp
+@@ -87,7 +87,7 @@ Muxer::~Muxer() {
+ 
+ VideoEncoder* Muxer::AddVideoEncoder(const QString& codec_name, const std::vector<std::pair<QString, QString> >& codec_options,
+ 									 unsigned int bit_rate, unsigned int width, unsigned int height, unsigned int frame_rate) {
+-	AVCodec *codec = FindCodec(codec_name);
++	const AVCodec *codec = FindCodec(codec_name);
+ 	AVCodecContext *codec_context = NULL;
+ 	AVStream *stream = AddStream(codec, &codec_context);
+ 	VideoEncoder *encoder;
+@@ -111,7 +111,7 @@ VideoEncoder* Muxer::AddVideoEncoder(const QString& codec_name, const std::vecto
+ 
+ AudioEncoder* Muxer::AddAudioEncoder(const QString& codec_name, const std::vector<std::pair<QString, QString> >& codec_options,
+ 									 unsigned int bit_rate, unsigned int channels, unsigned int sample_rate) {
+-	AVCodec *codec = FindCodec(codec_name);
++	const AVCodec *codec = FindCodec(codec_name);
+ 	AVCodecContext *codec_context = NULL;
+ 	AVStream *stream = AddStream(codec, &codec_context);
+ 	AudioEncoder *encoder;
+@@ -194,7 +194,7 @@ unsigned int Muxer::GetQueuedPacketCount(unsigned int stream_index) {
+ void Muxer::Init() {
+ 
+ 	// get the format we want (this is just a pointer, we don't have to free this)
+-	AVOutputFormat *format = av_guess_format(m_container_name.toUtf8().constData(), NULL, NULL);
++	const AVOutputFormat *format = av_guess_format(m_container_name.toUtf8().constData(), NULL, NULL);
+ 	if(format == NULL) {
+ 		Logger::LogError("[Muxer::Init] " + Logger::tr("Error: Can't find chosen output format!"));
+ 		throw LibavException();
+@@ -261,8 +261,8 @@ void Muxer::Free() {
+ 	}
+ }
+ 
+-AVCodec* Muxer::FindCodec(const QString& codec_name) {
+-	AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
++const AVCodec* Muxer::FindCodec(const QString& codec_name) {
++	const AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
+ 	if(codec == NULL) {
+ 		Logger::LogError("[Muxer::FindCodec] " + Logger::tr("Error: Can't find codec!"));
+ 		throw LibavException();
+@@ -270,7 +270,7 @@ AVCodec* Muxer::FindCodec(const QString& codec_name) {
+ 	return codec;
+ }
+ 
+-AVStream* Muxer::AddStream(AVCodec* codec, AVCodecContext** codec_context) {
++AVStream* Muxer::AddStream(const AVCodec* codec, AVCodecContext** codec_context) {
+ 	assert(!m_started);
+ 	assert(m_format_context->nb_streams < MUXER_MAX_STREAMS);
+ 
+diff --git a/src/AV/Output/Muxer.h b/src/AV/Output/Muxer.h
+index d72347d..b104bcb 100644
+--- a/src/AV/Output/Muxer.h
++++ b/src/AV/Output/Muxer.h
+@@ -114,8 +114,8 @@ private:
+ 	void Init();
+ 	void Free();
+ 
+-	AVCodec* FindCodec(const QString& codec_name);
+-	AVStream* AddStream(AVCodec* codec, AVCodecContext** codec_context);
++	const AVCodec* FindCodec(const QString& codec_name);
++	AVStream* AddStream(const AVCodec* codec, AVCodecContext** codec_context);
+ 
+ 	void MuxerThread();
+ 
+diff --git a/src/AV/Output/VideoEncoder.cpp b/src/AV/Output/VideoEncoder.cpp
+index 8087e8e..fc8b5d1 100644
+--- a/src/AV/Output/VideoEncoder.cpp
++++ b/src/AV/Output/VideoEncoder.cpp
+@@ -34,7 +34,7 @@ const std::vector<VideoEncoder::PixelFormatData> VideoEncoder::SUPPORTED_PIXEL_F
+ 	{"rgb", AV_PIX_FMT_RGB24, false},
+ };
+ 
+-VideoEncoder::VideoEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options)
++VideoEncoder::VideoEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options)
+ 	: BaseEncoder(muxer, stream, codec_context, codec, options) {
+ 
+ #if !SSR_USE_AVCODEC_ENCODE_VIDEO2
+@@ -95,7 +95,7 @@ unsigned int VideoEncoder::GetFrameRate() {
+ }
+ 
+ bool VideoEncoder::AVCodecIsSupported(const QString& codec_name) {
+-	AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
++	const AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
+ 	if(codec == NULL)
+ 		return false;
+ 	if(!av_codec_is_encoder(codec))
+@@ -111,7 +111,7 @@ bool VideoEncoder::AVCodecIsSupported(const QString& codec_name) {
+ 	return false;
+ }
+ 
+-void VideoEncoder::PrepareStream(AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
++void VideoEncoder::PrepareStream(AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
+ 								 unsigned int bit_rate, unsigned int width, unsigned int height, unsigned int frame_rate) {
+ 
+ 	if(width == 0 || height == 0) {
+diff --git a/src/AV/Output/VideoEncoder.h b/src/AV/Output/VideoEncoder.h
+index cb7ca27..68d872e 100644
+--- a/src/AV/Output/VideoEncoder.h
++++ b/src/AV/Output/VideoEncoder.h
+@@ -40,7 +40,7 @@ private:
+ #endif
+ 
+ public:
+-	VideoEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options);
++	VideoEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options);
+ 	~VideoEncoder();
+ 
+ 	// Returns the required pixel format.
+@@ -55,7 +55,7 @@ public:
+ 
+ public:
+ 	static bool AVCodecIsSupported(const QString& codec_name);
+-	static void PrepareStream(AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
++	static void PrepareStream(AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
+ 							  unsigned int bit_rate, unsigned int width, unsigned int height, unsigned int frame_rate);
+ 
+ private:
+-- 
+2.43.0
+
diff --git a/srcpkgs/ssr/template b/srcpkgs/ssr/template
index 3097754e3cbe5..e3c4261f1f5a6 100644
--- a/srcpkgs/ssr/template
+++ b/srcpkgs/ssr/template
@@ -1,7 +1,7 @@
 # Template file for 'ssr'
 pkgname=ssr
 version=0.4.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DWITH_QT5=ON"
 hostmakedepends="pkg-config"

From 4c8390afc2f795bb3e422c5e5acdbc809fa0364d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 065/113] synfig: revbump for ffmpeg6 and mlt7

---
 srcpkgs/synfig/patches/ffmpeg6.patch | 71 ++++++++++++++++++++++++++++
 srcpkgs/synfig/template              |  6 +--
 2 files changed, 74 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/synfig/patches/ffmpeg6.patch

diff --git a/srcpkgs/synfig/patches/ffmpeg6.patch b/srcpkgs/synfig/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..10780b42782f4
--- /dev/null
+++ b/srcpkgs/synfig/patches/ffmpeg6.patch
@@ -0,0 +1,71 @@
+--- a/src/modules/mod_libavcodec/trgt_av.cpp	2022-10-25 09:14:12.000000000 -0400
++++ b/src/modules/mod_libavcodec/trgt_av.cpp	2023-05-05 21:34:17.899194559 -0400
+@@ -38,6 +41,7 @@
+ extern "C"
+ {
+ #ifdef HAVE_LIBAVFORMAT_AVFORMAT_H
++#	include <libavcodec/avcodec.h>
+ #	include <libavformat/avformat.h>
+ #elif defined(HAVE_AVFORMAT_H)
+ #	include <avformat.h>
+@@ -155,11 +156,11 @@
+     }
+ 
+ 	bool open_video_stream() {
+-		if (avcodec_open2(video_context, NULL, NULL) < 0) {
++		if (avcodec_open2(video_context, nullptr, nullptr) < 0) {
+ 			synfig::error("Target_LibAVCodec: could not open video codec");
+ 			// seems the calling of avcodec_free_context after error will cause crash
+ 			// so just forget about this context
+-			video_context = NULL;
++			video_context = nullptr;
+ 			close();
+ 			return false;
+         }
+@@ -234,15 +235,21 @@
+ 		close();
+ 
+ 		if (!av_registered) {
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 			av_register_all();
++#endif
+ 			av_registered = true;
+ 		}
+ 
+ 		// guess format
+-		AVOutputFormat *format = av_guess_format(NULL, filename.c_str(), NULL);
++#if LIBAVCODEC_VERSION_MAJOR < 59 // FFMPEG < 5.0
++		AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#else
++		const AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#endif
+ 		if (!format) {
+ 			synfig::warning("Target_LibAVCodec: unable to guess the output format, defaulting to MPEG");
+-			format = av_guess_format("mpeg", NULL, NULL);
++			format = av_guess_format("mpeg", nullptr, nullptr);
+ 		}
+ 		if (!format) {
+ 			synfig::error("Target_LibAVCodec: unable to find 'mpeg' output format");
+@@ -254,6 +261,7 @@
+ 		context = avformat_alloc_context();
+ 		assert(context);
+ 		context->oformat = format;
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 		if (filename.size() + 1 > sizeof(context->filename)) {
+ 			synfig::error(
+ 				"Target_LibAVCodec: filename too long, max length is %d, filename is '%s'",
+@@ -263,6 +271,14 @@
+ 			return false;
+ 		}
+ 		memcpy(context->filename, filename.c_str(), filename.size() + 1);
++#else
++		context->url = av_strndup(filename.c_str(), filename.size());
++		if (!context->url) {
++			synfig::error("Target_LibAVCodec: cannot allocate space for filename");
++			close();
++			return false;
++		}
++#endif
+ 
+ 		packet = av_packet_alloc();
+ 		assert(packet);
diff --git a/srcpkgs/synfig/template b/srcpkgs/synfig/template
index d4d3e341a20bf..828b5cb32956e 100644
--- a/srcpkgs/synfig/template
+++ b/srcpkgs/synfig/template
@@ -2,11 +2,11 @@
 # Should be kept in sync with 'synfigstudio' and 'ETL'
 pkgname=synfig
 version=1.4.4
-revision=4
+revision=5
 build_style=gnu-configure
 configure_args="--with-boost-libdir=${XBPS_CROSS_BASE}/usr/lib"
 hostmakedepends="boost-build ImageMagick pkg-config intltool"
-makedepends="ETL gettext-devel libxml++-devel mlt-devel libmagick-devel
+makedepends="ETL gettext-devel libxml++-devel mlt7-devel libmagick-devel
  libmng-devel boost-build boost-devel libopenexr-devel ffmpeg-devel"
 depends="ImageMagick"
 short_desc="CLI 2D vector and timeline-based animation software"
@@ -20,7 +20,7 @@ CXXFLAGS="-std=c++11 -DHAVE_LOCALE_H=1"
 
 synfig-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision}
-	 libopenexr-devel libxml++-devel mlt-devel"
+	 libopenexr-devel libxml++-devel mlt7-devel"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/bin/synfig-config

From 7baa5a7ec5eda56518aa17a01bfbae149c68d857 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 066/113] timg: revbump for ffmpeg6

---
 srcpkgs/timg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/timg/template b/srcpkgs/timg/template
index 2a2ab763d2fdd..8fb4327535ef9 100644
--- a/srcpkgs/timg/template
+++ b/srcpkgs/timg/template
@@ -1,7 +1,7 @@
 # Template file for 'timg'
 pkgname=timg
 version=1.4.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_OPENSLIDE_SUPPORT=off -Wno-dev"
 hostmakedepends="pkg-config git"

From 33850cbd5a0d3a2f985f0685a6bb8410951fd6b2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 067/113] tvheadend: revbump for ffmpeg4

---
 srcpkgs/tvheadend/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tvheadend/template b/srcpkgs/tvheadend/template
index 9aea7de4ec705..012d31c4879ff 100644
--- a/srcpkgs/tvheadend/template
+++ b/srcpkgs/tvheadend/template
@@ -8,7 +8,7 @@ configure_args="--enable-dvbscan --disable-ffmpeg_static
 --disable-libx265_static --disable-libvpx_static --disable-libtheora_static
 --disable-libvorbis_static --disable-libfdkaac_static"
 hostmakedepends="gettext pkg-config python3 git which"
-makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg-devel"
+makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg4-devel"
 short_desc="TV streaming server"
 maintainer="lemmi <lemmi@nerd2nerd.org>"
 license="GPL-3.0-only"

From ffeadc1935f14a953c1409cca7e3aad73bf95433 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 068/113] unpaper: update to 7.0.0.

---
 srcpkgs/unpaper/template | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/srcpkgs/unpaper/template b/srcpkgs/unpaper/template
index 38ed47a584016..1ff910e722afc 100644
--- a/srcpkgs/unpaper/template
+++ b/srcpkgs/unpaper/template
@@ -1,13 +1,13 @@
 # Template file for 'unpaper'
 pkgname=unpaper
-version=6.1
-revision=3
-build_style=gnu-configure
+version=7.0.0
+revision=1
+build_style=meson
+hostmakedepends="pkg-config meson libxslt"
+makedepends="ffmpeg-devel python3-Sphinx"
+short_desc="Post-processing tool for scanned sheets of paper"
 maintainer="Orphaned <orphan@voidlinux.org>"
-hostmakedepends="pkg-config libxslt"
-makedepends="ffmpeg-devel"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://www.flameeyes.eu/projects/unpaper"
-short_desc="A post-processing tool for scanned sheets of paper"
 distfiles="https://www.flameeyes.eu/files/${pkgname}-${version}.tar.xz"
-checksum=237c84f5da544b3f7709827f9f12c37c346cdf029b1128fb4633f9bafa5cb930
+checksum=2575fbbf26c22719d1cb882b59602c9900c7f747118ac130883f63419be46a80

From fa482618ebaef3891abcab11e91b928fcbcdbd13 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 069/113] vice: revbump for ffmpeg4

---
 srcpkgs/vice/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/vice/template b/srcpkgs/vice/template
index b1f866d35095e..43f79243a1da1 100644
--- a/srcpkgs/vice/template
+++ b/srcpkgs/vice/template
@@ -1,7 +1,7 @@
 # Template file for 'vice'
 pkgname=vice
 version=3.7.1
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="
 	$(vopt_enable sdl2 sdlui2)
@@ -26,7 +26,7 @@ makedepends="
 	$(vopt_if gtk3 gtk+3-devel)
 	$(vopt_if gtk3 pulseaudio-devel)
 	$(vopt_if gtk3 pango-devel)
-	$(vopt_if ffmpeg ffmpeg-devel)"
+	$(vopt_if ffmpeg ffmpeg4-devel)"
 short_desc="Emulator for C64, C128, CBM-II, PET, VIC20, Plus4 and C16"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"

From bcb5c828c6f220f65765c6563225722a7e255a09 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 070/113] waypipe: revbump for ffmpeg6

---
 srcpkgs/waypipe/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waypipe/template b/srcpkgs/waypipe/template
index 6da88b21bf2a1..4da8058400b58 100644
--- a/srcpkgs/waypipe/template
+++ b/srcpkgs/waypipe/template
@@ -1,7 +1,7 @@
 # Template file for 'waypipe'
 pkgname=waypipe
 version=0.8.6
-revision=1
+revision=2
 build_style=meson
 # lto is off because it causes linking errors in armv6l and armv7l (due to NEON)
 configure_args="-Dwerror=false -Dwith_dmabuf=enabled -Dwith_lz4=enabled

From 0e2793b3f4c3d00cf679372901758d2c1adde731 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 071/113] xpra: revbump for ffmpeg6

---
 srcpkgs/xpra/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xpra/template b/srcpkgs/xpra/template
index f4a44ea814867..c0f66c9483d49 100644
--- a/srcpkgs/xpra/template
+++ b/srcpkgs/xpra/template
@@ -1,7 +1,7 @@
 # Template file for 'xpra'
 pkgname=xpra
 version=5.0.5
-revision=1
+revision=2
 build_style=python3-module
 make_build_args="--without-cuda_kernels --without-cuda_rebuild"
 make_install_args="$(vopt_with docs) ${make_build_args}"

From 0cfa3a6898b62266d83b8b7d0385ea191a61513e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:07:40 -0400
Subject: [PATCH 072/113] nv-codec-headers: update to 12.0.16.0

---
 srcpkgs/nv-codec-headers/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/nv-codec-headers/template b/srcpkgs/nv-codec-headers/template
index 3d422a61e4891..251e057f826fb 100644
--- a/srcpkgs/nv-codec-headers/template
+++ b/srcpkgs/nv-codec-headers/template
@@ -1,6 +1,6 @@
 # Template file for 'nv-codec-headers'
 pkgname=nv-codec-headers
-version=11.1.5.1
+version=12.0.16.0
 revision=1
 build_style=gnu-makefile
 short_desc="FFmpeg version of headers required to interface with Nvidias codec APIs"
@@ -8,7 +8,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="MIT"
 homepage="http://git.videolan.org/?p=ffmpeg/nv-codec-headers.git"
 distfiles="https://github.com/FFmpeg/nv-codec-headers/archive/n${version}.tar.gz"
-checksum=d095fbd56aa93772471a323be0ebe65504a0f43f06c76a30b6d25da77b06ae9c
+checksum=2a1533b65f55f9da52956faf0627ed3b74868ac0c7f269990edd21369113b48f
 
 post_install() {
 	sed -n '4,25p' include/ffnvcodec/nvEncodeAPI.h > LICENSE

From 30ae715eca2b96f833e7d2d83f3985f2cf323ab4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:08:40 -0400
Subject: [PATCH 073/113] openimagedenoise: revbump for ffmpeg6

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index b792813dba7c2..109deb171c3f7 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,7 +1,7 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
 version=1.4.3
-revision=1
+revision=2
 archs="x86_64*"
 build_style=cmake
 hostmakedepends="ispc python3"

From 530e08c44c6786f790d39aaeeb25e151e48fdfcd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:31:45 -0400
Subject: [PATCH 074/113] shotcut: revbump for ffmpeg6

---
 srcpkgs/shotcut/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/shotcut/template b/srcpkgs/shotcut/template
index 33141fbd862d7..f46cb53b6bfb9 100644
--- a/srcpkgs/shotcut/template
+++ b/srcpkgs/shotcut/template
@@ -1,7 +1,7 @@
 # Template file for 'shotcut'
 pkgname=shotcut
 version=23.09.29
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSHOTCUT_VERSION=${version}"
 hostmakedepends="pkg-config qt6-tools-devel"

From 19447dfa02fc31cc4bd1f36078a39ae8354a1094 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:30 -0400
Subject: [PATCH 075/113] shiboken2: revbump for qt5-5.15.11

---
 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch | 1 +
 1 file changed, 1 insertion(+)
 create mode 120000 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
new file mode 120000
index 0000000000000..efcf3249bd885
--- /dev/null
+++ b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1 @@
+../../python3-pyside2/patches/importlib-machinery-bypass.patch
\ No newline at end of file

From c36f98a3131998cce8b8a30dda263aa5d5e9dd64 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:53 -0400
Subject: [PATCH 076/113] python3-pyside2: revbump for qt5-5.15.11

---
 .../patches/importlib-machinery-bypass.patch      | 15 +++++++++++++++
 srcpkgs/python3-pyside2/template                  |  2 +-
 2 files changed, 16 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
new file mode 100644
index 0000000000000..64c429584776b
--- /dev/null
+++ b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1,15 @@
+Using this prevents an error around line 220 below it.
+"AttributeError: module 'importlib' has no attribute 'machinery'"
+The old backup logic is in place and compiles without issues.
+--- a/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:09:34.688912402 -0400
++++ b/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:10:03.395529582 -0400
+@@ -170,9 +170,6 @@
+
+     # 'zipstring_sequence' comes from signature.cpp
+     zipbytes = base64.b64decode(''.join(zipstring_sequence))
+-    if sys.version_info[0] >= 3:
+-        vzip = zipfile.ZipFile(io.BytesIO(zipbytes))
+-        return sys.meta_path, EmbeddableZipImporter(vzip)
+
+     # Old version for Python 2.7, only.
+     import os
diff --git a/srcpkgs/python3-pyside2/template b/srcpkgs/python3-pyside2/template
index 249efa9098842..52626436ce75f 100644
--- a/srcpkgs/python3-pyside2/template
+++ b/srcpkgs/python3-pyside2/template
@@ -1,7 +1,7 @@
 # Template file for 'python3-pyside2'
 pkgname=python3-pyside2
 version=5.15.10
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/pyside2"
 build_style=cmake

From 44442cd64dc565bd1378697a57a693476ab3ade6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:35 -0400
Subject: [PATCH 077/113] konqueror: revbump for ffmpeg6

---
 srcpkgs/konqueror/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/konqueror/template b/srcpkgs/konqueror/template
index 044dafa605ba6..63dd01fafc780 100644
--- a/srcpkgs/konqueror/template
+++ b/srcpkgs/konqueror/template
@@ -1,11 +1,11 @@
 # Template file for 'konqueror'
 pkgname=konqueror
 version=23.08.4
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DDESKTOPTOJSON_EXECUTABLE=/usr/bin/desktoptojson"
 hostmakedepends="extra-cmake-modules python3 qt5-host-tools qt5-qmake kdoctools
-kcoreaddons kconfig gettext"
+ kcoreaddons kconfig gettext"
 makedepends="qt5-devel qt5-webengine-devel qt5-declarative-devel
  qt5-webchannel-devel qt5-location-devel kcmutils-devel kdelibs4support-devel
  karchive-devel khtml-devel kdesu-devel kactivities5-devel"

From c965d32e23d6b9da87ab20d1b2ecc648c065662e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:58 -0400
Subject: [PATCH 078/113] qt5-speech: revbump for qt5-5.15.11

---
 srcpkgs/qt5-speech/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-speech/template b/srcpkgs/qt5-speech/template
index 1228bb60c41db..27a7da1dbdb91 100644
--- a/srcpkgs/qt5-speech/template
+++ b/srcpkgs/qt5-speech/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-speech'
 pkgname=qt5-speech
 version=5.15.11
-revision=1
+revision=2
 _commit=d32f4a479d38a11f547598004b975f4356424a16
 build_style=qmake
 configure_args="-- -flite -flite-alsa -speechd"

From 0ccdc7243769e67b68c86b07245cf4b02ce673a3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Jun 2023 08:20:22 -0400
Subject: [PATCH 079/113] gtk4: revbump for ffmpeg6

---
 srcpkgs/gtk4/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gtk4/template b/srcpkgs/gtk4/template
index d8ee60abe06f7..55bff6e33849a 100644
--- a/srcpkgs/gtk4/template
+++ b/srcpkgs/gtk4/template
@@ -1,7 +1,7 @@
 # Template file for 'gtk4'
 pkgname=gtk4
 version=4.12.3
-revision=1
+revision=2
 build_style=meson
 build_helper="gir"
 configure_args="-Dman-pages=true -Ddocumentation=true -Dbuild-tests=false

From d104f8633414d2691d65ff11f695d3caa10d57fb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:28:26 -0400
Subject: [PATCH 080/113] siril: revbump for ffmpeg6

---
 srcpkgs/siril/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/siril/template b/srcpkgs/siril/template
index 84332f79d060d..62750dd247548 100644
--- a/srcpkgs/siril/template
+++ b/srcpkgs/siril/template
@@ -1,7 +1,7 @@
 # Template file for 'siril'
 pkgname=siril
 version=0.9.12
-revision=10
+revision=11
 build_style=gnu-configure
 hostmakedepends="pkg-config intltool autoconf automake gettext-devel"
 makedepends="fftw-devel libconfig-devel libopencv-devel libffms2-devel

From 9f718b4c4ef131caa170be354f6351970855bb81 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 22 Jun 2023 10:25:02 -0400
Subject: [PATCH 081/113] kdenlive: revbump for ffmpeg6

---
 srcpkgs/kdenlive/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kdenlive/template b/srcpkgs/kdenlive/template
index a0f3615c9c530..d63166f95c4d7 100644
--- a/srcpkgs/kdenlive/template
+++ b/srcpkgs/kdenlive/template
@@ -1,7 +1,7 @@
 # Template file for 'kdenlive'
 pkgname=kdenlive
 version=23.08.4
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="
  extra-cmake-modules kconfig kcoreaddons kdoctools pkg-config python3

From 3384b6ab0752361c19b193ba232c5aad67a93da8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:20:59 -0400
Subject: [PATCH 082/113] tracker-miners: revbump for ffmpeg6

---
 srcpkgs/tracker-miners/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tracker-miners/template b/srcpkgs/tracker-miners/template
index 0b97f47489f81..f196d2bf9e4a4 100644
--- a/srcpkgs/tracker-miners/template
+++ b/srcpkgs/tracker-miners/template
@@ -1,7 +1,7 @@
 # Template file for 'tracker-miners'
 pkgname=tracker-miners
 version=3.6.1
-revision=1
+revision=2
 build_style=meson
 build_helper=qemu
 # missing libgrss for miner_rss

From 7db95be13f5a3d59fc44837f1c4235adc5253983 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:21:21 -0400
Subject: [PATCH 083/113] mpd: revbump for ffmpeg6

---
 srcpkgs/mpd/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpd/template b/srcpkgs/mpd/template
index 4fd32b7be8c53..b8e2bd4c1b59c 100644
--- a/srcpkgs/mpd/template
+++ b/srcpkgs/mpd/template
@@ -1,7 +1,7 @@
 # Template file for 'mpd'
 pkgname=mpd
 version=0.23.15
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dopus=enabled -Dmikmod=enabled -Dneighbor=true
  -Dsoundcloud=enabled -Dpipe=true -Dtwolame=enabled -Dbzip2=enabled

From f6d30e976d1af275beacb208e5aaa88822b009e8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:02 -0400
Subject: [PATCH 084/113] tg_owt: revbump for ffmpeg6

---
 srcpkgs/tg_owt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tg_owt/template b/srcpkgs/tg_owt/template
index aee8d35d08ffb..34e8fef054056 100644
--- a/srcpkgs/tg_owt/template
+++ b/srcpkgs/tg_owt/template
@@ -1,7 +1,7 @@
 # Template file for 'tg_owt'
 pkgname=tg_owt
 version=0.0.0.20231221
-revision=1
+revision=2
 _commit=afd9d5d31798d3eacf9ed6c30601e91d0f1e4d60
 _libyuv_commit=04821d1e7d60845525e8db55c7bcd41ef5be9406
 _abseil_commit=8c0b94e793a66495e0b1f34a5eb26bd7dc672db0

From 887174477acb970036d714228c339e1b522e31a6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:44 -0400
Subject: [PATCH 085/113] telegram-desktop: revbump for ffmpeg6

---
 srcpkgs/telegram-desktop/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/telegram-desktop/template b/srcpkgs/telegram-desktop/template
index d00b273b7b738..d20b87b5182db 100644
--- a/srcpkgs/telegram-desktop/template
+++ b/srcpkgs/telegram-desktop/template
@@ -1,7 +1,7 @@
 # Template file for 'telegram-desktop'
 pkgname=telegram-desktop
 version=4.14.9
-revision=1
+revision=2
 build_style=cmake
 build_helper="qemu gir"
 configure_args="-DTDESKTOP_API_ID=209235

From 25baa3d21fbb15cc2efc698bfe95f80f52e85e14 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:11:45 -0400
Subject: [PATCH 086/113] gst-plugins-bad1: revbump for ffmpeg6

---
 srcpkgs/gst-plugins-bad1/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index 63200e74f99a7..644758cb187a1 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-plugins-bad1'
 pkgname=gst-plugins-bad1
 version=1.22.9
-revision=1
+revision=2
 build_helper="gir"
 build_style=meson
 configure_args="-Dpackage-origin=https://voidlinux.org -Ddoc=disabled

From 207a5f7fc4e19a912e9b366abf906059e81da9c0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:12:09 -0400
Subject: [PATCH 087/113] openmw: revbump for ffmpeg6

---
 srcpkgs/openmw/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openmw/template b/srcpkgs/openmw/template
index 0abf5ff7cdbec..b57180f1a4446 100644
--- a/srcpkgs/openmw/template
+++ b/srcpkgs/openmw/template
@@ -1,7 +1,7 @@
 # Template file for 'openmw'
 pkgname=openmw
 version=0.48.0
-revision=2
+revision=3
 build_style=cmake
 _recast_commit=e75adf86f91eb3082220085e42dda62679f9a3ea
 _bullet_tag=3.17

From 85299103b11957295a15a58e49c12a33505a73d2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:14:53 -0400
Subject: [PATCH 088/113] lms: revbump for ffmpeg6

---
 srcpkgs/lms/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/lms/template b/srcpkgs/lms/template
index e358f75902a98..3b21c458de519 100644
--- a/srcpkgs/lms/template
+++ b/srcpkgs/lms/template
@@ -1,7 +1,7 @@
 # Template file for 'lms'
 pkgname=lms
 version=3.42.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="wt-devel ffmpeg-devel boost-devel libconfig++-devel taglib-devel pam-devel libgraphicsmagick-devel gtest-devel libarchive-devel"

From 494cb8b96b18e9a56cfe0973991f60c09b971a55 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:18:18 -0400
Subject: [PATCH 089/113] freecad: DELETE

---
 srcpkgs/freecad/patches/001-include.patch     | 112 ------------------
 .../154-revert-gui-tmp-redirect-stderr.patch  |  68 -----------
 ...d63c8c9b1280978be841d04e68a0a55cceb9.patch |  30 -----
 srcpkgs/freecad/template                      |  12 +-
 4 files changed, 7 insertions(+), 215 deletions(-)
 delete mode 100644 srcpkgs/freecad/patches/001-include.patch
 delete mode 100644 srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
 delete mode 100644 srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch

diff --git a/srcpkgs/freecad/patches/001-include.patch b/srcpkgs/freecad/patches/001-include.patch
deleted file mode 100644
index 28b5af54999b9..0000000000000
--- a/srcpkgs/freecad/patches/001-include.patch
+++ /dev/null
@@ -1,112 +0,0 @@
-From 9a41845a417189776741297c50a3827ce292bc4f Mon Sep 17 00:00:00 2001
-From: Uwe <donovaly@users.noreply.github.com>
-Date: Sun, 3 Jul 2022 22:51:16 +0200
-Subject: [PATCH] [Part] OCCError.h: remove unneeded includes
-
-- also sort includes
----
- src/Mod/Part/App/OCCError.h             | 36 +++----------------------
- src/Mod/Part/App/OffsetCurvePyImp.cpp   | 12 ++++-----
- src/Mod/Part/App/OffsetSurfacePyImp.cpp | 10 +++----
- 3 files changed, 12 insertions(+), 46 deletions(-)
-
---- a/src/Mod/Part/App/OCCError.h
-+++ b/src/Mod/Part/App/OCCError.h
-@@ -23,36 +23,8 @@
- #ifndef _OCCError_h_
- #define _OCCError_h_
- 
--# include <Standard_Version.hxx>
- # include <Standard_Failure.hxx>
--# include <Standard_AbortiveTransaction.hxx>
--# include <Standard_ConstructionError.hxx>
--# if OCC_VERSION_HEX >= 0x060500
--# include <Standard_DefineException.hxx>
--# endif
--# include <Standard_DimensionError.hxx>
--# include <Standard_DimensionMismatch.hxx>
--# include <Standard_DivideByZero.hxx>
--# include <Standard_DomainError.hxx>
--# include <Standard_ImmutableObject.hxx>
--# include <Standard_LicenseError.hxx>
--# include <Standard_LicenseNotFound.hxx>
--# include <Standard_MultiplyDefined.hxx>
--# include <Standard_NegativeValue.hxx>
--# include <Standard_NoMoreObject.hxx>
--# include <Standard_NoSuchObject.hxx>
--# include <Standard_NotImplemented.hxx>
--# include <Standard_NullObject.hxx>
--# include <Standard_NullValue.hxx>
--# include <Standard_NumericError.hxx>
--# include <Standard_OutOfMemory.hxx>
--# include <Standard_OutOfRange.hxx>
--# include <Standard_Overflow.hxx>
--# include <Standard_ProgramError.hxx>
--# include <Standard_RangeError.hxx>
--# include <Standard_TooManyUsers.hxx>
--# include <Standard_TypeMismatch.hxx>
--# include <Standard_Underflow.hxx>
-+# include <Standard_Version.hxx>
- 
- #include <Mod/Part/PartGlobal.h>
- #include <Base/Console.h>
-@@ -88,4 +60,3 @@ PartExport extern PyObject* PartExceptio
- 
- #define PY_CATCH_OCC _PY_CATCH_OCC(return(NULL))
- #endif  // _OCCError_h_
--
---- a/src/Mod/Part/App/OffsetCurvePyImp.cpp
-+++ b/src/Mod/Part/App/OffsetCurvePyImp.cpp
-@@ -20,20 +20,20 @@
-  *                                                                         *
-  ***************************************************************************/
- 
--
- #include "PreCompiled.h"
- #ifndef _PreComp_
- # include <Geom_OffsetCurve.hxx>
- #endif
- 
--#include "OCCError.h"
--#include "Geometry.h"
-+#include <Base/GeometryPyCXX.h>
-+#include <Base/Vector3D.h>
-+#include <Base/VectorPy.h>
-+
- #include "OffsetCurvePy.h"
- #include "OffsetCurvePy.cpp"
-+#include "Geometry.h"
-+#include "OCCError.h"
- 
--#include <Base/GeometryPyCXX.h>
--#include <Base/VectorPy.h>
--#include <Base/Vector3D.h>
- 
- using namespace Part;
- 
---- a/src/Mod/Part/App/OffsetSurfacePyImp.cpp
-+++ b/src/Mod/Part/App/OffsetSurfacePyImp.cpp
-@@ -20,20 +20,16 @@
-  *                                                                         *
-  ***************************************************************************/
- 
--
- #include "PreCompiled.h"
- #ifndef _PreComp_
- # include <Geom_OffsetSurface.hxx>
- # include <memory>
- #endif
- 
--#include <Base/VectorPy.h>
--#include <Base/Vector3D.h>
--
- #include "OCCError.h"
--#include "Geometry.h"
--#include <Mod/Part/App/OffsetSurfacePy.h>
--#include <Mod/Part/App/OffsetSurfacePy.cpp>
-+#include "OffsetSurfacePy.h"
-+#include "OffsetSurfacePy.cpp"
-+
- 
- using namespace Part;
- 
diff --git a/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch b/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
deleted file mode 100644
index d6a9adabdec83..0000000000000
--- a/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
+++ /dev/null
@@ -1,68 +0,0 @@
-see https://github.com/FreeCAD/FreeCAD/commit/cfe94b00d3434f3e2c8b5114d2909f628c330fa8#commitcomment-71413407
-
-upstream: yes
-
-From 7b377a216b9185960e4cee980a6504dc1a755f50 Mon Sep 17 00:00:00 2001
-From: wmayer <wmayer@users.sourceforge.net>
-Date: Wed, 29 Jun 2022 15:19:18 +0200
-Subject: [PATCH] Gui: remove workaround for spnav 0.23 due to build failure
- with musl libc
-
----
- src/Gui/3Dconnexion/GuiNativeEventLinux.cpp | 27 ---------------------
- 1 file changed, 27 deletions(-)
-
---- a/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp
-+++ b/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp
-@@ -21,42 +21,17 @@
-  ***************************************************************************/
- 
- #include <FCConfig.h>
--#include <cstdio>
- 
- #include "GuiNativeEventLinux.h"
- 
- #include "GuiApplicationNativeEventAware.h"
- #include <Base/Console.h>
--#include <Base/FileInfo.h>
- #include <QMainWindow>
- 
- #include <QSocketNotifier>
- 
- #include <spnav.h>
- 
--namespace {
--class RedirectStdErr
--{
--public:
--    RedirectStdErr()
--        : fi(Base::FileInfo::getTempFileName())
--        , file(stderr)
--    {
--        stderr = fopen(fi.filePath().c_str(), "w");
--    }
--    ~RedirectStdErr()
--    {
--        fclose(stderr);
--        fi.deleteFile();
--        stderr = file;
--    }
--
--private:
--    Base::FileInfo fi;
--    FILE* file;
--};
--}
--
- Gui::GuiNativeEvent::GuiNativeEvent(Gui::GUIApplicationNativeEventAware *app)
- : GuiAbstractNativeEvent(app)
- {
-@@ -72,8 +47,6 @@ Gui::GuiNativeEvent::~GuiNativeEvent()
- 
- void Gui::GuiNativeEvent::initSpaceball(QMainWindow *window)
- {
--    // tmp. redirect stderr to a file to suppress an error message from spnav_open()
--    RedirectStdErr err;
-     Q_UNUSED(window)
-     if (spnav_open() == -1) {
-         Base::Console().Log("Couldn't connect to spacenav daemon. Please ignore if you don't have a spacemouse.\n");
diff --git a/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch b/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch
deleted file mode 100644
index d4acf370ca0a4..0000000000000
--- a/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-From fe02d63c8c9b1280978be841d04e68a0a55cceb9 Mon Sep 17 00:00:00 2001
-From: Roy-043 <70520633+Roy-043@users.noreply.github.com>
-Date: Thu, 29 Dec 2022 23:20:38 +0100
-Subject: [PATCH] Draft: update inspect.getargspec to inspect.getfullargspec
- (#8101)
-
----
- src/Mod/Draft/draftguitools/gui_snapper.py | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
---- a/src/Mod/Draft/draftguitools/gui_snapper.py
-+++ b/src/Mod/Draft/draftguitools/gui_snapper.py
-@@ -1426,7 +1426,7 @@ class Snapper:
-             Gui.Snapper.off()
-             self.ui.offUi()
-             if callback:
--                if len(inspect.getargspec(callback).args) > 1:
-+                if len(inspect.getfullargspec(callback).args) > 1:
-                     obj = None
-                     if self.snapInfo and ("Object" in self.snapInfo) and self.snapInfo["Object"]:
-                         obj = App.ActiveDocument.getObject(self.snapInfo["Object"])
-@@ -1445,7 +1445,7 @@ class Snapper:
-             Gui.Snapper.off()
-             self.ui.offUi()
-             if callback:
--                if len(inspect.getargspec(callback).args) > 1:
-+                if len(inspect.getfullargspec(callback).args) > 1:
-                     callback(None, None)
-                 else:
-                     callback(None)
diff --git a/srcpkgs/freecad/template b/srcpkgs/freecad/template
index c135701e38b9a..7d5165f760bab 100644
--- a/srcpkgs/freecad/template
+++ b/srcpkgs/freecad/template
@@ -1,7 +1,7 @@
 # Template file for 'freecad'
 pkgname=freecad
-version=0.20.2
-revision=7
+version=0.21.1
+revision=2
 build_wrksrc="FreeCAD-${version}"
 build_style=cmake
 pycompile_dirs="usr/lib/${pkgname}/Mod"
@@ -24,8 +24,10 @@ makedepends="python3-devel boost-devel libxerces-c-devel zlib-devel occt-devel
  coin3-devel libshiboken2-devel libspnav-devel pyside2-tools
  liblz4-devel libpyside2-python3-devel python3-matplotlib netcdf-devel
  jsoncpp-devel qt5-devel qt5-svg-devel qt5-tools-devel qt5-webkit-devel
- qt5-xmlpatterns-devel coin3-doc glew-devel python3-pivy"
-depends="python3-matplotlib python3-pyside2-webengine python3-pivy"
+ qt5-xmlpatterns-devel coin3-doc glew-devel python3-pivy qt5-webengine-devel
+ qt5-declarative-devel qt5-webchannel-devel qt5-location-devel"
+depends="python3-matplotlib python3-pyside2-webengine python3-pivy
+ python3-GitPython python3-Markdown"
 short_desc="General purpose 3D CAD modeler"
 maintainer="yopito <pierre.bourgin@free.fr>"
 license="LGPL-2.0-or-later"
@@ -35,7 +37,7 @@ distfiles="
  https://github.com/FreeCAD/FreeCAD/archive/${version}.tar.gz
  ${SOURCEFORGE_SITE}/cxx/pycxx-${_pycxxver}.tar.gz
 "
-checksum="46922f3a477e742e1a89cd5346692d63aebb2b67af887b3e463e094a4ae055da
+checksum="e9b1fd0323f101268c7f3be52db42e4a29222f2e306ae6c4a6fc309cb418d35a
  4b91e1e1141c23fbd5039df635c4bb6e75632168548f56b83ce177193c0c98c6"
 python_version=3
 patch_args="-Np1 -d ${build_wrksrc}"

From 16531d66fa719c2224dafd7cc49184a8ce349eb9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:47:18 -0400
Subject: [PATCH 090/113] libopenshot: revbump for ffmpeg6

---
 srcpkgs/libopenshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenshot/template b/srcpkgs/libopenshot/template
index 8e57c5f592169..7a8f4520e7892 100644
--- a/srcpkgs/libopenshot/template
+++ b/srcpkgs/libopenshot/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenshot'
 pkgname=libopenshot
 version=0.3.0
-revision=3
+revision=4
 build_style=cmake
 # Builds fail with Ruby-2.4.1
 configure_args="-DENABLE_RUBY=OFF -DUSE_SYSTEM_JSONCPP=ON"

From c42952a84e14ffeaad7adc1355144b5db6344943 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:10:30 -0500
Subject: [PATCH 091/113] openimageio: revbump for ffmpeg6

---
 srcpkgs/openimageio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimageio/template b/srcpkgs/openimageio/template
index 3ce3f9e49d350..27d2131bc0a61 100644
--- a/srcpkgs/openimageio/template
+++ b/srcpkgs/openimageio/template
@@ -1,7 +1,7 @@
 # Template file for 'openimageio'
 pkgname=openimageio
 version=2.4.9.0
-revision=7
+revision=8
 build_style=cmake
 build_helper=qemu
 configure_args="-DUSE_QT=0 -DUSE_PYTHON=0 -DOIIO_BUILD_TESTS=0

From 5a9a013aa4005e4665d48c925cbe2a2c100f363b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:11:57 -0500
Subject: [PATCH 092/113] synfigstudio: revbump for ffmpeg6

---
 srcpkgs/synfigstudio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/synfigstudio/template b/srcpkgs/synfigstudio/template
index 09e442da9a680..2bc017cedca6b 100644
--- a/srcpkgs/synfigstudio/template
+++ b/srcpkgs/synfigstudio/template
@@ -2,7 +2,7 @@
 # Should be kept in sync with 'synfig' and 'ETL'
 pkgname=synfigstudio
 version=1.4.4
-revision=4
+revision=5
 build_style=gnu-configure
 configure_args="--disable-update-mimedb"
 hostmakedepends="pkg-config intltool gettext synfig"

From e31846e2ac6c9abd2a1b157eb20c3a1eb1deceb7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:10 -0500
Subject: [PATCH 093/113] mixxx: revbump for ffmpeg6

---
 srcpkgs/mixxx/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mixxx/template b/srcpkgs/mixxx/template
index 6921996e4e77b..6a79b328c1abf 100644
--- a/srcpkgs/mixxx/template
+++ b/srcpkgs/mixxx/template
@@ -1,7 +1,7 @@
 # Template file for 'mixxx'
 pkgname=mixxx
 version=2.3.3
-revision=6
+revision=7
 build_style=cmake
 configure_args="-DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="extra-cmake-modules pkg-config protobuf qt5-host-tools qt5-qmake"

From a043ba2fc28e8a86bd6f022fa52e49b1d3a26fed Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:28 -0500
Subject: [PATCH 094/113] musikcube: revbump for ffmpeg6

---
 srcpkgs/musikcube/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/musikcube/template b/srcpkgs/musikcube/template
index 8c4a51840859e..fb60dd2049089 100644
--- a/srcpkgs/musikcube/template
+++ b/srcpkgs/musikcube/template
@@ -1,7 +1,7 @@
 # Template file for 'musikcube'
 pkgname=musikcube
 version=3.0.0
-revision=3
+revision=4
 build_style=cmake
 make_cmd=make
 configure_args="-DNO_NCURSESW=1"

From cfc46b2fd5cf1925526818b8159ea978697387ae Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:45 -0500
Subject: [PATCH 095/113] electron24: revbump for ffmpeg6

---
 srcpkgs/electron24/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron24/template b/srcpkgs/electron24/template
index 7b4e28812f483..1ca93fde97a85 100644
--- a/srcpkgs/electron24/template
+++ b/srcpkgs/electron24/template
@@ -1,7 +1,7 @@
 # Template file for 'electron24'
 pkgname=electron24
 version=24.3.0
-revision=2
+revision=3
 _nodever=18.14.0
 _chromiumver=112.0.5615.165
 archs="x86_64* aarch64*"

From ca1883623e96c22771f0f864db0d04941dcd85af Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:00 -0500
Subject: [PATCH 096/113] electron19: revbump for ffmpeg6

---
 srcpkgs/electron19/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron19/template b/srcpkgs/electron19/template
index 0ef959125cb08..5371c0b354604 100644
--- a/srcpkgs/electron19/template
+++ b/srcpkgs/electron19/template
@@ -1,7 +1,7 @@
 # Template file for 'electron19'
 pkgname=electron19
 version=19.0.8
-revision=4
+revision=5
 _nodever=16.14.2
 _chromiumver=102.0.5005.125
 archs="x86_64* aarch64* ppc64le*"

From 08dc8e4e997be8a81178d4d60e443ef29490cbd5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:13 -0500
Subject: [PATCH 097/113] wf-recorder: revbump for ffmpeg6

---
 srcpkgs/wf-recorder/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/wf-recorder/template b/srcpkgs/wf-recorder/template
index 08f986b031006..63c45cf4b814d 100644
--- a/srcpkgs/wf-recorder/template
+++ b/srcpkgs/wf-recorder/template
@@ -1,7 +1,7 @@
 # Template file for 'wf-recorder'
 pkgname=wf-recorder
 version=0.4.1
-revision=2
+revision=3
 build_style=meson
 hostmakedepends="pkg-config scdoc wayland-devel"
 makedepends="wayland-protocols wayland-devel ffmpeg-devel libgbm-devel x264-devel

From 7d601a16043a7d72da0e1b00fbd02ad89a260c73 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:26 -0500
Subject: [PATCH 098/113] obs: revbump for ffmpeg6

---
 srcpkgs/obs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/obs/template b/srcpkgs/obs/template
index b343f1131bfcf..a25a67433e285 100644
--- a/srcpkgs/obs/template
+++ b/srcpkgs/obs/template
@@ -1,7 +1,7 @@
 # Template file for 'obs'
 pkgname=obs
 version=30.0.0
-revision=2
+revision=3
 archs="i686* x86_64* ppc64le* aarch64* riscv64*"
 build_style=cmake
 configure_args="-DOBS_VERSION_OVERRIDE=${version} -DENABLE_JACK=ON

From db641237683d6b660d8aab80be257c7cb514928c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:36 -0500
Subject: [PATCH 099/113] mlt7: revbump for ffmpeg6

---
 srcpkgs/mlt7/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mlt7/template b/srcpkgs/mlt7/template
index 98f302ad3a516..7eb8c00fa1580 100644
--- a/srcpkgs/mlt7/template
+++ b/srcpkgs/mlt7/template
@@ -1,7 +1,7 @@
 # Template file for 'mlt7'
 pkgname=mlt7
 version=7.20.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DSWIG_PYTHON=ON -DMOD_QT6=ON"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which

From badf5bab45d7bc9e1639723b684f99c68b741f5e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:48 -0500
Subject: [PATCH 100/113] qt6-multimedia: revbump for ffmpeg6

---
 srcpkgs/qt6-multimedia/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-multimedia/template b/srcpkgs/qt6-multimedia/template
index 67a577e1300fe..1da626ecf515a 100644
--- a/srcpkgs/qt6-multimedia/template
+++ b/srcpkgs/qt6-multimedia/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-multimedia'
 pkgname=qt6-multimedia
 version=6.6.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DQT_FEATURE_gstreamer=ON"
 hostmakedepends="perl qt6-declarative-host-tools pkg-config qt6-shadertools"

From ce449b8d418491d319a35416a8a1ce2d3ba1face Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:00:15 -0500
Subject: [PATCH 101/113] baresip: revbump for ffmpeg6

---
 srcpkgs/baresip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/baresip/template b/srcpkgs/baresip/template
index 12c8954ef7b9b..b16b67beab8d2 100644
--- a/srcpkgs/baresip/template
+++ b/srcpkgs/baresip/template
@@ -1,7 +1,7 @@
 # Template file for 'baresip'
 pkgname=baresip
 version=3.6.0
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config glib-devel"
 makedepends="libgsm-devel libpng-devel openssl-devel libsndfile-devel

From 0ec09ed729f34650509466592d0c44eb31a6ea04 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:30 -0500
Subject: [PATCH 102/113] QMPlay2: revbump for ffmpeg6

---
 srcpkgs/QMPlay2/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/QMPlay2/template b/srcpkgs/QMPlay2/template
index 46c80f64a1349..942258ce60fb7 100644
--- a/srcpkgs/QMPlay2/template
+++ b/srcpkgs/QMPlay2/template
@@ -1,7 +1,7 @@
 # Template file for 'QMPlay2'
 pkgname=QMPlay2
 version=23.10.22
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools"
 makedepends="alsa-lib-devel ffmpeg-devel libass-devel libcdio-devel libgme-devel

From c016f4a075b30ba72bff3f7a702945c7e4d48370 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:34 -0500
Subject: [PATCH 103/113] alsa-plugins: revbump for ffmpeg6

---
 srcpkgs/alsa-plugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/alsa-plugins/template b/srcpkgs/alsa-plugins/template
index a5708a7d82a8f..7bfdad046c483 100644
--- a/srcpkgs/alsa-plugins/template
+++ b/srcpkgs/alsa-plugins/template
@@ -1,7 +1,7 @@
 # Template file for 'alsa-plugins'
 pkgname=alsa-plugins
 version=1.2.7.1
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--disable-maemo-plugin"
 hostmakedepends="pkg-config"

From d244e2477515ce7acd5954a014a48af9c4093226 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:43 -0500
Subject: [PATCH 104/113] minidlna: revbump for ffmpeg6

---
 srcpkgs/minidlna/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/minidlna/template b/srcpkgs/minidlna/template
index 5fa929f3a0c12..742991ecd04af 100644
--- a/srcpkgs/minidlna/template
+++ b/srcpkgs/minidlna/template
@@ -1,7 +1,7 @@
 # Template file for 'minidlna'
 pkgname=minidlna
 version=1.3.3
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="
  --sbindir=/usr/bin

From 2d32f8dc151f61607ea8e42e384bc60483a5b4b5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 17:57:47 -0500
Subject: [PATCH 105/113] mpv: revbump for ffmpeg6

---
 srcpkgs/mpv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpv/template b/srcpkgs/mpv/template
index 4948d1e332cb8..1ac1b167af189 100644
--- a/srcpkgs/mpv/template
+++ b/srcpkgs/mpv/template
@@ -1,7 +1,7 @@
 # Template file for 'mpv'
 pkgname=mpv
 version=0.36.0
-revision=4
+revision=5
 build_style=meson
 configure_args="-Dcdda=enabled -Ddvbin=enabled -Ddvdnav=enabled
  -Dlibmpv=true -Dcplugins=enabled

From eb4cb940d9e36a474865cc83d8924554e6781d10 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 17:59:29 -0500
Subject: [PATCH 106/113] qimgv: revbump for ffmpeg6

---
 srcpkgs/qimgv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qimgv/template b/srcpkgs/qimgv/template
index dd341dfe1bfce..8a7e1c081ef12 100644
--- a/srcpkgs/qimgv/template
+++ b/srcpkgs/qimgv/template
@@ -1,7 +1,7 @@
 # Template file for 'qimgv'
 pkgname=qimgv
 version=1.0.2
-revision=3
+revision=4
 build_style=cmake
 configure_args="$(vopt_if video -DVIDEO_SUPPORT=ON -DVIDEO_SUPPORT=OFF)
  $(vopt_if scale -DOPENCV_SUPPORT=ON -DOPENCV_SUPPORT=OFF)

From 0fae751609643c01741a3987c8e325288f00a029 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 18:00:36 -0500
Subject: [PATCH 107/113] kfilemetadata5: revbump for ffmpeg6

---
 srcpkgs/kfilemetadata5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kfilemetadata5/template b/srcpkgs/kfilemetadata5/template
index 51fd6fec8c1c0..ad229b4c2e241 100644
--- a/srcpkgs/kfilemetadata5/template
+++ b/srcpkgs/kfilemetadata5/template
@@ -1,7 +1,7 @@
 # Template file for 'kfilemetadata5'
 pkgname=kfilemetadata5
 version=5.113.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="kcoreaddons extra-cmake-modules pkg-config qt5-host-tools qt5-qmake
  gettext kcoreaddons python3"

From c1fd922bbd683d17dc22d50be1775e36744ae8bd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 8 Dec 2023 11:46:01 -0500
Subject: [PATCH 108/113] vba-m: revbump for ffmpeg6

---
 srcpkgs/vba-m/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vba-m/template b/srcpkgs/vba-m/template
index 3d135efa1d0b6..3c5a20db0fa98 100644
--- a/srcpkgs/vba-m/template
+++ b/srcpkgs/vba-m/template
@@ -2,7 +2,7 @@
 pkgname=vba-m
 reverts=1292_2
 version=2.1.9
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_GTK=TRUE -DENABLE_FFMPEG=TRUE -DENABLE_LINK=TRUE -DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="gettext pkg-config unzip zip yasm wxWidgets-gtk3-devel"

From ea981e576c69460d987ba3fece3c83cfcaabb3fb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 8 Dec 2023 11:46:19 -0500
Subject: [PATCH 109/113] dolphin-emu: revbump for ffmpeg6

---
 srcpkgs/dolphin-emu/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/dolphin-emu/template b/srcpkgs/dolphin-emu/template
index 862d3ae964eec..a7ae0efb58fb7 100644
--- a/srcpkgs/dolphin-emu/template
+++ b/srcpkgs/dolphin-emu/template
@@ -1,7 +1,7 @@
 # Template file for 'dolphin-emu'
 pkgname=dolphin-emu
 version=5.0.19368
-revision=3
+revision=4
 _dolphin_commit=dadbeb4bae7e7fa23af2b46e0add4143094dc107
 _mgba_commit=44e074a15e9651481f7f652ac006a7c9d58cbeb9
 _googletest_commit=be03d00f5f0cc3a997d1a368bee8a1fe93651f48

From ff70d924e0e8fefc1216c9182202fdfe359803a8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 19 Dec 2023 15:38:51 -0500
Subject: [PATCH 110/113] qtox: revbump for ffmpeg4

---
 srcpkgs/qtox/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtox/template b/srcpkgs/qtox/template
index bb70e7f51240a..755e4462bc013 100644
--- a/srcpkgs/qtox/template
+++ b/srcpkgs/qtox/template
@@ -1,13 +1,13 @@
 # Template file for 'qtox'
 pkgname=qtox
 version=1.17.6
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DUPDATE_CHECK=OFF
  -DGIT_DESCRIBE=${version}
  $(vopt_if snorenotify -DDESKTOP_NOTIFICATIONS=ON)"
 hostmakedepends="pkg-config qt5-host-tools qt5-devel"
-makedepends="ffmpeg-devel libexif-devel libopenal-devel libsodium-devel
+makedepends="ffmpeg4-devel libexif-devel libopenal-devel libsodium-devel
  libvpx-devel opus-devel qrencode-devel qt5-svg-devel sonnet-devel
  sqlcipher-devel toxcore-devel
  $(vopt_if snorenotify snorenotify-devel)"

From c65745517bae38021d33507d58e0674f2227897e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 11 Jan 2024 11:52:00 -0500
Subject: [PATCH 111/113] arcan: revbump for ffmpeg6

---
 srcpkgs/arcan/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/arcan/template b/srcpkgs/arcan/template
index ff9091f90ebb1..030091a6cc9d0 100644
--- a/srcpkgs/arcan/template
+++ b/srcpkgs/arcan/template
@@ -2,7 +2,7 @@
 # !! keep synced with: acfgfs aclip aloadimage
 pkgname=arcan
 version=0.6.2.1
-revision=2
+revision=3
 create_wrksrc=yes
 build_wrksrc=arcan/src
 build_style=cmake

From 8fd0a2a782cf54d866b78a28c7f5f659cb8e08b6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 11 Jan 2024 11:52:10 -0500
Subject: [PATCH 112/113] notcurses: revbump for ffmpeg6

---
 srcpkgs/notcurses/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/notcurses/template b/srcpkgs/notcurses/template
index 48a7463cb68eb..515f316ab4576 100644
--- a/srcpkgs/notcurses/template
+++ b/srcpkgs/notcurses/template
@@ -1,7 +1,7 @@
 # Template file for 'notcurses'
 pkgname=notcurses
 version=3.0.9
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DUSE_STATIC=ON -DUSE_QRCODEGEN=On $(vopt_bool man USE_PANDOC)"
 hostmakedepends="pkg-config $(vopt_if man pandoc)"

From 4f27e8e00d1ca62205f4ce4ee7a0433e419fc1be Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Feb 2024 14:28:38 -0500
Subject: [PATCH 113/113] New package: oneVPL-intel-gpu-24.1.3

---
 srcpkgs/oneVPL-intel-gpu/template | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
 create mode 100644 srcpkgs/oneVPL-intel-gpu/template

diff --git a/srcpkgs/oneVPL-intel-gpu/template b/srcpkgs/oneVPL-intel-gpu/template
new file mode 100644
index 0000000000000..8b93cfabf7fc8
--- /dev/null
+++ b/srcpkgs/oneVPL-intel-gpu/template
@@ -0,0 +1,18 @@
+# Template file for 'oneVPL-intel-gpu'
+pkgname=oneVPL-intel-gpu
+version=24.1.3
+revision=1
+build_style=cmake
+hostmakedepends="pkg-config"
+makedepends="libva-devel libdrm-devel"
+short_desc="Intel oneVPL GPU Runtime"
+maintainer="zlice <zlice555@gmail.com>"
+license="MIT"
+homepage="https://github.com/oneapi-src/oneVPL-intel-gpu"
+changelog="https://github.com/oneapi-src/oneVPL-intel-gpu/blob/main/CHANGELOG.md"
+distfiles="https://github.com/oneapi-src/oneVPL-intel-gpu/archive/refs/tags/intel-onevpl-${version}.tar.gz"
+checksum=15d34e4304d7aeb5ea5e529b6f51171109cef42525113321f675bc14e56c697e
+
+post_install() {
+	vlicense LICENSE
+}

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (64 preceding siblings ...)
  2024-02-11 22:49 ` zlice
@ 2024-02-15 19:52 ` zlice
  2024-02-20 18:21 ` zlice
                   ` (31 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2024-02-15 19:52 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 4846 bytes --]

There is an updated pull request by zlice against master on the void-packages repository

https://github.com/zlice/void-packages ffmpeg6-split
https://github.com/void-linux/void-packages/pull/43761

ffmpeg6 split
[ci skip]


#### Testing the changes

- I tested the changes in this PR: **YES**

main testing has been vaapi in Firefox Nightly and enc/dec in Shotcut on Intel A770

#### New package

- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**

#### Local build testing

- I built this PR locally for my native architecture, **x86_64**

#### Discussion

Continuation of https://github.com/void-linux/void-packages/pull/36315

`libavresample` is deprecated, but marked as a dependency when trying to build other packages and install `ffmpeg`(6). I think the right way to handle this is make a meta package and the add to removals?


##### Commit naming / misc

~~Commits are 'dirty' right now, running with [gstreamer 1.22.1 updates](https://github.com/void-linux/void-packages/pull/42861) and [Intel OpenCL](https://github.com/void-linux/void-packages/pull/43084). This will also make [intel packages pr](https://github.com/void-linux/void-packages/pull/41132) obsolete.~~ (see Requirements below)

Maintainer for previous ffmpeg(4) was orphaned, I can put my name in there if that matters, though I don't exactly see myself keeping up on ffmpeg.

~~This updates QT5 which looks like it is usually hosted by Johnny. Not sure if there's any reason to stay there or these sources are fine.~~ Using qt5.15.11 now, revbumps and some patches.

##### STILL FFMPEG4

These are a mix of emulators, games and/or older packages.

- ~~attract~~ (2.7 builds)
- ~~audacity (https://github.com/audacity/audacity/issues/2305 and https://sourceforge.net/p/portmedia/wiki/portsmf/ is 'beta')~~ (updated to 3.x, compiles with ffmpeg6)
- ~~ccextractor~~ (master patches)
- vice (3.8 compiles, needs makedepends libcurl-devel)
- kodi
- mlt (only dep left is flowblade - flowblade 2.12.0.2 with mlt7-python3 can 'render' videos with cpu and gpu)
- ~~synfig (mlt)~~ (work with mlt7, bump synfigstudio)
- tvheadend (download page recommends using 4.3 which compiles fine, 4.4 eta is Q1 2024)
- ~~ssr~~ (patches)
- ~~spek-alternative~~ (replace with spek-x)
- ~~ppsspp~~ ~~(1.17.1 is out, but there's 5+ distfiles that are all git commits)~~ (minor patch)
- olive (has been in alpha since 2020, seems they do nightly builds and appimages)
- moc
- mediastreamer (linphone links are dead, changed to github belladonne. their stuff never worked for me but there are updates if someone wants to give it a try)
- libextractor (1.13 compiles, remove exiv2 patch)
- idjc (0.9.8 compiles, remove python3.10 patch, needs makedepends libebur128-devel and libshout-idjc 2.4.6 with '-r1' for distfile)
- hedgewars
- ~~ffmpegthumbnailer~~ (patches for moviedecoder.xxx files)
- ~~ffmpegthumbs~~ (latest compiles)
- deadbeef (1.9.6 may work but requires libdispatch from apple)
- ~~omxplayer~~ (package removed, deprecated in favor of vlc)
- qtav (fork has ffmpeg 5 patch - https://github.com/cmguo/QtAV)
- `vlc` (vlc4 will support ffmpeg5, there's a patch to build 3.x with ffmpeg5 but it will lack vaapi)
- `osg` (OpenSceneGraph plus `xine-lib`)


##### HAVE NOT BUILT YET

- ~~omxplayer (rpi only? ffmpeg4)~~ (removed)
- kodi (big, but ffmpeg4)


##### UPDATED (for ffmpeg6)

- ~~blender: update to 3.5.1~~ ~~will be revbump with~~ https://github.com/void-linux/void-packages/pull/43992
- unpaper: update to 7.0.0.
- guvcview: update to 2.0.8.
- ~~qt5: update to 5.15.8~~ updated by another PR to 5.15.11
- ~~qt5-webengine: update to 5.18.15~~ updated by another PR to 5.15.16 (some patching for ffmpeg build)
- ~~shiboken2: revbump for qt5.15.8 (patch)~~ updated by another PR to 5.15.10
- ~~python3-pyside2: update to 5.15.8 (patch)~~ updated by another PR to 5.15.10
- New package: spex-x replaces spek-alternative for ffmpeg-6.0


##### Requirements

- ~~[gstreamer 1.22.2](https://github.com/void-linux/void-packages/pull/42861)~~ - a few packages use ffmpeg-devel and require a revbump

- ~~[Intel Packages](https://github.com/void-linux/void-packages/pull/41132) [Intel Packages v2](https://github.com/void-linux/void-packages/pull/47330) - ffmpeg4 uses different libraries than 6 (libmfx / Intel-MediaSDK vs only oneVPL that Intel is moving to), both are included here~~. Using replacement oneVPL from OBS update.

- ~~[shotcut 23.05.14](https://github.com/void-linux/void-packages/pull/44260)~~

- https://github.com/void-linux/void-packages/pull/44781 will remove from this PR

A patch file from https://github.com/void-linux/void-packages/pull/43761.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ffmpeg6-split-43761.patch --]
[-- Type: text/x-diff, Size: 244216 bytes --]

From 8eacbb90ee73bac61e19296ebf992e45a117fd46 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:16:56 -0400
Subject: [PATCH 001/113] ffmpeg: update to 6.0.1.

---
 common/shlibs                                 | 26 ++++---
 srcpkgs/ffmpeg/files/altivec.patch            | 60 ---------------
 .../patches/armv5tel-floating-point.patch     | 18 -----
 srcpkgs/ffmpeg/patches/binutils-2.41.patch    | 73 -------------------
 ...h-libavcodec-libsvtav1-ten_bit_format.diff | 40 ----------
 .../workaround-mesa-readeon-vaapi-bug.patch   | 28 -------
 srcpkgs/ffmpeg/template                       | 40 +++++-----
 7 files changed, 37 insertions(+), 248 deletions(-)
 delete mode 100644 srcpkgs/ffmpeg/files/altivec.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/binutils-2.41.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 delete mode 100644 srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch

diff --git a/common/shlibs b/common/shlibs
index 935ace564ff11..02da0d0bd2e53 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -389,15 +389,23 @@ libid3tag.so.0 libid3tag-0.15.1b_1
 libgif.so.7 giflib-5.1.0_1
 libImlib2.so.1 imlib2-1.4.2_1
 libmp3lame.so.0 lame-3.98.2_1
-libavdevice.so.58 libavdevice-4.0_1
-libavformat.so.58 libavformat-4.0_1
-libswscale.so.5 libswscale-4.0_1
-libswresample.so.3 libswresample-4.0_1
-libavresample.so.4 libavresample-4.0_1
-libpostproc.so.55 libpostproc-4.0_1
-libavcodec.so.58 libavcodec-4.0_1
-libavutil.so.56 libavutil-4.0_1
-libavfilter.so.7 libavfilter-4.0_1
+libavdevice.so.60 libavdevice-6.0_1
+libavformat.so.60 libavformat-6.0_1
+libswscale.so.7 libswscale-6.0_1
+libswresample.so.4 libswresample-6.0_1
+libpostproc.so.57 libpostproc-6.0_1
+libavcodec.so.60 libavcodec-6.0_1
+libavutil.so.58 libavutil-6.0_1
+libavfilter.so.9 libavfilter-6.0_1
+libavdevice.so.58 libavdevice4-4.0_1
+libavformat.so.58 libavformat4-4.0_1
+libswscale.so.5 libswscale4-4.0_1
+libswresample.so.3 libswresample4-4.0_1
+libavresample.so.4 libavresample4-4.0_1
+libpostproc.so.55 libpostproc4-4.0_1
+libavcodec.so.58 libavcodec4-4.0_1
+libavutil.so.56 libavutil4-4.0_1
+libavfilter.so.7 libavfilter4-4.0_1
 libSDL-1.2.so.0 SDL-1.2.14_1
 libSDL_image-1.2.so.0 SDL_image-1.2.10_1
 libx264.so.157 x264-20190507.2245_1
diff --git a/srcpkgs/ffmpeg/files/altivec.patch b/srcpkgs/ffmpeg/files/altivec.patch
deleted file mode 100644
index 9c57200463320..0000000000000
--- a/srcpkgs/ffmpeg/files/altivec.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-revert some altivec specific change on all ppc* except ppc64le*
-
-q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
-conditionally, for ppc* but not ppc64le* (the new code is valid for
-POWER8 VSX which LE targets as a baseline but not BE)"
-
-
-This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
----
- libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
- 1 file changed, 20 insertions(+), 4 deletions(-)
-
-diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
-index 536545293d..c1e2852adb 100644
---- a/libswscale/ppc/yuv2rgb_altivec.c
-+++ b/libswscale/ppc/yuv2rgb_altivec.c
-@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-     vector signed short R1, G1, B1;                                           \
-     vector unsigned char R, G, B;                                             \
-                                                                               \
-+    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
-+    vector unsigned char align_perm;                                          \
-+                                                                              \
-     vector signed short lCY       = c->CY;                                    \
-     vector signed short lOY       = c->OY;                                    \
-     vector signed short lCRV      = c->CRV;                                   \
-@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
-                                                                               \
-         for (j = 0; j < w / 16; j++) {                                        \
--            y0 = vec_xl(0, y1i);                                              \
-+            y1ivP = (const vector unsigned char *) y1i;                       \
-+            y2ivP = (const vector unsigned char *) y2i;                       \
-+            uivP  = (const vector unsigned char *) ui;                        \
-+            vivP  = (const vector unsigned char *) vi;                        \
-+                                                                              \
-+            align_perm = vec_lvsl(0, y1i);                                    \
-+            y0 = (vector unsigned char)                                       \
-+                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
-                                                                               \
--            y1 = vec_xl(0, y2i);                                              \
-+            align_perm = vec_lvsl(0, y2i);                                    \
-+            y1 = (vector unsigned char)                                       \
-+                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
-                                                                               \
--            u = (vector signed char) vec_xl(0, ui);                           \
-+            align_perm = vec_lvsl(0, ui);                                     \
-+            u = (vector signed char)                                          \
-+                    vec_perm(uivP[0], uivP[1], align_perm);                   \
-                                                                               \
--            v = (vector signed char) vec_xl(0, vi);                           \
-+            align_perm = vec_lvsl(0, vi);                                     \
-+            v = (vector signed char)                                          \
-+                    vec_perm(vivP[0], vivP[1], align_perm);                   \
-                                                                               \
-             u = (vector signed char)                                          \
-                     vec_sub(u,                                                \
--- 
-2.27.0
-
diff --git a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
deleted file mode 100644
index 9a55178c74f0f..0000000000000
--- a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
-+++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
-@@ -39,6 +39,15 @@
- #endif
- #include <fenv.h>
- 
-+#if (FE_ALL_EXCEPT == 0)
-+/* E.g. ARM soft float does not define these */
-+#define FE_INVALID    0
-+#define FE_DIVBYZERO  0
-+#define FE_OVERFLOW   0
-+#define FE_UNDERFLOW  0
-+#define FE_INEXACT    0
-+#endif
-+
- #if CONFIG_LIBFONTCONFIG
- #include <fontconfig/fontconfig.h>
- #endif
diff --git a/srcpkgs/ffmpeg/patches/binutils-2.41.patch b/srcpkgs/ffmpeg/patches/binutils-2.41.patch
deleted file mode 100644
index 53a596d0ee7d4..0000000000000
--- a/srcpkgs/ffmpeg/patches/binutils-2.41.patch
+++ /dev/null
@@ -1,73 +0,0 @@
-From effadce6c756247ea8bae32dc13bb3e6f464f0eb Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= <remi@remlab.net>
-Date: Sun, 16 Jul 2023 18:18:02 +0300
-Subject: [PATCH] avcodec/x86/mathops: clip constants used with shift
- instructions within inline assembly
-
-Fixes assembling with binutil as >= 2.41
-
-Signed-off-by: James Almer <jamrial@gmail.com>
----
- libavcodec/x86/mathops.h | 26 +++++++++++++++++++++++---
- 1 file changed, 23 insertions(+), 3 deletions(-)
-
-diff --git a/libavcodec/x86/mathops.h b/libavcodec/x86/mathops.h
-index 6298f5ed1983b..ca7e2dffc1076 100644
---- a/libavcodec/x86/mathops.h
-+++ b/libavcodec/x86/mathops.h
-@@ -35,12 +35,20 @@
- static av_always_inline av_const int MULL(int a, int b, unsigned shift)
- {
-     int rt, dummy;
-+    if (__builtin_constant_p(shift))
-     __asm__ (
-         "imull %3               \n\t"
-         "shrdl %4, %%edx, %%eax \n\t"
-         :"=a"(rt), "=d"(dummy)
--        :"a"(a), "rm"(b), "ci"((uint8_t)shift)
-+        :"a"(a), "rm"(b), "i"(shift & 0x1F)
-     );
-+    else
-+        __asm__ (
-+            "imull %3               \n\t"
-+            "shrdl %4, %%edx, %%eax \n\t"
-+            :"=a"(rt), "=d"(dummy)
-+            :"a"(a), "rm"(b), "c"((uint8_t)shift)
-+        );
-     return rt;
- }
- 
-@@ -113,19 +121,31 @@ __asm__ volatile(\
- // avoid +32 for shift optimization (gcc should do that ...)
- #define NEG_SSR32 NEG_SSR32
- static inline  int32_t NEG_SSR32( int32_t a, int8_t s){
-+    if (__builtin_constant_p(s))
-     __asm__ ("sarl %1, %0\n\t"
-          : "+r" (a)
--         : "ic" ((uint8_t)(-s))
-+         : "i" (-s & 0x1F)
-     );
-+    else
-+        __asm__ ("sarl %1, %0\n\t"
-+               : "+r" (a)
-+               : "c" ((uint8_t)(-s))
-+        );
-     return a;
- }
- 
- #define NEG_USR32 NEG_USR32
- static inline uint32_t NEG_USR32(uint32_t a, int8_t s){
-+    if (__builtin_constant_p(s))
-     __asm__ ("shrl %1, %0\n\t"
-          : "+r" (a)
--         : "ic" ((uint8_t)(-s))
-+         : "i" (-s & 0x1F)
-     );
-+    else
-+        __asm__ ("shrl %1, %0\n\t"
-+               : "+r" (a)
-+               : "c" ((uint8_t)(-s))
-+        );
-     return a;
- }
- 
diff --git a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
deleted file mode 100644
index aa948f7a8a2df..0000000000000
--- a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
+++ /dev/null
@@ -1,40 +0,0 @@
-#==================================================================================================
-# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
-# From: Christopher Degawa <christopher.degawa@intel.com>
-# Date: Thu, 20 Oct 2022 22:55:27 -0500
-# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
-#
-# compressed_ten_bit_format has been deprecated upstream and has no effect
-# and can be removed. Plus, technically it was never used in the first place
-# since it would require the app (ffmpeg) to set it and do additional
-# processing of the input frames.
-#
-# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
-#
-# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
-#==================================================================================================
---- a/libavcodec/libsvtav1.c
-+++ b/libavcodec/libsvtav1.c
-@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
- 
- static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
- {
--    const int    pack_mode_10bit =
--        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
--    const size_t luma_size_8bit  =
--        config->source_width * config->source_height * (1 << pack_mode_10bit);
--    const size_t luma_size_10bit =
--        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
-+    const size_t luma_size = config->source_width * config->source_height *
-+        (config->encoder_bit_depth > 8 ? 2 : 1);
- 
-     EbSvtIOFormat *in_data;
- 
--    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
-+    svt_enc->raw_size = luma_size * 3 / 2;
- 
-     // allocate buffer for in and out
-     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
--- 
-GitLab
-
diff --git a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
deleted file mode 100644
index 00e3f68a415b8..0000000000000
--- a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
-From: Rainer Hochecker <fernetmenta@online.de>
-Date: Sat, 26 Jan 2019 19:48:35 +0100
-Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
-
-This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
-It was hit frequently when watching h264 channels received via DVB-X.
-Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
----
- libavcodec/vaapi_h264.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
-index 5854587a255..f12fdc457a4 100644
---- a/libavcodec/vaapi_h264.c
-+++ b/libavcodec/vaapi_h264.c
-@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
-     H264SliceContext *sl = &h->slice_ctx[0];
-     int ret;
- 
-+    if (pic->nb_slices == 0) {
-+        ret = AVERROR_INVALIDDATA;
-+        goto finish;
-+    }
-+
-     ret = ff_vaapi_decode_issue(avctx, pic);
-     if (ret < 0)
-         goto finish;
diff --git a/srcpkgs/ffmpeg/template b/srcpkgs/ffmpeg/template
index 1ebb436135938..f1e4712c41d08 100644
--- a/srcpkgs/ffmpeg/template
+++ b/srcpkgs/ffmpeg/template
@@ -1,15 +1,15 @@
 # Template file for 'ffmpeg'
 # audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
 pkgname=ffmpeg
-version=4.4.4
-revision=6
+version=6.0.1
+revision=1
 short_desc="Decoding, encoding and streaming software"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="https://www.ffmpeg.org"
 changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
 distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
-checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+checksum=9b16b8731d78e596b4be0d720428ca42df642bb2d78342881ff7f5bc29fc9623
 
 hostmakedepends="pkg-config perl"
 makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
@@ -26,12 +26,13 @@ makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-deve
  $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
  $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
  $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
- $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers Vulkan-Tools Vulkan-ValidationLayers')
+ $(vopt_if onevpl 'oneVPL oneVPL-devel')
  $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
 depends="ffplay>=${version}_${revision}"
 
 build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
- dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec onevpl"
 build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
 desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
 desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
@@ -39,9 +40,13 @@ desc_option_sofa="Enable support for AES SOFA"
 desc_option_webp="Enable support for WebP"
 
 case "$XBPS_TARGET_MACHINE" in
-	i686*|x86_64*)
-		hostmakedepends+=" nasm"
+	i686*)
 		build_options_default+=" vaapi vdpau nvenc nvdec"
+		hostmakedepends+=" nasm"
+		;;
+	x86_64*)
+		hostmakedepends+=" nasm"
+		build_options_default+=" vaapi vdpau nvenc nvdec onevpl"
 		;;
 	ppc64*) build_options_default+=" vaapi vdpau";;
 	mips*) CFLAGS="-mnan=legacy";;
@@ -65,8 +70,6 @@ post_patch() {
 		ppc64le*) ;;
 		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
 	esac
-
-	vsed -i libavfilter/vf_libvmaf.c -e 's!/usr/local/share/model/\(vmaf_v0.6.1\).pkl!/usr/share/vmaf/\1.json!'
 }
 
 do_configure() {
@@ -115,18 +118,19 @@ do_configure() {
 		$(vopt_enable x265 libx265) \
 		$(vopt_enable v4l2 libv4l2) \
 		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
-		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		--enable-libbs2b --enable-libvidstab \
 		$(vopt_enable dav1d libdav1d) \
 		$(vopt_enable zimg libzimg) \
 		$(vopt_enable webp libwebp) \
 		$(vopt_enable sofa libmysofa) \
 		$(vopt_enable vulkan) \
+		$(vopt_enable onevpl libvpl) \
 		$(vopt_enable drm libdrm) \
 		$(vopt_enable svtav1 libsvtav1) \
 		$(vopt_enable srt libsrt) \
 		$(vopt_enable rist librist) \
-		$(vopt_if nvenc '--enable-nvenc') \
-		$(vopt_if nvdec '--enable-nvdec')
+		$(vopt_enable nvenc nvenc) \
+		$(vopt_enable nvdec nvdec)
 }
 
 do_build() {
@@ -153,10 +157,8 @@ libavdevice_package() {
 }
 
 libavresample_package() {
-	short_desc="FFmpeg audio resampling library"
-	pkg_install() {
-		vmove "usr/lib/libavresample.so.*"
-	}
+	short_desc="Package deprecated, removal needed"
+	build_style=meta
 }
 
 libavformat_package() {
@@ -210,15 +212,13 @@ ffmpeg-devel_package() {
 		libavfilter>=${version}_${revision}
 		libpostproc>=${version}_${revision}
 		libswscale>=${version}_${revision}
-		libswresample>=${version}_${revision}
-		libavresample>=${version}_${revision}"
+		libswresample>=${version}_${revision}"
 	short_desc+=" - development files"
-
+	conflicts="ffmpeg4-devel"
 	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
 		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
 		nostrip_files="/usr/lib/libavfilter.a"
 	fi
-
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig

From 0e6ccdc76ce2ff4fb2dd8c81e17c8043dd6428a6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:14 -0400
Subject: [PATCH 002/113] openshot: revbump for ffmpeg6

---
 srcpkgs/openshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openshot/template b/srcpkgs/openshot/template
index 3849858fe963b..12789bc986749 100644
--- a/srcpkgs/openshot/template
+++ b/srcpkgs/openshot/template
@@ -1,7 +1,7 @@
 # Template file for 'openshot'
 pkgname=openshot
 version=3.1.1
-revision=1
+revision=2
 build_style=python3-module
 hostmakedepends="python3 python3-setuptools"
 makedepends="ffmpeg-devel python3-PyQt5"

From 9bb4ddb0b0957bb8d0bfe2295fb7f3d70ac12850 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:36 -0400
Subject: [PATCH 003/113] sumo: revbump for ffmpeg6

---
 srcpkgs/sumo/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/sumo/template b/srcpkgs/sumo/template
index a3fe134aa5acc..a730afa9fafa9 100644
--- a/srcpkgs/sumo/template
+++ b/srcpkgs/sumo/template
@@ -1,7 +1,7 @@
 # Template file for 'sumo'
 pkgname=sumo
 version=1.12.0
-revision=6
+revision=7
 build_style=cmake
 hostmakedepends="libgdal-tools pkg-config swig python3-setuptools"
 makedepends="python3-devel ffmpeg-devel fox-devel gl2ps-devel libgdal-devel

From 170659dfa350105d69109a184cde5435b94d6a0a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:56:22 -0400
Subject: [PATCH 004/113] New package: ffmpeg4-4.4.4.

---
 srcpkgs/ffmpeg4-devel                         |   1 +
 srcpkgs/ffmpeg4/files/altivec.patch           |  60 +++++
 .../patches/armv5tel-floating-point.patch     |  18 ++
 srcpkgs/ffmpeg4/patches/binutils-2.41.patch   |  73 ++++++
 ...h-libavcodec-libsvtav1-ten_bit_format.diff |  40 +++
 .../workaround-mesa-readeon-vaapi-bug.patch   |  28 +++
 srcpkgs/ffmpeg4/template                      | 234 ++++++++++++++++++
 srcpkgs/libavcodec4                           |   1 +
 srcpkgs/libavdevice4                          |   1 +
 srcpkgs/libavfilter4                          |   1 +
 srcpkgs/libavformat4                          |   1 +
 srcpkgs/libavresample4                        |   1 +
 srcpkgs/libavutil4                            |   1 +
 srcpkgs/libpostproc4                          |   1 +
 srcpkgs/libswresample4                        |   1 +
 srcpkgs/libswscale4                           |   1 +
 16 files changed, 463 insertions(+)
 create mode 120000 srcpkgs/ffmpeg4-devel
 create mode 100644 srcpkgs/ffmpeg4/files/altivec.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/binutils-2.41.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 create mode 100644 srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
 create mode 100644 srcpkgs/ffmpeg4/template
 create mode 120000 srcpkgs/libavcodec4
 create mode 120000 srcpkgs/libavdevice4
 create mode 120000 srcpkgs/libavfilter4
 create mode 120000 srcpkgs/libavformat4
 create mode 120000 srcpkgs/libavresample4
 create mode 120000 srcpkgs/libavutil4
 create mode 120000 srcpkgs/libpostproc4
 create mode 120000 srcpkgs/libswresample4
 create mode 120000 srcpkgs/libswscale4

diff --git a/srcpkgs/ffmpeg4-devel b/srcpkgs/ffmpeg4-devel
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/ffmpeg4-devel
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/ffmpeg4/files/altivec.patch b/srcpkgs/ffmpeg4/files/altivec.patch
new file mode 100644
index 0000000000000..9c57200463320
--- /dev/null
+++ b/srcpkgs/ffmpeg4/files/altivec.patch
@@ -0,0 +1,60 @@
+revert some altivec specific change on all ppc* except ppc64le*
+
+q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
+conditionally, for ppc* but not ppc64le* (the new code is valid for
+POWER8 VSX which LE targets as a baseline but not BE)"
+
+
+This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
+---
+ libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
+ 1 file changed, 20 insertions(+), 4 deletions(-)
+
+diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
+index 536545293d..c1e2852adb 100644
+--- a/libswscale/ppc/yuv2rgb_altivec.c
++++ b/libswscale/ppc/yuv2rgb_altivec.c
+@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+     vector signed short R1, G1, B1;                                           \
+     vector unsigned char R, G, B;                                             \
+                                                                               \
++    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
++    vector unsigned char align_perm;                                          \
++                                                                              \
+     vector signed short lCY       = c->CY;                                    \
+     vector signed short lOY       = c->OY;                                    \
+     vector signed short lCRV      = c->CRV;                                   \
+@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
+                                                                               \
+         for (j = 0; j < w / 16; j++) {                                        \
+-            y0 = vec_xl(0, y1i);                                              \
++            y1ivP = (const vector unsigned char *) y1i;                       \
++            y2ivP = (const vector unsigned char *) y2i;                       \
++            uivP  = (const vector unsigned char *) ui;                        \
++            vivP  = (const vector unsigned char *) vi;                        \
++                                                                              \
++            align_perm = vec_lvsl(0, y1i);                                    \
++            y0 = (vector unsigned char)                                       \
++                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
+                                                                               \
+-            y1 = vec_xl(0, y2i);                                              \
++            align_perm = vec_lvsl(0, y2i);                                    \
++            y1 = (vector unsigned char)                                       \
++                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
+                                                                               \
+-            u = (vector signed char) vec_xl(0, ui);                           \
++            align_perm = vec_lvsl(0, ui);                                     \
++            u = (vector signed char)                                          \
++                    vec_perm(uivP[0], uivP[1], align_perm);                   \
+                                                                               \
+-            v = (vector signed char) vec_xl(0, vi);                           \
++            align_perm = vec_lvsl(0, vi);                                     \
++            v = (vector signed char)                                          \
++                    vec_perm(vivP[0], vivP[1], align_perm);                   \
+                                                                               \
+             u = (vector signed char)                                          \
+                     vec_sub(u,                                                \
+-- 
+2.27.0
+
diff --git a/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
new file mode 100644
index 0000000000000..9a55178c74f0f
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
@@ -0,0 +1,18 @@
+--- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
++++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
+@@ -39,6 +39,15 @@
+ #endif
+ #include <fenv.h>
+ 
++#if (FE_ALL_EXCEPT == 0)
++/* E.g. ARM soft float does not define these */
++#define FE_INVALID    0
++#define FE_DIVBYZERO  0
++#define FE_OVERFLOW   0
++#define FE_UNDERFLOW  0
++#define FE_INEXACT    0
++#endif
++
+ #if CONFIG_LIBFONTCONFIG
+ #include <fontconfig/fontconfig.h>
+ #endif
diff --git a/srcpkgs/ffmpeg4/patches/binutils-2.41.patch b/srcpkgs/ffmpeg4/patches/binutils-2.41.patch
new file mode 100644
index 0000000000000..53a596d0ee7d4
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/binutils-2.41.patch
@@ -0,0 +1,73 @@
+From effadce6c756247ea8bae32dc13bb3e6f464f0eb Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= <remi@remlab.net>
+Date: Sun, 16 Jul 2023 18:18:02 +0300
+Subject: [PATCH] avcodec/x86/mathops: clip constants used with shift
+ instructions within inline assembly
+
+Fixes assembling with binutil as >= 2.41
+
+Signed-off-by: James Almer <jamrial@gmail.com>
+---
+ libavcodec/x86/mathops.h | 26 +++++++++++++++++++++++---
+ 1 file changed, 23 insertions(+), 3 deletions(-)
+
+diff --git a/libavcodec/x86/mathops.h b/libavcodec/x86/mathops.h
+index 6298f5ed1983b..ca7e2dffc1076 100644
+--- a/libavcodec/x86/mathops.h
++++ b/libavcodec/x86/mathops.h
+@@ -35,12 +35,20 @@
+ static av_always_inline av_const int MULL(int a, int b, unsigned shift)
+ {
+     int rt, dummy;
++    if (__builtin_constant_p(shift))
+     __asm__ (
+         "imull %3               \n\t"
+         "shrdl %4, %%edx, %%eax \n\t"
+         :"=a"(rt), "=d"(dummy)
+-        :"a"(a), "rm"(b), "ci"((uint8_t)shift)
++        :"a"(a), "rm"(b), "i"(shift & 0x1F)
+     );
++    else
++        __asm__ (
++            "imull %3               \n\t"
++            "shrdl %4, %%edx, %%eax \n\t"
++            :"=a"(rt), "=d"(dummy)
++            :"a"(a), "rm"(b), "c"((uint8_t)shift)
++        );
+     return rt;
+ }
+ 
+@@ -113,19 +121,31 @@ __asm__ volatile(\
+ // avoid +32 for shift optimization (gcc should do that ...)
+ #define NEG_SSR32 NEG_SSR32
+ static inline  int32_t NEG_SSR32( int32_t a, int8_t s){
++    if (__builtin_constant_p(s))
+     __asm__ ("sarl %1, %0\n\t"
+          : "+r" (a)
+-         : "ic" ((uint8_t)(-s))
++         : "i" (-s & 0x1F)
+     );
++    else
++        __asm__ ("sarl %1, %0\n\t"
++               : "+r" (a)
++               : "c" ((uint8_t)(-s))
++        );
+     return a;
+ }
+ 
+ #define NEG_USR32 NEG_USR32
+ static inline uint32_t NEG_USR32(uint32_t a, int8_t s){
++    if (__builtin_constant_p(s))
+     __asm__ ("shrl %1, %0\n\t"
+          : "+r" (a)
+-         : "ic" ((uint8_t)(-s))
++         : "i" (-s & 0x1F)
+     );
++    else
++        __asm__ ("shrl %1, %0\n\t"
++               : "+r" (a)
++               : "c" ((uint8_t)(-s))
++        );
+     return a;
+ }
+ 
diff --git a/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
new file mode 100644
index 0000000000000..aa948f7a8a2df
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
@@ -0,0 +1,40 @@
+#==================================================================================================
+# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
+# From: Christopher Degawa <christopher.degawa@intel.com>
+# Date: Thu, 20 Oct 2022 22:55:27 -0500
+# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
+#
+# compressed_ten_bit_format has been deprecated upstream and has no effect
+# and can be removed. Plus, technically it was never used in the first place
+# since it would require the app (ffmpeg) to set it and do additional
+# processing of the input frames.
+#
+# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
+#
+# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
+#==================================================================================================
+--- a/libavcodec/libsvtav1.c
++++ b/libavcodec/libsvtav1.c
+@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
+ 
+ static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
+ {
+-    const int    pack_mode_10bit =
+-        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
+-    const size_t luma_size_8bit  =
+-        config->source_width * config->source_height * (1 << pack_mode_10bit);
+-    const size_t luma_size_10bit =
+-        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
++    const size_t luma_size = config->source_width * config->source_height *
++        (config->encoder_bit_depth > 8 ? 2 : 1);
+ 
+     EbSvtIOFormat *in_data;
+ 
+-    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
++    svt_enc->raw_size = luma_size * 3 / 2;
+ 
+     // allocate buffer for in and out
+     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
+-- 
+GitLab
+
diff --git a/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
new file mode 100644
index 0000000000000..00e3f68a415b8
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
@@ -0,0 +1,28 @@
+From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
+From: Rainer Hochecker <fernetmenta@online.de>
+Date: Sat, 26 Jan 2019 19:48:35 +0100
+Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
+
+This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
+It was hit frequently when watching h264 channels received via DVB-X.
+Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
+---
+ libavcodec/vaapi_h264.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
+index 5854587a255..f12fdc457a4 100644
+--- a/libavcodec/vaapi_h264.c
++++ b/libavcodec/vaapi_h264.c
+@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
+     H264SliceContext *sl = &h->slice_ctx[0];
+     int ret;
+ 
++    if (pic->nb_slices == 0) {
++        ret = AVERROR_INVALIDDATA;
++        goto finish;
++    }
++
+     ret = ff_vaapi_decode_issue(avctx, pic);
+     if (ret < 0)
+         goto finish;
diff --git a/srcpkgs/ffmpeg4/template b/srcpkgs/ffmpeg4/template
new file mode 100644
index 0000000000000..9ba14bdb8ddf3
--- /dev/null
+++ b/srcpkgs/ffmpeg4/template
@@ -0,0 +1,234 @@
+# Template file for 'ffmpeg4'
+# audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
+pkgname=ffmpeg4
+version=4.4.4
+revision=1
+short_desc="Decoding, encoding and streaming software - ffmpeg4 libraries only"
+maintainer="Orphaned <orphan@voidlinux.org>"
+license="GPL-3.0-or-later"
+homepage="https://www.ffmpeg.org"
+changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
+distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
+checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+
+hostmakedepends="pkg-config perl"
+makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
+ libXext-devel libXvMC-devel libxcb-devel lame-devel libtheora-devel
+ libvorbis-devel x264-devel xvidcore-devel jack-devel SDL2-devel
+ libcdio-paranoia-devel librtmp-devel libmodplug-devel gnutls-devel
+ speex-devel celt-devel harfbuzz-devel libass-devel opus-devel ocl-icd-devel
+ libbs2b-devel libvidstab-devel vmaf-devel $(vopt_if pulseaudio pulseaudio-devel)
+ $(vopt_if vaapi libva-devel) $(vopt_if vdpau libvdpau-devel)
+ $(vopt_if x265 x265-devel) $(vopt_if v4l2 v4l-utils-devel)
+ $(vopt_if fdk_aac fdk-aac-devel) $(vopt_if vpx libvpx-devel)
+ $(vopt_if aom libaom-devel) $(vopt_if sndio sndio-devel)
+ $(vopt_if dav1d libdav1d-devel) $(vopt_if zimg zimg-devel)
+ $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
+ $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
+ $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
+
+build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
+
+desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
+desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
+desc_option_sofa="Enable support for AES SOFA"
+desc_option_webp="Enable support for WebP"
+
+case "$XBPS_TARGET_MACHINE" in
+	i686*|x86_64*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau nvenc nvdec"
+			;;
+	ppc64*) build_options_default+=" vaapi vdpau";;
+	mips*) CFLAGS="-mnan=legacy";;
+esac
+
+if [ "$XBPS_TARGET_WORDSIZE" != "32" ]; then
+	build_options_default+=" svtav1"
+fi
+
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+fi
+
+_apply_patch() {
+	local args="$1" pname="$(basename $2)"
+
+	if [ ! -f ".${pname}_done" ]; then
+		patch -N $args -i $2
+		touch .${pname}_done
+	fi
+}
+
+post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64le*) ;;
+		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
+	esac
+
+	vsed -i libavfilter/vf_libvmaf.c -e 's!/usr/local/share/model/\(vmaf_v0.6.1\).pkl!/usr/share/vmaf/\1.json!'
+}
+
+do_configure() {
+	# Fix gcc on x86_64-musl only
+	if [ "$XBPS_TARGET_MACHINE" = "x86_64-musl" ]; then
+		vsed -i configure -e "s;_cflags_speed='-O3';_cflags_speed='-O2';"
+	fi
+
+	if [ "$CROSS_BUILD" ]; then
+		case "$XBPS_TARGET_MACHINE" in
+			arm*) _arch="arm";;
+			aarch64*) _arch="aarch64";;
+			mips*) _arch="mips";;
+			ppc64*) _arch="ppc64";;
+			ppc*) _arch="ppc";;
+			*) _arch="${XBPS_TARGET_MACHINE%%-musl}";;
+		esac
+
+		_args+=" --enable-cross-compile
+			--sysroot=$XBPS_CROSS_BASE
+			--cross-prefix=${XBPS_CROSS_TRIPLET}-
+			--target-os=linux --arch=${_arch}"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc|ppc-musl) _args+=" --disable-altivec";;
+	esac
+
+	if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+		_args+=" --extra-libs=-latomic"
+	fi
+
+	./configure --prefix=/usr --disable-debug --enable-gpl --enable-gnutls \
+		--disable-stripping \
+		--enable-libcdio --enable-version3 --enable-runtime-cpudetect \
+		--enable-libmp3lame --enable-libvorbis --enable-libxvid \
+		--enable-libx264 $(vopt_enable vpx libvpx) --enable-libtheora \
+		--enable-shared --enable-static --enable-libxcb \
+		$(vopt_enable pulseaudio libpulse) --enable-libfreetype --enable-libmodplug \
+		--enable-libspeex --enable-libcelt --enable-libass \
+		--enable-libopus --enable-librtmp --enable-libjack \
+		$(vopt_if fdk_aac '--enable-nonfree --enable-libfdk-aac') \
+		--disable-libopencore_amrnb --disable-libopencore_amrwb \
+		--disable-libopenjpeg \
+		--enable-postproc --enable-opencl ${_args} --enable-libvmaf ${_args} \
+		$(vopt_enable x265 libx265) \
+		$(vopt_enable v4l2 libv4l2) \
+		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
+		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		$(vopt_enable dav1d libdav1d) \
+		$(vopt_enable zimg libzimg) \
+		$(vopt_enable webp libwebp) \
+		$(vopt_enable sofa libmysofa) \
+		$(vopt_enable vulkan) \
+		$(vopt_enable drm libdrm) \
+		$(vopt_enable svtav1 libsvtav1) \
+		$(vopt_enable srt libsrt) \
+		$(vopt_enable rist librist) \
+		$(vopt_if nvenc '--enable-nvenc') \
+		$(vopt_if nvdec '--enable-nvdec')
+}
+
+do_build() {
+	make ${makejobs}
+	make doc/ff{mpeg,play}.1
+}
+
+do_install() {
+	make DESTDIR=${DESTDIR} install install-man
+	rm -rf ${DESTDIR}/usr/bin
+}
+
+libavcodec4_package() {
+	short_desc="FFmpeg codec library"
+	pkg_install() {
+		vmove "usr/lib/libavcodec.so.*"
+	}
+}
+
+libavdevice4_package() {
+	short_desc="FFmpeg device handling library"
+	pkg_install() {
+		vmove "usr/lib/libavdevice.so.*"
+	}
+}
+
+libavresample4_package() {
+	short_desc="FFmpeg audio resampling library"
+	pkg_install() {
+		vmove "usr/lib/libavresample.so.*"
+	}
+}
+
+libavformat4_package() {
+	short_desc="FFmpeg file format library"
+	pkg_install() {
+		vmove "usr/lib/libavformat.so.*"
+	}
+}
+
+libavutil4_package() {
+	short_desc="FFmpeg utility library"
+	pkg_install() {
+		vmove "usr/lib/libavutil.so.*"
+	}
+}
+
+libavfilter4_package() {
+	short_desc="FFmpeg audio/video filter library"
+	pkg_install() {
+		vmove "usr/lib/libavfilter.so.*"
+	}
+}
+
+libpostproc4_package() {
+	short_desc="FFmpeg video postprocessing library"
+	pkg_install() {
+		vmove "usr/lib/libpostproc.so.*"
+	}
+}
+
+libswscale4_package() {
+	short_desc="FFmpeg video scaling library"
+	pkg_install() {
+		vmove "usr/lib/libswscale.so.*"
+	}
+}
+
+libswresample4_package() {
+	short_desc="FFmpeg video resampling library"
+	pkg_install() {
+		vmove "usr/lib/libswresample.so.*"
+	}
+}
+
+ffmpeg4-devel_package() {
+	depends="
+		libavcodec4>=${version}_${revision}
+		libavdevice4>=${version}_${revision}
+		libavformat4>=${version}_${revision}
+		libavutil4>=${version}_${revision}
+		libavfilter4>=${version}_${revision}
+		libpostproc4>=${version}_${revision}
+		libswscale4>=${version}_${revision}
+		libswresample4>=${version}_${revision}
+		libavresample4>=${version}_${revision}"
+	short_desc+=" - development files"
+	conflicts="ffmpeg-devel"
+	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
+		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
+		nostrip_files="/usr/lib/libavfilter.a"
+	fi
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.a"
+		vmove "usr/lib/*.so"
+		vmove usr/share/ffmpeg/examples
+		vmove usr/share/man/man3
+	}
+}
diff --git a/srcpkgs/libavcodec4 b/srcpkgs/libavcodec4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavcodec4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavdevice4 b/srcpkgs/libavdevice4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavdevice4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavfilter4 b/srcpkgs/libavfilter4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavfilter4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavformat4 b/srcpkgs/libavformat4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavformat4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavresample4 b/srcpkgs/libavresample4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavutil4 b/srcpkgs/libavutil4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavutil4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libpostproc4 b/srcpkgs/libpostproc4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libpostproc4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswresample4 b/srcpkgs/libswresample4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libswresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswscale4 b/srcpkgs/libswscale4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libswscale4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file

From fbd9bd6e63a3e9113026ce10cc72e0e59de25b7b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:04 -0400
Subject: [PATCH 005/113] opencv: update to 4.7.0.

---
 common/shlibs           | 104 ++++++++++++++++++++--------------------
 srcpkgs/opencv/template |   8 ++--
 2 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index 02da0d0bd2e53..fbe84c4d83586 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2075,58 +2075,58 @@ libcapstone.so.5 capstone-5.0.1_1
 libhavege.so.2 libhaveged-1.9.11_1
 libnih.so.1 libnih-1.0.3_1
 libnih-dbus.so.1 libnih-1.0.3_1
-libopencv_quality.so.406 libopencv-4.6.0_1
-libopencv_reg.so.406 libopencv-4.6.0_1
-libopencv_surface_matching.so.406 libopencv-4.6.0_1
-libopencv_xphoto.so.406 libopencv-4.6.0_1
-libopencv_freetype.so.406 libopencv-4.6.0_1
-libopencv_fuzzy.so.406 libopencv-4.6.0_1
-libopencv_hfs.so.406 libopencv-4.6.0_1
-libopencv_img_hash.so.406 libopencv-4.6.0_1
-libopencv_line_descriptor.so.406 libopencv-4.6.0_1
-libopencv_saliency.so.406 libopencv-4.6.0_1
-libopencv_structured_light.so.406 libopencv-4.6.0_1
-libopencv_aruco.so.406 libopencv-4.6.0_1
-libopencv_bgsegm.so.406 libopencv-4.6.0_1
-libopencv_bioinspired.so.406 libopencv-4.6.0_1
-libopencv_ccalib.so.406 libopencv-4.6.0_1
-libopencv_face.so.406 libopencv-4.6.0_1
-libopencv_tracking.so.406 libopencv-4.6.0_1
-libopencv_xfeatures2d.so.406 libopencv-4.6.0_1
-libopencv_optflow.so.406 libopencv-4.6.0_1
-libopencv_ximgproc.so.406 libopencv-4.6.0_1
-libopencv_plot.so.406 libopencv-4.6.0_1
-libopencv_text.so.406 libopencv-4.6.0_1
-libopencv_ml.so.406 libopencv-4.6.0_1
-libopencv_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn.so.406 libopencv-4.6.0_1
-libopencv_shape.so.406 libopencv-4.6.0_1
-libopencv_stitching.so.406 libopencv-4.6.0_1
-libopencv_photo.so.406 libopencv-4.6.0_1
-libopencv_video.so.406 libopencv-4.6.0_1
-libopencv_calib3d.so.406 libopencv-4.6.0_1
-libopencv_features2d.so.406 libopencv-4.6.0_1
-libopencv_flann.so.406 libopencv-4.6.0_1
-libopencv_highgui.so.406 libopencv-4.6.0_1
-libopencv_videoio.so.406 libopencv-4.6.0_1
-libopencv_imgcodecs.so.406 libopencv-4.6.0_1
-libopencv_imgproc.so.406 libopencv-4.6.0_1
-libopencv_core.so.406 libopencv-4.6.0_1
-libopencv_superres.so.406 libopencv-4.6.0_1
-libopencv_videostab.so.406 libopencv-4.6.0_1
-libopencv_gapi.so.406 libopencv-4.6.0_1
-libopencv_xobjdetect.so.406 libopencv-4.6.0_1
-libopencv_datasets.so.406 libopencv-4.6.0_1
-libopencv_dnn_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn_superres.so.406 libopencv-4.6.0_1
-libopencv_dpm.so.406 libopencv-4.6.0_1
-libopencv_phase_unwrapping.so.406 libopencv-4.6.0_1
-libopencv_stereo.so.406 libopencv-4.6.0_1
-libopencv_rapid.so.406 libopencv-4.6.0_1
-libopencv_intensity_transform.so.406 libopencv-4.6.0_1
-libopencv_alphamat.so.406 libopencv-4.6.0_1
-libopencv_barcode.so.406 libopencv-4.6.0_1
-libopencv_mcc.so.406 libopencv-4.6.0_1
+libopencv_quality.so.407 libopencv-4.7.0_1
+libopencv_reg.so.407 libopencv-4.7.0_1
+libopencv_surface_matching.so.407 libopencv-4.7.0_1
+libopencv_xphoto.so.407 libopencv-4.7.0_1
+libopencv_freetype.so.407 libopencv-4.7.0_1
+libopencv_fuzzy.so.407 libopencv-4.7.0_1
+libopencv_hfs.so.407 libopencv-4.7.0_1
+libopencv_img_hash.so.407 libopencv-4.7.0_1
+libopencv_line_descriptor.so.407 libopencv-4.7.0_1
+libopencv_saliency.so.407 libopencv-4.7.0_1
+libopencv_structured_light.so.407 libopencv-4.7.0_1
+libopencv_aruco.so.407 libopencv-4.7.0_1
+libopencv_bgsegm.so.407 libopencv-4.7.0_1
+libopencv_bioinspired.so.407 libopencv-4.7.0_1
+libopencv_ccalib.so.407 libopencv-4.7.0_1
+libopencv_face.so.407 libopencv-4.7.0_1
+libopencv_tracking.so.407 libopencv-4.7.0_1
+libopencv_xfeatures2d.so.407 libopencv-4.7.0_1
+libopencv_optflow.so.407 libopencv-4.7.0_1
+libopencv_ximgproc.so.407 libopencv-4.7.0_1
+libopencv_plot.so.407 libopencv-4.7.0_1
+libopencv_text.so.407 libopencv-4.7.0_1
+libopencv_ml.so.407 libopencv-4.7.0_1
+libopencv_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn.so.407 libopencv-4.7.0_1
+libopencv_shape.so.407 libopencv-4.7.0_1
+libopencv_stitching.so.407 libopencv-4.7.0_1
+libopencv_photo.so.407 libopencv-4.7.0_1
+libopencv_video.so.407 libopencv-4.7.0_1
+libopencv_calib3d.so.407 libopencv-4.7.0_1
+libopencv_features2d.so.407 libopencv-4.7.0_1
+libopencv_flann.so.407 libopencv-4.7.0_1
+libopencv_highgui.so.407 libopencv-4.7.0_1
+libopencv_videoio.so.407 libopencv-4.7.0_1
+libopencv_imgcodecs.so.407 libopencv-4.7.0_1
+libopencv_imgproc.so.407 libopencv-4.7.0_1
+libopencv_core.so.407 libopencv-4.7.0_1
+libopencv_superres.so.407 libopencv-4.7.0_1
+libopencv_videostab.so.407 libopencv-4.7.0_1
+libopencv_gapi.so.407 libopencv-4.7.0_1
+libopencv_xobjdetect.so.407 libopencv-4.7.0_1
+libopencv_datasets.so.407 libopencv-4.7.0_1
+libopencv_dnn_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn_superres.so.407 libopencv-4.7.0_1
+libopencv_dpm.so.407 libopencv-4.7.0_1
+libopencv_phase_unwrapping.so.407 libopencv-4.7.0_1
+libopencv_stereo.so.407 libopencv-4.7.0_1
+libopencv_rapid.so.407 libopencv-4.7.0_1
+libopencv_intensity_transform.so.407 libopencv-4.7.0_1
+libopencv_alphamat.so.407 libopencv-4.7.0_1
+libopencv_barcode.so.407 libopencv-4.7.0_1
+libopencv_mcc.so.407 libopencv-4.7.0_1
 libuniconf.so.4.6 wvstreams-4.6.1_20
 libwvbase.so.4.6 wvstreams-4.6.1_20
 libwvutils.so.4.6 wvstreams-4.6.1_20
diff --git a/srcpkgs/opencv/template b/srcpkgs/opencv/template
index aea4bfc3a265c..ce94de9424d18 100644
--- a/srcpkgs/opencv/template
+++ b/srcpkgs/opencv/template
@@ -1,7 +1,7 @@
 # Template file for 'opencv'
 pkgname=opencv
-version=4.6.0
-revision=6
+version=4.7.0
+revision=1
 create_wrksrc=yes
 build_wrksrc=${pkgname}-${version}
 build_style=cmake
@@ -24,8 +24,8 @@ homepage="https://opencv.org"
 changelog="https://github.com/opencv/opencv/wiki/ChangeLog"
 distfiles="https://github.com/opencv/opencv/archive/${version}.tar.gz
  https://github.com/opencv/opencv_contrib/archive/${version}.tar.gz>contrib.tar.gz"
-checksum="1ec1cba65f9f20fe5a41fda1586e01c70ea0c9a6d7b67c9e13edf0cfe2239277
- 1777d5fd2b59029cf537e5fd6f8aa68d707075822f90bde683fcde086f85f7a7"
+checksum="8df0079cdbe179748a18d44731af62a245a45ebf5085223dc03133954c662973
+ 42df840cf9055e59d0e22c249cfb19f04743e1bdad113d31b1573d3934d62584"
 patch_args="-Np1 -d ${build_wrksrc}"
 # tests hang indenfinitely, even with test data included
 make_check=no

From 1fd1f70e1ace18ec216600c16b4e58ccb1543131 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 006/113] actiona: revbump for opencv-4.7.0

---
 srcpkgs/actiona/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/actiona/template b/srcpkgs/actiona/template
index cf5f0b7a2ae61..0d899311e6df7 100644
--- a/srcpkgs/actiona/template
+++ b/srcpkgs/actiona/template
@@ -1,7 +1,7 @@
 # Template file for 'actiona'
 pkgname=actiona
 version=3.10.1
-revision=2
+revision=3
 build_style=qmake
 configure_args="PKGCONFIG_OPENCV=opencv4"
 hostmakedepends="pkg-config qt5-plugin-mysql qt5-qmake qt5-host-tools"

From 9675821c4b3fc1f8896610a807074d1fa24097a3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 007/113] retroshare: revbump for opencv-4.7.0

---
 srcpkgs/retroshare/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroshare/template b/srcpkgs/retroshare/template
index bb17569277a7f..49e2c1cbe8a53 100644
--- a/srcpkgs/retroshare/template
+++ b/srcpkgs/retroshare/template
@@ -1,7 +1,7 @@
 # Template file for 'retroshare'
 pkgname=retroshare
 version=0.6.6
-revision=3
+revision=4
 build_style=qmake
 #XXX broadcast feature requires an ancient udp-discovery-cpp which either needs
 # to be fetched+patched (FTBFS) here or packaged :/

From 22764e968a6cdc8d10ec4f7ace888e06b9028169 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 008/113] waifu2x-converter-cpp: revbump for opencv-4.7.0

---
 srcpkgs/waifu2x-converter-cpp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waifu2x-converter-cpp/template b/srcpkgs/waifu2x-converter-cpp/template
index 361b8a23b9497..c5ac17eb54ea4 100644
--- a/srcpkgs/waifu2x-converter-cpp/template
+++ b/srcpkgs/waifu2x-converter-cpp/template
@@ -1,7 +1,7 @@
 # Template file for 'waifu2x-converter-cpp'
 pkgname=waifu2x-converter-cpp
 version=5.2.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DINSTALL_MODELS=ON"
 hostmakedepends="pkg-config"

From b665dc31c185485ddb0fd92c5ff91483087e3bca Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:38 -0400
Subject: [PATCH 009/113] vlc: revbump for ffmpeg4

---
 srcpkgs/vlc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/vlc/template b/srcpkgs/vlc/template
index bdd0cc414dc1a..7d245a7b0019c 100644
--- a/srcpkgs/vlc/template
+++ b/srcpkgs/vlc/template
@@ -1,7 +1,7 @@
 # Template file for 'vlc'
 pkgname=vlc
 version=3.0.20
-revision=3
+revision=4
 build_style=gnu-configure
 configure_args="--disable-gme --disable-libtar --enable-jack
  --enable-live555 --disable-fluidsynth --enable-dvdread
@@ -25,7 +25,7 @@ lib32disabled=yes
 hostmakedepends="automake libtool pkg-config flex gettext libgcrypt-devel
  live555-devel gettext-devel $(vopt_if lua lua52) $(vopt_if chromecast protobuf)"
 makedepends="
- avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg-devel freefont-ttf
+ avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg4-devel freefont-ttf
  gnutls-devel jack-devel liba52-devel libass-devel libbluray-devel
  libcdio-devel libdca-devel libdvbpsi-devel libdvdnav-devel libmad-devel
  libmatroska-devel libmodplug-devel libmpcdec-devel libmpeg2-devel

From 0268371044722ffcf7e77719ce4fd1b23bf00c17 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:55 -0400
Subject: [PATCH 010/113] osg: revbump for ffmpeg4

---
 srcpkgs/osg/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/osg/template b/srcpkgs/osg/template
index a9ebbd287933b..a131ceaf7a867 100644
--- a/srcpkgs/osg/template
+++ b/srcpkgs/osg/template
@@ -1,14 +1,14 @@
 # Template file for 'osg'
 pkgname=osg
 version=3.6.5
-revision=2
+revision=3
 build_style=cmake
 build_helper="qemu"
 # don't use /usr/lib64 on 64bit platforms
 configure_args="-DLIB_POSTFIX="
 hostmakedepends="pkg-config xrandr"
 makedepends="MesaLib-devel gtkglext-devel libcurl-devel giflib-devel librsvg-devel
- jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg-devel xine-lib-devel
+ jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg4-devel xine-lib-devel
  SDL2-devel gst-plugins-base1-devel
  $(vopt_if openexr libopenexr-devel)
  $(vopt_if poppler poppler-glib-devel)

From 552b6353abc70fb78f9e9c9a820e8e01a8b5ff19 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:13 -0400
Subject: [PATCH 011/113] xine-lib: revbump for ffmpeg4

---
 srcpkgs/xine-lib/template | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/xine-lib/template b/srcpkgs/xine-lib/template
index 3be4d08eac77a..ed6194c17d11e 100644
--- a/srcpkgs/xine-lib/template
+++ b/srcpkgs/xine-lib/template
@@ -1,14 +1,14 @@
 # Template file for 'xine-lib'
 pkgname=xine-lib
-version=1.2.12
-revision=3
+version=1.2.13
+revision=1
 build_style=gnu-configure
 configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
  --disable-oss"
 hostmakedepends="automake gettext-devel libtool pkg-config perl"
 makedepends="
  zlib-devel alsa-lib-devel libxcb-devel libSM-devel libXext-devel libXv-devel
- libXvMC-devel liba52-devel libmad-devel ffmpeg-devel pulseaudio-devel
+ libXvMC-devel liba52-devel libmad-devel ffmpeg4-devel pulseaudio-devel
  jack-devel samba-devel libflac-devel libmodplug-devel libmpcdec-devel
  speex-devel libtheora-devel libvorbis-devel libdca-devel faad2-devel
  libcdio-devel libbluray-devel aalib-devel libcaca-devel libXinerama-devel
@@ -19,7 +19,7 @@ license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="http://www.xine-project.org"
 changelog="https://sourceforge.net/projects/xine/files/xine-lib/${version}/README.txt/view"
 distfiles="${SOURCEFORGE_SITE}/xine/${pkgname}-${version}.tar.xz"
-checksum=d606270468e1540c2a89c0d7f5fdf11e17ecc0c2698cc0bcb1065ff26abee098
+checksum=5f10d6d718a4a51c17ed1b32b031d4f9b80b061e8276535b2be31e5ac4b75e6f
 
 case "$XBPS_TARGET_MACHINE" in
 	i686-musl)

From bde86c1938ae30a5a021e5431c16d71dd489dda6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 012/113] attract: revbump for ffmpeg6

---
 srcpkgs/attract/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/attract/template b/srcpkgs/attract/template
index e769fb1545621..776cbe4ebd2c9 100644
--- a/srcpkgs/attract/template
+++ b/srcpkgs/attract/template
@@ -1,7 +1,7 @@
 # Template file for 'attract'
 pkgname=attract
 version=2.7.0
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="VERBOSE=1"
 make_use_env=yes

From b424aa22218365132b478e814289ce4d277910af Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 013/113] aubio: revbump for ffmpeg6

---
 srcpkgs/aubio/patches/ffmpeg5.patch | 25 +++++++++++++++++++++++++
 srcpkgs/aubio/template              |  2 +-
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/aubio/patches/ffmpeg5.patch

diff --git a/srcpkgs/aubio/patches/ffmpeg5.patch b/srcpkgs/aubio/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..aace41a6e6d9a
--- /dev/null
+++ b/srcpkgs/aubio/patches/ffmpeg5.patch
@@ -0,0 +1,25 @@
+From 8a05420e5dd8c7b8b2447f82dc919765876511b3 Mon Sep 17 00:00:00 2001
+From: Paul Brossier <piem@piem.org>
+Date: Tue, 25 Jan 2022 18:30:27 +0100
+Subject: [PATCH] [source_avcodec] define FF_API_LAVF_AVCTX for libavcodec >
+ 59, thx @berolinux (closes gh-353)
+
+---
+ src/io/source_avcodec.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/io/source_avcodec.c b/src/io/source_avcodec.c
+index e0ae93b5..1421bd9a 100644
+--- a/src/io/source_avcodec.c
++++ b/src/io/source_avcodec.c
+@@ -68,6 +68,10 @@
+ #define AUBIO_AVCODEC_MAX_BUFFER_SIZE AV_INPUT_BUFFER_MIN_SIZE
+ #endif
+ 
++#if LIBAVCODEC_VERSION_MAJOR >= 59
++#define FF_API_LAVF_AVCTX 1
++#endif
++
+ struct _aubio_source_avcodec_t {
+   uint_t hop_size;
+   uint_t samplerate;
diff --git a/srcpkgs/aubio/template b/srcpkgs/aubio/template
index ad1c4b2569917..7d875cc02541a 100644
--- a/srcpkgs/aubio/template
+++ b/srcpkgs/aubio/template
@@ -1,7 +1,7 @@
 # Template file for 'aubio'
 pkgname=aubio
 version=0.4.9
-revision=1
+revision=2
 build_style=waf3
 # XXX lash, pure and swig support.
 hostmakedepends="pkg-config txt2man"

From 8dd0308c1286454c2610f14917d5c3aa77bd17ab Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 014/113] audacious-plugins: revbump for ffmpeg6

---
 .../audacious-plugins/patches/ffmpeg5.patch   | 43 +++++++++++++++++++
 srcpkgs/audacious-plugins/template            |  2 +-
 2 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/audacious-plugins/patches/ffmpeg5.patch

diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg5.patch b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..4e5e34099d71c
--- /dev/null
+++ b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
@@ -0,0 +1,43 @@
+commit 298aa371c56c2f52c25a33d9bdec4918b11cebdc
+Author: tibequadorian <tibequadorian@posteo.de>
+Date:   Sat Mar 19 18:40:12 2022 +0100
+
+    audacious-plugins: rebuild against ffmpeg-5.0
+
+diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+new file mode 100644
+index 0000000000..617c11215b
+--- /dev/null
++++ b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+@@ -0,0 +1,31 @@
++From f60beb400eeb1e4778bbfd738bc4a4ccef3de539 Mon Sep 17 00:00:00 2001
++From: John Lindgren <john@jlindgren.net>
++Date: Sat, 5 Mar 2022 12:05:34 -0500
++Subject: [PATCH] Fix build with FFmpeg 5.0
++
++---
++ src/ffaudio/ffaudio-core.cc | 4 ++--
++ 1 file changed, 2 insertions(+), 2 deletions(-)
++
++diff --git a/src/ffaudio/ffaudio-core.cc b/src/ffaudio/ffaudio-core.cc
++index 16dc63e3a..a2b95fd6c 100644
++--- a/src/ffaudio/ffaudio-core.cc
+++++ b/src/ffaudio/ffaudio-core.cc
++@@ -274,7 +274,7 @@ static AVInputFormat * get_format_by_content (const char * name, VFSFile & file)
++         AVProbeData d = {name, buf, filled};
++         score = target;
++ 
++-        f = av_probe_input_format2 (& d, true, & score);
+++        f = (AVInputFormat *) av_probe_input_format2 (& d, true, & score);
++         if (f)
++             break;
++ 
++@@ -347,7 +347,7 @@ static bool find_codec (AVFormatContext * c, CodecInfo * cinfo)
++ #endif
++         if (stream && stream->codecpar && stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
++         {
++-            AVCodec * codec = avcodec_find_decoder (stream->codecpar->codec_id);
+++            AVCodec * codec = (AVCodec *) avcodec_find_decoder (stream->codecpar->codec_id);
++ 
++             if (codec)
++             {
diff --git a/srcpkgs/audacious-plugins/template b/srcpkgs/audacious-plugins/template
index 05e53a9adf78f..4b1968e03de78 100644
--- a/srcpkgs/audacious-plugins/template
+++ b/srcpkgs/audacious-plugins/template
@@ -2,7 +2,7 @@
 #Keep in sync with audacious!
 pkgname=audacious-plugins
 version=4.3.1
-revision=3
+revision=4
 build_style=meson
 configure_args="$(vopt_bool gtk3 gtk) $(vopt_bool gtk3)
  $(vopt_bool qt) $(vopt_bool qt qt6)"

From 35a06fa05dee3a6b3235716f72436530ea8cd5ff Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 015/113] audacity: revbump for ffmpeg6

---
 srcpkgs/audacity/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/audacity/template b/srcpkgs/audacity/template
index 7b838119ab261..84b49305edcef 100644
--- a/srcpkgs/audacity/template
+++ b/srcpkgs/audacity/template
@@ -1,7 +1,7 @@
 # Template file for 'audacity'
 pkgname=audacity
 version=3.4.2
-revision=1
+revision=2
 build_style=cmake
 build_helper="cmake-wxWidgets-gtk3 qemu"
 configure_args="-Daudacity_use_ffmpeg=loaded -Daudacity_lib_preference=system

From 14a264467fc364a0c8ee152df5c55bd3fc1a2e1b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 016/113] avidemux: revbump for ffmpeg6

---
 srcpkgs/avidemux/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/avidemux/template b/srcpkgs/avidemux/template
index 253a0243e2259..557285982d2b8 100644
--- a/srcpkgs/avidemux/template
+++ b/srcpkgs/avidemux/template
@@ -1,7 +1,7 @@
 # Template file for 'avidemux'
 pkgname=avidemux
 version=2.8.0
-revision=2
+revision=3
 # Can't be compiled for aarch64, arm* or mips*
 archs="x86_64* i686*"
 hostmakedepends="cmake pkg-config qt5-host-tools qt5-devel tar yasm"

From 93ee46017f0145791f4d53f5623e33eca463ba6a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 017/113] blender: revbump for ffmpeg6

---
 srcpkgs/blender/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index 1dc61ec9d29d8..e238717ac8c72 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -1,7 +1,7 @@
 # Template file for 'blender'
 pkgname=blender
 version=4.0.2
-revision=1
+revision=2
 archs="x86_64* ppc64*"
 build_style="cmake"
 pycompile_dirs="usr/share/blender/${version%.*}/scripts"
@@ -9,8 +9,8 @@ configure_args="-DWITH_INSTALL_PORTABLE=OFF -DWITH_PYTHON_INSTALL=OFF
  -DWITH_JACK=ON -DWITH_CODEC_FFMPEG=ON -DWITH_CODEC_SNDFILE=ON -DWITH_OPENMP=ON
  -DWITH_FFTW3=ON -DWITH_MOD_OCEANSIM=ON -DWITH_CYCLES_EMBREE=OFF -DWITH_OPENCOLORIO=ON
  -DWITH_IMAGE_OPENEXR=ON -DWITH_IMAGE_OPENJPEG=ON -DWITH_OPENSUBDIV=ON
- -DWITH_OPENCOLLADA=ON -DWITH_SYSTEM_GLEW=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
- -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_LIBDECOR=ON
+ -DWITH_OPENCOLLADA=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
+ -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_WAYLAND_LIBDECOR=ON
  -DWITH_BUILDINFO=OFF -DPYTHON_VERSION=${py3_ver} -DPYTHON_LIBPATH=/usr/lib
  -DPYTHON_LIBRARY=python${py3_ver}${py3_abiver} -DPYTHON_INCLUDE_DIRS=/${py3_inc}
  -DWITH_SYSTEM_LZO=ON -DWITH_SYSTEM_EIGEN3=ON -DWITH_SYSTEM_FREETYPE=ON"

From c34bc5de9a6ed6e0f2b38132aaa49a6ff367aaf5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 018/113] cantata: revbump for ffmpeg6

---
 srcpkgs/cantata/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cantata/template b/srcpkgs/cantata/template
index 4b417d80d5c2d..8a90aaa4c07a2 100644
--- a/srcpkgs/cantata/template
+++ b/srcpkgs/cantata/template
@@ -1,7 +1,7 @@
 # Template file for 'cantata'
 pkgname=cantata
 version=2.5.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools qt5-tools"
 makedepends="qt5-devel qt5-tools-devel qt5-svg-devel qt5-xmlpatterns-devel

From 59d4759cbdff3f0c4b756a47655f81c873a34655 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 019/113] ccextractor: revbump for ffmpeg6

---
 ...5-and-tesseract-5-compatibility-1479.patch | 168 ++++++++++++++++++
 srcpkgs/ccextractor/template                  |   2 +-
 2 files changed, 169 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ccextractor/patches/0001-fix-ffmpeg-5-and-tesseract-5-compatibility-1479.patch

diff --git a/srcpkgs/ccextractor/patches/0001-fix-ffmpeg-5-and-tesseract-5-compatibility-1479.patch b/srcpkgs/ccextractor/patches/0001-fix-ffmpeg-5-and-tesseract-5-compatibility-1479.patch
new file mode 100644
index 0000000000000..bcab4890554b9
--- /dev/null
+++ b/srcpkgs/ccextractor/patches/0001-fix-ffmpeg-5-and-tesseract-5-compatibility-1479.patch
@@ -0,0 +1,168 @@
+From b1cbfcea9b9c687143bf0d80bc179b563e99d025 Mon Sep 17 00:00:00 2001
+From: Prateek Sunal <prtksunal@gmail.com>
+Date: Thu, 9 Mar 2023 01:44:53 +0530
+Subject: [PATCH] fix: ffmpeg 5 and tesseract 5 compatibility (#1479)
+
+* fix: replace deprecated `codec` property with `codecpar`
+
+* fix: replace deprecated method `avcodec_decode_video2` with `avcodec_receive_frame` and `avcodec_send_packet`
+
+* Update CHANGES.TXT
+
+* fix: remove deprecated `av_register_all` function
+
+* fix: formatting
+
+* fix: add support for tesseract 5
+
+* fix: tesseract v5
+
+* fix: hardsubx codec context error
+
+* fix: lint const warning
+---
+ docs/CHANGES.TXT               |  1 +
+ src/lib_ccx/ffmpeg_intgr.c     |  7 +++---
+ src/lib_ccx/hardsubx.c         | 25 ++++++++++++------
+ src/lib_ccx/hardsubx_decoder.c | 27 ++++++++------------
+ src/lib_ccx/ocr.c              | 46 ++++++++++++----------------------
+ 5 files changed, 47 insertions(+), 59 deletions(-)
+
+diff --git a/src/lib_ccx/ffmpeg_intgr.c b/src/lib_ccx/ffmpeg_intgr.c
+index be988890..e6f21e20 100644
+--- a/src/lib_ccx/ffmpeg_intgr.c
++++ b/src/lib_ccx/ffmpeg_intgr.c
+@@ -66,7 +66,6 @@ void *init_ffmpeg(const char *path)
+ 	struct ffmpeg_ctx *ctx;
+ 	AVCodec *dec = NULL;
+ 	avcodec_register_all();
+-	av_register_all();
+ 
+ 	if (ccx_options.debug_mask & CCX_DMT_VERBOSE)
+ 		av_log_set_level(AV_LOG_INFO);
+@@ -133,7 +132,6 @@ int ff_get_ccframe(void *arg, unsigned char *data, int maxlen)
+ 	struct ffmpeg_ctx *ctx = arg;
+ 	int len = 0;
+ 	int ret = 0;
+-	int got_frame;
+ 	AVPacket packet;
+ 
+ 	ret = av_read_frame(ctx->ifmt, &packet);
+@@ -151,12 +149,13 @@ int ff_get_ccframe(void *arg, unsigned char *data, int maxlen)
+ 		return AVERROR(EAGAIN);
+ 	}
+ 
+-	ret = avcodec_decode_video2(ctx->dec_ctx, ctx->frame, &got_frame, &packet);
++	avcodec_send_packet(ctx->codec_ctx, &ctx->packet);
++	ret = avcodec_receive_frame(ctx->dec_ctx, ctx->frame);
+ 	if (ret < 0)
+ 	{
+ 		av_log(NULL, AV_LOG_ERROR, "unable to decode packet\n");
+ 	}
+-	else if (!got_frame)
++	else if (ret != 0)
+ 	{
+ 		return AVERROR(EAGAIN);
+ 	}
+diff --git a/src/lib_ccx/hardsubx.c b/src/lib_ccx/hardsubx.c
+index 411377f9..fb844c91 100644
+--- a/src/lib_ccx/hardsubx.c
++++ b/src/lib_ccx/hardsubx.c
+@@ -12,9 +12,6 @@
+
+ int hardsubx_process_data(struct lib_hardsubx_ctx *ctx)
+ {
+-	// Get the required media attributes and initialize structures
+-	av_register_all();
+-
+ 	if (avformat_open_input(&ctx->format_ctx, ctx->inputfile[0], NULL, NULL) != 0)
+ 	{
+ 		fatal(EXIT_READ_ERROR, "Error reading input file!\n");
+@@ -32,7 +29,7 @@
+ 	ctx->video_stream_id = -1;
+ 	for (int i = 0; i < ctx->format_ctx->nb_streams; i++)
+ 	{
+-		if (ctx->format_ctx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO)
++		if (ctx->format_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
+ 		{
+ 			ctx->video_stream_id = i;
+ 			break;
+@@ -43,8 +40,21 @@
+ 		fatal(EXIT_READ_ERROR, "Video Stream not found!\n");
+ 	}
+
+-	ctx->codec_ctx = ctx->format_ctx->streams[ctx->video_stream_id]->codec;
+-	ctx->codec = avcodec_find_decoder(ctx->codec_ctx->codec_id);
++	ctx->codec_ctx = avcodec_alloc_context3(NULL);
++	if (!ctx->codec_ctx)
++	{
++		    fatal(EXIT_NOT_ENOUGH_MEMORY, "Could not allocate codec context!\n");
++	}
++
++	// Assign codec parameters to codec context
++	if (avcodec_parameters_to_context(ctx->codec_ctx, ctx->format_ctx->streams[ctx->video_stream_id]->codecpar) < 0)
++	{
++		    fatal(EXIT_READ_ERROR, "Could not initialize codec context!\n");
++	}
++
++	// Find decoder for the codec context
++	ctx->codec = (AVCodec *)avcodec_find_decoder(ctx->codec_ctx->codec_id);
++
+ 	if (ctx->codec == NULL)
+ 	{
+ 		fatal(EXIT_READ_ERROR, "Input codec is not supported!\n");
+diff --git a/src/lib_ccx/hardsubx_decoder.c b/src/lib_ccx/hardsubx_decoder.c
+index bd9b0980..b5dfaec4 100644
+--- a/src/lib_ccx/hardsubx_decoder.c
++++ b/src/lib_ccx/hardsubx_decoder.c
+@@ -371,7 +371,6 @@
+ int hardsubx_process_frames_tickertext(struct lib_hardsubx_ctx *ctx, struct encoder_ctx *enc_ctx)
+ {
+ 	// Search for ticker text at the bottom of the screen, such as in Russia TV1 or stock prices
+-	int got_frame;
+ 	int cur_sec = 0, total_sec, progress;
+ 	int frame_number = 0;
+ 	char *ticker_text = NULL;
+@@ -382,8 +381,8 @@
+ 		{
+ 			frame_number++;
+ 			//Decode the video stream packet
+-			avcodec_decode_video2(ctx->codec_ctx, ctx->frame, &got_frame, &ctx->packet);
+-			if (got_frame && frame_number % 1000 == 0)
++      avcodec_send_packet(ctx->codec_ctx, &ctx->packet);
++      if (avcodec_receive_frame(ctx->codec_ctx, ctx->frame) == 0 && frame_number % 1000 == 0)
+ 			{
+ 				// sws_scale is used to convert the pixel format to RGB24 from all other cases
+ 				sws_scale(
+@@ -434,9 +433,8 @@
+ 			frame_number++;
+
+ 			//Decode the video stream packet
+-			avcodec_decode_video2(ctx->codec_ctx, ctx->frame, &got_frame, &ctx->packet);
+-
+-			if (got_frame && frame_number % 25 == 0)
++			avcodec_send_packet(ctx->codec_ctx, &ctx->packet);
++      if (avcodec_receive_frame(ctx->codec_ctx, ctx->frame) == 0 && frame_number % 25 == 0)
+ 			{
+ 				float diff = (float)convert_pts_to_ms(ctx->packet.pts - prev_packet_pts, ctx->format_ctx->streams[ctx->video_stream_id]->time_base);
+ 				if (fabsf(diff) < 1000 * ctx->min_sub_duration) //If the minimum duration of a subtitle line is exceeded, process packet
+@@ -548,7 +546,6 @@
+ {
+ 	// Do a binary search over the input video for faster processing
+ 	// printf("Duration: %d\n", (int)ctx->format_ctx->duration);
+-	int got_frame;
+ 	int seconds_time = 0;
+ 	for (seconds_time = 0; seconds_time < 20; seconds_time++)
+ 	{
+@@ -568,8 +565,9 @@
+ 			{
+ 				if (ctx->packet.stream_index == ctx->video_stream_id)
+ 				{
+-					avcodec_decode_video2(ctx->codec_ctx, ctx->frame, &got_frame, &ctx->packet);
+-					if (got_frame)
++          avcodec_send_packet(ctx->codec_ctx, &ctx->packet);
++          if (avcodec_receive_frame(ctx->codec_ctx, ctx->frame) == 0)
++
+ 					{
+ 						// printf("%d\n", seek_time);
+ 						if (ctx->packet.pts < seek_time)
diff --git a/srcpkgs/ccextractor/template b/srcpkgs/ccextractor/template
index 84059ffd02398..a670758bcbe41 100644
--- a/srcpkgs/ccextractor/template
+++ b/srcpkgs/ccextractor/template
@@ -1,7 +1,7 @@
 # Template file for 'ccextractor'
 pkgname=ccextractor
 version=0.93
-revision=2
+revision=3
 build_wrksrc="linux"
 build_style=gnu-configure
 configure_args="--enable-ocr --enable-hardsubx"

From bae05e8ffe60a1b1d70cf56e06a1d247a48332ef Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 020/113] chromaprint: revbump for ffmpeg6

---
 srcpkgs/chromaprint/patches/ffmpeg5.patch | 569 ++++++++++++++++++++++
 srcpkgs/chromaprint/template              |   2 +-
 2 files changed, 570 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromaprint/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromaprint/patches/ffmpeg5.patch b/srcpkgs/chromaprint/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..a9fd307a23c8a
--- /dev/null
+++ b/srcpkgs/chromaprint/patches/ffmpeg5.patch
@@ -0,0 +1,569 @@
+From 8ccad6937177b1b92e40ab8f4447ea27bac009a7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= <lalinsky@gmail.com>
+Date: Fri, 4 Nov 2022 21:47:38 +0100
+Subject: [PATCH] Use FFmpeg 5.x (#120)
+
+* Use FFmpeg 5.1.2 for CI builds
+
+* Build on Ubuntu 20.04
+
+* Upgrade code to FFmpeg 5.x APIs
+
+* Only set FFmpeg include dirs if building tools
+
+* No longer needed
+
+* Use ubuntu 20.04
+---
+ .github/workflows/build.yml                   |   6 +-
+ CMakeLists.txt                                |  16 --
+ package/build.sh                              |   4 +-
+ src/audio/ffmpeg_audio_processor.h            |   2 -
+ src/audio/ffmpeg_audio_processor_avresample.h |  72 -------
+ src/audio/ffmpeg_audio_processor_swresample.h |  18 +-
+ src/audio/ffmpeg_audio_reader.h               | 197 +++++++++---------
+ tests/CMakeLists.txt                          |   6 +
+ 8 files changed, 122 insertions(+), 199 deletions(-)
+ delete mode 100644 src/audio/ffmpeg_audio_processor_avresample.h
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index f8d6a32..4da2405 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -84,9 +84,6 @@ find_package(FFmpeg)
+ if(FFMPEG_LIBRARIES)
+ 	cmake_push_check_state(RESET)
+ 	set(CMAKE_REQUIRED_LIBRARIES ${FFMPEG_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -lm)
+-	check_function_exists(av_packet_unref HAVE_AV_PACKET_UNREF)
+-	check_function_exists(av_frame_alloc HAVE_AV_FRAME_ALLOC)
+-	check_function_exists(av_frame_free HAVE_AV_FRAME_FREE)
+ 	cmake_pop_check_state()
+ endif()
+
+@@ -163,14 +160,11 @@ message(STATUS "Using ${FFT_LIB} for FFT calculations")
+ if(NOT AUDIO_PROCESSOR_LIB)
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+ 		set(AUDIO_PROCESSOR_LIB "swresample")
+-	elseif(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(AUDIO_PROCESSOR_LIB "avresample")
+ 	endif()
+ endif()
+
+ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE OFF)
+ 		set(USE_SWRESAMPLE ON)
+ 		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBSWRESAMPLE_LIBRARIES})
+ 		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBSWRESAMPLE_INCLUDE_DIRS})
+@@ -178,16 +172,6 @@ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+ 	endif()
+ 	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+-elseif(AUDIO_PROCESSOR_LIB STREQUAL "avresample")
+-	if(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE ON)
+-		set(USE_SWRESAMPLE OFF)
+-		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBAVRESAMPLE_LIBRARIES})
+-		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBAVRESAMPLE_INCLUDE_DIRS})
+-	else()
+-		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+-	endif()
+-	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+ else()
+ 	message(STATUS "Building without audio conversion support, please install FFmpeg with libswresample")
+ endif()
+diff --git a/package/build.sh b/package/build.sh
+index da631ae..b41d36e 100755
+--- a/package/build.sh
++++ b/package/build.sh
+@@ -7,8 +7,8 @@ set -eux
+
+ BASE_DIR=$(cd $(dirname $0)/.. && pwd)
+
+-FFMPEG_VERSION=4.4.1
+-FFMPEG_BUILD_TAG=v4.4.1-1
++FFMPEG_VERSION=5.1.2
++FFMPEG_BUILD_TAG=v${FFMPEG_VERSION}-1
+
+ TMP_BUILD_DIR=$BASE_DIR/$(mktemp -d build.XXXXXXXX)
+ trap 'rm -rf $TMP_BUILD_DIR' EXIT
+diff --git a/src/audio/ffmpeg_audio_processor.h b/src/audio/ffmpeg_audio_processor.h
+index 7628fc7..39f4f6d 100644
+--- a/src/audio/ffmpeg_audio_processor.h
++++ b/src/audio/ffmpeg_audio_processor.h
+@@ -10,8 +10,6 @@
+
+ #if defined(USE_SWRESAMPLE)
+ #include "audio/ffmpeg_audio_processor_swresample.h"
+-#elif defined(USE_AVRESAMPLE)
+-#include "audio/ffmpeg_audio_processor_avresample.h"
+ #else
+ #error "no audio processing library"
+ #endif
+diff --git a/src/audio/ffmpeg_audio_processor_avresample.h b/src/audio/ffmpeg_audio_processor_avresample.h
+deleted file mode 100644
+index bd85f92..0000000
+--- a/src/audio/ffmpeg_audio_processor_avresample.h
++++ /dev/null
+@@ -1,72 +0,0 @@
+-// Copyright (C) 2016  Lukas Lalinsky
+-// Distributed under the MIT license, see the LICENSE file for details.
+-
+-#ifndef CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-#define CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-
+-extern "C" {
+-#include <libavresample/avresample.h>
+-}
+-
+-namespace chromaprint {
+-
+-class FFmpegAudioProcessor {
+-public:
+-	FFmpegAudioProcessor() {
+-		m_resample_ctx = avresample_alloc_context();
+-	}
+-
+-	~FFmpegAudioProcessor() {
+-		avresample_free(&m_resample_ctx);
+-	}
+-
+-	void SetCompatibleMode() {
+-		av_opt_set_int(m_resample_ctx, "filter_size", 16, 0);
+-		av_opt_set_int(m_resample_ctx, "phase_shift", 8, 0);
+-		av_opt_set_int(m_resample_ctx, "linear_interp", 1, 0);
+-		av_opt_set_double(m_resample_ctx, "cutoff", 0.8, 0);
+-	}
+-
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "in_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_rate", sample_rate, 0);
+-	}
+-
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "out_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_rate, 0);
+-	}
+-
+-	int Init() {
+-		return avresample_open(m_resample_ctx);
+-	}
+-
+-	int Convert(uint8_t **out, int out_count, const uint8_t **in, int in_count) {
+-		return avresample_convert(m_resample_ctx, out, 0, out_count, (uint8_t **) in, 0, in_count);
+-	}
+-
+-	int Flush(uint8_t **out, int out_count) {
+-		return avresample_read(m_resample_ctx, out, out_count);
+-	}
+-
+-private:
+-	AVAudioResampleContext *m_resample_ctx = nullptr;
+-};
+-
+-}; // namespace chromaprint
+-
+-#endif
+diff --git a/src/audio/ffmpeg_audio_processor_swresample.h b/src/audio/ffmpeg_audio_processor_swresample.h
+index b86266b..b1d4bea 100644
+--- a/src/audio/ffmpeg_audio_processor_swresample.h
++++ b/src/audio/ffmpeg_audio_processor_swresample.h
+@@ -28,30 +28,28 @@ public:
+ 		av_opt_set_double(m_swr_ctx, "cutoff", 0.8, 0);
+ 	}
+
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "icl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "ich", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetInputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "in_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "isf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "in_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "isr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "in_sample_rate", sample_rate, 0);
+ 	}
+
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "ocl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "och", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetOutputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "out_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "osf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "out_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "osr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "out_sample_rate", sample_rate, 0);
+ 	}
+
+ 	int Init() {
+diff --git a/src/audio/ffmpeg_audio_reader.h b/src/audio/ffmpeg_audio_reader.h
+index 5550164..1c6b346 100644
+--- a/src/audio/ffmpeg_audio_reader.h
++++ b/src/audio/ffmpeg_audio_reader.h
+@@ -62,7 +62,7 @@ public:
+ 	bool Read(const int16_t **data, size_t *size);
+
+ 	bool IsOpen() const { return m_opened; }
+-	bool IsFinished() const { return m_finished && !m_got_frame; }
++	bool IsFinished() const { return !m_has_more_packets && !m_has_more_frames; }
+
+ 	std::string GetError() const { return m_error; }
+ 	int GetErrorCode() const { return m_error_code; }
+@@ -74,20 +74,19 @@ private:
+ 	uint8_t *m_convert_buffer[1] = { nullptr };
+ 	int m_convert_buffer_nb_samples = 0;
+
+-	AVInputFormat *m_input_fmt = nullptr;
++	const AVInputFormat *m_input_fmt = nullptr;
+ 	AVDictionary *m_input_opts = nullptr;
+
+ 	AVFormatContext *m_format_ctx = nullptr;
+ 	AVCodecContext *m_codec_ctx = nullptr;
+-	AVFrame *m_frame = nullptr;
+ 	int m_stream_index = -1;
+ 	std::string m_error;
+ 	int m_error_code = 0;
+-	bool m_finished = false;
+ 	bool m_opened = false;
+-	int m_got_frame = 0;
+-	AVPacket m_packet;
+-	AVPacket m_packet0;
++	bool m_has_more_packets = true;
++	bool m_has_more_frames = true;
++	AVPacket *m_packet = nullptr;
++	AVFrame *m_frame = nullptr;
+
+ 	int m_output_sample_rate = 0;
+ 	int m_output_channels = 0;
+@@ -98,19 +97,12 @@ private:
+
+ inline FFmpegAudioReader::FFmpegAudioReader() {
+ 	av_log_set_level(AV_LOG_QUIET);
+-
+-	av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
+ }
+
+ inline FFmpegAudioReader::~FFmpegAudioReader() {
+ 	Close();
+ 	av_dict_free(&m_input_opts);
+ 	av_freep(&m_convert_buffer[0]);
+-	av_packet_unref(&m_packet0);
+ }
+
+ inline bool FFmpegAudioReader::SetInputFormat(const char *name) {
+@@ -135,11 +127,10 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ 	Close();
+
+-    av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
++	m_packet = av_packet_alloc();
++	if (!m_packet) {
++		return false;
++	}
+
+ 	ret = avformat_open_input(&m_format_ctx, file_name.c_str(), m_input_fmt, &m_input_opts);
+ 	if (ret < 0) {
+@@ -153,26 +144,31 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		return false;
+ 	}
+
+-	AVCodec *codec;
++	const AVCodec *codec;
+ 	ret = av_find_best_stream(m_format_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &codec, 0);
+ 	if (ret < 0) {
+ 		SetError("Could not find any audio stream in the file", ret);
+ 		return false;
+ 	}
+ 	m_stream_index = ret;
++	auto stream = m_format_ctx->streams[m_stream_index];
+
+-	m_codec_ctx = m_format_ctx->streams[m_stream_index]->codec;
++	m_codec_ctx = avcodec_alloc_context3(codec);
+ 	m_codec_ctx->request_sample_fmt = AV_SAMPLE_FMT_S16;
+
++	ret = avcodec_parameters_to_context(m_codec_ctx, stream->codecpar);
++	if (ret < 0) {
++		SetError("Could not copy the stream parameters", ret);
++		return false;
++	}
++
+ 	ret = avcodec_open2(m_codec_ctx, codec, nullptr);
+ 	if (ret < 0) {
+ 		SetError("Could not open the codec", ret);
+ 		return false;
+ 	}
+
+-	if (!m_codec_ctx->channel_layout) {
+-		m_codec_ctx->channel_layout = av_get_default_channel_layout(m_codec_ctx->channels);
+-	}
++	av_dump_format(m_format_ctx, 0, "foo", 0);
+
+ 	m_frame = av_frame_alloc();
+ 	if (!m_frame) {
+@@ -183,19 +179,23 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		m_output_sample_rate = m_codec_ctx->sample_rate;
+ 	}
+
+-	if (!m_output_channels) {
+-		m_output_channels = m_codec_ctx->channels;
++	AVChannelLayout output_channel_layout;
++	if (m_output_channels) {
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
++	} else {
++		m_output_channels = m_codec_ctx->ch_layout.nb_channels;
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
+ 	}
+
+-	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
++	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->ch_layout.nb_channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
+ 		m_converter.reset(new FFmpegAudioProcessor());
+ 		m_converter->SetCompatibleMode();
+ 		m_converter->SetInputSampleFormat(m_codec_ctx->sample_fmt);
+ 		m_converter->SetInputSampleRate(m_codec_ctx->sample_rate);
+-		m_converter->SetInputChannelLayout(m_codec_ctx->channel_layout);
++		m_converter->SetInputChannelLayout(&(m_codec_ctx->ch_layout));
+ 		m_converter->SetOutputSampleFormat(AV_SAMPLE_FMT_S16);
+ 		m_converter->SetOutputSampleRate(m_output_sample_rate);
+-		m_converter->SetOutputChannelLayout(av_get_default_channel_layout(m_output_channels));
++		m_converter->SetOutputChannelLayout(&output_channel_layout);
+ 		auto ret = m_converter->Init();
+ 		if (ret != 0) {
+ 			SetError("Could not create an audio converter instance", ret);
+@@ -203,10 +203,11 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		}
+ 	}
+
++	av_channel_layout_uninit(&output_channel_layout);
++
+ 	m_opened = true;
+-	m_finished = false;
+-	m_got_frame = 0;
+-	m_nb_packets = 0;
++	m_has_more_packets = true;
++	m_has_more_frames = true;
+ 	m_decode_error = 0;
+
+ 	return true;
+@@ -214,6 +215,7 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ inline void FFmpegAudioReader::Close() {
+ 	av_frame_free(&m_frame);
++	av_packet_free(&m_packet);
+
+ 	m_stream_index = -1;
+
+@@ -252,91 +254,98 @@ inline bool FFmpegAudioReader::Read(const int16_t **data, size_t *size) {
+ 		return false;
+ 	}
+
++	*data = nullptr;
++	*size = 0;
++
+ 	int ret;
++	bool needs_packet = false;
+ 	while (true) {
+-		while (m_packet.size <= 0) {
+-			av_packet_unref(&m_packet0);
+-			av_init_packet(&m_packet);
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			ret = av_read_frame(m_format_ctx, &m_packet);
++		while (needs_packet && m_packet->size == 0) {
++			ret = av_read_frame(m_format_ctx, m_packet);
+ 			if (ret < 0) {
+ 				if (ret == AVERROR_EOF) {
+-					m_finished = true;
++					needs_packet = false;
++					m_has_more_packets = false;
+ 					break;
+-				} else {
++				}
++				SetError("Error reading from the audio source", ret);
++				return false;
++			}
++			if (m_packet->stream_index == m_stream_index) {
++				needs_packet = false;
++			} else {
++				av_packet_unref(m_packet);
++			}
++		}
++
++		if (m_packet->size != 0) {
++			ret = avcodec_send_packet(m_codec_ctx, m_packet);
++			if (ret < 0) {
++				if (ret != AVERROR(EAGAIN)) {
+ 					SetError("Error reading from the audio source", ret);
+ 					return false;
+ 				}
+-			}
+-			m_packet0 = m_packet;
+-			if (m_packet.stream_index != m_stream_index) {
+-				m_packet.data = nullptr;
+-				m_packet.size = 0;
+ 			} else {
+-				m_nb_packets++;
++				av_packet_unref(m_packet);
+ 			}
+ 		}
+
+-		ret = avcodec_decode_audio4(m_codec_ctx, m_frame, &m_got_frame, &m_packet);
++		ret = avcodec_receive_frame(m_codec_ctx, m_frame);
+ 		if (ret < 0) {
+-			if (m_decode_error) {
+-				SetError("Error decoding audio frame", m_decode_error);
+-				return false;
++			if (ret == AVERROR_EOF) {
++				m_has_more_frames = false;
++			} else if (ret == AVERROR(EAGAIN)) {
++				if (m_has_more_packets) {
++					needs_packet = true;
++					continue;
++				} else {
++					m_has_more_frames = false;
++				}
+ 			}
+-			m_decode_error = ret;
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			continue;
++			SetError("Error decoding the audio source", ret);
++			return false;
+ 		}
+
+-		break;
+-	}
+-
+-	m_decode_error = 0;
+-
+-	const int decoded = std::min(ret, m_packet.size);
+-	m_packet.data += decoded;
+-	m_packet.size -= decoded;
+-
+-	if (m_got_frame) {
+-		if (m_converter) {
+-			if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
+-				int linsize;
+-				av_freep(&m_convert_buffer[0]);
+-				m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
+-				ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
+-				if (ret < 0) {
+-					SetError("Couldn't allocate audio converter buffer", ret);
++		if (m_frame->nb_samples > 0) {
++			if (m_converter) {
++				if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
++					int linsize;
++					av_freep(&m_convert_buffer[0]);
++					m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
++					ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->ch_layout.nb_channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
++					if (ret < 0) {
++						SetError("Couldn't allocate audio converter buffer", ret);
++						return false;
++					}
++				}
++				auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
++				if (nb_samples < 0) {
++					SetError("Couldn't convert audio", ret);
+ 					return false;
+ 				}
+-			}
+-			auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			}
+-			*data = (const int16_t *) m_convert_buffer[0];
+-			*size = nb_samples;
+-		} else {
+-			*data = (const int16_t *) m_frame->data[0];
+-			*size = m_frame->nb_samples;
+-		}
+-	} else {
+-		if (m_finished && m_converter) {
+-			auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			} else if (nb_samples > 0) {
+-				m_got_frame = 1;
+ 				*data = (const int16_t *) m_convert_buffer[0];
+ 				*size = nb_samples;
++			} else {
++				*data = (const int16_t *) m_frame->data[0];
++				*size = m_frame->nb_samples;
++			}
++		} else {
++			if (m_converter) {
++				if (IsFinished()) {
++					auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
++					if (nb_samples < 0) {
++						SetError("Couldn't convert audio", ret);
++						return false;
++					} else if (nb_samples > 0) {
++						*data = (const int16_t *) m_convert_buffer[0];
++						*size = nb_samples;
++					}
++				}
+ 			}
+ 		}
+-	}
+
+-	return true;
++		return true;
++	}
+ }
+
+ inline void FFmpegAudioReader::SetError(const char *message, int errnum) {
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index a2b517b..123e643 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -38,6 +38,12 @@ set(SRCS
+
+ if(BUILD_TOOLS)
+ 	set(SRCS ${SRCS} ../src/audio/ffmpeg_audio_reader_test.cpp)
++    include_directories(
++        ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}
++        ${AUDIO_PROCESSOR_INCLUDE_DIRS}
++    )
+ 	link_libraries(fpcalc_libs)
+ endif()
+
+-- 
+2.38.1
+
+
diff --git a/srcpkgs/chromaprint/template b/srcpkgs/chromaprint/template
index 7ef7838949f3a..1f7bbc70a22c8 100644
--- a/srcpkgs/chromaprint/template
+++ b/srcpkgs/chromaprint/template
@@ -1,7 +1,7 @@
 # Template file for 'chromaprint'
 pkgname=chromaprint
 version=1.5.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DBUILD_TOOLS=ON"
 make_check_target="check"

From 9ed8d8c34d74968bff7481b2ddb2091c69685673 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 021/113] chromium: revbump for ffmpeg6

---
 srcpkgs/chromium/patches/ffmpeg5.patch | 47 ++++++++++++++++++++++++++
 srcpkgs/chromium/template              |  2 +-
 2 files changed, 48 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..24e2da38e34ca
--- /dev/null
+++ b/srcpkgs/chromium/patches/ffmpeg5.patch
@@ -0,0 +1,47 @@
+--- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
++++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
+@@ -92,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+-  if (stream->start_time != kNoFFmpegTimestamp)
++  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -1597,7 +1585,7 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+@@ -1618,7 +1606,7 @@
+     if (stream->type() != DemuxerStream::VIDEO)
+       continue;
+ 
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+ 
+     if (!stream->IsEnabled())
diff --git a/srcpkgs/chromium/template b/srcpkgs/chromium/template
index 22947e83cb52c..e8e5b92b5c8d5 100644
--- a/srcpkgs/chromium/template
+++ b/srcpkgs/chromium/template
@@ -2,7 +2,7 @@
 pkgname=chromium
 # See https://chromiumdash.appspot.com/releases?platform=Linux for the latest version
 version=121.0.6167.160
-revision=1
+revision=2
 archs="i686* x86_64* aarch64* armv7l*"
 hostmakedepends="
  $(vopt_if clang "clang17 lld17 llvm17 compiler-rt")

From 28ec1088985d7c6da347e1adc0daec2d1d4ac2cd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 022/113] cmus: revbump for ffmpeg6

---
 srcpkgs/chromium/patches/ffmpeg5.patch | 47 --------------------------
 srcpkgs/cmus/patches/ffmpeg6.patch     | 12 +++++++
 srcpkgs/cmus/template                  |  2 +-
 3 files changed, 13 insertions(+), 48 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch
 create mode 100644 srcpkgs/cmus/patches/ffmpeg6.patch

diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
deleted file mode 100644
index 24e2da38e34ca..0000000000000
--- a/srcpkgs/chromium/patches/ffmpeg5.patch
+++ /dev/null
@@ -1,47 +0,0 @@
---- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
-+++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
-@@ -92,24 +92,12 @@
- 
- static base::TimeDelta ExtractStartTime(AVStream* stream) {
-   // The default start time is zero.
--  base::TimeDelta start_time;
-+  base::TimeDelta start_time = kNoTimestamp;
- 
-   // First try to use  the |start_time| value as is.
--  if (stream->start_time != kNoFFmpegTimestamp)
-+  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
-     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
- 
--  // Next try to use the first DTS value, for codecs where we know PTS == DTS
--  // (excludes all H26x codecs). The start time must be returned in PTS.
--  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
--      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
--      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
--      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
--    const base::TimeDelta first_pts =
--        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
--    if (first_pts < start_time)
--      start_time = first_pts;
--  }
--
-   return start_time;
- }
- 
-@@ -1597,7 +1585,7 @@
-   for (const auto& stream : streams_) {
-     if (!stream || stream->IsEnabled() != enabled)
-       continue;
--    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
-+    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
-       continue;
-     if (!lowest_start_time_stream ||
-         stream->start_time() < lowest_start_time_stream->start_time()) {
-@@ -1618,7 +1606,7 @@
-     if (stream->type() != DemuxerStream::VIDEO)
-       continue;
- 
--    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
-+    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
-       continue;
- 
-     if (!stream->IsEnabled())
diff --git a/srcpkgs/cmus/patches/ffmpeg6.patch b/srcpkgs/cmus/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..ffa95ab811101
--- /dev/null
+++ b/srcpkgs/cmus/patches/ffmpeg6.patch
@@ -0,0 +1,12 @@
+--- a/ip/ffmpeg.c
++++ b/ip/ffmpeg.c
+@@ -202,9 +202,6 @@ static int ffmpeg_open(struct input_plugin_data *ip_data)
+ 			break;
+ 		}
+ 
+-		if (codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+-			cc->flags |= AV_CODEC_FLAG_TRUNCATED;
+-
+ 		if (avcodec_open2(cc, codec, NULL) < 0) {
+ 			d_print("could not open codec: %d, %s\n", cc->codec_id, avcodec_get_name(cc->codec_id));
+ 			err = -IP_ERROR_UNSUPPORTED_FILE_TYPE;
diff --git a/srcpkgs/cmus/template b/srcpkgs/cmus/template
index 0d1436744f1b2..a6e4b4fa86cb8 100644
--- a/srcpkgs/cmus/template
+++ b/srcpkgs/cmus/template
@@ -1,7 +1,7 @@
 # Template file for 'cmus'
 pkgname=cmus
 version=2.10.0
-revision=3
+revision=4
 build_style=configure
 configure_args="prefix=/usr LD=$CC"
 hostmakedepends="pkg-config"

From 1a29002f3b3bda543c86336a16bdcf17f51a16d2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 023/113] cyanrip: revbump for ffmpeg6

---
 srcpkgs/cyanrip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cyanrip/template b/srcpkgs/cyanrip/template
index 9796e3461601a..5db30e020d17e 100644
--- a/srcpkgs/cyanrip/template
+++ b/srcpkgs/cyanrip/template
@@ -1,7 +1,7 @@
 # Template file for 'cyanrip'
 pkgname=cyanrip
 version=0.9.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config"
 makedepends="ffmpeg-devel libcdio-devel libcdio-paranoia-devel libcurl-devel libmusicbrainz5-devel"

From 491b9b0a7caa23aff5e4963dd52aea50b5dea3ea Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 024/113] deadbeef: revbump for ffmpeg4

---
 srcpkgs/deadbeef/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/deadbeef/template b/srcpkgs/deadbeef/template
index f5f4bf24b8cb6..7b47e615cd48e 100644
--- a/srcpkgs/deadbeef/template
+++ b/srcpkgs/deadbeef/template
@@ -1,14 +1,14 @@
 # Template file for 'deadbeef'
 pkgname=deadbeef
 version=1.8.8
-revision=3
+revision=4
 create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-oss --disable-lfm --disable-notify --disable-gtk2"
 hostmakedepends="automake libtool gettext gettext-devel intltool pkg-config
  yasm clang glib-devel"
 makedepends="
- alsa-lib-devel dbus-devel faad2-devel ffmpeg-devel gtk+3-devel imlib2-devel
+ alsa-lib-devel dbus-devel faad2-devel ffmpeg4-devel gtk+3-devel imlib2-devel
  jansson-devel libcddb-devel libcdio-devel libcurl-devel libflac-devel
  libmad-devel libpng-devel libsamplerate-devel libsndfile-devel libvorbis-devel
  libzip-devel mpg123-devel opusfile-devel pulseaudio-devel wavpack-devel"

From e4ce04e2b969a33d240e60d33bef918b9cb3688d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 025/113] droidcam-obs-plugin: revbump for ffmpeg6

---
 srcpkgs/droidcam-obs-plugin/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam-obs-plugin/template b/srcpkgs/droidcam-obs-plugin/template
index fc9c9bf6b9d54..fb0480754df4d 100644
--- a/srcpkgs/droidcam-obs-plugin/template
+++ b/srcpkgs/droidcam-obs-plugin/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam-obs-plugin'
 pkgname=droidcam-obs-plugin
 version=2.0.1
-revision=1
+revision=2
 build_style=gnu-makefile
 make_use_env=yes
 make_build_args="ALLOW_STATIC=no"

From cd428ee0a141e2719339509b165baabd284d4d01 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 026/113] droidcam: revbump for ffmpeg6

---
 srcpkgs/droidcam/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam/template b/srcpkgs/droidcam/template
index 1c3f1b8b1fc67..32a9220b79a4d 100644
--- a/srcpkgs/droidcam/template
+++ b/srcpkgs/droidcam/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam'
 pkgname=droidcam
 version=1.8.2
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="USBMUXD=-lusbmuxd-2.0 JPEG=-lturbojpeg"
 hostmakedepends="pkg-config"

From cfc42dab21bea3cdb971c0249cdfa03a37687c4e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 027/113] ffmpegthumbnailer: revbump for ffmpeg6

---
 .../ffmpegthumbnailer/patches/ffmpeg6.patch   | 202 ++++++++++++++++++
 srcpkgs/ffmpegthumbnailer/template            |   6 +-
 2 files changed, 205 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch

diff --git a/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..363ff35a28419
--- /dev/null
+++ b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
@@ -0,0 +1,202 @@
+--- a/libffmpegthumbnailer/moviedecoder.cpp	2017-11-21 14:06:57.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.cpp	2023-05-05 13:14:47.946560668 -0400
+@@ -41,11 +41,6 @@
+ namespace ffmpegthumbnailer
+ {
+ 
+-struct SilenceLogLevel
+-{
+-    SilenceLogLevel() { av_log_set_level(AV_LOG_QUIET); }
+-};
+-
+ MovieDecoder::MovieDecoder(AVFormatContext* pavContext)
+ : m_VideoStream(-1)
+ , m_pFormatContext(pavContext)
+@@ -70,8 +65,6 @@
+ 
+ void MovieDecoder::initialize(const string& filename, bool preferEmbeddedMetadata)
+ {
+-    av_register_all();
+-    avcodec_register_all();
+     avformat_network_init();
+ 
+     string inputFile = filename == "-" ? "pipe:" : filename;
+@@ -97,8 +90,7 @@
+ {
+     if (m_pVideoCodecContext)
+     {
+-        avcodec_close(m_pVideoCodecContext);
+-        m_pVideoCodecContext = nullptr;
++        avcodec_free_context(&m_pVideoCodecContext);
+     }
+ 
+     if ((!m_FormatContextWasGiven) && m_pFormatContext)
+@@ -152,10 +144,10 @@
+     for (unsigned int i = 0; i < m_pFormatContext->nb_streams; ++i)
+     {
+         AVStream *stream = m_pFormatContext->streams[i];
+-        auto ctx = m_pFormatContext->streams[i]->codec;
+-        if (ctx->codec_type == AVMEDIA_TYPE_VIDEO)
++        auto par = m_pFormatContext->streams[i]->codecpar;
++        if (par->codec_type == AVMEDIA_TYPE_VIDEO)
+         {
+-            if (!preferEmbeddedMetadata || !isStillImageCodec(ctx->codec_id))
++            if (!preferEmbeddedMetadata || !isStillImageCodec(par->codec_id))
+             {
+                 videoStreams.push_back(i);
+                 continue;
+@@ -203,8 +195,7 @@
+     }
+ 
+     m_pVideoStream = m_pFormatContext->streams[m_VideoStream];
+-    m_pVideoCodecContext = m_pVideoStream->codec;
+-    m_pVideoCodec = avcodec_find_decoder(m_pVideoCodecContext->codec_id);
++    m_pVideoCodec = avcodec_find_decoder(m_pVideoStream->codecpar->codec_id);
+ 
+     if (m_pVideoCodec == nullptr)
+     {
+@@ -214,6 +205,20 @@
+         throw logic_error("Video Codec not found");
+     }
+ 
++    m_pVideoCodecContext = avcodec_alloc_context3(m_pVideoCodec);
++
++    if (m_pVideoCodecContext == nullptr)
++    {
++        destroy();
++        throw logic_error("Could not allocate video codec context");
++    }
++
++    if (avcodec_parameters_to_context(m_pVideoCodecContext, m_pVideoStream->codecpar) < 0)
++    {
++        destroy();
++        throw logic_error("Could not configure video codec context");
++    }
++
+     m_pVideoCodecContext->workaround_bugs = 1;
+ 
+     if (avcodec_open2(m_pVideoCodecContext, m_pVideoCodec, nullptr) < 0)
+@@ -386,13 +391,6 @@
+ 
+ void MovieDecoder::initializeFilterGraph(const AVRational& timeBase, const std::string& size, bool maintainAspectRatio)
+ {
+-    static const AVPixelFormat pixelFormats[] = { AV_PIX_FMT_RGB24, AV_PIX_FMT_NONE };
+-
+-    auto del = [] (AVBufferSinkParams* p) { av_freep(p); };
+-    std::unique_ptr<AVBufferSinkParams, decltype(del)> buffersinkParams(av_buffersink_params_alloc(), del);
+-
+-    avfilter_register_all();
+-
+     m_pFilterGraph = avfilter_graph_alloc();
+     assert(m_pFilterGraph);
+ 
+@@ -404,10 +402,8 @@
+ 
+     checkRc(avfilter_graph_create_filter(&m_pFilterSource, avfilter_get_by_name("buffer"), "thumb_buffer", ss.str().c_str(), nullptr, m_pFilterGraph),
+             "Failed to create filter source");
+-    buffersinkParams->pixel_fmts = pixelFormats;
+-    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, buffersinkParams.get(), m_pFilterGraph),
++    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, nullptr, m_pFilterGraph),
+             "Failed to create filter sink");
+-    buffersinkParams.release();
+ 
+     AVFilterContext* yadifFilter = nullptr;
+     if (m_pFrame->interlaced_frame != 0)
+@@ -500,15 +496,15 @@
+     }
+ 
+     checkRc(av_seek_frame(m_pFormatContext, -1, timestamp, 0), "Seeking in video failed");
+-    avcodec_flush_buffers(m_pFormatContext->streams[m_VideoStream]->codec);
++    avcodec_flush_buffers(m_pVideoCodecContext);
+ 
+     int keyFrameAttempts = 0;
+-    bool gotFrame = 0;
++    bool gotFrame;
+ 
+     do
+     {
+         int count = 0;
+-        gotFrame = 0;
++        gotFrame = false;
+ 
+         while (!gotFrame && count < 20)
+         {
+@@ -552,17 +548,33 @@
+         return false;
+     }
+ 
+-    av_frame_unref(m_pFrame);
+-
+-    int frameFinished;
++    int rc = avcodec_send_packet(m_pVideoCodecContext, m_pPacket);
++    if(rc == AVERROR(EAGAIN))
++    {
++        rc = 0;
++    }
+ 
+-    int bytesDecoded = avcodec_decode_video2(m_pVideoCodecContext, m_pFrame, &frameFinished, m_pPacket);
+-    if (bytesDecoded < 0)
++    if(rc == AVERROR_EOF)
++    {
++        return false;
++    }
++    else if(rc < 0)
+     {
+-        throw logic_error("Failed to decode video frame: bytesDecoded < 0");
++        throw logic_error("Failed to decode video frame: avcodec_send_packet() < 0");
+     }
+ 
+-    return frameFinished > 0;
++    rc = avcodec_receive_frame(m_pVideoCodecContext, m_pFrame);
++    switch(rc)
++    {
++        case 0:
++            return true;
++
++        case AVERROR(EAGAIN):
++            return false;
++
++        default:
++            throw logic_error("Failed to decode video frame: avcodec_receive_frame() < 0");
++    }
+ }
+ 
+ bool MovieDecoder::getVideoPacket()
+@@ -570,8 +582,6 @@
+     bool framesAvailable = true;
+     bool frameDecoded = false;
+ 
+-    int attempts = 0;
+-
+     if (m_pPacket)
+     {
+         av_packet_unref(m_pPacket);
+@@ -580,6 +590,7 @@
+ 
+     m_pPacket = new AVPacket();
+ 
++
+     while (framesAvailable && !frameDecoded)
+     {
+         framesAvailable = av_read_frame(m_pFormatContext, m_pPacket) >= 0;
+@@ -644,7 +655,7 @@
+ 
+ int32_t MovieDecoder::getStreamRotation()
+ {
+-    int32_t* matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
++    auto matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
+     if (matrix)
+     {
+         auto angle = lround(av_display_rotation_get(matrix));
+
+--- a/libffmpegthumbnailer/moviedecoder.h	2017-11-12 04:23:38.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.h	2023-05-05 13:26:07.095529911 -0400
+@@ -78,7 +78,7 @@
+     int                     m_VideoStream;
+     AVFormatContext*        m_pFormatContext;
+     AVCodecContext*         m_pVideoCodecContext;
+-    AVCodec*                m_pVideoCodec;
++    const AVCodec*          m_pVideoCodec;
+     AVFilterGraph*          m_pFilterGraph;
+     AVFilterContext*        m_pFilterSource;
+     AVFilterContext*        m_pFilterSink;
diff --git a/srcpkgs/ffmpegthumbnailer/template b/srcpkgs/ffmpegthumbnailer/template
index 039eea7622b39..35d546018d12a 100644
--- a/srcpkgs/ffmpegthumbnailer/template
+++ b/srcpkgs/ffmpegthumbnailer/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbnailer'
 pkgname=ffmpegthumbnailer
 version=2.2.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libpng-devel libjpeg-turbo-devel ffmpeg-devel"
@@ -9,8 +9,8 @@ depends="ffmpeg"
 short_desc="Lightweight video thumbnailer"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
-homepage="https://github.com/dirkvdb/${pkgname}"
-distfiles="${homepage}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
+homepage="https://github.com/dirkvdb"
+distfiles="${homepage}/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
 checksum=1cb24059c38223f657b300c84dd80491b7040d4b69471c4fea69be862bc99b5b
 
 post_install() {

From 513a4bbd1afb667e452e16e90d6c9ef6f6cb14e3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 028/113] ffmpegthumbs: revbump for ffmpeg6

---
 srcpkgs/ffmpegthumbs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ffmpegthumbs/template b/srcpkgs/ffmpegthumbs/template
index 5f0b9414dadaf..11b88193528f4 100644
--- a/srcpkgs/ffmpegthumbs/template
+++ b/srcpkgs/ffmpegthumbs/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbs'
 pkgname=ffmpegthumbs
 version=22.12.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules kcoreaddons kconfig-devel
  pkg-config qt5-host-tools qt5-qmake gettext"

From a9db20f792ad0db9df5c63fa09311a16a1d4de5b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 029/113] ffms2: revbump for ffmpeg6

---
 srcpkgs/ffms2/patches/ffmpeg5.patch | 424 ++++++++++++++++++++++++++++
 srcpkgs/ffms2/template              |   2 +-
 2 files changed, 425 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ffms2/patches/ffmpeg5.patch

diff --git a/srcpkgs/ffms2/patches/ffmpeg5.patch b/srcpkgs/ffms2/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..1479fabcafcb4
--- /dev/null
+++ b/srcpkgs/ffms2/patches/ffmpeg5.patch
@@ -0,0 +1,424 @@
+From 45673149e9a2f5586855ad472e3059084eaa36b1 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:41:21 +0100
+Subject: [PATCH] Use auto for AVCodec
+
+The geniuses over at FFmpeg decided to constify this API, so old
+versions of the library will return AVCodec *, while new versions
+of the libary will return const AVCodec *, which, in C++, are not
+OK to convert between.
+
+Rather than use some macro hell in ffmscompat.h, we can work around
+this by using auto.
+
+Gross.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 2 +-
+ src/core/indexing.cpp    | 6 +++---
+ src/core/videosource.cpp | 2 +-
+ 3 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index e4ce97c..ac09666 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -469,7 +469,7 @@ void FFMS_AudioSource::OpenFile() {
+ 
+     LAVFOpenFile(SourceFile.c_str(), FormatContext, TrackNumber);
+ 
+-    AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
++    auto *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
+     if (Codec == nullptr)
+         throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+             "Audio codec not found");
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index e547c5a..59fb4e8 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -384,7 +384,7 @@ FFMS_TrackType FFMS_Indexer::GetTrackType(int Track) {
+ }
+ 
+ const char *FFMS_Indexer::GetTrackCodec(int Track) {
+-    AVCodec *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
++    auto *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
+     return codec ? codec->name : nullptr;
+ }
+ 
+@@ -402,7 +402,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             UseDTS);
+ 
+         if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            AVCodec *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (!VideoCodec) {
+                 FormatContext->streams[i]->discard = AVDISCARD_ALL;
+                 IndexMask.erase(i);
+@@ -433,7 +433,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 IndexMask.insert(i);
+             }
+         } else if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+-            AVCodec *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (AudioCodec == nullptr)
+                 throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_UNSUPPORTED,
+                     "Audio codec not found");
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index b889970..8956c22 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -171,7 +171,7 @@ FFMS_VideoSource::FFMS_VideoSource(const char *SourceFile, FFMS_Index &Index, in
+ 
+         LAVFOpenFile(SourceFile, FormatContext, VideoTrack);
+ 
+-        AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
++        auto *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
+         if (Codec == nullptr)
+             throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+                 "Video codec not found");
+-- 
+2.40.0
+
+From 96cbf38ea9381829a1314f432a2c60495dcefaad Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:12:41 +0100
+Subject: [PATCH] all: Update AVPacket API usage
+
+AVPackets must all be on the heap now, since it is no longer
+part of the libav* ABI.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 16 ++++++----
+ src/core/indexing.cpp    | 63 ++++++++++++++++++++++------------------
+ src/core/indexing.h      |  4 +--
+ src/core/utils.cpp       |  6 ----
+ src/core/utils.h         |  1 -
+ src/core/videosource.cpp | 30 ++++++++++---------
+ 6 files changed, 64 insertions(+), 56 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index 37cf9ae..e4ce97c 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -285,10 +285,15 @@ FFMS_AudioSource::AudioBlock *FFMS_AudioSource::CacheBlock(CacheIterator &pos) {
+ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     CurrentFrame = &Frames[PacketNumber];
+ 
+-    AVPacket Packet;
+-    if (!ReadPacket(&Packet))
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++    if (!ReadPacket(Packet)) {
++        av_packet_free(&Packet);
+         throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_UNKNOWN,
+             "ReadPacket unexpectedly failed to read a packet");
++    }
+ 
+     // ReadPacket may have changed the packet number
+     CurrentFrame = &Frames[PacketNumber];
+@@ -297,8 +302,9 @@ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     int NumberOfSamples = 0;
+     AudioBlock *CachedBlock = nullptr;
+     
+-    int Ret = avcodec_send_packet(CodecContext, &Packet);
+-    av_packet_unref(&Packet);
++    int Ret = avcodec_send_packet(CodecContext, Packet);
++    av_packet_unref(Packet);
++    av_packet_free(&Packet);
+ 
+     av_frame_unref(DecodeFrame);
+     Ret = avcodec_receive_frame(CodecContext, DecodeFrame);
+@@ -513,8 +519,6 @@ void FFMS_AudioSource::Seek() {
+ }
+ 
+ bool FFMS_AudioSource::ReadPacket(AVPacket *Packet) {
+-    InitNullPacket(*Packet);
+-
+     while (av_read_frame(FormatContext, Packet) >= 0) {
+         if (Packet->stream_index == TrackNumber) {
+             // Required because not all audio packets, especially in ogg, have a pts. Use the previous valid packet's pts instead.
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index 23fb95b..e547c5a 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -320,7 +320,7 @@ void FFMS_Indexer::CheckAudioProperties(int Track, AVCodecContext *Context) {
+     }
+ }
+ 
+-void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict,
++void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict,
+                                     int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct) {
+     if (VideoContext.Parser) {
+         uint8_t *OB;
+@@ -330,8 +330,8 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+         av_parser_parse2(VideoContext.Parser,
+             VideoContext.CodecContext,
+             &OB, &OBSize,
+-            pkt.data, pkt.size,
+-            pkt.pts, pkt.dts, pkt.pos);
++            pkt->data, pkt->size,
++            pkt->pts, pkt->dts, pkt->pos);
+ 
+         // H.264 (PAFF) and HEVC may have one field per packet, so we need to track
+         // when we have a full or half frame available, and mark one of them as
+@@ -351,15 +351,15 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+ 
+         *RepeatPict = VideoContext.Parser->repeat_pict;
+         *FrameType = VideoContext.Parser->pict_type;
+-        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt.flags & AV_PKT_FLAG_DISCARD));
++        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt->flags & AV_PKT_FLAG_DISCARD));
+     } else {
+-        *Invisible = !!(pkt.flags & AV_PKT_FLAG_DISCARD);
++        *Invisible = !!(pkt->flags & AV_PKT_FLAG_DISCARD);
+     }
+ 
+     if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP8)
+-        ParseVP8(pkt.data[0], Invisible, FrameType);
++        ParseVP8(pkt->data[0], Invisible, FrameType);
+     else if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP9)
+-        ParseVP9(pkt.data[0], Invisible, FrameType);
++        ParseVP9(pkt->data[0], Invisible, FrameType);
+ }
+ 
+ void FFMS_Indexer::Free() {
+@@ -458,32 +458,36 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+         }
+     }
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
+     std::vector<int64_t> LastValidTS(FormatContext->nb_streams, AV_NOPTS_VALUE);
+ 
+     int64_t filesize = avio_size(FormatContext->pb);
+     enum AVPictureStructure LastPicStruct = AV_PICTURE_STRUCTURE_UNKNOWN;
+-    while (av_read_frame(FormatContext, &Packet) >= 0) {
++    while (av_read_frame(FormatContext, Packet) >= 0) {
+         // Update progress
+         // FormatContext->pb can apparently be NULL when opening images.
+         if (IC && FormatContext->pb) {
+-            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate))
++            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate)) {
++                av_packet_free(&Packet);
+                 throw FFMS_Exception(FFMS_ERROR_CANCELLED, FFMS_ERROR_USER,
+                     "Cancelled by user");
++            }
+         }
+-        if (!IndexMask.count(Packet.stream_index)) {
+-            av_packet_unref(&Packet);
++        if (!IndexMask.count(Packet->stream_index)) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+-        int Track = Packet.stream_index;
++        int Track = Packet->stream_index;
+         FFMS_Track &TrackInfo = (*TrackIndices)[Track];
+-        bool KeyFrame = !!(Packet.flags & AV_PKT_FLAG_KEY);
++        bool KeyFrame = !!(Packet->flags & AV_PKT_FLAG_KEY);
+         ReadTS(Packet, LastValidTS[Track], (*TrackIndices)[Track].UseDTS);
+ 
+         if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            int64_t PTS = TrackInfo.UseDTS ? Packet.dts : Packet.pts;
++            int64_t PTS = TrackInfo.UseDTS ? Packet->dts : Packet->pts;
+             if (PTS == AV_NOPTS_VALUE) {
+                 // VPx alt-refs are output as packets which lack timestmps or durations, since
+                 // they are invisible. Currently, the timestamp mangling code in libavformat
+@@ -495,9 +499,11 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 // FFMS2 currently sorts packets by PTS, which will break decoding, otherwise.
+                 bool HasAltRefs = (FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP8 ||
+                                    FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP9);
+-                if (Packet.duration == 0 && !HasAltRefs)
++                if (Packet->duration == 0 && !HasAltRefs) {
++                    av_packet_free(&Packet);
+                     throw FFMS_Exception(FFMS_ERROR_INDEXING, FFMS_ERROR_PARSER,
+                         "Invalid packet pts, dts, and duration");
++                }
+ 
+                 if (TrackInfo.empty())
+                     PTS = 0;
+@@ -513,7 +519,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             ParseVideoPacket(AVContexts[Track], Packet, &RepeatPict, &FrameType, &Invisible, &LastPicStruct);
+ 
+             TrackInfo.AddVideoFrame(PTS, RepeatPict, KeyFrame,
+-                FrameType, Packet.pos, Invisible);
++                FrameType, Packet->pos, Invisible);
+         } else if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+             // For video seeking timestamps are used only if all packets have
+             // timestamps, while for audio they're used if any have timestamps,
+@@ -522,28 +528,29 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 TrackInfo.HasTS = true;
+ 
+             int64_t StartSample = AVContexts[Track].CurrentSample;
+-            uint32_t SampleCount = IndexAudioPacket(Track, &Packet, AVContexts[Track], *TrackIndices);
++            uint32_t SampleCount = IndexAudioPacket(Track, Packet, AVContexts[Track], *TrackIndices);
+             TrackInfo.SampleRate = AVContexts[Track].CodecContext->sample_rate;
+ 
+             TrackInfo.AddAudioFrame(LastValidTS[Track],
+-                StartSample, SampleCount, KeyFrame, Packet.pos, Packet.flags & AV_PKT_FLAG_DISCARD);
++                StartSample, SampleCount, KeyFrame, Packet->pos, Packet->flags & AV_PKT_FLAG_DISCARD);
+         }
+ 
+-        if (!(Packet.flags & AV_PKT_FLAG_DISCARD))
+-            TrackInfo.LastDuration = Packet.duration;
++        if (!(Packet->flags & AV_PKT_FLAG_DISCARD))
++            TrackInfo.LastDuration = Packet->duration;
+ 
+-        av_packet_unref(&Packet);
++        av_packet_unref(Packet);
+     }
++    av_packet_free(&Packet);
+ 
+     TrackIndices->Finalize(AVContexts, FormatContext->iformat->name);
+     return TrackIndices.release();
+ }
+ 
+-void FFMS_Indexer::ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS) {
+-    if (!UseDTS && Packet.pts != AV_NOPTS_VALUE)
+-        TS = Packet.pts;
++void FFMS_Indexer::ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS) {
++    if (!UseDTS && Packet->pts != AV_NOPTS_VALUE)
++        TS = Packet->pts;
+     if (TS == AV_NOPTS_VALUE)
+         UseDTS = true;
+-    if (UseDTS && Packet.dts != AV_NOPTS_VALUE)
+-        TS = Packet.dts;
++    if (UseDTS && Packet->dts != AV_NOPTS_VALUE)
++        TS = Packet->dts;
+ }
+diff --git a/src/core/indexing.h b/src/core/indexing.h
+index 3cfc3c3..5c06868 100644
+--- a/src/core/indexing.h
++++ b/src/core/indexing.h
+@@ -80,10 +80,10 @@ private:
+     int64_t Filesize;
+     uint8_t Digest[20];
+ 
+-    void ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS);
++    void ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS);
+     void CheckAudioProperties(int Track, AVCodecContext *Context);
+     uint32_t IndexAudioPacket(int Track, AVPacket *Packet, SharedAVContext &Context, FFMS_Index &TrackIndices);
+-    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
++    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
+     void Free();
+ public:
+     FFMS_Indexer(const char *Filename);
+diff --git a/src/core/utils.cpp b/src/core/utils.cpp
+index ce67533..8a2e997 100644
+--- a/src/core/utils.cpp
++++ b/src/core/utils.cpp
+@@ -62,12 +62,6 @@ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo) {
+     }
+ }
+ 
+-void InitNullPacket(AVPacket &pkt) {
+-    av_init_packet(&pkt);
+-    pkt.data = nullptr;
+-    pkt.size = 0;
+-}
+-
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames) {
+     AP.SampleFormat = static_cast<FFMS_SampleFormat>(av_get_packed_sample_fmt(CTX->sample_fmt));
+     AP.BitsPerSample = av_get_bytes_per_sample(CTX->sample_fmt) * 8;
+diff --git a/src/core/utils.h b/src/core/utils.h
+index 9819dc7..003ab79 100644
+--- a/src/core/utils.h
++++ b/src/core/utils.h
+@@ -58,7 +58,6 @@ std::unique_ptr<T> make_unique(Args&&... args) {
+ }
+ 
+ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo);
+-void InitNullPacket(AVPacket &pkt);
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames);
+ 
+ void LAVFOpenFile(const char *SourceFile, AVFormatContext *&FormatContext, int Track);
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index 06bd161..b889970 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -673,30 +673,34 @@ void FFMS_VideoSource::DecodeNextFrame(int64_t &AStartTime, int64_t &Pos) {
+     if (HasPendingDelayedFrames())
+         return;
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
+-
+-    while (ReadFrame(&Packet) >= 0) {
+-        if (Packet.stream_index != VideoTrack) {
+-            av_packet_unref(&Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++
++    while (ReadFrame(Packet) >= 0) {
++        if (Packet->stream_index != VideoTrack) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+         if (AStartTime < 0)
+-            AStartTime = Frames.UseDTS ? Packet.dts : Packet.pts;
++            AStartTime = Frames.UseDTS ? Packet->dts : Packet->pts;
+ 
+         if (Pos < 0)
+-            Pos = Packet.pos;
++            Pos = Packet->pos;
+ 
+-        bool FrameFinished = DecodePacket(&Packet);
+-        av_packet_unref(&Packet);
+-        if (FrameFinished)
++        bool FrameFinished = DecodePacket(Packet);
++        av_packet_unref(Packet);
++        if (FrameFinished) {
++            av_packet_free(&Packet);
+             return;
++        }
+     }
+ 
+     // Flush final frames
+-    InitNullPacket(Packet);
+-    DecodePacket(&Packet);
++    DecodePacket(Packet);
++    av_packet_free(&Packet);
+ }
+ 
+ bool FFMS_VideoSource::SeekTo(int n, int SeekOffset) {
+-- 
+2.40.0
+
+From bf9e03e9e08534c024e5a744a6437c4aac160201 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:20:47 +0100
+Subject: [PATCH 2/3] configure: Remove deprecated API use
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ configure.ac | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index b35ef80bc..d19714d0f 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -102,10 +102,10 @@ CFLAGS="$_CFLAGS $FFMPEG_CFLAGS"
+
+ AC_DEFUN([TEST_FFMPEG],
+          [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+-            #include <libavcodec/avcodec.h>
++            #include <libavformat/avformat.h>
+             #include <libswscale/swscale.h>
+             ]],[[
+-                avcodec_register_all();
++                avformat_network_init();
+                 swscale_version();
+             ]])], [eval $1=yes], [eval $1=no])
+         ])
+
diff --git a/srcpkgs/ffms2/template b/srcpkgs/ffms2/template
index 365f64d10cbab..1641ecf43be5b 100644
--- a/srcpkgs/ffms2/template
+++ b/srcpkgs/ffms2/template
@@ -1,7 +1,7 @@
 # Template file for 'ffms2'
 pkgname=ffms2
 version=2.40
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-shared --disable-static"
 hostmakedepends="pkg-config autoconf automake libtool"

From 7d4102cdf1c7ce13edcd4f749e51a39b2f943de8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 030/113] freerdp: revbump for ffmpeg6

---
 .../freerdp/patches/ffmpeg6_aa2cb9aa.patch    | 42 +++++++++++++++++++
 srcpkgs/freerdp/template                      |  2 +-
 2 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch

diff --git a/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
new file mode 100644
index 0000000000000..a4324da3a8822
--- /dev/null
+++ b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
@@ -0,0 +1,42 @@
+From aa2cb9aa5ff5562433598ba168a466e0752bca0e Mon Sep 17 00:00:00 2001
+From: akallabeth <akallabeth@posteo.net>
+Date: Tue, 14 Feb 2023 07:48:54 +0100
+Subject: [PATCH] Fixed #8686: Update h264 to use new FFMPEG API
+
+---
+ channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c | 2 ++
+ libfreerdp/codec/h264_ffmpeg.c            | 2 ++
+ 2 files changed, 4 insertions(+)
+
+diff --git a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+index 339462d865f..beea80b7a1e 100644
+--- a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
++++ b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+@@ -239,8 +239,10 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYP
+ 		}
+ 	}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 	if (mdecoder->codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		mdecoder->codec_context->flags |= AV_CODEC_FLAG_TRUNCATED;
++#endif
+ 
+ 	return TRUE;
+ }
+diff --git a/libfreerdp/codec/h264_ffmpeg.c b/libfreerdp/codec/h264_ffmpeg.c
+index 8a23db2473c..896a333019b 100644
+--- a/libfreerdp/codec/h264_ffmpeg.c
++++ b/libfreerdp/codec/h264_ffmpeg.c
+@@ -615,10 +615,12 @@ static BOOL libavcodec_init(H264_CONTEXT* h264)
+ 			goto EXCEPTION;
+ 		}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 		if (sys->codecDecoder->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		{
+ 			sys->codecDecoderContext->flags |= AV_CODEC_FLAG_TRUNCATED;
+ 		}
++#endif
+ 
+ #ifdef WITH_VAAPI
+ 
diff --git a/srcpkgs/freerdp/template b/srcpkgs/freerdp/template
index f36c38ca885b3..97b1d5ea519cd 100644
--- a/srcpkgs/freerdp/template
+++ b/srcpkgs/freerdp/template
@@ -1,7 +1,7 @@
 # Template file for 'freerdp'
 pkgname=freerdp
 version=2.10.0
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DWITH_ALSA=ON -DWITH_CUPS=OFF -DWITH_FFMPEG=ON
  -DWITH_GSTREAMER_0_10=OFF -DWITH_GSTREAMER_1_0=OFF -DWITH_JPEG=ON

From 4c4868bd457bf49b685e5ed657aa7df3444e608a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 031/113] gerbera: revbump for ffmpeg6

---
 srcpkgs/gerbera/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gerbera/template b/srcpkgs/gerbera/template
index ae14f35c767c0..2dc0ac0ce03b5 100644
--- a/srcpkgs/gerbera/template
+++ b/srcpkgs/gerbera/template
@@ -1,7 +1,7 @@
 # Template file for 'gerbera'
 pkgname=gerbera
 version=1.12.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_SYSTEMD=0 -DWITH_AVCODEC=1"
 hostmakedepends="pkg-config"

From 02d1746cde4ab3a2507499322f783022fb97c83a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 032/113] goldendict: revbump for ffmpeg6

---
 srcpkgs/goldendict/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/goldendict/template b/srcpkgs/goldendict/template
index f4a05759f693d..97f44347b03a6 100644
--- a/srcpkgs/goldendict/template
+++ b/srcpkgs/goldendict/template
@@ -1,7 +1,7 @@
 # Template file for 'goldendict'
 pkgname=goldendict
 version=1.5.0
-revision=1
+revision=2
 build_style=qmake
 configure_args="CONFIG+=zim_support goldendict.pro"
 hostmakedepends="qt5-qmake pkg-config qt5-host-tools"
@@ -10,7 +10,7 @@ makedepends="tiff-devel qt5-devel libvorbis-devel zlib-devel
  qt5-webkit-devel lzo-devel bzip2-devel libao-devel qt5-svg-devel
  libeb-devel qt5-x11extras-devel ffmpeg-devel liblzma-devel
  qt5-multimedia-devel"
-short_desc="A feature-rich dictionary lookup program"
+short_desc="Feature-rich dictionary lookup program"
 maintainer="John <me@johnnynator.dev>"
 license="GPL-3.0-or-later"
 homepage="http://goldendict.org/"

From 1de98065b094ec190eb9aea8a936616eb0ba5f14 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 033/113] gst-libav: revbump for ffmpeg6

---
 srcpkgs/gst-libav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index b24be23fc1a6d..0f9350a251bf6 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.22.9
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"

From 98a642cb400b4689b775b255aba155468c8f1c5a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Feb 2024 01:52:46 -0500
Subject: [PATCH 034/113] gst-bad: revbump for ffmpeg6

---
 srcpkgs/gst-plugins-bad1/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index 10dc49f4c151b..87e6922317734 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -27,7 +27,7 @@ makedepends="alsa-lib-devel celt-devel openssl-devel exempi-devel
  fdk-aac-devel flite-devel fluidsynth-devel liblrdf-devel ladspa-sdk
  lilv-devel lv2 libopenjpeg2-devel sbc-devel spandsp-devel vulkan-loader
  Vulkan-Headers webrtc-audio-processing-devel libzbar-devel ffmpeg-devel
- srt-devel libva-devel
+ srt-devel libva-devel oneVPL-devel
  $(vopt_if gme libgme-devel)"
 depends="gst-plugins-base1>=${version}"
 short_desc="GStreamer plugins from the bad set (v1.x)"

From 0341847add986541b3fc2995d754c2e89f4cb280 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 035/113] gst-rtsp-server: revbump for ffmpeg6

---
 srcpkgs/gst-rtsp-server/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index bc2a0dea6ac15..f77026c618eb6 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
 version=1.22.9
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="glib-devel gst-plugins-bad1-devel gobject-introspection

From 5c69031e8c1ea6cc9b8b791f9f4b003be5c6a50d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 036/113] guvcview: update to 2.0.8.

---
 srcpkgs/guvcview/patches/fix-include.patch | 10 ++++++++++
 srcpkgs/guvcview/template                  |  7 +++----
 2 files changed, 13 insertions(+), 4 deletions(-)
 create mode 100644 srcpkgs/guvcview/patches/fix-include.patch

diff --git a/srcpkgs/guvcview/patches/fix-include.patch b/srcpkgs/guvcview/patches/fix-include.patch
new file mode 100644
index 0000000000000..503c2af3b78c1
--- /dev/null
+++ b/srcpkgs/guvcview/patches/fix-include.patch
@@ -0,0 +1,10 @@
+--- a/guvcview/guvcview.c
++++ b/guvcview/guvcview.c
+@@ -28,6 +28,7 @@
+ #include <sys/stat.h>
+ #include <sys/resource.h>
+ #include <errno.h>
++#include <locale.h>
+ 
+ #include "gview.h"
+ #include "gviewv4l2core.h"
diff --git a/srcpkgs/guvcview/template b/srcpkgs/guvcview/template
index d42fd38fa4ad1..86a7fd619612c 100644
--- a/srcpkgs/guvcview/template
+++ b/srcpkgs/guvcview/template
@@ -1,8 +1,7 @@
 # Template file for 'guvcview'
 pkgname=guvcview
-version=2.0.7
-revision=2
-create_wrksrc=yes
+version=2.0.8
+revision=1
 build_style=gnu-configure
 configure_args="--disable-static --disable-debian-menu"
 hostmakedepends="pkg-config intltool autoconf automake libtool glib-devel"
@@ -14,7 +13,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="http://guvcview.sourceforge.net/"
 distfiles="${SOURCEFORGE_SITE}/${pkgname}/${pkgname}-src-${version}.tar.bz2"
-checksum=f47d51fbd06e44eeaa1a82f4a153c927527c90d94514197a70b2956028cc8ad4
+checksum=a21f4e448286666cf27bafef5290cc953a0a1796b752e5bbe521266dc1230c81
 
 post_patch() {
 	sed '31a#include <locale.h>' -i  guvcview/guvcview.c

From 0d46fbecd748a89ff7e9b846353922f559a3559f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 037/113] handbrake: update to 1.6.1

---
 .../patches/fix-missing-x265-link-flag.patch    | 11 ++++++-----
 .../handbrake/patches/libhb-vpl-include.patch   | 15 +++++++++++++++
 srcpkgs/handbrake/template                      | 17 ++++++++++-------
 3 files changed, 31 insertions(+), 12 deletions(-)
 create mode 100644 srcpkgs/handbrake/patches/libhb-vpl-include.patch

diff --git a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
index 26db03867a0c8..d6bb2eda627a3 100644
--- a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
+++ b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
@@ -1,14 +1,15 @@
 --- a/gtk/configure.ac
 +++ b/gtk/configure.ac
 @@ -203,7 +203,7 @@
- 
+
  AM_CONDITIONAL([MINGW], [test "x$mingw_flag" = "xyes"])
- 
--HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg"
-+HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -ldl"
+
+-HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc"
++HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc -ldl"
  HB_CPPFLAGS="$HB_CPPFLAGS $HBINC"
- 
+
  PKG_CHECK_MODULES([x264], [x264], sys_x264=yes, sys_x264=no)
+
 --- a/test/module.defs
 +++ b/test/module.defs
 @@ -69,6 +69,9 @@
diff --git a/srcpkgs/handbrake/patches/libhb-vpl-include.patch b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
new file mode 100644
index 0000000000000..298f9f4ab28f2
--- /dev/null
+++ b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
@@ -0,0 +1,15 @@
+--- a/libhb/module.defs	2023-01-22 11:36:49.000000000 -0500
++++ b/libhb/module.defs	2023-04-03 22:37:52.395467010 -0400
+@@ -46,11 +46,7 @@
+ LIBHB.GCC.I += $(LIBHB.build/) $(CONTRIB.build/)include
+ 
+ ifeq (1,$(FEATURE.qsv))
+-    ifeq ($(HOST.system),freebsd))
+-        LIBHB.GCC.I += $(LOCALBASE)/include/vpl
+-    else
+-        LIBHB.GCC.I += $(CONTRIB.build/)include/vpl
+-    endif
++    LIBHB.GCC.I += /usr/include/vpl
+ endif
+ 
+ ifneq (,$(filter $(HOST.system),freebsd netbsd openbsd))
diff --git a/srcpkgs/handbrake/template b/srcpkgs/handbrake/template
index ca5e4571e49c3..c32cb1bfa31f4 100644
--- a/srcpkgs/handbrake/template
+++ b/srcpkgs/handbrake/template
@@ -1,10 +1,10 @@
 # Template file for 'handbrake'
 pkgname=handbrake
-version=1.5.1
+version=1.6.1
 revision=1
 build_style=gnu-configure
 configure_args="--force --disable-gtk-update-checks --disable-df-fetch --harden
- $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc)"
+ $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc) $(vopt_enable qsv)"
 make_build_args="-C ${XBPS_TRIPLET}"
 make_install_args="-C ${XBPS_TRIPLET}"
 hostmakedepends="automake cmake gettext-devel glib-devel intltool libtool m4 meson nasm pkg-config python3"
@@ -12,8 +12,11 @@ makedepends="bzip2-devel ffmpeg-devel gst-plugins-base1-devel gtk+3-devel
  jansson-devel lame-devel libass-devel libbluray-devel libdav1d-devel
  libdvdnav-devel libdvdread-devel libgudev-devel libnuma-devel
  libsamplerate-devel libtheora-devel libvorbis-devel libvpx-devel libxml2-devel
- opus-devel speex-devel x264-devel x265-devel zimg-devel
+ opus-devel speex-devel x264-devel x265-devel zimg-devel libsvt-av1-devel
  $(vopt_if fdk_aac fdk-aac-devel)
+ $(vopt_if qsv libva-devel)
+ $(vopt_if qsv libdrm-devel)
+ $(vopt_if qsv onevpl-devel)
  $(vopt_if nvenc nv-codec-headers)"
 depends="desktop-file-utils gst-plugins-good1 hicolor-icon-theme"
 short_desc="Multithreaded video transcoder"
@@ -21,15 +24,15 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-2.0-only"
 homepage="https://handbrake.fr/"
 distfiles="https://github.com/HandBrake/HandBrake/releases/download/${version}/HandBrake-${version}-source.tar.bz2"
-checksum=3999fe06d5309c819799a73a968a8ec3840e7840c2b64af8f5cdb7fd8c9430f0
+checksum=94ccfe03db917a91650000c510f7fd53f844da19f19ad4b4be1b8f6bc31a8d4c
 nocross=yes
 
-build_options="fdk_aac nvenc"
+build_options="fdk_aac nvenc qsv"
 
 case "$XBPS_TARGET_MACHINE" in
 	x86_64*|i686*)
 		CFLAGS="-msse"
-		build_options_default="nvenc"
+		build_options_default="nvenc qsv"
 		;;
 esac
 
@@ -37,7 +40,7 @@ pre_configure() {
 	# use system libraries, don't download them
 	rm -rf contrib/
 	for module in fdk-aac ffmpeg libbluray libdav1d libdvdnav libdvdread nvenc \
-		x265 zimg; do
+		x265 zimg svt-av1 libvpl; do
 	    vsed -i "/MODULES += contrib\/${module}/d" make/include/main.defs
 	done
 }

From 8a1e9ab67ce58e64cd2a26398a3216be98606455 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 038/113] hedgewars: revbump for ffmpeg4

---
 srcpkgs/hedgewars/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/hedgewars/template b/srcpkgs/hedgewars/template
index 94b6db673b0c3..402ccfaaecbc2 100644
--- a/srcpkgs/hedgewars/template
+++ b/srcpkgs/hedgewars/template
@@ -1,13 +1,13 @@
 # Template file for 'hedgewars'
 pkgname=hedgewars
 version=1.0.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DNOSERVER=1 -DDATA_INSTALL_DIR=/usr/share/${pkgname}
  -DPHYSFS_SYSTEM=1 -DMINIMAL_FLAGS=1"
 make_cmd=make
 hostmakedepends="lua51 pkg-config qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
+makedepends="ffmpeg4-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
  SDL2_mixer-devel SDL2_net-devel SDL2_ttf-devel"
 depends="libfreeglut"
 short_desc="Funny turn-based artillery game, featuring fighting Hedgehogs!"

From ea990204c74dd2251488f6756d821233e48945ce Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 039/113] idjc: revbump for ffmpeg4

---
 srcpkgs/idjc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/idjc/template b/srcpkgs/idjc/template
index a9cde0665d55b..f41e1e4fabbae 100644
--- a/srcpkgs/idjc/template
+++ b/srcpkgs/idjc/template
@@ -1,11 +1,11 @@
 # Template file for 'idjc'
 pkgname=idjc
 version=0.9.1
-revision=5
+revision=6
 build_style=gnu-configure
 hostmakedepends="pkg-config git python3 automake gettext-devel libtool"
 makedepends="libvorbis-devel libogg-devel jack-devel libsamplerate-devel
- libflac-devel libsndfile-devel mpg123-devel ffmpeg-devel speex-devel
+ libflac-devel libsndfile-devel mpg123-devel ffmpeg4-devel speex-devel
  glib-devel pixman-devel lame-devel python3-gobject-devel libshout-idjc-devel
  opus-devel twolame-devel python3-mutagen python3-devel"
 depends="python3-gobject python3-mutagen desktop-file-utils shared-mime-info python3-dbus jack"

From cb4fb26cd98dae7bd9a37441efa21f666cb8d153 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 040/113] kid3: revbump for ffmpeg6

---
 srcpkgs/kid3/patches/ffmpeg5.patch | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 srcpkgs/kid3/patches/ffmpeg5.patch

diff --git a/srcpkgs/kid3/patches/ffmpeg5.patch b/srcpkgs/kid3/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..135fc50e07c9b
--- /dev/null
+++ b/srcpkgs/kid3/patches/ffmpeg5.patch
@@ -0,0 +1,17 @@
+# https://aur.archlinux.org/cgit/aur.git/diff/ffmpeg5.patch?h=kid3-cli&id=12410a74906612e7efc0ec8fbce739b4a0fef7e7
+diff --git a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+index e156d424..e12b9abd 100644
+--- a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
++++ b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+@@ -232,7 +232,11 @@ private:
+   friend class Format;
+   friend class Converter;
+   AVCodecContext* m_ptr;
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 0, 0)
+   AVCodec* m_impl;
++#else
++  const AVCodec* m_impl;
++#endif
+   AVFrame* m_frame;
+   bool m_opened;
+ };

From 9a89e2f73f6562a334d4774f1d764d97dcd85773 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 041/113] kodi: revbump for ffmpeg4

---
 srcpkgs/kodi/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/kodi/template b/srcpkgs/kodi/template
index d37a5918cd675..ea78e0aca0fe3 100644
--- a/srcpkgs/kodi/template
+++ b/srcpkgs/kodi/template
@@ -1,7 +1,7 @@
 # Template file for 'kodi'
 pkgname=kodi
 version=19.4
-revision=9
+revision=10
 _codename="Matrix"
 build_style=cmake
 configure_args="-DWITH_FFMPEG=/usr -DENABLE_LDGOLD=OFF
@@ -54,7 +54,7 @@ makedepends="
  libmad-devel fontconfig-devel libXinerama-devel libsamplerate-devel libmms-devel
  enca-devel boost-devel libcurl-devel libva-devel libvdpau-devel libass-devel
  libbluetooth-devel yajl-devel libplist-devel librtmp-devel tinyxml-devel
- taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg-devel
+ taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg4-devel
  giflib-devel libxslt-devel gnutls-devel libssh-devel libmicrohttpd-devel
  libcec-devel dcadec-devel flatbuffers-devel fmt-devel lcms2-devel
  libfstrcmp-devel rapidjson libcdio-paranoia spdlog libwaylandpp-devel

From df2d9eaa4d8e381678ff8040da2bd1c8ad4053e1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 042/113] kpipewire: revbump for ffmpeg6

---
 srcpkgs/kpipewire/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kpipewire/template b/srcpkgs/kpipewire/template
index 6214a4451336e..3555348659dde 100644
--- a/srcpkgs/kpipewire/template
+++ b/srcpkgs/kpipewire/template
@@ -1,7 +1,7 @@
 # Template file for 'kpipewire'
 pkgname=kpipewire
 version=5.27.10
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules plasma-wayland-protocols gettext
  qt5-qmake qt5-host-tools pkg-config wayland-devel kcoreaddons

From 8bca913c14769451e814b580181b1fef3897b4c4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 043/113] libextractor: revbump for ffmpeg4

---
 srcpkgs/libextractor/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/libextractor/template b/srcpkgs/libextractor/template
index 044c663a3a0b9..06e63bc3189d5 100644
--- a/srcpkgs/libextractor/template
+++ b/srcpkgs/libextractor/template
@@ -1,13 +1,13 @@
 # Template file for 'libextractor'
 pkgname=libextractor
 version=1.11
-revision=4
+revision=5
 build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="pkg-config"
 makedepends="zlib-devel bzip2-devel exiv2-devel tiff-devel libpng-devel
  libjpeg-turbo-devel libvorbis-devel libflac-devel giflib-devel libmpeg2-devel
- ffmpeg-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
+ ffmpeg4-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
 short_desc="Library used to extract meta data from files"
 maintainer="Martin Riese <grauehaare@gmx.de>"
 license="GPL-3.0-or-later"

From 653a6bf6b34403007fcc02e80b889cf1e4a23c51 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 044/113] libopenal: revbump for ffmpeg6

---
 srcpkgs/libopenal/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenal/template b/srcpkgs/libopenal/template
index 88d0f11307d81..8308fca0393e3 100644
--- a/srcpkgs/libopenal/template
+++ b/srcpkgs/libopenal/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenal'
 pkgname=libopenal
 version=1.23.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DALSOFT_EXAMPLES=OFF"
 hostmakedepends="pkg-config"

From f039de5a582ed31dca32827291ecefe95855ef72 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 045/113] loudgain: revbump for ffmpeg6

---
 srcpkgs/loudgain/patches/ffmpeg5.patch | 11 +++++++++++
 srcpkgs/loudgain/template              |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/loudgain/patches/ffmpeg5.patch

diff --git a/srcpkgs/loudgain/patches/ffmpeg5.patch b/srcpkgs/loudgain/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..16d4510ee98fa
--- /dev/null
+++ b/srcpkgs/loudgain/patches/ffmpeg5.patch
@@ -0,0 +1,11 @@
+--- a/src/scan.c	2019-09-06 11:31:19.000000000 -0400
++++ b/src/scan.c	2023-03-23 11:15:40.867968521 -0400
+@@ -69,8 +69,6 @@
+ 	 * It is now useless
+ 	 * https://github.com/FFmpeg/FFmpeg/blob/70d25268c21cbee5f08304da95be1f647c630c15/doc/APIchanges#L86
+ 	 */
+-  if (avformat_version() < AV_VERSION_INT(58,9,100))
+-    av_register_all();
+ 
+ 	av_log_set_callback(scan_av_log);
+ 
diff --git a/srcpkgs/loudgain/template b/srcpkgs/loudgain/template
index da4f2d56e94c3..4d6bf29efb4fd 100644
--- a/srcpkgs/loudgain/template
+++ b/srcpkgs/loudgain/template
@@ -1,7 +1,7 @@
 # Template file for 'loudgain'
 pkgname=loudgain
 version=0.6.8
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libebur128-devel taglib-devel ffmpeg-devel"

From db07e4cb3ebbe85419aa5d14ba8aaa2fdc558f3e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 046/113] mediastreamer: revbump for ffmpeg4

---
 srcpkgs/mediastreamer/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mediastreamer/template b/srcpkgs/mediastreamer/template
index 0fcffa7653d18..e888626b945e5 100644
--- a/srcpkgs/mediastreamer/template
+++ b/srcpkgs/mediastreamer/template
@@ -1,11 +1,11 @@
 # Template file for 'mediastreamer'
 pkgname=mediastreamer
 version=5.2.111
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DENABLE_STRICT=0 -DENABLE_UNIT_TESTS=0"
 hostmakedepends="python3"
-makedepends="bzrtp-devel ffmpeg-devel glew-devel libXv-devel libsrtp-devel
+makedepends="bzrtp-devel ffmpeg4-devel glew-devel libXv-devel libsrtp-devel
  libupnp-devel libvpx-devel mbedtls-devel opus-devel ortp-devel pulseaudio-devel
  libtheora-devel speex-devel v4l-utils-devel bcg729-devel bcmatroska2-devel libgsm-devel
  zxing-cpp-devel"

From d45325fcc479b1e9d1d334700b39ca6bab273a5f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 047/113] mgba: revbump for ffmpeg6

---
 srcpkgs/mgba/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mgba/template b/srcpkgs/mgba/template
index 6cd6565031254..93401adb618bd 100644
--- a/srcpkgs/mgba/template
+++ b/srcpkgs/mgba/template
@@ -1,7 +1,7 @@
 # Template file for 'mgba'
 pkgname=mgba
 version=0.10.3
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake desktop-file-utils"
 makedepends="SDL2-devel ffmpeg-devel libedit-devel libepoxy-devel libmagick-devel

From f5f837952ed8ff22b6a550d8c6aea41b6e148395 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 048/113] mlt: revbump for ffmpeg4

---
 srcpkgs/mlt/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mlt/template b/srcpkgs/mlt/template
index 73e3915aaab9a..d7ed4c4b30a86 100644
--- a/srcpkgs/mlt/template
+++ b/srcpkgs/mlt/template
@@ -1,14 +1,14 @@
 # Template file for 'mlt'
 pkgname=mlt
 version=6.26.1
-revision=3
+revision=4
 build_style=configure
 configure_args="--prefix=/usr --libdir=/usr/lib$XBPS_TARGET_WORDSIZE
  --enable-gpl --enable-gpl3 --disable-swfdec --without-kde
  --swig-languages=python"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which"
 # XXX: movit vid.stab
-makedepends="alsa-lib-devel ffmpeg-devel gtk+-devel jack-devel ladspa-sdk
+makedepends="alsa-lib-devel ffmpeg4-devel gtk+-devel jack-devel ladspa-sdk
  libexif-devel libsamplerate-devel libxml2-devel sox-devel SDL_image-devel
  fftw-devel frei0r-plugins python3-devel pulseaudio-devel movit-devel
  libvidstab-devel"

From 5f1f3b2583c151607cc5e2efa7f95df326e5ae86 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 049/113] moc: revbump for ffmpeg4

---
 srcpkgs/moc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/moc/template b/srcpkgs/moc/template
index 3a04932c8f1e6..838755f88db09 100644
--- a/srcpkgs/moc/template
+++ b/srcpkgs/moc/template
@@ -1,10 +1,10 @@
 # Template file for 'moc'
 pkgname=moc
 version=2.5.2
-revision=7
+revision=8
 build_style=gnu-configure
 hostmakedepends="pkg-config"
-makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg-devel
+makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg4-devel
  jack-devel alsa-lib-devel libltdl-devel libflac-devel libvorbis-devel
  libmad-devel libmpcdec-devel libmodplug-devel libid3tag-devel faad2-devel
  taglib-devel libsndfile-devel wavpack-devel speex-devel libsamplerate-devel

From ff552267817a3e64452cda24b55f3791c26a2240 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 050/113] motion: revbump for ffmpeg6

---
 srcpkgs/motion/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/motion/template b/srcpkgs/motion/template
index 607ebeb3c7b24..bf63a91d9764f 100644
--- a/srcpkgs/motion/template
+++ b/srcpkgs/motion/template
@@ -1,7 +1,7 @@
 # Template file for 'motion'
 pkgname=motion
 version=4.6.0
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake pkg-config gettext-devel tar"
 makedepends="ffmpeg-devel libmicrohttpd-devel v4l-utils-devel gettext-devel"

From bd3e95906afd080e2fc11dfc87f8bed3f2050aff Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 051/113] olive: revbump for ffmpeg4

---
 srcpkgs/olive/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/olive/template b/srcpkgs/olive/template
index 12a46936c9900..5c2917b9c5124 100644
--- a/srcpkgs/olive/template
+++ b/srcpkgs/olive/template
@@ -1,10 +1,10 @@
 # Template file for 'olive'
 pkgname=olive
 version=0.1.2
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools pkg-config"
-makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg-devel frei0r-plugins"
+makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg4-devel frei0r-plugins"
 short_desc="Non-linear video editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"

From 5c2e07d94bd16a829e00cb315d2be3af662e5560 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 052/113] opentoonz: revbump for ffmpeg6

---
 srcpkgs/opentoonz/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/opentoonz/template b/srcpkgs/opentoonz/template
index ee9f7603f55fd..3e81834ca0edd 100644
--- a/srcpkgs/opentoonz/template
+++ b/srcpkgs/opentoonz/template
@@ -1,7 +1,7 @@
 # Template file for 'opentoonz'
 pkgname=opentoonz
 version=1.6.0
-revision=2
+revision=3
 build_wrksrc="toonz/sources"
 build_style=cmake
 make_cmd=make

From 4b8703e0747addf2a7fa9e01c34f6810504d6e12 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 053/113] pianobar: revbump for ffmpeg6

---
 srcpkgs/pianobar/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pianobar/template b/srcpkgs/pianobar/template
index e3febb821a451..1e3dc1bf9308e 100644
--- a/srcpkgs/pianobar/template
+++ b/srcpkgs/pianobar/template
@@ -1,7 +1,7 @@
 # Template file for 'pianobar'
 pkgname=pianobar
 version=2022.04.01
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="V=1"
 hostmakedepends="pkg-config"

From 8a95b0b9d4d90e7ecf20283ba8852b9c024c3ed7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 054/113] ppsspp: revbump for ffmpeg6

---
 srcpkgs/ppsspp/patches/ffmpeg6.patch | 15 +++++++++++++++
 srcpkgs/ppsspp/template              |  3 +--
 2 files changed, 16 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/ppsspp/patches/ffmpeg6.patch

diff --git a/srcpkgs/ppsspp/patches/ffmpeg6.patch b/srcpkgs/ppsspp/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..5803c7bf22730
--- /dev/null
+++ b/srcpkgs/ppsspp/patches/ffmpeg6.patch
@@ -0,0 +1,15 @@
+--- a/Core/HW/SimpleAudioDec.cpp	2024-02-04 08:08:02.000000000 -0500
++++ b/Core/HW/SimpleAudioDec.cpp	2024-02-15 14:48:27.114362051 -0500
+@@ -81,7 +81,11 @@
+ 		return;
+ 	}
+ 	// Find decoder
++#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(58, 18, 100)
+ 	codec_ = avcodec_find_decoder((AVCodecID)audioCodecId);
++#else // this is a macro to const in the header
++	codec_ = (AVCodec*)avcodec_find_decoder((AVCodecID)audioCodecId);
++#endif
+ 	if (!codec_) {
+ 		// Eh, we shouldn't even have managed to compile. But meh.
+ 		ERROR_LOG(ME, "This version of FFMPEG does not support AV_CODEC_ctx for audio (%s). Update your submodule.", GetCodecName(audioType));
+
diff --git a/srcpkgs/ppsspp/template b/srcpkgs/ppsspp/template
index 2238a7601c0af..1fda55268a2d3 100644
--- a/srcpkgs/ppsspp/template
+++ b/srcpkgs/ppsspp/template
@@ -1,7 +1,7 @@
 # Template file for 'ppsspp'
 pkgname=ppsspp
 version=1.17.1
-revision=1
+revision=2
 _glslang_commit=b34f619e1c85810dcb3c578107d2e48ba4ee2b37
 _SPIRV_Cross_commit=4212eef67ed0ca048cb726a6767185504e7695e5
 _armips_commit=a8d71f0f279eb0d30ecf6af51473b66ae0cf8e8d
@@ -91,7 +91,6 @@ post_configure() {
 }
 
 do_install() {
-	vlicense LICENSE.TXT
 	vinstall icons/icon.svg 644 usr/share/pixmaps ppsspp.svg
 	vinstall Qt/PPSSPP.desktop 644 usr/share/applications
 	vbin build/PPSSPPHeadless ppsspp-headless

From 78c966f8d01cad97b8cd439ab1fad134ffbded9b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 055/113] pqiv: revbump for ffmpeg6

---
 srcpkgs/pqiv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pqiv/template b/srcpkgs/pqiv/template
index 542fc27a2d32a..9308d949b6a1c 100644
--- a/srcpkgs/pqiv/template
+++ b/srcpkgs/pqiv/template
@@ -1,7 +1,7 @@
 # Template file for 'pqiv'
 pkgname=pqiv
 version=2.12
-revision=1
+revision=2
 build_style=gnu-makefile
 hostmakedepends="pkg-config"
 makedepends="glib-devel gtk+3-devel $(vopt_if ffmpeg ffmpeg-devel)

From af64ac1f0feb9a647a2f174ec539cc0644d236f4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 056/113] qmmp: revbump for ffmpeg6

---
 srcpkgs/qmmp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qmmp/template b/srcpkgs/qmmp/template
index 53781ea3bc28a..2da07f1e87eac 100644
--- a/srcpkgs/qmmp/template
+++ b/srcpkgs/qmmp/template
@@ -1,7 +1,7 @@
 # Template file for 'qmmp'
 pkgname=qmmp
 version=1.6.1
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DUSE_HAL:BOOL=FALSE -DQMMP_DEFAULT_UI:STRING=simple"
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From 5a8801377831ddde8c4afff585b6152e5f743fdb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 14 Dec 2023 13:28:10 -0500
Subject: [PATCH 057/113] qt6-pdf: revbump for ffmpeg6

---
 srcpkgs/qt6-pdf/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-pdf/template b/srcpkgs/qt6-pdf/template
index ecda84afac131..531b4e1d4fe84 100644
--- a/srcpkgs/qt6-pdf/template
+++ b/srcpkgs/qt6-pdf/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-pdf'
 pkgname=qt6-pdf
 version=6.6.0
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DQT_FEATURE_qtpdf_build=ON
  -DQT_FEATURE_qtpdf_widgets_build=ON

From 7529c23d6c9af14526bd6cc58ad22a019fff4fea Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 058/113] qt5-webengine: revbump for ffmpeg6

---
 .../chromium-media-filters-cpp14.patch        |  11 ++
 srcpkgs/qt5-webengine/patches/ffmpeg5.patch   | 179 ++++++++++++++++++
 .../qtwebengine-fix-ffmpeg5-build.patch       |  14 ++
 srcpkgs/qt5-webengine/template                |   4 +-
 4 files changed, 206 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/ffmpeg5.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch

diff --git a/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
new file mode 100644
index 0000000000000..04adc540f2cbc
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
@@ -0,0 +1,11 @@
+--- a/src/3rdparty/chromium/media/filters/BUILD.gn	2023-02-27 13:32:59.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/BUILD.gn	2023-04-02 17:21:39.204066384 -0400
+@@ -96,6 +96,8 @@
+     "//ui/gfx/geometry:geometry",
+   ]
+ 
++  cflags_cc = [ "-std=c++14" ]
++
+   libs = []
+ 
+   if (proprietary_codecs) {
diff --git a/srcpkgs/qt5-webengine/patches/ffmpeg5.patch b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..ac55e1634423a
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
@@ -0,0 +1,179 @@
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:57.732547446 -0400
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:09.486478995 -0400
+@@ -57,6 +57,8 @@
+ 
+ namespace {
+ 
++constexpr int64_t kRelativeTsBase = static_cast<int64_t>(0x7ffeffffffffffff);
++
+ void SetAVStreamDiscard(AVStream* stream, AVDiscard discard) {
+   DCHECK(stream);
+   stream->discard = discard;
+@@ -90,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+   if (stream->start_time != kNoFFmpegTimestamp)
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (stream->first_dts != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, stream->first_dts);
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -408,11 +398,11 @@
+   scoped_refptr<DecoderBuffer> buffer;
+ 
+   if (type() == DemuxerStream::TEXT) {
+-    int id_size = 0;
++    size_t id_size = 0;
+     uint8_t* id_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
+ 
+-    int settings_size = 0;
++    size_t settings_size = 0;
+     uint8_t* settings_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
+ 
+@@ -424,7 +414,7 @@
+     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
+                                      side_data.data(), side_data.size());
+   } else {
+-    int side_data_size = 0;
++    size_t side_data_size = 0;
+     uint8_t* side_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
+ 
+@@ -485,7 +475,7 @@
+                                        packet->size - data_offset);
+     }
+ 
+-    int skip_samples_size = 0;
++    size_t skip_samples_size = 0;
+     const uint32_t* skip_samples_ptr =
+         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
+             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
+@@ -1587,6 +1577,8 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++      continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+       lowest_start_time_stream = stream.get();
+@@ -1604,6 +1596,8 @@
+     if (stream && stream->type() == DemuxerStream::VIDEO &&
+         stream->IsEnabled()) {
+       video_stream = stream.get();
++      if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++        continue;
+       if (video_stream->start_time() <= seek_time) {
+         return video_stream;
+       }
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h qtwebengine-5.15.10/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h
+--- a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-07-11 22:12:47.917192788 -0500
+@@ -29,6 +29,7 @@ extern "C" {
+ #include <libavformat/avformat.h>
+ #include <libavformat/avio.h>
+ #include <libavutil/avutil.h>
++#include <libavutil/channel_layout.h>
+ #include <libavutil/imgutils.h>
+ #include <libavutil/log.h>
+ #include <libavutil/mastering_display_metadata.h>
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/audio_file_reader.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/audio_file_reader.cc
+--- a/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -85,7 +85,7 @@ bool AudioFileReader::OpenDemuxer() {
+ }
+ 
+ bool AudioFileReader::OpenDecoder() {
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (codec) {
+     // MP3 decodes to S16P which we don't support, tell it to use S16 instead.
+     if (codec_context_->sample_fmt == AV_SAMPLE_FMT_S16P)
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -329,7 +329,7 @@ bool FFmpegAudioDecoder::ConfigureDecode
+     }
+   }
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec ||
+       avcodec_open2(codec_context_.get(), codec, &codec_options) < 0) {
+     DLOG(ERROR) << "Could not initialize audio decoder: "
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -59,7 +59,6 @@ static int64_t AVIOSeekOperation(void* o
+ }
+ 
+ void FFmpegGlue::InitializeFFmpeg() {
+-  av_register_all();
+ }
+ 
+ static void LogContainer(bool is_local_file,
+@@ -95,9 +94,6 @@ FFmpegGlue::FFmpegGlue(FFmpegURLProtocol
+   // Enable fast, but inaccurate seeks for MP3.
+   format_context_->flags |= AVFMT_FLAG_FAST_SEEK;
+ 
+-  // Ensures we can read out various metadata bits like vp8 alpha.
+-  format_context_->flags |= AVFMT_FLAG_KEEP_SIDE_DATA;
+-
+   // Ensures format parsing errors will bail out. From an audit on 11/2017, all
+   // instances were real failures. Solves bugs like http://crbug.com/710791.
+   format_context_->error_recognition |= AV_EF_EXPLODE;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -391,7 +391,7 @@ bool FFmpegVideoDecoder::ConfigureDecode
+   if (decode_nalus_)
+     codec_context_->flags2 |= AV_CODEC_FLAG2_CHUNKS;
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
+     ReleaseFFmpegResources();
+     return false;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/media_file_checker.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/media_file_checker.cc
+--- a/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -68,7 +68,7 @@ bool MediaFileChecker::Start(base::TimeD
+       auto context = AVStreamToAVCodecContext(format_context->streams[i]);
+       if (!context)
+         continue;
+-      AVCodec* codec = avcodec_find_decoder(cp->codec_id);
++      const AVCodec* codec = avcodec_find_decoder(cp->codec_id);
+       if (codec && avcodec_open2(context.get(), codec, nullptr) >= 0) {
+         auto loop = std::make_unique<FFmpegDecodingLoop>(context.get());
+         stream_contexts[i] = {std::move(context), std::move(loop)};
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc qtwebengine-5.15.10/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc
+--- a/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -203,7 +203,7 @@ int32_t H264DecoderImpl::InitDecode(cons
+   // a pointer |this|.
+   av_context_->opaque = this;
+ 
+-  AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
+   if (!codec) {
+     // This is an indication that FFmpeg has not been initialized or it has not
+     // been compiled/initialized with the correct set of codecs.
diff --git a/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch b/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch
new file mode 100644
index 0000000000000..bc24d5b9a29cb
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch
@@ -0,0 +1,14 @@
+--- a/src/buildtools/configure.json	2023-12-09 11:06:01.503058569 -0500
++++ b/src/buildtools/configure.json	2023-12-09 11:06:14.982361345 -0500
+@@ -779,11 +779,6 @@
+             "type": "warning",
+             "condition": "config.ios && config.simulator && config.device && features.build-qtpdf",
+             "message": "Building fat libray with device and simulator architectures will disable NEON."
+-        },
+-        {
+-            "type": "fatal",
+-            "condition": "features.webengine-system-ffmpeg && !libs.webengine-ffmpeg-support",
+-            "message": "Unmodified ffmpeg >= 5.0 is not supported. Please configure with -qt-webengine-ffmpeg."
+         }
+     ],
+     "summary": [
diff --git a/srcpkgs/qt5-webengine/template b/srcpkgs/qt5-webengine/template
index 8d2df1b5175ba..1687a77eb8a2f 100644
--- a/srcpkgs/qt5-webengine/template
+++ b/srcpkgs/qt5-webengine/template
@@ -1,14 +1,14 @@
 # Template file for 'qt5-webengine'
 pkgname=qt5-webengine
 version=5.15.16
-revision=1
+revision=2
 _version="${version}-lts"
 _chromium_commit=207c2ac45ca3386d153770c6b0d2ea2ec21ca880
 archs="x86_64* i686* armv[67]* ppc64* aarch64*"
 create_wrksrc=yes
 build_style=qmake
 configure_args="--
- -webengine-icu -webengine-ffmpeg -webengine-opus -webengine-webp
+ -webengine-icu -system-ffmpeg -webengine-opus -webengine-webp
  -webengine-pepper-plugins -webengine-printing-and-pdf -webengine-proprietary-codecs
  -webengine-pulseaudio -webengine-spellchecker -webengine-webrtc -webengine-geolocation
  -webengine-kerberos -no-webengine-embedded-build $(vopt_if sndio '' '-no')-webengine-sndio

From 5c0ffda9f5b23d725dd909002eea4b47fe93167c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 059/113] qt5: revbump for ffmpeg6

---
 srcpkgs/qt5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5/template b/srcpkgs/qt5/template
index 3efb7e42d5fd3..27f6d5388cd15 100644
--- a/srcpkgs/qt5/template
+++ b/srcpkgs/qt5/template
@@ -3,9 +3,9 @@
 # revbump libqtxdg after bumping patch version
 pkgname=qt5
 version=5.15.11+20231124
+revision=3
 # commit 4765fa1df7a837db9c1f89c4da0dd76b74bb5fab
 # base repo: https://invent.kde.org/qt/qt/qt5
-revision=2
 build_style=meta
 hostmakedepends="cmake clang17 flex perl glib-devel pkg-config
  python3 re2c ruby which"

From f5c7e05f8a4be901f36c633aa10fa146d9fd4542 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 060/113] qtav: revbump for ffmpeg4

---
 srcpkgs/qtav/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtav/template b/srcpkgs/qtav/template
index 775d5a139a9ef..aa69e213c984b 100644
--- a/srcpkgs/qtav/template
+++ b/srcpkgs/qtav/template
@@ -1,10 +1,10 @@
 # Template file for 'qtav'
 pkgname=qtav
 version=1.13.0
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel libass-devel libopenal-devel
+makedepends="ffmpeg4-devel libass-devel libopenal-devel
  libva-glx-devel libXv-devel pulseaudio-devel
  qt5-declarative-devel qt5-svg-devel
  qt5-quickcontrols"

From 50c087811e7a1cd00b51050ed5e372440d288f63 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 061/113] retroarch: revbump for ffmpeg6

---
 srcpkgs/retroarch/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroarch/template b/srcpkgs/retroarch/template
index cb3125c5dbf1a..c65c26f7bf033 100644
--- a/srcpkgs/retroarch/template
+++ b/srcpkgs/retroarch/template
@@ -1,7 +1,7 @@
 # Template file for 'retroarch'
 pkgname=retroarch
 version=1.16.0.3
-revision=3
+revision=4
 build_style=configure
 configure_args="--prefix=/usr --sysconfdir=/etc --enable-networking
  --enable-udev --disable-builtinflac --disable-builtinglslang

From c2c7c99fd1a54ca1957c709ad22e36adb923eccd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 062/113] scrcpy: revbump for ffmpeg6

---
 srcpkgs/scrcpy/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/scrcpy/template b/srcpkgs/scrcpy/template
index d04de770dc191..5218fa01f8ce1 100644
--- a/srcpkgs/scrcpy/template
+++ b/srcpkgs/scrcpy/template
@@ -1,7 +1,7 @@
 # Template file for 'scrcpy'
 pkgname=scrcpy
 version=2.3.1
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcompile_server=false
  -Dprebuilt_server=/usr/share/scrcpy/scrcpy-server-v${version}"

From d1f3a22ff49838082a1393f657edb8918e8fd40a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 17 Oct 2023 08:54:11 -0400
Subject: [PATCH 063/113] New package: spex-x replaces spek-alternative for
 ffmpeg6

---
 srcpkgs/spek-alternative                      |  1 +
 srcpkgs/{spek-alternative => spek-x}/template | 22 ++++++++++++-------
 2 files changed, 15 insertions(+), 8 deletions(-)
 create mode 120000 srcpkgs/spek-alternative
 rename srcpkgs/{spek-alternative => spek-x}/template (52%)

diff --git a/srcpkgs/spek-alternative b/srcpkgs/spek-alternative
new file mode 120000
index 0000000000000..76648236da701
--- /dev/null
+++ b/srcpkgs/spek-alternative
@@ -0,0 +1 @@
+spek-x
\ No newline at end of file
diff --git a/srcpkgs/spek-alternative/template b/srcpkgs/spek-x/template
similarity index 52%
rename from srcpkgs/spek-alternative/template
rename to srcpkgs/spek-x/template
index d7b55c776b1d4..3ded6c2c323e4 100644
--- a/srcpkgs/spek-alternative/template
+++ b/srcpkgs/spek-x/template
@@ -1,18 +1,18 @@
-# Template file for 'spek-alternative'
-pkgname=spek-alternative
-version=0.8.2.3
-revision=2
+# Template file for 'spek-x'
+pkgname=spek-x
+version=0.9.3
+revision=1
 build_style=gnu-configure
 hostmakedepends="automake gettext-devel intltool libtool pkg-config
  wxWidgets-common wxWidgets-gtk3-devel"
 makedepends="ffmpeg-devel wxWidgets-gtk3-devel"
 depends="ffmpeg"
 short_desc="Acoustic spectrum analyser"
-maintainer="Kartik Singh <kartik.ynwa@gmail.com>"
+maintainer="zlice <zlice555@gmail.com>"
 license="GPL-3.0-or-later"
-homepage="https://github.com/withmorten/spek-alternative"
-distfiles="https://github.com/withmorten/spek-alternative/archive/${version}.tar.gz"
-checksum="007ba4b84a310b078e378aa84c8e80783db5821437a757a488c3ecec377e6b2a"
+homepage="https://github.com/MikeWang000000/spek-x"
+distfiles="https://github.com/MikeWang000000/spek-x/archive/v${version}.tar.gz"
+checksum="7f4b109903333cdd310ab2b9176f0dc49a565891376e281a233d342cedf90ef7"
 
 CXXFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
 
@@ -22,3 +22,9 @@ export WX_CONFIG_NAME="wx-config-gtk3"
 pre_configure() {
 	NOCONFIGURE=1 ./autogen.sh
 }
+
+spek-alternative_package() {
+	depends="spek-x"
+	short_desc+=" - transitional dummy package"
+	build_style=meta
+}

From 01642f76a7557c16bd6c919affba7e6fb7909482 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 064/113] ssr: revbump for ffmpeg6

---
 .../0001-Fix-build-with-ffmpeg-5.0.patch      | 241 ++++++++++++++++++
 srcpkgs/ssr/template                          |   2 +-
 2 files changed, 242 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ssr/patches/0001-Fix-build-with-ffmpeg-5.0.patch

diff --git a/srcpkgs/ssr/patches/0001-Fix-build-with-ffmpeg-5.0.patch b/srcpkgs/ssr/patches/0001-Fix-build-with-ffmpeg-5.0.patch
new file mode 100644
index 0000000000000..4c069b5a9fc46
--- /dev/null
+++ b/srcpkgs/ssr/patches/0001-Fix-build-with-ffmpeg-5.0.patch
@@ -0,0 +1,241 @@
+From f4cbde38021d9330dc73d2e3dfa8a70da3ff5721 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Bernhard=20Rosenkr=C3=A4nzer?= <bero@lindev.ch>
+Date: Sun, 16 Jan 2022 02:40:04 +0100
+Subject: [PATCH] Fix build with ffmpeg 5.0
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Adapt to ffmpeg 5.0 requiring more const-ness for AVCodec.
+
+Signed-off-by: Bernhard Rosenkränzer <bero@lindev.ch>
+---
+ src/AV/Output/AudioEncoder.cpp |  6 +++---
+ src/AV/Output/AudioEncoder.h   |  4 ++--
+ src/AV/Output/BaseEncoder.cpp  |  4 ++--
+ src/AV/Output/BaseEncoder.h    |  4 ++--
+ src/AV/Output/Muxer.cpp        | 12 ++++++------
+ src/AV/Output/Muxer.h          |  4 ++--
+ src/AV/Output/VideoEncoder.cpp |  6 +++---
+ src/AV/Output/VideoEncoder.h   |  4 ++--
+ 8 files changed, 22 insertions(+), 22 deletions(-)
+
+diff --git a/src/AV/Output/AudioEncoder.cpp b/src/AV/Output/AudioEncoder.cpp
+index 34d015c..cefc2e0 100644
+--- a/src/AV/Output/AudioEncoder.cpp
++++ b/src/AV/Output/AudioEncoder.cpp
+@@ -34,7 +34,7 @@ const std::vector<AudioEncoder::SampleFormatData> AudioEncoder::SUPPORTED_SAMPLE
+ 
+ const unsigned int AudioEncoder::DEFAULT_FRAME_SAMPLES = 1024;
+ 
+-AudioEncoder::AudioEncoder(Muxer* muxer, AVStream* stream, AVCodecContext *codec_context, AVCodec* codec, AVDictionary** options)
++AudioEncoder::AudioEncoder(Muxer* muxer, AVStream* stream, AVCodecContext *codec_context, const AVCodec* codec, AVDictionary** options)
+ 	: BaseEncoder(muxer, stream, codec_context, codec, options) {
+ 
+ #if !SSR_USE_AVCODEC_ENCODE_AUDIO2
+@@ -77,7 +77,7 @@ unsigned int AudioEncoder::GetSampleRate() {
+ }
+ 
+ bool AudioEncoder::AVCodecIsSupported(const QString& codec_name) {
+-	AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
++	const AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
+ 	if(codec == NULL)
+ 		return false;
+ 	if(!av_codec_is_encoder(codec))
+@@ -93,7 +93,7 @@ bool AudioEncoder::AVCodecIsSupported(const QString& codec_name) {
+ 	return false;
+ }
+ 
+-void AudioEncoder::PrepareStream(AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
++void AudioEncoder::PrepareStream(AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
+ 								 unsigned int bit_rate, unsigned int channels, unsigned int sample_rate) {
+ 
+ 	if(channels == 0) {
+diff --git a/src/AV/Output/AudioEncoder.h b/src/AV/Output/AudioEncoder.h
+index c93278c..ae9c82e 100644
+--- a/src/AV/Output/AudioEncoder.h
++++ b/src/AV/Output/AudioEncoder.h
+@@ -40,7 +40,7 @@ private:
+ #endif
+ 
+ public:
+-	AudioEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options);
++	AudioEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options);
+ 	~AudioEncoder();
+ 
+ 	// Returns the required frame size, i.e. the number of samples (for each channel).
+@@ -57,7 +57,7 @@ public:
+ 
+ public:
+ 	static bool AVCodecIsSupported(const QString& codec_name);
+-	static void PrepareStream(AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
++	static void PrepareStream(AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
+ 							  unsigned int bit_rate, unsigned int channels, unsigned int sample_rate);
+ 
+ private:
+diff --git a/src/AV/Output/BaseEncoder.cpp b/src/AV/Output/BaseEncoder.cpp
+index 7c01ef3..4780aaf 100644
+--- a/src/AV/Output/BaseEncoder.cpp
++++ b/src/AV/Output/BaseEncoder.cpp
+@@ -42,7 +42,7 @@ double ParseCodecOptionDouble(const QString& key, const QString& value, double m
+ 	return clamp(value_double, min, max) * multiply;
+ }
+ 
+-BaseEncoder::BaseEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options) {
++BaseEncoder::BaseEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options) {
+ 
+ 	m_muxer = muxer;
+ 	m_stream = stream;
+@@ -157,7 +157,7 @@ void BaseEncoder::IncrementPacketCounter() {
+ 	++lock->m_total_packets;
+ }
+ 
+-void BaseEncoder::Init(AVCodec* codec, AVDictionary** options) {
++void BaseEncoder::Init(const AVCodec* codec, AVDictionary** options) {
+ 
+ 	// open codec
+ 	if(avcodec_open2(m_codec_context, codec, options) < 0) {
+diff --git a/src/AV/Output/BaseEncoder.h b/src/AV/Output/BaseEncoder.h
+index 3d92f29..7f02bbd 100644
+--- a/src/AV/Output/BaseEncoder.h
++++ b/src/AV/Output/BaseEncoder.h
+@@ -51,7 +51,7 @@ private:
+ 	std::atomic<bool> m_should_stop, m_should_finish, m_is_done, m_error_occurred;
+ 
+ protected:
+-	BaseEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options);
++	BaseEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options);
+ 
+ public:
+ 	virtual ~BaseEncoder(); // encoders will be deleted by Muxer, don't delete them yourself!
+@@ -117,7 +117,7 @@ protected:
+ 	void IncrementPacketCounter();
+ 
+ private:
+-	void Init(AVCodec* codec, AVDictionary** options);
++	void Init(const AVCodec* codec, AVDictionary** options);
+ 	void Free();
+ 
+ 	void EncoderThread();
+diff --git a/src/AV/Output/Muxer.cpp b/src/AV/Output/Muxer.cpp
+index ad58380..14650b0 100644
+--- a/src/AV/Output/Muxer.cpp
++++ b/src/AV/Output/Muxer.cpp
+@@ -87,7 +87,7 @@ Muxer::~Muxer() {
+ 
+ VideoEncoder* Muxer::AddVideoEncoder(const QString& codec_name, const std::vector<std::pair<QString, QString> >& codec_options,
+ 									 unsigned int bit_rate, unsigned int width, unsigned int height, unsigned int frame_rate) {
+-	AVCodec *codec = FindCodec(codec_name);
++	const AVCodec *codec = FindCodec(codec_name);
+ 	AVCodecContext *codec_context = NULL;
+ 	AVStream *stream = AddStream(codec, &codec_context);
+ 	VideoEncoder *encoder;
+@@ -111,7 +111,7 @@ VideoEncoder* Muxer::AddVideoEncoder(const QString& codec_name, const std::vecto
+ 
+ AudioEncoder* Muxer::AddAudioEncoder(const QString& codec_name, const std::vector<std::pair<QString, QString> >& codec_options,
+ 									 unsigned int bit_rate, unsigned int channels, unsigned int sample_rate) {
+-	AVCodec *codec = FindCodec(codec_name);
++	const AVCodec *codec = FindCodec(codec_name);
+ 	AVCodecContext *codec_context = NULL;
+ 	AVStream *stream = AddStream(codec, &codec_context);
+ 	AudioEncoder *encoder;
+@@ -194,7 +194,7 @@ unsigned int Muxer::GetQueuedPacketCount(unsigned int stream_index) {
+ void Muxer::Init() {
+ 
+ 	// get the format we want (this is just a pointer, we don't have to free this)
+-	AVOutputFormat *format = av_guess_format(m_container_name.toUtf8().constData(), NULL, NULL);
++	const AVOutputFormat *format = av_guess_format(m_container_name.toUtf8().constData(), NULL, NULL);
+ 	if(format == NULL) {
+ 		Logger::LogError("[Muxer::Init] " + Logger::tr("Error: Can't find chosen output format!"));
+ 		throw LibavException();
+@@ -261,8 +261,8 @@ void Muxer::Free() {
+ 	}
+ }
+ 
+-AVCodec* Muxer::FindCodec(const QString& codec_name) {
+-	AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
++const AVCodec* Muxer::FindCodec(const QString& codec_name) {
++	const AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
+ 	if(codec == NULL) {
+ 		Logger::LogError("[Muxer::FindCodec] " + Logger::tr("Error: Can't find codec!"));
+ 		throw LibavException();
+@@ -270,7 +270,7 @@ AVCodec* Muxer::FindCodec(const QString& codec_name) {
+ 	return codec;
+ }
+ 
+-AVStream* Muxer::AddStream(AVCodec* codec, AVCodecContext** codec_context) {
++AVStream* Muxer::AddStream(const AVCodec* codec, AVCodecContext** codec_context) {
+ 	assert(!m_started);
+ 	assert(m_format_context->nb_streams < MUXER_MAX_STREAMS);
+ 
+diff --git a/src/AV/Output/Muxer.h b/src/AV/Output/Muxer.h
+index d72347d..b104bcb 100644
+--- a/src/AV/Output/Muxer.h
++++ b/src/AV/Output/Muxer.h
+@@ -114,8 +114,8 @@ private:
+ 	void Init();
+ 	void Free();
+ 
+-	AVCodec* FindCodec(const QString& codec_name);
+-	AVStream* AddStream(AVCodec* codec, AVCodecContext** codec_context);
++	const AVCodec* FindCodec(const QString& codec_name);
++	AVStream* AddStream(const AVCodec* codec, AVCodecContext** codec_context);
+ 
+ 	void MuxerThread();
+ 
+diff --git a/src/AV/Output/VideoEncoder.cpp b/src/AV/Output/VideoEncoder.cpp
+index 8087e8e..fc8b5d1 100644
+--- a/src/AV/Output/VideoEncoder.cpp
++++ b/src/AV/Output/VideoEncoder.cpp
+@@ -34,7 +34,7 @@ const std::vector<VideoEncoder::PixelFormatData> VideoEncoder::SUPPORTED_PIXEL_F
+ 	{"rgb", AV_PIX_FMT_RGB24, false},
+ };
+ 
+-VideoEncoder::VideoEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options)
++VideoEncoder::VideoEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options)
+ 	: BaseEncoder(muxer, stream, codec_context, codec, options) {
+ 
+ #if !SSR_USE_AVCODEC_ENCODE_VIDEO2
+@@ -95,7 +95,7 @@ unsigned int VideoEncoder::GetFrameRate() {
+ }
+ 
+ bool VideoEncoder::AVCodecIsSupported(const QString& codec_name) {
+-	AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
++	const AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
+ 	if(codec == NULL)
+ 		return false;
+ 	if(!av_codec_is_encoder(codec))
+@@ -111,7 +111,7 @@ bool VideoEncoder::AVCodecIsSupported(const QString& codec_name) {
+ 	return false;
+ }
+ 
+-void VideoEncoder::PrepareStream(AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
++void VideoEncoder::PrepareStream(AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
+ 								 unsigned int bit_rate, unsigned int width, unsigned int height, unsigned int frame_rate) {
+ 
+ 	if(width == 0 || height == 0) {
+diff --git a/src/AV/Output/VideoEncoder.h b/src/AV/Output/VideoEncoder.h
+index cb7ca27..68d872e 100644
+--- a/src/AV/Output/VideoEncoder.h
++++ b/src/AV/Output/VideoEncoder.h
+@@ -40,7 +40,7 @@ private:
+ #endif
+ 
+ public:
+-	VideoEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options);
++	VideoEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options);
+ 	~VideoEncoder();
+ 
+ 	// Returns the required pixel format.
+@@ -55,7 +55,7 @@ public:
+ 
+ public:
+ 	static bool AVCodecIsSupported(const QString& codec_name);
+-	static void PrepareStream(AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
++	static void PrepareStream(AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
+ 							  unsigned int bit_rate, unsigned int width, unsigned int height, unsigned int frame_rate);
+ 
+ private:
+-- 
+2.43.0
+
diff --git a/srcpkgs/ssr/template b/srcpkgs/ssr/template
index 3097754e3cbe5..e3c4261f1f5a6 100644
--- a/srcpkgs/ssr/template
+++ b/srcpkgs/ssr/template
@@ -1,7 +1,7 @@
 # Template file for 'ssr'
 pkgname=ssr
 version=0.4.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DWITH_QT5=ON"
 hostmakedepends="pkg-config"

From b342ba4919d0b31b60062ce75d5ff33c4d09f90c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 065/113] synfig: revbump for ffmpeg6 and mlt7

---
 srcpkgs/synfig/patches/ffmpeg6.patch | 71 ++++++++++++++++++++++++++++
 srcpkgs/synfig/template              |  6 +--
 2 files changed, 74 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/synfig/patches/ffmpeg6.patch

diff --git a/srcpkgs/synfig/patches/ffmpeg6.patch b/srcpkgs/synfig/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..10780b42782f4
--- /dev/null
+++ b/srcpkgs/synfig/patches/ffmpeg6.patch
@@ -0,0 +1,71 @@
+--- a/src/modules/mod_libavcodec/trgt_av.cpp	2022-10-25 09:14:12.000000000 -0400
++++ b/src/modules/mod_libavcodec/trgt_av.cpp	2023-05-05 21:34:17.899194559 -0400
+@@ -38,6 +41,7 @@
+ extern "C"
+ {
+ #ifdef HAVE_LIBAVFORMAT_AVFORMAT_H
++#	include <libavcodec/avcodec.h>
+ #	include <libavformat/avformat.h>
+ #elif defined(HAVE_AVFORMAT_H)
+ #	include <avformat.h>
+@@ -155,11 +156,11 @@
+     }
+ 
+ 	bool open_video_stream() {
+-		if (avcodec_open2(video_context, NULL, NULL) < 0) {
++		if (avcodec_open2(video_context, nullptr, nullptr) < 0) {
+ 			synfig::error("Target_LibAVCodec: could not open video codec");
+ 			// seems the calling of avcodec_free_context after error will cause crash
+ 			// so just forget about this context
+-			video_context = NULL;
++			video_context = nullptr;
+ 			close();
+ 			return false;
+         }
+@@ -234,15 +235,21 @@
+ 		close();
+ 
+ 		if (!av_registered) {
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 			av_register_all();
++#endif
+ 			av_registered = true;
+ 		}
+ 
+ 		// guess format
+-		AVOutputFormat *format = av_guess_format(NULL, filename.c_str(), NULL);
++#if LIBAVCODEC_VERSION_MAJOR < 59 // FFMPEG < 5.0
++		AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#else
++		const AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#endif
+ 		if (!format) {
+ 			synfig::warning("Target_LibAVCodec: unable to guess the output format, defaulting to MPEG");
+-			format = av_guess_format("mpeg", NULL, NULL);
++			format = av_guess_format("mpeg", nullptr, nullptr);
+ 		}
+ 		if (!format) {
+ 			synfig::error("Target_LibAVCodec: unable to find 'mpeg' output format");
+@@ -254,6 +261,7 @@
+ 		context = avformat_alloc_context();
+ 		assert(context);
+ 		context->oformat = format;
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 		if (filename.size() + 1 > sizeof(context->filename)) {
+ 			synfig::error(
+ 				"Target_LibAVCodec: filename too long, max length is %d, filename is '%s'",
+@@ -263,6 +271,14 @@
+ 			return false;
+ 		}
+ 		memcpy(context->filename, filename.c_str(), filename.size() + 1);
++#else
++		context->url = av_strndup(filename.c_str(), filename.size());
++		if (!context->url) {
++			synfig::error("Target_LibAVCodec: cannot allocate space for filename");
++			close();
++			return false;
++		}
++#endif
+ 
+ 		packet = av_packet_alloc();
+ 		assert(packet);
diff --git a/srcpkgs/synfig/template b/srcpkgs/synfig/template
index d4d3e341a20bf..828b5cb32956e 100644
--- a/srcpkgs/synfig/template
+++ b/srcpkgs/synfig/template
@@ -2,11 +2,11 @@
 # Should be kept in sync with 'synfigstudio' and 'ETL'
 pkgname=synfig
 version=1.4.4
-revision=4
+revision=5
 build_style=gnu-configure
 configure_args="--with-boost-libdir=${XBPS_CROSS_BASE}/usr/lib"
 hostmakedepends="boost-build ImageMagick pkg-config intltool"
-makedepends="ETL gettext-devel libxml++-devel mlt-devel libmagick-devel
+makedepends="ETL gettext-devel libxml++-devel mlt7-devel libmagick-devel
  libmng-devel boost-build boost-devel libopenexr-devel ffmpeg-devel"
 depends="ImageMagick"
 short_desc="CLI 2D vector and timeline-based animation software"
@@ -20,7 +20,7 @@ CXXFLAGS="-std=c++11 -DHAVE_LOCALE_H=1"
 
 synfig-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision}
-	 libopenexr-devel libxml++-devel mlt-devel"
+	 libopenexr-devel libxml++-devel mlt7-devel"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/bin/synfig-config

From 491d0dfcfee01c5bad223ccf48299a7f9635ac22 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 066/113] timg: revbump for ffmpeg6

---
 srcpkgs/timg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/timg/template b/srcpkgs/timg/template
index 2a2ab763d2fdd..8fb4327535ef9 100644
--- a/srcpkgs/timg/template
+++ b/srcpkgs/timg/template
@@ -1,7 +1,7 @@
 # Template file for 'timg'
 pkgname=timg
 version=1.4.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_OPENSLIDE_SUPPORT=off -Wno-dev"
 hostmakedepends="pkg-config git"

From 3c9a5a7fb47429e6845a16a00ae3003b545490fc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 067/113] tvheadend: revbump for ffmpeg4

---
 srcpkgs/tvheadend/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tvheadend/template b/srcpkgs/tvheadend/template
index 9aea7de4ec705..012d31c4879ff 100644
--- a/srcpkgs/tvheadend/template
+++ b/srcpkgs/tvheadend/template
@@ -8,7 +8,7 @@ configure_args="--enable-dvbscan --disable-ffmpeg_static
 --disable-libx265_static --disable-libvpx_static --disable-libtheora_static
 --disable-libvorbis_static --disable-libfdkaac_static"
 hostmakedepends="gettext pkg-config python3 git which"
-makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg-devel"
+makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg4-devel"
 short_desc="TV streaming server"
 maintainer="lemmi <lemmi@nerd2nerd.org>"
 license="GPL-3.0-only"

From f35817c89148c31bd7e48beda24700040380b37e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 068/113] unpaper: update to 7.0.0.

---
 srcpkgs/unpaper/template | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/srcpkgs/unpaper/template b/srcpkgs/unpaper/template
index 38ed47a584016..1ff910e722afc 100644
--- a/srcpkgs/unpaper/template
+++ b/srcpkgs/unpaper/template
@@ -1,13 +1,13 @@
 # Template file for 'unpaper'
 pkgname=unpaper
-version=6.1
-revision=3
-build_style=gnu-configure
+version=7.0.0
+revision=1
+build_style=meson
+hostmakedepends="pkg-config meson libxslt"
+makedepends="ffmpeg-devel python3-Sphinx"
+short_desc="Post-processing tool for scanned sheets of paper"
 maintainer="Orphaned <orphan@voidlinux.org>"
-hostmakedepends="pkg-config libxslt"
-makedepends="ffmpeg-devel"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://www.flameeyes.eu/projects/unpaper"
-short_desc="A post-processing tool for scanned sheets of paper"
 distfiles="https://www.flameeyes.eu/files/${pkgname}-${version}.tar.xz"
-checksum=237c84f5da544b3f7709827f9f12c37c346cdf029b1128fb4633f9bafa5cb930
+checksum=2575fbbf26c22719d1cb882b59602c9900c7f747118ac130883f63419be46a80

From a6b2bfdfa87edfd109437bb8d7a3f29da89b9437 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 069/113] vice: revbump for ffmpeg4

---
 srcpkgs/vice/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/vice/template b/srcpkgs/vice/template
index b1f866d35095e..43f79243a1da1 100644
--- a/srcpkgs/vice/template
+++ b/srcpkgs/vice/template
@@ -1,7 +1,7 @@
 # Template file for 'vice'
 pkgname=vice
 version=3.7.1
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="
 	$(vopt_enable sdl2 sdlui2)
@@ -26,7 +26,7 @@ makedepends="
 	$(vopt_if gtk3 gtk+3-devel)
 	$(vopt_if gtk3 pulseaudio-devel)
 	$(vopt_if gtk3 pango-devel)
-	$(vopt_if ffmpeg ffmpeg-devel)"
+	$(vopt_if ffmpeg ffmpeg4-devel)"
 short_desc="Emulator for C64, C128, CBM-II, PET, VIC20, Plus4 and C16"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"

From 8adb5a4a8f2f7fef03b08a5f9fc4bfb5a162b8d2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 070/113] waypipe: revbump for ffmpeg6

---
 srcpkgs/waypipe/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waypipe/template b/srcpkgs/waypipe/template
index 6da88b21bf2a1..4da8058400b58 100644
--- a/srcpkgs/waypipe/template
+++ b/srcpkgs/waypipe/template
@@ -1,7 +1,7 @@
 # Template file for 'waypipe'
 pkgname=waypipe
 version=0.8.6
-revision=1
+revision=2
 build_style=meson
 # lto is off because it causes linking errors in armv6l and armv7l (due to NEON)
 configure_args="-Dwerror=false -Dwith_dmabuf=enabled -Dwith_lz4=enabled

From 05ee7cd9fc47bef4f70ce053f1ff5a652d714088 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 071/113] xpra: revbump for ffmpeg6

---
 srcpkgs/xpra/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xpra/template b/srcpkgs/xpra/template
index f4a44ea814867..c0f66c9483d49 100644
--- a/srcpkgs/xpra/template
+++ b/srcpkgs/xpra/template
@@ -1,7 +1,7 @@
 # Template file for 'xpra'
 pkgname=xpra
 version=5.0.5
-revision=1
+revision=2
 build_style=python3-module
 make_build_args="--without-cuda_kernels --without-cuda_rebuild"
 make_install_args="$(vopt_with docs) ${make_build_args}"

From 5df75fb83514fd708719077d13136d877da29838 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:07:40 -0400
Subject: [PATCH 072/113] nv-codec-headers: update to 12.0.16.0

---
 srcpkgs/nv-codec-headers/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/nv-codec-headers/template b/srcpkgs/nv-codec-headers/template
index 3d422a61e4891..251e057f826fb 100644
--- a/srcpkgs/nv-codec-headers/template
+++ b/srcpkgs/nv-codec-headers/template
@@ -1,6 +1,6 @@
 # Template file for 'nv-codec-headers'
 pkgname=nv-codec-headers
-version=11.1.5.1
+version=12.0.16.0
 revision=1
 build_style=gnu-makefile
 short_desc="FFmpeg version of headers required to interface with Nvidias codec APIs"
@@ -8,7 +8,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="MIT"
 homepage="http://git.videolan.org/?p=ffmpeg/nv-codec-headers.git"
 distfiles="https://github.com/FFmpeg/nv-codec-headers/archive/n${version}.tar.gz"
-checksum=d095fbd56aa93772471a323be0ebe65504a0f43f06c76a30b6d25da77b06ae9c
+checksum=2a1533b65f55f9da52956faf0627ed3b74868ac0c7f269990edd21369113b48f
 
 post_install() {
 	sed -n '4,25p' include/ffnvcodec/nvEncodeAPI.h > LICENSE

From a543ebd399c6e9542f9b510309e8dd8d8f8f8d23 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:08:40 -0400
Subject: [PATCH 073/113] openimagedenoise: revbump for ffmpeg6

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index b792813dba7c2..109deb171c3f7 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,7 +1,7 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
 version=1.4.3
-revision=1
+revision=2
 archs="x86_64*"
 build_style=cmake
 hostmakedepends="ispc python3"

From 9055414b4955fd14664054c9356db4a494fc54c4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:31:45 -0400
Subject: [PATCH 074/113] shotcut: revbump for ffmpeg6

---
 srcpkgs/shotcut/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/shotcut/template b/srcpkgs/shotcut/template
index 33141fbd862d7..f46cb53b6bfb9 100644
--- a/srcpkgs/shotcut/template
+++ b/srcpkgs/shotcut/template
@@ -1,7 +1,7 @@
 # Template file for 'shotcut'
 pkgname=shotcut
 version=23.09.29
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSHOTCUT_VERSION=${version}"
 hostmakedepends="pkg-config qt6-tools-devel"

From 0a66dbd714c330c95d01db878216286f7f0d309a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:30 -0400
Subject: [PATCH 075/113] shiboken2: revbump for qt5-5.15.11

---
 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch | 1 +
 1 file changed, 1 insertion(+)
 create mode 120000 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
new file mode 120000
index 0000000000000..efcf3249bd885
--- /dev/null
+++ b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1 @@
+../../python3-pyside2/patches/importlib-machinery-bypass.patch
\ No newline at end of file

From e41c85ba2587d57b486964394c292eb502b63156 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:53 -0400
Subject: [PATCH 076/113] python3-pyside2: revbump for qt5-5.15.11

---
 .../patches/importlib-machinery-bypass.patch      | 15 +++++++++++++++
 srcpkgs/python3-pyside2/template                  |  2 +-
 2 files changed, 16 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
new file mode 100644
index 0000000000000..64c429584776b
--- /dev/null
+++ b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1,15 @@
+Using this prevents an error around line 220 below it.
+"AttributeError: module 'importlib' has no attribute 'machinery'"
+The old backup logic is in place and compiles without issues.
+--- a/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:09:34.688912402 -0400
++++ b/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:10:03.395529582 -0400
+@@ -170,9 +170,6 @@
+
+     # 'zipstring_sequence' comes from signature.cpp
+     zipbytes = base64.b64decode(''.join(zipstring_sequence))
+-    if sys.version_info[0] >= 3:
+-        vzip = zipfile.ZipFile(io.BytesIO(zipbytes))
+-        return sys.meta_path, EmbeddableZipImporter(vzip)
+
+     # Old version for Python 2.7, only.
+     import os
diff --git a/srcpkgs/python3-pyside2/template b/srcpkgs/python3-pyside2/template
index 249efa9098842..52626436ce75f 100644
--- a/srcpkgs/python3-pyside2/template
+++ b/srcpkgs/python3-pyside2/template
@@ -1,7 +1,7 @@
 # Template file for 'python3-pyside2'
 pkgname=python3-pyside2
 version=5.15.10
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/pyside2"
 build_style=cmake

From 950921ba07de8b87ddcb892c70af4f1d9e606cc0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:35 -0400
Subject: [PATCH 077/113] konqueror: revbump for ffmpeg6

---
 srcpkgs/konqueror/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/konqueror/template b/srcpkgs/konqueror/template
index 044dafa605ba6..63dd01fafc780 100644
--- a/srcpkgs/konqueror/template
+++ b/srcpkgs/konqueror/template
@@ -1,11 +1,11 @@
 # Template file for 'konqueror'
 pkgname=konqueror
 version=23.08.4
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DDESKTOPTOJSON_EXECUTABLE=/usr/bin/desktoptojson"
 hostmakedepends="extra-cmake-modules python3 qt5-host-tools qt5-qmake kdoctools
-kcoreaddons kconfig gettext"
+ kcoreaddons kconfig gettext"
 makedepends="qt5-devel qt5-webengine-devel qt5-declarative-devel
  qt5-webchannel-devel qt5-location-devel kcmutils-devel kdelibs4support-devel
  karchive-devel khtml-devel kdesu-devel kactivities5-devel"

From eaaefc3e742043cd35376e7c35b20788e3aa684a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:58 -0400
Subject: [PATCH 078/113] qt5-speech: revbump for qt5-5.15.11

---
 srcpkgs/qt5-speech/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-speech/template b/srcpkgs/qt5-speech/template
index 1228bb60c41db..27a7da1dbdb91 100644
--- a/srcpkgs/qt5-speech/template
+++ b/srcpkgs/qt5-speech/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-speech'
 pkgname=qt5-speech
 version=5.15.11
-revision=1
+revision=2
 _commit=d32f4a479d38a11f547598004b975f4356424a16
 build_style=qmake
 configure_args="-- -flite -flite-alsa -speechd"

From c57f53c3d89e5c1656566a28eb1a0b7dfc552415 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Jun 2023 08:20:22 -0400
Subject: [PATCH 079/113] gtk4: revbump for ffmpeg6

---
 srcpkgs/gtk4/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gtk4/template b/srcpkgs/gtk4/template
index d8ee60abe06f7..55bff6e33849a 100644
--- a/srcpkgs/gtk4/template
+++ b/srcpkgs/gtk4/template
@@ -1,7 +1,7 @@
 # Template file for 'gtk4'
 pkgname=gtk4
 version=4.12.3
-revision=1
+revision=2
 build_style=meson
 build_helper="gir"
 configure_args="-Dman-pages=true -Ddocumentation=true -Dbuild-tests=false

From ed5ed8fde204ffc339eb4aa0b1073cc2cf978bfd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:28:26 -0400
Subject: [PATCH 080/113] siril: revbump for ffmpeg6

---
 srcpkgs/siril/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/siril/template b/srcpkgs/siril/template
index 84332f79d060d..62750dd247548 100644
--- a/srcpkgs/siril/template
+++ b/srcpkgs/siril/template
@@ -1,7 +1,7 @@
 # Template file for 'siril'
 pkgname=siril
 version=0.9.12
-revision=10
+revision=11
 build_style=gnu-configure
 hostmakedepends="pkg-config intltool autoconf automake gettext-devel"
 makedepends="fftw-devel libconfig-devel libopencv-devel libffms2-devel

From 5256e4197f1e572f06bcbf61fdb9a48f42a432be Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 22 Jun 2023 10:25:02 -0400
Subject: [PATCH 081/113] kdenlive: revbump for ffmpeg6

---
 srcpkgs/kdenlive/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kdenlive/template b/srcpkgs/kdenlive/template
index a0f3615c9c530..d63166f95c4d7 100644
--- a/srcpkgs/kdenlive/template
+++ b/srcpkgs/kdenlive/template
@@ -1,7 +1,7 @@
 # Template file for 'kdenlive'
 pkgname=kdenlive
 version=23.08.4
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="
  extra-cmake-modules kconfig kcoreaddons kdoctools pkg-config python3

From 4ac121c4682b1b1b4e3be5161c696ff557ef839b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:20:59 -0400
Subject: [PATCH 082/113] tracker-miners: revbump for ffmpeg6

---
 srcpkgs/tracker-miners/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tracker-miners/template b/srcpkgs/tracker-miners/template
index 0b97f47489f81..f196d2bf9e4a4 100644
--- a/srcpkgs/tracker-miners/template
+++ b/srcpkgs/tracker-miners/template
@@ -1,7 +1,7 @@
 # Template file for 'tracker-miners'
 pkgname=tracker-miners
 version=3.6.1
-revision=1
+revision=2
 build_style=meson
 build_helper=qemu
 # missing libgrss for miner_rss

From 02239b1f06179b406356bfd25e474887e22c1b3e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:21:21 -0400
Subject: [PATCH 083/113] mpd: revbump for ffmpeg6

---
 srcpkgs/mpd/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpd/template b/srcpkgs/mpd/template
index 4fd32b7be8c53..b8e2bd4c1b59c 100644
--- a/srcpkgs/mpd/template
+++ b/srcpkgs/mpd/template
@@ -1,7 +1,7 @@
 # Template file for 'mpd'
 pkgname=mpd
 version=0.23.15
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dopus=enabled -Dmikmod=enabled -Dneighbor=true
  -Dsoundcloud=enabled -Dpipe=true -Dtwolame=enabled -Dbzip2=enabled

From 81a2080467f8b7373c9787f33ae0cd4680dbc1e9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:02 -0400
Subject: [PATCH 084/113] tg_owt: revbump for ffmpeg6

---
 srcpkgs/tg_owt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tg_owt/template b/srcpkgs/tg_owt/template
index aee8d35d08ffb..34e8fef054056 100644
--- a/srcpkgs/tg_owt/template
+++ b/srcpkgs/tg_owt/template
@@ -1,7 +1,7 @@
 # Template file for 'tg_owt'
 pkgname=tg_owt
 version=0.0.0.20231221
-revision=1
+revision=2
 _commit=afd9d5d31798d3eacf9ed6c30601e91d0f1e4d60
 _libyuv_commit=04821d1e7d60845525e8db55c7bcd41ef5be9406
 _abseil_commit=8c0b94e793a66495e0b1f34a5eb26bd7dc672db0

From 9ed5a6b2379bd8f9628ac999b9b30b1b6d04e2df Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:44 -0400
Subject: [PATCH 085/113] telegram-desktop: revbump for ffmpeg6

---
 srcpkgs/telegram-desktop/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/telegram-desktop/template b/srcpkgs/telegram-desktop/template
index d00b273b7b738..d20b87b5182db 100644
--- a/srcpkgs/telegram-desktop/template
+++ b/srcpkgs/telegram-desktop/template
@@ -1,7 +1,7 @@
 # Template file for 'telegram-desktop'
 pkgname=telegram-desktop
 version=4.14.9
-revision=1
+revision=2
 build_style=cmake
 build_helper="qemu gir"
 configure_args="-DTDESKTOP_API_ID=209235

From efe03843e13b91bdcf3362f229d2a67ad28d6189 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:11:45 -0400
Subject: [PATCH 086/113] gst-plugins-bad1: revbump for ffmpeg6

---
 srcpkgs/gst-plugins-bad1/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index 87e6922317734..b4a7f7367e7df 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-plugins-bad1'
 pkgname=gst-plugins-bad1
 version=1.22.9
-revision=1
+revision=2
 build_helper="gir"
 build_style=meson
 configure_args="-Dpackage-origin=https://voidlinux.org -Ddoc=disabled

From 82fca4ea9cdb073da134d56f0bd8e67825c0a5c3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:12:09 -0400
Subject: [PATCH 087/113] openmw: revbump for ffmpeg6

---
 srcpkgs/openmw/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openmw/template b/srcpkgs/openmw/template
index 0abf5ff7cdbec..b57180f1a4446 100644
--- a/srcpkgs/openmw/template
+++ b/srcpkgs/openmw/template
@@ -1,7 +1,7 @@
 # Template file for 'openmw'
 pkgname=openmw
 version=0.48.0
-revision=2
+revision=3
 build_style=cmake
 _recast_commit=e75adf86f91eb3082220085e42dda62679f9a3ea
 _bullet_tag=3.17

From 2b804c28b027b697d955405b15f1a9114cc8acbb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:14:53 -0400
Subject: [PATCH 088/113] lms: revbump for ffmpeg6

---
 srcpkgs/lms/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/lms/template b/srcpkgs/lms/template
index e358f75902a98..3b21c458de519 100644
--- a/srcpkgs/lms/template
+++ b/srcpkgs/lms/template
@@ -1,7 +1,7 @@
 # Template file for 'lms'
 pkgname=lms
 version=3.42.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="wt-devel ffmpeg-devel boost-devel libconfig++-devel taglib-devel pam-devel libgraphicsmagick-devel gtest-devel libarchive-devel"

From 2f7f5db82ba87c5a81ab29c622af339e74afd152 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:18:18 -0400
Subject: [PATCH 089/113] freecad: DELETE

---
 srcpkgs/freecad/patches/001-include.patch     | 112 ------------------
 .../154-revert-gui-tmp-redirect-stderr.patch  |  68 -----------
 ...d63c8c9b1280978be841d04e68a0a55cceb9.patch |  30 -----
 srcpkgs/freecad/template                      |  12 +-
 4 files changed, 7 insertions(+), 215 deletions(-)
 delete mode 100644 srcpkgs/freecad/patches/001-include.patch
 delete mode 100644 srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
 delete mode 100644 srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch

diff --git a/srcpkgs/freecad/patches/001-include.patch b/srcpkgs/freecad/patches/001-include.patch
deleted file mode 100644
index 28b5af54999b9..0000000000000
--- a/srcpkgs/freecad/patches/001-include.patch
+++ /dev/null
@@ -1,112 +0,0 @@
-From 9a41845a417189776741297c50a3827ce292bc4f Mon Sep 17 00:00:00 2001
-From: Uwe <donovaly@users.noreply.github.com>
-Date: Sun, 3 Jul 2022 22:51:16 +0200
-Subject: [PATCH] [Part] OCCError.h: remove unneeded includes
-
-- also sort includes
----
- src/Mod/Part/App/OCCError.h             | 36 +++----------------------
- src/Mod/Part/App/OffsetCurvePyImp.cpp   | 12 ++++-----
- src/Mod/Part/App/OffsetSurfacePyImp.cpp | 10 +++----
- 3 files changed, 12 insertions(+), 46 deletions(-)
-
---- a/src/Mod/Part/App/OCCError.h
-+++ b/src/Mod/Part/App/OCCError.h
-@@ -23,36 +23,8 @@
- #ifndef _OCCError_h_
- #define _OCCError_h_
- 
--# include <Standard_Version.hxx>
- # include <Standard_Failure.hxx>
--# include <Standard_AbortiveTransaction.hxx>
--# include <Standard_ConstructionError.hxx>
--# if OCC_VERSION_HEX >= 0x060500
--# include <Standard_DefineException.hxx>
--# endif
--# include <Standard_DimensionError.hxx>
--# include <Standard_DimensionMismatch.hxx>
--# include <Standard_DivideByZero.hxx>
--# include <Standard_DomainError.hxx>
--# include <Standard_ImmutableObject.hxx>
--# include <Standard_LicenseError.hxx>
--# include <Standard_LicenseNotFound.hxx>
--# include <Standard_MultiplyDefined.hxx>
--# include <Standard_NegativeValue.hxx>
--# include <Standard_NoMoreObject.hxx>
--# include <Standard_NoSuchObject.hxx>
--# include <Standard_NotImplemented.hxx>
--# include <Standard_NullObject.hxx>
--# include <Standard_NullValue.hxx>
--# include <Standard_NumericError.hxx>
--# include <Standard_OutOfMemory.hxx>
--# include <Standard_OutOfRange.hxx>
--# include <Standard_Overflow.hxx>
--# include <Standard_ProgramError.hxx>
--# include <Standard_RangeError.hxx>
--# include <Standard_TooManyUsers.hxx>
--# include <Standard_TypeMismatch.hxx>
--# include <Standard_Underflow.hxx>
-+# include <Standard_Version.hxx>
- 
- #include <Mod/Part/PartGlobal.h>
- #include <Base/Console.h>
-@@ -88,4 +60,3 @@ PartExport extern PyObject* PartExceptio
- 
- #define PY_CATCH_OCC _PY_CATCH_OCC(return(NULL))
- #endif  // _OCCError_h_
--
---- a/src/Mod/Part/App/OffsetCurvePyImp.cpp
-+++ b/src/Mod/Part/App/OffsetCurvePyImp.cpp
-@@ -20,20 +20,20 @@
-  *                                                                         *
-  ***************************************************************************/
- 
--
- #include "PreCompiled.h"
- #ifndef _PreComp_
- # include <Geom_OffsetCurve.hxx>
- #endif
- 
--#include "OCCError.h"
--#include "Geometry.h"
-+#include <Base/GeometryPyCXX.h>
-+#include <Base/Vector3D.h>
-+#include <Base/VectorPy.h>
-+
- #include "OffsetCurvePy.h"
- #include "OffsetCurvePy.cpp"
-+#include "Geometry.h"
-+#include "OCCError.h"
- 
--#include <Base/GeometryPyCXX.h>
--#include <Base/VectorPy.h>
--#include <Base/Vector3D.h>
- 
- using namespace Part;
- 
---- a/src/Mod/Part/App/OffsetSurfacePyImp.cpp
-+++ b/src/Mod/Part/App/OffsetSurfacePyImp.cpp
-@@ -20,20 +20,16 @@
-  *                                                                         *
-  ***************************************************************************/
- 
--
- #include "PreCompiled.h"
- #ifndef _PreComp_
- # include <Geom_OffsetSurface.hxx>
- # include <memory>
- #endif
- 
--#include <Base/VectorPy.h>
--#include <Base/Vector3D.h>
--
- #include "OCCError.h"
--#include "Geometry.h"
--#include <Mod/Part/App/OffsetSurfacePy.h>
--#include <Mod/Part/App/OffsetSurfacePy.cpp>
-+#include "OffsetSurfacePy.h"
-+#include "OffsetSurfacePy.cpp"
-+
- 
- using namespace Part;
- 
diff --git a/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch b/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
deleted file mode 100644
index d6a9adabdec83..0000000000000
--- a/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
+++ /dev/null
@@ -1,68 +0,0 @@
-see https://github.com/FreeCAD/FreeCAD/commit/cfe94b00d3434f3e2c8b5114d2909f628c330fa8#commitcomment-71413407
-
-upstream: yes
-
-From 7b377a216b9185960e4cee980a6504dc1a755f50 Mon Sep 17 00:00:00 2001
-From: wmayer <wmayer@users.sourceforge.net>
-Date: Wed, 29 Jun 2022 15:19:18 +0200
-Subject: [PATCH] Gui: remove workaround for spnav 0.23 due to build failure
- with musl libc
-
----
- src/Gui/3Dconnexion/GuiNativeEventLinux.cpp | 27 ---------------------
- 1 file changed, 27 deletions(-)
-
---- a/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp
-+++ b/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp
-@@ -21,42 +21,17 @@
-  ***************************************************************************/
- 
- #include <FCConfig.h>
--#include <cstdio>
- 
- #include "GuiNativeEventLinux.h"
- 
- #include "GuiApplicationNativeEventAware.h"
- #include <Base/Console.h>
--#include <Base/FileInfo.h>
- #include <QMainWindow>
- 
- #include <QSocketNotifier>
- 
- #include <spnav.h>
- 
--namespace {
--class RedirectStdErr
--{
--public:
--    RedirectStdErr()
--        : fi(Base::FileInfo::getTempFileName())
--        , file(stderr)
--    {
--        stderr = fopen(fi.filePath().c_str(), "w");
--    }
--    ~RedirectStdErr()
--    {
--        fclose(stderr);
--        fi.deleteFile();
--        stderr = file;
--    }
--
--private:
--    Base::FileInfo fi;
--    FILE* file;
--};
--}
--
- Gui::GuiNativeEvent::GuiNativeEvent(Gui::GUIApplicationNativeEventAware *app)
- : GuiAbstractNativeEvent(app)
- {
-@@ -72,8 +47,6 @@ Gui::GuiNativeEvent::~GuiNativeEvent()
- 
- void Gui::GuiNativeEvent::initSpaceball(QMainWindow *window)
- {
--    // tmp. redirect stderr to a file to suppress an error message from spnav_open()
--    RedirectStdErr err;
-     Q_UNUSED(window)
-     if (spnav_open() == -1) {
-         Base::Console().Log("Couldn't connect to spacenav daemon. Please ignore if you don't have a spacemouse.\n");
diff --git a/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch b/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch
deleted file mode 100644
index d4acf370ca0a4..0000000000000
--- a/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-From fe02d63c8c9b1280978be841d04e68a0a55cceb9 Mon Sep 17 00:00:00 2001
-From: Roy-043 <70520633+Roy-043@users.noreply.github.com>
-Date: Thu, 29 Dec 2022 23:20:38 +0100
-Subject: [PATCH] Draft: update inspect.getargspec to inspect.getfullargspec
- (#8101)
-
----
- src/Mod/Draft/draftguitools/gui_snapper.py | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
---- a/src/Mod/Draft/draftguitools/gui_snapper.py
-+++ b/src/Mod/Draft/draftguitools/gui_snapper.py
-@@ -1426,7 +1426,7 @@ class Snapper:
-             Gui.Snapper.off()
-             self.ui.offUi()
-             if callback:
--                if len(inspect.getargspec(callback).args) > 1:
-+                if len(inspect.getfullargspec(callback).args) > 1:
-                     obj = None
-                     if self.snapInfo and ("Object" in self.snapInfo) and self.snapInfo["Object"]:
-                         obj = App.ActiveDocument.getObject(self.snapInfo["Object"])
-@@ -1445,7 +1445,7 @@ class Snapper:
-             Gui.Snapper.off()
-             self.ui.offUi()
-             if callback:
--                if len(inspect.getargspec(callback).args) > 1:
-+                if len(inspect.getfullargspec(callback).args) > 1:
-                     callback(None, None)
-                 else:
-                     callback(None)
diff --git a/srcpkgs/freecad/template b/srcpkgs/freecad/template
index c135701e38b9a..7d5165f760bab 100644
--- a/srcpkgs/freecad/template
+++ b/srcpkgs/freecad/template
@@ -1,7 +1,7 @@
 # Template file for 'freecad'
 pkgname=freecad
-version=0.20.2
-revision=7
+version=0.21.1
+revision=2
 build_wrksrc="FreeCAD-${version}"
 build_style=cmake
 pycompile_dirs="usr/lib/${pkgname}/Mod"
@@ -24,8 +24,10 @@ makedepends="python3-devel boost-devel libxerces-c-devel zlib-devel occt-devel
  coin3-devel libshiboken2-devel libspnav-devel pyside2-tools
  liblz4-devel libpyside2-python3-devel python3-matplotlib netcdf-devel
  jsoncpp-devel qt5-devel qt5-svg-devel qt5-tools-devel qt5-webkit-devel
- qt5-xmlpatterns-devel coin3-doc glew-devel python3-pivy"
-depends="python3-matplotlib python3-pyside2-webengine python3-pivy"
+ qt5-xmlpatterns-devel coin3-doc glew-devel python3-pivy qt5-webengine-devel
+ qt5-declarative-devel qt5-webchannel-devel qt5-location-devel"
+depends="python3-matplotlib python3-pyside2-webengine python3-pivy
+ python3-GitPython python3-Markdown"
 short_desc="General purpose 3D CAD modeler"
 maintainer="yopito <pierre.bourgin@free.fr>"
 license="LGPL-2.0-or-later"
@@ -35,7 +37,7 @@ distfiles="
  https://github.com/FreeCAD/FreeCAD/archive/${version}.tar.gz
  ${SOURCEFORGE_SITE}/cxx/pycxx-${_pycxxver}.tar.gz
 "
-checksum="46922f3a477e742e1a89cd5346692d63aebb2b67af887b3e463e094a4ae055da
+checksum="e9b1fd0323f101268c7f3be52db42e4a29222f2e306ae6c4a6fc309cb418d35a
  4b91e1e1141c23fbd5039df635c4bb6e75632168548f56b83ce177193c0c98c6"
 python_version=3
 patch_args="-Np1 -d ${build_wrksrc}"

From 34deb72c4dfbcc41eca1f5329dce7858ca1ef3d3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:47:18 -0400
Subject: [PATCH 090/113] libopenshot: revbump for ffmpeg6

---
 srcpkgs/libopenshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenshot/template b/srcpkgs/libopenshot/template
index 8e57c5f592169..7a8f4520e7892 100644
--- a/srcpkgs/libopenshot/template
+++ b/srcpkgs/libopenshot/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenshot'
 pkgname=libopenshot
 version=0.3.0
-revision=3
+revision=4
 build_style=cmake
 # Builds fail with Ruby-2.4.1
 configure_args="-DENABLE_RUBY=OFF -DUSE_SYSTEM_JSONCPP=ON"

From 93e0a5f04bf2497cb3734862d0f691f69b6434b6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:10:30 -0500
Subject: [PATCH 091/113] openimageio: revbump for ffmpeg6

---
 srcpkgs/openimageio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimageio/template b/srcpkgs/openimageio/template
index 3ce3f9e49d350..27d2131bc0a61 100644
--- a/srcpkgs/openimageio/template
+++ b/srcpkgs/openimageio/template
@@ -1,7 +1,7 @@
 # Template file for 'openimageio'
 pkgname=openimageio
 version=2.4.9.0
-revision=7
+revision=8
 build_style=cmake
 build_helper=qemu
 configure_args="-DUSE_QT=0 -DUSE_PYTHON=0 -DOIIO_BUILD_TESTS=0

From d41133a5f2202024eb82c732b5ba5247ab068b0d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:11:57 -0500
Subject: [PATCH 092/113] synfigstudio: revbump for ffmpeg6

---
 srcpkgs/synfigstudio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/synfigstudio/template b/srcpkgs/synfigstudio/template
index 09e442da9a680..2bc017cedca6b 100644
--- a/srcpkgs/synfigstudio/template
+++ b/srcpkgs/synfigstudio/template
@@ -2,7 +2,7 @@
 # Should be kept in sync with 'synfig' and 'ETL'
 pkgname=synfigstudio
 version=1.4.4
-revision=4
+revision=5
 build_style=gnu-configure
 configure_args="--disable-update-mimedb"
 hostmakedepends="pkg-config intltool gettext synfig"

From 33b0ee15dd7365eb89898e66fbb298bb5f0df2aa Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:10 -0500
Subject: [PATCH 093/113] mixxx: revbump for ffmpeg6

---
 srcpkgs/mixxx/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mixxx/template b/srcpkgs/mixxx/template
index 6921996e4e77b..6a79b328c1abf 100644
--- a/srcpkgs/mixxx/template
+++ b/srcpkgs/mixxx/template
@@ -1,7 +1,7 @@
 # Template file for 'mixxx'
 pkgname=mixxx
 version=2.3.3
-revision=6
+revision=7
 build_style=cmake
 configure_args="-DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="extra-cmake-modules pkg-config protobuf qt5-host-tools qt5-qmake"

From 1312c0acd5e77210c7403f87d0105ecab15c8435 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:28 -0500
Subject: [PATCH 094/113] musikcube: revbump for ffmpeg6

---
 srcpkgs/musikcube/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/musikcube/template b/srcpkgs/musikcube/template
index 8c4a51840859e..fb60dd2049089 100644
--- a/srcpkgs/musikcube/template
+++ b/srcpkgs/musikcube/template
@@ -1,7 +1,7 @@
 # Template file for 'musikcube'
 pkgname=musikcube
 version=3.0.0
-revision=3
+revision=4
 build_style=cmake
 make_cmd=make
 configure_args="-DNO_NCURSESW=1"

From a4c5f97708cfaf864e1ddd04ff2e620246251104 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:45 -0500
Subject: [PATCH 095/113] electron24: revbump for ffmpeg6

---
 srcpkgs/electron24/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron24/template b/srcpkgs/electron24/template
index 7b4e28812f483..1ca93fde97a85 100644
--- a/srcpkgs/electron24/template
+++ b/srcpkgs/electron24/template
@@ -1,7 +1,7 @@
 # Template file for 'electron24'
 pkgname=electron24
 version=24.3.0
-revision=2
+revision=3
 _nodever=18.14.0
 _chromiumver=112.0.5615.165
 archs="x86_64* aarch64*"

From 27010c7c5dc76a97f6e1ba98ebd38a0d00e9566f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:00 -0500
Subject: [PATCH 096/113] electron19: revbump for ffmpeg6

---
 srcpkgs/electron19/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron19/template b/srcpkgs/electron19/template
index 0ef959125cb08..5371c0b354604 100644
--- a/srcpkgs/electron19/template
+++ b/srcpkgs/electron19/template
@@ -1,7 +1,7 @@
 # Template file for 'electron19'
 pkgname=electron19
 version=19.0.8
-revision=4
+revision=5
 _nodever=16.14.2
 _chromiumver=102.0.5005.125
 archs="x86_64* aarch64* ppc64le*"

From f4bd14be5a629cfd1ea2ebf5cd777c3e2e0cad5e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:13 -0500
Subject: [PATCH 097/113] wf-recorder: revbump for ffmpeg6

---
 srcpkgs/wf-recorder/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/wf-recorder/template b/srcpkgs/wf-recorder/template
index 08f986b031006..63c45cf4b814d 100644
--- a/srcpkgs/wf-recorder/template
+++ b/srcpkgs/wf-recorder/template
@@ -1,7 +1,7 @@
 # Template file for 'wf-recorder'
 pkgname=wf-recorder
 version=0.4.1
-revision=2
+revision=3
 build_style=meson
 hostmakedepends="pkg-config scdoc wayland-devel"
 makedepends="wayland-protocols wayland-devel ffmpeg-devel libgbm-devel x264-devel

From 5e40c90c1418eed917fa0904abbb0fcdc8c88749 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:26 -0500
Subject: [PATCH 098/113] obs: revbump for ffmpeg6

---
 srcpkgs/obs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/obs/template b/srcpkgs/obs/template
index b343f1131bfcf..a25a67433e285 100644
--- a/srcpkgs/obs/template
+++ b/srcpkgs/obs/template
@@ -1,7 +1,7 @@
 # Template file for 'obs'
 pkgname=obs
 version=30.0.0
-revision=2
+revision=3
 archs="i686* x86_64* ppc64le* aarch64* riscv64*"
 build_style=cmake
 configure_args="-DOBS_VERSION_OVERRIDE=${version} -DENABLE_JACK=ON

From 0717c4e30c0db4eab94069db17bf4e5d44e1780a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:36 -0500
Subject: [PATCH 099/113] mlt7: revbump for ffmpeg6

---
 srcpkgs/mlt7/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mlt7/template b/srcpkgs/mlt7/template
index 98f302ad3a516..7eb8c00fa1580 100644
--- a/srcpkgs/mlt7/template
+++ b/srcpkgs/mlt7/template
@@ -1,7 +1,7 @@
 # Template file for 'mlt7'
 pkgname=mlt7
 version=7.20.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DSWIG_PYTHON=ON -DMOD_QT6=ON"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which

From 9b1aa6127d8589c13d69f646cd730e1b74950c4e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:48 -0500
Subject: [PATCH 100/113] qt6-multimedia: revbump for ffmpeg6

---
 srcpkgs/qt6-multimedia/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-multimedia/template b/srcpkgs/qt6-multimedia/template
index 67a577e1300fe..1da626ecf515a 100644
--- a/srcpkgs/qt6-multimedia/template
+++ b/srcpkgs/qt6-multimedia/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-multimedia'
 pkgname=qt6-multimedia
 version=6.6.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DQT_FEATURE_gstreamer=ON"
 hostmakedepends="perl qt6-declarative-host-tools pkg-config qt6-shadertools"

From 13d7ce9f13705bde63b54827839b3b69249d2f8c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:00:15 -0500
Subject: [PATCH 101/113] baresip: revbump for ffmpeg6

---
 srcpkgs/baresip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/baresip/template b/srcpkgs/baresip/template
index 12c8954ef7b9b..b16b67beab8d2 100644
--- a/srcpkgs/baresip/template
+++ b/srcpkgs/baresip/template
@@ -1,7 +1,7 @@
 # Template file for 'baresip'
 pkgname=baresip
 version=3.6.0
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config glib-devel"
 makedepends="libgsm-devel libpng-devel openssl-devel libsndfile-devel

From 9a832b15488867b38c271809b43b1d336c61e76a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:30 -0500
Subject: [PATCH 102/113] QMPlay2: revbump for ffmpeg6

---
 srcpkgs/QMPlay2/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/QMPlay2/template b/srcpkgs/QMPlay2/template
index 46c80f64a1349..942258ce60fb7 100644
--- a/srcpkgs/QMPlay2/template
+++ b/srcpkgs/QMPlay2/template
@@ -1,7 +1,7 @@
 # Template file for 'QMPlay2'
 pkgname=QMPlay2
 version=23.10.22
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools"
 makedepends="alsa-lib-devel ffmpeg-devel libass-devel libcdio-devel libgme-devel

From a927b3e15fe457840e98a2b98c54d14fee8f9115 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:34 -0500
Subject: [PATCH 103/113] alsa-plugins: revbump for ffmpeg6

---
 srcpkgs/alsa-plugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/alsa-plugins/template b/srcpkgs/alsa-plugins/template
index a5708a7d82a8f..7bfdad046c483 100644
--- a/srcpkgs/alsa-plugins/template
+++ b/srcpkgs/alsa-plugins/template
@@ -1,7 +1,7 @@
 # Template file for 'alsa-plugins'
 pkgname=alsa-plugins
 version=1.2.7.1
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--disable-maemo-plugin"
 hostmakedepends="pkg-config"

From 5434ecaf7caa4b75a2b9610d94bb1b0362d72f57 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:43 -0500
Subject: [PATCH 104/113] minidlna: revbump for ffmpeg6

---
 srcpkgs/minidlna/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/minidlna/template b/srcpkgs/minidlna/template
index 5fa929f3a0c12..742991ecd04af 100644
--- a/srcpkgs/minidlna/template
+++ b/srcpkgs/minidlna/template
@@ -1,7 +1,7 @@
 # Template file for 'minidlna'
 pkgname=minidlna
 version=1.3.3
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="
  --sbindir=/usr/bin

From 147b6ab57238f213c08372f32eefb195c9a5a484 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 17:57:47 -0500
Subject: [PATCH 105/113] mpv: revbump for ffmpeg6

---
 srcpkgs/mpv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpv/template b/srcpkgs/mpv/template
index 4948d1e332cb8..1ac1b167af189 100644
--- a/srcpkgs/mpv/template
+++ b/srcpkgs/mpv/template
@@ -1,7 +1,7 @@
 # Template file for 'mpv'
 pkgname=mpv
 version=0.36.0
-revision=4
+revision=5
 build_style=meson
 configure_args="-Dcdda=enabled -Ddvbin=enabled -Ddvdnav=enabled
  -Dlibmpv=true -Dcplugins=enabled

From f75783d632ce982111ce4b1eaaa95fbcc6a5f94a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 17:59:29 -0500
Subject: [PATCH 106/113] qimgv: revbump for ffmpeg6

---
 srcpkgs/qimgv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qimgv/template b/srcpkgs/qimgv/template
index dd341dfe1bfce..8a7e1c081ef12 100644
--- a/srcpkgs/qimgv/template
+++ b/srcpkgs/qimgv/template
@@ -1,7 +1,7 @@
 # Template file for 'qimgv'
 pkgname=qimgv
 version=1.0.2
-revision=3
+revision=4
 build_style=cmake
 configure_args="$(vopt_if video -DVIDEO_SUPPORT=ON -DVIDEO_SUPPORT=OFF)
  $(vopt_if scale -DOPENCV_SUPPORT=ON -DOPENCV_SUPPORT=OFF)

From 240746986de3cba5366cfee9a13bcfd80864eabf Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 18:00:36 -0500
Subject: [PATCH 107/113] kfilemetadata5: revbump for ffmpeg6

---
 srcpkgs/kfilemetadata5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kfilemetadata5/template b/srcpkgs/kfilemetadata5/template
index a0c4d80939532..b584f85ff2058 100644
--- a/srcpkgs/kfilemetadata5/template
+++ b/srcpkgs/kfilemetadata5/template
@@ -1,7 +1,7 @@
 # Template file for 'kfilemetadata5'
 pkgname=kfilemetadata5
 version=5.115.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="kcoreaddons extra-cmake-modules pkg-config qt5-host-tools qt5-qmake
  gettext kcoreaddons python3"

From 30e39a572ff08b391357e78d5c0fa035bcf1324a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 8 Dec 2023 11:46:01 -0500
Subject: [PATCH 108/113] vba-m: revbump for ffmpeg6

---
 srcpkgs/vba-m/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vba-m/template b/srcpkgs/vba-m/template
index 3d135efa1d0b6..3c5a20db0fa98 100644
--- a/srcpkgs/vba-m/template
+++ b/srcpkgs/vba-m/template
@@ -2,7 +2,7 @@
 pkgname=vba-m
 reverts=1292_2
 version=2.1.9
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_GTK=TRUE -DENABLE_FFMPEG=TRUE -DENABLE_LINK=TRUE -DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="gettext pkg-config unzip zip yasm wxWidgets-gtk3-devel"

From 24a609b8877b94ed53351e7206c1f2a72eadae7b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 8 Dec 2023 11:46:19 -0500
Subject: [PATCH 109/113] dolphin-emu: revbump for ffmpeg6

---
 srcpkgs/dolphin-emu/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/dolphin-emu/template b/srcpkgs/dolphin-emu/template
index 862d3ae964eec..a7ae0efb58fb7 100644
--- a/srcpkgs/dolphin-emu/template
+++ b/srcpkgs/dolphin-emu/template
@@ -1,7 +1,7 @@
 # Template file for 'dolphin-emu'
 pkgname=dolphin-emu
 version=5.0.19368
-revision=3
+revision=4
 _dolphin_commit=dadbeb4bae7e7fa23af2b46e0add4143094dc107
 _mgba_commit=44e074a15e9651481f7f652ac006a7c9d58cbeb9
 _googletest_commit=be03d00f5f0cc3a997d1a368bee8a1fe93651f48

From c886a22a80cc31fb1116d969f0e6c00371ea91a6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 19 Dec 2023 15:38:51 -0500
Subject: [PATCH 110/113] qtox: revbump for ffmpeg4

---
 srcpkgs/qtox/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtox/template b/srcpkgs/qtox/template
index bb70e7f51240a..755e4462bc013 100644
--- a/srcpkgs/qtox/template
+++ b/srcpkgs/qtox/template
@@ -1,13 +1,13 @@
 # Template file for 'qtox'
 pkgname=qtox
 version=1.17.6
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DUPDATE_CHECK=OFF
  -DGIT_DESCRIBE=${version}
  $(vopt_if snorenotify -DDESKTOP_NOTIFICATIONS=ON)"
 hostmakedepends="pkg-config qt5-host-tools qt5-devel"
-makedepends="ffmpeg-devel libexif-devel libopenal-devel libsodium-devel
+makedepends="ffmpeg4-devel libexif-devel libopenal-devel libsodium-devel
  libvpx-devel opus-devel qrencode-devel qt5-svg-devel sonnet-devel
  sqlcipher-devel toxcore-devel
  $(vopt_if snorenotify snorenotify-devel)"

From 208fffabcd6caff544f9baffd88a9f3f4f84a082 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 11 Jan 2024 11:52:00 -0500
Subject: [PATCH 111/113] arcan: revbump for ffmpeg6

---
 srcpkgs/arcan/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/arcan/template b/srcpkgs/arcan/template
index ff9091f90ebb1..030091a6cc9d0 100644
--- a/srcpkgs/arcan/template
+++ b/srcpkgs/arcan/template
@@ -2,7 +2,7 @@
 # !! keep synced with: acfgfs aclip aloadimage
 pkgname=arcan
 version=0.6.2.1
-revision=2
+revision=3
 create_wrksrc=yes
 build_wrksrc=arcan/src
 build_style=cmake

From 7119c6c9bf752a036c46855f09a16918e23ba2c3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 11 Jan 2024 11:52:10 -0500
Subject: [PATCH 112/113] notcurses: revbump for ffmpeg6

---
 srcpkgs/notcurses/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/notcurses/template b/srcpkgs/notcurses/template
index 48a7463cb68eb..515f316ab4576 100644
--- a/srcpkgs/notcurses/template
+++ b/srcpkgs/notcurses/template
@@ -1,7 +1,7 @@
 # Template file for 'notcurses'
 pkgname=notcurses
 version=3.0.9
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DUSE_STATIC=ON -DUSE_QRCODEGEN=On $(vopt_bool man USE_PANDOC)"
 hostmakedepends="pkg-config $(vopt_if man pandoc)"

From 796a3e09fe5ed6aa12848a21e9b6252cd350f687 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Feb 2024 14:28:38 -0500
Subject: [PATCH 113/113] New package: oneVPL-intel-gpu-24.1.3

---
 srcpkgs/oneVPL-intel-gpu/template | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
 create mode 100644 srcpkgs/oneVPL-intel-gpu/template

diff --git a/srcpkgs/oneVPL-intel-gpu/template b/srcpkgs/oneVPL-intel-gpu/template
new file mode 100644
index 0000000000000..8b93cfabf7fc8
--- /dev/null
+++ b/srcpkgs/oneVPL-intel-gpu/template
@@ -0,0 +1,18 @@
+# Template file for 'oneVPL-intel-gpu'
+pkgname=oneVPL-intel-gpu
+version=24.1.3
+revision=1
+build_style=cmake
+hostmakedepends="pkg-config"
+makedepends="libva-devel libdrm-devel"
+short_desc="Intel oneVPL GPU Runtime"
+maintainer="zlice <zlice555@gmail.com>"
+license="MIT"
+homepage="https://github.com/oneapi-src/oneVPL-intel-gpu"
+changelog="https://github.com/oneapi-src/oneVPL-intel-gpu/blob/main/CHANGELOG.md"
+distfiles="https://github.com/oneapi-src/oneVPL-intel-gpu/archive/refs/tags/intel-onevpl-${version}.tar.gz"
+checksum=15d34e4304d7aeb5ea5e529b6f51171109cef42525113321f675bc14e56c697e
+
+post_install() {
+	vlicense LICENSE
+}

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (65 preceding siblings ...)
  2024-02-15 19:52 ` zlice
@ 2024-02-20 18:21 ` zlice
  2024-02-22 17:25 ` yoshiyoshyosh
                   ` (30 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2024-02-20 18:21 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 4846 bytes --]

There is an updated pull request by zlice against master on the void-packages repository

https://github.com/zlice/void-packages ffmpeg6-split
https://github.com/void-linux/void-packages/pull/43761

ffmpeg6 split
[ci skip]


#### Testing the changes

- I tested the changes in this PR: **YES**

main testing has been vaapi in Firefox Nightly and enc/dec in Shotcut on Intel A770

#### New package

- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**

#### Local build testing

- I built this PR locally for my native architecture, **x86_64**

#### Discussion

Continuation of https://github.com/void-linux/void-packages/pull/36315

`libavresample` is deprecated, but marked as a dependency when trying to build other packages and install `ffmpeg`(6). I think the right way to handle this is make a meta package and the add to removals?


##### Commit naming / misc

~~Commits are 'dirty' right now, running with [gstreamer 1.22.1 updates](https://github.com/void-linux/void-packages/pull/42861) and [Intel OpenCL](https://github.com/void-linux/void-packages/pull/43084). This will also make [intel packages pr](https://github.com/void-linux/void-packages/pull/41132) obsolete.~~ (see Requirements below)

Maintainer for previous ffmpeg(4) was orphaned, I can put my name in there if that matters, though I don't exactly see myself keeping up on ffmpeg.

~~This updates QT5 which looks like it is usually hosted by Johnny. Not sure if there's any reason to stay there or these sources are fine.~~ Using qt5.15.11 now, revbumps and some patches.

##### STILL FFMPEG4

These are a mix of emulators, games and/or older packages.

- ~~attract~~ (2.7 builds)
- ~~audacity (https://github.com/audacity/audacity/issues/2305 and https://sourceforge.net/p/portmedia/wiki/portsmf/ is 'beta')~~ (updated to 3.x, compiles with ffmpeg6)
- ~~ccextractor~~ (master patches)
- vice (3.8 compiles, needs makedepends libcurl-devel)
- kodi
- mlt (only dep left is flowblade - flowblade 2.12.0.2 with mlt7-python3 can 'render' videos with cpu and gpu)
- ~~synfig (mlt)~~ (work with mlt7, bump synfigstudio)
- tvheadend (download page recommends using 4.3 which compiles fine, 4.4 eta is Q1 2024)
- ~~ssr~~ (patches)
- ~~spek-alternative~~ (replace with spek-x)
- ~~ppsspp~~ ~~(1.17.1 is out, but there's 5+ distfiles that are all git commits)~~ (minor patch)
- olive (has been in alpha since 2020, seems they do nightly builds and appimages)
- moc
- mediastreamer (linphone links are dead, changed to github belladonne. their stuff never worked for me but there are updates if someone wants to give it a try)
- libextractor (1.13 compiles, remove exiv2 patch)
- idjc (0.9.8 compiles, remove python3.10 patch, needs makedepends libebur128-devel and libshout-idjc 2.4.6 with '-r1' for distfile)
- hedgewars
- ~~ffmpegthumbnailer~~ (patches for moviedecoder.xxx files)
- ~~ffmpegthumbs~~ (latest compiles)
- deadbeef (1.9.6 may work but requires libdispatch from apple)
- ~~omxplayer~~ (package removed, deprecated in favor of vlc)
- qtav (fork has ffmpeg 5 patch - https://github.com/cmguo/QtAV)
- `vlc` (vlc4 will support ffmpeg5, there's a patch to build 3.x with ffmpeg5 but it will lack vaapi)
- `osg` (OpenSceneGraph plus `xine-lib`)


##### HAVE NOT BUILT YET

- ~~omxplayer (rpi only? ffmpeg4)~~ (removed)
- kodi (big, but ffmpeg4)


##### UPDATED (for ffmpeg6)

- ~~blender: update to 3.5.1~~ ~~will be revbump with~~ https://github.com/void-linux/void-packages/pull/43992
- unpaper: update to 7.0.0.
- guvcview: update to 2.0.8.
- ~~qt5: update to 5.15.8~~ updated by another PR to 5.15.11
- ~~qt5-webengine: update to 5.18.15~~ updated by another PR to 5.15.16 (some patching for ffmpeg build)
- ~~shiboken2: revbump for qt5.15.8 (patch)~~ updated by another PR to 5.15.10
- ~~python3-pyside2: update to 5.15.8 (patch)~~ updated by another PR to 5.15.10
- New package: spex-x replaces spek-alternative for ffmpeg-6.0


##### Requirements

- ~~[gstreamer 1.22.2](https://github.com/void-linux/void-packages/pull/42861)~~ - a few packages use ffmpeg-devel and require a revbump

- ~~[Intel Packages](https://github.com/void-linux/void-packages/pull/41132) [Intel Packages v2](https://github.com/void-linux/void-packages/pull/47330) - ffmpeg4 uses different libraries than 6 (libmfx / Intel-MediaSDK vs only oneVPL that Intel is moving to), both are included here~~. Using replacement oneVPL from OBS update.

- ~~[shotcut 23.05.14](https://github.com/void-linux/void-packages/pull/44260)~~

- https://github.com/void-linux/void-packages/pull/44781 will remove from this PR

A patch file from https://github.com/void-linux/void-packages/pull/43761.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ffmpeg6-split-43761.patch --]
[-- Type: text/x-diff, Size: 242511 bytes --]

From 62509570399387009f84a3c01c38fbab3282f59a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:16:56 -0400
Subject: [PATCH 001/111] ffmpeg: update to 6.0.1.

---
 common/shlibs                                 | 26 ++++---
 srcpkgs/ffmpeg/files/altivec.patch            | 60 ---------------
 .../patches/armv5tel-floating-point.patch     | 18 -----
 srcpkgs/ffmpeg/patches/binutils-2.41.patch    | 73 -------------------
 ...h-libavcodec-libsvtav1-ten_bit_format.diff | 40 ----------
 .../workaround-mesa-readeon-vaapi-bug.patch   | 28 -------
 srcpkgs/ffmpeg/template                       | 40 +++++-----
 7 files changed, 37 insertions(+), 248 deletions(-)
 delete mode 100644 srcpkgs/ffmpeg/files/altivec.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/binutils-2.41.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 delete mode 100644 srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch

diff --git a/common/shlibs b/common/shlibs
index 34596bac98f4b..cc15fb5f63b4b 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -389,15 +389,23 @@ libid3tag.so.0 libid3tag-0.15.1b_1
 libgif.so.7 giflib-5.1.0_1
 libImlib2.so.1 imlib2-1.4.2_1
 libmp3lame.so.0 lame-3.98.2_1
-libavdevice.so.58 libavdevice-4.0_1
-libavformat.so.58 libavformat-4.0_1
-libswscale.so.5 libswscale-4.0_1
-libswresample.so.3 libswresample-4.0_1
-libavresample.so.4 libavresample-4.0_1
-libpostproc.so.55 libpostproc-4.0_1
-libavcodec.so.58 libavcodec-4.0_1
-libavutil.so.56 libavutil-4.0_1
-libavfilter.so.7 libavfilter-4.0_1
+libavdevice.so.60 libavdevice-6.0_1
+libavformat.so.60 libavformat-6.0_1
+libswscale.so.7 libswscale-6.0_1
+libswresample.so.4 libswresample-6.0_1
+libpostproc.so.57 libpostproc-6.0_1
+libavcodec.so.60 libavcodec-6.0_1
+libavutil.so.58 libavutil-6.0_1
+libavfilter.so.9 libavfilter-6.0_1
+libavdevice.so.58 libavdevice4-4.0_1
+libavformat.so.58 libavformat4-4.0_1
+libswscale.so.5 libswscale4-4.0_1
+libswresample.so.3 libswresample4-4.0_1
+libavresample.so.4 libavresample4-4.0_1
+libpostproc.so.55 libpostproc4-4.0_1
+libavcodec.so.58 libavcodec4-4.0_1
+libavutil.so.56 libavutil4-4.0_1
+libavfilter.so.7 libavfilter4-4.0_1
 libSDL-1.2.so.0 SDL-1.2.14_1
 libSDL_image-1.2.so.0 SDL_image-1.2.10_1
 libx264.so.157 x264-20190507.2245_1
diff --git a/srcpkgs/ffmpeg/files/altivec.patch b/srcpkgs/ffmpeg/files/altivec.patch
deleted file mode 100644
index 9c57200463320..0000000000000
--- a/srcpkgs/ffmpeg/files/altivec.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-revert some altivec specific change on all ppc* except ppc64le*
-
-q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
-conditionally, for ppc* but not ppc64le* (the new code is valid for
-POWER8 VSX which LE targets as a baseline but not BE)"
-
-
-This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
----
- libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
- 1 file changed, 20 insertions(+), 4 deletions(-)
-
-diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
-index 536545293d..c1e2852adb 100644
---- a/libswscale/ppc/yuv2rgb_altivec.c
-+++ b/libswscale/ppc/yuv2rgb_altivec.c
-@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-     vector signed short R1, G1, B1;                                           \
-     vector unsigned char R, G, B;                                             \
-                                                                               \
-+    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
-+    vector unsigned char align_perm;                                          \
-+                                                                              \
-     vector signed short lCY       = c->CY;                                    \
-     vector signed short lOY       = c->OY;                                    \
-     vector signed short lCRV      = c->CRV;                                   \
-@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
-                                                                               \
-         for (j = 0; j < w / 16; j++) {                                        \
--            y0 = vec_xl(0, y1i);                                              \
-+            y1ivP = (const vector unsigned char *) y1i;                       \
-+            y2ivP = (const vector unsigned char *) y2i;                       \
-+            uivP  = (const vector unsigned char *) ui;                        \
-+            vivP  = (const vector unsigned char *) vi;                        \
-+                                                                              \
-+            align_perm = vec_lvsl(0, y1i);                                    \
-+            y0 = (vector unsigned char)                                       \
-+                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
-                                                                               \
--            y1 = vec_xl(0, y2i);                                              \
-+            align_perm = vec_lvsl(0, y2i);                                    \
-+            y1 = (vector unsigned char)                                       \
-+                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
-                                                                               \
--            u = (vector signed char) vec_xl(0, ui);                           \
-+            align_perm = vec_lvsl(0, ui);                                     \
-+            u = (vector signed char)                                          \
-+                    vec_perm(uivP[0], uivP[1], align_perm);                   \
-                                                                               \
--            v = (vector signed char) vec_xl(0, vi);                           \
-+            align_perm = vec_lvsl(0, vi);                                     \
-+            v = (vector signed char)                                          \
-+                    vec_perm(vivP[0], vivP[1], align_perm);                   \
-                                                                               \
-             u = (vector signed char)                                          \
-                     vec_sub(u,                                                \
--- 
-2.27.0
-
diff --git a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
deleted file mode 100644
index 9a55178c74f0f..0000000000000
--- a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
-+++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
-@@ -39,6 +39,15 @@
- #endif
- #include <fenv.h>
- 
-+#if (FE_ALL_EXCEPT == 0)
-+/* E.g. ARM soft float does not define these */
-+#define FE_INVALID    0
-+#define FE_DIVBYZERO  0
-+#define FE_OVERFLOW   0
-+#define FE_UNDERFLOW  0
-+#define FE_INEXACT    0
-+#endif
-+
- #if CONFIG_LIBFONTCONFIG
- #include <fontconfig/fontconfig.h>
- #endif
diff --git a/srcpkgs/ffmpeg/patches/binutils-2.41.patch b/srcpkgs/ffmpeg/patches/binutils-2.41.patch
deleted file mode 100644
index 53a596d0ee7d4..0000000000000
--- a/srcpkgs/ffmpeg/patches/binutils-2.41.patch
+++ /dev/null
@@ -1,73 +0,0 @@
-From effadce6c756247ea8bae32dc13bb3e6f464f0eb Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= <remi@remlab.net>
-Date: Sun, 16 Jul 2023 18:18:02 +0300
-Subject: [PATCH] avcodec/x86/mathops: clip constants used with shift
- instructions within inline assembly
-
-Fixes assembling with binutil as >= 2.41
-
-Signed-off-by: James Almer <jamrial@gmail.com>
----
- libavcodec/x86/mathops.h | 26 +++++++++++++++++++++++---
- 1 file changed, 23 insertions(+), 3 deletions(-)
-
-diff --git a/libavcodec/x86/mathops.h b/libavcodec/x86/mathops.h
-index 6298f5ed1983b..ca7e2dffc1076 100644
---- a/libavcodec/x86/mathops.h
-+++ b/libavcodec/x86/mathops.h
-@@ -35,12 +35,20 @@
- static av_always_inline av_const int MULL(int a, int b, unsigned shift)
- {
-     int rt, dummy;
-+    if (__builtin_constant_p(shift))
-     __asm__ (
-         "imull %3               \n\t"
-         "shrdl %4, %%edx, %%eax \n\t"
-         :"=a"(rt), "=d"(dummy)
--        :"a"(a), "rm"(b), "ci"((uint8_t)shift)
-+        :"a"(a), "rm"(b), "i"(shift & 0x1F)
-     );
-+    else
-+        __asm__ (
-+            "imull %3               \n\t"
-+            "shrdl %4, %%edx, %%eax \n\t"
-+            :"=a"(rt), "=d"(dummy)
-+            :"a"(a), "rm"(b), "c"((uint8_t)shift)
-+        );
-     return rt;
- }
- 
-@@ -113,19 +121,31 @@ __asm__ volatile(\
- // avoid +32 for shift optimization (gcc should do that ...)
- #define NEG_SSR32 NEG_SSR32
- static inline  int32_t NEG_SSR32( int32_t a, int8_t s){
-+    if (__builtin_constant_p(s))
-     __asm__ ("sarl %1, %0\n\t"
-          : "+r" (a)
--         : "ic" ((uint8_t)(-s))
-+         : "i" (-s & 0x1F)
-     );
-+    else
-+        __asm__ ("sarl %1, %0\n\t"
-+               : "+r" (a)
-+               : "c" ((uint8_t)(-s))
-+        );
-     return a;
- }
- 
- #define NEG_USR32 NEG_USR32
- static inline uint32_t NEG_USR32(uint32_t a, int8_t s){
-+    if (__builtin_constant_p(s))
-     __asm__ ("shrl %1, %0\n\t"
-          : "+r" (a)
--         : "ic" ((uint8_t)(-s))
-+         : "i" (-s & 0x1F)
-     );
-+    else
-+        __asm__ ("shrl %1, %0\n\t"
-+               : "+r" (a)
-+               : "c" ((uint8_t)(-s))
-+        );
-     return a;
- }
- 
diff --git a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
deleted file mode 100644
index aa948f7a8a2df..0000000000000
--- a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
+++ /dev/null
@@ -1,40 +0,0 @@
-#==================================================================================================
-# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
-# From: Christopher Degawa <christopher.degawa@intel.com>
-# Date: Thu, 20 Oct 2022 22:55:27 -0500
-# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
-#
-# compressed_ten_bit_format has been deprecated upstream and has no effect
-# and can be removed. Plus, technically it was never used in the first place
-# since it would require the app (ffmpeg) to set it and do additional
-# processing of the input frames.
-#
-# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
-#
-# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
-#==================================================================================================
---- a/libavcodec/libsvtav1.c
-+++ b/libavcodec/libsvtav1.c
-@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
- 
- static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
- {
--    const int    pack_mode_10bit =
--        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
--    const size_t luma_size_8bit  =
--        config->source_width * config->source_height * (1 << pack_mode_10bit);
--    const size_t luma_size_10bit =
--        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
-+    const size_t luma_size = config->source_width * config->source_height *
-+        (config->encoder_bit_depth > 8 ? 2 : 1);
- 
-     EbSvtIOFormat *in_data;
- 
--    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
-+    svt_enc->raw_size = luma_size * 3 / 2;
- 
-     // allocate buffer for in and out
-     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
--- 
-GitLab
-
diff --git a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
deleted file mode 100644
index 00e3f68a415b8..0000000000000
--- a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
-From: Rainer Hochecker <fernetmenta@online.de>
-Date: Sat, 26 Jan 2019 19:48:35 +0100
-Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
-
-This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
-It was hit frequently when watching h264 channels received via DVB-X.
-Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
----
- libavcodec/vaapi_h264.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
-index 5854587a255..f12fdc457a4 100644
---- a/libavcodec/vaapi_h264.c
-+++ b/libavcodec/vaapi_h264.c
-@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
-     H264SliceContext *sl = &h->slice_ctx[0];
-     int ret;
- 
-+    if (pic->nb_slices == 0) {
-+        ret = AVERROR_INVALIDDATA;
-+        goto finish;
-+    }
-+
-     ret = ff_vaapi_decode_issue(avctx, pic);
-     if (ret < 0)
-         goto finish;
diff --git a/srcpkgs/ffmpeg/template b/srcpkgs/ffmpeg/template
index 1ebb436135938..f1e4712c41d08 100644
--- a/srcpkgs/ffmpeg/template
+++ b/srcpkgs/ffmpeg/template
@@ -1,15 +1,15 @@
 # Template file for 'ffmpeg'
 # audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
 pkgname=ffmpeg
-version=4.4.4
-revision=6
+version=6.0.1
+revision=1
 short_desc="Decoding, encoding and streaming software"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="https://www.ffmpeg.org"
 changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
 distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
-checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+checksum=9b16b8731d78e596b4be0d720428ca42df642bb2d78342881ff7f5bc29fc9623
 
 hostmakedepends="pkg-config perl"
 makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
@@ -26,12 +26,13 @@ makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-deve
  $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
  $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
  $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
- $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers Vulkan-Tools Vulkan-ValidationLayers')
+ $(vopt_if onevpl 'oneVPL oneVPL-devel')
  $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
 depends="ffplay>=${version}_${revision}"
 
 build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
- dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec onevpl"
 build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
 desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
 desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
@@ -39,9 +40,13 @@ desc_option_sofa="Enable support for AES SOFA"
 desc_option_webp="Enable support for WebP"
 
 case "$XBPS_TARGET_MACHINE" in
-	i686*|x86_64*)
-		hostmakedepends+=" nasm"
+	i686*)
 		build_options_default+=" vaapi vdpau nvenc nvdec"
+		hostmakedepends+=" nasm"
+		;;
+	x86_64*)
+		hostmakedepends+=" nasm"
+		build_options_default+=" vaapi vdpau nvenc nvdec onevpl"
 		;;
 	ppc64*) build_options_default+=" vaapi vdpau";;
 	mips*) CFLAGS="-mnan=legacy";;
@@ -65,8 +70,6 @@ post_patch() {
 		ppc64le*) ;;
 		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
 	esac
-
-	vsed -i libavfilter/vf_libvmaf.c -e 's!/usr/local/share/model/\(vmaf_v0.6.1\).pkl!/usr/share/vmaf/\1.json!'
 }
 
 do_configure() {
@@ -115,18 +118,19 @@ do_configure() {
 		$(vopt_enable x265 libx265) \
 		$(vopt_enable v4l2 libv4l2) \
 		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
-		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		--enable-libbs2b --enable-libvidstab \
 		$(vopt_enable dav1d libdav1d) \
 		$(vopt_enable zimg libzimg) \
 		$(vopt_enable webp libwebp) \
 		$(vopt_enable sofa libmysofa) \
 		$(vopt_enable vulkan) \
+		$(vopt_enable onevpl libvpl) \
 		$(vopt_enable drm libdrm) \
 		$(vopt_enable svtav1 libsvtav1) \
 		$(vopt_enable srt libsrt) \
 		$(vopt_enable rist librist) \
-		$(vopt_if nvenc '--enable-nvenc') \
-		$(vopt_if nvdec '--enable-nvdec')
+		$(vopt_enable nvenc nvenc) \
+		$(vopt_enable nvdec nvdec)
 }
 
 do_build() {
@@ -153,10 +157,8 @@ libavdevice_package() {
 }
 
 libavresample_package() {
-	short_desc="FFmpeg audio resampling library"
-	pkg_install() {
-		vmove "usr/lib/libavresample.so.*"
-	}
+	short_desc="Package deprecated, removal needed"
+	build_style=meta
 }
 
 libavformat_package() {
@@ -210,15 +212,13 @@ ffmpeg-devel_package() {
 		libavfilter>=${version}_${revision}
 		libpostproc>=${version}_${revision}
 		libswscale>=${version}_${revision}
-		libswresample>=${version}_${revision}
-		libavresample>=${version}_${revision}"
+		libswresample>=${version}_${revision}"
 	short_desc+=" - development files"
-
+	conflicts="ffmpeg4-devel"
 	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
 		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
 		nostrip_files="/usr/lib/libavfilter.a"
 	fi
-
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig

From 2689f769fb99f4eedbc2d48dbc56d0ccc23b7907 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:14 -0400
Subject: [PATCH 002/111] openshot: revbump for ffmpeg6

---
 srcpkgs/openshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openshot/template b/srcpkgs/openshot/template
index 3849858fe963b..12789bc986749 100644
--- a/srcpkgs/openshot/template
+++ b/srcpkgs/openshot/template
@@ -1,7 +1,7 @@
 # Template file for 'openshot'
 pkgname=openshot
 version=3.1.1
-revision=1
+revision=2
 build_style=python3-module
 hostmakedepends="python3 python3-setuptools"
 makedepends="ffmpeg-devel python3-PyQt5"

From 9e37630ec5f256c73c8f661314571b7c4a07f211 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:36 -0400
Subject: [PATCH 003/111] sumo: revbump for ffmpeg6

---
 srcpkgs/sumo/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/sumo/template b/srcpkgs/sumo/template
index a3fe134aa5acc..a730afa9fafa9 100644
--- a/srcpkgs/sumo/template
+++ b/srcpkgs/sumo/template
@@ -1,7 +1,7 @@
 # Template file for 'sumo'
 pkgname=sumo
 version=1.12.0
-revision=6
+revision=7
 build_style=cmake
 hostmakedepends="libgdal-tools pkg-config swig python3-setuptools"
 makedepends="python3-devel ffmpeg-devel fox-devel gl2ps-devel libgdal-devel

From ec18eaf9200212ba9f2da7ca3b381bcfd3d4dd83 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:56:22 -0400
Subject: [PATCH 004/111] New package: ffmpeg4-4.4.4.

---
 srcpkgs/ffmpeg4-devel                         |   1 +
 srcpkgs/ffmpeg4/files/altivec.patch           |  60 +++++
 .../patches/armv5tel-floating-point.patch     |  18 ++
 srcpkgs/ffmpeg4/patches/binutils-2.41.patch   |  73 ++++++
 ...h-libavcodec-libsvtav1-ten_bit_format.diff |  40 +++
 .../workaround-mesa-readeon-vaapi-bug.patch   |  28 +++
 srcpkgs/ffmpeg4/template                      | 234 ++++++++++++++++++
 srcpkgs/libavcodec4                           |   1 +
 srcpkgs/libavdevice4                          |   1 +
 srcpkgs/libavfilter4                          |   1 +
 srcpkgs/libavformat4                          |   1 +
 srcpkgs/libavresample4                        |   1 +
 srcpkgs/libavutil4                            |   1 +
 srcpkgs/libpostproc4                          |   1 +
 srcpkgs/libswresample4                        |   1 +
 srcpkgs/libswscale4                           |   1 +
 16 files changed, 463 insertions(+)
 create mode 120000 srcpkgs/ffmpeg4-devel
 create mode 100644 srcpkgs/ffmpeg4/files/altivec.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/binutils-2.41.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 create mode 100644 srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
 create mode 100644 srcpkgs/ffmpeg4/template
 create mode 120000 srcpkgs/libavcodec4
 create mode 120000 srcpkgs/libavdevice4
 create mode 120000 srcpkgs/libavfilter4
 create mode 120000 srcpkgs/libavformat4
 create mode 120000 srcpkgs/libavresample4
 create mode 120000 srcpkgs/libavutil4
 create mode 120000 srcpkgs/libpostproc4
 create mode 120000 srcpkgs/libswresample4
 create mode 120000 srcpkgs/libswscale4

diff --git a/srcpkgs/ffmpeg4-devel b/srcpkgs/ffmpeg4-devel
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/ffmpeg4-devel
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/ffmpeg4/files/altivec.patch b/srcpkgs/ffmpeg4/files/altivec.patch
new file mode 100644
index 0000000000000..9c57200463320
--- /dev/null
+++ b/srcpkgs/ffmpeg4/files/altivec.patch
@@ -0,0 +1,60 @@
+revert some altivec specific change on all ppc* except ppc64le*
+
+q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
+conditionally, for ppc* but not ppc64le* (the new code is valid for
+POWER8 VSX which LE targets as a baseline but not BE)"
+
+
+This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
+---
+ libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
+ 1 file changed, 20 insertions(+), 4 deletions(-)
+
+diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
+index 536545293d..c1e2852adb 100644
+--- a/libswscale/ppc/yuv2rgb_altivec.c
++++ b/libswscale/ppc/yuv2rgb_altivec.c
+@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+     vector signed short R1, G1, B1;                                           \
+     vector unsigned char R, G, B;                                             \
+                                                                               \
++    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
++    vector unsigned char align_perm;                                          \
++                                                                              \
+     vector signed short lCY       = c->CY;                                    \
+     vector signed short lOY       = c->OY;                                    \
+     vector signed short lCRV      = c->CRV;                                   \
+@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
+                                                                               \
+         for (j = 0; j < w / 16; j++) {                                        \
+-            y0 = vec_xl(0, y1i);                                              \
++            y1ivP = (const vector unsigned char *) y1i;                       \
++            y2ivP = (const vector unsigned char *) y2i;                       \
++            uivP  = (const vector unsigned char *) ui;                        \
++            vivP  = (const vector unsigned char *) vi;                        \
++                                                                              \
++            align_perm = vec_lvsl(0, y1i);                                    \
++            y0 = (vector unsigned char)                                       \
++                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
+                                                                               \
+-            y1 = vec_xl(0, y2i);                                              \
++            align_perm = vec_lvsl(0, y2i);                                    \
++            y1 = (vector unsigned char)                                       \
++                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
+                                                                               \
+-            u = (vector signed char) vec_xl(0, ui);                           \
++            align_perm = vec_lvsl(0, ui);                                     \
++            u = (vector signed char)                                          \
++                    vec_perm(uivP[0], uivP[1], align_perm);                   \
+                                                                               \
+-            v = (vector signed char) vec_xl(0, vi);                           \
++            align_perm = vec_lvsl(0, vi);                                     \
++            v = (vector signed char)                                          \
++                    vec_perm(vivP[0], vivP[1], align_perm);                   \
+                                                                               \
+             u = (vector signed char)                                          \
+                     vec_sub(u,                                                \
+-- 
+2.27.0
+
diff --git a/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
new file mode 100644
index 0000000000000..9a55178c74f0f
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
@@ -0,0 +1,18 @@
+--- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
++++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
+@@ -39,6 +39,15 @@
+ #endif
+ #include <fenv.h>
+ 
++#if (FE_ALL_EXCEPT == 0)
++/* E.g. ARM soft float does not define these */
++#define FE_INVALID    0
++#define FE_DIVBYZERO  0
++#define FE_OVERFLOW   0
++#define FE_UNDERFLOW  0
++#define FE_INEXACT    0
++#endif
++
+ #if CONFIG_LIBFONTCONFIG
+ #include <fontconfig/fontconfig.h>
+ #endif
diff --git a/srcpkgs/ffmpeg4/patches/binutils-2.41.patch b/srcpkgs/ffmpeg4/patches/binutils-2.41.patch
new file mode 100644
index 0000000000000..53a596d0ee7d4
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/binutils-2.41.patch
@@ -0,0 +1,73 @@
+From effadce6c756247ea8bae32dc13bb3e6f464f0eb Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= <remi@remlab.net>
+Date: Sun, 16 Jul 2023 18:18:02 +0300
+Subject: [PATCH] avcodec/x86/mathops: clip constants used with shift
+ instructions within inline assembly
+
+Fixes assembling with binutil as >= 2.41
+
+Signed-off-by: James Almer <jamrial@gmail.com>
+---
+ libavcodec/x86/mathops.h | 26 +++++++++++++++++++++++---
+ 1 file changed, 23 insertions(+), 3 deletions(-)
+
+diff --git a/libavcodec/x86/mathops.h b/libavcodec/x86/mathops.h
+index 6298f5ed1983b..ca7e2dffc1076 100644
+--- a/libavcodec/x86/mathops.h
++++ b/libavcodec/x86/mathops.h
+@@ -35,12 +35,20 @@
+ static av_always_inline av_const int MULL(int a, int b, unsigned shift)
+ {
+     int rt, dummy;
++    if (__builtin_constant_p(shift))
+     __asm__ (
+         "imull %3               \n\t"
+         "shrdl %4, %%edx, %%eax \n\t"
+         :"=a"(rt), "=d"(dummy)
+-        :"a"(a), "rm"(b), "ci"((uint8_t)shift)
++        :"a"(a), "rm"(b), "i"(shift & 0x1F)
+     );
++    else
++        __asm__ (
++            "imull %3               \n\t"
++            "shrdl %4, %%edx, %%eax \n\t"
++            :"=a"(rt), "=d"(dummy)
++            :"a"(a), "rm"(b), "c"((uint8_t)shift)
++        );
+     return rt;
+ }
+ 
+@@ -113,19 +121,31 @@ __asm__ volatile(\
+ // avoid +32 for shift optimization (gcc should do that ...)
+ #define NEG_SSR32 NEG_SSR32
+ static inline  int32_t NEG_SSR32( int32_t a, int8_t s){
++    if (__builtin_constant_p(s))
+     __asm__ ("sarl %1, %0\n\t"
+          : "+r" (a)
+-         : "ic" ((uint8_t)(-s))
++         : "i" (-s & 0x1F)
+     );
++    else
++        __asm__ ("sarl %1, %0\n\t"
++               : "+r" (a)
++               : "c" ((uint8_t)(-s))
++        );
+     return a;
+ }
+ 
+ #define NEG_USR32 NEG_USR32
+ static inline uint32_t NEG_USR32(uint32_t a, int8_t s){
++    if (__builtin_constant_p(s))
+     __asm__ ("shrl %1, %0\n\t"
+          : "+r" (a)
+-         : "ic" ((uint8_t)(-s))
++         : "i" (-s & 0x1F)
+     );
++    else
++        __asm__ ("shrl %1, %0\n\t"
++               : "+r" (a)
++               : "c" ((uint8_t)(-s))
++        );
+     return a;
+ }
+ 
diff --git a/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
new file mode 100644
index 0000000000000..aa948f7a8a2df
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
@@ -0,0 +1,40 @@
+#==================================================================================================
+# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
+# From: Christopher Degawa <christopher.degawa@intel.com>
+# Date: Thu, 20 Oct 2022 22:55:27 -0500
+# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
+#
+# compressed_ten_bit_format has been deprecated upstream and has no effect
+# and can be removed. Plus, technically it was never used in the first place
+# since it would require the app (ffmpeg) to set it and do additional
+# processing of the input frames.
+#
+# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
+#
+# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
+#==================================================================================================
+--- a/libavcodec/libsvtav1.c
++++ b/libavcodec/libsvtav1.c
+@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
+ 
+ static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
+ {
+-    const int    pack_mode_10bit =
+-        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
+-    const size_t luma_size_8bit  =
+-        config->source_width * config->source_height * (1 << pack_mode_10bit);
+-    const size_t luma_size_10bit =
+-        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
++    const size_t luma_size = config->source_width * config->source_height *
++        (config->encoder_bit_depth > 8 ? 2 : 1);
+ 
+     EbSvtIOFormat *in_data;
+ 
+-    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
++    svt_enc->raw_size = luma_size * 3 / 2;
+ 
+     // allocate buffer for in and out
+     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
+-- 
+GitLab
+
diff --git a/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
new file mode 100644
index 0000000000000..00e3f68a415b8
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
@@ -0,0 +1,28 @@
+From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
+From: Rainer Hochecker <fernetmenta@online.de>
+Date: Sat, 26 Jan 2019 19:48:35 +0100
+Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
+
+This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
+It was hit frequently when watching h264 channels received via DVB-X.
+Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
+---
+ libavcodec/vaapi_h264.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
+index 5854587a255..f12fdc457a4 100644
+--- a/libavcodec/vaapi_h264.c
++++ b/libavcodec/vaapi_h264.c
+@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
+     H264SliceContext *sl = &h->slice_ctx[0];
+     int ret;
+ 
++    if (pic->nb_slices == 0) {
++        ret = AVERROR_INVALIDDATA;
++        goto finish;
++    }
++
+     ret = ff_vaapi_decode_issue(avctx, pic);
+     if (ret < 0)
+         goto finish;
diff --git a/srcpkgs/ffmpeg4/template b/srcpkgs/ffmpeg4/template
new file mode 100644
index 0000000000000..9ba14bdb8ddf3
--- /dev/null
+++ b/srcpkgs/ffmpeg4/template
@@ -0,0 +1,234 @@
+# Template file for 'ffmpeg4'
+# audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
+pkgname=ffmpeg4
+version=4.4.4
+revision=1
+short_desc="Decoding, encoding and streaming software - ffmpeg4 libraries only"
+maintainer="Orphaned <orphan@voidlinux.org>"
+license="GPL-3.0-or-later"
+homepage="https://www.ffmpeg.org"
+changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
+distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
+checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+
+hostmakedepends="pkg-config perl"
+makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
+ libXext-devel libXvMC-devel libxcb-devel lame-devel libtheora-devel
+ libvorbis-devel x264-devel xvidcore-devel jack-devel SDL2-devel
+ libcdio-paranoia-devel librtmp-devel libmodplug-devel gnutls-devel
+ speex-devel celt-devel harfbuzz-devel libass-devel opus-devel ocl-icd-devel
+ libbs2b-devel libvidstab-devel vmaf-devel $(vopt_if pulseaudio pulseaudio-devel)
+ $(vopt_if vaapi libva-devel) $(vopt_if vdpau libvdpau-devel)
+ $(vopt_if x265 x265-devel) $(vopt_if v4l2 v4l-utils-devel)
+ $(vopt_if fdk_aac fdk-aac-devel) $(vopt_if vpx libvpx-devel)
+ $(vopt_if aom libaom-devel) $(vopt_if sndio sndio-devel)
+ $(vopt_if dav1d libdav1d-devel) $(vopt_if zimg zimg-devel)
+ $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
+ $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
+ $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
+
+build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
+
+desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
+desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
+desc_option_sofa="Enable support for AES SOFA"
+desc_option_webp="Enable support for WebP"
+
+case "$XBPS_TARGET_MACHINE" in
+	i686*|x86_64*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau nvenc nvdec"
+			;;
+	ppc64*) build_options_default+=" vaapi vdpau";;
+	mips*) CFLAGS="-mnan=legacy";;
+esac
+
+if [ "$XBPS_TARGET_WORDSIZE" != "32" ]; then
+	build_options_default+=" svtav1"
+fi
+
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+fi
+
+_apply_patch() {
+	local args="$1" pname="$(basename $2)"
+
+	if [ ! -f ".${pname}_done" ]; then
+		patch -N $args -i $2
+		touch .${pname}_done
+	fi
+}
+
+post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64le*) ;;
+		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
+	esac
+
+	vsed -i libavfilter/vf_libvmaf.c -e 's!/usr/local/share/model/\(vmaf_v0.6.1\).pkl!/usr/share/vmaf/\1.json!'
+}
+
+do_configure() {
+	# Fix gcc on x86_64-musl only
+	if [ "$XBPS_TARGET_MACHINE" = "x86_64-musl" ]; then
+		vsed -i configure -e "s;_cflags_speed='-O3';_cflags_speed='-O2';"
+	fi
+
+	if [ "$CROSS_BUILD" ]; then
+		case "$XBPS_TARGET_MACHINE" in
+			arm*) _arch="arm";;
+			aarch64*) _arch="aarch64";;
+			mips*) _arch="mips";;
+			ppc64*) _arch="ppc64";;
+			ppc*) _arch="ppc";;
+			*) _arch="${XBPS_TARGET_MACHINE%%-musl}";;
+		esac
+
+		_args+=" --enable-cross-compile
+			--sysroot=$XBPS_CROSS_BASE
+			--cross-prefix=${XBPS_CROSS_TRIPLET}-
+			--target-os=linux --arch=${_arch}"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc|ppc-musl) _args+=" --disable-altivec";;
+	esac
+
+	if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+		_args+=" --extra-libs=-latomic"
+	fi
+
+	./configure --prefix=/usr --disable-debug --enable-gpl --enable-gnutls \
+		--disable-stripping \
+		--enable-libcdio --enable-version3 --enable-runtime-cpudetect \
+		--enable-libmp3lame --enable-libvorbis --enable-libxvid \
+		--enable-libx264 $(vopt_enable vpx libvpx) --enable-libtheora \
+		--enable-shared --enable-static --enable-libxcb \
+		$(vopt_enable pulseaudio libpulse) --enable-libfreetype --enable-libmodplug \
+		--enable-libspeex --enable-libcelt --enable-libass \
+		--enable-libopus --enable-librtmp --enable-libjack \
+		$(vopt_if fdk_aac '--enable-nonfree --enable-libfdk-aac') \
+		--disable-libopencore_amrnb --disable-libopencore_amrwb \
+		--disable-libopenjpeg \
+		--enable-postproc --enable-opencl ${_args} --enable-libvmaf ${_args} \
+		$(vopt_enable x265 libx265) \
+		$(vopt_enable v4l2 libv4l2) \
+		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
+		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		$(vopt_enable dav1d libdav1d) \
+		$(vopt_enable zimg libzimg) \
+		$(vopt_enable webp libwebp) \
+		$(vopt_enable sofa libmysofa) \
+		$(vopt_enable vulkan) \
+		$(vopt_enable drm libdrm) \
+		$(vopt_enable svtav1 libsvtav1) \
+		$(vopt_enable srt libsrt) \
+		$(vopt_enable rist librist) \
+		$(vopt_if nvenc '--enable-nvenc') \
+		$(vopt_if nvdec '--enable-nvdec')
+}
+
+do_build() {
+	make ${makejobs}
+	make doc/ff{mpeg,play}.1
+}
+
+do_install() {
+	make DESTDIR=${DESTDIR} install install-man
+	rm -rf ${DESTDIR}/usr/bin
+}
+
+libavcodec4_package() {
+	short_desc="FFmpeg codec library"
+	pkg_install() {
+		vmove "usr/lib/libavcodec.so.*"
+	}
+}
+
+libavdevice4_package() {
+	short_desc="FFmpeg device handling library"
+	pkg_install() {
+		vmove "usr/lib/libavdevice.so.*"
+	}
+}
+
+libavresample4_package() {
+	short_desc="FFmpeg audio resampling library"
+	pkg_install() {
+		vmove "usr/lib/libavresample.so.*"
+	}
+}
+
+libavformat4_package() {
+	short_desc="FFmpeg file format library"
+	pkg_install() {
+		vmove "usr/lib/libavformat.so.*"
+	}
+}
+
+libavutil4_package() {
+	short_desc="FFmpeg utility library"
+	pkg_install() {
+		vmove "usr/lib/libavutil.so.*"
+	}
+}
+
+libavfilter4_package() {
+	short_desc="FFmpeg audio/video filter library"
+	pkg_install() {
+		vmove "usr/lib/libavfilter.so.*"
+	}
+}
+
+libpostproc4_package() {
+	short_desc="FFmpeg video postprocessing library"
+	pkg_install() {
+		vmove "usr/lib/libpostproc.so.*"
+	}
+}
+
+libswscale4_package() {
+	short_desc="FFmpeg video scaling library"
+	pkg_install() {
+		vmove "usr/lib/libswscale.so.*"
+	}
+}
+
+libswresample4_package() {
+	short_desc="FFmpeg video resampling library"
+	pkg_install() {
+		vmove "usr/lib/libswresample.so.*"
+	}
+}
+
+ffmpeg4-devel_package() {
+	depends="
+		libavcodec4>=${version}_${revision}
+		libavdevice4>=${version}_${revision}
+		libavformat4>=${version}_${revision}
+		libavutil4>=${version}_${revision}
+		libavfilter4>=${version}_${revision}
+		libpostproc4>=${version}_${revision}
+		libswscale4>=${version}_${revision}
+		libswresample4>=${version}_${revision}
+		libavresample4>=${version}_${revision}"
+	short_desc+=" - development files"
+	conflicts="ffmpeg-devel"
+	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
+		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
+		nostrip_files="/usr/lib/libavfilter.a"
+	fi
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.a"
+		vmove "usr/lib/*.so"
+		vmove usr/share/ffmpeg/examples
+		vmove usr/share/man/man3
+	}
+}
diff --git a/srcpkgs/libavcodec4 b/srcpkgs/libavcodec4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavcodec4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavdevice4 b/srcpkgs/libavdevice4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavdevice4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavfilter4 b/srcpkgs/libavfilter4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavfilter4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavformat4 b/srcpkgs/libavformat4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavformat4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavresample4 b/srcpkgs/libavresample4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavutil4 b/srcpkgs/libavutil4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libavutil4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libpostproc4 b/srcpkgs/libpostproc4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libpostproc4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswresample4 b/srcpkgs/libswresample4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libswresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswscale4 b/srcpkgs/libswscale4
new file mode 120000
index 0000000000000..887f354e7c6be
--- /dev/null
+++ b/srcpkgs/libswscale4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file

From 07a58064b3d5a6f7384d2198bffed8e1eae5a02e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:04 -0400
Subject: [PATCH 005/111] opencv: update to 4.7.0.

---
 common/shlibs           | 104 ++++++++++++++++++++--------------------
 srcpkgs/opencv/template |   8 ++--
 2 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index cc15fb5f63b4b..f826233e8612d 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2075,58 +2075,58 @@ libcapstone.so.5 capstone-5.0.1_1
 libhavege.so.2 libhaveged-1.9.11_1
 libnih.so.1 libnih-1.0.3_1
 libnih-dbus.so.1 libnih-1.0.3_1
-libopencv_quality.so.406 libopencv-4.6.0_1
-libopencv_reg.so.406 libopencv-4.6.0_1
-libopencv_surface_matching.so.406 libopencv-4.6.0_1
-libopencv_xphoto.so.406 libopencv-4.6.0_1
-libopencv_freetype.so.406 libopencv-4.6.0_1
-libopencv_fuzzy.so.406 libopencv-4.6.0_1
-libopencv_hfs.so.406 libopencv-4.6.0_1
-libopencv_img_hash.so.406 libopencv-4.6.0_1
-libopencv_line_descriptor.so.406 libopencv-4.6.0_1
-libopencv_saliency.so.406 libopencv-4.6.0_1
-libopencv_structured_light.so.406 libopencv-4.6.0_1
-libopencv_aruco.so.406 libopencv-4.6.0_1
-libopencv_bgsegm.so.406 libopencv-4.6.0_1
-libopencv_bioinspired.so.406 libopencv-4.6.0_1
-libopencv_ccalib.so.406 libopencv-4.6.0_1
-libopencv_face.so.406 libopencv-4.6.0_1
-libopencv_tracking.so.406 libopencv-4.6.0_1
-libopencv_xfeatures2d.so.406 libopencv-4.6.0_1
-libopencv_optflow.so.406 libopencv-4.6.0_1
-libopencv_ximgproc.so.406 libopencv-4.6.0_1
-libopencv_plot.so.406 libopencv-4.6.0_1
-libopencv_text.so.406 libopencv-4.6.0_1
-libopencv_ml.so.406 libopencv-4.6.0_1
-libopencv_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn.so.406 libopencv-4.6.0_1
-libopencv_shape.so.406 libopencv-4.6.0_1
-libopencv_stitching.so.406 libopencv-4.6.0_1
-libopencv_photo.so.406 libopencv-4.6.0_1
-libopencv_video.so.406 libopencv-4.6.0_1
-libopencv_calib3d.so.406 libopencv-4.6.0_1
-libopencv_features2d.so.406 libopencv-4.6.0_1
-libopencv_flann.so.406 libopencv-4.6.0_1
-libopencv_highgui.so.406 libopencv-4.6.0_1
-libopencv_videoio.so.406 libopencv-4.6.0_1
-libopencv_imgcodecs.so.406 libopencv-4.6.0_1
-libopencv_imgproc.so.406 libopencv-4.6.0_1
-libopencv_core.so.406 libopencv-4.6.0_1
-libopencv_superres.so.406 libopencv-4.6.0_1
-libopencv_videostab.so.406 libopencv-4.6.0_1
-libopencv_gapi.so.406 libopencv-4.6.0_1
-libopencv_xobjdetect.so.406 libopencv-4.6.0_1
-libopencv_datasets.so.406 libopencv-4.6.0_1
-libopencv_dnn_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn_superres.so.406 libopencv-4.6.0_1
-libopencv_dpm.so.406 libopencv-4.6.0_1
-libopencv_phase_unwrapping.so.406 libopencv-4.6.0_1
-libopencv_stereo.so.406 libopencv-4.6.0_1
-libopencv_rapid.so.406 libopencv-4.6.0_1
-libopencv_intensity_transform.so.406 libopencv-4.6.0_1
-libopencv_alphamat.so.406 libopencv-4.6.0_1
-libopencv_barcode.so.406 libopencv-4.6.0_1
-libopencv_mcc.so.406 libopencv-4.6.0_1
+libopencv_quality.so.407 libopencv-4.7.0_1
+libopencv_reg.so.407 libopencv-4.7.0_1
+libopencv_surface_matching.so.407 libopencv-4.7.0_1
+libopencv_xphoto.so.407 libopencv-4.7.0_1
+libopencv_freetype.so.407 libopencv-4.7.0_1
+libopencv_fuzzy.so.407 libopencv-4.7.0_1
+libopencv_hfs.so.407 libopencv-4.7.0_1
+libopencv_img_hash.so.407 libopencv-4.7.0_1
+libopencv_line_descriptor.so.407 libopencv-4.7.0_1
+libopencv_saliency.so.407 libopencv-4.7.0_1
+libopencv_structured_light.so.407 libopencv-4.7.0_1
+libopencv_aruco.so.407 libopencv-4.7.0_1
+libopencv_bgsegm.so.407 libopencv-4.7.0_1
+libopencv_bioinspired.so.407 libopencv-4.7.0_1
+libopencv_ccalib.so.407 libopencv-4.7.0_1
+libopencv_face.so.407 libopencv-4.7.0_1
+libopencv_tracking.so.407 libopencv-4.7.0_1
+libopencv_xfeatures2d.so.407 libopencv-4.7.0_1
+libopencv_optflow.so.407 libopencv-4.7.0_1
+libopencv_ximgproc.so.407 libopencv-4.7.0_1
+libopencv_plot.so.407 libopencv-4.7.0_1
+libopencv_text.so.407 libopencv-4.7.0_1
+libopencv_ml.so.407 libopencv-4.7.0_1
+libopencv_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn.so.407 libopencv-4.7.0_1
+libopencv_shape.so.407 libopencv-4.7.0_1
+libopencv_stitching.so.407 libopencv-4.7.0_1
+libopencv_photo.so.407 libopencv-4.7.0_1
+libopencv_video.so.407 libopencv-4.7.0_1
+libopencv_calib3d.so.407 libopencv-4.7.0_1
+libopencv_features2d.so.407 libopencv-4.7.0_1
+libopencv_flann.so.407 libopencv-4.7.0_1
+libopencv_highgui.so.407 libopencv-4.7.0_1
+libopencv_videoio.so.407 libopencv-4.7.0_1
+libopencv_imgcodecs.so.407 libopencv-4.7.0_1
+libopencv_imgproc.so.407 libopencv-4.7.0_1
+libopencv_core.so.407 libopencv-4.7.0_1
+libopencv_superres.so.407 libopencv-4.7.0_1
+libopencv_videostab.so.407 libopencv-4.7.0_1
+libopencv_gapi.so.407 libopencv-4.7.0_1
+libopencv_xobjdetect.so.407 libopencv-4.7.0_1
+libopencv_datasets.so.407 libopencv-4.7.0_1
+libopencv_dnn_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn_superres.so.407 libopencv-4.7.0_1
+libopencv_dpm.so.407 libopencv-4.7.0_1
+libopencv_phase_unwrapping.so.407 libopencv-4.7.0_1
+libopencv_stereo.so.407 libopencv-4.7.0_1
+libopencv_rapid.so.407 libopencv-4.7.0_1
+libopencv_intensity_transform.so.407 libopencv-4.7.0_1
+libopencv_alphamat.so.407 libopencv-4.7.0_1
+libopencv_barcode.so.407 libopencv-4.7.0_1
+libopencv_mcc.so.407 libopencv-4.7.0_1
 libuniconf.so.4.6 wvstreams-4.6.1_20
 libwvbase.so.4.6 wvstreams-4.6.1_20
 libwvutils.so.4.6 wvstreams-4.6.1_20
diff --git a/srcpkgs/opencv/template b/srcpkgs/opencv/template
index aea4bfc3a265c..ce94de9424d18 100644
--- a/srcpkgs/opencv/template
+++ b/srcpkgs/opencv/template
@@ -1,7 +1,7 @@
 # Template file for 'opencv'
 pkgname=opencv
-version=4.6.0
-revision=6
+version=4.7.0
+revision=1
 create_wrksrc=yes
 build_wrksrc=${pkgname}-${version}
 build_style=cmake
@@ -24,8 +24,8 @@ homepage="https://opencv.org"
 changelog="https://github.com/opencv/opencv/wiki/ChangeLog"
 distfiles="https://github.com/opencv/opencv/archive/${version}.tar.gz
  https://github.com/opencv/opencv_contrib/archive/${version}.tar.gz>contrib.tar.gz"
-checksum="1ec1cba65f9f20fe5a41fda1586e01c70ea0c9a6d7b67c9e13edf0cfe2239277
- 1777d5fd2b59029cf537e5fd6f8aa68d707075822f90bde683fcde086f85f7a7"
+checksum="8df0079cdbe179748a18d44731af62a245a45ebf5085223dc03133954c662973
+ 42df840cf9055e59d0e22c249cfb19f04743e1bdad113d31b1573d3934d62584"
 patch_args="-Np1 -d ${build_wrksrc}"
 # tests hang indenfinitely, even with test data included
 make_check=no

From 28ce7088671c9bf8a427158518bd523949409255 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 006/111] actiona: revbump for opencv-4.7.0

---
 srcpkgs/actiona/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/actiona/template b/srcpkgs/actiona/template
index cf5f0b7a2ae61..0d899311e6df7 100644
--- a/srcpkgs/actiona/template
+++ b/srcpkgs/actiona/template
@@ -1,7 +1,7 @@
 # Template file for 'actiona'
 pkgname=actiona
 version=3.10.1
-revision=2
+revision=3
 build_style=qmake
 configure_args="PKGCONFIG_OPENCV=opencv4"
 hostmakedepends="pkg-config qt5-plugin-mysql qt5-qmake qt5-host-tools"

From a5ebeebbeed038e577d8d99b7b525f2c759f2b8d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 007/111] retroshare: revbump for opencv-4.7.0

---
 srcpkgs/retroshare/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroshare/template b/srcpkgs/retroshare/template
index bb17569277a7f..49e2c1cbe8a53 100644
--- a/srcpkgs/retroshare/template
+++ b/srcpkgs/retroshare/template
@@ -1,7 +1,7 @@
 # Template file for 'retroshare'
 pkgname=retroshare
 version=0.6.6
-revision=3
+revision=4
 build_style=qmake
 #XXX broadcast feature requires an ancient udp-discovery-cpp which either needs
 # to be fetched+patched (FTBFS) here or packaged :/

From d2cb825ba10d4fe4ef613c122a093e6db76ab665 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 008/111] waifu2x-converter-cpp: revbump for opencv-4.7.0

---
 srcpkgs/waifu2x-converter-cpp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waifu2x-converter-cpp/template b/srcpkgs/waifu2x-converter-cpp/template
index 361b8a23b9497..c5ac17eb54ea4 100644
--- a/srcpkgs/waifu2x-converter-cpp/template
+++ b/srcpkgs/waifu2x-converter-cpp/template
@@ -1,7 +1,7 @@
 # Template file for 'waifu2x-converter-cpp'
 pkgname=waifu2x-converter-cpp
 version=5.2.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DINSTALL_MODELS=ON"
 hostmakedepends="pkg-config"

From a22046d05f504836ee61debab887bfb7a4d54402 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:38 -0400
Subject: [PATCH 009/111] vlc: revbump for ffmpeg4

---
 srcpkgs/vlc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/vlc/template b/srcpkgs/vlc/template
index bdd0cc414dc1a..7d245a7b0019c 100644
--- a/srcpkgs/vlc/template
+++ b/srcpkgs/vlc/template
@@ -1,7 +1,7 @@
 # Template file for 'vlc'
 pkgname=vlc
 version=3.0.20
-revision=3
+revision=4
 build_style=gnu-configure
 configure_args="--disable-gme --disable-libtar --enable-jack
  --enable-live555 --disable-fluidsynth --enable-dvdread
@@ -25,7 +25,7 @@ lib32disabled=yes
 hostmakedepends="automake libtool pkg-config flex gettext libgcrypt-devel
  live555-devel gettext-devel $(vopt_if lua lua52) $(vopt_if chromecast protobuf)"
 makedepends="
- avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg-devel freefont-ttf
+ avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg4-devel freefont-ttf
  gnutls-devel jack-devel liba52-devel libass-devel libbluray-devel
  libcdio-devel libdca-devel libdvbpsi-devel libdvdnav-devel libmad-devel
  libmatroska-devel libmodplug-devel libmpcdec-devel libmpeg2-devel

From 796c7f4a1ac1efc627449cc55438cb8861bcb89a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:55 -0400
Subject: [PATCH 010/111] osg: revbump for ffmpeg4

---
 srcpkgs/osg/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/osg/template b/srcpkgs/osg/template
index a9ebbd287933b..a131ceaf7a867 100644
--- a/srcpkgs/osg/template
+++ b/srcpkgs/osg/template
@@ -1,14 +1,14 @@
 # Template file for 'osg'
 pkgname=osg
 version=3.6.5
-revision=2
+revision=3
 build_style=cmake
 build_helper="qemu"
 # don't use /usr/lib64 on 64bit platforms
 configure_args="-DLIB_POSTFIX="
 hostmakedepends="pkg-config xrandr"
 makedepends="MesaLib-devel gtkglext-devel libcurl-devel giflib-devel librsvg-devel
- jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg-devel xine-lib-devel
+ jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg4-devel xine-lib-devel
  SDL2-devel gst-plugins-base1-devel
  $(vopt_if openexr libopenexr-devel)
  $(vopt_if poppler poppler-glib-devel)

From ae58d13974c73e5229c5da2fc53aa41691e569fd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:13 -0400
Subject: [PATCH 011/111] xine-lib: revbump for ffmpeg4

---
 srcpkgs/xine-lib/template | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/xine-lib/template b/srcpkgs/xine-lib/template
index 3be4d08eac77a..ed6194c17d11e 100644
--- a/srcpkgs/xine-lib/template
+++ b/srcpkgs/xine-lib/template
@@ -1,14 +1,14 @@
 # Template file for 'xine-lib'
 pkgname=xine-lib
-version=1.2.12
-revision=3
+version=1.2.13
+revision=1
 build_style=gnu-configure
 configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
  --disable-oss"
 hostmakedepends="automake gettext-devel libtool pkg-config perl"
 makedepends="
  zlib-devel alsa-lib-devel libxcb-devel libSM-devel libXext-devel libXv-devel
- libXvMC-devel liba52-devel libmad-devel ffmpeg-devel pulseaudio-devel
+ libXvMC-devel liba52-devel libmad-devel ffmpeg4-devel pulseaudio-devel
  jack-devel samba-devel libflac-devel libmodplug-devel libmpcdec-devel
  speex-devel libtheora-devel libvorbis-devel libdca-devel faad2-devel
  libcdio-devel libbluray-devel aalib-devel libcaca-devel libXinerama-devel
@@ -19,7 +19,7 @@ license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="http://www.xine-project.org"
 changelog="https://sourceforge.net/projects/xine/files/xine-lib/${version}/README.txt/view"
 distfiles="${SOURCEFORGE_SITE}/xine/${pkgname}-${version}.tar.xz"
-checksum=d606270468e1540c2a89c0d7f5fdf11e17ecc0c2698cc0bcb1065ff26abee098
+checksum=5f10d6d718a4a51c17ed1b32b031d4f9b80b061e8276535b2be31e5ac4b75e6f
 
 case "$XBPS_TARGET_MACHINE" in
 	i686-musl)

From c8a611ed7a88984332e251ff742635f0364cd93c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 012/111] attract: revbump for ffmpeg6

---
 srcpkgs/attract/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/attract/template b/srcpkgs/attract/template
index e769fb1545621..776cbe4ebd2c9 100644
--- a/srcpkgs/attract/template
+++ b/srcpkgs/attract/template
@@ -1,7 +1,7 @@
 # Template file for 'attract'
 pkgname=attract
 version=2.7.0
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="VERBOSE=1"
 make_use_env=yes

From f94a8c8d2bde74d2851ef3b0c927dc47fd759613 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 013/111] aubio: revbump for ffmpeg6

---
 srcpkgs/aubio/patches/ffmpeg5.patch | 25 +++++++++++++++++++++++++
 srcpkgs/aubio/template              |  2 +-
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/aubio/patches/ffmpeg5.patch

diff --git a/srcpkgs/aubio/patches/ffmpeg5.patch b/srcpkgs/aubio/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..aace41a6e6d9a
--- /dev/null
+++ b/srcpkgs/aubio/patches/ffmpeg5.patch
@@ -0,0 +1,25 @@
+From 8a05420e5dd8c7b8b2447f82dc919765876511b3 Mon Sep 17 00:00:00 2001
+From: Paul Brossier <piem@piem.org>
+Date: Tue, 25 Jan 2022 18:30:27 +0100
+Subject: [PATCH] [source_avcodec] define FF_API_LAVF_AVCTX for libavcodec >
+ 59, thx @berolinux (closes gh-353)
+
+---
+ src/io/source_avcodec.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/io/source_avcodec.c b/src/io/source_avcodec.c
+index e0ae93b5..1421bd9a 100644
+--- a/src/io/source_avcodec.c
++++ b/src/io/source_avcodec.c
+@@ -68,6 +68,10 @@
+ #define AUBIO_AVCODEC_MAX_BUFFER_SIZE AV_INPUT_BUFFER_MIN_SIZE
+ #endif
+ 
++#if LIBAVCODEC_VERSION_MAJOR >= 59
++#define FF_API_LAVF_AVCTX 1
++#endif
++
+ struct _aubio_source_avcodec_t {
+   uint_t hop_size;
+   uint_t samplerate;
diff --git a/srcpkgs/aubio/template b/srcpkgs/aubio/template
index ad1c4b2569917..7d875cc02541a 100644
--- a/srcpkgs/aubio/template
+++ b/srcpkgs/aubio/template
@@ -1,7 +1,7 @@
 # Template file for 'aubio'
 pkgname=aubio
 version=0.4.9
-revision=1
+revision=2
 build_style=waf3
 # XXX lash, pure and swig support.
 hostmakedepends="pkg-config txt2man"

From dd439d59bfd1ed2a9cd72cf4cea2228f60777360 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 014/111] audacious-plugins: revbump for ffmpeg6

---
 .../audacious-plugins/patches/ffmpeg5.patch   | 43 +++++++++++++++++++
 srcpkgs/audacious-plugins/template            |  2 +-
 2 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/audacious-plugins/patches/ffmpeg5.patch

diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg5.patch b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..4e5e34099d71c
--- /dev/null
+++ b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
@@ -0,0 +1,43 @@
+commit 298aa371c56c2f52c25a33d9bdec4918b11cebdc
+Author: tibequadorian <tibequadorian@posteo.de>
+Date:   Sat Mar 19 18:40:12 2022 +0100
+
+    audacious-plugins: rebuild against ffmpeg-5.0
+
+diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+new file mode 100644
+index 0000000000..617c11215b
+--- /dev/null
++++ b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+@@ -0,0 +1,31 @@
++From f60beb400eeb1e4778bbfd738bc4a4ccef3de539 Mon Sep 17 00:00:00 2001
++From: John Lindgren <john@jlindgren.net>
++Date: Sat, 5 Mar 2022 12:05:34 -0500
++Subject: [PATCH] Fix build with FFmpeg 5.0
++
++---
++ src/ffaudio/ffaudio-core.cc | 4 ++--
++ 1 file changed, 2 insertions(+), 2 deletions(-)
++
++diff --git a/src/ffaudio/ffaudio-core.cc b/src/ffaudio/ffaudio-core.cc
++index 16dc63e3a..a2b95fd6c 100644
++--- a/src/ffaudio/ffaudio-core.cc
+++++ b/src/ffaudio/ffaudio-core.cc
++@@ -274,7 +274,7 @@ static AVInputFormat * get_format_by_content (const char * name, VFSFile & file)
++         AVProbeData d = {name, buf, filled};
++         score = target;
++ 
++-        f = av_probe_input_format2 (& d, true, & score);
+++        f = (AVInputFormat *) av_probe_input_format2 (& d, true, & score);
++         if (f)
++             break;
++ 
++@@ -347,7 +347,7 @@ static bool find_codec (AVFormatContext * c, CodecInfo * cinfo)
++ #endif
++         if (stream && stream->codecpar && stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
++         {
++-            AVCodec * codec = avcodec_find_decoder (stream->codecpar->codec_id);
+++            AVCodec * codec = (AVCodec *) avcodec_find_decoder (stream->codecpar->codec_id);
++ 
++             if (codec)
++             {
diff --git a/srcpkgs/audacious-plugins/template b/srcpkgs/audacious-plugins/template
index 05e53a9adf78f..4b1968e03de78 100644
--- a/srcpkgs/audacious-plugins/template
+++ b/srcpkgs/audacious-plugins/template
@@ -2,7 +2,7 @@
 #Keep in sync with audacious!
 pkgname=audacious-plugins
 version=4.3.1
-revision=3
+revision=4
 build_style=meson
 configure_args="$(vopt_bool gtk3 gtk) $(vopt_bool gtk3)
  $(vopt_bool qt) $(vopt_bool qt qt6)"

From 7415edf89ea11b5037a2905cf7c5224e0d4ae86f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 015/111] audacity: revbump for ffmpeg6

---
 srcpkgs/audacity/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/audacity/template b/srcpkgs/audacity/template
index 7b838119ab261..84b49305edcef 100644
--- a/srcpkgs/audacity/template
+++ b/srcpkgs/audacity/template
@@ -1,7 +1,7 @@
 # Template file for 'audacity'
 pkgname=audacity
 version=3.4.2
-revision=1
+revision=2
 build_style=cmake
 build_helper="cmake-wxWidgets-gtk3 qemu"
 configure_args="-Daudacity_use_ffmpeg=loaded -Daudacity_lib_preference=system

From c5b059632dd71a198e7b8e14b397c9be86c6e371 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 016/111] avidemux: revbump for ffmpeg6

---
 srcpkgs/avidemux/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/avidemux/template b/srcpkgs/avidemux/template
index 253a0243e2259..557285982d2b8 100644
--- a/srcpkgs/avidemux/template
+++ b/srcpkgs/avidemux/template
@@ -1,7 +1,7 @@
 # Template file for 'avidemux'
 pkgname=avidemux
 version=2.8.0
-revision=2
+revision=3
 # Can't be compiled for aarch64, arm* or mips*
 archs="x86_64* i686*"
 hostmakedepends="cmake pkg-config qt5-host-tools qt5-devel tar yasm"

From 0c35a5409ed9c52c3240a83480265a2eb4f891ec Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 017/111] blender: revbump for ffmpeg6

---
 srcpkgs/blender/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index 1dc61ec9d29d8..e238717ac8c72 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -1,7 +1,7 @@
 # Template file for 'blender'
 pkgname=blender
 version=4.0.2
-revision=1
+revision=2
 archs="x86_64* ppc64*"
 build_style="cmake"
 pycompile_dirs="usr/share/blender/${version%.*}/scripts"
@@ -9,8 +9,8 @@ configure_args="-DWITH_INSTALL_PORTABLE=OFF -DWITH_PYTHON_INSTALL=OFF
  -DWITH_JACK=ON -DWITH_CODEC_FFMPEG=ON -DWITH_CODEC_SNDFILE=ON -DWITH_OPENMP=ON
  -DWITH_FFTW3=ON -DWITH_MOD_OCEANSIM=ON -DWITH_CYCLES_EMBREE=OFF -DWITH_OPENCOLORIO=ON
  -DWITH_IMAGE_OPENEXR=ON -DWITH_IMAGE_OPENJPEG=ON -DWITH_OPENSUBDIV=ON
- -DWITH_OPENCOLLADA=ON -DWITH_SYSTEM_GLEW=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
- -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_LIBDECOR=ON
+ -DWITH_OPENCOLLADA=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
+ -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_WAYLAND_LIBDECOR=ON
  -DWITH_BUILDINFO=OFF -DPYTHON_VERSION=${py3_ver} -DPYTHON_LIBPATH=/usr/lib
  -DPYTHON_LIBRARY=python${py3_ver}${py3_abiver} -DPYTHON_INCLUDE_DIRS=/${py3_inc}
  -DWITH_SYSTEM_LZO=ON -DWITH_SYSTEM_EIGEN3=ON -DWITH_SYSTEM_FREETYPE=ON"

From 8ef4b2be68d53acc2025f0b4ce6d6b07aeb51656 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 018/111] cantata: revbump for ffmpeg6

---
 srcpkgs/cantata/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cantata/template b/srcpkgs/cantata/template
index 4b417d80d5c2d..8a90aaa4c07a2 100644
--- a/srcpkgs/cantata/template
+++ b/srcpkgs/cantata/template
@@ -1,7 +1,7 @@
 # Template file for 'cantata'
 pkgname=cantata
 version=2.5.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools qt5-tools"
 makedepends="qt5-devel qt5-tools-devel qt5-svg-devel qt5-xmlpatterns-devel

From ce0d365828c9c3d37d8ad65f6c7dacf8c889983b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 019/111] ccextractor: revbump for ffmpeg6

---
 ...5-and-tesseract-5-compatibility-1479.patch | 168 ++++++++++++++++++
 srcpkgs/ccextractor/template                  |   2 +-
 2 files changed, 169 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ccextractor/patches/0001-fix-ffmpeg-5-and-tesseract-5-compatibility-1479.patch

diff --git a/srcpkgs/ccextractor/patches/0001-fix-ffmpeg-5-and-tesseract-5-compatibility-1479.patch b/srcpkgs/ccextractor/patches/0001-fix-ffmpeg-5-and-tesseract-5-compatibility-1479.patch
new file mode 100644
index 0000000000000..bcab4890554b9
--- /dev/null
+++ b/srcpkgs/ccextractor/patches/0001-fix-ffmpeg-5-and-tesseract-5-compatibility-1479.patch
@@ -0,0 +1,168 @@
+From b1cbfcea9b9c687143bf0d80bc179b563e99d025 Mon Sep 17 00:00:00 2001
+From: Prateek Sunal <prtksunal@gmail.com>
+Date: Thu, 9 Mar 2023 01:44:53 +0530
+Subject: [PATCH] fix: ffmpeg 5 and tesseract 5 compatibility (#1479)
+
+* fix: replace deprecated `codec` property with `codecpar`
+
+* fix: replace deprecated method `avcodec_decode_video2` with `avcodec_receive_frame` and `avcodec_send_packet`
+
+* Update CHANGES.TXT
+
+* fix: remove deprecated `av_register_all` function
+
+* fix: formatting
+
+* fix: add support for tesseract 5
+
+* fix: tesseract v5
+
+* fix: hardsubx codec context error
+
+* fix: lint const warning
+---
+ docs/CHANGES.TXT               |  1 +
+ src/lib_ccx/ffmpeg_intgr.c     |  7 +++---
+ src/lib_ccx/hardsubx.c         | 25 ++++++++++++------
+ src/lib_ccx/hardsubx_decoder.c | 27 ++++++++------------
+ src/lib_ccx/ocr.c              | 46 ++++++++++++----------------------
+ 5 files changed, 47 insertions(+), 59 deletions(-)
+
+diff --git a/src/lib_ccx/ffmpeg_intgr.c b/src/lib_ccx/ffmpeg_intgr.c
+index be988890..e6f21e20 100644
+--- a/src/lib_ccx/ffmpeg_intgr.c
++++ b/src/lib_ccx/ffmpeg_intgr.c
+@@ -66,7 +66,6 @@ void *init_ffmpeg(const char *path)
+ 	struct ffmpeg_ctx *ctx;
+ 	AVCodec *dec = NULL;
+ 	avcodec_register_all();
+-	av_register_all();
+ 
+ 	if (ccx_options.debug_mask & CCX_DMT_VERBOSE)
+ 		av_log_set_level(AV_LOG_INFO);
+@@ -133,7 +132,6 @@ int ff_get_ccframe(void *arg, unsigned char *data, int maxlen)
+ 	struct ffmpeg_ctx *ctx = arg;
+ 	int len = 0;
+ 	int ret = 0;
+-	int got_frame;
+ 	AVPacket packet;
+ 
+ 	ret = av_read_frame(ctx->ifmt, &packet);
+@@ -151,12 +149,13 @@ int ff_get_ccframe(void *arg, unsigned char *data, int maxlen)
+ 		return AVERROR(EAGAIN);
+ 	}
+ 
+-	ret = avcodec_decode_video2(ctx->dec_ctx, ctx->frame, &got_frame, &packet);
++	avcodec_send_packet(ctx->codec_ctx, &ctx->packet);
++	ret = avcodec_receive_frame(ctx->dec_ctx, ctx->frame);
+ 	if (ret < 0)
+ 	{
+ 		av_log(NULL, AV_LOG_ERROR, "unable to decode packet\n");
+ 	}
+-	else if (!got_frame)
++	else if (ret != 0)
+ 	{
+ 		return AVERROR(EAGAIN);
+ 	}
+diff --git a/src/lib_ccx/hardsubx.c b/src/lib_ccx/hardsubx.c
+index 411377f9..fb844c91 100644
+--- a/src/lib_ccx/hardsubx.c
++++ b/src/lib_ccx/hardsubx.c
+@@ -12,9 +12,6 @@
+
+ int hardsubx_process_data(struct lib_hardsubx_ctx *ctx)
+ {
+-	// Get the required media attributes and initialize structures
+-	av_register_all();
+-
+ 	if (avformat_open_input(&ctx->format_ctx, ctx->inputfile[0], NULL, NULL) != 0)
+ 	{
+ 		fatal(EXIT_READ_ERROR, "Error reading input file!\n");
+@@ -32,7 +29,7 @@
+ 	ctx->video_stream_id = -1;
+ 	for (int i = 0; i < ctx->format_ctx->nb_streams; i++)
+ 	{
+-		if (ctx->format_ctx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO)
++		if (ctx->format_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
+ 		{
+ 			ctx->video_stream_id = i;
+ 			break;
+@@ -43,8 +40,21 @@
+ 		fatal(EXIT_READ_ERROR, "Video Stream not found!\n");
+ 	}
+
+-	ctx->codec_ctx = ctx->format_ctx->streams[ctx->video_stream_id]->codec;
+-	ctx->codec = avcodec_find_decoder(ctx->codec_ctx->codec_id);
++	ctx->codec_ctx = avcodec_alloc_context3(NULL);
++	if (!ctx->codec_ctx)
++	{
++		    fatal(EXIT_NOT_ENOUGH_MEMORY, "Could not allocate codec context!\n");
++	}
++
++	// Assign codec parameters to codec context
++	if (avcodec_parameters_to_context(ctx->codec_ctx, ctx->format_ctx->streams[ctx->video_stream_id]->codecpar) < 0)
++	{
++		    fatal(EXIT_READ_ERROR, "Could not initialize codec context!\n");
++	}
++
++	// Find decoder for the codec context
++	ctx->codec = (AVCodec *)avcodec_find_decoder(ctx->codec_ctx->codec_id);
++
+ 	if (ctx->codec == NULL)
+ 	{
+ 		fatal(EXIT_READ_ERROR, "Input codec is not supported!\n");
+diff --git a/src/lib_ccx/hardsubx_decoder.c b/src/lib_ccx/hardsubx_decoder.c
+index bd9b0980..b5dfaec4 100644
+--- a/src/lib_ccx/hardsubx_decoder.c
++++ b/src/lib_ccx/hardsubx_decoder.c
+@@ -371,7 +371,6 @@
+ int hardsubx_process_frames_tickertext(struct lib_hardsubx_ctx *ctx, struct encoder_ctx *enc_ctx)
+ {
+ 	// Search for ticker text at the bottom of the screen, such as in Russia TV1 or stock prices
+-	int got_frame;
+ 	int cur_sec = 0, total_sec, progress;
+ 	int frame_number = 0;
+ 	char *ticker_text = NULL;
+@@ -382,8 +381,8 @@
+ 		{
+ 			frame_number++;
+ 			//Decode the video stream packet
+-			avcodec_decode_video2(ctx->codec_ctx, ctx->frame, &got_frame, &ctx->packet);
+-			if (got_frame && frame_number % 1000 == 0)
++      avcodec_send_packet(ctx->codec_ctx, &ctx->packet);
++      if (avcodec_receive_frame(ctx->codec_ctx, ctx->frame) == 0 && frame_number % 1000 == 0)
+ 			{
+ 				// sws_scale is used to convert the pixel format to RGB24 from all other cases
+ 				sws_scale(
+@@ -434,9 +433,8 @@
+ 			frame_number++;
+
+ 			//Decode the video stream packet
+-			avcodec_decode_video2(ctx->codec_ctx, ctx->frame, &got_frame, &ctx->packet);
+-
+-			if (got_frame && frame_number % 25 == 0)
++			avcodec_send_packet(ctx->codec_ctx, &ctx->packet);
++      if (avcodec_receive_frame(ctx->codec_ctx, ctx->frame) == 0 && frame_number % 25 == 0)
+ 			{
+ 				float diff = (float)convert_pts_to_ms(ctx->packet.pts - prev_packet_pts, ctx->format_ctx->streams[ctx->video_stream_id]->time_base);
+ 				if (fabsf(diff) < 1000 * ctx->min_sub_duration) //If the minimum duration of a subtitle line is exceeded, process packet
+@@ -548,7 +546,6 @@
+ {
+ 	// Do a binary search over the input video for faster processing
+ 	// printf("Duration: %d\n", (int)ctx->format_ctx->duration);
+-	int got_frame;
+ 	int seconds_time = 0;
+ 	for (seconds_time = 0; seconds_time < 20; seconds_time++)
+ 	{
+@@ -568,8 +565,9 @@
+ 			{
+ 				if (ctx->packet.stream_index == ctx->video_stream_id)
+ 				{
+-					avcodec_decode_video2(ctx->codec_ctx, ctx->frame, &got_frame, &ctx->packet);
+-					if (got_frame)
++          avcodec_send_packet(ctx->codec_ctx, &ctx->packet);
++          if (avcodec_receive_frame(ctx->codec_ctx, ctx->frame) == 0)
++
+ 					{
+ 						// printf("%d\n", seek_time);
+ 						if (ctx->packet.pts < seek_time)
diff --git a/srcpkgs/ccextractor/template b/srcpkgs/ccextractor/template
index 84059ffd02398..a670758bcbe41 100644
--- a/srcpkgs/ccextractor/template
+++ b/srcpkgs/ccextractor/template
@@ -1,7 +1,7 @@
 # Template file for 'ccextractor'
 pkgname=ccextractor
 version=0.93
-revision=2
+revision=3
 build_wrksrc="linux"
 build_style=gnu-configure
 configure_args="--enable-ocr --enable-hardsubx"

From 408a6ac36e65ebcb732865a45713436a261b61e8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 020/111] chromaprint: revbump for ffmpeg6

---
 srcpkgs/chromaprint/patches/ffmpeg5.patch | 569 ++++++++++++++++++++++
 srcpkgs/chromaprint/template              |   2 +-
 2 files changed, 570 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromaprint/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromaprint/patches/ffmpeg5.patch b/srcpkgs/chromaprint/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..a9fd307a23c8a
--- /dev/null
+++ b/srcpkgs/chromaprint/patches/ffmpeg5.patch
@@ -0,0 +1,569 @@
+From 8ccad6937177b1b92e40ab8f4447ea27bac009a7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= <lalinsky@gmail.com>
+Date: Fri, 4 Nov 2022 21:47:38 +0100
+Subject: [PATCH] Use FFmpeg 5.x (#120)
+
+* Use FFmpeg 5.1.2 for CI builds
+
+* Build on Ubuntu 20.04
+
+* Upgrade code to FFmpeg 5.x APIs
+
+* Only set FFmpeg include dirs if building tools
+
+* No longer needed
+
+* Use ubuntu 20.04
+---
+ .github/workflows/build.yml                   |   6 +-
+ CMakeLists.txt                                |  16 --
+ package/build.sh                              |   4 +-
+ src/audio/ffmpeg_audio_processor.h            |   2 -
+ src/audio/ffmpeg_audio_processor_avresample.h |  72 -------
+ src/audio/ffmpeg_audio_processor_swresample.h |  18 +-
+ src/audio/ffmpeg_audio_reader.h               | 197 +++++++++---------
+ tests/CMakeLists.txt                          |   6 +
+ 8 files changed, 122 insertions(+), 199 deletions(-)
+ delete mode 100644 src/audio/ffmpeg_audio_processor_avresample.h
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index f8d6a32..4da2405 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -84,9 +84,6 @@ find_package(FFmpeg)
+ if(FFMPEG_LIBRARIES)
+ 	cmake_push_check_state(RESET)
+ 	set(CMAKE_REQUIRED_LIBRARIES ${FFMPEG_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -lm)
+-	check_function_exists(av_packet_unref HAVE_AV_PACKET_UNREF)
+-	check_function_exists(av_frame_alloc HAVE_AV_FRAME_ALLOC)
+-	check_function_exists(av_frame_free HAVE_AV_FRAME_FREE)
+ 	cmake_pop_check_state()
+ endif()
+
+@@ -163,14 +160,11 @@ message(STATUS "Using ${FFT_LIB} for FFT calculations")
+ if(NOT AUDIO_PROCESSOR_LIB)
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+ 		set(AUDIO_PROCESSOR_LIB "swresample")
+-	elseif(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(AUDIO_PROCESSOR_LIB "avresample")
+ 	endif()
+ endif()
+
+ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE OFF)
+ 		set(USE_SWRESAMPLE ON)
+ 		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBSWRESAMPLE_LIBRARIES})
+ 		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBSWRESAMPLE_INCLUDE_DIRS})
+@@ -178,16 +172,6 @@ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+ 	endif()
+ 	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+-elseif(AUDIO_PROCESSOR_LIB STREQUAL "avresample")
+-	if(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE ON)
+-		set(USE_SWRESAMPLE OFF)
+-		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBAVRESAMPLE_LIBRARIES})
+-		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBAVRESAMPLE_INCLUDE_DIRS})
+-	else()
+-		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+-	endif()
+-	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+ else()
+ 	message(STATUS "Building without audio conversion support, please install FFmpeg with libswresample")
+ endif()
+diff --git a/package/build.sh b/package/build.sh
+index da631ae..b41d36e 100755
+--- a/package/build.sh
++++ b/package/build.sh
+@@ -7,8 +7,8 @@ set -eux
+
+ BASE_DIR=$(cd $(dirname $0)/.. && pwd)
+
+-FFMPEG_VERSION=4.4.1
+-FFMPEG_BUILD_TAG=v4.4.1-1
++FFMPEG_VERSION=5.1.2
++FFMPEG_BUILD_TAG=v${FFMPEG_VERSION}-1
+
+ TMP_BUILD_DIR=$BASE_DIR/$(mktemp -d build.XXXXXXXX)
+ trap 'rm -rf $TMP_BUILD_DIR' EXIT
+diff --git a/src/audio/ffmpeg_audio_processor.h b/src/audio/ffmpeg_audio_processor.h
+index 7628fc7..39f4f6d 100644
+--- a/src/audio/ffmpeg_audio_processor.h
++++ b/src/audio/ffmpeg_audio_processor.h
+@@ -10,8 +10,6 @@
+
+ #if defined(USE_SWRESAMPLE)
+ #include "audio/ffmpeg_audio_processor_swresample.h"
+-#elif defined(USE_AVRESAMPLE)
+-#include "audio/ffmpeg_audio_processor_avresample.h"
+ #else
+ #error "no audio processing library"
+ #endif
+diff --git a/src/audio/ffmpeg_audio_processor_avresample.h b/src/audio/ffmpeg_audio_processor_avresample.h
+deleted file mode 100644
+index bd85f92..0000000
+--- a/src/audio/ffmpeg_audio_processor_avresample.h
++++ /dev/null
+@@ -1,72 +0,0 @@
+-// Copyright (C) 2016  Lukas Lalinsky
+-// Distributed under the MIT license, see the LICENSE file for details.
+-
+-#ifndef CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-#define CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-
+-extern "C" {
+-#include <libavresample/avresample.h>
+-}
+-
+-namespace chromaprint {
+-
+-class FFmpegAudioProcessor {
+-public:
+-	FFmpegAudioProcessor() {
+-		m_resample_ctx = avresample_alloc_context();
+-	}
+-
+-	~FFmpegAudioProcessor() {
+-		avresample_free(&m_resample_ctx);
+-	}
+-
+-	void SetCompatibleMode() {
+-		av_opt_set_int(m_resample_ctx, "filter_size", 16, 0);
+-		av_opt_set_int(m_resample_ctx, "phase_shift", 8, 0);
+-		av_opt_set_int(m_resample_ctx, "linear_interp", 1, 0);
+-		av_opt_set_double(m_resample_ctx, "cutoff", 0.8, 0);
+-	}
+-
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "in_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_rate", sample_rate, 0);
+-	}
+-
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "out_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_rate, 0);
+-	}
+-
+-	int Init() {
+-		return avresample_open(m_resample_ctx);
+-	}
+-
+-	int Convert(uint8_t **out, int out_count, const uint8_t **in, int in_count) {
+-		return avresample_convert(m_resample_ctx, out, 0, out_count, (uint8_t **) in, 0, in_count);
+-	}
+-
+-	int Flush(uint8_t **out, int out_count) {
+-		return avresample_read(m_resample_ctx, out, out_count);
+-	}
+-
+-private:
+-	AVAudioResampleContext *m_resample_ctx = nullptr;
+-};
+-
+-}; // namespace chromaprint
+-
+-#endif
+diff --git a/src/audio/ffmpeg_audio_processor_swresample.h b/src/audio/ffmpeg_audio_processor_swresample.h
+index b86266b..b1d4bea 100644
+--- a/src/audio/ffmpeg_audio_processor_swresample.h
++++ b/src/audio/ffmpeg_audio_processor_swresample.h
+@@ -28,30 +28,28 @@ public:
+ 		av_opt_set_double(m_swr_ctx, "cutoff", 0.8, 0);
+ 	}
+
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "icl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "ich", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetInputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "in_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "isf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "in_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "isr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "in_sample_rate", sample_rate, 0);
+ 	}
+
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "ocl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "och", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetOutputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "out_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "osf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "out_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "osr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "out_sample_rate", sample_rate, 0);
+ 	}
+
+ 	int Init() {
+diff --git a/src/audio/ffmpeg_audio_reader.h b/src/audio/ffmpeg_audio_reader.h
+index 5550164..1c6b346 100644
+--- a/src/audio/ffmpeg_audio_reader.h
++++ b/src/audio/ffmpeg_audio_reader.h
+@@ -62,7 +62,7 @@ public:
+ 	bool Read(const int16_t **data, size_t *size);
+
+ 	bool IsOpen() const { return m_opened; }
+-	bool IsFinished() const { return m_finished && !m_got_frame; }
++	bool IsFinished() const { return !m_has_more_packets && !m_has_more_frames; }
+
+ 	std::string GetError() const { return m_error; }
+ 	int GetErrorCode() const { return m_error_code; }
+@@ -74,20 +74,19 @@ private:
+ 	uint8_t *m_convert_buffer[1] = { nullptr };
+ 	int m_convert_buffer_nb_samples = 0;
+
+-	AVInputFormat *m_input_fmt = nullptr;
++	const AVInputFormat *m_input_fmt = nullptr;
+ 	AVDictionary *m_input_opts = nullptr;
+
+ 	AVFormatContext *m_format_ctx = nullptr;
+ 	AVCodecContext *m_codec_ctx = nullptr;
+-	AVFrame *m_frame = nullptr;
+ 	int m_stream_index = -1;
+ 	std::string m_error;
+ 	int m_error_code = 0;
+-	bool m_finished = false;
+ 	bool m_opened = false;
+-	int m_got_frame = 0;
+-	AVPacket m_packet;
+-	AVPacket m_packet0;
++	bool m_has_more_packets = true;
++	bool m_has_more_frames = true;
++	AVPacket *m_packet = nullptr;
++	AVFrame *m_frame = nullptr;
+
+ 	int m_output_sample_rate = 0;
+ 	int m_output_channels = 0;
+@@ -98,19 +97,12 @@ private:
+
+ inline FFmpegAudioReader::FFmpegAudioReader() {
+ 	av_log_set_level(AV_LOG_QUIET);
+-
+-	av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
+ }
+
+ inline FFmpegAudioReader::~FFmpegAudioReader() {
+ 	Close();
+ 	av_dict_free(&m_input_opts);
+ 	av_freep(&m_convert_buffer[0]);
+-	av_packet_unref(&m_packet0);
+ }
+
+ inline bool FFmpegAudioReader::SetInputFormat(const char *name) {
+@@ -135,11 +127,10 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ 	Close();
+
+-    av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
++	m_packet = av_packet_alloc();
++	if (!m_packet) {
++		return false;
++	}
+
+ 	ret = avformat_open_input(&m_format_ctx, file_name.c_str(), m_input_fmt, &m_input_opts);
+ 	if (ret < 0) {
+@@ -153,26 +144,31 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		return false;
+ 	}
+
+-	AVCodec *codec;
++	const AVCodec *codec;
+ 	ret = av_find_best_stream(m_format_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &codec, 0);
+ 	if (ret < 0) {
+ 		SetError("Could not find any audio stream in the file", ret);
+ 		return false;
+ 	}
+ 	m_stream_index = ret;
++	auto stream = m_format_ctx->streams[m_stream_index];
+
+-	m_codec_ctx = m_format_ctx->streams[m_stream_index]->codec;
++	m_codec_ctx = avcodec_alloc_context3(codec);
+ 	m_codec_ctx->request_sample_fmt = AV_SAMPLE_FMT_S16;
+
++	ret = avcodec_parameters_to_context(m_codec_ctx, stream->codecpar);
++	if (ret < 0) {
++		SetError("Could not copy the stream parameters", ret);
++		return false;
++	}
++
+ 	ret = avcodec_open2(m_codec_ctx, codec, nullptr);
+ 	if (ret < 0) {
+ 		SetError("Could not open the codec", ret);
+ 		return false;
+ 	}
+
+-	if (!m_codec_ctx->channel_layout) {
+-		m_codec_ctx->channel_layout = av_get_default_channel_layout(m_codec_ctx->channels);
+-	}
++	av_dump_format(m_format_ctx, 0, "foo", 0);
+
+ 	m_frame = av_frame_alloc();
+ 	if (!m_frame) {
+@@ -183,19 +179,23 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		m_output_sample_rate = m_codec_ctx->sample_rate;
+ 	}
+
+-	if (!m_output_channels) {
+-		m_output_channels = m_codec_ctx->channels;
++	AVChannelLayout output_channel_layout;
++	if (m_output_channels) {
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
++	} else {
++		m_output_channels = m_codec_ctx->ch_layout.nb_channels;
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
+ 	}
+
+-	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
++	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->ch_layout.nb_channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
+ 		m_converter.reset(new FFmpegAudioProcessor());
+ 		m_converter->SetCompatibleMode();
+ 		m_converter->SetInputSampleFormat(m_codec_ctx->sample_fmt);
+ 		m_converter->SetInputSampleRate(m_codec_ctx->sample_rate);
+-		m_converter->SetInputChannelLayout(m_codec_ctx->channel_layout);
++		m_converter->SetInputChannelLayout(&(m_codec_ctx->ch_layout));
+ 		m_converter->SetOutputSampleFormat(AV_SAMPLE_FMT_S16);
+ 		m_converter->SetOutputSampleRate(m_output_sample_rate);
+-		m_converter->SetOutputChannelLayout(av_get_default_channel_layout(m_output_channels));
++		m_converter->SetOutputChannelLayout(&output_channel_layout);
+ 		auto ret = m_converter->Init();
+ 		if (ret != 0) {
+ 			SetError("Could not create an audio converter instance", ret);
+@@ -203,10 +203,11 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		}
+ 	}
+
++	av_channel_layout_uninit(&output_channel_layout);
++
+ 	m_opened = true;
+-	m_finished = false;
+-	m_got_frame = 0;
+-	m_nb_packets = 0;
++	m_has_more_packets = true;
++	m_has_more_frames = true;
+ 	m_decode_error = 0;
+
+ 	return true;
+@@ -214,6 +215,7 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ inline void FFmpegAudioReader::Close() {
+ 	av_frame_free(&m_frame);
++	av_packet_free(&m_packet);
+
+ 	m_stream_index = -1;
+
+@@ -252,91 +254,98 @@ inline bool FFmpegAudioReader::Read(const int16_t **data, size_t *size) {
+ 		return false;
+ 	}
+
++	*data = nullptr;
++	*size = 0;
++
+ 	int ret;
++	bool needs_packet = false;
+ 	while (true) {
+-		while (m_packet.size <= 0) {
+-			av_packet_unref(&m_packet0);
+-			av_init_packet(&m_packet);
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			ret = av_read_frame(m_format_ctx, &m_packet);
++		while (needs_packet && m_packet->size == 0) {
++			ret = av_read_frame(m_format_ctx, m_packet);
+ 			if (ret < 0) {
+ 				if (ret == AVERROR_EOF) {
+-					m_finished = true;
++					needs_packet = false;
++					m_has_more_packets = false;
+ 					break;
+-				} else {
++				}
++				SetError("Error reading from the audio source", ret);
++				return false;
++			}
++			if (m_packet->stream_index == m_stream_index) {
++				needs_packet = false;
++			} else {
++				av_packet_unref(m_packet);
++			}
++		}
++
++		if (m_packet->size != 0) {
++			ret = avcodec_send_packet(m_codec_ctx, m_packet);
++			if (ret < 0) {
++				if (ret != AVERROR(EAGAIN)) {
+ 					SetError("Error reading from the audio source", ret);
+ 					return false;
+ 				}
+-			}
+-			m_packet0 = m_packet;
+-			if (m_packet.stream_index != m_stream_index) {
+-				m_packet.data = nullptr;
+-				m_packet.size = 0;
+ 			} else {
+-				m_nb_packets++;
++				av_packet_unref(m_packet);
+ 			}
+ 		}
+
+-		ret = avcodec_decode_audio4(m_codec_ctx, m_frame, &m_got_frame, &m_packet);
++		ret = avcodec_receive_frame(m_codec_ctx, m_frame);
+ 		if (ret < 0) {
+-			if (m_decode_error) {
+-				SetError("Error decoding audio frame", m_decode_error);
+-				return false;
++			if (ret == AVERROR_EOF) {
++				m_has_more_frames = false;
++			} else if (ret == AVERROR(EAGAIN)) {
++				if (m_has_more_packets) {
++					needs_packet = true;
++					continue;
++				} else {
++					m_has_more_frames = false;
++				}
+ 			}
+-			m_decode_error = ret;
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			continue;
++			SetError("Error decoding the audio source", ret);
++			return false;
+ 		}
+
+-		break;
+-	}
+-
+-	m_decode_error = 0;
+-
+-	const int decoded = std::min(ret, m_packet.size);
+-	m_packet.data += decoded;
+-	m_packet.size -= decoded;
+-
+-	if (m_got_frame) {
+-		if (m_converter) {
+-			if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
+-				int linsize;
+-				av_freep(&m_convert_buffer[0]);
+-				m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
+-				ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
+-				if (ret < 0) {
+-					SetError("Couldn't allocate audio converter buffer", ret);
++		if (m_frame->nb_samples > 0) {
++			if (m_converter) {
++				if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
++					int linsize;
++					av_freep(&m_convert_buffer[0]);
++					m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
++					ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->ch_layout.nb_channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
++					if (ret < 0) {
++						SetError("Couldn't allocate audio converter buffer", ret);
++						return false;
++					}
++				}
++				auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
++				if (nb_samples < 0) {
++					SetError("Couldn't convert audio", ret);
+ 					return false;
+ 				}
+-			}
+-			auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			}
+-			*data = (const int16_t *) m_convert_buffer[0];
+-			*size = nb_samples;
+-		} else {
+-			*data = (const int16_t *) m_frame->data[0];
+-			*size = m_frame->nb_samples;
+-		}
+-	} else {
+-		if (m_finished && m_converter) {
+-			auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			} else if (nb_samples > 0) {
+-				m_got_frame = 1;
+ 				*data = (const int16_t *) m_convert_buffer[0];
+ 				*size = nb_samples;
++			} else {
++				*data = (const int16_t *) m_frame->data[0];
++				*size = m_frame->nb_samples;
++			}
++		} else {
++			if (m_converter) {
++				if (IsFinished()) {
++					auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
++					if (nb_samples < 0) {
++						SetError("Couldn't convert audio", ret);
++						return false;
++					} else if (nb_samples > 0) {
++						*data = (const int16_t *) m_convert_buffer[0];
++						*size = nb_samples;
++					}
++				}
+ 			}
+ 		}
+-	}
+
+-	return true;
++		return true;
++	}
+ }
+
+ inline void FFmpegAudioReader::SetError(const char *message, int errnum) {
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index a2b517b..123e643 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -38,6 +38,12 @@ set(SRCS
+
+ if(BUILD_TOOLS)
+ 	set(SRCS ${SRCS} ../src/audio/ffmpeg_audio_reader_test.cpp)
++    include_directories(
++        ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}
++        ${AUDIO_PROCESSOR_INCLUDE_DIRS}
++    )
+ 	link_libraries(fpcalc_libs)
+ endif()
+
+-- 
+2.38.1
+
+
diff --git a/srcpkgs/chromaprint/template b/srcpkgs/chromaprint/template
index 7ef7838949f3a..1f7bbc70a22c8 100644
--- a/srcpkgs/chromaprint/template
+++ b/srcpkgs/chromaprint/template
@@ -1,7 +1,7 @@
 # Template file for 'chromaprint'
 pkgname=chromaprint
 version=1.5.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DBUILD_TOOLS=ON"
 make_check_target="check"

From 9fcc780c3ec01feb49aef20eaf117e9548b881c5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 021/111] chromium: revbump for ffmpeg6

---
 srcpkgs/chromium/patches/ffmpeg5.patch | 47 ++++++++++++++++++++++++++
 srcpkgs/chromium/template              |  2 +-
 2 files changed, 48 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..24e2da38e34ca
--- /dev/null
+++ b/srcpkgs/chromium/patches/ffmpeg5.patch
@@ -0,0 +1,47 @@
+--- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
++++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
+@@ -92,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+-  if (stream->start_time != kNoFFmpegTimestamp)
++  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -1597,7 +1585,7 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+@@ -1618,7 +1606,7 @@
+     if (stream->type() != DemuxerStream::VIDEO)
+       continue;
+ 
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+ 
+     if (!stream->IsEnabled())
diff --git a/srcpkgs/chromium/template b/srcpkgs/chromium/template
index 22947e83cb52c..e8e5b92b5c8d5 100644
--- a/srcpkgs/chromium/template
+++ b/srcpkgs/chromium/template
@@ -2,7 +2,7 @@
 pkgname=chromium
 # See https://chromiumdash.appspot.com/releases?platform=Linux for the latest version
 version=121.0.6167.160
-revision=1
+revision=2
 archs="i686* x86_64* aarch64* armv7l*"
 hostmakedepends="
  $(vopt_if clang "clang17 lld17 llvm17 compiler-rt")

From c8a437dedc9f60524e74fd4b57a15e8371e5d0f4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 022/111] cmus: revbump for ffmpeg6

---
 srcpkgs/chromium/patches/ffmpeg5.patch | 47 --------------------------
 srcpkgs/cmus/patches/ffmpeg6.patch     | 12 +++++++
 srcpkgs/cmus/template                  |  2 +-
 3 files changed, 13 insertions(+), 48 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch
 create mode 100644 srcpkgs/cmus/patches/ffmpeg6.patch

diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
deleted file mode 100644
index 24e2da38e34ca..0000000000000
--- a/srcpkgs/chromium/patches/ffmpeg5.patch
+++ /dev/null
@@ -1,47 +0,0 @@
---- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
-+++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
-@@ -92,24 +92,12 @@
- 
- static base::TimeDelta ExtractStartTime(AVStream* stream) {
-   // The default start time is zero.
--  base::TimeDelta start_time;
-+  base::TimeDelta start_time = kNoTimestamp;
- 
-   // First try to use  the |start_time| value as is.
--  if (stream->start_time != kNoFFmpegTimestamp)
-+  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
-     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
- 
--  // Next try to use the first DTS value, for codecs where we know PTS == DTS
--  // (excludes all H26x codecs). The start time must be returned in PTS.
--  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
--      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
--      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
--      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
--    const base::TimeDelta first_pts =
--        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
--    if (first_pts < start_time)
--      start_time = first_pts;
--  }
--
-   return start_time;
- }
- 
-@@ -1597,7 +1585,7 @@
-   for (const auto& stream : streams_) {
-     if (!stream || stream->IsEnabled() != enabled)
-       continue;
--    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
-+    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
-       continue;
-     if (!lowest_start_time_stream ||
-         stream->start_time() < lowest_start_time_stream->start_time()) {
-@@ -1618,7 +1606,7 @@
-     if (stream->type() != DemuxerStream::VIDEO)
-       continue;
- 
--    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
-+    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
-       continue;
- 
-     if (!stream->IsEnabled())
diff --git a/srcpkgs/cmus/patches/ffmpeg6.patch b/srcpkgs/cmus/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..ffa95ab811101
--- /dev/null
+++ b/srcpkgs/cmus/patches/ffmpeg6.patch
@@ -0,0 +1,12 @@
+--- a/ip/ffmpeg.c
++++ b/ip/ffmpeg.c
+@@ -202,9 +202,6 @@ static int ffmpeg_open(struct input_plugin_data *ip_data)
+ 			break;
+ 		}
+ 
+-		if (codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+-			cc->flags |= AV_CODEC_FLAG_TRUNCATED;
+-
+ 		if (avcodec_open2(cc, codec, NULL) < 0) {
+ 			d_print("could not open codec: %d, %s\n", cc->codec_id, avcodec_get_name(cc->codec_id));
+ 			err = -IP_ERROR_UNSUPPORTED_FILE_TYPE;
diff --git a/srcpkgs/cmus/template b/srcpkgs/cmus/template
index 0d1436744f1b2..a6e4b4fa86cb8 100644
--- a/srcpkgs/cmus/template
+++ b/srcpkgs/cmus/template
@@ -1,7 +1,7 @@
 # Template file for 'cmus'
 pkgname=cmus
 version=2.10.0
-revision=3
+revision=4
 build_style=configure
 configure_args="prefix=/usr LD=$CC"
 hostmakedepends="pkg-config"

From 9ac6c17ca2288010100a027b199ca839cafebf53 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 023/111] cyanrip: revbump for ffmpeg6

---
 srcpkgs/cyanrip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cyanrip/template b/srcpkgs/cyanrip/template
index 9796e3461601a..5db30e020d17e 100644
--- a/srcpkgs/cyanrip/template
+++ b/srcpkgs/cyanrip/template
@@ -1,7 +1,7 @@
 # Template file for 'cyanrip'
 pkgname=cyanrip
 version=0.9.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config"
 makedepends="ffmpeg-devel libcdio-devel libcdio-paranoia-devel libcurl-devel libmusicbrainz5-devel"

From b67cd5872599b6ef5c28878b1fcd99943414ef08 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 024/111] deadbeef: revbump for ffmpeg4

---
 srcpkgs/deadbeef/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/deadbeef/template b/srcpkgs/deadbeef/template
index f5f4bf24b8cb6..7b47e615cd48e 100644
--- a/srcpkgs/deadbeef/template
+++ b/srcpkgs/deadbeef/template
@@ -1,14 +1,14 @@
 # Template file for 'deadbeef'
 pkgname=deadbeef
 version=1.8.8
-revision=3
+revision=4
 create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-oss --disable-lfm --disable-notify --disable-gtk2"
 hostmakedepends="automake libtool gettext gettext-devel intltool pkg-config
  yasm clang glib-devel"
 makedepends="
- alsa-lib-devel dbus-devel faad2-devel ffmpeg-devel gtk+3-devel imlib2-devel
+ alsa-lib-devel dbus-devel faad2-devel ffmpeg4-devel gtk+3-devel imlib2-devel
  jansson-devel libcddb-devel libcdio-devel libcurl-devel libflac-devel
  libmad-devel libpng-devel libsamplerate-devel libsndfile-devel libvorbis-devel
  libzip-devel mpg123-devel opusfile-devel pulseaudio-devel wavpack-devel"

From b9a66a1b973e9981729a44dfaaea300b1cdc7e94 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 025/111] droidcam-obs-plugin: revbump for ffmpeg6

---
 srcpkgs/droidcam-obs-plugin/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam-obs-plugin/template b/srcpkgs/droidcam-obs-plugin/template
index fc9c9bf6b9d54..fb0480754df4d 100644
--- a/srcpkgs/droidcam-obs-plugin/template
+++ b/srcpkgs/droidcam-obs-plugin/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam-obs-plugin'
 pkgname=droidcam-obs-plugin
 version=2.0.1
-revision=1
+revision=2
 build_style=gnu-makefile
 make_use_env=yes
 make_build_args="ALLOW_STATIC=no"

From 7627b952d8952dc592af4179db8a0d0fb3b25c59 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 026/111] droidcam: revbump for ffmpeg6

---
 srcpkgs/droidcam/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam/template b/srcpkgs/droidcam/template
index 1c3f1b8b1fc67..32a9220b79a4d 100644
--- a/srcpkgs/droidcam/template
+++ b/srcpkgs/droidcam/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam'
 pkgname=droidcam
 version=1.8.2
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="USBMUXD=-lusbmuxd-2.0 JPEG=-lturbojpeg"
 hostmakedepends="pkg-config"

From 4ccbc2f847dd4a47324d23e4ace5d4cd288f0ec7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 027/111] ffmpegthumbnailer: revbump for ffmpeg6

---
 .../ffmpegthumbnailer/patches/ffmpeg6.patch   | 202 ++++++++++++++++++
 srcpkgs/ffmpegthumbnailer/template            |   6 +-
 2 files changed, 205 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch

diff --git a/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..363ff35a28419
--- /dev/null
+++ b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
@@ -0,0 +1,202 @@
+--- a/libffmpegthumbnailer/moviedecoder.cpp	2017-11-21 14:06:57.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.cpp	2023-05-05 13:14:47.946560668 -0400
+@@ -41,11 +41,6 @@
+ namespace ffmpegthumbnailer
+ {
+ 
+-struct SilenceLogLevel
+-{
+-    SilenceLogLevel() { av_log_set_level(AV_LOG_QUIET); }
+-};
+-
+ MovieDecoder::MovieDecoder(AVFormatContext* pavContext)
+ : m_VideoStream(-1)
+ , m_pFormatContext(pavContext)
+@@ -70,8 +65,6 @@
+ 
+ void MovieDecoder::initialize(const string& filename, bool preferEmbeddedMetadata)
+ {
+-    av_register_all();
+-    avcodec_register_all();
+     avformat_network_init();
+ 
+     string inputFile = filename == "-" ? "pipe:" : filename;
+@@ -97,8 +90,7 @@
+ {
+     if (m_pVideoCodecContext)
+     {
+-        avcodec_close(m_pVideoCodecContext);
+-        m_pVideoCodecContext = nullptr;
++        avcodec_free_context(&m_pVideoCodecContext);
+     }
+ 
+     if ((!m_FormatContextWasGiven) && m_pFormatContext)
+@@ -152,10 +144,10 @@
+     for (unsigned int i = 0; i < m_pFormatContext->nb_streams; ++i)
+     {
+         AVStream *stream = m_pFormatContext->streams[i];
+-        auto ctx = m_pFormatContext->streams[i]->codec;
+-        if (ctx->codec_type == AVMEDIA_TYPE_VIDEO)
++        auto par = m_pFormatContext->streams[i]->codecpar;
++        if (par->codec_type == AVMEDIA_TYPE_VIDEO)
+         {
+-            if (!preferEmbeddedMetadata || !isStillImageCodec(ctx->codec_id))
++            if (!preferEmbeddedMetadata || !isStillImageCodec(par->codec_id))
+             {
+                 videoStreams.push_back(i);
+                 continue;
+@@ -203,8 +195,7 @@
+     }
+ 
+     m_pVideoStream = m_pFormatContext->streams[m_VideoStream];
+-    m_pVideoCodecContext = m_pVideoStream->codec;
+-    m_pVideoCodec = avcodec_find_decoder(m_pVideoCodecContext->codec_id);
++    m_pVideoCodec = avcodec_find_decoder(m_pVideoStream->codecpar->codec_id);
+ 
+     if (m_pVideoCodec == nullptr)
+     {
+@@ -214,6 +205,20 @@
+         throw logic_error("Video Codec not found");
+     }
+ 
++    m_pVideoCodecContext = avcodec_alloc_context3(m_pVideoCodec);
++
++    if (m_pVideoCodecContext == nullptr)
++    {
++        destroy();
++        throw logic_error("Could not allocate video codec context");
++    }
++
++    if (avcodec_parameters_to_context(m_pVideoCodecContext, m_pVideoStream->codecpar) < 0)
++    {
++        destroy();
++        throw logic_error("Could not configure video codec context");
++    }
++
+     m_pVideoCodecContext->workaround_bugs = 1;
+ 
+     if (avcodec_open2(m_pVideoCodecContext, m_pVideoCodec, nullptr) < 0)
+@@ -386,13 +391,6 @@
+ 
+ void MovieDecoder::initializeFilterGraph(const AVRational& timeBase, const std::string& size, bool maintainAspectRatio)
+ {
+-    static const AVPixelFormat pixelFormats[] = { AV_PIX_FMT_RGB24, AV_PIX_FMT_NONE };
+-
+-    auto del = [] (AVBufferSinkParams* p) { av_freep(p); };
+-    std::unique_ptr<AVBufferSinkParams, decltype(del)> buffersinkParams(av_buffersink_params_alloc(), del);
+-
+-    avfilter_register_all();
+-
+     m_pFilterGraph = avfilter_graph_alloc();
+     assert(m_pFilterGraph);
+ 
+@@ -404,10 +402,8 @@
+ 
+     checkRc(avfilter_graph_create_filter(&m_pFilterSource, avfilter_get_by_name("buffer"), "thumb_buffer", ss.str().c_str(), nullptr, m_pFilterGraph),
+             "Failed to create filter source");
+-    buffersinkParams->pixel_fmts = pixelFormats;
+-    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, buffersinkParams.get(), m_pFilterGraph),
++    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, nullptr, m_pFilterGraph),
+             "Failed to create filter sink");
+-    buffersinkParams.release();
+ 
+     AVFilterContext* yadifFilter = nullptr;
+     if (m_pFrame->interlaced_frame != 0)
+@@ -500,15 +496,15 @@
+     }
+ 
+     checkRc(av_seek_frame(m_pFormatContext, -1, timestamp, 0), "Seeking in video failed");
+-    avcodec_flush_buffers(m_pFormatContext->streams[m_VideoStream]->codec);
++    avcodec_flush_buffers(m_pVideoCodecContext);
+ 
+     int keyFrameAttempts = 0;
+-    bool gotFrame = 0;
++    bool gotFrame;
+ 
+     do
+     {
+         int count = 0;
+-        gotFrame = 0;
++        gotFrame = false;
+ 
+         while (!gotFrame && count < 20)
+         {
+@@ -552,17 +548,33 @@
+         return false;
+     }
+ 
+-    av_frame_unref(m_pFrame);
+-
+-    int frameFinished;
++    int rc = avcodec_send_packet(m_pVideoCodecContext, m_pPacket);
++    if(rc == AVERROR(EAGAIN))
++    {
++        rc = 0;
++    }
+ 
+-    int bytesDecoded = avcodec_decode_video2(m_pVideoCodecContext, m_pFrame, &frameFinished, m_pPacket);
+-    if (bytesDecoded < 0)
++    if(rc == AVERROR_EOF)
++    {
++        return false;
++    }
++    else if(rc < 0)
+     {
+-        throw logic_error("Failed to decode video frame: bytesDecoded < 0");
++        throw logic_error("Failed to decode video frame: avcodec_send_packet() < 0");
+     }
+ 
+-    return frameFinished > 0;
++    rc = avcodec_receive_frame(m_pVideoCodecContext, m_pFrame);
++    switch(rc)
++    {
++        case 0:
++            return true;
++
++        case AVERROR(EAGAIN):
++            return false;
++
++        default:
++            throw logic_error("Failed to decode video frame: avcodec_receive_frame() < 0");
++    }
+ }
+ 
+ bool MovieDecoder::getVideoPacket()
+@@ -570,8 +582,6 @@
+     bool framesAvailable = true;
+     bool frameDecoded = false;
+ 
+-    int attempts = 0;
+-
+     if (m_pPacket)
+     {
+         av_packet_unref(m_pPacket);
+@@ -580,6 +590,7 @@
+ 
+     m_pPacket = new AVPacket();
+ 
++
+     while (framesAvailable && !frameDecoded)
+     {
+         framesAvailable = av_read_frame(m_pFormatContext, m_pPacket) >= 0;
+@@ -644,7 +655,7 @@
+ 
+ int32_t MovieDecoder::getStreamRotation()
+ {
+-    int32_t* matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
++    auto matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
+     if (matrix)
+     {
+         auto angle = lround(av_display_rotation_get(matrix));
+
+--- a/libffmpegthumbnailer/moviedecoder.h	2017-11-12 04:23:38.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.h	2023-05-05 13:26:07.095529911 -0400
+@@ -78,7 +78,7 @@
+     int                     m_VideoStream;
+     AVFormatContext*        m_pFormatContext;
+     AVCodecContext*         m_pVideoCodecContext;
+-    AVCodec*                m_pVideoCodec;
++    const AVCodec*          m_pVideoCodec;
+     AVFilterGraph*          m_pFilterGraph;
+     AVFilterContext*        m_pFilterSource;
+     AVFilterContext*        m_pFilterSink;
diff --git a/srcpkgs/ffmpegthumbnailer/template b/srcpkgs/ffmpegthumbnailer/template
index 039eea7622b39..35d546018d12a 100644
--- a/srcpkgs/ffmpegthumbnailer/template
+++ b/srcpkgs/ffmpegthumbnailer/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbnailer'
 pkgname=ffmpegthumbnailer
 version=2.2.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libpng-devel libjpeg-turbo-devel ffmpeg-devel"
@@ -9,8 +9,8 @@ depends="ffmpeg"
 short_desc="Lightweight video thumbnailer"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
-homepage="https://github.com/dirkvdb/${pkgname}"
-distfiles="${homepage}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
+homepage="https://github.com/dirkvdb"
+distfiles="${homepage}/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
 checksum=1cb24059c38223f657b300c84dd80491b7040d4b69471c4fea69be862bc99b5b
 
 post_install() {

From ebccf61838712e32de2b29983af245708952afc3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 028/111] ffmpegthumbs: revbump for ffmpeg6

---
 srcpkgs/ffmpegthumbs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ffmpegthumbs/template b/srcpkgs/ffmpegthumbs/template
index 5f0b9414dadaf..11b88193528f4 100644
--- a/srcpkgs/ffmpegthumbs/template
+++ b/srcpkgs/ffmpegthumbs/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbs'
 pkgname=ffmpegthumbs
 version=22.12.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules kcoreaddons kconfig-devel
  pkg-config qt5-host-tools qt5-qmake gettext"

From 6b1792ec25148a794078de733f555d04f3b12c95 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 029/111] ffms2: revbump for ffmpeg6

---
 srcpkgs/ffms2/patches/ffmpeg5.patch | 424 ++++++++++++++++++++++++++++
 srcpkgs/ffms2/template              |   2 +-
 2 files changed, 425 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ffms2/patches/ffmpeg5.patch

diff --git a/srcpkgs/ffms2/patches/ffmpeg5.patch b/srcpkgs/ffms2/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..1479fabcafcb4
--- /dev/null
+++ b/srcpkgs/ffms2/patches/ffmpeg5.patch
@@ -0,0 +1,424 @@
+From 45673149e9a2f5586855ad472e3059084eaa36b1 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:41:21 +0100
+Subject: [PATCH] Use auto for AVCodec
+
+The geniuses over at FFmpeg decided to constify this API, so old
+versions of the library will return AVCodec *, while new versions
+of the libary will return const AVCodec *, which, in C++, are not
+OK to convert between.
+
+Rather than use some macro hell in ffmscompat.h, we can work around
+this by using auto.
+
+Gross.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 2 +-
+ src/core/indexing.cpp    | 6 +++---
+ src/core/videosource.cpp | 2 +-
+ 3 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index e4ce97c..ac09666 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -469,7 +469,7 @@ void FFMS_AudioSource::OpenFile() {
+ 
+     LAVFOpenFile(SourceFile.c_str(), FormatContext, TrackNumber);
+ 
+-    AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
++    auto *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
+     if (Codec == nullptr)
+         throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+             "Audio codec not found");
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index e547c5a..59fb4e8 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -384,7 +384,7 @@ FFMS_TrackType FFMS_Indexer::GetTrackType(int Track) {
+ }
+ 
+ const char *FFMS_Indexer::GetTrackCodec(int Track) {
+-    AVCodec *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
++    auto *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
+     return codec ? codec->name : nullptr;
+ }
+ 
+@@ -402,7 +402,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             UseDTS);
+ 
+         if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            AVCodec *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (!VideoCodec) {
+                 FormatContext->streams[i]->discard = AVDISCARD_ALL;
+                 IndexMask.erase(i);
+@@ -433,7 +433,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 IndexMask.insert(i);
+             }
+         } else if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+-            AVCodec *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (AudioCodec == nullptr)
+                 throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_UNSUPPORTED,
+                     "Audio codec not found");
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index b889970..8956c22 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -171,7 +171,7 @@ FFMS_VideoSource::FFMS_VideoSource(const char *SourceFile, FFMS_Index &Index, in
+ 
+         LAVFOpenFile(SourceFile, FormatContext, VideoTrack);
+ 
+-        AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
++        auto *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
+         if (Codec == nullptr)
+             throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+                 "Video codec not found");
+-- 
+2.40.0
+
+From 96cbf38ea9381829a1314f432a2c60495dcefaad Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:12:41 +0100
+Subject: [PATCH] all: Update AVPacket API usage
+
+AVPackets must all be on the heap now, since it is no longer
+part of the libav* ABI.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 16 ++++++----
+ src/core/indexing.cpp    | 63 ++++++++++++++++++++++------------------
+ src/core/indexing.h      |  4 +--
+ src/core/utils.cpp       |  6 ----
+ src/core/utils.h         |  1 -
+ src/core/videosource.cpp | 30 ++++++++++---------
+ 6 files changed, 64 insertions(+), 56 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index 37cf9ae..e4ce97c 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -285,10 +285,15 @@ FFMS_AudioSource::AudioBlock *FFMS_AudioSource::CacheBlock(CacheIterator &pos) {
+ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     CurrentFrame = &Frames[PacketNumber];
+ 
+-    AVPacket Packet;
+-    if (!ReadPacket(&Packet))
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++    if (!ReadPacket(Packet)) {
++        av_packet_free(&Packet);
+         throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_UNKNOWN,
+             "ReadPacket unexpectedly failed to read a packet");
++    }
+ 
+     // ReadPacket may have changed the packet number
+     CurrentFrame = &Frames[PacketNumber];
+@@ -297,8 +302,9 @@ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     int NumberOfSamples = 0;
+     AudioBlock *CachedBlock = nullptr;
+     
+-    int Ret = avcodec_send_packet(CodecContext, &Packet);
+-    av_packet_unref(&Packet);
++    int Ret = avcodec_send_packet(CodecContext, Packet);
++    av_packet_unref(Packet);
++    av_packet_free(&Packet);
+ 
+     av_frame_unref(DecodeFrame);
+     Ret = avcodec_receive_frame(CodecContext, DecodeFrame);
+@@ -513,8 +519,6 @@ void FFMS_AudioSource::Seek() {
+ }
+ 
+ bool FFMS_AudioSource::ReadPacket(AVPacket *Packet) {
+-    InitNullPacket(*Packet);
+-
+     while (av_read_frame(FormatContext, Packet) >= 0) {
+         if (Packet->stream_index == TrackNumber) {
+             // Required because not all audio packets, especially in ogg, have a pts. Use the previous valid packet's pts instead.
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index 23fb95b..e547c5a 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -320,7 +320,7 @@ void FFMS_Indexer::CheckAudioProperties(int Track, AVCodecContext *Context) {
+     }
+ }
+ 
+-void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict,
++void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict,
+                                     int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct) {
+     if (VideoContext.Parser) {
+         uint8_t *OB;
+@@ -330,8 +330,8 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+         av_parser_parse2(VideoContext.Parser,
+             VideoContext.CodecContext,
+             &OB, &OBSize,
+-            pkt.data, pkt.size,
+-            pkt.pts, pkt.dts, pkt.pos);
++            pkt->data, pkt->size,
++            pkt->pts, pkt->dts, pkt->pos);
+ 
+         // H.264 (PAFF) and HEVC may have one field per packet, so we need to track
+         // when we have a full or half frame available, and mark one of them as
+@@ -351,15 +351,15 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+ 
+         *RepeatPict = VideoContext.Parser->repeat_pict;
+         *FrameType = VideoContext.Parser->pict_type;
+-        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt.flags & AV_PKT_FLAG_DISCARD));
++        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt->flags & AV_PKT_FLAG_DISCARD));
+     } else {
+-        *Invisible = !!(pkt.flags & AV_PKT_FLAG_DISCARD);
++        *Invisible = !!(pkt->flags & AV_PKT_FLAG_DISCARD);
+     }
+ 
+     if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP8)
+-        ParseVP8(pkt.data[0], Invisible, FrameType);
++        ParseVP8(pkt->data[0], Invisible, FrameType);
+     else if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP9)
+-        ParseVP9(pkt.data[0], Invisible, FrameType);
++        ParseVP9(pkt->data[0], Invisible, FrameType);
+ }
+ 
+ void FFMS_Indexer::Free() {
+@@ -458,32 +458,36 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+         }
+     }
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
+     std::vector<int64_t> LastValidTS(FormatContext->nb_streams, AV_NOPTS_VALUE);
+ 
+     int64_t filesize = avio_size(FormatContext->pb);
+     enum AVPictureStructure LastPicStruct = AV_PICTURE_STRUCTURE_UNKNOWN;
+-    while (av_read_frame(FormatContext, &Packet) >= 0) {
++    while (av_read_frame(FormatContext, Packet) >= 0) {
+         // Update progress
+         // FormatContext->pb can apparently be NULL when opening images.
+         if (IC && FormatContext->pb) {
+-            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate))
++            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate)) {
++                av_packet_free(&Packet);
+                 throw FFMS_Exception(FFMS_ERROR_CANCELLED, FFMS_ERROR_USER,
+                     "Cancelled by user");
++            }
+         }
+-        if (!IndexMask.count(Packet.stream_index)) {
+-            av_packet_unref(&Packet);
++        if (!IndexMask.count(Packet->stream_index)) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+-        int Track = Packet.stream_index;
++        int Track = Packet->stream_index;
+         FFMS_Track &TrackInfo = (*TrackIndices)[Track];
+-        bool KeyFrame = !!(Packet.flags & AV_PKT_FLAG_KEY);
++        bool KeyFrame = !!(Packet->flags & AV_PKT_FLAG_KEY);
+         ReadTS(Packet, LastValidTS[Track], (*TrackIndices)[Track].UseDTS);
+ 
+         if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            int64_t PTS = TrackInfo.UseDTS ? Packet.dts : Packet.pts;
++            int64_t PTS = TrackInfo.UseDTS ? Packet->dts : Packet->pts;
+             if (PTS == AV_NOPTS_VALUE) {
+                 // VPx alt-refs are output as packets which lack timestmps or durations, since
+                 // they are invisible. Currently, the timestamp mangling code in libavformat
+@@ -495,9 +499,11 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 // FFMS2 currently sorts packets by PTS, which will break decoding, otherwise.
+                 bool HasAltRefs = (FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP8 ||
+                                    FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP9);
+-                if (Packet.duration == 0 && !HasAltRefs)
++                if (Packet->duration == 0 && !HasAltRefs) {
++                    av_packet_free(&Packet);
+                     throw FFMS_Exception(FFMS_ERROR_INDEXING, FFMS_ERROR_PARSER,
+                         "Invalid packet pts, dts, and duration");
++                }
+ 
+                 if (TrackInfo.empty())
+                     PTS = 0;
+@@ -513,7 +519,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             ParseVideoPacket(AVContexts[Track], Packet, &RepeatPict, &FrameType, &Invisible, &LastPicStruct);
+ 
+             TrackInfo.AddVideoFrame(PTS, RepeatPict, KeyFrame,
+-                FrameType, Packet.pos, Invisible);
++                FrameType, Packet->pos, Invisible);
+         } else if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+             // For video seeking timestamps are used only if all packets have
+             // timestamps, while for audio they're used if any have timestamps,
+@@ -522,28 +528,29 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 TrackInfo.HasTS = true;
+ 
+             int64_t StartSample = AVContexts[Track].CurrentSample;
+-            uint32_t SampleCount = IndexAudioPacket(Track, &Packet, AVContexts[Track], *TrackIndices);
++            uint32_t SampleCount = IndexAudioPacket(Track, Packet, AVContexts[Track], *TrackIndices);
+             TrackInfo.SampleRate = AVContexts[Track].CodecContext->sample_rate;
+ 
+             TrackInfo.AddAudioFrame(LastValidTS[Track],
+-                StartSample, SampleCount, KeyFrame, Packet.pos, Packet.flags & AV_PKT_FLAG_DISCARD);
++                StartSample, SampleCount, KeyFrame, Packet->pos, Packet->flags & AV_PKT_FLAG_DISCARD);
+         }
+ 
+-        if (!(Packet.flags & AV_PKT_FLAG_DISCARD))
+-            TrackInfo.LastDuration = Packet.duration;
++        if (!(Packet->flags & AV_PKT_FLAG_DISCARD))
++            TrackInfo.LastDuration = Packet->duration;
+ 
+-        av_packet_unref(&Packet);
++        av_packet_unref(Packet);
+     }
++    av_packet_free(&Packet);
+ 
+     TrackIndices->Finalize(AVContexts, FormatContext->iformat->name);
+     return TrackIndices.release();
+ }
+ 
+-void FFMS_Indexer::ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS) {
+-    if (!UseDTS && Packet.pts != AV_NOPTS_VALUE)
+-        TS = Packet.pts;
++void FFMS_Indexer::ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS) {
++    if (!UseDTS && Packet->pts != AV_NOPTS_VALUE)
++        TS = Packet->pts;
+     if (TS == AV_NOPTS_VALUE)
+         UseDTS = true;
+-    if (UseDTS && Packet.dts != AV_NOPTS_VALUE)
+-        TS = Packet.dts;
++    if (UseDTS && Packet->dts != AV_NOPTS_VALUE)
++        TS = Packet->dts;
+ }
+diff --git a/src/core/indexing.h b/src/core/indexing.h
+index 3cfc3c3..5c06868 100644
+--- a/src/core/indexing.h
++++ b/src/core/indexing.h
+@@ -80,10 +80,10 @@ private:
+     int64_t Filesize;
+     uint8_t Digest[20];
+ 
+-    void ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS);
++    void ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS);
+     void CheckAudioProperties(int Track, AVCodecContext *Context);
+     uint32_t IndexAudioPacket(int Track, AVPacket *Packet, SharedAVContext &Context, FFMS_Index &TrackIndices);
+-    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
++    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
+     void Free();
+ public:
+     FFMS_Indexer(const char *Filename);
+diff --git a/src/core/utils.cpp b/src/core/utils.cpp
+index ce67533..8a2e997 100644
+--- a/src/core/utils.cpp
++++ b/src/core/utils.cpp
+@@ -62,12 +62,6 @@ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo) {
+     }
+ }
+ 
+-void InitNullPacket(AVPacket &pkt) {
+-    av_init_packet(&pkt);
+-    pkt.data = nullptr;
+-    pkt.size = 0;
+-}
+-
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames) {
+     AP.SampleFormat = static_cast<FFMS_SampleFormat>(av_get_packed_sample_fmt(CTX->sample_fmt));
+     AP.BitsPerSample = av_get_bytes_per_sample(CTX->sample_fmt) * 8;
+diff --git a/src/core/utils.h b/src/core/utils.h
+index 9819dc7..003ab79 100644
+--- a/src/core/utils.h
++++ b/src/core/utils.h
+@@ -58,7 +58,6 @@ std::unique_ptr<T> make_unique(Args&&... args) {
+ }
+ 
+ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo);
+-void InitNullPacket(AVPacket &pkt);
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames);
+ 
+ void LAVFOpenFile(const char *SourceFile, AVFormatContext *&FormatContext, int Track);
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index 06bd161..b889970 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -673,30 +673,34 @@ void FFMS_VideoSource::DecodeNextFrame(int64_t &AStartTime, int64_t &Pos) {
+     if (HasPendingDelayedFrames())
+         return;
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
+-
+-    while (ReadFrame(&Packet) >= 0) {
+-        if (Packet.stream_index != VideoTrack) {
+-            av_packet_unref(&Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++
++    while (ReadFrame(Packet) >= 0) {
++        if (Packet->stream_index != VideoTrack) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+         if (AStartTime < 0)
+-            AStartTime = Frames.UseDTS ? Packet.dts : Packet.pts;
++            AStartTime = Frames.UseDTS ? Packet->dts : Packet->pts;
+ 
+         if (Pos < 0)
+-            Pos = Packet.pos;
++            Pos = Packet->pos;
+ 
+-        bool FrameFinished = DecodePacket(&Packet);
+-        av_packet_unref(&Packet);
+-        if (FrameFinished)
++        bool FrameFinished = DecodePacket(Packet);
++        av_packet_unref(Packet);
++        if (FrameFinished) {
++            av_packet_free(&Packet);
+             return;
++        }
+     }
+ 
+     // Flush final frames
+-    InitNullPacket(Packet);
+-    DecodePacket(&Packet);
++    DecodePacket(Packet);
++    av_packet_free(&Packet);
+ }
+ 
+ bool FFMS_VideoSource::SeekTo(int n, int SeekOffset) {
+-- 
+2.40.0
+
+From bf9e03e9e08534c024e5a744a6437c4aac160201 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:20:47 +0100
+Subject: [PATCH 2/3] configure: Remove deprecated API use
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ configure.ac | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index b35ef80bc..d19714d0f 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -102,10 +102,10 @@ CFLAGS="$_CFLAGS $FFMPEG_CFLAGS"
+
+ AC_DEFUN([TEST_FFMPEG],
+          [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+-            #include <libavcodec/avcodec.h>
++            #include <libavformat/avformat.h>
+             #include <libswscale/swscale.h>
+             ]],[[
+-                avcodec_register_all();
++                avformat_network_init();
+                 swscale_version();
+             ]])], [eval $1=yes], [eval $1=no])
+         ])
+
diff --git a/srcpkgs/ffms2/template b/srcpkgs/ffms2/template
index 365f64d10cbab..1641ecf43be5b 100644
--- a/srcpkgs/ffms2/template
+++ b/srcpkgs/ffms2/template
@@ -1,7 +1,7 @@
 # Template file for 'ffms2'
 pkgname=ffms2
 version=2.40
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-shared --disable-static"
 hostmakedepends="pkg-config autoconf automake libtool"

From 9be4ce7a366bebac0fff4cea06c7c0498bf61f38 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 030/111] freerdp: revbump for ffmpeg6

---
 .../freerdp/patches/ffmpeg6_aa2cb9aa.patch    | 42 +++++++++++++++++++
 srcpkgs/freerdp/template                      |  2 +-
 2 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch

diff --git a/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
new file mode 100644
index 0000000000000..a4324da3a8822
--- /dev/null
+++ b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
@@ -0,0 +1,42 @@
+From aa2cb9aa5ff5562433598ba168a466e0752bca0e Mon Sep 17 00:00:00 2001
+From: akallabeth <akallabeth@posteo.net>
+Date: Tue, 14 Feb 2023 07:48:54 +0100
+Subject: [PATCH] Fixed #8686: Update h264 to use new FFMPEG API
+
+---
+ channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c | 2 ++
+ libfreerdp/codec/h264_ffmpeg.c            | 2 ++
+ 2 files changed, 4 insertions(+)
+
+diff --git a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+index 339462d865f..beea80b7a1e 100644
+--- a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
++++ b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+@@ -239,8 +239,10 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYP
+ 		}
+ 	}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 	if (mdecoder->codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		mdecoder->codec_context->flags |= AV_CODEC_FLAG_TRUNCATED;
++#endif
+ 
+ 	return TRUE;
+ }
+diff --git a/libfreerdp/codec/h264_ffmpeg.c b/libfreerdp/codec/h264_ffmpeg.c
+index 8a23db2473c..896a333019b 100644
+--- a/libfreerdp/codec/h264_ffmpeg.c
++++ b/libfreerdp/codec/h264_ffmpeg.c
+@@ -615,10 +615,12 @@ static BOOL libavcodec_init(H264_CONTEXT* h264)
+ 			goto EXCEPTION;
+ 		}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 		if (sys->codecDecoder->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		{
+ 			sys->codecDecoderContext->flags |= AV_CODEC_FLAG_TRUNCATED;
+ 		}
++#endif
+ 
+ #ifdef WITH_VAAPI
+ 
diff --git a/srcpkgs/freerdp/template b/srcpkgs/freerdp/template
index f36c38ca885b3..97b1d5ea519cd 100644
--- a/srcpkgs/freerdp/template
+++ b/srcpkgs/freerdp/template
@@ -1,7 +1,7 @@
 # Template file for 'freerdp'
 pkgname=freerdp
 version=2.10.0
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DWITH_ALSA=ON -DWITH_CUPS=OFF -DWITH_FFMPEG=ON
  -DWITH_GSTREAMER_0_10=OFF -DWITH_GSTREAMER_1_0=OFF -DWITH_JPEG=ON

From 14d3d37a5cada7866e2dd67f9ab58f3effc84d25 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 031/111] gerbera: revbump for ffmpeg6

---
 srcpkgs/gerbera/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gerbera/template b/srcpkgs/gerbera/template
index ae14f35c767c0..2dc0ac0ce03b5 100644
--- a/srcpkgs/gerbera/template
+++ b/srcpkgs/gerbera/template
@@ -1,7 +1,7 @@
 # Template file for 'gerbera'
 pkgname=gerbera
 version=1.12.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_SYSTEMD=0 -DWITH_AVCODEC=1"
 hostmakedepends="pkg-config"

From 7c7e7424b5302e7a0e6486d03054717f540320c1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 032/111] goldendict: revbump for ffmpeg6

---
 srcpkgs/goldendict/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/goldendict/template b/srcpkgs/goldendict/template
index f4a05759f693d..97f44347b03a6 100644
--- a/srcpkgs/goldendict/template
+++ b/srcpkgs/goldendict/template
@@ -1,7 +1,7 @@
 # Template file for 'goldendict'
 pkgname=goldendict
 version=1.5.0
-revision=1
+revision=2
 build_style=qmake
 configure_args="CONFIG+=zim_support goldendict.pro"
 hostmakedepends="qt5-qmake pkg-config qt5-host-tools"
@@ -10,7 +10,7 @@ makedepends="tiff-devel qt5-devel libvorbis-devel zlib-devel
  qt5-webkit-devel lzo-devel bzip2-devel libao-devel qt5-svg-devel
  libeb-devel qt5-x11extras-devel ffmpeg-devel liblzma-devel
  qt5-multimedia-devel"
-short_desc="A feature-rich dictionary lookup program"
+short_desc="Feature-rich dictionary lookup program"
 maintainer="John <me@johnnynator.dev>"
 license="GPL-3.0-or-later"
 homepage="http://goldendict.org/"

From a7ff36f4a7cd61aa8fcacdafde6a07e5499459c6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 033/111] gst-libav: revbump for ffmpeg6

---
 srcpkgs/gst-libav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index b24be23fc1a6d..0f9350a251bf6 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.22.9
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"

From 7afd538792b4ead33a46ffb1f375c0bf0b01198a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Feb 2024 01:52:46 -0500
Subject: [PATCH 034/111] gst-plugins-bad1: revbump for ffmpeg6

---
 srcpkgs/gst-plugins-bad1/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index 10dc49f4c151b..b4a7f7367e7df 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-plugins-bad1'
 pkgname=gst-plugins-bad1
 version=1.22.9
-revision=1
+revision=2
 build_helper="gir"
 build_style=meson
 configure_args="-Dpackage-origin=https://voidlinux.org -Ddoc=disabled
@@ -27,7 +27,7 @@ makedepends="alsa-lib-devel celt-devel openssl-devel exempi-devel
  fdk-aac-devel flite-devel fluidsynth-devel liblrdf-devel ladspa-sdk
  lilv-devel lv2 libopenjpeg2-devel sbc-devel spandsp-devel vulkan-loader
  Vulkan-Headers webrtc-audio-processing-devel libzbar-devel ffmpeg-devel
- srt-devel libva-devel
+ srt-devel libva-devel oneVPL-devel
  $(vopt_if gme libgme-devel)"
 depends="gst-plugins-base1>=${version}"
 short_desc="GStreamer plugins from the bad set (v1.x)"

From a49339075aa08ce1e332ae629bb8089e8aea7128 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 035/111] gst-rtsp-server: revbump for ffmpeg6

---
 srcpkgs/gst-rtsp-server/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index bc2a0dea6ac15..f77026c618eb6 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
 version=1.22.9
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="glib-devel gst-plugins-bad1-devel gobject-introspection

From 2d7477cf1700520583ac23079836b349d1b998eb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 036/111] guvcview: update to 2.0.8.

---
 srcpkgs/guvcview/patches/fix-include.patch | 10 ++++++++++
 srcpkgs/guvcview/template                  |  7 +++----
 2 files changed, 13 insertions(+), 4 deletions(-)
 create mode 100644 srcpkgs/guvcview/patches/fix-include.patch

diff --git a/srcpkgs/guvcview/patches/fix-include.patch b/srcpkgs/guvcview/patches/fix-include.patch
new file mode 100644
index 0000000000000..503c2af3b78c1
--- /dev/null
+++ b/srcpkgs/guvcview/patches/fix-include.patch
@@ -0,0 +1,10 @@
+--- a/guvcview/guvcview.c
++++ b/guvcview/guvcview.c
+@@ -28,6 +28,7 @@
+ #include <sys/stat.h>
+ #include <sys/resource.h>
+ #include <errno.h>
++#include <locale.h>
+ 
+ #include "gview.h"
+ #include "gviewv4l2core.h"
diff --git a/srcpkgs/guvcview/template b/srcpkgs/guvcview/template
index d42fd38fa4ad1..86a7fd619612c 100644
--- a/srcpkgs/guvcview/template
+++ b/srcpkgs/guvcview/template
@@ -1,8 +1,7 @@
 # Template file for 'guvcview'
 pkgname=guvcview
-version=2.0.7
-revision=2
-create_wrksrc=yes
+version=2.0.8
+revision=1
 build_style=gnu-configure
 configure_args="--disable-static --disable-debian-menu"
 hostmakedepends="pkg-config intltool autoconf automake libtool glib-devel"
@@ -14,7 +13,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="http://guvcview.sourceforge.net/"
 distfiles="${SOURCEFORGE_SITE}/${pkgname}/${pkgname}-src-${version}.tar.bz2"
-checksum=f47d51fbd06e44eeaa1a82f4a153c927527c90d94514197a70b2956028cc8ad4
+checksum=a21f4e448286666cf27bafef5290cc953a0a1796b752e5bbe521266dc1230c81
 
 post_patch() {
 	sed '31a#include <locale.h>' -i  guvcview/guvcview.c

From e09c5d211cf9c70881f5bb674ece3d6c5b00ac7d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 037/111] handbrake: update to 1.6.1

---
 .../patches/fix-missing-x265-link-flag.patch    | 11 ++++++-----
 .../handbrake/patches/libhb-vpl-include.patch   | 15 +++++++++++++++
 srcpkgs/handbrake/template                      | 17 ++++++++++-------
 3 files changed, 31 insertions(+), 12 deletions(-)
 create mode 100644 srcpkgs/handbrake/patches/libhb-vpl-include.patch

diff --git a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
index 26db03867a0c8..d6bb2eda627a3 100644
--- a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
+++ b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
@@ -1,14 +1,15 @@
 --- a/gtk/configure.ac
 +++ b/gtk/configure.ac
 @@ -203,7 +203,7 @@
- 
+
  AM_CONDITIONAL([MINGW], [test "x$mingw_flag" = "xyes"])
- 
--HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg"
-+HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -ldl"
+
+-HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc"
++HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc -ldl"
  HB_CPPFLAGS="$HB_CPPFLAGS $HBINC"
- 
+
  PKG_CHECK_MODULES([x264], [x264], sys_x264=yes, sys_x264=no)
+
 --- a/test/module.defs
 +++ b/test/module.defs
 @@ -69,6 +69,9 @@
diff --git a/srcpkgs/handbrake/patches/libhb-vpl-include.patch b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
new file mode 100644
index 0000000000000..298f9f4ab28f2
--- /dev/null
+++ b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
@@ -0,0 +1,15 @@
+--- a/libhb/module.defs	2023-01-22 11:36:49.000000000 -0500
++++ b/libhb/module.defs	2023-04-03 22:37:52.395467010 -0400
+@@ -46,11 +46,7 @@
+ LIBHB.GCC.I += $(LIBHB.build/) $(CONTRIB.build/)include
+ 
+ ifeq (1,$(FEATURE.qsv))
+-    ifeq ($(HOST.system),freebsd))
+-        LIBHB.GCC.I += $(LOCALBASE)/include/vpl
+-    else
+-        LIBHB.GCC.I += $(CONTRIB.build/)include/vpl
+-    endif
++    LIBHB.GCC.I += /usr/include/vpl
+ endif
+ 
+ ifneq (,$(filter $(HOST.system),freebsd netbsd openbsd))
diff --git a/srcpkgs/handbrake/template b/srcpkgs/handbrake/template
index ca5e4571e49c3..c32cb1bfa31f4 100644
--- a/srcpkgs/handbrake/template
+++ b/srcpkgs/handbrake/template
@@ -1,10 +1,10 @@
 # Template file for 'handbrake'
 pkgname=handbrake
-version=1.5.1
+version=1.6.1
 revision=1
 build_style=gnu-configure
 configure_args="--force --disable-gtk-update-checks --disable-df-fetch --harden
- $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc)"
+ $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc) $(vopt_enable qsv)"
 make_build_args="-C ${XBPS_TRIPLET}"
 make_install_args="-C ${XBPS_TRIPLET}"
 hostmakedepends="automake cmake gettext-devel glib-devel intltool libtool m4 meson nasm pkg-config python3"
@@ -12,8 +12,11 @@ makedepends="bzip2-devel ffmpeg-devel gst-plugins-base1-devel gtk+3-devel
  jansson-devel lame-devel libass-devel libbluray-devel libdav1d-devel
  libdvdnav-devel libdvdread-devel libgudev-devel libnuma-devel
  libsamplerate-devel libtheora-devel libvorbis-devel libvpx-devel libxml2-devel
- opus-devel speex-devel x264-devel x265-devel zimg-devel
+ opus-devel speex-devel x264-devel x265-devel zimg-devel libsvt-av1-devel
  $(vopt_if fdk_aac fdk-aac-devel)
+ $(vopt_if qsv libva-devel)
+ $(vopt_if qsv libdrm-devel)
+ $(vopt_if qsv onevpl-devel)
  $(vopt_if nvenc nv-codec-headers)"
 depends="desktop-file-utils gst-plugins-good1 hicolor-icon-theme"
 short_desc="Multithreaded video transcoder"
@@ -21,15 +24,15 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-2.0-only"
 homepage="https://handbrake.fr/"
 distfiles="https://github.com/HandBrake/HandBrake/releases/download/${version}/HandBrake-${version}-source.tar.bz2"
-checksum=3999fe06d5309c819799a73a968a8ec3840e7840c2b64af8f5cdb7fd8c9430f0
+checksum=94ccfe03db917a91650000c510f7fd53f844da19f19ad4b4be1b8f6bc31a8d4c
 nocross=yes
 
-build_options="fdk_aac nvenc"
+build_options="fdk_aac nvenc qsv"
 
 case "$XBPS_TARGET_MACHINE" in
 	x86_64*|i686*)
 		CFLAGS="-msse"
-		build_options_default="nvenc"
+		build_options_default="nvenc qsv"
 		;;
 esac
 
@@ -37,7 +40,7 @@ pre_configure() {
 	# use system libraries, don't download them
 	rm -rf contrib/
 	for module in fdk-aac ffmpeg libbluray libdav1d libdvdnav libdvdread nvenc \
-		x265 zimg; do
+		x265 zimg svt-av1 libvpl; do
 	    vsed -i "/MODULES += contrib\/${module}/d" make/include/main.defs
 	done
 }

From 8d57ab9fd32e71d14ab6c749f3095b01cb070fcc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 038/111] hedgewars: revbump for ffmpeg4

---
 srcpkgs/hedgewars/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/hedgewars/template b/srcpkgs/hedgewars/template
index 94b6db673b0c3..402ccfaaecbc2 100644
--- a/srcpkgs/hedgewars/template
+++ b/srcpkgs/hedgewars/template
@@ -1,13 +1,13 @@
 # Template file for 'hedgewars'
 pkgname=hedgewars
 version=1.0.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DNOSERVER=1 -DDATA_INSTALL_DIR=/usr/share/${pkgname}
  -DPHYSFS_SYSTEM=1 -DMINIMAL_FLAGS=1"
 make_cmd=make
 hostmakedepends="lua51 pkg-config qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
+makedepends="ffmpeg4-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
  SDL2_mixer-devel SDL2_net-devel SDL2_ttf-devel"
 depends="libfreeglut"
 short_desc="Funny turn-based artillery game, featuring fighting Hedgehogs!"

From 4d77f234fb23358aab089152fbe47de7d6ea76d7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 039/111] idjc: revbump for ffmpeg4

---
 srcpkgs/idjc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/idjc/template b/srcpkgs/idjc/template
index a9cde0665d55b..f41e1e4fabbae 100644
--- a/srcpkgs/idjc/template
+++ b/srcpkgs/idjc/template
@@ -1,11 +1,11 @@
 # Template file for 'idjc'
 pkgname=idjc
 version=0.9.1
-revision=5
+revision=6
 build_style=gnu-configure
 hostmakedepends="pkg-config git python3 automake gettext-devel libtool"
 makedepends="libvorbis-devel libogg-devel jack-devel libsamplerate-devel
- libflac-devel libsndfile-devel mpg123-devel ffmpeg-devel speex-devel
+ libflac-devel libsndfile-devel mpg123-devel ffmpeg4-devel speex-devel
  glib-devel pixman-devel lame-devel python3-gobject-devel libshout-idjc-devel
  opus-devel twolame-devel python3-mutagen python3-devel"
 depends="python3-gobject python3-mutagen desktop-file-utils shared-mime-info python3-dbus jack"

From d4e8ba1a5357eb50ce29645a9ae0712fd92acd29 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 040/111] kid3: revbump for ffmpeg6

---
 srcpkgs/kid3/patches/ffmpeg5.patch | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 srcpkgs/kid3/patches/ffmpeg5.patch

diff --git a/srcpkgs/kid3/patches/ffmpeg5.patch b/srcpkgs/kid3/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..135fc50e07c9b
--- /dev/null
+++ b/srcpkgs/kid3/patches/ffmpeg5.patch
@@ -0,0 +1,17 @@
+# https://aur.archlinux.org/cgit/aur.git/diff/ffmpeg5.patch?h=kid3-cli&id=12410a74906612e7efc0ec8fbce739b4a0fef7e7
+diff --git a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+index e156d424..e12b9abd 100644
+--- a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
++++ b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+@@ -232,7 +232,11 @@ private:
+   friend class Format;
+   friend class Converter;
+   AVCodecContext* m_ptr;
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 0, 0)
+   AVCodec* m_impl;
++#else
++  const AVCodec* m_impl;
++#endif
+   AVFrame* m_frame;
+   bool m_opened;
+ };

From f11b6bda83bda8edcd8ec76a4fa8dfe9c45c1481 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 041/111] kodi: revbump for ffmpeg4

---
 srcpkgs/kodi/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/kodi/template b/srcpkgs/kodi/template
index d37a5918cd675..ea78e0aca0fe3 100644
--- a/srcpkgs/kodi/template
+++ b/srcpkgs/kodi/template
@@ -1,7 +1,7 @@
 # Template file for 'kodi'
 pkgname=kodi
 version=19.4
-revision=9
+revision=10
 _codename="Matrix"
 build_style=cmake
 configure_args="-DWITH_FFMPEG=/usr -DENABLE_LDGOLD=OFF
@@ -54,7 +54,7 @@ makedepends="
  libmad-devel fontconfig-devel libXinerama-devel libsamplerate-devel libmms-devel
  enca-devel boost-devel libcurl-devel libva-devel libvdpau-devel libass-devel
  libbluetooth-devel yajl-devel libplist-devel librtmp-devel tinyxml-devel
- taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg-devel
+ taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg4-devel
  giflib-devel libxslt-devel gnutls-devel libssh-devel libmicrohttpd-devel
  libcec-devel dcadec-devel flatbuffers-devel fmt-devel lcms2-devel
  libfstrcmp-devel rapidjson libcdio-paranoia spdlog libwaylandpp-devel

From 700e9dc078c4d34d96331fc5008c862f1519652b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 042/111] kpipewire: revbump for ffmpeg6

---
 srcpkgs/kpipewire/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kpipewire/template b/srcpkgs/kpipewire/template
index 6214a4451336e..3555348659dde 100644
--- a/srcpkgs/kpipewire/template
+++ b/srcpkgs/kpipewire/template
@@ -1,7 +1,7 @@
 # Template file for 'kpipewire'
 pkgname=kpipewire
 version=5.27.10
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules plasma-wayland-protocols gettext
  qt5-qmake qt5-host-tools pkg-config wayland-devel kcoreaddons

From 8b51db1c4b4a568c7b5e98a8fa00dc8b25198158 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 043/111] libextractor: revbump for ffmpeg4

---
 srcpkgs/libextractor/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/libextractor/template b/srcpkgs/libextractor/template
index 044c663a3a0b9..06e63bc3189d5 100644
--- a/srcpkgs/libextractor/template
+++ b/srcpkgs/libextractor/template
@@ -1,13 +1,13 @@
 # Template file for 'libextractor'
 pkgname=libextractor
 version=1.11
-revision=4
+revision=5
 build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="pkg-config"
 makedepends="zlib-devel bzip2-devel exiv2-devel tiff-devel libpng-devel
  libjpeg-turbo-devel libvorbis-devel libflac-devel giflib-devel libmpeg2-devel
- ffmpeg-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
+ ffmpeg4-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
 short_desc="Library used to extract meta data from files"
 maintainer="Martin Riese <grauehaare@gmx.de>"
 license="GPL-3.0-or-later"

From 1c4640cc8dfd9192559066f34202d3733bd6dd67 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 044/111] libopenal: revbump for ffmpeg6

---
 srcpkgs/libopenal/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenal/template b/srcpkgs/libopenal/template
index 88d0f11307d81..8308fca0393e3 100644
--- a/srcpkgs/libopenal/template
+++ b/srcpkgs/libopenal/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenal'
 pkgname=libopenal
 version=1.23.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DALSOFT_EXAMPLES=OFF"
 hostmakedepends="pkg-config"

From 288d3e624885723d2b21642990fe6a145412a2b9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 045/111] loudgain: revbump for ffmpeg6

---
 srcpkgs/loudgain/patches/ffmpeg5.patch | 11 +++++++++++
 srcpkgs/loudgain/template              |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/loudgain/patches/ffmpeg5.patch

diff --git a/srcpkgs/loudgain/patches/ffmpeg5.patch b/srcpkgs/loudgain/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..16d4510ee98fa
--- /dev/null
+++ b/srcpkgs/loudgain/patches/ffmpeg5.patch
@@ -0,0 +1,11 @@
+--- a/src/scan.c	2019-09-06 11:31:19.000000000 -0400
++++ b/src/scan.c	2023-03-23 11:15:40.867968521 -0400
+@@ -69,8 +69,6 @@
+ 	 * It is now useless
+ 	 * https://github.com/FFmpeg/FFmpeg/blob/70d25268c21cbee5f08304da95be1f647c630c15/doc/APIchanges#L86
+ 	 */
+-  if (avformat_version() < AV_VERSION_INT(58,9,100))
+-    av_register_all();
+ 
+ 	av_log_set_callback(scan_av_log);
+ 
diff --git a/srcpkgs/loudgain/template b/srcpkgs/loudgain/template
index da4f2d56e94c3..4d6bf29efb4fd 100644
--- a/srcpkgs/loudgain/template
+++ b/srcpkgs/loudgain/template
@@ -1,7 +1,7 @@
 # Template file for 'loudgain'
 pkgname=loudgain
 version=0.6.8
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libebur128-devel taglib-devel ffmpeg-devel"

From c616865b232411d37a8398fecfa18734ad28c016 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 046/111] mediastreamer: revbump for ffmpeg4

---
 srcpkgs/mediastreamer/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mediastreamer/template b/srcpkgs/mediastreamer/template
index 0fcffa7653d18..e888626b945e5 100644
--- a/srcpkgs/mediastreamer/template
+++ b/srcpkgs/mediastreamer/template
@@ -1,11 +1,11 @@
 # Template file for 'mediastreamer'
 pkgname=mediastreamer
 version=5.2.111
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DENABLE_STRICT=0 -DENABLE_UNIT_TESTS=0"
 hostmakedepends="python3"
-makedepends="bzrtp-devel ffmpeg-devel glew-devel libXv-devel libsrtp-devel
+makedepends="bzrtp-devel ffmpeg4-devel glew-devel libXv-devel libsrtp-devel
  libupnp-devel libvpx-devel mbedtls-devel opus-devel ortp-devel pulseaudio-devel
  libtheora-devel speex-devel v4l-utils-devel bcg729-devel bcmatroska2-devel libgsm-devel
  zxing-cpp-devel"

From 3c8dd1e2065b4fc37f394c399fd3f2ea3dfdc1d7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 047/111] mgba: revbump for ffmpeg6

---
 srcpkgs/mgba/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mgba/template b/srcpkgs/mgba/template
index 6cd6565031254..93401adb618bd 100644
--- a/srcpkgs/mgba/template
+++ b/srcpkgs/mgba/template
@@ -1,7 +1,7 @@
 # Template file for 'mgba'
 pkgname=mgba
 version=0.10.3
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake desktop-file-utils"
 makedepends="SDL2-devel ffmpeg-devel libedit-devel libepoxy-devel libmagick-devel

From 33b830ad6a284b3eb65d13f2ec5983583dda578b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 048/111] mlt: revbump for ffmpeg4

---
 srcpkgs/mlt/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mlt/template b/srcpkgs/mlt/template
index 73e3915aaab9a..d7ed4c4b30a86 100644
--- a/srcpkgs/mlt/template
+++ b/srcpkgs/mlt/template
@@ -1,14 +1,14 @@
 # Template file for 'mlt'
 pkgname=mlt
 version=6.26.1
-revision=3
+revision=4
 build_style=configure
 configure_args="--prefix=/usr --libdir=/usr/lib$XBPS_TARGET_WORDSIZE
  --enable-gpl --enable-gpl3 --disable-swfdec --without-kde
  --swig-languages=python"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which"
 # XXX: movit vid.stab
-makedepends="alsa-lib-devel ffmpeg-devel gtk+-devel jack-devel ladspa-sdk
+makedepends="alsa-lib-devel ffmpeg4-devel gtk+-devel jack-devel ladspa-sdk
  libexif-devel libsamplerate-devel libxml2-devel sox-devel SDL_image-devel
  fftw-devel frei0r-plugins python3-devel pulseaudio-devel movit-devel
  libvidstab-devel"

From 4dea66f5bdbd3aa21bff9928981f42dd83c2bf3d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 049/111] moc: revbump for ffmpeg4

---
 srcpkgs/moc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/moc/template b/srcpkgs/moc/template
index 3a04932c8f1e6..838755f88db09 100644
--- a/srcpkgs/moc/template
+++ b/srcpkgs/moc/template
@@ -1,10 +1,10 @@
 # Template file for 'moc'
 pkgname=moc
 version=2.5.2
-revision=7
+revision=8
 build_style=gnu-configure
 hostmakedepends="pkg-config"
-makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg-devel
+makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg4-devel
  jack-devel alsa-lib-devel libltdl-devel libflac-devel libvorbis-devel
  libmad-devel libmpcdec-devel libmodplug-devel libid3tag-devel faad2-devel
  taglib-devel libsndfile-devel wavpack-devel speex-devel libsamplerate-devel

From fcf3b44208c2625d47cf9254ef1422de74f92afc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 050/111] motion: revbump for ffmpeg6

---
 srcpkgs/motion/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/motion/template b/srcpkgs/motion/template
index 607ebeb3c7b24..bf63a91d9764f 100644
--- a/srcpkgs/motion/template
+++ b/srcpkgs/motion/template
@@ -1,7 +1,7 @@
 # Template file for 'motion'
 pkgname=motion
 version=4.6.0
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake pkg-config gettext-devel tar"
 makedepends="ffmpeg-devel libmicrohttpd-devel v4l-utils-devel gettext-devel"

From 6289506226da364e57a6112db39241d5a6e9d1c2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 051/111] olive: revbump for ffmpeg4

---
 srcpkgs/olive/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/olive/template b/srcpkgs/olive/template
index 12a46936c9900..5c2917b9c5124 100644
--- a/srcpkgs/olive/template
+++ b/srcpkgs/olive/template
@@ -1,10 +1,10 @@
 # Template file for 'olive'
 pkgname=olive
 version=0.1.2
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools pkg-config"
-makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg-devel frei0r-plugins"
+makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg4-devel frei0r-plugins"
 short_desc="Non-linear video editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"

From 069c0189a3bd496dce0b576082bde05a7e5f9989 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 052/111] opentoonz: revbump for ffmpeg6

---
 srcpkgs/opentoonz/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/opentoonz/template b/srcpkgs/opentoonz/template
index ee9f7603f55fd..3e81834ca0edd 100644
--- a/srcpkgs/opentoonz/template
+++ b/srcpkgs/opentoonz/template
@@ -1,7 +1,7 @@
 # Template file for 'opentoonz'
 pkgname=opentoonz
 version=1.6.0
-revision=2
+revision=3
 build_wrksrc="toonz/sources"
 build_style=cmake
 make_cmd=make

From 6baa45593d31e9b601f1bd0cb792e6ce32152f45 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 053/111] pianobar: revbump for ffmpeg6

---
 srcpkgs/pianobar/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pianobar/template b/srcpkgs/pianobar/template
index e3febb821a451..1e3dc1bf9308e 100644
--- a/srcpkgs/pianobar/template
+++ b/srcpkgs/pianobar/template
@@ -1,7 +1,7 @@
 # Template file for 'pianobar'
 pkgname=pianobar
 version=2022.04.01
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="V=1"
 hostmakedepends="pkg-config"

From f8e41c13bd117553eb003edc190e01c2efd1ef4b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 054/111] ppsspp: revbump for ffmpeg6

---
 srcpkgs/ppsspp/patches/ffmpeg6.patch | 15 +++++++++++++++
 srcpkgs/ppsspp/template              |  3 +--
 2 files changed, 16 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/ppsspp/patches/ffmpeg6.patch

diff --git a/srcpkgs/ppsspp/patches/ffmpeg6.patch b/srcpkgs/ppsspp/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..5803c7bf22730
--- /dev/null
+++ b/srcpkgs/ppsspp/patches/ffmpeg6.patch
@@ -0,0 +1,15 @@
+--- a/Core/HW/SimpleAudioDec.cpp	2024-02-04 08:08:02.000000000 -0500
++++ b/Core/HW/SimpleAudioDec.cpp	2024-02-15 14:48:27.114362051 -0500
+@@ -81,7 +81,11 @@
+ 		return;
+ 	}
+ 	// Find decoder
++#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(58, 18, 100)
+ 	codec_ = avcodec_find_decoder((AVCodecID)audioCodecId);
++#else // this is a macro to const in the header
++	codec_ = (AVCodec*)avcodec_find_decoder((AVCodecID)audioCodecId);
++#endif
+ 	if (!codec_) {
+ 		// Eh, we shouldn't even have managed to compile. But meh.
+ 		ERROR_LOG(ME, "This version of FFMPEG does not support AV_CODEC_ctx for audio (%s). Update your submodule.", GetCodecName(audioType));
+
diff --git a/srcpkgs/ppsspp/template b/srcpkgs/ppsspp/template
index 2238a7601c0af..1fda55268a2d3 100644
--- a/srcpkgs/ppsspp/template
+++ b/srcpkgs/ppsspp/template
@@ -1,7 +1,7 @@
 # Template file for 'ppsspp'
 pkgname=ppsspp
 version=1.17.1
-revision=1
+revision=2
 _glslang_commit=b34f619e1c85810dcb3c578107d2e48ba4ee2b37
 _SPIRV_Cross_commit=4212eef67ed0ca048cb726a6767185504e7695e5
 _armips_commit=a8d71f0f279eb0d30ecf6af51473b66ae0cf8e8d
@@ -91,7 +91,6 @@ post_configure() {
 }
 
 do_install() {
-	vlicense LICENSE.TXT
 	vinstall icons/icon.svg 644 usr/share/pixmaps ppsspp.svg
 	vinstall Qt/PPSSPP.desktop 644 usr/share/applications
 	vbin build/PPSSPPHeadless ppsspp-headless

From a988dc860e64d025344325d589f256a3a2cde8c7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 055/111] pqiv: revbump for ffmpeg6

---
 srcpkgs/pqiv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pqiv/template b/srcpkgs/pqiv/template
index 542fc27a2d32a..9308d949b6a1c 100644
--- a/srcpkgs/pqiv/template
+++ b/srcpkgs/pqiv/template
@@ -1,7 +1,7 @@
 # Template file for 'pqiv'
 pkgname=pqiv
 version=2.12
-revision=1
+revision=2
 build_style=gnu-makefile
 hostmakedepends="pkg-config"
 makedepends="glib-devel gtk+3-devel $(vopt_if ffmpeg ffmpeg-devel)

From 3b5e297941cf865584b1599010ccec892586c6fc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 056/111] qmmp: revbump for ffmpeg6

---
 srcpkgs/qmmp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qmmp/template b/srcpkgs/qmmp/template
index 53781ea3bc28a..2da07f1e87eac 100644
--- a/srcpkgs/qmmp/template
+++ b/srcpkgs/qmmp/template
@@ -1,7 +1,7 @@
 # Template file for 'qmmp'
 pkgname=qmmp
 version=1.6.1
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DUSE_HAL:BOOL=FALSE -DQMMP_DEFAULT_UI:STRING=simple"
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From d4ce77ab46662fd722fb1aa1c40cb40108acdac9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 14 Dec 2023 13:28:10 -0500
Subject: [PATCH 057/111] qt6-pdf: revbump for ffmpeg6

---
 srcpkgs/qt6-pdf/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-pdf/template b/srcpkgs/qt6-pdf/template
index ecda84afac131..531b4e1d4fe84 100644
--- a/srcpkgs/qt6-pdf/template
+++ b/srcpkgs/qt6-pdf/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-pdf'
 pkgname=qt6-pdf
 version=6.6.0
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DQT_FEATURE_qtpdf_build=ON
  -DQT_FEATURE_qtpdf_widgets_build=ON

From 441425c40ddef82939e2481d8a6707f2639e374a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 058/111] qt5-webengine: revbump for ffmpeg6

---
 .../chromium-media-filters-cpp14.patch        |  11 ++
 srcpkgs/qt5-webengine/patches/ffmpeg5.patch   | 179 ++++++++++++++++++
 .../qtwebengine-fix-ffmpeg5-build.patch       |  14 ++
 srcpkgs/qt5-webengine/template                |   4 +-
 4 files changed, 206 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/ffmpeg5.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch

diff --git a/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
new file mode 100644
index 0000000000000..04adc540f2cbc
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
@@ -0,0 +1,11 @@
+--- a/src/3rdparty/chromium/media/filters/BUILD.gn	2023-02-27 13:32:59.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/BUILD.gn	2023-04-02 17:21:39.204066384 -0400
+@@ -96,6 +96,8 @@
+     "//ui/gfx/geometry:geometry",
+   ]
+ 
++  cflags_cc = [ "-std=c++14" ]
++
+   libs = []
+ 
+   if (proprietary_codecs) {
diff --git a/srcpkgs/qt5-webengine/patches/ffmpeg5.patch b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
new file mode 100644
index 0000000000000..ac55e1634423a
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
@@ -0,0 +1,179 @@
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:57.732547446 -0400
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:09.486478995 -0400
+@@ -57,6 +57,8 @@
+ 
+ namespace {
+ 
++constexpr int64_t kRelativeTsBase = static_cast<int64_t>(0x7ffeffffffffffff);
++
+ void SetAVStreamDiscard(AVStream* stream, AVDiscard discard) {
+   DCHECK(stream);
+   stream->discard = discard;
+@@ -90,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+   if (stream->start_time != kNoFFmpegTimestamp)
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (stream->first_dts != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, stream->first_dts);
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -408,11 +398,11 @@
+   scoped_refptr<DecoderBuffer> buffer;
+ 
+   if (type() == DemuxerStream::TEXT) {
+-    int id_size = 0;
++    size_t id_size = 0;
+     uint8_t* id_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
+ 
+-    int settings_size = 0;
++    size_t settings_size = 0;
+     uint8_t* settings_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
+ 
+@@ -424,7 +414,7 @@
+     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
+                                      side_data.data(), side_data.size());
+   } else {
+-    int side_data_size = 0;
++    size_t side_data_size = 0;
+     uint8_t* side_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
+ 
+@@ -485,7 +475,7 @@
+                                        packet->size - data_offset);
+     }
+ 
+-    int skip_samples_size = 0;
++    size_t skip_samples_size = 0;
+     const uint32_t* skip_samples_ptr =
+         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
+             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
+@@ -1587,6 +1577,8 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++      continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+       lowest_start_time_stream = stream.get();
+@@ -1604,6 +1596,8 @@
+     if (stream && stream->type() == DemuxerStream::VIDEO &&
+         stream->IsEnabled()) {
+       video_stream = stream.get();
++      if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++        continue;
+       if (video_stream->start_time() <= seek_time) {
+         return video_stream;
+       }
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h qtwebengine-5.15.10/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h
+--- a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-07-11 22:12:47.917192788 -0500
+@@ -29,6 +29,7 @@ extern "C" {
+ #include <libavformat/avformat.h>
+ #include <libavformat/avio.h>
+ #include <libavutil/avutil.h>
++#include <libavutil/channel_layout.h>
+ #include <libavutil/imgutils.h>
+ #include <libavutil/log.h>
+ #include <libavutil/mastering_display_metadata.h>
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/audio_file_reader.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/audio_file_reader.cc
+--- a/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -85,7 +85,7 @@ bool AudioFileReader::OpenDemuxer() {
+ }
+ 
+ bool AudioFileReader::OpenDecoder() {
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (codec) {
+     // MP3 decodes to S16P which we don't support, tell it to use S16 instead.
+     if (codec_context_->sample_fmt == AV_SAMPLE_FMT_S16P)
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -329,7 +329,7 @@ bool FFmpegAudioDecoder::ConfigureDecode
+     }
+   }
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec ||
+       avcodec_open2(codec_context_.get(), codec, &codec_options) < 0) {
+     DLOG(ERROR) << "Could not initialize audio decoder: "
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -59,7 +59,6 @@ static int64_t AVIOSeekOperation(void* o
+ }
+ 
+ void FFmpegGlue::InitializeFFmpeg() {
+-  av_register_all();
+ }
+ 
+ static void LogContainer(bool is_local_file,
+@@ -95,9 +94,6 @@ FFmpegGlue::FFmpegGlue(FFmpegURLProtocol
+   // Enable fast, but inaccurate seeks for MP3.
+   format_context_->flags |= AVFMT_FLAG_FAST_SEEK;
+ 
+-  // Ensures we can read out various metadata bits like vp8 alpha.
+-  format_context_->flags |= AVFMT_FLAG_KEEP_SIDE_DATA;
+-
+   // Ensures format parsing errors will bail out. From an audit on 11/2017, all
+   // instances were real failures. Solves bugs like http://crbug.com/710791.
+   format_context_->error_recognition |= AV_EF_EXPLODE;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -391,7 +391,7 @@ bool FFmpegVideoDecoder::ConfigureDecode
+   if (decode_nalus_)
+     codec_context_->flags2 |= AV_CODEC_FLAG2_CHUNKS;
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
+     ReleaseFFmpegResources();
+     return false;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/media_file_checker.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/media_file_checker.cc
+--- a/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -68,7 +68,7 @@ bool MediaFileChecker::Start(base::TimeD
+       auto context = AVStreamToAVCodecContext(format_context->streams[i]);
+       if (!context)
+         continue;
+-      AVCodec* codec = avcodec_find_decoder(cp->codec_id);
++      const AVCodec* codec = avcodec_find_decoder(cp->codec_id);
+       if (codec && avcodec_open2(context.get(), codec, nullptr) >= 0) {
+         auto loop = std::make_unique<FFmpegDecodingLoop>(context.get());
+         stream_contexts[i] = {std::move(context), std::move(loop)};
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc qtwebengine-5.15.10/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc
+--- a/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -203,7 +203,7 @@ int32_t H264DecoderImpl::InitDecode(cons
+   // a pointer |this|.
+   av_context_->opaque = this;
+ 
+-  AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
+   if (!codec) {
+     // This is an indication that FFmpeg has not been initialized or it has not
+     // been compiled/initialized with the correct set of codecs.
diff --git a/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch b/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch
new file mode 100644
index 0000000000000..bc24d5b9a29cb
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch
@@ -0,0 +1,14 @@
+--- a/src/buildtools/configure.json	2023-12-09 11:06:01.503058569 -0500
++++ b/src/buildtools/configure.json	2023-12-09 11:06:14.982361345 -0500
+@@ -779,11 +779,6 @@
+             "type": "warning",
+             "condition": "config.ios && config.simulator && config.device && features.build-qtpdf",
+             "message": "Building fat libray with device and simulator architectures will disable NEON."
+-        },
+-        {
+-            "type": "fatal",
+-            "condition": "features.webengine-system-ffmpeg && !libs.webengine-ffmpeg-support",
+-            "message": "Unmodified ffmpeg >= 5.0 is not supported. Please configure with -qt-webengine-ffmpeg."
+         }
+     ],
+     "summary": [
diff --git a/srcpkgs/qt5-webengine/template b/srcpkgs/qt5-webengine/template
index 8d2df1b5175ba..1687a77eb8a2f 100644
--- a/srcpkgs/qt5-webengine/template
+++ b/srcpkgs/qt5-webengine/template
@@ -1,14 +1,14 @@
 # Template file for 'qt5-webengine'
 pkgname=qt5-webengine
 version=5.15.16
-revision=1
+revision=2
 _version="${version}-lts"
 _chromium_commit=207c2ac45ca3386d153770c6b0d2ea2ec21ca880
 archs="x86_64* i686* armv[67]* ppc64* aarch64*"
 create_wrksrc=yes
 build_style=qmake
 configure_args="--
- -webengine-icu -webengine-ffmpeg -webengine-opus -webengine-webp
+ -webengine-icu -system-ffmpeg -webengine-opus -webengine-webp
  -webengine-pepper-plugins -webengine-printing-and-pdf -webengine-proprietary-codecs
  -webengine-pulseaudio -webengine-spellchecker -webengine-webrtc -webengine-geolocation
  -webengine-kerberos -no-webengine-embedded-build $(vopt_if sndio '' '-no')-webengine-sndio

From c0ec890f8862100ea9fdb3a507a7265747caac7c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 059/111] qt5: revbump for ffmpeg6

---
 srcpkgs/qt5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5/template b/srcpkgs/qt5/template
index 3efb7e42d5fd3..27f6d5388cd15 100644
--- a/srcpkgs/qt5/template
+++ b/srcpkgs/qt5/template
@@ -3,9 +3,9 @@
 # revbump libqtxdg after bumping patch version
 pkgname=qt5
 version=5.15.11+20231124
+revision=3
 # commit 4765fa1df7a837db9c1f89c4da0dd76b74bb5fab
 # base repo: https://invent.kde.org/qt/qt/qt5
-revision=2
 build_style=meta
 hostmakedepends="cmake clang17 flex perl glib-devel pkg-config
  python3 re2c ruby which"

From 23e2eb5c7e06101e9741fc7f7f394f31e8f3518c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 060/111] qtav: revbump for ffmpeg4

---
 srcpkgs/qtav/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtav/template b/srcpkgs/qtav/template
index 775d5a139a9ef..aa69e213c984b 100644
--- a/srcpkgs/qtav/template
+++ b/srcpkgs/qtav/template
@@ -1,10 +1,10 @@
 # Template file for 'qtav'
 pkgname=qtav
 version=1.13.0
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel libass-devel libopenal-devel
+makedepends="ffmpeg4-devel libass-devel libopenal-devel
  libva-glx-devel libXv-devel pulseaudio-devel
  qt5-declarative-devel qt5-svg-devel
  qt5-quickcontrols"

From d84739821997698df60cf8361e51ad4db700f54f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 061/111] retroarch: revbump for ffmpeg6

---
 srcpkgs/retroarch/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroarch/template b/srcpkgs/retroarch/template
index cb3125c5dbf1a..c65c26f7bf033 100644
--- a/srcpkgs/retroarch/template
+++ b/srcpkgs/retroarch/template
@@ -1,7 +1,7 @@
 # Template file for 'retroarch'
 pkgname=retroarch
 version=1.16.0.3
-revision=3
+revision=4
 build_style=configure
 configure_args="--prefix=/usr --sysconfdir=/etc --enable-networking
  --enable-udev --disable-builtinflac --disable-builtinglslang

From 65cb8ff64505d824c0dc3767d09eb8f438c55d76 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 062/111] scrcpy: revbump for ffmpeg6

---
 srcpkgs/scrcpy/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/scrcpy/template b/srcpkgs/scrcpy/template
index d04de770dc191..5218fa01f8ce1 100644
--- a/srcpkgs/scrcpy/template
+++ b/srcpkgs/scrcpy/template
@@ -1,7 +1,7 @@
 # Template file for 'scrcpy'
 pkgname=scrcpy
 version=2.3.1
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcompile_server=false
  -Dprebuilt_server=/usr/share/scrcpy/scrcpy-server-v${version}"

From ed4956465b4aa7c873b3b1ed426ab5e962a454d2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 17 Oct 2023 08:54:11 -0400
Subject: [PATCH 063/111] New package: spex-x replaces spek-alternative for
 ffmpeg6

---
 srcpkgs/spek-alternative                      |  1 +
 srcpkgs/{spek-alternative => spek-x}/template | 22 ++++++++++++-------
 2 files changed, 15 insertions(+), 8 deletions(-)
 create mode 120000 srcpkgs/spek-alternative
 rename srcpkgs/{spek-alternative => spek-x}/template (52%)

diff --git a/srcpkgs/spek-alternative b/srcpkgs/spek-alternative
new file mode 120000
index 0000000000000..76648236da701
--- /dev/null
+++ b/srcpkgs/spek-alternative
@@ -0,0 +1 @@
+spek-x
\ No newline at end of file
diff --git a/srcpkgs/spek-alternative/template b/srcpkgs/spek-x/template
similarity index 52%
rename from srcpkgs/spek-alternative/template
rename to srcpkgs/spek-x/template
index d7b55c776b1d4..3ded6c2c323e4 100644
--- a/srcpkgs/spek-alternative/template
+++ b/srcpkgs/spek-x/template
@@ -1,18 +1,18 @@
-# Template file for 'spek-alternative'
-pkgname=spek-alternative
-version=0.8.2.3
-revision=2
+# Template file for 'spek-x'
+pkgname=spek-x
+version=0.9.3
+revision=1
 build_style=gnu-configure
 hostmakedepends="automake gettext-devel intltool libtool pkg-config
  wxWidgets-common wxWidgets-gtk3-devel"
 makedepends="ffmpeg-devel wxWidgets-gtk3-devel"
 depends="ffmpeg"
 short_desc="Acoustic spectrum analyser"
-maintainer="Kartik Singh <kartik.ynwa@gmail.com>"
+maintainer="zlice <zlice555@gmail.com>"
 license="GPL-3.0-or-later"
-homepage="https://github.com/withmorten/spek-alternative"
-distfiles="https://github.com/withmorten/spek-alternative/archive/${version}.tar.gz"
-checksum="007ba4b84a310b078e378aa84c8e80783db5821437a757a488c3ecec377e6b2a"
+homepage="https://github.com/MikeWang000000/spek-x"
+distfiles="https://github.com/MikeWang000000/spek-x/archive/v${version}.tar.gz"
+checksum="7f4b109903333cdd310ab2b9176f0dc49a565891376e281a233d342cedf90ef7"
 
 CXXFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
 
@@ -22,3 +22,9 @@ export WX_CONFIG_NAME="wx-config-gtk3"
 pre_configure() {
 	NOCONFIGURE=1 ./autogen.sh
 }
+
+spek-alternative_package() {
+	depends="spek-x"
+	short_desc+=" - transitional dummy package"
+	build_style=meta
+}

From bd4d8c57f3bad5b49f59398e90e22e1a2d770be6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 064/111] ssr: revbump for ffmpeg6

---
 .../0001-Fix-build-with-ffmpeg-5.0.patch      | 241 ++++++++++++++++++
 srcpkgs/ssr/template                          |   2 +-
 2 files changed, 242 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ssr/patches/0001-Fix-build-with-ffmpeg-5.0.patch

diff --git a/srcpkgs/ssr/patches/0001-Fix-build-with-ffmpeg-5.0.patch b/srcpkgs/ssr/patches/0001-Fix-build-with-ffmpeg-5.0.patch
new file mode 100644
index 0000000000000..4c069b5a9fc46
--- /dev/null
+++ b/srcpkgs/ssr/patches/0001-Fix-build-with-ffmpeg-5.0.patch
@@ -0,0 +1,241 @@
+From f4cbde38021d9330dc73d2e3dfa8a70da3ff5721 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Bernhard=20Rosenkr=C3=A4nzer?= <bero@lindev.ch>
+Date: Sun, 16 Jan 2022 02:40:04 +0100
+Subject: [PATCH] Fix build with ffmpeg 5.0
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Adapt to ffmpeg 5.0 requiring more const-ness for AVCodec.
+
+Signed-off-by: Bernhard Rosenkränzer <bero@lindev.ch>
+---
+ src/AV/Output/AudioEncoder.cpp |  6 +++---
+ src/AV/Output/AudioEncoder.h   |  4 ++--
+ src/AV/Output/BaseEncoder.cpp  |  4 ++--
+ src/AV/Output/BaseEncoder.h    |  4 ++--
+ src/AV/Output/Muxer.cpp        | 12 ++++++------
+ src/AV/Output/Muxer.h          |  4 ++--
+ src/AV/Output/VideoEncoder.cpp |  6 +++---
+ src/AV/Output/VideoEncoder.h   |  4 ++--
+ 8 files changed, 22 insertions(+), 22 deletions(-)
+
+diff --git a/src/AV/Output/AudioEncoder.cpp b/src/AV/Output/AudioEncoder.cpp
+index 34d015c..cefc2e0 100644
+--- a/src/AV/Output/AudioEncoder.cpp
++++ b/src/AV/Output/AudioEncoder.cpp
+@@ -34,7 +34,7 @@ const std::vector<AudioEncoder::SampleFormatData> AudioEncoder::SUPPORTED_SAMPLE
+ 
+ const unsigned int AudioEncoder::DEFAULT_FRAME_SAMPLES = 1024;
+ 
+-AudioEncoder::AudioEncoder(Muxer* muxer, AVStream* stream, AVCodecContext *codec_context, AVCodec* codec, AVDictionary** options)
++AudioEncoder::AudioEncoder(Muxer* muxer, AVStream* stream, AVCodecContext *codec_context, const AVCodec* codec, AVDictionary** options)
+ 	: BaseEncoder(muxer, stream, codec_context, codec, options) {
+ 
+ #if !SSR_USE_AVCODEC_ENCODE_AUDIO2
+@@ -77,7 +77,7 @@ unsigned int AudioEncoder::GetSampleRate() {
+ }
+ 
+ bool AudioEncoder::AVCodecIsSupported(const QString& codec_name) {
+-	AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
++	const AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
+ 	if(codec == NULL)
+ 		return false;
+ 	if(!av_codec_is_encoder(codec))
+@@ -93,7 +93,7 @@ bool AudioEncoder::AVCodecIsSupported(const QString& codec_name) {
+ 	return false;
+ }
+ 
+-void AudioEncoder::PrepareStream(AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
++void AudioEncoder::PrepareStream(AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
+ 								 unsigned int bit_rate, unsigned int channels, unsigned int sample_rate) {
+ 
+ 	if(channels == 0) {
+diff --git a/src/AV/Output/AudioEncoder.h b/src/AV/Output/AudioEncoder.h
+index c93278c..ae9c82e 100644
+--- a/src/AV/Output/AudioEncoder.h
++++ b/src/AV/Output/AudioEncoder.h
+@@ -40,7 +40,7 @@ private:
+ #endif
+ 
+ public:
+-	AudioEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options);
++	AudioEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options);
+ 	~AudioEncoder();
+ 
+ 	// Returns the required frame size, i.e. the number of samples (for each channel).
+@@ -57,7 +57,7 @@ public:
+ 
+ public:
+ 	static bool AVCodecIsSupported(const QString& codec_name);
+-	static void PrepareStream(AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
++	static void PrepareStream(AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
+ 							  unsigned int bit_rate, unsigned int channels, unsigned int sample_rate);
+ 
+ private:
+diff --git a/src/AV/Output/BaseEncoder.cpp b/src/AV/Output/BaseEncoder.cpp
+index 7c01ef3..4780aaf 100644
+--- a/src/AV/Output/BaseEncoder.cpp
++++ b/src/AV/Output/BaseEncoder.cpp
+@@ -42,7 +42,7 @@ double ParseCodecOptionDouble(const QString& key, const QString& value, double m
+ 	return clamp(value_double, min, max) * multiply;
+ }
+ 
+-BaseEncoder::BaseEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options) {
++BaseEncoder::BaseEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options) {
+ 
+ 	m_muxer = muxer;
+ 	m_stream = stream;
+@@ -157,7 +157,7 @@ void BaseEncoder::IncrementPacketCounter() {
+ 	++lock->m_total_packets;
+ }
+ 
+-void BaseEncoder::Init(AVCodec* codec, AVDictionary** options) {
++void BaseEncoder::Init(const AVCodec* codec, AVDictionary** options) {
+ 
+ 	// open codec
+ 	if(avcodec_open2(m_codec_context, codec, options) < 0) {
+diff --git a/src/AV/Output/BaseEncoder.h b/src/AV/Output/BaseEncoder.h
+index 3d92f29..7f02bbd 100644
+--- a/src/AV/Output/BaseEncoder.h
++++ b/src/AV/Output/BaseEncoder.h
+@@ -51,7 +51,7 @@ private:
+ 	std::atomic<bool> m_should_stop, m_should_finish, m_is_done, m_error_occurred;
+ 
+ protected:
+-	BaseEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options);
++	BaseEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options);
+ 
+ public:
+ 	virtual ~BaseEncoder(); // encoders will be deleted by Muxer, don't delete them yourself!
+@@ -117,7 +117,7 @@ protected:
+ 	void IncrementPacketCounter();
+ 
+ private:
+-	void Init(AVCodec* codec, AVDictionary** options);
++	void Init(const AVCodec* codec, AVDictionary** options);
+ 	void Free();
+ 
+ 	void EncoderThread();
+diff --git a/src/AV/Output/Muxer.cpp b/src/AV/Output/Muxer.cpp
+index ad58380..14650b0 100644
+--- a/src/AV/Output/Muxer.cpp
++++ b/src/AV/Output/Muxer.cpp
+@@ -87,7 +87,7 @@ Muxer::~Muxer() {
+ 
+ VideoEncoder* Muxer::AddVideoEncoder(const QString& codec_name, const std::vector<std::pair<QString, QString> >& codec_options,
+ 									 unsigned int bit_rate, unsigned int width, unsigned int height, unsigned int frame_rate) {
+-	AVCodec *codec = FindCodec(codec_name);
++	const AVCodec *codec = FindCodec(codec_name);
+ 	AVCodecContext *codec_context = NULL;
+ 	AVStream *stream = AddStream(codec, &codec_context);
+ 	VideoEncoder *encoder;
+@@ -111,7 +111,7 @@ VideoEncoder* Muxer::AddVideoEncoder(const QString& codec_name, const std::vecto
+ 
+ AudioEncoder* Muxer::AddAudioEncoder(const QString& codec_name, const std::vector<std::pair<QString, QString> >& codec_options,
+ 									 unsigned int bit_rate, unsigned int channels, unsigned int sample_rate) {
+-	AVCodec *codec = FindCodec(codec_name);
++	const AVCodec *codec = FindCodec(codec_name);
+ 	AVCodecContext *codec_context = NULL;
+ 	AVStream *stream = AddStream(codec, &codec_context);
+ 	AudioEncoder *encoder;
+@@ -194,7 +194,7 @@ unsigned int Muxer::GetQueuedPacketCount(unsigned int stream_index) {
+ void Muxer::Init() {
+ 
+ 	// get the format we want (this is just a pointer, we don't have to free this)
+-	AVOutputFormat *format = av_guess_format(m_container_name.toUtf8().constData(), NULL, NULL);
++	const AVOutputFormat *format = av_guess_format(m_container_name.toUtf8().constData(), NULL, NULL);
+ 	if(format == NULL) {
+ 		Logger::LogError("[Muxer::Init] " + Logger::tr("Error: Can't find chosen output format!"));
+ 		throw LibavException();
+@@ -261,8 +261,8 @@ void Muxer::Free() {
+ 	}
+ }
+ 
+-AVCodec* Muxer::FindCodec(const QString& codec_name) {
+-	AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
++const AVCodec* Muxer::FindCodec(const QString& codec_name) {
++	const AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
+ 	if(codec == NULL) {
+ 		Logger::LogError("[Muxer::FindCodec] " + Logger::tr("Error: Can't find codec!"));
+ 		throw LibavException();
+@@ -270,7 +270,7 @@ AVCodec* Muxer::FindCodec(const QString& codec_name) {
+ 	return codec;
+ }
+ 
+-AVStream* Muxer::AddStream(AVCodec* codec, AVCodecContext** codec_context) {
++AVStream* Muxer::AddStream(const AVCodec* codec, AVCodecContext** codec_context) {
+ 	assert(!m_started);
+ 	assert(m_format_context->nb_streams < MUXER_MAX_STREAMS);
+ 
+diff --git a/src/AV/Output/Muxer.h b/src/AV/Output/Muxer.h
+index d72347d..b104bcb 100644
+--- a/src/AV/Output/Muxer.h
++++ b/src/AV/Output/Muxer.h
+@@ -114,8 +114,8 @@ private:
+ 	void Init();
+ 	void Free();
+ 
+-	AVCodec* FindCodec(const QString& codec_name);
+-	AVStream* AddStream(AVCodec* codec, AVCodecContext** codec_context);
++	const AVCodec* FindCodec(const QString& codec_name);
++	AVStream* AddStream(const AVCodec* codec, AVCodecContext** codec_context);
+ 
+ 	void MuxerThread();
+ 
+diff --git a/src/AV/Output/VideoEncoder.cpp b/src/AV/Output/VideoEncoder.cpp
+index 8087e8e..fc8b5d1 100644
+--- a/src/AV/Output/VideoEncoder.cpp
++++ b/src/AV/Output/VideoEncoder.cpp
+@@ -34,7 +34,7 @@ const std::vector<VideoEncoder::PixelFormatData> VideoEncoder::SUPPORTED_PIXEL_F
+ 	{"rgb", AV_PIX_FMT_RGB24, false},
+ };
+ 
+-VideoEncoder::VideoEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options)
++VideoEncoder::VideoEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options)
+ 	: BaseEncoder(muxer, stream, codec_context, codec, options) {
+ 
+ #if !SSR_USE_AVCODEC_ENCODE_VIDEO2
+@@ -95,7 +95,7 @@ unsigned int VideoEncoder::GetFrameRate() {
+ }
+ 
+ bool VideoEncoder::AVCodecIsSupported(const QString& codec_name) {
+-	AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
++	const AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
+ 	if(codec == NULL)
+ 		return false;
+ 	if(!av_codec_is_encoder(codec))
+@@ -111,7 +111,7 @@ bool VideoEncoder::AVCodecIsSupported(const QString& codec_name) {
+ 	return false;
+ }
+ 
+-void VideoEncoder::PrepareStream(AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
++void VideoEncoder::PrepareStream(AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
+ 								 unsigned int bit_rate, unsigned int width, unsigned int height, unsigned int frame_rate) {
+ 
+ 	if(width == 0 || height == 0) {
+diff --git a/src/AV/Output/VideoEncoder.h b/src/AV/Output/VideoEncoder.h
+index cb7ca27..68d872e 100644
+--- a/src/AV/Output/VideoEncoder.h
++++ b/src/AV/Output/VideoEncoder.h
+@@ -40,7 +40,7 @@ private:
+ #endif
+ 
+ public:
+-	VideoEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options);
++	VideoEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options);
+ 	~VideoEncoder();
+ 
+ 	// Returns the required pixel format.
+@@ -55,7 +55,7 @@ public:
+ 
+ public:
+ 	static bool AVCodecIsSupported(const QString& codec_name);
+-	static void PrepareStream(AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
++	static void PrepareStream(AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
+ 							  unsigned int bit_rate, unsigned int width, unsigned int height, unsigned int frame_rate);
+ 
+ private:
+-- 
+2.43.0
+
diff --git a/srcpkgs/ssr/template b/srcpkgs/ssr/template
index 3097754e3cbe5..e3c4261f1f5a6 100644
--- a/srcpkgs/ssr/template
+++ b/srcpkgs/ssr/template
@@ -1,7 +1,7 @@
 # Template file for 'ssr'
 pkgname=ssr
 version=0.4.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DWITH_QT5=ON"
 hostmakedepends="pkg-config"

From 5522d2cb9e79e21ac011b1eadc052b934c1c89b5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 065/111] synfig: revbump for ffmpeg6 and mlt7

---
 srcpkgs/synfig/patches/ffmpeg6.patch | 71 ++++++++++++++++++++++++++++
 srcpkgs/synfig/template              |  6 +--
 2 files changed, 74 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/synfig/patches/ffmpeg6.patch

diff --git a/srcpkgs/synfig/patches/ffmpeg6.patch b/srcpkgs/synfig/patches/ffmpeg6.patch
new file mode 100644
index 0000000000000..10780b42782f4
--- /dev/null
+++ b/srcpkgs/synfig/patches/ffmpeg6.patch
@@ -0,0 +1,71 @@
+--- a/src/modules/mod_libavcodec/trgt_av.cpp	2022-10-25 09:14:12.000000000 -0400
++++ b/src/modules/mod_libavcodec/trgt_av.cpp	2023-05-05 21:34:17.899194559 -0400
+@@ -38,6 +41,7 @@
+ extern "C"
+ {
+ #ifdef HAVE_LIBAVFORMAT_AVFORMAT_H
++#	include <libavcodec/avcodec.h>
+ #	include <libavformat/avformat.h>
+ #elif defined(HAVE_AVFORMAT_H)
+ #	include <avformat.h>
+@@ -155,11 +156,11 @@
+     }
+ 
+ 	bool open_video_stream() {
+-		if (avcodec_open2(video_context, NULL, NULL) < 0) {
++		if (avcodec_open2(video_context, nullptr, nullptr) < 0) {
+ 			synfig::error("Target_LibAVCodec: could not open video codec");
+ 			// seems the calling of avcodec_free_context after error will cause crash
+ 			// so just forget about this context
+-			video_context = NULL;
++			video_context = nullptr;
+ 			close();
+ 			return false;
+         }
+@@ -234,15 +235,21 @@
+ 		close();
+ 
+ 		if (!av_registered) {
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 			av_register_all();
++#endif
+ 			av_registered = true;
+ 		}
+ 
+ 		// guess format
+-		AVOutputFormat *format = av_guess_format(NULL, filename.c_str(), NULL);
++#if LIBAVCODEC_VERSION_MAJOR < 59 // FFMPEG < 5.0
++		AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#else
++		const AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#endif
+ 		if (!format) {
+ 			synfig::warning("Target_LibAVCodec: unable to guess the output format, defaulting to MPEG");
+-			format = av_guess_format("mpeg", NULL, NULL);
++			format = av_guess_format("mpeg", nullptr, nullptr);
+ 		}
+ 		if (!format) {
+ 			synfig::error("Target_LibAVCodec: unable to find 'mpeg' output format");
+@@ -254,6 +261,7 @@
+ 		context = avformat_alloc_context();
+ 		assert(context);
+ 		context->oformat = format;
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 		if (filename.size() + 1 > sizeof(context->filename)) {
+ 			synfig::error(
+ 				"Target_LibAVCodec: filename too long, max length is %d, filename is '%s'",
+@@ -263,6 +271,14 @@
+ 			return false;
+ 		}
+ 		memcpy(context->filename, filename.c_str(), filename.size() + 1);
++#else
++		context->url = av_strndup(filename.c_str(), filename.size());
++		if (!context->url) {
++			synfig::error("Target_LibAVCodec: cannot allocate space for filename");
++			close();
++			return false;
++		}
++#endif
+ 
+ 		packet = av_packet_alloc();
+ 		assert(packet);
diff --git a/srcpkgs/synfig/template b/srcpkgs/synfig/template
index d4d3e341a20bf..828b5cb32956e 100644
--- a/srcpkgs/synfig/template
+++ b/srcpkgs/synfig/template
@@ -2,11 +2,11 @@
 # Should be kept in sync with 'synfigstudio' and 'ETL'
 pkgname=synfig
 version=1.4.4
-revision=4
+revision=5
 build_style=gnu-configure
 configure_args="--with-boost-libdir=${XBPS_CROSS_BASE}/usr/lib"
 hostmakedepends="boost-build ImageMagick pkg-config intltool"
-makedepends="ETL gettext-devel libxml++-devel mlt-devel libmagick-devel
+makedepends="ETL gettext-devel libxml++-devel mlt7-devel libmagick-devel
  libmng-devel boost-build boost-devel libopenexr-devel ffmpeg-devel"
 depends="ImageMagick"
 short_desc="CLI 2D vector and timeline-based animation software"
@@ -20,7 +20,7 @@ CXXFLAGS="-std=c++11 -DHAVE_LOCALE_H=1"
 
 synfig-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision}
-	 libopenexr-devel libxml++-devel mlt-devel"
+	 libopenexr-devel libxml++-devel mlt7-devel"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/bin/synfig-config

From 445a62363f4f872c492f38000c632eca86622f4e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 066/111] timg: revbump for ffmpeg6

---
 srcpkgs/timg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/timg/template b/srcpkgs/timg/template
index 2a2ab763d2fdd..8fb4327535ef9 100644
--- a/srcpkgs/timg/template
+++ b/srcpkgs/timg/template
@@ -1,7 +1,7 @@
 # Template file for 'timg'
 pkgname=timg
 version=1.4.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_OPENSLIDE_SUPPORT=off -Wno-dev"
 hostmakedepends="pkg-config git"

From 479cf322a804ea8e47a38c50ab0afcab5d8d0a3f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 067/111] tvheadend: revbump for ffmpeg4

---
 srcpkgs/tvheadend/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tvheadend/template b/srcpkgs/tvheadend/template
index 9aea7de4ec705..012d31c4879ff 100644
--- a/srcpkgs/tvheadend/template
+++ b/srcpkgs/tvheadend/template
@@ -8,7 +8,7 @@ configure_args="--enable-dvbscan --disable-ffmpeg_static
 --disable-libx265_static --disable-libvpx_static --disable-libtheora_static
 --disable-libvorbis_static --disable-libfdkaac_static"
 hostmakedepends="gettext pkg-config python3 git which"
-makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg-devel"
+makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg4-devel"
 short_desc="TV streaming server"
 maintainer="lemmi <lemmi@nerd2nerd.org>"
 license="GPL-3.0-only"

From 6b66a149842382ec4cfc27c000a0dcfc2082cd11 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 068/111] unpaper: update to 7.0.0.

---
 srcpkgs/unpaper/template | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/srcpkgs/unpaper/template b/srcpkgs/unpaper/template
index 38ed47a584016..1ff910e722afc 100644
--- a/srcpkgs/unpaper/template
+++ b/srcpkgs/unpaper/template
@@ -1,13 +1,13 @@
 # Template file for 'unpaper'
 pkgname=unpaper
-version=6.1
-revision=3
-build_style=gnu-configure
+version=7.0.0
+revision=1
+build_style=meson
+hostmakedepends="pkg-config meson libxslt"
+makedepends="ffmpeg-devel python3-Sphinx"
+short_desc="Post-processing tool for scanned sheets of paper"
 maintainer="Orphaned <orphan@voidlinux.org>"
-hostmakedepends="pkg-config libxslt"
-makedepends="ffmpeg-devel"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://www.flameeyes.eu/projects/unpaper"
-short_desc="A post-processing tool for scanned sheets of paper"
 distfiles="https://www.flameeyes.eu/files/${pkgname}-${version}.tar.xz"
-checksum=237c84f5da544b3f7709827f9f12c37c346cdf029b1128fb4633f9bafa5cb930
+checksum=2575fbbf26c22719d1cb882b59602c9900c7f747118ac130883f63419be46a80

From 1bec8232284c25917c56682031037c45e34eccc0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 069/111] vice: revbump for ffmpeg4

---
 srcpkgs/vice/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/vice/template b/srcpkgs/vice/template
index b1f866d35095e..43f79243a1da1 100644
--- a/srcpkgs/vice/template
+++ b/srcpkgs/vice/template
@@ -1,7 +1,7 @@
 # Template file for 'vice'
 pkgname=vice
 version=3.7.1
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="
 	$(vopt_enable sdl2 sdlui2)
@@ -26,7 +26,7 @@ makedepends="
 	$(vopt_if gtk3 gtk+3-devel)
 	$(vopt_if gtk3 pulseaudio-devel)
 	$(vopt_if gtk3 pango-devel)
-	$(vopt_if ffmpeg ffmpeg-devel)"
+	$(vopt_if ffmpeg ffmpeg4-devel)"
 short_desc="Emulator for C64, C128, CBM-II, PET, VIC20, Plus4 and C16"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"

From 999af04cf7d033162749854152f63b51bb141de2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 070/111] waypipe: revbump for ffmpeg6

---
 srcpkgs/waypipe/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waypipe/template b/srcpkgs/waypipe/template
index 6da88b21bf2a1..4da8058400b58 100644
--- a/srcpkgs/waypipe/template
+++ b/srcpkgs/waypipe/template
@@ -1,7 +1,7 @@
 # Template file for 'waypipe'
 pkgname=waypipe
 version=0.8.6
-revision=1
+revision=2
 build_style=meson
 # lto is off because it causes linking errors in armv6l and armv7l (due to NEON)
 configure_args="-Dwerror=false -Dwith_dmabuf=enabled -Dwith_lz4=enabled

From 44d452a4ea493f6595788678c05afd9c9877a8f2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 071/111] xpra: revbump for ffmpeg6

---
 srcpkgs/xpra/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xpra/template b/srcpkgs/xpra/template
index f4a44ea814867..c0f66c9483d49 100644
--- a/srcpkgs/xpra/template
+++ b/srcpkgs/xpra/template
@@ -1,7 +1,7 @@
 # Template file for 'xpra'
 pkgname=xpra
 version=5.0.5
-revision=1
+revision=2
 build_style=python3-module
 make_build_args="--without-cuda_kernels --without-cuda_rebuild"
 make_install_args="$(vopt_with docs) ${make_build_args}"

From 5ebd60fb03aba02b1de9c989f6cd660a26f878f3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:07:40 -0400
Subject: [PATCH 072/111] nv-codec-headers: update to 12.0.16.0

---
 srcpkgs/nv-codec-headers/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/nv-codec-headers/template b/srcpkgs/nv-codec-headers/template
index 3d422a61e4891..251e057f826fb 100644
--- a/srcpkgs/nv-codec-headers/template
+++ b/srcpkgs/nv-codec-headers/template
@@ -1,6 +1,6 @@
 # Template file for 'nv-codec-headers'
 pkgname=nv-codec-headers
-version=11.1.5.1
+version=12.0.16.0
 revision=1
 build_style=gnu-makefile
 short_desc="FFmpeg version of headers required to interface with Nvidias codec APIs"
@@ -8,7 +8,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="MIT"
 homepage="http://git.videolan.org/?p=ffmpeg/nv-codec-headers.git"
 distfiles="https://github.com/FFmpeg/nv-codec-headers/archive/n${version}.tar.gz"
-checksum=d095fbd56aa93772471a323be0ebe65504a0f43f06c76a30b6d25da77b06ae9c
+checksum=2a1533b65f55f9da52956faf0627ed3b74868ac0c7f269990edd21369113b48f
 
 post_install() {
 	sed -n '4,25p' include/ffnvcodec/nvEncodeAPI.h > LICENSE

From 6cf75de567580a8a144ee70554cd7fdf77e4117f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:08:40 -0400
Subject: [PATCH 073/111] openimagedenoise: revbump for ffmpeg6

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index b792813dba7c2..109deb171c3f7 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,7 +1,7 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
 version=1.4.3
-revision=1
+revision=2
 archs="x86_64*"
 build_style=cmake
 hostmakedepends="ispc python3"

From e708783ea5e5ff18552c1ec8fb1599a4b4bb4de8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:31:45 -0400
Subject: [PATCH 074/111] shotcut: revbump for ffmpeg6

---
 srcpkgs/shotcut/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/shotcut/template b/srcpkgs/shotcut/template
index 33141fbd862d7..f46cb53b6bfb9 100644
--- a/srcpkgs/shotcut/template
+++ b/srcpkgs/shotcut/template
@@ -1,7 +1,7 @@
 # Template file for 'shotcut'
 pkgname=shotcut
 version=23.09.29
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSHOTCUT_VERSION=${version}"
 hostmakedepends="pkg-config qt6-tools-devel"

From 1b3c527f9723943c049dbe5dae6b5bf074fe34e3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:30 -0400
Subject: [PATCH 075/111] shiboken2: revbump for qt5-5.15.11

---
 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch | 1 +
 1 file changed, 1 insertion(+)
 create mode 120000 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
new file mode 120000
index 0000000000000..efcf3249bd885
--- /dev/null
+++ b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1 @@
+../../python3-pyside2/patches/importlib-machinery-bypass.patch
\ No newline at end of file

From 0be3821903f979193fa753d6df1064e7998019dd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:53 -0400
Subject: [PATCH 076/111] python3-pyside2: revbump for qt5-5.15.11

---
 .../patches/importlib-machinery-bypass.patch      | 15 +++++++++++++++
 srcpkgs/python3-pyside2/template                  |  2 +-
 2 files changed, 16 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
new file mode 100644
index 0000000000000..64c429584776b
--- /dev/null
+++ b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1,15 @@
+Using this prevents an error around line 220 below it.
+"AttributeError: module 'importlib' has no attribute 'machinery'"
+The old backup logic is in place and compiles without issues.
+--- a/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:09:34.688912402 -0400
++++ b/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:10:03.395529582 -0400
+@@ -170,9 +170,6 @@
+
+     # 'zipstring_sequence' comes from signature.cpp
+     zipbytes = base64.b64decode(''.join(zipstring_sequence))
+-    if sys.version_info[0] >= 3:
+-        vzip = zipfile.ZipFile(io.BytesIO(zipbytes))
+-        return sys.meta_path, EmbeddableZipImporter(vzip)
+
+     # Old version for Python 2.7, only.
+     import os
diff --git a/srcpkgs/python3-pyside2/template b/srcpkgs/python3-pyside2/template
index 249efa9098842..52626436ce75f 100644
--- a/srcpkgs/python3-pyside2/template
+++ b/srcpkgs/python3-pyside2/template
@@ -1,7 +1,7 @@
 # Template file for 'python3-pyside2'
 pkgname=python3-pyside2
 version=5.15.10
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/pyside2"
 build_style=cmake

From 691cf16bbf9031de923e68efe33a896f1b950199 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:35 -0400
Subject: [PATCH 077/111] konqueror: revbump for ffmpeg6

---
 srcpkgs/konqueror/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/konqueror/template b/srcpkgs/konqueror/template
index 044dafa605ba6..63dd01fafc780 100644
--- a/srcpkgs/konqueror/template
+++ b/srcpkgs/konqueror/template
@@ -1,11 +1,11 @@
 # Template file for 'konqueror'
 pkgname=konqueror
 version=23.08.4
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DDESKTOPTOJSON_EXECUTABLE=/usr/bin/desktoptojson"
 hostmakedepends="extra-cmake-modules python3 qt5-host-tools qt5-qmake kdoctools
-kcoreaddons kconfig gettext"
+ kcoreaddons kconfig gettext"
 makedepends="qt5-devel qt5-webengine-devel qt5-declarative-devel
  qt5-webchannel-devel qt5-location-devel kcmutils-devel kdelibs4support-devel
  karchive-devel khtml-devel kdesu-devel kactivities5-devel"

From 572a077a044afd57e8a211b79a9b8420c3a11152 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:58 -0400
Subject: [PATCH 078/111] qt5-speech: revbump for qt5-5.15.11

---
 srcpkgs/qt5-speech/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-speech/template b/srcpkgs/qt5-speech/template
index 1228bb60c41db..27a7da1dbdb91 100644
--- a/srcpkgs/qt5-speech/template
+++ b/srcpkgs/qt5-speech/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-speech'
 pkgname=qt5-speech
 version=5.15.11
-revision=1
+revision=2
 _commit=d32f4a479d38a11f547598004b975f4356424a16
 build_style=qmake
 configure_args="-- -flite -flite-alsa -speechd"

From 28b5334152fcdc928503fcddd9ff38a9133cc3d7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Jun 2023 08:20:22 -0400
Subject: [PATCH 079/111] gtk4: revbump for ffmpeg6

---
 srcpkgs/gtk4/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gtk4/template b/srcpkgs/gtk4/template
index d8ee60abe06f7..55bff6e33849a 100644
--- a/srcpkgs/gtk4/template
+++ b/srcpkgs/gtk4/template
@@ -1,7 +1,7 @@
 # Template file for 'gtk4'
 pkgname=gtk4
 version=4.12.3
-revision=1
+revision=2
 build_style=meson
 build_helper="gir"
 configure_args="-Dman-pages=true -Ddocumentation=true -Dbuild-tests=false

From e30c6b1e9618f5f004efbc85f0d60c2c08fb74c4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:28:26 -0400
Subject: [PATCH 080/111] siril: revbump for ffmpeg6

---
 srcpkgs/siril/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/siril/template b/srcpkgs/siril/template
index 84332f79d060d..62750dd247548 100644
--- a/srcpkgs/siril/template
+++ b/srcpkgs/siril/template
@@ -1,7 +1,7 @@
 # Template file for 'siril'
 pkgname=siril
 version=0.9.12
-revision=10
+revision=11
 build_style=gnu-configure
 hostmakedepends="pkg-config intltool autoconf automake gettext-devel"
 makedepends="fftw-devel libconfig-devel libopencv-devel libffms2-devel

From 9413b1dcdf64ea62c86fbf937b0f6ad1ee3cb622 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 22 Jun 2023 10:25:02 -0400
Subject: [PATCH 081/111] kdenlive: revbump for ffmpeg6

---
 srcpkgs/kdenlive/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kdenlive/template b/srcpkgs/kdenlive/template
index a0f3615c9c530..d63166f95c4d7 100644
--- a/srcpkgs/kdenlive/template
+++ b/srcpkgs/kdenlive/template
@@ -1,7 +1,7 @@
 # Template file for 'kdenlive'
 pkgname=kdenlive
 version=23.08.4
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="
  extra-cmake-modules kconfig kcoreaddons kdoctools pkg-config python3

From 56f7f30c11f1980139cf73334bb68aac3d3d34a4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:20:59 -0400
Subject: [PATCH 082/111] tracker-miners: revbump for ffmpeg6

---
 srcpkgs/tracker-miners/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tracker-miners/template b/srcpkgs/tracker-miners/template
index 0b97f47489f81..f196d2bf9e4a4 100644
--- a/srcpkgs/tracker-miners/template
+++ b/srcpkgs/tracker-miners/template
@@ -1,7 +1,7 @@
 # Template file for 'tracker-miners'
 pkgname=tracker-miners
 version=3.6.1
-revision=1
+revision=2
 build_style=meson
 build_helper=qemu
 # missing libgrss for miner_rss

From 145fee6f85e49ad4151145aec606611a7d3a5270 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:21:21 -0400
Subject: [PATCH 083/111] mpd: revbump for ffmpeg6

---
 srcpkgs/mpd/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpd/template b/srcpkgs/mpd/template
index 4fd32b7be8c53..b8e2bd4c1b59c 100644
--- a/srcpkgs/mpd/template
+++ b/srcpkgs/mpd/template
@@ -1,7 +1,7 @@
 # Template file for 'mpd'
 pkgname=mpd
 version=0.23.15
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dopus=enabled -Dmikmod=enabled -Dneighbor=true
  -Dsoundcloud=enabled -Dpipe=true -Dtwolame=enabled -Dbzip2=enabled

From 9f0fb516cd3ca4524748c73350fce11370e5e762 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:02 -0400
Subject: [PATCH 084/111] tg_owt: revbump for ffmpeg6

---
 srcpkgs/tg_owt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tg_owt/template b/srcpkgs/tg_owt/template
index aee8d35d08ffb..34e8fef054056 100644
--- a/srcpkgs/tg_owt/template
+++ b/srcpkgs/tg_owt/template
@@ -1,7 +1,7 @@
 # Template file for 'tg_owt'
 pkgname=tg_owt
 version=0.0.0.20231221
-revision=1
+revision=2
 _commit=afd9d5d31798d3eacf9ed6c30601e91d0f1e4d60
 _libyuv_commit=04821d1e7d60845525e8db55c7bcd41ef5be9406
 _abseil_commit=8c0b94e793a66495e0b1f34a5eb26bd7dc672db0

From efd22ce65461f1160367dbc699d7c587fde00032 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:44 -0400
Subject: [PATCH 085/111] telegram-desktop: revbump for ffmpeg6

---
 srcpkgs/telegram-desktop/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/telegram-desktop/template b/srcpkgs/telegram-desktop/template
index 6b63f1942620a..53d89aad23ba8 100644
--- a/srcpkgs/telegram-desktop/template
+++ b/srcpkgs/telegram-desktop/template
@@ -1,7 +1,7 @@
 # Template file for 'telegram-desktop'
 pkgname=telegram-desktop
 version=4.14.15
-revision=1
+revision=2
 build_style=cmake
 build_helper="qemu gir"
 configure_args="-DTDESKTOP_API_ID=209235

From 7e7d8939a46ccded102cecc07c4498c2a1270aae Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:12:09 -0400
Subject: [PATCH 086/111] openmw: revbump for ffmpeg6

---
 srcpkgs/openmw/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openmw/template b/srcpkgs/openmw/template
index 0abf5ff7cdbec..b57180f1a4446 100644
--- a/srcpkgs/openmw/template
+++ b/srcpkgs/openmw/template
@@ -1,7 +1,7 @@
 # Template file for 'openmw'
 pkgname=openmw
 version=0.48.0
-revision=2
+revision=3
 build_style=cmake
 _recast_commit=e75adf86f91eb3082220085e42dda62679f9a3ea
 _bullet_tag=3.17

From c1b420b83d4d5456f8bfaa24f83c6a76b3a5a9f5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:14:53 -0400
Subject: [PATCH 087/111] lms: revbump for ffmpeg6

---
 srcpkgs/lms/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/lms/template b/srcpkgs/lms/template
index e358f75902a98..3b21c458de519 100644
--- a/srcpkgs/lms/template
+++ b/srcpkgs/lms/template
@@ -1,7 +1,7 @@
 # Template file for 'lms'
 pkgname=lms
 version=3.42.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="wt-devel ffmpeg-devel boost-devel libconfig++-devel taglib-devel pam-devel libgraphicsmagick-devel gtest-devel libarchive-devel"

From 8ce8e2f8c0f4e1deb75db1b1c8c08103a9dfe1ad Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:18:18 -0400
Subject: [PATCH 088/111] freecad: DELETE

---
 srcpkgs/freecad/patches/001-include.patch     | 112 ------------------
 .../154-revert-gui-tmp-redirect-stderr.patch  |  68 -----------
 ...d63c8c9b1280978be841d04e68a0a55cceb9.patch |  30 -----
 srcpkgs/freecad/template                      |  12 +-
 4 files changed, 7 insertions(+), 215 deletions(-)
 delete mode 100644 srcpkgs/freecad/patches/001-include.patch
 delete mode 100644 srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
 delete mode 100644 srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch

diff --git a/srcpkgs/freecad/patches/001-include.patch b/srcpkgs/freecad/patches/001-include.patch
deleted file mode 100644
index 28b5af54999b9..0000000000000
--- a/srcpkgs/freecad/patches/001-include.patch
+++ /dev/null
@@ -1,112 +0,0 @@
-From 9a41845a417189776741297c50a3827ce292bc4f Mon Sep 17 00:00:00 2001
-From: Uwe <donovaly@users.noreply.github.com>
-Date: Sun, 3 Jul 2022 22:51:16 +0200
-Subject: [PATCH] [Part] OCCError.h: remove unneeded includes
-
-- also sort includes
----
- src/Mod/Part/App/OCCError.h             | 36 +++----------------------
- src/Mod/Part/App/OffsetCurvePyImp.cpp   | 12 ++++-----
- src/Mod/Part/App/OffsetSurfacePyImp.cpp | 10 +++----
- 3 files changed, 12 insertions(+), 46 deletions(-)
-
---- a/src/Mod/Part/App/OCCError.h
-+++ b/src/Mod/Part/App/OCCError.h
-@@ -23,36 +23,8 @@
- #ifndef _OCCError_h_
- #define _OCCError_h_
- 
--# include <Standard_Version.hxx>
- # include <Standard_Failure.hxx>
--# include <Standard_AbortiveTransaction.hxx>
--# include <Standard_ConstructionError.hxx>
--# if OCC_VERSION_HEX >= 0x060500
--# include <Standard_DefineException.hxx>
--# endif
--# include <Standard_DimensionError.hxx>
--# include <Standard_DimensionMismatch.hxx>
--# include <Standard_DivideByZero.hxx>
--# include <Standard_DomainError.hxx>
--# include <Standard_ImmutableObject.hxx>
--# include <Standard_LicenseError.hxx>
--# include <Standard_LicenseNotFound.hxx>
--# include <Standard_MultiplyDefined.hxx>
--# include <Standard_NegativeValue.hxx>
--# include <Standard_NoMoreObject.hxx>
--# include <Standard_NoSuchObject.hxx>
--# include <Standard_NotImplemented.hxx>
--# include <Standard_NullObject.hxx>
--# include <Standard_NullValue.hxx>
--# include <Standard_NumericError.hxx>
--# include <Standard_OutOfMemory.hxx>
--# include <Standard_OutOfRange.hxx>
--# include <Standard_Overflow.hxx>
--# include <Standard_ProgramError.hxx>
--# include <Standard_RangeError.hxx>
--# include <Standard_TooManyUsers.hxx>
--# include <Standard_TypeMismatch.hxx>
--# include <Standard_Underflow.hxx>
-+# include <Standard_Version.hxx>
- 
- #include <Mod/Part/PartGlobal.h>
- #include <Base/Console.h>
-@@ -88,4 +60,3 @@ PartExport extern PyObject* PartExceptio
- 
- #define PY_CATCH_OCC _PY_CATCH_OCC(return(NULL))
- #endif  // _OCCError_h_
--
---- a/src/Mod/Part/App/OffsetCurvePyImp.cpp
-+++ b/src/Mod/Part/App/OffsetCurvePyImp.cpp
-@@ -20,20 +20,20 @@
-  *                                                                         *
-  ***************************************************************************/
- 
--
- #include "PreCompiled.h"
- #ifndef _PreComp_
- # include <Geom_OffsetCurve.hxx>
- #endif
- 
--#include "OCCError.h"
--#include "Geometry.h"
-+#include <Base/GeometryPyCXX.h>
-+#include <Base/Vector3D.h>
-+#include <Base/VectorPy.h>
-+
- #include "OffsetCurvePy.h"
- #include "OffsetCurvePy.cpp"
-+#include "Geometry.h"
-+#include "OCCError.h"
- 
--#include <Base/GeometryPyCXX.h>
--#include <Base/VectorPy.h>
--#include <Base/Vector3D.h>
- 
- using namespace Part;
- 
---- a/src/Mod/Part/App/OffsetSurfacePyImp.cpp
-+++ b/src/Mod/Part/App/OffsetSurfacePyImp.cpp
-@@ -20,20 +20,16 @@
-  *                                                                         *
-  ***************************************************************************/
- 
--
- #include "PreCompiled.h"
- #ifndef _PreComp_
- # include <Geom_OffsetSurface.hxx>
- # include <memory>
- #endif
- 
--#include <Base/VectorPy.h>
--#include <Base/Vector3D.h>
--
- #include "OCCError.h"
--#include "Geometry.h"
--#include <Mod/Part/App/OffsetSurfacePy.h>
--#include <Mod/Part/App/OffsetSurfacePy.cpp>
-+#include "OffsetSurfacePy.h"
-+#include "OffsetSurfacePy.cpp"
-+
- 
- using namespace Part;
- 
diff --git a/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch b/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
deleted file mode 100644
index d6a9adabdec83..0000000000000
--- a/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
+++ /dev/null
@@ -1,68 +0,0 @@
-see https://github.com/FreeCAD/FreeCAD/commit/cfe94b00d3434f3e2c8b5114d2909f628c330fa8#commitcomment-71413407
-
-upstream: yes
-
-From 7b377a216b9185960e4cee980a6504dc1a755f50 Mon Sep 17 00:00:00 2001
-From: wmayer <wmayer@users.sourceforge.net>
-Date: Wed, 29 Jun 2022 15:19:18 +0200
-Subject: [PATCH] Gui: remove workaround for spnav 0.23 due to build failure
- with musl libc
-
----
- src/Gui/3Dconnexion/GuiNativeEventLinux.cpp | 27 ---------------------
- 1 file changed, 27 deletions(-)
-
---- a/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp
-+++ b/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp
-@@ -21,42 +21,17 @@
-  ***************************************************************************/
- 
- #include <FCConfig.h>
--#include <cstdio>
- 
- #include "GuiNativeEventLinux.h"
- 
- #include "GuiApplicationNativeEventAware.h"
- #include <Base/Console.h>
--#include <Base/FileInfo.h>
- #include <QMainWindow>
- 
- #include <QSocketNotifier>
- 
- #include <spnav.h>
- 
--namespace {
--class RedirectStdErr
--{
--public:
--    RedirectStdErr()
--        : fi(Base::FileInfo::getTempFileName())
--        , file(stderr)
--    {
--        stderr = fopen(fi.filePath().c_str(), "w");
--    }
--    ~RedirectStdErr()
--    {
--        fclose(stderr);
--        fi.deleteFile();
--        stderr = file;
--    }
--
--private:
--    Base::FileInfo fi;
--    FILE* file;
--};
--}
--
- Gui::GuiNativeEvent::GuiNativeEvent(Gui::GUIApplicationNativeEventAware *app)
- : GuiAbstractNativeEvent(app)
- {
-@@ -72,8 +47,6 @@ Gui::GuiNativeEvent::~GuiNativeEvent()
- 
- void Gui::GuiNativeEvent::initSpaceball(QMainWindow *window)
- {
--    // tmp. redirect stderr to a file to suppress an error message from spnav_open()
--    RedirectStdErr err;
-     Q_UNUSED(window)
-     if (spnav_open() == -1) {
-         Base::Console().Log("Couldn't connect to spacenav daemon. Please ignore if you don't have a spacemouse.\n");
diff --git a/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch b/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch
deleted file mode 100644
index d4acf370ca0a4..0000000000000
--- a/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-From fe02d63c8c9b1280978be841d04e68a0a55cceb9 Mon Sep 17 00:00:00 2001
-From: Roy-043 <70520633+Roy-043@users.noreply.github.com>
-Date: Thu, 29 Dec 2022 23:20:38 +0100
-Subject: [PATCH] Draft: update inspect.getargspec to inspect.getfullargspec
- (#8101)
-
----
- src/Mod/Draft/draftguitools/gui_snapper.py | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
---- a/src/Mod/Draft/draftguitools/gui_snapper.py
-+++ b/src/Mod/Draft/draftguitools/gui_snapper.py
-@@ -1426,7 +1426,7 @@ class Snapper:
-             Gui.Snapper.off()
-             self.ui.offUi()
-             if callback:
--                if len(inspect.getargspec(callback).args) > 1:
-+                if len(inspect.getfullargspec(callback).args) > 1:
-                     obj = None
-                     if self.snapInfo and ("Object" in self.snapInfo) and self.snapInfo["Object"]:
-                         obj = App.ActiveDocument.getObject(self.snapInfo["Object"])
-@@ -1445,7 +1445,7 @@ class Snapper:
-             Gui.Snapper.off()
-             self.ui.offUi()
-             if callback:
--                if len(inspect.getargspec(callback).args) > 1:
-+                if len(inspect.getfullargspec(callback).args) > 1:
-                     callback(None, None)
-                 else:
-                     callback(None)
diff --git a/srcpkgs/freecad/template b/srcpkgs/freecad/template
index c135701e38b9a..7d5165f760bab 100644
--- a/srcpkgs/freecad/template
+++ b/srcpkgs/freecad/template
@@ -1,7 +1,7 @@
 # Template file for 'freecad'
 pkgname=freecad
-version=0.20.2
-revision=7
+version=0.21.1
+revision=2
 build_wrksrc="FreeCAD-${version}"
 build_style=cmake
 pycompile_dirs="usr/lib/${pkgname}/Mod"
@@ -24,8 +24,10 @@ makedepends="python3-devel boost-devel libxerces-c-devel zlib-devel occt-devel
  coin3-devel libshiboken2-devel libspnav-devel pyside2-tools
  liblz4-devel libpyside2-python3-devel python3-matplotlib netcdf-devel
  jsoncpp-devel qt5-devel qt5-svg-devel qt5-tools-devel qt5-webkit-devel
- qt5-xmlpatterns-devel coin3-doc glew-devel python3-pivy"
-depends="python3-matplotlib python3-pyside2-webengine python3-pivy"
+ qt5-xmlpatterns-devel coin3-doc glew-devel python3-pivy qt5-webengine-devel
+ qt5-declarative-devel qt5-webchannel-devel qt5-location-devel"
+depends="python3-matplotlib python3-pyside2-webengine python3-pivy
+ python3-GitPython python3-Markdown"
 short_desc="General purpose 3D CAD modeler"
 maintainer="yopito <pierre.bourgin@free.fr>"
 license="LGPL-2.0-or-later"
@@ -35,7 +37,7 @@ distfiles="
  https://github.com/FreeCAD/FreeCAD/archive/${version}.tar.gz
  ${SOURCEFORGE_SITE}/cxx/pycxx-${_pycxxver}.tar.gz
 "
-checksum="46922f3a477e742e1a89cd5346692d63aebb2b67af887b3e463e094a4ae055da
+checksum="e9b1fd0323f101268c7f3be52db42e4a29222f2e306ae6c4a6fc309cb418d35a
  4b91e1e1141c23fbd5039df635c4bb6e75632168548f56b83ce177193c0c98c6"
 python_version=3
 patch_args="-Np1 -d ${build_wrksrc}"

From 81a5d50a73e746930f02f72102f7f7fd5e8dd45c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:47:18 -0400
Subject: [PATCH 089/111] libopenshot: revbump for ffmpeg6

---
 srcpkgs/libopenshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenshot/template b/srcpkgs/libopenshot/template
index 8e57c5f592169..7a8f4520e7892 100644
--- a/srcpkgs/libopenshot/template
+++ b/srcpkgs/libopenshot/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenshot'
 pkgname=libopenshot
 version=0.3.0
-revision=3
+revision=4
 build_style=cmake
 # Builds fail with Ruby-2.4.1
 configure_args="-DENABLE_RUBY=OFF -DUSE_SYSTEM_JSONCPP=ON"

From 7fc4b5757804feacc3757d67712b62a535a1eba2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:10:30 -0500
Subject: [PATCH 090/111] openimageio: revbump for ffmpeg6

---
 srcpkgs/openimageio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimageio/template b/srcpkgs/openimageio/template
index 3ce3f9e49d350..27d2131bc0a61 100644
--- a/srcpkgs/openimageio/template
+++ b/srcpkgs/openimageio/template
@@ -1,7 +1,7 @@
 # Template file for 'openimageio'
 pkgname=openimageio
 version=2.4.9.0
-revision=7
+revision=8
 build_style=cmake
 build_helper=qemu
 configure_args="-DUSE_QT=0 -DUSE_PYTHON=0 -DOIIO_BUILD_TESTS=0

From d138c690e085328897b99f4bbc884e6b150b3230 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:11:57 -0500
Subject: [PATCH 091/111] synfigstudio: revbump for ffmpeg6

---
 srcpkgs/synfigstudio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/synfigstudio/template b/srcpkgs/synfigstudio/template
index 09e442da9a680..2bc017cedca6b 100644
--- a/srcpkgs/synfigstudio/template
+++ b/srcpkgs/synfigstudio/template
@@ -2,7 +2,7 @@
 # Should be kept in sync with 'synfig' and 'ETL'
 pkgname=synfigstudio
 version=1.4.4
-revision=4
+revision=5
 build_style=gnu-configure
 configure_args="--disable-update-mimedb"
 hostmakedepends="pkg-config intltool gettext synfig"

From e50bd31409c5e119a5dc0d9f51e19fd796a5bcff Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:10 -0500
Subject: [PATCH 092/111] mixxx: revbump for ffmpeg6

---
 srcpkgs/mixxx/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mixxx/template b/srcpkgs/mixxx/template
index 6921996e4e77b..6a79b328c1abf 100644
--- a/srcpkgs/mixxx/template
+++ b/srcpkgs/mixxx/template
@@ -1,7 +1,7 @@
 # Template file for 'mixxx'
 pkgname=mixxx
 version=2.3.3
-revision=6
+revision=7
 build_style=cmake
 configure_args="-DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="extra-cmake-modules pkg-config protobuf qt5-host-tools qt5-qmake"

From be4d261858924fc4d3b8ff7d43eac3d564cd66e7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:28 -0500
Subject: [PATCH 093/111] musikcube: revbump for ffmpeg6

---
 srcpkgs/musikcube/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/musikcube/template b/srcpkgs/musikcube/template
index 8c4a51840859e..fb60dd2049089 100644
--- a/srcpkgs/musikcube/template
+++ b/srcpkgs/musikcube/template
@@ -1,7 +1,7 @@
 # Template file for 'musikcube'
 pkgname=musikcube
 version=3.0.0
-revision=3
+revision=4
 build_style=cmake
 make_cmd=make
 configure_args="-DNO_NCURSESW=1"

From 98c1d68d2f480ee6ec79b2dc6e8d241e802a3d9f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:45 -0500
Subject: [PATCH 094/111] electron24: revbump for ffmpeg6

---
 srcpkgs/electron24/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron24/template b/srcpkgs/electron24/template
index 7b4e28812f483..1ca93fde97a85 100644
--- a/srcpkgs/electron24/template
+++ b/srcpkgs/electron24/template
@@ -1,7 +1,7 @@
 # Template file for 'electron24'
 pkgname=electron24
 version=24.3.0
-revision=2
+revision=3
 _nodever=18.14.0
 _chromiumver=112.0.5615.165
 archs="x86_64* aarch64*"

From b01c12602771cca1e75e5c94c7fab9619caf0f86 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:00 -0500
Subject: [PATCH 095/111] electron19: revbump for ffmpeg6

---
 srcpkgs/electron19/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron19/template b/srcpkgs/electron19/template
index 0ef959125cb08..5371c0b354604 100644
--- a/srcpkgs/electron19/template
+++ b/srcpkgs/electron19/template
@@ -1,7 +1,7 @@
 # Template file for 'electron19'
 pkgname=electron19
 version=19.0.8
-revision=4
+revision=5
 _nodever=16.14.2
 _chromiumver=102.0.5005.125
 archs="x86_64* aarch64* ppc64le*"

From d4e89eb742b8b76be2effd469c38a206ed3e4aa3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:13 -0500
Subject: [PATCH 096/111] wf-recorder: revbump for ffmpeg6

---
 srcpkgs/wf-recorder/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/wf-recorder/template b/srcpkgs/wf-recorder/template
index 08f986b031006..63c45cf4b814d 100644
--- a/srcpkgs/wf-recorder/template
+++ b/srcpkgs/wf-recorder/template
@@ -1,7 +1,7 @@
 # Template file for 'wf-recorder'
 pkgname=wf-recorder
 version=0.4.1
-revision=2
+revision=3
 build_style=meson
 hostmakedepends="pkg-config scdoc wayland-devel"
 makedepends="wayland-protocols wayland-devel ffmpeg-devel libgbm-devel x264-devel

From 82fee3a0ddd95ca5132e5a3c715c3aa789d85aeb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:26 -0500
Subject: [PATCH 097/111] obs: revbump for ffmpeg6

---
 srcpkgs/obs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/obs/template b/srcpkgs/obs/template
index b343f1131bfcf..a25a67433e285 100644
--- a/srcpkgs/obs/template
+++ b/srcpkgs/obs/template
@@ -1,7 +1,7 @@
 # Template file for 'obs'
 pkgname=obs
 version=30.0.0
-revision=2
+revision=3
 archs="i686* x86_64* ppc64le* aarch64* riscv64*"
 build_style=cmake
 configure_args="-DOBS_VERSION_OVERRIDE=${version} -DENABLE_JACK=ON

From f86ac9937809d2f4dde1076d66264b9c6439076d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:36 -0500
Subject: [PATCH 098/111] mlt7: revbump for ffmpeg6

---
 srcpkgs/mlt7/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mlt7/template b/srcpkgs/mlt7/template
index 98f302ad3a516..7eb8c00fa1580 100644
--- a/srcpkgs/mlt7/template
+++ b/srcpkgs/mlt7/template
@@ -1,7 +1,7 @@
 # Template file for 'mlt7'
 pkgname=mlt7
 version=7.20.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DSWIG_PYTHON=ON -DMOD_QT6=ON"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which

From 787b09a2f4f69dc76e8ee082f748254fecd85ecc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:48 -0500
Subject: [PATCH 099/111] qt6-multimedia: revbump for ffmpeg6

---
 srcpkgs/qt6-multimedia/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-multimedia/template b/srcpkgs/qt6-multimedia/template
index 67a577e1300fe..1da626ecf515a 100644
--- a/srcpkgs/qt6-multimedia/template
+++ b/srcpkgs/qt6-multimedia/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-multimedia'
 pkgname=qt6-multimedia
 version=6.6.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DQT_FEATURE_gstreamer=ON"
 hostmakedepends="perl qt6-declarative-host-tools pkg-config qt6-shadertools"

From 758cb6990a2b62713565417272c103e7cc47fd32 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:00:15 -0500
Subject: [PATCH 100/111] baresip: revbump for ffmpeg6

---
 srcpkgs/baresip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/baresip/template b/srcpkgs/baresip/template
index 12c8954ef7b9b..b16b67beab8d2 100644
--- a/srcpkgs/baresip/template
+++ b/srcpkgs/baresip/template
@@ -1,7 +1,7 @@
 # Template file for 'baresip'
 pkgname=baresip
 version=3.6.0
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config glib-devel"
 makedepends="libgsm-devel libpng-devel openssl-devel libsndfile-devel

From 486c480b98322afb54ae23416f900ab99137fd8e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:30 -0500
Subject: [PATCH 101/111] QMPlay2: revbump for ffmpeg6

---
 srcpkgs/QMPlay2/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/QMPlay2/template b/srcpkgs/QMPlay2/template
index 46c80f64a1349..942258ce60fb7 100644
--- a/srcpkgs/QMPlay2/template
+++ b/srcpkgs/QMPlay2/template
@@ -1,7 +1,7 @@
 # Template file for 'QMPlay2'
 pkgname=QMPlay2
 version=23.10.22
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools"
 makedepends="alsa-lib-devel ffmpeg-devel libass-devel libcdio-devel libgme-devel

From 748e2b81ab00f5abe5de09129f5209f9e7a2db66 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:34 -0500
Subject: [PATCH 102/111] alsa-plugins: revbump for ffmpeg6

---
 srcpkgs/alsa-plugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/alsa-plugins/template b/srcpkgs/alsa-plugins/template
index a5708a7d82a8f..7bfdad046c483 100644
--- a/srcpkgs/alsa-plugins/template
+++ b/srcpkgs/alsa-plugins/template
@@ -1,7 +1,7 @@
 # Template file for 'alsa-plugins'
 pkgname=alsa-plugins
 version=1.2.7.1
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--disable-maemo-plugin"
 hostmakedepends="pkg-config"

From e37b22098a4338d0a5d4aca769694c43b84cfbb5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:43 -0500
Subject: [PATCH 103/111] minidlna: revbump for ffmpeg6

---
 srcpkgs/minidlna/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/minidlna/template b/srcpkgs/minidlna/template
index 5fa929f3a0c12..742991ecd04af 100644
--- a/srcpkgs/minidlna/template
+++ b/srcpkgs/minidlna/template
@@ -1,7 +1,7 @@
 # Template file for 'minidlna'
 pkgname=minidlna
 version=1.3.3
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="
  --sbindir=/usr/bin

From debbde50d1745eb2758ee12065ec4c603bdad797 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 17:57:47 -0500
Subject: [PATCH 104/111] mpv: revbump for ffmpeg6

---
 srcpkgs/mpv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpv/template b/srcpkgs/mpv/template
index 4948d1e332cb8..1ac1b167af189 100644
--- a/srcpkgs/mpv/template
+++ b/srcpkgs/mpv/template
@@ -1,7 +1,7 @@
 # Template file for 'mpv'
 pkgname=mpv
 version=0.36.0
-revision=4
+revision=5
 build_style=meson
 configure_args="-Dcdda=enabled -Ddvbin=enabled -Ddvdnav=enabled
  -Dlibmpv=true -Dcplugins=enabled

From e0426c07d057ad9825eb0d589d060efcf8dbda84 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 17:59:29 -0500
Subject: [PATCH 105/111] qimgv: revbump for ffmpeg6

---
 srcpkgs/qimgv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qimgv/template b/srcpkgs/qimgv/template
index dd341dfe1bfce..8a7e1c081ef12 100644
--- a/srcpkgs/qimgv/template
+++ b/srcpkgs/qimgv/template
@@ -1,7 +1,7 @@
 # Template file for 'qimgv'
 pkgname=qimgv
 version=1.0.2
-revision=3
+revision=4
 build_style=cmake
 configure_args="$(vopt_if video -DVIDEO_SUPPORT=ON -DVIDEO_SUPPORT=OFF)
  $(vopt_if scale -DOPENCV_SUPPORT=ON -DOPENCV_SUPPORT=OFF)

From 4847ed4b06ac9868a6f7cfca8ce368f8f6dfdc56 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 18:00:36 -0500
Subject: [PATCH 106/111] kfilemetadata5: revbump for ffmpeg6

---
 srcpkgs/kfilemetadata5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kfilemetadata5/template b/srcpkgs/kfilemetadata5/template
index a0c4d80939532..b584f85ff2058 100644
--- a/srcpkgs/kfilemetadata5/template
+++ b/srcpkgs/kfilemetadata5/template
@@ -1,7 +1,7 @@
 # Template file for 'kfilemetadata5'
 pkgname=kfilemetadata5
 version=5.115.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="kcoreaddons extra-cmake-modules pkg-config qt5-host-tools qt5-qmake
  gettext kcoreaddons python3"

From 784e69aa1a39aa49fc244faa4b6e7c34e5bd201c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 8 Dec 2023 11:46:01 -0500
Subject: [PATCH 107/111] vba-m: revbump for ffmpeg6

---
 srcpkgs/vba-m/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vba-m/template b/srcpkgs/vba-m/template
index 3d135efa1d0b6..3c5a20db0fa98 100644
--- a/srcpkgs/vba-m/template
+++ b/srcpkgs/vba-m/template
@@ -2,7 +2,7 @@
 pkgname=vba-m
 reverts=1292_2
 version=2.1.9
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_GTK=TRUE -DENABLE_FFMPEG=TRUE -DENABLE_LINK=TRUE -DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="gettext pkg-config unzip zip yasm wxWidgets-gtk3-devel"

From 0ba7acc78d0e429688214ef266f77e58c9f40187 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 8 Dec 2023 11:46:19 -0500
Subject: [PATCH 108/111] dolphin-emu: revbump for ffmpeg6

---
 srcpkgs/dolphin-emu/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/dolphin-emu/template b/srcpkgs/dolphin-emu/template
index 862d3ae964eec..a7ae0efb58fb7 100644
--- a/srcpkgs/dolphin-emu/template
+++ b/srcpkgs/dolphin-emu/template
@@ -1,7 +1,7 @@
 # Template file for 'dolphin-emu'
 pkgname=dolphin-emu
 version=5.0.19368
-revision=3
+revision=4
 _dolphin_commit=dadbeb4bae7e7fa23af2b46e0add4143094dc107
 _mgba_commit=44e074a15e9651481f7f652ac006a7c9d58cbeb9
 _googletest_commit=be03d00f5f0cc3a997d1a368bee8a1fe93651f48

From 731201800a46615c1412378bfc02766214fafe14 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 19 Dec 2023 15:38:51 -0500
Subject: [PATCH 109/111] qtox: revbump for ffmpeg4

---
 srcpkgs/qtox/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtox/template b/srcpkgs/qtox/template
index bb70e7f51240a..755e4462bc013 100644
--- a/srcpkgs/qtox/template
+++ b/srcpkgs/qtox/template
@@ -1,13 +1,13 @@
 # Template file for 'qtox'
 pkgname=qtox
 version=1.17.6
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DUPDATE_CHECK=OFF
  -DGIT_DESCRIBE=${version}
  $(vopt_if snorenotify -DDESKTOP_NOTIFICATIONS=ON)"
 hostmakedepends="pkg-config qt5-host-tools qt5-devel"
-makedepends="ffmpeg-devel libexif-devel libopenal-devel libsodium-devel
+makedepends="ffmpeg4-devel libexif-devel libopenal-devel libsodium-devel
  libvpx-devel opus-devel qrencode-devel qt5-svg-devel sonnet-devel
  sqlcipher-devel toxcore-devel
  $(vopt_if snorenotify snorenotify-devel)"

From 7823825e136c32af1e57cf741f25a92929bbb983 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 11 Jan 2024 11:52:00 -0500
Subject: [PATCH 110/111] arcan: revbump for ffmpeg6

---
 srcpkgs/arcan/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/arcan/template b/srcpkgs/arcan/template
index ff9091f90ebb1..030091a6cc9d0 100644
--- a/srcpkgs/arcan/template
+++ b/srcpkgs/arcan/template
@@ -2,7 +2,7 @@
 # !! keep synced with: acfgfs aclip aloadimage
 pkgname=arcan
 version=0.6.2.1
-revision=2
+revision=3
 create_wrksrc=yes
 build_wrksrc=arcan/src
 build_style=cmake

From 9e003b403b8686409d78f14ae5ae369213eeb4ee Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 11 Jan 2024 11:52:10 -0500
Subject: [PATCH 111/111] notcurses: revbump for ffmpeg6

---
 srcpkgs/notcurses/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/notcurses/template b/srcpkgs/notcurses/template
index 48a7463cb68eb..515f316ab4576 100644
--- a/srcpkgs/notcurses/template
+++ b/srcpkgs/notcurses/template
@@ -1,7 +1,7 @@
 # Template file for 'notcurses'
 pkgname=notcurses
 version=3.0.9
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DUSE_STATIC=ON -DUSE_QRCODEGEN=On $(vopt_bool man USE_PANDOC)"
 hostmakedepends="pkg-config $(vopt_if man pandoc)"

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (66 preceding siblings ...)
  2024-02-20 18:21 ` zlice
@ 2024-02-22 17:25 ` yoshiyoshyosh
  2024-02-22 17:34 ` zlice
                   ` (29 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: yoshiyoshyosh @ 2024-02-22 17:25 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 315 bytes --]

New comment by yoshiyoshyosh on void-packages repository

https://github.com/void-linux/void-packages/pull/43761#issuecomment-1959920326

Comment:
heya, I have enough time that I'd like to help move this along. has much changed in terms of what needs to be done since your last comment about what needs to be done?

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (67 preceding siblings ...)
  2024-02-22 17:25 ` yoshiyoshyosh
@ 2024-02-22 17:34 ` zlice
  2024-02-24  2:34 ` yoshiyoshyosh
                   ` (28 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2024-02-22 17:34 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 562 bytes --]

New comment by zlice on void-packages repository

https://github.com/void-linux/void-packages/pull/43761#issuecomment-1959934877

Comment:
i don't think much more can be done besides `vice, libextractor and idjc` being tested real quick. `tvheadend` update should hit at some point. nvidia headers could be merged. `mlt (flowblade)` can happen after. new `gonic` package can use ffmpeg6.

really just need to clean up commits and double check things.

as for testing, even slackware has ffmpeg 6.1, so i'm sure package compatibility fine at least for glibc.

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (68 preceding siblings ...)
  2024-02-22 17:34 ` zlice
@ 2024-02-24  2:34 ` yoshiyoshyosh
  2024-02-24  2:34 ` yoshiyoshyosh
                   ` (27 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: yoshiyoshyosh @ 2024-02-24  2:34 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 379 bytes --]

New comment by yoshiyoshyosh on void-packages repository

https://github.com/void-linux/void-packages/pull/43761#issuecomment-1962222780

Comment:
vice and idjc work well (well, idjc spews a bunch of syntax parsing warnings but that's python stuff rather than ffmpeg stuff). libextractor's throwing an error with exiv2 and I'm not sure if that's affecting the ffmpeg part or not

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (69 preceding siblings ...)
  2024-02-24  2:34 ` yoshiyoshyosh
@ 2024-02-24  2:34 ` yoshiyoshyosh
  2024-02-25 17:32 ` [PR PATCH] [Updated] " zlice
                   ` (26 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: yoshiyoshyosh @ 2024-02-24  2:34 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 419 bytes --]

New comment by yoshiyoshyosh on void-packages repository

https://github.com/void-linux/void-packages/pull/43761#issuecomment-1962222780

Comment:
vice and idjc work well (well, idjc spews a bunch of syntax parsing warnings but that's python stuff rather than ffmpeg stuff). libextractor's throwing an error with exiv2 and I'm not sure if that's affecting the ffmpeg part or not--no video/audio stuff is being returned

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (70 preceding siblings ...)
  2024-02-24  2:34 ` yoshiyoshyosh
@ 2024-02-25 17:32 ` zlice
  2024-02-25 17:33 ` zlice
                   ` (25 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2024-02-25 17:32 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 4903 bytes --]

There is an updated pull request by zlice against master on the void-packages repository

https://github.com/zlice/void-packages ffmpeg6-split
https://github.com/void-linux/void-packages/pull/43761

ffmpeg6 split
[ci skip]


#### Testing the changes

- I tested the changes in this PR: **YES**

main testing has been vaapi in Firefox Nightly and enc/dec in Shotcut on Intel A770

#### New package

- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**

#### Local build testing

- I built this PR locally for my native architecture, **x86_64**

#### Discussion

Continuation of https://github.com/void-linux/void-packages/pull/36315

`libavresample` is deprecated, but marked as a dependency when trying to build other packages and install `ffmpeg`(6). I think the right way to handle this is make a meta package and the add to removals?


##### Commit naming / misc

~~Commits are 'dirty' right now, running with [gstreamer 1.22.1 updates](https://github.com/void-linux/void-packages/pull/42861) and [Intel OpenCL](https://github.com/void-linux/void-packages/pull/43084). This will also make [intel packages pr](https://github.com/void-linux/void-packages/pull/41132) obsolete.~~ (see Requirements below)

Maintainer for previous ffmpeg(4) was orphaned, I can put my name in there if that matters, though I don't exactly see myself keeping up on ffmpeg.

~~This updates QT5 which looks like it is usually hosted by Johnny. Not sure if there's any reason to stay there or these sources are fine.~~ Using qt5.15.11 now, revbumps and some patches.

##### STILL FFMPEG4

These are a mix of emulators, games and/or older packages.

- ~~attract~~ (2.7 builds)
- ~~audacity (https://github.com/audacity/audacity/issues/2305 and https://sourceforge.net/p/portmedia/wiki/portsmf/ is 'beta')~~ (updated to 3.x, compiles with ffmpeg6)
- ~~ccextractor~~ (master patches)
- vice (3.8 compiles, needs makedepends libcurl-devel)
- kodi
- mlt (only dep left is flowblade - flowblade 2.12.0.2 with mlt7-python3 can 'render' videos with cpu and gpu - https://github.com/void-linux/void-packages/pull/47195)
- ~~synfig (mlt)~~ (work with mlt7, bump synfigstudio)
- tvheadend (download page recommends using 4.3 which compiles fine, 4.4 eta is Q1 2024)
- ~~ssr~~ (patches)
- ~~spek-alternative~~ (replace with spek-x)
- ~~ppsspp~~ ~~(1.17.1 is out, but there's 5+ distfiles that are all git commits)~~ (minor patch)
- olive (has been in alpha since 2020, seems they do nightly builds and appimages)
- moc
- mediastreamer (linphone links are dead, changed to github belladonne. their stuff never worked for me but there are updates if someone wants to give it a try)
- libextractor (1.13 compiles, remove exiv2 patch)
- idjc (0.9.8 compiles, remove python3.10 patch, needs makedepends libebur128-devel and libshout-idjc 2.4.6 with '-r1' for distfile)
- hedgewars
- ~~ffmpegthumbnailer~~ (patches for moviedecoder.xxx files)
- ~~ffmpegthumbs~~ (latest compiles)
- deadbeef (1.9.6 may work but requires libdispatch from apple)
- ~~omxplayer~~ (package removed, deprecated in favor of vlc)
- qtav (fork has ffmpeg 5 patch - https://github.com/cmguo/QtAV)
- `vlc` (vlc4 will support ffmpeg5, there's a patch to build 3.x with ffmpeg5 but it will lack vaapi)
- `osg` (OpenSceneGraph plus `xine-lib`)


##### HAVE NOT BUILT YET

- ~~omxplayer (rpi only? ffmpeg4)~~ (removed)
- kodi (big, but ffmpeg4)


##### UPDATED (for ffmpeg6)

- ~~blender: update to 3.5.1~~ ~~will be revbump with~~ https://github.com/void-linux/void-packages/pull/43992
- unpaper: update to 7.0.0.
- guvcview: update to 2.0.8.
- ~~qt5: update to 5.15.8~~ updated by another PR to 5.15.11
- ~~qt5-webengine: update to 5.18.15~~ updated by another PR to 5.15.16 (some patching for ffmpeg build)
- ~~shiboken2: revbump for qt5.15.8 (patch)~~ updated by another PR to 5.15.10
- ~~python3-pyside2: update to 5.15.8 (patch)~~ updated by another PR to 5.15.10
- New package: spex-x replaces spek-alternative for ffmpeg-6.0


##### Requirements

- ~~[gstreamer 1.22.2](https://github.com/void-linux/void-packages/pull/42861)~~ - a few packages use ffmpeg-devel and require a revbump

- ~~[Intel Packages](https://github.com/void-linux/void-packages/pull/41132) [Intel Packages v2](https://github.com/void-linux/void-packages/pull/47330) - ffmpeg4 uses different libraries than 6 (libmfx / Intel-MediaSDK vs only oneVPL that Intel is moving to), both are included here~~. Using replacement oneVPL from OBS update.

- ~~[shotcut 23.05.14](https://github.com/void-linux/void-packages/pull/44260)~~

- https://github.com/void-linux/void-packages/pull/44781 will remove from this PR

A patch file from https://github.com/void-linux/void-packages/pull/43761.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ffmpeg6-split-43761.patch --]
[-- Type: text/x-diff, Size: 242433 bytes --]

From b18e48e4eee9ff60da6e6380b115fb87d74f642e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:16:56 -0400
Subject: [PATCH 001/111] ffmpeg: update to 6.0.1.

---
 common/shlibs                                 | 26 ++++---
 srcpkgs/ffmpeg/files/altivec.patch            | 60 ---------------
 .../patches/armv5tel-floating-point.patch     | 18 -----
 srcpkgs/ffmpeg/patches/binutils-2.41.patch    | 73 -------------------
 ...h-libavcodec-libsvtav1-ten_bit_format.diff | 40 ----------
 .../workaround-mesa-readeon-vaapi-bug.patch   | 28 -------
 srcpkgs/ffmpeg/template                       | 40 +++++-----
 7 files changed, 37 insertions(+), 248 deletions(-)
 delete mode 100644 srcpkgs/ffmpeg/files/altivec.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/binutils-2.41.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 delete mode 100644 srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch

diff --git a/common/shlibs b/common/shlibs
index 695794c63daed5..6c43918b759af4 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -389,15 +389,23 @@ libid3tag.so.0 libid3tag-0.15.1b_1
 libgif.so.7 giflib-5.1.0_1
 libImlib2.so.1 imlib2-1.4.2_1
 libmp3lame.so.0 lame-3.98.2_1
-libavdevice.so.58 libavdevice-4.0_1
-libavformat.so.58 libavformat-4.0_1
-libswscale.so.5 libswscale-4.0_1
-libswresample.so.3 libswresample-4.0_1
-libavresample.so.4 libavresample-4.0_1
-libpostproc.so.55 libpostproc-4.0_1
-libavcodec.so.58 libavcodec-4.0_1
-libavutil.so.56 libavutil-4.0_1
-libavfilter.so.7 libavfilter-4.0_1
+libavdevice.so.60 libavdevice-6.0_1
+libavformat.so.60 libavformat-6.0_1
+libswscale.so.7 libswscale-6.0_1
+libswresample.so.4 libswresample-6.0_1
+libpostproc.so.57 libpostproc-6.0_1
+libavcodec.so.60 libavcodec-6.0_1
+libavutil.so.58 libavutil-6.0_1
+libavfilter.so.9 libavfilter-6.0_1
+libavdevice.so.58 libavdevice4-4.0_1
+libavformat.so.58 libavformat4-4.0_1
+libswscale.so.5 libswscale4-4.0_1
+libswresample.so.3 libswresample4-4.0_1
+libavresample.so.4 libavresample4-4.0_1
+libpostproc.so.55 libpostproc4-4.0_1
+libavcodec.so.58 libavcodec4-4.0_1
+libavutil.so.56 libavutil4-4.0_1
+libavfilter.so.7 libavfilter4-4.0_1
 libSDL-1.2.so.0 SDL-1.2.14_1
 libSDL_image-1.2.so.0 SDL_image-1.2.10_1
 libx264.so.157 x264-20190507.2245_1
diff --git a/srcpkgs/ffmpeg/files/altivec.patch b/srcpkgs/ffmpeg/files/altivec.patch
deleted file mode 100644
index 9c57200463320e..00000000000000
--- a/srcpkgs/ffmpeg/files/altivec.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-revert some altivec specific change on all ppc* except ppc64le*
-
-q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
-conditionally, for ppc* but not ppc64le* (the new code is valid for
-POWER8 VSX which LE targets as a baseline but not BE)"
-
-
-This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
----
- libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
- 1 file changed, 20 insertions(+), 4 deletions(-)
-
-diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
-index 536545293d..c1e2852adb 100644
---- a/libswscale/ppc/yuv2rgb_altivec.c
-+++ b/libswscale/ppc/yuv2rgb_altivec.c
-@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-     vector signed short R1, G1, B1;                                           \
-     vector unsigned char R, G, B;                                             \
-                                                                               \
-+    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
-+    vector unsigned char align_perm;                                          \
-+                                                                              \
-     vector signed short lCY       = c->CY;                                    \
-     vector signed short lOY       = c->OY;                                    \
-     vector signed short lCRV      = c->CRV;                                   \
-@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
-                                                                               \
-         for (j = 0; j < w / 16; j++) {                                        \
--            y0 = vec_xl(0, y1i);                                              \
-+            y1ivP = (const vector unsigned char *) y1i;                       \
-+            y2ivP = (const vector unsigned char *) y2i;                       \
-+            uivP  = (const vector unsigned char *) ui;                        \
-+            vivP  = (const vector unsigned char *) vi;                        \
-+                                                                              \
-+            align_perm = vec_lvsl(0, y1i);                                    \
-+            y0 = (vector unsigned char)                                       \
-+                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
-                                                                               \
--            y1 = vec_xl(0, y2i);                                              \
-+            align_perm = vec_lvsl(0, y2i);                                    \
-+            y1 = (vector unsigned char)                                       \
-+                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
-                                                                               \
--            u = (vector signed char) vec_xl(0, ui);                           \
-+            align_perm = vec_lvsl(0, ui);                                     \
-+            u = (vector signed char)                                          \
-+                    vec_perm(uivP[0], uivP[1], align_perm);                   \
-                                                                               \
--            v = (vector signed char) vec_xl(0, vi);                           \
-+            align_perm = vec_lvsl(0, vi);                                     \
-+            v = (vector signed char)                                          \
-+                    vec_perm(vivP[0], vivP[1], align_perm);                   \
-                                                                               \
-             u = (vector signed char)                                          \
-                     vec_sub(u,                                                \
--- 
-2.27.0
-
diff --git a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
deleted file mode 100644
index 9a55178c74f0fd..00000000000000
--- a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
-+++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
-@@ -39,6 +39,15 @@
- #endif
- #include <fenv.h>
- 
-+#if (FE_ALL_EXCEPT == 0)
-+/* E.g. ARM soft float does not define these */
-+#define FE_INVALID    0
-+#define FE_DIVBYZERO  0
-+#define FE_OVERFLOW   0
-+#define FE_UNDERFLOW  0
-+#define FE_INEXACT    0
-+#endif
-+
- #if CONFIG_LIBFONTCONFIG
- #include <fontconfig/fontconfig.h>
- #endif
diff --git a/srcpkgs/ffmpeg/patches/binutils-2.41.patch b/srcpkgs/ffmpeg/patches/binutils-2.41.patch
deleted file mode 100644
index 53a596d0ee7d4e..00000000000000
--- a/srcpkgs/ffmpeg/patches/binutils-2.41.patch
+++ /dev/null
@@ -1,73 +0,0 @@
-From effadce6c756247ea8bae32dc13bb3e6f464f0eb Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= <remi@remlab.net>
-Date: Sun, 16 Jul 2023 18:18:02 +0300
-Subject: [PATCH] avcodec/x86/mathops: clip constants used with shift
- instructions within inline assembly
-
-Fixes assembling with binutil as >= 2.41
-
-Signed-off-by: James Almer <jamrial@gmail.com>
----
- libavcodec/x86/mathops.h | 26 +++++++++++++++++++++++---
- 1 file changed, 23 insertions(+), 3 deletions(-)
-
-diff --git a/libavcodec/x86/mathops.h b/libavcodec/x86/mathops.h
-index 6298f5ed1983b..ca7e2dffc1076 100644
---- a/libavcodec/x86/mathops.h
-+++ b/libavcodec/x86/mathops.h
-@@ -35,12 +35,20 @@
- static av_always_inline av_const int MULL(int a, int b, unsigned shift)
- {
-     int rt, dummy;
-+    if (__builtin_constant_p(shift))
-     __asm__ (
-         "imull %3               \n\t"
-         "shrdl %4, %%edx, %%eax \n\t"
-         :"=a"(rt), "=d"(dummy)
--        :"a"(a), "rm"(b), "ci"((uint8_t)shift)
-+        :"a"(a), "rm"(b), "i"(shift & 0x1F)
-     );
-+    else
-+        __asm__ (
-+            "imull %3               \n\t"
-+            "shrdl %4, %%edx, %%eax \n\t"
-+            :"=a"(rt), "=d"(dummy)
-+            :"a"(a), "rm"(b), "c"((uint8_t)shift)
-+        );
-     return rt;
- }
- 
-@@ -113,19 +121,31 @@ __asm__ volatile(\
- // avoid +32 for shift optimization (gcc should do that ...)
- #define NEG_SSR32 NEG_SSR32
- static inline  int32_t NEG_SSR32( int32_t a, int8_t s){
-+    if (__builtin_constant_p(s))
-     __asm__ ("sarl %1, %0\n\t"
-          : "+r" (a)
--         : "ic" ((uint8_t)(-s))
-+         : "i" (-s & 0x1F)
-     );
-+    else
-+        __asm__ ("sarl %1, %0\n\t"
-+               : "+r" (a)
-+               : "c" ((uint8_t)(-s))
-+        );
-     return a;
- }
- 
- #define NEG_USR32 NEG_USR32
- static inline uint32_t NEG_USR32(uint32_t a, int8_t s){
-+    if (__builtin_constant_p(s))
-     __asm__ ("shrl %1, %0\n\t"
-          : "+r" (a)
--         : "ic" ((uint8_t)(-s))
-+         : "i" (-s & 0x1F)
-     );
-+    else
-+        __asm__ ("shrl %1, %0\n\t"
-+               : "+r" (a)
-+               : "c" ((uint8_t)(-s))
-+        );
-     return a;
- }
- 
diff --git a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
deleted file mode 100644
index aa948f7a8a2dfb..00000000000000
--- a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
+++ /dev/null
@@ -1,40 +0,0 @@
-#==================================================================================================
-# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
-# From: Christopher Degawa <christopher.degawa@intel.com>
-# Date: Thu, 20 Oct 2022 22:55:27 -0500
-# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
-#
-# compressed_ten_bit_format has been deprecated upstream and has no effect
-# and can be removed. Plus, technically it was never used in the first place
-# since it would require the app (ffmpeg) to set it and do additional
-# processing of the input frames.
-#
-# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
-#
-# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
-#==================================================================================================
---- a/libavcodec/libsvtav1.c
-+++ b/libavcodec/libsvtav1.c
-@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
- 
- static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
- {
--    const int    pack_mode_10bit =
--        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
--    const size_t luma_size_8bit  =
--        config->source_width * config->source_height * (1 << pack_mode_10bit);
--    const size_t luma_size_10bit =
--        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
-+    const size_t luma_size = config->source_width * config->source_height *
-+        (config->encoder_bit_depth > 8 ? 2 : 1);
- 
-     EbSvtIOFormat *in_data;
- 
--    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
-+    svt_enc->raw_size = luma_size * 3 / 2;
- 
-     // allocate buffer for in and out
-     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
--- 
-GitLab
-
diff --git a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
deleted file mode 100644
index 00e3f68a415b84..00000000000000
--- a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
-From: Rainer Hochecker <fernetmenta@online.de>
-Date: Sat, 26 Jan 2019 19:48:35 +0100
-Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
-
-This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
-It was hit frequently when watching h264 channels received via DVB-X.
-Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
----
- libavcodec/vaapi_h264.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
-index 5854587a255..f12fdc457a4 100644
---- a/libavcodec/vaapi_h264.c
-+++ b/libavcodec/vaapi_h264.c
-@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
-     H264SliceContext *sl = &h->slice_ctx[0];
-     int ret;
- 
-+    if (pic->nb_slices == 0) {
-+        ret = AVERROR_INVALIDDATA;
-+        goto finish;
-+    }
-+
-     ret = ff_vaapi_decode_issue(avctx, pic);
-     if (ret < 0)
-         goto finish;
diff --git a/srcpkgs/ffmpeg/template b/srcpkgs/ffmpeg/template
index 1ebb436135938d..f1e4712c41d087 100644
--- a/srcpkgs/ffmpeg/template
+++ b/srcpkgs/ffmpeg/template
@@ -1,15 +1,15 @@
 # Template file for 'ffmpeg'
 # audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
 pkgname=ffmpeg
-version=4.4.4
-revision=6
+version=6.0.1
+revision=1
 short_desc="Decoding, encoding and streaming software"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="https://www.ffmpeg.org"
 changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
 distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
-checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+checksum=9b16b8731d78e596b4be0d720428ca42df642bb2d78342881ff7f5bc29fc9623
 
 hostmakedepends="pkg-config perl"
 makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
@@ -26,12 +26,13 @@ makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-deve
  $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
  $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
  $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
- $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers Vulkan-Tools Vulkan-ValidationLayers')
+ $(vopt_if onevpl 'oneVPL oneVPL-devel')
  $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
 depends="ffplay>=${version}_${revision}"
 
 build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
- dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec onevpl"
 build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
 desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
 desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
@@ -39,9 +40,13 @@ desc_option_sofa="Enable support for AES SOFA"
 desc_option_webp="Enable support for WebP"
 
 case "$XBPS_TARGET_MACHINE" in
-	i686*|x86_64*)
-		hostmakedepends+=" nasm"
+	i686*)
 		build_options_default+=" vaapi vdpau nvenc nvdec"
+		hostmakedepends+=" nasm"
+		;;
+	x86_64*)
+		hostmakedepends+=" nasm"
+		build_options_default+=" vaapi vdpau nvenc nvdec onevpl"
 		;;
 	ppc64*) build_options_default+=" vaapi vdpau";;
 	mips*) CFLAGS="-mnan=legacy";;
@@ -65,8 +70,6 @@ post_patch() {
 		ppc64le*) ;;
 		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
 	esac
-
-	vsed -i libavfilter/vf_libvmaf.c -e 's!/usr/local/share/model/\(vmaf_v0.6.1\).pkl!/usr/share/vmaf/\1.json!'
 }
 
 do_configure() {
@@ -115,18 +118,19 @@ do_configure() {
 		$(vopt_enable x265 libx265) \
 		$(vopt_enable v4l2 libv4l2) \
 		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
-		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		--enable-libbs2b --enable-libvidstab \
 		$(vopt_enable dav1d libdav1d) \
 		$(vopt_enable zimg libzimg) \
 		$(vopt_enable webp libwebp) \
 		$(vopt_enable sofa libmysofa) \
 		$(vopt_enable vulkan) \
+		$(vopt_enable onevpl libvpl) \
 		$(vopt_enable drm libdrm) \
 		$(vopt_enable svtav1 libsvtav1) \
 		$(vopt_enable srt libsrt) \
 		$(vopt_enable rist librist) \
-		$(vopt_if nvenc '--enable-nvenc') \
-		$(vopt_if nvdec '--enable-nvdec')
+		$(vopt_enable nvenc nvenc) \
+		$(vopt_enable nvdec nvdec)
 }
 
 do_build() {
@@ -153,10 +157,8 @@ libavdevice_package() {
 }
 
 libavresample_package() {
-	short_desc="FFmpeg audio resampling library"
-	pkg_install() {
-		vmove "usr/lib/libavresample.so.*"
-	}
+	short_desc="Package deprecated, removal needed"
+	build_style=meta
 }
 
 libavformat_package() {
@@ -210,15 +212,13 @@ ffmpeg-devel_package() {
 		libavfilter>=${version}_${revision}
 		libpostproc>=${version}_${revision}
 		libswscale>=${version}_${revision}
-		libswresample>=${version}_${revision}
-		libavresample>=${version}_${revision}"
+		libswresample>=${version}_${revision}"
 	short_desc+=" - development files"
-
+	conflicts="ffmpeg4-devel"
 	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
 		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
 		nostrip_files="/usr/lib/libavfilter.a"
 	fi
-
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig

From d92db2d5de74fe105a2e85eaf585a7da040575b8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:14 -0400
Subject: [PATCH 002/111] openshot: revbump for ffmpeg6

---
 srcpkgs/openshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openshot/template b/srcpkgs/openshot/template
index 3849858fe963b5..12789bc9867499 100644
--- a/srcpkgs/openshot/template
+++ b/srcpkgs/openshot/template
@@ -1,7 +1,7 @@
 # Template file for 'openshot'
 pkgname=openshot
 version=3.1.1
-revision=1
+revision=2
 build_style=python3-module
 hostmakedepends="python3 python3-setuptools"
 makedepends="ffmpeg-devel python3-PyQt5"

From 578d99e31db8df6fb155cadbe48f26d68f183e5d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:36 -0400
Subject: [PATCH 003/111] sumo: revbump for ffmpeg6

---
 srcpkgs/sumo/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/sumo/template b/srcpkgs/sumo/template
index a730afa9fafa92..e2def06fa4bd7d 100644
--- a/srcpkgs/sumo/template
+++ b/srcpkgs/sumo/template
@@ -1,7 +1,7 @@
 # Template file for 'sumo'
 pkgname=sumo
 version=1.12.0
-revision=7
+revision=8
 build_style=cmake
 hostmakedepends="libgdal-tools pkg-config swig python3-setuptools"
 makedepends="python3-devel ffmpeg-devel fox-devel gl2ps-devel libgdal-devel

From 38876ba2694d7dac5dd1074471a8612fe7a5e895 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:56:22 -0400
Subject: [PATCH 004/111] New package: ffmpeg4-4.4.4.

---
 srcpkgs/ffmpeg4-devel                         |   1 +
 srcpkgs/ffmpeg4/files/altivec.patch           |  60 +++++
 .../patches/armv5tel-floating-point.patch     |  18 ++
 srcpkgs/ffmpeg4/patches/binutils-2.41.patch   |  73 ++++++
 ...h-libavcodec-libsvtav1-ten_bit_format.diff |  40 +++
 .../workaround-mesa-readeon-vaapi-bug.patch   |  28 +++
 srcpkgs/ffmpeg4/template                      | 234 ++++++++++++++++++
 srcpkgs/libavcodec4                           |   1 +
 srcpkgs/libavdevice4                          |   1 +
 srcpkgs/libavfilter4                          |   1 +
 srcpkgs/libavformat4                          |   1 +
 srcpkgs/libavresample4                        |   1 +
 srcpkgs/libavutil4                            |   1 +
 srcpkgs/libpostproc4                          |   1 +
 srcpkgs/libswresample4                        |   1 +
 srcpkgs/libswscale4                           |   1 +
 16 files changed, 463 insertions(+)
 create mode 120000 srcpkgs/ffmpeg4-devel
 create mode 100644 srcpkgs/ffmpeg4/files/altivec.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/binutils-2.41.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 create mode 100644 srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
 create mode 100644 srcpkgs/ffmpeg4/template
 create mode 120000 srcpkgs/libavcodec4
 create mode 120000 srcpkgs/libavdevice4
 create mode 120000 srcpkgs/libavfilter4
 create mode 120000 srcpkgs/libavformat4
 create mode 120000 srcpkgs/libavresample4
 create mode 120000 srcpkgs/libavutil4
 create mode 120000 srcpkgs/libpostproc4
 create mode 120000 srcpkgs/libswresample4
 create mode 120000 srcpkgs/libswscale4

diff --git a/srcpkgs/ffmpeg4-devel b/srcpkgs/ffmpeg4-devel
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/ffmpeg4-devel
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/ffmpeg4/files/altivec.patch b/srcpkgs/ffmpeg4/files/altivec.patch
new file mode 100644
index 00000000000000..9c57200463320e
--- /dev/null
+++ b/srcpkgs/ffmpeg4/files/altivec.patch
@@ -0,0 +1,60 @@
+revert some altivec specific change on all ppc* except ppc64le*
+
+q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
+conditionally, for ppc* but not ppc64le* (the new code is valid for
+POWER8 VSX which LE targets as a baseline but not BE)"
+
+
+This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
+---
+ libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
+ 1 file changed, 20 insertions(+), 4 deletions(-)
+
+diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
+index 536545293d..c1e2852adb 100644
+--- a/libswscale/ppc/yuv2rgb_altivec.c
++++ b/libswscale/ppc/yuv2rgb_altivec.c
+@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+     vector signed short R1, G1, B1;                                           \
+     vector unsigned char R, G, B;                                             \
+                                                                               \
++    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
++    vector unsigned char align_perm;                                          \
++                                                                              \
+     vector signed short lCY       = c->CY;                                    \
+     vector signed short lOY       = c->OY;                                    \
+     vector signed short lCRV      = c->CRV;                                   \
+@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
+                                                                               \
+         for (j = 0; j < w / 16; j++) {                                        \
+-            y0 = vec_xl(0, y1i);                                              \
++            y1ivP = (const vector unsigned char *) y1i;                       \
++            y2ivP = (const vector unsigned char *) y2i;                       \
++            uivP  = (const vector unsigned char *) ui;                        \
++            vivP  = (const vector unsigned char *) vi;                        \
++                                                                              \
++            align_perm = vec_lvsl(0, y1i);                                    \
++            y0 = (vector unsigned char)                                       \
++                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
+                                                                               \
+-            y1 = vec_xl(0, y2i);                                              \
++            align_perm = vec_lvsl(0, y2i);                                    \
++            y1 = (vector unsigned char)                                       \
++                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
+                                                                               \
+-            u = (vector signed char) vec_xl(0, ui);                           \
++            align_perm = vec_lvsl(0, ui);                                     \
++            u = (vector signed char)                                          \
++                    vec_perm(uivP[0], uivP[1], align_perm);                   \
+                                                                               \
+-            v = (vector signed char) vec_xl(0, vi);                           \
++            align_perm = vec_lvsl(0, vi);                                     \
++            v = (vector signed char)                                          \
++                    vec_perm(vivP[0], vivP[1], align_perm);                   \
+                                                                               \
+             u = (vector signed char)                                          \
+                     vec_sub(u,                                                \
+-- 
+2.27.0
+
diff --git a/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
new file mode 100644
index 00000000000000..9a55178c74f0fd
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
@@ -0,0 +1,18 @@
+--- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
++++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
+@@ -39,6 +39,15 @@
+ #endif
+ #include <fenv.h>
+ 
++#if (FE_ALL_EXCEPT == 0)
++/* E.g. ARM soft float does not define these */
++#define FE_INVALID    0
++#define FE_DIVBYZERO  0
++#define FE_OVERFLOW   0
++#define FE_UNDERFLOW  0
++#define FE_INEXACT    0
++#endif
++
+ #if CONFIG_LIBFONTCONFIG
+ #include <fontconfig/fontconfig.h>
+ #endif
diff --git a/srcpkgs/ffmpeg4/patches/binutils-2.41.patch b/srcpkgs/ffmpeg4/patches/binutils-2.41.patch
new file mode 100644
index 00000000000000..53a596d0ee7d4e
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/binutils-2.41.patch
@@ -0,0 +1,73 @@
+From effadce6c756247ea8bae32dc13bb3e6f464f0eb Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= <remi@remlab.net>
+Date: Sun, 16 Jul 2023 18:18:02 +0300
+Subject: [PATCH] avcodec/x86/mathops: clip constants used with shift
+ instructions within inline assembly
+
+Fixes assembling with binutil as >= 2.41
+
+Signed-off-by: James Almer <jamrial@gmail.com>
+---
+ libavcodec/x86/mathops.h | 26 +++++++++++++++++++++++---
+ 1 file changed, 23 insertions(+), 3 deletions(-)
+
+diff --git a/libavcodec/x86/mathops.h b/libavcodec/x86/mathops.h
+index 6298f5ed1983b..ca7e2dffc1076 100644
+--- a/libavcodec/x86/mathops.h
++++ b/libavcodec/x86/mathops.h
+@@ -35,12 +35,20 @@
+ static av_always_inline av_const int MULL(int a, int b, unsigned shift)
+ {
+     int rt, dummy;
++    if (__builtin_constant_p(shift))
+     __asm__ (
+         "imull %3               \n\t"
+         "shrdl %4, %%edx, %%eax \n\t"
+         :"=a"(rt), "=d"(dummy)
+-        :"a"(a), "rm"(b), "ci"((uint8_t)shift)
++        :"a"(a), "rm"(b), "i"(shift & 0x1F)
+     );
++    else
++        __asm__ (
++            "imull %3               \n\t"
++            "shrdl %4, %%edx, %%eax \n\t"
++            :"=a"(rt), "=d"(dummy)
++            :"a"(a), "rm"(b), "c"((uint8_t)shift)
++        );
+     return rt;
+ }
+ 
+@@ -113,19 +121,31 @@ __asm__ volatile(\
+ // avoid +32 for shift optimization (gcc should do that ...)
+ #define NEG_SSR32 NEG_SSR32
+ static inline  int32_t NEG_SSR32( int32_t a, int8_t s){
++    if (__builtin_constant_p(s))
+     __asm__ ("sarl %1, %0\n\t"
+          : "+r" (a)
+-         : "ic" ((uint8_t)(-s))
++         : "i" (-s & 0x1F)
+     );
++    else
++        __asm__ ("sarl %1, %0\n\t"
++               : "+r" (a)
++               : "c" ((uint8_t)(-s))
++        );
+     return a;
+ }
+ 
+ #define NEG_USR32 NEG_USR32
+ static inline uint32_t NEG_USR32(uint32_t a, int8_t s){
++    if (__builtin_constant_p(s))
+     __asm__ ("shrl %1, %0\n\t"
+          : "+r" (a)
+-         : "ic" ((uint8_t)(-s))
++         : "i" (-s & 0x1F)
+     );
++    else
++        __asm__ ("shrl %1, %0\n\t"
++               : "+r" (a)
++               : "c" ((uint8_t)(-s))
++        );
+     return a;
+ }
+ 
diff --git a/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
new file mode 100644
index 00000000000000..aa948f7a8a2dfb
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
@@ -0,0 +1,40 @@
+#==================================================================================================
+# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
+# From: Christopher Degawa <christopher.degawa@intel.com>
+# Date: Thu, 20 Oct 2022 22:55:27 -0500
+# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
+#
+# compressed_ten_bit_format has been deprecated upstream and has no effect
+# and can be removed. Plus, technically it was never used in the first place
+# since it would require the app (ffmpeg) to set it and do additional
+# processing of the input frames.
+#
+# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
+#
+# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
+#==================================================================================================
+--- a/libavcodec/libsvtav1.c
++++ b/libavcodec/libsvtav1.c
+@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
+ 
+ static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
+ {
+-    const int    pack_mode_10bit =
+-        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
+-    const size_t luma_size_8bit  =
+-        config->source_width * config->source_height * (1 << pack_mode_10bit);
+-    const size_t luma_size_10bit =
+-        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
++    const size_t luma_size = config->source_width * config->source_height *
++        (config->encoder_bit_depth > 8 ? 2 : 1);
+ 
+     EbSvtIOFormat *in_data;
+ 
+-    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
++    svt_enc->raw_size = luma_size * 3 / 2;
+ 
+     // allocate buffer for in and out
+     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
+-- 
+GitLab
+
diff --git a/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
new file mode 100644
index 00000000000000..00e3f68a415b84
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
@@ -0,0 +1,28 @@
+From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
+From: Rainer Hochecker <fernetmenta@online.de>
+Date: Sat, 26 Jan 2019 19:48:35 +0100
+Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
+
+This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
+It was hit frequently when watching h264 channels received via DVB-X.
+Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
+---
+ libavcodec/vaapi_h264.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
+index 5854587a255..f12fdc457a4 100644
+--- a/libavcodec/vaapi_h264.c
++++ b/libavcodec/vaapi_h264.c
+@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
+     H264SliceContext *sl = &h->slice_ctx[0];
+     int ret;
+ 
++    if (pic->nb_slices == 0) {
++        ret = AVERROR_INVALIDDATA;
++        goto finish;
++    }
++
+     ret = ff_vaapi_decode_issue(avctx, pic);
+     if (ret < 0)
+         goto finish;
diff --git a/srcpkgs/ffmpeg4/template b/srcpkgs/ffmpeg4/template
new file mode 100644
index 00000000000000..9ba14bdb8ddf32
--- /dev/null
+++ b/srcpkgs/ffmpeg4/template
@@ -0,0 +1,234 @@
+# Template file for 'ffmpeg4'
+# audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
+pkgname=ffmpeg4
+version=4.4.4
+revision=1
+short_desc="Decoding, encoding and streaming software - ffmpeg4 libraries only"
+maintainer="Orphaned <orphan@voidlinux.org>"
+license="GPL-3.0-or-later"
+homepage="https://www.ffmpeg.org"
+changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
+distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
+checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+
+hostmakedepends="pkg-config perl"
+makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
+ libXext-devel libXvMC-devel libxcb-devel lame-devel libtheora-devel
+ libvorbis-devel x264-devel xvidcore-devel jack-devel SDL2-devel
+ libcdio-paranoia-devel librtmp-devel libmodplug-devel gnutls-devel
+ speex-devel celt-devel harfbuzz-devel libass-devel opus-devel ocl-icd-devel
+ libbs2b-devel libvidstab-devel vmaf-devel $(vopt_if pulseaudio pulseaudio-devel)
+ $(vopt_if vaapi libva-devel) $(vopt_if vdpau libvdpau-devel)
+ $(vopt_if x265 x265-devel) $(vopt_if v4l2 v4l-utils-devel)
+ $(vopt_if fdk_aac fdk-aac-devel) $(vopt_if vpx libvpx-devel)
+ $(vopt_if aom libaom-devel) $(vopt_if sndio sndio-devel)
+ $(vopt_if dav1d libdav1d-devel) $(vopt_if zimg zimg-devel)
+ $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
+ $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
+ $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
+
+build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
+
+desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
+desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
+desc_option_sofa="Enable support for AES SOFA"
+desc_option_webp="Enable support for WebP"
+
+case "$XBPS_TARGET_MACHINE" in
+	i686*|x86_64*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau nvenc nvdec"
+			;;
+	ppc64*) build_options_default+=" vaapi vdpau";;
+	mips*) CFLAGS="-mnan=legacy";;
+esac
+
+if [ "$XBPS_TARGET_WORDSIZE" != "32" ]; then
+	build_options_default+=" svtav1"
+fi
+
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+fi
+
+_apply_patch() {
+	local args="$1" pname="$(basename $2)"
+
+	if [ ! -f ".${pname}_done" ]; then
+		patch -N $args -i $2
+		touch .${pname}_done
+	fi
+}
+
+post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64le*) ;;
+		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
+	esac
+
+	vsed -i libavfilter/vf_libvmaf.c -e 's!/usr/local/share/model/\(vmaf_v0.6.1\).pkl!/usr/share/vmaf/\1.json!'
+}
+
+do_configure() {
+	# Fix gcc on x86_64-musl only
+	if [ "$XBPS_TARGET_MACHINE" = "x86_64-musl" ]; then
+		vsed -i configure -e "s;_cflags_speed='-O3';_cflags_speed='-O2';"
+	fi
+
+	if [ "$CROSS_BUILD" ]; then
+		case "$XBPS_TARGET_MACHINE" in
+			arm*) _arch="arm";;
+			aarch64*) _arch="aarch64";;
+			mips*) _arch="mips";;
+			ppc64*) _arch="ppc64";;
+			ppc*) _arch="ppc";;
+			*) _arch="${XBPS_TARGET_MACHINE%%-musl}";;
+		esac
+
+		_args+=" --enable-cross-compile
+			--sysroot=$XBPS_CROSS_BASE
+			--cross-prefix=${XBPS_CROSS_TRIPLET}-
+			--target-os=linux --arch=${_arch}"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc|ppc-musl) _args+=" --disable-altivec";;
+	esac
+
+	if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+		_args+=" --extra-libs=-latomic"
+	fi
+
+	./configure --prefix=/usr --disable-debug --enable-gpl --enable-gnutls \
+		--disable-stripping \
+		--enable-libcdio --enable-version3 --enable-runtime-cpudetect \
+		--enable-libmp3lame --enable-libvorbis --enable-libxvid \
+		--enable-libx264 $(vopt_enable vpx libvpx) --enable-libtheora \
+		--enable-shared --enable-static --enable-libxcb \
+		$(vopt_enable pulseaudio libpulse) --enable-libfreetype --enable-libmodplug \
+		--enable-libspeex --enable-libcelt --enable-libass \
+		--enable-libopus --enable-librtmp --enable-libjack \
+		$(vopt_if fdk_aac '--enable-nonfree --enable-libfdk-aac') \
+		--disable-libopencore_amrnb --disable-libopencore_amrwb \
+		--disable-libopenjpeg \
+		--enable-postproc --enable-opencl ${_args} --enable-libvmaf ${_args} \
+		$(vopt_enable x265 libx265) \
+		$(vopt_enable v4l2 libv4l2) \
+		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
+		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		$(vopt_enable dav1d libdav1d) \
+		$(vopt_enable zimg libzimg) \
+		$(vopt_enable webp libwebp) \
+		$(vopt_enable sofa libmysofa) \
+		$(vopt_enable vulkan) \
+		$(vopt_enable drm libdrm) \
+		$(vopt_enable svtav1 libsvtav1) \
+		$(vopt_enable srt libsrt) \
+		$(vopt_enable rist librist) \
+		$(vopt_if nvenc '--enable-nvenc') \
+		$(vopt_if nvdec '--enable-nvdec')
+}
+
+do_build() {
+	make ${makejobs}
+	make doc/ff{mpeg,play}.1
+}
+
+do_install() {
+	make DESTDIR=${DESTDIR} install install-man
+	rm -rf ${DESTDIR}/usr/bin
+}
+
+libavcodec4_package() {
+	short_desc="FFmpeg codec library"
+	pkg_install() {
+		vmove "usr/lib/libavcodec.so.*"
+	}
+}
+
+libavdevice4_package() {
+	short_desc="FFmpeg device handling library"
+	pkg_install() {
+		vmove "usr/lib/libavdevice.so.*"
+	}
+}
+
+libavresample4_package() {
+	short_desc="FFmpeg audio resampling library"
+	pkg_install() {
+		vmove "usr/lib/libavresample.so.*"
+	}
+}
+
+libavformat4_package() {
+	short_desc="FFmpeg file format library"
+	pkg_install() {
+		vmove "usr/lib/libavformat.so.*"
+	}
+}
+
+libavutil4_package() {
+	short_desc="FFmpeg utility library"
+	pkg_install() {
+		vmove "usr/lib/libavutil.so.*"
+	}
+}
+
+libavfilter4_package() {
+	short_desc="FFmpeg audio/video filter library"
+	pkg_install() {
+		vmove "usr/lib/libavfilter.so.*"
+	}
+}
+
+libpostproc4_package() {
+	short_desc="FFmpeg video postprocessing library"
+	pkg_install() {
+		vmove "usr/lib/libpostproc.so.*"
+	}
+}
+
+libswscale4_package() {
+	short_desc="FFmpeg video scaling library"
+	pkg_install() {
+		vmove "usr/lib/libswscale.so.*"
+	}
+}
+
+libswresample4_package() {
+	short_desc="FFmpeg video resampling library"
+	pkg_install() {
+		vmove "usr/lib/libswresample.so.*"
+	}
+}
+
+ffmpeg4-devel_package() {
+	depends="
+		libavcodec4>=${version}_${revision}
+		libavdevice4>=${version}_${revision}
+		libavformat4>=${version}_${revision}
+		libavutil4>=${version}_${revision}
+		libavfilter4>=${version}_${revision}
+		libpostproc4>=${version}_${revision}
+		libswscale4>=${version}_${revision}
+		libswresample4>=${version}_${revision}
+		libavresample4>=${version}_${revision}"
+	short_desc+=" - development files"
+	conflicts="ffmpeg-devel"
+	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
+		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
+		nostrip_files="/usr/lib/libavfilter.a"
+	fi
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.a"
+		vmove "usr/lib/*.so"
+		vmove usr/share/ffmpeg/examples
+		vmove usr/share/man/man3
+	}
+}
diff --git a/srcpkgs/libavcodec4 b/srcpkgs/libavcodec4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavcodec4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavdevice4 b/srcpkgs/libavdevice4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavdevice4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavfilter4 b/srcpkgs/libavfilter4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavfilter4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavformat4 b/srcpkgs/libavformat4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavformat4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavresample4 b/srcpkgs/libavresample4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavutil4 b/srcpkgs/libavutil4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavutil4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libpostproc4 b/srcpkgs/libpostproc4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libpostproc4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswresample4 b/srcpkgs/libswresample4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libswresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswscale4 b/srcpkgs/libswscale4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libswscale4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file

From 828857007c36642097c2f074775d82140e62830c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:04 -0400
Subject: [PATCH 005/111] opencv: update to 4.7.0.

---
 common/shlibs           | 104 ++++++++++++++++++++--------------------
 srcpkgs/opencv/template |   8 ++--
 2 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index 6c43918b759af4..23695bed21ea8c 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2075,58 +2075,58 @@ libcapstone.so.5 capstone-5.0.1_1
 libhavege.so.2 libhaveged-1.9.11_1
 libnih.so.1 libnih-1.0.3_1
 libnih-dbus.so.1 libnih-1.0.3_1
-libopencv_quality.so.406 libopencv-4.6.0_1
-libopencv_reg.so.406 libopencv-4.6.0_1
-libopencv_surface_matching.so.406 libopencv-4.6.0_1
-libopencv_xphoto.so.406 libopencv-4.6.0_1
-libopencv_freetype.so.406 libopencv-4.6.0_1
-libopencv_fuzzy.so.406 libopencv-4.6.0_1
-libopencv_hfs.so.406 libopencv-4.6.0_1
-libopencv_img_hash.so.406 libopencv-4.6.0_1
-libopencv_line_descriptor.so.406 libopencv-4.6.0_1
-libopencv_saliency.so.406 libopencv-4.6.0_1
-libopencv_structured_light.so.406 libopencv-4.6.0_1
-libopencv_aruco.so.406 libopencv-4.6.0_1
-libopencv_bgsegm.so.406 libopencv-4.6.0_1
-libopencv_bioinspired.so.406 libopencv-4.6.0_1
-libopencv_ccalib.so.406 libopencv-4.6.0_1
-libopencv_face.so.406 libopencv-4.6.0_1
-libopencv_tracking.so.406 libopencv-4.6.0_1
-libopencv_xfeatures2d.so.406 libopencv-4.6.0_1
-libopencv_optflow.so.406 libopencv-4.6.0_1
-libopencv_ximgproc.so.406 libopencv-4.6.0_1
-libopencv_plot.so.406 libopencv-4.6.0_1
-libopencv_text.so.406 libopencv-4.6.0_1
-libopencv_ml.so.406 libopencv-4.6.0_1
-libopencv_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn.so.406 libopencv-4.6.0_1
-libopencv_shape.so.406 libopencv-4.6.0_1
-libopencv_stitching.so.406 libopencv-4.6.0_1
-libopencv_photo.so.406 libopencv-4.6.0_1
-libopencv_video.so.406 libopencv-4.6.0_1
-libopencv_calib3d.so.406 libopencv-4.6.0_1
-libopencv_features2d.so.406 libopencv-4.6.0_1
-libopencv_flann.so.406 libopencv-4.6.0_1
-libopencv_highgui.so.406 libopencv-4.6.0_1
-libopencv_videoio.so.406 libopencv-4.6.0_1
-libopencv_imgcodecs.so.406 libopencv-4.6.0_1
-libopencv_imgproc.so.406 libopencv-4.6.0_1
-libopencv_core.so.406 libopencv-4.6.0_1
-libopencv_superres.so.406 libopencv-4.6.0_1
-libopencv_videostab.so.406 libopencv-4.6.0_1
-libopencv_gapi.so.406 libopencv-4.6.0_1
-libopencv_xobjdetect.so.406 libopencv-4.6.0_1
-libopencv_datasets.so.406 libopencv-4.6.0_1
-libopencv_dnn_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn_superres.so.406 libopencv-4.6.0_1
-libopencv_dpm.so.406 libopencv-4.6.0_1
-libopencv_phase_unwrapping.so.406 libopencv-4.6.0_1
-libopencv_stereo.so.406 libopencv-4.6.0_1
-libopencv_rapid.so.406 libopencv-4.6.0_1
-libopencv_intensity_transform.so.406 libopencv-4.6.0_1
-libopencv_alphamat.so.406 libopencv-4.6.0_1
-libopencv_barcode.so.406 libopencv-4.6.0_1
-libopencv_mcc.so.406 libopencv-4.6.0_1
+libopencv_quality.so.407 libopencv-4.7.0_1
+libopencv_reg.so.407 libopencv-4.7.0_1
+libopencv_surface_matching.so.407 libopencv-4.7.0_1
+libopencv_xphoto.so.407 libopencv-4.7.0_1
+libopencv_freetype.so.407 libopencv-4.7.0_1
+libopencv_fuzzy.so.407 libopencv-4.7.0_1
+libopencv_hfs.so.407 libopencv-4.7.0_1
+libopencv_img_hash.so.407 libopencv-4.7.0_1
+libopencv_line_descriptor.so.407 libopencv-4.7.0_1
+libopencv_saliency.so.407 libopencv-4.7.0_1
+libopencv_structured_light.so.407 libopencv-4.7.0_1
+libopencv_aruco.so.407 libopencv-4.7.0_1
+libopencv_bgsegm.so.407 libopencv-4.7.0_1
+libopencv_bioinspired.so.407 libopencv-4.7.0_1
+libopencv_ccalib.so.407 libopencv-4.7.0_1
+libopencv_face.so.407 libopencv-4.7.0_1
+libopencv_tracking.so.407 libopencv-4.7.0_1
+libopencv_xfeatures2d.so.407 libopencv-4.7.0_1
+libopencv_optflow.so.407 libopencv-4.7.0_1
+libopencv_ximgproc.so.407 libopencv-4.7.0_1
+libopencv_plot.so.407 libopencv-4.7.0_1
+libopencv_text.so.407 libopencv-4.7.0_1
+libopencv_ml.so.407 libopencv-4.7.0_1
+libopencv_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn.so.407 libopencv-4.7.0_1
+libopencv_shape.so.407 libopencv-4.7.0_1
+libopencv_stitching.so.407 libopencv-4.7.0_1
+libopencv_photo.so.407 libopencv-4.7.0_1
+libopencv_video.so.407 libopencv-4.7.0_1
+libopencv_calib3d.so.407 libopencv-4.7.0_1
+libopencv_features2d.so.407 libopencv-4.7.0_1
+libopencv_flann.so.407 libopencv-4.7.0_1
+libopencv_highgui.so.407 libopencv-4.7.0_1
+libopencv_videoio.so.407 libopencv-4.7.0_1
+libopencv_imgcodecs.so.407 libopencv-4.7.0_1
+libopencv_imgproc.so.407 libopencv-4.7.0_1
+libopencv_core.so.407 libopencv-4.7.0_1
+libopencv_superres.so.407 libopencv-4.7.0_1
+libopencv_videostab.so.407 libopencv-4.7.0_1
+libopencv_gapi.so.407 libopencv-4.7.0_1
+libopencv_xobjdetect.so.407 libopencv-4.7.0_1
+libopencv_datasets.so.407 libopencv-4.7.0_1
+libopencv_dnn_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn_superres.so.407 libopencv-4.7.0_1
+libopencv_dpm.so.407 libopencv-4.7.0_1
+libopencv_phase_unwrapping.so.407 libopencv-4.7.0_1
+libopencv_stereo.so.407 libopencv-4.7.0_1
+libopencv_rapid.so.407 libopencv-4.7.0_1
+libopencv_intensity_transform.so.407 libopencv-4.7.0_1
+libopencv_alphamat.so.407 libopencv-4.7.0_1
+libopencv_barcode.so.407 libopencv-4.7.0_1
+libopencv_mcc.so.407 libopencv-4.7.0_1
 libuniconf.so.4.6 wvstreams-4.6.1_20
 libwvbase.so.4.6 wvstreams-4.6.1_20
 libwvutils.so.4.6 wvstreams-4.6.1_20
diff --git a/srcpkgs/opencv/template b/srcpkgs/opencv/template
index aea4bfc3a265cf..ce94de9424d18d 100644
--- a/srcpkgs/opencv/template
+++ b/srcpkgs/opencv/template
@@ -1,7 +1,7 @@
 # Template file for 'opencv'
 pkgname=opencv
-version=4.6.0
-revision=6
+version=4.7.0
+revision=1
 create_wrksrc=yes
 build_wrksrc=${pkgname}-${version}
 build_style=cmake
@@ -24,8 +24,8 @@ homepage="https://opencv.org"
 changelog="https://github.com/opencv/opencv/wiki/ChangeLog"
 distfiles="https://github.com/opencv/opencv/archive/${version}.tar.gz
  https://github.com/opencv/opencv_contrib/archive/${version}.tar.gz>contrib.tar.gz"
-checksum="1ec1cba65f9f20fe5a41fda1586e01c70ea0c9a6d7b67c9e13edf0cfe2239277
- 1777d5fd2b59029cf537e5fd6f8aa68d707075822f90bde683fcde086f85f7a7"
+checksum="8df0079cdbe179748a18d44731af62a245a45ebf5085223dc03133954c662973
+ 42df840cf9055e59d0e22c249cfb19f04743e1bdad113d31b1573d3934d62584"
 patch_args="-Np1 -d ${build_wrksrc}"
 # tests hang indenfinitely, even with test data included
 make_check=no

From 793c2333e159294c853ac3f3b3880e328b01de3c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 006/111] actiona: revbump for opencv-4.7.0

---
 srcpkgs/actiona/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/actiona/template b/srcpkgs/actiona/template
index cf5f0b7a2ae610..0d899311e6df75 100644
--- a/srcpkgs/actiona/template
+++ b/srcpkgs/actiona/template
@@ -1,7 +1,7 @@
 # Template file for 'actiona'
 pkgname=actiona
 version=3.10.1
-revision=2
+revision=3
 build_style=qmake
 configure_args="PKGCONFIG_OPENCV=opencv4"
 hostmakedepends="pkg-config qt5-plugin-mysql qt5-qmake qt5-host-tools"

From 6a2d4c2887a57f5b4e2174237e0fa650adc1aa61 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 007/111] retroshare: revbump for opencv-4.7.0

---
 srcpkgs/retroshare/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroshare/template b/srcpkgs/retroshare/template
index bb17569277a7f3..49e2c1cbe8a531 100644
--- a/srcpkgs/retroshare/template
+++ b/srcpkgs/retroshare/template
@@ -1,7 +1,7 @@
 # Template file for 'retroshare'
 pkgname=retroshare
 version=0.6.6
-revision=3
+revision=4
 build_style=qmake
 #XXX broadcast feature requires an ancient udp-discovery-cpp which either needs
 # to be fetched+patched (FTBFS) here or packaged :/

From 0660c4c68d9b04befefd80a43c7a44271de4d386 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 008/111] waifu2x-converter-cpp: revbump for opencv-4.7.0

---
 srcpkgs/waifu2x-converter-cpp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waifu2x-converter-cpp/template b/srcpkgs/waifu2x-converter-cpp/template
index 361b8a23b94977..c5ac17eb54ea4c 100644
--- a/srcpkgs/waifu2x-converter-cpp/template
+++ b/srcpkgs/waifu2x-converter-cpp/template
@@ -1,7 +1,7 @@
 # Template file for 'waifu2x-converter-cpp'
 pkgname=waifu2x-converter-cpp
 version=5.2.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DINSTALL_MODELS=ON"
 hostmakedepends="pkg-config"

From ca664e4f809f2e0a2a8121d2555b6d0f11296048 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:38 -0400
Subject: [PATCH 009/111] vlc: revbump for ffmpeg4

---
 srcpkgs/vlc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vlc/template b/srcpkgs/vlc/template
index 559b1c4fff339f..cfa11e6c26f28c 100644
--- a/srcpkgs/vlc/template
+++ b/srcpkgs/vlc/template
@@ -25,7 +25,7 @@ lib32disabled=yes
 hostmakedepends="automake libtool pkg-config flex gettext libgcrypt-devel
  live555-devel gettext-devel $(vopt_if lua lua52) $(vopt_if chromecast protobuf)"
 makedepends="
- avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg-devel freefont-ttf
+ avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg4-devel freefont-ttf
  gnutls-devel jack-devel liba52-devel libass-devel libbluray-devel
  libcdio-devel libdca-devel libdvbpsi-devel libdvdnav-devel libmad-devel
  libmatroska-devel libmodplug-devel libmpcdec-devel libmpeg2-devel

From cc5402d484822afa52d978eb1177121c63b7eaa6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:55 -0400
Subject: [PATCH 010/111] osg: revbump for ffmpeg4

---
 srcpkgs/osg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/osg/template b/srcpkgs/osg/template
index 8ef0efc599a1b1..a131ceaf7a867b 100644
--- a/srcpkgs/osg/template
+++ b/srcpkgs/osg/template
@@ -8,7 +8,7 @@ build_helper="qemu"
 configure_args="-DLIB_POSTFIX="
 hostmakedepends="pkg-config xrandr"
 makedepends="MesaLib-devel gtkglext-devel libcurl-devel giflib-devel librsvg-devel
- jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg-devel xine-lib-devel
+ jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg4-devel xine-lib-devel
  SDL2-devel gst-plugins-base1-devel
  $(vopt_if openexr libopenexr-devel)
  $(vopt_if poppler poppler-glib-devel)

From 59d1a471e3cb5d2aa6d0c9219b7544b7673561a7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:13 -0400
Subject: [PATCH 011/111] xine-lib: revbump for ffmpeg4

---
 srcpkgs/xine-lib/template | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/xine-lib/template b/srcpkgs/xine-lib/template
index 3be4d08eac77a3..ed6194c17d11e8 100644
--- a/srcpkgs/xine-lib/template
+++ b/srcpkgs/xine-lib/template
@@ -1,14 +1,14 @@
 # Template file for 'xine-lib'
 pkgname=xine-lib
-version=1.2.12
-revision=3
+version=1.2.13
+revision=1
 build_style=gnu-configure
 configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
  --disable-oss"
 hostmakedepends="automake gettext-devel libtool pkg-config perl"
 makedepends="
  zlib-devel alsa-lib-devel libxcb-devel libSM-devel libXext-devel libXv-devel
- libXvMC-devel liba52-devel libmad-devel ffmpeg-devel pulseaudio-devel
+ libXvMC-devel liba52-devel libmad-devel ffmpeg4-devel pulseaudio-devel
  jack-devel samba-devel libflac-devel libmodplug-devel libmpcdec-devel
  speex-devel libtheora-devel libvorbis-devel libdca-devel faad2-devel
  libcdio-devel libbluray-devel aalib-devel libcaca-devel libXinerama-devel
@@ -19,7 +19,7 @@ license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="http://www.xine-project.org"
 changelog="https://sourceforge.net/projects/xine/files/xine-lib/${version}/README.txt/view"
 distfiles="${SOURCEFORGE_SITE}/xine/${pkgname}-${version}.tar.xz"
-checksum=d606270468e1540c2a89c0d7f5fdf11e17ecc0c2698cc0bcb1065ff26abee098
+checksum=5f10d6d718a4a51c17ed1b32b031d4f9b80b061e8276535b2be31e5ac4b75e6f
 
 case "$XBPS_TARGET_MACHINE" in
 	i686-musl)

From 17fc99f16e678c414f8dd782523d667c0cc4dec1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 012/111] attract: revbump for ffmpeg6

---
 srcpkgs/attract/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/attract/template b/srcpkgs/attract/template
index e769fb15456217..776cbe4ebd2c93 100644
--- a/srcpkgs/attract/template
+++ b/srcpkgs/attract/template
@@ -1,7 +1,7 @@
 # Template file for 'attract'
 pkgname=attract
 version=2.7.0
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="VERBOSE=1"
 make_use_env=yes

From 21f61a7150c98d89130b3ec4eba65312c765e802 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 013/111] aubio: revbump for ffmpeg6

---
 srcpkgs/aubio/patches/ffmpeg5.patch | 25 +++++++++++++++++++++++++
 srcpkgs/aubio/template              |  2 +-
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/aubio/patches/ffmpeg5.patch

diff --git a/srcpkgs/aubio/patches/ffmpeg5.patch b/srcpkgs/aubio/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..aace41a6e6d9a4
--- /dev/null
+++ b/srcpkgs/aubio/patches/ffmpeg5.patch
@@ -0,0 +1,25 @@
+From 8a05420e5dd8c7b8b2447f82dc919765876511b3 Mon Sep 17 00:00:00 2001
+From: Paul Brossier <piem@piem.org>
+Date: Tue, 25 Jan 2022 18:30:27 +0100
+Subject: [PATCH] [source_avcodec] define FF_API_LAVF_AVCTX for libavcodec >
+ 59, thx @berolinux (closes gh-353)
+
+---
+ src/io/source_avcodec.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/io/source_avcodec.c b/src/io/source_avcodec.c
+index e0ae93b5..1421bd9a 100644
+--- a/src/io/source_avcodec.c
++++ b/src/io/source_avcodec.c
+@@ -68,6 +68,10 @@
+ #define AUBIO_AVCODEC_MAX_BUFFER_SIZE AV_INPUT_BUFFER_MIN_SIZE
+ #endif
+ 
++#if LIBAVCODEC_VERSION_MAJOR >= 59
++#define FF_API_LAVF_AVCTX 1
++#endif
++
+ struct _aubio_source_avcodec_t {
+   uint_t hop_size;
+   uint_t samplerate;
diff --git a/srcpkgs/aubio/template b/srcpkgs/aubio/template
index ad1c4b25699178..7d875cc02541a7 100644
--- a/srcpkgs/aubio/template
+++ b/srcpkgs/aubio/template
@@ -1,7 +1,7 @@
 # Template file for 'aubio'
 pkgname=aubio
 version=0.4.9
-revision=1
+revision=2
 build_style=waf3
 # XXX lash, pure and swig support.
 hostmakedepends="pkg-config txt2man"

From e0cd86af9f4c486f5985d969a43e5bad451add22 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 014/111] audacious-plugins: revbump for ffmpeg6

---
 .../audacious-plugins/patches/ffmpeg5.patch   | 43 +++++++++++++++++++
 srcpkgs/audacious-plugins/template            |  2 +-
 2 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/audacious-plugins/patches/ffmpeg5.patch

diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg5.patch b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..4e5e34099d71c4
--- /dev/null
+++ b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
@@ -0,0 +1,43 @@
+commit 298aa371c56c2f52c25a33d9bdec4918b11cebdc
+Author: tibequadorian <tibequadorian@posteo.de>
+Date:   Sat Mar 19 18:40:12 2022 +0100
+
+    audacious-plugins: rebuild against ffmpeg-5.0
+
+diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+new file mode 100644
+index 0000000000..617c11215b
+--- /dev/null
++++ b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+@@ -0,0 +1,31 @@
++From f60beb400eeb1e4778bbfd738bc4a4ccef3de539 Mon Sep 17 00:00:00 2001
++From: John Lindgren <john@jlindgren.net>
++Date: Sat, 5 Mar 2022 12:05:34 -0500
++Subject: [PATCH] Fix build with FFmpeg 5.0
++
++---
++ src/ffaudio/ffaudio-core.cc | 4 ++--
++ 1 file changed, 2 insertions(+), 2 deletions(-)
++
++diff --git a/src/ffaudio/ffaudio-core.cc b/src/ffaudio/ffaudio-core.cc
++index 16dc63e3a..a2b95fd6c 100644
++--- a/src/ffaudio/ffaudio-core.cc
+++++ b/src/ffaudio/ffaudio-core.cc
++@@ -274,7 +274,7 @@ static AVInputFormat * get_format_by_content (const char * name, VFSFile & file)
++         AVProbeData d = {name, buf, filled};
++         score = target;
++ 
++-        f = av_probe_input_format2 (& d, true, & score);
+++        f = (AVInputFormat *) av_probe_input_format2 (& d, true, & score);
++         if (f)
++             break;
++ 
++@@ -347,7 +347,7 @@ static bool find_codec (AVFormatContext * c, CodecInfo * cinfo)
++ #endif
++         if (stream && stream->codecpar && stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
++         {
++-            AVCodec * codec = avcodec_find_decoder (stream->codecpar->codec_id);
+++            AVCodec * codec = (AVCodec *) avcodec_find_decoder (stream->codecpar->codec_id);
++ 
++             if (codec)
++             {
diff --git a/srcpkgs/audacious-plugins/template b/srcpkgs/audacious-plugins/template
index 05e53a9adf78ff..4b1968e03de781 100644
--- a/srcpkgs/audacious-plugins/template
+++ b/srcpkgs/audacious-plugins/template
@@ -2,7 +2,7 @@
 #Keep in sync with audacious!
 pkgname=audacious-plugins
 version=4.3.1
-revision=3
+revision=4
 build_style=meson
 configure_args="$(vopt_bool gtk3 gtk) $(vopt_bool gtk3)
  $(vopt_bool qt) $(vopt_bool qt qt6)"

From b8cf74c5355ceee53add830b90bbb2db0b8bfa4a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 015/111] audacity: revbump for ffmpeg6

---
 srcpkgs/audacity/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/audacity/template b/srcpkgs/audacity/template
index 7b838119ab2611..84b49305edcef1 100644
--- a/srcpkgs/audacity/template
+++ b/srcpkgs/audacity/template
@@ -1,7 +1,7 @@
 # Template file for 'audacity'
 pkgname=audacity
 version=3.4.2
-revision=1
+revision=2
 build_style=cmake
 build_helper="cmake-wxWidgets-gtk3 qemu"
 configure_args="-Daudacity_use_ffmpeg=loaded -Daudacity_lib_preference=system

From f5fe9a8c64bf4b02508d60ad743e020278be48ab Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 016/111] avidemux: revbump for ffmpeg6

---
 srcpkgs/avidemux/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/avidemux/template b/srcpkgs/avidemux/template
index 253a0243e22599..557285982d2b8f 100644
--- a/srcpkgs/avidemux/template
+++ b/srcpkgs/avidemux/template
@@ -1,7 +1,7 @@
 # Template file for 'avidemux'
 pkgname=avidemux
 version=2.8.0
-revision=2
+revision=3
 # Can't be compiled for aarch64, arm* or mips*
 archs="x86_64* i686*"
 hostmakedepends="cmake pkg-config qt5-host-tools qt5-devel tar yasm"

From 38d3173596f7c9a1b080503e3e83643d22b3cea0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 017/111] blender: revbump for ffmpeg6

---
 srcpkgs/blender/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index 1dc61ec9d29d84..e238717ac8c729 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -1,7 +1,7 @@
 # Template file for 'blender'
 pkgname=blender
 version=4.0.2
-revision=1
+revision=2
 archs="x86_64* ppc64*"
 build_style="cmake"
 pycompile_dirs="usr/share/blender/${version%.*}/scripts"
@@ -9,8 +9,8 @@ configure_args="-DWITH_INSTALL_PORTABLE=OFF -DWITH_PYTHON_INSTALL=OFF
  -DWITH_JACK=ON -DWITH_CODEC_FFMPEG=ON -DWITH_CODEC_SNDFILE=ON -DWITH_OPENMP=ON
  -DWITH_FFTW3=ON -DWITH_MOD_OCEANSIM=ON -DWITH_CYCLES_EMBREE=OFF -DWITH_OPENCOLORIO=ON
  -DWITH_IMAGE_OPENEXR=ON -DWITH_IMAGE_OPENJPEG=ON -DWITH_OPENSUBDIV=ON
- -DWITH_OPENCOLLADA=ON -DWITH_SYSTEM_GLEW=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
- -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_LIBDECOR=ON
+ -DWITH_OPENCOLLADA=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
+ -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_WAYLAND_LIBDECOR=ON
  -DWITH_BUILDINFO=OFF -DPYTHON_VERSION=${py3_ver} -DPYTHON_LIBPATH=/usr/lib
  -DPYTHON_LIBRARY=python${py3_ver}${py3_abiver} -DPYTHON_INCLUDE_DIRS=/${py3_inc}
  -DWITH_SYSTEM_LZO=ON -DWITH_SYSTEM_EIGEN3=ON -DWITH_SYSTEM_FREETYPE=ON"

From 9c7eecfb277b8b3d15524fa2c2a79a704f8fd5a6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 018/111] cantata: revbump for ffmpeg6

---
 srcpkgs/cantata/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cantata/template b/srcpkgs/cantata/template
index 4b417d80d5c2da..8a90aaa4c07a2a 100644
--- a/srcpkgs/cantata/template
+++ b/srcpkgs/cantata/template
@@ -1,7 +1,7 @@
 # Template file for 'cantata'
 pkgname=cantata
 version=2.5.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools qt5-tools"
 makedepends="qt5-devel qt5-tools-devel qt5-svg-devel qt5-xmlpatterns-devel

From 65fd4bfeba6a02653f5fa9a395da353e39e21f2c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 019/111] ccextractor: revbump for ffmpeg6

---
 ...5-and-tesseract-5-compatibility-1479.patch | 168 ++++++++++++++++++
 srcpkgs/ccextractor/template                  |   2 +-
 2 files changed, 169 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ccextractor/patches/0001-fix-ffmpeg-5-and-tesseract-5-compatibility-1479.patch

diff --git a/srcpkgs/ccextractor/patches/0001-fix-ffmpeg-5-and-tesseract-5-compatibility-1479.patch b/srcpkgs/ccextractor/patches/0001-fix-ffmpeg-5-and-tesseract-5-compatibility-1479.patch
new file mode 100644
index 00000000000000..bcab4890554b9a
--- /dev/null
+++ b/srcpkgs/ccextractor/patches/0001-fix-ffmpeg-5-and-tesseract-5-compatibility-1479.patch
@@ -0,0 +1,168 @@
+From b1cbfcea9b9c687143bf0d80bc179b563e99d025 Mon Sep 17 00:00:00 2001
+From: Prateek Sunal <prtksunal@gmail.com>
+Date: Thu, 9 Mar 2023 01:44:53 +0530
+Subject: [PATCH] fix: ffmpeg 5 and tesseract 5 compatibility (#1479)
+
+* fix: replace deprecated `codec` property with `codecpar`
+
+* fix: replace deprecated method `avcodec_decode_video2` with `avcodec_receive_frame` and `avcodec_send_packet`
+
+* Update CHANGES.TXT
+
+* fix: remove deprecated `av_register_all` function
+
+* fix: formatting
+
+* fix: add support for tesseract 5
+
+* fix: tesseract v5
+
+* fix: hardsubx codec context error
+
+* fix: lint const warning
+---
+ docs/CHANGES.TXT               |  1 +
+ src/lib_ccx/ffmpeg_intgr.c     |  7 +++---
+ src/lib_ccx/hardsubx.c         | 25 ++++++++++++------
+ src/lib_ccx/hardsubx_decoder.c | 27 ++++++++------------
+ src/lib_ccx/ocr.c              | 46 ++++++++++++----------------------
+ 5 files changed, 47 insertions(+), 59 deletions(-)
+
+diff --git a/src/lib_ccx/ffmpeg_intgr.c b/src/lib_ccx/ffmpeg_intgr.c
+index be988890..e6f21e20 100644
+--- a/src/lib_ccx/ffmpeg_intgr.c
++++ b/src/lib_ccx/ffmpeg_intgr.c
+@@ -66,7 +66,6 @@ void *init_ffmpeg(const char *path)
+ 	struct ffmpeg_ctx *ctx;
+ 	AVCodec *dec = NULL;
+ 	avcodec_register_all();
+-	av_register_all();
+ 
+ 	if (ccx_options.debug_mask & CCX_DMT_VERBOSE)
+ 		av_log_set_level(AV_LOG_INFO);
+@@ -133,7 +132,6 @@ int ff_get_ccframe(void *arg, unsigned char *data, int maxlen)
+ 	struct ffmpeg_ctx *ctx = arg;
+ 	int len = 0;
+ 	int ret = 0;
+-	int got_frame;
+ 	AVPacket packet;
+ 
+ 	ret = av_read_frame(ctx->ifmt, &packet);
+@@ -151,12 +149,13 @@ int ff_get_ccframe(void *arg, unsigned char *data, int maxlen)
+ 		return AVERROR(EAGAIN);
+ 	}
+ 
+-	ret = avcodec_decode_video2(ctx->dec_ctx, ctx->frame, &got_frame, &packet);
++	avcodec_send_packet(ctx->codec_ctx, &ctx->packet);
++	ret = avcodec_receive_frame(ctx->dec_ctx, ctx->frame);
+ 	if (ret < 0)
+ 	{
+ 		av_log(NULL, AV_LOG_ERROR, "unable to decode packet\n");
+ 	}
+-	else if (!got_frame)
++	else if (ret != 0)
+ 	{
+ 		return AVERROR(EAGAIN);
+ 	}
+diff --git a/src/lib_ccx/hardsubx.c b/src/lib_ccx/hardsubx.c
+index 411377f9..fb844c91 100644
+--- a/src/lib_ccx/hardsubx.c
++++ b/src/lib_ccx/hardsubx.c
+@@ -12,9 +12,6 @@
+
+ int hardsubx_process_data(struct lib_hardsubx_ctx *ctx)
+ {
+-	// Get the required media attributes and initialize structures
+-	av_register_all();
+-
+ 	if (avformat_open_input(&ctx->format_ctx, ctx->inputfile[0], NULL, NULL) != 0)
+ 	{
+ 		fatal(EXIT_READ_ERROR, "Error reading input file!\n");
+@@ -32,7 +29,7 @@
+ 	ctx->video_stream_id = -1;
+ 	for (int i = 0; i < ctx->format_ctx->nb_streams; i++)
+ 	{
+-		if (ctx->format_ctx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO)
++		if (ctx->format_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
+ 		{
+ 			ctx->video_stream_id = i;
+ 			break;
+@@ -43,8 +40,21 @@
+ 		fatal(EXIT_READ_ERROR, "Video Stream not found!\n");
+ 	}
+
+-	ctx->codec_ctx = ctx->format_ctx->streams[ctx->video_stream_id]->codec;
+-	ctx->codec = avcodec_find_decoder(ctx->codec_ctx->codec_id);
++	ctx->codec_ctx = avcodec_alloc_context3(NULL);
++	if (!ctx->codec_ctx)
++	{
++		    fatal(EXIT_NOT_ENOUGH_MEMORY, "Could not allocate codec context!\n");
++	}
++
++	// Assign codec parameters to codec context
++	if (avcodec_parameters_to_context(ctx->codec_ctx, ctx->format_ctx->streams[ctx->video_stream_id]->codecpar) < 0)
++	{
++		    fatal(EXIT_READ_ERROR, "Could not initialize codec context!\n");
++	}
++
++	// Find decoder for the codec context
++	ctx->codec = (AVCodec *)avcodec_find_decoder(ctx->codec_ctx->codec_id);
++
+ 	if (ctx->codec == NULL)
+ 	{
+ 		fatal(EXIT_READ_ERROR, "Input codec is not supported!\n");
+diff --git a/src/lib_ccx/hardsubx_decoder.c b/src/lib_ccx/hardsubx_decoder.c
+index bd9b0980..b5dfaec4 100644
+--- a/src/lib_ccx/hardsubx_decoder.c
++++ b/src/lib_ccx/hardsubx_decoder.c
+@@ -371,7 +371,6 @@
+ int hardsubx_process_frames_tickertext(struct lib_hardsubx_ctx *ctx, struct encoder_ctx *enc_ctx)
+ {
+ 	// Search for ticker text at the bottom of the screen, such as in Russia TV1 or stock prices
+-	int got_frame;
+ 	int cur_sec = 0, total_sec, progress;
+ 	int frame_number = 0;
+ 	char *ticker_text = NULL;
+@@ -382,8 +381,8 @@
+ 		{
+ 			frame_number++;
+ 			//Decode the video stream packet
+-			avcodec_decode_video2(ctx->codec_ctx, ctx->frame, &got_frame, &ctx->packet);
+-			if (got_frame && frame_number % 1000 == 0)
++      avcodec_send_packet(ctx->codec_ctx, &ctx->packet);
++      if (avcodec_receive_frame(ctx->codec_ctx, ctx->frame) == 0 && frame_number % 1000 == 0)
+ 			{
+ 				// sws_scale is used to convert the pixel format to RGB24 from all other cases
+ 				sws_scale(
+@@ -434,9 +433,8 @@
+ 			frame_number++;
+
+ 			//Decode the video stream packet
+-			avcodec_decode_video2(ctx->codec_ctx, ctx->frame, &got_frame, &ctx->packet);
+-
+-			if (got_frame && frame_number % 25 == 0)
++			avcodec_send_packet(ctx->codec_ctx, &ctx->packet);
++      if (avcodec_receive_frame(ctx->codec_ctx, ctx->frame) == 0 && frame_number % 25 == 0)
+ 			{
+ 				float diff = (float)convert_pts_to_ms(ctx->packet.pts - prev_packet_pts, ctx->format_ctx->streams[ctx->video_stream_id]->time_base);
+ 				if (fabsf(diff) < 1000 * ctx->min_sub_duration) //If the minimum duration of a subtitle line is exceeded, process packet
+@@ -548,7 +546,6 @@
+ {
+ 	// Do a binary search over the input video for faster processing
+ 	// printf("Duration: %d\n", (int)ctx->format_ctx->duration);
+-	int got_frame;
+ 	int seconds_time = 0;
+ 	for (seconds_time = 0; seconds_time < 20; seconds_time++)
+ 	{
+@@ -568,8 +565,9 @@
+ 			{
+ 				if (ctx->packet.stream_index == ctx->video_stream_id)
+ 				{
+-					avcodec_decode_video2(ctx->codec_ctx, ctx->frame, &got_frame, &ctx->packet);
+-					if (got_frame)
++          avcodec_send_packet(ctx->codec_ctx, &ctx->packet);
++          if (avcodec_receive_frame(ctx->codec_ctx, ctx->frame) == 0)
++
+ 					{
+ 						// printf("%d\n", seek_time);
+ 						if (ctx->packet.pts < seek_time)
diff --git a/srcpkgs/ccextractor/template b/srcpkgs/ccextractor/template
index 84059ffd02398a..a670758bcbe41b 100644
--- a/srcpkgs/ccextractor/template
+++ b/srcpkgs/ccextractor/template
@@ -1,7 +1,7 @@
 # Template file for 'ccextractor'
 pkgname=ccextractor
 version=0.93
-revision=2
+revision=3
 build_wrksrc="linux"
 build_style=gnu-configure
 configure_args="--enable-ocr --enable-hardsubx"

From d48da0da7237e3fc75bffe59973f282525d435da Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 020/111] chromaprint: revbump for ffmpeg6

---
 srcpkgs/chromaprint/patches/ffmpeg5.patch | 569 ++++++++++++++++++++++
 srcpkgs/chromaprint/template              |   2 +-
 2 files changed, 570 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromaprint/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromaprint/patches/ffmpeg5.patch b/srcpkgs/chromaprint/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..a9fd307a23c8a4
--- /dev/null
+++ b/srcpkgs/chromaprint/patches/ffmpeg5.patch
@@ -0,0 +1,569 @@
+From 8ccad6937177b1b92e40ab8f4447ea27bac009a7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= <lalinsky@gmail.com>
+Date: Fri, 4 Nov 2022 21:47:38 +0100
+Subject: [PATCH] Use FFmpeg 5.x (#120)
+
+* Use FFmpeg 5.1.2 for CI builds
+
+* Build on Ubuntu 20.04
+
+* Upgrade code to FFmpeg 5.x APIs
+
+* Only set FFmpeg include dirs if building tools
+
+* No longer needed
+
+* Use ubuntu 20.04
+---
+ .github/workflows/build.yml                   |   6 +-
+ CMakeLists.txt                                |  16 --
+ package/build.sh                              |   4 +-
+ src/audio/ffmpeg_audio_processor.h            |   2 -
+ src/audio/ffmpeg_audio_processor_avresample.h |  72 -------
+ src/audio/ffmpeg_audio_processor_swresample.h |  18 +-
+ src/audio/ffmpeg_audio_reader.h               | 197 +++++++++---------
+ tests/CMakeLists.txt                          |   6 +
+ 8 files changed, 122 insertions(+), 199 deletions(-)
+ delete mode 100644 src/audio/ffmpeg_audio_processor_avresample.h
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index f8d6a32..4da2405 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -84,9 +84,6 @@ find_package(FFmpeg)
+ if(FFMPEG_LIBRARIES)
+ 	cmake_push_check_state(RESET)
+ 	set(CMAKE_REQUIRED_LIBRARIES ${FFMPEG_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -lm)
+-	check_function_exists(av_packet_unref HAVE_AV_PACKET_UNREF)
+-	check_function_exists(av_frame_alloc HAVE_AV_FRAME_ALLOC)
+-	check_function_exists(av_frame_free HAVE_AV_FRAME_FREE)
+ 	cmake_pop_check_state()
+ endif()
+
+@@ -163,14 +160,11 @@ message(STATUS "Using ${FFT_LIB} for FFT calculations")
+ if(NOT AUDIO_PROCESSOR_LIB)
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+ 		set(AUDIO_PROCESSOR_LIB "swresample")
+-	elseif(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(AUDIO_PROCESSOR_LIB "avresample")
+ 	endif()
+ endif()
+
+ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE OFF)
+ 		set(USE_SWRESAMPLE ON)
+ 		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBSWRESAMPLE_LIBRARIES})
+ 		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBSWRESAMPLE_INCLUDE_DIRS})
+@@ -178,16 +172,6 @@ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+ 	endif()
+ 	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+-elseif(AUDIO_PROCESSOR_LIB STREQUAL "avresample")
+-	if(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE ON)
+-		set(USE_SWRESAMPLE OFF)
+-		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBAVRESAMPLE_LIBRARIES})
+-		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBAVRESAMPLE_INCLUDE_DIRS})
+-	else()
+-		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+-	endif()
+-	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+ else()
+ 	message(STATUS "Building without audio conversion support, please install FFmpeg with libswresample")
+ endif()
+diff --git a/package/build.sh b/package/build.sh
+index da631ae..b41d36e 100755
+--- a/package/build.sh
++++ b/package/build.sh
+@@ -7,8 +7,8 @@ set -eux
+
+ BASE_DIR=$(cd $(dirname $0)/.. && pwd)
+
+-FFMPEG_VERSION=4.4.1
+-FFMPEG_BUILD_TAG=v4.4.1-1
++FFMPEG_VERSION=5.1.2
++FFMPEG_BUILD_TAG=v${FFMPEG_VERSION}-1
+
+ TMP_BUILD_DIR=$BASE_DIR/$(mktemp -d build.XXXXXXXX)
+ trap 'rm -rf $TMP_BUILD_DIR' EXIT
+diff --git a/src/audio/ffmpeg_audio_processor.h b/src/audio/ffmpeg_audio_processor.h
+index 7628fc7..39f4f6d 100644
+--- a/src/audio/ffmpeg_audio_processor.h
++++ b/src/audio/ffmpeg_audio_processor.h
+@@ -10,8 +10,6 @@
+
+ #if defined(USE_SWRESAMPLE)
+ #include "audio/ffmpeg_audio_processor_swresample.h"
+-#elif defined(USE_AVRESAMPLE)
+-#include "audio/ffmpeg_audio_processor_avresample.h"
+ #else
+ #error "no audio processing library"
+ #endif
+diff --git a/src/audio/ffmpeg_audio_processor_avresample.h b/src/audio/ffmpeg_audio_processor_avresample.h
+deleted file mode 100644
+index bd85f92..0000000
+--- a/src/audio/ffmpeg_audio_processor_avresample.h
++++ /dev/null
+@@ -1,72 +0,0 @@
+-// Copyright (C) 2016  Lukas Lalinsky
+-// Distributed under the MIT license, see the LICENSE file for details.
+-
+-#ifndef CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-#define CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-
+-extern "C" {
+-#include <libavresample/avresample.h>
+-}
+-
+-namespace chromaprint {
+-
+-class FFmpegAudioProcessor {
+-public:
+-	FFmpegAudioProcessor() {
+-		m_resample_ctx = avresample_alloc_context();
+-	}
+-
+-	~FFmpegAudioProcessor() {
+-		avresample_free(&m_resample_ctx);
+-	}
+-
+-	void SetCompatibleMode() {
+-		av_opt_set_int(m_resample_ctx, "filter_size", 16, 0);
+-		av_opt_set_int(m_resample_ctx, "phase_shift", 8, 0);
+-		av_opt_set_int(m_resample_ctx, "linear_interp", 1, 0);
+-		av_opt_set_double(m_resample_ctx, "cutoff", 0.8, 0);
+-	}
+-
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "in_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_rate", sample_rate, 0);
+-	}
+-
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "out_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_rate, 0);
+-	}
+-
+-	int Init() {
+-		return avresample_open(m_resample_ctx);
+-	}
+-
+-	int Convert(uint8_t **out, int out_count, const uint8_t **in, int in_count) {
+-		return avresample_convert(m_resample_ctx, out, 0, out_count, (uint8_t **) in, 0, in_count);
+-	}
+-
+-	int Flush(uint8_t **out, int out_count) {
+-		return avresample_read(m_resample_ctx, out, out_count);
+-	}
+-
+-private:
+-	AVAudioResampleContext *m_resample_ctx = nullptr;
+-};
+-
+-}; // namespace chromaprint
+-
+-#endif
+diff --git a/src/audio/ffmpeg_audio_processor_swresample.h b/src/audio/ffmpeg_audio_processor_swresample.h
+index b86266b..b1d4bea 100644
+--- a/src/audio/ffmpeg_audio_processor_swresample.h
++++ b/src/audio/ffmpeg_audio_processor_swresample.h
+@@ -28,30 +28,28 @@ public:
+ 		av_opt_set_double(m_swr_ctx, "cutoff", 0.8, 0);
+ 	}
+
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "icl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "ich", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetInputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "in_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "isf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "in_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "isr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "in_sample_rate", sample_rate, 0);
+ 	}
+
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "ocl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "och", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetOutputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "out_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "osf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "out_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "osr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "out_sample_rate", sample_rate, 0);
+ 	}
+
+ 	int Init() {
+diff --git a/src/audio/ffmpeg_audio_reader.h b/src/audio/ffmpeg_audio_reader.h
+index 5550164..1c6b346 100644
+--- a/src/audio/ffmpeg_audio_reader.h
++++ b/src/audio/ffmpeg_audio_reader.h
+@@ -62,7 +62,7 @@ public:
+ 	bool Read(const int16_t **data, size_t *size);
+
+ 	bool IsOpen() const { return m_opened; }
+-	bool IsFinished() const { return m_finished && !m_got_frame; }
++	bool IsFinished() const { return !m_has_more_packets && !m_has_more_frames; }
+
+ 	std::string GetError() const { return m_error; }
+ 	int GetErrorCode() const { return m_error_code; }
+@@ -74,20 +74,19 @@ private:
+ 	uint8_t *m_convert_buffer[1] = { nullptr };
+ 	int m_convert_buffer_nb_samples = 0;
+
+-	AVInputFormat *m_input_fmt = nullptr;
++	const AVInputFormat *m_input_fmt = nullptr;
+ 	AVDictionary *m_input_opts = nullptr;
+
+ 	AVFormatContext *m_format_ctx = nullptr;
+ 	AVCodecContext *m_codec_ctx = nullptr;
+-	AVFrame *m_frame = nullptr;
+ 	int m_stream_index = -1;
+ 	std::string m_error;
+ 	int m_error_code = 0;
+-	bool m_finished = false;
+ 	bool m_opened = false;
+-	int m_got_frame = 0;
+-	AVPacket m_packet;
+-	AVPacket m_packet0;
++	bool m_has_more_packets = true;
++	bool m_has_more_frames = true;
++	AVPacket *m_packet = nullptr;
++	AVFrame *m_frame = nullptr;
+
+ 	int m_output_sample_rate = 0;
+ 	int m_output_channels = 0;
+@@ -98,19 +97,12 @@ private:
+
+ inline FFmpegAudioReader::FFmpegAudioReader() {
+ 	av_log_set_level(AV_LOG_QUIET);
+-
+-	av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
+ }
+
+ inline FFmpegAudioReader::~FFmpegAudioReader() {
+ 	Close();
+ 	av_dict_free(&m_input_opts);
+ 	av_freep(&m_convert_buffer[0]);
+-	av_packet_unref(&m_packet0);
+ }
+
+ inline bool FFmpegAudioReader::SetInputFormat(const char *name) {
+@@ -135,11 +127,10 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ 	Close();
+
+-    av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
++	m_packet = av_packet_alloc();
++	if (!m_packet) {
++		return false;
++	}
+
+ 	ret = avformat_open_input(&m_format_ctx, file_name.c_str(), m_input_fmt, &m_input_opts);
+ 	if (ret < 0) {
+@@ -153,26 +144,31 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		return false;
+ 	}
+
+-	AVCodec *codec;
++	const AVCodec *codec;
+ 	ret = av_find_best_stream(m_format_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &codec, 0);
+ 	if (ret < 0) {
+ 		SetError("Could not find any audio stream in the file", ret);
+ 		return false;
+ 	}
+ 	m_stream_index = ret;
++	auto stream = m_format_ctx->streams[m_stream_index];
+
+-	m_codec_ctx = m_format_ctx->streams[m_stream_index]->codec;
++	m_codec_ctx = avcodec_alloc_context3(codec);
+ 	m_codec_ctx->request_sample_fmt = AV_SAMPLE_FMT_S16;
+
++	ret = avcodec_parameters_to_context(m_codec_ctx, stream->codecpar);
++	if (ret < 0) {
++		SetError("Could not copy the stream parameters", ret);
++		return false;
++	}
++
+ 	ret = avcodec_open2(m_codec_ctx, codec, nullptr);
+ 	if (ret < 0) {
+ 		SetError("Could not open the codec", ret);
+ 		return false;
+ 	}
+
+-	if (!m_codec_ctx->channel_layout) {
+-		m_codec_ctx->channel_layout = av_get_default_channel_layout(m_codec_ctx->channels);
+-	}
++	av_dump_format(m_format_ctx, 0, "foo", 0);
+
+ 	m_frame = av_frame_alloc();
+ 	if (!m_frame) {
+@@ -183,19 +179,23 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		m_output_sample_rate = m_codec_ctx->sample_rate;
+ 	}
+
+-	if (!m_output_channels) {
+-		m_output_channels = m_codec_ctx->channels;
++	AVChannelLayout output_channel_layout;
++	if (m_output_channels) {
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
++	} else {
++		m_output_channels = m_codec_ctx->ch_layout.nb_channels;
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
+ 	}
+
+-	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
++	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->ch_layout.nb_channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
+ 		m_converter.reset(new FFmpegAudioProcessor());
+ 		m_converter->SetCompatibleMode();
+ 		m_converter->SetInputSampleFormat(m_codec_ctx->sample_fmt);
+ 		m_converter->SetInputSampleRate(m_codec_ctx->sample_rate);
+-		m_converter->SetInputChannelLayout(m_codec_ctx->channel_layout);
++		m_converter->SetInputChannelLayout(&(m_codec_ctx->ch_layout));
+ 		m_converter->SetOutputSampleFormat(AV_SAMPLE_FMT_S16);
+ 		m_converter->SetOutputSampleRate(m_output_sample_rate);
+-		m_converter->SetOutputChannelLayout(av_get_default_channel_layout(m_output_channels));
++		m_converter->SetOutputChannelLayout(&output_channel_layout);
+ 		auto ret = m_converter->Init();
+ 		if (ret != 0) {
+ 			SetError("Could not create an audio converter instance", ret);
+@@ -203,10 +203,11 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		}
+ 	}
+
++	av_channel_layout_uninit(&output_channel_layout);
++
+ 	m_opened = true;
+-	m_finished = false;
+-	m_got_frame = 0;
+-	m_nb_packets = 0;
++	m_has_more_packets = true;
++	m_has_more_frames = true;
+ 	m_decode_error = 0;
+
+ 	return true;
+@@ -214,6 +215,7 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ inline void FFmpegAudioReader::Close() {
+ 	av_frame_free(&m_frame);
++	av_packet_free(&m_packet);
+
+ 	m_stream_index = -1;
+
+@@ -252,91 +254,98 @@ inline bool FFmpegAudioReader::Read(const int16_t **data, size_t *size) {
+ 		return false;
+ 	}
+
++	*data = nullptr;
++	*size = 0;
++
+ 	int ret;
++	bool needs_packet = false;
+ 	while (true) {
+-		while (m_packet.size <= 0) {
+-			av_packet_unref(&m_packet0);
+-			av_init_packet(&m_packet);
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			ret = av_read_frame(m_format_ctx, &m_packet);
++		while (needs_packet && m_packet->size == 0) {
++			ret = av_read_frame(m_format_ctx, m_packet);
+ 			if (ret < 0) {
+ 				if (ret == AVERROR_EOF) {
+-					m_finished = true;
++					needs_packet = false;
++					m_has_more_packets = false;
+ 					break;
+-				} else {
++				}
++				SetError("Error reading from the audio source", ret);
++				return false;
++			}
++			if (m_packet->stream_index == m_stream_index) {
++				needs_packet = false;
++			} else {
++				av_packet_unref(m_packet);
++			}
++		}
++
++		if (m_packet->size != 0) {
++			ret = avcodec_send_packet(m_codec_ctx, m_packet);
++			if (ret < 0) {
++				if (ret != AVERROR(EAGAIN)) {
+ 					SetError("Error reading from the audio source", ret);
+ 					return false;
+ 				}
+-			}
+-			m_packet0 = m_packet;
+-			if (m_packet.stream_index != m_stream_index) {
+-				m_packet.data = nullptr;
+-				m_packet.size = 0;
+ 			} else {
+-				m_nb_packets++;
++				av_packet_unref(m_packet);
+ 			}
+ 		}
+
+-		ret = avcodec_decode_audio4(m_codec_ctx, m_frame, &m_got_frame, &m_packet);
++		ret = avcodec_receive_frame(m_codec_ctx, m_frame);
+ 		if (ret < 0) {
+-			if (m_decode_error) {
+-				SetError("Error decoding audio frame", m_decode_error);
+-				return false;
++			if (ret == AVERROR_EOF) {
++				m_has_more_frames = false;
++			} else if (ret == AVERROR(EAGAIN)) {
++				if (m_has_more_packets) {
++					needs_packet = true;
++					continue;
++				} else {
++					m_has_more_frames = false;
++				}
+ 			}
+-			m_decode_error = ret;
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			continue;
++			SetError("Error decoding the audio source", ret);
++			return false;
+ 		}
+
+-		break;
+-	}
+-
+-	m_decode_error = 0;
+-
+-	const int decoded = std::min(ret, m_packet.size);
+-	m_packet.data += decoded;
+-	m_packet.size -= decoded;
+-
+-	if (m_got_frame) {
+-		if (m_converter) {
+-			if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
+-				int linsize;
+-				av_freep(&m_convert_buffer[0]);
+-				m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
+-				ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
+-				if (ret < 0) {
+-					SetError("Couldn't allocate audio converter buffer", ret);
++		if (m_frame->nb_samples > 0) {
++			if (m_converter) {
++				if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
++					int linsize;
++					av_freep(&m_convert_buffer[0]);
++					m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
++					ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->ch_layout.nb_channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
++					if (ret < 0) {
++						SetError("Couldn't allocate audio converter buffer", ret);
++						return false;
++					}
++				}
++				auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
++				if (nb_samples < 0) {
++					SetError("Couldn't convert audio", ret);
+ 					return false;
+ 				}
+-			}
+-			auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			}
+-			*data = (const int16_t *) m_convert_buffer[0];
+-			*size = nb_samples;
+-		} else {
+-			*data = (const int16_t *) m_frame->data[0];
+-			*size = m_frame->nb_samples;
+-		}
+-	} else {
+-		if (m_finished && m_converter) {
+-			auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			} else if (nb_samples > 0) {
+-				m_got_frame = 1;
+ 				*data = (const int16_t *) m_convert_buffer[0];
+ 				*size = nb_samples;
++			} else {
++				*data = (const int16_t *) m_frame->data[0];
++				*size = m_frame->nb_samples;
++			}
++		} else {
++			if (m_converter) {
++				if (IsFinished()) {
++					auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
++					if (nb_samples < 0) {
++						SetError("Couldn't convert audio", ret);
++						return false;
++					} else if (nb_samples > 0) {
++						*data = (const int16_t *) m_convert_buffer[0];
++						*size = nb_samples;
++					}
++				}
+ 			}
+ 		}
+-	}
+
+-	return true;
++		return true;
++	}
+ }
+
+ inline void FFmpegAudioReader::SetError(const char *message, int errnum) {
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index a2b517b..123e643 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -38,6 +38,12 @@ set(SRCS
+
+ if(BUILD_TOOLS)
+ 	set(SRCS ${SRCS} ../src/audio/ffmpeg_audio_reader_test.cpp)
++    include_directories(
++        ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}
++        ${AUDIO_PROCESSOR_INCLUDE_DIRS}
++    )
+ 	link_libraries(fpcalc_libs)
+ endif()
+
+-- 
+2.38.1
+
+
diff --git a/srcpkgs/chromaprint/template b/srcpkgs/chromaprint/template
index 7ef7838949f3a3..1f7bbc70a22c80 100644
--- a/srcpkgs/chromaprint/template
+++ b/srcpkgs/chromaprint/template
@@ -1,7 +1,7 @@
 # Template file for 'chromaprint'
 pkgname=chromaprint
 version=1.5.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DBUILD_TOOLS=ON"
 make_check_target="check"

From e672b0b3f7f79d5e8eacc7af2f993bdef47f88e1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 021/111] chromium: revbump for ffmpeg6

---
 srcpkgs/chromium/patches/ffmpeg5.patch | 47 ++++++++++++++++++++++++++
 srcpkgs/chromium/template              |  2 +-
 2 files changed, 48 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..24e2da38e34ca2
--- /dev/null
+++ b/srcpkgs/chromium/patches/ffmpeg5.patch
@@ -0,0 +1,47 @@
+--- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
++++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
+@@ -92,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+-  if (stream->start_time != kNoFFmpegTimestamp)
++  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -1597,7 +1585,7 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+@@ -1618,7 +1606,7 @@
+     if (stream->type() != DemuxerStream::VIDEO)
+       continue;
+ 
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+ 
+     if (!stream->IsEnabled())
diff --git a/srcpkgs/chromium/template b/srcpkgs/chromium/template
index 22947e83cb52c3..e8e5b92b5c8d5b 100644
--- a/srcpkgs/chromium/template
+++ b/srcpkgs/chromium/template
@@ -2,7 +2,7 @@
 pkgname=chromium
 # See https://chromiumdash.appspot.com/releases?platform=Linux for the latest version
 version=121.0.6167.160
-revision=1
+revision=2
 archs="i686* x86_64* aarch64* armv7l*"
 hostmakedepends="
  $(vopt_if clang "clang17 lld17 llvm17 compiler-rt")

From ecde8fa9fd972de02e07578354f2df19716da48e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 022/111] cmus: revbump for ffmpeg6

---
 srcpkgs/chromium/patches/ffmpeg5.patch | 47 --------------------------
 srcpkgs/cmus/patches/ffmpeg6.patch     | 12 +++++++
 srcpkgs/cmus/template                  |  2 +-
 3 files changed, 13 insertions(+), 48 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch
 create mode 100644 srcpkgs/cmus/patches/ffmpeg6.patch

diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
deleted file mode 100644
index 24e2da38e34ca2..00000000000000
--- a/srcpkgs/chromium/patches/ffmpeg5.patch
+++ /dev/null
@@ -1,47 +0,0 @@
---- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
-+++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
-@@ -92,24 +92,12 @@
- 
- static base::TimeDelta ExtractStartTime(AVStream* stream) {
-   // The default start time is zero.
--  base::TimeDelta start_time;
-+  base::TimeDelta start_time = kNoTimestamp;
- 
-   // First try to use  the |start_time| value as is.
--  if (stream->start_time != kNoFFmpegTimestamp)
-+  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
-     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
- 
--  // Next try to use the first DTS value, for codecs where we know PTS == DTS
--  // (excludes all H26x codecs). The start time must be returned in PTS.
--  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
--      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
--      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
--      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
--    const base::TimeDelta first_pts =
--        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
--    if (first_pts < start_time)
--      start_time = first_pts;
--  }
--
-   return start_time;
- }
- 
-@@ -1597,7 +1585,7 @@
-   for (const auto& stream : streams_) {
-     if (!stream || stream->IsEnabled() != enabled)
-       continue;
--    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
-+    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
-       continue;
-     if (!lowest_start_time_stream ||
-         stream->start_time() < lowest_start_time_stream->start_time()) {
-@@ -1618,7 +1606,7 @@
-     if (stream->type() != DemuxerStream::VIDEO)
-       continue;
- 
--    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
-+    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
-       continue;
- 
-     if (!stream->IsEnabled())
diff --git a/srcpkgs/cmus/patches/ffmpeg6.patch b/srcpkgs/cmus/patches/ffmpeg6.patch
new file mode 100644
index 00000000000000..ffa95ab811101b
--- /dev/null
+++ b/srcpkgs/cmus/patches/ffmpeg6.patch
@@ -0,0 +1,12 @@
+--- a/ip/ffmpeg.c
++++ b/ip/ffmpeg.c
+@@ -202,9 +202,6 @@ static int ffmpeg_open(struct input_plugin_data *ip_data)
+ 			break;
+ 		}
+ 
+-		if (codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+-			cc->flags |= AV_CODEC_FLAG_TRUNCATED;
+-
+ 		if (avcodec_open2(cc, codec, NULL) < 0) {
+ 			d_print("could not open codec: %d, %s\n", cc->codec_id, avcodec_get_name(cc->codec_id));
+ 			err = -IP_ERROR_UNSUPPORTED_FILE_TYPE;
diff --git a/srcpkgs/cmus/template b/srcpkgs/cmus/template
index 0d1436744f1b2c..a6e4b4fa86cb83 100644
--- a/srcpkgs/cmus/template
+++ b/srcpkgs/cmus/template
@@ -1,7 +1,7 @@
 # Template file for 'cmus'
 pkgname=cmus
 version=2.10.0
-revision=3
+revision=4
 build_style=configure
 configure_args="prefix=/usr LD=$CC"
 hostmakedepends="pkg-config"

From a37497f1f263275ef5bc56e0a5aae4c2596aefaa Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 023/111] cyanrip: revbump for ffmpeg6

---
 srcpkgs/cyanrip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cyanrip/template b/srcpkgs/cyanrip/template
index 9796e3461601a7..5db30e020d17ee 100644
--- a/srcpkgs/cyanrip/template
+++ b/srcpkgs/cyanrip/template
@@ -1,7 +1,7 @@
 # Template file for 'cyanrip'
 pkgname=cyanrip
 version=0.9.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config"
 makedepends="ffmpeg-devel libcdio-devel libcdio-paranoia-devel libcurl-devel libmusicbrainz5-devel"

From 55066c2a64092ddf79e8ed7c57ac521523673667 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 024/111] deadbeef: revbump for ffmpeg4

---
 srcpkgs/deadbeef/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/deadbeef/template b/srcpkgs/deadbeef/template
index f5f4bf24b8cb6d..7b47e615cd48ef 100644
--- a/srcpkgs/deadbeef/template
+++ b/srcpkgs/deadbeef/template
@@ -1,14 +1,14 @@
 # Template file for 'deadbeef'
 pkgname=deadbeef
 version=1.8.8
-revision=3
+revision=4
 create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-oss --disable-lfm --disable-notify --disable-gtk2"
 hostmakedepends="automake libtool gettext gettext-devel intltool pkg-config
  yasm clang glib-devel"
 makedepends="
- alsa-lib-devel dbus-devel faad2-devel ffmpeg-devel gtk+3-devel imlib2-devel
+ alsa-lib-devel dbus-devel faad2-devel ffmpeg4-devel gtk+3-devel imlib2-devel
  jansson-devel libcddb-devel libcdio-devel libcurl-devel libflac-devel
  libmad-devel libpng-devel libsamplerate-devel libsndfile-devel libvorbis-devel
  libzip-devel mpg123-devel opusfile-devel pulseaudio-devel wavpack-devel"

From 30ca00daed24fec9bde019781db457d95bc9e665 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 025/111] droidcam-obs-plugin: revbump for ffmpeg6

---
 srcpkgs/droidcam-obs-plugin/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam-obs-plugin/template b/srcpkgs/droidcam-obs-plugin/template
index fc9c9bf6b9d54c..fb0480754df4de 100644
--- a/srcpkgs/droidcam-obs-plugin/template
+++ b/srcpkgs/droidcam-obs-plugin/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam-obs-plugin'
 pkgname=droidcam-obs-plugin
 version=2.0.1
-revision=1
+revision=2
 build_style=gnu-makefile
 make_use_env=yes
 make_build_args="ALLOW_STATIC=no"

From c97757c39aeb4ccb305de500be707f2e3f459104 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 026/111] droidcam: revbump for ffmpeg6

---
 srcpkgs/droidcam/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam/template b/srcpkgs/droidcam/template
index 1c3f1b8b1fc676..32a9220b79a4d1 100644
--- a/srcpkgs/droidcam/template
+++ b/srcpkgs/droidcam/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam'
 pkgname=droidcam
 version=1.8.2
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="USBMUXD=-lusbmuxd-2.0 JPEG=-lturbojpeg"
 hostmakedepends="pkg-config"

From ddcd80bd44dda5237f4c59b80e3badfcc489abae Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 027/111] ffmpegthumbnailer: revbump for ffmpeg6

---
 .../ffmpegthumbnailer/patches/ffmpeg6.patch   | 202 ++++++++++++++++++
 srcpkgs/ffmpegthumbnailer/template            |   6 +-
 2 files changed, 205 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch

diff --git a/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
new file mode 100644
index 00000000000000..363ff35a28419d
--- /dev/null
+++ b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
@@ -0,0 +1,202 @@
+--- a/libffmpegthumbnailer/moviedecoder.cpp	2017-11-21 14:06:57.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.cpp	2023-05-05 13:14:47.946560668 -0400
+@@ -41,11 +41,6 @@
+ namespace ffmpegthumbnailer
+ {
+ 
+-struct SilenceLogLevel
+-{
+-    SilenceLogLevel() { av_log_set_level(AV_LOG_QUIET); }
+-};
+-
+ MovieDecoder::MovieDecoder(AVFormatContext* pavContext)
+ : m_VideoStream(-1)
+ , m_pFormatContext(pavContext)
+@@ -70,8 +65,6 @@
+ 
+ void MovieDecoder::initialize(const string& filename, bool preferEmbeddedMetadata)
+ {
+-    av_register_all();
+-    avcodec_register_all();
+     avformat_network_init();
+ 
+     string inputFile = filename == "-" ? "pipe:" : filename;
+@@ -97,8 +90,7 @@
+ {
+     if (m_pVideoCodecContext)
+     {
+-        avcodec_close(m_pVideoCodecContext);
+-        m_pVideoCodecContext = nullptr;
++        avcodec_free_context(&m_pVideoCodecContext);
+     }
+ 
+     if ((!m_FormatContextWasGiven) && m_pFormatContext)
+@@ -152,10 +144,10 @@
+     for (unsigned int i = 0; i < m_pFormatContext->nb_streams; ++i)
+     {
+         AVStream *stream = m_pFormatContext->streams[i];
+-        auto ctx = m_pFormatContext->streams[i]->codec;
+-        if (ctx->codec_type == AVMEDIA_TYPE_VIDEO)
++        auto par = m_pFormatContext->streams[i]->codecpar;
++        if (par->codec_type == AVMEDIA_TYPE_VIDEO)
+         {
+-            if (!preferEmbeddedMetadata || !isStillImageCodec(ctx->codec_id))
++            if (!preferEmbeddedMetadata || !isStillImageCodec(par->codec_id))
+             {
+                 videoStreams.push_back(i);
+                 continue;
+@@ -203,8 +195,7 @@
+     }
+ 
+     m_pVideoStream = m_pFormatContext->streams[m_VideoStream];
+-    m_pVideoCodecContext = m_pVideoStream->codec;
+-    m_pVideoCodec = avcodec_find_decoder(m_pVideoCodecContext->codec_id);
++    m_pVideoCodec = avcodec_find_decoder(m_pVideoStream->codecpar->codec_id);
+ 
+     if (m_pVideoCodec == nullptr)
+     {
+@@ -214,6 +205,20 @@
+         throw logic_error("Video Codec not found");
+     }
+ 
++    m_pVideoCodecContext = avcodec_alloc_context3(m_pVideoCodec);
++
++    if (m_pVideoCodecContext == nullptr)
++    {
++        destroy();
++        throw logic_error("Could not allocate video codec context");
++    }
++
++    if (avcodec_parameters_to_context(m_pVideoCodecContext, m_pVideoStream->codecpar) < 0)
++    {
++        destroy();
++        throw logic_error("Could not configure video codec context");
++    }
++
+     m_pVideoCodecContext->workaround_bugs = 1;
+ 
+     if (avcodec_open2(m_pVideoCodecContext, m_pVideoCodec, nullptr) < 0)
+@@ -386,13 +391,6 @@
+ 
+ void MovieDecoder::initializeFilterGraph(const AVRational& timeBase, const std::string& size, bool maintainAspectRatio)
+ {
+-    static const AVPixelFormat pixelFormats[] = { AV_PIX_FMT_RGB24, AV_PIX_FMT_NONE };
+-
+-    auto del = [] (AVBufferSinkParams* p) { av_freep(p); };
+-    std::unique_ptr<AVBufferSinkParams, decltype(del)> buffersinkParams(av_buffersink_params_alloc(), del);
+-
+-    avfilter_register_all();
+-
+     m_pFilterGraph = avfilter_graph_alloc();
+     assert(m_pFilterGraph);
+ 
+@@ -404,10 +402,8 @@
+ 
+     checkRc(avfilter_graph_create_filter(&m_pFilterSource, avfilter_get_by_name("buffer"), "thumb_buffer", ss.str().c_str(), nullptr, m_pFilterGraph),
+             "Failed to create filter source");
+-    buffersinkParams->pixel_fmts = pixelFormats;
+-    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, buffersinkParams.get(), m_pFilterGraph),
++    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, nullptr, m_pFilterGraph),
+             "Failed to create filter sink");
+-    buffersinkParams.release();
+ 
+     AVFilterContext* yadifFilter = nullptr;
+     if (m_pFrame->interlaced_frame != 0)
+@@ -500,15 +496,15 @@
+     }
+ 
+     checkRc(av_seek_frame(m_pFormatContext, -1, timestamp, 0), "Seeking in video failed");
+-    avcodec_flush_buffers(m_pFormatContext->streams[m_VideoStream]->codec);
++    avcodec_flush_buffers(m_pVideoCodecContext);
+ 
+     int keyFrameAttempts = 0;
+-    bool gotFrame = 0;
++    bool gotFrame;
+ 
+     do
+     {
+         int count = 0;
+-        gotFrame = 0;
++        gotFrame = false;
+ 
+         while (!gotFrame && count < 20)
+         {
+@@ -552,17 +548,33 @@
+         return false;
+     }
+ 
+-    av_frame_unref(m_pFrame);
+-
+-    int frameFinished;
++    int rc = avcodec_send_packet(m_pVideoCodecContext, m_pPacket);
++    if(rc == AVERROR(EAGAIN))
++    {
++        rc = 0;
++    }
+ 
+-    int bytesDecoded = avcodec_decode_video2(m_pVideoCodecContext, m_pFrame, &frameFinished, m_pPacket);
+-    if (bytesDecoded < 0)
++    if(rc == AVERROR_EOF)
++    {
++        return false;
++    }
++    else if(rc < 0)
+     {
+-        throw logic_error("Failed to decode video frame: bytesDecoded < 0");
++        throw logic_error("Failed to decode video frame: avcodec_send_packet() < 0");
+     }
+ 
+-    return frameFinished > 0;
++    rc = avcodec_receive_frame(m_pVideoCodecContext, m_pFrame);
++    switch(rc)
++    {
++        case 0:
++            return true;
++
++        case AVERROR(EAGAIN):
++            return false;
++
++        default:
++            throw logic_error("Failed to decode video frame: avcodec_receive_frame() < 0");
++    }
+ }
+ 
+ bool MovieDecoder::getVideoPacket()
+@@ -570,8 +582,6 @@
+     bool framesAvailable = true;
+     bool frameDecoded = false;
+ 
+-    int attempts = 0;
+-
+     if (m_pPacket)
+     {
+         av_packet_unref(m_pPacket);
+@@ -580,6 +590,7 @@
+ 
+     m_pPacket = new AVPacket();
+ 
++
+     while (framesAvailable && !frameDecoded)
+     {
+         framesAvailable = av_read_frame(m_pFormatContext, m_pPacket) >= 0;
+@@ -644,7 +655,7 @@
+ 
+ int32_t MovieDecoder::getStreamRotation()
+ {
+-    int32_t* matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
++    auto matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
+     if (matrix)
+     {
+         auto angle = lround(av_display_rotation_get(matrix));
+
+--- a/libffmpegthumbnailer/moviedecoder.h	2017-11-12 04:23:38.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.h	2023-05-05 13:26:07.095529911 -0400
+@@ -78,7 +78,7 @@
+     int                     m_VideoStream;
+     AVFormatContext*        m_pFormatContext;
+     AVCodecContext*         m_pVideoCodecContext;
+-    AVCodec*                m_pVideoCodec;
++    const AVCodec*          m_pVideoCodec;
+     AVFilterGraph*          m_pFilterGraph;
+     AVFilterContext*        m_pFilterSource;
+     AVFilterContext*        m_pFilterSink;
diff --git a/srcpkgs/ffmpegthumbnailer/template b/srcpkgs/ffmpegthumbnailer/template
index 039eea7622b391..35d546018d12af 100644
--- a/srcpkgs/ffmpegthumbnailer/template
+++ b/srcpkgs/ffmpegthumbnailer/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbnailer'
 pkgname=ffmpegthumbnailer
 version=2.2.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libpng-devel libjpeg-turbo-devel ffmpeg-devel"
@@ -9,8 +9,8 @@ depends="ffmpeg"
 short_desc="Lightweight video thumbnailer"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
-homepage="https://github.com/dirkvdb/${pkgname}"
-distfiles="${homepage}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
+homepage="https://github.com/dirkvdb"
+distfiles="${homepage}/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
 checksum=1cb24059c38223f657b300c84dd80491b7040d4b69471c4fea69be862bc99b5b
 
 post_install() {

From f5bf6d73358f7a79f2e110f0170a83066101a13a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 028/111] ffmpegthumbs: revbump for ffmpeg6

---
 srcpkgs/ffmpegthumbs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ffmpegthumbs/template b/srcpkgs/ffmpegthumbs/template
index 5f0b9414dadaf5..11b88193528f4b 100644
--- a/srcpkgs/ffmpegthumbs/template
+++ b/srcpkgs/ffmpegthumbs/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbs'
 pkgname=ffmpegthumbs
 version=22.12.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules kcoreaddons kconfig-devel
  pkg-config qt5-host-tools qt5-qmake gettext"

From 4886b630a0ffb99965003a2f70c81ed53b827497 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 029/111] ffms2: revbump for ffmpeg6

---
 srcpkgs/ffms2/patches/ffmpeg5.patch | 424 ++++++++++++++++++++++++++++
 srcpkgs/ffms2/template              |   2 +-
 2 files changed, 425 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ffms2/patches/ffmpeg5.patch

diff --git a/srcpkgs/ffms2/patches/ffmpeg5.patch b/srcpkgs/ffms2/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..1479fabcafcb4e
--- /dev/null
+++ b/srcpkgs/ffms2/patches/ffmpeg5.patch
@@ -0,0 +1,424 @@
+From 45673149e9a2f5586855ad472e3059084eaa36b1 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:41:21 +0100
+Subject: [PATCH] Use auto for AVCodec
+
+The geniuses over at FFmpeg decided to constify this API, so old
+versions of the library will return AVCodec *, while new versions
+of the libary will return const AVCodec *, which, in C++, are not
+OK to convert between.
+
+Rather than use some macro hell in ffmscompat.h, we can work around
+this by using auto.
+
+Gross.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 2 +-
+ src/core/indexing.cpp    | 6 +++---
+ src/core/videosource.cpp | 2 +-
+ 3 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index e4ce97c..ac09666 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -469,7 +469,7 @@ void FFMS_AudioSource::OpenFile() {
+ 
+     LAVFOpenFile(SourceFile.c_str(), FormatContext, TrackNumber);
+ 
+-    AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
++    auto *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
+     if (Codec == nullptr)
+         throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+             "Audio codec not found");
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index e547c5a..59fb4e8 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -384,7 +384,7 @@ FFMS_TrackType FFMS_Indexer::GetTrackType(int Track) {
+ }
+ 
+ const char *FFMS_Indexer::GetTrackCodec(int Track) {
+-    AVCodec *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
++    auto *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
+     return codec ? codec->name : nullptr;
+ }
+ 
+@@ -402,7 +402,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             UseDTS);
+ 
+         if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            AVCodec *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (!VideoCodec) {
+                 FormatContext->streams[i]->discard = AVDISCARD_ALL;
+                 IndexMask.erase(i);
+@@ -433,7 +433,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 IndexMask.insert(i);
+             }
+         } else if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+-            AVCodec *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (AudioCodec == nullptr)
+                 throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_UNSUPPORTED,
+                     "Audio codec not found");
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index b889970..8956c22 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -171,7 +171,7 @@ FFMS_VideoSource::FFMS_VideoSource(const char *SourceFile, FFMS_Index &Index, in
+ 
+         LAVFOpenFile(SourceFile, FormatContext, VideoTrack);
+ 
+-        AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
++        auto *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
+         if (Codec == nullptr)
+             throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+                 "Video codec not found");
+-- 
+2.40.0
+
+From 96cbf38ea9381829a1314f432a2c60495dcefaad Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:12:41 +0100
+Subject: [PATCH] all: Update AVPacket API usage
+
+AVPackets must all be on the heap now, since it is no longer
+part of the libav* ABI.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 16 ++++++----
+ src/core/indexing.cpp    | 63 ++++++++++++++++++++++------------------
+ src/core/indexing.h      |  4 +--
+ src/core/utils.cpp       |  6 ----
+ src/core/utils.h         |  1 -
+ src/core/videosource.cpp | 30 ++++++++++---------
+ 6 files changed, 64 insertions(+), 56 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index 37cf9ae..e4ce97c 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -285,10 +285,15 @@ FFMS_AudioSource::AudioBlock *FFMS_AudioSource::CacheBlock(CacheIterator &pos) {
+ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     CurrentFrame = &Frames[PacketNumber];
+ 
+-    AVPacket Packet;
+-    if (!ReadPacket(&Packet))
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++    if (!ReadPacket(Packet)) {
++        av_packet_free(&Packet);
+         throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_UNKNOWN,
+             "ReadPacket unexpectedly failed to read a packet");
++    }
+ 
+     // ReadPacket may have changed the packet number
+     CurrentFrame = &Frames[PacketNumber];
+@@ -297,8 +302,9 @@ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     int NumberOfSamples = 0;
+     AudioBlock *CachedBlock = nullptr;
+     
+-    int Ret = avcodec_send_packet(CodecContext, &Packet);
+-    av_packet_unref(&Packet);
++    int Ret = avcodec_send_packet(CodecContext, Packet);
++    av_packet_unref(Packet);
++    av_packet_free(&Packet);
+ 
+     av_frame_unref(DecodeFrame);
+     Ret = avcodec_receive_frame(CodecContext, DecodeFrame);
+@@ -513,8 +519,6 @@ void FFMS_AudioSource::Seek() {
+ }
+ 
+ bool FFMS_AudioSource::ReadPacket(AVPacket *Packet) {
+-    InitNullPacket(*Packet);
+-
+     while (av_read_frame(FormatContext, Packet) >= 0) {
+         if (Packet->stream_index == TrackNumber) {
+             // Required because not all audio packets, especially in ogg, have a pts. Use the previous valid packet's pts instead.
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index 23fb95b..e547c5a 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -320,7 +320,7 @@ void FFMS_Indexer::CheckAudioProperties(int Track, AVCodecContext *Context) {
+     }
+ }
+ 
+-void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict,
++void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict,
+                                     int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct) {
+     if (VideoContext.Parser) {
+         uint8_t *OB;
+@@ -330,8 +330,8 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+         av_parser_parse2(VideoContext.Parser,
+             VideoContext.CodecContext,
+             &OB, &OBSize,
+-            pkt.data, pkt.size,
+-            pkt.pts, pkt.dts, pkt.pos);
++            pkt->data, pkt->size,
++            pkt->pts, pkt->dts, pkt->pos);
+ 
+         // H.264 (PAFF) and HEVC may have one field per packet, so we need to track
+         // when we have a full or half frame available, and mark one of them as
+@@ -351,15 +351,15 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+ 
+         *RepeatPict = VideoContext.Parser->repeat_pict;
+         *FrameType = VideoContext.Parser->pict_type;
+-        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt.flags & AV_PKT_FLAG_DISCARD));
++        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt->flags & AV_PKT_FLAG_DISCARD));
+     } else {
+-        *Invisible = !!(pkt.flags & AV_PKT_FLAG_DISCARD);
++        *Invisible = !!(pkt->flags & AV_PKT_FLAG_DISCARD);
+     }
+ 
+     if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP8)
+-        ParseVP8(pkt.data[0], Invisible, FrameType);
++        ParseVP8(pkt->data[0], Invisible, FrameType);
+     else if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP9)
+-        ParseVP9(pkt.data[0], Invisible, FrameType);
++        ParseVP9(pkt->data[0], Invisible, FrameType);
+ }
+ 
+ void FFMS_Indexer::Free() {
+@@ -458,32 +458,36 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+         }
+     }
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
+     std::vector<int64_t> LastValidTS(FormatContext->nb_streams, AV_NOPTS_VALUE);
+ 
+     int64_t filesize = avio_size(FormatContext->pb);
+     enum AVPictureStructure LastPicStruct = AV_PICTURE_STRUCTURE_UNKNOWN;
+-    while (av_read_frame(FormatContext, &Packet) >= 0) {
++    while (av_read_frame(FormatContext, Packet) >= 0) {
+         // Update progress
+         // FormatContext->pb can apparently be NULL when opening images.
+         if (IC && FormatContext->pb) {
+-            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate))
++            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate)) {
++                av_packet_free(&Packet);
+                 throw FFMS_Exception(FFMS_ERROR_CANCELLED, FFMS_ERROR_USER,
+                     "Cancelled by user");
++            }
+         }
+-        if (!IndexMask.count(Packet.stream_index)) {
+-            av_packet_unref(&Packet);
++        if (!IndexMask.count(Packet->stream_index)) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+-        int Track = Packet.stream_index;
++        int Track = Packet->stream_index;
+         FFMS_Track &TrackInfo = (*TrackIndices)[Track];
+-        bool KeyFrame = !!(Packet.flags & AV_PKT_FLAG_KEY);
++        bool KeyFrame = !!(Packet->flags & AV_PKT_FLAG_KEY);
+         ReadTS(Packet, LastValidTS[Track], (*TrackIndices)[Track].UseDTS);
+ 
+         if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            int64_t PTS = TrackInfo.UseDTS ? Packet.dts : Packet.pts;
++            int64_t PTS = TrackInfo.UseDTS ? Packet->dts : Packet->pts;
+             if (PTS == AV_NOPTS_VALUE) {
+                 // VPx alt-refs are output as packets which lack timestmps or durations, since
+                 // they are invisible. Currently, the timestamp mangling code in libavformat
+@@ -495,9 +499,11 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 // FFMS2 currently sorts packets by PTS, which will break decoding, otherwise.
+                 bool HasAltRefs = (FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP8 ||
+                                    FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP9);
+-                if (Packet.duration == 0 && !HasAltRefs)
++                if (Packet->duration == 0 && !HasAltRefs) {
++                    av_packet_free(&Packet);
+                     throw FFMS_Exception(FFMS_ERROR_INDEXING, FFMS_ERROR_PARSER,
+                         "Invalid packet pts, dts, and duration");
++                }
+ 
+                 if (TrackInfo.empty())
+                     PTS = 0;
+@@ -513,7 +519,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             ParseVideoPacket(AVContexts[Track], Packet, &RepeatPict, &FrameType, &Invisible, &LastPicStruct);
+ 
+             TrackInfo.AddVideoFrame(PTS, RepeatPict, KeyFrame,
+-                FrameType, Packet.pos, Invisible);
++                FrameType, Packet->pos, Invisible);
+         } else if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+             // For video seeking timestamps are used only if all packets have
+             // timestamps, while for audio they're used if any have timestamps,
+@@ -522,28 +528,29 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 TrackInfo.HasTS = true;
+ 
+             int64_t StartSample = AVContexts[Track].CurrentSample;
+-            uint32_t SampleCount = IndexAudioPacket(Track, &Packet, AVContexts[Track], *TrackIndices);
++            uint32_t SampleCount = IndexAudioPacket(Track, Packet, AVContexts[Track], *TrackIndices);
+             TrackInfo.SampleRate = AVContexts[Track].CodecContext->sample_rate;
+ 
+             TrackInfo.AddAudioFrame(LastValidTS[Track],
+-                StartSample, SampleCount, KeyFrame, Packet.pos, Packet.flags & AV_PKT_FLAG_DISCARD);
++                StartSample, SampleCount, KeyFrame, Packet->pos, Packet->flags & AV_PKT_FLAG_DISCARD);
+         }
+ 
+-        if (!(Packet.flags & AV_PKT_FLAG_DISCARD))
+-            TrackInfo.LastDuration = Packet.duration;
++        if (!(Packet->flags & AV_PKT_FLAG_DISCARD))
++            TrackInfo.LastDuration = Packet->duration;
+ 
+-        av_packet_unref(&Packet);
++        av_packet_unref(Packet);
+     }
++    av_packet_free(&Packet);
+ 
+     TrackIndices->Finalize(AVContexts, FormatContext->iformat->name);
+     return TrackIndices.release();
+ }
+ 
+-void FFMS_Indexer::ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS) {
+-    if (!UseDTS && Packet.pts != AV_NOPTS_VALUE)
+-        TS = Packet.pts;
++void FFMS_Indexer::ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS) {
++    if (!UseDTS && Packet->pts != AV_NOPTS_VALUE)
++        TS = Packet->pts;
+     if (TS == AV_NOPTS_VALUE)
+         UseDTS = true;
+-    if (UseDTS && Packet.dts != AV_NOPTS_VALUE)
+-        TS = Packet.dts;
++    if (UseDTS && Packet->dts != AV_NOPTS_VALUE)
++        TS = Packet->dts;
+ }
+diff --git a/src/core/indexing.h b/src/core/indexing.h
+index 3cfc3c3..5c06868 100644
+--- a/src/core/indexing.h
++++ b/src/core/indexing.h
+@@ -80,10 +80,10 @@ private:
+     int64_t Filesize;
+     uint8_t Digest[20];
+ 
+-    void ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS);
++    void ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS);
+     void CheckAudioProperties(int Track, AVCodecContext *Context);
+     uint32_t IndexAudioPacket(int Track, AVPacket *Packet, SharedAVContext &Context, FFMS_Index &TrackIndices);
+-    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
++    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
+     void Free();
+ public:
+     FFMS_Indexer(const char *Filename);
+diff --git a/src/core/utils.cpp b/src/core/utils.cpp
+index ce67533..8a2e997 100644
+--- a/src/core/utils.cpp
++++ b/src/core/utils.cpp
+@@ -62,12 +62,6 @@ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo) {
+     }
+ }
+ 
+-void InitNullPacket(AVPacket &pkt) {
+-    av_init_packet(&pkt);
+-    pkt.data = nullptr;
+-    pkt.size = 0;
+-}
+-
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames) {
+     AP.SampleFormat = static_cast<FFMS_SampleFormat>(av_get_packed_sample_fmt(CTX->sample_fmt));
+     AP.BitsPerSample = av_get_bytes_per_sample(CTX->sample_fmt) * 8;
+diff --git a/src/core/utils.h b/src/core/utils.h
+index 9819dc7..003ab79 100644
+--- a/src/core/utils.h
++++ b/src/core/utils.h
+@@ -58,7 +58,6 @@ std::unique_ptr<T> make_unique(Args&&... args) {
+ }
+ 
+ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo);
+-void InitNullPacket(AVPacket &pkt);
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames);
+ 
+ void LAVFOpenFile(const char *SourceFile, AVFormatContext *&FormatContext, int Track);
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index 06bd161..b889970 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -673,30 +673,34 @@ void FFMS_VideoSource::DecodeNextFrame(int64_t &AStartTime, int64_t &Pos) {
+     if (HasPendingDelayedFrames())
+         return;
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
+-
+-    while (ReadFrame(&Packet) >= 0) {
+-        if (Packet.stream_index != VideoTrack) {
+-            av_packet_unref(&Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++
++    while (ReadFrame(Packet) >= 0) {
++        if (Packet->stream_index != VideoTrack) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+         if (AStartTime < 0)
+-            AStartTime = Frames.UseDTS ? Packet.dts : Packet.pts;
++            AStartTime = Frames.UseDTS ? Packet->dts : Packet->pts;
+ 
+         if (Pos < 0)
+-            Pos = Packet.pos;
++            Pos = Packet->pos;
+ 
+-        bool FrameFinished = DecodePacket(&Packet);
+-        av_packet_unref(&Packet);
+-        if (FrameFinished)
++        bool FrameFinished = DecodePacket(Packet);
++        av_packet_unref(Packet);
++        if (FrameFinished) {
++            av_packet_free(&Packet);
+             return;
++        }
+     }
+ 
+     // Flush final frames
+-    InitNullPacket(Packet);
+-    DecodePacket(&Packet);
++    DecodePacket(Packet);
++    av_packet_free(&Packet);
+ }
+ 
+ bool FFMS_VideoSource::SeekTo(int n, int SeekOffset) {
+-- 
+2.40.0
+
+From bf9e03e9e08534c024e5a744a6437c4aac160201 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:20:47 +0100
+Subject: [PATCH 2/3] configure: Remove deprecated API use
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ configure.ac | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index b35ef80bc..d19714d0f 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -102,10 +102,10 @@ CFLAGS="$_CFLAGS $FFMPEG_CFLAGS"
+
+ AC_DEFUN([TEST_FFMPEG],
+          [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+-            #include <libavcodec/avcodec.h>
++            #include <libavformat/avformat.h>
+             #include <libswscale/swscale.h>
+             ]],[[
+-                avcodec_register_all();
++                avformat_network_init();
+                 swscale_version();
+             ]])], [eval $1=yes], [eval $1=no])
+         ])
+
diff --git a/srcpkgs/ffms2/template b/srcpkgs/ffms2/template
index 365f64d10cbabf..1641ecf43be5bb 100644
--- a/srcpkgs/ffms2/template
+++ b/srcpkgs/ffms2/template
@@ -1,7 +1,7 @@
 # Template file for 'ffms2'
 pkgname=ffms2
 version=2.40
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-shared --disable-static"
 hostmakedepends="pkg-config autoconf automake libtool"

From 6222043858f146830835aa1756390d16a774c158 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 030/111] freerdp: revbump for ffmpeg6

---
 .../freerdp/patches/ffmpeg6_aa2cb9aa.patch    | 42 +++++++++++++++++++
 srcpkgs/freerdp/template                      |  2 +-
 2 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch

diff --git a/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
new file mode 100644
index 00000000000000..a4324da3a8822b
--- /dev/null
+++ b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
@@ -0,0 +1,42 @@
+From aa2cb9aa5ff5562433598ba168a466e0752bca0e Mon Sep 17 00:00:00 2001
+From: akallabeth <akallabeth@posteo.net>
+Date: Tue, 14 Feb 2023 07:48:54 +0100
+Subject: [PATCH] Fixed #8686: Update h264 to use new FFMPEG API
+
+---
+ channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c | 2 ++
+ libfreerdp/codec/h264_ffmpeg.c            | 2 ++
+ 2 files changed, 4 insertions(+)
+
+diff --git a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+index 339462d865f..beea80b7a1e 100644
+--- a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
++++ b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+@@ -239,8 +239,10 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYP
+ 		}
+ 	}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 	if (mdecoder->codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		mdecoder->codec_context->flags |= AV_CODEC_FLAG_TRUNCATED;
++#endif
+ 
+ 	return TRUE;
+ }
+diff --git a/libfreerdp/codec/h264_ffmpeg.c b/libfreerdp/codec/h264_ffmpeg.c
+index 8a23db2473c..896a333019b 100644
+--- a/libfreerdp/codec/h264_ffmpeg.c
++++ b/libfreerdp/codec/h264_ffmpeg.c
+@@ -615,10 +615,12 @@ static BOOL libavcodec_init(H264_CONTEXT* h264)
+ 			goto EXCEPTION;
+ 		}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 		if (sys->codecDecoder->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		{
+ 			sys->codecDecoderContext->flags |= AV_CODEC_FLAG_TRUNCATED;
+ 		}
++#endif
+ 
+ #ifdef WITH_VAAPI
+ 
diff --git a/srcpkgs/freerdp/template b/srcpkgs/freerdp/template
index 16fddfbe8f5287..bf3a4d2e2b3ae7 100644
--- a/srcpkgs/freerdp/template
+++ b/srcpkgs/freerdp/template
@@ -1,7 +1,7 @@
 # Template file for 'freerdp'
 pkgname=freerdp
 version=2.11.4
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_ALSA=ON -DWITH_CUPS=OFF -DWITH_FFMPEG=ON
  -DWITH_GSTREAMER_0_10=OFF -DWITH_GSTREAMER_1_0=OFF -DWITH_JPEG=ON

From 9b065a15fb34308da1f2ecfe90ad1ae4f75fbf7f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 031/111] gerbera: revbump for ffmpeg6

---
 srcpkgs/gerbera/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gerbera/template b/srcpkgs/gerbera/template
index ae14f35c767c03..2dc0ac0ce03b55 100644
--- a/srcpkgs/gerbera/template
+++ b/srcpkgs/gerbera/template
@@ -1,7 +1,7 @@
 # Template file for 'gerbera'
 pkgname=gerbera
 version=1.12.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_SYSTEMD=0 -DWITH_AVCODEC=1"
 hostmakedepends="pkg-config"

From f9a6dcc8f8d07326cbf9c606dbdf263b1ad76abd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 032/111] goldendict: revbump for ffmpeg6

---
 srcpkgs/goldendict/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/goldendict/template b/srcpkgs/goldendict/template
index f4a05759f693d3..97f44347b03a6a 100644
--- a/srcpkgs/goldendict/template
+++ b/srcpkgs/goldendict/template
@@ -1,7 +1,7 @@
 # Template file for 'goldendict'
 pkgname=goldendict
 version=1.5.0
-revision=1
+revision=2
 build_style=qmake
 configure_args="CONFIG+=zim_support goldendict.pro"
 hostmakedepends="qt5-qmake pkg-config qt5-host-tools"
@@ -10,7 +10,7 @@ makedepends="tiff-devel qt5-devel libvorbis-devel zlib-devel
  qt5-webkit-devel lzo-devel bzip2-devel libao-devel qt5-svg-devel
  libeb-devel qt5-x11extras-devel ffmpeg-devel liblzma-devel
  qt5-multimedia-devel"
-short_desc="A feature-rich dictionary lookup program"
+short_desc="Feature-rich dictionary lookup program"
 maintainer="John <me@johnnynator.dev>"
 license="GPL-3.0-or-later"
 homepage="http://goldendict.org/"

From b9c1abffc7681ebe571b05b7283d425df6d24ac0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 033/111] gst-libav: revbump for ffmpeg6

---
 srcpkgs/gst-libav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index b24be23fc1a6d2..0f9350a251bf67 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.22.9
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"

From 0b83c9042ff779bbc18a34755027c74d13725ae0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Feb 2024 01:52:46 -0500
Subject: [PATCH 034/111] gst-plugins-bad1: revbump for ffmpeg6

---
 srcpkgs/gst-plugins-bad1/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index 10dc49f4c151bc..b4a7f7367e7dff 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-plugins-bad1'
 pkgname=gst-plugins-bad1
 version=1.22.9
-revision=1
+revision=2
 build_helper="gir"
 build_style=meson
 configure_args="-Dpackage-origin=https://voidlinux.org -Ddoc=disabled
@@ -27,7 +27,7 @@ makedepends="alsa-lib-devel celt-devel openssl-devel exempi-devel
  fdk-aac-devel flite-devel fluidsynth-devel liblrdf-devel ladspa-sdk
  lilv-devel lv2 libopenjpeg2-devel sbc-devel spandsp-devel vulkan-loader
  Vulkan-Headers webrtc-audio-processing-devel libzbar-devel ffmpeg-devel
- srt-devel libva-devel
+ srt-devel libva-devel oneVPL-devel
  $(vopt_if gme libgme-devel)"
 depends="gst-plugins-base1>=${version}"
 short_desc="GStreamer plugins from the bad set (v1.x)"

From 8533e31dd11a17d59b4060d2a0323abb43047e20 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 035/111] gst-rtsp-server: revbump for ffmpeg6

---
 srcpkgs/gst-rtsp-server/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index bc2a0dea6ac152..f77026c618eb69 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
 version=1.22.9
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="glib-devel gst-plugins-bad1-devel gobject-introspection

From 5ac52d593f1e7089b11ef35999aa51e9b6ec207d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 036/111] guvcview: update to 2.0.8.

---
 srcpkgs/guvcview/patches/fix-include.patch | 10 ++++++++++
 srcpkgs/guvcview/template                  |  7 +++----
 2 files changed, 13 insertions(+), 4 deletions(-)
 create mode 100644 srcpkgs/guvcview/patches/fix-include.patch

diff --git a/srcpkgs/guvcview/patches/fix-include.patch b/srcpkgs/guvcview/patches/fix-include.patch
new file mode 100644
index 00000000000000..503c2af3b78c1a
--- /dev/null
+++ b/srcpkgs/guvcview/patches/fix-include.patch
@@ -0,0 +1,10 @@
+--- a/guvcview/guvcview.c
++++ b/guvcview/guvcview.c
+@@ -28,6 +28,7 @@
+ #include <sys/stat.h>
+ #include <sys/resource.h>
+ #include <errno.h>
++#include <locale.h>
+ 
+ #include "gview.h"
+ #include "gviewv4l2core.h"
diff --git a/srcpkgs/guvcview/template b/srcpkgs/guvcview/template
index d42fd38fa4ad12..86a7fd619612c8 100644
--- a/srcpkgs/guvcview/template
+++ b/srcpkgs/guvcview/template
@@ -1,8 +1,7 @@
 # Template file for 'guvcview'
 pkgname=guvcview
-version=2.0.7
-revision=2
-create_wrksrc=yes
+version=2.0.8
+revision=1
 build_style=gnu-configure
 configure_args="--disable-static --disable-debian-menu"
 hostmakedepends="pkg-config intltool autoconf automake libtool glib-devel"
@@ -14,7 +13,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="http://guvcview.sourceforge.net/"
 distfiles="${SOURCEFORGE_SITE}/${pkgname}/${pkgname}-src-${version}.tar.bz2"
-checksum=f47d51fbd06e44eeaa1a82f4a153c927527c90d94514197a70b2956028cc8ad4
+checksum=a21f4e448286666cf27bafef5290cc953a0a1796b752e5bbe521266dc1230c81
 
 post_patch() {
 	sed '31a#include <locale.h>' -i  guvcview/guvcview.c

From 8f00573dabfc622e78d9fe9564bd4e8582dc2895 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 037/111] handbrake: update to 1.6.1

---
 .../patches/fix-missing-x265-link-flag.patch    | 11 ++++++-----
 .../handbrake/patches/libhb-vpl-include.patch   | 15 +++++++++++++++
 srcpkgs/handbrake/template                      | 17 ++++++++++-------
 3 files changed, 31 insertions(+), 12 deletions(-)
 create mode 100644 srcpkgs/handbrake/patches/libhb-vpl-include.patch

diff --git a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
index 26db03867a0c83..d6bb2eda627a36 100644
--- a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
+++ b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
@@ -1,14 +1,15 @@
 --- a/gtk/configure.ac
 +++ b/gtk/configure.ac
 @@ -203,7 +203,7 @@
- 
+
  AM_CONDITIONAL([MINGW], [test "x$mingw_flag" = "xyes"])
- 
--HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg"
-+HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -ldl"
+
+-HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc"
++HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc -ldl"
  HB_CPPFLAGS="$HB_CPPFLAGS $HBINC"
- 
+
  PKG_CHECK_MODULES([x264], [x264], sys_x264=yes, sys_x264=no)
+
 --- a/test/module.defs
 +++ b/test/module.defs
 @@ -69,6 +69,9 @@
diff --git a/srcpkgs/handbrake/patches/libhb-vpl-include.patch b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
new file mode 100644
index 00000000000000..298f9f4ab28f2a
--- /dev/null
+++ b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
@@ -0,0 +1,15 @@
+--- a/libhb/module.defs	2023-01-22 11:36:49.000000000 -0500
++++ b/libhb/module.defs	2023-04-03 22:37:52.395467010 -0400
+@@ -46,11 +46,7 @@
+ LIBHB.GCC.I += $(LIBHB.build/) $(CONTRIB.build/)include
+ 
+ ifeq (1,$(FEATURE.qsv))
+-    ifeq ($(HOST.system),freebsd))
+-        LIBHB.GCC.I += $(LOCALBASE)/include/vpl
+-    else
+-        LIBHB.GCC.I += $(CONTRIB.build/)include/vpl
+-    endif
++    LIBHB.GCC.I += /usr/include/vpl
+ endif
+ 
+ ifneq (,$(filter $(HOST.system),freebsd netbsd openbsd))
diff --git a/srcpkgs/handbrake/template b/srcpkgs/handbrake/template
index ca5e4571e49c37..c32cb1bfa31f4b 100644
--- a/srcpkgs/handbrake/template
+++ b/srcpkgs/handbrake/template
@@ -1,10 +1,10 @@
 # Template file for 'handbrake'
 pkgname=handbrake
-version=1.5.1
+version=1.6.1
 revision=1
 build_style=gnu-configure
 configure_args="--force --disable-gtk-update-checks --disable-df-fetch --harden
- $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc)"
+ $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc) $(vopt_enable qsv)"
 make_build_args="-C ${XBPS_TRIPLET}"
 make_install_args="-C ${XBPS_TRIPLET}"
 hostmakedepends="automake cmake gettext-devel glib-devel intltool libtool m4 meson nasm pkg-config python3"
@@ -12,8 +12,11 @@ makedepends="bzip2-devel ffmpeg-devel gst-plugins-base1-devel gtk+3-devel
  jansson-devel lame-devel libass-devel libbluray-devel libdav1d-devel
  libdvdnav-devel libdvdread-devel libgudev-devel libnuma-devel
  libsamplerate-devel libtheora-devel libvorbis-devel libvpx-devel libxml2-devel
- opus-devel speex-devel x264-devel x265-devel zimg-devel
+ opus-devel speex-devel x264-devel x265-devel zimg-devel libsvt-av1-devel
  $(vopt_if fdk_aac fdk-aac-devel)
+ $(vopt_if qsv libva-devel)
+ $(vopt_if qsv libdrm-devel)
+ $(vopt_if qsv onevpl-devel)
  $(vopt_if nvenc nv-codec-headers)"
 depends="desktop-file-utils gst-plugins-good1 hicolor-icon-theme"
 short_desc="Multithreaded video transcoder"
@@ -21,15 +24,15 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-2.0-only"
 homepage="https://handbrake.fr/"
 distfiles="https://github.com/HandBrake/HandBrake/releases/download/${version}/HandBrake-${version}-source.tar.bz2"
-checksum=3999fe06d5309c819799a73a968a8ec3840e7840c2b64af8f5cdb7fd8c9430f0
+checksum=94ccfe03db917a91650000c510f7fd53f844da19f19ad4b4be1b8f6bc31a8d4c
 nocross=yes
 
-build_options="fdk_aac nvenc"
+build_options="fdk_aac nvenc qsv"
 
 case "$XBPS_TARGET_MACHINE" in
 	x86_64*|i686*)
 		CFLAGS="-msse"
-		build_options_default="nvenc"
+		build_options_default="nvenc qsv"
 		;;
 esac
 
@@ -37,7 +40,7 @@ pre_configure() {
 	# use system libraries, don't download them
 	rm -rf contrib/
 	for module in fdk-aac ffmpeg libbluray libdav1d libdvdnav libdvdread nvenc \
-		x265 zimg; do
+		x265 zimg svt-av1 libvpl; do
 	    vsed -i "/MODULES += contrib\/${module}/d" make/include/main.defs
 	done
 }

From e3cb9565c0409bfe7b22cc6ad237b38187efed48 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 038/111] hedgewars: revbump for ffmpeg4

---
 srcpkgs/hedgewars/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/hedgewars/template b/srcpkgs/hedgewars/template
index 94b6db673b0c3a..402ccfaaecbc2d 100644
--- a/srcpkgs/hedgewars/template
+++ b/srcpkgs/hedgewars/template
@@ -1,13 +1,13 @@
 # Template file for 'hedgewars'
 pkgname=hedgewars
 version=1.0.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DNOSERVER=1 -DDATA_INSTALL_DIR=/usr/share/${pkgname}
  -DPHYSFS_SYSTEM=1 -DMINIMAL_FLAGS=1"
 make_cmd=make
 hostmakedepends="lua51 pkg-config qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
+makedepends="ffmpeg4-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
  SDL2_mixer-devel SDL2_net-devel SDL2_ttf-devel"
 depends="libfreeglut"
 short_desc="Funny turn-based artillery game, featuring fighting Hedgehogs!"

From 9b91d30f30a57bf2cd5341f295f13ab13b9316bc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 039/111] idjc: revbump for ffmpeg4

---
 srcpkgs/idjc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/idjc/template b/srcpkgs/idjc/template
index a9cde0665d55b1..f41e1e4fabbae7 100644
--- a/srcpkgs/idjc/template
+++ b/srcpkgs/idjc/template
@@ -1,11 +1,11 @@
 # Template file for 'idjc'
 pkgname=idjc
 version=0.9.1
-revision=5
+revision=6
 build_style=gnu-configure
 hostmakedepends="pkg-config git python3 automake gettext-devel libtool"
 makedepends="libvorbis-devel libogg-devel jack-devel libsamplerate-devel
- libflac-devel libsndfile-devel mpg123-devel ffmpeg-devel speex-devel
+ libflac-devel libsndfile-devel mpg123-devel ffmpeg4-devel speex-devel
  glib-devel pixman-devel lame-devel python3-gobject-devel libshout-idjc-devel
  opus-devel twolame-devel python3-mutagen python3-devel"
 depends="python3-gobject python3-mutagen desktop-file-utils shared-mime-info python3-dbus jack"

From 820affbaf3e8f651ab947d8651cd09bf201de520 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 040/111] kid3: revbump for ffmpeg6

---
 srcpkgs/kid3/patches/ffmpeg5.patch | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 srcpkgs/kid3/patches/ffmpeg5.patch

diff --git a/srcpkgs/kid3/patches/ffmpeg5.patch b/srcpkgs/kid3/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..135fc50e07c9ba
--- /dev/null
+++ b/srcpkgs/kid3/patches/ffmpeg5.patch
@@ -0,0 +1,17 @@
+# https://aur.archlinux.org/cgit/aur.git/diff/ffmpeg5.patch?h=kid3-cli&id=12410a74906612e7efc0ec8fbce739b4a0fef7e7
+diff --git a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+index e156d424..e12b9abd 100644
+--- a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
++++ b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+@@ -232,7 +232,11 @@ private:
+   friend class Format;
+   friend class Converter;
+   AVCodecContext* m_ptr;
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 0, 0)
+   AVCodec* m_impl;
++#else
++  const AVCodec* m_impl;
++#endif
+   AVFrame* m_frame;
+   bool m_opened;
+ };

From aaa809fb251436befe35e32a179a4a4455e80e25 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 041/111] kodi: revbump for ffmpeg4

---
 srcpkgs/kodi/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/kodi/template b/srcpkgs/kodi/template
index d37a5918cd6758..ea78e0aca0fe3e 100644
--- a/srcpkgs/kodi/template
+++ b/srcpkgs/kodi/template
@@ -1,7 +1,7 @@
 # Template file for 'kodi'
 pkgname=kodi
 version=19.4
-revision=9
+revision=10
 _codename="Matrix"
 build_style=cmake
 configure_args="-DWITH_FFMPEG=/usr -DENABLE_LDGOLD=OFF
@@ -54,7 +54,7 @@ makedepends="
  libmad-devel fontconfig-devel libXinerama-devel libsamplerate-devel libmms-devel
  enca-devel boost-devel libcurl-devel libva-devel libvdpau-devel libass-devel
  libbluetooth-devel yajl-devel libplist-devel librtmp-devel tinyxml-devel
- taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg-devel
+ taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg4-devel
  giflib-devel libxslt-devel gnutls-devel libssh-devel libmicrohttpd-devel
  libcec-devel dcadec-devel flatbuffers-devel fmt-devel lcms2-devel
  libfstrcmp-devel rapidjson libcdio-paranoia spdlog libwaylandpp-devel

From 30fe854529f6c329cac4fcbd05df842bc70a3afe Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 042/111] kpipewire: revbump for ffmpeg6

---
 srcpkgs/kpipewire/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kpipewire/template b/srcpkgs/kpipewire/template
index 6214a4451336e7..3555348659dded 100644
--- a/srcpkgs/kpipewire/template
+++ b/srcpkgs/kpipewire/template
@@ -1,7 +1,7 @@
 # Template file for 'kpipewire'
 pkgname=kpipewire
 version=5.27.10
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules plasma-wayland-protocols gettext
  qt5-qmake qt5-host-tools pkg-config wayland-devel kcoreaddons

From 18ae6f1834f5f5045b07fc5965fdd2009908dbee Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 043/111] libextractor: revbump for ffmpeg4

---
 srcpkgs/libextractor/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/libextractor/template b/srcpkgs/libextractor/template
index 044c663a3a0b92..06e63bc3189d5e 100644
--- a/srcpkgs/libextractor/template
+++ b/srcpkgs/libextractor/template
@@ -1,13 +1,13 @@
 # Template file for 'libextractor'
 pkgname=libextractor
 version=1.11
-revision=4
+revision=5
 build_style=gnu-configure
 configure_args="--disable-static"
 hostmakedepends="pkg-config"
 makedepends="zlib-devel bzip2-devel exiv2-devel tiff-devel libpng-devel
  libjpeg-turbo-devel libvorbis-devel libflac-devel giflib-devel libmpeg2-devel
- ffmpeg-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
+ ffmpeg4-devel gtk+3-devel libltdl-devel libarchive-devel file-devel libgsf-devel"
 short_desc="Library used to extract meta data from files"
 maintainer="Martin Riese <grauehaare@gmx.de>"
 license="GPL-3.0-or-later"

From 9d519e1b0e94723aaf178f44cc20c6bea691b99a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 044/111] libopenal: revbump for ffmpeg6

---
 srcpkgs/libopenal/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenal/template b/srcpkgs/libopenal/template
index 88d0f11307d81a..8308fca0393e33 100644
--- a/srcpkgs/libopenal/template
+++ b/srcpkgs/libopenal/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenal'
 pkgname=libopenal
 version=1.23.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DALSOFT_EXAMPLES=OFF"
 hostmakedepends="pkg-config"

From 6c3e08e33e55412c5b7b9d719c579126899d127e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 045/111] loudgain: revbump for ffmpeg6

---
 srcpkgs/loudgain/patches/ffmpeg5.patch | 11 +++++++++++
 srcpkgs/loudgain/template              |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/loudgain/patches/ffmpeg5.patch

diff --git a/srcpkgs/loudgain/patches/ffmpeg5.patch b/srcpkgs/loudgain/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..16d4510ee98faa
--- /dev/null
+++ b/srcpkgs/loudgain/patches/ffmpeg5.patch
@@ -0,0 +1,11 @@
+--- a/src/scan.c	2019-09-06 11:31:19.000000000 -0400
++++ b/src/scan.c	2023-03-23 11:15:40.867968521 -0400
+@@ -69,8 +69,6 @@
+ 	 * It is now useless
+ 	 * https://github.com/FFmpeg/FFmpeg/blob/70d25268c21cbee5f08304da95be1f647c630c15/doc/APIchanges#L86
+ 	 */
+-  if (avformat_version() < AV_VERSION_INT(58,9,100))
+-    av_register_all();
+ 
+ 	av_log_set_callback(scan_av_log);
+ 
diff --git a/srcpkgs/loudgain/template b/srcpkgs/loudgain/template
index da4f2d56e94c3d..4d6bf29efb4fdd 100644
--- a/srcpkgs/loudgain/template
+++ b/srcpkgs/loudgain/template
@@ -1,7 +1,7 @@
 # Template file for 'loudgain'
 pkgname=loudgain
 version=0.6.8
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libebur128-devel taglib-devel ffmpeg-devel"

From 61c1562e72874235b6934e205a410a558fe8dde9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 046/111] mediastreamer: revbump for ffmpeg4

---
 srcpkgs/mediastreamer/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mediastreamer/template b/srcpkgs/mediastreamer/template
index 0fcffa7653d18e..e888626b945e55 100644
--- a/srcpkgs/mediastreamer/template
+++ b/srcpkgs/mediastreamer/template
@@ -1,11 +1,11 @@
 # Template file for 'mediastreamer'
 pkgname=mediastreamer
 version=5.2.111
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DENABLE_STRICT=0 -DENABLE_UNIT_TESTS=0"
 hostmakedepends="python3"
-makedepends="bzrtp-devel ffmpeg-devel glew-devel libXv-devel libsrtp-devel
+makedepends="bzrtp-devel ffmpeg4-devel glew-devel libXv-devel libsrtp-devel
  libupnp-devel libvpx-devel mbedtls-devel opus-devel ortp-devel pulseaudio-devel
  libtheora-devel speex-devel v4l-utils-devel bcg729-devel bcmatroska2-devel libgsm-devel
  zxing-cpp-devel"

From ef500b3af20b021ff27ba9f2f74f8f907a8ed061 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 047/111] mgba: revbump for ffmpeg6

---
 srcpkgs/mgba/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mgba/template b/srcpkgs/mgba/template
index 6cd65650312543..93401adb618bd8 100644
--- a/srcpkgs/mgba/template
+++ b/srcpkgs/mgba/template
@@ -1,7 +1,7 @@
 # Template file for 'mgba'
 pkgname=mgba
 version=0.10.3
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake desktop-file-utils"
 makedepends="SDL2-devel ffmpeg-devel libedit-devel libepoxy-devel libmagick-devel

From c7669720e4dc306cb951b3c93d0a2aa7b8faf1a0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 048/111] mlt: revbump for ffmpeg4

---
 srcpkgs/mlt/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mlt/template b/srcpkgs/mlt/template
index 73e3915aaab9ac..d7ed4c4b30a868 100644
--- a/srcpkgs/mlt/template
+++ b/srcpkgs/mlt/template
@@ -1,14 +1,14 @@
 # Template file for 'mlt'
 pkgname=mlt
 version=6.26.1
-revision=3
+revision=4
 build_style=configure
 configure_args="--prefix=/usr --libdir=/usr/lib$XBPS_TARGET_WORDSIZE
  --enable-gpl --enable-gpl3 --disable-swfdec --without-kde
  --swig-languages=python"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which"
 # XXX: movit vid.stab
-makedepends="alsa-lib-devel ffmpeg-devel gtk+-devel jack-devel ladspa-sdk
+makedepends="alsa-lib-devel ffmpeg4-devel gtk+-devel jack-devel ladspa-sdk
  libexif-devel libsamplerate-devel libxml2-devel sox-devel SDL_image-devel
  fftw-devel frei0r-plugins python3-devel pulseaudio-devel movit-devel
  libvidstab-devel"

From 4664d5e1c2f3824615ff4153b131b3e59103b9de Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 049/111] moc: revbump for ffmpeg4

---
 srcpkgs/moc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/moc/template b/srcpkgs/moc/template
index 3a04932c8f1e61..838755f88db09e 100644
--- a/srcpkgs/moc/template
+++ b/srcpkgs/moc/template
@@ -1,10 +1,10 @@
 # Template file for 'moc'
 pkgname=moc
 version=2.5.2
-revision=7
+revision=8
 build_style=gnu-configure
 hostmakedepends="pkg-config"
-makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg-devel
+makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg4-devel
  jack-devel alsa-lib-devel libltdl-devel libflac-devel libvorbis-devel
  libmad-devel libmpcdec-devel libmodplug-devel libid3tag-devel faad2-devel
  taglib-devel libsndfile-devel wavpack-devel speex-devel libsamplerate-devel

From 3f61230884f8b904c4fa9974522f3cd263fba229 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 050/111] motion: revbump for ffmpeg6

---
 srcpkgs/motion/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/motion/template b/srcpkgs/motion/template
index 607ebeb3c7b242..bf63a91d9764f6 100644
--- a/srcpkgs/motion/template
+++ b/srcpkgs/motion/template
@@ -1,7 +1,7 @@
 # Template file for 'motion'
 pkgname=motion
 version=4.6.0
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake pkg-config gettext-devel tar"
 makedepends="ffmpeg-devel libmicrohttpd-devel v4l-utils-devel gettext-devel"

From 95587f209835de88047a51f7323121a63549f60f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 051/111] olive: revbump for ffmpeg4

---
 srcpkgs/olive/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/olive/template b/srcpkgs/olive/template
index 12a46936c99003..5c2917b9c51245 100644
--- a/srcpkgs/olive/template
+++ b/srcpkgs/olive/template
@@ -1,10 +1,10 @@
 # Template file for 'olive'
 pkgname=olive
 version=0.1.2
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools pkg-config"
-makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg-devel frei0r-plugins"
+makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg4-devel frei0r-plugins"
 short_desc="Non-linear video editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"

From 0133503c8010eb0fa3ac21a2ce5e9e3cf4ed86fe Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 052/111] opentoonz: revbump for ffmpeg6

---
 srcpkgs/opentoonz/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/opentoonz/template b/srcpkgs/opentoonz/template
index ee9f7603f55fd8..3e81834ca0eddf 100644
--- a/srcpkgs/opentoonz/template
+++ b/srcpkgs/opentoonz/template
@@ -1,7 +1,7 @@
 # Template file for 'opentoonz'
 pkgname=opentoonz
 version=1.6.0
-revision=2
+revision=3
 build_wrksrc="toonz/sources"
 build_style=cmake
 make_cmd=make

From a89fe8b1aa56b8da5374d33470d4dfa32870cc2f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 053/111] pianobar: revbump for ffmpeg6

---
 srcpkgs/pianobar/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pianobar/template b/srcpkgs/pianobar/template
index e3febb821a4510..1e3dc1bf9308ee 100644
--- a/srcpkgs/pianobar/template
+++ b/srcpkgs/pianobar/template
@@ -1,7 +1,7 @@
 # Template file for 'pianobar'
 pkgname=pianobar
 version=2022.04.01
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="V=1"
 hostmakedepends="pkg-config"

From c36552ed94190c4b9528a0d1181b9b7d7d686e73 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 054/111] ppsspp: revbump for ffmpeg6

---
 srcpkgs/ppsspp/patches/ffmpeg6.patch | 15 +++++++++++++++
 srcpkgs/ppsspp/template              |  3 +--
 2 files changed, 16 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/ppsspp/patches/ffmpeg6.patch

diff --git a/srcpkgs/ppsspp/patches/ffmpeg6.patch b/srcpkgs/ppsspp/patches/ffmpeg6.patch
new file mode 100644
index 00000000000000..5803c7bf227309
--- /dev/null
+++ b/srcpkgs/ppsspp/patches/ffmpeg6.patch
@@ -0,0 +1,15 @@
+--- a/Core/HW/SimpleAudioDec.cpp	2024-02-04 08:08:02.000000000 -0500
++++ b/Core/HW/SimpleAudioDec.cpp	2024-02-15 14:48:27.114362051 -0500
+@@ -81,7 +81,11 @@
+ 		return;
+ 	}
+ 	// Find decoder
++#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(58, 18, 100)
+ 	codec_ = avcodec_find_decoder((AVCodecID)audioCodecId);
++#else // this is a macro to const in the header
++	codec_ = (AVCodec*)avcodec_find_decoder((AVCodecID)audioCodecId);
++#endif
+ 	if (!codec_) {
+ 		// Eh, we shouldn't even have managed to compile. But meh.
+ 		ERROR_LOG(ME, "This version of FFMPEG does not support AV_CODEC_ctx for audio (%s). Update your submodule.", GetCodecName(audioType));
+
diff --git a/srcpkgs/ppsspp/template b/srcpkgs/ppsspp/template
index 2238a7601c0af8..1fda55268a2d39 100644
--- a/srcpkgs/ppsspp/template
+++ b/srcpkgs/ppsspp/template
@@ -1,7 +1,7 @@
 # Template file for 'ppsspp'
 pkgname=ppsspp
 version=1.17.1
-revision=1
+revision=2
 _glslang_commit=b34f619e1c85810dcb3c578107d2e48ba4ee2b37
 _SPIRV_Cross_commit=4212eef67ed0ca048cb726a6767185504e7695e5
 _armips_commit=a8d71f0f279eb0d30ecf6af51473b66ae0cf8e8d
@@ -91,7 +91,6 @@ post_configure() {
 }
 
 do_install() {
-	vlicense LICENSE.TXT
 	vinstall icons/icon.svg 644 usr/share/pixmaps ppsspp.svg
 	vinstall Qt/PPSSPP.desktop 644 usr/share/applications
 	vbin build/PPSSPPHeadless ppsspp-headless

From 3cd68451abdfa6a1c80ed5c7067945fccc467142 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 055/111] pqiv: revbump for ffmpeg6

---
 srcpkgs/pqiv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pqiv/template b/srcpkgs/pqiv/template
index 542fc27a2d32a4..9308d949b6a1c7 100644
--- a/srcpkgs/pqiv/template
+++ b/srcpkgs/pqiv/template
@@ -1,7 +1,7 @@
 # Template file for 'pqiv'
 pkgname=pqiv
 version=2.12
-revision=1
+revision=2
 build_style=gnu-makefile
 hostmakedepends="pkg-config"
 makedepends="glib-devel gtk+3-devel $(vopt_if ffmpeg ffmpeg-devel)

From ede543a06136328703e828cfcdba0b4eb6e9427a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 056/111] qmmp: revbump for ffmpeg6

---
 srcpkgs/qmmp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qmmp/template b/srcpkgs/qmmp/template
index 53781ea3bc28ad..2da07f1e87eac0 100644
--- a/srcpkgs/qmmp/template
+++ b/srcpkgs/qmmp/template
@@ -1,7 +1,7 @@
 # Template file for 'qmmp'
 pkgname=qmmp
 version=1.6.1
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DUSE_HAL:BOOL=FALSE -DQMMP_DEFAULT_UI:STRING=simple"
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From 8ca67d5f95c9ba0800aa7321561312e37f68b26e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 14 Dec 2023 13:28:10 -0500
Subject: [PATCH 057/111] qt6-pdf: revbump for ffmpeg6

---
 srcpkgs/qt6-pdf/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-pdf/template b/srcpkgs/qt6-pdf/template
index ecda84afac1310..531b4e1d4fe84d 100644
--- a/srcpkgs/qt6-pdf/template
+++ b/srcpkgs/qt6-pdf/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-pdf'
 pkgname=qt6-pdf
 version=6.6.0
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DQT_FEATURE_qtpdf_build=ON
  -DQT_FEATURE_qtpdf_widgets_build=ON

From 75a64aa3d9a89191e60a3df0da46e81aa43b8bd5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 058/111] qt5-webengine: revbump for ffmpeg6

---
 .../chromium-media-filters-cpp14.patch        |  11 ++
 srcpkgs/qt5-webengine/patches/ffmpeg5.patch   | 179 ++++++++++++++++++
 .../qtwebengine-fix-ffmpeg5-build.patch       |  14 ++
 srcpkgs/qt5-webengine/template                |   4 +-
 4 files changed, 206 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/ffmpeg5.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch

diff --git a/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
new file mode 100644
index 00000000000000..04adc540f2cbc0
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
@@ -0,0 +1,11 @@
+--- a/src/3rdparty/chromium/media/filters/BUILD.gn	2023-02-27 13:32:59.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/BUILD.gn	2023-04-02 17:21:39.204066384 -0400
+@@ -96,6 +96,8 @@
+     "//ui/gfx/geometry:geometry",
+   ]
+ 
++  cflags_cc = [ "-std=c++14" ]
++
+   libs = []
+ 
+   if (proprietary_codecs) {
diff --git a/srcpkgs/qt5-webengine/patches/ffmpeg5.patch b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..ac55e1634423a9
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
@@ -0,0 +1,179 @@
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:57.732547446 -0400
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:09.486478995 -0400
+@@ -57,6 +57,8 @@
+ 
+ namespace {
+ 
++constexpr int64_t kRelativeTsBase = static_cast<int64_t>(0x7ffeffffffffffff);
++
+ void SetAVStreamDiscard(AVStream* stream, AVDiscard discard) {
+   DCHECK(stream);
+   stream->discard = discard;
+@@ -90,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+   if (stream->start_time != kNoFFmpegTimestamp)
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (stream->first_dts != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, stream->first_dts);
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -408,11 +398,11 @@
+   scoped_refptr<DecoderBuffer> buffer;
+ 
+   if (type() == DemuxerStream::TEXT) {
+-    int id_size = 0;
++    size_t id_size = 0;
+     uint8_t* id_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
+ 
+-    int settings_size = 0;
++    size_t settings_size = 0;
+     uint8_t* settings_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
+ 
+@@ -424,7 +414,7 @@
+     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
+                                      side_data.data(), side_data.size());
+   } else {
+-    int side_data_size = 0;
++    size_t side_data_size = 0;
+     uint8_t* side_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
+ 
+@@ -485,7 +475,7 @@
+                                        packet->size - data_offset);
+     }
+ 
+-    int skip_samples_size = 0;
++    size_t skip_samples_size = 0;
+     const uint32_t* skip_samples_ptr =
+         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
+             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
+@@ -1587,6 +1577,8 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++      continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+       lowest_start_time_stream = stream.get();
+@@ -1604,6 +1596,8 @@
+     if (stream && stream->type() == DemuxerStream::VIDEO &&
+         stream->IsEnabled()) {
+       video_stream = stream.get();
++      if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++        continue;
+       if (video_stream->start_time() <= seek_time) {
+         return video_stream;
+       }
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h qtwebengine-5.15.10/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h
+--- a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-07-11 22:12:47.917192788 -0500
+@@ -29,6 +29,7 @@ extern "C" {
+ #include <libavformat/avformat.h>
+ #include <libavformat/avio.h>
+ #include <libavutil/avutil.h>
++#include <libavutil/channel_layout.h>
+ #include <libavutil/imgutils.h>
+ #include <libavutil/log.h>
+ #include <libavutil/mastering_display_metadata.h>
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/audio_file_reader.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/audio_file_reader.cc
+--- a/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -85,7 +85,7 @@ bool AudioFileReader::OpenDemuxer() {
+ }
+ 
+ bool AudioFileReader::OpenDecoder() {
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (codec) {
+     // MP3 decodes to S16P which we don't support, tell it to use S16 instead.
+     if (codec_context_->sample_fmt == AV_SAMPLE_FMT_S16P)
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -329,7 +329,7 @@ bool FFmpegAudioDecoder::ConfigureDecode
+     }
+   }
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec ||
+       avcodec_open2(codec_context_.get(), codec, &codec_options) < 0) {
+     DLOG(ERROR) << "Could not initialize audio decoder: "
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -59,7 +59,6 @@ static int64_t AVIOSeekOperation(void* o
+ }
+ 
+ void FFmpegGlue::InitializeFFmpeg() {
+-  av_register_all();
+ }
+ 
+ static void LogContainer(bool is_local_file,
+@@ -95,9 +94,6 @@ FFmpegGlue::FFmpegGlue(FFmpegURLProtocol
+   // Enable fast, but inaccurate seeks for MP3.
+   format_context_->flags |= AVFMT_FLAG_FAST_SEEK;
+ 
+-  // Ensures we can read out various metadata bits like vp8 alpha.
+-  format_context_->flags |= AVFMT_FLAG_KEEP_SIDE_DATA;
+-
+   // Ensures format parsing errors will bail out. From an audit on 11/2017, all
+   // instances were real failures. Solves bugs like http://crbug.com/710791.
+   format_context_->error_recognition |= AV_EF_EXPLODE;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -391,7 +391,7 @@ bool FFmpegVideoDecoder::ConfigureDecode
+   if (decode_nalus_)
+     codec_context_->flags2 |= AV_CODEC_FLAG2_CHUNKS;
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
+     ReleaseFFmpegResources();
+     return false;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/media_file_checker.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/media_file_checker.cc
+--- a/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -68,7 +68,7 @@ bool MediaFileChecker::Start(base::TimeD
+       auto context = AVStreamToAVCodecContext(format_context->streams[i]);
+       if (!context)
+         continue;
+-      AVCodec* codec = avcodec_find_decoder(cp->codec_id);
++      const AVCodec* codec = avcodec_find_decoder(cp->codec_id);
+       if (codec && avcodec_open2(context.get(), codec, nullptr) >= 0) {
+         auto loop = std::make_unique<FFmpegDecodingLoop>(context.get());
+         stream_contexts[i] = {std::move(context), std::move(loop)};
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc qtwebengine-5.15.10/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc
+--- a/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -203,7 +203,7 @@ int32_t H264DecoderImpl::InitDecode(cons
+   // a pointer |this|.
+   av_context_->opaque = this;
+ 
+-  AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
+   if (!codec) {
+     // This is an indication that FFmpeg has not been initialized or it has not
+     // been compiled/initialized with the correct set of codecs.
diff --git a/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch b/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch
new file mode 100644
index 00000000000000..bc24d5b9a29cb5
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch
@@ -0,0 +1,14 @@
+--- a/src/buildtools/configure.json	2023-12-09 11:06:01.503058569 -0500
++++ b/src/buildtools/configure.json	2023-12-09 11:06:14.982361345 -0500
+@@ -779,11 +779,6 @@
+             "type": "warning",
+             "condition": "config.ios && config.simulator && config.device && features.build-qtpdf",
+             "message": "Building fat libray with device and simulator architectures will disable NEON."
+-        },
+-        {
+-            "type": "fatal",
+-            "condition": "features.webengine-system-ffmpeg && !libs.webengine-ffmpeg-support",
+-            "message": "Unmodified ffmpeg >= 5.0 is not supported. Please configure with -qt-webengine-ffmpeg."
+         }
+     ],
+     "summary": [
diff --git a/srcpkgs/qt5-webengine/template b/srcpkgs/qt5-webengine/template
index 8d2df1b5175bad..1687a77eb8a2f5 100644
--- a/srcpkgs/qt5-webengine/template
+++ b/srcpkgs/qt5-webengine/template
@@ -1,14 +1,14 @@
 # Template file for 'qt5-webengine'
 pkgname=qt5-webengine
 version=5.15.16
-revision=1
+revision=2
 _version="${version}-lts"
 _chromium_commit=207c2ac45ca3386d153770c6b0d2ea2ec21ca880
 archs="x86_64* i686* armv[67]* ppc64* aarch64*"
 create_wrksrc=yes
 build_style=qmake
 configure_args="--
- -webengine-icu -webengine-ffmpeg -webengine-opus -webengine-webp
+ -webengine-icu -system-ffmpeg -webengine-opus -webengine-webp
  -webengine-pepper-plugins -webengine-printing-and-pdf -webengine-proprietary-codecs
  -webengine-pulseaudio -webengine-spellchecker -webengine-webrtc -webengine-geolocation
  -webengine-kerberos -no-webengine-embedded-build $(vopt_if sndio '' '-no')-webengine-sndio

From 91c73b8ffe5a20b51515eefa3497090835510bd7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 059/111] qt5: revbump for ffmpeg6

---
 srcpkgs/qt5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5/template b/srcpkgs/qt5/template
index 3efb7e42d5fd3f..27f6d5388cd15c 100644
--- a/srcpkgs/qt5/template
+++ b/srcpkgs/qt5/template
@@ -3,9 +3,9 @@
 # revbump libqtxdg after bumping patch version
 pkgname=qt5
 version=5.15.11+20231124
+revision=3
 # commit 4765fa1df7a837db9c1f89c4da0dd76b74bb5fab
 # base repo: https://invent.kde.org/qt/qt/qt5
-revision=2
 build_style=meta
 hostmakedepends="cmake clang17 flex perl glib-devel pkg-config
  python3 re2c ruby which"

From d1908087801606c4aaeba76080d0bab4a3505fc7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 060/111] qtav: revbump for ffmpeg4

---
 srcpkgs/qtav/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtav/template b/srcpkgs/qtav/template
index 775d5a139a9efa..aa69e213c984b0 100644
--- a/srcpkgs/qtav/template
+++ b/srcpkgs/qtav/template
@@ -1,10 +1,10 @@
 # Template file for 'qtav'
 pkgname=qtav
 version=1.13.0
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel libass-devel libopenal-devel
+makedepends="ffmpeg4-devel libass-devel libopenal-devel
  libva-glx-devel libXv-devel pulseaudio-devel
  qt5-declarative-devel qt5-svg-devel
  qt5-quickcontrols"

From 5c6eadd71cbaa9e7b037f19ddb4943dc189eca06 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 061/111] retroarch: revbump for ffmpeg6

---
 srcpkgs/retroarch/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroarch/template b/srcpkgs/retroarch/template
index cb3125c5dbf1ae..c65c26f7bf0332 100644
--- a/srcpkgs/retroarch/template
+++ b/srcpkgs/retroarch/template
@@ -1,7 +1,7 @@
 # Template file for 'retroarch'
 pkgname=retroarch
 version=1.16.0.3
-revision=3
+revision=4
 build_style=configure
 configure_args="--prefix=/usr --sysconfdir=/etc --enable-networking
  --enable-udev --disable-builtinflac --disable-builtinglslang

From aa1acf125d469072acd6878455deaadfa90b6606 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 062/111] scrcpy: revbump for ffmpeg6

---
 srcpkgs/scrcpy/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/scrcpy/template b/srcpkgs/scrcpy/template
index d04de770dc1913..5218fa01f8ce1f 100644
--- a/srcpkgs/scrcpy/template
+++ b/srcpkgs/scrcpy/template
@@ -1,7 +1,7 @@
 # Template file for 'scrcpy'
 pkgname=scrcpy
 version=2.3.1
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcompile_server=false
  -Dprebuilt_server=/usr/share/scrcpy/scrcpy-server-v${version}"

From 00213415dadce80c157916e08198fa1be57c7161 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 17 Oct 2023 08:54:11 -0400
Subject: [PATCH 063/111] New package: spex-x replaces spek-alternative for
 ffmpeg6

---
 srcpkgs/spek-alternative                      |  1 +
 srcpkgs/{spek-alternative => spek-x}/template | 22 ++++++++++++-------
 2 files changed, 15 insertions(+), 8 deletions(-)
 create mode 120000 srcpkgs/spek-alternative
 rename srcpkgs/{spek-alternative => spek-x}/template (52%)

diff --git a/srcpkgs/spek-alternative b/srcpkgs/spek-alternative
new file mode 120000
index 00000000000000..76648236da7017
--- /dev/null
+++ b/srcpkgs/spek-alternative
@@ -0,0 +1 @@
+spek-x
\ No newline at end of file
diff --git a/srcpkgs/spek-alternative/template b/srcpkgs/spek-x/template
similarity index 52%
rename from srcpkgs/spek-alternative/template
rename to srcpkgs/spek-x/template
index d7b55c776b1d43..3ded6c2c323e4f 100644
--- a/srcpkgs/spek-alternative/template
+++ b/srcpkgs/spek-x/template
@@ -1,18 +1,18 @@
-# Template file for 'spek-alternative'
-pkgname=spek-alternative
-version=0.8.2.3
-revision=2
+# Template file for 'spek-x'
+pkgname=spek-x
+version=0.9.3
+revision=1
 build_style=gnu-configure
 hostmakedepends="automake gettext-devel intltool libtool pkg-config
  wxWidgets-common wxWidgets-gtk3-devel"
 makedepends="ffmpeg-devel wxWidgets-gtk3-devel"
 depends="ffmpeg"
 short_desc="Acoustic spectrum analyser"
-maintainer="Kartik Singh <kartik.ynwa@gmail.com>"
+maintainer="zlice <zlice555@gmail.com>"
 license="GPL-3.0-or-later"
-homepage="https://github.com/withmorten/spek-alternative"
-distfiles="https://github.com/withmorten/spek-alternative/archive/${version}.tar.gz"
-checksum="007ba4b84a310b078e378aa84c8e80783db5821437a757a488c3ecec377e6b2a"
+homepage="https://github.com/MikeWang000000/spek-x"
+distfiles="https://github.com/MikeWang000000/spek-x/archive/v${version}.tar.gz"
+checksum="7f4b109903333cdd310ab2b9176f0dc49a565891376e281a233d342cedf90ef7"
 
 CXXFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
 
@@ -22,3 +22,9 @@ export WX_CONFIG_NAME="wx-config-gtk3"
 pre_configure() {
 	NOCONFIGURE=1 ./autogen.sh
 }
+
+spek-alternative_package() {
+	depends="spek-x"
+	short_desc+=" - transitional dummy package"
+	build_style=meta
+}

From 70cc276fd178db97be1c07ff904f25717a0d73e6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 064/111] ssr: revbump for ffmpeg6

---
 .../0001-Fix-build-with-ffmpeg-5.0.patch      | 241 ++++++++++++++++++
 srcpkgs/ssr/template                          |   2 +-
 2 files changed, 242 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ssr/patches/0001-Fix-build-with-ffmpeg-5.0.patch

diff --git a/srcpkgs/ssr/patches/0001-Fix-build-with-ffmpeg-5.0.patch b/srcpkgs/ssr/patches/0001-Fix-build-with-ffmpeg-5.0.patch
new file mode 100644
index 00000000000000..4c069b5a9fc464
--- /dev/null
+++ b/srcpkgs/ssr/patches/0001-Fix-build-with-ffmpeg-5.0.patch
@@ -0,0 +1,241 @@
+From f4cbde38021d9330dc73d2e3dfa8a70da3ff5721 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Bernhard=20Rosenkr=C3=A4nzer?= <bero@lindev.ch>
+Date: Sun, 16 Jan 2022 02:40:04 +0100
+Subject: [PATCH] Fix build with ffmpeg 5.0
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Adapt to ffmpeg 5.0 requiring more const-ness for AVCodec.
+
+Signed-off-by: Bernhard Rosenkränzer <bero@lindev.ch>
+---
+ src/AV/Output/AudioEncoder.cpp |  6 +++---
+ src/AV/Output/AudioEncoder.h   |  4 ++--
+ src/AV/Output/BaseEncoder.cpp  |  4 ++--
+ src/AV/Output/BaseEncoder.h    |  4 ++--
+ src/AV/Output/Muxer.cpp        | 12 ++++++------
+ src/AV/Output/Muxer.h          |  4 ++--
+ src/AV/Output/VideoEncoder.cpp |  6 +++---
+ src/AV/Output/VideoEncoder.h   |  4 ++--
+ 8 files changed, 22 insertions(+), 22 deletions(-)
+
+diff --git a/src/AV/Output/AudioEncoder.cpp b/src/AV/Output/AudioEncoder.cpp
+index 34d015c..cefc2e0 100644
+--- a/src/AV/Output/AudioEncoder.cpp
++++ b/src/AV/Output/AudioEncoder.cpp
+@@ -34,7 +34,7 @@ const std::vector<AudioEncoder::SampleFormatData> AudioEncoder::SUPPORTED_SAMPLE
+ 
+ const unsigned int AudioEncoder::DEFAULT_FRAME_SAMPLES = 1024;
+ 
+-AudioEncoder::AudioEncoder(Muxer* muxer, AVStream* stream, AVCodecContext *codec_context, AVCodec* codec, AVDictionary** options)
++AudioEncoder::AudioEncoder(Muxer* muxer, AVStream* stream, AVCodecContext *codec_context, const AVCodec* codec, AVDictionary** options)
+ 	: BaseEncoder(muxer, stream, codec_context, codec, options) {
+ 
+ #if !SSR_USE_AVCODEC_ENCODE_AUDIO2
+@@ -77,7 +77,7 @@ unsigned int AudioEncoder::GetSampleRate() {
+ }
+ 
+ bool AudioEncoder::AVCodecIsSupported(const QString& codec_name) {
+-	AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
++	const AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
+ 	if(codec == NULL)
+ 		return false;
+ 	if(!av_codec_is_encoder(codec))
+@@ -93,7 +93,7 @@ bool AudioEncoder::AVCodecIsSupported(const QString& codec_name) {
+ 	return false;
+ }
+ 
+-void AudioEncoder::PrepareStream(AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
++void AudioEncoder::PrepareStream(AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
+ 								 unsigned int bit_rate, unsigned int channels, unsigned int sample_rate) {
+ 
+ 	if(channels == 0) {
+diff --git a/src/AV/Output/AudioEncoder.h b/src/AV/Output/AudioEncoder.h
+index c93278c..ae9c82e 100644
+--- a/src/AV/Output/AudioEncoder.h
++++ b/src/AV/Output/AudioEncoder.h
+@@ -40,7 +40,7 @@ private:
+ #endif
+ 
+ public:
+-	AudioEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options);
++	AudioEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options);
+ 	~AudioEncoder();
+ 
+ 	// Returns the required frame size, i.e. the number of samples (for each channel).
+@@ -57,7 +57,7 @@ public:
+ 
+ public:
+ 	static bool AVCodecIsSupported(const QString& codec_name);
+-	static void PrepareStream(AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
++	static void PrepareStream(AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
+ 							  unsigned int bit_rate, unsigned int channels, unsigned int sample_rate);
+ 
+ private:
+diff --git a/src/AV/Output/BaseEncoder.cpp b/src/AV/Output/BaseEncoder.cpp
+index 7c01ef3..4780aaf 100644
+--- a/src/AV/Output/BaseEncoder.cpp
++++ b/src/AV/Output/BaseEncoder.cpp
+@@ -42,7 +42,7 @@ double ParseCodecOptionDouble(const QString& key, const QString& value, double m
+ 	return clamp(value_double, min, max) * multiply;
+ }
+ 
+-BaseEncoder::BaseEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options) {
++BaseEncoder::BaseEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options) {
+ 
+ 	m_muxer = muxer;
+ 	m_stream = stream;
+@@ -157,7 +157,7 @@ void BaseEncoder::IncrementPacketCounter() {
+ 	++lock->m_total_packets;
+ }
+ 
+-void BaseEncoder::Init(AVCodec* codec, AVDictionary** options) {
++void BaseEncoder::Init(const AVCodec* codec, AVDictionary** options) {
+ 
+ 	// open codec
+ 	if(avcodec_open2(m_codec_context, codec, options) < 0) {
+diff --git a/src/AV/Output/BaseEncoder.h b/src/AV/Output/BaseEncoder.h
+index 3d92f29..7f02bbd 100644
+--- a/src/AV/Output/BaseEncoder.h
++++ b/src/AV/Output/BaseEncoder.h
+@@ -51,7 +51,7 @@ private:
+ 	std::atomic<bool> m_should_stop, m_should_finish, m_is_done, m_error_occurred;
+ 
+ protected:
+-	BaseEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options);
++	BaseEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options);
+ 
+ public:
+ 	virtual ~BaseEncoder(); // encoders will be deleted by Muxer, don't delete them yourself!
+@@ -117,7 +117,7 @@ protected:
+ 	void IncrementPacketCounter();
+ 
+ private:
+-	void Init(AVCodec* codec, AVDictionary** options);
++	void Init(const AVCodec* codec, AVDictionary** options);
+ 	void Free();
+ 
+ 	void EncoderThread();
+diff --git a/src/AV/Output/Muxer.cpp b/src/AV/Output/Muxer.cpp
+index ad58380..14650b0 100644
+--- a/src/AV/Output/Muxer.cpp
++++ b/src/AV/Output/Muxer.cpp
+@@ -87,7 +87,7 @@ Muxer::~Muxer() {
+ 
+ VideoEncoder* Muxer::AddVideoEncoder(const QString& codec_name, const std::vector<std::pair<QString, QString> >& codec_options,
+ 									 unsigned int bit_rate, unsigned int width, unsigned int height, unsigned int frame_rate) {
+-	AVCodec *codec = FindCodec(codec_name);
++	const AVCodec *codec = FindCodec(codec_name);
+ 	AVCodecContext *codec_context = NULL;
+ 	AVStream *stream = AddStream(codec, &codec_context);
+ 	VideoEncoder *encoder;
+@@ -111,7 +111,7 @@ VideoEncoder* Muxer::AddVideoEncoder(const QString& codec_name, const std::vecto
+ 
+ AudioEncoder* Muxer::AddAudioEncoder(const QString& codec_name, const std::vector<std::pair<QString, QString> >& codec_options,
+ 									 unsigned int bit_rate, unsigned int channels, unsigned int sample_rate) {
+-	AVCodec *codec = FindCodec(codec_name);
++	const AVCodec *codec = FindCodec(codec_name);
+ 	AVCodecContext *codec_context = NULL;
+ 	AVStream *stream = AddStream(codec, &codec_context);
+ 	AudioEncoder *encoder;
+@@ -194,7 +194,7 @@ unsigned int Muxer::GetQueuedPacketCount(unsigned int stream_index) {
+ void Muxer::Init() {
+ 
+ 	// get the format we want (this is just a pointer, we don't have to free this)
+-	AVOutputFormat *format = av_guess_format(m_container_name.toUtf8().constData(), NULL, NULL);
++	const AVOutputFormat *format = av_guess_format(m_container_name.toUtf8().constData(), NULL, NULL);
+ 	if(format == NULL) {
+ 		Logger::LogError("[Muxer::Init] " + Logger::tr("Error: Can't find chosen output format!"));
+ 		throw LibavException();
+@@ -261,8 +261,8 @@ void Muxer::Free() {
+ 	}
+ }
+ 
+-AVCodec* Muxer::FindCodec(const QString& codec_name) {
+-	AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
++const AVCodec* Muxer::FindCodec(const QString& codec_name) {
++	const AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
+ 	if(codec == NULL) {
+ 		Logger::LogError("[Muxer::FindCodec] " + Logger::tr("Error: Can't find codec!"));
+ 		throw LibavException();
+@@ -270,7 +270,7 @@ AVCodec* Muxer::FindCodec(const QString& codec_name) {
+ 	return codec;
+ }
+ 
+-AVStream* Muxer::AddStream(AVCodec* codec, AVCodecContext** codec_context) {
++AVStream* Muxer::AddStream(const AVCodec* codec, AVCodecContext** codec_context) {
+ 	assert(!m_started);
+ 	assert(m_format_context->nb_streams < MUXER_MAX_STREAMS);
+ 
+diff --git a/src/AV/Output/Muxer.h b/src/AV/Output/Muxer.h
+index d72347d..b104bcb 100644
+--- a/src/AV/Output/Muxer.h
++++ b/src/AV/Output/Muxer.h
+@@ -114,8 +114,8 @@ private:
+ 	void Init();
+ 	void Free();
+ 
+-	AVCodec* FindCodec(const QString& codec_name);
+-	AVStream* AddStream(AVCodec* codec, AVCodecContext** codec_context);
++	const AVCodec* FindCodec(const QString& codec_name);
++	AVStream* AddStream(const AVCodec* codec, AVCodecContext** codec_context);
+ 
+ 	void MuxerThread();
+ 
+diff --git a/src/AV/Output/VideoEncoder.cpp b/src/AV/Output/VideoEncoder.cpp
+index 8087e8e..fc8b5d1 100644
+--- a/src/AV/Output/VideoEncoder.cpp
++++ b/src/AV/Output/VideoEncoder.cpp
+@@ -34,7 +34,7 @@ const std::vector<VideoEncoder::PixelFormatData> VideoEncoder::SUPPORTED_PIXEL_F
+ 	{"rgb", AV_PIX_FMT_RGB24, false},
+ };
+ 
+-VideoEncoder::VideoEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options)
++VideoEncoder::VideoEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options)
+ 	: BaseEncoder(muxer, stream, codec_context, codec, options) {
+ 
+ #if !SSR_USE_AVCODEC_ENCODE_VIDEO2
+@@ -95,7 +95,7 @@ unsigned int VideoEncoder::GetFrameRate() {
+ }
+ 
+ bool VideoEncoder::AVCodecIsSupported(const QString& codec_name) {
+-	AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
++	const AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
+ 	if(codec == NULL)
+ 		return false;
+ 	if(!av_codec_is_encoder(codec))
+@@ -111,7 +111,7 @@ bool VideoEncoder::AVCodecIsSupported(const QString& codec_name) {
+ 	return false;
+ }
+ 
+-void VideoEncoder::PrepareStream(AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
++void VideoEncoder::PrepareStream(AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
+ 								 unsigned int bit_rate, unsigned int width, unsigned int height, unsigned int frame_rate) {
+ 
+ 	if(width == 0 || height == 0) {
+diff --git a/src/AV/Output/VideoEncoder.h b/src/AV/Output/VideoEncoder.h
+index cb7ca27..68d872e 100644
+--- a/src/AV/Output/VideoEncoder.h
++++ b/src/AV/Output/VideoEncoder.h
+@@ -40,7 +40,7 @@ private:
+ #endif
+ 
+ public:
+-	VideoEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options);
++	VideoEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options);
+ 	~VideoEncoder();
+ 
+ 	// Returns the required pixel format.
+@@ -55,7 +55,7 @@ public:
+ 
+ public:
+ 	static bool AVCodecIsSupported(const QString& codec_name);
+-	static void PrepareStream(AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
++	static void PrepareStream(AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
+ 							  unsigned int bit_rate, unsigned int width, unsigned int height, unsigned int frame_rate);
+ 
+ private:
+-- 
+2.43.0
+
diff --git a/srcpkgs/ssr/template b/srcpkgs/ssr/template
index 3097754e3cbe54..e3c4261f1f5a64 100644
--- a/srcpkgs/ssr/template
+++ b/srcpkgs/ssr/template
@@ -1,7 +1,7 @@
 # Template file for 'ssr'
 pkgname=ssr
 version=0.4.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DWITH_QT5=ON"
 hostmakedepends="pkg-config"

From 55564ff5d17c045d8530aecd470de5ae3c3dce44 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 065/111] synfig: revbump for ffmpeg6 and mlt7

---
 srcpkgs/synfig/patches/ffmpeg6.patch | 71 ++++++++++++++++++++++++++++
 srcpkgs/synfig/template              |  6 +--
 2 files changed, 74 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/synfig/patches/ffmpeg6.patch

diff --git a/srcpkgs/synfig/patches/ffmpeg6.patch b/srcpkgs/synfig/patches/ffmpeg6.patch
new file mode 100644
index 00000000000000..10780b42782f4b
--- /dev/null
+++ b/srcpkgs/synfig/patches/ffmpeg6.patch
@@ -0,0 +1,71 @@
+--- a/src/modules/mod_libavcodec/trgt_av.cpp	2022-10-25 09:14:12.000000000 -0400
++++ b/src/modules/mod_libavcodec/trgt_av.cpp	2023-05-05 21:34:17.899194559 -0400
+@@ -38,6 +41,7 @@
+ extern "C"
+ {
+ #ifdef HAVE_LIBAVFORMAT_AVFORMAT_H
++#	include <libavcodec/avcodec.h>
+ #	include <libavformat/avformat.h>
+ #elif defined(HAVE_AVFORMAT_H)
+ #	include <avformat.h>
+@@ -155,11 +156,11 @@
+     }
+ 
+ 	bool open_video_stream() {
+-		if (avcodec_open2(video_context, NULL, NULL) < 0) {
++		if (avcodec_open2(video_context, nullptr, nullptr) < 0) {
+ 			synfig::error("Target_LibAVCodec: could not open video codec");
+ 			// seems the calling of avcodec_free_context after error will cause crash
+ 			// so just forget about this context
+-			video_context = NULL;
++			video_context = nullptr;
+ 			close();
+ 			return false;
+         }
+@@ -234,15 +235,21 @@
+ 		close();
+ 
+ 		if (!av_registered) {
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 			av_register_all();
++#endif
+ 			av_registered = true;
+ 		}
+ 
+ 		// guess format
+-		AVOutputFormat *format = av_guess_format(NULL, filename.c_str(), NULL);
++#if LIBAVCODEC_VERSION_MAJOR < 59 // FFMPEG < 5.0
++		AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#else
++		const AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#endif
+ 		if (!format) {
+ 			synfig::warning("Target_LibAVCodec: unable to guess the output format, defaulting to MPEG");
+-			format = av_guess_format("mpeg", NULL, NULL);
++			format = av_guess_format("mpeg", nullptr, nullptr);
+ 		}
+ 		if (!format) {
+ 			synfig::error("Target_LibAVCodec: unable to find 'mpeg' output format");
+@@ -254,6 +261,7 @@
+ 		context = avformat_alloc_context();
+ 		assert(context);
+ 		context->oformat = format;
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 		if (filename.size() + 1 > sizeof(context->filename)) {
+ 			synfig::error(
+ 				"Target_LibAVCodec: filename too long, max length is %d, filename is '%s'",
+@@ -263,6 +271,14 @@
+ 			return false;
+ 		}
+ 		memcpy(context->filename, filename.c_str(), filename.size() + 1);
++#else
++		context->url = av_strndup(filename.c_str(), filename.size());
++		if (!context->url) {
++			synfig::error("Target_LibAVCodec: cannot allocate space for filename");
++			close();
++			return false;
++		}
++#endif
+ 
+ 		packet = av_packet_alloc();
+ 		assert(packet);
diff --git a/srcpkgs/synfig/template b/srcpkgs/synfig/template
index d4d3e341a20bf8..828b5cb32956ee 100644
--- a/srcpkgs/synfig/template
+++ b/srcpkgs/synfig/template
@@ -2,11 +2,11 @@
 # Should be kept in sync with 'synfigstudio' and 'ETL'
 pkgname=synfig
 version=1.4.4
-revision=4
+revision=5
 build_style=gnu-configure
 configure_args="--with-boost-libdir=${XBPS_CROSS_BASE}/usr/lib"
 hostmakedepends="boost-build ImageMagick pkg-config intltool"
-makedepends="ETL gettext-devel libxml++-devel mlt-devel libmagick-devel
+makedepends="ETL gettext-devel libxml++-devel mlt7-devel libmagick-devel
  libmng-devel boost-build boost-devel libopenexr-devel ffmpeg-devel"
 depends="ImageMagick"
 short_desc="CLI 2D vector and timeline-based animation software"
@@ -20,7 +20,7 @@ CXXFLAGS="-std=c++11 -DHAVE_LOCALE_H=1"
 
 synfig-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision}
-	 libopenexr-devel libxml++-devel mlt-devel"
+	 libopenexr-devel libxml++-devel mlt7-devel"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/bin/synfig-config

From 70983eaad394d283e29f2d5ba4524b97a5821601 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 066/111] timg: revbump for ffmpeg6

---
 srcpkgs/timg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/timg/template b/srcpkgs/timg/template
index 2a2ab763d2fddf..8fb4327535ef93 100644
--- a/srcpkgs/timg/template
+++ b/srcpkgs/timg/template
@@ -1,7 +1,7 @@
 # Template file for 'timg'
 pkgname=timg
 version=1.4.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_OPENSLIDE_SUPPORT=off -Wno-dev"
 hostmakedepends="pkg-config git"

From c27ea8b4ada4484371611be0f7008f741dba2a0e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 067/111] tvheadend: revbump for ffmpeg4

---
 srcpkgs/tvheadend/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tvheadend/template b/srcpkgs/tvheadend/template
index 9aea7de4ec7057..012d31c4879ff1 100644
--- a/srcpkgs/tvheadend/template
+++ b/srcpkgs/tvheadend/template
@@ -8,7 +8,7 @@ configure_args="--enable-dvbscan --disable-ffmpeg_static
 --disable-libx265_static --disable-libvpx_static --disable-libtheora_static
 --disable-libvorbis_static --disable-libfdkaac_static"
 hostmakedepends="gettext pkg-config python3 git which"
-makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg-devel"
+makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg4-devel"
 short_desc="TV streaming server"
 maintainer="lemmi <lemmi@nerd2nerd.org>"
 license="GPL-3.0-only"

From fc678b4fb0fd3175eaf7692ecdfbb185e44144ac Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 068/111] unpaper: update to 7.0.0.

---
 srcpkgs/unpaper/template | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/srcpkgs/unpaper/template b/srcpkgs/unpaper/template
index 38ed47a5840165..1ff910e722afc8 100644
--- a/srcpkgs/unpaper/template
+++ b/srcpkgs/unpaper/template
@@ -1,13 +1,13 @@
 # Template file for 'unpaper'
 pkgname=unpaper
-version=6.1
-revision=3
-build_style=gnu-configure
+version=7.0.0
+revision=1
+build_style=meson
+hostmakedepends="pkg-config meson libxslt"
+makedepends="ffmpeg-devel python3-Sphinx"
+short_desc="Post-processing tool for scanned sheets of paper"
 maintainer="Orphaned <orphan@voidlinux.org>"
-hostmakedepends="pkg-config libxslt"
-makedepends="ffmpeg-devel"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://www.flameeyes.eu/projects/unpaper"
-short_desc="A post-processing tool for scanned sheets of paper"
 distfiles="https://www.flameeyes.eu/files/${pkgname}-${version}.tar.xz"
-checksum=237c84f5da544b3f7709827f9f12c37c346cdf029b1128fb4633f9bafa5cb930
+checksum=2575fbbf26c22719d1cb882b59602c9900c7f747118ac130883f63419be46a80

From 206b8dcdca4d440c53ee1fa68e32b8b561f310db Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 069/111] vice: revbump for ffmpeg4

---
 srcpkgs/vice/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/vice/template b/srcpkgs/vice/template
index b1f866d35095e7..43f79243a1da11 100644
--- a/srcpkgs/vice/template
+++ b/srcpkgs/vice/template
@@ -1,7 +1,7 @@
 # Template file for 'vice'
 pkgname=vice
 version=3.7.1
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="
 	$(vopt_enable sdl2 sdlui2)
@@ -26,7 +26,7 @@ makedepends="
 	$(vopt_if gtk3 gtk+3-devel)
 	$(vopt_if gtk3 pulseaudio-devel)
 	$(vopt_if gtk3 pango-devel)
-	$(vopt_if ffmpeg ffmpeg-devel)"
+	$(vopt_if ffmpeg ffmpeg4-devel)"
 short_desc="Emulator for C64, C128, CBM-II, PET, VIC20, Plus4 and C16"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"

From 78594270477f686fa82fd9d775a39dcc20c28cea Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 070/111] waypipe: revbump for ffmpeg6

---
 srcpkgs/waypipe/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waypipe/template b/srcpkgs/waypipe/template
index 6da88b21bf2a19..4da8058400b588 100644
--- a/srcpkgs/waypipe/template
+++ b/srcpkgs/waypipe/template
@@ -1,7 +1,7 @@
 # Template file for 'waypipe'
 pkgname=waypipe
 version=0.8.6
-revision=1
+revision=2
 build_style=meson
 # lto is off because it causes linking errors in armv6l and armv7l (due to NEON)
 configure_args="-Dwerror=false -Dwith_dmabuf=enabled -Dwith_lz4=enabled

From 6b63827168542a0abfabc2ff73e136757f5ed83b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 071/111] xpra: revbump for ffmpeg6

---
 srcpkgs/xpra/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xpra/template b/srcpkgs/xpra/template
index 3c86cd943653b1..2281a25d81c48f 100644
--- a/srcpkgs/xpra/template
+++ b/srcpkgs/xpra/template
@@ -1,7 +1,7 @@
 # Template file for 'xpra'
 pkgname=xpra
 version=5.0.6
-revision=1
+revision=2
 build_style=python3-module
 make_build_args="--without-cuda_kernels --without-cuda_rebuild"
 make_install_args="$(vopt_with docs) ${make_build_args}"

From b56f55bccc0f6c5f05043e5352c14b6286c1dd98 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:07:40 -0400
Subject: [PATCH 072/111] nv-codec-headers: update to 12.0.16.0

---
 srcpkgs/nv-codec-headers/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/nv-codec-headers/template b/srcpkgs/nv-codec-headers/template
index 3d422a61e48917..251e057f826fb8 100644
--- a/srcpkgs/nv-codec-headers/template
+++ b/srcpkgs/nv-codec-headers/template
@@ -1,6 +1,6 @@
 # Template file for 'nv-codec-headers'
 pkgname=nv-codec-headers
-version=11.1.5.1
+version=12.0.16.0
 revision=1
 build_style=gnu-makefile
 short_desc="FFmpeg version of headers required to interface with Nvidias codec APIs"
@@ -8,7 +8,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="MIT"
 homepage="http://git.videolan.org/?p=ffmpeg/nv-codec-headers.git"
 distfiles="https://github.com/FFmpeg/nv-codec-headers/archive/n${version}.tar.gz"
-checksum=d095fbd56aa93772471a323be0ebe65504a0f43f06c76a30b6d25da77b06ae9c
+checksum=2a1533b65f55f9da52956faf0627ed3b74868ac0c7f269990edd21369113b48f
 
 post_install() {
 	sed -n '4,25p' include/ffnvcodec/nvEncodeAPI.h > LICENSE

From 7c4afa9d494ec614fc390d8bf49804735f92d121 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:08:40 -0400
Subject: [PATCH 073/111] openimagedenoise: revbump for ffmpeg6

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index b792813dba7c29..109deb171c3f75 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,7 +1,7 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
 version=1.4.3
-revision=1
+revision=2
 archs="x86_64*"
 build_style=cmake
 hostmakedepends="ispc python3"

From bf056dfb1a9514ca13e641c1f759caeff4684823 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:31:45 -0400
Subject: [PATCH 074/111] shotcut: revbump for ffmpeg6

---
 srcpkgs/shotcut/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/shotcut/template b/srcpkgs/shotcut/template
index 33141fbd862d7a..f46cb53b6bfb92 100644
--- a/srcpkgs/shotcut/template
+++ b/srcpkgs/shotcut/template
@@ -1,7 +1,7 @@
 # Template file for 'shotcut'
 pkgname=shotcut
 version=23.09.29
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSHOTCUT_VERSION=${version}"
 hostmakedepends="pkg-config qt6-tools-devel"

From 0fa0606825aea954b9c76f033c47000a8ab21974 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:30 -0400
Subject: [PATCH 075/111] shiboken2: revbump for qt5-5.15.11

---
 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch | 1 +
 1 file changed, 1 insertion(+)
 create mode 120000 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
new file mode 120000
index 00000000000000..efcf3249bd8854
--- /dev/null
+++ b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1 @@
+../../python3-pyside2/patches/importlib-machinery-bypass.patch
\ No newline at end of file

From 30cca1bdfd1ce2e319946c3bf75f55d59fea5ffd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:53 -0400
Subject: [PATCH 076/111] python3-pyside2: revbump for qt5-5.15.11

---
 .../patches/importlib-machinery-bypass.patch      | 15 +++++++++++++++
 srcpkgs/python3-pyside2/template                  |  2 +-
 2 files changed, 16 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
new file mode 100644
index 00000000000000..64c429584776b5
--- /dev/null
+++ b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1,15 @@
+Using this prevents an error around line 220 below it.
+"AttributeError: module 'importlib' has no attribute 'machinery'"
+The old backup logic is in place and compiles without issues.
+--- a/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:09:34.688912402 -0400
++++ b/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:10:03.395529582 -0400
+@@ -170,9 +170,6 @@
+
+     # 'zipstring_sequence' comes from signature.cpp
+     zipbytes = base64.b64decode(''.join(zipstring_sequence))
+-    if sys.version_info[0] >= 3:
+-        vzip = zipfile.ZipFile(io.BytesIO(zipbytes))
+-        return sys.meta_path, EmbeddableZipImporter(vzip)
+
+     # Old version for Python 2.7, only.
+     import os
diff --git a/srcpkgs/python3-pyside2/template b/srcpkgs/python3-pyside2/template
index 249efa90988425..52626436ce75f2 100644
--- a/srcpkgs/python3-pyside2/template
+++ b/srcpkgs/python3-pyside2/template
@@ -1,7 +1,7 @@
 # Template file for 'python3-pyside2'
 pkgname=python3-pyside2
 version=5.15.10
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/pyside2"
 build_style=cmake

From c298e1a8831e7e3c4cf8e2739d5a13cdc1d91dd1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:35 -0400
Subject: [PATCH 077/111] konqueror: revbump for ffmpeg6

---
 srcpkgs/konqueror/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/konqueror/template b/srcpkgs/konqueror/template
index 044dafa605ba65..63dd01fafc7802 100644
--- a/srcpkgs/konqueror/template
+++ b/srcpkgs/konqueror/template
@@ -1,11 +1,11 @@
 # Template file for 'konqueror'
 pkgname=konqueror
 version=23.08.4
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DDESKTOPTOJSON_EXECUTABLE=/usr/bin/desktoptojson"
 hostmakedepends="extra-cmake-modules python3 qt5-host-tools qt5-qmake kdoctools
-kcoreaddons kconfig gettext"
+ kcoreaddons kconfig gettext"
 makedepends="qt5-devel qt5-webengine-devel qt5-declarative-devel
  qt5-webchannel-devel qt5-location-devel kcmutils-devel kdelibs4support-devel
  karchive-devel khtml-devel kdesu-devel kactivities5-devel"

From 5f1b64f19f699102c68e5d87d7812ec7e86ac131 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:58 -0400
Subject: [PATCH 078/111] qt5-speech: revbump for qt5-5.15.11

---
 srcpkgs/qt5-speech/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-speech/template b/srcpkgs/qt5-speech/template
index 1228bb60c41db4..27a7da1dbdb91b 100644
--- a/srcpkgs/qt5-speech/template
+++ b/srcpkgs/qt5-speech/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-speech'
 pkgname=qt5-speech
 version=5.15.11
-revision=1
+revision=2
 _commit=d32f4a479d38a11f547598004b975f4356424a16
 build_style=qmake
 configure_args="-- -flite -flite-alsa -speechd"

From c31d453b4aaee167821c6ca7ccea9e7ca1479413 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Jun 2023 08:20:22 -0400
Subject: [PATCH 079/111] gtk4: revbump for ffmpeg6

---
 srcpkgs/gtk4/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gtk4/template b/srcpkgs/gtk4/template
index d8ee60abe06f71..55bff6e33849ac 100644
--- a/srcpkgs/gtk4/template
+++ b/srcpkgs/gtk4/template
@@ -1,7 +1,7 @@
 # Template file for 'gtk4'
 pkgname=gtk4
 version=4.12.3
-revision=1
+revision=2
 build_style=meson
 build_helper="gir"
 configure_args="-Dman-pages=true -Ddocumentation=true -Dbuild-tests=false

From c877262cdb9c91f8394c7d1e315d54eca2799692 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:28:26 -0400
Subject: [PATCH 080/111] siril: revbump for ffmpeg6

---
 srcpkgs/siril/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/siril/template b/srcpkgs/siril/template
index 84332f79d060d2..62750dd247548f 100644
--- a/srcpkgs/siril/template
+++ b/srcpkgs/siril/template
@@ -1,7 +1,7 @@
 # Template file for 'siril'
 pkgname=siril
 version=0.9.12
-revision=10
+revision=11
 build_style=gnu-configure
 hostmakedepends="pkg-config intltool autoconf automake gettext-devel"
 makedepends="fftw-devel libconfig-devel libopencv-devel libffms2-devel

From 86a93117d8ddeddcd9ec60bf9aaf8909f6b81485 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 22 Jun 2023 10:25:02 -0400
Subject: [PATCH 081/111] kdenlive: revbump for ffmpeg6

---
 srcpkgs/kdenlive/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kdenlive/template b/srcpkgs/kdenlive/template
index a0f3615c9c530c..d63166f95c4d78 100644
--- a/srcpkgs/kdenlive/template
+++ b/srcpkgs/kdenlive/template
@@ -1,7 +1,7 @@
 # Template file for 'kdenlive'
 pkgname=kdenlive
 version=23.08.4
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="
  extra-cmake-modules kconfig kcoreaddons kdoctools pkg-config python3

From 21d81099f9ea06449939ffbdb970b3f7c48b5e44 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:20:59 -0400
Subject: [PATCH 082/111] tracker-miners: revbump for ffmpeg6

---
 srcpkgs/tracker-miners/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tracker-miners/template b/srcpkgs/tracker-miners/template
index 0b97f47489f817..f196d2bf9e4a4c 100644
--- a/srcpkgs/tracker-miners/template
+++ b/srcpkgs/tracker-miners/template
@@ -1,7 +1,7 @@
 # Template file for 'tracker-miners'
 pkgname=tracker-miners
 version=3.6.1
-revision=1
+revision=2
 build_style=meson
 build_helper=qemu
 # missing libgrss for miner_rss

From c611925f30fb6fd3168f26368be9e472298946f8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:21:21 -0400
Subject: [PATCH 083/111] mpd: revbump for ffmpeg6

---
 srcpkgs/mpd/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpd/template b/srcpkgs/mpd/template
index 4fd32b7be8c537..b8e2bd4c1b59c8 100644
--- a/srcpkgs/mpd/template
+++ b/srcpkgs/mpd/template
@@ -1,7 +1,7 @@
 # Template file for 'mpd'
 pkgname=mpd
 version=0.23.15
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dopus=enabled -Dmikmod=enabled -Dneighbor=true
  -Dsoundcloud=enabled -Dpipe=true -Dtwolame=enabled -Dbzip2=enabled

From 1b0c68ea27cfecc316261a85bb4c2328e85ffdb1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:02 -0400
Subject: [PATCH 084/111] tg_owt: revbump for ffmpeg6

---
 srcpkgs/tg_owt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tg_owt/template b/srcpkgs/tg_owt/template
index 34e8fef0540569..1a46a8bedf3473 100644
--- a/srcpkgs/tg_owt/template
+++ b/srcpkgs/tg_owt/template
@@ -1,7 +1,7 @@
 # Template file for 'tg_owt'
 pkgname=tg_owt
 version=0.0.0.20231221
-revision=2
+revision=3
 _commit=afd9d5d31798d3eacf9ed6c30601e91d0f1e4d60
 _libyuv_commit=04821d1e7d60845525e8db55c7bcd41ef5be9406
 _abseil_commit=8c0b94e793a66495e0b1f34a5eb26bd7dc672db0

From 49b578c2e1ec0af30a7bf6324d86e781b11d564b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:44 -0400
Subject: [PATCH 085/111] telegram-desktop: revbump for ffmpeg6

---
 srcpkgs/telegram-desktop/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/telegram-desktop/template b/srcpkgs/telegram-desktop/template
index 6dc6a553cfcec8..cf85a731370062 100644
--- a/srcpkgs/telegram-desktop/template
+++ b/srcpkgs/telegram-desktop/template
@@ -1,7 +1,7 @@
 # Template file for 'telegram-desktop'
 pkgname=telegram-desktop
 version=4.14.15
-revision=3
+revision=4
 build_style=cmake
 build_helper="qemu gir"
 configure_args="-DTDESKTOP_API_ID=209235

From 6d0e10ab4f8884003c3b7a04e3fddd5a7e69fd2b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:12:09 -0400
Subject: [PATCH 086/111] openmw: revbump for ffmpeg6

---
 srcpkgs/openmw/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openmw/template b/srcpkgs/openmw/template
index 0abf5ff7cdbecc..b57180f1a4446f 100644
--- a/srcpkgs/openmw/template
+++ b/srcpkgs/openmw/template
@@ -1,7 +1,7 @@
 # Template file for 'openmw'
 pkgname=openmw
 version=0.48.0
-revision=2
+revision=3
 build_style=cmake
 _recast_commit=e75adf86f91eb3082220085e42dda62679f9a3ea
 _bullet_tag=3.17

From 58dae49ffbff2f6c55ba3976b8bbb895b07408c3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:14:53 -0400
Subject: [PATCH 087/111] lms: revbump for ffmpeg6

---
 srcpkgs/lms/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/lms/template b/srcpkgs/lms/template
index e358f75902a986..3b21c458de5199 100644
--- a/srcpkgs/lms/template
+++ b/srcpkgs/lms/template
@@ -1,7 +1,7 @@
 # Template file for 'lms'
 pkgname=lms
 version=3.42.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="wt-devel ffmpeg-devel boost-devel libconfig++-devel taglib-devel pam-devel libgraphicsmagick-devel gtest-devel libarchive-devel"

From 3e7b7d5e2ae97899bc0f326eaa74b5c7a54f9dc2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:18:18 -0400
Subject: [PATCH 088/111] freecad: DELETE

---
 srcpkgs/freecad/patches/001-include.patch     | 112 ------------------
 .../154-revert-gui-tmp-redirect-stderr.patch  |  68 -----------
 ...d63c8c9b1280978be841d04e68a0a55cceb9.patch |  30 -----
 srcpkgs/freecad/template                      |  12 +-
 4 files changed, 7 insertions(+), 215 deletions(-)
 delete mode 100644 srcpkgs/freecad/patches/001-include.patch
 delete mode 100644 srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
 delete mode 100644 srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch

diff --git a/srcpkgs/freecad/patches/001-include.patch b/srcpkgs/freecad/patches/001-include.patch
deleted file mode 100644
index 28b5af54999b96..00000000000000
--- a/srcpkgs/freecad/patches/001-include.patch
+++ /dev/null
@@ -1,112 +0,0 @@
-From 9a41845a417189776741297c50a3827ce292bc4f Mon Sep 17 00:00:00 2001
-From: Uwe <donovaly@users.noreply.github.com>
-Date: Sun, 3 Jul 2022 22:51:16 +0200
-Subject: [PATCH] [Part] OCCError.h: remove unneeded includes
-
-- also sort includes
----
- src/Mod/Part/App/OCCError.h             | 36 +++----------------------
- src/Mod/Part/App/OffsetCurvePyImp.cpp   | 12 ++++-----
- src/Mod/Part/App/OffsetSurfacePyImp.cpp | 10 +++----
- 3 files changed, 12 insertions(+), 46 deletions(-)
-
---- a/src/Mod/Part/App/OCCError.h
-+++ b/src/Mod/Part/App/OCCError.h
-@@ -23,36 +23,8 @@
- #ifndef _OCCError_h_
- #define _OCCError_h_
- 
--# include <Standard_Version.hxx>
- # include <Standard_Failure.hxx>
--# include <Standard_AbortiveTransaction.hxx>
--# include <Standard_ConstructionError.hxx>
--# if OCC_VERSION_HEX >= 0x060500
--# include <Standard_DefineException.hxx>
--# endif
--# include <Standard_DimensionError.hxx>
--# include <Standard_DimensionMismatch.hxx>
--# include <Standard_DivideByZero.hxx>
--# include <Standard_DomainError.hxx>
--# include <Standard_ImmutableObject.hxx>
--# include <Standard_LicenseError.hxx>
--# include <Standard_LicenseNotFound.hxx>
--# include <Standard_MultiplyDefined.hxx>
--# include <Standard_NegativeValue.hxx>
--# include <Standard_NoMoreObject.hxx>
--# include <Standard_NoSuchObject.hxx>
--# include <Standard_NotImplemented.hxx>
--# include <Standard_NullObject.hxx>
--# include <Standard_NullValue.hxx>
--# include <Standard_NumericError.hxx>
--# include <Standard_OutOfMemory.hxx>
--# include <Standard_OutOfRange.hxx>
--# include <Standard_Overflow.hxx>
--# include <Standard_ProgramError.hxx>
--# include <Standard_RangeError.hxx>
--# include <Standard_TooManyUsers.hxx>
--# include <Standard_TypeMismatch.hxx>
--# include <Standard_Underflow.hxx>
-+# include <Standard_Version.hxx>
- 
- #include <Mod/Part/PartGlobal.h>
- #include <Base/Console.h>
-@@ -88,4 +60,3 @@ PartExport extern PyObject* PartExceptio
- 
- #define PY_CATCH_OCC _PY_CATCH_OCC(return(NULL))
- #endif  // _OCCError_h_
--
---- a/src/Mod/Part/App/OffsetCurvePyImp.cpp
-+++ b/src/Mod/Part/App/OffsetCurvePyImp.cpp
-@@ -20,20 +20,20 @@
-  *                                                                         *
-  ***************************************************************************/
- 
--
- #include "PreCompiled.h"
- #ifndef _PreComp_
- # include <Geom_OffsetCurve.hxx>
- #endif
- 
--#include "OCCError.h"
--#include "Geometry.h"
-+#include <Base/GeometryPyCXX.h>
-+#include <Base/Vector3D.h>
-+#include <Base/VectorPy.h>
-+
- #include "OffsetCurvePy.h"
- #include "OffsetCurvePy.cpp"
-+#include "Geometry.h"
-+#include "OCCError.h"
- 
--#include <Base/GeometryPyCXX.h>
--#include <Base/VectorPy.h>
--#include <Base/Vector3D.h>
- 
- using namespace Part;
- 
---- a/src/Mod/Part/App/OffsetSurfacePyImp.cpp
-+++ b/src/Mod/Part/App/OffsetSurfacePyImp.cpp
-@@ -20,20 +20,16 @@
-  *                                                                         *
-  ***************************************************************************/
- 
--
- #include "PreCompiled.h"
- #ifndef _PreComp_
- # include <Geom_OffsetSurface.hxx>
- # include <memory>
- #endif
- 
--#include <Base/VectorPy.h>
--#include <Base/Vector3D.h>
--
- #include "OCCError.h"
--#include "Geometry.h"
--#include <Mod/Part/App/OffsetSurfacePy.h>
--#include <Mod/Part/App/OffsetSurfacePy.cpp>
-+#include "OffsetSurfacePy.h"
-+#include "OffsetSurfacePy.cpp"
-+
- 
- using namespace Part;
- 
diff --git a/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch b/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
deleted file mode 100644
index d6a9adabdec830..00000000000000
--- a/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
+++ /dev/null
@@ -1,68 +0,0 @@
-see https://github.com/FreeCAD/FreeCAD/commit/cfe94b00d3434f3e2c8b5114d2909f628c330fa8#commitcomment-71413407
-
-upstream: yes
-
-From 7b377a216b9185960e4cee980a6504dc1a755f50 Mon Sep 17 00:00:00 2001
-From: wmayer <wmayer@users.sourceforge.net>
-Date: Wed, 29 Jun 2022 15:19:18 +0200
-Subject: [PATCH] Gui: remove workaround for spnav 0.23 due to build failure
- with musl libc
-
----
- src/Gui/3Dconnexion/GuiNativeEventLinux.cpp | 27 ---------------------
- 1 file changed, 27 deletions(-)
-
---- a/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp
-+++ b/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp
-@@ -21,42 +21,17 @@
-  ***************************************************************************/
- 
- #include <FCConfig.h>
--#include <cstdio>
- 
- #include "GuiNativeEventLinux.h"
- 
- #include "GuiApplicationNativeEventAware.h"
- #include <Base/Console.h>
--#include <Base/FileInfo.h>
- #include <QMainWindow>
- 
- #include <QSocketNotifier>
- 
- #include <spnav.h>
- 
--namespace {
--class RedirectStdErr
--{
--public:
--    RedirectStdErr()
--        : fi(Base::FileInfo::getTempFileName())
--        , file(stderr)
--    {
--        stderr = fopen(fi.filePath().c_str(), "w");
--    }
--    ~RedirectStdErr()
--    {
--        fclose(stderr);
--        fi.deleteFile();
--        stderr = file;
--    }
--
--private:
--    Base::FileInfo fi;
--    FILE* file;
--};
--}
--
- Gui::GuiNativeEvent::GuiNativeEvent(Gui::GUIApplicationNativeEventAware *app)
- : GuiAbstractNativeEvent(app)
- {
-@@ -72,8 +47,6 @@ Gui::GuiNativeEvent::~GuiNativeEvent()
- 
- void Gui::GuiNativeEvent::initSpaceball(QMainWindow *window)
- {
--    // tmp. redirect stderr to a file to suppress an error message from spnav_open()
--    RedirectStdErr err;
-     Q_UNUSED(window)
-     if (spnav_open() == -1) {
-         Base::Console().Log("Couldn't connect to spacenav daemon. Please ignore if you don't have a spacemouse.\n");
diff --git a/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch b/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch
deleted file mode 100644
index d4acf370ca0a42..00000000000000
--- a/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-From fe02d63c8c9b1280978be841d04e68a0a55cceb9 Mon Sep 17 00:00:00 2001
-From: Roy-043 <70520633+Roy-043@users.noreply.github.com>
-Date: Thu, 29 Dec 2022 23:20:38 +0100
-Subject: [PATCH] Draft: update inspect.getargspec to inspect.getfullargspec
- (#8101)
-
----
- src/Mod/Draft/draftguitools/gui_snapper.py | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
---- a/src/Mod/Draft/draftguitools/gui_snapper.py
-+++ b/src/Mod/Draft/draftguitools/gui_snapper.py
-@@ -1426,7 +1426,7 @@ class Snapper:
-             Gui.Snapper.off()
-             self.ui.offUi()
-             if callback:
--                if len(inspect.getargspec(callback).args) > 1:
-+                if len(inspect.getfullargspec(callback).args) > 1:
-                     obj = None
-                     if self.snapInfo and ("Object" in self.snapInfo) and self.snapInfo["Object"]:
-                         obj = App.ActiveDocument.getObject(self.snapInfo["Object"])
-@@ -1445,7 +1445,7 @@ class Snapper:
-             Gui.Snapper.off()
-             self.ui.offUi()
-             if callback:
--                if len(inspect.getargspec(callback).args) > 1:
-+                if len(inspect.getfullargspec(callback).args) > 1:
-                     callback(None, None)
-                 else:
-                     callback(None)
diff --git a/srcpkgs/freecad/template b/srcpkgs/freecad/template
index c135701e38b9ad..7d5165f760bab9 100644
--- a/srcpkgs/freecad/template
+++ b/srcpkgs/freecad/template
@@ -1,7 +1,7 @@
 # Template file for 'freecad'
 pkgname=freecad
-version=0.20.2
-revision=7
+version=0.21.1
+revision=2
 build_wrksrc="FreeCAD-${version}"
 build_style=cmake
 pycompile_dirs="usr/lib/${pkgname}/Mod"
@@ -24,8 +24,10 @@ makedepends="python3-devel boost-devel libxerces-c-devel zlib-devel occt-devel
  coin3-devel libshiboken2-devel libspnav-devel pyside2-tools
  liblz4-devel libpyside2-python3-devel python3-matplotlib netcdf-devel
  jsoncpp-devel qt5-devel qt5-svg-devel qt5-tools-devel qt5-webkit-devel
- qt5-xmlpatterns-devel coin3-doc glew-devel python3-pivy"
-depends="python3-matplotlib python3-pyside2-webengine python3-pivy"
+ qt5-xmlpatterns-devel coin3-doc glew-devel python3-pivy qt5-webengine-devel
+ qt5-declarative-devel qt5-webchannel-devel qt5-location-devel"
+depends="python3-matplotlib python3-pyside2-webengine python3-pivy
+ python3-GitPython python3-Markdown"
 short_desc="General purpose 3D CAD modeler"
 maintainer="yopito <pierre.bourgin@free.fr>"
 license="LGPL-2.0-or-later"
@@ -35,7 +37,7 @@ distfiles="
  https://github.com/FreeCAD/FreeCAD/archive/${version}.tar.gz
  ${SOURCEFORGE_SITE}/cxx/pycxx-${_pycxxver}.tar.gz
 "
-checksum="46922f3a477e742e1a89cd5346692d63aebb2b67af887b3e463e094a4ae055da
+checksum="e9b1fd0323f101268c7f3be52db42e4a29222f2e306ae6c4a6fc309cb418d35a
  4b91e1e1141c23fbd5039df635c4bb6e75632168548f56b83ce177193c0c98c6"
 python_version=3
 patch_args="-Np1 -d ${build_wrksrc}"

From 0d82f49079714e42f3bb4b43970a83ba145c1b9f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:47:18 -0400
Subject: [PATCH 089/111] libopenshot: revbump for ffmpeg6

---
 srcpkgs/libopenshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenshot/template b/srcpkgs/libopenshot/template
index 8e57c5f592169c..7a8f4520e78925 100644
--- a/srcpkgs/libopenshot/template
+++ b/srcpkgs/libopenshot/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenshot'
 pkgname=libopenshot
 version=0.3.0
-revision=3
+revision=4
 build_style=cmake
 # Builds fail with Ruby-2.4.1
 configure_args="-DENABLE_RUBY=OFF -DUSE_SYSTEM_JSONCPP=ON"

From c14704fe8f3c4e90ab1834d6297068bf541ee93a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:10:30 -0500
Subject: [PATCH 090/111] openimageio: revbump for ffmpeg6

---
 srcpkgs/openimageio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimageio/template b/srcpkgs/openimageio/template
index 3ce3f9e49d350c..27d2131bc0a61a 100644
--- a/srcpkgs/openimageio/template
+++ b/srcpkgs/openimageio/template
@@ -1,7 +1,7 @@
 # Template file for 'openimageio'
 pkgname=openimageio
 version=2.4.9.0
-revision=7
+revision=8
 build_style=cmake
 build_helper=qemu
 configure_args="-DUSE_QT=0 -DUSE_PYTHON=0 -DOIIO_BUILD_TESTS=0

From c81f01cee7f31eefbb700e3485841dcaf2e38de7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:11:57 -0500
Subject: [PATCH 091/111] synfigstudio: revbump for ffmpeg6

---
 srcpkgs/synfigstudio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/synfigstudio/template b/srcpkgs/synfigstudio/template
index 09e442da9a6805..2bc017cedca6b8 100644
--- a/srcpkgs/synfigstudio/template
+++ b/srcpkgs/synfigstudio/template
@@ -2,7 +2,7 @@
 # Should be kept in sync with 'synfig' and 'ETL'
 pkgname=synfigstudio
 version=1.4.4
-revision=4
+revision=5
 build_style=gnu-configure
 configure_args="--disable-update-mimedb"
 hostmakedepends="pkg-config intltool gettext synfig"

From 9ab60a79ffe87b853eff7697cc1c4ba99d9dc36d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:10 -0500
Subject: [PATCH 092/111] mixxx: revbump for ffmpeg6

---
 srcpkgs/mixxx/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mixxx/template b/srcpkgs/mixxx/template
index 6a79b328c1abf0..9a5141856860b9 100644
--- a/srcpkgs/mixxx/template
+++ b/srcpkgs/mixxx/template
@@ -1,7 +1,7 @@
 # Template file for 'mixxx'
 pkgname=mixxx
 version=2.3.3
-revision=7
+revision=8
 build_style=cmake
 configure_args="-DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="extra-cmake-modules pkg-config protobuf qt5-host-tools qt5-qmake"

From c4e98519015f09ba3180064b33553254ed89aedb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:28 -0500
Subject: [PATCH 093/111] musikcube: revbump for ffmpeg6

---
 srcpkgs/musikcube/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/musikcube/template b/srcpkgs/musikcube/template
index 8c4a51840859ec..fb60dd2049089a 100644
--- a/srcpkgs/musikcube/template
+++ b/srcpkgs/musikcube/template
@@ -1,7 +1,7 @@
 # Template file for 'musikcube'
 pkgname=musikcube
 version=3.0.0
-revision=3
+revision=4
 build_style=cmake
 make_cmd=make
 configure_args="-DNO_NCURSESW=1"

From 084f653aa3f7a88b6a12f682f096a605f98c0617 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:45 -0500
Subject: [PATCH 094/111] electron24: revbump for ffmpeg6

---
 srcpkgs/electron24/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron24/template b/srcpkgs/electron24/template
index 7b4e28812f483e..1ca93fde97a854 100644
--- a/srcpkgs/electron24/template
+++ b/srcpkgs/electron24/template
@@ -1,7 +1,7 @@
 # Template file for 'electron24'
 pkgname=electron24
 version=24.3.0
-revision=2
+revision=3
 _nodever=18.14.0
 _chromiumver=112.0.5615.165
 archs="x86_64* aarch64*"

From 7ac918e4b56a85d3ea4faf67a294322290b467af Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:00 -0500
Subject: [PATCH 095/111] electron19: revbump for ffmpeg6

---
 srcpkgs/electron19/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron19/template b/srcpkgs/electron19/template
index 0ef959125cb085..5371c0b354604f 100644
--- a/srcpkgs/electron19/template
+++ b/srcpkgs/electron19/template
@@ -1,7 +1,7 @@
 # Template file for 'electron19'
 pkgname=electron19
 version=19.0.8
-revision=4
+revision=5
 _nodever=16.14.2
 _chromiumver=102.0.5005.125
 archs="x86_64* aarch64* ppc64le*"

From a9b7d4407463ed068951ad3f83b58b385a6ac9f1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:13 -0500
Subject: [PATCH 096/111] wf-recorder: revbump for ffmpeg6

---
 srcpkgs/wf-recorder/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/wf-recorder/template b/srcpkgs/wf-recorder/template
index 08f986b0310067..63c45cf4b814d7 100644
--- a/srcpkgs/wf-recorder/template
+++ b/srcpkgs/wf-recorder/template
@@ -1,7 +1,7 @@
 # Template file for 'wf-recorder'
 pkgname=wf-recorder
 version=0.4.1
-revision=2
+revision=3
 build_style=meson
 hostmakedepends="pkg-config scdoc wayland-devel"
 makedepends="wayland-protocols wayland-devel ffmpeg-devel libgbm-devel x264-devel

From 1cf63ac832cd8dde718c8a7594bb39850575b43a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:26 -0500
Subject: [PATCH 097/111] obs: revbump for ffmpeg6

---
 srcpkgs/obs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/obs/template b/srcpkgs/obs/template
index b343f1131bfcf6..a25a67433e285e 100644
--- a/srcpkgs/obs/template
+++ b/srcpkgs/obs/template
@@ -1,7 +1,7 @@
 # Template file for 'obs'
 pkgname=obs
 version=30.0.0
-revision=2
+revision=3
 archs="i686* x86_64* ppc64le* aarch64* riscv64*"
 build_style=cmake
 configure_args="-DOBS_VERSION_OVERRIDE=${version} -DENABLE_JACK=ON

From c6d50981de942215048003eff8dcd243fb9ed8e9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:36 -0500
Subject: [PATCH 098/111] mlt7: revbump for ffmpeg6

---
 srcpkgs/mlt7/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mlt7/template b/srcpkgs/mlt7/template
index 98f302ad3a5167..7eb8c00fa1580c 100644
--- a/srcpkgs/mlt7/template
+++ b/srcpkgs/mlt7/template
@@ -1,7 +1,7 @@
 # Template file for 'mlt7'
 pkgname=mlt7
 version=7.20.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DSWIG_PYTHON=ON -DMOD_QT6=ON"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which

From 18129c3731379349dc361d61341025bb249cd9f1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:48 -0500
Subject: [PATCH 099/111] qt6-multimedia: revbump for ffmpeg6

---
 srcpkgs/qt6-multimedia/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-multimedia/template b/srcpkgs/qt6-multimedia/template
index 67a577e1300fea..1da626ecf515a8 100644
--- a/srcpkgs/qt6-multimedia/template
+++ b/srcpkgs/qt6-multimedia/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-multimedia'
 pkgname=qt6-multimedia
 version=6.6.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DQT_FEATURE_gstreamer=ON"
 hostmakedepends="perl qt6-declarative-host-tools pkg-config qt6-shadertools"

From a397392d4d20115234abce0985c2e7ea06974a41 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:00:15 -0500
Subject: [PATCH 100/111] baresip: revbump for ffmpeg6

---
 srcpkgs/baresip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/baresip/template b/srcpkgs/baresip/template
index 12c8954ef7b9b7..b16b67beab8d2b 100644
--- a/srcpkgs/baresip/template
+++ b/srcpkgs/baresip/template
@@ -1,7 +1,7 @@
 # Template file for 'baresip'
 pkgname=baresip
 version=3.6.0
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config glib-devel"
 makedepends="libgsm-devel libpng-devel openssl-devel libsndfile-devel

From 2f9cc85cd0a907a4b657aeb4db0384f53c97ad00 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:30 -0500
Subject: [PATCH 101/111] QMPlay2: revbump for ffmpeg6

---
 srcpkgs/QMPlay2/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/QMPlay2/template b/srcpkgs/QMPlay2/template
index 46c80f64a13497..942258ce60fb7e 100644
--- a/srcpkgs/QMPlay2/template
+++ b/srcpkgs/QMPlay2/template
@@ -1,7 +1,7 @@
 # Template file for 'QMPlay2'
 pkgname=QMPlay2
 version=23.10.22
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools"
 makedepends="alsa-lib-devel ffmpeg-devel libass-devel libcdio-devel libgme-devel

From 82cc22d5c5fd6ffc0eda7d5cbe71ea9bbba01325 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:34 -0500
Subject: [PATCH 102/111] alsa-plugins: revbump for ffmpeg6

---
 srcpkgs/alsa-plugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/alsa-plugins/template b/srcpkgs/alsa-plugins/template
index a5708a7d82a8f0..7bfdad046c4830 100644
--- a/srcpkgs/alsa-plugins/template
+++ b/srcpkgs/alsa-plugins/template
@@ -1,7 +1,7 @@
 # Template file for 'alsa-plugins'
 pkgname=alsa-plugins
 version=1.2.7.1
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--disable-maemo-plugin"
 hostmakedepends="pkg-config"

From 5140df21600b25e0336b11d18000a7a3af379204 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:43 -0500
Subject: [PATCH 103/111] minidlna: revbump for ffmpeg6

---
 srcpkgs/minidlna/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/minidlna/template b/srcpkgs/minidlna/template
index 5fa929f3a0c124..742991ecd04afc 100644
--- a/srcpkgs/minidlna/template
+++ b/srcpkgs/minidlna/template
@@ -1,7 +1,7 @@
 # Template file for 'minidlna'
 pkgname=minidlna
 version=1.3.3
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="
  --sbindir=/usr/bin

From ba34d769796686b7dd72f59b4fdf0f2492afe345 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 17:57:47 -0500
Subject: [PATCH 104/111] mpv: revbump for ffmpeg6

---
 srcpkgs/mpv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpv/template b/srcpkgs/mpv/template
index 3d4349e27d8f62..bc40d6fcaa40d6 100644
--- a/srcpkgs/mpv/template
+++ b/srcpkgs/mpv/template
@@ -1,7 +1,7 @@
 # Template file for 'mpv'
 pkgname=mpv
 version=0.37.0
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcdda=enabled -Ddvbin=enabled -Ddvdnav=enabled
  -Dlibmpv=true -Dcplugins=enabled

From a3efceb491d215581963a0af261dc3def2418b92 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 17:59:29 -0500
Subject: [PATCH 105/111] qimgv: revbump for ffmpeg6

---
 srcpkgs/qimgv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qimgv/template b/srcpkgs/qimgv/template
index dd341dfe1bfce8..8a7e1c081ef12f 100644
--- a/srcpkgs/qimgv/template
+++ b/srcpkgs/qimgv/template
@@ -1,7 +1,7 @@
 # Template file for 'qimgv'
 pkgname=qimgv
 version=1.0.2
-revision=3
+revision=4
 build_style=cmake
 configure_args="$(vopt_if video -DVIDEO_SUPPORT=ON -DVIDEO_SUPPORT=OFF)
  $(vopt_if scale -DOPENCV_SUPPORT=ON -DOPENCV_SUPPORT=OFF)

From 9a423ab801d6f8c7bff932038bd49858aea14063 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 18:00:36 -0500
Subject: [PATCH 106/111] kfilemetadata5: revbump for ffmpeg6

---
 srcpkgs/kfilemetadata5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kfilemetadata5/template b/srcpkgs/kfilemetadata5/template
index a0c4d809395323..b584f85ff2058b 100644
--- a/srcpkgs/kfilemetadata5/template
+++ b/srcpkgs/kfilemetadata5/template
@@ -1,7 +1,7 @@
 # Template file for 'kfilemetadata5'
 pkgname=kfilemetadata5
 version=5.115.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="kcoreaddons extra-cmake-modules pkg-config qt5-host-tools qt5-qmake
  gettext kcoreaddons python3"

From 961d4e34a83b3fd767c54872a054cec1c86edbc1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 8 Dec 2023 11:46:01 -0500
Subject: [PATCH 107/111] vba-m: revbump for ffmpeg6

---
 srcpkgs/vba-m/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vba-m/template b/srcpkgs/vba-m/template
index 3d135efa1d0b69..3c5a20db0fa984 100644
--- a/srcpkgs/vba-m/template
+++ b/srcpkgs/vba-m/template
@@ -2,7 +2,7 @@
 pkgname=vba-m
 reverts=1292_2
 version=2.1.9
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_GTK=TRUE -DENABLE_FFMPEG=TRUE -DENABLE_LINK=TRUE -DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="gettext pkg-config unzip zip yasm wxWidgets-gtk3-devel"

From 66af8caff9dadb04f5ae178e297376f1345e7600 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 8 Dec 2023 11:46:19 -0500
Subject: [PATCH 108/111] dolphin-emu: revbump for ffmpeg6

---
 srcpkgs/dolphin-emu/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/dolphin-emu/template b/srcpkgs/dolphin-emu/template
index 862d3ae964eec4..a7ae0efb58fb75 100644
--- a/srcpkgs/dolphin-emu/template
+++ b/srcpkgs/dolphin-emu/template
@@ -1,7 +1,7 @@
 # Template file for 'dolphin-emu'
 pkgname=dolphin-emu
 version=5.0.19368
-revision=3
+revision=4
 _dolphin_commit=dadbeb4bae7e7fa23af2b46e0add4143094dc107
 _mgba_commit=44e074a15e9651481f7f652ac006a7c9d58cbeb9
 _googletest_commit=be03d00f5f0cc3a997d1a368bee8a1fe93651f48

From d553cae15d87ee6c06b2c49ffac21129200c4172 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 19 Dec 2023 15:38:51 -0500
Subject: [PATCH 109/111] qtox: revbump for ffmpeg4

---
 srcpkgs/qtox/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtox/template b/srcpkgs/qtox/template
index bb70e7f51240a4..755e4462bc0137 100644
--- a/srcpkgs/qtox/template
+++ b/srcpkgs/qtox/template
@@ -1,13 +1,13 @@
 # Template file for 'qtox'
 pkgname=qtox
 version=1.17.6
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DUPDATE_CHECK=OFF
  -DGIT_DESCRIBE=${version}
  $(vopt_if snorenotify -DDESKTOP_NOTIFICATIONS=ON)"
 hostmakedepends="pkg-config qt5-host-tools qt5-devel"
-makedepends="ffmpeg-devel libexif-devel libopenal-devel libsodium-devel
+makedepends="ffmpeg4-devel libexif-devel libopenal-devel libsodium-devel
  libvpx-devel opus-devel qrencode-devel qt5-svg-devel sonnet-devel
  sqlcipher-devel toxcore-devel
  $(vopt_if snorenotify snorenotify-devel)"

From cd75e6785336a7c9146c702cc9b89334bfb29464 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 11 Jan 2024 11:52:00 -0500
Subject: [PATCH 110/111] arcan: revbump for ffmpeg6

---
 srcpkgs/arcan/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/arcan/template b/srcpkgs/arcan/template
index ff9091f90ebb10..030091a6cc9d0c 100644
--- a/srcpkgs/arcan/template
+++ b/srcpkgs/arcan/template
@@ -2,7 +2,7 @@
 # !! keep synced with: acfgfs aclip aloadimage
 pkgname=arcan
 version=0.6.2.1
-revision=2
+revision=3
 create_wrksrc=yes
 build_wrksrc=arcan/src
 build_style=cmake

From dc69e878b1914e41bb68f4c822c0a0cf6ec06771 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 11 Jan 2024 11:52:10 -0500
Subject: [PATCH 111/111] notcurses: revbump for ffmpeg6

---
 srcpkgs/notcurses/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/notcurses/template b/srcpkgs/notcurses/template
index 48a7463cb68eb9..515f316ab4576c 100644
--- a/srcpkgs/notcurses/template
+++ b/srcpkgs/notcurses/template
@@ -1,7 +1,7 @@
 # Template file for 'notcurses'
 pkgname=notcurses
 version=3.0.9
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DUSE_STATIC=ON -DUSE_QRCODEGEN=On $(vopt_bool man USE_PANDOC)"
 hostmakedepends="pkg-config $(vopt_if man pandoc)"

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (71 preceding siblings ...)
  2024-02-25 17:32 ` [PR PATCH] [Updated] " zlice
@ 2024-02-25 17:33 ` zlice
  2024-02-25 19:08 ` yoshiyoshyosh
                   ` (24 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2024-02-25 17:33 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 288 bytes --]

New comment by zlice on void-packages repository

https://github.com/void-linux/void-packages/pull/43761#issuecomment-1963008208

Comment:
> vice and idjc work well

@yoshiyoshyosh would you mind making PRs to update vice/idjc version since you tested them? then i'll bump them in here

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (72 preceding siblings ...)
  2024-02-25 17:33 ` zlice
@ 2024-02-25 19:08 ` yoshiyoshyosh
  2024-02-25 19:08 ` yoshiyoshyosh
                   ` (23 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: yoshiyoshyosh @ 2024-02-25 19:08 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 421 bytes --]

New comment by yoshiyoshyosh on void-packages repository

https://github.com/void-linux/void-packages/pull/43761#issuecomment-1963032178

Comment:
> @yoshiyoshyosh would you mind making PRs to update vice/idjc version since you tested them? then i'll bump them in here

@zlice sounds good. also, I figured out something with libextractor: it doesn't need ffmpeg anymore with the latest versions. can also make a pr to 

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (73 preceding siblings ...)
  2024-02-25 19:08 ` yoshiyoshyosh
@ 2024-02-25 19:08 ` yoshiyoshyosh
  2024-02-25 19:09 ` yoshiyoshyosh
                   ` (22 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: yoshiyoshyosh @ 2024-02-25 19:08 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 445 bytes --]

New comment by yoshiyoshyosh on void-packages repository

https://github.com/void-linux/void-packages/pull/43761#issuecomment-1963032178

Comment:
> @yoshiyoshyosh would you mind making PRs to update vice/idjc version since you tested them? then i'll bump them in here

@zlice sounds good. also, I figured out something with libextractor: it doesn't need ffmpeg or its library anymore with the latest versions. can also make a pr to update it

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (74 preceding siblings ...)
  2024-02-25 19:08 ` yoshiyoshyosh
@ 2024-02-25 19:09 ` yoshiyoshyosh
  2024-02-25 19:09 ` yoshiyoshyosh
                   ` (21 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: yoshiyoshyosh @ 2024-02-25 19:09 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 481 bytes --]

New comment by yoshiyoshyosh on void-packages repository

https://github.com/void-linux/void-packages/pull/43761#issuecomment-1963032178

Comment:
> @yoshiyoshyosh would you mind making PRs to update vice/idjc version since you tested them? then i'll bump them in here

@zlice sounds good. also, I figured out something with libextractor: it doesn't need ffmpeg or its library anymore with the latest versions. can also make a pr to update it and you can remove the revbump here

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (75 preceding siblings ...)
  2024-02-25 19:09 ` yoshiyoshyosh
@ 2024-02-25 19:09 ` yoshiyoshyosh
  2024-02-25 19:28 ` yoshiyoshyosh
                   ` (20 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: yoshiyoshyosh @ 2024-02-25 19:09 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 500 bytes --]

New comment by yoshiyoshyosh on void-packages repository

https://github.com/void-linux/void-packages/pull/43761#issuecomment-1963032178

Comment:
> @yoshiyoshyosh would you mind making PRs to update vice/idjc version since you tested them? then i'll bump them in here

@zlice sounds good. also, I figured out something with libextractor: it doesn't need ffmpeg or any of ffmpeg's core libraries anymore with the latest versions. can also make a pr to update it and you can remove the revbump here

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (76 preceding siblings ...)
  2024-02-25 19:09 ` yoshiyoshyosh
@ 2024-02-25 19:28 ` yoshiyoshyosh
  2024-02-25 19:28 ` zlice
                   ` (19 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: yoshiyoshyosh @ 2024-02-25 19:28 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 552 bytes --]

New comment by yoshiyoshyosh on void-packages repository

https://github.com/void-linux/void-packages/pull/43761#issuecomment-1963032178

Comment:
> @yoshiyoshyosh would you mind making PRs to update vice/idjc version since you tested them? then i'll bump them in here

@zlice sounds good. also, I figured out something with libextractor: it doesn't need ffmpeg or any of ffmpeg's core libraries anymore with the latest versions (commit `2332716ae48d6b899e4d2bb07f468e8c076d2608`). can also make a pr to update it and you can remove the revbump here

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (77 preceding siblings ...)
  2024-02-25 19:28 ` yoshiyoshyosh
@ 2024-02-25 19:28 ` zlice
  2024-02-25 19:32 ` yoshiyoshyosh
                   ` (18 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2024-02-25 19:28 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 299 bytes --]

New comment by zlice on void-packages repository

https://github.com/void-linux/void-packages/pull/43761#issuecomment-1963037297

Comment:
must be why it built lol. odd, they removed it and didn't replace it with anything so opus and thumbnails are gone? only thing that uses it is `gnunet`. thanks

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (78 preceding siblings ...)
  2024-02-25 19:28 ` zlice
@ 2024-02-25 19:32 ` yoshiyoshyosh
  2024-02-25 19:33 ` yoshiyoshyosh
                   ` (17 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: yoshiyoshyosh @ 2024-02-25 19:32 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 267 bytes --]

New comment by yoshiyoshyosh on void-packages repository

https://github.com/void-linux/void-packages/pull/43761#issuecomment-1963038302

Comment:
> so opus and thumbnails are gone?
yup. I think it's just a symptom of being really old and half-abandoned by now haha

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (79 preceding siblings ...)
  2024-02-25 19:32 ` yoshiyoshyosh
@ 2024-02-25 19:33 ` yoshiyoshyosh
  2024-02-25 20:20 ` yoshiyoshyosh
                   ` (16 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: yoshiyoshyosh @ 2024-02-25 19:33 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 277 bytes --]

New comment by yoshiyoshyosh on void-packages repository

https://github.com/void-linux/void-packages/pull/43761#issuecomment-1963038302

Comment:
> so opus and [video] thumbnails are gone?

yup. I think it's just a symptom of being really old and half-abandoned by now haha

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (80 preceding siblings ...)
  2024-02-25 19:33 ` yoshiyoshyosh
@ 2024-02-25 20:20 ` yoshiyoshyosh
  2024-02-25 21:45 ` yoshiyoshyosh
                   ` (15 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: yoshiyoshyosh @ 2024-02-25 20:20 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 375 bytes --]

New comment by yoshiyoshyosh on void-packages repository

https://github.com/void-linux/void-packages/pull/43761#issuecomment-1963038302

Comment:
> so opus and [video] thumbnails are gone?

~~yup. I think it's just a symptom of being really old and half-abandoned by now haha~~

actually, they use gstreamer now, so opus is still there. video thumbnails are gone though

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (81 preceding siblings ...)
  2024-02-25 20:20 ` yoshiyoshyosh
@ 2024-02-25 21:45 ` yoshiyoshyosh
  2024-02-25 21:58 ` yoshiyoshyosh
                   ` (14 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: yoshiyoshyosh @ 2024-02-25 21:45 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 239 bytes --]

New comment by yoshiyoshyosh on void-packages repository

https://github.com/void-linux/void-packages/pull/43761#issuecomment-1963071384

Comment:
also, it seems like the latest idjc versions can build and run with ffmpeg6 perfectly fine.

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (82 preceding siblings ...)
  2024-02-25 21:45 ` yoshiyoshyosh
@ 2024-02-25 21:58 ` yoshiyoshyosh
  2024-03-01 15:58 ` [PR PATCH] [Updated] " zlice
                   ` (13 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: yoshiyoshyosh @ 2024-02-25 21:58 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 427 bytes --]

New comment by yoshiyoshyosh on void-packages repository

https://github.com/void-linux/void-packages/pull/43761#issuecomment-1963071384

Comment:
it seems like the latest idjc versions can build and run the ffmpeg-required portions with ffmpeg6 perfectly fine.

it's almost the same with vice? they started using the ffmpeg executable as a fork rather than relying on the library functions. h264 encoding works but not h265

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (83 preceding siblings ...)
  2024-02-25 21:58 ` yoshiyoshyosh
@ 2024-03-01 15:58 ` zlice
  2024-03-06 21:24 ` zlice
                   ` (12 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2024-03-01 15:58 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 4903 bytes --]

There is an updated pull request by zlice against master on the void-packages repository

https://github.com/zlice/void-packages ffmpeg6-split
https://github.com/void-linux/void-packages/pull/43761

ffmpeg6 split
[ci skip]


#### Testing the changes

- I tested the changes in this PR: **YES**

main testing has been vaapi in Firefox Nightly and enc/dec in Shotcut on Intel A770

#### New package

- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**

#### Local build testing

- I built this PR locally for my native architecture, **x86_64**

#### Discussion

Continuation of https://github.com/void-linux/void-packages/pull/36315

`libavresample` is deprecated, but marked as a dependency when trying to build other packages and install `ffmpeg`(6). I think the right way to handle this is make a meta package and the add to removals?


##### Commit naming / misc

~~Commits are 'dirty' right now, running with [gstreamer 1.22.1 updates](https://github.com/void-linux/void-packages/pull/42861) and [Intel OpenCL](https://github.com/void-linux/void-packages/pull/43084). This will also make [intel packages pr](https://github.com/void-linux/void-packages/pull/41132) obsolete.~~ (see Requirements below)

Maintainer for previous ffmpeg(4) was orphaned, I can put my name in there if that matters, though I don't exactly see myself keeping up on ffmpeg.

~~This updates QT5 which looks like it is usually hosted by Johnny. Not sure if there's any reason to stay there or these sources are fine.~~ Using qt5.15.11 now, revbumps and some patches.

##### STILL FFMPEG4

These are a mix of emulators, games and/or older packages.

- ~~attract~~ (2.7 builds)
- ~~audacity (https://github.com/audacity/audacity/issues/2305 and https://sourceforge.net/p/portmedia/wiki/portsmf/ is 'beta')~~ (updated to 3.x, compiles with ffmpeg6)
- ~~ccextractor~~ (master patches)
- vice (3.8 compiles, needs makedepends libcurl-devel)
- kodi
- mlt (only dep left is flowblade - flowblade 2.12.0.2 with mlt7-python3 can 'render' videos with cpu and gpu - https://github.com/void-linux/void-packages/pull/47195)
- ~~synfig (mlt)~~ (work with mlt7, bump synfigstudio)
- tvheadend (download page recommends using 4.3 which compiles fine, 4.4 eta is Q1 2024)
- ~~ssr~~ (patches)
- ~~spek-alternative~~ (replace with spek-x)
- ~~ppsspp~~ ~~(1.17.1 is out, but there's 5+ distfiles that are all git commits)~~ (minor patch)
- olive (has been in alpha since 2020, seems they do nightly builds and appimages)
- moc
- mediastreamer (linphone links are dead, changed to github belladonne. their stuff never worked for me but there are updates if someone wants to give it a try)
- libextractor (1.13 compiles, remove exiv2 patch)
- idjc (0.9.8 compiles, remove python3.10 patch, needs makedepends libebur128-devel and libshout-idjc 2.4.6 with '-r1' for distfile)
- hedgewars
- ~~ffmpegthumbnailer~~ (patches for moviedecoder.xxx files)
- ~~ffmpegthumbs~~ (latest compiles)
- deadbeef (1.9.6 may work but requires libdispatch from apple)
- ~~omxplayer~~ (package removed, deprecated in favor of vlc)
- qtav (fork has ffmpeg 5 patch - https://github.com/cmguo/QtAV)
- `vlc` (vlc4 will support ffmpeg5, there's a patch to build 3.x with ffmpeg5 but it will lack vaapi)
- `osg` (OpenSceneGraph plus `xine-lib`)


##### HAVE NOT BUILT YET

- ~~omxplayer (rpi only? ffmpeg4)~~ (removed)
- kodi (big, but ffmpeg4)


##### UPDATED (for ffmpeg6)

- ~~blender: update to 3.5.1~~ ~~will be revbump with~~ https://github.com/void-linux/void-packages/pull/43992
- unpaper: update to 7.0.0.
- guvcview: update to 2.0.8.
- ~~qt5: update to 5.15.8~~ updated by another PR to 5.15.11
- ~~qt5-webengine: update to 5.18.15~~ updated by another PR to 5.15.16 (some patching for ffmpeg build)
- ~~shiboken2: revbump for qt5.15.8 (patch)~~ updated by another PR to 5.15.10
- ~~python3-pyside2: update to 5.15.8 (patch)~~ updated by another PR to 5.15.10
- New package: spex-x replaces spek-alternative for ffmpeg-6.0


##### Requirements

- ~~[gstreamer 1.22.2](https://github.com/void-linux/void-packages/pull/42861)~~ - a few packages use ffmpeg-devel and require a revbump

- ~~[Intel Packages](https://github.com/void-linux/void-packages/pull/41132) [Intel Packages v2](https://github.com/void-linux/void-packages/pull/47330) - ffmpeg4 uses different libraries than 6 (libmfx / Intel-MediaSDK vs only oneVPL that Intel is moving to), both are included here~~. Using replacement oneVPL from OBS update.

- ~~[shotcut 23.05.14](https://github.com/void-linux/void-packages/pull/44260)~~

- https://github.com/void-linux/void-packages/pull/44781 will remove from this PR

A patch file from https://github.com/void-linux/void-packages/pull/43761.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ffmpeg6-split-43761.patch --]
[-- Type: text/x-diff, Size: 241077 bytes --]

From 3fd2f71d669859d3e5061db210645ade262d1923 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:16:56 -0400
Subject: [PATCH 001/110] ffmpeg: update to 6.0.1.

---
 common/shlibs                                 | 26 ++++---
 srcpkgs/ffmpeg/files/altivec.patch            | 60 ---------------
 .../patches/armv5tel-floating-point.patch     | 18 -----
 srcpkgs/ffmpeg/patches/binutils-2.41.patch    | 73 -------------------
 ...h-libavcodec-libsvtav1-ten_bit_format.diff | 40 ----------
 .../workaround-mesa-readeon-vaapi-bug.patch   | 28 -------
 srcpkgs/ffmpeg/template                       | 40 +++++-----
 7 files changed, 37 insertions(+), 248 deletions(-)
 delete mode 100644 srcpkgs/ffmpeg/files/altivec.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/binutils-2.41.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 delete mode 100644 srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch

diff --git a/common/shlibs b/common/shlibs
index 44c8b34a3482ea..d87b3be06a6dc6 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -389,15 +389,23 @@ libid3tag.so.0 libid3tag-0.15.1b_1
 libgif.so.7 giflib-5.1.0_1
 libImlib2.so.1 imlib2-1.4.2_1
 libmp3lame.so.0 lame-3.98.2_1
-libavdevice.so.58 libavdevice-4.0_1
-libavformat.so.58 libavformat-4.0_1
-libswscale.so.5 libswscale-4.0_1
-libswresample.so.3 libswresample-4.0_1
-libavresample.so.4 libavresample-4.0_1
-libpostproc.so.55 libpostproc-4.0_1
-libavcodec.so.58 libavcodec-4.0_1
-libavutil.so.56 libavutil-4.0_1
-libavfilter.so.7 libavfilter-4.0_1
+libavdevice.so.60 libavdevice-6.0_1
+libavformat.so.60 libavformat-6.0_1
+libswscale.so.7 libswscale-6.0_1
+libswresample.so.4 libswresample-6.0_1
+libpostproc.so.57 libpostproc-6.0_1
+libavcodec.so.60 libavcodec-6.0_1
+libavutil.so.58 libavutil-6.0_1
+libavfilter.so.9 libavfilter-6.0_1
+libavdevice.so.58 libavdevice4-4.0_1
+libavformat.so.58 libavformat4-4.0_1
+libswscale.so.5 libswscale4-4.0_1
+libswresample.so.3 libswresample4-4.0_1
+libavresample.so.4 libavresample4-4.0_1
+libpostproc.so.55 libpostproc4-4.0_1
+libavcodec.so.58 libavcodec4-4.0_1
+libavutil.so.56 libavutil4-4.0_1
+libavfilter.so.7 libavfilter4-4.0_1
 libSDL-1.2.so.0 SDL-1.2.14_1
 libSDL_image-1.2.so.0 SDL_image-1.2.10_1
 libx264.so.157 x264-20190507.2245_1
diff --git a/srcpkgs/ffmpeg/files/altivec.patch b/srcpkgs/ffmpeg/files/altivec.patch
deleted file mode 100644
index 9c57200463320e..00000000000000
--- a/srcpkgs/ffmpeg/files/altivec.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-revert some altivec specific change on all ppc* except ppc64le*
-
-q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
-conditionally, for ppc* but not ppc64le* (the new code is valid for
-POWER8 VSX which LE targets as a baseline but not BE)"
-
-
-This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
----
- libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
- 1 file changed, 20 insertions(+), 4 deletions(-)
-
-diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
-index 536545293d..c1e2852adb 100644
---- a/libswscale/ppc/yuv2rgb_altivec.c
-+++ b/libswscale/ppc/yuv2rgb_altivec.c
-@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-     vector signed short R1, G1, B1;                                           \
-     vector unsigned char R, G, B;                                             \
-                                                                               \
-+    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
-+    vector unsigned char align_perm;                                          \
-+                                                                              \
-     vector signed short lCY       = c->CY;                                    \
-     vector signed short lOY       = c->OY;                                    \
-     vector signed short lCRV      = c->CRV;                                   \
-@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
-                                                                               \
-         for (j = 0; j < w / 16; j++) {                                        \
--            y0 = vec_xl(0, y1i);                                              \
-+            y1ivP = (const vector unsigned char *) y1i;                       \
-+            y2ivP = (const vector unsigned char *) y2i;                       \
-+            uivP  = (const vector unsigned char *) ui;                        \
-+            vivP  = (const vector unsigned char *) vi;                        \
-+                                                                              \
-+            align_perm = vec_lvsl(0, y1i);                                    \
-+            y0 = (vector unsigned char)                                       \
-+                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
-                                                                               \
--            y1 = vec_xl(0, y2i);                                              \
-+            align_perm = vec_lvsl(0, y2i);                                    \
-+            y1 = (vector unsigned char)                                       \
-+                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
-                                                                               \
--            u = (vector signed char) vec_xl(0, ui);                           \
-+            align_perm = vec_lvsl(0, ui);                                     \
-+            u = (vector signed char)                                          \
-+                    vec_perm(uivP[0], uivP[1], align_perm);                   \
-                                                                               \
--            v = (vector signed char) vec_xl(0, vi);                           \
-+            align_perm = vec_lvsl(0, vi);                                     \
-+            v = (vector signed char)                                          \
-+                    vec_perm(vivP[0], vivP[1], align_perm);                   \
-                                                                               \
-             u = (vector signed char)                                          \
-                     vec_sub(u,                                                \
--- 
-2.27.0
-
diff --git a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
deleted file mode 100644
index 9a55178c74f0fd..00000000000000
--- a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
-+++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
-@@ -39,6 +39,15 @@
- #endif
- #include <fenv.h>
- 
-+#if (FE_ALL_EXCEPT == 0)
-+/* E.g. ARM soft float does not define these */
-+#define FE_INVALID    0
-+#define FE_DIVBYZERO  0
-+#define FE_OVERFLOW   0
-+#define FE_UNDERFLOW  0
-+#define FE_INEXACT    0
-+#endif
-+
- #if CONFIG_LIBFONTCONFIG
- #include <fontconfig/fontconfig.h>
- #endif
diff --git a/srcpkgs/ffmpeg/patches/binutils-2.41.patch b/srcpkgs/ffmpeg/patches/binutils-2.41.patch
deleted file mode 100644
index 53a596d0ee7d4e..00000000000000
--- a/srcpkgs/ffmpeg/patches/binutils-2.41.patch
+++ /dev/null
@@ -1,73 +0,0 @@
-From effadce6c756247ea8bae32dc13bb3e6f464f0eb Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= <remi@remlab.net>
-Date: Sun, 16 Jul 2023 18:18:02 +0300
-Subject: [PATCH] avcodec/x86/mathops: clip constants used with shift
- instructions within inline assembly
-
-Fixes assembling with binutil as >= 2.41
-
-Signed-off-by: James Almer <jamrial@gmail.com>
----
- libavcodec/x86/mathops.h | 26 +++++++++++++++++++++++---
- 1 file changed, 23 insertions(+), 3 deletions(-)
-
-diff --git a/libavcodec/x86/mathops.h b/libavcodec/x86/mathops.h
-index 6298f5ed1983b..ca7e2dffc1076 100644
---- a/libavcodec/x86/mathops.h
-+++ b/libavcodec/x86/mathops.h
-@@ -35,12 +35,20 @@
- static av_always_inline av_const int MULL(int a, int b, unsigned shift)
- {
-     int rt, dummy;
-+    if (__builtin_constant_p(shift))
-     __asm__ (
-         "imull %3               \n\t"
-         "shrdl %4, %%edx, %%eax \n\t"
-         :"=a"(rt), "=d"(dummy)
--        :"a"(a), "rm"(b), "ci"((uint8_t)shift)
-+        :"a"(a), "rm"(b), "i"(shift & 0x1F)
-     );
-+    else
-+        __asm__ (
-+            "imull %3               \n\t"
-+            "shrdl %4, %%edx, %%eax \n\t"
-+            :"=a"(rt), "=d"(dummy)
-+            :"a"(a), "rm"(b), "c"((uint8_t)shift)
-+        );
-     return rt;
- }
- 
-@@ -113,19 +121,31 @@ __asm__ volatile(\
- // avoid +32 for shift optimization (gcc should do that ...)
- #define NEG_SSR32 NEG_SSR32
- static inline  int32_t NEG_SSR32( int32_t a, int8_t s){
-+    if (__builtin_constant_p(s))
-     __asm__ ("sarl %1, %0\n\t"
-          : "+r" (a)
--         : "ic" ((uint8_t)(-s))
-+         : "i" (-s & 0x1F)
-     );
-+    else
-+        __asm__ ("sarl %1, %0\n\t"
-+               : "+r" (a)
-+               : "c" ((uint8_t)(-s))
-+        );
-     return a;
- }
- 
- #define NEG_USR32 NEG_USR32
- static inline uint32_t NEG_USR32(uint32_t a, int8_t s){
-+    if (__builtin_constant_p(s))
-     __asm__ ("shrl %1, %0\n\t"
-          : "+r" (a)
--         : "ic" ((uint8_t)(-s))
-+         : "i" (-s & 0x1F)
-     );
-+    else
-+        __asm__ ("shrl %1, %0\n\t"
-+               : "+r" (a)
-+               : "c" ((uint8_t)(-s))
-+        );
-     return a;
- }
- 
diff --git a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
deleted file mode 100644
index aa948f7a8a2dfb..00000000000000
--- a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
+++ /dev/null
@@ -1,40 +0,0 @@
-#==================================================================================================
-# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
-# From: Christopher Degawa <christopher.degawa@intel.com>
-# Date: Thu, 20 Oct 2022 22:55:27 -0500
-# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
-#
-# compressed_ten_bit_format has been deprecated upstream and has no effect
-# and can be removed. Plus, technically it was never used in the first place
-# since it would require the app (ffmpeg) to set it and do additional
-# processing of the input frames.
-#
-# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
-#
-# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
-#==================================================================================================
---- a/libavcodec/libsvtav1.c
-+++ b/libavcodec/libsvtav1.c
-@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
- 
- static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
- {
--    const int    pack_mode_10bit =
--        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
--    const size_t luma_size_8bit  =
--        config->source_width * config->source_height * (1 << pack_mode_10bit);
--    const size_t luma_size_10bit =
--        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
-+    const size_t luma_size = config->source_width * config->source_height *
-+        (config->encoder_bit_depth > 8 ? 2 : 1);
- 
-     EbSvtIOFormat *in_data;
- 
--    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
-+    svt_enc->raw_size = luma_size * 3 / 2;
- 
-     // allocate buffer for in and out
-     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
--- 
-GitLab
-
diff --git a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
deleted file mode 100644
index 00e3f68a415b84..00000000000000
--- a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
-From: Rainer Hochecker <fernetmenta@online.de>
-Date: Sat, 26 Jan 2019 19:48:35 +0100
-Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
-
-This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
-It was hit frequently when watching h264 channels received via DVB-X.
-Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
----
- libavcodec/vaapi_h264.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
-index 5854587a255..f12fdc457a4 100644
---- a/libavcodec/vaapi_h264.c
-+++ b/libavcodec/vaapi_h264.c
-@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
-     H264SliceContext *sl = &h->slice_ctx[0];
-     int ret;
- 
-+    if (pic->nb_slices == 0) {
-+        ret = AVERROR_INVALIDDATA;
-+        goto finish;
-+    }
-+
-     ret = ff_vaapi_decode_issue(avctx, pic);
-     if (ret < 0)
-         goto finish;
diff --git a/srcpkgs/ffmpeg/template b/srcpkgs/ffmpeg/template
index 1ebb436135938d..f1e4712c41d087 100644
--- a/srcpkgs/ffmpeg/template
+++ b/srcpkgs/ffmpeg/template
@@ -1,15 +1,15 @@
 # Template file for 'ffmpeg'
 # audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
 pkgname=ffmpeg
-version=4.4.4
-revision=6
+version=6.0.1
+revision=1
 short_desc="Decoding, encoding and streaming software"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="https://www.ffmpeg.org"
 changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
 distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
-checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+checksum=9b16b8731d78e596b4be0d720428ca42df642bb2d78342881ff7f5bc29fc9623
 
 hostmakedepends="pkg-config perl"
 makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
@@ -26,12 +26,13 @@ makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-deve
  $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
  $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
  $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
- $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers Vulkan-Tools Vulkan-ValidationLayers')
+ $(vopt_if onevpl 'oneVPL oneVPL-devel')
  $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
 depends="ffplay>=${version}_${revision}"
 
 build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
- dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec onevpl"
 build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
 desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
 desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
@@ -39,9 +40,13 @@ desc_option_sofa="Enable support for AES SOFA"
 desc_option_webp="Enable support for WebP"
 
 case "$XBPS_TARGET_MACHINE" in
-	i686*|x86_64*)
-		hostmakedepends+=" nasm"
+	i686*)
 		build_options_default+=" vaapi vdpau nvenc nvdec"
+		hostmakedepends+=" nasm"
+		;;
+	x86_64*)
+		hostmakedepends+=" nasm"
+		build_options_default+=" vaapi vdpau nvenc nvdec onevpl"
 		;;
 	ppc64*) build_options_default+=" vaapi vdpau";;
 	mips*) CFLAGS="-mnan=legacy";;
@@ -65,8 +70,6 @@ post_patch() {
 		ppc64le*) ;;
 		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
 	esac
-
-	vsed -i libavfilter/vf_libvmaf.c -e 's!/usr/local/share/model/\(vmaf_v0.6.1\).pkl!/usr/share/vmaf/\1.json!'
 }
 
 do_configure() {
@@ -115,18 +118,19 @@ do_configure() {
 		$(vopt_enable x265 libx265) \
 		$(vopt_enable v4l2 libv4l2) \
 		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
-		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		--enable-libbs2b --enable-libvidstab \
 		$(vopt_enable dav1d libdav1d) \
 		$(vopt_enable zimg libzimg) \
 		$(vopt_enable webp libwebp) \
 		$(vopt_enable sofa libmysofa) \
 		$(vopt_enable vulkan) \
+		$(vopt_enable onevpl libvpl) \
 		$(vopt_enable drm libdrm) \
 		$(vopt_enable svtav1 libsvtav1) \
 		$(vopt_enable srt libsrt) \
 		$(vopt_enable rist librist) \
-		$(vopt_if nvenc '--enable-nvenc') \
-		$(vopt_if nvdec '--enable-nvdec')
+		$(vopt_enable nvenc nvenc) \
+		$(vopt_enable nvdec nvdec)
 }
 
 do_build() {
@@ -153,10 +157,8 @@ libavdevice_package() {
 }
 
 libavresample_package() {
-	short_desc="FFmpeg audio resampling library"
-	pkg_install() {
-		vmove "usr/lib/libavresample.so.*"
-	}
+	short_desc="Package deprecated, removal needed"
+	build_style=meta
 }
 
 libavformat_package() {
@@ -210,15 +212,13 @@ ffmpeg-devel_package() {
 		libavfilter>=${version}_${revision}
 		libpostproc>=${version}_${revision}
 		libswscale>=${version}_${revision}
-		libswresample>=${version}_${revision}
-		libavresample>=${version}_${revision}"
+		libswresample>=${version}_${revision}"
 	short_desc+=" - development files"
-
+	conflicts="ffmpeg4-devel"
 	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
 		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
 		nostrip_files="/usr/lib/libavfilter.a"
 	fi
-
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig

From c2547f703ccaa5ac983ae0288f9c0f30a51bdfdd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:14 -0400
Subject: [PATCH 002/110] openshot: revbump for ffmpeg6

---
 srcpkgs/openshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openshot/template b/srcpkgs/openshot/template
index 3849858fe963b5..12789bc9867499 100644
--- a/srcpkgs/openshot/template
+++ b/srcpkgs/openshot/template
@@ -1,7 +1,7 @@
 # Template file for 'openshot'
 pkgname=openshot
 version=3.1.1
-revision=1
+revision=2
 build_style=python3-module
 hostmakedepends="python3 python3-setuptools"
 makedepends="ffmpeg-devel python3-PyQt5"

From e6e718e68ed0f82f03adaf990092f544092cbc68 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:36 -0400
Subject: [PATCH 003/110] sumo: revbump for ffmpeg6

---
 srcpkgs/sumo/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/sumo/template b/srcpkgs/sumo/template
index a730afa9fafa92..e2def06fa4bd7d 100644
--- a/srcpkgs/sumo/template
+++ b/srcpkgs/sumo/template
@@ -1,7 +1,7 @@
 # Template file for 'sumo'
 pkgname=sumo
 version=1.12.0
-revision=7
+revision=8
 build_style=cmake
 hostmakedepends="libgdal-tools pkg-config swig python3-setuptools"
 makedepends="python3-devel ffmpeg-devel fox-devel gl2ps-devel libgdal-devel

From 49a0c6befc4fe3b7dcd247ad68a62b5a18939c22 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:56:22 -0400
Subject: [PATCH 004/110] New package: ffmpeg4-4.4.4.

---
 srcpkgs/ffmpeg4-devel                         |   1 +
 srcpkgs/ffmpeg4/files/altivec.patch           |  60 +++++
 .../patches/armv5tel-floating-point.patch     |  18 ++
 srcpkgs/ffmpeg4/patches/binutils-2.41.patch   |  73 ++++++
 ...h-libavcodec-libsvtav1-ten_bit_format.diff |  40 +++
 .../workaround-mesa-readeon-vaapi-bug.patch   |  28 +++
 srcpkgs/ffmpeg4/template                      | 234 ++++++++++++++++++
 srcpkgs/libavcodec4                           |   1 +
 srcpkgs/libavdevice4                          |   1 +
 srcpkgs/libavfilter4                          |   1 +
 srcpkgs/libavformat4                          |   1 +
 srcpkgs/libavresample4                        |   1 +
 srcpkgs/libavutil4                            |   1 +
 srcpkgs/libpostproc4                          |   1 +
 srcpkgs/libswresample4                        |   1 +
 srcpkgs/libswscale4                           |   1 +
 16 files changed, 463 insertions(+)
 create mode 120000 srcpkgs/ffmpeg4-devel
 create mode 100644 srcpkgs/ffmpeg4/files/altivec.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/binutils-2.41.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 create mode 100644 srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
 create mode 100644 srcpkgs/ffmpeg4/template
 create mode 120000 srcpkgs/libavcodec4
 create mode 120000 srcpkgs/libavdevice4
 create mode 120000 srcpkgs/libavfilter4
 create mode 120000 srcpkgs/libavformat4
 create mode 120000 srcpkgs/libavresample4
 create mode 120000 srcpkgs/libavutil4
 create mode 120000 srcpkgs/libpostproc4
 create mode 120000 srcpkgs/libswresample4
 create mode 120000 srcpkgs/libswscale4

diff --git a/srcpkgs/ffmpeg4-devel b/srcpkgs/ffmpeg4-devel
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/ffmpeg4-devel
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/ffmpeg4/files/altivec.patch b/srcpkgs/ffmpeg4/files/altivec.patch
new file mode 100644
index 00000000000000..9c57200463320e
--- /dev/null
+++ b/srcpkgs/ffmpeg4/files/altivec.patch
@@ -0,0 +1,60 @@
+revert some altivec specific change on all ppc* except ppc64le*
+
+q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
+conditionally, for ppc* but not ppc64le* (the new code is valid for
+POWER8 VSX which LE targets as a baseline but not BE)"
+
+
+This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
+---
+ libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
+ 1 file changed, 20 insertions(+), 4 deletions(-)
+
+diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
+index 536545293d..c1e2852adb 100644
+--- a/libswscale/ppc/yuv2rgb_altivec.c
++++ b/libswscale/ppc/yuv2rgb_altivec.c
+@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+     vector signed short R1, G1, B1;                                           \
+     vector unsigned char R, G, B;                                             \
+                                                                               \
++    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
++    vector unsigned char align_perm;                                          \
++                                                                              \
+     vector signed short lCY       = c->CY;                                    \
+     vector signed short lOY       = c->OY;                                    \
+     vector signed short lCRV      = c->CRV;                                   \
+@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
+                                                                               \
+         for (j = 0; j < w / 16; j++) {                                        \
+-            y0 = vec_xl(0, y1i);                                              \
++            y1ivP = (const vector unsigned char *) y1i;                       \
++            y2ivP = (const vector unsigned char *) y2i;                       \
++            uivP  = (const vector unsigned char *) ui;                        \
++            vivP  = (const vector unsigned char *) vi;                        \
++                                                                              \
++            align_perm = vec_lvsl(0, y1i);                                    \
++            y0 = (vector unsigned char)                                       \
++                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
+                                                                               \
+-            y1 = vec_xl(0, y2i);                                              \
++            align_perm = vec_lvsl(0, y2i);                                    \
++            y1 = (vector unsigned char)                                       \
++                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
+                                                                               \
+-            u = (vector signed char) vec_xl(0, ui);                           \
++            align_perm = vec_lvsl(0, ui);                                     \
++            u = (vector signed char)                                          \
++                    vec_perm(uivP[0], uivP[1], align_perm);                   \
+                                                                               \
+-            v = (vector signed char) vec_xl(0, vi);                           \
++            align_perm = vec_lvsl(0, vi);                                     \
++            v = (vector signed char)                                          \
++                    vec_perm(vivP[0], vivP[1], align_perm);                   \
+                                                                               \
+             u = (vector signed char)                                          \
+                     vec_sub(u,                                                \
+-- 
+2.27.0
+
diff --git a/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
new file mode 100644
index 00000000000000..9a55178c74f0fd
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
@@ -0,0 +1,18 @@
+--- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
++++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
+@@ -39,6 +39,15 @@
+ #endif
+ #include <fenv.h>
+ 
++#if (FE_ALL_EXCEPT == 0)
++/* E.g. ARM soft float does not define these */
++#define FE_INVALID    0
++#define FE_DIVBYZERO  0
++#define FE_OVERFLOW   0
++#define FE_UNDERFLOW  0
++#define FE_INEXACT    0
++#endif
++
+ #if CONFIG_LIBFONTCONFIG
+ #include <fontconfig/fontconfig.h>
+ #endif
diff --git a/srcpkgs/ffmpeg4/patches/binutils-2.41.patch b/srcpkgs/ffmpeg4/patches/binutils-2.41.patch
new file mode 100644
index 00000000000000..53a596d0ee7d4e
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/binutils-2.41.patch
@@ -0,0 +1,73 @@
+From effadce6c756247ea8bae32dc13bb3e6f464f0eb Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= <remi@remlab.net>
+Date: Sun, 16 Jul 2023 18:18:02 +0300
+Subject: [PATCH] avcodec/x86/mathops: clip constants used with shift
+ instructions within inline assembly
+
+Fixes assembling with binutil as >= 2.41
+
+Signed-off-by: James Almer <jamrial@gmail.com>
+---
+ libavcodec/x86/mathops.h | 26 +++++++++++++++++++++++---
+ 1 file changed, 23 insertions(+), 3 deletions(-)
+
+diff --git a/libavcodec/x86/mathops.h b/libavcodec/x86/mathops.h
+index 6298f5ed1983b..ca7e2dffc1076 100644
+--- a/libavcodec/x86/mathops.h
++++ b/libavcodec/x86/mathops.h
+@@ -35,12 +35,20 @@
+ static av_always_inline av_const int MULL(int a, int b, unsigned shift)
+ {
+     int rt, dummy;
++    if (__builtin_constant_p(shift))
+     __asm__ (
+         "imull %3               \n\t"
+         "shrdl %4, %%edx, %%eax \n\t"
+         :"=a"(rt), "=d"(dummy)
+-        :"a"(a), "rm"(b), "ci"((uint8_t)shift)
++        :"a"(a), "rm"(b), "i"(shift & 0x1F)
+     );
++    else
++        __asm__ (
++            "imull %3               \n\t"
++            "shrdl %4, %%edx, %%eax \n\t"
++            :"=a"(rt), "=d"(dummy)
++            :"a"(a), "rm"(b), "c"((uint8_t)shift)
++        );
+     return rt;
+ }
+ 
+@@ -113,19 +121,31 @@ __asm__ volatile(\
+ // avoid +32 for shift optimization (gcc should do that ...)
+ #define NEG_SSR32 NEG_SSR32
+ static inline  int32_t NEG_SSR32( int32_t a, int8_t s){
++    if (__builtin_constant_p(s))
+     __asm__ ("sarl %1, %0\n\t"
+          : "+r" (a)
+-         : "ic" ((uint8_t)(-s))
++         : "i" (-s & 0x1F)
+     );
++    else
++        __asm__ ("sarl %1, %0\n\t"
++               : "+r" (a)
++               : "c" ((uint8_t)(-s))
++        );
+     return a;
+ }
+ 
+ #define NEG_USR32 NEG_USR32
+ static inline uint32_t NEG_USR32(uint32_t a, int8_t s){
++    if (__builtin_constant_p(s))
+     __asm__ ("shrl %1, %0\n\t"
+          : "+r" (a)
+-         : "ic" ((uint8_t)(-s))
++         : "i" (-s & 0x1F)
+     );
++    else
++        __asm__ ("shrl %1, %0\n\t"
++               : "+r" (a)
++               : "c" ((uint8_t)(-s))
++        );
+     return a;
+ }
+ 
diff --git a/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
new file mode 100644
index 00000000000000..aa948f7a8a2dfb
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
@@ -0,0 +1,40 @@
+#==================================================================================================
+# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
+# From: Christopher Degawa <christopher.degawa@intel.com>
+# Date: Thu, 20 Oct 2022 22:55:27 -0500
+# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
+#
+# compressed_ten_bit_format has been deprecated upstream and has no effect
+# and can be removed. Plus, technically it was never used in the first place
+# since it would require the app (ffmpeg) to set it and do additional
+# processing of the input frames.
+#
+# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
+#
+# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
+#==================================================================================================
+--- a/libavcodec/libsvtav1.c
++++ b/libavcodec/libsvtav1.c
+@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
+ 
+ static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
+ {
+-    const int    pack_mode_10bit =
+-        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
+-    const size_t luma_size_8bit  =
+-        config->source_width * config->source_height * (1 << pack_mode_10bit);
+-    const size_t luma_size_10bit =
+-        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
++    const size_t luma_size = config->source_width * config->source_height *
++        (config->encoder_bit_depth > 8 ? 2 : 1);
+ 
+     EbSvtIOFormat *in_data;
+ 
+-    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
++    svt_enc->raw_size = luma_size * 3 / 2;
+ 
+     // allocate buffer for in and out
+     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
+-- 
+GitLab
+
diff --git a/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
new file mode 100644
index 00000000000000..00e3f68a415b84
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
@@ -0,0 +1,28 @@
+From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
+From: Rainer Hochecker <fernetmenta@online.de>
+Date: Sat, 26 Jan 2019 19:48:35 +0100
+Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
+
+This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
+It was hit frequently when watching h264 channels received via DVB-X.
+Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
+---
+ libavcodec/vaapi_h264.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
+index 5854587a255..f12fdc457a4 100644
+--- a/libavcodec/vaapi_h264.c
++++ b/libavcodec/vaapi_h264.c
+@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
+     H264SliceContext *sl = &h->slice_ctx[0];
+     int ret;
+ 
++    if (pic->nb_slices == 0) {
++        ret = AVERROR_INVALIDDATA;
++        goto finish;
++    }
++
+     ret = ff_vaapi_decode_issue(avctx, pic);
+     if (ret < 0)
+         goto finish;
diff --git a/srcpkgs/ffmpeg4/template b/srcpkgs/ffmpeg4/template
new file mode 100644
index 00000000000000..9ba14bdb8ddf32
--- /dev/null
+++ b/srcpkgs/ffmpeg4/template
@@ -0,0 +1,234 @@
+# Template file for 'ffmpeg4'
+# audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
+pkgname=ffmpeg4
+version=4.4.4
+revision=1
+short_desc="Decoding, encoding and streaming software - ffmpeg4 libraries only"
+maintainer="Orphaned <orphan@voidlinux.org>"
+license="GPL-3.0-or-later"
+homepage="https://www.ffmpeg.org"
+changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
+distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
+checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+
+hostmakedepends="pkg-config perl"
+makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
+ libXext-devel libXvMC-devel libxcb-devel lame-devel libtheora-devel
+ libvorbis-devel x264-devel xvidcore-devel jack-devel SDL2-devel
+ libcdio-paranoia-devel librtmp-devel libmodplug-devel gnutls-devel
+ speex-devel celt-devel harfbuzz-devel libass-devel opus-devel ocl-icd-devel
+ libbs2b-devel libvidstab-devel vmaf-devel $(vopt_if pulseaudio pulseaudio-devel)
+ $(vopt_if vaapi libva-devel) $(vopt_if vdpau libvdpau-devel)
+ $(vopt_if x265 x265-devel) $(vopt_if v4l2 v4l-utils-devel)
+ $(vopt_if fdk_aac fdk-aac-devel) $(vopt_if vpx libvpx-devel)
+ $(vopt_if aom libaom-devel) $(vopt_if sndio sndio-devel)
+ $(vopt_if dav1d libdav1d-devel) $(vopt_if zimg zimg-devel)
+ $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
+ $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
+ $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
+
+build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
+
+desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
+desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
+desc_option_sofa="Enable support for AES SOFA"
+desc_option_webp="Enable support for WebP"
+
+case "$XBPS_TARGET_MACHINE" in
+	i686*|x86_64*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau nvenc nvdec"
+			;;
+	ppc64*) build_options_default+=" vaapi vdpau";;
+	mips*) CFLAGS="-mnan=legacy";;
+esac
+
+if [ "$XBPS_TARGET_WORDSIZE" != "32" ]; then
+	build_options_default+=" svtav1"
+fi
+
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+fi
+
+_apply_patch() {
+	local args="$1" pname="$(basename $2)"
+
+	if [ ! -f ".${pname}_done" ]; then
+		patch -N $args -i $2
+		touch .${pname}_done
+	fi
+}
+
+post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64le*) ;;
+		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
+	esac
+
+	vsed -i libavfilter/vf_libvmaf.c -e 's!/usr/local/share/model/\(vmaf_v0.6.1\).pkl!/usr/share/vmaf/\1.json!'
+}
+
+do_configure() {
+	# Fix gcc on x86_64-musl only
+	if [ "$XBPS_TARGET_MACHINE" = "x86_64-musl" ]; then
+		vsed -i configure -e "s;_cflags_speed='-O3';_cflags_speed='-O2';"
+	fi
+
+	if [ "$CROSS_BUILD" ]; then
+		case "$XBPS_TARGET_MACHINE" in
+			arm*) _arch="arm";;
+			aarch64*) _arch="aarch64";;
+			mips*) _arch="mips";;
+			ppc64*) _arch="ppc64";;
+			ppc*) _arch="ppc";;
+			*) _arch="${XBPS_TARGET_MACHINE%%-musl}";;
+		esac
+
+		_args+=" --enable-cross-compile
+			--sysroot=$XBPS_CROSS_BASE
+			--cross-prefix=${XBPS_CROSS_TRIPLET}-
+			--target-os=linux --arch=${_arch}"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc|ppc-musl) _args+=" --disable-altivec";;
+	esac
+
+	if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+		_args+=" --extra-libs=-latomic"
+	fi
+
+	./configure --prefix=/usr --disable-debug --enable-gpl --enable-gnutls \
+		--disable-stripping \
+		--enable-libcdio --enable-version3 --enable-runtime-cpudetect \
+		--enable-libmp3lame --enable-libvorbis --enable-libxvid \
+		--enable-libx264 $(vopt_enable vpx libvpx) --enable-libtheora \
+		--enable-shared --enable-static --enable-libxcb \
+		$(vopt_enable pulseaudio libpulse) --enable-libfreetype --enable-libmodplug \
+		--enable-libspeex --enable-libcelt --enable-libass \
+		--enable-libopus --enable-librtmp --enable-libjack \
+		$(vopt_if fdk_aac '--enable-nonfree --enable-libfdk-aac') \
+		--disable-libopencore_amrnb --disable-libopencore_amrwb \
+		--disable-libopenjpeg \
+		--enable-postproc --enable-opencl ${_args} --enable-libvmaf ${_args} \
+		$(vopt_enable x265 libx265) \
+		$(vopt_enable v4l2 libv4l2) \
+		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
+		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		$(vopt_enable dav1d libdav1d) \
+		$(vopt_enable zimg libzimg) \
+		$(vopt_enable webp libwebp) \
+		$(vopt_enable sofa libmysofa) \
+		$(vopt_enable vulkan) \
+		$(vopt_enable drm libdrm) \
+		$(vopt_enable svtav1 libsvtav1) \
+		$(vopt_enable srt libsrt) \
+		$(vopt_enable rist librist) \
+		$(vopt_if nvenc '--enable-nvenc') \
+		$(vopt_if nvdec '--enable-nvdec')
+}
+
+do_build() {
+	make ${makejobs}
+	make doc/ff{mpeg,play}.1
+}
+
+do_install() {
+	make DESTDIR=${DESTDIR} install install-man
+	rm -rf ${DESTDIR}/usr/bin
+}
+
+libavcodec4_package() {
+	short_desc="FFmpeg codec library"
+	pkg_install() {
+		vmove "usr/lib/libavcodec.so.*"
+	}
+}
+
+libavdevice4_package() {
+	short_desc="FFmpeg device handling library"
+	pkg_install() {
+		vmove "usr/lib/libavdevice.so.*"
+	}
+}
+
+libavresample4_package() {
+	short_desc="FFmpeg audio resampling library"
+	pkg_install() {
+		vmove "usr/lib/libavresample.so.*"
+	}
+}
+
+libavformat4_package() {
+	short_desc="FFmpeg file format library"
+	pkg_install() {
+		vmove "usr/lib/libavformat.so.*"
+	}
+}
+
+libavutil4_package() {
+	short_desc="FFmpeg utility library"
+	pkg_install() {
+		vmove "usr/lib/libavutil.so.*"
+	}
+}
+
+libavfilter4_package() {
+	short_desc="FFmpeg audio/video filter library"
+	pkg_install() {
+		vmove "usr/lib/libavfilter.so.*"
+	}
+}
+
+libpostproc4_package() {
+	short_desc="FFmpeg video postprocessing library"
+	pkg_install() {
+		vmove "usr/lib/libpostproc.so.*"
+	}
+}
+
+libswscale4_package() {
+	short_desc="FFmpeg video scaling library"
+	pkg_install() {
+		vmove "usr/lib/libswscale.so.*"
+	}
+}
+
+libswresample4_package() {
+	short_desc="FFmpeg video resampling library"
+	pkg_install() {
+		vmove "usr/lib/libswresample.so.*"
+	}
+}
+
+ffmpeg4-devel_package() {
+	depends="
+		libavcodec4>=${version}_${revision}
+		libavdevice4>=${version}_${revision}
+		libavformat4>=${version}_${revision}
+		libavutil4>=${version}_${revision}
+		libavfilter4>=${version}_${revision}
+		libpostproc4>=${version}_${revision}
+		libswscale4>=${version}_${revision}
+		libswresample4>=${version}_${revision}
+		libavresample4>=${version}_${revision}"
+	short_desc+=" - development files"
+	conflicts="ffmpeg-devel"
+	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
+		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
+		nostrip_files="/usr/lib/libavfilter.a"
+	fi
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.a"
+		vmove "usr/lib/*.so"
+		vmove usr/share/ffmpeg/examples
+		vmove usr/share/man/man3
+	}
+}
diff --git a/srcpkgs/libavcodec4 b/srcpkgs/libavcodec4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavcodec4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavdevice4 b/srcpkgs/libavdevice4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavdevice4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavfilter4 b/srcpkgs/libavfilter4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavfilter4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavformat4 b/srcpkgs/libavformat4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavformat4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavresample4 b/srcpkgs/libavresample4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavutil4 b/srcpkgs/libavutil4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavutil4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libpostproc4 b/srcpkgs/libpostproc4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libpostproc4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswresample4 b/srcpkgs/libswresample4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libswresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswscale4 b/srcpkgs/libswscale4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libswscale4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file

From da9b1a9e5198660c2c1729cbcc7d9c4fccb1b7a9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:04 -0400
Subject: [PATCH 005/110] opencv: update to 4.7.0.

---
 common/shlibs           | 104 ++++++++++++++++++++--------------------
 srcpkgs/opencv/template |   8 ++--
 2 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index d87b3be06a6dc6..d721ddd1fd858f 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2075,58 +2075,58 @@ libcapstone.so.5 capstone-5.0.1_1
 libhavege.so.2 libhaveged-1.9.11_1
 libnih.so.1 libnih-1.0.3_1
 libnih-dbus.so.1 libnih-1.0.3_1
-libopencv_quality.so.406 libopencv-4.6.0_1
-libopencv_reg.so.406 libopencv-4.6.0_1
-libopencv_surface_matching.so.406 libopencv-4.6.0_1
-libopencv_xphoto.so.406 libopencv-4.6.0_1
-libopencv_freetype.so.406 libopencv-4.6.0_1
-libopencv_fuzzy.so.406 libopencv-4.6.0_1
-libopencv_hfs.so.406 libopencv-4.6.0_1
-libopencv_img_hash.so.406 libopencv-4.6.0_1
-libopencv_line_descriptor.so.406 libopencv-4.6.0_1
-libopencv_saliency.so.406 libopencv-4.6.0_1
-libopencv_structured_light.so.406 libopencv-4.6.0_1
-libopencv_aruco.so.406 libopencv-4.6.0_1
-libopencv_bgsegm.so.406 libopencv-4.6.0_1
-libopencv_bioinspired.so.406 libopencv-4.6.0_1
-libopencv_ccalib.so.406 libopencv-4.6.0_1
-libopencv_face.so.406 libopencv-4.6.0_1
-libopencv_tracking.so.406 libopencv-4.6.0_1
-libopencv_xfeatures2d.so.406 libopencv-4.6.0_1
-libopencv_optflow.so.406 libopencv-4.6.0_1
-libopencv_ximgproc.so.406 libopencv-4.6.0_1
-libopencv_plot.so.406 libopencv-4.6.0_1
-libopencv_text.so.406 libopencv-4.6.0_1
-libopencv_ml.so.406 libopencv-4.6.0_1
-libopencv_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn.so.406 libopencv-4.6.0_1
-libopencv_shape.so.406 libopencv-4.6.0_1
-libopencv_stitching.so.406 libopencv-4.6.0_1
-libopencv_photo.so.406 libopencv-4.6.0_1
-libopencv_video.so.406 libopencv-4.6.0_1
-libopencv_calib3d.so.406 libopencv-4.6.0_1
-libopencv_features2d.so.406 libopencv-4.6.0_1
-libopencv_flann.so.406 libopencv-4.6.0_1
-libopencv_highgui.so.406 libopencv-4.6.0_1
-libopencv_videoio.so.406 libopencv-4.6.0_1
-libopencv_imgcodecs.so.406 libopencv-4.6.0_1
-libopencv_imgproc.so.406 libopencv-4.6.0_1
-libopencv_core.so.406 libopencv-4.6.0_1
-libopencv_superres.so.406 libopencv-4.6.0_1
-libopencv_videostab.so.406 libopencv-4.6.0_1
-libopencv_gapi.so.406 libopencv-4.6.0_1
-libopencv_xobjdetect.so.406 libopencv-4.6.0_1
-libopencv_datasets.so.406 libopencv-4.6.0_1
-libopencv_dnn_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn_superres.so.406 libopencv-4.6.0_1
-libopencv_dpm.so.406 libopencv-4.6.0_1
-libopencv_phase_unwrapping.so.406 libopencv-4.6.0_1
-libopencv_stereo.so.406 libopencv-4.6.0_1
-libopencv_rapid.so.406 libopencv-4.6.0_1
-libopencv_intensity_transform.so.406 libopencv-4.6.0_1
-libopencv_alphamat.so.406 libopencv-4.6.0_1
-libopencv_barcode.so.406 libopencv-4.6.0_1
-libopencv_mcc.so.406 libopencv-4.6.0_1
+libopencv_quality.so.407 libopencv-4.7.0_1
+libopencv_reg.so.407 libopencv-4.7.0_1
+libopencv_surface_matching.so.407 libopencv-4.7.0_1
+libopencv_xphoto.so.407 libopencv-4.7.0_1
+libopencv_freetype.so.407 libopencv-4.7.0_1
+libopencv_fuzzy.so.407 libopencv-4.7.0_1
+libopencv_hfs.so.407 libopencv-4.7.0_1
+libopencv_img_hash.so.407 libopencv-4.7.0_1
+libopencv_line_descriptor.so.407 libopencv-4.7.0_1
+libopencv_saliency.so.407 libopencv-4.7.0_1
+libopencv_structured_light.so.407 libopencv-4.7.0_1
+libopencv_aruco.so.407 libopencv-4.7.0_1
+libopencv_bgsegm.so.407 libopencv-4.7.0_1
+libopencv_bioinspired.so.407 libopencv-4.7.0_1
+libopencv_ccalib.so.407 libopencv-4.7.0_1
+libopencv_face.so.407 libopencv-4.7.0_1
+libopencv_tracking.so.407 libopencv-4.7.0_1
+libopencv_xfeatures2d.so.407 libopencv-4.7.0_1
+libopencv_optflow.so.407 libopencv-4.7.0_1
+libopencv_ximgproc.so.407 libopencv-4.7.0_1
+libopencv_plot.so.407 libopencv-4.7.0_1
+libopencv_text.so.407 libopencv-4.7.0_1
+libopencv_ml.so.407 libopencv-4.7.0_1
+libopencv_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn.so.407 libopencv-4.7.0_1
+libopencv_shape.so.407 libopencv-4.7.0_1
+libopencv_stitching.so.407 libopencv-4.7.0_1
+libopencv_photo.so.407 libopencv-4.7.0_1
+libopencv_video.so.407 libopencv-4.7.0_1
+libopencv_calib3d.so.407 libopencv-4.7.0_1
+libopencv_features2d.so.407 libopencv-4.7.0_1
+libopencv_flann.so.407 libopencv-4.7.0_1
+libopencv_highgui.so.407 libopencv-4.7.0_1
+libopencv_videoio.so.407 libopencv-4.7.0_1
+libopencv_imgcodecs.so.407 libopencv-4.7.0_1
+libopencv_imgproc.so.407 libopencv-4.7.0_1
+libopencv_core.so.407 libopencv-4.7.0_1
+libopencv_superres.so.407 libopencv-4.7.0_1
+libopencv_videostab.so.407 libopencv-4.7.0_1
+libopencv_gapi.so.407 libopencv-4.7.0_1
+libopencv_xobjdetect.so.407 libopencv-4.7.0_1
+libopencv_datasets.so.407 libopencv-4.7.0_1
+libopencv_dnn_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn_superres.so.407 libopencv-4.7.0_1
+libopencv_dpm.so.407 libopencv-4.7.0_1
+libopencv_phase_unwrapping.so.407 libopencv-4.7.0_1
+libopencv_stereo.so.407 libopencv-4.7.0_1
+libopencv_rapid.so.407 libopencv-4.7.0_1
+libopencv_intensity_transform.so.407 libopencv-4.7.0_1
+libopencv_alphamat.so.407 libopencv-4.7.0_1
+libopencv_barcode.so.407 libopencv-4.7.0_1
+libopencv_mcc.so.407 libopencv-4.7.0_1
 libuniconf.so.4.6 wvstreams-4.6.1_20
 libwvbase.so.4.6 wvstreams-4.6.1_20
 libwvutils.so.4.6 wvstreams-4.6.1_20
diff --git a/srcpkgs/opencv/template b/srcpkgs/opencv/template
index aea4bfc3a265cf..ce94de9424d18d 100644
--- a/srcpkgs/opencv/template
+++ b/srcpkgs/opencv/template
@@ -1,7 +1,7 @@
 # Template file for 'opencv'
 pkgname=opencv
-version=4.6.0
-revision=6
+version=4.7.0
+revision=1
 create_wrksrc=yes
 build_wrksrc=${pkgname}-${version}
 build_style=cmake
@@ -24,8 +24,8 @@ homepage="https://opencv.org"
 changelog="https://github.com/opencv/opencv/wiki/ChangeLog"
 distfiles="https://github.com/opencv/opencv/archive/${version}.tar.gz
  https://github.com/opencv/opencv_contrib/archive/${version}.tar.gz>contrib.tar.gz"
-checksum="1ec1cba65f9f20fe5a41fda1586e01c70ea0c9a6d7b67c9e13edf0cfe2239277
- 1777d5fd2b59029cf537e5fd6f8aa68d707075822f90bde683fcde086f85f7a7"
+checksum="8df0079cdbe179748a18d44731af62a245a45ebf5085223dc03133954c662973
+ 42df840cf9055e59d0e22c249cfb19f04743e1bdad113d31b1573d3934d62584"
 patch_args="-Np1 -d ${build_wrksrc}"
 # tests hang indenfinitely, even with test data included
 make_check=no

From f82fbd2b6216bd8077fc043a2f1887ef7b793592 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 006/110] actiona: revbump for opencv-4.7.0

---
 srcpkgs/actiona/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/actiona/template b/srcpkgs/actiona/template
index cf5f0b7a2ae610..0d899311e6df75 100644
--- a/srcpkgs/actiona/template
+++ b/srcpkgs/actiona/template
@@ -1,7 +1,7 @@
 # Template file for 'actiona'
 pkgname=actiona
 version=3.10.1
-revision=2
+revision=3
 build_style=qmake
 configure_args="PKGCONFIG_OPENCV=opencv4"
 hostmakedepends="pkg-config qt5-plugin-mysql qt5-qmake qt5-host-tools"

From 9fb6f123760b7f55b31728094fc25b4796a77b94 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 007/110] retroshare: revbump for opencv-4.7.0

---
 srcpkgs/retroshare/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroshare/template b/srcpkgs/retroshare/template
index bb17569277a7f3..49e2c1cbe8a531 100644
--- a/srcpkgs/retroshare/template
+++ b/srcpkgs/retroshare/template
@@ -1,7 +1,7 @@
 # Template file for 'retroshare'
 pkgname=retroshare
 version=0.6.6
-revision=3
+revision=4
 build_style=qmake
 #XXX broadcast feature requires an ancient udp-discovery-cpp which either needs
 # to be fetched+patched (FTBFS) here or packaged :/

From ff61278e969b7f5410c9e0cfc363f8d6889a2d89 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 008/110] waifu2x-converter-cpp: revbump for opencv-4.7.0

---
 srcpkgs/waifu2x-converter-cpp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waifu2x-converter-cpp/template b/srcpkgs/waifu2x-converter-cpp/template
index 361b8a23b94977..c5ac17eb54ea4c 100644
--- a/srcpkgs/waifu2x-converter-cpp/template
+++ b/srcpkgs/waifu2x-converter-cpp/template
@@ -1,7 +1,7 @@
 # Template file for 'waifu2x-converter-cpp'
 pkgname=waifu2x-converter-cpp
 version=5.2.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DINSTALL_MODELS=ON"
 hostmakedepends="pkg-config"

From d8c6f8e073060d19dc30423b07e1005ee91449fd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:38 -0400
Subject: [PATCH 009/110] vlc: revbump for ffmpeg4

---
 srcpkgs/vlc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vlc/template b/srcpkgs/vlc/template
index 559b1c4fff339f..cfa11e6c26f28c 100644
--- a/srcpkgs/vlc/template
+++ b/srcpkgs/vlc/template
@@ -25,7 +25,7 @@ lib32disabled=yes
 hostmakedepends="automake libtool pkg-config flex gettext libgcrypt-devel
  live555-devel gettext-devel $(vopt_if lua lua52) $(vopt_if chromecast protobuf)"
 makedepends="
- avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg-devel freefont-ttf
+ avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg4-devel freefont-ttf
  gnutls-devel jack-devel liba52-devel libass-devel libbluray-devel
  libcdio-devel libdca-devel libdvbpsi-devel libdvdnav-devel libmad-devel
  libmatroska-devel libmodplug-devel libmpcdec-devel libmpeg2-devel

From c8a5053a5194eea31fa6501f70b31ad39f5c8e25 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:55 -0400
Subject: [PATCH 010/110] osg: revbump for ffmpeg4

---
 srcpkgs/osg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/osg/template b/srcpkgs/osg/template
index 8ef0efc599a1b1..a131ceaf7a867b 100644
--- a/srcpkgs/osg/template
+++ b/srcpkgs/osg/template
@@ -8,7 +8,7 @@ build_helper="qemu"
 configure_args="-DLIB_POSTFIX="
 hostmakedepends="pkg-config xrandr"
 makedepends="MesaLib-devel gtkglext-devel libcurl-devel giflib-devel librsvg-devel
- jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg-devel xine-lib-devel
+ jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg4-devel xine-lib-devel
  SDL2-devel gst-plugins-base1-devel
  $(vopt_if openexr libopenexr-devel)
  $(vopt_if poppler poppler-glib-devel)

From 0e87b5632fa5775833b0eb3d0d2ec9912ef7aba3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:13 -0400
Subject: [PATCH 011/110] xine-lib: revbump for ffmpeg4

---
 srcpkgs/xine-lib/template | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/xine-lib/template b/srcpkgs/xine-lib/template
index 3be4d08eac77a3..ed6194c17d11e8 100644
--- a/srcpkgs/xine-lib/template
+++ b/srcpkgs/xine-lib/template
@@ -1,14 +1,14 @@
 # Template file for 'xine-lib'
 pkgname=xine-lib
-version=1.2.12
-revision=3
+version=1.2.13
+revision=1
 build_style=gnu-configure
 configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
  --disable-oss"
 hostmakedepends="automake gettext-devel libtool pkg-config perl"
 makedepends="
  zlib-devel alsa-lib-devel libxcb-devel libSM-devel libXext-devel libXv-devel
- libXvMC-devel liba52-devel libmad-devel ffmpeg-devel pulseaudio-devel
+ libXvMC-devel liba52-devel libmad-devel ffmpeg4-devel pulseaudio-devel
  jack-devel samba-devel libflac-devel libmodplug-devel libmpcdec-devel
  speex-devel libtheora-devel libvorbis-devel libdca-devel faad2-devel
  libcdio-devel libbluray-devel aalib-devel libcaca-devel libXinerama-devel
@@ -19,7 +19,7 @@ license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="http://www.xine-project.org"
 changelog="https://sourceforge.net/projects/xine/files/xine-lib/${version}/README.txt/view"
 distfiles="${SOURCEFORGE_SITE}/xine/${pkgname}-${version}.tar.xz"
-checksum=d606270468e1540c2a89c0d7f5fdf11e17ecc0c2698cc0bcb1065ff26abee098
+checksum=5f10d6d718a4a51c17ed1b32b031d4f9b80b061e8276535b2be31e5ac4b75e6f
 
 case "$XBPS_TARGET_MACHINE" in
 	i686-musl)

From 03a00f58a619cbd854e3fc97a3e8c242e9453779 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 012/110] attract: revbump for ffmpeg6

---
 srcpkgs/attract/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/attract/template b/srcpkgs/attract/template
index e769fb15456217..776cbe4ebd2c93 100644
--- a/srcpkgs/attract/template
+++ b/srcpkgs/attract/template
@@ -1,7 +1,7 @@
 # Template file for 'attract'
 pkgname=attract
 version=2.7.0
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="VERBOSE=1"
 make_use_env=yes

From ed30349037701ad8ad3da544d311ac1ededbc879 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 013/110] aubio: revbump for ffmpeg6

---
 srcpkgs/aubio/patches/ffmpeg5.patch | 25 +++++++++++++++++++++++++
 srcpkgs/aubio/template              |  2 +-
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/aubio/patches/ffmpeg5.patch

diff --git a/srcpkgs/aubio/patches/ffmpeg5.patch b/srcpkgs/aubio/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..aace41a6e6d9a4
--- /dev/null
+++ b/srcpkgs/aubio/patches/ffmpeg5.patch
@@ -0,0 +1,25 @@
+From 8a05420e5dd8c7b8b2447f82dc919765876511b3 Mon Sep 17 00:00:00 2001
+From: Paul Brossier <piem@piem.org>
+Date: Tue, 25 Jan 2022 18:30:27 +0100
+Subject: [PATCH] [source_avcodec] define FF_API_LAVF_AVCTX for libavcodec >
+ 59, thx @berolinux (closes gh-353)
+
+---
+ src/io/source_avcodec.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/io/source_avcodec.c b/src/io/source_avcodec.c
+index e0ae93b5..1421bd9a 100644
+--- a/src/io/source_avcodec.c
++++ b/src/io/source_avcodec.c
+@@ -68,6 +68,10 @@
+ #define AUBIO_AVCODEC_MAX_BUFFER_SIZE AV_INPUT_BUFFER_MIN_SIZE
+ #endif
+ 
++#if LIBAVCODEC_VERSION_MAJOR >= 59
++#define FF_API_LAVF_AVCTX 1
++#endif
++
+ struct _aubio_source_avcodec_t {
+   uint_t hop_size;
+   uint_t samplerate;
diff --git a/srcpkgs/aubio/template b/srcpkgs/aubio/template
index ad1c4b25699178..7d875cc02541a7 100644
--- a/srcpkgs/aubio/template
+++ b/srcpkgs/aubio/template
@@ -1,7 +1,7 @@
 # Template file for 'aubio'
 pkgname=aubio
 version=0.4.9
-revision=1
+revision=2
 build_style=waf3
 # XXX lash, pure and swig support.
 hostmakedepends="pkg-config txt2man"

From f512027edfb0b99d8fba436de234114d823de5d1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 014/110] audacious-plugins: revbump for ffmpeg6

---
 .../audacious-plugins/patches/ffmpeg5.patch   | 43 +++++++++++++++++++
 srcpkgs/audacious-plugins/template            |  2 +-
 2 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/audacious-plugins/patches/ffmpeg5.patch

diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg5.patch b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..4e5e34099d71c4
--- /dev/null
+++ b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
@@ -0,0 +1,43 @@
+commit 298aa371c56c2f52c25a33d9bdec4918b11cebdc
+Author: tibequadorian <tibequadorian@posteo.de>
+Date:   Sat Mar 19 18:40:12 2022 +0100
+
+    audacious-plugins: rebuild against ffmpeg-5.0
+
+diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+new file mode 100644
+index 0000000000..617c11215b
+--- /dev/null
++++ b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+@@ -0,0 +1,31 @@
++From f60beb400eeb1e4778bbfd738bc4a4ccef3de539 Mon Sep 17 00:00:00 2001
++From: John Lindgren <john@jlindgren.net>
++Date: Sat, 5 Mar 2022 12:05:34 -0500
++Subject: [PATCH] Fix build with FFmpeg 5.0
++
++---
++ src/ffaudio/ffaudio-core.cc | 4 ++--
++ 1 file changed, 2 insertions(+), 2 deletions(-)
++
++diff --git a/src/ffaudio/ffaudio-core.cc b/src/ffaudio/ffaudio-core.cc
++index 16dc63e3a..a2b95fd6c 100644
++--- a/src/ffaudio/ffaudio-core.cc
+++++ b/src/ffaudio/ffaudio-core.cc
++@@ -274,7 +274,7 @@ static AVInputFormat * get_format_by_content (const char * name, VFSFile & file)
++         AVProbeData d = {name, buf, filled};
++         score = target;
++ 
++-        f = av_probe_input_format2 (& d, true, & score);
+++        f = (AVInputFormat *) av_probe_input_format2 (& d, true, & score);
++         if (f)
++             break;
++ 
++@@ -347,7 +347,7 @@ static bool find_codec (AVFormatContext * c, CodecInfo * cinfo)
++ #endif
++         if (stream && stream->codecpar && stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
++         {
++-            AVCodec * codec = avcodec_find_decoder (stream->codecpar->codec_id);
+++            AVCodec * codec = (AVCodec *) avcodec_find_decoder (stream->codecpar->codec_id);
++ 
++             if (codec)
++             {
diff --git a/srcpkgs/audacious-plugins/template b/srcpkgs/audacious-plugins/template
index 05e53a9adf78ff..4b1968e03de781 100644
--- a/srcpkgs/audacious-plugins/template
+++ b/srcpkgs/audacious-plugins/template
@@ -2,7 +2,7 @@
 #Keep in sync with audacious!
 pkgname=audacious-plugins
 version=4.3.1
-revision=3
+revision=4
 build_style=meson
 configure_args="$(vopt_bool gtk3 gtk) $(vopt_bool gtk3)
  $(vopt_bool qt) $(vopt_bool qt qt6)"

From 70315c8c209f88c24a500054b7338617134cfbf4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 015/110] audacity: revbump for ffmpeg6

---
 srcpkgs/audacity/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/audacity/template b/srcpkgs/audacity/template
index 7b838119ab2611..84b49305edcef1 100644
--- a/srcpkgs/audacity/template
+++ b/srcpkgs/audacity/template
@@ -1,7 +1,7 @@
 # Template file for 'audacity'
 pkgname=audacity
 version=3.4.2
-revision=1
+revision=2
 build_style=cmake
 build_helper="cmake-wxWidgets-gtk3 qemu"
 configure_args="-Daudacity_use_ffmpeg=loaded -Daudacity_lib_preference=system

From 587bd8e7321b2989275885d51e48ca64ca7872a6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 016/110] avidemux: revbump for ffmpeg6

---
 srcpkgs/avidemux/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/avidemux/template b/srcpkgs/avidemux/template
index 253a0243e22599..557285982d2b8f 100644
--- a/srcpkgs/avidemux/template
+++ b/srcpkgs/avidemux/template
@@ -1,7 +1,7 @@
 # Template file for 'avidemux'
 pkgname=avidemux
 version=2.8.0
-revision=2
+revision=3
 # Can't be compiled for aarch64, arm* or mips*
 archs="x86_64* i686*"
 hostmakedepends="cmake pkg-config qt5-host-tools qt5-devel tar yasm"

From 698c57671787e1981bd6a1f528e922c134880ff8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 017/110] blender: revbump for ffmpeg6

---
 srcpkgs/blender/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index 68787b76a26c18..e238717ac8c729 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -9,8 +9,8 @@ configure_args="-DWITH_INSTALL_PORTABLE=OFF -DWITH_PYTHON_INSTALL=OFF
  -DWITH_JACK=ON -DWITH_CODEC_FFMPEG=ON -DWITH_CODEC_SNDFILE=ON -DWITH_OPENMP=ON
  -DWITH_FFTW3=ON -DWITH_MOD_OCEANSIM=ON -DWITH_CYCLES_EMBREE=OFF -DWITH_OPENCOLORIO=ON
  -DWITH_IMAGE_OPENEXR=ON -DWITH_IMAGE_OPENJPEG=ON -DWITH_OPENSUBDIV=ON
- -DWITH_OPENCOLLADA=ON -DWITH_SYSTEM_GLEW=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
- -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_LIBDECOR=ON
+ -DWITH_OPENCOLLADA=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
+ -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_WAYLAND_LIBDECOR=ON
  -DWITH_BUILDINFO=OFF -DPYTHON_VERSION=${py3_ver} -DPYTHON_LIBPATH=/usr/lib
  -DPYTHON_LIBRARY=python${py3_ver}${py3_abiver} -DPYTHON_INCLUDE_DIRS=/${py3_inc}
  -DWITH_SYSTEM_LZO=ON -DWITH_SYSTEM_EIGEN3=ON -DWITH_SYSTEM_FREETYPE=ON"

From 28754e53cea85ec2e0eaca710892168a650a3a2a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 018/110] cantata: revbump for ffmpeg6

---
 srcpkgs/cantata/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cantata/template b/srcpkgs/cantata/template
index 4b417d80d5c2da..8a90aaa4c07a2a 100644
--- a/srcpkgs/cantata/template
+++ b/srcpkgs/cantata/template
@@ -1,7 +1,7 @@
 # Template file for 'cantata'
 pkgname=cantata
 version=2.5.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools qt5-tools"
 makedepends="qt5-devel qt5-tools-devel qt5-svg-devel qt5-xmlpatterns-devel

From dbefce326ca57fbbd0045da75de81ee2c1645f77 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 019/110] ccextractor: revbump for ffmpeg6

---
 ...5-and-tesseract-5-compatibility-1479.patch | 168 ++++++++++++++++++
 srcpkgs/ccextractor/template                  |   2 +-
 2 files changed, 169 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ccextractor/patches/0001-fix-ffmpeg-5-and-tesseract-5-compatibility-1479.patch

diff --git a/srcpkgs/ccextractor/patches/0001-fix-ffmpeg-5-and-tesseract-5-compatibility-1479.patch b/srcpkgs/ccextractor/patches/0001-fix-ffmpeg-5-and-tesseract-5-compatibility-1479.patch
new file mode 100644
index 00000000000000..bcab4890554b9a
--- /dev/null
+++ b/srcpkgs/ccextractor/patches/0001-fix-ffmpeg-5-and-tesseract-5-compatibility-1479.patch
@@ -0,0 +1,168 @@
+From b1cbfcea9b9c687143bf0d80bc179b563e99d025 Mon Sep 17 00:00:00 2001
+From: Prateek Sunal <prtksunal@gmail.com>
+Date: Thu, 9 Mar 2023 01:44:53 +0530
+Subject: [PATCH] fix: ffmpeg 5 and tesseract 5 compatibility (#1479)
+
+* fix: replace deprecated `codec` property with `codecpar`
+
+* fix: replace deprecated method `avcodec_decode_video2` with `avcodec_receive_frame` and `avcodec_send_packet`
+
+* Update CHANGES.TXT
+
+* fix: remove deprecated `av_register_all` function
+
+* fix: formatting
+
+* fix: add support for tesseract 5
+
+* fix: tesseract v5
+
+* fix: hardsubx codec context error
+
+* fix: lint const warning
+---
+ docs/CHANGES.TXT               |  1 +
+ src/lib_ccx/ffmpeg_intgr.c     |  7 +++---
+ src/lib_ccx/hardsubx.c         | 25 ++++++++++++------
+ src/lib_ccx/hardsubx_decoder.c | 27 ++++++++------------
+ src/lib_ccx/ocr.c              | 46 ++++++++++++----------------------
+ 5 files changed, 47 insertions(+), 59 deletions(-)
+
+diff --git a/src/lib_ccx/ffmpeg_intgr.c b/src/lib_ccx/ffmpeg_intgr.c
+index be988890..e6f21e20 100644
+--- a/src/lib_ccx/ffmpeg_intgr.c
++++ b/src/lib_ccx/ffmpeg_intgr.c
+@@ -66,7 +66,6 @@ void *init_ffmpeg(const char *path)
+ 	struct ffmpeg_ctx *ctx;
+ 	AVCodec *dec = NULL;
+ 	avcodec_register_all();
+-	av_register_all();
+ 
+ 	if (ccx_options.debug_mask & CCX_DMT_VERBOSE)
+ 		av_log_set_level(AV_LOG_INFO);
+@@ -133,7 +132,6 @@ int ff_get_ccframe(void *arg, unsigned char *data, int maxlen)
+ 	struct ffmpeg_ctx *ctx = arg;
+ 	int len = 0;
+ 	int ret = 0;
+-	int got_frame;
+ 	AVPacket packet;
+ 
+ 	ret = av_read_frame(ctx->ifmt, &packet);
+@@ -151,12 +149,13 @@ int ff_get_ccframe(void *arg, unsigned char *data, int maxlen)
+ 		return AVERROR(EAGAIN);
+ 	}
+ 
+-	ret = avcodec_decode_video2(ctx->dec_ctx, ctx->frame, &got_frame, &packet);
++	avcodec_send_packet(ctx->codec_ctx, &ctx->packet);
++	ret = avcodec_receive_frame(ctx->dec_ctx, ctx->frame);
+ 	if (ret < 0)
+ 	{
+ 		av_log(NULL, AV_LOG_ERROR, "unable to decode packet\n");
+ 	}
+-	else if (!got_frame)
++	else if (ret != 0)
+ 	{
+ 		return AVERROR(EAGAIN);
+ 	}
+diff --git a/src/lib_ccx/hardsubx.c b/src/lib_ccx/hardsubx.c
+index 411377f9..fb844c91 100644
+--- a/src/lib_ccx/hardsubx.c
++++ b/src/lib_ccx/hardsubx.c
+@@ -12,9 +12,6 @@
+
+ int hardsubx_process_data(struct lib_hardsubx_ctx *ctx)
+ {
+-	// Get the required media attributes and initialize structures
+-	av_register_all();
+-
+ 	if (avformat_open_input(&ctx->format_ctx, ctx->inputfile[0], NULL, NULL) != 0)
+ 	{
+ 		fatal(EXIT_READ_ERROR, "Error reading input file!\n");
+@@ -32,7 +29,7 @@
+ 	ctx->video_stream_id = -1;
+ 	for (int i = 0; i < ctx->format_ctx->nb_streams; i++)
+ 	{
+-		if (ctx->format_ctx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO)
++		if (ctx->format_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
+ 		{
+ 			ctx->video_stream_id = i;
+ 			break;
+@@ -43,8 +40,21 @@
+ 		fatal(EXIT_READ_ERROR, "Video Stream not found!\n");
+ 	}
+
+-	ctx->codec_ctx = ctx->format_ctx->streams[ctx->video_stream_id]->codec;
+-	ctx->codec = avcodec_find_decoder(ctx->codec_ctx->codec_id);
++	ctx->codec_ctx = avcodec_alloc_context3(NULL);
++	if (!ctx->codec_ctx)
++	{
++		    fatal(EXIT_NOT_ENOUGH_MEMORY, "Could not allocate codec context!\n");
++	}
++
++	// Assign codec parameters to codec context
++	if (avcodec_parameters_to_context(ctx->codec_ctx, ctx->format_ctx->streams[ctx->video_stream_id]->codecpar) < 0)
++	{
++		    fatal(EXIT_READ_ERROR, "Could not initialize codec context!\n");
++	}
++
++	// Find decoder for the codec context
++	ctx->codec = (AVCodec *)avcodec_find_decoder(ctx->codec_ctx->codec_id);
++
+ 	if (ctx->codec == NULL)
+ 	{
+ 		fatal(EXIT_READ_ERROR, "Input codec is not supported!\n");
+diff --git a/src/lib_ccx/hardsubx_decoder.c b/src/lib_ccx/hardsubx_decoder.c
+index bd9b0980..b5dfaec4 100644
+--- a/src/lib_ccx/hardsubx_decoder.c
++++ b/src/lib_ccx/hardsubx_decoder.c
+@@ -371,7 +371,6 @@
+ int hardsubx_process_frames_tickertext(struct lib_hardsubx_ctx *ctx, struct encoder_ctx *enc_ctx)
+ {
+ 	// Search for ticker text at the bottom of the screen, such as in Russia TV1 or stock prices
+-	int got_frame;
+ 	int cur_sec = 0, total_sec, progress;
+ 	int frame_number = 0;
+ 	char *ticker_text = NULL;
+@@ -382,8 +381,8 @@
+ 		{
+ 			frame_number++;
+ 			//Decode the video stream packet
+-			avcodec_decode_video2(ctx->codec_ctx, ctx->frame, &got_frame, &ctx->packet);
+-			if (got_frame && frame_number % 1000 == 0)
++      avcodec_send_packet(ctx->codec_ctx, &ctx->packet);
++      if (avcodec_receive_frame(ctx->codec_ctx, ctx->frame) == 0 && frame_number % 1000 == 0)
+ 			{
+ 				// sws_scale is used to convert the pixel format to RGB24 from all other cases
+ 				sws_scale(
+@@ -434,9 +433,8 @@
+ 			frame_number++;
+
+ 			//Decode the video stream packet
+-			avcodec_decode_video2(ctx->codec_ctx, ctx->frame, &got_frame, &ctx->packet);
+-
+-			if (got_frame && frame_number % 25 == 0)
++			avcodec_send_packet(ctx->codec_ctx, &ctx->packet);
++      if (avcodec_receive_frame(ctx->codec_ctx, ctx->frame) == 0 && frame_number % 25 == 0)
+ 			{
+ 				float diff = (float)convert_pts_to_ms(ctx->packet.pts - prev_packet_pts, ctx->format_ctx->streams[ctx->video_stream_id]->time_base);
+ 				if (fabsf(diff) < 1000 * ctx->min_sub_duration) //If the minimum duration of a subtitle line is exceeded, process packet
+@@ -548,7 +546,6 @@
+ {
+ 	// Do a binary search over the input video for faster processing
+ 	// printf("Duration: %d\n", (int)ctx->format_ctx->duration);
+-	int got_frame;
+ 	int seconds_time = 0;
+ 	for (seconds_time = 0; seconds_time < 20; seconds_time++)
+ 	{
+@@ -568,8 +565,9 @@
+ 			{
+ 				if (ctx->packet.stream_index == ctx->video_stream_id)
+ 				{
+-					avcodec_decode_video2(ctx->codec_ctx, ctx->frame, &got_frame, &ctx->packet);
+-					if (got_frame)
++          avcodec_send_packet(ctx->codec_ctx, &ctx->packet);
++          if (avcodec_receive_frame(ctx->codec_ctx, ctx->frame) == 0)
++
+ 					{
+ 						// printf("%d\n", seek_time);
+ 						if (ctx->packet.pts < seek_time)
diff --git a/srcpkgs/ccextractor/template b/srcpkgs/ccextractor/template
index 84059ffd02398a..a670758bcbe41b 100644
--- a/srcpkgs/ccextractor/template
+++ b/srcpkgs/ccextractor/template
@@ -1,7 +1,7 @@
 # Template file for 'ccextractor'
 pkgname=ccextractor
 version=0.93
-revision=2
+revision=3
 build_wrksrc="linux"
 build_style=gnu-configure
 configure_args="--enable-ocr --enable-hardsubx"

From 5e923920bf28d9a29823f1077134418f1e2d561f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 020/110] chromaprint: revbump for ffmpeg6

---
 srcpkgs/chromaprint/patches/ffmpeg5.patch | 569 ++++++++++++++++++++++
 srcpkgs/chromaprint/template              |   2 +-
 2 files changed, 570 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromaprint/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromaprint/patches/ffmpeg5.patch b/srcpkgs/chromaprint/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..a9fd307a23c8a4
--- /dev/null
+++ b/srcpkgs/chromaprint/patches/ffmpeg5.patch
@@ -0,0 +1,569 @@
+From 8ccad6937177b1b92e40ab8f4447ea27bac009a7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= <lalinsky@gmail.com>
+Date: Fri, 4 Nov 2022 21:47:38 +0100
+Subject: [PATCH] Use FFmpeg 5.x (#120)
+
+* Use FFmpeg 5.1.2 for CI builds
+
+* Build on Ubuntu 20.04
+
+* Upgrade code to FFmpeg 5.x APIs
+
+* Only set FFmpeg include dirs if building tools
+
+* No longer needed
+
+* Use ubuntu 20.04
+---
+ .github/workflows/build.yml                   |   6 +-
+ CMakeLists.txt                                |  16 --
+ package/build.sh                              |   4 +-
+ src/audio/ffmpeg_audio_processor.h            |   2 -
+ src/audio/ffmpeg_audio_processor_avresample.h |  72 -------
+ src/audio/ffmpeg_audio_processor_swresample.h |  18 +-
+ src/audio/ffmpeg_audio_reader.h               | 197 +++++++++---------
+ tests/CMakeLists.txt                          |   6 +
+ 8 files changed, 122 insertions(+), 199 deletions(-)
+ delete mode 100644 src/audio/ffmpeg_audio_processor_avresample.h
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index f8d6a32..4da2405 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -84,9 +84,6 @@ find_package(FFmpeg)
+ if(FFMPEG_LIBRARIES)
+ 	cmake_push_check_state(RESET)
+ 	set(CMAKE_REQUIRED_LIBRARIES ${FFMPEG_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -lm)
+-	check_function_exists(av_packet_unref HAVE_AV_PACKET_UNREF)
+-	check_function_exists(av_frame_alloc HAVE_AV_FRAME_ALLOC)
+-	check_function_exists(av_frame_free HAVE_AV_FRAME_FREE)
+ 	cmake_pop_check_state()
+ endif()
+
+@@ -163,14 +160,11 @@ message(STATUS "Using ${FFT_LIB} for FFT calculations")
+ if(NOT AUDIO_PROCESSOR_LIB)
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+ 		set(AUDIO_PROCESSOR_LIB "swresample")
+-	elseif(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(AUDIO_PROCESSOR_LIB "avresample")
+ 	endif()
+ endif()
+
+ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE OFF)
+ 		set(USE_SWRESAMPLE ON)
+ 		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBSWRESAMPLE_LIBRARIES})
+ 		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBSWRESAMPLE_INCLUDE_DIRS})
+@@ -178,16 +172,6 @@ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+ 	endif()
+ 	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+-elseif(AUDIO_PROCESSOR_LIB STREQUAL "avresample")
+-	if(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE ON)
+-		set(USE_SWRESAMPLE OFF)
+-		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBAVRESAMPLE_LIBRARIES})
+-		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBAVRESAMPLE_INCLUDE_DIRS})
+-	else()
+-		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+-	endif()
+-	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+ else()
+ 	message(STATUS "Building without audio conversion support, please install FFmpeg with libswresample")
+ endif()
+diff --git a/package/build.sh b/package/build.sh
+index da631ae..b41d36e 100755
+--- a/package/build.sh
++++ b/package/build.sh
+@@ -7,8 +7,8 @@ set -eux
+
+ BASE_DIR=$(cd $(dirname $0)/.. && pwd)
+
+-FFMPEG_VERSION=4.4.1
+-FFMPEG_BUILD_TAG=v4.4.1-1
++FFMPEG_VERSION=5.1.2
++FFMPEG_BUILD_TAG=v${FFMPEG_VERSION}-1
+
+ TMP_BUILD_DIR=$BASE_DIR/$(mktemp -d build.XXXXXXXX)
+ trap 'rm -rf $TMP_BUILD_DIR' EXIT
+diff --git a/src/audio/ffmpeg_audio_processor.h b/src/audio/ffmpeg_audio_processor.h
+index 7628fc7..39f4f6d 100644
+--- a/src/audio/ffmpeg_audio_processor.h
++++ b/src/audio/ffmpeg_audio_processor.h
+@@ -10,8 +10,6 @@
+
+ #if defined(USE_SWRESAMPLE)
+ #include "audio/ffmpeg_audio_processor_swresample.h"
+-#elif defined(USE_AVRESAMPLE)
+-#include "audio/ffmpeg_audio_processor_avresample.h"
+ #else
+ #error "no audio processing library"
+ #endif
+diff --git a/src/audio/ffmpeg_audio_processor_avresample.h b/src/audio/ffmpeg_audio_processor_avresample.h
+deleted file mode 100644
+index bd85f92..0000000
+--- a/src/audio/ffmpeg_audio_processor_avresample.h
++++ /dev/null
+@@ -1,72 +0,0 @@
+-// Copyright (C) 2016  Lukas Lalinsky
+-// Distributed under the MIT license, see the LICENSE file for details.
+-
+-#ifndef CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-#define CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-
+-extern "C" {
+-#include <libavresample/avresample.h>
+-}
+-
+-namespace chromaprint {
+-
+-class FFmpegAudioProcessor {
+-public:
+-	FFmpegAudioProcessor() {
+-		m_resample_ctx = avresample_alloc_context();
+-	}
+-
+-	~FFmpegAudioProcessor() {
+-		avresample_free(&m_resample_ctx);
+-	}
+-
+-	void SetCompatibleMode() {
+-		av_opt_set_int(m_resample_ctx, "filter_size", 16, 0);
+-		av_opt_set_int(m_resample_ctx, "phase_shift", 8, 0);
+-		av_opt_set_int(m_resample_ctx, "linear_interp", 1, 0);
+-		av_opt_set_double(m_resample_ctx, "cutoff", 0.8, 0);
+-	}
+-
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "in_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_rate", sample_rate, 0);
+-	}
+-
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "out_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_rate, 0);
+-	}
+-
+-	int Init() {
+-		return avresample_open(m_resample_ctx);
+-	}
+-
+-	int Convert(uint8_t **out, int out_count, const uint8_t **in, int in_count) {
+-		return avresample_convert(m_resample_ctx, out, 0, out_count, (uint8_t **) in, 0, in_count);
+-	}
+-
+-	int Flush(uint8_t **out, int out_count) {
+-		return avresample_read(m_resample_ctx, out, out_count);
+-	}
+-
+-private:
+-	AVAudioResampleContext *m_resample_ctx = nullptr;
+-};
+-
+-}; // namespace chromaprint
+-
+-#endif
+diff --git a/src/audio/ffmpeg_audio_processor_swresample.h b/src/audio/ffmpeg_audio_processor_swresample.h
+index b86266b..b1d4bea 100644
+--- a/src/audio/ffmpeg_audio_processor_swresample.h
++++ b/src/audio/ffmpeg_audio_processor_swresample.h
+@@ -28,30 +28,28 @@ public:
+ 		av_opt_set_double(m_swr_ctx, "cutoff", 0.8, 0);
+ 	}
+
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "icl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "ich", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetInputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "in_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "isf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "in_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "isr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "in_sample_rate", sample_rate, 0);
+ 	}
+
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "ocl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "och", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetOutputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "out_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "osf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "out_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "osr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "out_sample_rate", sample_rate, 0);
+ 	}
+
+ 	int Init() {
+diff --git a/src/audio/ffmpeg_audio_reader.h b/src/audio/ffmpeg_audio_reader.h
+index 5550164..1c6b346 100644
+--- a/src/audio/ffmpeg_audio_reader.h
++++ b/src/audio/ffmpeg_audio_reader.h
+@@ -62,7 +62,7 @@ public:
+ 	bool Read(const int16_t **data, size_t *size);
+
+ 	bool IsOpen() const { return m_opened; }
+-	bool IsFinished() const { return m_finished && !m_got_frame; }
++	bool IsFinished() const { return !m_has_more_packets && !m_has_more_frames; }
+
+ 	std::string GetError() const { return m_error; }
+ 	int GetErrorCode() const { return m_error_code; }
+@@ -74,20 +74,19 @@ private:
+ 	uint8_t *m_convert_buffer[1] = { nullptr };
+ 	int m_convert_buffer_nb_samples = 0;
+
+-	AVInputFormat *m_input_fmt = nullptr;
++	const AVInputFormat *m_input_fmt = nullptr;
+ 	AVDictionary *m_input_opts = nullptr;
+
+ 	AVFormatContext *m_format_ctx = nullptr;
+ 	AVCodecContext *m_codec_ctx = nullptr;
+-	AVFrame *m_frame = nullptr;
+ 	int m_stream_index = -1;
+ 	std::string m_error;
+ 	int m_error_code = 0;
+-	bool m_finished = false;
+ 	bool m_opened = false;
+-	int m_got_frame = 0;
+-	AVPacket m_packet;
+-	AVPacket m_packet0;
++	bool m_has_more_packets = true;
++	bool m_has_more_frames = true;
++	AVPacket *m_packet = nullptr;
++	AVFrame *m_frame = nullptr;
+
+ 	int m_output_sample_rate = 0;
+ 	int m_output_channels = 0;
+@@ -98,19 +97,12 @@ private:
+
+ inline FFmpegAudioReader::FFmpegAudioReader() {
+ 	av_log_set_level(AV_LOG_QUIET);
+-
+-	av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
+ }
+
+ inline FFmpegAudioReader::~FFmpegAudioReader() {
+ 	Close();
+ 	av_dict_free(&m_input_opts);
+ 	av_freep(&m_convert_buffer[0]);
+-	av_packet_unref(&m_packet0);
+ }
+
+ inline bool FFmpegAudioReader::SetInputFormat(const char *name) {
+@@ -135,11 +127,10 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ 	Close();
+
+-    av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
++	m_packet = av_packet_alloc();
++	if (!m_packet) {
++		return false;
++	}
+
+ 	ret = avformat_open_input(&m_format_ctx, file_name.c_str(), m_input_fmt, &m_input_opts);
+ 	if (ret < 0) {
+@@ -153,26 +144,31 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		return false;
+ 	}
+
+-	AVCodec *codec;
++	const AVCodec *codec;
+ 	ret = av_find_best_stream(m_format_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &codec, 0);
+ 	if (ret < 0) {
+ 		SetError("Could not find any audio stream in the file", ret);
+ 		return false;
+ 	}
+ 	m_stream_index = ret;
++	auto stream = m_format_ctx->streams[m_stream_index];
+
+-	m_codec_ctx = m_format_ctx->streams[m_stream_index]->codec;
++	m_codec_ctx = avcodec_alloc_context3(codec);
+ 	m_codec_ctx->request_sample_fmt = AV_SAMPLE_FMT_S16;
+
++	ret = avcodec_parameters_to_context(m_codec_ctx, stream->codecpar);
++	if (ret < 0) {
++		SetError("Could not copy the stream parameters", ret);
++		return false;
++	}
++
+ 	ret = avcodec_open2(m_codec_ctx, codec, nullptr);
+ 	if (ret < 0) {
+ 		SetError("Could not open the codec", ret);
+ 		return false;
+ 	}
+
+-	if (!m_codec_ctx->channel_layout) {
+-		m_codec_ctx->channel_layout = av_get_default_channel_layout(m_codec_ctx->channels);
+-	}
++	av_dump_format(m_format_ctx, 0, "foo", 0);
+
+ 	m_frame = av_frame_alloc();
+ 	if (!m_frame) {
+@@ -183,19 +179,23 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		m_output_sample_rate = m_codec_ctx->sample_rate;
+ 	}
+
+-	if (!m_output_channels) {
+-		m_output_channels = m_codec_ctx->channels;
++	AVChannelLayout output_channel_layout;
++	if (m_output_channels) {
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
++	} else {
++		m_output_channels = m_codec_ctx->ch_layout.nb_channels;
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
+ 	}
+
+-	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
++	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->ch_layout.nb_channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
+ 		m_converter.reset(new FFmpegAudioProcessor());
+ 		m_converter->SetCompatibleMode();
+ 		m_converter->SetInputSampleFormat(m_codec_ctx->sample_fmt);
+ 		m_converter->SetInputSampleRate(m_codec_ctx->sample_rate);
+-		m_converter->SetInputChannelLayout(m_codec_ctx->channel_layout);
++		m_converter->SetInputChannelLayout(&(m_codec_ctx->ch_layout));
+ 		m_converter->SetOutputSampleFormat(AV_SAMPLE_FMT_S16);
+ 		m_converter->SetOutputSampleRate(m_output_sample_rate);
+-		m_converter->SetOutputChannelLayout(av_get_default_channel_layout(m_output_channels));
++		m_converter->SetOutputChannelLayout(&output_channel_layout);
+ 		auto ret = m_converter->Init();
+ 		if (ret != 0) {
+ 			SetError("Could not create an audio converter instance", ret);
+@@ -203,10 +203,11 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		}
+ 	}
+
++	av_channel_layout_uninit(&output_channel_layout);
++
+ 	m_opened = true;
+-	m_finished = false;
+-	m_got_frame = 0;
+-	m_nb_packets = 0;
++	m_has_more_packets = true;
++	m_has_more_frames = true;
+ 	m_decode_error = 0;
+
+ 	return true;
+@@ -214,6 +215,7 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ inline void FFmpegAudioReader::Close() {
+ 	av_frame_free(&m_frame);
++	av_packet_free(&m_packet);
+
+ 	m_stream_index = -1;
+
+@@ -252,91 +254,98 @@ inline bool FFmpegAudioReader::Read(const int16_t **data, size_t *size) {
+ 		return false;
+ 	}
+
++	*data = nullptr;
++	*size = 0;
++
+ 	int ret;
++	bool needs_packet = false;
+ 	while (true) {
+-		while (m_packet.size <= 0) {
+-			av_packet_unref(&m_packet0);
+-			av_init_packet(&m_packet);
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			ret = av_read_frame(m_format_ctx, &m_packet);
++		while (needs_packet && m_packet->size == 0) {
++			ret = av_read_frame(m_format_ctx, m_packet);
+ 			if (ret < 0) {
+ 				if (ret == AVERROR_EOF) {
+-					m_finished = true;
++					needs_packet = false;
++					m_has_more_packets = false;
+ 					break;
+-				} else {
++				}
++				SetError("Error reading from the audio source", ret);
++				return false;
++			}
++			if (m_packet->stream_index == m_stream_index) {
++				needs_packet = false;
++			} else {
++				av_packet_unref(m_packet);
++			}
++		}
++
++		if (m_packet->size != 0) {
++			ret = avcodec_send_packet(m_codec_ctx, m_packet);
++			if (ret < 0) {
++				if (ret != AVERROR(EAGAIN)) {
+ 					SetError("Error reading from the audio source", ret);
+ 					return false;
+ 				}
+-			}
+-			m_packet0 = m_packet;
+-			if (m_packet.stream_index != m_stream_index) {
+-				m_packet.data = nullptr;
+-				m_packet.size = 0;
+ 			} else {
+-				m_nb_packets++;
++				av_packet_unref(m_packet);
+ 			}
+ 		}
+
+-		ret = avcodec_decode_audio4(m_codec_ctx, m_frame, &m_got_frame, &m_packet);
++		ret = avcodec_receive_frame(m_codec_ctx, m_frame);
+ 		if (ret < 0) {
+-			if (m_decode_error) {
+-				SetError("Error decoding audio frame", m_decode_error);
+-				return false;
++			if (ret == AVERROR_EOF) {
++				m_has_more_frames = false;
++			} else if (ret == AVERROR(EAGAIN)) {
++				if (m_has_more_packets) {
++					needs_packet = true;
++					continue;
++				} else {
++					m_has_more_frames = false;
++				}
+ 			}
+-			m_decode_error = ret;
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			continue;
++			SetError("Error decoding the audio source", ret);
++			return false;
+ 		}
+
+-		break;
+-	}
+-
+-	m_decode_error = 0;
+-
+-	const int decoded = std::min(ret, m_packet.size);
+-	m_packet.data += decoded;
+-	m_packet.size -= decoded;
+-
+-	if (m_got_frame) {
+-		if (m_converter) {
+-			if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
+-				int linsize;
+-				av_freep(&m_convert_buffer[0]);
+-				m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
+-				ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
+-				if (ret < 0) {
+-					SetError("Couldn't allocate audio converter buffer", ret);
++		if (m_frame->nb_samples > 0) {
++			if (m_converter) {
++				if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
++					int linsize;
++					av_freep(&m_convert_buffer[0]);
++					m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
++					ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->ch_layout.nb_channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
++					if (ret < 0) {
++						SetError("Couldn't allocate audio converter buffer", ret);
++						return false;
++					}
++				}
++				auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
++				if (nb_samples < 0) {
++					SetError("Couldn't convert audio", ret);
+ 					return false;
+ 				}
+-			}
+-			auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			}
+-			*data = (const int16_t *) m_convert_buffer[0];
+-			*size = nb_samples;
+-		} else {
+-			*data = (const int16_t *) m_frame->data[0];
+-			*size = m_frame->nb_samples;
+-		}
+-	} else {
+-		if (m_finished && m_converter) {
+-			auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			} else if (nb_samples > 0) {
+-				m_got_frame = 1;
+ 				*data = (const int16_t *) m_convert_buffer[0];
+ 				*size = nb_samples;
++			} else {
++				*data = (const int16_t *) m_frame->data[0];
++				*size = m_frame->nb_samples;
++			}
++		} else {
++			if (m_converter) {
++				if (IsFinished()) {
++					auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
++					if (nb_samples < 0) {
++						SetError("Couldn't convert audio", ret);
++						return false;
++					} else if (nb_samples > 0) {
++						*data = (const int16_t *) m_convert_buffer[0];
++						*size = nb_samples;
++					}
++				}
+ 			}
+ 		}
+-	}
+
+-	return true;
++		return true;
++	}
+ }
+
+ inline void FFmpegAudioReader::SetError(const char *message, int errnum) {
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index a2b517b..123e643 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -38,6 +38,12 @@ set(SRCS
+
+ if(BUILD_TOOLS)
+ 	set(SRCS ${SRCS} ../src/audio/ffmpeg_audio_reader_test.cpp)
++    include_directories(
++        ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}
++        ${AUDIO_PROCESSOR_INCLUDE_DIRS}
++    )
+ 	link_libraries(fpcalc_libs)
+ endif()
+
+-- 
+2.38.1
+
+
diff --git a/srcpkgs/chromaprint/template b/srcpkgs/chromaprint/template
index 7ef7838949f3a3..1f7bbc70a22c80 100644
--- a/srcpkgs/chromaprint/template
+++ b/srcpkgs/chromaprint/template
@@ -1,7 +1,7 @@
 # Template file for 'chromaprint'
 pkgname=chromaprint
 version=1.5.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DBUILD_TOOLS=ON"
 make_check_target="check"

From 59b727a2585520f6eb6fe0a5b43e519f0a3d3391 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 021/110] chromium: revbump for ffmpeg6

---
 srcpkgs/chromium/patches/ffmpeg5.patch | 47 ++++++++++++++++++++++++++
 srcpkgs/chromium/template              |  2 +-
 2 files changed, 48 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..24e2da38e34ca2
--- /dev/null
+++ b/srcpkgs/chromium/patches/ffmpeg5.patch
@@ -0,0 +1,47 @@
+--- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
++++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
+@@ -92,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+-  if (stream->start_time != kNoFFmpegTimestamp)
++  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -1597,7 +1585,7 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+@@ -1618,7 +1606,7 @@
+     if (stream->type() != DemuxerStream::VIDEO)
+       continue;
+ 
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+ 
+     if (!stream->IsEnabled())
diff --git a/srcpkgs/chromium/template b/srcpkgs/chromium/template
index 22947e83cb52c3..e8e5b92b5c8d5b 100644
--- a/srcpkgs/chromium/template
+++ b/srcpkgs/chromium/template
@@ -2,7 +2,7 @@
 pkgname=chromium
 # See https://chromiumdash.appspot.com/releases?platform=Linux for the latest version
 version=121.0.6167.160
-revision=1
+revision=2
 archs="i686* x86_64* aarch64* armv7l*"
 hostmakedepends="
  $(vopt_if clang "clang17 lld17 llvm17 compiler-rt")

From 74b7e594571da19bfdc47958983c529d2c31e015 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 022/110] cmus: revbump for ffmpeg6

---
 srcpkgs/chromium/patches/ffmpeg5.patch | 47 --------------------------
 srcpkgs/cmus/patches/ffmpeg6.patch     | 12 +++++++
 srcpkgs/cmus/template                  |  2 +-
 3 files changed, 13 insertions(+), 48 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch
 create mode 100644 srcpkgs/cmus/patches/ffmpeg6.patch

diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
deleted file mode 100644
index 24e2da38e34ca2..00000000000000
--- a/srcpkgs/chromium/patches/ffmpeg5.patch
+++ /dev/null
@@ -1,47 +0,0 @@
---- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
-+++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
-@@ -92,24 +92,12 @@
- 
- static base::TimeDelta ExtractStartTime(AVStream* stream) {
-   // The default start time is zero.
--  base::TimeDelta start_time;
-+  base::TimeDelta start_time = kNoTimestamp;
- 
-   // First try to use  the |start_time| value as is.
--  if (stream->start_time != kNoFFmpegTimestamp)
-+  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
-     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
- 
--  // Next try to use the first DTS value, for codecs where we know PTS == DTS
--  // (excludes all H26x codecs). The start time must be returned in PTS.
--  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
--      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
--      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
--      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
--    const base::TimeDelta first_pts =
--        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
--    if (first_pts < start_time)
--      start_time = first_pts;
--  }
--
-   return start_time;
- }
- 
-@@ -1597,7 +1585,7 @@
-   for (const auto& stream : streams_) {
-     if (!stream || stream->IsEnabled() != enabled)
-       continue;
--    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
-+    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
-       continue;
-     if (!lowest_start_time_stream ||
-         stream->start_time() < lowest_start_time_stream->start_time()) {
-@@ -1618,7 +1606,7 @@
-     if (stream->type() != DemuxerStream::VIDEO)
-       continue;
- 
--    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
-+    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
-       continue;
- 
-     if (!stream->IsEnabled())
diff --git a/srcpkgs/cmus/patches/ffmpeg6.patch b/srcpkgs/cmus/patches/ffmpeg6.patch
new file mode 100644
index 00000000000000..ffa95ab811101b
--- /dev/null
+++ b/srcpkgs/cmus/patches/ffmpeg6.patch
@@ -0,0 +1,12 @@
+--- a/ip/ffmpeg.c
++++ b/ip/ffmpeg.c
+@@ -202,9 +202,6 @@ static int ffmpeg_open(struct input_plugin_data *ip_data)
+ 			break;
+ 		}
+ 
+-		if (codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+-			cc->flags |= AV_CODEC_FLAG_TRUNCATED;
+-
+ 		if (avcodec_open2(cc, codec, NULL) < 0) {
+ 			d_print("could not open codec: %d, %s\n", cc->codec_id, avcodec_get_name(cc->codec_id));
+ 			err = -IP_ERROR_UNSUPPORTED_FILE_TYPE;
diff --git a/srcpkgs/cmus/template b/srcpkgs/cmus/template
index 0d1436744f1b2c..a6e4b4fa86cb83 100644
--- a/srcpkgs/cmus/template
+++ b/srcpkgs/cmus/template
@@ -1,7 +1,7 @@
 # Template file for 'cmus'
 pkgname=cmus
 version=2.10.0
-revision=3
+revision=4
 build_style=configure
 configure_args="prefix=/usr LD=$CC"
 hostmakedepends="pkg-config"

From 747ff581f7fa395ae9c4e1b9777d51ce49b9ba90 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 023/110] cyanrip: revbump for ffmpeg6

---
 srcpkgs/cyanrip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cyanrip/template b/srcpkgs/cyanrip/template
index 9796e3461601a7..5db30e020d17ee 100644
--- a/srcpkgs/cyanrip/template
+++ b/srcpkgs/cyanrip/template
@@ -1,7 +1,7 @@
 # Template file for 'cyanrip'
 pkgname=cyanrip
 version=0.9.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config"
 makedepends="ffmpeg-devel libcdio-devel libcdio-paranoia-devel libcurl-devel libmusicbrainz5-devel"

From 2c3175d64bf7b4ebef2e01fb57309dcdcb9816d0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 024/110] deadbeef: revbump for ffmpeg4

---
 srcpkgs/deadbeef/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/deadbeef/template b/srcpkgs/deadbeef/template
index f5f4bf24b8cb6d..7b47e615cd48ef 100644
--- a/srcpkgs/deadbeef/template
+++ b/srcpkgs/deadbeef/template
@@ -1,14 +1,14 @@
 # Template file for 'deadbeef'
 pkgname=deadbeef
 version=1.8.8
-revision=3
+revision=4
 create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-oss --disable-lfm --disable-notify --disable-gtk2"
 hostmakedepends="automake libtool gettext gettext-devel intltool pkg-config
  yasm clang glib-devel"
 makedepends="
- alsa-lib-devel dbus-devel faad2-devel ffmpeg-devel gtk+3-devel imlib2-devel
+ alsa-lib-devel dbus-devel faad2-devel ffmpeg4-devel gtk+3-devel imlib2-devel
  jansson-devel libcddb-devel libcdio-devel libcurl-devel libflac-devel
  libmad-devel libpng-devel libsamplerate-devel libsndfile-devel libvorbis-devel
  libzip-devel mpg123-devel opusfile-devel pulseaudio-devel wavpack-devel"

From 76467264bf10c1669da087e4101032e65adf9751 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 025/110] droidcam-obs-plugin: revbump for ffmpeg6

---
 srcpkgs/droidcam-obs-plugin/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam-obs-plugin/template b/srcpkgs/droidcam-obs-plugin/template
index fc9c9bf6b9d54c..fb0480754df4de 100644
--- a/srcpkgs/droidcam-obs-plugin/template
+++ b/srcpkgs/droidcam-obs-plugin/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam-obs-plugin'
 pkgname=droidcam-obs-plugin
 version=2.0.1
-revision=1
+revision=2
 build_style=gnu-makefile
 make_use_env=yes
 make_build_args="ALLOW_STATIC=no"

From c9440372c5e428de987f65590815eca5036cbfcd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 026/110] droidcam: revbump for ffmpeg6

---
 srcpkgs/droidcam/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam/template b/srcpkgs/droidcam/template
index 1c3f1b8b1fc676..32a9220b79a4d1 100644
--- a/srcpkgs/droidcam/template
+++ b/srcpkgs/droidcam/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam'
 pkgname=droidcam
 version=1.8.2
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="USBMUXD=-lusbmuxd-2.0 JPEG=-lturbojpeg"
 hostmakedepends="pkg-config"

From eb5a8a123eae6f0bc98f069f5468fcbad2f34d99 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 027/110] ffmpegthumbnailer: revbump for ffmpeg6

---
 .../ffmpegthumbnailer/patches/ffmpeg6.patch   | 202 ++++++++++++++++++
 srcpkgs/ffmpegthumbnailer/template            |   6 +-
 2 files changed, 205 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch

diff --git a/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
new file mode 100644
index 00000000000000..363ff35a28419d
--- /dev/null
+++ b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
@@ -0,0 +1,202 @@
+--- a/libffmpegthumbnailer/moviedecoder.cpp	2017-11-21 14:06:57.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.cpp	2023-05-05 13:14:47.946560668 -0400
+@@ -41,11 +41,6 @@
+ namespace ffmpegthumbnailer
+ {
+ 
+-struct SilenceLogLevel
+-{
+-    SilenceLogLevel() { av_log_set_level(AV_LOG_QUIET); }
+-};
+-
+ MovieDecoder::MovieDecoder(AVFormatContext* pavContext)
+ : m_VideoStream(-1)
+ , m_pFormatContext(pavContext)
+@@ -70,8 +65,6 @@
+ 
+ void MovieDecoder::initialize(const string& filename, bool preferEmbeddedMetadata)
+ {
+-    av_register_all();
+-    avcodec_register_all();
+     avformat_network_init();
+ 
+     string inputFile = filename == "-" ? "pipe:" : filename;
+@@ -97,8 +90,7 @@
+ {
+     if (m_pVideoCodecContext)
+     {
+-        avcodec_close(m_pVideoCodecContext);
+-        m_pVideoCodecContext = nullptr;
++        avcodec_free_context(&m_pVideoCodecContext);
+     }
+ 
+     if ((!m_FormatContextWasGiven) && m_pFormatContext)
+@@ -152,10 +144,10 @@
+     for (unsigned int i = 0; i < m_pFormatContext->nb_streams; ++i)
+     {
+         AVStream *stream = m_pFormatContext->streams[i];
+-        auto ctx = m_pFormatContext->streams[i]->codec;
+-        if (ctx->codec_type == AVMEDIA_TYPE_VIDEO)
++        auto par = m_pFormatContext->streams[i]->codecpar;
++        if (par->codec_type == AVMEDIA_TYPE_VIDEO)
+         {
+-            if (!preferEmbeddedMetadata || !isStillImageCodec(ctx->codec_id))
++            if (!preferEmbeddedMetadata || !isStillImageCodec(par->codec_id))
+             {
+                 videoStreams.push_back(i);
+                 continue;
+@@ -203,8 +195,7 @@
+     }
+ 
+     m_pVideoStream = m_pFormatContext->streams[m_VideoStream];
+-    m_pVideoCodecContext = m_pVideoStream->codec;
+-    m_pVideoCodec = avcodec_find_decoder(m_pVideoCodecContext->codec_id);
++    m_pVideoCodec = avcodec_find_decoder(m_pVideoStream->codecpar->codec_id);
+ 
+     if (m_pVideoCodec == nullptr)
+     {
+@@ -214,6 +205,20 @@
+         throw logic_error("Video Codec not found");
+     }
+ 
++    m_pVideoCodecContext = avcodec_alloc_context3(m_pVideoCodec);
++
++    if (m_pVideoCodecContext == nullptr)
++    {
++        destroy();
++        throw logic_error("Could not allocate video codec context");
++    }
++
++    if (avcodec_parameters_to_context(m_pVideoCodecContext, m_pVideoStream->codecpar) < 0)
++    {
++        destroy();
++        throw logic_error("Could not configure video codec context");
++    }
++
+     m_pVideoCodecContext->workaround_bugs = 1;
+ 
+     if (avcodec_open2(m_pVideoCodecContext, m_pVideoCodec, nullptr) < 0)
+@@ -386,13 +391,6 @@
+ 
+ void MovieDecoder::initializeFilterGraph(const AVRational& timeBase, const std::string& size, bool maintainAspectRatio)
+ {
+-    static const AVPixelFormat pixelFormats[] = { AV_PIX_FMT_RGB24, AV_PIX_FMT_NONE };
+-
+-    auto del = [] (AVBufferSinkParams* p) { av_freep(p); };
+-    std::unique_ptr<AVBufferSinkParams, decltype(del)> buffersinkParams(av_buffersink_params_alloc(), del);
+-
+-    avfilter_register_all();
+-
+     m_pFilterGraph = avfilter_graph_alloc();
+     assert(m_pFilterGraph);
+ 
+@@ -404,10 +402,8 @@
+ 
+     checkRc(avfilter_graph_create_filter(&m_pFilterSource, avfilter_get_by_name("buffer"), "thumb_buffer", ss.str().c_str(), nullptr, m_pFilterGraph),
+             "Failed to create filter source");
+-    buffersinkParams->pixel_fmts = pixelFormats;
+-    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, buffersinkParams.get(), m_pFilterGraph),
++    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, nullptr, m_pFilterGraph),
+             "Failed to create filter sink");
+-    buffersinkParams.release();
+ 
+     AVFilterContext* yadifFilter = nullptr;
+     if (m_pFrame->interlaced_frame != 0)
+@@ -500,15 +496,15 @@
+     }
+ 
+     checkRc(av_seek_frame(m_pFormatContext, -1, timestamp, 0), "Seeking in video failed");
+-    avcodec_flush_buffers(m_pFormatContext->streams[m_VideoStream]->codec);
++    avcodec_flush_buffers(m_pVideoCodecContext);
+ 
+     int keyFrameAttempts = 0;
+-    bool gotFrame = 0;
++    bool gotFrame;
+ 
+     do
+     {
+         int count = 0;
+-        gotFrame = 0;
++        gotFrame = false;
+ 
+         while (!gotFrame && count < 20)
+         {
+@@ -552,17 +548,33 @@
+         return false;
+     }
+ 
+-    av_frame_unref(m_pFrame);
+-
+-    int frameFinished;
++    int rc = avcodec_send_packet(m_pVideoCodecContext, m_pPacket);
++    if(rc == AVERROR(EAGAIN))
++    {
++        rc = 0;
++    }
+ 
+-    int bytesDecoded = avcodec_decode_video2(m_pVideoCodecContext, m_pFrame, &frameFinished, m_pPacket);
+-    if (bytesDecoded < 0)
++    if(rc == AVERROR_EOF)
++    {
++        return false;
++    }
++    else if(rc < 0)
+     {
+-        throw logic_error("Failed to decode video frame: bytesDecoded < 0");
++        throw logic_error("Failed to decode video frame: avcodec_send_packet() < 0");
+     }
+ 
+-    return frameFinished > 0;
++    rc = avcodec_receive_frame(m_pVideoCodecContext, m_pFrame);
++    switch(rc)
++    {
++        case 0:
++            return true;
++
++        case AVERROR(EAGAIN):
++            return false;
++
++        default:
++            throw logic_error("Failed to decode video frame: avcodec_receive_frame() < 0");
++    }
+ }
+ 
+ bool MovieDecoder::getVideoPacket()
+@@ -570,8 +582,6 @@
+     bool framesAvailable = true;
+     bool frameDecoded = false;
+ 
+-    int attempts = 0;
+-
+     if (m_pPacket)
+     {
+         av_packet_unref(m_pPacket);
+@@ -580,6 +590,7 @@
+ 
+     m_pPacket = new AVPacket();
+ 
++
+     while (framesAvailable && !frameDecoded)
+     {
+         framesAvailable = av_read_frame(m_pFormatContext, m_pPacket) >= 0;
+@@ -644,7 +655,7 @@
+ 
+ int32_t MovieDecoder::getStreamRotation()
+ {
+-    int32_t* matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
++    auto matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
+     if (matrix)
+     {
+         auto angle = lround(av_display_rotation_get(matrix));
+
+--- a/libffmpegthumbnailer/moviedecoder.h	2017-11-12 04:23:38.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.h	2023-05-05 13:26:07.095529911 -0400
+@@ -78,7 +78,7 @@
+     int                     m_VideoStream;
+     AVFormatContext*        m_pFormatContext;
+     AVCodecContext*         m_pVideoCodecContext;
+-    AVCodec*                m_pVideoCodec;
++    const AVCodec*          m_pVideoCodec;
+     AVFilterGraph*          m_pFilterGraph;
+     AVFilterContext*        m_pFilterSource;
+     AVFilterContext*        m_pFilterSink;
diff --git a/srcpkgs/ffmpegthumbnailer/template b/srcpkgs/ffmpegthumbnailer/template
index 039eea7622b391..35d546018d12af 100644
--- a/srcpkgs/ffmpegthumbnailer/template
+++ b/srcpkgs/ffmpegthumbnailer/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbnailer'
 pkgname=ffmpegthumbnailer
 version=2.2.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libpng-devel libjpeg-turbo-devel ffmpeg-devel"
@@ -9,8 +9,8 @@ depends="ffmpeg"
 short_desc="Lightweight video thumbnailer"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
-homepage="https://github.com/dirkvdb/${pkgname}"
-distfiles="${homepage}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
+homepage="https://github.com/dirkvdb"
+distfiles="${homepage}/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
 checksum=1cb24059c38223f657b300c84dd80491b7040d4b69471c4fea69be862bc99b5b
 
 post_install() {

From 263f251eb9337565bf0153610964f1c1ac3de54f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 028/110] ffmpegthumbs: revbump for ffmpeg6

---
 srcpkgs/ffmpegthumbs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ffmpegthumbs/template b/srcpkgs/ffmpegthumbs/template
index 2e2a96de83ce8a..dfd7e9dede36d3 100644
--- a/srcpkgs/ffmpegthumbs/template
+++ b/srcpkgs/ffmpegthumbs/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbs'
 pkgname=ffmpegthumbs
 version=23.08.5
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules kcoreaddons kconfig-devel
  pkg-config qt5-host-tools qt5-qmake gettext"

From 6cde5c9a015f5608cd32b666c4fa8dbe0a91657e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 029/110] ffms2: revbump for ffmpeg6

---
 srcpkgs/ffms2/patches/ffmpeg5.patch | 424 ++++++++++++++++++++++++++++
 srcpkgs/ffms2/template              |   2 +-
 2 files changed, 425 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ffms2/patches/ffmpeg5.patch

diff --git a/srcpkgs/ffms2/patches/ffmpeg5.patch b/srcpkgs/ffms2/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..1479fabcafcb4e
--- /dev/null
+++ b/srcpkgs/ffms2/patches/ffmpeg5.patch
@@ -0,0 +1,424 @@
+From 45673149e9a2f5586855ad472e3059084eaa36b1 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:41:21 +0100
+Subject: [PATCH] Use auto for AVCodec
+
+The geniuses over at FFmpeg decided to constify this API, so old
+versions of the library will return AVCodec *, while new versions
+of the libary will return const AVCodec *, which, in C++, are not
+OK to convert between.
+
+Rather than use some macro hell in ffmscompat.h, we can work around
+this by using auto.
+
+Gross.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 2 +-
+ src/core/indexing.cpp    | 6 +++---
+ src/core/videosource.cpp | 2 +-
+ 3 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index e4ce97c..ac09666 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -469,7 +469,7 @@ void FFMS_AudioSource::OpenFile() {
+ 
+     LAVFOpenFile(SourceFile.c_str(), FormatContext, TrackNumber);
+ 
+-    AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
++    auto *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
+     if (Codec == nullptr)
+         throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+             "Audio codec not found");
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index e547c5a..59fb4e8 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -384,7 +384,7 @@ FFMS_TrackType FFMS_Indexer::GetTrackType(int Track) {
+ }
+ 
+ const char *FFMS_Indexer::GetTrackCodec(int Track) {
+-    AVCodec *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
++    auto *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
+     return codec ? codec->name : nullptr;
+ }
+ 
+@@ -402,7 +402,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             UseDTS);
+ 
+         if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            AVCodec *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (!VideoCodec) {
+                 FormatContext->streams[i]->discard = AVDISCARD_ALL;
+                 IndexMask.erase(i);
+@@ -433,7 +433,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 IndexMask.insert(i);
+             }
+         } else if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+-            AVCodec *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (AudioCodec == nullptr)
+                 throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_UNSUPPORTED,
+                     "Audio codec not found");
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index b889970..8956c22 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -171,7 +171,7 @@ FFMS_VideoSource::FFMS_VideoSource(const char *SourceFile, FFMS_Index &Index, in
+ 
+         LAVFOpenFile(SourceFile, FormatContext, VideoTrack);
+ 
+-        AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
++        auto *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
+         if (Codec == nullptr)
+             throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+                 "Video codec not found");
+-- 
+2.40.0
+
+From 96cbf38ea9381829a1314f432a2c60495dcefaad Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:12:41 +0100
+Subject: [PATCH] all: Update AVPacket API usage
+
+AVPackets must all be on the heap now, since it is no longer
+part of the libav* ABI.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 16 ++++++----
+ src/core/indexing.cpp    | 63 ++++++++++++++++++++++------------------
+ src/core/indexing.h      |  4 +--
+ src/core/utils.cpp       |  6 ----
+ src/core/utils.h         |  1 -
+ src/core/videosource.cpp | 30 ++++++++++---------
+ 6 files changed, 64 insertions(+), 56 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index 37cf9ae..e4ce97c 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -285,10 +285,15 @@ FFMS_AudioSource::AudioBlock *FFMS_AudioSource::CacheBlock(CacheIterator &pos) {
+ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     CurrentFrame = &Frames[PacketNumber];
+ 
+-    AVPacket Packet;
+-    if (!ReadPacket(&Packet))
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++    if (!ReadPacket(Packet)) {
++        av_packet_free(&Packet);
+         throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_UNKNOWN,
+             "ReadPacket unexpectedly failed to read a packet");
++    }
+ 
+     // ReadPacket may have changed the packet number
+     CurrentFrame = &Frames[PacketNumber];
+@@ -297,8 +302,9 @@ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     int NumberOfSamples = 0;
+     AudioBlock *CachedBlock = nullptr;
+     
+-    int Ret = avcodec_send_packet(CodecContext, &Packet);
+-    av_packet_unref(&Packet);
++    int Ret = avcodec_send_packet(CodecContext, Packet);
++    av_packet_unref(Packet);
++    av_packet_free(&Packet);
+ 
+     av_frame_unref(DecodeFrame);
+     Ret = avcodec_receive_frame(CodecContext, DecodeFrame);
+@@ -513,8 +519,6 @@ void FFMS_AudioSource::Seek() {
+ }
+ 
+ bool FFMS_AudioSource::ReadPacket(AVPacket *Packet) {
+-    InitNullPacket(*Packet);
+-
+     while (av_read_frame(FormatContext, Packet) >= 0) {
+         if (Packet->stream_index == TrackNumber) {
+             // Required because not all audio packets, especially in ogg, have a pts. Use the previous valid packet's pts instead.
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index 23fb95b..e547c5a 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -320,7 +320,7 @@ void FFMS_Indexer::CheckAudioProperties(int Track, AVCodecContext *Context) {
+     }
+ }
+ 
+-void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict,
++void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict,
+                                     int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct) {
+     if (VideoContext.Parser) {
+         uint8_t *OB;
+@@ -330,8 +330,8 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+         av_parser_parse2(VideoContext.Parser,
+             VideoContext.CodecContext,
+             &OB, &OBSize,
+-            pkt.data, pkt.size,
+-            pkt.pts, pkt.dts, pkt.pos);
++            pkt->data, pkt->size,
++            pkt->pts, pkt->dts, pkt->pos);
+ 
+         // H.264 (PAFF) and HEVC may have one field per packet, so we need to track
+         // when we have a full or half frame available, and mark one of them as
+@@ -351,15 +351,15 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+ 
+         *RepeatPict = VideoContext.Parser->repeat_pict;
+         *FrameType = VideoContext.Parser->pict_type;
+-        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt.flags & AV_PKT_FLAG_DISCARD));
++        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt->flags & AV_PKT_FLAG_DISCARD));
+     } else {
+-        *Invisible = !!(pkt.flags & AV_PKT_FLAG_DISCARD);
++        *Invisible = !!(pkt->flags & AV_PKT_FLAG_DISCARD);
+     }
+ 
+     if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP8)
+-        ParseVP8(pkt.data[0], Invisible, FrameType);
++        ParseVP8(pkt->data[0], Invisible, FrameType);
+     else if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP9)
+-        ParseVP9(pkt.data[0], Invisible, FrameType);
++        ParseVP9(pkt->data[0], Invisible, FrameType);
+ }
+ 
+ void FFMS_Indexer::Free() {
+@@ -458,32 +458,36 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+         }
+     }
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
+     std::vector<int64_t> LastValidTS(FormatContext->nb_streams, AV_NOPTS_VALUE);
+ 
+     int64_t filesize = avio_size(FormatContext->pb);
+     enum AVPictureStructure LastPicStruct = AV_PICTURE_STRUCTURE_UNKNOWN;
+-    while (av_read_frame(FormatContext, &Packet) >= 0) {
++    while (av_read_frame(FormatContext, Packet) >= 0) {
+         // Update progress
+         // FormatContext->pb can apparently be NULL when opening images.
+         if (IC && FormatContext->pb) {
+-            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate))
++            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate)) {
++                av_packet_free(&Packet);
+                 throw FFMS_Exception(FFMS_ERROR_CANCELLED, FFMS_ERROR_USER,
+                     "Cancelled by user");
++            }
+         }
+-        if (!IndexMask.count(Packet.stream_index)) {
+-            av_packet_unref(&Packet);
++        if (!IndexMask.count(Packet->stream_index)) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+-        int Track = Packet.stream_index;
++        int Track = Packet->stream_index;
+         FFMS_Track &TrackInfo = (*TrackIndices)[Track];
+-        bool KeyFrame = !!(Packet.flags & AV_PKT_FLAG_KEY);
++        bool KeyFrame = !!(Packet->flags & AV_PKT_FLAG_KEY);
+         ReadTS(Packet, LastValidTS[Track], (*TrackIndices)[Track].UseDTS);
+ 
+         if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            int64_t PTS = TrackInfo.UseDTS ? Packet.dts : Packet.pts;
++            int64_t PTS = TrackInfo.UseDTS ? Packet->dts : Packet->pts;
+             if (PTS == AV_NOPTS_VALUE) {
+                 // VPx alt-refs are output as packets which lack timestmps or durations, since
+                 // they are invisible. Currently, the timestamp mangling code in libavformat
+@@ -495,9 +499,11 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 // FFMS2 currently sorts packets by PTS, which will break decoding, otherwise.
+                 bool HasAltRefs = (FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP8 ||
+                                    FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP9);
+-                if (Packet.duration == 0 && !HasAltRefs)
++                if (Packet->duration == 0 && !HasAltRefs) {
++                    av_packet_free(&Packet);
+                     throw FFMS_Exception(FFMS_ERROR_INDEXING, FFMS_ERROR_PARSER,
+                         "Invalid packet pts, dts, and duration");
++                }
+ 
+                 if (TrackInfo.empty())
+                     PTS = 0;
+@@ -513,7 +519,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             ParseVideoPacket(AVContexts[Track], Packet, &RepeatPict, &FrameType, &Invisible, &LastPicStruct);
+ 
+             TrackInfo.AddVideoFrame(PTS, RepeatPict, KeyFrame,
+-                FrameType, Packet.pos, Invisible);
++                FrameType, Packet->pos, Invisible);
+         } else if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+             // For video seeking timestamps are used only if all packets have
+             // timestamps, while for audio they're used if any have timestamps,
+@@ -522,28 +528,29 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 TrackInfo.HasTS = true;
+ 
+             int64_t StartSample = AVContexts[Track].CurrentSample;
+-            uint32_t SampleCount = IndexAudioPacket(Track, &Packet, AVContexts[Track], *TrackIndices);
++            uint32_t SampleCount = IndexAudioPacket(Track, Packet, AVContexts[Track], *TrackIndices);
+             TrackInfo.SampleRate = AVContexts[Track].CodecContext->sample_rate;
+ 
+             TrackInfo.AddAudioFrame(LastValidTS[Track],
+-                StartSample, SampleCount, KeyFrame, Packet.pos, Packet.flags & AV_PKT_FLAG_DISCARD);
++                StartSample, SampleCount, KeyFrame, Packet->pos, Packet->flags & AV_PKT_FLAG_DISCARD);
+         }
+ 
+-        if (!(Packet.flags & AV_PKT_FLAG_DISCARD))
+-            TrackInfo.LastDuration = Packet.duration;
++        if (!(Packet->flags & AV_PKT_FLAG_DISCARD))
++            TrackInfo.LastDuration = Packet->duration;
+ 
+-        av_packet_unref(&Packet);
++        av_packet_unref(Packet);
+     }
++    av_packet_free(&Packet);
+ 
+     TrackIndices->Finalize(AVContexts, FormatContext->iformat->name);
+     return TrackIndices.release();
+ }
+ 
+-void FFMS_Indexer::ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS) {
+-    if (!UseDTS && Packet.pts != AV_NOPTS_VALUE)
+-        TS = Packet.pts;
++void FFMS_Indexer::ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS) {
++    if (!UseDTS && Packet->pts != AV_NOPTS_VALUE)
++        TS = Packet->pts;
+     if (TS == AV_NOPTS_VALUE)
+         UseDTS = true;
+-    if (UseDTS && Packet.dts != AV_NOPTS_VALUE)
+-        TS = Packet.dts;
++    if (UseDTS && Packet->dts != AV_NOPTS_VALUE)
++        TS = Packet->dts;
+ }
+diff --git a/src/core/indexing.h b/src/core/indexing.h
+index 3cfc3c3..5c06868 100644
+--- a/src/core/indexing.h
++++ b/src/core/indexing.h
+@@ -80,10 +80,10 @@ private:
+     int64_t Filesize;
+     uint8_t Digest[20];
+ 
+-    void ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS);
++    void ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS);
+     void CheckAudioProperties(int Track, AVCodecContext *Context);
+     uint32_t IndexAudioPacket(int Track, AVPacket *Packet, SharedAVContext &Context, FFMS_Index &TrackIndices);
+-    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
++    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
+     void Free();
+ public:
+     FFMS_Indexer(const char *Filename);
+diff --git a/src/core/utils.cpp b/src/core/utils.cpp
+index ce67533..8a2e997 100644
+--- a/src/core/utils.cpp
++++ b/src/core/utils.cpp
+@@ -62,12 +62,6 @@ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo) {
+     }
+ }
+ 
+-void InitNullPacket(AVPacket &pkt) {
+-    av_init_packet(&pkt);
+-    pkt.data = nullptr;
+-    pkt.size = 0;
+-}
+-
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames) {
+     AP.SampleFormat = static_cast<FFMS_SampleFormat>(av_get_packed_sample_fmt(CTX->sample_fmt));
+     AP.BitsPerSample = av_get_bytes_per_sample(CTX->sample_fmt) * 8;
+diff --git a/src/core/utils.h b/src/core/utils.h
+index 9819dc7..003ab79 100644
+--- a/src/core/utils.h
++++ b/src/core/utils.h
+@@ -58,7 +58,6 @@ std::unique_ptr<T> make_unique(Args&&... args) {
+ }
+ 
+ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo);
+-void InitNullPacket(AVPacket &pkt);
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames);
+ 
+ void LAVFOpenFile(const char *SourceFile, AVFormatContext *&FormatContext, int Track);
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index 06bd161..b889970 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -673,30 +673,34 @@ void FFMS_VideoSource::DecodeNextFrame(int64_t &AStartTime, int64_t &Pos) {
+     if (HasPendingDelayedFrames())
+         return;
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
+-
+-    while (ReadFrame(&Packet) >= 0) {
+-        if (Packet.stream_index != VideoTrack) {
+-            av_packet_unref(&Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++
++    while (ReadFrame(Packet) >= 0) {
++        if (Packet->stream_index != VideoTrack) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+         if (AStartTime < 0)
+-            AStartTime = Frames.UseDTS ? Packet.dts : Packet.pts;
++            AStartTime = Frames.UseDTS ? Packet->dts : Packet->pts;
+ 
+         if (Pos < 0)
+-            Pos = Packet.pos;
++            Pos = Packet->pos;
+ 
+-        bool FrameFinished = DecodePacket(&Packet);
+-        av_packet_unref(&Packet);
+-        if (FrameFinished)
++        bool FrameFinished = DecodePacket(Packet);
++        av_packet_unref(Packet);
++        if (FrameFinished) {
++            av_packet_free(&Packet);
+             return;
++        }
+     }
+ 
+     // Flush final frames
+-    InitNullPacket(Packet);
+-    DecodePacket(&Packet);
++    DecodePacket(Packet);
++    av_packet_free(&Packet);
+ }
+ 
+ bool FFMS_VideoSource::SeekTo(int n, int SeekOffset) {
+-- 
+2.40.0
+
+From bf9e03e9e08534c024e5a744a6437c4aac160201 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:20:47 +0100
+Subject: [PATCH 2/3] configure: Remove deprecated API use
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ configure.ac | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index b35ef80bc..d19714d0f 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -102,10 +102,10 @@ CFLAGS="$_CFLAGS $FFMPEG_CFLAGS"
+
+ AC_DEFUN([TEST_FFMPEG],
+          [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+-            #include <libavcodec/avcodec.h>
++            #include <libavformat/avformat.h>
+             #include <libswscale/swscale.h>
+             ]],[[
+-                avcodec_register_all();
++                avformat_network_init();
+                 swscale_version();
+             ]])], [eval $1=yes], [eval $1=no])
+         ])
+
diff --git a/srcpkgs/ffms2/template b/srcpkgs/ffms2/template
index 365f64d10cbabf..1641ecf43be5bb 100644
--- a/srcpkgs/ffms2/template
+++ b/srcpkgs/ffms2/template
@@ -1,7 +1,7 @@
 # Template file for 'ffms2'
 pkgname=ffms2
 version=2.40
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-shared --disable-static"
 hostmakedepends="pkg-config autoconf automake libtool"

From f373e6eaaaa344bd96a74a5e254721842c520bd4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 030/110] freerdp: revbump for ffmpeg6

---
 .../freerdp/patches/ffmpeg6_aa2cb9aa.patch    | 42 +++++++++++++++++++
 srcpkgs/freerdp/template                      |  2 +-
 2 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch

diff --git a/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
new file mode 100644
index 00000000000000..a4324da3a8822b
--- /dev/null
+++ b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
@@ -0,0 +1,42 @@
+From aa2cb9aa5ff5562433598ba168a466e0752bca0e Mon Sep 17 00:00:00 2001
+From: akallabeth <akallabeth@posteo.net>
+Date: Tue, 14 Feb 2023 07:48:54 +0100
+Subject: [PATCH] Fixed #8686: Update h264 to use new FFMPEG API
+
+---
+ channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c | 2 ++
+ libfreerdp/codec/h264_ffmpeg.c            | 2 ++
+ 2 files changed, 4 insertions(+)
+
+diff --git a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+index 339462d865f..beea80b7a1e 100644
+--- a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
++++ b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+@@ -239,8 +239,10 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYP
+ 		}
+ 	}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 	if (mdecoder->codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		mdecoder->codec_context->flags |= AV_CODEC_FLAG_TRUNCATED;
++#endif
+ 
+ 	return TRUE;
+ }
+diff --git a/libfreerdp/codec/h264_ffmpeg.c b/libfreerdp/codec/h264_ffmpeg.c
+index 8a23db2473c..896a333019b 100644
+--- a/libfreerdp/codec/h264_ffmpeg.c
++++ b/libfreerdp/codec/h264_ffmpeg.c
+@@ -615,10 +615,12 @@ static BOOL libavcodec_init(H264_CONTEXT* h264)
+ 			goto EXCEPTION;
+ 		}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 		if (sys->codecDecoder->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		{
+ 			sys->codecDecoderContext->flags |= AV_CODEC_FLAG_TRUNCATED;
+ 		}
++#endif
+ 
+ #ifdef WITH_VAAPI
+ 
diff --git a/srcpkgs/freerdp/template b/srcpkgs/freerdp/template
index 16fddfbe8f5287..bf3a4d2e2b3ae7 100644
--- a/srcpkgs/freerdp/template
+++ b/srcpkgs/freerdp/template
@@ -1,7 +1,7 @@
 # Template file for 'freerdp'
 pkgname=freerdp
 version=2.11.4
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_ALSA=ON -DWITH_CUPS=OFF -DWITH_FFMPEG=ON
  -DWITH_GSTREAMER_0_10=OFF -DWITH_GSTREAMER_1_0=OFF -DWITH_JPEG=ON

From 251117617ee6478df31f9f93ce7e083b05576afd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 031/110] gerbera: revbump for ffmpeg6

---
 srcpkgs/gerbera/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gerbera/template b/srcpkgs/gerbera/template
index ae14f35c767c03..2dc0ac0ce03b55 100644
--- a/srcpkgs/gerbera/template
+++ b/srcpkgs/gerbera/template
@@ -1,7 +1,7 @@
 # Template file for 'gerbera'
 pkgname=gerbera
 version=1.12.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_SYSTEMD=0 -DWITH_AVCODEC=1"
 hostmakedepends="pkg-config"

From 51bd24011abf437622d0e1acb9cfa66aac1a4a36 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 032/110] goldendict: revbump for ffmpeg6

---
 srcpkgs/goldendict/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/goldendict/template b/srcpkgs/goldendict/template
index f4a05759f693d3..97f44347b03a6a 100644
--- a/srcpkgs/goldendict/template
+++ b/srcpkgs/goldendict/template
@@ -1,7 +1,7 @@
 # Template file for 'goldendict'
 pkgname=goldendict
 version=1.5.0
-revision=1
+revision=2
 build_style=qmake
 configure_args="CONFIG+=zim_support goldendict.pro"
 hostmakedepends="qt5-qmake pkg-config qt5-host-tools"
@@ -10,7 +10,7 @@ makedepends="tiff-devel qt5-devel libvorbis-devel zlib-devel
  qt5-webkit-devel lzo-devel bzip2-devel libao-devel qt5-svg-devel
  libeb-devel qt5-x11extras-devel ffmpeg-devel liblzma-devel
  qt5-multimedia-devel"
-short_desc="A feature-rich dictionary lookup program"
+short_desc="Feature-rich dictionary lookup program"
 maintainer="John <me@johnnynator.dev>"
 license="GPL-3.0-or-later"
 homepage="http://goldendict.org/"

From 8d8ef80e182b04bccc07840164241649569b2339 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 033/110] gst-libav: revbump for ffmpeg6

---
 srcpkgs/gst-libav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index b24be23fc1a6d2..0f9350a251bf67 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.22.9
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"

From efaaebf52ea662f8db0062a760f26c508ca9d8f2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Feb 2024 01:52:46 -0500
Subject: [PATCH 034/110] gst-plugins-bad1: revbump for ffmpeg6

---
 srcpkgs/gst-plugins-bad1/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index 10dc49f4c151bc..b4a7f7367e7dff 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-plugins-bad1'
 pkgname=gst-plugins-bad1
 version=1.22.9
-revision=1
+revision=2
 build_helper="gir"
 build_style=meson
 configure_args="-Dpackage-origin=https://voidlinux.org -Ddoc=disabled
@@ -27,7 +27,7 @@ makedepends="alsa-lib-devel celt-devel openssl-devel exempi-devel
  fdk-aac-devel flite-devel fluidsynth-devel liblrdf-devel ladspa-sdk
  lilv-devel lv2 libopenjpeg2-devel sbc-devel spandsp-devel vulkan-loader
  Vulkan-Headers webrtc-audio-processing-devel libzbar-devel ffmpeg-devel
- srt-devel libva-devel
+ srt-devel libva-devel oneVPL-devel
  $(vopt_if gme libgme-devel)"
 depends="gst-plugins-base1>=${version}"
 short_desc="GStreamer plugins from the bad set (v1.x)"

From 7d076fd46be816fe21095dd4b4cd49813b1332d6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 035/110] gst-rtsp-server: revbump for ffmpeg6

---
 srcpkgs/gst-rtsp-server/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index bc2a0dea6ac152..f77026c618eb69 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
 version=1.22.9
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="glib-devel gst-plugins-bad1-devel gobject-introspection

From 935bf7c77aa7c4b0fd33d9cba8b2937b5d46e36b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 036/110] guvcview: update to 2.0.8.

---
 srcpkgs/guvcview/patches/fix-include.patch | 10 ++++++++++
 srcpkgs/guvcview/template                  |  7 +++----
 2 files changed, 13 insertions(+), 4 deletions(-)
 create mode 100644 srcpkgs/guvcview/patches/fix-include.patch

diff --git a/srcpkgs/guvcview/patches/fix-include.patch b/srcpkgs/guvcview/patches/fix-include.patch
new file mode 100644
index 00000000000000..503c2af3b78c1a
--- /dev/null
+++ b/srcpkgs/guvcview/patches/fix-include.patch
@@ -0,0 +1,10 @@
+--- a/guvcview/guvcview.c
++++ b/guvcview/guvcview.c
+@@ -28,6 +28,7 @@
+ #include <sys/stat.h>
+ #include <sys/resource.h>
+ #include <errno.h>
++#include <locale.h>
+ 
+ #include "gview.h"
+ #include "gviewv4l2core.h"
diff --git a/srcpkgs/guvcview/template b/srcpkgs/guvcview/template
index d42fd38fa4ad12..86a7fd619612c8 100644
--- a/srcpkgs/guvcview/template
+++ b/srcpkgs/guvcview/template
@@ -1,8 +1,7 @@
 # Template file for 'guvcview'
 pkgname=guvcview
-version=2.0.7
-revision=2
-create_wrksrc=yes
+version=2.0.8
+revision=1
 build_style=gnu-configure
 configure_args="--disable-static --disable-debian-menu"
 hostmakedepends="pkg-config intltool autoconf automake libtool glib-devel"
@@ -14,7 +13,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="http://guvcview.sourceforge.net/"
 distfiles="${SOURCEFORGE_SITE}/${pkgname}/${pkgname}-src-${version}.tar.bz2"
-checksum=f47d51fbd06e44eeaa1a82f4a153c927527c90d94514197a70b2956028cc8ad4
+checksum=a21f4e448286666cf27bafef5290cc953a0a1796b752e5bbe521266dc1230c81
 
 post_patch() {
 	sed '31a#include <locale.h>' -i  guvcview/guvcview.c

From ccbb9214e1540eac4e46d8382e85d3376dcb5c10 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 037/110] handbrake: update to 1.6.1

---
 .../patches/fix-missing-x265-link-flag.patch    | 11 ++++++-----
 .../handbrake/patches/libhb-vpl-include.patch   | 15 +++++++++++++++
 srcpkgs/handbrake/template                      | 17 ++++++++++-------
 3 files changed, 31 insertions(+), 12 deletions(-)
 create mode 100644 srcpkgs/handbrake/patches/libhb-vpl-include.patch

diff --git a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
index 26db03867a0c83..d6bb2eda627a36 100644
--- a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
+++ b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
@@ -1,14 +1,15 @@
 --- a/gtk/configure.ac
 +++ b/gtk/configure.ac
 @@ -203,7 +203,7 @@
- 
+
  AM_CONDITIONAL([MINGW], [test "x$mingw_flag" = "xyes"])
- 
--HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg"
-+HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -ldl"
+
+-HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc"
++HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc -ldl"
  HB_CPPFLAGS="$HB_CPPFLAGS $HBINC"
- 
+
  PKG_CHECK_MODULES([x264], [x264], sys_x264=yes, sys_x264=no)
+
 --- a/test/module.defs
 +++ b/test/module.defs
 @@ -69,6 +69,9 @@
diff --git a/srcpkgs/handbrake/patches/libhb-vpl-include.patch b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
new file mode 100644
index 00000000000000..298f9f4ab28f2a
--- /dev/null
+++ b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
@@ -0,0 +1,15 @@
+--- a/libhb/module.defs	2023-01-22 11:36:49.000000000 -0500
++++ b/libhb/module.defs	2023-04-03 22:37:52.395467010 -0400
+@@ -46,11 +46,7 @@
+ LIBHB.GCC.I += $(LIBHB.build/) $(CONTRIB.build/)include
+ 
+ ifeq (1,$(FEATURE.qsv))
+-    ifeq ($(HOST.system),freebsd))
+-        LIBHB.GCC.I += $(LOCALBASE)/include/vpl
+-    else
+-        LIBHB.GCC.I += $(CONTRIB.build/)include/vpl
+-    endif
++    LIBHB.GCC.I += /usr/include/vpl
+ endif
+ 
+ ifneq (,$(filter $(HOST.system),freebsd netbsd openbsd))
diff --git a/srcpkgs/handbrake/template b/srcpkgs/handbrake/template
index ca5e4571e49c37..c32cb1bfa31f4b 100644
--- a/srcpkgs/handbrake/template
+++ b/srcpkgs/handbrake/template
@@ -1,10 +1,10 @@
 # Template file for 'handbrake'
 pkgname=handbrake
-version=1.5.1
+version=1.6.1
 revision=1
 build_style=gnu-configure
 configure_args="--force --disable-gtk-update-checks --disable-df-fetch --harden
- $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc)"
+ $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc) $(vopt_enable qsv)"
 make_build_args="-C ${XBPS_TRIPLET}"
 make_install_args="-C ${XBPS_TRIPLET}"
 hostmakedepends="automake cmake gettext-devel glib-devel intltool libtool m4 meson nasm pkg-config python3"
@@ -12,8 +12,11 @@ makedepends="bzip2-devel ffmpeg-devel gst-plugins-base1-devel gtk+3-devel
  jansson-devel lame-devel libass-devel libbluray-devel libdav1d-devel
  libdvdnav-devel libdvdread-devel libgudev-devel libnuma-devel
  libsamplerate-devel libtheora-devel libvorbis-devel libvpx-devel libxml2-devel
- opus-devel speex-devel x264-devel x265-devel zimg-devel
+ opus-devel speex-devel x264-devel x265-devel zimg-devel libsvt-av1-devel
  $(vopt_if fdk_aac fdk-aac-devel)
+ $(vopt_if qsv libva-devel)
+ $(vopt_if qsv libdrm-devel)
+ $(vopt_if qsv onevpl-devel)
  $(vopt_if nvenc nv-codec-headers)"
 depends="desktop-file-utils gst-plugins-good1 hicolor-icon-theme"
 short_desc="Multithreaded video transcoder"
@@ -21,15 +24,15 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-2.0-only"
 homepage="https://handbrake.fr/"
 distfiles="https://github.com/HandBrake/HandBrake/releases/download/${version}/HandBrake-${version}-source.tar.bz2"
-checksum=3999fe06d5309c819799a73a968a8ec3840e7840c2b64af8f5cdb7fd8c9430f0
+checksum=94ccfe03db917a91650000c510f7fd53f844da19f19ad4b4be1b8f6bc31a8d4c
 nocross=yes
 
-build_options="fdk_aac nvenc"
+build_options="fdk_aac nvenc qsv"
 
 case "$XBPS_TARGET_MACHINE" in
 	x86_64*|i686*)
 		CFLAGS="-msse"
-		build_options_default="nvenc"
+		build_options_default="nvenc qsv"
 		;;
 esac
 
@@ -37,7 +40,7 @@ pre_configure() {
 	# use system libraries, don't download them
 	rm -rf contrib/
 	for module in fdk-aac ffmpeg libbluray libdav1d libdvdnav libdvdread nvenc \
-		x265 zimg; do
+		x265 zimg svt-av1 libvpl; do
 	    vsed -i "/MODULES += contrib\/${module}/d" make/include/main.defs
 	done
 }

From 3fc1e06da2f2a5233e5ed1e6c96a5523395fada4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 038/110] hedgewars: revbump for ffmpeg4

---
 srcpkgs/hedgewars/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/hedgewars/template b/srcpkgs/hedgewars/template
index 94b6db673b0c3a..402ccfaaecbc2d 100644
--- a/srcpkgs/hedgewars/template
+++ b/srcpkgs/hedgewars/template
@@ -1,13 +1,13 @@
 # Template file for 'hedgewars'
 pkgname=hedgewars
 version=1.0.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DNOSERVER=1 -DDATA_INSTALL_DIR=/usr/share/${pkgname}
  -DPHYSFS_SYSTEM=1 -DMINIMAL_FLAGS=1"
 make_cmd=make
 hostmakedepends="lua51 pkg-config qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
+makedepends="ffmpeg4-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
  SDL2_mixer-devel SDL2_net-devel SDL2_ttf-devel"
 depends="libfreeglut"
 short_desc="Funny turn-based artillery game, featuring fighting Hedgehogs!"

From 8d121b4b3acc3f27bb0f8b5d043570fa8818afcb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 039/110] idjc: revbump for ffmpeg4

---
 srcpkgs/idjc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/idjc/template b/srcpkgs/idjc/template
index a9cde0665d55b1..f41e1e4fabbae7 100644
--- a/srcpkgs/idjc/template
+++ b/srcpkgs/idjc/template
@@ -1,11 +1,11 @@
 # Template file for 'idjc'
 pkgname=idjc
 version=0.9.1
-revision=5
+revision=6
 build_style=gnu-configure
 hostmakedepends="pkg-config git python3 automake gettext-devel libtool"
 makedepends="libvorbis-devel libogg-devel jack-devel libsamplerate-devel
- libflac-devel libsndfile-devel mpg123-devel ffmpeg-devel speex-devel
+ libflac-devel libsndfile-devel mpg123-devel ffmpeg4-devel speex-devel
  glib-devel pixman-devel lame-devel python3-gobject-devel libshout-idjc-devel
  opus-devel twolame-devel python3-mutagen python3-devel"
 depends="python3-gobject python3-mutagen desktop-file-utils shared-mime-info python3-dbus jack"

From 530ca9077b50a7ba2bf1804781f42943fe3ab04b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 040/110] kid3: revbump for ffmpeg6

---
 srcpkgs/kid3/patches/ffmpeg5.patch | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 srcpkgs/kid3/patches/ffmpeg5.patch

diff --git a/srcpkgs/kid3/patches/ffmpeg5.patch b/srcpkgs/kid3/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..135fc50e07c9ba
--- /dev/null
+++ b/srcpkgs/kid3/patches/ffmpeg5.patch
@@ -0,0 +1,17 @@
+# https://aur.archlinux.org/cgit/aur.git/diff/ffmpeg5.patch?h=kid3-cli&id=12410a74906612e7efc0ec8fbce739b4a0fef7e7
+diff --git a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+index e156d424..e12b9abd 100644
+--- a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
++++ b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+@@ -232,7 +232,11 @@ private:
+   friend class Format;
+   friend class Converter;
+   AVCodecContext* m_ptr;
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 0, 0)
+   AVCodec* m_impl;
++#else
++  const AVCodec* m_impl;
++#endif
+   AVFrame* m_frame;
+   bool m_opened;
+ };

From 9cc4b5ba917dfc319d867115521a739011c36583 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 041/110] kodi: revbump for ffmpeg4

---
 srcpkgs/kodi/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/kodi/template b/srcpkgs/kodi/template
index d37a5918cd6758..ea78e0aca0fe3e 100644
--- a/srcpkgs/kodi/template
+++ b/srcpkgs/kodi/template
@@ -1,7 +1,7 @@
 # Template file for 'kodi'
 pkgname=kodi
 version=19.4
-revision=9
+revision=10
 _codename="Matrix"
 build_style=cmake
 configure_args="-DWITH_FFMPEG=/usr -DENABLE_LDGOLD=OFF
@@ -54,7 +54,7 @@ makedepends="
  libmad-devel fontconfig-devel libXinerama-devel libsamplerate-devel libmms-devel
  enca-devel boost-devel libcurl-devel libva-devel libvdpau-devel libass-devel
  libbluetooth-devel yajl-devel libplist-devel librtmp-devel tinyxml-devel
- taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg-devel
+ taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg4-devel
  giflib-devel libxslt-devel gnutls-devel libssh-devel libmicrohttpd-devel
  libcec-devel dcadec-devel flatbuffers-devel fmt-devel lcms2-devel
  libfstrcmp-devel rapidjson libcdio-paranoia spdlog libwaylandpp-devel

From be4baf84f7b44fb1fbc6b13ebeee9664d57cb9e8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 042/110] kpipewire: revbump for ffmpeg6

---
 srcpkgs/kpipewire/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kpipewire/template b/srcpkgs/kpipewire/template
index 6214a4451336e7..3555348659dded 100644
--- a/srcpkgs/kpipewire/template
+++ b/srcpkgs/kpipewire/template
@@ -1,7 +1,7 @@
 # Template file for 'kpipewire'
 pkgname=kpipewire
 version=5.27.10
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules plasma-wayland-protocols gettext
  qt5-qmake qt5-host-tools pkg-config wayland-devel kcoreaddons

From b25dd337d2a224bb09ae6ba677921fcd2b04e3bf Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 043/110] libopenal: revbump for ffmpeg6

---
 srcpkgs/libopenal/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenal/template b/srcpkgs/libopenal/template
index 88d0f11307d81a..8308fca0393e33 100644
--- a/srcpkgs/libopenal/template
+++ b/srcpkgs/libopenal/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenal'
 pkgname=libopenal
 version=1.23.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DALSOFT_EXAMPLES=OFF"
 hostmakedepends="pkg-config"

From 69706557a00f479787481635ea0895436c1a287d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 044/110] loudgain: revbump for ffmpeg6

---
 srcpkgs/loudgain/patches/ffmpeg5.patch | 11 +++++++++++
 srcpkgs/loudgain/template              |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/loudgain/patches/ffmpeg5.patch

diff --git a/srcpkgs/loudgain/patches/ffmpeg5.patch b/srcpkgs/loudgain/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..16d4510ee98faa
--- /dev/null
+++ b/srcpkgs/loudgain/patches/ffmpeg5.patch
@@ -0,0 +1,11 @@
+--- a/src/scan.c	2019-09-06 11:31:19.000000000 -0400
++++ b/src/scan.c	2023-03-23 11:15:40.867968521 -0400
+@@ -69,8 +69,6 @@
+ 	 * It is now useless
+ 	 * https://github.com/FFmpeg/FFmpeg/blob/70d25268c21cbee5f08304da95be1f647c630c15/doc/APIchanges#L86
+ 	 */
+-  if (avformat_version() < AV_VERSION_INT(58,9,100))
+-    av_register_all();
+ 
+ 	av_log_set_callback(scan_av_log);
+ 
diff --git a/srcpkgs/loudgain/template b/srcpkgs/loudgain/template
index da4f2d56e94c3d..4d6bf29efb4fdd 100644
--- a/srcpkgs/loudgain/template
+++ b/srcpkgs/loudgain/template
@@ -1,7 +1,7 @@
 # Template file for 'loudgain'
 pkgname=loudgain
 version=0.6.8
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libebur128-devel taglib-devel ffmpeg-devel"

From 19071a0527780e891703bca1094421168f8ebbcd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 045/110] mediastreamer: revbump for ffmpeg4

---
 srcpkgs/mediastreamer/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mediastreamer/template b/srcpkgs/mediastreamer/template
index 0fcffa7653d18e..e888626b945e55 100644
--- a/srcpkgs/mediastreamer/template
+++ b/srcpkgs/mediastreamer/template
@@ -1,11 +1,11 @@
 # Template file for 'mediastreamer'
 pkgname=mediastreamer
 version=5.2.111
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DENABLE_STRICT=0 -DENABLE_UNIT_TESTS=0"
 hostmakedepends="python3"
-makedepends="bzrtp-devel ffmpeg-devel glew-devel libXv-devel libsrtp-devel
+makedepends="bzrtp-devel ffmpeg4-devel glew-devel libXv-devel libsrtp-devel
  libupnp-devel libvpx-devel mbedtls-devel opus-devel ortp-devel pulseaudio-devel
  libtheora-devel speex-devel v4l-utils-devel bcg729-devel bcmatroska2-devel libgsm-devel
  zxing-cpp-devel"

From e1e4d1a8a0f6f4567a2b89de2d3f3b2edaefac0e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 046/110] mgba: revbump for ffmpeg6

---
 srcpkgs/mgba/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mgba/template b/srcpkgs/mgba/template
index 6cd65650312543..93401adb618bd8 100644
--- a/srcpkgs/mgba/template
+++ b/srcpkgs/mgba/template
@@ -1,7 +1,7 @@
 # Template file for 'mgba'
 pkgname=mgba
 version=0.10.3
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake desktop-file-utils"
 makedepends="SDL2-devel ffmpeg-devel libedit-devel libepoxy-devel libmagick-devel

From 477fc79ccaab15be99146321d44987dbf04818ac Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 047/110] mlt: revbump for ffmpeg4

---
 srcpkgs/mlt/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mlt/template b/srcpkgs/mlt/template
index 73e3915aaab9ac..d7ed4c4b30a868 100644
--- a/srcpkgs/mlt/template
+++ b/srcpkgs/mlt/template
@@ -1,14 +1,14 @@
 # Template file for 'mlt'
 pkgname=mlt
 version=6.26.1
-revision=3
+revision=4
 build_style=configure
 configure_args="--prefix=/usr --libdir=/usr/lib$XBPS_TARGET_WORDSIZE
  --enable-gpl --enable-gpl3 --disable-swfdec --without-kde
  --swig-languages=python"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which"
 # XXX: movit vid.stab
-makedepends="alsa-lib-devel ffmpeg-devel gtk+-devel jack-devel ladspa-sdk
+makedepends="alsa-lib-devel ffmpeg4-devel gtk+-devel jack-devel ladspa-sdk
  libexif-devel libsamplerate-devel libxml2-devel sox-devel SDL_image-devel
  fftw-devel frei0r-plugins python3-devel pulseaudio-devel movit-devel
  libvidstab-devel"

From 2e96200c93642d8685a0f40ef7bf95fdfba79032 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 048/110] moc: revbump for ffmpeg4

---
 srcpkgs/moc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/moc/template b/srcpkgs/moc/template
index 3a04932c8f1e61..838755f88db09e 100644
--- a/srcpkgs/moc/template
+++ b/srcpkgs/moc/template
@@ -1,10 +1,10 @@
 # Template file for 'moc'
 pkgname=moc
 version=2.5.2
-revision=7
+revision=8
 build_style=gnu-configure
 hostmakedepends="pkg-config"
-makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg-devel
+makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg4-devel
  jack-devel alsa-lib-devel libltdl-devel libflac-devel libvorbis-devel
  libmad-devel libmpcdec-devel libmodplug-devel libid3tag-devel faad2-devel
  taglib-devel libsndfile-devel wavpack-devel speex-devel libsamplerate-devel

From 343f0d9f384aa97d9d97ed975bafbd950bf37d43 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 049/110] motion: revbump for ffmpeg6

---
 srcpkgs/motion/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/motion/template b/srcpkgs/motion/template
index 607ebeb3c7b242..bf63a91d9764f6 100644
--- a/srcpkgs/motion/template
+++ b/srcpkgs/motion/template
@@ -1,7 +1,7 @@
 # Template file for 'motion'
 pkgname=motion
 version=4.6.0
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake pkg-config gettext-devel tar"
 makedepends="ffmpeg-devel libmicrohttpd-devel v4l-utils-devel gettext-devel"

From e6c14ece739daf7951eb496f3fe07ac1d077dfe9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 050/110] olive: revbump for ffmpeg4

---
 srcpkgs/olive/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/olive/template b/srcpkgs/olive/template
index 12a46936c99003..5c2917b9c51245 100644
--- a/srcpkgs/olive/template
+++ b/srcpkgs/olive/template
@@ -1,10 +1,10 @@
 # Template file for 'olive'
 pkgname=olive
 version=0.1.2
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools pkg-config"
-makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg-devel frei0r-plugins"
+makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg4-devel frei0r-plugins"
 short_desc="Non-linear video editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"

From 8460b261096422eff7bad9c57df5562b3e386d0b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 051/110] opentoonz: revbump for ffmpeg6

---
 srcpkgs/opentoonz/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/opentoonz/template b/srcpkgs/opentoonz/template
index ee9f7603f55fd8..3e81834ca0eddf 100644
--- a/srcpkgs/opentoonz/template
+++ b/srcpkgs/opentoonz/template
@@ -1,7 +1,7 @@
 # Template file for 'opentoonz'
 pkgname=opentoonz
 version=1.6.0
-revision=2
+revision=3
 build_wrksrc="toonz/sources"
 build_style=cmake
 make_cmd=make

From 54b8925036054870ee0aa0c0aaf6ec8fa6f670af Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 052/110] pianobar: revbump for ffmpeg6

---
 srcpkgs/pianobar/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pianobar/template b/srcpkgs/pianobar/template
index e3febb821a4510..1e3dc1bf9308ee 100644
--- a/srcpkgs/pianobar/template
+++ b/srcpkgs/pianobar/template
@@ -1,7 +1,7 @@
 # Template file for 'pianobar'
 pkgname=pianobar
 version=2022.04.01
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="V=1"
 hostmakedepends="pkg-config"

From 6590c16beda6cd3b8ec9ac2aa574383167cc6f7c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 053/110] ppsspp: revbump for ffmpeg6

---
 srcpkgs/ppsspp/patches/ffmpeg6.patch | 15 +++++++++++++++
 srcpkgs/ppsspp/template              |  3 +--
 2 files changed, 16 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/ppsspp/patches/ffmpeg6.patch

diff --git a/srcpkgs/ppsspp/patches/ffmpeg6.patch b/srcpkgs/ppsspp/patches/ffmpeg6.patch
new file mode 100644
index 00000000000000..5803c7bf227309
--- /dev/null
+++ b/srcpkgs/ppsspp/patches/ffmpeg6.patch
@@ -0,0 +1,15 @@
+--- a/Core/HW/SimpleAudioDec.cpp	2024-02-04 08:08:02.000000000 -0500
++++ b/Core/HW/SimpleAudioDec.cpp	2024-02-15 14:48:27.114362051 -0500
+@@ -81,7 +81,11 @@
+ 		return;
+ 	}
+ 	// Find decoder
++#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(58, 18, 100)
+ 	codec_ = avcodec_find_decoder((AVCodecID)audioCodecId);
++#else // this is a macro to const in the header
++	codec_ = (AVCodec*)avcodec_find_decoder((AVCodecID)audioCodecId);
++#endif
+ 	if (!codec_) {
+ 		// Eh, we shouldn't even have managed to compile. But meh.
+ 		ERROR_LOG(ME, "This version of FFMPEG does not support AV_CODEC_ctx for audio (%s). Update your submodule.", GetCodecName(audioType));
+
diff --git a/srcpkgs/ppsspp/template b/srcpkgs/ppsspp/template
index 2238a7601c0af8..1fda55268a2d39 100644
--- a/srcpkgs/ppsspp/template
+++ b/srcpkgs/ppsspp/template
@@ -1,7 +1,7 @@
 # Template file for 'ppsspp'
 pkgname=ppsspp
 version=1.17.1
-revision=1
+revision=2
 _glslang_commit=b34f619e1c85810dcb3c578107d2e48ba4ee2b37
 _SPIRV_Cross_commit=4212eef67ed0ca048cb726a6767185504e7695e5
 _armips_commit=a8d71f0f279eb0d30ecf6af51473b66ae0cf8e8d
@@ -91,7 +91,6 @@ post_configure() {
 }
 
 do_install() {
-	vlicense LICENSE.TXT
 	vinstall icons/icon.svg 644 usr/share/pixmaps ppsspp.svg
 	vinstall Qt/PPSSPP.desktop 644 usr/share/applications
 	vbin build/PPSSPPHeadless ppsspp-headless

From 3b1ee46c4bc429c5f91fb2b9b8e9465aa16fa216 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 054/110] pqiv: revbump for ffmpeg6

---
 srcpkgs/pqiv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pqiv/template b/srcpkgs/pqiv/template
index 542fc27a2d32a4..9308d949b6a1c7 100644
--- a/srcpkgs/pqiv/template
+++ b/srcpkgs/pqiv/template
@@ -1,7 +1,7 @@
 # Template file for 'pqiv'
 pkgname=pqiv
 version=2.12
-revision=1
+revision=2
 build_style=gnu-makefile
 hostmakedepends="pkg-config"
 makedepends="glib-devel gtk+3-devel $(vopt_if ffmpeg ffmpeg-devel)

From e75775d4166b837372531576aeb66bbec295ad63 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 055/110] qmmp: revbump for ffmpeg6

---
 srcpkgs/qmmp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qmmp/template b/srcpkgs/qmmp/template
index 53781ea3bc28ad..2da07f1e87eac0 100644
--- a/srcpkgs/qmmp/template
+++ b/srcpkgs/qmmp/template
@@ -1,7 +1,7 @@
 # Template file for 'qmmp'
 pkgname=qmmp
 version=1.6.1
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DUSE_HAL:BOOL=FALSE -DQMMP_DEFAULT_UI:STRING=simple"
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From d0e75202eb8405600ef5ad77edffd8a2910c9182 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 14 Dec 2023 13:28:10 -0500
Subject: [PATCH 056/110] qt6-pdf: revbump for ffmpeg6

---
 srcpkgs/qt6-pdf/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-pdf/template b/srcpkgs/qt6-pdf/template
index ecda84afac1310..531b4e1d4fe84d 100644
--- a/srcpkgs/qt6-pdf/template
+++ b/srcpkgs/qt6-pdf/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-pdf'
 pkgname=qt6-pdf
 version=6.6.0
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DQT_FEATURE_qtpdf_build=ON
  -DQT_FEATURE_qtpdf_widgets_build=ON

From 010786798205d2bd3d994cf2792ceeb4822c824d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 057/110] qt5-webengine: revbump for ffmpeg6

---
 .../chromium-media-filters-cpp14.patch        |  11 ++
 srcpkgs/qt5-webengine/patches/ffmpeg5.patch   | 179 ++++++++++++++++++
 .../qtwebengine-fix-ffmpeg5-build.patch       |  14 ++
 srcpkgs/qt5-webengine/template                |   4 +-
 4 files changed, 206 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/ffmpeg5.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch

diff --git a/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
new file mode 100644
index 00000000000000..04adc540f2cbc0
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
@@ -0,0 +1,11 @@
+--- a/src/3rdparty/chromium/media/filters/BUILD.gn	2023-02-27 13:32:59.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/BUILD.gn	2023-04-02 17:21:39.204066384 -0400
+@@ -96,6 +96,8 @@
+     "//ui/gfx/geometry:geometry",
+   ]
+ 
++  cflags_cc = [ "-std=c++14" ]
++
+   libs = []
+ 
+   if (proprietary_codecs) {
diff --git a/srcpkgs/qt5-webengine/patches/ffmpeg5.patch b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..ac55e1634423a9
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
@@ -0,0 +1,179 @@
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:57.732547446 -0400
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:09.486478995 -0400
+@@ -57,6 +57,8 @@
+ 
+ namespace {
+ 
++constexpr int64_t kRelativeTsBase = static_cast<int64_t>(0x7ffeffffffffffff);
++
+ void SetAVStreamDiscard(AVStream* stream, AVDiscard discard) {
+   DCHECK(stream);
+   stream->discard = discard;
+@@ -90,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+   if (stream->start_time != kNoFFmpegTimestamp)
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (stream->first_dts != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, stream->first_dts);
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -408,11 +398,11 @@
+   scoped_refptr<DecoderBuffer> buffer;
+ 
+   if (type() == DemuxerStream::TEXT) {
+-    int id_size = 0;
++    size_t id_size = 0;
+     uint8_t* id_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
+ 
+-    int settings_size = 0;
++    size_t settings_size = 0;
+     uint8_t* settings_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
+ 
+@@ -424,7 +414,7 @@
+     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
+                                      side_data.data(), side_data.size());
+   } else {
+-    int side_data_size = 0;
++    size_t side_data_size = 0;
+     uint8_t* side_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
+ 
+@@ -485,7 +475,7 @@
+                                        packet->size - data_offset);
+     }
+ 
+-    int skip_samples_size = 0;
++    size_t skip_samples_size = 0;
+     const uint32_t* skip_samples_ptr =
+         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
+             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
+@@ -1587,6 +1577,8 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++      continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+       lowest_start_time_stream = stream.get();
+@@ -1604,6 +1596,8 @@
+     if (stream && stream->type() == DemuxerStream::VIDEO &&
+         stream->IsEnabled()) {
+       video_stream = stream.get();
++      if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++        continue;
+       if (video_stream->start_time() <= seek_time) {
+         return video_stream;
+       }
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h qtwebengine-5.15.10/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h
+--- a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-07-11 22:12:47.917192788 -0500
+@@ -29,6 +29,7 @@ extern "C" {
+ #include <libavformat/avformat.h>
+ #include <libavformat/avio.h>
+ #include <libavutil/avutil.h>
++#include <libavutil/channel_layout.h>
+ #include <libavutil/imgutils.h>
+ #include <libavutil/log.h>
+ #include <libavutil/mastering_display_metadata.h>
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/audio_file_reader.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/audio_file_reader.cc
+--- a/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -85,7 +85,7 @@ bool AudioFileReader::OpenDemuxer() {
+ }
+ 
+ bool AudioFileReader::OpenDecoder() {
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (codec) {
+     // MP3 decodes to S16P which we don't support, tell it to use S16 instead.
+     if (codec_context_->sample_fmt == AV_SAMPLE_FMT_S16P)
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -329,7 +329,7 @@ bool FFmpegAudioDecoder::ConfigureDecode
+     }
+   }
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec ||
+       avcodec_open2(codec_context_.get(), codec, &codec_options) < 0) {
+     DLOG(ERROR) << "Could not initialize audio decoder: "
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -59,7 +59,6 @@ static int64_t AVIOSeekOperation(void* o
+ }
+ 
+ void FFmpegGlue::InitializeFFmpeg() {
+-  av_register_all();
+ }
+ 
+ static void LogContainer(bool is_local_file,
+@@ -95,9 +94,6 @@ FFmpegGlue::FFmpegGlue(FFmpegURLProtocol
+   // Enable fast, but inaccurate seeks for MP3.
+   format_context_->flags |= AVFMT_FLAG_FAST_SEEK;
+ 
+-  // Ensures we can read out various metadata bits like vp8 alpha.
+-  format_context_->flags |= AVFMT_FLAG_KEEP_SIDE_DATA;
+-
+   // Ensures format parsing errors will bail out. From an audit on 11/2017, all
+   // instances were real failures. Solves bugs like http://crbug.com/710791.
+   format_context_->error_recognition |= AV_EF_EXPLODE;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -391,7 +391,7 @@ bool FFmpegVideoDecoder::ConfigureDecode
+   if (decode_nalus_)
+     codec_context_->flags2 |= AV_CODEC_FLAG2_CHUNKS;
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
+     ReleaseFFmpegResources();
+     return false;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/media_file_checker.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/media_file_checker.cc
+--- a/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -68,7 +68,7 @@ bool MediaFileChecker::Start(base::TimeD
+       auto context = AVStreamToAVCodecContext(format_context->streams[i]);
+       if (!context)
+         continue;
+-      AVCodec* codec = avcodec_find_decoder(cp->codec_id);
++      const AVCodec* codec = avcodec_find_decoder(cp->codec_id);
+       if (codec && avcodec_open2(context.get(), codec, nullptr) >= 0) {
+         auto loop = std::make_unique<FFmpegDecodingLoop>(context.get());
+         stream_contexts[i] = {std::move(context), std::move(loop)};
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc qtwebengine-5.15.10/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc
+--- a/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -203,7 +203,7 @@ int32_t H264DecoderImpl::InitDecode(cons
+   // a pointer |this|.
+   av_context_->opaque = this;
+ 
+-  AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
+   if (!codec) {
+     // This is an indication that FFmpeg has not been initialized or it has not
+     // been compiled/initialized with the correct set of codecs.
diff --git a/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch b/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch
new file mode 100644
index 00000000000000..bc24d5b9a29cb5
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch
@@ -0,0 +1,14 @@
+--- a/src/buildtools/configure.json	2023-12-09 11:06:01.503058569 -0500
++++ b/src/buildtools/configure.json	2023-12-09 11:06:14.982361345 -0500
+@@ -779,11 +779,6 @@
+             "type": "warning",
+             "condition": "config.ios && config.simulator && config.device && features.build-qtpdf",
+             "message": "Building fat libray with device and simulator architectures will disable NEON."
+-        },
+-        {
+-            "type": "fatal",
+-            "condition": "features.webengine-system-ffmpeg && !libs.webengine-ffmpeg-support",
+-            "message": "Unmodified ffmpeg >= 5.0 is not supported. Please configure with -qt-webengine-ffmpeg."
+         }
+     ],
+     "summary": [
diff --git a/srcpkgs/qt5-webengine/template b/srcpkgs/qt5-webengine/template
index 8d2df1b5175bad..1687a77eb8a2f5 100644
--- a/srcpkgs/qt5-webengine/template
+++ b/srcpkgs/qt5-webengine/template
@@ -1,14 +1,14 @@
 # Template file for 'qt5-webengine'
 pkgname=qt5-webengine
 version=5.15.16
-revision=1
+revision=2
 _version="${version}-lts"
 _chromium_commit=207c2ac45ca3386d153770c6b0d2ea2ec21ca880
 archs="x86_64* i686* armv[67]* ppc64* aarch64*"
 create_wrksrc=yes
 build_style=qmake
 configure_args="--
- -webengine-icu -webengine-ffmpeg -webengine-opus -webengine-webp
+ -webengine-icu -system-ffmpeg -webengine-opus -webengine-webp
  -webengine-pepper-plugins -webengine-printing-and-pdf -webengine-proprietary-codecs
  -webengine-pulseaudio -webengine-spellchecker -webengine-webrtc -webengine-geolocation
  -webengine-kerberos -no-webengine-embedded-build $(vopt_if sndio '' '-no')-webengine-sndio

From dedeeec69849aa8d2dc7a329430d4e130b8f9840 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 058/110] qt5: revbump for ffmpeg6

---
 srcpkgs/qt5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5/template b/srcpkgs/qt5/template
index 3efb7e42d5fd3f..27f6d5388cd15c 100644
--- a/srcpkgs/qt5/template
+++ b/srcpkgs/qt5/template
@@ -3,9 +3,9 @@
 # revbump libqtxdg after bumping patch version
 pkgname=qt5
 version=5.15.11+20231124
+revision=3
 # commit 4765fa1df7a837db9c1f89c4da0dd76b74bb5fab
 # base repo: https://invent.kde.org/qt/qt/qt5
-revision=2
 build_style=meta
 hostmakedepends="cmake clang17 flex perl glib-devel pkg-config
  python3 re2c ruby which"

From a0ffbccf15923838a726abcc5aec92b8f2b4e7fb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 059/110] qtav: revbump for ffmpeg4

---
 srcpkgs/qtav/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtav/template b/srcpkgs/qtav/template
index 775d5a139a9efa..aa69e213c984b0 100644
--- a/srcpkgs/qtav/template
+++ b/srcpkgs/qtav/template
@@ -1,10 +1,10 @@
 # Template file for 'qtav'
 pkgname=qtav
 version=1.13.0
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel libass-devel libopenal-devel
+makedepends="ffmpeg4-devel libass-devel libopenal-devel
  libva-glx-devel libXv-devel pulseaudio-devel
  qt5-declarative-devel qt5-svg-devel
  qt5-quickcontrols"

From df1b963cb767a337a9448f92114a3b3c03926b14 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 060/110] retroarch: revbump for ffmpeg6

---
 srcpkgs/retroarch/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroarch/template b/srcpkgs/retroarch/template
index cb3125c5dbf1ae..c65c26f7bf0332 100644
--- a/srcpkgs/retroarch/template
+++ b/srcpkgs/retroarch/template
@@ -1,7 +1,7 @@
 # Template file for 'retroarch'
 pkgname=retroarch
 version=1.16.0.3
-revision=3
+revision=4
 build_style=configure
 configure_args="--prefix=/usr --sysconfdir=/etc --enable-networking
  --enable-udev --disable-builtinflac --disable-builtinglslang

From 23c8fe29ae3ce249214002ae266ed6c607e39c54 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 061/110] scrcpy: revbump for ffmpeg6

---
 srcpkgs/scrcpy/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/scrcpy/template b/srcpkgs/scrcpy/template
index d04de770dc1913..5218fa01f8ce1f 100644
--- a/srcpkgs/scrcpy/template
+++ b/srcpkgs/scrcpy/template
@@ -1,7 +1,7 @@
 # Template file for 'scrcpy'
 pkgname=scrcpy
 version=2.3.1
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcompile_server=false
  -Dprebuilt_server=/usr/share/scrcpy/scrcpy-server-v${version}"

From 9d37e8abc52e0476cd8f433c40eb3aca60cbadf8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 17 Oct 2023 08:54:11 -0400
Subject: [PATCH 062/110] New package: spex-x replaces spek-alternative for
 ffmpeg6

---
 srcpkgs/spek-alternative                      |  1 +
 srcpkgs/{spek-alternative => spek-x}/template | 22 ++++++++++++-------
 2 files changed, 15 insertions(+), 8 deletions(-)
 create mode 120000 srcpkgs/spek-alternative
 rename srcpkgs/{spek-alternative => spek-x}/template (52%)

diff --git a/srcpkgs/spek-alternative b/srcpkgs/spek-alternative
new file mode 120000
index 00000000000000..76648236da7017
--- /dev/null
+++ b/srcpkgs/spek-alternative
@@ -0,0 +1 @@
+spek-x
\ No newline at end of file
diff --git a/srcpkgs/spek-alternative/template b/srcpkgs/spek-x/template
similarity index 52%
rename from srcpkgs/spek-alternative/template
rename to srcpkgs/spek-x/template
index d7b55c776b1d43..3ded6c2c323e4f 100644
--- a/srcpkgs/spek-alternative/template
+++ b/srcpkgs/spek-x/template
@@ -1,18 +1,18 @@
-# Template file for 'spek-alternative'
-pkgname=spek-alternative
-version=0.8.2.3
-revision=2
+# Template file for 'spek-x'
+pkgname=spek-x
+version=0.9.3
+revision=1
 build_style=gnu-configure
 hostmakedepends="automake gettext-devel intltool libtool pkg-config
  wxWidgets-common wxWidgets-gtk3-devel"
 makedepends="ffmpeg-devel wxWidgets-gtk3-devel"
 depends="ffmpeg"
 short_desc="Acoustic spectrum analyser"
-maintainer="Kartik Singh <kartik.ynwa@gmail.com>"
+maintainer="zlice <zlice555@gmail.com>"
 license="GPL-3.0-or-later"
-homepage="https://github.com/withmorten/spek-alternative"
-distfiles="https://github.com/withmorten/spek-alternative/archive/${version}.tar.gz"
-checksum="007ba4b84a310b078e378aa84c8e80783db5821437a757a488c3ecec377e6b2a"
+homepage="https://github.com/MikeWang000000/spek-x"
+distfiles="https://github.com/MikeWang000000/spek-x/archive/v${version}.tar.gz"
+checksum="7f4b109903333cdd310ab2b9176f0dc49a565891376e281a233d342cedf90ef7"
 
 CXXFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
 
@@ -22,3 +22,9 @@ export WX_CONFIG_NAME="wx-config-gtk3"
 pre_configure() {
 	NOCONFIGURE=1 ./autogen.sh
 }
+
+spek-alternative_package() {
+	depends="spek-x"
+	short_desc+=" - transitional dummy package"
+	build_style=meta
+}

From 19048d911a81ab5f5d3f90d1e705a07654a38dae Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 063/110] ssr: revbump for ffmpeg6

---
 .../0001-Fix-build-with-ffmpeg-5.0.patch      | 241 ++++++++++++++++++
 srcpkgs/ssr/template                          |   2 +-
 2 files changed, 242 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ssr/patches/0001-Fix-build-with-ffmpeg-5.0.patch

diff --git a/srcpkgs/ssr/patches/0001-Fix-build-with-ffmpeg-5.0.patch b/srcpkgs/ssr/patches/0001-Fix-build-with-ffmpeg-5.0.patch
new file mode 100644
index 00000000000000..4c069b5a9fc464
--- /dev/null
+++ b/srcpkgs/ssr/patches/0001-Fix-build-with-ffmpeg-5.0.patch
@@ -0,0 +1,241 @@
+From f4cbde38021d9330dc73d2e3dfa8a70da3ff5721 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Bernhard=20Rosenkr=C3=A4nzer?= <bero@lindev.ch>
+Date: Sun, 16 Jan 2022 02:40:04 +0100
+Subject: [PATCH] Fix build with ffmpeg 5.0
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Adapt to ffmpeg 5.0 requiring more const-ness for AVCodec.
+
+Signed-off-by: Bernhard Rosenkränzer <bero@lindev.ch>
+---
+ src/AV/Output/AudioEncoder.cpp |  6 +++---
+ src/AV/Output/AudioEncoder.h   |  4 ++--
+ src/AV/Output/BaseEncoder.cpp  |  4 ++--
+ src/AV/Output/BaseEncoder.h    |  4 ++--
+ src/AV/Output/Muxer.cpp        | 12 ++++++------
+ src/AV/Output/Muxer.h          |  4 ++--
+ src/AV/Output/VideoEncoder.cpp |  6 +++---
+ src/AV/Output/VideoEncoder.h   |  4 ++--
+ 8 files changed, 22 insertions(+), 22 deletions(-)
+
+diff --git a/src/AV/Output/AudioEncoder.cpp b/src/AV/Output/AudioEncoder.cpp
+index 34d015c..cefc2e0 100644
+--- a/src/AV/Output/AudioEncoder.cpp
++++ b/src/AV/Output/AudioEncoder.cpp
+@@ -34,7 +34,7 @@ const std::vector<AudioEncoder::SampleFormatData> AudioEncoder::SUPPORTED_SAMPLE
+ 
+ const unsigned int AudioEncoder::DEFAULT_FRAME_SAMPLES = 1024;
+ 
+-AudioEncoder::AudioEncoder(Muxer* muxer, AVStream* stream, AVCodecContext *codec_context, AVCodec* codec, AVDictionary** options)
++AudioEncoder::AudioEncoder(Muxer* muxer, AVStream* stream, AVCodecContext *codec_context, const AVCodec* codec, AVDictionary** options)
+ 	: BaseEncoder(muxer, stream, codec_context, codec, options) {
+ 
+ #if !SSR_USE_AVCODEC_ENCODE_AUDIO2
+@@ -77,7 +77,7 @@ unsigned int AudioEncoder::GetSampleRate() {
+ }
+ 
+ bool AudioEncoder::AVCodecIsSupported(const QString& codec_name) {
+-	AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
++	const AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
+ 	if(codec == NULL)
+ 		return false;
+ 	if(!av_codec_is_encoder(codec))
+@@ -93,7 +93,7 @@ bool AudioEncoder::AVCodecIsSupported(const QString& codec_name) {
+ 	return false;
+ }
+ 
+-void AudioEncoder::PrepareStream(AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
++void AudioEncoder::PrepareStream(AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
+ 								 unsigned int bit_rate, unsigned int channels, unsigned int sample_rate) {
+ 
+ 	if(channels == 0) {
+diff --git a/src/AV/Output/AudioEncoder.h b/src/AV/Output/AudioEncoder.h
+index c93278c..ae9c82e 100644
+--- a/src/AV/Output/AudioEncoder.h
++++ b/src/AV/Output/AudioEncoder.h
+@@ -40,7 +40,7 @@ private:
+ #endif
+ 
+ public:
+-	AudioEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options);
++	AudioEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options);
+ 	~AudioEncoder();
+ 
+ 	// Returns the required frame size, i.e. the number of samples (for each channel).
+@@ -57,7 +57,7 @@ public:
+ 
+ public:
+ 	static bool AVCodecIsSupported(const QString& codec_name);
+-	static void PrepareStream(AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
++	static void PrepareStream(AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
+ 							  unsigned int bit_rate, unsigned int channels, unsigned int sample_rate);
+ 
+ private:
+diff --git a/src/AV/Output/BaseEncoder.cpp b/src/AV/Output/BaseEncoder.cpp
+index 7c01ef3..4780aaf 100644
+--- a/src/AV/Output/BaseEncoder.cpp
++++ b/src/AV/Output/BaseEncoder.cpp
+@@ -42,7 +42,7 @@ double ParseCodecOptionDouble(const QString& key, const QString& value, double m
+ 	return clamp(value_double, min, max) * multiply;
+ }
+ 
+-BaseEncoder::BaseEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options) {
++BaseEncoder::BaseEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options) {
+ 
+ 	m_muxer = muxer;
+ 	m_stream = stream;
+@@ -157,7 +157,7 @@ void BaseEncoder::IncrementPacketCounter() {
+ 	++lock->m_total_packets;
+ }
+ 
+-void BaseEncoder::Init(AVCodec* codec, AVDictionary** options) {
++void BaseEncoder::Init(const AVCodec* codec, AVDictionary** options) {
+ 
+ 	// open codec
+ 	if(avcodec_open2(m_codec_context, codec, options) < 0) {
+diff --git a/src/AV/Output/BaseEncoder.h b/src/AV/Output/BaseEncoder.h
+index 3d92f29..7f02bbd 100644
+--- a/src/AV/Output/BaseEncoder.h
++++ b/src/AV/Output/BaseEncoder.h
+@@ -51,7 +51,7 @@ private:
+ 	std::atomic<bool> m_should_stop, m_should_finish, m_is_done, m_error_occurred;
+ 
+ protected:
+-	BaseEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options);
++	BaseEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options);
+ 
+ public:
+ 	virtual ~BaseEncoder(); // encoders will be deleted by Muxer, don't delete them yourself!
+@@ -117,7 +117,7 @@ protected:
+ 	void IncrementPacketCounter();
+ 
+ private:
+-	void Init(AVCodec* codec, AVDictionary** options);
++	void Init(const AVCodec* codec, AVDictionary** options);
+ 	void Free();
+ 
+ 	void EncoderThread();
+diff --git a/src/AV/Output/Muxer.cpp b/src/AV/Output/Muxer.cpp
+index ad58380..14650b0 100644
+--- a/src/AV/Output/Muxer.cpp
++++ b/src/AV/Output/Muxer.cpp
+@@ -87,7 +87,7 @@ Muxer::~Muxer() {
+ 
+ VideoEncoder* Muxer::AddVideoEncoder(const QString& codec_name, const std::vector<std::pair<QString, QString> >& codec_options,
+ 									 unsigned int bit_rate, unsigned int width, unsigned int height, unsigned int frame_rate) {
+-	AVCodec *codec = FindCodec(codec_name);
++	const AVCodec *codec = FindCodec(codec_name);
+ 	AVCodecContext *codec_context = NULL;
+ 	AVStream *stream = AddStream(codec, &codec_context);
+ 	VideoEncoder *encoder;
+@@ -111,7 +111,7 @@ VideoEncoder* Muxer::AddVideoEncoder(const QString& codec_name, const std::vecto
+ 
+ AudioEncoder* Muxer::AddAudioEncoder(const QString& codec_name, const std::vector<std::pair<QString, QString> >& codec_options,
+ 									 unsigned int bit_rate, unsigned int channels, unsigned int sample_rate) {
+-	AVCodec *codec = FindCodec(codec_name);
++	const AVCodec *codec = FindCodec(codec_name);
+ 	AVCodecContext *codec_context = NULL;
+ 	AVStream *stream = AddStream(codec, &codec_context);
+ 	AudioEncoder *encoder;
+@@ -194,7 +194,7 @@ unsigned int Muxer::GetQueuedPacketCount(unsigned int stream_index) {
+ void Muxer::Init() {
+ 
+ 	// get the format we want (this is just a pointer, we don't have to free this)
+-	AVOutputFormat *format = av_guess_format(m_container_name.toUtf8().constData(), NULL, NULL);
++	const AVOutputFormat *format = av_guess_format(m_container_name.toUtf8().constData(), NULL, NULL);
+ 	if(format == NULL) {
+ 		Logger::LogError("[Muxer::Init] " + Logger::tr("Error: Can't find chosen output format!"));
+ 		throw LibavException();
+@@ -261,8 +261,8 @@ void Muxer::Free() {
+ 	}
+ }
+ 
+-AVCodec* Muxer::FindCodec(const QString& codec_name) {
+-	AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
++const AVCodec* Muxer::FindCodec(const QString& codec_name) {
++	const AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
+ 	if(codec == NULL) {
+ 		Logger::LogError("[Muxer::FindCodec] " + Logger::tr("Error: Can't find codec!"));
+ 		throw LibavException();
+@@ -270,7 +270,7 @@ AVCodec* Muxer::FindCodec(const QString& codec_name) {
+ 	return codec;
+ }
+ 
+-AVStream* Muxer::AddStream(AVCodec* codec, AVCodecContext** codec_context) {
++AVStream* Muxer::AddStream(const AVCodec* codec, AVCodecContext** codec_context) {
+ 	assert(!m_started);
+ 	assert(m_format_context->nb_streams < MUXER_MAX_STREAMS);
+ 
+diff --git a/src/AV/Output/Muxer.h b/src/AV/Output/Muxer.h
+index d72347d..b104bcb 100644
+--- a/src/AV/Output/Muxer.h
++++ b/src/AV/Output/Muxer.h
+@@ -114,8 +114,8 @@ private:
+ 	void Init();
+ 	void Free();
+ 
+-	AVCodec* FindCodec(const QString& codec_name);
+-	AVStream* AddStream(AVCodec* codec, AVCodecContext** codec_context);
++	const AVCodec* FindCodec(const QString& codec_name);
++	AVStream* AddStream(const AVCodec* codec, AVCodecContext** codec_context);
+ 
+ 	void MuxerThread();
+ 
+diff --git a/src/AV/Output/VideoEncoder.cpp b/src/AV/Output/VideoEncoder.cpp
+index 8087e8e..fc8b5d1 100644
+--- a/src/AV/Output/VideoEncoder.cpp
++++ b/src/AV/Output/VideoEncoder.cpp
+@@ -34,7 +34,7 @@ const std::vector<VideoEncoder::PixelFormatData> VideoEncoder::SUPPORTED_PIXEL_F
+ 	{"rgb", AV_PIX_FMT_RGB24, false},
+ };
+ 
+-VideoEncoder::VideoEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options)
++VideoEncoder::VideoEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options)
+ 	: BaseEncoder(muxer, stream, codec_context, codec, options) {
+ 
+ #if !SSR_USE_AVCODEC_ENCODE_VIDEO2
+@@ -95,7 +95,7 @@ unsigned int VideoEncoder::GetFrameRate() {
+ }
+ 
+ bool VideoEncoder::AVCodecIsSupported(const QString& codec_name) {
+-	AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
++	const AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
+ 	if(codec == NULL)
+ 		return false;
+ 	if(!av_codec_is_encoder(codec))
+@@ -111,7 +111,7 @@ bool VideoEncoder::AVCodecIsSupported(const QString& codec_name) {
+ 	return false;
+ }
+ 
+-void VideoEncoder::PrepareStream(AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
++void VideoEncoder::PrepareStream(AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
+ 								 unsigned int bit_rate, unsigned int width, unsigned int height, unsigned int frame_rate) {
+ 
+ 	if(width == 0 || height == 0) {
+diff --git a/src/AV/Output/VideoEncoder.h b/src/AV/Output/VideoEncoder.h
+index cb7ca27..68d872e 100644
+--- a/src/AV/Output/VideoEncoder.h
++++ b/src/AV/Output/VideoEncoder.h
+@@ -40,7 +40,7 @@ private:
+ #endif
+ 
+ public:
+-	VideoEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options);
++	VideoEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options);
+ 	~VideoEncoder();
+ 
+ 	// Returns the required pixel format.
+@@ -55,7 +55,7 @@ public:
+ 
+ public:
+ 	static bool AVCodecIsSupported(const QString& codec_name);
+-	static void PrepareStream(AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
++	static void PrepareStream(AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
+ 							  unsigned int bit_rate, unsigned int width, unsigned int height, unsigned int frame_rate);
+ 
+ private:
+-- 
+2.43.0
+
diff --git a/srcpkgs/ssr/template b/srcpkgs/ssr/template
index 3097754e3cbe54..e3c4261f1f5a64 100644
--- a/srcpkgs/ssr/template
+++ b/srcpkgs/ssr/template
@@ -1,7 +1,7 @@
 # Template file for 'ssr'
 pkgname=ssr
 version=0.4.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DWITH_QT5=ON"
 hostmakedepends="pkg-config"

From 794ea3fe123413f367a877410b25299bd9c3cb22 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 064/110] synfig: revbump for ffmpeg6 and mlt7

---
 srcpkgs/synfig/patches/ffmpeg6.patch | 71 ++++++++++++++++++++++++++++
 srcpkgs/synfig/template              |  6 +--
 2 files changed, 74 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/synfig/patches/ffmpeg6.patch

diff --git a/srcpkgs/synfig/patches/ffmpeg6.patch b/srcpkgs/synfig/patches/ffmpeg6.patch
new file mode 100644
index 00000000000000..10780b42782f4b
--- /dev/null
+++ b/srcpkgs/synfig/patches/ffmpeg6.patch
@@ -0,0 +1,71 @@
+--- a/src/modules/mod_libavcodec/trgt_av.cpp	2022-10-25 09:14:12.000000000 -0400
++++ b/src/modules/mod_libavcodec/trgt_av.cpp	2023-05-05 21:34:17.899194559 -0400
+@@ -38,6 +41,7 @@
+ extern "C"
+ {
+ #ifdef HAVE_LIBAVFORMAT_AVFORMAT_H
++#	include <libavcodec/avcodec.h>
+ #	include <libavformat/avformat.h>
+ #elif defined(HAVE_AVFORMAT_H)
+ #	include <avformat.h>
+@@ -155,11 +156,11 @@
+     }
+ 
+ 	bool open_video_stream() {
+-		if (avcodec_open2(video_context, NULL, NULL) < 0) {
++		if (avcodec_open2(video_context, nullptr, nullptr) < 0) {
+ 			synfig::error("Target_LibAVCodec: could not open video codec");
+ 			// seems the calling of avcodec_free_context after error will cause crash
+ 			// so just forget about this context
+-			video_context = NULL;
++			video_context = nullptr;
+ 			close();
+ 			return false;
+         }
+@@ -234,15 +235,21 @@
+ 		close();
+ 
+ 		if (!av_registered) {
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 			av_register_all();
++#endif
+ 			av_registered = true;
+ 		}
+ 
+ 		// guess format
+-		AVOutputFormat *format = av_guess_format(NULL, filename.c_str(), NULL);
++#if LIBAVCODEC_VERSION_MAJOR < 59 // FFMPEG < 5.0
++		AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#else
++		const AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#endif
+ 		if (!format) {
+ 			synfig::warning("Target_LibAVCodec: unable to guess the output format, defaulting to MPEG");
+-			format = av_guess_format("mpeg", NULL, NULL);
++			format = av_guess_format("mpeg", nullptr, nullptr);
+ 		}
+ 		if (!format) {
+ 			synfig::error("Target_LibAVCodec: unable to find 'mpeg' output format");
+@@ -254,6 +261,7 @@
+ 		context = avformat_alloc_context();
+ 		assert(context);
+ 		context->oformat = format;
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 		if (filename.size() + 1 > sizeof(context->filename)) {
+ 			synfig::error(
+ 				"Target_LibAVCodec: filename too long, max length is %d, filename is '%s'",
+@@ -263,6 +271,14 @@
+ 			return false;
+ 		}
+ 		memcpy(context->filename, filename.c_str(), filename.size() + 1);
++#else
++		context->url = av_strndup(filename.c_str(), filename.size());
++		if (!context->url) {
++			synfig::error("Target_LibAVCodec: cannot allocate space for filename");
++			close();
++			return false;
++		}
++#endif
+ 
+ 		packet = av_packet_alloc();
+ 		assert(packet);
diff --git a/srcpkgs/synfig/template b/srcpkgs/synfig/template
index d4d3e341a20bf8..828b5cb32956ee 100644
--- a/srcpkgs/synfig/template
+++ b/srcpkgs/synfig/template
@@ -2,11 +2,11 @@
 # Should be kept in sync with 'synfigstudio' and 'ETL'
 pkgname=synfig
 version=1.4.4
-revision=4
+revision=5
 build_style=gnu-configure
 configure_args="--with-boost-libdir=${XBPS_CROSS_BASE}/usr/lib"
 hostmakedepends="boost-build ImageMagick pkg-config intltool"
-makedepends="ETL gettext-devel libxml++-devel mlt-devel libmagick-devel
+makedepends="ETL gettext-devel libxml++-devel mlt7-devel libmagick-devel
  libmng-devel boost-build boost-devel libopenexr-devel ffmpeg-devel"
 depends="ImageMagick"
 short_desc="CLI 2D vector and timeline-based animation software"
@@ -20,7 +20,7 @@ CXXFLAGS="-std=c++11 -DHAVE_LOCALE_H=1"
 
 synfig-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision}
-	 libopenexr-devel libxml++-devel mlt-devel"
+	 libopenexr-devel libxml++-devel mlt7-devel"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/bin/synfig-config

From 121f8b347fa90ef6c5f63b55c7ea2e16ebb116c6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 065/110] timg: revbump for ffmpeg6

---
 srcpkgs/timg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/timg/template b/srcpkgs/timg/template
index 2a2ab763d2fddf..8fb4327535ef93 100644
--- a/srcpkgs/timg/template
+++ b/srcpkgs/timg/template
@@ -1,7 +1,7 @@
 # Template file for 'timg'
 pkgname=timg
 version=1.4.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_OPENSLIDE_SUPPORT=off -Wno-dev"
 hostmakedepends="pkg-config git"

From 1310d992f413e3253fa8dfef87843f059555c9a9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 066/110] tvheadend: revbump for ffmpeg4

---
 srcpkgs/tvheadend/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tvheadend/template b/srcpkgs/tvheadend/template
index 9aea7de4ec7057..012d31c4879ff1 100644
--- a/srcpkgs/tvheadend/template
+++ b/srcpkgs/tvheadend/template
@@ -8,7 +8,7 @@ configure_args="--enable-dvbscan --disable-ffmpeg_static
 --disable-libx265_static --disable-libvpx_static --disable-libtheora_static
 --disable-libvorbis_static --disable-libfdkaac_static"
 hostmakedepends="gettext pkg-config python3 git which"
-makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg-devel"
+makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg4-devel"
 short_desc="TV streaming server"
 maintainer="lemmi <lemmi@nerd2nerd.org>"
 license="GPL-3.0-only"

From 8dd2cc0b283889a580d5bc5c9926eb626c7addce Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 067/110] unpaper: update to 7.0.0.

---
 srcpkgs/unpaper/template | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/srcpkgs/unpaper/template b/srcpkgs/unpaper/template
index 38ed47a5840165..1ff910e722afc8 100644
--- a/srcpkgs/unpaper/template
+++ b/srcpkgs/unpaper/template
@@ -1,13 +1,13 @@
 # Template file for 'unpaper'
 pkgname=unpaper
-version=6.1
-revision=3
-build_style=gnu-configure
+version=7.0.0
+revision=1
+build_style=meson
+hostmakedepends="pkg-config meson libxslt"
+makedepends="ffmpeg-devel python3-Sphinx"
+short_desc="Post-processing tool for scanned sheets of paper"
 maintainer="Orphaned <orphan@voidlinux.org>"
-hostmakedepends="pkg-config libxslt"
-makedepends="ffmpeg-devel"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://www.flameeyes.eu/projects/unpaper"
-short_desc="A post-processing tool for scanned sheets of paper"
 distfiles="https://www.flameeyes.eu/files/${pkgname}-${version}.tar.xz"
-checksum=237c84f5da544b3f7709827f9f12c37c346cdf029b1128fb4633f9bafa5cb930
+checksum=2575fbbf26c22719d1cb882b59602c9900c7f747118ac130883f63419be46a80

From 06b7bef2fe1c2cf00779afff15bf4f2aec6708e2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 068/110] vice: revbump for ffmpeg4

---
 srcpkgs/vice/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/vice/template b/srcpkgs/vice/template
index b1f866d35095e7..43f79243a1da11 100644
--- a/srcpkgs/vice/template
+++ b/srcpkgs/vice/template
@@ -1,7 +1,7 @@
 # Template file for 'vice'
 pkgname=vice
 version=3.7.1
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="
 	$(vopt_enable sdl2 sdlui2)
@@ -26,7 +26,7 @@ makedepends="
 	$(vopt_if gtk3 gtk+3-devel)
 	$(vopt_if gtk3 pulseaudio-devel)
 	$(vopt_if gtk3 pango-devel)
-	$(vopt_if ffmpeg ffmpeg-devel)"
+	$(vopt_if ffmpeg ffmpeg4-devel)"
 short_desc="Emulator for C64, C128, CBM-II, PET, VIC20, Plus4 and C16"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"

From cb6b959f84f92e30cb21b5bb8267aa4bcdd4b039 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 069/110] waypipe: revbump for ffmpeg6

---
 srcpkgs/waypipe/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waypipe/template b/srcpkgs/waypipe/template
index 6da88b21bf2a19..4da8058400b588 100644
--- a/srcpkgs/waypipe/template
+++ b/srcpkgs/waypipe/template
@@ -1,7 +1,7 @@
 # Template file for 'waypipe'
 pkgname=waypipe
 version=0.8.6
-revision=1
+revision=2
 build_style=meson
 # lto is off because it causes linking errors in armv6l and armv7l (due to NEON)
 configure_args="-Dwerror=false -Dwith_dmabuf=enabled -Dwith_lz4=enabled

From 2d46f7ad1cd81da36b5e07983791e38017b46384 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 070/110] xpra: revbump for ffmpeg6

---
 srcpkgs/xpra/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xpra/template b/srcpkgs/xpra/template
index 3e49ab23deac9c..3939026a6fbf90 100644
--- a/srcpkgs/xpra/template
+++ b/srcpkgs/xpra/template
@@ -1,7 +1,7 @@
 # Template file for 'xpra'
 pkgname=xpra
 version=5.0.7
-revision=1
+revision=2
 build_style=python3-module
 make_build_args="--without-cuda_kernels --without-cuda_rebuild"
 make_install_args="$(vopt_with docs) ${make_build_args}"

From d8684660c5b99a839c68012df156c12415df85e7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:07:40 -0400
Subject: [PATCH 071/110] nv-codec-headers: update to 12.0.16.0

---
 srcpkgs/nv-codec-headers/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/nv-codec-headers/template b/srcpkgs/nv-codec-headers/template
index 3d422a61e48917..251e057f826fb8 100644
--- a/srcpkgs/nv-codec-headers/template
+++ b/srcpkgs/nv-codec-headers/template
@@ -1,6 +1,6 @@
 # Template file for 'nv-codec-headers'
 pkgname=nv-codec-headers
-version=11.1.5.1
+version=12.0.16.0
 revision=1
 build_style=gnu-makefile
 short_desc="FFmpeg version of headers required to interface with Nvidias codec APIs"
@@ -8,7 +8,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="MIT"
 homepage="http://git.videolan.org/?p=ffmpeg/nv-codec-headers.git"
 distfiles="https://github.com/FFmpeg/nv-codec-headers/archive/n${version}.tar.gz"
-checksum=d095fbd56aa93772471a323be0ebe65504a0f43f06c76a30b6d25da77b06ae9c
+checksum=2a1533b65f55f9da52956faf0627ed3b74868ac0c7f269990edd21369113b48f
 
 post_install() {
 	sed -n '4,25p' include/ffnvcodec/nvEncodeAPI.h > LICENSE

From ff2a0463be8cf82cb10ce6785501f785512cf26b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:08:40 -0400
Subject: [PATCH 072/110] openimagedenoise: revbump for ffmpeg6

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index 109deb171c3f75..44edf38fb289d8 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,7 +1,7 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
 version=1.4.3
-revision=2
+revision=3
 archs="x86_64*"
 build_style=cmake
 hostmakedepends="ispc python3"

From 00886ea114943bcc2ac27ce28545f5a9be8aaa9b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:31:45 -0400
Subject: [PATCH 073/110] shotcut: revbump for ffmpeg6

---
 srcpkgs/shotcut/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/shotcut/template b/srcpkgs/shotcut/template
index 33141fbd862d7a..f46cb53b6bfb92 100644
--- a/srcpkgs/shotcut/template
+++ b/srcpkgs/shotcut/template
@@ -1,7 +1,7 @@
 # Template file for 'shotcut'
 pkgname=shotcut
 version=23.09.29
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSHOTCUT_VERSION=${version}"
 hostmakedepends="pkg-config qt6-tools-devel"

From 216ae213c45fe7e16cb72885cf1d1046d288af04 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:30 -0400
Subject: [PATCH 074/110] shiboken2: revbump for qt5-5.15.11

---
 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch | 1 +
 1 file changed, 1 insertion(+)
 create mode 120000 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
new file mode 120000
index 00000000000000..efcf3249bd8854
--- /dev/null
+++ b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1 @@
+../../python3-pyside2/patches/importlib-machinery-bypass.patch
\ No newline at end of file

From ad99171e96f1d6ca0f7386cde4bbb43645f75491 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:53 -0400
Subject: [PATCH 075/110] python3-pyside2: revbump for qt5-5.15.11

---
 .../patches/importlib-machinery-bypass.patch      | 15 +++++++++++++++
 srcpkgs/python3-pyside2/template                  |  2 +-
 2 files changed, 16 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
new file mode 100644
index 00000000000000..64c429584776b5
--- /dev/null
+++ b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1,15 @@
+Using this prevents an error around line 220 below it.
+"AttributeError: module 'importlib' has no attribute 'machinery'"
+The old backup logic is in place and compiles without issues.
+--- a/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:09:34.688912402 -0400
++++ b/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:10:03.395529582 -0400
+@@ -170,9 +170,6 @@
+
+     # 'zipstring_sequence' comes from signature.cpp
+     zipbytes = base64.b64decode(''.join(zipstring_sequence))
+-    if sys.version_info[0] >= 3:
+-        vzip = zipfile.ZipFile(io.BytesIO(zipbytes))
+-        return sys.meta_path, EmbeddableZipImporter(vzip)
+
+     # Old version for Python 2.7, only.
+     import os
diff --git a/srcpkgs/python3-pyside2/template b/srcpkgs/python3-pyside2/template
index 249efa90988425..52626436ce75f2 100644
--- a/srcpkgs/python3-pyside2/template
+++ b/srcpkgs/python3-pyside2/template
@@ -1,7 +1,7 @@
 # Template file for 'python3-pyside2'
 pkgname=python3-pyside2
 version=5.15.10
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/pyside2"
 build_style=cmake

From 091883b4ff7681cf402e7fb6bec4a4b2deee2d45 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:35 -0400
Subject: [PATCH 076/110] konqueror: revbump for ffmpeg6

---
 srcpkgs/konqueror/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/konqueror/template b/srcpkgs/konqueror/template
index add972916753c6..50bbf4eec05e55 100644
--- a/srcpkgs/konqueror/template
+++ b/srcpkgs/konqueror/template
@@ -1,11 +1,11 @@
 # Template file for 'konqueror'
 pkgname=konqueror
 version=23.08.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DDESKTOPTOJSON_EXECUTABLE=/usr/bin/desktoptojson"
 hostmakedepends="extra-cmake-modules python3 qt5-host-tools qt5-qmake kdoctools
-kcoreaddons kconfig gettext"
+ kcoreaddons kconfig gettext"
 makedepends="qt5-devel qt5-webengine-devel qt5-declarative-devel
  qt5-webchannel-devel qt5-location-devel kcmutils-devel kdelibs4support-devel
  karchive-devel khtml-devel kdesu-devel kactivities5-devel"

From 83b9997d420aa7f152e9dfd2be8bfd41da0894f9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:58 -0400
Subject: [PATCH 077/110] qt5-speech: revbump for qt5-5.15.11

---
 srcpkgs/qt5-speech/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-speech/template b/srcpkgs/qt5-speech/template
index 1228bb60c41db4..27a7da1dbdb91b 100644
--- a/srcpkgs/qt5-speech/template
+++ b/srcpkgs/qt5-speech/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-speech'
 pkgname=qt5-speech
 version=5.15.11
-revision=1
+revision=2
 _commit=d32f4a479d38a11f547598004b975f4356424a16
 build_style=qmake
 configure_args="-- -flite -flite-alsa -speechd"

From 48fd18342c40cc3ae59ad7b7ae93ea872c874ef6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Jun 2023 08:20:22 -0400
Subject: [PATCH 078/110] gtk4: revbump for ffmpeg6

---
 srcpkgs/gtk4/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gtk4/template b/srcpkgs/gtk4/template
index 3f2554ea3bc940..da41e85ec329c3 100644
--- a/srcpkgs/gtk4/template
+++ b/srcpkgs/gtk4/template
@@ -1,7 +1,7 @@
 # Template file for 'gtk4'
 pkgname=gtk4
 version=4.12.5
-revision=1
+revision=2
 build_style=meson
 build_helper="gir"
 configure_args="-Dman-pages=true -Ddocumentation=true -Dbuild-tests=false

From cdc0252846fcc221de0c3c12676ec672af75e834 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:28:26 -0400
Subject: [PATCH 079/110] siril: revbump for ffmpeg6

---
 srcpkgs/siril/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/siril/template b/srcpkgs/siril/template
index 84332f79d060d2..62750dd247548f 100644
--- a/srcpkgs/siril/template
+++ b/srcpkgs/siril/template
@@ -1,7 +1,7 @@
 # Template file for 'siril'
 pkgname=siril
 version=0.9.12
-revision=10
+revision=11
 build_style=gnu-configure
 hostmakedepends="pkg-config intltool autoconf automake gettext-devel"
 makedepends="fftw-devel libconfig-devel libopencv-devel libffms2-devel

From 230c4bd2da1010781913cfc125b1e845d8947eb8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 22 Jun 2023 10:25:02 -0400
Subject: [PATCH 080/110] kdenlive: revbump for ffmpeg6

---
 srcpkgs/kdenlive/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kdenlive/template b/srcpkgs/kdenlive/template
index ecb48dfc74d29d..a3476d0b876b10 100644
--- a/srcpkgs/kdenlive/template
+++ b/srcpkgs/kdenlive/template
@@ -1,7 +1,7 @@
 # Template file for 'kdenlive'
 pkgname=kdenlive
 version=23.08.5
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="
  extra-cmake-modules kconfig kcoreaddons kdoctools pkg-config python3

From d60cfc0b224faa6514e7573a6a59fc53cb886f59 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:20:59 -0400
Subject: [PATCH 081/110] tracker-miners: revbump for ffmpeg6

---
 srcpkgs/tracker-miners/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tracker-miners/template b/srcpkgs/tracker-miners/template
index 0b97f47489f817..f196d2bf9e4a4c 100644
--- a/srcpkgs/tracker-miners/template
+++ b/srcpkgs/tracker-miners/template
@@ -1,7 +1,7 @@
 # Template file for 'tracker-miners'
 pkgname=tracker-miners
 version=3.6.1
-revision=1
+revision=2
 build_style=meson
 build_helper=qemu
 # missing libgrss for miner_rss

From 450e1ce4e12aaf55a676982997ebdb05c4a2559f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:21:21 -0400
Subject: [PATCH 082/110] mpd: revbump for ffmpeg6

---
 srcpkgs/mpd/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpd/template b/srcpkgs/mpd/template
index 4fd32b7be8c537..b8e2bd4c1b59c8 100644
--- a/srcpkgs/mpd/template
+++ b/srcpkgs/mpd/template
@@ -1,7 +1,7 @@
 # Template file for 'mpd'
 pkgname=mpd
 version=0.23.15
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dopus=enabled -Dmikmod=enabled -Dneighbor=true
  -Dsoundcloud=enabled -Dpipe=true -Dtwolame=enabled -Dbzip2=enabled

From df7cf2da00a85e7774a5925722c14bf53eb70e7b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:02 -0400
Subject: [PATCH 083/110] tg_owt: revbump for ffmpeg6

---
 srcpkgs/tg_owt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tg_owt/template b/srcpkgs/tg_owt/template
index 34e8fef0540569..1a46a8bedf3473 100644
--- a/srcpkgs/tg_owt/template
+++ b/srcpkgs/tg_owt/template
@@ -1,7 +1,7 @@
 # Template file for 'tg_owt'
 pkgname=tg_owt
 version=0.0.0.20231221
-revision=2
+revision=3
 _commit=afd9d5d31798d3eacf9ed6c30601e91d0f1e4d60
 _libyuv_commit=04821d1e7d60845525e8db55c7bcd41ef5be9406
 _abseil_commit=8c0b94e793a66495e0b1f34a5eb26bd7dc672db0

From 9df660b2c5b7d546fde76b9b484bbbf766d1cb95 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:44 -0400
Subject: [PATCH 084/110] telegram-desktop: revbump for ffmpeg6

---
 srcpkgs/telegram-desktop/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/telegram-desktop/template b/srcpkgs/telegram-desktop/template
index 6dc6a553cfcec8..cf85a731370062 100644
--- a/srcpkgs/telegram-desktop/template
+++ b/srcpkgs/telegram-desktop/template
@@ -1,7 +1,7 @@
 # Template file for 'telegram-desktop'
 pkgname=telegram-desktop
 version=4.14.15
-revision=3
+revision=4
 build_style=cmake
 build_helper="qemu gir"
 configure_args="-DTDESKTOP_API_ID=209235

From 4b02b1e94608b9c4657a0d803cf561e2b1ae88f3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:12:09 -0400
Subject: [PATCH 085/110] openmw: revbump for ffmpeg6

---
 srcpkgs/openmw/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openmw/template b/srcpkgs/openmw/template
index 0abf5ff7cdbecc..b57180f1a4446f 100644
--- a/srcpkgs/openmw/template
+++ b/srcpkgs/openmw/template
@@ -1,7 +1,7 @@
 # Template file for 'openmw'
 pkgname=openmw
 version=0.48.0
-revision=2
+revision=3
 build_style=cmake
 _recast_commit=e75adf86f91eb3082220085e42dda62679f9a3ea
 _bullet_tag=3.17

From 84a671399018905fc137853f59bf2bad50495628 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:14:53 -0400
Subject: [PATCH 086/110] lms: revbump for ffmpeg6

---
 srcpkgs/lms/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/lms/template b/srcpkgs/lms/template
index e358f75902a986..3b21c458de5199 100644
--- a/srcpkgs/lms/template
+++ b/srcpkgs/lms/template
@@ -1,7 +1,7 @@
 # Template file for 'lms'
 pkgname=lms
 version=3.42.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="wt-devel ffmpeg-devel boost-devel libconfig++-devel taglib-devel pam-devel libgraphicsmagick-devel gtest-devel libarchive-devel"

From a68bf9156ab344128b5ef9a576a9278dc0687664 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:18:18 -0400
Subject: [PATCH 087/110] freecad: DELETE

---
 srcpkgs/freecad/patches/001-include.patch     | 112 ------------------
 .../154-revert-gui-tmp-redirect-stderr.patch  |  68 -----------
 ...d63c8c9b1280978be841d04e68a0a55cceb9.patch |  30 -----
 srcpkgs/freecad/template                      |  12 +-
 4 files changed, 7 insertions(+), 215 deletions(-)
 delete mode 100644 srcpkgs/freecad/patches/001-include.patch
 delete mode 100644 srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
 delete mode 100644 srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch

diff --git a/srcpkgs/freecad/patches/001-include.patch b/srcpkgs/freecad/patches/001-include.patch
deleted file mode 100644
index 28b5af54999b96..00000000000000
--- a/srcpkgs/freecad/patches/001-include.patch
+++ /dev/null
@@ -1,112 +0,0 @@
-From 9a41845a417189776741297c50a3827ce292bc4f Mon Sep 17 00:00:00 2001
-From: Uwe <donovaly@users.noreply.github.com>
-Date: Sun, 3 Jul 2022 22:51:16 +0200
-Subject: [PATCH] [Part] OCCError.h: remove unneeded includes
-
-- also sort includes
----
- src/Mod/Part/App/OCCError.h             | 36 +++----------------------
- src/Mod/Part/App/OffsetCurvePyImp.cpp   | 12 ++++-----
- src/Mod/Part/App/OffsetSurfacePyImp.cpp | 10 +++----
- 3 files changed, 12 insertions(+), 46 deletions(-)
-
---- a/src/Mod/Part/App/OCCError.h
-+++ b/src/Mod/Part/App/OCCError.h
-@@ -23,36 +23,8 @@
- #ifndef _OCCError_h_
- #define _OCCError_h_
- 
--# include <Standard_Version.hxx>
- # include <Standard_Failure.hxx>
--# include <Standard_AbortiveTransaction.hxx>
--# include <Standard_ConstructionError.hxx>
--# if OCC_VERSION_HEX >= 0x060500
--# include <Standard_DefineException.hxx>
--# endif
--# include <Standard_DimensionError.hxx>
--# include <Standard_DimensionMismatch.hxx>
--# include <Standard_DivideByZero.hxx>
--# include <Standard_DomainError.hxx>
--# include <Standard_ImmutableObject.hxx>
--# include <Standard_LicenseError.hxx>
--# include <Standard_LicenseNotFound.hxx>
--# include <Standard_MultiplyDefined.hxx>
--# include <Standard_NegativeValue.hxx>
--# include <Standard_NoMoreObject.hxx>
--# include <Standard_NoSuchObject.hxx>
--# include <Standard_NotImplemented.hxx>
--# include <Standard_NullObject.hxx>
--# include <Standard_NullValue.hxx>
--# include <Standard_NumericError.hxx>
--# include <Standard_OutOfMemory.hxx>
--# include <Standard_OutOfRange.hxx>
--# include <Standard_Overflow.hxx>
--# include <Standard_ProgramError.hxx>
--# include <Standard_RangeError.hxx>
--# include <Standard_TooManyUsers.hxx>
--# include <Standard_TypeMismatch.hxx>
--# include <Standard_Underflow.hxx>
-+# include <Standard_Version.hxx>
- 
- #include <Mod/Part/PartGlobal.h>
- #include <Base/Console.h>
-@@ -88,4 +60,3 @@ PartExport extern PyObject* PartExceptio
- 
- #define PY_CATCH_OCC _PY_CATCH_OCC(return(NULL))
- #endif  // _OCCError_h_
--
---- a/src/Mod/Part/App/OffsetCurvePyImp.cpp
-+++ b/src/Mod/Part/App/OffsetCurvePyImp.cpp
-@@ -20,20 +20,20 @@
-  *                                                                         *
-  ***************************************************************************/
- 
--
- #include "PreCompiled.h"
- #ifndef _PreComp_
- # include <Geom_OffsetCurve.hxx>
- #endif
- 
--#include "OCCError.h"
--#include "Geometry.h"
-+#include <Base/GeometryPyCXX.h>
-+#include <Base/Vector3D.h>
-+#include <Base/VectorPy.h>
-+
- #include "OffsetCurvePy.h"
- #include "OffsetCurvePy.cpp"
-+#include "Geometry.h"
-+#include "OCCError.h"
- 
--#include <Base/GeometryPyCXX.h>
--#include <Base/VectorPy.h>
--#include <Base/Vector3D.h>
- 
- using namespace Part;
- 
---- a/src/Mod/Part/App/OffsetSurfacePyImp.cpp
-+++ b/src/Mod/Part/App/OffsetSurfacePyImp.cpp
-@@ -20,20 +20,16 @@
-  *                                                                         *
-  ***************************************************************************/
- 
--
- #include "PreCompiled.h"
- #ifndef _PreComp_
- # include <Geom_OffsetSurface.hxx>
- # include <memory>
- #endif
- 
--#include <Base/VectorPy.h>
--#include <Base/Vector3D.h>
--
- #include "OCCError.h"
--#include "Geometry.h"
--#include <Mod/Part/App/OffsetSurfacePy.h>
--#include <Mod/Part/App/OffsetSurfacePy.cpp>
-+#include "OffsetSurfacePy.h"
-+#include "OffsetSurfacePy.cpp"
-+
- 
- using namespace Part;
- 
diff --git a/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch b/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
deleted file mode 100644
index d6a9adabdec830..00000000000000
--- a/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
+++ /dev/null
@@ -1,68 +0,0 @@
-see https://github.com/FreeCAD/FreeCAD/commit/cfe94b00d3434f3e2c8b5114d2909f628c330fa8#commitcomment-71413407
-
-upstream: yes
-
-From 7b377a216b9185960e4cee980a6504dc1a755f50 Mon Sep 17 00:00:00 2001
-From: wmayer <wmayer@users.sourceforge.net>
-Date: Wed, 29 Jun 2022 15:19:18 +0200
-Subject: [PATCH] Gui: remove workaround for spnav 0.23 due to build failure
- with musl libc
-
----
- src/Gui/3Dconnexion/GuiNativeEventLinux.cpp | 27 ---------------------
- 1 file changed, 27 deletions(-)
-
---- a/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp
-+++ b/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp
-@@ -21,42 +21,17 @@
-  ***************************************************************************/
- 
- #include <FCConfig.h>
--#include <cstdio>
- 
- #include "GuiNativeEventLinux.h"
- 
- #include "GuiApplicationNativeEventAware.h"
- #include <Base/Console.h>
--#include <Base/FileInfo.h>
- #include <QMainWindow>
- 
- #include <QSocketNotifier>
- 
- #include <spnav.h>
- 
--namespace {
--class RedirectStdErr
--{
--public:
--    RedirectStdErr()
--        : fi(Base::FileInfo::getTempFileName())
--        , file(stderr)
--    {
--        stderr = fopen(fi.filePath().c_str(), "w");
--    }
--    ~RedirectStdErr()
--    {
--        fclose(stderr);
--        fi.deleteFile();
--        stderr = file;
--    }
--
--private:
--    Base::FileInfo fi;
--    FILE* file;
--};
--}
--
- Gui::GuiNativeEvent::GuiNativeEvent(Gui::GUIApplicationNativeEventAware *app)
- : GuiAbstractNativeEvent(app)
- {
-@@ -72,8 +47,6 @@ Gui::GuiNativeEvent::~GuiNativeEvent()
- 
- void Gui::GuiNativeEvent::initSpaceball(QMainWindow *window)
- {
--    // tmp. redirect stderr to a file to suppress an error message from spnav_open()
--    RedirectStdErr err;
-     Q_UNUSED(window)
-     if (spnav_open() == -1) {
-         Base::Console().Log("Couldn't connect to spacenav daemon. Please ignore if you don't have a spacemouse.\n");
diff --git a/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch b/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch
deleted file mode 100644
index d4acf370ca0a42..00000000000000
--- a/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-From fe02d63c8c9b1280978be841d04e68a0a55cceb9 Mon Sep 17 00:00:00 2001
-From: Roy-043 <70520633+Roy-043@users.noreply.github.com>
-Date: Thu, 29 Dec 2022 23:20:38 +0100
-Subject: [PATCH] Draft: update inspect.getargspec to inspect.getfullargspec
- (#8101)
-
----
- src/Mod/Draft/draftguitools/gui_snapper.py | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
---- a/src/Mod/Draft/draftguitools/gui_snapper.py
-+++ b/src/Mod/Draft/draftguitools/gui_snapper.py
-@@ -1426,7 +1426,7 @@ class Snapper:
-             Gui.Snapper.off()
-             self.ui.offUi()
-             if callback:
--                if len(inspect.getargspec(callback).args) > 1:
-+                if len(inspect.getfullargspec(callback).args) > 1:
-                     obj = None
-                     if self.snapInfo and ("Object" in self.snapInfo) and self.snapInfo["Object"]:
-                         obj = App.ActiveDocument.getObject(self.snapInfo["Object"])
-@@ -1445,7 +1445,7 @@ class Snapper:
-             Gui.Snapper.off()
-             self.ui.offUi()
-             if callback:
--                if len(inspect.getargspec(callback).args) > 1:
-+                if len(inspect.getfullargspec(callback).args) > 1:
-                     callback(None, None)
-                 else:
-                     callback(None)
diff --git a/srcpkgs/freecad/template b/srcpkgs/freecad/template
index c135701e38b9ad..7d5165f760bab9 100644
--- a/srcpkgs/freecad/template
+++ b/srcpkgs/freecad/template
@@ -1,7 +1,7 @@
 # Template file for 'freecad'
 pkgname=freecad
-version=0.20.2
-revision=7
+version=0.21.1
+revision=2
 build_wrksrc="FreeCAD-${version}"
 build_style=cmake
 pycompile_dirs="usr/lib/${pkgname}/Mod"
@@ -24,8 +24,10 @@ makedepends="python3-devel boost-devel libxerces-c-devel zlib-devel occt-devel
  coin3-devel libshiboken2-devel libspnav-devel pyside2-tools
  liblz4-devel libpyside2-python3-devel python3-matplotlib netcdf-devel
  jsoncpp-devel qt5-devel qt5-svg-devel qt5-tools-devel qt5-webkit-devel
- qt5-xmlpatterns-devel coin3-doc glew-devel python3-pivy"
-depends="python3-matplotlib python3-pyside2-webengine python3-pivy"
+ qt5-xmlpatterns-devel coin3-doc glew-devel python3-pivy qt5-webengine-devel
+ qt5-declarative-devel qt5-webchannel-devel qt5-location-devel"
+depends="python3-matplotlib python3-pyside2-webengine python3-pivy
+ python3-GitPython python3-Markdown"
 short_desc="General purpose 3D CAD modeler"
 maintainer="yopito <pierre.bourgin@free.fr>"
 license="LGPL-2.0-or-later"
@@ -35,7 +37,7 @@ distfiles="
  https://github.com/FreeCAD/FreeCAD/archive/${version}.tar.gz
  ${SOURCEFORGE_SITE}/cxx/pycxx-${_pycxxver}.tar.gz
 "
-checksum="46922f3a477e742e1a89cd5346692d63aebb2b67af887b3e463e094a4ae055da
+checksum="e9b1fd0323f101268c7f3be52db42e4a29222f2e306ae6c4a6fc309cb418d35a
  4b91e1e1141c23fbd5039df635c4bb6e75632168548f56b83ce177193c0c98c6"
 python_version=3
 patch_args="-Np1 -d ${build_wrksrc}"

From 3499f78f1dc0984435b52a9bcf2242f52e6f6d0e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:47:18 -0400
Subject: [PATCH 088/110] libopenshot: revbump for ffmpeg6

---
 srcpkgs/libopenshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenshot/template b/srcpkgs/libopenshot/template
index 8e57c5f592169c..7a8f4520e78925 100644
--- a/srcpkgs/libopenshot/template
+++ b/srcpkgs/libopenshot/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenshot'
 pkgname=libopenshot
 version=0.3.0
-revision=3
+revision=4
 build_style=cmake
 # Builds fail with Ruby-2.4.1
 configure_args="-DENABLE_RUBY=OFF -DUSE_SYSTEM_JSONCPP=ON"

From 91e1df1efa30e9eac470252803ff40af7333dd5a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:10:30 -0500
Subject: [PATCH 089/110] openimageio: revbump for ffmpeg6

---
 srcpkgs/openimageio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimageio/template b/srcpkgs/openimageio/template
index 27d2131bc0a61a..61f44b43f9083e 100644
--- a/srcpkgs/openimageio/template
+++ b/srcpkgs/openimageio/template
@@ -1,7 +1,7 @@
 # Template file for 'openimageio'
 pkgname=openimageio
 version=2.4.9.0
-revision=8
+revision=9
 build_style=cmake
 build_helper=qemu
 configure_args="-DUSE_QT=0 -DUSE_PYTHON=0 -DOIIO_BUILD_TESTS=0

From 000cbb95ec4d674aaf21fd7efdc928539f99cf07 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:11:57 -0500
Subject: [PATCH 090/110] synfigstudio: revbump for ffmpeg6

---
 srcpkgs/synfigstudio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/synfigstudio/template b/srcpkgs/synfigstudio/template
index 09e442da9a6805..2bc017cedca6b8 100644
--- a/srcpkgs/synfigstudio/template
+++ b/srcpkgs/synfigstudio/template
@@ -2,7 +2,7 @@
 # Should be kept in sync with 'synfig' and 'ETL'
 pkgname=synfigstudio
 version=1.4.4
-revision=4
+revision=5
 build_style=gnu-configure
 configure_args="--disable-update-mimedb"
 hostmakedepends="pkg-config intltool gettext synfig"

From 5c88f1e240c359f0137afa45fe0d10771f73b2c3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:10 -0500
Subject: [PATCH 091/110] mixxx: revbump for ffmpeg6

---
 srcpkgs/mixxx/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mixxx/template b/srcpkgs/mixxx/template
index 6a79b328c1abf0..9a5141856860b9 100644
--- a/srcpkgs/mixxx/template
+++ b/srcpkgs/mixxx/template
@@ -1,7 +1,7 @@
 # Template file for 'mixxx'
 pkgname=mixxx
 version=2.3.3
-revision=7
+revision=8
 build_style=cmake
 configure_args="-DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="extra-cmake-modules pkg-config protobuf qt5-host-tools qt5-qmake"

From 9ab020b345f9598625a2fb919f38f55b675c4441 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:28 -0500
Subject: [PATCH 092/110] musikcube: revbump for ffmpeg6

---
 srcpkgs/musikcube/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/musikcube/template b/srcpkgs/musikcube/template
index 8c4a51840859ec..fb60dd2049089a 100644
--- a/srcpkgs/musikcube/template
+++ b/srcpkgs/musikcube/template
@@ -1,7 +1,7 @@
 # Template file for 'musikcube'
 pkgname=musikcube
 version=3.0.0
-revision=3
+revision=4
 build_style=cmake
 make_cmd=make
 configure_args="-DNO_NCURSESW=1"

From e7a19626f201659d3c436c25c0e8936779597baa Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:45 -0500
Subject: [PATCH 093/110] electron24: revbump for ffmpeg6

---
 srcpkgs/electron24/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron24/template b/srcpkgs/electron24/template
index 7b4e28812f483e..1ca93fde97a854 100644
--- a/srcpkgs/electron24/template
+++ b/srcpkgs/electron24/template
@@ -1,7 +1,7 @@
 # Template file for 'electron24'
 pkgname=electron24
 version=24.3.0
-revision=2
+revision=3
 _nodever=18.14.0
 _chromiumver=112.0.5615.165
 archs="x86_64* aarch64*"

From a73b62ac3f12c7792b6d8b593d8e985d53ffd398 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:00 -0500
Subject: [PATCH 094/110] electron19: revbump for ffmpeg6

---
 srcpkgs/electron19/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron19/template b/srcpkgs/electron19/template
index 0ef959125cb085..5371c0b354604f 100644
--- a/srcpkgs/electron19/template
+++ b/srcpkgs/electron19/template
@@ -1,7 +1,7 @@
 # Template file for 'electron19'
 pkgname=electron19
 version=19.0.8
-revision=4
+revision=5
 _nodever=16.14.2
 _chromiumver=102.0.5005.125
 archs="x86_64* aarch64* ppc64le*"

From 9910466240b5df4e662c0a50f7dd16db6dae3e4a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:13 -0500
Subject: [PATCH 095/110] wf-recorder: revbump for ffmpeg6

---
 srcpkgs/wf-recorder/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/wf-recorder/template b/srcpkgs/wf-recorder/template
index 08f986b0310067..63c45cf4b814d7 100644
--- a/srcpkgs/wf-recorder/template
+++ b/srcpkgs/wf-recorder/template
@@ -1,7 +1,7 @@
 # Template file for 'wf-recorder'
 pkgname=wf-recorder
 version=0.4.1
-revision=2
+revision=3
 build_style=meson
 hostmakedepends="pkg-config scdoc wayland-devel"
 makedepends="wayland-protocols wayland-devel ffmpeg-devel libgbm-devel x264-devel

From dc39742a04b1308a34af10547626c618b8a80867 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:26 -0500
Subject: [PATCH 096/110] obs: revbump for ffmpeg6

---
 srcpkgs/obs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/obs/template b/srcpkgs/obs/template
index b343f1131bfcf6..a25a67433e285e 100644
--- a/srcpkgs/obs/template
+++ b/srcpkgs/obs/template
@@ -1,7 +1,7 @@
 # Template file for 'obs'
 pkgname=obs
 version=30.0.0
-revision=2
+revision=3
 archs="i686* x86_64* ppc64le* aarch64* riscv64*"
 build_style=cmake
 configure_args="-DOBS_VERSION_OVERRIDE=${version} -DENABLE_JACK=ON

From af884e440f9adcfd8e8622608aed407e214db1d5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:36 -0500
Subject: [PATCH 097/110] mlt7: revbump for ffmpeg6

---
 srcpkgs/mlt7/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mlt7/template b/srcpkgs/mlt7/template
index 98f302ad3a5167..7eb8c00fa1580c 100644
--- a/srcpkgs/mlt7/template
+++ b/srcpkgs/mlt7/template
@@ -1,7 +1,7 @@
 # Template file for 'mlt7'
 pkgname=mlt7
 version=7.20.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DSWIG_PYTHON=ON -DMOD_QT6=ON"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which

From df2738e54d37dd0c57efcfd796f9d8481eceae8f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:48 -0500
Subject: [PATCH 098/110] qt6-multimedia: revbump for ffmpeg6

---
 srcpkgs/qt6-multimedia/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-multimedia/template b/srcpkgs/qt6-multimedia/template
index 67a577e1300fea..1da626ecf515a8 100644
--- a/srcpkgs/qt6-multimedia/template
+++ b/srcpkgs/qt6-multimedia/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-multimedia'
 pkgname=qt6-multimedia
 version=6.6.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DQT_FEATURE_gstreamer=ON"
 hostmakedepends="perl qt6-declarative-host-tools pkg-config qt6-shadertools"

From 30003623e32b20671f003461ea1c1854d0ff095e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:00:15 -0500
Subject: [PATCH 099/110] baresip: revbump for ffmpeg6

---
 srcpkgs/baresip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/baresip/template b/srcpkgs/baresip/template
index 12c8954ef7b9b7..b16b67beab8d2b 100644
--- a/srcpkgs/baresip/template
+++ b/srcpkgs/baresip/template
@@ -1,7 +1,7 @@
 # Template file for 'baresip'
 pkgname=baresip
 version=3.6.0
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config glib-devel"
 makedepends="libgsm-devel libpng-devel openssl-devel libsndfile-devel

From 063c12e8a1dff1859959d224c98c6f4f43921b76 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:30 -0500
Subject: [PATCH 100/110] QMPlay2: revbump for ffmpeg6

---
 srcpkgs/QMPlay2/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/QMPlay2/template b/srcpkgs/QMPlay2/template
index 46c80f64a13497..942258ce60fb7e 100644
--- a/srcpkgs/QMPlay2/template
+++ b/srcpkgs/QMPlay2/template
@@ -1,7 +1,7 @@
 # Template file for 'QMPlay2'
 pkgname=QMPlay2
 version=23.10.22
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools"
 makedepends="alsa-lib-devel ffmpeg-devel libass-devel libcdio-devel libgme-devel

From b829e403bd658e4e34d0cebbc8a82fbed7e7ab2d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:34 -0500
Subject: [PATCH 101/110] alsa-plugins: revbump for ffmpeg6

---
 srcpkgs/alsa-plugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/alsa-plugins/template b/srcpkgs/alsa-plugins/template
index a5708a7d82a8f0..7bfdad046c4830 100644
--- a/srcpkgs/alsa-plugins/template
+++ b/srcpkgs/alsa-plugins/template
@@ -1,7 +1,7 @@
 # Template file for 'alsa-plugins'
 pkgname=alsa-plugins
 version=1.2.7.1
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--disable-maemo-plugin"
 hostmakedepends="pkg-config"

From e95de93ea58eebf0f2515e7b8623a4b5683b8d44 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:43 -0500
Subject: [PATCH 102/110] minidlna: revbump for ffmpeg6

---
 srcpkgs/minidlna/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/minidlna/template b/srcpkgs/minidlna/template
index 5fa929f3a0c124..742991ecd04afc 100644
--- a/srcpkgs/minidlna/template
+++ b/srcpkgs/minidlna/template
@@ -1,7 +1,7 @@
 # Template file for 'minidlna'
 pkgname=minidlna
 version=1.3.3
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="
  --sbindir=/usr/bin

From c2fe938e44319a9b899932812721e3cd089ba708 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 17:57:47 -0500
Subject: [PATCH 103/110] mpv: revbump for ffmpeg6

---
 srcpkgs/mpv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpv/template b/srcpkgs/mpv/template
index 3d4349e27d8f62..bc40d6fcaa40d6 100644
--- a/srcpkgs/mpv/template
+++ b/srcpkgs/mpv/template
@@ -1,7 +1,7 @@
 # Template file for 'mpv'
 pkgname=mpv
 version=0.37.0
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcdda=enabled -Ddvbin=enabled -Ddvdnav=enabled
  -Dlibmpv=true -Dcplugins=enabled

From d364269c86a5abbbb354264592228f3338a3700b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 17:59:29 -0500
Subject: [PATCH 104/110] qimgv: revbump for ffmpeg6

---
 srcpkgs/qimgv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qimgv/template b/srcpkgs/qimgv/template
index dd341dfe1bfce8..8a7e1c081ef12f 100644
--- a/srcpkgs/qimgv/template
+++ b/srcpkgs/qimgv/template
@@ -1,7 +1,7 @@
 # Template file for 'qimgv'
 pkgname=qimgv
 version=1.0.2
-revision=3
+revision=4
 build_style=cmake
 configure_args="$(vopt_if video -DVIDEO_SUPPORT=ON -DVIDEO_SUPPORT=OFF)
  $(vopt_if scale -DOPENCV_SUPPORT=ON -DOPENCV_SUPPORT=OFF)

From 7fe8cd5ed16fe0e40fe13b6212526808c06a5add Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 18:00:36 -0500
Subject: [PATCH 105/110] kfilemetadata5: revbump for ffmpeg6

---
 srcpkgs/kfilemetadata5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kfilemetadata5/template b/srcpkgs/kfilemetadata5/template
index a0c4d809395323..b584f85ff2058b 100644
--- a/srcpkgs/kfilemetadata5/template
+++ b/srcpkgs/kfilemetadata5/template
@@ -1,7 +1,7 @@
 # Template file for 'kfilemetadata5'
 pkgname=kfilemetadata5
 version=5.115.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="kcoreaddons extra-cmake-modules pkg-config qt5-host-tools qt5-qmake
  gettext kcoreaddons python3"

From 48ae140769887597f1c60e4ce14dc1f70b301afd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 8 Dec 2023 11:46:01 -0500
Subject: [PATCH 106/110] vba-m: revbump for ffmpeg6

---
 srcpkgs/vba-m/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vba-m/template b/srcpkgs/vba-m/template
index 3d135efa1d0b69..3c5a20db0fa984 100644
--- a/srcpkgs/vba-m/template
+++ b/srcpkgs/vba-m/template
@@ -2,7 +2,7 @@
 pkgname=vba-m
 reverts=1292_2
 version=2.1.9
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_GTK=TRUE -DENABLE_FFMPEG=TRUE -DENABLE_LINK=TRUE -DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="gettext pkg-config unzip zip yasm wxWidgets-gtk3-devel"

From a49a0320a3aa36609a4d0693782c54cb1fa3d79a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 8 Dec 2023 11:46:19 -0500
Subject: [PATCH 107/110] dolphin-emu: revbump for ffmpeg6

---
 srcpkgs/dolphin-emu/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/dolphin-emu/template b/srcpkgs/dolphin-emu/template
index 862d3ae964eec4..a7ae0efb58fb75 100644
--- a/srcpkgs/dolphin-emu/template
+++ b/srcpkgs/dolphin-emu/template
@@ -1,7 +1,7 @@
 # Template file for 'dolphin-emu'
 pkgname=dolphin-emu
 version=5.0.19368
-revision=3
+revision=4
 _dolphin_commit=dadbeb4bae7e7fa23af2b46e0add4143094dc107
 _mgba_commit=44e074a15e9651481f7f652ac006a7c9d58cbeb9
 _googletest_commit=be03d00f5f0cc3a997d1a368bee8a1fe93651f48

From cba63e386fcc007be165f9d8972e3b6b3a7fecb0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 19 Dec 2023 15:38:51 -0500
Subject: [PATCH 108/110] qtox: revbump for ffmpeg4

---
 srcpkgs/qtox/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtox/template b/srcpkgs/qtox/template
index bb70e7f51240a4..755e4462bc0137 100644
--- a/srcpkgs/qtox/template
+++ b/srcpkgs/qtox/template
@@ -1,13 +1,13 @@
 # Template file for 'qtox'
 pkgname=qtox
 version=1.17.6
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DUPDATE_CHECK=OFF
  -DGIT_DESCRIBE=${version}
  $(vopt_if snorenotify -DDESKTOP_NOTIFICATIONS=ON)"
 hostmakedepends="pkg-config qt5-host-tools qt5-devel"
-makedepends="ffmpeg-devel libexif-devel libopenal-devel libsodium-devel
+makedepends="ffmpeg4-devel libexif-devel libopenal-devel libsodium-devel
  libvpx-devel opus-devel qrencode-devel qt5-svg-devel sonnet-devel
  sqlcipher-devel toxcore-devel
  $(vopt_if snorenotify snorenotify-devel)"

From 300e581ed88afbadf926266b30edb51178e298e1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 11 Jan 2024 11:52:00 -0500
Subject: [PATCH 109/110] arcan: revbump for ffmpeg6

---
 srcpkgs/arcan/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/arcan/template b/srcpkgs/arcan/template
index ff9091f90ebb10..030091a6cc9d0c 100644
--- a/srcpkgs/arcan/template
+++ b/srcpkgs/arcan/template
@@ -2,7 +2,7 @@
 # !! keep synced with: acfgfs aclip aloadimage
 pkgname=arcan
 version=0.6.2.1
-revision=2
+revision=3
 create_wrksrc=yes
 build_wrksrc=arcan/src
 build_style=cmake

From a09b45aa7c400bfc359872c224c6613bc345374f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 11 Jan 2024 11:52:10 -0500
Subject: [PATCH 110/110] notcurses: revbump for ffmpeg6

---
 srcpkgs/notcurses/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/notcurses/template b/srcpkgs/notcurses/template
index 48a7463cb68eb9..515f316ab4576c 100644
--- a/srcpkgs/notcurses/template
+++ b/srcpkgs/notcurses/template
@@ -1,7 +1,7 @@
 # Template file for 'notcurses'
 pkgname=notcurses
 version=3.0.9
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DUSE_STATIC=ON -DUSE_QRCODEGEN=On $(vopt_bool man USE_PANDOC)"
 hostmakedepends="pkg-config $(vopt_if man pandoc)"

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (84 preceding siblings ...)
  2024-03-01 15:58 ` [PR PATCH] [Updated] " zlice
@ 2024-03-06 21:24 ` zlice
  2024-03-09 22:24 ` yoshiyoshyosh
                   ` (11 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2024-03-06 21:24 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 4903 bytes --]

There is an updated pull request by zlice against master on the void-packages repository

https://github.com/zlice/void-packages ffmpeg6-split
https://github.com/void-linux/void-packages/pull/43761

ffmpeg6 split
[ci skip]


#### Testing the changes

- I tested the changes in this PR: **YES**

main testing has been vaapi in Firefox Nightly and enc/dec in Shotcut on Intel A770

#### New package

- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**

#### Local build testing

- I built this PR locally for my native architecture, **x86_64**

#### Discussion

Continuation of https://github.com/void-linux/void-packages/pull/36315

`libavresample` is deprecated, but marked as a dependency when trying to build other packages and install `ffmpeg`(6). I think the right way to handle this is make a meta package and the add to removals?


##### Commit naming / misc

~~Commits are 'dirty' right now, running with [gstreamer 1.22.1 updates](https://github.com/void-linux/void-packages/pull/42861) and [Intel OpenCL](https://github.com/void-linux/void-packages/pull/43084). This will also make [intel packages pr](https://github.com/void-linux/void-packages/pull/41132) obsolete.~~ (see Requirements below)

Maintainer for previous ffmpeg(4) was orphaned, I can put my name in there if that matters, though I don't exactly see myself keeping up on ffmpeg.

~~This updates QT5 which looks like it is usually hosted by Johnny. Not sure if there's any reason to stay there or these sources are fine.~~ Using qt5.15.11 now, revbumps and some patches.

##### STILL FFMPEG4

These are a mix of emulators, games and/or older packages.

- ~~attract~~ (2.7 builds)
- ~~audacity (https://github.com/audacity/audacity/issues/2305 and https://sourceforge.net/p/portmedia/wiki/portsmf/ is 'beta')~~ (updated to 3.x, compiles with ffmpeg6)
- ~~ccextractor~~ (master patches)
- vice (3.8 compiles, needs makedepends libcurl-devel)
- kodi
- mlt (only dep left is flowblade - flowblade 2.12.0.2 with mlt7-python3 can 'render' videos with cpu and gpu - https://github.com/void-linux/void-packages/pull/47195)
- ~~synfig (mlt)~~ (work with mlt7, bump synfigstudio)
- tvheadend (download page recommends using 4.3 which compiles fine, 4.4 eta is Q1 2024)
- ~~ssr~~ (patches)
- ~~spek-alternative~~ (replace with spek-x)
- ~~ppsspp~~ ~~(1.17.1 is out, but there's 5+ distfiles that are all git commits)~~ (minor patch)
- olive (has been in alpha since 2020, seems they do nightly builds and appimages)
- moc
- mediastreamer (linphone links are dead, changed to github belladonne. their stuff never worked for me but there are updates if someone wants to give it a try)
- libextractor (1.13 compiles, remove exiv2 patch)
- idjc (0.9.8 compiles, remove python3.10 patch, needs makedepends libebur128-devel and libshout-idjc 2.4.6 with '-r1' for distfile)
- hedgewars
- ~~ffmpegthumbnailer~~ (patches for moviedecoder.xxx files)
- ~~ffmpegthumbs~~ (latest compiles)
- deadbeef (1.9.6 may work but requires libdispatch from apple)
- ~~omxplayer~~ (package removed, deprecated in favor of vlc)
- qtav (fork has ffmpeg 5 patch - https://github.com/cmguo/QtAV)
- `vlc` (vlc4 will support ffmpeg5, there's a patch to build 3.x with ffmpeg5 but it will lack vaapi)
- `osg` (OpenSceneGraph plus `xine-lib`)


##### HAVE NOT BUILT YET

- ~~omxplayer (rpi only? ffmpeg4)~~ (removed)
- kodi (big, but ffmpeg4)


##### UPDATED (for ffmpeg6)

- ~~blender: update to 3.5.1~~ ~~will be revbump with~~ https://github.com/void-linux/void-packages/pull/43992
- unpaper: update to 7.0.0.
- guvcview: update to 2.0.8.
- ~~qt5: update to 5.15.8~~ updated by another PR to 5.15.11
- ~~qt5-webengine: update to 5.18.15~~ updated by another PR to 5.15.16 (some patching for ffmpeg build)
- ~~shiboken2: revbump for qt5.15.8 (patch)~~ updated by another PR to 5.15.10
- ~~python3-pyside2: update to 5.15.8 (patch)~~ updated by another PR to 5.15.10
- New package: spex-x replaces spek-alternative for ffmpeg-6.0


##### Requirements

- ~~[gstreamer 1.22.2](https://github.com/void-linux/void-packages/pull/42861)~~ - a few packages use ffmpeg-devel and require a revbump

- ~~[Intel Packages](https://github.com/void-linux/void-packages/pull/41132) [Intel Packages v2](https://github.com/void-linux/void-packages/pull/47330) - ffmpeg4 uses different libraries than 6 (libmfx / Intel-MediaSDK vs only oneVPL that Intel is moving to), both are included here~~. Using replacement oneVPL from OBS update.

- ~~[shotcut 23.05.14](https://github.com/void-linux/void-packages/pull/44260)~~

- https://github.com/void-linux/void-packages/pull/44781 will remove from this PR

A patch file from https://github.com/void-linux/void-packages/pull/43761.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ffmpeg6-split-43761.patch --]
[-- Type: text/x-diff, Size: 241076 bytes --]

From 0144d44d06a0353f5c83a0e72b742b6ab09528b6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:16:56 -0400
Subject: [PATCH 001/110] ffmpeg: update to 6.0.1.

---
 common/shlibs                                 | 26 ++++---
 srcpkgs/ffmpeg/files/altivec.patch            | 60 ---------------
 .../patches/armv5tel-floating-point.patch     | 18 -----
 srcpkgs/ffmpeg/patches/binutils-2.41.patch    | 73 -------------------
 ...h-libavcodec-libsvtav1-ten_bit_format.diff | 40 ----------
 .../workaround-mesa-readeon-vaapi-bug.patch   | 28 -------
 srcpkgs/ffmpeg/template                       | 40 +++++-----
 7 files changed, 37 insertions(+), 248 deletions(-)
 delete mode 100644 srcpkgs/ffmpeg/files/altivec.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/binutils-2.41.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 delete mode 100644 srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch

diff --git a/common/shlibs b/common/shlibs
index 5a317bb15d4a41..4baee3efcb02c1 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -389,15 +389,23 @@ libid3tag.so.0 libid3tag-0.15.1b_1
 libgif.so.7 giflib-5.1.0_1
 libImlib2.so.1 imlib2-1.4.2_1
 libmp3lame.so.0 lame-3.98.2_1
-libavdevice.so.58 libavdevice-4.0_1
-libavformat.so.58 libavformat-4.0_1
-libswscale.so.5 libswscale-4.0_1
-libswresample.so.3 libswresample-4.0_1
-libavresample.so.4 libavresample-4.0_1
-libpostproc.so.55 libpostproc-4.0_1
-libavcodec.so.58 libavcodec-4.0_1
-libavutil.so.56 libavutil-4.0_1
-libavfilter.so.7 libavfilter-4.0_1
+libavdevice.so.60 libavdevice-6.0_1
+libavformat.so.60 libavformat-6.0_1
+libswscale.so.7 libswscale-6.0_1
+libswresample.so.4 libswresample-6.0_1
+libpostproc.so.57 libpostproc-6.0_1
+libavcodec.so.60 libavcodec-6.0_1
+libavutil.so.58 libavutil-6.0_1
+libavfilter.so.9 libavfilter-6.0_1
+libavdevice.so.58 libavdevice4-4.0_1
+libavformat.so.58 libavformat4-4.0_1
+libswscale.so.5 libswscale4-4.0_1
+libswresample.so.3 libswresample4-4.0_1
+libavresample.so.4 libavresample4-4.0_1
+libpostproc.so.55 libpostproc4-4.0_1
+libavcodec.so.58 libavcodec4-4.0_1
+libavutil.so.56 libavutil4-4.0_1
+libavfilter.so.7 libavfilter4-4.0_1
 libSDL-1.2.so.0 SDL-1.2.14_1
 libSDL_image-1.2.so.0 SDL_image-1.2.10_1
 libx264.so.157 x264-20190507.2245_1
diff --git a/srcpkgs/ffmpeg/files/altivec.patch b/srcpkgs/ffmpeg/files/altivec.patch
deleted file mode 100644
index 9c57200463320e..00000000000000
--- a/srcpkgs/ffmpeg/files/altivec.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-revert some altivec specific change on all ppc* except ppc64le*
-
-q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
-conditionally, for ppc* but not ppc64le* (the new code is valid for
-POWER8 VSX which LE targets as a baseline but not BE)"
-
-
-This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
----
- libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
- 1 file changed, 20 insertions(+), 4 deletions(-)
-
-diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
-index 536545293d..c1e2852adb 100644
---- a/libswscale/ppc/yuv2rgb_altivec.c
-+++ b/libswscale/ppc/yuv2rgb_altivec.c
-@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-     vector signed short R1, G1, B1;                                           \
-     vector unsigned char R, G, B;                                             \
-                                                                               \
-+    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
-+    vector unsigned char align_perm;                                          \
-+                                                                              \
-     vector signed short lCY       = c->CY;                                    \
-     vector signed short lOY       = c->OY;                                    \
-     vector signed short lCRV      = c->CRV;                                   \
-@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
-                                                                               \
-         for (j = 0; j < w / 16; j++) {                                        \
--            y0 = vec_xl(0, y1i);                                              \
-+            y1ivP = (const vector unsigned char *) y1i;                       \
-+            y2ivP = (const vector unsigned char *) y2i;                       \
-+            uivP  = (const vector unsigned char *) ui;                        \
-+            vivP  = (const vector unsigned char *) vi;                        \
-+                                                                              \
-+            align_perm = vec_lvsl(0, y1i);                                    \
-+            y0 = (vector unsigned char)                                       \
-+                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
-                                                                               \
--            y1 = vec_xl(0, y2i);                                              \
-+            align_perm = vec_lvsl(0, y2i);                                    \
-+            y1 = (vector unsigned char)                                       \
-+                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
-                                                                               \
--            u = (vector signed char) vec_xl(0, ui);                           \
-+            align_perm = vec_lvsl(0, ui);                                     \
-+            u = (vector signed char)                                          \
-+                    vec_perm(uivP[0], uivP[1], align_perm);                   \
-                                                                               \
--            v = (vector signed char) vec_xl(0, vi);                           \
-+            align_perm = vec_lvsl(0, vi);                                     \
-+            v = (vector signed char)                                          \
-+                    vec_perm(vivP[0], vivP[1], align_perm);                   \
-                                                                               \
-             u = (vector signed char)                                          \
-                     vec_sub(u,                                                \
--- 
-2.27.0
-
diff --git a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
deleted file mode 100644
index 9a55178c74f0fd..00000000000000
--- a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
-+++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
-@@ -39,6 +39,15 @@
- #endif
- #include <fenv.h>
- 
-+#if (FE_ALL_EXCEPT == 0)
-+/* E.g. ARM soft float does not define these */
-+#define FE_INVALID    0
-+#define FE_DIVBYZERO  0
-+#define FE_OVERFLOW   0
-+#define FE_UNDERFLOW  0
-+#define FE_INEXACT    0
-+#endif
-+
- #if CONFIG_LIBFONTCONFIG
- #include <fontconfig/fontconfig.h>
- #endif
diff --git a/srcpkgs/ffmpeg/patches/binutils-2.41.patch b/srcpkgs/ffmpeg/patches/binutils-2.41.patch
deleted file mode 100644
index 53a596d0ee7d4e..00000000000000
--- a/srcpkgs/ffmpeg/patches/binutils-2.41.patch
+++ /dev/null
@@ -1,73 +0,0 @@
-From effadce6c756247ea8bae32dc13bb3e6f464f0eb Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= <remi@remlab.net>
-Date: Sun, 16 Jul 2023 18:18:02 +0300
-Subject: [PATCH] avcodec/x86/mathops: clip constants used with shift
- instructions within inline assembly
-
-Fixes assembling with binutil as >= 2.41
-
-Signed-off-by: James Almer <jamrial@gmail.com>
----
- libavcodec/x86/mathops.h | 26 +++++++++++++++++++++++---
- 1 file changed, 23 insertions(+), 3 deletions(-)
-
-diff --git a/libavcodec/x86/mathops.h b/libavcodec/x86/mathops.h
-index 6298f5ed1983b..ca7e2dffc1076 100644
---- a/libavcodec/x86/mathops.h
-+++ b/libavcodec/x86/mathops.h
-@@ -35,12 +35,20 @@
- static av_always_inline av_const int MULL(int a, int b, unsigned shift)
- {
-     int rt, dummy;
-+    if (__builtin_constant_p(shift))
-     __asm__ (
-         "imull %3               \n\t"
-         "shrdl %4, %%edx, %%eax \n\t"
-         :"=a"(rt), "=d"(dummy)
--        :"a"(a), "rm"(b), "ci"((uint8_t)shift)
-+        :"a"(a), "rm"(b), "i"(shift & 0x1F)
-     );
-+    else
-+        __asm__ (
-+            "imull %3               \n\t"
-+            "shrdl %4, %%edx, %%eax \n\t"
-+            :"=a"(rt), "=d"(dummy)
-+            :"a"(a), "rm"(b), "c"((uint8_t)shift)
-+        );
-     return rt;
- }
- 
-@@ -113,19 +121,31 @@ __asm__ volatile(\
- // avoid +32 for shift optimization (gcc should do that ...)
- #define NEG_SSR32 NEG_SSR32
- static inline  int32_t NEG_SSR32( int32_t a, int8_t s){
-+    if (__builtin_constant_p(s))
-     __asm__ ("sarl %1, %0\n\t"
-          : "+r" (a)
--         : "ic" ((uint8_t)(-s))
-+         : "i" (-s & 0x1F)
-     );
-+    else
-+        __asm__ ("sarl %1, %0\n\t"
-+               : "+r" (a)
-+               : "c" ((uint8_t)(-s))
-+        );
-     return a;
- }
- 
- #define NEG_USR32 NEG_USR32
- static inline uint32_t NEG_USR32(uint32_t a, int8_t s){
-+    if (__builtin_constant_p(s))
-     __asm__ ("shrl %1, %0\n\t"
-          : "+r" (a)
--         : "ic" ((uint8_t)(-s))
-+         : "i" (-s & 0x1F)
-     );
-+    else
-+        __asm__ ("shrl %1, %0\n\t"
-+               : "+r" (a)
-+               : "c" ((uint8_t)(-s))
-+        );
-     return a;
- }
- 
diff --git a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
deleted file mode 100644
index aa948f7a8a2dfb..00000000000000
--- a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
+++ /dev/null
@@ -1,40 +0,0 @@
-#==================================================================================================
-# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
-# From: Christopher Degawa <christopher.degawa@intel.com>
-# Date: Thu, 20 Oct 2022 22:55:27 -0500
-# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
-#
-# compressed_ten_bit_format has been deprecated upstream and has no effect
-# and can be removed. Plus, technically it was never used in the first place
-# since it would require the app (ffmpeg) to set it and do additional
-# processing of the input frames.
-#
-# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
-#
-# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
-#==================================================================================================
---- a/libavcodec/libsvtav1.c
-+++ b/libavcodec/libsvtav1.c
-@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
- 
- static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
- {
--    const int    pack_mode_10bit =
--        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
--    const size_t luma_size_8bit  =
--        config->source_width * config->source_height * (1 << pack_mode_10bit);
--    const size_t luma_size_10bit =
--        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
-+    const size_t luma_size = config->source_width * config->source_height *
-+        (config->encoder_bit_depth > 8 ? 2 : 1);
- 
-     EbSvtIOFormat *in_data;
- 
--    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
-+    svt_enc->raw_size = luma_size * 3 / 2;
- 
-     // allocate buffer for in and out
-     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
--- 
-GitLab
-
diff --git a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
deleted file mode 100644
index 00e3f68a415b84..00000000000000
--- a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
-From: Rainer Hochecker <fernetmenta@online.de>
-Date: Sat, 26 Jan 2019 19:48:35 +0100
-Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
-
-This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
-It was hit frequently when watching h264 channels received via DVB-X.
-Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
----
- libavcodec/vaapi_h264.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
-index 5854587a255..f12fdc457a4 100644
---- a/libavcodec/vaapi_h264.c
-+++ b/libavcodec/vaapi_h264.c
-@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
-     H264SliceContext *sl = &h->slice_ctx[0];
-     int ret;
- 
-+    if (pic->nb_slices == 0) {
-+        ret = AVERROR_INVALIDDATA;
-+        goto finish;
-+    }
-+
-     ret = ff_vaapi_decode_issue(avctx, pic);
-     if (ret < 0)
-         goto finish;
diff --git a/srcpkgs/ffmpeg/template b/srcpkgs/ffmpeg/template
index 1ebb436135938d..f1e4712c41d087 100644
--- a/srcpkgs/ffmpeg/template
+++ b/srcpkgs/ffmpeg/template
@@ -1,15 +1,15 @@
 # Template file for 'ffmpeg'
 # audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
 pkgname=ffmpeg
-version=4.4.4
-revision=6
+version=6.0.1
+revision=1
 short_desc="Decoding, encoding and streaming software"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="https://www.ffmpeg.org"
 changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
 distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
-checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+checksum=9b16b8731d78e596b4be0d720428ca42df642bb2d78342881ff7f5bc29fc9623
 
 hostmakedepends="pkg-config perl"
 makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
@@ -26,12 +26,13 @@ makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-deve
  $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
  $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
  $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
- $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers Vulkan-Tools Vulkan-ValidationLayers')
+ $(vopt_if onevpl 'oneVPL oneVPL-devel')
  $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
 depends="ffplay>=${version}_${revision}"
 
 build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
- dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec onevpl"
 build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
 desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
 desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
@@ -39,9 +40,13 @@ desc_option_sofa="Enable support for AES SOFA"
 desc_option_webp="Enable support for WebP"
 
 case "$XBPS_TARGET_MACHINE" in
-	i686*|x86_64*)
-		hostmakedepends+=" nasm"
+	i686*)
 		build_options_default+=" vaapi vdpau nvenc nvdec"
+		hostmakedepends+=" nasm"
+		;;
+	x86_64*)
+		hostmakedepends+=" nasm"
+		build_options_default+=" vaapi vdpau nvenc nvdec onevpl"
 		;;
 	ppc64*) build_options_default+=" vaapi vdpau";;
 	mips*) CFLAGS="-mnan=legacy";;
@@ -65,8 +70,6 @@ post_patch() {
 		ppc64le*) ;;
 		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
 	esac
-
-	vsed -i libavfilter/vf_libvmaf.c -e 's!/usr/local/share/model/\(vmaf_v0.6.1\).pkl!/usr/share/vmaf/\1.json!'
 }
 
 do_configure() {
@@ -115,18 +118,19 @@ do_configure() {
 		$(vopt_enable x265 libx265) \
 		$(vopt_enable v4l2 libv4l2) \
 		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
-		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		--enable-libbs2b --enable-libvidstab \
 		$(vopt_enable dav1d libdav1d) \
 		$(vopt_enable zimg libzimg) \
 		$(vopt_enable webp libwebp) \
 		$(vopt_enable sofa libmysofa) \
 		$(vopt_enable vulkan) \
+		$(vopt_enable onevpl libvpl) \
 		$(vopt_enable drm libdrm) \
 		$(vopt_enable svtav1 libsvtav1) \
 		$(vopt_enable srt libsrt) \
 		$(vopt_enable rist librist) \
-		$(vopt_if nvenc '--enable-nvenc') \
-		$(vopt_if nvdec '--enable-nvdec')
+		$(vopt_enable nvenc nvenc) \
+		$(vopt_enable nvdec nvdec)
 }
 
 do_build() {
@@ -153,10 +157,8 @@ libavdevice_package() {
 }
 
 libavresample_package() {
-	short_desc="FFmpeg audio resampling library"
-	pkg_install() {
-		vmove "usr/lib/libavresample.so.*"
-	}
+	short_desc="Package deprecated, removal needed"
+	build_style=meta
 }
 
 libavformat_package() {
@@ -210,15 +212,13 @@ ffmpeg-devel_package() {
 		libavfilter>=${version}_${revision}
 		libpostproc>=${version}_${revision}
 		libswscale>=${version}_${revision}
-		libswresample>=${version}_${revision}
-		libavresample>=${version}_${revision}"
+		libswresample>=${version}_${revision}"
 	short_desc+=" - development files"
-
+	conflicts="ffmpeg4-devel"
 	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
 		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
 		nostrip_files="/usr/lib/libavfilter.a"
 	fi
-
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig

From 3dd00a47fb9715fa9dd7d79eec3e2dcc06075e88 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:14 -0400
Subject: [PATCH 002/110] openshot: revbump for ffmpeg6

---
 srcpkgs/openshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openshot/template b/srcpkgs/openshot/template
index 3849858fe963b5..12789bc9867499 100644
--- a/srcpkgs/openshot/template
+++ b/srcpkgs/openshot/template
@@ -1,7 +1,7 @@
 # Template file for 'openshot'
 pkgname=openshot
 version=3.1.1
-revision=1
+revision=2
 build_style=python3-module
 hostmakedepends="python3 python3-setuptools"
 makedepends="ffmpeg-devel python3-PyQt5"

From da102f7d8f8a0617277763249d476548ac812090 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:36 -0400
Subject: [PATCH 003/110] sumo: revbump for ffmpeg6

---
 srcpkgs/sumo/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/sumo/template b/srcpkgs/sumo/template
index a730afa9fafa92..e2def06fa4bd7d 100644
--- a/srcpkgs/sumo/template
+++ b/srcpkgs/sumo/template
@@ -1,7 +1,7 @@
 # Template file for 'sumo'
 pkgname=sumo
 version=1.12.0
-revision=7
+revision=8
 build_style=cmake
 hostmakedepends="libgdal-tools pkg-config swig python3-setuptools"
 makedepends="python3-devel ffmpeg-devel fox-devel gl2ps-devel libgdal-devel

From ce2eac383ab198aeef6841d7520be593a084d128 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:56:22 -0400
Subject: [PATCH 004/110] New package: ffmpeg4-4.4.4.

---
 srcpkgs/ffmpeg4-devel                         |   1 +
 srcpkgs/ffmpeg4/files/altivec.patch           |  60 +++++
 .../patches/armv5tel-floating-point.patch     |  18 ++
 srcpkgs/ffmpeg4/patches/binutils-2.41.patch   |  73 ++++++
 ...h-libavcodec-libsvtav1-ten_bit_format.diff |  40 +++
 .../workaround-mesa-readeon-vaapi-bug.patch   |  28 +++
 srcpkgs/ffmpeg4/template                      | 234 ++++++++++++++++++
 srcpkgs/libavcodec4                           |   1 +
 srcpkgs/libavdevice4                          |   1 +
 srcpkgs/libavfilter4                          |   1 +
 srcpkgs/libavformat4                          |   1 +
 srcpkgs/libavresample4                        |   1 +
 srcpkgs/libavutil4                            |   1 +
 srcpkgs/libpostproc4                          |   1 +
 srcpkgs/libswresample4                        |   1 +
 srcpkgs/libswscale4                           |   1 +
 16 files changed, 463 insertions(+)
 create mode 120000 srcpkgs/ffmpeg4-devel
 create mode 100644 srcpkgs/ffmpeg4/files/altivec.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/binutils-2.41.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 create mode 100644 srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
 create mode 100644 srcpkgs/ffmpeg4/template
 create mode 120000 srcpkgs/libavcodec4
 create mode 120000 srcpkgs/libavdevice4
 create mode 120000 srcpkgs/libavfilter4
 create mode 120000 srcpkgs/libavformat4
 create mode 120000 srcpkgs/libavresample4
 create mode 120000 srcpkgs/libavutil4
 create mode 120000 srcpkgs/libpostproc4
 create mode 120000 srcpkgs/libswresample4
 create mode 120000 srcpkgs/libswscale4

diff --git a/srcpkgs/ffmpeg4-devel b/srcpkgs/ffmpeg4-devel
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/ffmpeg4-devel
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/ffmpeg4/files/altivec.patch b/srcpkgs/ffmpeg4/files/altivec.patch
new file mode 100644
index 00000000000000..9c57200463320e
--- /dev/null
+++ b/srcpkgs/ffmpeg4/files/altivec.patch
@@ -0,0 +1,60 @@
+revert some altivec specific change on all ppc* except ppc64le*
+
+q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
+conditionally, for ppc* but not ppc64le* (the new code is valid for
+POWER8 VSX which LE targets as a baseline but not BE)"
+
+
+This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
+---
+ libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
+ 1 file changed, 20 insertions(+), 4 deletions(-)
+
+diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
+index 536545293d..c1e2852adb 100644
+--- a/libswscale/ppc/yuv2rgb_altivec.c
++++ b/libswscale/ppc/yuv2rgb_altivec.c
+@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+     vector signed short R1, G1, B1;                                           \
+     vector unsigned char R, G, B;                                             \
+                                                                               \
++    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
++    vector unsigned char align_perm;                                          \
++                                                                              \
+     vector signed short lCY       = c->CY;                                    \
+     vector signed short lOY       = c->OY;                                    \
+     vector signed short lCRV      = c->CRV;                                   \
+@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
+                                                                               \
+         for (j = 0; j < w / 16; j++) {                                        \
+-            y0 = vec_xl(0, y1i);                                              \
++            y1ivP = (const vector unsigned char *) y1i;                       \
++            y2ivP = (const vector unsigned char *) y2i;                       \
++            uivP  = (const vector unsigned char *) ui;                        \
++            vivP  = (const vector unsigned char *) vi;                        \
++                                                                              \
++            align_perm = vec_lvsl(0, y1i);                                    \
++            y0 = (vector unsigned char)                                       \
++                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
+                                                                               \
+-            y1 = vec_xl(0, y2i);                                              \
++            align_perm = vec_lvsl(0, y2i);                                    \
++            y1 = (vector unsigned char)                                       \
++                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
+                                                                               \
+-            u = (vector signed char) vec_xl(0, ui);                           \
++            align_perm = vec_lvsl(0, ui);                                     \
++            u = (vector signed char)                                          \
++                    vec_perm(uivP[0], uivP[1], align_perm);                   \
+                                                                               \
+-            v = (vector signed char) vec_xl(0, vi);                           \
++            align_perm = vec_lvsl(0, vi);                                     \
++            v = (vector signed char)                                          \
++                    vec_perm(vivP[0], vivP[1], align_perm);                   \
+                                                                               \
+             u = (vector signed char)                                          \
+                     vec_sub(u,                                                \
+-- 
+2.27.0
+
diff --git a/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
new file mode 100644
index 00000000000000..9a55178c74f0fd
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
@@ -0,0 +1,18 @@
+--- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
++++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
+@@ -39,6 +39,15 @@
+ #endif
+ #include <fenv.h>
+ 
++#if (FE_ALL_EXCEPT == 0)
++/* E.g. ARM soft float does not define these */
++#define FE_INVALID    0
++#define FE_DIVBYZERO  0
++#define FE_OVERFLOW   0
++#define FE_UNDERFLOW  0
++#define FE_INEXACT    0
++#endif
++
+ #if CONFIG_LIBFONTCONFIG
+ #include <fontconfig/fontconfig.h>
+ #endif
diff --git a/srcpkgs/ffmpeg4/patches/binutils-2.41.patch b/srcpkgs/ffmpeg4/patches/binutils-2.41.patch
new file mode 100644
index 00000000000000..53a596d0ee7d4e
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/binutils-2.41.patch
@@ -0,0 +1,73 @@
+From effadce6c756247ea8bae32dc13bb3e6f464f0eb Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= <remi@remlab.net>
+Date: Sun, 16 Jul 2023 18:18:02 +0300
+Subject: [PATCH] avcodec/x86/mathops: clip constants used with shift
+ instructions within inline assembly
+
+Fixes assembling with binutil as >= 2.41
+
+Signed-off-by: James Almer <jamrial@gmail.com>
+---
+ libavcodec/x86/mathops.h | 26 +++++++++++++++++++++++---
+ 1 file changed, 23 insertions(+), 3 deletions(-)
+
+diff --git a/libavcodec/x86/mathops.h b/libavcodec/x86/mathops.h
+index 6298f5ed1983b..ca7e2dffc1076 100644
+--- a/libavcodec/x86/mathops.h
++++ b/libavcodec/x86/mathops.h
+@@ -35,12 +35,20 @@
+ static av_always_inline av_const int MULL(int a, int b, unsigned shift)
+ {
+     int rt, dummy;
++    if (__builtin_constant_p(shift))
+     __asm__ (
+         "imull %3               \n\t"
+         "shrdl %4, %%edx, %%eax \n\t"
+         :"=a"(rt), "=d"(dummy)
+-        :"a"(a), "rm"(b), "ci"((uint8_t)shift)
++        :"a"(a), "rm"(b), "i"(shift & 0x1F)
+     );
++    else
++        __asm__ (
++            "imull %3               \n\t"
++            "shrdl %4, %%edx, %%eax \n\t"
++            :"=a"(rt), "=d"(dummy)
++            :"a"(a), "rm"(b), "c"((uint8_t)shift)
++        );
+     return rt;
+ }
+ 
+@@ -113,19 +121,31 @@ __asm__ volatile(\
+ // avoid +32 for shift optimization (gcc should do that ...)
+ #define NEG_SSR32 NEG_SSR32
+ static inline  int32_t NEG_SSR32( int32_t a, int8_t s){
++    if (__builtin_constant_p(s))
+     __asm__ ("sarl %1, %0\n\t"
+          : "+r" (a)
+-         : "ic" ((uint8_t)(-s))
++         : "i" (-s & 0x1F)
+     );
++    else
++        __asm__ ("sarl %1, %0\n\t"
++               : "+r" (a)
++               : "c" ((uint8_t)(-s))
++        );
+     return a;
+ }
+ 
+ #define NEG_USR32 NEG_USR32
+ static inline uint32_t NEG_USR32(uint32_t a, int8_t s){
++    if (__builtin_constant_p(s))
+     __asm__ ("shrl %1, %0\n\t"
+          : "+r" (a)
+-         : "ic" ((uint8_t)(-s))
++         : "i" (-s & 0x1F)
+     );
++    else
++        __asm__ ("shrl %1, %0\n\t"
++               : "+r" (a)
++               : "c" ((uint8_t)(-s))
++        );
+     return a;
+ }
+ 
diff --git a/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
new file mode 100644
index 00000000000000..aa948f7a8a2dfb
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
@@ -0,0 +1,40 @@
+#==================================================================================================
+# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
+# From: Christopher Degawa <christopher.degawa@intel.com>
+# Date: Thu, 20 Oct 2022 22:55:27 -0500
+# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
+#
+# compressed_ten_bit_format has been deprecated upstream and has no effect
+# and can be removed. Plus, technically it was never used in the first place
+# since it would require the app (ffmpeg) to set it and do additional
+# processing of the input frames.
+#
+# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
+#
+# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
+#==================================================================================================
+--- a/libavcodec/libsvtav1.c
++++ b/libavcodec/libsvtav1.c
+@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
+ 
+ static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
+ {
+-    const int    pack_mode_10bit =
+-        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
+-    const size_t luma_size_8bit  =
+-        config->source_width * config->source_height * (1 << pack_mode_10bit);
+-    const size_t luma_size_10bit =
+-        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
++    const size_t luma_size = config->source_width * config->source_height *
++        (config->encoder_bit_depth > 8 ? 2 : 1);
+ 
+     EbSvtIOFormat *in_data;
+ 
+-    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
++    svt_enc->raw_size = luma_size * 3 / 2;
+ 
+     // allocate buffer for in and out
+     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
+-- 
+GitLab
+
diff --git a/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
new file mode 100644
index 00000000000000..00e3f68a415b84
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
@@ -0,0 +1,28 @@
+From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
+From: Rainer Hochecker <fernetmenta@online.de>
+Date: Sat, 26 Jan 2019 19:48:35 +0100
+Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
+
+This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
+It was hit frequently when watching h264 channels received via DVB-X.
+Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
+---
+ libavcodec/vaapi_h264.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
+index 5854587a255..f12fdc457a4 100644
+--- a/libavcodec/vaapi_h264.c
++++ b/libavcodec/vaapi_h264.c
+@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
+     H264SliceContext *sl = &h->slice_ctx[0];
+     int ret;
+ 
++    if (pic->nb_slices == 0) {
++        ret = AVERROR_INVALIDDATA;
++        goto finish;
++    }
++
+     ret = ff_vaapi_decode_issue(avctx, pic);
+     if (ret < 0)
+         goto finish;
diff --git a/srcpkgs/ffmpeg4/template b/srcpkgs/ffmpeg4/template
new file mode 100644
index 00000000000000..9ba14bdb8ddf32
--- /dev/null
+++ b/srcpkgs/ffmpeg4/template
@@ -0,0 +1,234 @@
+# Template file for 'ffmpeg4'
+# audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
+pkgname=ffmpeg4
+version=4.4.4
+revision=1
+short_desc="Decoding, encoding and streaming software - ffmpeg4 libraries only"
+maintainer="Orphaned <orphan@voidlinux.org>"
+license="GPL-3.0-or-later"
+homepage="https://www.ffmpeg.org"
+changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
+distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
+checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+
+hostmakedepends="pkg-config perl"
+makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
+ libXext-devel libXvMC-devel libxcb-devel lame-devel libtheora-devel
+ libvorbis-devel x264-devel xvidcore-devel jack-devel SDL2-devel
+ libcdio-paranoia-devel librtmp-devel libmodplug-devel gnutls-devel
+ speex-devel celt-devel harfbuzz-devel libass-devel opus-devel ocl-icd-devel
+ libbs2b-devel libvidstab-devel vmaf-devel $(vopt_if pulseaudio pulseaudio-devel)
+ $(vopt_if vaapi libva-devel) $(vopt_if vdpau libvdpau-devel)
+ $(vopt_if x265 x265-devel) $(vopt_if v4l2 v4l-utils-devel)
+ $(vopt_if fdk_aac fdk-aac-devel) $(vopt_if vpx libvpx-devel)
+ $(vopt_if aom libaom-devel) $(vopt_if sndio sndio-devel)
+ $(vopt_if dav1d libdav1d-devel) $(vopt_if zimg zimg-devel)
+ $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
+ $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
+ $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
+
+build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
+
+desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
+desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
+desc_option_sofa="Enable support for AES SOFA"
+desc_option_webp="Enable support for WebP"
+
+case "$XBPS_TARGET_MACHINE" in
+	i686*|x86_64*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau nvenc nvdec"
+			;;
+	ppc64*) build_options_default+=" vaapi vdpau";;
+	mips*) CFLAGS="-mnan=legacy";;
+esac
+
+if [ "$XBPS_TARGET_WORDSIZE" != "32" ]; then
+	build_options_default+=" svtav1"
+fi
+
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+fi
+
+_apply_patch() {
+	local args="$1" pname="$(basename $2)"
+
+	if [ ! -f ".${pname}_done" ]; then
+		patch -N $args -i $2
+		touch .${pname}_done
+	fi
+}
+
+post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64le*) ;;
+		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
+	esac
+
+	vsed -i libavfilter/vf_libvmaf.c -e 's!/usr/local/share/model/\(vmaf_v0.6.1\).pkl!/usr/share/vmaf/\1.json!'
+}
+
+do_configure() {
+	# Fix gcc on x86_64-musl only
+	if [ "$XBPS_TARGET_MACHINE" = "x86_64-musl" ]; then
+		vsed -i configure -e "s;_cflags_speed='-O3';_cflags_speed='-O2';"
+	fi
+
+	if [ "$CROSS_BUILD" ]; then
+		case "$XBPS_TARGET_MACHINE" in
+			arm*) _arch="arm";;
+			aarch64*) _arch="aarch64";;
+			mips*) _arch="mips";;
+			ppc64*) _arch="ppc64";;
+			ppc*) _arch="ppc";;
+			*) _arch="${XBPS_TARGET_MACHINE%%-musl}";;
+		esac
+
+		_args+=" --enable-cross-compile
+			--sysroot=$XBPS_CROSS_BASE
+			--cross-prefix=${XBPS_CROSS_TRIPLET}-
+			--target-os=linux --arch=${_arch}"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc|ppc-musl) _args+=" --disable-altivec";;
+	esac
+
+	if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+		_args+=" --extra-libs=-latomic"
+	fi
+
+	./configure --prefix=/usr --disable-debug --enable-gpl --enable-gnutls \
+		--disable-stripping \
+		--enable-libcdio --enable-version3 --enable-runtime-cpudetect \
+		--enable-libmp3lame --enable-libvorbis --enable-libxvid \
+		--enable-libx264 $(vopt_enable vpx libvpx) --enable-libtheora \
+		--enable-shared --enable-static --enable-libxcb \
+		$(vopt_enable pulseaudio libpulse) --enable-libfreetype --enable-libmodplug \
+		--enable-libspeex --enable-libcelt --enable-libass \
+		--enable-libopus --enable-librtmp --enable-libjack \
+		$(vopt_if fdk_aac '--enable-nonfree --enable-libfdk-aac') \
+		--disable-libopencore_amrnb --disable-libopencore_amrwb \
+		--disable-libopenjpeg \
+		--enable-postproc --enable-opencl ${_args} --enable-libvmaf ${_args} \
+		$(vopt_enable x265 libx265) \
+		$(vopt_enable v4l2 libv4l2) \
+		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
+		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		$(vopt_enable dav1d libdav1d) \
+		$(vopt_enable zimg libzimg) \
+		$(vopt_enable webp libwebp) \
+		$(vopt_enable sofa libmysofa) \
+		$(vopt_enable vulkan) \
+		$(vopt_enable drm libdrm) \
+		$(vopt_enable svtav1 libsvtav1) \
+		$(vopt_enable srt libsrt) \
+		$(vopt_enable rist librist) \
+		$(vopt_if nvenc '--enable-nvenc') \
+		$(vopt_if nvdec '--enable-nvdec')
+}
+
+do_build() {
+	make ${makejobs}
+	make doc/ff{mpeg,play}.1
+}
+
+do_install() {
+	make DESTDIR=${DESTDIR} install install-man
+	rm -rf ${DESTDIR}/usr/bin
+}
+
+libavcodec4_package() {
+	short_desc="FFmpeg codec library"
+	pkg_install() {
+		vmove "usr/lib/libavcodec.so.*"
+	}
+}
+
+libavdevice4_package() {
+	short_desc="FFmpeg device handling library"
+	pkg_install() {
+		vmove "usr/lib/libavdevice.so.*"
+	}
+}
+
+libavresample4_package() {
+	short_desc="FFmpeg audio resampling library"
+	pkg_install() {
+		vmove "usr/lib/libavresample.so.*"
+	}
+}
+
+libavformat4_package() {
+	short_desc="FFmpeg file format library"
+	pkg_install() {
+		vmove "usr/lib/libavformat.so.*"
+	}
+}
+
+libavutil4_package() {
+	short_desc="FFmpeg utility library"
+	pkg_install() {
+		vmove "usr/lib/libavutil.so.*"
+	}
+}
+
+libavfilter4_package() {
+	short_desc="FFmpeg audio/video filter library"
+	pkg_install() {
+		vmove "usr/lib/libavfilter.so.*"
+	}
+}
+
+libpostproc4_package() {
+	short_desc="FFmpeg video postprocessing library"
+	pkg_install() {
+		vmove "usr/lib/libpostproc.so.*"
+	}
+}
+
+libswscale4_package() {
+	short_desc="FFmpeg video scaling library"
+	pkg_install() {
+		vmove "usr/lib/libswscale.so.*"
+	}
+}
+
+libswresample4_package() {
+	short_desc="FFmpeg video resampling library"
+	pkg_install() {
+		vmove "usr/lib/libswresample.so.*"
+	}
+}
+
+ffmpeg4-devel_package() {
+	depends="
+		libavcodec4>=${version}_${revision}
+		libavdevice4>=${version}_${revision}
+		libavformat4>=${version}_${revision}
+		libavutil4>=${version}_${revision}
+		libavfilter4>=${version}_${revision}
+		libpostproc4>=${version}_${revision}
+		libswscale4>=${version}_${revision}
+		libswresample4>=${version}_${revision}
+		libavresample4>=${version}_${revision}"
+	short_desc+=" - development files"
+	conflicts="ffmpeg-devel"
+	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
+		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
+		nostrip_files="/usr/lib/libavfilter.a"
+	fi
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.a"
+		vmove "usr/lib/*.so"
+		vmove usr/share/ffmpeg/examples
+		vmove usr/share/man/man3
+	}
+}
diff --git a/srcpkgs/libavcodec4 b/srcpkgs/libavcodec4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavcodec4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavdevice4 b/srcpkgs/libavdevice4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavdevice4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavfilter4 b/srcpkgs/libavfilter4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavfilter4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavformat4 b/srcpkgs/libavformat4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavformat4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavresample4 b/srcpkgs/libavresample4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavutil4 b/srcpkgs/libavutil4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavutil4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libpostproc4 b/srcpkgs/libpostproc4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libpostproc4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswresample4 b/srcpkgs/libswresample4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libswresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswscale4 b/srcpkgs/libswscale4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libswscale4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file

From 527c2f513dd26b09f24e57c4d6d7f46b2e30be62 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:04 -0400
Subject: [PATCH 005/110] opencv: update to 4.7.0.

---
 common/shlibs           | 104 ++++++++++++++++++++--------------------
 srcpkgs/opencv/template |   8 ++--
 2 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index 4baee3efcb02c1..3c23afe020b924 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2079,58 +2079,58 @@ libcapstone.so.5 capstone-5.0.1_1
 libhavege.so.2 libhaveged-1.9.11_1
 libnih.so.1 libnih-1.0.3_1
 libnih-dbus.so.1 libnih-1.0.3_1
-libopencv_quality.so.406 libopencv-4.6.0_1
-libopencv_reg.so.406 libopencv-4.6.0_1
-libopencv_surface_matching.so.406 libopencv-4.6.0_1
-libopencv_xphoto.so.406 libopencv-4.6.0_1
-libopencv_freetype.so.406 libopencv-4.6.0_1
-libopencv_fuzzy.so.406 libopencv-4.6.0_1
-libopencv_hfs.so.406 libopencv-4.6.0_1
-libopencv_img_hash.so.406 libopencv-4.6.0_1
-libopencv_line_descriptor.so.406 libopencv-4.6.0_1
-libopencv_saliency.so.406 libopencv-4.6.0_1
-libopencv_structured_light.so.406 libopencv-4.6.0_1
-libopencv_aruco.so.406 libopencv-4.6.0_1
-libopencv_bgsegm.so.406 libopencv-4.6.0_1
-libopencv_bioinspired.so.406 libopencv-4.6.0_1
-libopencv_ccalib.so.406 libopencv-4.6.0_1
-libopencv_face.so.406 libopencv-4.6.0_1
-libopencv_tracking.so.406 libopencv-4.6.0_1
-libopencv_xfeatures2d.so.406 libopencv-4.6.0_1
-libopencv_optflow.so.406 libopencv-4.6.0_1
-libopencv_ximgproc.so.406 libopencv-4.6.0_1
-libopencv_plot.so.406 libopencv-4.6.0_1
-libopencv_text.so.406 libopencv-4.6.0_1
-libopencv_ml.so.406 libopencv-4.6.0_1
-libopencv_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn.so.406 libopencv-4.6.0_1
-libopencv_shape.so.406 libopencv-4.6.0_1
-libopencv_stitching.so.406 libopencv-4.6.0_1
-libopencv_photo.so.406 libopencv-4.6.0_1
-libopencv_video.so.406 libopencv-4.6.0_1
-libopencv_calib3d.so.406 libopencv-4.6.0_1
-libopencv_features2d.so.406 libopencv-4.6.0_1
-libopencv_flann.so.406 libopencv-4.6.0_1
-libopencv_highgui.so.406 libopencv-4.6.0_1
-libopencv_videoio.so.406 libopencv-4.6.0_1
-libopencv_imgcodecs.so.406 libopencv-4.6.0_1
-libopencv_imgproc.so.406 libopencv-4.6.0_1
-libopencv_core.so.406 libopencv-4.6.0_1
-libopencv_superres.so.406 libopencv-4.6.0_1
-libopencv_videostab.so.406 libopencv-4.6.0_1
-libopencv_gapi.so.406 libopencv-4.6.0_1
-libopencv_xobjdetect.so.406 libopencv-4.6.0_1
-libopencv_datasets.so.406 libopencv-4.6.0_1
-libopencv_dnn_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn_superres.so.406 libopencv-4.6.0_1
-libopencv_dpm.so.406 libopencv-4.6.0_1
-libopencv_phase_unwrapping.so.406 libopencv-4.6.0_1
-libopencv_stereo.so.406 libopencv-4.6.0_1
-libopencv_rapid.so.406 libopencv-4.6.0_1
-libopencv_intensity_transform.so.406 libopencv-4.6.0_1
-libopencv_alphamat.so.406 libopencv-4.6.0_1
-libopencv_barcode.so.406 libopencv-4.6.0_1
-libopencv_mcc.so.406 libopencv-4.6.0_1
+libopencv_quality.so.407 libopencv-4.7.0_1
+libopencv_reg.so.407 libopencv-4.7.0_1
+libopencv_surface_matching.so.407 libopencv-4.7.0_1
+libopencv_xphoto.so.407 libopencv-4.7.0_1
+libopencv_freetype.so.407 libopencv-4.7.0_1
+libopencv_fuzzy.so.407 libopencv-4.7.0_1
+libopencv_hfs.so.407 libopencv-4.7.0_1
+libopencv_img_hash.so.407 libopencv-4.7.0_1
+libopencv_line_descriptor.so.407 libopencv-4.7.0_1
+libopencv_saliency.so.407 libopencv-4.7.0_1
+libopencv_structured_light.so.407 libopencv-4.7.0_1
+libopencv_aruco.so.407 libopencv-4.7.0_1
+libopencv_bgsegm.so.407 libopencv-4.7.0_1
+libopencv_bioinspired.so.407 libopencv-4.7.0_1
+libopencv_ccalib.so.407 libopencv-4.7.0_1
+libopencv_face.so.407 libopencv-4.7.0_1
+libopencv_tracking.so.407 libopencv-4.7.0_1
+libopencv_xfeatures2d.so.407 libopencv-4.7.0_1
+libopencv_optflow.so.407 libopencv-4.7.0_1
+libopencv_ximgproc.so.407 libopencv-4.7.0_1
+libopencv_plot.so.407 libopencv-4.7.0_1
+libopencv_text.so.407 libopencv-4.7.0_1
+libopencv_ml.so.407 libopencv-4.7.0_1
+libopencv_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn.so.407 libopencv-4.7.0_1
+libopencv_shape.so.407 libopencv-4.7.0_1
+libopencv_stitching.so.407 libopencv-4.7.0_1
+libopencv_photo.so.407 libopencv-4.7.0_1
+libopencv_video.so.407 libopencv-4.7.0_1
+libopencv_calib3d.so.407 libopencv-4.7.0_1
+libopencv_features2d.so.407 libopencv-4.7.0_1
+libopencv_flann.so.407 libopencv-4.7.0_1
+libopencv_highgui.so.407 libopencv-4.7.0_1
+libopencv_videoio.so.407 libopencv-4.7.0_1
+libopencv_imgcodecs.so.407 libopencv-4.7.0_1
+libopencv_imgproc.so.407 libopencv-4.7.0_1
+libopencv_core.so.407 libopencv-4.7.0_1
+libopencv_superres.so.407 libopencv-4.7.0_1
+libopencv_videostab.so.407 libopencv-4.7.0_1
+libopencv_gapi.so.407 libopencv-4.7.0_1
+libopencv_xobjdetect.so.407 libopencv-4.7.0_1
+libopencv_datasets.so.407 libopencv-4.7.0_1
+libopencv_dnn_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn_superres.so.407 libopencv-4.7.0_1
+libopencv_dpm.so.407 libopencv-4.7.0_1
+libopencv_phase_unwrapping.so.407 libopencv-4.7.0_1
+libopencv_stereo.so.407 libopencv-4.7.0_1
+libopencv_rapid.so.407 libopencv-4.7.0_1
+libopencv_intensity_transform.so.407 libopencv-4.7.0_1
+libopencv_alphamat.so.407 libopencv-4.7.0_1
+libopencv_barcode.so.407 libopencv-4.7.0_1
+libopencv_mcc.so.407 libopencv-4.7.0_1
 libuniconf.so.4.6 wvstreams-4.6.1_20
 libwvbase.so.4.6 wvstreams-4.6.1_20
 libwvutils.so.4.6 wvstreams-4.6.1_20
diff --git a/srcpkgs/opencv/template b/srcpkgs/opencv/template
index aea4bfc3a265cf..ce94de9424d18d 100644
--- a/srcpkgs/opencv/template
+++ b/srcpkgs/opencv/template
@@ -1,7 +1,7 @@
 # Template file for 'opencv'
 pkgname=opencv
-version=4.6.0
-revision=6
+version=4.7.0
+revision=1
 create_wrksrc=yes
 build_wrksrc=${pkgname}-${version}
 build_style=cmake
@@ -24,8 +24,8 @@ homepage="https://opencv.org"
 changelog="https://github.com/opencv/opencv/wiki/ChangeLog"
 distfiles="https://github.com/opencv/opencv/archive/${version}.tar.gz
  https://github.com/opencv/opencv_contrib/archive/${version}.tar.gz>contrib.tar.gz"
-checksum="1ec1cba65f9f20fe5a41fda1586e01c70ea0c9a6d7b67c9e13edf0cfe2239277
- 1777d5fd2b59029cf537e5fd6f8aa68d707075822f90bde683fcde086f85f7a7"
+checksum="8df0079cdbe179748a18d44731af62a245a45ebf5085223dc03133954c662973
+ 42df840cf9055e59d0e22c249cfb19f04743e1bdad113d31b1573d3934d62584"
 patch_args="-Np1 -d ${build_wrksrc}"
 # tests hang indenfinitely, even with test data included
 make_check=no

From 01125a800c27a65ee8f2006b5bcf51ec06ac5591 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 006/110] actiona: revbump for opencv-4.7.0

---
 srcpkgs/actiona/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/actiona/template b/srcpkgs/actiona/template
index cf5f0b7a2ae610..0d899311e6df75 100644
--- a/srcpkgs/actiona/template
+++ b/srcpkgs/actiona/template
@@ -1,7 +1,7 @@
 # Template file for 'actiona'
 pkgname=actiona
 version=3.10.1
-revision=2
+revision=3
 build_style=qmake
 configure_args="PKGCONFIG_OPENCV=opencv4"
 hostmakedepends="pkg-config qt5-plugin-mysql qt5-qmake qt5-host-tools"

From efe250760a96f43e8a28ac5f83411f4944ab14c7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 007/110] retroshare: revbump for opencv-4.7.0

---
 srcpkgs/retroshare/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroshare/template b/srcpkgs/retroshare/template
index bb17569277a7f3..49e2c1cbe8a531 100644
--- a/srcpkgs/retroshare/template
+++ b/srcpkgs/retroshare/template
@@ -1,7 +1,7 @@
 # Template file for 'retroshare'
 pkgname=retroshare
 version=0.6.6
-revision=3
+revision=4
 build_style=qmake
 #XXX broadcast feature requires an ancient udp-discovery-cpp which either needs
 # to be fetched+patched (FTBFS) here or packaged :/

From ac0fb09f9247601adfb69c996a47d0d0343f69ef Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 008/110] waifu2x-converter-cpp: revbump for opencv-4.7.0

---
 srcpkgs/waifu2x-converter-cpp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waifu2x-converter-cpp/template b/srcpkgs/waifu2x-converter-cpp/template
index 361b8a23b94977..c5ac17eb54ea4c 100644
--- a/srcpkgs/waifu2x-converter-cpp/template
+++ b/srcpkgs/waifu2x-converter-cpp/template
@@ -1,7 +1,7 @@
 # Template file for 'waifu2x-converter-cpp'
 pkgname=waifu2x-converter-cpp
 version=5.2.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DINSTALL_MODELS=ON"
 hostmakedepends="pkg-config"

From 6ac01bea1cc4626ba4b7f3872061250e2371d111 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:38 -0400
Subject: [PATCH 009/110] vlc: revbump for ffmpeg4

---
 srcpkgs/vlc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vlc/template b/srcpkgs/vlc/template
index 559b1c4fff339f..cfa11e6c26f28c 100644
--- a/srcpkgs/vlc/template
+++ b/srcpkgs/vlc/template
@@ -25,7 +25,7 @@ lib32disabled=yes
 hostmakedepends="automake libtool pkg-config flex gettext libgcrypt-devel
  live555-devel gettext-devel $(vopt_if lua lua52) $(vopt_if chromecast protobuf)"
 makedepends="
- avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg-devel freefont-ttf
+ avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg4-devel freefont-ttf
  gnutls-devel jack-devel liba52-devel libass-devel libbluray-devel
  libcdio-devel libdca-devel libdvbpsi-devel libdvdnav-devel libmad-devel
  libmatroska-devel libmodplug-devel libmpcdec-devel libmpeg2-devel

From 3455eb887e82c2825e7db0175fd8e8fa0be0233d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:55 -0400
Subject: [PATCH 010/110] osg: revbump for ffmpeg4

---
 srcpkgs/osg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/osg/template b/srcpkgs/osg/template
index 8ef0efc599a1b1..a131ceaf7a867b 100644
--- a/srcpkgs/osg/template
+++ b/srcpkgs/osg/template
@@ -8,7 +8,7 @@ build_helper="qemu"
 configure_args="-DLIB_POSTFIX="
 hostmakedepends="pkg-config xrandr"
 makedepends="MesaLib-devel gtkglext-devel libcurl-devel giflib-devel librsvg-devel
- jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg-devel xine-lib-devel
+ jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg4-devel xine-lib-devel
  SDL2-devel gst-plugins-base1-devel
  $(vopt_if openexr libopenexr-devel)
  $(vopt_if poppler poppler-glib-devel)

From 7f1d018281900594e5977ce82e8f1e13289759b9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:13 -0400
Subject: [PATCH 011/110] xine-lib: revbump for ffmpeg4

---
 srcpkgs/xine-lib/template | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/xine-lib/template b/srcpkgs/xine-lib/template
index 3be4d08eac77a3..ed6194c17d11e8 100644
--- a/srcpkgs/xine-lib/template
+++ b/srcpkgs/xine-lib/template
@@ -1,14 +1,14 @@
 # Template file for 'xine-lib'
 pkgname=xine-lib
-version=1.2.12
-revision=3
+version=1.2.13
+revision=1
 build_style=gnu-configure
 configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
  --disable-oss"
 hostmakedepends="automake gettext-devel libtool pkg-config perl"
 makedepends="
  zlib-devel alsa-lib-devel libxcb-devel libSM-devel libXext-devel libXv-devel
- libXvMC-devel liba52-devel libmad-devel ffmpeg-devel pulseaudio-devel
+ libXvMC-devel liba52-devel libmad-devel ffmpeg4-devel pulseaudio-devel
  jack-devel samba-devel libflac-devel libmodplug-devel libmpcdec-devel
  speex-devel libtheora-devel libvorbis-devel libdca-devel faad2-devel
  libcdio-devel libbluray-devel aalib-devel libcaca-devel libXinerama-devel
@@ -19,7 +19,7 @@ license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="http://www.xine-project.org"
 changelog="https://sourceforge.net/projects/xine/files/xine-lib/${version}/README.txt/view"
 distfiles="${SOURCEFORGE_SITE}/xine/${pkgname}-${version}.tar.xz"
-checksum=d606270468e1540c2a89c0d7f5fdf11e17ecc0c2698cc0bcb1065ff26abee098
+checksum=5f10d6d718a4a51c17ed1b32b031d4f9b80b061e8276535b2be31e5ac4b75e6f
 
 case "$XBPS_TARGET_MACHINE" in
 	i686-musl)

From 36391075995a0afd79d32e4219080a782986c5f5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 012/110] attract: revbump for ffmpeg6

---
 srcpkgs/attract/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/attract/template b/srcpkgs/attract/template
index e769fb15456217..776cbe4ebd2c93 100644
--- a/srcpkgs/attract/template
+++ b/srcpkgs/attract/template
@@ -1,7 +1,7 @@
 # Template file for 'attract'
 pkgname=attract
 version=2.7.0
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="VERBOSE=1"
 make_use_env=yes

From 8dba847ef327f20c66648278a9fc54484e21e8fc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 013/110] aubio: revbump for ffmpeg6

---
 srcpkgs/aubio/patches/ffmpeg5.patch | 25 +++++++++++++++++++++++++
 srcpkgs/aubio/template              |  2 +-
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/aubio/patches/ffmpeg5.patch

diff --git a/srcpkgs/aubio/patches/ffmpeg5.patch b/srcpkgs/aubio/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..aace41a6e6d9a4
--- /dev/null
+++ b/srcpkgs/aubio/patches/ffmpeg5.patch
@@ -0,0 +1,25 @@
+From 8a05420e5dd8c7b8b2447f82dc919765876511b3 Mon Sep 17 00:00:00 2001
+From: Paul Brossier <piem@piem.org>
+Date: Tue, 25 Jan 2022 18:30:27 +0100
+Subject: [PATCH] [source_avcodec] define FF_API_LAVF_AVCTX for libavcodec >
+ 59, thx @berolinux (closes gh-353)
+
+---
+ src/io/source_avcodec.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/io/source_avcodec.c b/src/io/source_avcodec.c
+index e0ae93b5..1421bd9a 100644
+--- a/src/io/source_avcodec.c
++++ b/src/io/source_avcodec.c
+@@ -68,6 +68,10 @@
+ #define AUBIO_AVCODEC_MAX_BUFFER_SIZE AV_INPUT_BUFFER_MIN_SIZE
+ #endif
+ 
++#if LIBAVCODEC_VERSION_MAJOR >= 59
++#define FF_API_LAVF_AVCTX 1
++#endif
++
+ struct _aubio_source_avcodec_t {
+   uint_t hop_size;
+   uint_t samplerate;
diff --git a/srcpkgs/aubio/template b/srcpkgs/aubio/template
index ad1c4b25699178..7d875cc02541a7 100644
--- a/srcpkgs/aubio/template
+++ b/srcpkgs/aubio/template
@@ -1,7 +1,7 @@
 # Template file for 'aubio'
 pkgname=aubio
 version=0.4.9
-revision=1
+revision=2
 build_style=waf3
 # XXX lash, pure and swig support.
 hostmakedepends="pkg-config txt2man"

From 399773979e11ffcb2c1226898d87259b3234a911 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 014/110] audacious-plugins: revbump for ffmpeg6

---
 .../audacious-plugins/patches/ffmpeg5.patch   | 43 +++++++++++++++++++
 srcpkgs/audacious-plugins/template            |  2 +-
 2 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/audacious-plugins/patches/ffmpeg5.patch

diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg5.patch b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..4e5e34099d71c4
--- /dev/null
+++ b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
@@ -0,0 +1,43 @@
+commit 298aa371c56c2f52c25a33d9bdec4918b11cebdc
+Author: tibequadorian <tibequadorian@posteo.de>
+Date:   Sat Mar 19 18:40:12 2022 +0100
+
+    audacious-plugins: rebuild against ffmpeg-5.0
+
+diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+new file mode 100644
+index 0000000000..617c11215b
+--- /dev/null
++++ b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+@@ -0,0 +1,31 @@
++From f60beb400eeb1e4778bbfd738bc4a4ccef3de539 Mon Sep 17 00:00:00 2001
++From: John Lindgren <john@jlindgren.net>
++Date: Sat, 5 Mar 2022 12:05:34 -0500
++Subject: [PATCH] Fix build with FFmpeg 5.0
++
++---
++ src/ffaudio/ffaudio-core.cc | 4 ++--
++ 1 file changed, 2 insertions(+), 2 deletions(-)
++
++diff --git a/src/ffaudio/ffaudio-core.cc b/src/ffaudio/ffaudio-core.cc
++index 16dc63e3a..a2b95fd6c 100644
++--- a/src/ffaudio/ffaudio-core.cc
+++++ b/src/ffaudio/ffaudio-core.cc
++@@ -274,7 +274,7 @@ static AVInputFormat * get_format_by_content (const char * name, VFSFile & file)
++         AVProbeData d = {name, buf, filled};
++         score = target;
++ 
++-        f = av_probe_input_format2 (& d, true, & score);
+++        f = (AVInputFormat *) av_probe_input_format2 (& d, true, & score);
++         if (f)
++             break;
++ 
++@@ -347,7 +347,7 @@ static bool find_codec (AVFormatContext * c, CodecInfo * cinfo)
++ #endif
++         if (stream && stream->codecpar && stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
++         {
++-            AVCodec * codec = avcodec_find_decoder (stream->codecpar->codec_id);
+++            AVCodec * codec = (AVCodec *) avcodec_find_decoder (stream->codecpar->codec_id);
++ 
++             if (codec)
++             {
diff --git a/srcpkgs/audacious-plugins/template b/srcpkgs/audacious-plugins/template
index 05e53a9adf78ff..4b1968e03de781 100644
--- a/srcpkgs/audacious-plugins/template
+++ b/srcpkgs/audacious-plugins/template
@@ -2,7 +2,7 @@
 #Keep in sync with audacious!
 pkgname=audacious-plugins
 version=4.3.1
-revision=3
+revision=4
 build_style=meson
 configure_args="$(vopt_bool gtk3 gtk) $(vopt_bool gtk3)
  $(vopt_bool qt) $(vopt_bool qt qt6)"

From 5667ec7278cb63212d6da832ebcdb421ca5e088d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 015/110] audacity: revbump for ffmpeg6

---
 srcpkgs/audacity/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/audacity/template b/srcpkgs/audacity/template
index 7b838119ab2611..84b49305edcef1 100644
--- a/srcpkgs/audacity/template
+++ b/srcpkgs/audacity/template
@@ -1,7 +1,7 @@
 # Template file for 'audacity'
 pkgname=audacity
 version=3.4.2
-revision=1
+revision=2
 build_style=cmake
 build_helper="cmake-wxWidgets-gtk3 qemu"
 configure_args="-Daudacity_use_ffmpeg=loaded -Daudacity_lib_preference=system

From df3b2f882ce1f2cd0b285255207f352e17154eaa Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 016/110] avidemux: revbump for ffmpeg6

---
 srcpkgs/avidemux/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/avidemux/template b/srcpkgs/avidemux/template
index 253a0243e22599..557285982d2b8f 100644
--- a/srcpkgs/avidemux/template
+++ b/srcpkgs/avidemux/template
@@ -1,7 +1,7 @@
 # Template file for 'avidemux'
 pkgname=avidemux
 version=2.8.0
-revision=2
+revision=3
 # Can't be compiled for aarch64, arm* or mips*
 archs="x86_64* i686*"
 hostmakedepends="cmake pkg-config qt5-host-tools qt5-devel tar yasm"

From c45057f6e2633a534d331b25bf000dcdd6e75cd2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 017/110] blender: revbump for ffmpeg6

---
 srcpkgs/blender/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index 68787b76a26c18..e238717ac8c729 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -9,8 +9,8 @@ configure_args="-DWITH_INSTALL_PORTABLE=OFF -DWITH_PYTHON_INSTALL=OFF
  -DWITH_JACK=ON -DWITH_CODEC_FFMPEG=ON -DWITH_CODEC_SNDFILE=ON -DWITH_OPENMP=ON
  -DWITH_FFTW3=ON -DWITH_MOD_OCEANSIM=ON -DWITH_CYCLES_EMBREE=OFF -DWITH_OPENCOLORIO=ON
  -DWITH_IMAGE_OPENEXR=ON -DWITH_IMAGE_OPENJPEG=ON -DWITH_OPENSUBDIV=ON
- -DWITH_OPENCOLLADA=ON -DWITH_SYSTEM_GLEW=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
- -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_LIBDECOR=ON
+ -DWITH_OPENCOLLADA=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
+ -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_WAYLAND_LIBDECOR=ON
  -DWITH_BUILDINFO=OFF -DPYTHON_VERSION=${py3_ver} -DPYTHON_LIBPATH=/usr/lib
  -DPYTHON_LIBRARY=python${py3_ver}${py3_abiver} -DPYTHON_INCLUDE_DIRS=/${py3_inc}
  -DWITH_SYSTEM_LZO=ON -DWITH_SYSTEM_EIGEN3=ON -DWITH_SYSTEM_FREETYPE=ON"

From d4933a0b7ee622089cc5c590654cd7bcae348a0d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 018/110] cantata: revbump for ffmpeg6

---
 srcpkgs/cantata/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cantata/template b/srcpkgs/cantata/template
index 4b417d80d5c2da..8a90aaa4c07a2a 100644
--- a/srcpkgs/cantata/template
+++ b/srcpkgs/cantata/template
@@ -1,7 +1,7 @@
 # Template file for 'cantata'
 pkgname=cantata
 version=2.5.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools qt5-tools"
 makedepends="qt5-devel qt5-tools-devel qt5-svg-devel qt5-xmlpatterns-devel

From 777908e578bd74d0e0dbbfd64bfc97eeba7b69b6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 019/110] ccextractor: revbump for ffmpeg6

---
 ...5-and-tesseract-5-compatibility-1479.patch | 168 ++++++++++++++++++
 srcpkgs/ccextractor/template                  |   2 +-
 2 files changed, 169 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ccextractor/patches/0001-fix-ffmpeg-5-and-tesseract-5-compatibility-1479.patch

diff --git a/srcpkgs/ccextractor/patches/0001-fix-ffmpeg-5-and-tesseract-5-compatibility-1479.patch b/srcpkgs/ccextractor/patches/0001-fix-ffmpeg-5-and-tesseract-5-compatibility-1479.patch
new file mode 100644
index 00000000000000..bcab4890554b9a
--- /dev/null
+++ b/srcpkgs/ccextractor/patches/0001-fix-ffmpeg-5-and-tesseract-5-compatibility-1479.patch
@@ -0,0 +1,168 @@
+From b1cbfcea9b9c687143bf0d80bc179b563e99d025 Mon Sep 17 00:00:00 2001
+From: Prateek Sunal <prtksunal@gmail.com>
+Date: Thu, 9 Mar 2023 01:44:53 +0530
+Subject: [PATCH] fix: ffmpeg 5 and tesseract 5 compatibility (#1479)
+
+* fix: replace deprecated `codec` property with `codecpar`
+
+* fix: replace deprecated method `avcodec_decode_video2` with `avcodec_receive_frame` and `avcodec_send_packet`
+
+* Update CHANGES.TXT
+
+* fix: remove deprecated `av_register_all` function
+
+* fix: formatting
+
+* fix: add support for tesseract 5
+
+* fix: tesseract v5
+
+* fix: hardsubx codec context error
+
+* fix: lint const warning
+---
+ docs/CHANGES.TXT               |  1 +
+ src/lib_ccx/ffmpeg_intgr.c     |  7 +++---
+ src/lib_ccx/hardsubx.c         | 25 ++++++++++++------
+ src/lib_ccx/hardsubx_decoder.c | 27 ++++++++------------
+ src/lib_ccx/ocr.c              | 46 ++++++++++++----------------------
+ 5 files changed, 47 insertions(+), 59 deletions(-)
+
+diff --git a/src/lib_ccx/ffmpeg_intgr.c b/src/lib_ccx/ffmpeg_intgr.c
+index be988890..e6f21e20 100644
+--- a/src/lib_ccx/ffmpeg_intgr.c
++++ b/src/lib_ccx/ffmpeg_intgr.c
+@@ -66,7 +66,6 @@ void *init_ffmpeg(const char *path)
+ 	struct ffmpeg_ctx *ctx;
+ 	AVCodec *dec = NULL;
+ 	avcodec_register_all();
+-	av_register_all();
+ 
+ 	if (ccx_options.debug_mask & CCX_DMT_VERBOSE)
+ 		av_log_set_level(AV_LOG_INFO);
+@@ -133,7 +132,6 @@ int ff_get_ccframe(void *arg, unsigned char *data, int maxlen)
+ 	struct ffmpeg_ctx *ctx = arg;
+ 	int len = 0;
+ 	int ret = 0;
+-	int got_frame;
+ 	AVPacket packet;
+ 
+ 	ret = av_read_frame(ctx->ifmt, &packet);
+@@ -151,12 +149,13 @@ int ff_get_ccframe(void *arg, unsigned char *data, int maxlen)
+ 		return AVERROR(EAGAIN);
+ 	}
+ 
+-	ret = avcodec_decode_video2(ctx->dec_ctx, ctx->frame, &got_frame, &packet);
++	avcodec_send_packet(ctx->codec_ctx, &ctx->packet);
++	ret = avcodec_receive_frame(ctx->dec_ctx, ctx->frame);
+ 	if (ret < 0)
+ 	{
+ 		av_log(NULL, AV_LOG_ERROR, "unable to decode packet\n");
+ 	}
+-	else if (!got_frame)
++	else if (ret != 0)
+ 	{
+ 		return AVERROR(EAGAIN);
+ 	}
+diff --git a/src/lib_ccx/hardsubx.c b/src/lib_ccx/hardsubx.c
+index 411377f9..fb844c91 100644
+--- a/src/lib_ccx/hardsubx.c
++++ b/src/lib_ccx/hardsubx.c
+@@ -12,9 +12,6 @@
+
+ int hardsubx_process_data(struct lib_hardsubx_ctx *ctx)
+ {
+-	// Get the required media attributes and initialize structures
+-	av_register_all();
+-
+ 	if (avformat_open_input(&ctx->format_ctx, ctx->inputfile[0], NULL, NULL) != 0)
+ 	{
+ 		fatal(EXIT_READ_ERROR, "Error reading input file!\n");
+@@ -32,7 +29,7 @@
+ 	ctx->video_stream_id = -1;
+ 	for (int i = 0; i < ctx->format_ctx->nb_streams; i++)
+ 	{
+-		if (ctx->format_ctx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO)
++		if (ctx->format_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
+ 		{
+ 			ctx->video_stream_id = i;
+ 			break;
+@@ -43,8 +40,21 @@
+ 		fatal(EXIT_READ_ERROR, "Video Stream not found!\n");
+ 	}
+
+-	ctx->codec_ctx = ctx->format_ctx->streams[ctx->video_stream_id]->codec;
+-	ctx->codec = avcodec_find_decoder(ctx->codec_ctx->codec_id);
++	ctx->codec_ctx = avcodec_alloc_context3(NULL);
++	if (!ctx->codec_ctx)
++	{
++		    fatal(EXIT_NOT_ENOUGH_MEMORY, "Could not allocate codec context!\n");
++	}
++
++	// Assign codec parameters to codec context
++	if (avcodec_parameters_to_context(ctx->codec_ctx, ctx->format_ctx->streams[ctx->video_stream_id]->codecpar) < 0)
++	{
++		    fatal(EXIT_READ_ERROR, "Could not initialize codec context!\n");
++	}
++
++	// Find decoder for the codec context
++	ctx->codec = (AVCodec *)avcodec_find_decoder(ctx->codec_ctx->codec_id);
++
+ 	if (ctx->codec == NULL)
+ 	{
+ 		fatal(EXIT_READ_ERROR, "Input codec is not supported!\n");
+diff --git a/src/lib_ccx/hardsubx_decoder.c b/src/lib_ccx/hardsubx_decoder.c
+index bd9b0980..b5dfaec4 100644
+--- a/src/lib_ccx/hardsubx_decoder.c
++++ b/src/lib_ccx/hardsubx_decoder.c
+@@ -371,7 +371,6 @@
+ int hardsubx_process_frames_tickertext(struct lib_hardsubx_ctx *ctx, struct encoder_ctx *enc_ctx)
+ {
+ 	// Search for ticker text at the bottom of the screen, such as in Russia TV1 or stock prices
+-	int got_frame;
+ 	int cur_sec = 0, total_sec, progress;
+ 	int frame_number = 0;
+ 	char *ticker_text = NULL;
+@@ -382,8 +381,8 @@
+ 		{
+ 			frame_number++;
+ 			//Decode the video stream packet
+-			avcodec_decode_video2(ctx->codec_ctx, ctx->frame, &got_frame, &ctx->packet);
+-			if (got_frame && frame_number % 1000 == 0)
++      avcodec_send_packet(ctx->codec_ctx, &ctx->packet);
++      if (avcodec_receive_frame(ctx->codec_ctx, ctx->frame) == 0 && frame_number % 1000 == 0)
+ 			{
+ 				// sws_scale is used to convert the pixel format to RGB24 from all other cases
+ 				sws_scale(
+@@ -434,9 +433,8 @@
+ 			frame_number++;
+
+ 			//Decode the video stream packet
+-			avcodec_decode_video2(ctx->codec_ctx, ctx->frame, &got_frame, &ctx->packet);
+-
+-			if (got_frame && frame_number % 25 == 0)
++			avcodec_send_packet(ctx->codec_ctx, &ctx->packet);
++      if (avcodec_receive_frame(ctx->codec_ctx, ctx->frame) == 0 && frame_number % 25 == 0)
+ 			{
+ 				float diff = (float)convert_pts_to_ms(ctx->packet.pts - prev_packet_pts, ctx->format_ctx->streams[ctx->video_stream_id]->time_base);
+ 				if (fabsf(diff) < 1000 * ctx->min_sub_duration) //If the minimum duration of a subtitle line is exceeded, process packet
+@@ -548,7 +546,6 @@
+ {
+ 	// Do a binary search over the input video for faster processing
+ 	// printf("Duration: %d\n", (int)ctx->format_ctx->duration);
+-	int got_frame;
+ 	int seconds_time = 0;
+ 	for (seconds_time = 0; seconds_time < 20; seconds_time++)
+ 	{
+@@ -568,8 +565,9 @@
+ 			{
+ 				if (ctx->packet.stream_index == ctx->video_stream_id)
+ 				{
+-					avcodec_decode_video2(ctx->codec_ctx, ctx->frame, &got_frame, &ctx->packet);
+-					if (got_frame)
++          avcodec_send_packet(ctx->codec_ctx, &ctx->packet);
++          if (avcodec_receive_frame(ctx->codec_ctx, ctx->frame) == 0)
++
+ 					{
+ 						// printf("%d\n", seek_time);
+ 						if (ctx->packet.pts < seek_time)
diff --git a/srcpkgs/ccextractor/template b/srcpkgs/ccextractor/template
index 84059ffd02398a..a670758bcbe41b 100644
--- a/srcpkgs/ccextractor/template
+++ b/srcpkgs/ccextractor/template
@@ -1,7 +1,7 @@
 # Template file for 'ccextractor'
 pkgname=ccextractor
 version=0.93
-revision=2
+revision=3
 build_wrksrc="linux"
 build_style=gnu-configure
 configure_args="--enable-ocr --enable-hardsubx"

From 72da19f57e8dd04d9efe3a51e1d626b473b99281 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 020/110] chromaprint: revbump for ffmpeg6

---
 srcpkgs/chromaprint/patches/ffmpeg5.patch | 569 ++++++++++++++++++++++
 srcpkgs/chromaprint/template              |   2 +-
 2 files changed, 570 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromaprint/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromaprint/patches/ffmpeg5.patch b/srcpkgs/chromaprint/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..a9fd307a23c8a4
--- /dev/null
+++ b/srcpkgs/chromaprint/patches/ffmpeg5.patch
@@ -0,0 +1,569 @@
+From 8ccad6937177b1b92e40ab8f4447ea27bac009a7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= <lalinsky@gmail.com>
+Date: Fri, 4 Nov 2022 21:47:38 +0100
+Subject: [PATCH] Use FFmpeg 5.x (#120)
+
+* Use FFmpeg 5.1.2 for CI builds
+
+* Build on Ubuntu 20.04
+
+* Upgrade code to FFmpeg 5.x APIs
+
+* Only set FFmpeg include dirs if building tools
+
+* No longer needed
+
+* Use ubuntu 20.04
+---
+ .github/workflows/build.yml                   |   6 +-
+ CMakeLists.txt                                |  16 --
+ package/build.sh                              |   4 +-
+ src/audio/ffmpeg_audio_processor.h            |   2 -
+ src/audio/ffmpeg_audio_processor_avresample.h |  72 -------
+ src/audio/ffmpeg_audio_processor_swresample.h |  18 +-
+ src/audio/ffmpeg_audio_reader.h               | 197 +++++++++---------
+ tests/CMakeLists.txt                          |   6 +
+ 8 files changed, 122 insertions(+), 199 deletions(-)
+ delete mode 100644 src/audio/ffmpeg_audio_processor_avresample.h
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index f8d6a32..4da2405 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -84,9 +84,6 @@ find_package(FFmpeg)
+ if(FFMPEG_LIBRARIES)
+ 	cmake_push_check_state(RESET)
+ 	set(CMAKE_REQUIRED_LIBRARIES ${FFMPEG_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -lm)
+-	check_function_exists(av_packet_unref HAVE_AV_PACKET_UNREF)
+-	check_function_exists(av_frame_alloc HAVE_AV_FRAME_ALLOC)
+-	check_function_exists(av_frame_free HAVE_AV_FRAME_FREE)
+ 	cmake_pop_check_state()
+ endif()
+
+@@ -163,14 +160,11 @@ message(STATUS "Using ${FFT_LIB} for FFT calculations")
+ if(NOT AUDIO_PROCESSOR_LIB)
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+ 		set(AUDIO_PROCESSOR_LIB "swresample")
+-	elseif(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(AUDIO_PROCESSOR_LIB "avresample")
+ 	endif()
+ endif()
+
+ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE OFF)
+ 		set(USE_SWRESAMPLE ON)
+ 		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBSWRESAMPLE_LIBRARIES})
+ 		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBSWRESAMPLE_INCLUDE_DIRS})
+@@ -178,16 +172,6 @@ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+ 	endif()
+ 	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+-elseif(AUDIO_PROCESSOR_LIB STREQUAL "avresample")
+-	if(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE ON)
+-		set(USE_SWRESAMPLE OFF)
+-		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBAVRESAMPLE_LIBRARIES})
+-		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBAVRESAMPLE_INCLUDE_DIRS})
+-	else()
+-		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+-	endif()
+-	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+ else()
+ 	message(STATUS "Building without audio conversion support, please install FFmpeg with libswresample")
+ endif()
+diff --git a/package/build.sh b/package/build.sh
+index da631ae..b41d36e 100755
+--- a/package/build.sh
++++ b/package/build.sh
+@@ -7,8 +7,8 @@ set -eux
+
+ BASE_DIR=$(cd $(dirname $0)/.. && pwd)
+
+-FFMPEG_VERSION=4.4.1
+-FFMPEG_BUILD_TAG=v4.4.1-1
++FFMPEG_VERSION=5.1.2
++FFMPEG_BUILD_TAG=v${FFMPEG_VERSION}-1
+
+ TMP_BUILD_DIR=$BASE_DIR/$(mktemp -d build.XXXXXXXX)
+ trap 'rm -rf $TMP_BUILD_DIR' EXIT
+diff --git a/src/audio/ffmpeg_audio_processor.h b/src/audio/ffmpeg_audio_processor.h
+index 7628fc7..39f4f6d 100644
+--- a/src/audio/ffmpeg_audio_processor.h
++++ b/src/audio/ffmpeg_audio_processor.h
+@@ -10,8 +10,6 @@
+
+ #if defined(USE_SWRESAMPLE)
+ #include "audio/ffmpeg_audio_processor_swresample.h"
+-#elif defined(USE_AVRESAMPLE)
+-#include "audio/ffmpeg_audio_processor_avresample.h"
+ #else
+ #error "no audio processing library"
+ #endif
+diff --git a/src/audio/ffmpeg_audio_processor_avresample.h b/src/audio/ffmpeg_audio_processor_avresample.h
+deleted file mode 100644
+index bd85f92..0000000
+--- a/src/audio/ffmpeg_audio_processor_avresample.h
++++ /dev/null
+@@ -1,72 +0,0 @@
+-// Copyright (C) 2016  Lukas Lalinsky
+-// Distributed under the MIT license, see the LICENSE file for details.
+-
+-#ifndef CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-#define CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-
+-extern "C" {
+-#include <libavresample/avresample.h>
+-}
+-
+-namespace chromaprint {
+-
+-class FFmpegAudioProcessor {
+-public:
+-	FFmpegAudioProcessor() {
+-		m_resample_ctx = avresample_alloc_context();
+-	}
+-
+-	~FFmpegAudioProcessor() {
+-		avresample_free(&m_resample_ctx);
+-	}
+-
+-	void SetCompatibleMode() {
+-		av_opt_set_int(m_resample_ctx, "filter_size", 16, 0);
+-		av_opt_set_int(m_resample_ctx, "phase_shift", 8, 0);
+-		av_opt_set_int(m_resample_ctx, "linear_interp", 1, 0);
+-		av_opt_set_double(m_resample_ctx, "cutoff", 0.8, 0);
+-	}
+-
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "in_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_rate", sample_rate, 0);
+-	}
+-
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "out_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_rate, 0);
+-	}
+-
+-	int Init() {
+-		return avresample_open(m_resample_ctx);
+-	}
+-
+-	int Convert(uint8_t **out, int out_count, const uint8_t **in, int in_count) {
+-		return avresample_convert(m_resample_ctx, out, 0, out_count, (uint8_t **) in, 0, in_count);
+-	}
+-
+-	int Flush(uint8_t **out, int out_count) {
+-		return avresample_read(m_resample_ctx, out, out_count);
+-	}
+-
+-private:
+-	AVAudioResampleContext *m_resample_ctx = nullptr;
+-};
+-
+-}; // namespace chromaprint
+-
+-#endif
+diff --git a/src/audio/ffmpeg_audio_processor_swresample.h b/src/audio/ffmpeg_audio_processor_swresample.h
+index b86266b..b1d4bea 100644
+--- a/src/audio/ffmpeg_audio_processor_swresample.h
++++ b/src/audio/ffmpeg_audio_processor_swresample.h
+@@ -28,30 +28,28 @@ public:
+ 		av_opt_set_double(m_swr_ctx, "cutoff", 0.8, 0);
+ 	}
+
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "icl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "ich", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetInputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "in_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "isf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "in_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "isr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "in_sample_rate", sample_rate, 0);
+ 	}
+
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "ocl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "och", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetOutputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "out_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "osf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "out_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "osr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "out_sample_rate", sample_rate, 0);
+ 	}
+
+ 	int Init() {
+diff --git a/src/audio/ffmpeg_audio_reader.h b/src/audio/ffmpeg_audio_reader.h
+index 5550164..1c6b346 100644
+--- a/src/audio/ffmpeg_audio_reader.h
++++ b/src/audio/ffmpeg_audio_reader.h
+@@ -62,7 +62,7 @@ public:
+ 	bool Read(const int16_t **data, size_t *size);
+
+ 	bool IsOpen() const { return m_opened; }
+-	bool IsFinished() const { return m_finished && !m_got_frame; }
++	bool IsFinished() const { return !m_has_more_packets && !m_has_more_frames; }
+
+ 	std::string GetError() const { return m_error; }
+ 	int GetErrorCode() const { return m_error_code; }
+@@ -74,20 +74,19 @@ private:
+ 	uint8_t *m_convert_buffer[1] = { nullptr };
+ 	int m_convert_buffer_nb_samples = 0;
+
+-	AVInputFormat *m_input_fmt = nullptr;
++	const AVInputFormat *m_input_fmt = nullptr;
+ 	AVDictionary *m_input_opts = nullptr;
+
+ 	AVFormatContext *m_format_ctx = nullptr;
+ 	AVCodecContext *m_codec_ctx = nullptr;
+-	AVFrame *m_frame = nullptr;
+ 	int m_stream_index = -1;
+ 	std::string m_error;
+ 	int m_error_code = 0;
+-	bool m_finished = false;
+ 	bool m_opened = false;
+-	int m_got_frame = 0;
+-	AVPacket m_packet;
+-	AVPacket m_packet0;
++	bool m_has_more_packets = true;
++	bool m_has_more_frames = true;
++	AVPacket *m_packet = nullptr;
++	AVFrame *m_frame = nullptr;
+
+ 	int m_output_sample_rate = 0;
+ 	int m_output_channels = 0;
+@@ -98,19 +97,12 @@ private:
+
+ inline FFmpegAudioReader::FFmpegAudioReader() {
+ 	av_log_set_level(AV_LOG_QUIET);
+-
+-	av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
+ }
+
+ inline FFmpegAudioReader::~FFmpegAudioReader() {
+ 	Close();
+ 	av_dict_free(&m_input_opts);
+ 	av_freep(&m_convert_buffer[0]);
+-	av_packet_unref(&m_packet0);
+ }
+
+ inline bool FFmpegAudioReader::SetInputFormat(const char *name) {
+@@ -135,11 +127,10 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ 	Close();
+
+-    av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
++	m_packet = av_packet_alloc();
++	if (!m_packet) {
++		return false;
++	}
+
+ 	ret = avformat_open_input(&m_format_ctx, file_name.c_str(), m_input_fmt, &m_input_opts);
+ 	if (ret < 0) {
+@@ -153,26 +144,31 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		return false;
+ 	}
+
+-	AVCodec *codec;
++	const AVCodec *codec;
+ 	ret = av_find_best_stream(m_format_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &codec, 0);
+ 	if (ret < 0) {
+ 		SetError("Could not find any audio stream in the file", ret);
+ 		return false;
+ 	}
+ 	m_stream_index = ret;
++	auto stream = m_format_ctx->streams[m_stream_index];
+
+-	m_codec_ctx = m_format_ctx->streams[m_stream_index]->codec;
++	m_codec_ctx = avcodec_alloc_context3(codec);
+ 	m_codec_ctx->request_sample_fmt = AV_SAMPLE_FMT_S16;
+
++	ret = avcodec_parameters_to_context(m_codec_ctx, stream->codecpar);
++	if (ret < 0) {
++		SetError("Could not copy the stream parameters", ret);
++		return false;
++	}
++
+ 	ret = avcodec_open2(m_codec_ctx, codec, nullptr);
+ 	if (ret < 0) {
+ 		SetError("Could not open the codec", ret);
+ 		return false;
+ 	}
+
+-	if (!m_codec_ctx->channel_layout) {
+-		m_codec_ctx->channel_layout = av_get_default_channel_layout(m_codec_ctx->channels);
+-	}
++	av_dump_format(m_format_ctx, 0, "foo", 0);
+
+ 	m_frame = av_frame_alloc();
+ 	if (!m_frame) {
+@@ -183,19 +179,23 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		m_output_sample_rate = m_codec_ctx->sample_rate;
+ 	}
+
+-	if (!m_output_channels) {
+-		m_output_channels = m_codec_ctx->channels;
++	AVChannelLayout output_channel_layout;
++	if (m_output_channels) {
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
++	} else {
++		m_output_channels = m_codec_ctx->ch_layout.nb_channels;
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
+ 	}
+
+-	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
++	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->ch_layout.nb_channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
+ 		m_converter.reset(new FFmpegAudioProcessor());
+ 		m_converter->SetCompatibleMode();
+ 		m_converter->SetInputSampleFormat(m_codec_ctx->sample_fmt);
+ 		m_converter->SetInputSampleRate(m_codec_ctx->sample_rate);
+-		m_converter->SetInputChannelLayout(m_codec_ctx->channel_layout);
++		m_converter->SetInputChannelLayout(&(m_codec_ctx->ch_layout));
+ 		m_converter->SetOutputSampleFormat(AV_SAMPLE_FMT_S16);
+ 		m_converter->SetOutputSampleRate(m_output_sample_rate);
+-		m_converter->SetOutputChannelLayout(av_get_default_channel_layout(m_output_channels));
++		m_converter->SetOutputChannelLayout(&output_channel_layout);
+ 		auto ret = m_converter->Init();
+ 		if (ret != 0) {
+ 			SetError("Could not create an audio converter instance", ret);
+@@ -203,10 +203,11 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		}
+ 	}
+
++	av_channel_layout_uninit(&output_channel_layout);
++
+ 	m_opened = true;
+-	m_finished = false;
+-	m_got_frame = 0;
+-	m_nb_packets = 0;
++	m_has_more_packets = true;
++	m_has_more_frames = true;
+ 	m_decode_error = 0;
+
+ 	return true;
+@@ -214,6 +215,7 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ inline void FFmpegAudioReader::Close() {
+ 	av_frame_free(&m_frame);
++	av_packet_free(&m_packet);
+
+ 	m_stream_index = -1;
+
+@@ -252,91 +254,98 @@ inline bool FFmpegAudioReader::Read(const int16_t **data, size_t *size) {
+ 		return false;
+ 	}
+
++	*data = nullptr;
++	*size = 0;
++
+ 	int ret;
++	bool needs_packet = false;
+ 	while (true) {
+-		while (m_packet.size <= 0) {
+-			av_packet_unref(&m_packet0);
+-			av_init_packet(&m_packet);
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			ret = av_read_frame(m_format_ctx, &m_packet);
++		while (needs_packet && m_packet->size == 0) {
++			ret = av_read_frame(m_format_ctx, m_packet);
+ 			if (ret < 0) {
+ 				if (ret == AVERROR_EOF) {
+-					m_finished = true;
++					needs_packet = false;
++					m_has_more_packets = false;
+ 					break;
+-				} else {
++				}
++				SetError("Error reading from the audio source", ret);
++				return false;
++			}
++			if (m_packet->stream_index == m_stream_index) {
++				needs_packet = false;
++			} else {
++				av_packet_unref(m_packet);
++			}
++		}
++
++		if (m_packet->size != 0) {
++			ret = avcodec_send_packet(m_codec_ctx, m_packet);
++			if (ret < 0) {
++				if (ret != AVERROR(EAGAIN)) {
+ 					SetError("Error reading from the audio source", ret);
+ 					return false;
+ 				}
+-			}
+-			m_packet0 = m_packet;
+-			if (m_packet.stream_index != m_stream_index) {
+-				m_packet.data = nullptr;
+-				m_packet.size = 0;
+ 			} else {
+-				m_nb_packets++;
++				av_packet_unref(m_packet);
+ 			}
+ 		}
+
+-		ret = avcodec_decode_audio4(m_codec_ctx, m_frame, &m_got_frame, &m_packet);
++		ret = avcodec_receive_frame(m_codec_ctx, m_frame);
+ 		if (ret < 0) {
+-			if (m_decode_error) {
+-				SetError("Error decoding audio frame", m_decode_error);
+-				return false;
++			if (ret == AVERROR_EOF) {
++				m_has_more_frames = false;
++			} else if (ret == AVERROR(EAGAIN)) {
++				if (m_has_more_packets) {
++					needs_packet = true;
++					continue;
++				} else {
++					m_has_more_frames = false;
++				}
+ 			}
+-			m_decode_error = ret;
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			continue;
++			SetError("Error decoding the audio source", ret);
++			return false;
+ 		}
+
+-		break;
+-	}
+-
+-	m_decode_error = 0;
+-
+-	const int decoded = std::min(ret, m_packet.size);
+-	m_packet.data += decoded;
+-	m_packet.size -= decoded;
+-
+-	if (m_got_frame) {
+-		if (m_converter) {
+-			if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
+-				int linsize;
+-				av_freep(&m_convert_buffer[0]);
+-				m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
+-				ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
+-				if (ret < 0) {
+-					SetError("Couldn't allocate audio converter buffer", ret);
++		if (m_frame->nb_samples > 0) {
++			if (m_converter) {
++				if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
++					int linsize;
++					av_freep(&m_convert_buffer[0]);
++					m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
++					ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->ch_layout.nb_channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
++					if (ret < 0) {
++						SetError("Couldn't allocate audio converter buffer", ret);
++						return false;
++					}
++				}
++				auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
++				if (nb_samples < 0) {
++					SetError("Couldn't convert audio", ret);
+ 					return false;
+ 				}
+-			}
+-			auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			}
+-			*data = (const int16_t *) m_convert_buffer[0];
+-			*size = nb_samples;
+-		} else {
+-			*data = (const int16_t *) m_frame->data[0];
+-			*size = m_frame->nb_samples;
+-		}
+-	} else {
+-		if (m_finished && m_converter) {
+-			auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			} else if (nb_samples > 0) {
+-				m_got_frame = 1;
+ 				*data = (const int16_t *) m_convert_buffer[0];
+ 				*size = nb_samples;
++			} else {
++				*data = (const int16_t *) m_frame->data[0];
++				*size = m_frame->nb_samples;
++			}
++		} else {
++			if (m_converter) {
++				if (IsFinished()) {
++					auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
++					if (nb_samples < 0) {
++						SetError("Couldn't convert audio", ret);
++						return false;
++					} else if (nb_samples > 0) {
++						*data = (const int16_t *) m_convert_buffer[0];
++						*size = nb_samples;
++					}
++				}
+ 			}
+ 		}
+-	}
+
+-	return true;
++		return true;
++	}
+ }
+
+ inline void FFmpegAudioReader::SetError(const char *message, int errnum) {
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index a2b517b..123e643 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -38,6 +38,12 @@ set(SRCS
+
+ if(BUILD_TOOLS)
+ 	set(SRCS ${SRCS} ../src/audio/ffmpeg_audio_reader_test.cpp)
++    include_directories(
++        ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}
++        ${AUDIO_PROCESSOR_INCLUDE_DIRS}
++    )
+ 	link_libraries(fpcalc_libs)
+ endif()
+
+-- 
+2.38.1
+
+
diff --git a/srcpkgs/chromaprint/template b/srcpkgs/chromaprint/template
index 7ef7838949f3a3..1f7bbc70a22c80 100644
--- a/srcpkgs/chromaprint/template
+++ b/srcpkgs/chromaprint/template
@@ -1,7 +1,7 @@
 # Template file for 'chromaprint'
 pkgname=chromaprint
 version=1.5.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DBUILD_TOOLS=ON"
 make_check_target="check"

From 9e2308b2813e99c6eee26cf5e28b7d029554df57 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 021/110] chromium: revbump for ffmpeg6

---
 srcpkgs/chromium/patches/ffmpeg5.patch | 47 ++++++++++++++++++++++++++
 srcpkgs/chromium/template              |  2 +-
 2 files changed, 48 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..24e2da38e34ca2
--- /dev/null
+++ b/srcpkgs/chromium/patches/ffmpeg5.patch
@@ -0,0 +1,47 @@
+--- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
++++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
+@@ -92,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+-  if (stream->start_time != kNoFFmpegTimestamp)
++  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -1597,7 +1585,7 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+@@ -1618,7 +1606,7 @@
+     if (stream->type() != DemuxerStream::VIDEO)
+       continue;
+ 
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+ 
+     if (!stream->IsEnabled())
diff --git a/srcpkgs/chromium/template b/srcpkgs/chromium/template
index 53981f7cd367f8..b462de56fe3bf5 100644
--- a/srcpkgs/chromium/template
+++ b/srcpkgs/chromium/template
@@ -2,7 +2,7 @@
 pkgname=chromium
 # See https://chromiumdash.appspot.com/releases?platform=Linux for the latest version
 version=122.0.6261.94
-revision=1
+revision=2
 archs="i686* x86_64* aarch64* armv7l*"
 hostmakedepends="
  $(vopt_if clang "clang17 lld17 llvm17 compiler-rt")

From 428468bab193d90bce815e4b61284ded6feb3f16 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 022/110] cmus: revbump for ffmpeg6

---
 srcpkgs/chromium/patches/ffmpeg5.patch | 47 --------------------------
 srcpkgs/cmus/patches/ffmpeg6.patch     | 12 +++++++
 srcpkgs/cmus/template                  |  2 +-
 3 files changed, 13 insertions(+), 48 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch
 create mode 100644 srcpkgs/cmus/patches/ffmpeg6.patch

diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
deleted file mode 100644
index 24e2da38e34ca2..00000000000000
--- a/srcpkgs/chromium/patches/ffmpeg5.patch
+++ /dev/null
@@ -1,47 +0,0 @@
---- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
-+++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
-@@ -92,24 +92,12 @@
- 
- static base::TimeDelta ExtractStartTime(AVStream* stream) {
-   // The default start time is zero.
--  base::TimeDelta start_time;
-+  base::TimeDelta start_time = kNoTimestamp;
- 
-   // First try to use  the |start_time| value as is.
--  if (stream->start_time != kNoFFmpegTimestamp)
-+  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
-     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
- 
--  // Next try to use the first DTS value, for codecs where we know PTS == DTS
--  // (excludes all H26x codecs). The start time must be returned in PTS.
--  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
--      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
--      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
--      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
--    const base::TimeDelta first_pts =
--        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
--    if (first_pts < start_time)
--      start_time = first_pts;
--  }
--
-   return start_time;
- }
- 
-@@ -1597,7 +1585,7 @@
-   for (const auto& stream : streams_) {
-     if (!stream || stream->IsEnabled() != enabled)
-       continue;
--    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
-+    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
-       continue;
-     if (!lowest_start_time_stream ||
-         stream->start_time() < lowest_start_time_stream->start_time()) {
-@@ -1618,7 +1606,7 @@
-     if (stream->type() != DemuxerStream::VIDEO)
-       continue;
- 
--    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
-+    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
-       continue;
- 
-     if (!stream->IsEnabled())
diff --git a/srcpkgs/cmus/patches/ffmpeg6.patch b/srcpkgs/cmus/patches/ffmpeg6.patch
new file mode 100644
index 00000000000000..ffa95ab811101b
--- /dev/null
+++ b/srcpkgs/cmus/patches/ffmpeg6.patch
@@ -0,0 +1,12 @@
+--- a/ip/ffmpeg.c
++++ b/ip/ffmpeg.c
+@@ -202,9 +202,6 @@ static int ffmpeg_open(struct input_plugin_data *ip_data)
+ 			break;
+ 		}
+ 
+-		if (codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+-			cc->flags |= AV_CODEC_FLAG_TRUNCATED;
+-
+ 		if (avcodec_open2(cc, codec, NULL) < 0) {
+ 			d_print("could not open codec: %d, %s\n", cc->codec_id, avcodec_get_name(cc->codec_id));
+ 			err = -IP_ERROR_UNSUPPORTED_FILE_TYPE;
diff --git a/srcpkgs/cmus/template b/srcpkgs/cmus/template
index 0d1436744f1b2c..a6e4b4fa86cb83 100644
--- a/srcpkgs/cmus/template
+++ b/srcpkgs/cmus/template
@@ -1,7 +1,7 @@
 # Template file for 'cmus'
 pkgname=cmus
 version=2.10.0
-revision=3
+revision=4
 build_style=configure
 configure_args="prefix=/usr LD=$CC"
 hostmakedepends="pkg-config"

From ca42c64411168e84e948380fa13bc9442c046bc2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 023/110] cyanrip: revbump for ffmpeg6

---
 srcpkgs/cyanrip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cyanrip/template b/srcpkgs/cyanrip/template
index 9796e3461601a7..5db30e020d17ee 100644
--- a/srcpkgs/cyanrip/template
+++ b/srcpkgs/cyanrip/template
@@ -1,7 +1,7 @@
 # Template file for 'cyanrip'
 pkgname=cyanrip
 version=0.9.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config"
 makedepends="ffmpeg-devel libcdio-devel libcdio-paranoia-devel libcurl-devel libmusicbrainz5-devel"

From 52f45c86904c0bd88e2639ce9a9e819c3218ab99 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 024/110] deadbeef: revbump for ffmpeg4

---
 srcpkgs/deadbeef/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/deadbeef/template b/srcpkgs/deadbeef/template
index f5f4bf24b8cb6d..7b47e615cd48ef 100644
--- a/srcpkgs/deadbeef/template
+++ b/srcpkgs/deadbeef/template
@@ -1,14 +1,14 @@
 # Template file for 'deadbeef'
 pkgname=deadbeef
 version=1.8.8
-revision=3
+revision=4
 create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-oss --disable-lfm --disable-notify --disable-gtk2"
 hostmakedepends="automake libtool gettext gettext-devel intltool pkg-config
  yasm clang glib-devel"
 makedepends="
- alsa-lib-devel dbus-devel faad2-devel ffmpeg-devel gtk+3-devel imlib2-devel
+ alsa-lib-devel dbus-devel faad2-devel ffmpeg4-devel gtk+3-devel imlib2-devel
  jansson-devel libcddb-devel libcdio-devel libcurl-devel libflac-devel
  libmad-devel libpng-devel libsamplerate-devel libsndfile-devel libvorbis-devel
  libzip-devel mpg123-devel opusfile-devel pulseaudio-devel wavpack-devel"

From 4f451e60ef2aa9f0f7290a89c2cfada53d74f59e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 025/110] droidcam-obs-plugin: revbump for ffmpeg6

---
 srcpkgs/droidcam-obs-plugin/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam-obs-plugin/template b/srcpkgs/droidcam-obs-plugin/template
index fc9c9bf6b9d54c..fb0480754df4de 100644
--- a/srcpkgs/droidcam-obs-plugin/template
+++ b/srcpkgs/droidcam-obs-plugin/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam-obs-plugin'
 pkgname=droidcam-obs-plugin
 version=2.0.1
-revision=1
+revision=2
 build_style=gnu-makefile
 make_use_env=yes
 make_build_args="ALLOW_STATIC=no"

From 0f211de4b82af6ab5eb9dd05c52cbe147f0a4ec2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 026/110] droidcam: revbump for ffmpeg6

---
 srcpkgs/droidcam/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam/template b/srcpkgs/droidcam/template
index 1c3f1b8b1fc676..32a9220b79a4d1 100644
--- a/srcpkgs/droidcam/template
+++ b/srcpkgs/droidcam/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam'
 pkgname=droidcam
 version=1.8.2
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="USBMUXD=-lusbmuxd-2.0 JPEG=-lturbojpeg"
 hostmakedepends="pkg-config"

From 2a080e3c6492ca7b1ed7b061c4c2c6fe358fbe4c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 027/110] ffmpegthumbnailer: revbump for ffmpeg6

---
 .../ffmpegthumbnailer/patches/ffmpeg6.patch   | 202 ++++++++++++++++++
 srcpkgs/ffmpegthumbnailer/template            |   6 +-
 2 files changed, 205 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch

diff --git a/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
new file mode 100644
index 00000000000000..363ff35a28419d
--- /dev/null
+++ b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
@@ -0,0 +1,202 @@
+--- a/libffmpegthumbnailer/moviedecoder.cpp	2017-11-21 14:06:57.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.cpp	2023-05-05 13:14:47.946560668 -0400
+@@ -41,11 +41,6 @@
+ namespace ffmpegthumbnailer
+ {
+ 
+-struct SilenceLogLevel
+-{
+-    SilenceLogLevel() { av_log_set_level(AV_LOG_QUIET); }
+-};
+-
+ MovieDecoder::MovieDecoder(AVFormatContext* pavContext)
+ : m_VideoStream(-1)
+ , m_pFormatContext(pavContext)
+@@ -70,8 +65,6 @@
+ 
+ void MovieDecoder::initialize(const string& filename, bool preferEmbeddedMetadata)
+ {
+-    av_register_all();
+-    avcodec_register_all();
+     avformat_network_init();
+ 
+     string inputFile = filename == "-" ? "pipe:" : filename;
+@@ -97,8 +90,7 @@
+ {
+     if (m_pVideoCodecContext)
+     {
+-        avcodec_close(m_pVideoCodecContext);
+-        m_pVideoCodecContext = nullptr;
++        avcodec_free_context(&m_pVideoCodecContext);
+     }
+ 
+     if ((!m_FormatContextWasGiven) && m_pFormatContext)
+@@ -152,10 +144,10 @@
+     for (unsigned int i = 0; i < m_pFormatContext->nb_streams; ++i)
+     {
+         AVStream *stream = m_pFormatContext->streams[i];
+-        auto ctx = m_pFormatContext->streams[i]->codec;
+-        if (ctx->codec_type == AVMEDIA_TYPE_VIDEO)
++        auto par = m_pFormatContext->streams[i]->codecpar;
++        if (par->codec_type == AVMEDIA_TYPE_VIDEO)
+         {
+-            if (!preferEmbeddedMetadata || !isStillImageCodec(ctx->codec_id))
++            if (!preferEmbeddedMetadata || !isStillImageCodec(par->codec_id))
+             {
+                 videoStreams.push_back(i);
+                 continue;
+@@ -203,8 +195,7 @@
+     }
+ 
+     m_pVideoStream = m_pFormatContext->streams[m_VideoStream];
+-    m_pVideoCodecContext = m_pVideoStream->codec;
+-    m_pVideoCodec = avcodec_find_decoder(m_pVideoCodecContext->codec_id);
++    m_pVideoCodec = avcodec_find_decoder(m_pVideoStream->codecpar->codec_id);
+ 
+     if (m_pVideoCodec == nullptr)
+     {
+@@ -214,6 +205,20 @@
+         throw logic_error("Video Codec not found");
+     }
+ 
++    m_pVideoCodecContext = avcodec_alloc_context3(m_pVideoCodec);
++
++    if (m_pVideoCodecContext == nullptr)
++    {
++        destroy();
++        throw logic_error("Could not allocate video codec context");
++    }
++
++    if (avcodec_parameters_to_context(m_pVideoCodecContext, m_pVideoStream->codecpar) < 0)
++    {
++        destroy();
++        throw logic_error("Could not configure video codec context");
++    }
++
+     m_pVideoCodecContext->workaround_bugs = 1;
+ 
+     if (avcodec_open2(m_pVideoCodecContext, m_pVideoCodec, nullptr) < 0)
+@@ -386,13 +391,6 @@
+ 
+ void MovieDecoder::initializeFilterGraph(const AVRational& timeBase, const std::string& size, bool maintainAspectRatio)
+ {
+-    static const AVPixelFormat pixelFormats[] = { AV_PIX_FMT_RGB24, AV_PIX_FMT_NONE };
+-
+-    auto del = [] (AVBufferSinkParams* p) { av_freep(p); };
+-    std::unique_ptr<AVBufferSinkParams, decltype(del)> buffersinkParams(av_buffersink_params_alloc(), del);
+-
+-    avfilter_register_all();
+-
+     m_pFilterGraph = avfilter_graph_alloc();
+     assert(m_pFilterGraph);
+ 
+@@ -404,10 +402,8 @@
+ 
+     checkRc(avfilter_graph_create_filter(&m_pFilterSource, avfilter_get_by_name("buffer"), "thumb_buffer", ss.str().c_str(), nullptr, m_pFilterGraph),
+             "Failed to create filter source");
+-    buffersinkParams->pixel_fmts = pixelFormats;
+-    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, buffersinkParams.get(), m_pFilterGraph),
++    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, nullptr, m_pFilterGraph),
+             "Failed to create filter sink");
+-    buffersinkParams.release();
+ 
+     AVFilterContext* yadifFilter = nullptr;
+     if (m_pFrame->interlaced_frame != 0)
+@@ -500,15 +496,15 @@
+     }
+ 
+     checkRc(av_seek_frame(m_pFormatContext, -1, timestamp, 0), "Seeking in video failed");
+-    avcodec_flush_buffers(m_pFormatContext->streams[m_VideoStream]->codec);
++    avcodec_flush_buffers(m_pVideoCodecContext);
+ 
+     int keyFrameAttempts = 0;
+-    bool gotFrame = 0;
++    bool gotFrame;
+ 
+     do
+     {
+         int count = 0;
+-        gotFrame = 0;
++        gotFrame = false;
+ 
+         while (!gotFrame && count < 20)
+         {
+@@ -552,17 +548,33 @@
+         return false;
+     }
+ 
+-    av_frame_unref(m_pFrame);
+-
+-    int frameFinished;
++    int rc = avcodec_send_packet(m_pVideoCodecContext, m_pPacket);
++    if(rc == AVERROR(EAGAIN))
++    {
++        rc = 0;
++    }
+ 
+-    int bytesDecoded = avcodec_decode_video2(m_pVideoCodecContext, m_pFrame, &frameFinished, m_pPacket);
+-    if (bytesDecoded < 0)
++    if(rc == AVERROR_EOF)
++    {
++        return false;
++    }
++    else if(rc < 0)
+     {
+-        throw logic_error("Failed to decode video frame: bytesDecoded < 0");
++        throw logic_error("Failed to decode video frame: avcodec_send_packet() < 0");
+     }
+ 
+-    return frameFinished > 0;
++    rc = avcodec_receive_frame(m_pVideoCodecContext, m_pFrame);
++    switch(rc)
++    {
++        case 0:
++            return true;
++
++        case AVERROR(EAGAIN):
++            return false;
++
++        default:
++            throw logic_error("Failed to decode video frame: avcodec_receive_frame() < 0");
++    }
+ }
+ 
+ bool MovieDecoder::getVideoPacket()
+@@ -570,8 +582,6 @@
+     bool framesAvailable = true;
+     bool frameDecoded = false;
+ 
+-    int attempts = 0;
+-
+     if (m_pPacket)
+     {
+         av_packet_unref(m_pPacket);
+@@ -580,6 +590,7 @@
+ 
+     m_pPacket = new AVPacket();
+ 
++
+     while (framesAvailable && !frameDecoded)
+     {
+         framesAvailable = av_read_frame(m_pFormatContext, m_pPacket) >= 0;
+@@ -644,7 +655,7 @@
+ 
+ int32_t MovieDecoder::getStreamRotation()
+ {
+-    int32_t* matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
++    auto matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
+     if (matrix)
+     {
+         auto angle = lround(av_display_rotation_get(matrix));
+
+--- a/libffmpegthumbnailer/moviedecoder.h	2017-11-12 04:23:38.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.h	2023-05-05 13:26:07.095529911 -0400
+@@ -78,7 +78,7 @@
+     int                     m_VideoStream;
+     AVFormatContext*        m_pFormatContext;
+     AVCodecContext*         m_pVideoCodecContext;
+-    AVCodec*                m_pVideoCodec;
++    const AVCodec*          m_pVideoCodec;
+     AVFilterGraph*          m_pFilterGraph;
+     AVFilterContext*        m_pFilterSource;
+     AVFilterContext*        m_pFilterSink;
diff --git a/srcpkgs/ffmpegthumbnailer/template b/srcpkgs/ffmpegthumbnailer/template
index 039eea7622b391..35d546018d12af 100644
--- a/srcpkgs/ffmpegthumbnailer/template
+++ b/srcpkgs/ffmpegthumbnailer/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbnailer'
 pkgname=ffmpegthumbnailer
 version=2.2.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libpng-devel libjpeg-turbo-devel ffmpeg-devel"
@@ -9,8 +9,8 @@ depends="ffmpeg"
 short_desc="Lightweight video thumbnailer"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
-homepage="https://github.com/dirkvdb/${pkgname}"
-distfiles="${homepage}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
+homepage="https://github.com/dirkvdb"
+distfiles="${homepage}/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
 checksum=1cb24059c38223f657b300c84dd80491b7040d4b69471c4fea69be862bc99b5b
 
 post_install() {

From 930624d85a701829554faaf08668dd27868f24da Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 028/110] ffmpegthumbs: revbump for ffmpeg6

---
 srcpkgs/ffmpegthumbs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ffmpegthumbs/template b/srcpkgs/ffmpegthumbs/template
index 2e2a96de83ce8a..dfd7e9dede36d3 100644
--- a/srcpkgs/ffmpegthumbs/template
+++ b/srcpkgs/ffmpegthumbs/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbs'
 pkgname=ffmpegthumbs
 version=23.08.5
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules kcoreaddons kconfig-devel
  pkg-config qt5-host-tools qt5-qmake gettext"

From 433f39df79edc86057d8d4f12ae033f24b46b6f2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 029/110] ffms2: revbump for ffmpeg6

---
 srcpkgs/ffms2/patches/ffmpeg5.patch | 424 ++++++++++++++++++++++++++++
 srcpkgs/ffms2/template              |   2 +-
 2 files changed, 425 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ffms2/patches/ffmpeg5.patch

diff --git a/srcpkgs/ffms2/patches/ffmpeg5.patch b/srcpkgs/ffms2/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..1479fabcafcb4e
--- /dev/null
+++ b/srcpkgs/ffms2/patches/ffmpeg5.patch
@@ -0,0 +1,424 @@
+From 45673149e9a2f5586855ad472e3059084eaa36b1 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:41:21 +0100
+Subject: [PATCH] Use auto for AVCodec
+
+The geniuses over at FFmpeg decided to constify this API, so old
+versions of the library will return AVCodec *, while new versions
+of the libary will return const AVCodec *, which, in C++, are not
+OK to convert between.
+
+Rather than use some macro hell in ffmscompat.h, we can work around
+this by using auto.
+
+Gross.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 2 +-
+ src/core/indexing.cpp    | 6 +++---
+ src/core/videosource.cpp | 2 +-
+ 3 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index e4ce97c..ac09666 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -469,7 +469,7 @@ void FFMS_AudioSource::OpenFile() {
+ 
+     LAVFOpenFile(SourceFile.c_str(), FormatContext, TrackNumber);
+ 
+-    AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
++    auto *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
+     if (Codec == nullptr)
+         throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+             "Audio codec not found");
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index e547c5a..59fb4e8 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -384,7 +384,7 @@ FFMS_TrackType FFMS_Indexer::GetTrackType(int Track) {
+ }
+ 
+ const char *FFMS_Indexer::GetTrackCodec(int Track) {
+-    AVCodec *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
++    auto *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
+     return codec ? codec->name : nullptr;
+ }
+ 
+@@ -402,7 +402,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             UseDTS);
+ 
+         if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            AVCodec *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (!VideoCodec) {
+                 FormatContext->streams[i]->discard = AVDISCARD_ALL;
+                 IndexMask.erase(i);
+@@ -433,7 +433,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 IndexMask.insert(i);
+             }
+         } else if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+-            AVCodec *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (AudioCodec == nullptr)
+                 throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_UNSUPPORTED,
+                     "Audio codec not found");
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index b889970..8956c22 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -171,7 +171,7 @@ FFMS_VideoSource::FFMS_VideoSource(const char *SourceFile, FFMS_Index &Index, in
+ 
+         LAVFOpenFile(SourceFile, FormatContext, VideoTrack);
+ 
+-        AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
++        auto *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
+         if (Codec == nullptr)
+             throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+                 "Video codec not found");
+-- 
+2.40.0
+
+From 96cbf38ea9381829a1314f432a2c60495dcefaad Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:12:41 +0100
+Subject: [PATCH] all: Update AVPacket API usage
+
+AVPackets must all be on the heap now, since it is no longer
+part of the libav* ABI.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 16 ++++++----
+ src/core/indexing.cpp    | 63 ++++++++++++++++++++++------------------
+ src/core/indexing.h      |  4 +--
+ src/core/utils.cpp       |  6 ----
+ src/core/utils.h         |  1 -
+ src/core/videosource.cpp | 30 ++++++++++---------
+ 6 files changed, 64 insertions(+), 56 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index 37cf9ae..e4ce97c 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -285,10 +285,15 @@ FFMS_AudioSource::AudioBlock *FFMS_AudioSource::CacheBlock(CacheIterator &pos) {
+ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     CurrentFrame = &Frames[PacketNumber];
+ 
+-    AVPacket Packet;
+-    if (!ReadPacket(&Packet))
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++    if (!ReadPacket(Packet)) {
++        av_packet_free(&Packet);
+         throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_UNKNOWN,
+             "ReadPacket unexpectedly failed to read a packet");
++    }
+ 
+     // ReadPacket may have changed the packet number
+     CurrentFrame = &Frames[PacketNumber];
+@@ -297,8 +302,9 @@ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     int NumberOfSamples = 0;
+     AudioBlock *CachedBlock = nullptr;
+     
+-    int Ret = avcodec_send_packet(CodecContext, &Packet);
+-    av_packet_unref(&Packet);
++    int Ret = avcodec_send_packet(CodecContext, Packet);
++    av_packet_unref(Packet);
++    av_packet_free(&Packet);
+ 
+     av_frame_unref(DecodeFrame);
+     Ret = avcodec_receive_frame(CodecContext, DecodeFrame);
+@@ -513,8 +519,6 @@ void FFMS_AudioSource::Seek() {
+ }
+ 
+ bool FFMS_AudioSource::ReadPacket(AVPacket *Packet) {
+-    InitNullPacket(*Packet);
+-
+     while (av_read_frame(FormatContext, Packet) >= 0) {
+         if (Packet->stream_index == TrackNumber) {
+             // Required because not all audio packets, especially in ogg, have a pts. Use the previous valid packet's pts instead.
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index 23fb95b..e547c5a 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -320,7 +320,7 @@ void FFMS_Indexer::CheckAudioProperties(int Track, AVCodecContext *Context) {
+     }
+ }
+ 
+-void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict,
++void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict,
+                                     int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct) {
+     if (VideoContext.Parser) {
+         uint8_t *OB;
+@@ -330,8 +330,8 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+         av_parser_parse2(VideoContext.Parser,
+             VideoContext.CodecContext,
+             &OB, &OBSize,
+-            pkt.data, pkt.size,
+-            pkt.pts, pkt.dts, pkt.pos);
++            pkt->data, pkt->size,
++            pkt->pts, pkt->dts, pkt->pos);
+ 
+         // H.264 (PAFF) and HEVC may have one field per packet, so we need to track
+         // when we have a full or half frame available, and mark one of them as
+@@ -351,15 +351,15 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+ 
+         *RepeatPict = VideoContext.Parser->repeat_pict;
+         *FrameType = VideoContext.Parser->pict_type;
+-        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt.flags & AV_PKT_FLAG_DISCARD));
++        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt->flags & AV_PKT_FLAG_DISCARD));
+     } else {
+-        *Invisible = !!(pkt.flags & AV_PKT_FLAG_DISCARD);
++        *Invisible = !!(pkt->flags & AV_PKT_FLAG_DISCARD);
+     }
+ 
+     if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP8)
+-        ParseVP8(pkt.data[0], Invisible, FrameType);
++        ParseVP8(pkt->data[0], Invisible, FrameType);
+     else if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP9)
+-        ParseVP9(pkt.data[0], Invisible, FrameType);
++        ParseVP9(pkt->data[0], Invisible, FrameType);
+ }
+ 
+ void FFMS_Indexer::Free() {
+@@ -458,32 +458,36 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+         }
+     }
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
+     std::vector<int64_t> LastValidTS(FormatContext->nb_streams, AV_NOPTS_VALUE);
+ 
+     int64_t filesize = avio_size(FormatContext->pb);
+     enum AVPictureStructure LastPicStruct = AV_PICTURE_STRUCTURE_UNKNOWN;
+-    while (av_read_frame(FormatContext, &Packet) >= 0) {
++    while (av_read_frame(FormatContext, Packet) >= 0) {
+         // Update progress
+         // FormatContext->pb can apparently be NULL when opening images.
+         if (IC && FormatContext->pb) {
+-            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate))
++            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate)) {
++                av_packet_free(&Packet);
+                 throw FFMS_Exception(FFMS_ERROR_CANCELLED, FFMS_ERROR_USER,
+                     "Cancelled by user");
++            }
+         }
+-        if (!IndexMask.count(Packet.stream_index)) {
+-            av_packet_unref(&Packet);
++        if (!IndexMask.count(Packet->stream_index)) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+-        int Track = Packet.stream_index;
++        int Track = Packet->stream_index;
+         FFMS_Track &TrackInfo = (*TrackIndices)[Track];
+-        bool KeyFrame = !!(Packet.flags & AV_PKT_FLAG_KEY);
++        bool KeyFrame = !!(Packet->flags & AV_PKT_FLAG_KEY);
+         ReadTS(Packet, LastValidTS[Track], (*TrackIndices)[Track].UseDTS);
+ 
+         if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            int64_t PTS = TrackInfo.UseDTS ? Packet.dts : Packet.pts;
++            int64_t PTS = TrackInfo.UseDTS ? Packet->dts : Packet->pts;
+             if (PTS == AV_NOPTS_VALUE) {
+                 // VPx alt-refs are output as packets which lack timestmps or durations, since
+                 // they are invisible. Currently, the timestamp mangling code in libavformat
+@@ -495,9 +499,11 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 // FFMS2 currently sorts packets by PTS, which will break decoding, otherwise.
+                 bool HasAltRefs = (FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP8 ||
+                                    FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP9);
+-                if (Packet.duration == 0 && !HasAltRefs)
++                if (Packet->duration == 0 && !HasAltRefs) {
++                    av_packet_free(&Packet);
+                     throw FFMS_Exception(FFMS_ERROR_INDEXING, FFMS_ERROR_PARSER,
+                         "Invalid packet pts, dts, and duration");
++                }
+ 
+                 if (TrackInfo.empty())
+                     PTS = 0;
+@@ -513,7 +519,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             ParseVideoPacket(AVContexts[Track], Packet, &RepeatPict, &FrameType, &Invisible, &LastPicStruct);
+ 
+             TrackInfo.AddVideoFrame(PTS, RepeatPict, KeyFrame,
+-                FrameType, Packet.pos, Invisible);
++                FrameType, Packet->pos, Invisible);
+         } else if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+             // For video seeking timestamps are used only if all packets have
+             // timestamps, while for audio they're used if any have timestamps,
+@@ -522,28 +528,29 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 TrackInfo.HasTS = true;
+ 
+             int64_t StartSample = AVContexts[Track].CurrentSample;
+-            uint32_t SampleCount = IndexAudioPacket(Track, &Packet, AVContexts[Track], *TrackIndices);
++            uint32_t SampleCount = IndexAudioPacket(Track, Packet, AVContexts[Track], *TrackIndices);
+             TrackInfo.SampleRate = AVContexts[Track].CodecContext->sample_rate;
+ 
+             TrackInfo.AddAudioFrame(LastValidTS[Track],
+-                StartSample, SampleCount, KeyFrame, Packet.pos, Packet.flags & AV_PKT_FLAG_DISCARD);
++                StartSample, SampleCount, KeyFrame, Packet->pos, Packet->flags & AV_PKT_FLAG_DISCARD);
+         }
+ 
+-        if (!(Packet.flags & AV_PKT_FLAG_DISCARD))
+-            TrackInfo.LastDuration = Packet.duration;
++        if (!(Packet->flags & AV_PKT_FLAG_DISCARD))
++            TrackInfo.LastDuration = Packet->duration;
+ 
+-        av_packet_unref(&Packet);
++        av_packet_unref(Packet);
+     }
++    av_packet_free(&Packet);
+ 
+     TrackIndices->Finalize(AVContexts, FormatContext->iformat->name);
+     return TrackIndices.release();
+ }
+ 
+-void FFMS_Indexer::ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS) {
+-    if (!UseDTS && Packet.pts != AV_NOPTS_VALUE)
+-        TS = Packet.pts;
++void FFMS_Indexer::ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS) {
++    if (!UseDTS && Packet->pts != AV_NOPTS_VALUE)
++        TS = Packet->pts;
+     if (TS == AV_NOPTS_VALUE)
+         UseDTS = true;
+-    if (UseDTS && Packet.dts != AV_NOPTS_VALUE)
+-        TS = Packet.dts;
++    if (UseDTS && Packet->dts != AV_NOPTS_VALUE)
++        TS = Packet->dts;
+ }
+diff --git a/src/core/indexing.h b/src/core/indexing.h
+index 3cfc3c3..5c06868 100644
+--- a/src/core/indexing.h
++++ b/src/core/indexing.h
+@@ -80,10 +80,10 @@ private:
+     int64_t Filesize;
+     uint8_t Digest[20];
+ 
+-    void ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS);
++    void ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS);
+     void CheckAudioProperties(int Track, AVCodecContext *Context);
+     uint32_t IndexAudioPacket(int Track, AVPacket *Packet, SharedAVContext &Context, FFMS_Index &TrackIndices);
+-    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
++    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
+     void Free();
+ public:
+     FFMS_Indexer(const char *Filename);
+diff --git a/src/core/utils.cpp b/src/core/utils.cpp
+index ce67533..8a2e997 100644
+--- a/src/core/utils.cpp
++++ b/src/core/utils.cpp
+@@ -62,12 +62,6 @@ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo) {
+     }
+ }
+ 
+-void InitNullPacket(AVPacket &pkt) {
+-    av_init_packet(&pkt);
+-    pkt.data = nullptr;
+-    pkt.size = 0;
+-}
+-
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames) {
+     AP.SampleFormat = static_cast<FFMS_SampleFormat>(av_get_packed_sample_fmt(CTX->sample_fmt));
+     AP.BitsPerSample = av_get_bytes_per_sample(CTX->sample_fmt) * 8;
+diff --git a/src/core/utils.h b/src/core/utils.h
+index 9819dc7..003ab79 100644
+--- a/src/core/utils.h
++++ b/src/core/utils.h
+@@ -58,7 +58,6 @@ std::unique_ptr<T> make_unique(Args&&... args) {
+ }
+ 
+ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo);
+-void InitNullPacket(AVPacket &pkt);
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames);
+ 
+ void LAVFOpenFile(const char *SourceFile, AVFormatContext *&FormatContext, int Track);
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index 06bd161..b889970 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -673,30 +673,34 @@ void FFMS_VideoSource::DecodeNextFrame(int64_t &AStartTime, int64_t &Pos) {
+     if (HasPendingDelayedFrames())
+         return;
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
+-
+-    while (ReadFrame(&Packet) >= 0) {
+-        if (Packet.stream_index != VideoTrack) {
+-            av_packet_unref(&Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++
++    while (ReadFrame(Packet) >= 0) {
++        if (Packet->stream_index != VideoTrack) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+         if (AStartTime < 0)
+-            AStartTime = Frames.UseDTS ? Packet.dts : Packet.pts;
++            AStartTime = Frames.UseDTS ? Packet->dts : Packet->pts;
+ 
+         if (Pos < 0)
+-            Pos = Packet.pos;
++            Pos = Packet->pos;
+ 
+-        bool FrameFinished = DecodePacket(&Packet);
+-        av_packet_unref(&Packet);
+-        if (FrameFinished)
++        bool FrameFinished = DecodePacket(Packet);
++        av_packet_unref(Packet);
++        if (FrameFinished) {
++            av_packet_free(&Packet);
+             return;
++        }
+     }
+ 
+     // Flush final frames
+-    InitNullPacket(Packet);
+-    DecodePacket(&Packet);
++    DecodePacket(Packet);
++    av_packet_free(&Packet);
+ }
+ 
+ bool FFMS_VideoSource::SeekTo(int n, int SeekOffset) {
+-- 
+2.40.0
+
+From bf9e03e9e08534c024e5a744a6437c4aac160201 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:20:47 +0100
+Subject: [PATCH 2/3] configure: Remove deprecated API use
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ configure.ac | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index b35ef80bc..d19714d0f 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -102,10 +102,10 @@ CFLAGS="$_CFLAGS $FFMPEG_CFLAGS"
+
+ AC_DEFUN([TEST_FFMPEG],
+          [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+-            #include <libavcodec/avcodec.h>
++            #include <libavformat/avformat.h>
+             #include <libswscale/swscale.h>
+             ]],[[
+-                avcodec_register_all();
++                avformat_network_init();
+                 swscale_version();
+             ]])], [eval $1=yes], [eval $1=no])
+         ])
+
diff --git a/srcpkgs/ffms2/template b/srcpkgs/ffms2/template
index 365f64d10cbabf..1641ecf43be5bb 100644
--- a/srcpkgs/ffms2/template
+++ b/srcpkgs/ffms2/template
@@ -1,7 +1,7 @@
 # Template file for 'ffms2'
 pkgname=ffms2
 version=2.40
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-shared --disable-static"
 hostmakedepends="pkg-config autoconf automake libtool"

From dbc24d8310cf3223aa57d1c73efb15bb14129a85 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 030/110] freerdp: revbump for ffmpeg6

---
 .../freerdp/patches/ffmpeg6_aa2cb9aa.patch    | 42 +++++++++++++++++++
 srcpkgs/freerdp/template                      |  2 +-
 2 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch

diff --git a/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
new file mode 100644
index 00000000000000..a4324da3a8822b
--- /dev/null
+++ b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
@@ -0,0 +1,42 @@
+From aa2cb9aa5ff5562433598ba168a466e0752bca0e Mon Sep 17 00:00:00 2001
+From: akallabeth <akallabeth@posteo.net>
+Date: Tue, 14 Feb 2023 07:48:54 +0100
+Subject: [PATCH] Fixed #8686: Update h264 to use new FFMPEG API
+
+---
+ channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c | 2 ++
+ libfreerdp/codec/h264_ffmpeg.c            | 2 ++
+ 2 files changed, 4 insertions(+)
+
+diff --git a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+index 339462d865f..beea80b7a1e 100644
+--- a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
++++ b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+@@ -239,8 +239,10 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYP
+ 		}
+ 	}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 	if (mdecoder->codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		mdecoder->codec_context->flags |= AV_CODEC_FLAG_TRUNCATED;
++#endif
+ 
+ 	return TRUE;
+ }
+diff --git a/libfreerdp/codec/h264_ffmpeg.c b/libfreerdp/codec/h264_ffmpeg.c
+index 8a23db2473c..896a333019b 100644
+--- a/libfreerdp/codec/h264_ffmpeg.c
++++ b/libfreerdp/codec/h264_ffmpeg.c
+@@ -615,10 +615,12 @@ static BOOL libavcodec_init(H264_CONTEXT* h264)
+ 			goto EXCEPTION;
+ 		}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 		if (sys->codecDecoder->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		{
+ 			sys->codecDecoderContext->flags |= AV_CODEC_FLAG_TRUNCATED;
+ 		}
++#endif
+ 
+ #ifdef WITH_VAAPI
+ 
diff --git a/srcpkgs/freerdp/template b/srcpkgs/freerdp/template
index 16fddfbe8f5287..bf3a4d2e2b3ae7 100644
--- a/srcpkgs/freerdp/template
+++ b/srcpkgs/freerdp/template
@@ -1,7 +1,7 @@
 # Template file for 'freerdp'
 pkgname=freerdp
 version=2.11.4
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_ALSA=ON -DWITH_CUPS=OFF -DWITH_FFMPEG=ON
  -DWITH_GSTREAMER_0_10=OFF -DWITH_GSTREAMER_1_0=OFF -DWITH_JPEG=ON

From c740b9258fb96150c5c33f8d42780d131432fe28 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 031/110] gerbera: revbump for ffmpeg6

---
 srcpkgs/gerbera/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gerbera/template b/srcpkgs/gerbera/template
index ae14f35c767c03..2dc0ac0ce03b55 100644
--- a/srcpkgs/gerbera/template
+++ b/srcpkgs/gerbera/template
@@ -1,7 +1,7 @@
 # Template file for 'gerbera'
 pkgname=gerbera
 version=1.12.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_SYSTEMD=0 -DWITH_AVCODEC=1"
 hostmakedepends="pkg-config"

From 14ee73fbf867284eb7394dcea7724bd83be76ca5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 032/110] goldendict: revbump for ffmpeg6

---
 srcpkgs/goldendict/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/goldendict/template b/srcpkgs/goldendict/template
index f4a05759f693d3..97f44347b03a6a 100644
--- a/srcpkgs/goldendict/template
+++ b/srcpkgs/goldendict/template
@@ -1,7 +1,7 @@
 # Template file for 'goldendict'
 pkgname=goldendict
 version=1.5.0
-revision=1
+revision=2
 build_style=qmake
 configure_args="CONFIG+=zim_support goldendict.pro"
 hostmakedepends="qt5-qmake pkg-config qt5-host-tools"
@@ -10,7 +10,7 @@ makedepends="tiff-devel qt5-devel libvorbis-devel zlib-devel
  qt5-webkit-devel lzo-devel bzip2-devel libao-devel qt5-svg-devel
  libeb-devel qt5-x11extras-devel ffmpeg-devel liblzma-devel
  qt5-multimedia-devel"
-short_desc="A feature-rich dictionary lookup program"
+short_desc="Feature-rich dictionary lookup program"
 maintainer="John <me@johnnynator.dev>"
 license="GPL-3.0-or-later"
 homepage="http://goldendict.org/"

From fcf38c72a90965d70889c7eb287101a3a2e11587 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 033/110] gst-libav: revbump for ffmpeg6

---
 srcpkgs/gst-libav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index b24be23fc1a6d2..0f9350a251bf67 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.22.9
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"

From 774cc9ac796de7013c518dbd76be513c5e96170a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Feb 2024 01:52:46 -0500
Subject: [PATCH 034/110] gst-plugins-bad1: revbump for ffmpeg6

---
 srcpkgs/gst-plugins-bad1/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index 10dc49f4c151bc..b4a7f7367e7dff 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-plugins-bad1'
 pkgname=gst-plugins-bad1
 version=1.22.9
-revision=1
+revision=2
 build_helper="gir"
 build_style=meson
 configure_args="-Dpackage-origin=https://voidlinux.org -Ddoc=disabled
@@ -27,7 +27,7 @@ makedepends="alsa-lib-devel celt-devel openssl-devel exempi-devel
  fdk-aac-devel flite-devel fluidsynth-devel liblrdf-devel ladspa-sdk
  lilv-devel lv2 libopenjpeg2-devel sbc-devel spandsp-devel vulkan-loader
  Vulkan-Headers webrtc-audio-processing-devel libzbar-devel ffmpeg-devel
- srt-devel libva-devel
+ srt-devel libva-devel oneVPL-devel
  $(vopt_if gme libgme-devel)"
 depends="gst-plugins-base1>=${version}"
 short_desc="GStreamer plugins from the bad set (v1.x)"

From 56a51cedc49a17c081cd7e68875969660540b249 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 035/110] gst-rtsp-server: revbump for ffmpeg6

---
 srcpkgs/gst-rtsp-server/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index bc2a0dea6ac152..f77026c618eb69 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
 version=1.22.9
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="glib-devel gst-plugins-bad1-devel gobject-introspection

From 49796c2e7c8893067b72b12e9276a4a9a52f51ae Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 036/110] guvcview: update to 2.0.8.

---
 srcpkgs/guvcview/patches/fix-include.patch | 10 ++++++++++
 srcpkgs/guvcview/template                  |  7 +++----
 2 files changed, 13 insertions(+), 4 deletions(-)
 create mode 100644 srcpkgs/guvcview/patches/fix-include.patch

diff --git a/srcpkgs/guvcview/patches/fix-include.patch b/srcpkgs/guvcview/patches/fix-include.patch
new file mode 100644
index 00000000000000..503c2af3b78c1a
--- /dev/null
+++ b/srcpkgs/guvcview/patches/fix-include.patch
@@ -0,0 +1,10 @@
+--- a/guvcview/guvcview.c
++++ b/guvcview/guvcview.c
+@@ -28,6 +28,7 @@
+ #include <sys/stat.h>
+ #include <sys/resource.h>
+ #include <errno.h>
++#include <locale.h>
+ 
+ #include "gview.h"
+ #include "gviewv4l2core.h"
diff --git a/srcpkgs/guvcview/template b/srcpkgs/guvcview/template
index d42fd38fa4ad12..86a7fd619612c8 100644
--- a/srcpkgs/guvcview/template
+++ b/srcpkgs/guvcview/template
@@ -1,8 +1,7 @@
 # Template file for 'guvcview'
 pkgname=guvcview
-version=2.0.7
-revision=2
-create_wrksrc=yes
+version=2.0.8
+revision=1
 build_style=gnu-configure
 configure_args="--disable-static --disable-debian-menu"
 hostmakedepends="pkg-config intltool autoconf automake libtool glib-devel"
@@ -14,7 +13,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="http://guvcview.sourceforge.net/"
 distfiles="${SOURCEFORGE_SITE}/${pkgname}/${pkgname}-src-${version}.tar.bz2"
-checksum=f47d51fbd06e44eeaa1a82f4a153c927527c90d94514197a70b2956028cc8ad4
+checksum=a21f4e448286666cf27bafef5290cc953a0a1796b752e5bbe521266dc1230c81
 
 post_patch() {
 	sed '31a#include <locale.h>' -i  guvcview/guvcview.c

From 64844de2f3a09f522542902fae2ecf29951ec951 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 037/110] handbrake: update to 1.6.1

---
 .../patches/fix-missing-x265-link-flag.patch    | 11 ++++++-----
 .../handbrake/patches/libhb-vpl-include.patch   | 15 +++++++++++++++
 srcpkgs/handbrake/template                      | 17 ++++++++++-------
 3 files changed, 31 insertions(+), 12 deletions(-)
 create mode 100644 srcpkgs/handbrake/patches/libhb-vpl-include.patch

diff --git a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
index 26db03867a0c83..d6bb2eda627a36 100644
--- a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
+++ b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
@@ -1,14 +1,15 @@
 --- a/gtk/configure.ac
 +++ b/gtk/configure.ac
 @@ -203,7 +203,7 @@
- 
+
  AM_CONDITIONAL([MINGW], [test "x$mingw_flag" = "xyes"])
- 
--HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg"
-+HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -ldl"
+
+-HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc"
++HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc -ldl"
  HB_CPPFLAGS="$HB_CPPFLAGS $HBINC"
- 
+
  PKG_CHECK_MODULES([x264], [x264], sys_x264=yes, sys_x264=no)
+
 --- a/test/module.defs
 +++ b/test/module.defs
 @@ -69,6 +69,9 @@
diff --git a/srcpkgs/handbrake/patches/libhb-vpl-include.patch b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
new file mode 100644
index 00000000000000..298f9f4ab28f2a
--- /dev/null
+++ b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
@@ -0,0 +1,15 @@
+--- a/libhb/module.defs	2023-01-22 11:36:49.000000000 -0500
++++ b/libhb/module.defs	2023-04-03 22:37:52.395467010 -0400
+@@ -46,11 +46,7 @@
+ LIBHB.GCC.I += $(LIBHB.build/) $(CONTRIB.build/)include
+ 
+ ifeq (1,$(FEATURE.qsv))
+-    ifeq ($(HOST.system),freebsd))
+-        LIBHB.GCC.I += $(LOCALBASE)/include/vpl
+-    else
+-        LIBHB.GCC.I += $(CONTRIB.build/)include/vpl
+-    endif
++    LIBHB.GCC.I += /usr/include/vpl
+ endif
+ 
+ ifneq (,$(filter $(HOST.system),freebsd netbsd openbsd))
diff --git a/srcpkgs/handbrake/template b/srcpkgs/handbrake/template
index ca5e4571e49c37..c32cb1bfa31f4b 100644
--- a/srcpkgs/handbrake/template
+++ b/srcpkgs/handbrake/template
@@ -1,10 +1,10 @@
 # Template file for 'handbrake'
 pkgname=handbrake
-version=1.5.1
+version=1.6.1
 revision=1
 build_style=gnu-configure
 configure_args="--force --disable-gtk-update-checks --disable-df-fetch --harden
- $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc)"
+ $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc) $(vopt_enable qsv)"
 make_build_args="-C ${XBPS_TRIPLET}"
 make_install_args="-C ${XBPS_TRIPLET}"
 hostmakedepends="automake cmake gettext-devel glib-devel intltool libtool m4 meson nasm pkg-config python3"
@@ -12,8 +12,11 @@ makedepends="bzip2-devel ffmpeg-devel gst-plugins-base1-devel gtk+3-devel
  jansson-devel lame-devel libass-devel libbluray-devel libdav1d-devel
  libdvdnav-devel libdvdread-devel libgudev-devel libnuma-devel
  libsamplerate-devel libtheora-devel libvorbis-devel libvpx-devel libxml2-devel
- opus-devel speex-devel x264-devel x265-devel zimg-devel
+ opus-devel speex-devel x264-devel x265-devel zimg-devel libsvt-av1-devel
  $(vopt_if fdk_aac fdk-aac-devel)
+ $(vopt_if qsv libva-devel)
+ $(vopt_if qsv libdrm-devel)
+ $(vopt_if qsv onevpl-devel)
  $(vopt_if nvenc nv-codec-headers)"
 depends="desktop-file-utils gst-plugins-good1 hicolor-icon-theme"
 short_desc="Multithreaded video transcoder"
@@ -21,15 +24,15 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-2.0-only"
 homepage="https://handbrake.fr/"
 distfiles="https://github.com/HandBrake/HandBrake/releases/download/${version}/HandBrake-${version}-source.tar.bz2"
-checksum=3999fe06d5309c819799a73a968a8ec3840e7840c2b64af8f5cdb7fd8c9430f0
+checksum=94ccfe03db917a91650000c510f7fd53f844da19f19ad4b4be1b8f6bc31a8d4c
 nocross=yes
 
-build_options="fdk_aac nvenc"
+build_options="fdk_aac nvenc qsv"
 
 case "$XBPS_TARGET_MACHINE" in
 	x86_64*|i686*)
 		CFLAGS="-msse"
-		build_options_default="nvenc"
+		build_options_default="nvenc qsv"
 		;;
 esac
 
@@ -37,7 +40,7 @@ pre_configure() {
 	# use system libraries, don't download them
 	rm -rf contrib/
 	for module in fdk-aac ffmpeg libbluray libdav1d libdvdnav libdvdread nvenc \
-		x265 zimg; do
+		x265 zimg svt-av1 libvpl; do
 	    vsed -i "/MODULES += contrib\/${module}/d" make/include/main.defs
 	done
 }

From f3c5b099ee7ba8040c1d371fa16771f3e0ce6f09 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 038/110] hedgewars: revbump for ffmpeg4

---
 srcpkgs/hedgewars/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/hedgewars/template b/srcpkgs/hedgewars/template
index 94b6db673b0c3a..402ccfaaecbc2d 100644
--- a/srcpkgs/hedgewars/template
+++ b/srcpkgs/hedgewars/template
@@ -1,13 +1,13 @@
 # Template file for 'hedgewars'
 pkgname=hedgewars
 version=1.0.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DNOSERVER=1 -DDATA_INSTALL_DIR=/usr/share/${pkgname}
  -DPHYSFS_SYSTEM=1 -DMINIMAL_FLAGS=1"
 make_cmd=make
 hostmakedepends="lua51 pkg-config qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
+makedepends="ffmpeg4-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
  SDL2_mixer-devel SDL2_net-devel SDL2_ttf-devel"
 depends="libfreeglut"
 short_desc="Funny turn-based artillery game, featuring fighting Hedgehogs!"

From eae345172d6c1d94008489d550abb5fb899f9173 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 039/110] idjc: revbump for ffmpeg4

---
 srcpkgs/idjc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/idjc/template b/srcpkgs/idjc/template
index a9cde0665d55b1..f41e1e4fabbae7 100644
--- a/srcpkgs/idjc/template
+++ b/srcpkgs/idjc/template
@@ -1,11 +1,11 @@
 # Template file for 'idjc'
 pkgname=idjc
 version=0.9.1
-revision=5
+revision=6
 build_style=gnu-configure
 hostmakedepends="pkg-config git python3 automake gettext-devel libtool"
 makedepends="libvorbis-devel libogg-devel jack-devel libsamplerate-devel
- libflac-devel libsndfile-devel mpg123-devel ffmpeg-devel speex-devel
+ libflac-devel libsndfile-devel mpg123-devel ffmpeg4-devel speex-devel
  glib-devel pixman-devel lame-devel python3-gobject-devel libshout-idjc-devel
  opus-devel twolame-devel python3-mutagen python3-devel"
 depends="python3-gobject python3-mutagen desktop-file-utils shared-mime-info python3-dbus jack"

From 0022e50faf988320917fe65247f368167e639c35 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 040/110] kid3: revbump for ffmpeg6

---
 srcpkgs/kid3/patches/ffmpeg5.patch | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 srcpkgs/kid3/patches/ffmpeg5.patch

diff --git a/srcpkgs/kid3/patches/ffmpeg5.patch b/srcpkgs/kid3/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..135fc50e07c9ba
--- /dev/null
+++ b/srcpkgs/kid3/patches/ffmpeg5.patch
@@ -0,0 +1,17 @@
+# https://aur.archlinux.org/cgit/aur.git/diff/ffmpeg5.patch?h=kid3-cli&id=12410a74906612e7efc0ec8fbce739b4a0fef7e7
+diff --git a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+index e156d424..e12b9abd 100644
+--- a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
++++ b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+@@ -232,7 +232,11 @@ private:
+   friend class Format;
+   friend class Converter;
+   AVCodecContext* m_ptr;
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 0, 0)
+   AVCodec* m_impl;
++#else
++  const AVCodec* m_impl;
++#endif
+   AVFrame* m_frame;
+   bool m_opened;
+ };

From c73debbafab37cced6269c568d29933a6336a980 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 041/110] kodi: revbump for ffmpeg4

---
 srcpkgs/kodi/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/kodi/template b/srcpkgs/kodi/template
index d37a5918cd6758..ea78e0aca0fe3e 100644
--- a/srcpkgs/kodi/template
+++ b/srcpkgs/kodi/template
@@ -1,7 +1,7 @@
 # Template file for 'kodi'
 pkgname=kodi
 version=19.4
-revision=9
+revision=10
 _codename="Matrix"
 build_style=cmake
 configure_args="-DWITH_FFMPEG=/usr -DENABLE_LDGOLD=OFF
@@ -54,7 +54,7 @@ makedepends="
  libmad-devel fontconfig-devel libXinerama-devel libsamplerate-devel libmms-devel
  enca-devel boost-devel libcurl-devel libva-devel libvdpau-devel libass-devel
  libbluetooth-devel yajl-devel libplist-devel librtmp-devel tinyxml-devel
- taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg-devel
+ taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg4-devel
  giflib-devel libxslt-devel gnutls-devel libssh-devel libmicrohttpd-devel
  libcec-devel dcadec-devel flatbuffers-devel fmt-devel lcms2-devel
  libfstrcmp-devel rapidjson libcdio-paranoia spdlog libwaylandpp-devel

From c7446c3246d1291d1e75f887527a3a4b31a96ee3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 042/110] kpipewire: revbump for ffmpeg6

---
 srcpkgs/kpipewire/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kpipewire/template b/srcpkgs/kpipewire/template
index 6214a4451336e7..3555348659dded 100644
--- a/srcpkgs/kpipewire/template
+++ b/srcpkgs/kpipewire/template
@@ -1,7 +1,7 @@
 # Template file for 'kpipewire'
 pkgname=kpipewire
 version=5.27.10
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules plasma-wayland-protocols gettext
  qt5-qmake qt5-host-tools pkg-config wayland-devel kcoreaddons

From be42ede2889f7fdccaba0e621a3b78b0fdd9e2d2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 043/110] libopenal: revbump for ffmpeg6

---
 srcpkgs/libopenal/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenal/template b/srcpkgs/libopenal/template
index 88d0f11307d81a..8308fca0393e33 100644
--- a/srcpkgs/libopenal/template
+++ b/srcpkgs/libopenal/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenal'
 pkgname=libopenal
 version=1.23.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DALSOFT_EXAMPLES=OFF"
 hostmakedepends="pkg-config"

From 4f5ee54e6e58d91ff57f33520cea26189dc09748 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 044/110] loudgain: revbump for ffmpeg6

---
 srcpkgs/loudgain/patches/ffmpeg5.patch | 11 +++++++++++
 srcpkgs/loudgain/template              |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/loudgain/patches/ffmpeg5.patch

diff --git a/srcpkgs/loudgain/patches/ffmpeg5.patch b/srcpkgs/loudgain/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..16d4510ee98faa
--- /dev/null
+++ b/srcpkgs/loudgain/patches/ffmpeg5.patch
@@ -0,0 +1,11 @@
+--- a/src/scan.c	2019-09-06 11:31:19.000000000 -0400
++++ b/src/scan.c	2023-03-23 11:15:40.867968521 -0400
+@@ -69,8 +69,6 @@
+ 	 * It is now useless
+ 	 * https://github.com/FFmpeg/FFmpeg/blob/70d25268c21cbee5f08304da95be1f647c630c15/doc/APIchanges#L86
+ 	 */
+-  if (avformat_version() < AV_VERSION_INT(58,9,100))
+-    av_register_all();
+ 
+ 	av_log_set_callback(scan_av_log);
+ 
diff --git a/srcpkgs/loudgain/template b/srcpkgs/loudgain/template
index da4f2d56e94c3d..4d6bf29efb4fdd 100644
--- a/srcpkgs/loudgain/template
+++ b/srcpkgs/loudgain/template
@@ -1,7 +1,7 @@
 # Template file for 'loudgain'
 pkgname=loudgain
 version=0.6.8
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libebur128-devel taglib-devel ffmpeg-devel"

From ddcb875ff428c4200d1732597dde4f8e502558b0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 045/110] mediastreamer: revbump for ffmpeg4

---
 srcpkgs/mediastreamer/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mediastreamer/template b/srcpkgs/mediastreamer/template
index 0fcffa7653d18e..e888626b945e55 100644
--- a/srcpkgs/mediastreamer/template
+++ b/srcpkgs/mediastreamer/template
@@ -1,11 +1,11 @@
 # Template file for 'mediastreamer'
 pkgname=mediastreamer
 version=5.2.111
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DENABLE_STRICT=0 -DENABLE_UNIT_TESTS=0"
 hostmakedepends="python3"
-makedepends="bzrtp-devel ffmpeg-devel glew-devel libXv-devel libsrtp-devel
+makedepends="bzrtp-devel ffmpeg4-devel glew-devel libXv-devel libsrtp-devel
  libupnp-devel libvpx-devel mbedtls-devel opus-devel ortp-devel pulseaudio-devel
  libtheora-devel speex-devel v4l-utils-devel bcg729-devel bcmatroska2-devel libgsm-devel
  zxing-cpp-devel"

From 3fd3433f02288235b00091a2f057f022971b023d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 046/110] mgba: revbump for ffmpeg6

---
 srcpkgs/mgba/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mgba/template b/srcpkgs/mgba/template
index 6cd65650312543..93401adb618bd8 100644
--- a/srcpkgs/mgba/template
+++ b/srcpkgs/mgba/template
@@ -1,7 +1,7 @@
 # Template file for 'mgba'
 pkgname=mgba
 version=0.10.3
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake desktop-file-utils"
 makedepends="SDL2-devel ffmpeg-devel libedit-devel libepoxy-devel libmagick-devel

From 59efbf352c9aa0219a9b56fc34274be375ec7ea8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 047/110] mlt: revbump for ffmpeg4

---
 srcpkgs/mlt/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mlt/template b/srcpkgs/mlt/template
index 73e3915aaab9ac..d7ed4c4b30a868 100644
--- a/srcpkgs/mlt/template
+++ b/srcpkgs/mlt/template
@@ -1,14 +1,14 @@
 # Template file for 'mlt'
 pkgname=mlt
 version=6.26.1
-revision=3
+revision=4
 build_style=configure
 configure_args="--prefix=/usr --libdir=/usr/lib$XBPS_TARGET_WORDSIZE
  --enable-gpl --enable-gpl3 --disable-swfdec --without-kde
  --swig-languages=python"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which"
 # XXX: movit vid.stab
-makedepends="alsa-lib-devel ffmpeg-devel gtk+-devel jack-devel ladspa-sdk
+makedepends="alsa-lib-devel ffmpeg4-devel gtk+-devel jack-devel ladspa-sdk
  libexif-devel libsamplerate-devel libxml2-devel sox-devel SDL_image-devel
  fftw-devel frei0r-plugins python3-devel pulseaudio-devel movit-devel
  libvidstab-devel"

From c1bf96320848e0f07238e6b1c065f3c324b0c222 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 048/110] moc: revbump for ffmpeg4

---
 srcpkgs/moc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/moc/template b/srcpkgs/moc/template
index 3a04932c8f1e61..838755f88db09e 100644
--- a/srcpkgs/moc/template
+++ b/srcpkgs/moc/template
@@ -1,10 +1,10 @@
 # Template file for 'moc'
 pkgname=moc
 version=2.5.2
-revision=7
+revision=8
 build_style=gnu-configure
 hostmakedepends="pkg-config"
-makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg-devel
+makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg4-devel
  jack-devel alsa-lib-devel libltdl-devel libflac-devel libvorbis-devel
  libmad-devel libmpcdec-devel libmodplug-devel libid3tag-devel faad2-devel
  taglib-devel libsndfile-devel wavpack-devel speex-devel libsamplerate-devel

From 04bf20117d3b83952419a26ff2899a83658ec640 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 049/110] motion: revbump for ffmpeg6

---
 srcpkgs/motion/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/motion/template b/srcpkgs/motion/template
index 607ebeb3c7b242..bf63a91d9764f6 100644
--- a/srcpkgs/motion/template
+++ b/srcpkgs/motion/template
@@ -1,7 +1,7 @@
 # Template file for 'motion'
 pkgname=motion
 version=4.6.0
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake pkg-config gettext-devel tar"
 makedepends="ffmpeg-devel libmicrohttpd-devel v4l-utils-devel gettext-devel"

From cb6f1d42bd20c8af462951526e6facb4ba7c5056 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 050/110] olive: revbump for ffmpeg4

---
 srcpkgs/olive/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/olive/template b/srcpkgs/olive/template
index 12a46936c99003..5c2917b9c51245 100644
--- a/srcpkgs/olive/template
+++ b/srcpkgs/olive/template
@@ -1,10 +1,10 @@
 # Template file for 'olive'
 pkgname=olive
 version=0.1.2
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools pkg-config"
-makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg-devel frei0r-plugins"
+makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg4-devel frei0r-plugins"
 short_desc="Non-linear video editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"

From da0bd41dc0434e3b2926417bde66ad12cf07d1c1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 051/110] opentoonz: revbump for ffmpeg6

---
 srcpkgs/opentoonz/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/opentoonz/template b/srcpkgs/opentoonz/template
index ee9f7603f55fd8..3e81834ca0eddf 100644
--- a/srcpkgs/opentoonz/template
+++ b/srcpkgs/opentoonz/template
@@ -1,7 +1,7 @@
 # Template file for 'opentoonz'
 pkgname=opentoonz
 version=1.6.0
-revision=2
+revision=3
 build_wrksrc="toonz/sources"
 build_style=cmake
 make_cmd=make

From 874ec266b530ba4943c48f13cc8deb3010db6c44 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 052/110] pianobar: revbump for ffmpeg6

---
 srcpkgs/pianobar/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pianobar/template b/srcpkgs/pianobar/template
index e3febb821a4510..1e3dc1bf9308ee 100644
--- a/srcpkgs/pianobar/template
+++ b/srcpkgs/pianobar/template
@@ -1,7 +1,7 @@
 # Template file for 'pianobar'
 pkgname=pianobar
 version=2022.04.01
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="V=1"
 hostmakedepends="pkg-config"

From 8f3937b55731a6360809112e11e384ea475ab84f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 053/110] ppsspp: revbump for ffmpeg6

---
 srcpkgs/ppsspp/patches/ffmpeg6.patch | 15 +++++++++++++++
 srcpkgs/ppsspp/template              |  3 +--
 2 files changed, 16 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/ppsspp/patches/ffmpeg6.patch

diff --git a/srcpkgs/ppsspp/patches/ffmpeg6.patch b/srcpkgs/ppsspp/patches/ffmpeg6.patch
new file mode 100644
index 00000000000000..5803c7bf227309
--- /dev/null
+++ b/srcpkgs/ppsspp/patches/ffmpeg6.patch
@@ -0,0 +1,15 @@
+--- a/Core/HW/SimpleAudioDec.cpp	2024-02-04 08:08:02.000000000 -0500
++++ b/Core/HW/SimpleAudioDec.cpp	2024-02-15 14:48:27.114362051 -0500
+@@ -81,7 +81,11 @@
+ 		return;
+ 	}
+ 	// Find decoder
++#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(58, 18, 100)
+ 	codec_ = avcodec_find_decoder((AVCodecID)audioCodecId);
++#else // this is a macro to const in the header
++	codec_ = (AVCodec*)avcodec_find_decoder((AVCodecID)audioCodecId);
++#endif
+ 	if (!codec_) {
+ 		// Eh, we shouldn't even have managed to compile. But meh.
+ 		ERROR_LOG(ME, "This version of FFMPEG does not support AV_CODEC_ctx for audio (%s). Update your submodule.", GetCodecName(audioType));
+
diff --git a/srcpkgs/ppsspp/template b/srcpkgs/ppsspp/template
index 2238a7601c0af8..1fda55268a2d39 100644
--- a/srcpkgs/ppsspp/template
+++ b/srcpkgs/ppsspp/template
@@ -1,7 +1,7 @@
 # Template file for 'ppsspp'
 pkgname=ppsspp
 version=1.17.1
-revision=1
+revision=2
 _glslang_commit=b34f619e1c85810dcb3c578107d2e48ba4ee2b37
 _SPIRV_Cross_commit=4212eef67ed0ca048cb726a6767185504e7695e5
 _armips_commit=a8d71f0f279eb0d30ecf6af51473b66ae0cf8e8d
@@ -91,7 +91,6 @@ post_configure() {
 }
 
 do_install() {
-	vlicense LICENSE.TXT
 	vinstall icons/icon.svg 644 usr/share/pixmaps ppsspp.svg
 	vinstall Qt/PPSSPP.desktop 644 usr/share/applications
 	vbin build/PPSSPPHeadless ppsspp-headless

From 9c2a72a9ba841f12ea477fdd53383a7933bf68c6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 054/110] pqiv: revbump for ffmpeg6

---
 srcpkgs/pqiv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pqiv/template b/srcpkgs/pqiv/template
index 24bd18ebe8618f..9fc2324ec7ce6b 100644
--- a/srcpkgs/pqiv/template
+++ b/srcpkgs/pqiv/template
@@ -1,7 +1,7 @@
 # Template file for 'pqiv'
 pkgname=pqiv
 version=2.13
-revision=1
+revision=2
 build_style=gnu-makefile
 hostmakedepends="pkg-config"
 makedepends="glib-devel gtk+3-devel $(vopt_if ffmpeg ffmpeg-devel)

From 92d23911df6120c08ba240ad2c2db73769ac98eb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 055/110] qmmp: revbump for ffmpeg6

---
 srcpkgs/qmmp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qmmp/template b/srcpkgs/qmmp/template
index 53781ea3bc28ad..2da07f1e87eac0 100644
--- a/srcpkgs/qmmp/template
+++ b/srcpkgs/qmmp/template
@@ -1,7 +1,7 @@
 # Template file for 'qmmp'
 pkgname=qmmp
 version=1.6.1
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DUSE_HAL:BOOL=FALSE -DQMMP_DEFAULT_UI:STRING=simple"
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From 5113cae03c47a8abb4b5b5545ccda6d03561d980 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 14 Dec 2023 13:28:10 -0500
Subject: [PATCH 056/110] qt6-pdf: revbump for ffmpeg6

---
 srcpkgs/qt6-pdf/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-pdf/template b/srcpkgs/qt6-pdf/template
index ecda84afac1310..531b4e1d4fe84d 100644
--- a/srcpkgs/qt6-pdf/template
+++ b/srcpkgs/qt6-pdf/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-pdf'
 pkgname=qt6-pdf
 version=6.6.0
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DQT_FEATURE_qtpdf_build=ON
  -DQT_FEATURE_qtpdf_widgets_build=ON

From d026622816b114713b533b30b05ba9b17a8ee289 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 057/110] qt5-webengine: revbump for ffmpeg6

---
 .../chromium-media-filters-cpp14.patch        |  11 ++
 srcpkgs/qt5-webengine/patches/ffmpeg5.patch   | 179 ++++++++++++++++++
 .../qtwebengine-fix-ffmpeg5-build.patch       |  14 ++
 srcpkgs/qt5-webengine/template                |   4 +-
 4 files changed, 206 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/ffmpeg5.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch

diff --git a/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
new file mode 100644
index 00000000000000..04adc540f2cbc0
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
@@ -0,0 +1,11 @@
+--- a/src/3rdparty/chromium/media/filters/BUILD.gn	2023-02-27 13:32:59.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/BUILD.gn	2023-04-02 17:21:39.204066384 -0400
+@@ -96,6 +96,8 @@
+     "//ui/gfx/geometry:geometry",
+   ]
+ 
++  cflags_cc = [ "-std=c++14" ]
++
+   libs = []
+ 
+   if (proprietary_codecs) {
diff --git a/srcpkgs/qt5-webengine/patches/ffmpeg5.patch b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..ac55e1634423a9
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
@@ -0,0 +1,179 @@
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:57.732547446 -0400
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:09.486478995 -0400
+@@ -57,6 +57,8 @@
+ 
+ namespace {
+ 
++constexpr int64_t kRelativeTsBase = static_cast<int64_t>(0x7ffeffffffffffff);
++
+ void SetAVStreamDiscard(AVStream* stream, AVDiscard discard) {
+   DCHECK(stream);
+   stream->discard = discard;
+@@ -90,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+   if (stream->start_time != kNoFFmpegTimestamp)
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (stream->first_dts != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, stream->first_dts);
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -408,11 +398,11 @@
+   scoped_refptr<DecoderBuffer> buffer;
+ 
+   if (type() == DemuxerStream::TEXT) {
+-    int id_size = 0;
++    size_t id_size = 0;
+     uint8_t* id_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
+ 
+-    int settings_size = 0;
++    size_t settings_size = 0;
+     uint8_t* settings_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
+ 
+@@ -424,7 +414,7 @@
+     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
+                                      side_data.data(), side_data.size());
+   } else {
+-    int side_data_size = 0;
++    size_t side_data_size = 0;
+     uint8_t* side_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
+ 
+@@ -485,7 +475,7 @@
+                                        packet->size - data_offset);
+     }
+ 
+-    int skip_samples_size = 0;
++    size_t skip_samples_size = 0;
+     const uint32_t* skip_samples_ptr =
+         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
+             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
+@@ -1587,6 +1577,8 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++      continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+       lowest_start_time_stream = stream.get();
+@@ -1604,6 +1596,8 @@
+     if (stream && stream->type() == DemuxerStream::VIDEO &&
+         stream->IsEnabled()) {
+       video_stream = stream.get();
++      if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++        continue;
+       if (video_stream->start_time() <= seek_time) {
+         return video_stream;
+       }
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h qtwebengine-5.15.10/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h
+--- a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-07-11 22:12:47.917192788 -0500
+@@ -29,6 +29,7 @@ extern "C" {
+ #include <libavformat/avformat.h>
+ #include <libavformat/avio.h>
+ #include <libavutil/avutil.h>
++#include <libavutil/channel_layout.h>
+ #include <libavutil/imgutils.h>
+ #include <libavutil/log.h>
+ #include <libavutil/mastering_display_metadata.h>
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/audio_file_reader.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/audio_file_reader.cc
+--- a/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -85,7 +85,7 @@ bool AudioFileReader::OpenDemuxer() {
+ }
+ 
+ bool AudioFileReader::OpenDecoder() {
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (codec) {
+     // MP3 decodes to S16P which we don't support, tell it to use S16 instead.
+     if (codec_context_->sample_fmt == AV_SAMPLE_FMT_S16P)
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -329,7 +329,7 @@ bool FFmpegAudioDecoder::ConfigureDecode
+     }
+   }
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec ||
+       avcodec_open2(codec_context_.get(), codec, &codec_options) < 0) {
+     DLOG(ERROR) << "Could not initialize audio decoder: "
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -59,7 +59,6 @@ static int64_t AVIOSeekOperation(void* o
+ }
+ 
+ void FFmpegGlue::InitializeFFmpeg() {
+-  av_register_all();
+ }
+ 
+ static void LogContainer(bool is_local_file,
+@@ -95,9 +94,6 @@ FFmpegGlue::FFmpegGlue(FFmpegURLProtocol
+   // Enable fast, but inaccurate seeks for MP3.
+   format_context_->flags |= AVFMT_FLAG_FAST_SEEK;
+ 
+-  // Ensures we can read out various metadata bits like vp8 alpha.
+-  format_context_->flags |= AVFMT_FLAG_KEEP_SIDE_DATA;
+-
+   // Ensures format parsing errors will bail out. From an audit on 11/2017, all
+   // instances were real failures. Solves bugs like http://crbug.com/710791.
+   format_context_->error_recognition |= AV_EF_EXPLODE;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -391,7 +391,7 @@ bool FFmpegVideoDecoder::ConfigureDecode
+   if (decode_nalus_)
+     codec_context_->flags2 |= AV_CODEC_FLAG2_CHUNKS;
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
+     ReleaseFFmpegResources();
+     return false;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/media_file_checker.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/media_file_checker.cc
+--- a/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -68,7 +68,7 @@ bool MediaFileChecker::Start(base::TimeD
+       auto context = AVStreamToAVCodecContext(format_context->streams[i]);
+       if (!context)
+         continue;
+-      AVCodec* codec = avcodec_find_decoder(cp->codec_id);
++      const AVCodec* codec = avcodec_find_decoder(cp->codec_id);
+       if (codec && avcodec_open2(context.get(), codec, nullptr) >= 0) {
+         auto loop = std::make_unique<FFmpegDecodingLoop>(context.get());
+         stream_contexts[i] = {std::move(context), std::move(loop)};
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc qtwebengine-5.15.10/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc
+--- a/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -203,7 +203,7 @@ int32_t H264DecoderImpl::InitDecode(cons
+   // a pointer |this|.
+   av_context_->opaque = this;
+ 
+-  AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
+   if (!codec) {
+     // This is an indication that FFmpeg has not been initialized or it has not
+     // been compiled/initialized with the correct set of codecs.
diff --git a/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch b/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch
new file mode 100644
index 00000000000000..bc24d5b9a29cb5
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch
@@ -0,0 +1,14 @@
+--- a/src/buildtools/configure.json	2023-12-09 11:06:01.503058569 -0500
++++ b/src/buildtools/configure.json	2023-12-09 11:06:14.982361345 -0500
+@@ -779,11 +779,6 @@
+             "type": "warning",
+             "condition": "config.ios && config.simulator && config.device && features.build-qtpdf",
+             "message": "Building fat libray with device and simulator architectures will disable NEON."
+-        },
+-        {
+-            "type": "fatal",
+-            "condition": "features.webengine-system-ffmpeg && !libs.webengine-ffmpeg-support",
+-            "message": "Unmodified ffmpeg >= 5.0 is not supported. Please configure with -qt-webengine-ffmpeg."
+         }
+     ],
+     "summary": [
diff --git a/srcpkgs/qt5-webengine/template b/srcpkgs/qt5-webengine/template
index 8d2df1b5175bad..1687a77eb8a2f5 100644
--- a/srcpkgs/qt5-webengine/template
+++ b/srcpkgs/qt5-webengine/template
@@ -1,14 +1,14 @@
 # Template file for 'qt5-webengine'
 pkgname=qt5-webengine
 version=5.15.16
-revision=1
+revision=2
 _version="${version}-lts"
 _chromium_commit=207c2ac45ca3386d153770c6b0d2ea2ec21ca880
 archs="x86_64* i686* armv[67]* ppc64* aarch64*"
 create_wrksrc=yes
 build_style=qmake
 configure_args="--
- -webengine-icu -webengine-ffmpeg -webengine-opus -webengine-webp
+ -webengine-icu -system-ffmpeg -webengine-opus -webengine-webp
  -webengine-pepper-plugins -webengine-printing-and-pdf -webengine-proprietary-codecs
  -webengine-pulseaudio -webengine-spellchecker -webengine-webrtc -webengine-geolocation
  -webengine-kerberos -no-webengine-embedded-build $(vopt_if sndio '' '-no')-webengine-sndio

From e82fa52ffd7098491ec50e2a434a1f211a19bda2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 058/110] qt5: revbump for ffmpeg6

---
 srcpkgs/qt5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5/template b/srcpkgs/qt5/template
index 3efb7e42d5fd3f..27f6d5388cd15c 100644
--- a/srcpkgs/qt5/template
+++ b/srcpkgs/qt5/template
@@ -3,9 +3,9 @@
 # revbump libqtxdg after bumping patch version
 pkgname=qt5
 version=5.15.11+20231124
+revision=3
 # commit 4765fa1df7a837db9c1f89c4da0dd76b74bb5fab
 # base repo: https://invent.kde.org/qt/qt/qt5
-revision=2
 build_style=meta
 hostmakedepends="cmake clang17 flex perl glib-devel pkg-config
  python3 re2c ruby which"

From cca863930fa83af833055311ed8008980ea09f44 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 059/110] qtav: revbump for ffmpeg4

---
 srcpkgs/qtav/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtav/template b/srcpkgs/qtav/template
index 775d5a139a9efa..aa69e213c984b0 100644
--- a/srcpkgs/qtav/template
+++ b/srcpkgs/qtav/template
@@ -1,10 +1,10 @@
 # Template file for 'qtav'
 pkgname=qtav
 version=1.13.0
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel libass-devel libopenal-devel
+makedepends="ffmpeg4-devel libass-devel libopenal-devel
  libva-glx-devel libXv-devel pulseaudio-devel
  qt5-declarative-devel qt5-svg-devel
  qt5-quickcontrols"

From ffd72d88f32e69d263a342d53027663644fb7cad Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 060/110] retroarch: revbump for ffmpeg6

---
 srcpkgs/retroarch/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroarch/template b/srcpkgs/retroarch/template
index cb3125c5dbf1ae..c65c26f7bf0332 100644
--- a/srcpkgs/retroarch/template
+++ b/srcpkgs/retroarch/template
@@ -1,7 +1,7 @@
 # Template file for 'retroarch'
 pkgname=retroarch
 version=1.16.0.3
-revision=3
+revision=4
 build_style=configure
 configure_args="--prefix=/usr --sysconfdir=/etc --enable-networking
  --enable-udev --disable-builtinflac --disable-builtinglslang

From 5d15a727ac582023e5bc693c06c46aa1b9e4fee2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 061/110] scrcpy: revbump for ffmpeg6

---
 srcpkgs/scrcpy/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/scrcpy/template b/srcpkgs/scrcpy/template
index d04de770dc1913..5218fa01f8ce1f 100644
--- a/srcpkgs/scrcpy/template
+++ b/srcpkgs/scrcpy/template
@@ -1,7 +1,7 @@
 # Template file for 'scrcpy'
 pkgname=scrcpy
 version=2.3.1
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcompile_server=false
  -Dprebuilt_server=/usr/share/scrcpy/scrcpy-server-v${version}"

From d435684f26eb9dd6614b5ad5fda8ebd0aa8089f1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 17 Oct 2023 08:54:11 -0400
Subject: [PATCH 062/110] New package: spex-x replaces spek-alternative for
 ffmpeg6

---
 srcpkgs/spek-alternative                      |  1 +
 srcpkgs/{spek-alternative => spek-x}/template | 22 ++++++++++++-------
 2 files changed, 15 insertions(+), 8 deletions(-)
 create mode 120000 srcpkgs/spek-alternative
 rename srcpkgs/{spek-alternative => spek-x}/template (52%)

diff --git a/srcpkgs/spek-alternative b/srcpkgs/spek-alternative
new file mode 120000
index 00000000000000..76648236da7017
--- /dev/null
+++ b/srcpkgs/spek-alternative
@@ -0,0 +1 @@
+spek-x
\ No newline at end of file
diff --git a/srcpkgs/spek-alternative/template b/srcpkgs/spek-x/template
similarity index 52%
rename from srcpkgs/spek-alternative/template
rename to srcpkgs/spek-x/template
index d7b55c776b1d43..3ded6c2c323e4f 100644
--- a/srcpkgs/spek-alternative/template
+++ b/srcpkgs/spek-x/template
@@ -1,18 +1,18 @@
-# Template file for 'spek-alternative'
-pkgname=spek-alternative
-version=0.8.2.3
-revision=2
+# Template file for 'spek-x'
+pkgname=spek-x
+version=0.9.3
+revision=1
 build_style=gnu-configure
 hostmakedepends="automake gettext-devel intltool libtool pkg-config
  wxWidgets-common wxWidgets-gtk3-devel"
 makedepends="ffmpeg-devel wxWidgets-gtk3-devel"
 depends="ffmpeg"
 short_desc="Acoustic spectrum analyser"
-maintainer="Kartik Singh <kartik.ynwa@gmail.com>"
+maintainer="zlice <zlice555@gmail.com>"
 license="GPL-3.0-or-later"
-homepage="https://github.com/withmorten/spek-alternative"
-distfiles="https://github.com/withmorten/spek-alternative/archive/${version}.tar.gz"
-checksum="007ba4b84a310b078e378aa84c8e80783db5821437a757a488c3ecec377e6b2a"
+homepage="https://github.com/MikeWang000000/spek-x"
+distfiles="https://github.com/MikeWang000000/spek-x/archive/v${version}.tar.gz"
+checksum="7f4b109903333cdd310ab2b9176f0dc49a565891376e281a233d342cedf90ef7"
 
 CXXFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
 
@@ -22,3 +22,9 @@ export WX_CONFIG_NAME="wx-config-gtk3"
 pre_configure() {
 	NOCONFIGURE=1 ./autogen.sh
 }
+
+spek-alternative_package() {
+	depends="spek-x"
+	short_desc+=" - transitional dummy package"
+	build_style=meta
+}

From fec7bff0f741c68bb2e3faf5931a8b9f5e878761 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 063/110] ssr: revbump for ffmpeg6

---
 .../0001-Fix-build-with-ffmpeg-5.0.patch      | 241 ++++++++++++++++++
 srcpkgs/ssr/template                          |   2 +-
 2 files changed, 242 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ssr/patches/0001-Fix-build-with-ffmpeg-5.0.patch

diff --git a/srcpkgs/ssr/patches/0001-Fix-build-with-ffmpeg-5.0.patch b/srcpkgs/ssr/patches/0001-Fix-build-with-ffmpeg-5.0.patch
new file mode 100644
index 00000000000000..4c069b5a9fc464
--- /dev/null
+++ b/srcpkgs/ssr/patches/0001-Fix-build-with-ffmpeg-5.0.patch
@@ -0,0 +1,241 @@
+From f4cbde38021d9330dc73d2e3dfa8a70da3ff5721 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Bernhard=20Rosenkr=C3=A4nzer?= <bero@lindev.ch>
+Date: Sun, 16 Jan 2022 02:40:04 +0100
+Subject: [PATCH] Fix build with ffmpeg 5.0
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Adapt to ffmpeg 5.0 requiring more const-ness for AVCodec.
+
+Signed-off-by: Bernhard Rosenkränzer <bero@lindev.ch>
+---
+ src/AV/Output/AudioEncoder.cpp |  6 +++---
+ src/AV/Output/AudioEncoder.h   |  4 ++--
+ src/AV/Output/BaseEncoder.cpp  |  4 ++--
+ src/AV/Output/BaseEncoder.h    |  4 ++--
+ src/AV/Output/Muxer.cpp        | 12 ++++++------
+ src/AV/Output/Muxer.h          |  4 ++--
+ src/AV/Output/VideoEncoder.cpp |  6 +++---
+ src/AV/Output/VideoEncoder.h   |  4 ++--
+ 8 files changed, 22 insertions(+), 22 deletions(-)
+
+diff --git a/src/AV/Output/AudioEncoder.cpp b/src/AV/Output/AudioEncoder.cpp
+index 34d015c..cefc2e0 100644
+--- a/src/AV/Output/AudioEncoder.cpp
++++ b/src/AV/Output/AudioEncoder.cpp
+@@ -34,7 +34,7 @@ const std::vector<AudioEncoder::SampleFormatData> AudioEncoder::SUPPORTED_SAMPLE
+ 
+ const unsigned int AudioEncoder::DEFAULT_FRAME_SAMPLES = 1024;
+ 
+-AudioEncoder::AudioEncoder(Muxer* muxer, AVStream* stream, AVCodecContext *codec_context, AVCodec* codec, AVDictionary** options)
++AudioEncoder::AudioEncoder(Muxer* muxer, AVStream* stream, AVCodecContext *codec_context, const AVCodec* codec, AVDictionary** options)
+ 	: BaseEncoder(muxer, stream, codec_context, codec, options) {
+ 
+ #if !SSR_USE_AVCODEC_ENCODE_AUDIO2
+@@ -77,7 +77,7 @@ unsigned int AudioEncoder::GetSampleRate() {
+ }
+ 
+ bool AudioEncoder::AVCodecIsSupported(const QString& codec_name) {
+-	AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
++	const AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
+ 	if(codec == NULL)
+ 		return false;
+ 	if(!av_codec_is_encoder(codec))
+@@ -93,7 +93,7 @@ bool AudioEncoder::AVCodecIsSupported(const QString& codec_name) {
+ 	return false;
+ }
+ 
+-void AudioEncoder::PrepareStream(AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
++void AudioEncoder::PrepareStream(AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
+ 								 unsigned int bit_rate, unsigned int channels, unsigned int sample_rate) {
+ 
+ 	if(channels == 0) {
+diff --git a/src/AV/Output/AudioEncoder.h b/src/AV/Output/AudioEncoder.h
+index c93278c..ae9c82e 100644
+--- a/src/AV/Output/AudioEncoder.h
++++ b/src/AV/Output/AudioEncoder.h
+@@ -40,7 +40,7 @@ private:
+ #endif
+ 
+ public:
+-	AudioEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options);
++	AudioEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options);
+ 	~AudioEncoder();
+ 
+ 	// Returns the required frame size, i.e. the number of samples (for each channel).
+@@ -57,7 +57,7 @@ public:
+ 
+ public:
+ 	static bool AVCodecIsSupported(const QString& codec_name);
+-	static void PrepareStream(AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
++	static void PrepareStream(AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
+ 							  unsigned int bit_rate, unsigned int channels, unsigned int sample_rate);
+ 
+ private:
+diff --git a/src/AV/Output/BaseEncoder.cpp b/src/AV/Output/BaseEncoder.cpp
+index 7c01ef3..4780aaf 100644
+--- a/src/AV/Output/BaseEncoder.cpp
++++ b/src/AV/Output/BaseEncoder.cpp
+@@ -42,7 +42,7 @@ double ParseCodecOptionDouble(const QString& key, const QString& value, double m
+ 	return clamp(value_double, min, max) * multiply;
+ }
+ 
+-BaseEncoder::BaseEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options) {
++BaseEncoder::BaseEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options) {
+ 
+ 	m_muxer = muxer;
+ 	m_stream = stream;
+@@ -157,7 +157,7 @@ void BaseEncoder::IncrementPacketCounter() {
+ 	++lock->m_total_packets;
+ }
+ 
+-void BaseEncoder::Init(AVCodec* codec, AVDictionary** options) {
++void BaseEncoder::Init(const AVCodec* codec, AVDictionary** options) {
+ 
+ 	// open codec
+ 	if(avcodec_open2(m_codec_context, codec, options) < 0) {
+diff --git a/src/AV/Output/BaseEncoder.h b/src/AV/Output/BaseEncoder.h
+index 3d92f29..7f02bbd 100644
+--- a/src/AV/Output/BaseEncoder.h
++++ b/src/AV/Output/BaseEncoder.h
+@@ -51,7 +51,7 @@ private:
+ 	std::atomic<bool> m_should_stop, m_should_finish, m_is_done, m_error_occurred;
+ 
+ protected:
+-	BaseEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options);
++	BaseEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options);
+ 
+ public:
+ 	virtual ~BaseEncoder(); // encoders will be deleted by Muxer, don't delete them yourself!
+@@ -117,7 +117,7 @@ protected:
+ 	void IncrementPacketCounter();
+ 
+ private:
+-	void Init(AVCodec* codec, AVDictionary** options);
++	void Init(const AVCodec* codec, AVDictionary** options);
+ 	void Free();
+ 
+ 	void EncoderThread();
+diff --git a/src/AV/Output/Muxer.cpp b/src/AV/Output/Muxer.cpp
+index ad58380..14650b0 100644
+--- a/src/AV/Output/Muxer.cpp
++++ b/src/AV/Output/Muxer.cpp
+@@ -87,7 +87,7 @@ Muxer::~Muxer() {
+ 
+ VideoEncoder* Muxer::AddVideoEncoder(const QString& codec_name, const std::vector<std::pair<QString, QString> >& codec_options,
+ 									 unsigned int bit_rate, unsigned int width, unsigned int height, unsigned int frame_rate) {
+-	AVCodec *codec = FindCodec(codec_name);
++	const AVCodec *codec = FindCodec(codec_name);
+ 	AVCodecContext *codec_context = NULL;
+ 	AVStream *stream = AddStream(codec, &codec_context);
+ 	VideoEncoder *encoder;
+@@ -111,7 +111,7 @@ VideoEncoder* Muxer::AddVideoEncoder(const QString& codec_name, const std::vecto
+ 
+ AudioEncoder* Muxer::AddAudioEncoder(const QString& codec_name, const std::vector<std::pair<QString, QString> >& codec_options,
+ 									 unsigned int bit_rate, unsigned int channels, unsigned int sample_rate) {
+-	AVCodec *codec = FindCodec(codec_name);
++	const AVCodec *codec = FindCodec(codec_name);
+ 	AVCodecContext *codec_context = NULL;
+ 	AVStream *stream = AddStream(codec, &codec_context);
+ 	AudioEncoder *encoder;
+@@ -194,7 +194,7 @@ unsigned int Muxer::GetQueuedPacketCount(unsigned int stream_index) {
+ void Muxer::Init() {
+ 
+ 	// get the format we want (this is just a pointer, we don't have to free this)
+-	AVOutputFormat *format = av_guess_format(m_container_name.toUtf8().constData(), NULL, NULL);
++	const AVOutputFormat *format = av_guess_format(m_container_name.toUtf8().constData(), NULL, NULL);
+ 	if(format == NULL) {
+ 		Logger::LogError("[Muxer::Init] " + Logger::tr("Error: Can't find chosen output format!"));
+ 		throw LibavException();
+@@ -261,8 +261,8 @@ void Muxer::Free() {
+ 	}
+ }
+ 
+-AVCodec* Muxer::FindCodec(const QString& codec_name) {
+-	AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
++const AVCodec* Muxer::FindCodec(const QString& codec_name) {
++	const AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
+ 	if(codec == NULL) {
+ 		Logger::LogError("[Muxer::FindCodec] " + Logger::tr("Error: Can't find codec!"));
+ 		throw LibavException();
+@@ -270,7 +270,7 @@ AVCodec* Muxer::FindCodec(const QString& codec_name) {
+ 	return codec;
+ }
+ 
+-AVStream* Muxer::AddStream(AVCodec* codec, AVCodecContext** codec_context) {
++AVStream* Muxer::AddStream(const AVCodec* codec, AVCodecContext** codec_context) {
+ 	assert(!m_started);
+ 	assert(m_format_context->nb_streams < MUXER_MAX_STREAMS);
+ 
+diff --git a/src/AV/Output/Muxer.h b/src/AV/Output/Muxer.h
+index d72347d..b104bcb 100644
+--- a/src/AV/Output/Muxer.h
++++ b/src/AV/Output/Muxer.h
+@@ -114,8 +114,8 @@ private:
+ 	void Init();
+ 	void Free();
+ 
+-	AVCodec* FindCodec(const QString& codec_name);
+-	AVStream* AddStream(AVCodec* codec, AVCodecContext** codec_context);
++	const AVCodec* FindCodec(const QString& codec_name);
++	AVStream* AddStream(const AVCodec* codec, AVCodecContext** codec_context);
+ 
+ 	void MuxerThread();
+ 
+diff --git a/src/AV/Output/VideoEncoder.cpp b/src/AV/Output/VideoEncoder.cpp
+index 8087e8e..fc8b5d1 100644
+--- a/src/AV/Output/VideoEncoder.cpp
++++ b/src/AV/Output/VideoEncoder.cpp
+@@ -34,7 +34,7 @@ const std::vector<VideoEncoder::PixelFormatData> VideoEncoder::SUPPORTED_PIXEL_F
+ 	{"rgb", AV_PIX_FMT_RGB24, false},
+ };
+ 
+-VideoEncoder::VideoEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options)
++VideoEncoder::VideoEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options)
+ 	: BaseEncoder(muxer, stream, codec_context, codec, options) {
+ 
+ #if !SSR_USE_AVCODEC_ENCODE_VIDEO2
+@@ -95,7 +95,7 @@ unsigned int VideoEncoder::GetFrameRate() {
+ }
+ 
+ bool VideoEncoder::AVCodecIsSupported(const QString& codec_name) {
+-	AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
++	const AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
+ 	if(codec == NULL)
+ 		return false;
+ 	if(!av_codec_is_encoder(codec))
+@@ -111,7 +111,7 @@ bool VideoEncoder::AVCodecIsSupported(const QString& codec_name) {
+ 	return false;
+ }
+ 
+-void VideoEncoder::PrepareStream(AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
++void VideoEncoder::PrepareStream(AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
+ 								 unsigned int bit_rate, unsigned int width, unsigned int height, unsigned int frame_rate) {
+ 
+ 	if(width == 0 || height == 0) {
+diff --git a/src/AV/Output/VideoEncoder.h b/src/AV/Output/VideoEncoder.h
+index cb7ca27..68d872e 100644
+--- a/src/AV/Output/VideoEncoder.h
++++ b/src/AV/Output/VideoEncoder.h
+@@ -40,7 +40,7 @@ private:
+ #endif
+ 
+ public:
+-	VideoEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options);
++	VideoEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options);
+ 	~VideoEncoder();
+ 
+ 	// Returns the required pixel format.
+@@ -55,7 +55,7 @@ public:
+ 
+ public:
+ 	static bool AVCodecIsSupported(const QString& codec_name);
+-	static void PrepareStream(AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
++	static void PrepareStream(AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
+ 							  unsigned int bit_rate, unsigned int width, unsigned int height, unsigned int frame_rate);
+ 
+ private:
+-- 
+2.43.0
+
diff --git a/srcpkgs/ssr/template b/srcpkgs/ssr/template
index 3097754e3cbe54..e3c4261f1f5a64 100644
--- a/srcpkgs/ssr/template
+++ b/srcpkgs/ssr/template
@@ -1,7 +1,7 @@
 # Template file for 'ssr'
 pkgname=ssr
 version=0.4.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DWITH_QT5=ON"
 hostmakedepends="pkg-config"

From ec319e0ea46d29122839f11828a307130f349975 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 064/110] synfig: revbump for ffmpeg6 and mlt7

---
 srcpkgs/synfig/patches/ffmpeg6.patch | 71 ++++++++++++++++++++++++++++
 srcpkgs/synfig/template              |  6 +--
 2 files changed, 74 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/synfig/patches/ffmpeg6.patch

diff --git a/srcpkgs/synfig/patches/ffmpeg6.patch b/srcpkgs/synfig/patches/ffmpeg6.patch
new file mode 100644
index 00000000000000..10780b42782f4b
--- /dev/null
+++ b/srcpkgs/synfig/patches/ffmpeg6.patch
@@ -0,0 +1,71 @@
+--- a/src/modules/mod_libavcodec/trgt_av.cpp	2022-10-25 09:14:12.000000000 -0400
++++ b/src/modules/mod_libavcodec/trgt_av.cpp	2023-05-05 21:34:17.899194559 -0400
+@@ -38,6 +41,7 @@
+ extern "C"
+ {
+ #ifdef HAVE_LIBAVFORMAT_AVFORMAT_H
++#	include <libavcodec/avcodec.h>
+ #	include <libavformat/avformat.h>
+ #elif defined(HAVE_AVFORMAT_H)
+ #	include <avformat.h>
+@@ -155,11 +156,11 @@
+     }
+ 
+ 	bool open_video_stream() {
+-		if (avcodec_open2(video_context, NULL, NULL) < 0) {
++		if (avcodec_open2(video_context, nullptr, nullptr) < 0) {
+ 			synfig::error("Target_LibAVCodec: could not open video codec");
+ 			// seems the calling of avcodec_free_context after error will cause crash
+ 			// so just forget about this context
+-			video_context = NULL;
++			video_context = nullptr;
+ 			close();
+ 			return false;
+         }
+@@ -234,15 +235,21 @@
+ 		close();
+ 
+ 		if (!av_registered) {
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 			av_register_all();
++#endif
+ 			av_registered = true;
+ 		}
+ 
+ 		// guess format
+-		AVOutputFormat *format = av_guess_format(NULL, filename.c_str(), NULL);
++#if LIBAVCODEC_VERSION_MAJOR < 59 // FFMPEG < 5.0
++		AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#else
++		const AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#endif
+ 		if (!format) {
+ 			synfig::warning("Target_LibAVCodec: unable to guess the output format, defaulting to MPEG");
+-			format = av_guess_format("mpeg", NULL, NULL);
++			format = av_guess_format("mpeg", nullptr, nullptr);
+ 		}
+ 		if (!format) {
+ 			synfig::error("Target_LibAVCodec: unable to find 'mpeg' output format");
+@@ -254,6 +261,7 @@
+ 		context = avformat_alloc_context();
+ 		assert(context);
+ 		context->oformat = format;
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 		if (filename.size() + 1 > sizeof(context->filename)) {
+ 			synfig::error(
+ 				"Target_LibAVCodec: filename too long, max length is %d, filename is '%s'",
+@@ -263,6 +271,14 @@
+ 			return false;
+ 		}
+ 		memcpy(context->filename, filename.c_str(), filename.size() + 1);
++#else
++		context->url = av_strndup(filename.c_str(), filename.size());
++		if (!context->url) {
++			synfig::error("Target_LibAVCodec: cannot allocate space for filename");
++			close();
++			return false;
++		}
++#endif
+ 
+ 		packet = av_packet_alloc();
+ 		assert(packet);
diff --git a/srcpkgs/synfig/template b/srcpkgs/synfig/template
index d4d3e341a20bf8..828b5cb32956ee 100644
--- a/srcpkgs/synfig/template
+++ b/srcpkgs/synfig/template
@@ -2,11 +2,11 @@
 # Should be kept in sync with 'synfigstudio' and 'ETL'
 pkgname=synfig
 version=1.4.4
-revision=4
+revision=5
 build_style=gnu-configure
 configure_args="--with-boost-libdir=${XBPS_CROSS_BASE}/usr/lib"
 hostmakedepends="boost-build ImageMagick pkg-config intltool"
-makedepends="ETL gettext-devel libxml++-devel mlt-devel libmagick-devel
+makedepends="ETL gettext-devel libxml++-devel mlt7-devel libmagick-devel
  libmng-devel boost-build boost-devel libopenexr-devel ffmpeg-devel"
 depends="ImageMagick"
 short_desc="CLI 2D vector and timeline-based animation software"
@@ -20,7 +20,7 @@ CXXFLAGS="-std=c++11 -DHAVE_LOCALE_H=1"
 
 synfig-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision}
-	 libopenexr-devel libxml++-devel mlt-devel"
+	 libopenexr-devel libxml++-devel mlt7-devel"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/bin/synfig-config

From 10613ee6c817dec94a50207a8ad24f0d2cfce1ee Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 065/110] timg: revbump for ffmpeg6

---
 srcpkgs/timg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/timg/template b/srcpkgs/timg/template
index 2a2ab763d2fddf..8fb4327535ef93 100644
--- a/srcpkgs/timg/template
+++ b/srcpkgs/timg/template
@@ -1,7 +1,7 @@
 # Template file for 'timg'
 pkgname=timg
 version=1.4.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_OPENSLIDE_SUPPORT=off -Wno-dev"
 hostmakedepends="pkg-config git"

From 552a280d3565914be423e79b6e2e89ab52b42246 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 066/110] tvheadend: revbump for ffmpeg4

---
 srcpkgs/tvheadend/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tvheadend/template b/srcpkgs/tvheadend/template
index 9aea7de4ec7057..012d31c4879ff1 100644
--- a/srcpkgs/tvheadend/template
+++ b/srcpkgs/tvheadend/template
@@ -8,7 +8,7 @@ configure_args="--enable-dvbscan --disable-ffmpeg_static
 --disable-libx265_static --disable-libvpx_static --disable-libtheora_static
 --disable-libvorbis_static --disable-libfdkaac_static"
 hostmakedepends="gettext pkg-config python3 git which"
-makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg-devel"
+makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg4-devel"
 short_desc="TV streaming server"
 maintainer="lemmi <lemmi@nerd2nerd.org>"
 license="GPL-3.0-only"

From 049808eb96b1280014c87650a0fd051cff4c9778 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 067/110] unpaper: update to 7.0.0.

---
 srcpkgs/unpaper/template | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/srcpkgs/unpaper/template b/srcpkgs/unpaper/template
index 38ed47a5840165..1ff910e722afc8 100644
--- a/srcpkgs/unpaper/template
+++ b/srcpkgs/unpaper/template
@@ -1,13 +1,13 @@
 # Template file for 'unpaper'
 pkgname=unpaper
-version=6.1
-revision=3
-build_style=gnu-configure
+version=7.0.0
+revision=1
+build_style=meson
+hostmakedepends="pkg-config meson libxslt"
+makedepends="ffmpeg-devel python3-Sphinx"
+short_desc="Post-processing tool for scanned sheets of paper"
 maintainer="Orphaned <orphan@voidlinux.org>"
-hostmakedepends="pkg-config libxslt"
-makedepends="ffmpeg-devel"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://www.flameeyes.eu/projects/unpaper"
-short_desc="A post-processing tool for scanned sheets of paper"
 distfiles="https://www.flameeyes.eu/files/${pkgname}-${version}.tar.xz"
-checksum=237c84f5da544b3f7709827f9f12c37c346cdf029b1128fb4633f9bafa5cb930
+checksum=2575fbbf26c22719d1cb882b59602c9900c7f747118ac130883f63419be46a80

From 62150af23842cc46217536b81e001c7c1d605902 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 068/110] vice: revbump for ffmpeg4

---
 srcpkgs/vice/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/vice/template b/srcpkgs/vice/template
index b1f866d35095e7..43f79243a1da11 100644
--- a/srcpkgs/vice/template
+++ b/srcpkgs/vice/template
@@ -1,7 +1,7 @@
 # Template file for 'vice'
 pkgname=vice
 version=3.7.1
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="
 	$(vopt_enable sdl2 sdlui2)
@@ -26,7 +26,7 @@ makedepends="
 	$(vopt_if gtk3 gtk+3-devel)
 	$(vopt_if gtk3 pulseaudio-devel)
 	$(vopt_if gtk3 pango-devel)
-	$(vopt_if ffmpeg ffmpeg-devel)"
+	$(vopt_if ffmpeg ffmpeg4-devel)"
 short_desc="Emulator for C64, C128, CBM-II, PET, VIC20, Plus4 and C16"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"

From 768f262cacf86e953037aaf1054d5702f1c5a3c9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 069/110] waypipe: revbump for ffmpeg6

---
 srcpkgs/waypipe/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waypipe/template b/srcpkgs/waypipe/template
index 6da88b21bf2a19..4da8058400b588 100644
--- a/srcpkgs/waypipe/template
+++ b/srcpkgs/waypipe/template
@@ -1,7 +1,7 @@
 # Template file for 'waypipe'
 pkgname=waypipe
 version=0.8.6
-revision=1
+revision=2
 build_style=meson
 # lto is off because it causes linking errors in armv6l and armv7l (due to NEON)
 configure_args="-Dwerror=false -Dwith_dmabuf=enabled -Dwith_lz4=enabled

From ffe14c7414b5f4fb30818ba2e7bbd92ee970c08f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 070/110] xpra: revbump for ffmpeg6

---
 srcpkgs/xpra/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xpra/template b/srcpkgs/xpra/template
index 3e49ab23deac9c..3939026a6fbf90 100644
--- a/srcpkgs/xpra/template
+++ b/srcpkgs/xpra/template
@@ -1,7 +1,7 @@
 # Template file for 'xpra'
 pkgname=xpra
 version=5.0.7
-revision=1
+revision=2
 build_style=python3-module
 make_build_args="--without-cuda_kernels --without-cuda_rebuild"
 make_install_args="$(vopt_with docs) ${make_build_args}"

From 4ee4e320d1e4aafb45b765fd38b67e37860efc0f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:07:40 -0400
Subject: [PATCH 071/110] nv-codec-headers: update to 12.0.16.0

---
 srcpkgs/nv-codec-headers/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/nv-codec-headers/template b/srcpkgs/nv-codec-headers/template
index 3d422a61e48917..251e057f826fb8 100644
--- a/srcpkgs/nv-codec-headers/template
+++ b/srcpkgs/nv-codec-headers/template
@@ -1,6 +1,6 @@
 # Template file for 'nv-codec-headers'
 pkgname=nv-codec-headers
-version=11.1.5.1
+version=12.0.16.0
 revision=1
 build_style=gnu-makefile
 short_desc="FFmpeg version of headers required to interface with Nvidias codec APIs"
@@ -8,7 +8,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="MIT"
 homepage="http://git.videolan.org/?p=ffmpeg/nv-codec-headers.git"
 distfiles="https://github.com/FFmpeg/nv-codec-headers/archive/n${version}.tar.gz"
-checksum=d095fbd56aa93772471a323be0ebe65504a0f43f06c76a30b6d25da77b06ae9c
+checksum=2a1533b65f55f9da52956faf0627ed3b74868ac0c7f269990edd21369113b48f
 
 post_install() {
 	sed -n '4,25p' include/ffnvcodec/nvEncodeAPI.h > LICENSE

From c8eb1c3ca236982fbc65f0760aca9969c2f224fc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:08:40 -0400
Subject: [PATCH 072/110] openimagedenoise: revbump for ffmpeg6

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index 109deb171c3f75..44edf38fb289d8 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,7 +1,7 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
 version=1.4.3
-revision=2
+revision=3
 archs="x86_64*"
 build_style=cmake
 hostmakedepends="ispc python3"

From 35fe31b8a8c8fec26b67c46c4d3071c999fca335 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:31:45 -0400
Subject: [PATCH 073/110] shotcut: revbump for ffmpeg6

---
 srcpkgs/shotcut/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/shotcut/template b/srcpkgs/shotcut/template
index 33141fbd862d7a..f46cb53b6bfb92 100644
--- a/srcpkgs/shotcut/template
+++ b/srcpkgs/shotcut/template
@@ -1,7 +1,7 @@
 # Template file for 'shotcut'
 pkgname=shotcut
 version=23.09.29
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSHOTCUT_VERSION=${version}"
 hostmakedepends="pkg-config qt6-tools-devel"

From 31ea2d379d360ebbca6e21b918e7a7e5b7ff2994 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:30 -0400
Subject: [PATCH 074/110] shiboken2: revbump for qt5-5.15.11

---
 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch | 1 +
 1 file changed, 1 insertion(+)
 create mode 120000 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
new file mode 120000
index 00000000000000..efcf3249bd8854
--- /dev/null
+++ b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1 @@
+../../python3-pyside2/patches/importlib-machinery-bypass.patch
\ No newline at end of file

From 165f8e670494181f4c6a635670b0403323e6c800 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:53 -0400
Subject: [PATCH 075/110] python3-pyside2: revbump for qt5-5.15.11

---
 .../patches/importlib-machinery-bypass.patch      | 15 +++++++++++++++
 srcpkgs/python3-pyside2/template                  |  2 +-
 2 files changed, 16 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
new file mode 100644
index 00000000000000..64c429584776b5
--- /dev/null
+++ b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1,15 @@
+Using this prevents an error around line 220 below it.
+"AttributeError: module 'importlib' has no attribute 'machinery'"
+The old backup logic is in place and compiles without issues.
+--- a/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:09:34.688912402 -0400
++++ b/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:10:03.395529582 -0400
+@@ -170,9 +170,6 @@
+
+     # 'zipstring_sequence' comes from signature.cpp
+     zipbytes = base64.b64decode(''.join(zipstring_sequence))
+-    if sys.version_info[0] >= 3:
+-        vzip = zipfile.ZipFile(io.BytesIO(zipbytes))
+-        return sys.meta_path, EmbeddableZipImporter(vzip)
+
+     # Old version for Python 2.7, only.
+     import os
diff --git a/srcpkgs/python3-pyside2/template b/srcpkgs/python3-pyside2/template
index 249efa90988425..52626436ce75f2 100644
--- a/srcpkgs/python3-pyside2/template
+++ b/srcpkgs/python3-pyside2/template
@@ -1,7 +1,7 @@
 # Template file for 'python3-pyside2'
 pkgname=python3-pyside2
 version=5.15.10
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/pyside2"
 build_style=cmake

From 6130baa882d8a72d153633fc7bb29182c1b5d20a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:35 -0400
Subject: [PATCH 076/110] konqueror: revbump for ffmpeg6

---
 srcpkgs/konqueror/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/konqueror/template b/srcpkgs/konqueror/template
index add972916753c6..50bbf4eec05e55 100644
--- a/srcpkgs/konqueror/template
+++ b/srcpkgs/konqueror/template
@@ -1,11 +1,11 @@
 # Template file for 'konqueror'
 pkgname=konqueror
 version=23.08.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DDESKTOPTOJSON_EXECUTABLE=/usr/bin/desktoptojson"
 hostmakedepends="extra-cmake-modules python3 qt5-host-tools qt5-qmake kdoctools
-kcoreaddons kconfig gettext"
+ kcoreaddons kconfig gettext"
 makedepends="qt5-devel qt5-webengine-devel qt5-declarative-devel
  qt5-webchannel-devel qt5-location-devel kcmutils-devel kdelibs4support-devel
  karchive-devel khtml-devel kdesu-devel kactivities5-devel"

From c94dac46918f6bb249b0309134bc926162d7668f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:58 -0400
Subject: [PATCH 077/110] qt5-speech: revbump for qt5-5.15.11

---
 srcpkgs/qt5-speech/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-speech/template b/srcpkgs/qt5-speech/template
index 1228bb60c41db4..27a7da1dbdb91b 100644
--- a/srcpkgs/qt5-speech/template
+++ b/srcpkgs/qt5-speech/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-speech'
 pkgname=qt5-speech
 version=5.15.11
-revision=1
+revision=2
 _commit=d32f4a479d38a11f547598004b975f4356424a16
 build_style=qmake
 configure_args="-- -flite -flite-alsa -speechd"

From cd4b1b0ed00068fdf1982cfe795b4e149169ea6b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Jun 2023 08:20:22 -0400
Subject: [PATCH 078/110] gtk4: revbump for ffmpeg6

---
 srcpkgs/gtk4/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gtk4/template b/srcpkgs/gtk4/template
index 3f2554ea3bc940..da41e85ec329c3 100644
--- a/srcpkgs/gtk4/template
+++ b/srcpkgs/gtk4/template
@@ -1,7 +1,7 @@
 # Template file for 'gtk4'
 pkgname=gtk4
 version=4.12.5
-revision=1
+revision=2
 build_style=meson
 build_helper="gir"
 configure_args="-Dman-pages=true -Ddocumentation=true -Dbuild-tests=false

From 0ae344ad54fc6e43e9b4c5f9c1932654bcf84ae2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:28:26 -0400
Subject: [PATCH 079/110] siril: revbump for ffmpeg6

---
 srcpkgs/siril/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/siril/template b/srcpkgs/siril/template
index 84332f79d060d2..62750dd247548f 100644
--- a/srcpkgs/siril/template
+++ b/srcpkgs/siril/template
@@ -1,7 +1,7 @@
 # Template file for 'siril'
 pkgname=siril
 version=0.9.12
-revision=10
+revision=11
 build_style=gnu-configure
 hostmakedepends="pkg-config intltool autoconf automake gettext-devel"
 makedepends="fftw-devel libconfig-devel libopencv-devel libffms2-devel

From 2bdc005a7adfd30c2a8f5e187fe872a61135f5e8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 22 Jun 2023 10:25:02 -0400
Subject: [PATCH 080/110] kdenlive: revbump for ffmpeg6

---
 srcpkgs/kdenlive/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kdenlive/template b/srcpkgs/kdenlive/template
index ecb48dfc74d29d..a3476d0b876b10 100644
--- a/srcpkgs/kdenlive/template
+++ b/srcpkgs/kdenlive/template
@@ -1,7 +1,7 @@
 # Template file for 'kdenlive'
 pkgname=kdenlive
 version=23.08.5
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="
  extra-cmake-modules kconfig kcoreaddons kdoctools pkg-config python3

From 0c888604669963baf038ce985953d43345a74d12 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:20:59 -0400
Subject: [PATCH 081/110] tracker-miners: revbump for ffmpeg6

---
 srcpkgs/tracker-miners/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tracker-miners/template b/srcpkgs/tracker-miners/template
index 0b97f47489f817..f196d2bf9e4a4c 100644
--- a/srcpkgs/tracker-miners/template
+++ b/srcpkgs/tracker-miners/template
@@ -1,7 +1,7 @@
 # Template file for 'tracker-miners'
 pkgname=tracker-miners
 version=3.6.1
-revision=1
+revision=2
 build_style=meson
 build_helper=qemu
 # missing libgrss for miner_rss

From 37e42904f4437dce3bc8f6a02f871cd14ce6cf1d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:21:21 -0400
Subject: [PATCH 082/110] mpd: revbump for ffmpeg6

---
 srcpkgs/mpd/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpd/template b/srcpkgs/mpd/template
index 4fd32b7be8c537..b8e2bd4c1b59c8 100644
--- a/srcpkgs/mpd/template
+++ b/srcpkgs/mpd/template
@@ -1,7 +1,7 @@
 # Template file for 'mpd'
 pkgname=mpd
 version=0.23.15
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dopus=enabled -Dmikmod=enabled -Dneighbor=true
  -Dsoundcloud=enabled -Dpipe=true -Dtwolame=enabled -Dbzip2=enabled

From 94d06c509e05c726b72a4e2db5048e2f5b0732bb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:02 -0400
Subject: [PATCH 083/110] tg_owt: revbump for ffmpeg6

---
 srcpkgs/tg_owt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tg_owt/template b/srcpkgs/tg_owt/template
index 34e8fef0540569..1a46a8bedf3473 100644
--- a/srcpkgs/tg_owt/template
+++ b/srcpkgs/tg_owt/template
@@ -1,7 +1,7 @@
 # Template file for 'tg_owt'
 pkgname=tg_owt
 version=0.0.0.20231221
-revision=2
+revision=3
 _commit=afd9d5d31798d3eacf9ed6c30601e91d0f1e4d60
 _libyuv_commit=04821d1e7d60845525e8db55c7bcd41ef5be9406
 _abseil_commit=8c0b94e793a66495e0b1f34a5eb26bd7dc672db0

From 273aa0b2672b6409912b8485f8b60579cf2553e2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:44 -0400
Subject: [PATCH 084/110] telegram-desktop: revbump for ffmpeg6

---
 srcpkgs/telegram-desktop/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/telegram-desktop/template b/srcpkgs/telegram-desktop/template
index 6dc6a553cfcec8..cf85a731370062 100644
--- a/srcpkgs/telegram-desktop/template
+++ b/srcpkgs/telegram-desktop/template
@@ -1,7 +1,7 @@
 # Template file for 'telegram-desktop'
 pkgname=telegram-desktop
 version=4.14.15
-revision=3
+revision=4
 build_style=cmake
 build_helper="qemu gir"
 configure_args="-DTDESKTOP_API_ID=209235

From ab0405c0d9f954a3fbaf9b5225e47d0ada5353bc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:12:09 -0400
Subject: [PATCH 085/110] openmw: revbump for ffmpeg6

---
 srcpkgs/openmw/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openmw/template b/srcpkgs/openmw/template
index 0abf5ff7cdbecc..b57180f1a4446f 100644
--- a/srcpkgs/openmw/template
+++ b/srcpkgs/openmw/template
@@ -1,7 +1,7 @@
 # Template file for 'openmw'
 pkgname=openmw
 version=0.48.0
-revision=2
+revision=3
 build_style=cmake
 _recast_commit=e75adf86f91eb3082220085e42dda62679f9a3ea
 _bullet_tag=3.17

From 09957c042ce1fa909f7755f5e59911a49be99809 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:14:53 -0400
Subject: [PATCH 086/110] lms: revbump for ffmpeg6

---
 srcpkgs/lms/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/lms/template b/srcpkgs/lms/template
index e358f75902a986..3b21c458de5199 100644
--- a/srcpkgs/lms/template
+++ b/srcpkgs/lms/template
@@ -1,7 +1,7 @@
 # Template file for 'lms'
 pkgname=lms
 version=3.42.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="wt-devel ffmpeg-devel boost-devel libconfig++-devel taglib-devel pam-devel libgraphicsmagick-devel gtest-devel libarchive-devel"

From 68960638c7ec450eaed43f51ead93fe8afef69a3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:18:18 -0400
Subject: [PATCH 087/110] freecad: DELETE

---
 srcpkgs/freecad/patches/001-include.patch     | 112 ------------------
 .../154-revert-gui-tmp-redirect-stderr.patch  |  68 -----------
 ...d63c8c9b1280978be841d04e68a0a55cceb9.patch |  30 -----
 srcpkgs/freecad/template                      |  12 +-
 4 files changed, 7 insertions(+), 215 deletions(-)
 delete mode 100644 srcpkgs/freecad/patches/001-include.patch
 delete mode 100644 srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
 delete mode 100644 srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch

diff --git a/srcpkgs/freecad/patches/001-include.patch b/srcpkgs/freecad/patches/001-include.patch
deleted file mode 100644
index 28b5af54999b96..00000000000000
--- a/srcpkgs/freecad/patches/001-include.patch
+++ /dev/null
@@ -1,112 +0,0 @@
-From 9a41845a417189776741297c50a3827ce292bc4f Mon Sep 17 00:00:00 2001
-From: Uwe <donovaly@users.noreply.github.com>
-Date: Sun, 3 Jul 2022 22:51:16 +0200
-Subject: [PATCH] [Part] OCCError.h: remove unneeded includes
-
-- also sort includes
----
- src/Mod/Part/App/OCCError.h             | 36 +++----------------------
- src/Mod/Part/App/OffsetCurvePyImp.cpp   | 12 ++++-----
- src/Mod/Part/App/OffsetSurfacePyImp.cpp | 10 +++----
- 3 files changed, 12 insertions(+), 46 deletions(-)
-
---- a/src/Mod/Part/App/OCCError.h
-+++ b/src/Mod/Part/App/OCCError.h
-@@ -23,36 +23,8 @@
- #ifndef _OCCError_h_
- #define _OCCError_h_
- 
--# include <Standard_Version.hxx>
- # include <Standard_Failure.hxx>
--# include <Standard_AbortiveTransaction.hxx>
--# include <Standard_ConstructionError.hxx>
--# if OCC_VERSION_HEX >= 0x060500
--# include <Standard_DefineException.hxx>
--# endif
--# include <Standard_DimensionError.hxx>
--# include <Standard_DimensionMismatch.hxx>
--# include <Standard_DivideByZero.hxx>
--# include <Standard_DomainError.hxx>
--# include <Standard_ImmutableObject.hxx>
--# include <Standard_LicenseError.hxx>
--# include <Standard_LicenseNotFound.hxx>
--# include <Standard_MultiplyDefined.hxx>
--# include <Standard_NegativeValue.hxx>
--# include <Standard_NoMoreObject.hxx>
--# include <Standard_NoSuchObject.hxx>
--# include <Standard_NotImplemented.hxx>
--# include <Standard_NullObject.hxx>
--# include <Standard_NullValue.hxx>
--# include <Standard_NumericError.hxx>
--# include <Standard_OutOfMemory.hxx>
--# include <Standard_OutOfRange.hxx>
--# include <Standard_Overflow.hxx>
--# include <Standard_ProgramError.hxx>
--# include <Standard_RangeError.hxx>
--# include <Standard_TooManyUsers.hxx>
--# include <Standard_TypeMismatch.hxx>
--# include <Standard_Underflow.hxx>
-+# include <Standard_Version.hxx>
- 
- #include <Mod/Part/PartGlobal.h>
- #include <Base/Console.h>
-@@ -88,4 +60,3 @@ PartExport extern PyObject* PartExceptio
- 
- #define PY_CATCH_OCC _PY_CATCH_OCC(return(NULL))
- #endif  // _OCCError_h_
--
---- a/src/Mod/Part/App/OffsetCurvePyImp.cpp
-+++ b/src/Mod/Part/App/OffsetCurvePyImp.cpp
-@@ -20,20 +20,20 @@
-  *                                                                         *
-  ***************************************************************************/
- 
--
- #include "PreCompiled.h"
- #ifndef _PreComp_
- # include <Geom_OffsetCurve.hxx>
- #endif
- 
--#include "OCCError.h"
--#include "Geometry.h"
-+#include <Base/GeometryPyCXX.h>
-+#include <Base/Vector3D.h>
-+#include <Base/VectorPy.h>
-+
- #include "OffsetCurvePy.h"
- #include "OffsetCurvePy.cpp"
-+#include "Geometry.h"
-+#include "OCCError.h"
- 
--#include <Base/GeometryPyCXX.h>
--#include <Base/VectorPy.h>
--#include <Base/Vector3D.h>
- 
- using namespace Part;
- 
---- a/src/Mod/Part/App/OffsetSurfacePyImp.cpp
-+++ b/src/Mod/Part/App/OffsetSurfacePyImp.cpp
-@@ -20,20 +20,16 @@
-  *                                                                         *
-  ***************************************************************************/
- 
--
- #include "PreCompiled.h"
- #ifndef _PreComp_
- # include <Geom_OffsetSurface.hxx>
- # include <memory>
- #endif
- 
--#include <Base/VectorPy.h>
--#include <Base/Vector3D.h>
--
- #include "OCCError.h"
--#include "Geometry.h"
--#include <Mod/Part/App/OffsetSurfacePy.h>
--#include <Mod/Part/App/OffsetSurfacePy.cpp>
-+#include "OffsetSurfacePy.h"
-+#include "OffsetSurfacePy.cpp"
-+
- 
- using namespace Part;
- 
diff --git a/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch b/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
deleted file mode 100644
index d6a9adabdec830..00000000000000
--- a/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
+++ /dev/null
@@ -1,68 +0,0 @@
-see https://github.com/FreeCAD/FreeCAD/commit/cfe94b00d3434f3e2c8b5114d2909f628c330fa8#commitcomment-71413407
-
-upstream: yes
-
-From 7b377a216b9185960e4cee980a6504dc1a755f50 Mon Sep 17 00:00:00 2001
-From: wmayer <wmayer@users.sourceforge.net>
-Date: Wed, 29 Jun 2022 15:19:18 +0200
-Subject: [PATCH] Gui: remove workaround for spnav 0.23 due to build failure
- with musl libc
-
----
- src/Gui/3Dconnexion/GuiNativeEventLinux.cpp | 27 ---------------------
- 1 file changed, 27 deletions(-)
-
---- a/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp
-+++ b/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp
-@@ -21,42 +21,17 @@
-  ***************************************************************************/
- 
- #include <FCConfig.h>
--#include <cstdio>
- 
- #include "GuiNativeEventLinux.h"
- 
- #include "GuiApplicationNativeEventAware.h"
- #include <Base/Console.h>
--#include <Base/FileInfo.h>
- #include <QMainWindow>
- 
- #include <QSocketNotifier>
- 
- #include <spnav.h>
- 
--namespace {
--class RedirectStdErr
--{
--public:
--    RedirectStdErr()
--        : fi(Base::FileInfo::getTempFileName())
--        , file(stderr)
--    {
--        stderr = fopen(fi.filePath().c_str(), "w");
--    }
--    ~RedirectStdErr()
--    {
--        fclose(stderr);
--        fi.deleteFile();
--        stderr = file;
--    }
--
--private:
--    Base::FileInfo fi;
--    FILE* file;
--};
--}
--
- Gui::GuiNativeEvent::GuiNativeEvent(Gui::GUIApplicationNativeEventAware *app)
- : GuiAbstractNativeEvent(app)
- {
-@@ -72,8 +47,6 @@ Gui::GuiNativeEvent::~GuiNativeEvent()
- 
- void Gui::GuiNativeEvent::initSpaceball(QMainWindow *window)
- {
--    // tmp. redirect stderr to a file to suppress an error message from spnav_open()
--    RedirectStdErr err;
-     Q_UNUSED(window)
-     if (spnav_open() == -1) {
-         Base::Console().Log("Couldn't connect to spacenav daemon. Please ignore if you don't have a spacemouse.\n");
diff --git a/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch b/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch
deleted file mode 100644
index d4acf370ca0a42..00000000000000
--- a/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-From fe02d63c8c9b1280978be841d04e68a0a55cceb9 Mon Sep 17 00:00:00 2001
-From: Roy-043 <70520633+Roy-043@users.noreply.github.com>
-Date: Thu, 29 Dec 2022 23:20:38 +0100
-Subject: [PATCH] Draft: update inspect.getargspec to inspect.getfullargspec
- (#8101)
-
----
- src/Mod/Draft/draftguitools/gui_snapper.py | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
---- a/src/Mod/Draft/draftguitools/gui_snapper.py
-+++ b/src/Mod/Draft/draftguitools/gui_snapper.py
-@@ -1426,7 +1426,7 @@ class Snapper:
-             Gui.Snapper.off()
-             self.ui.offUi()
-             if callback:
--                if len(inspect.getargspec(callback).args) > 1:
-+                if len(inspect.getfullargspec(callback).args) > 1:
-                     obj = None
-                     if self.snapInfo and ("Object" in self.snapInfo) and self.snapInfo["Object"]:
-                         obj = App.ActiveDocument.getObject(self.snapInfo["Object"])
-@@ -1445,7 +1445,7 @@ class Snapper:
-             Gui.Snapper.off()
-             self.ui.offUi()
-             if callback:
--                if len(inspect.getargspec(callback).args) > 1:
-+                if len(inspect.getfullargspec(callback).args) > 1:
-                     callback(None, None)
-                 else:
-                     callback(None)
diff --git a/srcpkgs/freecad/template b/srcpkgs/freecad/template
index c135701e38b9ad..7d5165f760bab9 100644
--- a/srcpkgs/freecad/template
+++ b/srcpkgs/freecad/template
@@ -1,7 +1,7 @@
 # Template file for 'freecad'
 pkgname=freecad
-version=0.20.2
-revision=7
+version=0.21.1
+revision=2
 build_wrksrc="FreeCAD-${version}"
 build_style=cmake
 pycompile_dirs="usr/lib/${pkgname}/Mod"
@@ -24,8 +24,10 @@ makedepends="python3-devel boost-devel libxerces-c-devel zlib-devel occt-devel
  coin3-devel libshiboken2-devel libspnav-devel pyside2-tools
  liblz4-devel libpyside2-python3-devel python3-matplotlib netcdf-devel
  jsoncpp-devel qt5-devel qt5-svg-devel qt5-tools-devel qt5-webkit-devel
- qt5-xmlpatterns-devel coin3-doc glew-devel python3-pivy"
-depends="python3-matplotlib python3-pyside2-webengine python3-pivy"
+ qt5-xmlpatterns-devel coin3-doc glew-devel python3-pivy qt5-webengine-devel
+ qt5-declarative-devel qt5-webchannel-devel qt5-location-devel"
+depends="python3-matplotlib python3-pyside2-webengine python3-pivy
+ python3-GitPython python3-Markdown"
 short_desc="General purpose 3D CAD modeler"
 maintainer="yopito <pierre.bourgin@free.fr>"
 license="LGPL-2.0-or-later"
@@ -35,7 +37,7 @@ distfiles="
  https://github.com/FreeCAD/FreeCAD/archive/${version}.tar.gz
  ${SOURCEFORGE_SITE}/cxx/pycxx-${_pycxxver}.tar.gz
 "
-checksum="46922f3a477e742e1a89cd5346692d63aebb2b67af887b3e463e094a4ae055da
+checksum="e9b1fd0323f101268c7f3be52db42e4a29222f2e306ae6c4a6fc309cb418d35a
  4b91e1e1141c23fbd5039df635c4bb6e75632168548f56b83ce177193c0c98c6"
 python_version=3
 patch_args="-Np1 -d ${build_wrksrc}"

From 89a6846b925aec0cf08d13881b97c1c15cac82f7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:47:18 -0400
Subject: [PATCH 088/110] libopenshot: revbump for ffmpeg6

---
 srcpkgs/libopenshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenshot/template b/srcpkgs/libopenshot/template
index 8e57c5f592169c..7a8f4520e78925 100644
--- a/srcpkgs/libopenshot/template
+++ b/srcpkgs/libopenshot/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenshot'
 pkgname=libopenshot
 version=0.3.0
-revision=3
+revision=4
 build_style=cmake
 # Builds fail with Ruby-2.4.1
 configure_args="-DENABLE_RUBY=OFF -DUSE_SYSTEM_JSONCPP=ON"

From b323e0ab88314b2a0dcfd7bb7dbce302db72e912 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:10:30 -0500
Subject: [PATCH 089/110] openimageio: revbump for ffmpeg6

---
 srcpkgs/openimageio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimageio/template b/srcpkgs/openimageio/template
index 27d2131bc0a61a..61f44b43f9083e 100644
--- a/srcpkgs/openimageio/template
+++ b/srcpkgs/openimageio/template
@@ -1,7 +1,7 @@
 # Template file for 'openimageio'
 pkgname=openimageio
 version=2.4.9.0
-revision=8
+revision=9
 build_style=cmake
 build_helper=qemu
 configure_args="-DUSE_QT=0 -DUSE_PYTHON=0 -DOIIO_BUILD_TESTS=0

From b8ab8a2626a438c87c11ee7089438e2f31480c6e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:11:57 -0500
Subject: [PATCH 090/110] synfigstudio: revbump for ffmpeg6

---
 srcpkgs/synfigstudio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/synfigstudio/template b/srcpkgs/synfigstudio/template
index 09e442da9a6805..2bc017cedca6b8 100644
--- a/srcpkgs/synfigstudio/template
+++ b/srcpkgs/synfigstudio/template
@@ -2,7 +2,7 @@
 # Should be kept in sync with 'synfig' and 'ETL'
 pkgname=synfigstudio
 version=1.4.4
-revision=4
+revision=5
 build_style=gnu-configure
 configure_args="--disable-update-mimedb"
 hostmakedepends="pkg-config intltool gettext synfig"

From 76a75edb4d19e4f726a12c0a646e2f97e5cd467d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:10 -0500
Subject: [PATCH 091/110] mixxx: revbump for ffmpeg6

---
 srcpkgs/mixxx/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mixxx/template b/srcpkgs/mixxx/template
index 6a79b328c1abf0..9a5141856860b9 100644
--- a/srcpkgs/mixxx/template
+++ b/srcpkgs/mixxx/template
@@ -1,7 +1,7 @@
 # Template file for 'mixxx'
 pkgname=mixxx
 version=2.3.3
-revision=7
+revision=8
 build_style=cmake
 configure_args="-DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="extra-cmake-modules pkg-config protobuf qt5-host-tools qt5-qmake"

From 2d867eb503b5b9e9358910d42c9d1d9fb450c93d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:28 -0500
Subject: [PATCH 092/110] musikcube: revbump for ffmpeg6

---
 srcpkgs/musikcube/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/musikcube/template b/srcpkgs/musikcube/template
index 8c4a51840859ec..fb60dd2049089a 100644
--- a/srcpkgs/musikcube/template
+++ b/srcpkgs/musikcube/template
@@ -1,7 +1,7 @@
 # Template file for 'musikcube'
 pkgname=musikcube
 version=3.0.0
-revision=3
+revision=4
 build_style=cmake
 make_cmd=make
 configure_args="-DNO_NCURSESW=1"

From 157e6a3516eb27cc002b6a191478e0713fc666cc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:45 -0500
Subject: [PATCH 093/110] electron24: revbump for ffmpeg6

---
 srcpkgs/electron24/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron24/template b/srcpkgs/electron24/template
index 7b4e28812f483e..1ca93fde97a854 100644
--- a/srcpkgs/electron24/template
+++ b/srcpkgs/electron24/template
@@ -1,7 +1,7 @@
 # Template file for 'electron24'
 pkgname=electron24
 version=24.3.0
-revision=2
+revision=3
 _nodever=18.14.0
 _chromiumver=112.0.5615.165
 archs="x86_64* aarch64*"

From 6cf38e2488c4743fe3144a739c4ba1eec161e2cc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:00 -0500
Subject: [PATCH 094/110] electron19: revbump for ffmpeg6

---
 srcpkgs/electron19/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron19/template b/srcpkgs/electron19/template
index 0ef959125cb085..5371c0b354604f 100644
--- a/srcpkgs/electron19/template
+++ b/srcpkgs/electron19/template
@@ -1,7 +1,7 @@
 # Template file for 'electron19'
 pkgname=electron19
 version=19.0.8
-revision=4
+revision=5
 _nodever=16.14.2
 _chromiumver=102.0.5005.125
 archs="x86_64* aarch64* ppc64le*"

From ae81fb61a24dd7dcfcec72202cc7290d79cb2295 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:13 -0500
Subject: [PATCH 095/110] wf-recorder: revbump for ffmpeg6

---
 srcpkgs/wf-recorder/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/wf-recorder/template b/srcpkgs/wf-recorder/template
index 08f986b0310067..63c45cf4b814d7 100644
--- a/srcpkgs/wf-recorder/template
+++ b/srcpkgs/wf-recorder/template
@@ -1,7 +1,7 @@
 # Template file for 'wf-recorder'
 pkgname=wf-recorder
 version=0.4.1
-revision=2
+revision=3
 build_style=meson
 hostmakedepends="pkg-config scdoc wayland-devel"
 makedepends="wayland-protocols wayland-devel ffmpeg-devel libgbm-devel x264-devel

From 07cec6ead314a9187547dd091a896a39fd67a398 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:26 -0500
Subject: [PATCH 096/110] obs: revbump for ffmpeg6

---
 srcpkgs/obs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/obs/template b/srcpkgs/obs/template
index b343f1131bfcf6..a25a67433e285e 100644
--- a/srcpkgs/obs/template
+++ b/srcpkgs/obs/template
@@ -1,7 +1,7 @@
 # Template file for 'obs'
 pkgname=obs
 version=30.0.0
-revision=2
+revision=3
 archs="i686* x86_64* ppc64le* aarch64* riscv64*"
 build_style=cmake
 configure_args="-DOBS_VERSION_OVERRIDE=${version} -DENABLE_JACK=ON

From 5a8ac3382ed7e856da78cad7cd029352686bf05b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:36 -0500
Subject: [PATCH 097/110] mlt7: revbump for ffmpeg6

---
 srcpkgs/mlt7/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mlt7/template b/srcpkgs/mlt7/template
index 98f302ad3a5167..7eb8c00fa1580c 100644
--- a/srcpkgs/mlt7/template
+++ b/srcpkgs/mlt7/template
@@ -1,7 +1,7 @@
 # Template file for 'mlt7'
 pkgname=mlt7
 version=7.20.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DSWIG_PYTHON=ON -DMOD_QT6=ON"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which

From 8f43328fe43c35e1c05038f9137f822af889bfea Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:48 -0500
Subject: [PATCH 098/110] qt6-multimedia: revbump for ffmpeg6

---
 srcpkgs/qt6-multimedia/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-multimedia/template b/srcpkgs/qt6-multimedia/template
index 67a577e1300fea..1da626ecf515a8 100644
--- a/srcpkgs/qt6-multimedia/template
+++ b/srcpkgs/qt6-multimedia/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-multimedia'
 pkgname=qt6-multimedia
 version=6.6.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DQT_FEATURE_gstreamer=ON"
 hostmakedepends="perl qt6-declarative-host-tools pkg-config qt6-shadertools"

From 9ccd7844a3df73585d63d794f67f40b567fae039 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:00:15 -0500
Subject: [PATCH 099/110] baresip: revbump for ffmpeg6

---
 srcpkgs/baresip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/baresip/template b/srcpkgs/baresip/template
index 12c8954ef7b9b7..b16b67beab8d2b 100644
--- a/srcpkgs/baresip/template
+++ b/srcpkgs/baresip/template
@@ -1,7 +1,7 @@
 # Template file for 'baresip'
 pkgname=baresip
 version=3.6.0
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config glib-devel"
 makedepends="libgsm-devel libpng-devel openssl-devel libsndfile-devel

From 4b739141779729895a75117faf80658d16ed8a5b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:30 -0500
Subject: [PATCH 100/110] QMPlay2: revbump for ffmpeg6

---
 srcpkgs/QMPlay2/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/QMPlay2/template b/srcpkgs/QMPlay2/template
index 46c80f64a13497..942258ce60fb7e 100644
--- a/srcpkgs/QMPlay2/template
+++ b/srcpkgs/QMPlay2/template
@@ -1,7 +1,7 @@
 # Template file for 'QMPlay2'
 pkgname=QMPlay2
 version=23.10.22
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools"
 makedepends="alsa-lib-devel ffmpeg-devel libass-devel libcdio-devel libgme-devel

From c552a2d71d5367dc0e0b69956dc59765c9241591 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:34 -0500
Subject: [PATCH 101/110] alsa-plugins: revbump for ffmpeg6

---
 srcpkgs/alsa-plugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/alsa-plugins/template b/srcpkgs/alsa-plugins/template
index a5708a7d82a8f0..7bfdad046c4830 100644
--- a/srcpkgs/alsa-plugins/template
+++ b/srcpkgs/alsa-plugins/template
@@ -1,7 +1,7 @@
 # Template file for 'alsa-plugins'
 pkgname=alsa-plugins
 version=1.2.7.1
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--disable-maemo-plugin"
 hostmakedepends="pkg-config"

From e1406dfb0eca4e1222f86ea72aa1dd7cb8972e70 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:43 -0500
Subject: [PATCH 102/110] minidlna: revbump for ffmpeg6

---
 srcpkgs/minidlna/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/minidlna/template b/srcpkgs/minidlna/template
index 5fa929f3a0c124..742991ecd04afc 100644
--- a/srcpkgs/minidlna/template
+++ b/srcpkgs/minidlna/template
@@ -1,7 +1,7 @@
 # Template file for 'minidlna'
 pkgname=minidlna
 version=1.3.3
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="
  --sbindir=/usr/bin

From 65a9758e97337cbb30a358263f9160645e6c893b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 17:57:47 -0500
Subject: [PATCH 103/110] mpv: revbump for ffmpeg6

---
 srcpkgs/mpv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpv/template b/srcpkgs/mpv/template
index 3d4349e27d8f62..bc40d6fcaa40d6 100644
--- a/srcpkgs/mpv/template
+++ b/srcpkgs/mpv/template
@@ -1,7 +1,7 @@
 # Template file for 'mpv'
 pkgname=mpv
 version=0.37.0
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcdda=enabled -Ddvbin=enabled -Ddvdnav=enabled
  -Dlibmpv=true -Dcplugins=enabled

From 84369341003d219fc649cabc35057402dc745090 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 17:59:29 -0500
Subject: [PATCH 104/110] qimgv: revbump for ffmpeg6

---
 srcpkgs/qimgv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qimgv/template b/srcpkgs/qimgv/template
index dd341dfe1bfce8..8a7e1c081ef12f 100644
--- a/srcpkgs/qimgv/template
+++ b/srcpkgs/qimgv/template
@@ -1,7 +1,7 @@
 # Template file for 'qimgv'
 pkgname=qimgv
 version=1.0.2
-revision=3
+revision=4
 build_style=cmake
 configure_args="$(vopt_if video -DVIDEO_SUPPORT=ON -DVIDEO_SUPPORT=OFF)
  $(vopt_if scale -DOPENCV_SUPPORT=ON -DOPENCV_SUPPORT=OFF)

From 17fef99acf492c7cb41caa48941fd18a3cee93d5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 18:00:36 -0500
Subject: [PATCH 105/110] kfilemetadata5: revbump for ffmpeg6

---
 srcpkgs/kfilemetadata5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kfilemetadata5/template b/srcpkgs/kfilemetadata5/template
index a0c4d809395323..b584f85ff2058b 100644
--- a/srcpkgs/kfilemetadata5/template
+++ b/srcpkgs/kfilemetadata5/template
@@ -1,7 +1,7 @@
 # Template file for 'kfilemetadata5'
 pkgname=kfilemetadata5
 version=5.115.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="kcoreaddons extra-cmake-modules pkg-config qt5-host-tools qt5-qmake
  gettext kcoreaddons python3"

From 562bf0f1e0279489af68067af93192ac7a31f723 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 8 Dec 2023 11:46:01 -0500
Subject: [PATCH 106/110] vba-m: revbump for ffmpeg6

---
 srcpkgs/vba-m/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vba-m/template b/srcpkgs/vba-m/template
index 3d135efa1d0b69..3c5a20db0fa984 100644
--- a/srcpkgs/vba-m/template
+++ b/srcpkgs/vba-m/template
@@ -2,7 +2,7 @@
 pkgname=vba-m
 reverts=1292_2
 version=2.1.9
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_GTK=TRUE -DENABLE_FFMPEG=TRUE -DENABLE_LINK=TRUE -DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="gettext pkg-config unzip zip yasm wxWidgets-gtk3-devel"

From a895caf20f1487774568b7acc714d09070a5efba Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 8 Dec 2023 11:46:19 -0500
Subject: [PATCH 107/110] dolphin-emu: revbump for ffmpeg6

---
 srcpkgs/dolphin-emu/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/dolphin-emu/template b/srcpkgs/dolphin-emu/template
index 862d3ae964eec4..a7ae0efb58fb75 100644
--- a/srcpkgs/dolphin-emu/template
+++ b/srcpkgs/dolphin-emu/template
@@ -1,7 +1,7 @@
 # Template file for 'dolphin-emu'
 pkgname=dolphin-emu
 version=5.0.19368
-revision=3
+revision=4
 _dolphin_commit=dadbeb4bae7e7fa23af2b46e0add4143094dc107
 _mgba_commit=44e074a15e9651481f7f652ac006a7c9d58cbeb9
 _googletest_commit=be03d00f5f0cc3a997d1a368bee8a1fe93651f48

From f97d0fe000078217fae67aae6b88041c389ea17f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 19 Dec 2023 15:38:51 -0500
Subject: [PATCH 108/110] qtox: revbump for ffmpeg4

---
 srcpkgs/qtox/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtox/template b/srcpkgs/qtox/template
index bb70e7f51240a4..755e4462bc0137 100644
--- a/srcpkgs/qtox/template
+++ b/srcpkgs/qtox/template
@@ -1,13 +1,13 @@
 # Template file for 'qtox'
 pkgname=qtox
 version=1.17.6
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DUPDATE_CHECK=OFF
  -DGIT_DESCRIBE=${version}
  $(vopt_if snorenotify -DDESKTOP_NOTIFICATIONS=ON)"
 hostmakedepends="pkg-config qt5-host-tools qt5-devel"
-makedepends="ffmpeg-devel libexif-devel libopenal-devel libsodium-devel
+makedepends="ffmpeg4-devel libexif-devel libopenal-devel libsodium-devel
  libvpx-devel opus-devel qrencode-devel qt5-svg-devel sonnet-devel
  sqlcipher-devel toxcore-devel
  $(vopt_if snorenotify snorenotify-devel)"

From cf5d12cf853c992a268963f2d98f9c7c700cc655 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 11 Jan 2024 11:52:00 -0500
Subject: [PATCH 109/110] arcan: revbump for ffmpeg6

---
 srcpkgs/arcan/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/arcan/template b/srcpkgs/arcan/template
index ff9091f90ebb10..030091a6cc9d0c 100644
--- a/srcpkgs/arcan/template
+++ b/srcpkgs/arcan/template
@@ -2,7 +2,7 @@
 # !! keep synced with: acfgfs aclip aloadimage
 pkgname=arcan
 version=0.6.2.1
-revision=2
+revision=3
 create_wrksrc=yes
 build_wrksrc=arcan/src
 build_style=cmake

From 04d8ba3763790c115e87bbbf6816512c1f0fcc4f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 11 Jan 2024 11:52:10 -0500
Subject: [PATCH 110/110] notcurses: revbump for ffmpeg6

---
 srcpkgs/notcurses/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/notcurses/template b/srcpkgs/notcurses/template
index 48a7463cb68eb9..515f316ab4576c 100644
--- a/srcpkgs/notcurses/template
+++ b/srcpkgs/notcurses/template
@@ -1,7 +1,7 @@
 # Template file for 'notcurses'
 pkgname=notcurses
 version=3.0.9
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DUSE_STATIC=ON -DUSE_QRCODEGEN=On $(vopt_bool man USE_PANDOC)"
 hostmakedepends="pkg-config $(vopt_if man pandoc)"

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (85 preceding siblings ...)
  2024-03-06 21:24 ` zlice
@ 2024-03-09 22:24 ` yoshiyoshyosh
  2024-03-09 22:41 ` [PR PATCH] [Updated] " zlice
                   ` (10 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: yoshiyoshyosh @ 2024-03-09 22:24 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 475 bytes --]

New comment by yoshiyoshyosh on void-packages repository

https://github.com/void-linux/void-packages/pull/43761#issuecomment-1986996401

Comment:
idk if you did tests for spek-x when building it but they seem to fail for me without this patch:
```diff
--- a/tests/perf.cc	2024-03-09 17:13:49.086603418 -0500
+++ b/tests/perf.cc	2024-03-09 17:13:59.453603753 -0500
@@ -1,3 +1,4 @@
+#include <cstdint>
 #include <cstdlib>
 #include <iostream>
 #include <fstream>
```

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (86 preceding siblings ...)
  2024-03-09 22:24 ` yoshiyoshyosh
@ 2024-03-09 22:41 ` zlice
  2024-03-09 22:43 ` zlice
                   ` (9 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2024-03-09 22:41 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 4960 bytes --]

There is an updated pull request by zlice against master on the void-packages repository

https://github.com/zlice/void-packages ffmpeg6-split
https://github.com/void-linux/void-packages/pull/43761

ffmpeg6 split
[ci skip]


#### Testing the changes

- I tested the changes in this PR: **YES**

main testing has been vaapi in Firefox Nightly and enc/dec in Shotcut on Intel A770

#### New package

- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**

#### Local build testing

- I built this PR locally for my native architecture, **x86_64**

#### Discussion

Continuation of https://github.com/void-linux/void-packages/pull/36315

`libavresample` is deprecated, but marked as a dependency when trying to build other packages and install `ffmpeg`(6). I think the right way to handle this is make a meta package and the add to removals?


##### Commit naming / misc

~~Commits are 'dirty' right now, running with [gstreamer 1.22.1 updates](https://github.com/void-linux/void-packages/pull/42861) and [Intel OpenCL](https://github.com/void-linux/void-packages/pull/43084). This will also make [intel packages pr](https://github.com/void-linux/void-packages/pull/41132) obsolete.~~ (see Requirements below)

Maintainer for previous ffmpeg(4) was orphaned, I can put my name in there if that matters, though I don't exactly see myself keeping up on ffmpeg.

~~This updates QT5 which looks like it is usually hosted by Johnny. Not sure if there's any reason to stay there or these sources are fine.~~ Using qt5.15.11 now, revbumps and some patches.

##### STILL FFMPEG4

These are a mix of emulators, games and/or older packages.

- ~~attract~~ (2.7 builds)
- ~~audacity (https://github.com/audacity/audacity/issues/2305 and https://sourceforge.net/p/portmedia/wiki/portsmf/ is 'beta')~~ (updated to 3.x, compiles with ffmpeg6)
- ~~ccextractor~~ (master patches)
- vice (3.8 compiles, needs makedepends libcurl-devel)
- kodi
- mlt (only dep left is flowblade - flowblade 2.12.0.2 with mlt7-python3 can 'render' videos with cpu and gpu - https://github.com/void-linux/void-packages/pull/47195)
- ~~synfig (mlt)~~ (work with mlt7, bump synfigstudio)
- tvheadend (download page recommends using 4.3 which compiles fine, 4.4 eta is Q1 2024)
- ~~ssr~~ (patches)
- ~~spek-alternative~~ (replace with spek-x)
- ~~ppsspp~~ ~~(1.17.1 is out, but there's 5+ distfiles that are all git commits)~~ (minor patch)
- olive (has been in alpha since 2020, seems they do nightly builds and appimages)
- moc
- mediastreamer (linphone links are dead, changed to github belladonne. their stuff never worked for me but there are updates if someone wants to give it a try)
- ~~libextractor (1.13 compiles, remove exiv2 patch)~~ (as yosh pointed out, 1.13 just removes ffmpeg bits)
- idjc (0.9.8 compiles, remove python3.10 patch, needs makedepends libebur128-devel and libshout-idjc 2.4.6 with '-r1' for distfile)
- hedgewars
- ~~ffmpegthumbnailer~~ (patches for moviedecoder.xxx files)
- ~~ffmpegthumbs~~ (latest compiles)
- deadbeef (1.9.6 may work but requires libdispatch from apple)
- ~~omxplayer~~ (package removed, deprecated in favor of vlc)
- qtav (fork has ffmpeg 5 patch - https://github.com/cmguo/QtAV)
- `vlc` (vlc4 will support ffmpeg5, there's a patch to build 3.x with ffmpeg5 but it will lack vaapi)
- `osg` (OpenSceneGraph plus `xine-lib`)


##### HAVE NOT BUILT YET

- ~~omxplayer (rpi only? ffmpeg4)~~ (removed)
- kodi (big, but ffmpeg4)


##### UPDATED (for ffmpeg6)

- ~~blender: update to 3.5.1~~ ~~will be revbump with~~ https://github.com/void-linux/void-packages/pull/43992
- unpaper: update to 7.0.0.
- guvcview: update to 2.0.8.
- ~~qt5: update to 5.15.8~~ updated by another PR to 5.15.11
- ~~qt5-webengine: update to 5.18.15~~ updated by another PR to 5.15.16 (some patching for ffmpeg build)
- ~~shiboken2: revbump for qt5.15.8 (patch)~~ updated by another PR to 5.15.10
- ~~python3-pyside2: update to 5.15.8 (patch)~~ updated by another PR to 5.15.10
- New package: spex-x replaces spek-alternative for ffmpeg-6.0


##### Requirements

- ~~[gstreamer 1.22.2](https://github.com/void-linux/void-packages/pull/42861)~~ - a few packages use ffmpeg-devel and require a revbump

- ~~[Intel Packages](https://github.com/void-linux/void-packages/pull/41132) [Intel Packages v2](https://github.com/void-linux/void-packages/pull/47330) - ffmpeg4 uses different libraries than 6 (libmfx / Intel-MediaSDK vs only oneVPL that Intel is moving to), both are included here~~. Using replacement oneVPL from OBS update.

- ~~[shotcut 23.05.14](https://github.com/void-linux/void-packages/pull/44260)~~

- https://github.com/void-linux/void-packages/pull/44781 will remove from this PR

A patch file from https://github.com/void-linux/void-packages/pull/43761.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ffmpeg6-split-43761.patch --]
[-- Type: text/x-diff, Size: 241380 bytes --]

From 0c2696f28d1ab40d8e73873c424b8a31704e70bd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:16:56 -0400
Subject: [PATCH 001/110] ffmpeg: update to 6.0.1.

---
 common/shlibs                                 | 26 ++++---
 srcpkgs/ffmpeg/files/altivec.patch            | 60 ---------------
 .../patches/armv5tel-floating-point.patch     | 18 -----
 srcpkgs/ffmpeg/patches/binutils-2.41.patch    | 73 -------------------
 ...h-libavcodec-libsvtav1-ten_bit_format.diff | 40 ----------
 .../workaround-mesa-readeon-vaapi-bug.patch   | 28 -------
 srcpkgs/ffmpeg/template                       | 40 +++++-----
 7 files changed, 37 insertions(+), 248 deletions(-)
 delete mode 100644 srcpkgs/ffmpeg/files/altivec.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/binutils-2.41.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 delete mode 100644 srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch

diff --git a/common/shlibs b/common/shlibs
index 131fbb19ebc2a7..d7810a9ae0d6fc 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -389,15 +389,23 @@ libid3tag.so.0 libid3tag-0.15.1b_1
 libgif.so.7 giflib-5.1.0_1
 libImlib2.so.1 imlib2-1.4.2_1
 libmp3lame.so.0 lame-3.98.2_1
-libavdevice.so.58 libavdevice-4.0_1
-libavformat.so.58 libavformat-4.0_1
-libswscale.so.5 libswscale-4.0_1
-libswresample.so.3 libswresample-4.0_1
-libavresample.so.4 libavresample-4.0_1
-libpostproc.so.55 libpostproc-4.0_1
-libavcodec.so.58 libavcodec-4.0_1
-libavutil.so.56 libavutil-4.0_1
-libavfilter.so.7 libavfilter-4.0_1
+libavdevice.so.60 libavdevice-6.0_1
+libavformat.so.60 libavformat-6.0_1
+libswscale.so.7 libswscale-6.0_1
+libswresample.so.4 libswresample-6.0_1
+libpostproc.so.57 libpostproc-6.0_1
+libavcodec.so.60 libavcodec-6.0_1
+libavutil.so.58 libavutil-6.0_1
+libavfilter.so.9 libavfilter-6.0_1
+libavdevice.so.58 libavdevice4-4.0_1
+libavformat.so.58 libavformat4-4.0_1
+libswscale.so.5 libswscale4-4.0_1
+libswresample.so.3 libswresample4-4.0_1
+libavresample.so.4 libavresample4-4.0_1
+libpostproc.so.55 libpostproc4-4.0_1
+libavcodec.so.58 libavcodec4-4.0_1
+libavutil.so.56 libavutil4-4.0_1
+libavfilter.so.7 libavfilter4-4.0_1
 libSDL-1.2.so.0 SDL-1.2.14_1
 libSDL_image-1.2.so.0 SDL_image-1.2.10_1
 libx264.so.157 x264-20190507.2245_1
diff --git a/srcpkgs/ffmpeg/files/altivec.patch b/srcpkgs/ffmpeg/files/altivec.patch
deleted file mode 100644
index 9c57200463320e..00000000000000
--- a/srcpkgs/ffmpeg/files/altivec.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-revert some altivec specific change on all ppc* except ppc64le*
-
-q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
-conditionally, for ppc* but not ppc64le* (the new code is valid for
-POWER8 VSX which LE targets as a baseline but not BE)"
-
-
-This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
----
- libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
- 1 file changed, 20 insertions(+), 4 deletions(-)
-
-diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
-index 536545293d..c1e2852adb 100644
---- a/libswscale/ppc/yuv2rgb_altivec.c
-+++ b/libswscale/ppc/yuv2rgb_altivec.c
-@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-     vector signed short R1, G1, B1;                                           \
-     vector unsigned char R, G, B;                                             \
-                                                                               \
-+    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
-+    vector unsigned char align_perm;                                          \
-+                                                                              \
-     vector signed short lCY       = c->CY;                                    \
-     vector signed short lOY       = c->OY;                                    \
-     vector signed short lCRV      = c->CRV;                                   \
-@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
-                                                                               \
-         for (j = 0; j < w / 16; j++) {                                        \
--            y0 = vec_xl(0, y1i);                                              \
-+            y1ivP = (const vector unsigned char *) y1i;                       \
-+            y2ivP = (const vector unsigned char *) y2i;                       \
-+            uivP  = (const vector unsigned char *) ui;                        \
-+            vivP  = (const vector unsigned char *) vi;                        \
-+                                                                              \
-+            align_perm = vec_lvsl(0, y1i);                                    \
-+            y0 = (vector unsigned char)                                       \
-+                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
-                                                                               \
--            y1 = vec_xl(0, y2i);                                              \
-+            align_perm = vec_lvsl(0, y2i);                                    \
-+            y1 = (vector unsigned char)                                       \
-+                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
-                                                                               \
--            u = (vector signed char) vec_xl(0, ui);                           \
-+            align_perm = vec_lvsl(0, ui);                                     \
-+            u = (vector signed char)                                          \
-+                    vec_perm(uivP[0], uivP[1], align_perm);                   \
-                                                                               \
--            v = (vector signed char) vec_xl(0, vi);                           \
-+            align_perm = vec_lvsl(0, vi);                                     \
-+            v = (vector signed char)                                          \
-+                    vec_perm(vivP[0], vivP[1], align_perm);                   \
-                                                                               \
-             u = (vector signed char)                                          \
-                     vec_sub(u,                                                \
--- 
-2.27.0
-
diff --git a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
deleted file mode 100644
index 9a55178c74f0fd..00000000000000
--- a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
-+++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
-@@ -39,6 +39,15 @@
- #endif
- #include <fenv.h>
- 
-+#if (FE_ALL_EXCEPT == 0)
-+/* E.g. ARM soft float does not define these */
-+#define FE_INVALID    0
-+#define FE_DIVBYZERO  0
-+#define FE_OVERFLOW   0
-+#define FE_UNDERFLOW  0
-+#define FE_INEXACT    0
-+#endif
-+
- #if CONFIG_LIBFONTCONFIG
- #include <fontconfig/fontconfig.h>
- #endif
diff --git a/srcpkgs/ffmpeg/patches/binutils-2.41.patch b/srcpkgs/ffmpeg/patches/binutils-2.41.patch
deleted file mode 100644
index 53a596d0ee7d4e..00000000000000
--- a/srcpkgs/ffmpeg/patches/binutils-2.41.patch
+++ /dev/null
@@ -1,73 +0,0 @@
-From effadce6c756247ea8bae32dc13bb3e6f464f0eb Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= <remi@remlab.net>
-Date: Sun, 16 Jul 2023 18:18:02 +0300
-Subject: [PATCH] avcodec/x86/mathops: clip constants used with shift
- instructions within inline assembly
-
-Fixes assembling with binutil as >= 2.41
-
-Signed-off-by: James Almer <jamrial@gmail.com>
----
- libavcodec/x86/mathops.h | 26 +++++++++++++++++++++++---
- 1 file changed, 23 insertions(+), 3 deletions(-)
-
-diff --git a/libavcodec/x86/mathops.h b/libavcodec/x86/mathops.h
-index 6298f5ed1983b..ca7e2dffc1076 100644
---- a/libavcodec/x86/mathops.h
-+++ b/libavcodec/x86/mathops.h
-@@ -35,12 +35,20 @@
- static av_always_inline av_const int MULL(int a, int b, unsigned shift)
- {
-     int rt, dummy;
-+    if (__builtin_constant_p(shift))
-     __asm__ (
-         "imull %3               \n\t"
-         "shrdl %4, %%edx, %%eax \n\t"
-         :"=a"(rt), "=d"(dummy)
--        :"a"(a), "rm"(b), "ci"((uint8_t)shift)
-+        :"a"(a), "rm"(b), "i"(shift & 0x1F)
-     );
-+    else
-+        __asm__ (
-+            "imull %3               \n\t"
-+            "shrdl %4, %%edx, %%eax \n\t"
-+            :"=a"(rt), "=d"(dummy)
-+            :"a"(a), "rm"(b), "c"((uint8_t)shift)
-+        );
-     return rt;
- }
- 
-@@ -113,19 +121,31 @@ __asm__ volatile(\
- // avoid +32 for shift optimization (gcc should do that ...)
- #define NEG_SSR32 NEG_SSR32
- static inline  int32_t NEG_SSR32( int32_t a, int8_t s){
-+    if (__builtin_constant_p(s))
-     __asm__ ("sarl %1, %0\n\t"
-          : "+r" (a)
--         : "ic" ((uint8_t)(-s))
-+         : "i" (-s & 0x1F)
-     );
-+    else
-+        __asm__ ("sarl %1, %0\n\t"
-+               : "+r" (a)
-+               : "c" ((uint8_t)(-s))
-+        );
-     return a;
- }
- 
- #define NEG_USR32 NEG_USR32
- static inline uint32_t NEG_USR32(uint32_t a, int8_t s){
-+    if (__builtin_constant_p(s))
-     __asm__ ("shrl %1, %0\n\t"
-          : "+r" (a)
--         : "ic" ((uint8_t)(-s))
-+         : "i" (-s & 0x1F)
-     );
-+    else
-+        __asm__ ("shrl %1, %0\n\t"
-+               : "+r" (a)
-+               : "c" ((uint8_t)(-s))
-+        );
-     return a;
- }
- 
diff --git a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
deleted file mode 100644
index aa948f7a8a2dfb..00000000000000
--- a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
+++ /dev/null
@@ -1,40 +0,0 @@
-#==================================================================================================
-# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
-# From: Christopher Degawa <christopher.degawa@intel.com>
-# Date: Thu, 20 Oct 2022 22:55:27 -0500
-# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
-#
-# compressed_ten_bit_format has been deprecated upstream and has no effect
-# and can be removed. Plus, technically it was never used in the first place
-# since it would require the app (ffmpeg) to set it and do additional
-# processing of the input frames.
-#
-# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
-#
-# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
-#==================================================================================================
---- a/libavcodec/libsvtav1.c
-+++ b/libavcodec/libsvtav1.c
-@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
- 
- static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
- {
--    const int    pack_mode_10bit =
--        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
--    const size_t luma_size_8bit  =
--        config->source_width * config->source_height * (1 << pack_mode_10bit);
--    const size_t luma_size_10bit =
--        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
-+    const size_t luma_size = config->source_width * config->source_height *
-+        (config->encoder_bit_depth > 8 ? 2 : 1);
- 
-     EbSvtIOFormat *in_data;
- 
--    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
-+    svt_enc->raw_size = luma_size * 3 / 2;
- 
-     // allocate buffer for in and out
-     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
--- 
-GitLab
-
diff --git a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
deleted file mode 100644
index 00e3f68a415b84..00000000000000
--- a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
-From: Rainer Hochecker <fernetmenta@online.de>
-Date: Sat, 26 Jan 2019 19:48:35 +0100
-Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
-
-This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
-It was hit frequently when watching h264 channels received via DVB-X.
-Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
----
- libavcodec/vaapi_h264.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
-index 5854587a255..f12fdc457a4 100644
---- a/libavcodec/vaapi_h264.c
-+++ b/libavcodec/vaapi_h264.c
-@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
-     H264SliceContext *sl = &h->slice_ctx[0];
-     int ret;
- 
-+    if (pic->nb_slices == 0) {
-+        ret = AVERROR_INVALIDDATA;
-+        goto finish;
-+    }
-+
-     ret = ff_vaapi_decode_issue(avctx, pic);
-     if (ret < 0)
-         goto finish;
diff --git a/srcpkgs/ffmpeg/template b/srcpkgs/ffmpeg/template
index 1ebb436135938d..f1e4712c41d087 100644
--- a/srcpkgs/ffmpeg/template
+++ b/srcpkgs/ffmpeg/template
@@ -1,15 +1,15 @@
 # Template file for 'ffmpeg'
 # audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
 pkgname=ffmpeg
-version=4.4.4
-revision=6
+version=6.0.1
+revision=1
 short_desc="Decoding, encoding and streaming software"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="https://www.ffmpeg.org"
 changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
 distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
-checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+checksum=9b16b8731d78e596b4be0d720428ca42df642bb2d78342881ff7f5bc29fc9623
 
 hostmakedepends="pkg-config perl"
 makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
@@ -26,12 +26,13 @@ makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-deve
  $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
  $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
  $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
- $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers Vulkan-Tools Vulkan-ValidationLayers')
+ $(vopt_if onevpl 'oneVPL oneVPL-devel')
  $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
 depends="ffplay>=${version}_${revision}"
 
 build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
- dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec onevpl"
 build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
 desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
 desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
@@ -39,9 +40,13 @@ desc_option_sofa="Enable support for AES SOFA"
 desc_option_webp="Enable support for WebP"
 
 case "$XBPS_TARGET_MACHINE" in
-	i686*|x86_64*)
-		hostmakedepends+=" nasm"
+	i686*)
 		build_options_default+=" vaapi vdpau nvenc nvdec"
+		hostmakedepends+=" nasm"
+		;;
+	x86_64*)
+		hostmakedepends+=" nasm"
+		build_options_default+=" vaapi vdpau nvenc nvdec onevpl"
 		;;
 	ppc64*) build_options_default+=" vaapi vdpau";;
 	mips*) CFLAGS="-mnan=legacy";;
@@ -65,8 +70,6 @@ post_patch() {
 		ppc64le*) ;;
 		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
 	esac
-
-	vsed -i libavfilter/vf_libvmaf.c -e 's!/usr/local/share/model/\(vmaf_v0.6.1\).pkl!/usr/share/vmaf/\1.json!'
 }
 
 do_configure() {
@@ -115,18 +118,19 @@ do_configure() {
 		$(vopt_enable x265 libx265) \
 		$(vopt_enable v4l2 libv4l2) \
 		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
-		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		--enable-libbs2b --enable-libvidstab \
 		$(vopt_enable dav1d libdav1d) \
 		$(vopt_enable zimg libzimg) \
 		$(vopt_enable webp libwebp) \
 		$(vopt_enable sofa libmysofa) \
 		$(vopt_enable vulkan) \
+		$(vopt_enable onevpl libvpl) \
 		$(vopt_enable drm libdrm) \
 		$(vopt_enable svtav1 libsvtav1) \
 		$(vopt_enable srt libsrt) \
 		$(vopt_enable rist librist) \
-		$(vopt_if nvenc '--enable-nvenc') \
-		$(vopt_if nvdec '--enable-nvdec')
+		$(vopt_enable nvenc nvenc) \
+		$(vopt_enable nvdec nvdec)
 }
 
 do_build() {
@@ -153,10 +157,8 @@ libavdevice_package() {
 }
 
 libavresample_package() {
-	short_desc="FFmpeg audio resampling library"
-	pkg_install() {
-		vmove "usr/lib/libavresample.so.*"
-	}
+	short_desc="Package deprecated, removal needed"
+	build_style=meta
 }
 
 libavformat_package() {
@@ -210,15 +212,13 @@ ffmpeg-devel_package() {
 		libavfilter>=${version}_${revision}
 		libpostproc>=${version}_${revision}
 		libswscale>=${version}_${revision}
-		libswresample>=${version}_${revision}
-		libavresample>=${version}_${revision}"
+		libswresample>=${version}_${revision}"
 	short_desc+=" - development files"
-
+	conflicts="ffmpeg4-devel"
 	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
 		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
 		nostrip_files="/usr/lib/libavfilter.a"
 	fi
-
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig

From a7689e165e47cfdc9ae4d8cbcdcd927b03ee483a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:14 -0400
Subject: [PATCH 002/110] openshot: revbump for ffmpeg6

---
 srcpkgs/openshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openshot/template b/srcpkgs/openshot/template
index 3849858fe963b5..12789bc9867499 100644
--- a/srcpkgs/openshot/template
+++ b/srcpkgs/openshot/template
@@ -1,7 +1,7 @@
 # Template file for 'openshot'
 pkgname=openshot
 version=3.1.1
-revision=1
+revision=2
 build_style=python3-module
 hostmakedepends="python3 python3-setuptools"
 makedepends="ffmpeg-devel python3-PyQt5"

From 604a4febd69e05e7bf475b0c5308b8ce7529eeff Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:36 -0400
Subject: [PATCH 003/110] sumo: revbump for ffmpeg6

---
 srcpkgs/sumo/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/sumo/template b/srcpkgs/sumo/template
index a730afa9fafa92..e2def06fa4bd7d 100644
--- a/srcpkgs/sumo/template
+++ b/srcpkgs/sumo/template
@@ -1,7 +1,7 @@
 # Template file for 'sumo'
 pkgname=sumo
 version=1.12.0
-revision=7
+revision=8
 build_style=cmake
 hostmakedepends="libgdal-tools pkg-config swig python3-setuptools"
 makedepends="python3-devel ffmpeg-devel fox-devel gl2ps-devel libgdal-devel

From 072ba5e8f636cfc5884fef252c381c51d96b8354 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:56:22 -0400
Subject: [PATCH 004/110] New package: ffmpeg4-4.4.4.

---
 srcpkgs/ffmpeg4-devel                         |   1 +
 srcpkgs/ffmpeg4/files/altivec.patch           |  60 +++++
 .../patches/armv5tel-floating-point.patch     |  18 ++
 srcpkgs/ffmpeg4/patches/binutils-2.41.patch   |  73 ++++++
 ...h-libavcodec-libsvtav1-ten_bit_format.diff |  40 +++
 .../workaround-mesa-readeon-vaapi-bug.patch   |  28 +++
 srcpkgs/ffmpeg4/template                      | 234 ++++++++++++++++++
 srcpkgs/libavcodec4                           |   1 +
 srcpkgs/libavdevice4                          |   1 +
 srcpkgs/libavfilter4                          |   1 +
 srcpkgs/libavformat4                          |   1 +
 srcpkgs/libavresample4                        |   1 +
 srcpkgs/libavutil4                            |   1 +
 srcpkgs/libpostproc4                          |   1 +
 srcpkgs/libswresample4                        |   1 +
 srcpkgs/libswscale4                           |   1 +
 16 files changed, 463 insertions(+)
 create mode 120000 srcpkgs/ffmpeg4-devel
 create mode 100644 srcpkgs/ffmpeg4/files/altivec.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/binutils-2.41.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 create mode 100644 srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
 create mode 100644 srcpkgs/ffmpeg4/template
 create mode 120000 srcpkgs/libavcodec4
 create mode 120000 srcpkgs/libavdevice4
 create mode 120000 srcpkgs/libavfilter4
 create mode 120000 srcpkgs/libavformat4
 create mode 120000 srcpkgs/libavresample4
 create mode 120000 srcpkgs/libavutil4
 create mode 120000 srcpkgs/libpostproc4
 create mode 120000 srcpkgs/libswresample4
 create mode 120000 srcpkgs/libswscale4

diff --git a/srcpkgs/ffmpeg4-devel b/srcpkgs/ffmpeg4-devel
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/ffmpeg4-devel
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/ffmpeg4/files/altivec.patch b/srcpkgs/ffmpeg4/files/altivec.patch
new file mode 100644
index 00000000000000..9c57200463320e
--- /dev/null
+++ b/srcpkgs/ffmpeg4/files/altivec.patch
@@ -0,0 +1,60 @@
+revert some altivec specific change on all ppc* except ppc64le*
+
+q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
+conditionally, for ppc* but not ppc64le* (the new code is valid for
+POWER8 VSX which LE targets as a baseline but not BE)"
+
+
+This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
+---
+ libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
+ 1 file changed, 20 insertions(+), 4 deletions(-)
+
+diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
+index 536545293d..c1e2852adb 100644
+--- a/libswscale/ppc/yuv2rgb_altivec.c
++++ b/libswscale/ppc/yuv2rgb_altivec.c
+@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+     vector signed short R1, G1, B1;                                           \
+     vector unsigned char R, G, B;                                             \
+                                                                               \
++    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
++    vector unsigned char align_perm;                                          \
++                                                                              \
+     vector signed short lCY       = c->CY;                                    \
+     vector signed short lOY       = c->OY;                                    \
+     vector signed short lCRV      = c->CRV;                                   \
+@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
+                                                                               \
+         for (j = 0; j < w / 16; j++) {                                        \
+-            y0 = vec_xl(0, y1i);                                              \
++            y1ivP = (const vector unsigned char *) y1i;                       \
++            y2ivP = (const vector unsigned char *) y2i;                       \
++            uivP  = (const vector unsigned char *) ui;                        \
++            vivP  = (const vector unsigned char *) vi;                        \
++                                                                              \
++            align_perm = vec_lvsl(0, y1i);                                    \
++            y0 = (vector unsigned char)                                       \
++                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
+                                                                               \
+-            y1 = vec_xl(0, y2i);                                              \
++            align_perm = vec_lvsl(0, y2i);                                    \
++            y1 = (vector unsigned char)                                       \
++                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
+                                                                               \
+-            u = (vector signed char) vec_xl(0, ui);                           \
++            align_perm = vec_lvsl(0, ui);                                     \
++            u = (vector signed char)                                          \
++                    vec_perm(uivP[0], uivP[1], align_perm);                   \
+                                                                               \
+-            v = (vector signed char) vec_xl(0, vi);                           \
++            align_perm = vec_lvsl(0, vi);                                     \
++            v = (vector signed char)                                          \
++                    vec_perm(vivP[0], vivP[1], align_perm);                   \
+                                                                               \
+             u = (vector signed char)                                          \
+                     vec_sub(u,                                                \
+-- 
+2.27.0
+
diff --git a/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
new file mode 100644
index 00000000000000..9a55178c74f0fd
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
@@ -0,0 +1,18 @@
+--- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
++++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
+@@ -39,6 +39,15 @@
+ #endif
+ #include <fenv.h>
+ 
++#if (FE_ALL_EXCEPT == 0)
++/* E.g. ARM soft float does not define these */
++#define FE_INVALID    0
++#define FE_DIVBYZERO  0
++#define FE_OVERFLOW   0
++#define FE_UNDERFLOW  0
++#define FE_INEXACT    0
++#endif
++
+ #if CONFIG_LIBFONTCONFIG
+ #include <fontconfig/fontconfig.h>
+ #endif
diff --git a/srcpkgs/ffmpeg4/patches/binutils-2.41.patch b/srcpkgs/ffmpeg4/patches/binutils-2.41.patch
new file mode 100644
index 00000000000000..53a596d0ee7d4e
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/binutils-2.41.patch
@@ -0,0 +1,73 @@
+From effadce6c756247ea8bae32dc13bb3e6f464f0eb Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= <remi@remlab.net>
+Date: Sun, 16 Jul 2023 18:18:02 +0300
+Subject: [PATCH] avcodec/x86/mathops: clip constants used with shift
+ instructions within inline assembly
+
+Fixes assembling with binutil as >= 2.41
+
+Signed-off-by: James Almer <jamrial@gmail.com>
+---
+ libavcodec/x86/mathops.h | 26 +++++++++++++++++++++++---
+ 1 file changed, 23 insertions(+), 3 deletions(-)
+
+diff --git a/libavcodec/x86/mathops.h b/libavcodec/x86/mathops.h
+index 6298f5ed1983b..ca7e2dffc1076 100644
+--- a/libavcodec/x86/mathops.h
++++ b/libavcodec/x86/mathops.h
+@@ -35,12 +35,20 @@
+ static av_always_inline av_const int MULL(int a, int b, unsigned shift)
+ {
+     int rt, dummy;
++    if (__builtin_constant_p(shift))
+     __asm__ (
+         "imull %3               \n\t"
+         "shrdl %4, %%edx, %%eax \n\t"
+         :"=a"(rt), "=d"(dummy)
+-        :"a"(a), "rm"(b), "ci"((uint8_t)shift)
++        :"a"(a), "rm"(b), "i"(shift & 0x1F)
+     );
++    else
++        __asm__ (
++            "imull %3               \n\t"
++            "shrdl %4, %%edx, %%eax \n\t"
++            :"=a"(rt), "=d"(dummy)
++            :"a"(a), "rm"(b), "c"((uint8_t)shift)
++        );
+     return rt;
+ }
+ 
+@@ -113,19 +121,31 @@ __asm__ volatile(\
+ // avoid +32 for shift optimization (gcc should do that ...)
+ #define NEG_SSR32 NEG_SSR32
+ static inline  int32_t NEG_SSR32( int32_t a, int8_t s){
++    if (__builtin_constant_p(s))
+     __asm__ ("sarl %1, %0\n\t"
+          : "+r" (a)
+-         : "ic" ((uint8_t)(-s))
++         : "i" (-s & 0x1F)
+     );
++    else
++        __asm__ ("sarl %1, %0\n\t"
++               : "+r" (a)
++               : "c" ((uint8_t)(-s))
++        );
+     return a;
+ }
+ 
+ #define NEG_USR32 NEG_USR32
+ static inline uint32_t NEG_USR32(uint32_t a, int8_t s){
++    if (__builtin_constant_p(s))
+     __asm__ ("shrl %1, %0\n\t"
+          : "+r" (a)
+-         : "ic" ((uint8_t)(-s))
++         : "i" (-s & 0x1F)
+     );
++    else
++        __asm__ ("shrl %1, %0\n\t"
++               : "+r" (a)
++               : "c" ((uint8_t)(-s))
++        );
+     return a;
+ }
+ 
diff --git a/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
new file mode 100644
index 00000000000000..aa948f7a8a2dfb
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
@@ -0,0 +1,40 @@
+#==================================================================================================
+# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
+# From: Christopher Degawa <christopher.degawa@intel.com>
+# Date: Thu, 20 Oct 2022 22:55:27 -0500
+# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
+#
+# compressed_ten_bit_format has been deprecated upstream and has no effect
+# and can be removed. Plus, technically it was never used in the first place
+# since it would require the app (ffmpeg) to set it and do additional
+# processing of the input frames.
+#
+# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
+#
+# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
+#==================================================================================================
+--- a/libavcodec/libsvtav1.c
++++ b/libavcodec/libsvtav1.c
+@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
+ 
+ static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
+ {
+-    const int    pack_mode_10bit =
+-        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
+-    const size_t luma_size_8bit  =
+-        config->source_width * config->source_height * (1 << pack_mode_10bit);
+-    const size_t luma_size_10bit =
+-        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
++    const size_t luma_size = config->source_width * config->source_height *
++        (config->encoder_bit_depth > 8 ? 2 : 1);
+ 
+     EbSvtIOFormat *in_data;
+ 
+-    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
++    svt_enc->raw_size = luma_size * 3 / 2;
+ 
+     // allocate buffer for in and out
+     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
+-- 
+GitLab
+
diff --git a/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
new file mode 100644
index 00000000000000..00e3f68a415b84
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
@@ -0,0 +1,28 @@
+From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
+From: Rainer Hochecker <fernetmenta@online.de>
+Date: Sat, 26 Jan 2019 19:48:35 +0100
+Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
+
+This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
+It was hit frequently when watching h264 channels received via DVB-X.
+Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
+---
+ libavcodec/vaapi_h264.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
+index 5854587a255..f12fdc457a4 100644
+--- a/libavcodec/vaapi_h264.c
++++ b/libavcodec/vaapi_h264.c
+@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
+     H264SliceContext *sl = &h->slice_ctx[0];
+     int ret;
+ 
++    if (pic->nb_slices == 0) {
++        ret = AVERROR_INVALIDDATA;
++        goto finish;
++    }
++
+     ret = ff_vaapi_decode_issue(avctx, pic);
+     if (ret < 0)
+         goto finish;
diff --git a/srcpkgs/ffmpeg4/template b/srcpkgs/ffmpeg4/template
new file mode 100644
index 00000000000000..9ba14bdb8ddf32
--- /dev/null
+++ b/srcpkgs/ffmpeg4/template
@@ -0,0 +1,234 @@
+# Template file for 'ffmpeg4'
+# audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
+pkgname=ffmpeg4
+version=4.4.4
+revision=1
+short_desc="Decoding, encoding and streaming software - ffmpeg4 libraries only"
+maintainer="Orphaned <orphan@voidlinux.org>"
+license="GPL-3.0-or-later"
+homepage="https://www.ffmpeg.org"
+changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
+distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
+checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+
+hostmakedepends="pkg-config perl"
+makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
+ libXext-devel libXvMC-devel libxcb-devel lame-devel libtheora-devel
+ libvorbis-devel x264-devel xvidcore-devel jack-devel SDL2-devel
+ libcdio-paranoia-devel librtmp-devel libmodplug-devel gnutls-devel
+ speex-devel celt-devel harfbuzz-devel libass-devel opus-devel ocl-icd-devel
+ libbs2b-devel libvidstab-devel vmaf-devel $(vopt_if pulseaudio pulseaudio-devel)
+ $(vopt_if vaapi libva-devel) $(vopt_if vdpau libvdpau-devel)
+ $(vopt_if x265 x265-devel) $(vopt_if v4l2 v4l-utils-devel)
+ $(vopt_if fdk_aac fdk-aac-devel) $(vopt_if vpx libvpx-devel)
+ $(vopt_if aom libaom-devel) $(vopt_if sndio sndio-devel)
+ $(vopt_if dav1d libdav1d-devel) $(vopt_if zimg zimg-devel)
+ $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
+ $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
+ $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
+
+build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
+
+desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
+desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
+desc_option_sofa="Enable support for AES SOFA"
+desc_option_webp="Enable support for WebP"
+
+case "$XBPS_TARGET_MACHINE" in
+	i686*|x86_64*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau nvenc nvdec"
+			;;
+	ppc64*) build_options_default+=" vaapi vdpau";;
+	mips*) CFLAGS="-mnan=legacy";;
+esac
+
+if [ "$XBPS_TARGET_WORDSIZE" != "32" ]; then
+	build_options_default+=" svtav1"
+fi
+
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+fi
+
+_apply_patch() {
+	local args="$1" pname="$(basename $2)"
+
+	if [ ! -f ".${pname}_done" ]; then
+		patch -N $args -i $2
+		touch .${pname}_done
+	fi
+}
+
+post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64le*) ;;
+		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
+	esac
+
+	vsed -i libavfilter/vf_libvmaf.c -e 's!/usr/local/share/model/\(vmaf_v0.6.1\).pkl!/usr/share/vmaf/\1.json!'
+}
+
+do_configure() {
+	# Fix gcc on x86_64-musl only
+	if [ "$XBPS_TARGET_MACHINE" = "x86_64-musl" ]; then
+		vsed -i configure -e "s;_cflags_speed='-O3';_cflags_speed='-O2';"
+	fi
+
+	if [ "$CROSS_BUILD" ]; then
+		case "$XBPS_TARGET_MACHINE" in
+			arm*) _arch="arm";;
+			aarch64*) _arch="aarch64";;
+			mips*) _arch="mips";;
+			ppc64*) _arch="ppc64";;
+			ppc*) _arch="ppc";;
+			*) _arch="${XBPS_TARGET_MACHINE%%-musl}";;
+		esac
+
+		_args+=" --enable-cross-compile
+			--sysroot=$XBPS_CROSS_BASE
+			--cross-prefix=${XBPS_CROSS_TRIPLET}-
+			--target-os=linux --arch=${_arch}"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc|ppc-musl) _args+=" --disable-altivec";;
+	esac
+
+	if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+		_args+=" --extra-libs=-latomic"
+	fi
+
+	./configure --prefix=/usr --disable-debug --enable-gpl --enable-gnutls \
+		--disable-stripping \
+		--enable-libcdio --enable-version3 --enable-runtime-cpudetect \
+		--enable-libmp3lame --enable-libvorbis --enable-libxvid \
+		--enable-libx264 $(vopt_enable vpx libvpx) --enable-libtheora \
+		--enable-shared --enable-static --enable-libxcb \
+		$(vopt_enable pulseaudio libpulse) --enable-libfreetype --enable-libmodplug \
+		--enable-libspeex --enable-libcelt --enable-libass \
+		--enable-libopus --enable-librtmp --enable-libjack \
+		$(vopt_if fdk_aac '--enable-nonfree --enable-libfdk-aac') \
+		--disable-libopencore_amrnb --disable-libopencore_amrwb \
+		--disable-libopenjpeg \
+		--enable-postproc --enable-opencl ${_args} --enable-libvmaf ${_args} \
+		$(vopt_enable x265 libx265) \
+		$(vopt_enable v4l2 libv4l2) \
+		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
+		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		$(vopt_enable dav1d libdav1d) \
+		$(vopt_enable zimg libzimg) \
+		$(vopt_enable webp libwebp) \
+		$(vopt_enable sofa libmysofa) \
+		$(vopt_enable vulkan) \
+		$(vopt_enable drm libdrm) \
+		$(vopt_enable svtav1 libsvtav1) \
+		$(vopt_enable srt libsrt) \
+		$(vopt_enable rist librist) \
+		$(vopt_if nvenc '--enable-nvenc') \
+		$(vopt_if nvdec '--enable-nvdec')
+}
+
+do_build() {
+	make ${makejobs}
+	make doc/ff{mpeg,play}.1
+}
+
+do_install() {
+	make DESTDIR=${DESTDIR} install install-man
+	rm -rf ${DESTDIR}/usr/bin
+}
+
+libavcodec4_package() {
+	short_desc="FFmpeg codec library"
+	pkg_install() {
+		vmove "usr/lib/libavcodec.so.*"
+	}
+}
+
+libavdevice4_package() {
+	short_desc="FFmpeg device handling library"
+	pkg_install() {
+		vmove "usr/lib/libavdevice.so.*"
+	}
+}
+
+libavresample4_package() {
+	short_desc="FFmpeg audio resampling library"
+	pkg_install() {
+		vmove "usr/lib/libavresample.so.*"
+	}
+}
+
+libavformat4_package() {
+	short_desc="FFmpeg file format library"
+	pkg_install() {
+		vmove "usr/lib/libavformat.so.*"
+	}
+}
+
+libavutil4_package() {
+	short_desc="FFmpeg utility library"
+	pkg_install() {
+		vmove "usr/lib/libavutil.so.*"
+	}
+}
+
+libavfilter4_package() {
+	short_desc="FFmpeg audio/video filter library"
+	pkg_install() {
+		vmove "usr/lib/libavfilter.so.*"
+	}
+}
+
+libpostproc4_package() {
+	short_desc="FFmpeg video postprocessing library"
+	pkg_install() {
+		vmove "usr/lib/libpostproc.so.*"
+	}
+}
+
+libswscale4_package() {
+	short_desc="FFmpeg video scaling library"
+	pkg_install() {
+		vmove "usr/lib/libswscale.so.*"
+	}
+}
+
+libswresample4_package() {
+	short_desc="FFmpeg video resampling library"
+	pkg_install() {
+		vmove "usr/lib/libswresample.so.*"
+	}
+}
+
+ffmpeg4-devel_package() {
+	depends="
+		libavcodec4>=${version}_${revision}
+		libavdevice4>=${version}_${revision}
+		libavformat4>=${version}_${revision}
+		libavutil4>=${version}_${revision}
+		libavfilter4>=${version}_${revision}
+		libpostproc4>=${version}_${revision}
+		libswscale4>=${version}_${revision}
+		libswresample4>=${version}_${revision}
+		libavresample4>=${version}_${revision}"
+	short_desc+=" - development files"
+	conflicts="ffmpeg-devel"
+	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
+		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
+		nostrip_files="/usr/lib/libavfilter.a"
+	fi
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.a"
+		vmove "usr/lib/*.so"
+		vmove usr/share/ffmpeg/examples
+		vmove usr/share/man/man3
+	}
+}
diff --git a/srcpkgs/libavcodec4 b/srcpkgs/libavcodec4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavcodec4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavdevice4 b/srcpkgs/libavdevice4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavdevice4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavfilter4 b/srcpkgs/libavfilter4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavfilter4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavformat4 b/srcpkgs/libavformat4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavformat4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavresample4 b/srcpkgs/libavresample4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavutil4 b/srcpkgs/libavutil4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavutil4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libpostproc4 b/srcpkgs/libpostproc4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libpostproc4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswresample4 b/srcpkgs/libswresample4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libswresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswscale4 b/srcpkgs/libswscale4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libswscale4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file

From 1cc59db4375d23b6674f6ee772ef4cbe411293f0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:04 -0400
Subject: [PATCH 005/110] opencv: update to 4.7.0.

---
 common/shlibs           | 104 ++++++++++++++++++++--------------------
 srcpkgs/opencv/template |   8 ++--
 2 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index d7810a9ae0d6fc..fea744e4d617f1 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2080,58 +2080,58 @@ libcapstone.so.5 capstone-5.0.1_1
 libhavege.so.2 libhaveged-1.9.11_1
 libnih.so.1 libnih-1.0.3_1
 libnih-dbus.so.1 libnih-1.0.3_1
-libopencv_quality.so.406 libopencv-4.6.0_1
-libopencv_reg.so.406 libopencv-4.6.0_1
-libopencv_surface_matching.so.406 libopencv-4.6.0_1
-libopencv_xphoto.so.406 libopencv-4.6.0_1
-libopencv_freetype.so.406 libopencv-4.6.0_1
-libopencv_fuzzy.so.406 libopencv-4.6.0_1
-libopencv_hfs.so.406 libopencv-4.6.0_1
-libopencv_img_hash.so.406 libopencv-4.6.0_1
-libopencv_line_descriptor.so.406 libopencv-4.6.0_1
-libopencv_saliency.so.406 libopencv-4.6.0_1
-libopencv_structured_light.so.406 libopencv-4.6.0_1
-libopencv_aruco.so.406 libopencv-4.6.0_1
-libopencv_bgsegm.so.406 libopencv-4.6.0_1
-libopencv_bioinspired.so.406 libopencv-4.6.0_1
-libopencv_ccalib.so.406 libopencv-4.6.0_1
-libopencv_face.so.406 libopencv-4.6.0_1
-libopencv_tracking.so.406 libopencv-4.6.0_1
-libopencv_xfeatures2d.so.406 libopencv-4.6.0_1
-libopencv_optflow.so.406 libopencv-4.6.0_1
-libopencv_ximgproc.so.406 libopencv-4.6.0_1
-libopencv_plot.so.406 libopencv-4.6.0_1
-libopencv_text.so.406 libopencv-4.6.0_1
-libopencv_ml.so.406 libopencv-4.6.0_1
-libopencv_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn.so.406 libopencv-4.6.0_1
-libopencv_shape.so.406 libopencv-4.6.0_1
-libopencv_stitching.so.406 libopencv-4.6.0_1
-libopencv_photo.so.406 libopencv-4.6.0_1
-libopencv_video.so.406 libopencv-4.6.0_1
-libopencv_calib3d.so.406 libopencv-4.6.0_1
-libopencv_features2d.so.406 libopencv-4.6.0_1
-libopencv_flann.so.406 libopencv-4.6.0_1
-libopencv_highgui.so.406 libopencv-4.6.0_1
-libopencv_videoio.so.406 libopencv-4.6.0_1
-libopencv_imgcodecs.so.406 libopencv-4.6.0_1
-libopencv_imgproc.so.406 libopencv-4.6.0_1
-libopencv_core.so.406 libopencv-4.6.0_1
-libopencv_superres.so.406 libopencv-4.6.0_1
-libopencv_videostab.so.406 libopencv-4.6.0_1
-libopencv_gapi.so.406 libopencv-4.6.0_1
-libopencv_xobjdetect.so.406 libopencv-4.6.0_1
-libopencv_datasets.so.406 libopencv-4.6.0_1
-libopencv_dnn_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn_superres.so.406 libopencv-4.6.0_1
-libopencv_dpm.so.406 libopencv-4.6.0_1
-libopencv_phase_unwrapping.so.406 libopencv-4.6.0_1
-libopencv_stereo.so.406 libopencv-4.6.0_1
-libopencv_rapid.so.406 libopencv-4.6.0_1
-libopencv_intensity_transform.so.406 libopencv-4.6.0_1
-libopencv_alphamat.so.406 libopencv-4.6.0_1
-libopencv_barcode.so.406 libopencv-4.6.0_1
-libopencv_mcc.so.406 libopencv-4.6.0_1
+libopencv_quality.so.407 libopencv-4.7.0_1
+libopencv_reg.so.407 libopencv-4.7.0_1
+libopencv_surface_matching.so.407 libopencv-4.7.0_1
+libopencv_xphoto.so.407 libopencv-4.7.0_1
+libopencv_freetype.so.407 libopencv-4.7.0_1
+libopencv_fuzzy.so.407 libopencv-4.7.0_1
+libopencv_hfs.so.407 libopencv-4.7.0_1
+libopencv_img_hash.so.407 libopencv-4.7.0_1
+libopencv_line_descriptor.so.407 libopencv-4.7.0_1
+libopencv_saliency.so.407 libopencv-4.7.0_1
+libopencv_structured_light.so.407 libopencv-4.7.0_1
+libopencv_aruco.so.407 libopencv-4.7.0_1
+libopencv_bgsegm.so.407 libopencv-4.7.0_1
+libopencv_bioinspired.so.407 libopencv-4.7.0_1
+libopencv_ccalib.so.407 libopencv-4.7.0_1
+libopencv_face.so.407 libopencv-4.7.0_1
+libopencv_tracking.so.407 libopencv-4.7.0_1
+libopencv_xfeatures2d.so.407 libopencv-4.7.0_1
+libopencv_optflow.so.407 libopencv-4.7.0_1
+libopencv_ximgproc.so.407 libopencv-4.7.0_1
+libopencv_plot.so.407 libopencv-4.7.0_1
+libopencv_text.so.407 libopencv-4.7.0_1
+libopencv_ml.so.407 libopencv-4.7.0_1
+libopencv_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn.so.407 libopencv-4.7.0_1
+libopencv_shape.so.407 libopencv-4.7.0_1
+libopencv_stitching.so.407 libopencv-4.7.0_1
+libopencv_photo.so.407 libopencv-4.7.0_1
+libopencv_video.so.407 libopencv-4.7.0_1
+libopencv_calib3d.so.407 libopencv-4.7.0_1
+libopencv_features2d.so.407 libopencv-4.7.0_1
+libopencv_flann.so.407 libopencv-4.7.0_1
+libopencv_highgui.so.407 libopencv-4.7.0_1
+libopencv_videoio.so.407 libopencv-4.7.0_1
+libopencv_imgcodecs.so.407 libopencv-4.7.0_1
+libopencv_imgproc.so.407 libopencv-4.7.0_1
+libopencv_core.so.407 libopencv-4.7.0_1
+libopencv_superres.so.407 libopencv-4.7.0_1
+libopencv_videostab.so.407 libopencv-4.7.0_1
+libopencv_gapi.so.407 libopencv-4.7.0_1
+libopencv_xobjdetect.so.407 libopencv-4.7.0_1
+libopencv_datasets.so.407 libopencv-4.7.0_1
+libopencv_dnn_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn_superres.so.407 libopencv-4.7.0_1
+libopencv_dpm.so.407 libopencv-4.7.0_1
+libopencv_phase_unwrapping.so.407 libopencv-4.7.0_1
+libopencv_stereo.so.407 libopencv-4.7.0_1
+libopencv_rapid.so.407 libopencv-4.7.0_1
+libopencv_intensity_transform.so.407 libopencv-4.7.0_1
+libopencv_alphamat.so.407 libopencv-4.7.0_1
+libopencv_barcode.so.407 libopencv-4.7.0_1
+libopencv_mcc.so.407 libopencv-4.7.0_1
 libuniconf.so.4.6 wvstreams-4.6.1_20
 libwvbase.so.4.6 wvstreams-4.6.1_20
 libwvutils.so.4.6 wvstreams-4.6.1_20
diff --git a/srcpkgs/opencv/template b/srcpkgs/opencv/template
index aea4bfc3a265cf..ce94de9424d18d 100644
--- a/srcpkgs/opencv/template
+++ b/srcpkgs/opencv/template
@@ -1,7 +1,7 @@
 # Template file for 'opencv'
 pkgname=opencv
-version=4.6.0
-revision=6
+version=4.7.0
+revision=1
 create_wrksrc=yes
 build_wrksrc=${pkgname}-${version}
 build_style=cmake
@@ -24,8 +24,8 @@ homepage="https://opencv.org"
 changelog="https://github.com/opencv/opencv/wiki/ChangeLog"
 distfiles="https://github.com/opencv/opencv/archive/${version}.tar.gz
  https://github.com/opencv/opencv_contrib/archive/${version}.tar.gz>contrib.tar.gz"
-checksum="1ec1cba65f9f20fe5a41fda1586e01c70ea0c9a6d7b67c9e13edf0cfe2239277
- 1777d5fd2b59029cf537e5fd6f8aa68d707075822f90bde683fcde086f85f7a7"
+checksum="8df0079cdbe179748a18d44731af62a245a45ebf5085223dc03133954c662973
+ 42df840cf9055e59d0e22c249cfb19f04743e1bdad113d31b1573d3934d62584"
 patch_args="-Np1 -d ${build_wrksrc}"
 # tests hang indenfinitely, even with test data included
 make_check=no

From 48b1b5b8adeed6f5b49f7328e985c19356572140 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 006/110] actiona: revbump for opencv-4.7.0

---
 srcpkgs/actiona/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/actiona/template b/srcpkgs/actiona/template
index cf5f0b7a2ae610..0d899311e6df75 100644
--- a/srcpkgs/actiona/template
+++ b/srcpkgs/actiona/template
@@ -1,7 +1,7 @@
 # Template file for 'actiona'
 pkgname=actiona
 version=3.10.1
-revision=2
+revision=3
 build_style=qmake
 configure_args="PKGCONFIG_OPENCV=opencv4"
 hostmakedepends="pkg-config qt5-plugin-mysql qt5-qmake qt5-host-tools"

From 4a7a47c02569dffa39c650c16b9335e74ad3d7dd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 007/110] retroshare: revbump for opencv-4.7.0

---
 srcpkgs/retroshare/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroshare/template b/srcpkgs/retroshare/template
index bb17569277a7f3..49e2c1cbe8a531 100644
--- a/srcpkgs/retroshare/template
+++ b/srcpkgs/retroshare/template
@@ -1,7 +1,7 @@
 # Template file for 'retroshare'
 pkgname=retroshare
 version=0.6.6
-revision=3
+revision=4
 build_style=qmake
 #XXX broadcast feature requires an ancient udp-discovery-cpp which either needs
 # to be fetched+patched (FTBFS) here or packaged :/

From 8021b42e43f002291a290afe055e642e05209528 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 008/110] waifu2x-converter-cpp: revbump for opencv-4.7.0

---
 srcpkgs/waifu2x-converter-cpp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waifu2x-converter-cpp/template b/srcpkgs/waifu2x-converter-cpp/template
index 361b8a23b94977..c5ac17eb54ea4c 100644
--- a/srcpkgs/waifu2x-converter-cpp/template
+++ b/srcpkgs/waifu2x-converter-cpp/template
@@ -1,7 +1,7 @@
 # Template file for 'waifu2x-converter-cpp'
 pkgname=waifu2x-converter-cpp
 version=5.2.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DINSTALL_MODELS=ON"
 hostmakedepends="pkg-config"

From da392a4140d060af693ff56b9725e85e81096f62 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:38 -0400
Subject: [PATCH 009/110] vlc: revbump for ffmpeg4

---
 srcpkgs/vlc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vlc/template b/srcpkgs/vlc/template
index 559b1c4fff339f..cfa11e6c26f28c 100644
--- a/srcpkgs/vlc/template
+++ b/srcpkgs/vlc/template
@@ -25,7 +25,7 @@ lib32disabled=yes
 hostmakedepends="automake libtool pkg-config flex gettext libgcrypt-devel
  live555-devel gettext-devel $(vopt_if lua lua52) $(vopt_if chromecast protobuf)"
 makedepends="
- avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg-devel freefont-ttf
+ avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg4-devel freefont-ttf
  gnutls-devel jack-devel liba52-devel libass-devel libbluray-devel
  libcdio-devel libdca-devel libdvbpsi-devel libdvdnav-devel libmad-devel
  libmatroska-devel libmodplug-devel libmpcdec-devel libmpeg2-devel

From c17e2cb3d7a97272b210c1191e94de113203b6a7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:55 -0400
Subject: [PATCH 010/110] osg: revbump for ffmpeg4

---
 srcpkgs/osg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/osg/template b/srcpkgs/osg/template
index 8ef0efc599a1b1..a131ceaf7a867b 100644
--- a/srcpkgs/osg/template
+++ b/srcpkgs/osg/template
@@ -8,7 +8,7 @@ build_helper="qemu"
 configure_args="-DLIB_POSTFIX="
 hostmakedepends="pkg-config xrandr"
 makedepends="MesaLib-devel gtkglext-devel libcurl-devel giflib-devel librsvg-devel
- jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg-devel xine-lib-devel
+ jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg4-devel xine-lib-devel
  SDL2-devel gst-plugins-base1-devel
  $(vopt_if openexr libopenexr-devel)
  $(vopt_if poppler poppler-glib-devel)

From 4b368b140c176398f411a4ba01cccecd22313a4e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:13 -0400
Subject: [PATCH 011/110] xine-lib: revbump for ffmpeg4

---
 srcpkgs/xine-lib/template | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/xine-lib/template b/srcpkgs/xine-lib/template
index 3be4d08eac77a3..ed6194c17d11e8 100644
--- a/srcpkgs/xine-lib/template
+++ b/srcpkgs/xine-lib/template
@@ -1,14 +1,14 @@
 # Template file for 'xine-lib'
 pkgname=xine-lib
-version=1.2.12
-revision=3
+version=1.2.13
+revision=1
 build_style=gnu-configure
 configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
  --disable-oss"
 hostmakedepends="automake gettext-devel libtool pkg-config perl"
 makedepends="
  zlib-devel alsa-lib-devel libxcb-devel libSM-devel libXext-devel libXv-devel
- libXvMC-devel liba52-devel libmad-devel ffmpeg-devel pulseaudio-devel
+ libXvMC-devel liba52-devel libmad-devel ffmpeg4-devel pulseaudio-devel
  jack-devel samba-devel libflac-devel libmodplug-devel libmpcdec-devel
  speex-devel libtheora-devel libvorbis-devel libdca-devel faad2-devel
  libcdio-devel libbluray-devel aalib-devel libcaca-devel libXinerama-devel
@@ -19,7 +19,7 @@ license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="http://www.xine-project.org"
 changelog="https://sourceforge.net/projects/xine/files/xine-lib/${version}/README.txt/view"
 distfiles="${SOURCEFORGE_SITE}/xine/${pkgname}-${version}.tar.xz"
-checksum=d606270468e1540c2a89c0d7f5fdf11e17ecc0c2698cc0bcb1065ff26abee098
+checksum=5f10d6d718a4a51c17ed1b32b031d4f9b80b061e8276535b2be31e5ac4b75e6f
 
 case "$XBPS_TARGET_MACHINE" in
 	i686-musl)

From 795d0dbc2bfb0b962778e5b0d4a01a5438fac4ca Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 012/110] attract: revbump for ffmpeg6

---
 srcpkgs/attract/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/attract/template b/srcpkgs/attract/template
index e769fb15456217..776cbe4ebd2c93 100644
--- a/srcpkgs/attract/template
+++ b/srcpkgs/attract/template
@@ -1,7 +1,7 @@
 # Template file for 'attract'
 pkgname=attract
 version=2.7.0
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="VERBOSE=1"
 make_use_env=yes

From 1111baad0223cfab9adf626ec3bf7dcea3ad609a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 013/110] aubio: revbump for ffmpeg6

---
 srcpkgs/aubio/patches/ffmpeg5.patch | 25 +++++++++++++++++++++++++
 srcpkgs/aubio/template              |  2 +-
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/aubio/patches/ffmpeg5.patch

diff --git a/srcpkgs/aubio/patches/ffmpeg5.patch b/srcpkgs/aubio/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..aace41a6e6d9a4
--- /dev/null
+++ b/srcpkgs/aubio/patches/ffmpeg5.patch
@@ -0,0 +1,25 @@
+From 8a05420e5dd8c7b8b2447f82dc919765876511b3 Mon Sep 17 00:00:00 2001
+From: Paul Brossier <piem@piem.org>
+Date: Tue, 25 Jan 2022 18:30:27 +0100
+Subject: [PATCH] [source_avcodec] define FF_API_LAVF_AVCTX for libavcodec >
+ 59, thx @berolinux (closes gh-353)
+
+---
+ src/io/source_avcodec.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/io/source_avcodec.c b/src/io/source_avcodec.c
+index e0ae93b5..1421bd9a 100644
+--- a/src/io/source_avcodec.c
++++ b/src/io/source_avcodec.c
+@@ -68,6 +68,10 @@
+ #define AUBIO_AVCODEC_MAX_BUFFER_SIZE AV_INPUT_BUFFER_MIN_SIZE
+ #endif
+ 
++#if LIBAVCODEC_VERSION_MAJOR >= 59
++#define FF_API_LAVF_AVCTX 1
++#endif
++
+ struct _aubio_source_avcodec_t {
+   uint_t hop_size;
+   uint_t samplerate;
diff --git a/srcpkgs/aubio/template b/srcpkgs/aubio/template
index ad1c4b25699178..7d875cc02541a7 100644
--- a/srcpkgs/aubio/template
+++ b/srcpkgs/aubio/template
@@ -1,7 +1,7 @@
 # Template file for 'aubio'
 pkgname=aubio
 version=0.4.9
-revision=1
+revision=2
 build_style=waf3
 # XXX lash, pure and swig support.
 hostmakedepends="pkg-config txt2man"

From bc08f27030cfe78ef324623ad380a2003111fa38 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 014/110] audacious-plugins: revbump for ffmpeg6

---
 .../audacious-plugins/patches/ffmpeg5.patch   | 43 +++++++++++++++++++
 srcpkgs/audacious-plugins/template            |  2 +-
 2 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/audacious-plugins/patches/ffmpeg5.patch

diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg5.patch b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..4e5e34099d71c4
--- /dev/null
+++ b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
@@ -0,0 +1,43 @@
+commit 298aa371c56c2f52c25a33d9bdec4918b11cebdc
+Author: tibequadorian <tibequadorian@posteo.de>
+Date:   Sat Mar 19 18:40:12 2022 +0100
+
+    audacious-plugins: rebuild against ffmpeg-5.0
+
+diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+new file mode 100644
+index 0000000000..617c11215b
+--- /dev/null
++++ b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+@@ -0,0 +1,31 @@
++From f60beb400eeb1e4778bbfd738bc4a4ccef3de539 Mon Sep 17 00:00:00 2001
++From: John Lindgren <john@jlindgren.net>
++Date: Sat, 5 Mar 2022 12:05:34 -0500
++Subject: [PATCH] Fix build with FFmpeg 5.0
++
++---
++ src/ffaudio/ffaudio-core.cc | 4 ++--
++ 1 file changed, 2 insertions(+), 2 deletions(-)
++
++diff --git a/src/ffaudio/ffaudio-core.cc b/src/ffaudio/ffaudio-core.cc
++index 16dc63e3a..a2b95fd6c 100644
++--- a/src/ffaudio/ffaudio-core.cc
+++++ b/src/ffaudio/ffaudio-core.cc
++@@ -274,7 +274,7 @@ static AVInputFormat * get_format_by_content (const char * name, VFSFile & file)
++         AVProbeData d = {name, buf, filled};
++         score = target;
++ 
++-        f = av_probe_input_format2 (& d, true, & score);
+++        f = (AVInputFormat *) av_probe_input_format2 (& d, true, & score);
++         if (f)
++             break;
++ 
++@@ -347,7 +347,7 @@ static bool find_codec (AVFormatContext * c, CodecInfo * cinfo)
++ #endif
++         if (stream && stream->codecpar && stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
++         {
++-            AVCodec * codec = avcodec_find_decoder (stream->codecpar->codec_id);
+++            AVCodec * codec = (AVCodec *) avcodec_find_decoder (stream->codecpar->codec_id);
++ 
++             if (codec)
++             {
diff --git a/srcpkgs/audacious-plugins/template b/srcpkgs/audacious-plugins/template
index 05e53a9adf78ff..4b1968e03de781 100644
--- a/srcpkgs/audacious-plugins/template
+++ b/srcpkgs/audacious-plugins/template
@@ -2,7 +2,7 @@
 #Keep in sync with audacious!
 pkgname=audacious-plugins
 version=4.3.1
-revision=3
+revision=4
 build_style=meson
 configure_args="$(vopt_bool gtk3 gtk) $(vopt_bool gtk3)
  $(vopt_bool qt) $(vopt_bool qt qt6)"

From d9486e08e910e9c2b111300f0e0a8d6f77c987a1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 015/110] audacity: revbump for ffmpeg6

---
 srcpkgs/audacity/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/audacity/template b/srcpkgs/audacity/template
index 7b838119ab2611..84b49305edcef1 100644
--- a/srcpkgs/audacity/template
+++ b/srcpkgs/audacity/template
@@ -1,7 +1,7 @@
 # Template file for 'audacity'
 pkgname=audacity
 version=3.4.2
-revision=1
+revision=2
 build_style=cmake
 build_helper="cmake-wxWidgets-gtk3 qemu"
 configure_args="-Daudacity_use_ffmpeg=loaded -Daudacity_lib_preference=system

From a69f5d92eacbe5da4ac12891dbca1c7da1178e3e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 016/110] avidemux: revbump for ffmpeg6

---
 srcpkgs/avidemux/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/avidemux/template b/srcpkgs/avidemux/template
index 253a0243e22599..557285982d2b8f 100644
--- a/srcpkgs/avidemux/template
+++ b/srcpkgs/avidemux/template
@@ -1,7 +1,7 @@
 # Template file for 'avidemux'
 pkgname=avidemux
 version=2.8.0
-revision=2
+revision=3
 # Can't be compiled for aarch64, arm* or mips*
 archs="x86_64* i686*"
 hostmakedepends="cmake pkg-config qt5-host-tools qt5-devel tar yasm"

From c862b2134316a2686c420cfcba4d6e566d093b3b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 017/110] blender: revbump for ffmpeg6

---
 srcpkgs/blender/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index 68787b76a26c18..e238717ac8c729 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -9,8 +9,8 @@ configure_args="-DWITH_INSTALL_PORTABLE=OFF -DWITH_PYTHON_INSTALL=OFF
  -DWITH_JACK=ON -DWITH_CODEC_FFMPEG=ON -DWITH_CODEC_SNDFILE=ON -DWITH_OPENMP=ON
  -DWITH_FFTW3=ON -DWITH_MOD_OCEANSIM=ON -DWITH_CYCLES_EMBREE=OFF -DWITH_OPENCOLORIO=ON
  -DWITH_IMAGE_OPENEXR=ON -DWITH_IMAGE_OPENJPEG=ON -DWITH_OPENSUBDIV=ON
- -DWITH_OPENCOLLADA=ON -DWITH_SYSTEM_GLEW=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
- -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_LIBDECOR=ON
+ -DWITH_OPENCOLLADA=ON -DWITH_OPENVDB=ON -DWITH_ALEMBIC=ON
+ -DWITH_GHOST_X11=ON -DWITH_GHOST_WAYLAND=ON -DWITH_GHOST_WAYLAND_LIBDECOR=ON
  -DWITH_BUILDINFO=OFF -DPYTHON_VERSION=${py3_ver} -DPYTHON_LIBPATH=/usr/lib
  -DPYTHON_LIBRARY=python${py3_ver}${py3_abiver} -DPYTHON_INCLUDE_DIRS=/${py3_inc}
  -DWITH_SYSTEM_LZO=ON -DWITH_SYSTEM_EIGEN3=ON -DWITH_SYSTEM_FREETYPE=ON"

From 93421b3826bfb62d40c3c371f4bed035fcfce3d7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 018/110] cantata: revbump for ffmpeg6

---
 srcpkgs/cantata/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cantata/template b/srcpkgs/cantata/template
index 4b417d80d5c2da..8a90aaa4c07a2a 100644
--- a/srcpkgs/cantata/template
+++ b/srcpkgs/cantata/template
@@ -1,7 +1,7 @@
 # Template file for 'cantata'
 pkgname=cantata
 version=2.5.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools qt5-tools"
 makedepends="qt5-devel qt5-tools-devel qt5-svg-devel qt5-xmlpatterns-devel

From 3dd6dab8aea6f715b414def14bc5f2f55cda9466 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 019/110] ccextractor: revbump for ffmpeg6

---
 ...5-and-tesseract-5-compatibility-1479.patch | 168 ++++++++++++++++++
 srcpkgs/ccextractor/template                  |   2 +-
 2 files changed, 169 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ccextractor/patches/0001-fix-ffmpeg-5-and-tesseract-5-compatibility-1479.patch

diff --git a/srcpkgs/ccextractor/patches/0001-fix-ffmpeg-5-and-tesseract-5-compatibility-1479.patch b/srcpkgs/ccextractor/patches/0001-fix-ffmpeg-5-and-tesseract-5-compatibility-1479.patch
new file mode 100644
index 00000000000000..bcab4890554b9a
--- /dev/null
+++ b/srcpkgs/ccextractor/patches/0001-fix-ffmpeg-5-and-tesseract-5-compatibility-1479.patch
@@ -0,0 +1,168 @@
+From b1cbfcea9b9c687143bf0d80bc179b563e99d025 Mon Sep 17 00:00:00 2001
+From: Prateek Sunal <prtksunal@gmail.com>
+Date: Thu, 9 Mar 2023 01:44:53 +0530
+Subject: [PATCH] fix: ffmpeg 5 and tesseract 5 compatibility (#1479)
+
+* fix: replace deprecated `codec` property with `codecpar`
+
+* fix: replace deprecated method `avcodec_decode_video2` with `avcodec_receive_frame` and `avcodec_send_packet`
+
+* Update CHANGES.TXT
+
+* fix: remove deprecated `av_register_all` function
+
+* fix: formatting
+
+* fix: add support for tesseract 5
+
+* fix: tesseract v5
+
+* fix: hardsubx codec context error
+
+* fix: lint const warning
+---
+ docs/CHANGES.TXT               |  1 +
+ src/lib_ccx/ffmpeg_intgr.c     |  7 +++---
+ src/lib_ccx/hardsubx.c         | 25 ++++++++++++------
+ src/lib_ccx/hardsubx_decoder.c | 27 ++++++++------------
+ src/lib_ccx/ocr.c              | 46 ++++++++++++----------------------
+ 5 files changed, 47 insertions(+), 59 deletions(-)
+
+diff --git a/src/lib_ccx/ffmpeg_intgr.c b/src/lib_ccx/ffmpeg_intgr.c
+index be988890..e6f21e20 100644
+--- a/src/lib_ccx/ffmpeg_intgr.c
++++ b/src/lib_ccx/ffmpeg_intgr.c
+@@ -66,7 +66,6 @@ void *init_ffmpeg(const char *path)
+ 	struct ffmpeg_ctx *ctx;
+ 	AVCodec *dec = NULL;
+ 	avcodec_register_all();
+-	av_register_all();
+ 
+ 	if (ccx_options.debug_mask & CCX_DMT_VERBOSE)
+ 		av_log_set_level(AV_LOG_INFO);
+@@ -133,7 +132,6 @@ int ff_get_ccframe(void *arg, unsigned char *data, int maxlen)
+ 	struct ffmpeg_ctx *ctx = arg;
+ 	int len = 0;
+ 	int ret = 0;
+-	int got_frame;
+ 	AVPacket packet;
+ 
+ 	ret = av_read_frame(ctx->ifmt, &packet);
+@@ -151,12 +149,13 @@ int ff_get_ccframe(void *arg, unsigned char *data, int maxlen)
+ 		return AVERROR(EAGAIN);
+ 	}
+ 
+-	ret = avcodec_decode_video2(ctx->dec_ctx, ctx->frame, &got_frame, &packet);
++	avcodec_send_packet(ctx->codec_ctx, &ctx->packet);
++	ret = avcodec_receive_frame(ctx->dec_ctx, ctx->frame);
+ 	if (ret < 0)
+ 	{
+ 		av_log(NULL, AV_LOG_ERROR, "unable to decode packet\n");
+ 	}
+-	else if (!got_frame)
++	else if (ret != 0)
+ 	{
+ 		return AVERROR(EAGAIN);
+ 	}
+diff --git a/src/lib_ccx/hardsubx.c b/src/lib_ccx/hardsubx.c
+index 411377f9..fb844c91 100644
+--- a/src/lib_ccx/hardsubx.c
++++ b/src/lib_ccx/hardsubx.c
+@@ -12,9 +12,6 @@
+
+ int hardsubx_process_data(struct lib_hardsubx_ctx *ctx)
+ {
+-	// Get the required media attributes and initialize structures
+-	av_register_all();
+-
+ 	if (avformat_open_input(&ctx->format_ctx, ctx->inputfile[0], NULL, NULL) != 0)
+ 	{
+ 		fatal(EXIT_READ_ERROR, "Error reading input file!\n");
+@@ -32,7 +29,7 @@
+ 	ctx->video_stream_id = -1;
+ 	for (int i = 0; i < ctx->format_ctx->nb_streams; i++)
+ 	{
+-		if (ctx->format_ctx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO)
++		if (ctx->format_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
+ 		{
+ 			ctx->video_stream_id = i;
+ 			break;
+@@ -43,8 +40,21 @@
+ 		fatal(EXIT_READ_ERROR, "Video Stream not found!\n");
+ 	}
+
+-	ctx->codec_ctx = ctx->format_ctx->streams[ctx->video_stream_id]->codec;
+-	ctx->codec = avcodec_find_decoder(ctx->codec_ctx->codec_id);
++	ctx->codec_ctx = avcodec_alloc_context3(NULL);
++	if (!ctx->codec_ctx)
++	{
++		    fatal(EXIT_NOT_ENOUGH_MEMORY, "Could not allocate codec context!\n");
++	}
++
++	// Assign codec parameters to codec context
++	if (avcodec_parameters_to_context(ctx->codec_ctx, ctx->format_ctx->streams[ctx->video_stream_id]->codecpar) < 0)
++	{
++		    fatal(EXIT_READ_ERROR, "Could not initialize codec context!\n");
++	}
++
++	// Find decoder for the codec context
++	ctx->codec = (AVCodec *)avcodec_find_decoder(ctx->codec_ctx->codec_id);
++
+ 	if (ctx->codec == NULL)
+ 	{
+ 		fatal(EXIT_READ_ERROR, "Input codec is not supported!\n");
+diff --git a/src/lib_ccx/hardsubx_decoder.c b/src/lib_ccx/hardsubx_decoder.c
+index bd9b0980..b5dfaec4 100644
+--- a/src/lib_ccx/hardsubx_decoder.c
++++ b/src/lib_ccx/hardsubx_decoder.c
+@@ -371,7 +371,6 @@
+ int hardsubx_process_frames_tickertext(struct lib_hardsubx_ctx *ctx, struct encoder_ctx *enc_ctx)
+ {
+ 	// Search for ticker text at the bottom of the screen, such as in Russia TV1 or stock prices
+-	int got_frame;
+ 	int cur_sec = 0, total_sec, progress;
+ 	int frame_number = 0;
+ 	char *ticker_text = NULL;
+@@ -382,8 +381,8 @@
+ 		{
+ 			frame_number++;
+ 			//Decode the video stream packet
+-			avcodec_decode_video2(ctx->codec_ctx, ctx->frame, &got_frame, &ctx->packet);
+-			if (got_frame && frame_number % 1000 == 0)
++      avcodec_send_packet(ctx->codec_ctx, &ctx->packet);
++      if (avcodec_receive_frame(ctx->codec_ctx, ctx->frame) == 0 && frame_number % 1000 == 0)
+ 			{
+ 				// sws_scale is used to convert the pixel format to RGB24 from all other cases
+ 				sws_scale(
+@@ -434,9 +433,8 @@
+ 			frame_number++;
+
+ 			//Decode the video stream packet
+-			avcodec_decode_video2(ctx->codec_ctx, ctx->frame, &got_frame, &ctx->packet);
+-
+-			if (got_frame && frame_number % 25 == 0)
++			avcodec_send_packet(ctx->codec_ctx, &ctx->packet);
++      if (avcodec_receive_frame(ctx->codec_ctx, ctx->frame) == 0 && frame_number % 25 == 0)
+ 			{
+ 				float diff = (float)convert_pts_to_ms(ctx->packet.pts - prev_packet_pts, ctx->format_ctx->streams[ctx->video_stream_id]->time_base);
+ 				if (fabsf(diff) < 1000 * ctx->min_sub_duration) //If the minimum duration of a subtitle line is exceeded, process packet
+@@ -548,7 +546,6 @@
+ {
+ 	// Do a binary search over the input video for faster processing
+ 	// printf("Duration: %d\n", (int)ctx->format_ctx->duration);
+-	int got_frame;
+ 	int seconds_time = 0;
+ 	for (seconds_time = 0; seconds_time < 20; seconds_time++)
+ 	{
+@@ -568,8 +565,9 @@
+ 			{
+ 				if (ctx->packet.stream_index == ctx->video_stream_id)
+ 				{
+-					avcodec_decode_video2(ctx->codec_ctx, ctx->frame, &got_frame, &ctx->packet);
+-					if (got_frame)
++          avcodec_send_packet(ctx->codec_ctx, &ctx->packet);
++          if (avcodec_receive_frame(ctx->codec_ctx, ctx->frame) == 0)
++
+ 					{
+ 						// printf("%d\n", seek_time);
+ 						if (ctx->packet.pts < seek_time)
diff --git a/srcpkgs/ccextractor/template b/srcpkgs/ccextractor/template
index 84059ffd02398a..a670758bcbe41b 100644
--- a/srcpkgs/ccextractor/template
+++ b/srcpkgs/ccextractor/template
@@ -1,7 +1,7 @@
 # Template file for 'ccextractor'
 pkgname=ccextractor
 version=0.93
-revision=2
+revision=3
 build_wrksrc="linux"
 build_style=gnu-configure
 configure_args="--enable-ocr --enable-hardsubx"

From 6852e97bd9012f24bf6a2c580e2220a97727c6c2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 020/110] chromaprint: revbump for ffmpeg6

---
 srcpkgs/chromaprint/patches/ffmpeg5.patch | 569 ++++++++++++++++++++++
 srcpkgs/chromaprint/template              |   2 +-
 2 files changed, 570 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromaprint/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromaprint/patches/ffmpeg5.patch b/srcpkgs/chromaprint/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..a9fd307a23c8a4
--- /dev/null
+++ b/srcpkgs/chromaprint/patches/ffmpeg5.patch
@@ -0,0 +1,569 @@
+From 8ccad6937177b1b92e40ab8f4447ea27bac009a7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= <lalinsky@gmail.com>
+Date: Fri, 4 Nov 2022 21:47:38 +0100
+Subject: [PATCH] Use FFmpeg 5.x (#120)
+
+* Use FFmpeg 5.1.2 for CI builds
+
+* Build on Ubuntu 20.04
+
+* Upgrade code to FFmpeg 5.x APIs
+
+* Only set FFmpeg include dirs if building tools
+
+* No longer needed
+
+* Use ubuntu 20.04
+---
+ .github/workflows/build.yml                   |   6 +-
+ CMakeLists.txt                                |  16 --
+ package/build.sh                              |   4 +-
+ src/audio/ffmpeg_audio_processor.h            |   2 -
+ src/audio/ffmpeg_audio_processor_avresample.h |  72 -------
+ src/audio/ffmpeg_audio_processor_swresample.h |  18 +-
+ src/audio/ffmpeg_audio_reader.h               | 197 +++++++++---------
+ tests/CMakeLists.txt                          |   6 +
+ 8 files changed, 122 insertions(+), 199 deletions(-)
+ delete mode 100644 src/audio/ffmpeg_audio_processor_avresample.h
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index f8d6a32..4da2405 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -84,9 +84,6 @@ find_package(FFmpeg)
+ if(FFMPEG_LIBRARIES)
+ 	cmake_push_check_state(RESET)
+ 	set(CMAKE_REQUIRED_LIBRARIES ${FFMPEG_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -lm)
+-	check_function_exists(av_packet_unref HAVE_AV_PACKET_UNREF)
+-	check_function_exists(av_frame_alloc HAVE_AV_FRAME_ALLOC)
+-	check_function_exists(av_frame_free HAVE_AV_FRAME_FREE)
+ 	cmake_pop_check_state()
+ endif()
+
+@@ -163,14 +160,11 @@ message(STATUS "Using ${FFT_LIB} for FFT calculations")
+ if(NOT AUDIO_PROCESSOR_LIB)
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+ 		set(AUDIO_PROCESSOR_LIB "swresample")
+-	elseif(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(AUDIO_PROCESSOR_LIB "avresample")
+ 	endif()
+ endif()
+
+ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE OFF)
+ 		set(USE_SWRESAMPLE ON)
+ 		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBSWRESAMPLE_LIBRARIES})
+ 		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBSWRESAMPLE_INCLUDE_DIRS})
+@@ -178,16 +172,6 @@ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+ 	endif()
+ 	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+-elseif(AUDIO_PROCESSOR_LIB STREQUAL "avresample")
+-	if(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE ON)
+-		set(USE_SWRESAMPLE OFF)
+-		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBAVRESAMPLE_LIBRARIES})
+-		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBAVRESAMPLE_INCLUDE_DIRS})
+-	else()
+-		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+-	endif()
+-	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+ else()
+ 	message(STATUS "Building without audio conversion support, please install FFmpeg with libswresample")
+ endif()
+diff --git a/package/build.sh b/package/build.sh
+index da631ae..b41d36e 100755
+--- a/package/build.sh
++++ b/package/build.sh
+@@ -7,8 +7,8 @@ set -eux
+
+ BASE_DIR=$(cd $(dirname $0)/.. && pwd)
+
+-FFMPEG_VERSION=4.4.1
+-FFMPEG_BUILD_TAG=v4.4.1-1
++FFMPEG_VERSION=5.1.2
++FFMPEG_BUILD_TAG=v${FFMPEG_VERSION}-1
+
+ TMP_BUILD_DIR=$BASE_DIR/$(mktemp -d build.XXXXXXXX)
+ trap 'rm -rf $TMP_BUILD_DIR' EXIT
+diff --git a/src/audio/ffmpeg_audio_processor.h b/src/audio/ffmpeg_audio_processor.h
+index 7628fc7..39f4f6d 100644
+--- a/src/audio/ffmpeg_audio_processor.h
++++ b/src/audio/ffmpeg_audio_processor.h
+@@ -10,8 +10,6 @@
+
+ #if defined(USE_SWRESAMPLE)
+ #include "audio/ffmpeg_audio_processor_swresample.h"
+-#elif defined(USE_AVRESAMPLE)
+-#include "audio/ffmpeg_audio_processor_avresample.h"
+ #else
+ #error "no audio processing library"
+ #endif
+diff --git a/src/audio/ffmpeg_audio_processor_avresample.h b/src/audio/ffmpeg_audio_processor_avresample.h
+deleted file mode 100644
+index bd85f92..0000000
+--- a/src/audio/ffmpeg_audio_processor_avresample.h
++++ /dev/null
+@@ -1,72 +0,0 @@
+-// Copyright (C) 2016  Lukas Lalinsky
+-// Distributed under the MIT license, see the LICENSE file for details.
+-
+-#ifndef CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-#define CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-
+-extern "C" {
+-#include <libavresample/avresample.h>
+-}
+-
+-namespace chromaprint {
+-
+-class FFmpegAudioProcessor {
+-public:
+-	FFmpegAudioProcessor() {
+-		m_resample_ctx = avresample_alloc_context();
+-	}
+-
+-	~FFmpegAudioProcessor() {
+-		avresample_free(&m_resample_ctx);
+-	}
+-
+-	void SetCompatibleMode() {
+-		av_opt_set_int(m_resample_ctx, "filter_size", 16, 0);
+-		av_opt_set_int(m_resample_ctx, "phase_shift", 8, 0);
+-		av_opt_set_int(m_resample_ctx, "linear_interp", 1, 0);
+-		av_opt_set_double(m_resample_ctx, "cutoff", 0.8, 0);
+-	}
+-
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "in_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_rate", sample_rate, 0);
+-	}
+-
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "out_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_rate, 0);
+-	}
+-
+-	int Init() {
+-		return avresample_open(m_resample_ctx);
+-	}
+-
+-	int Convert(uint8_t **out, int out_count, const uint8_t **in, int in_count) {
+-		return avresample_convert(m_resample_ctx, out, 0, out_count, (uint8_t **) in, 0, in_count);
+-	}
+-
+-	int Flush(uint8_t **out, int out_count) {
+-		return avresample_read(m_resample_ctx, out, out_count);
+-	}
+-
+-private:
+-	AVAudioResampleContext *m_resample_ctx = nullptr;
+-};
+-
+-}; // namespace chromaprint
+-
+-#endif
+diff --git a/src/audio/ffmpeg_audio_processor_swresample.h b/src/audio/ffmpeg_audio_processor_swresample.h
+index b86266b..b1d4bea 100644
+--- a/src/audio/ffmpeg_audio_processor_swresample.h
++++ b/src/audio/ffmpeg_audio_processor_swresample.h
+@@ -28,30 +28,28 @@ public:
+ 		av_opt_set_double(m_swr_ctx, "cutoff", 0.8, 0);
+ 	}
+
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "icl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "ich", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetInputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "in_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "isf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "in_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "isr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "in_sample_rate", sample_rate, 0);
+ 	}
+
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "ocl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "och", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetOutputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "out_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "osf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "out_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "osr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "out_sample_rate", sample_rate, 0);
+ 	}
+
+ 	int Init() {
+diff --git a/src/audio/ffmpeg_audio_reader.h b/src/audio/ffmpeg_audio_reader.h
+index 5550164..1c6b346 100644
+--- a/src/audio/ffmpeg_audio_reader.h
++++ b/src/audio/ffmpeg_audio_reader.h
+@@ -62,7 +62,7 @@ public:
+ 	bool Read(const int16_t **data, size_t *size);
+
+ 	bool IsOpen() const { return m_opened; }
+-	bool IsFinished() const { return m_finished && !m_got_frame; }
++	bool IsFinished() const { return !m_has_more_packets && !m_has_more_frames; }
+
+ 	std::string GetError() const { return m_error; }
+ 	int GetErrorCode() const { return m_error_code; }
+@@ -74,20 +74,19 @@ private:
+ 	uint8_t *m_convert_buffer[1] = { nullptr };
+ 	int m_convert_buffer_nb_samples = 0;
+
+-	AVInputFormat *m_input_fmt = nullptr;
++	const AVInputFormat *m_input_fmt = nullptr;
+ 	AVDictionary *m_input_opts = nullptr;
+
+ 	AVFormatContext *m_format_ctx = nullptr;
+ 	AVCodecContext *m_codec_ctx = nullptr;
+-	AVFrame *m_frame = nullptr;
+ 	int m_stream_index = -1;
+ 	std::string m_error;
+ 	int m_error_code = 0;
+-	bool m_finished = false;
+ 	bool m_opened = false;
+-	int m_got_frame = 0;
+-	AVPacket m_packet;
+-	AVPacket m_packet0;
++	bool m_has_more_packets = true;
++	bool m_has_more_frames = true;
++	AVPacket *m_packet = nullptr;
++	AVFrame *m_frame = nullptr;
+
+ 	int m_output_sample_rate = 0;
+ 	int m_output_channels = 0;
+@@ -98,19 +97,12 @@ private:
+
+ inline FFmpegAudioReader::FFmpegAudioReader() {
+ 	av_log_set_level(AV_LOG_QUIET);
+-
+-	av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
+ }
+
+ inline FFmpegAudioReader::~FFmpegAudioReader() {
+ 	Close();
+ 	av_dict_free(&m_input_opts);
+ 	av_freep(&m_convert_buffer[0]);
+-	av_packet_unref(&m_packet0);
+ }
+
+ inline bool FFmpegAudioReader::SetInputFormat(const char *name) {
+@@ -135,11 +127,10 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ 	Close();
+
+-    av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
++	m_packet = av_packet_alloc();
++	if (!m_packet) {
++		return false;
++	}
+
+ 	ret = avformat_open_input(&m_format_ctx, file_name.c_str(), m_input_fmt, &m_input_opts);
+ 	if (ret < 0) {
+@@ -153,26 +144,31 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		return false;
+ 	}
+
+-	AVCodec *codec;
++	const AVCodec *codec;
+ 	ret = av_find_best_stream(m_format_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &codec, 0);
+ 	if (ret < 0) {
+ 		SetError("Could not find any audio stream in the file", ret);
+ 		return false;
+ 	}
+ 	m_stream_index = ret;
++	auto stream = m_format_ctx->streams[m_stream_index];
+
+-	m_codec_ctx = m_format_ctx->streams[m_stream_index]->codec;
++	m_codec_ctx = avcodec_alloc_context3(codec);
+ 	m_codec_ctx->request_sample_fmt = AV_SAMPLE_FMT_S16;
+
++	ret = avcodec_parameters_to_context(m_codec_ctx, stream->codecpar);
++	if (ret < 0) {
++		SetError("Could not copy the stream parameters", ret);
++		return false;
++	}
++
+ 	ret = avcodec_open2(m_codec_ctx, codec, nullptr);
+ 	if (ret < 0) {
+ 		SetError("Could not open the codec", ret);
+ 		return false;
+ 	}
+
+-	if (!m_codec_ctx->channel_layout) {
+-		m_codec_ctx->channel_layout = av_get_default_channel_layout(m_codec_ctx->channels);
+-	}
++	av_dump_format(m_format_ctx, 0, "foo", 0);
+
+ 	m_frame = av_frame_alloc();
+ 	if (!m_frame) {
+@@ -183,19 +179,23 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		m_output_sample_rate = m_codec_ctx->sample_rate;
+ 	}
+
+-	if (!m_output_channels) {
+-		m_output_channels = m_codec_ctx->channels;
++	AVChannelLayout output_channel_layout;
++	if (m_output_channels) {
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
++	} else {
++		m_output_channels = m_codec_ctx->ch_layout.nb_channels;
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
+ 	}
+
+-	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
++	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->ch_layout.nb_channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
+ 		m_converter.reset(new FFmpegAudioProcessor());
+ 		m_converter->SetCompatibleMode();
+ 		m_converter->SetInputSampleFormat(m_codec_ctx->sample_fmt);
+ 		m_converter->SetInputSampleRate(m_codec_ctx->sample_rate);
+-		m_converter->SetInputChannelLayout(m_codec_ctx->channel_layout);
++		m_converter->SetInputChannelLayout(&(m_codec_ctx->ch_layout));
+ 		m_converter->SetOutputSampleFormat(AV_SAMPLE_FMT_S16);
+ 		m_converter->SetOutputSampleRate(m_output_sample_rate);
+-		m_converter->SetOutputChannelLayout(av_get_default_channel_layout(m_output_channels));
++		m_converter->SetOutputChannelLayout(&output_channel_layout);
+ 		auto ret = m_converter->Init();
+ 		if (ret != 0) {
+ 			SetError("Could not create an audio converter instance", ret);
+@@ -203,10 +203,11 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		}
+ 	}
+
++	av_channel_layout_uninit(&output_channel_layout);
++
+ 	m_opened = true;
+-	m_finished = false;
+-	m_got_frame = 0;
+-	m_nb_packets = 0;
++	m_has_more_packets = true;
++	m_has_more_frames = true;
+ 	m_decode_error = 0;
+
+ 	return true;
+@@ -214,6 +215,7 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ inline void FFmpegAudioReader::Close() {
+ 	av_frame_free(&m_frame);
++	av_packet_free(&m_packet);
+
+ 	m_stream_index = -1;
+
+@@ -252,91 +254,98 @@ inline bool FFmpegAudioReader::Read(const int16_t **data, size_t *size) {
+ 		return false;
+ 	}
+
++	*data = nullptr;
++	*size = 0;
++
+ 	int ret;
++	bool needs_packet = false;
+ 	while (true) {
+-		while (m_packet.size <= 0) {
+-			av_packet_unref(&m_packet0);
+-			av_init_packet(&m_packet);
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			ret = av_read_frame(m_format_ctx, &m_packet);
++		while (needs_packet && m_packet->size == 0) {
++			ret = av_read_frame(m_format_ctx, m_packet);
+ 			if (ret < 0) {
+ 				if (ret == AVERROR_EOF) {
+-					m_finished = true;
++					needs_packet = false;
++					m_has_more_packets = false;
+ 					break;
+-				} else {
++				}
++				SetError("Error reading from the audio source", ret);
++				return false;
++			}
++			if (m_packet->stream_index == m_stream_index) {
++				needs_packet = false;
++			} else {
++				av_packet_unref(m_packet);
++			}
++		}
++
++		if (m_packet->size != 0) {
++			ret = avcodec_send_packet(m_codec_ctx, m_packet);
++			if (ret < 0) {
++				if (ret != AVERROR(EAGAIN)) {
+ 					SetError("Error reading from the audio source", ret);
+ 					return false;
+ 				}
+-			}
+-			m_packet0 = m_packet;
+-			if (m_packet.stream_index != m_stream_index) {
+-				m_packet.data = nullptr;
+-				m_packet.size = 0;
+ 			} else {
+-				m_nb_packets++;
++				av_packet_unref(m_packet);
+ 			}
+ 		}
+
+-		ret = avcodec_decode_audio4(m_codec_ctx, m_frame, &m_got_frame, &m_packet);
++		ret = avcodec_receive_frame(m_codec_ctx, m_frame);
+ 		if (ret < 0) {
+-			if (m_decode_error) {
+-				SetError("Error decoding audio frame", m_decode_error);
+-				return false;
++			if (ret == AVERROR_EOF) {
++				m_has_more_frames = false;
++			} else if (ret == AVERROR(EAGAIN)) {
++				if (m_has_more_packets) {
++					needs_packet = true;
++					continue;
++				} else {
++					m_has_more_frames = false;
++				}
+ 			}
+-			m_decode_error = ret;
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			continue;
++			SetError("Error decoding the audio source", ret);
++			return false;
+ 		}
+
+-		break;
+-	}
+-
+-	m_decode_error = 0;
+-
+-	const int decoded = std::min(ret, m_packet.size);
+-	m_packet.data += decoded;
+-	m_packet.size -= decoded;
+-
+-	if (m_got_frame) {
+-		if (m_converter) {
+-			if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
+-				int linsize;
+-				av_freep(&m_convert_buffer[0]);
+-				m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
+-				ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
+-				if (ret < 0) {
+-					SetError("Couldn't allocate audio converter buffer", ret);
++		if (m_frame->nb_samples > 0) {
++			if (m_converter) {
++				if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
++					int linsize;
++					av_freep(&m_convert_buffer[0]);
++					m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
++					ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->ch_layout.nb_channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
++					if (ret < 0) {
++						SetError("Couldn't allocate audio converter buffer", ret);
++						return false;
++					}
++				}
++				auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
++				if (nb_samples < 0) {
++					SetError("Couldn't convert audio", ret);
+ 					return false;
+ 				}
+-			}
+-			auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			}
+-			*data = (const int16_t *) m_convert_buffer[0];
+-			*size = nb_samples;
+-		} else {
+-			*data = (const int16_t *) m_frame->data[0];
+-			*size = m_frame->nb_samples;
+-		}
+-	} else {
+-		if (m_finished && m_converter) {
+-			auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			} else if (nb_samples > 0) {
+-				m_got_frame = 1;
+ 				*data = (const int16_t *) m_convert_buffer[0];
+ 				*size = nb_samples;
++			} else {
++				*data = (const int16_t *) m_frame->data[0];
++				*size = m_frame->nb_samples;
++			}
++		} else {
++			if (m_converter) {
++				if (IsFinished()) {
++					auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
++					if (nb_samples < 0) {
++						SetError("Couldn't convert audio", ret);
++						return false;
++					} else if (nb_samples > 0) {
++						*data = (const int16_t *) m_convert_buffer[0];
++						*size = nb_samples;
++					}
++				}
+ 			}
+ 		}
+-	}
+
+-	return true;
++		return true;
++	}
+ }
+
+ inline void FFmpegAudioReader::SetError(const char *message, int errnum) {
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index a2b517b..123e643 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -38,6 +38,12 @@ set(SRCS
+
+ if(BUILD_TOOLS)
+ 	set(SRCS ${SRCS} ../src/audio/ffmpeg_audio_reader_test.cpp)
++    include_directories(
++        ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}
++        ${AUDIO_PROCESSOR_INCLUDE_DIRS}
++    )
+ 	link_libraries(fpcalc_libs)
+ endif()
+
+-- 
+2.38.1
+
+
diff --git a/srcpkgs/chromaprint/template b/srcpkgs/chromaprint/template
index 7ef7838949f3a3..1f7bbc70a22c80 100644
--- a/srcpkgs/chromaprint/template
+++ b/srcpkgs/chromaprint/template
@@ -1,7 +1,7 @@
 # Template file for 'chromaprint'
 pkgname=chromaprint
 version=1.5.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DBUILD_TOOLS=ON"
 make_check_target="check"

From a69b865de1ae80370666b3b36a1d7144af9e36b8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 021/110] chromium: revbump for ffmpeg6

---
 srcpkgs/chromium/patches/ffmpeg5.patch | 47 ++++++++++++++++++++++++++
 srcpkgs/chromium/template              |  2 +-
 2 files changed, 48 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..24e2da38e34ca2
--- /dev/null
+++ b/srcpkgs/chromium/patches/ffmpeg5.patch
@@ -0,0 +1,47 @@
+--- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
++++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
+@@ -92,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+-  if (stream->start_time != kNoFFmpegTimestamp)
++  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -1597,7 +1585,7 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+@@ -1618,7 +1606,7 @@
+     if (stream->type() != DemuxerStream::VIDEO)
+       continue;
+ 
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+ 
+     if (!stream->IsEnabled())
diff --git a/srcpkgs/chromium/template b/srcpkgs/chromium/template
index 53981f7cd367f8..b462de56fe3bf5 100644
--- a/srcpkgs/chromium/template
+++ b/srcpkgs/chromium/template
@@ -2,7 +2,7 @@
 pkgname=chromium
 # See https://chromiumdash.appspot.com/releases?platform=Linux for the latest version
 version=122.0.6261.94
-revision=1
+revision=2
 archs="i686* x86_64* aarch64* armv7l*"
 hostmakedepends="
  $(vopt_if clang "clang17 lld17 llvm17 compiler-rt")

From 4c3bd0fce19659864c7b933fd15360db729f1d0d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 022/110] cmus: revbump for ffmpeg6

---
 srcpkgs/chromium/patches/ffmpeg5.patch | 47 --------------------------
 srcpkgs/cmus/patches/ffmpeg6.patch     | 12 +++++++
 srcpkgs/cmus/template                  |  2 +-
 3 files changed, 13 insertions(+), 48 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch
 create mode 100644 srcpkgs/cmus/patches/ffmpeg6.patch

diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
deleted file mode 100644
index 24e2da38e34ca2..00000000000000
--- a/srcpkgs/chromium/patches/ffmpeg5.patch
+++ /dev/null
@@ -1,47 +0,0 @@
---- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
-+++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
-@@ -92,24 +92,12 @@
- 
- static base::TimeDelta ExtractStartTime(AVStream* stream) {
-   // The default start time is zero.
--  base::TimeDelta start_time;
-+  base::TimeDelta start_time = kNoTimestamp;
- 
-   // First try to use  the |start_time| value as is.
--  if (stream->start_time != kNoFFmpegTimestamp)
-+  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
-     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
- 
--  // Next try to use the first DTS value, for codecs where we know PTS == DTS
--  // (excludes all H26x codecs). The start time must be returned in PTS.
--  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
--      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
--      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
--      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
--    const base::TimeDelta first_pts =
--        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
--    if (first_pts < start_time)
--      start_time = first_pts;
--  }
--
-   return start_time;
- }
- 
-@@ -1597,7 +1585,7 @@
-   for (const auto& stream : streams_) {
-     if (!stream || stream->IsEnabled() != enabled)
-       continue;
--    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
-+    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
-       continue;
-     if (!lowest_start_time_stream ||
-         stream->start_time() < lowest_start_time_stream->start_time()) {
-@@ -1618,7 +1606,7 @@
-     if (stream->type() != DemuxerStream::VIDEO)
-       continue;
- 
--    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
-+    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
-       continue;
- 
-     if (!stream->IsEnabled())
diff --git a/srcpkgs/cmus/patches/ffmpeg6.patch b/srcpkgs/cmus/patches/ffmpeg6.patch
new file mode 100644
index 00000000000000..ffa95ab811101b
--- /dev/null
+++ b/srcpkgs/cmus/patches/ffmpeg6.patch
@@ -0,0 +1,12 @@
+--- a/ip/ffmpeg.c
++++ b/ip/ffmpeg.c
+@@ -202,9 +202,6 @@ static int ffmpeg_open(struct input_plugin_data *ip_data)
+ 			break;
+ 		}
+ 
+-		if (codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+-			cc->flags |= AV_CODEC_FLAG_TRUNCATED;
+-
+ 		if (avcodec_open2(cc, codec, NULL) < 0) {
+ 			d_print("could not open codec: %d, %s\n", cc->codec_id, avcodec_get_name(cc->codec_id));
+ 			err = -IP_ERROR_UNSUPPORTED_FILE_TYPE;
diff --git a/srcpkgs/cmus/template b/srcpkgs/cmus/template
index 0d1436744f1b2c..a6e4b4fa86cb83 100644
--- a/srcpkgs/cmus/template
+++ b/srcpkgs/cmus/template
@@ -1,7 +1,7 @@
 # Template file for 'cmus'
 pkgname=cmus
 version=2.10.0
-revision=3
+revision=4
 build_style=configure
 configure_args="prefix=/usr LD=$CC"
 hostmakedepends="pkg-config"

From a31117d48c9acb69969b61fa737beb50b0dfaafc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 023/110] cyanrip: revbump for ffmpeg6

---
 srcpkgs/cyanrip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cyanrip/template b/srcpkgs/cyanrip/template
index 9796e3461601a7..5db30e020d17ee 100644
--- a/srcpkgs/cyanrip/template
+++ b/srcpkgs/cyanrip/template
@@ -1,7 +1,7 @@
 # Template file for 'cyanrip'
 pkgname=cyanrip
 version=0.9.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config"
 makedepends="ffmpeg-devel libcdio-devel libcdio-paranoia-devel libcurl-devel libmusicbrainz5-devel"

From 516c32a6ed6793266fedb95c7176256e52c21ddb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 024/110] deadbeef: revbump for ffmpeg4

---
 srcpkgs/deadbeef/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/deadbeef/template b/srcpkgs/deadbeef/template
index f5f4bf24b8cb6d..7b47e615cd48ef 100644
--- a/srcpkgs/deadbeef/template
+++ b/srcpkgs/deadbeef/template
@@ -1,14 +1,14 @@
 # Template file for 'deadbeef'
 pkgname=deadbeef
 version=1.8.8
-revision=3
+revision=4
 create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-oss --disable-lfm --disable-notify --disable-gtk2"
 hostmakedepends="automake libtool gettext gettext-devel intltool pkg-config
  yasm clang glib-devel"
 makedepends="
- alsa-lib-devel dbus-devel faad2-devel ffmpeg-devel gtk+3-devel imlib2-devel
+ alsa-lib-devel dbus-devel faad2-devel ffmpeg4-devel gtk+3-devel imlib2-devel
  jansson-devel libcddb-devel libcdio-devel libcurl-devel libflac-devel
  libmad-devel libpng-devel libsamplerate-devel libsndfile-devel libvorbis-devel
  libzip-devel mpg123-devel opusfile-devel pulseaudio-devel wavpack-devel"

From 07e8ac43ccb99b1215da42606c66b872e5fb7a2c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 025/110] droidcam-obs-plugin: revbump for ffmpeg6

---
 srcpkgs/droidcam-obs-plugin/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam-obs-plugin/template b/srcpkgs/droidcam-obs-plugin/template
index fc9c9bf6b9d54c..fb0480754df4de 100644
--- a/srcpkgs/droidcam-obs-plugin/template
+++ b/srcpkgs/droidcam-obs-plugin/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam-obs-plugin'
 pkgname=droidcam-obs-plugin
 version=2.0.1
-revision=1
+revision=2
 build_style=gnu-makefile
 make_use_env=yes
 make_build_args="ALLOW_STATIC=no"

From 78f58d626c684b9b0fa1c7907505133a5cc2754a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 026/110] droidcam: revbump for ffmpeg6

---
 srcpkgs/droidcam/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam/template b/srcpkgs/droidcam/template
index 1c3f1b8b1fc676..32a9220b79a4d1 100644
--- a/srcpkgs/droidcam/template
+++ b/srcpkgs/droidcam/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam'
 pkgname=droidcam
 version=1.8.2
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="USBMUXD=-lusbmuxd-2.0 JPEG=-lturbojpeg"
 hostmakedepends="pkg-config"

From 73f835c849fa9b966c15a14e7d801cfe3312d049 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 027/110] ffmpegthumbnailer: revbump for ffmpeg6

---
 .../ffmpegthumbnailer/patches/ffmpeg6.patch   | 202 ++++++++++++++++++
 srcpkgs/ffmpegthumbnailer/template            |   6 +-
 2 files changed, 205 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch

diff --git a/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
new file mode 100644
index 00000000000000..363ff35a28419d
--- /dev/null
+++ b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
@@ -0,0 +1,202 @@
+--- a/libffmpegthumbnailer/moviedecoder.cpp	2017-11-21 14:06:57.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.cpp	2023-05-05 13:14:47.946560668 -0400
+@@ -41,11 +41,6 @@
+ namespace ffmpegthumbnailer
+ {
+ 
+-struct SilenceLogLevel
+-{
+-    SilenceLogLevel() { av_log_set_level(AV_LOG_QUIET); }
+-};
+-
+ MovieDecoder::MovieDecoder(AVFormatContext* pavContext)
+ : m_VideoStream(-1)
+ , m_pFormatContext(pavContext)
+@@ -70,8 +65,6 @@
+ 
+ void MovieDecoder::initialize(const string& filename, bool preferEmbeddedMetadata)
+ {
+-    av_register_all();
+-    avcodec_register_all();
+     avformat_network_init();
+ 
+     string inputFile = filename == "-" ? "pipe:" : filename;
+@@ -97,8 +90,7 @@
+ {
+     if (m_pVideoCodecContext)
+     {
+-        avcodec_close(m_pVideoCodecContext);
+-        m_pVideoCodecContext = nullptr;
++        avcodec_free_context(&m_pVideoCodecContext);
+     }
+ 
+     if ((!m_FormatContextWasGiven) && m_pFormatContext)
+@@ -152,10 +144,10 @@
+     for (unsigned int i = 0; i < m_pFormatContext->nb_streams; ++i)
+     {
+         AVStream *stream = m_pFormatContext->streams[i];
+-        auto ctx = m_pFormatContext->streams[i]->codec;
+-        if (ctx->codec_type == AVMEDIA_TYPE_VIDEO)
++        auto par = m_pFormatContext->streams[i]->codecpar;
++        if (par->codec_type == AVMEDIA_TYPE_VIDEO)
+         {
+-            if (!preferEmbeddedMetadata || !isStillImageCodec(ctx->codec_id))
++            if (!preferEmbeddedMetadata || !isStillImageCodec(par->codec_id))
+             {
+                 videoStreams.push_back(i);
+                 continue;
+@@ -203,8 +195,7 @@
+     }
+ 
+     m_pVideoStream = m_pFormatContext->streams[m_VideoStream];
+-    m_pVideoCodecContext = m_pVideoStream->codec;
+-    m_pVideoCodec = avcodec_find_decoder(m_pVideoCodecContext->codec_id);
++    m_pVideoCodec = avcodec_find_decoder(m_pVideoStream->codecpar->codec_id);
+ 
+     if (m_pVideoCodec == nullptr)
+     {
+@@ -214,6 +205,20 @@
+         throw logic_error("Video Codec not found");
+     }
+ 
++    m_pVideoCodecContext = avcodec_alloc_context3(m_pVideoCodec);
++
++    if (m_pVideoCodecContext == nullptr)
++    {
++        destroy();
++        throw logic_error("Could not allocate video codec context");
++    }
++
++    if (avcodec_parameters_to_context(m_pVideoCodecContext, m_pVideoStream->codecpar) < 0)
++    {
++        destroy();
++        throw logic_error("Could not configure video codec context");
++    }
++
+     m_pVideoCodecContext->workaround_bugs = 1;
+ 
+     if (avcodec_open2(m_pVideoCodecContext, m_pVideoCodec, nullptr) < 0)
+@@ -386,13 +391,6 @@
+ 
+ void MovieDecoder::initializeFilterGraph(const AVRational& timeBase, const std::string& size, bool maintainAspectRatio)
+ {
+-    static const AVPixelFormat pixelFormats[] = { AV_PIX_FMT_RGB24, AV_PIX_FMT_NONE };
+-
+-    auto del = [] (AVBufferSinkParams* p) { av_freep(p); };
+-    std::unique_ptr<AVBufferSinkParams, decltype(del)> buffersinkParams(av_buffersink_params_alloc(), del);
+-
+-    avfilter_register_all();
+-
+     m_pFilterGraph = avfilter_graph_alloc();
+     assert(m_pFilterGraph);
+ 
+@@ -404,10 +402,8 @@
+ 
+     checkRc(avfilter_graph_create_filter(&m_pFilterSource, avfilter_get_by_name("buffer"), "thumb_buffer", ss.str().c_str(), nullptr, m_pFilterGraph),
+             "Failed to create filter source");
+-    buffersinkParams->pixel_fmts = pixelFormats;
+-    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, buffersinkParams.get(), m_pFilterGraph),
++    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, nullptr, m_pFilterGraph),
+             "Failed to create filter sink");
+-    buffersinkParams.release();
+ 
+     AVFilterContext* yadifFilter = nullptr;
+     if (m_pFrame->interlaced_frame != 0)
+@@ -500,15 +496,15 @@
+     }
+ 
+     checkRc(av_seek_frame(m_pFormatContext, -1, timestamp, 0), "Seeking in video failed");
+-    avcodec_flush_buffers(m_pFormatContext->streams[m_VideoStream]->codec);
++    avcodec_flush_buffers(m_pVideoCodecContext);
+ 
+     int keyFrameAttempts = 0;
+-    bool gotFrame = 0;
++    bool gotFrame;
+ 
+     do
+     {
+         int count = 0;
+-        gotFrame = 0;
++        gotFrame = false;
+ 
+         while (!gotFrame && count < 20)
+         {
+@@ -552,17 +548,33 @@
+         return false;
+     }
+ 
+-    av_frame_unref(m_pFrame);
+-
+-    int frameFinished;
++    int rc = avcodec_send_packet(m_pVideoCodecContext, m_pPacket);
++    if(rc == AVERROR(EAGAIN))
++    {
++        rc = 0;
++    }
+ 
+-    int bytesDecoded = avcodec_decode_video2(m_pVideoCodecContext, m_pFrame, &frameFinished, m_pPacket);
+-    if (bytesDecoded < 0)
++    if(rc == AVERROR_EOF)
++    {
++        return false;
++    }
++    else if(rc < 0)
+     {
+-        throw logic_error("Failed to decode video frame: bytesDecoded < 0");
++        throw logic_error("Failed to decode video frame: avcodec_send_packet() < 0");
+     }
+ 
+-    return frameFinished > 0;
++    rc = avcodec_receive_frame(m_pVideoCodecContext, m_pFrame);
++    switch(rc)
++    {
++        case 0:
++            return true;
++
++        case AVERROR(EAGAIN):
++            return false;
++
++        default:
++            throw logic_error("Failed to decode video frame: avcodec_receive_frame() < 0");
++    }
+ }
+ 
+ bool MovieDecoder::getVideoPacket()
+@@ -570,8 +582,6 @@
+     bool framesAvailable = true;
+     bool frameDecoded = false;
+ 
+-    int attempts = 0;
+-
+     if (m_pPacket)
+     {
+         av_packet_unref(m_pPacket);
+@@ -580,6 +590,7 @@
+ 
+     m_pPacket = new AVPacket();
+ 
++
+     while (framesAvailable && !frameDecoded)
+     {
+         framesAvailable = av_read_frame(m_pFormatContext, m_pPacket) >= 0;
+@@ -644,7 +655,7 @@
+ 
+ int32_t MovieDecoder::getStreamRotation()
+ {
+-    int32_t* matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
++    auto matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
+     if (matrix)
+     {
+         auto angle = lround(av_display_rotation_get(matrix));
+
+--- a/libffmpegthumbnailer/moviedecoder.h	2017-11-12 04:23:38.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.h	2023-05-05 13:26:07.095529911 -0400
+@@ -78,7 +78,7 @@
+     int                     m_VideoStream;
+     AVFormatContext*        m_pFormatContext;
+     AVCodecContext*         m_pVideoCodecContext;
+-    AVCodec*                m_pVideoCodec;
++    const AVCodec*          m_pVideoCodec;
+     AVFilterGraph*          m_pFilterGraph;
+     AVFilterContext*        m_pFilterSource;
+     AVFilterContext*        m_pFilterSink;
diff --git a/srcpkgs/ffmpegthumbnailer/template b/srcpkgs/ffmpegthumbnailer/template
index 039eea7622b391..35d546018d12af 100644
--- a/srcpkgs/ffmpegthumbnailer/template
+++ b/srcpkgs/ffmpegthumbnailer/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbnailer'
 pkgname=ffmpegthumbnailer
 version=2.2.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libpng-devel libjpeg-turbo-devel ffmpeg-devel"
@@ -9,8 +9,8 @@ depends="ffmpeg"
 short_desc="Lightweight video thumbnailer"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
-homepage="https://github.com/dirkvdb/${pkgname}"
-distfiles="${homepage}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
+homepage="https://github.com/dirkvdb"
+distfiles="${homepage}/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
 checksum=1cb24059c38223f657b300c84dd80491b7040d4b69471c4fea69be862bc99b5b
 
 post_install() {

From 73befbfff9c7fa1c013ec6d5783c89185e24611b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 028/110] ffmpegthumbs: revbump for ffmpeg6

---
 srcpkgs/ffmpegthumbs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ffmpegthumbs/template b/srcpkgs/ffmpegthumbs/template
index 2e2a96de83ce8a..dfd7e9dede36d3 100644
--- a/srcpkgs/ffmpegthumbs/template
+++ b/srcpkgs/ffmpegthumbs/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbs'
 pkgname=ffmpegthumbs
 version=23.08.5
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules kcoreaddons kconfig-devel
  pkg-config qt5-host-tools qt5-qmake gettext"

From 361cd4d5267bae9b1345833743e387ef40a1bcba Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 029/110] ffms2: revbump for ffmpeg6

---
 srcpkgs/ffms2/patches/ffmpeg5.patch | 424 ++++++++++++++++++++++++++++
 srcpkgs/ffms2/template              |   2 +-
 2 files changed, 425 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ffms2/patches/ffmpeg5.patch

diff --git a/srcpkgs/ffms2/patches/ffmpeg5.patch b/srcpkgs/ffms2/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..1479fabcafcb4e
--- /dev/null
+++ b/srcpkgs/ffms2/patches/ffmpeg5.patch
@@ -0,0 +1,424 @@
+From 45673149e9a2f5586855ad472e3059084eaa36b1 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:41:21 +0100
+Subject: [PATCH] Use auto for AVCodec
+
+The geniuses over at FFmpeg decided to constify this API, so old
+versions of the library will return AVCodec *, while new versions
+of the libary will return const AVCodec *, which, in C++, are not
+OK to convert between.
+
+Rather than use some macro hell in ffmscompat.h, we can work around
+this by using auto.
+
+Gross.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 2 +-
+ src/core/indexing.cpp    | 6 +++---
+ src/core/videosource.cpp | 2 +-
+ 3 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index e4ce97c..ac09666 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -469,7 +469,7 @@ void FFMS_AudioSource::OpenFile() {
+ 
+     LAVFOpenFile(SourceFile.c_str(), FormatContext, TrackNumber);
+ 
+-    AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
++    auto *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
+     if (Codec == nullptr)
+         throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+             "Audio codec not found");
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index e547c5a..59fb4e8 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -384,7 +384,7 @@ FFMS_TrackType FFMS_Indexer::GetTrackType(int Track) {
+ }
+ 
+ const char *FFMS_Indexer::GetTrackCodec(int Track) {
+-    AVCodec *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
++    auto *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
+     return codec ? codec->name : nullptr;
+ }
+ 
+@@ -402,7 +402,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             UseDTS);
+ 
+         if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            AVCodec *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (!VideoCodec) {
+                 FormatContext->streams[i]->discard = AVDISCARD_ALL;
+                 IndexMask.erase(i);
+@@ -433,7 +433,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 IndexMask.insert(i);
+             }
+         } else if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+-            AVCodec *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (AudioCodec == nullptr)
+                 throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_UNSUPPORTED,
+                     "Audio codec not found");
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index b889970..8956c22 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -171,7 +171,7 @@ FFMS_VideoSource::FFMS_VideoSource(const char *SourceFile, FFMS_Index &Index, in
+ 
+         LAVFOpenFile(SourceFile, FormatContext, VideoTrack);
+ 
+-        AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
++        auto *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
+         if (Codec == nullptr)
+             throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+                 "Video codec not found");
+-- 
+2.40.0
+
+From 96cbf38ea9381829a1314f432a2c60495dcefaad Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:12:41 +0100
+Subject: [PATCH] all: Update AVPacket API usage
+
+AVPackets must all be on the heap now, since it is no longer
+part of the libav* ABI.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 16 ++++++----
+ src/core/indexing.cpp    | 63 ++++++++++++++++++++++------------------
+ src/core/indexing.h      |  4 +--
+ src/core/utils.cpp       |  6 ----
+ src/core/utils.h         |  1 -
+ src/core/videosource.cpp | 30 ++++++++++---------
+ 6 files changed, 64 insertions(+), 56 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index 37cf9ae..e4ce97c 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -285,10 +285,15 @@ FFMS_AudioSource::AudioBlock *FFMS_AudioSource::CacheBlock(CacheIterator &pos) {
+ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     CurrentFrame = &Frames[PacketNumber];
+ 
+-    AVPacket Packet;
+-    if (!ReadPacket(&Packet))
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++    if (!ReadPacket(Packet)) {
++        av_packet_free(&Packet);
+         throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_UNKNOWN,
+             "ReadPacket unexpectedly failed to read a packet");
++    }
+ 
+     // ReadPacket may have changed the packet number
+     CurrentFrame = &Frames[PacketNumber];
+@@ -297,8 +302,9 @@ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     int NumberOfSamples = 0;
+     AudioBlock *CachedBlock = nullptr;
+     
+-    int Ret = avcodec_send_packet(CodecContext, &Packet);
+-    av_packet_unref(&Packet);
++    int Ret = avcodec_send_packet(CodecContext, Packet);
++    av_packet_unref(Packet);
++    av_packet_free(&Packet);
+ 
+     av_frame_unref(DecodeFrame);
+     Ret = avcodec_receive_frame(CodecContext, DecodeFrame);
+@@ -513,8 +519,6 @@ void FFMS_AudioSource::Seek() {
+ }
+ 
+ bool FFMS_AudioSource::ReadPacket(AVPacket *Packet) {
+-    InitNullPacket(*Packet);
+-
+     while (av_read_frame(FormatContext, Packet) >= 0) {
+         if (Packet->stream_index == TrackNumber) {
+             // Required because not all audio packets, especially in ogg, have a pts. Use the previous valid packet's pts instead.
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index 23fb95b..e547c5a 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -320,7 +320,7 @@ void FFMS_Indexer::CheckAudioProperties(int Track, AVCodecContext *Context) {
+     }
+ }
+ 
+-void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict,
++void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict,
+                                     int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct) {
+     if (VideoContext.Parser) {
+         uint8_t *OB;
+@@ -330,8 +330,8 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+         av_parser_parse2(VideoContext.Parser,
+             VideoContext.CodecContext,
+             &OB, &OBSize,
+-            pkt.data, pkt.size,
+-            pkt.pts, pkt.dts, pkt.pos);
++            pkt->data, pkt->size,
++            pkt->pts, pkt->dts, pkt->pos);
+ 
+         // H.264 (PAFF) and HEVC may have one field per packet, so we need to track
+         // when we have a full or half frame available, and mark one of them as
+@@ -351,15 +351,15 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+ 
+         *RepeatPict = VideoContext.Parser->repeat_pict;
+         *FrameType = VideoContext.Parser->pict_type;
+-        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt.flags & AV_PKT_FLAG_DISCARD));
++        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt->flags & AV_PKT_FLAG_DISCARD));
+     } else {
+-        *Invisible = !!(pkt.flags & AV_PKT_FLAG_DISCARD);
++        *Invisible = !!(pkt->flags & AV_PKT_FLAG_DISCARD);
+     }
+ 
+     if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP8)
+-        ParseVP8(pkt.data[0], Invisible, FrameType);
++        ParseVP8(pkt->data[0], Invisible, FrameType);
+     else if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP9)
+-        ParseVP9(pkt.data[0], Invisible, FrameType);
++        ParseVP9(pkt->data[0], Invisible, FrameType);
+ }
+ 
+ void FFMS_Indexer::Free() {
+@@ -458,32 +458,36 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+         }
+     }
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
+     std::vector<int64_t> LastValidTS(FormatContext->nb_streams, AV_NOPTS_VALUE);
+ 
+     int64_t filesize = avio_size(FormatContext->pb);
+     enum AVPictureStructure LastPicStruct = AV_PICTURE_STRUCTURE_UNKNOWN;
+-    while (av_read_frame(FormatContext, &Packet) >= 0) {
++    while (av_read_frame(FormatContext, Packet) >= 0) {
+         // Update progress
+         // FormatContext->pb can apparently be NULL when opening images.
+         if (IC && FormatContext->pb) {
+-            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate))
++            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate)) {
++                av_packet_free(&Packet);
+                 throw FFMS_Exception(FFMS_ERROR_CANCELLED, FFMS_ERROR_USER,
+                     "Cancelled by user");
++            }
+         }
+-        if (!IndexMask.count(Packet.stream_index)) {
+-            av_packet_unref(&Packet);
++        if (!IndexMask.count(Packet->stream_index)) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+-        int Track = Packet.stream_index;
++        int Track = Packet->stream_index;
+         FFMS_Track &TrackInfo = (*TrackIndices)[Track];
+-        bool KeyFrame = !!(Packet.flags & AV_PKT_FLAG_KEY);
++        bool KeyFrame = !!(Packet->flags & AV_PKT_FLAG_KEY);
+         ReadTS(Packet, LastValidTS[Track], (*TrackIndices)[Track].UseDTS);
+ 
+         if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            int64_t PTS = TrackInfo.UseDTS ? Packet.dts : Packet.pts;
++            int64_t PTS = TrackInfo.UseDTS ? Packet->dts : Packet->pts;
+             if (PTS == AV_NOPTS_VALUE) {
+                 // VPx alt-refs are output as packets which lack timestmps or durations, since
+                 // they are invisible. Currently, the timestamp mangling code in libavformat
+@@ -495,9 +499,11 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 // FFMS2 currently sorts packets by PTS, which will break decoding, otherwise.
+                 bool HasAltRefs = (FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP8 ||
+                                    FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP9);
+-                if (Packet.duration == 0 && !HasAltRefs)
++                if (Packet->duration == 0 && !HasAltRefs) {
++                    av_packet_free(&Packet);
+                     throw FFMS_Exception(FFMS_ERROR_INDEXING, FFMS_ERROR_PARSER,
+                         "Invalid packet pts, dts, and duration");
++                }
+ 
+                 if (TrackInfo.empty())
+                     PTS = 0;
+@@ -513,7 +519,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             ParseVideoPacket(AVContexts[Track], Packet, &RepeatPict, &FrameType, &Invisible, &LastPicStruct);
+ 
+             TrackInfo.AddVideoFrame(PTS, RepeatPict, KeyFrame,
+-                FrameType, Packet.pos, Invisible);
++                FrameType, Packet->pos, Invisible);
+         } else if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+             // For video seeking timestamps are used only if all packets have
+             // timestamps, while for audio they're used if any have timestamps,
+@@ -522,28 +528,29 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 TrackInfo.HasTS = true;
+ 
+             int64_t StartSample = AVContexts[Track].CurrentSample;
+-            uint32_t SampleCount = IndexAudioPacket(Track, &Packet, AVContexts[Track], *TrackIndices);
++            uint32_t SampleCount = IndexAudioPacket(Track, Packet, AVContexts[Track], *TrackIndices);
+             TrackInfo.SampleRate = AVContexts[Track].CodecContext->sample_rate;
+ 
+             TrackInfo.AddAudioFrame(LastValidTS[Track],
+-                StartSample, SampleCount, KeyFrame, Packet.pos, Packet.flags & AV_PKT_FLAG_DISCARD);
++                StartSample, SampleCount, KeyFrame, Packet->pos, Packet->flags & AV_PKT_FLAG_DISCARD);
+         }
+ 
+-        if (!(Packet.flags & AV_PKT_FLAG_DISCARD))
+-            TrackInfo.LastDuration = Packet.duration;
++        if (!(Packet->flags & AV_PKT_FLAG_DISCARD))
++            TrackInfo.LastDuration = Packet->duration;
+ 
+-        av_packet_unref(&Packet);
++        av_packet_unref(Packet);
+     }
++    av_packet_free(&Packet);
+ 
+     TrackIndices->Finalize(AVContexts, FormatContext->iformat->name);
+     return TrackIndices.release();
+ }
+ 
+-void FFMS_Indexer::ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS) {
+-    if (!UseDTS && Packet.pts != AV_NOPTS_VALUE)
+-        TS = Packet.pts;
++void FFMS_Indexer::ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS) {
++    if (!UseDTS && Packet->pts != AV_NOPTS_VALUE)
++        TS = Packet->pts;
+     if (TS == AV_NOPTS_VALUE)
+         UseDTS = true;
+-    if (UseDTS && Packet.dts != AV_NOPTS_VALUE)
+-        TS = Packet.dts;
++    if (UseDTS && Packet->dts != AV_NOPTS_VALUE)
++        TS = Packet->dts;
+ }
+diff --git a/src/core/indexing.h b/src/core/indexing.h
+index 3cfc3c3..5c06868 100644
+--- a/src/core/indexing.h
++++ b/src/core/indexing.h
+@@ -80,10 +80,10 @@ private:
+     int64_t Filesize;
+     uint8_t Digest[20];
+ 
+-    void ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS);
++    void ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS);
+     void CheckAudioProperties(int Track, AVCodecContext *Context);
+     uint32_t IndexAudioPacket(int Track, AVPacket *Packet, SharedAVContext &Context, FFMS_Index &TrackIndices);
+-    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
++    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
+     void Free();
+ public:
+     FFMS_Indexer(const char *Filename);
+diff --git a/src/core/utils.cpp b/src/core/utils.cpp
+index ce67533..8a2e997 100644
+--- a/src/core/utils.cpp
++++ b/src/core/utils.cpp
+@@ -62,12 +62,6 @@ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo) {
+     }
+ }
+ 
+-void InitNullPacket(AVPacket &pkt) {
+-    av_init_packet(&pkt);
+-    pkt.data = nullptr;
+-    pkt.size = 0;
+-}
+-
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames) {
+     AP.SampleFormat = static_cast<FFMS_SampleFormat>(av_get_packed_sample_fmt(CTX->sample_fmt));
+     AP.BitsPerSample = av_get_bytes_per_sample(CTX->sample_fmt) * 8;
+diff --git a/src/core/utils.h b/src/core/utils.h
+index 9819dc7..003ab79 100644
+--- a/src/core/utils.h
++++ b/src/core/utils.h
+@@ -58,7 +58,6 @@ std::unique_ptr<T> make_unique(Args&&... args) {
+ }
+ 
+ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo);
+-void InitNullPacket(AVPacket &pkt);
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames);
+ 
+ void LAVFOpenFile(const char *SourceFile, AVFormatContext *&FormatContext, int Track);
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index 06bd161..b889970 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -673,30 +673,34 @@ void FFMS_VideoSource::DecodeNextFrame(int64_t &AStartTime, int64_t &Pos) {
+     if (HasPendingDelayedFrames())
+         return;
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
+-
+-    while (ReadFrame(&Packet) >= 0) {
+-        if (Packet.stream_index != VideoTrack) {
+-            av_packet_unref(&Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++
++    while (ReadFrame(Packet) >= 0) {
++        if (Packet->stream_index != VideoTrack) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+         if (AStartTime < 0)
+-            AStartTime = Frames.UseDTS ? Packet.dts : Packet.pts;
++            AStartTime = Frames.UseDTS ? Packet->dts : Packet->pts;
+ 
+         if (Pos < 0)
+-            Pos = Packet.pos;
++            Pos = Packet->pos;
+ 
+-        bool FrameFinished = DecodePacket(&Packet);
+-        av_packet_unref(&Packet);
+-        if (FrameFinished)
++        bool FrameFinished = DecodePacket(Packet);
++        av_packet_unref(Packet);
++        if (FrameFinished) {
++            av_packet_free(&Packet);
+             return;
++        }
+     }
+ 
+     // Flush final frames
+-    InitNullPacket(Packet);
+-    DecodePacket(&Packet);
++    DecodePacket(Packet);
++    av_packet_free(&Packet);
+ }
+ 
+ bool FFMS_VideoSource::SeekTo(int n, int SeekOffset) {
+-- 
+2.40.0
+
+From bf9e03e9e08534c024e5a744a6437c4aac160201 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:20:47 +0100
+Subject: [PATCH 2/3] configure: Remove deprecated API use
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ configure.ac | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index b35ef80bc..d19714d0f 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -102,10 +102,10 @@ CFLAGS="$_CFLAGS $FFMPEG_CFLAGS"
+
+ AC_DEFUN([TEST_FFMPEG],
+          [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+-            #include <libavcodec/avcodec.h>
++            #include <libavformat/avformat.h>
+             #include <libswscale/swscale.h>
+             ]],[[
+-                avcodec_register_all();
++                avformat_network_init();
+                 swscale_version();
+             ]])], [eval $1=yes], [eval $1=no])
+         ])
+
diff --git a/srcpkgs/ffms2/template b/srcpkgs/ffms2/template
index 365f64d10cbabf..1641ecf43be5bb 100644
--- a/srcpkgs/ffms2/template
+++ b/srcpkgs/ffms2/template
@@ -1,7 +1,7 @@
 # Template file for 'ffms2'
 pkgname=ffms2
 version=2.40
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-shared --disable-static"
 hostmakedepends="pkg-config autoconf automake libtool"

From 31eb22c7a5b90134898688a9bc222ebc1d318305 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 030/110] freerdp: revbump for ffmpeg6

---
 .../freerdp/patches/ffmpeg6_aa2cb9aa.patch    | 42 +++++++++++++++++++
 srcpkgs/freerdp/template                      |  2 +-
 2 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch

diff --git a/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
new file mode 100644
index 00000000000000..a4324da3a8822b
--- /dev/null
+++ b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
@@ -0,0 +1,42 @@
+From aa2cb9aa5ff5562433598ba168a466e0752bca0e Mon Sep 17 00:00:00 2001
+From: akallabeth <akallabeth@posteo.net>
+Date: Tue, 14 Feb 2023 07:48:54 +0100
+Subject: [PATCH] Fixed #8686: Update h264 to use new FFMPEG API
+
+---
+ channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c | 2 ++
+ libfreerdp/codec/h264_ffmpeg.c            | 2 ++
+ 2 files changed, 4 insertions(+)
+
+diff --git a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+index 339462d865f..beea80b7a1e 100644
+--- a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
++++ b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+@@ -239,8 +239,10 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYP
+ 		}
+ 	}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 	if (mdecoder->codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		mdecoder->codec_context->flags |= AV_CODEC_FLAG_TRUNCATED;
++#endif
+ 
+ 	return TRUE;
+ }
+diff --git a/libfreerdp/codec/h264_ffmpeg.c b/libfreerdp/codec/h264_ffmpeg.c
+index 8a23db2473c..896a333019b 100644
+--- a/libfreerdp/codec/h264_ffmpeg.c
++++ b/libfreerdp/codec/h264_ffmpeg.c
+@@ -615,10 +615,12 @@ static BOOL libavcodec_init(H264_CONTEXT* h264)
+ 			goto EXCEPTION;
+ 		}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 		if (sys->codecDecoder->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		{
+ 			sys->codecDecoderContext->flags |= AV_CODEC_FLAG_TRUNCATED;
+ 		}
++#endif
+ 
+ #ifdef WITH_VAAPI
+ 
diff --git a/srcpkgs/freerdp/template b/srcpkgs/freerdp/template
index 16fddfbe8f5287..bf3a4d2e2b3ae7 100644
--- a/srcpkgs/freerdp/template
+++ b/srcpkgs/freerdp/template
@@ -1,7 +1,7 @@
 # Template file for 'freerdp'
 pkgname=freerdp
 version=2.11.4
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_ALSA=ON -DWITH_CUPS=OFF -DWITH_FFMPEG=ON
  -DWITH_GSTREAMER_0_10=OFF -DWITH_GSTREAMER_1_0=OFF -DWITH_JPEG=ON

From 14fe88e2e57f5f3cb778af32260e1bb77d9d7946 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 031/110] gerbera: revbump for ffmpeg6

---
 srcpkgs/gerbera/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gerbera/template b/srcpkgs/gerbera/template
index ae14f35c767c03..2dc0ac0ce03b55 100644
--- a/srcpkgs/gerbera/template
+++ b/srcpkgs/gerbera/template
@@ -1,7 +1,7 @@
 # Template file for 'gerbera'
 pkgname=gerbera
 version=1.12.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_SYSTEMD=0 -DWITH_AVCODEC=1"
 hostmakedepends="pkg-config"

From 007e525bbea87d7a2f9e1783ee0947ee28eb6369 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 032/110] goldendict: revbump for ffmpeg6

---
 srcpkgs/goldendict/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/goldendict/template b/srcpkgs/goldendict/template
index f4a05759f693d3..97f44347b03a6a 100644
--- a/srcpkgs/goldendict/template
+++ b/srcpkgs/goldendict/template
@@ -1,7 +1,7 @@
 # Template file for 'goldendict'
 pkgname=goldendict
 version=1.5.0
-revision=1
+revision=2
 build_style=qmake
 configure_args="CONFIG+=zim_support goldendict.pro"
 hostmakedepends="qt5-qmake pkg-config qt5-host-tools"
@@ -10,7 +10,7 @@ makedepends="tiff-devel qt5-devel libvorbis-devel zlib-devel
  qt5-webkit-devel lzo-devel bzip2-devel libao-devel qt5-svg-devel
  libeb-devel qt5-x11extras-devel ffmpeg-devel liblzma-devel
  qt5-multimedia-devel"
-short_desc="A feature-rich dictionary lookup program"
+short_desc="Feature-rich dictionary lookup program"
 maintainer="John <me@johnnynator.dev>"
 license="GPL-3.0-or-later"
 homepage="http://goldendict.org/"

From 0d8404a39a62f83761b3798c5f97b79c9a9033d9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 033/110] gst-libav: revbump for ffmpeg6

---
 srcpkgs/gst-libav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index b24be23fc1a6d2..0f9350a251bf67 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.22.9
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"

From 2f9dcc583f517a8b0c7a6b884b305162ed749724 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Feb 2024 01:52:46 -0500
Subject: [PATCH 034/110] gst-plugins-bad1: revbump for ffmpeg6

---
 srcpkgs/gst-plugins-bad1/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index dc4db910c43e84..b4a7f7367e7dff 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -27,7 +27,7 @@ makedepends="alsa-lib-devel celt-devel openssl-devel exempi-devel
  fdk-aac-devel flite-devel fluidsynth-devel liblrdf-devel ladspa-sdk
  lilv-devel lv2 libopenjpeg2-devel sbc-devel spandsp-devel vulkan-loader
  Vulkan-Headers webrtc-audio-processing-devel libzbar-devel ffmpeg-devel
- srt-devel libva-devel
+ srt-devel libva-devel oneVPL-devel
  $(vopt_if gme libgme-devel)"
 depends="gst-plugins-base1>=${version}"
 short_desc="GStreamer plugins from the bad set (v1.x)"

From 732d7e3ec984dd3316644b47e4d2764f365b0032 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 035/110] gst-rtsp-server: revbump for ffmpeg6

---
 srcpkgs/gst-rtsp-server/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index bc2a0dea6ac152..f77026c618eb69 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
 version=1.22.9
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="glib-devel gst-plugins-bad1-devel gobject-introspection

From 2003b75a3152dce07f2d78f9fea019564bca30ce Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 036/110] guvcview: update to 2.0.8.

---
 srcpkgs/guvcview/patches/fix-include.patch | 10 ++++++++++
 srcpkgs/guvcview/template                  |  7 +++----
 2 files changed, 13 insertions(+), 4 deletions(-)
 create mode 100644 srcpkgs/guvcview/patches/fix-include.patch

diff --git a/srcpkgs/guvcview/patches/fix-include.patch b/srcpkgs/guvcview/patches/fix-include.patch
new file mode 100644
index 00000000000000..503c2af3b78c1a
--- /dev/null
+++ b/srcpkgs/guvcview/patches/fix-include.patch
@@ -0,0 +1,10 @@
+--- a/guvcview/guvcview.c
++++ b/guvcview/guvcview.c
+@@ -28,6 +28,7 @@
+ #include <sys/stat.h>
+ #include <sys/resource.h>
+ #include <errno.h>
++#include <locale.h>
+ 
+ #include "gview.h"
+ #include "gviewv4l2core.h"
diff --git a/srcpkgs/guvcview/template b/srcpkgs/guvcview/template
index d42fd38fa4ad12..86a7fd619612c8 100644
--- a/srcpkgs/guvcview/template
+++ b/srcpkgs/guvcview/template
@@ -1,8 +1,7 @@
 # Template file for 'guvcview'
 pkgname=guvcview
-version=2.0.7
-revision=2
-create_wrksrc=yes
+version=2.0.8
+revision=1
 build_style=gnu-configure
 configure_args="--disable-static --disable-debian-menu"
 hostmakedepends="pkg-config intltool autoconf automake libtool glib-devel"
@@ -14,7 +13,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="http://guvcview.sourceforge.net/"
 distfiles="${SOURCEFORGE_SITE}/${pkgname}/${pkgname}-src-${version}.tar.bz2"
-checksum=f47d51fbd06e44eeaa1a82f4a153c927527c90d94514197a70b2956028cc8ad4
+checksum=a21f4e448286666cf27bafef5290cc953a0a1796b752e5bbe521266dc1230c81
 
 post_patch() {
 	sed '31a#include <locale.h>' -i  guvcview/guvcview.c

From 599936b50b6b9146577b30c1ac191ad2f14a7552 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 037/110] handbrake: update to 1.6.1

---
 .../patches/fix-missing-x265-link-flag.patch    | 11 ++++++-----
 .../handbrake/patches/libhb-vpl-include.patch   | 15 +++++++++++++++
 srcpkgs/handbrake/template                      | 17 ++++++++++-------
 3 files changed, 31 insertions(+), 12 deletions(-)
 create mode 100644 srcpkgs/handbrake/patches/libhb-vpl-include.patch

diff --git a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
index 26db03867a0c83..d6bb2eda627a36 100644
--- a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
+++ b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
@@ -1,14 +1,15 @@
 --- a/gtk/configure.ac
 +++ b/gtk/configure.ac
 @@ -203,7 +203,7 @@
- 
+
  AM_CONDITIONAL([MINGW], [test "x$mingw_flag" = "xyes"])
- 
--HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg"
-+HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -ldl"
+
+-HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc"
++HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc -ldl"
  HB_CPPFLAGS="$HB_CPPFLAGS $HBINC"
- 
+
  PKG_CHECK_MODULES([x264], [x264], sys_x264=yes, sys_x264=no)
+
 --- a/test/module.defs
 +++ b/test/module.defs
 @@ -69,6 +69,9 @@
diff --git a/srcpkgs/handbrake/patches/libhb-vpl-include.patch b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
new file mode 100644
index 00000000000000..298f9f4ab28f2a
--- /dev/null
+++ b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
@@ -0,0 +1,15 @@
+--- a/libhb/module.defs	2023-01-22 11:36:49.000000000 -0500
++++ b/libhb/module.defs	2023-04-03 22:37:52.395467010 -0400
+@@ -46,11 +46,7 @@
+ LIBHB.GCC.I += $(LIBHB.build/) $(CONTRIB.build/)include
+ 
+ ifeq (1,$(FEATURE.qsv))
+-    ifeq ($(HOST.system),freebsd))
+-        LIBHB.GCC.I += $(LOCALBASE)/include/vpl
+-    else
+-        LIBHB.GCC.I += $(CONTRIB.build/)include/vpl
+-    endif
++    LIBHB.GCC.I += /usr/include/vpl
+ endif
+ 
+ ifneq (,$(filter $(HOST.system),freebsd netbsd openbsd))
diff --git a/srcpkgs/handbrake/template b/srcpkgs/handbrake/template
index ca5e4571e49c37..c32cb1bfa31f4b 100644
--- a/srcpkgs/handbrake/template
+++ b/srcpkgs/handbrake/template
@@ -1,10 +1,10 @@
 # Template file for 'handbrake'
 pkgname=handbrake
-version=1.5.1
+version=1.6.1
 revision=1
 build_style=gnu-configure
 configure_args="--force --disable-gtk-update-checks --disable-df-fetch --harden
- $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc)"
+ $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc) $(vopt_enable qsv)"
 make_build_args="-C ${XBPS_TRIPLET}"
 make_install_args="-C ${XBPS_TRIPLET}"
 hostmakedepends="automake cmake gettext-devel glib-devel intltool libtool m4 meson nasm pkg-config python3"
@@ -12,8 +12,11 @@ makedepends="bzip2-devel ffmpeg-devel gst-plugins-base1-devel gtk+3-devel
  jansson-devel lame-devel libass-devel libbluray-devel libdav1d-devel
  libdvdnav-devel libdvdread-devel libgudev-devel libnuma-devel
  libsamplerate-devel libtheora-devel libvorbis-devel libvpx-devel libxml2-devel
- opus-devel speex-devel x264-devel x265-devel zimg-devel
+ opus-devel speex-devel x264-devel x265-devel zimg-devel libsvt-av1-devel
  $(vopt_if fdk_aac fdk-aac-devel)
+ $(vopt_if qsv libva-devel)
+ $(vopt_if qsv libdrm-devel)
+ $(vopt_if qsv onevpl-devel)
  $(vopt_if nvenc nv-codec-headers)"
 depends="desktop-file-utils gst-plugins-good1 hicolor-icon-theme"
 short_desc="Multithreaded video transcoder"
@@ -21,15 +24,15 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-2.0-only"
 homepage="https://handbrake.fr/"
 distfiles="https://github.com/HandBrake/HandBrake/releases/download/${version}/HandBrake-${version}-source.tar.bz2"
-checksum=3999fe06d5309c819799a73a968a8ec3840e7840c2b64af8f5cdb7fd8c9430f0
+checksum=94ccfe03db917a91650000c510f7fd53f844da19f19ad4b4be1b8f6bc31a8d4c
 nocross=yes
 
-build_options="fdk_aac nvenc"
+build_options="fdk_aac nvenc qsv"
 
 case "$XBPS_TARGET_MACHINE" in
 	x86_64*|i686*)
 		CFLAGS="-msse"
-		build_options_default="nvenc"
+		build_options_default="nvenc qsv"
 		;;
 esac
 
@@ -37,7 +40,7 @@ pre_configure() {
 	# use system libraries, don't download them
 	rm -rf contrib/
 	for module in fdk-aac ffmpeg libbluray libdav1d libdvdnav libdvdread nvenc \
-		x265 zimg; do
+		x265 zimg svt-av1 libvpl; do
 	    vsed -i "/MODULES += contrib\/${module}/d" make/include/main.defs
 	done
 }

From 39c57e6ab4da1f5f6e36faf9d4c13e90cb97bc16 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 038/110] hedgewars: revbump for ffmpeg4

---
 srcpkgs/hedgewars/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/hedgewars/template b/srcpkgs/hedgewars/template
index 94b6db673b0c3a..402ccfaaecbc2d 100644
--- a/srcpkgs/hedgewars/template
+++ b/srcpkgs/hedgewars/template
@@ -1,13 +1,13 @@
 # Template file for 'hedgewars'
 pkgname=hedgewars
 version=1.0.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DNOSERVER=1 -DDATA_INSTALL_DIR=/usr/share/${pkgname}
  -DPHYSFS_SYSTEM=1 -DMINIMAL_FLAGS=1"
 make_cmd=make
 hostmakedepends="lua51 pkg-config qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
+makedepends="ffmpeg4-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
  SDL2_mixer-devel SDL2_net-devel SDL2_ttf-devel"
 depends="libfreeglut"
 short_desc="Funny turn-based artillery game, featuring fighting Hedgehogs!"

From 86333c29f753a80de416e3f3498906c9f017525d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 039/110] idjc: revbump for ffmpeg4

---
 srcpkgs/idjc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/idjc/template b/srcpkgs/idjc/template
index a9cde0665d55b1..f41e1e4fabbae7 100644
--- a/srcpkgs/idjc/template
+++ b/srcpkgs/idjc/template
@@ -1,11 +1,11 @@
 # Template file for 'idjc'
 pkgname=idjc
 version=0.9.1
-revision=5
+revision=6
 build_style=gnu-configure
 hostmakedepends="pkg-config git python3 automake gettext-devel libtool"
 makedepends="libvorbis-devel libogg-devel jack-devel libsamplerate-devel
- libflac-devel libsndfile-devel mpg123-devel ffmpeg-devel speex-devel
+ libflac-devel libsndfile-devel mpg123-devel ffmpeg4-devel speex-devel
  glib-devel pixman-devel lame-devel python3-gobject-devel libshout-idjc-devel
  opus-devel twolame-devel python3-mutagen python3-devel"
 depends="python3-gobject python3-mutagen desktop-file-utils shared-mime-info python3-dbus jack"

From fd49f04598598cc1d82df52892c7e6dcd2702a4f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 040/110] kid3: revbump for ffmpeg6

---
 srcpkgs/kid3/patches/ffmpeg5.patch | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 srcpkgs/kid3/patches/ffmpeg5.patch

diff --git a/srcpkgs/kid3/patches/ffmpeg5.patch b/srcpkgs/kid3/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..135fc50e07c9ba
--- /dev/null
+++ b/srcpkgs/kid3/patches/ffmpeg5.patch
@@ -0,0 +1,17 @@
+# https://aur.archlinux.org/cgit/aur.git/diff/ffmpeg5.patch?h=kid3-cli&id=12410a74906612e7efc0ec8fbce739b4a0fef7e7
+diff --git a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+index e156d424..e12b9abd 100644
+--- a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
++++ b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+@@ -232,7 +232,11 @@ private:
+   friend class Format;
+   friend class Converter;
+   AVCodecContext* m_ptr;
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 0, 0)
+   AVCodec* m_impl;
++#else
++  const AVCodec* m_impl;
++#endif
+   AVFrame* m_frame;
+   bool m_opened;
+ };

From 9817c4aea6788db2a5438a4a1cba014041b96929 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 041/110] kodi: revbump for ffmpeg4

---
 srcpkgs/kodi/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/kodi/template b/srcpkgs/kodi/template
index d37a5918cd6758..ea78e0aca0fe3e 100644
--- a/srcpkgs/kodi/template
+++ b/srcpkgs/kodi/template
@@ -1,7 +1,7 @@
 # Template file for 'kodi'
 pkgname=kodi
 version=19.4
-revision=9
+revision=10
 _codename="Matrix"
 build_style=cmake
 configure_args="-DWITH_FFMPEG=/usr -DENABLE_LDGOLD=OFF
@@ -54,7 +54,7 @@ makedepends="
  libmad-devel fontconfig-devel libXinerama-devel libsamplerate-devel libmms-devel
  enca-devel boost-devel libcurl-devel libva-devel libvdpau-devel libass-devel
  libbluetooth-devel yajl-devel libplist-devel librtmp-devel tinyxml-devel
- taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg-devel
+ taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg4-devel
  giflib-devel libxslt-devel gnutls-devel libssh-devel libmicrohttpd-devel
  libcec-devel dcadec-devel flatbuffers-devel fmt-devel lcms2-devel
  libfstrcmp-devel rapidjson libcdio-paranoia spdlog libwaylandpp-devel

From b210bad2c9833d8c7dbfec308219f0ef58f1168b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 042/110] kpipewire: revbump for ffmpeg6

---
 srcpkgs/kpipewire/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kpipewire/template b/srcpkgs/kpipewire/template
index 6214a4451336e7..3555348659dded 100644
--- a/srcpkgs/kpipewire/template
+++ b/srcpkgs/kpipewire/template
@@ -1,7 +1,7 @@
 # Template file for 'kpipewire'
 pkgname=kpipewire
 version=5.27.10
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules plasma-wayland-protocols gettext
  qt5-qmake qt5-host-tools pkg-config wayland-devel kcoreaddons

From e7dd0932bea6d0b3ee5062938d7c3ae396dc0131 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 043/110] libopenal: revbump for ffmpeg6

---
 srcpkgs/libopenal/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenal/template b/srcpkgs/libopenal/template
index 88d0f11307d81a..8308fca0393e33 100644
--- a/srcpkgs/libopenal/template
+++ b/srcpkgs/libopenal/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenal'
 pkgname=libopenal
 version=1.23.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DALSOFT_EXAMPLES=OFF"
 hostmakedepends="pkg-config"

From 364b4eb43d2ac2e162b5524db0427cb0c56670d4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 044/110] loudgain: revbump for ffmpeg6

---
 srcpkgs/loudgain/patches/ffmpeg5.patch | 11 +++++++++++
 srcpkgs/loudgain/template              |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/loudgain/patches/ffmpeg5.patch

diff --git a/srcpkgs/loudgain/patches/ffmpeg5.patch b/srcpkgs/loudgain/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..16d4510ee98faa
--- /dev/null
+++ b/srcpkgs/loudgain/patches/ffmpeg5.patch
@@ -0,0 +1,11 @@
+--- a/src/scan.c	2019-09-06 11:31:19.000000000 -0400
++++ b/src/scan.c	2023-03-23 11:15:40.867968521 -0400
+@@ -69,8 +69,6 @@
+ 	 * It is now useless
+ 	 * https://github.com/FFmpeg/FFmpeg/blob/70d25268c21cbee5f08304da95be1f647c630c15/doc/APIchanges#L86
+ 	 */
+-  if (avformat_version() < AV_VERSION_INT(58,9,100))
+-    av_register_all();
+ 
+ 	av_log_set_callback(scan_av_log);
+ 
diff --git a/srcpkgs/loudgain/template b/srcpkgs/loudgain/template
index da4f2d56e94c3d..4d6bf29efb4fdd 100644
--- a/srcpkgs/loudgain/template
+++ b/srcpkgs/loudgain/template
@@ -1,7 +1,7 @@
 # Template file for 'loudgain'
 pkgname=loudgain
 version=0.6.8
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libebur128-devel taglib-devel ffmpeg-devel"

From a025d7e5405f17d37e6f4ea8c3dc4121c9079497 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 045/110] mediastreamer: revbump for ffmpeg4

---
 srcpkgs/mediastreamer/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mediastreamer/template b/srcpkgs/mediastreamer/template
index 0fcffa7653d18e..e888626b945e55 100644
--- a/srcpkgs/mediastreamer/template
+++ b/srcpkgs/mediastreamer/template
@@ -1,11 +1,11 @@
 # Template file for 'mediastreamer'
 pkgname=mediastreamer
 version=5.2.111
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DENABLE_STRICT=0 -DENABLE_UNIT_TESTS=0"
 hostmakedepends="python3"
-makedepends="bzrtp-devel ffmpeg-devel glew-devel libXv-devel libsrtp-devel
+makedepends="bzrtp-devel ffmpeg4-devel glew-devel libXv-devel libsrtp-devel
  libupnp-devel libvpx-devel mbedtls-devel opus-devel ortp-devel pulseaudio-devel
  libtheora-devel speex-devel v4l-utils-devel bcg729-devel bcmatroska2-devel libgsm-devel
  zxing-cpp-devel"

From 6eb636708e853ae141b031351b4b4a74b04052bc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 046/110] mgba: revbump for ffmpeg6

---
 srcpkgs/mgba/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mgba/template b/srcpkgs/mgba/template
index 6cd65650312543..93401adb618bd8 100644
--- a/srcpkgs/mgba/template
+++ b/srcpkgs/mgba/template
@@ -1,7 +1,7 @@
 # Template file for 'mgba'
 pkgname=mgba
 version=0.10.3
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake desktop-file-utils"
 makedepends="SDL2-devel ffmpeg-devel libedit-devel libepoxy-devel libmagick-devel

From 50d4361290b65e67416d57105691669cdda87100 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 047/110] mlt: revbump for ffmpeg4

---
 srcpkgs/mlt/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mlt/template b/srcpkgs/mlt/template
index 73e3915aaab9ac..d7ed4c4b30a868 100644
--- a/srcpkgs/mlt/template
+++ b/srcpkgs/mlt/template
@@ -1,14 +1,14 @@
 # Template file for 'mlt'
 pkgname=mlt
 version=6.26.1
-revision=3
+revision=4
 build_style=configure
 configure_args="--prefix=/usr --libdir=/usr/lib$XBPS_TARGET_WORDSIZE
  --enable-gpl --enable-gpl3 --disable-swfdec --without-kde
  --swig-languages=python"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which"
 # XXX: movit vid.stab
-makedepends="alsa-lib-devel ffmpeg-devel gtk+-devel jack-devel ladspa-sdk
+makedepends="alsa-lib-devel ffmpeg4-devel gtk+-devel jack-devel ladspa-sdk
  libexif-devel libsamplerate-devel libxml2-devel sox-devel SDL_image-devel
  fftw-devel frei0r-plugins python3-devel pulseaudio-devel movit-devel
  libvidstab-devel"

From 6de86d7e9c937ec3ac6d36b0e182fd85a9f6379c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 048/110] moc: revbump for ffmpeg4

---
 srcpkgs/moc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/moc/template b/srcpkgs/moc/template
index 3a04932c8f1e61..838755f88db09e 100644
--- a/srcpkgs/moc/template
+++ b/srcpkgs/moc/template
@@ -1,10 +1,10 @@
 # Template file for 'moc'
 pkgname=moc
 version=2.5.2
-revision=7
+revision=8
 build_style=gnu-configure
 hostmakedepends="pkg-config"
-makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg-devel
+makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg4-devel
  jack-devel alsa-lib-devel libltdl-devel libflac-devel libvorbis-devel
  libmad-devel libmpcdec-devel libmodplug-devel libid3tag-devel faad2-devel
  taglib-devel libsndfile-devel wavpack-devel speex-devel libsamplerate-devel

From e32d3a75828ce26e8c30f65348d2efa8ded82332 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 049/110] motion: revbump for ffmpeg6

---
 srcpkgs/motion/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/motion/template b/srcpkgs/motion/template
index 607ebeb3c7b242..bf63a91d9764f6 100644
--- a/srcpkgs/motion/template
+++ b/srcpkgs/motion/template
@@ -1,7 +1,7 @@
 # Template file for 'motion'
 pkgname=motion
 version=4.6.0
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake pkg-config gettext-devel tar"
 makedepends="ffmpeg-devel libmicrohttpd-devel v4l-utils-devel gettext-devel"

From a15b08231139cea5e5db964b730730fdc6d5d2f2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 050/110] olive: revbump for ffmpeg4

---
 srcpkgs/olive/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/olive/template b/srcpkgs/olive/template
index 12a46936c99003..5c2917b9c51245 100644
--- a/srcpkgs/olive/template
+++ b/srcpkgs/olive/template
@@ -1,10 +1,10 @@
 # Template file for 'olive'
 pkgname=olive
 version=0.1.2
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools pkg-config"
-makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg-devel frei0r-plugins"
+makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg4-devel frei0r-plugins"
 short_desc="Non-linear video editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"

From d63c411dfd11f231740901a077186c8c08556883 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 051/110] opentoonz: revbump for ffmpeg6

---
 srcpkgs/opentoonz/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/opentoonz/template b/srcpkgs/opentoonz/template
index ee9f7603f55fd8..3e81834ca0eddf 100644
--- a/srcpkgs/opentoonz/template
+++ b/srcpkgs/opentoonz/template
@@ -1,7 +1,7 @@
 # Template file for 'opentoonz'
 pkgname=opentoonz
 version=1.6.0
-revision=2
+revision=3
 build_wrksrc="toonz/sources"
 build_style=cmake
 make_cmd=make

From ca5df7b833ddf820119e7d7144b2e9bf14c115c9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 052/110] pianobar: revbump for ffmpeg6

---
 srcpkgs/pianobar/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pianobar/template b/srcpkgs/pianobar/template
index e3febb821a4510..1e3dc1bf9308ee 100644
--- a/srcpkgs/pianobar/template
+++ b/srcpkgs/pianobar/template
@@ -1,7 +1,7 @@
 # Template file for 'pianobar'
 pkgname=pianobar
 version=2022.04.01
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="V=1"
 hostmakedepends="pkg-config"

From fe9dd8daaf50f720492102756fbd40a9e51f712b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 053/110] ppsspp: revbump for ffmpeg6

---
 srcpkgs/ppsspp/patches/ffmpeg6.patch | 15 +++++++++++++++
 srcpkgs/ppsspp/template              |  3 +--
 2 files changed, 16 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/ppsspp/patches/ffmpeg6.patch

diff --git a/srcpkgs/ppsspp/patches/ffmpeg6.patch b/srcpkgs/ppsspp/patches/ffmpeg6.patch
new file mode 100644
index 00000000000000..5803c7bf227309
--- /dev/null
+++ b/srcpkgs/ppsspp/patches/ffmpeg6.patch
@@ -0,0 +1,15 @@
+--- a/Core/HW/SimpleAudioDec.cpp	2024-02-04 08:08:02.000000000 -0500
++++ b/Core/HW/SimpleAudioDec.cpp	2024-02-15 14:48:27.114362051 -0500
+@@ -81,7 +81,11 @@
+ 		return;
+ 	}
+ 	// Find decoder
++#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(58, 18, 100)
+ 	codec_ = avcodec_find_decoder((AVCodecID)audioCodecId);
++#else // this is a macro to const in the header
++	codec_ = (AVCodec*)avcodec_find_decoder((AVCodecID)audioCodecId);
++#endif
+ 	if (!codec_) {
+ 		// Eh, we shouldn't even have managed to compile. But meh.
+ 		ERROR_LOG(ME, "This version of FFMPEG does not support AV_CODEC_ctx for audio (%s). Update your submodule.", GetCodecName(audioType));
+
diff --git a/srcpkgs/ppsspp/template b/srcpkgs/ppsspp/template
index 2238a7601c0af8..1fda55268a2d39 100644
--- a/srcpkgs/ppsspp/template
+++ b/srcpkgs/ppsspp/template
@@ -1,7 +1,7 @@
 # Template file for 'ppsspp'
 pkgname=ppsspp
 version=1.17.1
-revision=1
+revision=2
 _glslang_commit=b34f619e1c85810dcb3c578107d2e48ba4ee2b37
 _SPIRV_Cross_commit=4212eef67ed0ca048cb726a6767185504e7695e5
 _armips_commit=a8d71f0f279eb0d30ecf6af51473b66ae0cf8e8d
@@ -91,7 +91,6 @@ post_configure() {
 }
 
 do_install() {
-	vlicense LICENSE.TXT
 	vinstall icons/icon.svg 644 usr/share/pixmaps ppsspp.svg
 	vinstall Qt/PPSSPP.desktop 644 usr/share/applications
 	vbin build/PPSSPPHeadless ppsspp-headless

From 005dad0438415d5b4307f8f0450480d69aeb0b01 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 054/110] pqiv: revbump for ffmpeg6

---
 srcpkgs/pqiv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pqiv/template b/srcpkgs/pqiv/template
index 24bd18ebe8618f..9fc2324ec7ce6b 100644
--- a/srcpkgs/pqiv/template
+++ b/srcpkgs/pqiv/template
@@ -1,7 +1,7 @@
 # Template file for 'pqiv'
 pkgname=pqiv
 version=2.13
-revision=1
+revision=2
 build_style=gnu-makefile
 hostmakedepends="pkg-config"
 makedepends="glib-devel gtk+3-devel $(vopt_if ffmpeg ffmpeg-devel)

From d6130802223c713c29e65c49c3b18445b0c9d3f7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 055/110] qmmp: revbump for ffmpeg6

---
 srcpkgs/qmmp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qmmp/template b/srcpkgs/qmmp/template
index 53781ea3bc28ad..2da07f1e87eac0 100644
--- a/srcpkgs/qmmp/template
+++ b/srcpkgs/qmmp/template
@@ -1,7 +1,7 @@
 # Template file for 'qmmp'
 pkgname=qmmp
 version=1.6.1
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DUSE_HAL:BOOL=FALSE -DQMMP_DEFAULT_UI:STRING=simple"
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From d949ed669332e597e5cdda9edd348b04016ed0c4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 14 Dec 2023 13:28:10 -0500
Subject: [PATCH 056/110] qt6-pdf: revbump for ffmpeg6

---
 srcpkgs/qt6-pdf/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-pdf/template b/srcpkgs/qt6-pdf/template
index ecda84afac1310..531b4e1d4fe84d 100644
--- a/srcpkgs/qt6-pdf/template
+++ b/srcpkgs/qt6-pdf/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-pdf'
 pkgname=qt6-pdf
 version=6.6.0
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DQT_FEATURE_qtpdf_build=ON
  -DQT_FEATURE_qtpdf_widgets_build=ON

From b60b8c4edf70fcbc52bfc0fb503ea25317ee1566 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 057/110] qt5-webengine: revbump for ffmpeg6

---
 .../chromium-media-filters-cpp14.patch        |  11 ++
 srcpkgs/qt5-webengine/patches/ffmpeg5.patch   | 179 ++++++++++++++++++
 .../qtwebengine-fix-ffmpeg5-build.patch       |  14 ++
 srcpkgs/qt5-webengine/template                |   4 +-
 4 files changed, 206 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/ffmpeg5.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch

diff --git a/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
new file mode 100644
index 00000000000000..04adc540f2cbc0
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
@@ -0,0 +1,11 @@
+--- a/src/3rdparty/chromium/media/filters/BUILD.gn	2023-02-27 13:32:59.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/BUILD.gn	2023-04-02 17:21:39.204066384 -0400
+@@ -96,6 +96,8 @@
+     "//ui/gfx/geometry:geometry",
+   ]
+ 
++  cflags_cc = [ "-std=c++14" ]
++
+   libs = []
+ 
+   if (proprietary_codecs) {
diff --git a/srcpkgs/qt5-webengine/patches/ffmpeg5.patch b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..ac55e1634423a9
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
@@ -0,0 +1,179 @@
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:57.732547446 -0400
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:09.486478995 -0400
+@@ -57,6 +57,8 @@
+ 
+ namespace {
+ 
++constexpr int64_t kRelativeTsBase = static_cast<int64_t>(0x7ffeffffffffffff);
++
+ void SetAVStreamDiscard(AVStream* stream, AVDiscard discard) {
+   DCHECK(stream);
+   stream->discard = discard;
+@@ -90,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+   if (stream->start_time != kNoFFmpegTimestamp)
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (stream->first_dts != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, stream->first_dts);
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -408,11 +398,11 @@
+   scoped_refptr<DecoderBuffer> buffer;
+ 
+   if (type() == DemuxerStream::TEXT) {
+-    int id_size = 0;
++    size_t id_size = 0;
+     uint8_t* id_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
+ 
+-    int settings_size = 0;
++    size_t settings_size = 0;
+     uint8_t* settings_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
+ 
+@@ -424,7 +414,7 @@
+     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
+                                      side_data.data(), side_data.size());
+   } else {
+-    int side_data_size = 0;
++    size_t side_data_size = 0;
+     uint8_t* side_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
+ 
+@@ -485,7 +475,7 @@
+                                        packet->size - data_offset);
+     }
+ 
+-    int skip_samples_size = 0;
++    size_t skip_samples_size = 0;
+     const uint32_t* skip_samples_ptr =
+         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
+             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
+@@ -1587,6 +1577,8 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++      continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+       lowest_start_time_stream = stream.get();
+@@ -1604,6 +1596,8 @@
+     if (stream && stream->type() == DemuxerStream::VIDEO &&
+         stream->IsEnabled()) {
+       video_stream = stream.get();
++      if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++        continue;
+       if (video_stream->start_time() <= seek_time) {
+         return video_stream;
+       }
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h qtwebengine-5.15.10/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h
+--- a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-07-11 22:12:47.917192788 -0500
+@@ -29,6 +29,7 @@ extern "C" {
+ #include <libavformat/avformat.h>
+ #include <libavformat/avio.h>
+ #include <libavutil/avutil.h>
++#include <libavutil/channel_layout.h>
+ #include <libavutil/imgutils.h>
+ #include <libavutil/log.h>
+ #include <libavutil/mastering_display_metadata.h>
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/audio_file_reader.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/audio_file_reader.cc
+--- a/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -85,7 +85,7 @@ bool AudioFileReader::OpenDemuxer() {
+ }
+ 
+ bool AudioFileReader::OpenDecoder() {
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (codec) {
+     // MP3 decodes to S16P which we don't support, tell it to use S16 instead.
+     if (codec_context_->sample_fmt == AV_SAMPLE_FMT_S16P)
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -329,7 +329,7 @@ bool FFmpegAudioDecoder::ConfigureDecode
+     }
+   }
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec ||
+       avcodec_open2(codec_context_.get(), codec, &codec_options) < 0) {
+     DLOG(ERROR) << "Could not initialize audio decoder: "
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -59,7 +59,6 @@ static int64_t AVIOSeekOperation(void* o
+ }
+ 
+ void FFmpegGlue::InitializeFFmpeg() {
+-  av_register_all();
+ }
+ 
+ static void LogContainer(bool is_local_file,
+@@ -95,9 +94,6 @@ FFmpegGlue::FFmpegGlue(FFmpegURLProtocol
+   // Enable fast, but inaccurate seeks for MP3.
+   format_context_->flags |= AVFMT_FLAG_FAST_SEEK;
+ 
+-  // Ensures we can read out various metadata bits like vp8 alpha.
+-  format_context_->flags |= AVFMT_FLAG_KEEP_SIDE_DATA;
+-
+   // Ensures format parsing errors will bail out. From an audit on 11/2017, all
+   // instances were real failures. Solves bugs like http://crbug.com/710791.
+   format_context_->error_recognition |= AV_EF_EXPLODE;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -391,7 +391,7 @@ bool FFmpegVideoDecoder::ConfigureDecode
+   if (decode_nalus_)
+     codec_context_->flags2 |= AV_CODEC_FLAG2_CHUNKS;
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
+     ReleaseFFmpegResources();
+     return false;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/media_file_checker.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/media_file_checker.cc
+--- a/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -68,7 +68,7 @@ bool MediaFileChecker::Start(base::TimeD
+       auto context = AVStreamToAVCodecContext(format_context->streams[i]);
+       if (!context)
+         continue;
+-      AVCodec* codec = avcodec_find_decoder(cp->codec_id);
++      const AVCodec* codec = avcodec_find_decoder(cp->codec_id);
+       if (codec && avcodec_open2(context.get(), codec, nullptr) >= 0) {
+         auto loop = std::make_unique<FFmpegDecodingLoop>(context.get());
+         stream_contexts[i] = {std::move(context), std::move(loop)};
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc qtwebengine-5.15.10/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc
+--- a/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -203,7 +203,7 @@ int32_t H264DecoderImpl::InitDecode(cons
+   // a pointer |this|.
+   av_context_->opaque = this;
+ 
+-  AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
+   if (!codec) {
+     // This is an indication that FFmpeg has not been initialized or it has not
+     // been compiled/initialized with the correct set of codecs.
diff --git a/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch b/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch
new file mode 100644
index 00000000000000..bc24d5b9a29cb5
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch
@@ -0,0 +1,14 @@
+--- a/src/buildtools/configure.json	2023-12-09 11:06:01.503058569 -0500
++++ b/src/buildtools/configure.json	2023-12-09 11:06:14.982361345 -0500
+@@ -779,11 +779,6 @@
+             "type": "warning",
+             "condition": "config.ios && config.simulator && config.device && features.build-qtpdf",
+             "message": "Building fat libray with device and simulator architectures will disable NEON."
+-        },
+-        {
+-            "type": "fatal",
+-            "condition": "features.webengine-system-ffmpeg && !libs.webengine-ffmpeg-support",
+-            "message": "Unmodified ffmpeg >= 5.0 is not supported. Please configure with -qt-webengine-ffmpeg."
+         }
+     ],
+     "summary": [
diff --git a/srcpkgs/qt5-webengine/template b/srcpkgs/qt5-webengine/template
index 8d2df1b5175bad..1687a77eb8a2f5 100644
--- a/srcpkgs/qt5-webengine/template
+++ b/srcpkgs/qt5-webengine/template
@@ -1,14 +1,14 @@
 # Template file for 'qt5-webengine'
 pkgname=qt5-webengine
 version=5.15.16
-revision=1
+revision=2
 _version="${version}-lts"
 _chromium_commit=207c2ac45ca3386d153770c6b0d2ea2ec21ca880
 archs="x86_64* i686* armv[67]* ppc64* aarch64*"
 create_wrksrc=yes
 build_style=qmake
 configure_args="--
- -webengine-icu -webengine-ffmpeg -webengine-opus -webengine-webp
+ -webengine-icu -system-ffmpeg -webengine-opus -webengine-webp
  -webengine-pepper-plugins -webengine-printing-and-pdf -webengine-proprietary-codecs
  -webengine-pulseaudio -webengine-spellchecker -webengine-webrtc -webengine-geolocation
  -webengine-kerberos -no-webengine-embedded-build $(vopt_if sndio '' '-no')-webengine-sndio

From 2ffd1da50ea1ef8af320e667b00b25b4f2096059 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 058/110] qt5: revbump for ffmpeg6

---
 srcpkgs/qt5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5/template b/srcpkgs/qt5/template
index 3efb7e42d5fd3f..27f6d5388cd15c 100644
--- a/srcpkgs/qt5/template
+++ b/srcpkgs/qt5/template
@@ -3,9 +3,9 @@
 # revbump libqtxdg after bumping patch version
 pkgname=qt5
 version=5.15.11+20231124
+revision=3
 # commit 4765fa1df7a837db9c1f89c4da0dd76b74bb5fab
 # base repo: https://invent.kde.org/qt/qt/qt5
-revision=2
 build_style=meta
 hostmakedepends="cmake clang17 flex perl glib-devel pkg-config
  python3 re2c ruby which"

From 1a219b6b5b33e8be4d049a264d94ac001840ba92 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 059/110] qtav: revbump for ffmpeg4

---
 srcpkgs/qtav/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtav/template b/srcpkgs/qtav/template
index 775d5a139a9efa..aa69e213c984b0 100644
--- a/srcpkgs/qtav/template
+++ b/srcpkgs/qtav/template
@@ -1,10 +1,10 @@
 # Template file for 'qtav'
 pkgname=qtav
 version=1.13.0
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel libass-devel libopenal-devel
+makedepends="ffmpeg4-devel libass-devel libopenal-devel
  libva-glx-devel libXv-devel pulseaudio-devel
  qt5-declarative-devel qt5-svg-devel
  qt5-quickcontrols"

From 6cf59b075dbfc0c72ec7ffa34e1e1b799d47c4f1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 060/110] retroarch: revbump for ffmpeg6

---
 srcpkgs/retroarch/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroarch/template b/srcpkgs/retroarch/template
index cb3125c5dbf1ae..c65c26f7bf0332 100644
--- a/srcpkgs/retroarch/template
+++ b/srcpkgs/retroarch/template
@@ -1,7 +1,7 @@
 # Template file for 'retroarch'
 pkgname=retroarch
 version=1.16.0.3
-revision=3
+revision=4
 build_style=configure
 configure_args="--prefix=/usr --sysconfdir=/etc --enable-networking
  --enable-udev --disable-builtinflac --disable-builtinglslang

From 73c186ccc57ee506f5993d5143717c2a9e24edc8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 061/110] scrcpy: revbump for ffmpeg6

---
 srcpkgs/scrcpy/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/scrcpy/template b/srcpkgs/scrcpy/template
index d04de770dc1913..5218fa01f8ce1f 100644
--- a/srcpkgs/scrcpy/template
+++ b/srcpkgs/scrcpy/template
@@ -1,7 +1,7 @@
 # Template file for 'scrcpy'
 pkgname=scrcpy
 version=2.3.1
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcompile_server=false
  -Dprebuilt_server=/usr/share/scrcpy/scrcpy-server-v${version}"

From 49b06b3436b55c1f43e57b4eb829d9ea6528f7a9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 17 Oct 2023 08:54:11 -0400
Subject: [PATCH 062/110] New package: spex-x replaces spek-alternative for
 ffmpeg6

---
 srcpkgs/spek-alternative                      |  1 +
 srcpkgs/spek-x/patches/musl.patch             |  7 ++++++
 srcpkgs/{spek-alternative => spek-x}/template | 22 ++++++++++++-------
 3 files changed, 22 insertions(+), 8 deletions(-)
 create mode 120000 srcpkgs/spek-alternative
 create mode 100644 srcpkgs/spek-x/patches/musl.patch
 rename srcpkgs/{spek-alternative => spek-x}/template (52%)

diff --git a/srcpkgs/spek-alternative b/srcpkgs/spek-alternative
new file mode 120000
index 00000000000000..76648236da7017
--- /dev/null
+++ b/srcpkgs/spek-alternative
@@ -0,0 +1 @@
+spek-x
\ No newline at end of file
diff --git a/srcpkgs/spek-x/patches/musl.patch b/srcpkgs/spek-x/patches/musl.patch
new file mode 100644
index 00000000000000..662f45936febc6
--- /dev/null
+++ b/srcpkgs/spek-x/patches/musl.patch
@@ -0,0 +1,7 @@
+--- a/tests/perf.cc	2024-03-09 17:13:49.086603418 -0500
++++ b/tests/perf.cc	2024-03-09 17:13:59.453603753 -0500
+@@ -1,3 +1,4 @@
++#include <cstdint>
+ #include <cstdlib>
+ #include <iostream>
+ #include <fstream>
diff --git a/srcpkgs/spek-alternative/template b/srcpkgs/spek-x/template
similarity index 52%
rename from srcpkgs/spek-alternative/template
rename to srcpkgs/spek-x/template
index d7b55c776b1d43..3ded6c2c323e4f 100644
--- a/srcpkgs/spek-alternative/template
+++ b/srcpkgs/spek-x/template
@@ -1,18 +1,18 @@
-# Template file for 'spek-alternative'
-pkgname=spek-alternative
-version=0.8.2.3
-revision=2
+# Template file for 'spek-x'
+pkgname=spek-x
+version=0.9.3
+revision=1
 build_style=gnu-configure
 hostmakedepends="automake gettext-devel intltool libtool pkg-config
  wxWidgets-common wxWidgets-gtk3-devel"
 makedepends="ffmpeg-devel wxWidgets-gtk3-devel"
 depends="ffmpeg"
 short_desc="Acoustic spectrum analyser"
-maintainer="Kartik Singh <kartik.ynwa@gmail.com>"
+maintainer="zlice <zlice555@gmail.com>"
 license="GPL-3.0-or-later"
-homepage="https://github.com/withmorten/spek-alternative"
-distfiles="https://github.com/withmorten/spek-alternative/archive/${version}.tar.gz"
-checksum="007ba4b84a310b078e378aa84c8e80783db5821437a757a488c3ecec377e6b2a"
+homepage="https://github.com/MikeWang000000/spek-x"
+distfiles="https://github.com/MikeWang000000/spek-x/archive/v${version}.tar.gz"
+checksum="7f4b109903333cdd310ab2b9176f0dc49a565891376e281a233d342cedf90ef7"
 
 CXXFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
 
@@ -22,3 +22,9 @@ export WX_CONFIG_NAME="wx-config-gtk3"
 pre_configure() {
 	NOCONFIGURE=1 ./autogen.sh
 }
+
+spek-alternative_package() {
+	depends="spek-x"
+	short_desc+=" - transitional dummy package"
+	build_style=meta
+}

From be2accfe19a08cc8843c7298884bf848368555c8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 063/110] ssr: revbump for ffmpeg6

---
 .../0001-Fix-build-with-ffmpeg-5.0.patch      | 241 ++++++++++++++++++
 srcpkgs/ssr/template                          |   2 +-
 2 files changed, 242 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ssr/patches/0001-Fix-build-with-ffmpeg-5.0.patch

diff --git a/srcpkgs/ssr/patches/0001-Fix-build-with-ffmpeg-5.0.patch b/srcpkgs/ssr/patches/0001-Fix-build-with-ffmpeg-5.0.patch
new file mode 100644
index 00000000000000..4c069b5a9fc464
--- /dev/null
+++ b/srcpkgs/ssr/patches/0001-Fix-build-with-ffmpeg-5.0.patch
@@ -0,0 +1,241 @@
+From f4cbde38021d9330dc73d2e3dfa8a70da3ff5721 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Bernhard=20Rosenkr=C3=A4nzer?= <bero@lindev.ch>
+Date: Sun, 16 Jan 2022 02:40:04 +0100
+Subject: [PATCH] Fix build with ffmpeg 5.0
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Adapt to ffmpeg 5.0 requiring more const-ness for AVCodec.
+
+Signed-off-by: Bernhard Rosenkränzer <bero@lindev.ch>
+---
+ src/AV/Output/AudioEncoder.cpp |  6 +++---
+ src/AV/Output/AudioEncoder.h   |  4 ++--
+ src/AV/Output/BaseEncoder.cpp  |  4 ++--
+ src/AV/Output/BaseEncoder.h    |  4 ++--
+ src/AV/Output/Muxer.cpp        | 12 ++++++------
+ src/AV/Output/Muxer.h          |  4 ++--
+ src/AV/Output/VideoEncoder.cpp |  6 +++---
+ src/AV/Output/VideoEncoder.h   |  4 ++--
+ 8 files changed, 22 insertions(+), 22 deletions(-)
+
+diff --git a/src/AV/Output/AudioEncoder.cpp b/src/AV/Output/AudioEncoder.cpp
+index 34d015c..cefc2e0 100644
+--- a/src/AV/Output/AudioEncoder.cpp
++++ b/src/AV/Output/AudioEncoder.cpp
+@@ -34,7 +34,7 @@ const std::vector<AudioEncoder::SampleFormatData> AudioEncoder::SUPPORTED_SAMPLE
+ 
+ const unsigned int AudioEncoder::DEFAULT_FRAME_SAMPLES = 1024;
+ 
+-AudioEncoder::AudioEncoder(Muxer* muxer, AVStream* stream, AVCodecContext *codec_context, AVCodec* codec, AVDictionary** options)
++AudioEncoder::AudioEncoder(Muxer* muxer, AVStream* stream, AVCodecContext *codec_context, const AVCodec* codec, AVDictionary** options)
+ 	: BaseEncoder(muxer, stream, codec_context, codec, options) {
+ 
+ #if !SSR_USE_AVCODEC_ENCODE_AUDIO2
+@@ -77,7 +77,7 @@ unsigned int AudioEncoder::GetSampleRate() {
+ }
+ 
+ bool AudioEncoder::AVCodecIsSupported(const QString& codec_name) {
+-	AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
++	const AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
+ 	if(codec == NULL)
+ 		return false;
+ 	if(!av_codec_is_encoder(codec))
+@@ -93,7 +93,7 @@ bool AudioEncoder::AVCodecIsSupported(const QString& codec_name) {
+ 	return false;
+ }
+ 
+-void AudioEncoder::PrepareStream(AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
++void AudioEncoder::PrepareStream(AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
+ 								 unsigned int bit_rate, unsigned int channels, unsigned int sample_rate) {
+ 
+ 	if(channels == 0) {
+diff --git a/src/AV/Output/AudioEncoder.h b/src/AV/Output/AudioEncoder.h
+index c93278c..ae9c82e 100644
+--- a/src/AV/Output/AudioEncoder.h
++++ b/src/AV/Output/AudioEncoder.h
+@@ -40,7 +40,7 @@ private:
+ #endif
+ 
+ public:
+-	AudioEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options);
++	AudioEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options);
+ 	~AudioEncoder();
+ 
+ 	// Returns the required frame size, i.e. the number of samples (for each channel).
+@@ -57,7 +57,7 @@ public:
+ 
+ public:
+ 	static bool AVCodecIsSupported(const QString& codec_name);
+-	static void PrepareStream(AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
++	static void PrepareStream(AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
+ 							  unsigned int bit_rate, unsigned int channels, unsigned int sample_rate);
+ 
+ private:
+diff --git a/src/AV/Output/BaseEncoder.cpp b/src/AV/Output/BaseEncoder.cpp
+index 7c01ef3..4780aaf 100644
+--- a/src/AV/Output/BaseEncoder.cpp
++++ b/src/AV/Output/BaseEncoder.cpp
+@@ -42,7 +42,7 @@ double ParseCodecOptionDouble(const QString& key, const QString& value, double m
+ 	return clamp(value_double, min, max) * multiply;
+ }
+ 
+-BaseEncoder::BaseEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options) {
++BaseEncoder::BaseEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options) {
+ 
+ 	m_muxer = muxer;
+ 	m_stream = stream;
+@@ -157,7 +157,7 @@ void BaseEncoder::IncrementPacketCounter() {
+ 	++lock->m_total_packets;
+ }
+ 
+-void BaseEncoder::Init(AVCodec* codec, AVDictionary** options) {
++void BaseEncoder::Init(const AVCodec* codec, AVDictionary** options) {
+ 
+ 	// open codec
+ 	if(avcodec_open2(m_codec_context, codec, options) < 0) {
+diff --git a/src/AV/Output/BaseEncoder.h b/src/AV/Output/BaseEncoder.h
+index 3d92f29..7f02bbd 100644
+--- a/src/AV/Output/BaseEncoder.h
++++ b/src/AV/Output/BaseEncoder.h
+@@ -51,7 +51,7 @@ private:
+ 	std::atomic<bool> m_should_stop, m_should_finish, m_is_done, m_error_occurred;
+ 
+ protected:
+-	BaseEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options);
++	BaseEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options);
+ 
+ public:
+ 	virtual ~BaseEncoder(); // encoders will be deleted by Muxer, don't delete them yourself!
+@@ -117,7 +117,7 @@ protected:
+ 	void IncrementPacketCounter();
+ 
+ private:
+-	void Init(AVCodec* codec, AVDictionary** options);
++	void Init(const AVCodec* codec, AVDictionary** options);
+ 	void Free();
+ 
+ 	void EncoderThread();
+diff --git a/src/AV/Output/Muxer.cpp b/src/AV/Output/Muxer.cpp
+index ad58380..14650b0 100644
+--- a/src/AV/Output/Muxer.cpp
++++ b/src/AV/Output/Muxer.cpp
+@@ -87,7 +87,7 @@ Muxer::~Muxer() {
+ 
+ VideoEncoder* Muxer::AddVideoEncoder(const QString& codec_name, const std::vector<std::pair<QString, QString> >& codec_options,
+ 									 unsigned int bit_rate, unsigned int width, unsigned int height, unsigned int frame_rate) {
+-	AVCodec *codec = FindCodec(codec_name);
++	const AVCodec *codec = FindCodec(codec_name);
+ 	AVCodecContext *codec_context = NULL;
+ 	AVStream *stream = AddStream(codec, &codec_context);
+ 	VideoEncoder *encoder;
+@@ -111,7 +111,7 @@ VideoEncoder* Muxer::AddVideoEncoder(const QString& codec_name, const std::vecto
+ 
+ AudioEncoder* Muxer::AddAudioEncoder(const QString& codec_name, const std::vector<std::pair<QString, QString> >& codec_options,
+ 									 unsigned int bit_rate, unsigned int channels, unsigned int sample_rate) {
+-	AVCodec *codec = FindCodec(codec_name);
++	const AVCodec *codec = FindCodec(codec_name);
+ 	AVCodecContext *codec_context = NULL;
+ 	AVStream *stream = AddStream(codec, &codec_context);
+ 	AudioEncoder *encoder;
+@@ -194,7 +194,7 @@ unsigned int Muxer::GetQueuedPacketCount(unsigned int stream_index) {
+ void Muxer::Init() {
+ 
+ 	// get the format we want (this is just a pointer, we don't have to free this)
+-	AVOutputFormat *format = av_guess_format(m_container_name.toUtf8().constData(), NULL, NULL);
++	const AVOutputFormat *format = av_guess_format(m_container_name.toUtf8().constData(), NULL, NULL);
+ 	if(format == NULL) {
+ 		Logger::LogError("[Muxer::Init] " + Logger::tr("Error: Can't find chosen output format!"));
+ 		throw LibavException();
+@@ -261,8 +261,8 @@ void Muxer::Free() {
+ 	}
+ }
+ 
+-AVCodec* Muxer::FindCodec(const QString& codec_name) {
+-	AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
++const AVCodec* Muxer::FindCodec(const QString& codec_name) {
++	const AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
+ 	if(codec == NULL) {
+ 		Logger::LogError("[Muxer::FindCodec] " + Logger::tr("Error: Can't find codec!"));
+ 		throw LibavException();
+@@ -270,7 +270,7 @@ AVCodec* Muxer::FindCodec(const QString& codec_name) {
+ 	return codec;
+ }
+ 
+-AVStream* Muxer::AddStream(AVCodec* codec, AVCodecContext** codec_context) {
++AVStream* Muxer::AddStream(const AVCodec* codec, AVCodecContext** codec_context) {
+ 	assert(!m_started);
+ 	assert(m_format_context->nb_streams < MUXER_MAX_STREAMS);
+ 
+diff --git a/src/AV/Output/Muxer.h b/src/AV/Output/Muxer.h
+index d72347d..b104bcb 100644
+--- a/src/AV/Output/Muxer.h
++++ b/src/AV/Output/Muxer.h
+@@ -114,8 +114,8 @@ private:
+ 	void Init();
+ 	void Free();
+ 
+-	AVCodec* FindCodec(const QString& codec_name);
+-	AVStream* AddStream(AVCodec* codec, AVCodecContext** codec_context);
++	const AVCodec* FindCodec(const QString& codec_name);
++	AVStream* AddStream(const AVCodec* codec, AVCodecContext** codec_context);
+ 
+ 	void MuxerThread();
+ 
+diff --git a/src/AV/Output/VideoEncoder.cpp b/src/AV/Output/VideoEncoder.cpp
+index 8087e8e..fc8b5d1 100644
+--- a/src/AV/Output/VideoEncoder.cpp
++++ b/src/AV/Output/VideoEncoder.cpp
+@@ -34,7 +34,7 @@ const std::vector<VideoEncoder::PixelFormatData> VideoEncoder::SUPPORTED_PIXEL_F
+ 	{"rgb", AV_PIX_FMT_RGB24, false},
+ };
+ 
+-VideoEncoder::VideoEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options)
++VideoEncoder::VideoEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options)
+ 	: BaseEncoder(muxer, stream, codec_context, codec, options) {
+ 
+ #if !SSR_USE_AVCODEC_ENCODE_VIDEO2
+@@ -95,7 +95,7 @@ unsigned int VideoEncoder::GetFrameRate() {
+ }
+ 
+ bool VideoEncoder::AVCodecIsSupported(const QString& codec_name) {
+-	AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
++	const AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
+ 	if(codec == NULL)
+ 		return false;
+ 	if(!av_codec_is_encoder(codec))
+@@ -111,7 +111,7 @@ bool VideoEncoder::AVCodecIsSupported(const QString& codec_name) {
+ 	return false;
+ }
+ 
+-void VideoEncoder::PrepareStream(AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
++void VideoEncoder::PrepareStream(AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
+ 								 unsigned int bit_rate, unsigned int width, unsigned int height, unsigned int frame_rate) {
+ 
+ 	if(width == 0 || height == 0) {
+diff --git a/src/AV/Output/VideoEncoder.h b/src/AV/Output/VideoEncoder.h
+index cb7ca27..68d872e 100644
+--- a/src/AV/Output/VideoEncoder.h
++++ b/src/AV/Output/VideoEncoder.h
+@@ -40,7 +40,7 @@ private:
+ #endif
+ 
+ public:
+-	VideoEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options);
++	VideoEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options);
+ 	~VideoEncoder();
+ 
+ 	// Returns the required pixel format.
+@@ -55,7 +55,7 @@ public:
+ 
+ public:
+ 	static bool AVCodecIsSupported(const QString& codec_name);
+-	static void PrepareStream(AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
++	static void PrepareStream(AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
+ 							  unsigned int bit_rate, unsigned int width, unsigned int height, unsigned int frame_rate);
+ 
+ private:
+-- 
+2.43.0
+
diff --git a/srcpkgs/ssr/template b/srcpkgs/ssr/template
index 3097754e3cbe54..e3c4261f1f5a64 100644
--- a/srcpkgs/ssr/template
+++ b/srcpkgs/ssr/template
@@ -1,7 +1,7 @@
 # Template file for 'ssr'
 pkgname=ssr
 version=0.4.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DWITH_QT5=ON"
 hostmakedepends="pkg-config"

From 5c0e5f535abc3607e1df6b40b0674c408b1116e6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 064/110] synfig: revbump for ffmpeg6 and mlt7

---
 srcpkgs/synfig/patches/ffmpeg6.patch | 71 ++++++++++++++++++++++++++++
 srcpkgs/synfig/template              |  6 +--
 2 files changed, 74 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/synfig/patches/ffmpeg6.patch

diff --git a/srcpkgs/synfig/patches/ffmpeg6.patch b/srcpkgs/synfig/patches/ffmpeg6.patch
new file mode 100644
index 00000000000000..10780b42782f4b
--- /dev/null
+++ b/srcpkgs/synfig/patches/ffmpeg6.patch
@@ -0,0 +1,71 @@
+--- a/src/modules/mod_libavcodec/trgt_av.cpp	2022-10-25 09:14:12.000000000 -0400
++++ b/src/modules/mod_libavcodec/trgt_av.cpp	2023-05-05 21:34:17.899194559 -0400
+@@ -38,6 +41,7 @@
+ extern "C"
+ {
+ #ifdef HAVE_LIBAVFORMAT_AVFORMAT_H
++#	include <libavcodec/avcodec.h>
+ #	include <libavformat/avformat.h>
+ #elif defined(HAVE_AVFORMAT_H)
+ #	include <avformat.h>
+@@ -155,11 +156,11 @@
+     }
+ 
+ 	bool open_video_stream() {
+-		if (avcodec_open2(video_context, NULL, NULL) < 0) {
++		if (avcodec_open2(video_context, nullptr, nullptr) < 0) {
+ 			synfig::error("Target_LibAVCodec: could not open video codec");
+ 			// seems the calling of avcodec_free_context after error will cause crash
+ 			// so just forget about this context
+-			video_context = NULL;
++			video_context = nullptr;
+ 			close();
+ 			return false;
+         }
+@@ -234,15 +235,21 @@
+ 		close();
+ 
+ 		if (!av_registered) {
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 			av_register_all();
++#endif
+ 			av_registered = true;
+ 		}
+ 
+ 		// guess format
+-		AVOutputFormat *format = av_guess_format(NULL, filename.c_str(), NULL);
++#if LIBAVCODEC_VERSION_MAJOR < 59 // FFMPEG < 5.0
++		AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#else
++		const AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#endif
+ 		if (!format) {
+ 			synfig::warning("Target_LibAVCodec: unable to guess the output format, defaulting to MPEG");
+-			format = av_guess_format("mpeg", NULL, NULL);
++			format = av_guess_format("mpeg", nullptr, nullptr);
+ 		}
+ 		if (!format) {
+ 			synfig::error("Target_LibAVCodec: unable to find 'mpeg' output format");
+@@ -254,6 +261,7 @@
+ 		context = avformat_alloc_context();
+ 		assert(context);
+ 		context->oformat = format;
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 		if (filename.size() + 1 > sizeof(context->filename)) {
+ 			synfig::error(
+ 				"Target_LibAVCodec: filename too long, max length is %d, filename is '%s'",
+@@ -263,6 +271,14 @@
+ 			return false;
+ 		}
+ 		memcpy(context->filename, filename.c_str(), filename.size() + 1);
++#else
++		context->url = av_strndup(filename.c_str(), filename.size());
++		if (!context->url) {
++			synfig::error("Target_LibAVCodec: cannot allocate space for filename");
++			close();
++			return false;
++		}
++#endif
+ 
+ 		packet = av_packet_alloc();
+ 		assert(packet);
diff --git a/srcpkgs/synfig/template b/srcpkgs/synfig/template
index d4d3e341a20bf8..828b5cb32956ee 100644
--- a/srcpkgs/synfig/template
+++ b/srcpkgs/synfig/template
@@ -2,11 +2,11 @@
 # Should be kept in sync with 'synfigstudio' and 'ETL'
 pkgname=synfig
 version=1.4.4
-revision=4
+revision=5
 build_style=gnu-configure
 configure_args="--with-boost-libdir=${XBPS_CROSS_BASE}/usr/lib"
 hostmakedepends="boost-build ImageMagick pkg-config intltool"
-makedepends="ETL gettext-devel libxml++-devel mlt-devel libmagick-devel
+makedepends="ETL gettext-devel libxml++-devel mlt7-devel libmagick-devel
  libmng-devel boost-build boost-devel libopenexr-devel ffmpeg-devel"
 depends="ImageMagick"
 short_desc="CLI 2D vector and timeline-based animation software"
@@ -20,7 +20,7 @@ CXXFLAGS="-std=c++11 -DHAVE_LOCALE_H=1"
 
 synfig-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision}
-	 libopenexr-devel libxml++-devel mlt-devel"
+	 libopenexr-devel libxml++-devel mlt7-devel"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/bin/synfig-config

From 3b698882077def38a4b8c22942666ca0bf59c737 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 065/110] timg: revbump for ffmpeg6

---
 srcpkgs/timg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/timg/template b/srcpkgs/timg/template
index 2a2ab763d2fddf..8fb4327535ef93 100644
--- a/srcpkgs/timg/template
+++ b/srcpkgs/timg/template
@@ -1,7 +1,7 @@
 # Template file for 'timg'
 pkgname=timg
 version=1.4.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_OPENSLIDE_SUPPORT=off -Wno-dev"
 hostmakedepends="pkg-config git"

From 966e2d27537622bb724271b52ab50e6986f1f69e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 066/110] tvheadend: revbump for ffmpeg4

---
 srcpkgs/tvheadend/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tvheadend/template b/srcpkgs/tvheadend/template
index 9aea7de4ec7057..012d31c4879ff1 100644
--- a/srcpkgs/tvheadend/template
+++ b/srcpkgs/tvheadend/template
@@ -8,7 +8,7 @@ configure_args="--enable-dvbscan --disable-ffmpeg_static
 --disable-libx265_static --disable-libvpx_static --disable-libtheora_static
 --disable-libvorbis_static --disable-libfdkaac_static"
 hostmakedepends="gettext pkg-config python3 git which"
-makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg-devel"
+makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg4-devel"
 short_desc="TV streaming server"
 maintainer="lemmi <lemmi@nerd2nerd.org>"
 license="GPL-3.0-only"

From 05c0a66c937ab4fbe5ece4c552513bc2bd8006d3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 067/110] unpaper: update to 7.0.0.

---
 srcpkgs/unpaper/template | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/srcpkgs/unpaper/template b/srcpkgs/unpaper/template
index 38ed47a5840165..1ff910e722afc8 100644
--- a/srcpkgs/unpaper/template
+++ b/srcpkgs/unpaper/template
@@ -1,13 +1,13 @@
 # Template file for 'unpaper'
 pkgname=unpaper
-version=6.1
-revision=3
-build_style=gnu-configure
+version=7.0.0
+revision=1
+build_style=meson
+hostmakedepends="pkg-config meson libxslt"
+makedepends="ffmpeg-devel python3-Sphinx"
+short_desc="Post-processing tool for scanned sheets of paper"
 maintainer="Orphaned <orphan@voidlinux.org>"
-hostmakedepends="pkg-config libxslt"
-makedepends="ffmpeg-devel"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://www.flameeyes.eu/projects/unpaper"
-short_desc="A post-processing tool for scanned sheets of paper"
 distfiles="https://www.flameeyes.eu/files/${pkgname}-${version}.tar.xz"
-checksum=237c84f5da544b3f7709827f9f12c37c346cdf029b1128fb4633f9bafa5cb930
+checksum=2575fbbf26c22719d1cb882b59602c9900c7f747118ac130883f63419be46a80

From 10c801eec931251d14595cd6bb59dfd694197f7a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 068/110] vice: revbump for ffmpeg4

---
 srcpkgs/vice/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/vice/template b/srcpkgs/vice/template
index b1f866d35095e7..43f79243a1da11 100644
--- a/srcpkgs/vice/template
+++ b/srcpkgs/vice/template
@@ -1,7 +1,7 @@
 # Template file for 'vice'
 pkgname=vice
 version=3.7.1
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="
 	$(vopt_enable sdl2 sdlui2)
@@ -26,7 +26,7 @@ makedepends="
 	$(vopt_if gtk3 gtk+3-devel)
 	$(vopt_if gtk3 pulseaudio-devel)
 	$(vopt_if gtk3 pango-devel)
-	$(vopt_if ffmpeg ffmpeg-devel)"
+	$(vopt_if ffmpeg ffmpeg4-devel)"
 short_desc="Emulator for C64, C128, CBM-II, PET, VIC20, Plus4 and C16"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"

From 4b9cde260dfe1804ebf228b4d839eeae0e01c4d4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 069/110] waypipe: revbump for ffmpeg6

---
 srcpkgs/waypipe/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waypipe/template b/srcpkgs/waypipe/template
index 6da88b21bf2a19..4da8058400b588 100644
--- a/srcpkgs/waypipe/template
+++ b/srcpkgs/waypipe/template
@@ -1,7 +1,7 @@
 # Template file for 'waypipe'
 pkgname=waypipe
 version=0.8.6
-revision=1
+revision=2
 build_style=meson
 # lto is off because it causes linking errors in armv6l and armv7l (due to NEON)
 configure_args="-Dwerror=false -Dwith_dmabuf=enabled -Dwith_lz4=enabled

From 520ba80163b4e6f07ae605955cd28c54bce6b34f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 070/110] xpra: revbump for ffmpeg6

---
 srcpkgs/xpra/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xpra/template b/srcpkgs/xpra/template
index 3e49ab23deac9c..3939026a6fbf90 100644
--- a/srcpkgs/xpra/template
+++ b/srcpkgs/xpra/template
@@ -1,7 +1,7 @@
 # Template file for 'xpra'
 pkgname=xpra
 version=5.0.7
-revision=1
+revision=2
 build_style=python3-module
 make_build_args="--without-cuda_kernels --without-cuda_rebuild"
 make_install_args="$(vopt_with docs) ${make_build_args}"

From 9e7eafc6bbbbacf2130edcd2fd184c492a4b5cc3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:07:40 -0400
Subject: [PATCH 071/110] nv-codec-headers: update to 12.0.16.0

---
 srcpkgs/nv-codec-headers/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/nv-codec-headers/template b/srcpkgs/nv-codec-headers/template
index 3d422a61e48917..251e057f826fb8 100644
--- a/srcpkgs/nv-codec-headers/template
+++ b/srcpkgs/nv-codec-headers/template
@@ -1,6 +1,6 @@
 # Template file for 'nv-codec-headers'
 pkgname=nv-codec-headers
-version=11.1.5.1
+version=12.0.16.0
 revision=1
 build_style=gnu-makefile
 short_desc="FFmpeg version of headers required to interface with Nvidias codec APIs"
@@ -8,7 +8,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="MIT"
 homepage="http://git.videolan.org/?p=ffmpeg/nv-codec-headers.git"
 distfiles="https://github.com/FFmpeg/nv-codec-headers/archive/n${version}.tar.gz"
-checksum=d095fbd56aa93772471a323be0ebe65504a0f43f06c76a30b6d25da77b06ae9c
+checksum=2a1533b65f55f9da52956faf0627ed3b74868ac0c7f269990edd21369113b48f
 
 post_install() {
 	sed -n '4,25p' include/ffnvcodec/nvEncodeAPI.h > LICENSE

From cd6a93c20a107fa719c7ce337667731e4929df1a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:08:40 -0400
Subject: [PATCH 072/110] openimagedenoise: revbump for ffmpeg6

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index 109deb171c3f75..44edf38fb289d8 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,7 +1,7 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
 version=1.4.3
-revision=2
+revision=3
 archs="x86_64*"
 build_style=cmake
 hostmakedepends="ispc python3"

From 49467684505c65b6f10c274c3992300f8b219735 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:31:45 -0400
Subject: [PATCH 073/110] shotcut: revbump for ffmpeg6

---
 srcpkgs/shotcut/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/shotcut/template b/srcpkgs/shotcut/template
index 33141fbd862d7a..f46cb53b6bfb92 100644
--- a/srcpkgs/shotcut/template
+++ b/srcpkgs/shotcut/template
@@ -1,7 +1,7 @@
 # Template file for 'shotcut'
 pkgname=shotcut
 version=23.09.29
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSHOTCUT_VERSION=${version}"
 hostmakedepends="pkg-config qt6-tools-devel"

From 65f694a9fb89014dc04e27327ddf879f52a75acd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:30 -0400
Subject: [PATCH 074/110] shiboken2: revbump for qt5-5.15.11

---
 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch | 1 +
 1 file changed, 1 insertion(+)
 create mode 120000 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
new file mode 120000
index 00000000000000..efcf3249bd8854
--- /dev/null
+++ b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1 @@
+../../python3-pyside2/patches/importlib-machinery-bypass.patch
\ No newline at end of file

From bcc485cb3e979ec6c60d3f2c7e4a4f0658cf1ebc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:53 -0400
Subject: [PATCH 075/110] python3-pyside2: revbump for qt5-5.15.11

---
 .../patches/importlib-machinery-bypass.patch      | 15 +++++++++++++++
 srcpkgs/python3-pyside2/template                  |  2 +-
 2 files changed, 16 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
new file mode 100644
index 00000000000000..64c429584776b5
--- /dev/null
+++ b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1,15 @@
+Using this prevents an error around line 220 below it.
+"AttributeError: module 'importlib' has no attribute 'machinery'"
+The old backup logic is in place and compiles without issues.
+--- a/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:09:34.688912402 -0400
++++ b/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:10:03.395529582 -0400
+@@ -170,9 +170,6 @@
+
+     # 'zipstring_sequence' comes from signature.cpp
+     zipbytes = base64.b64decode(''.join(zipstring_sequence))
+-    if sys.version_info[0] >= 3:
+-        vzip = zipfile.ZipFile(io.BytesIO(zipbytes))
+-        return sys.meta_path, EmbeddableZipImporter(vzip)
+
+     # Old version for Python 2.7, only.
+     import os
diff --git a/srcpkgs/python3-pyside2/template b/srcpkgs/python3-pyside2/template
index 249efa90988425..52626436ce75f2 100644
--- a/srcpkgs/python3-pyside2/template
+++ b/srcpkgs/python3-pyside2/template
@@ -1,7 +1,7 @@
 # Template file for 'python3-pyside2'
 pkgname=python3-pyside2
 version=5.15.10
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/pyside2"
 build_style=cmake

From fb5d1c58bca89a07ccfd7c805115cd7a59a92dc9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:35 -0400
Subject: [PATCH 076/110] konqueror: revbump for ffmpeg6

---
 srcpkgs/konqueror/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/konqueror/template b/srcpkgs/konqueror/template
index add972916753c6..50bbf4eec05e55 100644
--- a/srcpkgs/konqueror/template
+++ b/srcpkgs/konqueror/template
@@ -1,11 +1,11 @@
 # Template file for 'konqueror'
 pkgname=konqueror
 version=23.08.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DDESKTOPTOJSON_EXECUTABLE=/usr/bin/desktoptojson"
 hostmakedepends="extra-cmake-modules python3 qt5-host-tools qt5-qmake kdoctools
-kcoreaddons kconfig gettext"
+ kcoreaddons kconfig gettext"
 makedepends="qt5-devel qt5-webengine-devel qt5-declarative-devel
  qt5-webchannel-devel qt5-location-devel kcmutils-devel kdelibs4support-devel
  karchive-devel khtml-devel kdesu-devel kactivities5-devel"

From b57c54434447acff8d8f65eee909f9a8dc544886 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:58 -0400
Subject: [PATCH 077/110] qt5-speech: revbump for qt5-5.15.11

---
 srcpkgs/qt5-speech/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-speech/template b/srcpkgs/qt5-speech/template
index 1228bb60c41db4..27a7da1dbdb91b 100644
--- a/srcpkgs/qt5-speech/template
+++ b/srcpkgs/qt5-speech/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-speech'
 pkgname=qt5-speech
 version=5.15.11
-revision=1
+revision=2
 _commit=d32f4a479d38a11f547598004b975f4356424a16
 build_style=qmake
 configure_args="-- -flite -flite-alsa -speechd"

From 7dd182b44f2aa5bd01d20cafd5647c3077e0c08c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Jun 2023 08:20:22 -0400
Subject: [PATCH 078/110] gtk4: revbump for ffmpeg6

---
 srcpkgs/gtk4/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gtk4/template b/srcpkgs/gtk4/template
index 3f2554ea3bc940..da41e85ec329c3 100644
--- a/srcpkgs/gtk4/template
+++ b/srcpkgs/gtk4/template
@@ -1,7 +1,7 @@
 # Template file for 'gtk4'
 pkgname=gtk4
 version=4.12.5
-revision=1
+revision=2
 build_style=meson
 build_helper="gir"
 configure_args="-Dman-pages=true -Ddocumentation=true -Dbuild-tests=false

From 9b931ecf2464909d503463ab6aaea6ef7955fbf8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:28:26 -0400
Subject: [PATCH 079/110] siril: revbump for ffmpeg6

---
 srcpkgs/siril/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/siril/template b/srcpkgs/siril/template
index 84332f79d060d2..62750dd247548f 100644
--- a/srcpkgs/siril/template
+++ b/srcpkgs/siril/template
@@ -1,7 +1,7 @@
 # Template file for 'siril'
 pkgname=siril
 version=0.9.12
-revision=10
+revision=11
 build_style=gnu-configure
 hostmakedepends="pkg-config intltool autoconf automake gettext-devel"
 makedepends="fftw-devel libconfig-devel libopencv-devel libffms2-devel

From c5e61988bff2fcaa63e4361b60d63c53dc3aa949 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 22 Jun 2023 10:25:02 -0400
Subject: [PATCH 080/110] kdenlive: revbump for ffmpeg6

---
 srcpkgs/kdenlive/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kdenlive/template b/srcpkgs/kdenlive/template
index ecb48dfc74d29d..a3476d0b876b10 100644
--- a/srcpkgs/kdenlive/template
+++ b/srcpkgs/kdenlive/template
@@ -1,7 +1,7 @@
 # Template file for 'kdenlive'
 pkgname=kdenlive
 version=23.08.5
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="
  extra-cmake-modules kconfig kcoreaddons kdoctools pkg-config python3

From 33b1cc77a5be2b37a90133d1c0033989a585796f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:20:59 -0400
Subject: [PATCH 081/110] tracker-miners: revbump for ffmpeg6

---
 srcpkgs/tracker-miners/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tracker-miners/template b/srcpkgs/tracker-miners/template
index 0b97f47489f817..f196d2bf9e4a4c 100644
--- a/srcpkgs/tracker-miners/template
+++ b/srcpkgs/tracker-miners/template
@@ -1,7 +1,7 @@
 # Template file for 'tracker-miners'
 pkgname=tracker-miners
 version=3.6.1
-revision=1
+revision=2
 build_style=meson
 build_helper=qemu
 # missing libgrss for miner_rss

From acd5dc3515d4c8c5b066bf4b2249aae5a86d2c6e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:21:21 -0400
Subject: [PATCH 082/110] mpd: revbump for ffmpeg6

---
 srcpkgs/mpd/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpd/template b/srcpkgs/mpd/template
index 4fd32b7be8c537..b8e2bd4c1b59c8 100644
--- a/srcpkgs/mpd/template
+++ b/srcpkgs/mpd/template
@@ -1,7 +1,7 @@
 # Template file for 'mpd'
 pkgname=mpd
 version=0.23.15
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dopus=enabled -Dmikmod=enabled -Dneighbor=true
  -Dsoundcloud=enabled -Dpipe=true -Dtwolame=enabled -Dbzip2=enabled

From 02aa2687ce2a1f4bd0d81914df9d52c8148cad1a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:02 -0400
Subject: [PATCH 083/110] tg_owt: revbump for ffmpeg6

---
 srcpkgs/tg_owt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tg_owt/template b/srcpkgs/tg_owt/template
index 34e8fef0540569..1a46a8bedf3473 100644
--- a/srcpkgs/tg_owt/template
+++ b/srcpkgs/tg_owt/template
@@ -1,7 +1,7 @@
 # Template file for 'tg_owt'
 pkgname=tg_owt
 version=0.0.0.20231221
-revision=2
+revision=3
 _commit=afd9d5d31798d3eacf9ed6c30601e91d0f1e4d60
 _libyuv_commit=04821d1e7d60845525e8db55c7bcd41ef5be9406
 _abseil_commit=8c0b94e793a66495e0b1f34a5eb26bd7dc672db0

From 0b085f0f8eeee64a45394577c08bf732d8d80179 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:44 -0400
Subject: [PATCH 084/110] telegram-desktop: revbump for ffmpeg6

---
 srcpkgs/telegram-desktop/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/telegram-desktop/template b/srcpkgs/telegram-desktop/template
index 6dc6a553cfcec8..cf85a731370062 100644
--- a/srcpkgs/telegram-desktop/template
+++ b/srcpkgs/telegram-desktop/template
@@ -1,7 +1,7 @@
 # Template file for 'telegram-desktop'
 pkgname=telegram-desktop
 version=4.14.15
-revision=3
+revision=4
 build_style=cmake
 build_helper="qemu gir"
 configure_args="-DTDESKTOP_API_ID=209235

From 33b2bb25e723c1a751c8b7d17b08ae8ec0da35ec Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:12:09 -0400
Subject: [PATCH 085/110] openmw: revbump for ffmpeg6

---
 srcpkgs/openmw/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openmw/template b/srcpkgs/openmw/template
index 0abf5ff7cdbecc..b57180f1a4446f 100644
--- a/srcpkgs/openmw/template
+++ b/srcpkgs/openmw/template
@@ -1,7 +1,7 @@
 # Template file for 'openmw'
 pkgname=openmw
 version=0.48.0
-revision=2
+revision=3
 build_style=cmake
 _recast_commit=e75adf86f91eb3082220085e42dda62679f9a3ea
 _bullet_tag=3.17

From 89a2858c52ad8122d6a70953e938ad12605b1b36 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:14:53 -0400
Subject: [PATCH 086/110] lms: revbump for ffmpeg6

---
 srcpkgs/lms/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/lms/template b/srcpkgs/lms/template
index e358f75902a986..3b21c458de5199 100644
--- a/srcpkgs/lms/template
+++ b/srcpkgs/lms/template
@@ -1,7 +1,7 @@
 # Template file for 'lms'
 pkgname=lms
 version=3.42.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="wt-devel ffmpeg-devel boost-devel libconfig++-devel taglib-devel pam-devel libgraphicsmagick-devel gtest-devel libarchive-devel"

From 7016a5498731ffd3816cf22312e9389b1ee5039c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:18:18 -0400
Subject: [PATCH 087/110] freecad: DELETE

---
 srcpkgs/freecad/patches/001-include.patch     | 112 ------------------
 .../154-revert-gui-tmp-redirect-stderr.patch  |  68 -----------
 ...d63c8c9b1280978be841d04e68a0a55cceb9.patch |  30 -----
 srcpkgs/freecad/template                      |  12 +-
 4 files changed, 7 insertions(+), 215 deletions(-)
 delete mode 100644 srcpkgs/freecad/patches/001-include.patch
 delete mode 100644 srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
 delete mode 100644 srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch

diff --git a/srcpkgs/freecad/patches/001-include.patch b/srcpkgs/freecad/patches/001-include.patch
deleted file mode 100644
index 28b5af54999b96..00000000000000
--- a/srcpkgs/freecad/patches/001-include.patch
+++ /dev/null
@@ -1,112 +0,0 @@
-From 9a41845a417189776741297c50a3827ce292bc4f Mon Sep 17 00:00:00 2001
-From: Uwe <donovaly@users.noreply.github.com>
-Date: Sun, 3 Jul 2022 22:51:16 +0200
-Subject: [PATCH] [Part] OCCError.h: remove unneeded includes
-
-- also sort includes
----
- src/Mod/Part/App/OCCError.h             | 36 +++----------------------
- src/Mod/Part/App/OffsetCurvePyImp.cpp   | 12 ++++-----
- src/Mod/Part/App/OffsetSurfacePyImp.cpp | 10 +++----
- 3 files changed, 12 insertions(+), 46 deletions(-)
-
---- a/src/Mod/Part/App/OCCError.h
-+++ b/src/Mod/Part/App/OCCError.h
-@@ -23,36 +23,8 @@
- #ifndef _OCCError_h_
- #define _OCCError_h_
- 
--# include <Standard_Version.hxx>
- # include <Standard_Failure.hxx>
--# include <Standard_AbortiveTransaction.hxx>
--# include <Standard_ConstructionError.hxx>
--# if OCC_VERSION_HEX >= 0x060500
--# include <Standard_DefineException.hxx>
--# endif
--# include <Standard_DimensionError.hxx>
--# include <Standard_DimensionMismatch.hxx>
--# include <Standard_DivideByZero.hxx>
--# include <Standard_DomainError.hxx>
--# include <Standard_ImmutableObject.hxx>
--# include <Standard_LicenseError.hxx>
--# include <Standard_LicenseNotFound.hxx>
--# include <Standard_MultiplyDefined.hxx>
--# include <Standard_NegativeValue.hxx>
--# include <Standard_NoMoreObject.hxx>
--# include <Standard_NoSuchObject.hxx>
--# include <Standard_NotImplemented.hxx>
--# include <Standard_NullObject.hxx>
--# include <Standard_NullValue.hxx>
--# include <Standard_NumericError.hxx>
--# include <Standard_OutOfMemory.hxx>
--# include <Standard_OutOfRange.hxx>
--# include <Standard_Overflow.hxx>
--# include <Standard_ProgramError.hxx>
--# include <Standard_RangeError.hxx>
--# include <Standard_TooManyUsers.hxx>
--# include <Standard_TypeMismatch.hxx>
--# include <Standard_Underflow.hxx>
-+# include <Standard_Version.hxx>
- 
- #include <Mod/Part/PartGlobal.h>
- #include <Base/Console.h>
-@@ -88,4 +60,3 @@ PartExport extern PyObject* PartExceptio
- 
- #define PY_CATCH_OCC _PY_CATCH_OCC(return(NULL))
- #endif  // _OCCError_h_
--
---- a/src/Mod/Part/App/OffsetCurvePyImp.cpp
-+++ b/src/Mod/Part/App/OffsetCurvePyImp.cpp
-@@ -20,20 +20,20 @@
-  *                                                                         *
-  ***************************************************************************/
- 
--
- #include "PreCompiled.h"
- #ifndef _PreComp_
- # include <Geom_OffsetCurve.hxx>
- #endif
- 
--#include "OCCError.h"
--#include "Geometry.h"
-+#include <Base/GeometryPyCXX.h>
-+#include <Base/Vector3D.h>
-+#include <Base/VectorPy.h>
-+
- #include "OffsetCurvePy.h"
- #include "OffsetCurvePy.cpp"
-+#include "Geometry.h"
-+#include "OCCError.h"
- 
--#include <Base/GeometryPyCXX.h>
--#include <Base/VectorPy.h>
--#include <Base/Vector3D.h>
- 
- using namespace Part;
- 
---- a/src/Mod/Part/App/OffsetSurfacePyImp.cpp
-+++ b/src/Mod/Part/App/OffsetSurfacePyImp.cpp
-@@ -20,20 +20,16 @@
-  *                                                                         *
-  ***************************************************************************/
- 
--
- #include "PreCompiled.h"
- #ifndef _PreComp_
- # include <Geom_OffsetSurface.hxx>
- # include <memory>
- #endif
- 
--#include <Base/VectorPy.h>
--#include <Base/Vector3D.h>
--
- #include "OCCError.h"
--#include "Geometry.h"
--#include <Mod/Part/App/OffsetSurfacePy.h>
--#include <Mod/Part/App/OffsetSurfacePy.cpp>
-+#include "OffsetSurfacePy.h"
-+#include "OffsetSurfacePy.cpp"
-+
- 
- using namespace Part;
- 
diff --git a/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch b/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
deleted file mode 100644
index d6a9adabdec830..00000000000000
--- a/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
+++ /dev/null
@@ -1,68 +0,0 @@
-see https://github.com/FreeCAD/FreeCAD/commit/cfe94b00d3434f3e2c8b5114d2909f628c330fa8#commitcomment-71413407
-
-upstream: yes
-
-From 7b377a216b9185960e4cee980a6504dc1a755f50 Mon Sep 17 00:00:00 2001
-From: wmayer <wmayer@users.sourceforge.net>
-Date: Wed, 29 Jun 2022 15:19:18 +0200
-Subject: [PATCH] Gui: remove workaround for spnav 0.23 due to build failure
- with musl libc
-
----
- src/Gui/3Dconnexion/GuiNativeEventLinux.cpp | 27 ---------------------
- 1 file changed, 27 deletions(-)
-
---- a/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp
-+++ b/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp
-@@ -21,42 +21,17 @@
-  ***************************************************************************/
- 
- #include <FCConfig.h>
--#include <cstdio>
- 
- #include "GuiNativeEventLinux.h"
- 
- #include "GuiApplicationNativeEventAware.h"
- #include <Base/Console.h>
--#include <Base/FileInfo.h>
- #include <QMainWindow>
- 
- #include <QSocketNotifier>
- 
- #include <spnav.h>
- 
--namespace {
--class RedirectStdErr
--{
--public:
--    RedirectStdErr()
--        : fi(Base::FileInfo::getTempFileName())
--        , file(stderr)
--    {
--        stderr = fopen(fi.filePath().c_str(), "w");
--    }
--    ~RedirectStdErr()
--    {
--        fclose(stderr);
--        fi.deleteFile();
--        stderr = file;
--    }
--
--private:
--    Base::FileInfo fi;
--    FILE* file;
--};
--}
--
- Gui::GuiNativeEvent::GuiNativeEvent(Gui::GUIApplicationNativeEventAware *app)
- : GuiAbstractNativeEvent(app)
- {
-@@ -72,8 +47,6 @@ Gui::GuiNativeEvent::~GuiNativeEvent()
- 
- void Gui::GuiNativeEvent::initSpaceball(QMainWindow *window)
- {
--    // tmp. redirect stderr to a file to suppress an error message from spnav_open()
--    RedirectStdErr err;
-     Q_UNUSED(window)
-     if (spnav_open() == -1) {
-         Base::Console().Log("Couldn't connect to spacenav daemon. Please ignore if you don't have a spacemouse.\n");
diff --git a/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch b/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch
deleted file mode 100644
index d4acf370ca0a42..00000000000000
--- a/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-From fe02d63c8c9b1280978be841d04e68a0a55cceb9 Mon Sep 17 00:00:00 2001
-From: Roy-043 <70520633+Roy-043@users.noreply.github.com>
-Date: Thu, 29 Dec 2022 23:20:38 +0100
-Subject: [PATCH] Draft: update inspect.getargspec to inspect.getfullargspec
- (#8101)
-
----
- src/Mod/Draft/draftguitools/gui_snapper.py | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
---- a/src/Mod/Draft/draftguitools/gui_snapper.py
-+++ b/src/Mod/Draft/draftguitools/gui_snapper.py
-@@ -1426,7 +1426,7 @@ class Snapper:
-             Gui.Snapper.off()
-             self.ui.offUi()
-             if callback:
--                if len(inspect.getargspec(callback).args) > 1:
-+                if len(inspect.getfullargspec(callback).args) > 1:
-                     obj = None
-                     if self.snapInfo and ("Object" in self.snapInfo) and self.snapInfo["Object"]:
-                         obj = App.ActiveDocument.getObject(self.snapInfo["Object"])
-@@ -1445,7 +1445,7 @@ class Snapper:
-             Gui.Snapper.off()
-             self.ui.offUi()
-             if callback:
--                if len(inspect.getargspec(callback).args) > 1:
-+                if len(inspect.getfullargspec(callback).args) > 1:
-                     callback(None, None)
-                 else:
-                     callback(None)
diff --git a/srcpkgs/freecad/template b/srcpkgs/freecad/template
index c135701e38b9ad..7d5165f760bab9 100644
--- a/srcpkgs/freecad/template
+++ b/srcpkgs/freecad/template
@@ -1,7 +1,7 @@
 # Template file for 'freecad'
 pkgname=freecad
-version=0.20.2
-revision=7
+version=0.21.1
+revision=2
 build_wrksrc="FreeCAD-${version}"
 build_style=cmake
 pycompile_dirs="usr/lib/${pkgname}/Mod"
@@ -24,8 +24,10 @@ makedepends="python3-devel boost-devel libxerces-c-devel zlib-devel occt-devel
  coin3-devel libshiboken2-devel libspnav-devel pyside2-tools
  liblz4-devel libpyside2-python3-devel python3-matplotlib netcdf-devel
  jsoncpp-devel qt5-devel qt5-svg-devel qt5-tools-devel qt5-webkit-devel
- qt5-xmlpatterns-devel coin3-doc glew-devel python3-pivy"
-depends="python3-matplotlib python3-pyside2-webengine python3-pivy"
+ qt5-xmlpatterns-devel coin3-doc glew-devel python3-pivy qt5-webengine-devel
+ qt5-declarative-devel qt5-webchannel-devel qt5-location-devel"
+depends="python3-matplotlib python3-pyside2-webengine python3-pivy
+ python3-GitPython python3-Markdown"
 short_desc="General purpose 3D CAD modeler"
 maintainer="yopito <pierre.bourgin@free.fr>"
 license="LGPL-2.0-or-later"
@@ -35,7 +37,7 @@ distfiles="
  https://github.com/FreeCAD/FreeCAD/archive/${version}.tar.gz
  ${SOURCEFORGE_SITE}/cxx/pycxx-${_pycxxver}.tar.gz
 "
-checksum="46922f3a477e742e1a89cd5346692d63aebb2b67af887b3e463e094a4ae055da
+checksum="e9b1fd0323f101268c7f3be52db42e4a29222f2e306ae6c4a6fc309cb418d35a
  4b91e1e1141c23fbd5039df635c4bb6e75632168548f56b83ce177193c0c98c6"
 python_version=3
 patch_args="-Np1 -d ${build_wrksrc}"

From 6f6d94922ceaec83935a26850e3960edb2b81fc3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:47:18 -0400
Subject: [PATCH 088/110] libopenshot: revbump for ffmpeg6

---
 srcpkgs/libopenshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenshot/template b/srcpkgs/libopenshot/template
index 8e57c5f592169c..7a8f4520e78925 100644
--- a/srcpkgs/libopenshot/template
+++ b/srcpkgs/libopenshot/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenshot'
 pkgname=libopenshot
 version=0.3.0
-revision=3
+revision=4
 build_style=cmake
 # Builds fail with Ruby-2.4.1
 configure_args="-DENABLE_RUBY=OFF -DUSE_SYSTEM_JSONCPP=ON"

From c5ec97a20676c94dcec4c07d7184edc57430758e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:10:30 -0500
Subject: [PATCH 089/110] openimageio: revbump for ffmpeg6

---
 srcpkgs/openimageio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimageio/template b/srcpkgs/openimageio/template
index 27d2131bc0a61a..61f44b43f9083e 100644
--- a/srcpkgs/openimageio/template
+++ b/srcpkgs/openimageio/template
@@ -1,7 +1,7 @@
 # Template file for 'openimageio'
 pkgname=openimageio
 version=2.4.9.0
-revision=8
+revision=9
 build_style=cmake
 build_helper=qemu
 configure_args="-DUSE_QT=0 -DUSE_PYTHON=0 -DOIIO_BUILD_TESTS=0

From b533df73aed86b5ba35156354268d96a0bb8a81a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:11:57 -0500
Subject: [PATCH 090/110] synfigstudio: revbump for ffmpeg6

---
 srcpkgs/synfigstudio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/synfigstudio/template b/srcpkgs/synfigstudio/template
index 09e442da9a6805..2bc017cedca6b8 100644
--- a/srcpkgs/synfigstudio/template
+++ b/srcpkgs/synfigstudio/template
@@ -2,7 +2,7 @@
 # Should be kept in sync with 'synfig' and 'ETL'
 pkgname=synfigstudio
 version=1.4.4
-revision=4
+revision=5
 build_style=gnu-configure
 configure_args="--disable-update-mimedb"
 hostmakedepends="pkg-config intltool gettext synfig"

From 846dfe049ac89479b24253b4a3f6ac262b02e33e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:10 -0500
Subject: [PATCH 091/110] mixxx: revbump for ffmpeg6

---
 srcpkgs/mixxx/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mixxx/template b/srcpkgs/mixxx/template
index 6a79b328c1abf0..9a5141856860b9 100644
--- a/srcpkgs/mixxx/template
+++ b/srcpkgs/mixxx/template
@@ -1,7 +1,7 @@
 # Template file for 'mixxx'
 pkgname=mixxx
 version=2.3.3
-revision=7
+revision=8
 build_style=cmake
 configure_args="-DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="extra-cmake-modules pkg-config protobuf qt5-host-tools qt5-qmake"

From de5c8ab08f896bb1087abcff5e822f72ddad0511 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:28 -0500
Subject: [PATCH 092/110] musikcube: revbump for ffmpeg6

---
 srcpkgs/musikcube/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/musikcube/template b/srcpkgs/musikcube/template
index 8c4a51840859ec..fb60dd2049089a 100644
--- a/srcpkgs/musikcube/template
+++ b/srcpkgs/musikcube/template
@@ -1,7 +1,7 @@
 # Template file for 'musikcube'
 pkgname=musikcube
 version=3.0.0
-revision=3
+revision=4
 build_style=cmake
 make_cmd=make
 configure_args="-DNO_NCURSESW=1"

From a6251c603df6fe3e5300b6e352a4ee443418adef Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:45 -0500
Subject: [PATCH 093/110] electron24: revbump for ffmpeg6

---
 srcpkgs/electron24/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron24/template b/srcpkgs/electron24/template
index 7b4e28812f483e..1ca93fde97a854 100644
--- a/srcpkgs/electron24/template
+++ b/srcpkgs/electron24/template
@@ -1,7 +1,7 @@
 # Template file for 'electron24'
 pkgname=electron24
 version=24.3.0
-revision=2
+revision=3
 _nodever=18.14.0
 _chromiumver=112.0.5615.165
 archs="x86_64* aarch64*"

From 378f0099196feb32ead22a1513d439786f9ed977 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:00 -0500
Subject: [PATCH 094/110] electron19: revbump for ffmpeg6

---
 srcpkgs/electron19/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron19/template b/srcpkgs/electron19/template
index 0ef959125cb085..5371c0b354604f 100644
--- a/srcpkgs/electron19/template
+++ b/srcpkgs/electron19/template
@@ -1,7 +1,7 @@
 # Template file for 'electron19'
 pkgname=electron19
 version=19.0.8
-revision=4
+revision=5
 _nodever=16.14.2
 _chromiumver=102.0.5005.125
 archs="x86_64* aarch64* ppc64le*"

From 4e597af526cdbbf299966e9ceac5f3d20fe75e18 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:13 -0500
Subject: [PATCH 095/110] wf-recorder: revbump for ffmpeg6

---
 srcpkgs/wf-recorder/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/wf-recorder/template b/srcpkgs/wf-recorder/template
index 08f986b0310067..63c45cf4b814d7 100644
--- a/srcpkgs/wf-recorder/template
+++ b/srcpkgs/wf-recorder/template
@@ -1,7 +1,7 @@
 # Template file for 'wf-recorder'
 pkgname=wf-recorder
 version=0.4.1
-revision=2
+revision=3
 build_style=meson
 hostmakedepends="pkg-config scdoc wayland-devel"
 makedepends="wayland-protocols wayland-devel ffmpeg-devel libgbm-devel x264-devel

From f07031fc74267050e3dd4349820cfbf48d26ac75 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:26 -0500
Subject: [PATCH 096/110] obs: revbump for ffmpeg6

---
 srcpkgs/obs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/obs/template b/srcpkgs/obs/template
index b343f1131bfcf6..a25a67433e285e 100644
--- a/srcpkgs/obs/template
+++ b/srcpkgs/obs/template
@@ -1,7 +1,7 @@
 # Template file for 'obs'
 pkgname=obs
 version=30.0.0
-revision=2
+revision=3
 archs="i686* x86_64* ppc64le* aarch64* riscv64*"
 build_style=cmake
 configure_args="-DOBS_VERSION_OVERRIDE=${version} -DENABLE_JACK=ON

From b3cbb407c7c8fd47dce3cc8ca7e787173b1deb16 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:36 -0500
Subject: [PATCH 097/110] mlt7: revbump for ffmpeg6

---
 srcpkgs/mlt7/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mlt7/template b/srcpkgs/mlt7/template
index 98f302ad3a5167..7eb8c00fa1580c 100644
--- a/srcpkgs/mlt7/template
+++ b/srcpkgs/mlt7/template
@@ -1,7 +1,7 @@
 # Template file for 'mlt7'
 pkgname=mlt7
 version=7.20.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DSWIG_PYTHON=ON -DMOD_QT6=ON"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which

From a31a53a61d286de7e98de14036570cdb14f22101 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:48 -0500
Subject: [PATCH 098/110] qt6-multimedia: revbump for ffmpeg6

---
 srcpkgs/qt6-multimedia/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-multimedia/template b/srcpkgs/qt6-multimedia/template
index 67a577e1300fea..1da626ecf515a8 100644
--- a/srcpkgs/qt6-multimedia/template
+++ b/srcpkgs/qt6-multimedia/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-multimedia'
 pkgname=qt6-multimedia
 version=6.6.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DQT_FEATURE_gstreamer=ON"
 hostmakedepends="perl qt6-declarative-host-tools pkg-config qt6-shadertools"

From 1da23653b98be9843b30a5aabe72dc237ee8f261 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:00:15 -0500
Subject: [PATCH 099/110] baresip: revbump for ffmpeg6

---
 srcpkgs/baresip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/baresip/template b/srcpkgs/baresip/template
index b16b67beab8d2b..fe21ebf40c03c1 100644
--- a/srcpkgs/baresip/template
+++ b/srcpkgs/baresip/template
@@ -1,7 +1,7 @@
 # Template file for 'baresip'
 pkgname=baresip
 version=3.6.0
-revision=3
+revision=4
 build_style=cmake
 hostmakedepends="pkg-config glib-devel"
 makedepends="libgsm-devel libpng-devel openssl-devel libsndfile-devel

From e2bfdc5300ccad313eb1702f7ebb2a1674d13529 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:30 -0500
Subject: [PATCH 100/110] QMPlay2: revbump for ffmpeg6

---
 srcpkgs/QMPlay2/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/QMPlay2/template b/srcpkgs/QMPlay2/template
index 46c80f64a13497..942258ce60fb7e 100644
--- a/srcpkgs/QMPlay2/template
+++ b/srcpkgs/QMPlay2/template
@@ -1,7 +1,7 @@
 # Template file for 'QMPlay2'
 pkgname=QMPlay2
 version=23.10.22
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools"
 makedepends="alsa-lib-devel ffmpeg-devel libass-devel libcdio-devel libgme-devel

From 98dd6f96092b7618012bdafd4095f157c13f314b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:34 -0500
Subject: [PATCH 101/110] alsa-plugins: revbump for ffmpeg6

---
 srcpkgs/alsa-plugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/alsa-plugins/template b/srcpkgs/alsa-plugins/template
index a5708a7d82a8f0..7bfdad046c4830 100644
--- a/srcpkgs/alsa-plugins/template
+++ b/srcpkgs/alsa-plugins/template
@@ -1,7 +1,7 @@
 # Template file for 'alsa-plugins'
 pkgname=alsa-plugins
 version=1.2.7.1
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--disable-maemo-plugin"
 hostmakedepends="pkg-config"

From e12eb01e9990e18f822ca5960e698d702caead58 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:43 -0500
Subject: [PATCH 102/110] minidlna: revbump for ffmpeg6

---
 srcpkgs/minidlna/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/minidlna/template b/srcpkgs/minidlna/template
index 5fa929f3a0c124..742991ecd04afc 100644
--- a/srcpkgs/minidlna/template
+++ b/srcpkgs/minidlna/template
@@ -1,7 +1,7 @@
 # Template file for 'minidlna'
 pkgname=minidlna
 version=1.3.3
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="
  --sbindir=/usr/bin

From 91f56568646f28747d6124b54b31f610fba7a64b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 17:57:47 -0500
Subject: [PATCH 103/110] mpv: revbump for ffmpeg6

---
 srcpkgs/mpv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpv/template b/srcpkgs/mpv/template
index 3d4349e27d8f62..bc40d6fcaa40d6 100644
--- a/srcpkgs/mpv/template
+++ b/srcpkgs/mpv/template
@@ -1,7 +1,7 @@
 # Template file for 'mpv'
 pkgname=mpv
 version=0.37.0
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcdda=enabled -Ddvbin=enabled -Ddvdnav=enabled
  -Dlibmpv=true -Dcplugins=enabled

From 30bd74ea2f92535a532894eca35029dc7d838e65 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 17:59:29 -0500
Subject: [PATCH 104/110] qimgv: revbump for ffmpeg6

---
 srcpkgs/qimgv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qimgv/template b/srcpkgs/qimgv/template
index dd341dfe1bfce8..8a7e1c081ef12f 100644
--- a/srcpkgs/qimgv/template
+++ b/srcpkgs/qimgv/template
@@ -1,7 +1,7 @@
 # Template file for 'qimgv'
 pkgname=qimgv
 version=1.0.2
-revision=3
+revision=4
 build_style=cmake
 configure_args="$(vopt_if video -DVIDEO_SUPPORT=ON -DVIDEO_SUPPORT=OFF)
  $(vopt_if scale -DOPENCV_SUPPORT=ON -DOPENCV_SUPPORT=OFF)

From 2227587a28ff02bdeee5cb4a10a6f083875e993b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 18:00:36 -0500
Subject: [PATCH 105/110] kfilemetadata5: revbump for ffmpeg6

---
 srcpkgs/kfilemetadata5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kfilemetadata5/template b/srcpkgs/kfilemetadata5/template
index a0c4d809395323..b584f85ff2058b 100644
--- a/srcpkgs/kfilemetadata5/template
+++ b/srcpkgs/kfilemetadata5/template
@@ -1,7 +1,7 @@
 # Template file for 'kfilemetadata5'
 pkgname=kfilemetadata5
 version=5.115.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="kcoreaddons extra-cmake-modules pkg-config qt5-host-tools qt5-qmake
  gettext kcoreaddons python3"

From 290ea400ee585d7e82223a6842cf60273620f5bf Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 8 Dec 2023 11:46:01 -0500
Subject: [PATCH 106/110] vba-m: revbump for ffmpeg6

---
 srcpkgs/vba-m/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vba-m/template b/srcpkgs/vba-m/template
index 3d135efa1d0b69..3c5a20db0fa984 100644
--- a/srcpkgs/vba-m/template
+++ b/srcpkgs/vba-m/template
@@ -2,7 +2,7 @@
 pkgname=vba-m
 reverts=1292_2
 version=2.1.9
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_GTK=TRUE -DENABLE_FFMPEG=TRUE -DENABLE_LINK=TRUE -DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="gettext pkg-config unzip zip yasm wxWidgets-gtk3-devel"

From d6a04e5cf5ffad018096759758b75bac6f687f4b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 8 Dec 2023 11:46:19 -0500
Subject: [PATCH 107/110] dolphin-emu: revbump for ffmpeg6

---
 srcpkgs/dolphin-emu/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/dolphin-emu/template b/srcpkgs/dolphin-emu/template
index 862d3ae964eec4..a7ae0efb58fb75 100644
--- a/srcpkgs/dolphin-emu/template
+++ b/srcpkgs/dolphin-emu/template
@@ -1,7 +1,7 @@
 # Template file for 'dolphin-emu'
 pkgname=dolphin-emu
 version=5.0.19368
-revision=3
+revision=4
 _dolphin_commit=dadbeb4bae7e7fa23af2b46e0add4143094dc107
 _mgba_commit=44e074a15e9651481f7f652ac006a7c9d58cbeb9
 _googletest_commit=be03d00f5f0cc3a997d1a368bee8a1fe93651f48

From a512835b6469ae2fe5364779c1890bd9c5a643d4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 19 Dec 2023 15:38:51 -0500
Subject: [PATCH 108/110] qtox: revbump for ffmpeg4

---
 srcpkgs/qtox/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtox/template b/srcpkgs/qtox/template
index bb70e7f51240a4..755e4462bc0137 100644
--- a/srcpkgs/qtox/template
+++ b/srcpkgs/qtox/template
@@ -1,13 +1,13 @@
 # Template file for 'qtox'
 pkgname=qtox
 version=1.17.6
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DUPDATE_CHECK=OFF
  -DGIT_DESCRIBE=${version}
  $(vopt_if snorenotify -DDESKTOP_NOTIFICATIONS=ON)"
 hostmakedepends="pkg-config qt5-host-tools qt5-devel"
-makedepends="ffmpeg-devel libexif-devel libopenal-devel libsodium-devel
+makedepends="ffmpeg4-devel libexif-devel libopenal-devel libsodium-devel
  libvpx-devel opus-devel qrencode-devel qt5-svg-devel sonnet-devel
  sqlcipher-devel toxcore-devel
  $(vopt_if snorenotify snorenotify-devel)"

From 7a56ea3c4d64e6700dfda2ce05ac02f0034b9f05 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 11 Jan 2024 11:52:00 -0500
Subject: [PATCH 109/110] arcan: revbump for ffmpeg6

---
 srcpkgs/arcan/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/arcan/template b/srcpkgs/arcan/template
index ff9091f90ebb10..030091a6cc9d0c 100644
--- a/srcpkgs/arcan/template
+++ b/srcpkgs/arcan/template
@@ -2,7 +2,7 @@
 # !! keep synced with: acfgfs aclip aloadimage
 pkgname=arcan
 version=0.6.2.1
-revision=2
+revision=3
 create_wrksrc=yes
 build_wrksrc=arcan/src
 build_style=cmake

From 4072bd9bd75ecfd75ac85cae2e11718f397d2a99 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 11 Jan 2024 11:52:10 -0500
Subject: [PATCH 110/110] notcurses: revbump for ffmpeg6

---
 srcpkgs/notcurses/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/notcurses/template b/srcpkgs/notcurses/template
index 48a7463cb68eb9..515f316ab4576c 100644
--- a/srcpkgs/notcurses/template
+++ b/srcpkgs/notcurses/template
@@ -1,7 +1,7 @@
 # Template file for 'notcurses'
 pkgname=notcurses
 version=3.0.9
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DUSE_STATIC=ON -DUSE_QRCODEGEN=On $(vopt_bool man USE_PANDOC)"
 hostmakedepends="pkg-config $(vopt_if man pandoc)"

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (87 preceding siblings ...)
  2024-03-09 22:41 ` [PR PATCH] [Updated] " zlice
@ 2024-03-09 22:43 ` zlice
  2024-03-09 22:56 ` yoshiyoshyosh
                   ` (8 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2024-03-09 22:43 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 457 bytes --]

New comment by zlice on void-packages repository

https://github.com/void-linux/void-packages/pull/43761#issuecomment-1986999887

Comment:
> idk if you did tests for spek-x when building it but they seem to fail for me without this patch:

haven't done full builds for musl yet. when your PRs get merged i'll probably start bugging people. coming up on a year now and my updates just needed another kick. probably doing a full reinstall once this merges.

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (88 preceding siblings ...)
  2024-03-09 22:43 ` zlice
@ 2024-03-09 22:56 ` yoshiyoshyosh
  2024-03-10  0:03 ` zlice
                   ` (7 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: yoshiyoshyosh @ 2024-03-09 22:56 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 355 bytes --]

New comment by yoshiyoshyosh on void-packages repository

https://github.com/void-linux/void-packages/pull/43761#issuecomment-1987002459

Comment:
> haven't done full builds for musl yet

that's odd, it was failing while I was testing on glibc O.o, wonder if there's some differing strict compiler flags present somewhere. whatever, so long as it works

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (89 preceding siblings ...)
  2024-03-09 22:56 ` yoshiyoshyosh
@ 2024-03-10  0:03 ` zlice
  2024-03-12 17:08 ` [PR PATCH] [Updated] " zlice
                   ` (6 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2024-03-10  0:03 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 262 bytes --]

New comment by zlice on void-packages repository

https://github.com/void-linux/void-packages/pull/43761#issuecomment-1987016438

Comment:
usually when i have to include stdint it's a musl thing. ya builds fine for me on glibc. don't know of anything fancy i do

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (90 preceding siblings ...)
  2024-03-10  0:03 ` zlice
@ 2024-03-12 17:08 ` zlice
  2024-03-18 20:07 ` zlice
                   ` (5 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2024-03-12 17:08 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 4960 bytes --]

There is an updated pull request by zlice against master on the void-packages repository

https://github.com/zlice/void-packages ffmpeg6-split
https://github.com/void-linux/void-packages/pull/43761

ffmpeg6 split
[ci skip]


#### Testing the changes

- I tested the changes in this PR: **YES**

main testing has been vaapi in Firefox Nightly and enc/dec in Shotcut on Intel A770

#### New package

- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**

#### Local build testing

- I built this PR locally for my native architecture, **x86_64**

#### Discussion

Continuation of https://github.com/void-linux/void-packages/pull/36315

`libavresample` is deprecated, but marked as a dependency when trying to build other packages and install `ffmpeg`(6). I think the right way to handle this is make a meta package and the add to removals?


##### Commit naming / misc

~~Commits are 'dirty' right now, running with [gstreamer 1.22.1 updates](https://github.com/void-linux/void-packages/pull/42861) and [Intel OpenCL](https://github.com/void-linux/void-packages/pull/43084). This will also make [intel packages pr](https://github.com/void-linux/void-packages/pull/41132) obsolete.~~ (see Requirements below)

Maintainer for previous ffmpeg(4) was orphaned, I can put my name in there if that matters, though I don't exactly see myself keeping up on ffmpeg.

~~This updates QT5 which looks like it is usually hosted by Johnny. Not sure if there's any reason to stay there or these sources are fine.~~ Using qt5.15.11 now, revbumps and some patches.

##### STILL FFMPEG4

These are a mix of emulators, games and/or older packages.

- ~~attract~~ (2.7 builds)
- ~~audacity (https://github.com/audacity/audacity/issues/2305 and https://sourceforge.net/p/portmedia/wiki/portsmf/ is 'beta')~~ (updated to 3.x, compiles with ffmpeg6)
- ~~ccextractor~~ (master patches)
- vice (3.8 compiles, needs makedepends libcurl-devel)
- kodi
- mlt (only dep left is flowblade - flowblade 2.12.0.2 with mlt7-python3 can 'render' videos with cpu and gpu - https://github.com/void-linux/void-packages/pull/47195)
- ~~synfig (mlt)~~ (work with mlt7, bump synfigstudio)
- tvheadend (download page recommends using 4.3 which compiles fine, 4.4 eta is Q1 2024)
- ~~ssr~~ (patches)
- ~~spek-alternative~~ (replace with spek-x)
- ~~ppsspp~~ ~~(1.17.1 is out, but there's 5+ distfiles that are all git commits)~~ (minor patch)
- olive (has been in alpha since 2020, seems they do nightly builds and appimages)
- moc
- mediastreamer (linphone links are dead, changed to github belladonne. their stuff never worked for me but there are updates if someone wants to give it a try)
- ~~libextractor (1.13 compiles, remove exiv2 patch)~~ (as yosh pointed out, 1.13 just removes ffmpeg bits)
- idjc (0.9.8 compiles, remove python3.10 patch, needs makedepends libebur128-devel and libshout-idjc 2.4.6 with '-r1' for distfile)
- hedgewars
- ~~ffmpegthumbnailer~~ (patches for moviedecoder.xxx files)
- ~~ffmpegthumbs~~ (latest compiles)
- deadbeef (1.9.6 may work but requires libdispatch from apple)
- ~~omxplayer~~ (package removed, deprecated in favor of vlc)
- qtav (fork has ffmpeg 5 patch - https://github.com/cmguo/QtAV)
- `vlc` (vlc4 will support ffmpeg5, there's a patch to build 3.x with ffmpeg5 but it will lack vaapi)
- `osg` (OpenSceneGraph plus `xine-lib`)


##### HAVE NOT BUILT YET

- ~~omxplayer (rpi only? ffmpeg4)~~ (removed)
- kodi (big, but ffmpeg4)


##### UPDATED (for ffmpeg6)

- ~~blender: update to 3.5.1~~ ~~will be revbump with~~ https://github.com/void-linux/void-packages/pull/43992
- unpaper: update to 7.0.0.
- guvcview: update to 2.0.8.
- ~~qt5: update to 5.15.8~~ updated by another PR to 5.15.11
- ~~qt5-webengine: update to 5.18.15~~ updated by another PR to 5.15.16 (some patching for ffmpeg build)
- ~~shiboken2: revbump for qt5.15.8 (patch)~~ updated by another PR to 5.15.10
- ~~python3-pyside2: update to 5.15.8 (patch)~~ updated by another PR to 5.15.10
- New package: spex-x replaces spek-alternative for ffmpeg-6.0


##### Requirements

- ~~[gstreamer 1.22.2](https://github.com/void-linux/void-packages/pull/42861)~~ - a few packages use ffmpeg-devel and require a revbump

- ~~[Intel Packages](https://github.com/void-linux/void-packages/pull/41132) [Intel Packages v2](https://github.com/void-linux/void-packages/pull/47330) - ffmpeg4 uses different libraries than 6 (libmfx / Intel-MediaSDK vs only oneVPL that Intel is moving to), both are included here~~. Using replacement oneVPL from OBS update.

- ~~[shotcut 23.05.14](https://github.com/void-linux/void-packages/pull/44260)~~

- https://github.com/void-linux/void-packages/pull/44781 will remove from this PR

A patch file from https://github.com/void-linux/void-packages/pull/43761.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ffmpeg6-split-43761.patch --]
[-- Type: text/x-diff, Size: 241213 bytes --]

From 5ca88666161acacb292353a357de48e160c03de4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:16:56 -0400
Subject: [PATCH 001/110] ffmpeg: update to 6.0.1.

---
 common/shlibs                                 | 26 ++++---
 srcpkgs/ffmpeg/files/altivec.patch            | 60 ---------------
 .../patches/armv5tel-floating-point.patch     | 18 -----
 srcpkgs/ffmpeg/patches/binutils-2.41.patch    | 73 -------------------
 ...h-libavcodec-libsvtav1-ten_bit_format.diff | 40 ----------
 .../workaround-mesa-readeon-vaapi-bug.patch   | 28 -------
 srcpkgs/ffmpeg/template                       | 40 +++++-----
 7 files changed, 37 insertions(+), 248 deletions(-)
 delete mode 100644 srcpkgs/ffmpeg/files/altivec.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/binutils-2.41.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 delete mode 100644 srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch

diff --git a/common/shlibs b/common/shlibs
index 4c9c98e1a3b7b8..7a69e761ed7dbe 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -389,15 +389,23 @@ libid3tag.so.0 libid3tag-0.15.1b_1
 libgif.so.7 giflib-5.1.0_1
 libImlib2.so.1 imlib2-1.4.2_1
 libmp3lame.so.0 lame-3.98.2_1
-libavdevice.so.58 libavdevice-4.0_1
-libavformat.so.58 libavformat-4.0_1
-libswscale.so.5 libswscale-4.0_1
-libswresample.so.3 libswresample-4.0_1
-libavresample.so.4 libavresample-4.0_1
-libpostproc.so.55 libpostproc-4.0_1
-libavcodec.so.58 libavcodec-4.0_1
-libavutil.so.56 libavutil-4.0_1
-libavfilter.so.7 libavfilter-4.0_1
+libavdevice.so.60 libavdevice-6.0_1
+libavformat.so.60 libavformat-6.0_1
+libswscale.so.7 libswscale-6.0_1
+libswresample.so.4 libswresample-6.0_1
+libpostproc.so.57 libpostproc-6.0_1
+libavcodec.so.60 libavcodec-6.0_1
+libavutil.so.58 libavutil-6.0_1
+libavfilter.so.9 libavfilter-6.0_1
+libavdevice.so.58 libavdevice4-4.0_1
+libavformat.so.58 libavformat4-4.0_1
+libswscale.so.5 libswscale4-4.0_1
+libswresample.so.3 libswresample4-4.0_1
+libavresample.so.4 libavresample4-4.0_1
+libpostproc.so.55 libpostproc4-4.0_1
+libavcodec.so.58 libavcodec4-4.0_1
+libavutil.so.56 libavutil4-4.0_1
+libavfilter.so.7 libavfilter4-4.0_1
 libSDL-1.2.so.0 SDL-1.2.14_1
 libSDL_image-1.2.so.0 SDL_image-1.2.10_1
 libx264.so.157 x264-20190507.2245_1
diff --git a/srcpkgs/ffmpeg/files/altivec.patch b/srcpkgs/ffmpeg/files/altivec.patch
deleted file mode 100644
index 9c57200463320e..00000000000000
--- a/srcpkgs/ffmpeg/files/altivec.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-revert some altivec specific change on all ppc* except ppc64le*
-
-q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
-conditionally, for ppc* but not ppc64le* (the new code is valid for
-POWER8 VSX which LE targets as a baseline but not BE)"
-
-
-This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
----
- libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
- 1 file changed, 20 insertions(+), 4 deletions(-)
-
-diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
-index 536545293d..c1e2852adb 100644
---- a/libswscale/ppc/yuv2rgb_altivec.c
-+++ b/libswscale/ppc/yuv2rgb_altivec.c
-@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-     vector signed short R1, G1, B1;                                           \
-     vector unsigned char R, G, B;                                             \
-                                                                               \
-+    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
-+    vector unsigned char align_perm;                                          \
-+                                                                              \
-     vector signed short lCY       = c->CY;                                    \
-     vector signed short lOY       = c->OY;                                    \
-     vector signed short lCRV      = c->CRV;                                   \
-@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
-                                                                               \
-         for (j = 0; j < w / 16; j++) {                                        \
--            y0 = vec_xl(0, y1i);                                              \
-+            y1ivP = (const vector unsigned char *) y1i;                       \
-+            y2ivP = (const vector unsigned char *) y2i;                       \
-+            uivP  = (const vector unsigned char *) ui;                        \
-+            vivP  = (const vector unsigned char *) vi;                        \
-+                                                                              \
-+            align_perm = vec_lvsl(0, y1i);                                    \
-+            y0 = (vector unsigned char)                                       \
-+                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
-                                                                               \
--            y1 = vec_xl(0, y2i);                                              \
-+            align_perm = vec_lvsl(0, y2i);                                    \
-+            y1 = (vector unsigned char)                                       \
-+                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
-                                                                               \
--            u = (vector signed char) vec_xl(0, ui);                           \
-+            align_perm = vec_lvsl(0, ui);                                     \
-+            u = (vector signed char)                                          \
-+                    vec_perm(uivP[0], uivP[1], align_perm);                   \
-                                                                               \
--            v = (vector signed char) vec_xl(0, vi);                           \
-+            align_perm = vec_lvsl(0, vi);                                     \
-+            v = (vector signed char)                                          \
-+                    vec_perm(vivP[0], vivP[1], align_perm);                   \
-                                                                               \
-             u = (vector signed char)                                          \
-                     vec_sub(u,                                                \
--- 
-2.27.0
-
diff --git a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
deleted file mode 100644
index 9a55178c74f0fd..00000000000000
--- a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
-+++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
-@@ -39,6 +39,15 @@
- #endif
- #include <fenv.h>
- 
-+#if (FE_ALL_EXCEPT == 0)
-+/* E.g. ARM soft float does not define these */
-+#define FE_INVALID    0
-+#define FE_DIVBYZERO  0
-+#define FE_OVERFLOW   0
-+#define FE_UNDERFLOW  0
-+#define FE_INEXACT    0
-+#endif
-+
- #if CONFIG_LIBFONTCONFIG
- #include <fontconfig/fontconfig.h>
- #endif
diff --git a/srcpkgs/ffmpeg/patches/binutils-2.41.patch b/srcpkgs/ffmpeg/patches/binutils-2.41.patch
deleted file mode 100644
index 53a596d0ee7d4e..00000000000000
--- a/srcpkgs/ffmpeg/patches/binutils-2.41.patch
+++ /dev/null
@@ -1,73 +0,0 @@
-From effadce6c756247ea8bae32dc13bb3e6f464f0eb Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= <remi@remlab.net>
-Date: Sun, 16 Jul 2023 18:18:02 +0300
-Subject: [PATCH] avcodec/x86/mathops: clip constants used with shift
- instructions within inline assembly
-
-Fixes assembling with binutil as >= 2.41
-
-Signed-off-by: James Almer <jamrial@gmail.com>
----
- libavcodec/x86/mathops.h | 26 +++++++++++++++++++++++---
- 1 file changed, 23 insertions(+), 3 deletions(-)
-
-diff --git a/libavcodec/x86/mathops.h b/libavcodec/x86/mathops.h
-index 6298f5ed1983b..ca7e2dffc1076 100644
---- a/libavcodec/x86/mathops.h
-+++ b/libavcodec/x86/mathops.h
-@@ -35,12 +35,20 @@
- static av_always_inline av_const int MULL(int a, int b, unsigned shift)
- {
-     int rt, dummy;
-+    if (__builtin_constant_p(shift))
-     __asm__ (
-         "imull %3               \n\t"
-         "shrdl %4, %%edx, %%eax \n\t"
-         :"=a"(rt), "=d"(dummy)
--        :"a"(a), "rm"(b), "ci"((uint8_t)shift)
-+        :"a"(a), "rm"(b), "i"(shift & 0x1F)
-     );
-+    else
-+        __asm__ (
-+            "imull %3               \n\t"
-+            "shrdl %4, %%edx, %%eax \n\t"
-+            :"=a"(rt), "=d"(dummy)
-+            :"a"(a), "rm"(b), "c"((uint8_t)shift)
-+        );
-     return rt;
- }
- 
-@@ -113,19 +121,31 @@ __asm__ volatile(\
- // avoid +32 for shift optimization (gcc should do that ...)
- #define NEG_SSR32 NEG_SSR32
- static inline  int32_t NEG_SSR32( int32_t a, int8_t s){
-+    if (__builtin_constant_p(s))
-     __asm__ ("sarl %1, %0\n\t"
-          : "+r" (a)
--         : "ic" ((uint8_t)(-s))
-+         : "i" (-s & 0x1F)
-     );
-+    else
-+        __asm__ ("sarl %1, %0\n\t"
-+               : "+r" (a)
-+               : "c" ((uint8_t)(-s))
-+        );
-     return a;
- }
- 
- #define NEG_USR32 NEG_USR32
- static inline uint32_t NEG_USR32(uint32_t a, int8_t s){
-+    if (__builtin_constant_p(s))
-     __asm__ ("shrl %1, %0\n\t"
-          : "+r" (a)
--         : "ic" ((uint8_t)(-s))
-+         : "i" (-s & 0x1F)
-     );
-+    else
-+        __asm__ ("shrl %1, %0\n\t"
-+               : "+r" (a)
-+               : "c" ((uint8_t)(-s))
-+        );
-     return a;
- }
- 
diff --git a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
deleted file mode 100644
index aa948f7a8a2dfb..00000000000000
--- a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
+++ /dev/null
@@ -1,40 +0,0 @@
-#==================================================================================================
-# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
-# From: Christopher Degawa <christopher.degawa@intel.com>
-# Date: Thu, 20 Oct 2022 22:55:27 -0500
-# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
-#
-# compressed_ten_bit_format has been deprecated upstream and has no effect
-# and can be removed. Plus, technically it was never used in the first place
-# since it would require the app (ffmpeg) to set it and do additional
-# processing of the input frames.
-#
-# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
-#
-# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
-#==================================================================================================
---- a/libavcodec/libsvtav1.c
-+++ b/libavcodec/libsvtav1.c
-@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
- 
- static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
- {
--    const int    pack_mode_10bit =
--        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
--    const size_t luma_size_8bit  =
--        config->source_width * config->source_height * (1 << pack_mode_10bit);
--    const size_t luma_size_10bit =
--        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
-+    const size_t luma_size = config->source_width * config->source_height *
-+        (config->encoder_bit_depth > 8 ? 2 : 1);
- 
-     EbSvtIOFormat *in_data;
- 
--    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
-+    svt_enc->raw_size = luma_size * 3 / 2;
- 
-     // allocate buffer for in and out
-     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
--- 
-GitLab
-
diff --git a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
deleted file mode 100644
index 00e3f68a415b84..00000000000000
--- a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
-From: Rainer Hochecker <fernetmenta@online.de>
-Date: Sat, 26 Jan 2019 19:48:35 +0100
-Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
-
-This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
-It was hit frequently when watching h264 channels received via DVB-X.
-Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
----
- libavcodec/vaapi_h264.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
-index 5854587a255..f12fdc457a4 100644
---- a/libavcodec/vaapi_h264.c
-+++ b/libavcodec/vaapi_h264.c
-@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
-     H264SliceContext *sl = &h->slice_ctx[0];
-     int ret;
- 
-+    if (pic->nb_slices == 0) {
-+        ret = AVERROR_INVALIDDATA;
-+        goto finish;
-+    }
-+
-     ret = ff_vaapi_decode_issue(avctx, pic);
-     if (ret < 0)
-         goto finish;
diff --git a/srcpkgs/ffmpeg/template b/srcpkgs/ffmpeg/template
index 1ebb436135938d..f1e4712c41d087 100644
--- a/srcpkgs/ffmpeg/template
+++ b/srcpkgs/ffmpeg/template
@@ -1,15 +1,15 @@
 # Template file for 'ffmpeg'
 # audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
 pkgname=ffmpeg
-version=4.4.4
-revision=6
+version=6.0.1
+revision=1
 short_desc="Decoding, encoding and streaming software"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="https://www.ffmpeg.org"
 changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
 distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
-checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+checksum=9b16b8731d78e596b4be0d720428ca42df642bb2d78342881ff7f5bc29fc9623
 
 hostmakedepends="pkg-config perl"
 makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
@@ -26,12 +26,13 @@ makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-deve
  $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
  $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
  $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
- $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers Vulkan-Tools Vulkan-ValidationLayers')
+ $(vopt_if onevpl 'oneVPL oneVPL-devel')
  $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
 depends="ffplay>=${version}_${revision}"
 
 build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
- dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec onevpl"
 build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
 desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
 desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
@@ -39,9 +40,13 @@ desc_option_sofa="Enable support for AES SOFA"
 desc_option_webp="Enable support for WebP"
 
 case "$XBPS_TARGET_MACHINE" in
-	i686*|x86_64*)
-		hostmakedepends+=" nasm"
+	i686*)
 		build_options_default+=" vaapi vdpau nvenc nvdec"
+		hostmakedepends+=" nasm"
+		;;
+	x86_64*)
+		hostmakedepends+=" nasm"
+		build_options_default+=" vaapi vdpau nvenc nvdec onevpl"
 		;;
 	ppc64*) build_options_default+=" vaapi vdpau";;
 	mips*) CFLAGS="-mnan=legacy";;
@@ -65,8 +70,6 @@ post_patch() {
 		ppc64le*) ;;
 		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
 	esac
-
-	vsed -i libavfilter/vf_libvmaf.c -e 's!/usr/local/share/model/\(vmaf_v0.6.1\).pkl!/usr/share/vmaf/\1.json!'
 }
 
 do_configure() {
@@ -115,18 +118,19 @@ do_configure() {
 		$(vopt_enable x265 libx265) \
 		$(vopt_enable v4l2 libv4l2) \
 		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
-		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		--enable-libbs2b --enable-libvidstab \
 		$(vopt_enable dav1d libdav1d) \
 		$(vopt_enable zimg libzimg) \
 		$(vopt_enable webp libwebp) \
 		$(vopt_enable sofa libmysofa) \
 		$(vopt_enable vulkan) \
+		$(vopt_enable onevpl libvpl) \
 		$(vopt_enable drm libdrm) \
 		$(vopt_enable svtav1 libsvtav1) \
 		$(vopt_enable srt libsrt) \
 		$(vopt_enable rist librist) \
-		$(vopt_if nvenc '--enable-nvenc') \
-		$(vopt_if nvdec '--enable-nvdec')
+		$(vopt_enable nvenc nvenc) \
+		$(vopt_enable nvdec nvdec)
 }
 
 do_build() {
@@ -153,10 +157,8 @@ libavdevice_package() {
 }
 
 libavresample_package() {
-	short_desc="FFmpeg audio resampling library"
-	pkg_install() {
-		vmove "usr/lib/libavresample.so.*"
-	}
+	short_desc="Package deprecated, removal needed"
+	build_style=meta
 }
 
 libavformat_package() {
@@ -210,15 +212,13 @@ ffmpeg-devel_package() {
 		libavfilter>=${version}_${revision}
 		libpostproc>=${version}_${revision}
 		libswscale>=${version}_${revision}
-		libswresample>=${version}_${revision}
-		libavresample>=${version}_${revision}"
+		libswresample>=${version}_${revision}"
 	short_desc+=" - development files"
-
+	conflicts="ffmpeg4-devel"
 	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
 		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
 		nostrip_files="/usr/lib/libavfilter.a"
 	fi
-
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig

From 5098b600a1b10766274ddb08343c8d7d9484dad1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:14 -0400
Subject: [PATCH 002/110] openshot: revbump for ffmpeg6

---
 srcpkgs/openshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openshot/template b/srcpkgs/openshot/template
index 3849858fe963b5..12789bc9867499 100644
--- a/srcpkgs/openshot/template
+++ b/srcpkgs/openshot/template
@@ -1,7 +1,7 @@
 # Template file for 'openshot'
 pkgname=openshot
 version=3.1.1
-revision=1
+revision=2
 build_style=python3-module
 hostmakedepends="python3 python3-setuptools"
 makedepends="ffmpeg-devel python3-PyQt5"

From 83630c4a150614e08fd4a0b45978890963392d6a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:36 -0400
Subject: [PATCH 003/110] sumo: revbump for ffmpeg6

---
 srcpkgs/sumo/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/sumo/template b/srcpkgs/sumo/template
index a730afa9fafa92..e2def06fa4bd7d 100644
--- a/srcpkgs/sumo/template
+++ b/srcpkgs/sumo/template
@@ -1,7 +1,7 @@
 # Template file for 'sumo'
 pkgname=sumo
 version=1.12.0
-revision=7
+revision=8
 build_style=cmake
 hostmakedepends="libgdal-tools pkg-config swig python3-setuptools"
 makedepends="python3-devel ffmpeg-devel fox-devel gl2ps-devel libgdal-devel

From b16c09bd11f3f13532e59f9f075d95e62596b59f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:56:22 -0400
Subject: [PATCH 004/110] New package: ffmpeg4-4.4.4.

---
 srcpkgs/ffmpeg4-devel                         |   1 +
 srcpkgs/ffmpeg4/files/altivec.patch           |  60 +++++
 .../patches/armv5tel-floating-point.patch     |  18 ++
 srcpkgs/ffmpeg4/patches/binutils-2.41.patch   |  73 ++++++
 ...h-libavcodec-libsvtav1-ten_bit_format.diff |  40 +++
 .../workaround-mesa-readeon-vaapi-bug.patch   |  28 +++
 srcpkgs/ffmpeg4/template                      | 234 ++++++++++++++++++
 srcpkgs/libavcodec4                           |   1 +
 srcpkgs/libavdevice4                          |   1 +
 srcpkgs/libavfilter4                          |   1 +
 srcpkgs/libavformat4                          |   1 +
 srcpkgs/libavresample4                        |   1 +
 srcpkgs/libavutil4                            |   1 +
 srcpkgs/libpostproc4                          |   1 +
 srcpkgs/libswresample4                        |   1 +
 srcpkgs/libswscale4                           |   1 +
 16 files changed, 463 insertions(+)
 create mode 120000 srcpkgs/ffmpeg4-devel
 create mode 100644 srcpkgs/ffmpeg4/files/altivec.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/binutils-2.41.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 create mode 100644 srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
 create mode 100644 srcpkgs/ffmpeg4/template
 create mode 120000 srcpkgs/libavcodec4
 create mode 120000 srcpkgs/libavdevice4
 create mode 120000 srcpkgs/libavfilter4
 create mode 120000 srcpkgs/libavformat4
 create mode 120000 srcpkgs/libavresample4
 create mode 120000 srcpkgs/libavutil4
 create mode 120000 srcpkgs/libpostproc4
 create mode 120000 srcpkgs/libswresample4
 create mode 120000 srcpkgs/libswscale4

diff --git a/srcpkgs/ffmpeg4-devel b/srcpkgs/ffmpeg4-devel
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/ffmpeg4-devel
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/ffmpeg4/files/altivec.patch b/srcpkgs/ffmpeg4/files/altivec.patch
new file mode 100644
index 00000000000000..9c57200463320e
--- /dev/null
+++ b/srcpkgs/ffmpeg4/files/altivec.patch
@@ -0,0 +1,60 @@
+revert some altivec specific change on all ppc* except ppc64le*
+
+q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
+conditionally, for ppc* but not ppc64le* (the new code is valid for
+POWER8 VSX which LE targets as a baseline but not BE)"
+
+
+This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
+---
+ libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
+ 1 file changed, 20 insertions(+), 4 deletions(-)
+
+diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
+index 536545293d..c1e2852adb 100644
+--- a/libswscale/ppc/yuv2rgb_altivec.c
++++ b/libswscale/ppc/yuv2rgb_altivec.c
+@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+     vector signed short R1, G1, B1;                                           \
+     vector unsigned char R, G, B;                                             \
+                                                                               \
++    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
++    vector unsigned char align_perm;                                          \
++                                                                              \
+     vector signed short lCY       = c->CY;                                    \
+     vector signed short lOY       = c->OY;                                    \
+     vector signed short lCRV      = c->CRV;                                   \
+@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
+                                                                               \
+         for (j = 0; j < w / 16; j++) {                                        \
+-            y0 = vec_xl(0, y1i);                                              \
++            y1ivP = (const vector unsigned char *) y1i;                       \
++            y2ivP = (const vector unsigned char *) y2i;                       \
++            uivP  = (const vector unsigned char *) ui;                        \
++            vivP  = (const vector unsigned char *) vi;                        \
++                                                                              \
++            align_perm = vec_lvsl(0, y1i);                                    \
++            y0 = (vector unsigned char)                                       \
++                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
+                                                                               \
+-            y1 = vec_xl(0, y2i);                                              \
++            align_perm = vec_lvsl(0, y2i);                                    \
++            y1 = (vector unsigned char)                                       \
++                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
+                                                                               \
+-            u = (vector signed char) vec_xl(0, ui);                           \
++            align_perm = vec_lvsl(0, ui);                                     \
++            u = (vector signed char)                                          \
++                    vec_perm(uivP[0], uivP[1], align_perm);                   \
+                                                                               \
+-            v = (vector signed char) vec_xl(0, vi);                           \
++            align_perm = vec_lvsl(0, vi);                                     \
++            v = (vector signed char)                                          \
++                    vec_perm(vivP[0], vivP[1], align_perm);                   \
+                                                                               \
+             u = (vector signed char)                                          \
+                     vec_sub(u,                                                \
+-- 
+2.27.0
+
diff --git a/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
new file mode 100644
index 00000000000000..9a55178c74f0fd
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
@@ -0,0 +1,18 @@
+--- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
++++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
+@@ -39,6 +39,15 @@
+ #endif
+ #include <fenv.h>
+ 
++#if (FE_ALL_EXCEPT == 0)
++/* E.g. ARM soft float does not define these */
++#define FE_INVALID    0
++#define FE_DIVBYZERO  0
++#define FE_OVERFLOW   0
++#define FE_UNDERFLOW  0
++#define FE_INEXACT    0
++#endif
++
+ #if CONFIG_LIBFONTCONFIG
+ #include <fontconfig/fontconfig.h>
+ #endif
diff --git a/srcpkgs/ffmpeg4/patches/binutils-2.41.patch b/srcpkgs/ffmpeg4/patches/binutils-2.41.patch
new file mode 100644
index 00000000000000..53a596d0ee7d4e
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/binutils-2.41.patch
@@ -0,0 +1,73 @@
+From effadce6c756247ea8bae32dc13bb3e6f464f0eb Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= <remi@remlab.net>
+Date: Sun, 16 Jul 2023 18:18:02 +0300
+Subject: [PATCH] avcodec/x86/mathops: clip constants used with shift
+ instructions within inline assembly
+
+Fixes assembling with binutil as >= 2.41
+
+Signed-off-by: James Almer <jamrial@gmail.com>
+---
+ libavcodec/x86/mathops.h | 26 +++++++++++++++++++++++---
+ 1 file changed, 23 insertions(+), 3 deletions(-)
+
+diff --git a/libavcodec/x86/mathops.h b/libavcodec/x86/mathops.h
+index 6298f5ed1983b..ca7e2dffc1076 100644
+--- a/libavcodec/x86/mathops.h
++++ b/libavcodec/x86/mathops.h
+@@ -35,12 +35,20 @@
+ static av_always_inline av_const int MULL(int a, int b, unsigned shift)
+ {
+     int rt, dummy;
++    if (__builtin_constant_p(shift))
+     __asm__ (
+         "imull %3               \n\t"
+         "shrdl %4, %%edx, %%eax \n\t"
+         :"=a"(rt), "=d"(dummy)
+-        :"a"(a), "rm"(b), "ci"((uint8_t)shift)
++        :"a"(a), "rm"(b), "i"(shift & 0x1F)
+     );
++    else
++        __asm__ (
++            "imull %3               \n\t"
++            "shrdl %4, %%edx, %%eax \n\t"
++            :"=a"(rt), "=d"(dummy)
++            :"a"(a), "rm"(b), "c"((uint8_t)shift)
++        );
+     return rt;
+ }
+ 
+@@ -113,19 +121,31 @@ __asm__ volatile(\
+ // avoid +32 for shift optimization (gcc should do that ...)
+ #define NEG_SSR32 NEG_SSR32
+ static inline  int32_t NEG_SSR32( int32_t a, int8_t s){
++    if (__builtin_constant_p(s))
+     __asm__ ("sarl %1, %0\n\t"
+          : "+r" (a)
+-         : "ic" ((uint8_t)(-s))
++         : "i" (-s & 0x1F)
+     );
++    else
++        __asm__ ("sarl %1, %0\n\t"
++               : "+r" (a)
++               : "c" ((uint8_t)(-s))
++        );
+     return a;
+ }
+ 
+ #define NEG_USR32 NEG_USR32
+ static inline uint32_t NEG_USR32(uint32_t a, int8_t s){
++    if (__builtin_constant_p(s))
+     __asm__ ("shrl %1, %0\n\t"
+          : "+r" (a)
+-         : "ic" ((uint8_t)(-s))
++         : "i" (-s & 0x1F)
+     );
++    else
++        __asm__ ("shrl %1, %0\n\t"
++               : "+r" (a)
++               : "c" ((uint8_t)(-s))
++        );
+     return a;
+ }
+ 
diff --git a/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
new file mode 100644
index 00000000000000..aa948f7a8a2dfb
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
@@ -0,0 +1,40 @@
+#==================================================================================================
+# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
+# From: Christopher Degawa <christopher.degawa@intel.com>
+# Date: Thu, 20 Oct 2022 22:55:27 -0500
+# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
+#
+# compressed_ten_bit_format has been deprecated upstream and has no effect
+# and can be removed. Plus, technically it was never used in the first place
+# since it would require the app (ffmpeg) to set it and do additional
+# processing of the input frames.
+#
+# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
+#
+# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
+#==================================================================================================
+--- a/libavcodec/libsvtav1.c
++++ b/libavcodec/libsvtav1.c
+@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
+ 
+ static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
+ {
+-    const int    pack_mode_10bit =
+-        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
+-    const size_t luma_size_8bit  =
+-        config->source_width * config->source_height * (1 << pack_mode_10bit);
+-    const size_t luma_size_10bit =
+-        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
++    const size_t luma_size = config->source_width * config->source_height *
++        (config->encoder_bit_depth > 8 ? 2 : 1);
+ 
+     EbSvtIOFormat *in_data;
+ 
+-    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
++    svt_enc->raw_size = luma_size * 3 / 2;
+ 
+     // allocate buffer for in and out
+     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
+-- 
+GitLab
+
diff --git a/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
new file mode 100644
index 00000000000000..00e3f68a415b84
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
@@ -0,0 +1,28 @@
+From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
+From: Rainer Hochecker <fernetmenta@online.de>
+Date: Sat, 26 Jan 2019 19:48:35 +0100
+Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
+
+This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
+It was hit frequently when watching h264 channels received via DVB-X.
+Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
+---
+ libavcodec/vaapi_h264.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
+index 5854587a255..f12fdc457a4 100644
+--- a/libavcodec/vaapi_h264.c
++++ b/libavcodec/vaapi_h264.c
+@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
+     H264SliceContext *sl = &h->slice_ctx[0];
+     int ret;
+ 
++    if (pic->nb_slices == 0) {
++        ret = AVERROR_INVALIDDATA;
++        goto finish;
++    }
++
+     ret = ff_vaapi_decode_issue(avctx, pic);
+     if (ret < 0)
+         goto finish;
diff --git a/srcpkgs/ffmpeg4/template b/srcpkgs/ffmpeg4/template
new file mode 100644
index 00000000000000..9ba14bdb8ddf32
--- /dev/null
+++ b/srcpkgs/ffmpeg4/template
@@ -0,0 +1,234 @@
+# Template file for 'ffmpeg4'
+# audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
+pkgname=ffmpeg4
+version=4.4.4
+revision=1
+short_desc="Decoding, encoding and streaming software - ffmpeg4 libraries only"
+maintainer="Orphaned <orphan@voidlinux.org>"
+license="GPL-3.0-or-later"
+homepage="https://www.ffmpeg.org"
+changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
+distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
+checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+
+hostmakedepends="pkg-config perl"
+makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
+ libXext-devel libXvMC-devel libxcb-devel lame-devel libtheora-devel
+ libvorbis-devel x264-devel xvidcore-devel jack-devel SDL2-devel
+ libcdio-paranoia-devel librtmp-devel libmodplug-devel gnutls-devel
+ speex-devel celt-devel harfbuzz-devel libass-devel opus-devel ocl-icd-devel
+ libbs2b-devel libvidstab-devel vmaf-devel $(vopt_if pulseaudio pulseaudio-devel)
+ $(vopt_if vaapi libva-devel) $(vopt_if vdpau libvdpau-devel)
+ $(vopt_if x265 x265-devel) $(vopt_if v4l2 v4l-utils-devel)
+ $(vopt_if fdk_aac fdk-aac-devel) $(vopt_if vpx libvpx-devel)
+ $(vopt_if aom libaom-devel) $(vopt_if sndio sndio-devel)
+ $(vopt_if dav1d libdav1d-devel) $(vopt_if zimg zimg-devel)
+ $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
+ $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
+ $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
+
+build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
+
+desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
+desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
+desc_option_sofa="Enable support for AES SOFA"
+desc_option_webp="Enable support for WebP"
+
+case "$XBPS_TARGET_MACHINE" in
+	i686*|x86_64*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau nvenc nvdec"
+			;;
+	ppc64*) build_options_default+=" vaapi vdpau";;
+	mips*) CFLAGS="-mnan=legacy";;
+esac
+
+if [ "$XBPS_TARGET_WORDSIZE" != "32" ]; then
+	build_options_default+=" svtav1"
+fi
+
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+fi
+
+_apply_patch() {
+	local args="$1" pname="$(basename $2)"
+
+	if [ ! -f ".${pname}_done" ]; then
+		patch -N $args -i $2
+		touch .${pname}_done
+	fi
+}
+
+post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64le*) ;;
+		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
+	esac
+
+	vsed -i libavfilter/vf_libvmaf.c -e 's!/usr/local/share/model/\(vmaf_v0.6.1\).pkl!/usr/share/vmaf/\1.json!'
+}
+
+do_configure() {
+	# Fix gcc on x86_64-musl only
+	if [ "$XBPS_TARGET_MACHINE" = "x86_64-musl" ]; then
+		vsed -i configure -e "s;_cflags_speed='-O3';_cflags_speed='-O2';"
+	fi
+
+	if [ "$CROSS_BUILD" ]; then
+		case "$XBPS_TARGET_MACHINE" in
+			arm*) _arch="arm";;
+			aarch64*) _arch="aarch64";;
+			mips*) _arch="mips";;
+			ppc64*) _arch="ppc64";;
+			ppc*) _arch="ppc";;
+			*) _arch="${XBPS_TARGET_MACHINE%%-musl}";;
+		esac
+
+		_args+=" --enable-cross-compile
+			--sysroot=$XBPS_CROSS_BASE
+			--cross-prefix=${XBPS_CROSS_TRIPLET}-
+			--target-os=linux --arch=${_arch}"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc|ppc-musl) _args+=" --disable-altivec";;
+	esac
+
+	if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+		_args+=" --extra-libs=-latomic"
+	fi
+
+	./configure --prefix=/usr --disable-debug --enable-gpl --enable-gnutls \
+		--disable-stripping \
+		--enable-libcdio --enable-version3 --enable-runtime-cpudetect \
+		--enable-libmp3lame --enable-libvorbis --enable-libxvid \
+		--enable-libx264 $(vopt_enable vpx libvpx) --enable-libtheora \
+		--enable-shared --enable-static --enable-libxcb \
+		$(vopt_enable pulseaudio libpulse) --enable-libfreetype --enable-libmodplug \
+		--enable-libspeex --enable-libcelt --enable-libass \
+		--enable-libopus --enable-librtmp --enable-libjack \
+		$(vopt_if fdk_aac '--enable-nonfree --enable-libfdk-aac') \
+		--disable-libopencore_amrnb --disable-libopencore_amrwb \
+		--disable-libopenjpeg \
+		--enable-postproc --enable-opencl ${_args} --enable-libvmaf ${_args} \
+		$(vopt_enable x265 libx265) \
+		$(vopt_enable v4l2 libv4l2) \
+		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
+		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		$(vopt_enable dav1d libdav1d) \
+		$(vopt_enable zimg libzimg) \
+		$(vopt_enable webp libwebp) \
+		$(vopt_enable sofa libmysofa) \
+		$(vopt_enable vulkan) \
+		$(vopt_enable drm libdrm) \
+		$(vopt_enable svtav1 libsvtav1) \
+		$(vopt_enable srt libsrt) \
+		$(vopt_enable rist librist) \
+		$(vopt_if nvenc '--enable-nvenc') \
+		$(vopt_if nvdec '--enable-nvdec')
+}
+
+do_build() {
+	make ${makejobs}
+	make doc/ff{mpeg,play}.1
+}
+
+do_install() {
+	make DESTDIR=${DESTDIR} install install-man
+	rm -rf ${DESTDIR}/usr/bin
+}
+
+libavcodec4_package() {
+	short_desc="FFmpeg codec library"
+	pkg_install() {
+		vmove "usr/lib/libavcodec.so.*"
+	}
+}
+
+libavdevice4_package() {
+	short_desc="FFmpeg device handling library"
+	pkg_install() {
+		vmove "usr/lib/libavdevice.so.*"
+	}
+}
+
+libavresample4_package() {
+	short_desc="FFmpeg audio resampling library"
+	pkg_install() {
+		vmove "usr/lib/libavresample.so.*"
+	}
+}
+
+libavformat4_package() {
+	short_desc="FFmpeg file format library"
+	pkg_install() {
+		vmove "usr/lib/libavformat.so.*"
+	}
+}
+
+libavutil4_package() {
+	short_desc="FFmpeg utility library"
+	pkg_install() {
+		vmove "usr/lib/libavutil.so.*"
+	}
+}
+
+libavfilter4_package() {
+	short_desc="FFmpeg audio/video filter library"
+	pkg_install() {
+		vmove "usr/lib/libavfilter.so.*"
+	}
+}
+
+libpostproc4_package() {
+	short_desc="FFmpeg video postprocessing library"
+	pkg_install() {
+		vmove "usr/lib/libpostproc.so.*"
+	}
+}
+
+libswscale4_package() {
+	short_desc="FFmpeg video scaling library"
+	pkg_install() {
+		vmove "usr/lib/libswscale.so.*"
+	}
+}
+
+libswresample4_package() {
+	short_desc="FFmpeg video resampling library"
+	pkg_install() {
+		vmove "usr/lib/libswresample.so.*"
+	}
+}
+
+ffmpeg4-devel_package() {
+	depends="
+		libavcodec4>=${version}_${revision}
+		libavdevice4>=${version}_${revision}
+		libavformat4>=${version}_${revision}
+		libavutil4>=${version}_${revision}
+		libavfilter4>=${version}_${revision}
+		libpostproc4>=${version}_${revision}
+		libswscale4>=${version}_${revision}
+		libswresample4>=${version}_${revision}
+		libavresample4>=${version}_${revision}"
+	short_desc+=" - development files"
+	conflicts="ffmpeg-devel"
+	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
+		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
+		nostrip_files="/usr/lib/libavfilter.a"
+	fi
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.a"
+		vmove "usr/lib/*.so"
+		vmove usr/share/ffmpeg/examples
+		vmove usr/share/man/man3
+	}
+}
diff --git a/srcpkgs/libavcodec4 b/srcpkgs/libavcodec4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavcodec4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavdevice4 b/srcpkgs/libavdevice4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavdevice4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavfilter4 b/srcpkgs/libavfilter4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavfilter4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavformat4 b/srcpkgs/libavformat4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavformat4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavresample4 b/srcpkgs/libavresample4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavutil4 b/srcpkgs/libavutil4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavutil4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libpostproc4 b/srcpkgs/libpostproc4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libpostproc4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswresample4 b/srcpkgs/libswresample4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libswresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswscale4 b/srcpkgs/libswscale4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libswscale4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file

From 24a7b62af1cea283957cb6dffd20969208547ec3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:04 -0400
Subject: [PATCH 005/110] opencv: update to 4.7.0.

---
 common/shlibs           | 104 ++++++++++++++++++++--------------------
 srcpkgs/opencv/template |   8 ++--
 2 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index 7a69e761ed7dbe..2b6bc3f6654f7e 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2080,58 +2080,58 @@ libcapstone.so.5 capstone-5.0.1_1
 libhavege.so.2 libhaveged-1.9.11_1
 libnih.so.1 libnih-1.0.3_1
 libnih-dbus.so.1 libnih-1.0.3_1
-libopencv_quality.so.406 libopencv-4.6.0_1
-libopencv_reg.so.406 libopencv-4.6.0_1
-libopencv_surface_matching.so.406 libopencv-4.6.0_1
-libopencv_xphoto.so.406 libopencv-4.6.0_1
-libopencv_freetype.so.406 libopencv-4.6.0_1
-libopencv_fuzzy.so.406 libopencv-4.6.0_1
-libopencv_hfs.so.406 libopencv-4.6.0_1
-libopencv_img_hash.so.406 libopencv-4.6.0_1
-libopencv_line_descriptor.so.406 libopencv-4.6.0_1
-libopencv_saliency.so.406 libopencv-4.6.0_1
-libopencv_structured_light.so.406 libopencv-4.6.0_1
-libopencv_aruco.so.406 libopencv-4.6.0_1
-libopencv_bgsegm.so.406 libopencv-4.6.0_1
-libopencv_bioinspired.so.406 libopencv-4.6.0_1
-libopencv_ccalib.so.406 libopencv-4.6.0_1
-libopencv_face.so.406 libopencv-4.6.0_1
-libopencv_tracking.so.406 libopencv-4.6.0_1
-libopencv_xfeatures2d.so.406 libopencv-4.6.0_1
-libopencv_optflow.so.406 libopencv-4.6.0_1
-libopencv_ximgproc.so.406 libopencv-4.6.0_1
-libopencv_plot.so.406 libopencv-4.6.0_1
-libopencv_text.so.406 libopencv-4.6.0_1
-libopencv_ml.so.406 libopencv-4.6.0_1
-libopencv_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn.so.406 libopencv-4.6.0_1
-libopencv_shape.so.406 libopencv-4.6.0_1
-libopencv_stitching.so.406 libopencv-4.6.0_1
-libopencv_photo.so.406 libopencv-4.6.0_1
-libopencv_video.so.406 libopencv-4.6.0_1
-libopencv_calib3d.so.406 libopencv-4.6.0_1
-libopencv_features2d.so.406 libopencv-4.6.0_1
-libopencv_flann.so.406 libopencv-4.6.0_1
-libopencv_highgui.so.406 libopencv-4.6.0_1
-libopencv_videoio.so.406 libopencv-4.6.0_1
-libopencv_imgcodecs.so.406 libopencv-4.6.0_1
-libopencv_imgproc.so.406 libopencv-4.6.0_1
-libopencv_core.so.406 libopencv-4.6.0_1
-libopencv_superres.so.406 libopencv-4.6.0_1
-libopencv_videostab.so.406 libopencv-4.6.0_1
-libopencv_gapi.so.406 libopencv-4.6.0_1
-libopencv_xobjdetect.so.406 libopencv-4.6.0_1
-libopencv_datasets.so.406 libopencv-4.6.0_1
-libopencv_dnn_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn_superres.so.406 libopencv-4.6.0_1
-libopencv_dpm.so.406 libopencv-4.6.0_1
-libopencv_phase_unwrapping.so.406 libopencv-4.6.0_1
-libopencv_stereo.so.406 libopencv-4.6.0_1
-libopencv_rapid.so.406 libopencv-4.6.0_1
-libopencv_intensity_transform.so.406 libopencv-4.6.0_1
-libopencv_alphamat.so.406 libopencv-4.6.0_1
-libopencv_barcode.so.406 libopencv-4.6.0_1
-libopencv_mcc.so.406 libopencv-4.6.0_1
+libopencv_quality.so.407 libopencv-4.7.0_1
+libopencv_reg.so.407 libopencv-4.7.0_1
+libopencv_surface_matching.so.407 libopencv-4.7.0_1
+libopencv_xphoto.so.407 libopencv-4.7.0_1
+libopencv_freetype.so.407 libopencv-4.7.0_1
+libopencv_fuzzy.so.407 libopencv-4.7.0_1
+libopencv_hfs.so.407 libopencv-4.7.0_1
+libopencv_img_hash.so.407 libopencv-4.7.0_1
+libopencv_line_descriptor.so.407 libopencv-4.7.0_1
+libopencv_saliency.so.407 libopencv-4.7.0_1
+libopencv_structured_light.so.407 libopencv-4.7.0_1
+libopencv_aruco.so.407 libopencv-4.7.0_1
+libopencv_bgsegm.so.407 libopencv-4.7.0_1
+libopencv_bioinspired.so.407 libopencv-4.7.0_1
+libopencv_ccalib.so.407 libopencv-4.7.0_1
+libopencv_face.so.407 libopencv-4.7.0_1
+libopencv_tracking.so.407 libopencv-4.7.0_1
+libopencv_xfeatures2d.so.407 libopencv-4.7.0_1
+libopencv_optflow.so.407 libopencv-4.7.0_1
+libopencv_ximgproc.so.407 libopencv-4.7.0_1
+libopencv_plot.so.407 libopencv-4.7.0_1
+libopencv_text.so.407 libopencv-4.7.0_1
+libopencv_ml.so.407 libopencv-4.7.0_1
+libopencv_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn.so.407 libopencv-4.7.0_1
+libopencv_shape.so.407 libopencv-4.7.0_1
+libopencv_stitching.so.407 libopencv-4.7.0_1
+libopencv_photo.so.407 libopencv-4.7.0_1
+libopencv_video.so.407 libopencv-4.7.0_1
+libopencv_calib3d.so.407 libopencv-4.7.0_1
+libopencv_features2d.so.407 libopencv-4.7.0_1
+libopencv_flann.so.407 libopencv-4.7.0_1
+libopencv_highgui.so.407 libopencv-4.7.0_1
+libopencv_videoio.so.407 libopencv-4.7.0_1
+libopencv_imgcodecs.so.407 libopencv-4.7.0_1
+libopencv_imgproc.so.407 libopencv-4.7.0_1
+libopencv_core.so.407 libopencv-4.7.0_1
+libopencv_superres.so.407 libopencv-4.7.0_1
+libopencv_videostab.so.407 libopencv-4.7.0_1
+libopencv_gapi.so.407 libopencv-4.7.0_1
+libopencv_xobjdetect.so.407 libopencv-4.7.0_1
+libopencv_datasets.so.407 libopencv-4.7.0_1
+libopencv_dnn_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn_superres.so.407 libopencv-4.7.0_1
+libopencv_dpm.so.407 libopencv-4.7.0_1
+libopencv_phase_unwrapping.so.407 libopencv-4.7.0_1
+libopencv_stereo.so.407 libopencv-4.7.0_1
+libopencv_rapid.so.407 libopencv-4.7.0_1
+libopencv_intensity_transform.so.407 libopencv-4.7.0_1
+libopencv_alphamat.so.407 libopencv-4.7.0_1
+libopencv_barcode.so.407 libopencv-4.7.0_1
+libopencv_mcc.so.407 libopencv-4.7.0_1
 libuniconf.so.4.6 wvstreams-4.6.1_20
 libwvbase.so.4.6 wvstreams-4.6.1_20
 libwvutils.so.4.6 wvstreams-4.6.1_20
diff --git a/srcpkgs/opencv/template b/srcpkgs/opencv/template
index aea4bfc3a265cf..ce94de9424d18d 100644
--- a/srcpkgs/opencv/template
+++ b/srcpkgs/opencv/template
@@ -1,7 +1,7 @@
 # Template file for 'opencv'
 pkgname=opencv
-version=4.6.0
-revision=6
+version=4.7.0
+revision=1
 create_wrksrc=yes
 build_wrksrc=${pkgname}-${version}
 build_style=cmake
@@ -24,8 +24,8 @@ homepage="https://opencv.org"
 changelog="https://github.com/opencv/opencv/wiki/ChangeLog"
 distfiles="https://github.com/opencv/opencv/archive/${version}.tar.gz
  https://github.com/opencv/opencv_contrib/archive/${version}.tar.gz>contrib.tar.gz"
-checksum="1ec1cba65f9f20fe5a41fda1586e01c70ea0c9a6d7b67c9e13edf0cfe2239277
- 1777d5fd2b59029cf537e5fd6f8aa68d707075822f90bde683fcde086f85f7a7"
+checksum="8df0079cdbe179748a18d44731af62a245a45ebf5085223dc03133954c662973
+ 42df840cf9055e59d0e22c249cfb19f04743e1bdad113d31b1573d3934d62584"
 patch_args="-Np1 -d ${build_wrksrc}"
 # tests hang indenfinitely, even with test data included
 make_check=no

From 4b87462a4268919171180c69cad59764539f0760 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 006/110] actiona: revbump for opencv-4.7.0

---
 srcpkgs/actiona/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/actiona/template b/srcpkgs/actiona/template
index cf5f0b7a2ae610..0d899311e6df75 100644
--- a/srcpkgs/actiona/template
+++ b/srcpkgs/actiona/template
@@ -1,7 +1,7 @@
 # Template file for 'actiona'
 pkgname=actiona
 version=3.10.1
-revision=2
+revision=3
 build_style=qmake
 configure_args="PKGCONFIG_OPENCV=opencv4"
 hostmakedepends="pkg-config qt5-plugin-mysql qt5-qmake qt5-host-tools"

From 0a049728cd9d0b4f853c10e43bdf20515ca38629 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 007/110] retroshare: revbump for opencv-4.7.0

---
 srcpkgs/retroshare/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroshare/template b/srcpkgs/retroshare/template
index bb17569277a7f3..49e2c1cbe8a531 100644
--- a/srcpkgs/retroshare/template
+++ b/srcpkgs/retroshare/template
@@ -1,7 +1,7 @@
 # Template file for 'retroshare'
 pkgname=retroshare
 version=0.6.6
-revision=3
+revision=4
 build_style=qmake
 #XXX broadcast feature requires an ancient udp-discovery-cpp which either needs
 # to be fetched+patched (FTBFS) here or packaged :/

From eb0d4e099e50054d60820b3e4d522798ef593c7d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 008/110] waifu2x-converter-cpp: revbump for opencv-4.7.0

---
 srcpkgs/waifu2x-converter-cpp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waifu2x-converter-cpp/template b/srcpkgs/waifu2x-converter-cpp/template
index 361b8a23b94977..c5ac17eb54ea4c 100644
--- a/srcpkgs/waifu2x-converter-cpp/template
+++ b/srcpkgs/waifu2x-converter-cpp/template
@@ -1,7 +1,7 @@
 # Template file for 'waifu2x-converter-cpp'
 pkgname=waifu2x-converter-cpp
 version=5.2.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DINSTALL_MODELS=ON"
 hostmakedepends="pkg-config"

From c30743be2cfc5aa1c437b5d1f50c6f8017c0b946 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:38 -0400
Subject: [PATCH 009/110] vlc: revbump for ffmpeg4

---
 srcpkgs/vlc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/vlc/template b/srcpkgs/vlc/template
index 559b1c4fff339f..fc399f1a6e9bfc 100644
--- a/srcpkgs/vlc/template
+++ b/srcpkgs/vlc/template
@@ -1,7 +1,7 @@
 # Template file for 'vlc'
 pkgname=vlc
 version=3.0.20
-revision=4
+revision=5
 build_style=gnu-configure
 configure_args="--disable-gme --disable-libtar --enable-jack
  --enable-live555 --disable-fluidsynth --enable-dvdread
@@ -25,7 +25,7 @@ lib32disabled=yes
 hostmakedepends="automake libtool pkg-config flex gettext libgcrypt-devel
  live555-devel gettext-devel $(vopt_if lua lua52) $(vopt_if chromecast protobuf)"
 makedepends="
- avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg-devel freefont-ttf
+ avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg4-devel freefont-ttf
  gnutls-devel jack-devel liba52-devel libass-devel libbluray-devel
  libcdio-devel libdca-devel libdvbpsi-devel libdvdnav-devel libmad-devel
  libmatroska-devel libmodplug-devel libmpcdec-devel libmpeg2-devel

From a53c6ce74f673bff9b4e350f1f92ecfc238b7676 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:55 -0400
Subject: [PATCH 010/110] osg: revbump for ffmpeg4

---
 srcpkgs/osg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/osg/template b/srcpkgs/osg/template
index 8ef0efc599a1b1..a131ceaf7a867b 100644
--- a/srcpkgs/osg/template
+++ b/srcpkgs/osg/template
@@ -8,7 +8,7 @@ build_helper="qemu"
 configure_args="-DLIB_POSTFIX="
 hostmakedepends="pkg-config xrandr"
 makedepends="MesaLib-devel gtkglext-devel libcurl-devel giflib-devel librsvg-devel
- jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg-devel xine-lib-devel
+ jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg4-devel xine-lib-devel
  SDL2-devel gst-plugins-base1-devel
  $(vopt_if openexr libopenexr-devel)
  $(vopt_if poppler poppler-glib-devel)

From b086a906f756fa59cddc4312290e19fffef15c72 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:13 -0400
Subject: [PATCH 011/110] xine-lib: revbump for ffmpeg4

---
 srcpkgs/xine-lib/template | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/xine-lib/template b/srcpkgs/xine-lib/template
index 3be4d08eac77a3..ed6194c17d11e8 100644
--- a/srcpkgs/xine-lib/template
+++ b/srcpkgs/xine-lib/template
@@ -1,14 +1,14 @@
 # Template file for 'xine-lib'
 pkgname=xine-lib
-version=1.2.12
-revision=3
+version=1.2.13
+revision=1
 build_style=gnu-configure
 configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
  --disable-oss"
 hostmakedepends="automake gettext-devel libtool pkg-config perl"
 makedepends="
  zlib-devel alsa-lib-devel libxcb-devel libSM-devel libXext-devel libXv-devel
- libXvMC-devel liba52-devel libmad-devel ffmpeg-devel pulseaudio-devel
+ libXvMC-devel liba52-devel libmad-devel ffmpeg4-devel pulseaudio-devel
  jack-devel samba-devel libflac-devel libmodplug-devel libmpcdec-devel
  speex-devel libtheora-devel libvorbis-devel libdca-devel faad2-devel
  libcdio-devel libbluray-devel aalib-devel libcaca-devel libXinerama-devel
@@ -19,7 +19,7 @@ license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="http://www.xine-project.org"
 changelog="https://sourceforge.net/projects/xine/files/xine-lib/${version}/README.txt/view"
 distfiles="${SOURCEFORGE_SITE}/xine/${pkgname}-${version}.tar.xz"
-checksum=d606270468e1540c2a89c0d7f5fdf11e17ecc0c2698cc0bcb1065ff26abee098
+checksum=5f10d6d718a4a51c17ed1b32b031d4f9b80b061e8276535b2be31e5ac4b75e6f
 
 case "$XBPS_TARGET_MACHINE" in
 	i686-musl)

From 876c12d59ba4ac868d2fcdcc808c0c0c39eee9ac Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 012/110] attract: revbump for ffmpeg6

---
 srcpkgs/attract/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/attract/template b/srcpkgs/attract/template
index e769fb15456217..776cbe4ebd2c93 100644
--- a/srcpkgs/attract/template
+++ b/srcpkgs/attract/template
@@ -1,7 +1,7 @@
 # Template file for 'attract'
 pkgname=attract
 version=2.7.0
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="VERBOSE=1"
 make_use_env=yes

From 53f223f90ce1a337bf5b8607e6157baf6f7dfdbc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 013/110] aubio: revbump for ffmpeg6

---
 srcpkgs/aubio/patches/ffmpeg5.patch | 25 +++++++++++++++++++++++++
 srcpkgs/aubio/template              |  2 +-
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/aubio/patches/ffmpeg5.patch

diff --git a/srcpkgs/aubio/patches/ffmpeg5.patch b/srcpkgs/aubio/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..aace41a6e6d9a4
--- /dev/null
+++ b/srcpkgs/aubio/patches/ffmpeg5.patch
@@ -0,0 +1,25 @@
+From 8a05420e5dd8c7b8b2447f82dc919765876511b3 Mon Sep 17 00:00:00 2001
+From: Paul Brossier <piem@piem.org>
+Date: Tue, 25 Jan 2022 18:30:27 +0100
+Subject: [PATCH] [source_avcodec] define FF_API_LAVF_AVCTX for libavcodec >
+ 59, thx @berolinux (closes gh-353)
+
+---
+ src/io/source_avcodec.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/io/source_avcodec.c b/src/io/source_avcodec.c
+index e0ae93b5..1421bd9a 100644
+--- a/src/io/source_avcodec.c
++++ b/src/io/source_avcodec.c
+@@ -68,6 +68,10 @@
+ #define AUBIO_AVCODEC_MAX_BUFFER_SIZE AV_INPUT_BUFFER_MIN_SIZE
+ #endif
+ 
++#if LIBAVCODEC_VERSION_MAJOR >= 59
++#define FF_API_LAVF_AVCTX 1
++#endif
++
+ struct _aubio_source_avcodec_t {
+   uint_t hop_size;
+   uint_t samplerate;
diff --git a/srcpkgs/aubio/template b/srcpkgs/aubio/template
index ad1c4b25699178..7d875cc02541a7 100644
--- a/srcpkgs/aubio/template
+++ b/srcpkgs/aubio/template
@@ -1,7 +1,7 @@
 # Template file for 'aubio'
 pkgname=aubio
 version=0.4.9
-revision=1
+revision=2
 build_style=waf3
 # XXX lash, pure and swig support.
 hostmakedepends="pkg-config txt2man"

From 4f293341d99655cacab616a230f96a1d101b656e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 014/110] audacious-plugins: revbump for ffmpeg6

---
 .../audacious-plugins/patches/ffmpeg5.patch   | 43 +++++++++++++++++++
 srcpkgs/audacious-plugins/template            |  2 +-
 2 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/audacious-plugins/patches/ffmpeg5.patch

diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg5.patch b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..4e5e34099d71c4
--- /dev/null
+++ b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
@@ -0,0 +1,43 @@
+commit 298aa371c56c2f52c25a33d9bdec4918b11cebdc
+Author: tibequadorian <tibequadorian@posteo.de>
+Date:   Sat Mar 19 18:40:12 2022 +0100
+
+    audacious-plugins: rebuild against ffmpeg-5.0
+
+diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+new file mode 100644
+index 0000000000..617c11215b
+--- /dev/null
++++ b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+@@ -0,0 +1,31 @@
++From f60beb400eeb1e4778bbfd738bc4a4ccef3de539 Mon Sep 17 00:00:00 2001
++From: John Lindgren <john@jlindgren.net>
++Date: Sat, 5 Mar 2022 12:05:34 -0500
++Subject: [PATCH] Fix build with FFmpeg 5.0
++
++---
++ src/ffaudio/ffaudio-core.cc | 4 ++--
++ 1 file changed, 2 insertions(+), 2 deletions(-)
++
++diff --git a/src/ffaudio/ffaudio-core.cc b/src/ffaudio/ffaudio-core.cc
++index 16dc63e3a..a2b95fd6c 100644
++--- a/src/ffaudio/ffaudio-core.cc
+++++ b/src/ffaudio/ffaudio-core.cc
++@@ -274,7 +274,7 @@ static AVInputFormat * get_format_by_content (const char * name, VFSFile & file)
++         AVProbeData d = {name, buf, filled};
++         score = target;
++ 
++-        f = av_probe_input_format2 (& d, true, & score);
+++        f = (AVInputFormat *) av_probe_input_format2 (& d, true, & score);
++         if (f)
++             break;
++ 
++@@ -347,7 +347,7 @@ static bool find_codec (AVFormatContext * c, CodecInfo * cinfo)
++ #endif
++         if (stream && stream->codecpar && stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
++         {
++-            AVCodec * codec = avcodec_find_decoder (stream->codecpar->codec_id);
+++            AVCodec * codec = (AVCodec *) avcodec_find_decoder (stream->codecpar->codec_id);
++ 
++             if (codec)
++             {
diff --git a/srcpkgs/audacious-plugins/template b/srcpkgs/audacious-plugins/template
index 05e53a9adf78ff..4b1968e03de781 100644
--- a/srcpkgs/audacious-plugins/template
+++ b/srcpkgs/audacious-plugins/template
@@ -2,7 +2,7 @@
 #Keep in sync with audacious!
 pkgname=audacious-plugins
 version=4.3.1
-revision=3
+revision=4
 build_style=meson
 configure_args="$(vopt_bool gtk3 gtk) $(vopt_bool gtk3)
  $(vopt_bool qt) $(vopt_bool qt qt6)"

From e945c8c760152fbaf7ca0d7e8f397a7c7c47a1b6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 015/110] audacity: revbump for ffmpeg6

---
 srcpkgs/audacity/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/audacity/template b/srcpkgs/audacity/template
index 7b838119ab2611..84b49305edcef1 100644
--- a/srcpkgs/audacity/template
+++ b/srcpkgs/audacity/template
@@ -1,7 +1,7 @@
 # Template file for 'audacity'
 pkgname=audacity
 version=3.4.2
-revision=1
+revision=2
 build_style=cmake
 build_helper="cmake-wxWidgets-gtk3 qemu"
 configure_args="-Daudacity_use_ffmpeg=loaded -Daudacity_lib_preference=system

From 85a2b51412314e5c4c9f22be64fcf589d925a4d7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 016/110] avidemux: revbump for ffmpeg6

---
 srcpkgs/avidemux/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/avidemux/template b/srcpkgs/avidemux/template
index 253a0243e22599..557285982d2b8f 100644
--- a/srcpkgs/avidemux/template
+++ b/srcpkgs/avidemux/template
@@ -1,7 +1,7 @@
 # Template file for 'avidemux'
 pkgname=avidemux
 version=2.8.0
-revision=2
+revision=3
 # Can't be compiled for aarch64, arm* or mips*
 archs="x86_64* i686*"
 hostmakedepends="cmake pkg-config qt5-host-tools qt5-devel tar yasm"

From da9f394b9a409a14a614115371514247cc7eafb0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 017/110] blender: revbump for ffmpeg6

---
 srcpkgs/blender/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index 68787b76a26c18..e2e090e6dfa41c 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -1,7 +1,7 @@
 # Template file for 'blender'
 pkgname=blender
 version=4.0.2
-revision=2
+revision=3
 archs="x86_64* ppc64*"
 build_style="cmake"
 pycompile_dirs="usr/share/blender/${version%.*}/scripts"

From 8ae6d0e73f57efdaec530a2066eea3f2c5fc03f7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 018/110] cantata: revbump for ffmpeg6

---
 srcpkgs/cantata/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cantata/template b/srcpkgs/cantata/template
index 4b417d80d5c2da..8a90aaa4c07a2a 100644
--- a/srcpkgs/cantata/template
+++ b/srcpkgs/cantata/template
@@ -1,7 +1,7 @@
 # Template file for 'cantata'
 pkgname=cantata
 version=2.5.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools qt5-tools"
 makedepends="qt5-devel qt5-tools-devel qt5-svg-devel qt5-xmlpatterns-devel

From 1870b66cce88ae7bc211c7d6d85ca67f2aaab015 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 019/110] ccextractor: revbump for ffmpeg6

---
 ...5-and-tesseract-5-compatibility-1479.patch | 168 ++++++++++++++++++
 srcpkgs/ccextractor/template                  |   2 +-
 2 files changed, 169 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ccextractor/patches/0001-fix-ffmpeg-5-and-tesseract-5-compatibility-1479.patch

diff --git a/srcpkgs/ccextractor/patches/0001-fix-ffmpeg-5-and-tesseract-5-compatibility-1479.patch b/srcpkgs/ccextractor/patches/0001-fix-ffmpeg-5-and-tesseract-5-compatibility-1479.patch
new file mode 100644
index 00000000000000..bcab4890554b9a
--- /dev/null
+++ b/srcpkgs/ccextractor/patches/0001-fix-ffmpeg-5-and-tesseract-5-compatibility-1479.patch
@@ -0,0 +1,168 @@
+From b1cbfcea9b9c687143bf0d80bc179b563e99d025 Mon Sep 17 00:00:00 2001
+From: Prateek Sunal <prtksunal@gmail.com>
+Date: Thu, 9 Mar 2023 01:44:53 +0530
+Subject: [PATCH] fix: ffmpeg 5 and tesseract 5 compatibility (#1479)
+
+* fix: replace deprecated `codec` property with `codecpar`
+
+* fix: replace deprecated method `avcodec_decode_video2` with `avcodec_receive_frame` and `avcodec_send_packet`
+
+* Update CHANGES.TXT
+
+* fix: remove deprecated `av_register_all` function
+
+* fix: formatting
+
+* fix: add support for tesseract 5
+
+* fix: tesseract v5
+
+* fix: hardsubx codec context error
+
+* fix: lint const warning
+---
+ docs/CHANGES.TXT               |  1 +
+ src/lib_ccx/ffmpeg_intgr.c     |  7 +++---
+ src/lib_ccx/hardsubx.c         | 25 ++++++++++++------
+ src/lib_ccx/hardsubx_decoder.c | 27 ++++++++------------
+ src/lib_ccx/ocr.c              | 46 ++++++++++++----------------------
+ 5 files changed, 47 insertions(+), 59 deletions(-)
+
+diff --git a/src/lib_ccx/ffmpeg_intgr.c b/src/lib_ccx/ffmpeg_intgr.c
+index be988890..e6f21e20 100644
+--- a/src/lib_ccx/ffmpeg_intgr.c
++++ b/src/lib_ccx/ffmpeg_intgr.c
+@@ -66,7 +66,6 @@ void *init_ffmpeg(const char *path)
+ 	struct ffmpeg_ctx *ctx;
+ 	AVCodec *dec = NULL;
+ 	avcodec_register_all();
+-	av_register_all();
+ 
+ 	if (ccx_options.debug_mask & CCX_DMT_VERBOSE)
+ 		av_log_set_level(AV_LOG_INFO);
+@@ -133,7 +132,6 @@ int ff_get_ccframe(void *arg, unsigned char *data, int maxlen)
+ 	struct ffmpeg_ctx *ctx = arg;
+ 	int len = 0;
+ 	int ret = 0;
+-	int got_frame;
+ 	AVPacket packet;
+ 
+ 	ret = av_read_frame(ctx->ifmt, &packet);
+@@ -151,12 +149,13 @@ int ff_get_ccframe(void *arg, unsigned char *data, int maxlen)
+ 		return AVERROR(EAGAIN);
+ 	}
+ 
+-	ret = avcodec_decode_video2(ctx->dec_ctx, ctx->frame, &got_frame, &packet);
++	avcodec_send_packet(ctx->codec_ctx, &ctx->packet);
++	ret = avcodec_receive_frame(ctx->dec_ctx, ctx->frame);
+ 	if (ret < 0)
+ 	{
+ 		av_log(NULL, AV_LOG_ERROR, "unable to decode packet\n");
+ 	}
+-	else if (!got_frame)
++	else if (ret != 0)
+ 	{
+ 		return AVERROR(EAGAIN);
+ 	}
+diff --git a/src/lib_ccx/hardsubx.c b/src/lib_ccx/hardsubx.c
+index 411377f9..fb844c91 100644
+--- a/src/lib_ccx/hardsubx.c
++++ b/src/lib_ccx/hardsubx.c
+@@ -12,9 +12,6 @@
+
+ int hardsubx_process_data(struct lib_hardsubx_ctx *ctx)
+ {
+-	// Get the required media attributes and initialize structures
+-	av_register_all();
+-
+ 	if (avformat_open_input(&ctx->format_ctx, ctx->inputfile[0], NULL, NULL) != 0)
+ 	{
+ 		fatal(EXIT_READ_ERROR, "Error reading input file!\n");
+@@ -32,7 +29,7 @@
+ 	ctx->video_stream_id = -1;
+ 	for (int i = 0; i < ctx->format_ctx->nb_streams; i++)
+ 	{
+-		if (ctx->format_ctx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO)
++		if (ctx->format_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
+ 		{
+ 			ctx->video_stream_id = i;
+ 			break;
+@@ -43,8 +40,21 @@
+ 		fatal(EXIT_READ_ERROR, "Video Stream not found!\n");
+ 	}
+
+-	ctx->codec_ctx = ctx->format_ctx->streams[ctx->video_stream_id]->codec;
+-	ctx->codec = avcodec_find_decoder(ctx->codec_ctx->codec_id);
++	ctx->codec_ctx = avcodec_alloc_context3(NULL);
++	if (!ctx->codec_ctx)
++	{
++		    fatal(EXIT_NOT_ENOUGH_MEMORY, "Could not allocate codec context!\n");
++	}
++
++	// Assign codec parameters to codec context
++	if (avcodec_parameters_to_context(ctx->codec_ctx, ctx->format_ctx->streams[ctx->video_stream_id]->codecpar) < 0)
++	{
++		    fatal(EXIT_READ_ERROR, "Could not initialize codec context!\n");
++	}
++
++	// Find decoder for the codec context
++	ctx->codec = (AVCodec *)avcodec_find_decoder(ctx->codec_ctx->codec_id);
++
+ 	if (ctx->codec == NULL)
+ 	{
+ 		fatal(EXIT_READ_ERROR, "Input codec is not supported!\n");
+diff --git a/src/lib_ccx/hardsubx_decoder.c b/src/lib_ccx/hardsubx_decoder.c
+index bd9b0980..b5dfaec4 100644
+--- a/src/lib_ccx/hardsubx_decoder.c
++++ b/src/lib_ccx/hardsubx_decoder.c
+@@ -371,7 +371,6 @@
+ int hardsubx_process_frames_tickertext(struct lib_hardsubx_ctx *ctx, struct encoder_ctx *enc_ctx)
+ {
+ 	// Search for ticker text at the bottom of the screen, such as in Russia TV1 or stock prices
+-	int got_frame;
+ 	int cur_sec = 0, total_sec, progress;
+ 	int frame_number = 0;
+ 	char *ticker_text = NULL;
+@@ -382,8 +381,8 @@
+ 		{
+ 			frame_number++;
+ 			//Decode the video stream packet
+-			avcodec_decode_video2(ctx->codec_ctx, ctx->frame, &got_frame, &ctx->packet);
+-			if (got_frame && frame_number % 1000 == 0)
++      avcodec_send_packet(ctx->codec_ctx, &ctx->packet);
++      if (avcodec_receive_frame(ctx->codec_ctx, ctx->frame) == 0 && frame_number % 1000 == 0)
+ 			{
+ 				// sws_scale is used to convert the pixel format to RGB24 from all other cases
+ 				sws_scale(
+@@ -434,9 +433,8 @@
+ 			frame_number++;
+
+ 			//Decode the video stream packet
+-			avcodec_decode_video2(ctx->codec_ctx, ctx->frame, &got_frame, &ctx->packet);
+-
+-			if (got_frame && frame_number % 25 == 0)
++			avcodec_send_packet(ctx->codec_ctx, &ctx->packet);
++      if (avcodec_receive_frame(ctx->codec_ctx, ctx->frame) == 0 && frame_number % 25 == 0)
+ 			{
+ 				float diff = (float)convert_pts_to_ms(ctx->packet.pts - prev_packet_pts, ctx->format_ctx->streams[ctx->video_stream_id]->time_base);
+ 				if (fabsf(diff) < 1000 * ctx->min_sub_duration) //If the minimum duration of a subtitle line is exceeded, process packet
+@@ -548,7 +546,6 @@
+ {
+ 	// Do a binary search over the input video for faster processing
+ 	// printf("Duration: %d\n", (int)ctx->format_ctx->duration);
+-	int got_frame;
+ 	int seconds_time = 0;
+ 	for (seconds_time = 0; seconds_time < 20; seconds_time++)
+ 	{
+@@ -568,8 +565,9 @@
+ 			{
+ 				if (ctx->packet.stream_index == ctx->video_stream_id)
+ 				{
+-					avcodec_decode_video2(ctx->codec_ctx, ctx->frame, &got_frame, &ctx->packet);
+-					if (got_frame)
++          avcodec_send_packet(ctx->codec_ctx, &ctx->packet);
++          if (avcodec_receive_frame(ctx->codec_ctx, ctx->frame) == 0)
++
+ 					{
+ 						// printf("%d\n", seek_time);
+ 						if (ctx->packet.pts < seek_time)
diff --git a/srcpkgs/ccextractor/template b/srcpkgs/ccextractor/template
index 84059ffd02398a..a670758bcbe41b 100644
--- a/srcpkgs/ccextractor/template
+++ b/srcpkgs/ccextractor/template
@@ -1,7 +1,7 @@
 # Template file for 'ccextractor'
 pkgname=ccextractor
 version=0.93
-revision=2
+revision=3
 build_wrksrc="linux"
 build_style=gnu-configure
 configure_args="--enable-ocr --enable-hardsubx"

From 021fa9c42fac2cf9b1b7fae8dd6526dd87830376 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 020/110] chromaprint: revbump for ffmpeg6

---
 srcpkgs/chromaprint/patches/ffmpeg5.patch | 569 ++++++++++++++++++++++
 srcpkgs/chromaprint/template              |   2 +-
 2 files changed, 570 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromaprint/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromaprint/patches/ffmpeg5.patch b/srcpkgs/chromaprint/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..a9fd307a23c8a4
--- /dev/null
+++ b/srcpkgs/chromaprint/patches/ffmpeg5.patch
@@ -0,0 +1,569 @@
+From 8ccad6937177b1b92e40ab8f4447ea27bac009a7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= <lalinsky@gmail.com>
+Date: Fri, 4 Nov 2022 21:47:38 +0100
+Subject: [PATCH] Use FFmpeg 5.x (#120)
+
+* Use FFmpeg 5.1.2 for CI builds
+
+* Build on Ubuntu 20.04
+
+* Upgrade code to FFmpeg 5.x APIs
+
+* Only set FFmpeg include dirs if building tools
+
+* No longer needed
+
+* Use ubuntu 20.04
+---
+ .github/workflows/build.yml                   |   6 +-
+ CMakeLists.txt                                |  16 --
+ package/build.sh                              |   4 +-
+ src/audio/ffmpeg_audio_processor.h            |   2 -
+ src/audio/ffmpeg_audio_processor_avresample.h |  72 -------
+ src/audio/ffmpeg_audio_processor_swresample.h |  18 +-
+ src/audio/ffmpeg_audio_reader.h               | 197 +++++++++---------
+ tests/CMakeLists.txt                          |   6 +
+ 8 files changed, 122 insertions(+), 199 deletions(-)
+ delete mode 100644 src/audio/ffmpeg_audio_processor_avresample.h
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index f8d6a32..4da2405 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -84,9 +84,6 @@ find_package(FFmpeg)
+ if(FFMPEG_LIBRARIES)
+ 	cmake_push_check_state(RESET)
+ 	set(CMAKE_REQUIRED_LIBRARIES ${FFMPEG_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -lm)
+-	check_function_exists(av_packet_unref HAVE_AV_PACKET_UNREF)
+-	check_function_exists(av_frame_alloc HAVE_AV_FRAME_ALLOC)
+-	check_function_exists(av_frame_free HAVE_AV_FRAME_FREE)
+ 	cmake_pop_check_state()
+ endif()
+
+@@ -163,14 +160,11 @@ message(STATUS "Using ${FFT_LIB} for FFT calculations")
+ if(NOT AUDIO_PROCESSOR_LIB)
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+ 		set(AUDIO_PROCESSOR_LIB "swresample")
+-	elseif(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(AUDIO_PROCESSOR_LIB "avresample")
+ 	endif()
+ endif()
+
+ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE OFF)
+ 		set(USE_SWRESAMPLE ON)
+ 		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBSWRESAMPLE_LIBRARIES})
+ 		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBSWRESAMPLE_INCLUDE_DIRS})
+@@ -178,16 +172,6 @@ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+ 	endif()
+ 	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+-elseif(AUDIO_PROCESSOR_LIB STREQUAL "avresample")
+-	if(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE ON)
+-		set(USE_SWRESAMPLE OFF)
+-		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBAVRESAMPLE_LIBRARIES})
+-		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBAVRESAMPLE_INCLUDE_DIRS})
+-	else()
+-		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+-	endif()
+-	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+ else()
+ 	message(STATUS "Building without audio conversion support, please install FFmpeg with libswresample")
+ endif()
+diff --git a/package/build.sh b/package/build.sh
+index da631ae..b41d36e 100755
+--- a/package/build.sh
++++ b/package/build.sh
+@@ -7,8 +7,8 @@ set -eux
+
+ BASE_DIR=$(cd $(dirname $0)/.. && pwd)
+
+-FFMPEG_VERSION=4.4.1
+-FFMPEG_BUILD_TAG=v4.4.1-1
++FFMPEG_VERSION=5.1.2
++FFMPEG_BUILD_TAG=v${FFMPEG_VERSION}-1
+
+ TMP_BUILD_DIR=$BASE_DIR/$(mktemp -d build.XXXXXXXX)
+ trap 'rm -rf $TMP_BUILD_DIR' EXIT
+diff --git a/src/audio/ffmpeg_audio_processor.h b/src/audio/ffmpeg_audio_processor.h
+index 7628fc7..39f4f6d 100644
+--- a/src/audio/ffmpeg_audio_processor.h
++++ b/src/audio/ffmpeg_audio_processor.h
+@@ -10,8 +10,6 @@
+
+ #if defined(USE_SWRESAMPLE)
+ #include "audio/ffmpeg_audio_processor_swresample.h"
+-#elif defined(USE_AVRESAMPLE)
+-#include "audio/ffmpeg_audio_processor_avresample.h"
+ #else
+ #error "no audio processing library"
+ #endif
+diff --git a/src/audio/ffmpeg_audio_processor_avresample.h b/src/audio/ffmpeg_audio_processor_avresample.h
+deleted file mode 100644
+index bd85f92..0000000
+--- a/src/audio/ffmpeg_audio_processor_avresample.h
++++ /dev/null
+@@ -1,72 +0,0 @@
+-// Copyright (C) 2016  Lukas Lalinsky
+-// Distributed under the MIT license, see the LICENSE file for details.
+-
+-#ifndef CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-#define CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-
+-extern "C" {
+-#include <libavresample/avresample.h>
+-}
+-
+-namespace chromaprint {
+-
+-class FFmpegAudioProcessor {
+-public:
+-	FFmpegAudioProcessor() {
+-		m_resample_ctx = avresample_alloc_context();
+-	}
+-
+-	~FFmpegAudioProcessor() {
+-		avresample_free(&m_resample_ctx);
+-	}
+-
+-	void SetCompatibleMode() {
+-		av_opt_set_int(m_resample_ctx, "filter_size", 16, 0);
+-		av_opt_set_int(m_resample_ctx, "phase_shift", 8, 0);
+-		av_opt_set_int(m_resample_ctx, "linear_interp", 1, 0);
+-		av_opt_set_double(m_resample_ctx, "cutoff", 0.8, 0);
+-	}
+-
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "in_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_rate", sample_rate, 0);
+-	}
+-
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "out_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_rate, 0);
+-	}
+-
+-	int Init() {
+-		return avresample_open(m_resample_ctx);
+-	}
+-
+-	int Convert(uint8_t **out, int out_count, const uint8_t **in, int in_count) {
+-		return avresample_convert(m_resample_ctx, out, 0, out_count, (uint8_t **) in, 0, in_count);
+-	}
+-
+-	int Flush(uint8_t **out, int out_count) {
+-		return avresample_read(m_resample_ctx, out, out_count);
+-	}
+-
+-private:
+-	AVAudioResampleContext *m_resample_ctx = nullptr;
+-};
+-
+-}; // namespace chromaprint
+-
+-#endif
+diff --git a/src/audio/ffmpeg_audio_processor_swresample.h b/src/audio/ffmpeg_audio_processor_swresample.h
+index b86266b..b1d4bea 100644
+--- a/src/audio/ffmpeg_audio_processor_swresample.h
++++ b/src/audio/ffmpeg_audio_processor_swresample.h
+@@ -28,30 +28,28 @@ public:
+ 		av_opt_set_double(m_swr_ctx, "cutoff", 0.8, 0);
+ 	}
+
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "icl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "ich", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetInputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "in_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "isf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "in_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "isr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "in_sample_rate", sample_rate, 0);
+ 	}
+
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "ocl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "och", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetOutputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "out_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "osf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "out_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "osr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "out_sample_rate", sample_rate, 0);
+ 	}
+
+ 	int Init() {
+diff --git a/src/audio/ffmpeg_audio_reader.h b/src/audio/ffmpeg_audio_reader.h
+index 5550164..1c6b346 100644
+--- a/src/audio/ffmpeg_audio_reader.h
++++ b/src/audio/ffmpeg_audio_reader.h
+@@ -62,7 +62,7 @@ public:
+ 	bool Read(const int16_t **data, size_t *size);
+
+ 	bool IsOpen() const { return m_opened; }
+-	bool IsFinished() const { return m_finished && !m_got_frame; }
++	bool IsFinished() const { return !m_has_more_packets && !m_has_more_frames; }
+
+ 	std::string GetError() const { return m_error; }
+ 	int GetErrorCode() const { return m_error_code; }
+@@ -74,20 +74,19 @@ private:
+ 	uint8_t *m_convert_buffer[1] = { nullptr };
+ 	int m_convert_buffer_nb_samples = 0;
+
+-	AVInputFormat *m_input_fmt = nullptr;
++	const AVInputFormat *m_input_fmt = nullptr;
+ 	AVDictionary *m_input_opts = nullptr;
+
+ 	AVFormatContext *m_format_ctx = nullptr;
+ 	AVCodecContext *m_codec_ctx = nullptr;
+-	AVFrame *m_frame = nullptr;
+ 	int m_stream_index = -1;
+ 	std::string m_error;
+ 	int m_error_code = 0;
+-	bool m_finished = false;
+ 	bool m_opened = false;
+-	int m_got_frame = 0;
+-	AVPacket m_packet;
+-	AVPacket m_packet0;
++	bool m_has_more_packets = true;
++	bool m_has_more_frames = true;
++	AVPacket *m_packet = nullptr;
++	AVFrame *m_frame = nullptr;
+
+ 	int m_output_sample_rate = 0;
+ 	int m_output_channels = 0;
+@@ -98,19 +97,12 @@ private:
+
+ inline FFmpegAudioReader::FFmpegAudioReader() {
+ 	av_log_set_level(AV_LOG_QUIET);
+-
+-	av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
+ }
+
+ inline FFmpegAudioReader::~FFmpegAudioReader() {
+ 	Close();
+ 	av_dict_free(&m_input_opts);
+ 	av_freep(&m_convert_buffer[0]);
+-	av_packet_unref(&m_packet0);
+ }
+
+ inline bool FFmpegAudioReader::SetInputFormat(const char *name) {
+@@ -135,11 +127,10 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ 	Close();
+
+-    av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
++	m_packet = av_packet_alloc();
++	if (!m_packet) {
++		return false;
++	}
+
+ 	ret = avformat_open_input(&m_format_ctx, file_name.c_str(), m_input_fmt, &m_input_opts);
+ 	if (ret < 0) {
+@@ -153,26 +144,31 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		return false;
+ 	}
+
+-	AVCodec *codec;
++	const AVCodec *codec;
+ 	ret = av_find_best_stream(m_format_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &codec, 0);
+ 	if (ret < 0) {
+ 		SetError("Could not find any audio stream in the file", ret);
+ 		return false;
+ 	}
+ 	m_stream_index = ret;
++	auto stream = m_format_ctx->streams[m_stream_index];
+
+-	m_codec_ctx = m_format_ctx->streams[m_stream_index]->codec;
++	m_codec_ctx = avcodec_alloc_context3(codec);
+ 	m_codec_ctx->request_sample_fmt = AV_SAMPLE_FMT_S16;
+
++	ret = avcodec_parameters_to_context(m_codec_ctx, stream->codecpar);
++	if (ret < 0) {
++		SetError("Could not copy the stream parameters", ret);
++		return false;
++	}
++
+ 	ret = avcodec_open2(m_codec_ctx, codec, nullptr);
+ 	if (ret < 0) {
+ 		SetError("Could not open the codec", ret);
+ 		return false;
+ 	}
+
+-	if (!m_codec_ctx->channel_layout) {
+-		m_codec_ctx->channel_layout = av_get_default_channel_layout(m_codec_ctx->channels);
+-	}
++	av_dump_format(m_format_ctx, 0, "foo", 0);
+
+ 	m_frame = av_frame_alloc();
+ 	if (!m_frame) {
+@@ -183,19 +179,23 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		m_output_sample_rate = m_codec_ctx->sample_rate;
+ 	}
+
+-	if (!m_output_channels) {
+-		m_output_channels = m_codec_ctx->channels;
++	AVChannelLayout output_channel_layout;
++	if (m_output_channels) {
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
++	} else {
++		m_output_channels = m_codec_ctx->ch_layout.nb_channels;
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
+ 	}
+
+-	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
++	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->ch_layout.nb_channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
+ 		m_converter.reset(new FFmpegAudioProcessor());
+ 		m_converter->SetCompatibleMode();
+ 		m_converter->SetInputSampleFormat(m_codec_ctx->sample_fmt);
+ 		m_converter->SetInputSampleRate(m_codec_ctx->sample_rate);
+-		m_converter->SetInputChannelLayout(m_codec_ctx->channel_layout);
++		m_converter->SetInputChannelLayout(&(m_codec_ctx->ch_layout));
+ 		m_converter->SetOutputSampleFormat(AV_SAMPLE_FMT_S16);
+ 		m_converter->SetOutputSampleRate(m_output_sample_rate);
+-		m_converter->SetOutputChannelLayout(av_get_default_channel_layout(m_output_channels));
++		m_converter->SetOutputChannelLayout(&output_channel_layout);
+ 		auto ret = m_converter->Init();
+ 		if (ret != 0) {
+ 			SetError("Could not create an audio converter instance", ret);
+@@ -203,10 +203,11 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		}
+ 	}
+
++	av_channel_layout_uninit(&output_channel_layout);
++
+ 	m_opened = true;
+-	m_finished = false;
+-	m_got_frame = 0;
+-	m_nb_packets = 0;
++	m_has_more_packets = true;
++	m_has_more_frames = true;
+ 	m_decode_error = 0;
+
+ 	return true;
+@@ -214,6 +215,7 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ inline void FFmpegAudioReader::Close() {
+ 	av_frame_free(&m_frame);
++	av_packet_free(&m_packet);
+
+ 	m_stream_index = -1;
+
+@@ -252,91 +254,98 @@ inline bool FFmpegAudioReader::Read(const int16_t **data, size_t *size) {
+ 		return false;
+ 	}
+
++	*data = nullptr;
++	*size = 0;
++
+ 	int ret;
++	bool needs_packet = false;
+ 	while (true) {
+-		while (m_packet.size <= 0) {
+-			av_packet_unref(&m_packet0);
+-			av_init_packet(&m_packet);
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			ret = av_read_frame(m_format_ctx, &m_packet);
++		while (needs_packet && m_packet->size == 0) {
++			ret = av_read_frame(m_format_ctx, m_packet);
+ 			if (ret < 0) {
+ 				if (ret == AVERROR_EOF) {
+-					m_finished = true;
++					needs_packet = false;
++					m_has_more_packets = false;
+ 					break;
+-				} else {
++				}
++				SetError("Error reading from the audio source", ret);
++				return false;
++			}
++			if (m_packet->stream_index == m_stream_index) {
++				needs_packet = false;
++			} else {
++				av_packet_unref(m_packet);
++			}
++		}
++
++		if (m_packet->size != 0) {
++			ret = avcodec_send_packet(m_codec_ctx, m_packet);
++			if (ret < 0) {
++				if (ret != AVERROR(EAGAIN)) {
+ 					SetError("Error reading from the audio source", ret);
+ 					return false;
+ 				}
+-			}
+-			m_packet0 = m_packet;
+-			if (m_packet.stream_index != m_stream_index) {
+-				m_packet.data = nullptr;
+-				m_packet.size = 0;
+ 			} else {
+-				m_nb_packets++;
++				av_packet_unref(m_packet);
+ 			}
+ 		}
+
+-		ret = avcodec_decode_audio4(m_codec_ctx, m_frame, &m_got_frame, &m_packet);
++		ret = avcodec_receive_frame(m_codec_ctx, m_frame);
+ 		if (ret < 0) {
+-			if (m_decode_error) {
+-				SetError("Error decoding audio frame", m_decode_error);
+-				return false;
++			if (ret == AVERROR_EOF) {
++				m_has_more_frames = false;
++			} else if (ret == AVERROR(EAGAIN)) {
++				if (m_has_more_packets) {
++					needs_packet = true;
++					continue;
++				} else {
++					m_has_more_frames = false;
++				}
+ 			}
+-			m_decode_error = ret;
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			continue;
++			SetError("Error decoding the audio source", ret);
++			return false;
+ 		}
+
+-		break;
+-	}
+-
+-	m_decode_error = 0;
+-
+-	const int decoded = std::min(ret, m_packet.size);
+-	m_packet.data += decoded;
+-	m_packet.size -= decoded;
+-
+-	if (m_got_frame) {
+-		if (m_converter) {
+-			if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
+-				int linsize;
+-				av_freep(&m_convert_buffer[0]);
+-				m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
+-				ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
+-				if (ret < 0) {
+-					SetError("Couldn't allocate audio converter buffer", ret);
++		if (m_frame->nb_samples > 0) {
++			if (m_converter) {
++				if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
++					int linsize;
++					av_freep(&m_convert_buffer[0]);
++					m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
++					ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->ch_layout.nb_channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
++					if (ret < 0) {
++						SetError("Couldn't allocate audio converter buffer", ret);
++						return false;
++					}
++				}
++				auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
++				if (nb_samples < 0) {
++					SetError("Couldn't convert audio", ret);
+ 					return false;
+ 				}
+-			}
+-			auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			}
+-			*data = (const int16_t *) m_convert_buffer[0];
+-			*size = nb_samples;
+-		} else {
+-			*data = (const int16_t *) m_frame->data[0];
+-			*size = m_frame->nb_samples;
+-		}
+-	} else {
+-		if (m_finished && m_converter) {
+-			auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			} else if (nb_samples > 0) {
+-				m_got_frame = 1;
+ 				*data = (const int16_t *) m_convert_buffer[0];
+ 				*size = nb_samples;
++			} else {
++				*data = (const int16_t *) m_frame->data[0];
++				*size = m_frame->nb_samples;
++			}
++		} else {
++			if (m_converter) {
++				if (IsFinished()) {
++					auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
++					if (nb_samples < 0) {
++						SetError("Couldn't convert audio", ret);
++						return false;
++					} else if (nb_samples > 0) {
++						*data = (const int16_t *) m_convert_buffer[0];
++						*size = nb_samples;
++					}
++				}
+ 			}
+ 		}
+-	}
+
+-	return true;
++		return true;
++	}
+ }
+
+ inline void FFmpegAudioReader::SetError(const char *message, int errnum) {
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index a2b517b..123e643 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -38,6 +38,12 @@ set(SRCS
+
+ if(BUILD_TOOLS)
+ 	set(SRCS ${SRCS} ../src/audio/ffmpeg_audio_reader_test.cpp)
++    include_directories(
++        ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}
++        ${AUDIO_PROCESSOR_INCLUDE_DIRS}
++    )
+ 	link_libraries(fpcalc_libs)
+ endif()
+
+-- 
+2.38.1
+
+
diff --git a/srcpkgs/chromaprint/template b/srcpkgs/chromaprint/template
index 7ef7838949f3a3..1f7bbc70a22c80 100644
--- a/srcpkgs/chromaprint/template
+++ b/srcpkgs/chromaprint/template
@@ -1,7 +1,7 @@
 # Template file for 'chromaprint'
 pkgname=chromaprint
 version=1.5.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DBUILD_TOOLS=ON"
 make_check_target="check"

From 1d5a0eed2f27320b64f647f4f2239dd96f66a8bd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 021/110] chromium: revbump for ffmpeg6

---
 srcpkgs/chromium/patches/ffmpeg5.patch | 47 ++++++++++++++++++++++++++
 srcpkgs/chromium/template              |  2 +-
 2 files changed, 48 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..24e2da38e34ca2
--- /dev/null
+++ b/srcpkgs/chromium/patches/ffmpeg5.patch
@@ -0,0 +1,47 @@
+--- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
++++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
+@@ -92,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+-  if (stream->start_time != kNoFFmpegTimestamp)
++  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -1597,7 +1585,7 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+@@ -1618,7 +1606,7 @@
+     if (stream->type() != DemuxerStream::VIDEO)
+       continue;
+ 
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+ 
+     if (!stream->IsEnabled())
diff --git a/srcpkgs/chromium/template b/srcpkgs/chromium/template
index 53981f7cd367f8..b462de56fe3bf5 100644
--- a/srcpkgs/chromium/template
+++ b/srcpkgs/chromium/template
@@ -2,7 +2,7 @@
 pkgname=chromium
 # See https://chromiumdash.appspot.com/releases?platform=Linux for the latest version
 version=122.0.6261.94
-revision=1
+revision=2
 archs="i686* x86_64* aarch64* armv7l*"
 hostmakedepends="
  $(vopt_if clang "clang17 lld17 llvm17 compiler-rt")

From 89695d68e11c05eab930e647557e429a9ed06a06 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 022/110] cmus: revbump for ffmpeg6

---
 srcpkgs/chromium/patches/ffmpeg5.patch | 47 --------------------------
 srcpkgs/cmus/patches/ffmpeg6.patch     | 12 +++++++
 srcpkgs/cmus/template                  |  2 +-
 3 files changed, 13 insertions(+), 48 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch
 create mode 100644 srcpkgs/cmus/patches/ffmpeg6.patch

diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
deleted file mode 100644
index 24e2da38e34ca2..00000000000000
--- a/srcpkgs/chromium/patches/ffmpeg5.patch
+++ /dev/null
@@ -1,47 +0,0 @@
---- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
-+++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
-@@ -92,24 +92,12 @@
- 
- static base::TimeDelta ExtractStartTime(AVStream* stream) {
-   // The default start time is zero.
--  base::TimeDelta start_time;
-+  base::TimeDelta start_time = kNoTimestamp;
- 
-   // First try to use  the |start_time| value as is.
--  if (stream->start_time != kNoFFmpegTimestamp)
-+  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
-     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
- 
--  // Next try to use the first DTS value, for codecs where we know PTS == DTS
--  // (excludes all H26x codecs). The start time must be returned in PTS.
--  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
--      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
--      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
--      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
--    const base::TimeDelta first_pts =
--        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
--    if (first_pts < start_time)
--      start_time = first_pts;
--  }
--
-   return start_time;
- }
- 
-@@ -1597,7 +1585,7 @@
-   for (const auto& stream : streams_) {
-     if (!stream || stream->IsEnabled() != enabled)
-       continue;
--    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
-+    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
-       continue;
-     if (!lowest_start_time_stream ||
-         stream->start_time() < lowest_start_time_stream->start_time()) {
-@@ -1618,7 +1606,7 @@
-     if (stream->type() != DemuxerStream::VIDEO)
-       continue;
- 
--    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
-+    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
-       continue;
- 
-     if (!stream->IsEnabled())
diff --git a/srcpkgs/cmus/patches/ffmpeg6.patch b/srcpkgs/cmus/patches/ffmpeg6.patch
new file mode 100644
index 00000000000000..ffa95ab811101b
--- /dev/null
+++ b/srcpkgs/cmus/patches/ffmpeg6.patch
@@ -0,0 +1,12 @@
+--- a/ip/ffmpeg.c
++++ b/ip/ffmpeg.c
+@@ -202,9 +202,6 @@ static int ffmpeg_open(struct input_plugin_data *ip_data)
+ 			break;
+ 		}
+ 
+-		if (codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+-			cc->flags |= AV_CODEC_FLAG_TRUNCATED;
+-
+ 		if (avcodec_open2(cc, codec, NULL) < 0) {
+ 			d_print("could not open codec: %d, %s\n", cc->codec_id, avcodec_get_name(cc->codec_id));
+ 			err = -IP_ERROR_UNSUPPORTED_FILE_TYPE;
diff --git a/srcpkgs/cmus/template b/srcpkgs/cmus/template
index 0d1436744f1b2c..a6e4b4fa86cb83 100644
--- a/srcpkgs/cmus/template
+++ b/srcpkgs/cmus/template
@@ -1,7 +1,7 @@
 # Template file for 'cmus'
 pkgname=cmus
 version=2.10.0
-revision=3
+revision=4
 build_style=configure
 configure_args="prefix=/usr LD=$CC"
 hostmakedepends="pkg-config"

From 57729c73baebe776f98090efbcbb922d14b8ee59 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 023/110] cyanrip: revbump for ffmpeg6

---
 srcpkgs/cyanrip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cyanrip/template b/srcpkgs/cyanrip/template
index 9796e3461601a7..5db30e020d17ee 100644
--- a/srcpkgs/cyanrip/template
+++ b/srcpkgs/cyanrip/template
@@ -1,7 +1,7 @@
 # Template file for 'cyanrip'
 pkgname=cyanrip
 version=0.9.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config"
 makedepends="ffmpeg-devel libcdio-devel libcdio-paranoia-devel libcurl-devel libmusicbrainz5-devel"

From 078f925987602eaf5f11a09008b65055f8bde7c3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 024/110] deadbeef: revbump for ffmpeg4

---
 srcpkgs/deadbeef/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/deadbeef/template b/srcpkgs/deadbeef/template
index f5f4bf24b8cb6d..7b47e615cd48ef 100644
--- a/srcpkgs/deadbeef/template
+++ b/srcpkgs/deadbeef/template
@@ -1,14 +1,14 @@
 # Template file for 'deadbeef'
 pkgname=deadbeef
 version=1.8.8
-revision=3
+revision=4
 create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-oss --disable-lfm --disable-notify --disable-gtk2"
 hostmakedepends="automake libtool gettext gettext-devel intltool pkg-config
  yasm clang glib-devel"
 makedepends="
- alsa-lib-devel dbus-devel faad2-devel ffmpeg-devel gtk+3-devel imlib2-devel
+ alsa-lib-devel dbus-devel faad2-devel ffmpeg4-devel gtk+3-devel imlib2-devel
  jansson-devel libcddb-devel libcdio-devel libcurl-devel libflac-devel
  libmad-devel libpng-devel libsamplerate-devel libsndfile-devel libvorbis-devel
  libzip-devel mpg123-devel opusfile-devel pulseaudio-devel wavpack-devel"

From 1ccb2c2376c2bf178df128eb36d46e1d1c04999f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 025/110] droidcam-obs-plugin: revbump for ffmpeg6

---
 srcpkgs/droidcam-obs-plugin/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam-obs-plugin/template b/srcpkgs/droidcam-obs-plugin/template
index fc9c9bf6b9d54c..fb0480754df4de 100644
--- a/srcpkgs/droidcam-obs-plugin/template
+++ b/srcpkgs/droidcam-obs-plugin/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam-obs-plugin'
 pkgname=droidcam-obs-plugin
 version=2.0.1
-revision=1
+revision=2
 build_style=gnu-makefile
 make_use_env=yes
 make_build_args="ALLOW_STATIC=no"

From c58522e7553a271336fe9d5f333c61d36c9af39c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 026/110] droidcam: revbump for ffmpeg6

---
 srcpkgs/droidcam/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam/template b/srcpkgs/droidcam/template
index 1c3f1b8b1fc676..32a9220b79a4d1 100644
--- a/srcpkgs/droidcam/template
+++ b/srcpkgs/droidcam/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam'
 pkgname=droidcam
 version=1.8.2
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="USBMUXD=-lusbmuxd-2.0 JPEG=-lturbojpeg"
 hostmakedepends="pkg-config"

From 5d31cfb512e5636f10f2b39e515212001b467b63 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 027/110] ffmpegthumbnailer: revbump for ffmpeg6

---
 .../ffmpegthumbnailer/patches/ffmpeg6.patch   | 202 ++++++++++++++++++
 srcpkgs/ffmpegthumbnailer/template            |   6 +-
 2 files changed, 205 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch

diff --git a/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
new file mode 100644
index 00000000000000..363ff35a28419d
--- /dev/null
+++ b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
@@ -0,0 +1,202 @@
+--- a/libffmpegthumbnailer/moviedecoder.cpp	2017-11-21 14:06:57.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.cpp	2023-05-05 13:14:47.946560668 -0400
+@@ -41,11 +41,6 @@
+ namespace ffmpegthumbnailer
+ {
+ 
+-struct SilenceLogLevel
+-{
+-    SilenceLogLevel() { av_log_set_level(AV_LOG_QUIET); }
+-};
+-
+ MovieDecoder::MovieDecoder(AVFormatContext* pavContext)
+ : m_VideoStream(-1)
+ , m_pFormatContext(pavContext)
+@@ -70,8 +65,6 @@
+ 
+ void MovieDecoder::initialize(const string& filename, bool preferEmbeddedMetadata)
+ {
+-    av_register_all();
+-    avcodec_register_all();
+     avformat_network_init();
+ 
+     string inputFile = filename == "-" ? "pipe:" : filename;
+@@ -97,8 +90,7 @@
+ {
+     if (m_pVideoCodecContext)
+     {
+-        avcodec_close(m_pVideoCodecContext);
+-        m_pVideoCodecContext = nullptr;
++        avcodec_free_context(&m_pVideoCodecContext);
+     }
+ 
+     if ((!m_FormatContextWasGiven) && m_pFormatContext)
+@@ -152,10 +144,10 @@
+     for (unsigned int i = 0; i < m_pFormatContext->nb_streams; ++i)
+     {
+         AVStream *stream = m_pFormatContext->streams[i];
+-        auto ctx = m_pFormatContext->streams[i]->codec;
+-        if (ctx->codec_type == AVMEDIA_TYPE_VIDEO)
++        auto par = m_pFormatContext->streams[i]->codecpar;
++        if (par->codec_type == AVMEDIA_TYPE_VIDEO)
+         {
+-            if (!preferEmbeddedMetadata || !isStillImageCodec(ctx->codec_id))
++            if (!preferEmbeddedMetadata || !isStillImageCodec(par->codec_id))
+             {
+                 videoStreams.push_back(i);
+                 continue;
+@@ -203,8 +195,7 @@
+     }
+ 
+     m_pVideoStream = m_pFormatContext->streams[m_VideoStream];
+-    m_pVideoCodecContext = m_pVideoStream->codec;
+-    m_pVideoCodec = avcodec_find_decoder(m_pVideoCodecContext->codec_id);
++    m_pVideoCodec = avcodec_find_decoder(m_pVideoStream->codecpar->codec_id);
+ 
+     if (m_pVideoCodec == nullptr)
+     {
+@@ -214,6 +205,20 @@
+         throw logic_error("Video Codec not found");
+     }
+ 
++    m_pVideoCodecContext = avcodec_alloc_context3(m_pVideoCodec);
++
++    if (m_pVideoCodecContext == nullptr)
++    {
++        destroy();
++        throw logic_error("Could not allocate video codec context");
++    }
++
++    if (avcodec_parameters_to_context(m_pVideoCodecContext, m_pVideoStream->codecpar) < 0)
++    {
++        destroy();
++        throw logic_error("Could not configure video codec context");
++    }
++
+     m_pVideoCodecContext->workaround_bugs = 1;
+ 
+     if (avcodec_open2(m_pVideoCodecContext, m_pVideoCodec, nullptr) < 0)
+@@ -386,13 +391,6 @@
+ 
+ void MovieDecoder::initializeFilterGraph(const AVRational& timeBase, const std::string& size, bool maintainAspectRatio)
+ {
+-    static const AVPixelFormat pixelFormats[] = { AV_PIX_FMT_RGB24, AV_PIX_FMT_NONE };
+-
+-    auto del = [] (AVBufferSinkParams* p) { av_freep(p); };
+-    std::unique_ptr<AVBufferSinkParams, decltype(del)> buffersinkParams(av_buffersink_params_alloc(), del);
+-
+-    avfilter_register_all();
+-
+     m_pFilterGraph = avfilter_graph_alloc();
+     assert(m_pFilterGraph);
+ 
+@@ -404,10 +402,8 @@
+ 
+     checkRc(avfilter_graph_create_filter(&m_pFilterSource, avfilter_get_by_name("buffer"), "thumb_buffer", ss.str().c_str(), nullptr, m_pFilterGraph),
+             "Failed to create filter source");
+-    buffersinkParams->pixel_fmts = pixelFormats;
+-    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, buffersinkParams.get(), m_pFilterGraph),
++    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, nullptr, m_pFilterGraph),
+             "Failed to create filter sink");
+-    buffersinkParams.release();
+ 
+     AVFilterContext* yadifFilter = nullptr;
+     if (m_pFrame->interlaced_frame != 0)
+@@ -500,15 +496,15 @@
+     }
+ 
+     checkRc(av_seek_frame(m_pFormatContext, -1, timestamp, 0), "Seeking in video failed");
+-    avcodec_flush_buffers(m_pFormatContext->streams[m_VideoStream]->codec);
++    avcodec_flush_buffers(m_pVideoCodecContext);
+ 
+     int keyFrameAttempts = 0;
+-    bool gotFrame = 0;
++    bool gotFrame;
+ 
+     do
+     {
+         int count = 0;
+-        gotFrame = 0;
++        gotFrame = false;
+ 
+         while (!gotFrame && count < 20)
+         {
+@@ -552,17 +548,33 @@
+         return false;
+     }
+ 
+-    av_frame_unref(m_pFrame);
+-
+-    int frameFinished;
++    int rc = avcodec_send_packet(m_pVideoCodecContext, m_pPacket);
++    if(rc == AVERROR(EAGAIN))
++    {
++        rc = 0;
++    }
+ 
+-    int bytesDecoded = avcodec_decode_video2(m_pVideoCodecContext, m_pFrame, &frameFinished, m_pPacket);
+-    if (bytesDecoded < 0)
++    if(rc == AVERROR_EOF)
++    {
++        return false;
++    }
++    else if(rc < 0)
+     {
+-        throw logic_error("Failed to decode video frame: bytesDecoded < 0");
++        throw logic_error("Failed to decode video frame: avcodec_send_packet() < 0");
+     }
+ 
+-    return frameFinished > 0;
++    rc = avcodec_receive_frame(m_pVideoCodecContext, m_pFrame);
++    switch(rc)
++    {
++        case 0:
++            return true;
++
++        case AVERROR(EAGAIN):
++            return false;
++
++        default:
++            throw logic_error("Failed to decode video frame: avcodec_receive_frame() < 0");
++    }
+ }
+ 
+ bool MovieDecoder::getVideoPacket()
+@@ -570,8 +582,6 @@
+     bool framesAvailable = true;
+     bool frameDecoded = false;
+ 
+-    int attempts = 0;
+-
+     if (m_pPacket)
+     {
+         av_packet_unref(m_pPacket);
+@@ -580,6 +590,7 @@
+ 
+     m_pPacket = new AVPacket();
+ 
++
+     while (framesAvailable && !frameDecoded)
+     {
+         framesAvailable = av_read_frame(m_pFormatContext, m_pPacket) >= 0;
+@@ -644,7 +655,7 @@
+ 
+ int32_t MovieDecoder::getStreamRotation()
+ {
+-    int32_t* matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
++    auto matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
+     if (matrix)
+     {
+         auto angle = lround(av_display_rotation_get(matrix));
+
+--- a/libffmpegthumbnailer/moviedecoder.h	2017-11-12 04:23:38.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.h	2023-05-05 13:26:07.095529911 -0400
+@@ -78,7 +78,7 @@
+     int                     m_VideoStream;
+     AVFormatContext*        m_pFormatContext;
+     AVCodecContext*         m_pVideoCodecContext;
+-    AVCodec*                m_pVideoCodec;
++    const AVCodec*          m_pVideoCodec;
+     AVFilterGraph*          m_pFilterGraph;
+     AVFilterContext*        m_pFilterSource;
+     AVFilterContext*        m_pFilterSink;
diff --git a/srcpkgs/ffmpegthumbnailer/template b/srcpkgs/ffmpegthumbnailer/template
index 039eea7622b391..35d546018d12af 100644
--- a/srcpkgs/ffmpegthumbnailer/template
+++ b/srcpkgs/ffmpegthumbnailer/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbnailer'
 pkgname=ffmpegthumbnailer
 version=2.2.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libpng-devel libjpeg-turbo-devel ffmpeg-devel"
@@ -9,8 +9,8 @@ depends="ffmpeg"
 short_desc="Lightweight video thumbnailer"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
-homepage="https://github.com/dirkvdb/${pkgname}"
-distfiles="${homepage}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
+homepage="https://github.com/dirkvdb"
+distfiles="${homepage}/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
 checksum=1cb24059c38223f657b300c84dd80491b7040d4b69471c4fea69be862bc99b5b
 
 post_install() {

From 696c07d158964e4c3daff2a328f58ad1326fe227 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 028/110] ffmpegthumbs: revbump for ffmpeg6

---
 srcpkgs/ffmpegthumbs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ffmpegthumbs/template b/srcpkgs/ffmpegthumbs/template
index 2e2a96de83ce8a..dfd7e9dede36d3 100644
--- a/srcpkgs/ffmpegthumbs/template
+++ b/srcpkgs/ffmpegthumbs/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbs'
 pkgname=ffmpegthumbs
 version=23.08.5
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules kcoreaddons kconfig-devel
  pkg-config qt5-host-tools qt5-qmake gettext"

From cea701a0f583e65a945e41c09e795b5f629c6937 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 029/110] ffms2: revbump for ffmpeg6

---
 srcpkgs/ffms2/patches/ffmpeg5.patch | 424 ++++++++++++++++++++++++++++
 srcpkgs/ffms2/template              |   2 +-
 2 files changed, 425 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ffms2/patches/ffmpeg5.patch

diff --git a/srcpkgs/ffms2/patches/ffmpeg5.patch b/srcpkgs/ffms2/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..1479fabcafcb4e
--- /dev/null
+++ b/srcpkgs/ffms2/patches/ffmpeg5.patch
@@ -0,0 +1,424 @@
+From 45673149e9a2f5586855ad472e3059084eaa36b1 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:41:21 +0100
+Subject: [PATCH] Use auto for AVCodec
+
+The geniuses over at FFmpeg decided to constify this API, so old
+versions of the library will return AVCodec *, while new versions
+of the libary will return const AVCodec *, which, in C++, are not
+OK to convert between.
+
+Rather than use some macro hell in ffmscompat.h, we can work around
+this by using auto.
+
+Gross.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 2 +-
+ src/core/indexing.cpp    | 6 +++---
+ src/core/videosource.cpp | 2 +-
+ 3 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index e4ce97c..ac09666 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -469,7 +469,7 @@ void FFMS_AudioSource::OpenFile() {
+ 
+     LAVFOpenFile(SourceFile.c_str(), FormatContext, TrackNumber);
+ 
+-    AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
++    auto *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
+     if (Codec == nullptr)
+         throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+             "Audio codec not found");
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index e547c5a..59fb4e8 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -384,7 +384,7 @@ FFMS_TrackType FFMS_Indexer::GetTrackType(int Track) {
+ }
+ 
+ const char *FFMS_Indexer::GetTrackCodec(int Track) {
+-    AVCodec *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
++    auto *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
+     return codec ? codec->name : nullptr;
+ }
+ 
+@@ -402,7 +402,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             UseDTS);
+ 
+         if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            AVCodec *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (!VideoCodec) {
+                 FormatContext->streams[i]->discard = AVDISCARD_ALL;
+                 IndexMask.erase(i);
+@@ -433,7 +433,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 IndexMask.insert(i);
+             }
+         } else if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+-            AVCodec *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (AudioCodec == nullptr)
+                 throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_UNSUPPORTED,
+                     "Audio codec not found");
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index b889970..8956c22 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -171,7 +171,7 @@ FFMS_VideoSource::FFMS_VideoSource(const char *SourceFile, FFMS_Index &Index, in
+ 
+         LAVFOpenFile(SourceFile, FormatContext, VideoTrack);
+ 
+-        AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
++        auto *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
+         if (Codec == nullptr)
+             throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+                 "Video codec not found");
+-- 
+2.40.0
+
+From 96cbf38ea9381829a1314f432a2c60495dcefaad Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:12:41 +0100
+Subject: [PATCH] all: Update AVPacket API usage
+
+AVPackets must all be on the heap now, since it is no longer
+part of the libav* ABI.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 16 ++++++----
+ src/core/indexing.cpp    | 63 ++++++++++++++++++++++------------------
+ src/core/indexing.h      |  4 +--
+ src/core/utils.cpp       |  6 ----
+ src/core/utils.h         |  1 -
+ src/core/videosource.cpp | 30 ++++++++++---------
+ 6 files changed, 64 insertions(+), 56 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index 37cf9ae..e4ce97c 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -285,10 +285,15 @@ FFMS_AudioSource::AudioBlock *FFMS_AudioSource::CacheBlock(CacheIterator &pos) {
+ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     CurrentFrame = &Frames[PacketNumber];
+ 
+-    AVPacket Packet;
+-    if (!ReadPacket(&Packet))
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++    if (!ReadPacket(Packet)) {
++        av_packet_free(&Packet);
+         throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_UNKNOWN,
+             "ReadPacket unexpectedly failed to read a packet");
++    }
+ 
+     // ReadPacket may have changed the packet number
+     CurrentFrame = &Frames[PacketNumber];
+@@ -297,8 +302,9 @@ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     int NumberOfSamples = 0;
+     AudioBlock *CachedBlock = nullptr;
+     
+-    int Ret = avcodec_send_packet(CodecContext, &Packet);
+-    av_packet_unref(&Packet);
++    int Ret = avcodec_send_packet(CodecContext, Packet);
++    av_packet_unref(Packet);
++    av_packet_free(&Packet);
+ 
+     av_frame_unref(DecodeFrame);
+     Ret = avcodec_receive_frame(CodecContext, DecodeFrame);
+@@ -513,8 +519,6 @@ void FFMS_AudioSource::Seek() {
+ }
+ 
+ bool FFMS_AudioSource::ReadPacket(AVPacket *Packet) {
+-    InitNullPacket(*Packet);
+-
+     while (av_read_frame(FormatContext, Packet) >= 0) {
+         if (Packet->stream_index == TrackNumber) {
+             // Required because not all audio packets, especially in ogg, have a pts. Use the previous valid packet's pts instead.
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index 23fb95b..e547c5a 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -320,7 +320,7 @@ void FFMS_Indexer::CheckAudioProperties(int Track, AVCodecContext *Context) {
+     }
+ }
+ 
+-void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict,
++void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict,
+                                     int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct) {
+     if (VideoContext.Parser) {
+         uint8_t *OB;
+@@ -330,8 +330,8 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+         av_parser_parse2(VideoContext.Parser,
+             VideoContext.CodecContext,
+             &OB, &OBSize,
+-            pkt.data, pkt.size,
+-            pkt.pts, pkt.dts, pkt.pos);
++            pkt->data, pkt->size,
++            pkt->pts, pkt->dts, pkt->pos);
+ 
+         // H.264 (PAFF) and HEVC may have one field per packet, so we need to track
+         // when we have a full or half frame available, and mark one of them as
+@@ -351,15 +351,15 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+ 
+         *RepeatPict = VideoContext.Parser->repeat_pict;
+         *FrameType = VideoContext.Parser->pict_type;
+-        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt.flags & AV_PKT_FLAG_DISCARD));
++        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt->flags & AV_PKT_FLAG_DISCARD));
+     } else {
+-        *Invisible = !!(pkt.flags & AV_PKT_FLAG_DISCARD);
++        *Invisible = !!(pkt->flags & AV_PKT_FLAG_DISCARD);
+     }
+ 
+     if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP8)
+-        ParseVP8(pkt.data[0], Invisible, FrameType);
++        ParseVP8(pkt->data[0], Invisible, FrameType);
+     else if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP9)
+-        ParseVP9(pkt.data[0], Invisible, FrameType);
++        ParseVP9(pkt->data[0], Invisible, FrameType);
+ }
+ 
+ void FFMS_Indexer::Free() {
+@@ -458,32 +458,36 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+         }
+     }
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
+     std::vector<int64_t> LastValidTS(FormatContext->nb_streams, AV_NOPTS_VALUE);
+ 
+     int64_t filesize = avio_size(FormatContext->pb);
+     enum AVPictureStructure LastPicStruct = AV_PICTURE_STRUCTURE_UNKNOWN;
+-    while (av_read_frame(FormatContext, &Packet) >= 0) {
++    while (av_read_frame(FormatContext, Packet) >= 0) {
+         // Update progress
+         // FormatContext->pb can apparently be NULL when opening images.
+         if (IC && FormatContext->pb) {
+-            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate))
++            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate)) {
++                av_packet_free(&Packet);
+                 throw FFMS_Exception(FFMS_ERROR_CANCELLED, FFMS_ERROR_USER,
+                     "Cancelled by user");
++            }
+         }
+-        if (!IndexMask.count(Packet.stream_index)) {
+-            av_packet_unref(&Packet);
++        if (!IndexMask.count(Packet->stream_index)) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+-        int Track = Packet.stream_index;
++        int Track = Packet->stream_index;
+         FFMS_Track &TrackInfo = (*TrackIndices)[Track];
+-        bool KeyFrame = !!(Packet.flags & AV_PKT_FLAG_KEY);
++        bool KeyFrame = !!(Packet->flags & AV_PKT_FLAG_KEY);
+         ReadTS(Packet, LastValidTS[Track], (*TrackIndices)[Track].UseDTS);
+ 
+         if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            int64_t PTS = TrackInfo.UseDTS ? Packet.dts : Packet.pts;
++            int64_t PTS = TrackInfo.UseDTS ? Packet->dts : Packet->pts;
+             if (PTS == AV_NOPTS_VALUE) {
+                 // VPx alt-refs are output as packets which lack timestmps or durations, since
+                 // they are invisible. Currently, the timestamp mangling code in libavformat
+@@ -495,9 +499,11 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 // FFMS2 currently sorts packets by PTS, which will break decoding, otherwise.
+                 bool HasAltRefs = (FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP8 ||
+                                    FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP9);
+-                if (Packet.duration == 0 && !HasAltRefs)
++                if (Packet->duration == 0 && !HasAltRefs) {
++                    av_packet_free(&Packet);
+                     throw FFMS_Exception(FFMS_ERROR_INDEXING, FFMS_ERROR_PARSER,
+                         "Invalid packet pts, dts, and duration");
++                }
+ 
+                 if (TrackInfo.empty())
+                     PTS = 0;
+@@ -513,7 +519,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             ParseVideoPacket(AVContexts[Track], Packet, &RepeatPict, &FrameType, &Invisible, &LastPicStruct);
+ 
+             TrackInfo.AddVideoFrame(PTS, RepeatPict, KeyFrame,
+-                FrameType, Packet.pos, Invisible);
++                FrameType, Packet->pos, Invisible);
+         } else if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+             // For video seeking timestamps are used only if all packets have
+             // timestamps, while for audio they're used if any have timestamps,
+@@ -522,28 +528,29 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 TrackInfo.HasTS = true;
+ 
+             int64_t StartSample = AVContexts[Track].CurrentSample;
+-            uint32_t SampleCount = IndexAudioPacket(Track, &Packet, AVContexts[Track], *TrackIndices);
++            uint32_t SampleCount = IndexAudioPacket(Track, Packet, AVContexts[Track], *TrackIndices);
+             TrackInfo.SampleRate = AVContexts[Track].CodecContext->sample_rate;
+ 
+             TrackInfo.AddAudioFrame(LastValidTS[Track],
+-                StartSample, SampleCount, KeyFrame, Packet.pos, Packet.flags & AV_PKT_FLAG_DISCARD);
++                StartSample, SampleCount, KeyFrame, Packet->pos, Packet->flags & AV_PKT_FLAG_DISCARD);
+         }
+ 
+-        if (!(Packet.flags & AV_PKT_FLAG_DISCARD))
+-            TrackInfo.LastDuration = Packet.duration;
++        if (!(Packet->flags & AV_PKT_FLAG_DISCARD))
++            TrackInfo.LastDuration = Packet->duration;
+ 
+-        av_packet_unref(&Packet);
++        av_packet_unref(Packet);
+     }
++    av_packet_free(&Packet);
+ 
+     TrackIndices->Finalize(AVContexts, FormatContext->iformat->name);
+     return TrackIndices.release();
+ }
+ 
+-void FFMS_Indexer::ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS) {
+-    if (!UseDTS && Packet.pts != AV_NOPTS_VALUE)
+-        TS = Packet.pts;
++void FFMS_Indexer::ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS) {
++    if (!UseDTS && Packet->pts != AV_NOPTS_VALUE)
++        TS = Packet->pts;
+     if (TS == AV_NOPTS_VALUE)
+         UseDTS = true;
+-    if (UseDTS && Packet.dts != AV_NOPTS_VALUE)
+-        TS = Packet.dts;
++    if (UseDTS && Packet->dts != AV_NOPTS_VALUE)
++        TS = Packet->dts;
+ }
+diff --git a/src/core/indexing.h b/src/core/indexing.h
+index 3cfc3c3..5c06868 100644
+--- a/src/core/indexing.h
++++ b/src/core/indexing.h
+@@ -80,10 +80,10 @@ private:
+     int64_t Filesize;
+     uint8_t Digest[20];
+ 
+-    void ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS);
++    void ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS);
+     void CheckAudioProperties(int Track, AVCodecContext *Context);
+     uint32_t IndexAudioPacket(int Track, AVPacket *Packet, SharedAVContext &Context, FFMS_Index &TrackIndices);
+-    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
++    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
+     void Free();
+ public:
+     FFMS_Indexer(const char *Filename);
+diff --git a/src/core/utils.cpp b/src/core/utils.cpp
+index ce67533..8a2e997 100644
+--- a/src/core/utils.cpp
++++ b/src/core/utils.cpp
+@@ -62,12 +62,6 @@ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo) {
+     }
+ }
+ 
+-void InitNullPacket(AVPacket &pkt) {
+-    av_init_packet(&pkt);
+-    pkt.data = nullptr;
+-    pkt.size = 0;
+-}
+-
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames) {
+     AP.SampleFormat = static_cast<FFMS_SampleFormat>(av_get_packed_sample_fmt(CTX->sample_fmt));
+     AP.BitsPerSample = av_get_bytes_per_sample(CTX->sample_fmt) * 8;
+diff --git a/src/core/utils.h b/src/core/utils.h
+index 9819dc7..003ab79 100644
+--- a/src/core/utils.h
++++ b/src/core/utils.h
+@@ -58,7 +58,6 @@ std::unique_ptr<T> make_unique(Args&&... args) {
+ }
+ 
+ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo);
+-void InitNullPacket(AVPacket &pkt);
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames);
+ 
+ void LAVFOpenFile(const char *SourceFile, AVFormatContext *&FormatContext, int Track);
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index 06bd161..b889970 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -673,30 +673,34 @@ void FFMS_VideoSource::DecodeNextFrame(int64_t &AStartTime, int64_t &Pos) {
+     if (HasPendingDelayedFrames())
+         return;
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
+-
+-    while (ReadFrame(&Packet) >= 0) {
+-        if (Packet.stream_index != VideoTrack) {
+-            av_packet_unref(&Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++
++    while (ReadFrame(Packet) >= 0) {
++        if (Packet->stream_index != VideoTrack) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+         if (AStartTime < 0)
+-            AStartTime = Frames.UseDTS ? Packet.dts : Packet.pts;
++            AStartTime = Frames.UseDTS ? Packet->dts : Packet->pts;
+ 
+         if (Pos < 0)
+-            Pos = Packet.pos;
++            Pos = Packet->pos;
+ 
+-        bool FrameFinished = DecodePacket(&Packet);
+-        av_packet_unref(&Packet);
+-        if (FrameFinished)
++        bool FrameFinished = DecodePacket(Packet);
++        av_packet_unref(Packet);
++        if (FrameFinished) {
++            av_packet_free(&Packet);
+             return;
++        }
+     }
+ 
+     // Flush final frames
+-    InitNullPacket(Packet);
+-    DecodePacket(&Packet);
++    DecodePacket(Packet);
++    av_packet_free(&Packet);
+ }
+ 
+ bool FFMS_VideoSource::SeekTo(int n, int SeekOffset) {
+-- 
+2.40.0
+
+From bf9e03e9e08534c024e5a744a6437c4aac160201 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:20:47 +0100
+Subject: [PATCH 2/3] configure: Remove deprecated API use
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ configure.ac | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index b35ef80bc..d19714d0f 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -102,10 +102,10 @@ CFLAGS="$_CFLAGS $FFMPEG_CFLAGS"
+
+ AC_DEFUN([TEST_FFMPEG],
+          [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+-            #include <libavcodec/avcodec.h>
++            #include <libavformat/avformat.h>
+             #include <libswscale/swscale.h>
+             ]],[[
+-                avcodec_register_all();
++                avformat_network_init();
+                 swscale_version();
+             ]])], [eval $1=yes], [eval $1=no])
+         ])
+
diff --git a/srcpkgs/ffms2/template b/srcpkgs/ffms2/template
index 365f64d10cbabf..1641ecf43be5bb 100644
--- a/srcpkgs/ffms2/template
+++ b/srcpkgs/ffms2/template
@@ -1,7 +1,7 @@
 # Template file for 'ffms2'
 pkgname=ffms2
 version=2.40
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-shared --disable-static"
 hostmakedepends="pkg-config autoconf automake libtool"

From d63f4d61a33b7edcfb9c9fa5b90709291df44749 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 030/110] freerdp: revbump for ffmpeg6

---
 .../freerdp/patches/ffmpeg6_aa2cb9aa.patch    | 42 +++++++++++++++++++
 srcpkgs/freerdp/template                      |  2 +-
 2 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch

diff --git a/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
new file mode 100644
index 00000000000000..a4324da3a8822b
--- /dev/null
+++ b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
@@ -0,0 +1,42 @@
+From aa2cb9aa5ff5562433598ba168a466e0752bca0e Mon Sep 17 00:00:00 2001
+From: akallabeth <akallabeth@posteo.net>
+Date: Tue, 14 Feb 2023 07:48:54 +0100
+Subject: [PATCH] Fixed #8686: Update h264 to use new FFMPEG API
+
+---
+ channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c | 2 ++
+ libfreerdp/codec/h264_ffmpeg.c            | 2 ++
+ 2 files changed, 4 insertions(+)
+
+diff --git a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+index 339462d865f..beea80b7a1e 100644
+--- a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
++++ b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+@@ -239,8 +239,10 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYP
+ 		}
+ 	}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 	if (mdecoder->codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		mdecoder->codec_context->flags |= AV_CODEC_FLAG_TRUNCATED;
++#endif
+ 
+ 	return TRUE;
+ }
+diff --git a/libfreerdp/codec/h264_ffmpeg.c b/libfreerdp/codec/h264_ffmpeg.c
+index 8a23db2473c..896a333019b 100644
+--- a/libfreerdp/codec/h264_ffmpeg.c
++++ b/libfreerdp/codec/h264_ffmpeg.c
+@@ -615,10 +615,12 @@ static BOOL libavcodec_init(H264_CONTEXT* h264)
+ 			goto EXCEPTION;
+ 		}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 		if (sys->codecDecoder->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		{
+ 			sys->codecDecoderContext->flags |= AV_CODEC_FLAG_TRUNCATED;
+ 		}
++#endif
+ 
+ #ifdef WITH_VAAPI
+ 
diff --git a/srcpkgs/freerdp/template b/srcpkgs/freerdp/template
index 16fddfbe8f5287..bf3a4d2e2b3ae7 100644
--- a/srcpkgs/freerdp/template
+++ b/srcpkgs/freerdp/template
@@ -1,7 +1,7 @@
 # Template file for 'freerdp'
 pkgname=freerdp
 version=2.11.4
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_ALSA=ON -DWITH_CUPS=OFF -DWITH_FFMPEG=ON
  -DWITH_GSTREAMER_0_10=OFF -DWITH_GSTREAMER_1_0=OFF -DWITH_JPEG=ON

From 96d60ec532bbe6acffa349ac8ebc097bacb50b2c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 031/110] gerbera: revbump for ffmpeg6

---
 srcpkgs/gerbera/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gerbera/template b/srcpkgs/gerbera/template
index ae14f35c767c03..2dc0ac0ce03b55 100644
--- a/srcpkgs/gerbera/template
+++ b/srcpkgs/gerbera/template
@@ -1,7 +1,7 @@
 # Template file for 'gerbera'
 pkgname=gerbera
 version=1.12.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_SYSTEMD=0 -DWITH_AVCODEC=1"
 hostmakedepends="pkg-config"

From 0fc3380ba2f13b175b8947b7f73be8fe744b27b5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 032/110] goldendict: revbump for ffmpeg6

---
 srcpkgs/goldendict/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/goldendict/template b/srcpkgs/goldendict/template
index f4a05759f693d3..97f44347b03a6a 100644
--- a/srcpkgs/goldendict/template
+++ b/srcpkgs/goldendict/template
@@ -1,7 +1,7 @@
 # Template file for 'goldendict'
 pkgname=goldendict
 version=1.5.0
-revision=1
+revision=2
 build_style=qmake
 configure_args="CONFIG+=zim_support goldendict.pro"
 hostmakedepends="qt5-qmake pkg-config qt5-host-tools"
@@ -10,7 +10,7 @@ makedepends="tiff-devel qt5-devel libvorbis-devel zlib-devel
  qt5-webkit-devel lzo-devel bzip2-devel libao-devel qt5-svg-devel
  libeb-devel qt5-x11extras-devel ffmpeg-devel liblzma-devel
  qt5-multimedia-devel"
-short_desc="A feature-rich dictionary lookup program"
+short_desc="Feature-rich dictionary lookup program"
 maintainer="John <me@johnnynator.dev>"
 license="GPL-3.0-or-later"
 homepage="http://goldendict.org/"

From 3aea37c87381335bab828b9ac9def5fbd6eccdd2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 033/110] gst-libav: revbump for ffmpeg6

---
 srcpkgs/gst-libav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index b24be23fc1a6d2..0f9350a251bf67 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.22.9
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"

From d936cb57f0f301daabe57a80cb926ecf52a30252 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Feb 2024 01:52:46 -0500
Subject: [PATCH 034/110] gst-plugins-bad1: revbump for ffmpeg6

---
 srcpkgs/gst-plugins-bad1/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index dc4db910c43e84..b3db9c0ab0829f 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-plugins-bad1'
 pkgname=gst-plugins-bad1
 version=1.22.9
-revision=2
+revision=3
 build_helper="gir"
 build_style=meson
 configure_args="-Dpackage-origin=https://voidlinux.org -Ddoc=disabled
@@ -27,7 +27,7 @@ makedepends="alsa-lib-devel celt-devel openssl-devel exempi-devel
  fdk-aac-devel flite-devel fluidsynth-devel liblrdf-devel ladspa-sdk
  lilv-devel lv2 libopenjpeg2-devel sbc-devel spandsp-devel vulkan-loader
  Vulkan-Headers webrtc-audio-processing-devel libzbar-devel ffmpeg-devel
- srt-devel libva-devel
+ srt-devel libva-devel oneVPL-devel
  $(vopt_if gme libgme-devel)"
 depends="gst-plugins-base1>=${version}"
 short_desc="GStreamer plugins from the bad set (v1.x)"

From 4c3631d5529696b2a6240a65ab5be36aacc8a371 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 035/110] gst-rtsp-server: revbump for ffmpeg6

---
 srcpkgs/gst-rtsp-server/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index bc2a0dea6ac152..f77026c618eb69 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
 version=1.22.9
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="glib-devel gst-plugins-bad1-devel gobject-introspection

From beaee8e0c056ea768c7b3288c0f348c856301b6c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 036/110] guvcview: update to 2.0.8.

---
 srcpkgs/guvcview/patches/fix-include.patch | 10 ++++++++++
 srcpkgs/guvcview/template                  |  7 +++----
 2 files changed, 13 insertions(+), 4 deletions(-)
 create mode 100644 srcpkgs/guvcview/patches/fix-include.patch

diff --git a/srcpkgs/guvcview/patches/fix-include.patch b/srcpkgs/guvcview/patches/fix-include.patch
new file mode 100644
index 00000000000000..503c2af3b78c1a
--- /dev/null
+++ b/srcpkgs/guvcview/patches/fix-include.patch
@@ -0,0 +1,10 @@
+--- a/guvcview/guvcview.c
++++ b/guvcview/guvcview.c
+@@ -28,6 +28,7 @@
+ #include <sys/stat.h>
+ #include <sys/resource.h>
+ #include <errno.h>
++#include <locale.h>
+ 
+ #include "gview.h"
+ #include "gviewv4l2core.h"
diff --git a/srcpkgs/guvcview/template b/srcpkgs/guvcview/template
index d42fd38fa4ad12..86a7fd619612c8 100644
--- a/srcpkgs/guvcview/template
+++ b/srcpkgs/guvcview/template
@@ -1,8 +1,7 @@
 # Template file for 'guvcview'
 pkgname=guvcview
-version=2.0.7
-revision=2
-create_wrksrc=yes
+version=2.0.8
+revision=1
 build_style=gnu-configure
 configure_args="--disable-static --disable-debian-menu"
 hostmakedepends="pkg-config intltool autoconf automake libtool glib-devel"
@@ -14,7 +13,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="http://guvcview.sourceforge.net/"
 distfiles="${SOURCEFORGE_SITE}/${pkgname}/${pkgname}-src-${version}.tar.bz2"
-checksum=f47d51fbd06e44eeaa1a82f4a153c927527c90d94514197a70b2956028cc8ad4
+checksum=a21f4e448286666cf27bafef5290cc953a0a1796b752e5bbe521266dc1230c81
 
 post_patch() {
 	sed '31a#include <locale.h>' -i  guvcview/guvcview.c

From 873bf076dba71f0664e8c92f9f1385486634dd26 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 037/110] handbrake: update to 1.6.1

---
 .../patches/fix-missing-x265-link-flag.patch    | 11 ++++++-----
 .../handbrake/patches/libhb-vpl-include.patch   | 15 +++++++++++++++
 srcpkgs/handbrake/template                      | 17 ++++++++++-------
 3 files changed, 31 insertions(+), 12 deletions(-)
 create mode 100644 srcpkgs/handbrake/patches/libhb-vpl-include.patch

diff --git a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
index 26db03867a0c83..d6bb2eda627a36 100644
--- a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
+++ b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
@@ -1,14 +1,15 @@
 --- a/gtk/configure.ac
 +++ b/gtk/configure.ac
 @@ -203,7 +203,7 @@
- 
+
  AM_CONDITIONAL([MINGW], [test "x$mingw_flag" = "xyes"])
- 
--HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg"
-+HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -ldl"
+
+-HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc"
++HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc -ldl"
  HB_CPPFLAGS="$HB_CPPFLAGS $HBINC"
- 
+
  PKG_CHECK_MODULES([x264], [x264], sys_x264=yes, sys_x264=no)
+
 --- a/test/module.defs
 +++ b/test/module.defs
 @@ -69,6 +69,9 @@
diff --git a/srcpkgs/handbrake/patches/libhb-vpl-include.patch b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
new file mode 100644
index 00000000000000..298f9f4ab28f2a
--- /dev/null
+++ b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
@@ -0,0 +1,15 @@
+--- a/libhb/module.defs	2023-01-22 11:36:49.000000000 -0500
++++ b/libhb/module.defs	2023-04-03 22:37:52.395467010 -0400
+@@ -46,11 +46,7 @@
+ LIBHB.GCC.I += $(LIBHB.build/) $(CONTRIB.build/)include
+ 
+ ifeq (1,$(FEATURE.qsv))
+-    ifeq ($(HOST.system),freebsd))
+-        LIBHB.GCC.I += $(LOCALBASE)/include/vpl
+-    else
+-        LIBHB.GCC.I += $(CONTRIB.build/)include/vpl
+-    endif
++    LIBHB.GCC.I += /usr/include/vpl
+ endif
+ 
+ ifneq (,$(filter $(HOST.system),freebsd netbsd openbsd))
diff --git a/srcpkgs/handbrake/template b/srcpkgs/handbrake/template
index ca5e4571e49c37..c32cb1bfa31f4b 100644
--- a/srcpkgs/handbrake/template
+++ b/srcpkgs/handbrake/template
@@ -1,10 +1,10 @@
 # Template file for 'handbrake'
 pkgname=handbrake
-version=1.5.1
+version=1.6.1
 revision=1
 build_style=gnu-configure
 configure_args="--force --disable-gtk-update-checks --disable-df-fetch --harden
- $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc)"
+ $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc) $(vopt_enable qsv)"
 make_build_args="-C ${XBPS_TRIPLET}"
 make_install_args="-C ${XBPS_TRIPLET}"
 hostmakedepends="automake cmake gettext-devel glib-devel intltool libtool m4 meson nasm pkg-config python3"
@@ -12,8 +12,11 @@ makedepends="bzip2-devel ffmpeg-devel gst-plugins-base1-devel gtk+3-devel
  jansson-devel lame-devel libass-devel libbluray-devel libdav1d-devel
  libdvdnav-devel libdvdread-devel libgudev-devel libnuma-devel
  libsamplerate-devel libtheora-devel libvorbis-devel libvpx-devel libxml2-devel
- opus-devel speex-devel x264-devel x265-devel zimg-devel
+ opus-devel speex-devel x264-devel x265-devel zimg-devel libsvt-av1-devel
  $(vopt_if fdk_aac fdk-aac-devel)
+ $(vopt_if qsv libva-devel)
+ $(vopt_if qsv libdrm-devel)
+ $(vopt_if qsv onevpl-devel)
  $(vopt_if nvenc nv-codec-headers)"
 depends="desktop-file-utils gst-plugins-good1 hicolor-icon-theme"
 short_desc="Multithreaded video transcoder"
@@ -21,15 +24,15 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-2.0-only"
 homepage="https://handbrake.fr/"
 distfiles="https://github.com/HandBrake/HandBrake/releases/download/${version}/HandBrake-${version}-source.tar.bz2"
-checksum=3999fe06d5309c819799a73a968a8ec3840e7840c2b64af8f5cdb7fd8c9430f0
+checksum=94ccfe03db917a91650000c510f7fd53f844da19f19ad4b4be1b8f6bc31a8d4c
 nocross=yes
 
-build_options="fdk_aac nvenc"
+build_options="fdk_aac nvenc qsv"
 
 case "$XBPS_TARGET_MACHINE" in
 	x86_64*|i686*)
 		CFLAGS="-msse"
-		build_options_default="nvenc"
+		build_options_default="nvenc qsv"
 		;;
 esac
 
@@ -37,7 +40,7 @@ pre_configure() {
 	# use system libraries, don't download them
 	rm -rf contrib/
 	for module in fdk-aac ffmpeg libbluray libdav1d libdvdnav libdvdread nvenc \
-		x265 zimg; do
+		x265 zimg svt-av1 libvpl; do
 	    vsed -i "/MODULES += contrib\/${module}/d" make/include/main.defs
 	done
 }

From 481e14cfd2260e68ded76b21b4c46f6420221b06 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 038/110] hedgewars: revbump for ffmpeg4

---
 srcpkgs/hedgewars/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/hedgewars/template b/srcpkgs/hedgewars/template
index 94b6db673b0c3a..402ccfaaecbc2d 100644
--- a/srcpkgs/hedgewars/template
+++ b/srcpkgs/hedgewars/template
@@ -1,13 +1,13 @@
 # Template file for 'hedgewars'
 pkgname=hedgewars
 version=1.0.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DNOSERVER=1 -DDATA_INSTALL_DIR=/usr/share/${pkgname}
  -DPHYSFS_SYSTEM=1 -DMINIMAL_FLAGS=1"
 make_cmd=make
 hostmakedepends="lua51 pkg-config qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
+makedepends="ffmpeg4-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
  SDL2_mixer-devel SDL2_net-devel SDL2_ttf-devel"
 depends="libfreeglut"
 short_desc="Funny turn-based artillery game, featuring fighting Hedgehogs!"

From 3d1aae53bde71a97bb5d2851c0e118ea718d2ee1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 039/110] idjc: revbump for ffmpeg4

---
 srcpkgs/idjc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/idjc/template b/srcpkgs/idjc/template
index a9cde0665d55b1..f41e1e4fabbae7 100644
--- a/srcpkgs/idjc/template
+++ b/srcpkgs/idjc/template
@@ -1,11 +1,11 @@
 # Template file for 'idjc'
 pkgname=idjc
 version=0.9.1
-revision=5
+revision=6
 build_style=gnu-configure
 hostmakedepends="pkg-config git python3 automake gettext-devel libtool"
 makedepends="libvorbis-devel libogg-devel jack-devel libsamplerate-devel
- libflac-devel libsndfile-devel mpg123-devel ffmpeg-devel speex-devel
+ libflac-devel libsndfile-devel mpg123-devel ffmpeg4-devel speex-devel
  glib-devel pixman-devel lame-devel python3-gobject-devel libshout-idjc-devel
  opus-devel twolame-devel python3-mutagen python3-devel"
 depends="python3-gobject python3-mutagen desktop-file-utils shared-mime-info python3-dbus jack"

From 390e1afbf224f2565e4a3b49ee41463e4ce3c7eb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 040/110] kid3: revbump for ffmpeg6

---
 srcpkgs/kid3/patches/ffmpeg5.patch | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 srcpkgs/kid3/patches/ffmpeg5.patch

diff --git a/srcpkgs/kid3/patches/ffmpeg5.patch b/srcpkgs/kid3/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..135fc50e07c9ba
--- /dev/null
+++ b/srcpkgs/kid3/patches/ffmpeg5.patch
@@ -0,0 +1,17 @@
+# https://aur.archlinux.org/cgit/aur.git/diff/ffmpeg5.patch?h=kid3-cli&id=12410a74906612e7efc0ec8fbce739b4a0fef7e7
+diff --git a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+index e156d424..e12b9abd 100644
+--- a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
++++ b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+@@ -232,7 +232,11 @@ private:
+   friend class Format;
+   friend class Converter;
+   AVCodecContext* m_ptr;
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 0, 0)
+   AVCodec* m_impl;
++#else
++  const AVCodec* m_impl;
++#endif
+   AVFrame* m_frame;
+   bool m_opened;
+ };

From ddb80a7fc361ed24d74816b11948f15e2ce1f9de Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 041/110] kodi: revbump for ffmpeg4

---
 srcpkgs/kodi/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/kodi/template b/srcpkgs/kodi/template
index d37a5918cd6758..ea78e0aca0fe3e 100644
--- a/srcpkgs/kodi/template
+++ b/srcpkgs/kodi/template
@@ -1,7 +1,7 @@
 # Template file for 'kodi'
 pkgname=kodi
 version=19.4
-revision=9
+revision=10
 _codename="Matrix"
 build_style=cmake
 configure_args="-DWITH_FFMPEG=/usr -DENABLE_LDGOLD=OFF
@@ -54,7 +54,7 @@ makedepends="
  libmad-devel fontconfig-devel libXinerama-devel libsamplerate-devel libmms-devel
  enca-devel boost-devel libcurl-devel libva-devel libvdpau-devel libass-devel
  libbluetooth-devel yajl-devel libplist-devel librtmp-devel tinyxml-devel
- taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg-devel
+ taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg4-devel
  giflib-devel libxslt-devel gnutls-devel libssh-devel libmicrohttpd-devel
  libcec-devel dcadec-devel flatbuffers-devel fmt-devel lcms2-devel
  libfstrcmp-devel rapidjson libcdio-paranoia spdlog libwaylandpp-devel

From 2072b35b0835df45c1aa242266dc5853320c2e6e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 042/110] kpipewire: revbump for ffmpeg6

---
 srcpkgs/kpipewire/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kpipewire/template b/srcpkgs/kpipewire/template
index 6214a4451336e7..3555348659dded 100644
--- a/srcpkgs/kpipewire/template
+++ b/srcpkgs/kpipewire/template
@@ -1,7 +1,7 @@
 # Template file for 'kpipewire'
 pkgname=kpipewire
 version=5.27.10
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules plasma-wayland-protocols gettext
  qt5-qmake qt5-host-tools pkg-config wayland-devel kcoreaddons

From c03113df694e0fb48c718c54714be5d4d0f345be Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 043/110] libopenal: revbump for ffmpeg6

---
 srcpkgs/libopenal/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenal/template b/srcpkgs/libopenal/template
index 88d0f11307d81a..8308fca0393e33 100644
--- a/srcpkgs/libopenal/template
+++ b/srcpkgs/libopenal/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenal'
 pkgname=libopenal
 version=1.23.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DALSOFT_EXAMPLES=OFF"
 hostmakedepends="pkg-config"

From b43ebcfff47c19e4739644fe9c08fe62baf37dbd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 044/110] loudgain: revbump for ffmpeg6

---
 srcpkgs/loudgain/patches/ffmpeg5.patch | 11 +++++++++++
 srcpkgs/loudgain/template              |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/loudgain/patches/ffmpeg5.patch

diff --git a/srcpkgs/loudgain/patches/ffmpeg5.patch b/srcpkgs/loudgain/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..16d4510ee98faa
--- /dev/null
+++ b/srcpkgs/loudgain/patches/ffmpeg5.patch
@@ -0,0 +1,11 @@
+--- a/src/scan.c	2019-09-06 11:31:19.000000000 -0400
++++ b/src/scan.c	2023-03-23 11:15:40.867968521 -0400
+@@ -69,8 +69,6 @@
+ 	 * It is now useless
+ 	 * https://github.com/FFmpeg/FFmpeg/blob/70d25268c21cbee5f08304da95be1f647c630c15/doc/APIchanges#L86
+ 	 */
+-  if (avformat_version() < AV_VERSION_INT(58,9,100))
+-    av_register_all();
+ 
+ 	av_log_set_callback(scan_av_log);
+ 
diff --git a/srcpkgs/loudgain/template b/srcpkgs/loudgain/template
index da4f2d56e94c3d..4d6bf29efb4fdd 100644
--- a/srcpkgs/loudgain/template
+++ b/srcpkgs/loudgain/template
@@ -1,7 +1,7 @@
 # Template file for 'loudgain'
 pkgname=loudgain
 version=0.6.8
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libebur128-devel taglib-devel ffmpeg-devel"

From b2db1e23d742b2494f0a4ee191e612a9ce8ec094 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 045/110] mediastreamer: revbump for ffmpeg4

---
 srcpkgs/mediastreamer/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mediastreamer/template b/srcpkgs/mediastreamer/template
index 0fcffa7653d18e..e888626b945e55 100644
--- a/srcpkgs/mediastreamer/template
+++ b/srcpkgs/mediastreamer/template
@@ -1,11 +1,11 @@
 # Template file for 'mediastreamer'
 pkgname=mediastreamer
 version=5.2.111
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DENABLE_STRICT=0 -DENABLE_UNIT_TESTS=0"
 hostmakedepends="python3"
-makedepends="bzrtp-devel ffmpeg-devel glew-devel libXv-devel libsrtp-devel
+makedepends="bzrtp-devel ffmpeg4-devel glew-devel libXv-devel libsrtp-devel
  libupnp-devel libvpx-devel mbedtls-devel opus-devel ortp-devel pulseaudio-devel
  libtheora-devel speex-devel v4l-utils-devel bcg729-devel bcmatroska2-devel libgsm-devel
  zxing-cpp-devel"

From 394e4e3924147b4439dfe28492ba74a58338695a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 046/110] mgba: revbump for ffmpeg6

---
 srcpkgs/mgba/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mgba/template b/srcpkgs/mgba/template
index 6cd65650312543..93401adb618bd8 100644
--- a/srcpkgs/mgba/template
+++ b/srcpkgs/mgba/template
@@ -1,7 +1,7 @@
 # Template file for 'mgba'
 pkgname=mgba
 version=0.10.3
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake desktop-file-utils"
 makedepends="SDL2-devel ffmpeg-devel libedit-devel libepoxy-devel libmagick-devel

From 4ea14b72af0ce5bdb92cc3431c90c35b49a5cecb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 047/110] mlt: revbump for ffmpeg4

---
 srcpkgs/mlt/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mlt/template b/srcpkgs/mlt/template
index 73e3915aaab9ac..d7ed4c4b30a868 100644
--- a/srcpkgs/mlt/template
+++ b/srcpkgs/mlt/template
@@ -1,14 +1,14 @@
 # Template file for 'mlt'
 pkgname=mlt
 version=6.26.1
-revision=3
+revision=4
 build_style=configure
 configure_args="--prefix=/usr --libdir=/usr/lib$XBPS_TARGET_WORDSIZE
  --enable-gpl --enable-gpl3 --disable-swfdec --without-kde
  --swig-languages=python"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which"
 # XXX: movit vid.stab
-makedepends="alsa-lib-devel ffmpeg-devel gtk+-devel jack-devel ladspa-sdk
+makedepends="alsa-lib-devel ffmpeg4-devel gtk+-devel jack-devel ladspa-sdk
  libexif-devel libsamplerate-devel libxml2-devel sox-devel SDL_image-devel
  fftw-devel frei0r-plugins python3-devel pulseaudio-devel movit-devel
  libvidstab-devel"

From 7961c49b14bbc9a165faeebd471d23dbd38dc2fc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 048/110] moc: revbump for ffmpeg4

---
 srcpkgs/moc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/moc/template b/srcpkgs/moc/template
index 3a04932c8f1e61..838755f88db09e 100644
--- a/srcpkgs/moc/template
+++ b/srcpkgs/moc/template
@@ -1,10 +1,10 @@
 # Template file for 'moc'
 pkgname=moc
 version=2.5.2
-revision=7
+revision=8
 build_style=gnu-configure
 hostmakedepends="pkg-config"
-makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg-devel
+makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg4-devel
  jack-devel alsa-lib-devel libltdl-devel libflac-devel libvorbis-devel
  libmad-devel libmpcdec-devel libmodplug-devel libid3tag-devel faad2-devel
  taglib-devel libsndfile-devel wavpack-devel speex-devel libsamplerate-devel

From 94d6d2a1cb2e1400204191fb379534afad50d8f4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 049/110] motion: revbump for ffmpeg6

---
 srcpkgs/motion/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/motion/template b/srcpkgs/motion/template
index 607ebeb3c7b242..bf63a91d9764f6 100644
--- a/srcpkgs/motion/template
+++ b/srcpkgs/motion/template
@@ -1,7 +1,7 @@
 # Template file for 'motion'
 pkgname=motion
 version=4.6.0
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake pkg-config gettext-devel tar"
 makedepends="ffmpeg-devel libmicrohttpd-devel v4l-utils-devel gettext-devel"

From 1a96979306b7c81580caeaa0e3ac960c51e7e5dc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 050/110] olive: revbump for ffmpeg4

---
 srcpkgs/olive/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/olive/template b/srcpkgs/olive/template
index 12a46936c99003..5c2917b9c51245 100644
--- a/srcpkgs/olive/template
+++ b/srcpkgs/olive/template
@@ -1,10 +1,10 @@
 # Template file for 'olive'
 pkgname=olive
 version=0.1.2
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools pkg-config"
-makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg-devel frei0r-plugins"
+makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg4-devel frei0r-plugins"
 short_desc="Non-linear video editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"

From fe0b2f9238849d18f9c7cc23abb981344ffa710e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 051/110] opentoonz: revbump for ffmpeg6

---
 srcpkgs/opentoonz/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/opentoonz/template b/srcpkgs/opentoonz/template
index ee9f7603f55fd8..3e81834ca0eddf 100644
--- a/srcpkgs/opentoonz/template
+++ b/srcpkgs/opentoonz/template
@@ -1,7 +1,7 @@
 # Template file for 'opentoonz'
 pkgname=opentoonz
 version=1.6.0
-revision=2
+revision=3
 build_wrksrc="toonz/sources"
 build_style=cmake
 make_cmd=make

From 5d918ef589b84bb5effd3f7af7b5045bb33a4d0a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 052/110] pianobar: revbump for ffmpeg6

---
 srcpkgs/pianobar/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pianobar/template b/srcpkgs/pianobar/template
index e3febb821a4510..1e3dc1bf9308ee 100644
--- a/srcpkgs/pianobar/template
+++ b/srcpkgs/pianobar/template
@@ -1,7 +1,7 @@
 # Template file for 'pianobar'
 pkgname=pianobar
 version=2022.04.01
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="V=1"
 hostmakedepends="pkg-config"

From 52e8d22540b913f2ffa1544bb425389e3022f2c0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 053/110] ppsspp: revbump for ffmpeg6

---
 srcpkgs/ppsspp/patches/ffmpeg6.patch | 15 +++++++++++++++
 srcpkgs/ppsspp/template              |  3 +--
 2 files changed, 16 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/ppsspp/patches/ffmpeg6.patch

diff --git a/srcpkgs/ppsspp/patches/ffmpeg6.patch b/srcpkgs/ppsspp/patches/ffmpeg6.patch
new file mode 100644
index 00000000000000..5803c7bf227309
--- /dev/null
+++ b/srcpkgs/ppsspp/patches/ffmpeg6.patch
@@ -0,0 +1,15 @@
+--- a/Core/HW/SimpleAudioDec.cpp	2024-02-04 08:08:02.000000000 -0500
++++ b/Core/HW/SimpleAudioDec.cpp	2024-02-15 14:48:27.114362051 -0500
+@@ -81,7 +81,11 @@
+ 		return;
+ 	}
+ 	// Find decoder
++#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(58, 18, 100)
+ 	codec_ = avcodec_find_decoder((AVCodecID)audioCodecId);
++#else // this is a macro to const in the header
++	codec_ = (AVCodec*)avcodec_find_decoder((AVCodecID)audioCodecId);
++#endif
+ 	if (!codec_) {
+ 		// Eh, we shouldn't even have managed to compile. But meh.
+ 		ERROR_LOG(ME, "This version of FFMPEG does not support AV_CODEC_ctx for audio (%s). Update your submodule.", GetCodecName(audioType));
+
diff --git a/srcpkgs/ppsspp/template b/srcpkgs/ppsspp/template
index 2238a7601c0af8..1fda55268a2d39 100644
--- a/srcpkgs/ppsspp/template
+++ b/srcpkgs/ppsspp/template
@@ -1,7 +1,7 @@
 # Template file for 'ppsspp'
 pkgname=ppsspp
 version=1.17.1
-revision=1
+revision=2
 _glslang_commit=b34f619e1c85810dcb3c578107d2e48ba4ee2b37
 _SPIRV_Cross_commit=4212eef67ed0ca048cb726a6767185504e7695e5
 _armips_commit=a8d71f0f279eb0d30ecf6af51473b66ae0cf8e8d
@@ -91,7 +91,6 @@ post_configure() {
 }
 
 do_install() {
-	vlicense LICENSE.TXT
 	vinstall icons/icon.svg 644 usr/share/pixmaps ppsspp.svg
 	vinstall Qt/PPSSPP.desktop 644 usr/share/applications
 	vbin build/PPSSPPHeadless ppsspp-headless

From 5c25921356a48cd6b84abe5e0f2426a8ba2382cc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 054/110] pqiv: revbump for ffmpeg6

---
 srcpkgs/pqiv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pqiv/template b/srcpkgs/pqiv/template
index f9f7751196d4ee..0d50777e56a2d8 100644
--- a/srcpkgs/pqiv/template
+++ b/srcpkgs/pqiv/template
@@ -1,7 +1,7 @@
 # Template file for 'pqiv'
 pkgname=pqiv
 version=2.13.1
-revision=1
+revision=2
 build_style=gnu-makefile
 hostmakedepends="pkg-config"
 makedepends="glib-devel gtk+3-devel $(vopt_if ffmpeg ffmpeg-devel)

From 2df6e426fdfbecfea3cbf5d8ec51da32c8d6c07e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 055/110] qmmp: revbump for ffmpeg6

---
 srcpkgs/qmmp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qmmp/template b/srcpkgs/qmmp/template
index 53781ea3bc28ad..2da07f1e87eac0 100644
--- a/srcpkgs/qmmp/template
+++ b/srcpkgs/qmmp/template
@@ -1,7 +1,7 @@
 # Template file for 'qmmp'
 pkgname=qmmp
 version=1.6.1
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DUSE_HAL:BOOL=FALSE -DQMMP_DEFAULT_UI:STRING=simple"
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From f1f61a83a6ab819a637964738993a1a426a7c959 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 14 Dec 2023 13:28:10 -0500
Subject: [PATCH 056/110] qt6-pdf: revbump for ffmpeg6

---
 srcpkgs/qt6-pdf/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-pdf/template b/srcpkgs/qt6-pdf/template
index ecda84afac1310..531b4e1d4fe84d 100644
--- a/srcpkgs/qt6-pdf/template
+++ b/srcpkgs/qt6-pdf/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-pdf'
 pkgname=qt6-pdf
 version=6.6.0
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DQT_FEATURE_qtpdf_build=ON
  -DQT_FEATURE_qtpdf_widgets_build=ON

From 406b74f58234410a4f1d5398eda67680032a540c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 057/110] qt5-webengine: revbump for ffmpeg6

---
 .../chromium-media-filters-cpp14.patch        |  11 ++
 srcpkgs/qt5-webengine/patches/ffmpeg5.patch   | 179 ++++++++++++++++++
 .../qtwebengine-fix-ffmpeg5-build.patch       |  14 ++
 srcpkgs/qt5-webengine/template                |   4 +-
 4 files changed, 206 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/ffmpeg5.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch

diff --git a/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
new file mode 100644
index 00000000000000..04adc540f2cbc0
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
@@ -0,0 +1,11 @@
+--- a/src/3rdparty/chromium/media/filters/BUILD.gn	2023-02-27 13:32:59.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/BUILD.gn	2023-04-02 17:21:39.204066384 -0400
+@@ -96,6 +96,8 @@
+     "//ui/gfx/geometry:geometry",
+   ]
+ 
++  cflags_cc = [ "-std=c++14" ]
++
+   libs = []
+ 
+   if (proprietary_codecs) {
diff --git a/srcpkgs/qt5-webengine/patches/ffmpeg5.patch b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..ac55e1634423a9
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
@@ -0,0 +1,179 @@
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:57.732547446 -0400
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:09.486478995 -0400
+@@ -57,6 +57,8 @@
+ 
+ namespace {
+ 
++constexpr int64_t kRelativeTsBase = static_cast<int64_t>(0x7ffeffffffffffff);
++
+ void SetAVStreamDiscard(AVStream* stream, AVDiscard discard) {
+   DCHECK(stream);
+   stream->discard = discard;
+@@ -90,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+   if (stream->start_time != kNoFFmpegTimestamp)
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (stream->first_dts != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, stream->first_dts);
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -408,11 +398,11 @@
+   scoped_refptr<DecoderBuffer> buffer;
+ 
+   if (type() == DemuxerStream::TEXT) {
+-    int id_size = 0;
++    size_t id_size = 0;
+     uint8_t* id_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
+ 
+-    int settings_size = 0;
++    size_t settings_size = 0;
+     uint8_t* settings_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
+ 
+@@ -424,7 +414,7 @@
+     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
+                                      side_data.data(), side_data.size());
+   } else {
+-    int side_data_size = 0;
++    size_t side_data_size = 0;
+     uint8_t* side_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
+ 
+@@ -485,7 +475,7 @@
+                                        packet->size - data_offset);
+     }
+ 
+-    int skip_samples_size = 0;
++    size_t skip_samples_size = 0;
+     const uint32_t* skip_samples_ptr =
+         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
+             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
+@@ -1587,6 +1577,8 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++      continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+       lowest_start_time_stream = stream.get();
+@@ -1604,6 +1596,8 @@
+     if (stream && stream->type() == DemuxerStream::VIDEO &&
+         stream->IsEnabled()) {
+       video_stream = stream.get();
++      if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++        continue;
+       if (video_stream->start_time() <= seek_time) {
+         return video_stream;
+       }
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h qtwebengine-5.15.10/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h
+--- a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-07-11 22:12:47.917192788 -0500
+@@ -29,6 +29,7 @@ extern "C" {
+ #include <libavformat/avformat.h>
+ #include <libavformat/avio.h>
+ #include <libavutil/avutil.h>
++#include <libavutil/channel_layout.h>
+ #include <libavutil/imgutils.h>
+ #include <libavutil/log.h>
+ #include <libavutil/mastering_display_metadata.h>
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/audio_file_reader.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/audio_file_reader.cc
+--- a/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -85,7 +85,7 @@ bool AudioFileReader::OpenDemuxer() {
+ }
+ 
+ bool AudioFileReader::OpenDecoder() {
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (codec) {
+     // MP3 decodes to S16P which we don't support, tell it to use S16 instead.
+     if (codec_context_->sample_fmt == AV_SAMPLE_FMT_S16P)
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -329,7 +329,7 @@ bool FFmpegAudioDecoder::ConfigureDecode
+     }
+   }
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec ||
+       avcodec_open2(codec_context_.get(), codec, &codec_options) < 0) {
+     DLOG(ERROR) << "Could not initialize audio decoder: "
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -59,7 +59,6 @@ static int64_t AVIOSeekOperation(void* o
+ }
+ 
+ void FFmpegGlue::InitializeFFmpeg() {
+-  av_register_all();
+ }
+ 
+ static void LogContainer(bool is_local_file,
+@@ -95,9 +94,6 @@ FFmpegGlue::FFmpegGlue(FFmpegURLProtocol
+   // Enable fast, but inaccurate seeks for MP3.
+   format_context_->flags |= AVFMT_FLAG_FAST_SEEK;
+ 
+-  // Ensures we can read out various metadata bits like vp8 alpha.
+-  format_context_->flags |= AVFMT_FLAG_KEEP_SIDE_DATA;
+-
+   // Ensures format parsing errors will bail out. From an audit on 11/2017, all
+   // instances were real failures. Solves bugs like http://crbug.com/710791.
+   format_context_->error_recognition |= AV_EF_EXPLODE;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -391,7 +391,7 @@ bool FFmpegVideoDecoder::ConfigureDecode
+   if (decode_nalus_)
+     codec_context_->flags2 |= AV_CODEC_FLAG2_CHUNKS;
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
+     ReleaseFFmpegResources();
+     return false;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/media_file_checker.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/media_file_checker.cc
+--- a/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -68,7 +68,7 @@ bool MediaFileChecker::Start(base::TimeD
+       auto context = AVStreamToAVCodecContext(format_context->streams[i]);
+       if (!context)
+         continue;
+-      AVCodec* codec = avcodec_find_decoder(cp->codec_id);
++      const AVCodec* codec = avcodec_find_decoder(cp->codec_id);
+       if (codec && avcodec_open2(context.get(), codec, nullptr) >= 0) {
+         auto loop = std::make_unique<FFmpegDecodingLoop>(context.get());
+         stream_contexts[i] = {std::move(context), std::move(loop)};
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc qtwebengine-5.15.10/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc
+--- a/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -203,7 +203,7 @@ int32_t H264DecoderImpl::InitDecode(cons
+   // a pointer |this|.
+   av_context_->opaque = this;
+ 
+-  AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
+   if (!codec) {
+     // This is an indication that FFmpeg has not been initialized or it has not
+     // been compiled/initialized with the correct set of codecs.
diff --git a/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch b/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch
new file mode 100644
index 00000000000000..bc24d5b9a29cb5
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch
@@ -0,0 +1,14 @@
+--- a/src/buildtools/configure.json	2023-12-09 11:06:01.503058569 -0500
++++ b/src/buildtools/configure.json	2023-12-09 11:06:14.982361345 -0500
+@@ -779,11 +779,6 @@
+             "type": "warning",
+             "condition": "config.ios && config.simulator && config.device && features.build-qtpdf",
+             "message": "Building fat libray with device and simulator architectures will disable NEON."
+-        },
+-        {
+-            "type": "fatal",
+-            "condition": "features.webengine-system-ffmpeg && !libs.webengine-ffmpeg-support",
+-            "message": "Unmodified ffmpeg >= 5.0 is not supported. Please configure with -qt-webengine-ffmpeg."
+         }
+     ],
+     "summary": [
diff --git a/srcpkgs/qt5-webengine/template b/srcpkgs/qt5-webengine/template
index 8d2df1b5175bad..1687a77eb8a2f5 100644
--- a/srcpkgs/qt5-webengine/template
+++ b/srcpkgs/qt5-webengine/template
@@ -1,14 +1,14 @@
 # Template file for 'qt5-webengine'
 pkgname=qt5-webengine
 version=5.15.16
-revision=1
+revision=2
 _version="${version}-lts"
 _chromium_commit=207c2ac45ca3386d153770c6b0d2ea2ec21ca880
 archs="x86_64* i686* armv[67]* ppc64* aarch64*"
 create_wrksrc=yes
 build_style=qmake
 configure_args="--
- -webengine-icu -webengine-ffmpeg -webengine-opus -webengine-webp
+ -webengine-icu -system-ffmpeg -webengine-opus -webengine-webp
  -webengine-pepper-plugins -webengine-printing-and-pdf -webengine-proprietary-codecs
  -webengine-pulseaudio -webengine-spellchecker -webengine-webrtc -webengine-geolocation
  -webengine-kerberos -no-webengine-embedded-build $(vopt_if sndio '' '-no')-webengine-sndio

From 28defb0fb3970fda8ee500e68589f6039ade7c74 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 058/110] qt5: revbump for ffmpeg6

---
 srcpkgs/qt5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5/template b/srcpkgs/qt5/template
index 3efb7e42d5fd3f..27f6d5388cd15c 100644
--- a/srcpkgs/qt5/template
+++ b/srcpkgs/qt5/template
@@ -3,9 +3,9 @@
 # revbump libqtxdg after bumping patch version
 pkgname=qt5
 version=5.15.11+20231124
+revision=3
 # commit 4765fa1df7a837db9c1f89c4da0dd76b74bb5fab
 # base repo: https://invent.kde.org/qt/qt/qt5
-revision=2
 build_style=meta
 hostmakedepends="cmake clang17 flex perl glib-devel pkg-config
  python3 re2c ruby which"

From 9cb572d1bfff8646b0ebfce2968bf185829b190a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 059/110] qtav: revbump for ffmpeg4

---
 srcpkgs/qtav/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtav/template b/srcpkgs/qtav/template
index 775d5a139a9efa..aa69e213c984b0 100644
--- a/srcpkgs/qtav/template
+++ b/srcpkgs/qtav/template
@@ -1,10 +1,10 @@
 # Template file for 'qtav'
 pkgname=qtav
 version=1.13.0
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel libass-devel libopenal-devel
+makedepends="ffmpeg4-devel libass-devel libopenal-devel
  libva-glx-devel libXv-devel pulseaudio-devel
  qt5-declarative-devel qt5-svg-devel
  qt5-quickcontrols"

From 255d16ba4eca6213f44a6764512aad5c13613547 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 060/110] retroarch: revbump for ffmpeg6

---
 srcpkgs/retroarch/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroarch/template b/srcpkgs/retroarch/template
index cb3125c5dbf1ae..c65c26f7bf0332 100644
--- a/srcpkgs/retroarch/template
+++ b/srcpkgs/retroarch/template
@@ -1,7 +1,7 @@
 # Template file for 'retroarch'
 pkgname=retroarch
 version=1.16.0.3
-revision=3
+revision=4
 build_style=configure
 configure_args="--prefix=/usr --sysconfdir=/etc --enable-networking
  --enable-udev --disable-builtinflac --disable-builtinglslang

From 4fcd35a4278d8454585d7d7e578a7542998d3d21 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 061/110] scrcpy: revbump for ffmpeg6

---
 srcpkgs/scrcpy/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/scrcpy/template b/srcpkgs/scrcpy/template
index d04de770dc1913..5218fa01f8ce1f 100644
--- a/srcpkgs/scrcpy/template
+++ b/srcpkgs/scrcpy/template
@@ -1,7 +1,7 @@
 # Template file for 'scrcpy'
 pkgname=scrcpy
 version=2.3.1
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcompile_server=false
  -Dprebuilt_server=/usr/share/scrcpy/scrcpy-server-v${version}"

From 109bad7b4d6da446cc94107ef8fd992c66774c03 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 17 Oct 2023 08:54:11 -0400
Subject: [PATCH 062/110] New package: spex-x replaces spek-alternative for
 ffmpeg6

---
 srcpkgs/spek-alternative                      |  1 +
 srcpkgs/spek-x/patches/musl.patch             |  7 ++++++
 srcpkgs/{spek-alternative => spek-x}/template | 22 ++++++++++++-------
 3 files changed, 22 insertions(+), 8 deletions(-)
 create mode 120000 srcpkgs/spek-alternative
 create mode 100644 srcpkgs/spek-x/patches/musl.patch
 rename srcpkgs/{spek-alternative => spek-x}/template (52%)

diff --git a/srcpkgs/spek-alternative b/srcpkgs/spek-alternative
new file mode 120000
index 00000000000000..76648236da7017
--- /dev/null
+++ b/srcpkgs/spek-alternative
@@ -0,0 +1 @@
+spek-x
\ No newline at end of file
diff --git a/srcpkgs/spek-x/patches/musl.patch b/srcpkgs/spek-x/patches/musl.patch
new file mode 100644
index 00000000000000..662f45936febc6
--- /dev/null
+++ b/srcpkgs/spek-x/patches/musl.patch
@@ -0,0 +1,7 @@
+--- a/tests/perf.cc	2024-03-09 17:13:49.086603418 -0500
++++ b/tests/perf.cc	2024-03-09 17:13:59.453603753 -0500
+@@ -1,3 +1,4 @@
++#include <cstdint>
+ #include <cstdlib>
+ #include <iostream>
+ #include <fstream>
diff --git a/srcpkgs/spek-alternative/template b/srcpkgs/spek-x/template
similarity index 52%
rename from srcpkgs/spek-alternative/template
rename to srcpkgs/spek-x/template
index d7b55c776b1d43..3ded6c2c323e4f 100644
--- a/srcpkgs/spek-alternative/template
+++ b/srcpkgs/spek-x/template
@@ -1,18 +1,18 @@
-# Template file for 'spek-alternative'
-pkgname=spek-alternative
-version=0.8.2.3
-revision=2
+# Template file for 'spek-x'
+pkgname=spek-x
+version=0.9.3
+revision=1
 build_style=gnu-configure
 hostmakedepends="automake gettext-devel intltool libtool pkg-config
  wxWidgets-common wxWidgets-gtk3-devel"
 makedepends="ffmpeg-devel wxWidgets-gtk3-devel"
 depends="ffmpeg"
 short_desc="Acoustic spectrum analyser"
-maintainer="Kartik Singh <kartik.ynwa@gmail.com>"
+maintainer="zlice <zlice555@gmail.com>"
 license="GPL-3.0-or-later"
-homepage="https://github.com/withmorten/spek-alternative"
-distfiles="https://github.com/withmorten/spek-alternative/archive/${version}.tar.gz"
-checksum="007ba4b84a310b078e378aa84c8e80783db5821437a757a488c3ecec377e6b2a"
+homepage="https://github.com/MikeWang000000/spek-x"
+distfiles="https://github.com/MikeWang000000/spek-x/archive/v${version}.tar.gz"
+checksum="7f4b109903333cdd310ab2b9176f0dc49a565891376e281a233d342cedf90ef7"
 
 CXXFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
 
@@ -22,3 +22,9 @@ export WX_CONFIG_NAME="wx-config-gtk3"
 pre_configure() {
 	NOCONFIGURE=1 ./autogen.sh
 }
+
+spek-alternative_package() {
+	depends="spek-x"
+	short_desc+=" - transitional dummy package"
+	build_style=meta
+}

From 8b69bd4501cea9d2a71b796e1c13713cab3d77f2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 063/110] ssr: revbump for ffmpeg6

---
 .../0001-Fix-build-with-ffmpeg-5.0.patch      | 241 ++++++++++++++++++
 srcpkgs/ssr/template                          |   2 +-
 2 files changed, 242 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ssr/patches/0001-Fix-build-with-ffmpeg-5.0.patch

diff --git a/srcpkgs/ssr/patches/0001-Fix-build-with-ffmpeg-5.0.patch b/srcpkgs/ssr/patches/0001-Fix-build-with-ffmpeg-5.0.patch
new file mode 100644
index 00000000000000..4c069b5a9fc464
--- /dev/null
+++ b/srcpkgs/ssr/patches/0001-Fix-build-with-ffmpeg-5.0.patch
@@ -0,0 +1,241 @@
+From f4cbde38021d9330dc73d2e3dfa8a70da3ff5721 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Bernhard=20Rosenkr=C3=A4nzer?= <bero@lindev.ch>
+Date: Sun, 16 Jan 2022 02:40:04 +0100
+Subject: [PATCH] Fix build with ffmpeg 5.0
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Adapt to ffmpeg 5.0 requiring more const-ness for AVCodec.
+
+Signed-off-by: Bernhard Rosenkränzer <bero@lindev.ch>
+---
+ src/AV/Output/AudioEncoder.cpp |  6 +++---
+ src/AV/Output/AudioEncoder.h   |  4 ++--
+ src/AV/Output/BaseEncoder.cpp  |  4 ++--
+ src/AV/Output/BaseEncoder.h    |  4 ++--
+ src/AV/Output/Muxer.cpp        | 12 ++++++------
+ src/AV/Output/Muxer.h          |  4 ++--
+ src/AV/Output/VideoEncoder.cpp |  6 +++---
+ src/AV/Output/VideoEncoder.h   |  4 ++--
+ 8 files changed, 22 insertions(+), 22 deletions(-)
+
+diff --git a/src/AV/Output/AudioEncoder.cpp b/src/AV/Output/AudioEncoder.cpp
+index 34d015c..cefc2e0 100644
+--- a/src/AV/Output/AudioEncoder.cpp
++++ b/src/AV/Output/AudioEncoder.cpp
+@@ -34,7 +34,7 @@ const std::vector<AudioEncoder::SampleFormatData> AudioEncoder::SUPPORTED_SAMPLE
+ 
+ const unsigned int AudioEncoder::DEFAULT_FRAME_SAMPLES = 1024;
+ 
+-AudioEncoder::AudioEncoder(Muxer* muxer, AVStream* stream, AVCodecContext *codec_context, AVCodec* codec, AVDictionary** options)
++AudioEncoder::AudioEncoder(Muxer* muxer, AVStream* stream, AVCodecContext *codec_context, const AVCodec* codec, AVDictionary** options)
+ 	: BaseEncoder(muxer, stream, codec_context, codec, options) {
+ 
+ #if !SSR_USE_AVCODEC_ENCODE_AUDIO2
+@@ -77,7 +77,7 @@ unsigned int AudioEncoder::GetSampleRate() {
+ }
+ 
+ bool AudioEncoder::AVCodecIsSupported(const QString& codec_name) {
+-	AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
++	const AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
+ 	if(codec == NULL)
+ 		return false;
+ 	if(!av_codec_is_encoder(codec))
+@@ -93,7 +93,7 @@ bool AudioEncoder::AVCodecIsSupported(const QString& codec_name) {
+ 	return false;
+ }
+ 
+-void AudioEncoder::PrepareStream(AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
++void AudioEncoder::PrepareStream(AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
+ 								 unsigned int bit_rate, unsigned int channels, unsigned int sample_rate) {
+ 
+ 	if(channels == 0) {
+diff --git a/src/AV/Output/AudioEncoder.h b/src/AV/Output/AudioEncoder.h
+index c93278c..ae9c82e 100644
+--- a/src/AV/Output/AudioEncoder.h
++++ b/src/AV/Output/AudioEncoder.h
+@@ -40,7 +40,7 @@ private:
+ #endif
+ 
+ public:
+-	AudioEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options);
++	AudioEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options);
+ 	~AudioEncoder();
+ 
+ 	// Returns the required frame size, i.e. the number of samples (for each channel).
+@@ -57,7 +57,7 @@ public:
+ 
+ public:
+ 	static bool AVCodecIsSupported(const QString& codec_name);
+-	static void PrepareStream(AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
++	static void PrepareStream(AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
+ 							  unsigned int bit_rate, unsigned int channels, unsigned int sample_rate);
+ 
+ private:
+diff --git a/src/AV/Output/BaseEncoder.cpp b/src/AV/Output/BaseEncoder.cpp
+index 7c01ef3..4780aaf 100644
+--- a/src/AV/Output/BaseEncoder.cpp
++++ b/src/AV/Output/BaseEncoder.cpp
+@@ -42,7 +42,7 @@ double ParseCodecOptionDouble(const QString& key, const QString& value, double m
+ 	return clamp(value_double, min, max) * multiply;
+ }
+ 
+-BaseEncoder::BaseEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options) {
++BaseEncoder::BaseEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options) {
+ 
+ 	m_muxer = muxer;
+ 	m_stream = stream;
+@@ -157,7 +157,7 @@ void BaseEncoder::IncrementPacketCounter() {
+ 	++lock->m_total_packets;
+ }
+ 
+-void BaseEncoder::Init(AVCodec* codec, AVDictionary** options) {
++void BaseEncoder::Init(const AVCodec* codec, AVDictionary** options) {
+ 
+ 	// open codec
+ 	if(avcodec_open2(m_codec_context, codec, options) < 0) {
+diff --git a/src/AV/Output/BaseEncoder.h b/src/AV/Output/BaseEncoder.h
+index 3d92f29..7f02bbd 100644
+--- a/src/AV/Output/BaseEncoder.h
++++ b/src/AV/Output/BaseEncoder.h
+@@ -51,7 +51,7 @@ private:
+ 	std::atomic<bool> m_should_stop, m_should_finish, m_is_done, m_error_occurred;
+ 
+ protected:
+-	BaseEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options);
++	BaseEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options);
+ 
+ public:
+ 	virtual ~BaseEncoder(); // encoders will be deleted by Muxer, don't delete them yourself!
+@@ -117,7 +117,7 @@ protected:
+ 	void IncrementPacketCounter();
+ 
+ private:
+-	void Init(AVCodec* codec, AVDictionary** options);
++	void Init(const AVCodec* codec, AVDictionary** options);
+ 	void Free();
+ 
+ 	void EncoderThread();
+diff --git a/src/AV/Output/Muxer.cpp b/src/AV/Output/Muxer.cpp
+index ad58380..14650b0 100644
+--- a/src/AV/Output/Muxer.cpp
++++ b/src/AV/Output/Muxer.cpp
+@@ -87,7 +87,7 @@ Muxer::~Muxer() {
+ 
+ VideoEncoder* Muxer::AddVideoEncoder(const QString& codec_name, const std::vector<std::pair<QString, QString> >& codec_options,
+ 									 unsigned int bit_rate, unsigned int width, unsigned int height, unsigned int frame_rate) {
+-	AVCodec *codec = FindCodec(codec_name);
++	const AVCodec *codec = FindCodec(codec_name);
+ 	AVCodecContext *codec_context = NULL;
+ 	AVStream *stream = AddStream(codec, &codec_context);
+ 	VideoEncoder *encoder;
+@@ -111,7 +111,7 @@ VideoEncoder* Muxer::AddVideoEncoder(const QString& codec_name, const std::vecto
+ 
+ AudioEncoder* Muxer::AddAudioEncoder(const QString& codec_name, const std::vector<std::pair<QString, QString> >& codec_options,
+ 									 unsigned int bit_rate, unsigned int channels, unsigned int sample_rate) {
+-	AVCodec *codec = FindCodec(codec_name);
++	const AVCodec *codec = FindCodec(codec_name);
+ 	AVCodecContext *codec_context = NULL;
+ 	AVStream *stream = AddStream(codec, &codec_context);
+ 	AudioEncoder *encoder;
+@@ -194,7 +194,7 @@ unsigned int Muxer::GetQueuedPacketCount(unsigned int stream_index) {
+ void Muxer::Init() {
+ 
+ 	// get the format we want (this is just a pointer, we don't have to free this)
+-	AVOutputFormat *format = av_guess_format(m_container_name.toUtf8().constData(), NULL, NULL);
++	const AVOutputFormat *format = av_guess_format(m_container_name.toUtf8().constData(), NULL, NULL);
+ 	if(format == NULL) {
+ 		Logger::LogError("[Muxer::Init] " + Logger::tr("Error: Can't find chosen output format!"));
+ 		throw LibavException();
+@@ -261,8 +261,8 @@ void Muxer::Free() {
+ 	}
+ }
+ 
+-AVCodec* Muxer::FindCodec(const QString& codec_name) {
+-	AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
++const AVCodec* Muxer::FindCodec(const QString& codec_name) {
++	const AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
+ 	if(codec == NULL) {
+ 		Logger::LogError("[Muxer::FindCodec] " + Logger::tr("Error: Can't find codec!"));
+ 		throw LibavException();
+@@ -270,7 +270,7 @@ AVCodec* Muxer::FindCodec(const QString& codec_name) {
+ 	return codec;
+ }
+ 
+-AVStream* Muxer::AddStream(AVCodec* codec, AVCodecContext** codec_context) {
++AVStream* Muxer::AddStream(const AVCodec* codec, AVCodecContext** codec_context) {
+ 	assert(!m_started);
+ 	assert(m_format_context->nb_streams < MUXER_MAX_STREAMS);
+ 
+diff --git a/src/AV/Output/Muxer.h b/src/AV/Output/Muxer.h
+index d72347d..b104bcb 100644
+--- a/src/AV/Output/Muxer.h
++++ b/src/AV/Output/Muxer.h
+@@ -114,8 +114,8 @@ private:
+ 	void Init();
+ 	void Free();
+ 
+-	AVCodec* FindCodec(const QString& codec_name);
+-	AVStream* AddStream(AVCodec* codec, AVCodecContext** codec_context);
++	const AVCodec* FindCodec(const QString& codec_name);
++	AVStream* AddStream(const AVCodec* codec, AVCodecContext** codec_context);
+ 
+ 	void MuxerThread();
+ 
+diff --git a/src/AV/Output/VideoEncoder.cpp b/src/AV/Output/VideoEncoder.cpp
+index 8087e8e..fc8b5d1 100644
+--- a/src/AV/Output/VideoEncoder.cpp
++++ b/src/AV/Output/VideoEncoder.cpp
+@@ -34,7 +34,7 @@ const std::vector<VideoEncoder::PixelFormatData> VideoEncoder::SUPPORTED_PIXEL_F
+ 	{"rgb", AV_PIX_FMT_RGB24, false},
+ };
+ 
+-VideoEncoder::VideoEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options)
++VideoEncoder::VideoEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options)
+ 	: BaseEncoder(muxer, stream, codec_context, codec, options) {
+ 
+ #if !SSR_USE_AVCODEC_ENCODE_VIDEO2
+@@ -95,7 +95,7 @@ unsigned int VideoEncoder::GetFrameRate() {
+ }
+ 
+ bool VideoEncoder::AVCodecIsSupported(const QString& codec_name) {
+-	AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
++	const AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
+ 	if(codec == NULL)
+ 		return false;
+ 	if(!av_codec_is_encoder(codec))
+@@ -111,7 +111,7 @@ bool VideoEncoder::AVCodecIsSupported(const QString& codec_name) {
+ 	return false;
+ }
+ 
+-void VideoEncoder::PrepareStream(AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
++void VideoEncoder::PrepareStream(AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
+ 								 unsigned int bit_rate, unsigned int width, unsigned int height, unsigned int frame_rate) {
+ 
+ 	if(width == 0 || height == 0) {
+diff --git a/src/AV/Output/VideoEncoder.h b/src/AV/Output/VideoEncoder.h
+index cb7ca27..68d872e 100644
+--- a/src/AV/Output/VideoEncoder.h
++++ b/src/AV/Output/VideoEncoder.h
+@@ -40,7 +40,7 @@ private:
+ #endif
+ 
+ public:
+-	VideoEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options);
++	VideoEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options);
+ 	~VideoEncoder();
+ 
+ 	// Returns the required pixel format.
+@@ -55,7 +55,7 @@ public:
+ 
+ public:
+ 	static bool AVCodecIsSupported(const QString& codec_name);
+-	static void PrepareStream(AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
++	static void PrepareStream(AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
+ 							  unsigned int bit_rate, unsigned int width, unsigned int height, unsigned int frame_rate);
+ 
+ private:
+-- 
+2.43.0
+
diff --git a/srcpkgs/ssr/template b/srcpkgs/ssr/template
index 3097754e3cbe54..e3c4261f1f5a64 100644
--- a/srcpkgs/ssr/template
+++ b/srcpkgs/ssr/template
@@ -1,7 +1,7 @@
 # Template file for 'ssr'
 pkgname=ssr
 version=0.4.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DWITH_QT5=ON"
 hostmakedepends="pkg-config"

From 08f2ce05dcc1925d9f6f92aaa4842112dcbec202 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 064/110] synfig: revbump for ffmpeg6 and mlt7

---
 srcpkgs/synfig/patches/ffmpeg6.patch | 71 ++++++++++++++++++++++++++++
 srcpkgs/synfig/template              |  6 +--
 2 files changed, 74 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/synfig/patches/ffmpeg6.patch

diff --git a/srcpkgs/synfig/patches/ffmpeg6.patch b/srcpkgs/synfig/patches/ffmpeg6.patch
new file mode 100644
index 00000000000000..10780b42782f4b
--- /dev/null
+++ b/srcpkgs/synfig/patches/ffmpeg6.patch
@@ -0,0 +1,71 @@
+--- a/src/modules/mod_libavcodec/trgt_av.cpp	2022-10-25 09:14:12.000000000 -0400
++++ b/src/modules/mod_libavcodec/trgt_av.cpp	2023-05-05 21:34:17.899194559 -0400
+@@ -38,6 +41,7 @@
+ extern "C"
+ {
+ #ifdef HAVE_LIBAVFORMAT_AVFORMAT_H
++#	include <libavcodec/avcodec.h>
+ #	include <libavformat/avformat.h>
+ #elif defined(HAVE_AVFORMAT_H)
+ #	include <avformat.h>
+@@ -155,11 +156,11 @@
+     }
+ 
+ 	bool open_video_stream() {
+-		if (avcodec_open2(video_context, NULL, NULL) < 0) {
++		if (avcodec_open2(video_context, nullptr, nullptr) < 0) {
+ 			synfig::error("Target_LibAVCodec: could not open video codec");
+ 			// seems the calling of avcodec_free_context after error will cause crash
+ 			// so just forget about this context
+-			video_context = NULL;
++			video_context = nullptr;
+ 			close();
+ 			return false;
+         }
+@@ -234,15 +235,21 @@
+ 		close();
+ 
+ 		if (!av_registered) {
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 			av_register_all();
++#endif
+ 			av_registered = true;
+ 		}
+ 
+ 		// guess format
+-		AVOutputFormat *format = av_guess_format(NULL, filename.c_str(), NULL);
++#if LIBAVCODEC_VERSION_MAJOR < 59 // FFMPEG < 5.0
++		AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#else
++		const AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#endif
+ 		if (!format) {
+ 			synfig::warning("Target_LibAVCodec: unable to guess the output format, defaulting to MPEG");
+-			format = av_guess_format("mpeg", NULL, NULL);
++			format = av_guess_format("mpeg", nullptr, nullptr);
+ 		}
+ 		if (!format) {
+ 			synfig::error("Target_LibAVCodec: unable to find 'mpeg' output format");
+@@ -254,6 +261,7 @@
+ 		context = avformat_alloc_context();
+ 		assert(context);
+ 		context->oformat = format;
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 		if (filename.size() + 1 > sizeof(context->filename)) {
+ 			synfig::error(
+ 				"Target_LibAVCodec: filename too long, max length is %d, filename is '%s'",
+@@ -263,6 +271,14 @@
+ 			return false;
+ 		}
+ 		memcpy(context->filename, filename.c_str(), filename.size() + 1);
++#else
++		context->url = av_strndup(filename.c_str(), filename.size());
++		if (!context->url) {
++			synfig::error("Target_LibAVCodec: cannot allocate space for filename");
++			close();
++			return false;
++		}
++#endif
+ 
+ 		packet = av_packet_alloc();
+ 		assert(packet);
diff --git a/srcpkgs/synfig/template b/srcpkgs/synfig/template
index d4d3e341a20bf8..828b5cb32956ee 100644
--- a/srcpkgs/synfig/template
+++ b/srcpkgs/synfig/template
@@ -2,11 +2,11 @@
 # Should be kept in sync with 'synfigstudio' and 'ETL'
 pkgname=synfig
 version=1.4.4
-revision=4
+revision=5
 build_style=gnu-configure
 configure_args="--with-boost-libdir=${XBPS_CROSS_BASE}/usr/lib"
 hostmakedepends="boost-build ImageMagick pkg-config intltool"
-makedepends="ETL gettext-devel libxml++-devel mlt-devel libmagick-devel
+makedepends="ETL gettext-devel libxml++-devel mlt7-devel libmagick-devel
  libmng-devel boost-build boost-devel libopenexr-devel ffmpeg-devel"
 depends="ImageMagick"
 short_desc="CLI 2D vector and timeline-based animation software"
@@ -20,7 +20,7 @@ CXXFLAGS="-std=c++11 -DHAVE_LOCALE_H=1"
 
 synfig-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision}
-	 libopenexr-devel libxml++-devel mlt-devel"
+	 libopenexr-devel libxml++-devel mlt7-devel"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/bin/synfig-config

From a43c375010f07078a511c5085a0ae573ed648e45 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 065/110] timg: revbump for ffmpeg6

---
 srcpkgs/timg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/timg/template b/srcpkgs/timg/template
index 2a2ab763d2fddf..8fb4327535ef93 100644
--- a/srcpkgs/timg/template
+++ b/srcpkgs/timg/template
@@ -1,7 +1,7 @@
 # Template file for 'timg'
 pkgname=timg
 version=1.4.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_OPENSLIDE_SUPPORT=off -Wno-dev"
 hostmakedepends="pkg-config git"

From dacbfa54e5d4b0644f2a771c62c1acfcf02f0727 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 066/110] tvheadend: revbump for ffmpeg4

---
 srcpkgs/tvheadend/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tvheadend/template b/srcpkgs/tvheadend/template
index 9aea7de4ec7057..012d31c4879ff1 100644
--- a/srcpkgs/tvheadend/template
+++ b/srcpkgs/tvheadend/template
@@ -8,7 +8,7 @@ configure_args="--enable-dvbscan --disable-ffmpeg_static
 --disable-libx265_static --disable-libvpx_static --disable-libtheora_static
 --disable-libvorbis_static --disable-libfdkaac_static"
 hostmakedepends="gettext pkg-config python3 git which"
-makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg-devel"
+makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg4-devel"
 short_desc="TV streaming server"
 maintainer="lemmi <lemmi@nerd2nerd.org>"
 license="GPL-3.0-only"

From 8a5eb8f21ad728a9d2240f4c15efbc026a2b022d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 067/110] unpaper: update to 7.0.0.

---
 srcpkgs/unpaper/template | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/srcpkgs/unpaper/template b/srcpkgs/unpaper/template
index 38ed47a5840165..1ff910e722afc8 100644
--- a/srcpkgs/unpaper/template
+++ b/srcpkgs/unpaper/template
@@ -1,13 +1,13 @@
 # Template file for 'unpaper'
 pkgname=unpaper
-version=6.1
-revision=3
-build_style=gnu-configure
+version=7.0.0
+revision=1
+build_style=meson
+hostmakedepends="pkg-config meson libxslt"
+makedepends="ffmpeg-devel python3-Sphinx"
+short_desc="Post-processing tool for scanned sheets of paper"
 maintainer="Orphaned <orphan@voidlinux.org>"
-hostmakedepends="pkg-config libxslt"
-makedepends="ffmpeg-devel"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://www.flameeyes.eu/projects/unpaper"
-short_desc="A post-processing tool for scanned sheets of paper"
 distfiles="https://www.flameeyes.eu/files/${pkgname}-${version}.tar.xz"
-checksum=237c84f5da544b3f7709827f9f12c37c346cdf029b1128fb4633f9bafa5cb930
+checksum=2575fbbf26c22719d1cb882b59602c9900c7f747118ac130883f63419be46a80

From 92edba642db5d784f866d0814a3dfcadd8780665 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 068/110] vice: revbump for ffmpeg4

---
 srcpkgs/vice/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/vice/template b/srcpkgs/vice/template
index b1f866d35095e7..43f79243a1da11 100644
--- a/srcpkgs/vice/template
+++ b/srcpkgs/vice/template
@@ -1,7 +1,7 @@
 # Template file for 'vice'
 pkgname=vice
 version=3.7.1
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="
 	$(vopt_enable sdl2 sdlui2)
@@ -26,7 +26,7 @@ makedepends="
 	$(vopt_if gtk3 gtk+3-devel)
 	$(vopt_if gtk3 pulseaudio-devel)
 	$(vopt_if gtk3 pango-devel)
-	$(vopt_if ffmpeg ffmpeg-devel)"
+	$(vopt_if ffmpeg ffmpeg4-devel)"
 short_desc="Emulator for C64, C128, CBM-II, PET, VIC20, Plus4 and C16"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"

From e5398379af73838067469b92decdbb5a923ff8f1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 069/110] waypipe: revbump for ffmpeg6

---
 srcpkgs/waypipe/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waypipe/template b/srcpkgs/waypipe/template
index 6da88b21bf2a19..4da8058400b588 100644
--- a/srcpkgs/waypipe/template
+++ b/srcpkgs/waypipe/template
@@ -1,7 +1,7 @@
 # Template file for 'waypipe'
 pkgname=waypipe
 version=0.8.6
-revision=1
+revision=2
 build_style=meson
 # lto is off because it causes linking errors in armv6l and armv7l (due to NEON)
 configure_args="-Dwerror=false -Dwith_dmabuf=enabled -Dwith_lz4=enabled

From a2812be6b5f3578ba77f108fdb19a70965961d1b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 070/110] xpra: revbump for ffmpeg6

---
 srcpkgs/xpra/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xpra/template b/srcpkgs/xpra/template
index 3e49ab23deac9c..3939026a6fbf90 100644
--- a/srcpkgs/xpra/template
+++ b/srcpkgs/xpra/template
@@ -1,7 +1,7 @@
 # Template file for 'xpra'
 pkgname=xpra
 version=5.0.7
-revision=1
+revision=2
 build_style=python3-module
 make_build_args="--without-cuda_kernels --without-cuda_rebuild"
 make_install_args="$(vopt_with docs) ${make_build_args}"

From 0f34a9ab243a87a1017dc12952b42600cc08b4fa Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:07:40 -0400
Subject: [PATCH 071/110] nv-codec-headers: update to 12.0.16.0

---
 srcpkgs/nv-codec-headers/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/nv-codec-headers/template b/srcpkgs/nv-codec-headers/template
index 3d422a61e48917..251e057f826fb8 100644
--- a/srcpkgs/nv-codec-headers/template
+++ b/srcpkgs/nv-codec-headers/template
@@ -1,6 +1,6 @@
 # Template file for 'nv-codec-headers'
 pkgname=nv-codec-headers
-version=11.1.5.1
+version=12.0.16.0
 revision=1
 build_style=gnu-makefile
 short_desc="FFmpeg version of headers required to interface with Nvidias codec APIs"
@@ -8,7 +8,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="MIT"
 homepage="http://git.videolan.org/?p=ffmpeg/nv-codec-headers.git"
 distfiles="https://github.com/FFmpeg/nv-codec-headers/archive/n${version}.tar.gz"
-checksum=d095fbd56aa93772471a323be0ebe65504a0f43f06c76a30b6d25da77b06ae9c
+checksum=2a1533b65f55f9da52956faf0627ed3b74868ac0c7f269990edd21369113b48f
 
 post_install() {
 	sed -n '4,25p' include/ffnvcodec/nvEncodeAPI.h > LICENSE

From 0e714829f581d9c4222e0fff33af301fbc73bc04 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:08:40 -0400
Subject: [PATCH 072/110] openimagedenoise: revbump for ffmpeg6

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index 109deb171c3f75..44edf38fb289d8 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,7 +1,7 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
 version=1.4.3
-revision=2
+revision=3
 archs="x86_64*"
 build_style=cmake
 hostmakedepends="ispc python3"

From ecc0caaeafd2f299caf8528ab4234ad4253080cc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:31:45 -0400
Subject: [PATCH 073/110] shotcut: revbump for ffmpeg6

---
 srcpkgs/shotcut/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/shotcut/template b/srcpkgs/shotcut/template
index 33141fbd862d7a..f46cb53b6bfb92 100644
--- a/srcpkgs/shotcut/template
+++ b/srcpkgs/shotcut/template
@@ -1,7 +1,7 @@
 # Template file for 'shotcut'
 pkgname=shotcut
 version=23.09.29
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSHOTCUT_VERSION=${version}"
 hostmakedepends="pkg-config qt6-tools-devel"

From 08396eb9f1db557e6e35a57d136c8794c7fa3ce3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:30 -0400
Subject: [PATCH 074/110] shiboken2: revbump for qt5-5.15.11

---
 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch | 1 +
 1 file changed, 1 insertion(+)
 create mode 120000 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
new file mode 120000
index 00000000000000..efcf3249bd8854
--- /dev/null
+++ b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1 @@
+../../python3-pyside2/patches/importlib-machinery-bypass.patch
\ No newline at end of file

From 55ad0250972bc50c3ef02de0f18d4668b6e37688 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:53 -0400
Subject: [PATCH 075/110] python3-pyside2: revbump for qt5-5.15.11

---
 .../patches/importlib-machinery-bypass.patch      | 15 +++++++++++++++
 srcpkgs/python3-pyside2/template                  |  2 +-
 2 files changed, 16 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
new file mode 100644
index 00000000000000..64c429584776b5
--- /dev/null
+++ b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1,15 @@
+Using this prevents an error around line 220 below it.
+"AttributeError: module 'importlib' has no attribute 'machinery'"
+The old backup logic is in place and compiles without issues.
+--- a/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:09:34.688912402 -0400
++++ b/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:10:03.395529582 -0400
+@@ -170,9 +170,6 @@
+
+     # 'zipstring_sequence' comes from signature.cpp
+     zipbytes = base64.b64decode(''.join(zipstring_sequence))
+-    if sys.version_info[0] >= 3:
+-        vzip = zipfile.ZipFile(io.BytesIO(zipbytes))
+-        return sys.meta_path, EmbeddableZipImporter(vzip)
+
+     # Old version for Python 2.7, only.
+     import os
diff --git a/srcpkgs/python3-pyside2/template b/srcpkgs/python3-pyside2/template
index 249efa90988425..52626436ce75f2 100644
--- a/srcpkgs/python3-pyside2/template
+++ b/srcpkgs/python3-pyside2/template
@@ -1,7 +1,7 @@
 # Template file for 'python3-pyside2'
 pkgname=python3-pyside2
 version=5.15.10
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/pyside2"
 build_style=cmake

From cfb7f0b37330d850e941969e4c6c342888144f1f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:35 -0400
Subject: [PATCH 076/110] konqueror: revbump for ffmpeg6

---
 srcpkgs/konqueror/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/konqueror/template b/srcpkgs/konqueror/template
index add972916753c6..50bbf4eec05e55 100644
--- a/srcpkgs/konqueror/template
+++ b/srcpkgs/konqueror/template
@@ -1,11 +1,11 @@
 # Template file for 'konqueror'
 pkgname=konqueror
 version=23.08.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DDESKTOPTOJSON_EXECUTABLE=/usr/bin/desktoptojson"
 hostmakedepends="extra-cmake-modules python3 qt5-host-tools qt5-qmake kdoctools
-kcoreaddons kconfig gettext"
+ kcoreaddons kconfig gettext"
 makedepends="qt5-devel qt5-webengine-devel qt5-declarative-devel
  qt5-webchannel-devel qt5-location-devel kcmutils-devel kdelibs4support-devel
  karchive-devel khtml-devel kdesu-devel kactivities5-devel"

From f82017c1744266d9345311c694395d7c002919cc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:58 -0400
Subject: [PATCH 077/110] qt5-speech: revbump for qt5-5.15.11

---
 srcpkgs/qt5-speech/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-speech/template b/srcpkgs/qt5-speech/template
index 1228bb60c41db4..27a7da1dbdb91b 100644
--- a/srcpkgs/qt5-speech/template
+++ b/srcpkgs/qt5-speech/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-speech'
 pkgname=qt5-speech
 version=5.15.11
-revision=1
+revision=2
 _commit=d32f4a479d38a11f547598004b975f4356424a16
 build_style=qmake
 configure_args="-- -flite -flite-alsa -speechd"

From a86bf8fd341d31aa03c41e6c2a9e79b290874c7d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Jun 2023 08:20:22 -0400
Subject: [PATCH 078/110] gtk4: revbump for ffmpeg6

---
 srcpkgs/gtk4/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gtk4/template b/srcpkgs/gtk4/template
index 3f2554ea3bc940..da41e85ec329c3 100644
--- a/srcpkgs/gtk4/template
+++ b/srcpkgs/gtk4/template
@@ -1,7 +1,7 @@
 # Template file for 'gtk4'
 pkgname=gtk4
 version=4.12.5
-revision=1
+revision=2
 build_style=meson
 build_helper="gir"
 configure_args="-Dman-pages=true -Ddocumentation=true -Dbuild-tests=false

From f028910b25dac149ac271a4b218290aef6258c57 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:28:26 -0400
Subject: [PATCH 079/110] siril: revbump for ffmpeg6

---
 srcpkgs/siril/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/siril/template b/srcpkgs/siril/template
index 84332f79d060d2..62750dd247548f 100644
--- a/srcpkgs/siril/template
+++ b/srcpkgs/siril/template
@@ -1,7 +1,7 @@
 # Template file for 'siril'
 pkgname=siril
 version=0.9.12
-revision=10
+revision=11
 build_style=gnu-configure
 hostmakedepends="pkg-config intltool autoconf automake gettext-devel"
 makedepends="fftw-devel libconfig-devel libopencv-devel libffms2-devel

From 794fb35ba549b626d79e281f90485bc6a0636267 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 22 Jun 2023 10:25:02 -0400
Subject: [PATCH 080/110] kdenlive: revbump for ffmpeg6

---
 srcpkgs/kdenlive/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kdenlive/template b/srcpkgs/kdenlive/template
index ecb48dfc74d29d..a3476d0b876b10 100644
--- a/srcpkgs/kdenlive/template
+++ b/srcpkgs/kdenlive/template
@@ -1,7 +1,7 @@
 # Template file for 'kdenlive'
 pkgname=kdenlive
 version=23.08.5
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="
  extra-cmake-modules kconfig kcoreaddons kdoctools pkg-config python3

From a499f97156fa35c237e81e8d579f0ba675b3c007 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:20:59 -0400
Subject: [PATCH 081/110] tracker-miners: revbump for ffmpeg6

---
 srcpkgs/tracker-miners/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tracker-miners/template b/srcpkgs/tracker-miners/template
index 0b97f47489f817..f196d2bf9e4a4c 100644
--- a/srcpkgs/tracker-miners/template
+++ b/srcpkgs/tracker-miners/template
@@ -1,7 +1,7 @@
 # Template file for 'tracker-miners'
 pkgname=tracker-miners
 version=3.6.1
-revision=1
+revision=2
 build_style=meson
 build_helper=qemu
 # missing libgrss for miner_rss

From cc2398aaf588867c32dd2b912565437fa4911793 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:21:21 -0400
Subject: [PATCH 082/110] mpd: revbump for ffmpeg6

---
 srcpkgs/mpd/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpd/template b/srcpkgs/mpd/template
index 4fd32b7be8c537..b8e2bd4c1b59c8 100644
--- a/srcpkgs/mpd/template
+++ b/srcpkgs/mpd/template
@@ -1,7 +1,7 @@
 # Template file for 'mpd'
 pkgname=mpd
 version=0.23.15
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dopus=enabled -Dmikmod=enabled -Dneighbor=true
  -Dsoundcloud=enabled -Dpipe=true -Dtwolame=enabled -Dbzip2=enabled

From 43db574a9477e36557d67cabe1225e1864aea8eb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:02 -0400
Subject: [PATCH 083/110] tg_owt: revbump for ffmpeg6

---
 srcpkgs/tg_owt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tg_owt/template b/srcpkgs/tg_owt/template
index 34e8fef0540569..1a46a8bedf3473 100644
--- a/srcpkgs/tg_owt/template
+++ b/srcpkgs/tg_owt/template
@@ -1,7 +1,7 @@
 # Template file for 'tg_owt'
 pkgname=tg_owt
 version=0.0.0.20231221
-revision=2
+revision=3
 _commit=afd9d5d31798d3eacf9ed6c30601e91d0f1e4d60
 _libyuv_commit=04821d1e7d60845525e8db55c7bcd41ef5be9406
 _abseil_commit=8c0b94e793a66495e0b1f34a5eb26bd7dc672db0

From 40260b85bb35fc02292d15177f3d5c51f1ee92d5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:44 -0400
Subject: [PATCH 084/110] telegram-desktop: revbump for ffmpeg6

---
 srcpkgs/telegram-desktop/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/telegram-desktop/template b/srcpkgs/telegram-desktop/template
index 6dc6a553cfcec8..cf85a731370062 100644
--- a/srcpkgs/telegram-desktop/template
+++ b/srcpkgs/telegram-desktop/template
@@ -1,7 +1,7 @@
 # Template file for 'telegram-desktop'
 pkgname=telegram-desktop
 version=4.14.15
-revision=3
+revision=4
 build_style=cmake
 build_helper="qemu gir"
 configure_args="-DTDESKTOP_API_ID=209235

From 354f316e3850bc25692436cf4a6f0f820f4564e7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:12:09 -0400
Subject: [PATCH 085/110] openmw: revbump for ffmpeg6

---
 srcpkgs/openmw/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openmw/template b/srcpkgs/openmw/template
index 0abf5ff7cdbecc..b57180f1a4446f 100644
--- a/srcpkgs/openmw/template
+++ b/srcpkgs/openmw/template
@@ -1,7 +1,7 @@
 # Template file for 'openmw'
 pkgname=openmw
 version=0.48.0
-revision=2
+revision=3
 build_style=cmake
 _recast_commit=e75adf86f91eb3082220085e42dda62679f9a3ea
 _bullet_tag=3.17

From 08b0eda7a24be9c804e504aef0ba515bf3ee0703 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:14:53 -0400
Subject: [PATCH 086/110] lms: revbump for ffmpeg6

---
 srcpkgs/lms/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/lms/template b/srcpkgs/lms/template
index e358f75902a986..3b21c458de5199 100644
--- a/srcpkgs/lms/template
+++ b/srcpkgs/lms/template
@@ -1,7 +1,7 @@
 # Template file for 'lms'
 pkgname=lms
 version=3.42.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="wt-devel ffmpeg-devel boost-devel libconfig++-devel taglib-devel pam-devel libgraphicsmagick-devel gtest-devel libarchive-devel"

From c982719084460e00a945b06cea67e3caa31d1008 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:18:18 -0400
Subject: [PATCH 087/110] freecad: DELETE

---
 srcpkgs/freecad/patches/001-include.patch     | 112 ------------------
 .../154-revert-gui-tmp-redirect-stderr.patch  |  68 -----------
 ...d63c8c9b1280978be841d04e68a0a55cceb9.patch |  30 -----
 srcpkgs/freecad/template                      |  12 +-
 4 files changed, 7 insertions(+), 215 deletions(-)
 delete mode 100644 srcpkgs/freecad/patches/001-include.patch
 delete mode 100644 srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
 delete mode 100644 srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch

diff --git a/srcpkgs/freecad/patches/001-include.patch b/srcpkgs/freecad/patches/001-include.patch
deleted file mode 100644
index 28b5af54999b96..00000000000000
--- a/srcpkgs/freecad/patches/001-include.patch
+++ /dev/null
@@ -1,112 +0,0 @@
-From 9a41845a417189776741297c50a3827ce292bc4f Mon Sep 17 00:00:00 2001
-From: Uwe <donovaly@users.noreply.github.com>
-Date: Sun, 3 Jul 2022 22:51:16 +0200
-Subject: [PATCH] [Part] OCCError.h: remove unneeded includes
-
-- also sort includes
----
- src/Mod/Part/App/OCCError.h             | 36 +++----------------------
- src/Mod/Part/App/OffsetCurvePyImp.cpp   | 12 ++++-----
- src/Mod/Part/App/OffsetSurfacePyImp.cpp | 10 +++----
- 3 files changed, 12 insertions(+), 46 deletions(-)
-
---- a/src/Mod/Part/App/OCCError.h
-+++ b/src/Mod/Part/App/OCCError.h
-@@ -23,36 +23,8 @@
- #ifndef _OCCError_h_
- #define _OCCError_h_
- 
--# include <Standard_Version.hxx>
- # include <Standard_Failure.hxx>
--# include <Standard_AbortiveTransaction.hxx>
--# include <Standard_ConstructionError.hxx>
--# if OCC_VERSION_HEX >= 0x060500
--# include <Standard_DefineException.hxx>
--# endif
--# include <Standard_DimensionError.hxx>
--# include <Standard_DimensionMismatch.hxx>
--# include <Standard_DivideByZero.hxx>
--# include <Standard_DomainError.hxx>
--# include <Standard_ImmutableObject.hxx>
--# include <Standard_LicenseError.hxx>
--# include <Standard_LicenseNotFound.hxx>
--# include <Standard_MultiplyDefined.hxx>
--# include <Standard_NegativeValue.hxx>
--# include <Standard_NoMoreObject.hxx>
--# include <Standard_NoSuchObject.hxx>
--# include <Standard_NotImplemented.hxx>
--# include <Standard_NullObject.hxx>
--# include <Standard_NullValue.hxx>
--# include <Standard_NumericError.hxx>
--# include <Standard_OutOfMemory.hxx>
--# include <Standard_OutOfRange.hxx>
--# include <Standard_Overflow.hxx>
--# include <Standard_ProgramError.hxx>
--# include <Standard_RangeError.hxx>
--# include <Standard_TooManyUsers.hxx>
--# include <Standard_TypeMismatch.hxx>
--# include <Standard_Underflow.hxx>
-+# include <Standard_Version.hxx>
- 
- #include <Mod/Part/PartGlobal.h>
- #include <Base/Console.h>
-@@ -88,4 +60,3 @@ PartExport extern PyObject* PartExceptio
- 
- #define PY_CATCH_OCC _PY_CATCH_OCC(return(NULL))
- #endif  // _OCCError_h_
--
---- a/src/Mod/Part/App/OffsetCurvePyImp.cpp
-+++ b/src/Mod/Part/App/OffsetCurvePyImp.cpp
-@@ -20,20 +20,20 @@
-  *                                                                         *
-  ***************************************************************************/
- 
--
- #include "PreCompiled.h"
- #ifndef _PreComp_
- # include <Geom_OffsetCurve.hxx>
- #endif
- 
--#include "OCCError.h"
--#include "Geometry.h"
-+#include <Base/GeometryPyCXX.h>
-+#include <Base/Vector3D.h>
-+#include <Base/VectorPy.h>
-+
- #include "OffsetCurvePy.h"
- #include "OffsetCurvePy.cpp"
-+#include "Geometry.h"
-+#include "OCCError.h"
- 
--#include <Base/GeometryPyCXX.h>
--#include <Base/VectorPy.h>
--#include <Base/Vector3D.h>
- 
- using namespace Part;
- 
---- a/src/Mod/Part/App/OffsetSurfacePyImp.cpp
-+++ b/src/Mod/Part/App/OffsetSurfacePyImp.cpp
-@@ -20,20 +20,16 @@
-  *                                                                         *
-  ***************************************************************************/
- 
--
- #include "PreCompiled.h"
- #ifndef _PreComp_
- # include <Geom_OffsetSurface.hxx>
- # include <memory>
- #endif
- 
--#include <Base/VectorPy.h>
--#include <Base/Vector3D.h>
--
- #include "OCCError.h"
--#include "Geometry.h"
--#include <Mod/Part/App/OffsetSurfacePy.h>
--#include <Mod/Part/App/OffsetSurfacePy.cpp>
-+#include "OffsetSurfacePy.h"
-+#include "OffsetSurfacePy.cpp"
-+
- 
- using namespace Part;
- 
diff --git a/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch b/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
deleted file mode 100644
index d6a9adabdec830..00000000000000
--- a/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
+++ /dev/null
@@ -1,68 +0,0 @@
-see https://github.com/FreeCAD/FreeCAD/commit/cfe94b00d3434f3e2c8b5114d2909f628c330fa8#commitcomment-71413407
-
-upstream: yes
-
-From 7b377a216b9185960e4cee980a6504dc1a755f50 Mon Sep 17 00:00:00 2001
-From: wmayer <wmayer@users.sourceforge.net>
-Date: Wed, 29 Jun 2022 15:19:18 +0200
-Subject: [PATCH] Gui: remove workaround for spnav 0.23 due to build failure
- with musl libc
-
----
- src/Gui/3Dconnexion/GuiNativeEventLinux.cpp | 27 ---------------------
- 1 file changed, 27 deletions(-)
-
---- a/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp
-+++ b/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp
-@@ -21,42 +21,17 @@
-  ***************************************************************************/
- 
- #include <FCConfig.h>
--#include <cstdio>
- 
- #include "GuiNativeEventLinux.h"
- 
- #include "GuiApplicationNativeEventAware.h"
- #include <Base/Console.h>
--#include <Base/FileInfo.h>
- #include <QMainWindow>
- 
- #include <QSocketNotifier>
- 
- #include <spnav.h>
- 
--namespace {
--class RedirectStdErr
--{
--public:
--    RedirectStdErr()
--        : fi(Base::FileInfo::getTempFileName())
--        , file(stderr)
--    {
--        stderr = fopen(fi.filePath().c_str(), "w");
--    }
--    ~RedirectStdErr()
--    {
--        fclose(stderr);
--        fi.deleteFile();
--        stderr = file;
--    }
--
--private:
--    Base::FileInfo fi;
--    FILE* file;
--};
--}
--
- Gui::GuiNativeEvent::GuiNativeEvent(Gui::GUIApplicationNativeEventAware *app)
- : GuiAbstractNativeEvent(app)
- {
-@@ -72,8 +47,6 @@ Gui::GuiNativeEvent::~GuiNativeEvent()
- 
- void Gui::GuiNativeEvent::initSpaceball(QMainWindow *window)
- {
--    // tmp. redirect stderr to a file to suppress an error message from spnav_open()
--    RedirectStdErr err;
-     Q_UNUSED(window)
-     if (spnav_open() == -1) {
-         Base::Console().Log("Couldn't connect to spacenav daemon. Please ignore if you don't have a spacemouse.\n");
diff --git a/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch b/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch
deleted file mode 100644
index d4acf370ca0a42..00000000000000
--- a/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-From fe02d63c8c9b1280978be841d04e68a0a55cceb9 Mon Sep 17 00:00:00 2001
-From: Roy-043 <70520633+Roy-043@users.noreply.github.com>
-Date: Thu, 29 Dec 2022 23:20:38 +0100
-Subject: [PATCH] Draft: update inspect.getargspec to inspect.getfullargspec
- (#8101)
-
----
- src/Mod/Draft/draftguitools/gui_snapper.py | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
---- a/src/Mod/Draft/draftguitools/gui_snapper.py
-+++ b/src/Mod/Draft/draftguitools/gui_snapper.py
-@@ -1426,7 +1426,7 @@ class Snapper:
-             Gui.Snapper.off()
-             self.ui.offUi()
-             if callback:
--                if len(inspect.getargspec(callback).args) > 1:
-+                if len(inspect.getfullargspec(callback).args) > 1:
-                     obj = None
-                     if self.snapInfo and ("Object" in self.snapInfo) and self.snapInfo["Object"]:
-                         obj = App.ActiveDocument.getObject(self.snapInfo["Object"])
-@@ -1445,7 +1445,7 @@ class Snapper:
-             Gui.Snapper.off()
-             self.ui.offUi()
-             if callback:
--                if len(inspect.getargspec(callback).args) > 1:
-+                if len(inspect.getfullargspec(callback).args) > 1:
-                     callback(None, None)
-                 else:
-                     callback(None)
diff --git a/srcpkgs/freecad/template b/srcpkgs/freecad/template
index c135701e38b9ad..7d5165f760bab9 100644
--- a/srcpkgs/freecad/template
+++ b/srcpkgs/freecad/template
@@ -1,7 +1,7 @@
 # Template file for 'freecad'
 pkgname=freecad
-version=0.20.2
-revision=7
+version=0.21.1
+revision=2
 build_wrksrc="FreeCAD-${version}"
 build_style=cmake
 pycompile_dirs="usr/lib/${pkgname}/Mod"
@@ -24,8 +24,10 @@ makedepends="python3-devel boost-devel libxerces-c-devel zlib-devel occt-devel
  coin3-devel libshiboken2-devel libspnav-devel pyside2-tools
  liblz4-devel libpyside2-python3-devel python3-matplotlib netcdf-devel
  jsoncpp-devel qt5-devel qt5-svg-devel qt5-tools-devel qt5-webkit-devel
- qt5-xmlpatterns-devel coin3-doc glew-devel python3-pivy"
-depends="python3-matplotlib python3-pyside2-webengine python3-pivy"
+ qt5-xmlpatterns-devel coin3-doc glew-devel python3-pivy qt5-webengine-devel
+ qt5-declarative-devel qt5-webchannel-devel qt5-location-devel"
+depends="python3-matplotlib python3-pyside2-webengine python3-pivy
+ python3-GitPython python3-Markdown"
 short_desc="General purpose 3D CAD modeler"
 maintainer="yopito <pierre.bourgin@free.fr>"
 license="LGPL-2.0-or-later"
@@ -35,7 +37,7 @@ distfiles="
  https://github.com/FreeCAD/FreeCAD/archive/${version}.tar.gz
  ${SOURCEFORGE_SITE}/cxx/pycxx-${_pycxxver}.tar.gz
 "
-checksum="46922f3a477e742e1a89cd5346692d63aebb2b67af887b3e463e094a4ae055da
+checksum="e9b1fd0323f101268c7f3be52db42e4a29222f2e306ae6c4a6fc309cb418d35a
  4b91e1e1141c23fbd5039df635c4bb6e75632168548f56b83ce177193c0c98c6"
 python_version=3
 patch_args="-Np1 -d ${build_wrksrc}"

From cdcccde66de9fc1fe58288a95043c078ebb3db1d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:47:18 -0400
Subject: [PATCH 088/110] libopenshot: revbump for ffmpeg6

---
 srcpkgs/libopenshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenshot/template b/srcpkgs/libopenshot/template
index 8e57c5f592169c..7a8f4520e78925 100644
--- a/srcpkgs/libopenshot/template
+++ b/srcpkgs/libopenshot/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenshot'
 pkgname=libopenshot
 version=0.3.0
-revision=3
+revision=4
 build_style=cmake
 # Builds fail with Ruby-2.4.1
 configure_args="-DENABLE_RUBY=OFF -DUSE_SYSTEM_JSONCPP=ON"

From cbebe0219bb31907faef2257d19bca09f42bd584 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:10:30 -0500
Subject: [PATCH 089/110] openimageio: revbump for ffmpeg6

---
 srcpkgs/openimageio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimageio/template b/srcpkgs/openimageio/template
index 27d2131bc0a61a..61f44b43f9083e 100644
--- a/srcpkgs/openimageio/template
+++ b/srcpkgs/openimageio/template
@@ -1,7 +1,7 @@
 # Template file for 'openimageio'
 pkgname=openimageio
 version=2.4.9.0
-revision=8
+revision=9
 build_style=cmake
 build_helper=qemu
 configure_args="-DUSE_QT=0 -DUSE_PYTHON=0 -DOIIO_BUILD_TESTS=0

From f0e3e77dbd24dba683b8650b7429afb3b1d02776 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:11:57 -0500
Subject: [PATCH 090/110] synfigstudio: revbump for ffmpeg6

---
 srcpkgs/synfigstudio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/synfigstudio/template b/srcpkgs/synfigstudio/template
index 09e442da9a6805..2bc017cedca6b8 100644
--- a/srcpkgs/synfigstudio/template
+++ b/srcpkgs/synfigstudio/template
@@ -2,7 +2,7 @@
 # Should be kept in sync with 'synfig' and 'ETL'
 pkgname=synfigstudio
 version=1.4.4
-revision=4
+revision=5
 build_style=gnu-configure
 configure_args="--disable-update-mimedb"
 hostmakedepends="pkg-config intltool gettext synfig"

From 6bd818c695ce84601af7adff7c0ad6491c279492 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:10 -0500
Subject: [PATCH 091/110] mixxx: revbump for ffmpeg6

---
 srcpkgs/mixxx/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mixxx/template b/srcpkgs/mixxx/template
index 6a79b328c1abf0..9a5141856860b9 100644
--- a/srcpkgs/mixxx/template
+++ b/srcpkgs/mixxx/template
@@ -1,7 +1,7 @@
 # Template file for 'mixxx'
 pkgname=mixxx
 version=2.3.3
-revision=7
+revision=8
 build_style=cmake
 configure_args="-DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="extra-cmake-modules pkg-config protobuf qt5-host-tools qt5-qmake"

From 22e63868fa96bcfc2524082d71c022cf710463ce Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:28 -0500
Subject: [PATCH 092/110] musikcube: revbump for ffmpeg6

---
 srcpkgs/musikcube/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/musikcube/template b/srcpkgs/musikcube/template
index 8c4a51840859ec..fb60dd2049089a 100644
--- a/srcpkgs/musikcube/template
+++ b/srcpkgs/musikcube/template
@@ -1,7 +1,7 @@
 # Template file for 'musikcube'
 pkgname=musikcube
 version=3.0.0
-revision=3
+revision=4
 build_style=cmake
 make_cmd=make
 configure_args="-DNO_NCURSESW=1"

From 1e9ca683ae1c7d1585fc6cf59576430de1eb9ace Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:45 -0500
Subject: [PATCH 093/110] electron24: revbump for ffmpeg6

---
 srcpkgs/electron24/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron24/template b/srcpkgs/electron24/template
index 7b4e28812f483e..1ca93fde97a854 100644
--- a/srcpkgs/electron24/template
+++ b/srcpkgs/electron24/template
@@ -1,7 +1,7 @@
 # Template file for 'electron24'
 pkgname=electron24
 version=24.3.0
-revision=2
+revision=3
 _nodever=18.14.0
 _chromiumver=112.0.5615.165
 archs="x86_64* aarch64*"

From f5a77a9bd1240f26b6b136928ada28c08f08e017 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:00 -0500
Subject: [PATCH 094/110] electron19: revbump for ffmpeg6

---
 srcpkgs/electron19/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron19/template b/srcpkgs/electron19/template
index 0ef959125cb085..5371c0b354604f 100644
--- a/srcpkgs/electron19/template
+++ b/srcpkgs/electron19/template
@@ -1,7 +1,7 @@
 # Template file for 'electron19'
 pkgname=electron19
 version=19.0.8
-revision=4
+revision=5
 _nodever=16.14.2
 _chromiumver=102.0.5005.125
 archs="x86_64* aarch64* ppc64le*"

From dbbc21ce943cec3061535625718d974893fa9856 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:13 -0500
Subject: [PATCH 095/110] wf-recorder: revbump for ffmpeg6

---
 srcpkgs/wf-recorder/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/wf-recorder/template b/srcpkgs/wf-recorder/template
index 08f986b0310067..63c45cf4b814d7 100644
--- a/srcpkgs/wf-recorder/template
+++ b/srcpkgs/wf-recorder/template
@@ -1,7 +1,7 @@
 # Template file for 'wf-recorder'
 pkgname=wf-recorder
 version=0.4.1
-revision=2
+revision=3
 build_style=meson
 hostmakedepends="pkg-config scdoc wayland-devel"
 makedepends="wayland-protocols wayland-devel ffmpeg-devel libgbm-devel x264-devel

From cbd80b4591d86b928dbcd9d3053a1a1c2e5071af Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:26 -0500
Subject: [PATCH 096/110] obs: revbump for ffmpeg6

---
 srcpkgs/obs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/obs/template b/srcpkgs/obs/template
index b343f1131bfcf6..a25a67433e285e 100644
--- a/srcpkgs/obs/template
+++ b/srcpkgs/obs/template
@@ -1,7 +1,7 @@
 # Template file for 'obs'
 pkgname=obs
 version=30.0.0
-revision=2
+revision=3
 archs="i686* x86_64* ppc64le* aarch64* riscv64*"
 build_style=cmake
 configure_args="-DOBS_VERSION_OVERRIDE=${version} -DENABLE_JACK=ON

From cd8ba7607d3016b76824f1153038b05e51d7664a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:36 -0500
Subject: [PATCH 097/110] mlt7: revbump for ffmpeg6

---
 srcpkgs/mlt7/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mlt7/template b/srcpkgs/mlt7/template
index 98f302ad3a5167..7eb8c00fa1580c 100644
--- a/srcpkgs/mlt7/template
+++ b/srcpkgs/mlt7/template
@@ -1,7 +1,7 @@
 # Template file for 'mlt7'
 pkgname=mlt7
 version=7.20.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DSWIG_PYTHON=ON -DMOD_QT6=ON"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which

From f9b228d7a7eede90b01e289eac5ef13fdaf9fc7d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:48 -0500
Subject: [PATCH 098/110] qt6-multimedia: revbump for ffmpeg6

---
 srcpkgs/qt6-multimedia/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-multimedia/template b/srcpkgs/qt6-multimedia/template
index 67a577e1300fea..1da626ecf515a8 100644
--- a/srcpkgs/qt6-multimedia/template
+++ b/srcpkgs/qt6-multimedia/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-multimedia'
 pkgname=qt6-multimedia
 version=6.6.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DQT_FEATURE_gstreamer=ON"
 hostmakedepends="perl qt6-declarative-host-tools pkg-config qt6-shadertools"

From 2e43eea3a7465390bf04c50affa486e049eff4b1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:00:15 -0500
Subject: [PATCH 099/110] baresip: revbump for ffmpeg6

---
 srcpkgs/baresip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/baresip/template b/srcpkgs/baresip/template
index b16b67beab8d2b..fe21ebf40c03c1 100644
--- a/srcpkgs/baresip/template
+++ b/srcpkgs/baresip/template
@@ -1,7 +1,7 @@
 # Template file for 'baresip'
 pkgname=baresip
 version=3.6.0
-revision=3
+revision=4
 build_style=cmake
 hostmakedepends="pkg-config glib-devel"
 makedepends="libgsm-devel libpng-devel openssl-devel libsndfile-devel

From a7a235415ded6531fa905e70ce67479a7d6ef301 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:30 -0500
Subject: [PATCH 100/110] QMPlay2: revbump for ffmpeg6

---
 srcpkgs/QMPlay2/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/QMPlay2/template b/srcpkgs/QMPlay2/template
index 46c80f64a13497..942258ce60fb7e 100644
--- a/srcpkgs/QMPlay2/template
+++ b/srcpkgs/QMPlay2/template
@@ -1,7 +1,7 @@
 # Template file for 'QMPlay2'
 pkgname=QMPlay2
 version=23.10.22
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools"
 makedepends="alsa-lib-devel ffmpeg-devel libass-devel libcdio-devel libgme-devel

From 68454494163cf8b87483a7b656c1070c638f9764 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:34 -0500
Subject: [PATCH 101/110] alsa-plugins: revbump for ffmpeg6

---
 srcpkgs/alsa-plugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/alsa-plugins/template b/srcpkgs/alsa-plugins/template
index a5708a7d82a8f0..7bfdad046c4830 100644
--- a/srcpkgs/alsa-plugins/template
+++ b/srcpkgs/alsa-plugins/template
@@ -1,7 +1,7 @@
 # Template file for 'alsa-plugins'
 pkgname=alsa-plugins
 version=1.2.7.1
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--disable-maemo-plugin"
 hostmakedepends="pkg-config"

From 8ffca31537f2dee83d8901a579dfe07f840edbc1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:43 -0500
Subject: [PATCH 102/110] minidlna: revbump for ffmpeg6

---
 srcpkgs/minidlna/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/minidlna/template b/srcpkgs/minidlna/template
index 5fa929f3a0c124..742991ecd04afc 100644
--- a/srcpkgs/minidlna/template
+++ b/srcpkgs/minidlna/template
@@ -1,7 +1,7 @@
 # Template file for 'minidlna'
 pkgname=minidlna
 version=1.3.3
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="
  --sbindir=/usr/bin

From b4cb81656bf866953e5f56fe20087d0e8d734e80 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 17:57:47 -0500
Subject: [PATCH 103/110] mpv: revbump for ffmpeg6

---
 srcpkgs/mpv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpv/template b/srcpkgs/mpv/template
index 3d4349e27d8f62..bc40d6fcaa40d6 100644
--- a/srcpkgs/mpv/template
+++ b/srcpkgs/mpv/template
@@ -1,7 +1,7 @@
 # Template file for 'mpv'
 pkgname=mpv
 version=0.37.0
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcdda=enabled -Ddvbin=enabled -Ddvdnav=enabled
  -Dlibmpv=true -Dcplugins=enabled

From 86b3ca1cecbc6d86ddde183b1afb0e7ead9f2c32 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 17:59:29 -0500
Subject: [PATCH 104/110] qimgv: revbump for ffmpeg6

---
 srcpkgs/qimgv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qimgv/template b/srcpkgs/qimgv/template
index dd341dfe1bfce8..8a7e1c081ef12f 100644
--- a/srcpkgs/qimgv/template
+++ b/srcpkgs/qimgv/template
@@ -1,7 +1,7 @@
 # Template file for 'qimgv'
 pkgname=qimgv
 version=1.0.2
-revision=3
+revision=4
 build_style=cmake
 configure_args="$(vopt_if video -DVIDEO_SUPPORT=ON -DVIDEO_SUPPORT=OFF)
  $(vopt_if scale -DOPENCV_SUPPORT=ON -DOPENCV_SUPPORT=OFF)

From fa767191db501f2edd32f963e55cc24b005fd8dc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 18:00:36 -0500
Subject: [PATCH 105/110] kfilemetadata5: revbump for ffmpeg6

---
 srcpkgs/kfilemetadata5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kfilemetadata5/template b/srcpkgs/kfilemetadata5/template
index a0c4d809395323..b584f85ff2058b 100644
--- a/srcpkgs/kfilemetadata5/template
+++ b/srcpkgs/kfilemetadata5/template
@@ -1,7 +1,7 @@
 # Template file for 'kfilemetadata5'
 pkgname=kfilemetadata5
 version=5.115.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="kcoreaddons extra-cmake-modules pkg-config qt5-host-tools qt5-qmake
  gettext kcoreaddons python3"

From 3f8f530f12f6c4c663e953a32707a6c5a2e6bda6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 8 Dec 2023 11:46:01 -0500
Subject: [PATCH 106/110] vba-m: revbump for ffmpeg6

---
 srcpkgs/vba-m/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vba-m/template b/srcpkgs/vba-m/template
index 3d135efa1d0b69..3c5a20db0fa984 100644
--- a/srcpkgs/vba-m/template
+++ b/srcpkgs/vba-m/template
@@ -2,7 +2,7 @@
 pkgname=vba-m
 reverts=1292_2
 version=2.1.9
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_GTK=TRUE -DENABLE_FFMPEG=TRUE -DENABLE_LINK=TRUE -DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="gettext pkg-config unzip zip yasm wxWidgets-gtk3-devel"

From 9e2f035397d946bbcad68be8a1e1d04c23ec0d3f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 8 Dec 2023 11:46:19 -0500
Subject: [PATCH 107/110] dolphin-emu: revbump for ffmpeg6

---
 srcpkgs/dolphin-emu/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/dolphin-emu/template b/srcpkgs/dolphin-emu/template
index 862d3ae964eec4..a7ae0efb58fb75 100644
--- a/srcpkgs/dolphin-emu/template
+++ b/srcpkgs/dolphin-emu/template
@@ -1,7 +1,7 @@
 # Template file for 'dolphin-emu'
 pkgname=dolphin-emu
 version=5.0.19368
-revision=3
+revision=4
 _dolphin_commit=dadbeb4bae7e7fa23af2b46e0add4143094dc107
 _mgba_commit=44e074a15e9651481f7f652ac006a7c9d58cbeb9
 _googletest_commit=be03d00f5f0cc3a997d1a368bee8a1fe93651f48

From 249352551c03643afd2ae390f7c07198b30f07e3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 19 Dec 2023 15:38:51 -0500
Subject: [PATCH 108/110] qtox: revbump for ffmpeg4

---
 srcpkgs/qtox/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtox/template b/srcpkgs/qtox/template
index bb70e7f51240a4..755e4462bc0137 100644
--- a/srcpkgs/qtox/template
+++ b/srcpkgs/qtox/template
@@ -1,13 +1,13 @@
 # Template file for 'qtox'
 pkgname=qtox
 version=1.17.6
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DUPDATE_CHECK=OFF
  -DGIT_DESCRIBE=${version}
  $(vopt_if snorenotify -DDESKTOP_NOTIFICATIONS=ON)"
 hostmakedepends="pkg-config qt5-host-tools qt5-devel"
-makedepends="ffmpeg-devel libexif-devel libopenal-devel libsodium-devel
+makedepends="ffmpeg4-devel libexif-devel libopenal-devel libsodium-devel
  libvpx-devel opus-devel qrencode-devel qt5-svg-devel sonnet-devel
  sqlcipher-devel toxcore-devel
  $(vopt_if snorenotify snorenotify-devel)"

From bb60be75824f9eafb30f606ec1c20a94037dffdb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 11 Jan 2024 11:52:00 -0500
Subject: [PATCH 109/110] arcan: revbump for ffmpeg6

---
 srcpkgs/arcan/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/arcan/template b/srcpkgs/arcan/template
index ff9091f90ebb10..030091a6cc9d0c 100644
--- a/srcpkgs/arcan/template
+++ b/srcpkgs/arcan/template
@@ -2,7 +2,7 @@
 # !! keep synced with: acfgfs aclip aloadimage
 pkgname=arcan
 version=0.6.2.1
-revision=2
+revision=3
 create_wrksrc=yes
 build_wrksrc=arcan/src
 build_style=cmake

From faf6bd3b4ec59dad78654942b75a0f3c43ca85e2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 11 Jan 2024 11:52:10 -0500
Subject: [PATCH 110/110] notcurses: revbump for ffmpeg6

---
 srcpkgs/notcurses/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/notcurses/template b/srcpkgs/notcurses/template
index 48a7463cb68eb9..515f316ab4576c 100644
--- a/srcpkgs/notcurses/template
+++ b/srcpkgs/notcurses/template
@@ -1,7 +1,7 @@
 # Template file for 'notcurses'
 pkgname=notcurses
 version=3.0.9
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DUSE_STATIC=ON -DUSE_QRCODEGEN=On $(vopt_bool man USE_PANDOC)"
 hostmakedepends="pkg-config $(vopt_if man pandoc)"

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (91 preceding siblings ...)
  2024-03-12 17:08 ` [PR PATCH] [Updated] " zlice
@ 2024-03-18 20:07 ` zlice
  2024-03-21 21:29 ` zlice
                   ` (4 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2024-03-18 20:07 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 4960 bytes --]

There is an updated pull request by zlice against master on the void-packages repository

https://github.com/zlice/void-packages ffmpeg6-split
https://github.com/void-linux/void-packages/pull/43761

ffmpeg6 split
[ci skip]


#### Testing the changes

- I tested the changes in this PR: **YES**

main testing has been vaapi in Firefox Nightly and enc/dec in Shotcut on Intel A770

#### New package

- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**

#### Local build testing

- I built this PR locally for my native architecture, **x86_64**

#### Discussion

Continuation of https://github.com/void-linux/void-packages/pull/36315

`libavresample` is deprecated, but marked as a dependency when trying to build other packages and install `ffmpeg`(6). I think the right way to handle this is make a meta package and the add to removals?


##### Commit naming / misc

~~Commits are 'dirty' right now, running with [gstreamer 1.22.1 updates](https://github.com/void-linux/void-packages/pull/42861) and [Intel OpenCL](https://github.com/void-linux/void-packages/pull/43084). This will also make [intel packages pr](https://github.com/void-linux/void-packages/pull/41132) obsolete.~~ (see Requirements below)

Maintainer for previous ffmpeg(4) was orphaned, I can put my name in there if that matters, though I don't exactly see myself keeping up on ffmpeg.

~~This updates QT5 which looks like it is usually hosted by Johnny. Not sure if there's any reason to stay there or these sources are fine.~~ Using qt5.15.11 now, revbumps and some patches.

##### STILL FFMPEG4

These are a mix of emulators, games and/or older packages.

- ~~attract~~ (2.7 builds)
- ~~audacity (https://github.com/audacity/audacity/issues/2305 and https://sourceforge.net/p/portmedia/wiki/portsmf/ is 'beta')~~ (updated to 3.x, compiles with ffmpeg6)
- ~~ccextractor~~ (master patches)
- vice (3.8 compiles, needs makedepends libcurl-devel)
- kodi
- mlt (only dep left is flowblade - flowblade 2.12.0.2 with mlt7-python3 can 'render' videos with cpu and gpu - https://github.com/void-linux/void-packages/pull/47195)
- ~~synfig (mlt)~~ (work with mlt7, bump synfigstudio)
- tvheadend (download page recommends using 4.3 which compiles fine, 4.4 eta is Q1 2024)
- ~~ssr~~ (patches)
- ~~spek-alternative~~ (replace with spek-x)
- ~~ppsspp~~ ~~(1.17.1 is out, but there's 5+ distfiles that are all git commits)~~ (minor patch)
- olive (has been in alpha since 2020, seems they do nightly builds and appimages)
- moc
- mediastreamer (linphone links are dead, changed to github belladonne. their stuff never worked for me but there are updates if someone wants to give it a try)
- ~~libextractor (1.13 compiles, remove exiv2 patch)~~ (as yosh pointed out, 1.13 just removes ffmpeg bits)
- idjc (0.9.8 compiles, remove python3.10 patch, needs makedepends libebur128-devel and libshout-idjc 2.4.6 with '-r1' for distfile)
- hedgewars
- ~~ffmpegthumbnailer~~ (patches for moviedecoder.xxx files)
- ~~ffmpegthumbs~~ (latest compiles)
- deadbeef (1.9.6 may work but requires libdispatch from apple)
- ~~omxplayer~~ (package removed, deprecated in favor of vlc)
- qtav (fork has ffmpeg 5 patch - https://github.com/cmguo/QtAV)
- `vlc` (vlc4 will support ffmpeg5, there's a patch to build 3.x with ffmpeg5 but it will lack vaapi)
- `osg` (OpenSceneGraph plus `xine-lib`)


##### HAVE NOT BUILT YET

- ~~omxplayer (rpi only? ffmpeg4)~~ (removed)
- kodi (big, but ffmpeg4)


##### UPDATED (for ffmpeg6)

- ~~blender: update to 3.5.1~~ ~~will be revbump with~~ https://github.com/void-linux/void-packages/pull/43992
- unpaper: update to 7.0.0.
- guvcview: update to 2.0.8.
- ~~qt5: update to 5.15.8~~ updated by another PR to 5.15.11
- ~~qt5-webengine: update to 5.18.15~~ updated by another PR to 5.15.16 (some patching for ffmpeg build)
- ~~shiboken2: revbump for qt5.15.8 (patch)~~ updated by another PR to 5.15.10
- ~~python3-pyside2: update to 5.15.8 (patch)~~ updated by another PR to 5.15.10
- New package: spex-x replaces spek-alternative for ffmpeg-6.0


##### Requirements

- ~~[gstreamer 1.22.2](https://github.com/void-linux/void-packages/pull/42861)~~ - a few packages use ffmpeg-devel and require a revbump

- ~~[Intel Packages](https://github.com/void-linux/void-packages/pull/41132) [Intel Packages v2](https://github.com/void-linux/void-packages/pull/47330) - ffmpeg4 uses different libraries than 6 (libmfx / Intel-MediaSDK vs only oneVPL that Intel is moving to), both are included here~~. Using replacement oneVPL from OBS update.

- ~~[shotcut 23.05.14](https://github.com/void-linux/void-packages/pull/44260)~~

- https://github.com/void-linux/void-packages/pull/44781 will remove from this PR

A patch file from https://github.com/void-linux/void-packages/pull/43761.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ffmpeg6-split-43761.patch --]
[-- Type: text/x-diff, Size: 240242 bytes --]

From 6f1fdd2e2d18940a42795397f4595063ad5f8a7f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:16:56 -0400
Subject: [PATCH 001/109] ffmpeg: update to 6.0.1.

---
 common/shlibs                                 | 26 ++++---
 srcpkgs/ffmpeg/files/altivec.patch            | 60 ---------------
 .../patches/armv5tel-floating-point.patch     | 18 -----
 srcpkgs/ffmpeg/patches/binutils-2.41.patch    | 73 -------------------
 ...h-libavcodec-libsvtav1-ten_bit_format.diff | 40 ----------
 .../workaround-mesa-readeon-vaapi-bug.patch   | 28 -------
 srcpkgs/ffmpeg/template                       | 40 +++++-----
 7 files changed, 37 insertions(+), 248 deletions(-)
 delete mode 100644 srcpkgs/ffmpeg/files/altivec.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/binutils-2.41.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 delete mode 100644 srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch

diff --git a/common/shlibs b/common/shlibs
index c39827e7d630a1..22cae2fcb156de 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -389,15 +389,23 @@ libid3tag.so.0 libid3tag-0.15.1b_1
 libgif.so.7 giflib-5.1.0_1
 libImlib2.so.1 imlib2-1.4.2_1
 libmp3lame.so.0 lame-3.98.2_1
-libavdevice.so.58 libavdevice-4.0_1
-libavformat.so.58 libavformat-4.0_1
-libswscale.so.5 libswscale-4.0_1
-libswresample.so.3 libswresample-4.0_1
-libavresample.so.4 libavresample-4.0_1
-libpostproc.so.55 libpostproc-4.0_1
-libavcodec.so.58 libavcodec-4.0_1
-libavutil.so.56 libavutil-4.0_1
-libavfilter.so.7 libavfilter-4.0_1
+libavdevice.so.60 libavdevice-6.0_1
+libavformat.so.60 libavformat-6.0_1
+libswscale.so.7 libswscale-6.0_1
+libswresample.so.4 libswresample-6.0_1
+libpostproc.so.57 libpostproc-6.0_1
+libavcodec.so.60 libavcodec-6.0_1
+libavutil.so.58 libavutil-6.0_1
+libavfilter.so.9 libavfilter-6.0_1
+libavdevice.so.58 libavdevice4-4.0_1
+libavformat.so.58 libavformat4-4.0_1
+libswscale.so.5 libswscale4-4.0_1
+libswresample.so.3 libswresample4-4.0_1
+libavresample.so.4 libavresample4-4.0_1
+libpostproc.so.55 libpostproc4-4.0_1
+libavcodec.so.58 libavcodec4-4.0_1
+libavutil.so.56 libavutil4-4.0_1
+libavfilter.so.7 libavfilter4-4.0_1
 libSDL-1.2.so.0 SDL-1.2.14_1
 libSDL_image-1.2.so.0 SDL_image-1.2.10_1
 libx264.so.157 x264-20190507.2245_1
diff --git a/srcpkgs/ffmpeg/files/altivec.patch b/srcpkgs/ffmpeg/files/altivec.patch
deleted file mode 100644
index 9c57200463320e..00000000000000
--- a/srcpkgs/ffmpeg/files/altivec.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-revert some altivec specific change on all ppc* except ppc64le*
-
-q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
-conditionally, for ppc* but not ppc64le* (the new code is valid for
-POWER8 VSX which LE targets as a baseline but not BE)"
-
-
-This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
----
- libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
- 1 file changed, 20 insertions(+), 4 deletions(-)
-
-diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
-index 536545293d..c1e2852adb 100644
---- a/libswscale/ppc/yuv2rgb_altivec.c
-+++ b/libswscale/ppc/yuv2rgb_altivec.c
-@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-     vector signed short R1, G1, B1;                                           \
-     vector unsigned char R, G, B;                                             \
-                                                                               \
-+    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
-+    vector unsigned char align_perm;                                          \
-+                                                                              \
-     vector signed short lCY       = c->CY;                                    \
-     vector signed short lOY       = c->OY;                                    \
-     vector signed short lCRV      = c->CRV;                                   \
-@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
-                                                                               \
-         for (j = 0; j < w / 16; j++) {                                        \
--            y0 = vec_xl(0, y1i);                                              \
-+            y1ivP = (const vector unsigned char *) y1i;                       \
-+            y2ivP = (const vector unsigned char *) y2i;                       \
-+            uivP  = (const vector unsigned char *) ui;                        \
-+            vivP  = (const vector unsigned char *) vi;                        \
-+                                                                              \
-+            align_perm = vec_lvsl(0, y1i);                                    \
-+            y0 = (vector unsigned char)                                       \
-+                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
-                                                                               \
--            y1 = vec_xl(0, y2i);                                              \
-+            align_perm = vec_lvsl(0, y2i);                                    \
-+            y1 = (vector unsigned char)                                       \
-+                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
-                                                                               \
--            u = (vector signed char) vec_xl(0, ui);                           \
-+            align_perm = vec_lvsl(0, ui);                                     \
-+            u = (vector signed char)                                          \
-+                    vec_perm(uivP[0], uivP[1], align_perm);                   \
-                                                                               \
--            v = (vector signed char) vec_xl(0, vi);                           \
-+            align_perm = vec_lvsl(0, vi);                                     \
-+            v = (vector signed char)                                          \
-+                    vec_perm(vivP[0], vivP[1], align_perm);                   \
-                                                                               \
-             u = (vector signed char)                                          \
-                     vec_sub(u,                                                \
--- 
-2.27.0
-
diff --git a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
deleted file mode 100644
index 9a55178c74f0fd..00000000000000
--- a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
-+++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
-@@ -39,6 +39,15 @@
- #endif
- #include <fenv.h>
- 
-+#if (FE_ALL_EXCEPT == 0)
-+/* E.g. ARM soft float does not define these */
-+#define FE_INVALID    0
-+#define FE_DIVBYZERO  0
-+#define FE_OVERFLOW   0
-+#define FE_UNDERFLOW  0
-+#define FE_INEXACT    0
-+#endif
-+
- #if CONFIG_LIBFONTCONFIG
- #include <fontconfig/fontconfig.h>
- #endif
diff --git a/srcpkgs/ffmpeg/patches/binutils-2.41.patch b/srcpkgs/ffmpeg/patches/binutils-2.41.patch
deleted file mode 100644
index 53a596d0ee7d4e..00000000000000
--- a/srcpkgs/ffmpeg/patches/binutils-2.41.patch
+++ /dev/null
@@ -1,73 +0,0 @@
-From effadce6c756247ea8bae32dc13bb3e6f464f0eb Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= <remi@remlab.net>
-Date: Sun, 16 Jul 2023 18:18:02 +0300
-Subject: [PATCH] avcodec/x86/mathops: clip constants used with shift
- instructions within inline assembly
-
-Fixes assembling with binutil as >= 2.41
-
-Signed-off-by: James Almer <jamrial@gmail.com>
----
- libavcodec/x86/mathops.h | 26 +++++++++++++++++++++++---
- 1 file changed, 23 insertions(+), 3 deletions(-)
-
-diff --git a/libavcodec/x86/mathops.h b/libavcodec/x86/mathops.h
-index 6298f5ed1983b..ca7e2dffc1076 100644
---- a/libavcodec/x86/mathops.h
-+++ b/libavcodec/x86/mathops.h
-@@ -35,12 +35,20 @@
- static av_always_inline av_const int MULL(int a, int b, unsigned shift)
- {
-     int rt, dummy;
-+    if (__builtin_constant_p(shift))
-     __asm__ (
-         "imull %3               \n\t"
-         "shrdl %4, %%edx, %%eax \n\t"
-         :"=a"(rt), "=d"(dummy)
--        :"a"(a), "rm"(b), "ci"((uint8_t)shift)
-+        :"a"(a), "rm"(b), "i"(shift & 0x1F)
-     );
-+    else
-+        __asm__ (
-+            "imull %3               \n\t"
-+            "shrdl %4, %%edx, %%eax \n\t"
-+            :"=a"(rt), "=d"(dummy)
-+            :"a"(a), "rm"(b), "c"((uint8_t)shift)
-+        );
-     return rt;
- }
- 
-@@ -113,19 +121,31 @@ __asm__ volatile(\
- // avoid +32 for shift optimization (gcc should do that ...)
- #define NEG_SSR32 NEG_SSR32
- static inline  int32_t NEG_SSR32( int32_t a, int8_t s){
-+    if (__builtin_constant_p(s))
-     __asm__ ("sarl %1, %0\n\t"
-          : "+r" (a)
--         : "ic" ((uint8_t)(-s))
-+         : "i" (-s & 0x1F)
-     );
-+    else
-+        __asm__ ("sarl %1, %0\n\t"
-+               : "+r" (a)
-+               : "c" ((uint8_t)(-s))
-+        );
-     return a;
- }
- 
- #define NEG_USR32 NEG_USR32
- static inline uint32_t NEG_USR32(uint32_t a, int8_t s){
-+    if (__builtin_constant_p(s))
-     __asm__ ("shrl %1, %0\n\t"
-          : "+r" (a)
--         : "ic" ((uint8_t)(-s))
-+         : "i" (-s & 0x1F)
-     );
-+    else
-+        __asm__ ("shrl %1, %0\n\t"
-+               : "+r" (a)
-+               : "c" ((uint8_t)(-s))
-+        );
-     return a;
- }
- 
diff --git a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
deleted file mode 100644
index aa948f7a8a2dfb..00000000000000
--- a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
+++ /dev/null
@@ -1,40 +0,0 @@
-#==================================================================================================
-# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
-# From: Christopher Degawa <christopher.degawa@intel.com>
-# Date: Thu, 20 Oct 2022 22:55:27 -0500
-# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
-#
-# compressed_ten_bit_format has been deprecated upstream and has no effect
-# and can be removed. Plus, technically it was never used in the first place
-# since it would require the app (ffmpeg) to set it and do additional
-# processing of the input frames.
-#
-# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
-#
-# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
-#==================================================================================================
---- a/libavcodec/libsvtav1.c
-+++ b/libavcodec/libsvtav1.c
-@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
- 
- static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
- {
--    const int    pack_mode_10bit =
--        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
--    const size_t luma_size_8bit  =
--        config->source_width * config->source_height * (1 << pack_mode_10bit);
--    const size_t luma_size_10bit =
--        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
-+    const size_t luma_size = config->source_width * config->source_height *
-+        (config->encoder_bit_depth > 8 ? 2 : 1);
- 
-     EbSvtIOFormat *in_data;
- 
--    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
-+    svt_enc->raw_size = luma_size * 3 / 2;
- 
-     // allocate buffer for in and out
-     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
--- 
-GitLab
-
diff --git a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
deleted file mode 100644
index 00e3f68a415b84..00000000000000
--- a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
-From: Rainer Hochecker <fernetmenta@online.de>
-Date: Sat, 26 Jan 2019 19:48:35 +0100
-Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
-
-This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
-It was hit frequently when watching h264 channels received via DVB-X.
-Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
----
- libavcodec/vaapi_h264.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
-index 5854587a255..f12fdc457a4 100644
---- a/libavcodec/vaapi_h264.c
-+++ b/libavcodec/vaapi_h264.c
-@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
-     H264SliceContext *sl = &h->slice_ctx[0];
-     int ret;
- 
-+    if (pic->nb_slices == 0) {
-+        ret = AVERROR_INVALIDDATA;
-+        goto finish;
-+    }
-+
-     ret = ff_vaapi_decode_issue(avctx, pic);
-     if (ret < 0)
-         goto finish;
diff --git a/srcpkgs/ffmpeg/template b/srcpkgs/ffmpeg/template
index 1ebb436135938d..f1e4712c41d087 100644
--- a/srcpkgs/ffmpeg/template
+++ b/srcpkgs/ffmpeg/template
@@ -1,15 +1,15 @@
 # Template file for 'ffmpeg'
 # audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
 pkgname=ffmpeg
-version=4.4.4
-revision=6
+version=6.0.1
+revision=1
 short_desc="Decoding, encoding and streaming software"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="https://www.ffmpeg.org"
 changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
 distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
-checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+checksum=9b16b8731d78e596b4be0d720428ca42df642bb2d78342881ff7f5bc29fc9623
 
 hostmakedepends="pkg-config perl"
 makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
@@ -26,12 +26,13 @@ makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-deve
  $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
  $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
  $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
- $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers Vulkan-Tools Vulkan-ValidationLayers')
+ $(vopt_if onevpl 'oneVPL oneVPL-devel')
  $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
 depends="ffplay>=${version}_${revision}"
 
 build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
- dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec onevpl"
 build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
 desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
 desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
@@ -39,9 +40,13 @@ desc_option_sofa="Enable support for AES SOFA"
 desc_option_webp="Enable support for WebP"
 
 case "$XBPS_TARGET_MACHINE" in
-	i686*|x86_64*)
-		hostmakedepends+=" nasm"
+	i686*)
 		build_options_default+=" vaapi vdpau nvenc nvdec"
+		hostmakedepends+=" nasm"
+		;;
+	x86_64*)
+		hostmakedepends+=" nasm"
+		build_options_default+=" vaapi vdpau nvenc nvdec onevpl"
 		;;
 	ppc64*) build_options_default+=" vaapi vdpau";;
 	mips*) CFLAGS="-mnan=legacy";;
@@ -65,8 +70,6 @@ post_patch() {
 		ppc64le*) ;;
 		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
 	esac
-
-	vsed -i libavfilter/vf_libvmaf.c -e 's!/usr/local/share/model/\(vmaf_v0.6.1\).pkl!/usr/share/vmaf/\1.json!'
 }
 
 do_configure() {
@@ -115,18 +118,19 @@ do_configure() {
 		$(vopt_enable x265 libx265) \
 		$(vopt_enable v4l2 libv4l2) \
 		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
-		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		--enable-libbs2b --enable-libvidstab \
 		$(vopt_enable dav1d libdav1d) \
 		$(vopt_enable zimg libzimg) \
 		$(vopt_enable webp libwebp) \
 		$(vopt_enable sofa libmysofa) \
 		$(vopt_enable vulkan) \
+		$(vopt_enable onevpl libvpl) \
 		$(vopt_enable drm libdrm) \
 		$(vopt_enable svtav1 libsvtav1) \
 		$(vopt_enable srt libsrt) \
 		$(vopt_enable rist librist) \
-		$(vopt_if nvenc '--enable-nvenc') \
-		$(vopt_if nvdec '--enable-nvdec')
+		$(vopt_enable nvenc nvenc) \
+		$(vopt_enable nvdec nvdec)
 }
 
 do_build() {
@@ -153,10 +157,8 @@ libavdevice_package() {
 }
 
 libavresample_package() {
-	short_desc="FFmpeg audio resampling library"
-	pkg_install() {
-		vmove "usr/lib/libavresample.so.*"
-	}
+	short_desc="Package deprecated, removal needed"
+	build_style=meta
 }
 
 libavformat_package() {
@@ -210,15 +212,13 @@ ffmpeg-devel_package() {
 		libavfilter>=${version}_${revision}
 		libpostproc>=${version}_${revision}
 		libswscale>=${version}_${revision}
-		libswresample>=${version}_${revision}
-		libavresample>=${version}_${revision}"
+		libswresample>=${version}_${revision}"
 	short_desc+=" - development files"
-
+	conflicts="ffmpeg4-devel"
 	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
 		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
 		nostrip_files="/usr/lib/libavfilter.a"
 	fi
-
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig

From 61fb49cf4481fca45a8983ab3fef20abf0de39ca Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:14 -0400
Subject: [PATCH 002/109] openshot: revbump for ffmpeg6

---
 srcpkgs/openshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openshot/template b/srcpkgs/openshot/template
index 3849858fe963b5..12789bc9867499 100644
--- a/srcpkgs/openshot/template
+++ b/srcpkgs/openshot/template
@@ -1,7 +1,7 @@
 # Template file for 'openshot'
 pkgname=openshot
 version=3.1.1
-revision=1
+revision=2
 build_style=python3-module
 hostmakedepends="python3 python3-setuptools"
 makedepends="ffmpeg-devel python3-PyQt5"

From 4da64e5ff291711cb19338cf51bd4166fd7a5bc2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:36 -0400
Subject: [PATCH 003/109] sumo: revbump for ffmpeg6

---
 srcpkgs/sumo/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/sumo/template b/srcpkgs/sumo/template
index a730afa9fafa92..e2def06fa4bd7d 100644
--- a/srcpkgs/sumo/template
+++ b/srcpkgs/sumo/template
@@ -1,7 +1,7 @@
 # Template file for 'sumo'
 pkgname=sumo
 version=1.12.0
-revision=7
+revision=8
 build_style=cmake
 hostmakedepends="libgdal-tools pkg-config swig python3-setuptools"
 makedepends="python3-devel ffmpeg-devel fox-devel gl2ps-devel libgdal-devel

From 957d7921a114ecee5a605c9988b37662fbd41cf9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:56:22 -0400
Subject: [PATCH 004/109] New package: ffmpeg4-4.4.4.

---
 srcpkgs/ffmpeg4-devel                         |   1 +
 srcpkgs/ffmpeg4/files/altivec.patch           |  60 +++++
 .../patches/armv5tel-floating-point.patch     |  18 ++
 srcpkgs/ffmpeg4/patches/binutils-2.41.patch   |  73 ++++++
 ...h-libavcodec-libsvtav1-ten_bit_format.diff |  40 +++
 .../workaround-mesa-readeon-vaapi-bug.patch   |  28 +++
 srcpkgs/ffmpeg4/template                      | 234 ++++++++++++++++++
 srcpkgs/libavcodec4                           |   1 +
 srcpkgs/libavdevice4                          |   1 +
 srcpkgs/libavfilter4                          |   1 +
 srcpkgs/libavformat4                          |   1 +
 srcpkgs/libavresample4                        |   1 +
 srcpkgs/libavutil4                            |   1 +
 srcpkgs/libpostproc4                          |   1 +
 srcpkgs/libswresample4                        |   1 +
 srcpkgs/libswscale4                           |   1 +
 16 files changed, 463 insertions(+)
 create mode 120000 srcpkgs/ffmpeg4-devel
 create mode 100644 srcpkgs/ffmpeg4/files/altivec.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/binutils-2.41.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 create mode 100644 srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
 create mode 100644 srcpkgs/ffmpeg4/template
 create mode 120000 srcpkgs/libavcodec4
 create mode 120000 srcpkgs/libavdevice4
 create mode 120000 srcpkgs/libavfilter4
 create mode 120000 srcpkgs/libavformat4
 create mode 120000 srcpkgs/libavresample4
 create mode 120000 srcpkgs/libavutil4
 create mode 120000 srcpkgs/libpostproc4
 create mode 120000 srcpkgs/libswresample4
 create mode 120000 srcpkgs/libswscale4

diff --git a/srcpkgs/ffmpeg4-devel b/srcpkgs/ffmpeg4-devel
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/ffmpeg4-devel
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/ffmpeg4/files/altivec.patch b/srcpkgs/ffmpeg4/files/altivec.patch
new file mode 100644
index 00000000000000..9c57200463320e
--- /dev/null
+++ b/srcpkgs/ffmpeg4/files/altivec.patch
@@ -0,0 +1,60 @@
+revert some altivec specific change on all ppc* except ppc64le*
+
+q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
+conditionally, for ppc* but not ppc64le* (the new code is valid for
+POWER8 VSX which LE targets as a baseline but not BE)"
+
+
+This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
+---
+ libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
+ 1 file changed, 20 insertions(+), 4 deletions(-)
+
+diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
+index 536545293d..c1e2852adb 100644
+--- a/libswscale/ppc/yuv2rgb_altivec.c
++++ b/libswscale/ppc/yuv2rgb_altivec.c
+@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+     vector signed short R1, G1, B1;                                           \
+     vector unsigned char R, G, B;                                             \
+                                                                               \
++    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
++    vector unsigned char align_perm;                                          \
++                                                                              \
+     vector signed short lCY       = c->CY;                                    \
+     vector signed short lOY       = c->OY;                                    \
+     vector signed short lCRV      = c->CRV;                                   \
+@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
+                                                                               \
+         for (j = 0; j < w / 16; j++) {                                        \
+-            y0 = vec_xl(0, y1i);                                              \
++            y1ivP = (const vector unsigned char *) y1i;                       \
++            y2ivP = (const vector unsigned char *) y2i;                       \
++            uivP  = (const vector unsigned char *) ui;                        \
++            vivP  = (const vector unsigned char *) vi;                        \
++                                                                              \
++            align_perm = vec_lvsl(0, y1i);                                    \
++            y0 = (vector unsigned char)                                       \
++                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
+                                                                               \
+-            y1 = vec_xl(0, y2i);                                              \
++            align_perm = vec_lvsl(0, y2i);                                    \
++            y1 = (vector unsigned char)                                       \
++                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
+                                                                               \
+-            u = (vector signed char) vec_xl(0, ui);                           \
++            align_perm = vec_lvsl(0, ui);                                     \
++            u = (vector signed char)                                          \
++                    vec_perm(uivP[0], uivP[1], align_perm);                   \
+                                                                               \
+-            v = (vector signed char) vec_xl(0, vi);                           \
++            align_perm = vec_lvsl(0, vi);                                     \
++            v = (vector signed char)                                          \
++                    vec_perm(vivP[0], vivP[1], align_perm);                   \
+                                                                               \
+             u = (vector signed char)                                          \
+                     vec_sub(u,                                                \
+-- 
+2.27.0
+
diff --git a/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
new file mode 100644
index 00000000000000..9a55178c74f0fd
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
@@ -0,0 +1,18 @@
+--- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
++++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
+@@ -39,6 +39,15 @@
+ #endif
+ #include <fenv.h>
+ 
++#if (FE_ALL_EXCEPT == 0)
++/* E.g. ARM soft float does not define these */
++#define FE_INVALID    0
++#define FE_DIVBYZERO  0
++#define FE_OVERFLOW   0
++#define FE_UNDERFLOW  0
++#define FE_INEXACT    0
++#endif
++
+ #if CONFIG_LIBFONTCONFIG
+ #include <fontconfig/fontconfig.h>
+ #endif
diff --git a/srcpkgs/ffmpeg4/patches/binutils-2.41.patch b/srcpkgs/ffmpeg4/patches/binutils-2.41.patch
new file mode 100644
index 00000000000000..53a596d0ee7d4e
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/binutils-2.41.patch
@@ -0,0 +1,73 @@
+From effadce6c756247ea8bae32dc13bb3e6f464f0eb Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= <remi@remlab.net>
+Date: Sun, 16 Jul 2023 18:18:02 +0300
+Subject: [PATCH] avcodec/x86/mathops: clip constants used with shift
+ instructions within inline assembly
+
+Fixes assembling with binutil as >= 2.41
+
+Signed-off-by: James Almer <jamrial@gmail.com>
+---
+ libavcodec/x86/mathops.h | 26 +++++++++++++++++++++++---
+ 1 file changed, 23 insertions(+), 3 deletions(-)
+
+diff --git a/libavcodec/x86/mathops.h b/libavcodec/x86/mathops.h
+index 6298f5ed1983b..ca7e2dffc1076 100644
+--- a/libavcodec/x86/mathops.h
++++ b/libavcodec/x86/mathops.h
+@@ -35,12 +35,20 @@
+ static av_always_inline av_const int MULL(int a, int b, unsigned shift)
+ {
+     int rt, dummy;
++    if (__builtin_constant_p(shift))
+     __asm__ (
+         "imull %3               \n\t"
+         "shrdl %4, %%edx, %%eax \n\t"
+         :"=a"(rt), "=d"(dummy)
+-        :"a"(a), "rm"(b), "ci"((uint8_t)shift)
++        :"a"(a), "rm"(b), "i"(shift & 0x1F)
+     );
++    else
++        __asm__ (
++            "imull %3               \n\t"
++            "shrdl %4, %%edx, %%eax \n\t"
++            :"=a"(rt), "=d"(dummy)
++            :"a"(a), "rm"(b), "c"((uint8_t)shift)
++        );
+     return rt;
+ }
+ 
+@@ -113,19 +121,31 @@ __asm__ volatile(\
+ // avoid +32 for shift optimization (gcc should do that ...)
+ #define NEG_SSR32 NEG_SSR32
+ static inline  int32_t NEG_SSR32( int32_t a, int8_t s){
++    if (__builtin_constant_p(s))
+     __asm__ ("sarl %1, %0\n\t"
+          : "+r" (a)
+-         : "ic" ((uint8_t)(-s))
++         : "i" (-s & 0x1F)
+     );
++    else
++        __asm__ ("sarl %1, %0\n\t"
++               : "+r" (a)
++               : "c" ((uint8_t)(-s))
++        );
+     return a;
+ }
+ 
+ #define NEG_USR32 NEG_USR32
+ static inline uint32_t NEG_USR32(uint32_t a, int8_t s){
++    if (__builtin_constant_p(s))
+     __asm__ ("shrl %1, %0\n\t"
+          : "+r" (a)
+-         : "ic" ((uint8_t)(-s))
++         : "i" (-s & 0x1F)
+     );
++    else
++        __asm__ ("shrl %1, %0\n\t"
++               : "+r" (a)
++               : "c" ((uint8_t)(-s))
++        );
+     return a;
+ }
+ 
diff --git a/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
new file mode 100644
index 00000000000000..aa948f7a8a2dfb
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
@@ -0,0 +1,40 @@
+#==================================================================================================
+# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
+# From: Christopher Degawa <christopher.degawa@intel.com>
+# Date: Thu, 20 Oct 2022 22:55:27 -0500
+# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
+#
+# compressed_ten_bit_format has been deprecated upstream and has no effect
+# and can be removed. Plus, technically it was never used in the first place
+# since it would require the app (ffmpeg) to set it and do additional
+# processing of the input frames.
+#
+# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
+#
+# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
+#==================================================================================================
+--- a/libavcodec/libsvtav1.c
++++ b/libavcodec/libsvtav1.c
+@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
+ 
+ static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
+ {
+-    const int    pack_mode_10bit =
+-        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
+-    const size_t luma_size_8bit  =
+-        config->source_width * config->source_height * (1 << pack_mode_10bit);
+-    const size_t luma_size_10bit =
+-        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
++    const size_t luma_size = config->source_width * config->source_height *
++        (config->encoder_bit_depth > 8 ? 2 : 1);
+ 
+     EbSvtIOFormat *in_data;
+ 
+-    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
++    svt_enc->raw_size = luma_size * 3 / 2;
+ 
+     // allocate buffer for in and out
+     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
+-- 
+GitLab
+
diff --git a/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
new file mode 100644
index 00000000000000..00e3f68a415b84
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
@@ -0,0 +1,28 @@
+From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
+From: Rainer Hochecker <fernetmenta@online.de>
+Date: Sat, 26 Jan 2019 19:48:35 +0100
+Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
+
+This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
+It was hit frequently when watching h264 channels received via DVB-X.
+Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
+---
+ libavcodec/vaapi_h264.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
+index 5854587a255..f12fdc457a4 100644
+--- a/libavcodec/vaapi_h264.c
++++ b/libavcodec/vaapi_h264.c
+@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
+     H264SliceContext *sl = &h->slice_ctx[0];
+     int ret;
+ 
++    if (pic->nb_slices == 0) {
++        ret = AVERROR_INVALIDDATA;
++        goto finish;
++    }
++
+     ret = ff_vaapi_decode_issue(avctx, pic);
+     if (ret < 0)
+         goto finish;
diff --git a/srcpkgs/ffmpeg4/template b/srcpkgs/ffmpeg4/template
new file mode 100644
index 00000000000000..9ba14bdb8ddf32
--- /dev/null
+++ b/srcpkgs/ffmpeg4/template
@@ -0,0 +1,234 @@
+# Template file for 'ffmpeg4'
+# audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
+pkgname=ffmpeg4
+version=4.4.4
+revision=1
+short_desc="Decoding, encoding and streaming software - ffmpeg4 libraries only"
+maintainer="Orphaned <orphan@voidlinux.org>"
+license="GPL-3.0-or-later"
+homepage="https://www.ffmpeg.org"
+changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
+distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
+checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+
+hostmakedepends="pkg-config perl"
+makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
+ libXext-devel libXvMC-devel libxcb-devel lame-devel libtheora-devel
+ libvorbis-devel x264-devel xvidcore-devel jack-devel SDL2-devel
+ libcdio-paranoia-devel librtmp-devel libmodplug-devel gnutls-devel
+ speex-devel celt-devel harfbuzz-devel libass-devel opus-devel ocl-icd-devel
+ libbs2b-devel libvidstab-devel vmaf-devel $(vopt_if pulseaudio pulseaudio-devel)
+ $(vopt_if vaapi libva-devel) $(vopt_if vdpau libvdpau-devel)
+ $(vopt_if x265 x265-devel) $(vopt_if v4l2 v4l-utils-devel)
+ $(vopt_if fdk_aac fdk-aac-devel) $(vopt_if vpx libvpx-devel)
+ $(vopt_if aom libaom-devel) $(vopt_if sndio sndio-devel)
+ $(vopt_if dav1d libdav1d-devel) $(vopt_if zimg zimg-devel)
+ $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
+ $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
+ $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
+
+build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
+
+desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
+desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
+desc_option_sofa="Enable support for AES SOFA"
+desc_option_webp="Enable support for WebP"
+
+case "$XBPS_TARGET_MACHINE" in
+	i686*|x86_64*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau nvenc nvdec"
+			;;
+	ppc64*) build_options_default+=" vaapi vdpau";;
+	mips*) CFLAGS="-mnan=legacy";;
+esac
+
+if [ "$XBPS_TARGET_WORDSIZE" != "32" ]; then
+	build_options_default+=" svtav1"
+fi
+
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+fi
+
+_apply_patch() {
+	local args="$1" pname="$(basename $2)"
+
+	if [ ! -f ".${pname}_done" ]; then
+		patch -N $args -i $2
+		touch .${pname}_done
+	fi
+}
+
+post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64le*) ;;
+		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
+	esac
+
+	vsed -i libavfilter/vf_libvmaf.c -e 's!/usr/local/share/model/\(vmaf_v0.6.1\).pkl!/usr/share/vmaf/\1.json!'
+}
+
+do_configure() {
+	# Fix gcc on x86_64-musl only
+	if [ "$XBPS_TARGET_MACHINE" = "x86_64-musl" ]; then
+		vsed -i configure -e "s;_cflags_speed='-O3';_cflags_speed='-O2';"
+	fi
+
+	if [ "$CROSS_BUILD" ]; then
+		case "$XBPS_TARGET_MACHINE" in
+			arm*) _arch="arm";;
+			aarch64*) _arch="aarch64";;
+			mips*) _arch="mips";;
+			ppc64*) _arch="ppc64";;
+			ppc*) _arch="ppc";;
+			*) _arch="${XBPS_TARGET_MACHINE%%-musl}";;
+		esac
+
+		_args+=" --enable-cross-compile
+			--sysroot=$XBPS_CROSS_BASE
+			--cross-prefix=${XBPS_CROSS_TRIPLET}-
+			--target-os=linux --arch=${_arch}"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc|ppc-musl) _args+=" --disable-altivec";;
+	esac
+
+	if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+		_args+=" --extra-libs=-latomic"
+	fi
+
+	./configure --prefix=/usr --disable-debug --enable-gpl --enable-gnutls \
+		--disable-stripping \
+		--enable-libcdio --enable-version3 --enable-runtime-cpudetect \
+		--enable-libmp3lame --enable-libvorbis --enable-libxvid \
+		--enable-libx264 $(vopt_enable vpx libvpx) --enable-libtheora \
+		--enable-shared --enable-static --enable-libxcb \
+		$(vopt_enable pulseaudio libpulse) --enable-libfreetype --enable-libmodplug \
+		--enable-libspeex --enable-libcelt --enable-libass \
+		--enable-libopus --enable-librtmp --enable-libjack \
+		$(vopt_if fdk_aac '--enable-nonfree --enable-libfdk-aac') \
+		--disable-libopencore_amrnb --disable-libopencore_amrwb \
+		--disable-libopenjpeg \
+		--enable-postproc --enable-opencl ${_args} --enable-libvmaf ${_args} \
+		$(vopt_enable x265 libx265) \
+		$(vopt_enable v4l2 libv4l2) \
+		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
+		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		$(vopt_enable dav1d libdav1d) \
+		$(vopt_enable zimg libzimg) \
+		$(vopt_enable webp libwebp) \
+		$(vopt_enable sofa libmysofa) \
+		$(vopt_enable vulkan) \
+		$(vopt_enable drm libdrm) \
+		$(vopt_enable svtav1 libsvtav1) \
+		$(vopt_enable srt libsrt) \
+		$(vopt_enable rist librist) \
+		$(vopt_if nvenc '--enable-nvenc') \
+		$(vopt_if nvdec '--enable-nvdec')
+}
+
+do_build() {
+	make ${makejobs}
+	make doc/ff{mpeg,play}.1
+}
+
+do_install() {
+	make DESTDIR=${DESTDIR} install install-man
+	rm -rf ${DESTDIR}/usr/bin
+}
+
+libavcodec4_package() {
+	short_desc="FFmpeg codec library"
+	pkg_install() {
+		vmove "usr/lib/libavcodec.so.*"
+	}
+}
+
+libavdevice4_package() {
+	short_desc="FFmpeg device handling library"
+	pkg_install() {
+		vmove "usr/lib/libavdevice.so.*"
+	}
+}
+
+libavresample4_package() {
+	short_desc="FFmpeg audio resampling library"
+	pkg_install() {
+		vmove "usr/lib/libavresample.so.*"
+	}
+}
+
+libavformat4_package() {
+	short_desc="FFmpeg file format library"
+	pkg_install() {
+		vmove "usr/lib/libavformat.so.*"
+	}
+}
+
+libavutil4_package() {
+	short_desc="FFmpeg utility library"
+	pkg_install() {
+		vmove "usr/lib/libavutil.so.*"
+	}
+}
+
+libavfilter4_package() {
+	short_desc="FFmpeg audio/video filter library"
+	pkg_install() {
+		vmove "usr/lib/libavfilter.so.*"
+	}
+}
+
+libpostproc4_package() {
+	short_desc="FFmpeg video postprocessing library"
+	pkg_install() {
+		vmove "usr/lib/libpostproc.so.*"
+	}
+}
+
+libswscale4_package() {
+	short_desc="FFmpeg video scaling library"
+	pkg_install() {
+		vmove "usr/lib/libswscale.so.*"
+	}
+}
+
+libswresample4_package() {
+	short_desc="FFmpeg video resampling library"
+	pkg_install() {
+		vmove "usr/lib/libswresample.so.*"
+	}
+}
+
+ffmpeg4-devel_package() {
+	depends="
+		libavcodec4>=${version}_${revision}
+		libavdevice4>=${version}_${revision}
+		libavformat4>=${version}_${revision}
+		libavutil4>=${version}_${revision}
+		libavfilter4>=${version}_${revision}
+		libpostproc4>=${version}_${revision}
+		libswscale4>=${version}_${revision}
+		libswresample4>=${version}_${revision}
+		libavresample4>=${version}_${revision}"
+	short_desc+=" - development files"
+	conflicts="ffmpeg-devel"
+	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
+		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
+		nostrip_files="/usr/lib/libavfilter.a"
+	fi
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.a"
+		vmove "usr/lib/*.so"
+		vmove usr/share/ffmpeg/examples
+		vmove usr/share/man/man3
+	}
+}
diff --git a/srcpkgs/libavcodec4 b/srcpkgs/libavcodec4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavcodec4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavdevice4 b/srcpkgs/libavdevice4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavdevice4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavfilter4 b/srcpkgs/libavfilter4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavfilter4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavformat4 b/srcpkgs/libavformat4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavformat4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavresample4 b/srcpkgs/libavresample4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavutil4 b/srcpkgs/libavutil4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavutil4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libpostproc4 b/srcpkgs/libpostproc4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libpostproc4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswresample4 b/srcpkgs/libswresample4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libswresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswscale4 b/srcpkgs/libswscale4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libswscale4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file

From 107796d8744578395f21b4af5d0b66066f18111f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:04 -0400
Subject: [PATCH 005/109] opencv: update to 4.7.0.

---
 common/shlibs           | 104 ++++++++++++++++++++--------------------
 srcpkgs/opencv/template |   8 ++--
 2 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index 22cae2fcb156de..4e74eafd4a1836 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2080,58 +2080,58 @@ libcapstone.so.5 capstone-5.0.1_1
 libhavege.so.2 libhaveged-1.9.11_1
 libnih.so.1 libnih-1.0.3_1
 libnih-dbus.so.1 libnih-1.0.3_1
-libopencv_quality.so.406 libopencv-4.6.0_1
-libopencv_reg.so.406 libopencv-4.6.0_1
-libopencv_surface_matching.so.406 libopencv-4.6.0_1
-libopencv_xphoto.so.406 libopencv-4.6.0_1
-libopencv_freetype.so.406 libopencv-4.6.0_1
-libopencv_fuzzy.so.406 libopencv-4.6.0_1
-libopencv_hfs.so.406 libopencv-4.6.0_1
-libopencv_img_hash.so.406 libopencv-4.6.0_1
-libopencv_line_descriptor.so.406 libopencv-4.6.0_1
-libopencv_saliency.so.406 libopencv-4.6.0_1
-libopencv_structured_light.so.406 libopencv-4.6.0_1
-libopencv_aruco.so.406 libopencv-4.6.0_1
-libopencv_bgsegm.so.406 libopencv-4.6.0_1
-libopencv_bioinspired.so.406 libopencv-4.6.0_1
-libopencv_ccalib.so.406 libopencv-4.6.0_1
-libopencv_face.so.406 libopencv-4.6.0_1
-libopencv_tracking.so.406 libopencv-4.6.0_1
-libopencv_xfeatures2d.so.406 libopencv-4.6.0_1
-libopencv_optflow.so.406 libopencv-4.6.0_1
-libopencv_ximgproc.so.406 libopencv-4.6.0_1
-libopencv_plot.so.406 libopencv-4.6.0_1
-libopencv_text.so.406 libopencv-4.6.0_1
-libopencv_ml.so.406 libopencv-4.6.0_1
-libopencv_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn.so.406 libopencv-4.6.0_1
-libopencv_shape.so.406 libopencv-4.6.0_1
-libopencv_stitching.so.406 libopencv-4.6.0_1
-libopencv_photo.so.406 libopencv-4.6.0_1
-libopencv_video.so.406 libopencv-4.6.0_1
-libopencv_calib3d.so.406 libopencv-4.6.0_1
-libopencv_features2d.so.406 libopencv-4.6.0_1
-libopencv_flann.so.406 libopencv-4.6.0_1
-libopencv_highgui.so.406 libopencv-4.6.0_1
-libopencv_videoio.so.406 libopencv-4.6.0_1
-libopencv_imgcodecs.so.406 libopencv-4.6.0_1
-libopencv_imgproc.so.406 libopencv-4.6.0_1
-libopencv_core.so.406 libopencv-4.6.0_1
-libopencv_superres.so.406 libopencv-4.6.0_1
-libopencv_videostab.so.406 libopencv-4.6.0_1
-libopencv_gapi.so.406 libopencv-4.6.0_1
-libopencv_xobjdetect.so.406 libopencv-4.6.0_1
-libopencv_datasets.so.406 libopencv-4.6.0_1
-libopencv_dnn_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn_superres.so.406 libopencv-4.6.0_1
-libopencv_dpm.so.406 libopencv-4.6.0_1
-libopencv_phase_unwrapping.so.406 libopencv-4.6.0_1
-libopencv_stereo.so.406 libopencv-4.6.0_1
-libopencv_rapid.so.406 libopencv-4.6.0_1
-libopencv_intensity_transform.so.406 libopencv-4.6.0_1
-libopencv_alphamat.so.406 libopencv-4.6.0_1
-libopencv_barcode.so.406 libopencv-4.6.0_1
-libopencv_mcc.so.406 libopencv-4.6.0_1
+libopencv_quality.so.407 libopencv-4.7.0_1
+libopencv_reg.so.407 libopencv-4.7.0_1
+libopencv_surface_matching.so.407 libopencv-4.7.0_1
+libopencv_xphoto.so.407 libopencv-4.7.0_1
+libopencv_freetype.so.407 libopencv-4.7.0_1
+libopencv_fuzzy.so.407 libopencv-4.7.0_1
+libopencv_hfs.so.407 libopencv-4.7.0_1
+libopencv_img_hash.so.407 libopencv-4.7.0_1
+libopencv_line_descriptor.so.407 libopencv-4.7.0_1
+libopencv_saliency.so.407 libopencv-4.7.0_1
+libopencv_structured_light.so.407 libopencv-4.7.0_1
+libopencv_aruco.so.407 libopencv-4.7.0_1
+libopencv_bgsegm.so.407 libopencv-4.7.0_1
+libopencv_bioinspired.so.407 libopencv-4.7.0_1
+libopencv_ccalib.so.407 libopencv-4.7.0_1
+libopencv_face.so.407 libopencv-4.7.0_1
+libopencv_tracking.so.407 libopencv-4.7.0_1
+libopencv_xfeatures2d.so.407 libopencv-4.7.0_1
+libopencv_optflow.so.407 libopencv-4.7.0_1
+libopencv_ximgproc.so.407 libopencv-4.7.0_1
+libopencv_plot.so.407 libopencv-4.7.0_1
+libopencv_text.so.407 libopencv-4.7.0_1
+libopencv_ml.so.407 libopencv-4.7.0_1
+libopencv_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn.so.407 libopencv-4.7.0_1
+libopencv_shape.so.407 libopencv-4.7.0_1
+libopencv_stitching.so.407 libopencv-4.7.0_1
+libopencv_photo.so.407 libopencv-4.7.0_1
+libopencv_video.so.407 libopencv-4.7.0_1
+libopencv_calib3d.so.407 libopencv-4.7.0_1
+libopencv_features2d.so.407 libopencv-4.7.0_1
+libopencv_flann.so.407 libopencv-4.7.0_1
+libopencv_highgui.so.407 libopencv-4.7.0_1
+libopencv_videoio.so.407 libopencv-4.7.0_1
+libopencv_imgcodecs.so.407 libopencv-4.7.0_1
+libopencv_imgproc.so.407 libopencv-4.7.0_1
+libopencv_core.so.407 libopencv-4.7.0_1
+libopencv_superres.so.407 libopencv-4.7.0_1
+libopencv_videostab.so.407 libopencv-4.7.0_1
+libopencv_gapi.so.407 libopencv-4.7.0_1
+libopencv_xobjdetect.so.407 libopencv-4.7.0_1
+libopencv_datasets.so.407 libopencv-4.7.0_1
+libopencv_dnn_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn_superres.so.407 libopencv-4.7.0_1
+libopencv_dpm.so.407 libopencv-4.7.0_1
+libopencv_phase_unwrapping.so.407 libopencv-4.7.0_1
+libopencv_stereo.so.407 libopencv-4.7.0_1
+libopencv_rapid.so.407 libopencv-4.7.0_1
+libopencv_intensity_transform.so.407 libopencv-4.7.0_1
+libopencv_alphamat.so.407 libopencv-4.7.0_1
+libopencv_barcode.so.407 libopencv-4.7.0_1
+libopencv_mcc.so.407 libopencv-4.7.0_1
 libuniconf.so.4.6 wvstreams-4.6.1_20
 libwvbase.so.4.6 wvstreams-4.6.1_20
 libwvutils.so.4.6 wvstreams-4.6.1_20
diff --git a/srcpkgs/opencv/template b/srcpkgs/opencv/template
index aea4bfc3a265cf..ce94de9424d18d 100644
--- a/srcpkgs/opencv/template
+++ b/srcpkgs/opencv/template
@@ -1,7 +1,7 @@
 # Template file for 'opencv'
 pkgname=opencv
-version=4.6.0
-revision=6
+version=4.7.0
+revision=1
 create_wrksrc=yes
 build_wrksrc=${pkgname}-${version}
 build_style=cmake
@@ -24,8 +24,8 @@ homepage="https://opencv.org"
 changelog="https://github.com/opencv/opencv/wiki/ChangeLog"
 distfiles="https://github.com/opencv/opencv/archive/${version}.tar.gz
  https://github.com/opencv/opencv_contrib/archive/${version}.tar.gz>contrib.tar.gz"
-checksum="1ec1cba65f9f20fe5a41fda1586e01c70ea0c9a6d7b67c9e13edf0cfe2239277
- 1777d5fd2b59029cf537e5fd6f8aa68d707075822f90bde683fcde086f85f7a7"
+checksum="8df0079cdbe179748a18d44731af62a245a45ebf5085223dc03133954c662973
+ 42df840cf9055e59d0e22c249cfb19f04743e1bdad113d31b1573d3934d62584"
 patch_args="-Np1 -d ${build_wrksrc}"
 # tests hang indenfinitely, even with test data included
 make_check=no

From fda0b2fd4b8fe03e23cfe0e5d8bc76289345bac5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 006/109] actiona: revbump for opencv-4.7.0

---
 srcpkgs/actiona/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/actiona/template b/srcpkgs/actiona/template
index cf5f0b7a2ae610..0d899311e6df75 100644
--- a/srcpkgs/actiona/template
+++ b/srcpkgs/actiona/template
@@ -1,7 +1,7 @@
 # Template file for 'actiona'
 pkgname=actiona
 version=3.10.1
-revision=2
+revision=3
 build_style=qmake
 configure_args="PKGCONFIG_OPENCV=opencv4"
 hostmakedepends="pkg-config qt5-plugin-mysql qt5-qmake qt5-host-tools"

From ae87bea0a5fcc8c9e149f06d7ba2da6257a60030 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 007/109] retroshare: revbump for opencv-4.7.0

---
 srcpkgs/retroshare/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroshare/template b/srcpkgs/retroshare/template
index bb17569277a7f3..49e2c1cbe8a531 100644
--- a/srcpkgs/retroshare/template
+++ b/srcpkgs/retroshare/template
@@ -1,7 +1,7 @@
 # Template file for 'retroshare'
 pkgname=retroshare
 version=0.6.6
-revision=3
+revision=4
 build_style=qmake
 #XXX broadcast feature requires an ancient udp-discovery-cpp which either needs
 # to be fetched+patched (FTBFS) here or packaged :/

From 772ca522da9c0dd41c6de4919a9c0ec89c5954e7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 008/109] waifu2x-converter-cpp: revbump for opencv-4.7.0

---
 srcpkgs/waifu2x-converter-cpp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waifu2x-converter-cpp/template b/srcpkgs/waifu2x-converter-cpp/template
index 361b8a23b94977..c5ac17eb54ea4c 100644
--- a/srcpkgs/waifu2x-converter-cpp/template
+++ b/srcpkgs/waifu2x-converter-cpp/template
@@ -1,7 +1,7 @@
 # Template file for 'waifu2x-converter-cpp'
 pkgname=waifu2x-converter-cpp
 version=5.2.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DINSTALL_MODELS=ON"
 hostmakedepends="pkg-config"

From bc7703e534f4947ef0067a36fd3b5478d2523214 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:38 -0400
Subject: [PATCH 009/109] vlc: revbump for ffmpeg4

---
 srcpkgs/vlc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/vlc/template b/srcpkgs/vlc/template
index 559b1c4fff339f..fc399f1a6e9bfc 100644
--- a/srcpkgs/vlc/template
+++ b/srcpkgs/vlc/template
@@ -1,7 +1,7 @@
 # Template file for 'vlc'
 pkgname=vlc
 version=3.0.20
-revision=4
+revision=5
 build_style=gnu-configure
 configure_args="--disable-gme --disable-libtar --enable-jack
  --enable-live555 --disable-fluidsynth --enable-dvdread
@@ -25,7 +25,7 @@ lib32disabled=yes
 hostmakedepends="automake libtool pkg-config flex gettext libgcrypt-devel
  live555-devel gettext-devel $(vopt_if lua lua52) $(vopt_if chromecast protobuf)"
 makedepends="
- avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg-devel freefont-ttf
+ avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg4-devel freefont-ttf
  gnutls-devel jack-devel liba52-devel libass-devel libbluray-devel
  libcdio-devel libdca-devel libdvbpsi-devel libdvdnav-devel libmad-devel
  libmatroska-devel libmodplug-devel libmpcdec-devel libmpeg2-devel

From 7b796e6d8465a292991f0c0c1b3841cd4c8cfc15 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:55 -0400
Subject: [PATCH 010/109] osg: revbump for ffmpeg4

---
 srcpkgs/osg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/osg/template b/srcpkgs/osg/template
index 8ef0efc599a1b1..a131ceaf7a867b 100644
--- a/srcpkgs/osg/template
+++ b/srcpkgs/osg/template
@@ -8,7 +8,7 @@ build_helper="qemu"
 configure_args="-DLIB_POSTFIX="
 hostmakedepends="pkg-config xrandr"
 makedepends="MesaLib-devel gtkglext-devel libcurl-devel giflib-devel librsvg-devel
- jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg-devel xine-lib-devel
+ jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg4-devel xine-lib-devel
  SDL2-devel gst-plugins-base1-devel
  $(vopt_if openexr libopenexr-devel)
  $(vopt_if poppler poppler-glib-devel)

From e7805a02b7740d88c4ed7ac97f0eb5b33e2d1923 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:13 -0400
Subject: [PATCH 011/109] xine-lib: revbump for ffmpeg4

---
 srcpkgs/xine-lib/template | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/xine-lib/template b/srcpkgs/xine-lib/template
index 3be4d08eac77a3..ed6194c17d11e8 100644
--- a/srcpkgs/xine-lib/template
+++ b/srcpkgs/xine-lib/template
@@ -1,14 +1,14 @@
 # Template file for 'xine-lib'
 pkgname=xine-lib
-version=1.2.12
-revision=3
+version=1.2.13
+revision=1
 build_style=gnu-configure
 configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
  --disable-oss"
 hostmakedepends="automake gettext-devel libtool pkg-config perl"
 makedepends="
  zlib-devel alsa-lib-devel libxcb-devel libSM-devel libXext-devel libXv-devel
- libXvMC-devel liba52-devel libmad-devel ffmpeg-devel pulseaudio-devel
+ libXvMC-devel liba52-devel libmad-devel ffmpeg4-devel pulseaudio-devel
  jack-devel samba-devel libflac-devel libmodplug-devel libmpcdec-devel
  speex-devel libtheora-devel libvorbis-devel libdca-devel faad2-devel
  libcdio-devel libbluray-devel aalib-devel libcaca-devel libXinerama-devel
@@ -19,7 +19,7 @@ license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="http://www.xine-project.org"
 changelog="https://sourceforge.net/projects/xine/files/xine-lib/${version}/README.txt/view"
 distfiles="${SOURCEFORGE_SITE}/xine/${pkgname}-${version}.tar.xz"
-checksum=d606270468e1540c2a89c0d7f5fdf11e17ecc0c2698cc0bcb1065ff26abee098
+checksum=5f10d6d718a4a51c17ed1b32b031d4f9b80b061e8276535b2be31e5ac4b75e6f
 
 case "$XBPS_TARGET_MACHINE" in
 	i686-musl)

From c6263c4d9443079c2c7997a6be526d38379eda70 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 012/109] attract: revbump for ffmpeg6

---
 srcpkgs/attract/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/attract/template b/srcpkgs/attract/template
index e769fb15456217..776cbe4ebd2c93 100644
--- a/srcpkgs/attract/template
+++ b/srcpkgs/attract/template
@@ -1,7 +1,7 @@
 # Template file for 'attract'
 pkgname=attract
 version=2.7.0
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="VERBOSE=1"
 make_use_env=yes

From 44767b55b5c12386be356061072fdf8ed67c5e68 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 013/109] aubio: revbump for ffmpeg6

---
 srcpkgs/aubio/patches/ffmpeg5.patch | 25 +++++++++++++++++++++++++
 srcpkgs/aubio/template              |  2 +-
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/aubio/patches/ffmpeg5.patch

diff --git a/srcpkgs/aubio/patches/ffmpeg5.patch b/srcpkgs/aubio/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..aace41a6e6d9a4
--- /dev/null
+++ b/srcpkgs/aubio/patches/ffmpeg5.patch
@@ -0,0 +1,25 @@
+From 8a05420e5dd8c7b8b2447f82dc919765876511b3 Mon Sep 17 00:00:00 2001
+From: Paul Brossier <piem@piem.org>
+Date: Tue, 25 Jan 2022 18:30:27 +0100
+Subject: [PATCH] [source_avcodec] define FF_API_LAVF_AVCTX for libavcodec >
+ 59, thx @berolinux (closes gh-353)
+
+---
+ src/io/source_avcodec.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/io/source_avcodec.c b/src/io/source_avcodec.c
+index e0ae93b5..1421bd9a 100644
+--- a/src/io/source_avcodec.c
++++ b/src/io/source_avcodec.c
+@@ -68,6 +68,10 @@
+ #define AUBIO_AVCODEC_MAX_BUFFER_SIZE AV_INPUT_BUFFER_MIN_SIZE
+ #endif
+ 
++#if LIBAVCODEC_VERSION_MAJOR >= 59
++#define FF_API_LAVF_AVCTX 1
++#endif
++
+ struct _aubio_source_avcodec_t {
+   uint_t hop_size;
+   uint_t samplerate;
diff --git a/srcpkgs/aubio/template b/srcpkgs/aubio/template
index ad1c4b25699178..7d875cc02541a7 100644
--- a/srcpkgs/aubio/template
+++ b/srcpkgs/aubio/template
@@ -1,7 +1,7 @@
 # Template file for 'aubio'
 pkgname=aubio
 version=0.4.9
-revision=1
+revision=2
 build_style=waf3
 # XXX lash, pure and swig support.
 hostmakedepends="pkg-config txt2man"

From 3a5cdea3bff287ce8a17da207ec635cceaf6b675 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 014/109] audacious-plugins: revbump for ffmpeg6

---
 .../audacious-plugins/patches/ffmpeg5.patch   | 43 +++++++++++++++++++
 srcpkgs/audacious-plugins/template            |  2 +-
 2 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/audacious-plugins/patches/ffmpeg5.patch

diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg5.patch b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..4e5e34099d71c4
--- /dev/null
+++ b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
@@ -0,0 +1,43 @@
+commit 298aa371c56c2f52c25a33d9bdec4918b11cebdc
+Author: tibequadorian <tibequadorian@posteo.de>
+Date:   Sat Mar 19 18:40:12 2022 +0100
+
+    audacious-plugins: rebuild against ffmpeg-5.0
+
+diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+new file mode 100644
+index 0000000000..617c11215b
+--- /dev/null
++++ b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+@@ -0,0 +1,31 @@
++From f60beb400eeb1e4778bbfd738bc4a4ccef3de539 Mon Sep 17 00:00:00 2001
++From: John Lindgren <john@jlindgren.net>
++Date: Sat, 5 Mar 2022 12:05:34 -0500
++Subject: [PATCH] Fix build with FFmpeg 5.0
++
++---
++ src/ffaudio/ffaudio-core.cc | 4 ++--
++ 1 file changed, 2 insertions(+), 2 deletions(-)
++
++diff --git a/src/ffaudio/ffaudio-core.cc b/src/ffaudio/ffaudio-core.cc
++index 16dc63e3a..a2b95fd6c 100644
++--- a/src/ffaudio/ffaudio-core.cc
+++++ b/src/ffaudio/ffaudio-core.cc
++@@ -274,7 +274,7 @@ static AVInputFormat * get_format_by_content (const char * name, VFSFile & file)
++         AVProbeData d = {name, buf, filled};
++         score = target;
++ 
++-        f = av_probe_input_format2 (& d, true, & score);
+++        f = (AVInputFormat *) av_probe_input_format2 (& d, true, & score);
++         if (f)
++             break;
++ 
++@@ -347,7 +347,7 @@ static bool find_codec (AVFormatContext * c, CodecInfo * cinfo)
++ #endif
++         if (stream && stream->codecpar && stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
++         {
++-            AVCodec * codec = avcodec_find_decoder (stream->codecpar->codec_id);
+++            AVCodec * codec = (AVCodec *) avcodec_find_decoder (stream->codecpar->codec_id);
++ 
++             if (codec)
++             {
diff --git a/srcpkgs/audacious-plugins/template b/srcpkgs/audacious-plugins/template
index 05e53a9adf78ff..4b1968e03de781 100644
--- a/srcpkgs/audacious-plugins/template
+++ b/srcpkgs/audacious-plugins/template
@@ -2,7 +2,7 @@
 #Keep in sync with audacious!
 pkgname=audacious-plugins
 version=4.3.1
-revision=3
+revision=4
 build_style=meson
 configure_args="$(vopt_bool gtk3 gtk) $(vopt_bool gtk3)
  $(vopt_bool qt) $(vopt_bool qt qt6)"

From 1aeabd5382b2483510e5296c47e08f5e61822ad7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 015/109] audacity: revbump for ffmpeg6

---
 srcpkgs/audacity/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/audacity/template b/srcpkgs/audacity/template
index 7b838119ab2611..84b49305edcef1 100644
--- a/srcpkgs/audacity/template
+++ b/srcpkgs/audacity/template
@@ -1,7 +1,7 @@
 # Template file for 'audacity'
 pkgname=audacity
 version=3.4.2
-revision=1
+revision=2
 build_style=cmake
 build_helper="cmake-wxWidgets-gtk3 qemu"
 configure_args="-Daudacity_use_ffmpeg=loaded -Daudacity_lib_preference=system

From 6fb8777016eb2409821d13a42c247340215e01fc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 016/109] avidemux: revbump for ffmpeg6

---
 srcpkgs/avidemux/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/avidemux/template b/srcpkgs/avidemux/template
index 253a0243e22599..557285982d2b8f 100644
--- a/srcpkgs/avidemux/template
+++ b/srcpkgs/avidemux/template
@@ -1,7 +1,7 @@
 # Template file for 'avidemux'
 pkgname=avidemux
 version=2.8.0
-revision=2
+revision=3
 # Can't be compiled for aarch64, arm* or mips*
 archs="x86_64* i686*"
 hostmakedepends="cmake pkg-config qt5-host-tools qt5-devel tar yasm"

From 368f137b5cbbb4f0c4c607add770218e4cc9354c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 017/109] blender: revbump for ffmpeg6

---
 srcpkgs/blender/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index 68787b76a26c18..e2e090e6dfa41c 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -1,7 +1,7 @@
 # Template file for 'blender'
 pkgname=blender
 version=4.0.2
-revision=2
+revision=3
 archs="x86_64* ppc64*"
 build_style="cmake"
 pycompile_dirs="usr/share/blender/${version%.*}/scripts"

From a35ad1258970fa8920fc4aebaf10ae1dbc9c847d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 018/109] cantata: revbump for ffmpeg6

---
 srcpkgs/cantata/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cantata/template b/srcpkgs/cantata/template
index 4b417d80d5c2da..8a90aaa4c07a2a 100644
--- a/srcpkgs/cantata/template
+++ b/srcpkgs/cantata/template
@@ -1,7 +1,7 @@
 # Template file for 'cantata'
 pkgname=cantata
 version=2.5.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools qt5-tools"
 makedepends="qt5-devel qt5-tools-devel qt5-svg-devel qt5-xmlpatterns-devel

From 8308b07c341e9d3243b0fef6dfd6872a1648acc3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 019/109] ccextractor: revbump for ffmpeg6

---
 ...5-and-tesseract-5-compatibility-1479.patch | 168 ++++++++++++++++++
 srcpkgs/ccextractor/template                  |   2 +-
 2 files changed, 169 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ccextractor/patches/0001-fix-ffmpeg-5-and-tesseract-5-compatibility-1479.patch

diff --git a/srcpkgs/ccextractor/patches/0001-fix-ffmpeg-5-and-tesseract-5-compatibility-1479.patch b/srcpkgs/ccextractor/patches/0001-fix-ffmpeg-5-and-tesseract-5-compatibility-1479.patch
new file mode 100644
index 00000000000000..bcab4890554b9a
--- /dev/null
+++ b/srcpkgs/ccextractor/patches/0001-fix-ffmpeg-5-and-tesseract-5-compatibility-1479.patch
@@ -0,0 +1,168 @@
+From b1cbfcea9b9c687143bf0d80bc179b563e99d025 Mon Sep 17 00:00:00 2001
+From: Prateek Sunal <prtksunal@gmail.com>
+Date: Thu, 9 Mar 2023 01:44:53 +0530
+Subject: [PATCH] fix: ffmpeg 5 and tesseract 5 compatibility (#1479)
+
+* fix: replace deprecated `codec` property with `codecpar`
+
+* fix: replace deprecated method `avcodec_decode_video2` with `avcodec_receive_frame` and `avcodec_send_packet`
+
+* Update CHANGES.TXT
+
+* fix: remove deprecated `av_register_all` function
+
+* fix: formatting
+
+* fix: add support for tesseract 5
+
+* fix: tesseract v5
+
+* fix: hardsubx codec context error
+
+* fix: lint const warning
+---
+ docs/CHANGES.TXT               |  1 +
+ src/lib_ccx/ffmpeg_intgr.c     |  7 +++---
+ src/lib_ccx/hardsubx.c         | 25 ++++++++++++------
+ src/lib_ccx/hardsubx_decoder.c | 27 ++++++++------------
+ src/lib_ccx/ocr.c              | 46 ++++++++++++----------------------
+ 5 files changed, 47 insertions(+), 59 deletions(-)
+
+diff --git a/src/lib_ccx/ffmpeg_intgr.c b/src/lib_ccx/ffmpeg_intgr.c
+index be988890..e6f21e20 100644
+--- a/src/lib_ccx/ffmpeg_intgr.c
++++ b/src/lib_ccx/ffmpeg_intgr.c
+@@ -66,7 +66,6 @@ void *init_ffmpeg(const char *path)
+ 	struct ffmpeg_ctx *ctx;
+ 	AVCodec *dec = NULL;
+ 	avcodec_register_all();
+-	av_register_all();
+ 
+ 	if (ccx_options.debug_mask & CCX_DMT_VERBOSE)
+ 		av_log_set_level(AV_LOG_INFO);
+@@ -133,7 +132,6 @@ int ff_get_ccframe(void *arg, unsigned char *data, int maxlen)
+ 	struct ffmpeg_ctx *ctx = arg;
+ 	int len = 0;
+ 	int ret = 0;
+-	int got_frame;
+ 	AVPacket packet;
+ 
+ 	ret = av_read_frame(ctx->ifmt, &packet);
+@@ -151,12 +149,13 @@ int ff_get_ccframe(void *arg, unsigned char *data, int maxlen)
+ 		return AVERROR(EAGAIN);
+ 	}
+ 
+-	ret = avcodec_decode_video2(ctx->dec_ctx, ctx->frame, &got_frame, &packet);
++	avcodec_send_packet(ctx->codec_ctx, &ctx->packet);
++	ret = avcodec_receive_frame(ctx->dec_ctx, ctx->frame);
+ 	if (ret < 0)
+ 	{
+ 		av_log(NULL, AV_LOG_ERROR, "unable to decode packet\n");
+ 	}
+-	else if (!got_frame)
++	else if (ret != 0)
+ 	{
+ 		return AVERROR(EAGAIN);
+ 	}
+diff --git a/src/lib_ccx/hardsubx.c b/src/lib_ccx/hardsubx.c
+index 411377f9..fb844c91 100644
+--- a/src/lib_ccx/hardsubx.c
++++ b/src/lib_ccx/hardsubx.c
+@@ -12,9 +12,6 @@
+
+ int hardsubx_process_data(struct lib_hardsubx_ctx *ctx)
+ {
+-	// Get the required media attributes and initialize structures
+-	av_register_all();
+-
+ 	if (avformat_open_input(&ctx->format_ctx, ctx->inputfile[0], NULL, NULL) != 0)
+ 	{
+ 		fatal(EXIT_READ_ERROR, "Error reading input file!\n");
+@@ -32,7 +29,7 @@
+ 	ctx->video_stream_id = -1;
+ 	for (int i = 0; i < ctx->format_ctx->nb_streams; i++)
+ 	{
+-		if (ctx->format_ctx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO)
++		if (ctx->format_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
+ 		{
+ 			ctx->video_stream_id = i;
+ 			break;
+@@ -43,8 +40,21 @@
+ 		fatal(EXIT_READ_ERROR, "Video Stream not found!\n");
+ 	}
+
+-	ctx->codec_ctx = ctx->format_ctx->streams[ctx->video_stream_id]->codec;
+-	ctx->codec = avcodec_find_decoder(ctx->codec_ctx->codec_id);
++	ctx->codec_ctx = avcodec_alloc_context3(NULL);
++	if (!ctx->codec_ctx)
++	{
++		    fatal(EXIT_NOT_ENOUGH_MEMORY, "Could not allocate codec context!\n");
++	}
++
++	// Assign codec parameters to codec context
++	if (avcodec_parameters_to_context(ctx->codec_ctx, ctx->format_ctx->streams[ctx->video_stream_id]->codecpar) < 0)
++	{
++		    fatal(EXIT_READ_ERROR, "Could not initialize codec context!\n");
++	}
++
++	// Find decoder for the codec context
++	ctx->codec = (AVCodec *)avcodec_find_decoder(ctx->codec_ctx->codec_id);
++
+ 	if (ctx->codec == NULL)
+ 	{
+ 		fatal(EXIT_READ_ERROR, "Input codec is not supported!\n");
+diff --git a/src/lib_ccx/hardsubx_decoder.c b/src/lib_ccx/hardsubx_decoder.c
+index bd9b0980..b5dfaec4 100644
+--- a/src/lib_ccx/hardsubx_decoder.c
++++ b/src/lib_ccx/hardsubx_decoder.c
+@@ -371,7 +371,6 @@
+ int hardsubx_process_frames_tickertext(struct lib_hardsubx_ctx *ctx, struct encoder_ctx *enc_ctx)
+ {
+ 	// Search for ticker text at the bottom of the screen, such as in Russia TV1 or stock prices
+-	int got_frame;
+ 	int cur_sec = 0, total_sec, progress;
+ 	int frame_number = 0;
+ 	char *ticker_text = NULL;
+@@ -382,8 +381,8 @@
+ 		{
+ 			frame_number++;
+ 			//Decode the video stream packet
+-			avcodec_decode_video2(ctx->codec_ctx, ctx->frame, &got_frame, &ctx->packet);
+-			if (got_frame && frame_number % 1000 == 0)
++      avcodec_send_packet(ctx->codec_ctx, &ctx->packet);
++      if (avcodec_receive_frame(ctx->codec_ctx, ctx->frame) == 0 && frame_number % 1000 == 0)
+ 			{
+ 				// sws_scale is used to convert the pixel format to RGB24 from all other cases
+ 				sws_scale(
+@@ -434,9 +433,8 @@
+ 			frame_number++;
+
+ 			//Decode the video stream packet
+-			avcodec_decode_video2(ctx->codec_ctx, ctx->frame, &got_frame, &ctx->packet);
+-
+-			if (got_frame && frame_number % 25 == 0)
++			avcodec_send_packet(ctx->codec_ctx, &ctx->packet);
++      if (avcodec_receive_frame(ctx->codec_ctx, ctx->frame) == 0 && frame_number % 25 == 0)
+ 			{
+ 				float diff = (float)convert_pts_to_ms(ctx->packet.pts - prev_packet_pts, ctx->format_ctx->streams[ctx->video_stream_id]->time_base);
+ 				if (fabsf(diff) < 1000 * ctx->min_sub_duration) //If the minimum duration of a subtitle line is exceeded, process packet
+@@ -548,7 +546,6 @@
+ {
+ 	// Do a binary search over the input video for faster processing
+ 	// printf("Duration: %d\n", (int)ctx->format_ctx->duration);
+-	int got_frame;
+ 	int seconds_time = 0;
+ 	for (seconds_time = 0; seconds_time < 20; seconds_time++)
+ 	{
+@@ -568,8 +565,9 @@
+ 			{
+ 				if (ctx->packet.stream_index == ctx->video_stream_id)
+ 				{
+-					avcodec_decode_video2(ctx->codec_ctx, ctx->frame, &got_frame, &ctx->packet);
+-					if (got_frame)
++          avcodec_send_packet(ctx->codec_ctx, &ctx->packet);
++          if (avcodec_receive_frame(ctx->codec_ctx, ctx->frame) == 0)
++
+ 					{
+ 						// printf("%d\n", seek_time);
+ 						if (ctx->packet.pts < seek_time)
diff --git a/srcpkgs/ccextractor/template b/srcpkgs/ccextractor/template
index 84059ffd02398a..a670758bcbe41b 100644
--- a/srcpkgs/ccextractor/template
+++ b/srcpkgs/ccextractor/template
@@ -1,7 +1,7 @@
 # Template file for 'ccextractor'
 pkgname=ccextractor
 version=0.93
-revision=2
+revision=3
 build_wrksrc="linux"
 build_style=gnu-configure
 configure_args="--enable-ocr --enable-hardsubx"

From 4133e7d3b771baf5bdaf7df34405c315e2c61ef7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 020/109] chromaprint: revbump for ffmpeg6

---
 srcpkgs/chromaprint/patches/ffmpeg5.patch | 569 ++++++++++++++++++++++
 srcpkgs/chromaprint/template              |   2 +-
 2 files changed, 570 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromaprint/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromaprint/patches/ffmpeg5.patch b/srcpkgs/chromaprint/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..a9fd307a23c8a4
--- /dev/null
+++ b/srcpkgs/chromaprint/patches/ffmpeg5.patch
@@ -0,0 +1,569 @@
+From 8ccad6937177b1b92e40ab8f4447ea27bac009a7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= <lalinsky@gmail.com>
+Date: Fri, 4 Nov 2022 21:47:38 +0100
+Subject: [PATCH] Use FFmpeg 5.x (#120)
+
+* Use FFmpeg 5.1.2 for CI builds
+
+* Build on Ubuntu 20.04
+
+* Upgrade code to FFmpeg 5.x APIs
+
+* Only set FFmpeg include dirs if building tools
+
+* No longer needed
+
+* Use ubuntu 20.04
+---
+ .github/workflows/build.yml                   |   6 +-
+ CMakeLists.txt                                |  16 --
+ package/build.sh                              |   4 +-
+ src/audio/ffmpeg_audio_processor.h            |   2 -
+ src/audio/ffmpeg_audio_processor_avresample.h |  72 -------
+ src/audio/ffmpeg_audio_processor_swresample.h |  18 +-
+ src/audio/ffmpeg_audio_reader.h               | 197 +++++++++---------
+ tests/CMakeLists.txt                          |   6 +
+ 8 files changed, 122 insertions(+), 199 deletions(-)
+ delete mode 100644 src/audio/ffmpeg_audio_processor_avresample.h
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index f8d6a32..4da2405 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -84,9 +84,6 @@ find_package(FFmpeg)
+ if(FFMPEG_LIBRARIES)
+ 	cmake_push_check_state(RESET)
+ 	set(CMAKE_REQUIRED_LIBRARIES ${FFMPEG_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -lm)
+-	check_function_exists(av_packet_unref HAVE_AV_PACKET_UNREF)
+-	check_function_exists(av_frame_alloc HAVE_AV_FRAME_ALLOC)
+-	check_function_exists(av_frame_free HAVE_AV_FRAME_FREE)
+ 	cmake_pop_check_state()
+ endif()
+
+@@ -163,14 +160,11 @@ message(STATUS "Using ${FFT_LIB} for FFT calculations")
+ if(NOT AUDIO_PROCESSOR_LIB)
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+ 		set(AUDIO_PROCESSOR_LIB "swresample")
+-	elseif(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(AUDIO_PROCESSOR_LIB "avresample")
+ 	endif()
+ endif()
+
+ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE OFF)
+ 		set(USE_SWRESAMPLE ON)
+ 		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBSWRESAMPLE_LIBRARIES})
+ 		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBSWRESAMPLE_INCLUDE_DIRS})
+@@ -178,16 +172,6 @@ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+ 	endif()
+ 	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+-elseif(AUDIO_PROCESSOR_LIB STREQUAL "avresample")
+-	if(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE ON)
+-		set(USE_SWRESAMPLE OFF)
+-		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBAVRESAMPLE_LIBRARIES})
+-		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBAVRESAMPLE_INCLUDE_DIRS})
+-	else()
+-		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+-	endif()
+-	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+ else()
+ 	message(STATUS "Building without audio conversion support, please install FFmpeg with libswresample")
+ endif()
+diff --git a/package/build.sh b/package/build.sh
+index da631ae..b41d36e 100755
+--- a/package/build.sh
++++ b/package/build.sh
+@@ -7,8 +7,8 @@ set -eux
+
+ BASE_DIR=$(cd $(dirname $0)/.. && pwd)
+
+-FFMPEG_VERSION=4.4.1
+-FFMPEG_BUILD_TAG=v4.4.1-1
++FFMPEG_VERSION=5.1.2
++FFMPEG_BUILD_TAG=v${FFMPEG_VERSION}-1
+
+ TMP_BUILD_DIR=$BASE_DIR/$(mktemp -d build.XXXXXXXX)
+ trap 'rm -rf $TMP_BUILD_DIR' EXIT
+diff --git a/src/audio/ffmpeg_audio_processor.h b/src/audio/ffmpeg_audio_processor.h
+index 7628fc7..39f4f6d 100644
+--- a/src/audio/ffmpeg_audio_processor.h
++++ b/src/audio/ffmpeg_audio_processor.h
+@@ -10,8 +10,6 @@
+
+ #if defined(USE_SWRESAMPLE)
+ #include "audio/ffmpeg_audio_processor_swresample.h"
+-#elif defined(USE_AVRESAMPLE)
+-#include "audio/ffmpeg_audio_processor_avresample.h"
+ #else
+ #error "no audio processing library"
+ #endif
+diff --git a/src/audio/ffmpeg_audio_processor_avresample.h b/src/audio/ffmpeg_audio_processor_avresample.h
+deleted file mode 100644
+index bd85f92..0000000
+--- a/src/audio/ffmpeg_audio_processor_avresample.h
++++ /dev/null
+@@ -1,72 +0,0 @@
+-// Copyright (C) 2016  Lukas Lalinsky
+-// Distributed under the MIT license, see the LICENSE file for details.
+-
+-#ifndef CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-#define CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-
+-extern "C" {
+-#include <libavresample/avresample.h>
+-}
+-
+-namespace chromaprint {
+-
+-class FFmpegAudioProcessor {
+-public:
+-	FFmpegAudioProcessor() {
+-		m_resample_ctx = avresample_alloc_context();
+-	}
+-
+-	~FFmpegAudioProcessor() {
+-		avresample_free(&m_resample_ctx);
+-	}
+-
+-	void SetCompatibleMode() {
+-		av_opt_set_int(m_resample_ctx, "filter_size", 16, 0);
+-		av_opt_set_int(m_resample_ctx, "phase_shift", 8, 0);
+-		av_opt_set_int(m_resample_ctx, "linear_interp", 1, 0);
+-		av_opt_set_double(m_resample_ctx, "cutoff", 0.8, 0);
+-	}
+-
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "in_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_rate", sample_rate, 0);
+-	}
+-
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "out_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_rate, 0);
+-	}
+-
+-	int Init() {
+-		return avresample_open(m_resample_ctx);
+-	}
+-
+-	int Convert(uint8_t **out, int out_count, const uint8_t **in, int in_count) {
+-		return avresample_convert(m_resample_ctx, out, 0, out_count, (uint8_t **) in, 0, in_count);
+-	}
+-
+-	int Flush(uint8_t **out, int out_count) {
+-		return avresample_read(m_resample_ctx, out, out_count);
+-	}
+-
+-private:
+-	AVAudioResampleContext *m_resample_ctx = nullptr;
+-};
+-
+-}; // namespace chromaprint
+-
+-#endif
+diff --git a/src/audio/ffmpeg_audio_processor_swresample.h b/src/audio/ffmpeg_audio_processor_swresample.h
+index b86266b..b1d4bea 100644
+--- a/src/audio/ffmpeg_audio_processor_swresample.h
++++ b/src/audio/ffmpeg_audio_processor_swresample.h
+@@ -28,30 +28,28 @@ public:
+ 		av_opt_set_double(m_swr_ctx, "cutoff", 0.8, 0);
+ 	}
+
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "icl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "ich", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetInputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "in_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "isf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "in_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "isr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "in_sample_rate", sample_rate, 0);
+ 	}
+
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "ocl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "och", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetOutputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "out_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "osf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "out_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "osr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "out_sample_rate", sample_rate, 0);
+ 	}
+
+ 	int Init() {
+diff --git a/src/audio/ffmpeg_audio_reader.h b/src/audio/ffmpeg_audio_reader.h
+index 5550164..1c6b346 100644
+--- a/src/audio/ffmpeg_audio_reader.h
++++ b/src/audio/ffmpeg_audio_reader.h
+@@ -62,7 +62,7 @@ public:
+ 	bool Read(const int16_t **data, size_t *size);
+
+ 	bool IsOpen() const { return m_opened; }
+-	bool IsFinished() const { return m_finished && !m_got_frame; }
++	bool IsFinished() const { return !m_has_more_packets && !m_has_more_frames; }
+
+ 	std::string GetError() const { return m_error; }
+ 	int GetErrorCode() const { return m_error_code; }
+@@ -74,20 +74,19 @@ private:
+ 	uint8_t *m_convert_buffer[1] = { nullptr };
+ 	int m_convert_buffer_nb_samples = 0;
+
+-	AVInputFormat *m_input_fmt = nullptr;
++	const AVInputFormat *m_input_fmt = nullptr;
+ 	AVDictionary *m_input_opts = nullptr;
+
+ 	AVFormatContext *m_format_ctx = nullptr;
+ 	AVCodecContext *m_codec_ctx = nullptr;
+-	AVFrame *m_frame = nullptr;
+ 	int m_stream_index = -1;
+ 	std::string m_error;
+ 	int m_error_code = 0;
+-	bool m_finished = false;
+ 	bool m_opened = false;
+-	int m_got_frame = 0;
+-	AVPacket m_packet;
+-	AVPacket m_packet0;
++	bool m_has_more_packets = true;
++	bool m_has_more_frames = true;
++	AVPacket *m_packet = nullptr;
++	AVFrame *m_frame = nullptr;
+
+ 	int m_output_sample_rate = 0;
+ 	int m_output_channels = 0;
+@@ -98,19 +97,12 @@ private:
+
+ inline FFmpegAudioReader::FFmpegAudioReader() {
+ 	av_log_set_level(AV_LOG_QUIET);
+-
+-	av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
+ }
+
+ inline FFmpegAudioReader::~FFmpegAudioReader() {
+ 	Close();
+ 	av_dict_free(&m_input_opts);
+ 	av_freep(&m_convert_buffer[0]);
+-	av_packet_unref(&m_packet0);
+ }
+
+ inline bool FFmpegAudioReader::SetInputFormat(const char *name) {
+@@ -135,11 +127,10 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ 	Close();
+
+-    av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
++	m_packet = av_packet_alloc();
++	if (!m_packet) {
++		return false;
++	}
+
+ 	ret = avformat_open_input(&m_format_ctx, file_name.c_str(), m_input_fmt, &m_input_opts);
+ 	if (ret < 0) {
+@@ -153,26 +144,31 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		return false;
+ 	}
+
+-	AVCodec *codec;
++	const AVCodec *codec;
+ 	ret = av_find_best_stream(m_format_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &codec, 0);
+ 	if (ret < 0) {
+ 		SetError("Could not find any audio stream in the file", ret);
+ 		return false;
+ 	}
+ 	m_stream_index = ret;
++	auto stream = m_format_ctx->streams[m_stream_index];
+
+-	m_codec_ctx = m_format_ctx->streams[m_stream_index]->codec;
++	m_codec_ctx = avcodec_alloc_context3(codec);
+ 	m_codec_ctx->request_sample_fmt = AV_SAMPLE_FMT_S16;
+
++	ret = avcodec_parameters_to_context(m_codec_ctx, stream->codecpar);
++	if (ret < 0) {
++		SetError("Could not copy the stream parameters", ret);
++		return false;
++	}
++
+ 	ret = avcodec_open2(m_codec_ctx, codec, nullptr);
+ 	if (ret < 0) {
+ 		SetError("Could not open the codec", ret);
+ 		return false;
+ 	}
+
+-	if (!m_codec_ctx->channel_layout) {
+-		m_codec_ctx->channel_layout = av_get_default_channel_layout(m_codec_ctx->channels);
+-	}
++	av_dump_format(m_format_ctx, 0, "foo", 0);
+
+ 	m_frame = av_frame_alloc();
+ 	if (!m_frame) {
+@@ -183,19 +179,23 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		m_output_sample_rate = m_codec_ctx->sample_rate;
+ 	}
+
+-	if (!m_output_channels) {
+-		m_output_channels = m_codec_ctx->channels;
++	AVChannelLayout output_channel_layout;
++	if (m_output_channels) {
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
++	} else {
++		m_output_channels = m_codec_ctx->ch_layout.nb_channels;
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
+ 	}
+
+-	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
++	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->ch_layout.nb_channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
+ 		m_converter.reset(new FFmpegAudioProcessor());
+ 		m_converter->SetCompatibleMode();
+ 		m_converter->SetInputSampleFormat(m_codec_ctx->sample_fmt);
+ 		m_converter->SetInputSampleRate(m_codec_ctx->sample_rate);
+-		m_converter->SetInputChannelLayout(m_codec_ctx->channel_layout);
++		m_converter->SetInputChannelLayout(&(m_codec_ctx->ch_layout));
+ 		m_converter->SetOutputSampleFormat(AV_SAMPLE_FMT_S16);
+ 		m_converter->SetOutputSampleRate(m_output_sample_rate);
+-		m_converter->SetOutputChannelLayout(av_get_default_channel_layout(m_output_channels));
++		m_converter->SetOutputChannelLayout(&output_channel_layout);
+ 		auto ret = m_converter->Init();
+ 		if (ret != 0) {
+ 			SetError("Could not create an audio converter instance", ret);
+@@ -203,10 +203,11 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		}
+ 	}
+
++	av_channel_layout_uninit(&output_channel_layout);
++
+ 	m_opened = true;
+-	m_finished = false;
+-	m_got_frame = 0;
+-	m_nb_packets = 0;
++	m_has_more_packets = true;
++	m_has_more_frames = true;
+ 	m_decode_error = 0;
+
+ 	return true;
+@@ -214,6 +215,7 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ inline void FFmpegAudioReader::Close() {
+ 	av_frame_free(&m_frame);
++	av_packet_free(&m_packet);
+
+ 	m_stream_index = -1;
+
+@@ -252,91 +254,98 @@ inline bool FFmpegAudioReader::Read(const int16_t **data, size_t *size) {
+ 		return false;
+ 	}
+
++	*data = nullptr;
++	*size = 0;
++
+ 	int ret;
++	bool needs_packet = false;
+ 	while (true) {
+-		while (m_packet.size <= 0) {
+-			av_packet_unref(&m_packet0);
+-			av_init_packet(&m_packet);
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			ret = av_read_frame(m_format_ctx, &m_packet);
++		while (needs_packet && m_packet->size == 0) {
++			ret = av_read_frame(m_format_ctx, m_packet);
+ 			if (ret < 0) {
+ 				if (ret == AVERROR_EOF) {
+-					m_finished = true;
++					needs_packet = false;
++					m_has_more_packets = false;
+ 					break;
+-				} else {
++				}
++				SetError("Error reading from the audio source", ret);
++				return false;
++			}
++			if (m_packet->stream_index == m_stream_index) {
++				needs_packet = false;
++			} else {
++				av_packet_unref(m_packet);
++			}
++		}
++
++		if (m_packet->size != 0) {
++			ret = avcodec_send_packet(m_codec_ctx, m_packet);
++			if (ret < 0) {
++				if (ret != AVERROR(EAGAIN)) {
+ 					SetError("Error reading from the audio source", ret);
+ 					return false;
+ 				}
+-			}
+-			m_packet0 = m_packet;
+-			if (m_packet.stream_index != m_stream_index) {
+-				m_packet.data = nullptr;
+-				m_packet.size = 0;
+ 			} else {
+-				m_nb_packets++;
++				av_packet_unref(m_packet);
+ 			}
+ 		}
+
+-		ret = avcodec_decode_audio4(m_codec_ctx, m_frame, &m_got_frame, &m_packet);
++		ret = avcodec_receive_frame(m_codec_ctx, m_frame);
+ 		if (ret < 0) {
+-			if (m_decode_error) {
+-				SetError("Error decoding audio frame", m_decode_error);
+-				return false;
++			if (ret == AVERROR_EOF) {
++				m_has_more_frames = false;
++			} else if (ret == AVERROR(EAGAIN)) {
++				if (m_has_more_packets) {
++					needs_packet = true;
++					continue;
++				} else {
++					m_has_more_frames = false;
++				}
+ 			}
+-			m_decode_error = ret;
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			continue;
++			SetError("Error decoding the audio source", ret);
++			return false;
+ 		}
+
+-		break;
+-	}
+-
+-	m_decode_error = 0;
+-
+-	const int decoded = std::min(ret, m_packet.size);
+-	m_packet.data += decoded;
+-	m_packet.size -= decoded;
+-
+-	if (m_got_frame) {
+-		if (m_converter) {
+-			if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
+-				int linsize;
+-				av_freep(&m_convert_buffer[0]);
+-				m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
+-				ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
+-				if (ret < 0) {
+-					SetError("Couldn't allocate audio converter buffer", ret);
++		if (m_frame->nb_samples > 0) {
++			if (m_converter) {
++				if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
++					int linsize;
++					av_freep(&m_convert_buffer[0]);
++					m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
++					ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->ch_layout.nb_channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
++					if (ret < 0) {
++						SetError("Couldn't allocate audio converter buffer", ret);
++						return false;
++					}
++				}
++				auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
++				if (nb_samples < 0) {
++					SetError("Couldn't convert audio", ret);
+ 					return false;
+ 				}
+-			}
+-			auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			}
+-			*data = (const int16_t *) m_convert_buffer[0];
+-			*size = nb_samples;
+-		} else {
+-			*data = (const int16_t *) m_frame->data[0];
+-			*size = m_frame->nb_samples;
+-		}
+-	} else {
+-		if (m_finished && m_converter) {
+-			auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			} else if (nb_samples > 0) {
+-				m_got_frame = 1;
+ 				*data = (const int16_t *) m_convert_buffer[0];
+ 				*size = nb_samples;
++			} else {
++				*data = (const int16_t *) m_frame->data[0];
++				*size = m_frame->nb_samples;
++			}
++		} else {
++			if (m_converter) {
++				if (IsFinished()) {
++					auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
++					if (nb_samples < 0) {
++						SetError("Couldn't convert audio", ret);
++						return false;
++					} else if (nb_samples > 0) {
++						*data = (const int16_t *) m_convert_buffer[0];
++						*size = nb_samples;
++					}
++				}
+ 			}
+ 		}
+-	}
+
+-	return true;
++		return true;
++	}
+ }
+
+ inline void FFmpegAudioReader::SetError(const char *message, int errnum) {
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index a2b517b..123e643 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -38,6 +38,12 @@ set(SRCS
+
+ if(BUILD_TOOLS)
+ 	set(SRCS ${SRCS} ../src/audio/ffmpeg_audio_reader_test.cpp)
++    include_directories(
++        ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}
++        ${AUDIO_PROCESSOR_INCLUDE_DIRS}
++    )
+ 	link_libraries(fpcalc_libs)
+ endif()
+
+-- 
+2.38.1
+
+
diff --git a/srcpkgs/chromaprint/template b/srcpkgs/chromaprint/template
index 7ef7838949f3a3..1f7bbc70a22c80 100644
--- a/srcpkgs/chromaprint/template
+++ b/srcpkgs/chromaprint/template
@@ -1,7 +1,7 @@
 # Template file for 'chromaprint'
 pkgname=chromaprint
 version=1.5.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DBUILD_TOOLS=ON"
 make_check_target="check"

From 3abf01bbc69f7be2d8d422e3ce89516dd29d6c92 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 021/109] chromium: revbump for ffmpeg6

---
 srcpkgs/chromium/patches/ffmpeg5.patch | 47 ++++++++++++++++++++++++++
 srcpkgs/chromium/template              |  2 +-
 2 files changed, 48 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..24e2da38e34ca2
--- /dev/null
+++ b/srcpkgs/chromium/patches/ffmpeg5.patch
@@ -0,0 +1,47 @@
+--- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
++++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
+@@ -92,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+-  if (stream->start_time != kNoFFmpegTimestamp)
++  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -1597,7 +1585,7 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+@@ -1618,7 +1606,7 @@
+     if (stream->type() != DemuxerStream::VIDEO)
+       continue;
+ 
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+ 
+     if (!stream->IsEnabled())
diff --git a/srcpkgs/chromium/template b/srcpkgs/chromium/template
index 53981f7cd367f8..b462de56fe3bf5 100644
--- a/srcpkgs/chromium/template
+++ b/srcpkgs/chromium/template
@@ -2,7 +2,7 @@
 pkgname=chromium
 # See https://chromiumdash.appspot.com/releases?platform=Linux for the latest version
 version=122.0.6261.94
-revision=1
+revision=2
 archs="i686* x86_64* aarch64* armv7l*"
 hostmakedepends="
  $(vopt_if clang "clang17 lld17 llvm17 compiler-rt")

From 1ce8d4422e25a6ac7bd831529d6dd7c4c9473f55 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 022/109] cmus: revbump for ffmpeg6

---
 srcpkgs/chromium/patches/ffmpeg5.patch | 47 --------------------------
 srcpkgs/cmus/patches/ffmpeg6.patch     | 12 +++++++
 srcpkgs/cmus/template                  |  2 +-
 3 files changed, 13 insertions(+), 48 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch
 create mode 100644 srcpkgs/cmus/patches/ffmpeg6.patch

diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
deleted file mode 100644
index 24e2da38e34ca2..00000000000000
--- a/srcpkgs/chromium/patches/ffmpeg5.patch
+++ /dev/null
@@ -1,47 +0,0 @@
---- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
-+++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
-@@ -92,24 +92,12 @@
- 
- static base::TimeDelta ExtractStartTime(AVStream* stream) {
-   // The default start time is zero.
--  base::TimeDelta start_time;
-+  base::TimeDelta start_time = kNoTimestamp;
- 
-   // First try to use  the |start_time| value as is.
--  if (stream->start_time != kNoFFmpegTimestamp)
-+  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
-     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
- 
--  // Next try to use the first DTS value, for codecs where we know PTS == DTS
--  // (excludes all H26x codecs). The start time must be returned in PTS.
--  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
--      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
--      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
--      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
--    const base::TimeDelta first_pts =
--        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
--    if (first_pts < start_time)
--      start_time = first_pts;
--  }
--
-   return start_time;
- }
- 
-@@ -1597,7 +1585,7 @@
-   for (const auto& stream : streams_) {
-     if (!stream || stream->IsEnabled() != enabled)
-       continue;
--    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
-+    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
-       continue;
-     if (!lowest_start_time_stream ||
-         stream->start_time() < lowest_start_time_stream->start_time()) {
-@@ -1618,7 +1606,7 @@
-     if (stream->type() != DemuxerStream::VIDEO)
-       continue;
- 
--    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
-+    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
-       continue;
- 
-     if (!stream->IsEnabled())
diff --git a/srcpkgs/cmus/patches/ffmpeg6.patch b/srcpkgs/cmus/patches/ffmpeg6.patch
new file mode 100644
index 00000000000000..ffa95ab811101b
--- /dev/null
+++ b/srcpkgs/cmus/patches/ffmpeg6.patch
@@ -0,0 +1,12 @@
+--- a/ip/ffmpeg.c
++++ b/ip/ffmpeg.c
+@@ -202,9 +202,6 @@ static int ffmpeg_open(struct input_plugin_data *ip_data)
+ 			break;
+ 		}
+ 
+-		if (codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+-			cc->flags |= AV_CODEC_FLAG_TRUNCATED;
+-
+ 		if (avcodec_open2(cc, codec, NULL) < 0) {
+ 			d_print("could not open codec: %d, %s\n", cc->codec_id, avcodec_get_name(cc->codec_id));
+ 			err = -IP_ERROR_UNSUPPORTED_FILE_TYPE;
diff --git a/srcpkgs/cmus/template b/srcpkgs/cmus/template
index 0d1436744f1b2c..a6e4b4fa86cb83 100644
--- a/srcpkgs/cmus/template
+++ b/srcpkgs/cmus/template
@@ -1,7 +1,7 @@
 # Template file for 'cmus'
 pkgname=cmus
 version=2.10.0
-revision=3
+revision=4
 build_style=configure
 configure_args="prefix=/usr LD=$CC"
 hostmakedepends="pkg-config"

From 9e478dedcd7638c55059df6f886e27ca98f4f88d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 023/109] cyanrip: revbump for ffmpeg6

---
 srcpkgs/cyanrip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cyanrip/template b/srcpkgs/cyanrip/template
index 9796e3461601a7..5db30e020d17ee 100644
--- a/srcpkgs/cyanrip/template
+++ b/srcpkgs/cyanrip/template
@@ -1,7 +1,7 @@
 # Template file for 'cyanrip'
 pkgname=cyanrip
 version=0.9.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config"
 makedepends="ffmpeg-devel libcdio-devel libcdio-paranoia-devel libcurl-devel libmusicbrainz5-devel"

From fd63e4641dc3ed4f2a3e0059ec37a7a517960d3f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 024/109] deadbeef: revbump for ffmpeg4

---
 srcpkgs/deadbeef/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/deadbeef/template b/srcpkgs/deadbeef/template
index f5f4bf24b8cb6d..7b47e615cd48ef 100644
--- a/srcpkgs/deadbeef/template
+++ b/srcpkgs/deadbeef/template
@@ -1,14 +1,14 @@
 # Template file for 'deadbeef'
 pkgname=deadbeef
 version=1.8.8
-revision=3
+revision=4
 create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-oss --disable-lfm --disable-notify --disable-gtk2"
 hostmakedepends="automake libtool gettext gettext-devel intltool pkg-config
  yasm clang glib-devel"
 makedepends="
- alsa-lib-devel dbus-devel faad2-devel ffmpeg-devel gtk+3-devel imlib2-devel
+ alsa-lib-devel dbus-devel faad2-devel ffmpeg4-devel gtk+3-devel imlib2-devel
  jansson-devel libcddb-devel libcdio-devel libcurl-devel libflac-devel
  libmad-devel libpng-devel libsamplerate-devel libsndfile-devel libvorbis-devel
  libzip-devel mpg123-devel opusfile-devel pulseaudio-devel wavpack-devel"

From 2c2252c044cc105b648be81b983dd882d36902a5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 025/109] droidcam-obs-plugin: revbump for ffmpeg6

---
 srcpkgs/droidcam-obs-plugin/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam-obs-plugin/template b/srcpkgs/droidcam-obs-plugin/template
index fc9c9bf6b9d54c..fb0480754df4de 100644
--- a/srcpkgs/droidcam-obs-plugin/template
+++ b/srcpkgs/droidcam-obs-plugin/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam-obs-plugin'
 pkgname=droidcam-obs-plugin
 version=2.0.1
-revision=1
+revision=2
 build_style=gnu-makefile
 make_use_env=yes
 make_build_args="ALLOW_STATIC=no"

From 6f8a8d8f307c867dd70da5618b1885023657d373 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 026/109] droidcam: revbump for ffmpeg6

---
 srcpkgs/droidcam/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam/template b/srcpkgs/droidcam/template
index 1c3f1b8b1fc676..32a9220b79a4d1 100644
--- a/srcpkgs/droidcam/template
+++ b/srcpkgs/droidcam/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam'
 pkgname=droidcam
 version=1.8.2
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="USBMUXD=-lusbmuxd-2.0 JPEG=-lturbojpeg"
 hostmakedepends="pkg-config"

From 190ba5d8f85347e03f7b90687008803a45f1fb17 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 027/109] ffmpegthumbnailer: revbump for ffmpeg6

---
 .../ffmpegthumbnailer/patches/ffmpeg6.patch   | 202 ++++++++++++++++++
 srcpkgs/ffmpegthumbnailer/template            |   6 +-
 2 files changed, 205 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch

diff --git a/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
new file mode 100644
index 00000000000000..363ff35a28419d
--- /dev/null
+++ b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
@@ -0,0 +1,202 @@
+--- a/libffmpegthumbnailer/moviedecoder.cpp	2017-11-21 14:06:57.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.cpp	2023-05-05 13:14:47.946560668 -0400
+@@ -41,11 +41,6 @@
+ namespace ffmpegthumbnailer
+ {
+ 
+-struct SilenceLogLevel
+-{
+-    SilenceLogLevel() { av_log_set_level(AV_LOG_QUIET); }
+-};
+-
+ MovieDecoder::MovieDecoder(AVFormatContext* pavContext)
+ : m_VideoStream(-1)
+ , m_pFormatContext(pavContext)
+@@ -70,8 +65,6 @@
+ 
+ void MovieDecoder::initialize(const string& filename, bool preferEmbeddedMetadata)
+ {
+-    av_register_all();
+-    avcodec_register_all();
+     avformat_network_init();
+ 
+     string inputFile = filename == "-" ? "pipe:" : filename;
+@@ -97,8 +90,7 @@
+ {
+     if (m_pVideoCodecContext)
+     {
+-        avcodec_close(m_pVideoCodecContext);
+-        m_pVideoCodecContext = nullptr;
++        avcodec_free_context(&m_pVideoCodecContext);
+     }
+ 
+     if ((!m_FormatContextWasGiven) && m_pFormatContext)
+@@ -152,10 +144,10 @@
+     for (unsigned int i = 0; i < m_pFormatContext->nb_streams; ++i)
+     {
+         AVStream *stream = m_pFormatContext->streams[i];
+-        auto ctx = m_pFormatContext->streams[i]->codec;
+-        if (ctx->codec_type == AVMEDIA_TYPE_VIDEO)
++        auto par = m_pFormatContext->streams[i]->codecpar;
++        if (par->codec_type == AVMEDIA_TYPE_VIDEO)
+         {
+-            if (!preferEmbeddedMetadata || !isStillImageCodec(ctx->codec_id))
++            if (!preferEmbeddedMetadata || !isStillImageCodec(par->codec_id))
+             {
+                 videoStreams.push_back(i);
+                 continue;
+@@ -203,8 +195,7 @@
+     }
+ 
+     m_pVideoStream = m_pFormatContext->streams[m_VideoStream];
+-    m_pVideoCodecContext = m_pVideoStream->codec;
+-    m_pVideoCodec = avcodec_find_decoder(m_pVideoCodecContext->codec_id);
++    m_pVideoCodec = avcodec_find_decoder(m_pVideoStream->codecpar->codec_id);
+ 
+     if (m_pVideoCodec == nullptr)
+     {
+@@ -214,6 +205,20 @@
+         throw logic_error("Video Codec not found");
+     }
+ 
++    m_pVideoCodecContext = avcodec_alloc_context3(m_pVideoCodec);
++
++    if (m_pVideoCodecContext == nullptr)
++    {
++        destroy();
++        throw logic_error("Could not allocate video codec context");
++    }
++
++    if (avcodec_parameters_to_context(m_pVideoCodecContext, m_pVideoStream->codecpar) < 0)
++    {
++        destroy();
++        throw logic_error("Could not configure video codec context");
++    }
++
+     m_pVideoCodecContext->workaround_bugs = 1;
+ 
+     if (avcodec_open2(m_pVideoCodecContext, m_pVideoCodec, nullptr) < 0)
+@@ -386,13 +391,6 @@
+ 
+ void MovieDecoder::initializeFilterGraph(const AVRational& timeBase, const std::string& size, bool maintainAspectRatio)
+ {
+-    static const AVPixelFormat pixelFormats[] = { AV_PIX_FMT_RGB24, AV_PIX_FMT_NONE };
+-
+-    auto del = [] (AVBufferSinkParams* p) { av_freep(p); };
+-    std::unique_ptr<AVBufferSinkParams, decltype(del)> buffersinkParams(av_buffersink_params_alloc(), del);
+-
+-    avfilter_register_all();
+-
+     m_pFilterGraph = avfilter_graph_alloc();
+     assert(m_pFilterGraph);
+ 
+@@ -404,10 +402,8 @@
+ 
+     checkRc(avfilter_graph_create_filter(&m_pFilterSource, avfilter_get_by_name("buffer"), "thumb_buffer", ss.str().c_str(), nullptr, m_pFilterGraph),
+             "Failed to create filter source");
+-    buffersinkParams->pixel_fmts = pixelFormats;
+-    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, buffersinkParams.get(), m_pFilterGraph),
++    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, nullptr, m_pFilterGraph),
+             "Failed to create filter sink");
+-    buffersinkParams.release();
+ 
+     AVFilterContext* yadifFilter = nullptr;
+     if (m_pFrame->interlaced_frame != 0)
+@@ -500,15 +496,15 @@
+     }
+ 
+     checkRc(av_seek_frame(m_pFormatContext, -1, timestamp, 0), "Seeking in video failed");
+-    avcodec_flush_buffers(m_pFormatContext->streams[m_VideoStream]->codec);
++    avcodec_flush_buffers(m_pVideoCodecContext);
+ 
+     int keyFrameAttempts = 0;
+-    bool gotFrame = 0;
++    bool gotFrame;
+ 
+     do
+     {
+         int count = 0;
+-        gotFrame = 0;
++        gotFrame = false;
+ 
+         while (!gotFrame && count < 20)
+         {
+@@ -552,17 +548,33 @@
+         return false;
+     }
+ 
+-    av_frame_unref(m_pFrame);
+-
+-    int frameFinished;
++    int rc = avcodec_send_packet(m_pVideoCodecContext, m_pPacket);
++    if(rc == AVERROR(EAGAIN))
++    {
++        rc = 0;
++    }
+ 
+-    int bytesDecoded = avcodec_decode_video2(m_pVideoCodecContext, m_pFrame, &frameFinished, m_pPacket);
+-    if (bytesDecoded < 0)
++    if(rc == AVERROR_EOF)
++    {
++        return false;
++    }
++    else if(rc < 0)
+     {
+-        throw logic_error("Failed to decode video frame: bytesDecoded < 0");
++        throw logic_error("Failed to decode video frame: avcodec_send_packet() < 0");
+     }
+ 
+-    return frameFinished > 0;
++    rc = avcodec_receive_frame(m_pVideoCodecContext, m_pFrame);
++    switch(rc)
++    {
++        case 0:
++            return true;
++
++        case AVERROR(EAGAIN):
++            return false;
++
++        default:
++            throw logic_error("Failed to decode video frame: avcodec_receive_frame() < 0");
++    }
+ }
+ 
+ bool MovieDecoder::getVideoPacket()
+@@ -570,8 +582,6 @@
+     bool framesAvailable = true;
+     bool frameDecoded = false;
+ 
+-    int attempts = 0;
+-
+     if (m_pPacket)
+     {
+         av_packet_unref(m_pPacket);
+@@ -580,6 +590,7 @@
+ 
+     m_pPacket = new AVPacket();
+ 
++
+     while (framesAvailable && !frameDecoded)
+     {
+         framesAvailable = av_read_frame(m_pFormatContext, m_pPacket) >= 0;
+@@ -644,7 +655,7 @@
+ 
+ int32_t MovieDecoder::getStreamRotation()
+ {
+-    int32_t* matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
++    auto matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
+     if (matrix)
+     {
+         auto angle = lround(av_display_rotation_get(matrix));
+
+--- a/libffmpegthumbnailer/moviedecoder.h	2017-11-12 04:23:38.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.h	2023-05-05 13:26:07.095529911 -0400
+@@ -78,7 +78,7 @@
+     int                     m_VideoStream;
+     AVFormatContext*        m_pFormatContext;
+     AVCodecContext*         m_pVideoCodecContext;
+-    AVCodec*                m_pVideoCodec;
++    const AVCodec*          m_pVideoCodec;
+     AVFilterGraph*          m_pFilterGraph;
+     AVFilterContext*        m_pFilterSource;
+     AVFilterContext*        m_pFilterSink;
diff --git a/srcpkgs/ffmpegthumbnailer/template b/srcpkgs/ffmpegthumbnailer/template
index 039eea7622b391..35d546018d12af 100644
--- a/srcpkgs/ffmpegthumbnailer/template
+++ b/srcpkgs/ffmpegthumbnailer/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbnailer'
 pkgname=ffmpegthumbnailer
 version=2.2.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libpng-devel libjpeg-turbo-devel ffmpeg-devel"
@@ -9,8 +9,8 @@ depends="ffmpeg"
 short_desc="Lightweight video thumbnailer"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
-homepage="https://github.com/dirkvdb/${pkgname}"
-distfiles="${homepage}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
+homepage="https://github.com/dirkvdb"
+distfiles="${homepage}/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
 checksum=1cb24059c38223f657b300c84dd80491b7040d4b69471c4fea69be862bc99b5b
 
 post_install() {

From 5f0de2051794b548ea8e07a00a7e99cfc466de06 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 028/109] ffmpegthumbs: revbump for ffmpeg6

---
 srcpkgs/ffmpegthumbs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ffmpegthumbs/template b/srcpkgs/ffmpegthumbs/template
index 2e2a96de83ce8a..dfd7e9dede36d3 100644
--- a/srcpkgs/ffmpegthumbs/template
+++ b/srcpkgs/ffmpegthumbs/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbs'
 pkgname=ffmpegthumbs
 version=23.08.5
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules kcoreaddons kconfig-devel
  pkg-config qt5-host-tools qt5-qmake gettext"

From 7804fa7cd3f443d6e7abdcce6c10e6fc04ce6b52 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 029/109] ffms2: revbump for ffmpeg6

---
 srcpkgs/ffms2/patches/ffmpeg5.patch | 424 ++++++++++++++++++++++++++++
 srcpkgs/ffms2/template              |   2 +-
 2 files changed, 425 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ffms2/patches/ffmpeg5.patch

diff --git a/srcpkgs/ffms2/patches/ffmpeg5.patch b/srcpkgs/ffms2/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..1479fabcafcb4e
--- /dev/null
+++ b/srcpkgs/ffms2/patches/ffmpeg5.patch
@@ -0,0 +1,424 @@
+From 45673149e9a2f5586855ad472e3059084eaa36b1 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:41:21 +0100
+Subject: [PATCH] Use auto for AVCodec
+
+The geniuses over at FFmpeg decided to constify this API, so old
+versions of the library will return AVCodec *, while new versions
+of the libary will return const AVCodec *, which, in C++, are not
+OK to convert between.
+
+Rather than use some macro hell in ffmscompat.h, we can work around
+this by using auto.
+
+Gross.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 2 +-
+ src/core/indexing.cpp    | 6 +++---
+ src/core/videosource.cpp | 2 +-
+ 3 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index e4ce97c..ac09666 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -469,7 +469,7 @@ void FFMS_AudioSource::OpenFile() {
+ 
+     LAVFOpenFile(SourceFile.c_str(), FormatContext, TrackNumber);
+ 
+-    AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
++    auto *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
+     if (Codec == nullptr)
+         throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+             "Audio codec not found");
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index e547c5a..59fb4e8 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -384,7 +384,7 @@ FFMS_TrackType FFMS_Indexer::GetTrackType(int Track) {
+ }
+ 
+ const char *FFMS_Indexer::GetTrackCodec(int Track) {
+-    AVCodec *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
++    auto *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
+     return codec ? codec->name : nullptr;
+ }
+ 
+@@ -402,7 +402,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             UseDTS);
+ 
+         if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            AVCodec *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (!VideoCodec) {
+                 FormatContext->streams[i]->discard = AVDISCARD_ALL;
+                 IndexMask.erase(i);
+@@ -433,7 +433,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 IndexMask.insert(i);
+             }
+         } else if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+-            AVCodec *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (AudioCodec == nullptr)
+                 throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_UNSUPPORTED,
+                     "Audio codec not found");
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index b889970..8956c22 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -171,7 +171,7 @@ FFMS_VideoSource::FFMS_VideoSource(const char *SourceFile, FFMS_Index &Index, in
+ 
+         LAVFOpenFile(SourceFile, FormatContext, VideoTrack);
+ 
+-        AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
++        auto *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
+         if (Codec == nullptr)
+             throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+                 "Video codec not found");
+-- 
+2.40.0
+
+From 96cbf38ea9381829a1314f432a2c60495dcefaad Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:12:41 +0100
+Subject: [PATCH] all: Update AVPacket API usage
+
+AVPackets must all be on the heap now, since it is no longer
+part of the libav* ABI.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 16 ++++++----
+ src/core/indexing.cpp    | 63 ++++++++++++++++++++++------------------
+ src/core/indexing.h      |  4 +--
+ src/core/utils.cpp       |  6 ----
+ src/core/utils.h         |  1 -
+ src/core/videosource.cpp | 30 ++++++++++---------
+ 6 files changed, 64 insertions(+), 56 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index 37cf9ae..e4ce97c 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -285,10 +285,15 @@ FFMS_AudioSource::AudioBlock *FFMS_AudioSource::CacheBlock(CacheIterator &pos) {
+ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     CurrentFrame = &Frames[PacketNumber];
+ 
+-    AVPacket Packet;
+-    if (!ReadPacket(&Packet))
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++    if (!ReadPacket(Packet)) {
++        av_packet_free(&Packet);
+         throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_UNKNOWN,
+             "ReadPacket unexpectedly failed to read a packet");
++    }
+ 
+     // ReadPacket may have changed the packet number
+     CurrentFrame = &Frames[PacketNumber];
+@@ -297,8 +302,9 @@ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     int NumberOfSamples = 0;
+     AudioBlock *CachedBlock = nullptr;
+     
+-    int Ret = avcodec_send_packet(CodecContext, &Packet);
+-    av_packet_unref(&Packet);
++    int Ret = avcodec_send_packet(CodecContext, Packet);
++    av_packet_unref(Packet);
++    av_packet_free(&Packet);
+ 
+     av_frame_unref(DecodeFrame);
+     Ret = avcodec_receive_frame(CodecContext, DecodeFrame);
+@@ -513,8 +519,6 @@ void FFMS_AudioSource::Seek() {
+ }
+ 
+ bool FFMS_AudioSource::ReadPacket(AVPacket *Packet) {
+-    InitNullPacket(*Packet);
+-
+     while (av_read_frame(FormatContext, Packet) >= 0) {
+         if (Packet->stream_index == TrackNumber) {
+             // Required because not all audio packets, especially in ogg, have a pts. Use the previous valid packet's pts instead.
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index 23fb95b..e547c5a 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -320,7 +320,7 @@ void FFMS_Indexer::CheckAudioProperties(int Track, AVCodecContext *Context) {
+     }
+ }
+ 
+-void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict,
++void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict,
+                                     int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct) {
+     if (VideoContext.Parser) {
+         uint8_t *OB;
+@@ -330,8 +330,8 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+         av_parser_parse2(VideoContext.Parser,
+             VideoContext.CodecContext,
+             &OB, &OBSize,
+-            pkt.data, pkt.size,
+-            pkt.pts, pkt.dts, pkt.pos);
++            pkt->data, pkt->size,
++            pkt->pts, pkt->dts, pkt->pos);
+ 
+         // H.264 (PAFF) and HEVC may have one field per packet, so we need to track
+         // when we have a full or half frame available, and mark one of them as
+@@ -351,15 +351,15 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+ 
+         *RepeatPict = VideoContext.Parser->repeat_pict;
+         *FrameType = VideoContext.Parser->pict_type;
+-        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt.flags & AV_PKT_FLAG_DISCARD));
++        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt->flags & AV_PKT_FLAG_DISCARD));
+     } else {
+-        *Invisible = !!(pkt.flags & AV_PKT_FLAG_DISCARD);
++        *Invisible = !!(pkt->flags & AV_PKT_FLAG_DISCARD);
+     }
+ 
+     if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP8)
+-        ParseVP8(pkt.data[0], Invisible, FrameType);
++        ParseVP8(pkt->data[0], Invisible, FrameType);
+     else if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP9)
+-        ParseVP9(pkt.data[0], Invisible, FrameType);
++        ParseVP9(pkt->data[0], Invisible, FrameType);
+ }
+ 
+ void FFMS_Indexer::Free() {
+@@ -458,32 +458,36 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+         }
+     }
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
+     std::vector<int64_t> LastValidTS(FormatContext->nb_streams, AV_NOPTS_VALUE);
+ 
+     int64_t filesize = avio_size(FormatContext->pb);
+     enum AVPictureStructure LastPicStruct = AV_PICTURE_STRUCTURE_UNKNOWN;
+-    while (av_read_frame(FormatContext, &Packet) >= 0) {
++    while (av_read_frame(FormatContext, Packet) >= 0) {
+         // Update progress
+         // FormatContext->pb can apparently be NULL when opening images.
+         if (IC && FormatContext->pb) {
+-            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate))
++            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate)) {
++                av_packet_free(&Packet);
+                 throw FFMS_Exception(FFMS_ERROR_CANCELLED, FFMS_ERROR_USER,
+                     "Cancelled by user");
++            }
+         }
+-        if (!IndexMask.count(Packet.stream_index)) {
+-            av_packet_unref(&Packet);
++        if (!IndexMask.count(Packet->stream_index)) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+-        int Track = Packet.stream_index;
++        int Track = Packet->stream_index;
+         FFMS_Track &TrackInfo = (*TrackIndices)[Track];
+-        bool KeyFrame = !!(Packet.flags & AV_PKT_FLAG_KEY);
++        bool KeyFrame = !!(Packet->flags & AV_PKT_FLAG_KEY);
+         ReadTS(Packet, LastValidTS[Track], (*TrackIndices)[Track].UseDTS);
+ 
+         if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            int64_t PTS = TrackInfo.UseDTS ? Packet.dts : Packet.pts;
++            int64_t PTS = TrackInfo.UseDTS ? Packet->dts : Packet->pts;
+             if (PTS == AV_NOPTS_VALUE) {
+                 // VPx alt-refs are output as packets which lack timestmps or durations, since
+                 // they are invisible. Currently, the timestamp mangling code in libavformat
+@@ -495,9 +499,11 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 // FFMS2 currently sorts packets by PTS, which will break decoding, otherwise.
+                 bool HasAltRefs = (FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP8 ||
+                                    FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP9);
+-                if (Packet.duration == 0 && !HasAltRefs)
++                if (Packet->duration == 0 && !HasAltRefs) {
++                    av_packet_free(&Packet);
+                     throw FFMS_Exception(FFMS_ERROR_INDEXING, FFMS_ERROR_PARSER,
+                         "Invalid packet pts, dts, and duration");
++                }
+ 
+                 if (TrackInfo.empty())
+                     PTS = 0;
+@@ -513,7 +519,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             ParseVideoPacket(AVContexts[Track], Packet, &RepeatPict, &FrameType, &Invisible, &LastPicStruct);
+ 
+             TrackInfo.AddVideoFrame(PTS, RepeatPict, KeyFrame,
+-                FrameType, Packet.pos, Invisible);
++                FrameType, Packet->pos, Invisible);
+         } else if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+             // For video seeking timestamps are used only if all packets have
+             // timestamps, while for audio they're used if any have timestamps,
+@@ -522,28 +528,29 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 TrackInfo.HasTS = true;
+ 
+             int64_t StartSample = AVContexts[Track].CurrentSample;
+-            uint32_t SampleCount = IndexAudioPacket(Track, &Packet, AVContexts[Track], *TrackIndices);
++            uint32_t SampleCount = IndexAudioPacket(Track, Packet, AVContexts[Track], *TrackIndices);
+             TrackInfo.SampleRate = AVContexts[Track].CodecContext->sample_rate;
+ 
+             TrackInfo.AddAudioFrame(LastValidTS[Track],
+-                StartSample, SampleCount, KeyFrame, Packet.pos, Packet.flags & AV_PKT_FLAG_DISCARD);
++                StartSample, SampleCount, KeyFrame, Packet->pos, Packet->flags & AV_PKT_FLAG_DISCARD);
+         }
+ 
+-        if (!(Packet.flags & AV_PKT_FLAG_DISCARD))
+-            TrackInfo.LastDuration = Packet.duration;
++        if (!(Packet->flags & AV_PKT_FLAG_DISCARD))
++            TrackInfo.LastDuration = Packet->duration;
+ 
+-        av_packet_unref(&Packet);
++        av_packet_unref(Packet);
+     }
++    av_packet_free(&Packet);
+ 
+     TrackIndices->Finalize(AVContexts, FormatContext->iformat->name);
+     return TrackIndices.release();
+ }
+ 
+-void FFMS_Indexer::ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS) {
+-    if (!UseDTS && Packet.pts != AV_NOPTS_VALUE)
+-        TS = Packet.pts;
++void FFMS_Indexer::ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS) {
++    if (!UseDTS && Packet->pts != AV_NOPTS_VALUE)
++        TS = Packet->pts;
+     if (TS == AV_NOPTS_VALUE)
+         UseDTS = true;
+-    if (UseDTS && Packet.dts != AV_NOPTS_VALUE)
+-        TS = Packet.dts;
++    if (UseDTS && Packet->dts != AV_NOPTS_VALUE)
++        TS = Packet->dts;
+ }
+diff --git a/src/core/indexing.h b/src/core/indexing.h
+index 3cfc3c3..5c06868 100644
+--- a/src/core/indexing.h
++++ b/src/core/indexing.h
+@@ -80,10 +80,10 @@ private:
+     int64_t Filesize;
+     uint8_t Digest[20];
+ 
+-    void ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS);
++    void ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS);
+     void CheckAudioProperties(int Track, AVCodecContext *Context);
+     uint32_t IndexAudioPacket(int Track, AVPacket *Packet, SharedAVContext &Context, FFMS_Index &TrackIndices);
+-    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
++    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
+     void Free();
+ public:
+     FFMS_Indexer(const char *Filename);
+diff --git a/src/core/utils.cpp b/src/core/utils.cpp
+index ce67533..8a2e997 100644
+--- a/src/core/utils.cpp
++++ b/src/core/utils.cpp
+@@ -62,12 +62,6 @@ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo) {
+     }
+ }
+ 
+-void InitNullPacket(AVPacket &pkt) {
+-    av_init_packet(&pkt);
+-    pkt.data = nullptr;
+-    pkt.size = 0;
+-}
+-
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames) {
+     AP.SampleFormat = static_cast<FFMS_SampleFormat>(av_get_packed_sample_fmt(CTX->sample_fmt));
+     AP.BitsPerSample = av_get_bytes_per_sample(CTX->sample_fmt) * 8;
+diff --git a/src/core/utils.h b/src/core/utils.h
+index 9819dc7..003ab79 100644
+--- a/src/core/utils.h
++++ b/src/core/utils.h
+@@ -58,7 +58,6 @@ std::unique_ptr<T> make_unique(Args&&... args) {
+ }
+ 
+ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo);
+-void InitNullPacket(AVPacket &pkt);
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames);
+ 
+ void LAVFOpenFile(const char *SourceFile, AVFormatContext *&FormatContext, int Track);
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index 06bd161..b889970 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -673,30 +673,34 @@ void FFMS_VideoSource::DecodeNextFrame(int64_t &AStartTime, int64_t &Pos) {
+     if (HasPendingDelayedFrames())
+         return;
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
+-
+-    while (ReadFrame(&Packet) >= 0) {
+-        if (Packet.stream_index != VideoTrack) {
+-            av_packet_unref(&Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++
++    while (ReadFrame(Packet) >= 0) {
++        if (Packet->stream_index != VideoTrack) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+         if (AStartTime < 0)
+-            AStartTime = Frames.UseDTS ? Packet.dts : Packet.pts;
++            AStartTime = Frames.UseDTS ? Packet->dts : Packet->pts;
+ 
+         if (Pos < 0)
+-            Pos = Packet.pos;
++            Pos = Packet->pos;
+ 
+-        bool FrameFinished = DecodePacket(&Packet);
+-        av_packet_unref(&Packet);
+-        if (FrameFinished)
++        bool FrameFinished = DecodePacket(Packet);
++        av_packet_unref(Packet);
++        if (FrameFinished) {
++            av_packet_free(&Packet);
+             return;
++        }
+     }
+ 
+     // Flush final frames
+-    InitNullPacket(Packet);
+-    DecodePacket(&Packet);
++    DecodePacket(Packet);
++    av_packet_free(&Packet);
+ }
+ 
+ bool FFMS_VideoSource::SeekTo(int n, int SeekOffset) {
+-- 
+2.40.0
+
+From bf9e03e9e08534c024e5a744a6437c4aac160201 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:20:47 +0100
+Subject: [PATCH 2/3] configure: Remove deprecated API use
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ configure.ac | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index b35ef80bc..d19714d0f 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -102,10 +102,10 @@ CFLAGS="$_CFLAGS $FFMPEG_CFLAGS"
+
+ AC_DEFUN([TEST_FFMPEG],
+          [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+-            #include <libavcodec/avcodec.h>
++            #include <libavformat/avformat.h>
+             #include <libswscale/swscale.h>
+             ]],[[
+-                avcodec_register_all();
++                avformat_network_init();
+                 swscale_version();
+             ]])], [eval $1=yes], [eval $1=no])
+         ])
+
diff --git a/srcpkgs/ffms2/template b/srcpkgs/ffms2/template
index 365f64d10cbabf..1641ecf43be5bb 100644
--- a/srcpkgs/ffms2/template
+++ b/srcpkgs/ffms2/template
@@ -1,7 +1,7 @@
 # Template file for 'ffms2'
 pkgname=ffms2
 version=2.40
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-shared --disable-static"
 hostmakedepends="pkg-config autoconf automake libtool"

From f6e9f163f3cec21773adeeb1dc3ebf70f0e739a2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 030/109] freerdp: revbump for ffmpeg6

---
 .../freerdp/patches/ffmpeg6_aa2cb9aa.patch    | 42 +++++++++++++++++++
 srcpkgs/freerdp/template                      |  2 +-
 2 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch

diff --git a/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
new file mode 100644
index 00000000000000..a4324da3a8822b
--- /dev/null
+++ b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
@@ -0,0 +1,42 @@
+From aa2cb9aa5ff5562433598ba168a466e0752bca0e Mon Sep 17 00:00:00 2001
+From: akallabeth <akallabeth@posteo.net>
+Date: Tue, 14 Feb 2023 07:48:54 +0100
+Subject: [PATCH] Fixed #8686: Update h264 to use new FFMPEG API
+
+---
+ channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c | 2 ++
+ libfreerdp/codec/h264_ffmpeg.c            | 2 ++
+ 2 files changed, 4 insertions(+)
+
+diff --git a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+index 339462d865f..beea80b7a1e 100644
+--- a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
++++ b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+@@ -239,8 +239,10 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYP
+ 		}
+ 	}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 	if (mdecoder->codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		mdecoder->codec_context->flags |= AV_CODEC_FLAG_TRUNCATED;
++#endif
+ 
+ 	return TRUE;
+ }
+diff --git a/libfreerdp/codec/h264_ffmpeg.c b/libfreerdp/codec/h264_ffmpeg.c
+index 8a23db2473c..896a333019b 100644
+--- a/libfreerdp/codec/h264_ffmpeg.c
++++ b/libfreerdp/codec/h264_ffmpeg.c
+@@ -615,10 +615,12 @@ static BOOL libavcodec_init(H264_CONTEXT* h264)
+ 			goto EXCEPTION;
+ 		}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 		if (sys->codecDecoder->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		{
+ 			sys->codecDecoderContext->flags |= AV_CODEC_FLAG_TRUNCATED;
+ 		}
++#endif
+ 
+ #ifdef WITH_VAAPI
+ 
diff --git a/srcpkgs/freerdp/template b/srcpkgs/freerdp/template
index 16fddfbe8f5287..bf3a4d2e2b3ae7 100644
--- a/srcpkgs/freerdp/template
+++ b/srcpkgs/freerdp/template
@@ -1,7 +1,7 @@
 # Template file for 'freerdp'
 pkgname=freerdp
 version=2.11.4
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_ALSA=ON -DWITH_CUPS=OFF -DWITH_FFMPEG=ON
  -DWITH_GSTREAMER_0_10=OFF -DWITH_GSTREAMER_1_0=OFF -DWITH_JPEG=ON

From 171aea861f1d63c36118dcb5cf483ccd5f44c6e0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 031/109] gerbera: revbump for ffmpeg6

---
 srcpkgs/gerbera/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gerbera/template b/srcpkgs/gerbera/template
index ae14f35c767c03..2dc0ac0ce03b55 100644
--- a/srcpkgs/gerbera/template
+++ b/srcpkgs/gerbera/template
@@ -1,7 +1,7 @@
 # Template file for 'gerbera'
 pkgname=gerbera
 version=1.12.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_SYSTEMD=0 -DWITH_AVCODEC=1"
 hostmakedepends="pkg-config"

From 83ffee4a0cb00a537b75dab6dcb3b258425edd17 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 032/109] goldendict: revbump for ffmpeg6

---
 srcpkgs/goldendict/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/goldendict/template b/srcpkgs/goldendict/template
index f4a05759f693d3..97f44347b03a6a 100644
--- a/srcpkgs/goldendict/template
+++ b/srcpkgs/goldendict/template
@@ -1,7 +1,7 @@
 # Template file for 'goldendict'
 pkgname=goldendict
 version=1.5.0
-revision=1
+revision=2
 build_style=qmake
 configure_args="CONFIG+=zim_support goldendict.pro"
 hostmakedepends="qt5-qmake pkg-config qt5-host-tools"
@@ -10,7 +10,7 @@ makedepends="tiff-devel qt5-devel libvorbis-devel zlib-devel
  qt5-webkit-devel lzo-devel bzip2-devel libao-devel qt5-svg-devel
  libeb-devel qt5-x11extras-devel ffmpeg-devel liblzma-devel
  qt5-multimedia-devel"
-short_desc="A feature-rich dictionary lookup program"
+short_desc="Feature-rich dictionary lookup program"
 maintainer="John <me@johnnynator.dev>"
 license="GPL-3.0-or-later"
 homepage="http://goldendict.org/"

From a843500760a8c9d62505135f595d610ff1bc7da0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 033/109] gst-libav: revbump for ffmpeg6

---
 srcpkgs/gst-libav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index b24be23fc1a6d2..0f9350a251bf67 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.22.9
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"

From 10cd1fb00f897410dd6f2360bbcaf38d4acb5141 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Feb 2024 01:52:46 -0500
Subject: [PATCH 034/109] gst-plugins-bad1: revbump for ffmpeg6

---
 srcpkgs/gst-plugins-bad1/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index dc4db910c43e84..b3db9c0ab0829f 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-plugins-bad1'
 pkgname=gst-plugins-bad1
 version=1.22.9
-revision=2
+revision=3
 build_helper="gir"
 build_style=meson
 configure_args="-Dpackage-origin=https://voidlinux.org -Ddoc=disabled
@@ -27,7 +27,7 @@ makedepends="alsa-lib-devel celt-devel openssl-devel exempi-devel
  fdk-aac-devel flite-devel fluidsynth-devel liblrdf-devel ladspa-sdk
  lilv-devel lv2 libopenjpeg2-devel sbc-devel spandsp-devel vulkan-loader
  Vulkan-Headers webrtc-audio-processing-devel libzbar-devel ffmpeg-devel
- srt-devel libva-devel
+ srt-devel libva-devel oneVPL-devel
  $(vopt_if gme libgme-devel)"
 depends="gst-plugins-base1>=${version}"
 short_desc="GStreamer plugins from the bad set (v1.x)"

From 154d9099e2a922a0d682ceab8a12f487b646affd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 035/109] gst-rtsp-server: revbump for ffmpeg6

---
 srcpkgs/gst-rtsp-server/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index bc2a0dea6ac152..f77026c618eb69 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
 version=1.22.9
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config python3"
 makedepends="glib-devel gst-plugins-bad1-devel gobject-introspection

From 5f3711d3c0ed274b4cbfcb1e8e23e86ca80043d9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 036/109] guvcview: update to 2.0.8.

---
 srcpkgs/guvcview/patches/fix-include.patch | 10 ++++++++++
 srcpkgs/guvcview/template                  |  7 +++----
 2 files changed, 13 insertions(+), 4 deletions(-)
 create mode 100644 srcpkgs/guvcview/patches/fix-include.patch

diff --git a/srcpkgs/guvcview/patches/fix-include.patch b/srcpkgs/guvcview/patches/fix-include.patch
new file mode 100644
index 00000000000000..503c2af3b78c1a
--- /dev/null
+++ b/srcpkgs/guvcview/patches/fix-include.patch
@@ -0,0 +1,10 @@
+--- a/guvcview/guvcview.c
++++ b/guvcview/guvcview.c
+@@ -28,6 +28,7 @@
+ #include <sys/stat.h>
+ #include <sys/resource.h>
+ #include <errno.h>
++#include <locale.h>
+ 
+ #include "gview.h"
+ #include "gviewv4l2core.h"
diff --git a/srcpkgs/guvcview/template b/srcpkgs/guvcview/template
index d42fd38fa4ad12..86a7fd619612c8 100644
--- a/srcpkgs/guvcview/template
+++ b/srcpkgs/guvcview/template
@@ -1,8 +1,7 @@
 # Template file for 'guvcview'
 pkgname=guvcview
-version=2.0.7
-revision=2
-create_wrksrc=yes
+version=2.0.8
+revision=1
 build_style=gnu-configure
 configure_args="--disable-static --disable-debian-menu"
 hostmakedepends="pkg-config intltool autoconf automake libtool glib-devel"
@@ -14,7 +13,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="http://guvcview.sourceforge.net/"
 distfiles="${SOURCEFORGE_SITE}/${pkgname}/${pkgname}-src-${version}.tar.bz2"
-checksum=f47d51fbd06e44eeaa1a82f4a153c927527c90d94514197a70b2956028cc8ad4
+checksum=a21f4e448286666cf27bafef5290cc953a0a1796b752e5bbe521266dc1230c81
 
 post_patch() {
 	sed '31a#include <locale.h>' -i  guvcview/guvcview.c

From 1d2a98c2852815ae67b3c577b88a8338561db670 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 037/109] handbrake: update to 1.6.1

---
 .../patches/fix-missing-x265-link-flag.patch    | 11 ++++++-----
 .../handbrake/patches/libhb-vpl-include.patch   | 15 +++++++++++++++
 srcpkgs/handbrake/template                      | 17 ++++++++++-------
 3 files changed, 31 insertions(+), 12 deletions(-)
 create mode 100644 srcpkgs/handbrake/patches/libhb-vpl-include.patch

diff --git a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
index 26db03867a0c83..d6bb2eda627a36 100644
--- a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
+++ b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
@@ -1,14 +1,15 @@
 --- a/gtk/configure.ac
 +++ b/gtk/configure.ac
 @@ -203,7 +203,7 @@
- 
+
  AM_CONDITIONAL([MINGW], [test "x$mingw_flag" = "xyes"])
- 
--HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg"
-+HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -ldl"
+
+-HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc"
++HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc -ldl"
  HB_CPPFLAGS="$HB_CPPFLAGS $HBINC"
- 
+
  PKG_CHECK_MODULES([x264], [x264], sys_x264=yes, sys_x264=no)
+
 --- a/test/module.defs
 +++ b/test/module.defs
 @@ -69,6 +69,9 @@
diff --git a/srcpkgs/handbrake/patches/libhb-vpl-include.patch b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
new file mode 100644
index 00000000000000..298f9f4ab28f2a
--- /dev/null
+++ b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
@@ -0,0 +1,15 @@
+--- a/libhb/module.defs	2023-01-22 11:36:49.000000000 -0500
++++ b/libhb/module.defs	2023-04-03 22:37:52.395467010 -0400
+@@ -46,11 +46,7 @@
+ LIBHB.GCC.I += $(LIBHB.build/) $(CONTRIB.build/)include
+ 
+ ifeq (1,$(FEATURE.qsv))
+-    ifeq ($(HOST.system),freebsd))
+-        LIBHB.GCC.I += $(LOCALBASE)/include/vpl
+-    else
+-        LIBHB.GCC.I += $(CONTRIB.build/)include/vpl
+-    endif
++    LIBHB.GCC.I += /usr/include/vpl
+ endif
+ 
+ ifneq (,$(filter $(HOST.system),freebsd netbsd openbsd))
diff --git a/srcpkgs/handbrake/template b/srcpkgs/handbrake/template
index ca5e4571e49c37..c32cb1bfa31f4b 100644
--- a/srcpkgs/handbrake/template
+++ b/srcpkgs/handbrake/template
@@ -1,10 +1,10 @@
 # Template file for 'handbrake'
 pkgname=handbrake
-version=1.5.1
+version=1.6.1
 revision=1
 build_style=gnu-configure
 configure_args="--force --disable-gtk-update-checks --disable-df-fetch --harden
- $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc)"
+ $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc) $(vopt_enable qsv)"
 make_build_args="-C ${XBPS_TRIPLET}"
 make_install_args="-C ${XBPS_TRIPLET}"
 hostmakedepends="automake cmake gettext-devel glib-devel intltool libtool m4 meson nasm pkg-config python3"
@@ -12,8 +12,11 @@ makedepends="bzip2-devel ffmpeg-devel gst-plugins-base1-devel gtk+3-devel
  jansson-devel lame-devel libass-devel libbluray-devel libdav1d-devel
  libdvdnav-devel libdvdread-devel libgudev-devel libnuma-devel
  libsamplerate-devel libtheora-devel libvorbis-devel libvpx-devel libxml2-devel
- opus-devel speex-devel x264-devel x265-devel zimg-devel
+ opus-devel speex-devel x264-devel x265-devel zimg-devel libsvt-av1-devel
  $(vopt_if fdk_aac fdk-aac-devel)
+ $(vopt_if qsv libva-devel)
+ $(vopt_if qsv libdrm-devel)
+ $(vopt_if qsv onevpl-devel)
  $(vopt_if nvenc nv-codec-headers)"
 depends="desktop-file-utils gst-plugins-good1 hicolor-icon-theme"
 short_desc="Multithreaded video transcoder"
@@ -21,15 +24,15 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-2.0-only"
 homepage="https://handbrake.fr/"
 distfiles="https://github.com/HandBrake/HandBrake/releases/download/${version}/HandBrake-${version}-source.tar.bz2"
-checksum=3999fe06d5309c819799a73a968a8ec3840e7840c2b64af8f5cdb7fd8c9430f0
+checksum=94ccfe03db917a91650000c510f7fd53f844da19f19ad4b4be1b8f6bc31a8d4c
 nocross=yes
 
-build_options="fdk_aac nvenc"
+build_options="fdk_aac nvenc qsv"
 
 case "$XBPS_TARGET_MACHINE" in
 	x86_64*|i686*)
 		CFLAGS="-msse"
-		build_options_default="nvenc"
+		build_options_default="nvenc qsv"
 		;;
 esac
 
@@ -37,7 +40,7 @@ pre_configure() {
 	# use system libraries, don't download them
 	rm -rf contrib/
 	for module in fdk-aac ffmpeg libbluray libdav1d libdvdnav libdvdread nvenc \
-		x265 zimg; do
+		x265 zimg svt-av1 libvpl; do
 	    vsed -i "/MODULES += contrib\/${module}/d" make/include/main.defs
 	done
 }

From fd833ebb78ec90e0ba095a019713247e4ae26101 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 038/109] hedgewars: revbump for ffmpeg4

---
 srcpkgs/hedgewars/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/hedgewars/template b/srcpkgs/hedgewars/template
index 94b6db673b0c3a..402ccfaaecbc2d 100644
--- a/srcpkgs/hedgewars/template
+++ b/srcpkgs/hedgewars/template
@@ -1,13 +1,13 @@
 # Template file for 'hedgewars'
 pkgname=hedgewars
 version=1.0.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DNOSERVER=1 -DDATA_INSTALL_DIR=/usr/share/${pkgname}
  -DPHYSFS_SYSTEM=1 -DMINIMAL_FLAGS=1"
 make_cmd=make
 hostmakedepends="lua51 pkg-config qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
+makedepends="ffmpeg4-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
  SDL2_mixer-devel SDL2_net-devel SDL2_ttf-devel"
 depends="libfreeglut"
 short_desc="Funny turn-based artillery game, featuring fighting Hedgehogs!"

From e70d315d6f2ed441c4f6dbb3d6252cc50d26e02b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 039/109] idjc: revbump for ffmpeg4

---
 srcpkgs/idjc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/idjc/template b/srcpkgs/idjc/template
index a9cde0665d55b1..f41e1e4fabbae7 100644
--- a/srcpkgs/idjc/template
+++ b/srcpkgs/idjc/template
@@ -1,11 +1,11 @@
 # Template file for 'idjc'
 pkgname=idjc
 version=0.9.1
-revision=5
+revision=6
 build_style=gnu-configure
 hostmakedepends="pkg-config git python3 automake gettext-devel libtool"
 makedepends="libvorbis-devel libogg-devel jack-devel libsamplerate-devel
- libflac-devel libsndfile-devel mpg123-devel ffmpeg-devel speex-devel
+ libflac-devel libsndfile-devel mpg123-devel ffmpeg4-devel speex-devel
  glib-devel pixman-devel lame-devel python3-gobject-devel libshout-idjc-devel
  opus-devel twolame-devel python3-mutagen python3-devel"
 depends="python3-gobject python3-mutagen desktop-file-utils shared-mime-info python3-dbus jack"

From 773d130fd18d9e792d76103a89f8d667af56dd54 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 040/109] kid3: revbump for ffmpeg6

---
 srcpkgs/kid3/patches/ffmpeg5.patch | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 srcpkgs/kid3/patches/ffmpeg5.patch

diff --git a/srcpkgs/kid3/patches/ffmpeg5.patch b/srcpkgs/kid3/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..135fc50e07c9ba
--- /dev/null
+++ b/srcpkgs/kid3/patches/ffmpeg5.patch
@@ -0,0 +1,17 @@
+# https://aur.archlinux.org/cgit/aur.git/diff/ffmpeg5.patch?h=kid3-cli&id=12410a74906612e7efc0ec8fbce739b4a0fef7e7
+diff --git a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+index e156d424..e12b9abd 100644
+--- a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
++++ b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+@@ -232,7 +232,11 @@ private:
+   friend class Format;
+   friend class Converter;
+   AVCodecContext* m_ptr;
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 0, 0)
+   AVCodec* m_impl;
++#else
++  const AVCodec* m_impl;
++#endif
+   AVFrame* m_frame;
+   bool m_opened;
+ };

From 06682e940d3d2bee890fdeb54433adbe08e666c5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 041/109] kodi: revbump for ffmpeg4

---
 srcpkgs/kodi/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/kodi/template b/srcpkgs/kodi/template
index d37a5918cd6758..ea78e0aca0fe3e 100644
--- a/srcpkgs/kodi/template
+++ b/srcpkgs/kodi/template
@@ -1,7 +1,7 @@
 # Template file for 'kodi'
 pkgname=kodi
 version=19.4
-revision=9
+revision=10
 _codename="Matrix"
 build_style=cmake
 configure_args="-DWITH_FFMPEG=/usr -DENABLE_LDGOLD=OFF
@@ -54,7 +54,7 @@ makedepends="
  libmad-devel fontconfig-devel libXinerama-devel libsamplerate-devel libmms-devel
  enca-devel boost-devel libcurl-devel libva-devel libvdpau-devel libass-devel
  libbluetooth-devel yajl-devel libplist-devel librtmp-devel tinyxml-devel
- taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg-devel
+ taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg4-devel
  giflib-devel libxslt-devel gnutls-devel libssh-devel libmicrohttpd-devel
  libcec-devel dcadec-devel flatbuffers-devel fmt-devel lcms2-devel
  libfstrcmp-devel rapidjson libcdio-paranoia spdlog libwaylandpp-devel

From 905cb0ecc0fffe07674b4af16e99acb2fd8c0d09 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 042/109] kpipewire: revbump for ffmpeg6

---
 srcpkgs/kpipewire/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kpipewire/template b/srcpkgs/kpipewire/template
index 24f5f152749c97..d5ac3788ff586a 100644
--- a/srcpkgs/kpipewire/template
+++ b/srcpkgs/kpipewire/template
@@ -1,7 +1,7 @@
 # Template file for 'kpipewire'
 pkgname=kpipewire
 version=5.27.11
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules plasma-wayland-protocols gettext
  qt5-qmake qt5-host-tools pkg-config wayland-devel kcoreaddons

From 2397ca4b7c6ca31f01b9e746c5d95e083706d7e8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 043/109] libopenal: revbump for ffmpeg6

---
 srcpkgs/libopenal/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenal/template b/srcpkgs/libopenal/template
index 88d0f11307d81a..8308fca0393e33 100644
--- a/srcpkgs/libopenal/template
+++ b/srcpkgs/libopenal/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenal'
 pkgname=libopenal
 version=1.23.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DALSOFT_EXAMPLES=OFF"
 hostmakedepends="pkg-config"

From 237f53d50e9a18014cbc79ee6763433b05b26b20 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 044/109] loudgain: revbump for ffmpeg6

---
 srcpkgs/loudgain/patches/ffmpeg5.patch | 11 +++++++++++
 srcpkgs/loudgain/template              |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/loudgain/patches/ffmpeg5.patch

diff --git a/srcpkgs/loudgain/patches/ffmpeg5.patch b/srcpkgs/loudgain/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..16d4510ee98faa
--- /dev/null
+++ b/srcpkgs/loudgain/patches/ffmpeg5.patch
@@ -0,0 +1,11 @@
+--- a/src/scan.c	2019-09-06 11:31:19.000000000 -0400
++++ b/src/scan.c	2023-03-23 11:15:40.867968521 -0400
+@@ -69,8 +69,6 @@
+ 	 * It is now useless
+ 	 * https://github.com/FFmpeg/FFmpeg/blob/70d25268c21cbee5f08304da95be1f647c630c15/doc/APIchanges#L86
+ 	 */
+-  if (avformat_version() < AV_VERSION_INT(58,9,100))
+-    av_register_all();
+ 
+ 	av_log_set_callback(scan_av_log);
+ 
diff --git a/srcpkgs/loudgain/template b/srcpkgs/loudgain/template
index da4f2d56e94c3d..4d6bf29efb4fdd 100644
--- a/srcpkgs/loudgain/template
+++ b/srcpkgs/loudgain/template
@@ -1,7 +1,7 @@
 # Template file for 'loudgain'
 pkgname=loudgain
 version=0.6.8
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libebur128-devel taglib-devel ffmpeg-devel"

From f0d1a6e1823c3cc22a76c85fa78ec6367c658466 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 045/109] mediastreamer: revbump for ffmpeg4

---
 srcpkgs/mediastreamer/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mediastreamer/template b/srcpkgs/mediastreamer/template
index 0fcffa7653d18e..e888626b945e55 100644
--- a/srcpkgs/mediastreamer/template
+++ b/srcpkgs/mediastreamer/template
@@ -1,11 +1,11 @@
 # Template file for 'mediastreamer'
 pkgname=mediastreamer
 version=5.2.111
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DENABLE_STRICT=0 -DENABLE_UNIT_TESTS=0"
 hostmakedepends="python3"
-makedepends="bzrtp-devel ffmpeg-devel glew-devel libXv-devel libsrtp-devel
+makedepends="bzrtp-devel ffmpeg4-devel glew-devel libXv-devel libsrtp-devel
  libupnp-devel libvpx-devel mbedtls-devel opus-devel ortp-devel pulseaudio-devel
  libtheora-devel speex-devel v4l-utils-devel bcg729-devel bcmatroska2-devel libgsm-devel
  zxing-cpp-devel"

From 5d88fccb1df8cf6982b5961fb9bc5be7aab27b58 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 046/109] mgba: revbump for ffmpeg6

---
 srcpkgs/mgba/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mgba/template b/srcpkgs/mgba/template
index 6cd65650312543..93401adb618bd8 100644
--- a/srcpkgs/mgba/template
+++ b/srcpkgs/mgba/template
@@ -1,7 +1,7 @@
 # Template file for 'mgba'
 pkgname=mgba
 version=0.10.3
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake desktop-file-utils"
 makedepends="SDL2-devel ffmpeg-devel libedit-devel libepoxy-devel libmagick-devel

From 5ff59ea4391531222e558e0ee09bdabbaf4be134 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 047/109] mlt: revbump for ffmpeg4

---
 srcpkgs/mlt/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mlt/template b/srcpkgs/mlt/template
index 73e3915aaab9ac..d7ed4c4b30a868 100644
--- a/srcpkgs/mlt/template
+++ b/srcpkgs/mlt/template
@@ -1,14 +1,14 @@
 # Template file for 'mlt'
 pkgname=mlt
 version=6.26.1
-revision=3
+revision=4
 build_style=configure
 configure_args="--prefix=/usr --libdir=/usr/lib$XBPS_TARGET_WORDSIZE
  --enable-gpl --enable-gpl3 --disable-swfdec --without-kde
  --swig-languages=python"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which"
 # XXX: movit vid.stab
-makedepends="alsa-lib-devel ffmpeg-devel gtk+-devel jack-devel ladspa-sdk
+makedepends="alsa-lib-devel ffmpeg4-devel gtk+-devel jack-devel ladspa-sdk
  libexif-devel libsamplerate-devel libxml2-devel sox-devel SDL_image-devel
  fftw-devel frei0r-plugins python3-devel pulseaudio-devel movit-devel
  libvidstab-devel"

From 201986f116c74cfdb62164f89f970299720237f9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 048/109] moc: revbump for ffmpeg4

---
 srcpkgs/moc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/moc/template b/srcpkgs/moc/template
index 3a04932c8f1e61..838755f88db09e 100644
--- a/srcpkgs/moc/template
+++ b/srcpkgs/moc/template
@@ -1,10 +1,10 @@
 # Template file for 'moc'
 pkgname=moc
 version=2.5.2
-revision=7
+revision=8
 build_style=gnu-configure
 hostmakedepends="pkg-config"
-makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg-devel
+makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg4-devel
  jack-devel alsa-lib-devel libltdl-devel libflac-devel libvorbis-devel
  libmad-devel libmpcdec-devel libmodplug-devel libid3tag-devel faad2-devel
  taglib-devel libsndfile-devel wavpack-devel speex-devel libsamplerate-devel

From 8d773268b6fa1ba0d560beeb056d6e69226bc266 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 049/109] motion: revbump for ffmpeg6

---
 srcpkgs/motion/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/motion/template b/srcpkgs/motion/template
index 607ebeb3c7b242..bf63a91d9764f6 100644
--- a/srcpkgs/motion/template
+++ b/srcpkgs/motion/template
@@ -1,7 +1,7 @@
 # Template file for 'motion'
 pkgname=motion
 version=4.6.0
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake pkg-config gettext-devel tar"
 makedepends="ffmpeg-devel libmicrohttpd-devel v4l-utils-devel gettext-devel"

From 5c294b19751ae75f4d64a7ed70d6e51b82c3fbd4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 050/109] olive: revbump for ffmpeg4

---
 srcpkgs/olive/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/olive/template b/srcpkgs/olive/template
index 12a46936c99003..5c2917b9c51245 100644
--- a/srcpkgs/olive/template
+++ b/srcpkgs/olive/template
@@ -1,10 +1,10 @@
 # Template file for 'olive'
 pkgname=olive
 version=0.1.2
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools pkg-config"
-makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg-devel frei0r-plugins"
+makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg4-devel frei0r-plugins"
 short_desc="Non-linear video editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"

From 433959e40eb2936355cd5b8d8b904cfb801095c4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 051/109] opentoonz: revbump for ffmpeg6

---
 srcpkgs/opentoonz/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/opentoonz/template b/srcpkgs/opentoonz/template
index ee9f7603f55fd8..3e81834ca0eddf 100644
--- a/srcpkgs/opentoonz/template
+++ b/srcpkgs/opentoonz/template
@@ -1,7 +1,7 @@
 # Template file for 'opentoonz'
 pkgname=opentoonz
 version=1.6.0
-revision=2
+revision=3
 build_wrksrc="toonz/sources"
 build_style=cmake
 make_cmd=make

From 2b11220e06eaa377a5e65af72b1a6afc5c5c843c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 052/109] pianobar: revbump for ffmpeg6

---
 srcpkgs/pianobar/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pianobar/template b/srcpkgs/pianobar/template
index e3febb821a4510..1e3dc1bf9308ee 100644
--- a/srcpkgs/pianobar/template
+++ b/srcpkgs/pianobar/template
@@ -1,7 +1,7 @@
 # Template file for 'pianobar'
 pkgname=pianobar
 version=2022.04.01
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="V=1"
 hostmakedepends="pkg-config"

From 6142e3276c52bd65f330e5fefd8995e5eba70932 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 053/109] ppsspp: revbump for ffmpeg6

---
 srcpkgs/ppsspp/patches/ffmpeg6.patch | 15 +++++++++++++++
 srcpkgs/ppsspp/template              |  3 +--
 2 files changed, 16 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/ppsspp/patches/ffmpeg6.patch

diff --git a/srcpkgs/ppsspp/patches/ffmpeg6.patch b/srcpkgs/ppsspp/patches/ffmpeg6.patch
new file mode 100644
index 00000000000000..5803c7bf227309
--- /dev/null
+++ b/srcpkgs/ppsspp/patches/ffmpeg6.patch
@@ -0,0 +1,15 @@
+--- a/Core/HW/SimpleAudioDec.cpp	2024-02-04 08:08:02.000000000 -0500
++++ b/Core/HW/SimpleAudioDec.cpp	2024-02-15 14:48:27.114362051 -0500
+@@ -81,7 +81,11 @@
+ 		return;
+ 	}
+ 	// Find decoder
++#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(58, 18, 100)
+ 	codec_ = avcodec_find_decoder((AVCodecID)audioCodecId);
++#else // this is a macro to const in the header
++	codec_ = (AVCodec*)avcodec_find_decoder((AVCodecID)audioCodecId);
++#endif
+ 	if (!codec_) {
+ 		// Eh, we shouldn't even have managed to compile. But meh.
+ 		ERROR_LOG(ME, "This version of FFMPEG does not support AV_CODEC_ctx for audio (%s). Update your submodule.", GetCodecName(audioType));
+
diff --git a/srcpkgs/ppsspp/template b/srcpkgs/ppsspp/template
index 2238a7601c0af8..1fda55268a2d39 100644
--- a/srcpkgs/ppsspp/template
+++ b/srcpkgs/ppsspp/template
@@ -1,7 +1,7 @@
 # Template file for 'ppsspp'
 pkgname=ppsspp
 version=1.17.1
-revision=1
+revision=2
 _glslang_commit=b34f619e1c85810dcb3c578107d2e48ba4ee2b37
 _SPIRV_Cross_commit=4212eef67ed0ca048cb726a6767185504e7695e5
 _armips_commit=a8d71f0f279eb0d30ecf6af51473b66ae0cf8e8d
@@ -91,7 +91,6 @@ post_configure() {
 }
 
 do_install() {
-	vlicense LICENSE.TXT
 	vinstall icons/icon.svg 644 usr/share/pixmaps ppsspp.svg
 	vinstall Qt/PPSSPP.desktop 644 usr/share/applications
 	vbin build/PPSSPPHeadless ppsspp-headless

From 2602f28a2312ea6d5e607ef327fbf1ec3d841682 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 054/109] pqiv: revbump for ffmpeg6

---
 srcpkgs/pqiv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pqiv/template b/srcpkgs/pqiv/template
index f9f7751196d4ee..0d50777e56a2d8 100644
--- a/srcpkgs/pqiv/template
+++ b/srcpkgs/pqiv/template
@@ -1,7 +1,7 @@
 # Template file for 'pqiv'
 pkgname=pqiv
 version=2.13.1
-revision=1
+revision=2
 build_style=gnu-makefile
 hostmakedepends="pkg-config"
 makedepends="glib-devel gtk+3-devel $(vopt_if ffmpeg ffmpeg-devel)

From 23067ddcc282e05e8af5a8e16155a19a52884528 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 055/109] qmmp: revbump for ffmpeg6

---
 srcpkgs/qmmp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qmmp/template b/srcpkgs/qmmp/template
index 53781ea3bc28ad..2da07f1e87eac0 100644
--- a/srcpkgs/qmmp/template
+++ b/srcpkgs/qmmp/template
@@ -1,7 +1,7 @@
 # Template file for 'qmmp'
 pkgname=qmmp
 version=1.6.1
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DUSE_HAL:BOOL=FALSE -DQMMP_DEFAULT_UI:STRING=simple"
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From 1ed23362d899f0f9bad88dfbf627ba537301ce4c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 14 Dec 2023 13:28:10 -0500
Subject: [PATCH 056/109] qt6-pdf: revbump for ffmpeg6

---
 srcpkgs/qt6-pdf/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-pdf/template b/srcpkgs/qt6-pdf/template
index ecda84afac1310..531b4e1d4fe84d 100644
--- a/srcpkgs/qt6-pdf/template
+++ b/srcpkgs/qt6-pdf/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-pdf'
 pkgname=qt6-pdf
 version=6.6.0
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DQT_FEATURE_qtpdf_build=ON
  -DQT_FEATURE_qtpdf_widgets_build=ON

From bcfb52b0c9223dcf5de13b8ee6f2fd57843c447c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 057/109] qt5-webengine: revbump for ffmpeg6

---
 .../chromium-media-filters-cpp14.patch        |  11 ++
 srcpkgs/qt5-webengine/patches/ffmpeg5.patch   | 179 ++++++++++++++++++
 .../qtwebengine-fix-ffmpeg5-build.patch       |  14 ++
 srcpkgs/qt5-webengine/template                |   4 +-
 4 files changed, 206 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/ffmpeg5.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch

diff --git a/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
new file mode 100644
index 00000000000000..04adc540f2cbc0
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
@@ -0,0 +1,11 @@
+--- a/src/3rdparty/chromium/media/filters/BUILD.gn	2023-02-27 13:32:59.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/BUILD.gn	2023-04-02 17:21:39.204066384 -0400
+@@ -96,6 +96,8 @@
+     "//ui/gfx/geometry:geometry",
+   ]
+ 
++  cflags_cc = [ "-std=c++14" ]
++
+   libs = []
+ 
+   if (proprietary_codecs) {
diff --git a/srcpkgs/qt5-webengine/patches/ffmpeg5.patch b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..ac55e1634423a9
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
@@ -0,0 +1,179 @@
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:57.732547446 -0400
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:09.486478995 -0400
+@@ -57,6 +57,8 @@
+ 
+ namespace {
+ 
++constexpr int64_t kRelativeTsBase = static_cast<int64_t>(0x7ffeffffffffffff);
++
+ void SetAVStreamDiscard(AVStream* stream, AVDiscard discard) {
+   DCHECK(stream);
+   stream->discard = discard;
+@@ -90,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+   if (stream->start_time != kNoFFmpegTimestamp)
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (stream->first_dts != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, stream->first_dts);
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -408,11 +398,11 @@
+   scoped_refptr<DecoderBuffer> buffer;
+ 
+   if (type() == DemuxerStream::TEXT) {
+-    int id_size = 0;
++    size_t id_size = 0;
+     uint8_t* id_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
+ 
+-    int settings_size = 0;
++    size_t settings_size = 0;
+     uint8_t* settings_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
+ 
+@@ -424,7 +414,7 @@
+     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
+                                      side_data.data(), side_data.size());
+   } else {
+-    int side_data_size = 0;
++    size_t side_data_size = 0;
+     uint8_t* side_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
+ 
+@@ -485,7 +475,7 @@
+                                        packet->size - data_offset);
+     }
+ 
+-    int skip_samples_size = 0;
++    size_t skip_samples_size = 0;
+     const uint32_t* skip_samples_ptr =
+         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
+             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
+@@ -1587,6 +1577,8 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++      continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+       lowest_start_time_stream = stream.get();
+@@ -1604,6 +1596,8 @@
+     if (stream && stream->type() == DemuxerStream::VIDEO &&
+         stream->IsEnabled()) {
+       video_stream = stream.get();
++      if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++        continue;
+       if (video_stream->start_time() <= seek_time) {
+         return video_stream;
+       }
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h qtwebengine-5.15.10/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h
+--- a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-07-11 22:12:47.917192788 -0500
+@@ -29,6 +29,7 @@ extern "C" {
+ #include <libavformat/avformat.h>
+ #include <libavformat/avio.h>
+ #include <libavutil/avutil.h>
++#include <libavutil/channel_layout.h>
+ #include <libavutil/imgutils.h>
+ #include <libavutil/log.h>
+ #include <libavutil/mastering_display_metadata.h>
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/audio_file_reader.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/audio_file_reader.cc
+--- a/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -85,7 +85,7 @@ bool AudioFileReader::OpenDemuxer() {
+ }
+ 
+ bool AudioFileReader::OpenDecoder() {
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (codec) {
+     // MP3 decodes to S16P which we don't support, tell it to use S16 instead.
+     if (codec_context_->sample_fmt == AV_SAMPLE_FMT_S16P)
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -329,7 +329,7 @@ bool FFmpegAudioDecoder::ConfigureDecode
+     }
+   }
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec ||
+       avcodec_open2(codec_context_.get(), codec, &codec_options) < 0) {
+     DLOG(ERROR) << "Could not initialize audio decoder: "
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -59,7 +59,6 @@ static int64_t AVIOSeekOperation(void* o
+ }
+ 
+ void FFmpegGlue::InitializeFFmpeg() {
+-  av_register_all();
+ }
+ 
+ static void LogContainer(bool is_local_file,
+@@ -95,9 +94,6 @@ FFmpegGlue::FFmpegGlue(FFmpegURLProtocol
+   // Enable fast, but inaccurate seeks for MP3.
+   format_context_->flags |= AVFMT_FLAG_FAST_SEEK;
+ 
+-  // Ensures we can read out various metadata bits like vp8 alpha.
+-  format_context_->flags |= AVFMT_FLAG_KEEP_SIDE_DATA;
+-
+   // Ensures format parsing errors will bail out. From an audit on 11/2017, all
+   // instances were real failures. Solves bugs like http://crbug.com/710791.
+   format_context_->error_recognition |= AV_EF_EXPLODE;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -391,7 +391,7 @@ bool FFmpegVideoDecoder::ConfigureDecode
+   if (decode_nalus_)
+     codec_context_->flags2 |= AV_CODEC_FLAG2_CHUNKS;
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
+     ReleaseFFmpegResources();
+     return false;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/media_file_checker.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/media_file_checker.cc
+--- a/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -68,7 +68,7 @@ bool MediaFileChecker::Start(base::TimeD
+       auto context = AVStreamToAVCodecContext(format_context->streams[i]);
+       if (!context)
+         continue;
+-      AVCodec* codec = avcodec_find_decoder(cp->codec_id);
++      const AVCodec* codec = avcodec_find_decoder(cp->codec_id);
+       if (codec && avcodec_open2(context.get(), codec, nullptr) >= 0) {
+         auto loop = std::make_unique<FFmpegDecodingLoop>(context.get());
+         stream_contexts[i] = {std::move(context), std::move(loop)};
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc qtwebengine-5.15.10/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc
+--- a/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -203,7 +203,7 @@ int32_t H264DecoderImpl::InitDecode(cons
+   // a pointer |this|.
+   av_context_->opaque = this;
+ 
+-  AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
+   if (!codec) {
+     // This is an indication that FFmpeg has not been initialized or it has not
+     // been compiled/initialized with the correct set of codecs.
diff --git a/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch b/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch
new file mode 100644
index 00000000000000..bc24d5b9a29cb5
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch
@@ -0,0 +1,14 @@
+--- a/src/buildtools/configure.json	2023-12-09 11:06:01.503058569 -0500
++++ b/src/buildtools/configure.json	2023-12-09 11:06:14.982361345 -0500
+@@ -779,11 +779,6 @@
+             "type": "warning",
+             "condition": "config.ios && config.simulator && config.device && features.build-qtpdf",
+             "message": "Building fat libray with device and simulator architectures will disable NEON."
+-        },
+-        {
+-            "type": "fatal",
+-            "condition": "features.webengine-system-ffmpeg && !libs.webengine-ffmpeg-support",
+-            "message": "Unmodified ffmpeg >= 5.0 is not supported. Please configure with -qt-webengine-ffmpeg."
+         }
+     ],
+     "summary": [
diff --git a/srcpkgs/qt5-webengine/template b/srcpkgs/qt5-webengine/template
index 8d2df1b5175bad..1687a77eb8a2f5 100644
--- a/srcpkgs/qt5-webengine/template
+++ b/srcpkgs/qt5-webengine/template
@@ -1,14 +1,14 @@
 # Template file for 'qt5-webengine'
 pkgname=qt5-webengine
 version=5.15.16
-revision=1
+revision=2
 _version="${version}-lts"
 _chromium_commit=207c2ac45ca3386d153770c6b0d2ea2ec21ca880
 archs="x86_64* i686* armv[67]* ppc64* aarch64*"
 create_wrksrc=yes
 build_style=qmake
 configure_args="--
- -webengine-icu -webengine-ffmpeg -webengine-opus -webengine-webp
+ -webengine-icu -system-ffmpeg -webengine-opus -webengine-webp
  -webengine-pepper-plugins -webengine-printing-and-pdf -webengine-proprietary-codecs
  -webengine-pulseaudio -webengine-spellchecker -webengine-webrtc -webengine-geolocation
  -webengine-kerberos -no-webengine-embedded-build $(vopt_if sndio '' '-no')-webengine-sndio

From 1262bcc7793662e7f2a7b9fa5d8fa88059d1efca Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 058/109] qt5: revbump for ffmpeg6

---
 srcpkgs/qt5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5/template b/srcpkgs/qt5/template
index 3efb7e42d5fd3f..27f6d5388cd15c 100644
--- a/srcpkgs/qt5/template
+++ b/srcpkgs/qt5/template
@@ -3,9 +3,9 @@
 # revbump libqtxdg after bumping patch version
 pkgname=qt5
 version=5.15.11+20231124
+revision=3
 # commit 4765fa1df7a837db9c1f89c4da0dd76b74bb5fab
 # base repo: https://invent.kde.org/qt/qt/qt5
-revision=2
 build_style=meta
 hostmakedepends="cmake clang17 flex perl glib-devel pkg-config
  python3 re2c ruby which"

From b7f26f0c9e68c9c61a65059c0e811ce1e281f0f4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 059/109] qtav: revbump for ffmpeg4

---
 srcpkgs/qtav/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtav/template b/srcpkgs/qtav/template
index 775d5a139a9efa..aa69e213c984b0 100644
--- a/srcpkgs/qtav/template
+++ b/srcpkgs/qtav/template
@@ -1,10 +1,10 @@
 # Template file for 'qtav'
 pkgname=qtav
 version=1.13.0
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel libass-devel libopenal-devel
+makedepends="ffmpeg4-devel libass-devel libopenal-devel
  libva-glx-devel libXv-devel pulseaudio-devel
  qt5-declarative-devel qt5-svg-devel
  qt5-quickcontrols"

From 9e17b9ed54df86aa3648641255e3657a3beb5b84 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 060/109] retroarch: revbump for ffmpeg6

---
 srcpkgs/retroarch/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroarch/template b/srcpkgs/retroarch/template
index cb3125c5dbf1ae..c65c26f7bf0332 100644
--- a/srcpkgs/retroarch/template
+++ b/srcpkgs/retroarch/template
@@ -1,7 +1,7 @@
 # Template file for 'retroarch'
 pkgname=retroarch
 version=1.16.0.3
-revision=3
+revision=4
 build_style=configure
 configure_args="--prefix=/usr --sysconfdir=/etc --enable-networking
  --enable-udev --disable-builtinflac --disable-builtinglslang

From 0c0833acbca2a1595a0b87465d6f3197b5044a7c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 061/109] scrcpy: revbump for ffmpeg6

---
 srcpkgs/scrcpy/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/scrcpy/template b/srcpkgs/scrcpy/template
index d04de770dc1913..5218fa01f8ce1f 100644
--- a/srcpkgs/scrcpy/template
+++ b/srcpkgs/scrcpy/template
@@ -1,7 +1,7 @@
 # Template file for 'scrcpy'
 pkgname=scrcpy
 version=2.3.1
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcompile_server=false
  -Dprebuilt_server=/usr/share/scrcpy/scrcpy-server-v${version}"

From 6fb96bd6c1150fad3e43ea8200ff496589423c47 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 17 Oct 2023 08:54:11 -0400
Subject: [PATCH 062/109] New package: spex-x replaces spek-alternative for
 ffmpeg6

---
 srcpkgs/spek-alternative                      |  1 +
 srcpkgs/spek-x/patches/musl.patch             |  7 ++++++
 srcpkgs/{spek-alternative => spek-x}/template | 22 ++++++++++++-------
 3 files changed, 22 insertions(+), 8 deletions(-)
 create mode 120000 srcpkgs/spek-alternative
 create mode 100644 srcpkgs/spek-x/patches/musl.patch
 rename srcpkgs/{spek-alternative => spek-x}/template (52%)

diff --git a/srcpkgs/spek-alternative b/srcpkgs/spek-alternative
new file mode 120000
index 00000000000000..76648236da7017
--- /dev/null
+++ b/srcpkgs/spek-alternative
@@ -0,0 +1 @@
+spek-x
\ No newline at end of file
diff --git a/srcpkgs/spek-x/patches/musl.patch b/srcpkgs/spek-x/patches/musl.patch
new file mode 100644
index 00000000000000..662f45936febc6
--- /dev/null
+++ b/srcpkgs/spek-x/patches/musl.patch
@@ -0,0 +1,7 @@
+--- a/tests/perf.cc	2024-03-09 17:13:49.086603418 -0500
++++ b/tests/perf.cc	2024-03-09 17:13:59.453603753 -0500
+@@ -1,3 +1,4 @@
++#include <cstdint>
+ #include <cstdlib>
+ #include <iostream>
+ #include <fstream>
diff --git a/srcpkgs/spek-alternative/template b/srcpkgs/spek-x/template
similarity index 52%
rename from srcpkgs/spek-alternative/template
rename to srcpkgs/spek-x/template
index d7b55c776b1d43..3ded6c2c323e4f 100644
--- a/srcpkgs/spek-alternative/template
+++ b/srcpkgs/spek-x/template
@@ -1,18 +1,18 @@
-# Template file for 'spek-alternative'
-pkgname=spek-alternative
-version=0.8.2.3
-revision=2
+# Template file for 'spek-x'
+pkgname=spek-x
+version=0.9.3
+revision=1
 build_style=gnu-configure
 hostmakedepends="automake gettext-devel intltool libtool pkg-config
  wxWidgets-common wxWidgets-gtk3-devel"
 makedepends="ffmpeg-devel wxWidgets-gtk3-devel"
 depends="ffmpeg"
 short_desc="Acoustic spectrum analyser"
-maintainer="Kartik Singh <kartik.ynwa@gmail.com>"
+maintainer="zlice <zlice555@gmail.com>"
 license="GPL-3.0-or-later"
-homepage="https://github.com/withmorten/spek-alternative"
-distfiles="https://github.com/withmorten/spek-alternative/archive/${version}.tar.gz"
-checksum="007ba4b84a310b078e378aa84c8e80783db5821437a757a488c3ecec377e6b2a"
+homepage="https://github.com/MikeWang000000/spek-x"
+distfiles="https://github.com/MikeWang000000/spek-x/archive/v${version}.tar.gz"
+checksum="7f4b109903333cdd310ab2b9176f0dc49a565891376e281a233d342cedf90ef7"
 
 CXXFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
 
@@ -22,3 +22,9 @@ export WX_CONFIG_NAME="wx-config-gtk3"
 pre_configure() {
 	NOCONFIGURE=1 ./autogen.sh
 }
+
+spek-alternative_package() {
+	depends="spek-x"
+	short_desc+=" - transitional dummy package"
+	build_style=meta
+}

From b5507f63b9f8c9392fbbdad79e33244759d65908 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 063/109] ssr: revbump for ffmpeg6

---
 .../0001-Fix-build-with-ffmpeg-5.0.patch      | 241 ++++++++++++++++++
 srcpkgs/ssr/template                          |   2 +-
 2 files changed, 242 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ssr/patches/0001-Fix-build-with-ffmpeg-5.0.patch

diff --git a/srcpkgs/ssr/patches/0001-Fix-build-with-ffmpeg-5.0.patch b/srcpkgs/ssr/patches/0001-Fix-build-with-ffmpeg-5.0.patch
new file mode 100644
index 00000000000000..4c069b5a9fc464
--- /dev/null
+++ b/srcpkgs/ssr/patches/0001-Fix-build-with-ffmpeg-5.0.patch
@@ -0,0 +1,241 @@
+From f4cbde38021d9330dc73d2e3dfa8a70da3ff5721 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Bernhard=20Rosenkr=C3=A4nzer?= <bero@lindev.ch>
+Date: Sun, 16 Jan 2022 02:40:04 +0100
+Subject: [PATCH] Fix build with ffmpeg 5.0
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Adapt to ffmpeg 5.0 requiring more const-ness for AVCodec.
+
+Signed-off-by: Bernhard Rosenkränzer <bero@lindev.ch>
+---
+ src/AV/Output/AudioEncoder.cpp |  6 +++---
+ src/AV/Output/AudioEncoder.h   |  4 ++--
+ src/AV/Output/BaseEncoder.cpp  |  4 ++--
+ src/AV/Output/BaseEncoder.h    |  4 ++--
+ src/AV/Output/Muxer.cpp        | 12 ++++++------
+ src/AV/Output/Muxer.h          |  4 ++--
+ src/AV/Output/VideoEncoder.cpp |  6 +++---
+ src/AV/Output/VideoEncoder.h   |  4 ++--
+ 8 files changed, 22 insertions(+), 22 deletions(-)
+
+diff --git a/src/AV/Output/AudioEncoder.cpp b/src/AV/Output/AudioEncoder.cpp
+index 34d015c..cefc2e0 100644
+--- a/src/AV/Output/AudioEncoder.cpp
++++ b/src/AV/Output/AudioEncoder.cpp
+@@ -34,7 +34,7 @@ const std::vector<AudioEncoder::SampleFormatData> AudioEncoder::SUPPORTED_SAMPLE
+ 
+ const unsigned int AudioEncoder::DEFAULT_FRAME_SAMPLES = 1024;
+ 
+-AudioEncoder::AudioEncoder(Muxer* muxer, AVStream* stream, AVCodecContext *codec_context, AVCodec* codec, AVDictionary** options)
++AudioEncoder::AudioEncoder(Muxer* muxer, AVStream* stream, AVCodecContext *codec_context, const AVCodec* codec, AVDictionary** options)
+ 	: BaseEncoder(muxer, stream, codec_context, codec, options) {
+ 
+ #if !SSR_USE_AVCODEC_ENCODE_AUDIO2
+@@ -77,7 +77,7 @@ unsigned int AudioEncoder::GetSampleRate() {
+ }
+ 
+ bool AudioEncoder::AVCodecIsSupported(const QString& codec_name) {
+-	AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
++	const AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
+ 	if(codec == NULL)
+ 		return false;
+ 	if(!av_codec_is_encoder(codec))
+@@ -93,7 +93,7 @@ bool AudioEncoder::AVCodecIsSupported(const QString& codec_name) {
+ 	return false;
+ }
+ 
+-void AudioEncoder::PrepareStream(AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
++void AudioEncoder::PrepareStream(AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
+ 								 unsigned int bit_rate, unsigned int channels, unsigned int sample_rate) {
+ 
+ 	if(channels == 0) {
+diff --git a/src/AV/Output/AudioEncoder.h b/src/AV/Output/AudioEncoder.h
+index c93278c..ae9c82e 100644
+--- a/src/AV/Output/AudioEncoder.h
++++ b/src/AV/Output/AudioEncoder.h
+@@ -40,7 +40,7 @@ private:
+ #endif
+ 
+ public:
+-	AudioEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options);
++	AudioEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options);
+ 	~AudioEncoder();
+ 
+ 	// Returns the required frame size, i.e. the number of samples (for each channel).
+@@ -57,7 +57,7 @@ public:
+ 
+ public:
+ 	static bool AVCodecIsSupported(const QString& codec_name);
+-	static void PrepareStream(AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
++	static void PrepareStream(AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
+ 							  unsigned int bit_rate, unsigned int channels, unsigned int sample_rate);
+ 
+ private:
+diff --git a/src/AV/Output/BaseEncoder.cpp b/src/AV/Output/BaseEncoder.cpp
+index 7c01ef3..4780aaf 100644
+--- a/src/AV/Output/BaseEncoder.cpp
++++ b/src/AV/Output/BaseEncoder.cpp
+@@ -42,7 +42,7 @@ double ParseCodecOptionDouble(const QString& key, const QString& value, double m
+ 	return clamp(value_double, min, max) * multiply;
+ }
+ 
+-BaseEncoder::BaseEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options) {
++BaseEncoder::BaseEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options) {
+ 
+ 	m_muxer = muxer;
+ 	m_stream = stream;
+@@ -157,7 +157,7 @@ void BaseEncoder::IncrementPacketCounter() {
+ 	++lock->m_total_packets;
+ }
+ 
+-void BaseEncoder::Init(AVCodec* codec, AVDictionary** options) {
++void BaseEncoder::Init(const AVCodec* codec, AVDictionary** options) {
+ 
+ 	// open codec
+ 	if(avcodec_open2(m_codec_context, codec, options) < 0) {
+diff --git a/src/AV/Output/BaseEncoder.h b/src/AV/Output/BaseEncoder.h
+index 3d92f29..7f02bbd 100644
+--- a/src/AV/Output/BaseEncoder.h
++++ b/src/AV/Output/BaseEncoder.h
+@@ -51,7 +51,7 @@ private:
+ 	std::atomic<bool> m_should_stop, m_should_finish, m_is_done, m_error_occurred;
+ 
+ protected:
+-	BaseEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options);
++	BaseEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options);
+ 
+ public:
+ 	virtual ~BaseEncoder(); // encoders will be deleted by Muxer, don't delete them yourself!
+@@ -117,7 +117,7 @@ protected:
+ 	void IncrementPacketCounter();
+ 
+ private:
+-	void Init(AVCodec* codec, AVDictionary** options);
++	void Init(const AVCodec* codec, AVDictionary** options);
+ 	void Free();
+ 
+ 	void EncoderThread();
+diff --git a/src/AV/Output/Muxer.cpp b/src/AV/Output/Muxer.cpp
+index ad58380..14650b0 100644
+--- a/src/AV/Output/Muxer.cpp
++++ b/src/AV/Output/Muxer.cpp
+@@ -87,7 +87,7 @@ Muxer::~Muxer() {
+ 
+ VideoEncoder* Muxer::AddVideoEncoder(const QString& codec_name, const std::vector<std::pair<QString, QString> >& codec_options,
+ 									 unsigned int bit_rate, unsigned int width, unsigned int height, unsigned int frame_rate) {
+-	AVCodec *codec = FindCodec(codec_name);
++	const AVCodec *codec = FindCodec(codec_name);
+ 	AVCodecContext *codec_context = NULL;
+ 	AVStream *stream = AddStream(codec, &codec_context);
+ 	VideoEncoder *encoder;
+@@ -111,7 +111,7 @@ VideoEncoder* Muxer::AddVideoEncoder(const QString& codec_name, const std::vecto
+ 
+ AudioEncoder* Muxer::AddAudioEncoder(const QString& codec_name, const std::vector<std::pair<QString, QString> >& codec_options,
+ 									 unsigned int bit_rate, unsigned int channels, unsigned int sample_rate) {
+-	AVCodec *codec = FindCodec(codec_name);
++	const AVCodec *codec = FindCodec(codec_name);
+ 	AVCodecContext *codec_context = NULL;
+ 	AVStream *stream = AddStream(codec, &codec_context);
+ 	AudioEncoder *encoder;
+@@ -194,7 +194,7 @@ unsigned int Muxer::GetQueuedPacketCount(unsigned int stream_index) {
+ void Muxer::Init() {
+ 
+ 	// get the format we want (this is just a pointer, we don't have to free this)
+-	AVOutputFormat *format = av_guess_format(m_container_name.toUtf8().constData(), NULL, NULL);
++	const AVOutputFormat *format = av_guess_format(m_container_name.toUtf8().constData(), NULL, NULL);
+ 	if(format == NULL) {
+ 		Logger::LogError("[Muxer::Init] " + Logger::tr("Error: Can't find chosen output format!"));
+ 		throw LibavException();
+@@ -261,8 +261,8 @@ void Muxer::Free() {
+ 	}
+ }
+ 
+-AVCodec* Muxer::FindCodec(const QString& codec_name) {
+-	AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
++const AVCodec* Muxer::FindCodec(const QString& codec_name) {
++	const AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
+ 	if(codec == NULL) {
+ 		Logger::LogError("[Muxer::FindCodec] " + Logger::tr("Error: Can't find codec!"));
+ 		throw LibavException();
+@@ -270,7 +270,7 @@ AVCodec* Muxer::FindCodec(const QString& codec_name) {
+ 	return codec;
+ }
+ 
+-AVStream* Muxer::AddStream(AVCodec* codec, AVCodecContext** codec_context) {
++AVStream* Muxer::AddStream(const AVCodec* codec, AVCodecContext** codec_context) {
+ 	assert(!m_started);
+ 	assert(m_format_context->nb_streams < MUXER_MAX_STREAMS);
+ 
+diff --git a/src/AV/Output/Muxer.h b/src/AV/Output/Muxer.h
+index d72347d..b104bcb 100644
+--- a/src/AV/Output/Muxer.h
++++ b/src/AV/Output/Muxer.h
+@@ -114,8 +114,8 @@ private:
+ 	void Init();
+ 	void Free();
+ 
+-	AVCodec* FindCodec(const QString& codec_name);
+-	AVStream* AddStream(AVCodec* codec, AVCodecContext** codec_context);
++	const AVCodec* FindCodec(const QString& codec_name);
++	AVStream* AddStream(const AVCodec* codec, AVCodecContext** codec_context);
+ 
+ 	void MuxerThread();
+ 
+diff --git a/src/AV/Output/VideoEncoder.cpp b/src/AV/Output/VideoEncoder.cpp
+index 8087e8e..fc8b5d1 100644
+--- a/src/AV/Output/VideoEncoder.cpp
++++ b/src/AV/Output/VideoEncoder.cpp
+@@ -34,7 +34,7 @@ const std::vector<VideoEncoder::PixelFormatData> VideoEncoder::SUPPORTED_PIXEL_F
+ 	{"rgb", AV_PIX_FMT_RGB24, false},
+ };
+ 
+-VideoEncoder::VideoEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options)
++VideoEncoder::VideoEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options)
+ 	: BaseEncoder(muxer, stream, codec_context, codec, options) {
+ 
+ #if !SSR_USE_AVCODEC_ENCODE_VIDEO2
+@@ -95,7 +95,7 @@ unsigned int VideoEncoder::GetFrameRate() {
+ }
+ 
+ bool VideoEncoder::AVCodecIsSupported(const QString& codec_name) {
+-	AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
++	const AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
+ 	if(codec == NULL)
+ 		return false;
+ 	if(!av_codec_is_encoder(codec))
+@@ -111,7 +111,7 @@ bool VideoEncoder::AVCodecIsSupported(const QString& codec_name) {
+ 	return false;
+ }
+ 
+-void VideoEncoder::PrepareStream(AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
++void VideoEncoder::PrepareStream(AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
+ 								 unsigned int bit_rate, unsigned int width, unsigned int height, unsigned int frame_rate) {
+ 
+ 	if(width == 0 || height == 0) {
+diff --git a/src/AV/Output/VideoEncoder.h b/src/AV/Output/VideoEncoder.h
+index cb7ca27..68d872e 100644
+--- a/src/AV/Output/VideoEncoder.h
++++ b/src/AV/Output/VideoEncoder.h
+@@ -40,7 +40,7 @@ private:
+ #endif
+ 
+ public:
+-	VideoEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options);
++	VideoEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options);
+ 	~VideoEncoder();
+ 
+ 	// Returns the required pixel format.
+@@ -55,7 +55,7 @@ public:
+ 
+ public:
+ 	static bool AVCodecIsSupported(const QString& codec_name);
+-	static void PrepareStream(AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
++	static void PrepareStream(AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
+ 							  unsigned int bit_rate, unsigned int width, unsigned int height, unsigned int frame_rate);
+ 
+ private:
+-- 
+2.43.0
+
diff --git a/srcpkgs/ssr/template b/srcpkgs/ssr/template
index 3097754e3cbe54..e3c4261f1f5a64 100644
--- a/srcpkgs/ssr/template
+++ b/srcpkgs/ssr/template
@@ -1,7 +1,7 @@
 # Template file for 'ssr'
 pkgname=ssr
 version=0.4.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DWITH_QT5=ON"
 hostmakedepends="pkg-config"

From a98132ecb38b214e66dae14c7238b9e6903e5795 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 064/109] synfig: revbump for ffmpeg6 and mlt7

---
 srcpkgs/synfig/patches/ffmpeg6.patch | 71 ++++++++++++++++++++++++++++
 srcpkgs/synfig/template              |  6 +--
 2 files changed, 74 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/synfig/patches/ffmpeg6.patch

diff --git a/srcpkgs/synfig/patches/ffmpeg6.patch b/srcpkgs/synfig/patches/ffmpeg6.patch
new file mode 100644
index 00000000000000..10780b42782f4b
--- /dev/null
+++ b/srcpkgs/synfig/patches/ffmpeg6.patch
@@ -0,0 +1,71 @@
+--- a/src/modules/mod_libavcodec/trgt_av.cpp	2022-10-25 09:14:12.000000000 -0400
++++ b/src/modules/mod_libavcodec/trgt_av.cpp	2023-05-05 21:34:17.899194559 -0400
+@@ -38,6 +41,7 @@
+ extern "C"
+ {
+ #ifdef HAVE_LIBAVFORMAT_AVFORMAT_H
++#	include <libavcodec/avcodec.h>
+ #	include <libavformat/avformat.h>
+ #elif defined(HAVE_AVFORMAT_H)
+ #	include <avformat.h>
+@@ -155,11 +156,11 @@
+     }
+ 
+ 	bool open_video_stream() {
+-		if (avcodec_open2(video_context, NULL, NULL) < 0) {
++		if (avcodec_open2(video_context, nullptr, nullptr) < 0) {
+ 			synfig::error("Target_LibAVCodec: could not open video codec");
+ 			// seems the calling of avcodec_free_context after error will cause crash
+ 			// so just forget about this context
+-			video_context = NULL;
++			video_context = nullptr;
+ 			close();
+ 			return false;
+         }
+@@ -234,15 +235,21 @@
+ 		close();
+ 
+ 		if (!av_registered) {
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 			av_register_all();
++#endif
+ 			av_registered = true;
+ 		}
+ 
+ 		// guess format
+-		AVOutputFormat *format = av_guess_format(NULL, filename.c_str(), NULL);
++#if LIBAVCODEC_VERSION_MAJOR < 59 // FFMPEG < 5.0
++		AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#else
++		const AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#endif
+ 		if (!format) {
+ 			synfig::warning("Target_LibAVCodec: unable to guess the output format, defaulting to MPEG");
+-			format = av_guess_format("mpeg", NULL, NULL);
++			format = av_guess_format("mpeg", nullptr, nullptr);
+ 		}
+ 		if (!format) {
+ 			synfig::error("Target_LibAVCodec: unable to find 'mpeg' output format");
+@@ -254,6 +261,7 @@
+ 		context = avformat_alloc_context();
+ 		assert(context);
+ 		context->oformat = format;
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 		if (filename.size() + 1 > sizeof(context->filename)) {
+ 			synfig::error(
+ 				"Target_LibAVCodec: filename too long, max length is %d, filename is '%s'",
+@@ -263,6 +271,14 @@
+ 			return false;
+ 		}
+ 		memcpy(context->filename, filename.c_str(), filename.size() + 1);
++#else
++		context->url = av_strndup(filename.c_str(), filename.size());
++		if (!context->url) {
++			synfig::error("Target_LibAVCodec: cannot allocate space for filename");
++			close();
++			return false;
++		}
++#endif
+ 
+ 		packet = av_packet_alloc();
+ 		assert(packet);
diff --git a/srcpkgs/synfig/template b/srcpkgs/synfig/template
index d4d3e341a20bf8..828b5cb32956ee 100644
--- a/srcpkgs/synfig/template
+++ b/srcpkgs/synfig/template
@@ -2,11 +2,11 @@
 # Should be kept in sync with 'synfigstudio' and 'ETL'
 pkgname=synfig
 version=1.4.4
-revision=4
+revision=5
 build_style=gnu-configure
 configure_args="--with-boost-libdir=${XBPS_CROSS_BASE}/usr/lib"
 hostmakedepends="boost-build ImageMagick pkg-config intltool"
-makedepends="ETL gettext-devel libxml++-devel mlt-devel libmagick-devel
+makedepends="ETL gettext-devel libxml++-devel mlt7-devel libmagick-devel
  libmng-devel boost-build boost-devel libopenexr-devel ffmpeg-devel"
 depends="ImageMagick"
 short_desc="CLI 2D vector and timeline-based animation software"
@@ -20,7 +20,7 @@ CXXFLAGS="-std=c++11 -DHAVE_LOCALE_H=1"
 
 synfig-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision}
-	 libopenexr-devel libxml++-devel mlt-devel"
+	 libopenexr-devel libxml++-devel mlt7-devel"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/bin/synfig-config

From 7844d93c6ebc103b9c33df223587f2fbf3724cbf Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 065/109] timg: revbump for ffmpeg6

---
 srcpkgs/timg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/timg/template b/srcpkgs/timg/template
index 2a2ab763d2fddf..8fb4327535ef93 100644
--- a/srcpkgs/timg/template
+++ b/srcpkgs/timg/template
@@ -1,7 +1,7 @@
 # Template file for 'timg'
 pkgname=timg
 version=1.4.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_OPENSLIDE_SUPPORT=off -Wno-dev"
 hostmakedepends="pkg-config git"

From b6691db17a2802652336c8145700810936c34b66 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 066/109] tvheadend: revbump for ffmpeg4

---
 srcpkgs/tvheadend/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tvheadend/template b/srcpkgs/tvheadend/template
index 9aea7de4ec7057..012d31c4879ff1 100644
--- a/srcpkgs/tvheadend/template
+++ b/srcpkgs/tvheadend/template
@@ -8,7 +8,7 @@ configure_args="--enable-dvbscan --disable-ffmpeg_static
 --disable-libx265_static --disable-libvpx_static --disable-libtheora_static
 --disable-libvorbis_static --disable-libfdkaac_static"
 hostmakedepends="gettext pkg-config python3 git which"
-makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg-devel"
+makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg4-devel"
 short_desc="TV streaming server"
 maintainer="lemmi <lemmi@nerd2nerd.org>"
 license="GPL-3.0-only"

From b3c6515d9c9e6e2ef8ff5376543a602ce3deb388 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 067/109] unpaper: update to 7.0.0.

---
 srcpkgs/unpaper/template | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/srcpkgs/unpaper/template b/srcpkgs/unpaper/template
index 38ed47a5840165..1ff910e722afc8 100644
--- a/srcpkgs/unpaper/template
+++ b/srcpkgs/unpaper/template
@@ -1,13 +1,13 @@
 # Template file for 'unpaper'
 pkgname=unpaper
-version=6.1
-revision=3
-build_style=gnu-configure
+version=7.0.0
+revision=1
+build_style=meson
+hostmakedepends="pkg-config meson libxslt"
+makedepends="ffmpeg-devel python3-Sphinx"
+short_desc="Post-processing tool for scanned sheets of paper"
 maintainer="Orphaned <orphan@voidlinux.org>"
-hostmakedepends="pkg-config libxslt"
-makedepends="ffmpeg-devel"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://www.flameeyes.eu/projects/unpaper"
-short_desc="A post-processing tool for scanned sheets of paper"
 distfiles="https://www.flameeyes.eu/files/${pkgname}-${version}.tar.xz"
-checksum=237c84f5da544b3f7709827f9f12c37c346cdf029b1128fb4633f9bafa5cb930
+checksum=2575fbbf26c22719d1cb882b59602c9900c7f747118ac130883f63419be46a80

From 9a9ce95a1917efc7eb078c85d3def124a00fbf80 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 068/109] vice: revbump for ffmpeg4

---
 srcpkgs/vice/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vice/template b/srcpkgs/vice/template
index 1c641d9ae9be22..4f43e85b5b8972 100644
--- a/srcpkgs/vice/template
+++ b/srcpkgs/vice/template
@@ -1,7 +1,7 @@
 # Template file for 'vice'
 pkgname=vice
 version=3.8
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-cpuhistory --enable-x64 --disable-pdf-docs
  --libdir=/usr/lib$XBPS_TARGET_WORDSIZE $(vopt_enable sdl2 sdlui2)

From 6a23ad3c874b5863db76e4f8c7f6975f0b6ded0f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 069/109] waypipe: revbump for ffmpeg6

---
 srcpkgs/waypipe/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waypipe/template b/srcpkgs/waypipe/template
index 6da88b21bf2a19..4da8058400b588 100644
--- a/srcpkgs/waypipe/template
+++ b/srcpkgs/waypipe/template
@@ -1,7 +1,7 @@
 # Template file for 'waypipe'
 pkgname=waypipe
 version=0.8.6
-revision=1
+revision=2
 build_style=meson
 # lto is off because it causes linking errors in armv6l and armv7l (due to NEON)
 configure_args="-Dwerror=false -Dwith_dmabuf=enabled -Dwith_lz4=enabled

From 6f062505e3fe682e7199b653de0b924012795f3a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 070/109] xpra: revbump for ffmpeg6

---
 srcpkgs/xpra/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xpra/template b/srcpkgs/xpra/template
index 3e49ab23deac9c..3939026a6fbf90 100644
--- a/srcpkgs/xpra/template
+++ b/srcpkgs/xpra/template
@@ -1,7 +1,7 @@
 # Template file for 'xpra'
 pkgname=xpra
 version=5.0.7
-revision=1
+revision=2
 build_style=python3-module
 make_build_args="--without-cuda_kernels --without-cuda_rebuild"
 make_install_args="$(vopt_with docs) ${make_build_args}"

From fd647b42a51b63551e1ad1ef4ef90a4ba2324e0b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:07:40 -0400
Subject: [PATCH 071/109] nv-codec-headers: update to 12.0.16.0

---
 srcpkgs/nv-codec-headers/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/nv-codec-headers/template b/srcpkgs/nv-codec-headers/template
index 3d422a61e48917..251e057f826fb8 100644
--- a/srcpkgs/nv-codec-headers/template
+++ b/srcpkgs/nv-codec-headers/template
@@ -1,6 +1,6 @@
 # Template file for 'nv-codec-headers'
 pkgname=nv-codec-headers
-version=11.1.5.1
+version=12.0.16.0
 revision=1
 build_style=gnu-makefile
 short_desc="FFmpeg version of headers required to interface with Nvidias codec APIs"
@@ -8,7 +8,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="MIT"
 homepage="http://git.videolan.org/?p=ffmpeg/nv-codec-headers.git"
 distfiles="https://github.com/FFmpeg/nv-codec-headers/archive/n${version}.tar.gz"
-checksum=d095fbd56aa93772471a323be0ebe65504a0f43f06c76a30b6d25da77b06ae9c
+checksum=2a1533b65f55f9da52956faf0627ed3b74868ac0c7f269990edd21369113b48f
 
 post_install() {
 	sed -n '4,25p' include/ffnvcodec/nvEncodeAPI.h > LICENSE

From 97f51c85b6130fd01f514799e778d3bdfbab3b1c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:08:40 -0400
Subject: [PATCH 072/109] openimagedenoise: revbump for ffmpeg6

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index 109deb171c3f75..44edf38fb289d8 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,7 +1,7 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
 version=1.4.3
-revision=2
+revision=3
 archs="x86_64*"
 build_style=cmake
 hostmakedepends="ispc python3"

From bd8c25af2f9ddffb8bece52723bf22869cef258f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:31:45 -0400
Subject: [PATCH 073/109] shotcut: revbump for ffmpeg6

---
 srcpkgs/shotcut/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/shotcut/template b/srcpkgs/shotcut/template
index 33141fbd862d7a..f46cb53b6bfb92 100644
--- a/srcpkgs/shotcut/template
+++ b/srcpkgs/shotcut/template
@@ -1,7 +1,7 @@
 # Template file for 'shotcut'
 pkgname=shotcut
 version=23.09.29
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSHOTCUT_VERSION=${version}"
 hostmakedepends="pkg-config qt6-tools-devel"

From 57bb2c7b5da579173424bf833b57eaaa266fdbd3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:30 -0400
Subject: [PATCH 074/109] shiboken2: revbump for qt5-5.15.11

---
 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch | 1 +
 1 file changed, 1 insertion(+)
 create mode 120000 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
new file mode 120000
index 00000000000000..efcf3249bd8854
--- /dev/null
+++ b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1 @@
+../../python3-pyside2/patches/importlib-machinery-bypass.patch
\ No newline at end of file

From bdae4b001f81ad6b6a75e98065fafecef245a7ca Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:53 -0400
Subject: [PATCH 075/109] python3-pyside2: revbump for qt5-5.15.11

---
 .../patches/importlib-machinery-bypass.patch      | 15 +++++++++++++++
 srcpkgs/python3-pyside2/template                  |  2 +-
 2 files changed, 16 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
new file mode 100644
index 00000000000000..64c429584776b5
--- /dev/null
+++ b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1,15 @@
+Using this prevents an error around line 220 below it.
+"AttributeError: module 'importlib' has no attribute 'machinery'"
+The old backup logic is in place and compiles without issues.
+--- a/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:09:34.688912402 -0400
++++ b/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:10:03.395529582 -0400
+@@ -170,9 +170,6 @@
+
+     # 'zipstring_sequence' comes from signature.cpp
+     zipbytes = base64.b64decode(''.join(zipstring_sequence))
+-    if sys.version_info[0] >= 3:
+-        vzip = zipfile.ZipFile(io.BytesIO(zipbytes))
+-        return sys.meta_path, EmbeddableZipImporter(vzip)
+
+     # Old version for Python 2.7, only.
+     import os
diff --git a/srcpkgs/python3-pyside2/template b/srcpkgs/python3-pyside2/template
index 249efa90988425..52626436ce75f2 100644
--- a/srcpkgs/python3-pyside2/template
+++ b/srcpkgs/python3-pyside2/template
@@ -1,7 +1,7 @@
 # Template file for 'python3-pyside2'
 pkgname=python3-pyside2
 version=5.15.10
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/pyside2"
 build_style=cmake

From c718814da6ef8e170bc8d56c497acfc85581b139 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:35 -0400
Subject: [PATCH 076/109] konqueror: revbump for ffmpeg6

---
 srcpkgs/konqueror/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/konqueror/template b/srcpkgs/konqueror/template
index add972916753c6..50bbf4eec05e55 100644
--- a/srcpkgs/konqueror/template
+++ b/srcpkgs/konqueror/template
@@ -1,11 +1,11 @@
 # Template file for 'konqueror'
 pkgname=konqueror
 version=23.08.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DDESKTOPTOJSON_EXECUTABLE=/usr/bin/desktoptojson"
 hostmakedepends="extra-cmake-modules python3 qt5-host-tools qt5-qmake kdoctools
-kcoreaddons kconfig gettext"
+ kcoreaddons kconfig gettext"
 makedepends="qt5-devel qt5-webengine-devel qt5-declarative-devel
  qt5-webchannel-devel qt5-location-devel kcmutils-devel kdelibs4support-devel
  karchive-devel khtml-devel kdesu-devel kactivities5-devel"

From f05edc9b765701acec11c229280961f5036ebcfa Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:58 -0400
Subject: [PATCH 077/109] qt5-speech: revbump for qt5-5.15.11

---
 srcpkgs/qt5-speech/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-speech/template b/srcpkgs/qt5-speech/template
index 1228bb60c41db4..27a7da1dbdb91b 100644
--- a/srcpkgs/qt5-speech/template
+++ b/srcpkgs/qt5-speech/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-speech'
 pkgname=qt5-speech
 version=5.15.11
-revision=1
+revision=2
 _commit=d32f4a479d38a11f547598004b975f4356424a16
 build_style=qmake
 configure_args="-- -flite -flite-alsa -speechd"

From 69329d0d6c5bd1370d9df52179d0d1da81812532 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Jun 2023 08:20:22 -0400
Subject: [PATCH 078/109] gtk4: revbump for ffmpeg6

---
 srcpkgs/gtk4/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gtk4/template b/srcpkgs/gtk4/template
index 3f2554ea3bc940..da41e85ec329c3 100644
--- a/srcpkgs/gtk4/template
+++ b/srcpkgs/gtk4/template
@@ -1,7 +1,7 @@
 # Template file for 'gtk4'
 pkgname=gtk4
 version=4.12.5
-revision=1
+revision=2
 build_style=meson
 build_helper="gir"
 configure_args="-Dman-pages=true -Ddocumentation=true -Dbuild-tests=false

From 68040832504e97adc5ded61304889ad73660e8bb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:28:26 -0400
Subject: [PATCH 079/109] siril: revbump for ffmpeg6

---
 srcpkgs/siril/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/siril/template b/srcpkgs/siril/template
index 84332f79d060d2..62750dd247548f 100644
--- a/srcpkgs/siril/template
+++ b/srcpkgs/siril/template
@@ -1,7 +1,7 @@
 # Template file for 'siril'
 pkgname=siril
 version=0.9.12
-revision=10
+revision=11
 build_style=gnu-configure
 hostmakedepends="pkg-config intltool autoconf automake gettext-devel"
 makedepends="fftw-devel libconfig-devel libopencv-devel libffms2-devel

From 2d66bca485f94762ea3c6d011a4fca76af6e676f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:20:59 -0400
Subject: [PATCH 080/109] tracker-miners: revbump for ffmpeg6

---
 srcpkgs/tracker-miners/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tracker-miners/template b/srcpkgs/tracker-miners/template
index 0b97f47489f817..f196d2bf9e4a4c 100644
--- a/srcpkgs/tracker-miners/template
+++ b/srcpkgs/tracker-miners/template
@@ -1,7 +1,7 @@
 # Template file for 'tracker-miners'
 pkgname=tracker-miners
 version=3.6.1
-revision=1
+revision=2
 build_style=meson
 build_helper=qemu
 # missing libgrss for miner_rss

From 9d4b26ccb84a41840baae6e8c50fee7f1d92585b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:21:21 -0400
Subject: [PATCH 081/109] mpd: revbump for ffmpeg6

---
 srcpkgs/mdp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mdp/template b/srcpkgs/mdp/template
index 3720bfae02f840..1c45395dca9b21 100644
--- a/srcpkgs/mdp/template
+++ b/srcpkgs/mdp/template
@@ -1,7 +1,7 @@
 # Template file for 'mdp'
 pkgname=mdp
 version=1.0.15
-revision=1
+revision=2
 build_style=gnu-makefile
 makedepends="ncurses-devel"
 short_desc="A command-line based markdown presentation tool"

From 6a150977b211bd9ddaee79963384a9319da2f538 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:02 -0400
Subject: [PATCH 082/109] tg_owt: revbump for ffmpeg6

---
 srcpkgs/tg_owt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tg_owt/template b/srcpkgs/tg_owt/template
index 34e8fef0540569..1a46a8bedf3473 100644
--- a/srcpkgs/tg_owt/template
+++ b/srcpkgs/tg_owt/template
@@ -1,7 +1,7 @@
 # Template file for 'tg_owt'
 pkgname=tg_owt
 version=0.0.0.20231221
-revision=2
+revision=3
 _commit=afd9d5d31798d3eacf9ed6c30601e91d0f1e4d60
 _libyuv_commit=04821d1e7d60845525e8db55c7bcd41ef5be9406
 _abseil_commit=8c0b94e793a66495e0b1f34a5eb26bd7dc672db0

From 6ffcea802a4dd03960798685efa5dcc5db91e9e8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:44 -0400
Subject: [PATCH 083/109] telegram-desktop: revbump for ffmpeg6

---
 srcpkgs/telegram-desktop/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/telegram-desktop/template b/srcpkgs/telegram-desktop/template
index 6dc6a553cfcec8..cf85a731370062 100644
--- a/srcpkgs/telegram-desktop/template
+++ b/srcpkgs/telegram-desktop/template
@@ -1,7 +1,7 @@
 # Template file for 'telegram-desktop'
 pkgname=telegram-desktop
 version=4.14.15
-revision=3
+revision=4
 build_style=cmake
 build_helper="qemu gir"
 configure_args="-DTDESKTOP_API_ID=209235

From 43ebef0eb335aeef516be53fd8f8d14b554c9560 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:12:09 -0400
Subject: [PATCH 084/109] openmw: revbump for ffmpeg6

---
 srcpkgs/openmw/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openmw/template b/srcpkgs/openmw/template
index 0abf5ff7cdbecc..b57180f1a4446f 100644
--- a/srcpkgs/openmw/template
+++ b/srcpkgs/openmw/template
@@ -1,7 +1,7 @@
 # Template file for 'openmw'
 pkgname=openmw
 version=0.48.0
-revision=2
+revision=3
 build_style=cmake
 _recast_commit=e75adf86f91eb3082220085e42dda62679f9a3ea
 _bullet_tag=3.17

From 9fcc3c419dd78f77aaee86e6d09ab7ae1cce5c8e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:14:53 -0400
Subject: [PATCH 085/109] lms: revbump for ffmpeg6

---
 srcpkgs/lms/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/lms/template b/srcpkgs/lms/template
index e358f75902a986..3b21c458de5199 100644
--- a/srcpkgs/lms/template
+++ b/srcpkgs/lms/template
@@ -1,7 +1,7 @@
 # Template file for 'lms'
 pkgname=lms
 version=3.42.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="wt-devel ffmpeg-devel boost-devel libconfig++-devel taglib-devel pam-devel libgraphicsmagick-devel gtest-devel libarchive-devel"

From 414babe16418b4eb6244adaedc850aaae4ec3453 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:18:18 -0400
Subject: [PATCH 086/109] freecad: DELETE

---
 srcpkgs/freecad/patches/001-include.patch     | 112 ------------------
 .../154-revert-gui-tmp-redirect-stderr.patch  |  68 -----------
 ...d63c8c9b1280978be841d04e68a0a55cceb9.patch |  30 -----
 srcpkgs/freecad/template                      |  12 +-
 4 files changed, 7 insertions(+), 215 deletions(-)
 delete mode 100644 srcpkgs/freecad/patches/001-include.patch
 delete mode 100644 srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
 delete mode 100644 srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch

diff --git a/srcpkgs/freecad/patches/001-include.patch b/srcpkgs/freecad/patches/001-include.patch
deleted file mode 100644
index 28b5af54999b96..00000000000000
--- a/srcpkgs/freecad/patches/001-include.patch
+++ /dev/null
@@ -1,112 +0,0 @@
-From 9a41845a417189776741297c50a3827ce292bc4f Mon Sep 17 00:00:00 2001
-From: Uwe <donovaly@users.noreply.github.com>
-Date: Sun, 3 Jul 2022 22:51:16 +0200
-Subject: [PATCH] [Part] OCCError.h: remove unneeded includes
-
-- also sort includes
----
- src/Mod/Part/App/OCCError.h             | 36 +++----------------------
- src/Mod/Part/App/OffsetCurvePyImp.cpp   | 12 ++++-----
- src/Mod/Part/App/OffsetSurfacePyImp.cpp | 10 +++----
- 3 files changed, 12 insertions(+), 46 deletions(-)
-
---- a/src/Mod/Part/App/OCCError.h
-+++ b/src/Mod/Part/App/OCCError.h
-@@ -23,36 +23,8 @@
- #ifndef _OCCError_h_
- #define _OCCError_h_
- 
--# include <Standard_Version.hxx>
- # include <Standard_Failure.hxx>
--# include <Standard_AbortiveTransaction.hxx>
--# include <Standard_ConstructionError.hxx>
--# if OCC_VERSION_HEX >= 0x060500
--# include <Standard_DefineException.hxx>
--# endif
--# include <Standard_DimensionError.hxx>
--# include <Standard_DimensionMismatch.hxx>
--# include <Standard_DivideByZero.hxx>
--# include <Standard_DomainError.hxx>
--# include <Standard_ImmutableObject.hxx>
--# include <Standard_LicenseError.hxx>
--# include <Standard_LicenseNotFound.hxx>
--# include <Standard_MultiplyDefined.hxx>
--# include <Standard_NegativeValue.hxx>
--# include <Standard_NoMoreObject.hxx>
--# include <Standard_NoSuchObject.hxx>
--# include <Standard_NotImplemented.hxx>
--# include <Standard_NullObject.hxx>
--# include <Standard_NullValue.hxx>
--# include <Standard_NumericError.hxx>
--# include <Standard_OutOfMemory.hxx>
--# include <Standard_OutOfRange.hxx>
--# include <Standard_Overflow.hxx>
--# include <Standard_ProgramError.hxx>
--# include <Standard_RangeError.hxx>
--# include <Standard_TooManyUsers.hxx>
--# include <Standard_TypeMismatch.hxx>
--# include <Standard_Underflow.hxx>
-+# include <Standard_Version.hxx>
- 
- #include <Mod/Part/PartGlobal.h>
- #include <Base/Console.h>
-@@ -88,4 +60,3 @@ PartExport extern PyObject* PartExceptio
- 
- #define PY_CATCH_OCC _PY_CATCH_OCC(return(NULL))
- #endif  // _OCCError_h_
--
---- a/src/Mod/Part/App/OffsetCurvePyImp.cpp
-+++ b/src/Mod/Part/App/OffsetCurvePyImp.cpp
-@@ -20,20 +20,20 @@
-  *                                                                         *
-  ***************************************************************************/
- 
--
- #include "PreCompiled.h"
- #ifndef _PreComp_
- # include <Geom_OffsetCurve.hxx>
- #endif
- 
--#include "OCCError.h"
--#include "Geometry.h"
-+#include <Base/GeometryPyCXX.h>
-+#include <Base/Vector3D.h>
-+#include <Base/VectorPy.h>
-+
- #include "OffsetCurvePy.h"
- #include "OffsetCurvePy.cpp"
-+#include "Geometry.h"
-+#include "OCCError.h"
- 
--#include <Base/GeometryPyCXX.h>
--#include <Base/VectorPy.h>
--#include <Base/Vector3D.h>
- 
- using namespace Part;
- 
---- a/src/Mod/Part/App/OffsetSurfacePyImp.cpp
-+++ b/src/Mod/Part/App/OffsetSurfacePyImp.cpp
-@@ -20,20 +20,16 @@
-  *                                                                         *
-  ***************************************************************************/
- 
--
- #include "PreCompiled.h"
- #ifndef _PreComp_
- # include <Geom_OffsetSurface.hxx>
- # include <memory>
- #endif
- 
--#include <Base/VectorPy.h>
--#include <Base/Vector3D.h>
--
- #include "OCCError.h"
--#include "Geometry.h"
--#include <Mod/Part/App/OffsetSurfacePy.h>
--#include <Mod/Part/App/OffsetSurfacePy.cpp>
-+#include "OffsetSurfacePy.h"
-+#include "OffsetSurfacePy.cpp"
-+
- 
- using namespace Part;
- 
diff --git a/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch b/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
deleted file mode 100644
index d6a9adabdec830..00000000000000
--- a/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
+++ /dev/null
@@ -1,68 +0,0 @@
-see https://github.com/FreeCAD/FreeCAD/commit/cfe94b00d3434f3e2c8b5114d2909f628c330fa8#commitcomment-71413407
-
-upstream: yes
-
-From 7b377a216b9185960e4cee980a6504dc1a755f50 Mon Sep 17 00:00:00 2001
-From: wmayer <wmayer@users.sourceforge.net>
-Date: Wed, 29 Jun 2022 15:19:18 +0200
-Subject: [PATCH] Gui: remove workaround for spnav 0.23 due to build failure
- with musl libc
-
----
- src/Gui/3Dconnexion/GuiNativeEventLinux.cpp | 27 ---------------------
- 1 file changed, 27 deletions(-)
-
---- a/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp
-+++ b/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp
-@@ -21,42 +21,17 @@
-  ***************************************************************************/
- 
- #include <FCConfig.h>
--#include <cstdio>
- 
- #include "GuiNativeEventLinux.h"
- 
- #include "GuiApplicationNativeEventAware.h"
- #include <Base/Console.h>
--#include <Base/FileInfo.h>
- #include <QMainWindow>
- 
- #include <QSocketNotifier>
- 
- #include <spnav.h>
- 
--namespace {
--class RedirectStdErr
--{
--public:
--    RedirectStdErr()
--        : fi(Base::FileInfo::getTempFileName())
--        , file(stderr)
--    {
--        stderr = fopen(fi.filePath().c_str(), "w");
--    }
--    ~RedirectStdErr()
--    {
--        fclose(stderr);
--        fi.deleteFile();
--        stderr = file;
--    }
--
--private:
--    Base::FileInfo fi;
--    FILE* file;
--};
--}
--
- Gui::GuiNativeEvent::GuiNativeEvent(Gui::GUIApplicationNativeEventAware *app)
- : GuiAbstractNativeEvent(app)
- {
-@@ -72,8 +47,6 @@ Gui::GuiNativeEvent::~GuiNativeEvent()
- 
- void Gui::GuiNativeEvent::initSpaceball(QMainWindow *window)
- {
--    // tmp. redirect stderr to a file to suppress an error message from spnav_open()
--    RedirectStdErr err;
-     Q_UNUSED(window)
-     if (spnav_open() == -1) {
-         Base::Console().Log("Couldn't connect to spacenav daemon. Please ignore if you don't have a spacemouse.\n");
diff --git a/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch b/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch
deleted file mode 100644
index d4acf370ca0a42..00000000000000
--- a/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-From fe02d63c8c9b1280978be841d04e68a0a55cceb9 Mon Sep 17 00:00:00 2001
-From: Roy-043 <70520633+Roy-043@users.noreply.github.com>
-Date: Thu, 29 Dec 2022 23:20:38 +0100
-Subject: [PATCH] Draft: update inspect.getargspec to inspect.getfullargspec
- (#8101)
-
----
- src/Mod/Draft/draftguitools/gui_snapper.py | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
---- a/src/Mod/Draft/draftguitools/gui_snapper.py
-+++ b/src/Mod/Draft/draftguitools/gui_snapper.py
-@@ -1426,7 +1426,7 @@ class Snapper:
-             Gui.Snapper.off()
-             self.ui.offUi()
-             if callback:
--                if len(inspect.getargspec(callback).args) > 1:
-+                if len(inspect.getfullargspec(callback).args) > 1:
-                     obj = None
-                     if self.snapInfo and ("Object" in self.snapInfo) and self.snapInfo["Object"]:
-                         obj = App.ActiveDocument.getObject(self.snapInfo["Object"])
-@@ -1445,7 +1445,7 @@ class Snapper:
-             Gui.Snapper.off()
-             self.ui.offUi()
-             if callback:
--                if len(inspect.getargspec(callback).args) > 1:
-+                if len(inspect.getfullargspec(callback).args) > 1:
-                     callback(None, None)
-                 else:
-                     callback(None)
diff --git a/srcpkgs/freecad/template b/srcpkgs/freecad/template
index c135701e38b9ad..7d5165f760bab9 100644
--- a/srcpkgs/freecad/template
+++ b/srcpkgs/freecad/template
@@ -1,7 +1,7 @@
 # Template file for 'freecad'
 pkgname=freecad
-version=0.20.2
-revision=7
+version=0.21.1
+revision=2
 build_wrksrc="FreeCAD-${version}"
 build_style=cmake
 pycompile_dirs="usr/lib/${pkgname}/Mod"
@@ -24,8 +24,10 @@ makedepends="python3-devel boost-devel libxerces-c-devel zlib-devel occt-devel
  coin3-devel libshiboken2-devel libspnav-devel pyside2-tools
  liblz4-devel libpyside2-python3-devel python3-matplotlib netcdf-devel
  jsoncpp-devel qt5-devel qt5-svg-devel qt5-tools-devel qt5-webkit-devel
- qt5-xmlpatterns-devel coin3-doc glew-devel python3-pivy"
-depends="python3-matplotlib python3-pyside2-webengine python3-pivy"
+ qt5-xmlpatterns-devel coin3-doc glew-devel python3-pivy qt5-webengine-devel
+ qt5-declarative-devel qt5-webchannel-devel qt5-location-devel"
+depends="python3-matplotlib python3-pyside2-webengine python3-pivy
+ python3-GitPython python3-Markdown"
 short_desc="General purpose 3D CAD modeler"
 maintainer="yopito <pierre.bourgin@free.fr>"
 license="LGPL-2.0-or-later"
@@ -35,7 +37,7 @@ distfiles="
  https://github.com/FreeCAD/FreeCAD/archive/${version}.tar.gz
  ${SOURCEFORGE_SITE}/cxx/pycxx-${_pycxxver}.tar.gz
 "
-checksum="46922f3a477e742e1a89cd5346692d63aebb2b67af887b3e463e094a4ae055da
+checksum="e9b1fd0323f101268c7f3be52db42e4a29222f2e306ae6c4a6fc309cb418d35a
  4b91e1e1141c23fbd5039df635c4bb6e75632168548f56b83ce177193c0c98c6"
 python_version=3
 patch_args="-Np1 -d ${build_wrksrc}"

From 742f0d63cd6777d7e76ebd00b3e168433703301a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:47:18 -0400
Subject: [PATCH 087/109] libopenshot: revbump for ffmpeg6

---
 srcpkgs/libopenshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenshot/template b/srcpkgs/libopenshot/template
index 8e57c5f592169c..7a8f4520e78925 100644
--- a/srcpkgs/libopenshot/template
+++ b/srcpkgs/libopenshot/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenshot'
 pkgname=libopenshot
 version=0.3.0
-revision=3
+revision=4
 build_style=cmake
 # Builds fail with Ruby-2.4.1
 configure_args="-DENABLE_RUBY=OFF -DUSE_SYSTEM_JSONCPP=ON"

From aadb0851454a1f935d6cee0f40efdb974ceff552 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:10:30 -0500
Subject: [PATCH 088/109] openimageio: revbump for ffmpeg6

---
 srcpkgs/openimageio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimageio/template b/srcpkgs/openimageio/template
index 27d2131bc0a61a..61f44b43f9083e 100644
--- a/srcpkgs/openimageio/template
+++ b/srcpkgs/openimageio/template
@@ -1,7 +1,7 @@
 # Template file for 'openimageio'
 pkgname=openimageio
 version=2.4.9.0
-revision=8
+revision=9
 build_style=cmake
 build_helper=qemu
 configure_args="-DUSE_QT=0 -DUSE_PYTHON=0 -DOIIO_BUILD_TESTS=0

From b52b05fe49059a497fac10ab98bac03013f2c2e7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:11:57 -0500
Subject: [PATCH 089/109] synfigstudio: revbump for ffmpeg6

---
 srcpkgs/synfigstudio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/synfigstudio/template b/srcpkgs/synfigstudio/template
index 09e442da9a6805..2bc017cedca6b8 100644
--- a/srcpkgs/synfigstudio/template
+++ b/srcpkgs/synfigstudio/template
@@ -2,7 +2,7 @@
 # Should be kept in sync with 'synfig' and 'ETL'
 pkgname=synfigstudio
 version=1.4.4
-revision=4
+revision=5
 build_style=gnu-configure
 configure_args="--disable-update-mimedb"
 hostmakedepends="pkg-config intltool gettext synfig"

From 63e91b0d70f1a9d73bc5b1ced6cbf92208adf130 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:10 -0500
Subject: [PATCH 090/109] mixxx: revbump for ffmpeg6

---
 srcpkgs/mixxx/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mixxx/template b/srcpkgs/mixxx/template
index 6a79b328c1abf0..9a5141856860b9 100644
--- a/srcpkgs/mixxx/template
+++ b/srcpkgs/mixxx/template
@@ -1,7 +1,7 @@
 # Template file for 'mixxx'
 pkgname=mixxx
 version=2.3.3
-revision=7
+revision=8
 build_style=cmake
 configure_args="-DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="extra-cmake-modules pkg-config protobuf qt5-host-tools qt5-qmake"

From 9679c55156872a33f77caba2bcc3ed7fedad8f20 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:28 -0500
Subject: [PATCH 091/109] musikcube: revbump for ffmpeg6

---
 srcpkgs/musikcube/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/musikcube/template b/srcpkgs/musikcube/template
index 8c4a51840859ec..fb60dd2049089a 100644
--- a/srcpkgs/musikcube/template
+++ b/srcpkgs/musikcube/template
@@ -1,7 +1,7 @@
 # Template file for 'musikcube'
 pkgname=musikcube
 version=3.0.0
-revision=3
+revision=4
 build_style=cmake
 make_cmd=make
 configure_args="-DNO_NCURSESW=1"

From e6d9c78e278b4e8650d44b819dd8ac50d2a13925 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:45 -0500
Subject: [PATCH 092/109] electron24: revbump for ffmpeg6

---
 srcpkgs/electron24/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron24/template b/srcpkgs/electron24/template
index 7b4e28812f483e..1ca93fde97a854 100644
--- a/srcpkgs/electron24/template
+++ b/srcpkgs/electron24/template
@@ -1,7 +1,7 @@
 # Template file for 'electron24'
 pkgname=electron24
 version=24.3.0
-revision=2
+revision=3
 _nodever=18.14.0
 _chromiumver=112.0.5615.165
 archs="x86_64* aarch64*"

From eaba4a72adc5ed61c41b2e40a9ffbb2a6be09b2c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:00 -0500
Subject: [PATCH 093/109] electron19: revbump for ffmpeg6

---
 srcpkgs/electron19/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron19/template b/srcpkgs/electron19/template
index 0ef959125cb085..5371c0b354604f 100644
--- a/srcpkgs/electron19/template
+++ b/srcpkgs/electron19/template
@@ -1,7 +1,7 @@
 # Template file for 'electron19'
 pkgname=electron19
 version=19.0.8
-revision=4
+revision=5
 _nodever=16.14.2
 _chromiumver=102.0.5005.125
 archs="x86_64* aarch64* ppc64le*"

From eddb46abac372dda16836121fa5a892d930289cc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:13 -0500
Subject: [PATCH 094/109] wf-recorder: revbump for ffmpeg6

---
 srcpkgs/wf-recorder/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/wf-recorder/template b/srcpkgs/wf-recorder/template
index 08f986b0310067..63c45cf4b814d7 100644
--- a/srcpkgs/wf-recorder/template
+++ b/srcpkgs/wf-recorder/template
@@ -1,7 +1,7 @@
 # Template file for 'wf-recorder'
 pkgname=wf-recorder
 version=0.4.1
-revision=2
+revision=3
 build_style=meson
 hostmakedepends="pkg-config scdoc wayland-devel"
 makedepends="wayland-protocols wayland-devel ffmpeg-devel libgbm-devel x264-devel

From 48ece7bcaa766c43ef9d698a510a56f7a1ec0668 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:26 -0500
Subject: [PATCH 095/109] obs: revbump for ffmpeg6

---
 srcpkgs/obs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/obs/template b/srcpkgs/obs/template
index b343f1131bfcf6..a25a67433e285e 100644
--- a/srcpkgs/obs/template
+++ b/srcpkgs/obs/template
@@ -1,7 +1,7 @@
 # Template file for 'obs'
 pkgname=obs
 version=30.0.0
-revision=2
+revision=3
 archs="i686* x86_64* ppc64le* aarch64* riscv64*"
 build_style=cmake
 configure_args="-DOBS_VERSION_OVERRIDE=${version} -DENABLE_JACK=ON

From 83a638d270d56524e16627d8eeb36546f0c18b48 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:36 -0500
Subject: [PATCH 096/109] mlt7: revbump for ffmpeg6

---
 srcpkgs/mlt7/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mlt7/template b/srcpkgs/mlt7/template
index 98f302ad3a5167..7eb8c00fa1580c 100644
--- a/srcpkgs/mlt7/template
+++ b/srcpkgs/mlt7/template
@@ -1,7 +1,7 @@
 # Template file for 'mlt7'
 pkgname=mlt7
 version=7.20.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DSWIG_PYTHON=ON -DMOD_QT6=ON"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which

From c97cc4a736ced9786a6f156b06237eff0db882c0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:48 -0500
Subject: [PATCH 097/109] qt6-multimedia: revbump for ffmpeg6

---
 srcpkgs/qt6-multimedia/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-multimedia/template b/srcpkgs/qt6-multimedia/template
index 67a577e1300fea..1da626ecf515a8 100644
--- a/srcpkgs/qt6-multimedia/template
+++ b/srcpkgs/qt6-multimedia/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-multimedia'
 pkgname=qt6-multimedia
 version=6.6.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DQT_FEATURE_gstreamer=ON"
 hostmakedepends="perl qt6-declarative-host-tools pkg-config qt6-shadertools"

From 1385063595057d37bedb3bb53f9375755669ce6b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:00:15 -0500
Subject: [PATCH 098/109] baresip: revbump for ffmpeg6

---
 srcpkgs/baresip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/baresip/template b/srcpkgs/baresip/template
index b16b67beab8d2b..fe21ebf40c03c1 100644
--- a/srcpkgs/baresip/template
+++ b/srcpkgs/baresip/template
@@ -1,7 +1,7 @@
 # Template file for 'baresip'
 pkgname=baresip
 version=3.6.0
-revision=3
+revision=4
 build_style=cmake
 hostmakedepends="pkg-config glib-devel"
 makedepends="libgsm-devel libpng-devel openssl-devel libsndfile-devel

From 11906916cf454fd45c5fd193b39e380200046c91 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:30 -0500
Subject: [PATCH 099/109] QMPlay2: revbump for ffmpeg6

---
 srcpkgs/QMPlay2/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/QMPlay2/template b/srcpkgs/QMPlay2/template
index efa9726614093c..10e5ac4ceebf80 100644
--- a/srcpkgs/QMPlay2/template
+++ b/srcpkgs/QMPlay2/template
@@ -1,7 +1,7 @@
 # Template file for 'QMPlay2'
 pkgname=QMPlay2
 version=24.03.16
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools"
 makedepends="alsa-lib-devel ffmpeg-devel libass-devel libcdio-devel libgme-devel

From 008dafbc0ba2d91e97f039ce112ee58a1b06fecc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:34 -0500
Subject: [PATCH 100/109] alsa-plugins: revbump for ffmpeg6

---
 srcpkgs/alsa-plugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/alsa-plugins/template b/srcpkgs/alsa-plugins/template
index a5708a7d82a8f0..7bfdad046c4830 100644
--- a/srcpkgs/alsa-plugins/template
+++ b/srcpkgs/alsa-plugins/template
@@ -1,7 +1,7 @@
 # Template file for 'alsa-plugins'
 pkgname=alsa-plugins
 version=1.2.7.1
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--disable-maemo-plugin"
 hostmakedepends="pkg-config"

From ab8939aa3251e8557f39b6207e89ba3bccbf4440 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:43 -0500
Subject: [PATCH 101/109] minidlna: revbump for ffmpeg6

---
 srcpkgs/minidlna/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/minidlna/template b/srcpkgs/minidlna/template
index 5fa929f3a0c124..742991ecd04afc 100644
--- a/srcpkgs/minidlna/template
+++ b/srcpkgs/minidlna/template
@@ -1,7 +1,7 @@
 # Template file for 'minidlna'
 pkgname=minidlna
 version=1.3.3
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="
  --sbindir=/usr/bin

From 6ca42f9bb49ff2d3a4cc5d5e82cd7fabcbfad546 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 17:57:47 -0500
Subject: [PATCH 102/109] mpv: revbump for ffmpeg6

---
 srcpkgs/mpv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpv/template b/srcpkgs/mpv/template
index 3d4349e27d8f62..bc40d6fcaa40d6 100644
--- a/srcpkgs/mpv/template
+++ b/srcpkgs/mpv/template
@@ -1,7 +1,7 @@
 # Template file for 'mpv'
 pkgname=mpv
 version=0.37.0
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcdda=enabled -Ddvbin=enabled -Ddvdnav=enabled
  -Dlibmpv=true -Dcplugins=enabled

From a36e9bf63e298dcbcc313b4808b1b7f708041465 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 17:59:29 -0500
Subject: [PATCH 103/109] qimgv: revbump for ffmpeg6

---
 srcpkgs/qimgv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qimgv/template b/srcpkgs/qimgv/template
index dd341dfe1bfce8..8a7e1c081ef12f 100644
--- a/srcpkgs/qimgv/template
+++ b/srcpkgs/qimgv/template
@@ -1,7 +1,7 @@
 # Template file for 'qimgv'
 pkgname=qimgv
 version=1.0.2
-revision=3
+revision=4
 build_style=cmake
 configure_args="$(vopt_if video -DVIDEO_SUPPORT=ON -DVIDEO_SUPPORT=OFF)
  $(vopt_if scale -DOPENCV_SUPPORT=ON -DOPENCV_SUPPORT=OFF)

From fdc534d5b6c8262af459ba58eebc63b83404b7a9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 18:00:36 -0500
Subject: [PATCH 104/109] kfilemetadata5: revbump for ffmpeg6

---
 srcpkgs/kfilemetadata5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kfilemetadata5/template b/srcpkgs/kfilemetadata5/template
index a0c4d809395323..b584f85ff2058b 100644
--- a/srcpkgs/kfilemetadata5/template
+++ b/srcpkgs/kfilemetadata5/template
@@ -1,7 +1,7 @@
 # Template file for 'kfilemetadata5'
 pkgname=kfilemetadata5
 version=5.115.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="kcoreaddons extra-cmake-modules pkg-config qt5-host-tools qt5-qmake
  gettext kcoreaddons python3"

From 01cb608511be382b07c438325b638715acfa4b7b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 8 Dec 2023 11:46:01 -0500
Subject: [PATCH 105/109] vba-m: revbump for ffmpeg6

---
 srcpkgs/vba-m/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vba-m/template b/srcpkgs/vba-m/template
index 3d135efa1d0b69..3c5a20db0fa984 100644
--- a/srcpkgs/vba-m/template
+++ b/srcpkgs/vba-m/template
@@ -2,7 +2,7 @@
 pkgname=vba-m
 reverts=1292_2
 version=2.1.9
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_GTK=TRUE -DENABLE_FFMPEG=TRUE -DENABLE_LINK=TRUE -DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="gettext pkg-config unzip zip yasm wxWidgets-gtk3-devel"

From ff9478659c37e7687f99e9bc0d898a664dc251d3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 8 Dec 2023 11:46:19 -0500
Subject: [PATCH 106/109] dolphin-emu: revbump for ffmpeg6

---
 srcpkgs/dolphin-emu/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/dolphin-emu/template b/srcpkgs/dolphin-emu/template
index 862d3ae964eec4..a7ae0efb58fb75 100644
--- a/srcpkgs/dolphin-emu/template
+++ b/srcpkgs/dolphin-emu/template
@@ -1,7 +1,7 @@
 # Template file for 'dolphin-emu'
 pkgname=dolphin-emu
 version=5.0.19368
-revision=3
+revision=4
 _dolphin_commit=dadbeb4bae7e7fa23af2b46e0add4143094dc107
 _mgba_commit=44e074a15e9651481f7f652ac006a7c9d58cbeb9
 _googletest_commit=be03d00f5f0cc3a997d1a368bee8a1fe93651f48

From 9f9cb5e1aa1379899fc40a85d4179087c349e7ff Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 19 Dec 2023 15:38:51 -0500
Subject: [PATCH 107/109] qtox: revbump for ffmpeg4

---
 srcpkgs/qtox/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtox/template b/srcpkgs/qtox/template
index bb70e7f51240a4..755e4462bc0137 100644
--- a/srcpkgs/qtox/template
+++ b/srcpkgs/qtox/template
@@ -1,13 +1,13 @@
 # Template file for 'qtox'
 pkgname=qtox
 version=1.17.6
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DUPDATE_CHECK=OFF
  -DGIT_DESCRIBE=${version}
  $(vopt_if snorenotify -DDESKTOP_NOTIFICATIONS=ON)"
 hostmakedepends="pkg-config qt5-host-tools qt5-devel"
-makedepends="ffmpeg-devel libexif-devel libopenal-devel libsodium-devel
+makedepends="ffmpeg4-devel libexif-devel libopenal-devel libsodium-devel
  libvpx-devel opus-devel qrencode-devel qt5-svg-devel sonnet-devel
  sqlcipher-devel toxcore-devel
  $(vopt_if snorenotify snorenotify-devel)"

From 3554b4d5eb7a025676562cd230f0b5d2e77a3f99 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 11 Jan 2024 11:52:00 -0500
Subject: [PATCH 108/109] arcan: revbump for ffmpeg6

---
 srcpkgs/arcan/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/arcan/template b/srcpkgs/arcan/template
index ff9091f90ebb10..030091a6cc9d0c 100644
--- a/srcpkgs/arcan/template
+++ b/srcpkgs/arcan/template
@@ -2,7 +2,7 @@
 # !! keep synced with: acfgfs aclip aloadimage
 pkgname=arcan
 version=0.6.2.1
-revision=2
+revision=3
 create_wrksrc=yes
 build_wrksrc=arcan/src
 build_style=cmake

From 15a2974bee82c86d18abbd65a8f60547eb227605 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 11 Jan 2024 11:52:10 -0500
Subject: [PATCH 109/109] notcurses: revbump for ffmpeg6

---
 srcpkgs/notcurses/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/notcurses/template b/srcpkgs/notcurses/template
index 48a7463cb68eb9..515f316ab4576c 100644
--- a/srcpkgs/notcurses/template
+++ b/srcpkgs/notcurses/template
@@ -1,7 +1,7 @@
 # Template file for 'notcurses'
 pkgname=notcurses
 version=3.0.9
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DUSE_STATIC=ON -DUSE_QRCODEGEN=On $(vopt_bool man USE_PANDOC)"
 hostmakedepends="pkg-config $(vopt_if man pandoc)"

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (92 preceding siblings ...)
  2024-03-18 20:07 ` zlice
@ 2024-03-21 21:29 ` zlice
  2024-03-21 21:51 ` zlice
                   ` (3 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2024-03-21 21:29 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 4972 bytes --]

There is an updated pull request by zlice against master on the void-packages repository

https://github.com/zlice/void-packages ffmpeg6-split
https://github.com/void-linux/void-packages/pull/43761

ffmpeg6 split
[ci skip]


#### Testing the changes

- I tested the changes in this PR: **YES**

main testing has been vaapi in Firefox Nightly and enc/dec in Shotcut on Intel A770

#### New package

- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**

#### Local build testing

- I built this PR locally for my native architecture, **x86_64**

#### Discussion

Continuation of https://github.com/void-linux/void-packages/pull/36315

`libavresample` is deprecated, but marked as a dependency when trying to build other packages and install `ffmpeg`(6). I think the right way to handle this is make a meta package and the add to removals?


##### Commit naming / misc

~~Commits are 'dirty' right now, running with [gstreamer 1.22.1 updates](https://github.com/void-linux/void-packages/pull/42861) and [Intel OpenCL](https://github.com/void-linux/void-packages/pull/43084). This will also make [intel packages pr](https://github.com/void-linux/void-packages/pull/41132) obsolete.~~ (see Requirements below)

Maintainer for previous ffmpeg(4) was orphaned, I can put my name in there if that matters, though I don't exactly see myself keeping up on ffmpeg.

~~This updates QT5 which looks like it is usually hosted by Johnny. Not sure if there's any reason to stay there or these sources are fine.~~ Using qt5.15.11 now, revbumps and some patches.

##### STILL FFMPEG4

These are a mix of emulators, games and/or older packages.

- ~~attract~~ (2.7 builds)
- ~~audacity (https://github.com/audacity/audacity/issues/2305 and https://sourceforge.net/p/portmedia/wiki/portsmf/ is 'beta')~~ (updated to 3.x, compiles with ffmpeg6)
- ~~ccextractor~~ (master patches)
- ~~vice (3.8 compiles, needs makedepends libcurl-devel)~~ ty yosh
- kodi
- mlt (only dep left is flowblade - flowblade 2.12.0.2 with mlt7-python3 can 'render' videos with cpu and gpu - https://github.com/void-linux/void-packages/pull/47195)
- ~~synfig (mlt)~~ (work with mlt7, bump synfigstudio)
- tvheadend (download page recommends using 4.3 which compiles fine, 4.4 eta is Q1 2024)
- ~~ssr~~ (patches)
- ~~spek-alternative~~ (replace with spek-x)
- ~~ppsspp~~ ~~(1.17.1 is out, but there's 5+ distfiles that are all git commits)~~ (minor patch)
- olive (has been in alpha since 2020, seems they do nightly builds and appimages)
- moc
- mediastreamer (linphone links are dead, changed to github belladonne. their stuff never worked for me but there are updates if someone wants to give it a try)
- ~~libextractor (1.13 compiles, remove exiv2 patch)~~ (as yosh pointed out, 1.13 just removes ffmpeg bits)
- idjc (0.9.8 compiles, remove python3.10 patch, needs makedepends libebur128-devel and libshout-idjc 2.4.6 with '-r1' for distfile)
- hedgewars
- ~~ffmpegthumbnailer~~ (patches for moviedecoder.xxx files)
- ~~ffmpegthumbs~~ (latest compiles)
- deadbeef (1.9.6 may work but requires libdispatch from apple)
- ~~omxplayer~~ (package removed, deprecated in favor of vlc)
- qtav (fork has ffmpeg 5 patch - https://github.com/cmguo/QtAV)
- `vlc` (vlc4 will support ffmpeg5, there's a patch to build 3.x with ffmpeg5 but it will lack vaapi)
- `osg` (OpenSceneGraph plus `xine-lib`)


##### HAVE NOT BUILT YET

- ~~omxplayer (rpi only? ffmpeg4)~~ (removed)
- kodi (big, but ffmpeg4)


##### UPDATED (for ffmpeg6)

- ~~blender: update to 3.5.1~~ ~~will be revbump with~~ https://github.com/void-linux/void-packages/pull/43992
- unpaper: update to 7.0.0.
- guvcview: update to 2.0.8.
- ~~qt5: update to 5.15.8~~ updated by another PR to 5.15.11
- ~~qt5-webengine: update to 5.18.15~~ updated by another PR to 5.15.16 (some patching for ffmpeg build)
- ~~shiboken2: revbump for qt5.15.8 (patch)~~ updated by another PR to 5.15.10
- ~~python3-pyside2: update to 5.15.8 (patch)~~ updated by another PR to 5.15.10
- New package: spex-x replaces spek-alternative for ffmpeg-6.0


##### Requirements

- ~~[gstreamer 1.22.2](https://github.com/void-linux/void-packages/pull/42861)~~ - a few packages use ffmpeg-devel and require a revbump

- ~~[Intel Packages](https://github.com/void-linux/void-packages/pull/41132) [Intel Packages v2](https://github.com/void-linux/void-packages/pull/47330) - ffmpeg4 uses different libraries than 6 (libmfx / Intel-MediaSDK vs only oneVPL that Intel is moving to), both are included here~~. Using replacement oneVPL from OBS update.

- ~~[shotcut 23.05.14](https://github.com/void-linux/void-packages/pull/44260)~~

- https://github.com/void-linux/void-packages/pull/44781 will remove from this PR

A patch file from https://github.com/void-linux/void-packages/pull/43761.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ffmpeg6-split-43761.patch --]
[-- Type: text/x-diff, Size: 240194 bytes --]

From f0573d72abd9dda4f4059b7e2346e8a0e49c2f95 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:16:56 -0400
Subject: [PATCH 001/109] ffmpeg: update to 6.0.1.

---
 common/shlibs                                 | 26 ++++---
 srcpkgs/ffmpeg/files/altivec.patch            | 60 ---------------
 .../patches/armv5tel-floating-point.patch     | 18 -----
 srcpkgs/ffmpeg/patches/binutils-2.41.patch    | 73 -------------------
 ...h-libavcodec-libsvtav1-ten_bit_format.diff | 40 ----------
 .../workaround-mesa-readeon-vaapi-bug.patch   | 28 -------
 srcpkgs/ffmpeg/template                       | 40 +++++-----
 7 files changed, 37 insertions(+), 248 deletions(-)
 delete mode 100644 srcpkgs/ffmpeg/files/altivec.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/binutils-2.41.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 delete mode 100644 srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch

diff --git a/common/shlibs b/common/shlibs
index 9ca4502a01c4a7..e29b7e87b8915c 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -389,15 +389,23 @@ libid3tag.so.0 libid3tag-0.15.1b_1
 libgif.so.7 giflib-5.1.0_1
 libImlib2.so.1 imlib2-1.4.2_1
 libmp3lame.so.0 lame-3.98.2_1
-libavdevice.so.58 libavdevice-4.0_1
-libavformat.so.58 libavformat-4.0_1
-libswscale.so.5 libswscale-4.0_1
-libswresample.so.3 libswresample-4.0_1
-libavresample.so.4 libavresample-4.0_1
-libpostproc.so.55 libpostproc-4.0_1
-libavcodec.so.58 libavcodec-4.0_1
-libavutil.so.56 libavutil-4.0_1
-libavfilter.so.7 libavfilter-4.0_1
+libavdevice.so.60 libavdevice-6.0_1
+libavformat.so.60 libavformat-6.0_1
+libswscale.so.7 libswscale-6.0_1
+libswresample.so.4 libswresample-6.0_1
+libpostproc.so.57 libpostproc-6.0_1
+libavcodec.so.60 libavcodec-6.0_1
+libavutil.so.58 libavutil-6.0_1
+libavfilter.so.9 libavfilter-6.0_1
+libavdevice.so.58 libavdevice4-4.0_1
+libavformat.so.58 libavformat4-4.0_1
+libswscale.so.5 libswscale4-4.0_1
+libswresample.so.3 libswresample4-4.0_1
+libavresample.so.4 libavresample4-4.0_1
+libpostproc.so.55 libpostproc4-4.0_1
+libavcodec.so.58 libavcodec4-4.0_1
+libavutil.so.56 libavutil4-4.0_1
+libavfilter.so.7 libavfilter4-4.0_1
 libSDL-1.2.so.0 SDL-1.2.14_1
 libSDL_image-1.2.so.0 SDL_image-1.2.10_1
 libx264.so.157 x264-20190507.2245_1
diff --git a/srcpkgs/ffmpeg/files/altivec.patch b/srcpkgs/ffmpeg/files/altivec.patch
deleted file mode 100644
index 9c57200463320e..00000000000000
--- a/srcpkgs/ffmpeg/files/altivec.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-revert some altivec specific change on all ppc* except ppc64le*
-
-q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
-conditionally, for ppc* but not ppc64le* (the new code is valid for
-POWER8 VSX which LE targets as a baseline but not BE)"
-
-
-This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
----
- libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
- 1 file changed, 20 insertions(+), 4 deletions(-)
-
-diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
-index 536545293d..c1e2852adb 100644
---- a/libswscale/ppc/yuv2rgb_altivec.c
-+++ b/libswscale/ppc/yuv2rgb_altivec.c
-@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-     vector signed short R1, G1, B1;                                           \
-     vector unsigned char R, G, B;                                             \
-                                                                               \
-+    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
-+    vector unsigned char align_perm;                                          \
-+                                                                              \
-     vector signed short lCY       = c->CY;                                    \
-     vector signed short lOY       = c->OY;                                    \
-     vector signed short lCRV      = c->CRV;                                   \
-@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
-                                                                               \
-         for (j = 0; j < w / 16; j++) {                                        \
--            y0 = vec_xl(0, y1i);                                              \
-+            y1ivP = (const vector unsigned char *) y1i;                       \
-+            y2ivP = (const vector unsigned char *) y2i;                       \
-+            uivP  = (const vector unsigned char *) ui;                        \
-+            vivP  = (const vector unsigned char *) vi;                        \
-+                                                                              \
-+            align_perm = vec_lvsl(0, y1i);                                    \
-+            y0 = (vector unsigned char)                                       \
-+                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
-                                                                               \
--            y1 = vec_xl(0, y2i);                                              \
-+            align_perm = vec_lvsl(0, y2i);                                    \
-+            y1 = (vector unsigned char)                                       \
-+                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
-                                                                               \
--            u = (vector signed char) vec_xl(0, ui);                           \
-+            align_perm = vec_lvsl(0, ui);                                     \
-+            u = (vector signed char)                                          \
-+                    vec_perm(uivP[0], uivP[1], align_perm);                   \
-                                                                               \
--            v = (vector signed char) vec_xl(0, vi);                           \
-+            align_perm = vec_lvsl(0, vi);                                     \
-+            v = (vector signed char)                                          \
-+                    vec_perm(vivP[0], vivP[1], align_perm);                   \
-                                                                               \
-             u = (vector signed char)                                          \
-                     vec_sub(u,                                                \
--- 
-2.27.0
-
diff --git a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
deleted file mode 100644
index 9a55178c74f0fd..00000000000000
--- a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
-+++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
-@@ -39,6 +39,15 @@
- #endif
- #include <fenv.h>
- 
-+#if (FE_ALL_EXCEPT == 0)
-+/* E.g. ARM soft float does not define these */
-+#define FE_INVALID    0
-+#define FE_DIVBYZERO  0
-+#define FE_OVERFLOW   0
-+#define FE_UNDERFLOW  0
-+#define FE_INEXACT    0
-+#endif
-+
- #if CONFIG_LIBFONTCONFIG
- #include <fontconfig/fontconfig.h>
- #endif
diff --git a/srcpkgs/ffmpeg/patches/binutils-2.41.patch b/srcpkgs/ffmpeg/patches/binutils-2.41.patch
deleted file mode 100644
index 53a596d0ee7d4e..00000000000000
--- a/srcpkgs/ffmpeg/patches/binutils-2.41.patch
+++ /dev/null
@@ -1,73 +0,0 @@
-From effadce6c756247ea8bae32dc13bb3e6f464f0eb Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= <remi@remlab.net>
-Date: Sun, 16 Jul 2023 18:18:02 +0300
-Subject: [PATCH] avcodec/x86/mathops: clip constants used with shift
- instructions within inline assembly
-
-Fixes assembling with binutil as >= 2.41
-
-Signed-off-by: James Almer <jamrial@gmail.com>
----
- libavcodec/x86/mathops.h | 26 +++++++++++++++++++++++---
- 1 file changed, 23 insertions(+), 3 deletions(-)
-
-diff --git a/libavcodec/x86/mathops.h b/libavcodec/x86/mathops.h
-index 6298f5ed1983b..ca7e2dffc1076 100644
---- a/libavcodec/x86/mathops.h
-+++ b/libavcodec/x86/mathops.h
-@@ -35,12 +35,20 @@
- static av_always_inline av_const int MULL(int a, int b, unsigned shift)
- {
-     int rt, dummy;
-+    if (__builtin_constant_p(shift))
-     __asm__ (
-         "imull %3               \n\t"
-         "shrdl %4, %%edx, %%eax \n\t"
-         :"=a"(rt), "=d"(dummy)
--        :"a"(a), "rm"(b), "ci"((uint8_t)shift)
-+        :"a"(a), "rm"(b), "i"(shift & 0x1F)
-     );
-+    else
-+        __asm__ (
-+            "imull %3               \n\t"
-+            "shrdl %4, %%edx, %%eax \n\t"
-+            :"=a"(rt), "=d"(dummy)
-+            :"a"(a), "rm"(b), "c"((uint8_t)shift)
-+        );
-     return rt;
- }
- 
-@@ -113,19 +121,31 @@ __asm__ volatile(\
- // avoid +32 for shift optimization (gcc should do that ...)
- #define NEG_SSR32 NEG_SSR32
- static inline  int32_t NEG_SSR32( int32_t a, int8_t s){
-+    if (__builtin_constant_p(s))
-     __asm__ ("sarl %1, %0\n\t"
-          : "+r" (a)
--         : "ic" ((uint8_t)(-s))
-+         : "i" (-s & 0x1F)
-     );
-+    else
-+        __asm__ ("sarl %1, %0\n\t"
-+               : "+r" (a)
-+               : "c" ((uint8_t)(-s))
-+        );
-     return a;
- }
- 
- #define NEG_USR32 NEG_USR32
- static inline uint32_t NEG_USR32(uint32_t a, int8_t s){
-+    if (__builtin_constant_p(s))
-     __asm__ ("shrl %1, %0\n\t"
-          : "+r" (a)
--         : "ic" ((uint8_t)(-s))
-+         : "i" (-s & 0x1F)
-     );
-+    else
-+        __asm__ ("shrl %1, %0\n\t"
-+               : "+r" (a)
-+               : "c" ((uint8_t)(-s))
-+        );
-     return a;
- }
- 
diff --git a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
deleted file mode 100644
index aa948f7a8a2dfb..00000000000000
--- a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
+++ /dev/null
@@ -1,40 +0,0 @@
-#==================================================================================================
-# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
-# From: Christopher Degawa <christopher.degawa@intel.com>
-# Date: Thu, 20 Oct 2022 22:55:27 -0500
-# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
-#
-# compressed_ten_bit_format has been deprecated upstream and has no effect
-# and can be removed. Plus, technically it was never used in the first place
-# since it would require the app (ffmpeg) to set it and do additional
-# processing of the input frames.
-#
-# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
-#
-# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
-#==================================================================================================
---- a/libavcodec/libsvtav1.c
-+++ b/libavcodec/libsvtav1.c
-@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
- 
- static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
- {
--    const int    pack_mode_10bit =
--        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
--    const size_t luma_size_8bit  =
--        config->source_width * config->source_height * (1 << pack_mode_10bit);
--    const size_t luma_size_10bit =
--        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
-+    const size_t luma_size = config->source_width * config->source_height *
-+        (config->encoder_bit_depth > 8 ? 2 : 1);
- 
-     EbSvtIOFormat *in_data;
- 
--    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
-+    svt_enc->raw_size = luma_size * 3 / 2;
- 
-     // allocate buffer for in and out
-     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
--- 
-GitLab
-
diff --git a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
deleted file mode 100644
index 00e3f68a415b84..00000000000000
--- a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
-From: Rainer Hochecker <fernetmenta@online.de>
-Date: Sat, 26 Jan 2019 19:48:35 +0100
-Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
-
-This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
-It was hit frequently when watching h264 channels received via DVB-X.
-Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
----
- libavcodec/vaapi_h264.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
-index 5854587a255..f12fdc457a4 100644
---- a/libavcodec/vaapi_h264.c
-+++ b/libavcodec/vaapi_h264.c
-@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
-     H264SliceContext *sl = &h->slice_ctx[0];
-     int ret;
- 
-+    if (pic->nb_slices == 0) {
-+        ret = AVERROR_INVALIDDATA;
-+        goto finish;
-+    }
-+
-     ret = ff_vaapi_decode_issue(avctx, pic);
-     if (ret < 0)
-         goto finish;
diff --git a/srcpkgs/ffmpeg/template b/srcpkgs/ffmpeg/template
index 1ebb436135938d..f1e4712c41d087 100644
--- a/srcpkgs/ffmpeg/template
+++ b/srcpkgs/ffmpeg/template
@@ -1,15 +1,15 @@
 # Template file for 'ffmpeg'
 # audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
 pkgname=ffmpeg
-version=4.4.4
-revision=6
+version=6.0.1
+revision=1
 short_desc="Decoding, encoding and streaming software"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="https://www.ffmpeg.org"
 changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
 distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
-checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+checksum=9b16b8731d78e596b4be0d720428ca42df642bb2d78342881ff7f5bc29fc9623
 
 hostmakedepends="pkg-config perl"
 makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
@@ -26,12 +26,13 @@ makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-deve
  $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
  $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
  $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
- $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers Vulkan-Tools Vulkan-ValidationLayers')
+ $(vopt_if onevpl 'oneVPL oneVPL-devel')
  $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
 depends="ffplay>=${version}_${revision}"
 
 build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
- dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec onevpl"
 build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
 desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
 desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
@@ -39,9 +40,13 @@ desc_option_sofa="Enable support for AES SOFA"
 desc_option_webp="Enable support for WebP"
 
 case "$XBPS_TARGET_MACHINE" in
-	i686*|x86_64*)
-		hostmakedepends+=" nasm"
+	i686*)
 		build_options_default+=" vaapi vdpau nvenc nvdec"
+		hostmakedepends+=" nasm"
+		;;
+	x86_64*)
+		hostmakedepends+=" nasm"
+		build_options_default+=" vaapi vdpau nvenc nvdec onevpl"
 		;;
 	ppc64*) build_options_default+=" vaapi vdpau";;
 	mips*) CFLAGS="-mnan=legacy";;
@@ -65,8 +70,6 @@ post_patch() {
 		ppc64le*) ;;
 		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
 	esac
-
-	vsed -i libavfilter/vf_libvmaf.c -e 's!/usr/local/share/model/\(vmaf_v0.6.1\).pkl!/usr/share/vmaf/\1.json!'
 }
 
 do_configure() {
@@ -115,18 +118,19 @@ do_configure() {
 		$(vopt_enable x265 libx265) \
 		$(vopt_enable v4l2 libv4l2) \
 		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
-		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		--enable-libbs2b --enable-libvidstab \
 		$(vopt_enable dav1d libdav1d) \
 		$(vopt_enable zimg libzimg) \
 		$(vopt_enable webp libwebp) \
 		$(vopt_enable sofa libmysofa) \
 		$(vopt_enable vulkan) \
+		$(vopt_enable onevpl libvpl) \
 		$(vopt_enable drm libdrm) \
 		$(vopt_enable svtav1 libsvtav1) \
 		$(vopt_enable srt libsrt) \
 		$(vopt_enable rist librist) \
-		$(vopt_if nvenc '--enable-nvenc') \
-		$(vopt_if nvdec '--enable-nvdec')
+		$(vopt_enable nvenc nvenc) \
+		$(vopt_enable nvdec nvdec)
 }
 
 do_build() {
@@ -153,10 +157,8 @@ libavdevice_package() {
 }
 
 libavresample_package() {
-	short_desc="FFmpeg audio resampling library"
-	pkg_install() {
-		vmove "usr/lib/libavresample.so.*"
-	}
+	short_desc="Package deprecated, removal needed"
+	build_style=meta
 }
 
 libavformat_package() {
@@ -210,15 +212,13 @@ ffmpeg-devel_package() {
 		libavfilter>=${version}_${revision}
 		libpostproc>=${version}_${revision}
 		libswscale>=${version}_${revision}
-		libswresample>=${version}_${revision}
-		libavresample>=${version}_${revision}"
+		libswresample>=${version}_${revision}"
 	short_desc+=" - development files"
-
+	conflicts="ffmpeg4-devel"
 	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
 		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
 		nostrip_files="/usr/lib/libavfilter.a"
 	fi
-
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig

From 2f444f539c6569dc2a2e8da339af5f3ae71b43c7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:14 -0400
Subject: [PATCH 002/109] openshot: revbump for ffmpeg6

---
 srcpkgs/openshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openshot/template b/srcpkgs/openshot/template
index 3849858fe963b5..12789bc9867499 100644
--- a/srcpkgs/openshot/template
+++ b/srcpkgs/openshot/template
@@ -1,7 +1,7 @@
 # Template file for 'openshot'
 pkgname=openshot
 version=3.1.1
-revision=1
+revision=2
 build_style=python3-module
 hostmakedepends="python3 python3-setuptools"
 makedepends="ffmpeg-devel python3-PyQt5"

From 05f3e5ecccf0685968bccb8774abeb6d150795b3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:36 -0400
Subject: [PATCH 003/109] sumo: revbump for ffmpeg6

---
 srcpkgs/sumo/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/sumo/template b/srcpkgs/sumo/template
index a730afa9fafa92..e2def06fa4bd7d 100644
--- a/srcpkgs/sumo/template
+++ b/srcpkgs/sumo/template
@@ -1,7 +1,7 @@
 # Template file for 'sumo'
 pkgname=sumo
 version=1.12.0
-revision=7
+revision=8
 build_style=cmake
 hostmakedepends="libgdal-tools pkg-config swig python3-setuptools"
 makedepends="python3-devel ffmpeg-devel fox-devel gl2ps-devel libgdal-devel

From 5a61ce996bab6f7cc99bf1286763f76dcdbd995f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:56:22 -0400
Subject: [PATCH 004/109] New package: ffmpeg4-4.4.4.

---
 srcpkgs/ffmpeg4-devel                         |   1 +
 srcpkgs/ffmpeg4/files/altivec.patch           |  60 +++++
 .../patches/armv5tel-floating-point.patch     |  18 ++
 srcpkgs/ffmpeg4/patches/binutils-2.41.patch   |  73 ++++++
 ...h-libavcodec-libsvtav1-ten_bit_format.diff |  40 +++
 .../workaround-mesa-readeon-vaapi-bug.patch   |  28 +++
 srcpkgs/ffmpeg4/template                      | 234 ++++++++++++++++++
 srcpkgs/libavcodec4                           |   1 +
 srcpkgs/libavdevice4                          |   1 +
 srcpkgs/libavfilter4                          |   1 +
 srcpkgs/libavformat4                          |   1 +
 srcpkgs/libavresample4                        |   1 +
 srcpkgs/libavutil4                            |   1 +
 srcpkgs/libpostproc4                          |   1 +
 srcpkgs/libswresample4                        |   1 +
 srcpkgs/libswscale4                           |   1 +
 16 files changed, 463 insertions(+)
 create mode 120000 srcpkgs/ffmpeg4-devel
 create mode 100644 srcpkgs/ffmpeg4/files/altivec.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/binutils-2.41.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 create mode 100644 srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
 create mode 100644 srcpkgs/ffmpeg4/template
 create mode 120000 srcpkgs/libavcodec4
 create mode 120000 srcpkgs/libavdevice4
 create mode 120000 srcpkgs/libavfilter4
 create mode 120000 srcpkgs/libavformat4
 create mode 120000 srcpkgs/libavresample4
 create mode 120000 srcpkgs/libavutil4
 create mode 120000 srcpkgs/libpostproc4
 create mode 120000 srcpkgs/libswresample4
 create mode 120000 srcpkgs/libswscale4

diff --git a/srcpkgs/ffmpeg4-devel b/srcpkgs/ffmpeg4-devel
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/ffmpeg4-devel
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/ffmpeg4/files/altivec.patch b/srcpkgs/ffmpeg4/files/altivec.patch
new file mode 100644
index 00000000000000..9c57200463320e
--- /dev/null
+++ b/srcpkgs/ffmpeg4/files/altivec.patch
@@ -0,0 +1,60 @@
+revert some altivec specific change on all ppc* except ppc64le*
+
+q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
+conditionally, for ppc* but not ppc64le* (the new code is valid for
+POWER8 VSX which LE targets as a baseline but not BE)"
+
+
+This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
+---
+ libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
+ 1 file changed, 20 insertions(+), 4 deletions(-)
+
+diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
+index 536545293d..c1e2852adb 100644
+--- a/libswscale/ppc/yuv2rgb_altivec.c
++++ b/libswscale/ppc/yuv2rgb_altivec.c
+@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+     vector signed short R1, G1, B1;                                           \
+     vector unsigned char R, G, B;                                             \
+                                                                               \
++    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
++    vector unsigned char align_perm;                                          \
++                                                                              \
+     vector signed short lCY       = c->CY;                                    \
+     vector signed short lOY       = c->OY;                                    \
+     vector signed short lCRV      = c->CRV;                                   \
+@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
+                                                                               \
+         for (j = 0; j < w / 16; j++) {                                        \
+-            y0 = vec_xl(0, y1i);                                              \
++            y1ivP = (const vector unsigned char *) y1i;                       \
++            y2ivP = (const vector unsigned char *) y2i;                       \
++            uivP  = (const vector unsigned char *) ui;                        \
++            vivP  = (const vector unsigned char *) vi;                        \
++                                                                              \
++            align_perm = vec_lvsl(0, y1i);                                    \
++            y0 = (vector unsigned char)                                       \
++                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
+                                                                               \
+-            y1 = vec_xl(0, y2i);                                              \
++            align_perm = vec_lvsl(0, y2i);                                    \
++            y1 = (vector unsigned char)                                       \
++                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
+                                                                               \
+-            u = (vector signed char) vec_xl(0, ui);                           \
++            align_perm = vec_lvsl(0, ui);                                     \
++            u = (vector signed char)                                          \
++                    vec_perm(uivP[0], uivP[1], align_perm);                   \
+                                                                               \
+-            v = (vector signed char) vec_xl(0, vi);                           \
++            align_perm = vec_lvsl(0, vi);                                     \
++            v = (vector signed char)                                          \
++                    vec_perm(vivP[0], vivP[1], align_perm);                   \
+                                                                               \
+             u = (vector signed char)                                          \
+                     vec_sub(u,                                                \
+-- 
+2.27.0
+
diff --git a/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
new file mode 100644
index 00000000000000..9a55178c74f0fd
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
@@ -0,0 +1,18 @@
+--- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
++++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
+@@ -39,6 +39,15 @@
+ #endif
+ #include <fenv.h>
+ 
++#if (FE_ALL_EXCEPT == 0)
++/* E.g. ARM soft float does not define these */
++#define FE_INVALID    0
++#define FE_DIVBYZERO  0
++#define FE_OVERFLOW   0
++#define FE_UNDERFLOW  0
++#define FE_INEXACT    0
++#endif
++
+ #if CONFIG_LIBFONTCONFIG
+ #include <fontconfig/fontconfig.h>
+ #endif
diff --git a/srcpkgs/ffmpeg4/patches/binutils-2.41.patch b/srcpkgs/ffmpeg4/patches/binutils-2.41.patch
new file mode 100644
index 00000000000000..53a596d0ee7d4e
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/binutils-2.41.patch
@@ -0,0 +1,73 @@
+From effadce6c756247ea8bae32dc13bb3e6f464f0eb Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= <remi@remlab.net>
+Date: Sun, 16 Jul 2023 18:18:02 +0300
+Subject: [PATCH] avcodec/x86/mathops: clip constants used with shift
+ instructions within inline assembly
+
+Fixes assembling with binutil as >= 2.41
+
+Signed-off-by: James Almer <jamrial@gmail.com>
+---
+ libavcodec/x86/mathops.h | 26 +++++++++++++++++++++++---
+ 1 file changed, 23 insertions(+), 3 deletions(-)
+
+diff --git a/libavcodec/x86/mathops.h b/libavcodec/x86/mathops.h
+index 6298f5ed1983b..ca7e2dffc1076 100644
+--- a/libavcodec/x86/mathops.h
++++ b/libavcodec/x86/mathops.h
+@@ -35,12 +35,20 @@
+ static av_always_inline av_const int MULL(int a, int b, unsigned shift)
+ {
+     int rt, dummy;
++    if (__builtin_constant_p(shift))
+     __asm__ (
+         "imull %3               \n\t"
+         "shrdl %4, %%edx, %%eax \n\t"
+         :"=a"(rt), "=d"(dummy)
+-        :"a"(a), "rm"(b), "ci"((uint8_t)shift)
++        :"a"(a), "rm"(b), "i"(shift & 0x1F)
+     );
++    else
++        __asm__ (
++            "imull %3               \n\t"
++            "shrdl %4, %%edx, %%eax \n\t"
++            :"=a"(rt), "=d"(dummy)
++            :"a"(a), "rm"(b), "c"((uint8_t)shift)
++        );
+     return rt;
+ }
+ 
+@@ -113,19 +121,31 @@ __asm__ volatile(\
+ // avoid +32 for shift optimization (gcc should do that ...)
+ #define NEG_SSR32 NEG_SSR32
+ static inline  int32_t NEG_SSR32( int32_t a, int8_t s){
++    if (__builtin_constant_p(s))
+     __asm__ ("sarl %1, %0\n\t"
+          : "+r" (a)
+-         : "ic" ((uint8_t)(-s))
++         : "i" (-s & 0x1F)
+     );
++    else
++        __asm__ ("sarl %1, %0\n\t"
++               : "+r" (a)
++               : "c" ((uint8_t)(-s))
++        );
+     return a;
+ }
+ 
+ #define NEG_USR32 NEG_USR32
+ static inline uint32_t NEG_USR32(uint32_t a, int8_t s){
++    if (__builtin_constant_p(s))
+     __asm__ ("shrl %1, %0\n\t"
+          : "+r" (a)
+-         : "ic" ((uint8_t)(-s))
++         : "i" (-s & 0x1F)
+     );
++    else
++        __asm__ ("shrl %1, %0\n\t"
++               : "+r" (a)
++               : "c" ((uint8_t)(-s))
++        );
+     return a;
+ }
+ 
diff --git a/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
new file mode 100644
index 00000000000000..aa948f7a8a2dfb
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
@@ -0,0 +1,40 @@
+#==================================================================================================
+# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
+# From: Christopher Degawa <christopher.degawa@intel.com>
+# Date: Thu, 20 Oct 2022 22:55:27 -0500
+# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
+#
+# compressed_ten_bit_format has been deprecated upstream and has no effect
+# and can be removed. Plus, technically it was never used in the first place
+# since it would require the app (ffmpeg) to set it and do additional
+# processing of the input frames.
+#
+# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
+#
+# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
+#==================================================================================================
+--- a/libavcodec/libsvtav1.c
++++ b/libavcodec/libsvtav1.c
+@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
+ 
+ static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
+ {
+-    const int    pack_mode_10bit =
+-        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
+-    const size_t luma_size_8bit  =
+-        config->source_width * config->source_height * (1 << pack_mode_10bit);
+-    const size_t luma_size_10bit =
+-        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
++    const size_t luma_size = config->source_width * config->source_height *
++        (config->encoder_bit_depth > 8 ? 2 : 1);
+ 
+     EbSvtIOFormat *in_data;
+ 
+-    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
++    svt_enc->raw_size = luma_size * 3 / 2;
+ 
+     // allocate buffer for in and out
+     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
+-- 
+GitLab
+
diff --git a/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
new file mode 100644
index 00000000000000..00e3f68a415b84
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
@@ -0,0 +1,28 @@
+From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
+From: Rainer Hochecker <fernetmenta@online.de>
+Date: Sat, 26 Jan 2019 19:48:35 +0100
+Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
+
+This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
+It was hit frequently when watching h264 channels received via DVB-X.
+Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
+---
+ libavcodec/vaapi_h264.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
+index 5854587a255..f12fdc457a4 100644
+--- a/libavcodec/vaapi_h264.c
++++ b/libavcodec/vaapi_h264.c
+@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
+     H264SliceContext *sl = &h->slice_ctx[0];
+     int ret;
+ 
++    if (pic->nb_slices == 0) {
++        ret = AVERROR_INVALIDDATA;
++        goto finish;
++    }
++
+     ret = ff_vaapi_decode_issue(avctx, pic);
+     if (ret < 0)
+         goto finish;
diff --git a/srcpkgs/ffmpeg4/template b/srcpkgs/ffmpeg4/template
new file mode 100644
index 00000000000000..9ba14bdb8ddf32
--- /dev/null
+++ b/srcpkgs/ffmpeg4/template
@@ -0,0 +1,234 @@
+# Template file for 'ffmpeg4'
+# audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
+pkgname=ffmpeg4
+version=4.4.4
+revision=1
+short_desc="Decoding, encoding and streaming software - ffmpeg4 libraries only"
+maintainer="Orphaned <orphan@voidlinux.org>"
+license="GPL-3.0-or-later"
+homepage="https://www.ffmpeg.org"
+changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
+distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
+checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+
+hostmakedepends="pkg-config perl"
+makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
+ libXext-devel libXvMC-devel libxcb-devel lame-devel libtheora-devel
+ libvorbis-devel x264-devel xvidcore-devel jack-devel SDL2-devel
+ libcdio-paranoia-devel librtmp-devel libmodplug-devel gnutls-devel
+ speex-devel celt-devel harfbuzz-devel libass-devel opus-devel ocl-icd-devel
+ libbs2b-devel libvidstab-devel vmaf-devel $(vopt_if pulseaudio pulseaudio-devel)
+ $(vopt_if vaapi libva-devel) $(vopt_if vdpau libvdpau-devel)
+ $(vopt_if x265 x265-devel) $(vopt_if v4l2 v4l-utils-devel)
+ $(vopt_if fdk_aac fdk-aac-devel) $(vopt_if vpx libvpx-devel)
+ $(vopt_if aom libaom-devel) $(vopt_if sndio sndio-devel)
+ $(vopt_if dav1d libdav1d-devel) $(vopt_if zimg zimg-devel)
+ $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
+ $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
+ $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
+
+build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
+
+desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
+desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
+desc_option_sofa="Enable support for AES SOFA"
+desc_option_webp="Enable support for WebP"
+
+case "$XBPS_TARGET_MACHINE" in
+	i686*|x86_64*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau nvenc nvdec"
+			;;
+	ppc64*) build_options_default+=" vaapi vdpau";;
+	mips*) CFLAGS="-mnan=legacy";;
+esac
+
+if [ "$XBPS_TARGET_WORDSIZE" != "32" ]; then
+	build_options_default+=" svtav1"
+fi
+
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+fi
+
+_apply_patch() {
+	local args="$1" pname="$(basename $2)"
+
+	if [ ! -f ".${pname}_done" ]; then
+		patch -N $args -i $2
+		touch .${pname}_done
+	fi
+}
+
+post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64le*) ;;
+		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
+	esac
+
+	vsed -i libavfilter/vf_libvmaf.c -e 's!/usr/local/share/model/\(vmaf_v0.6.1\).pkl!/usr/share/vmaf/\1.json!'
+}
+
+do_configure() {
+	# Fix gcc on x86_64-musl only
+	if [ "$XBPS_TARGET_MACHINE" = "x86_64-musl" ]; then
+		vsed -i configure -e "s;_cflags_speed='-O3';_cflags_speed='-O2';"
+	fi
+
+	if [ "$CROSS_BUILD" ]; then
+		case "$XBPS_TARGET_MACHINE" in
+			arm*) _arch="arm";;
+			aarch64*) _arch="aarch64";;
+			mips*) _arch="mips";;
+			ppc64*) _arch="ppc64";;
+			ppc*) _arch="ppc";;
+			*) _arch="${XBPS_TARGET_MACHINE%%-musl}";;
+		esac
+
+		_args+=" --enable-cross-compile
+			--sysroot=$XBPS_CROSS_BASE
+			--cross-prefix=${XBPS_CROSS_TRIPLET}-
+			--target-os=linux --arch=${_arch}"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc|ppc-musl) _args+=" --disable-altivec";;
+	esac
+
+	if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+		_args+=" --extra-libs=-latomic"
+	fi
+
+	./configure --prefix=/usr --disable-debug --enable-gpl --enable-gnutls \
+		--disable-stripping \
+		--enable-libcdio --enable-version3 --enable-runtime-cpudetect \
+		--enable-libmp3lame --enable-libvorbis --enable-libxvid \
+		--enable-libx264 $(vopt_enable vpx libvpx) --enable-libtheora \
+		--enable-shared --enable-static --enable-libxcb \
+		$(vopt_enable pulseaudio libpulse) --enable-libfreetype --enable-libmodplug \
+		--enable-libspeex --enable-libcelt --enable-libass \
+		--enable-libopus --enable-librtmp --enable-libjack \
+		$(vopt_if fdk_aac '--enable-nonfree --enable-libfdk-aac') \
+		--disable-libopencore_amrnb --disable-libopencore_amrwb \
+		--disable-libopenjpeg \
+		--enable-postproc --enable-opencl ${_args} --enable-libvmaf ${_args} \
+		$(vopt_enable x265 libx265) \
+		$(vopt_enable v4l2 libv4l2) \
+		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
+		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		$(vopt_enable dav1d libdav1d) \
+		$(vopt_enable zimg libzimg) \
+		$(vopt_enable webp libwebp) \
+		$(vopt_enable sofa libmysofa) \
+		$(vopt_enable vulkan) \
+		$(vopt_enable drm libdrm) \
+		$(vopt_enable svtav1 libsvtav1) \
+		$(vopt_enable srt libsrt) \
+		$(vopt_enable rist librist) \
+		$(vopt_if nvenc '--enable-nvenc') \
+		$(vopt_if nvdec '--enable-nvdec')
+}
+
+do_build() {
+	make ${makejobs}
+	make doc/ff{mpeg,play}.1
+}
+
+do_install() {
+	make DESTDIR=${DESTDIR} install install-man
+	rm -rf ${DESTDIR}/usr/bin
+}
+
+libavcodec4_package() {
+	short_desc="FFmpeg codec library"
+	pkg_install() {
+		vmove "usr/lib/libavcodec.so.*"
+	}
+}
+
+libavdevice4_package() {
+	short_desc="FFmpeg device handling library"
+	pkg_install() {
+		vmove "usr/lib/libavdevice.so.*"
+	}
+}
+
+libavresample4_package() {
+	short_desc="FFmpeg audio resampling library"
+	pkg_install() {
+		vmove "usr/lib/libavresample.so.*"
+	}
+}
+
+libavformat4_package() {
+	short_desc="FFmpeg file format library"
+	pkg_install() {
+		vmove "usr/lib/libavformat.so.*"
+	}
+}
+
+libavutil4_package() {
+	short_desc="FFmpeg utility library"
+	pkg_install() {
+		vmove "usr/lib/libavutil.so.*"
+	}
+}
+
+libavfilter4_package() {
+	short_desc="FFmpeg audio/video filter library"
+	pkg_install() {
+		vmove "usr/lib/libavfilter.so.*"
+	}
+}
+
+libpostproc4_package() {
+	short_desc="FFmpeg video postprocessing library"
+	pkg_install() {
+		vmove "usr/lib/libpostproc.so.*"
+	}
+}
+
+libswscale4_package() {
+	short_desc="FFmpeg video scaling library"
+	pkg_install() {
+		vmove "usr/lib/libswscale.so.*"
+	}
+}
+
+libswresample4_package() {
+	short_desc="FFmpeg video resampling library"
+	pkg_install() {
+		vmove "usr/lib/libswresample.so.*"
+	}
+}
+
+ffmpeg4-devel_package() {
+	depends="
+		libavcodec4>=${version}_${revision}
+		libavdevice4>=${version}_${revision}
+		libavformat4>=${version}_${revision}
+		libavutil4>=${version}_${revision}
+		libavfilter4>=${version}_${revision}
+		libpostproc4>=${version}_${revision}
+		libswscale4>=${version}_${revision}
+		libswresample4>=${version}_${revision}
+		libavresample4>=${version}_${revision}"
+	short_desc+=" - development files"
+	conflicts="ffmpeg-devel"
+	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
+		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
+		nostrip_files="/usr/lib/libavfilter.a"
+	fi
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.a"
+		vmove "usr/lib/*.so"
+		vmove usr/share/ffmpeg/examples
+		vmove usr/share/man/man3
+	}
+}
diff --git a/srcpkgs/libavcodec4 b/srcpkgs/libavcodec4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavcodec4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavdevice4 b/srcpkgs/libavdevice4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavdevice4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavfilter4 b/srcpkgs/libavfilter4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavfilter4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavformat4 b/srcpkgs/libavformat4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavformat4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavresample4 b/srcpkgs/libavresample4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavutil4 b/srcpkgs/libavutil4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavutil4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libpostproc4 b/srcpkgs/libpostproc4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libpostproc4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswresample4 b/srcpkgs/libswresample4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libswresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswscale4 b/srcpkgs/libswscale4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libswscale4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file

From a2ca35ab323aa9666cadbef9342104081df6ff93 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:04 -0400
Subject: [PATCH 005/109] opencv: update to 4.7.0.

---
 common/shlibs           | 104 ++++++++++++++++++++--------------------
 srcpkgs/opencv/template |   8 ++--
 2 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index e29b7e87b8915c..34ebb185c3ab7b 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2081,58 +2081,58 @@ libcapstone.so.5 capstone-5.0.1_1
 libhavege.so.2 libhaveged-1.9.11_1
 libnih.so.1 libnih-1.0.3_1
 libnih-dbus.so.1 libnih-1.0.3_1
-libopencv_quality.so.406 libopencv-4.6.0_1
-libopencv_reg.so.406 libopencv-4.6.0_1
-libopencv_surface_matching.so.406 libopencv-4.6.0_1
-libopencv_xphoto.so.406 libopencv-4.6.0_1
-libopencv_freetype.so.406 libopencv-4.6.0_1
-libopencv_fuzzy.so.406 libopencv-4.6.0_1
-libopencv_hfs.so.406 libopencv-4.6.0_1
-libopencv_img_hash.so.406 libopencv-4.6.0_1
-libopencv_line_descriptor.so.406 libopencv-4.6.0_1
-libopencv_saliency.so.406 libopencv-4.6.0_1
-libopencv_structured_light.so.406 libopencv-4.6.0_1
-libopencv_aruco.so.406 libopencv-4.6.0_1
-libopencv_bgsegm.so.406 libopencv-4.6.0_1
-libopencv_bioinspired.so.406 libopencv-4.6.0_1
-libopencv_ccalib.so.406 libopencv-4.6.0_1
-libopencv_face.so.406 libopencv-4.6.0_1
-libopencv_tracking.so.406 libopencv-4.6.0_1
-libopencv_xfeatures2d.so.406 libopencv-4.6.0_1
-libopencv_optflow.so.406 libopencv-4.6.0_1
-libopencv_ximgproc.so.406 libopencv-4.6.0_1
-libopencv_plot.so.406 libopencv-4.6.0_1
-libopencv_text.so.406 libopencv-4.6.0_1
-libopencv_ml.so.406 libopencv-4.6.0_1
-libopencv_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn.so.406 libopencv-4.6.0_1
-libopencv_shape.so.406 libopencv-4.6.0_1
-libopencv_stitching.so.406 libopencv-4.6.0_1
-libopencv_photo.so.406 libopencv-4.6.0_1
-libopencv_video.so.406 libopencv-4.6.0_1
-libopencv_calib3d.so.406 libopencv-4.6.0_1
-libopencv_features2d.so.406 libopencv-4.6.0_1
-libopencv_flann.so.406 libopencv-4.6.0_1
-libopencv_highgui.so.406 libopencv-4.6.0_1
-libopencv_videoio.so.406 libopencv-4.6.0_1
-libopencv_imgcodecs.so.406 libopencv-4.6.0_1
-libopencv_imgproc.so.406 libopencv-4.6.0_1
-libopencv_core.so.406 libopencv-4.6.0_1
-libopencv_superres.so.406 libopencv-4.6.0_1
-libopencv_videostab.so.406 libopencv-4.6.0_1
-libopencv_gapi.so.406 libopencv-4.6.0_1
-libopencv_xobjdetect.so.406 libopencv-4.6.0_1
-libopencv_datasets.so.406 libopencv-4.6.0_1
-libopencv_dnn_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn_superres.so.406 libopencv-4.6.0_1
-libopencv_dpm.so.406 libopencv-4.6.0_1
-libopencv_phase_unwrapping.so.406 libopencv-4.6.0_1
-libopencv_stereo.so.406 libopencv-4.6.0_1
-libopencv_rapid.so.406 libopencv-4.6.0_1
-libopencv_intensity_transform.so.406 libopencv-4.6.0_1
-libopencv_alphamat.so.406 libopencv-4.6.0_1
-libopencv_barcode.so.406 libopencv-4.6.0_1
-libopencv_mcc.so.406 libopencv-4.6.0_1
+libopencv_quality.so.407 libopencv-4.7.0_1
+libopencv_reg.so.407 libopencv-4.7.0_1
+libopencv_surface_matching.so.407 libopencv-4.7.0_1
+libopencv_xphoto.so.407 libopencv-4.7.0_1
+libopencv_freetype.so.407 libopencv-4.7.0_1
+libopencv_fuzzy.so.407 libopencv-4.7.0_1
+libopencv_hfs.so.407 libopencv-4.7.0_1
+libopencv_img_hash.so.407 libopencv-4.7.0_1
+libopencv_line_descriptor.so.407 libopencv-4.7.0_1
+libopencv_saliency.so.407 libopencv-4.7.0_1
+libopencv_structured_light.so.407 libopencv-4.7.0_1
+libopencv_aruco.so.407 libopencv-4.7.0_1
+libopencv_bgsegm.so.407 libopencv-4.7.0_1
+libopencv_bioinspired.so.407 libopencv-4.7.0_1
+libopencv_ccalib.so.407 libopencv-4.7.0_1
+libopencv_face.so.407 libopencv-4.7.0_1
+libopencv_tracking.so.407 libopencv-4.7.0_1
+libopencv_xfeatures2d.so.407 libopencv-4.7.0_1
+libopencv_optflow.so.407 libopencv-4.7.0_1
+libopencv_ximgproc.so.407 libopencv-4.7.0_1
+libopencv_plot.so.407 libopencv-4.7.0_1
+libopencv_text.so.407 libopencv-4.7.0_1
+libopencv_ml.so.407 libopencv-4.7.0_1
+libopencv_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn.so.407 libopencv-4.7.0_1
+libopencv_shape.so.407 libopencv-4.7.0_1
+libopencv_stitching.so.407 libopencv-4.7.0_1
+libopencv_photo.so.407 libopencv-4.7.0_1
+libopencv_video.so.407 libopencv-4.7.0_1
+libopencv_calib3d.so.407 libopencv-4.7.0_1
+libopencv_features2d.so.407 libopencv-4.7.0_1
+libopencv_flann.so.407 libopencv-4.7.0_1
+libopencv_highgui.so.407 libopencv-4.7.0_1
+libopencv_videoio.so.407 libopencv-4.7.0_1
+libopencv_imgcodecs.so.407 libopencv-4.7.0_1
+libopencv_imgproc.so.407 libopencv-4.7.0_1
+libopencv_core.so.407 libopencv-4.7.0_1
+libopencv_superres.so.407 libopencv-4.7.0_1
+libopencv_videostab.so.407 libopencv-4.7.0_1
+libopencv_gapi.so.407 libopencv-4.7.0_1
+libopencv_xobjdetect.so.407 libopencv-4.7.0_1
+libopencv_datasets.so.407 libopencv-4.7.0_1
+libopencv_dnn_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn_superres.so.407 libopencv-4.7.0_1
+libopencv_dpm.so.407 libopencv-4.7.0_1
+libopencv_phase_unwrapping.so.407 libopencv-4.7.0_1
+libopencv_stereo.so.407 libopencv-4.7.0_1
+libopencv_rapid.so.407 libopencv-4.7.0_1
+libopencv_intensity_transform.so.407 libopencv-4.7.0_1
+libopencv_alphamat.so.407 libopencv-4.7.0_1
+libopencv_barcode.so.407 libopencv-4.7.0_1
+libopencv_mcc.so.407 libopencv-4.7.0_1
 libuniconf.so.4.6 wvstreams-4.6.1_20
 libwvbase.so.4.6 wvstreams-4.6.1_20
 libwvutils.so.4.6 wvstreams-4.6.1_20
diff --git a/srcpkgs/opencv/template b/srcpkgs/opencv/template
index aea4bfc3a265cf..ce94de9424d18d 100644
--- a/srcpkgs/opencv/template
+++ b/srcpkgs/opencv/template
@@ -1,7 +1,7 @@
 # Template file for 'opencv'
 pkgname=opencv
-version=4.6.0
-revision=6
+version=4.7.0
+revision=1
 create_wrksrc=yes
 build_wrksrc=${pkgname}-${version}
 build_style=cmake
@@ -24,8 +24,8 @@ homepage="https://opencv.org"
 changelog="https://github.com/opencv/opencv/wiki/ChangeLog"
 distfiles="https://github.com/opencv/opencv/archive/${version}.tar.gz
  https://github.com/opencv/opencv_contrib/archive/${version}.tar.gz>contrib.tar.gz"
-checksum="1ec1cba65f9f20fe5a41fda1586e01c70ea0c9a6d7b67c9e13edf0cfe2239277
- 1777d5fd2b59029cf537e5fd6f8aa68d707075822f90bde683fcde086f85f7a7"
+checksum="8df0079cdbe179748a18d44731af62a245a45ebf5085223dc03133954c662973
+ 42df840cf9055e59d0e22c249cfb19f04743e1bdad113d31b1573d3934d62584"
 patch_args="-Np1 -d ${build_wrksrc}"
 # tests hang indenfinitely, even with test data included
 make_check=no

From c754dbe845409d3cee65d0601541b06b2e693188 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 006/109] actiona: revbump for opencv-4.7.0

---
 srcpkgs/actiona/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/actiona/template b/srcpkgs/actiona/template
index cf5f0b7a2ae610..0d899311e6df75 100644
--- a/srcpkgs/actiona/template
+++ b/srcpkgs/actiona/template
@@ -1,7 +1,7 @@
 # Template file for 'actiona'
 pkgname=actiona
 version=3.10.1
-revision=2
+revision=3
 build_style=qmake
 configure_args="PKGCONFIG_OPENCV=opencv4"
 hostmakedepends="pkg-config qt5-plugin-mysql qt5-qmake qt5-host-tools"

From 02bc2ccad4e358b5b930ec2c5707fe7541bf9fec Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 007/109] retroshare: revbump for opencv-4.7.0

---
 srcpkgs/retroshare/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroshare/template b/srcpkgs/retroshare/template
index bb17569277a7f3..49e2c1cbe8a531 100644
--- a/srcpkgs/retroshare/template
+++ b/srcpkgs/retroshare/template
@@ -1,7 +1,7 @@
 # Template file for 'retroshare'
 pkgname=retroshare
 version=0.6.6
-revision=3
+revision=4
 build_style=qmake
 #XXX broadcast feature requires an ancient udp-discovery-cpp which either needs
 # to be fetched+patched (FTBFS) here or packaged :/

From 6b2807291eddf2d7d2f97c00ab8b20bcd050a14f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 008/109] waifu2x-converter-cpp: revbump for opencv-4.7.0

---
 srcpkgs/waifu2x-converter-cpp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waifu2x-converter-cpp/template b/srcpkgs/waifu2x-converter-cpp/template
index 361b8a23b94977..c5ac17eb54ea4c 100644
--- a/srcpkgs/waifu2x-converter-cpp/template
+++ b/srcpkgs/waifu2x-converter-cpp/template
@@ -1,7 +1,7 @@
 # Template file for 'waifu2x-converter-cpp'
 pkgname=waifu2x-converter-cpp
 version=5.2.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DINSTALL_MODELS=ON"
 hostmakedepends="pkg-config"

From 55478e9c36eced0f1a86c1d17e316dbc877e9adf Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:38 -0400
Subject: [PATCH 009/109] vlc: revbump for ffmpeg4

---
 srcpkgs/vlc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/vlc/template b/srcpkgs/vlc/template
index 559b1c4fff339f..fc399f1a6e9bfc 100644
--- a/srcpkgs/vlc/template
+++ b/srcpkgs/vlc/template
@@ -1,7 +1,7 @@
 # Template file for 'vlc'
 pkgname=vlc
 version=3.0.20
-revision=4
+revision=5
 build_style=gnu-configure
 configure_args="--disable-gme --disable-libtar --enable-jack
  --enable-live555 --disable-fluidsynth --enable-dvdread
@@ -25,7 +25,7 @@ lib32disabled=yes
 hostmakedepends="automake libtool pkg-config flex gettext libgcrypt-devel
  live555-devel gettext-devel $(vopt_if lua lua52) $(vopt_if chromecast protobuf)"
 makedepends="
- avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg-devel freefont-ttf
+ avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg4-devel freefont-ttf
  gnutls-devel jack-devel liba52-devel libass-devel libbluray-devel
  libcdio-devel libdca-devel libdvbpsi-devel libdvdnav-devel libmad-devel
  libmatroska-devel libmodplug-devel libmpcdec-devel libmpeg2-devel

From 9ab535b5197b7d81967e65c608fdd14664438238 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:55 -0400
Subject: [PATCH 010/109] osg: revbump for ffmpeg4

---
 srcpkgs/osg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/osg/template b/srcpkgs/osg/template
index 8ef0efc599a1b1..a131ceaf7a867b 100644
--- a/srcpkgs/osg/template
+++ b/srcpkgs/osg/template
@@ -8,7 +8,7 @@ build_helper="qemu"
 configure_args="-DLIB_POSTFIX="
 hostmakedepends="pkg-config xrandr"
 makedepends="MesaLib-devel gtkglext-devel libcurl-devel giflib-devel librsvg-devel
- jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg-devel xine-lib-devel
+ jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg4-devel xine-lib-devel
  SDL2-devel gst-plugins-base1-devel
  $(vopt_if openexr libopenexr-devel)
  $(vopt_if poppler poppler-glib-devel)

From 86f35d6d10ca5f58936987b645d7f08ebafc75d2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:13 -0400
Subject: [PATCH 011/109] xine-lib: revbump for ffmpeg4

---
 srcpkgs/xine-lib/template | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/xine-lib/template b/srcpkgs/xine-lib/template
index 3be4d08eac77a3..ed6194c17d11e8 100644
--- a/srcpkgs/xine-lib/template
+++ b/srcpkgs/xine-lib/template
@@ -1,14 +1,14 @@
 # Template file for 'xine-lib'
 pkgname=xine-lib
-version=1.2.12
-revision=3
+version=1.2.13
+revision=1
 build_style=gnu-configure
 configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
  --disable-oss"
 hostmakedepends="automake gettext-devel libtool pkg-config perl"
 makedepends="
  zlib-devel alsa-lib-devel libxcb-devel libSM-devel libXext-devel libXv-devel
- libXvMC-devel liba52-devel libmad-devel ffmpeg-devel pulseaudio-devel
+ libXvMC-devel liba52-devel libmad-devel ffmpeg4-devel pulseaudio-devel
  jack-devel samba-devel libflac-devel libmodplug-devel libmpcdec-devel
  speex-devel libtheora-devel libvorbis-devel libdca-devel faad2-devel
  libcdio-devel libbluray-devel aalib-devel libcaca-devel libXinerama-devel
@@ -19,7 +19,7 @@ license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="http://www.xine-project.org"
 changelog="https://sourceforge.net/projects/xine/files/xine-lib/${version}/README.txt/view"
 distfiles="${SOURCEFORGE_SITE}/xine/${pkgname}-${version}.tar.xz"
-checksum=d606270468e1540c2a89c0d7f5fdf11e17ecc0c2698cc0bcb1065ff26abee098
+checksum=5f10d6d718a4a51c17ed1b32b031d4f9b80b061e8276535b2be31e5ac4b75e6f
 
 case "$XBPS_TARGET_MACHINE" in
 	i686-musl)

From b22b928b907833a97ee5572be12d921d51e24f10 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 012/109] attract: revbump for ffmpeg6

---
 srcpkgs/attract/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/attract/template b/srcpkgs/attract/template
index e769fb15456217..776cbe4ebd2c93 100644
--- a/srcpkgs/attract/template
+++ b/srcpkgs/attract/template
@@ -1,7 +1,7 @@
 # Template file for 'attract'
 pkgname=attract
 version=2.7.0
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="VERBOSE=1"
 make_use_env=yes

From d1bbae65b0ca433cfcf2e0b440d0742f85494df4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 013/109] aubio: revbump for ffmpeg6

---
 srcpkgs/aubio/patches/ffmpeg5.patch | 25 +++++++++++++++++++++++++
 srcpkgs/aubio/template              |  2 +-
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/aubio/patches/ffmpeg5.patch

diff --git a/srcpkgs/aubio/patches/ffmpeg5.patch b/srcpkgs/aubio/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..aace41a6e6d9a4
--- /dev/null
+++ b/srcpkgs/aubio/patches/ffmpeg5.patch
@@ -0,0 +1,25 @@
+From 8a05420e5dd8c7b8b2447f82dc919765876511b3 Mon Sep 17 00:00:00 2001
+From: Paul Brossier <piem@piem.org>
+Date: Tue, 25 Jan 2022 18:30:27 +0100
+Subject: [PATCH] [source_avcodec] define FF_API_LAVF_AVCTX for libavcodec >
+ 59, thx @berolinux (closes gh-353)
+
+---
+ src/io/source_avcodec.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/io/source_avcodec.c b/src/io/source_avcodec.c
+index e0ae93b5..1421bd9a 100644
+--- a/src/io/source_avcodec.c
++++ b/src/io/source_avcodec.c
+@@ -68,6 +68,10 @@
+ #define AUBIO_AVCODEC_MAX_BUFFER_SIZE AV_INPUT_BUFFER_MIN_SIZE
+ #endif
+ 
++#if LIBAVCODEC_VERSION_MAJOR >= 59
++#define FF_API_LAVF_AVCTX 1
++#endif
++
+ struct _aubio_source_avcodec_t {
+   uint_t hop_size;
+   uint_t samplerate;
diff --git a/srcpkgs/aubio/template b/srcpkgs/aubio/template
index ad1c4b25699178..7d875cc02541a7 100644
--- a/srcpkgs/aubio/template
+++ b/srcpkgs/aubio/template
@@ -1,7 +1,7 @@
 # Template file for 'aubio'
 pkgname=aubio
 version=0.4.9
-revision=1
+revision=2
 build_style=waf3
 # XXX lash, pure and swig support.
 hostmakedepends="pkg-config txt2man"

From 55327fe9ab6049728d6067c33777c07d554acdb4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 014/109] audacious-plugins: revbump for ffmpeg6

---
 .../audacious-plugins/patches/ffmpeg5.patch   | 43 +++++++++++++++++++
 srcpkgs/audacious-plugins/template            |  2 +-
 2 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/audacious-plugins/patches/ffmpeg5.patch

diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg5.patch b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..4e5e34099d71c4
--- /dev/null
+++ b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
@@ -0,0 +1,43 @@
+commit 298aa371c56c2f52c25a33d9bdec4918b11cebdc
+Author: tibequadorian <tibequadorian@posteo.de>
+Date:   Sat Mar 19 18:40:12 2022 +0100
+
+    audacious-plugins: rebuild against ffmpeg-5.0
+
+diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+new file mode 100644
+index 0000000000..617c11215b
+--- /dev/null
++++ b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+@@ -0,0 +1,31 @@
++From f60beb400eeb1e4778bbfd738bc4a4ccef3de539 Mon Sep 17 00:00:00 2001
++From: John Lindgren <john@jlindgren.net>
++Date: Sat, 5 Mar 2022 12:05:34 -0500
++Subject: [PATCH] Fix build with FFmpeg 5.0
++
++---
++ src/ffaudio/ffaudio-core.cc | 4 ++--
++ 1 file changed, 2 insertions(+), 2 deletions(-)
++
++diff --git a/src/ffaudio/ffaudio-core.cc b/src/ffaudio/ffaudio-core.cc
++index 16dc63e3a..a2b95fd6c 100644
++--- a/src/ffaudio/ffaudio-core.cc
+++++ b/src/ffaudio/ffaudio-core.cc
++@@ -274,7 +274,7 @@ static AVInputFormat * get_format_by_content (const char * name, VFSFile & file)
++         AVProbeData d = {name, buf, filled};
++         score = target;
++ 
++-        f = av_probe_input_format2 (& d, true, & score);
+++        f = (AVInputFormat *) av_probe_input_format2 (& d, true, & score);
++         if (f)
++             break;
++ 
++@@ -347,7 +347,7 @@ static bool find_codec (AVFormatContext * c, CodecInfo * cinfo)
++ #endif
++         if (stream && stream->codecpar && stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
++         {
++-            AVCodec * codec = avcodec_find_decoder (stream->codecpar->codec_id);
+++            AVCodec * codec = (AVCodec *) avcodec_find_decoder (stream->codecpar->codec_id);
++ 
++             if (codec)
++             {
diff --git a/srcpkgs/audacious-plugins/template b/srcpkgs/audacious-plugins/template
index 05e53a9adf78ff..4b1968e03de781 100644
--- a/srcpkgs/audacious-plugins/template
+++ b/srcpkgs/audacious-plugins/template
@@ -2,7 +2,7 @@
 #Keep in sync with audacious!
 pkgname=audacious-plugins
 version=4.3.1
-revision=3
+revision=4
 build_style=meson
 configure_args="$(vopt_bool gtk3 gtk) $(vopt_bool gtk3)
  $(vopt_bool qt) $(vopt_bool qt qt6)"

From 11c026024321b955c0dceddd6c092659e2c76dac Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 015/109] audacity: revbump for ffmpeg6

---
 srcpkgs/audacity/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/audacity/template b/srcpkgs/audacity/template
index 7b838119ab2611..84b49305edcef1 100644
--- a/srcpkgs/audacity/template
+++ b/srcpkgs/audacity/template
@@ -1,7 +1,7 @@
 # Template file for 'audacity'
 pkgname=audacity
 version=3.4.2
-revision=1
+revision=2
 build_style=cmake
 build_helper="cmake-wxWidgets-gtk3 qemu"
 configure_args="-Daudacity_use_ffmpeg=loaded -Daudacity_lib_preference=system

From f6527acbaa078055dc8554b4ed22e8735e67dc2c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 016/109] avidemux: revbump for ffmpeg6

---
 srcpkgs/avidemux/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/avidemux/template b/srcpkgs/avidemux/template
index 253a0243e22599..557285982d2b8f 100644
--- a/srcpkgs/avidemux/template
+++ b/srcpkgs/avidemux/template
@@ -1,7 +1,7 @@
 # Template file for 'avidemux'
 pkgname=avidemux
 version=2.8.0
-revision=2
+revision=3
 # Can't be compiled for aarch64, arm* or mips*
 archs="x86_64* i686*"
 hostmakedepends="cmake pkg-config qt5-host-tools qt5-devel tar yasm"

From b52d6c60e30082ac6cc88035e00f4e2f8f9c0e7c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 017/109] blender: revbump for ffmpeg6

---
 srcpkgs/blender/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index 68787b76a26c18..e2e090e6dfa41c 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -1,7 +1,7 @@
 # Template file for 'blender'
 pkgname=blender
 version=4.0.2
-revision=2
+revision=3
 archs="x86_64* ppc64*"
 build_style="cmake"
 pycompile_dirs="usr/share/blender/${version%.*}/scripts"

From 22cd01ed7439e224931ed184c06f4bf164aaf2a1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 018/109] cantata: revbump for ffmpeg6

---
 srcpkgs/cantata/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cantata/template b/srcpkgs/cantata/template
index 4b417d80d5c2da..8a90aaa4c07a2a 100644
--- a/srcpkgs/cantata/template
+++ b/srcpkgs/cantata/template
@@ -1,7 +1,7 @@
 # Template file for 'cantata'
 pkgname=cantata
 version=2.5.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools qt5-tools"
 makedepends="qt5-devel qt5-tools-devel qt5-svg-devel qt5-xmlpatterns-devel

From 86a5c7f4c9a11d8df972baa397ada65b58fbae49 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 019/109] ccextractor: revbump for ffmpeg6

---
 ...5-and-tesseract-5-compatibility-1479.patch | 168 ++++++++++++++++++
 srcpkgs/ccextractor/template                  |   2 +-
 2 files changed, 169 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ccextractor/patches/0001-fix-ffmpeg-5-and-tesseract-5-compatibility-1479.patch

diff --git a/srcpkgs/ccextractor/patches/0001-fix-ffmpeg-5-and-tesseract-5-compatibility-1479.patch b/srcpkgs/ccextractor/patches/0001-fix-ffmpeg-5-and-tesseract-5-compatibility-1479.patch
new file mode 100644
index 00000000000000..bcab4890554b9a
--- /dev/null
+++ b/srcpkgs/ccextractor/patches/0001-fix-ffmpeg-5-and-tesseract-5-compatibility-1479.patch
@@ -0,0 +1,168 @@
+From b1cbfcea9b9c687143bf0d80bc179b563e99d025 Mon Sep 17 00:00:00 2001
+From: Prateek Sunal <prtksunal@gmail.com>
+Date: Thu, 9 Mar 2023 01:44:53 +0530
+Subject: [PATCH] fix: ffmpeg 5 and tesseract 5 compatibility (#1479)
+
+* fix: replace deprecated `codec` property with `codecpar`
+
+* fix: replace deprecated method `avcodec_decode_video2` with `avcodec_receive_frame` and `avcodec_send_packet`
+
+* Update CHANGES.TXT
+
+* fix: remove deprecated `av_register_all` function
+
+* fix: formatting
+
+* fix: add support for tesseract 5
+
+* fix: tesseract v5
+
+* fix: hardsubx codec context error
+
+* fix: lint const warning
+---
+ docs/CHANGES.TXT               |  1 +
+ src/lib_ccx/ffmpeg_intgr.c     |  7 +++---
+ src/lib_ccx/hardsubx.c         | 25 ++++++++++++------
+ src/lib_ccx/hardsubx_decoder.c | 27 ++++++++------------
+ src/lib_ccx/ocr.c              | 46 ++++++++++++----------------------
+ 5 files changed, 47 insertions(+), 59 deletions(-)
+
+diff --git a/src/lib_ccx/ffmpeg_intgr.c b/src/lib_ccx/ffmpeg_intgr.c
+index be988890..e6f21e20 100644
+--- a/src/lib_ccx/ffmpeg_intgr.c
++++ b/src/lib_ccx/ffmpeg_intgr.c
+@@ -66,7 +66,6 @@ void *init_ffmpeg(const char *path)
+ 	struct ffmpeg_ctx *ctx;
+ 	AVCodec *dec = NULL;
+ 	avcodec_register_all();
+-	av_register_all();
+ 
+ 	if (ccx_options.debug_mask & CCX_DMT_VERBOSE)
+ 		av_log_set_level(AV_LOG_INFO);
+@@ -133,7 +132,6 @@ int ff_get_ccframe(void *arg, unsigned char *data, int maxlen)
+ 	struct ffmpeg_ctx *ctx = arg;
+ 	int len = 0;
+ 	int ret = 0;
+-	int got_frame;
+ 	AVPacket packet;
+ 
+ 	ret = av_read_frame(ctx->ifmt, &packet);
+@@ -151,12 +149,13 @@ int ff_get_ccframe(void *arg, unsigned char *data, int maxlen)
+ 		return AVERROR(EAGAIN);
+ 	}
+ 
+-	ret = avcodec_decode_video2(ctx->dec_ctx, ctx->frame, &got_frame, &packet);
++	avcodec_send_packet(ctx->codec_ctx, &ctx->packet);
++	ret = avcodec_receive_frame(ctx->dec_ctx, ctx->frame);
+ 	if (ret < 0)
+ 	{
+ 		av_log(NULL, AV_LOG_ERROR, "unable to decode packet\n");
+ 	}
+-	else if (!got_frame)
++	else if (ret != 0)
+ 	{
+ 		return AVERROR(EAGAIN);
+ 	}
+diff --git a/src/lib_ccx/hardsubx.c b/src/lib_ccx/hardsubx.c
+index 411377f9..fb844c91 100644
+--- a/src/lib_ccx/hardsubx.c
++++ b/src/lib_ccx/hardsubx.c
+@@ -12,9 +12,6 @@
+
+ int hardsubx_process_data(struct lib_hardsubx_ctx *ctx)
+ {
+-	// Get the required media attributes and initialize structures
+-	av_register_all();
+-
+ 	if (avformat_open_input(&ctx->format_ctx, ctx->inputfile[0], NULL, NULL) != 0)
+ 	{
+ 		fatal(EXIT_READ_ERROR, "Error reading input file!\n");
+@@ -32,7 +29,7 @@
+ 	ctx->video_stream_id = -1;
+ 	for (int i = 0; i < ctx->format_ctx->nb_streams; i++)
+ 	{
+-		if (ctx->format_ctx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO)
++		if (ctx->format_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
+ 		{
+ 			ctx->video_stream_id = i;
+ 			break;
+@@ -43,8 +40,21 @@
+ 		fatal(EXIT_READ_ERROR, "Video Stream not found!\n");
+ 	}
+
+-	ctx->codec_ctx = ctx->format_ctx->streams[ctx->video_stream_id]->codec;
+-	ctx->codec = avcodec_find_decoder(ctx->codec_ctx->codec_id);
++	ctx->codec_ctx = avcodec_alloc_context3(NULL);
++	if (!ctx->codec_ctx)
++	{
++		    fatal(EXIT_NOT_ENOUGH_MEMORY, "Could not allocate codec context!\n");
++	}
++
++	// Assign codec parameters to codec context
++	if (avcodec_parameters_to_context(ctx->codec_ctx, ctx->format_ctx->streams[ctx->video_stream_id]->codecpar) < 0)
++	{
++		    fatal(EXIT_READ_ERROR, "Could not initialize codec context!\n");
++	}
++
++	// Find decoder for the codec context
++	ctx->codec = (AVCodec *)avcodec_find_decoder(ctx->codec_ctx->codec_id);
++
+ 	if (ctx->codec == NULL)
+ 	{
+ 		fatal(EXIT_READ_ERROR, "Input codec is not supported!\n");
+diff --git a/src/lib_ccx/hardsubx_decoder.c b/src/lib_ccx/hardsubx_decoder.c
+index bd9b0980..b5dfaec4 100644
+--- a/src/lib_ccx/hardsubx_decoder.c
++++ b/src/lib_ccx/hardsubx_decoder.c
+@@ -371,7 +371,6 @@
+ int hardsubx_process_frames_tickertext(struct lib_hardsubx_ctx *ctx, struct encoder_ctx *enc_ctx)
+ {
+ 	// Search for ticker text at the bottom of the screen, such as in Russia TV1 or stock prices
+-	int got_frame;
+ 	int cur_sec = 0, total_sec, progress;
+ 	int frame_number = 0;
+ 	char *ticker_text = NULL;
+@@ -382,8 +381,8 @@
+ 		{
+ 			frame_number++;
+ 			//Decode the video stream packet
+-			avcodec_decode_video2(ctx->codec_ctx, ctx->frame, &got_frame, &ctx->packet);
+-			if (got_frame && frame_number % 1000 == 0)
++      avcodec_send_packet(ctx->codec_ctx, &ctx->packet);
++      if (avcodec_receive_frame(ctx->codec_ctx, ctx->frame) == 0 && frame_number % 1000 == 0)
+ 			{
+ 				// sws_scale is used to convert the pixel format to RGB24 from all other cases
+ 				sws_scale(
+@@ -434,9 +433,8 @@
+ 			frame_number++;
+
+ 			//Decode the video stream packet
+-			avcodec_decode_video2(ctx->codec_ctx, ctx->frame, &got_frame, &ctx->packet);
+-
+-			if (got_frame && frame_number % 25 == 0)
++			avcodec_send_packet(ctx->codec_ctx, &ctx->packet);
++      if (avcodec_receive_frame(ctx->codec_ctx, ctx->frame) == 0 && frame_number % 25 == 0)
+ 			{
+ 				float diff = (float)convert_pts_to_ms(ctx->packet.pts - prev_packet_pts, ctx->format_ctx->streams[ctx->video_stream_id]->time_base);
+ 				if (fabsf(diff) < 1000 * ctx->min_sub_duration) //If the minimum duration of a subtitle line is exceeded, process packet
+@@ -548,7 +546,6 @@
+ {
+ 	// Do a binary search over the input video for faster processing
+ 	// printf("Duration: %d\n", (int)ctx->format_ctx->duration);
+-	int got_frame;
+ 	int seconds_time = 0;
+ 	for (seconds_time = 0; seconds_time < 20; seconds_time++)
+ 	{
+@@ -568,8 +565,9 @@
+ 			{
+ 				if (ctx->packet.stream_index == ctx->video_stream_id)
+ 				{
+-					avcodec_decode_video2(ctx->codec_ctx, ctx->frame, &got_frame, &ctx->packet);
+-					if (got_frame)
++          avcodec_send_packet(ctx->codec_ctx, &ctx->packet);
++          if (avcodec_receive_frame(ctx->codec_ctx, ctx->frame) == 0)
++
+ 					{
+ 						// printf("%d\n", seek_time);
+ 						if (ctx->packet.pts < seek_time)
diff --git a/srcpkgs/ccextractor/template b/srcpkgs/ccextractor/template
index 84059ffd02398a..a670758bcbe41b 100644
--- a/srcpkgs/ccextractor/template
+++ b/srcpkgs/ccextractor/template
@@ -1,7 +1,7 @@
 # Template file for 'ccextractor'
 pkgname=ccextractor
 version=0.93
-revision=2
+revision=3
 build_wrksrc="linux"
 build_style=gnu-configure
 configure_args="--enable-ocr --enable-hardsubx"

From e97420ae202fa0c2203efc3c918c3a2a19ddb0b2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 020/109] chromaprint: revbump for ffmpeg6

---
 srcpkgs/chromaprint/patches/ffmpeg5.patch | 569 ++++++++++++++++++++++
 srcpkgs/chromaprint/template              |   2 +-
 2 files changed, 570 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromaprint/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromaprint/patches/ffmpeg5.patch b/srcpkgs/chromaprint/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..a9fd307a23c8a4
--- /dev/null
+++ b/srcpkgs/chromaprint/patches/ffmpeg5.patch
@@ -0,0 +1,569 @@
+From 8ccad6937177b1b92e40ab8f4447ea27bac009a7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= <lalinsky@gmail.com>
+Date: Fri, 4 Nov 2022 21:47:38 +0100
+Subject: [PATCH] Use FFmpeg 5.x (#120)
+
+* Use FFmpeg 5.1.2 for CI builds
+
+* Build on Ubuntu 20.04
+
+* Upgrade code to FFmpeg 5.x APIs
+
+* Only set FFmpeg include dirs if building tools
+
+* No longer needed
+
+* Use ubuntu 20.04
+---
+ .github/workflows/build.yml                   |   6 +-
+ CMakeLists.txt                                |  16 --
+ package/build.sh                              |   4 +-
+ src/audio/ffmpeg_audio_processor.h            |   2 -
+ src/audio/ffmpeg_audio_processor_avresample.h |  72 -------
+ src/audio/ffmpeg_audio_processor_swresample.h |  18 +-
+ src/audio/ffmpeg_audio_reader.h               | 197 +++++++++---------
+ tests/CMakeLists.txt                          |   6 +
+ 8 files changed, 122 insertions(+), 199 deletions(-)
+ delete mode 100644 src/audio/ffmpeg_audio_processor_avresample.h
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index f8d6a32..4da2405 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -84,9 +84,6 @@ find_package(FFmpeg)
+ if(FFMPEG_LIBRARIES)
+ 	cmake_push_check_state(RESET)
+ 	set(CMAKE_REQUIRED_LIBRARIES ${FFMPEG_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -lm)
+-	check_function_exists(av_packet_unref HAVE_AV_PACKET_UNREF)
+-	check_function_exists(av_frame_alloc HAVE_AV_FRAME_ALLOC)
+-	check_function_exists(av_frame_free HAVE_AV_FRAME_FREE)
+ 	cmake_pop_check_state()
+ endif()
+
+@@ -163,14 +160,11 @@ message(STATUS "Using ${FFT_LIB} for FFT calculations")
+ if(NOT AUDIO_PROCESSOR_LIB)
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+ 		set(AUDIO_PROCESSOR_LIB "swresample")
+-	elseif(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(AUDIO_PROCESSOR_LIB "avresample")
+ 	endif()
+ endif()
+
+ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE OFF)
+ 		set(USE_SWRESAMPLE ON)
+ 		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBSWRESAMPLE_LIBRARIES})
+ 		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBSWRESAMPLE_INCLUDE_DIRS})
+@@ -178,16 +172,6 @@ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+ 	endif()
+ 	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+-elseif(AUDIO_PROCESSOR_LIB STREQUAL "avresample")
+-	if(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE ON)
+-		set(USE_SWRESAMPLE OFF)
+-		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBAVRESAMPLE_LIBRARIES})
+-		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBAVRESAMPLE_INCLUDE_DIRS})
+-	else()
+-		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+-	endif()
+-	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+ else()
+ 	message(STATUS "Building without audio conversion support, please install FFmpeg with libswresample")
+ endif()
+diff --git a/package/build.sh b/package/build.sh
+index da631ae..b41d36e 100755
+--- a/package/build.sh
++++ b/package/build.sh
+@@ -7,8 +7,8 @@ set -eux
+
+ BASE_DIR=$(cd $(dirname $0)/.. && pwd)
+
+-FFMPEG_VERSION=4.4.1
+-FFMPEG_BUILD_TAG=v4.4.1-1
++FFMPEG_VERSION=5.1.2
++FFMPEG_BUILD_TAG=v${FFMPEG_VERSION}-1
+
+ TMP_BUILD_DIR=$BASE_DIR/$(mktemp -d build.XXXXXXXX)
+ trap 'rm -rf $TMP_BUILD_DIR' EXIT
+diff --git a/src/audio/ffmpeg_audio_processor.h b/src/audio/ffmpeg_audio_processor.h
+index 7628fc7..39f4f6d 100644
+--- a/src/audio/ffmpeg_audio_processor.h
++++ b/src/audio/ffmpeg_audio_processor.h
+@@ -10,8 +10,6 @@
+
+ #if defined(USE_SWRESAMPLE)
+ #include "audio/ffmpeg_audio_processor_swresample.h"
+-#elif defined(USE_AVRESAMPLE)
+-#include "audio/ffmpeg_audio_processor_avresample.h"
+ #else
+ #error "no audio processing library"
+ #endif
+diff --git a/src/audio/ffmpeg_audio_processor_avresample.h b/src/audio/ffmpeg_audio_processor_avresample.h
+deleted file mode 100644
+index bd85f92..0000000
+--- a/src/audio/ffmpeg_audio_processor_avresample.h
++++ /dev/null
+@@ -1,72 +0,0 @@
+-// Copyright (C) 2016  Lukas Lalinsky
+-// Distributed under the MIT license, see the LICENSE file for details.
+-
+-#ifndef CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-#define CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-
+-extern "C" {
+-#include <libavresample/avresample.h>
+-}
+-
+-namespace chromaprint {
+-
+-class FFmpegAudioProcessor {
+-public:
+-	FFmpegAudioProcessor() {
+-		m_resample_ctx = avresample_alloc_context();
+-	}
+-
+-	~FFmpegAudioProcessor() {
+-		avresample_free(&m_resample_ctx);
+-	}
+-
+-	void SetCompatibleMode() {
+-		av_opt_set_int(m_resample_ctx, "filter_size", 16, 0);
+-		av_opt_set_int(m_resample_ctx, "phase_shift", 8, 0);
+-		av_opt_set_int(m_resample_ctx, "linear_interp", 1, 0);
+-		av_opt_set_double(m_resample_ctx, "cutoff", 0.8, 0);
+-	}
+-
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "in_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_rate", sample_rate, 0);
+-	}
+-
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "out_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_rate, 0);
+-	}
+-
+-	int Init() {
+-		return avresample_open(m_resample_ctx);
+-	}
+-
+-	int Convert(uint8_t **out, int out_count, const uint8_t **in, int in_count) {
+-		return avresample_convert(m_resample_ctx, out, 0, out_count, (uint8_t **) in, 0, in_count);
+-	}
+-
+-	int Flush(uint8_t **out, int out_count) {
+-		return avresample_read(m_resample_ctx, out, out_count);
+-	}
+-
+-private:
+-	AVAudioResampleContext *m_resample_ctx = nullptr;
+-};
+-
+-}; // namespace chromaprint
+-
+-#endif
+diff --git a/src/audio/ffmpeg_audio_processor_swresample.h b/src/audio/ffmpeg_audio_processor_swresample.h
+index b86266b..b1d4bea 100644
+--- a/src/audio/ffmpeg_audio_processor_swresample.h
++++ b/src/audio/ffmpeg_audio_processor_swresample.h
+@@ -28,30 +28,28 @@ public:
+ 		av_opt_set_double(m_swr_ctx, "cutoff", 0.8, 0);
+ 	}
+
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "icl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "ich", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetInputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "in_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "isf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "in_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "isr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "in_sample_rate", sample_rate, 0);
+ 	}
+
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "ocl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "och", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetOutputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "out_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "osf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "out_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "osr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "out_sample_rate", sample_rate, 0);
+ 	}
+
+ 	int Init() {
+diff --git a/src/audio/ffmpeg_audio_reader.h b/src/audio/ffmpeg_audio_reader.h
+index 5550164..1c6b346 100644
+--- a/src/audio/ffmpeg_audio_reader.h
++++ b/src/audio/ffmpeg_audio_reader.h
+@@ -62,7 +62,7 @@ public:
+ 	bool Read(const int16_t **data, size_t *size);
+
+ 	bool IsOpen() const { return m_opened; }
+-	bool IsFinished() const { return m_finished && !m_got_frame; }
++	bool IsFinished() const { return !m_has_more_packets && !m_has_more_frames; }
+
+ 	std::string GetError() const { return m_error; }
+ 	int GetErrorCode() const { return m_error_code; }
+@@ -74,20 +74,19 @@ private:
+ 	uint8_t *m_convert_buffer[1] = { nullptr };
+ 	int m_convert_buffer_nb_samples = 0;
+
+-	AVInputFormat *m_input_fmt = nullptr;
++	const AVInputFormat *m_input_fmt = nullptr;
+ 	AVDictionary *m_input_opts = nullptr;
+
+ 	AVFormatContext *m_format_ctx = nullptr;
+ 	AVCodecContext *m_codec_ctx = nullptr;
+-	AVFrame *m_frame = nullptr;
+ 	int m_stream_index = -1;
+ 	std::string m_error;
+ 	int m_error_code = 0;
+-	bool m_finished = false;
+ 	bool m_opened = false;
+-	int m_got_frame = 0;
+-	AVPacket m_packet;
+-	AVPacket m_packet0;
++	bool m_has_more_packets = true;
++	bool m_has_more_frames = true;
++	AVPacket *m_packet = nullptr;
++	AVFrame *m_frame = nullptr;
+
+ 	int m_output_sample_rate = 0;
+ 	int m_output_channels = 0;
+@@ -98,19 +97,12 @@ private:
+
+ inline FFmpegAudioReader::FFmpegAudioReader() {
+ 	av_log_set_level(AV_LOG_QUIET);
+-
+-	av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
+ }
+
+ inline FFmpegAudioReader::~FFmpegAudioReader() {
+ 	Close();
+ 	av_dict_free(&m_input_opts);
+ 	av_freep(&m_convert_buffer[0]);
+-	av_packet_unref(&m_packet0);
+ }
+
+ inline bool FFmpegAudioReader::SetInputFormat(const char *name) {
+@@ -135,11 +127,10 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ 	Close();
+
+-    av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
++	m_packet = av_packet_alloc();
++	if (!m_packet) {
++		return false;
++	}
+
+ 	ret = avformat_open_input(&m_format_ctx, file_name.c_str(), m_input_fmt, &m_input_opts);
+ 	if (ret < 0) {
+@@ -153,26 +144,31 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		return false;
+ 	}
+
+-	AVCodec *codec;
++	const AVCodec *codec;
+ 	ret = av_find_best_stream(m_format_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &codec, 0);
+ 	if (ret < 0) {
+ 		SetError("Could not find any audio stream in the file", ret);
+ 		return false;
+ 	}
+ 	m_stream_index = ret;
++	auto stream = m_format_ctx->streams[m_stream_index];
+
+-	m_codec_ctx = m_format_ctx->streams[m_stream_index]->codec;
++	m_codec_ctx = avcodec_alloc_context3(codec);
+ 	m_codec_ctx->request_sample_fmt = AV_SAMPLE_FMT_S16;
+
++	ret = avcodec_parameters_to_context(m_codec_ctx, stream->codecpar);
++	if (ret < 0) {
++		SetError("Could not copy the stream parameters", ret);
++		return false;
++	}
++
+ 	ret = avcodec_open2(m_codec_ctx, codec, nullptr);
+ 	if (ret < 0) {
+ 		SetError("Could not open the codec", ret);
+ 		return false;
+ 	}
+
+-	if (!m_codec_ctx->channel_layout) {
+-		m_codec_ctx->channel_layout = av_get_default_channel_layout(m_codec_ctx->channels);
+-	}
++	av_dump_format(m_format_ctx, 0, "foo", 0);
+
+ 	m_frame = av_frame_alloc();
+ 	if (!m_frame) {
+@@ -183,19 +179,23 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		m_output_sample_rate = m_codec_ctx->sample_rate;
+ 	}
+
+-	if (!m_output_channels) {
+-		m_output_channels = m_codec_ctx->channels;
++	AVChannelLayout output_channel_layout;
++	if (m_output_channels) {
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
++	} else {
++		m_output_channels = m_codec_ctx->ch_layout.nb_channels;
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
+ 	}
+
+-	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
++	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->ch_layout.nb_channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
+ 		m_converter.reset(new FFmpegAudioProcessor());
+ 		m_converter->SetCompatibleMode();
+ 		m_converter->SetInputSampleFormat(m_codec_ctx->sample_fmt);
+ 		m_converter->SetInputSampleRate(m_codec_ctx->sample_rate);
+-		m_converter->SetInputChannelLayout(m_codec_ctx->channel_layout);
++		m_converter->SetInputChannelLayout(&(m_codec_ctx->ch_layout));
+ 		m_converter->SetOutputSampleFormat(AV_SAMPLE_FMT_S16);
+ 		m_converter->SetOutputSampleRate(m_output_sample_rate);
+-		m_converter->SetOutputChannelLayout(av_get_default_channel_layout(m_output_channels));
++		m_converter->SetOutputChannelLayout(&output_channel_layout);
+ 		auto ret = m_converter->Init();
+ 		if (ret != 0) {
+ 			SetError("Could not create an audio converter instance", ret);
+@@ -203,10 +203,11 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		}
+ 	}
+
++	av_channel_layout_uninit(&output_channel_layout);
++
+ 	m_opened = true;
+-	m_finished = false;
+-	m_got_frame = 0;
+-	m_nb_packets = 0;
++	m_has_more_packets = true;
++	m_has_more_frames = true;
+ 	m_decode_error = 0;
+
+ 	return true;
+@@ -214,6 +215,7 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ inline void FFmpegAudioReader::Close() {
+ 	av_frame_free(&m_frame);
++	av_packet_free(&m_packet);
+
+ 	m_stream_index = -1;
+
+@@ -252,91 +254,98 @@ inline bool FFmpegAudioReader::Read(const int16_t **data, size_t *size) {
+ 		return false;
+ 	}
+
++	*data = nullptr;
++	*size = 0;
++
+ 	int ret;
++	bool needs_packet = false;
+ 	while (true) {
+-		while (m_packet.size <= 0) {
+-			av_packet_unref(&m_packet0);
+-			av_init_packet(&m_packet);
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			ret = av_read_frame(m_format_ctx, &m_packet);
++		while (needs_packet && m_packet->size == 0) {
++			ret = av_read_frame(m_format_ctx, m_packet);
+ 			if (ret < 0) {
+ 				if (ret == AVERROR_EOF) {
+-					m_finished = true;
++					needs_packet = false;
++					m_has_more_packets = false;
+ 					break;
+-				} else {
++				}
++				SetError("Error reading from the audio source", ret);
++				return false;
++			}
++			if (m_packet->stream_index == m_stream_index) {
++				needs_packet = false;
++			} else {
++				av_packet_unref(m_packet);
++			}
++		}
++
++		if (m_packet->size != 0) {
++			ret = avcodec_send_packet(m_codec_ctx, m_packet);
++			if (ret < 0) {
++				if (ret != AVERROR(EAGAIN)) {
+ 					SetError("Error reading from the audio source", ret);
+ 					return false;
+ 				}
+-			}
+-			m_packet0 = m_packet;
+-			if (m_packet.stream_index != m_stream_index) {
+-				m_packet.data = nullptr;
+-				m_packet.size = 0;
+ 			} else {
+-				m_nb_packets++;
++				av_packet_unref(m_packet);
+ 			}
+ 		}
+
+-		ret = avcodec_decode_audio4(m_codec_ctx, m_frame, &m_got_frame, &m_packet);
++		ret = avcodec_receive_frame(m_codec_ctx, m_frame);
+ 		if (ret < 0) {
+-			if (m_decode_error) {
+-				SetError("Error decoding audio frame", m_decode_error);
+-				return false;
++			if (ret == AVERROR_EOF) {
++				m_has_more_frames = false;
++			} else if (ret == AVERROR(EAGAIN)) {
++				if (m_has_more_packets) {
++					needs_packet = true;
++					continue;
++				} else {
++					m_has_more_frames = false;
++				}
+ 			}
+-			m_decode_error = ret;
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			continue;
++			SetError("Error decoding the audio source", ret);
++			return false;
+ 		}
+
+-		break;
+-	}
+-
+-	m_decode_error = 0;
+-
+-	const int decoded = std::min(ret, m_packet.size);
+-	m_packet.data += decoded;
+-	m_packet.size -= decoded;
+-
+-	if (m_got_frame) {
+-		if (m_converter) {
+-			if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
+-				int linsize;
+-				av_freep(&m_convert_buffer[0]);
+-				m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
+-				ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
+-				if (ret < 0) {
+-					SetError("Couldn't allocate audio converter buffer", ret);
++		if (m_frame->nb_samples > 0) {
++			if (m_converter) {
++				if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
++					int linsize;
++					av_freep(&m_convert_buffer[0]);
++					m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
++					ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->ch_layout.nb_channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
++					if (ret < 0) {
++						SetError("Couldn't allocate audio converter buffer", ret);
++						return false;
++					}
++				}
++				auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
++				if (nb_samples < 0) {
++					SetError("Couldn't convert audio", ret);
+ 					return false;
+ 				}
+-			}
+-			auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			}
+-			*data = (const int16_t *) m_convert_buffer[0];
+-			*size = nb_samples;
+-		} else {
+-			*data = (const int16_t *) m_frame->data[0];
+-			*size = m_frame->nb_samples;
+-		}
+-	} else {
+-		if (m_finished && m_converter) {
+-			auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			} else if (nb_samples > 0) {
+-				m_got_frame = 1;
+ 				*data = (const int16_t *) m_convert_buffer[0];
+ 				*size = nb_samples;
++			} else {
++				*data = (const int16_t *) m_frame->data[0];
++				*size = m_frame->nb_samples;
++			}
++		} else {
++			if (m_converter) {
++				if (IsFinished()) {
++					auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
++					if (nb_samples < 0) {
++						SetError("Couldn't convert audio", ret);
++						return false;
++					} else if (nb_samples > 0) {
++						*data = (const int16_t *) m_convert_buffer[0];
++						*size = nb_samples;
++					}
++				}
+ 			}
+ 		}
+-	}
+
+-	return true;
++		return true;
++	}
+ }
+
+ inline void FFmpegAudioReader::SetError(const char *message, int errnum) {
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index a2b517b..123e643 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -38,6 +38,12 @@ set(SRCS
+
+ if(BUILD_TOOLS)
+ 	set(SRCS ${SRCS} ../src/audio/ffmpeg_audio_reader_test.cpp)
++    include_directories(
++        ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}
++        ${AUDIO_PROCESSOR_INCLUDE_DIRS}
++    )
+ 	link_libraries(fpcalc_libs)
+ endif()
+
+-- 
+2.38.1
+
+
diff --git a/srcpkgs/chromaprint/template b/srcpkgs/chromaprint/template
index 7ef7838949f3a3..1f7bbc70a22c80 100644
--- a/srcpkgs/chromaprint/template
+++ b/srcpkgs/chromaprint/template
@@ -1,7 +1,7 @@
 # Template file for 'chromaprint'
 pkgname=chromaprint
 version=1.5.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DBUILD_TOOLS=ON"
 make_check_target="check"

From 9a6bf77d706d70f8b890b4633e89b16812d3599a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 021/109] chromium: revbump for ffmpeg6

---
 srcpkgs/chromium/patches/ffmpeg5.patch | 47 ++++++++++++++++++++++++++
 srcpkgs/chromium/template              |  2 +-
 2 files changed, 48 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..24e2da38e34ca2
--- /dev/null
+++ b/srcpkgs/chromium/patches/ffmpeg5.patch
@@ -0,0 +1,47 @@
+--- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
++++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
+@@ -92,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+-  if (stream->start_time != kNoFFmpegTimestamp)
++  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -1597,7 +1585,7 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+@@ -1618,7 +1606,7 @@
+     if (stream->type() != DemuxerStream::VIDEO)
+       continue;
+ 
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+ 
+     if (!stream->IsEnabled())
diff --git a/srcpkgs/chromium/template b/srcpkgs/chromium/template
index 53981f7cd367f8..b462de56fe3bf5 100644
--- a/srcpkgs/chromium/template
+++ b/srcpkgs/chromium/template
@@ -2,7 +2,7 @@
 pkgname=chromium
 # See https://chromiumdash.appspot.com/releases?platform=Linux for the latest version
 version=122.0.6261.94
-revision=1
+revision=2
 archs="i686* x86_64* aarch64* armv7l*"
 hostmakedepends="
  $(vopt_if clang "clang17 lld17 llvm17 compiler-rt")

From 0ce282418f9f8fb893e6a2064992809c01bbe08f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 022/109] cmus: revbump for ffmpeg6

---
 srcpkgs/chromium/patches/ffmpeg5.patch | 47 --------------------------
 srcpkgs/cmus/patches/ffmpeg6.patch     | 12 +++++++
 srcpkgs/cmus/template                  |  2 +-
 3 files changed, 13 insertions(+), 48 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch
 create mode 100644 srcpkgs/cmus/patches/ffmpeg6.patch

diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
deleted file mode 100644
index 24e2da38e34ca2..00000000000000
--- a/srcpkgs/chromium/patches/ffmpeg5.patch
+++ /dev/null
@@ -1,47 +0,0 @@
---- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
-+++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
-@@ -92,24 +92,12 @@
- 
- static base::TimeDelta ExtractStartTime(AVStream* stream) {
-   // The default start time is zero.
--  base::TimeDelta start_time;
-+  base::TimeDelta start_time = kNoTimestamp;
- 
-   // First try to use  the |start_time| value as is.
--  if (stream->start_time != kNoFFmpegTimestamp)
-+  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
-     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
- 
--  // Next try to use the first DTS value, for codecs where we know PTS == DTS
--  // (excludes all H26x codecs). The start time must be returned in PTS.
--  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
--      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
--      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
--      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
--    const base::TimeDelta first_pts =
--        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
--    if (first_pts < start_time)
--      start_time = first_pts;
--  }
--
-   return start_time;
- }
- 
-@@ -1597,7 +1585,7 @@
-   for (const auto& stream : streams_) {
-     if (!stream || stream->IsEnabled() != enabled)
-       continue;
--    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
-+    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
-       continue;
-     if (!lowest_start_time_stream ||
-         stream->start_time() < lowest_start_time_stream->start_time()) {
-@@ -1618,7 +1606,7 @@
-     if (stream->type() != DemuxerStream::VIDEO)
-       continue;
- 
--    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
-+    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
-       continue;
- 
-     if (!stream->IsEnabled())
diff --git a/srcpkgs/cmus/patches/ffmpeg6.patch b/srcpkgs/cmus/patches/ffmpeg6.patch
new file mode 100644
index 00000000000000..ffa95ab811101b
--- /dev/null
+++ b/srcpkgs/cmus/patches/ffmpeg6.patch
@@ -0,0 +1,12 @@
+--- a/ip/ffmpeg.c
++++ b/ip/ffmpeg.c
+@@ -202,9 +202,6 @@ static int ffmpeg_open(struct input_plugin_data *ip_data)
+ 			break;
+ 		}
+ 
+-		if (codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+-			cc->flags |= AV_CODEC_FLAG_TRUNCATED;
+-
+ 		if (avcodec_open2(cc, codec, NULL) < 0) {
+ 			d_print("could not open codec: %d, %s\n", cc->codec_id, avcodec_get_name(cc->codec_id));
+ 			err = -IP_ERROR_UNSUPPORTED_FILE_TYPE;
diff --git a/srcpkgs/cmus/template b/srcpkgs/cmus/template
index 0d1436744f1b2c..a6e4b4fa86cb83 100644
--- a/srcpkgs/cmus/template
+++ b/srcpkgs/cmus/template
@@ -1,7 +1,7 @@
 # Template file for 'cmus'
 pkgname=cmus
 version=2.10.0
-revision=3
+revision=4
 build_style=configure
 configure_args="prefix=/usr LD=$CC"
 hostmakedepends="pkg-config"

From 2b598e6fb5eaaa4e2778adc2598f03e220cee98f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 023/109] cyanrip: revbump for ffmpeg6

---
 srcpkgs/cyanrip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cyanrip/template b/srcpkgs/cyanrip/template
index 9796e3461601a7..5db30e020d17ee 100644
--- a/srcpkgs/cyanrip/template
+++ b/srcpkgs/cyanrip/template
@@ -1,7 +1,7 @@
 # Template file for 'cyanrip'
 pkgname=cyanrip
 version=0.9.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config"
 makedepends="ffmpeg-devel libcdio-devel libcdio-paranoia-devel libcurl-devel libmusicbrainz5-devel"

From 7b6ba71e124e220cc6046ffe32848eee8ad8e301 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 024/109] deadbeef: revbump for ffmpeg4

---
 srcpkgs/deadbeef/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/deadbeef/template b/srcpkgs/deadbeef/template
index f5f4bf24b8cb6d..7b47e615cd48ef 100644
--- a/srcpkgs/deadbeef/template
+++ b/srcpkgs/deadbeef/template
@@ -1,14 +1,14 @@
 # Template file for 'deadbeef'
 pkgname=deadbeef
 version=1.8.8
-revision=3
+revision=4
 create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-oss --disable-lfm --disable-notify --disable-gtk2"
 hostmakedepends="automake libtool gettext gettext-devel intltool pkg-config
  yasm clang glib-devel"
 makedepends="
- alsa-lib-devel dbus-devel faad2-devel ffmpeg-devel gtk+3-devel imlib2-devel
+ alsa-lib-devel dbus-devel faad2-devel ffmpeg4-devel gtk+3-devel imlib2-devel
  jansson-devel libcddb-devel libcdio-devel libcurl-devel libflac-devel
  libmad-devel libpng-devel libsamplerate-devel libsndfile-devel libvorbis-devel
  libzip-devel mpg123-devel opusfile-devel pulseaudio-devel wavpack-devel"

From 3d2491f12113c63a448aacb3f344dd1a68f53d96 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 025/109] droidcam-obs-plugin: revbump for ffmpeg6

---
 srcpkgs/droidcam-obs-plugin/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam-obs-plugin/template b/srcpkgs/droidcam-obs-plugin/template
index fc9c9bf6b9d54c..fb0480754df4de 100644
--- a/srcpkgs/droidcam-obs-plugin/template
+++ b/srcpkgs/droidcam-obs-plugin/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam-obs-plugin'
 pkgname=droidcam-obs-plugin
 version=2.0.1
-revision=1
+revision=2
 build_style=gnu-makefile
 make_use_env=yes
 make_build_args="ALLOW_STATIC=no"

From 6caf1692ef25a9bf8358eaae27c1349d36b5488f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 026/109] droidcam: revbump for ffmpeg6

---
 srcpkgs/droidcam/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam/template b/srcpkgs/droidcam/template
index 1c3f1b8b1fc676..32a9220b79a4d1 100644
--- a/srcpkgs/droidcam/template
+++ b/srcpkgs/droidcam/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam'
 pkgname=droidcam
 version=1.8.2
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="USBMUXD=-lusbmuxd-2.0 JPEG=-lturbojpeg"
 hostmakedepends="pkg-config"

From 8632a15594dea817989784c6dc567c54adbeddb9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 027/109] ffmpegthumbnailer: revbump for ffmpeg6

---
 .../ffmpegthumbnailer/patches/ffmpeg6.patch   | 202 ++++++++++++++++++
 srcpkgs/ffmpegthumbnailer/template            |   6 +-
 2 files changed, 205 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch

diff --git a/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
new file mode 100644
index 00000000000000..363ff35a28419d
--- /dev/null
+++ b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
@@ -0,0 +1,202 @@
+--- a/libffmpegthumbnailer/moviedecoder.cpp	2017-11-21 14:06:57.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.cpp	2023-05-05 13:14:47.946560668 -0400
+@@ -41,11 +41,6 @@
+ namespace ffmpegthumbnailer
+ {
+ 
+-struct SilenceLogLevel
+-{
+-    SilenceLogLevel() { av_log_set_level(AV_LOG_QUIET); }
+-};
+-
+ MovieDecoder::MovieDecoder(AVFormatContext* pavContext)
+ : m_VideoStream(-1)
+ , m_pFormatContext(pavContext)
+@@ -70,8 +65,6 @@
+ 
+ void MovieDecoder::initialize(const string& filename, bool preferEmbeddedMetadata)
+ {
+-    av_register_all();
+-    avcodec_register_all();
+     avformat_network_init();
+ 
+     string inputFile = filename == "-" ? "pipe:" : filename;
+@@ -97,8 +90,7 @@
+ {
+     if (m_pVideoCodecContext)
+     {
+-        avcodec_close(m_pVideoCodecContext);
+-        m_pVideoCodecContext = nullptr;
++        avcodec_free_context(&m_pVideoCodecContext);
+     }
+ 
+     if ((!m_FormatContextWasGiven) && m_pFormatContext)
+@@ -152,10 +144,10 @@
+     for (unsigned int i = 0; i < m_pFormatContext->nb_streams; ++i)
+     {
+         AVStream *stream = m_pFormatContext->streams[i];
+-        auto ctx = m_pFormatContext->streams[i]->codec;
+-        if (ctx->codec_type == AVMEDIA_TYPE_VIDEO)
++        auto par = m_pFormatContext->streams[i]->codecpar;
++        if (par->codec_type == AVMEDIA_TYPE_VIDEO)
+         {
+-            if (!preferEmbeddedMetadata || !isStillImageCodec(ctx->codec_id))
++            if (!preferEmbeddedMetadata || !isStillImageCodec(par->codec_id))
+             {
+                 videoStreams.push_back(i);
+                 continue;
+@@ -203,8 +195,7 @@
+     }
+ 
+     m_pVideoStream = m_pFormatContext->streams[m_VideoStream];
+-    m_pVideoCodecContext = m_pVideoStream->codec;
+-    m_pVideoCodec = avcodec_find_decoder(m_pVideoCodecContext->codec_id);
++    m_pVideoCodec = avcodec_find_decoder(m_pVideoStream->codecpar->codec_id);
+ 
+     if (m_pVideoCodec == nullptr)
+     {
+@@ -214,6 +205,20 @@
+         throw logic_error("Video Codec not found");
+     }
+ 
++    m_pVideoCodecContext = avcodec_alloc_context3(m_pVideoCodec);
++
++    if (m_pVideoCodecContext == nullptr)
++    {
++        destroy();
++        throw logic_error("Could not allocate video codec context");
++    }
++
++    if (avcodec_parameters_to_context(m_pVideoCodecContext, m_pVideoStream->codecpar) < 0)
++    {
++        destroy();
++        throw logic_error("Could not configure video codec context");
++    }
++
+     m_pVideoCodecContext->workaround_bugs = 1;
+ 
+     if (avcodec_open2(m_pVideoCodecContext, m_pVideoCodec, nullptr) < 0)
+@@ -386,13 +391,6 @@
+ 
+ void MovieDecoder::initializeFilterGraph(const AVRational& timeBase, const std::string& size, bool maintainAspectRatio)
+ {
+-    static const AVPixelFormat pixelFormats[] = { AV_PIX_FMT_RGB24, AV_PIX_FMT_NONE };
+-
+-    auto del = [] (AVBufferSinkParams* p) { av_freep(p); };
+-    std::unique_ptr<AVBufferSinkParams, decltype(del)> buffersinkParams(av_buffersink_params_alloc(), del);
+-
+-    avfilter_register_all();
+-
+     m_pFilterGraph = avfilter_graph_alloc();
+     assert(m_pFilterGraph);
+ 
+@@ -404,10 +402,8 @@
+ 
+     checkRc(avfilter_graph_create_filter(&m_pFilterSource, avfilter_get_by_name("buffer"), "thumb_buffer", ss.str().c_str(), nullptr, m_pFilterGraph),
+             "Failed to create filter source");
+-    buffersinkParams->pixel_fmts = pixelFormats;
+-    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, buffersinkParams.get(), m_pFilterGraph),
++    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, nullptr, m_pFilterGraph),
+             "Failed to create filter sink");
+-    buffersinkParams.release();
+ 
+     AVFilterContext* yadifFilter = nullptr;
+     if (m_pFrame->interlaced_frame != 0)
+@@ -500,15 +496,15 @@
+     }
+ 
+     checkRc(av_seek_frame(m_pFormatContext, -1, timestamp, 0), "Seeking in video failed");
+-    avcodec_flush_buffers(m_pFormatContext->streams[m_VideoStream]->codec);
++    avcodec_flush_buffers(m_pVideoCodecContext);
+ 
+     int keyFrameAttempts = 0;
+-    bool gotFrame = 0;
++    bool gotFrame;
+ 
+     do
+     {
+         int count = 0;
+-        gotFrame = 0;
++        gotFrame = false;
+ 
+         while (!gotFrame && count < 20)
+         {
+@@ -552,17 +548,33 @@
+         return false;
+     }
+ 
+-    av_frame_unref(m_pFrame);
+-
+-    int frameFinished;
++    int rc = avcodec_send_packet(m_pVideoCodecContext, m_pPacket);
++    if(rc == AVERROR(EAGAIN))
++    {
++        rc = 0;
++    }
+ 
+-    int bytesDecoded = avcodec_decode_video2(m_pVideoCodecContext, m_pFrame, &frameFinished, m_pPacket);
+-    if (bytesDecoded < 0)
++    if(rc == AVERROR_EOF)
++    {
++        return false;
++    }
++    else if(rc < 0)
+     {
+-        throw logic_error("Failed to decode video frame: bytesDecoded < 0");
++        throw logic_error("Failed to decode video frame: avcodec_send_packet() < 0");
+     }
+ 
+-    return frameFinished > 0;
++    rc = avcodec_receive_frame(m_pVideoCodecContext, m_pFrame);
++    switch(rc)
++    {
++        case 0:
++            return true;
++
++        case AVERROR(EAGAIN):
++            return false;
++
++        default:
++            throw logic_error("Failed to decode video frame: avcodec_receive_frame() < 0");
++    }
+ }
+ 
+ bool MovieDecoder::getVideoPacket()
+@@ -570,8 +582,6 @@
+     bool framesAvailable = true;
+     bool frameDecoded = false;
+ 
+-    int attempts = 0;
+-
+     if (m_pPacket)
+     {
+         av_packet_unref(m_pPacket);
+@@ -580,6 +590,7 @@
+ 
+     m_pPacket = new AVPacket();
+ 
++
+     while (framesAvailable && !frameDecoded)
+     {
+         framesAvailable = av_read_frame(m_pFormatContext, m_pPacket) >= 0;
+@@ -644,7 +655,7 @@
+ 
+ int32_t MovieDecoder::getStreamRotation()
+ {
+-    int32_t* matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
++    auto matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
+     if (matrix)
+     {
+         auto angle = lround(av_display_rotation_get(matrix));
+
+--- a/libffmpegthumbnailer/moviedecoder.h	2017-11-12 04:23:38.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.h	2023-05-05 13:26:07.095529911 -0400
+@@ -78,7 +78,7 @@
+     int                     m_VideoStream;
+     AVFormatContext*        m_pFormatContext;
+     AVCodecContext*         m_pVideoCodecContext;
+-    AVCodec*                m_pVideoCodec;
++    const AVCodec*          m_pVideoCodec;
+     AVFilterGraph*          m_pFilterGraph;
+     AVFilterContext*        m_pFilterSource;
+     AVFilterContext*        m_pFilterSink;
diff --git a/srcpkgs/ffmpegthumbnailer/template b/srcpkgs/ffmpegthumbnailer/template
index 039eea7622b391..35d546018d12af 100644
--- a/srcpkgs/ffmpegthumbnailer/template
+++ b/srcpkgs/ffmpegthumbnailer/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbnailer'
 pkgname=ffmpegthumbnailer
 version=2.2.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libpng-devel libjpeg-turbo-devel ffmpeg-devel"
@@ -9,8 +9,8 @@ depends="ffmpeg"
 short_desc="Lightweight video thumbnailer"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
-homepage="https://github.com/dirkvdb/${pkgname}"
-distfiles="${homepage}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
+homepage="https://github.com/dirkvdb"
+distfiles="${homepage}/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
 checksum=1cb24059c38223f657b300c84dd80491b7040d4b69471c4fea69be862bc99b5b
 
 post_install() {

From 38998d363887f7ac2a930c635b915e97636b5255 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 028/109] ffmpegthumbs: revbump for ffmpeg6

---
 srcpkgs/ffmpegthumbs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ffmpegthumbs/template b/srcpkgs/ffmpegthumbs/template
index 2e2a96de83ce8a..dfd7e9dede36d3 100644
--- a/srcpkgs/ffmpegthumbs/template
+++ b/srcpkgs/ffmpegthumbs/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbs'
 pkgname=ffmpegthumbs
 version=23.08.5
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules kcoreaddons kconfig-devel
  pkg-config qt5-host-tools qt5-qmake gettext"

From e99d5526c3ebbd2931178b2e04db03d17d589470 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 029/109] ffms2: revbump for ffmpeg6

---
 srcpkgs/ffms2/patches/ffmpeg5.patch | 424 ++++++++++++++++++++++++++++
 srcpkgs/ffms2/template              |   2 +-
 2 files changed, 425 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ffms2/patches/ffmpeg5.patch

diff --git a/srcpkgs/ffms2/patches/ffmpeg5.patch b/srcpkgs/ffms2/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..1479fabcafcb4e
--- /dev/null
+++ b/srcpkgs/ffms2/patches/ffmpeg5.patch
@@ -0,0 +1,424 @@
+From 45673149e9a2f5586855ad472e3059084eaa36b1 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:41:21 +0100
+Subject: [PATCH] Use auto for AVCodec
+
+The geniuses over at FFmpeg decided to constify this API, so old
+versions of the library will return AVCodec *, while new versions
+of the libary will return const AVCodec *, which, in C++, are not
+OK to convert between.
+
+Rather than use some macro hell in ffmscompat.h, we can work around
+this by using auto.
+
+Gross.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 2 +-
+ src/core/indexing.cpp    | 6 +++---
+ src/core/videosource.cpp | 2 +-
+ 3 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index e4ce97c..ac09666 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -469,7 +469,7 @@ void FFMS_AudioSource::OpenFile() {
+ 
+     LAVFOpenFile(SourceFile.c_str(), FormatContext, TrackNumber);
+ 
+-    AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
++    auto *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
+     if (Codec == nullptr)
+         throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+             "Audio codec not found");
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index e547c5a..59fb4e8 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -384,7 +384,7 @@ FFMS_TrackType FFMS_Indexer::GetTrackType(int Track) {
+ }
+ 
+ const char *FFMS_Indexer::GetTrackCodec(int Track) {
+-    AVCodec *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
++    auto *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
+     return codec ? codec->name : nullptr;
+ }
+ 
+@@ -402,7 +402,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             UseDTS);
+ 
+         if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            AVCodec *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (!VideoCodec) {
+                 FormatContext->streams[i]->discard = AVDISCARD_ALL;
+                 IndexMask.erase(i);
+@@ -433,7 +433,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 IndexMask.insert(i);
+             }
+         } else if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+-            AVCodec *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (AudioCodec == nullptr)
+                 throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_UNSUPPORTED,
+                     "Audio codec not found");
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index b889970..8956c22 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -171,7 +171,7 @@ FFMS_VideoSource::FFMS_VideoSource(const char *SourceFile, FFMS_Index &Index, in
+ 
+         LAVFOpenFile(SourceFile, FormatContext, VideoTrack);
+ 
+-        AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
++        auto *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
+         if (Codec == nullptr)
+             throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+                 "Video codec not found");
+-- 
+2.40.0
+
+From 96cbf38ea9381829a1314f432a2c60495dcefaad Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:12:41 +0100
+Subject: [PATCH] all: Update AVPacket API usage
+
+AVPackets must all be on the heap now, since it is no longer
+part of the libav* ABI.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 16 ++++++----
+ src/core/indexing.cpp    | 63 ++++++++++++++++++++++------------------
+ src/core/indexing.h      |  4 +--
+ src/core/utils.cpp       |  6 ----
+ src/core/utils.h         |  1 -
+ src/core/videosource.cpp | 30 ++++++++++---------
+ 6 files changed, 64 insertions(+), 56 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index 37cf9ae..e4ce97c 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -285,10 +285,15 @@ FFMS_AudioSource::AudioBlock *FFMS_AudioSource::CacheBlock(CacheIterator &pos) {
+ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     CurrentFrame = &Frames[PacketNumber];
+ 
+-    AVPacket Packet;
+-    if (!ReadPacket(&Packet))
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++    if (!ReadPacket(Packet)) {
++        av_packet_free(&Packet);
+         throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_UNKNOWN,
+             "ReadPacket unexpectedly failed to read a packet");
++    }
+ 
+     // ReadPacket may have changed the packet number
+     CurrentFrame = &Frames[PacketNumber];
+@@ -297,8 +302,9 @@ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     int NumberOfSamples = 0;
+     AudioBlock *CachedBlock = nullptr;
+     
+-    int Ret = avcodec_send_packet(CodecContext, &Packet);
+-    av_packet_unref(&Packet);
++    int Ret = avcodec_send_packet(CodecContext, Packet);
++    av_packet_unref(Packet);
++    av_packet_free(&Packet);
+ 
+     av_frame_unref(DecodeFrame);
+     Ret = avcodec_receive_frame(CodecContext, DecodeFrame);
+@@ -513,8 +519,6 @@ void FFMS_AudioSource::Seek() {
+ }
+ 
+ bool FFMS_AudioSource::ReadPacket(AVPacket *Packet) {
+-    InitNullPacket(*Packet);
+-
+     while (av_read_frame(FormatContext, Packet) >= 0) {
+         if (Packet->stream_index == TrackNumber) {
+             // Required because not all audio packets, especially in ogg, have a pts. Use the previous valid packet's pts instead.
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index 23fb95b..e547c5a 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -320,7 +320,7 @@ void FFMS_Indexer::CheckAudioProperties(int Track, AVCodecContext *Context) {
+     }
+ }
+ 
+-void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict,
++void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict,
+                                     int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct) {
+     if (VideoContext.Parser) {
+         uint8_t *OB;
+@@ -330,8 +330,8 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+         av_parser_parse2(VideoContext.Parser,
+             VideoContext.CodecContext,
+             &OB, &OBSize,
+-            pkt.data, pkt.size,
+-            pkt.pts, pkt.dts, pkt.pos);
++            pkt->data, pkt->size,
++            pkt->pts, pkt->dts, pkt->pos);
+ 
+         // H.264 (PAFF) and HEVC may have one field per packet, so we need to track
+         // when we have a full or half frame available, and mark one of them as
+@@ -351,15 +351,15 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+ 
+         *RepeatPict = VideoContext.Parser->repeat_pict;
+         *FrameType = VideoContext.Parser->pict_type;
+-        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt.flags & AV_PKT_FLAG_DISCARD));
++        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt->flags & AV_PKT_FLAG_DISCARD));
+     } else {
+-        *Invisible = !!(pkt.flags & AV_PKT_FLAG_DISCARD);
++        *Invisible = !!(pkt->flags & AV_PKT_FLAG_DISCARD);
+     }
+ 
+     if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP8)
+-        ParseVP8(pkt.data[0], Invisible, FrameType);
++        ParseVP8(pkt->data[0], Invisible, FrameType);
+     else if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP9)
+-        ParseVP9(pkt.data[0], Invisible, FrameType);
++        ParseVP9(pkt->data[0], Invisible, FrameType);
+ }
+ 
+ void FFMS_Indexer::Free() {
+@@ -458,32 +458,36 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+         }
+     }
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
+     std::vector<int64_t> LastValidTS(FormatContext->nb_streams, AV_NOPTS_VALUE);
+ 
+     int64_t filesize = avio_size(FormatContext->pb);
+     enum AVPictureStructure LastPicStruct = AV_PICTURE_STRUCTURE_UNKNOWN;
+-    while (av_read_frame(FormatContext, &Packet) >= 0) {
++    while (av_read_frame(FormatContext, Packet) >= 0) {
+         // Update progress
+         // FormatContext->pb can apparently be NULL when opening images.
+         if (IC && FormatContext->pb) {
+-            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate))
++            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate)) {
++                av_packet_free(&Packet);
+                 throw FFMS_Exception(FFMS_ERROR_CANCELLED, FFMS_ERROR_USER,
+                     "Cancelled by user");
++            }
+         }
+-        if (!IndexMask.count(Packet.stream_index)) {
+-            av_packet_unref(&Packet);
++        if (!IndexMask.count(Packet->stream_index)) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+-        int Track = Packet.stream_index;
++        int Track = Packet->stream_index;
+         FFMS_Track &TrackInfo = (*TrackIndices)[Track];
+-        bool KeyFrame = !!(Packet.flags & AV_PKT_FLAG_KEY);
++        bool KeyFrame = !!(Packet->flags & AV_PKT_FLAG_KEY);
+         ReadTS(Packet, LastValidTS[Track], (*TrackIndices)[Track].UseDTS);
+ 
+         if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            int64_t PTS = TrackInfo.UseDTS ? Packet.dts : Packet.pts;
++            int64_t PTS = TrackInfo.UseDTS ? Packet->dts : Packet->pts;
+             if (PTS == AV_NOPTS_VALUE) {
+                 // VPx alt-refs are output as packets which lack timestmps or durations, since
+                 // they are invisible. Currently, the timestamp mangling code in libavformat
+@@ -495,9 +499,11 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 // FFMS2 currently sorts packets by PTS, which will break decoding, otherwise.
+                 bool HasAltRefs = (FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP8 ||
+                                    FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP9);
+-                if (Packet.duration == 0 && !HasAltRefs)
++                if (Packet->duration == 0 && !HasAltRefs) {
++                    av_packet_free(&Packet);
+                     throw FFMS_Exception(FFMS_ERROR_INDEXING, FFMS_ERROR_PARSER,
+                         "Invalid packet pts, dts, and duration");
++                }
+ 
+                 if (TrackInfo.empty())
+                     PTS = 0;
+@@ -513,7 +519,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             ParseVideoPacket(AVContexts[Track], Packet, &RepeatPict, &FrameType, &Invisible, &LastPicStruct);
+ 
+             TrackInfo.AddVideoFrame(PTS, RepeatPict, KeyFrame,
+-                FrameType, Packet.pos, Invisible);
++                FrameType, Packet->pos, Invisible);
+         } else if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+             // For video seeking timestamps are used only if all packets have
+             // timestamps, while for audio they're used if any have timestamps,
+@@ -522,28 +528,29 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 TrackInfo.HasTS = true;
+ 
+             int64_t StartSample = AVContexts[Track].CurrentSample;
+-            uint32_t SampleCount = IndexAudioPacket(Track, &Packet, AVContexts[Track], *TrackIndices);
++            uint32_t SampleCount = IndexAudioPacket(Track, Packet, AVContexts[Track], *TrackIndices);
+             TrackInfo.SampleRate = AVContexts[Track].CodecContext->sample_rate;
+ 
+             TrackInfo.AddAudioFrame(LastValidTS[Track],
+-                StartSample, SampleCount, KeyFrame, Packet.pos, Packet.flags & AV_PKT_FLAG_DISCARD);
++                StartSample, SampleCount, KeyFrame, Packet->pos, Packet->flags & AV_PKT_FLAG_DISCARD);
+         }
+ 
+-        if (!(Packet.flags & AV_PKT_FLAG_DISCARD))
+-            TrackInfo.LastDuration = Packet.duration;
++        if (!(Packet->flags & AV_PKT_FLAG_DISCARD))
++            TrackInfo.LastDuration = Packet->duration;
+ 
+-        av_packet_unref(&Packet);
++        av_packet_unref(Packet);
+     }
++    av_packet_free(&Packet);
+ 
+     TrackIndices->Finalize(AVContexts, FormatContext->iformat->name);
+     return TrackIndices.release();
+ }
+ 
+-void FFMS_Indexer::ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS) {
+-    if (!UseDTS && Packet.pts != AV_NOPTS_VALUE)
+-        TS = Packet.pts;
++void FFMS_Indexer::ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS) {
++    if (!UseDTS && Packet->pts != AV_NOPTS_VALUE)
++        TS = Packet->pts;
+     if (TS == AV_NOPTS_VALUE)
+         UseDTS = true;
+-    if (UseDTS && Packet.dts != AV_NOPTS_VALUE)
+-        TS = Packet.dts;
++    if (UseDTS && Packet->dts != AV_NOPTS_VALUE)
++        TS = Packet->dts;
+ }
+diff --git a/src/core/indexing.h b/src/core/indexing.h
+index 3cfc3c3..5c06868 100644
+--- a/src/core/indexing.h
++++ b/src/core/indexing.h
+@@ -80,10 +80,10 @@ private:
+     int64_t Filesize;
+     uint8_t Digest[20];
+ 
+-    void ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS);
++    void ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS);
+     void CheckAudioProperties(int Track, AVCodecContext *Context);
+     uint32_t IndexAudioPacket(int Track, AVPacket *Packet, SharedAVContext &Context, FFMS_Index &TrackIndices);
+-    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
++    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
+     void Free();
+ public:
+     FFMS_Indexer(const char *Filename);
+diff --git a/src/core/utils.cpp b/src/core/utils.cpp
+index ce67533..8a2e997 100644
+--- a/src/core/utils.cpp
++++ b/src/core/utils.cpp
+@@ -62,12 +62,6 @@ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo) {
+     }
+ }
+ 
+-void InitNullPacket(AVPacket &pkt) {
+-    av_init_packet(&pkt);
+-    pkt.data = nullptr;
+-    pkt.size = 0;
+-}
+-
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames) {
+     AP.SampleFormat = static_cast<FFMS_SampleFormat>(av_get_packed_sample_fmt(CTX->sample_fmt));
+     AP.BitsPerSample = av_get_bytes_per_sample(CTX->sample_fmt) * 8;
+diff --git a/src/core/utils.h b/src/core/utils.h
+index 9819dc7..003ab79 100644
+--- a/src/core/utils.h
++++ b/src/core/utils.h
+@@ -58,7 +58,6 @@ std::unique_ptr<T> make_unique(Args&&... args) {
+ }
+ 
+ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo);
+-void InitNullPacket(AVPacket &pkt);
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames);
+ 
+ void LAVFOpenFile(const char *SourceFile, AVFormatContext *&FormatContext, int Track);
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index 06bd161..b889970 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -673,30 +673,34 @@ void FFMS_VideoSource::DecodeNextFrame(int64_t &AStartTime, int64_t &Pos) {
+     if (HasPendingDelayedFrames())
+         return;
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
+-
+-    while (ReadFrame(&Packet) >= 0) {
+-        if (Packet.stream_index != VideoTrack) {
+-            av_packet_unref(&Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++
++    while (ReadFrame(Packet) >= 0) {
++        if (Packet->stream_index != VideoTrack) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+         if (AStartTime < 0)
+-            AStartTime = Frames.UseDTS ? Packet.dts : Packet.pts;
++            AStartTime = Frames.UseDTS ? Packet->dts : Packet->pts;
+ 
+         if (Pos < 0)
+-            Pos = Packet.pos;
++            Pos = Packet->pos;
+ 
+-        bool FrameFinished = DecodePacket(&Packet);
+-        av_packet_unref(&Packet);
+-        if (FrameFinished)
++        bool FrameFinished = DecodePacket(Packet);
++        av_packet_unref(Packet);
++        if (FrameFinished) {
++            av_packet_free(&Packet);
+             return;
++        }
+     }
+ 
+     // Flush final frames
+-    InitNullPacket(Packet);
+-    DecodePacket(&Packet);
++    DecodePacket(Packet);
++    av_packet_free(&Packet);
+ }
+ 
+ bool FFMS_VideoSource::SeekTo(int n, int SeekOffset) {
+-- 
+2.40.0
+
+From bf9e03e9e08534c024e5a744a6437c4aac160201 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:20:47 +0100
+Subject: [PATCH 2/3] configure: Remove deprecated API use
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ configure.ac | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index b35ef80bc..d19714d0f 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -102,10 +102,10 @@ CFLAGS="$_CFLAGS $FFMPEG_CFLAGS"
+
+ AC_DEFUN([TEST_FFMPEG],
+          [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+-            #include <libavcodec/avcodec.h>
++            #include <libavformat/avformat.h>
+             #include <libswscale/swscale.h>
+             ]],[[
+-                avcodec_register_all();
++                avformat_network_init();
+                 swscale_version();
+             ]])], [eval $1=yes], [eval $1=no])
+         ])
+
diff --git a/srcpkgs/ffms2/template b/srcpkgs/ffms2/template
index 365f64d10cbabf..1641ecf43be5bb 100644
--- a/srcpkgs/ffms2/template
+++ b/srcpkgs/ffms2/template
@@ -1,7 +1,7 @@
 # Template file for 'ffms2'
 pkgname=ffms2
 version=2.40
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-shared --disable-static"
 hostmakedepends="pkg-config autoconf automake libtool"

From aed5da6ee9062109fd500969e237ba1d81e8387c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 030/109] freerdp: revbump for ffmpeg6

---
 .../freerdp/patches/ffmpeg6_aa2cb9aa.patch    | 42 +++++++++++++++++++
 srcpkgs/freerdp/template                      |  2 +-
 2 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch

diff --git a/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
new file mode 100644
index 00000000000000..a4324da3a8822b
--- /dev/null
+++ b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
@@ -0,0 +1,42 @@
+From aa2cb9aa5ff5562433598ba168a466e0752bca0e Mon Sep 17 00:00:00 2001
+From: akallabeth <akallabeth@posteo.net>
+Date: Tue, 14 Feb 2023 07:48:54 +0100
+Subject: [PATCH] Fixed #8686: Update h264 to use new FFMPEG API
+
+---
+ channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c | 2 ++
+ libfreerdp/codec/h264_ffmpeg.c            | 2 ++
+ 2 files changed, 4 insertions(+)
+
+diff --git a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+index 339462d865f..beea80b7a1e 100644
+--- a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
++++ b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+@@ -239,8 +239,10 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYP
+ 		}
+ 	}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 	if (mdecoder->codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		mdecoder->codec_context->flags |= AV_CODEC_FLAG_TRUNCATED;
++#endif
+ 
+ 	return TRUE;
+ }
+diff --git a/libfreerdp/codec/h264_ffmpeg.c b/libfreerdp/codec/h264_ffmpeg.c
+index 8a23db2473c..896a333019b 100644
+--- a/libfreerdp/codec/h264_ffmpeg.c
++++ b/libfreerdp/codec/h264_ffmpeg.c
+@@ -615,10 +615,12 @@ static BOOL libavcodec_init(H264_CONTEXT* h264)
+ 			goto EXCEPTION;
+ 		}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 		if (sys->codecDecoder->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		{
+ 			sys->codecDecoderContext->flags |= AV_CODEC_FLAG_TRUNCATED;
+ 		}
++#endif
+ 
+ #ifdef WITH_VAAPI
+ 
diff --git a/srcpkgs/freerdp/template b/srcpkgs/freerdp/template
index 16fddfbe8f5287..bf3a4d2e2b3ae7 100644
--- a/srcpkgs/freerdp/template
+++ b/srcpkgs/freerdp/template
@@ -1,7 +1,7 @@
 # Template file for 'freerdp'
 pkgname=freerdp
 version=2.11.4
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_ALSA=ON -DWITH_CUPS=OFF -DWITH_FFMPEG=ON
  -DWITH_GSTREAMER_0_10=OFF -DWITH_GSTREAMER_1_0=OFF -DWITH_JPEG=ON

From c2a5deb045913de073127ba43c60b2f64a00efc0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 031/109] gerbera: revbump for ffmpeg6

---
 srcpkgs/gerbera/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gerbera/template b/srcpkgs/gerbera/template
index ae14f35c767c03..2dc0ac0ce03b55 100644
--- a/srcpkgs/gerbera/template
+++ b/srcpkgs/gerbera/template
@@ -1,7 +1,7 @@
 # Template file for 'gerbera'
 pkgname=gerbera
 version=1.12.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_SYSTEMD=0 -DWITH_AVCODEC=1"
 hostmakedepends="pkg-config"

From 8fd81715f1b9549e1c9a26879401b24fb2fe7ab4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 032/109] goldendict: revbump for ffmpeg6

---
 srcpkgs/goldendict/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/goldendict/template b/srcpkgs/goldendict/template
index f4a05759f693d3..97f44347b03a6a 100644
--- a/srcpkgs/goldendict/template
+++ b/srcpkgs/goldendict/template
@@ -1,7 +1,7 @@
 # Template file for 'goldendict'
 pkgname=goldendict
 version=1.5.0
-revision=1
+revision=2
 build_style=qmake
 configure_args="CONFIG+=zim_support goldendict.pro"
 hostmakedepends="qt5-qmake pkg-config qt5-host-tools"
@@ -10,7 +10,7 @@ makedepends="tiff-devel qt5-devel libvorbis-devel zlib-devel
  qt5-webkit-devel lzo-devel bzip2-devel libao-devel qt5-svg-devel
  libeb-devel qt5-x11extras-devel ffmpeg-devel liblzma-devel
  qt5-multimedia-devel"
-short_desc="A feature-rich dictionary lookup program"
+short_desc="Feature-rich dictionary lookup program"
 maintainer="John <me@johnnynator.dev>"
 license="GPL-3.0-or-later"
 homepage="http://goldendict.org/"

From 3cbcebe9d4d25e48b31833aa0db49d16ae3cb8c2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 033/109] gst-libav: revbump for ffmpeg6

---
 srcpkgs/gst-libav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index e02c0deafc6d24..3b82a28e99c970 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.24.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"

From 7f11298cea0570c5c2b9060de583f43e842f570f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Feb 2024 01:52:46 -0500
Subject: [PATCH 034/109] gst-plugins-bad1: revbump for ffmpeg6

---
 srcpkgs/gst-plugins-bad1/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index 0712c756c00e60..46384ca0ddaddb 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-plugins-bad1'
 pkgname=gst-plugins-bad1
 version=1.24.0
-revision=1
+revision=2
 build_helper="gir"
 build_style=meson
 configure_args="-Dpackage-origin=https://voidlinux.org -Ddoc=disabled
@@ -27,7 +27,7 @@ makedepends="alsa-lib-devel celt-devel openssl-devel exempi-devel
  fdk-aac-devel flite-devel fluidsynth-devel liblrdf-devel ladspa-sdk
  lilv-devel lv2 libopenjpeg2-devel sbc-devel spandsp-devel vulkan-loader
  Vulkan-Headers webrtc-audio-processing-devel libzbar-devel ffmpeg-devel
- srt-devel libva-devel
+ srt-devel libva-devel oneVPL-devel
  $(vopt_if gme libgme-devel)"
 depends="gst-plugins-base1>=${version}"
 short_desc="GStreamer plugins from the bad set (v1.x)"

From bfa3c30e2bbbe57da7930570936dfa344d215660 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 035/109] gst-rtsp-server: revbump for ffmpeg6

---
 srcpkgs/gst-rtsp-server/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index 4ace541d36e324..837b1bc0d14118 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
 version=1.24.0
-revision=1
+revision=2
 build_style=meson
 build_helper=gir
 configure_args="-Dintrospection=enabled"

From 4b04c1ddd0ad44304027b71f44e9b1b0842d6dbf Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 036/109] guvcview: update to 2.0.8.

---
 srcpkgs/guvcview/patches/fix-include.patch | 10 ++++++++++
 srcpkgs/guvcview/template                  |  7 +++----
 2 files changed, 13 insertions(+), 4 deletions(-)
 create mode 100644 srcpkgs/guvcview/patches/fix-include.patch

diff --git a/srcpkgs/guvcview/patches/fix-include.patch b/srcpkgs/guvcview/patches/fix-include.patch
new file mode 100644
index 00000000000000..503c2af3b78c1a
--- /dev/null
+++ b/srcpkgs/guvcview/patches/fix-include.patch
@@ -0,0 +1,10 @@
+--- a/guvcview/guvcview.c
++++ b/guvcview/guvcview.c
+@@ -28,6 +28,7 @@
+ #include <sys/stat.h>
+ #include <sys/resource.h>
+ #include <errno.h>
++#include <locale.h>
+ 
+ #include "gview.h"
+ #include "gviewv4l2core.h"
diff --git a/srcpkgs/guvcview/template b/srcpkgs/guvcview/template
index d42fd38fa4ad12..86a7fd619612c8 100644
--- a/srcpkgs/guvcview/template
+++ b/srcpkgs/guvcview/template
@@ -1,8 +1,7 @@
 # Template file for 'guvcview'
 pkgname=guvcview
-version=2.0.7
-revision=2
-create_wrksrc=yes
+version=2.0.8
+revision=1
 build_style=gnu-configure
 configure_args="--disable-static --disable-debian-menu"
 hostmakedepends="pkg-config intltool autoconf automake libtool glib-devel"
@@ -14,7 +13,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="http://guvcview.sourceforge.net/"
 distfiles="${SOURCEFORGE_SITE}/${pkgname}/${pkgname}-src-${version}.tar.bz2"
-checksum=f47d51fbd06e44eeaa1a82f4a153c927527c90d94514197a70b2956028cc8ad4
+checksum=a21f4e448286666cf27bafef5290cc953a0a1796b752e5bbe521266dc1230c81
 
 post_patch() {
 	sed '31a#include <locale.h>' -i  guvcview/guvcview.c

From b78bbdace46c560afcd82d248deeae82c993f8c5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 037/109] handbrake: update to 1.6.1

---
 .../patches/fix-missing-x265-link-flag.patch    | 11 ++++++-----
 .../handbrake/patches/libhb-vpl-include.patch   | 15 +++++++++++++++
 srcpkgs/handbrake/template                      | 17 ++++++++++-------
 3 files changed, 31 insertions(+), 12 deletions(-)
 create mode 100644 srcpkgs/handbrake/patches/libhb-vpl-include.patch

diff --git a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
index 26db03867a0c83..d6bb2eda627a36 100644
--- a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
+++ b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
@@ -1,14 +1,15 @@
 --- a/gtk/configure.ac
 +++ b/gtk/configure.ac
 @@ -203,7 +203,7 @@
- 
+
  AM_CONDITIONAL([MINGW], [test "x$mingw_flag" = "xyes"])
- 
--HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg"
-+HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -ldl"
+
+-HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc"
++HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc -ldl"
  HB_CPPFLAGS="$HB_CPPFLAGS $HBINC"
- 
+
  PKG_CHECK_MODULES([x264], [x264], sys_x264=yes, sys_x264=no)
+
 --- a/test/module.defs
 +++ b/test/module.defs
 @@ -69,6 +69,9 @@
diff --git a/srcpkgs/handbrake/patches/libhb-vpl-include.patch b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
new file mode 100644
index 00000000000000..298f9f4ab28f2a
--- /dev/null
+++ b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
@@ -0,0 +1,15 @@
+--- a/libhb/module.defs	2023-01-22 11:36:49.000000000 -0500
++++ b/libhb/module.defs	2023-04-03 22:37:52.395467010 -0400
+@@ -46,11 +46,7 @@
+ LIBHB.GCC.I += $(LIBHB.build/) $(CONTRIB.build/)include
+ 
+ ifeq (1,$(FEATURE.qsv))
+-    ifeq ($(HOST.system),freebsd))
+-        LIBHB.GCC.I += $(LOCALBASE)/include/vpl
+-    else
+-        LIBHB.GCC.I += $(CONTRIB.build/)include/vpl
+-    endif
++    LIBHB.GCC.I += /usr/include/vpl
+ endif
+ 
+ ifneq (,$(filter $(HOST.system),freebsd netbsd openbsd))
diff --git a/srcpkgs/handbrake/template b/srcpkgs/handbrake/template
index ca5e4571e49c37..c32cb1bfa31f4b 100644
--- a/srcpkgs/handbrake/template
+++ b/srcpkgs/handbrake/template
@@ -1,10 +1,10 @@
 # Template file for 'handbrake'
 pkgname=handbrake
-version=1.5.1
+version=1.6.1
 revision=1
 build_style=gnu-configure
 configure_args="--force --disable-gtk-update-checks --disable-df-fetch --harden
- $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc)"
+ $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc) $(vopt_enable qsv)"
 make_build_args="-C ${XBPS_TRIPLET}"
 make_install_args="-C ${XBPS_TRIPLET}"
 hostmakedepends="automake cmake gettext-devel glib-devel intltool libtool m4 meson nasm pkg-config python3"
@@ -12,8 +12,11 @@ makedepends="bzip2-devel ffmpeg-devel gst-plugins-base1-devel gtk+3-devel
  jansson-devel lame-devel libass-devel libbluray-devel libdav1d-devel
  libdvdnav-devel libdvdread-devel libgudev-devel libnuma-devel
  libsamplerate-devel libtheora-devel libvorbis-devel libvpx-devel libxml2-devel
- opus-devel speex-devel x264-devel x265-devel zimg-devel
+ opus-devel speex-devel x264-devel x265-devel zimg-devel libsvt-av1-devel
  $(vopt_if fdk_aac fdk-aac-devel)
+ $(vopt_if qsv libva-devel)
+ $(vopt_if qsv libdrm-devel)
+ $(vopt_if qsv onevpl-devel)
  $(vopt_if nvenc nv-codec-headers)"
 depends="desktop-file-utils gst-plugins-good1 hicolor-icon-theme"
 short_desc="Multithreaded video transcoder"
@@ -21,15 +24,15 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-2.0-only"
 homepage="https://handbrake.fr/"
 distfiles="https://github.com/HandBrake/HandBrake/releases/download/${version}/HandBrake-${version}-source.tar.bz2"
-checksum=3999fe06d5309c819799a73a968a8ec3840e7840c2b64af8f5cdb7fd8c9430f0
+checksum=94ccfe03db917a91650000c510f7fd53f844da19f19ad4b4be1b8f6bc31a8d4c
 nocross=yes
 
-build_options="fdk_aac nvenc"
+build_options="fdk_aac nvenc qsv"
 
 case "$XBPS_TARGET_MACHINE" in
 	x86_64*|i686*)
 		CFLAGS="-msse"
-		build_options_default="nvenc"
+		build_options_default="nvenc qsv"
 		;;
 esac
 
@@ -37,7 +40,7 @@ pre_configure() {
 	# use system libraries, don't download them
 	rm -rf contrib/
 	for module in fdk-aac ffmpeg libbluray libdav1d libdvdnav libdvdread nvenc \
-		x265 zimg; do
+		x265 zimg svt-av1 libvpl; do
 	    vsed -i "/MODULES += contrib\/${module}/d" make/include/main.defs
 	done
 }

From 45b694f0d5fdd099493954087b9fa0f093402c2a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 038/109] hedgewars: revbump for ffmpeg4

---
 srcpkgs/hedgewars/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/hedgewars/template b/srcpkgs/hedgewars/template
index 94b6db673b0c3a..402ccfaaecbc2d 100644
--- a/srcpkgs/hedgewars/template
+++ b/srcpkgs/hedgewars/template
@@ -1,13 +1,13 @@
 # Template file for 'hedgewars'
 pkgname=hedgewars
 version=1.0.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DNOSERVER=1 -DDATA_INSTALL_DIR=/usr/share/${pkgname}
  -DPHYSFS_SYSTEM=1 -DMINIMAL_FLAGS=1"
 make_cmd=make
 hostmakedepends="lua51 pkg-config qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
+makedepends="ffmpeg4-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
  SDL2_mixer-devel SDL2_net-devel SDL2_ttf-devel"
 depends="libfreeglut"
 short_desc="Funny turn-based artillery game, featuring fighting Hedgehogs!"

From 0f90bcdc145c4bed34aa5196701aa393d1b61fbd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 039/109] idjc: revbump for ffmpeg4

---
 srcpkgs/idjc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/idjc/template b/srcpkgs/idjc/template
index a9cde0665d55b1..f41e1e4fabbae7 100644
--- a/srcpkgs/idjc/template
+++ b/srcpkgs/idjc/template
@@ -1,11 +1,11 @@
 # Template file for 'idjc'
 pkgname=idjc
 version=0.9.1
-revision=5
+revision=6
 build_style=gnu-configure
 hostmakedepends="pkg-config git python3 automake gettext-devel libtool"
 makedepends="libvorbis-devel libogg-devel jack-devel libsamplerate-devel
- libflac-devel libsndfile-devel mpg123-devel ffmpeg-devel speex-devel
+ libflac-devel libsndfile-devel mpg123-devel ffmpeg4-devel speex-devel
  glib-devel pixman-devel lame-devel python3-gobject-devel libshout-idjc-devel
  opus-devel twolame-devel python3-mutagen python3-devel"
 depends="python3-gobject python3-mutagen desktop-file-utils shared-mime-info python3-dbus jack"

From ee190b0cbe19ef5459de3cbeb1dbaa03b46b83b7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 040/109] kid3: revbump for ffmpeg6

---
 srcpkgs/kid3/patches/ffmpeg5.patch | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 srcpkgs/kid3/patches/ffmpeg5.patch

diff --git a/srcpkgs/kid3/patches/ffmpeg5.patch b/srcpkgs/kid3/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..135fc50e07c9ba
--- /dev/null
+++ b/srcpkgs/kid3/patches/ffmpeg5.patch
@@ -0,0 +1,17 @@
+# https://aur.archlinux.org/cgit/aur.git/diff/ffmpeg5.patch?h=kid3-cli&id=12410a74906612e7efc0ec8fbce739b4a0fef7e7
+diff --git a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+index e156d424..e12b9abd 100644
+--- a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
++++ b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+@@ -232,7 +232,11 @@ private:
+   friend class Format;
+   friend class Converter;
+   AVCodecContext* m_ptr;
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 0, 0)
+   AVCodec* m_impl;
++#else
++  const AVCodec* m_impl;
++#endif
+   AVFrame* m_frame;
+   bool m_opened;
+ };

From bb62399aa2a755f0e90275053c67856902a9ed37 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 041/109] kodi: revbump for ffmpeg4

---
 srcpkgs/kodi/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/kodi/template b/srcpkgs/kodi/template
index d37a5918cd6758..ea78e0aca0fe3e 100644
--- a/srcpkgs/kodi/template
+++ b/srcpkgs/kodi/template
@@ -1,7 +1,7 @@
 # Template file for 'kodi'
 pkgname=kodi
 version=19.4
-revision=9
+revision=10
 _codename="Matrix"
 build_style=cmake
 configure_args="-DWITH_FFMPEG=/usr -DENABLE_LDGOLD=OFF
@@ -54,7 +54,7 @@ makedepends="
  libmad-devel fontconfig-devel libXinerama-devel libsamplerate-devel libmms-devel
  enca-devel boost-devel libcurl-devel libva-devel libvdpau-devel libass-devel
  libbluetooth-devel yajl-devel libplist-devel librtmp-devel tinyxml-devel
- taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg-devel
+ taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg4-devel
  giflib-devel libxslt-devel gnutls-devel libssh-devel libmicrohttpd-devel
  libcec-devel dcadec-devel flatbuffers-devel fmt-devel lcms2-devel
  libfstrcmp-devel rapidjson libcdio-paranoia spdlog libwaylandpp-devel

From 415b82754e267679c4fd9d0675d9283dcc61beba Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 042/109] kpipewire: revbump for ffmpeg6

---
 srcpkgs/kpipewire/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kpipewire/template b/srcpkgs/kpipewire/template
index 24f5f152749c97..d5ac3788ff586a 100644
--- a/srcpkgs/kpipewire/template
+++ b/srcpkgs/kpipewire/template
@@ -1,7 +1,7 @@
 # Template file for 'kpipewire'
 pkgname=kpipewire
 version=5.27.11
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules plasma-wayland-protocols gettext
  qt5-qmake qt5-host-tools pkg-config wayland-devel kcoreaddons

From 85ba26efbe2194285b0c942d88f8fbed2ba50939 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 043/109] libopenal: revbump for ffmpeg6

---
 srcpkgs/libopenal/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenal/template b/srcpkgs/libopenal/template
index 88d0f11307d81a..8308fca0393e33 100644
--- a/srcpkgs/libopenal/template
+++ b/srcpkgs/libopenal/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenal'
 pkgname=libopenal
 version=1.23.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DALSOFT_EXAMPLES=OFF"
 hostmakedepends="pkg-config"

From 4038b36df3e02364e420867d9656685218a93ffe Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 044/109] loudgain: revbump for ffmpeg6

---
 srcpkgs/loudgain/patches/ffmpeg5.patch | 11 +++++++++++
 srcpkgs/loudgain/template              |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/loudgain/patches/ffmpeg5.patch

diff --git a/srcpkgs/loudgain/patches/ffmpeg5.patch b/srcpkgs/loudgain/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..16d4510ee98faa
--- /dev/null
+++ b/srcpkgs/loudgain/patches/ffmpeg5.patch
@@ -0,0 +1,11 @@
+--- a/src/scan.c	2019-09-06 11:31:19.000000000 -0400
++++ b/src/scan.c	2023-03-23 11:15:40.867968521 -0400
+@@ -69,8 +69,6 @@
+ 	 * It is now useless
+ 	 * https://github.com/FFmpeg/FFmpeg/blob/70d25268c21cbee5f08304da95be1f647c630c15/doc/APIchanges#L86
+ 	 */
+-  if (avformat_version() < AV_VERSION_INT(58,9,100))
+-    av_register_all();
+ 
+ 	av_log_set_callback(scan_av_log);
+ 
diff --git a/srcpkgs/loudgain/template b/srcpkgs/loudgain/template
index da4f2d56e94c3d..4d6bf29efb4fdd 100644
--- a/srcpkgs/loudgain/template
+++ b/srcpkgs/loudgain/template
@@ -1,7 +1,7 @@
 # Template file for 'loudgain'
 pkgname=loudgain
 version=0.6.8
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libebur128-devel taglib-devel ffmpeg-devel"

From 917e504e269b1a84d5caf9f7f3475acc10f0a18a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 045/109] mediastreamer: revbump for ffmpeg4

---
 srcpkgs/mediastreamer/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mediastreamer/template b/srcpkgs/mediastreamer/template
index 0fcffa7653d18e..e888626b945e55 100644
--- a/srcpkgs/mediastreamer/template
+++ b/srcpkgs/mediastreamer/template
@@ -1,11 +1,11 @@
 # Template file for 'mediastreamer'
 pkgname=mediastreamer
 version=5.2.111
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DENABLE_STRICT=0 -DENABLE_UNIT_TESTS=0"
 hostmakedepends="python3"
-makedepends="bzrtp-devel ffmpeg-devel glew-devel libXv-devel libsrtp-devel
+makedepends="bzrtp-devel ffmpeg4-devel glew-devel libXv-devel libsrtp-devel
  libupnp-devel libvpx-devel mbedtls-devel opus-devel ortp-devel pulseaudio-devel
  libtheora-devel speex-devel v4l-utils-devel bcg729-devel bcmatroska2-devel libgsm-devel
  zxing-cpp-devel"

From 20faf62f99744694ced06d23c9ab816f416b44ac Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 046/109] mgba: revbump for ffmpeg6

---
 srcpkgs/mgba/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mgba/template b/srcpkgs/mgba/template
index 6cd65650312543..93401adb618bd8 100644
--- a/srcpkgs/mgba/template
+++ b/srcpkgs/mgba/template
@@ -1,7 +1,7 @@
 # Template file for 'mgba'
 pkgname=mgba
 version=0.10.3
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake desktop-file-utils"
 makedepends="SDL2-devel ffmpeg-devel libedit-devel libepoxy-devel libmagick-devel

From 29c31575d59f6c7dba2eafd6b0bcf65006d9eb8e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 047/109] mlt: revbump for ffmpeg4

---
 srcpkgs/mlt/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mlt/template b/srcpkgs/mlt/template
index 73e3915aaab9ac..d7ed4c4b30a868 100644
--- a/srcpkgs/mlt/template
+++ b/srcpkgs/mlt/template
@@ -1,14 +1,14 @@
 # Template file for 'mlt'
 pkgname=mlt
 version=6.26.1
-revision=3
+revision=4
 build_style=configure
 configure_args="--prefix=/usr --libdir=/usr/lib$XBPS_TARGET_WORDSIZE
  --enable-gpl --enable-gpl3 --disable-swfdec --without-kde
  --swig-languages=python"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which"
 # XXX: movit vid.stab
-makedepends="alsa-lib-devel ffmpeg-devel gtk+-devel jack-devel ladspa-sdk
+makedepends="alsa-lib-devel ffmpeg4-devel gtk+-devel jack-devel ladspa-sdk
  libexif-devel libsamplerate-devel libxml2-devel sox-devel SDL_image-devel
  fftw-devel frei0r-plugins python3-devel pulseaudio-devel movit-devel
  libvidstab-devel"

From 86a9551e01ce06e48d942194a70a7fee25e16ccd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 048/109] moc: revbump for ffmpeg4

---
 srcpkgs/moc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/moc/template b/srcpkgs/moc/template
index 3a04932c8f1e61..838755f88db09e 100644
--- a/srcpkgs/moc/template
+++ b/srcpkgs/moc/template
@@ -1,10 +1,10 @@
 # Template file for 'moc'
 pkgname=moc
 version=2.5.2
-revision=7
+revision=8
 build_style=gnu-configure
 hostmakedepends="pkg-config"
-makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg-devel
+makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg4-devel
  jack-devel alsa-lib-devel libltdl-devel libflac-devel libvorbis-devel
  libmad-devel libmpcdec-devel libmodplug-devel libid3tag-devel faad2-devel
  taglib-devel libsndfile-devel wavpack-devel speex-devel libsamplerate-devel

From e8ad4cc2a8d7e52e206379e7d28cdaa30d1e52bd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 049/109] motion: revbump for ffmpeg6

---
 srcpkgs/motion/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/motion/template b/srcpkgs/motion/template
index 607ebeb3c7b242..bf63a91d9764f6 100644
--- a/srcpkgs/motion/template
+++ b/srcpkgs/motion/template
@@ -1,7 +1,7 @@
 # Template file for 'motion'
 pkgname=motion
 version=4.6.0
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake pkg-config gettext-devel tar"
 makedepends="ffmpeg-devel libmicrohttpd-devel v4l-utils-devel gettext-devel"

From c1b40a0acf83614eb71998e0e70380310a39fe5c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 050/109] olive: revbump for ffmpeg4

---
 srcpkgs/olive/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/olive/template b/srcpkgs/olive/template
index 12a46936c99003..5c2917b9c51245 100644
--- a/srcpkgs/olive/template
+++ b/srcpkgs/olive/template
@@ -1,10 +1,10 @@
 # Template file for 'olive'
 pkgname=olive
 version=0.1.2
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools pkg-config"
-makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg-devel frei0r-plugins"
+makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg4-devel frei0r-plugins"
 short_desc="Non-linear video editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"

From eaf8c44db7e5df24d2690543514bb4dd2eba4a11 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 051/109] opentoonz: revbump for ffmpeg6

---
 srcpkgs/opentoonz/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/opentoonz/template b/srcpkgs/opentoonz/template
index ee9f7603f55fd8..3e81834ca0eddf 100644
--- a/srcpkgs/opentoonz/template
+++ b/srcpkgs/opentoonz/template
@@ -1,7 +1,7 @@
 # Template file for 'opentoonz'
 pkgname=opentoonz
 version=1.6.0
-revision=2
+revision=3
 build_wrksrc="toonz/sources"
 build_style=cmake
 make_cmd=make

From ed2e9a3f6beba8ad4584a370a9fe863ff440ae49 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 052/109] pianobar: revbump for ffmpeg6

---
 srcpkgs/pianobar/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pianobar/template b/srcpkgs/pianobar/template
index e3febb821a4510..1e3dc1bf9308ee 100644
--- a/srcpkgs/pianobar/template
+++ b/srcpkgs/pianobar/template
@@ -1,7 +1,7 @@
 # Template file for 'pianobar'
 pkgname=pianobar
 version=2022.04.01
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="V=1"
 hostmakedepends="pkg-config"

From c87c3dfee16aa15d538ef77fd25e803d1a0fb25e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 053/109] ppsspp: revbump for ffmpeg6

---
 srcpkgs/ppsspp/patches/ffmpeg6.patch | 15 +++++++++++++++
 srcpkgs/ppsspp/template              |  3 +--
 2 files changed, 16 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/ppsspp/patches/ffmpeg6.patch

diff --git a/srcpkgs/ppsspp/patches/ffmpeg6.patch b/srcpkgs/ppsspp/patches/ffmpeg6.patch
new file mode 100644
index 00000000000000..5803c7bf227309
--- /dev/null
+++ b/srcpkgs/ppsspp/patches/ffmpeg6.patch
@@ -0,0 +1,15 @@
+--- a/Core/HW/SimpleAudioDec.cpp	2024-02-04 08:08:02.000000000 -0500
++++ b/Core/HW/SimpleAudioDec.cpp	2024-02-15 14:48:27.114362051 -0500
+@@ -81,7 +81,11 @@
+ 		return;
+ 	}
+ 	// Find decoder
++#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(58, 18, 100)
+ 	codec_ = avcodec_find_decoder((AVCodecID)audioCodecId);
++#else // this is a macro to const in the header
++	codec_ = (AVCodec*)avcodec_find_decoder((AVCodecID)audioCodecId);
++#endif
+ 	if (!codec_) {
+ 		// Eh, we shouldn't even have managed to compile. But meh.
+ 		ERROR_LOG(ME, "This version of FFMPEG does not support AV_CODEC_ctx for audio (%s). Update your submodule.", GetCodecName(audioType));
+
diff --git a/srcpkgs/ppsspp/template b/srcpkgs/ppsspp/template
index 2238a7601c0af8..1fda55268a2d39 100644
--- a/srcpkgs/ppsspp/template
+++ b/srcpkgs/ppsspp/template
@@ -1,7 +1,7 @@
 # Template file for 'ppsspp'
 pkgname=ppsspp
 version=1.17.1
-revision=1
+revision=2
 _glslang_commit=b34f619e1c85810dcb3c578107d2e48ba4ee2b37
 _SPIRV_Cross_commit=4212eef67ed0ca048cb726a6767185504e7695e5
 _armips_commit=a8d71f0f279eb0d30ecf6af51473b66ae0cf8e8d
@@ -91,7 +91,6 @@ post_configure() {
 }
 
 do_install() {
-	vlicense LICENSE.TXT
 	vinstall icons/icon.svg 644 usr/share/pixmaps ppsspp.svg
 	vinstall Qt/PPSSPP.desktop 644 usr/share/applications
 	vbin build/PPSSPPHeadless ppsspp-headless

From 5c93775950b614116b3f31d331cb07f5357bb173 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 054/109] pqiv: revbump for ffmpeg6

---
 srcpkgs/pqiv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pqiv/template b/srcpkgs/pqiv/template
index f9f7751196d4ee..0d50777e56a2d8 100644
--- a/srcpkgs/pqiv/template
+++ b/srcpkgs/pqiv/template
@@ -1,7 +1,7 @@
 # Template file for 'pqiv'
 pkgname=pqiv
 version=2.13.1
-revision=1
+revision=2
 build_style=gnu-makefile
 hostmakedepends="pkg-config"
 makedepends="glib-devel gtk+3-devel $(vopt_if ffmpeg ffmpeg-devel)

From 05315e89a79d47efd79c67de2b0516e35cd9e6f3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 055/109] qmmp: revbump for ffmpeg6

---
 srcpkgs/qmmp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qmmp/template b/srcpkgs/qmmp/template
index 53781ea3bc28ad..2da07f1e87eac0 100644
--- a/srcpkgs/qmmp/template
+++ b/srcpkgs/qmmp/template
@@ -1,7 +1,7 @@
 # Template file for 'qmmp'
 pkgname=qmmp
 version=1.6.1
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DUSE_HAL:BOOL=FALSE -DQMMP_DEFAULT_UI:STRING=simple"
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From 19bc71ac8ae11417bdc46945c08dbb18e95107c2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 14 Dec 2023 13:28:10 -0500
Subject: [PATCH 056/109] qt6-pdf: revbump for ffmpeg6

---
 srcpkgs/qt6-pdf/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-pdf/template b/srcpkgs/qt6-pdf/template
index ecda84afac1310..531b4e1d4fe84d 100644
--- a/srcpkgs/qt6-pdf/template
+++ b/srcpkgs/qt6-pdf/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-pdf'
 pkgname=qt6-pdf
 version=6.6.0
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DQT_FEATURE_qtpdf_build=ON
  -DQT_FEATURE_qtpdf_widgets_build=ON

From ac52dd46c80e5b6e412da5413131bcfdcdf4f53c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 057/109] qt5-webengine: revbump for ffmpeg6

---
 .../chromium-media-filters-cpp14.patch        |  11 ++
 srcpkgs/qt5-webengine/patches/ffmpeg5.patch   | 179 ++++++++++++++++++
 .../qtwebengine-fix-ffmpeg5-build.patch       |  14 ++
 srcpkgs/qt5-webengine/template                |   4 +-
 4 files changed, 206 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/ffmpeg5.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch

diff --git a/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
new file mode 100644
index 00000000000000..04adc540f2cbc0
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
@@ -0,0 +1,11 @@
+--- a/src/3rdparty/chromium/media/filters/BUILD.gn	2023-02-27 13:32:59.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/BUILD.gn	2023-04-02 17:21:39.204066384 -0400
+@@ -96,6 +96,8 @@
+     "//ui/gfx/geometry:geometry",
+   ]
+ 
++  cflags_cc = [ "-std=c++14" ]
++
+   libs = []
+ 
+   if (proprietary_codecs) {
diff --git a/srcpkgs/qt5-webengine/patches/ffmpeg5.patch b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..ac55e1634423a9
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
@@ -0,0 +1,179 @@
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:57.732547446 -0400
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:09.486478995 -0400
+@@ -57,6 +57,8 @@
+ 
+ namespace {
+ 
++constexpr int64_t kRelativeTsBase = static_cast<int64_t>(0x7ffeffffffffffff);
++
+ void SetAVStreamDiscard(AVStream* stream, AVDiscard discard) {
+   DCHECK(stream);
+   stream->discard = discard;
+@@ -90,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+   if (stream->start_time != kNoFFmpegTimestamp)
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (stream->first_dts != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, stream->first_dts);
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -408,11 +398,11 @@
+   scoped_refptr<DecoderBuffer> buffer;
+ 
+   if (type() == DemuxerStream::TEXT) {
+-    int id_size = 0;
++    size_t id_size = 0;
+     uint8_t* id_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
+ 
+-    int settings_size = 0;
++    size_t settings_size = 0;
+     uint8_t* settings_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
+ 
+@@ -424,7 +414,7 @@
+     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
+                                      side_data.data(), side_data.size());
+   } else {
+-    int side_data_size = 0;
++    size_t side_data_size = 0;
+     uint8_t* side_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
+ 
+@@ -485,7 +475,7 @@
+                                        packet->size - data_offset);
+     }
+ 
+-    int skip_samples_size = 0;
++    size_t skip_samples_size = 0;
+     const uint32_t* skip_samples_ptr =
+         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
+             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
+@@ -1587,6 +1577,8 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++      continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+       lowest_start_time_stream = stream.get();
+@@ -1604,6 +1596,8 @@
+     if (stream && stream->type() == DemuxerStream::VIDEO &&
+         stream->IsEnabled()) {
+       video_stream = stream.get();
++      if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++        continue;
+       if (video_stream->start_time() <= seek_time) {
+         return video_stream;
+       }
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h qtwebengine-5.15.10/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h
+--- a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-07-11 22:12:47.917192788 -0500
+@@ -29,6 +29,7 @@ extern "C" {
+ #include <libavformat/avformat.h>
+ #include <libavformat/avio.h>
+ #include <libavutil/avutil.h>
++#include <libavutil/channel_layout.h>
+ #include <libavutil/imgutils.h>
+ #include <libavutil/log.h>
+ #include <libavutil/mastering_display_metadata.h>
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/audio_file_reader.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/audio_file_reader.cc
+--- a/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -85,7 +85,7 @@ bool AudioFileReader::OpenDemuxer() {
+ }
+ 
+ bool AudioFileReader::OpenDecoder() {
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (codec) {
+     // MP3 decodes to S16P which we don't support, tell it to use S16 instead.
+     if (codec_context_->sample_fmt == AV_SAMPLE_FMT_S16P)
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -329,7 +329,7 @@ bool FFmpegAudioDecoder::ConfigureDecode
+     }
+   }
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec ||
+       avcodec_open2(codec_context_.get(), codec, &codec_options) < 0) {
+     DLOG(ERROR) << "Could not initialize audio decoder: "
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -59,7 +59,6 @@ static int64_t AVIOSeekOperation(void* o
+ }
+ 
+ void FFmpegGlue::InitializeFFmpeg() {
+-  av_register_all();
+ }
+ 
+ static void LogContainer(bool is_local_file,
+@@ -95,9 +94,6 @@ FFmpegGlue::FFmpegGlue(FFmpegURLProtocol
+   // Enable fast, but inaccurate seeks for MP3.
+   format_context_->flags |= AVFMT_FLAG_FAST_SEEK;
+ 
+-  // Ensures we can read out various metadata bits like vp8 alpha.
+-  format_context_->flags |= AVFMT_FLAG_KEEP_SIDE_DATA;
+-
+   // Ensures format parsing errors will bail out. From an audit on 11/2017, all
+   // instances were real failures. Solves bugs like http://crbug.com/710791.
+   format_context_->error_recognition |= AV_EF_EXPLODE;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -391,7 +391,7 @@ bool FFmpegVideoDecoder::ConfigureDecode
+   if (decode_nalus_)
+     codec_context_->flags2 |= AV_CODEC_FLAG2_CHUNKS;
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
+     ReleaseFFmpegResources();
+     return false;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/media_file_checker.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/media_file_checker.cc
+--- a/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -68,7 +68,7 @@ bool MediaFileChecker::Start(base::TimeD
+       auto context = AVStreamToAVCodecContext(format_context->streams[i]);
+       if (!context)
+         continue;
+-      AVCodec* codec = avcodec_find_decoder(cp->codec_id);
++      const AVCodec* codec = avcodec_find_decoder(cp->codec_id);
+       if (codec && avcodec_open2(context.get(), codec, nullptr) >= 0) {
+         auto loop = std::make_unique<FFmpegDecodingLoop>(context.get());
+         stream_contexts[i] = {std::move(context), std::move(loop)};
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc qtwebengine-5.15.10/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc
+--- a/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -203,7 +203,7 @@ int32_t H264DecoderImpl::InitDecode(cons
+   // a pointer |this|.
+   av_context_->opaque = this;
+ 
+-  AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
+   if (!codec) {
+     // This is an indication that FFmpeg has not been initialized or it has not
+     // been compiled/initialized with the correct set of codecs.
diff --git a/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch b/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch
new file mode 100644
index 00000000000000..bc24d5b9a29cb5
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch
@@ -0,0 +1,14 @@
+--- a/src/buildtools/configure.json	2023-12-09 11:06:01.503058569 -0500
++++ b/src/buildtools/configure.json	2023-12-09 11:06:14.982361345 -0500
+@@ -779,11 +779,6 @@
+             "type": "warning",
+             "condition": "config.ios && config.simulator && config.device && features.build-qtpdf",
+             "message": "Building fat libray with device and simulator architectures will disable NEON."
+-        },
+-        {
+-            "type": "fatal",
+-            "condition": "features.webengine-system-ffmpeg && !libs.webengine-ffmpeg-support",
+-            "message": "Unmodified ffmpeg >= 5.0 is not supported. Please configure with -qt-webengine-ffmpeg."
+         }
+     ],
+     "summary": [
diff --git a/srcpkgs/qt5-webengine/template b/srcpkgs/qt5-webengine/template
index 8d2df1b5175bad..1687a77eb8a2f5 100644
--- a/srcpkgs/qt5-webengine/template
+++ b/srcpkgs/qt5-webengine/template
@@ -1,14 +1,14 @@
 # Template file for 'qt5-webengine'
 pkgname=qt5-webengine
 version=5.15.16
-revision=1
+revision=2
 _version="${version}-lts"
 _chromium_commit=207c2ac45ca3386d153770c6b0d2ea2ec21ca880
 archs="x86_64* i686* armv[67]* ppc64* aarch64*"
 create_wrksrc=yes
 build_style=qmake
 configure_args="--
- -webengine-icu -webengine-ffmpeg -webengine-opus -webengine-webp
+ -webengine-icu -system-ffmpeg -webengine-opus -webengine-webp
  -webengine-pepper-plugins -webengine-printing-and-pdf -webengine-proprietary-codecs
  -webengine-pulseaudio -webengine-spellchecker -webengine-webrtc -webengine-geolocation
  -webengine-kerberos -no-webengine-embedded-build $(vopt_if sndio '' '-no')-webengine-sndio

From 3cac94131e95069831fd613ce5c7b89672424ede Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 058/109] qt5: revbump for ffmpeg6

---
 srcpkgs/qt5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5/template b/srcpkgs/qt5/template
index 3efb7e42d5fd3f..27f6d5388cd15c 100644
--- a/srcpkgs/qt5/template
+++ b/srcpkgs/qt5/template
@@ -3,9 +3,9 @@
 # revbump libqtxdg after bumping patch version
 pkgname=qt5
 version=5.15.11+20231124
+revision=3
 # commit 4765fa1df7a837db9c1f89c4da0dd76b74bb5fab
 # base repo: https://invent.kde.org/qt/qt/qt5
-revision=2
 build_style=meta
 hostmakedepends="cmake clang17 flex perl glib-devel pkg-config
  python3 re2c ruby which"

From b1775a85baf69fde21f8103ef038fd4be7983d6a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 059/109] qtav: revbump for ffmpeg4

---
 srcpkgs/qtav/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtav/template b/srcpkgs/qtav/template
index 775d5a139a9efa..aa69e213c984b0 100644
--- a/srcpkgs/qtav/template
+++ b/srcpkgs/qtav/template
@@ -1,10 +1,10 @@
 # Template file for 'qtav'
 pkgname=qtav
 version=1.13.0
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel libass-devel libopenal-devel
+makedepends="ffmpeg4-devel libass-devel libopenal-devel
  libva-glx-devel libXv-devel pulseaudio-devel
  qt5-declarative-devel qt5-svg-devel
  qt5-quickcontrols"

From 4998010e6e4792513bc5ef28c240fc61b74d24cd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 060/109] retroarch: revbump for ffmpeg6

---
 srcpkgs/retroarch/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroarch/template b/srcpkgs/retroarch/template
index cb3125c5dbf1ae..c65c26f7bf0332 100644
--- a/srcpkgs/retroarch/template
+++ b/srcpkgs/retroarch/template
@@ -1,7 +1,7 @@
 # Template file for 'retroarch'
 pkgname=retroarch
 version=1.16.0.3
-revision=3
+revision=4
 build_style=configure
 configure_args="--prefix=/usr --sysconfdir=/etc --enable-networking
  --enable-udev --disable-builtinflac --disable-builtinglslang

From 90207f3e1d8da9cfd7f2ea10439068b55ed28571 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 061/109] scrcpy: revbump for ffmpeg6

---
 srcpkgs/scrcpy/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/scrcpy/template b/srcpkgs/scrcpy/template
index d04de770dc1913..5218fa01f8ce1f 100644
--- a/srcpkgs/scrcpy/template
+++ b/srcpkgs/scrcpy/template
@@ -1,7 +1,7 @@
 # Template file for 'scrcpy'
 pkgname=scrcpy
 version=2.3.1
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcompile_server=false
  -Dprebuilt_server=/usr/share/scrcpy/scrcpy-server-v${version}"

From 8bbb59688c755d5a238e5223ea99802d52d86e80 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 17 Oct 2023 08:54:11 -0400
Subject: [PATCH 062/109] New package: spex-x replaces spek-alternative for
 ffmpeg6

---
 srcpkgs/spek-alternative                      |  1 +
 srcpkgs/spek-x/patches/musl.patch             |  7 ++++++
 srcpkgs/{spek-alternative => spek-x}/template | 22 ++++++++++++-------
 3 files changed, 22 insertions(+), 8 deletions(-)
 create mode 120000 srcpkgs/spek-alternative
 create mode 100644 srcpkgs/spek-x/patches/musl.patch
 rename srcpkgs/{spek-alternative => spek-x}/template (52%)

diff --git a/srcpkgs/spek-alternative b/srcpkgs/spek-alternative
new file mode 120000
index 00000000000000..76648236da7017
--- /dev/null
+++ b/srcpkgs/spek-alternative
@@ -0,0 +1 @@
+spek-x
\ No newline at end of file
diff --git a/srcpkgs/spek-x/patches/musl.patch b/srcpkgs/spek-x/patches/musl.patch
new file mode 100644
index 00000000000000..662f45936febc6
--- /dev/null
+++ b/srcpkgs/spek-x/patches/musl.patch
@@ -0,0 +1,7 @@
+--- a/tests/perf.cc	2024-03-09 17:13:49.086603418 -0500
++++ b/tests/perf.cc	2024-03-09 17:13:59.453603753 -0500
+@@ -1,3 +1,4 @@
++#include <cstdint>
+ #include <cstdlib>
+ #include <iostream>
+ #include <fstream>
diff --git a/srcpkgs/spek-alternative/template b/srcpkgs/spek-x/template
similarity index 52%
rename from srcpkgs/spek-alternative/template
rename to srcpkgs/spek-x/template
index d7b55c776b1d43..3ded6c2c323e4f 100644
--- a/srcpkgs/spek-alternative/template
+++ b/srcpkgs/spek-x/template
@@ -1,18 +1,18 @@
-# Template file for 'spek-alternative'
-pkgname=spek-alternative
-version=0.8.2.3
-revision=2
+# Template file for 'spek-x'
+pkgname=spek-x
+version=0.9.3
+revision=1
 build_style=gnu-configure
 hostmakedepends="automake gettext-devel intltool libtool pkg-config
  wxWidgets-common wxWidgets-gtk3-devel"
 makedepends="ffmpeg-devel wxWidgets-gtk3-devel"
 depends="ffmpeg"
 short_desc="Acoustic spectrum analyser"
-maintainer="Kartik Singh <kartik.ynwa@gmail.com>"
+maintainer="zlice <zlice555@gmail.com>"
 license="GPL-3.0-or-later"
-homepage="https://github.com/withmorten/spek-alternative"
-distfiles="https://github.com/withmorten/spek-alternative/archive/${version}.tar.gz"
-checksum="007ba4b84a310b078e378aa84c8e80783db5821437a757a488c3ecec377e6b2a"
+homepage="https://github.com/MikeWang000000/spek-x"
+distfiles="https://github.com/MikeWang000000/spek-x/archive/v${version}.tar.gz"
+checksum="7f4b109903333cdd310ab2b9176f0dc49a565891376e281a233d342cedf90ef7"
 
 CXXFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
 
@@ -22,3 +22,9 @@ export WX_CONFIG_NAME="wx-config-gtk3"
 pre_configure() {
 	NOCONFIGURE=1 ./autogen.sh
 }
+
+spek-alternative_package() {
+	depends="spek-x"
+	short_desc+=" - transitional dummy package"
+	build_style=meta
+}

From 642aad0ea8ff01a4c8e8e0eece612d83028daba7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 063/109] ssr: revbump for ffmpeg6

---
 .../0001-Fix-build-with-ffmpeg-5.0.patch      | 241 ++++++++++++++++++
 srcpkgs/ssr/template                          |   2 +-
 2 files changed, 242 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ssr/patches/0001-Fix-build-with-ffmpeg-5.0.patch

diff --git a/srcpkgs/ssr/patches/0001-Fix-build-with-ffmpeg-5.0.patch b/srcpkgs/ssr/patches/0001-Fix-build-with-ffmpeg-5.0.patch
new file mode 100644
index 00000000000000..4c069b5a9fc464
--- /dev/null
+++ b/srcpkgs/ssr/patches/0001-Fix-build-with-ffmpeg-5.0.patch
@@ -0,0 +1,241 @@
+From f4cbde38021d9330dc73d2e3dfa8a70da3ff5721 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Bernhard=20Rosenkr=C3=A4nzer?= <bero@lindev.ch>
+Date: Sun, 16 Jan 2022 02:40:04 +0100
+Subject: [PATCH] Fix build with ffmpeg 5.0
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Adapt to ffmpeg 5.0 requiring more const-ness for AVCodec.
+
+Signed-off-by: Bernhard Rosenkränzer <bero@lindev.ch>
+---
+ src/AV/Output/AudioEncoder.cpp |  6 +++---
+ src/AV/Output/AudioEncoder.h   |  4 ++--
+ src/AV/Output/BaseEncoder.cpp  |  4 ++--
+ src/AV/Output/BaseEncoder.h    |  4 ++--
+ src/AV/Output/Muxer.cpp        | 12 ++++++------
+ src/AV/Output/Muxer.h          |  4 ++--
+ src/AV/Output/VideoEncoder.cpp |  6 +++---
+ src/AV/Output/VideoEncoder.h   |  4 ++--
+ 8 files changed, 22 insertions(+), 22 deletions(-)
+
+diff --git a/src/AV/Output/AudioEncoder.cpp b/src/AV/Output/AudioEncoder.cpp
+index 34d015c..cefc2e0 100644
+--- a/src/AV/Output/AudioEncoder.cpp
++++ b/src/AV/Output/AudioEncoder.cpp
+@@ -34,7 +34,7 @@ const std::vector<AudioEncoder::SampleFormatData> AudioEncoder::SUPPORTED_SAMPLE
+ 
+ const unsigned int AudioEncoder::DEFAULT_FRAME_SAMPLES = 1024;
+ 
+-AudioEncoder::AudioEncoder(Muxer* muxer, AVStream* stream, AVCodecContext *codec_context, AVCodec* codec, AVDictionary** options)
++AudioEncoder::AudioEncoder(Muxer* muxer, AVStream* stream, AVCodecContext *codec_context, const AVCodec* codec, AVDictionary** options)
+ 	: BaseEncoder(muxer, stream, codec_context, codec, options) {
+ 
+ #if !SSR_USE_AVCODEC_ENCODE_AUDIO2
+@@ -77,7 +77,7 @@ unsigned int AudioEncoder::GetSampleRate() {
+ }
+ 
+ bool AudioEncoder::AVCodecIsSupported(const QString& codec_name) {
+-	AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
++	const AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
+ 	if(codec == NULL)
+ 		return false;
+ 	if(!av_codec_is_encoder(codec))
+@@ -93,7 +93,7 @@ bool AudioEncoder::AVCodecIsSupported(const QString& codec_name) {
+ 	return false;
+ }
+ 
+-void AudioEncoder::PrepareStream(AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
++void AudioEncoder::PrepareStream(AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
+ 								 unsigned int bit_rate, unsigned int channels, unsigned int sample_rate) {
+ 
+ 	if(channels == 0) {
+diff --git a/src/AV/Output/AudioEncoder.h b/src/AV/Output/AudioEncoder.h
+index c93278c..ae9c82e 100644
+--- a/src/AV/Output/AudioEncoder.h
++++ b/src/AV/Output/AudioEncoder.h
+@@ -40,7 +40,7 @@ private:
+ #endif
+ 
+ public:
+-	AudioEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options);
++	AudioEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options);
+ 	~AudioEncoder();
+ 
+ 	// Returns the required frame size, i.e. the number of samples (for each channel).
+@@ -57,7 +57,7 @@ public:
+ 
+ public:
+ 	static bool AVCodecIsSupported(const QString& codec_name);
+-	static void PrepareStream(AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
++	static void PrepareStream(AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
+ 							  unsigned int bit_rate, unsigned int channels, unsigned int sample_rate);
+ 
+ private:
+diff --git a/src/AV/Output/BaseEncoder.cpp b/src/AV/Output/BaseEncoder.cpp
+index 7c01ef3..4780aaf 100644
+--- a/src/AV/Output/BaseEncoder.cpp
++++ b/src/AV/Output/BaseEncoder.cpp
+@@ -42,7 +42,7 @@ double ParseCodecOptionDouble(const QString& key, const QString& value, double m
+ 	return clamp(value_double, min, max) * multiply;
+ }
+ 
+-BaseEncoder::BaseEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options) {
++BaseEncoder::BaseEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options) {
+ 
+ 	m_muxer = muxer;
+ 	m_stream = stream;
+@@ -157,7 +157,7 @@ void BaseEncoder::IncrementPacketCounter() {
+ 	++lock->m_total_packets;
+ }
+ 
+-void BaseEncoder::Init(AVCodec* codec, AVDictionary** options) {
++void BaseEncoder::Init(const AVCodec* codec, AVDictionary** options) {
+ 
+ 	// open codec
+ 	if(avcodec_open2(m_codec_context, codec, options) < 0) {
+diff --git a/src/AV/Output/BaseEncoder.h b/src/AV/Output/BaseEncoder.h
+index 3d92f29..7f02bbd 100644
+--- a/src/AV/Output/BaseEncoder.h
++++ b/src/AV/Output/BaseEncoder.h
+@@ -51,7 +51,7 @@ private:
+ 	std::atomic<bool> m_should_stop, m_should_finish, m_is_done, m_error_occurred;
+ 
+ protected:
+-	BaseEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options);
++	BaseEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options);
+ 
+ public:
+ 	virtual ~BaseEncoder(); // encoders will be deleted by Muxer, don't delete them yourself!
+@@ -117,7 +117,7 @@ protected:
+ 	void IncrementPacketCounter();
+ 
+ private:
+-	void Init(AVCodec* codec, AVDictionary** options);
++	void Init(const AVCodec* codec, AVDictionary** options);
+ 	void Free();
+ 
+ 	void EncoderThread();
+diff --git a/src/AV/Output/Muxer.cpp b/src/AV/Output/Muxer.cpp
+index ad58380..14650b0 100644
+--- a/src/AV/Output/Muxer.cpp
++++ b/src/AV/Output/Muxer.cpp
+@@ -87,7 +87,7 @@ Muxer::~Muxer() {
+ 
+ VideoEncoder* Muxer::AddVideoEncoder(const QString& codec_name, const std::vector<std::pair<QString, QString> >& codec_options,
+ 									 unsigned int bit_rate, unsigned int width, unsigned int height, unsigned int frame_rate) {
+-	AVCodec *codec = FindCodec(codec_name);
++	const AVCodec *codec = FindCodec(codec_name);
+ 	AVCodecContext *codec_context = NULL;
+ 	AVStream *stream = AddStream(codec, &codec_context);
+ 	VideoEncoder *encoder;
+@@ -111,7 +111,7 @@ VideoEncoder* Muxer::AddVideoEncoder(const QString& codec_name, const std::vecto
+ 
+ AudioEncoder* Muxer::AddAudioEncoder(const QString& codec_name, const std::vector<std::pair<QString, QString> >& codec_options,
+ 									 unsigned int bit_rate, unsigned int channels, unsigned int sample_rate) {
+-	AVCodec *codec = FindCodec(codec_name);
++	const AVCodec *codec = FindCodec(codec_name);
+ 	AVCodecContext *codec_context = NULL;
+ 	AVStream *stream = AddStream(codec, &codec_context);
+ 	AudioEncoder *encoder;
+@@ -194,7 +194,7 @@ unsigned int Muxer::GetQueuedPacketCount(unsigned int stream_index) {
+ void Muxer::Init() {
+ 
+ 	// get the format we want (this is just a pointer, we don't have to free this)
+-	AVOutputFormat *format = av_guess_format(m_container_name.toUtf8().constData(), NULL, NULL);
++	const AVOutputFormat *format = av_guess_format(m_container_name.toUtf8().constData(), NULL, NULL);
+ 	if(format == NULL) {
+ 		Logger::LogError("[Muxer::Init] " + Logger::tr("Error: Can't find chosen output format!"));
+ 		throw LibavException();
+@@ -261,8 +261,8 @@ void Muxer::Free() {
+ 	}
+ }
+ 
+-AVCodec* Muxer::FindCodec(const QString& codec_name) {
+-	AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
++const AVCodec* Muxer::FindCodec(const QString& codec_name) {
++	const AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
+ 	if(codec == NULL) {
+ 		Logger::LogError("[Muxer::FindCodec] " + Logger::tr("Error: Can't find codec!"));
+ 		throw LibavException();
+@@ -270,7 +270,7 @@ AVCodec* Muxer::FindCodec(const QString& codec_name) {
+ 	return codec;
+ }
+ 
+-AVStream* Muxer::AddStream(AVCodec* codec, AVCodecContext** codec_context) {
++AVStream* Muxer::AddStream(const AVCodec* codec, AVCodecContext** codec_context) {
+ 	assert(!m_started);
+ 	assert(m_format_context->nb_streams < MUXER_MAX_STREAMS);
+ 
+diff --git a/src/AV/Output/Muxer.h b/src/AV/Output/Muxer.h
+index d72347d..b104bcb 100644
+--- a/src/AV/Output/Muxer.h
++++ b/src/AV/Output/Muxer.h
+@@ -114,8 +114,8 @@ private:
+ 	void Init();
+ 	void Free();
+ 
+-	AVCodec* FindCodec(const QString& codec_name);
+-	AVStream* AddStream(AVCodec* codec, AVCodecContext** codec_context);
++	const AVCodec* FindCodec(const QString& codec_name);
++	AVStream* AddStream(const AVCodec* codec, AVCodecContext** codec_context);
+ 
+ 	void MuxerThread();
+ 
+diff --git a/src/AV/Output/VideoEncoder.cpp b/src/AV/Output/VideoEncoder.cpp
+index 8087e8e..fc8b5d1 100644
+--- a/src/AV/Output/VideoEncoder.cpp
++++ b/src/AV/Output/VideoEncoder.cpp
+@@ -34,7 +34,7 @@ const std::vector<VideoEncoder::PixelFormatData> VideoEncoder::SUPPORTED_PIXEL_F
+ 	{"rgb", AV_PIX_FMT_RGB24, false},
+ };
+ 
+-VideoEncoder::VideoEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options)
++VideoEncoder::VideoEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options)
+ 	: BaseEncoder(muxer, stream, codec_context, codec, options) {
+ 
+ #if !SSR_USE_AVCODEC_ENCODE_VIDEO2
+@@ -95,7 +95,7 @@ unsigned int VideoEncoder::GetFrameRate() {
+ }
+ 
+ bool VideoEncoder::AVCodecIsSupported(const QString& codec_name) {
+-	AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
++	const AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
+ 	if(codec == NULL)
+ 		return false;
+ 	if(!av_codec_is_encoder(codec))
+@@ -111,7 +111,7 @@ bool VideoEncoder::AVCodecIsSupported(const QString& codec_name) {
+ 	return false;
+ }
+ 
+-void VideoEncoder::PrepareStream(AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
++void VideoEncoder::PrepareStream(AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
+ 								 unsigned int bit_rate, unsigned int width, unsigned int height, unsigned int frame_rate) {
+ 
+ 	if(width == 0 || height == 0) {
+diff --git a/src/AV/Output/VideoEncoder.h b/src/AV/Output/VideoEncoder.h
+index cb7ca27..68d872e 100644
+--- a/src/AV/Output/VideoEncoder.h
++++ b/src/AV/Output/VideoEncoder.h
+@@ -40,7 +40,7 @@ private:
+ #endif
+ 
+ public:
+-	VideoEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options);
++	VideoEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options);
+ 	~VideoEncoder();
+ 
+ 	// Returns the required pixel format.
+@@ -55,7 +55,7 @@ public:
+ 
+ public:
+ 	static bool AVCodecIsSupported(const QString& codec_name);
+-	static void PrepareStream(AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
++	static void PrepareStream(AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
+ 							  unsigned int bit_rate, unsigned int width, unsigned int height, unsigned int frame_rate);
+ 
+ private:
+-- 
+2.43.0
+
diff --git a/srcpkgs/ssr/template b/srcpkgs/ssr/template
index 3097754e3cbe54..e3c4261f1f5a64 100644
--- a/srcpkgs/ssr/template
+++ b/srcpkgs/ssr/template
@@ -1,7 +1,7 @@
 # Template file for 'ssr'
 pkgname=ssr
 version=0.4.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DWITH_QT5=ON"
 hostmakedepends="pkg-config"

From b18fb540effc391442b3aac7371ef286c903c8fc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 064/109] synfig: revbump for ffmpeg6 and mlt7

---
 srcpkgs/synfig/patches/ffmpeg6.patch | 71 ++++++++++++++++++++++++++++
 srcpkgs/synfig/template              |  6 +--
 2 files changed, 74 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/synfig/patches/ffmpeg6.patch

diff --git a/srcpkgs/synfig/patches/ffmpeg6.patch b/srcpkgs/synfig/patches/ffmpeg6.patch
new file mode 100644
index 00000000000000..10780b42782f4b
--- /dev/null
+++ b/srcpkgs/synfig/patches/ffmpeg6.patch
@@ -0,0 +1,71 @@
+--- a/src/modules/mod_libavcodec/trgt_av.cpp	2022-10-25 09:14:12.000000000 -0400
++++ b/src/modules/mod_libavcodec/trgt_av.cpp	2023-05-05 21:34:17.899194559 -0400
+@@ -38,6 +41,7 @@
+ extern "C"
+ {
+ #ifdef HAVE_LIBAVFORMAT_AVFORMAT_H
++#	include <libavcodec/avcodec.h>
+ #	include <libavformat/avformat.h>
+ #elif defined(HAVE_AVFORMAT_H)
+ #	include <avformat.h>
+@@ -155,11 +156,11 @@
+     }
+ 
+ 	bool open_video_stream() {
+-		if (avcodec_open2(video_context, NULL, NULL) < 0) {
++		if (avcodec_open2(video_context, nullptr, nullptr) < 0) {
+ 			synfig::error("Target_LibAVCodec: could not open video codec");
+ 			// seems the calling of avcodec_free_context after error will cause crash
+ 			// so just forget about this context
+-			video_context = NULL;
++			video_context = nullptr;
+ 			close();
+ 			return false;
+         }
+@@ -234,15 +235,21 @@
+ 		close();
+ 
+ 		if (!av_registered) {
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 			av_register_all();
++#endif
+ 			av_registered = true;
+ 		}
+ 
+ 		// guess format
+-		AVOutputFormat *format = av_guess_format(NULL, filename.c_str(), NULL);
++#if LIBAVCODEC_VERSION_MAJOR < 59 // FFMPEG < 5.0
++		AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#else
++		const AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#endif
+ 		if (!format) {
+ 			synfig::warning("Target_LibAVCodec: unable to guess the output format, defaulting to MPEG");
+-			format = av_guess_format("mpeg", NULL, NULL);
++			format = av_guess_format("mpeg", nullptr, nullptr);
+ 		}
+ 		if (!format) {
+ 			synfig::error("Target_LibAVCodec: unable to find 'mpeg' output format");
+@@ -254,6 +261,7 @@
+ 		context = avformat_alloc_context();
+ 		assert(context);
+ 		context->oformat = format;
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 		if (filename.size() + 1 > sizeof(context->filename)) {
+ 			synfig::error(
+ 				"Target_LibAVCodec: filename too long, max length is %d, filename is '%s'",
+@@ -263,6 +271,14 @@
+ 			return false;
+ 		}
+ 		memcpy(context->filename, filename.c_str(), filename.size() + 1);
++#else
++		context->url = av_strndup(filename.c_str(), filename.size());
++		if (!context->url) {
++			synfig::error("Target_LibAVCodec: cannot allocate space for filename");
++			close();
++			return false;
++		}
++#endif
+ 
+ 		packet = av_packet_alloc();
+ 		assert(packet);
diff --git a/srcpkgs/synfig/template b/srcpkgs/synfig/template
index d4d3e341a20bf8..828b5cb32956ee 100644
--- a/srcpkgs/synfig/template
+++ b/srcpkgs/synfig/template
@@ -2,11 +2,11 @@
 # Should be kept in sync with 'synfigstudio' and 'ETL'
 pkgname=synfig
 version=1.4.4
-revision=4
+revision=5
 build_style=gnu-configure
 configure_args="--with-boost-libdir=${XBPS_CROSS_BASE}/usr/lib"
 hostmakedepends="boost-build ImageMagick pkg-config intltool"
-makedepends="ETL gettext-devel libxml++-devel mlt-devel libmagick-devel
+makedepends="ETL gettext-devel libxml++-devel mlt7-devel libmagick-devel
  libmng-devel boost-build boost-devel libopenexr-devel ffmpeg-devel"
 depends="ImageMagick"
 short_desc="CLI 2D vector and timeline-based animation software"
@@ -20,7 +20,7 @@ CXXFLAGS="-std=c++11 -DHAVE_LOCALE_H=1"
 
 synfig-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision}
-	 libopenexr-devel libxml++-devel mlt-devel"
+	 libopenexr-devel libxml++-devel mlt7-devel"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/bin/synfig-config

From bb1f1cca1341e70f7b3a5bb2acb8b2a5aea8a4bf Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 065/109] timg: revbump for ffmpeg6

---
 srcpkgs/timg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/timg/template b/srcpkgs/timg/template
index 2a2ab763d2fddf..8fb4327535ef93 100644
--- a/srcpkgs/timg/template
+++ b/srcpkgs/timg/template
@@ -1,7 +1,7 @@
 # Template file for 'timg'
 pkgname=timg
 version=1.4.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_OPENSLIDE_SUPPORT=off -Wno-dev"
 hostmakedepends="pkg-config git"

From 7a85513da4f95ca691e20361d2de8c7f53e65447 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 066/109] tvheadend: revbump for ffmpeg4

---
 srcpkgs/tvheadend/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tvheadend/template b/srcpkgs/tvheadend/template
index 9aea7de4ec7057..012d31c4879ff1 100644
--- a/srcpkgs/tvheadend/template
+++ b/srcpkgs/tvheadend/template
@@ -8,7 +8,7 @@ configure_args="--enable-dvbscan --disable-ffmpeg_static
 --disable-libx265_static --disable-libvpx_static --disable-libtheora_static
 --disable-libvorbis_static --disable-libfdkaac_static"
 hostmakedepends="gettext pkg-config python3 git which"
-makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg-devel"
+makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg4-devel"
 short_desc="TV streaming server"
 maintainer="lemmi <lemmi@nerd2nerd.org>"
 license="GPL-3.0-only"

From f667d4fc8ad01c71e493ecd877d6d69337158b56 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 067/109] unpaper: update to 7.0.0.

---
 srcpkgs/unpaper/template | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/srcpkgs/unpaper/template b/srcpkgs/unpaper/template
index 38ed47a5840165..1ff910e722afc8 100644
--- a/srcpkgs/unpaper/template
+++ b/srcpkgs/unpaper/template
@@ -1,13 +1,13 @@
 # Template file for 'unpaper'
 pkgname=unpaper
-version=6.1
-revision=3
-build_style=gnu-configure
+version=7.0.0
+revision=1
+build_style=meson
+hostmakedepends="pkg-config meson libxslt"
+makedepends="ffmpeg-devel python3-Sphinx"
+short_desc="Post-processing tool for scanned sheets of paper"
 maintainer="Orphaned <orphan@voidlinux.org>"
-hostmakedepends="pkg-config libxslt"
-makedepends="ffmpeg-devel"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://www.flameeyes.eu/projects/unpaper"
-short_desc="A post-processing tool for scanned sheets of paper"
 distfiles="https://www.flameeyes.eu/files/${pkgname}-${version}.tar.xz"
-checksum=237c84f5da544b3f7709827f9f12c37c346cdf029b1128fb4633f9bafa5cb930
+checksum=2575fbbf26c22719d1cb882b59602c9900c7f747118ac130883f63419be46a80

From c1ef233788b50b5f43fa9ada66578b2a59d782a2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 068/109] vice: revbump for ffmpeg4

---
 srcpkgs/vice/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vice/template b/srcpkgs/vice/template
index 1c641d9ae9be22..4f43e85b5b8972 100644
--- a/srcpkgs/vice/template
+++ b/srcpkgs/vice/template
@@ -1,7 +1,7 @@
 # Template file for 'vice'
 pkgname=vice
 version=3.8
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-cpuhistory --enable-x64 --disable-pdf-docs
  --libdir=/usr/lib$XBPS_TARGET_WORDSIZE $(vopt_enable sdl2 sdlui2)

From c2e111210b2cf05d3a8072f9478a3a74aedd6113 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 069/109] waypipe: revbump for ffmpeg6

---
 srcpkgs/waypipe/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waypipe/template b/srcpkgs/waypipe/template
index 6da88b21bf2a19..4da8058400b588 100644
--- a/srcpkgs/waypipe/template
+++ b/srcpkgs/waypipe/template
@@ -1,7 +1,7 @@
 # Template file for 'waypipe'
 pkgname=waypipe
 version=0.8.6
-revision=1
+revision=2
 build_style=meson
 # lto is off because it causes linking errors in armv6l and armv7l (due to NEON)
 configure_args="-Dwerror=false -Dwith_dmabuf=enabled -Dwith_lz4=enabled

From 1921c87af8f6d40a23deeecfbb7f661345fcd2a8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 070/109] xpra: revbump for ffmpeg6

---
 srcpkgs/xpra/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xpra/template b/srcpkgs/xpra/template
index 3e49ab23deac9c..3939026a6fbf90 100644
--- a/srcpkgs/xpra/template
+++ b/srcpkgs/xpra/template
@@ -1,7 +1,7 @@
 # Template file for 'xpra'
 pkgname=xpra
 version=5.0.7
-revision=1
+revision=2
 build_style=python3-module
 make_build_args="--without-cuda_kernels --without-cuda_rebuild"
 make_install_args="$(vopt_with docs) ${make_build_args}"

From c9313f4c1ef59c96ddd913b181002f0f508ccc9d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:07:40 -0400
Subject: [PATCH 071/109] nv-codec-headers: update to 12.0.16.0

---
 srcpkgs/nv-codec-headers/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/nv-codec-headers/template b/srcpkgs/nv-codec-headers/template
index 3d422a61e48917..251e057f826fb8 100644
--- a/srcpkgs/nv-codec-headers/template
+++ b/srcpkgs/nv-codec-headers/template
@@ -1,6 +1,6 @@
 # Template file for 'nv-codec-headers'
 pkgname=nv-codec-headers
-version=11.1.5.1
+version=12.0.16.0
 revision=1
 build_style=gnu-makefile
 short_desc="FFmpeg version of headers required to interface with Nvidias codec APIs"
@@ -8,7 +8,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="MIT"
 homepage="http://git.videolan.org/?p=ffmpeg/nv-codec-headers.git"
 distfiles="https://github.com/FFmpeg/nv-codec-headers/archive/n${version}.tar.gz"
-checksum=d095fbd56aa93772471a323be0ebe65504a0f43f06c76a30b6d25da77b06ae9c
+checksum=2a1533b65f55f9da52956faf0627ed3b74868ac0c7f269990edd21369113b48f
 
 post_install() {
 	sed -n '4,25p' include/ffnvcodec/nvEncodeAPI.h > LICENSE

From 6dbea7223d8dee7c3d4b037121090074666f00b0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:08:40 -0400
Subject: [PATCH 072/109] openimagedenoise: revbump for ffmpeg6

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index 109deb171c3f75..44edf38fb289d8 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,7 +1,7 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
 version=1.4.3
-revision=2
+revision=3
 archs="x86_64*"
 build_style=cmake
 hostmakedepends="ispc python3"

From f30850658ed7817ef1c1204cfc47d5ea7d2a2528 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:31:45 -0400
Subject: [PATCH 073/109] shotcut: revbump for ffmpeg6

---
 srcpkgs/shotcut/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/shotcut/template b/srcpkgs/shotcut/template
index 33141fbd862d7a..f46cb53b6bfb92 100644
--- a/srcpkgs/shotcut/template
+++ b/srcpkgs/shotcut/template
@@ -1,7 +1,7 @@
 # Template file for 'shotcut'
 pkgname=shotcut
 version=23.09.29
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSHOTCUT_VERSION=${version}"
 hostmakedepends="pkg-config qt6-tools-devel"

From 4445fbb279182c9fee198a16eddb128345a2e63c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:30 -0400
Subject: [PATCH 074/109] shiboken2: revbump for qt5-5.15.11

---
 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch | 1 +
 1 file changed, 1 insertion(+)
 create mode 120000 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
new file mode 120000
index 00000000000000..efcf3249bd8854
--- /dev/null
+++ b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1 @@
+../../python3-pyside2/patches/importlib-machinery-bypass.patch
\ No newline at end of file

From 7e437556a3c69bc7d150eafd2ecdc7691244566e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:53 -0400
Subject: [PATCH 075/109] python3-pyside2: revbump for qt5-5.15.11

---
 .../patches/importlib-machinery-bypass.patch      | 15 +++++++++++++++
 srcpkgs/python3-pyside2/template                  |  2 +-
 2 files changed, 16 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
new file mode 100644
index 00000000000000..64c429584776b5
--- /dev/null
+++ b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1,15 @@
+Using this prevents an error around line 220 below it.
+"AttributeError: module 'importlib' has no attribute 'machinery'"
+The old backup logic is in place and compiles without issues.
+--- a/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:09:34.688912402 -0400
++++ b/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:10:03.395529582 -0400
+@@ -170,9 +170,6 @@
+
+     # 'zipstring_sequence' comes from signature.cpp
+     zipbytes = base64.b64decode(''.join(zipstring_sequence))
+-    if sys.version_info[0] >= 3:
+-        vzip = zipfile.ZipFile(io.BytesIO(zipbytes))
+-        return sys.meta_path, EmbeddableZipImporter(vzip)
+
+     # Old version for Python 2.7, only.
+     import os
diff --git a/srcpkgs/python3-pyside2/template b/srcpkgs/python3-pyside2/template
index 249efa90988425..52626436ce75f2 100644
--- a/srcpkgs/python3-pyside2/template
+++ b/srcpkgs/python3-pyside2/template
@@ -1,7 +1,7 @@
 # Template file for 'python3-pyside2'
 pkgname=python3-pyside2
 version=5.15.10
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/pyside2"
 build_style=cmake

From fbae4ea3a6d74e328808890064a1a385a6bb57fa Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:35 -0400
Subject: [PATCH 076/109] konqueror: revbump for ffmpeg6

---
 srcpkgs/konqueror/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/konqueror/template b/srcpkgs/konqueror/template
index add972916753c6..50bbf4eec05e55 100644
--- a/srcpkgs/konqueror/template
+++ b/srcpkgs/konqueror/template
@@ -1,11 +1,11 @@
 # Template file for 'konqueror'
 pkgname=konqueror
 version=23.08.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DDESKTOPTOJSON_EXECUTABLE=/usr/bin/desktoptojson"
 hostmakedepends="extra-cmake-modules python3 qt5-host-tools qt5-qmake kdoctools
-kcoreaddons kconfig gettext"
+ kcoreaddons kconfig gettext"
 makedepends="qt5-devel qt5-webengine-devel qt5-declarative-devel
  qt5-webchannel-devel qt5-location-devel kcmutils-devel kdelibs4support-devel
  karchive-devel khtml-devel kdesu-devel kactivities5-devel"

From 8c263716a60bd3ae4d54bdc7b5de7125d125e187 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:58 -0400
Subject: [PATCH 077/109] qt5-speech: revbump for qt5-5.15.11

---
 srcpkgs/qt5-speech/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-speech/template b/srcpkgs/qt5-speech/template
index 1228bb60c41db4..27a7da1dbdb91b 100644
--- a/srcpkgs/qt5-speech/template
+++ b/srcpkgs/qt5-speech/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-speech'
 pkgname=qt5-speech
 version=5.15.11
-revision=1
+revision=2
 _commit=d32f4a479d38a11f547598004b975f4356424a16
 build_style=qmake
 configure_args="-- -flite -flite-alsa -speechd"

From 06394737e38754a451e354a3d7a72c82f1f7ce7d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Jun 2023 08:20:22 -0400
Subject: [PATCH 078/109] gtk4: revbump for ffmpeg6

---
 srcpkgs/gtk4/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gtk4/template b/srcpkgs/gtk4/template
index 452ad63a9f4e6c..8f534c54aab81a 100644
--- a/srcpkgs/gtk4/template
+++ b/srcpkgs/gtk4/template
@@ -1,7 +1,7 @@
 # Template file for 'gtk4'
 pkgname=gtk4
 version=4.14.1
-revision=1
+revision=2
 build_style=meson
 build_helper="gir"
 configure_args="-Dman-pages=true -Ddocumentation=true -Dbuild-tests=false

From dec1ec132390599146f4367a38964dac75fddfb2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:28:26 -0400
Subject: [PATCH 079/109] siril: revbump for ffmpeg6

---
 srcpkgs/siril/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/siril/template b/srcpkgs/siril/template
index 84332f79d060d2..62750dd247548f 100644
--- a/srcpkgs/siril/template
+++ b/srcpkgs/siril/template
@@ -1,7 +1,7 @@
 # Template file for 'siril'
 pkgname=siril
 version=0.9.12
-revision=10
+revision=11
 build_style=gnu-configure
 hostmakedepends="pkg-config intltool autoconf automake gettext-devel"
 makedepends="fftw-devel libconfig-devel libopencv-devel libffms2-devel

From 7c80da5a668c65a4441af9efed54005dc324e68f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:20:59 -0400
Subject: [PATCH 080/109] tracker-miners: revbump for ffmpeg6

---
 srcpkgs/tracker-miners/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tracker-miners/template b/srcpkgs/tracker-miners/template
index 0ae1cb0a986bdd..8be9ca6f8cc28b 100644
--- a/srcpkgs/tracker-miners/template
+++ b/srcpkgs/tracker-miners/template
@@ -1,7 +1,7 @@
 # Template file for 'tracker-miners'
 pkgname=tracker-miners
 version=3.6.2
-revision=1
+revision=2
 build_style=meson
 build_helper=qemu
 # missing libgrss for miner_rss

From b5e2a61e730a75653b472e4a2f43168c48c92674 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:21:21 -0400
Subject: [PATCH 081/109] mpd: revbump for ffmpeg6

---
 srcpkgs/mdp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mdp/template b/srcpkgs/mdp/template
index 3720bfae02f840..1c45395dca9b21 100644
--- a/srcpkgs/mdp/template
+++ b/srcpkgs/mdp/template
@@ -1,7 +1,7 @@
 # Template file for 'mdp'
 pkgname=mdp
 version=1.0.15
-revision=1
+revision=2
 build_style=gnu-makefile
 makedepends="ncurses-devel"
 short_desc="A command-line based markdown presentation tool"

From 748687cb06525b5187f4b3c4659066a6d088dc80 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:02 -0400
Subject: [PATCH 082/109] tg_owt: revbump for ffmpeg6

---
 srcpkgs/tg_owt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tg_owt/template b/srcpkgs/tg_owt/template
index 34e8fef0540569..1a46a8bedf3473 100644
--- a/srcpkgs/tg_owt/template
+++ b/srcpkgs/tg_owt/template
@@ -1,7 +1,7 @@
 # Template file for 'tg_owt'
 pkgname=tg_owt
 version=0.0.0.20231221
-revision=2
+revision=3
 _commit=afd9d5d31798d3eacf9ed6c30601e91d0f1e4d60
 _libyuv_commit=04821d1e7d60845525e8db55c7bcd41ef5be9406
 _abseil_commit=8c0b94e793a66495e0b1f34a5eb26bd7dc672db0

From b9324652fefb4d3b3b7aa194e423e9fb6ecc2321 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:44 -0400
Subject: [PATCH 083/109] telegram-desktop: revbump for ffmpeg6

---
 srcpkgs/telegram-desktop/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/telegram-desktop/template b/srcpkgs/telegram-desktop/template
index 6dc6a553cfcec8..cf85a731370062 100644
--- a/srcpkgs/telegram-desktop/template
+++ b/srcpkgs/telegram-desktop/template
@@ -1,7 +1,7 @@
 # Template file for 'telegram-desktop'
 pkgname=telegram-desktop
 version=4.14.15
-revision=3
+revision=4
 build_style=cmake
 build_helper="qemu gir"
 configure_args="-DTDESKTOP_API_ID=209235

From d8aa2312c5dee0d59a4cf7511d969235fb0bfe54 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:12:09 -0400
Subject: [PATCH 084/109] openmw: revbump for ffmpeg6

---
 srcpkgs/openmw/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openmw/template b/srcpkgs/openmw/template
index 0abf5ff7cdbecc..b57180f1a4446f 100644
--- a/srcpkgs/openmw/template
+++ b/srcpkgs/openmw/template
@@ -1,7 +1,7 @@
 # Template file for 'openmw'
 pkgname=openmw
 version=0.48.0
-revision=2
+revision=3
 build_style=cmake
 _recast_commit=e75adf86f91eb3082220085e42dda62679f9a3ea
 _bullet_tag=3.17

From 85454f1e8d1d0bcb30c1ba593d1a9c326f26b07a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:14:53 -0400
Subject: [PATCH 085/109] lms: revbump for ffmpeg6

---
 srcpkgs/lms/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/lms/template b/srcpkgs/lms/template
index e358f75902a986..3b21c458de5199 100644
--- a/srcpkgs/lms/template
+++ b/srcpkgs/lms/template
@@ -1,7 +1,7 @@
 # Template file for 'lms'
 pkgname=lms
 version=3.42.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="wt-devel ffmpeg-devel boost-devel libconfig++-devel taglib-devel pam-devel libgraphicsmagick-devel gtest-devel libarchive-devel"

From 2e3404e132d1423323cf206b5bc714aa3b721d2c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:18:18 -0400
Subject: [PATCH 086/109] freecad: DELETE

---
 srcpkgs/freecad/patches/001-include.patch     | 112 ------------------
 .../154-revert-gui-tmp-redirect-stderr.patch  |  68 -----------
 ...d63c8c9b1280978be841d04e68a0a55cceb9.patch |  30 -----
 srcpkgs/freecad/template                      |  12 +-
 4 files changed, 7 insertions(+), 215 deletions(-)
 delete mode 100644 srcpkgs/freecad/patches/001-include.patch
 delete mode 100644 srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
 delete mode 100644 srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch

diff --git a/srcpkgs/freecad/patches/001-include.patch b/srcpkgs/freecad/patches/001-include.patch
deleted file mode 100644
index 28b5af54999b96..00000000000000
--- a/srcpkgs/freecad/patches/001-include.patch
+++ /dev/null
@@ -1,112 +0,0 @@
-From 9a41845a417189776741297c50a3827ce292bc4f Mon Sep 17 00:00:00 2001
-From: Uwe <donovaly@users.noreply.github.com>
-Date: Sun, 3 Jul 2022 22:51:16 +0200
-Subject: [PATCH] [Part] OCCError.h: remove unneeded includes
-
-- also sort includes
----
- src/Mod/Part/App/OCCError.h             | 36 +++----------------------
- src/Mod/Part/App/OffsetCurvePyImp.cpp   | 12 ++++-----
- src/Mod/Part/App/OffsetSurfacePyImp.cpp | 10 +++----
- 3 files changed, 12 insertions(+), 46 deletions(-)
-
---- a/src/Mod/Part/App/OCCError.h
-+++ b/src/Mod/Part/App/OCCError.h
-@@ -23,36 +23,8 @@
- #ifndef _OCCError_h_
- #define _OCCError_h_
- 
--# include <Standard_Version.hxx>
- # include <Standard_Failure.hxx>
--# include <Standard_AbortiveTransaction.hxx>
--# include <Standard_ConstructionError.hxx>
--# if OCC_VERSION_HEX >= 0x060500
--# include <Standard_DefineException.hxx>
--# endif
--# include <Standard_DimensionError.hxx>
--# include <Standard_DimensionMismatch.hxx>
--# include <Standard_DivideByZero.hxx>
--# include <Standard_DomainError.hxx>
--# include <Standard_ImmutableObject.hxx>
--# include <Standard_LicenseError.hxx>
--# include <Standard_LicenseNotFound.hxx>
--# include <Standard_MultiplyDefined.hxx>
--# include <Standard_NegativeValue.hxx>
--# include <Standard_NoMoreObject.hxx>
--# include <Standard_NoSuchObject.hxx>
--# include <Standard_NotImplemented.hxx>
--# include <Standard_NullObject.hxx>
--# include <Standard_NullValue.hxx>
--# include <Standard_NumericError.hxx>
--# include <Standard_OutOfMemory.hxx>
--# include <Standard_OutOfRange.hxx>
--# include <Standard_Overflow.hxx>
--# include <Standard_ProgramError.hxx>
--# include <Standard_RangeError.hxx>
--# include <Standard_TooManyUsers.hxx>
--# include <Standard_TypeMismatch.hxx>
--# include <Standard_Underflow.hxx>
-+# include <Standard_Version.hxx>
- 
- #include <Mod/Part/PartGlobal.h>
- #include <Base/Console.h>
-@@ -88,4 +60,3 @@ PartExport extern PyObject* PartExceptio
- 
- #define PY_CATCH_OCC _PY_CATCH_OCC(return(NULL))
- #endif  // _OCCError_h_
--
---- a/src/Mod/Part/App/OffsetCurvePyImp.cpp
-+++ b/src/Mod/Part/App/OffsetCurvePyImp.cpp
-@@ -20,20 +20,20 @@
-  *                                                                         *
-  ***************************************************************************/
- 
--
- #include "PreCompiled.h"
- #ifndef _PreComp_
- # include <Geom_OffsetCurve.hxx>
- #endif
- 
--#include "OCCError.h"
--#include "Geometry.h"
-+#include <Base/GeometryPyCXX.h>
-+#include <Base/Vector3D.h>
-+#include <Base/VectorPy.h>
-+
- #include "OffsetCurvePy.h"
- #include "OffsetCurvePy.cpp"
-+#include "Geometry.h"
-+#include "OCCError.h"
- 
--#include <Base/GeometryPyCXX.h>
--#include <Base/VectorPy.h>
--#include <Base/Vector3D.h>
- 
- using namespace Part;
- 
---- a/src/Mod/Part/App/OffsetSurfacePyImp.cpp
-+++ b/src/Mod/Part/App/OffsetSurfacePyImp.cpp
-@@ -20,20 +20,16 @@
-  *                                                                         *
-  ***************************************************************************/
- 
--
- #include "PreCompiled.h"
- #ifndef _PreComp_
- # include <Geom_OffsetSurface.hxx>
- # include <memory>
- #endif
- 
--#include <Base/VectorPy.h>
--#include <Base/Vector3D.h>
--
- #include "OCCError.h"
--#include "Geometry.h"
--#include <Mod/Part/App/OffsetSurfacePy.h>
--#include <Mod/Part/App/OffsetSurfacePy.cpp>
-+#include "OffsetSurfacePy.h"
-+#include "OffsetSurfacePy.cpp"
-+
- 
- using namespace Part;
- 
diff --git a/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch b/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
deleted file mode 100644
index d6a9adabdec830..00000000000000
--- a/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
+++ /dev/null
@@ -1,68 +0,0 @@
-see https://github.com/FreeCAD/FreeCAD/commit/cfe94b00d3434f3e2c8b5114d2909f628c330fa8#commitcomment-71413407
-
-upstream: yes
-
-From 7b377a216b9185960e4cee980a6504dc1a755f50 Mon Sep 17 00:00:00 2001
-From: wmayer <wmayer@users.sourceforge.net>
-Date: Wed, 29 Jun 2022 15:19:18 +0200
-Subject: [PATCH] Gui: remove workaround for spnav 0.23 due to build failure
- with musl libc
-
----
- src/Gui/3Dconnexion/GuiNativeEventLinux.cpp | 27 ---------------------
- 1 file changed, 27 deletions(-)
-
---- a/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp
-+++ b/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp
-@@ -21,42 +21,17 @@
-  ***************************************************************************/
- 
- #include <FCConfig.h>
--#include <cstdio>
- 
- #include "GuiNativeEventLinux.h"
- 
- #include "GuiApplicationNativeEventAware.h"
- #include <Base/Console.h>
--#include <Base/FileInfo.h>
- #include <QMainWindow>
- 
- #include <QSocketNotifier>
- 
- #include <spnav.h>
- 
--namespace {
--class RedirectStdErr
--{
--public:
--    RedirectStdErr()
--        : fi(Base::FileInfo::getTempFileName())
--        , file(stderr)
--    {
--        stderr = fopen(fi.filePath().c_str(), "w");
--    }
--    ~RedirectStdErr()
--    {
--        fclose(stderr);
--        fi.deleteFile();
--        stderr = file;
--    }
--
--private:
--    Base::FileInfo fi;
--    FILE* file;
--};
--}
--
- Gui::GuiNativeEvent::GuiNativeEvent(Gui::GUIApplicationNativeEventAware *app)
- : GuiAbstractNativeEvent(app)
- {
-@@ -72,8 +47,6 @@ Gui::GuiNativeEvent::~GuiNativeEvent()
- 
- void Gui::GuiNativeEvent::initSpaceball(QMainWindow *window)
- {
--    // tmp. redirect stderr to a file to suppress an error message from spnav_open()
--    RedirectStdErr err;
-     Q_UNUSED(window)
-     if (spnav_open() == -1) {
-         Base::Console().Log("Couldn't connect to spacenav daemon. Please ignore if you don't have a spacemouse.\n");
diff --git a/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch b/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch
deleted file mode 100644
index d4acf370ca0a42..00000000000000
--- a/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-From fe02d63c8c9b1280978be841d04e68a0a55cceb9 Mon Sep 17 00:00:00 2001
-From: Roy-043 <70520633+Roy-043@users.noreply.github.com>
-Date: Thu, 29 Dec 2022 23:20:38 +0100
-Subject: [PATCH] Draft: update inspect.getargspec to inspect.getfullargspec
- (#8101)
-
----
- src/Mod/Draft/draftguitools/gui_snapper.py | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
---- a/src/Mod/Draft/draftguitools/gui_snapper.py
-+++ b/src/Mod/Draft/draftguitools/gui_snapper.py
-@@ -1426,7 +1426,7 @@ class Snapper:
-             Gui.Snapper.off()
-             self.ui.offUi()
-             if callback:
--                if len(inspect.getargspec(callback).args) > 1:
-+                if len(inspect.getfullargspec(callback).args) > 1:
-                     obj = None
-                     if self.snapInfo and ("Object" in self.snapInfo) and self.snapInfo["Object"]:
-                         obj = App.ActiveDocument.getObject(self.snapInfo["Object"])
-@@ -1445,7 +1445,7 @@ class Snapper:
-             Gui.Snapper.off()
-             self.ui.offUi()
-             if callback:
--                if len(inspect.getargspec(callback).args) > 1:
-+                if len(inspect.getfullargspec(callback).args) > 1:
-                     callback(None, None)
-                 else:
-                     callback(None)
diff --git a/srcpkgs/freecad/template b/srcpkgs/freecad/template
index c135701e38b9ad..7d5165f760bab9 100644
--- a/srcpkgs/freecad/template
+++ b/srcpkgs/freecad/template
@@ -1,7 +1,7 @@
 # Template file for 'freecad'
 pkgname=freecad
-version=0.20.2
-revision=7
+version=0.21.1
+revision=2
 build_wrksrc="FreeCAD-${version}"
 build_style=cmake
 pycompile_dirs="usr/lib/${pkgname}/Mod"
@@ -24,8 +24,10 @@ makedepends="python3-devel boost-devel libxerces-c-devel zlib-devel occt-devel
  coin3-devel libshiboken2-devel libspnav-devel pyside2-tools
  liblz4-devel libpyside2-python3-devel python3-matplotlib netcdf-devel
  jsoncpp-devel qt5-devel qt5-svg-devel qt5-tools-devel qt5-webkit-devel
- qt5-xmlpatterns-devel coin3-doc glew-devel python3-pivy"
-depends="python3-matplotlib python3-pyside2-webengine python3-pivy"
+ qt5-xmlpatterns-devel coin3-doc glew-devel python3-pivy qt5-webengine-devel
+ qt5-declarative-devel qt5-webchannel-devel qt5-location-devel"
+depends="python3-matplotlib python3-pyside2-webengine python3-pivy
+ python3-GitPython python3-Markdown"
 short_desc="General purpose 3D CAD modeler"
 maintainer="yopito <pierre.bourgin@free.fr>"
 license="LGPL-2.0-or-later"
@@ -35,7 +37,7 @@ distfiles="
  https://github.com/FreeCAD/FreeCAD/archive/${version}.tar.gz
  ${SOURCEFORGE_SITE}/cxx/pycxx-${_pycxxver}.tar.gz
 "
-checksum="46922f3a477e742e1a89cd5346692d63aebb2b67af887b3e463e094a4ae055da
+checksum="e9b1fd0323f101268c7f3be52db42e4a29222f2e306ae6c4a6fc309cb418d35a
  4b91e1e1141c23fbd5039df635c4bb6e75632168548f56b83ce177193c0c98c6"
 python_version=3
 patch_args="-Np1 -d ${build_wrksrc}"

From 34e3fb717801ca730cb67d77bd5a3cef9610b851 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:47:18 -0400
Subject: [PATCH 087/109] libopenshot: revbump for ffmpeg6

---
 srcpkgs/libopenshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenshot/template b/srcpkgs/libopenshot/template
index 8e57c5f592169c..7a8f4520e78925 100644
--- a/srcpkgs/libopenshot/template
+++ b/srcpkgs/libopenshot/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenshot'
 pkgname=libopenshot
 version=0.3.0
-revision=3
+revision=4
 build_style=cmake
 # Builds fail with Ruby-2.4.1
 configure_args="-DENABLE_RUBY=OFF -DUSE_SYSTEM_JSONCPP=ON"

From f5d0bb9fde6a39025f08d8d27552c31c5544020e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:10:30 -0500
Subject: [PATCH 088/109] openimageio: revbump for ffmpeg6

---
 srcpkgs/openimageio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimageio/template b/srcpkgs/openimageio/template
index 27d2131bc0a61a..61f44b43f9083e 100644
--- a/srcpkgs/openimageio/template
+++ b/srcpkgs/openimageio/template
@@ -1,7 +1,7 @@
 # Template file for 'openimageio'
 pkgname=openimageio
 version=2.4.9.0
-revision=8
+revision=9
 build_style=cmake
 build_helper=qemu
 configure_args="-DUSE_QT=0 -DUSE_PYTHON=0 -DOIIO_BUILD_TESTS=0

From 020825f686eaa1956b91b15056b633d937ae2cf1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:11:57 -0500
Subject: [PATCH 089/109] synfigstudio: revbump for ffmpeg6

---
 srcpkgs/synfigstudio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/synfigstudio/template b/srcpkgs/synfigstudio/template
index 09e442da9a6805..2bc017cedca6b8 100644
--- a/srcpkgs/synfigstudio/template
+++ b/srcpkgs/synfigstudio/template
@@ -2,7 +2,7 @@
 # Should be kept in sync with 'synfig' and 'ETL'
 pkgname=synfigstudio
 version=1.4.4
-revision=4
+revision=5
 build_style=gnu-configure
 configure_args="--disable-update-mimedb"
 hostmakedepends="pkg-config intltool gettext synfig"

From ec09932776341c4dd7e6f7e4715c7e3b2d40b530 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:10 -0500
Subject: [PATCH 090/109] mixxx: revbump for ffmpeg6

---
 srcpkgs/mixxx/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mixxx/template b/srcpkgs/mixxx/template
index 6a79b328c1abf0..9a5141856860b9 100644
--- a/srcpkgs/mixxx/template
+++ b/srcpkgs/mixxx/template
@@ -1,7 +1,7 @@
 # Template file for 'mixxx'
 pkgname=mixxx
 version=2.3.3
-revision=7
+revision=8
 build_style=cmake
 configure_args="-DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="extra-cmake-modules pkg-config protobuf qt5-host-tools qt5-qmake"

From 7c5f128410fe8b6e0ff502a4f87f4a6f497e8491 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:28 -0500
Subject: [PATCH 091/109] musikcube: revbump for ffmpeg6

---
 srcpkgs/musikcube/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/musikcube/template b/srcpkgs/musikcube/template
index 8c4a51840859ec..fb60dd2049089a 100644
--- a/srcpkgs/musikcube/template
+++ b/srcpkgs/musikcube/template
@@ -1,7 +1,7 @@
 # Template file for 'musikcube'
 pkgname=musikcube
 version=3.0.0
-revision=3
+revision=4
 build_style=cmake
 make_cmd=make
 configure_args="-DNO_NCURSESW=1"

From 5a1ce328143597715874ad407e72f8a531a52185 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:45 -0500
Subject: [PATCH 092/109] electron24: revbump for ffmpeg6

---
 srcpkgs/electron24/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron24/template b/srcpkgs/electron24/template
index 7b4e28812f483e..1ca93fde97a854 100644
--- a/srcpkgs/electron24/template
+++ b/srcpkgs/electron24/template
@@ -1,7 +1,7 @@
 # Template file for 'electron24'
 pkgname=electron24
 version=24.3.0
-revision=2
+revision=3
 _nodever=18.14.0
 _chromiumver=112.0.5615.165
 archs="x86_64* aarch64*"

From d0222dc5a02af00585773ea5d2958abf0cf93f01 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:00 -0500
Subject: [PATCH 093/109] electron19: revbump for ffmpeg6

---
 srcpkgs/electron19/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron19/template b/srcpkgs/electron19/template
index 0ef959125cb085..5371c0b354604f 100644
--- a/srcpkgs/electron19/template
+++ b/srcpkgs/electron19/template
@@ -1,7 +1,7 @@
 # Template file for 'electron19'
 pkgname=electron19
 version=19.0.8
-revision=4
+revision=5
 _nodever=16.14.2
 _chromiumver=102.0.5005.125
 archs="x86_64* aarch64* ppc64le*"

From 0416876086010ddc1cb617d1d79f66718279d3f1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:13 -0500
Subject: [PATCH 094/109] wf-recorder: revbump for ffmpeg6

---
 srcpkgs/wf-recorder/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/wf-recorder/template b/srcpkgs/wf-recorder/template
index 08f986b0310067..63c45cf4b814d7 100644
--- a/srcpkgs/wf-recorder/template
+++ b/srcpkgs/wf-recorder/template
@@ -1,7 +1,7 @@
 # Template file for 'wf-recorder'
 pkgname=wf-recorder
 version=0.4.1
-revision=2
+revision=3
 build_style=meson
 hostmakedepends="pkg-config scdoc wayland-devel"
 makedepends="wayland-protocols wayland-devel ffmpeg-devel libgbm-devel x264-devel

From 9390c0d2d99ceff7d31e9032bc1a994a4986ea7b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:26 -0500
Subject: [PATCH 095/109] obs: revbump for ffmpeg6

---
 srcpkgs/obs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/obs/template b/srcpkgs/obs/template
index 8aa49832357cf1..357c45c9ef6a09 100644
--- a/srcpkgs/obs/template
+++ b/srcpkgs/obs/template
@@ -1,7 +1,7 @@
 # Template file for 'obs'
 pkgname=obs
 version=30.1.0
-revision=1
+revision=2
 archs="i686* x86_64* ppc64le* aarch64* riscv64*"
 build_style=cmake
 configure_args="-DOBS_VERSION_OVERRIDE=${version} -DENABLE_JACK=ON

From 07335f8143570ad53dc7682d1d647f3cbe6a0a16 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:36 -0500
Subject: [PATCH 096/109] mlt7: revbump for ffmpeg6

---
 srcpkgs/mlt7/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mlt7/template b/srcpkgs/mlt7/template
index 98f302ad3a5167..7eb8c00fa1580c 100644
--- a/srcpkgs/mlt7/template
+++ b/srcpkgs/mlt7/template
@@ -1,7 +1,7 @@
 # Template file for 'mlt7'
 pkgname=mlt7
 version=7.20.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DSWIG_PYTHON=ON -DMOD_QT6=ON"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which

From c151cbfeb16037ecb1d48ce8a33dd87be37c6134 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:48 -0500
Subject: [PATCH 097/109] qt6-multimedia: revbump for ffmpeg6

---
 srcpkgs/qt6-multimedia/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-multimedia/template b/srcpkgs/qt6-multimedia/template
index 67a577e1300fea..1da626ecf515a8 100644
--- a/srcpkgs/qt6-multimedia/template
+++ b/srcpkgs/qt6-multimedia/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-multimedia'
 pkgname=qt6-multimedia
 version=6.6.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DQT_FEATURE_gstreamer=ON"
 hostmakedepends="perl qt6-declarative-host-tools pkg-config qt6-shadertools"

From a6c77bc2517fb01d83d470a9bfc414faaa8a11a0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:00:15 -0500
Subject: [PATCH 098/109] baresip: revbump for ffmpeg6

---
 srcpkgs/baresip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/baresip/template b/srcpkgs/baresip/template
index b16b67beab8d2b..fe21ebf40c03c1 100644
--- a/srcpkgs/baresip/template
+++ b/srcpkgs/baresip/template
@@ -1,7 +1,7 @@
 # Template file for 'baresip'
 pkgname=baresip
 version=3.6.0
-revision=3
+revision=4
 build_style=cmake
 hostmakedepends="pkg-config glib-devel"
 makedepends="libgsm-devel libpng-devel openssl-devel libsndfile-devel

From 3369de558810ddc6f327f1baa057e9b3b75350b6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:30 -0500
Subject: [PATCH 099/109] QMPlay2: revbump for ffmpeg6

---
 srcpkgs/QMPlay2/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/QMPlay2/template b/srcpkgs/QMPlay2/template
index efa9726614093c..10e5ac4ceebf80 100644
--- a/srcpkgs/QMPlay2/template
+++ b/srcpkgs/QMPlay2/template
@@ -1,7 +1,7 @@
 # Template file for 'QMPlay2'
 pkgname=QMPlay2
 version=24.03.16
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools"
 makedepends="alsa-lib-devel ffmpeg-devel libass-devel libcdio-devel libgme-devel

From 129327e25a7ed94553fec0821b880a15f6ca7df3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:34 -0500
Subject: [PATCH 100/109] alsa-plugins: revbump for ffmpeg6

---
 srcpkgs/alsa-plugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/alsa-plugins/template b/srcpkgs/alsa-plugins/template
index a5708a7d82a8f0..7bfdad046c4830 100644
--- a/srcpkgs/alsa-plugins/template
+++ b/srcpkgs/alsa-plugins/template
@@ -1,7 +1,7 @@
 # Template file for 'alsa-plugins'
 pkgname=alsa-plugins
 version=1.2.7.1
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--disable-maemo-plugin"
 hostmakedepends="pkg-config"

From 2ff7618729fec45e54c9ee15e07009bd4e5ecbc7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:43 -0500
Subject: [PATCH 101/109] minidlna: revbump for ffmpeg6

---
 srcpkgs/minidlna/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/minidlna/template b/srcpkgs/minidlna/template
index 5fa929f3a0c124..742991ecd04afc 100644
--- a/srcpkgs/minidlna/template
+++ b/srcpkgs/minidlna/template
@@ -1,7 +1,7 @@
 # Template file for 'minidlna'
 pkgname=minidlna
 version=1.3.3
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="
  --sbindir=/usr/bin

From 8961acb5b99223f12b232195851aa02ec93e5603 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 17:57:47 -0500
Subject: [PATCH 102/109] mpv: revbump for ffmpeg6

---
 srcpkgs/mpv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpv/template b/srcpkgs/mpv/template
index 3d4349e27d8f62..bc40d6fcaa40d6 100644
--- a/srcpkgs/mpv/template
+++ b/srcpkgs/mpv/template
@@ -1,7 +1,7 @@
 # Template file for 'mpv'
 pkgname=mpv
 version=0.37.0
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcdda=enabled -Ddvbin=enabled -Ddvdnav=enabled
  -Dlibmpv=true -Dcplugins=enabled

From 6215442e4905d72b1170b21887d026ac2cf982eb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 17:59:29 -0500
Subject: [PATCH 103/109] qimgv: revbump for ffmpeg6

---
 srcpkgs/qimgv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qimgv/template b/srcpkgs/qimgv/template
index dd341dfe1bfce8..8a7e1c081ef12f 100644
--- a/srcpkgs/qimgv/template
+++ b/srcpkgs/qimgv/template
@@ -1,7 +1,7 @@
 # Template file for 'qimgv'
 pkgname=qimgv
 version=1.0.2
-revision=3
+revision=4
 build_style=cmake
 configure_args="$(vopt_if video -DVIDEO_SUPPORT=ON -DVIDEO_SUPPORT=OFF)
  $(vopt_if scale -DOPENCV_SUPPORT=ON -DOPENCV_SUPPORT=OFF)

From 80d4d1a6ef8298a258a53357259d95becfd35284 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 18:00:36 -0500
Subject: [PATCH 104/109] kfilemetadata5: revbump for ffmpeg6

---
 srcpkgs/kfilemetadata5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kfilemetadata5/template b/srcpkgs/kfilemetadata5/template
index a0c4d809395323..b584f85ff2058b 100644
--- a/srcpkgs/kfilemetadata5/template
+++ b/srcpkgs/kfilemetadata5/template
@@ -1,7 +1,7 @@
 # Template file for 'kfilemetadata5'
 pkgname=kfilemetadata5
 version=5.115.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="kcoreaddons extra-cmake-modules pkg-config qt5-host-tools qt5-qmake
  gettext kcoreaddons python3"

From a21b90ab090a2e4295cf066f1bd9e71c10e03888 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 8 Dec 2023 11:46:01 -0500
Subject: [PATCH 105/109] vba-m: revbump for ffmpeg6

---
 srcpkgs/vba-m/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vba-m/template b/srcpkgs/vba-m/template
index 3d135efa1d0b69..3c5a20db0fa984 100644
--- a/srcpkgs/vba-m/template
+++ b/srcpkgs/vba-m/template
@@ -2,7 +2,7 @@
 pkgname=vba-m
 reverts=1292_2
 version=2.1.9
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_GTK=TRUE -DENABLE_FFMPEG=TRUE -DENABLE_LINK=TRUE -DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="gettext pkg-config unzip zip yasm wxWidgets-gtk3-devel"

From 84edd5dee5c7b9830a43ff3105116508863029f7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 8 Dec 2023 11:46:19 -0500
Subject: [PATCH 106/109] dolphin-emu: revbump for ffmpeg6

---
 srcpkgs/dolphin-emu/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/dolphin-emu/template b/srcpkgs/dolphin-emu/template
index 862d3ae964eec4..a7ae0efb58fb75 100644
--- a/srcpkgs/dolphin-emu/template
+++ b/srcpkgs/dolphin-emu/template
@@ -1,7 +1,7 @@
 # Template file for 'dolphin-emu'
 pkgname=dolphin-emu
 version=5.0.19368
-revision=3
+revision=4
 _dolphin_commit=dadbeb4bae7e7fa23af2b46e0add4143094dc107
 _mgba_commit=44e074a15e9651481f7f652ac006a7c9d58cbeb9
 _googletest_commit=be03d00f5f0cc3a997d1a368bee8a1fe93651f48

From 64aab8d7fdbad4b76d08356e30ce8f4b271ff8ee Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 19 Dec 2023 15:38:51 -0500
Subject: [PATCH 107/109] qtox: revbump for ffmpeg4

---
 srcpkgs/qtox/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtox/template b/srcpkgs/qtox/template
index bb70e7f51240a4..755e4462bc0137 100644
--- a/srcpkgs/qtox/template
+++ b/srcpkgs/qtox/template
@@ -1,13 +1,13 @@
 # Template file for 'qtox'
 pkgname=qtox
 version=1.17.6
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DUPDATE_CHECK=OFF
  -DGIT_DESCRIBE=${version}
  $(vopt_if snorenotify -DDESKTOP_NOTIFICATIONS=ON)"
 hostmakedepends="pkg-config qt5-host-tools qt5-devel"
-makedepends="ffmpeg-devel libexif-devel libopenal-devel libsodium-devel
+makedepends="ffmpeg4-devel libexif-devel libopenal-devel libsodium-devel
  libvpx-devel opus-devel qrencode-devel qt5-svg-devel sonnet-devel
  sqlcipher-devel toxcore-devel
  $(vopt_if snorenotify snorenotify-devel)"

From 0675184469c9ba0ff36e3bdc28a3ea538e3f9e55 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 11 Jan 2024 11:52:00 -0500
Subject: [PATCH 108/109] arcan: revbump for ffmpeg6

---
 srcpkgs/arcan/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/arcan/template b/srcpkgs/arcan/template
index ff9091f90ebb10..030091a6cc9d0c 100644
--- a/srcpkgs/arcan/template
+++ b/srcpkgs/arcan/template
@@ -2,7 +2,7 @@
 # !! keep synced with: acfgfs aclip aloadimage
 pkgname=arcan
 version=0.6.2.1
-revision=2
+revision=3
 create_wrksrc=yes
 build_wrksrc=arcan/src
 build_style=cmake

From cb5978ece39edccce396affba87e84710b7f1a80 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 11 Jan 2024 11:52:10 -0500
Subject: [PATCH 109/109] notcurses: revbump for ffmpeg6

---
 srcpkgs/notcurses/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/notcurses/template b/srcpkgs/notcurses/template
index 48a7463cb68eb9..515f316ab4576c 100644
--- a/srcpkgs/notcurses/template
+++ b/srcpkgs/notcurses/template
@@ -1,7 +1,7 @@
 # Template file for 'notcurses'
 pkgname=notcurses
 version=3.0.9
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DUSE_STATIC=ON -DUSE_QRCODEGEN=On $(vopt_bool man USE_PANDOC)"
 hostmakedepends="pkg-config $(vopt_if man pandoc)"

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (93 preceding siblings ...)
  2024-03-21 21:29 ` zlice
@ 2024-03-21 21:51 ` zlice
  2024-03-28 17:21 ` zlice
                   ` (2 subsequent siblings)
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2024-03-21 21:51 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 4972 bytes --]

There is an updated pull request by zlice against master on the void-packages repository

https://github.com/zlice/void-packages ffmpeg6-split
https://github.com/void-linux/void-packages/pull/43761

ffmpeg6 split
[ci skip]


#### Testing the changes

- I tested the changes in this PR: **YES**

main testing has been vaapi in Firefox Nightly and enc/dec in Shotcut on Intel A770

#### New package

- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**

#### Local build testing

- I built this PR locally for my native architecture, **x86_64**

#### Discussion

Continuation of https://github.com/void-linux/void-packages/pull/36315

`libavresample` is deprecated, but marked as a dependency when trying to build other packages and install `ffmpeg`(6). I think the right way to handle this is make a meta package and the add to removals?


##### Commit naming / misc

~~Commits are 'dirty' right now, running with [gstreamer 1.22.1 updates](https://github.com/void-linux/void-packages/pull/42861) and [Intel OpenCL](https://github.com/void-linux/void-packages/pull/43084). This will also make [intel packages pr](https://github.com/void-linux/void-packages/pull/41132) obsolete.~~ (see Requirements below)

Maintainer for previous ffmpeg(4) was orphaned, I can put my name in there if that matters, though I don't exactly see myself keeping up on ffmpeg.

~~This updates QT5 which looks like it is usually hosted by Johnny. Not sure if there's any reason to stay there or these sources are fine.~~ Using qt5.15.11 now, revbumps and some patches.

##### STILL FFMPEG4

These are a mix of emulators, games and/or older packages.

- ~~attract~~ (2.7 builds)
- ~~audacity (https://github.com/audacity/audacity/issues/2305 and https://sourceforge.net/p/portmedia/wiki/portsmf/ is 'beta')~~ (updated to 3.x, compiles with ffmpeg6)
- ~~ccextractor~~ (master patches)
- ~~vice (3.8 compiles, needs makedepends libcurl-devel)~~ ty yosh
- kodi
- mlt (only dep left is flowblade - flowblade 2.12.0.2 with mlt7-python3 can 'render' videos with cpu and gpu - https://github.com/void-linux/void-packages/pull/47195)
- ~~synfig (mlt)~~ (work with mlt7, bump synfigstudio)
- tvheadend (download page recommends using 4.3 which compiles fine, 4.4 eta is Q1 2024)
- ~~ssr~~ (patches)
- ~~spek-alternative~~ (replace with spek-x)
- ~~ppsspp~~ ~~(1.17.1 is out, but there's 5+ distfiles that are all git commits)~~ (minor patch)
- olive (has been in alpha since 2020, seems they do nightly builds and appimages)
- moc
- mediastreamer (linphone links are dead, changed to github belladonne. their stuff never worked for me but there are updates if someone wants to give it a try)
- ~~libextractor (1.13 compiles, remove exiv2 patch)~~ (as yosh pointed out, 1.13 just removes ffmpeg bits)
- idjc (0.9.8 compiles, remove python3.10 patch, needs makedepends libebur128-devel and libshout-idjc 2.4.6 with '-r1' for distfile)
- hedgewars
- ~~ffmpegthumbnailer~~ (patches for moviedecoder.xxx files)
- ~~ffmpegthumbs~~ (latest compiles)
- deadbeef (1.9.6 may work but requires libdispatch from apple)
- ~~omxplayer~~ (package removed, deprecated in favor of vlc)
- qtav (fork has ffmpeg 5 patch - https://github.com/cmguo/QtAV)
- `vlc` (vlc4 will support ffmpeg5, there's a patch to build 3.x with ffmpeg5 but it will lack vaapi)
- `osg` (OpenSceneGraph plus `xine-lib`)


##### HAVE NOT BUILT YET

- ~~omxplayer (rpi only? ffmpeg4)~~ (removed)
- kodi (big, but ffmpeg4)


##### UPDATED (for ffmpeg6)

- ~~blender: update to 3.5.1~~ ~~will be revbump with~~ https://github.com/void-linux/void-packages/pull/43992
- unpaper: update to 7.0.0.
- guvcview: update to 2.0.8.
- ~~qt5: update to 5.15.8~~ updated by another PR to 5.15.11
- ~~qt5-webengine: update to 5.18.15~~ updated by another PR to 5.15.16 (some patching for ffmpeg build)
- ~~shiboken2: revbump for qt5.15.8 (patch)~~ updated by another PR to 5.15.10
- ~~python3-pyside2: update to 5.15.8 (patch)~~ updated by another PR to 5.15.10
- New package: spex-x replaces spek-alternative for ffmpeg-6.0


##### Requirements

- ~~[gstreamer 1.22.2](https://github.com/void-linux/void-packages/pull/42861)~~ - a few packages use ffmpeg-devel and require a revbump

- ~~[Intel Packages](https://github.com/void-linux/void-packages/pull/41132) [Intel Packages v2](https://github.com/void-linux/void-packages/pull/47330) - ffmpeg4 uses different libraries than 6 (libmfx / Intel-MediaSDK vs only oneVPL that Intel is moving to), both are included here~~. Using replacement oneVPL from OBS update.

- ~~[shotcut 23.05.14](https://github.com/void-linux/void-packages/pull/44260)~~

- https://github.com/void-linux/void-packages/pull/44781 will remove from this PR

A patch file from https://github.com/void-linux/void-packages/pull/43761.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ffmpeg6-split-43761.patch --]
[-- Type: text/x-diff, Size: 240981 bytes --]

From f0573d72abd9dda4f4059b7e2346e8a0e49c2f95 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:16:56 -0400
Subject: [PATCH 001/109] ffmpeg: update to 6.0.1.

---
 common/shlibs                                 | 26 ++++---
 srcpkgs/ffmpeg/files/altivec.patch            | 60 ---------------
 .../patches/armv5tel-floating-point.patch     | 18 -----
 srcpkgs/ffmpeg/patches/binutils-2.41.patch    | 73 -------------------
 ...h-libavcodec-libsvtav1-ten_bit_format.diff | 40 ----------
 .../workaround-mesa-readeon-vaapi-bug.patch   | 28 -------
 srcpkgs/ffmpeg/template                       | 40 +++++-----
 7 files changed, 37 insertions(+), 248 deletions(-)
 delete mode 100644 srcpkgs/ffmpeg/files/altivec.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/binutils-2.41.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 delete mode 100644 srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch

diff --git a/common/shlibs b/common/shlibs
index 9ca4502a01c4a7..e29b7e87b8915c 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -389,15 +389,23 @@ libid3tag.so.0 libid3tag-0.15.1b_1
 libgif.so.7 giflib-5.1.0_1
 libImlib2.so.1 imlib2-1.4.2_1
 libmp3lame.so.0 lame-3.98.2_1
-libavdevice.so.58 libavdevice-4.0_1
-libavformat.so.58 libavformat-4.0_1
-libswscale.so.5 libswscale-4.0_1
-libswresample.so.3 libswresample-4.0_1
-libavresample.so.4 libavresample-4.0_1
-libpostproc.so.55 libpostproc-4.0_1
-libavcodec.so.58 libavcodec-4.0_1
-libavutil.so.56 libavutil-4.0_1
-libavfilter.so.7 libavfilter-4.0_1
+libavdevice.so.60 libavdevice-6.0_1
+libavformat.so.60 libavformat-6.0_1
+libswscale.so.7 libswscale-6.0_1
+libswresample.so.4 libswresample-6.0_1
+libpostproc.so.57 libpostproc-6.0_1
+libavcodec.so.60 libavcodec-6.0_1
+libavutil.so.58 libavutil-6.0_1
+libavfilter.so.9 libavfilter-6.0_1
+libavdevice.so.58 libavdevice4-4.0_1
+libavformat.so.58 libavformat4-4.0_1
+libswscale.so.5 libswscale4-4.0_1
+libswresample.so.3 libswresample4-4.0_1
+libavresample.so.4 libavresample4-4.0_1
+libpostproc.so.55 libpostproc4-4.0_1
+libavcodec.so.58 libavcodec4-4.0_1
+libavutil.so.56 libavutil4-4.0_1
+libavfilter.so.7 libavfilter4-4.0_1
 libSDL-1.2.so.0 SDL-1.2.14_1
 libSDL_image-1.2.so.0 SDL_image-1.2.10_1
 libx264.so.157 x264-20190507.2245_1
diff --git a/srcpkgs/ffmpeg/files/altivec.patch b/srcpkgs/ffmpeg/files/altivec.patch
deleted file mode 100644
index 9c57200463320e..00000000000000
--- a/srcpkgs/ffmpeg/files/altivec.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-revert some altivec specific change on all ppc* except ppc64le*
-
-q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
-conditionally, for ppc* but not ppc64le* (the new code is valid for
-POWER8 VSX which LE targets as a baseline but not BE)"
-
-
-This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
----
- libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
- 1 file changed, 20 insertions(+), 4 deletions(-)
-
-diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
-index 536545293d..c1e2852adb 100644
---- a/libswscale/ppc/yuv2rgb_altivec.c
-+++ b/libswscale/ppc/yuv2rgb_altivec.c
-@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-     vector signed short R1, G1, B1;                                           \
-     vector unsigned char R, G, B;                                             \
-                                                                               \
-+    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
-+    vector unsigned char align_perm;                                          \
-+                                                                              \
-     vector signed short lCY       = c->CY;                                    \
-     vector signed short lOY       = c->OY;                                    \
-     vector signed short lCRV      = c->CRV;                                   \
-@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
-                                                                               \
-         for (j = 0; j < w / 16; j++) {                                        \
--            y0 = vec_xl(0, y1i);                                              \
-+            y1ivP = (const vector unsigned char *) y1i;                       \
-+            y2ivP = (const vector unsigned char *) y2i;                       \
-+            uivP  = (const vector unsigned char *) ui;                        \
-+            vivP  = (const vector unsigned char *) vi;                        \
-+                                                                              \
-+            align_perm = vec_lvsl(0, y1i);                                    \
-+            y0 = (vector unsigned char)                                       \
-+                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
-                                                                               \
--            y1 = vec_xl(0, y2i);                                              \
-+            align_perm = vec_lvsl(0, y2i);                                    \
-+            y1 = (vector unsigned char)                                       \
-+                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
-                                                                               \
--            u = (vector signed char) vec_xl(0, ui);                           \
-+            align_perm = vec_lvsl(0, ui);                                     \
-+            u = (vector signed char)                                          \
-+                    vec_perm(uivP[0], uivP[1], align_perm);                   \
-                                                                               \
--            v = (vector signed char) vec_xl(0, vi);                           \
-+            align_perm = vec_lvsl(0, vi);                                     \
-+            v = (vector signed char)                                          \
-+                    vec_perm(vivP[0], vivP[1], align_perm);                   \
-                                                                               \
-             u = (vector signed char)                                          \
-                     vec_sub(u,                                                \
--- 
-2.27.0
-
diff --git a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
deleted file mode 100644
index 9a55178c74f0fd..00000000000000
--- a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
-+++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
-@@ -39,6 +39,15 @@
- #endif
- #include <fenv.h>
- 
-+#if (FE_ALL_EXCEPT == 0)
-+/* E.g. ARM soft float does not define these */
-+#define FE_INVALID    0
-+#define FE_DIVBYZERO  0
-+#define FE_OVERFLOW   0
-+#define FE_UNDERFLOW  0
-+#define FE_INEXACT    0
-+#endif
-+
- #if CONFIG_LIBFONTCONFIG
- #include <fontconfig/fontconfig.h>
- #endif
diff --git a/srcpkgs/ffmpeg/patches/binutils-2.41.patch b/srcpkgs/ffmpeg/patches/binutils-2.41.patch
deleted file mode 100644
index 53a596d0ee7d4e..00000000000000
--- a/srcpkgs/ffmpeg/patches/binutils-2.41.patch
+++ /dev/null
@@ -1,73 +0,0 @@
-From effadce6c756247ea8bae32dc13bb3e6f464f0eb Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= <remi@remlab.net>
-Date: Sun, 16 Jul 2023 18:18:02 +0300
-Subject: [PATCH] avcodec/x86/mathops: clip constants used with shift
- instructions within inline assembly
-
-Fixes assembling with binutil as >= 2.41
-
-Signed-off-by: James Almer <jamrial@gmail.com>
----
- libavcodec/x86/mathops.h | 26 +++++++++++++++++++++++---
- 1 file changed, 23 insertions(+), 3 deletions(-)
-
-diff --git a/libavcodec/x86/mathops.h b/libavcodec/x86/mathops.h
-index 6298f5ed1983b..ca7e2dffc1076 100644
---- a/libavcodec/x86/mathops.h
-+++ b/libavcodec/x86/mathops.h
-@@ -35,12 +35,20 @@
- static av_always_inline av_const int MULL(int a, int b, unsigned shift)
- {
-     int rt, dummy;
-+    if (__builtin_constant_p(shift))
-     __asm__ (
-         "imull %3               \n\t"
-         "shrdl %4, %%edx, %%eax \n\t"
-         :"=a"(rt), "=d"(dummy)
--        :"a"(a), "rm"(b), "ci"((uint8_t)shift)
-+        :"a"(a), "rm"(b), "i"(shift & 0x1F)
-     );
-+    else
-+        __asm__ (
-+            "imull %3               \n\t"
-+            "shrdl %4, %%edx, %%eax \n\t"
-+            :"=a"(rt), "=d"(dummy)
-+            :"a"(a), "rm"(b), "c"((uint8_t)shift)
-+        );
-     return rt;
- }
- 
-@@ -113,19 +121,31 @@ __asm__ volatile(\
- // avoid +32 for shift optimization (gcc should do that ...)
- #define NEG_SSR32 NEG_SSR32
- static inline  int32_t NEG_SSR32( int32_t a, int8_t s){
-+    if (__builtin_constant_p(s))
-     __asm__ ("sarl %1, %0\n\t"
-          : "+r" (a)
--         : "ic" ((uint8_t)(-s))
-+         : "i" (-s & 0x1F)
-     );
-+    else
-+        __asm__ ("sarl %1, %0\n\t"
-+               : "+r" (a)
-+               : "c" ((uint8_t)(-s))
-+        );
-     return a;
- }
- 
- #define NEG_USR32 NEG_USR32
- static inline uint32_t NEG_USR32(uint32_t a, int8_t s){
-+    if (__builtin_constant_p(s))
-     __asm__ ("shrl %1, %0\n\t"
-          : "+r" (a)
--         : "ic" ((uint8_t)(-s))
-+         : "i" (-s & 0x1F)
-     );
-+    else
-+        __asm__ ("shrl %1, %0\n\t"
-+               : "+r" (a)
-+               : "c" ((uint8_t)(-s))
-+        );
-     return a;
- }
- 
diff --git a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
deleted file mode 100644
index aa948f7a8a2dfb..00000000000000
--- a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
+++ /dev/null
@@ -1,40 +0,0 @@
-#==================================================================================================
-# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
-# From: Christopher Degawa <christopher.degawa@intel.com>
-# Date: Thu, 20 Oct 2022 22:55:27 -0500
-# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
-#
-# compressed_ten_bit_format has been deprecated upstream and has no effect
-# and can be removed. Plus, technically it was never used in the first place
-# since it would require the app (ffmpeg) to set it and do additional
-# processing of the input frames.
-#
-# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
-#
-# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
-#==================================================================================================
---- a/libavcodec/libsvtav1.c
-+++ b/libavcodec/libsvtav1.c
-@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
- 
- static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
- {
--    const int    pack_mode_10bit =
--        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
--    const size_t luma_size_8bit  =
--        config->source_width * config->source_height * (1 << pack_mode_10bit);
--    const size_t luma_size_10bit =
--        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
-+    const size_t luma_size = config->source_width * config->source_height *
-+        (config->encoder_bit_depth > 8 ? 2 : 1);
- 
-     EbSvtIOFormat *in_data;
- 
--    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
-+    svt_enc->raw_size = luma_size * 3 / 2;
- 
-     // allocate buffer for in and out
-     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
--- 
-GitLab
-
diff --git a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
deleted file mode 100644
index 00e3f68a415b84..00000000000000
--- a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
-From: Rainer Hochecker <fernetmenta@online.de>
-Date: Sat, 26 Jan 2019 19:48:35 +0100
-Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
-
-This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
-It was hit frequently when watching h264 channels received via DVB-X.
-Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
----
- libavcodec/vaapi_h264.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
-index 5854587a255..f12fdc457a4 100644
---- a/libavcodec/vaapi_h264.c
-+++ b/libavcodec/vaapi_h264.c
-@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
-     H264SliceContext *sl = &h->slice_ctx[0];
-     int ret;
- 
-+    if (pic->nb_slices == 0) {
-+        ret = AVERROR_INVALIDDATA;
-+        goto finish;
-+    }
-+
-     ret = ff_vaapi_decode_issue(avctx, pic);
-     if (ret < 0)
-         goto finish;
diff --git a/srcpkgs/ffmpeg/template b/srcpkgs/ffmpeg/template
index 1ebb436135938d..f1e4712c41d087 100644
--- a/srcpkgs/ffmpeg/template
+++ b/srcpkgs/ffmpeg/template
@@ -1,15 +1,15 @@
 # Template file for 'ffmpeg'
 # audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
 pkgname=ffmpeg
-version=4.4.4
-revision=6
+version=6.0.1
+revision=1
 short_desc="Decoding, encoding and streaming software"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="https://www.ffmpeg.org"
 changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
 distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
-checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+checksum=9b16b8731d78e596b4be0d720428ca42df642bb2d78342881ff7f5bc29fc9623
 
 hostmakedepends="pkg-config perl"
 makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
@@ -26,12 +26,13 @@ makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-deve
  $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
  $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
  $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
- $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers Vulkan-Tools Vulkan-ValidationLayers')
+ $(vopt_if onevpl 'oneVPL oneVPL-devel')
  $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
 depends="ffplay>=${version}_${revision}"
 
 build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
- dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec onevpl"
 build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
 desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
 desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
@@ -39,9 +40,13 @@ desc_option_sofa="Enable support for AES SOFA"
 desc_option_webp="Enable support for WebP"
 
 case "$XBPS_TARGET_MACHINE" in
-	i686*|x86_64*)
-		hostmakedepends+=" nasm"
+	i686*)
 		build_options_default+=" vaapi vdpau nvenc nvdec"
+		hostmakedepends+=" nasm"
+		;;
+	x86_64*)
+		hostmakedepends+=" nasm"
+		build_options_default+=" vaapi vdpau nvenc nvdec onevpl"
 		;;
 	ppc64*) build_options_default+=" vaapi vdpau";;
 	mips*) CFLAGS="-mnan=legacy";;
@@ -65,8 +70,6 @@ post_patch() {
 		ppc64le*) ;;
 		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
 	esac
-
-	vsed -i libavfilter/vf_libvmaf.c -e 's!/usr/local/share/model/\(vmaf_v0.6.1\).pkl!/usr/share/vmaf/\1.json!'
 }
 
 do_configure() {
@@ -115,18 +118,19 @@ do_configure() {
 		$(vopt_enable x265 libx265) \
 		$(vopt_enable v4l2 libv4l2) \
 		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
-		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		--enable-libbs2b --enable-libvidstab \
 		$(vopt_enable dav1d libdav1d) \
 		$(vopt_enable zimg libzimg) \
 		$(vopt_enable webp libwebp) \
 		$(vopt_enable sofa libmysofa) \
 		$(vopt_enable vulkan) \
+		$(vopt_enable onevpl libvpl) \
 		$(vopt_enable drm libdrm) \
 		$(vopt_enable svtav1 libsvtav1) \
 		$(vopt_enable srt libsrt) \
 		$(vopt_enable rist librist) \
-		$(vopt_if nvenc '--enable-nvenc') \
-		$(vopt_if nvdec '--enable-nvdec')
+		$(vopt_enable nvenc nvenc) \
+		$(vopt_enable nvdec nvdec)
 }
 
 do_build() {
@@ -153,10 +157,8 @@ libavdevice_package() {
 }
 
 libavresample_package() {
-	short_desc="FFmpeg audio resampling library"
-	pkg_install() {
-		vmove "usr/lib/libavresample.so.*"
-	}
+	short_desc="Package deprecated, removal needed"
+	build_style=meta
 }
 
 libavformat_package() {
@@ -210,15 +212,13 @@ ffmpeg-devel_package() {
 		libavfilter>=${version}_${revision}
 		libpostproc>=${version}_${revision}
 		libswscale>=${version}_${revision}
-		libswresample>=${version}_${revision}
-		libavresample>=${version}_${revision}"
+		libswresample>=${version}_${revision}"
 	short_desc+=" - development files"
-
+	conflicts="ffmpeg4-devel"
 	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
 		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
 		nostrip_files="/usr/lib/libavfilter.a"
 	fi
-
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig

From 2f444f539c6569dc2a2e8da339af5f3ae71b43c7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:14 -0400
Subject: [PATCH 002/109] openshot: revbump for ffmpeg6

---
 srcpkgs/openshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openshot/template b/srcpkgs/openshot/template
index 3849858fe963b5..12789bc9867499 100644
--- a/srcpkgs/openshot/template
+++ b/srcpkgs/openshot/template
@@ -1,7 +1,7 @@
 # Template file for 'openshot'
 pkgname=openshot
 version=3.1.1
-revision=1
+revision=2
 build_style=python3-module
 hostmakedepends="python3 python3-setuptools"
 makedepends="ffmpeg-devel python3-PyQt5"

From 05f3e5ecccf0685968bccb8774abeb6d150795b3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:36 -0400
Subject: [PATCH 003/109] sumo: revbump for ffmpeg6

---
 srcpkgs/sumo/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/sumo/template b/srcpkgs/sumo/template
index a730afa9fafa92..e2def06fa4bd7d 100644
--- a/srcpkgs/sumo/template
+++ b/srcpkgs/sumo/template
@@ -1,7 +1,7 @@
 # Template file for 'sumo'
 pkgname=sumo
 version=1.12.0
-revision=7
+revision=8
 build_style=cmake
 hostmakedepends="libgdal-tools pkg-config swig python3-setuptools"
 makedepends="python3-devel ffmpeg-devel fox-devel gl2ps-devel libgdal-devel

From 5a61ce996bab6f7cc99bf1286763f76dcdbd995f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:56:22 -0400
Subject: [PATCH 004/109] New package: ffmpeg4-4.4.4.

---
 srcpkgs/ffmpeg4-devel                         |   1 +
 srcpkgs/ffmpeg4/files/altivec.patch           |  60 +++++
 .../patches/armv5tel-floating-point.patch     |  18 ++
 srcpkgs/ffmpeg4/patches/binutils-2.41.patch   |  73 ++++++
 ...h-libavcodec-libsvtav1-ten_bit_format.diff |  40 +++
 .../workaround-mesa-readeon-vaapi-bug.patch   |  28 +++
 srcpkgs/ffmpeg4/template                      | 234 ++++++++++++++++++
 srcpkgs/libavcodec4                           |   1 +
 srcpkgs/libavdevice4                          |   1 +
 srcpkgs/libavfilter4                          |   1 +
 srcpkgs/libavformat4                          |   1 +
 srcpkgs/libavresample4                        |   1 +
 srcpkgs/libavutil4                            |   1 +
 srcpkgs/libpostproc4                          |   1 +
 srcpkgs/libswresample4                        |   1 +
 srcpkgs/libswscale4                           |   1 +
 16 files changed, 463 insertions(+)
 create mode 120000 srcpkgs/ffmpeg4-devel
 create mode 100644 srcpkgs/ffmpeg4/files/altivec.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/binutils-2.41.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 create mode 100644 srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
 create mode 100644 srcpkgs/ffmpeg4/template
 create mode 120000 srcpkgs/libavcodec4
 create mode 120000 srcpkgs/libavdevice4
 create mode 120000 srcpkgs/libavfilter4
 create mode 120000 srcpkgs/libavformat4
 create mode 120000 srcpkgs/libavresample4
 create mode 120000 srcpkgs/libavutil4
 create mode 120000 srcpkgs/libpostproc4
 create mode 120000 srcpkgs/libswresample4
 create mode 120000 srcpkgs/libswscale4

diff --git a/srcpkgs/ffmpeg4-devel b/srcpkgs/ffmpeg4-devel
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/ffmpeg4-devel
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/ffmpeg4/files/altivec.patch b/srcpkgs/ffmpeg4/files/altivec.patch
new file mode 100644
index 00000000000000..9c57200463320e
--- /dev/null
+++ b/srcpkgs/ffmpeg4/files/altivec.patch
@@ -0,0 +1,60 @@
+revert some altivec specific change on all ppc* except ppc64le*
+
+q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
+conditionally, for ppc* but not ppc64le* (the new code is valid for
+POWER8 VSX which LE targets as a baseline but not BE)"
+
+
+This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
+---
+ libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
+ 1 file changed, 20 insertions(+), 4 deletions(-)
+
+diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
+index 536545293d..c1e2852adb 100644
+--- a/libswscale/ppc/yuv2rgb_altivec.c
++++ b/libswscale/ppc/yuv2rgb_altivec.c
+@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+     vector signed short R1, G1, B1;                                           \
+     vector unsigned char R, G, B;                                             \
+                                                                               \
++    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
++    vector unsigned char align_perm;                                          \
++                                                                              \
+     vector signed short lCY       = c->CY;                                    \
+     vector signed short lOY       = c->OY;                                    \
+     vector signed short lCRV      = c->CRV;                                   \
+@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
+                                                                               \
+         for (j = 0; j < w / 16; j++) {                                        \
+-            y0 = vec_xl(0, y1i);                                              \
++            y1ivP = (const vector unsigned char *) y1i;                       \
++            y2ivP = (const vector unsigned char *) y2i;                       \
++            uivP  = (const vector unsigned char *) ui;                        \
++            vivP  = (const vector unsigned char *) vi;                        \
++                                                                              \
++            align_perm = vec_lvsl(0, y1i);                                    \
++            y0 = (vector unsigned char)                                       \
++                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
+                                                                               \
+-            y1 = vec_xl(0, y2i);                                              \
++            align_perm = vec_lvsl(0, y2i);                                    \
++            y1 = (vector unsigned char)                                       \
++                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
+                                                                               \
+-            u = (vector signed char) vec_xl(0, ui);                           \
++            align_perm = vec_lvsl(0, ui);                                     \
++            u = (vector signed char)                                          \
++                    vec_perm(uivP[0], uivP[1], align_perm);                   \
+                                                                               \
+-            v = (vector signed char) vec_xl(0, vi);                           \
++            align_perm = vec_lvsl(0, vi);                                     \
++            v = (vector signed char)                                          \
++                    vec_perm(vivP[0], vivP[1], align_perm);                   \
+                                                                               \
+             u = (vector signed char)                                          \
+                     vec_sub(u,                                                \
+-- 
+2.27.0
+
diff --git a/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
new file mode 100644
index 00000000000000..9a55178c74f0fd
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
@@ -0,0 +1,18 @@
+--- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
++++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
+@@ -39,6 +39,15 @@
+ #endif
+ #include <fenv.h>
+ 
++#if (FE_ALL_EXCEPT == 0)
++/* E.g. ARM soft float does not define these */
++#define FE_INVALID    0
++#define FE_DIVBYZERO  0
++#define FE_OVERFLOW   0
++#define FE_UNDERFLOW  0
++#define FE_INEXACT    0
++#endif
++
+ #if CONFIG_LIBFONTCONFIG
+ #include <fontconfig/fontconfig.h>
+ #endif
diff --git a/srcpkgs/ffmpeg4/patches/binutils-2.41.patch b/srcpkgs/ffmpeg4/patches/binutils-2.41.patch
new file mode 100644
index 00000000000000..53a596d0ee7d4e
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/binutils-2.41.patch
@@ -0,0 +1,73 @@
+From effadce6c756247ea8bae32dc13bb3e6f464f0eb Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= <remi@remlab.net>
+Date: Sun, 16 Jul 2023 18:18:02 +0300
+Subject: [PATCH] avcodec/x86/mathops: clip constants used with shift
+ instructions within inline assembly
+
+Fixes assembling with binutil as >= 2.41
+
+Signed-off-by: James Almer <jamrial@gmail.com>
+---
+ libavcodec/x86/mathops.h | 26 +++++++++++++++++++++++---
+ 1 file changed, 23 insertions(+), 3 deletions(-)
+
+diff --git a/libavcodec/x86/mathops.h b/libavcodec/x86/mathops.h
+index 6298f5ed1983b..ca7e2dffc1076 100644
+--- a/libavcodec/x86/mathops.h
++++ b/libavcodec/x86/mathops.h
+@@ -35,12 +35,20 @@
+ static av_always_inline av_const int MULL(int a, int b, unsigned shift)
+ {
+     int rt, dummy;
++    if (__builtin_constant_p(shift))
+     __asm__ (
+         "imull %3               \n\t"
+         "shrdl %4, %%edx, %%eax \n\t"
+         :"=a"(rt), "=d"(dummy)
+-        :"a"(a), "rm"(b), "ci"((uint8_t)shift)
++        :"a"(a), "rm"(b), "i"(shift & 0x1F)
+     );
++    else
++        __asm__ (
++            "imull %3               \n\t"
++            "shrdl %4, %%edx, %%eax \n\t"
++            :"=a"(rt), "=d"(dummy)
++            :"a"(a), "rm"(b), "c"((uint8_t)shift)
++        );
+     return rt;
+ }
+ 
+@@ -113,19 +121,31 @@ __asm__ volatile(\
+ // avoid +32 for shift optimization (gcc should do that ...)
+ #define NEG_SSR32 NEG_SSR32
+ static inline  int32_t NEG_SSR32( int32_t a, int8_t s){
++    if (__builtin_constant_p(s))
+     __asm__ ("sarl %1, %0\n\t"
+          : "+r" (a)
+-         : "ic" ((uint8_t)(-s))
++         : "i" (-s & 0x1F)
+     );
++    else
++        __asm__ ("sarl %1, %0\n\t"
++               : "+r" (a)
++               : "c" ((uint8_t)(-s))
++        );
+     return a;
+ }
+ 
+ #define NEG_USR32 NEG_USR32
+ static inline uint32_t NEG_USR32(uint32_t a, int8_t s){
++    if (__builtin_constant_p(s))
+     __asm__ ("shrl %1, %0\n\t"
+          : "+r" (a)
+-         : "ic" ((uint8_t)(-s))
++         : "i" (-s & 0x1F)
+     );
++    else
++        __asm__ ("shrl %1, %0\n\t"
++               : "+r" (a)
++               : "c" ((uint8_t)(-s))
++        );
+     return a;
+ }
+ 
diff --git a/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
new file mode 100644
index 00000000000000..aa948f7a8a2dfb
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
@@ -0,0 +1,40 @@
+#==================================================================================================
+# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
+# From: Christopher Degawa <christopher.degawa@intel.com>
+# Date: Thu, 20 Oct 2022 22:55:27 -0500
+# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
+#
+# compressed_ten_bit_format has been deprecated upstream and has no effect
+# and can be removed. Plus, technically it was never used in the first place
+# since it would require the app (ffmpeg) to set it and do additional
+# processing of the input frames.
+#
+# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
+#
+# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
+#==================================================================================================
+--- a/libavcodec/libsvtav1.c
++++ b/libavcodec/libsvtav1.c
+@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
+ 
+ static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
+ {
+-    const int    pack_mode_10bit =
+-        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
+-    const size_t luma_size_8bit  =
+-        config->source_width * config->source_height * (1 << pack_mode_10bit);
+-    const size_t luma_size_10bit =
+-        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
++    const size_t luma_size = config->source_width * config->source_height *
++        (config->encoder_bit_depth > 8 ? 2 : 1);
+ 
+     EbSvtIOFormat *in_data;
+ 
+-    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
++    svt_enc->raw_size = luma_size * 3 / 2;
+ 
+     // allocate buffer for in and out
+     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
+-- 
+GitLab
+
diff --git a/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
new file mode 100644
index 00000000000000..00e3f68a415b84
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
@@ -0,0 +1,28 @@
+From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
+From: Rainer Hochecker <fernetmenta@online.de>
+Date: Sat, 26 Jan 2019 19:48:35 +0100
+Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
+
+This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
+It was hit frequently when watching h264 channels received via DVB-X.
+Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
+---
+ libavcodec/vaapi_h264.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
+index 5854587a255..f12fdc457a4 100644
+--- a/libavcodec/vaapi_h264.c
++++ b/libavcodec/vaapi_h264.c
+@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
+     H264SliceContext *sl = &h->slice_ctx[0];
+     int ret;
+ 
++    if (pic->nb_slices == 0) {
++        ret = AVERROR_INVALIDDATA;
++        goto finish;
++    }
++
+     ret = ff_vaapi_decode_issue(avctx, pic);
+     if (ret < 0)
+         goto finish;
diff --git a/srcpkgs/ffmpeg4/template b/srcpkgs/ffmpeg4/template
new file mode 100644
index 00000000000000..9ba14bdb8ddf32
--- /dev/null
+++ b/srcpkgs/ffmpeg4/template
@@ -0,0 +1,234 @@
+# Template file for 'ffmpeg4'
+# audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
+pkgname=ffmpeg4
+version=4.4.4
+revision=1
+short_desc="Decoding, encoding and streaming software - ffmpeg4 libraries only"
+maintainer="Orphaned <orphan@voidlinux.org>"
+license="GPL-3.0-or-later"
+homepage="https://www.ffmpeg.org"
+changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
+distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
+checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+
+hostmakedepends="pkg-config perl"
+makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
+ libXext-devel libXvMC-devel libxcb-devel lame-devel libtheora-devel
+ libvorbis-devel x264-devel xvidcore-devel jack-devel SDL2-devel
+ libcdio-paranoia-devel librtmp-devel libmodplug-devel gnutls-devel
+ speex-devel celt-devel harfbuzz-devel libass-devel opus-devel ocl-icd-devel
+ libbs2b-devel libvidstab-devel vmaf-devel $(vopt_if pulseaudio pulseaudio-devel)
+ $(vopt_if vaapi libva-devel) $(vopt_if vdpau libvdpau-devel)
+ $(vopt_if x265 x265-devel) $(vopt_if v4l2 v4l-utils-devel)
+ $(vopt_if fdk_aac fdk-aac-devel) $(vopt_if vpx libvpx-devel)
+ $(vopt_if aom libaom-devel) $(vopt_if sndio sndio-devel)
+ $(vopt_if dav1d libdav1d-devel) $(vopt_if zimg zimg-devel)
+ $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
+ $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
+ $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
+
+build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
+
+desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
+desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
+desc_option_sofa="Enable support for AES SOFA"
+desc_option_webp="Enable support for WebP"
+
+case "$XBPS_TARGET_MACHINE" in
+	i686*|x86_64*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau nvenc nvdec"
+			;;
+	ppc64*) build_options_default+=" vaapi vdpau";;
+	mips*) CFLAGS="-mnan=legacy";;
+esac
+
+if [ "$XBPS_TARGET_WORDSIZE" != "32" ]; then
+	build_options_default+=" svtav1"
+fi
+
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+fi
+
+_apply_patch() {
+	local args="$1" pname="$(basename $2)"
+
+	if [ ! -f ".${pname}_done" ]; then
+		patch -N $args -i $2
+		touch .${pname}_done
+	fi
+}
+
+post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64le*) ;;
+		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
+	esac
+
+	vsed -i libavfilter/vf_libvmaf.c -e 's!/usr/local/share/model/\(vmaf_v0.6.1\).pkl!/usr/share/vmaf/\1.json!'
+}
+
+do_configure() {
+	# Fix gcc on x86_64-musl only
+	if [ "$XBPS_TARGET_MACHINE" = "x86_64-musl" ]; then
+		vsed -i configure -e "s;_cflags_speed='-O3';_cflags_speed='-O2';"
+	fi
+
+	if [ "$CROSS_BUILD" ]; then
+		case "$XBPS_TARGET_MACHINE" in
+			arm*) _arch="arm";;
+			aarch64*) _arch="aarch64";;
+			mips*) _arch="mips";;
+			ppc64*) _arch="ppc64";;
+			ppc*) _arch="ppc";;
+			*) _arch="${XBPS_TARGET_MACHINE%%-musl}";;
+		esac
+
+		_args+=" --enable-cross-compile
+			--sysroot=$XBPS_CROSS_BASE
+			--cross-prefix=${XBPS_CROSS_TRIPLET}-
+			--target-os=linux --arch=${_arch}"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc|ppc-musl) _args+=" --disable-altivec";;
+	esac
+
+	if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+		_args+=" --extra-libs=-latomic"
+	fi
+
+	./configure --prefix=/usr --disable-debug --enable-gpl --enable-gnutls \
+		--disable-stripping \
+		--enable-libcdio --enable-version3 --enable-runtime-cpudetect \
+		--enable-libmp3lame --enable-libvorbis --enable-libxvid \
+		--enable-libx264 $(vopt_enable vpx libvpx) --enable-libtheora \
+		--enable-shared --enable-static --enable-libxcb \
+		$(vopt_enable pulseaudio libpulse) --enable-libfreetype --enable-libmodplug \
+		--enable-libspeex --enable-libcelt --enable-libass \
+		--enable-libopus --enable-librtmp --enable-libjack \
+		$(vopt_if fdk_aac '--enable-nonfree --enable-libfdk-aac') \
+		--disable-libopencore_amrnb --disable-libopencore_amrwb \
+		--disable-libopenjpeg \
+		--enable-postproc --enable-opencl ${_args} --enable-libvmaf ${_args} \
+		$(vopt_enable x265 libx265) \
+		$(vopt_enable v4l2 libv4l2) \
+		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
+		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		$(vopt_enable dav1d libdav1d) \
+		$(vopt_enable zimg libzimg) \
+		$(vopt_enable webp libwebp) \
+		$(vopt_enable sofa libmysofa) \
+		$(vopt_enable vulkan) \
+		$(vopt_enable drm libdrm) \
+		$(vopt_enable svtav1 libsvtav1) \
+		$(vopt_enable srt libsrt) \
+		$(vopt_enable rist librist) \
+		$(vopt_if nvenc '--enable-nvenc') \
+		$(vopt_if nvdec '--enable-nvdec')
+}
+
+do_build() {
+	make ${makejobs}
+	make doc/ff{mpeg,play}.1
+}
+
+do_install() {
+	make DESTDIR=${DESTDIR} install install-man
+	rm -rf ${DESTDIR}/usr/bin
+}
+
+libavcodec4_package() {
+	short_desc="FFmpeg codec library"
+	pkg_install() {
+		vmove "usr/lib/libavcodec.so.*"
+	}
+}
+
+libavdevice4_package() {
+	short_desc="FFmpeg device handling library"
+	pkg_install() {
+		vmove "usr/lib/libavdevice.so.*"
+	}
+}
+
+libavresample4_package() {
+	short_desc="FFmpeg audio resampling library"
+	pkg_install() {
+		vmove "usr/lib/libavresample.so.*"
+	}
+}
+
+libavformat4_package() {
+	short_desc="FFmpeg file format library"
+	pkg_install() {
+		vmove "usr/lib/libavformat.so.*"
+	}
+}
+
+libavutil4_package() {
+	short_desc="FFmpeg utility library"
+	pkg_install() {
+		vmove "usr/lib/libavutil.so.*"
+	}
+}
+
+libavfilter4_package() {
+	short_desc="FFmpeg audio/video filter library"
+	pkg_install() {
+		vmove "usr/lib/libavfilter.so.*"
+	}
+}
+
+libpostproc4_package() {
+	short_desc="FFmpeg video postprocessing library"
+	pkg_install() {
+		vmove "usr/lib/libpostproc.so.*"
+	}
+}
+
+libswscale4_package() {
+	short_desc="FFmpeg video scaling library"
+	pkg_install() {
+		vmove "usr/lib/libswscale.so.*"
+	}
+}
+
+libswresample4_package() {
+	short_desc="FFmpeg video resampling library"
+	pkg_install() {
+		vmove "usr/lib/libswresample.so.*"
+	}
+}
+
+ffmpeg4-devel_package() {
+	depends="
+		libavcodec4>=${version}_${revision}
+		libavdevice4>=${version}_${revision}
+		libavformat4>=${version}_${revision}
+		libavutil4>=${version}_${revision}
+		libavfilter4>=${version}_${revision}
+		libpostproc4>=${version}_${revision}
+		libswscale4>=${version}_${revision}
+		libswresample4>=${version}_${revision}
+		libavresample4>=${version}_${revision}"
+	short_desc+=" - development files"
+	conflicts="ffmpeg-devel"
+	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
+		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
+		nostrip_files="/usr/lib/libavfilter.a"
+	fi
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.a"
+		vmove "usr/lib/*.so"
+		vmove usr/share/ffmpeg/examples
+		vmove usr/share/man/man3
+	}
+}
diff --git a/srcpkgs/libavcodec4 b/srcpkgs/libavcodec4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavcodec4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavdevice4 b/srcpkgs/libavdevice4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavdevice4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavfilter4 b/srcpkgs/libavfilter4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavfilter4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavformat4 b/srcpkgs/libavformat4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavformat4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavresample4 b/srcpkgs/libavresample4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavutil4 b/srcpkgs/libavutil4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavutil4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libpostproc4 b/srcpkgs/libpostproc4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libpostproc4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswresample4 b/srcpkgs/libswresample4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libswresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswscale4 b/srcpkgs/libswscale4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libswscale4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file

From a2ca35ab323aa9666cadbef9342104081df6ff93 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:04 -0400
Subject: [PATCH 005/109] opencv: update to 4.7.0.

---
 common/shlibs           | 104 ++++++++++++++++++++--------------------
 srcpkgs/opencv/template |   8 ++--
 2 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index e29b7e87b8915c..34ebb185c3ab7b 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2081,58 +2081,58 @@ libcapstone.so.5 capstone-5.0.1_1
 libhavege.so.2 libhaveged-1.9.11_1
 libnih.so.1 libnih-1.0.3_1
 libnih-dbus.so.1 libnih-1.0.3_1
-libopencv_quality.so.406 libopencv-4.6.0_1
-libopencv_reg.so.406 libopencv-4.6.0_1
-libopencv_surface_matching.so.406 libopencv-4.6.0_1
-libopencv_xphoto.so.406 libopencv-4.6.0_1
-libopencv_freetype.so.406 libopencv-4.6.0_1
-libopencv_fuzzy.so.406 libopencv-4.6.0_1
-libopencv_hfs.so.406 libopencv-4.6.0_1
-libopencv_img_hash.so.406 libopencv-4.6.0_1
-libopencv_line_descriptor.so.406 libopencv-4.6.0_1
-libopencv_saliency.so.406 libopencv-4.6.0_1
-libopencv_structured_light.so.406 libopencv-4.6.0_1
-libopencv_aruco.so.406 libopencv-4.6.0_1
-libopencv_bgsegm.so.406 libopencv-4.6.0_1
-libopencv_bioinspired.so.406 libopencv-4.6.0_1
-libopencv_ccalib.so.406 libopencv-4.6.0_1
-libopencv_face.so.406 libopencv-4.6.0_1
-libopencv_tracking.so.406 libopencv-4.6.0_1
-libopencv_xfeatures2d.so.406 libopencv-4.6.0_1
-libopencv_optflow.so.406 libopencv-4.6.0_1
-libopencv_ximgproc.so.406 libopencv-4.6.0_1
-libopencv_plot.so.406 libopencv-4.6.0_1
-libopencv_text.so.406 libopencv-4.6.0_1
-libopencv_ml.so.406 libopencv-4.6.0_1
-libopencv_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn.so.406 libopencv-4.6.0_1
-libopencv_shape.so.406 libopencv-4.6.0_1
-libopencv_stitching.so.406 libopencv-4.6.0_1
-libopencv_photo.so.406 libopencv-4.6.0_1
-libopencv_video.so.406 libopencv-4.6.0_1
-libopencv_calib3d.so.406 libopencv-4.6.0_1
-libopencv_features2d.so.406 libopencv-4.6.0_1
-libopencv_flann.so.406 libopencv-4.6.0_1
-libopencv_highgui.so.406 libopencv-4.6.0_1
-libopencv_videoio.so.406 libopencv-4.6.0_1
-libopencv_imgcodecs.so.406 libopencv-4.6.0_1
-libopencv_imgproc.so.406 libopencv-4.6.0_1
-libopencv_core.so.406 libopencv-4.6.0_1
-libopencv_superres.so.406 libopencv-4.6.0_1
-libopencv_videostab.so.406 libopencv-4.6.0_1
-libopencv_gapi.so.406 libopencv-4.6.0_1
-libopencv_xobjdetect.so.406 libopencv-4.6.0_1
-libopencv_datasets.so.406 libopencv-4.6.0_1
-libopencv_dnn_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn_superres.so.406 libopencv-4.6.0_1
-libopencv_dpm.so.406 libopencv-4.6.0_1
-libopencv_phase_unwrapping.so.406 libopencv-4.6.0_1
-libopencv_stereo.so.406 libopencv-4.6.0_1
-libopencv_rapid.so.406 libopencv-4.6.0_1
-libopencv_intensity_transform.so.406 libopencv-4.6.0_1
-libopencv_alphamat.so.406 libopencv-4.6.0_1
-libopencv_barcode.so.406 libopencv-4.6.0_1
-libopencv_mcc.so.406 libopencv-4.6.0_1
+libopencv_quality.so.407 libopencv-4.7.0_1
+libopencv_reg.so.407 libopencv-4.7.0_1
+libopencv_surface_matching.so.407 libopencv-4.7.0_1
+libopencv_xphoto.so.407 libopencv-4.7.0_1
+libopencv_freetype.so.407 libopencv-4.7.0_1
+libopencv_fuzzy.so.407 libopencv-4.7.0_1
+libopencv_hfs.so.407 libopencv-4.7.0_1
+libopencv_img_hash.so.407 libopencv-4.7.0_1
+libopencv_line_descriptor.so.407 libopencv-4.7.0_1
+libopencv_saliency.so.407 libopencv-4.7.0_1
+libopencv_structured_light.so.407 libopencv-4.7.0_1
+libopencv_aruco.so.407 libopencv-4.7.0_1
+libopencv_bgsegm.so.407 libopencv-4.7.0_1
+libopencv_bioinspired.so.407 libopencv-4.7.0_1
+libopencv_ccalib.so.407 libopencv-4.7.0_1
+libopencv_face.so.407 libopencv-4.7.0_1
+libopencv_tracking.so.407 libopencv-4.7.0_1
+libopencv_xfeatures2d.so.407 libopencv-4.7.0_1
+libopencv_optflow.so.407 libopencv-4.7.0_1
+libopencv_ximgproc.so.407 libopencv-4.7.0_1
+libopencv_plot.so.407 libopencv-4.7.0_1
+libopencv_text.so.407 libopencv-4.7.0_1
+libopencv_ml.so.407 libopencv-4.7.0_1
+libopencv_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn.so.407 libopencv-4.7.0_1
+libopencv_shape.so.407 libopencv-4.7.0_1
+libopencv_stitching.so.407 libopencv-4.7.0_1
+libopencv_photo.so.407 libopencv-4.7.0_1
+libopencv_video.so.407 libopencv-4.7.0_1
+libopencv_calib3d.so.407 libopencv-4.7.0_1
+libopencv_features2d.so.407 libopencv-4.7.0_1
+libopencv_flann.so.407 libopencv-4.7.0_1
+libopencv_highgui.so.407 libopencv-4.7.0_1
+libopencv_videoio.so.407 libopencv-4.7.0_1
+libopencv_imgcodecs.so.407 libopencv-4.7.0_1
+libopencv_imgproc.so.407 libopencv-4.7.0_1
+libopencv_core.so.407 libopencv-4.7.0_1
+libopencv_superres.so.407 libopencv-4.7.0_1
+libopencv_videostab.so.407 libopencv-4.7.0_1
+libopencv_gapi.so.407 libopencv-4.7.0_1
+libopencv_xobjdetect.so.407 libopencv-4.7.0_1
+libopencv_datasets.so.407 libopencv-4.7.0_1
+libopencv_dnn_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn_superres.so.407 libopencv-4.7.0_1
+libopencv_dpm.so.407 libopencv-4.7.0_1
+libopencv_phase_unwrapping.so.407 libopencv-4.7.0_1
+libopencv_stereo.so.407 libopencv-4.7.0_1
+libopencv_rapid.so.407 libopencv-4.7.0_1
+libopencv_intensity_transform.so.407 libopencv-4.7.0_1
+libopencv_alphamat.so.407 libopencv-4.7.0_1
+libopencv_barcode.so.407 libopencv-4.7.0_1
+libopencv_mcc.so.407 libopencv-4.7.0_1
 libuniconf.so.4.6 wvstreams-4.6.1_20
 libwvbase.so.4.6 wvstreams-4.6.1_20
 libwvutils.so.4.6 wvstreams-4.6.1_20
diff --git a/srcpkgs/opencv/template b/srcpkgs/opencv/template
index aea4bfc3a265cf..ce94de9424d18d 100644
--- a/srcpkgs/opencv/template
+++ b/srcpkgs/opencv/template
@@ -1,7 +1,7 @@
 # Template file for 'opencv'
 pkgname=opencv
-version=4.6.0
-revision=6
+version=4.7.0
+revision=1
 create_wrksrc=yes
 build_wrksrc=${pkgname}-${version}
 build_style=cmake
@@ -24,8 +24,8 @@ homepage="https://opencv.org"
 changelog="https://github.com/opencv/opencv/wiki/ChangeLog"
 distfiles="https://github.com/opencv/opencv/archive/${version}.tar.gz
  https://github.com/opencv/opencv_contrib/archive/${version}.tar.gz>contrib.tar.gz"
-checksum="1ec1cba65f9f20fe5a41fda1586e01c70ea0c9a6d7b67c9e13edf0cfe2239277
- 1777d5fd2b59029cf537e5fd6f8aa68d707075822f90bde683fcde086f85f7a7"
+checksum="8df0079cdbe179748a18d44731af62a245a45ebf5085223dc03133954c662973
+ 42df840cf9055e59d0e22c249cfb19f04743e1bdad113d31b1573d3934d62584"
 patch_args="-Np1 -d ${build_wrksrc}"
 # tests hang indenfinitely, even with test data included
 make_check=no

From c754dbe845409d3cee65d0601541b06b2e693188 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 006/109] actiona: revbump for opencv-4.7.0

---
 srcpkgs/actiona/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/actiona/template b/srcpkgs/actiona/template
index cf5f0b7a2ae610..0d899311e6df75 100644
--- a/srcpkgs/actiona/template
+++ b/srcpkgs/actiona/template
@@ -1,7 +1,7 @@
 # Template file for 'actiona'
 pkgname=actiona
 version=3.10.1
-revision=2
+revision=3
 build_style=qmake
 configure_args="PKGCONFIG_OPENCV=opencv4"
 hostmakedepends="pkg-config qt5-plugin-mysql qt5-qmake qt5-host-tools"

From 02bc2ccad4e358b5b930ec2c5707fe7541bf9fec Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 007/109] retroshare: revbump for opencv-4.7.0

---
 srcpkgs/retroshare/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroshare/template b/srcpkgs/retroshare/template
index bb17569277a7f3..49e2c1cbe8a531 100644
--- a/srcpkgs/retroshare/template
+++ b/srcpkgs/retroshare/template
@@ -1,7 +1,7 @@
 # Template file for 'retroshare'
 pkgname=retroshare
 version=0.6.6
-revision=3
+revision=4
 build_style=qmake
 #XXX broadcast feature requires an ancient udp-discovery-cpp which either needs
 # to be fetched+patched (FTBFS) here or packaged :/

From 6b2807291eddf2d7d2f97c00ab8b20bcd050a14f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 008/109] waifu2x-converter-cpp: revbump for opencv-4.7.0

---
 srcpkgs/waifu2x-converter-cpp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waifu2x-converter-cpp/template b/srcpkgs/waifu2x-converter-cpp/template
index 361b8a23b94977..c5ac17eb54ea4c 100644
--- a/srcpkgs/waifu2x-converter-cpp/template
+++ b/srcpkgs/waifu2x-converter-cpp/template
@@ -1,7 +1,7 @@
 # Template file for 'waifu2x-converter-cpp'
 pkgname=waifu2x-converter-cpp
 version=5.2.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DINSTALL_MODELS=ON"
 hostmakedepends="pkg-config"

From 55478e9c36eced0f1a86c1d17e316dbc877e9adf Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:38 -0400
Subject: [PATCH 009/109] vlc: revbump for ffmpeg4

---
 srcpkgs/vlc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/vlc/template b/srcpkgs/vlc/template
index 559b1c4fff339f..fc399f1a6e9bfc 100644
--- a/srcpkgs/vlc/template
+++ b/srcpkgs/vlc/template
@@ -1,7 +1,7 @@
 # Template file for 'vlc'
 pkgname=vlc
 version=3.0.20
-revision=4
+revision=5
 build_style=gnu-configure
 configure_args="--disable-gme --disable-libtar --enable-jack
  --enable-live555 --disable-fluidsynth --enable-dvdread
@@ -25,7 +25,7 @@ lib32disabled=yes
 hostmakedepends="automake libtool pkg-config flex gettext libgcrypt-devel
  live555-devel gettext-devel $(vopt_if lua lua52) $(vopt_if chromecast protobuf)"
 makedepends="
- avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg-devel freefont-ttf
+ avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg4-devel freefont-ttf
  gnutls-devel jack-devel liba52-devel libass-devel libbluray-devel
  libcdio-devel libdca-devel libdvbpsi-devel libdvdnav-devel libmad-devel
  libmatroska-devel libmodplug-devel libmpcdec-devel libmpeg2-devel

From 9ab535b5197b7d81967e65c608fdd14664438238 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:55 -0400
Subject: [PATCH 010/109] osg: revbump for ffmpeg4

---
 srcpkgs/osg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/osg/template b/srcpkgs/osg/template
index 8ef0efc599a1b1..a131ceaf7a867b 100644
--- a/srcpkgs/osg/template
+++ b/srcpkgs/osg/template
@@ -8,7 +8,7 @@ build_helper="qemu"
 configure_args="-DLIB_POSTFIX="
 hostmakedepends="pkg-config xrandr"
 makedepends="MesaLib-devel gtkglext-devel libcurl-devel giflib-devel librsvg-devel
- jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg-devel xine-lib-devel
+ jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg4-devel xine-lib-devel
  SDL2-devel gst-plugins-base1-devel
  $(vopt_if openexr libopenexr-devel)
  $(vopt_if poppler poppler-glib-devel)

From 86f35d6d10ca5f58936987b645d7f08ebafc75d2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:13 -0400
Subject: [PATCH 011/109] xine-lib: revbump for ffmpeg4

---
 srcpkgs/xine-lib/template | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/xine-lib/template b/srcpkgs/xine-lib/template
index 3be4d08eac77a3..ed6194c17d11e8 100644
--- a/srcpkgs/xine-lib/template
+++ b/srcpkgs/xine-lib/template
@@ -1,14 +1,14 @@
 # Template file for 'xine-lib'
 pkgname=xine-lib
-version=1.2.12
-revision=3
+version=1.2.13
+revision=1
 build_style=gnu-configure
 configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
  --disable-oss"
 hostmakedepends="automake gettext-devel libtool pkg-config perl"
 makedepends="
  zlib-devel alsa-lib-devel libxcb-devel libSM-devel libXext-devel libXv-devel
- libXvMC-devel liba52-devel libmad-devel ffmpeg-devel pulseaudio-devel
+ libXvMC-devel liba52-devel libmad-devel ffmpeg4-devel pulseaudio-devel
  jack-devel samba-devel libflac-devel libmodplug-devel libmpcdec-devel
  speex-devel libtheora-devel libvorbis-devel libdca-devel faad2-devel
  libcdio-devel libbluray-devel aalib-devel libcaca-devel libXinerama-devel
@@ -19,7 +19,7 @@ license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="http://www.xine-project.org"
 changelog="https://sourceforge.net/projects/xine/files/xine-lib/${version}/README.txt/view"
 distfiles="${SOURCEFORGE_SITE}/xine/${pkgname}-${version}.tar.xz"
-checksum=d606270468e1540c2a89c0d7f5fdf11e17ecc0c2698cc0bcb1065ff26abee098
+checksum=5f10d6d718a4a51c17ed1b32b031d4f9b80b061e8276535b2be31e5ac4b75e6f
 
 case "$XBPS_TARGET_MACHINE" in
 	i686-musl)

From b22b928b907833a97ee5572be12d921d51e24f10 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 012/109] attract: revbump for ffmpeg6

---
 srcpkgs/attract/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/attract/template b/srcpkgs/attract/template
index e769fb15456217..776cbe4ebd2c93 100644
--- a/srcpkgs/attract/template
+++ b/srcpkgs/attract/template
@@ -1,7 +1,7 @@
 # Template file for 'attract'
 pkgname=attract
 version=2.7.0
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="VERBOSE=1"
 make_use_env=yes

From d1bbae65b0ca433cfcf2e0b440d0742f85494df4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 013/109] aubio: revbump for ffmpeg6

---
 srcpkgs/aubio/patches/ffmpeg5.patch | 25 +++++++++++++++++++++++++
 srcpkgs/aubio/template              |  2 +-
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/aubio/patches/ffmpeg5.patch

diff --git a/srcpkgs/aubio/patches/ffmpeg5.patch b/srcpkgs/aubio/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..aace41a6e6d9a4
--- /dev/null
+++ b/srcpkgs/aubio/patches/ffmpeg5.patch
@@ -0,0 +1,25 @@
+From 8a05420e5dd8c7b8b2447f82dc919765876511b3 Mon Sep 17 00:00:00 2001
+From: Paul Brossier <piem@piem.org>
+Date: Tue, 25 Jan 2022 18:30:27 +0100
+Subject: [PATCH] [source_avcodec] define FF_API_LAVF_AVCTX for libavcodec >
+ 59, thx @berolinux (closes gh-353)
+
+---
+ src/io/source_avcodec.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/io/source_avcodec.c b/src/io/source_avcodec.c
+index e0ae93b5..1421bd9a 100644
+--- a/src/io/source_avcodec.c
++++ b/src/io/source_avcodec.c
+@@ -68,6 +68,10 @@
+ #define AUBIO_AVCODEC_MAX_BUFFER_SIZE AV_INPUT_BUFFER_MIN_SIZE
+ #endif
+ 
++#if LIBAVCODEC_VERSION_MAJOR >= 59
++#define FF_API_LAVF_AVCTX 1
++#endif
++
+ struct _aubio_source_avcodec_t {
+   uint_t hop_size;
+   uint_t samplerate;
diff --git a/srcpkgs/aubio/template b/srcpkgs/aubio/template
index ad1c4b25699178..7d875cc02541a7 100644
--- a/srcpkgs/aubio/template
+++ b/srcpkgs/aubio/template
@@ -1,7 +1,7 @@
 # Template file for 'aubio'
 pkgname=aubio
 version=0.4.9
-revision=1
+revision=2
 build_style=waf3
 # XXX lash, pure and swig support.
 hostmakedepends="pkg-config txt2man"

From 55327fe9ab6049728d6067c33777c07d554acdb4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 014/109] audacious-plugins: revbump for ffmpeg6

---
 .../audacious-plugins/patches/ffmpeg5.patch   | 43 +++++++++++++++++++
 srcpkgs/audacious-plugins/template            |  2 +-
 2 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/audacious-plugins/patches/ffmpeg5.patch

diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg5.patch b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..4e5e34099d71c4
--- /dev/null
+++ b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
@@ -0,0 +1,43 @@
+commit 298aa371c56c2f52c25a33d9bdec4918b11cebdc
+Author: tibequadorian <tibequadorian@posteo.de>
+Date:   Sat Mar 19 18:40:12 2022 +0100
+
+    audacious-plugins: rebuild against ffmpeg-5.0
+
+diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+new file mode 100644
+index 0000000000..617c11215b
+--- /dev/null
++++ b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+@@ -0,0 +1,31 @@
++From f60beb400eeb1e4778bbfd738bc4a4ccef3de539 Mon Sep 17 00:00:00 2001
++From: John Lindgren <john@jlindgren.net>
++Date: Sat, 5 Mar 2022 12:05:34 -0500
++Subject: [PATCH] Fix build with FFmpeg 5.0
++
++---
++ src/ffaudio/ffaudio-core.cc | 4 ++--
++ 1 file changed, 2 insertions(+), 2 deletions(-)
++
++diff --git a/src/ffaudio/ffaudio-core.cc b/src/ffaudio/ffaudio-core.cc
++index 16dc63e3a..a2b95fd6c 100644
++--- a/src/ffaudio/ffaudio-core.cc
+++++ b/src/ffaudio/ffaudio-core.cc
++@@ -274,7 +274,7 @@ static AVInputFormat * get_format_by_content (const char * name, VFSFile & file)
++         AVProbeData d = {name, buf, filled};
++         score = target;
++ 
++-        f = av_probe_input_format2 (& d, true, & score);
+++        f = (AVInputFormat *) av_probe_input_format2 (& d, true, & score);
++         if (f)
++             break;
++ 
++@@ -347,7 +347,7 @@ static bool find_codec (AVFormatContext * c, CodecInfo * cinfo)
++ #endif
++         if (stream && stream->codecpar && stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
++         {
++-            AVCodec * codec = avcodec_find_decoder (stream->codecpar->codec_id);
+++            AVCodec * codec = (AVCodec *) avcodec_find_decoder (stream->codecpar->codec_id);
++ 
++             if (codec)
++             {
diff --git a/srcpkgs/audacious-plugins/template b/srcpkgs/audacious-plugins/template
index 05e53a9adf78ff..4b1968e03de781 100644
--- a/srcpkgs/audacious-plugins/template
+++ b/srcpkgs/audacious-plugins/template
@@ -2,7 +2,7 @@
 #Keep in sync with audacious!
 pkgname=audacious-plugins
 version=4.3.1
-revision=3
+revision=4
 build_style=meson
 configure_args="$(vopt_bool gtk3 gtk) $(vopt_bool gtk3)
  $(vopt_bool qt) $(vopt_bool qt qt6)"

From 11c026024321b955c0dceddd6c092659e2c76dac Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 015/109] audacity: revbump for ffmpeg6

---
 srcpkgs/audacity/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/audacity/template b/srcpkgs/audacity/template
index 7b838119ab2611..84b49305edcef1 100644
--- a/srcpkgs/audacity/template
+++ b/srcpkgs/audacity/template
@@ -1,7 +1,7 @@
 # Template file for 'audacity'
 pkgname=audacity
 version=3.4.2
-revision=1
+revision=2
 build_style=cmake
 build_helper="cmake-wxWidgets-gtk3 qemu"
 configure_args="-Daudacity_use_ffmpeg=loaded -Daudacity_lib_preference=system

From f6527acbaa078055dc8554b4ed22e8735e67dc2c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 016/109] avidemux: revbump for ffmpeg6

---
 srcpkgs/avidemux/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/avidemux/template b/srcpkgs/avidemux/template
index 253a0243e22599..557285982d2b8f 100644
--- a/srcpkgs/avidemux/template
+++ b/srcpkgs/avidemux/template
@@ -1,7 +1,7 @@
 # Template file for 'avidemux'
 pkgname=avidemux
 version=2.8.0
-revision=2
+revision=3
 # Can't be compiled for aarch64, arm* or mips*
 archs="x86_64* i686*"
 hostmakedepends="cmake pkg-config qt5-host-tools qt5-devel tar yasm"

From b52d6c60e30082ac6cc88035e00f4e2f8f9c0e7c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 017/109] blender: revbump for ffmpeg6

---
 srcpkgs/blender/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index 68787b76a26c18..e2e090e6dfa41c 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -1,7 +1,7 @@
 # Template file for 'blender'
 pkgname=blender
 version=4.0.2
-revision=2
+revision=3
 archs="x86_64* ppc64*"
 build_style="cmake"
 pycompile_dirs="usr/share/blender/${version%.*}/scripts"

From 22cd01ed7439e224931ed184c06f4bf164aaf2a1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 018/109] cantata: revbump for ffmpeg6

---
 srcpkgs/cantata/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cantata/template b/srcpkgs/cantata/template
index 4b417d80d5c2da..8a90aaa4c07a2a 100644
--- a/srcpkgs/cantata/template
+++ b/srcpkgs/cantata/template
@@ -1,7 +1,7 @@
 # Template file for 'cantata'
 pkgname=cantata
 version=2.5.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools qt5-tools"
 makedepends="qt5-devel qt5-tools-devel qt5-svg-devel qt5-xmlpatterns-devel

From 86a5c7f4c9a11d8df972baa397ada65b58fbae49 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 019/109] ccextractor: revbump for ffmpeg6

---
 ...5-and-tesseract-5-compatibility-1479.patch | 168 ++++++++++++++++++
 srcpkgs/ccextractor/template                  |   2 +-
 2 files changed, 169 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ccextractor/patches/0001-fix-ffmpeg-5-and-tesseract-5-compatibility-1479.patch

diff --git a/srcpkgs/ccextractor/patches/0001-fix-ffmpeg-5-and-tesseract-5-compatibility-1479.patch b/srcpkgs/ccextractor/patches/0001-fix-ffmpeg-5-and-tesseract-5-compatibility-1479.patch
new file mode 100644
index 00000000000000..bcab4890554b9a
--- /dev/null
+++ b/srcpkgs/ccextractor/patches/0001-fix-ffmpeg-5-and-tesseract-5-compatibility-1479.patch
@@ -0,0 +1,168 @@
+From b1cbfcea9b9c687143bf0d80bc179b563e99d025 Mon Sep 17 00:00:00 2001
+From: Prateek Sunal <prtksunal@gmail.com>
+Date: Thu, 9 Mar 2023 01:44:53 +0530
+Subject: [PATCH] fix: ffmpeg 5 and tesseract 5 compatibility (#1479)
+
+* fix: replace deprecated `codec` property with `codecpar`
+
+* fix: replace deprecated method `avcodec_decode_video2` with `avcodec_receive_frame` and `avcodec_send_packet`
+
+* Update CHANGES.TXT
+
+* fix: remove deprecated `av_register_all` function
+
+* fix: formatting
+
+* fix: add support for tesseract 5
+
+* fix: tesseract v5
+
+* fix: hardsubx codec context error
+
+* fix: lint const warning
+---
+ docs/CHANGES.TXT               |  1 +
+ src/lib_ccx/ffmpeg_intgr.c     |  7 +++---
+ src/lib_ccx/hardsubx.c         | 25 ++++++++++++------
+ src/lib_ccx/hardsubx_decoder.c | 27 ++++++++------------
+ src/lib_ccx/ocr.c              | 46 ++++++++++++----------------------
+ 5 files changed, 47 insertions(+), 59 deletions(-)
+
+diff --git a/src/lib_ccx/ffmpeg_intgr.c b/src/lib_ccx/ffmpeg_intgr.c
+index be988890..e6f21e20 100644
+--- a/src/lib_ccx/ffmpeg_intgr.c
++++ b/src/lib_ccx/ffmpeg_intgr.c
+@@ -66,7 +66,6 @@ void *init_ffmpeg(const char *path)
+ 	struct ffmpeg_ctx *ctx;
+ 	AVCodec *dec = NULL;
+ 	avcodec_register_all();
+-	av_register_all();
+ 
+ 	if (ccx_options.debug_mask & CCX_DMT_VERBOSE)
+ 		av_log_set_level(AV_LOG_INFO);
+@@ -133,7 +132,6 @@ int ff_get_ccframe(void *arg, unsigned char *data, int maxlen)
+ 	struct ffmpeg_ctx *ctx = arg;
+ 	int len = 0;
+ 	int ret = 0;
+-	int got_frame;
+ 	AVPacket packet;
+ 
+ 	ret = av_read_frame(ctx->ifmt, &packet);
+@@ -151,12 +149,13 @@ int ff_get_ccframe(void *arg, unsigned char *data, int maxlen)
+ 		return AVERROR(EAGAIN);
+ 	}
+ 
+-	ret = avcodec_decode_video2(ctx->dec_ctx, ctx->frame, &got_frame, &packet);
++	avcodec_send_packet(ctx->codec_ctx, &ctx->packet);
++	ret = avcodec_receive_frame(ctx->dec_ctx, ctx->frame);
+ 	if (ret < 0)
+ 	{
+ 		av_log(NULL, AV_LOG_ERROR, "unable to decode packet\n");
+ 	}
+-	else if (!got_frame)
++	else if (ret != 0)
+ 	{
+ 		return AVERROR(EAGAIN);
+ 	}
+diff --git a/src/lib_ccx/hardsubx.c b/src/lib_ccx/hardsubx.c
+index 411377f9..fb844c91 100644
+--- a/src/lib_ccx/hardsubx.c
++++ b/src/lib_ccx/hardsubx.c
+@@ -12,9 +12,6 @@
+
+ int hardsubx_process_data(struct lib_hardsubx_ctx *ctx)
+ {
+-	// Get the required media attributes and initialize structures
+-	av_register_all();
+-
+ 	if (avformat_open_input(&ctx->format_ctx, ctx->inputfile[0], NULL, NULL) != 0)
+ 	{
+ 		fatal(EXIT_READ_ERROR, "Error reading input file!\n");
+@@ -32,7 +29,7 @@
+ 	ctx->video_stream_id = -1;
+ 	for (int i = 0; i < ctx->format_ctx->nb_streams; i++)
+ 	{
+-		if (ctx->format_ctx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO)
++		if (ctx->format_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
+ 		{
+ 			ctx->video_stream_id = i;
+ 			break;
+@@ -43,8 +40,21 @@
+ 		fatal(EXIT_READ_ERROR, "Video Stream not found!\n");
+ 	}
+
+-	ctx->codec_ctx = ctx->format_ctx->streams[ctx->video_stream_id]->codec;
+-	ctx->codec = avcodec_find_decoder(ctx->codec_ctx->codec_id);
++	ctx->codec_ctx = avcodec_alloc_context3(NULL);
++	if (!ctx->codec_ctx)
++	{
++		    fatal(EXIT_NOT_ENOUGH_MEMORY, "Could not allocate codec context!\n");
++	}
++
++	// Assign codec parameters to codec context
++	if (avcodec_parameters_to_context(ctx->codec_ctx, ctx->format_ctx->streams[ctx->video_stream_id]->codecpar) < 0)
++	{
++		    fatal(EXIT_READ_ERROR, "Could not initialize codec context!\n");
++	}
++
++	// Find decoder for the codec context
++	ctx->codec = (AVCodec *)avcodec_find_decoder(ctx->codec_ctx->codec_id);
++
+ 	if (ctx->codec == NULL)
+ 	{
+ 		fatal(EXIT_READ_ERROR, "Input codec is not supported!\n");
+diff --git a/src/lib_ccx/hardsubx_decoder.c b/src/lib_ccx/hardsubx_decoder.c
+index bd9b0980..b5dfaec4 100644
+--- a/src/lib_ccx/hardsubx_decoder.c
++++ b/src/lib_ccx/hardsubx_decoder.c
+@@ -371,7 +371,6 @@
+ int hardsubx_process_frames_tickertext(struct lib_hardsubx_ctx *ctx, struct encoder_ctx *enc_ctx)
+ {
+ 	// Search for ticker text at the bottom of the screen, such as in Russia TV1 or stock prices
+-	int got_frame;
+ 	int cur_sec = 0, total_sec, progress;
+ 	int frame_number = 0;
+ 	char *ticker_text = NULL;
+@@ -382,8 +381,8 @@
+ 		{
+ 			frame_number++;
+ 			//Decode the video stream packet
+-			avcodec_decode_video2(ctx->codec_ctx, ctx->frame, &got_frame, &ctx->packet);
+-			if (got_frame && frame_number % 1000 == 0)
++      avcodec_send_packet(ctx->codec_ctx, &ctx->packet);
++      if (avcodec_receive_frame(ctx->codec_ctx, ctx->frame) == 0 && frame_number % 1000 == 0)
+ 			{
+ 				// sws_scale is used to convert the pixel format to RGB24 from all other cases
+ 				sws_scale(
+@@ -434,9 +433,8 @@
+ 			frame_number++;
+
+ 			//Decode the video stream packet
+-			avcodec_decode_video2(ctx->codec_ctx, ctx->frame, &got_frame, &ctx->packet);
+-
+-			if (got_frame && frame_number % 25 == 0)
++			avcodec_send_packet(ctx->codec_ctx, &ctx->packet);
++      if (avcodec_receive_frame(ctx->codec_ctx, ctx->frame) == 0 && frame_number % 25 == 0)
+ 			{
+ 				float diff = (float)convert_pts_to_ms(ctx->packet.pts - prev_packet_pts, ctx->format_ctx->streams[ctx->video_stream_id]->time_base);
+ 				if (fabsf(diff) < 1000 * ctx->min_sub_duration) //If the minimum duration of a subtitle line is exceeded, process packet
+@@ -548,7 +546,6 @@
+ {
+ 	// Do a binary search over the input video for faster processing
+ 	// printf("Duration: %d\n", (int)ctx->format_ctx->duration);
+-	int got_frame;
+ 	int seconds_time = 0;
+ 	for (seconds_time = 0; seconds_time < 20; seconds_time++)
+ 	{
+@@ -568,8 +565,9 @@
+ 			{
+ 				if (ctx->packet.stream_index == ctx->video_stream_id)
+ 				{
+-					avcodec_decode_video2(ctx->codec_ctx, ctx->frame, &got_frame, &ctx->packet);
+-					if (got_frame)
++          avcodec_send_packet(ctx->codec_ctx, &ctx->packet);
++          if (avcodec_receive_frame(ctx->codec_ctx, ctx->frame) == 0)
++
+ 					{
+ 						// printf("%d\n", seek_time);
+ 						if (ctx->packet.pts < seek_time)
diff --git a/srcpkgs/ccextractor/template b/srcpkgs/ccextractor/template
index 84059ffd02398a..a670758bcbe41b 100644
--- a/srcpkgs/ccextractor/template
+++ b/srcpkgs/ccextractor/template
@@ -1,7 +1,7 @@
 # Template file for 'ccextractor'
 pkgname=ccextractor
 version=0.93
-revision=2
+revision=3
 build_wrksrc="linux"
 build_style=gnu-configure
 configure_args="--enable-ocr --enable-hardsubx"

From e97420ae202fa0c2203efc3c918c3a2a19ddb0b2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 020/109] chromaprint: revbump for ffmpeg6

---
 srcpkgs/chromaprint/patches/ffmpeg5.patch | 569 ++++++++++++++++++++++
 srcpkgs/chromaprint/template              |   2 +-
 2 files changed, 570 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromaprint/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromaprint/patches/ffmpeg5.patch b/srcpkgs/chromaprint/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..a9fd307a23c8a4
--- /dev/null
+++ b/srcpkgs/chromaprint/patches/ffmpeg5.patch
@@ -0,0 +1,569 @@
+From 8ccad6937177b1b92e40ab8f4447ea27bac009a7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= <lalinsky@gmail.com>
+Date: Fri, 4 Nov 2022 21:47:38 +0100
+Subject: [PATCH] Use FFmpeg 5.x (#120)
+
+* Use FFmpeg 5.1.2 for CI builds
+
+* Build on Ubuntu 20.04
+
+* Upgrade code to FFmpeg 5.x APIs
+
+* Only set FFmpeg include dirs if building tools
+
+* No longer needed
+
+* Use ubuntu 20.04
+---
+ .github/workflows/build.yml                   |   6 +-
+ CMakeLists.txt                                |  16 --
+ package/build.sh                              |   4 +-
+ src/audio/ffmpeg_audio_processor.h            |   2 -
+ src/audio/ffmpeg_audio_processor_avresample.h |  72 -------
+ src/audio/ffmpeg_audio_processor_swresample.h |  18 +-
+ src/audio/ffmpeg_audio_reader.h               | 197 +++++++++---------
+ tests/CMakeLists.txt                          |   6 +
+ 8 files changed, 122 insertions(+), 199 deletions(-)
+ delete mode 100644 src/audio/ffmpeg_audio_processor_avresample.h
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index f8d6a32..4da2405 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -84,9 +84,6 @@ find_package(FFmpeg)
+ if(FFMPEG_LIBRARIES)
+ 	cmake_push_check_state(RESET)
+ 	set(CMAKE_REQUIRED_LIBRARIES ${FFMPEG_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -lm)
+-	check_function_exists(av_packet_unref HAVE_AV_PACKET_UNREF)
+-	check_function_exists(av_frame_alloc HAVE_AV_FRAME_ALLOC)
+-	check_function_exists(av_frame_free HAVE_AV_FRAME_FREE)
+ 	cmake_pop_check_state()
+ endif()
+
+@@ -163,14 +160,11 @@ message(STATUS "Using ${FFT_LIB} for FFT calculations")
+ if(NOT AUDIO_PROCESSOR_LIB)
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+ 		set(AUDIO_PROCESSOR_LIB "swresample")
+-	elseif(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(AUDIO_PROCESSOR_LIB "avresample")
+ 	endif()
+ endif()
+
+ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE OFF)
+ 		set(USE_SWRESAMPLE ON)
+ 		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBSWRESAMPLE_LIBRARIES})
+ 		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBSWRESAMPLE_INCLUDE_DIRS})
+@@ -178,16 +172,6 @@ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+ 	endif()
+ 	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+-elseif(AUDIO_PROCESSOR_LIB STREQUAL "avresample")
+-	if(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE ON)
+-		set(USE_SWRESAMPLE OFF)
+-		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBAVRESAMPLE_LIBRARIES})
+-		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBAVRESAMPLE_INCLUDE_DIRS})
+-	else()
+-		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+-	endif()
+-	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+ else()
+ 	message(STATUS "Building without audio conversion support, please install FFmpeg with libswresample")
+ endif()
+diff --git a/package/build.sh b/package/build.sh
+index da631ae..b41d36e 100755
+--- a/package/build.sh
++++ b/package/build.sh
+@@ -7,8 +7,8 @@ set -eux
+
+ BASE_DIR=$(cd $(dirname $0)/.. && pwd)
+
+-FFMPEG_VERSION=4.4.1
+-FFMPEG_BUILD_TAG=v4.4.1-1
++FFMPEG_VERSION=5.1.2
++FFMPEG_BUILD_TAG=v${FFMPEG_VERSION}-1
+
+ TMP_BUILD_DIR=$BASE_DIR/$(mktemp -d build.XXXXXXXX)
+ trap 'rm -rf $TMP_BUILD_DIR' EXIT
+diff --git a/src/audio/ffmpeg_audio_processor.h b/src/audio/ffmpeg_audio_processor.h
+index 7628fc7..39f4f6d 100644
+--- a/src/audio/ffmpeg_audio_processor.h
++++ b/src/audio/ffmpeg_audio_processor.h
+@@ -10,8 +10,6 @@
+
+ #if defined(USE_SWRESAMPLE)
+ #include "audio/ffmpeg_audio_processor_swresample.h"
+-#elif defined(USE_AVRESAMPLE)
+-#include "audio/ffmpeg_audio_processor_avresample.h"
+ #else
+ #error "no audio processing library"
+ #endif
+diff --git a/src/audio/ffmpeg_audio_processor_avresample.h b/src/audio/ffmpeg_audio_processor_avresample.h
+deleted file mode 100644
+index bd85f92..0000000
+--- a/src/audio/ffmpeg_audio_processor_avresample.h
++++ /dev/null
+@@ -1,72 +0,0 @@
+-// Copyright (C) 2016  Lukas Lalinsky
+-// Distributed under the MIT license, see the LICENSE file for details.
+-
+-#ifndef CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-#define CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-
+-extern "C" {
+-#include <libavresample/avresample.h>
+-}
+-
+-namespace chromaprint {
+-
+-class FFmpegAudioProcessor {
+-public:
+-	FFmpegAudioProcessor() {
+-		m_resample_ctx = avresample_alloc_context();
+-	}
+-
+-	~FFmpegAudioProcessor() {
+-		avresample_free(&m_resample_ctx);
+-	}
+-
+-	void SetCompatibleMode() {
+-		av_opt_set_int(m_resample_ctx, "filter_size", 16, 0);
+-		av_opt_set_int(m_resample_ctx, "phase_shift", 8, 0);
+-		av_opt_set_int(m_resample_ctx, "linear_interp", 1, 0);
+-		av_opt_set_double(m_resample_ctx, "cutoff", 0.8, 0);
+-	}
+-
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "in_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_rate", sample_rate, 0);
+-	}
+-
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "out_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_rate, 0);
+-	}
+-
+-	int Init() {
+-		return avresample_open(m_resample_ctx);
+-	}
+-
+-	int Convert(uint8_t **out, int out_count, const uint8_t **in, int in_count) {
+-		return avresample_convert(m_resample_ctx, out, 0, out_count, (uint8_t **) in, 0, in_count);
+-	}
+-
+-	int Flush(uint8_t **out, int out_count) {
+-		return avresample_read(m_resample_ctx, out, out_count);
+-	}
+-
+-private:
+-	AVAudioResampleContext *m_resample_ctx = nullptr;
+-};
+-
+-}; // namespace chromaprint
+-
+-#endif
+diff --git a/src/audio/ffmpeg_audio_processor_swresample.h b/src/audio/ffmpeg_audio_processor_swresample.h
+index b86266b..b1d4bea 100644
+--- a/src/audio/ffmpeg_audio_processor_swresample.h
++++ b/src/audio/ffmpeg_audio_processor_swresample.h
+@@ -28,30 +28,28 @@ public:
+ 		av_opt_set_double(m_swr_ctx, "cutoff", 0.8, 0);
+ 	}
+
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "icl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "ich", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetInputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "in_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "isf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "in_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "isr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "in_sample_rate", sample_rate, 0);
+ 	}
+
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "ocl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "och", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetOutputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "out_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "osf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "out_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "osr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "out_sample_rate", sample_rate, 0);
+ 	}
+
+ 	int Init() {
+diff --git a/src/audio/ffmpeg_audio_reader.h b/src/audio/ffmpeg_audio_reader.h
+index 5550164..1c6b346 100644
+--- a/src/audio/ffmpeg_audio_reader.h
++++ b/src/audio/ffmpeg_audio_reader.h
+@@ -62,7 +62,7 @@ public:
+ 	bool Read(const int16_t **data, size_t *size);
+
+ 	bool IsOpen() const { return m_opened; }
+-	bool IsFinished() const { return m_finished && !m_got_frame; }
++	bool IsFinished() const { return !m_has_more_packets && !m_has_more_frames; }
+
+ 	std::string GetError() const { return m_error; }
+ 	int GetErrorCode() const { return m_error_code; }
+@@ -74,20 +74,19 @@ private:
+ 	uint8_t *m_convert_buffer[1] = { nullptr };
+ 	int m_convert_buffer_nb_samples = 0;
+
+-	AVInputFormat *m_input_fmt = nullptr;
++	const AVInputFormat *m_input_fmt = nullptr;
+ 	AVDictionary *m_input_opts = nullptr;
+
+ 	AVFormatContext *m_format_ctx = nullptr;
+ 	AVCodecContext *m_codec_ctx = nullptr;
+-	AVFrame *m_frame = nullptr;
+ 	int m_stream_index = -1;
+ 	std::string m_error;
+ 	int m_error_code = 0;
+-	bool m_finished = false;
+ 	bool m_opened = false;
+-	int m_got_frame = 0;
+-	AVPacket m_packet;
+-	AVPacket m_packet0;
++	bool m_has_more_packets = true;
++	bool m_has_more_frames = true;
++	AVPacket *m_packet = nullptr;
++	AVFrame *m_frame = nullptr;
+
+ 	int m_output_sample_rate = 0;
+ 	int m_output_channels = 0;
+@@ -98,19 +97,12 @@ private:
+
+ inline FFmpegAudioReader::FFmpegAudioReader() {
+ 	av_log_set_level(AV_LOG_QUIET);
+-
+-	av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
+ }
+
+ inline FFmpegAudioReader::~FFmpegAudioReader() {
+ 	Close();
+ 	av_dict_free(&m_input_opts);
+ 	av_freep(&m_convert_buffer[0]);
+-	av_packet_unref(&m_packet0);
+ }
+
+ inline bool FFmpegAudioReader::SetInputFormat(const char *name) {
+@@ -135,11 +127,10 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ 	Close();
+
+-    av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
++	m_packet = av_packet_alloc();
++	if (!m_packet) {
++		return false;
++	}
+
+ 	ret = avformat_open_input(&m_format_ctx, file_name.c_str(), m_input_fmt, &m_input_opts);
+ 	if (ret < 0) {
+@@ -153,26 +144,31 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		return false;
+ 	}
+
+-	AVCodec *codec;
++	const AVCodec *codec;
+ 	ret = av_find_best_stream(m_format_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &codec, 0);
+ 	if (ret < 0) {
+ 		SetError("Could not find any audio stream in the file", ret);
+ 		return false;
+ 	}
+ 	m_stream_index = ret;
++	auto stream = m_format_ctx->streams[m_stream_index];
+
+-	m_codec_ctx = m_format_ctx->streams[m_stream_index]->codec;
++	m_codec_ctx = avcodec_alloc_context3(codec);
+ 	m_codec_ctx->request_sample_fmt = AV_SAMPLE_FMT_S16;
+
++	ret = avcodec_parameters_to_context(m_codec_ctx, stream->codecpar);
++	if (ret < 0) {
++		SetError("Could not copy the stream parameters", ret);
++		return false;
++	}
++
+ 	ret = avcodec_open2(m_codec_ctx, codec, nullptr);
+ 	if (ret < 0) {
+ 		SetError("Could not open the codec", ret);
+ 		return false;
+ 	}
+
+-	if (!m_codec_ctx->channel_layout) {
+-		m_codec_ctx->channel_layout = av_get_default_channel_layout(m_codec_ctx->channels);
+-	}
++	av_dump_format(m_format_ctx, 0, "foo", 0);
+
+ 	m_frame = av_frame_alloc();
+ 	if (!m_frame) {
+@@ -183,19 +179,23 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		m_output_sample_rate = m_codec_ctx->sample_rate;
+ 	}
+
+-	if (!m_output_channels) {
+-		m_output_channels = m_codec_ctx->channels;
++	AVChannelLayout output_channel_layout;
++	if (m_output_channels) {
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
++	} else {
++		m_output_channels = m_codec_ctx->ch_layout.nb_channels;
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
+ 	}
+
+-	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
++	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->ch_layout.nb_channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
+ 		m_converter.reset(new FFmpegAudioProcessor());
+ 		m_converter->SetCompatibleMode();
+ 		m_converter->SetInputSampleFormat(m_codec_ctx->sample_fmt);
+ 		m_converter->SetInputSampleRate(m_codec_ctx->sample_rate);
+-		m_converter->SetInputChannelLayout(m_codec_ctx->channel_layout);
++		m_converter->SetInputChannelLayout(&(m_codec_ctx->ch_layout));
+ 		m_converter->SetOutputSampleFormat(AV_SAMPLE_FMT_S16);
+ 		m_converter->SetOutputSampleRate(m_output_sample_rate);
+-		m_converter->SetOutputChannelLayout(av_get_default_channel_layout(m_output_channels));
++		m_converter->SetOutputChannelLayout(&output_channel_layout);
+ 		auto ret = m_converter->Init();
+ 		if (ret != 0) {
+ 			SetError("Could not create an audio converter instance", ret);
+@@ -203,10 +203,11 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		}
+ 	}
+
++	av_channel_layout_uninit(&output_channel_layout);
++
+ 	m_opened = true;
+-	m_finished = false;
+-	m_got_frame = 0;
+-	m_nb_packets = 0;
++	m_has_more_packets = true;
++	m_has_more_frames = true;
+ 	m_decode_error = 0;
+
+ 	return true;
+@@ -214,6 +215,7 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ inline void FFmpegAudioReader::Close() {
+ 	av_frame_free(&m_frame);
++	av_packet_free(&m_packet);
+
+ 	m_stream_index = -1;
+
+@@ -252,91 +254,98 @@ inline bool FFmpegAudioReader::Read(const int16_t **data, size_t *size) {
+ 		return false;
+ 	}
+
++	*data = nullptr;
++	*size = 0;
++
+ 	int ret;
++	bool needs_packet = false;
+ 	while (true) {
+-		while (m_packet.size <= 0) {
+-			av_packet_unref(&m_packet0);
+-			av_init_packet(&m_packet);
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			ret = av_read_frame(m_format_ctx, &m_packet);
++		while (needs_packet && m_packet->size == 0) {
++			ret = av_read_frame(m_format_ctx, m_packet);
+ 			if (ret < 0) {
+ 				if (ret == AVERROR_EOF) {
+-					m_finished = true;
++					needs_packet = false;
++					m_has_more_packets = false;
+ 					break;
+-				} else {
++				}
++				SetError("Error reading from the audio source", ret);
++				return false;
++			}
++			if (m_packet->stream_index == m_stream_index) {
++				needs_packet = false;
++			} else {
++				av_packet_unref(m_packet);
++			}
++		}
++
++		if (m_packet->size != 0) {
++			ret = avcodec_send_packet(m_codec_ctx, m_packet);
++			if (ret < 0) {
++				if (ret != AVERROR(EAGAIN)) {
+ 					SetError("Error reading from the audio source", ret);
+ 					return false;
+ 				}
+-			}
+-			m_packet0 = m_packet;
+-			if (m_packet.stream_index != m_stream_index) {
+-				m_packet.data = nullptr;
+-				m_packet.size = 0;
+ 			} else {
+-				m_nb_packets++;
++				av_packet_unref(m_packet);
+ 			}
+ 		}
+
+-		ret = avcodec_decode_audio4(m_codec_ctx, m_frame, &m_got_frame, &m_packet);
++		ret = avcodec_receive_frame(m_codec_ctx, m_frame);
+ 		if (ret < 0) {
+-			if (m_decode_error) {
+-				SetError("Error decoding audio frame", m_decode_error);
+-				return false;
++			if (ret == AVERROR_EOF) {
++				m_has_more_frames = false;
++			} else if (ret == AVERROR(EAGAIN)) {
++				if (m_has_more_packets) {
++					needs_packet = true;
++					continue;
++				} else {
++					m_has_more_frames = false;
++				}
+ 			}
+-			m_decode_error = ret;
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			continue;
++			SetError("Error decoding the audio source", ret);
++			return false;
+ 		}
+
+-		break;
+-	}
+-
+-	m_decode_error = 0;
+-
+-	const int decoded = std::min(ret, m_packet.size);
+-	m_packet.data += decoded;
+-	m_packet.size -= decoded;
+-
+-	if (m_got_frame) {
+-		if (m_converter) {
+-			if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
+-				int linsize;
+-				av_freep(&m_convert_buffer[0]);
+-				m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
+-				ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
+-				if (ret < 0) {
+-					SetError("Couldn't allocate audio converter buffer", ret);
++		if (m_frame->nb_samples > 0) {
++			if (m_converter) {
++				if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
++					int linsize;
++					av_freep(&m_convert_buffer[0]);
++					m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
++					ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->ch_layout.nb_channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
++					if (ret < 0) {
++						SetError("Couldn't allocate audio converter buffer", ret);
++						return false;
++					}
++				}
++				auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
++				if (nb_samples < 0) {
++					SetError("Couldn't convert audio", ret);
+ 					return false;
+ 				}
+-			}
+-			auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			}
+-			*data = (const int16_t *) m_convert_buffer[0];
+-			*size = nb_samples;
+-		} else {
+-			*data = (const int16_t *) m_frame->data[0];
+-			*size = m_frame->nb_samples;
+-		}
+-	} else {
+-		if (m_finished && m_converter) {
+-			auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			} else if (nb_samples > 0) {
+-				m_got_frame = 1;
+ 				*data = (const int16_t *) m_convert_buffer[0];
+ 				*size = nb_samples;
++			} else {
++				*data = (const int16_t *) m_frame->data[0];
++				*size = m_frame->nb_samples;
++			}
++		} else {
++			if (m_converter) {
++				if (IsFinished()) {
++					auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
++					if (nb_samples < 0) {
++						SetError("Couldn't convert audio", ret);
++						return false;
++					} else if (nb_samples > 0) {
++						*data = (const int16_t *) m_convert_buffer[0];
++						*size = nb_samples;
++					}
++				}
+ 			}
+ 		}
+-	}
+
+-	return true;
++		return true;
++	}
+ }
+
+ inline void FFmpegAudioReader::SetError(const char *message, int errnum) {
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index a2b517b..123e643 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -38,6 +38,12 @@ set(SRCS
+
+ if(BUILD_TOOLS)
+ 	set(SRCS ${SRCS} ../src/audio/ffmpeg_audio_reader_test.cpp)
++    include_directories(
++        ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}
++        ${AUDIO_PROCESSOR_INCLUDE_DIRS}
++    )
+ 	link_libraries(fpcalc_libs)
+ endif()
+
+-- 
+2.38.1
+
+
diff --git a/srcpkgs/chromaprint/template b/srcpkgs/chromaprint/template
index 7ef7838949f3a3..1f7bbc70a22c80 100644
--- a/srcpkgs/chromaprint/template
+++ b/srcpkgs/chromaprint/template
@@ -1,7 +1,7 @@
 # Template file for 'chromaprint'
 pkgname=chromaprint
 version=1.5.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DBUILD_TOOLS=ON"
 make_check_target="check"

From 9a6bf77d706d70f8b890b4633e89b16812d3599a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 021/109] chromium: revbump for ffmpeg6

---
 srcpkgs/chromium/patches/ffmpeg5.patch | 47 ++++++++++++++++++++++++++
 srcpkgs/chromium/template              |  2 +-
 2 files changed, 48 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..24e2da38e34ca2
--- /dev/null
+++ b/srcpkgs/chromium/patches/ffmpeg5.patch
@@ -0,0 +1,47 @@
+--- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
++++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
+@@ -92,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+-  if (stream->start_time != kNoFFmpegTimestamp)
++  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -1597,7 +1585,7 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+@@ -1618,7 +1606,7 @@
+     if (stream->type() != DemuxerStream::VIDEO)
+       continue;
+ 
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+ 
+     if (!stream->IsEnabled())
diff --git a/srcpkgs/chromium/template b/srcpkgs/chromium/template
index 53981f7cd367f8..b462de56fe3bf5 100644
--- a/srcpkgs/chromium/template
+++ b/srcpkgs/chromium/template
@@ -2,7 +2,7 @@
 pkgname=chromium
 # See https://chromiumdash.appspot.com/releases?platform=Linux for the latest version
 version=122.0.6261.94
-revision=1
+revision=2
 archs="i686* x86_64* aarch64* armv7l*"
 hostmakedepends="
  $(vopt_if clang "clang17 lld17 llvm17 compiler-rt")

From 0ce282418f9f8fb893e6a2064992809c01bbe08f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 022/109] cmus: revbump for ffmpeg6

---
 srcpkgs/chromium/patches/ffmpeg5.patch | 47 --------------------------
 srcpkgs/cmus/patches/ffmpeg6.patch     | 12 +++++++
 srcpkgs/cmus/template                  |  2 +-
 3 files changed, 13 insertions(+), 48 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch
 create mode 100644 srcpkgs/cmus/patches/ffmpeg6.patch

diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
deleted file mode 100644
index 24e2da38e34ca2..00000000000000
--- a/srcpkgs/chromium/patches/ffmpeg5.patch
+++ /dev/null
@@ -1,47 +0,0 @@
---- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
-+++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
-@@ -92,24 +92,12 @@
- 
- static base::TimeDelta ExtractStartTime(AVStream* stream) {
-   // The default start time is zero.
--  base::TimeDelta start_time;
-+  base::TimeDelta start_time = kNoTimestamp;
- 
-   // First try to use  the |start_time| value as is.
--  if (stream->start_time != kNoFFmpegTimestamp)
-+  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
-     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
- 
--  // Next try to use the first DTS value, for codecs where we know PTS == DTS
--  // (excludes all H26x codecs). The start time must be returned in PTS.
--  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
--      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
--      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
--      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
--    const base::TimeDelta first_pts =
--        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
--    if (first_pts < start_time)
--      start_time = first_pts;
--  }
--
-   return start_time;
- }
- 
-@@ -1597,7 +1585,7 @@
-   for (const auto& stream : streams_) {
-     if (!stream || stream->IsEnabled() != enabled)
-       continue;
--    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
-+    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
-       continue;
-     if (!lowest_start_time_stream ||
-         stream->start_time() < lowest_start_time_stream->start_time()) {
-@@ -1618,7 +1606,7 @@
-     if (stream->type() != DemuxerStream::VIDEO)
-       continue;
- 
--    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
-+    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
-       continue;
- 
-     if (!stream->IsEnabled())
diff --git a/srcpkgs/cmus/patches/ffmpeg6.patch b/srcpkgs/cmus/patches/ffmpeg6.patch
new file mode 100644
index 00000000000000..ffa95ab811101b
--- /dev/null
+++ b/srcpkgs/cmus/patches/ffmpeg6.patch
@@ -0,0 +1,12 @@
+--- a/ip/ffmpeg.c
++++ b/ip/ffmpeg.c
+@@ -202,9 +202,6 @@ static int ffmpeg_open(struct input_plugin_data *ip_data)
+ 			break;
+ 		}
+ 
+-		if (codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+-			cc->flags |= AV_CODEC_FLAG_TRUNCATED;
+-
+ 		if (avcodec_open2(cc, codec, NULL) < 0) {
+ 			d_print("could not open codec: %d, %s\n", cc->codec_id, avcodec_get_name(cc->codec_id));
+ 			err = -IP_ERROR_UNSUPPORTED_FILE_TYPE;
diff --git a/srcpkgs/cmus/template b/srcpkgs/cmus/template
index 0d1436744f1b2c..a6e4b4fa86cb83 100644
--- a/srcpkgs/cmus/template
+++ b/srcpkgs/cmus/template
@@ -1,7 +1,7 @@
 # Template file for 'cmus'
 pkgname=cmus
 version=2.10.0
-revision=3
+revision=4
 build_style=configure
 configure_args="prefix=/usr LD=$CC"
 hostmakedepends="pkg-config"

From 2b598e6fb5eaaa4e2778adc2598f03e220cee98f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 023/109] cyanrip: revbump for ffmpeg6

---
 srcpkgs/cyanrip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cyanrip/template b/srcpkgs/cyanrip/template
index 9796e3461601a7..5db30e020d17ee 100644
--- a/srcpkgs/cyanrip/template
+++ b/srcpkgs/cyanrip/template
@@ -1,7 +1,7 @@
 # Template file for 'cyanrip'
 pkgname=cyanrip
 version=0.9.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config"
 makedepends="ffmpeg-devel libcdio-devel libcdio-paranoia-devel libcurl-devel libmusicbrainz5-devel"

From 7b6ba71e124e220cc6046ffe32848eee8ad8e301 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 024/109] deadbeef: revbump for ffmpeg4

---
 srcpkgs/deadbeef/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/deadbeef/template b/srcpkgs/deadbeef/template
index f5f4bf24b8cb6d..7b47e615cd48ef 100644
--- a/srcpkgs/deadbeef/template
+++ b/srcpkgs/deadbeef/template
@@ -1,14 +1,14 @@
 # Template file for 'deadbeef'
 pkgname=deadbeef
 version=1.8.8
-revision=3
+revision=4
 create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-oss --disable-lfm --disable-notify --disable-gtk2"
 hostmakedepends="automake libtool gettext gettext-devel intltool pkg-config
  yasm clang glib-devel"
 makedepends="
- alsa-lib-devel dbus-devel faad2-devel ffmpeg-devel gtk+3-devel imlib2-devel
+ alsa-lib-devel dbus-devel faad2-devel ffmpeg4-devel gtk+3-devel imlib2-devel
  jansson-devel libcddb-devel libcdio-devel libcurl-devel libflac-devel
  libmad-devel libpng-devel libsamplerate-devel libsndfile-devel libvorbis-devel
  libzip-devel mpg123-devel opusfile-devel pulseaudio-devel wavpack-devel"

From 3d2491f12113c63a448aacb3f344dd1a68f53d96 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 025/109] droidcam-obs-plugin: revbump for ffmpeg6

---
 srcpkgs/droidcam-obs-plugin/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam-obs-plugin/template b/srcpkgs/droidcam-obs-plugin/template
index fc9c9bf6b9d54c..fb0480754df4de 100644
--- a/srcpkgs/droidcam-obs-plugin/template
+++ b/srcpkgs/droidcam-obs-plugin/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam-obs-plugin'
 pkgname=droidcam-obs-plugin
 version=2.0.1
-revision=1
+revision=2
 build_style=gnu-makefile
 make_use_env=yes
 make_build_args="ALLOW_STATIC=no"

From 6caf1692ef25a9bf8358eaae27c1349d36b5488f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 026/109] droidcam: revbump for ffmpeg6

---
 srcpkgs/droidcam/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam/template b/srcpkgs/droidcam/template
index 1c3f1b8b1fc676..32a9220b79a4d1 100644
--- a/srcpkgs/droidcam/template
+++ b/srcpkgs/droidcam/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam'
 pkgname=droidcam
 version=1.8.2
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="USBMUXD=-lusbmuxd-2.0 JPEG=-lturbojpeg"
 hostmakedepends="pkg-config"

From 8632a15594dea817989784c6dc567c54adbeddb9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 027/109] ffmpegthumbnailer: revbump for ffmpeg6

---
 .../ffmpegthumbnailer/patches/ffmpeg6.patch   | 202 ++++++++++++++++++
 srcpkgs/ffmpegthumbnailer/template            |   6 +-
 2 files changed, 205 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch

diff --git a/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
new file mode 100644
index 00000000000000..363ff35a28419d
--- /dev/null
+++ b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
@@ -0,0 +1,202 @@
+--- a/libffmpegthumbnailer/moviedecoder.cpp	2017-11-21 14:06:57.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.cpp	2023-05-05 13:14:47.946560668 -0400
+@@ -41,11 +41,6 @@
+ namespace ffmpegthumbnailer
+ {
+ 
+-struct SilenceLogLevel
+-{
+-    SilenceLogLevel() { av_log_set_level(AV_LOG_QUIET); }
+-};
+-
+ MovieDecoder::MovieDecoder(AVFormatContext* pavContext)
+ : m_VideoStream(-1)
+ , m_pFormatContext(pavContext)
+@@ -70,8 +65,6 @@
+ 
+ void MovieDecoder::initialize(const string& filename, bool preferEmbeddedMetadata)
+ {
+-    av_register_all();
+-    avcodec_register_all();
+     avformat_network_init();
+ 
+     string inputFile = filename == "-" ? "pipe:" : filename;
+@@ -97,8 +90,7 @@
+ {
+     if (m_pVideoCodecContext)
+     {
+-        avcodec_close(m_pVideoCodecContext);
+-        m_pVideoCodecContext = nullptr;
++        avcodec_free_context(&m_pVideoCodecContext);
+     }
+ 
+     if ((!m_FormatContextWasGiven) && m_pFormatContext)
+@@ -152,10 +144,10 @@
+     for (unsigned int i = 0; i < m_pFormatContext->nb_streams; ++i)
+     {
+         AVStream *stream = m_pFormatContext->streams[i];
+-        auto ctx = m_pFormatContext->streams[i]->codec;
+-        if (ctx->codec_type == AVMEDIA_TYPE_VIDEO)
++        auto par = m_pFormatContext->streams[i]->codecpar;
++        if (par->codec_type == AVMEDIA_TYPE_VIDEO)
+         {
+-            if (!preferEmbeddedMetadata || !isStillImageCodec(ctx->codec_id))
++            if (!preferEmbeddedMetadata || !isStillImageCodec(par->codec_id))
+             {
+                 videoStreams.push_back(i);
+                 continue;
+@@ -203,8 +195,7 @@
+     }
+ 
+     m_pVideoStream = m_pFormatContext->streams[m_VideoStream];
+-    m_pVideoCodecContext = m_pVideoStream->codec;
+-    m_pVideoCodec = avcodec_find_decoder(m_pVideoCodecContext->codec_id);
++    m_pVideoCodec = avcodec_find_decoder(m_pVideoStream->codecpar->codec_id);
+ 
+     if (m_pVideoCodec == nullptr)
+     {
+@@ -214,6 +205,20 @@
+         throw logic_error("Video Codec not found");
+     }
+ 
++    m_pVideoCodecContext = avcodec_alloc_context3(m_pVideoCodec);
++
++    if (m_pVideoCodecContext == nullptr)
++    {
++        destroy();
++        throw logic_error("Could not allocate video codec context");
++    }
++
++    if (avcodec_parameters_to_context(m_pVideoCodecContext, m_pVideoStream->codecpar) < 0)
++    {
++        destroy();
++        throw logic_error("Could not configure video codec context");
++    }
++
+     m_pVideoCodecContext->workaround_bugs = 1;
+ 
+     if (avcodec_open2(m_pVideoCodecContext, m_pVideoCodec, nullptr) < 0)
+@@ -386,13 +391,6 @@
+ 
+ void MovieDecoder::initializeFilterGraph(const AVRational& timeBase, const std::string& size, bool maintainAspectRatio)
+ {
+-    static const AVPixelFormat pixelFormats[] = { AV_PIX_FMT_RGB24, AV_PIX_FMT_NONE };
+-
+-    auto del = [] (AVBufferSinkParams* p) { av_freep(p); };
+-    std::unique_ptr<AVBufferSinkParams, decltype(del)> buffersinkParams(av_buffersink_params_alloc(), del);
+-
+-    avfilter_register_all();
+-
+     m_pFilterGraph = avfilter_graph_alloc();
+     assert(m_pFilterGraph);
+ 
+@@ -404,10 +402,8 @@
+ 
+     checkRc(avfilter_graph_create_filter(&m_pFilterSource, avfilter_get_by_name("buffer"), "thumb_buffer", ss.str().c_str(), nullptr, m_pFilterGraph),
+             "Failed to create filter source");
+-    buffersinkParams->pixel_fmts = pixelFormats;
+-    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, buffersinkParams.get(), m_pFilterGraph),
++    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, nullptr, m_pFilterGraph),
+             "Failed to create filter sink");
+-    buffersinkParams.release();
+ 
+     AVFilterContext* yadifFilter = nullptr;
+     if (m_pFrame->interlaced_frame != 0)
+@@ -500,15 +496,15 @@
+     }
+ 
+     checkRc(av_seek_frame(m_pFormatContext, -1, timestamp, 0), "Seeking in video failed");
+-    avcodec_flush_buffers(m_pFormatContext->streams[m_VideoStream]->codec);
++    avcodec_flush_buffers(m_pVideoCodecContext);
+ 
+     int keyFrameAttempts = 0;
+-    bool gotFrame = 0;
++    bool gotFrame;
+ 
+     do
+     {
+         int count = 0;
+-        gotFrame = 0;
++        gotFrame = false;
+ 
+         while (!gotFrame && count < 20)
+         {
+@@ -552,17 +548,33 @@
+         return false;
+     }
+ 
+-    av_frame_unref(m_pFrame);
+-
+-    int frameFinished;
++    int rc = avcodec_send_packet(m_pVideoCodecContext, m_pPacket);
++    if(rc == AVERROR(EAGAIN))
++    {
++        rc = 0;
++    }
+ 
+-    int bytesDecoded = avcodec_decode_video2(m_pVideoCodecContext, m_pFrame, &frameFinished, m_pPacket);
+-    if (bytesDecoded < 0)
++    if(rc == AVERROR_EOF)
++    {
++        return false;
++    }
++    else if(rc < 0)
+     {
+-        throw logic_error("Failed to decode video frame: bytesDecoded < 0");
++        throw logic_error("Failed to decode video frame: avcodec_send_packet() < 0");
+     }
+ 
+-    return frameFinished > 0;
++    rc = avcodec_receive_frame(m_pVideoCodecContext, m_pFrame);
++    switch(rc)
++    {
++        case 0:
++            return true;
++
++        case AVERROR(EAGAIN):
++            return false;
++
++        default:
++            throw logic_error("Failed to decode video frame: avcodec_receive_frame() < 0");
++    }
+ }
+ 
+ bool MovieDecoder::getVideoPacket()
+@@ -570,8 +582,6 @@
+     bool framesAvailable = true;
+     bool frameDecoded = false;
+ 
+-    int attempts = 0;
+-
+     if (m_pPacket)
+     {
+         av_packet_unref(m_pPacket);
+@@ -580,6 +590,7 @@
+ 
+     m_pPacket = new AVPacket();
+ 
++
+     while (framesAvailable && !frameDecoded)
+     {
+         framesAvailable = av_read_frame(m_pFormatContext, m_pPacket) >= 0;
+@@ -644,7 +655,7 @@
+ 
+ int32_t MovieDecoder::getStreamRotation()
+ {
+-    int32_t* matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
++    auto matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
+     if (matrix)
+     {
+         auto angle = lround(av_display_rotation_get(matrix));
+
+--- a/libffmpegthumbnailer/moviedecoder.h	2017-11-12 04:23:38.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.h	2023-05-05 13:26:07.095529911 -0400
+@@ -78,7 +78,7 @@
+     int                     m_VideoStream;
+     AVFormatContext*        m_pFormatContext;
+     AVCodecContext*         m_pVideoCodecContext;
+-    AVCodec*                m_pVideoCodec;
++    const AVCodec*          m_pVideoCodec;
+     AVFilterGraph*          m_pFilterGraph;
+     AVFilterContext*        m_pFilterSource;
+     AVFilterContext*        m_pFilterSink;
diff --git a/srcpkgs/ffmpegthumbnailer/template b/srcpkgs/ffmpegthumbnailer/template
index 039eea7622b391..35d546018d12af 100644
--- a/srcpkgs/ffmpegthumbnailer/template
+++ b/srcpkgs/ffmpegthumbnailer/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbnailer'
 pkgname=ffmpegthumbnailer
 version=2.2.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libpng-devel libjpeg-turbo-devel ffmpeg-devel"
@@ -9,8 +9,8 @@ depends="ffmpeg"
 short_desc="Lightweight video thumbnailer"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
-homepage="https://github.com/dirkvdb/${pkgname}"
-distfiles="${homepage}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
+homepage="https://github.com/dirkvdb"
+distfiles="${homepage}/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
 checksum=1cb24059c38223f657b300c84dd80491b7040d4b69471c4fea69be862bc99b5b
 
 post_install() {

From 38998d363887f7ac2a930c635b915e97636b5255 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 028/109] ffmpegthumbs: revbump for ffmpeg6

---
 srcpkgs/ffmpegthumbs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ffmpegthumbs/template b/srcpkgs/ffmpegthumbs/template
index 2e2a96de83ce8a..dfd7e9dede36d3 100644
--- a/srcpkgs/ffmpegthumbs/template
+++ b/srcpkgs/ffmpegthumbs/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbs'
 pkgname=ffmpegthumbs
 version=23.08.5
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules kcoreaddons kconfig-devel
  pkg-config qt5-host-tools qt5-qmake gettext"

From e99d5526c3ebbd2931178b2e04db03d17d589470 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 029/109] ffms2: revbump for ffmpeg6

---
 srcpkgs/ffms2/patches/ffmpeg5.patch | 424 ++++++++++++++++++++++++++++
 srcpkgs/ffms2/template              |   2 +-
 2 files changed, 425 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ffms2/patches/ffmpeg5.patch

diff --git a/srcpkgs/ffms2/patches/ffmpeg5.patch b/srcpkgs/ffms2/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..1479fabcafcb4e
--- /dev/null
+++ b/srcpkgs/ffms2/patches/ffmpeg5.patch
@@ -0,0 +1,424 @@
+From 45673149e9a2f5586855ad472e3059084eaa36b1 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:41:21 +0100
+Subject: [PATCH] Use auto for AVCodec
+
+The geniuses over at FFmpeg decided to constify this API, so old
+versions of the library will return AVCodec *, while new versions
+of the libary will return const AVCodec *, which, in C++, are not
+OK to convert between.
+
+Rather than use some macro hell in ffmscompat.h, we can work around
+this by using auto.
+
+Gross.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 2 +-
+ src/core/indexing.cpp    | 6 +++---
+ src/core/videosource.cpp | 2 +-
+ 3 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index e4ce97c..ac09666 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -469,7 +469,7 @@ void FFMS_AudioSource::OpenFile() {
+ 
+     LAVFOpenFile(SourceFile.c_str(), FormatContext, TrackNumber);
+ 
+-    AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
++    auto *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
+     if (Codec == nullptr)
+         throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+             "Audio codec not found");
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index e547c5a..59fb4e8 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -384,7 +384,7 @@ FFMS_TrackType FFMS_Indexer::GetTrackType(int Track) {
+ }
+ 
+ const char *FFMS_Indexer::GetTrackCodec(int Track) {
+-    AVCodec *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
++    auto *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
+     return codec ? codec->name : nullptr;
+ }
+ 
+@@ -402,7 +402,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             UseDTS);
+ 
+         if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            AVCodec *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (!VideoCodec) {
+                 FormatContext->streams[i]->discard = AVDISCARD_ALL;
+                 IndexMask.erase(i);
+@@ -433,7 +433,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 IndexMask.insert(i);
+             }
+         } else if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+-            AVCodec *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (AudioCodec == nullptr)
+                 throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_UNSUPPORTED,
+                     "Audio codec not found");
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index b889970..8956c22 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -171,7 +171,7 @@ FFMS_VideoSource::FFMS_VideoSource(const char *SourceFile, FFMS_Index &Index, in
+ 
+         LAVFOpenFile(SourceFile, FormatContext, VideoTrack);
+ 
+-        AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
++        auto *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
+         if (Codec == nullptr)
+             throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+                 "Video codec not found");
+-- 
+2.40.0
+
+From 96cbf38ea9381829a1314f432a2c60495dcefaad Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:12:41 +0100
+Subject: [PATCH] all: Update AVPacket API usage
+
+AVPackets must all be on the heap now, since it is no longer
+part of the libav* ABI.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 16 ++++++----
+ src/core/indexing.cpp    | 63 ++++++++++++++++++++++------------------
+ src/core/indexing.h      |  4 +--
+ src/core/utils.cpp       |  6 ----
+ src/core/utils.h         |  1 -
+ src/core/videosource.cpp | 30 ++++++++++---------
+ 6 files changed, 64 insertions(+), 56 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index 37cf9ae..e4ce97c 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -285,10 +285,15 @@ FFMS_AudioSource::AudioBlock *FFMS_AudioSource::CacheBlock(CacheIterator &pos) {
+ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     CurrentFrame = &Frames[PacketNumber];
+ 
+-    AVPacket Packet;
+-    if (!ReadPacket(&Packet))
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++    if (!ReadPacket(Packet)) {
++        av_packet_free(&Packet);
+         throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_UNKNOWN,
+             "ReadPacket unexpectedly failed to read a packet");
++    }
+ 
+     // ReadPacket may have changed the packet number
+     CurrentFrame = &Frames[PacketNumber];
+@@ -297,8 +302,9 @@ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     int NumberOfSamples = 0;
+     AudioBlock *CachedBlock = nullptr;
+     
+-    int Ret = avcodec_send_packet(CodecContext, &Packet);
+-    av_packet_unref(&Packet);
++    int Ret = avcodec_send_packet(CodecContext, Packet);
++    av_packet_unref(Packet);
++    av_packet_free(&Packet);
+ 
+     av_frame_unref(DecodeFrame);
+     Ret = avcodec_receive_frame(CodecContext, DecodeFrame);
+@@ -513,8 +519,6 @@ void FFMS_AudioSource::Seek() {
+ }
+ 
+ bool FFMS_AudioSource::ReadPacket(AVPacket *Packet) {
+-    InitNullPacket(*Packet);
+-
+     while (av_read_frame(FormatContext, Packet) >= 0) {
+         if (Packet->stream_index == TrackNumber) {
+             // Required because not all audio packets, especially in ogg, have a pts. Use the previous valid packet's pts instead.
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index 23fb95b..e547c5a 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -320,7 +320,7 @@ void FFMS_Indexer::CheckAudioProperties(int Track, AVCodecContext *Context) {
+     }
+ }
+ 
+-void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict,
++void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict,
+                                     int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct) {
+     if (VideoContext.Parser) {
+         uint8_t *OB;
+@@ -330,8 +330,8 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+         av_parser_parse2(VideoContext.Parser,
+             VideoContext.CodecContext,
+             &OB, &OBSize,
+-            pkt.data, pkt.size,
+-            pkt.pts, pkt.dts, pkt.pos);
++            pkt->data, pkt->size,
++            pkt->pts, pkt->dts, pkt->pos);
+ 
+         // H.264 (PAFF) and HEVC may have one field per packet, so we need to track
+         // when we have a full or half frame available, and mark one of them as
+@@ -351,15 +351,15 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+ 
+         *RepeatPict = VideoContext.Parser->repeat_pict;
+         *FrameType = VideoContext.Parser->pict_type;
+-        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt.flags & AV_PKT_FLAG_DISCARD));
++        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt->flags & AV_PKT_FLAG_DISCARD));
+     } else {
+-        *Invisible = !!(pkt.flags & AV_PKT_FLAG_DISCARD);
++        *Invisible = !!(pkt->flags & AV_PKT_FLAG_DISCARD);
+     }
+ 
+     if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP8)
+-        ParseVP8(pkt.data[0], Invisible, FrameType);
++        ParseVP8(pkt->data[0], Invisible, FrameType);
+     else if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP9)
+-        ParseVP9(pkt.data[0], Invisible, FrameType);
++        ParseVP9(pkt->data[0], Invisible, FrameType);
+ }
+ 
+ void FFMS_Indexer::Free() {
+@@ -458,32 +458,36 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+         }
+     }
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
+     std::vector<int64_t> LastValidTS(FormatContext->nb_streams, AV_NOPTS_VALUE);
+ 
+     int64_t filesize = avio_size(FormatContext->pb);
+     enum AVPictureStructure LastPicStruct = AV_PICTURE_STRUCTURE_UNKNOWN;
+-    while (av_read_frame(FormatContext, &Packet) >= 0) {
++    while (av_read_frame(FormatContext, Packet) >= 0) {
+         // Update progress
+         // FormatContext->pb can apparently be NULL when opening images.
+         if (IC && FormatContext->pb) {
+-            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate))
++            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate)) {
++                av_packet_free(&Packet);
+                 throw FFMS_Exception(FFMS_ERROR_CANCELLED, FFMS_ERROR_USER,
+                     "Cancelled by user");
++            }
+         }
+-        if (!IndexMask.count(Packet.stream_index)) {
+-            av_packet_unref(&Packet);
++        if (!IndexMask.count(Packet->stream_index)) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+-        int Track = Packet.stream_index;
++        int Track = Packet->stream_index;
+         FFMS_Track &TrackInfo = (*TrackIndices)[Track];
+-        bool KeyFrame = !!(Packet.flags & AV_PKT_FLAG_KEY);
++        bool KeyFrame = !!(Packet->flags & AV_PKT_FLAG_KEY);
+         ReadTS(Packet, LastValidTS[Track], (*TrackIndices)[Track].UseDTS);
+ 
+         if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            int64_t PTS = TrackInfo.UseDTS ? Packet.dts : Packet.pts;
++            int64_t PTS = TrackInfo.UseDTS ? Packet->dts : Packet->pts;
+             if (PTS == AV_NOPTS_VALUE) {
+                 // VPx alt-refs are output as packets which lack timestmps or durations, since
+                 // they are invisible. Currently, the timestamp mangling code in libavformat
+@@ -495,9 +499,11 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 // FFMS2 currently sorts packets by PTS, which will break decoding, otherwise.
+                 bool HasAltRefs = (FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP8 ||
+                                    FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP9);
+-                if (Packet.duration == 0 && !HasAltRefs)
++                if (Packet->duration == 0 && !HasAltRefs) {
++                    av_packet_free(&Packet);
+                     throw FFMS_Exception(FFMS_ERROR_INDEXING, FFMS_ERROR_PARSER,
+                         "Invalid packet pts, dts, and duration");
++                }
+ 
+                 if (TrackInfo.empty())
+                     PTS = 0;
+@@ -513,7 +519,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             ParseVideoPacket(AVContexts[Track], Packet, &RepeatPict, &FrameType, &Invisible, &LastPicStruct);
+ 
+             TrackInfo.AddVideoFrame(PTS, RepeatPict, KeyFrame,
+-                FrameType, Packet.pos, Invisible);
++                FrameType, Packet->pos, Invisible);
+         } else if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+             // For video seeking timestamps are used only if all packets have
+             // timestamps, while for audio they're used if any have timestamps,
+@@ -522,28 +528,29 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 TrackInfo.HasTS = true;
+ 
+             int64_t StartSample = AVContexts[Track].CurrentSample;
+-            uint32_t SampleCount = IndexAudioPacket(Track, &Packet, AVContexts[Track], *TrackIndices);
++            uint32_t SampleCount = IndexAudioPacket(Track, Packet, AVContexts[Track], *TrackIndices);
+             TrackInfo.SampleRate = AVContexts[Track].CodecContext->sample_rate;
+ 
+             TrackInfo.AddAudioFrame(LastValidTS[Track],
+-                StartSample, SampleCount, KeyFrame, Packet.pos, Packet.flags & AV_PKT_FLAG_DISCARD);
++                StartSample, SampleCount, KeyFrame, Packet->pos, Packet->flags & AV_PKT_FLAG_DISCARD);
+         }
+ 
+-        if (!(Packet.flags & AV_PKT_FLAG_DISCARD))
+-            TrackInfo.LastDuration = Packet.duration;
++        if (!(Packet->flags & AV_PKT_FLAG_DISCARD))
++            TrackInfo.LastDuration = Packet->duration;
+ 
+-        av_packet_unref(&Packet);
++        av_packet_unref(Packet);
+     }
++    av_packet_free(&Packet);
+ 
+     TrackIndices->Finalize(AVContexts, FormatContext->iformat->name);
+     return TrackIndices.release();
+ }
+ 
+-void FFMS_Indexer::ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS) {
+-    if (!UseDTS && Packet.pts != AV_NOPTS_VALUE)
+-        TS = Packet.pts;
++void FFMS_Indexer::ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS) {
++    if (!UseDTS && Packet->pts != AV_NOPTS_VALUE)
++        TS = Packet->pts;
+     if (TS == AV_NOPTS_VALUE)
+         UseDTS = true;
+-    if (UseDTS && Packet.dts != AV_NOPTS_VALUE)
+-        TS = Packet.dts;
++    if (UseDTS && Packet->dts != AV_NOPTS_VALUE)
++        TS = Packet->dts;
+ }
+diff --git a/src/core/indexing.h b/src/core/indexing.h
+index 3cfc3c3..5c06868 100644
+--- a/src/core/indexing.h
++++ b/src/core/indexing.h
+@@ -80,10 +80,10 @@ private:
+     int64_t Filesize;
+     uint8_t Digest[20];
+ 
+-    void ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS);
++    void ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS);
+     void CheckAudioProperties(int Track, AVCodecContext *Context);
+     uint32_t IndexAudioPacket(int Track, AVPacket *Packet, SharedAVContext &Context, FFMS_Index &TrackIndices);
+-    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
++    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
+     void Free();
+ public:
+     FFMS_Indexer(const char *Filename);
+diff --git a/src/core/utils.cpp b/src/core/utils.cpp
+index ce67533..8a2e997 100644
+--- a/src/core/utils.cpp
++++ b/src/core/utils.cpp
+@@ -62,12 +62,6 @@ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo) {
+     }
+ }
+ 
+-void InitNullPacket(AVPacket &pkt) {
+-    av_init_packet(&pkt);
+-    pkt.data = nullptr;
+-    pkt.size = 0;
+-}
+-
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames) {
+     AP.SampleFormat = static_cast<FFMS_SampleFormat>(av_get_packed_sample_fmt(CTX->sample_fmt));
+     AP.BitsPerSample = av_get_bytes_per_sample(CTX->sample_fmt) * 8;
+diff --git a/src/core/utils.h b/src/core/utils.h
+index 9819dc7..003ab79 100644
+--- a/src/core/utils.h
++++ b/src/core/utils.h
+@@ -58,7 +58,6 @@ std::unique_ptr<T> make_unique(Args&&... args) {
+ }
+ 
+ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo);
+-void InitNullPacket(AVPacket &pkt);
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames);
+ 
+ void LAVFOpenFile(const char *SourceFile, AVFormatContext *&FormatContext, int Track);
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index 06bd161..b889970 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -673,30 +673,34 @@ void FFMS_VideoSource::DecodeNextFrame(int64_t &AStartTime, int64_t &Pos) {
+     if (HasPendingDelayedFrames())
+         return;
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
+-
+-    while (ReadFrame(&Packet) >= 0) {
+-        if (Packet.stream_index != VideoTrack) {
+-            av_packet_unref(&Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++
++    while (ReadFrame(Packet) >= 0) {
++        if (Packet->stream_index != VideoTrack) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+         if (AStartTime < 0)
+-            AStartTime = Frames.UseDTS ? Packet.dts : Packet.pts;
++            AStartTime = Frames.UseDTS ? Packet->dts : Packet->pts;
+ 
+         if (Pos < 0)
+-            Pos = Packet.pos;
++            Pos = Packet->pos;
+ 
+-        bool FrameFinished = DecodePacket(&Packet);
+-        av_packet_unref(&Packet);
+-        if (FrameFinished)
++        bool FrameFinished = DecodePacket(Packet);
++        av_packet_unref(Packet);
++        if (FrameFinished) {
++            av_packet_free(&Packet);
+             return;
++        }
+     }
+ 
+     // Flush final frames
+-    InitNullPacket(Packet);
+-    DecodePacket(&Packet);
++    DecodePacket(Packet);
++    av_packet_free(&Packet);
+ }
+ 
+ bool FFMS_VideoSource::SeekTo(int n, int SeekOffset) {
+-- 
+2.40.0
+
+From bf9e03e9e08534c024e5a744a6437c4aac160201 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:20:47 +0100
+Subject: [PATCH 2/3] configure: Remove deprecated API use
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ configure.ac | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index b35ef80bc..d19714d0f 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -102,10 +102,10 @@ CFLAGS="$_CFLAGS $FFMPEG_CFLAGS"
+
+ AC_DEFUN([TEST_FFMPEG],
+          [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+-            #include <libavcodec/avcodec.h>
++            #include <libavformat/avformat.h>
+             #include <libswscale/swscale.h>
+             ]],[[
+-                avcodec_register_all();
++                avformat_network_init();
+                 swscale_version();
+             ]])], [eval $1=yes], [eval $1=no])
+         ])
+
diff --git a/srcpkgs/ffms2/template b/srcpkgs/ffms2/template
index 365f64d10cbabf..1641ecf43be5bb 100644
--- a/srcpkgs/ffms2/template
+++ b/srcpkgs/ffms2/template
@@ -1,7 +1,7 @@
 # Template file for 'ffms2'
 pkgname=ffms2
 version=2.40
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-shared --disable-static"
 hostmakedepends="pkg-config autoconf automake libtool"

From aed5da6ee9062109fd500969e237ba1d81e8387c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 030/109] freerdp: revbump for ffmpeg6

---
 .../freerdp/patches/ffmpeg6_aa2cb9aa.patch    | 42 +++++++++++++++++++
 srcpkgs/freerdp/template                      |  2 +-
 2 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch

diff --git a/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
new file mode 100644
index 00000000000000..a4324da3a8822b
--- /dev/null
+++ b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
@@ -0,0 +1,42 @@
+From aa2cb9aa5ff5562433598ba168a466e0752bca0e Mon Sep 17 00:00:00 2001
+From: akallabeth <akallabeth@posteo.net>
+Date: Tue, 14 Feb 2023 07:48:54 +0100
+Subject: [PATCH] Fixed #8686: Update h264 to use new FFMPEG API
+
+---
+ channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c | 2 ++
+ libfreerdp/codec/h264_ffmpeg.c            | 2 ++
+ 2 files changed, 4 insertions(+)
+
+diff --git a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+index 339462d865f..beea80b7a1e 100644
+--- a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
++++ b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+@@ -239,8 +239,10 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYP
+ 		}
+ 	}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 	if (mdecoder->codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		mdecoder->codec_context->flags |= AV_CODEC_FLAG_TRUNCATED;
++#endif
+ 
+ 	return TRUE;
+ }
+diff --git a/libfreerdp/codec/h264_ffmpeg.c b/libfreerdp/codec/h264_ffmpeg.c
+index 8a23db2473c..896a333019b 100644
+--- a/libfreerdp/codec/h264_ffmpeg.c
++++ b/libfreerdp/codec/h264_ffmpeg.c
+@@ -615,10 +615,12 @@ static BOOL libavcodec_init(H264_CONTEXT* h264)
+ 			goto EXCEPTION;
+ 		}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 		if (sys->codecDecoder->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		{
+ 			sys->codecDecoderContext->flags |= AV_CODEC_FLAG_TRUNCATED;
+ 		}
++#endif
+ 
+ #ifdef WITH_VAAPI
+ 
diff --git a/srcpkgs/freerdp/template b/srcpkgs/freerdp/template
index 16fddfbe8f5287..bf3a4d2e2b3ae7 100644
--- a/srcpkgs/freerdp/template
+++ b/srcpkgs/freerdp/template
@@ -1,7 +1,7 @@
 # Template file for 'freerdp'
 pkgname=freerdp
 version=2.11.4
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_ALSA=ON -DWITH_CUPS=OFF -DWITH_FFMPEG=ON
  -DWITH_GSTREAMER_0_10=OFF -DWITH_GSTREAMER_1_0=OFF -DWITH_JPEG=ON

From c2a5deb045913de073127ba43c60b2f64a00efc0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 031/109] gerbera: revbump for ffmpeg6

---
 srcpkgs/gerbera/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gerbera/template b/srcpkgs/gerbera/template
index ae14f35c767c03..2dc0ac0ce03b55 100644
--- a/srcpkgs/gerbera/template
+++ b/srcpkgs/gerbera/template
@@ -1,7 +1,7 @@
 # Template file for 'gerbera'
 pkgname=gerbera
 version=1.12.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_SYSTEMD=0 -DWITH_AVCODEC=1"
 hostmakedepends="pkg-config"

From 8fd81715f1b9549e1c9a26879401b24fb2fe7ab4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 032/109] goldendict: revbump for ffmpeg6

---
 srcpkgs/goldendict/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/goldendict/template b/srcpkgs/goldendict/template
index f4a05759f693d3..97f44347b03a6a 100644
--- a/srcpkgs/goldendict/template
+++ b/srcpkgs/goldendict/template
@@ -1,7 +1,7 @@
 # Template file for 'goldendict'
 pkgname=goldendict
 version=1.5.0
-revision=1
+revision=2
 build_style=qmake
 configure_args="CONFIG+=zim_support goldendict.pro"
 hostmakedepends="qt5-qmake pkg-config qt5-host-tools"
@@ -10,7 +10,7 @@ makedepends="tiff-devel qt5-devel libvorbis-devel zlib-devel
  qt5-webkit-devel lzo-devel bzip2-devel libao-devel qt5-svg-devel
  libeb-devel qt5-x11extras-devel ffmpeg-devel liblzma-devel
  qt5-multimedia-devel"
-short_desc="A feature-rich dictionary lookup program"
+short_desc="Feature-rich dictionary lookup program"
 maintainer="John <me@johnnynator.dev>"
 license="GPL-3.0-or-later"
 homepage="http://goldendict.org/"

From 3cbcebe9d4d25e48b31833aa0db49d16ae3cb8c2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 033/109] gst-libav: revbump for ffmpeg6

---
 srcpkgs/gst-libav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index e02c0deafc6d24..3b82a28e99c970 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.24.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"

From 5ec187eb0e28a2b57b63eb6d650f941208a0f079 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Feb 2024 01:52:46 -0500
Subject: [PATCH 034/109] gst-plugins-bad1: revbump for ffmpeg6

---
 srcpkgs/gst-plugins-bad1/template | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index 0712c756c00e60..5bb0986fb26953 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-plugins-bad1'
 pkgname=gst-plugins-bad1
 version=1.24.0
-revision=1
+revision=2
 build_helper="gir"
 build_style=meson
 configure_args="-Dpackage-origin=https://voidlinux.org -Ddoc=disabled
@@ -27,8 +27,7 @@ makedepends="alsa-lib-devel celt-devel openssl-devel exempi-devel
  fdk-aac-devel flite-devel fluidsynth-devel liblrdf-devel ladspa-sdk
  lilv-devel lv2 libopenjpeg2-devel sbc-devel spandsp-devel vulkan-loader
  Vulkan-Headers webrtc-audio-processing-devel libzbar-devel ffmpeg-devel
- srt-devel libva-devel
- $(vopt_if gme libgme-devel)"
+ srt-devel libva-devel $(vopt_if onevpl oneVPL-devel) $(vopt_if gme libgme-devel)"
 depends="gst-plugins-base1>=${version}"
 short_desc="GStreamer plugins from the bad set (v1.x)"
 maintainer="Orphaned <orphan@voidlinux.org>"
@@ -38,7 +37,7 @@ changelog="https://gstreamer.freedesktop.org/releases/${version%.*}/#${version}"
 distfiles="https://gstreamer.freedesktop.org/src/gst-plugins-bad/gst-plugins-bad-${version}.tar.xz"
 checksum=d23c3a1a79c425d21078b4892c3302a1d4930d67b83dfa8e03df416fc3f97eba
 
-build_options="gir gme wayland"
+build_options="gir gme onevpl wayland"
 build_options_default="gir wayland"
 desc_option_gme="Build with Game Music Emulator support"
 
@@ -46,6 +45,7 @@ CFLAGS="-fcommon"
 
 case "$XBPS_TARGET_MACHINE" in
 	mips*) ;; # libgme cannot be built for mips*
+	x86_64*) build_options_default+=" gme onevpl" ;; # onevpl only supports 64bit
 	*) build_options_default+=" gme" ;;
 esac
 

From 37091baaf7a2ebe3f1eb70c46f67952f2a8e0dfb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 035/109] gst-rtsp-server: revbump for ffmpeg6

---
 srcpkgs/gst-rtsp-server/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index 4ace541d36e324..837b1bc0d14118 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
 version=1.24.0
-revision=1
+revision=2
 build_style=meson
 build_helper=gir
 configure_args="-Dintrospection=enabled"

From ac65168d96a7090f2f0aabaff15e1fef97ebcb9f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 036/109] guvcview: update to 2.0.8.

---
 srcpkgs/guvcview/patches/fix-include.patch | 10 ++++++++++
 srcpkgs/guvcview/template                  |  7 +++----
 2 files changed, 13 insertions(+), 4 deletions(-)
 create mode 100644 srcpkgs/guvcview/patches/fix-include.patch

diff --git a/srcpkgs/guvcview/patches/fix-include.patch b/srcpkgs/guvcview/patches/fix-include.patch
new file mode 100644
index 00000000000000..503c2af3b78c1a
--- /dev/null
+++ b/srcpkgs/guvcview/patches/fix-include.patch
@@ -0,0 +1,10 @@
+--- a/guvcview/guvcview.c
++++ b/guvcview/guvcview.c
+@@ -28,6 +28,7 @@
+ #include <sys/stat.h>
+ #include <sys/resource.h>
+ #include <errno.h>
++#include <locale.h>
+ 
+ #include "gview.h"
+ #include "gviewv4l2core.h"
diff --git a/srcpkgs/guvcview/template b/srcpkgs/guvcview/template
index d42fd38fa4ad12..86a7fd619612c8 100644
--- a/srcpkgs/guvcview/template
+++ b/srcpkgs/guvcview/template
@@ -1,8 +1,7 @@
 # Template file for 'guvcview'
 pkgname=guvcview
-version=2.0.7
-revision=2
-create_wrksrc=yes
+version=2.0.8
+revision=1
 build_style=gnu-configure
 configure_args="--disable-static --disable-debian-menu"
 hostmakedepends="pkg-config intltool autoconf automake libtool glib-devel"
@@ -14,7 +13,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="http://guvcview.sourceforge.net/"
 distfiles="${SOURCEFORGE_SITE}/${pkgname}/${pkgname}-src-${version}.tar.bz2"
-checksum=f47d51fbd06e44eeaa1a82f4a153c927527c90d94514197a70b2956028cc8ad4
+checksum=a21f4e448286666cf27bafef5290cc953a0a1796b752e5bbe521266dc1230c81
 
 post_patch() {
 	sed '31a#include <locale.h>' -i  guvcview/guvcview.c

From 5c6b0b2dde95fd967b7e7f0d39a5fa7823b905ba Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 037/109] handbrake: update to 1.6.1

---
 .../patches/fix-missing-x265-link-flag.patch    | 11 ++++++-----
 .../handbrake/patches/libhb-vpl-include.patch   | 15 +++++++++++++++
 srcpkgs/handbrake/template                      | 17 ++++++++++-------
 3 files changed, 31 insertions(+), 12 deletions(-)
 create mode 100644 srcpkgs/handbrake/patches/libhb-vpl-include.patch

diff --git a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
index 26db03867a0c83..d6bb2eda627a36 100644
--- a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
+++ b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
@@ -1,14 +1,15 @@
 --- a/gtk/configure.ac
 +++ b/gtk/configure.ac
 @@ -203,7 +203,7 @@
- 
+
  AM_CONDITIONAL([MINGW], [test "x$mingw_flag" = "xyes"])
- 
--HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg"
-+HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -ldl"
+
+-HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc"
++HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc -ldl"
  HB_CPPFLAGS="$HB_CPPFLAGS $HBINC"
- 
+
  PKG_CHECK_MODULES([x264], [x264], sys_x264=yes, sys_x264=no)
+
 --- a/test/module.defs
 +++ b/test/module.defs
 @@ -69,6 +69,9 @@
diff --git a/srcpkgs/handbrake/patches/libhb-vpl-include.patch b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
new file mode 100644
index 00000000000000..298f9f4ab28f2a
--- /dev/null
+++ b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
@@ -0,0 +1,15 @@
+--- a/libhb/module.defs	2023-01-22 11:36:49.000000000 -0500
++++ b/libhb/module.defs	2023-04-03 22:37:52.395467010 -0400
+@@ -46,11 +46,7 @@
+ LIBHB.GCC.I += $(LIBHB.build/) $(CONTRIB.build/)include
+ 
+ ifeq (1,$(FEATURE.qsv))
+-    ifeq ($(HOST.system),freebsd))
+-        LIBHB.GCC.I += $(LOCALBASE)/include/vpl
+-    else
+-        LIBHB.GCC.I += $(CONTRIB.build/)include/vpl
+-    endif
++    LIBHB.GCC.I += /usr/include/vpl
+ endif
+ 
+ ifneq (,$(filter $(HOST.system),freebsd netbsd openbsd))
diff --git a/srcpkgs/handbrake/template b/srcpkgs/handbrake/template
index ca5e4571e49c37..c32cb1bfa31f4b 100644
--- a/srcpkgs/handbrake/template
+++ b/srcpkgs/handbrake/template
@@ -1,10 +1,10 @@
 # Template file for 'handbrake'
 pkgname=handbrake
-version=1.5.1
+version=1.6.1
 revision=1
 build_style=gnu-configure
 configure_args="--force --disable-gtk-update-checks --disable-df-fetch --harden
- $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc)"
+ $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc) $(vopt_enable qsv)"
 make_build_args="-C ${XBPS_TRIPLET}"
 make_install_args="-C ${XBPS_TRIPLET}"
 hostmakedepends="automake cmake gettext-devel glib-devel intltool libtool m4 meson nasm pkg-config python3"
@@ -12,8 +12,11 @@ makedepends="bzip2-devel ffmpeg-devel gst-plugins-base1-devel gtk+3-devel
  jansson-devel lame-devel libass-devel libbluray-devel libdav1d-devel
  libdvdnav-devel libdvdread-devel libgudev-devel libnuma-devel
  libsamplerate-devel libtheora-devel libvorbis-devel libvpx-devel libxml2-devel
- opus-devel speex-devel x264-devel x265-devel zimg-devel
+ opus-devel speex-devel x264-devel x265-devel zimg-devel libsvt-av1-devel
  $(vopt_if fdk_aac fdk-aac-devel)
+ $(vopt_if qsv libva-devel)
+ $(vopt_if qsv libdrm-devel)
+ $(vopt_if qsv onevpl-devel)
  $(vopt_if nvenc nv-codec-headers)"
 depends="desktop-file-utils gst-plugins-good1 hicolor-icon-theme"
 short_desc="Multithreaded video transcoder"
@@ -21,15 +24,15 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-2.0-only"
 homepage="https://handbrake.fr/"
 distfiles="https://github.com/HandBrake/HandBrake/releases/download/${version}/HandBrake-${version}-source.tar.bz2"
-checksum=3999fe06d5309c819799a73a968a8ec3840e7840c2b64af8f5cdb7fd8c9430f0
+checksum=94ccfe03db917a91650000c510f7fd53f844da19f19ad4b4be1b8f6bc31a8d4c
 nocross=yes
 
-build_options="fdk_aac nvenc"
+build_options="fdk_aac nvenc qsv"
 
 case "$XBPS_TARGET_MACHINE" in
 	x86_64*|i686*)
 		CFLAGS="-msse"
-		build_options_default="nvenc"
+		build_options_default="nvenc qsv"
 		;;
 esac
 
@@ -37,7 +40,7 @@ pre_configure() {
 	# use system libraries, don't download them
 	rm -rf contrib/
 	for module in fdk-aac ffmpeg libbluray libdav1d libdvdnav libdvdread nvenc \
-		x265 zimg; do
+		x265 zimg svt-av1 libvpl; do
 	    vsed -i "/MODULES += contrib\/${module}/d" make/include/main.defs
 	done
 }

From d5535f54d42c9b90f3d298aaf7b14f8d702df9c6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 038/109] hedgewars: revbump for ffmpeg4

---
 srcpkgs/hedgewars/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/hedgewars/template b/srcpkgs/hedgewars/template
index 94b6db673b0c3a..402ccfaaecbc2d 100644
--- a/srcpkgs/hedgewars/template
+++ b/srcpkgs/hedgewars/template
@@ -1,13 +1,13 @@
 # Template file for 'hedgewars'
 pkgname=hedgewars
 version=1.0.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DNOSERVER=1 -DDATA_INSTALL_DIR=/usr/share/${pkgname}
  -DPHYSFS_SYSTEM=1 -DMINIMAL_FLAGS=1"
 make_cmd=make
 hostmakedepends="lua51 pkg-config qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
+makedepends="ffmpeg4-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
  SDL2_mixer-devel SDL2_net-devel SDL2_ttf-devel"
 depends="libfreeglut"
 short_desc="Funny turn-based artillery game, featuring fighting Hedgehogs!"

From cc7aa94f21d4c5c6216b811e99d41d33c32c125e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 039/109] idjc: revbump for ffmpeg4

---
 srcpkgs/idjc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/idjc/template b/srcpkgs/idjc/template
index a9cde0665d55b1..f41e1e4fabbae7 100644
--- a/srcpkgs/idjc/template
+++ b/srcpkgs/idjc/template
@@ -1,11 +1,11 @@
 # Template file for 'idjc'
 pkgname=idjc
 version=0.9.1
-revision=5
+revision=6
 build_style=gnu-configure
 hostmakedepends="pkg-config git python3 automake gettext-devel libtool"
 makedepends="libvorbis-devel libogg-devel jack-devel libsamplerate-devel
- libflac-devel libsndfile-devel mpg123-devel ffmpeg-devel speex-devel
+ libflac-devel libsndfile-devel mpg123-devel ffmpeg4-devel speex-devel
  glib-devel pixman-devel lame-devel python3-gobject-devel libshout-idjc-devel
  opus-devel twolame-devel python3-mutagen python3-devel"
 depends="python3-gobject python3-mutagen desktop-file-utils shared-mime-info python3-dbus jack"

From d310b6cd879369e8af63d80cd8847b184a0eb617 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 040/109] kid3: revbump for ffmpeg6

---
 srcpkgs/kid3/patches/ffmpeg5.patch | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 srcpkgs/kid3/patches/ffmpeg5.patch

diff --git a/srcpkgs/kid3/patches/ffmpeg5.patch b/srcpkgs/kid3/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..135fc50e07c9ba
--- /dev/null
+++ b/srcpkgs/kid3/patches/ffmpeg5.patch
@@ -0,0 +1,17 @@
+# https://aur.archlinux.org/cgit/aur.git/diff/ffmpeg5.patch?h=kid3-cli&id=12410a74906612e7efc0ec8fbce739b4a0fef7e7
+diff --git a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+index e156d424..e12b9abd 100644
+--- a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
++++ b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+@@ -232,7 +232,11 @@ private:
+   friend class Format;
+   friend class Converter;
+   AVCodecContext* m_ptr;
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 0, 0)
+   AVCodec* m_impl;
++#else
++  const AVCodec* m_impl;
++#endif
+   AVFrame* m_frame;
+   bool m_opened;
+ };

From f4c45f75d0e77d819b4c3ce2380dcd46592435ff Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 041/109] kodi: revbump for ffmpeg4

---
 srcpkgs/kodi/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/kodi/template b/srcpkgs/kodi/template
index d37a5918cd6758..ea78e0aca0fe3e 100644
--- a/srcpkgs/kodi/template
+++ b/srcpkgs/kodi/template
@@ -1,7 +1,7 @@
 # Template file for 'kodi'
 pkgname=kodi
 version=19.4
-revision=9
+revision=10
 _codename="Matrix"
 build_style=cmake
 configure_args="-DWITH_FFMPEG=/usr -DENABLE_LDGOLD=OFF
@@ -54,7 +54,7 @@ makedepends="
  libmad-devel fontconfig-devel libXinerama-devel libsamplerate-devel libmms-devel
  enca-devel boost-devel libcurl-devel libva-devel libvdpau-devel libass-devel
  libbluetooth-devel yajl-devel libplist-devel librtmp-devel tinyxml-devel
- taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg-devel
+ taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg4-devel
  giflib-devel libxslt-devel gnutls-devel libssh-devel libmicrohttpd-devel
  libcec-devel dcadec-devel flatbuffers-devel fmt-devel lcms2-devel
  libfstrcmp-devel rapidjson libcdio-paranoia spdlog libwaylandpp-devel

From 3c7a5a98b11220eb88bb260fc9a7d78f6815e131 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 042/109] kpipewire: revbump for ffmpeg6

---
 srcpkgs/kpipewire/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kpipewire/template b/srcpkgs/kpipewire/template
index 24f5f152749c97..d5ac3788ff586a 100644
--- a/srcpkgs/kpipewire/template
+++ b/srcpkgs/kpipewire/template
@@ -1,7 +1,7 @@
 # Template file for 'kpipewire'
 pkgname=kpipewire
 version=5.27.11
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules plasma-wayland-protocols gettext
  qt5-qmake qt5-host-tools pkg-config wayland-devel kcoreaddons

From 01dad20b741954f2d9bf4d4749e1ab8b8fa5d8cd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 043/109] libopenal: revbump for ffmpeg6

---
 srcpkgs/libopenal/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenal/template b/srcpkgs/libopenal/template
index 88d0f11307d81a..8308fca0393e33 100644
--- a/srcpkgs/libopenal/template
+++ b/srcpkgs/libopenal/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenal'
 pkgname=libopenal
 version=1.23.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DALSOFT_EXAMPLES=OFF"
 hostmakedepends="pkg-config"

From caf6626c2671fd457d7a88626f668d461795faac Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 044/109] loudgain: revbump for ffmpeg6

---
 srcpkgs/loudgain/patches/ffmpeg5.patch | 11 +++++++++++
 srcpkgs/loudgain/template              |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/loudgain/patches/ffmpeg5.patch

diff --git a/srcpkgs/loudgain/patches/ffmpeg5.patch b/srcpkgs/loudgain/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..16d4510ee98faa
--- /dev/null
+++ b/srcpkgs/loudgain/patches/ffmpeg5.patch
@@ -0,0 +1,11 @@
+--- a/src/scan.c	2019-09-06 11:31:19.000000000 -0400
++++ b/src/scan.c	2023-03-23 11:15:40.867968521 -0400
+@@ -69,8 +69,6 @@
+ 	 * It is now useless
+ 	 * https://github.com/FFmpeg/FFmpeg/blob/70d25268c21cbee5f08304da95be1f647c630c15/doc/APIchanges#L86
+ 	 */
+-  if (avformat_version() < AV_VERSION_INT(58,9,100))
+-    av_register_all();
+ 
+ 	av_log_set_callback(scan_av_log);
+ 
diff --git a/srcpkgs/loudgain/template b/srcpkgs/loudgain/template
index da4f2d56e94c3d..4d6bf29efb4fdd 100644
--- a/srcpkgs/loudgain/template
+++ b/srcpkgs/loudgain/template
@@ -1,7 +1,7 @@
 # Template file for 'loudgain'
 pkgname=loudgain
 version=0.6.8
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libebur128-devel taglib-devel ffmpeg-devel"

From bab98ac27be0b6917203e1a497776fe5b35a4d7d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 045/109] mediastreamer: revbump for ffmpeg4

---
 srcpkgs/mediastreamer/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mediastreamer/template b/srcpkgs/mediastreamer/template
index 0fcffa7653d18e..e888626b945e55 100644
--- a/srcpkgs/mediastreamer/template
+++ b/srcpkgs/mediastreamer/template
@@ -1,11 +1,11 @@
 # Template file for 'mediastreamer'
 pkgname=mediastreamer
 version=5.2.111
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DENABLE_STRICT=0 -DENABLE_UNIT_TESTS=0"
 hostmakedepends="python3"
-makedepends="bzrtp-devel ffmpeg-devel glew-devel libXv-devel libsrtp-devel
+makedepends="bzrtp-devel ffmpeg4-devel glew-devel libXv-devel libsrtp-devel
  libupnp-devel libvpx-devel mbedtls-devel opus-devel ortp-devel pulseaudio-devel
  libtheora-devel speex-devel v4l-utils-devel bcg729-devel bcmatroska2-devel libgsm-devel
  zxing-cpp-devel"

From 7fe4548a46a5078fca40be351afc1fc810007621 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 046/109] mgba: revbump for ffmpeg6

---
 srcpkgs/mgba/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mgba/template b/srcpkgs/mgba/template
index 6cd65650312543..93401adb618bd8 100644
--- a/srcpkgs/mgba/template
+++ b/srcpkgs/mgba/template
@@ -1,7 +1,7 @@
 # Template file for 'mgba'
 pkgname=mgba
 version=0.10.3
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake desktop-file-utils"
 makedepends="SDL2-devel ffmpeg-devel libedit-devel libepoxy-devel libmagick-devel

From 2267a89bb3030b4d6f6fbf48bd1805d5b515339e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 047/109] mlt: revbump for ffmpeg4

---
 srcpkgs/mlt/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mlt/template b/srcpkgs/mlt/template
index 73e3915aaab9ac..d7ed4c4b30a868 100644
--- a/srcpkgs/mlt/template
+++ b/srcpkgs/mlt/template
@@ -1,14 +1,14 @@
 # Template file for 'mlt'
 pkgname=mlt
 version=6.26.1
-revision=3
+revision=4
 build_style=configure
 configure_args="--prefix=/usr --libdir=/usr/lib$XBPS_TARGET_WORDSIZE
  --enable-gpl --enable-gpl3 --disable-swfdec --without-kde
  --swig-languages=python"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which"
 # XXX: movit vid.stab
-makedepends="alsa-lib-devel ffmpeg-devel gtk+-devel jack-devel ladspa-sdk
+makedepends="alsa-lib-devel ffmpeg4-devel gtk+-devel jack-devel ladspa-sdk
  libexif-devel libsamplerate-devel libxml2-devel sox-devel SDL_image-devel
  fftw-devel frei0r-plugins python3-devel pulseaudio-devel movit-devel
  libvidstab-devel"

From 82be9005b0db17ef3e5304da10c2b489a6cc9e59 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 048/109] moc: revbump for ffmpeg4

---
 srcpkgs/moc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/moc/template b/srcpkgs/moc/template
index 3a04932c8f1e61..838755f88db09e 100644
--- a/srcpkgs/moc/template
+++ b/srcpkgs/moc/template
@@ -1,10 +1,10 @@
 # Template file for 'moc'
 pkgname=moc
 version=2.5.2
-revision=7
+revision=8
 build_style=gnu-configure
 hostmakedepends="pkg-config"
-makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg-devel
+makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg4-devel
  jack-devel alsa-lib-devel libltdl-devel libflac-devel libvorbis-devel
  libmad-devel libmpcdec-devel libmodplug-devel libid3tag-devel faad2-devel
  taglib-devel libsndfile-devel wavpack-devel speex-devel libsamplerate-devel

From 6f0d7675f013da64615cc8d57f10ecea8663dc0d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 049/109] motion: revbump for ffmpeg6

---
 srcpkgs/motion/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/motion/template b/srcpkgs/motion/template
index 607ebeb3c7b242..bf63a91d9764f6 100644
--- a/srcpkgs/motion/template
+++ b/srcpkgs/motion/template
@@ -1,7 +1,7 @@
 # Template file for 'motion'
 pkgname=motion
 version=4.6.0
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake pkg-config gettext-devel tar"
 makedepends="ffmpeg-devel libmicrohttpd-devel v4l-utils-devel gettext-devel"

From c2cbe044b6f1edf8bf76caf44ee9f2b3472e79f2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 050/109] olive: revbump for ffmpeg4

---
 srcpkgs/olive/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/olive/template b/srcpkgs/olive/template
index 12a46936c99003..5c2917b9c51245 100644
--- a/srcpkgs/olive/template
+++ b/srcpkgs/olive/template
@@ -1,10 +1,10 @@
 # Template file for 'olive'
 pkgname=olive
 version=0.1.2
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools pkg-config"
-makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg-devel frei0r-plugins"
+makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg4-devel frei0r-plugins"
 short_desc="Non-linear video editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"

From 6825e0af96f38e6b9efda955ab4b5750af714196 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 051/109] opentoonz: revbump for ffmpeg6

---
 srcpkgs/opentoonz/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/opentoonz/template b/srcpkgs/opentoonz/template
index ee9f7603f55fd8..3e81834ca0eddf 100644
--- a/srcpkgs/opentoonz/template
+++ b/srcpkgs/opentoonz/template
@@ -1,7 +1,7 @@
 # Template file for 'opentoonz'
 pkgname=opentoonz
 version=1.6.0
-revision=2
+revision=3
 build_wrksrc="toonz/sources"
 build_style=cmake
 make_cmd=make

From 81e87548afbe5d538834da5c4c505afe50de0eb9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 052/109] pianobar: revbump for ffmpeg6

---
 srcpkgs/pianobar/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pianobar/template b/srcpkgs/pianobar/template
index e3febb821a4510..1e3dc1bf9308ee 100644
--- a/srcpkgs/pianobar/template
+++ b/srcpkgs/pianobar/template
@@ -1,7 +1,7 @@
 # Template file for 'pianobar'
 pkgname=pianobar
 version=2022.04.01
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="V=1"
 hostmakedepends="pkg-config"

From c49cde00f9c1fca537763774b801746301eb55b6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 053/109] ppsspp: revbump for ffmpeg6

---
 srcpkgs/ppsspp/patches/ffmpeg6.patch | 15 +++++++++++++++
 srcpkgs/ppsspp/template              |  3 +--
 2 files changed, 16 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/ppsspp/patches/ffmpeg6.patch

diff --git a/srcpkgs/ppsspp/patches/ffmpeg6.patch b/srcpkgs/ppsspp/patches/ffmpeg6.patch
new file mode 100644
index 00000000000000..5803c7bf227309
--- /dev/null
+++ b/srcpkgs/ppsspp/patches/ffmpeg6.patch
@@ -0,0 +1,15 @@
+--- a/Core/HW/SimpleAudioDec.cpp	2024-02-04 08:08:02.000000000 -0500
++++ b/Core/HW/SimpleAudioDec.cpp	2024-02-15 14:48:27.114362051 -0500
+@@ -81,7 +81,11 @@
+ 		return;
+ 	}
+ 	// Find decoder
++#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(58, 18, 100)
+ 	codec_ = avcodec_find_decoder((AVCodecID)audioCodecId);
++#else // this is a macro to const in the header
++	codec_ = (AVCodec*)avcodec_find_decoder((AVCodecID)audioCodecId);
++#endif
+ 	if (!codec_) {
+ 		// Eh, we shouldn't even have managed to compile. But meh.
+ 		ERROR_LOG(ME, "This version of FFMPEG does not support AV_CODEC_ctx for audio (%s). Update your submodule.", GetCodecName(audioType));
+
diff --git a/srcpkgs/ppsspp/template b/srcpkgs/ppsspp/template
index 2238a7601c0af8..1fda55268a2d39 100644
--- a/srcpkgs/ppsspp/template
+++ b/srcpkgs/ppsspp/template
@@ -1,7 +1,7 @@
 # Template file for 'ppsspp'
 pkgname=ppsspp
 version=1.17.1
-revision=1
+revision=2
 _glslang_commit=b34f619e1c85810dcb3c578107d2e48ba4ee2b37
 _SPIRV_Cross_commit=4212eef67ed0ca048cb726a6767185504e7695e5
 _armips_commit=a8d71f0f279eb0d30ecf6af51473b66ae0cf8e8d
@@ -91,7 +91,6 @@ post_configure() {
 }
 
 do_install() {
-	vlicense LICENSE.TXT
 	vinstall icons/icon.svg 644 usr/share/pixmaps ppsspp.svg
 	vinstall Qt/PPSSPP.desktop 644 usr/share/applications
 	vbin build/PPSSPPHeadless ppsspp-headless

From 01d0a647f977e9ebc2b34512a450281fee149884 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 054/109] pqiv: revbump for ffmpeg6

---
 srcpkgs/pqiv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pqiv/template b/srcpkgs/pqiv/template
index f9f7751196d4ee..0d50777e56a2d8 100644
--- a/srcpkgs/pqiv/template
+++ b/srcpkgs/pqiv/template
@@ -1,7 +1,7 @@
 # Template file for 'pqiv'
 pkgname=pqiv
 version=2.13.1
-revision=1
+revision=2
 build_style=gnu-makefile
 hostmakedepends="pkg-config"
 makedepends="glib-devel gtk+3-devel $(vopt_if ffmpeg ffmpeg-devel)

From c7956997d21d1f3ab47f73ba9647aec495f74e5b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 055/109] qmmp: revbump for ffmpeg6

---
 srcpkgs/qmmp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qmmp/template b/srcpkgs/qmmp/template
index 53781ea3bc28ad..2da07f1e87eac0 100644
--- a/srcpkgs/qmmp/template
+++ b/srcpkgs/qmmp/template
@@ -1,7 +1,7 @@
 # Template file for 'qmmp'
 pkgname=qmmp
 version=1.6.1
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DUSE_HAL:BOOL=FALSE -DQMMP_DEFAULT_UI:STRING=simple"
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From b88c553195a576e45e512ff1750013ea3a4f1dd5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 14 Dec 2023 13:28:10 -0500
Subject: [PATCH 056/109] qt6-pdf: revbump for ffmpeg6

---
 srcpkgs/qt6-pdf/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-pdf/template b/srcpkgs/qt6-pdf/template
index ecda84afac1310..531b4e1d4fe84d 100644
--- a/srcpkgs/qt6-pdf/template
+++ b/srcpkgs/qt6-pdf/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-pdf'
 pkgname=qt6-pdf
 version=6.6.0
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DQT_FEATURE_qtpdf_build=ON
  -DQT_FEATURE_qtpdf_widgets_build=ON

From 4b651c138911b6bc312e1f4fe6ce5a4c845403fe Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 057/109] qt5-webengine: revbump for ffmpeg6

---
 .../chromium-media-filters-cpp14.patch        |  11 ++
 srcpkgs/qt5-webengine/patches/ffmpeg5.patch   | 179 ++++++++++++++++++
 .../qtwebengine-fix-ffmpeg5-build.patch       |  14 ++
 srcpkgs/qt5-webengine/template                |   4 +-
 4 files changed, 206 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/ffmpeg5.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch

diff --git a/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
new file mode 100644
index 00000000000000..04adc540f2cbc0
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
@@ -0,0 +1,11 @@
+--- a/src/3rdparty/chromium/media/filters/BUILD.gn	2023-02-27 13:32:59.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/BUILD.gn	2023-04-02 17:21:39.204066384 -0400
+@@ -96,6 +96,8 @@
+     "//ui/gfx/geometry:geometry",
+   ]
+ 
++  cflags_cc = [ "-std=c++14" ]
++
+   libs = []
+ 
+   if (proprietary_codecs) {
diff --git a/srcpkgs/qt5-webengine/patches/ffmpeg5.patch b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..ac55e1634423a9
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
@@ -0,0 +1,179 @@
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:57.732547446 -0400
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:09.486478995 -0400
+@@ -57,6 +57,8 @@
+ 
+ namespace {
+ 
++constexpr int64_t kRelativeTsBase = static_cast<int64_t>(0x7ffeffffffffffff);
++
+ void SetAVStreamDiscard(AVStream* stream, AVDiscard discard) {
+   DCHECK(stream);
+   stream->discard = discard;
+@@ -90,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+   if (stream->start_time != kNoFFmpegTimestamp)
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (stream->first_dts != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, stream->first_dts);
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -408,11 +398,11 @@
+   scoped_refptr<DecoderBuffer> buffer;
+ 
+   if (type() == DemuxerStream::TEXT) {
+-    int id_size = 0;
++    size_t id_size = 0;
+     uint8_t* id_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
+ 
+-    int settings_size = 0;
++    size_t settings_size = 0;
+     uint8_t* settings_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
+ 
+@@ -424,7 +414,7 @@
+     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
+                                      side_data.data(), side_data.size());
+   } else {
+-    int side_data_size = 0;
++    size_t side_data_size = 0;
+     uint8_t* side_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
+ 
+@@ -485,7 +475,7 @@
+                                        packet->size - data_offset);
+     }
+ 
+-    int skip_samples_size = 0;
++    size_t skip_samples_size = 0;
+     const uint32_t* skip_samples_ptr =
+         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
+             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
+@@ -1587,6 +1577,8 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++      continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+       lowest_start_time_stream = stream.get();
+@@ -1604,6 +1596,8 @@
+     if (stream && stream->type() == DemuxerStream::VIDEO &&
+         stream->IsEnabled()) {
+       video_stream = stream.get();
++      if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++        continue;
+       if (video_stream->start_time() <= seek_time) {
+         return video_stream;
+       }
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h qtwebengine-5.15.10/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h
+--- a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-07-11 22:12:47.917192788 -0500
+@@ -29,6 +29,7 @@ extern "C" {
+ #include <libavformat/avformat.h>
+ #include <libavformat/avio.h>
+ #include <libavutil/avutil.h>
++#include <libavutil/channel_layout.h>
+ #include <libavutil/imgutils.h>
+ #include <libavutil/log.h>
+ #include <libavutil/mastering_display_metadata.h>
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/audio_file_reader.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/audio_file_reader.cc
+--- a/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -85,7 +85,7 @@ bool AudioFileReader::OpenDemuxer() {
+ }
+ 
+ bool AudioFileReader::OpenDecoder() {
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (codec) {
+     // MP3 decodes to S16P which we don't support, tell it to use S16 instead.
+     if (codec_context_->sample_fmt == AV_SAMPLE_FMT_S16P)
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -329,7 +329,7 @@ bool FFmpegAudioDecoder::ConfigureDecode
+     }
+   }
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec ||
+       avcodec_open2(codec_context_.get(), codec, &codec_options) < 0) {
+     DLOG(ERROR) << "Could not initialize audio decoder: "
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -59,7 +59,6 @@ static int64_t AVIOSeekOperation(void* o
+ }
+ 
+ void FFmpegGlue::InitializeFFmpeg() {
+-  av_register_all();
+ }
+ 
+ static void LogContainer(bool is_local_file,
+@@ -95,9 +94,6 @@ FFmpegGlue::FFmpegGlue(FFmpegURLProtocol
+   // Enable fast, but inaccurate seeks for MP3.
+   format_context_->flags |= AVFMT_FLAG_FAST_SEEK;
+ 
+-  // Ensures we can read out various metadata bits like vp8 alpha.
+-  format_context_->flags |= AVFMT_FLAG_KEEP_SIDE_DATA;
+-
+   // Ensures format parsing errors will bail out. From an audit on 11/2017, all
+   // instances were real failures. Solves bugs like http://crbug.com/710791.
+   format_context_->error_recognition |= AV_EF_EXPLODE;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -391,7 +391,7 @@ bool FFmpegVideoDecoder::ConfigureDecode
+   if (decode_nalus_)
+     codec_context_->flags2 |= AV_CODEC_FLAG2_CHUNKS;
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
+     ReleaseFFmpegResources();
+     return false;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/media_file_checker.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/media_file_checker.cc
+--- a/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -68,7 +68,7 @@ bool MediaFileChecker::Start(base::TimeD
+       auto context = AVStreamToAVCodecContext(format_context->streams[i]);
+       if (!context)
+         continue;
+-      AVCodec* codec = avcodec_find_decoder(cp->codec_id);
++      const AVCodec* codec = avcodec_find_decoder(cp->codec_id);
+       if (codec && avcodec_open2(context.get(), codec, nullptr) >= 0) {
+         auto loop = std::make_unique<FFmpegDecodingLoop>(context.get());
+         stream_contexts[i] = {std::move(context), std::move(loop)};
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc qtwebengine-5.15.10/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc
+--- a/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -203,7 +203,7 @@ int32_t H264DecoderImpl::InitDecode(cons
+   // a pointer |this|.
+   av_context_->opaque = this;
+ 
+-  AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
+   if (!codec) {
+     // This is an indication that FFmpeg has not been initialized or it has not
+     // been compiled/initialized with the correct set of codecs.
diff --git a/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch b/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch
new file mode 100644
index 00000000000000..bc24d5b9a29cb5
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch
@@ -0,0 +1,14 @@
+--- a/src/buildtools/configure.json	2023-12-09 11:06:01.503058569 -0500
++++ b/src/buildtools/configure.json	2023-12-09 11:06:14.982361345 -0500
+@@ -779,11 +779,6 @@
+             "type": "warning",
+             "condition": "config.ios && config.simulator && config.device && features.build-qtpdf",
+             "message": "Building fat libray with device and simulator architectures will disable NEON."
+-        },
+-        {
+-            "type": "fatal",
+-            "condition": "features.webengine-system-ffmpeg && !libs.webengine-ffmpeg-support",
+-            "message": "Unmodified ffmpeg >= 5.0 is not supported. Please configure with -qt-webengine-ffmpeg."
+         }
+     ],
+     "summary": [
diff --git a/srcpkgs/qt5-webengine/template b/srcpkgs/qt5-webengine/template
index 8d2df1b5175bad..1687a77eb8a2f5 100644
--- a/srcpkgs/qt5-webengine/template
+++ b/srcpkgs/qt5-webengine/template
@@ -1,14 +1,14 @@
 # Template file for 'qt5-webengine'
 pkgname=qt5-webengine
 version=5.15.16
-revision=1
+revision=2
 _version="${version}-lts"
 _chromium_commit=207c2ac45ca3386d153770c6b0d2ea2ec21ca880
 archs="x86_64* i686* armv[67]* ppc64* aarch64*"
 create_wrksrc=yes
 build_style=qmake
 configure_args="--
- -webengine-icu -webengine-ffmpeg -webengine-opus -webengine-webp
+ -webengine-icu -system-ffmpeg -webengine-opus -webengine-webp
  -webengine-pepper-plugins -webengine-printing-and-pdf -webengine-proprietary-codecs
  -webengine-pulseaudio -webengine-spellchecker -webengine-webrtc -webengine-geolocation
  -webengine-kerberos -no-webengine-embedded-build $(vopt_if sndio '' '-no')-webengine-sndio

From 0849664d5ff3aa3b75a2a5673d5f70bcab8ea146 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 058/109] qt5: revbump for ffmpeg6

---
 srcpkgs/qt5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5/template b/srcpkgs/qt5/template
index 3efb7e42d5fd3f..27f6d5388cd15c 100644
--- a/srcpkgs/qt5/template
+++ b/srcpkgs/qt5/template
@@ -3,9 +3,9 @@
 # revbump libqtxdg after bumping patch version
 pkgname=qt5
 version=5.15.11+20231124
+revision=3
 # commit 4765fa1df7a837db9c1f89c4da0dd76b74bb5fab
 # base repo: https://invent.kde.org/qt/qt/qt5
-revision=2
 build_style=meta
 hostmakedepends="cmake clang17 flex perl glib-devel pkg-config
  python3 re2c ruby which"

From 79334efa817e349662a08cb81398479fd9722ecc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 059/109] qtav: revbump for ffmpeg4

---
 srcpkgs/qtav/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtav/template b/srcpkgs/qtav/template
index 775d5a139a9efa..aa69e213c984b0 100644
--- a/srcpkgs/qtav/template
+++ b/srcpkgs/qtav/template
@@ -1,10 +1,10 @@
 # Template file for 'qtav'
 pkgname=qtav
 version=1.13.0
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel libass-devel libopenal-devel
+makedepends="ffmpeg4-devel libass-devel libopenal-devel
  libva-glx-devel libXv-devel pulseaudio-devel
  qt5-declarative-devel qt5-svg-devel
  qt5-quickcontrols"

From 8f9221fb973879754b61029a5ae42723553f339a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 060/109] retroarch: revbump for ffmpeg6

---
 srcpkgs/retroarch/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroarch/template b/srcpkgs/retroarch/template
index cb3125c5dbf1ae..c65c26f7bf0332 100644
--- a/srcpkgs/retroarch/template
+++ b/srcpkgs/retroarch/template
@@ -1,7 +1,7 @@
 # Template file for 'retroarch'
 pkgname=retroarch
 version=1.16.0.3
-revision=3
+revision=4
 build_style=configure
 configure_args="--prefix=/usr --sysconfdir=/etc --enable-networking
  --enable-udev --disable-builtinflac --disable-builtinglslang

From 423a39b24628cc40ded645f37da93a0de0103b8d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 061/109] scrcpy: revbump for ffmpeg6

---
 srcpkgs/scrcpy/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/scrcpy/template b/srcpkgs/scrcpy/template
index d04de770dc1913..5218fa01f8ce1f 100644
--- a/srcpkgs/scrcpy/template
+++ b/srcpkgs/scrcpy/template
@@ -1,7 +1,7 @@
 # Template file for 'scrcpy'
 pkgname=scrcpy
 version=2.3.1
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcompile_server=false
  -Dprebuilt_server=/usr/share/scrcpy/scrcpy-server-v${version}"

From f6d229e9a2556a35c46c0dc01e5c63500f660a09 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 17 Oct 2023 08:54:11 -0400
Subject: [PATCH 062/109] New package: spex-x replaces spek-alternative for
 ffmpeg6

---
 srcpkgs/spek-alternative                      |  1 +
 srcpkgs/spek-x/patches/musl.patch             |  7 ++++++
 srcpkgs/{spek-alternative => spek-x}/template | 22 ++++++++++++-------
 3 files changed, 22 insertions(+), 8 deletions(-)
 create mode 120000 srcpkgs/spek-alternative
 create mode 100644 srcpkgs/spek-x/patches/musl.patch
 rename srcpkgs/{spek-alternative => spek-x}/template (52%)

diff --git a/srcpkgs/spek-alternative b/srcpkgs/spek-alternative
new file mode 120000
index 00000000000000..76648236da7017
--- /dev/null
+++ b/srcpkgs/spek-alternative
@@ -0,0 +1 @@
+spek-x
\ No newline at end of file
diff --git a/srcpkgs/spek-x/patches/musl.patch b/srcpkgs/spek-x/patches/musl.patch
new file mode 100644
index 00000000000000..662f45936febc6
--- /dev/null
+++ b/srcpkgs/spek-x/patches/musl.patch
@@ -0,0 +1,7 @@
+--- a/tests/perf.cc	2024-03-09 17:13:49.086603418 -0500
++++ b/tests/perf.cc	2024-03-09 17:13:59.453603753 -0500
+@@ -1,3 +1,4 @@
++#include <cstdint>
+ #include <cstdlib>
+ #include <iostream>
+ #include <fstream>
diff --git a/srcpkgs/spek-alternative/template b/srcpkgs/spek-x/template
similarity index 52%
rename from srcpkgs/spek-alternative/template
rename to srcpkgs/spek-x/template
index d7b55c776b1d43..3ded6c2c323e4f 100644
--- a/srcpkgs/spek-alternative/template
+++ b/srcpkgs/spek-x/template
@@ -1,18 +1,18 @@
-# Template file for 'spek-alternative'
-pkgname=spek-alternative
-version=0.8.2.3
-revision=2
+# Template file for 'spek-x'
+pkgname=spek-x
+version=0.9.3
+revision=1
 build_style=gnu-configure
 hostmakedepends="automake gettext-devel intltool libtool pkg-config
  wxWidgets-common wxWidgets-gtk3-devel"
 makedepends="ffmpeg-devel wxWidgets-gtk3-devel"
 depends="ffmpeg"
 short_desc="Acoustic spectrum analyser"
-maintainer="Kartik Singh <kartik.ynwa@gmail.com>"
+maintainer="zlice <zlice555@gmail.com>"
 license="GPL-3.0-or-later"
-homepage="https://github.com/withmorten/spek-alternative"
-distfiles="https://github.com/withmorten/spek-alternative/archive/${version}.tar.gz"
-checksum="007ba4b84a310b078e378aa84c8e80783db5821437a757a488c3ecec377e6b2a"
+homepage="https://github.com/MikeWang000000/spek-x"
+distfiles="https://github.com/MikeWang000000/spek-x/archive/v${version}.tar.gz"
+checksum="7f4b109903333cdd310ab2b9176f0dc49a565891376e281a233d342cedf90ef7"
 
 CXXFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
 
@@ -22,3 +22,9 @@ export WX_CONFIG_NAME="wx-config-gtk3"
 pre_configure() {
 	NOCONFIGURE=1 ./autogen.sh
 }
+
+spek-alternative_package() {
+	depends="spek-x"
+	short_desc+=" - transitional dummy package"
+	build_style=meta
+}

From 0a9d3bb0b40b18a336fa9479961b1bf111439407 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 063/109] ssr: revbump for ffmpeg6

---
 .../0001-Fix-build-with-ffmpeg-5.0.patch      | 241 ++++++++++++++++++
 srcpkgs/ssr/template                          |   2 +-
 2 files changed, 242 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ssr/patches/0001-Fix-build-with-ffmpeg-5.0.patch

diff --git a/srcpkgs/ssr/patches/0001-Fix-build-with-ffmpeg-5.0.patch b/srcpkgs/ssr/patches/0001-Fix-build-with-ffmpeg-5.0.patch
new file mode 100644
index 00000000000000..4c069b5a9fc464
--- /dev/null
+++ b/srcpkgs/ssr/patches/0001-Fix-build-with-ffmpeg-5.0.patch
@@ -0,0 +1,241 @@
+From f4cbde38021d9330dc73d2e3dfa8a70da3ff5721 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Bernhard=20Rosenkr=C3=A4nzer?= <bero@lindev.ch>
+Date: Sun, 16 Jan 2022 02:40:04 +0100
+Subject: [PATCH] Fix build with ffmpeg 5.0
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Adapt to ffmpeg 5.0 requiring more const-ness for AVCodec.
+
+Signed-off-by: Bernhard Rosenkränzer <bero@lindev.ch>
+---
+ src/AV/Output/AudioEncoder.cpp |  6 +++---
+ src/AV/Output/AudioEncoder.h   |  4 ++--
+ src/AV/Output/BaseEncoder.cpp  |  4 ++--
+ src/AV/Output/BaseEncoder.h    |  4 ++--
+ src/AV/Output/Muxer.cpp        | 12 ++++++------
+ src/AV/Output/Muxer.h          |  4 ++--
+ src/AV/Output/VideoEncoder.cpp |  6 +++---
+ src/AV/Output/VideoEncoder.h   |  4 ++--
+ 8 files changed, 22 insertions(+), 22 deletions(-)
+
+diff --git a/src/AV/Output/AudioEncoder.cpp b/src/AV/Output/AudioEncoder.cpp
+index 34d015c..cefc2e0 100644
+--- a/src/AV/Output/AudioEncoder.cpp
++++ b/src/AV/Output/AudioEncoder.cpp
+@@ -34,7 +34,7 @@ const std::vector<AudioEncoder::SampleFormatData> AudioEncoder::SUPPORTED_SAMPLE
+ 
+ const unsigned int AudioEncoder::DEFAULT_FRAME_SAMPLES = 1024;
+ 
+-AudioEncoder::AudioEncoder(Muxer* muxer, AVStream* stream, AVCodecContext *codec_context, AVCodec* codec, AVDictionary** options)
++AudioEncoder::AudioEncoder(Muxer* muxer, AVStream* stream, AVCodecContext *codec_context, const AVCodec* codec, AVDictionary** options)
+ 	: BaseEncoder(muxer, stream, codec_context, codec, options) {
+ 
+ #if !SSR_USE_AVCODEC_ENCODE_AUDIO2
+@@ -77,7 +77,7 @@ unsigned int AudioEncoder::GetSampleRate() {
+ }
+ 
+ bool AudioEncoder::AVCodecIsSupported(const QString& codec_name) {
+-	AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
++	const AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
+ 	if(codec == NULL)
+ 		return false;
+ 	if(!av_codec_is_encoder(codec))
+@@ -93,7 +93,7 @@ bool AudioEncoder::AVCodecIsSupported(const QString& codec_name) {
+ 	return false;
+ }
+ 
+-void AudioEncoder::PrepareStream(AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
++void AudioEncoder::PrepareStream(AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
+ 								 unsigned int bit_rate, unsigned int channels, unsigned int sample_rate) {
+ 
+ 	if(channels == 0) {
+diff --git a/src/AV/Output/AudioEncoder.h b/src/AV/Output/AudioEncoder.h
+index c93278c..ae9c82e 100644
+--- a/src/AV/Output/AudioEncoder.h
++++ b/src/AV/Output/AudioEncoder.h
+@@ -40,7 +40,7 @@ private:
+ #endif
+ 
+ public:
+-	AudioEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options);
++	AudioEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options);
+ 	~AudioEncoder();
+ 
+ 	// Returns the required frame size, i.e. the number of samples (for each channel).
+@@ -57,7 +57,7 @@ public:
+ 
+ public:
+ 	static bool AVCodecIsSupported(const QString& codec_name);
+-	static void PrepareStream(AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
++	static void PrepareStream(AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
+ 							  unsigned int bit_rate, unsigned int channels, unsigned int sample_rate);
+ 
+ private:
+diff --git a/src/AV/Output/BaseEncoder.cpp b/src/AV/Output/BaseEncoder.cpp
+index 7c01ef3..4780aaf 100644
+--- a/src/AV/Output/BaseEncoder.cpp
++++ b/src/AV/Output/BaseEncoder.cpp
+@@ -42,7 +42,7 @@ double ParseCodecOptionDouble(const QString& key, const QString& value, double m
+ 	return clamp(value_double, min, max) * multiply;
+ }
+ 
+-BaseEncoder::BaseEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options) {
++BaseEncoder::BaseEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options) {
+ 
+ 	m_muxer = muxer;
+ 	m_stream = stream;
+@@ -157,7 +157,7 @@ void BaseEncoder::IncrementPacketCounter() {
+ 	++lock->m_total_packets;
+ }
+ 
+-void BaseEncoder::Init(AVCodec* codec, AVDictionary** options) {
++void BaseEncoder::Init(const AVCodec* codec, AVDictionary** options) {
+ 
+ 	// open codec
+ 	if(avcodec_open2(m_codec_context, codec, options) < 0) {
+diff --git a/src/AV/Output/BaseEncoder.h b/src/AV/Output/BaseEncoder.h
+index 3d92f29..7f02bbd 100644
+--- a/src/AV/Output/BaseEncoder.h
++++ b/src/AV/Output/BaseEncoder.h
+@@ -51,7 +51,7 @@ private:
+ 	std::atomic<bool> m_should_stop, m_should_finish, m_is_done, m_error_occurred;
+ 
+ protected:
+-	BaseEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options);
++	BaseEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options);
+ 
+ public:
+ 	virtual ~BaseEncoder(); // encoders will be deleted by Muxer, don't delete them yourself!
+@@ -117,7 +117,7 @@ protected:
+ 	void IncrementPacketCounter();
+ 
+ private:
+-	void Init(AVCodec* codec, AVDictionary** options);
++	void Init(const AVCodec* codec, AVDictionary** options);
+ 	void Free();
+ 
+ 	void EncoderThread();
+diff --git a/src/AV/Output/Muxer.cpp b/src/AV/Output/Muxer.cpp
+index ad58380..14650b0 100644
+--- a/src/AV/Output/Muxer.cpp
++++ b/src/AV/Output/Muxer.cpp
+@@ -87,7 +87,7 @@ Muxer::~Muxer() {
+ 
+ VideoEncoder* Muxer::AddVideoEncoder(const QString& codec_name, const std::vector<std::pair<QString, QString> >& codec_options,
+ 									 unsigned int bit_rate, unsigned int width, unsigned int height, unsigned int frame_rate) {
+-	AVCodec *codec = FindCodec(codec_name);
++	const AVCodec *codec = FindCodec(codec_name);
+ 	AVCodecContext *codec_context = NULL;
+ 	AVStream *stream = AddStream(codec, &codec_context);
+ 	VideoEncoder *encoder;
+@@ -111,7 +111,7 @@ VideoEncoder* Muxer::AddVideoEncoder(const QString& codec_name, const std::vecto
+ 
+ AudioEncoder* Muxer::AddAudioEncoder(const QString& codec_name, const std::vector<std::pair<QString, QString> >& codec_options,
+ 									 unsigned int bit_rate, unsigned int channels, unsigned int sample_rate) {
+-	AVCodec *codec = FindCodec(codec_name);
++	const AVCodec *codec = FindCodec(codec_name);
+ 	AVCodecContext *codec_context = NULL;
+ 	AVStream *stream = AddStream(codec, &codec_context);
+ 	AudioEncoder *encoder;
+@@ -194,7 +194,7 @@ unsigned int Muxer::GetQueuedPacketCount(unsigned int stream_index) {
+ void Muxer::Init() {
+ 
+ 	// get the format we want (this is just a pointer, we don't have to free this)
+-	AVOutputFormat *format = av_guess_format(m_container_name.toUtf8().constData(), NULL, NULL);
++	const AVOutputFormat *format = av_guess_format(m_container_name.toUtf8().constData(), NULL, NULL);
+ 	if(format == NULL) {
+ 		Logger::LogError("[Muxer::Init] " + Logger::tr("Error: Can't find chosen output format!"));
+ 		throw LibavException();
+@@ -261,8 +261,8 @@ void Muxer::Free() {
+ 	}
+ }
+ 
+-AVCodec* Muxer::FindCodec(const QString& codec_name) {
+-	AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
++const AVCodec* Muxer::FindCodec(const QString& codec_name) {
++	const AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
+ 	if(codec == NULL) {
+ 		Logger::LogError("[Muxer::FindCodec] " + Logger::tr("Error: Can't find codec!"));
+ 		throw LibavException();
+@@ -270,7 +270,7 @@ AVCodec* Muxer::FindCodec(const QString& codec_name) {
+ 	return codec;
+ }
+ 
+-AVStream* Muxer::AddStream(AVCodec* codec, AVCodecContext** codec_context) {
++AVStream* Muxer::AddStream(const AVCodec* codec, AVCodecContext** codec_context) {
+ 	assert(!m_started);
+ 	assert(m_format_context->nb_streams < MUXER_MAX_STREAMS);
+ 
+diff --git a/src/AV/Output/Muxer.h b/src/AV/Output/Muxer.h
+index d72347d..b104bcb 100644
+--- a/src/AV/Output/Muxer.h
++++ b/src/AV/Output/Muxer.h
+@@ -114,8 +114,8 @@ private:
+ 	void Init();
+ 	void Free();
+ 
+-	AVCodec* FindCodec(const QString& codec_name);
+-	AVStream* AddStream(AVCodec* codec, AVCodecContext** codec_context);
++	const AVCodec* FindCodec(const QString& codec_name);
++	AVStream* AddStream(const AVCodec* codec, AVCodecContext** codec_context);
+ 
+ 	void MuxerThread();
+ 
+diff --git a/src/AV/Output/VideoEncoder.cpp b/src/AV/Output/VideoEncoder.cpp
+index 8087e8e..fc8b5d1 100644
+--- a/src/AV/Output/VideoEncoder.cpp
++++ b/src/AV/Output/VideoEncoder.cpp
+@@ -34,7 +34,7 @@ const std::vector<VideoEncoder::PixelFormatData> VideoEncoder::SUPPORTED_PIXEL_F
+ 	{"rgb", AV_PIX_FMT_RGB24, false},
+ };
+ 
+-VideoEncoder::VideoEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options)
++VideoEncoder::VideoEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options)
+ 	: BaseEncoder(muxer, stream, codec_context, codec, options) {
+ 
+ #if !SSR_USE_AVCODEC_ENCODE_VIDEO2
+@@ -95,7 +95,7 @@ unsigned int VideoEncoder::GetFrameRate() {
+ }
+ 
+ bool VideoEncoder::AVCodecIsSupported(const QString& codec_name) {
+-	AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
++	const AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
+ 	if(codec == NULL)
+ 		return false;
+ 	if(!av_codec_is_encoder(codec))
+@@ -111,7 +111,7 @@ bool VideoEncoder::AVCodecIsSupported(const QString& codec_name) {
+ 	return false;
+ }
+ 
+-void VideoEncoder::PrepareStream(AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
++void VideoEncoder::PrepareStream(AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
+ 								 unsigned int bit_rate, unsigned int width, unsigned int height, unsigned int frame_rate) {
+ 
+ 	if(width == 0 || height == 0) {
+diff --git a/src/AV/Output/VideoEncoder.h b/src/AV/Output/VideoEncoder.h
+index cb7ca27..68d872e 100644
+--- a/src/AV/Output/VideoEncoder.h
++++ b/src/AV/Output/VideoEncoder.h
+@@ -40,7 +40,7 @@ private:
+ #endif
+ 
+ public:
+-	VideoEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options);
++	VideoEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options);
+ 	~VideoEncoder();
+ 
+ 	// Returns the required pixel format.
+@@ -55,7 +55,7 @@ public:
+ 
+ public:
+ 	static bool AVCodecIsSupported(const QString& codec_name);
+-	static void PrepareStream(AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
++	static void PrepareStream(AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
+ 							  unsigned int bit_rate, unsigned int width, unsigned int height, unsigned int frame_rate);
+ 
+ private:
+-- 
+2.43.0
+
diff --git a/srcpkgs/ssr/template b/srcpkgs/ssr/template
index 3097754e3cbe54..e3c4261f1f5a64 100644
--- a/srcpkgs/ssr/template
+++ b/srcpkgs/ssr/template
@@ -1,7 +1,7 @@
 # Template file for 'ssr'
 pkgname=ssr
 version=0.4.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DWITH_QT5=ON"
 hostmakedepends="pkg-config"

From ce396c3c2728a776e914a3579bd15ef58c25d648 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 064/109] synfig: revbump for ffmpeg6 and mlt7

---
 srcpkgs/synfig/patches/ffmpeg6.patch | 71 ++++++++++++++++++++++++++++
 srcpkgs/synfig/template              |  6 +--
 2 files changed, 74 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/synfig/patches/ffmpeg6.patch

diff --git a/srcpkgs/synfig/patches/ffmpeg6.patch b/srcpkgs/synfig/patches/ffmpeg6.patch
new file mode 100644
index 00000000000000..10780b42782f4b
--- /dev/null
+++ b/srcpkgs/synfig/patches/ffmpeg6.patch
@@ -0,0 +1,71 @@
+--- a/src/modules/mod_libavcodec/trgt_av.cpp	2022-10-25 09:14:12.000000000 -0400
++++ b/src/modules/mod_libavcodec/trgt_av.cpp	2023-05-05 21:34:17.899194559 -0400
+@@ -38,6 +41,7 @@
+ extern "C"
+ {
+ #ifdef HAVE_LIBAVFORMAT_AVFORMAT_H
++#	include <libavcodec/avcodec.h>
+ #	include <libavformat/avformat.h>
+ #elif defined(HAVE_AVFORMAT_H)
+ #	include <avformat.h>
+@@ -155,11 +156,11 @@
+     }
+ 
+ 	bool open_video_stream() {
+-		if (avcodec_open2(video_context, NULL, NULL) < 0) {
++		if (avcodec_open2(video_context, nullptr, nullptr) < 0) {
+ 			synfig::error("Target_LibAVCodec: could not open video codec");
+ 			// seems the calling of avcodec_free_context after error will cause crash
+ 			// so just forget about this context
+-			video_context = NULL;
++			video_context = nullptr;
+ 			close();
+ 			return false;
+         }
+@@ -234,15 +235,21 @@
+ 		close();
+ 
+ 		if (!av_registered) {
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 			av_register_all();
++#endif
+ 			av_registered = true;
+ 		}
+ 
+ 		// guess format
+-		AVOutputFormat *format = av_guess_format(NULL, filename.c_str(), NULL);
++#if LIBAVCODEC_VERSION_MAJOR < 59 // FFMPEG < 5.0
++		AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#else
++		const AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#endif
+ 		if (!format) {
+ 			synfig::warning("Target_LibAVCodec: unable to guess the output format, defaulting to MPEG");
+-			format = av_guess_format("mpeg", NULL, NULL);
++			format = av_guess_format("mpeg", nullptr, nullptr);
+ 		}
+ 		if (!format) {
+ 			synfig::error("Target_LibAVCodec: unable to find 'mpeg' output format");
+@@ -254,6 +261,7 @@
+ 		context = avformat_alloc_context();
+ 		assert(context);
+ 		context->oformat = format;
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 		if (filename.size() + 1 > sizeof(context->filename)) {
+ 			synfig::error(
+ 				"Target_LibAVCodec: filename too long, max length is %d, filename is '%s'",
+@@ -263,6 +271,14 @@
+ 			return false;
+ 		}
+ 		memcpy(context->filename, filename.c_str(), filename.size() + 1);
++#else
++		context->url = av_strndup(filename.c_str(), filename.size());
++		if (!context->url) {
++			synfig::error("Target_LibAVCodec: cannot allocate space for filename");
++			close();
++			return false;
++		}
++#endif
+ 
+ 		packet = av_packet_alloc();
+ 		assert(packet);
diff --git a/srcpkgs/synfig/template b/srcpkgs/synfig/template
index d4d3e341a20bf8..828b5cb32956ee 100644
--- a/srcpkgs/synfig/template
+++ b/srcpkgs/synfig/template
@@ -2,11 +2,11 @@
 # Should be kept in sync with 'synfigstudio' and 'ETL'
 pkgname=synfig
 version=1.4.4
-revision=4
+revision=5
 build_style=gnu-configure
 configure_args="--with-boost-libdir=${XBPS_CROSS_BASE}/usr/lib"
 hostmakedepends="boost-build ImageMagick pkg-config intltool"
-makedepends="ETL gettext-devel libxml++-devel mlt-devel libmagick-devel
+makedepends="ETL gettext-devel libxml++-devel mlt7-devel libmagick-devel
  libmng-devel boost-build boost-devel libopenexr-devel ffmpeg-devel"
 depends="ImageMagick"
 short_desc="CLI 2D vector and timeline-based animation software"
@@ -20,7 +20,7 @@ CXXFLAGS="-std=c++11 -DHAVE_LOCALE_H=1"
 
 synfig-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision}
-	 libopenexr-devel libxml++-devel mlt-devel"
+	 libopenexr-devel libxml++-devel mlt7-devel"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/bin/synfig-config

From 23bc8cd9e67291ccc6be31d61d91f6703282a5e5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 065/109] timg: revbump for ffmpeg6

---
 srcpkgs/timg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/timg/template b/srcpkgs/timg/template
index 2a2ab763d2fddf..8fb4327535ef93 100644
--- a/srcpkgs/timg/template
+++ b/srcpkgs/timg/template
@@ -1,7 +1,7 @@
 # Template file for 'timg'
 pkgname=timg
 version=1.4.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_OPENSLIDE_SUPPORT=off -Wno-dev"
 hostmakedepends="pkg-config git"

From ba0de81567503462ad6dd736afe23afa776f4525 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 066/109] tvheadend: revbump for ffmpeg4

---
 srcpkgs/tvheadend/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tvheadend/template b/srcpkgs/tvheadend/template
index 9aea7de4ec7057..012d31c4879ff1 100644
--- a/srcpkgs/tvheadend/template
+++ b/srcpkgs/tvheadend/template
@@ -8,7 +8,7 @@ configure_args="--enable-dvbscan --disable-ffmpeg_static
 --disable-libx265_static --disable-libvpx_static --disable-libtheora_static
 --disable-libvorbis_static --disable-libfdkaac_static"
 hostmakedepends="gettext pkg-config python3 git which"
-makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg-devel"
+makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg4-devel"
 short_desc="TV streaming server"
 maintainer="lemmi <lemmi@nerd2nerd.org>"
 license="GPL-3.0-only"

From 86a48f96756f49dc3c2820690dcc2cd564d0af80 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 067/109] unpaper: update to 7.0.0.

---
 srcpkgs/unpaper/template | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/srcpkgs/unpaper/template b/srcpkgs/unpaper/template
index 38ed47a5840165..1ff910e722afc8 100644
--- a/srcpkgs/unpaper/template
+++ b/srcpkgs/unpaper/template
@@ -1,13 +1,13 @@
 # Template file for 'unpaper'
 pkgname=unpaper
-version=6.1
-revision=3
-build_style=gnu-configure
+version=7.0.0
+revision=1
+build_style=meson
+hostmakedepends="pkg-config meson libxslt"
+makedepends="ffmpeg-devel python3-Sphinx"
+short_desc="Post-processing tool for scanned sheets of paper"
 maintainer="Orphaned <orphan@voidlinux.org>"
-hostmakedepends="pkg-config libxslt"
-makedepends="ffmpeg-devel"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://www.flameeyes.eu/projects/unpaper"
-short_desc="A post-processing tool for scanned sheets of paper"
 distfiles="https://www.flameeyes.eu/files/${pkgname}-${version}.tar.xz"
-checksum=237c84f5da544b3f7709827f9f12c37c346cdf029b1128fb4633f9bafa5cb930
+checksum=2575fbbf26c22719d1cb882b59602c9900c7f747118ac130883f63419be46a80

From 1f223746762046f622a56c5629ca86101aaa2fdc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 068/109] vice: revbump for ffmpeg4

---
 srcpkgs/vice/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vice/template b/srcpkgs/vice/template
index 1c641d9ae9be22..4f43e85b5b8972 100644
--- a/srcpkgs/vice/template
+++ b/srcpkgs/vice/template
@@ -1,7 +1,7 @@
 # Template file for 'vice'
 pkgname=vice
 version=3.8
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-cpuhistory --enable-x64 --disable-pdf-docs
  --libdir=/usr/lib$XBPS_TARGET_WORDSIZE $(vopt_enable sdl2 sdlui2)

From d13b19e144fd8014ff33a9b80028282ccdcf638c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 069/109] waypipe: revbump for ffmpeg6

---
 srcpkgs/waypipe/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waypipe/template b/srcpkgs/waypipe/template
index 6da88b21bf2a19..4da8058400b588 100644
--- a/srcpkgs/waypipe/template
+++ b/srcpkgs/waypipe/template
@@ -1,7 +1,7 @@
 # Template file for 'waypipe'
 pkgname=waypipe
 version=0.8.6
-revision=1
+revision=2
 build_style=meson
 # lto is off because it causes linking errors in armv6l and armv7l (due to NEON)
 configure_args="-Dwerror=false -Dwith_dmabuf=enabled -Dwith_lz4=enabled

From 04b50e9c7587ba73d06dd7150105c96e1a94c5b0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 070/109] xpra: revbump for ffmpeg6

---
 srcpkgs/xpra/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xpra/template b/srcpkgs/xpra/template
index 3e49ab23deac9c..3939026a6fbf90 100644
--- a/srcpkgs/xpra/template
+++ b/srcpkgs/xpra/template
@@ -1,7 +1,7 @@
 # Template file for 'xpra'
 pkgname=xpra
 version=5.0.7
-revision=1
+revision=2
 build_style=python3-module
 make_build_args="--without-cuda_kernels --without-cuda_rebuild"
 make_install_args="$(vopt_with docs) ${make_build_args}"

From e39f20d48cdf6436d6952133ff41b77d7824f21e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:07:40 -0400
Subject: [PATCH 071/109] nv-codec-headers: update to 12.0.16.0

---
 srcpkgs/nv-codec-headers/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/nv-codec-headers/template b/srcpkgs/nv-codec-headers/template
index 3d422a61e48917..251e057f826fb8 100644
--- a/srcpkgs/nv-codec-headers/template
+++ b/srcpkgs/nv-codec-headers/template
@@ -1,6 +1,6 @@
 # Template file for 'nv-codec-headers'
 pkgname=nv-codec-headers
-version=11.1.5.1
+version=12.0.16.0
 revision=1
 build_style=gnu-makefile
 short_desc="FFmpeg version of headers required to interface with Nvidias codec APIs"
@@ -8,7 +8,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="MIT"
 homepage="http://git.videolan.org/?p=ffmpeg/nv-codec-headers.git"
 distfiles="https://github.com/FFmpeg/nv-codec-headers/archive/n${version}.tar.gz"
-checksum=d095fbd56aa93772471a323be0ebe65504a0f43f06c76a30b6d25da77b06ae9c
+checksum=2a1533b65f55f9da52956faf0627ed3b74868ac0c7f269990edd21369113b48f
 
 post_install() {
 	sed -n '4,25p' include/ffnvcodec/nvEncodeAPI.h > LICENSE

From 844ac6937b072ca44494783ba18b89375c1f9b7a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:08:40 -0400
Subject: [PATCH 072/109] openimagedenoise: revbump for ffmpeg6

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index 109deb171c3f75..44edf38fb289d8 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,7 +1,7 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
 version=1.4.3
-revision=2
+revision=3
 archs="x86_64*"
 build_style=cmake
 hostmakedepends="ispc python3"

From b9c5e2d2917212e82953f634dbf535129dbc518f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:31:45 -0400
Subject: [PATCH 073/109] shotcut: revbump for ffmpeg6

---
 srcpkgs/shotcut/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/shotcut/template b/srcpkgs/shotcut/template
index 33141fbd862d7a..f46cb53b6bfb92 100644
--- a/srcpkgs/shotcut/template
+++ b/srcpkgs/shotcut/template
@@ -1,7 +1,7 @@
 # Template file for 'shotcut'
 pkgname=shotcut
 version=23.09.29
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSHOTCUT_VERSION=${version}"
 hostmakedepends="pkg-config qt6-tools-devel"

From 98782353c7d9dc5842487ca1dd3185efad02db18 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:30 -0400
Subject: [PATCH 074/109] shiboken2: revbump for qt5-5.15.11

---
 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch | 1 +
 1 file changed, 1 insertion(+)
 create mode 120000 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
new file mode 120000
index 00000000000000..efcf3249bd8854
--- /dev/null
+++ b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1 @@
+../../python3-pyside2/patches/importlib-machinery-bypass.patch
\ No newline at end of file

From a8fe3fe4f5b596bb09a92ad36931c10d0a4fd77a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:53 -0400
Subject: [PATCH 075/109] python3-pyside2: revbump for qt5-5.15.11

---
 .../patches/importlib-machinery-bypass.patch      | 15 +++++++++++++++
 srcpkgs/python3-pyside2/template                  |  2 +-
 2 files changed, 16 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
new file mode 100644
index 00000000000000..64c429584776b5
--- /dev/null
+++ b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1,15 @@
+Using this prevents an error around line 220 below it.
+"AttributeError: module 'importlib' has no attribute 'machinery'"
+The old backup logic is in place and compiles without issues.
+--- a/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:09:34.688912402 -0400
++++ b/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:10:03.395529582 -0400
+@@ -170,9 +170,6 @@
+
+     # 'zipstring_sequence' comes from signature.cpp
+     zipbytes = base64.b64decode(''.join(zipstring_sequence))
+-    if sys.version_info[0] >= 3:
+-        vzip = zipfile.ZipFile(io.BytesIO(zipbytes))
+-        return sys.meta_path, EmbeddableZipImporter(vzip)
+
+     # Old version for Python 2.7, only.
+     import os
diff --git a/srcpkgs/python3-pyside2/template b/srcpkgs/python3-pyside2/template
index 249efa90988425..52626436ce75f2 100644
--- a/srcpkgs/python3-pyside2/template
+++ b/srcpkgs/python3-pyside2/template
@@ -1,7 +1,7 @@
 # Template file for 'python3-pyside2'
 pkgname=python3-pyside2
 version=5.15.10
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/pyside2"
 build_style=cmake

From 42bebd2f98d93bccdb480572c4dd11675e1dc52a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:35 -0400
Subject: [PATCH 076/109] konqueror: revbump for ffmpeg6

---
 srcpkgs/konqueror/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/konqueror/template b/srcpkgs/konqueror/template
index add972916753c6..50bbf4eec05e55 100644
--- a/srcpkgs/konqueror/template
+++ b/srcpkgs/konqueror/template
@@ -1,11 +1,11 @@
 # Template file for 'konqueror'
 pkgname=konqueror
 version=23.08.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DDESKTOPTOJSON_EXECUTABLE=/usr/bin/desktoptojson"
 hostmakedepends="extra-cmake-modules python3 qt5-host-tools qt5-qmake kdoctools
-kcoreaddons kconfig gettext"
+ kcoreaddons kconfig gettext"
 makedepends="qt5-devel qt5-webengine-devel qt5-declarative-devel
  qt5-webchannel-devel qt5-location-devel kcmutils-devel kdelibs4support-devel
  karchive-devel khtml-devel kdesu-devel kactivities5-devel"

From 38eb3f0b32c7c3af5f2164bbc8e7dcb14e525042 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:58 -0400
Subject: [PATCH 077/109] qt5-speech: revbump for qt5-5.15.11

---
 srcpkgs/qt5-speech/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-speech/template b/srcpkgs/qt5-speech/template
index 1228bb60c41db4..27a7da1dbdb91b 100644
--- a/srcpkgs/qt5-speech/template
+++ b/srcpkgs/qt5-speech/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-speech'
 pkgname=qt5-speech
 version=5.15.11
-revision=1
+revision=2
 _commit=d32f4a479d38a11f547598004b975f4356424a16
 build_style=qmake
 configure_args="-- -flite -flite-alsa -speechd"

From 66f315a16c1d32256a7e5d7103b22c97dc0c7d2c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Jun 2023 08:20:22 -0400
Subject: [PATCH 078/109] gtk4: revbump for ffmpeg6

---
 srcpkgs/gtk4/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gtk4/template b/srcpkgs/gtk4/template
index 452ad63a9f4e6c..8f534c54aab81a 100644
--- a/srcpkgs/gtk4/template
+++ b/srcpkgs/gtk4/template
@@ -1,7 +1,7 @@
 # Template file for 'gtk4'
 pkgname=gtk4
 version=4.14.1
-revision=1
+revision=2
 build_style=meson
 build_helper="gir"
 configure_args="-Dman-pages=true -Ddocumentation=true -Dbuild-tests=false

From cfa6559cf1fa54c6a6875e5bee033fb230cbf919 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:28:26 -0400
Subject: [PATCH 079/109] siril: revbump for ffmpeg6

---
 srcpkgs/siril/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/siril/template b/srcpkgs/siril/template
index 84332f79d060d2..62750dd247548f 100644
--- a/srcpkgs/siril/template
+++ b/srcpkgs/siril/template
@@ -1,7 +1,7 @@
 # Template file for 'siril'
 pkgname=siril
 version=0.9.12
-revision=10
+revision=11
 build_style=gnu-configure
 hostmakedepends="pkg-config intltool autoconf automake gettext-devel"
 makedepends="fftw-devel libconfig-devel libopencv-devel libffms2-devel

From efee144b93c3c75cb5815ac5134ad65c872ecda7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:20:59 -0400
Subject: [PATCH 080/109] tracker-miners: revbump for ffmpeg6

---
 srcpkgs/tracker-miners/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tracker-miners/template b/srcpkgs/tracker-miners/template
index 0ae1cb0a986bdd..8be9ca6f8cc28b 100644
--- a/srcpkgs/tracker-miners/template
+++ b/srcpkgs/tracker-miners/template
@@ -1,7 +1,7 @@
 # Template file for 'tracker-miners'
 pkgname=tracker-miners
 version=3.6.2
-revision=1
+revision=2
 build_style=meson
 build_helper=qemu
 # missing libgrss for miner_rss

From eb6df7a050f9ef842fecd2aac0d7f357828fe496 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:21:21 -0400
Subject: [PATCH 081/109] mpd: revbump for ffmpeg6

---
 srcpkgs/mdp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mdp/template b/srcpkgs/mdp/template
index 3720bfae02f840..1c45395dca9b21 100644
--- a/srcpkgs/mdp/template
+++ b/srcpkgs/mdp/template
@@ -1,7 +1,7 @@
 # Template file for 'mdp'
 pkgname=mdp
 version=1.0.15
-revision=1
+revision=2
 build_style=gnu-makefile
 makedepends="ncurses-devel"
 short_desc="A command-line based markdown presentation tool"

From 871fc9cd460a1a446403c9bb24ac112af28ad9b7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:02 -0400
Subject: [PATCH 082/109] tg_owt: revbump for ffmpeg6

---
 srcpkgs/tg_owt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tg_owt/template b/srcpkgs/tg_owt/template
index 34e8fef0540569..1a46a8bedf3473 100644
--- a/srcpkgs/tg_owt/template
+++ b/srcpkgs/tg_owt/template
@@ -1,7 +1,7 @@
 # Template file for 'tg_owt'
 pkgname=tg_owt
 version=0.0.0.20231221
-revision=2
+revision=3
 _commit=afd9d5d31798d3eacf9ed6c30601e91d0f1e4d60
 _libyuv_commit=04821d1e7d60845525e8db55c7bcd41ef5be9406
 _abseil_commit=8c0b94e793a66495e0b1f34a5eb26bd7dc672db0

From 794c6c2726527b9968802e108d9c46e137b9e3f5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:44 -0400
Subject: [PATCH 083/109] telegram-desktop: revbump for ffmpeg6

---
 srcpkgs/telegram-desktop/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/telegram-desktop/template b/srcpkgs/telegram-desktop/template
index 6dc6a553cfcec8..cf85a731370062 100644
--- a/srcpkgs/telegram-desktop/template
+++ b/srcpkgs/telegram-desktop/template
@@ -1,7 +1,7 @@
 # Template file for 'telegram-desktop'
 pkgname=telegram-desktop
 version=4.14.15
-revision=3
+revision=4
 build_style=cmake
 build_helper="qemu gir"
 configure_args="-DTDESKTOP_API_ID=209235

From ba56e5d0e8a47a4c66158fa449453c3541d294c7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:12:09 -0400
Subject: [PATCH 084/109] openmw: revbump for ffmpeg6

---
 srcpkgs/openmw/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openmw/template b/srcpkgs/openmw/template
index 0abf5ff7cdbecc..b57180f1a4446f 100644
--- a/srcpkgs/openmw/template
+++ b/srcpkgs/openmw/template
@@ -1,7 +1,7 @@
 # Template file for 'openmw'
 pkgname=openmw
 version=0.48.0
-revision=2
+revision=3
 build_style=cmake
 _recast_commit=e75adf86f91eb3082220085e42dda62679f9a3ea
 _bullet_tag=3.17

From 0fe6edad83c5cea65ead0c42ec4027e34bbe0d09 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:14:53 -0400
Subject: [PATCH 085/109] lms: revbump for ffmpeg6

---
 srcpkgs/lms/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/lms/template b/srcpkgs/lms/template
index e358f75902a986..3b21c458de5199 100644
--- a/srcpkgs/lms/template
+++ b/srcpkgs/lms/template
@@ -1,7 +1,7 @@
 # Template file for 'lms'
 pkgname=lms
 version=3.42.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="wt-devel ffmpeg-devel boost-devel libconfig++-devel taglib-devel pam-devel libgraphicsmagick-devel gtest-devel libarchive-devel"

From 72666ccf2c2653422ff1aa2e6b71dc20ff21de17 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:18:18 -0400
Subject: [PATCH 086/109] freecad: DELETE

---
 srcpkgs/freecad/patches/001-include.patch     | 112 ------------------
 .../154-revert-gui-tmp-redirect-stderr.patch  |  68 -----------
 ...d63c8c9b1280978be841d04e68a0a55cceb9.patch |  30 -----
 srcpkgs/freecad/template                      |  12 +-
 4 files changed, 7 insertions(+), 215 deletions(-)
 delete mode 100644 srcpkgs/freecad/patches/001-include.patch
 delete mode 100644 srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
 delete mode 100644 srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch

diff --git a/srcpkgs/freecad/patches/001-include.patch b/srcpkgs/freecad/patches/001-include.patch
deleted file mode 100644
index 28b5af54999b96..00000000000000
--- a/srcpkgs/freecad/patches/001-include.patch
+++ /dev/null
@@ -1,112 +0,0 @@
-From 9a41845a417189776741297c50a3827ce292bc4f Mon Sep 17 00:00:00 2001
-From: Uwe <donovaly@users.noreply.github.com>
-Date: Sun, 3 Jul 2022 22:51:16 +0200
-Subject: [PATCH] [Part] OCCError.h: remove unneeded includes
-
-- also sort includes
----
- src/Mod/Part/App/OCCError.h             | 36 +++----------------------
- src/Mod/Part/App/OffsetCurvePyImp.cpp   | 12 ++++-----
- src/Mod/Part/App/OffsetSurfacePyImp.cpp | 10 +++----
- 3 files changed, 12 insertions(+), 46 deletions(-)
-
---- a/src/Mod/Part/App/OCCError.h
-+++ b/src/Mod/Part/App/OCCError.h
-@@ -23,36 +23,8 @@
- #ifndef _OCCError_h_
- #define _OCCError_h_
- 
--# include <Standard_Version.hxx>
- # include <Standard_Failure.hxx>
--# include <Standard_AbortiveTransaction.hxx>
--# include <Standard_ConstructionError.hxx>
--# if OCC_VERSION_HEX >= 0x060500
--# include <Standard_DefineException.hxx>
--# endif
--# include <Standard_DimensionError.hxx>
--# include <Standard_DimensionMismatch.hxx>
--# include <Standard_DivideByZero.hxx>
--# include <Standard_DomainError.hxx>
--# include <Standard_ImmutableObject.hxx>
--# include <Standard_LicenseError.hxx>
--# include <Standard_LicenseNotFound.hxx>
--# include <Standard_MultiplyDefined.hxx>
--# include <Standard_NegativeValue.hxx>
--# include <Standard_NoMoreObject.hxx>
--# include <Standard_NoSuchObject.hxx>
--# include <Standard_NotImplemented.hxx>
--# include <Standard_NullObject.hxx>
--# include <Standard_NullValue.hxx>
--# include <Standard_NumericError.hxx>
--# include <Standard_OutOfMemory.hxx>
--# include <Standard_OutOfRange.hxx>
--# include <Standard_Overflow.hxx>
--# include <Standard_ProgramError.hxx>
--# include <Standard_RangeError.hxx>
--# include <Standard_TooManyUsers.hxx>
--# include <Standard_TypeMismatch.hxx>
--# include <Standard_Underflow.hxx>
-+# include <Standard_Version.hxx>
- 
- #include <Mod/Part/PartGlobal.h>
- #include <Base/Console.h>
-@@ -88,4 +60,3 @@ PartExport extern PyObject* PartExceptio
- 
- #define PY_CATCH_OCC _PY_CATCH_OCC(return(NULL))
- #endif  // _OCCError_h_
--
---- a/src/Mod/Part/App/OffsetCurvePyImp.cpp
-+++ b/src/Mod/Part/App/OffsetCurvePyImp.cpp
-@@ -20,20 +20,20 @@
-  *                                                                         *
-  ***************************************************************************/
- 
--
- #include "PreCompiled.h"
- #ifndef _PreComp_
- # include <Geom_OffsetCurve.hxx>
- #endif
- 
--#include "OCCError.h"
--#include "Geometry.h"
-+#include <Base/GeometryPyCXX.h>
-+#include <Base/Vector3D.h>
-+#include <Base/VectorPy.h>
-+
- #include "OffsetCurvePy.h"
- #include "OffsetCurvePy.cpp"
-+#include "Geometry.h"
-+#include "OCCError.h"
- 
--#include <Base/GeometryPyCXX.h>
--#include <Base/VectorPy.h>
--#include <Base/Vector3D.h>
- 
- using namespace Part;
- 
---- a/src/Mod/Part/App/OffsetSurfacePyImp.cpp
-+++ b/src/Mod/Part/App/OffsetSurfacePyImp.cpp
-@@ -20,20 +20,16 @@
-  *                                                                         *
-  ***************************************************************************/
- 
--
- #include "PreCompiled.h"
- #ifndef _PreComp_
- # include <Geom_OffsetSurface.hxx>
- # include <memory>
- #endif
- 
--#include <Base/VectorPy.h>
--#include <Base/Vector3D.h>
--
- #include "OCCError.h"
--#include "Geometry.h"
--#include <Mod/Part/App/OffsetSurfacePy.h>
--#include <Mod/Part/App/OffsetSurfacePy.cpp>
-+#include "OffsetSurfacePy.h"
-+#include "OffsetSurfacePy.cpp"
-+
- 
- using namespace Part;
- 
diff --git a/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch b/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
deleted file mode 100644
index d6a9adabdec830..00000000000000
--- a/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
+++ /dev/null
@@ -1,68 +0,0 @@
-see https://github.com/FreeCAD/FreeCAD/commit/cfe94b00d3434f3e2c8b5114d2909f628c330fa8#commitcomment-71413407
-
-upstream: yes
-
-From 7b377a216b9185960e4cee980a6504dc1a755f50 Mon Sep 17 00:00:00 2001
-From: wmayer <wmayer@users.sourceforge.net>
-Date: Wed, 29 Jun 2022 15:19:18 +0200
-Subject: [PATCH] Gui: remove workaround for spnav 0.23 due to build failure
- with musl libc
-
----
- src/Gui/3Dconnexion/GuiNativeEventLinux.cpp | 27 ---------------------
- 1 file changed, 27 deletions(-)
-
---- a/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp
-+++ b/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp
-@@ -21,42 +21,17 @@
-  ***************************************************************************/
- 
- #include <FCConfig.h>
--#include <cstdio>
- 
- #include "GuiNativeEventLinux.h"
- 
- #include "GuiApplicationNativeEventAware.h"
- #include <Base/Console.h>
--#include <Base/FileInfo.h>
- #include <QMainWindow>
- 
- #include <QSocketNotifier>
- 
- #include <spnav.h>
- 
--namespace {
--class RedirectStdErr
--{
--public:
--    RedirectStdErr()
--        : fi(Base::FileInfo::getTempFileName())
--        , file(stderr)
--    {
--        stderr = fopen(fi.filePath().c_str(), "w");
--    }
--    ~RedirectStdErr()
--    {
--        fclose(stderr);
--        fi.deleteFile();
--        stderr = file;
--    }
--
--private:
--    Base::FileInfo fi;
--    FILE* file;
--};
--}
--
- Gui::GuiNativeEvent::GuiNativeEvent(Gui::GUIApplicationNativeEventAware *app)
- : GuiAbstractNativeEvent(app)
- {
-@@ -72,8 +47,6 @@ Gui::GuiNativeEvent::~GuiNativeEvent()
- 
- void Gui::GuiNativeEvent::initSpaceball(QMainWindow *window)
- {
--    // tmp. redirect stderr to a file to suppress an error message from spnav_open()
--    RedirectStdErr err;
-     Q_UNUSED(window)
-     if (spnav_open() == -1) {
-         Base::Console().Log("Couldn't connect to spacenav daemon. Please ignore if you don't have a spacemouse.\n");
diff --git a/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch b/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch
deleted file mode 100644
index d4acf370ca0a42..00000000000000
--- a/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-From fe02d63c8c9b1280978be841d04e68a0a55cceb9 Mon Sep 17 00:00:00 2001
-From: Roy-043 <70520633+Roy-043@users.noreply.github.com>
-Date: Thu, 29 Dec 2022 23:20:38 +0100
-Subject: [PATCH] Draft: update inspect.getargspec to inspect.getfullargspec
- (#8101)
-
----
- src/Mod/Draft/draftguitools/gui_snapper.py | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
---- a/src/Mod/Draft/draftguitools/gui_snapper.py
-+++ b/src/Mod/Draft/draftguitools/gui_snapper.py
-@@ -1426,7 +1426,7 @@ class Snapper:
-             Gui.Snapper.off()
-             self.ui.offUi()
-             if callback:
--                if len(inspect.getargspec(callback).args) > 1:
-+                if len(inspect.getfullargspec(callback).args) > 1:
-                     obj = None
-                     if self.snapInfo and ("Object" in self.snapInfo) and self.snapInfo["Object"]:
-                         obj = App.ActiveDocument.getObject(self.snapInfo["Object"])
-@@ -1445,7 +1445,7 @@ class Snapper:
-             Gui.Snapper.off()
-             self.ui.offUi()
-             if callback:
--                if len(inspect.getargspec(callback).args) > 1:
-+                if len(inspect.getfullargspec(callback).args) > 1:
-                     callback(None, None)
-                 else:
-                     callback(None)
diff --git a/srcpkgs/freecad/template b/srcpkgs/freecad/template
index c135701e38b9ad..7d5165f760bab9 100644
--- a/srcpkgs/freecad/template
+++ b/srcpkgs/freecad/template
@@ -1,7 +1,7 @@
 # Template file for 'freecad'
 pkgname=freecad
-version=0.20.2
-revision=7
+version=0.21.1
+revision=2
 build_wrksrc="FreeCAD-${version}"
 build_style=cmake
 pycompile_dirs="usr/lib/${pkgname}/Mod"
@@ -24,8 +24,10 @@ makedepends="python3-devel boost-devel libxerces-c-devel zlib-devel occt-devel
  coin3-devel libshiboken2-devel libspnav-devel pyside2-tools
  liblz4-devel libpyside2-python3-devel python3-matplotlib netcdf-devel
  jsoncpp-devel qt5-devel qt5-svg-devel qt5-tools-devel qt5-webkit-devel
- qt5-xmlpatterns-devel coin3-doc glew-devel python3-pivy"
-depends="python3-matplotlib python3-pyside2-webengine python3-pivy"
+ qt5-xmlpatterns-devel coin3-doc glew-devel python3-pivy qt5-webengine-devel
+ qt5-declarative-devel qt5-webchannel-devel qt5-location-devel"
+depends="python3-matplotlib python3-pyside2-webengine python3-pivy
+ python3-GitPython python3-Markdown"
 short_desc="General purpose 3D CAD modeler"
 maintainer="yopito <pierre.bourgin@free.fr>"
 license="LGPL-2.0-or-later"
@@ -35,7 +37,7 @@ distfiles="
  https://github.com/FreeCAD/FreeCAD/archive/${version}.tar.gz
  ${SOURCEFORGE_SITE}/cxx/pycxx-${_pycxxver}.tar.gz
 "
-checksum="46922f3a477e742e1a89cd5346692d63aebb2b67af887b3e463e094a4ae055da
+checksum="e9b1fd0323f101268c7f3be52db42e4a29222f2e306ae6c4a6fc309cb418d35a
  4b91e1e1141c23fbd5039df635c4bb6e75632168548f56b83ce177193c0c98c6"
 python_version=3
 patch_args="-Np1 -d ${build_wrksrc}"

From a7f097f0333c5d5f5779486fdb6e0606a3cdbdd9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:47:18 -0400
Subject: [PATCH 087/109] libopenshot: revbump for ffmpeg6

---
 srcpkgs/libopenshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenshot/template b/srcpkgs/libopenshot/template
index 8e57c5f592169c..7a8f4520e78925 100644
--- a/srcpkgs/libopenshot/template
+++ b/srcpkgs/libopenshot/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenshot'
 pkgname=libopenshot
 version=0.3.0
-revision=3
+revision=4
 build_style=cmake
 # Builds fail with Ruby-2.4.1
 configure_args="-DENABLE_RUBY=OFF -DUSE_SYSTEM_JSONCPP=ON"

From 7fef2d2fd768724075189d6e4bf138a1e90ee260 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:10:30 -0500
Subject: [PATCH 088/109] openimageio: revbump for ffmpeg6

---
 srcpkgs/openimageio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimageio/template b/srcpkgs/openimageio/template
index 27d2131bc0a61a..61f44b43f9083e 100644
--- a/srcpkgs/openimageio/template
+++ b/srcpkgs/openimageio/template
@@ -1,7 +1,7 @@
 # Template file for 'openimageio'
 pkgname=openimageio
 version=2.4.9.0
-revision=8
+revision=9
 build_style=cmake
 build_helper=qemu
 configure_args="-DUSE_QT=0 -DUSE_PYTHON=0 -DOIIO_BUILD_TESTS=0

From c99be0c58c209ddeb56f6c0cdc5eb2224cdfe5f9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:11:57 -0500
Subject: [PATCH 089/109] synfigstudio: revbump for ffmpeg6

---
 srcpkgs/synfigstudio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/synfigstudio/template b/srcpkgs/synfigstudio/template
index 09e442da9a6805..2bc017cedca6b8 100644
--- a/srcpkgs/synfigstudio/template
+++ b/srcpkgs/synfigstudio/template
@@ -2,7 +2,7 @@
 # Should be kept in sync with 'synfig' and 'ETL'
 pkgname=synfigstudio
 version=1.4.4
-revision=4
+revision=5
 build_style=gnu-configure
 configure_args="--disable-update-mimedb"
 hostmakedepends="pkg-config intltool gettext synfig"

From 372c9cd124fefebd5939b46dc35eb571aad91d4a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:10 -0500
Subject: [PATCH 090/109] mixxx: revbump for ffmpeg6

---
 srcpkgs/mixxx/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mixxx/template b/srcpkgs/mixxx/template
index 6a79b328c1abf0..9a5141856860b9 100644
--- a/srcpkgs/mixxx/template
+++ b/srcpkgs/mixxx/template
@@ -1,7 +1,7 @@
 # Template file for 'mixxx'
 pkgname=mixxx
 version=2.3.3
-revision=7
+revision=8
 build_style=cmake
 configure_args="-DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="extra-cmake-modules pkg-config protobuf qt5-host-tools qt5-qmake"

From 1bf3d14535f08bdba4ba4bf6fe7ba9cced92bd81 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:28 -0500
Subject: [PATCH 091/109] musikcube: revbump for ffmpeg6

---
 srcpkgs/musikcube/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/musikcube/template b/srcpkgs/musikcube/template
index 8c4a51840859ec..fb60dd2049089a 100644
--- a/srcpkgs/musikcube/template
+++ b/srcpkgs/musikcube/template
@@ -1,7 +1,7 @@
 # Template file for 'musikcube'
 pkgname=musikcube
 version=3.0.0
-revision=3
+revision=4
 build_style=cmake
 make_cmd=make
 configure_args="-DNO_NCURSESW=1"

From 3a580cfd7f03fb45f84ee75aefbf7b30ce5aa5cb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:45 -0500
Subject: [PATCH 092/109] electron24: revbump for ffmpeg6

---
 srcpkgs/electron24/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron24/template b/srcpkgs/electron24/template
index 7b4e28812f483e..1ca93fde97a854 100644
--- a/srcpkgs/electron24/template
+++ b/srcpkgs/electron24/template
@@ -1,7 +1,7 @@
 # Template file for 'electron24'
 pkgname=electron24
 version=24.3.0
-revision=2
+revision=3
 _nodever=18.14.0
 _chromiumver=112.0.5615.165
 archs="x86_64* aarch64*"

From 3266a023132716cf3f9e2e1611a0685a3812dc44 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:00 -0500
Subject: [PATCH 093/109] electron19: revbump for ffmpeg6

---
 srcpkgs/electron19/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron19/template b/srcpkgs/electron19/template
index 0ef959125cb085..5371c0b354604f 100644
--- a/srcpkgs/electron19/template
+++ b/srcpkgs/electron19/template
@@ -1,7 +1,7 @@
 # Template file for 'electron19'
 pkgname=electron19
 version=19.0.8
-revision=4
+revision=5
 _nodever=16.14.2
 _chromiumver=102.0.5005.125
 archs="x86_64* aarch64* ppc64le*"

From 1e1ce3cb3719fbf4f71cac8bbc65a2437fbadef5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:13 -0500
Subject: [PATCH 094/109] wf-recorder: revbump for ffmpeg6

---
 srcpkgs/wf-recorder/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/wf-recorder/template b/srcpkgs/wf-recorder/template
index 08f986b0310067..63c45cf4b814d7 100644
--- a/srcpkgs/wf-recorder/template
+++ b/srcpkgs/wf-recorder/template
@@ -1,7 +1,7 @@
 # Template file for 'wf-recorder'
 pkgname=wf-recorder
 version=0.4.1
-revision=2
+revision=3
 build_style=meson
 hostmakedepends="pkg-config scdoc wayland-devel"
 makedepends="wayland-protocols wayland-devel ffmpeg-devel libgbm-devel x264-devel

From 391a05eadc432daa47500198a9fb74c8e03420d0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:26 -0500
Subject: [PATCH 095/109] obs: revbump for ffmpeg6

---
 srcpkgs/obs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/obs/template b/srcpkgs/obs/template
index 8aa49832357cf1..357c45c9ef6a09 100644
--- a/srcpkgs/obs/template
+++ b/srcpkgs/obs/template
@@ -1,7 +1,7 @@
 # Template file for 'obs'
 pkgname=obs
 version=30.1.0
-revision=1
+revision=2
 archs="i686* x86_64* ppc64le* aarch64* riscv64*"
 build_style=cmake
 configure_args="-DOBS_VERSION_OVERRIDE=${version} -DENABLE_JACK=ON

From 4c324b0833ab9d9b4654b611e3b380bd93a07cf7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:36 -0500
Subject: [PATCH 096/109] mlt7: revbump for ffmpeg6

---
 srcpkgs/mlt7/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mlt7/template b/srcpkgs/mlt7/template
index 98f302ad3a5167..7eb8c00fa1580c 100644
--- a/srcpkgs/mlt7/template
+++ b/srcpkgs/mlt7/template
@@ -1,7 +1,7 @@
 # Template file for 'mlt7'
 pkgname=mlt7
 version=7.20.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DSWIG_PYTHON=ON -DMOD_QT6=ON"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which

From 3db3c5d3bf01db9968ee1a90815530f978677f6d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:48 -0500
Subject: [PATCH 097/109] qt6-multimedia: revbump for ffmpeg6

---
 srcpkgs/qt6-multimedia/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-multimedia/template b/srcpkgs/qt6-multimedia/template
index 67a577e1300fea..1da626ecf515a8 100644
--- a/srcpkgs/qt6-multimedia/template
+++ b/srcpkgs/qt6-multimedia/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-multimedia'
 pkgname=qt6-multimedia
 version=6.6.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DQT_FEATURE_gstreamer=ON"
 hostmakedepends="perl qt6-declarative-host-tools pkg-config qt6-shadertools"

From e7cfb0173426037ad2a36c062dc7d8153367bcd9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:00:15 -0500
Subject: [PATCH 098/109] baresip: revbump for ffmpeg6

---
 srcpkgs/baresip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/baresip/template b/srcpkgs/baresip/template
index b16b67beab8d2b..fe21ebf40c03c1 100644
--- a/srcpkgs/baresip/template
+++ b/srcpkgs/baresip/template
@@ -1,7 +1,7 @@
 # Template file for 'baresip'
 pkgname=baresip
 version=3.6.0
-revision=3
+revision=4
 build_style=cmake
 hostmakedepends="pkg-config glib-devel"
 makedepends="libgsm-devel libpng-devel openssl-devel libsndfile-devel

From 2912b9706220514930550893e69fa5cc6942926b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:30 -0500
Subject: [PATCH 099/109] QMPlay2: revbump for ffmpeg6

---
 srcpkgs/QMPlay2/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/QMPlay2/template b/srcpkgs/QMPlay2/template
index efa9726614093c..10e5ac4ceebf80 100644
--- a/srcpkgs/QMPlay2/template
+++ b/srcpkgs/QMPlay2/template
@@ -1,7 +1,7 @@
 # Template file for 'QMPlay2'
 pkgname=QMPlay2
 version=24.03.16
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools"
 makedepends="alsa-lib-devel ffmpeg-devel libass-devel libcdio-devel libgme-devel

From 376820851031762ea32448bdc77a558b29608e43 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:34 -0500
Subject: [PATCH 100/109] alsa-plugins: revbump for ffmpeg6

---
 srcpkgs/alsa-plugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/alsa-plugins/template b/srcpkgs/alsa-plugins/template
index a5708a7d82a8f0..7bfdad046c4830 100644
--- a/srcpkgs/alsa-plugins/template
+++ b/srcpkgs/alsa-plugins/template
@@ -1,7 +1,7 @@
 # Template file for 'alsa-plugins'
 pkgname=alsa-plugins
 version=1.2.7.1
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--disable-maemo-plugin"
 hostmakedepends="pkg-config"

From a55ac0414ff750b6a6d9149bda64b2a94bca00e8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:43 -0500
Subject: [PATCH 101/109] minidlna: revbump for ffmpeg6

---
 srcpkgs/minidlna/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/minidlna/template b/srcpkgs/minidlna/template
index 5fa929f3a0c124..742991ecd04afc 100644
--- a/srcpkgs/minidlna/template
+++ b/srcpkgs/minidlna/template
@@ -1,7 +1,7 @@
 # Template file for 'minidlna'
 pkgname=minidlna
 version=1.3.3
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="
  --sbindir=/usr/bin

From cd1b6b77a5084f920457cc43608027bf02d14f35 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 17:57:47 -0500
Subject: [PATCH 102/109] mpv: revbump for ffmpeg6

---
 srcpkgs/mpv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpv/template b/srcpkgs/mpv/template
index 3d4349e27d8f62..bc40d6fcaa40d6 100644
--- a/srcpkgs/mpv/template
+++ b/srcpkgs/mpv/template
@@ -1,7 +1,7 @@
 # Template file for 'mpv'
 pkgname=mpv
 version=0.37.0
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcdda=enabled -Ddvbin=enabled -Ddvdnav=enabled
  -Dlibmpv=true -Dcplugins=enabled

From 769dbb9ffaad7b0d2340bf94e5659da7cf589e14 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 17:59:29 -0500
Subject: [PATCH 103/109] qimgv: revbump for ffmpeg6

---
 srcpkgs/qimgv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qimgv/template b/srcpkgs/qimgv/template
index dd341dfe1bfce8..8a7e1c081ef12f 100644
--- a/srcpkgs/qimgv/template
+++ b/srcpkgs/qimgv/template
@@ -1,7 +1,7 @@
 # Template file for 'qimgv'
 pkgname=qimgv
 version=1.0.2
-revision=3
+revision=4
 build_style=cmake
 configure_args="$(vopt_if video -DVIDEO_SUPPORT=ON -DVIDEO_SUPPORT=OFF)
  $(vopt_if scale -DOPENCV_SUPPORT=ON -DOPENCV_SUPPORT=OFF)

From 89dfe44ee963cd8b172d60a076e3343b3e4e51b4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 18:00:36 -0500
Subject: [PATCH 104/109] kfilemetadata5: revbump for ffmpeg6

---
 srcpkgs/kfilemetadata5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kfilemetadata5/template b/srcpkgs/kfilemetadata5/template
index a0c4d809395323..b584f85ff2058b 100644
--- a/srcpkgs/kfilemetadata5/template
+++ b/srcpkgs/kfilemetadata5/template
@@ -1,7 +1,7 @@
 # Template file for 'kfilemetadata5'
 pkgname=kfilemetadata5
 version=5.115.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="kcoreaddons extra-cmake-modules pkg-config qt5-host-tools qt5-qmake
  gettext kcoreaddons python3"

From 60d16e5f98b9885655b1b9fb1a6446b22800b744 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 8 Dec 2023 11:46:01 -0500
Subject: [PATCH 105/109] vba-m: revbump for ffmpeg6

---
 srcpkgs/vba-m/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vba-m/template b/srcpkgs/vba-m/template
index 3d135efa1d0b69..3c5a20db0fa984 100644
--- a/srcpkgs/vba-m/template
+++ b/srcpkgs/vba-m/template
@@ -2,7 +2,7 @@
 pkgname=vba-m
 reverts=1292_2
 version=2.1.9
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_GTK=TRUE -DENABLE_FFMPEG=TRUE -DENABLE_LINK=TRUE -DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="gettext pkg-config unzip zip yasm wxWidgets-gtk3-devel"

From 1f5ceb4c91337085687e74655da292465585a641 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 8 Dec 2023 11:46:19 -0500
Subject: [PATCH 106/109] dolphin-emu: revbump for ffmpeg6

---
 srcpkgs/dolphin-emu/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/dolphin-emu/template b/srcpkgs/dolphin-emu/template
index 862d3ae964eec4..a7ae0efb58fb75 100644
--- a/srcpkgs/dolphin-emu/template
+++ b/srcpkgs/dolphin-emu/template
@@ -1,7 +1,7 @@
 # Template file for 'dolphin-emu'
 pkgname=dolphin-emu
 version=5.0.19368
-revision=3
+revision=4
 _dolphin_commit=dadbeb4bae7e7fa23af2b46e0add4143094dc107
 _mgba_commit=44e074a15e9651481f7f652ac006a7c9d58cbeb9
 _googletest_commit=be03d00f5f0cc3a997d1a368bee8a1fe93651f48

From 650592528d96c75f057cb54224c29ab64804901a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 19 Dec 2023 15:38:51 -0500
Subject: [PATCH 107/109] qtox: revbump for ffmpeg4

---
 srcpkgs/qtox/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtox/template b/srcpkgs/qtox/template
index bb70e7f51240a4..755e4462bc0137 100644
--- a/srcpkgs/qtox/template
+++ b/srcpkgs/qtox/template
@@ -1,13 +1,13 @@
 # Template file for 'qtox'
 pkgname=qtox
 version=1.17.6
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DUPDATE_CHECK=OFF
  -DGIT_DESCRIBE=${version}
  $(vopt_if snorenotify -DDESKTOP_NOTIFICATIONS=ON)"
 hostmakedepends="pkg-config qt5-host-tools qt5-devel"
-makedepends="ffmpeg-devel libexif-devel libopenal-devel libsodium-devel
+makedepends="ffmpeg4-devel libexif-devel libopenal-devel libsodium-devel
  libvpx-devel opus-devel qrencode-devel qt5-svg-devel sonnet-devel
  sqlcipher-devel toxcore-devel
  $(vopt_if snorenotify snorenotify-devel)"

From 96bc40ea06d2a507050dca7a801e26cb78c7bb69 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 11 Jan 2024 11:52:00 -0500
Subject: [PATCH 108/109] arcan: revbump for ffmpeg6

---
 srcpkgs/arcan/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/arcan/template b/srcpkgs/arcan/template
index ff9091f90ebb10..030091a6cc9d0c 100644
--- a/srcpkgs/arcan/template
+++ b/srcpkgs/arcan/template
@@ -2,7 +2,7 @@
 # !! keep synced with: acfgfs aclip aloadimage
 pkgname=arcan
 version=0.6.2.1
-revision=2
+revision=3
 create_wrksrc=yes
 build_wrksrc=arcan/src
 build_style=cmake

From cea2deae9af7983199fc620485af392200f27404 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 11 Jan 2024 11:52:10 -0500
Subject: [PATCH 109/109] notcurses: revbump for ffmpeg6

---
 srcpkgs/notcurses/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/notcurses/template b/srcpkgs/notcurses/template
index 48a7463cb68eb9..515f316ab4576c 100644
--- a/srcpkgs/notcurses/template
+++ b/srcpkgs/notcurses/template
@@ -1,7 +1,7 @@
 # Template file for 'notcurses'
 pkgname=notcurses
 version=3.0.9
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DUSE_STATIC=ON -DUSE_QRCODEGEN=On $(vopt_bool man USE_PANDOC)"
 hostmakedepends="pkg-config $(vopt_if man pandoc)"

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (94 preceding siblings ...)
  2024-03-21 21:51 ` zlice
@ 2024-03-28 17:21 ` zlice
  2024-04-13 14:47 ` zlice
  2024-04-26 12:45 ` zlice
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2024-03-28 17:21 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 5117 bytes --]

There is an updated pull request by zlice against master on the void-packages repository

https://github.com/zlice/void-packages ffmpeg6-split
https://github.com/void-linux/void-packages/pull/43761

ffmpeg6 split
[ci skip]


#### Testing the changes

- I tested the changes in this PR: **YES**

main testing has been vaapi in Firefox Nightly and enc/dec in Shotcut on Intel A770

#### New package

- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**

#### Local build testing

- I built this PR locally for my native architecture, **x86_64**

#### Discussion

Continuation of https://github.com/void-linux/void-packages/pull/36315

`libavresample` is deprecated, but marked as a dependency when trying to build other packages and install `ffmpeg`(6). I think the right way to handle this is make a meta package and the add to removals?


##### Commit naming / misc

~~Commits are 'dirty' right now, running with [gstreamer 1.22.1 updates](https://github.com/void-linux/void-packages/pull/42861) and [Intel OpenCL](https://github.com/void-linux/void-packages/pull/43084). This will also make [intel packages pr](https://github.com/void-linux/void-packages/pull/41132) obsolete.~~ (see Requirements below)

Maintainer for previous ffmpeg(4) was orphaned, I can put my name in there if that matters, though I don't exactly see myself keeping up on ffmpeg.

~~This updates QT5 which looks like it is usually hosted by Johnny. Not sure if there's any reason to stay there or these sources are fine.~~ Using qt5.15.11 now, revbumps and some patches.

##### STILL FFMPEG4

These are a mix of emulators, games and/or older packages.

- ~~attract~~ (2.7 builds)
- ~~audacity (https://github.com/audacity/audacity/issues/2305 and https://sourceforge.net/p/portmedia/wiki/portsmf/ is 'beta')~~ (updated to 3.x, compiles with ffmpeg6)
- ~~ccextractor~~ (master patches)
- ~~vice (3.8 compiles, needs makedepends libcurl-devel)~~ ty yosh
- kodi
- mlt (only dep left is flowblade - flowblade 2.12.0.2 with mlt7-python3 can 'render' videos with cpu and gpu - https://github.com/void-linux/void-packages/pull/47195)
- ~~synfig (mlt)~~ (work with mlt7, bump synfigstudio)
- tvheadend (download page recommends using 4.3 which compiles fine, 4.4 eta is Q1 2024)
- ~~ssr~~ (patches)
- ~~spek-alternative~~ (replace with spek-x)
- ~~ppsspp~~ ~~(1.17.1 is out, but there's 5+ distfiles that are all git commits)~~ (minor patch)
- olive (has been in alpha since 2020, seems they do nightly builds and appimages)
- moc
- mediastreamer (linphone links are dead, changed to github belladonne. their stuff never worked for me but there are updates if someone wants to give it a try)
- ~~libextractor (1.13 compiles, remove exiv2 patch)~~ (as yosh pointed out, 1.13 just removes ffmpeg bits)
- idjc (0.9.8 compiles, remove python3.10 patch, needs makedepends libebur128-devel and libshout-idjc 2.4.6 with '-r1' for distfile)
- hedgewars
- ~~ffmpegthumbnailer~~ (patches for moviedecoder.xxx files)
- ~~ffmpegthumbs~~ (latest compiles)
- deadbeef (1.9.6 may work but requires libdispatch from apple)
- ~~omxplayer~~ (package removed, deprecated in favor of vlc)
- qtav (fork has ffmpeg 5 patch - https://github.com/cmguo/QtAV)
- `vlc` (vlc4 will support ffmpeg5, there's a patch to build 3.x with ffmpeg5 but it will lack vaapi)
- `osg` (OpenSceneGraph plus `xine-lib`) (patches from osg issue build with ffmpeg6, [ffmpeg5.patch.txt](https://github.com/void-linux/void-packages/files/14743246/ffmpeg5.patch.txt))



##### HAVE NOT BUILT YET

- ~~omxplayer (rpi only? ffmpeg4)~~ (removed)
- kodi (big, but ffmpeg4)


##### UPDATED (for ffmpeg6)

- ~~blender: update to 3.5.1~~ ~~will be revbump with~~ https://github.com/void-linux/void-packages/pull/43992
- unpaper: update to 7.0.0.
- guvcview: update to 2.0.8.
- ~~qt5: update to 5.15.8~~ updated by another PR to 5.15.11
- ~~qt5-webengine: update to 5.18.15~~ updated by another PR to 5.15.16 (some patching for ffmpeg build)
- ~~shiboken2: revbump for qt5.15.8 (patch)~~ updated by another PR to 5.15.10
- ~~python3-pyside2: update to 5.15.8 (patch)~~ updated by another PR to 5.15.10
- New package: spex-x replaces spek-alternative for ffmpeg-6.0


##### Requirements

- ~~[gstreamer 1.22.2](https://github.com/void-linux/void-packages/pull/42861)~~ - a few packages use ffmpeg-devel and require a revbump

- ~~[Intel Packages](https://github.com/void-linux/void-packages/pull/41132) [Intel Packages v2](https://github.com/void-linux/void-packages/pull/47330) - ffmpeg4 uses different libraries than 6 (libmfx / Intel-MediaSDK vs only oneVPL that Intel is moving to), both are included here~~. Using replacement oneVPL from OBS update.

- ~~[shotcut 23.05.14](https://github.com/void-linux/void-packages/pull/44260)~~

- https://github.com/void-linux/void-packages/pull/44781 will remove from this PR

A patch file from https://github.com/void-linux/void-packages/pull/43761.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ffmpeg6-split-43761.patch --]
[-- Type: text/x-diff, Size: 240982 bytes --]

From 97340ba22a0daedb57d813b17e8b139613283186 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:16:56 -0400
Subject: [PATCH 001/109] ffmpeg: update to 6.0.1.

---
 common/shlibs                                 | 26 ++++---
 srcpkgs/ffmpeg/files/altivec.patch            | 60 ---------------
 .../patches/armv5tel-floating-point.patch     | 18 -----
 srcpkgs/ffmpeg/patches/binutils-2.41.patch    | 73 -------------------
 ...h-libavcodec-libsvtav1-ten_bit_format.diff | 40 ----------
 .../workaround-mesa-readeon-vaapi-bug.patch   | 28 -------
 srcpkgs/ffmpeg/template                       | 40 +++++-----
 7 files changed, 37 insertions(+), 248 deletions(-)
 delete mode 100644 srcpkgs/ffmpeg/files/altivec.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/binutils-2.41.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 delete mode 100644 srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch

diff --git a/common/shlibs b/common/shlibs
index 1ee5b1f0544b5c..7861aab64f3a25 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -389,15 +389,23 @@ libid3tag.so.0 libid3tag-0.15.1b_1
 libgif.so.7 giflib-5.1.0_1
 libImlib2.so.1 imlib2-1.4.2_1
 libmp3lame.so.0 lame-3.98.2_1
-libavdevice.so.58 libavdevice-4.0_1
-libavformat.so.58 libavformat-4.0_1
-libswscale.so.5 libswscale-4.0_1
-libswresample.so.3 libswresample-4.0_1
-libavresample.so.4 libavresample-4.0_1
-libpostproc.so.55 libpostproc-4.0_1
-libavcodec.so.58 libavcodec-4.0_1
-libavutil.so.56 libavutil-4.0_1
-libavfilter.so.7 libavfilter-4.0_1
+libavdevice.so.60 libavdevice-6.0_1
+libavformat.so.60 libavformat-6.0_1
+libswscale.so.7 libswscale-6.0_1
+libswresample.so.4 libswresample-6.0_1
+libpostproc.so.57 libpostproc-6.0_1
+libavcodec.so.60 libavcodec-6.0_1
+libavutil.so.58 libavutil-6.0_1
+libavfilter.so.9 libavfilter-6.0_1
+libavdevice.so.58 libavdevice4-4.0_1
+libavformat.so.58 libavformat4-4.0_1
+libswscale.so.5 libswscale4-4.0_1
+libswresample.so.3 libswresample4-4.0_1
+libavresample.so.4 libavresample4-4.0_1
+libpostproc.so.55 libpostproc4-4.0_1
+libavcodec.so.58 libavcodec4-4.0_1
+libavutil.so.56 libavutil4-4.0_1
+libavfilter.so.7 libavfilter4-4.0_1
 libSDL-1.2.so.0 SDL-1.2.14_1
 libSDL_image-1.2.so.0 SDL_image-1.2.10_1
 libx264.so.157 x264-20190507.2245_1
diff --git a/srcpkgs/ffmpeg/files/altivec.patch b/srcpkgs/ffmpeg/files/altivec.patch
deleted file mode 100644
index 9c57200463320e..00000000000000
--- a/srcpkgs/ffmpeg/files/altivec.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-revert some altivec specific change on all ppc* except ppc64le*
-
-q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
-conditionally, for ppc* but not ppc64le* (the new code is valid for
-POWER8 VSX which LE targets as a baseline but not BE)"
-
-
-This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
----
- libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
- 1 file changed, 20 insertions(+), 4 deletions(-)
-
-diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
-index 536545293d..c1e2852adb 100644
---- a/libswscale/ppc/yuv2rgb_altivec.c
-+++ b/libswscale/ppc/yuv2rgb_altivec.c
-@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-     vector signed short R1, G1, B1;                                           \
-     vector unsigned char R, G, B;                                             \
-                                                                               \
-+    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
-+    vector unsigned char align_perm;                                          \
-+                                                                              \
-     vector signed short lCY       = c->CY;                                    \
-     vector signed short lOY       = c->OY;                                    \
-     vector signed short lCRV      = c->CRV;                                   \
-@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
-                                                                               \
-         for (j = 0; j < w / 16; j++) {                                        \
--            y0 = vec_xl(0, y1i);                                              \
-+            y1ivP = (const vector unsigned char *) y1i;                       \
-+            y2ivP = (const vector unsigned char *) y2i;                       \
-+            uivP  = (const vector unsigned char *) ui;                        \
-+            vivP  = (const vector unsigned char *) vi;                        \
-+                                                                              \
-+            align_perm = vec_lvsl(0, y1i);                                    \
-+            y0 = (vector unsigned char)                                       \
-+                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
-                                                                               \
--            y1 = vec_xl(0, y2i);                                              \
-+            align_perm = vec_lvsl(0, y2i);                                    \
-+            y1 = (vector unsigned char)                                       \
-+                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
-                                                                               \
--            u = (vector signed char) vec_xl(0, ui);                           \
-+            align_perm = vec_lvsl(0, ui);                                     \
-+            u = (vector signed char)                                          \
-+                    vec_perm(uivP[0], uivP[1], align_perm);                   \
-                                                                               \
--            v = (vector signed char) vec_xl(0, vi);                           \
-+            align_perm = vec_lvsl(0, vi);                                     \
-+            v = (vector signed char)                                          \
-+                    vec_perm(vivP[0], vivP[1], align_perm);                   \
-                                                                               \
-             u = (vector signed char)                                          \
-                     vec_sub(u,                                                \
--- 
-2.27.0
-
diff --git a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
deleted file mode 100644
index 9a55178c74f0fd..00000000000000
--- a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
-+++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
-@@ -39,6 +39,15 @@
- #endif
- #include <fenv.h>
- 
-+#if (FE_ALL_EXCEPT == 0)
-+/* E.g. ARM soft float does not define these */
-+#define FE_INVALID    0
-+#define FE_DIVBYZERO  0
-+#define FE_OVERFLOW   0
-+#define FE_UNDERFLOW  0
-+#define FE_INEXACT    0
-+#endif
-+
- #if CONFIG_LIBFONTCONFIG
- #include <fontconfig/fontconfig.h>
- #endif
diff --git a/srcpkgs/ffmpeg/patches/binutils-2.41.patch b/srcpkgs/ffmpeg/patches/binutils-2.41.patch
deleted file mode 100644
index 53a596d0ee7d4e..00000000000000
--- a/srcpkgs/ffmpeg/patches/binutils-2.41.patch
+++ /dev/null
@@ -1,73 +0,0 @@
-From effadce6c756247ea8bae32dc13bb3e6f464f0eb Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= <remi@remlab.net>
-Date: Sun, 16 Jul 2023 18:18:02 +0300
-Subject: [PATCH] avcodec/x86/mathops: clip constants used with shift
- instructions within inline assembly
-
-Fixes assembling with binutil as >= 2.41
-
-Signed-off-by: James Almer <jamrial@gmail.com>
----
- libavcodec/x86/mathops.h | 26 +++++++++++++++++++++++---
- 1 file changed, 23 insertions(+), 3 deletions(-)
-
-diff --git a/libavcodec/x86/mathops.h b/libavcodec/x86/mathops.h
-index 6298f5ed1983b..ca7e2dffc1076 100644
---- a/libavcodec/x86/mathops.h
-+++ b/libavcodec/x86/mathops.h
-@@ -35,12 +35,20 @@
- static av_always_inline av_const int MULL(int a, int b, unsigned shift)
- {
-     int rt, dummy;
-+    if (__builtin_constant_p(shift))
-     __asm__ (
-         "imull %3               \n\t"
-         "shrdl %4, %%edx, %%eax \n\t"
-         :"=a"(rt), "=d"(dummy)
--        :"a"(a), "rm"(b), "ci"((uint8_t)shift)
-+        :"a"(a), "rm"(b), "i"(shift & 0x1F)
-     );
-+    else
-+        __asm__ (
-+            "imull %3               \n\t"
-+            "shrdl %4, %%edx, %%eax \n\t"
-+            :"=a"(rt), "=d"(dummy)
-+            :"a"(a), "rm"(b), "c"((uint8_t)shift)
-+        );
-     return rt;
- }
- 
-@@ -113,19 +121,31 @@ __asm__ volatile(\
- // avoid +32 for shift optimization (gcc should do that ...)
- #define NEG_SSR32 NEG_SSR32
- static inline  int32_t NEG_SSR32( int32_t a, int8_t s){
-+    if (__builtin_constant_p(s))
-     __asm__ ("sarl %1, %0\n\t"
-          : "+r" (a)
--         : "ic" ((uint8_t)(-s))
-+         : "i" (-s & 0x1F)
-     );
-+    else
-+        __asm__ ("sarl %1, %0\n\t"
-+               : "+r" (a)
-+               : "c" ((uint8_t)(-s))
-+        );
-     return a;
- }
- 
- #define NEG_USR32 NEG_USR32
- static inline uint32_t NEG_USR32(uint32_t a, int8_t s){
-+    if (__builtin_constant_p(s))
-     __asm__ ("shrl %1, %0\n\t"
-          : "+r" (a)
--         : "ic" ((uint8_t)(-s))
-+         : "i" (-s & 0x1F)
-     );
-+    else
-+        __asm__ ("shrl %1, %0\n\t"
-+               : "+r" (a)
-+               : "c" ((uint8_t)(-s))
-+        );
-     return a;
- }
- 
diff --git a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
deleted file mode 100644
index aa948f7a8a2dfb..00000000000000
--- a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
+++ /dev/null
@@ -1,40 +0,0 @@
-#==================================================================================================
-# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
-# From: Christopher Degawa <christopher.degawa@intel.com>
-# Date: Thu, 20 Oct 2022 22:55:27 -0500
-# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
-#
-# compressed_ten_bit_format has been deprecated upstream and has no effect
-# and can be removed. Plus, technically it was never used in the first place
-# since it would require the app (ffmpeg) to set it and do additional
-# processing of the input frames.
-#
-# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
-#
-# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
-#==================================================================================================
---- a/libavcodec/libsvtav1.c
-+++ b/libavcodec/libsvtav1.c
-@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
- 
- static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
- {
--    const int    pack_mode_10bit =
--        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
--    const size_t luma_size_8bit  =
--        config->source_width * config->source_height * (1 << pack_mode_10bit);
--    const size_t luma_size_10bit =
--        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
-+    const size_t luma_size = config->source_width * config->source_height *
-+        (config->encoder_bit_depth > 8 ? 2 : 1);
- 
-     EbSvtIOFormat *in_data;
- 
--    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
-+    svt_enc->raw_size = luma_size * 3 / 2;
- 
-     // allocate buffer for in and out
-     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
--- 
-GitLab
-
diff --git a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
deleted file mode 100644
index 00e3f68a415b84..00000000000000
--- a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
-From: Rainer Hochecker <fernetmenta@online.de>
-Date: Sat, 26 Jan 2019 19:48:35 +0100
-Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
-
-This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
-It was hit frequently when watching h264 channels received via DVB-X.
-Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
----
- libavcodec/vaapi_h264.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
-index 5854587a255..f12fdc457a4 100644
---- a/libavcodec/vaapi_h264.c
-+++ b/libavcodec/vaapi_h264.c
-@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
-     H264SliceContext *sl = &h->slice_ctx[0];
-     int ret;
- 
-+    if (pic->nb_slices == 0) {
-+        ret = AVERROR_INVALIDDATA;
-+        goto finish;
-+    }
-+
-     ret = ff_vaapi_decode_issue(avctx, pic);
-     if (ret < 0)
-         goto finish;
diff --git a/srcpkgs/ffmpeg/template b/srcpkgs/ffmpeg/template
index 1ebb436135938d..f1e4712c41d087 100644
--- a/srcpkgs/ffmpeg/template
+++ b/srcpkgs/ffmpeg/template
@@ -1,15 +1,15 @@
 # Template file for 'ffmpeg'
 # audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
 pkgname=ffmpeg
-version=4.4.4
-revision=6
+version=6.0.1
+revision=1
 short_desc="Decoding, encoding and streaming software"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="https://www.ffmpeg.org"
 changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
 distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
-checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+checksum=9b16b8731d78e596b4be0d720428ca42df642bb2d78342881ff7f5bc29fc9623
 
 hostmakedepends="pkg-config perl"
 makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
@@ -26,12 +26,13 @@ makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-deve
  $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
  $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
  $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
- $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers Vulkan-Tools Vulkan-ValidationLayers')
+ $(vopt_if onevpl 'oneVPL oneVPL-devel')
  $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
 depends="ffplay>=${version}_${revision}"
 
 build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
- dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec onevpl"
 build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
 desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
 desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
@@ -39,9 +40,13 @@ desc_option_sofa="Enable support for AES SOFA"
 desc_option_webp="Enable support for WebP"
 
 case "$XBPS_TARGET_MACHINE" in
-	i686*|x86_64*)
-		hostmakedepends+=" nasm"
+	i686*)
 		build_options_default+=" vaapi vdpau nvenc nvdec"
+		hostmakedepends+=" nasm"
+		;;
+	x86_64*)
+		hostmakedepends+=" nasm"
+		build_options_default+=" vaapi vdpau nvenc nvdec onevpl"
 		;;
 	ppc64*) build_options_default+=" vaapi vdpau";;
 	mips*) CFLAGS="-mnan=legacy";;
@@ -65,8 +70,6 @@ post_patch() {
 		ppc64le*) ;;
 		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
 	esac
-
-	vsed -i libavfilter/vf_libvmaf.c -e 's!/usr/local/share/model/\(vmaf_v0.6.1\).pkl!/usr/share/vmaf/\1.json!'
 }
 
 do_configure() {
@@ -115,18 +118,19 @@ do_configure() {
 		$(vopt_enable x265 libx265) \
 		$(vopt_enable v4l2 libv4l2) \
 		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
-		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		--enable-libbs2b --enable-libvidstab \
 		$(vopt_enable dav1d libdav1d) \
 		$(vopt_enable zimg libzimg) \
 		$(vopt_enable webp libwebp) \
 		$(vopt_enable sofa libmysofa) \
 		$(vopt_enable vulkan) \
+		$(vopt_enable onevpl libvpl) \
 		$(vopt_enable drm libdrm) \
 		$(vopt_enable svtav1 libsvtav1) \
 		$(vopt_enable srt libsrt) \
 		$(vopt_enable rist librist) \
-		$(vopt_if nvenc '--enable-nvenc') \
-		$(vopt_if nvdec '--enable-nvdec')
+		$(vopt_enable nvenc nvenc) \
+		$(vopt_enable nvdec nvdec)
 }
 
 do_build() {
@@ -153,10 +157,8 @@ libavdevice_package() {
 }
 
 libavresample_package() {
-	short_desc="FFmpeg audio resampling library"
-	pkg_install() {
-		vmove "usr/lib/libavresample.so.*"
-	}
+	short_desc="Package deprecated, removal needed"
+	build_style=meta
 }
 
 libavformat_package() {
@@ -210,15 +212,13 @@ ffmpeg-devel_package() {
 		libavfilter>=${version}_${revision}
 		libpostproc>=${version}_${revision}
 		libswscale>=${version}_${revision}
-		libswresample>=${version}_${revision}
-		libavresample>=${version}_${revision}"
+		libswresample>=${version}_${revision}"
 	short_desc+=" - development files"
-
+	conflicts="ffmpeg4-devel"
 	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
 		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
 		nostrip_files="/usr/lib/libavfilter.a"
 	fi
-
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig

From cbeff7d87be5d03d782849a0dcd2f12eab90ae9a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:14 -0400
Subject: [PATCH 002/109] openshot: revbump for ffmpeg6

---
 srcpkgs/openshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openshot/template b/srcpkgs/openshot/template
index 3849858fe963b5..12789bc9867499 100644
--- a/srcpkgs/openshot/template
+++ b/srcpkgs/openshot/template
@@ -1,7 +1,7 @@
 # Template file for 'openshot'
 pkgname=openshot
 version=3.1.1
-revision=1
+revision=2
 build_style=python3-module
 hostmakedepends="python3 python3-setuptools"
 makedepends="ffmpeg-devel python3-PyQt5"

From 40beb14c00726ced4c634a4e1003f1eceffaff98 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:36 -0400
Subject: [PATCH 003/109] sumo: revbump for ffmpeg6

---
 srcpkgs/sumo/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/sumo/template b/srcpkgs/sumo/template
index a730afa9fafa92..e2def06fa4bd7d 100644
--- a/srcpkgs/sumo/template
+++ b/srcpkgs/sumo/template
@@ -1,7 +1,7 @@
 # Template file for 'sumo'
 pkgname=sumo
 version=1.12.0
-revision=7
+revision=8
 build_style=cmake
 hostmakedepends="libgdal-tools pkg-config swig python3-setuptools"
 makedepends="python3-devel ffmpeg-devel fox-devel gl2ps-devel libgdal-devel

From 703835d49d03fa91691b029fbe24bea8061841f0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:56:22 -0400
Subject: [PATCH 004/109] New package: ffmpeg4-4.4.4.

---
 srcpkgs/ffmpeg4-devel                         |   1 +
 srcpkgs/ffmpeg4/files/altivec.patch           |  60 +++++
 .../patches/armv5tel-floating-point.patch     |  18 ++
 srcpkgs/ffmpeg4/patches/binutils-2.41.patch   |  73 ++++++
 ...h-libavcodec-libsvtav1-ten_bit_format.diff |  40 +++
 .../workaround-mesa-readeon-vaapi-bug.patch   |  28 +++
 srcpkgs/ffmpeg4/template                      | 234 ++++++++++++++++++
 srcpkgs/libavcodec4                           |   1 +
 srcpkgs/libavdevice4                          |   1 +
 srcpkgs/libavfilter4                          |   1 +
 srcpkgs/libavformat4                          |   1 +
 srcpkgs/libavresample4                        |   1 +
 srcpkgs/libavutil4                            |   1 +
 srcpkgs/libpostproc4                          |   1 +
 srcpkgs/libswresample4                        |   1 +
 srcpkgs/libswscale4                           |   1 +
 16 files changed, 463 insertions(+)
 create mode 120000 srcpkgs/ffmpeg4-devel
 create mode 100644 srcpkgs/ffmpeg4/files/altivec.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/binutils-2.41.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 create mode 100644 srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
 create mode 100644 srcpkgs/ffmpeg4/template
 create mode 120000 srcpkgs/libavcodec4
 create mode 120000 srcpkgs/libavdevice4
 create mode 120000 srcpkgs/libavfilter4
 create mode 120000 srcpkgs/libavformat4
 create mode 120000 srcpkgs/libavresample4
 create mode 120000 srcpkgs/libavutil4
 create mode 120000 srcpkgs/libpostproc4
 create mode 120000 srcpkgs/libswresample4
 create mode 120000 srcpkgs/libswscale4

diff --git a/srcpkgs/ffmpeg4-devel b/srcpkgs/ffmpeg4-devel
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/ffmpeg4-devel
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/ffmpeg4/files/altivec.patch b/srcpkgs/ffmpeg4/files/altivec.patch
new file mode 100644
index 00000000000000..9c57200463320e
--- /dev/null
+++ b/srcpkgs/ffmpeg4/files/altivec.patch
@@ -0,0 +1,60 @@
+revert some altivec specific change on all ppc* except ppc64le*
+
+q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
+conditionally, for ppc* but not ppc64le* (the new code is valid for
+POWER8 VSX which LE targets as a baseline but not BE)"
+
+
+This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
+---
+ libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
+ 1 file changed, 20 insertions(+), 4 deletions(-)
+
+diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
+index 536545293d..c1e2852adb 100644
+--- a/libswscale/ppc/yuv2rgb_altivec.c
++++ b/libswscale/ppc/yuv2rgb_altivec.c
+@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+     vector signed short R1, G1, B1;                                           \
+     vector unsigned char R, G, B;                                             \
+                                                                               \
++    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
++    vector unsigned char align_perm;                                          \
++                                                                              \
+     vector signed short lCY       = c->CY;                                    \
+     vector signed short lOY       = c->OY;                                    \
+     vector signed short lCRV      = c->CRV;                                   \
+@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
+                                                                               \
+         for (j = 0; j < w / 16; j++) {                                        \
+-            y0 = vec_xl(0, y1i);                                              \
++            y1ivP = (const vector unsigned char *) y1i;                       \
++            y2ivP = (const vector unsigned char *) y2i;                       \
++            uivP  = (const vector unsigned char *) ui;                        \
++            vivP  = (const vector unsigned char *) vi;                        \
++                                                                              \
++            align_perm = vec_lvsl(0, y1i);                                    \
++            y0 = (vector unsigned char)                                       \
++                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
+                                                                               \
+-            y1 = vec_xl(0, y2i);                                              \
++            align_perm = vec_lvsl(0, y2i);                                    \
++            y1 = (vector unsigned char)                                       \
++                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
+                                                                               \
+-            u = (vector signed char) vec_xl(0, ui);                           \
++            align_perm = vec_lvsl(0, ui);                                     \
++            u = (vector signed char)                                          \
++                    vec_perm(uivP[0], uivP[1], align_perm);                   \
+                                                                               \
+-            v = (vector signed char) vec_xl(0, vi);                           \
++            align_perm = vec_lvsl(0, vi);                                     \
++            v = (vector signed char)                                          \
++                    vec_perm(vivP[0], vivP[1], align_perm);                   \
+                                                                               \
+             u = (vector signed char)                                          \
+                     vec_sub(u,                                                \
+-- 
+2.27.0
+
diff --git a/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
new file mode 100644
index 00000000000000..9a55178c74f0fd
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
@@ -0,0 +1,18 @@
+--- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
++++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
+@@ -39,6 +39,15 @@
+ #endif
+ #include <fenv.h>
+ 
++#if (FE_ALL_EXCEPT == 0)
++/* E.g. ARM soft float does not define these */
++#define FE_INVALID    0
++#define FE_DIVBYZERO  0
++#define FE_OVERFLOW   0
++#define FE_UNDERFLOW  0
++#define FE_INEXACT    0
++#endif
++
+ #if CONFIG_LIBFONTCONFIG
+ #include <fontconfig/fontconfig.h>
+ #endif
diff --git a/srcpkgs/ffmpeg4/patches/binutils-2.41.patch b/srcpkgs/ffmpeg4/patches/binutils-2.41.patch
new file mode 100644
index 00000000000000..53a596d0ee7d4e
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/binutils-2.41.patch
@@ -0,0 +1,73 @@
+From effadce6c756247ea8bae32dc13bb3e6f464f0eb Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= <remi@remlab.net>
+Date: Sun, 16 Jul 2023 18:18:02 +0300
+Subject: [PATCH] avcodec/x86/mathops: clip constants used with shift
+ instructions within inline assembly
+
+Fixes assembling with binutil as >= 2.41
+
+Signed-off-by: James Almer <jamrial@gmail.com>
+---
+ libavcodec/x86/mathops.h | 26 +++++++++++++++++++++++---
+ 1 file changed, 23 insertions(+), 3 deletions(-)
+
+diff --git a/libavcodec/x86/mathops.h b/libavcodec/x86/mathops.h
+index 6298f5ed1983b..ca7e2dffc1076 100644
+--- a/libavcodec/x86/mathops.h
++++ b/libavcodec/x86/mathops.h
+@@ -35,12 +35,20 @@
+ static av_always_inline av_const int MULL(int a, int b, unsigned shift)
+ {
+     int rt, dummy;
++    if (__builtin_constant_p(shift))
+     __asm__ (
+         "imull %3               \n\t"
+         "shrdl %4, %%edx, %%eax \n\t"
+         :"=a"(rt), "=d"(dummy)
+-        :"a"(a), "rm"(b), "ci"((uint8_t)shift)
++        :"a"(a), "rm"(b), "i"(shift & 0x1F)
+     );
++    else
++        __asm__ (
++            "imull %3               \n\t"
++            "shrdl %4, %%edx, %%eax \n\t"
++            :"=a"(rt), "=d"(dummy)
++            :"a"(a), "rm"(b), "c"((uint8_t)shift)
++        );
+     return rt;
+ }
+ 
+@@ -113,19 +121,31 @@ __asm__ volatile(\
+ // avoid +32 for shift optimization (gcc should do that ...)
+ #define NEG_SSR32 NEG_SSR32
+ static inline  int32_t NEG_SSR32( int32_t a, int8_t s){
++    if (__builtin_constant_p(s))
+     __asm__ ("sarl %1, %0\n\t"
+          : "+r" (a)
+-         : "ic" ((uint8_t)(-s))
++         : "i" (-s & 0x1F)
+     );
++    else
++        __asm__ ("sarl %1, %0\n\t"
++               : "+r" (a)
++               : "c" ((uint8_t)(-s))
++        );
+     return a;
+ }
+ 
+ #define NEG_USR32 NEG_USR32
+ static inline uint32_t NEG_USR32(uint32_t a, int8_t s){
++    if (__builtin_constant_p(s))
+     __asm__ ("shrl %1, %0\n\t"
+          : "+r" (a)
+-         : "ic" ((uint8_t)(-s))
++         : "i" (-s & 0x1F)
+     );
++    else
++        __asm__ ("shrl %1, %0\n\t"
++               : "+r" (a)
++               : "c" ((uint8_t)(-s))
++        );
+     return a;
+ }
+ 
diff --git a/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
new file mode 100644
index 00000000000000..aa948f7a8a2dfb
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
@@ -0,0 +1,40 @@
+#==================================================================================================
+# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
+# From: Christopher Degawa <christopher.degawa@intel.com>
+# Date: Thu, 20 Oct 2022 22:55:27 -0500
+# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
+#
+# compressed_ten_bit_format has been deprecated upstream and has no effect
+# and can be removed. Plus, technically it was never used in the first place
+# since it would require the app (ffmpeg) to set it and do additional
+# processing of the input frames.
+#
+# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
+#
+# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
+#==================================================================================================
+--- a/libavcodec/libsvtav1.c
++++ b/libavcodec/libsvtav1.c
+@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
+ 
+ static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
+ {
+-    const int    pack_mode_10bit =
+-        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
+-    const size_t luma_size_8bit  =
+-        config->source_width * config->source_height * (1 << pack_mode_10bit);
+-    const size_t luma_size_10bit =
+-        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
++    const size_t luma_size = config->source_width * config->source_height *
++        (config->encoder_bit_depth > 8 ? 2 : 1);
+ 
+     EbSvtIOFormat *in_data;
+ 
+-    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
++    svt_enc->raw_size = luma_size * 3 / 2;
+ 
+     // allocate buffer for in and out
+     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
+-- 
+GitLab
+
diff --git a/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
new file mode 100644
index 00000000000000..00e3f68a415b84
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
@@ -0,0 +1,28 @@
+From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
+From: Rainer Hochecker <fernetmenta@online.de>
+Date: Sat, 26 Jan 2019 19:48:35 +0100
+Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
+
+This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
+It was hit frequently when watching h264 channels received via DVB-X.
+Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
+---
+ libavcodec/vaapi_h264.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
+index 5854587a255..f12fdc457a4 100644
+--- a/libavcodec/vaapi_h264.c
++++ b/libavcodec/vaapi_h264.c
+@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
+     H264SliceContext *sl = &h->slice_ctx[0];
+     int ret;
+ 
++    if (pic->nb_slices == 0) {
++        ret = AVERROR_INVALIDDATA;
++        goto finish;
++    }
++
+     ret = ff_vaapi_decode_issue(avctx, pic);
+     if (ret < 0)
+         goto finish;
diff --git a/srcpkgs/ffmpeg4/template b/srcpkgs/ffmpeg4/template
new file mode 100644
index 00000000000000..9ba14bdb8ddf32
--- /dev/null
+++ b/srcpkgs/ffmpeg4/template
@@ -0,0 +1,234 @@
+# Template file for 'ffmpeg4'
+# audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
+pkgname=ffmpeg4
+version=4.4.4
+revision=1
+short_desc="Decoding, encoding and streaming software - ffmpeg4 libraries only"
+maintainer="Orphaned <orphan@voidlinux.org>"
+license="GPL-3.0-or-later"
+homepage="https://www.ffmpeg.org"
+changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
+distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
+checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+
+hostmakedepends="pkg-config perl"
+makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
+ libXext-devel libXvMC-devel libxcb-devel lame-devel libtheora-devel
+ libvorbis-devel x264-devel xvidcore-devel jack-devel SDL2-devel
+ libcdio-paranoia-devel librtmp-devel libmodplug-devel gnutls-devel
+ speex-devel celt-devel harfbuzz-devel libass-devel opus-devel ocl-icd-devel
+ libbs2b-devel libvidstab-devel vmaf-devel $(vopt_if pulseaudio pulseaudio-devel)
+ $(vopt_if vaapi libva-devel) $(vopt_if vdpau libvdpau-devel)
+ $(vopt_if x265 x265-devel) $(vopt_if v4l2 v4l-utils-devel)
+ $(vopt_if fdk_aac fdk-aac-devel) $(vopt_if vpx libvpx-devel)
+ $(vopt_if aom libaom-devel) $(vopt_if sndio sndio-devel)
+ $(vopt_if dav1d libdav1d-devel) $(vopt_if zimg zimg-devel)
+ $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
+ $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
+ $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
+
+build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
+
+desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
+desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
+desc_option_sofa="Enable support for AES SOFA"
+desc_option_webp="Enable support for WebP"
+
+case "$XBPS_TARGET_MACHINE" in
+	i686*|x86_64*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau nvenc nvdec"
+			;;
+	ppc64*) build_options_default+=" vaapi vdpau";;
+	mips*) CFLAGS="-mnan=legacy";;
+esac
+
+if [ "$XBPS_TARGET_WORDSIZE" != "32" ]; then
+	build_options_default+=" svtav1"
+fi
+
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+fi
+
+_apply_patch() {
+	local args="$1" pname="$(basename $2)"
+
+	if [ ! -f ".${pname}_done" ]; then
+		patch -N $args -i $2
+		touch .${pname}_done
+	fi
+}
+
+post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64le*) ;;
+		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
+	esac
+
+	vsed -i libavfilter/vf_libvmaf.c -e 's!/usr/local/share/model/\(vmaf_v0.6.1\).pkl!/usr/share/vmaf/\1.json!'
+}
+
+do_configure() {
+	# Fix gcc on x86_64-musl only
+	if [ "$XBPS_TARGET_MACHINE" = "x86_64-musl" ]; then
+		vsed -i configure -e "s;_cflags_speed='-O3';_cflags_speed='-O2';"
+	fi
+
+	if [ "$CROSS_BUILD" ]; then
+		case "$XBPS_TARGET_MACHINE" in
+			arm*) _arch="arm";;
+			aarch64*) _arch="aarch64";;
+			mips*) _arch="mips";;
+			ppc64*) _arch="ppc64";;
+			ppc*) _arch="ppc";;
+			*) _arch="${XBPS_TARGET_MACHINE%%-musl}";;
+		esac
+
+		_args+=" --enable-cross-compile
+			--sysroot=$XBPS_CROSS_BASE
+			--cross-prefix=${XBPS_CROSS_TRIPLET}-
+			--target-os=linux --arch=${_arch}"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc|ppc-musl) _args+=" --disable-altivec";;
+	esac
+
+	if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+		_args+=" --extra-libs=-latomic"
+	fi
+
+	./configure --prefix=/usr --disable-debug --enable-gpl --enable-gnutls \
+		--disable-stripping \
+		--enable-libcdio --enable-version3 --enable-runtime-cpudetect \
+		--enable-libmp3lame --enable-libvorbis --enable-libxvid \
+		--enable-libx264 $(vopt_enable vpx libvpx) --enable-libtheora \
+		--enable-shared --enable-static --enable-libxcb \
+		$(vopt_enable pulseaudio libpulse) --enable-libfreetype --enable-libmodplug \
+		--enable-libspeex --enable-libcelt --enable-libass \
+		--enable-libopus --enable-librtmp --enable-libjack \
+		$(vopt_if fdk_aac '--enable-nonfree --enable-libfdk-aac') \
+		--disable-libopencore_amrnb --disable-libopencore_amrwb \
+		--disable-libopenjpeg \
+		--enable-postproc --enable-opencl ${_args} --enable-libvmaf ${_args} \
+		$(vopt_enable x265 libx265) \
+		$(vopt_enable v4l2 libv4l2) \
+		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
+		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		$(vopt_enable dav1d libdav1d) \
+		$(vopt_enable zimg libzimg) \
+		$(vopt_enable webp libwebp) \
+		$(vopt_enable sofa libmysofa) \
+		$(vopt_enable vulkan) \
+		$(vopt_enable drm libdrm) \
+		$(vopt_enable svtav1 libsvtav1) \
+		$(vopt_enable srt libsrt) \
+		$(vopt_enable rist librist) \
+		$(vopt_if nvenc '--enable-nvenc') \
+		$(vopt_if nvdec '--enable-nvdec')
+}
+
+do_build() {
+	make ${makejobs}
+	make doc/ff{mpeg,play}.1
+}
+
+do_install() {
+	make DESTDIR=${DESTDIR} install install-man
+	rm -rf ${DESTDIR}/usr/bin
+}
+
+libavcodec4_package() {
+	short_desc="FFmpeg codec library"
+	pkg_install() {
+		vmove "usr/lib/libavcodec.so.*"
+	}
+}
+
+libavdevice4_package() {
+	short_desc="FFmpeg device handling library"
+	pkg_install() {
+		vmove "usr/lib/libavdevice.so.*"
+	}
+}
+
+libavresample4_package() {
+	short_desc="FFmpeg audio resampling library"
+	pkg_install() {
+		vmove "usr/lib/libavresample.so.*"
+	}
+}
+
+libavformat4_package() {
+	short_desc="FFmpeg file format library"
+	pkg_install() {
+		vmove "usr/lib/libavformat.so.*"
+	}
+}
+
+libavutil4_package() {
+	short_desc="FFmpeg utility library"
+	pkg_install() {
+		vmove "usr/lib/libavutil.so.*"
+	}
+}
+
+libavfilter4_package() {
+	short_desc="FFmpeg audio/video filter library"
+	pkg_install() {
+		vmove "usr/lib/libavfilter.so.*"
+	}
+}
+
+libpostproc4_package() {
+	short_desc="FFmpeg video postprocessing library"
+	pkg_install() {
+		vmove "usr/lib/libpostproc.so.*"
+	}
+}
+
+libswscale4_package() {
+	short_desc="FFmpeg video scaling library"
+	pkg_install() {
+		vmove "usr/lib/libswscale.so.*"
+	}
+}
+
+libswresample4_package() {
+	short_desc="FFmpeg video resampling library"
+	pkg_install() {
+		vmove "usr/lib/libswresample.so.*"
+	}
+}
+
+ffmpeg4-devel_package() {
+	depends="
+		libavcodec4>=${version}_${revision}
+		libavdevice4>=${version}_${revision}
+		libavformat4>=${version}_${revision}
+		libavutil4>=${version}_${revision}
+		libavfilter4>=${version}_${revision}
+		libpostproc4>=${version}_${revision}
+		libswscale4>=${version}_${revision}
+		libswresample4>=${version}_${revision}
+		libavresample4>=${version}_${revision}"
+	short_desc+=" - development files"
+	conflicts="ffmpeg-devel"
+	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
+		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
+		nostrip_files="/usr/lib/libavfilter.a"
+	fi
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.a"
+		vmove "usr/lib/*.so"
+		vmove usr/share/ffmpeg/examples
+		vmove usr/share/man/man3
+	}
+}
diff --git a/srcpkgs/libavcodec4 b/srcpkgs/libavcodec4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavcodec4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavdevice4 b/srcpkgs/libavdevice4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavdevice4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavfilter4 b/srcpkgs/libavfilter4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavfilter4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavformat4 b/srcpkgs/libavformat4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavformat4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavresample4 b/srcpkgs/libavresample4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavutil4 b/srcpkgs/libavutil4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavutil4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libpostproc4 b/srcpkgs/libpostproc4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libpostproc4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswresample4 b/srcpkgs/libswresample4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libswresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswscale4 b/srcpkgs/libswscale4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libswscale4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file

From d231e5549b6e9a8feffd571fe121290945ea0c97 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:04 -0400
Subject: [PATCH 005/109] opencv: update to 4.7.0.

---
 common/shlibs           | 104 ++++++++++++++++++++--------------------
 srcpkgs/opencv/template |   8 ++--
 2 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index 7861aab64f3a25..47b3223df78908 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2082,58 +2082,58 @@ libcapstone.so.5 capstone-5.0.1_1
 libhavege.so.2 libhaveged-1.9.11_1
 libnih.so.1 libnih-1.0.3_1
 libnih-dbus.so.1 libnih-1.0.3_1
-libopencv_quality.so.406 libopencv-4.6.0_1
-libopencv_reg.so.406 libopencv-4.6.0_1
-libopencv_surface_matching.so.406 libopencv-4.6.0_1
-libopencv_xphoto.so.406 libopencv-4.6.0_1
-libopencv_freetype.so.406 libopencv-4.6.0_1
-libopencv_fuzzy.so.406 libopencv-4.6.0_1
-libopencv_hfs.so.406 libopencv-4.6.0_1
-libopencv_img_hash.so.406 libopencv-4.6.0_1
-libopencv_line_descriptor.so.406 libopencv-4.6.0_1
-libopencv_saliency.so.406 libopencv-4.6.0_1
-libopencv_structured_light.so.406 libopencv-4.6.0_1
-libopencv_aruco.so.406 libopencv-4.6.0_1
-libopencv_bgsegm.so.406 libopencv-4.6.0_1
-libopencv_bioinspired.so.406 libopencv-4.6.0_1
-libopencv_ccalib.so.406 libopencv-4.6.0_1
-libopencv_face.so.406 libopencv-4.6.0_1
-libopencv_tracking.so.406 libopencv-4.6.0_1
-libopencv_xfeatures2d.so.406 libopencv-4.6.0_1
-libopencv_optflow.so.406 libopencv-4.6.0_1
-libopencv_ximgproc.so.406 libopencv-4.6.0_1
-libopencv_plot.so.406 libopencv-4.6.0_1
-libopencv_text.so.406 libopencv-4.6.0_1
-libopencv_ml.so.406 libopencv-4.6.0_1
-libopencv_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn.so.406 libopencv-4.6.0_1
-libopencv_shape.so.406 libopencv-4.6.0_1
-libopencv_stitching.so.406 libopencv-4.6.0_1
-libopencv_photo.so.406 libopencv-4.6.0_1
-libopencv_video.so.406 libopencv-4.6.0_1
-libopencv_calib3d.so.406 libopencv-4.6.0_1
-libopencv_features2d.so.406 libopencv-4.6.0_1
-libopencv_flann.so.406 libopencv-4.6.0_1
-libopencv_highgui.so.406 libopencv-4.6.0_1
-libopencv_videoio.so.406 libopencv-4.6.0_1
-libopencv_imgcodecs.so.406 libopencv-4.6.0_1
-libopencv_imgproc.so.406 libopencv-4.6.0_1
-libopencv_core.so.406 libopencv-4.6.0_1
-libopencv_superres.so.406 libopencv-4.6.0_1
-libopencv_videostab.so.406 libopencv-4.6.0_1
-libopencv_gapi.so.406 libopencv-4.6.0_1
-libopencv_xobjdetect.so.406 libopencv-4.6.0_1
-libopencv_datasets.so.406 libopencv-4.6.0_1
-libopencv_dnn_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn_superres.so.406 libopencv-4.6.0_1
-libopencv_dpm.so.406 libopencv-4.6.0_1
-libopencv_phase_unwrapping.so.406 libopencv-4.6.0_1
-libopencv_stereo.so.406 libopencv-4.6.0_1
-libopencv_rapid.so.406 libopencv-4.6.0_1
-libopencv_intensity_transform.so.406 libopencv-4.6.0_1
-libopencv_alphamat.so.406 libopencv-4.6.0_1
-libopencv_barcode.so.406 libopencv-4.6.0_1
-libopencv_mcc.so.406 libopencv-4.6.0_1
+libopencv_quality.so.407 libopencv-4.7.0_1
+libopencv_reg.so.407 libopencv-4.7.0_1
+libopencv_surface_matching.so.407 libopencv-4.7.0_1
+libopencv_xphoto.so.407 libopencv-4.7.0_1
+libopencv_freetype.so.407 libopencv-4.7.0_1
+libopencv_fuzzy.so.407 libopencv-4.7.0_1
+libopencv_hfs.so.407 libopencv-4.7.0_1
+libopencv_img_hash.so.407 libopencv-4.7.0_1
+libopencv_line_descriptor.so.407 libopencv-4.7.0_1
+libopencv_saliency.so.407 libopencv-4.7.0_1
+libopencv_structured_light.so.407 libopencv-4.7.0_1
+libopencv_aruco.so.407 libopencv-4.7.0_1
+libopencv_bgsegm.so.407 libopencv-4.7.0_1
+libopencv_bioinspired.so.407 libopencv-4.7.0_1
+libopencv_ccalib.so.407 libopencv-4.7.0_1
+libopencv_face.so.407 libopencv-4.7.0_1
+libopencv_tracking.so.407 libopencv-4.7.0_1
+libopencv_xfeatures2d.so.407 libopencv-4.7.0_1
+libopencv_optflow.so.407 libopencv-4.7.0_1
+libopencv_ximgproc.so.407 libopencv-4.7.0_1
+libopencv_plot.so.407 libopencv-4.7.0_1
+libopencv_text.so.407 libopencv-4.7.0_1
+libopencv_ml.so.407 libopencv-4.7.0_1
+libopencv_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn.so.407 libopencv-4.7.0_1
+libopencv_shape.so.407 libopencv-4.7.0_1
+libopencv_stitching.so.407 libopencv-4.7.0_1
+libopencv_photo.so.407 libopencv-4.7.0_1
+libopencv_video.so.407 libopencv-4.7.0_1
+libopencv_calib3d.so.407 libopencv-4.7.0_1
+libopencv_features2d.so.407 libopencv-4.7.0_1
+libopencv_flann.so.407 libopencv-4.7.0_1
+libopencv_highgui.so.407 libopencv-4.7.0_1
+libopencv_videoio.so.407 libopencv-4.7.0_1
+libopencv_imgcodecs.so.407 libopencv-4.7.0_1
+libopencv_imgproc.so.407 libopencv-4.7.0_1
+libopencv_core.so.407 libopencv-4.7.0_1
+libopencv_superres.so.407 libopencv-4.7.0_1
+libopencv_videostab.so.407 libopencv-4.7.0_1
+libopencv_gapi.so.407 libopencv-4.7.0_1
+libopencv_xobjdetect.so.407 libopencv-4.7.0_1
+libopencv_datasets.so.407 libopencv-4.7.0_1
+libopencv_dnn_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn_superres.so.407 libopencv-4.7.0_1
+libopencv_dpm.so.407 libopencv-4.7.0_1
+libopencv_phase_unwrapping.so.407 libopencv-4.7.0_1
+libopencv_stereo.so.407 libopencv-4.7.0_1
+libopencv_rapid.so.407 libopencv-4.7.0_1
+libopencv_intensity_transform.so.407 libopencv-4.7.0_1
+libopencv_alphamat.so.407 libopencv-4.7.0_1
+libopencv_barcode.so.407 libopencv-4.7.0_1
+libopencv_mcc.so.407 libopencv-4.7.0_1
 libuniconf.so.4.6 wvstreams-4.6.1_20
 libwvbase.so.4.6 wvstreams-4.6.1_20
 libwvutils.so.4.6 wvstreams-4.6.1_20
diff --git a/srcpkgs/opencv/template b/srcpkgs/opencv/template
index aea4bfc3a265cf..ce94de9424d18d 100644
--- a/srcpkgs/opencv/template
+++ b/srcpkgs/opencv/template
@@ -1,7 +1,7 @@
 # Template file for 'opencv'
 pkgname=opencv
-version=4.6.0
-revision=6
+version=4.7.0
+revision=1
 create_wrksrc=yes
 build_wrksrc=${pkgname}-${version}
 build_style=cmake
@@ -24,8 +24,8 @@ homepage="https://opencv.org"
 changelog="https://github.com/opencv/opencv/wiki/ChangeLog"
 distfiles="https://github.com/opencv/opencv/archive/${version}.tar.gz
  https://github.com/opencv/opencv_contrib/archive/${version}.tar.gz>contrib.tar.gz"
-checksum="1ec1cba65f9f20fe5a41fda1586e01c70ea0c9a6d7b67c9e13edf0cfe2239277
- 1777d5fd2b59029cf537e5fd6f8aa68d707075822f90bde683fcde086f85f7a7"
+checksum="8df0079cdbe179748a18d44731af62a245a45ebf5085223dc03133954c662973
+ 42df840cf9055e59d0e22c249cfb19f04743e1bdad113d31b1573d3934d62584"
 patch_args="-Np1 -d ${build_wrksrc}"
 # tests hang indenfinitely, even with test data included
 make_check=no

From fa188acba06e2c8bf9b7719763b99edbe515f515 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 006/109] actiona: revbump for opencv-4.7.0

---
 srcpkgs/actiona/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/actiona/template b/srcpkgs/actiona/template
index cf5f0b7a2ae610..0d899311e6df75 100644
--- a/srcpkgs/actiona/template
+++ b/srcpkgs/actiona/template
@@ -1,7 +1,7 @@
 # Template file for 'actiona'
 pkgname=actiona
 version=3.10.1
-revision=2
+revision=3
 build_style=qmake
 configure_args="PKGCONFIG_OPENCV=opencv4"
 hostmakedepends="pkg-config qt5-plugin-mysql qt5-qmake qt5-host-tools"

From 85c35acf6a0278e42fd160215edb2c486ed06367 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 007/109] retroshare: revbump for opencv-4.7.0

---
 srcpkgs/retroshare/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroshare/template b/srcpkgs/retroshare/template
index bb17569277a7f3..49e2c1cbe8a531 100644
--- a/srcpkgs/retroshare/template
+++ b/srcpkgs/retroshare/template
@@ -1,7 +1,7 @@
 # Template file for 'retroshare'
 pkgname=retroshare
 version=0.6.6
-revision=3
+revision=4
 build_style=qmake
 #XXX broadcast feature requires an ancient udp-discovery-cpp which either needs
 # to be fetched+patched (FTBFS) here or packaged :/

From bf70641afae38ce672114dec64bb5d476823d1a5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 008/109] waifu2x-converter-cpp: revbump for opencv-4.7.0

---
 srcpkgs/waifu2x-converter-cpp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waifu2x-converter-cpp/template b/srcpkgs/waifu2x-converter-cpp/template
index 361b8a23b94977..c5ac17eb54ea4c 100644
--- a/srcpkgs/waifu2x-converter-cpp/template
+++ b/srcpkgs/waifu2x-converter-cpp/template
@@ -1,7 +1,7 @@
 # Template file for 'waifu2x-converter-cpp'
 pkgname=waifu2x-converter-cpp
 version=5.2.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DINSTALL_MODELS=ON"
 hostmakedepends="pkg-config"

From 8751c00dfc3c50a7e2121cf95f27f3671a630b98 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:38 -0400
Subject: [PATCH 009/109] vlc: revbump for ffmpeg4

---
 srcpkgs/vlc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/vlc/template b/srcpkgs/vlc/template
index 559b1c4fff339f..fc399f1a6e9bfc 100644
--- a/srcpkgs/vlc/template
+++ b/srcpkgs/vlc/template
@@ -1,7 +1,7 @@
 # Template file for 'vlc'
 pkgname=vlc
 version=3.0.20
-revision=4
+revision=5
 build_style=gnu-configure
 configure_args="--disable-gme --disable-libtar --enable-jack
  --enable-live555 --disable-fluidsynth --enable-dvdread
@@ -25,7 +25,7 @@ lib32disabled=yes
 hostmakedepends="automake libtool pkg-config flex gettext libgcrypt-devel
  live555-devel gettext-devel $(vopt_if lua lua52) $(vopt_if chromecast protobuf)"
 makedepends="
- avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg-devel freefont-ttf
+ avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg4-devel freefont-ttf
  gnutls-devel jack-devel liba52-devel libass-devel libbluray-devel
  libcdio-devel libdca-devel libdvbpsi-devel libdvdnav-devel libmad-devel
  libmatroska-devel libmodplug-devel libmpcdec-devel libmpeg2-devel

From b28ebb89456c9c448a22e82f82c5e04fb709f9c6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:55 -0400
Subject: [PATCH 010/109] osg: revbump for ffmpeg4

---
 srcpkgs/osg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/osg/template b/srcpkgs/osg/template
index 8ef0efc599a1b1..a131ceaf7a867b 100644
--- a/srcpkgs/osg/template
+++ b/srcpkgs/osg/template
@@ -8,7 +8,7 @@ build_helper="qemu"
 configure_args="-DLIB_POSTFIX="
 hostmakedepends="pkg-config xrandr"
 makedepends="MesaLib-devel gtkglext-devel libcurl-devel giflib-devel librsvg-devel
- jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg-devel xine-lib-devel
+ jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg4-devel xine-lib-devel
  SDL2-devel gst-plugins-base1-devel
  $(vopt_if openexr libopenexr-devel)
  $(vopt_if poppler poppler-glib-devel)

From dc39e1bf72a274439ee020c419bb3dc0bfcc2532 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:13 -0400
Subject: [PATCH 011/109] xine-lib: revbump for ffmpeg4

---
 srcpkgs/xine-lib/template | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/xine-lib/template b/srcpkgs/xine-lib/template
index 3be4d08eac77a3..ed6194c17d11e8 100644
--- a/srcpkgs/xine-lib/template
+++ b/srcpkgs/xine-lib/template
@@ -1,14 +1,14 @@
 # Template file for 'xine-lib'
 pkgname=xine-lib
-version=1.2.12
-revision=3
+version=1.2.13
+revision=1
 build_style=gnu-configure
 configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
  --disable-oss"
 hostmakedepends="automake gettext-devel libtool pkg-config perl"
 makedepends="
  zlib-devel alsa-lib-devel libxcb-devel libSM-devel libXext-devel libXv-devel
- libXvMC-devel liba52-devel libmad-devel ffmpeg-devel pulseaudio-devel
+ libXvMC-devel liba52-devel libmad-devel ffmpeg4-devel pulseaudio-devel
  jack-devel samba-devel libflac-devel libmodplug-devel libmpcdec-devel
  speex-devel libtheora-devel libvorbis-devel libdca-devel faad2-devel
  libcdio-devel libbluray-devel aalib-devel libcaca-devel libXinerama-devel
@@ -19,7 +19,7 @@ license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="http://www.xine-project.org"
 changelog="https://sourceforge.net/projects/xine/files/xine-lib/${version}/README.txt/view"
 distfiles="${SOURCEFORGE_SITE}/xine/${pkgname}-${version}.tar.xz"
-checksum=d606270468e1540c2a89c0d7f5fdf11e17ecc0c2698cc0bcb1065ff26abee098
+checksum=5f10d6d718a4a51c17ed1b32b031d4f9b80b061e8276535b2be31e5ac4b75e6f
 
 case "$XBPS_TARGET_MACHINE" in
 	i686-musl)

From f1e75ba2176644b6ee9336e3cb0c3d1a0675a505 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 012/109] attract: revbump for ffmpeg6

---
 srcpkgs/attract/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/attract/template b/srcpkgs/attract/template
index e769fb15456217..776cbe4ebd2c93 100644
--- a/srcpkgs/attract/template
+++ b/srcpkgs/attract/template
@@ -1,7 +1,7 @@
 # Template file for 'attract'
 pkgname=attract
 version=2.7.0
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="VERBOSE=1"
 make_use_env=yes

From ac33febf73f2b5ae4a73475d307fcba819eee590 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 013/109] aubio: revbump for ffmpeg6

---
 srcpkgs/aubio/patches/ffmpeg5.patch | 25 +++++++++++++++++++++++++
 srcpkgs/aubio/template              |  2 +-
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/aubio/patches/ffmpeg5.patch

diff --git a/srcpkgs/aubio/patches/ffmpeg5.patch b/srcpkgs/aubio/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..aace41a6e6d9a4
--- /dev/null
+++ b/srcpkgs/aubio/patches/ffmpeg5.patch
@@ -0,0 +1,25 @@
+From 8a05420e5dd8c7b8b2447f82dc919765876511b3 Mon Sep 17 00:00:00 2001
+From: Paul Brossier <piem@piem.org>
+Date: Tue, 25 Jan 2022 18:30:27 +0100
+Subject: [PATCH] [source_avcodec] define FF_API_LAVF_AVCTX for libavcodec >
+ 59, thx @berolinux (closes gh-353)
+
+---
+ src/io/source_avcodec.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/io/source_avcodec.c b/src/io/source_avcodec.c
+index e0ae93b5..1421bd9a 100644
+--- a/src/io/source_avcodec.c
++++ b/src/io/source_avcodec.c
+@@ -68,6 +68,10 @@
+ #define AUBIO_AVCODEC_MAX_BUFFER_SIZE AV_INPUT_BUFFER_MIN_SIZE
+ #endif
+ 
++#if LIBAVCODEC_VERSION_MAJOR >= 59
++#define FF_API_LAVF_AVCTX 1
++#endif
++
+ struct _aubio_source_avcodec_t {
+   uint_t hop_size;
+   uint_t samplerate;
diff --git a/srcpkgs/aubio/template b/srcpkgs/aubio/template
index ad1c4b25699178..7d875cc02541a7 100644
--- a/srcpkgs/aubio/template
+++ b/srcpkgs/aubio/template
@@ -1,7 +1,7 @@
 # Template file for 'aubio'
 pkgname=aubio
 version=0.4.9
-revision=1
+revision=2
 build_style=waf3
 # XXX lash, pure and swig support.
 hostmakedepends="pkg-config txt2man"

From 9213776101d45167746e6c8f94e6cf8ce8facf9d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 014/109] audacious-plugins: revbump for ffmpeg6

---
 .../audacious-plugins/patches/ffmpeg5.patch   | 43 +++++++++++++++++++
 srcpkgs/audacious-plugins/template            |  2 +-
 2 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/audacious-plugins/patches/ffmpeg5.patch

diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg5.patch b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..4e5e34099d71c4
--- /dev/null
+++ b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
@@ -0,0 +1,43 @@
+commit 298aa371c56c2f52c25a33d9bdec4918b11cebdc
+Author: tibequadorian <tibequadorian@posteo.de>
+Date:   Sat Mar 19 18:40:12 2022 +0100
+
+    audacious-plugins: rebuild against ffmpeg-5.0
+
+diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+new file mode 100644
+index 0000000000..617c11215b
+--- /dev/null
++++ b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+@@ -0,0 +1,31 @@
++From f60beb400eeb1e4778bbfd738bc4a4ccef3de539 Mon Sep 17 00:00:00 2001
++From: John Lindgren <john@jlindgren.net>
++Date: Sat, 5 Mar 2022 12:05:34 -0500
++Subject: [PATCH] Fix build with FFmpeg 5.0
++
++---
++ src/ffaudio/ffaudio-core.cc | 4 ++--
++ 1 file changed, 2 insertions(+), 2 deletions(-)
++
++diff --git a/src/ffaudio/ffaudio-core.cc b/src/ffaudio/ffaudio-core.cc
++index 16dc63e3a..a2b95fd6c 100644
++--- a/src/ffaudio/ffaudio-core.cc
+++++ b/src/ffaudio/ffaudio-core.cc
++@@ -274,7 +274,7 @@ static AVInputFormat * get_format_by_content (const char * name, VFSFile & file)
++         AVProbeData d = {name, buf, filled};
++         score = target;
++ 
++-        f = av_probe_input_format2 (& d, true, & score);
+++        f = (AVInputFormat *) av_probe_input_format2 (& d, true, & score);
++         if (f)
++             break;
++ 
++@@ -347,7 +347,7 @@ static bool find_codec (AVFormatContext * c, CodecInfo * cinfo)
++ #endif
++         if (stream && stream->codecpar && stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
++         {
++-            AVCodec * codec = avcodec_find_decoder (stream->codecpar->codec_id);
+++            AVCodec * codec = (AVCodec *) avcodec_find_decoder (stream->codecpar->codec_id);
++ 
++             if (codec)
++             {
diff --git a/srcpkgs/audacious-plugins/template b/srcpkgs/audacious-plugins/template
index 05e53a9adf78ff..4b1968e03de781 100644
--- a/srcpkgs/audacious-plugins/template
+++ b/srcpkgs/audacious-plugins/template
@@ -2,7 +2,7 @@
 #Keep in sync with audacious!
 pkgname=audacious-plugins
 version=4.3.1
-revision=3
+revision=4
 build_style=meson
 configure_args="$(vopt_bool gtk3 gtk) $(vopt_bool gtk3)
  $(vopt_bool qt) $(vopt_bool qt qt6)"

From fd812a20e8b1bfb06cc5dd2b81499d55a0ab462a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 015/109] audacity: revbump for ffmpeg6

---
 srcpkgs/audacity/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/audacity/template b/srcpkgs/audacity/template
index 7b838119ab2611..84b49305edcef1 100644
--- a/srcpkgs/audacity/template
+++ b/srcpkgs/audacity/template
@@ -1,7 +1,7 @@
 # Template file for 'audacity'
 pkgname=audacity
 version=3.4.2
-revision=1
+revision=2
 build_style=cmake
 build_helper="cmake-wxWidgets-gtk3 qemu"
 configure_args="-Daudacity_use_ffmpeg=loaded -Daudacity_lib_preference=system

From 72de0eebfeb3b4d9fe7b06e48b9b8c0b7e10d297 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 016/109] avidemux: revbump for ffmpeg6

---
 srcpkgs/avidemux/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/avidemux/template b/srcpkgs/avidemux/template
index 253a0243e22599..557285982d2b8f 100644
--- a/srcpkgs/avidemux/template
+++ b/srcpkgs/avidemux/template
@@ -1,7 +1,7 @@
 # Template file for 'avidemux'
 pkgname=avidemux
 version=2.8.0
-revision=2
+revision=3
 # Can't be compiled for aarch64, arm* or mips*
 archs="x86_64* i686*"
 hostmakedepends="cmake pkg-config qt5-host-tools qt5-devel tar yasm"

From 347e09f4c5b5a0d1099e3c775c2468053111b8c3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 017/109] blender: revbump for ffmpeg6

---
 srcpkgs/blender/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index 68787b76a26c18..e2e090e6dfa41c 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -1,7 +1,7 @@
 # Template file for 'blender'
 pkgname=blender
 version=4.0.2
-revision=2
+revision=3
 archs="x86_64* ppc64*"
 build_style="cmake"
 pycompile_dirs="usr/share/blender/${version%.*}/scripts"

From ed93e86b8b4c01643a19a9de92824f370ed9c94b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 018/109] cantata: revbump for ffmpeg6

---
 srcpkgs/cantata/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cantata/template b/srcpkgs/cantata/template
index 4b417d80d5c2da..8a90aaa4c07a2a 100644
--- a/srcpkgs/cantata/template
+++ b/srcpkgs/cantata/template
@@ -1,7 +1,7 @@
 # Template file for 'cantata'
 pkgname=cantata
 version=2.5.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools qt5-tools"
 makedepends="qt5-devel qt5-tools-devel qt5-svg-devel qt5-xmlpatterns-devel

From c622127cf406ece9abf889bfa84ae767a943ffe6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 019/109] ccextractor: revbump for ffmpeg6

---
 ...5-and-tesseract-5-compatibility-1479.patch | 168 ++++++++++++++++++
 srcpkgs/ccextractor/template                  |   2 +-
 2 files changed, 169 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ccextractor/patches/0001-fix-ffmpeg-5-and-tesseract-5-compatibility-1479.patch

diff --git a/srcpkgs/ccextractor/patches/0001-fix-ffmpeg-5-and-tesseract-5-compatibility-1479.patch b/srcpkgs/ccextractor/patches/0001-fix-ffmpeg-5-and-tesseract-5-compatibility-1479.patch
new file mode 100644
index 00000000000000..bcab4890554b9a
--- /dev/null
+++ b/srcpkgs/ccextractor/patches/0001-fix-ffmpeg-5-and-tesseract-5-compatibility-1479.patch
@@ -0,0 +1,168 @@
+From b1cbfcea9b9c687143bf0d80bc179b563e99d025 Mon Sep 17 00:00:00 2001
+From: Prateek Sunal <prtksunal@gmail.com>
+Date: Thu, 9 Mar 2023 01:44:53 +0530
+Subject: [PATCH] fix: ffmpeg 5 and tesseract 5 compatibility (#1479)
+
+* fix: replace deprecated `codec` property with `codecpar`
+
+* fix: replace deprecated method `avcodec_decode_video2` with `avcodec_receive_frame` and `avcodec_send_packet`
+
+* Update CHANGES.TXT
+
+* fix: remove deprecated `av_register_all` function
+
+* fix: formatting
+
+* fix: add support for tesseract 5
+
+* fix: tesseract v5
+
+* fix: hardsubx codec context error
+
+* fix: lint const warning
+---
+ docs/CHANGES.TXT               |  1 +
+ src/lib_ccx/ffmpeg_intgr.c     |  7 +++---
+ src/lib_ccx/hardsubx.c         | 25 ++++++++++++------
+ src/lib_ccx/hardsubx_decoder.c | 27 ++++++++------------
+ src/lib_ccx/ocr.c              | 46 ++++++++++++----------------------
+ 5 files changed, 47 insertions(+), 59 deletions(-)
+
+diff --git a/src/lib_ccx/ffmpeg_intgr.c b/src/lib_ccx/ffmpeg_intgr.c
+index be988890..e6f21e20 100644
+--- a/src/lib_ccx/ffmpeg_intgr.c
++++ b/src/lib_ccx/ffmpeg_intgr.c
+@@ -66,7 +66,6 @@ void *init_ffmpeg(const char *path)
+ 	struct ffmpeg_ctx *ctx;
+ 	AVCodec *dec = NULL;
+ 	avcodec_register_all();
+-	av_register_all();
+ 
+ 	if (ccx_options.debug_mask & CCX_DMT_VERBOSE)
+ 		av_log_set_level(AV_LOG_INFO);
+@@ -133,7 +132,6 @@ int ff_get_ccframe(void *arg, unsigned char *data, int maxlen)
+ 	struct ffmpeg_ctx *ctx = arg;
+ 	int len = 0;
+ 	int ret = 0;
+-	int got_frame;
+ 	AVPacket packet;
+ 
+ 	ret = av_read_frame(ctx->ifmt, &packet);
+@@ -151,12 +149,13 @@ int ff_get_ccframe(void *arg, unsigned char *data, int maxlen)
+ 		return AVERROR(EAGAIN);
+ 	}
+ 
+-	ret = avcodec_decode_video2(ctx->dec_ctx, ctx->frame, &got_frame, &packet);
++	avcodec_send_packet(ctx->codec_ctx, &ctx->packet);
++	ret = avcodec_receive_frame(ctx->dec_ctx, ctx->frame);
+ 	if (ret < 0)
+ 	{
+ 		av_log(NULL, AV_LOG_ERROR, "unable to decode packet\n");
+ 	}
+-	else if (!got_frame)
++	else if (ret != 0)
+ 	{
+ 		return AVERROR(EAGAIN);
+ 	}
+diff --git a/src/lib_ccx/hardsubx.c b/src/lib_ccx/hardsubx.c
+index 411377f9..fb844c91 100644
+--- a/src/lib_ccx/hardsubx.c
++++ b/src/lib_ccx/hardsubx.c
+@@ -12,9 +12,6 @@
+
+ int hardsubx_process_data(struct lib_hardsubx_ctx *ctx)
+ {
+-	// Get the required media attributes and initialize structures
+-	av_register_all();
+-
+ 	if (avformat_open_input(&ctx->format_ctx, ctx->inputfile[0], NULL, NULL) != 0)
+ 	{
+ 		fatal(EXIT_READ_ERROR, "Error reading input file!\n");
+@@ -32,7 +29,7 @@
+ 	ctx->video_stream_id = -1;
+ 	for (int i = 0; i < ctx->format_ctx->nb_streams; i++)
+ 	{
+-		if (ctx->format_ctx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO)
++		if (ctx->format_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
+ 		{
+ 			ctx->video_stream_id = i;
+ 			break;
+@@ -43,8 +40,21 @@
+ 		fatal(EXIT_READ_ERROR, "Video Stream not found!\n");
+ 	}
+
+-	ctx->codec_ctx = ctx->format_ctx->streams[ctx->video_stream_id]->codec;
+-	ctx->codec = avcodec_find_decoder(ctx->codec_ctx->codec_id);
++	ctx->codec_ctx = avcodec_alloc_context3(NULL);
++	if (!ctx->codec_ctx)
++	{
++		    fatal(EXIT_NOT_ENOUGH_MEMORY, "Could not allocate codec context!\n");
++	}
++
++	// Assign codec parameters to codec context
++	if (avcodec_parameters_to_context(ctx->codec_ctx, ctx->format_ctx->streams[ctx->video_stream_id]->codecpar) < 0)
++	{
++		    fatal(EXIT_READ_ERROR, "Could not initialize codec context!\n");
++	}
++
++	// Find decoder for the codec context
++	ctx->codec = (AVCodec *)avcodec_find_decoder(ctx->codec_ctx->codec_id);
++
+ 	if (ctx->codec == NULL)
+ 	{
+ 		fatal(EXIT_READ_ERROR, "Input codec is not supported!\n");
+diff --git a/src/lib_ccx/hardsubx_decoder.c b/src/lib_ccx/hardsubx_decoder.c
+index bd9b0980..b5dfaec4 100644
+--- a/src/lib_ccx/hardsubx_decoder.c
++++ b/src/lib_ccx/hardsubx_decoder.c
+@@ -371,7 +371,6 @@
+ int hardsubx_process_frames_tickertext(struct lib_hardsubx_ctx *ctx, struct encoder_ctx *enc_ctx)
+ {
+ 	// Search for ticker text at the bottom of the screen, such as in Russia TV1 or stock prices
+-	int got_frame;
+ 	int cur_sec = 0, total_sec, progress;
+ 	int frame_number = 0;
+ 	char *ticker_text = NULL;
+@@ -382,8 +381,8 @@
+ 		{
+ 			frame_number++;
+ 			//Decode the video stream packet
+-			avcodec_decode_video2(ctx->codec_ctx, ctx->frame, &got_frame, &ctx->packet);
+-			if (got_frame && frame_number % 1000 == 0)
++      avcodec_send_packet(ctx->codec_ctx, &ctx->packet);
++      if (avcodec_receive_frame(ctx->codec_ctx, ctx->frame) == 0 && frame_number % 1000 == 0)
+ 			{
+ 				// sws_scale is used to convert the pixel format to RGB24 from all other cases
+ 				sws_scale(
+@@ -434,9 +433,8 @@
+ 			frame_number++;
+
+ 			//Decode the video stream packet
+-			avcodec_decode_video2(ctx->codec_ctx, ctx->frame, &got_frame, &ctx->packet);
+-
+-			if (got_frame && frame_number % 25 == 0)
++			avcodec_send_packet(ctx->codec_ctx, &ctx->packet);
++      if (avcodec_receive_frame(ctx->codec_ctx, ctx->frame) == 0 && frame_number % 25 == 0)
+ 			{
+ 				float diff = (float)convert_pts_to_ms(ctx->packet.pts - prev_packet_pts, ctx->format_ctx->streams[ctx->video_stream_id]->time_base);
+ 				if (fabsf(diff) < 1000 * ctx->min_sub_duration) //If the minimum duration of a subtitle line is exceeded, process packet
+@@ -548,7 +546,6 @@
+ {
+ 	// Do a binary search over the input video for faster processing
+ 	// printf("Duration: %d\n", (int)ctx->format_ctx->duration);
+-	int got_frame;
+ 	int seconds_time = 0;
+ 	for (seconds_time = 0; seconds_time < 20; seconds_time++)
+ 	{
+@@ -568,8 +565,9 @@
+ 			{
+ 				if (ctx->packet.stream_index == ctx->video_stream_id)
+ 				{
+-					avcodec_decode_video2(ctx->codec_ctx, ctx->frame, &got_frame, &ctx->packet);
+-					if (got_frame)
++          avcodec_send_packet(ctx->codec_ctx, &ctx->packet);
++          if (avcodec_receive_frame(ctx->codec_ctx, ctx->frame) == 0)
++
+ 					{
+ 						// printf("%d\n", seek_time);
+ 						if (ctx->packet.pts < seek_time)
diff --git a/srcpkgs/ccextractor/template b/srcpkgs/ccextractor/template
index 84059ffd02398a..a670758bcbe41b 100644
--- a/srcpkgs/ccextractor/template
+++ b/srcpkgs/ccextractor/template
@@ -1,7 +1,7 @@
 # Template file for 'ccextractor'
 pkgname=ccextractor
 version=0.93
-revision=2
+revision=3
 build_wrksrc="linux"
 build_style=gnu-configure
 configure_args="--enable-ocr --enable-hardsubx"

From eefdd7af998a0493f72aed6f220dde31aa3179cb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 020/109] chromaprint: revbump for ffmpeg6

---
 srcpkgs/chromaprint/patches/ffmpeg5.patch | 569 ++++++++++++++++++++++
 srcpkgs/chromaprint/template              |   2 +-
 2 files changed, 570 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromaprint/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromaprint/patches/ffmpeg5.patch b/srcpkgs/chromaprint/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..a9fd307a23c8a4
--- /dev/null
+++ b/srcpkgs/chromaprint/patches/ffmpeg5.patch
@@ -0,0 +1,569 @@
+From 8ccad6937177b1b92e40ab8f4447ea27bac009a7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= <lalinsky@gmail.com>
+Date: Fri, 4 Nov 2022 21:47:38 +0100
+Subject: [PATCH] Use FFmpeg 5.x (#120)
+
+* Use FFmpeg 5.1.2 for CI builds
+
+* Build on Ubuntu 20.04
+
+* Upgrade code to FFmpeg 5.x APIs
+
+* Only set FFmpeg include dirs if building tools
+
+* No longer needed
+
+* Use ubuntu 20.04
+---
+ .github/workflows/build.yml                   |   6 +-
+ CMakeLists.txt                                |  16 --
+ package/build.sh                              |   4 +-
+ src/audio/ffmpeg_audio_processor.h            |   2 -
+ src/audio/ffmpeg_audio_processor_avresample.h |  72 -------
+ src/audio/ffmpeg_audio_processor_swresample.h |  18 +-
+ src/audio/ffmpeg_audio_reader.h               | 197 +++++++++---------
+ tests/CMakeLists.txt                          |   6 +
+ 8 files changed, 122 insertions(+), 199 deletions(-)
+ delete mode 100644 src/audio/ffmpeg_audio_processor_avresample.h
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index f8d6a32..4da2405 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -84,9 +84,6 @@ find_package(FFmpeg)
+ if(FFMPEG_LIBRARIES)
+ 	cmake_push_check_state(RESET)
+ 	set(CMAKE_REQUIRED_LIBRARIES ${FFMPEG_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -lm)
+-	check_function_exists(av_packet_unref HAVE_AV_PACKET_UNREF)
+-	check_function_exists(av_frame_alloc HAVE_AV_FRAME_ALLOC)
+-	check_function_exists(av_frame_free HAVE_AV_FRAME_FREE)
+ 	cmake_pop_check_state()
+ endif()
+
+@@ -163,14 +160,11 @@ message(STATUS "Using ${FFT_LIB} for FFT calculations")
+ if(NOT AUDIO_PROCESSOR_LIB)
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+ 		set(AUDIO_PROCESSOR_LIB "swresample")
+-	elseif(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(AUDIO_PROCESSOR_LIB "avresample")
+ 	endif()
+ endif()
+
+ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE OFF)
+ 		set(USE_SWRESAMPLE ON)
+ 		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBSWRESAMPLE_LIBRARIES})
+ 		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBSWRESAMPLE_INCLUDE_DIRS})
+@@ -178,16 +172,6 @@ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+ 	endif()
+ 	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+-elseif(AUDIO_PROCESSOR_LIB STREQUAL "avresample")
+-	if(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE ON)
+-		set(USE_SWRESAMPLE OFF)
+-		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBAVRESAMPLE_LIBRARIES})
+-		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBAVRESAMPLE_INCLUDE_DIRS})
+-	else()
+-		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+-	endif()
+-	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+ else()
+ 	message(STATUS "Building without audio conversion support, please install FFmpeg with libswresample")
+ endif()
+diff --git a/package/build.sh b/package/build.sh
+index da631ae..b41d36e 100755
+--- a/package/build.sh
++++ b/package/build.sh
+@@ -7,8 +7,8 @@ set -eux
+
+ BASE_DIR=$(cd $(dirname $0)/.. && pwd)
+
+-FFMPEG_VERSION=4.4.1
+-FFMPEG_BUILD_TAG=v4.4.1-1
++FFMPEG_VERSION=5.1.2
++FFMPEG_BUILD_TAG=v${FFMPEG_VERSION}-1
+
+ TMP_BUILD_DIR=$BASE_DIR/$(mktemp -d build.XXXXXXXX)
+ trap 'rm -rf $TMP_BUILD_DIR' EXIT
+diff --git a/src/audio/ffmpeg_audio_processor.h b/src/audio/ffmpeg_audio_processor.h
+index 7628fc7..39f4f6d 100644
+--- a/src/audio/ffmpeg_audio_processor.h
++++ b/src/audio/ffmpeg_audio_processor.h
+@@ -10,8 +10,6 @@
+
+ #if defined(USE_SWRESAMPLE)
+ #include "audio/ffmpeg_audio_processor_swresample.h"
+-#elif defined(USE_AVRESAMPLE)
+-#include "audio/ffmpeg_audio_processor_avresample.h"
+ #else
+ #error "no audio processing library"
+ #endif
+diff --git a/src/audio/ffmpeg_audio_processor_avresample.h b/src/audio/ffmpeg_audio_processor_avresample.h
+deleted file mode 100644
+index bd85f92..0000000
+--- a/src/audio/ffmpeg_audio_processor_avresample.h
++++ /dev/null
+@@ -1,72 +0,0 @@
+-// Copyright (C) 2016  Lukas Lalinsky
+-// Distributed under the MIT license, see the LICENSE file for details.
+-
+-#ifndef CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-#define CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-
+-extern "C" {
+-#include <libavresample/avresample.h>
+-}
+-
+-namespace chromaprint {
+-
+-class FFmpegAudioProcessor {
+-public:
+-	FFmpegAudioProcessor() {
+-		m_resample_ctx = avresample_alloc_context();
+-	}
+-
+-	~FFmpegAudioProcessor() {
+-		avresample_free(&m_resample_ctx);
+-	}
+-
+-	void SetCompatibleMode() {
+-		av_opt_set_int(m_resample_ctx, "filter_size", 16, 0);
+-		av_opt_set_int(m_resample_ctx, "phase_shift", 8, 0);
+-		av_opt_set_int(m_resample_ctx, "linear_interp", 1, 0);
+-		av_opt_set_double(m_resample_ctx, "cutoff", 0.8, 0);
+-	}
+-
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "in_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_rate", sample_rate, 0);
+-	}
+-
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "out_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_rate, 0);
+-	}
+-
+-	int Init() {
+-		return avresample_open(m_resample_ctx);
+-	}
+-
+-	int Convert(uint8_t **out, int out_count, const uint8_t **in, int in_count) {
+-		return avresample_convert(m_resample_ctx, out, 0, out_count, (uint8_t **) in, 0, in_count);
+-	}
+-
+-	int Flush(uint8_t **out, int out_count) {
+-		return avresample_read(m_resample_ctx, out, out_count);
+-	}
+-
+-private:
+-	AVAudioResampleContext *m_resample_ctx = nullptr;
+-};
+-
+-}; // namespace chromaprint
+-
+-#endif
+diff --git a/src/audio/ffmpeg_audio_processor_swresample.h b/src/audio/ffmpeg_audio_processor_swresample.h
+index b86266b..b1d4bea 100644
+--- a/src/audio/ffmpeg_audio_processor_swresample.h
++++ b/src/audio/ffmpeg_audio_processor_swresample.h
+@@ -28,30 +28,28 @@ public:
+ 		av_opt_set_double(m_swr_ctx, "cutoff", 0.8, 0);
+ 	}
+
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "icl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "ich", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetInputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "in_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "isf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "in_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "isr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "in_sample_rate", sample_rate, 0);
+ 	}
+
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "ocl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "och", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetOutputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "out_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "osf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "out_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "osr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "out_sample_rate", sample_rate, 0);
+ 	}
+
+ 	int Init() {
+diff --git a/src/audio/ffmpeg_audio_reader.h b/src/audio/ffmpeg_audio_reader.h
+index 5550164..1c6b346 100644
+--- a/src/audio/ffmpeg_audio_reader.h
++++ b/src/audio/ffmpeg_audio_reader.h
+@@ -62,7 +62,7 @@ public:
+ 	bool Read(const int16_t **data, size_t *size);
+
+ 	bool IsOpen() const { return m_opened; }
+-	bool IsFinished() const { return m_finished && !m_got_frame; }
++	bool IsFinished() const { return !m_has_more_packets && !m_has_more_frames; }
+
+ 	std::string GetError() const { return m_error; }
+ 	int GetErrorCode() const { return m_error_code; }
+@@ -74,20 +74,19 @@ private:
+ 	uint8_t *m_convert_buffer[1] = { nullptr };
+ 	int m_convert_buffer_nb_samples = 0;
+
+-	AVInputFormat *m_input_fmt = nullptr;
++	const AVInputFormat *m_input_fmt = nullptr;
+ 	AVDictionary *m_input_opts = nullptr;
+
+ 	AVFormatContext *m_format_ctx = nullptr;
+ 	AVCodecContext *m_codec_ctx = nullptr;
+-	AVFrame *m_frame = nullptr;
+ 	int m_stream_index = -1;
+ 	std::string m_error;
+ 	int m_error_code = 0;
+-	bool m_finished = false;
+ 	bool m_opened = false;
+-	int m_got_frame = 0;
+-	AVPacket m_packet;
+-	AVPacket m_packet0;
++	bool m_has_more_packets = true;
++	bool m_has_more_frames = true;
++	AVPacket *m_packet = nullptr;
++	AVFrame *m_frame = nullptr;
+
+ 	int m_output_sample_rate = 0;
+ 	int m_output_channels = 0;
+@@ -98,19 +97,12 @@ private:
+
+ inline FFmpegAudioReader::FFmpegAudioReader() {
+ 	av_log_set_level(AV_LOG_QUIET);
+-
+-	av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
+ }
+
+ inline FFmpegAudioReader::~FFmpegAudioReader() {
+ 	Close();
+ 	av_dict_free(&m_input_opts);
+ 	av_freep(&m_convert_buffer[0]);
+-	av_packet_unref(&m_packet0);
+ }
+
+ inline bool FFmpegAudioReader::SetInputFormat(const char *name) {
+@@ -135,11 +127,10 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ 	Close();
+
+-    av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
++	m_packet = av_packet_alloc();
++	if (!m_packet) {
++		return false;
++	}
+
+ 	ret = avformat_open_input(&m_format_ctx, file_name.c_str(), m_input_fmt, &m_input_opts);
+ 	if (ret < 0) {
+@@ -153,26 +144,31 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		return false;
+ 	}
+
+-	AVCodec *codec;
++	const AVCodec *codec;
+ 	ret = av_find_best_stream(m_format_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &codec, 0);
+ 	if (ret < 0) {
+ 		SetError("Could not find any audio stream in the file", ret);
+ 		return false;
+ 	}
+ 	m_stream_index = ret;
++	auto stream = m_format_ctx->streams[m_stream_index];
+
+-	m_codec_ctx = m_format_ctx->streams[m_stream_index]->codec;
++	m_codec_ctx = avcodec_alloc_context3(codec);
+ 	m_codec_ctx->request_sample_fmt = AV_SAMPLE_FMT_S16;
+
++	ret = avcodec_parameters_to_context(m_codec_ctx, stream->codecpar);
++	if (ret < 0) {
++		SetError("Could not copy the stream parameters", ret);
++		return false;
++	}
++
+ 	ret = avcodec_open2(m_codec_ctx, codec, nullptr);
+ 	if (ret < 0) {
+ 		SetError("Could not open the codec", ret);
+ 		return false;
+ 	}
+
+-	if (!m_codec_ctx->channel_layout) {
+-		m_codec_ctx->channel_layout = av_get_default_channel_layout(m_codec_ctx->channels);
+-	}
++	av_dump_format(m_format_ctx, 0, "foo", 0);
+
+ 	m_frame = av_frame_alloc();
+ 	if (!m_frame) {
+@@ -183,19 +179,23 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		m_output_sample_rate = m_codec_ctx->sample_rate;
+ 	}
+
+-	if (!m_output_channels) {
+-		m_output_channels = m_codec_ctx->channels;
++	AVChannelLayout output_channel_layout;
++	if (m_output_channels) {
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
++	} else {
++		m_output_channels = m_codec_ctx->ch_layout.nb_channels;
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
+ 	}
+
+-	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
++	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->ch_layout.nb_channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
+ 		m_converter.reset(new FFmpegAudioProcessor());
+ 		m_converter->SetCompatibleMode();
+ 		m_converter->SetInputSampleFormat(m_codec_ctx->sample_fmt);
+ 		m_converter->SetInputSampleRate(m_codec_ctx->sample_rate);
+-		m_converter->SetInputChannelLayout(m_codec_ctx->channel_layout);
++		m_converter->SetInputChannelLayout(&(m_codec_ctx->ch_layout));
+ 		m_converter->SetOutputSampleFormat(AV_SAMPLE_FMT_S16);
+ 		m_converter->SetOutputSampleRate(m_output_sample_rate);
+-		m_converter->SetOutputChannelLayout(av_get_default_channel_layout(m_output_channels));
++		m_converter->SetOutputChannelLayout(&output_channel_layout);
+ 		auto ret = m_converter->Init();
+ 		if (ret != 0) {
+ 			SetError("Could not create an audio converter instance", ret);
+@@ -203,10 +203,11 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		}
+ 	}
+
++	av_channel_layout_uninit(&output_channel_layout);
++
+ 	m_opened = true;
+-	m_finished = false;
+-	m_got_frame = 0;
+-	m_nb_packets = 0;
++	m_has_more_packets = true;
++	m_has_more_frames = true;
+ 	m_decode_error = 0;
+
+ 	return true;
+@@ -214,6 +215,7 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ inline void FFmpegAudioReader::Close() {
+ 	av_frame_free(&m_frame);
++	av_packet_free(&m_packet);
+
+ 	m_stream_index = -1;
+
+@@ -252,91 +254,98 @@ inline bool FFmpegAudioReader::Read(const int16_t **data, size_t *size) {
+ 		return false;
+ 	}
+
++	*data = nullptr;
++	*size = 0;
++
+ 	int ret;
++	bool needs_packet = false;
+ 	while (true) {
+-		while (m_packet.size <= 0) {
+-			av_packet_unref(&m_packet0);
+-			av_init_packet(&m_packet);
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			ret = av_read_frame(m_format_ctx, &m_packet);
++		while (needs_packet && m_packet->size == 0) {
++			ret = av_read_frame(m_format_ctx, m_packet);
+ 			if (ret < 0) {
+ 				if (ret == AVERROR_EOF) {
+-					m_finished = true;
++					needs_packet = false;
++					m_has_more_packets = false;
+ 					break;
+-				} else {
++				}
++				SetError("Error reading from the audio source", ret);
++				return false;
++			}
++			if (m_packet->stream_index == m_stream_index) {
++				needs_packet = false;
++			} else {
++				av_packet_unref(m_packet);
++			}
++		}
++
++		if (m_packet->size != 0) {
++			ret = avcodec_send_packet(m_codec_ctx, m_packet);
++			if (ret < 0) {
++				if (ret != AVERROR(EAGAIN)) {
+ 					SetError("Error reading from the audio source", ret);
+ 					return false;
+ 				}
+-			}
+-			m_packet0 = m_packet;
+-			if (m_packet.stream_index != m_stream_index) {
+-				m_packet.data = nullptr;
+-				m_packet.size = 0;
+ 			} else {
+-				m_nb_packets++;
++				av_packet_unref(m_packet);
+ 			}
+ 		}
+
+-		ret = avcodec_decode_audio4(m_codec_ctx, m_frame, &m_got_frame, &m_packet);
++		ret = avcodec_receive_frame(m_codec_ctx, m_frame);
+ 		if (ret < 0) {
+-			if (m_decode_error) {
+-				SetError("Error decoding audio frame", m_decode_error);
+-				return false;
++			if (ret == AVERROR_EOF) {
++				m_has_more_frames = false;
++			} else if (ret == AVERROR(EAGAIN)) {
++				if (m_has_more_packets) {
++					needs_packet = true;
++					continue;
++				} else {
++					m_has_more_frames = false;
++				}
+ 			}
+-			m_decode_error = ret;
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			continue;
++			SetError("Error decoding the audio source", ret);
++			return false;
+ 		}
+
+-		break;
+-	}
+-
+-	m_decode_error = 0;
+-
+-	const int decoded = std::min(ret, m_packet.size);
+-	m_packet.data += decoded;
+-	m_packet.size -= decoded;
+-
+-	if (m_got_frame) {
+-		if (m_converter) {
+-			if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
+-				int linsize;
+-				av_freep(&m_convert_buffer[0]);
+-				m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
+-				ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
+-				if (ret < 0) {
+-					SetError("Couldn't allocate audio converter buffer", ret);
++		if (m_frame->nb_samples > 0) {
++			if (m_converter) {
++				if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
++					int linsize;
++					av_freep(&m_convert_buffer[0]);
++					m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
++					ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->ch_layout.nb_channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
++					if (ret < 0) {
++						SetError("Couldn't allocate audio converter buffer", ret);
++						return false;
++					}
++				}
++				auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
++				if (nb_samples < 0) {
++					SetError("Couldn't convert audio", ret);
+ 					return false;
+ 				}
+-			}
+-			auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			}
+-			*data = (const int16_t *) m_convert_buffer[0];
+-			*size = nb_samples;
+-		} else {
+-			*data = (const int16_t *) m_frame->data[0];
+-			*size = m_frame->nb_samples;
+-		}
+-	} else {
+-		if (m_finished && m_converter) {
+-			auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			} else if (nb_samples > 0) {
+-				m_got_frame = 1;
+ 				*data = (const int16_t *) m_convert_buffer[0];
+ 				*size = nb_samples;
++			} else {
++				*data = (const int16_t *) m_frame->data[0];
++				*size = m_frame->nb_samples;
++			}
++		} else {
++			if (m_converter) {
++				if (IsFinished()) {
++					auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
++					if (nb_samples < 0) {
++						SetError("Couldn't convert audio", ret);
++						return false;
++					} else if (nb_samples > 0) {
++						*data = (const int16_t *) m_convert_buffer[0];
++						*size = nb_samples;
++					}
++				}
+ 			}
+ 		}
+-	}
+
+-	return true;
++		return true;
++	}
+ }
+
+ inline void FFmpegAudioReader::SetError(const char *message, int errnum) {
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index a2b517b..123e643 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -38,6 +38,12 @@ set(SRCS
+
+ if(BUILD_TOOLS)
+ 	set(SRCS ${SRCS} ../src/audio/ffmpeg_audio_reader_test.cpp)
++    include_directories(
++        ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}
++        ${AUDIO_PROCESSOR_INCLUDE_DIRS}
++    )
+ 	link_libraries(fpcalc_libs)
+ endif()
+
+-- 
+2.38.1
+
+
diff --git a/srcpkgs/chromaprint/template b/srcpkgs/chromaprint/template
index 7ef7838949f3a3..1f7bbc70a22c80 100644
--- a/srcpkgs/chromaprint/template
+++ b/srcpkgs/chromaprint/template
@@ -1,7 +1,7 @@
 # Template file for 'chromaprint'
 pkgname=chromaprint
 version=1.5.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DBUILD_TOOLS=ON"
 make_check_target="check"

From 25155bc7ba9ed6ac3b7e32fe3f5498e3e368e85b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 021/109] chromium: revbump for ffmpeg6

---
 srcpkgs/chromium/patches/ffmpeg5.patch | 47 ++++++++++++++++++++++++++
 srcpkgs/chromium/template              |  2 +-
 2 files changed, 48 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..24e2da38e34ca2
--- /dev/null
+++ b/srcpkgs/chromium/patches/ffmpeg5.patch
@@ -0,0 +1,47 @@
+--- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
++++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
+@@ -92,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+-  if (stream->start_time != kNoFFmpegTimestamp)
++  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -1597,7 +1585,7 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+@@ -1618,7 +1606,7 @@
+     if (stream->type() != DemuxerStream::VIDEO)
+       continue;
+ 
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+ 
+     if (!stream->IsEnabled())
diff --git a/srcpkgs/chromium/template b/srcpkgs/chromium/template
index fc7534f3f303c3..4853b6cf973eed 100644
--- a/srcpkgs/chromium/template
+++ b/srcpkgs/chromium/template
@@ -2,7 +2,7 @@
 pkgname=chromium
 # See https://chromiumdash.appspot.com/releases?platform=Linux for the latest version
 version=123.0.6312.86
-revision=1
+revision=2
 archs="i686* x86_64* aarch64* armv7l*"
 hostmakedepends="
  $(vopt_if clang "clang17 lld17 llvm17 compiler-rt")

From 75215df159d52ac9f50bb4303ea3dcf1cc0058f9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 022/109] cmus: revbump for ffmpeg6

---
 srcpkgs/chromium/patches/ffmpeg5.patch | 47 --------------------------
 srcpkgs/cmus/patches/ffmpeg6.patch     | 12 +++++++
 srcpkgs/cmus/template                  |  2 +-
 3 files changed, 13 insertions(+), 48 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch
 create mode 100644 srcpkgs/cmus/patches/ffmpeg6.patch

diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
deleted file mode 100644
index 24e2da38e34ca2..00000000000000
--- a/srcpkgs/chromium/patches/ffmpeg5.patch
+++ /dev/null
@@ -1,47 +0,0 @@
---- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
-+++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
-@@ -92,24 +92,12 @@
- 
- static base::TimeDelta ExtractStartTime(AVStream* stream) {
-   // The default start time is zero.
--  base::TimeDelta start_time;
-+  base::TimeDelta start_time = kNoTimestamp;
- 
-   // First try to use  the |start_time| value as is.
--  if (stream->start_time != kNoFFmpegTimestamp)
-+  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
-     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
- 
--  // Next try to use the first DTS value, for codecs where we know PTS == DTS
--  // (excludes all H26x codecs). The start time must be returned in PTS.
--  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
--      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
--      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
--      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
--    const base::TimeDelta first_pts =
--        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
--    if (first_pts < start_time)
--      start_time = first_pts;
--  }
--
-   return start_time;
- }
- 
-@@ -1597,7 +1585,7 @@
-   for (const auto& stream : streams_) {
-     if (!stream || stream->IsEnabled() != enabled)
-       continue;
--    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
-+    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
-       continue;
-     if (!lowest_start_time_stream ||
-         stream->start_time() < lowest_start_time_stream->start_time()) {
-@@ -1618,7 +1606,7 @@
-     if (stream->type() != DemuxerStream::VIDEO)
-       continue;
- 
--    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
-+    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
-       continue;
- 
-     if (!stream->IsEnabled())
diff --git a/srcpkgs/cmus/patches/ffmpeg6.patch b/srcpkgs/cmus/patches/ffmpeg6.patch
new file mode 100644
index 00000000000000..ffa95ab811101b
--- /dev/null
+++ b/srcpkgs/cmus/patches/ffmpeg6.patch
@@ -0,0 +1,12 @@
+--- a/ip/ffmpeg.c
++++ b/ip/ffmpeg.c
+@@ -202,9 +202,6 @@ static int ffmpeg_open(struct input_plugin_data *ip_data)
+ 			break;
+ 		}
+ 
+-		if (codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+-			cc->flags |= AV_CODEC_FLAG_TRUNCATED;
+-
+ 		if (avcodec_open2(cc, codec, NULL) < 0) {
+ 			d_print("could not open codec: %d, %s\n", cc->codec_id, avcodec_get_name(cc->codec_id));
+ 			err = -IP_ERROR_UNSUPPORTED_FILE_TYPE;
diff --git a/srcpkgs/cmus/template b/srcpkgs/cmus/template
index 0d1436744f1b2c..a6e4b4fa86cb83 100644
--- a/srcpkgs/cmus/template
+++ b/srcpkgs/cmus/template
@@ -1,7 +1,7 @@
 # Template file for 'cmus'
 pkgname=cmus
 version=2.10.0
-revision=3
+revision=4
 build_style=configure
 configure_args="prefix=/usr LD=$CC"
 hostmakedepends="pkg-config"

From 23c18b0b50f346177cfe83a7d1626ec1ba09fa01 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 023/109] cyanrip: revbump for ffmpeg6

---
 srcpkgs/cyanrip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cyanrip/template b/srcpkgs/cyanrip/template
index 9796e3461601a7..5db30e020d17ee 100644
--- a/srcpkgs/cyanrip/template
+++ b/srcpkgs/cyanrip/template
@@ -1,7 +1,7 @@
 # Template file for 'cyanrip'
 pkgname=cyanrip
 version=0.9.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config"
 makedepends="ffmpeg-devel libcdio-devel libcdio-paranoia-devel libcurl-devel libmusicbrainz5-devel"

From 70118105277ae877ec93a3d966e8034cd01008d1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 024/109] deadbeef: revbump for ffmpeg4

---
 srcpkgs/deadbeef/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/deadbeef/template b/srcpkgs/deadbeef/template
index f5f4bf24b8cb6d..7b47e615cd48ef 100644
--- a/srcpkgs/deadbeef/template
+++ b/srcpkgs/deadbeef/template
@@ -1,14 +1,14 @@
 # Template file for 'deadbeef'
 pkgname=deadbeef
 version=1.8.8
-revision=3
+revision=4
 create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-oss --disable-lfm --disable-notify --disable-gtk2"
 hostmakedepends="automake libtool gettext gettext-devel intltool pkg-config
  yasm clang glib-devel"
 makedepends="
- alsa-lib-devel dbus-devel faad2-devel ffmpeg-devel gtk+3-devel imlib2-devel
+ alsa-lib-devel dbus-devel faad2-devel ffmpeg4-devel gtk+3-devel imlib2-devel
  jansson-devel libcddb-devel libcdio-devel libcurl-devel libflac-devel
  libmad-devel libpng-devel libsamplerate-devel libsndfile-devel libvorbis-devel
  libzip-devel mpg123-devel opusfile-devel pulseaudio-devel wavpack-devel"

From 58529ab4c4a3dc70924c9ad846a42857de58d651 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 025/109] droidcam-obs-plugin: revbump for ffmpeg6

---
 srcpkgs/droidcam-obs-plugin/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam-obs-plugin/template b/srcpkgs/droidcam-obs-plugin/template
index fc9c9bf6b9d54c..fb0480754df4de 100644
--- a/srcpkgs/droidcam-obs-plugin/template
+++ b/srcpkgs/droidcam-obs-plugin/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam-obs-plugin'
 pkgname=droidcam-obs-plugin
 version=2.0.1
-revision=1
+revision=2
 build_style=gnu-makefile
 make_use_env=yes
 make_build_args="ALLOW_STATIC=no"

From 554c8d5ee782831d7a9be70e6d574717666bdb00 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 026/109] droidcam: revbump for ffmpeg6

---
 srcpkgs/droidcam/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam/template b/srcpkgs/droidcam/template
index 1c3f1b8b1fc676..32a9220b79a4d1 100644
--- a/srcpkgs/droidcam/template
+++ b/srcpkgs/droidcam/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam'
 pkgname=droidcam
 version=1.8.2
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="USBMUXD=-lusbmuxd-2.0 JPEG=-lturbojpeg"
 hostmakedepends="pkg-config"

From 01d93c45b70930698a6778fe999b5eb9237c492a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 027/109] ffmpegthumbnailer: revbump for ffmpeg6

---
 .../ffmpegthumbnailer/patches/ffmpeg6.patch   | 202 ++++++++++++++++++
 srcpkgs/ffmpegthumbnailer/template            |   6 +-
 2 files changed, 205 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch

diff --git a/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
new file mode 100644
index 00000000000000..363ff35a28419d
--- /dev/null
+++ b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
@@ -0,0 +1,202 @@
+--- a/libffmpegthumbnailer/moviedecoder.cpp	2017-11-21 14:06:57.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.cpp	2023-05-05 13:14:47.946560668 -0400
+@@ -41,11 +41,6 @@
+ namespace ffmpegthumbnailer
+ {
+ 
+-struct SilenceLogLevel
+-{
+-    SilenceLogLevel() { av_log_set_level(AV_LOG_QUIET); }
+-};
+-
+ MovieDecoder::MovieDecoder(AVFormatContext* pavContext)
+ : m_VideoStream(-1)
+ , m_pFormatContext(pavContext)
+@@ -70,8 +65,6 @@
+ 
+ void MovieDecoder::initialize(const string& filename, bool preferEmbeddedMetadata)
+ {
+-    av_register_all();
+-    avcodec_register_all();
+     avformat_network_init();
+ 
+     string inputFile = filename == "-" ? "pipe:" : filename;
+@@ -97,8 +90,7 @@
+ {
+     if (m_pVideoCodecContext)
+     {
+-        avcodec_close(m_pVideoCodecContext);
+-        m_pVideoCodecContext = nullptr;
++        avcodec_free_context(&m_pVideoCodecContext);
+     }
+ 
+     if ((!m_FormatContextWasGiven) && m_pFormatContext)
+@@ -152,10 +144,10 @@
+     for (unsigned int i = 0; i < m_pFormatContext->nb_streams; ++i)
+     {
+         AVStream *stream = m_pFormatContext->streams[i];
+-        auto ctx = m_pFormatContext->streams[i]->codec;
+-        if (ctx->codec_type == AVMEDIA_TYPE_VIDEO)
++        auto par = m_pFormatContext->streams[i]->codecpar;
++        if (par->codec_type == AVMEDIA_TYPE_VIDEO)
+         {
+-            if (!preferEmbeddedMetadata || !isStillImageCodec(ctx->codec_id))
++            if (!preferEmbeddedMetadata || !isStillImageCodec(par->codec_id))
+             {
+                 videoStreams.push_back(i);
+                 continue;
+@@ -203,8 +195,7 @@
+     }
+ 
+     m_pVideoStream = m_pFormatContext->streams[m_VideoStream];
+-    m_pVideoCodecContext = m_pVideoStream->codec;
+-    m_pVideoCodec = avcodec_find_decoder(m_pVideoCodecContext->codec_id);
++    m_pVideoCodec = avcodec_find_decoder(m_pVideoStream->codecpar->codec_id);
+ 
+     if (m_pVideoCodec == nullptr)
+     {
+@@ -214,6 +205,20 @@
+         throw logic_error("Video Codec not found");
+     }
+ 
++    m_pVideoCodecContext = avcodec_alloc_context3(m_pVideoCodec);
++
++    if (m_pVideoCodecContext == nullptr)
++    {
++        destroy();
++        throw logic_error("Could not allocate video codec context");
++    }
++
++    if (avcodec_parameters_to_context(m_pVideoCodecContext, m_pVideoStream->codecpar) < 0)
++    {
++        destroy();
++        throw logic_error("Could not configure video codec context");
++    }
++
+     m_pVideoCodecContext->workaround_bugs = 1;
+ 
+     if (avcodec_open2(m_pVideoCodecContext, m_pVideoCodec, nullptr) < 0)
+@@ -386,13 +391,6 @@
+ 
+ void MovieDecoder::initializeFilterGraph(const AVRational& timeBase, const std::string& size, bool maintainAspectRatio)
+ {
+-    static const AVPixelFormat pixelFormats[] = { AV_PIX_FMT_RGB24, AV_PIX_FMT_NONE };
+-
+-    auto del = [] (AVBufferSinkParams* p) { av_freep(p); };
+-    std::unique_ptr<AVBufferSinkParams, decltype(del)> buffersinkParams(av_buffersink_params_alloc(), del);
+-
+-    avfilter_register_all();
+-
+     m_pFilterGraph = avfilter_graph_alloc();
+     assert(m_pFilterGraph);
+ 
+@@ -404,10 +402,8 @@
+ 
+     checkRc(avfilter_graph_create_filter(&m_pFilterSource, avfilter_get_by_name("buffer"), "thumb_buffer", ss.str().c_str(), nullptr, m_pFilterGraph),
+             "Failed to create filter source");
+-    buffersinkParams->pixel_fmts = pixelFormats;
+-    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, buffersinkParams.get(), m_pFilterGraph),
++    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, nullptr, m_pFilterGraph),
+             "Failed to create filter sink");
+-    buffersinkParams.release();
+ 
+     AVFilterContext* yadifFilter = nullptr;
+     if (m_pFrame->interlaced_frame != 0)
+@@ -500,15 +496,15 @@
+     }
+ 
+     checkRc(av_seek_frame(m_pFormatContext, -1, timestamp, 0), "Seeking in video failed");
+-    avcodec_flush_buffers(m_pFormatContext->streams[m_VideoStream]->codec);
++    avcodec_flush_buffers(m_pVideoCodecContext);
+ 
+     int keyFrameAttempts = 0;
+-    bool gotFrame = 0;
++    bool gotFrame;
+ 
+     do
+     {
+         int count = 0;
+-        gotFrame = 0;
++        gotFrame = false;
+ 
+         while (!gotFrame && count < 20)
+         {
+@@ -552,17 +548,33 @@
+         return false;
+     }
+ 
+-    av_frame_unref(m_pFrame);
+-
+-    int frameFinished;
++    int rc = avcodec_send_packet(m_pVideoCodecContext, m_pPacket);
++    if(rc == AVERROR(EAGAIN))
++    {
++        rc = 0;
++    }
+ 
+-    int bytesDecoded = avcodec_decode_video2(m_pVideoCodecContext, m_pFrame, &frameFinished, m_pPacket);
+-    if (bytesDecoded < 0)
++    if(rc == AVERROR_EOF)
++    {
++        return false;
++    }
++    else if(rc < 0)
+     {
+-        throw logic_error("Failed to decode video frame: bytesDecoded < 0");
++        throw logic_error("Failed to decode video frame: avcodec_send_packet() < 0");
+     }
+ 
+-    return frameFinished > 0;
++    rc = avcodec_receive_frame(m_pVideoCodecContext, m_pFrame);
++    switch(rc)
++    {
++        case 0:
++            return true;
++
++        case AVERROR(EAGAIN):
++            return false;
++
++        default:
++            throw logic_error("Failed to decode video frame: avcodec_receive_frame() < 0");
++    }
+ }
+ 
+ bool MovieDecoder::getVideoPacket()
+@@ -570,8 +582,6 @@
+     bool framesAvailable = true;
+     bool frameDecoded = false;
+ 
+-    int attempts = 0;
+-
+     if (m_pPacket)
+     {
+         av_packet_unref(m_pPacket);
+@@ -580,6 +590,7 @@
+ 
+     m_pPacket = new AVPacket();
+ 
++
+     while (framesAvailable && !frameDecoded)
+     {
+         framesAvailable = av_read_frame(m_pFormatContext, m_pPacket) >= 0;
+@@ -644,7 +655,7 @@
+ 
+ int32_t MovieDecoder::getStreamRotation()
+ {
+-    int32_t* matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
++    auto matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
+     if (matrix)
+     {
+         auto angle = lround(av_display_rotation_get(matrix));
+
+--- a/libffmpegthumbnailer/moviedecoder.h	2017-11-12 04:23:38.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.h	2023-05-05 13:26:07.095529911 -0400
+@@ -78,7 +78,7 @@
+     int                     m_VideoStream;
+     AVFormatContext*        m_pFormatContext;
+     AVCodecContext*         m_pVideoCodecContext;
+-    AVCodec*                m_pVideoCodec;
++    const AVCodec*          m_pVideoCodec;
+     AVFilterGraph*          m_pFilterGraph;
+     AVFilterContext*        m_pFilterSource;
+     AVFilterContext*        m_pFilterSink;
diff --git a/srcpkgs/ffmpegthumbnailer/template b/srcpkgs/ffmpegthumbnailer/template
index 039eea7622b391..35d546018d12af 100644
--- a/srcpkgs/ffmpegthumbnailer/template
+++ b/srcpkgs/ffmpegthumbnailer/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbnailer'
 pkgname=ffmpegthumbnailer
 version=2.2.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libpng-devel libjpeg-turbo-devel ffmpeg-devel"
@@ -9,8 +9,8 @@ depends="ffmpeg"
 short_desc="Lightweight video thumbnailer"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
-homepage="https://github.com/dirkvdb/${pkgname}"
-distfiles="${homepage}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
+homepage="https://github.com/dirkvdb"
+distfiles="${homepage}/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
 checksum=1cb24059c38223f657b300c84dd80491b7040d4b69471c4fea69be862bc99b5b
 
 post_install() {

From 35fd9e82d2f82d6001a95faf945ddcf7995087a9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 028/109] ffmpegthumbs: revbump for ffmpeg6

---
 srcpkgs/ffmpegthumbs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ffmpegthumbs/template b/srcpkgs/ffmpegthumbs/template
index 2e2a96de83ce8a..dfd7e9dede36d3 100644
--- a/srcpkgs/ffmpegthumbs/template
+++ b/srcpkgs/ffmpegthumbs/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbs'
 pkgname=ffmpegthumbs
 version=23.08.5
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules kcoreaddons kconfig-devel
  pkg-config qt5-host-tools qt5-qmake gettext"

From c2e2fd2adb67a72a2f7461dcc0bd0cf5da6082e8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 029/109] ffms2: revbump for ffmpeg6

---
 srcpkgs/ffms2/patches/ffmpeg5.patch | 424 ++++++++++++++++++++++++++++
 srcpkgs/ffms2/template              |   2 +-
 2 files changed, 425 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ffms2/patches/ffmpeg5.patch

diff --git a/srcpkgs/ffms2/patches/ffmpeg5.patch b/srcpkgs/ffms2/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..1479fabcafcb4e
--- /dev/null
+++ b/srcpkgs/ffms2/patches/ffmpeg5.patch
@@ -0,0 +1,424 @@
+From 45673149e9a2f5586855ad472e3059084eaa36b1 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:41:21 +0100
+Subject: [PATCH] Use auto for AVCodec
+
+The geniuses over at FFmpeg decided to constify this API, so old
+versions of the library will return AVCodec *, while new versions
+of the libary will return const AVCodec *, which, in C++, are not
+OK to convert between.
+
+Rather than use some macro hell in ffmscompat.h, we can work around
+this by using auto.
+
+Gross.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 2 +-
+ src/core/indexing.cpp    | 6 +++---
+ src/core/videosource.cpp | 2 +-
+ 3 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index e4ce97c..ac09666 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -469,7 +469,7 @@ void FFMS_AudioSource::OpenFile() {
+ 
+     LAVFOpenFile(SourceFile.c_str(), FormatContext, TrackNumber);
+ 
+-    AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
++    auto *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
+     if (Codec == nullptr)
+         throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+             "Audio codec not found");
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index e547c5a..59fb4e8 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -384,7 +384,7 @@ FFMS_TrackType FFMS_Indexer::GetTrackType(int Track) {
+ }
+ 
+ const char *FFMS_Indexer::GetTrackCodec(int Track) {
+-    AVCodec *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
++    auto *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
+     return codec ? codec->name : nullptr;
+ }
+ 
+@@ -402,7 +402,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             UseDTS);
+ 
+         if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            AVCodec *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (!VideoCodec) {
+                 FormatContext->streams[i]->discard = AVDISCARD_ALL;
+                 IndexMask.erase(i);
+@@ -433,7 +433,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 IndexMask.insert(i);
+             }
+         } else if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+-            AVCodec *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (AudioCodec == nullptr)
+                 throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_UNSUPPORTED,
+                     "Audio codec not found");
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index b889970..8956c22 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -171,7 +171,7 @@ FFMS_VideoSource::FFMS_VideoSource(const char *SourceFile, FFMS_Index &Index, in
+ 
+         LAVFOpenFile(SourceFile, FormatContext, VideoTrack);
+ 
+-        AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
++        auto *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
+         if (Codec == nullptr)
+             throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+                 "Video codec not found");
+-- 
+2.40.0
+
+From 96cbf38ea9381829a1314f432a2c60495dcefaad Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:12:41 +0100
+Subject: [PATCH] all: Update AVPacket API usage
+
+AVPackets must all be on the heap now, since it is no longer
+part of the libav* ABI.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 16 ++++++----
+ src/core/indexing.cpp    | 63 ++++++++++++++++++++++------------------
+ src/core/indexing.h      |  4 +--
+ src/core/utils.cpp       |  6 ----
+ src/core/utils.h         |  1 -
+ src/core/videosource.cpp | 30 ++++++++++---------
+ 6 files changed, 64 insertions(+), 56 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index 37cf9ae..e4ce97c 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -285,10 +285,15 @@ FFMS_AudioSource::AudioBlock *FFMS_AudioSource::CacheBlock(CacheIterator &pos) {
+ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     CurrentFrame = &Frames[PacketNumber];
+ 
+-    AVPacket Packet;
+-    if (!ReadPacket(&Packet))
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++    if (!ReadPacket(Packet)) {
++        av_packet_free(&Packet);
+         throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_UNKNOWN,
+             "ReadPacket unexpectedly failed to read a packet");
++    }
+ 
+     // ReadPacket may have changed the packet number
+     CurrentFrame = &Frames[PacketNumber];
+@@ -297,8 +302,9 @@ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     int NumberOfSamples = 0;
+     AudioBlock *CachedBlock = nullptr;
+     
+-    int Ret = avcodec_send_packet(CodecContext, &Packet);
+-    av_packet_unref(&Packet);
++    int Ret = avcodec_send_packet(CodecContext, Packet);
++    av_packet_unref(Packet);
++    av_packet_free(&Packet);
+ 
+     av_frame_unref(DecodeFrame);
+     Ret = avcodec_receive_frame(CodecContext, DecodeFrame);
+@@ -513,8 +519,6 @@ void FFMS_AudioSource::Seek() {
+ }
+ 
+ bool FFMS_AudioSource::ReadPacket(AVPacket *Packet) {
+-    InitNullPacket(*Packet);
+-
+     while (av_read_frame(FormatContext, Packet) >= 0) {
+         if (Packet->stream_index == TrackNumber) {
+             // Required because not all audio packets, especially in ogg, have a pts. Use the previous valid packet's pts instead.
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index 23fb95b..e547c5a 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -320,7 +320,7 @@ void FFMS_Indexer::CheckAudioProperties(int Track, AVCodecContext *Context) {
+     }
+ }
+ 
+-void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict,
++void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict,
+                                     int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct) {
+     if (VideoContext.Parser) {
+         uint8_t *OB;
+@@ -330,8 +330,8 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+         av_parser_parse2(VideoContext.Parser,
+             VideoContext.CodecContext,
+             &OB, &OBSize,
+-            pkt.data, pkt.size,
+-            pkt.pts, pkt.dts, pkt.pos);
++            pkt->data, pkt->size,
++            pkt->pts, pkt->dts, pkt->pos);
+ 
+         // H.264 (PAFF) and HEVC may have one field per packet, so we need to track
+         // when we have a full or half frame available, and mark one of them as
+@@ -351,15 +351,15 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+ 
+         *RepeatPict = VideoContext.Parser->repeat_pict;
+         *FrameType = VideoContext.Parser->pict_type;
+-        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt.flags & AV_PKT_FLAG_DISCARD));
++        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt->flags & AV_PKT_FLAG_DISCARD));
+     } else {
+-        *Invisible = !!(pkt.flags & AV_PKT_FLAG_DISCARD);
++        *Invisible = !!(pkt->flags & AV_PKT_FLAG_DISCARD);
+     }
+ 
+     if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP8)
+-        ParseVP8(pkt.data[0], Invisible, FrameType);
++        ParseVP8(pkt->data[0], Invisible, FrameType);
+     else if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP9)
+-        ParseVP9(pkt.data[0], Invisible, FrameType);
++        ParseVP9(pkt->data[0], Invisible, FrameType);
+ }
+ 
+ void FFMS_Indexer::Free() {
+@@ -458,32 +458,36 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+         }
+     }
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
+     std::vector<int64_t> LastValidTS(FormatContext->nb_streams, AV_NOPTS_VALUE);
+ 
+     int64_t filesize = avio_size(FormatContext->pb);
+     enum AVPictureStructure LastPicStruct = AV_PICTURE_STRUCTURE_UNKNOWN;
+-    while (av_read_frame(FormatContext, &Packet) >= 0) {
++    while (av_read_frame(FormatContext, Packet) >= 0) {
+         // Update progress
+         // FormatContext->pb can apparently be NULL when opening images.
+         if (IC && FormatContext->pb) {
+-            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate))
++            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate)) {
++                av_packet_free(&Packet);
+                 throw FFMS_Exception(FFMS_ERROR_CANCELLED, FFMS_ERROR_USER,
+                     "Cancelled by user");
++            }
+         }
+-        if (!IndexMask.count(Packet.stream_index)) {
+-            av_packet_unref(&Packet);
++        if (!IndexMask.count(Packet->stream_index)) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+-        int Track = Packet.stream_index;
++        int Track = Packet->stream_index;
+         FFMS_Track &TrackInfo = (*TrackIndices)[Track];
+-        bool KeyFrame = !!(Packet.flags & AV_PKT_FLAG_KEY);
++        bool KeyFrame = !!(Packet->flags & AV_PKT_FLAG_KEY);
+         ReadTS(Packet, LastValidTS[Track], (*TrackIndices)[Track].UseDTS);
+ 
+         if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            int64_t PTS = TrackInfo.UseDTS ? Packet.dts : Packet.pts;
++            int64_t PTS = TrackInfo.UseDTS ? Packet->dts : Packet->pts;
+             if (PTS == AV_NOPTS_VALUE) {
+                 // VPx alt-refs are output as packets which lack timestmps or durations, since
+                 // they are invisible. Currently, the timestamp mangling code in libavformat
+@@ -495,9 +499,11 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 // FFMS2 currently sorts packets by PTS, which will break decoding, otherwise.
+                 bool HasAltRefs = (FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP8 ||
+                                    FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP9);
+-                if (Packet.duration == 0 && !HasAltRefs)
++                if (Packet->duration == 0 && !HasAltRefs) {
++                    av_packet_free(&Packet);
+                     throw FFMS_Exception(FFMS_ERROR_INDEXING, FFMS_ERROR_PARSER,
+                         "Invalid packet pts, dts, and duration");
++                }
+ 
+                 if (TrackInfo.empty())
+                     PTS = 0;
+@@ -513,7 +519,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             ParseVideoPacket(AVContexts[Track], Packet, &RepeatPict, &FrameType, &Invisible, &LastPicStruct);
+ 
+             TrackInfo.AddVideoFrame(PTS, RepeatPict, KeyFrame,
+-                FrameType, Packet.pos, Invisible);
++                FrameType, Packet->pos, Invisible);
+         } else if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+             // For video seeking timestamps are used only if all packets have
+             // timestamps, while for audio they're used if any have timestamps,
+@@ -522,28 +528,29 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 TrackInfo.HasTS = true;
+ 
+             int64_t StartSample = AVContexts[Track].CurrentSample;
+-            uint32_t SampleCount = IndexAudioPacket(Track, &Packet, AVContexts[Track], *TrackIndices);
++            uint32_t SampleCount = IndexAudioPacket(Track, Packet, AVContexts[Track], *TrackIndices);
+             TrackInfo.SampleRate = AVContexts[Track].CodecContext->sample_rate;
+ 
+             TrackInfo.AddAudioFrame(LastValidTS[Track],
+-                StartSample, SampleCount, KeyFrame, Packet.pos, Packet.flags & AV_PKT_FLAG_DISCARD);
++                StartSample, SampleCount, KeyFrame, Packet->pos, Packet->flags & AV_PKT_FLAG_DISCARD);
+         }
+ 
+-        if (!(Packet.flags & AV_PKT_FLAG_DISCARD))
+-            TrackInfo.LastDuration = Packet.duration;
++        if (!(Packet->flags & AV_PKT_FLAG_DISCARD))
++            TrackInfo.LastDuration = Packet->duration;
+ 
+-        av_packet_unref(&Packet);
++        av_packet_unref(Packet);
+     }
++    av_packet_free(&Packet);
+ 
+     TrackIndices->Finalize(AVContexts, FormatContext->iformat->name);
+     return TrackIndices.release();
+ }
+ 
+-void FFMS_Indexer::ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS) {
+-    if (!UseDTS && Packet.pts != AV_NOPTS_VALUE)
+-        TS = Packet.pts;
++void FFMS_Indexer::ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS) {
++    if (!UseDTS && Packet->pts != AV_NOPTS_VALUE)
++        TS = Packet->pts;
+     if (TS == AV_NOPTS_VALUE)
+         UseDTS = true;
+-    if (UseDTS && Packet.dts != AV_NOPTS_VALUE)
+-        TS = Packet.dts;
++    if (UseDTS && Packet->dts != AV_NOPTS_VALUE)
++        TS = Packet->dts;
+ }
+diff --git a/src/core/indexing.h b/src/core/indexing.h
+index 3cfc3c3..5c06868 100644
+--- a/src/core/indexing.h
++++ b/src/core/indexing.h
+@@ -80,10 +80,10 @@ private:
+     int64_t Filesize;
+     uint8_t Digest[20];
+ 
+-    void ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS);
++    void ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS);
+     void CheckAudioProperties(int Track, AVCodecContext *Context);
+     uint32_t IndexAudioPacket(int Track, AVPacket *Packet, SharedAVContext &Context, FFMS_Index &TrackIndices);
+-    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
++    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
+     void Free();
+ public:
+     FFMS_Indexer(const char *Filename);
+diff --git a/src/core/utils.cpp b/src/core/utils.cpp
+index ce67533..8a2e997 100644
+--- a/src/core/utils.cpp
++++ b/src/core/utils.cpp
+@@ -62,12 +62,6 @@ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo) {
+     }
+ }
+ 
+-void InitNullPacket(AVPacket &pkt) {
+-    av_init_packet(&pkt);
+-    pkt.data = nullptr;
+-    pkt.size = 0;
+-}
+-
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames) {
+     AP.SampleFormat = static_cast<FFMS_SampleFormat>(av_get_packed_sample_fmt(CTX->sample_fmt));
+     AP.BitsPerSample = av_get_bytes_per_sample(CTX->sample_fmt) * 8;
+diff --git a/src/core/utils.h b/src/core/utils.h
+index 9819dc7..003ab79 100644
+--- a/src/core/utils.h
++++ b/src/core/utils.h
+@@ -58,7 +58,6 @@ std::unique_ptr<T> make_unique(Args&&... args) {
+ }
+ 
+ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo);
+-void InitNullPacket(AVPacket &pkt);
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames);
+ 
+ void LAVFOpenFile(const char *SourceFile, AVFormatContext *&FormatContext, int Track);
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index 06bd161..b889970 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -673,30 +673,34 @@ void FFMS_VideoSource::DecodeNextFrame(int64_t &AStartTime, int64_t &Pos) {
+     if (HasPendingDelayedFrames())
+         return;
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
+-
+-    while (ReadFrame(&Packet) >= 0) {
+-        if (Packet.stream_index != VideoTrack) {
+-            av_packet_unref(&Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++
++    while (ReadFrame(Packet) >= 0) {
++        if (Packet->stream_index != VideoTrack) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+         if (AStartTime < 0)
+-            AStartTime = Frames.UseDTS ? Packet.dts : Packet.pts;
++            AStartTime = Frames.UseDTS ? Packet->dts : Packet->pts;
+ 
+         if (Pos < 0)
+-            Pos = Packet.pos;
++            Pos = Packet->pos;
+ 
+-        bool FrameFinished = DecodePacket(&Packet);
+-        av_packet_unref(&Packet);
+-        if (FrameFinished)
++        bool FrameFinished = DecodePacket(Packet);
++        av_packet_unref(Packet);
++        if (FrameFinished) {
++            av_packet_free(&Packet);
+             return;
++        }
+     }
+ 
+     // Flush final frames
+-    InitNullPacket(Packet);
+-    DecodePacket(&Packet);
++    DecodePacket(Packet);
++    av_packet_free(&Packet);
+ }
+ 
+ bool FFMS_VideoSource::SeekTo(int n, int SeekOffset) {
+-- 
+2.40.0
+
+From bf9e03e9e08534c024e5a744a6437c4aac160201 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:20:47 +0100
+Subject: [PATCH 2/3] configure: Remove deprecated API use
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ configure.ac | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index b35ef80bc..d19714d0f 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -102,10 +102,10 @@ CFLAGS="$_CFLAGS $FFMPEG_CFLAGS"
+
+ AC_DEFUN([TEST_FFMPEG],
+          [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+-            #include <libavcodec/avcodec.h>
++            #include <libavformat/avformat.h>
+             #include <libswscale/swscale.h>
+             ]],[[
+-                avcodec_register_all();
++                avformat_network_init();
+                 swscale_version();
+             ]])], [eval $1=yes], [eval $1=no])
+         ])
+
diff --git a/srcpkgs/ffms2/template b/srcpkgs/ffms2/template
index 365f64d10cbabf..1641ecf43be5bb 100644
--- a/srcpkgs/ffms2/template
+++ b/srcpkgs/ffms2/template
@@ -1,7 +1,7 @@
 # Template file for 'ffms2'
 pkgname=ffms2
 version=2.40
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-shared --disable-static"
 hostmakedepends="pkg-config autoconf automake libtool"

From 2d2eaa99d4d3d3ff9fedfab1de6cad281e2ad211 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 030/109] freerdp: revbump for ffmpeg6

---
 .../freerdp/patches/ffmpeg6_aa2cb9aa.patch    | 42 +++++++++++++++++++
 srcpkgs/freerdp/template                      |  2 +-
 2 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch

diff --git a/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
new file mode 100644
index 00000000000000..a4324da3a8822b
--- /dev/null
+++ b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
@@ -0,0 +1,42 @@
+From aa2cb9aa5ff5562433598ba168a466e0752bca0e Mon Sep 17 00:00:00 2001
+From: akallabeth <akallabeth@posteo.net>
+Date: Tue, 14 Feb 2023 07:48:54 +0100
+Subject: [PATCH] Fixed #8686: Update h264 to use new FFMPEG API
+
+---
+ channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c | 2 ++
+ libfreerdp/codec/h264_ffmpeg.c            | 2 ++
+ 2 files changed, 4 insertions(+)
+
+diff --git a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+index 339462d865f..beea80b7a1e 100644
+--- a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
++++ b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+@@ -239,8 +239,10 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYP
+ 		}
+ 	}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 	if (mdecoder->codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		mdecoder->codec_context->flags |= AV_CODEC_FLAG_TRUNCATED;
++#endif
+ 
+ 	return TRUE;
+ }
+diff --git a/libfreerdp/codec/h264_ffmpeg.c b/libfreerdp/codec/h264_ffmpeg.c
+index 8a23db2473c..896a333019b 100644
+--- a/libfreerdp/codec/h264_ffmpeg.c
++++ b/libfreerdp/codec/h264_ffmpeg.c
+@@ -615,10 +615,12 @@ static BOOL libavcodec_init(H264_CONTEXT* h264)
+ 			goto EXCEPTION;
+ 		}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 		if (sys->codecDecoder->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		{
+ 			sys->codecDecoderContext->flags |= AV_CODEC_FLAG_TRUNCATED;
+ 		}
++#endif
+ 
+ #ifdef WITH_VAAPI
+ 
diff --git a/srcpkgs/freerdp/template b/srcpkgs/freerdp/template
index 16fddfbe8f5287..bf3a4d2e2b3ae7 100644
--- a/srcpkgs/freerdp/template
+++ b/srcpkgs/freerdp/template
@@ -1,7 +1,7 @@
 # Template file for 'freerdp'
 pkgname=freerdp
 version=2.11.4
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_ALSA=ON -DWITH_CUPS=OFF -DWITH_FFMPEG=ON
  -DWITH_GSTREAMER_0_10=OFF -DWITH_GSTREAMER_1_0=OFF -DWITH_JPEG=ON

From 955d84d9bb221050d6eb2c02d9e10df91243ac3f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 031/109] gerbera: revbump for ffmpeg6

---
 srcpkgs/gerbera/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gerbera/template b/srcpkgs/gerbera/template
index ae14f35c767c03..2dc0ac0ce03b55 100644
--- a/srcpkgs/gerbera/template
+++ b/srcpkgs/gerbera/template
@@ -1,7 +1,7 @@
 # Template file for 'gerbera'
 pkgname=gerbera
 version=1.12.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_SYSTEMD=0 -DWITH_AVCODEC=1"
 hostmakedepends="pkg-config"

From 33c1e277f2ae92020a289bb0eda61657aee451bb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 032/109] goldendict: revbump for ffmpeg6

---
 srcpkgs/goldendict/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/goldendict/template b/srcpkgs/goldendict/template
index f4a05759f693d3..97f44347b03a6a 100644
--- a/srcpkgs/goldendict/template
+++ b/srcpkgs/goldendict/template
@@ -1,7 +1,7 @@
 # Template file for 'goldendict'
 pkgname=goldendict
 version=1.5.0
-revision=1
+revision=2
 build_style=qmake
 configure_args="CONFIG+=zim_support goldendict.pro"
 hostmakedepends="qt5-qmake pkg-config qt5-host-tools"
@@ -10,7 +10,7 @@ makedepends="tiff-devel qt5-devel libvorbis-devel zlib-devel
  qt5-webkit-devel lzo-devel bzip2-devel libao-devel qt5-svg-devel
  libeb-devel qt5-x11extras-devel ffmpeg-devel liblzma-devel
  qt5-multimedia-devel"
-short_desc="A feature-rich dictionary lookup program"
+short_desc="Feature-rich dictionary lookup program"
 maintainer="John <me@johnnynator.dev>"
 license="GPL-3.0-or-later"
 homepage="http://goldendict.org/"

From d41fa1a2101f292d2957406cddb1db9bbab77570 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 033/109] gst-libav: revbump for ffmpeg6

---
 srcpkgs/gst-libav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index e02c0deafc6d24..3b82a28e99c970 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.24.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"

From b0bde1229c47b5f9dff45735275e36c3e16d245b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Feb 2024 01:52:46 -0500
Subject: [PATCH 034/109] gst-plugins-bad1: revbump for ffmpeg6

---
 srcpkgs/gst-plugins-bad1/template | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index 0712c756c00e60..5bb0986fb26953 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-plugins-bad1'
 pkgname=gst-plugins-bad1
 version=1.24.0
-revision=1
+revision=2
 build_helper="gir"
 build_style=meson
 configure_args="-Dpackage-origin=https://voidlinux.org -Ddoc=disabled
@@ -27,8 +27,7 @@ makedepends="alsa-lib-devel celt-devel openssl-devel exempi-devel
  fdk-aac-devel flite-devel fluidsynth-devel liblrdf-devel ladspa-sdk
  lilv-devel lv2 libopenjpeg2-devel sbc-devel spandsp-devel vulkan-loader
  Vulkan-Headers webrtc-audio-processing-devel libzbar-devel ffmpeg-devel
- srt-devel libva-devel
- $(vopt_if gme libgme-devel)"
+ srt-devel libva-devel $(vopt_if onevpl oneVPL-devel) $(vopt_if gme libgme-devel)"
 depends="gst-plugins-base1>=${version}"
 short_desc="GStreamer plugins from the bad set (v1.x)"
 maintainer="Orphaned <orphan@voidlinux.org>"
@@ -38,7 +37,7 @@ changelog="https://gstreamer.freedesktop.org/releases/${version%.*}/#${version}"
 distfiles="https://gstreamer.freedesktop.org/src/gst-plugins-bad/gst-plugins-bad-${version}.tar.xz"
 checksum=d23c3a1a79c425d21078b4892c3302a1d4930d67b83dfa8e03df416fc3f97eba
 
-build_options="gir gme wayland"
+build_options="gir gme onevpl wayland"
 build_options_default="gir wayland"
 desc_option_gme="Build with Game Music Emulator support"
 
@@ -46,6 +45,7 @@ CFLAGS="-fcommon"
 
 case "$XBPS_TARGET_MACHINE" in
 	mips*) ;; # libgme cannot be built for mips*
+	x86_64*) build_options_default+=" gme onevpl" ;; # onevpl only supports 64bit
 	*) build_options_default+=" gme" ;;
 esac
 

From b17dae48b5c5f3585386ba0f4dbc00fe8a10914a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 035/109] gst-rtsp-server: revbump for ffmpeg6

---
 srcpkgs/gst-rtsp-server/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index 4ace541d36e324..837b1bc0d14118 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
 version=1.24.0
-revision=1
+revision=2
 build_style=meson
 build_helper=gir
 configure_args="-Dintrospection=enabled"

From 6910fe92ba5a9e2e19e3b5d0a4643adccc4c40b6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 036/109] guvcview: update to 2.0.8.

---
 srcpkgs/guvcview/patches/fix-include.patch | 10 ++++++++++
 srcpkgs/guvcview/template                  |  7 +++----
 2 files changed, 13 insertions(+), 4 deletions(-)
 create mode 100644 srcpkgs/guvcview/patches/fix-include.patch

diff --git a/srcpkgs/guvcview/patches/fix-include.patch b/srcpkgs/guvcview/patches/fix-include.patch
new file mode 100644
index 00000000000000..503c2af3b78c1a
--- /dev/null
+++ b/srcpkgs/guvcview/patches/fix-include.patch
@@ -0,0 +1,10 @@
+--- a/guvcview/guvcview.c
++++ b/guvcview/guvcview.c
+@@ -28,6 +28,7 @@
+ #include <sys/stat.h>
+ #include <sys/resource.h>
+ #include <errno.h>
++#include <locale.h>
+ 
+ #include "gview.h"
+ #include "gviewv4l2core.h"
diff --git a/srcpkgs/guvcview/template b/srcpkgs/guvcview/template
index d42fd38fa4ad12..86a7fd619612c8 100644
--- a/srcpkgs/guvcview/template
+++ b/srcpkgs/guvcview/template
@@ -1,8 +1,7 @@
 # Template file for 'guvcview'
 pkgname=guvcview
-version=2.0.7
-revision=2
-create_wrksrc=yes
+version=2.0.8
+revision=1
 build_style=gnu-configure
 configure_args="--disable-static --disable-debian-menu"
 hostmakedepends="pkg-config intltool autoconf automake libtool glib-devel"
@@ -14,7 +13,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="http://guvcview.sourceforge.net/"
 distfiles="${SOURCEFORGE_SITE}/${pkgname}/${pkgname}-src-${version}.tar.bz2"
-checksum=f47d51fbd06e44eeaa1a82f4a153c927527c90d94514197a70b2956028cc8ad4
+checksum=a21f4e448286666cf27bafef5290cc953a0a1796b752e5bbe521266dc1230c81
 
 post_patch() {
 	sed '31a#include <locale.h>' -i  guvcview/guvcview.c

From 806966b75dd3d032890be318de4cdf3f015bd040 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 037/109] handbrake: update to 1.6.1

---
 .../patches/fix-missing-x265-link-flag.patch    | 11 ++++++-----
 .../handbrake/patches/libhb-vpl-include.patch   | 15 +++++++++++++++
 srcpkgs/handbrake/template                      | 17 ++++++++++-------
 3 files changed, 31 insertions(+), 12 deletions(-)
 create mode 100644 srcpkgs/handbrake/patches/libhb-vpl-include.patch

diff --git a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
index 26db03867a0c83..d6bb2eda627a36 100644
--- a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
+++ b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
@@ -1,14 +1,15 @@
 --- a/gtk/configure.ac
 +++ b/gtk/configure.ac
 @@ -203,7 +203,7 @@
- 
+
  AM_CONDITIONAL([MINGW], [test "x$mingw_flag" = "xyes"])
- 
--HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg"
-+HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -ldl"
+
+-HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc"
++HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc -ldl"
  HB_CPPFLAGS="$HB_CPPFLAGS $HBINC"
- 
+
  PKG_CHECK_MODULES([x264], [x264], sys_x264=yes, sys_x264=no)
+
 --- a/test/module.defs
 +++ b/test/module.defs
 @@ -69,6 +69,9 @@
diff --git a/srcpkgs/handbrake/patches/libhb-vpl-include.patch b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
new file mode 100644
index 00000000000000..298f9f4ab28f2a
--- /dev/null
+++ b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
@@ -0,0 +1,15 @@
+--- a/libhb/module.defs	2023-01-22 11:36:49.000000000 -0500
++++ b/libhb/module.defs	2023-04-03 22:37:52.395467010 -0400
+@@ -46,11 +46,7 @@
+ LIBHB.GCC.I += $(LIBHB.build/) $(CONTRIB.build/)include
+ 
+ ifeq (1,$(FEATURE.qsv))
+-    ifeq ($(HOST.system),freebsd))
+-        LIBHB.GCC.I += $(LOCALBASE)/include/vpl
+-    else
+-        LIBHB.GCC.I += $(CONTRIB.build/)include/vpl
+-    endif
++    LIBHB.GCC.I += /usr/include/vpl
+ endif
+ 
+ ifneq (,$(filter $(HOST.system),freebsd netbsd openbsd))
diff --git a/srcpkgs/handbrake/template b/srcpkgs/handbrake/template
index ca5e4571e49c37..c32cb1bfa31f4b 100644
--- a/srcpkgs/handbrake/template
+++ b/srcpkgs/handbrake/template
@@ -1,10 +1,10 @@
 # Template file for 'handbrake'
 pkgname=handbrake
-version=1.5.1
+version=1.6.1
 revision=1
 build_style=gnu-configure
 configure_args="--force --disable-gtk-update-checks --disable-df-fetch --harden
- $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc)"
+ $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc) $(vopt_enable qsv)"
 make_build_args="-C ${XBPS_TRIPLET}"
 make_install_args="-C ${XBPS_TRIPLET}"
 hostmakedepends="automake cmake gettext-devel glib-devel intltool libtool m4 meson nasm pkg-config python3"
@@ -12,8 +12,11 @@ makedepends="bzip2-devel ffmpeg-devel gst-plugins-base1-devel gtk+3-devel
  jansson-devel lame-devel libass-devel libbluray-devel libdav1d-devel
  libdvdnav-devel libdvdread-devel libgudev-devel libnuma-devel
  libsamplerate-devel libtheora-devel libvorbis-devel libvpx-devel libxml2-devel
- opus-devel speex-devel x264-devel x265-devel zimg-devel
+ opus-devel speex-devel x264-devel x265-devel zimg-devel libsvt-av1-devel
  $(vopt_if fdk_aac fdk-aac-devel)
+ $(vopt_if qsv libva-devel)
+ $(vopt_if qsv libdrm-devel)
+ $(vopt_if qsv onevpl-devel)
  $(vopt_if nvenc nv-codec-headers)"
 depends="desktop-file-utils gst-plugins-good1 hicolor-icon-theme"
 short_desc="Multithreaded video transcoder"
@@ -21,15 +24,15 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-2.0-only"
 homepage="https://handbrake.fr/"
 distfiles="https://github.com/HandBrake/HandBrake/releases/download/${version}/HandBrake-${version}-source.tar.bz2"
-checksum=3999fe06d5309c819799a73a968a8ec3840e7840c2b64af8f5cdb7fd8c9430f0
+checksum=94ccfe03db917a91650000c510f7fd53f844da19f19ad4b4be1b8f6bc31a8d4c
 nocross=yes
 
-build_options="fdk_aac nvenc"
+build_options="fdk_aac nvenc qsv"
 
 case "$XBPS_TARGET_MACHINE" in
 	x86_64*|i686*)
 		CFLAGS="-msse"
-		build_options_default="nvenc"
+		build_options_default="nvenc qsv"
 		;;
 esac
 
@@ -37,7 +40,7 @@ pre_configure() {
 	# use system libraries, don't download them
 	rm -rf contrib/
 	for module in fdk-aac ffmpeg libbluray libdav1d libdvdnav libdvdread nvenc \
-		x265 zimg; do
+		x265 zimg svt-av1 libvpl; do
 	    vsed -i "/MODULES += contrib\/${module}/d" make/include/main.defs
 	done
 }

From 424ba187347f28f8ac476f8a345a425a1264e864 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 038/109] hedgewars: revbump for ffmpeg4

---
 srcpkgs/hedgewars/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/hedgewars/template b/srcpkgs/hedgewars/template
index 94b6db673b0c3a..402ccfaaecbc2d 100644
--- a/srcpkgs/hedgewars/template
+++ b/srcpkgs/hedgewars/template
@@ -1,13 +1,13 @@
 # Template file for 'hedgewars'
 pkgname=hedgewars
 version=1.0.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DNOSERVER=1 -DDATA_INSTALL_DIR=/usr/share/${pkgname}
  -DPHYSFS_SYSTEM=1 -DMINIMAL_FLAGS=1"
 make_cmd=make
 hostmakedepends="lua51 pkg-config qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
+makedepends="ffmpeg4-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
  SDL2_mixer-devel SDL2_net-devel SDL2_ttf-devel"
 depends="libfreeglut"
 short_desc="Funny turn-based artillery game, featuring fighting Hedgehogs!"

From 8ff17b07cbc0930c0d08efced888d11c0396f2d6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 039/109] idjc: revbump for ffmpeg4

---
 srcpkgs/idjc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/idjc/template b/srcpkgs/idjc/template
index a9cde0665d55b1..f41e1e4fabbae7 100644
--- a/srcpkgs/idjc/template
+++ b/srcpkgs/idjc/template
@@ -1,11 +1,11 @@
 # Template file for 'idjc'
 pkgname=idjc
 version=0.9.1
-revision=5
+revision=6
 build_style=gnu-configure
 hostmakedepends="pkg-config git python3 automake gettext-devel libtool"
 makedepends="libvorbis-devel libogg-devel jack-devel libsamplerate-devel
- libflac-devel libsndfile-devel mpg123-devel ffmpeg-devel speex-devel
+ libflac-devel libsndfile-devel mpg123-devel ffmpeg4-devel speex-devel
  glib-devel pixman-devel lame-devel python3-gobject-devel libshout-idjc-devel
  opus-devel twolame-devel python3-mutagen python3-devel"
 depends="python3-gobject python3-mutagen desktop-file-utils shared-mime-info python3-dbus jack"

From bd559d444a205a37a23ee32d80686aa6c9be3888 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 040/109] kid3: revbump for ffmpeg6

---
 srcpkgs/kid3/patches/ffmpeg5.patch | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 srcpkgs/kid3/patches/ffmpeg5.patch

diff --git a/srcpkgs/kid3/patches/ffmpeg5.patch b/srcpkgs/kid3/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..135fc50e07c9ba
--- /dev/null
+++ b/srcpkgs/kid3/patches/ffmpeg5.patch
@@ -0,0 +1,17 @@
+# https://aur.archlinux.org/cgit/aur.git/diff/ffmpeg5.patch?h=kid3-cli&id=12410a74906612e7efc0ec8fbce739b4a0fef7e7
+diff --git a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+index e156d424..e12b9abd 100644
+--- a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
++++ b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+@@ -232,7 +232,11 @@ private:
+   friend class Format;
+   friend class Converter;
+   AVCodecContext* m_ptr;
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 0, 0)
+   AVCodec* m_impl;
++#else
++  const AVCodec* m_impl;
++#endif
+   AVFrame* m_frame;
+   bool m_opened;
+ };

From 1bad228e6f1a58956022176a0027bc559873342c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 041/109] kodi: revbump for ffmpeg4

---
 srcpkgs/kodi/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/kodi/template b/srcpkgs/kodi/template
index d37a5918cd6758..ea78e0aca0fe3e 100644
--- a/srcpkgs/kodi/template
+++ b/srcpkgs/kodi/template
@@ -1,7 +1,7 @@
 # Template file for 'kodi'
 pkgname=kodi
 version=19.4
-revision=9
+revision=10
 _codename="Matrix"
 build_style=cmake
 configure_args="-DWITH_FFMPEG=/usr -DENABLE_LDGOLD=OFF
@@ -54,7 +54,7 @@ makedepends="
  libmad-devel fontconfig-devel libXinerama-devel libsamplerate-devel libmms-devel
  enca-devel boost-devel libcurl-devel libva-devel libvdpau-devel libass-devel
  libbluetooth-devel yajl-devel libplist-devel librtmp-devel tinyxml-devel
- taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg-devel
+ taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg4-devel
  giflib-devel libxslt-devel gnutls-devel libssh-devel libmicrohttpd-devel
  libcec-devel dcadec-devel flatbuffers-devel fmt-devel lcms2-devel
  libfstrcmp-devel rapidjson libcdio-paranoia spdlog libwaylandpp-devel

From 38440d05bce6acbd90707166ca5dfa565eef51c6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 042/109] kpipewire: revbump for ffmpeg6

---
 srcpkgs/kpipewire/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kpipewire/template b/srcpkgs/kpipewire/template
index 24f5f152749c97..d5ac3788ff586a 100644
--- a/srcpkgs/kpipewire/template
+++ b/srcpkgs/kpipewire/template
@@ -1,7 +1,7 @@
 # Template file for 'kpipewire'
 pkgname=kpipewire
 version=5.27.11
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules plasma-wayland-protocols gettext
  qt5-qmake qt5-host-tools pkg-config wayland-devel kcoreaddons

From 0ec8e9b0020037b51a12ecba85a18f552e942ecc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 043/109] libopenal: revbump for ffmpeg6

---
 srcpkgs/libopenal/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenal/template b/srcpkgs/libopenal/template
index 88d0f11307d81a..8308fca0393e33 100644
--- a/srcpkgs/libopenal/template
+++ b/srcpkgs/libopenal/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenal'
 pkgname=libopenal
 version=1.23.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DALSOFT_EXAMPLES=OFF"
 hostmakedepends="pkg-config"

From 6997ff0549ea6405a9f57327d6242ba84a1d17f6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 044/109] loudgain: revbump for ffmpeg6

---
 srcpkgs/loudgain/patches/ffmpeg5.patch | 11 +++++++++++
 srcpkgs/loudgain/template              |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/loudgain/patches/ffmpeg5.patch

diff --git a/srcpkgs/loudgain/patches/ffmpeg5.patch b/srcpkgs/loudgain/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..16d4510ee98faa
--- /dev/null
+++ b/srcpkgs/loudgain/patches/ffmpeg5.patch
@@ -0,0 +1,11 @@
+--- a/src/scan.c	2019-09-06 11:31:19.000000000 -0400
++++ b/src/scan.c	2023-03-23 11:15:40.867968521 -0400
+@@ -69,8 +69,6 @@
+ 	 * It is now useless
+ 	 * https://github.com/FFmpeg/FFmpeg/blob/70d25268c21cbee5f08304da95be1f647c630c15/doc/APIchanges#L86
+ 	 */
+-  if (avformat_version() < AV_VERSION_INT(58,9,100))
+-    av_register_all();
+ 
+ 	av_log_set_callback(scan_av_log);
+ 
diff --git a/srcpkgs/loudgain/template b/srcpkgs/loudgain/template
index da4f2d56e94c3d..4d6bf29efb4fdd 100644
--- a/srcpkgs/loudgain/template
+++ b/srcpkgs/loudgain/template
@@ -1,7 +1,7 @@
 # Template file for 'loudgain'
 pkgname=loudgain
 version=0.6.8
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libebur128-devel taglib-devel ffmpeg-devel"

From a50f3ebdfd6b391bc325ac00f6ccba72a5d7d4c3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 045/109] mediastreamer: revbump for ffmpeg4

---
 srcpkgs/mediastreamer/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mediastreamer/template b/srcpkgs/mediastreamer/template
index 0fcffa7653d18e..e888626b945e55 100644
--- a/srcpkgs/mediastreamer/template
+++ b/srcpkgs/mediastreamer/template
@@ -1,11 +1,11 @@
 # Template file for 'mediastreamer'
 pkgname=mediastreamer
 version=5.2.111
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DENABLE_STRICT=0 -DENABLE_UNIT_TESTS=0"
 hostmakedepends="python3"
-makedepends="bzrtp-devel ffmpeg-devel glew-devel libXv-devel libsrtp-devel
+makedepends="bzrtp-devel ffmpeg4-devel glew-devel libXv-devel libsrtp-devel
  libupnp-devel libvpx-devel mbedtls-devel opus-devel ortp-devel pulseaudio-devel
  libtheora-devel speex-devel v4l-utils-devel bcg729-devel bcmatroska2-devel libgsm-devel
  zxing-cpp-devel"

From c32f800209e713d58a3756909cdfae9765cf8ce6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 046/109] mgba: revbump for ffmpeg6

---
 srcpkgs/mgba/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mgba/template b/srcpkgs/mgba/template
index 6cd65650312543..93401adb618bd8 100644
--- a/srcpkgs/mgba/template
+++ b/srcpkgs/mgba/template
@@ -1,7 +1,7 @@
 # Template file for 'mgba'
 pkgname=mgba
 version=0.10.3
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake desktop-file-utils"
 makedepends="SDL2-devel ffmpeg-devel libedit-devel libepoxy-devel libmagick-devel

From 877c801aabdde5f67422062cd22a881146a0a009 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 047/109] mlt: revbump for ffmpeg4

---
 srcpkgs/mlt/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mlt/template b/srcpkgs/mlt/template
index 73e3915aaab9ac..d7ed4c4b30a868 100644
--- a/srcpkgs/mlt/template
+++ b/srcpkgs/mlt/template
@@ -1,14 +1,14 @@
 # Template file for 'mlt'
 pkgname=mlt
 version=6.26.1
-revision=3
+revision=4
 build_style=configure
 configure_args="--prefix=/usr --libdir=/usr/lib$XBPS_TARGET_WORDSIZE
  --enable-gpl --enable-gpl3 --disable-swfdec --without-kde
  --swig-languages=python"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which"
 # XXX: movit vid.stab
-makedepends="alsa-lib-devel ffmpeg-devel gtk+-devel jack-devel ladspa-sdk
+makedepends="alsa-lib-devel ffmpeg4-devel gtk+-devel jack-devel ladspa-sdk
  libexif-devel libsamplerate-devel libxml2-devel sox-devel SDL_image-devel
  fftw-devel frei0r-plugins python3-devel pulseaudio-devel movit-devel
  libvidstab-devel"

From 1243fcf48c266a20f7d4735bc842e793115ed62d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 048/109] moc: revbump for ffmpeg4

---
 srcpkgs/moc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/moc/template b/srcpkgs/moc/template
index 3a04932c8f1e61..838755f88db09e 100644
--- a/srcpkgs/moc/template
+++ b/srcpkgs/moc/template
@@ -1,10 +1,10 @@
 # Template file for 'moc'
 pkgname=moc
 version=2.5.2
-revision=7
+revision=8
 build_style=gnu-configure
 hostmakedepends="pkg-config"
-makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg-devel
+makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg4-devel
  jack-devel alsa-lib-devel libltdl-devel libflac-devel libvorbis-devel
  libmad-devel libmpcdec-devel libmodplug-devel libid3tag-devel faad2-devel
  taglib-devel libsndfile-devel wavpack-devel speex-devel libsamplerate-devel

From 5e228e277b7ddbc6987d6cf7e8c11abe9e4b9346 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 049/109] motion: revbump for ffmpeg6

---
 srcpkgs/motion/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/motion/template b/srcpkgs/motion/template
index 607ebeb3c7b242..bf63a91d9764f6 100644
--- a/srcpkgs/motion/template
+++ b/srcpkgs/motion/template
@@ -1,7 +1,7 @@
 # Template file for 'motion'
 pkgname=motion
 version=4.6.0
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake pkg-config gettext-devel tar"
 makedepends="ffmpeg-devel libmicrohttpd-devel v4l-utils-devel gettext-devel"

From c0ba7f2a92042330b2bbed2de3d9d920af368533 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 050/109] olive: revbump for ffmpeg4

---
 srcpkgs/olive/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/olive/template b/srcpkgs/olive/template
index 12a46936c99003..5c2917b9c51245 100644
--- a/srcpkgs/olive/template
+++ b/srcpkgs/olive/template
@@ -1,10 +1,10 @@
 # Template file for 'olive'
 pkgname=olive
 version=0.1.2
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools pkg-config"
-makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg-devel frei0r-plugins"
+makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg4-devel frei0r-plugins"
 short_desc="Non-linear video editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"

From d8bcf1aa8de7f96ad959c358be236e05c779c26a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 051/109] opentoonz: revbump for ffmpeg6

---
 srcpkgs/opentoonz/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/opentoonz/template b/srcpkgs/opentoonz/template
index ee9f7603f55fd8..3e81834ca0eddf 100644
--- a/srcpkgs/opentoonz/template
+++ b/srcpkgs/opentoonz/template
@@ -1,7 +1,7 @@
 # Template file for 'opentoonz'
 pkgname=opentoonz
 version=1.6.0
-revision=2
+revision=3
 build_wrksrc="toonz/sources"
 build_style=cmake
 make_cmd=make

From 031db38eff92855dcd5c8e93943ed09e3be8e0b6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 052/109] pianobar: revbump for ffmpeg6

---
 srcpkgs/pianobar/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pianobar/template b/srcpkgs/pianobar/template
index e3febb821a4510..1e3dc1bf9308ee 100644
--- a/srcpkgs/pianobar/template
+++ b/srcpkgs/pianobar/template
@@ -1,7 +1,7 @@
 # Template file for 'pianobar'
 pkgname=pianobar
 version=2022.04.01
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="V=1"
 hostmakedepends="pkg-config"

From 1eac73b3e862727194895b2aecd99abd777a850d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 053/109] ppsspp: revbump for ffmpeg6

---
 srcpkgs/ppsspp/patches/ffmpeg6.patch | 15 +++++++++++++++
 srcpkgs/ppsspp/template              |  3 +--
 2 files changed, 16 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/ppsspp/patches/ffmpeg6.patch

diff --git a/srcpkgs/ppsspp/patches/ffmpeg6.patch b/srcpkgs/ppsspp/patches/ffmpeg6.patch
new file mode 100644
index 00000000000000..5803c7bf227309
--- /dev/null
+++ b/srcpkgs/ppsspp/patches/ffmpeg6.patch
@@ -0,0 +1,15 @@
+--- a/Core/HW/SimpleAudioDec.cpp	2024-02-04 08:08:02.000000000 -0500
++++ b/Core/HW/SimpleAudioDec.cpp	2024-02-15 14:48:27.114362051 -0500
+@@ -81,7 +81,11 @@
+ 		return;
+ 	}
+ 	// Find decoder
++#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(58, 18, 100)
+ 	codec_ = avcodec_find_decoder((AVCodecID)audioCodecId);
++#else // this is a macro to const in the header
++	codec_ = (AVCodec*)avcodec_find_decoder((AVCodecID)audioCodecId);
++#endif
+ 	if (!codec_) {
+ 		// Eh, we shouldn't even have managed to compile. But meh.
+ 		ERROR_LOG(ME, "This version of FFMPEG does not support AV_CODEC_ctx for audio (%s). Update your submodule.", GetCodecName(audioType));
+
diff --git a/srcpkgs/ppsspp/template b/srcpkgs/ppsspp/template
index 2238a7601c0af8..1fda55268a2d39 100644
--- a/srcpkgs/ppsspp/template
+++ b/srcpkgs/ppsspp/template
@@ -1,7 +1,7 @@
 # Template file for 'ppsspp'
 pkgname=ppsspp
 version=1.17.1
-revision=1
+revision=2
 _glslang_commit=b34f619e1c85810dcb3c578107d2e48ba4ee2b37
 _SPIRV_Cross_commit=4212eef67ed0ca048cb726a6767185504e7695e5
 _armips_commit=a8d71f0f279eb0d30ecf6af51473b66ae0cf8e8d
@@ -91,7 +91,6 @@ post_configure() {
 }
 
 do_install() {
-	vlicense LICENSE.TXT
 	vinstall icons/icon.svg 644 usr/share/pixmaps ppsspp.svg
 	vinstall Qt/PPSSPP.desktop 644 usr/share/applications
 	vbin build/PPSSPPHeadless ppsspp-headless

From 67956721b0412cc734a1de90b356f660b2dbde7e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 054/109] pqiv: revbump for ffmpeg6

---
 srcpkgs/pqiv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pqiv/template b/srcpkgs/pqiv/template
index f9f7751196d4ee..0d50777e56a2d8 100644
--- a/srcpkgs/pqiv/template
+++ b/srcpkgs/pqiv/template
@@ -1,7 +1,7 @@
 # Template file for 'pqiv'
 pkgname=pqiv
 version=2.13.1
-revision=1
+revision=2
 build_style=gnu-makefile
 hostmakedepends="pkg-config"
 makedepends="glib-devel gtk+3-devel $(vopt_if ffmpeg ffmpeg-devel)

From aa723c9face71223dc8ebafde87a1fc1e66d3590 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 055/109] qmmp: revbump for ffmpeg6

---
 srcpkgs/qmmp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qmmp/template b/srcpkgs/qmmp/template
index 53781ea3bc28ad..2da07f1e87eac0 100644
--- a/srcpkgs/qmmp/template
+++ b/srcpkgs/qmmp/template
@@ -1,7 +1,7 @@
 # Template file for 'qmmp'
 pkgname=qmmp
 version=1.6.1
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DUSE_HAL:BOOL=FALSE -DQMMP_DEFAULT_UI:STRING=simple"
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From 956b0a03befa1cb0e67ba58af54c6fa3c5334b78 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 14 Dec 2023 13:28:10 -0500
Subject: [PATCH 056/109] qt6-pdf: revbump for ffmpeg6

---
 srcpkgs/qt6-pdf/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-pdf/template b/srcpkgs/qt6-pdf/template
index ecda84afac1310..531b4e1d4fe84d 100644
--- a/srcpkgs/qt6-pdf/template
+++ b/srcpkgs/qt6-pdf/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-pdf'
 pkgname=qt6-pdf
 version=6.6.0
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DQT_FEATURE_qtpdf_build=ON
  -DQT_FEATURE_qtpdf_widgets_build=ON

From 64e875cb8cfd0e740e12afeb79d5a7d4f0a85f01 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 057/109] qt5-webengine: revbump for ffmpeg6

---
 .../chromium-media-filters-cpp14.patch        |  11 ++
 srcpkgs/qt5-webengine/patches/ffmpeg5.patch   | 179 ++++++++++++++++++
 .../qtwebengine-fix-ffmpeg5-build.patch       |  14 ++
 srcpkgs/qt5-webengine/template                |   4 +-
 4 files changed, 206 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/ffmpeg5.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch

diff --git a/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
new file mode 100644
index 00000000000000..04adc540f2cbc0
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
@@ -0,0 +1,11 @@
+--- a/src/3rdparty/chromium/media/filters/BUILD.gn	2023-02-27 13:32:59.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/BUILD.gn	2023-04-02 17:21:39.204066384 -0400
+@@ -96,6 +96,8 @@
+     "//ui/gfx/geometry:geometry",
+   ]
+ 
++  cflags_cc = [ "-std=c++14" ]
++
+   libs = []
+ 
+   if (proprietary_codecs) {
diff --git a/srcpkgs/qt5-webengine/patches/ffmpeg5.patch b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..ac55e1634423a9
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
@@ -0,0 +1,179 @@
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:57.732547446 -0400
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:09.486478995 -0400
+@@ -57,6 +57,8 @@
+ 
+ namespace {
+ 
++constexpr int64_t kRelativeTsBase = static_cast<int64_t>(0x7ffeffffffffffff);
++
+ void SetAVStreamDiscard(AVStream* stream, AVDiscard discard) {
+   DCHECK(stream);
+   stream->discard = discard;
+@@ -90,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+   if (stream->start_time != kNoFFmpegTimestamp)
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (stream->first_dts != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, stream->first_dts);
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -408,11 +398,11 @@
+   scoped_refptr<DecoderBuffer> buffer;
+ 
+   if (type() == DemuxerStream::TEXT) {
+-    int id_size = 0;
++    size_t id_size = 0;
+     uint8_t* id_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
+ 
+-    int settings_size = 0;
++    size_t settings_size = 0;
+     uint8_t* settings_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
+ 
+@@ -424,7 +414,7 @@
+     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
+                                      side_data.data(), side_data.size());
+   } else {
+-    int side_data_size = 0;
++    size_t side_data_size = 0;
+     uint8_t* side_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
+ 
+@@ -485,7 +475,7 @@
+                                        packet->size - data_offset);
+     }
+ 
+-    int skip_samples_size = 0;
++    size_t skip_samples_size = 0;
+     const uint32_t* skip_samples_ptr =
+         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
+             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
+@@ -1587,6 +1577,8 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++      continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+       lowest_start_time_stream = stream.get();
+@@ -1604,6 +1596,8 @@
+     if (stream && stream->type() == DemuxerStream::VIDEO &&
+         stream->IsEnabled()) {
+       video_stream = stream.get();
++      if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++        continue;
+       if (video_stream->start_time() <= seek_time) {
+         return video_stream;
+       }
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h qtwebengine-5.15.10/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h
+--- a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-07-11 22:12:47.917192788 -0500
+@@ -29,6 +29,7 @@ extern "C" {
+ #include <libavformat/avformat.h>
+ #include <libavformat/avio.h>
+ #include <libavutil/avutil.h>
++#include <libavutil/channel_layout.h>
+ #include <libavutil/imgutils.h>
+ #include <libavutil/log.h>
+ #include <libavutil/mastering_display_metadata.h>
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/audio_file_reader.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/audio_file_reader.cc
+--- a/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -85,7 +85,7 @@ bool AudioFileReader::OpenDemuxer() {
+ }
+ 
+ bool AudioFileReader::OpenDecoder() {
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (codec) {
+     // MP3 decodes to S16P which we don't support, tell it to use S16 instead.
+     if (codec_context_->sample_fmt == AV_SAMPLE_FMT_S16P)
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -329,7 +329,7 @@ bool FFmpegAudioDecoder::ConfigureDecode
+     }
+   }
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec ||
+       avcodec_open2(codec_context_.get(), codec, &codec_options) < 0) {
+     DLOG(ERROR) << "Could not initialize audio decoder: "
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -59,7 +59,6 @@ static int64_t AVIOSeekOperation(void* o
+ }
+ 
+ void FFmpegGlue::InitializeFFmpeg() {
+-  av_register_all();
+ }
+ 
+ static void LogContainer(bool is_local_file,
+@@ -95,9 +94,6 @@ FFmpegGlue::FFmpegGlue(FFmpegURLProtocol
+   // Enable fast, but inaccurate seeks for MP3.
+   format_context_->flags |= AVFMT_FLAG_FAST_SEEK;
+ 
+-  // Ensures we can read out various metadata bits like vp8 alpha.
+-  format_context_->flags |= AVFMT_FLAG_KEEP_SIDE_DATA;
+-
+   // Ensures format parsing errors will bail out. From an audit on 11/2017, all
+   // instances were real failures. Solves bugs like http://crbug.com/710791.
+   format_context_->error_recognition |= AV_EF_EXPLODE;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -391,7 +391,7 @@ bool FFmpegVideoDecoder::ConfigureDecode
+   if (decode_nalus_)
+     codec_context_->flags2 |= AV_CODEC_FLAG2_CHUNKS;
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
+     ReleaseFFmpegResources();
+     return false;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/media_file_checker.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/media_file_checker.cc
+--- a/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -68,7 +68,7 @@ bool MediaFileChecker::Start(base::TimeD
+       auto context = AVStreamToAVCodecContext(format_context->streams[i]);
+       if (!context)
+         continue;
+-      AVCodec* codec = avcodec_find_decoder(cp->codec_id);
++      const AVCodec* codec = avcodec_find_decoder(cp->codec_id);
+       if (codec && avcodec_open2(context.get(), codec, nullptr) >= 0) {
+         auto loop = std::make_unique<FFmpegDecodingLoop>(context.get());
+         stream_contexts[i] = {std::move(context), std::move(loop)};
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc qtwebengine-5.15.10/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc
+--- a/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -203,7 +203,7 @@ int32_t H264DecoderImpl::InitDecode(cons
+   // a pointer |this|.
+   av_context_->opaque = this;
+ 
+-  AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
+   if (!codec) {
+     // This is an indication that FFmpeg has not been initialized or it has not
+     // been compiled/initialized with the correct set of codecs.
diff --git a/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch b/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch
new file mode 100644
index 00000000000000..bc24d5b9a29cb5
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch
@@ -0,0 +1,14 @@
+--- a/src/buildtools/configure.json	2023-12-09 11:06:01.503058569 -0500
++++ b/src/buildtools/configure.json	2023-12-09 11:06:14.982361345 -0500
+@@ -779,11 +779,6 @@
+             "type": "warning",
+             "condition": "config.ios && config.simulator && config.device && features.build-qtpdf",
+             "message": "Building fat libray with device and simulator architectures will disable NEON."
+-        },
+-        {
+-            "type": "fatal",
+-            "condition": "features.webengine-system-ffmpeg && !libs.webengine-ffmpeg-support",
+-            "message": "Unmodified ffmpeg >= 5.0 is not supported. Please configure with -qt-webengine-ffmpeg."
+         }
+     ],
+     "summary": [
diff --git a/srcpkgs/qt5-webengine/template b/srcpkgs/qt5-webengine/template
index 8d2df1b5175bad..1687a77eb8a2f5 100644
--- a/srcpkgs/qt5-webengine/template
+++ b/srcpkgs/qt5-webengine/template
@@ -1,14 +1,14 @@
 # Template file for 'qt5-webengine'
 pkgname=qt5-webengine
 version=5.15.16
-revision=1
+revision=2
 _version="${version}-lts"
 _chromium_commit=207c2ac45ca3386d153770c6b0d2ea2ec21ca880
 archs="x86_64* i686* armv[67]* ppc64* aarch64*"
 create_wrksrc=yes
 build_style=qmake
 configure_args="--
- -webengine-icu -webengine-ffmpeg -webengine-opus -webengine-webp
+ -webengine-icu -system-ffmpeg -webengine-opus -webengine-webp
  -webengine-pepper-plugins -webengine-printing-and-pdf -webengine-proprietary-codecs
  -webengine-pulseaudio -webengine-spellchecker -webengine-webrtc -webengine-geolocation
  -webengine-kerberos -no-webengine-embedded-build $(vopt_if sndio '' '-no')-webengine-sndio

From 4c8b9e886795805d240a12bf7d5e490e62b505f1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 058/109] qt5: revbump for ffmpeg6

---
 srcpkgs/qt5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5/template b/srcpkgs/qt5/template
index 3efb7e42d5fd3f..27f6d5388cd15c 100644
--- a/srcpkgs/qt5/template
+++ b/srcpkgs/qt5/template
@@ -3,9 +3,9 @@
 # revbump libqtxdg after bumping patch version
 pkgname=qt5
 version=5.15.11+20231124
+revision=3
 # commit 4765fa1df7a837db9c1f89c4da0dd76b74bb5fab
 # base repo: https://invent.kde.org/qt/qt/qt5
-revision=2
 build_style=meta
 hostmakedepends="cmake clang17 flex perl glib-devel pkg-config
  python3 re2c ruby which"

From c854229496aaac7a15a181fb433664b842354292 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 059/109] qtav: revbump for ffmpeg4

---
 srcpkgs/qtav/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtav/template b/srcpkgs/qtav/template
index 775d5a139a9efa..aa69e213c984b0 100644
--- a/srcpkgs/qtav/template
+++ b/srcpkgs/qtav/template
@@ -1,10 +1,10 @@
 # Template file for 'qtav'
 pkgname=qtav
 version=1.13.0
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel libass-devel libopenal-devel
+makedepends="ffmpeg4-devel libass-devel libopenal-devel
  libva-glx-devel libXv-devel pulseaudio-devel
  qt5-declarative-devel qt5-svg-devel
  qt5-quickcontrols"

From cf5a6ed1db79b78096a5795af1adc3d64504c7f4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 060/109] retroarch: revbump for ffmpeg6

---
 srcpkgs/retroarch/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroarch/template b/srcpkgs/retroarch/template
index cb3125c5dbf1ae..c65c26f7bf0332 100644
--- a/srcpkgs/retroarch/template
+++ b/srcpkgs/retroarch/template
@@ -1,7 +1,7 @@
 # Template file for 'retroarch'
 pkgname=retroarch
 version=1.16.0.3
-revision=3
+revision=4
 build_style=configure
 configure_args="--prefix=/usr --sysconfdir=/etc --enable-networking
  --enable-udev --disable-builtinflac --disable-builtinglslang

From c332130635c10300bcce46b49044c077102177ce Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 061/109] scrcpy: revbump for ffmpeg6

---
 srcpkgs/scrcpy/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/scrcpy/template b/srcpkgs/scrcpy/template
index d40651ad8dc835..3ec7139be5c0c5 100644
--- a/srcpkgs/scrcpy/template
+++ b/srcpkgs/scrcpy/template
@@ -1,7 +1,7 @@
 # Template file for 'scrcpy'
 pkgname=scrcpy
 version=2.4
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcompile_server=false
  -Dprebuilt_server=/usr/share/scrcpy/scrcpy-server-v${version}"

From 4f30964f255e46b70b7f57bb93a29c3ab7175f60 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 17 Oct 2023 08:54:11 -0400
Subject: [PATCH 062/109] New package: spex-x replaces spek-alternative for
 ffmpeg6

---
 srcpkgs/spek-alternative                      |  1 +
 srcpkgs/spek-x/patches/musl.patch             |  7 ++++++
 srcpkgs/{spek-alternative => spek-x}/template | 22 ++++++++++++-------
 3 files changed, 22 insertions(+), 8 deletions(-)
 create mode 120000 srcpkgs/spek-alternative
 create mode 100644 srcpkgs/spek-x/patches/musl.patch
 rename srcpkgs/{spek-alternative => spek-x}/template (52%)

diff --git a/srcpkgs/spek-alternative b/srcpkgs/spek-alternative
new file mode 120000
index 00000000000000..76648236da7017
--- /dev/null
+++ b/srcpkgs/spek-alternative
@@ -0,0 +1 @@
+spek-x
\ No newline at end of file
diff --git a/srcpkgs/spek-x/patches/musl.patch b/srcpkgs/spek-x/patches/musl.patch
new file mode 100644
index 00000000000000..662f45936febc6
--- /dev/null
+++ b/srcpkgs/spek-x/patches/musl.patch
@@ -0,0 +1,7 @@
+--- a/tests/perf.cc	2024-03-09 17:13:49.086603418 -0500
++++ b/tests/perf.cc	2024-03-09 17:13:59.453603753 -0500
+@@ -1,3 +1,4 @@
++#include <cstdint>
+ #include <cstdlib>
+ #include <iostream>
+ #include <fstream>
diff --git a/srcpkgs/spek-alternative/template b/srcpkgs/spek-x/template
similarity index 52%
rename from srcpkgs/spek-alternative/template
rename to srcpkgs/spek-x/template
index d7b55c776b1d43..3ded6c2c323e4f 100644
--- a/srcpkgs/spek-alternative/template
+++ b/srcpkgs/spek-x/template
@@ -1,18 +1,18 @@
-# Template file for 'spek-alternative'
-pkgname=spek-alternative
-version=0.8.2.3
-revision=2
+# Template file for 'spek-x'
+pkgname=spek-x
+version=0.9.3
+revision=1
 build_style=gnu-configure
 hostmakedepends="automake gettext-devel intltool libtool pkg-config
  wxWidgets-common wxWidgets-gtk3-devel"
 makedepends="ffmpeg-devel wxWidgets-gtk3-devel"
 depends="ffmpeg"
 short_desc="Acoustic spectrum analyser"
-maintainer="Kartik Singh <kartik.ynwa@gmail.com>"
+maintainer="zlice <zlice555@gmail.com>"
 license="GPL-3.0-or-later"
-homepage="https://github.com/withmorten/spek-alternative"
-distfiles="https://github.com/withmorten/spek-alternative/archive/${version}.tar.gz"
-checksum="007ba4b84a310b078e378aa84c8e80783db5821437a757a488c3ecec377e6b2a"
+homepage="https://github.com/MikeWang000000/spek-x"
+distfiles="https://github.com/MikeWang000000/spek-x/archive/v${version}.tar.gz"
+checksum="7f4b109903333cdd310ab2b9176f0dc49a565891376e281a233d342cedf90ef7"
 
 CXXFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
 
@@ -22,3 +22,9 @@ export WX_CONFIG_NAME="wx-config-gtk3"
 pre_configure() {
 	NOCONFIGURE=1 ./autogen.sh
 }
+
+spek-alternative_package() {
+	depends="spek-x"
+	short_desc+=" - transitional dummy package"
+	build_style=meta
+}

From 3cb6d2dbf239b24b666359e5209580d2004f2197 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 063/109] ssr: revbump for ffmpeg6

---
 .../0001-Fix-build-with-ffmpeg-5.0.patch      | 241 ++++++++++++++++++
 srcpkgs/ssr/template                          |   2 +-
 2 files changed, 242 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ssr/patches/0001-Fix-build-with-ffmpeg-5.0.patch

diff --git a/srcpkgs/ssr/patches/0001-Fix-build-with-ffmpeg-5.0.patch b/srcpkgs/ssr/patches/0001-Fix-build-with-ffmpeg-5.0.patch
new file mode 100644
index 00000000000000..4c069b5a9fc464
--- /dev/null
+++ b/srcpkgs/ssr/patches/0001-Fix-build-with-ffmpeg-5.0.patch
@@ -0,0 +1,241 @@
+From f4cbde38021d9330dc73d2e3dfa8a70da3ff5721 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Bernhard=20Rosenkr=C3=A4nzer?= <bero@lindev.ch>
+Date: Sun, 16 Jan 2022 02:40:04 +0100
+Subject: [PATCH] Fix build with ffmpeg 5.0
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Adapt to ffmpeg 5.0 requiring more const-ness for AVCodec.
+
+Signed-off-by: Bernhard Rosenkränzer <bero@lindev.ch>
+---
+ src/AV/Output/AudioEncoder.cpp |  6 +++---
+ src/AV/Output/AudioEncoder.h   |  4 ++--
+ src/AV/Output/BaseEncoder.cpp  |  4 ++--
+ src/AV/Output/BaseEncoder.h    |  4 ++--
+ src/AV/Output/Muxer.cpp        | 12 ++++++------
+ src/AV/Output/Muxer.h          |  4 ++--
+ src/AV/Output/VideoEncoder.cpp |  6 +++---
+ src/AV/Output/VideoEncoder.h   |  4 ++--
+ 8 files changed, 22 insertions(+), 22 deletions(-)
+
+diff --git a/src/AV/Output/AudioEncoder.cpp b/src/AV/Output/AudioEncoder.cpp
+index 34d015c..cefc2e0 100644
+--- a/src/AV/Output/AudioEncoder.cpp
++++ b/src/AV/Output/AudioEncoder.cpp
+@@ -34,7 +34,7 @@ const std::vector<AudioEncoder::SampleFormatData> AudioEncoder::SUPPORTED_SAMPLE
+ 
+ const unsigned int AudioEncoder::DEFAULT_FRAME_SAMPLES = 1024;
+ 
+-AudioEncoder::AudioEncoder(Muxer* muxer, AVStream* stream, AVCodecContext *codec_context, AVCodec* codec, AVDictionary** options)
++AudioEncoder::AudioEncoder(Muxer* muxer, AVStream* stream, AVCodecContext *codec_context, const AVCodec* codec, AVDictionary** options)
+ 	: BaseEncoder(muxer, stream, codec_context, codec, options) {
+ 
+ #if !SSR_USE_AVCODEC_ENCODE_AUDIO2
+@@ -77,7 +77,7 @@ unsigned int AudioEncoder::GetSampleRate() {
+ }
+ 
+ bool AudioEncoder::AVCodecIsSupported(const QString& codec_name) {
+-	AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
++	const AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
+ 	if(codec == NULL)
+ 		return false;
+ 	if(!av_codec_is_encoder(codec))
+@@ -93,7 +93,7 @@ bool AudioEncoder::AVCodecIsSupported(const QString& codec_name) {
+ 	return false;
+ }
+ 
+-void AudioEncoder::PrepareStream(AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
++void AudioEncoder::PrepareStream(AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
+ 								 unsigned int bit_rate, unsigned int channels, unsigned int sample_rate) {
+ 
+ 	if(channels == 0) {
+diff --git a/src/AV/Output/AudioEncoder.h b/src/AV/Output/AudioEncoder.h
+index c93278c..ae9c82e 100644
+--- a/src/AV/Output/AudioEncoder.h
++++ b/src/AV/Output/AudioEncoder.h
+@@ -40,7 +40,7 @@ private:
+ #endif
+ 
+ public:
+-	AudioEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options);
++	AudioEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options);
+ 	~AudioEncoder();
+ 
+ 	// Returns the required frame size, i.e. the number of samples (for each channel).
+@@ -57,7 +57,7 @@ public:
+ 
+ public:
+ 	static bool AVCodecIsSupported(const QString& codec_name);
+-	static void PrepareStream(AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
++	static void PrepareStream(AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
+ 							  unsigned int bit_rate, unsigned int channels, unsigned int sample_rate);
+ 
+ private:
+diff --git a/src/AV/Output/BaseEncoder.cpp b/src/AV/Output/BaseEncoder.cpp
+index 7c01ef3..4780aaf 100644
+--- a/src/AV/Output/BaseEncoder.cpp
++++ b/src/AV/Output/BaseEncoder.cpp
+@@ -42,7 +42,7 @@ double ParseCodecOptionDouble(const QString& key, const QString& value, double m
+ 	return clamp(value_double, min, max) * multiply;
+ }
+ 
+-BaseEncoder::BaseEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options) {
++BaseEncoder::BaseEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options) {
+ 
+ 	m_muxer = muxer;
+ 	m_stream = stream;
+@@ -157,7 +157,7 @@ void BaseEncoder::IncrementPacketCounter() {
+ 	++lock->m_total_packets;
+ }
+ 
+-void BaseEncoder::Init(AVCodec* codec, AVDictionary** options) {
++void BaseEncoder::Init(const AVCodec* codec, AVDictionary** options) {
+ 
+ 	// open codec
+ 	if(avcodec_open2(m_codec_context, codec, options) < 0) {
+diff --git a/src/AV/Output/BaseEncoder.h b/src/AV/Output/BaseEncoder.h
+index 3d92f29..7f02bbd 100644
+--- a/src/AV/Output/BaseEncoder.h
++++ b/src/AV/Output/BaseEncoder.h
+@@ -51,7 +51,7 @@ private:
+ 	std::atomic<bool> m_should_stop, m_should_finish, m_is_done, m_error_occurred;
+ 
+ protected:
+-	BaseEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options);
++	BaseEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options);
+ 
+ public:
+ 	virtual ~BaseEncoder(); // encoders will be deleted by Muxer, don't delete them yourself!
+@@ -117,7 +117,7 @@ protected:
+ 	void IncrementPacketCounter();
+ 
+ private:
+-	void Init(AVCodec* codec, AVDictionary** options);
++	void Init(const AVCodec* codec, AVDictionary** options);
+ 	void Free();
+ 
+ 	void EncoderThread();
+diff --git a/src/AV/Output/Muxer.cpp b/src/AV/Output/Muxer.cpp
+index ad58380..14650b0 100644
+--- a/src/AV/Output/Muxer.cpp
++++ b/src/AV/Output/Muxer.cpp
+@@ -87,7 +87,7 @@ Muxer::~Muxer() {
+ 
+ VideoEncoder* Muxer::AddVideoEncoder(const QString& codec_name, const std::vector<std::pair<QString, QString> >& codec_options,
+ 									 unsigned int bit_rate, unsigned int width, unsigned int height, unsigned int frame_rate) {
+-	AVCodec *codec = FindCodec(codec_name);
++	const AVCodec *codec = FindCodec(codec_name);
+ 	AVCodecContext *codec_context = NULL;
+ 	AVStream *stream = AddStream(codec, &codec_context);
+ 	VideoEncoder *encoder;
+@@ -111,7 +111,7 @@ VideoEncoder* Muxer::AddVideoEncoder(const QString& codec_name, const std::vecto
+ 
+ AudioEncoder* Muxer::AddAudioEncoder(const QString& codec_name, const std::vector<std::pair<QString, QString> >& codec_options,
+ 									 unsigned int bit_rate, unsigned int channels, unsigned int sample_rate) {
+-	AVCodec *codec = FindCodec(codec_name);
++	const AVCodec *codec = FindCodec(codec_name);
+ 	AVCodecContext *codec_context = NULL;
+ 	AVStream *stream = AddStream(codec, &codec_context);
+ 	AudioEncoder *encoder;
+@@ -194,7 +194,7 @@ unsigned int Muxer::GetQueuedPacketCount(unsigned int stream_index) {
+ void Muxer::Init() {
+ 
+ 	// get the format we want (this is just a pointer, we don't have to free this)
+-	AVOutputFormat *format = av_guess_format(m_container_name.toUtf8().constData(), NULL, NULL);
++	const AVOutputFormat *format = av_guess_format(m_container_name.toUtf8().constData(), NULL, NULL);
+ 	if(format == NULL) {
+ 		Logger::LogError("[Muxer::Init] " + Logger::tr("Error: Can't find chosen output format!"));
+ 		throw LibavException();
+@@ -261,8 +261,8 @@ void Muxer::Free() {
+ 	}
+ }
+ 
+-AVCodec* Muxer::FindCodec(const QString& codec_name) {
+-	AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
++const AVCodec* Muxer::FindCodec(const QString& codec_name) {
++	const AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
+ 	if(codec == NULL) {
+ 		Logger::LogError("[Muxer::FindCodec] " + Logger::tr("Error: Can't find codec!"));
+ 		throw LibavException();
+@@ -270,7 +270,7 @@ AVCodec* Muxer::FindCodec(const QString& codec_name) {
+ 	return codec;
+ }
+ 
+-AVStream* Muxer::AddStream(AVCodec* codec, AVCodecContext** codec_context) {
++AVStream* Muxer::AddStream(const AVCodec* codec, AVCodecContext** codec_context) {
+ 	assert(!m_started);
+ 	assert(m_format_context->nb_streams < MUXER_MAX_STREAMS);
+ 
+diff --git a/src/AV/Output/Muxer.h b/src/AV/Output/Muxer.h
+index d72347d..b104bcb 100644
+--- a/src/AV/Output/Muxer.h
++++ b/src/AV/Output/Muxer.h
+@@ -114,8 +114,8 @@ private:
+ 	void Init();
+ 	void Free();
+ 
+-	AVCodec* FindCodec(const QString& codec_name);
+-	AVStream* AddStream(AVCodec* codec, AVCodecContext** codec_context);
++	const AVCodec* FindCodec(const QString& codec_name);
++	AVStream* AddStream(const AVCodec* codec, AVCodecContext** codec_context);
+ 
+ 	void MuxerThread();
+ 
+diff --git a/src/AV/Output/VideoEncoder.cpp b/src/AV/Output/VideoEncoder.cpp
+index 8087e8e..fc8b5d1 100644
+--- a/src/AV/Output/VideoEncoder.cpp
++++ b/src/AV/Output/VideoEncoder.cpp
+@@ -34,7 +34,7 @@ const std::vector<VideoEncoder::PixelFormatData> VideoEncoder::SUPPORTED_PIXEL_F
+ 	{"rgb", AV_PIX_FMT_RGB24, false},
+ };
+ 
+-VideoEncoder::VideoEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options)
++VideoEncoder::VideoEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options)
+ 	: BaseEncoder(muxer, stream, codec_context, codec, options) {
+ 
+ #if !SSR_USE_AVCODEC_ENCODE_VIDEO2
+@@ -95,7 +95,7 @@ unsigned int VideoEncoder::GetFrameRate() {
+ }
+ 
+ bool VideoEncoder::AVCodecIsSupported(const QString& codec_name) {
+-	AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
++	const AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
+ 	if(codec == NULL)
+ 		return false;
+ 	if(!av_codec_is_encoder(codec))
+@@ -111,7 +111,7 @@ bool VideoEncoder::AVCodecIsSupported(const QString& codec_name) {
+ 	return false;
+ }
+ 
+-void VideoEncoder::PrepareStream(AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
++void VideoEncoder::PrepareStream(AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
+ 								 unsigned int bit_rate, unsigned int width, unsigned int height, unsigned int frame_rate) {
+ 
+ 	if(width == 0 || height == 0) {
+diff --git a/src/AV/Output/VideoEncoder.h b/src/AV/Output/VideoEncoder.h
+index cb7ca27..68d872e 100644
+--- a/src/AV/Output/VideoEncoder.h
++++ b/src/AV/Output/VideoEncoder.h
+@@ -40,7 +40,7 @@ private:
+ #endif
+ 
+ public:
+-	VideoEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options);
++	VideoEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options);
+ 	~VideoEncoder();
+ 
+ 	// Returns the required pixel format.
+@@ -55,7 +55,7 @@ public:
+ 
+ public:
+ 	static bool AVCodecIsSupported(const QString& codec_name);
+-	static void PrepareStream(AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
++	static void PrepareStream(AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
+ 							  unsigned int bit_rate, unsigned int width, unsigned int height, unsigned int frame_rate);
+ 
+ private:
+-- 
+2.43.0
+
diff --git a/srcpkgs/ssr/template b/srcpkgs/ssr/template
index 3097754e3cbe54..e3c4261f1f5a64 100644
--- a/srcpkgs/ssr/template
+++ b/srcpkgs/ssr/template
@@ -1,7 +1,7 @@
 # Template file for 'ssr'
 pkgname=ssr
 version=0.4.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DWITH_QT5=ON"
 hostmakedepends="pkg-config"

From 4b6c1b71cb4b231b2d9574ad9567a579aee98a78 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 064/109] synfig: revbump for ffmpeg6 and mlt7

---
 srcpkgs/synfig/patches/ffmpeg6.patch | 71 ++++++++++++++++++++++++++++
 srcpkgs/synfig/template              |  6 +--
 2 files changed, 74 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/synfig/patches/ffmpeg6.patch

diff --git a/srcpkgs/synfig/patches/ffmpeg6.patch b/srcpkgs/synfig/patches/ffmpeg6.patch
new file mode 100644
index 00000000000000..10780b42782f4b
--- /dev/null
+++ b/srcpkgs/synfig/patches/ffmpeg6.patch
@@ -0,0 +1,71 @@
+--- a/src/modules/mod_libavcodec/trgt_av.cpp	2022-10-25 09:14:12.000000000 -0400
++++ b/src/modules/mod_libavcodec/trgt_av.cpp	2023-05-05 21:34:17.899194559 -0400
+@@ -38,6 +41,7 @@
+ extern "C"
+ {
+ #ifdef HAVE_LIBAVFORMAT_AVFORMAT_H
++#	include <libavcodec/avcodec.h>
+ #	include <libavformat/avformat.h>
+ #elif defined(HAVE_AVFORMAT_H)
+ #	include <avformat.h>
+@@ -155,11 +156,11 @@
+     }
+ 
+ 	bool open_video_stream() {
+-		if (avcodec_open2(video_context, NULL, NULL) < 0) {
++		if (avcodec_open2(video_context, nullptr, nullptr) < 0) {
+ 			synfig::error("Target_LibAVCodec: could not open video codec");
+ 			// seems the calling of avcodec_free_context after error will cause crash
+ 			// so just forget about this context
+-			video_context = NULL;
++			video_context = nullptr;
+ 			close();
+ 			return false;
+         }
+@@ -234,15 +235,21 @@
+ 		close();
+ 
+ 		if (!av_registered) {
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 			av_register_all();
++#endif
+ 			av_registered = true;
+ 		}
+ 
+ 		// guess format
+-		AVOutputFormat *format = av_guess_format(NULL, filename.c_str(), NULL);
++#if LIBAVCODEC_VERSION_MAJOR < 59 // FFMPEG < 5.0
++		AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#else
++		const AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#endif
+ 		if (!format) {
+ 			synfig::warning("Target_LibAVCodec: unable to guess the output format, defaulting to MPEG");
+-			format = av_guess_format("mpeg", NULL, NULL);
++			format = av_guess_format("mpeg", nullptr, nullptr);
+ 		}
+ 		if (!format) {
+ 			synfig::error("Target_LibAVCodec: unable to find 'mpeg' output format");
+@@ -254,6 +261,7 @@
+ 		context = avformat_alloc_context();
+ 		assert(context);
+ 		context->oformat = format;
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 		if (filename.size() + 1 > sizeof(context->filename)) {
+ 			synfig::error(
+ 				"Target_LibAVCodec: filename too long, max length is %d, filename is '%s'",
+@@ -263,6 +271,14 @@
+ 			return false;
+ 		}
+ 		memcpy(context->filename, filename.c_str(), filename.size() + 1);
++#else
++		context->url = av_strndup(filename.c_str(), filename.size());
++		if (!context->url) {
++			synfig::error("Target_LibAVCodec: cannot allocate space for filename");
++			close();
++			return false;
++		}
++#endif
+ 
+ 		packet = av_packet_alloc();
+ 		assert(packet);
diff --git a/srcpkgs/synfig/template b/srcpkgs/synfig/template
index d4d3e341a20bf8..828b5cb32956ee 100644
--- a/srcpkgs/synfig/template
+++ b/srcpkgs/synfig/template
@@ -2,11 +2,11 @@
 # Should be kept in sync with 'synfigstudio' and 'ETL'
 pkgname=synfig
 version=1.4.4
-revision=4
+revision=5
 build_style=gnu-configure
 configure_args="--with-boost-libdir=${XBPS_CROSS_BASE}/usr/lib"
 hostmakedepends="boost-build ImageMagick pkg-config intltool"
-makedepends="ETL gettext-devel libxml++-devel mlt-devel libmagick-devel
+makedepends="ETL gettext-devel libxml++-devel mlt7-devel libmagick-devel
  libmng-devel boost-build boost-devel libopenexr-devel ffmpeg-devel"
 depends="ImageMagick"
 short_desc="CLI 2D vector and timeline-based animation software"
@@ -20,7 +20,7 @@ CXXFLAGS="-std=c++11 -DHAVE_LOCALE_H=1"
 
 synfig-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision}
-	 libopenexr-devel libxml++-devel mlt-devel"
+	 libopenexr-devel libxml++-devel mlt7-devel"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/bin/synfig-config

From 0ca71620da52c20f3d7d777484abf62f45fb0ab9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 065/109] timg: revbump for ffmpeg6

---
 srcpkgs/timg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/timg/template b/srcpkgs/timg/template
index 2a2ab763d2fddf..8fb4327535ef93 100644
--- a/srcpkgs/timg/template
+++ b/srcpkgs/timg/template
@@ -1,7 +1,7 @@
 # Template file for 'timg'
 pkgname=timg
 version=1.4.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_OPENSLIDE_SUPPORT=off -Wno-dev"
 hostmakedepends="pkg-config git"

From c73b8a2e49bc9e15bfc79cb8380e1cf0db745c2f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 066/109] tvheadend: revbump for ffmpeg4

---
 srcpkgs/tvheadend/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tvheadend/template b/srcpkgs/tvheadend/template
index 9aea7de4ec7057..012d31c4879ff1 100644
--- a/srcpkgs/tvheadend/template
+++ b/srcpkgs/tvheadend/template
@@ -8,7 +8,7 @@ configure_args="--enable-dvbscan --disable-ffmpeg_static
 --disable-libx265_static --disable-libvpx_static --disable-libtheora_static
 --disable-libvorbis_static --disable-libfdkaac_static"
 hostmakedepends="gettext pkg-config python3 git which"
-makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg-devel"
+makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg4-devel"
 short_desc="TV streaming server"
 maintainer="lemmi <lemmi@nerd2nerd.org>"
 license="GPL-3.0-only"

From e01da082f82b01d9cfa297ec8be465a275db7c16 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 067/109] unpaper: update to 7.0.0.

---
 srcpkgs/unpaper/template | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/srcpkgs/unpaper/template b/srcpkgs/unpaper/template
index 38ed47a5840165..1ff910e722afc8 100644
--- a/srcpkgs/unpaper/template
+++ b/srcpkgs/unpaper/template
@@ -1,13 +1,13 @@
 # Template file for 'unpaper'
 pkgname=unpaper
-version=6.1
-revision=3
-build_style=gnu-configure
+version=7.0.0
+revision=1
+build_style=meson
+hostmakedepends="pkg-config meson libxslt"
+makedepends="ffmpeg-devel python3-Sphinx"
+short_desc="Post-processing tool for scanned sheets of paper"
 maintainer="Orphaned <orphan@voidlinux.org>"
-hostmakedepends="pkg-config libxslt"
-makedepends="ffmpeg-devel"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://www.flameeyes.eu/projects/unpaper"
-short_desc="A post-processing tool for scanned sheets of paper"
 distfiles="https://www.flameeyes.eu/files/${pkgname}-${version}.tar.xz"
-checksum=237c84f5da544b3f7709827f9f12c37c346cdf029b1128fb4633f9bafa5cb930
+checksum=2575fbbf26c22719d1cb882b59602c9900c7f747118ac130883f63419be46a80

From 07fbbaf418ec5c60171388f9afdcfacf5516a7cc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 068/109] vice: revbump for ffmpeg4

---
 srcpkgs/vice/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vice/template b/srcpkgs/vice/template
index 1c641d9ae9be22..4f43e85b5b8972 100644
--- a/srcpkgs/vice/template
+++ b/srcpkgs/vice/template
@@ -1,7 +1,7 @@
 # Template file for 'vice'
 pkgname=vice
 version=3.8
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-cpuhistory --enable-x64 --disable-pdf-docs
  --libdir=/usr/lib$XBPS_TARGET_WORDSIZE $(vopt_enable sdl2 sdlui2)

From 582631bb0785e97c6ab3add4b8e7a79e140d0f80 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 069/109] waypipe: revbump for ffmpeg6

---
 srcpkgs/waypipe/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waypipe/template b/srcpkgs/waypipe/template
index 6da88b21bf2a19..4da8058400b588 100644
--- a/srcpkgs/waypipe/template
+++ b/srcpkgs/waypipe/template
@@ -1,7 +1,7 @@
 # Template file for 'waypipe'
 pkgname=waypipe
 version=0.8.6
-revision=1
+revision=2
 build_style=meson
 # lto is off because it causes linking errors in armv6l and armv7l (due to NEON)
 configure_args="-Dwerror=false -Dwith_dmabuf=enabled -Dwith_lz4=enabled

From 6fc67979d69a6db6f9e4a89bf6aa77998faf8588 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 070/109] xpra: revbump for ffmpeg6

---
 srcpkgs/xpra/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xpra/template b/srcpkgs/xpra/template
index 3e49ab23deac9c..3939026a6fbf90 100644
--- a/srcpkgs/xpra/template
+++ b/srcpkgs/xpra/template
@@ -1,7 +1,7 @@
 # Template file for 'xpra'
 pkgname=xpra
 version=5.0.7
-revision=1
+revision=2
 build_style=python3-module
 make_build_args="--without-cuda_kernels --without-cuda_rebuild"
 make_install_args="$(vopt_with docs) ${make_build_args}"

From 5496fe40622bbba6cfa2c4f7dd90d3711b299cfb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:07:40 -0400
Subject: [PATCH 071/109] nv-codec-headers: update to 12.0.16.0

---
 srcpkgs/nv-codec-headers/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/nv-codec-headers/template b/srcpkgs/nv-codec-headers/template
index 3d422a61e48917..251e057f826fb8 100644
--- a/srcpkgs/nv-codec-headers/template
+++ b/srcpkgs/nv-codec-headers/template
@@ -1,6 +1,6 @@
 # Template file for 'nv-codec-headers'
 pkgname=nv-codec-headers
-version=11.1.5.1
+version=12.0.16.0
 revision=1
 build_style=gnu-makefile
 short_desc="FFmpeg version of headers required to interface with Nvidias codec APIs"
@@ -8,7 +8,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="MIT"
 homepage="http://git.videolan.org/?p=ffmpeg/nv-codec-headers.git"
 distfiles="https://github.com/FFmpeg/nv-codec-headers/archive/n${version}.tar.gz"
-checksum=d095fbd56aa93772471a323be0ebe65504a0f43f06c76a30b6d25da77b06ae9c
+checksum=2a1533b65f55f9da52956faf0627ed3b74868ac0c7f269990edd21369113b48f
 
 post_install() {
 	sed -n '4,25p' include/ffnvcodec/nvEncodeAPI.h > LICENSE

From 4edcc5fb2ed3829679a94a9b777a2f51a4ec9f8f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:08:40 -0400
Subject: [PATCH 072/109] openimagedenoise: revbump for ffmpeg6

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index 109deb171c3f75..44edf38fb289d8 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,7 +1,7 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
 version=1.4.3
-revision=2
+revision=3
 archs="x86_64*"
 build_style=cmake
 hostmakedepends="ispc python3"

From 8abd715425ba58db5c686208cd4a6706e99c9cdb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:31:45 -0400
Subject: [PATCH 073/109] shotcut: revbump for ffmpeg6

---
 srcpkgs/shotcut/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/shotcut/template b/srcpkgs/shotcut/template
index b0dc9377558941..13e8a08522b68f 100644
--- a/srcpkgs/shotcut/template
+++ b/srcpkgs/shotcut/template
@@ -1,7 +1,7 @@
 # Template file for 'shotcut'
 pkgname=shotcut
 version=23.09.29
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSHOTCUT_VERSION=${version}"
 hostmakedepends="pkg-config qt6-base qt6-tools"

From 7c5bb8e639d144d3f7681b12733383805632665b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:30 -0400
Subject: [PATCH 074/109] shiboken2: revbump for qt5-5.15.11

---
 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch | 1 +
 1 file changed, 1 insertion(+)
 create mode 120000 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
new file mode 120000
index 00000000000000..efcf3249bd8854
--- /dev/null
+++ b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1 @@
+../../python3-pyside2/patches/importlib-machinery-bypass.patch
\ No newline at end of file

From 8ea62f366f01cd5715484c86bdabd2a9228f7bc3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:53 -0400
Subject: [PATCH 075/109] python3-pyside2: revbump for qt5-5.15.11

---
 .../patches/importlib-machinery-bypass.patch      | 15 +++++++++++++++
 srcpkgs/python3-pyside2/template                  |  2 +-
 2 files changed, 16 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
new file mode 100644
index 00000000000000..64c429584776b5
--- /dev/null
+++ b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1,15 @@
+Using this prevents an error around line 220 below it.
+"AttributeError: module 'importlib' has no attribute 'machinery'"
+The old backup logic is in place and compiles without issues.
+--- a/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:09:34.688912402 -0400
++++ b/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:10:03.395529582 -0400
+@@ -170,9 +170,6 @@
+
+     # 'zipstring_sequence' comes from signature.cpp
+     zipbytes = base64.b64decode(''.join(zipstring_sequence))
+-    if sys.version_info[0] >= 3:
+-        vzip = zipfile.ZipFile(io.BytesIO(zipbytes))
+-        return sys.meta_path, EmbeddableZipImporter(vzip)
+
+     # Old version for Python 2.7, only.
+     import os
diff --git a/srcpkgs/python3-pyside2/template b/srcpkgs/python3-pyside2/template
index 249efa90988425..52626436ce75f2 100644
--- a/srcpkgs/python3-pyside2/template
+++ b/srcpkgs/python3-pyside2/template
@@ -1,7 +1,7 @@
 # Template file for 'python3-pyside2'
 pkgname=python3-pyside2
 version=5.15.10
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/pyside2"
 build_style=cmake

From 6563c6f8393c34b5f70709a92da948c5be8a5cfe Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:35 -0400
Subject: [PATCH 076/109] konqueror: revbump for ffmpeg6

---
 srcpkgs/konqueror/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/konqueror/template b/srcpkgs/konqueror/template
index add972916753c6..50bbf4eec05e55 100644
--- a/srcpkgs/konqueror/template
+++ b/srcpkgs/konqueror/template
@@ -1,11 +1,11 @@
 # Template file for 'konqueror'
 pkgname=konqueror
 version=23.08.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DDESKTOPTOJSON_EXECUTABLE=/usr/bin/desktoptojson"
 hostmakedepends="extra-cmake-modules python3 qt5-host-tools qt5-qmake kdoctools
-kcoreaddons kconfig gettext"
+ kcoreaddons kconfig gettext"
 makedepends="qt5-devel qt5-webengine-devel qt5-declarative-devel
  qt5-webchannel-devel qt5-location-devel kcmutils-devel kdelibs4support-devel
  karchive-devel khtml-devel kdesu-devel kactivities5-devel"

From 71ae5cd705c973975fc48ef59307b36ce95000d0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:58 -0400
Subject: [PATCH 077/109] qt5-speech: revbump for qt5-5.15.11

---
 srcpkgs/qt5-speech/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-speech/template b/srcpkgs/qt5-speech/template
index 1228bb60c41db4..27a7da1dbdb91b 100644
--- a/srcpkgs/qt5-speech/template
+++ b/srcpkgs/qt5-speech/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-speech'
 pkgname=qt5-speech
 version=5.15.11
-revision=1
+revision=2
 _commit=d32f4a479d38a11f547598004b975f4356424a16
 build_style=qmake
 configure_args="-- -flite -flite-alsa -speechd"

From 6f474797db9c4f1b48361211d26eb9a7610eac98 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Jun 2023 08:20:22 -0400
Subject: [PATCH 078/109] gtk4: revbump for ffmpeg6

---
 srcpkgs/gtk4/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gtk4/template b/srcpkgs/gtk4/template
index 452ad63a9f4e6c..8f534c54aab81a 100644
--- a/srcpkgs/gtk4/template
+++ b/srcpkgs/gtk4/template
@@ -1,7 +1,7 @@
 # Template file for 'gtk4'
 pkgname=gtk4
 version=4.14.1
-revision=1
+revision=2
 build_style=meson
 build_helper="gir"
 configure_args="-Dman-pages=true -Ddocumentation=true -Dbuild-tests=false

From 037b563d35e7725082e63413d7eff59427040ade Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:28:26 -0400
Subject: [PATCH 079/109] siril: revbump for ffmpeg6

---
 srcpkgs/siril/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/siril/template b/srcpkgs/siril/template
index 84332f79d060d2..62750dd247548f 100644
--- a/srcpkgs/siril/template
+++ b/srcpkgs/siril/template
@@ -1,7 +1,7 @@
 # Template file for 'siril'
 pkgname=siril
 version=0.9.12
-revision=10
+revision=11
 build_style=gnu-configure
 hostmakedepends="pkg-config intltool autoconf automake gettext-devel"
 makedepends="fftw-devel libconfig-devel libopencv-devel libffms2-devel

From 73d54f6f01c748c725c27d1d7cd4afcaf5b76497 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:20:59 -0400
Subject: [PATCH 080/109] tracker-miners: revbump for ffmpeg6

---
 srcpkgs/tracker-miners/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tracker-miners/template b/srcpkgs/tracker-miners/template
index 32c9c116114dc2..363c08cccdc349 100644
--- a/srcpkgs/tracker-miners/template
+++ b/srcpkgs/tracker-miners/template
@@ -1,7 +1,7 @@
 # Template file for 'tracker-miners'
 pkgname=tracker-miners
 version=3.7.1
-revision=1
+revision=2
 build_style=meson
 build_helper=qemu
 # missing libgrss for miner_rss

From f26b723b8110bf8a5ab2bfc22e73070fd638663c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:21:21 -0400
Subject: [PATCH 081/109] mpd: revbump for ffmpeg6

---
 srcpkgs/mdp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mdp/template b/srcpkgs/mdp/template
index 3720bfae02f840..1c45395dca9b21 100644
--- a/srcpkgs/mdp/template
+++ b/srcpkgs/mdp/template
@@ -1,7 +1,7 @@
 # Template file for 'mdp'
 pkgname=mdp
 version=1.0.15
-revision=1
+revision=2
 build_style=gnu-makefile
 makedepends="ncurses-devel"
 short_desc="A command-line based markdown presentation tool"

From fab306403dae0040965ae516eaf77a4ba9235e3e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:02 -0400
Subject: [PATCH 082/109] tg_owt: revbump for ffmpeg6

---
 srcpkgs/tg_owt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tg_owt/template b/srcpkgs/tg_owt/template
index 34e8fef0540569..1a46a8bedf3473 100644
--- a/srcpkgs/tg_owt/template
+++ b/srcpkgs/tg_owt/template
@@ -1,7 +1,7 @@
 # Template file for 'tg_owt'
 pkgname=tg_owt
 version=0.0.0.20231221
-revision=2
+revision=3
 _commit=afd9d5d31798d3eacf9ed6c30601e91d0f1e4d60
 _libyuv_commit=04821d1e7d60845525e8db55c7bcd41ef5be9406
 _abseil_commit=8c0b94e793a66495e0b1f34a5eb26bd7dc672db0

From fbb0f09144f58b64e1a5f85d09fd1eaa289e6394 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:44 -0400
Subject: [PATCH 083/109] telegram-desktop: revbump for ffmpeg6

---
 srcpkgs/telegram-desktop/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/telegram-desktop/template b/srcpkgs/telegram-desktop/template
index 6dc6a553cfcec8..cf85a731370062 100644
--- a/srcpkgs/telegram-desktop/template
+++ b/srcpkgs/telegram-desktop/template
@@ -1,7 +1,7 @@
 # Template file for 'telegram-desktop'
 pkgname=telegram-desktop
 version=4.14.15
-revision=3
+revision=4
 build_style=cmake
 build_helper="qemu gir"
 configure_args="-DTDESKTOP_API_ID=209235

From aba88a1374707afbeacdbe8c0fa61c05609e3235 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:12:09 -0400
Subject: [PATCH 084/109] openmw: revbump for ffmpeg6

---
 srcpkgs/openmw/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openmw/template b/srcpkgs/openmw/template
index 0abf5ff7cdbecc..b57180f1a4446f 100644
--- a/srcpkgs/openmw/template
+++ b/srcpkgs/openmw/template
@@ -1,7 +1,7 @@
 # Template file for 'openmw'
 pkgname=openmw
 version=0.48.0
-revision=2
+revision=3
 build_style=cmake
 _recast_commit=e75adf86f91eb3082220085e42dda62679f9a3ea
 _bullet_tag=3.17

From 8075aa83ee18e974886364187188aca428641233 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:14:53 -0400
Subject: [PATCH 085/109] lms: revbump for ffmpeg6

---
 srcpkgs/lms/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/lms/template b/srcpkgs/lms/template
index e358f75902a986..3b21c458de5199 100644
--- a/srcpkgs/lms/template
+++ b/srcpkgs/lms/template
@@ -1,7 +1,7 @@
 # Template file for 'lms'
 pkgname=lms
 version=3.42.1
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="wt-devel ffmpeg-devel boost-devel libconfig++-devel taglib-devel pam-devel libgraphicsmagick-devel gtest-devel libarchive-devel"

From bb9501cbe0c4e7b7f536d509dcd6ed8923fbfd1e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:18:18 -0400
Subject: [PATCH 086/109] freecad: DELETE

---
 srcpkgs/freecad/patches/001-include.patch     | 112 ------------------
 .../154-revert-gui-tmp-redirect-stderr.patch  |  68 -----------
 ...d63c8c9b1280978be841d04e68a0a55cceb9.patch |  30 -----
 srcpkgs/freecad/template                      |  12 +-
 4 files changed, 7 insertions(+), 215 deletions(-)
 delete mode 100644 srcpkgs/freecad/patches/001-include.patch
 delete mode 100644 srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
 delete mode 100644 srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch

diff --git a/srcpkgs/freecad/patches/001-include.patch b/srcpkgs/freecad/patches/001-include.patch
deleted file mode 100644
index 28b5af54999b96..00000000000000
--- a/srcpkgs/freecad/patches/001-include.patch
+++ /dev/null
@@ -1,112 +0,0 @@
-From 9a41845a417189776741297c50a3827ce292bc4f Mon Sep 17 00:00:00 2001
-From: Uwe <donovaly@users.noreply.github.com>
-Date: Sun, 3 Jul 2022 22:51:16 +0200
-Subject: [PATCH] [Part] OCCError.h: remove unneeded includes
-
-- also sort includes
----
- src/Mod/Part/App/OCCError.h             | 36 +++----------------------
- src/Mod/Part/App/OffsetCurvePyImp.cpp   | 12 ++++-----
- src/Mod/Part/App/OffsetSurfacePyImp.cpp | 10 +++----
- 3 files changed, 12 insertions(+), 46 deletions(-)
-
---- a/src/Mod/Part/App/OCCError.h
-+++ b/src/Mod/Part/App/OCCError.h
-@@ -23,36 +23,8 @@
- #ifndef _OCCError_h_
- #define _OCCError_h_
- 
--# include <Standard_Version.hxx>
- # include <Standard_Failure.hxx>
--# include <Standard_AbortiveTransaction.hxx>
--# include <Standard_ConstructionError.hxx>
--# if OCC_VERSION_HEX >= 0x060500
--# include <Standard_DefineException.hxx>
--# endif
--# include <Standard_DimensionError.hxx>
--# include <Standard_DimensionMismatch.hxx>
--# include <Standard_DivideByZero.hxx>
--# include <Standard_DomainError.hxx>
--# include <Standard_ImmutableObject.hxx>
--# include <Standard_LicenseError.hxx>
--# include <Standard_LicenseNotFound.hxx>
--# include <Standard_MultiplyDefined.hxx>
--# include <Standard_NegativeValue.hxx>
--# include <Standard_NoMoreObject.hxx>
--# include <Standard_NoSuchObject.hxx>
--# include <Standard_NotImplemented.hxx>
--# include <Standard_NullObject.hxx>
--# include <Standard_NullValue.hxx>
--# include <Standard_NumericError.hxx>
--# include <Standard_OutOfMemory.hxx>
--# include <Standard_OutOfRange.hxx>
--# include <Standard_Overflow.hxx>
--# include <Standard_ProgramError.hxx>
--# include <Standard_RangeError.hxx>
--# include <Standard_TooManyUsers.hxx>
--# include <Standard_TypeMismatch.hxx>
--# include <Standard_Underflow.hxx>
-+# include <Standard_Version.hxx>
- 
- #include <Mod/Part/PartGlobal.h>
- #include <Base/Console.h>
-@@ -88,4 +60,3 @@ PartExport extern PyObject* PartExceptio
- 
- #define PY_CATCH_OCC _PY_CATCH_OCC(return(NULL))
- #endif  // _OCCError_h_
--
---- a/src/Mod/Part/App/OffsetCurvePyImp.cpp
-+++ b/src/Mod/Part/App/OffsetCurvePyImp.cpp
-@@ -20,20 +20,20 @@
-  *                                                                         *
-  ***************************************************************************/
- 
--
- #include "PreCompiled.h"
- #ifndef _PreComp_
- # include <Geom_OffsetCurve.hxx>
- #endif
- 
--#include "OCCError.h"
--#include "Geometry.h"
-+#include <Base/GeometryPyCXX.h>
-+#include <Base/Vector3D.h>
-+#include <Base/VectorPy.h>
-+
- #include "OffsetCurvePy.h"
- #include "OffsetCurvePy.cpp"
-+#include "Geometry.h"
-+#include "OCCError.h"
- 
--#include <Base/GeometryPyCXX.h>
--#include <Base/VectorPy.h>
--#include <Base/Vector3D.h>
- 
- using namespace Part;
- 
---- a/src/Mod/Part/App/OffsetSurfacePyImp.cpp
-+++ b/src/Mod/Part/App/OffsetSurfacePyImp.cpp
-@@ -20,20 +20,16 @@
-  *                                                                         *
-  ***************************************************************************/
- 
--
- #include "PreCompiled.h"
- #ifndef _PreComp_
- # include <Geom_OffsetSurface.hxx>
- # include <memory>
- #endif
- 
--#include <Base/VectorPy.h>
--#include <Base/Vector3D.h>
--
- #include "OCCError.h"
--#include "Geometry.h"
--#include <Mod/Part/App/OffsetSurfacePy.h>
--#include <Mod/Part/App/OffsetSurfacePy.cpp>
-+#include "OffsetSurfacePy.h"
-+#include "OffsetSurfacePy.cpp"
-+
- 
- using namespace Part;
- 
diff --git a/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch b/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
deleted file mode 100644
index d6a9adabdec830..00000000000000
--- a/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
+++ /dev/null
@@ -1,68 +0,0 @@
-see https://github.com/FreeCAD/FreeCAD/commit/cfe94b00d3434f3e2c8b5114d2909f628c330fa8#commitcomment-71413407
-
-upstream: yes
-
-From 7b377a216b9185960e4cee980a6504dc1a755f50 Mon Sep 17 00:00:00 2001
-From: wmayer <wmayer@users.sourceforge.net>
-Date: Wed, 29 Jun 2022 15:19:18 +0200
-Subject: [PATCH] Gui: remove workaround for spnav 0.23 due to build failure
- with musl libc
-
----
- src/Gui/3Dconnexion/GuiNativeEventLinux.cpp | 27 ---------------------
- 1 file changed, 27 deletions(-)
-
---- a/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp
-+++ b/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp
-@@ -21,42 +21,17 @@
-  ***************************************************************************/
- 
- #include <FCConfig.h>
--#include <cstdio>
- 
- #include "GuiNativeEventLinux.h"
- 
- #include "GuiApplicationNativeEventAware.h"
- #include <Base/Console.h>
--#include <Base/FileInfo.h>
- #include <QMainWindow>
- 
- #include <QSocketNotifier>
- 
- #include <spnav.h>
- 
--namespace {
--class RedirectStdErr
--{
--public:
--    RedirectStdErr()
--        : fi(Base::FileInfo::getTempFileName())
--        , file(stderr)
--    {
--        stderr = fopen(fi.filePath().c_str(), "w");
--    }
--    ~RedirectStdErr()
--    {
--        fclose(stderr);
--        fi.deleteFile();
--        stderr = file;
--    }
--
--private:
--    Base::FileInfo fi;
--    FILE* file;
--};
--}
--
- Gui::GuiNativeEvent::GuiNativeEvent(Gui::GUIApplicationNativeEventAware *app)
- : GuiAbstractNativeEvent(app)
- {
-@@ -72,8 +47,6 @@ Gui::GuiNativeEvent::~GuiNativeEvent()
- 
- void Gui::GuiNativeEvent::initSpaceball(QMainWindow *window)
- {
--    // tmp. redirect stderr to a file to suppress an error message from spnav_open()
--    RedirectStdErr err;
-     Q_UNUSED(window)
-     if (spnav_open() == -1) {
-         Base::Console().Log("Couldn't connect to spacenav daemon. Please ignore if you don't have a spacemouse.\n");
diff --git a/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch b/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch
deleted file mode 100644
index d4acf370ca0a42..00000000000000
--- a/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-From fe02d63c8c9b1280978be841d04e68a0a55cceb9 Mon Sep 17 00:00:00 2001
-From: Roy-043 <70520633+Roy-043@users.noreply.github.com>
-Date: Thu, 29 Dec 2022 23:20:38 +0100
-Subject: [PATCH] Draft: update inspect.getargspec to inspect.getfullargspec
- (#8101)
-
----
- src/Mod/Draft/draftguitools/gui_snapper.py | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
---- a/src/Mod/Draft/draftguitools/gui_snapper.py
-+++ b/src/Mod/Draft/draftguitools/gui_snapper.py
-@@ -1426,7 +1426,7 @@ class Snapper:
-             Gui.Snapper.off()
-             self.ui.offUi()
-             if callback:
--                if len(inspect.getargspec(callback).args) > 1:
-+                if len(inspect.getfullargspec(callback).args) > 1:
-                     obj = None
-                     if self.snapInfo and ("Object" in self.snapInfo) and self.snapInfo["Object"]:
-                         obj = App.ActiveDocument.getObject(self.snapInfo["Object"])
-@@ -1445,7 +1445,7 @@ class Snapper:
-             Gui.Snapper.off()
-             self.ui.offUi()
-             if callback:
--                if len(inspect.getargspec(callback).args) > 1:
-+                if len(inspect.getfullargspec(callback).args) > 1:
-                     callback(None, None)
-                 else:
-                     callback(None)
diff --git a/srcpkgs/freecad/template b/srcpkgs/freecad/template
index c135701e38b9ad..7d5165f760bab9 100644
--- a/srcpkgs/freecad/template
+++ b/srcpkgs/freecad/template
@@ -1,7 +1,7 @@
 # Template file for 'freecad'
 pkgname=freecad
-version=0.20.2
-revision=7
+version=0.21.1
+revision=2
 build_wrksrc="FreeCAD-${version}"
 build_style=cmake
 pycompile_dirs="usr/lib/${pkgname}/Mod"
@@ -24,8 +24,10 @@ makedepends="python3-devel boost-devel libxerces-c-devel zlib-devel occt-devel
  coin3-devel libshiboken2-devel libspnav-devel pyside2-tools
  liblz4-devel libpyside2-python3-devel python3-matplotlib netcdf-devel
  jsoncpp-devel qt5-devel qt5-svg-devel qt5-tools-devel qt5-webkit-devel
- qt5-xmlpatterns-devel coin3-doc glew-devel python3-pivy"
-depends="python3-matplotlib python3-pyside2-webengine python3-pivy"
+ qt5-xmlpatterns-devel coin3-doc glew-devel python3-pivy qt5-webengine-devel
+ qt5-declarative-devel qt5-webchannel-devel qt5-location-devel"
+depends="python3-matplotlib python3-pyside2-webengine python3-pivy
+ python3-GitPython python3-Markdown"
 short_desc="General purpose 3D CAD modeler"
 maintainer="yopito <pierre.bourgin@free.fr>"
 license="LGPL-2.0-or-later"
@@ -35,7 +37,7 @@ distfiles="
  https://github.com/FreeCAD/FreeCAD/archive/${version}.tar.gz
  ${SOURCEFORGE_SITE}/cxx/pycxx-${_pycxxver}.tar.gz
 "
-checksum="46922f3a477e742e1a89cd5346692d63aebb2b67af887b3e463e094a4ae055da
+checksum="e9b1fd0323f101268c7f3be52db42e4a29222f2e306ae6c4a6fc309cb418d35a
  4b91e1e1141c23fbd5039df635c4bb6e75632168548f56b83ce177193c0c98c6"
 python_version=3
 patch_args="-Np1 -d ${build_wrksrc}"

From 99cbee578ff4918bdc281af45d7211e12bedb9ab Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:47:18 -0400
Subject: [PATCH 087/109] libopenshot: revbump for ffmpeg6

---
 srcpkgs/libopenshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenshot/template b/srcpkgs/libopenshot/template
index 8e57c5f592169c..7a8f4520e78925 100644
--- a/srcpkgs/libopenshot/template
+++ b/srcpkgs/libopenshot/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenshot'
 pkgname=libopenshot
 version=0.3.0
-revision=3
+revision=4
 build_style=cmake
 # Builds fail with Ruby-2.4.1
 configure_args="-DENABLE_RUBY=OFF -DUSE_SYSTEM_JSONCPP=ON"

From c5a841ef148beafdb620ed4f7e7eb03ce76ff064 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:10:30 -0500
Subject: [PATCH 088/109] openimageio: revbump for ffmpeg6

---
 srcpkgs/openimageio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimageio/template b/srcpkgs/openimageio/template
index 27d2131bc0a61a..61f44b43f9083e 100644
--- a/srcpkgs/openimageio/template
+++ b/srcpkgs/openimageio/template
@@ -1,7 +1,7 @@
 # Template file for 'openimageio'
 pkgname=openimageio
 version=2.4.9.0
-revision=8
+revision=9
 build_style=cmake
 build_helper=qemu
 configure_args="-DUSE_QT=0 -DUSE_PYTHON=0 -DOIIO_BUILD_TESTS=0

From 0cd1a34685273f8ff04bbb3b0f91ffccd0b5a532 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:11:57 -0500
Subject: [PATCH 089/109] synfigstudio: revbump for ffmpeg6

---
 srcpkgs/synfigstudio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/synfigstudio/template b/srcpkgs/synfigstudio/template
index 09e442da9a6805..2bc017cedca6b8 100644
--- a/srcpkgs/synfigstudio/template
+++ b/srcpkgs/synfigstudio/template
@@ -2,7 +2,7 @@
 # Should be kept in sync with 'synfig' and 'ETL'
 pkgname=synfigstudio
 version=1.4.4
-revision=4
+revision=5
 build_style=gnu-configure
 configure_args="--disable-update-mimedb"
 hostmakedepends="pkg-config intltool gettext synfig"

From e0dd2f62b27c30ff50e3cf72943e598cd721375a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:10 -0500
Subject: [PATCH 090/109] mixxx: revbump for ffmpeg6

---
 srcpkgs/mixxx/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mixxx/template b/srcpkgs/mixxx/template
index 6a79b328c1abf0..9a5141856860b9 100644
--- a/srcpkgs/mixxx/template
+++ b/srcpkgs/mixxx/template
@@ -1,7 +1,7 @@
 # Template file for 'mixxx'
 pkgname=mixxx
 version=2.3.3
-revision=7
+revision=8
 build_style=cmake
 configure_args="-DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="extra-cmake-modules pkg-config protobuf qt5-host-tools qt5-qmake"

From 4cca9d6b4e2e80c0feb55920c00fc5c6905e1974 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:28 -0500
Subject: [PATCH 091/109] musikcube: revbump for ffmpeg6

---
 srcpkgs/musikcube/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/musikcube/template b/srcpkgs/musikcube/template
index 8c4a51840859ec..fb60dd2049089a 100644
--- a/srcpkgs/musikcube/template
+++ b/srcpkgs/musikcube/template
@@ -1,7 +1,7 @@
 # Template file for 'musikcube'
 pkgname=musikcube
 version=3.0.0
-revision=3
+revision=4
 build_style=cmake
 make_cmd=make
 configure_args="-DNO_NCURSESW=1"

From 992a396345252e1501736827a307113e7c9f6359 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:45 -0500
Subject: [PATCH 092/109] electron24: revbump for ffmpeg6

---
 srcpkgs/electron24/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron24/template b/srcpkgs/electron24/template
index 7b4e28812f483e..1ca93fde97a854 100644
--- a/srcpkgs/electron24/template
+++ b/srcpkgs/electron24/template
@@ -1,7 +1,7 @@
 # Template file for 'electron24'
 pkgname=electron24
 version=24.3.0
-revision=2
+revision=3
 _nodever=18.14.0
 _chromiumver=112.0.5615.165
 archs="x86_64* aarch64*"

From 2a7ac9e9a3abb6229910ddc83ecd8588c054ca6e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:00 -0500
Subject: [PATCH 093/109] electron19: revbump for ffmpeg6

---
 srcpkgs/electron19/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron19/template b/srcpkgs/electron19/template
index 0ef959125cb085..5371c0b354604f 100644
--- a/srcpkgs/electron19/template
+++ b/srcpkgs/electron19/template
@@ -1,7 +1,7 @@
 # Template file for 'electron19'
 pkgname=electron19
 version=19.0.8
-revision=4
+revision=5
 _nodever=16.14.2
 _chromiumver=102.0.5005.125
 archs="x86_64* aarch64* ppc64le*"

From f0661b2bfe8329ca4bdc1a254139f20401446c5b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:13 -0500
Subject: [PATCH 094/109] wf-recorder: revbump for ffmpeg6

---
 srcpkgs/wf-recorder/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/wf-recorder/template b/srcpkgs/wf-recorder/template
index 08f986b0310067..63c45cf4b814d7 100644
--- a/srcpkgs/wf-recorder/template
+++ b/srcpkgs/wf-recorder/template
@@ -1,7 +1,7 @@
 # Template file for 'wf-recorder'
 pkgname=wf-recorder
 version=0.4.1
-revision=2
+revision=3
 build_style=meson
 hostmakedepends="pkg-config scdoc wayland-devel"
 makedepends="wayland-protocols wayland-devel ffmpeg-devel libgbm-devel x264-devel

From e766c137a3a88fd3a1cce5de1b1bab04b5723b02 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:26 -0500
Subject: [PATCH 095/109] obs: revbump for ffmpeg6

---
 srcpkgs/obs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/obs/template b/srcpkgs/obs/template
index feb9649977a8d4..0888fb3aaaccfe 100644
--- a/srcpkgs/obs/template
+++ b/srcpkgs/obs/template
@@ -1,7 +1,7 @@
 # Template file for 'obs'
 pkgname=obs
 version=30.1.1
-revision=1
+revision=2
 archs="i686* x86_64* ppc64le* aarch64* riscv64*"
 build_style=cmake
 configure_args="-DOBS_VERSION_OVERRIDE=${version} -DENABLE_JACK=ON

From cddbb3b15df1b50e336bbcb4bad6593bd9c491c5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:36 -0500
Subject: [PATCH 096/109] mlt7: revbump for ffmpeg6

---
 srcpkgs/mlt7/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mlt7/template b/srcpkgs/mlt7/template
index 65eed998d39832..59f7ec147f0d04 100644
--- a/srcpkgs/mlt7/template
+++ b/srcpkgs/mlt7/template
@@ -1,7 +1,7 @@
 # Template file for 'mlt7'
 pkgname=mlt7
 version=7.20.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DSWIG_PYTHON=ON -DMOD_QT6=ON"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which

From 8de4046064cc95202752a686193c3b49f9427932 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:48 -0500
Subject: [PATCH 097/109] qt6-multimedia: revbump for ffmpeg6

---
 srcpkgs/qt6-multimedia/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-multimedia/template b/srcpkgs/qt6-multimedia/template
index 67a577e1300fea..1da626ecf515a8 100644
--- a/srcpkgs/qt6-multimedia/template
+++ b/srcpkgs/qt6-multimedia/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-multimedia'
 pkgname=qt6-multimedia
 version=6.6.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DQT_FEATURE_gstreamer=ON"
 hostmakedepends="perl qt6-declarative-host-tools pkg-config qt6-shadertools"

From 93256ff0f3ecae913a19fb48a626a0c479ade520 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:00:15 -0500
Subject: [PATCH 098/109] baresip: revbump for ffmpeg6

---
 srcpkgs/baresip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/baresip/template b/srcpkgs/baresip/template
index b16b67beab8d2b..fe21ebf40c03c1 100644
--- a/srcpkgs/baresip/template
+++ b/srcpkgs/baresip/template
@@ -1,7 +1,7 @@
 # Template file for 'baresip'
 pkgname=baresip
 version=3.6.0
-revision=3
+revision=4
 build_style=cmake
 hostmakedepends="pkg-config glib-devel"
 makedepends="libgsm-devel libpng-devel openssl-devel libsndfile-devel

From 1eb21f60afa6e369ab2216356c2e6088d8f35634 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:30 -0500
Subject: [PATCH 099/109] QMPlay2: revbump for ffmpeg6

---
 srcpkgs/QMPlay2/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/QMPlay2/template b/srcpkgs/QMPlay2/template
index efa9726614093c..10e5ac4ceebf80 100644
--- a/srcpkgs/QMPlay2/template
+++ b/srcpkgs/QMPlay2/template
@@ -1,7 +1,7 @@
 # Template file for 'QMPlay2'
 pkgname=QMPlay2
 version=24.03.16
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools"
 makedepends="alsa-lib-devel ffmpeg-devel libass-devel libcdio-devel libgme-devel

From e3820f32ab490aa8b1ac4b1d430d1dbac018829c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:34 -0500
Subject: [PATCH 100/109] alsa-plugins: revbump for ffmpeg6

---
 srcpkgs/alsa-plugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/alsa-plugins/template b/srcpkgs/alsa-plugins/template
index a5708a7d82a8f0..7bfdad046c4830 100644
--- a/srcpkgs/alsa-plugins/template
+++ b/srcpkgs/alsa-plugins/template
@@ -1,7 +1,7 @@
 # Template file for 'alsa-plugins'
 pkgname=alsa-plugins
 version=1.2.7.1
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--disable-maemo-plugin"
 hostmakedepends="pkg-config"

From 3b2809a21285ce147949d632b55541ef5db6b7e9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:43 -0500
Subject: [PATCH 101/109] minidlna: revbump for ffmpeg6

---
 srcpkgs/minidlna/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/minidlna/template b/srcpkgs/minidlna/template
index 5fa929f3a0c124..742991ecd04afc 100644
--- a/srcpkgs/minidlna/template
+++ b/srcpkgs/minidlna/template
@@ -1,7 +1,7 @@
 # Template file for 'minidlna'
 pkgname=minidlna
 version=1.3.3
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="
  --sbindir=/usr/bin

From 1852c0ffd9fada071690622f420ed383e168d809 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 17:57:47 -0500
Subject: [PATCH 102/109] mpv: revbump for ffmpeg6

---
 srcpkgs/mpv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpv/template b/srcpkgs/mpv/template
index 3d4349e27d8f62..bc40d6fcaa40d6 100644
--- a/srcpkgs/mpv/template
+++ b/srcpkgs/mpv/template
@@ -1,7 +1,7 @@
 # Template file for 'mpv'
 pkgname=mpv
 version=0.37.0
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcdda=enabled -Ddvbin=enabled -Ddvdnav=enabled
  -Dlibmpv=true -Dcplugins=enabled

From 0fbacead4a15700d1bbf0f69d52a55638d60a7f3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 17:59:29 -0500
Subject: [PATCH 103/109] qimgv: revbump for ffmpeg6

---
 srcpkgs/qimgv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qimgv/template b/srcpkgs/qimgv/template
index dd341dfe1bfce8..8a7e1c081ef12f 100644
--- a/srcpkgs/qimgv/template
+++ b/srcpkgs/qimgv/template
@@ -1,7 +1,7 @@
 # Template file for 'qimgv'
 pkgname=qimgv
 version=1.0.2
-revision=3
+revision=4
 build_style=cmake
 configure_args="$(vopt_if video -DVIDEO_SUPPORT=ON -DVIDEO_SUPPORT=OFF)
  $(vopt_if scale -DOPENCV_SUPPORT=ON -DOPENCV_SUPPORT=OFF)

From 68805c4fe321c282869978326acf12343a2df801 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 18:00:36 -0500
Subject: [PATCH 104/109] kfilemetadata5: revbump for ffmpeg6

---
 srcpkgs/kfilemetadata5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kfilemetadata5/template b/srcpkgs/kfilemetadata5/template
index a0c4d809395323..b584f85ff2058b 100644
--- a/srcpkgs/kfilemetadata5/template
+++ b/srcpkgs/kfilemetadata5/template
@@ -1,7 +1,7 @@
 # Template file for 'kfilemetadata5'
 pkgname=kfilemetadata5
 version=5.115.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="kcoreaddons extra-cmake-modules pkg-config qt5-host-tools qt5-qmake
  gettext kcoreaddons python3"

From 836b1a1b9312596b18c5bc412fae9f81b70df5ba Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 8 Dec 2023 11:46:01 -0500
Subject: [PATCH 105/109] vba-m: revbump for ffmpeg6

---
 srcpkgs/vba-m/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vba-m/template b/srcpkgs/vba-m/template
index 3d135efa1d0b69..3c5a20db0fa984 100644
--- a/srcpkgs/vba-m/template
+++ b/srcpkgs/vba-m/template
@@ -2,7 +2,7 @@
 pkgname=vba-m
 reverts=1292_2
 version=2.1.9
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_GTK=TRUE -DENABLE_FFMPEG=TRUE -DENABLE_LINK=TRUE -DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="gettext pkg-config unzip zip yasm wxWidgets-gtk3-devel"

From 3f6bad5723ac9741198d0fdba81941ca18a4a2fb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 8 Dec 2023 11:46:19 -0500
Subject: [PATCH 106/109] dolphin-emu: revbump for ffmpeg6

---
 srcpkgs/dolphin-emu/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/dolphin-emu/template b/srcpkgs/dolphin-emu/template
index 862d3ae964eec4..a7ae0efb58fb75 100644
--- a/srcpkgs/dolphin-emu/template
+++ b/srcpkgs/dolphin-emu/template
@@ -1,7 +1,7 @@
 # Template file for 'dolphin-emu'
 pkgname=dolphin-emu
 version=5.0.19368
-revision=3
+revision=4
 _dolphin_commit=dadbeb4bae7e7fa23af2b46e0add4143094dc107
 _mgba_commit=44e074a15e9651481f7f652ac006a7c9d58cbeb9
 _googletest_commit=be03d00f5f0cc3a997d1a368bee8a1fe93651f48

From 6b044da3899eef06ce54553c9cff72826fef8389 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 19 Dec 2023 15:38:51 -0500
Subject: [PATCH 107/109] qtox: revbump for ffmpeg4

---
 srcpkgs/qtox/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtox/template b/srcpkgs/qtox/template
index bb70e7f51240a4..755e4462bc0137 100644
--- a/srcpkgs/qtox/template
+++ b/srcpkgs/qtox/template
@@ -1,13 +1,13 @@
 # Template file for 'qtox'
 pkgname=qtox
 version=1.17.6
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DUPDATE_CHECK=OFF
  -DGIT_DESCRIBE=${version}
  $(vopt_if snorenotify -DDESKTOP_NOTIFICATIONS=ON)"
 hostmakedepends="pkg-config qt5-host-tools qt5-devel"
-makedepends="ffmpeg-devel libexif-devel libopenal-devel libsodium-devel
+makedepends="ffmpeg4-devel libexif-devel libopenal-devel libsodium-devel
  libvpx-devel opus-devel qrencode-devel qt5-svg-devel sonnet-devel
  sqlcipher-devel toxcore-devel
  $(vopt_if snorenotify snorenotify-devel)"

From 99110a0165a9b31dbcb73716c0d5487a976ddc20 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 11 Jan 2024 11:52:00 -0500
Subject: [PATCH 108/109] arcan: revbump for ffmpeg6

---
 srcpkgs/arcan/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/arcan/template b/srcpkgs/arcan/template
index ff9091f90ebb10..030091a6cc9d0c 100644
--- a/srcpkgs/arcan/template
+++ b/srcpkgs/arcan/template
@@ -2,7 +2,7 @@
 # !! keep synced with: acfgfs aclip aloadimage
 pkgname=arcan
 version=0.6.2.1
-revision=2
+revision=3
 create_wrksrc=yes
 build_wrksrc=arcan/src
 build_style=cmake

From 12e92561e7faf5328c29e464242ae89a14a53a27 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 11 Jan 2024 11:52:10 -0500
Subject: [PATCH 109/109] notcurses: revbump for ffmpeg6

---
 srcpkgs/notcurses/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/notcurses/template b/srcpkgs/notcurses/template
index 48a7463cb68eb9..515f316ab4576c 100644
--- a/srcpkgs/notcurses/template
+++ b/srcpkgs/notcurses/template
@@ -1,7 +1,7 @@
 # Template file for 'notcurses'
 pkgname=notcurses
 version=3.0.9
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DUSE_STATIC=ON -DUSE_QRCODEGEN=On $(vopt_bool man USE_PANDOC)"
 hostmakedepends="pkg-config $(vopt_if man pandoc)"

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (95 preceding siblings ...)
  2024-03-28 17:21 ` zlice
@ 2024-04-13 14:47 ` zlice
  2024-04-26 12:45 ` zlice
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2024-04-13 14:47 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 5117 bytes --]

There is an updated pull request by zlice against master on the void-packages repository

https://github.com/zlice/void-packages ffmpeg6-split
https://github.com/void-linux/void-packages/pull/43761

ffmpeg6 split
[ci skip]


#### Testing the changes

- I tested the changes in this PR: **YES**

main testing has been vaapi in Firefox Nightly and enc/dec in Shotcut on Intel A770

#### New package

- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**

#### Local build testing

- I built this PR locally for my native architecture, **x86_64**

#### Discussion

Continuation of https://github.com/void-linux/void-packages/pull/36315

`libavresample` is deprecated, but marked as a dependency when trying to build other packages and install `ffmpeg`(6). I think the right way to handle this is make a meta package and the add to removals?


##### Commit naming / misc

~~Commits are 'dirty' right now, running with [gstreamer 1.22.1 updates](https://github.com/void-linux/void-packages/pull/42861) and [Intel OpenCL](https://github.com/void-linux/void-packages/pull/43084). This will also make [intel packages pr](https://github.com/void-linux/void-packages/pull/41132) obsolete.~~ (see Requirements below)

Maintainer for previous ffmpeg(4) was orphaned, I can put my name in there if that matters, though I don't exactly see myself keeping up on ffmpeg.

~~This updates QT5 which looks like it is usually hosted by Johnny. Not sure if there's any reason to stay there or these sources are fine.~~ Using qt5.15.11 now, revbumps and some patches.

##### STILL FFMPEG4

These are a mix of emulators, games and/or older packages.

- ~~attract~~ (2.7 builds)
- ~~audacity (https://github.com/audacity/audacity/issues/2305 and https://sourceforge.net/p/portmedia/wiki/portsmf/ is 'beta')~~ (updated to 3.x, compiles with ffmpeg6)
- ~~ccextractor~~ (master patches)
- ~~vice (3.8 compiles, needs makedepends libcurl-devel)~~ ty yosh
- kodi
- mlt (only dep left is flowblade - flowblade 2.12.0.2 with mlt7-python3 can 'render' videos with cpu and gpu - https://github.com/void-linux/void-packages/pull/47195)
- ~~synfig (mlt)~~ (work with mlt7, bump synfigstudio)
- tvheadend (download page recommends using 4.3 which compiles fine, 4.4 eta is Q1 2024)
- ~~ssr~~ (patches)
- ~~spek-alternative~~ (replace with spek-x)
- ~~ppsspp~~ ~~(1.17.1 is out, but there's 5+ distfiles that are all git commits)~~ (minor patch)
- olive (has been in alpha since 2020, seems they do nightly builds and appimages)
- moc
- mediastreamer (linphone links are dead, changed to github belladonne. their stuff never worked for me but there are updates if someone wants to give it a try)
- ~~libextractor (1.13 compiles, remove exiv2 patch)~~ (as yosh pointed out, 1.13 just removes ffmpeg bits)
- idjc (0.9.8 compiles, remove python3.10 patch, needs makedepends libebur128-devel and libshout-idjc 2.4.6 with '-r1' for distfile)
- hedgewars
- ~~ffmpegthumbnailer~~ (patches for moviedecoder.xxx files)
- ~~ffmpegthumbs~~ (latest compiles)
- deadbeef (1.9.6 may work but requires libdispatch from apple)
- ~~omxplayer~~ (package removed, deprecated in favor of vlc)
- qtav (fork has ffmpeg 5 patch - https://github.com/cmguo/QtAV)
- `vlc` (vlc4 will support ffmpeg5, there's a patch to build 3.x with ffmpeg5 but it will lack vaapi)
- `osg` (OpenSceneGraph plus `xine-lib`) (patches from osg issue build with ffmpeg6, [ffmpeg5.patch.txt](https://github.com/void-linux/void-packages/files/14743246/ffmpeg5.patch.txt))



##### HAVE NOT BUILT YET

- ~~omxplayer (rpi only? ffmpeg4)~~ (removed)
- kodi (big, but ffmpeg4)


##### UPDATED (for ffmpeg6)

- ~~blender: update to 3.5.1~~ ~~will be revbump with~~ https://github.com/void-linux/void-packages/pull/43992
- unpaper: update to 7.0.0.
- guvcview: update to 2.0.8.
- ~~qt5: update to 5.15.8~~ updated by another PR to 5.15.11
- ~~qt5-webengine: update to 5.18.15~~ updated by another PR to 5.15.16 (some patching for ffmpeg build)
- ~~shiboken2: revbump for qt5.15.8 (patch)~~ updated by another PR to 5.15.10
- ~~python3-pyside2: update to 5.15.8 (patch)~~ updated by another PR to 5.15.10
- New package: spex-x replaces spek-alternative for ffmpeg-6.0


##### Requirements

- ~~[gstreamer 1.22.2](https://github.com/void-linux/void-packages/pull/42861)~~ - a few packages use ffmpeg-devel and require a revbump

- ~~[Intel Packages](https://github.com/void-linux/void-packages/pull/41132) [Intel Packages v2](https://github.com/void-linux/void-packages/pull/47330) - ffmpeg4 uses different libraries than 6 (libmfx / Intel-MediaSDK vs only oneVPL that Intel is moving to), both are included here~~. Using replacement oneVPL from OBS update.

- ~~[shotcut 23.05.14](https://github.com/void-linux/void-packages/pull/44260)~~

- https://github.com/void-linux/void-packages/pull/44781 will remove from this PR

A patch file from https://github.com/void-linux/void-packages/pull/43761.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ffmpeg6-split-43761.patch --]
[-- Type: text/x-diff, Size: 240264 bytes --]

From 9fc7f671ccefc8ff7dce50902d03e1a18bd1c035 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:16:56 -0400
Subject: [PATCH 001/108] ffmpeg: update to 6.0.1.

---
 common/shlibs                                 | 26 ++++---
 srcpkgs/ffmpeg/files/altivec.patch            | 60 ---------------
 .../patches/armv5tel-floating-point.patch     | 18 -----
 srcpkgs/ffmpeg/patches/binutils-2.41.patch    | 73 -------------------
 ...h-libavcodec-libsvtav1-ten_bit_format.diff | 40 ----------
 .../workaround-mesa-readeon-vaapi-bug.patch   | 28 -------
 srcpkgs/ffmpeg/template                       | 40 +++++-----
 7 files changed, 37 insertions(+), 248 deletions(-)
 delete mode 100644 srcpkgs/ffmpeg/files/altivec.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/binutils-2.41.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 delete mode 100644 srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch

diff --git a/common/shlibs b/common/shlibs
index 12238cd813cede..7ed9310ad0a8c2 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -389,15 +389,23 @@ libid3tag.so.0 libid3tag-0.15.1b_1
 libgif.so.7 giflib-5.1.0_1
 libImlib2.so.1 imlib2-1.4.2_1
 libmp3lame.so.0 lame-3.98.2_1
-libavdevice.so.58 libavdevice-4.0_1
-libavformat.so.58 libavformat-4.0_1
-libswscale.so.5 libswscale-4.0_1
-libswresample.so.3 libswresample-4.0_1
-libavresample.so.4 libavresample-4.0_1
-libpostproc.so.55 libpostproc-4.0_1
-libavcodec.so.58 libavcodec-4.0_1
-libavutil.so.56 libavutil-4.0_1
-libavfilter.so.7 libavfilter-4.0_1
+libavdevice.so.60 libavdevice-6.0_1
+libavformat.so.60 libavformat-6.0_1
+libswscale.so.7 libswscale-6.0_1
+libswresample.so.4 libswresample-6.0_1
+libpostproc.so.57 libpostproc-6.0_1
+libavcodec.so.60 libavcodec-6.0_1
+libavutil.so.58 libavutil-6.0_1
+libavfilter.so.9 libavfilter-6.0_1
+libavdevice.so.58 libavdevice4-4.0_1
+libavformat.so.58 libavformat4-4.0_1
+libswscale.so.5 libswscale4-4.0_1
+libswresample.so.3 libswresample4-4.0_1
+libavresample.so.4 libavresample4-4.0_1
+libpostproc.so.55 libpostproc4-4.0_1
+libavcodec.so.58 libavcodec4-4.0_1
+libavutil.so.56 libavutil4-4.0_1
+libavfilter.so.7 libavfilter4-4.0_1
 libSDL-1.2.so.0 SDL-1.2.14_1
 libSDL_image-1.2.so.0 SDL_image-1.2.10_1
 libx264.so.157 x264-20190507.2245_1
diff --git a/srcpkgs/ffmpeg/files/altivec.patch b/srcpkgs/ffmpeg/files/altivec.patch
deleted file mode 100644
index 9c57200463320e..00000000000000
--- a/srcpkgs/ffmpeg/files/altivec.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-revert some altivec specific change on all ppc* except ppc64le*
-
-q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
-conditionally, for ppc* but not ppc64le* (the new code is valid for
-POWER8 VSX which LE targets as a baseline but not BE)"
-
-
-This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
----
- libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
- 1 file changed, 20 insertions(+), 4 deletions(-)
-
-diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
-index 536545293d..c1e2852adb 100644
---- a/libswscale/ppc/yuv2rgb_altivec.c
-+++ b/libswscale/ppc/yuv2rgb_altivec.c
-@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-     vector signed short R1, G1, B1;                                           \
-     vector unsigned char R, G, B;                                             \
-                                                                               \
-+    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
-+    vector unsigned char align_perm;                                          \
-+                                                                              \
-     vector signed short lCY       = c->CY;                                    \
-     vector signed short lOY       = c->OY;                                    \
-     vector signed short lCRV      = c->CRV;                                   \
-@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
-                                                                               \
-         for (j = 0; j < w / 16; j++) {                                        \
--            y0 = vec_xl(0, y1i);                                              \
-+            y1ivP = (const vector unsigned char *) y1i;                       \
-+            y2ivP = (const vector unsigned char *) y2i;                       \
-+            uivP  = (const vector unsigned char *) ui;                        \
-+            vivP  = (const vector unsigned char *) vi;                        \
-+                                                                              \
-+            align_perm = vec_lvsl(0, y1i);                                    \
-+            y0 = (vector unsigned char)                                       \
-+                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
-                                                                               \
--            y1 = vec_xl(0, y2i);                                              \
-+            align_perm = vec_lvsl(0, y2i);                                    \
-+            y1 = (vector unsigned char)                                       \
-+                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
-                                                                               \
--            u = (vector signed char) vec_xl(0, ui);                           \
-+            align_perm = vec_lvsl(0, ui);                                     \
-+            u = (vector signed char)                                          \
-+                    vec_perm(uivP[0], uivP[1], align_perm);                   \
-                                                                               \
--            v = (vector signed char) vec_xl(0, vi);                           \
-+            align_perm = vec_lvsl(0, vi);                                     \
-+            v = (vector signed char)                                          \
-+                    vec_perm(vivP[0], vivP[1], align_perm);                   \
-                                                                               \
-             u = (vector signed char)                                          \
-                     vec_sub(u,                                                \
--- 
-2.27.0
-
diff --git a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
deleted file mode 100644
index 9a55178c74f0fd..00000000000000
--- a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
-+++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
-@@ -39,6 +39,15 @@
- #endif
- #include <fenv.h>
- 
-+#if (FE_ALL_EXCEPT == 0)
-+/* E.g. ARM soft float does not define these */
-+#define FE_INVALID    0
-+#define FE_DIVBYZERO  0
-+#define FE_OVERFLOW   0
-+#define FE_UNDERFLOW  0
-+#define FE_INEXACT    0
-+#endif
-+
- #if CONFIG_LIBFONTCONFIG
- #include <fontconfig/fontconfig.h>
- #endif
diff --git a/srcpkgs/ffmpeg/patches/binutils-2.41.patch b/srcpkgs/ffmpeg/patches/binutils-2.41.patch
deleted file mode 100644
index 53a596d0ee7d4e..00000000000000
--- a/srcpkgs/ffmpeg/patches/binutils-2.41.patch
+++ /dev/null
@@ -1,73 +0,0 @@
-From effadce6c756247ea8bae32dc13bb3e6f464f0eb Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= <remi@remlab.net>
-Date: Sun, 16 Jul 2023 18:18:02 +0300
-Subject: [PATCH] avcodec/x86/mathops: clip constants used with shift
- instructions within inline assembly
-
-Fixes assembling with binutil as >= 2.41
-
-Signed-off-by: James Almer <jamrial@gmail.com>
----
- libavcodec/x86/mathops.h | 26 +++++++++++++++++++++++---
- 1 file changed, 23 insertions(+), 3 deletions(-)
-
-diff --git a/libavcodec/x86/mathops.h b/libavcodec/x86/mathops.h
-index 6298f5ed1983b..ca7e2dffc1076 100644
---- a/libavcodec/x86/mathops.h
-+++ b/libavcodec/x86/mathops.h
-@@ -35,12 +35,20 @@
- static av_always_inline av_const int MULL(int a, int b, unsigned shift)
- {
-     int rt, dummy;
-+    if (__builtin_constant_p(shift))
-     __asm__ (
-         "imull %3               \n\t"
-         "shrdl %4, %%edx, %%eax \n\t"
-         :"=a"(rt), "=d"(dummy)
--        :"a"(a), "rm"(b), "ci"((uint8_t)shift)
-+        :"a"(a), "rm"(b), "i"(shift & 0x1F)
-     );
-+    else
-+        __asm__ (
-+            "imull %3               \n\t"
-+            "shrdl %4, %%edx, %%eax \n\t"
-+            :"=a"(rt), "=d"(dummy)
-+            :"a"(a), "rm"(b), "c"((uint8_t)shift)
-+        );
-     return rt;
- }
- 
-@@ -113,19 +121,31 @@ __asm__ volatile(\
- // avoid +32 for shift optimization (gcc should do that ...)
- #define NEG_SSR32 NEG_SSR32
- static inline  int32_t NEG_SSR32( int32_t a, int8_t s){
-+    if (__builtin_constant_p(s))
-     __asm__ ("sarl %1, %0\n\t"
-          : "+r" (a)
--         : "ic" ((uint8_t)(-s))
-+         : "i" (-s & 0x1F)
-     );
-+    else
-+        __asm__ ("sarl %1, %0\n\t"
-+               : "+r" (a)
-+               : "c" ((uint8_t)(-s))
-+        );
-     return a;
- }
- 
- #define NEG_USR32 NEG_USR32
- static inline uint32_t NEG_USR32(uint32_t a, int8_t s){
-+    if (__builtin_constant_p(s))
-     __asm__ ("shrl %1, %0\n\t"
-          : "+r" (a)
--         : "ic" ((uint8_t)(-s))
-+         : "i" (-s & 0x1F)
-     );
-+    else
-+        __asm__ ("shrl %1, %0\n\t"
-+               : "+r" (a)
-+               : "c" ((uint8_t)(-s))
-+        );
-     return a;
- }
- 
diff --git a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
deleted file mode 100644
index aa948f7a8a2dfb..00000000000000
--- a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
+++ /dev/null
@@ -1,40 +0,0 @@
-#==================================================================================================
-# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
-# From: Christopher Degawa <christopher.degawa@intel.com>
-# Date: Thu, 20 Oct 2022 22:55:27 -0500
-# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
-#
-# compressed_ten_bit_format has been deprecated upstream and has no effect
-# and can be removed. Plus, technically it was never used in the first place
-# since it would require the app (ffmpeg) to set it and do additional
-# processing of the input frames.
-#
-# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
-#
-# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
-#==================================================================================================
---- a/libavcodec/libsvtav1.c
-+++ b/libavcodec/libsvtav1.c
-@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
- 
- static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
- {
--    const int    pack_mode_10bit =
--        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
--    const size_t luma_size_8bit  =
--        config->source_width * config->source_height * (1 << pack_mode_10bit);
--    const size_t luma_size_10bit =
--        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
-+    const size_t luma_size = config->source_width * config->source_height *
-+        (config->encoder_bit_depth > 8 ? 2 : 1);
- 
-     EbSvtIOFormat *in_data;
- 
--    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
-+    svt_enc->raw_size = luma_size * 3 / 2;
- 
-     // allocate buffer for in and out
-     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
--- 
-GitLab
-
diff --git a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
deleted file mode 100644
index 00e3f68a415b84..00000000000000
--- a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
-From: Rainer Hochecker <fernetmenta@online.de>
-Date: Sat, 26 Jan 2019 19:48:35 +0100
-Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
-
-This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
-It was hit frequently when watching h264 channels received via DVB-X.
-Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
----
- libavcodec/vaapi_h264.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
-index 5854587a255..f12fdc457a4 100644
---- a/libavcodec/vaapi_h264.c
-+++ b/libavcodec/vaapi_h264.c
-@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
-     H264SliceContext *sl = &h->slice_ctx[0];
-     int ret;
- 
-+    if (pic->nb_slices == 0) {
-+        ret = AVERROR_INVALIDDATA;
-+        goto finish;
-+    }
-+
-     ret = ff_vaapi_decode_issue(avctx, pic);
-     if (ret < 0)
-         goto finish;
diff --git a/srcpkgs/ffmpeg/template b/srcpkgs/ffmpeg/template
index 1ebb436135938d..f1e4712c41d087 100644
--- a/srcpkgs/ffmpeg/template
+++ b/srcpkgs/ffmpeg/template
@@ -1,15 +1,15 @@
 # Template file for 'ffmpeg'
 # audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
 pkgname=ffmpeg
-version=4.4.4
-revision=6
+version=6.0.1
+revision=1
 short_desc="Decoding, encoding and streaming software"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="https://www.ffmpeg.org"
 changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
 distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
-checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+checksum=9b16b8731d78e596b4be0d720428ca42df642bb2d78342881ff7f5bc29fc9623
 
 hostmakedepends="pkg-config perl"
 makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
@@ -26,12 +26,13 @@ makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-deve
  $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
  $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
  $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
- $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers Vulkan-Tools Vulkan-ValidationLayers')
+ $(vopt_if onevpl 'oneVPL oneVPL-devel')
  $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
 depends="ffplay>=${version}_${revision}"
 
 build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
- dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec onevpl"
 build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
 desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
 desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
@@ -39,9 +40,13 @@ desc_option_sofa="Enable support for AES SOFA"
 desc_option_webp="Enable support for WebP"
 
 case "$XBPS_TARGET_MACHINE" in
-	i686*|x86_64*)
-		hostmakedepends+=" nasm"
+	i686*)
 		build_options_default+=" vaapi vdpau nvenc nvdec"
+		hostmakedepends+=" nasm"
+		;;
+	x86_64*)
+		hostmakedepends+=" nasm"
+		build_options_default+=" vaapi vdpau nvenc nvdec onevpl"
 		;;
 	ppc64*) build_options_default+=" vaapi vdpau";;
 	mips*) CFLAGS="-mnan=legacy";;
@@ -65,8 +70,6 @@ post_patch() {
 		ppc64le*) ;;
 		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
 	esac
-
-	vsed -i libavfilter/vf_libvmaf.c -e 's!/usr/local/share/model/\(vmaf_v0.6.1\).pkl!/usr/share/vmaf/\1.json!'
 }
 
 do_configure() {
@@ -115,18 +118,19 @@ do_configure() {
 		$(vopt_enable x265 libx265) \
 		$(vopt_enable v4l2 libv4l2) \
 		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
-		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		--enable-libbs2b --enable-libvidstab \
 		$(vopt_enable dav1d libdav1d) \
 		$(vopt_enable zimg libzimg) \
 		$(vopt_enable webp libwebp) \
 		$(vopt_enable sofa libmysofa) \
 		$(vopt_enable vulkan) \
+		$(vopt_enable onevpl libvpl) \
 		$(vopt_enable drm libdrm) \
 		$(vopt_enable svtav1 libsvtav1) \
 		$(vopt_enable srt libsrt) \
 		$(vopt_enable rist librist) \
-		$(vopt_if nvenc '--enable-nvenc') \
-		$(vopt_if nvdec '--enable-nvdec')
+		$(vopt_enable nvenc nvenc) \
+		$(vopt_enable nvdec nvdec)
 }
 
 do_build() {
@@ -153,10 +157,8 @@ libavdevice_package() {
 }
 
 libavresample_package() {
-	short_desc="FFmpeg audio resampling library"
-	pkg_install() {
-		vmove "usr/lib/libavresample.so.*"
-	}
+	short_desc="Package deprecated, removal needed"
+	build_style=meta
 }
 
 libavformat_package() {
@@ -210,15 +212,13 @@ ffmpeg-devel_package() {
 		libavfilter>=${version}_${revision}
 		libpostproc>=${version}_${revision}
 		libswscale>=${version}_${revision}
-		libswresample>=${version}_${revision}
-		libavresample>=${version}_${revision}"
+		libswresample>=${version}_${revision}"
 	short_desc+=" - development files"
-
+	conflicts="ffmpeg4-devel"
 	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
 		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
 		nostrip_files="/usr/lib/libavfilter.a"
 	fi
-
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig

From e01e54ba573911f8be66395c068aa936fcd27f26 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:14 -0400
Subject: [PATCH 002/108] openshot: revbump for ffmpeg6

---
 srcpkgs/openshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openshot/template b/srcpkgs/openshot/template
index 3849858fe963b5..12789bc9867499 100644
--- a/srcpkgs/openshot/template
+++ b/srcpkgs/openshot/template
@@ -1,7 +1,7 @@
 # Template file for 'openshot'
 pkgname=openshot
 version=3.1.1
-revision=1
+revision=2
 build_style=python3-module
 hostmakedepends="python3 python3-setuptools"
 makedepends="ffmpeg-devel python3-PyQt5"

From d2deeb27be11f8358a6dbe9979958da7fc4baa8c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:36 -0400
Subject: [PATCH 003/108] sumo: revbump for ffmpeg6

---
 srcpkgs/sumo/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/sumo/template b/srcpkgs/sumo/template
index a730afa9fafa92..e2def06fa4bd7d 100644
--- a/srcpkgs/sumo/template
+++ b/srcpkgs/sumo/template
@@ -1,7 +1,7 @@
 # Template file for 'sumo'
 pkgname=sumo
 version=1.12.0
-revision=7
+revision=8
 build_style=cmake
 hostmakedepends="libgdal-tools pkg-config swig python3-setuptools"
 makedepends="python3-devel ffmpeg-devel fox-devel gl2ps-devel libgdal-devel

From 87601eeb1c0420ebacc197a2f72e447437fe0261 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:56:22 -0400
Subject: [PATCH 004/108] New package: ffmpeg4-4.4.4.

---
 srcpkgs/ffmpeg4-devel                         |   1 +
 srcpkgs/ffmpeg4/files/altivec.patch           |  60 +++++
 .../patches/armv5tel-floating-point.patch     |  18 ++
 srcpkgs/ffmpeg4/patches/binutils-2.41.patch   |  73 ++++++
 ...h-libavcodec-libsvtav1-ten_bit_format.diff |  40 +++
 .../workaround-mesa-readeon-vaapi-bug.patch   |  28 +++
 srcpkgs/ffmpeg4/template                      | 234 ++++++++++++++++++
 srcpkgs/libavcodec4                           |   1 +
 srcpkgs/libavdevice4                          |   1 +
 srcpkgs/libavfilter4                          |   1 +
 srcpkgs/libavformat4                          |   1 +
 srcpkgs/libavresample4                        |   1 +
 srcpkgs/libavutil4                            |   1 +
 srcpkgs/libpostproc4                          |   1 +
 srcpkgs/libswresample4                        |   1 +
 srcpkgs/libswscale4                           |   1 +
 16 files changed, 463 insertions(+)
 create mode 120000 srcpkgs/ffmpeg4-devel
 create mode 100644 srcpkgs/ffmpeg4/files/altivec.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/binutils-2.41.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 create mode 100644 srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
 create mode 100644 srcpkgs/ffmpeg4/template
 create mode 120000 srcpkgs/libavcodec4
 create mode 120000 srcpkgs/libavdevice4
 create mode 120000 srcpkgs/libavfilter4
 create mode 120000 srcpkgs/libavformat4
 create mode 120000 srcpkgs/libavresample4
 create mode 120000 srcpkgs/libavutil4
 create mode 120000 srcpkgs/libpostproc4
 create mode 120000 srcpkgs/libswresample4
 create mode 120000 srcpkgs/libswscale4

diff --git a/srcpkgs/ffmpeg4-devel b/srcpkgs/ffmpeg4-devel
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/ffmpeg4-devel
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/ffmpeg4/files/altivec.patch b/srcpkgs/ffmpeg4/files/altivec.patch
new file mode 100644
index 00000000000000..9c57200463320e
--- /dev/null
+++ b/srcpkgs/ffmpeg4/files/altivec.patch
@@ -0,0 +1,60 @@
+revert some altivec specific change on all ppc* except ppc64le*
+
+q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
+conditionally, for ppc* but not ppc64le* (the new code is valid for
+POWER8 VSX which LE targets as a baseline but not BE)"
+
+
+This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
+---
+ libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
+ 1 file changed, 20 insertions(+), 4 deletions(-)
+
+diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
+index 536545293d..c1e2852adb 100644
+--- a/libswscale/ppc/yuv2rgb_altivec.c
++++ b/libswscale/ppc/yuv2rgb_altivec.c
+@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+     vector signed short R1, G1, B1;                                           \
+     vector unsigned char R, G, B;                                             \
+                                                                               \
++    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
++    vector unsigned char align_perm;                                          \
++                                                                              \
+     vector signed short lCY       = c->CY;                                    \
+     vector signed short lOY       = c->OY;                                    \
+     vector signed short lCRV      = c->CRV;                                   \
+@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
+                                                                               \
+         for (j = 0; j < w / 16; j++) {                                        \
+-            y0 = vec_xl(0, y1i);                                              \
++            y1ivP = (const vector unsigned char *) y1i;                       \
++            y2ivP = (const vector unsigned char *) y2i;                       \
++            uivP  = (const vector unsigned char *) ui;                        \
++            vivP  = (const vector unsigned char *) vi;                        \
++                                                                              \
++            align_perm = vec_lvsl(0, y1i);                                    \
++            y0 = (vector unsigned char)                                       \
++                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
+                                                                               \
+-            y1 = vec_xl(0, y2i);                                              \
++            align_perm = vec_lvsl(0, y2i);                                    \
++            y1 = (vector unsigned char)                                       \
++                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
+                                                                               \
+-            u = (vector signed char) vec_xl(0, ui);                           \
++            align_perm = vec_lvsl(0, ui);                                     \
++            u = (vector signed char)                                          \
++                    vec_perm(uivP[0], uivP[1], align_perm);                   \
+                                                                               \
+-            v = (vector signed char) vec_xl(0, vi);                           \
++            align_perm = vec_lvsl(0, vi);                                     \
++            v = (vector signed char)                                          \
++                    vec_perm(vivP[0], vivP[1], align_perm);                   \
+                                                                               \
+             u = (vector signed char)                                          \
+                     vec_sub(u,                                                \
+-- 
+2.27.0
+
diff --git a/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
new file mode 100644
index 00000000000000..9a55178c74f0fd
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
@@ -0,0 +1,18 @@
+--- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
++++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
+@@ -39,6 +39,15 @@
+ #endif
+ #include <fenv.h>
+ 
++#if (FE_ALL_EXCEPT == 0)
++/* E.g. ARM soft float does not define these */
++#define FE_INVALID    0
++#define FE_DIVBYZERO  0
++#define FE_OVERFLOW   0
++#define FE_UNDERFLOW  0
++#define FE_INEXACT    0
++#endif
++
+ #if CONFIG_LIBFONTCONFIG
+ #include <fontconfig/fontconfig.h>
+ #endif
diff --git a/srcpkgs/ffmpeg4/patches/binutils-2.41.patch b/srcpkgs/ffmpeg4/patches/binutils-2.41.patch
new file mode 100644
index 00000000000000..53a596d0ee7d4e
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/binutils-2.41.patch
@@ -0,0 +1,73 @@
+From effadce6c756247ea8bae32dc13bb3e6f464f0eb Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= <remi@remlab.net>
+Date: Sun, 16 Jul 2023 18:18:02 +0300
+Subject: [PATCH] avcodec/x86/mathops: clip constants used with shift
+ instructions within inline assembly
+
+Fixes assembling with binutil as >= 2.41
+
+Signed-off-by: James Almer <jamrial@gmail.com>
+---
+ libavcodec/x86/mathops.h | 26 +++++++++++++++++++++++---
+ 1 file changed, 23 insertions(+), 3 deletions(-)
+
+diff --git a/libavcodec/x86/mathops.h b/libavcodec/x86/mathops.h
+index 6298f5ed1983b..ca7e2dffc1076 100644
+--- a/libavcodec/x86/mathops.h
++++ b/libavcodec/x86/mathops.h
+@@ -35,12 +35,20 @@
+ static av_always_inline av_const int MULL(int a, int b, unsigned shift)
+ {
+     int rt, dummy;
++    if (__builtin_constant_p(shift))
+     __asm__ (
+         "imull %3               \n\t"
+         "shrdl %4, %%edx, %%eax \n\t"
+         :"=a"(rt), "=d"(dummy)
+-        :"a"(a), "rm"(b), "ci"((uint8_t)shift)
++        :"a"(a), "rm"(b), "i"(shift & 0x1F)
+     );
++    else
++        __asm__ (
++            "imull %3               \n\t"
++            "shrdl %4, %%edx, %%eax \n\t"
++            :"=a"(rt), "=d"(dummy)
++            :"a"(a), "rm"(b), "c"((uint8_t)shift)
++        );
+     return rt;
+ }
+ 
+@@ -113,19 +121,31 @@ __asm__ volatile(\
+ // avoid +32 for shift optimization (gcc should do that ...)
+ #define NEG_SSR32 NEG_SSR32
+ static inline  int32_t NEG_SSR32( int32_t a, int8_t s){
++    if (__builtin_constant_p(s))
+     __asm__ ("sarl %1, %0\n\t"
+          : "+r" (a)
+-         : "ic" ((uint8_t)(-s))
++         : "i" (-s & 0x1F)
+     );
++    else
++        __asm__ ("sarl %1, %0\n\t"
++               : "+r" (a)
++               : "c" ((uint8_t)(-s))
++        );
+     return a;
+ }
+ 
+ #define NEG_USR32 NEG_USR32
+ static inline uint32_t NEG_USR32(uint32_t a, int8_t s){
++    if (__builtin_constant_p(s))
+     __asm__ ("shrl %1, %0\n\t"
+          : "+r" (a)
+-         : "ic" ((uint8_t)(-s))
++         : "i" (-s & 0x1F)
+     );
++    else
++        __asm__ ("shrl %1, %0\n\t"
++               : "+r" (a)
++               : "c" ((uint8_t)(-s))
++        );
+     return a;
+ }
+ 
diff --git a/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
new file mode 100644
index 00000000000000..aa948f7a8a2dfb
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
@@ -0,0 +1,40 @@
+#==================================================================================================
+# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
+# From: Christopher Degawa <christopher.degawa@intel.com>
+# Date: Thu, 20 Oct 2022 22:55:27 -0500
+# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
+#
+# compressed_ten_bit_format has been deprecated upstream and has no effect
+# and can be removed. Plus, technically it was never used in the first place
+# since it would require the app (ffmpeg) to set it and do additional
+# processing of the input frames.
+#
+# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
+#
+# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
+#==================================================================================================
+--- a/libavcodec/libsvtav1.c
++++ b/libavcodec/libsvtav1.c
+@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
+ 
+ static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
+ {
+-    const int    pack_mode_10bit =
+-        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
+-    const size_t luma_size_8bit  =
+-        config->source_width * config->source_height * (1 << pack_mode_10bit);
+-    const size_t luma_size_10bit =
+-        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
++    const size_t luma_size = config->source_width * config->source_height *
++        (config->encoder_bit_depth > 8 ? 2 : 1);
+ 
+     EbSvtIOFormat *in_data;
+ 
+-    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
++    svt_enc->raw_size = luma_size * 3 / 2;
+ 
+     // allocate buffer for in and out
+     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
+-- 
+GitLab
+
diff --git a/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
new file mode 100644
index 00000000000000..00e3f68a415b84
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
@@ -0,0 +1,28 @@
+From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
+From: Rainer Hochecker <fernetmenta@online.de>
+Date: Sat, 26 Jan 2019 19:48:35 +0100
+Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
+
+This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
+It was hit frequently when watching h264 channels received via DVB-X.
+Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
+---
+ libavcodec/vaapi_h264.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
+index 5854587a255..f12fdc457a4 100644
+--- a/libavcodec/vaapi_h264.c
++++ b/libavcodec/vaapi_h264.c
+@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
+     H264SliceContext *sl = &h->slice_ctx[0];
+     int ret;
+ 
++    if (pic->nb_slices == 0) {
++        ret = AVERROR_INVALIDDATA;
++        goto finish;
++    }
++
+     ret = ff_vaapi_decode_issue(avctx, pic);
+     if (ret < 0)
+         goto finish;
diff --git a/srcpkgs/ffmpeg4/template b/srcpkgs/ffmpeg4/template
new file mode 100644
index 00000000000000..9ba14bdb8ddf32
--- /dev/null
+++ b/srcpkgs/ffmpeg4/template
@@ -0,0 +1,234 @@
+# Template file for 'ffmpeg4'
+# audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
+pkgname=ffmpeg4
+version=4.4.4
+revision=1
+short_desc="Decoding, encoding and streaming software - ffmpeg4 libraries only"
+maintainer="Orphaned <orphan@voidlinux.org>"
+license="GPL-3.0-or-later"
+homepage="https://www.ffmpeg.org"
+changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
+distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
+checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+
+hostmakedepends="pkg-config perl"
+makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
+ libXext-devel libXvMC-devel libxcb-devel lame-devel libtheora-devel
+ libvorbis-devel x264-devel xvidcore-devel jack-devel SDL2-devel
+ libcdio-paranoia-devel librtmp-devel libmodplug-devel gnutls-devel
+ speex-devel celt-devel harfbuzz-devel libass-devel opus-devel ocl-icd-devel
+ libbs2b-devel libvidstab-devel vmaf-devel $(vopt_if pulseaudio pulseaudio-devel)
+ $(vopt_if vaapi libva-devel) $(vopt_if vdpau libvdpau-devel)
+ $(vopt_if x265 x265-devel) $(vopt_if v4l2 v4l-utils-devel)
+ $(vopt_if fdk_aac fdk-aac-devel) $(vopt_if vpx libvpx-devel)
+ $(vopt_if aom libaom-devel) $(vopt_if sndio sndio-devel)
+ $(vopt_if dav1d libdav1d-devel) $(vopt_if zimg zimg-devel)
+ $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
+ $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
+ $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
+
+build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
+
+desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
+desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
+desc_option_sofa="Enable support for AES SOFA"
+desc_option_webp="Enable support for WebP"
+
+case "$XBPS_TARGET_MACHINE" in
+	i686*|x86_64*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau nvenc nvdec"
+			;;
+	ppc64*) build_options_default+=" vaapi vdpau";;
+	mips*) CFLAGS="-mnan=legacy";;
+esac
+
+if [ "$XBPS_TARGET_WORDSIZE" != "32" ]; then
+	build_options_default+=" svtav1"
+fi
+
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+fi
+
+_apply_patch() {
+	local args="$1" pname="$(basename $2)"
+
+	if [ ! -f ".${pname}_done" ]; then
+		patch -N $args -i $2
+		touch .${pname}_done
+	fi
+}
+
+post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64le*) ;;
+		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
+	esac
+
+	vsed -i libavfilter/vf_libvmaf.c -e 's!/usr/local/share/model/\(vmaf_v0.6.1\).pkl!/usr/share/vmaf/\1.json!'
+}
+
+do_configure() {
+	# Fix gcc on x86_64-musl only
+	if [ "$XBPS_TARGET_MACHINE" = "x86_64-musl" ]; then
+		vsed -i configure -e "s;_cflags_speed='-O3';_cflags_speed='-O2';"
+	fi
+
+	if [ "$CROSS_BUILD" ]; then
+		case "$XBPS_TARGET_MACHINE" in
+			arm*) _arch="arm";;
+			aarch64*) _arch="aarch64";;
+			mips*) _arch="mips";;
+			ppc64*) _arch="ppc64";;
+			ppc*) _arch="ppc";;
+			*) _arch="${XBPS_TARGET_MACHINE%%-musl}";;
+		esac
+
+		_args+=" --enable-cross-compile
+			--sysroot=$XBPS_CROSS_BASE
+			--cross-prefix=${XBPS_CROSS_TRIPLET}-
+			--target-os=linux --arch=${_arch}"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc|ppc-musl) _args+=" --disable-altivec";;
+	esac
+
+	if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+		_args+=" --extra-libs=-latomic"
+	fi
+
+	./configure --prefix=/usr --disable-debug --enable-gpl --enable-gnutls \
+		--disable-stripping \
+		--enable-libcdio --enable-version3 --enable-runtime-cpudetect \
+		--enable-libmp3lame --enable-libvorbis --enable-libxvid \
+		--enable-libx264 $(vopt_enable vpx libvpx) --enable-libtheora \
+		--enable-shared --enable-static --enable-libxcb \
+		$(vopt_enable pulseaudio libpulse) --enable-libfreetype --enable-libmodplug \
+		--enable-libspeex --enable-libcelt --enable-libass \
+		--enable-libopus --enable-librtmp --enable-libjack \
+		$(vopt_if fdk_aac '--enable-nonfree --enable-libfdk-aac') \
+		--disable-libopencore_amrnb --disable-libopencore_amrwb \
+		--disable-libopenjpeg \
+		--enable-postproc --enable-opencl ${_args} --enable-libvmaf ${_args} \
+		$(vopt_enable x265 libx265) \
+		$(vopt_enable v4l2 libv4l2) \
+		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
+		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		$(vopt_enable dav1d libdav1d) \
+		$(vopt_enable zimg libzimg) \
+		$(vopt_enable webp libwebp) \
+		$(vopt_enable sofa libmysofa) \
+		$(vopt_enable vulkan) \
+		$(vopt_enable drm libdrm) \
+		$(vopt_enable svtav1 libsvtav1) \
+		$(vopt_enable srt libsrt) \
+		$(vopt_enable rist librist) \
+		$(vopt_if nvenc '--enable-nvenc') \
+		$(vopt_if nvdec '--enable-nvdec')
+}
+
+do_build() {
+	make ${makejobs}
+	make doc/ff{mpeg,play}.1
+}
+
+do_install() {
+	make DESTDIR=${DESTDIR} install install-man
+	rm -rf ${DESTDIR}/usr/bin
+}
+
+libavcodec4_package() {
+	short_desc="FFmpeg codec library"
+	pkg_install() {
+		vmove "usr/lib/libavcodec.so.*"
+	}
+}
+
+libavdevice4_package() {
+	short_desc="FFmpeg device handling library"
+	pkg_install() {
+		vmove "usr/lib/libavdevice.so.*"
+	}
+}
+
+libavresample4_package() {
+	short_desc="FFmpeg audio resampling library"
+	pkg_install() {
+		vmove "usr/lib/libavresample.so.*"
+	}
+}
+
+libavformat4_package() {
+	short_desc="FFmpeg file format library"
+	pkg_install() {
+		vmove "usr/lib/libavformat.so.*"
+	}
+}
+
+libavutil4_package() {
+	short_desc="FFmpeg utility library"
+	pkg_install() {
+		vmove "usr/lib/libavutil.so.*"
+	}
+}
+
+libavfilter4_package() {
+	short_desc="FFmpeg audio/video filter library"
+	pkg_install() {
+		vmove "usr/lib/libavfilter.so.*"
+	}
+}
+
+libpostproc4_package() {
+	short_desc="FFmpeg video postprocessing library"
+	pkg_install() {
+		vmove "usr/lib/libpostproc.so.*"
+	}
+}
+
+libswscale4_package() {
+	short_desc="FFmpeg video scaling library"
+	pkg_install() {
+		vmove "usr/lib/libswscale.so.*"
+	}
+}
+
+libswresample4_package() {
+	short_desc="FFmpeg video resampling library"
+	pkg_install() {
+		vmove "usr/lib/libswresample.so.*"
+	}
+}
+
+ffmpeg4-devel_package() {
+	depends="
+		libavcodec4>=${version}_${revision}
+		libavdevice4>=${version}_${revision}
+		libavformat4>=${version}_${revision}
+		libavutil4>=${version}_${revision}
+		libavfilter4>=${version}_${revision}
+		libpostproc4>=${version}_${revision}
+		libswscale4>=${version}_${revision}
+		libswresample4>=${version}_${revision}
+		libavresample4>=${version}_${revision}"
+	short_desc+=" - development files"
+	conflicts="ffmpeg-devel"
+	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
+		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
+		nostrip_files="/usr/lib/libavfilter.a"
+	fi
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.a"
+		vmove "usr/lib/*.so"
+		vmove usr/share/ffmpeg/examples
+		vmove usr/share/man/man3
+	}
+}
diff --git a/srcpkgs/libavcodec4 b/srcpkgs/libavcodec4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavcodec4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavdevice4 b/srcpkgs/libavdevice4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavdevice4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavfilter4 b/srcpkgs/libavfilter4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavfilter4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavformat4 b/srcpkgs/libavformat4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavformat4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavresample4 b/srcpkgs/libavresample4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavutil4 b/srcpkgs/libavutil4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavutil4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libpostproc4 b/srcpkgs/libpostproc4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libpostproc4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswresample4 b/srcpkgs/libswresample4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libswresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswscale4 b/srcpkgs/libswscale4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libswscale4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file

From 70ec762b7282a15b35cae0021de273a199d3c1c1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:04 -0400
Subject: [PATCH 005/108] opencv: update to 4.7.0.

---
 common/shlibs           | 104 ++++++++++++++++++++--------------------
 srcpkgs/opencv/template |   8 ++--
 2 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index 7ed9310ad0a8c2..446b296c349dae 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2082,58 +2082,58 @@ libcapstone.so.5 capstone-5.0.1_1
 libhavege.so.2 libhaveged-1.9.11_1
 libnih.so.1 libnih-1.0.3_1
 libnih-dbus.so.1 libnih-1.0.3_1
-libopencv_quality.so.406 libopencv-4.6.0_1
-libopencv_reg.so.406 libopencv-4.6.0_1
-libopencv_surface_matching.so.406 libopencv-4.6.0_1
-libopencv_xphoto.so.406 libopencv-4.6.0_1
-libopencv_freetype.so.406 libopencv-4.6.0_1
-libopencv_fuzzy.so.406 libopencv-4.6.0_1
-libopencv_hfs.so.406 libopencv-4.6.0_1
-libopencv_img_hash.so.406 libopencv-4.6.0_1
-libopencv_line_descriptor.so.406 libopencv-4.6.0_1
-libopencv_saliency.so.406 libopencv-4.6.0_1
-libopencv_structured_light.so.406 libopencv-4.6.0_1
-libopencv_aruco.so.406 libopencv-4.6.0_1
-libopencv_bgsegm.so.406 libopencv-4.6.0_1
-libopencv_bioinspired.so.406 libopencv-4.6.0_1
-libopencv_ccalib.so.406 libopencv-4.6.0_1
-libopencv_face.so.406 libopencv-4.6.0_1
-libopencv_tracking.so.406 libopencv-4.6.0_1
-libopencv_xfeatures2d.so.406 libopencv-4.6.0_1
-libopencv_optflow.so.406 libopencv-4.6.0_1
-libopencv_ximgproc.so.406 libopencv-4.6.0_1
-libopencv_plot.so.406 libopencv-4.6.0_1
-libopencv_text.so.406 libopencv-4.6.0_1
-libopencv_ml.so.406 libopencv-4.6.0_1
-libopencv_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn.so.406 libopencv-4.6.0_1
-libopencv_shape.so.406 libopencv-4.6.0_1
-libopencv_stitching.so.406 libopencv-4.6.0_1
-libopencv_photo.so.406 libopencv-4.6.0_1
-libopencv_video.so.406 libopencv-4.6.0_1
-libopencv_calib3d.so.406 libopencv-4.6.0_1
-libopencv_features2d.so.406 libopencv-4.6.0_1
-libopencv_flann.so.406 libopencv-4.6.0_1
-libopencv_highgui.so.406 libopencv-4.6.0_1
-libopencv_videoio.so.406 libopencv-4.6.0_1
-libopencv_imgcodecs.so.406 libopencv-4.6.0_1
-libopencv_imgproc.so.406 libopencv-4.6.0_1
-libopencv_core.so.406 libopencv-4.6.0_1
-libopencv_superres.so.406 libopencv-4.6.0_1
-libopencv_videostab.so.406 libopencv-4.6.0_1
-libopencv_gapi.so.406 libopencv-4.6.0_1
-libopencv_xobjdetect.so.406 libopencv-4.6.0_1
-libopencv_datasets.so.406 libopencv-4.6.0_1
-libopencv_dnn_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn_superres.so.406 libopencv-4.6.0_1
-libopencv_dpm.so.406 libopencv-4.6.0_1
-libopencv_phase_unwrapping.so.406 libopencv-4.6.0_1
-libopencv_stereo.so.406 libopencv-4.6.0_1
-libopencv_rapid.so.406 libopencv-4.6.0_1
-libopencv_intensity_transform.so.406 libopencv-4.6.0_1
-libopencv_alphamat.so.406 libopencv-4.6.0_1
-libopencv_barcode.so.406 libopencv-4.6.0_1
-libopencv_mcc.so.406 libopencv-4.6.0_1
+libopencv_quality.so.407 libopencv-4.7.0_1
+libopencv_reg.so.407 libopencv-4.7.0_1
+libopencv_surface_matching.so.407 libopencv-4.7.0_1
+libopencv_xphoto.so.407 libopencv-4.7.0_1
+libopencv_freetype.so.407 libopencv-4.7.0_1
+libopencv_fuzzy.so.407 libopencv-4.7.0_1
+libopencv_hfs.so.407 libopencv-4.7.0_1
+libopencv_img_hash.so.407 libopencv-4.7.0_1
+libopencv_line_descriptor.so.407 libopencv-4.7.0_1
+libopencv_saliency.so.407 libopencv-4.7.0_1
+libopencv_structured_light.so.407 libopencv-4.7.0_1
+libopencv_aruco.so.407 libopencv-4.7.0_1
+libopencv_bgsegm.so.407 libopencv-4.7.0_1
+libopencv_bioinspired.so.407 libopencv-4.7.0_1
+libopencv_ccalib.so.407 libopencv-4.7.0_1
+libopencv_face.so.407 libopencv-4.7.0_1
+libopencv_tracking.so.407 libopencv-4.7.0_1
+libopencv_xfeatures2d.so.407 libopencv-4.7.0_1
+libopencv_optflow.so.407 libopencv-4.7.0_1
+libopencv_ximgproc.so.407 libopencv-4.7.0_1
+libopencv_plot.so.407 libopencv-4.7.0_1
+libopencv_text.so.407 libopencv-4.7.0_1
+libopencv_ml.so.407 libopencv-4.7.0_1
+libopencv_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn.so.407 libopencv-4.7.0_1
+libopencv_shape.so.407 libopencv-4.7.0_1
+libopencv_stitching.so.407 libopencv-4.7.0_1
+libopencv_photo.so.407 libopencv-4.7.0_1
+libopencv_video.so.407 libopencv-4.7.0_1
+libopencv_calib3d.so.407 libopencv-4.7.0_1
+libopencv_features2d.so.407 libopencv-4.7.0_1
+libopencv_flann.so.407 libopencv-4.7.0_1
+libopencv_highgui.so.407 libopencv-4.7.0_1
+libopencv_videoio.so.407 libopencv-4.7.0_1
+libopencv_imgcodecs.so.407 libopencv-4.7.0_1
+libopencv_imgproc.so.407 libopencv-4.7.0_1
+libopencv_core.so.407 libopencv-4.7.0_1
+libopencv_superres.so.407 libopencv-4.7.0_1
+libopencv_videostab.so.407 libopencv-4.7.0_1
+libopencv_gapi.so.407 libopencv-4.7.0_1
+libopencv_xobjdetect.so.407 libopencv-4.7.0_1
+libopencv_datasets.so.407 libopencv-4.7.0_1
+libopencv_dnn_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn_superres.so.407 libopencv-4.7.0_1
+libopencv_dpm.so.407 libopencv-4.7.0_1
+libopencv_phase_unwrapping.so.407 libopencv-4.7.0_1
+libopencv_stereo.so.407 libopencv-4.7.0_1
+libopencv_rapid.so.407 libopencv-4.7.0_1
+libopencv_intensity_transform.so.407 libopencv-4.7.0_1
+libopencv_alphamat.so.407 libopencv-4.7.0_1
+libopencv_barcode.so.407 libopencv-4.7.0_1
+libopencv_mcc.so.407 libopencv-4.7.0_1
 libuniconf.so.4.6 wvstreams-4.6.1_20
 libwvbase.so.4.6 wvstreams-4.6.1_20
 libwvutils.so.4.6 wvstreams-4.6.1_20
diff --git a/srcpkgs/opencv/template b/srcpkgs/opencv/template
index aea4bfc3a265cf..ce94de9424d18d 100644
--- a/srcpkgs/opencv/template
+++ b/srcpkgs/opencv/template
@@ -1,7 +1,7 @@
 # Template file for 'opencv'
 pkgname=opencv
-version=4.6.0
-revision=6
+version=4.7.0
+revision=1
 create_wrksrc=yes
 build_wrksrc=${pkgname}-${version}
 build_style=cmake
@@ -24,8 +24,8 @@ homepage="https://opencv.org"
 changelog="https://github.com/opencv/opencv/wiki/ChangeLog"
 distfiles="https://github.com/opencv/opencv/archive/${version}.tar.gz
  https://github.com/opencv/opencv_contrib/archive/${version}.tar.gz>contrib.tar.gz"
-checksum="1ec1cba65f9f20fe5a41fda1586e01c70ea0c9a6d7b67c9e13edf0cfe2239277
- 1777d5fd2b59029cf537e5fd6f8aa68d707075822f90bde683fcde086f85f7a7"
+checksum="8df0079cdbe179748a18d44731af62a245a45ebf5085223dc03133954c662973
+ 42df840cf9055e59d0e22c249cfb19f04743e1bdad113d31b1573d3934d62584"
 patch_args="-Np1 -d ${build_wrksrc}"
 # tests hang indenfinitely, even with test data included
 make_check=no

From 0858cbe501e9a46dcc1adbe8b173fee8a89632c5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 006/108] actiona: revbump for opencv-4.7.0

---
 srcpkgs/actiona/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/actiona/template b/srcpkgs/actiona/template
index cf5f0b7a2ae610..0d899311e6df75 100644
--- a/srcpkgs/actiona/template
+++ b/srcpkgs/actiona/template
@@ -1,7 +1,7 @@
 # Template file for 'actiona'
 pkgname=actiona
 version=3.10.1
-revision=2
+revision=3
 build_style=qmake
 configure_args="PKGCONFIG_OPENCV=opencv4"
 hostmakedepends="pkg-config qt5-plugin-mysql qt5-qmake qt5-host-tools"

From 631d8a38984b1a21a38c322aa6aa2f445896c068 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 007/108] retroshare: revbump for opencv-4.7.0

---
 srcpkgs/retroshare/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroshare/template b/srcpkgs/retroshare/template
index 35a2732c77f634..31a40a6ac6d4a7 100644
--- a/srcpkgs/retroshare/template
+++ b/srcpkgs/retroshare/template
@@ -1,7 +1,7 @@
 # Template file for 'retroshare'
 pkgname=retroshare
 version=0.6.6
-revision=4
+revision=5
 build_style=qmake
 #XXX broadcast feature requires an ancient udp-discovery-cpp which either needs
 # to be fetched+patched (FTBFS) here or packaged :/

From 441002874514b958a5587c9d1235b31672b66647 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 008/108] waifu2x-converter-cpp: revbump for opencv-4.7.0

---
 srcpkgs/waifu2x-converter-cpp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waifu2x-converter-cpp/template b/srcpkgs/waifu2x-converter-cpp/template
index 361b8a23b94977..c5ac17eb54ea4c 100644
--- a/srcpkgs/waifu2x-converter-cpp/template
+++ b/srcpkgs/waifu2x-converter-cpp/template
@@ -1,7 +1,7 @@
 # Template file for 'waifu2x-converter-cpp'
 pkgname=waifu2x-converter-cpp
 version=5.2.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DINSTALL_MODELS=ON"
 hostmakedepends="pkg-config"

From 16b1bf81318aae193adbf1afdcaf7dae80fdb4b5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:38 -0400
Subject: [PATCH 009/108] vlc: revbump for ffmpeg4

---
 srcpkgs/vlc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/vlc/template b/srcpkgs/vlc/template
index 559b1c4fff339f..fc399f1a6e9bfc 100644
--- a/srcpkgs/vlc/template
+++ b/srcpkgs/vlc/template
@@ -1,7 +1,7 @@
 # Template file for 'vlc'
 pkgname=vlc
 version=3.0.20
-revision=4
+revision=5
 build_style=gnu-configure
 configure_args="--disable-gme --disable-libtar --enable-jack
  --enable-live555 --disable-fluidsynth --enable-dvdread
@@ -25,7 +25,7 @@ lib32disabled=yes
 hostmakedepends="automake libtool pkg-config flex gettext libgcrypt-devel
  live555-devel gettext-devel $(vopt_if lua lua52) $(vopt_if chromecast protobuf)"
 makedepends="
- avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg-devel freefont-ttf
+ avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg4-devel freefont-ttf
  gnutls-devel jack-devel liba52-devel libass-devel libbluray-devel
  libcdio-devel libdca-devel libdvbpsi-devel libdvdnav-devel libmad-devel
  libmatroska-devel libmodplug-devel libmpcdec-devel libmpeg2-devel

From 646cd0723c99fc145bcae400eb994e19171c524b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:55 -0400
Subject: [PATCH 010/108] osg: revbump for ffmpeg4

---
 srcpkgs/osg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/osg/template b/srcpkgs/osg/template
index 8ef0efc599a1b1..a131ceaf7a867b 100644
--- a/srcpkgs/osg/template
+++ b/srcpkgs/osg/template
@@ -8,7 +8,7 @@ build_helper="qemu"
 configure_args="-DLIB_POSTFIX="
 hostmakedepends="pkg-config xrandr"
 makedepends="MesaLib-devel gtkglext-devel libcurl-devel giflib-devel librsvg-devel
- jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg-devel xine-lib-devel
+ jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg4-devel xine-lib-devel
  SDL2-devel gst-plugins-base1-devel
  $(vopt_if openexr libopenexr-devel)
  $(vopt_if poppler poppler-glib-devel)

From d47e4c4d54bd82136435c675505626079c0b9dc5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:13 -0400
Subject: [PATCH 011/108] xine-lib: revbump for ffmpeg4

---
 srcpkgs/xine-lib/template | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/xine-lib/template b/srcpkgs/xine-lib/template
index 3be4d08eac77a3..ed6194c17d11e8 100644
--- a/srcpkgs/xine-lib/template
+++ b/srcpkgs/xine-lib/template
@@ -1,14 +1,14 @@
 # Template file for 'xine-lib'
 pkgname=xine-lib
-version=1.2.12
-revision=3
+version=1.2.13
+revision=1
 build_style=gnu-configure
 configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
  --disable-oss"
 hostmakedepends="automake gettext-devel libtool pkg-config perl"
 makedepends="
  zlib-devel alsa-lib-devel libxcb-devel libSM-devel libXext-devel libXv-devel
- libXvMC-devel liba52-devel libmad-devel ffmpeg-devel pulseaudio-devel
+ libXvMC-devel liba52-devel libmad-devel ffmpeg4-devel pulseaudio-devel
  jack-devel samba-devel libflac-devel libmodplug-devel libmpcdec-devel
  speex-devel libtheora-devel libvorbis-devel libdca-devel faad2-devel
  libcdio-devel libbluray-devel aalib-devel libcaca-devel libXinerama-devel
@@ -19,7 +19,7 @@ license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="http://www.xine-project.org"
 changelog="https://sourceforge.net/projects/xine/files/xine-lib/${version}/README.txt/view"
 distfiles="${SOURCEFORGE_SITE}/xine/${pkgname}-${version}.tar.xz"
-checksum=d606270468e1540c2a89c0d7f5fdf11e17ecc0c2698cc0bcb1065ff26abee098
+checksum=5f10d6d718a4a51c17ed1b32b031d4f9b80b061e8276535b2be31e5ac4b75e6f
 
 case "$XBPS_TARGET_MACHINE" in
 	i686-musl)

From 27c25f14b50be1a2e54c2a512408c979255b6b0c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 012/108] attract: revbump for ffmpeg6

---
 srcpkgs/attract/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/attract/template b/srcpkgs/attract/template
index e769fb15456217..776cbe4ebd2c93 100644
--- a/srcpkgs/attract/template
+++ b/srcpkgs/attract/template
@@ -1,7 +1,7 @@
 # Template file for 'attract'
 pkgname=attract
 version=2.7.0
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="VERBOSE=1"
 make_use_env=yes

From 813236f40ba2191d7d65c232b44f34a661bad6f1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 013/108] aubio: revbump for ffmpeg6

---
 srcpkgs/aubio/patches/ffmpeg5.patch | 25 +++++++++++++++++++++++++
 srcpkgs/aubio/template              |  2 +-
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/aubio/patches/ffmpeg5.patch

diff --git a/srcpkgs/aubio/patches/ffmpeg5.patch b/srcpkgs/aubio/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..aace41a6e6d9a4
--- /dev/null
+++ b/srcpkgs/aubio/patches/ffmpeg5.patch
@@ -0,0 +1,25 @@
+From 8a05420e5dd8c7b8b2447f82dc919765876511b3 Mon Sep 17 00:00:00 2001
+From: Paul Brossier <piem@piem.org>
+Date: Tue, 25 Jan 2022 18:30:27 +0100
+Subject: [PATCH] [source_avcodec] define FF_API_LAVF_AVCTX for libavcodec >
+ 59, thx @berolinux (closes gh-353)
+
+---
+ src/io/source_avcodec.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/io/source_avcodec.c b/src/io/source_avcodec.c
+index e0ae93b5..1421bd9a 100644
+--- a/src/io/source_avcodec.c
++++ b/src/io/source_avcodec.c
+@@ -68,6 +68,10 @@
+ #define AUBIO_AVCODEC_MAX_BUFFER_SIZE AV_INPUT_BUFFER_MIN_SIZE
+ #endif
+ 
++#if LIBAVCODEC_VERSION_MAJOR >= 59
++#define FF_API_LAVF_AVCTX 1
++#endif
++
+ struct _aubio_source_avcodec_t {
+   uint_t hop_size;
+   uint_t samplerate;
diff --git a/srcpkgs/aubio/template b/srcpkgs/aubio/template
index ad1c4b25699178..7d875cc02541a7 100644
--- a/srcpkgs/aubio/template
+++ b/srcpkgs/aubio/template
@@ -1,7 +1,7 @@
 # Template file for 'aubio'
 pkgname=aubio
 version=0.4.9
-revision=1
+revision=2
 build_style=waf3
 # XXX lash, pure and swig support.
 hostmakedepends="pkg-config txt2man"

From ff2f57cba660308a1b80435c1cbae568543f91c5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 014/108] audacious-plugins: revbump for ffmpeg6

---
 .../audacious-plugins/patches/ffmpeg5.patch   | 43 +++++++++++++++++++
 srcpkgs/audacious-plugins/template            |  2 +-
 2 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/audacious-plugins/patches/ffmpeg5.patch

diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg5.patch b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..4e5e34099d71c4
--- /dev/null
+++ b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
@@ -0,0 +1,43 @@
+commit 298aa371c56c2f52c25a33d9bdec4918b11cebdc
+Author: tibequadorian <tibequadorian@posteo.de>
+Date:   Sat Mar 19 18:40:12 2022 +0100
+
+    audacious-plugins: rebuild against ffmpeg-5.0
+
+diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+new file mode 100644
+index 0000000000..617c11215b
+--- /dev/null
++++ b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+@@ -0,0 +1,31 @@
++From f60beb400eeb1e4778bbfd738bc4a4ccef3de539 Mon Sep 17 00:00:00 2001
++From: John Lindgren <john@jlindgren.net>
++Date: Sat, 5 Mar 2022 12:05:34 -0500
++Subject: [PATCH] Fix build with FFmpeg 5.0
++
++---
++ src/ffaudio/ffaudio-core.cc | 4 ++--
++ 1 file changed, 2 insertions(+), 2 deletions(-)
++
++diff --git a/src/ffaudio/ffaudio-core.cc b/src/ffaudio/ffaudio-core.cc
++index 16dc63e3a..a2b95fd6c 100644
++--- a/src/ffaudio/ffaudio-core.cc
+++++ b/src/ffaudio/ffaudio-core.cc
++@@ -274,7 +274,7 @@ static AVInputFormat * get_format_by_content (const char * name, VFSFile & file)
++         AVProbeData d = {name, buf, filled};
++         score = target;
++ 
++-        f = av_probe_input_format2 (& d, true, & score);
+++        f = (AVInputFormat *) av_probe_input_format2 (& d, true, & score);
++         if (f)
++             break;
++ 
++@@ -347,7 +347,7 @@ static bool find_codec (AVFormatContext * c, CodecInfo * cinfo)
++ #endif
++         if (stream && stream->codecpar && stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
++         {
++-            AVCodec * codec = avcodec_find_decoder (stream->codecpar->codec_id);
+++            AVCodec * codec = (AVCodec *) avcodec_find_decoder (stream->codecpar->codec_id);
++ 
++             if (codec)
++             {
diff --git a/srcpkgs/audacious-plugins/template b/srcpkgs/audacious-plugins/template
index 05e53a9adf78ff..4b1968e03de781 100644
--- a/srcpkgs/audacious-plugins/template
+++ b/srcpkgs/audacious-plugins/template
@@ -2,7 +2,7 @@
 #Keep in sync with audacious!
 pkgname=audacious-plugins
 version=4.3.1
-revision=3
+revision=4
 build_style=meson
 configure_args="$(vopt_bool gtk3 gtk) $(vopt_bool gtk3)
  $(vopt_bool qt) $(vopt_bool qt qt6)"

From 917e575ec4ab739f5b1ee216016fe1b2c2110076 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 015/108] audacity: revbump for ffmpeg6

---
 srcpkgs/audacity/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/audacity/template b/srcpkgs/audacity/template
index 7b838119ab2611..84b49305edcef1 100644
--- a/srcpkgs/audacity/template
+++ b/srcpkgs/audacity/template
@@ -1,7 +1,7 @@
 # Template file for 'audacity'
 pkgname=audacity
 version=3.4.2
-revision=1
+revision=2
 build_style=cmake
 build_helper="cmake-wxWidgets-gtk3 qemu"
 configure_args="-Daudacity_use_ffmpeg=loaded -Daudacity_lib_preference=system

From c6040d2140e181ec75a6c3ab9698a057ca17a7bf Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 016/108] avidemux: revbump for ffmpeg6

---
 srcpkgs/avidemux/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/avidemux/template b/srcpkgs/avidemux/template
index 253a0243e22599..557285982d2b8f 100644
--- a/srcpkgs/avidemux/template
+++ b/srcpkgs/avidemux/template
@@ -1,7 +1,7 @@
 # Template file for 'avidemux'
 pkgname=avidemux
 version=2.8.0
-revision=2
+revision=3
 # Can't be compiled for aarch64, arm* or mips*
 archs="x86_64* i686*"
 hostmakedepends="cmake pkg-config qt5-host-tools qt5-devel tar yasm"

From c4b1c165359f2500cf29dea0a886f593c224eb4d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 017/108] blender: revbump for ffmpeg6

---
 srcpkgs/blender/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index 68787b76a26c18..e2e090e6dfa41c 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -1,7 +1,7 @@
 # Template file for 'blender'
 pkgname=blender
 version=4.0.2
-revision=2
+revision=3
 archs="x86_64* ppc64*"
 build_style="cmake"
 pycompile_dirs="usr/share/blender/${version%.*}/scripts"

From b2fb2bf91b934181b9f80addd5fa3e8df232d0ae Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 018/108] cantata: revbump for ffmpeg6

---
 srcpkgs/cantata/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cantata/template b/srcpkgs/cantata/template
index 4b417d80d5c2da..8a90aaa4c07a2a 100644
--- a/srcpkgs/cantata/template
+++ b/srcpkgs/cantata/template
@@ -1,7 +1,7 @@
 # Template file for 'cantata'
 pkgname=cantata
 version=2.5.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools qt5-tools"
 makedepends="qt5-devel qt5-tools-devel qt5-svg-devel qt5-xmlpatterns-devel

From 2e6e58e4394657d3e566299adec96fb73e2eb012 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 019/108] ccextractor: revbump for ffmpeg6

---
 ...5-and-tesseract-5-compatibility-1479.patch | 168 ++++++++++++++++++
 srcpkgs/ccextractor/template                  |   2 +-
 2 files changed, 169 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ccextractor/patches/0001-fix-ffmpeg-5-and-tesseract-5-compatibility-1479.patch

diff --git a/srcpkgs/ccextractor/patches/0001-fix-ffmpeg-5-and-tesseract-5-compatibility-1479.patch b/srcpkgs/ccextractor/patches/0001-fix-ffmpeg-5-and-tesseract-5-compatibility-1479.patch
new file mode 100644
index 00000000000000..bcab4890554b9a
--- /dev/null
+++ b/srcpkgs/ccextractor/patches/0001-fix-ffmpeg-5-and-tesseract-5-compatibility-1479.patch
@@ -0,0 +1,168 @@
+From b1cbfcea9b9c687143bf0d80bc179b563e99d025 Mon Sep 17 00:00:00 2001
+From: Prateek Sunal <prtksunal@gmail.com>
+Date: Thu, 9 Mar 2023 01:44:53 +0530
+Subject: [PATCH] fix: ffmpeg 5 and tesseract 5 compatibility (#1479)
+
+* fix: replace deprecated `codec` property with `codecpar`
+
+* fix: replace deprecated method `avcodec_decode_video2` with `avcodec_receive_frame` and `avcodec_send_packet`
+
+* Update CHANGES.TXT
+
+* fix: remove deprecated `av_register_all` function
+
+* fix: formatting
+
+* fix: add support for tesseract 5
+
+* fix: tesseract v5
+
+* fix: hardsubx codec context error
+
+* fix: lint const warning
+---
+ docs/CHANGES.TXT               |  1 +
+ src/lib_ccx/ffmpeg_intgr.c     |  7 +++---
+ src/lib_ccx/hardsubx.c         | 25 ++++++++++++------
+ src/lib_ccx/hardsubx_decoder.c | 27 ++++++++------------
+ src/lib_ccx/ocr.c              | 46 ++++++++++++----------------------
+ 5 files changed, 47 insertions(+), 59 deletions(-)
+
+diff --git a/src/lib_ccx/ffmpeg_intgr.c b/src/lib_ccx/ffmpeg_intgr.c
+index be988890..e6f21e20 100644
+--- a/src/lib_ccx/ffmpeg_intgr.c
++++ b/src/lib_ccx/ffmpeg_intgr.c
+@@ -66,7 +66,6 @@ void *init_ffmpeg(const char *path)
+ 	struct ffmpeg_ctx *ctx;
+ 	AVCodec *dec = NULL;
+ 	avcodec_register_all();
+-	av_register_all();
+ 
+ 	if (ccx_options.debug_mask & CCX_DMT_VERBOSE)
+ 		av_log_set_level(AV_LOG_INFO);
+@@ -133,7 +132,6 @@ int ff_get_ccframe(void *arg, unsigned char *data, int maxlen)
+ 	struct ffmpeg_ctx *ctx = arg;
+ 	int len = 0;
+ 	int ret = 0;
+-	int got_frame;
+ 	AVPacket packet;
+ 
+ 	ret = av_read_frame(ctx->ifmt, &packet);
+@@ -151,12 +149,13 @@ int ff_get_ccframe(void *arg, unsigned char *data, int maxlen)
+ 		return AVERROR(EAGAIN);
+ 	}
+ 
+-	ret = avcodec_decode_video2(ctx->dec_ctx, ctx->frame, &got_frame, &packet);
++	avcodec_send_packet(ctx->codec_ctx, &ctx->packet);
++	ret = avcodec_receive_frame(ctx->dec_ctx, ctx->frame);
+ 	if (ret < 0)
+ 	{
+ 		av_log(NULL, AV_LOG_ERROR, "unable to decode packet\n");
+ 	}
+-	else if (!got_frame)
++	else if (ret != 0)
+ 	{
+ 		return AVERROR(EAGAIN);
+ 	}
+diff --git a/src/lib_ccx/hardsubx.c b/src/lib_ccx/hardsubx.c
+index 411377f9..fb844c91 100644
+--- a/src/lib_ccx/hardsubx.c
++++ b/src/lib_ccx/hardsubx.c
+@@ -12,9 +12,6 @@
+
+ int hardsubx_process_data(struct lib_hardsubx_ctx *ctx)
+ {
+-	// Get the required media attributes and initialize structures
+-	av_register_all();
+-
+ 	if (avformat_open_input(&ctx->format_ctx, ctx->inputfile[0], NULL, NULL) != 0)
+ 	{
+ 		fatal(EXIT_READ_ERROR, "Error reading input file!\n");
+@@ -32,7 +29,7 @@
+ 	ctx->video_stream_id = -1;
+ 	for (int i = 0; i < ctx->format_ctx->nb_streams; i++)
+ 	{
+-		if (ctx->format_ctx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO)
++		if (ctx->format_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
+ 		{
+ 			ctx->video_stream_id = i;
+ 			break;
+@@ -43,8 +40,21 @@
+ 		fatal(EXIT_READ_ERROR, "Video Stream not found!\n");
+ 	}
+
+-	ctx->codec_ctx = ctx->format_ctx->streams[ctx->video_stream_id]->codec;
+-	ctx->codec = avcodec_find_decoder(ctx->codec_ctx->codec_id);
++	ctx->codec_ctx = avcodec_alloc_context3(NULL);
++	if (!ctx->codec_ctx)
++	{
++		    fatal(EXIT_NOT_ENOUGH_MEMORY, "Could not allocate codec context!\n");
++	}
++
++	// Assign codec parameters to codec context
++	if (avcodec_parameters_to_context(ctx->codec_ctx, ctx->format_ctx->streams[ctx->video_stream_id]->codecpar) < 0)
++	{
++		    fatal(EXIT_READ_ERROR, "Could not initialize codec context!\n");
++	}
++
++	// Find decoder for the codec context
++	ctx->codec = (AVCodec *)avcodec_find_decoder(ctx->codec_ctx->codec_id);
++
+ 	if (ctx->codec == NULL)
+ 	{
+ 		fatal(EXIT_READ_ERROR, "Input codec is not supported!\n");
+diff --git a/src/lib_ccx/hardsubx_decoder.c b/src/lib_ccx/hardsubx_decoder.c
+index bd9b0980..b5dfaec4 100644
+--- a/src/lib_ccx/hardsubx_decoder.c
++++ b/src/lib_ccx/hardsubx_decoder.c
+@@ -371,7 +371,6 @@
+ int hardsubx_process_frames_tickertext(struct lib_hardsubx_ctx *ctx, struct encoder_ctx *enc_ctx)
+ {
+ 	// Search for ticker text at the bottom of the screen, such as in Russia TV1 or stock prices
+-	int got_frame;
+ 	int cur_sec = 0, total_sec, progress;
+ 	int frame_number = 0;
+ 	char *ticker_text = NULL;
+@@ -382,8 +381,8 @@
+ 		{
+ 			frame_number++;
+ 			//Decode the video stream packet
+-			avcodec_decode_video2(ctx->codec_ctx, ctx->frame, &got_frame, &ctx->packet);
+-			if (got_frame && frame_number % 1000 == 0)
++      avcodec_send_packet(ctx->codec_ctx, &ctx->packet);
++      if (avcodec_receive_frame(ctx->codec_ctx, ctx->frame) == 0 && frame_number % 1000 == 0)
+ 			{
+ 				// sws_scale is used to convert the pixel format to RGB24 from all other cases
+ 				sws_scale(
+@@ -434,9 +433,8 @@
+ 			frame_number++;
+
+ 			//Decode the video stream packet
+-			avcodec_decode_video2(ctx->codec_ctx, ctx->frame, &got_frame, &ctx->packet);
+-
+-			if (got_frame && frame_number % 25 == 0)
++			avcodec_send_packet(ctx->codec_ctx, &ctx->packet);
++      if (avcodec_receive_frame(ctx->codec_ctx, ctx->frame) == 0 && frame_number % 25 == 0)
+ 			{
+ 				float diff = (float)convert_pts_to_ms(ctx->packet.pts - prev_packet_pts, ctx->format_ctx->streams[ctx->video_stream_id]->time_base);
+ 				if (fabsf(diff) < 1000 * ctx->min_sub_duration) //If the minimum duration of a subtitle line is exceeded, process packet
+@@ -548,7 +546,6 @@
+ {
+ 	// Do a binary search over the input video for faster processing
+ 	// printf("Duration: %d\n", (int)ctx->format_ctx->duration);
+-	int got_frame;
+ 	int seconds_time = 0;
+ 	for (seconds_time = 0; seconds_time < 20; seconds_time++)
+ 	{
+@@ -568,8 +565,9 @@
+ 			{
+ 				if (ctx->packet.stream_index == ctx->video_stream_id)
+ 				{
+-					avcodec_decode_video2(ctx->codec_ctx, ctx->frame, &got_frame, &ctx->packet);
+-					if (got_frame)
++          avcodec_send_packet(ctx->codec_ctx, &ctx->packet);
++          if (avcodec_receive_frame(ctx->codec_ctx, ctx->frame) == 0)
++
+ 					{
+ 						// printf("%d\n", seek_time);
+ 						if (ctx->packet.pts < seek_time)
diff --git a/srcpkgs/ccextractor/template b/srcpkgs/ccextractor/template
index 84059ffd02398a..a670758bcbe41b 100644
--- a/srcpkgs/ccextractor/template
+++ b/srcpkgs/ccextractor/template
@@ -1,7 +1,7 @@
 # Template file for 'ccextractor'
 pkgname=ccextractor
 version=0.93
-revision=2
+revision=3
 build_wrksrc="linux"
 build_style=gnu-configure
 configure_args="--enable-ocr --enable-hardsubx"

From 5fb29b041cc4e5f45b169b022b50f6ddbb5dd473 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 020/108] chromaprint: revbump for ffmpeg6

---
 srcpkgs/chromaprint/patches/ffmpeg5.patch | 569 ++++++++++++++++++++++
 srcpkgs/chromaprint/template              |   2 +-
 2 files changed, 570 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromaprint/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromaprint/patches/ffmpeg5.patch b/srcpkgs/chromaprint/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..a9fd307a23c8a4
--- /dev/null
+++ b/srcpkgs/chromaprint/patches/ffmpeg5.patch
@@ -0,0 +1,569 @@
+From 8ccad6937177b1b92e40ab8f4447ea27bac009a7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= <lalinsky@gmail.com>
+Date: Fri, 4 Nov 2022 21:47:38 +0100
+Subject: [PATCH] Use FFmpeg 5.x (#120)
+
+* Use FFmpeg 5.1.2 for CI builds
+
+* Build on Ubuntu 20.04
+
+* Upgrade code to FFmpeg 5.x APIs
+
+* Only set FFmpeg include dirs if building tools
+
+* No longer needed
+
+* Use ubuntu 20.04
+---
+ .github/workflows/build.yml                   |   6 +-
+ CMakeLists.txt                                |  16 --
+ package/build.sh                              |   4 +-
+ src/audio/ffmpeg_audio_processor.h            |   2 -
+ src/audio/ffmpeg_audio_processor_avresample.h |  72 -------
+ src/audio/ffmpeg_audio_processor_swresample.h |  18 +-
+ src/audio/ffmpeg_audio_reader.h               | 197 +++++++++---------
+ tests/CMakeLists.txt                          |   6 +
+ 8 files changed, 122 insertions(+), 199 deletions(-)
+ delete mode 100644 src/audio/ffmpeg_audio_processor_avresample.h
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index f8d6a32..4da2405 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -84,9 +84,6 @@ find_package(FFmpeg)
+ if(FFMPEG_LIBRARIES)
+ 	cmake_push_check_state(RESET)
+ 	set(CMAKE_REQUIRED_LIBRARIES ${FFMPEG_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -lm)
+-	check_function_exists(av_packet_unref HAVE_AV_PACKET_UNREF)
+-	check_function_exists(av_frame_alloc HAVE_AV_FRAME_ALLOC)
+-	check_function_exists(av_frame_free HAVE_AV_FRAME_FREE)
+ 	cmake_pop_check_state()
+ endif()
+
+@@ -163,14 +160,11 @@ message(STATUS "Using ${FFT_LIB} for FFT calculations")
+ if(NOT AUDIO_PROCESSOR_LIB)
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+ 		set(AUDIO_PROCESSOR_LIB "swresample")
+-	elseif(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(AUDIO_PROCESSOR_LIB "avresample")
+ 	endif()
+ endif()
+
+ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE OFF)
+ 		set(USE_SWRESAMPLE ON)
+ 		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBSWRESAMPLE_LIBRARIES})
+ 		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBSWRESAMPLE_INCLUDE_DIRS})
+@@ -178,16 +172,6 @@ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+ 	endif()
+ 	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+-elseif(AUDIO_PROCESSOR_LIB STREQUAL "avresample")
+-	if(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE ON)
+-		set(USE_SWRESAMPLE OFF)
+-		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBAVRESAMPLE_LIBRARIES})
+-		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBAVRESAMPLE_INCLUDE_DIRS})
+-	else()
+-		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+-	endif()
+-	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+ else()
+ 	message(STATUS "Building without audio conversion support, please install FFmpeg with libswresample")
+ endif()
+diff --git a/package/build.sh b/package/build.sh
+index da631ae..b41d36e 100755
+--- a/package/build.sh
++++ b/package/build.sh
+@@ -7,8 +7,8 @@ set -eux
+
+ BASE_DIR=$(cd $(dirname $0)/.. && pwd)
+
+-FFMPEG_VERSION=4.4.1
+-FFMPEG_BUILD_TAG=v4.4.1-1
++FFMPEG_VERSION=5.1.2
++FFMPEG_BUILD_TAG=v${FFMPEG_VERSION}-1
+
+ TMP_BUILD_DIR=$BASE_DIR/$(mktemp -d build.XXXXXXXX)
+ trap 'rm -rf $TMP_BUILD_DIR' EXIT
+diff --git a/src/audio/ffmpeg_audio_processor.h b/src/audio/ffmpeg_audio_processor.h
+index 7628fc7..39f4f6d 100644
+--- a/src/audio/ffmpeg_audio_processor.h
++++ b/src/audio/ffmpeg_audio_processor.h
+@@ -10,8 +10,6 @@
+
+ #if defined(USE_SWRESAMPLE)
+ #include "audio/ffmpeg_audio_processor_swresample.h"
+-#elif defined(USE_AVRESAMPLE)
+-#include "audio/ffmpeg_audio_processor_avresample.h"
+ #else
+ #error "no audio processing library"
+ #endif
+diff --git a/src/audio/ffmpeg_audio_processor_avresample.h b/src/audio/ffmpeg_audio_processor_avresample.h
+deleted file mode 100644
+index bd85f92..0000000
+--- a/src/audio/ffmpeg_audio_processor_avresample.h
++++ /dev/null
+@@ -1,72 +0,0 @@
+-// Copyright (C) 2016  Lukas Lalinsky
+-// Distributed under the MIT license, see the LICENSE file for details.
+-
+-#ifndef CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-#define CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-
+-extern "C" {
+-#include <libavresample/avresample.h>
+-}
+-
+-namespace chromaprint {
+-
+-class FFmpegAudioProcessor {
+-public:
+-	FFmpegAudioProcessor() {
+-		m_resample_ctx = avresample_alloc_context();
+-	}
+-
+-	~FFmpegAudioProcessor() {
+-		avresample_free(&m_resample_ctx);
+-	}
+-
+-	void SetCompatibleMode() {
+-		av_opt_set_int(m_resample_ctx, "filter_size", 16, 0);
+-		av_opt_set_int(m_resample_ctx, "phase_shift", 8, 0);
+-		av_opt_set_int(m_resample_ctx, "linear_interp", 1, 0);
+-		av_opt_set_double(m_resample_ctx, "cutoff", 0.8, 0);
+-	}
+-
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "in_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_rate", sample_rate, 0);
+-	}
+-
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "out_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_rate, 0);
+-	}
+-
+-	int Init() {
+-		return avresample_open(m_resample_ctx);
+-	}
+-
+-	int Convert(uint8_t **out, int out_count, const uint8_t **in, int in_count) {
+-		return avresample_convert(m_resample_ctx, out, 0, out_count, (uint8_t **) in, 0, in_count);
+-	}
+-
+-	int Flush(uint8_t **out, int out_count) {
+-		return avresample_read(m_resample_ctx, out, out_count);
+-	}
+-
+-private:
+-	AVAudioResampleContext *m_resample_ctx = nullptr;
+-};
+-
+-}; // namespace chromaprint
+-
+-#endif
+diff --git a/src/audio/ffmpeg_audio_processor_swresample.h b/src/audio/ffmpeg_audio_processor_swresample.h
+index b86266b..b1d4bea 100644
+--- a/src/audio/ffmpeg_audio_processor_swresample.h
++++ b/src/audio/ffmpeg_audio_processor_swresample.h
+@@ -28,30 +28,28 @@ public:
+ 		av_opt_set_double(m_swr_ctx, "cutoff", 0.8, 0);
+ 	}
+
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "icl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "ich", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetInputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "in_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "isf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "in_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "isr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "in_sample_rate", sample_rate, 0);
+ 	}
+
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "ocl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "och", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetOutputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "out_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "osf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "out_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "osr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "out_sample_rate", sample_rate, 0);
+ 	}
+
+ 	int Init() {
+diff --git a/src/audio/ffmpeg_audio_reader.h b/src/audio/ffmpeg_audio_reader.h
+index 5550164..1c6b346 100644
+--- a/src/audio/ffmpeg_audio_reader.h
++++ b/src/audio/ffmpeg_audio_reader.h
+@@ -62,7 +62,7 @@ public:
+ 	bool Read(const int16_t **data, size_t *size);
+
+ 	bool IsOpen() const { return m_opened; }
+-	bool IsFinished() const { return m_finished && !m_got_frame; }
++	bool IsFinished() const { return !m_has_more_packets && !m_has_more_frames; }
+
+ 	std::string GetError() const { return m_error; }
+ 	int GetErrorCode() const { return m_error_code; }
+@@ -74,20 +74,19 @@ private:
+ 	uint8_t *m_convert_buffer[1] = { nullptr };
+ 	int m_convert_buffer_nb_samples = 0;
+
+-	AVInputFormat *m_input_fmt = nullptr;
++	const AVInputFormat *m_input_fmt = nullptr;
+ 	AVDictionary *m_input_opts = nullptr;
+
+ 	AVFormatContext *m_format_ctx = nullptr;
+ 	AVCodecContext *m_codec_ctx = nullptr;
+-	AVFrame *m_frame = nullptr;
+ 	int m_stream_index = -1;
+ 	std::string m_error;
+ 	int m_error_code = 0;
+-	bool m_finished = false;
+ 	bool m_opened = false;
+-	int m_got_frame = 0;
+-	AVPacket m_packet;
+-	AVPacket m_packet0;
++	bool m_has_more_packets = true;
++	bool m_has_more_frames = true;
++	AVPacket *m_packet = nullptr;
++	AVFrame *m_frame = nullptr;
+
+ 	int m_output_sample_rate = 0;
+ 	int m_output_channels = 0;
+@@ -98,19 +97,12 @@ private:
+
+ inline FFmpegAudioReader::FFmpegAudioReader() {
+ 	av_log_set_level(AV_LOG_QUIET);
+-
+-	av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
+ }
+
+ inline FFmpegAudioReader::~FFmpegAudioReader() {
+ 	Close();
+ 	av_dict_free(&m_input_opts);
+ 	av_freep(&m_convert_buffer[0]);
+-	av_packet_unref(&m_packet0);
+ }
+
+ inline bool FFmpegAudioReader::SetInputFormat(const char *name) {
+@@ -135,11 +127,10 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ 	Close();
+
+-    av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
++	m_packet = av_packet_alloc();
++	if (!m_packet) {
++		return false;
++	}
+
+ 	ret = avformat_open_input(&m_format_ctx, file_name.c_str(), m_input_fmt, &m_input_opts);
+ 	if (ret < 0) {
+@@ -153,26 +144,31 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		return false;
+ 	}
+
+-	AVCodec *codec;
++	const AVCodec *codec;
+ 	ret = av_find_best_stream(m_format_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &codec, 0);
+ 	if (ret < 0) {
+ 		SetError("Could not find any audio stream in the file", ret);
+ 		return false;
+ 	}
+ 	m_stream_index = ret;
++	auto stream = m_format_ctx->streams[m_stream_index];
+
+-	m_codec_ctx = m_format_ctx->streams[m_stream_index]->codec;
++	m_codec_ctx = avcodec_alloc_context3(codec);
+ 	m_codec_ctx->request_sample_fmt = AV_SAMPLE_FMT_S16;
+
++	ret = avcodec_parameters_to_context(m_codec_ctx, stream->codecpar);
++	if (ret < 0) {
++		SetError("Could not copy the stream parameters", ret);
++		return false;
++	}
++
+ 	ret = avcodec_open2(m_codec_ctx, codec, nullptr);
+ 	if (ret < 0) {
+ 		SetError("Could not open the codec", ret);
+ 		return false;
+ 	}
+
+-	if (!m_codec_ctx->channel_layout) {
+-		m_codec_ctx->channel_layout = av_get_default_channel_layout(m_codec_ctx->channels);
+-	}
++	av_dump_format(m_format_ctx, 0, "foo", 0);
+
+ 	m_frame = av_frame_alloc();
+ 	if (!m_frame) {
+@@ -183,19 +179,23 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		m_output_sample_rate = m_codec_ctx->sample_rate;
+ 	}
+
+-	if (!m_output_channels) {
+-		m_output_channels = m_codec_ctx->channels;
++	AVChannelLayout output_channel_layout;
++	if (m_output_channels) {
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
++	} else {
++		m_output_channels = m_codec_ctx->ch_layout.nb_channels;
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
+ 	}
+
+-	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
++	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->ch_layout.nb_channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
+ 		m_converter.reset(new FFmpegAudioProcessor());
+ 		m_converter->SetCompatibleMode();
+ 		m_converter->SetInputSampleFormat(m_codec_ctx->sample_fmt);
+ 		m_converter->SetInputSampleRate(m_codec_ctx->sample_rate);
+-		m_converter->SetInputChannelLayout(m_codec_ctx->channel_layout);
++		m_converter->SetInputChannelLayout(&(m_codec_ctx->ch_layout));
+ 		m_converter->SetOutputSampleFormat(AV_SAMPLE_FMT_S16);
+ 		m_converter->SetOutputSampleRate(m_output_sample_rate);
+-		m_converter->SetOutputChannelLayout(av_get_default_channel_layout(m_output_channels));
++		m_converter->SetOutputChannelLayout(&output_channel_layout);
+ 		auto ret = m_converter->Init();
+ 		if (ret != 0) {
+ 			SetError("Could not create an audio converter instance", ret);
+@@ -203,10 +203,11 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		}
+ 	}
+
++	av_channel_layout_uninit(&output_channel_layout);
++
+ 	m_opened = true;
+-	m_finished = false;
+-	m_got_frame = 0;
+-	m_nb_packets = 0;
++	m_has_more_packets = true;
++	m_has_more_frames = true;
+ 	m_decode_error = 0;
+
+ 	return true;
+@@ -214,6 +215,7 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ inline void FFmpegAudioReader::Close() {
+ 	av_frame_free(&m_frame);
++	av_packet_free(&m_packet);
+
+ 	m_stream_index = -1;
+
+@@ -252,91 +254,98 @@ inline bool FFmpegAudioReader::Read(const int16_t **data, size_t *size) {
+ 		return false;
+ 	}
+
++	*data = nullptr;
++	*size = 0;
++
+ 	int ret;
++	bool needs_packet = false;
+ 	while (true) {
+-		while (m_packet.size <= 0) {
+-			av_packet_unref(&m_packet0);
+-			av_init_packet(&m_packet);
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			ret = av_read_frame(m_format_ctx, &m_packet);
++		while (needs_packet && m_packet->size == 0) {
++			ret = av_read_frame(m_format_ctx, m_packet);
+ 			if (ret < 0) {
+ 				if (ret == AVERROR_EOF) {
+-					m_finished = true;
++					needs_packet = false;
++					m_has_more_packets = false;
+ 					break;
+-				} else {
++				}
++				SetError("Error reading from the audio source", ret);
++				return false;
++			}
++			if (m_packet->stream_index == m_stream_index) {
++				needs_packet = false;
++			} else {
++				av_packet_unref(m_packet);
++			}
++		}
++
++		if (m_packet->size != 0) {
++			ret = avcodec_send_packet(m_codec_ctx, m_packet);
++			if (ret < 0) {
++				if (ret != AVERROR(EAGAIN)) {
+ 					SetError("Error reading from the audio source", ret);
+ 					return false;
+ 				}
+-			}
+-			m_packet0 = m_packet;
+-			if (m_packet.stream_index != m_stream_index) {
+-				m_packet.data = nullptr;
+-				m_packet.size = 0;
+ 			} else {
+-				m_nb_packets++;
++				av_packet_unref(m_packet);
+ 			}
+ 		}
+
+-		ret = avcodec_decode_audio4(m_codec_ctx, m_frame, &m_got_frame, &m_packet);
++		ret = avcodec_receive_frame(m_codec_ctx, m_frame);
+ 		if (ret < 0) {
+-			if (m_decode_error) {
+-				SetError("Error decoding audio frame", m_decode_error);
+-				return false;
++			if (ret == AVERROR_EOF) {
++				m_has_more_frames = false;
++			} else if (ret == AVERROR(EAGAIN)) {
++				if (m_has_more_packets) {
++					needs_packet = true;
++					continue;
++				} else {
++					m_has_more_frames = false;
++				}
+ 			}
+-			m_decode_error = ret;
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			continue;
++			SetError("Error decoding the audio source", ret);
++			return false;
+ 		}
+
+-		break;
+-	}
+-
+-	m_decode_error = 0;
+-
+-	const int decoded = std::min(ret, m_packet.size);
+-	m_packet.data += decoded;
+-	m_packet.size -= decoded;
+-
+-	if (m_got_frame) {
+-		if (m_converter) {
+-			if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
+-				int linsize;
+-				av_freep(&m_convert_buffer[0]);
+-				m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
+-				ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
+-				if (ret < 0) {
+-					SetError("Couldn't allocate audio converter buffer", ret);
++		if (m_frame->nb_samples > 0) {
++			if (m_converter) {
++				if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
++					int linsize;
++					av_freep(&m_convert_buffer[0]);
++					m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
++					ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->ch_layout.nb_channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
++					if (ret < 0) {
++						SetError("Couldn't allocate audio converter buffer", ret);
++						return false;
++					}
++				}
++				auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
++				if (nb_samples < 0) {
++					SetError("Couldn't convert audio", ret);
+ 					return false;
+ 				}
+-			}
+-			auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			}
+-			*data = (const int16_t *) m_convert_buffer[0];
+-			*size = nb_samples;
+-		} else {
+-			*data = (const int16_t *) m_frame->data[0];
+-			*size = m_frame->nb_samples;
+-		}
+-	} else {
+-		if (m_finished && m_converter) {
+-			auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			} else if (nb_samples > 0) {
+-				m_got_frame = 1;
+ 				*data = (const int16_t *) m_convert_buffer[0];
+ 				*size = nb_samples;
++			} else {
++				*data = (const int16_t *) m_frame->data[0];
++				*size = m_frame->nb_samples;
++			}
++		} else {
++			if (m_converter) {
++				if (IsFinished()) {
++					auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
++					if (nb_samples < 0) {
++						SetError("Couldn't convert audio", ret);
++						return false;
++					} else if (nb_samples > 0) {
++						*data = (const int16_t *) m_convert_buffer[0];
++						*size = nb_samples;
++					}
++				}
+ 			}
+ 		}
+-	}
+
+-	return true;
++		return true;
++	}
+ }
+
+ inline void FFmpegAudioReader::SetError(const char *message, int errnum) {
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index a2b517b..123e643 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -38,6 +38,12 @@ set(SRCS
+
+ if(BUILD_TOOLS)
+ 	set(SRCS ${SRCS} ../src/audio/ffmpeg_audio_reader_test.cpp)
++    include_directories(
++        ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}
++        ${AUDIO_PROCESSOR_INCLUDE_DIRS}
++    )
+ 	link_libraries(fpcalc_libs)
+ endif()
+
+-- 
+2.38.1
+
+
diff --git a/srcpkgs/chromaprint/template b/srcpkgs/chromaprint/template
index 7ef7838949f3a3..1f7bbc70a22c80 100644
--- a/srcpkgs/chromaprint/template
+++ b/srcpkgs/chromaprint/template
@@ -1,7 +1,7 @@
 # Template file for 'chromaprint'
 pkgname=chromaprint
 version=1.5.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DBUILD_TOOLS=ON"
 make_check_target="check"

From 3b11818fc7be9a56119a68e812065c6379b741fc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 021/108] chromium: revbump for ffmpeg6

---
 srcpkgs/chromium/patches/ffmpeg5.patch | 47 ++++++++++++++++++++++++++
 srcpkgs/chromium/template              |  2 +-
 2 files changed, 48 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..24e2da38e34ca2
--- /dev/null
+++ b/srcpkgs/chromium/patches/ffmpeg5.patch
@@ -0,0 +1,47 @@
+--- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
++++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
+@@ -92,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+-  if (stream->start_time != kNoFFmpegTimestamp)
++  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -1597,7 +1585,7 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+@@ -1618,7 +1606,7 @@
+     if (stream->type() != DemuxerStream::VIDEO)
+       continue;
+ 
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+ 
+     if (!stream->IsEnabled())
diff --git a/srcpkgs/chromium/template b/srcpkgs/chromium/template
index fc7534f3f303c3..4853b6cf973eed 100644
--- a/srcpkgs/chromium/template
+++ b/srcpkgs/chromium/template
@@ -2,7 +2,7 @@
 pkgname=chromium
 # See https://chromiumdash.appspot.com/releases?platform=Linux for the latest version
 version=123.0.6312.86
-revision=1
+revision=2
 archs="i686* x86_64* aarch64* armv7l*"
 hostmakedepends="
  $(vopt_if clang "clang17 lld17 llvm17 compiler-rt")

From 64b1bc96143c17069ad323f58b2e6bcbe3b08d0f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 022/108] cmus: revbump for ffmpeg6

---
 srcpkgs/chromium/patches/ffmpeg5.patch | 47 --------------------------
 srcpkgs/cmus/patches/ffmpeg6.patch     | 12 +++++++
 srcpkgs/cmus/template                  |  2 +-
 3 files changed, 13 insertions(+), 48 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch
 create mode 100644 srcpkgs/cmus/patches/ffmpeg6.patch

diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
deleted file mode 100644
index 24e2da38e34ca2..00000000000000
--- a/srcpkgs/chromium/patches/ffmpeg5.patch
+++ /dev/null
@@ -1,47 +0,0 @@
---- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
-+++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
-@@ -92,24 +92,12 @@
- 
- static base::TimeDelta ExtractStartTime(AVStream* stream) {
-   // The default start time is zero.
--  base::TimeDelta start_time;
-+  base::TimeDelta start_time = kNoTimestamp;
- 
-   // First try to use  the |start_time| value as is.
--  if (stream->start_time != kNoFFmpegTimestamp)
-+  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
-     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
- 
--  // Next try to use the first DTS value, for codecs where we know PTS == DTS
--  // (excludes all H26x codecs). The start time must be returned in PTS.
--  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
--      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
--      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
--      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
--    const base::TimeDelta first_pts =
--        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
--    if (first_pts < start_time)
--      start_time = first_pts;
--  }
--
-   return start_time;
- }
- 
-@@ -1597,7 +1585,7 @@
-   for (const auto& stream : streams_) {
-     if (!stream || stream->IsEnabled() != enabled)
-       continue;
--    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
-+    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
-       continue;
-     if (!lowest_start_time_stream ||
-         stream->start_time() < lowest_start_time_stream->start_time()) {
-@@ -1618,7 +1606,7 @@
-     if (stream->type() != DemuxerStream::VIDEO)
-       continue;
- 
--    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
-+    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
-       continue;
- 
-     if (!stream->IsEnabled())
diff --git a/srcpkgs/cmus/patches/ffmpeg6.patch b/srcpkgs/cmus/patches/ffmpeg6.patch
new file mode 100644
index 00000000000000..ffa95ab811101b
--- /dev/null
+++ b/srcpkgs/cmus/patches/ffmpeg6.patch
@@ -0,0 +1,12 @@
+--- a/ip/ffmpeg.c
++++ b/ip/ffmpeg.c
+@@ -202,9 +202,6 @@ static int ffmpeg_open(struct input_plugin_data *ip_data)
+ 			break;
+ 		}
+ 
+-		if (codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+-			cc->flags |= AV_CODEC_FLAG_TRUNCATED;
+-
+ 		if (avcodec_open2(cc, codec, NULL) < 0) {
+ 			d_print("could not open codec: %d, %s\n", cc->codec_id, avcodec_get_name(cc->codec_id));
+ 			err = -IP_ERROR_UNSUPPORTED_FILE_TYPE;
diff --git a/srcpkgs/cmus/template b/srcpkgs/cmus/template
index 0d1436744f1b2c..a6e4b4fa86cb83 100644
--- a/srcpkgs/cmus/template
+++ b/srcpkgs/cmus/template
@@ -1,7 +1,7 @@
 # Template file for 'cmus'
 pkgname=cmus
 version=2.10.0
-revision=3
+revision=4
 build_style=configure
 configure_args="prefix=/usr LD=$CC"
 hostmakedepends="pkg-config"

From 4bbcd8a1a5664da67405df517aea818b528a9b27 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 023/108] cyanrip: revbump for ffmpeg6

---
 srcpkgs/cyanrip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cyanrip/template b/srcpkgs/cyanrip/template
index 9796e3461601a7..5db30e020d17ee 100644
--- a/srcpkgs/cyanrip/template
+++ b/srcpkgs/cyanrip/template
@@ -1,7 +1,7 @@
 # Template file for 'cyanrip'
 pkgname=cyanrip
 version=0.9.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config"
 makedepends="ffmpeg-devel libcdio-devel libcdio-paranoia-devel libcurl-devel libmusicbrainz5-devel"

From 5f91f39054712112cd2011d8e07c797f174eb21e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 024/108] deadbeef: revbump for ffmpeg4

---
 srcpkgs/deadbeef/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/deadbeef/template b/srcpkgs/deadbeef/template
index f5f4bf24b8cb6d..7b47e615cd48ef 100644
--- a/srcpkgs/deadbeef/template
+++ b/srcpkgs/deadbeef/template
@@ -1,14 +1,14 @@
 # Template file for 'deadbeef'
 pkgname=deadbeef
 version=1.8.8
-revision=3
+revision=4
 create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-oss --disable-lfm --disable-notify --disable-gtk2"
 hostmakedepends="automake libtool gettext gettext-devel intltool pkg-config
  yasm clang glib-devel"
 makedepends="
- alsa-lib-devel dbus-devel faad2-devel ffmpeg-devel gtk+3-devel imlib2-devel
+ alsa-lib-devel dbus-devel faad2-devel ffmpeg4-devel gtk+3-devel imlib2-devel
  jansson-devel libcddb-devel libcdio-devel libcurl-devel libflac-devel
  libmad-devel libpng-devel libsamplerate-devel libsndfile-devel libvorbis-devel
  libzip-devel mpg123-devel opusfile-devel pulseaudio-devel wavpack-devel"

From 544a7a19a252e35c7cff1ef810b35ecacb51f10c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 025/108] droidcam-obs-plugin: revbump for ffmpeg6

---
 srcpkgs/droidcam-obs-plugin/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam-obs-plugin/template b/srcpkgs/droidcam-obs-plugin/template
index fc9c9bf6b9d54c..fb0480754df4de 100644
--- a/srcpkgs/droidcam-obs-plugin/template
+++ b/srcpkgs/droidcam-obs-plugin/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam-obs-plugin'
 pkgname=droidcam-obs-plugin
 version=2.0.1
-revision=1
+revision=2
 build_style=gnu-makefile
 make_use_env=yes
 make_build_args="ALLOW_STATIC=no"

From 4ba6681df8cb7f17099fb6493783ee7d7889b1ea Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 026/108] droidcam: revbump for ffmpeg6

---
 srcpkgs/droidcam/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam/template b/srcpkgs/droidcam/template
index 1c3f1b8b1fc676..32a9220b79a4d1 100644
--- a/srcpkgs/droidcam/template
+++ b/srcpkgs/droidcam/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam'
 pkgname=droidcam
 version=1.8.2
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="USBMUXD=-lusbmuxd-2.0 JPEG=-lturbojpeg"
 hostmakedepends="pkg-config"

From 4762cc7f2eaea49605b3478fbace48095ce76195 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 027/108] ffmpegthumbnailer: revbump for ffmpeg6

---
 .../ffmpegthumbnailer/patches/ffmpeg6.patch   | 202 ++++++++++++++++++
 srcpkgs/ffmpegthumbnailer/template            |   6 +-
 2 files changed, 205 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch

diff --git a/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
new file mode 100644
index 00000000000000..363ff35a28419d
--- /dev/null
+++ b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
@@ -0,0 +1,202 @@
+--- a/libffmpegthumbnailer/moviedecoder.cpp	2017-11-21 14:06:57.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.cpp	2023-05-05 13:14:47.946560668 -0400
+@@ -41,11 +41,6 @@
+ namespace ffmpegthumbnailer
+ {
+ 
+-struct SilenceLogLevel
+-{
+-    SilenceLogLevel() { av_log_set_level(AV_LOG_QUIET); }
+-};
+-
+ MovieDecoder::MovieDecoder(AVFormatContext* pavContext)
+ : m_VideoStream(-1)
+ , m_pFormatContext(pavContext)
+@@ -70,8 +65,6 @@
+ 
+ void MovieDecoder::initialize(const string& filename, bool preferEmbeddedMetadata)
+ {
+-    av_register_all();
+-    avcodec_register_all();
+     avformat_network_init();
+ 
+     string inputFile = filename == "-" ? "pipe:" : filename;
+@@ -97,8 +90,7 @@
+ {
+     if (m_pVideoCodecContext)
+     {
+-        avcodec_close(m_pVideoCodecContext);
+-        m_pVideoCodecContext = nullptr;
++        avcodec_free_context(&m_pVideoCodecContext);
+     }
+ 
+     if ((!m_FormatContextWasGiven) && m_pFormatContext)
+@@ -152,10 +144,10 @@
+     for (unsigned int i = 0; i < m_pFormatContext->nb_streams; ++i)
+     {
+         AVStream *stream = m_pFormatContext->streams[i];
+-        auto ctx = m_pFormatContext->streams[i]->codec;
+-        if (ctx->codec_type == AVMEDIA_TYPE_VIDEO)
++        auto par = m_pFormatContext->streams[i]->codecpar;
++        if (par->codec_type == AVMEDIA_TYPE_VIDEO)
+         {
+-            if (!preferEmbeddedMetadata || !isStillImageCodec(ctx->codec_id))
++            if (!preferEmbeddedMetadata || !isStillImageCodec(par->codec_id))
+             {
+                 videoStreams.push_back(i);
+                 continue;
+@@ -203,8 +195,7 @@
+     }
+ 
+     m_pVideoStream = m_pFormatContext->streams[m_VideoStream];
+-    m_pVideoCodecContext = m_pVideoStream->codec;
+-    m_pVideoCodec = avcodec_find_decoder(m_pVideoCodecContext->codec_id);
++    m_pVideoCodec = avcodec_find_decoder(m_pVideoStream->codecpar->codec_id);
+ 
+     if (m_pVideoCodec == nullptr)
+     {
+@@ -214,6 +205,20 @@
+         throw logic_error("Video Codec not found");
+     }
+ 
++    m_pVideoCodecContext = avcodec_alloc_context3(m_pVideoCodec);
++
++    if (m_pVideoCodecContext == nullptr)
++    {
++        destroy();
++        throw logic_error("Could not allocate video codec context");
++    }
++
++    if (avcodec_parameters_to_context(m_pVideoCodecContext, m_pVideoStream->codecpar) < 0)
++    {
++        destroy();
++        throw logic_error("Could not configure video codec context");
++    }
++
+     m_pVideoCodecContext->workaround_bugs = 1;
+ 
+     if (avcodec_open2(m_pVideoCodecContext, m_pVideoCodec, nullptr) < 0)
+@@ -386,13 +391,6 @@
+ 
+ void MovieDecoder::initializeFilterGraph(const AVRational& timeBase, const std::string& size, bool maintainAspectRatio)
+ {
+-    static const AVPixelFormat pixelFormats[] = { AV_PIX_FMT_RGB24, AV_PIX_FMT_NONE };
+-
+-    auto del = [] (AVBufferSinkParams* p) { av_freep(p); };
+-    std::unique_ptr<AVBufferSinkParams, decltype(del)> buffersinkParams(av_buffersink_params_alloc(), del);
+-
+-    avfilter_register_all();
+-
+     m_pFilterGraph = avfilter_graph_alloc();
+     assert(m_pFilterGraph);
+ 
+@@ -404,10 +402,8 @@
+ 
+     checkRc(avfilter_graph_create_filter(&m_pFilterSource, avfilter_get_by_name("buffer"), "thumb_buffer", ss.str().c_str(), nullptr, m_pFilterGraph),
+             "Failed to create filter source");
+-    buffersinkParams->pixel_fmts = pixelFormats;
+-    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, buffersinkParams.get(), m_pFilterGraph),
++    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, nullptr, m_pFilterGraph),
+             "Failed to create filter sink");
+-    buffersinkParams.release();
+ 
+     AVFilterContext* yadifFilter = nullptr;
+     if (m_pFrame->interlaced_frame != 0)
+@@ -500,15 +496,15 @@
+     }
+ 
+     checkRc(av_seek_frame(m_pFormatContext, -1, timestamp, 0), "Seeking in video failed");
+-    avcodec_flush_buffers(m_pFormatContext->streams[m_VideoStream]->codec);
++    avcodec_flush_buffers(m_pVideoCodecContext);
+ 
+     int keyFrameAttempts = 0;
+-    bool gotFrame = 0;
++    bool gotFrame;
+ 
+     do
+     {
+         int count = 0;
+-        gotFrame = 0;
++        gotFrame = false;
+ 
+         while (!gotFrame && count < 20)
+         {
+@@ -552,17 +548,33 @@
+         return false;
+     }
+ 
+-    av_frame_unref(m_pFrame);
+-
+-    int frameFinished;
++    int rc = avcodec_send_packet(m_pVideoCodecContext, m_pPacket);
++    if(rc == AVERROR(EAGAIN))
++    {
++        rc = 0;
++    }
+ 
+-    int bytesDecoded = avcodec_decode_video2(m_pVideoCodecContext, m_pFrame, &frameFinished, m_pPacket);
+-    if (bytesDecoded < 0)
++    if(rc == AVERROR_EOF)
++    {
++        return false;
++    }
++    else if(rc < 0)
+     {
+-        throw logic_error("Failed to decode video frame: bytesDecoded < 0");
++        throw logic_error("Failed to decode video frame: avcodec_send_packet() < 0");
+     }
+ 
+-    return frameFinished > 0;
++    rc = avcodec_receive_frame(m_pVideoCodecContext, m_pFrame);
++    switch(rc)
++    {
++        case 0:
++            return true;
++
++        case AVERROR(EAGAIN):
++            return false;
++
++        default:
++            throw logic_error("Failed to decode video frame: avcodec_receive_frame() < 0");
++    }
+ }
+ 
+ bool MovieDecoder::getVideoPacket()
+@@ -570,8 +582,6 @@
+     bool framesAvailable = true;
+     bool frameDecoded = false;
+ 
+-    int attempts = 0;
+-
+     if (m_pPacket)
+     {
+         av_packet_unref(m_pPacket);
+@@ -580,6 +590,7 @@
+ 
+     m_pPacket = new AVPacket();
+ 
++
+     while (framesAvailable && !frameDecoded)
+     {
+         framesAvailable = av_read_frame(m_pFormatContext, m_pPacket) >= 0;
+@@ -644,7 +655,7 @@
+ 
+ int32_t MovieDecoder::getStreamRotation()
+ {
+-    int32_t* matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
++    auto matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
+     if (matrix)
+     {
+         auto angle = lround(av_display_rotation_get(matrix));
+
+--- a/libffmpegthumbnailer/moviedecoder.h	2017-11-12 04:23:38.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.h	2023-05-05 13:26:07.095529911 -0400
+@@ -78,7 +78,7 @@
+     int                     m_VideoStream;
+     AVFormatContext*        m_pFormatContext;
+     AVCodecContext*         m_pVideoCodecContext;
+-    AVCodec*                m_pVideoCodec;
++    const AVCodec*          m_pVideoCodec;
+     AVFilterGraph*          m_pFilterGraph;
+     AVFilterContext*        m_pFilterSource;
+     AVFilterContext*        m_pFilterSink;
diff --git a/srcpkgs/ffmpegthumbnailer/template b/srcpkgs/ffmpegthumbnailer/template
index 039eea7622b391..35d546018d12af 100644
--- a/srcpkgs/ffmpegthumbnailer/template
+++ b/srcpkgs/ffmpegthumbnailer/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbnailer'
 pkgname=ffmpegthumbnailer
 version=2.2.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libpng-devel libjpeg-turbo-devel ffmpeg-devel"
@@ -9,8 +9,8 @@ depends="ffmpeg"
 short_desc="Lightweight video thumbnailer"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
-homepage="https://github.com/dirkvdb/${pkgname}"
-distfiles="${homepage}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
+homepage="https://github.com/dirkvdb"
+distfiles="${homepage}/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
 checksum=1cb24059c38223f657b300c84dd80491b7040d4b69471c4fea69be862bc99b5b
 
 post_install() {

From 3f20403b526fcad357bbca7c5b29919964e5be24 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 028/108] ffmpegthumbs: revbump for ffmpeg6

---
 srcpkgs/ffmpegthumbs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ffmpegthumbs/template b/srcpkgs/ffmpegthumbs/template
index 2e2a96de83ce8a..dfd7e9dede36d3 100644
--- a/srcpkgs/ffmpegthumbs/template
+++ b/srcpkgs/ffmpegthumbs/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbs'
 pkgname=ffmpegthumbs
 version=23.08.5
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules kcoreaddons kconfig-devel
  pkg-config qt5-host-tools qt5-qmake gettext"

From 5e3d8c876b25cd7b8588bbbb69e4d1557e497b5f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 029/108] ffms2: revbump for ffmpeg6

---
 srcpkgs/ffms2/patches/ffmpeg5.patch | 424 ++++++++++++++++++++++++++++
 srcpkgs/ffms2/template              |   2 +-
 2 files changed, 425 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ffms2/patches/ffmpeg5.patch

diff --git a/srcpkgs/ffms2/patches/ffmpeg5.patch b/srcpkgs/ffms2/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..1479fabcafcb4e
--- /dev/null
+++ b/srcpkgs/ffms2/patches/ffmpeg5.patch
@@ -0,0 +1,424 @@
+From 45673149e9a2f5586855ad472e3059084eaa36b1 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:41:21 +0100
+Subject: [PATCH] Use auto for AVCodec
+
+The geniuses over at FFmpeg decided to constify this API, so old
+versions of the library will return AVCodec *, while new versions
+of the libary will return const AVCodec *, which, in C++, are not
+OK to convert between.
+
+Rather than use some macro hell in ffmscompat.h, we can work around
+this by using auto.
+
+Gross.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 2 +-
+ src/core/indexing.cpp    | 6 +++---
+ src/core/videosource.cpp | 2 +-
+ 3 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index e4ce97c..ac09666 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -469,7 +469,7 @@ void FFMS_AudioSource::OpenFile() {
+ 
+     LAVFOpenFile(SourceFile.c_str(), FormatContext, TrackNumber);
+ 
+-    AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
++    auto *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
+     if (Codec == nullptr)
+         throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+             "Audio codec not found");
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index e547c5a..59fb4e8 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -384,7 +384,7 @@ FFMS_TrackType FFMS_Indexer::GetTrackType(int Track) {
+ }
+ 
+ const char *FFMS_Indexer::GetTrackCodec(int Track) {
+-    AVCodec *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
++    auto *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
+     return codec ? codec->name : nullptr;
+ }
+ 
+@@ -402,7 +402,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             UseDTS);
+ 
+         if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            AVCodec *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (!VideoCodec) {
+                 FormatContext->streams[i]->discard = AVDISCARD_ALL;
+                 IndexMask.erase(i);
+@@ -433,7 +433,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 IndexMask.insert(i);
+             }
+         } else if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+-            AVCodec *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (AudioCodec == nullptr)
+                 throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_UNSUPPORTED,
+                     "Audio codec not found");
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index b889970..8956c22 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -171,7 +171,7 @@ FFMS_VideoSource::FFMS_VideoSource(const char *SourceFile, FFMS_Index &Index, in
+ 
+         LAVFOpenFile(SourceFile, FormatContext, VideoTrack);
+ 
+-        AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
++        auto *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
+         if (Codec == nullptr)
+             throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+                 "Video codec not found");
+-- 
+2.40.0
+
+From 96cbf38ea9381829a1314f432a2c60495dcefaad Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:12:41 +0100
+Subject: [PATCH] all: Update AVPacket API usage
+
+AVPackets must all be on the heap now, since it is no longer
+part of the libav* ABI.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 16 ++++++----
+ src/core/indexing.cpp    | 63 ++++++++++++++++++++++------------------
+ src/core/indexing.h      |  4 +--
+ src/core/utils.cpp       |  6 ----
+ src/core/utils.h         |  1 -
+ src/core/videosource.cpp | 30 ++++++++++---------
+ 6 files changed, 64 insertions(+), 56 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index 37cf9ae..e4ce97c 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -285,10 +285,15 @@ FFMS_AudioSource::AudioBlock *FFMS_AudioSource::CacheBlock(CacheIterator &pos) {
+ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     CurrentFrame = &Frames[PacketNumber];
+ 
+-    AVPacket Packet;
+-    if (!ReadPacket(&Packet))
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++    if (!ReadPacket(Packet)) {
++        av_packet_free(&Packet);
+         throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_UNKNOWN,
+             "ReadPacket unexpectedly failed to read a packet");
++    }
+ 
+     // ReadPacket may have changed the packet number
+     CurrentFrame = &Frames[PacketNumber];
+@@ -297,8 +302,9 @@ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     int NumberOfSamples = 0;
+     AudioBlock *CachedBlock = nullptr;
+     
+-    int Ret = avcodec_send_packet(CodecContext, &Packet);
+-    av_packet_unref(&Packet);
++    int Ret = avcodec_send_packet(CodecContext, Packet);
++    av_packet_unref(Packet);
++    av_packet_free(&Packet);
+ 
+     av_frame_unref(DecodeFrame);
+     Ret = avcodec_receive_frame(CodecContext, DecodeFrame);
+@@ -513,8 +519,6 @@ void FFMS_AudioSource::Seek() {
+ }
+ 
+ bool FFMS_AudioSource::ReadPacket(AVPacket *Packet) {
+-    InitNullPacket(*Packet);
+-
+     while (av_read_frame(FormatContext, Packet) >= 0) {
+         if (Packet->stream_index == TrackNumber) {
+             // Required because not all audio packets, especially in ogg, have a pts. Use the previous valid packet's pts instead.
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index 23fb95b..e547c5a 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -320,7 +320,7 @@ void FFMS_Indexer::CheckAudioProperties(int Track, AVCodecContext *Context) {
+     }
+ }
+ 
+-void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict,
++void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict,
+                                     int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct) {
+     if (VideoContext.Parser) {
+         uint8_t *OB;
+@@ -330,8 +330,8 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+         av_parser_parse2(VideoContext.Parser,
+             VideoContext.CodecContext,
+             &OB, &OBSize,
+-            pkt.data, pkt.size,
+-            pkt.pts, pkt.dts, pkt.pos);
++            pkt->data, pkt->size,
++            pkt->pts, pkt->dts, pkt->pos);
+ 
+         // H.264 (PAFF) and HEVC may have one field per packet, so we need to track
+         // when we have a full or half frame available, and mark one of them as
+@@ -351,15 +351,15 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+ 
+         *RepeatPict = VideoContext.Parser->repeat_pict;
+         *FrameType = VideoContext.Parser->pict_type;
+-        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt.flags & AV_PKT_FLAG_DISCARD));
++        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt->flags & AV_PKT_FLAG_DISCARD));
+     } else {
+-        *Invisible = !!(pkt.flags & AV_PKT_FLAG_DISCARD);
++        *Invisible = !!(pkt->flags & AV_PKT_FLAG_DISCARD);
+     }
+ 
+     if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP8)
+-        ParseVP8(pkt.data[0], Invisible, FrameType);
++        ParseVP8(pkt->data[0], Invisible, FrameType);
+     else if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP9)
+-        ParseVP9(pkt.data[0], Invisible, FrameType);
++        ParseVP9(pkt->data[0], Invisible, FrameType);
+ }
+ 
+ void FFMS_Indexer::Free() {
+@@ -458,32 +458,36 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+         }
+     }
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
+     std::vector<int64_t> LastValidTS(FormatContext->nb_streams, AV_NOPTS_VALUE);
+ 
+     int64_t filesize = avio_size(FormatContext->pb);
+     enum AVPictureStructure LastPicStruct = AV_PICTURE_STRUCTURE_UNKNOWN;
+-    while (av_read_frame(FormatContext, &Packet) >= 0) {
++    while (av_read_frame(FormatContext, Packet) >= 0) {
+         // Update progress
+         // FormatContext->pb can apparently be NULL when opening images.
+         if (IC && FormatContext->pb) {
+-            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate))
++            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate)) {
++                av_packet_free(&Packet);
+                 throw FFMS_Exception(FFMS_ERROR_CANCELLED, FFMS_ERROR_USER,
+                     "Cancelled by user");
++            }
+         }
+-        if (!IndexMask.count(Packet.stream_index)) {
+-            av_packet_unref(&Packet);
++        if (!IndexMask.count(Packet->stream_index)) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+-        int Track = Packet.stream_index;
++        int Track = Packet->stream_index;
+         FFMS_Track &TrackInfo = (*TrackIndices)[Track];
+-        bool KeyFrame = !!(Packet.flags & AV_PKT_FLAG_KEY);
++        bool KeyFrame = !!(Packet->flags & AV_PKT_FLAG_KEY);
+         ReadTS(Packet, LastValidTS[Track], (*TrackIndices)[Track].UseDTS);
+ 
+         if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            int64_t PTS = TrackInfo.UseDTS ? Packet.dts : Packet.pts;
++            int64_t PTS = TrackInfo.UseDTS ? Packet->dts : Packet->pts;
+             if (PTS == AV_NOPTS_VALUE) {
+                 // VPx alt-refs are output as packets which lack timestmps or durations, since
+                 // they are invisible. Currently, the timestamp mangling code in libavformat
+@@ -495,9 +499,11 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 // FFMS2 currently sorts packets by PTS, which will break decoding, otherwise.
+                 bool HasAltRefs = (FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP8 ||
+                                    FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP9);
+-                if (Packet.duration == 0 && !HasAltRefs)
++                if (Packet->duration == 0 && !HasAltRefs) {
++                    av_packet_free(&Packet);
+                     throw FFMS_Exception(FFMS_ERROR_INDEXING, FFMS_ERROR_PARSER,
+                         "Invalid packet pts, dts, and duration");
++                }
+ 
+                 if (TrackInfo.empty())
+                     PTS = 0;
+@@ -513,7 +519,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             ParseVideoPacket(AVContexts[Track], Packet, &RepeatPict, &FrameType, &Invisible, &LastPicStruct);
+ 
+             TrackInfo.AddVideoFrame(PTS, RepeatPict, KeyFrame,
+-                FrameType, Packet.pos, Invisible);
++                FrameType, Packet->pos, Invisible);
+         } else if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+             // For video seeking timestamps are used only if all packets have
+             // timestamps, while for audio they're used if any have timestamps,
+@@ -522,28 +528,29 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 TrackInfo.HasTS = true;
+ 
+             int64_t StartSample = AVContexts[Track].CurrentSample;
+-            uint32_t SampleCount = IndexAudioPacket(Track, &Packet, AVContexts[Track], *TrackIndices);
++            uint32_t SampleCount = IndexAudioPacket(Track, Packet, AVContexts[Track], *TrackIndices);
+             TrackInfo.SampleRate = AVContexts[Track].CodecContext->sample_rate;
+ 
+             TrackInfo.AddAudioFrame(LastValidTS[Track],
+-                StartSample, SampleCount, KeyFrame, Packet.pos, Packet.flags & AV_PKT_FLAG_DISCARD);
++                StartSample, SampleCount, KeyFrame, Packet->pos, Packet->flags & AV_PKT_FLAG_DISCARD);
+         }
+ 
+-        if (!(Packet.flags & AV_PKT_FLAG_DISCARD))
+-            TrackInfo.LastDuration = Packet.duration;
++        if (!(Packet->flags & AV_PKT_FLAG_DISCARD))
++            TrackInfo.LastDuration = Packet->duration;
+ 
+-        av_packet_unref(&Packet);
++        av_packet_unref(Packet);
+     }
++    av_packet_free(&Packet);
+ 
+     TrackIndices->Finalize(AVContexts, FormatContext->iformat->name);
+     return TrackIndices.release();
+ }
+ 
+-void FFMS_Indexer::ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS) {
+-    if (!UseDTS && Packet.pts != AV_NOPTS_VALUE)
+-        TS = Packet.pts;
++void FFMS_Indexer::ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS) {
++    if (!UseDTS && Packet->pts != AV_NOPTS_VALUE)
++        TS = Packet->pts;
+     if (TS == AV_NOPTS_VALUE)
+         UseDTS = true;
+-    if (UseDTS && Packet.dts != AV_NOPTS_VALUE)
+-        TS = Packet.dts;
++    if (UseDTS && Packet->dts != AV_NOPTS_VALUE)
++        TS = Packet->dts;
+ }
+diff --git a/src/core/indexing.h b/src/core/indexing.h
+index 3cfc3c3..5c06868 100644
+--- a/src/core/indexing.h
++++ b/src/core/indexing.h
+@@ -80,10 +80,10 @@ private:
+     int64_t Filesize;
+     uint8_t Digest[20];
+ 
+-    void ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS);
++    void ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS);
+     void CheckAudioProperties(int Track, AVCodecContext *Context);
+     uint32_t IndexAudioPacket(int Track, AVPacket *Packet, SharedAVContext &Context, FFMS_Index &TrackIndices);
+-    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
++    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
+     void Free();
+ public:
+     FFMS_Indexer(const char *Filename);
+diff --git a/src/core/utils.cpp b/src/core/utils.cpp
+index ce67533..8a2e997 100644
+--- a/src/core/utils.cpp
++++ b/src/core/utils.cpp
+@@ -62,12 +62,6 @@ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo) {
+     }
+ }
+ 
+-void InitNullPacket(AVPacket &pkt) {
+-    av_init_packet(&pkt);
+-    pkt.data = nullptr;
+-    pkt.size = 0;
+-}
+-
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames) {
+     AP.SampleFormat = static_cast<FFMS_SampleFormat>(av_get_packed_sample_fmt(CTX->sample_fmt));
+     AP.BitsPerSample = av_get_bytes_per_sample(CTX->sample_fmt) * 8;
+diff --git a/src/core/utils.h b/src/core/utils.h
+index 9819dc7..003ab79 100644
+--- a/src/core/utils.h
++++ b/src/core/utils.h
+@@ -58,7 +58,6 @@ std::unique_ptr<T> make_unique(Args&&... args) {
+ }
+ 
+ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo);
+-void InitNullPacket(AVPacket &pkt);
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames);
+ 
+ void LAVFOpenFile(const char *SourceFile, AVFormatContext *&FormatContext, int Track);
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index 06bd161..b889970 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -673,30 +673,34 @@ void FFMS_VideoSource::DecodeNextFrame(int64_t &AStartTime, int64_t &Pos) {
+     if (HasPendingDelayedFrames())
+         return;
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
+-
+-    while (ReadFrame(&Packet) >= 0) {
+-        if (Packet.stream_index != VideoTrack) {
+-            av_packet_unref(&Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++
++    while (ReadFrame(Packet) >= 0) {
++        if (Packet->stream_index != VideoTrack) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+         if (AStartTime < 0)
+-            AStartTime = Frames.UseDTS ? Packet.dts : Packet.pts;
++            AStartTime = Frames.UseDTS ? Packet->dts : Packet->pts;
+ 
+         if (Pos < 0)
+-            Pos = Packet.pos;
++            Pos = Packet->pos;
+ 
+-        bool FrameFinished = DecodePacket(&Packet);
+-        av_packet_unref(&Packet);
+-        if (FrameFinished)
++        bool FrameFinished = DecodePacket(Packet);
++        av_packet_unref(Packet);
++        if (FrameFinished) {
++            av_packet_free(&Packet);
+             return;
++        }
+     }
+ 
+     // Flush final frames
+-    InitNullPacket(Packet);
+-    DecodePacket(&Packet);
++    DecodePacket(Packet);
++    av_packet_free(&Packet);
+ }
+ 
+ bool FFMS_VideoSource::SeekTo(int n, int SeekOffset) {
+-- 
+2.40.0
+
+From bf9e03e9e08534c024e5a744a6437c4aac160201 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:20:47 +0100
+Subject: [PATCH 2/3] configure: Remove deprecated API use
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ configure.ac | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index b35ef80bc..d19714d0f 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -102,10 +102,10 @@ CFLAGS="$_CFLAGS $FFMPEG_CFLAGS"
+
+ AC_DEFUN([TEST_FFMPEG],
+          [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+-            #include <libavcodec/avcodec.h>
++            #include <libavformat/avformat.h>
+             #include <libswscale/swscale.h>
+             ]],[[
+-                avcodec_register_all();
++                avformat_network_init();
+                 swscale_version();
+             ]])], [eval $1=yes], [eval $1=no])
+         ])
+
diff --git a/srcpkgs/ffms2/template b/srcpkgs/ffms2/template
index 365f64d10cbabf..1641ecf43be5bb 100644
--- a/srcpkgs/ffms2/template
+++ b/srcpkgs/ffms2/template
@@ -1,7 +1,7 @@
 # Template file for 'ffms2'
 pkgname=ffms2
 version=2.40
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-shared --disable-static"
 hostmakedepends="pkg-config autoconf automake libtool"

From 7877f8511f387a9dac968b7503f3b7ef4b3b4a9a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 030/108] freerdp: revbump for ffmpeg6

---
 .../freerdp/patches/ffmpeg6_aa2cb9aa.patch    | 42 +++++++++++++++++++
 srcpkgs/freerdp/template                      |  2 +-
 2 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch

diff --git a/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
new file mode 100644
index 00000000000000..a4324da3a8822b
--- /dev/null
+++ b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
@@ -0,0 +1,42 @@
+From aa2cb9aa5ff5562433598ba168a466e0752bca0e Mon Sep 17 00:00:00 2001
+From: akallabeth <akallabeth@posteo.net>
+Date: Tue, 14 Feb 2023 07:48:54 +0100
+Subject: [PATCH] Fixed #8686: Update h264 to use new FFMPEG API
+
+---
+ channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c | 2 ++
+ libfreerdp/codec/h264_ffmpeg.c            | 2 ++
+ 2 files changed, 4 insertions(+)
+
+diff --git a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+index 339462d865f..beea80b7a1e 100644
+--- a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
++++ b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+@@ -239,8 +239,10 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYP
+ 		}
+ 	}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 	if (mdecoder->codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		mdecoder->codec_context->flags |= AV_CODEC_FLAG_TRUNCATED;
++#endif
+ 
+ 	return TRUE;
+ }
+diff --git a/libfreerdp/codec/h264_ffmpeg.c b/libfreerdp/codec/h264_ffmpeg.c
+index 8a23db2473c..896a333019b 100644
+--- a/libfreerdp/codec/h264_ffmpeg.c
++++ b/libfreerdp/codec/h264_ffmpeg.c
+@@ -615,10 +615,12 @@ static BOOL libavcodec_init(H264_CONTEXT* h264)
+ 			goto EXCEPTION;
+ 		}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 		if (sys->codecDecoder->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		{
+ 			sys->codecDecoderContext->flags |= AV_CODEC_FLAG_TRUNCATED;
+ 		}
++#endif
+ 
+ #ifdef WITH_VAAPI
+ 
diff --git a/srcpkgs/freerdp/template b/srcpkgs/freerdp/template
index 16fddfbe8f5287..bf3a4d2e2b3ae7 100644
--- a/srcpkgs/freerdp/template
+++ b/srcpkgs/freerdp/template
@@ -1,7 +1,7 @@
 # Template file for 'freerdp'
 pkgname=freerdp
 version=2.11.4
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_ALSA=ON -DWITH_CUPS=OFF -DWITH_FFMPEG=ON
  -DWITH_GSTREAMER_0_10=OFF -DWITH_GSTREAMER_1_0=OFF -DWITH_JPEG=ON

From 9f5c9907414caead179b68d595ec970fc0161c2d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 031/108] gerbera: revbump for ffmpeg6

---
 srcpkgs/gerbera/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gerbera/template b/srcpkgs/gerbera/template
index ae14f35c767c03..2dc0ac0ce03b55 100644
--- a/srcpkgs/gerbera/template
+++ b/srcpkgs/gerbera/template
@@ -1,7 +1,7 @@
 # Template file for 'gerbera'
 pkgname=gerbera
 version=1.12.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_SYSTEMD=0 -DWITH_AVCODEC=1"
 hostmakedepends="pkg-config"

From a5a48d8ee36ce99caa264fdb0fc5a831ec06c04f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 032/108] goldendict: revbump for ffmpeg6

---
 srcpkgs/goldendict/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/goldendict/template b/srcpkgs/goldendict/template
index f4a05759f693d3..97f44347b03a6a 100644
--- a/srcpkgs/goldendict/template
+++ b/srcpkgs/goldendict/template
@@ -1,7 +1,7 @@
 # Template file for 'goldendict'
 pkgname=goldendict
 version=1.5.0
-revision=1
+revision=2
 build_style=qmake
 configure_args="CONFIG+=zim_support goldendict.pro"
 hostmakedepends="qt5-qmake pkg-config qt5-host-tools"
@@ -10,7 +10,7 @@ makedepends="tiff-devel qt5-devel libvorbis-devel zlib-devel
  qt5-webkit-devel lzo-devel bzip2-devel libao-devel qt5-svg-devel
  libeb-devel qt5-x11extras-devel ffmpeg-devel liblzma-devel
  qt5-multimedia-devel"
-short_desc="A feature-rich dictionary lookup program"
+short_desc="Feature-rich dictionary lookup program"
 maintainer="John <me@johnnynator.dev>"
 license="GPL-3.0-or-later"
 homepage="http://goldendict.org/"

From 767c7706bbb0d2aa1dfc770524800fe11dd55a0c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 033/108] gst-libav: revbump for ffmpeg6

---
 srcpkgs/gst-libav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index e02c0deafc6d24..3b82a28e99c970 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.24.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"

From 1d1f22807e72d8e1577ce811106dd7a1c4a4573a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Feb 2024 01:52:46 -0500
Subject: [PATCH 034/108] gst-plugins-bad1: revbump for ffmpeg6

---
 srcpkgs/gst-plugins-bad1/template | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index 0712c756c00e60..5bb0986fb26953 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-plugins-bad1'
 pkgname=gst-plugins-bad1
 version=1.24.0
-revision=1
+revision=2
 build_helper="gir"
 build_style=meson
 configure_args="-Dpackage-origin=https://voidlinux.org -Ddoc=disabled
@@ -27,8 +27,7 @@ makedepends="alsa-lib-devel celt-devel openssl-devel exempi-devel
  fdk-aac-devel flite-devel fluidsynth-devel liblrdf-devel ladspa-sdk
  lilv-devel lv2 libopenjpeg2-devel sbc-devel spandsp-devel vulkan-loader
  Vulkan-Headers webrtc-audio-processing-devel libzbar-devel ffmpeg-devel
- srt-devel libva-devel
- $(vopt_if gme libgme-devel)"
+ srt-devel libva-devel $(vopt_if onevpl oneVPL-devel) $(vopt_if gme libgme-devel)"
 depends="gst-plugins-base1>=${version}"
 short_desc="GStreamer plugins from the bad set (v1.x)"
 maintainer="Orphaned <orphan@voidlinux.org>"
@@ -38,7 +37,7 @@ changelog="https://gstreamer.freedesktop.org/releases/${version%.*}/#${version}"
 distfiles="https://gstreamer.freedesktop.org/src/gst-plugins-bad/gst-plugins-bad-${version}.tar.xz"
 checksum=d23c3a1a79c425d21078b4892c3302a1d4930d67b83dfa8e03df416fc3f97eba
 
-build_options="gir gme wayland"
+build_options="gir gme onevpl wayland"
 build_options_default="gir wayland"
 desc_option_gme="Build with Game Music Emulator support"
 
@@ -46,6 +45,7 @@ CFLAGS="-fcommon"
 
 case "$XBPS_TARGET_MACHINE" in
 	mips*) ;; # libgme cannot be built for mips*
+	x86_64*) build_options_default+=" gme onevpl" ;; # onevpl only supports 64bit
 	*) build_options_default+=" gme" ;;
 esac
 

From bc9649c9dc8691d6c67df0d9bfee91c5b1594c7e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 035/108] gst-rtsp-server: revbump for ffmpeg6

---
 srcpkgs/gst-rtsp-server/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index 4ace541d36e324..837b1bc0d14118 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
 version=1.24.0
-revision=1
+revision=2
 build_style=meson
 build_helper=gir
 configure_args="-Dintrospection=enabled"

From 954807af6172bac1f28fa14e7a2c5ed85a95e329 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 036/108] guvcview: update to 2.0.8.

---
 srcpkgs/guvcview/patches/fix-include.patch | 10 ++++++++++
 srcpkgs/guvcview/template                  |  7 +++----
 2 files changed, 13 insertions(+), 4 deletions(-)
 create mode 100644 srcpkgs/guvcview/patches/fix-include.patch

diff --git a/srcpkgs/guvcview/patches/fix-include.patch b/srcpkgs/guvcview/patches/fix-include.patch
new file mode 100644
index 00000000000000..503c2af3b78c1a
--- /dev/null
+++ b/srcpkgs/guvcview/patches/fix-include.patch
@@ -0,0 +1,10 @@
+--- a/guvcview/guvcview.c
++++ b/guvcview/guvcview.c
+@@ -28,6 +28,7 @@
+ #include <sys/stat.h>
+ #include <sys/resource.h>
+ #include <errno.h>
++#include <locale.h>
+ 
+ #include "gview.h"
+ #include "gviewv4l2core.h"
diff --git a/srcpkgs/guvcview/template b/srcpkgs/guvcview/template
index d42fd38fa4ad12..86a7fd619612c8 100644
--- a/srcpkgs/guvcview/template
+++ b/srcpkgs/guvcview/template
@@ -1,8 +1,7 @@
 # Template file for 'guvcview'
 pkgname=guvcview
-version=2.0.7
-revision=2
-create_wrksrc=yes
+version=2.0.8
+revision=1
 build_style=gnu-configure
 configure_args="--disable-static --disable-debian-menu"
 hostmakedepends="pkg-config intltool autoconf automake libtool glib-devel"
@@ -14,7 +13,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="http://guvcview.sourceforge.net/"
 distfiles="${SOURCEFORGE_SITE}/${pkgname}/${pkgname}-src-${version}.tar.bz2"
-checksum=f47d51fbd06e44eeaa1a82f4a153c927527c90d94514197a70b2956028cc8ad4
+checksum=a21f4e448286666cf27bafef5290cc953a0a1796b752e5bbe521266dc1230c81
 
 post_patch() {
 	sed '31a#include <locale.h>' -i  guvcview/guvcview.c

From 3343dc4ebc71a0597b7351e6f603fcdd6490e24d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 037/108] handbrake: update to 1.6.1

---
 .../patches/fix-missing-x265-link-flag.patch    | 11 ++++++-----
 .../handbrake/patches/libhb-vpl-include.patch   | 15 +++++++++++++++
 srcpkgs/handbrake/template                      | 17 ++++++++++-------
 3 files changed, 31 insertions(+), 12 deletions(-)
 create mode 100644 srcpkgs/handbrake/patches/libhb-vpl-include.patch

diff --git a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
index 26db03867a0c83..d6bb2eda627a36 100644
--- a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
+++ b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
@@ -1,14 +1,15 @@
 --- a/gtk/configure.ac
 +++ b/gtk/configure.ac
 @@ -203,7 +203,7 @@
- 
+
  AM_CONDITIONAL([MINGW], [test "x$mingw_flag" = "xyes"])
- 
--HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg"
-+HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -ldl"
+
+-HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc"
++HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc -ldl"
  HB_CPPFLAGS="$HB_CPPFLAGS $HBINC"
- 
+
  PKG_CHECK_MODULES([x264], [x264], sys_x264=yes, sys_x264=no)
+
 --- a/test/module.defs
 +++ b/test/module.defs
 @@ -69,6 +69,9 @@
diff --git a/srcpkgs/handbrake/patches/libhb-vpl-include.patch b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
new file mode 100644
index 00000000000000..298f9f4ab28f2a
--- /dev/null
+++ b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
@@ -0,0 +1,15 @@
+--- a/libhb/module.defs	2023-01-22 11:36:49.000000000 -0500
++++ b/libhb/module.defs	2023-04-03 22:37:52.395467010 -0400
+@@ -46,11 +46,7 @@
+ LIBHB.GCC.I += $(LIBHB.build/) $(CONTRIB.build/)include
+ 
+ ifeq (1,$(FEATURE.qsv))
+-    ifeq ($(HOST.system),freebsd))
+-        LIBHB.GCC.I += $(LOCALBASE)/include/vpl
+-    else
+-        LIBHB.GCC.I += $(CONTRIB.build/)include/vpl
+-    endif
++    LIBHB.GCC.I += /usr/include/vpl
+ endif
+ 
+ ifneq (,$(filter $(HOST.system),freebsd netbsd openbsd))
diff --git a/srcpkgs/handbrake/template b/srcpkgs/handbrake/template
index ca5e4571e49c37..c32cb1bfa31f4b 100644
--- a/srcpkgs/handbrake/template
+++ b/srcpkgs/handbrake/template
@@ -1,10 +1,10 @@
 # Template file for 'handbrake'
 pkgname=handbrake
-version=1.5.1
+version=1.6.1
 revision=1
 build_style=gnu-configure
 configure_args="--force --disable-gtk-update-checks --disable-df-fetch --harden
- $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc)"
+ $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc) $(vopt_enable qsv)"
 make_build_args="-C ${XBPS_TRIPLET}"
 make_install_args="-C ${XBPS_TRIPLET}"
 hostmakedepends="automake cmake gettext-devel glib-devel intltool libtool m4 meson nasm pkg-config python3"
@@ -12,8 +12,11 @@ makedepends="bzip2-devel ffmpeg-devel gst-plugins-base1-devel gtk+3-devel
  jansson-devel lame-devel libass-devel libbluray-devel libdav1d-devel
  libdvdnav-devel libdvdread-devel libgudev-devel libnuma-devel
  libsamplerate-devel libtheora-devel libvorbis-devel libvpx-devel libxml2-devel
- opus-devel speex-devel x264-devel x265-devel zimg-devel
+ opus-devel speex-devel x264-devel x265-devel zimg-devel libsvt-av1-devel
  $(vopt_if fdk_aac fdk-aac-devel)
+ $(vopt_if qsv libva-devel)
+ $(vopt_if qsv libdrm-devel)
+ $(vopt_if qsv onevpl-devel)
  $(vopt_if nvenc nv-codec-headers)"
 depends="desktop-file-utils gst-plugins-good1 hicolor-icon-theme"
 short_desc="Multithreaded video transcoder"
@@ -21,15 +24,15 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-2.0-only"
 homepage="https://handbrake.fr/"
 distfiles="https://github.com/HandBrake/HandBrake/releases/download/${version}/HandBrake-${version}-source.tar.bz2"
-checksum=3999fe06d5309c819799a73a968a8ec3840e7840c2b64af8f5cdb7fd8c9430f0
+checksum=94ccfe03db917a91650000c510f7fd53f844da19f19ad4b4be1b8f6bc31a8d4c
 nocross=yes
 
-build_options="fdk_aac nvenc"
+build_options="fdk_aac nvenc qsv"
 
 case "$XBPS_TARGET_MACHINE" in
 	x86_64*|i686*)
 		CFLAGS="-msse"
-		build_options_default="nvenc"
+		build_options_default="nvenc qsv"
 		;;
 esac
 
@@ -37,7 +40,7 @@ pre_configure() {
 	# use system libraries, don't download them
 	rm -rf contrib/
 	for module in fdk-aac ffmpeg libbluray libdav1d libdvdnav libdvdread nvenc \
-		x265 zimg; do
+		x265 zimg svt-av1 libvpl; do
 	    vsed -i "/MODULES += contrib\/${module}/d" make/include/main.defs
 	done
 }

From d11382630b8bd8590cb1673112606add471fd04f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 038/108] hedgewars: revbump for ffmpeg4

---
 srcpkgs/hedgewars/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/hedgewars/template b/srcpkgs/hedgewars/template
index 94b6db673b0c3a..402ccfaaecbc2d 100644
--- a/srcpkgs/hedgewars/template
+++ b/srcpkgs/hedgewars/template
@@ -1,13 +1,13 @@
 # Template file for 'hedgewars'
 pkgname=hedgewars
 version=1.0.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DNOSERVER=1 -DDATA_INSTALL_DIR=/usr/share/${pkgname}
  -DPHYSFS_SYSTEM=1 -DMINIMAL_FLAGS=1"
 make_cmd=make
 hostmakedepends="lua51 pkg-config qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
+makedepends="ffmpeg4-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
  SDL2_mixer-devel SDL2_net-devel SDL2_ttf-devel"
 depends="libfreeglut"
 short_desc="Funny turn-based artillery game, featuring fighting Hedgehogs!"

From 816283cc660e1b42d1a2aa89552c9b8527a30a57 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 039/108] idjc: revbump for ffmpeg4

---
 srcpkgs/idjc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/idjc/template b/srcpkgs/idjc/template
index a9cde0665d55b1..f41e1e4fabbae7 100644
--- a/srcpkgs/idjc/template
+++ b/srcpkgs/idjc/template
@@ -1,11 +1,11 @@
 # Template file for 'idjc'
 pkgname=idjc
 version=0.9.1
-revision=5
+revision=6
 build_style=gnu-configure
 hostmakedepends="pkg-config git python3 automake gettext-devel libtool"
 makedepends="libvorbis-devel libogg-devel jack-devel libsamplerate-devel
- libflac-devel libsndfile-devel mpg123-devel ffmpeg-devel speex-devel
+ libflac-devel libsndfile-devel mpg123-devel ffmpeg4-devel speex-devel
  glib-devel pixman-devel lame-devel python3-gobject-devel libshout-idjc-devel
  opus-devel twolame-devel python3-mutagen python3-devel"
 depends="python3-gobject python3-mutagen desktop-file-utils shared-mime-info python3-dbus jack"

From 97f2ba151aaad41b7a4bff7db28fb023e050ac6d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 040/108] kid3: revbump for ffmpeg6

---
 srcpkgs/kid3/patches/ffmpeg5.patch | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 srcpkgs/kid3/patches/ffmpeg5.patch

diff --git a/srcpkgs/kid3/patches/ffmpeg5.patch b/srcpkgs/kid3/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..135fc50e07c9ba
--- /dev/null
+++ b/srcpkgs/kid3/patches/ffmpeg5.patch
@@ -0,0 +1,17 @@
+# https://aur.archlinux.org/cgit/aur.git/diff/ffmpeg5.patch?h=kid3-cli&id=12410a74906612e7efc0ec8fbce739b4a0fef7e7
+diff --git a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+index e156d424..e12b9abd 100644
+--- a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
++++ b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+@@ -232,7 +232,11 @@ private:
+   friend class Format;
+   friend class Converter;
+   AVCodecContext* m_ptr;
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 0, 0)
+   AVCodec* m_impl;
++#else
++  const AVCodec* m_impl;
++#endif
+   AVFrame* m_frame;
+   bool m_opened;
+ };

From 459529dc5c6e4fdee480c6f876579c10e0facd5c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 041/108] kodi: revbump for ffmpeg4

---
 srcpkgs/kodi/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/kodi/template b/srcpkgs/kodi/template
index d37a5918cd6758..ea78e0aca0fe3e 100644
--- a/srcpkgs/kodi/template
+++ b/srcpkgs/kodi/template
@@ -1,7 +1,7 @@
 # Template file for 'kodi'
 pkgname=kodi
 version=19.4
-revision=9
+revision=10
 _codename="Matrix"
 build_style=cmake
 configure_args="-DWITH_FFMPEG=/usr -DENABLE_LDGOLD=OFF
@@ -54,7 +54,7 @@ makedepends="
  libmad-devel fontconfig-devel libXinerama-devel libsamplerate-devel libmms-devel
  enca-devel boost-devel libcurl-devel libva-devel libvdpau-devel libass-devel
  libbluetooth-devel yajl-devel libplist-devel librtmp-devel tinyxml-devel
- taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg-devel
+ taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg4-devel
  giflib-devel libxslt-devel gnutls-devel libssh-devel libmicrohttpd-devel
  libcec-devel dcadec-devel flatbuffers-devel fmt-devel lcms2-devel
  libfstrcmp-devel rapidjson libcdio-paranoia spdlog libwaylandpp-devel

From 143d72ce3e754b1c44980c29af8750e5e4da2680 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 042/108] kpipewire: revbump for ffmpeg6

---
 srcpkgs/kpipewire/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kpipewire/template b/srcpkgs/kpipewire/template
index 24f5f152749c97..d5ac3788ff586a 100644
--- a/srcpkgs/kpipewire/template
+++ b/srcpkgs/kpipewire/template
@@ -1,7 +1,7 @@
 # Template file for 'kpipewire'
 pkgname=kpipewire
 version=5.27.11
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules plasma-wayland-protocols gettext
  qt5-qmake qt5-host-tools pkg-config wayland-devel kcoreaddons

From 72551f465bba68046a6e8b10687a2f29d4762287 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 043/108] libopenal: revbump for ffmpeg6

---
 srcpkgs/libopenal/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenal/template b/srcpkgs/libopenal/template
index 88d0f11307d81a..8308fca0393e33 100644
--- a/srcpkgs/libopenal/template
+++ b/srcpkgs/libopenal/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenal'
 pkgname=libopenal
 version=1.23.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DALSOFT_EXAMPLES=OFF"
 hostmakedepends="pkg-config"

From 92fad30529644f072a73bbc7e686f5e6e5722f19 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 044/108] loudgain: revbump for ffmpeg6

---
 srcpkgs/loudgain/patches/ffmpeg5.patch | 11 +++++++++++
 srcpkgs/loudgain/template              |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/loudgain/patches/ffmpeg5.patch

diff --git a/srcpkgs/loudgain/patches/ffmpeg5.patch b/srcpkgs/loudgain/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..16d4510ee98faa
--- /dev/null
+++ b/srcpkgs/loudgain/patches/ffmpeg5.patch
@@ -0,0 +1,11 @@
+--- a/src/scan.c	2019-09-06 11:31:19.000000000 -0400
++++ b/src/scan.c	2023-03-23 11:15:40.867968521 -0400
+@@ -69,8 +69,6 @@
+ 	 * It is now useless
+ 	 * https://github.com/FFmpeg/FFmpeg/blob/70d25268c21cbee5f08304da95be1f647c630c15/doc/APIchanges#L86
+ 	 */
+-  if (avformat_version() < AV_VERSION_INT(58,9,100))
+-    av_register_all();
+ 
+ 	av_log_set_callback(scan_av_log);
+ 
diff --git a/srcpkgs/loudgain/template b/srcpkgs/loudgain/template
index da4f2d56e94c3d..4d6bf29efb4fdd 100644
--- a/srcpkgs/loudgain/template
+++ b/srcpkgs/loudgain/template
@@ -1,7 +1,7 @@
 # Template file for 'loudgain'
 pkgname=loudgain
 version=0.6.8
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libebur128-devel taglib-devel ffmpeg-devel"

From fb9f7910a755f990505a7ba13c1b19aa6a22d48f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 045/108] mediastreamer: revbump for ffmpeg4

---
 srcpkgs/mediastreamer/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mediastreamer/template b/srcpkgs/mediastreamer/template
index 0fcffa7653d18e..e888626b945e55 100644
--- a/srcpkgs/mediastreamer/template
+++ b/srcpkgs/mediastreamer/template
@@ -1,11 +1,11 @@
 # Template file for 'mediastreamer'
 pkgname=mediastreamer
 version=5.2.111
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DENABLE_STRICT=0 -DENABLE_UNIT_TESTS=0"
 hostmakedepends="python3"
-makedepends="bzrtp-devel ffmpeg-devel glew-devel libXv-devel libsrtp-devel
+makedepends="bzrtp-devel ffmpeg4-devel glew-devel libXv-devel libsrtp-devel
  libupnp-devel libvpx-devel mbedtls-devel opus-devel ortp-devel pulseaudio-devel
  libtheora-devel speex-devel v4l-utils-devel bcg729-devel bcmatroska2-devel libgsm-devel
  zxing-cpp-devel"

From 461e99fcb8413b08f108febd7defa7aa099ec39e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 046/108] mgba: revbump for ffmpeg6

---
 srcpkgs/mgba/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mgba/template b/srcpkgs/mgba/template
index 6cd65650312543..93401adb618bd8 100644
--- a/srcpkgs/mgba/template
+++ b/srcpkgs/mgba/template
@@ -1,7 +1,7 @@
 # Template file for 'mgba'
 pkgname=mgba
 version=0.10.3
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake desktop-file-utils"
 makedepends="SDL2-devel ffmpeg-devel libedit-devel libepoxy-devel libmagick-devel

From 619c8f01b27631aa7538e16242e90aac1301cf77 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 047/108] mlt: revbump for ffmpeg4

---
 srcpkgs/mlt/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mlt/template b/srcpkgs/mlt/template
index 73e3915aaab9ac..d7ed4c4b30a868 100644
--- a/srcpkgs/mlt/template
+++ b/srcpkgs/mlt/template
@@ -1,14 +1,14 @@
 # Template file for 'mlt'
 pkgname=mlt
 version=6.26.1
-revision=3
+revision=4
 build_style=configure
 configure_args="--prefix=/usr --libdir=/usr/lib$XBPS_TARGET_WORDSIZE
  --enable-gpl --enable-gpl3 --disable-swfdec --without-kde
  --swig-languages=python"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which"
 # XXX: movit vid.stab
-makedepends="alsa-lib-devel ffmpeg-devel gtk+-devel jack-devel ladspa-sdk
+makedepends="alsa-lib-devel ffmpeg4-devel gtk+-devel jack-devel ladspa-sdk
  libexif-devel libsamplerate-devel libxml2-devel sox-devel SDL_image-devel
  fftw-devel frei0r-plugins python3-devel pulseaudio-devel movit-devel
  libvidstab-devel"

From c200a229897b5dad4086640ea2e9e7108c7c3b09 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 048/108] moc: revbump for ffmpeg4

---
 srcpkgs/moc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/moc/template b/srcpkgs/moc/template
index 3a04932c8f1e61..838755f88db09e 100644
--- a/srcpkgs/moc/template
+++ b/srcpkgs/moc/template
@@ -1,10 +1,10 @@
 # Template file for 'moc'
 pkgname=moc
 version=2.5.2
-revision=7
+revision=8
 build_style=gnu-configure
 hostmakedepends="pkg-config"
-makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg-devel
+makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg4-devel
  jack-devel alsa-lib-devel libltdl-devel libflac-devel libvorbis-devel
  libmad-devel libmpcdec-devel libmodplug-devel libid3tag-devel faad2-devel
  taglib-devel libsndfile-devel wavpack-devel speex-devel libsamplerate-devel

From e004461e048c64a902016bfeb846ebed949a6c86 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 049/108] motion: revbump for ffmpeg6

---
 srcpkgs/motion/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/motion/template b/srcpkgs/motion/template
index 607ebeb3c7b242..bf63a91d9764f6 100644
--- a/srcpkgs/motion/template
+++ b/srcpkgs/motion/template
@@ -1,7 +1,7 @@
 # Template file for 'motion'
 pkgname=motion
 version=4.6.0
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake pkg-config gettext-devel tar"
 makedepends="ffmpeg-devel libmicrohttpd-devel v4l-utils-devel gettext-devel"

From 69f3d10308111a276ddc1f0bbc2aa9c2d4ae3061 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 050/108] olive: revbump for ffmpeg4

---
 srcpkgs/olive/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/olive/template b/srcpkgs/olive/template
index 12a46936c99003..5c2917b9c51245 100644
--- a/srcpkgs/olive/template
+++ b/srcpkgs/olive/template
@@ -1,10 +1,10 @@
 # Template file for 'olive'
 pkgname=olive
 version=0.1.2
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools pkg-config"
-makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg-devel frei0r-plugins"
+makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg4-devel frei0r-plugins"
 short_desc="Non-linear video editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"

From 23748290000b83f31f293ad62b8936692f66f888 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 051/108] opentoonz: revbump for ffmpeg6

---
 srcpkgs/opentoonz/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/opentoonz/template b/srcpkgs/opentoonz/template
index ee9f7603f55fd8..3e81834ca0eddf 100644
--- a/srcpkgs/opentoonz/template
+++ b/srcpkgs/opentoonz/template
@@ -1,7 +1,7 @@
 # Template file for 'opentoonz'
 pkgname=opentoonz
 version=1.6.0
-revision=2
+revision=3
 build_wrksrc="toonz/sources"
 build_style=cmake
 make_cmd=make

From 390d9f02c5d1cce2cce1bc1d2a9732a986399676 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 052/108] pianobar: revbump for ffmpeg6

---
 srcpkgs/pianobar/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pianobar/template b/srcpkgs/pianobar/template
index e3febb821a4510..1e3dc1bf9308ee 100644
--- a/srcpkgs/pianobar/template
+++ b/srcpkgs/pianobar/template
@@ -1,7 +1,7 @@
 # Template file for 'pianobar'
 pkgname=pianobar
 version=2022.04.01
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="V=1"
 hostmakedepends="pkg-config"

From 0ecf60b5714538aa2935cfaf8993fbf8e141aabf Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 053/108] ppsspp: revbump for ffmpeg6

---
 srcpkgs/ppsspp/patches/ffmpeg6.patch | 15 +++++++++++++++
 srcpkgs/ppsspp/template              |  3 +--
 2 files changed, 16 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/ppsspp/patches/ffmpeg6.patch

diff --git a/srcpkgs/ppsspp/patches/ffmpeg6.patch b/srcpkgs/ppsspp/patches/ffmpeg6.patch
new file mode 100644
index 00000000000000..5803c7bf227309
--- /dev/null
+++ b/srcpkgs/ppsspp/patches/ffmpeg6.patch
@@ -0,0 +1,15 @@
+--- a/Core/HW/SimpleAudioDec.cpp	2024-02-04 08:08:02.000000000 -0500
++++ b/Core/HW/SimpleAudioDec.cpp	2024-02-15 14:48:27.114362051 -0500
+@@ -81,7 +81,11 @@
+ 		return;
+ 	}
+ 	// Find decoder
++#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(58, 18, 100)
+ 	codec_ = avcodec_find_decoder((AVCodecID)audioCodecId);
++#else // this is a macro to const in the header
++	codec_ = (AVCodec*)avcodec_find_decoder((AVCodecID)audioCodecId);
++#endif
+ 	if (!codec_) {
+ 		// Eh, we shouldn't even have managed to compile. But meh.
+ 		ERROR_LOG(ME, "This version of FFMPEG does not support AV_CODEC_ctx for audio (%s). Update your submodule.", GetCodecName(audioType));
+
diff --git a/srcpkgs/ppsspp/template b/srcpkgs/ppsspp/template
index 2238a7601c0af8..1fda55268a2d39 100644
--- a/srcpkgs/ppsspp/template
+++ b/srcpkgs/ppsspp/template
@@ -1,7 +1,7 @@
 # Template file for 'ppsspp'
 pkgname=ppsspp
 version=1.17.1
-revision=1
+revision=2
 _glslang_commit=b34f619e1c85810dcb3c578107d2e48ba4ee2b37
 _SPIRV_Cross_commit=4212eef67ed0ca048cb726a6767185504e7695e5
 _armips_commit=a8d71f0f279eb0d30ecf6af51473b66ae0cf8e8d
@@ -91,7 +91,6 @@ post_configure() {
 }
 
 do_install() {
-	vlicense LICENSE.TXT
 	vinstall icons/icon.svg 644 usr/share/pixmaps ppsspp.svg
 	vinstall Qt/PPSSPP.desktop 644 usr/share/applications
 	vbin build/PPSSPPHeadless ppsspp-headless

From 924f9cb350dd92dc7c5a2c3da8218c729dae3512 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 054/108] pqiv: revbump for ffmpeg6

---
 srcpkgs/pqiv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pqiv/template b/srcpkgs/pqiv/template
index f9f7751196d4ee..0d50777e56a2d8 100644
--- a/srcpkgs/pqiv/template
+++ b/srcpkgs/pqiv/template
@@ -1,7 +1,7 @@
 # Template file for 'pqiv'
 pkgname=pqiv
 version=2.13.1
-revision=1
+revision=2
 build_style=gnu-makefile
 hostmakedepends="pkg-config"
 makedepends="glib-devel gtk+3-devel $(vopt_if ffmpeg ffmpeg-devel)

From 4448eb290e23921694c885f8910dd96d06f3b4c6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 055/108] qmmp: revbump for ffmpeg6

---
 srcpkgs/qmmp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qmmp/template b/srcpkgs/qmmp/template
index 53781ea3bc28ad..2da07f1e87eac0 100644
--- a/srcpkgs/qmmp/template
+++ b/srcpkgs/qmmp/template
@@ -1,7 +1,7 @@
 # Template file for 'qmmp'
 pkgname=qmmp
 version=1.6.1
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DUSE_HAL:BOOL=FALSE -DQMMP_DEFAULT_UI:STRING=simple"
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From 2425cd73b7fb5b712c7bf883f2d47cb69ad98b44 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 14 Dec 2023 13:28:10 -0500
Subject: [PATCH 056/108] qt6-pdf: revbump for ffmpeg6

---
 srcpkgs/qt6-pdf/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-pdf/template b/srcpkgs/qt6-pdf/template
index ecda84afac1310..531b4e1d4fe84d 100644
--- a/srcpkgs/qt6-pdf/template
+++ b/srcpkgs/qt6-pdf/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-pdf'
 pkgname=qt6-pdf
 version=6.6.0
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DQT_FEATURE_qtpdf_build=ON
  -DQT_FEATURE_qtpdf_widgets_build=ON

From c14786611e496f6877ded61ce0d2ced57de49e00 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 057/108] qt5-webengine: revbump for ffmpeg6

---
 .../chromium-media-filters-cpp14.patch        |  11 ++
 srcpkgs/qt5-webengine/patches/ffmpeg5.patch   | 179 ++++++++++++++++++
 .../qtwebengine-fix-ffmpeg5-build.patch       |  14 ++
 srcpkgs/qt5-webengine/template                |   4 +-
 4 files changed, 206 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/ffmpeg5.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch

diff --git a/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
new file mode 100644
index 00000000000000..04adc540f2cbc0
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
@@ -0,0 +1,11 @@
+--- a/src/3rdparty/chromium/media/filters/BUILD.gn	2023-02-27 13:32:59.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/BUILD.gn	2023-04-02 17:21:39.204066384 -0400
+@@ -96,6 +96,8 @@
+     "//ui/gfx/geometry:geometry",
+   ]
+ 
++  cflags_cc = [ "-std=c++14" ]
++
+   libs = []
+ 
+   if (proprietary_codecs) {
diff --git a/srcpkgs/qt5-webengine/patches/ffmpeg5.patch b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..ac55e1634423a9
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
@@ -0,0 +1,179 @@
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:57.732547446 -0400
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:09.486478995 -0400
+@@ -57,6 +57,8 @@
+ 
+ namespace {
+ 
++constexpr int64_t kRelativeTsBase = static_cast<int64_t>(0x7ffeffffffffffff);
++
+ void SetAVStreamDiscard(AVStream* stream, AVDiscard discard) {
+   DCHECK(stream);
+   stream->discard = discard;
+@@ -90,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+   if (stream->start_time != kNoFFmpegTimestamp)
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (stream->first_dts != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, stream->first_dts);
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -408,11 +398,11 @@
+   scoped_refptr<DecoderBuffer> buffer;
+ 
+   if (type() == DemuxerStream::TEXT) {
+-    int id_size = 0;
++    size_t id_size = 0;
+     uint8_t* id_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
+ 
+-    int settings_size = 0;
++    size_t settings_size = 0;
+     uint8_t* settings_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
+ 
+@@ -424,7 +414,7 @@
+     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
+                                      side_data.data(), side_data.size());
+   } else {
+-    int side_data_size = 0;
++    size_t side_data_size = 0;
+     uint8_t* side_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
+ 
+@@ -485,7 +475,7 @@
+                                        packet->size - data_offset);
+     }
+ 
+-    int skip_samples_size = 0;
++    size_t skip_samples_size = 0;
+     const uint32_t* skip_samples_ptr =
+         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
+             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
+@@ -1587,6 +1577,8 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++      continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+       lowest_start_time_stream = stream.get();
+@@ -1604,6 +1596,8 @@
+     if (stream && stream->type() == DemuxerStream::VIDEO &&
+         stream->IsEnabled()) {
+       video_stream = stream.get();
++      if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++        continue;
+       if (video_stream->start_time() <= seek_time) {
+         return video_stream;
+       }
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h qtwebengine-5.15.10/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h
+--- a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-07-11 22:12:47.917192788 -0500
+@@ -29,6 +29,7 @@ extern "C" {
+ #include <libavformat/avformat.h>
+ #include <libavformat/avio.h>
+ #include <libavutil/avutil.h>
++#include <libavutil/channel_layout.h>
+ #include <libavutil/imgutils.h>
+ #include <libavutil/log.h>
+ #include <libavutil/mastering_display_metadata.h>
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/audio_file_reader.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/audio_file_reader.cc
+--- a/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -85,7 +85,7 @@ bool AudioFileReader::OpenDemuxer() {
+ }
+ 
+ bool AudioFileReader::OpenDecoder() {
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (codec) {
+     // MP3 decodes to S16P which we don't support, tell it to use S16 instead.
+     if (codec_context_->sample_fmt == AV_SAMPLE_FMT_S16P)
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -329,7 +329,7 @@ bool FFmpegAudioDecoder::ConfigureDecode
+     }
+   }
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec ||
+       avcodec_open2(codec_context_.get(), codec, &codec_options) < 0) {
+     DLOG(ERROR) << "Could not initialize audio decoder: "
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -59,7 +59,6 @@ static int64_t AVIOSeekOperation(void* o
+ }
+ 
+ void FFmpegGlue::InitializeFFmpeg() {
+-  av_register_all();
+ }
+ 
+ static void LogContainer(bool is_local_file,
+@@ -95,9 +94,6 @@ FFmpegGlue::FFmpegGlue(FFmpegURLProtocol
+   // Enable fast, but inaccurate seeks for MP3.
+   format_context_->flags |= AVFMT_FLAG_FAST_SEEK;
+ 
+-  // Ensures we can read out various metadata bits like vp8 alpha.
+-  format_context_->flags |= AVFMT_FLAG_KEEP_SIDE_DATA;
+-
+   // Ensures format parsing errors will bail out. From an audit on 11/2017, all
+   // instances were real failures. Solves bugs like http://crbug.com/710791.
+   format_context_->error_recognition |= AV_EF_EXPLODE;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -391,7 +391,7 @@ bool FFmpegVideoDecoder::ConfigureDecode
+   if (decode_nalus_)
+     codec_context_->flags2 |= AV_CODEC_FLAG2_CHUNKS;
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
+     ReleaseFFmpegResources();
+     return false;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/media_file_checker.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/media_file_checker.cc
+--- a/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -68,7 +68,7 @@ bool MediaFileChecker::Start(base::TimeD
+       auto context = AVStreamToAVCodecContext(format_context->streams[i]);
+       if (!context)
+         continue;
+-      AVCodec* codec = avcodec_find_decoder(cp->codec_id);
++      const AVCodec* codec = avcodec_find_decoder(cp->codec_id);
+       if (codec && avcodec_open2(context.get(), codec, nullptr) >= 0) {
+         auto loop = std::make_unique<FFmpegDecodingLoop>(context.get());
+         stream_contexts[i] = {std::move(context), std::move(loop)};
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc qtwebengine-5.15.10/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc
+--- a/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -203,7 +203,7 @@ int32_t H264DecoderImpl::InitDecode(cons
+   // a pointer |this|.
+   av_context_->opaque = this;
+ 
+-  AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
+   if (!codec) {
+     // This is an indication that FFmpeg has not been initialized or it has not
+     // been compiled/initialized with the correct set of codecs.
diff --git a/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch b/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch
new file mode 100644
index 00000000000000..bc24d5b9a29cb5
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch
@@ -0,0 +1,14 @@
+--- a/src/buildtools/configure.json	2023-12-09 11:06:01.503058569 -0500
++++ b/src/buildtools/configure.json	2023-12-09 11:06:14.982361345 -0500
+@@ -779,11 +779,6 @@
+             "type": "warning",
+             "condition": "config.ios && config.simulator && config.device && features.build-qtpdf",
+             "message": "Building fat libray with device and simulator architectures will disable NEON."
+-        },
+-        {
+-            "type": "fatal",
+-            "condition": "features.webengine-system-ffmpeg && !libs.webengine-ffmpeg-support",
+-            "message": "Unmodified ffmpeg >= 5.0 is not supported. Please configure with -qt-webengine-ffmpeg."
+         }
+     ],
+     "summary": [
diff --git a/srcpkgs/qt5-webengine/template b/srcpkgs/qt5-webengine/template
index 8d2df1b5175bad..1687a77eb8a2f5 100644
--- a/srcpkgs/qt5-webengine/template
+++ b/srcpkgs/qt5-webengine/template
@@ -1,14 +1,14 @@
 # Template file for 'qt5-webengine'
 pkgname=qt5-webengine
 version=5.15.16
-revision=1
+revision=2
 _version="${version}-lts"
 _chromium_commit=207c2ac45ca3386d153770c6b0d2ea2ec21ca880
 archs="x86_64* i686* armv[67]* ppc64* aarch64*"
 create_wrksrc=yes
 build_style=qmake
 configure_args="--
- -webengine-icu -webengine-ffmpeg -webengine-opus -webengine-webp
+ -webengine-icu -system-ffmpeg -webengine-opus -webengine-webp
  -webengine-pepper-plugins -webengine-printing-and-pdf -webengine-proprietary-codecs
  -webengine-pulseaudio -webengine-spellchecker -webengine-webrtc -webengine-geolocation
  -webengine-kerberos -no-webengine-embedded-build $(vopt_if sndio '' '-no')-webengine-sndio

From 8baff7a49bcda5a6641fc3204fda6ef2582d3b75 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 058/108] qt5: revbump for ffmpeg6

---
 srcpkgs/qt5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5/template b/srcpkgs/qt5/template
index 3efb7e42d5fd3f..27f6d5388cd15c 100644
--- a/srcpkgs/qt5/template
+++ b/srcpkgs/qt5/template
@@ -3,9 +3,9 @@
 # revbump libqtxdg after bumping patch version
 pkgname=qt5
 version=5.15.11+20231124
+revision=3
 # commit 4765fa1df7a837db9c1f89c4da0dd76b74bb5fab
 # base repo: https://invent.kde.org/qt/qt/qt5
-revision=2
 build_style=meta
 hostmakedepends="cmake clang17 flex perl glib-devel pkg-config
  python3 re2c ruby which"

From bb00e8591d74c51afd979554c29a77712cc80480 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 059/108] qtav: revbump for ffmpeg4

---
 srcpkgs/qtav/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtav/template b/srcpkgs/qtav/template
index 775d5a139a9efa..aa69e213c984b0 100644
--- a/srcpkgs/qtav/template
+++ b/srcpkgs/qtav/template
@@ -1,10 +1,10 @@
 # Template file for 'qtav'
 pkgname=qtav
 version=1.13.0
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel libass-devel libopenal-devel
+makedepends="ffmpeg4-devel libass-devel libopenal-devel
  libva-glx-devel libXv-devel pulseaudio-devel
  qt5-declarative-devel qt5-svg-devel
  qt5-quickcontrols"

From 0029418a6c7edb611f153fe6df75a4b4fc137d44 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 060/108] retroarch: revbump for ffmpeg6

---
 srcpkgs/retroarch/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroarch/template b/srcpkgs/retroarch/template
index cb3125c5dbf1ae..c65c26f7bf0332 100644
--- a/srcpkgs/retroarch/template
+++ b/srcpkgs/retroarch/template
@@ -1,7 +1,7 @@
 # Template file for 'retroarch'
 pkgname=retroarch
 version=1.16.0.3
-revision=3
+revision=4
 build_style=configure
 configure_args="--prefix=/usr --sysconfdir=/etc --enable-networking
  --enable-udev --disable-builtinflac --disable-builtinglslang

From 04c5eca46f28a562efb5cdf9c0ca7655e68c4599 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 061/108] scrcpy: revbump for ffmpeg6

---
 srcpkgs/scrcpy/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/scrcpy/template b/srcpkgs/scrcpy/template
index d40651ad8dc835..3ec7139be5c0c5 100644
--- a/srcpkgs/scrcpy/template
+++ b/srcpkgs/scrcpy/template
@@ -1,7 +1,7 @@
 # Template file for 'scrcpy'
 pkgname=scrcpy
 version=2.4
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcompile_server=false
  -Dprebuilt_server=/usr/share/scrcpy/scrcpy-server-v${version}"

From caf254610db79be1ec3f3534d1bae8757ca6efbe Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 17 Oct 2023 08:54:11 -0400
Subject: [PATCH 062/108] New package: spex-x replaces spek-alternative for
 ffmpeg6

---
 srcpkgs/spek-alternative                      |  1 +
 srcpkgs/spek-x/patches/musl.patch             |  7 ++++++
 srcpkgs/{spek-alternative => spek-x}/template | 22 ++++++++++++-------
 3 files changed, 22 insertions(+), 8 deletions(-)
 create mode 120000 srcpkgs/spek-alternative
 create mode 100644 srcpkgs/spek-x/patches/musl.patch
 rename srcpkgs/{spek-alternative => spek-x}/template (52%)

diff --git a/srcpkgs/spek-alternative b/srcpkgs/spek-alternative
new file mode 120000
index 00000000000000..76648236da7017
--- /dev/null
+++ b/srcpkgs/spek-alternative
@@ -0,0 +1 @@
+spek-x
\ No newline at end of file
diff --git a/srcpkgs/spek-x/patches/musl.patch b/srcpkgs/spek-x/patches/musl.patch
new file mode 100644
index 00000000000000..662f45936febc6
--- /dev/null
+++ b/srcpkgs/spek-x/patches/musl.patch
@@ -0,0 +1,7 @@
+--- a/tests/perf.cc	2024-03-09 17:13:49.086603418 -0500
++++ b/tests/perf.cc	2024-03-09 17:13:59.453603753 -0500
+@@ -1,3 +1,4 @@
++#include <cstdint>
+ #include <cstdlib>
+ #include <iostream>
+ #include <fstream>
diff --git a/srcpkgs/spek-alternative/template b/srcpkgs/spek-x/template
similarity index 52%
rename from srcpkgs/spek-alternative/template
rename to srcpkgs/spek-x/template
index d7b55c776b1d43..3ded6c2c323e4f 100644
--- a/srcpkgs/spek-alternative/template
+++ b/srcpkgs/spek-x/template
@@ -1,18 +1,18 @@
-# Template file for 'spek-alternative'
-pkgname=spek-alternative
-version=0.8.2.3
-revision=2
+# Template file for 'spek-x'
+pkgname=spek-x
+version=0.9.3
+revision=1
 build_style=gnu-configure
 hostmakedepends="automake gettext-devel intltool libtool pkg-config
  wxWidgets-common wxWidgets-gtk3-devel"
 makedepends="ffmpeg-devel wxWidgets-gtk3-devel"
 depends="ffmpeg"
 short_desc="Acoustic spectrum analyser"
-maintainer="Kartik Singh <kartik.ynwa@gmail.com>"
+maintainer="zlice <zlice555@gmail.com>"
 license="GPL-3.0-or-later"
-homepage="https://github.com/withmorten/spek-alternative"
-distfiles="https://github.com/withmorten/spek-alternative/archive/${version}.tar.gz"
-checksum="007ba4b84a310b078e378aa84c8e80783db5821437a757a488c3ecec377e6b2a"
+homepage="https://github.com/MikeWang000000/spek-x"
+distfiles="https://github.com/MikeWang000000/spek-x/archive/v${version}.tar.gz"
+checksum="7f4b109903333cdd310ab2b9176f0dc49a565891376e281a233d342cedf90ef7"
 
 CXXFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
 
@@ -22,3 +22,9 @@ export WX_CONFIG_NAME="wx-config-gtk3"
 pre_configure() {
 	NOCONFIGURE=1 ./autogen.sh
 }
+
+spek-alternative_package() {
+	depends="spek-x"
+	short_desc+=" - transitional dummy package"
+	build_style=meta
+}

From fb2eca2c17dd4a98c9da7f264631e2d09d3fdaa5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 063/108] ssr: revbump for ffmpeg6

---
 .../0001-Fix-build-with-ffmpeg-5.0.patch      | 241 ++++++++++++++++++
 srcpkgs/ssr/template                          |   2 +-
 2 files changed, 242 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ssr/patches/0001-Fix-build-with-ffmpeg-5.0.patch

diff --git a/srcpkgs/ssr/patches/0001-Fix-build-with-ffmpeg-5.0.patch b/srcpkgs/ssr/patches/0001-Fix-build-with-ffmpeg-5.0.patch
new file mode 100644
index 00000000000000..4c069b5a9fc464
--- /dev/null
+++ b/srcpkgs/ssr/patches/0001-Fix-build-with-ffmpeg-5.0.patch
@@ -0,0 +1,241 @@
+From f4cbde38021d9330dc73d2e3dfa8a70da3ff5721 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Bernhard=20Rosenkr=C3=A4nzer?= <bero@lindev.ch>
+Date: Sun, 16 Jan 2022 02:40:04 +0100
+Subject: [PATCH] Fix build with ffmpeg 5.0
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Adapt to ffmpeg 5.0 requiring more const-ness for AVCodec.
+
+Signed-off-by: Bernhard Rosenkränzer <bero@lindev.ch>
+---
+ src/AV/Output/AudioEncoder.cpp |  6 +++---
+ src/AV/Output/AudioEncoder.h   |  4 ++--
+ src/AV/Output/BaseEncoder.cpp  |  4 ++--
+ src/AV/Output/BaseEncoder.h    |  4 ++--
+ src/AV/Output/Muxer.cpp        | 12 ++++++------
+ src/AV/Output/Muxer.h          |  4 ++--
+ src/AV/Output/VideoEncoder.cpp |  6 +++---
+ src/AV/Output/VideoEncoder.h   |  4 ++--
+ 8 files changed, 22 insertions(+), 22 deletions(-)
+
+diff --git a/src/AV/Output/AudioEncoder.cpp b/src/AV/Output/AudioEncoder.cpp
+index 34d015c..cefc2e0 100644
+--- a/src/AV/Output/AudioEncoder.cpp
++++ b/src/AV/Output/AudioEncoder.cpp
+@@ -34,7 +34,7 @@ const std::vector<AudioEncoder::SampleFormatData> AudioEncoder::SUPPORTED_SAMPLE
+ 
+ const unsigned int AudioEncoder::DEFAULT_FRAME_SAMPLES = 1024;
+ 
+-AudioEncoder::AudioEncoder(Muxer* muxer, AVStream* stream, AVCodecContext *codec_context, AVCodec* codec, AVDictionary** options)
++AudioEncoder::AudioEncoder(Muxer* muxer, AVStream* stream, AVCodecContext *codec_context, const AVCodec* codec, AVDictionary** options)
+ 	: BaseEncoder(muxer, stream, codec_context, codec, options) {
+ 
+ #if !SSR_USE_AVCODEC_ENCODE_AUDIO2
+@@ -77,7 +77,7 @@ unsigned int AudioEncoder::GetSampleRate() {
+ }
+ 
+ bool AudioEncoder::AVCodecIsSupported(const QString& codec_name) {
+-	AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
++	const AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
+ 	if(codec == NULL)
+ 		return false;
+ 	if(!av_codec_is_encoder(codec))
+@@ -93,7 +93,7 @@ bool AudioEncoder::AVCodecIsSupported(const QString& codec_name) {
+ 	return false;
+ }
+ 
+-void AudioEncoder::PrepareStream(AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
++void AudioEncoder::PrepareStream(AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
+ 								 unsigned int bit_rate, unsigned int channels, unsigned int sample_rate) {
+ 
+ 	if(channels == 0) {
+diff --git a/src/AV/Output/AudioEncoder.h b/src/AV/Output/AudioEncoder.h
+index c93278c..ae9c82e 100644
+--- a/src/AV/Output/AudioEncoder.h
++++ b/src/AV/Output/AudioEncoder.h
+@@ -40,7 +40,7 @@ private:
+ #endif
+ 
+ public:
+-	AudioEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options);
++	AudioEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options);
+ 	~AudioEncoder();
+ 
+ 	// Returns the required frame size, i.e. the number of samples (for each channel).
+@@ -57,7 +57,7 @@ public:
+ 
+ public:
+ 	static bool AVCodecIsSupported(const QString& codec_name);
+-	static void PrepareStream(AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
++	static void PrepareStream(AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
+ 							  unsigned int bit_rate, unsigned int channels, unsigned int sample_rate);
+ 
+ private:
+diff --git a/src/AV/Output/BaseEncoder.cpp b/src/AV/Output/BaseEncoder.cpp
+index 7c01ef3..4780aaf 100644
+--- a/src/AV/Output/BaseEncoder.cpp
++++ b/src/AV/Output/BaseEncoder.cpp
+@@ -42,7 +42,7 @@ double ParseCodecOptionDouble(const QString& key, const QString& value, double m
+ 	return clamp(value_double, min, max) * multiply;
+ }
+ 
+-BaseEncoder::BaseEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options) {
++BaseEncoder::BaseEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options) {
+ 
+ 	m_muxer = muxer;
+ 	m_stream = stream;
+@@ -157,7 +157,7 @@ void BaseEncoder::IncrementPacketCounter() {
+ 	++lock->m_total_packets;
+ }
+ 
+-void BaseEncoder::Init(AVCodec* codec, AVDictionary** options) {
++void BaseEncoder::Init(const AVCodec* codec, AVDictionary** options) {
+ 
+ 	// open codec
+ 	if(avcodec_open2(m_codec_context, codec, options) < 0) {
+diff --git a/src/AV/Output/BaseEncoder.h b/src/AV/Output/BaseEncoder.h
+index 3d92f29..7f02bbd 100644
+--- a/src/AV/Output/BaseEncoder.h
++++ b/src/AV/Output/BaseEncoder.h
+@@ -51,7 +51,7 @@ private:
+ 	std::atomic<bool> m_should_stop, m_should_finish, m_is_done, m_error_occurred;
+ 
+ protected:
+-	BaseEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options);
++	BaseEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options);
+ 
+ public:
+ 	virtual ~BaseEncoder(); // encoders will be deleted by Muxer, don't delete them yourself!
+@@ -117,7 +117,7 @@ protected:
+ 	void IncrementPacketCounter();
+ 
+ private:
+-	void Init(AVCodec* codec, AVDictionary** options);
++	void Init(const AVCodec* codec, AVDictionary** options);
+ 	void Free();
+ 
+ 	void EncoderThread();
+diff --git a/src/AV/Output/Muxer.cpp b/src/AV/Output/Muxer.cpp
+index ad58380..14650b0 100644
+--- a/src/AV/Output/Muxer.cpp
++++ b/src/AV/Output/Muxer.cpp
+@@ -87,7 +87,7 @@ Muxer::~Muxer() {
+ 
+ VideoEncoder* Muxer::AddVideoEncoder(const QString& codec_name, const std::vector<std::pair<QString, QString> >& codec_options,
+ 									 unsigned int bit_rate, unsigned int width, unsigned int height, unsigned int frame_rate) {
+-	AVCodec *codec = FindCodec(codec_name);
++	const AVCodec *codec = FindCodec(codec_name);
+ 	AVCodecContext *codec_context = NULL;
+ 	AVStream *stream = AddStream(codec, &codec_context);
+ 	VideoEncoder *encoder;
+@@ -111,7 +111,7 @@ VideoEncoder* Muxer::AddVideoEncoder(const QString& codec_name, const std::vecto
+ 
+ AudioEncoder* Muxer::AddAudioEncoder(const QString& codec_name, const std::vector<std::pair<QString, QString> >& codec_options,
+ 									 unsigned int bit_rate, unsigned int channels, unsigned int sample_rate) {
+-	AVCodec *codec = FindCodec(codec_name);
++	const AVCodec *codec = FindCodec(codec_name);
+ 	AVCodecContext *codec_context = NULL;
+ 	AVStream *stream = AddStream(codec, &codec_context);
+ 	AudioEncoder *encoder;
+@@ -194,7 +194,7 @@ unsigned int Muxer::GetQueuedPacketCount(unsigned int stream_index) {
+ void Muxer::Init() {
+ 
+ 	// get the format we want (this is just a pointer, we don't have to free this)
+-	AVOutputFormat *format = av_guess_format(m_container_name.toUtf8().constData(), NULL, NULL);
++	const AVOutputFormat *format = av_guess_format(m_container_name.toUtf8().constData(), NULL, NULL);
+ 	if(format == NULL) {
+ 		Logger::LogError("[Muxer::Init] " + Logger::tr("Error: Can't find chosen output format!"));
+ 		throw LibavException();
+@@ -261,8 +261,8 @@ void Muxer::Free() {
+ 	}
+ }
+ 
+-AVCodec* Muxer::FindCodec(const QString& codec_name) {
+-	AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
++const AVCodec* Muxer::FindCodec(const QString& codec_name) {
++	const AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
+ 	if(codec == NULL) {
+ 		Logger::LogError("[Muxer::FindCodec] " + Logger::tr("Error: Can't find codec!"));
+ 		throw LibavException();
+@@ -270,7 +270,7 @@ AVCodec* Muxer::FindCodec(const QString& codec_name) {
+ 	return codec;
+ }
+ 
+-AVStream* Muxer::AddStream(AVCodec* codec, AVCodecContext** codec_context) {
++AVStream* Muxer::AddStream(const AVCodec* codec, AVCodecContext** codec_context) {
+ 	assert(!m_started);
+ 	assert(m_format_context->nb_streams < MUXER_MAX_STREAMS);
+ 
+diff --git a/src/AV/Output/Muxer.h b/src/AV/Output/Muxer.h
+index d72347d..b104bcb 100644
+--- a/src/AV/Output/Muxer.h
++++ b/src/AV/Output/Muxer.h
+@@ -114,8 +114,8 @@ private:
+ 	void Init();
+ 	void Free();
+ 
+-	AVCodec* FindCodec(const QString& codec_name);
+-	AVStream* AddStream(AVCodec* codec, AVCodecContext** codec_context);
++	const AVCodec* FindCodec(const QString& codec_name);
++	AVStream* AddStream(const AVCodec* codec, AVCodecContext** codec_context);
+ 
+ 	void MuxerThread();
+ 
+diff --git a/src/AV/Output/VideoEncoder.cpp b/src/AV/Output/VideoEncoder.cpp
+index 8087e8e..fc8b5d1 100644
+--- a/src/AV/Output/VideoEncoder.cpp
++++ b/src/AV/Output/VideoEncoder.cpp
+@@ -34,7 +34,7 @@ const std::vector<VideoEncoder::PixelFormatData> VideoEncoder::SUPPORTED_PIXEL_F
+ 	{"rgb", AV_PIX_FMT_RGB24, false},
+ };
+ 
+-VideoEncoder::VideoEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options)
++VideoEncoder::VideoEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options)
+ 	: BaseEncoder(muxer, stream, codec_context, codec, options) {
+ 
+ #if !SSR_USE_AVCODEC_ENCODE_VIDEO2
+@@ -95,7 +95,7 @@ unsigned int VideoEncoder::GetFrameRate() {
+ }
+ 
+ bool VideoEncoder::AVCodecIsSupported(const QString& codec_name) {
+-	AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
++	const AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
+ 	if(codec == NULL)
+ 		return false;
+ 	if(!av_codec_is_encoder(codec))
+@@ -111,7 +111,7 @@ bool VideoEncoder::AVCodecIsSupported(const QString& codec_name) {
+ 	return false;
+ }
+ 
+-void VideoEncoder::PrepareStream(AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
++void VideoEncoder::PrepareStream(AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
+ 								 unsigned int bit_rate, unsigned int width, unsigned int height, unsigned int frame_rate) {
+ 
+ 	if(width == 0 || height == 0) {
+diff --git a/src/AV/Output/VideoEncoder.h b/src/AV/Output/VideoEncoder.h
+index cb7ca27..68d872e 100644
+--- a/src/AV/Output/VideoEncoder.h
++++ b/src/AV/Output/VideoEncoder.h
+@@ -40,7 +40,7 @@ private:
+ #endif
+ 
+ public:
+-	VideoEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options);
++	VideoEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options);
+ 	~VideoEncoder();
+ 
+ 	// Returns the required pixel format.
+@@ -55,7 +55,7 @@ public:
+ 
+ public:
+ 	static bool AVCodecIsSupported(const QString& codec_name);
+-	static void PrepareStream(AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
++	static void PrepareStream(AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
+ 							  unsigned int bit_rate, unsigned int width, unsigned int height, unsigned int frame_rate);
+ 
+ private:
+-- 
+2.43.0
+
diff --git a/srcpkgs/ssr/template b/srcpkgs/ssr/template
index 3097754e3cbe54..e3c4261f1f5a64 100644
--- a/srcpkgs/ssr/template
+++ b/srcpkgs/ssr/template
@@ -1,7 +1,7 @@
 # Template file for 'ssr'
 pkgname=ssr
 version=0.4.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DWITH_QT5=ON"
 hostmakedepends="pkg-config"

From 444fd1f80c885b6e79246b24d33ccc35d118b35f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 064/108] synfig: revbump for ffmpeg6 and mlt7

---
 srcpkgs/synfig/patches/ffmpeg6.patch | 71 ++++++++++++++++++++++++++++
 srcpkgs/synfig/template              |  6 +--
 2 files changed, 74 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/synfig/patches/ffmpeg6.patch

diff --git a/srcpkgs/synfig/patches/ffmpeg6.patch b/srcpkgs/synfig/patches/ffmpeg6.patch
new file mode 100644
index 00000000000000..10780b42782f4b
--- /dev/null
+++ b/srcpkgs/synfig/patches/ffmpeg6.patch
@@ -0,0 +1,71 @@
+--- a/src/modules/mod_libavcodec/trgt_av.cpp	2022-10-25 09:14:12.000000000 -0400
++++ b/src/modules/mod_libavcodec/trgt_av.cpp	2023-05-05 21:34:17.899194559 -0400
+@@ -38,6 +41,7 @@
+ extern "C"
+ {
+ #ifdef HAVE_LIBAVFORMAT_AVFORMAT_H
++#	include <libavcodec/avcodec.h>
+ #	include <libavformat/avformat.h>
+ #elif defined(HAVE_AVFORMAT_H)
+ #	include <avformat.h>
+@@ -155,11 +156,11 @@
+     }
+ 
+ 	bool open_video_stream() {
+-		if (avcodec_open2(video_context, NULL, NULL) < 0) {
++		if (avcodec_open2(video_context, nullptr, nullptr) < 0) {
+ 			synfig::error("Target_LibAVCodec: could not open video codec");
+ 			// seems the calling of avcodec_free_context after error will cause crash
+ 			// so just forget about this context
+-			video_context = NULL;
++			video_context = nullptr;
+ 			close();
+ 			return false;
+         }
+@@ -234,15 +235,21 @@
+ 		close();
+ 
+ 		if (!av_registered) {
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 			av_register_all();
++#endif
+ 			av_registered = true;
+ 		}
+ 
+ 		// guess format
+-		AVOutputFormat *format = av_guess_format(NULL, filename.c_str(), NULL);
++#if LIBAVCODEC_VERSION_MAJOR < 59 // FFMPEG < 5.0
++		AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#else
++		const AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#endif
+ 		if (!format) {
+ 			synfig::warning("Target_LibAVCodec: unable to guess the output format, defaulting to MPEG");
+-			format = av_guess_format("mpeg", NULL, NULL);
++			format = av_guess_format("mpeg", nullptr, nullptr);
+ 		}
+ 		if (!format) {
+ 			synfig::error("Target_LibAVCodec: unable to find 'mpeg' output format");
+@@ -254,6 +261,7 @@
+ 		context = avformat_alloc_context();
+ 		assert(context);
+ 		context->oformat = format;
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 		if (filename.size() + 1 > sizeof(context->filename)) {
+ 			synfig::error(
+ 				"Target_LibAVCodec: filename too long, max length is %d, filename is '%s'",
+@@ -263,6 +271,14 @@
+ 			return false;
+ 		}
+ 		memcpy(context->filename, filename.c_str(), filename.size() + 1);
++#else
++		context->url = av_strndup(filename.c_str(), filename.size());
++		if (!context->url) {
++			synfig::error("Target_LibAVCodec: cannot allocate space for filename");
++			close();
++			return false;
++		}
++#endif
+ 
+ 		packet = av_packet_alloc();
+ 		assert(packet);
diff --git a/srcpkgs/synfig/template b/srcpkgs/synfig/template
index d4d3e341a20bf8..828b5cb32956ee 100644
--- a/srcpkgs/synfig/template
+++ b/srcpkgs/synfig/template
@@ -2,11 +2,11 @@
 # Should be kept in sync with 'synfigstudio' and 'ETL'
 pkgname=synfig
 version=1.4.4
-revision=4
+revision=5
 build_style=gnu-configure
 configure_args="--with-boost-libdir=${XBPS_CROSS_BASE}/usr/lib"
 hostmakedepends="boost-build ImageMagick pkg-config intltool"
-makedepends="ETL gettext-devel libxml++-devel mlt-devel libmagick-devel
+makedepends="ETL gettext-devel libxml++-devel mlt7-devel libmagick-devel
  libmng-devel boost-build boost-devel libopenexr-devel ffmpeg-devel"
 depends="ImageMagick"
 short_desc="CLI 2D vector and timeline-based animation software"
@@ -20,7 +20,7 @@ CXXFLAGS="-std=c++11 -DHAVE_LOCALE_H=1"
 
 synfig-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision}
-	 libopenexr-devel libxml++-devel mlt-devel"
+	 libopenexr-devel libxml++-devel mlt7-devel"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/bin/synfig-config

From 3e08c5f6f532c7f9d896fb408dd671e4b927b920 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 065/108] timg: revbump for ffmpeg6

---
 srcpkgs/timg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/timg/template b/srcpkgs/timg/template
index 2a2ab763d2fddf..8fb4327535ef93 100644
--- a/srcpkgs/timg/template
+++ b/srcpkgs/timg/template
@@ -1,7 +1,7 @@
 # Template file for 'timg'
 pkgname=timg
 version=1.4.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_OPENSLIDE_SUPPORT=off -Wno-dev"
 hostmakedepends="pkg-config git"

From 2dc1878aab31ef85496824ed7134548e548b7856 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 066/108] tvheadend: revbump for ffmpeg4

---
 srcpkgs/tvheadend/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tvheadend/template b/srcpkgs/tvheadend/template
index 9aea7de4ec7057..012d31c4879ff1 100644
--- a/srcpkgs/tvheadend/template
+++ b/srcpkgs/tvheadend/template
@@ -8,7 +8,7 @@ configure_args="--enable-dvbscan --disable-ffmpeg_static
 --disable-libx265_static --disable-libvpx_static --disable-libtheora_static
 --disable-libvorbis_static --disable-libfdkaac_static"
 hostmakedepends="gettext pkg-config python3 git which"
-makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg-devel"
+makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg4-devel"
 short_desc="TV streaming server"
 maintainer="lemmi <lemmi@nerd2nerd.org>"
 license="GPL-3.0-only"

From 4047006889459d6dff1cfa9aae4a7aa773521cb2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 067/108] unpaper: update to 7.0.0.

---
 srcpkgs/unpaper/template | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/srcpkgs/unpaper/template b/srcpkgs/unpaper/template
index 38ed47a5840165..1ff910e722afc8 100644
--- a/srcpkgs/unpaper/template
+++ b/srcpkgs/unpaper/template
@@ -1,13 +1,13 @@
 # Template file for 'unpaper'
 pkgname=unpaper
-version=6.1
-revision=3
-build_style=gnu-configure
+version=7.0.0
+revision=1
+build_style=meson
+hostmakedepends="pkg-config meson libxslt"
+makedepends="ffmpeg-devel python3-Sphinx"
+short_desc="Post-processing tool for scanned sheets of paper"
 maintainer="Orphaned <orphan@voidlinux.org>"
-hostmakedepends="pkg-config libxslt"
-makedepends="ffmpeg-devel"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://www.flameeyes.eu/projects/unpaper"
-short_desc="A post-processing tool for scanned sheets of paper"
 distfiles="https://www.flameeyes.eu/files/${pkgname}-${version}.tar.xz"
-checksum=237c84f5da544b3f7709827f9f12c37c346cdf029b1128fb4633f9bafa5cb930
+checksum=2575fbbf26c22719d1cb882b59602c9900c7f747118ac130883f63419be46a80

From 42975eb5efe3c5f706b14865d5e87626aba1ea9d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 068/108] vice: revbump for ffmpeg4

---
 srcpkgs/vice/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vice/template b/srcpkgs/vice/template
index 1c641d9ae9be22..4f43e85b5b8972 100644
--- a/srcpkgs/vice/template
+++ b/srcpkgs/vice/template
@@ -1,7 +1,7 @@
 # Template file for 'vice'
 pkgname=vice
 version=3.8
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-cpuhistory --enable-x64 --disable-pdf-docs
  --libdir=/usr/lib$XBPS_TARGET_WORDSIZE $(vopt_enable sdl2 sdlui2)

From eb60abd49e1f8f4f86970458d266c00332e05e44 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 069/108] waypipe: revbump for ffmpeg6

---
 srcpkgs/waypipe/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waypipe/template b/srcpkgs/waypipe/template
index 6da88b21bf2a19..4da8058400b588 100644
--- a/srcpkgs/waypipe/template
+++ b/srcpkgs/waypipe/template
@@ -1,7 +1,7 @@
 # Template file for 'waypipe'
 pkgname=waypipe
 version=0.8.6
-revision=1
+revision=2
 build_style=meson
 # lto is off because it causes linking errors in armv6l and armv7l (due to NEON)
 configure_args="-Dwerror=false -Dwith_dmabuf=enabled -Dwith_lz4=enabled

From 10a00fd60292621685685c7482d583eec20d6436 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 070/108] xpra: revbump for ffmpeg6

---
 srcpkgs/xpra/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xpra/template b/srcpkgs/xpra/template
index cc264b4ebd604c..ad53a093f09014 100644
--- a/srcpkgs/xpra/template
+++ b/srcpkgs/xpra/template
@@ -1,7 +1,7 @@
 # Template file for 'xpra'
 pkgname=xpra
 version=5.0.8
-revision=1
+revision=2
 build_style=python3-module
 make_build_args="--without-cuda_kernels --without-cuda_rebuild"
 make_install_args="$(vopt_with docs) ${make_build_args}"

From 6c4f4e14f88cd46f115e939d3d6fee35be47fb7a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:07:40 -0400
Subject: [PATCH 071/108] nv-codec-headers: update to 12.0.16.0

---
 srcpkgs/nv-codec-headers/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/nv-codec-headers/template b/srcpkgs/nv-codec-headers/template
index 3d422a61e48917..251e057f826fb8 100644
--- a/srcpkgs/nv-codec-headers/template
+++ b/srcpkgs/nv-codec-headers/template
@@ -1,6 +1,6 @@
 # Template file for 'nv-codec-headers'
 pkgname=nv-codec-headers
-version=11.1.5.1
+version=12.0.16.0
 revision=1
 build_style=gnu-makefile
 short_desc="FFmpeg version of headers required to interface with Nvidias codec APIs"
@@ -8,7 +8,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="MIT"
 homepage="http://git.videolan.org/?p=ffmpeg/nv-codec-headers.git"
 distfiles="https://github.com/FFmpeg/nv-codec-headers/archive/n${version}.tar.gz"
-checksum=d095fbd56aa93772471a323be0ebe65504a0f43f06c76a30b6d25da77b06ae9c
+checksum=2a1533b65f55f9da52956faf0627ed3b74868ac0c7f269990edd21369113b48f
 
 post_install() {
 	sed -n '4,25p' include/ffnvcodec/nvEncodeAPI.h > LICENSE

From 3016762c549a790b327328a4a12e6819dc9cb704 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:08:40 -0400
Subject: [PATCH 072/108] openimagedenoise: revbump for ffmpeg6

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index 109deb171c3f75..44edf38fb289d8 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,7 +1,7 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
 version=1.4.3
-revision=2
+revision=3
 archs="x86_64*"
 build_style=cmake
 hostmakedepends="ispc python3"

From 872375eb326d0a16313234bf7adf9d6f2d7034e4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:31:45 -0400
Subject: [PATCH 073/108] shotcut: revbump for ffmpeg6

---
 srcpkgs/shotcut/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/shotcut/template b/srcpkgs/shotcut/template
index b0dc9377558941..13e8a08522b68f 100644
--- a/srcpkgs/shotcut/template
+++ b/srcpkgs/shotcut/template
@@ -1,7 +1,7 @@
 # Template file for 'shotcut'
 pkgname=shotcut
 version=23.09.29
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSHOTCUT_VERSION=${version}"
 hostmakedepends="pkg-config qt6-base qt6-tools"

From 15a9e421afc7ced31236ef419e1946036195bc42 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:30 -0400
Subject: [PATCH 074/108] shiboken2: revbump for qt5-5.15.11

---
 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch | 1 +
 1 file changed, 1 insertion(+)
 create mode 120000 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
new file mode 120000
index 00000000000000..efcf3249bd8854
--- /dev/null
+++ b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1 @@
+../../python3-pyside2/patches/importlib-machinery-bypass.patch
\ No newline at end of file

From 13677a41be704caf2a346a17f090c45ec93f895f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:53 -0400
Subject: [PATCH 075/108] python3-pyside2: revbump for qt5-5.15.11

---
 .../patches/importlib-machinery-bypass.patch      | 15 +++++++++++++++
 srcpkgs/python3-pyside2/template                  |  2 +-
 2 files changed, 16 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
new file mode 100644
index 00000000000000..64c429584776b5
--- /dev/null
+++ b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1,15 @@
+Using this prevents an error around line 220 below it.
+"AttributeError: module 'importlib' has no attribute 'machinery'"
+The old backup logic is in place and compiles without issues.
+--- a/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:09:34.688912402 -0400
++++ b/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:10:03.395529582 -0400
+@@ -170,9 +170,6 @@
+
+     # 'zipstring_sequence' comes from signature.cpp
+     zipbytes = base64.b64decode(''.join(zipstring_sequence))
+-    if sys.version_info[0] >= 3:
+-        vzip = zipfile.ZipFile(io.BytesIO(zipbytes))
+-        return sys.meta_path, EmbeddableZipImporter(vzip)
+
+     # Old version for Python 2.7, only.
+     import os
diff --git a/srcpkgs/python3-pyside2/template b/srcpkgs/python3-pyside2/template
index 249efa90988425..52626436ce75f2 100644
--- a/srcpkgs/python3-pyside2/template
+++ b/srcpkgs/python3-pyside2/template
@@ -1,7 +1,7 @@
 # Template file for 'python3-pyside2'
 pkgname=python3-pyside2
 version=5.15.10
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/pyside2"
 build_style=cmake

From 1118b389628c2f3b24c87461eae25bad85995ceb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:35 -0400
Subject: [PATCH 076/108] konqueror: revbump for ffmpeg6

---
 srcpkgs/konqueror/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/konqueror/template b/srcpkgs/konqueror/template
index add972916753c6..50bbf4eec05e55 100644
--- a/srcpkgs/konqueror/template
+++ b/srcpkgs/konqueror/template
@@ -1,11 +1,11 @@
 # Template file for 'konqueror'
 pkgname=konqueror
 version=23.08.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DDESKTOPTOJSON_EXECUTABLE=/usr/bin/desktoptojson"
 hostmakedepends="extra-cmake-modules python3 qt5-host-tools qt5-qmake kdoctools
-kcoreaddons kconfig gettext"
+ kcoreaddons kconfig gettext"
 makedepends="qt5-devel qt5-webengine-devel qt5-declarative-devel
  qt5-webchannel-devel qt5-location-devel kcmutils-devel kdelibs4support-devel
  karchive-devel khtml-devel kdesu-devel kactivities5-devel"

From c4fff2a373b973eb303f726d6b61df0514eeced8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:58 -0400
Subject: [PATCH 077/108] qt5-speech: revbump for qt5-5.15.11

---
 srcpkgs/qt5-speech/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-speech/template b/srcpkgs/qt5-speech/template
index 1228bb60c41db4..27a7da1dbdb91b 100644
--- a/srcpkgs/qt5-speech/template
+++ b/srcpkgs/qt5-speech/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-speech'
 pkgname=qt5-speech
 version=5.15.11
-revision=1
+revision=2
 _commit=d32f4a479d38a11f547598004b975f4356424a16
 build_style=qmake
 configure_args="-- -flite -flite-alsa -speechd"

From 3994a3c41a8e8a75d8dbb0d81d0102a4446ac1a6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Jun 2023 08:20:22 -0400
Subject: [PATCH 078/108] gtk4: revbump for ffmpeg6

---
 srcpkgs/gtk4/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gtk4/template b/srcpkgs/gtk4/template
index 452ad63a9f4e6c..8f534c54aab81a 100644
--- a/srcpkgs/gtk4/template
+++ b/srcpkgs/gtk4/template
@@ -1,7 +1,7 @@
 # Template file for 'gtk4'
 pkgname=gtk4
 version=4.14.1
-revision=1
+revision=2
 build_style=meson
 build_helper="gir"
 configure_args="-Dman-pages=true -Ddocumentation=true -Dbuild-tests=false

From 0b2e48ec053951bd0859b69eb995f2b6ee34bcbf Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:28:26 -0400
Subject: [PATCH 079/108] siril: revbump for ffmpeg6

---
 srcpkgs/siril/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/siril/template b/srcpkgs/siril/template
index 84332f79d060d2..62750dd247548f 100644
--- a/srcpkgs/siril/template
+++ b/srcpkgs/siril/template
@@ -1,7 +1,7 @@
 # Template file for 'siril'
 pkgname=siril
 version=0.9.12
-revision=10
+revision=11
 build_style=gnu-configure
 hostmakedepends="pkg-config intltool autoconf automake gettext-devel"
 makedepends="fftw-devel libconfig-devel libopencv-devel libffms2-devel

From 982adbf9180d35ee7c28be7e1a7bf2e237d0a1bd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:20:59 -0400
Subject: [PATCH 080/108] tracker-miners: revbump for ffmpeg6

---
 srcpkgs/tracker-miners/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tracker-miners/template b/srcpkgs/tracker-miners/template
index 32c9c116114dc2..363c08cccdc349 100644
--- a/srcpkgs/tracker-miners/template
+++ b/srcpkgs/tracker-miners/template
@@ -1,7 +1,7 @@
 # Template file for 'tracker-miners'
 pkgname=tracker-miners
 version=3.7.1
-revision=1
+revision=2
 build_style=meson
 build_helper=qemu
 # missing libgrss for miner_rss

From bb73da4dfc536fbd3c896ff6b7cff99f9b53788a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:21:21 -0400
Subject: [PATCH 081/108] mpd: revbump for ffmpeg6

---
 srcpkgs/mdp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mdp/template b/srcpkgs/mdp/template
index 3720bfae02f840..1c45395dca9b21 100644
--- a/srcpkgs/mdp/template
+++ b/srcpkgs/mdp/template
@@ -1,7 +1,7 @@
 # Template file for 'mdp'
 pkgname=mdp
 version=1.0.15
-revision=1
+revision=2
 build_style=gnu-makefile
 makedepends="ncurses-devel"
 short_desc="A command-line based markdown presentation tool"

From 05bd1808325bd5fcaeb6a519d9ade8b43b46538c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:02 -0400
Subject: [PATCH 082/108] tg_owt: revbump for ffmpeg6

---
 srcpkgs/tg_owt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tg_owt/template b/srcpkgs/tg_owt/template
index 34e8fef0540569..1a46a8bedf3473 100644
--- a/srcpkgs/tg_owt/template
+++ b/srcpkgs/tg_owt/template
@@ -1,7 +1,7 @@
 # Template file for 'tg_owt'
 pkgname=tg_owt
 version=0.0.0.20231221
-revision=2
+revision=3
 _commit=afd9d5d31798d3eacf9ed6c30601e91d0f1e4d60
 _libyuv_commit=04821d1e7d60845525e8db55c7bcd41ef5be9406
 _abseil_commit=8c0b94e793a66495e0b1f34a5eb26bd7dc672db0

From b66cedf418d435fe79d96167346ffa7df0bcc001 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:44 -0400
Subject: [PATCH 083/108] telegram-desktop: revbump for ffmpeg6

---
 srcpkgs/telegram-desktop/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/telegram-desktop/template b/srcpkgs/telegram-desktop/template
index 6dc6a553cfcec8..cf85a731370062 100644
--- a/srcpkgs/telegram-desktop/template
+++ b/srcpkgs/telegram-desktop/template
@@ -1,7 +1,7 @@
 # Template file for 'telegram-desktop'
 pkgname=telegram-desktop
 version=4.14.15
-revision=3
+revision=4
 build_style=cmake
 build_helper="qemu gir"
 configure_args="-DTDESKTOP_API_ID=209235

From 7c432c8668ab7bce7dca2f997bf6c596d6647a7f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:12:09 -0400
Subject: [PATCH 084/108] openmw: revbump for ffmpeg6

---
 srcpkgs/openmw/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openmw/template b/srcpkgs/openmw/template
index 0abf5ff7cdbecc..b57180f1a4446f 100644
--- a/srcpkgs/openmw/template
+++ b/srcpkgs/openmw/template
@@ -1,7 +1,7 @@
 # Template file for 'openmw'
 pkgname=openmw
 version=0.48.0
-revision=2
+revision=3
 build_style=cmake
 _recast_commit=e75adf86f91eb3082220085e42dda62679f9a3ea
 _bullet_tag=3.17

From d9cd078b3b9de7f386f5913ccfe5d8ef27267bc4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:18:18 -0400
Subject: [PATCH 085/108] freecad: DELETE

---
 srcpkgs/freecad/patches/001-include.patch     | 112 ------------------
 .../154-revert-gui-tmp-redirect-stderr.patch  |  68 -----------
 ...d63c8c9b1280978be841d04e68a0a55cceb9.patch |  30 -----
 srcpkgs/freecad/template                      |  12 +-
 4 files changed, 7 insertions(+), 215 deletions(-)
 delete mode 100644 srcpkgs/freecad/patches/001-include.patch
 delete mode 100644 srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
 delete mode 100644 srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch

diff --git a/srcpkgs/freecad/patches/001-include.patch b/srcpkgs/freecad/patches/001-include.patch
deleted file mode 100644
index 28b5af54999b96..00000000000000
--- a/srcpkgs/freecad/patches/001-include.patch
+++ /dev/null
@@ -1,112 +0,0 @@
-From 9a41845a417189776741297c50a3827ce292bc4f Mon Sep 17 00:00:00 2001
-From: Uwe <donovaly@users.noreply.github.com>
-Date: Sun, 3 Jul 2022 22:51:16 +0200
-Subject: [PATCH] [Part] OCCError.h: remove unneeded includes
-
-- also sort includes
----
- src/Mod/Part/App/OCCError.h             | 36 +++----------------------
- src/Mod/Part/App/OffsetCurvePyImp.cpp   | 12 ++++-----
- src/Mod/Part/App/OffsetSurfacePyImp.cpp | 10 +++----
- 3 files changed, 12 insertions(+), 46 deletions(-)
-
---- a/src/Mod/Part/App/OCCError.h
-+++ b/src/Mod/Part/App/OCCError.h
-@@ -23,36 +23,8 @@
- #ifndef _OCCError_h_
- #define _OCCError_h_
- 
--# include <Standard_Version.hxx>
- # include <Standard_Failure.hxx>
--# include <Standard_AbortiveTransaction.hxx>
--# include <Standard_ConstructionError.hxx>
--# if OCC_VERSION_HEX >= 0x060500
--# include <Standard_DefineException.hxx>
--# endif
--# include <Standard_DimensionError.hxx>
--# include <Standard_DimensionMismatch.hxx>
--# include <Standard_DivideByZero.hxx>
--# include <Standard_DomainError.hxx>
--# include <Standard_ImmutableObject.hxx>
--# include <Standard_LicenseError.hxx>
--# include <Standard_LicenseNotFound.hxx>
--# include <Standard_MultiplyDefined.hxx>
--# include <Standard_NegativeValue.hxx>
--# include <Standard_NoMoreObject.hxx>
--# include <Standard_NoSuchObject.hxx>
--# include <Standard_NotImplemented.hxx>
--# include <Standard_NullObject.hxx>
--# include <Standard_NullValue.hxx>
--# include <Standard_NumericError.hxx>
--# include <Standard_OutOfMemory.hxx>
--# include <Standard_OutOfRange.hxx>
--# include <Standard_Overflow.hxx>
--# include <Standard_ProgramError.hxx>
--# include <Standard_RangeError.hxx>
--# include <Standard_TooManyUsers.hxx>
--# include <Standard_TypeMismatch.hxx>
--# include <Standard_Underflow.hxx>
-+# include <Standard_Version.hxx>
- 
- #include <Mod/Part/PartGlobal.h>
- #include <Base/Console.h>
-@@ -88,4 +60,3 @@ PartExport extern PyObject* PartExceptio
- 
- #define PY_CATCH_OCC _PY_CATCH_OCC(return(NULL))
- #endif  // _OCCError_h_
--
---- a/src/Mod/Part/App/OffsetCurvePyImp.cpp
-+++ b/src/Mod/Part/App/OffsetCurvePyImp.cpp
-@@ -20,20 +20,20 @@
-  *                                                                         *
-  ***************************************************************************/
- 
--
- #include "PreCompiled.h"
- #ifndef _PreComp_
- # include <Geom_OffsetCurve.hxx>
- #endif
- 
--#include "OCCError.h"
--#include "Geometry.h"
-+#include <Base/GeometryPyCXX.h>
-+#include <Base/Vector3D.h>
-+#include <Base/VectorPy.h>
-+
- #include "OffsetCurvePy.h"
- #include "OffsetCurvePy.cpp"
-+#include "Geometry.h"
-+#include "OCCError.h"
- 
--#include <Base/GeometryPyCXX.h>
--#include <Base/VectorPy.h>
--#include <Base/Vector3D.h>
- 
- using namespace Part;
- 
---- a/src/Mod/Part/App/OffsetSurfacePyImp.cpp
-+++ b/src/Mod/Part/App/OffsetSurfacePyImp.cpp
-@@ -20,20 +20,16 @@
-  *                                                                         *
-  ***************************************************************************/
- 
--
- #include "PreCompiled.h"
- #ifndef _PreComp_
- # include <Geom_OffsetSurface.hxx>
- # include <memory>
- #endif
- 
--#include <Base/VectorPy.h>
--#include <Base/Vector3D.h>
--
- #include "OCCError.h"
--#include "Geometry.h"
--#include <Mod/Part/App/OffsetSurfacePy.h>
--#include <Mod/Part/App/OffsetSurfacePy.cpp>
-+#include "OffsetSurfacePy.h"
-+#include "OffsetSurfacePy.cpp"
-+
- 
- using namespace Part;
- 
diff --git a/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch b/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
deleted file mode 100644
index d6a9adabdec830..00000000000000
--- a/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
+++ /dev/null
@@ -1,68 +0,0 @@
-see https://github.com/FreeCAD/FreeCAD/commit/cfe94b00d3434f3e2c8b5114d2909f628c330fa8#commitcomment-71413407
-
-upstream: yes
-
-From 7b377a216b9185960e4cee980a6504dc1a755f50 Mon Sep 17 00:00:00 2001
-From: wmayer <wmayer@users.sourceforge.net>
-Date: Wed, 29 Jun 2022 15:19:18 +0200
-Subject: [PATCH] Gui: remove workaround for spnav 0.23 due to build failure
- with musl libc
-
----
- src/Gui/3Dconnexion/GuiNativeEventLinux.cpp | 27 ---------------------
- 1 file changed, 27 deletions(-)
-
---- a/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp
-+++ b/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp
-@@ -21,42 +21,17 @@
-  ***************************************************************************/
- 
- #include <FCConfig.h>
--#include <cstdio>
- 
- #include "GuiNativeEventLinux.h"
- 
- #include "GuiApplicationNativeEventAware.h"
- #include <Base/Console.h>
--#include <Base/FileInfo.h>
- #include <QMainWindow>
- 
- #include <QSocketNotifier>
- 
- #include <spnav.h>
- 
--namespace {
--class RedirectStdErr
--{
--public:
--    RedirectStdErr()
--        : fi(Base::FileInfo::getTempFileName())
--        , file(stderr)
--    {
--        stderr = fopen(fi.filePath().c_str(), "w");
--    }
--    ~RedirectStdErr()
--    {
--        fclose(stderr);
--        fi.deleteFile();
--        stderr = file;
--    }
--
--private:
--    Base::FileInfo fi;
--    FILE* file;
--};
--}
--
- Gui::GuiNativeEvent::GuiNativeEvent(Gui::GUIApplicationNativeEventAware *app)
- : GuiAbstractNativeEvent(app)
- {
-@@ -72,8 +47,6 @@ Gui::GuiNativeEvent::~GuiNativeEvent()
- 
- void Gui::GuiNativeEvent::initSpaceball(QMainWindow *window)
- {
--    // tmp. redirect stderr to a file to suppress an error message from spnav_open()
--    RedirectStdErr err;
-     Q_UNUSED(window)
-     if (spnav_open() == -1) {
-         Base::Console().Log("Couldn't connect to spacenav daemon. Please ignore if you don't have a spacemouse.\n");
diff --git a/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch b/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch
deleted file mode 100644
index d4acf370ca0a42..00000000000000
--- a/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-From fe02d63c8c9b1280978be841d04e68a0a55cceb9 Mon Sep 17 00:00:00 2001
-From: Roy-043 <70520633+Roy-043@users.noreply.github.com>
-Date: Thu, 29 Dec 2022 23:20:38 +0100
-Subject: [PATCH] Draft: update inspect.getargspec to inspect.getfullargspec
- (#8101)
-
----
- src/Mod/Draft/draftguitools/gui_snapper.py | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
---- a/src/Mod/Draft/draftguitools/gui_snapper.py
-+++ b/src/Mod/Draft/draftguitools/gui_snapper.py
-@@ -1426,7 +1426,7 @@ class Snapper:
-             Gui.Snapper.off()
-             self.ui.offUi()
-             if callback:
--                if len(inspect.getargspec(callback).args) > 1:
-+                if len(inspect.getfullargspec(callback).args) > 1:
-                     obj = None
-                     if self.snapInfo and ("Object" in self.snapInfo) and self.snapInfo["Object"]:
-                         obj = App.ActiveDocument.getObject(self.snapInfo["Object"])
-@@ -1445,7 +1445,7 @@ class Snapper:
-             Gui.Snapper.off()
-             self.ui.offUi()
-             if callback:
--                if len(inspect.getargspec(callback).args) > 1:
-+                if len(inspect.getfullargspec(callback).args) > 1:
-                     callback(None, None)
-                 else:
-                     callback(None)
diff --git a/srcpkgs/freecad/template b/srcpkgs/freecad/template
index c135701e38b9ad..7d5165f760bab9 100644
--- a/srcpkgs/freecad/template
+++ b/srcpkgs/freecad/template
@@ -1,7 +1,7 @@
 # Template file for 'freecad'
 pkgname=freecad
-version=0.20.2
-revision=7
+version=0.21.1
+revision=2
 build_wrksrc="FreeCAD-${version}"
 build_style=cmake
 pycompile_dirs="usr/lib/${pkgname}/Mod"
@@ -24,8 +24,10 @@ makedepends="python3-devel boost-devel libxerces-c-devel zlib-devel occt-devel
  coin3-devel libshiboken2-devel libspnav-devel pyside2-tools
  liblz4-devel libpyside2-python3-devel python3-matplotlib netcdf-devel
  jsoncpp-devel qt5-devel qt5-svg-devel qt5-tools-devel qt5-webkit-devel
- qt5-xmlpatterns-devel coin3-doc glew-devel python3-pivy"
-depends="python3-matplotlib python3-pyside2-webengine python3-pivy"
+ qt5-xmlpatterns-devel coin3-doc glew-devel python3-pivy qt5-webengine-devel
+ qt5-declarative-devel qt5-webchannel-devel qt5-location-devel"
+depends="python3-matplotlib python3-pyside2-webengine python3-pivy
+ python3-GitPython python3-Markdown"
 short_desc="General purpose 3D CAD modeler"
 maintainer="yopito <pierre.bourgin@free.fr>"
 license="LGPL-2.0-or-later"
@@ -35,7 +37,7 @@ distfiles="
  https://github.com/FreeCAD/FreeCAD/archive/${version}.tar.gz
  ${SOURCEFORGE_SITE}/cxx/pycxx-${_pycxxver}.tar.gz
 "
-checksum="46922f3a477e742e1a89cd5346692d63aebb2b67af887b3e463e094a4ae055da
+checksum="e9b1fd0323f101268c7f3be52db42e4a29222f2e306ae6c4a6fc309cb418d35a
  4b91e1e1141c23fbd5039df635c4bb6e75632168548f56b83ce177193c0c98c6"
 python_version=3
 patch_args="-Np1 -d ${build_wrksrc}"

From a80e0c37ccdcc62564685bada88630e54e430f37 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:47:18 -0400
Subject: [PATCH 086/108] libopenshot: revbump for ffmpeg6

---
 srcpkgs/libopenshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenshot/template b/srcpkgs/libopenshot/template
index 8e57c5f592169c..7a8f4520e78925 100644
--- a/srcpkgs/libopenshot/template
+++ b/srcpkgs/libopenshot/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenshot'
 pkgname=libopenshot
 version=0.3.0
-revision=3
+revision=4
 build_style=cmake
 # Builds fail with Ruby-2.4.1
 configure_args="-DENABLE_RUBY=OFF -DUSE_SYSTEM_JSONCPP=ON"

From 9fd50be4de035f51668d937fc47ef961a18705af Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:10:30 -0500
Subject: [PATCH 087/108] openimageio: revbump for ffmpeg6

---
 srcpkgs/openimageio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimageio/template b/srcpkgs/openimageio/template
index 27d2131bc0a61a..61f44b43f9083e 100644
--- a/srcpkgs/openimageio/template
+++ b/srcpkgs/openimageio/template
@@ -1,7 +1,7 @@
 # Template file for 'openimageio'
 pkgname=openimageio
 version=2.4.9.0
-revision=8
+revision=9
 build_style=cmake
 build_helper=qemu
 configure_args="-DUSE_QT=0 -DUSE_PYTHON=0 -DOIIO_BUILD_TESTS=0

From 6a41562c5d4dc667e00a3ab4fcea3c2c4332f5a1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:11:57 -0500
Subject: [PATCH 088/108] synfigstudio: revbump for ffmpeg6

---
 srcpkgs/synfigstudio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/synfigstudio/template b/srcpkgs/synfigstudio/template
index 09e442da9a6805..2bc017cedca6b8 100644
--- a/srcpkgs/synfigstudio/template
+++ b/srcpkgs/synfigstudio/template
@@ -2,7 +2,7 @@
 # Should be kept in sync with 'synfig' and 'ETL'
 pkgname=synfigstudio
 version=1.4.4
-revision=4
+revision=5
 build_style=gnu-configure
 configure_args="--disable-update-mimedb"
 hostmakedepends="pkg-config intltool gettext synfig"

From e9bfa0f4e5ea9c85fece090438648a033b7da4e1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:10 -0500
Subject: [PATCH 089/108] mixxx: revbump for ffmpeg6

---
 srcpkgs/mixxx/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mixxx/template b/srcpkgs/mixxx/template
index 6a79b328c1abf0..9a5141856860b9 100644
--- a/srcpkgs/mixxx/template
+++ b/srcpkgs/mixxx/template
@@ -1,7 +1,7 @@
 # Template file for 'mixxx'
 pkgname=mixxx
 version=2.3.3
-revision=7
+revision=8
 build_style=cmake
 configure_args="-DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="extra-cmake-modules pkg-config protobuf qt5-host-tools qt5-qmake"

From ddaaf55cb1bfa6fa2e89ff885371020bc9db2da1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:28 -0500
Subject: [PATCH 090/108] musikcube: revbump for ffmpeg6

---
 srcpkgs/musikcube/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/musikcube/template b/srcpkgs/musikcube/template
index 8c4a51840859ec..fb60dd2049089a 100644
--- a/srcpkgs/musikcube/template
+++ b/srcpkgs/musikcube/template
@@ -1,7 +1,7 @@
 # Template file for 'musikcube'
 pkgname=musikcube
 version=3.0.0
-revision=3
+revision=4
 build_style=cmake
 make_cmd=make
 configure_args="-DNO_NCURSESW=1"

From daed48d9f185406a2d4b2fb632ddda39ad87b51c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:45 -0500
Subject: [PATCH 091/108] electron24: revbump for ffmpeg6

---
 srcpkgs/electron24/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron24/template b/srcpkgs/electron24/template
index eafb9a0c696131..42b57dc512d822 100644
--- a/srcpkgs/electron24/template
+++ b/srcpkgs/electron24/template
@@ -1,7 +1,7 @@
 # Template file for 'electron24'
 pkgname=electron24
 version=24.3.0
-revision=3
+revision=4
 _nodever=18.14.0
 _chromiumver=112.0.5615.165
 archs="x86_64* aarch64*"

From beaeb07e578b79835b31b1b0a695847f42238834 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:00 -0500
Subject: [PATCH 092/108] electron19: revbump for ffmpeg6

---
 srcpkgs/electron19/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron19/template b/srcpkgs/electron19/template
index 0ef959125cb085..5371c0b354604f 100644
--- a/srcpkgs/electron19/template
+++ b/srcpkgs/electron19/template
@@ -1,7 +1,7 @@
 # Template file for 'electron19'
 pkgname=electron19
 version=19.0.8
-revision=4
+revision=5
 _nodever=16.14.2
 _chromiumver=102.0.5005.125
 archs="x86_64* aarch64* ppc64le*"

From 9ce640c3d953951196c50c2c9a6e40f60d15e71b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:13 -0500
Subject: [PATCH 093/108] wf-recorder: revbump for ffmpeg6

---
 srcpkgs/wf-recorder/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/wf-recorder/template b/srcpkgs/wf-recorder/template
index 08f986b0310067..63c45cf4b814d7 100644
--- a/srcpkgs/wf-recorder/template
+++ b/srcpkgs/wf-recorder/template
@@ -1,7 +1,7 @@
 # Template file for 'wf-recorder'
 pkgname=wf-recorder
 version=0.4.1
-revision=2
+revision=3
 build_style=meson
 hostmakedepends="pkg-config scdoc wayland-devel"
 makedepends="wayland-protocols wayland-devel ffmpeg-devel libgbm-devel x264-devel

From f9b70071f3d80b4e9903ebf61164336d8227c32c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:26 -0500
Subject: [PATCH 094/108] obs: revbump for ffmpeg6

---
 srcpkgs/obs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/obs/template b/srcpkgs/obs/template
index feb9649977a8d4..0888fb3aaaccfe 100644
--- a/srcpkgs/obs/template
+++ b/srcpkgs/obs/template
@@ -1,7 +1,7 @@
 # Template file for 'obs'
 pkgname=obs
 version=30.1.1
-revision=1
+revision=2
 archs="i686* x86_64* ppc64le* aarch64* riscv64*"
 build_style=cmake
 configure_args="-DOBS_VERSION_OVERRIDE=${version} -DENABLE_JACK=ON

From 530be9304e924bfa6737624d24e866329ac634d8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:36 -0500
Subject: [PATCH 095/108] mlt7: revbump for ffmpeg6

---
 srcpkgs/mlt7/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mlt7/template b/srcpkgs/mlt7/template
index 65eed998d39832..59f7ec147f0d04 100644
--- a/srcpkgs/mlt7/template
+++ b/srcpkgs/mlt7/template
@@ -1,7 +1,7 @@
 # Template file for 'mlt7'
 pkgname=mlt7
 version=7.20.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DSWIG_PYTHON=ON -DMOD_QT6=ON"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which

From dcfbe359c97c34d81a9937ed1991e439b56b9120 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:48 -0500
Subject: [PATCH 096/108] qt6-multimedia: revbump for ffmpeg6

---
 srcpkgs/qt6-multimedia/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-multimedia/template b/srcpkgs/qt6-multimedia/template
index 67a577e1300fea..1da626ecf515a8 100644
--- a/srcpkgs/qt6-multimedia/template
+++ b/srcpkgs/qt6-multimedia/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-multimedia'
 pkgname=qt6-multimedia
 version=6.6.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DQT_FEATURE_gstreamer=ON"
 hostmakedepends="perl qt6-declarative-host-tools pkg-config qt6-shadertools"

From dca3a9e3892cd7a7d640e70cd10fd15f8ee29e62 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:00:15 -0500
Subject: [PATCH 097/108] baresip: revbump for ffmpeg6

---
 srcpkgs/baresip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/baresip/template b/srcpkgs/baresip/template
index b16b67beab8d2b..fe21ebf40c03c1 100644
--- a/srcpkgs/baresip/template
+++ b/srcpkgs/baresip/template
@@ -1,7 +1,7 @@
 # Template file for 'baresip'
 pkgname=baresip
 version=3.6.0
-revision=3
+revision=4
 build_style=cmake
 hostmakedepends="pkg-config glib-devel"
 makedepends="libgsm-devel libpng-devel openssl-devel libsndfile-devel

From 17b2a2a3d3d45f46214773d1220f9cd9223fb9b8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:30 -0500
Subject: [PATCH 098/108] QMPlay2: revbump for ffmpeg6

---
 srcpkgs/QMPlay2/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/QMPlay2/template b/srcpkgs/QMPlay2/template
index 83a49d5b0b9415..00e659dc598831 100644
--- a/srcpkgs/QMPlay2/template
+++ b/srcpkgs/QMPlay2/template
@@ -1,7 +1,7 @@
 # Template file for 'QMPlay2'
 pkgname=QMPlay2
 version=24.04.07
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools"
 makedepends="alsa-lib-devel ffmpeg-devel libass-devel libcdio-devel libgme-devel

From 54377d625df9ef5aadd83079f8fe002103f43854 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:34 -0500
Subject: [PATCH 099/108] alsa-plugins: revbump for ffmpeg6

---
 srcpkgs/alsa-plugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/alsa-plugins/template b/srcpkgs/alsa-plugins/template
index a5708a7d82a8f0..7bfdad046c4830 100644
--- a/srcpkgs/alsa-plugins/template
+++ b/srcpkgs/alsa-plugins/template
@@ -1,7 +1,7 @@
 # Template file for 'alsa-plugins'
 pkgname=alsa-plugins
 version=1.2.7.1
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--disable-maemo-plugin"
 hostmakedepends="pkg-config"

From 8af7b9a99b61071c2bbb00a343b8aa2dc4bd66a4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:43 -0500
Subject: [PATCH 100/108] minidlna: revbump for ffmpeg6

---
 srcpkgs/minidlna/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/minidlna/template b/srcpkgs/minidlna/template
index 5fa929f3a0c124..742991ecd04afc 100644
--- a/srcpkgs/minidlna/template
+++ b/srcpkgs/minidlna/template
@@ -1,7 +1,7 @@
 # Template file for 'minidlna'
 pkgname=minidlna
 version=1.3.3
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="
  --sbindir=/usr/bin

From 259616d8418ed341bce077a469b305692ea4eccb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 17:57:47 -0500
Subject: [PATCH 101/108] mpv: revbump for ffmpeg6

---
 srcpkgs/mpv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpv/template b/srcpkgs/mpv/template
index 3d4349e27d8f62..bc40d6fcaa40d6 100644
--- a/srcpkgs/mpv/template
+++ b/srcpkgs/mpv/template
@@ -1,7 +1,7 @@
 # Template file for 'mpv'
 pkgname=mpv
 version=0.37.0
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcdda=enabled -Ddvbin=enabled -Ddvdnav=enabled
  -Dlibmpv=true -Dcplugins=enabled

From 0fe17e359154ebad0003a216d7b87e0b0bb4f324 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 17:59:29 -0500
Subject: [PATCH 102/108] qimgv: revbump for ffmpeg6

---
 srcpkgs/qimgv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qimgv/template b/srcpkgs/qimgv/template
index dd341dfe1bfce8..8a7e1c081ef12f 100644
--- a/srcpkgs/qimgv/template
+++ b/srcpkgs/qimgv/template
@@ -1,7 +1,7 @@
 # Template file for 'qimgv'
 pkgname=qimgv
 version=1.0.2
-revision=3
+revision=4
 build_style=cmake
 configure_args="$(vopt_if video -DVIDEO_SUPPORT=ON -DVIDEO_SUPPORT=OFF)
  $(vopt_if scale -DOPENCV_SUPPORT=ON -DOPENCV_SUPPORT=OFF)

From 98faedae401841d62ed413b3e3bfbf41f88e6499 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 18:00:36 -0500
Subject: [PATCH 103/108] kfilemetadata5: revbump for ffmpeg6

---
 srcpkgs/kfilemetadata5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kfilemetadata5/template b/srcpkgs/kfilemetadata5/template
index a0c4d809395323..b584f85ff2058b 100644
--- a/srcpkgs/kfilemetadata5/template
+++ b/srcpkgs/kfilemetadata5/template
@@ -1,7 +1,7 @@
 # Template file for 'kfilemetadata5'
 pkgname=kfilemetadata5
 version=5.115.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="kcoreaddons extra-cmake-modules pkg-config qt5-host-tools qt5-qmake
  gettext kcoreaddons python3"

From cf99041516a38cccd45883db618081716965096b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 8 Dec 2023 11:46:01 -0500
Subject: [PATCH 104/108] vba-m: revbump for ffmpeg6

---
 srcpkgs/vba-m/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vba-m/template b/srcpkgs/vba-m/template
index 3d135efa1d0b69..3c5a20db0fa984 100644
--- a/srcpkgs/vba-m/template
+++ b/srcpkgs/vba-m/template
@@ -2,7 +2,7 @@
 pkgname=vba-m
 reverts=1292_2
 version=2.1.9
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_GTK=TRUE -DENABLE_FFMPEG=TRUE -DENABLE_LINK=TRUE -DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="gettext pkg-config unzip zip yasm wxWidgets-gtk3-devel"

From abd7056574330c75bfc503e39e6dae2b919deeba Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 8 Dec 2023 11:46:19 -0500
Subject: [PATCH 105/108] dolphin-emu: revbump for ffmpeg6

---
 srcpkgs/dolphin-emu/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/dolphin-emu/template b/srcpkgs/dolphin-emu/template
index 862d3ae964eec4..a7ae0efb58fb75 100644
--- a/srcpkgs/dolphin-emu/template
+++ b/srcpkgs/dolphin-emu/template
@@ -1,7 +1,7 @@
 # Template file for 'dolphin-emu'
 pkgname=dolphin-emu
 version=5.0.19368
-revision=3
+revision=4
 _dolphin_commit=dadbeb4bae7e7fa23af2b46e0add4143094dc107
 _mgba_commit=44e074a15e9651481f7f652ac006a7c9d58cbeb9
 _googletest_commit=be03d00f5f0cc3a997d1a368bee8a1fe93651f48

From 1cc8c9d4dab556cf4271d519c8c41d528b50be4d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 19 Dec 2023 15:38:51 -0500
Subject: [PATCH 106/108] qtox: revbump for ffmpeg4

---
 srcpkgs/qtox/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtox/template b/srcpkgs/qtox/template
index bb70e7f51240a4..755e4462bc0137 100644
--- a/srcpkgs/qtox/template
+++ b/srcpkgs/qtox/template
@@ -1,13 +1,13 @@
 # Template file for 'qtox'
 pkgname=qtox
 version=1.17.6
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DUPDATE_CHECK=OFF
  -DGIT_DESCRIBE=${version}
  $(vopt_if snorenotify -DDESKTOP_NOTIFICATIONS=ON)"
 hostmakedepends="pkg-config qt5-host-tools qt5-devel"
-makedepends="ffmpeg-devel libexif-devel libopenal-devel libsodium-devel
+makedepends="ffmpeg4-devel libexif-devel libopenal-devel libsodium-devel
  libvpx-devel opus-devel qrencode-devel qt5-svg-devel sonnet-devel
  sqlcipher-devel toxcore-devel
  $(vopt_if snorenotify snorenotify-devel)"

From 98d955a0840d79cf5ce88fee33b7f9edb6f5e814 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 11 Jan 2024 11:52:00 -0500
Subject: [PATCH 107/108] arcan: revbump for ffmpeg6

---
 srcpkgs/arcan/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/arcan/template b/srcpkgs/arcan/template
index ff9091f90ebb10..030091a6cc9d0c 100644
--- a/srcpkgs/arcan/template
+++ b/srcpkgs/arcan/template
@@ -2,7 +2,7 @@
 # !! keep synced with: acfgfs aclip aloadimage
 pkgname=arcan
 version=0.6.2.1
-revision=2
+revision=3
 create_wrksrc=yes
 build_wrksrc=arcan/src
 build_style=cmake

From d759ce46bacb7402206cd666464a4d55b0fa3db2 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 11 Jan 2024 11:52:10 -0500
Subject: [PATCH 108/108] notcurses: revbump for ffmpeg6

---
 srcpkgs/notcurses/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/notcurses/template b/srcpkgs/notcurses/template
index 48a7463cb68eb9..515f316ab4576c 100644
--- a/srcpkgs/notcurses/template
+++ b/srcpkgs/notcurses/template
@@ -1,7 +1,7 @@
 # Template file for 'notcurses'
 pkgname=notcurses
 version=3.0.9
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DUSE_STATIC=ON -DUSE_QRCODEGEN=On $(vopt_bool man USE_PANDOC)"
 hostmakedepends="pkg-config $(vopt_if man pandoc)"

^ permalink raw reply	[flat|nested] 99+ messages in thread

* Re: [PR PATCH] [Updated] ffmpeg6 split
  2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
                   ` (96 preceding siblings ...)
  2024-04-13 14:47 ` zlice
@ 2024-04-26 12:45 ` zlice
  97 siblings, 0 replies; 99+ messages in thread
From: zlice @ 2024-04-26 12:45 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 5117 bytes --]

There is an updated pull request by zlice against master on the void-packages repository

https://github.com/zlice/void-packages ffmpeg6-split
https://github.com/void-linux/void-packages/pull/43761

ffmpeg6 split
[ci skip]


#### Testing the changes

- I tested the changes in this PR: **YES**

main testing has been vaapi in Firefox Nightly and enc/dec in Shotcut on Intel A770

#### New package

- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**

#### Local build testing

- I built this PR locally for my native architecture, **x86_64**

#### Discussion

Continuation of https://github.com/void-linux/void-packages/pull/36315

`libavresample` is deprecated, but marked as a dependency when trying to build other packages and install `ffmpeg`(6). I think the right way to handle this is make a meta package and the add to removals?


##### Commit naming / misc

~~Commits are 'dirty' right now, running with [gstreamer 1.22.1 updates](https://github.com/void-linux/void-packages/pull/42861) and [Intel OpenCL](https://github.com/void-linux/void-packages/pull/43084). This will also make [intel packages pr](https://github.com/void-linux/void-packages/pull/41132) obsolete.~~ (see Requirements below)

Maintainer for previous ffmpeg(4) was orphaned, I can put my name in there if that matters, though I don't exactly see myself keeping up on ffmpeg.

~~This updates QT5 which looks like it is usually hosted by Johnny. Not sure if there's any reason to stay there or these sources are fine.~~ Using qt5.15.11 now, revbumps and some patches.

##### STILL FFMPEG4

These are a mix of emulators, games and/or older packages.

- ~~attract~~ (2.7 builds)
- ~~audacity (https://github.com/audacity/audacity/issues/2305 and https://sourceforge.net/p/portmedia/wiki/portsmf/ is 'beta')~~ (updated to 3.x, compiles with ffmpeg6)
- ~~ccextractor~~ (master patches)
- ~~vice (3.8 compiles, needs makedepends libcurl-devel)~~ ty yosh
- kodi
- mlt (only dep left is flowblade - flowblade 2.12.0.2 with mlt7-python3 can 'render' videos with cpu and gpu - https://github.com/void-linux/void-packages/pull/47195)
- ~~synfig (mlt)~~ (work with mlt7, bump synfigstudio)
- tvheadend (download page recommends using 4.3 which compiles fine, 4.4 eta is Q1 2024)
- ~~ssr~~ (patches)
- ~~spek-alternative~~ (replace with spek-x)
- ~~ppsspp~~ ~~(1.17.1 is out, but there's 5+ distfiles that are all git commits)~~ (minor patch)
- olive (has been in alpha since 2020, seems they do nightly builds and appimages)
- moc
- mediastreamer (linphone links are dead, changed to github belladonne. their stuff never worked for me but there are updates if someone wants to give it a try)
- ~~libextractor (1.13 compiles, remove exiv2 patch)~~ (as yosh pointed out, 1.13 just removes ffmpeg bits)
- idjc (0.9.8 compiles, remove python3.10 patch, needs makedepends libebur128-devel and libshout-idjc 2.4.6 with '-r1' for distfile)
- hedgewars
- ~~ffmpegthumbnailer~~ (patches for moviedecoder.xxx files)
- ~~ffmpegthumbs~~ (latest compiles)
- deadbeef (1.9.6 may work but requires libdispatch from apple)
- ~~omxplayer~~ (package removed, deprecated in favor of vlc)
- qtav (fork has ffmpeg 5 patch - https://github.com/cmguo/QtAV)
- `vlc` (vlc4 will support ffmpeg5, there's a patch to build 3.x with ffmpeg5 but it will lack vaapi)
- `osg` (OpenSceneGraph plus `xine-lib`) (patches from osg issue build with ffmpeg6, [ffmpeg5.patch.txt](https://github.com/void-linux/void-packages/files/14743246/ffmpeg5.patch.txt))



##### HAVE NOT BUILT YET

- ~~omxplayer (rpi only? ffmpeg4)~~ (removed)
- kodi (big, but ffmpeg4)


##### UPDATED (for ffmpeg6)

- ~~blender: update to 3.5.1~~ ~~will be revbump with~~ https://github.com/void-linux/void-packages/pull/43992
- unpaper: update to 7.0.0.
- guvcview: update to 2.0.8.
- ~~qt5: update to 5.15.8~~ updated by another PR to 5.15.11
- ~~qt5-webengine: update to 5.18.15~~ updated by another PR to 5.15.16 (some patching for ffmpeg build)
- ~~shiboken2: revbump for qt5.15.8 (patch)~~ updated by another PR to 5.15.10
- ~~python3-pyside2: update to 5.15.8 (patch)~~ updated by another PR to 5.15.10
- New package: spex-x replaces spek-alternative for ffmpeg-6.0


##### Requirements

- ~~[gstreamer 1.22.2](https://github.com/void-linux/void-packages/pull/42861)~~ - a few packages use ffmpeg-devel and require a revbump

- ~~[Intel Packages](https://github.com/void-linux/void-packages/pull/41132) [Intel Packages v2](https://github.com/void-linux/void-packages/pull/47330) - ffmpeg4 uses different libraries than 6 (libmfx / Intel-MediaSDK vs only oneVPL that Intel is moving to), both are included here~~. Using replacement oneVPL from OBS update.

- ~~[shotcut 23.05.14](https://github.com/void-linux/void-packages/pull/44260)~~

- https://github.com/void-linux/void-packages/pull/44781 will remove from this PR

A patch file from https://github.com/void-linux/void-packages/pull/43761.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ffmpeg6-split-43761.patch --]
[-- Type: text/x-diff, Size: 240172 bytes --]

From 120c35ffff8224cb5acf08208b9fb92daea24e20 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:16:56 -0400
Subject: [PATCH 001/108] ffmpeg: update to 6.0.1.

---
 common/shlibs                                 | 26 ++++---
 srcpkgs/ffmpeg/files/altivec.patch            | 60 ---------------
 .../patches/armv5tel-floating-point.patch     | 18 -----
 srcpkgs/ffmpeg/patches/binutils-2.41.patch    | 73 -------------------
 ...h-libavcodec-libsvtav1-ten_bit_format.diff | 40 ----------
 .../workaround-mesa-readeon-vaapi-bug.patch   | 28 -------
 srcpkgs/ffmpeg/template                       | 40 +++++-----
 7 files changed, 37 insertions(+), 248 deletions(-)
 delete mode 100644 srcpkgs/ffmpeg/files/altivec.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/binutils-2.41.patch
 delete mode 100644 srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 delete mode 100644 srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch

diff --git a/common/shlibs b/common/shlibs
index 794290d3a2f77d..bbd268f650d066 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -390,15 +390,23 @@ libid3tag.so.0 libid3tag-0.15.1b_1
 libgif.so.7 giflib-5.1.0_1
 libImlib2.so.1 imlib2-1.4.2_1
 libmp3lame.so.0 lame-3.98.2_1
-libavdevice.so.58 libavdevice-4.0_1
-libavformat.so.58 libavformat-4.0_1
-libswscale.so.5 libswscale-4.0_1
-libswresample.so.3 libswresample-4.0_1
-libavresample.so.4 libavresample-4.0_1
-libpostproc.so.55 libpostproc-4.0_1
-libavcodec.so.58 libavcodec-4.0_1
-libavutil.so.56 libavutil-4.0_1
-libavfilter.so.7 libavfilter-4.0_1
+libavdevice.so.60 libavdevice-6.0_1
+libavformat.so.60 libavformat-6.0_1
+libswscale.so.7 libswscale-6.0_1
+libswresample.so.4 libswresample-6.0_1
+libpostproc.so.57 libpostproc-6.0_1
+libavcodec.so.60 libavcodec-6.0_1
+libavutil.so.58 libavutil-6.0_1
+libavfilter.so.9 libavfilter-6.0_1
+libavdevice.so.58 libavdevice4-4.0_1
+libavformat.so.58 libavformat4-4.0_1
+libswscale.so.5 libswscale4-4.0_1
+libswresample.so.3 libswresample4-4.0_1
+libavresample.so.4 libavresample4-4.0_1
+libpostproc.so.55 libpostproc4-4.0_1
+libavcodec.so.58 libavcodec4-4.0_1
+libavutil.so.56 libavutil4-4.0_1
+libavfilter.so.7 libavfilter4-4.0_1
 libSDL-1.2.so.0 SDL-1.2.14_1
 libSDL_image-1.2.so.0 SDL_image-1.2.10_1
 libx264.so.157 x264-20190507.2245_1
diff --git a/srcpkgs/ffmpeg/files/altivec.patch b/srcpkgs/ffmpeg/files/altivec.patch
deleted file mode 100644
index 9c57200463320e..00000000000000
--- a/srcpkgs/ffmpeg/files/altivec.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-revert some altivec specific change on all ppc* except ppc64le*
-
-q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
-conditionally, for ppc* but not ppc64le* (the new code is valid for
-POWER8 VSX which LE targets as a baseline but not BE)"
-
-
-This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
----
- libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
- 1 file changed, 20 insertions(+), 4 deletions(-)
-
-diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
-index 536545293d..c1e2852adb 100644
---- a/libswscale/ppc/yuv2rgb_altivec.c
-+++ b/libswscale/ppc/yuv2rgb_altivec.c
-@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-     vector signed short R1, G1, B1;                                           \
-     vector unsigned char R, G, B;                                             \
-                                                                               \
-+    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
-+    vector unsigned char align_perm;                                          \
-+                                                                              \
-     vector signed short lCY       = c->CY;                                    \
-     vector signed short lOY       = c->OY;                                    \
-     vector signed short lCRV      = c->CRV;                                   \
-@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
-         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
-                                                                               \
-         for (j = 0; j < w / 16; j++) {                                        \
--            y0 = vec_xl(0, y1i);                                              \
-+            y1ivP = (const vector unsigned char *) y1i;                       \
-+            y2ivP = (const vector unsigned char *) y2i;                       \
-+            uivP  = (const vector unsigned char *) ui;                        \
-+            vivP  = (const vector unsigned char *) vi;                        \
-+                                                                              \
-+            align_perm = vec_lvsl(0, y1i);                                    \
-+            y0 = (vector unsigned char)                                       \
-+                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
-                                                                               \
--            y1 = vec_xl(0, y2i);                                              \
-+            align_perm = vec_lvsl(0, y2i);                                    \
-+            y1 = (vector unsigned char)                                       \
-+                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
-                                                                               \
--            u = (vector signed char) vec_xl(0, ui);                           \
-+            align_perm = vec_lvsl(0, ui);                                     \
-+            u = (vector signed char)                                          \
-+                    vec_perm(uivP[0], uivP[1], align_perm);                   \
-                                                                               \
--            v = (vector signed char) vec_xl(0, vi);                           \
-+            align_perm = vec_lvsl(0, vi);                                     \
-+            v = (vector signed char)                                          \
-+                    vec_perm(vivP[0], vivP[1], align_perm);                   \
-                                                                               \
-             u = (vector signed char)                                          \
-                     vec_sub(u,                                                \
--- 
-2.27.0
-
diff --git a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
deleted file mode 100644
index 9a55178c74f0fd..00000000000000
--- a/srcpkgs/ffmpeg/patches/armv5tel-floating-point.patch
+++ /dev/null
@@ -1,18 +0,0 @@
---- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
-+++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
-@@ -39,6 +39,15 @@
- #endif
- #include <fenv.h>
- 
-+#if (FE_ALL_EXCEPT == 0)
-+/* E.g. ARM soft float does not define these */
-+#define FE_INVALID    0
-+#define FE_DIVBYZERO  0
-+#define FE_OVERFLOW   0
-+#define FE_UNDERFLOW  0
-+#define FE_INEXACT    0
-+#endif
-+
- #if CONFIG_LIBFONTCONFIG
- #include <fontconfig/fontconfig.h>
- #endif
diff --git a/srcpkgs/ffmpeg/patches/binutils-2.41.patch b/srcpkgs/ffmpeg/patches/binutils-2.41.patch
deleted file mode 100644
index 53a596d0ee7d4e..00000000000000
--- a/srcpkgs/ffmpeg/patches/binutils-2.41.patch
+++ /dev/null
@@ -1,73 +0,0 @@
-From effadce6c756247ea8bae32dc13bb3e6f464f0eb Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= <remi@remlab.net>
-Date: Sun, 16 Jul 2023 18:18:02 +0300
-Subject: [PATCH] avcodec/x86/mathops: clip constants used with shift
- instructions within inline assembly
-
-Fixes assembling with binutil as >= 2.41
-
-Signed-off-by: James Almer <jamrial@gmail.com>
----
- libavcodec/x86/mathops.h | 26 +++++++++++++++++++++++---
- 1 file changed, 23 insertions(+), 3 deletions(-)
-
-diff --git a/libavcodec/x86/mathops.h b/libavcodec/x86/mathops.h
-index 6298f5ed1983b..ca7e2dffc1076 100644
---- a/libavcodec/x86/mathops.h
-+++ b/libavcodec/x86/mathops.h
-@@ -35,12 +35,20 @@
- static av_always_inline av_const int MULL(int a, int b, unsigned shift)
- {
-     int rt, dummy;
-+    if (__builtin_constant_p(shift))
-     __asm__ (
-         "imull %3               \n\t"
-         "shrdl %4, %%edx, %%eax \n\t"
-         :"=a"(rt), "=d"(dummy)
--        :"a"(a), "rm"(b), "ci"((uint8_t)shift)
-+        :"a"(a), "rm"(b), "i"(shift & 0x1F)
-     );
-+    else
-+        __asm__ (
-+            "imull %3               \n\t"
-+            "shrdl %4, %%edx, %%eax \n\t"
-+            :"=a"(rt), "=d"(dummy)
-+            :"a"(a), "rm"(b), "c"((uint8_t)shift)
-+        );
-     return rt;
- }
- 
-@@ -113,19 +121,31 @@ __asm__ volatile(\
- // avoid +32 for shift optimization (gcc should do that ...)
- #define NEG_SSR32 NEG_SSR32
- static inline  int32_t NEG_SSR32( int32_t a, int8_t s){
-+    if (__builtin_constant_p(s))
-     __asm__ ("sarl %1, %0\n\t"
-          : "+r" (a)
--         : "ic" ((uint8_t)(-s))
-+         : "i" (-s & 0x1F)
-     );
-+    else
-+        __asm__ ("sarl %1, %0\n\t"
-+               : "+r" (a)
-+               : "c" ((uint8_t)(-s))
-+        );
-     return a;
- }
- 
- #define NEG_USR32 NEG_USR32
- static inline uint32_t NEG_USR32(uint32_t a, int8_t s){
-+    if (__builtin_constant_p(s))
-     __asm__ ("shrl %1, %0\n\t"
-          : "+r" (a)
--         : "ic" ((uint8_t)(-s))
-+         : "i" (-s & 0x1F)
-     );
-+    else
-+        __asm__ ("shrl %1, %0\n\t"
-+               : "+r" (a)
-+               : "c" ((uint8_t)(-s))
-+        );
-     return a;
- }
- 
diff --git a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
deleted file mode 100644
index aa948f7a8a2dfb..00000000000000
--- a/srcpkgs/ffmpeg/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
+++ /dev/null
@@ -1,40 +0,0 @@
-#==================================================================================================
-# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
-# From: Christopher Degawa <christopher.degawa@intel.com>
-# Date: Thu, 20 Oct 2022 22:55:27 -0500
-# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
-#
-# compressed_ten_bit_format has been deprecated upstream and has no effect
-# and can be removed. Plus, technically it was never used in the first place
-# since it would require the app (ffmpeg) to set it and do additional
-# processing of the input frames.
-#
-# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
-#
-# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
-#==================================================================================================
---- a/libavcodec/libsvtav1.c
-+++ b/libavcodec/libsvtav1.c
-@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
- 
- static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
- {
--    const int    pack_mode_10bit =
--        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
--    const size_t luma_size_8bit  =
--        config->source_width * config->source_height * (1 << pack_mode_10bit);
--    const size_t luma_size_10bit =
--        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
-+    const size_t luma_size = config->source_width * config->source_height *
-+        (config->encoder_bit_depth > 8 ? 2 : 1);
- 
-     EbSvtIOFormat *in_data;
- 
--    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
-+    svt_enc->raw_size = luma_size * 3 / 2;
- 
-     // allocate buffer for in and out
-     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
--- 
-GitLab
-
diff --git a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
deleted file mode 100644
index 00e3f68a415b84..00000000000000
--- a/srcpkgs/ffmpeg/patches/workaround-mesa-readeon-vaapi-bug.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
-From: Rainer Hochecker <fernetmenta@online.de>
-Date: Sat, 26 Jan 2019 19:48:35 +0100
-Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
-
-This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
-It was hit frequently when watching h264 channels received via DVB-X.
-Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
----
- libavcodec/vaapi_h264.c | 5 +++++
- 1 file changed, 5 insertions(+)
-
-diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
-index 5854587a255..f12fdc457a4 100644
---- a/libavcodec/vaapi_h264.c
-+++ b/libavcodec/vaapi_h264.c
-@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
-     H264SliceContext *sl = &h->slice_ctx[0];
-     int ret;
- 
-+    if (pic->nb_slices == 0) {
-+        ret = AVERROR_INVALIDDATA;
-+        goto finish;
-+    }
-+
-     ret = ff_vaapi_decode_issue(avctx, pic);
-     if (ret < 0)
-         goto finish;
diff --git a/srcpkgs/ffmpeg/template b/srcpkgs/ffmpeg/template
index 1ebb436135938d..f1e4712c41d087 100644
--- a/srcpkgs/ffmpeg/template
+++ b/srcpkgs/ffmpeg/template
@@ -1,15 +1,15 @@
 # Template file for 'ffmpeg'
 # audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
 pkgname=ffmpeg
-version=4.4.4
-revision=6
+version=6.0.1
+revision=1
 short_desc="Decoding, encoding and streaming software"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="https://www.ffmpeg.org"
 changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
 distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
-checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+checksum=9b16b8731d78e596b4be0d720428ca42df642bb2d78342881ff7f5bc29fc9623
 
 hostmakedepends="pkg-config perl"
 makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
@@ -26,12 +26,13 @@ makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-deve
  $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
  $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
  $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
- $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers Vulkan-Tools Vulkan-ValidationLayers')
+ $(vopt_if onevpl 'oneVPL oneVPL-devel')
  $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
 depends="ffplay>=${version}_${revision}"
 
 build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
- dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec onevpl"
 build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
 desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
 desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
@@ -39,9 +40,13 @@ desc_option_sofa="Enable support for AES SOFA"
 desc_option_webp="Enable support for WebP"
 
 case "$XBPS_TARGET_MACHINE" in
-	i686*|x86_64*)
-		hostmakedepends+=" nasm"
+	i686*)
 		build_options_default+=" vaapi vdpau nvenc nvdec"
+		hostmakedepends+=" nasm"
+		;;
+	x86_64*)
+		hostmakedepends+=" nasm"
+		build_options_default+=" vaapi vdpau nvenc nvdec onevpl"
 		;;
 	ppc64*) build_options_default+=" vaapi vdpau";;
 	mips*) CFLAGS="-mnan=legacy";;
@@ -65,8 +70,6 @@ post_patch() {
 		ppc64le*) ;;
 		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
 	esac
-
-	vsed -i libavfilter/vf_libvmaf.c -e 's!/usr/local/share/model/\(vmaf_v0.6.1\).pkl!/usr/share/vmaf/\1.json!'
 }
 
 do_configure() {
@@ -115,18 +118,19 @@ do_configure() {
 		$(vopt_enable x265 libx265) \
 		$(vopt_enable v4l2 libv4l2) \
 		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
-		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		--enable-libbs2b --enable-libvidstab \
 		$(vopt_enable dav1d libdav1d) \
 		$(vopt_enable zimg libzimg) \
 		$(vopt_enable webp libwebp) \
 		$(vopt_enable sofa libmysofa) \
 		$(vopt_enable vulkan) \
+		$(vopt_enable onevpl libvpl) \
 		$(vopt_enable drm libdrm) \
 		$(vopt_enable svtav1 libsvtav1) \
 		$(vopt_enable srt libsrt) \
 		$(vopt_enable rist librist) \
-		$(vopt_if nvenc '--enable-nvenc') \
-		$(vopt_if nvdec '--enable-nvdec')
+		$(vopt_enable nvenc nvenc) \
+		$(vopt_enable nvdec nvdec)
 }
 
 do_build() {
@@ -153,10 +157,8 @@ libavdevice_package() {
 }
 
 libavresample_package() {
-	short_desc="FFmpeg audio resampling library"
-	pkg_install() {
-		vmove "usr/lib/libavresample.so.*"
-	}
+	short_desc="Package deprecated, removal needed"
+	build_style=meta
 }
 
 libavformat_package() {
@@ -210,15 +212,13 @@ ffmpeg-devel_package() {
 		libavfilter>=${version}_${revision}
 		libpostproc>=${version}_${revision}
 		libswscale>=${version}_${revision}
-		libswresample>=${version}_${revision}
-		libavresample>=${version}_${revision}"
+		libswresample>=${version}_${revision}"
 	short_desc+=" - development files"
-
+	conflicts="ffmpeg4-devel"
 	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
 		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
 		nostrip_files="/usr/lib/libavfilter.a"
 	fi
-
 	pkg_install() {
 		vmove usr/include
 		vmove usr/lib/pkgconfig

From d380fd3186f07febcef0d51fd0c7a62e0c712db1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:14 -0400
Subject: [PATCH 002/108] openshot: revbump for ffmpeg6

---
 srcpkgs/openshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openshot/template b/srcpkgs/openshot/template
index 3849858fe963b5..12789bc9867499 100644
--- a/srcpkgs/openshot/template
+++ b/srcpkgs/openshot/template
@@ -1,7 +1,7 @@
 # Template file for 'openshot'
 pkgname=openshot
 version=3.1.1
-revision=1
+revision=2
 build_style=python3-module
 hostmakedepends="python3 python3-setuptools"
 makedepends="ffmpeg-devel python3-PyQt5"

From 12970ed585b01400c928d4e55380e54ad6820e04 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:18:36 -0400
Subject: [PATCH 003/108] sumo: revbump for ffmpeg6

---
 srcpkgs/sumo/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/sumo/template b/srcpkgs/sumo/template
index a730afa9fafa92..e2def06fa4bd7d 100644
--- a/srcpkgs/sumo/template
+++ b/srcpkgs/sumo/template
@@ -1,7 +1,7 @@
 # Template file for 'sumo'
 pkgname=sumo
 version=1.12.0
-revision=7
+revision=8
 build_style=cmake
 hostmakedepends="libgdal-tools pkg-config swig python3-setuptools"
 makedepends="python3-devel ffmpeg-devel fox-devel gl2ps-devel libgdal-devel

From 0d48ed6dc790ed3b40dc965b39582ae922534891 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:56:22 -0400
Subject: [PATCH 004/108] New package: ffmpeg4-4.4.4.

---
 srcpkgs/ffmpeg4-devel                         |   1 +
 srcpkgs/ffmpeg4/files/altivec.patch           |  60 +++++
 .../patches/armv5tel-floating-point.patch     |  18 ++
 srcpkgs/ffmpeg4/patches/binutils-2.41.patch   |  73 ++++++
 ...h-libavcodec-libsvtav1-ten_bit_format.diff |  40 +++
 .../workaround-mesa-readeon-vaapi-bug.patch   |  28 +++
 srcpkgs/ffmpeg4/template                      | 234 ++++++++++++++++++
 srcpkgs/libavcodec4                           |   1 +
 srcpkgs/libavdevice4                          |   1 +
 srcpkgs/libavfilter4                          |   1 +
 srcpkgs/libavformat4                          |   1 +
 srcpkgs/libavresample4                        |   1 +
 srcpkgs/libavutil4                            |   1 +
 srcpkgs/libpostproc4                          |   1 +
 srcpkgs/libswresample4                        |   1 +
 srcpkgs/libswscale4                           |   1 +
 16 files changed, 463 insertions(+)
 create mode 120000 srcpkgs/ffmpeg4-devel
 create mode 100644 srcpkgs/ffmpeg4/files/altivec.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/binutils-2.41.patch
 create mode 100644 srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
 create mode 100644 srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
 create mode 100644 srcpkgs/ffmpeg4/template
 create mode 120000 srcpkgs/libavcodec4
 create mode 120000 srcpkgs/libavdevice4
 create mode 120000 srcpkgs/libavfilter4
 create mode 120000 srcpkgs/libavformat4
 create mode 120000 srcpkgs/libavresample4
 create mode 120000 srcpkgs/libavutil4
 create mode 120000 srcpkgs/libpostproc4
 create mode 120000 srcpkgs/libswresample4
 create mode 120000 srcpkgs/libswscale4

diff --git a/srcpkgs/ffmpeg4-devel b/srcpkgs/ffmpeg4-devel
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/ffmpeg4-devel
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/ffmpeg4/files/altivec.patch b/srcpkgs/ffmpeg4/files/altivec.patch
new file mode 100644
index 00000000000000..9c57200463320e
--- /dev/null
+++ b/srcpkgs/ffmpeg4/files/altivec.patch
@@ -0,0 +1,60 @@
+revert some altivec specific change on all ppc* except ppc64le*
+
+q66: "We should also throw in a revert of FFmpeg/FFmpeg@3a557c5 but only
+conditionally, for ppc* but not ppc64le* (the new code is valid for
+POWER8 VSX which LE targets as a baseline but not BE)"
+
+
+This reverts commit 3a557c5d88b7b15b5954ba2743febb055549b536.
+---
+ libswscale/ppc/yuv2rgb_altivec.c | 24 ++++++++++++++++++++----
+ 1 file changed, 20 insertions(+), 4 deletions(-)
+
+diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
+index 536545293d..c1e2852adb 100644
+--- a/libswscale/ppc/yuv2rgb_altivec.c
++++ b/libswscale/ppc/yuv2rgb_altivec.c
+@@ -305,6 +305,9 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+     vector signed short R1, G1, B1;                                           \
+     vector unsigned char R, G, B;                                             \
+                                                                               \
++    const vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP;                  \
++    vector unsigned char align_perm;                                          \
++                                                                              \
+     vector signed short lCY       = c->CY;                                    \
+     vector signed short lOY       = c->OY;                                    \
+     vector signed short lCRV      = c->CRV;                                   \
+@@ -335,13 +338,26 @@ static int altivec_ ## name(SwsContext *c, const unsigned char **in,          \
+         vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1);       \
+                                                                               \
+         for (j = 0; j < w / 16; j++) {                                        \
+-            y0 = vec_xl(0, y1i);                                              \
++            y1ivP = (const vector unsigned char *) y1i;                       \
++            y2ivP = (const vector unsigned char *) y2i;                       \
++            uivP  = (const vector unsigned char *) ui;                        \
++            vivP  = (const vector unsigned char *) vi;                        \
++                                                                              \
++            align_perm = vec_lvsl(0, y1i);                                    \
++            y0 = (vector unsigned char)                                       \
++                     vec_perm(y1ivP[0], y1ivP[1], align_perm);                \
+                                                                               \
+-            y1 = vec_xl(0, y2i);                                              \
++            align_perm = vec_lvsl(0, y2i);                                    \
++            y1 = (vector unsigned char)                                       \
++                     vec_perm(y2ivP[0], y2ivP[1], align_perm);                \
+                                                                               \
+-            u = (vector signed char) vec_xl(0, ui);                           \
++            align_perm = vec_lvsl(0, ui);                                     \
++            u = (vector signed char)                                          \
++                    vec_perm(uivP[0], uivP[1], align_perm);                   \
+                                                                               \
+-            v = (vector signed char) vec_xl(0, vi);                           \
++            align_perm = vec_lvsl(0, vi);                                     \
++            v = (vector signed char)                                          \
++                    vec_perm(vivP[0], vivP[1], align_perm);                   \
+                                                                               \
+             u = (vector signed char)                                          \
+                     vec_sub(u,                                                \
+-- 
+2.27.0
+
diff --git a/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
new file mode 100644
index 00000000000000..9a55178c74f0fd
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/armv5tel-floating-point.patch
@@ -0,0 +1,18 @@
+--- a/libavfilter/vf_drawtext.c	2017-10-26 21:03:03.000000000 +0200
++++ b/libavfilter/vf_drawtext.c	2017-11-21 11:06:49.602284422 +0100
+@@ -39,6 +39,15 @@
+ #endif
+ #include <fenv.h>
+ 
++#if (FE_ALL_EXCEPT == 0)
++/* E.g. ARM soft float does not define these */
++#define FE_INVALID    0
++#define FE_DIVBYZERO  0
++#define FE_OVERFLOW   0
++#define FE_UNDERFLOW  0
++#define FE_INEXACT    0
++#endif
++
+ #if CONFIG_LIBFONTCONFIG
+ #include <fontconfig/fontconfig.h>
+ #endif
diff --git a/srcpkgs/ffmpeg4/patches/binutils-2.41.patch b/srcpkgs/ffmpeg4/patches/binutils-2.41.patch
new file mode 100644
index 00000000000000..53a596d0ee7d4e
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/binutils-2.41.patch
@@ -0,0 +1,73 @@
+From effadce6c756247ea8bae32dc13bb3e6f464f0eb Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= <remi@remlab.net>
+Date: Sun, 16 Jul 2023 18:18:02 +0300
+Subject: [PATCH] avcodec/x86/mathops: clip constants used with shift
+ instructions within inline assembly
+
+Fixes assembling with binutil as >= 2.41
+
+Signed-off-by: James Almer <jamrial@gmail.com>
+---
+ libavcodec/x86/mathops.h | 26 +++++++++++++++++++++++---
+ 1 file changed, 23 insertions(+), 3 deletions(-)
+
+diff --git a/libavcodec/x86/mathops.h b/libavcodec/x86/mathops.h
+index 6298f5ed1983b..ca7e2dffc1076 100644
+--- a/libavcodec/x86/mathops.h
++++ b/libavcodec/x86/mathops.h
+@@ -35,12 +35,20 @@
+ static av_always_inline av_const int MULL(int a, int b, unsigned shift)
+ {
+     int rt, dummy;
++    if (__builtin_constant_p(shift))
+     __asm__ (
+         "imull %3               \n\t"
+         "shrdl %4, %%edx, %%eax \n\t"
+         :"=a"(rt), "=d"(dummy)
+-        :"a"(a), "rm"(b), "ci"((uint8_t)shift)
++        :"a"(a), "rm"(b), "i"(shift & 0x1F)
+     );
++    else
++        __asm__ (
++            "imull %3               \n\t"
++            "shrdl %4, %%edx, %%eax \n\t"
++            :"=a"(rt), "=d"(dummy)
++            :"a"(a), "rm"(b), "c"((uint8_t)shift)
++        );
+     return rt;
+ }
+ 
+@@ -113,19 +121,31 @@ __asm__ volatile(\
+ // avoid +32 for shift optimization (gcc should do that ...)
+ #define NEG_SSR32 NEG_SSR32
+ static inline  int32_t NEG_SSR32( int32_t a, int8_t s){
++    if (__builtin_constant_p(s))
+     __asm__ ("sarl %1, %0\n\t"
+          : "+r" (a)
+-         : "ic" ((uint8_t)(-s))
++         : "i" (-s & 0x1F)
+     );
++    else
++        __asm__ ("sarl %1, %0\n\t"
++               : "+r" (a)
++               : "c" ((uint8_t)(-s))
++        );
+     return a;
+ }
+ 
+ #define NEG_USR32 NEG_USR32
+ static inline uint32_t NEG_USR32(uint32_t a, int8_t s){
++    if (__builtin_constant_p(s))
+     __asm__ ("shrl %1, %0\n\t"
+          : "+r" (a)
+-         : "ic" ((uint8_t)(-s))
++         : "i" (-s & 0x1F)
+     );
++    else
++        __asm__ ("shrl %1, %0\n\t"
++               : "+r" (a)
++               : "c" ((uint8_t)(-s))
++        );
+     return a;
+ }
+ 
diff --git a/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
new file mode 100644
index 00000000000000..aa948f7a8a2dfb
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/patch-libavcodec-libsvtav1-ten_bit_format.diff
@@ -0,0 +1,40 @@
+#==================================================================================================
+# From 031f1561cd286596cdb374da32f8aa816ce3b135 Mon Sep 17 00:00:00 2001
+# From: Christopher Degawa <christopher.degawa@intel.com>
+# Date: Thu, 20 Oct 2022 22:55:27 -0500
+# Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and simplify alloc_buffer
+#
+# compressed_ten_bit_format has been deprecated upstream and has no effect
+# and can be removed. Plus, technically it was never used in the first place
+# since it would require the app (ffmpeg) to set it and do additional
+# processing of the input frames.
+#
+# Also simplify alloc_buffer by removing calculations relating to the non-existant processing.
+#
+# Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
+#==================================================================================================
+--- a/libavcodec/libsvtav1.c
++++ b/libavcodec/libsvtav1.c
+@@ -124,16 +124,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err,
+ 
+ static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc)
+ {
+-    const int    pack_mode_10bit =
+-        (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0;
+-    const size_t luma_size_8bit  =
+-        config->source_width * config->source_height * (1 << pack_mode_10bit);
+-    const size_t luma_size_10bit =
+-        (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0;
++    const size_t luma_size = config->source_width * config->source_height *
++        (config->encoder_bit_depth > 8 ? 2 : 1);
+ 
+     EbSvtIOFormat *in_data;
+ 
+-    svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2;
++    svt_enc->raw_size = luma_size * 3 / 2;
+ 
+     // allocate buffer for in and out
+     svt_enc->in_buf           = av_mallocz(sizeof(*svt_enc->in_buf));
+-- 
+GitLab
+
diff --git a/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
new file mode 100644
index 00000000000000..00e3f68a415b84
--- /dev/null
+++ b/srcpkgs/ffmpeg4/patches/workaround-mesa-readeon-vaapi-bug.patch
@@ -0,0 +1,28 @@
+From 811d290844206fc73dc39c3e5b67d5d895baedf8 Mon Sep 17 00:00:00 2001
+From: Rainer Hochecker <fernetmenta@online.de>
+Date: Sat, 26 Jan 2019 19:48:35 +0100
+Subject: [PATCH] avcodec/vaapi_h264: skip decode if pic has no slices
+
+This fixes / workarounds https://bugs.freedesktop.org/show_bug.cgi?id=105368.
+It was hit frequently when watching h264 channels received via DVB-X.
+Corresponding kodi bug: https://github.com/xbmc/xbmc/issues/15704
+---
+ libavcodec/vaapi_h264.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
+index 5854587a255..f12fdc457a4 100644
+--- a/libavcodec/vaapi_h264.c
++++ b/libavcodec/vaapi_h264.c
+@@ -317,6 +317,11 @@ static int vaapi_h264_end_frame(AVCodecContext *avctx)
+     H264SliceContext *sl = &h->slice_ctx[0];
+     int ret;
+ 
++    if (pic->nb_slices == 0) {
++        ret = AVERROR_INVALIDDATA;
++        goto finish;
++    }
++
+     ret = ff_vaapi_decode_issue(avctx, pic);
+     if (ret < 0)
+         goto finish;
diff --git a/srcpkgs/ffmpeg4/template b/srcpkgs/ffmpeg4/template
new file mode 100644
index 00000000000000..9ba14bdb8ddf32
--- /dev/null
+++ b/srcpkgs/ffmpeg4/template
@@ -0,0 +1,234 @@
+# Template file for 'ffmpeg4'
+# audacity also needs to be bumped when a new ffmpeg version bumps libavformat's soname!
+pkgname=ffmpeg4
+version=4.4.4
+revision=1
+short_desc="Decoding, encoding and streaming software - ffmpeg4 libraries only"
+maintainer="Orphaned <orphan@voidlinux.org>"
+license="GPL-3.0-or-later"
+homepage="https://www.ffmpeg.org"
+changelog="https://raw.githubusercontent.com/FFmpeg/FFmpeg/master/Changelog"
+distfiles="https://www.ffmpeg.org/releases/ffmpeg-${version}.tar.xz"
+checksum=e80b380d595c809060f66f96a5d849511ef4a76a26b76eacf5778b94c3570309
+
+hostmakedepends="pkg-config perl"
+makedepends="zlib-devel bzip2-devel freetype-devel alsa-lib-devel libXfixes-devel
+ libXext-devel libXvMC-devel libxcb-devel lame-devel libtheora-devel
+ libvorbis-devel x264-devel xvidcore-devel jack-devel SDL2-devel
+ libcdio-paranoia-devel librtmp-devel libmodplug-devel gnutls-devel
+ speex-devel celt-devel harfbuzz-devel libass-devel opus-devel ocl-icd-devel
+ libbs2b-devel libvidstab-devel vmaf-devel $(vopt_if pulseaudio pulseaudio-devel)
+ $(vopt_if vaapi libva-devel) $(vopt_if vdpau libvdpau-devel)
+ $(vopt_if x265 x265-devel) $(vopt_if v4l2 v4l-utils-devel)
+ $(vopt_if fdk_aac fdk-aac-devel) $(vopt_if vpx libvpx-devel)
+ $(vopt_if aom libaom-devel) $(vopt_if sndio sndio-devel)
+ $(vopt_if dav1d libdav1d-devel) $(vopt_if zimg zimg-devel)
+ $(vopt_if webp libwebp-devel) $(vopt_if sofa libmysofa-devel)
+ $(vopt_if drm libdrm-devel) $(vopt_if svtav1 libsvt-av1-devel)
+ $(vopt_if srt srt-devel) $(vopt_if rist librist-devel)
+ $(vopt_if vulkan 'vulkan-loader Vulkan-Headers')
+ $(vopt_if nvenc nv-codec-headers) $(vopt_if nvdec nv-codec-headers)"
+
+build_options="x265 v4l2 vaapi vdpau vpx fdk_aac aom nvenc sndio pulseaudio
+ dav1d zimg webp sofa vulkan drm svtav1 srt rist nvdec"
+build_options_default="x265 v4l2 vpx aom sndio pulseaudio dav1d webp vulkan drm srt rist"
+
+desc_option_srt="Enable support for SRT (Secure, Reliable, Transport)"
+desc_option_rist="Enable support for RIST (Reliable Internet Stream Transport)"
+desc_option_sofa="Enable support for AES SOFA"
+desc_option_webp="Enable support for WebP"
+
+case "$XBPS_TARGET_MACHINE" in
+	i686*|x86_64*)
+			hostmakedepends+=" nasm"
+			build_options_default+=" vaapi vdpau nvenc nvdec"
+			;;
+	ppc64*) build_options_default+=" vaapi vdpau";;
+	mips*) CFLAGS="-mnan=legacy";;
+esac
+
+if [ "$XBPS_TARGET_WORDSIZE" != "32" ]; then
+	build_options_default+=" svtav1"
+fi
+
+if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+	makedepends+=" libatomic-devel"
+fi
+
+_apply_patch() {
+	local args="$1" pname="$(basename $2)"
+
+	if [ ! -f ".${pname}_done" ]; then
+		patch -N $args -i $2
+		touch .${pname}_done
+	fi
+}
+
+post_patch() {
+	case "$XBPS_TARGET_MACHINE" in
+		ppc64le*) ;;
+		ppc*) _apply_patch -p1 ${FILESDIR}/altivec.patch ;;
+	esac
+
+	vsed -i libavfilter/vf_libvmaf.c -e 's!/usr/local/share/model/\(vmaf_v0.6.1\).pkl!/usr/share/vmaf/\1.json!'
+}
+
+do_configure() {
+	# Fix gcc on x86_64-musl only
+	if [ "$XBPS_TARGET_MACHINE" = "x86_64-musl" ]; then
+		vsed -i configure -e "s;_cflags_speed='-O3';_cflags_speed='-O2';"
+	fi
+
+	if [ "$CROSS_BUILD" ]; then
+		case "$XBPS_TARGET_MACHINE" in
+			arm*) _arch="arm";;
+			aarch64*) _arch="aarch64";;
+			mips*) _arch="mips";;
+			ppc64*) _arch="ppc64";;
+			ppc*) _arch="ppc";;
+			*) _arch="${XBPS_TARGET_MACHINE%%-musl}";;
+		esac
+
+		_args+=" --enable-cross-compile
+			--sysroot=$XBPS_CROSS_BASE
+			--cross-prefix=${XBPS_CROSS_TRIPLET}-
+			--target-os=linux --arch=${_arch}"
+	fi
+
+	case "$XBPS_TARGET_MACHINE" in
+		ppc|ppc-musl) _args+=" --disable-altivec";;
+	esac
+
+	if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
+		_args+=" --extra-libs=-latomic"
+	fi
+
+	./configure --prefix=/usr --disable-debug --enable-gpl --enable-gnutls \
+		--disable-stripping \
+		--enable-libcdio --enable-version3 --enable-runtime-cpudetect \
+		--enable-libmp3lame --enable-libvorbis --enable-libxvid \
+		--enable-libx264 $(vopt_enable vpx libvpx) --enable-libtheora \
+		--enable-shared --enable-static --enable-libxcb \
+		$(vopt_enable pulseaudio libpulse) --enable-libfreetype --enable-libmodplug \
+		--enable-libspeex --enable-libcelt --enable-libass \
+		--enable-libopus --enable-librtmp --enable-libjack \
+		$(vopt_if fdk_aac '--enable-nonfree --enable-libfdk-aac') \
+		--disable-libopencore_amrnb --disable-libopencore_amrwb \
+		--disable-libopenjpeg \
+		--enable-postproc --enable-opencl ${_args} --enable-libvmaf ${_args} \
+		$(vopt_enable x265 libx265) \
+		$(vopt_enable v4l2 libv4l2) \
+		$(vopt_enable aom libaom) $(vopt_enable vaapi) $(vopt_enable vdpau) \
+		--enable-libbs2b --enable-avresample --enable-libvidstab \
+		$(vopt_enable dav1d libdav1d) \
+		$(vopt_enable zimg libzimg) \
+		$(vopt_enable webp libwebp) \
+		$(vopt_enable sofa libmysofa) \
+		$(vopt_enable vulkan) \
+		$(vopt_enable drm libdrm) \
+		$(vopt_enable svtav1 libsvtav1) \
+		$(vopt_enable srt libsrt) \
+		$(vopt_enable rist librist) \
+		$(vopt_if nvenc '--enable-nvenc') \
+		$(vopt_if nvdec '--enable-nvdec')
+}
+
+do_build() {
+	make ${makejobs}
+	make doc/ff{mpeg,play}.1
+}
+
+do_install() {
+	make DESTDIR=${DESTDIR} install install-man
+	rm -rf ${DESTDIR}/usr/bin
+}
+
+libavcodec4_package() {
+	short_desc="FFmpeg codec library"
+	pkg_install() {
+		vmove "usr/lib/libavcodec.so.*"
+	}
+}
+
+libavdevice4_package() {
+	short_desc="FFmpeg device handling library"
+	pkg_install() {
+		vmove "usr/lib/libavdevice.so.*"
+	}
+}
+
+libavresample4_package() {
+	short_desc="FFmpeg audio resampling library"
+	pkg_install() {
+		vmove "usr/lib/libavresample.so.*"
+	}
+}
+
+libavformat4_package() {
+	short_desc="FFmpeg file format library"
+	pkg_install() {
+		vmove "usr/lib/libavformat.so.*"
+	}
+}
+
+libavutil4_package() {
+	short_desc="FFmpeg utility library"
+	pkg_install() {
+		vmove "usr/lib/libavutil.so.*"
+	}
+}
+
+libavfilter4_package() {
+	short_desc="FFmpeg audio/video filter library"
+	pkg_install() {
+		vmove "usr/lib/libavfilter.so.*"
+	}
+}
+
+libpostproc4_package() {
+	short_desc="FFmpeg video postprocessing library"
+	pkg_install() {
+		vmove "usr/lib/libpostproc.so.*"
+	}
+}
+
+libswscale4_package() {
+	short_desc="FFmpeg video scaling library"
+	pkg_install() {
+		vmove "usr/lib/libswscale.so.*"
+	}
+}
+
+libswresample4_package() {
+	short_desc="FFmpeg video resampling library"
+	pkg_install() {
+		vmove "usr/lib/libswresample.so.*"
+	}
+}
+
+ffmpeg4-devel_package() {
+	depends="
+		libavcodec4>=${version}_${revision}
+		libavdevice4>=${version}_${revision}
+		libavformat4>=${version}_${revision}
+		libavutil4>=${version}_${revision}
+		libavfilter4>=${version}_${revision}
+		libpostproc4>=${version}_${revision}
+		libswscale4>=${version}_${revision}
+		libswresample4>=${version}_${revision}
+		libavresample4>=${version}_${revision}"
+	short_desc+=" - development files"
+	conflicts="ffmpeg-devel"
+	if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
+		# /usr/bin/strip: error: the input file '/destdir//ffmpeg-devel-4.4.4/usr/lib/libavfilter.a(vf_atadenoise.o)' has no sections
+		nostrip_files="/usr/lib/libavfilter.a"
+	fi
+	pkg_install() {
+		vmove usr/include
+		vmove usr/lib/pkgconfig
+		vmove "usr/lib/*.a"
+		vmove "usr/lib/*.so"
+		vmove usr/share/ffmpeg/examples
+		vmove usr/share/man/man3
+	}
+}
diff --git a/srcpkgs/libavcodec4 b/srcpkgs/libavcodec4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavcodec4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavdevice4 b/srcpkgs/libavdevice4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavdevice4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavfilter4 b/srcpkgs/libavfilter4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavfilter4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavformat4 b/srcpkgs/libavformat4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavformat4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavresample4 b/srcpkgs/libavresample4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libavutil4 b/srcpkgs/libavutil4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libavutil4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libpostproc4 b/srcpkgs/libpostproc4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libpostproc4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswresample4 b/srcpkgs/libswresample4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libswresample4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file
diff --git a/srcpkgs/libswscale4 b/srcpkgs/libswscale4
new file mode 120000
index 00000000000000..887f354e7c6be3
--- /dev/null
+++ b/srcpkgs/libswscale4
@@ -0,0 +1 @@
+ffmpeg4
\ No newline at end of file

From 0c90b651e23c4cf374562d7fb6e58f459a2d3ce1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:04 -0400
Subject: [PATCH 005/108] opencv: update to 4.7.0.

---
 common/shlibs           | 104 ++++++++++++++++++++--------------------
 srcpkgs/opencv/template |   8 ++--
 2 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index bbd268f650d066..41ad4d5efb536c 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -2078,58 +2078,58 @@ libcapstone.so.5 capstone-5.0.1_1
 libhavege.so.2 libhaveged-1.9.11_1
 libnih.so.1 libnih-1.0.3_1
 libnih-dbus.so.1 libnih-1.0.3_1
-libopencv_quality.so.406 libopencv-4.6.0_1
-libopencv_reg.so.406 libopencv-4.6.0_1
-libopencv_surface_matching.so.406 libopencv-4.6.0_1
-libopencv_xphoto.so.406 libopencv-4.6.0_1
-libopencv_freetype.so.406 libopencv-4.6.0_1
-libopencv_fuzzy.so.406 libopencv-4.6.0_1
-libopencv_hfs.so.406 libopencv-4.6.0_1
-libopencv_img_hash.so.406 libopencv-4.6.0_1
-libopencv_line_descriptor.so.406 libopencv-4.6.0_1
-libopencv_saliency.so.406 libopencv-4.6.0_1
-libopencv_structured_light.so.406 libopencv-4.6.0_1
-libopencv_aruco.so.406 libopencv-4.6.0_1
-libopencv_bgsegm.so.406 libopencv-4.6.0_1
-libopencv_bioinspired.so.406 libopencv-4.6.0_1
-libopencv_ccalib.so.406 libopencv-4.6.0_1
-libopencv_face.so.406 libopencv-4.6.0_1
-libopencv_tracking.so.406 libopencv-4.6.0_1
-libopencv_xfeatures2d.so.406 libopencv-4.6.0_1
-libopencv_optflow.so.406 libopencv-4.6.0_1
-libopencv_ximgproc.so.406 libopencv-4.6.0_1
-libopencv_plot.so.406 libopencv-4.6.0_1
-libopencv_text.so.406 libopencv-4.6.0_1
-libopencv_ml.so.406 libopencv-4.6.0_1
-libopencv_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn.so.406 libopencv-4.6.0_1
-libopencv_shape.so.406 libopencv-4.6.0_1
-libopencv_stitching.so.406 libopencv-4.6.0_1
-libopencv_photo.so.406 libopencv-4.6.0_1
-libopencv_video.so.406 libopencv-4.6.0_1
-libopencv_calib3d.so.406 libopencv-4.6.0_1
-libopencv_features2d.so.406 libopencv-4.6.0_1
-libopencv_flann.so.406 libopencv-4.6.0_1
-libopencv_highgui.so.406 libopencv-4.6.0_1
-libopencv_videoio.so.406 libopencv-4.6.0_1
-libopencv_imgcodecs.so.406 libopencv-4.6.0_1
-libopencv_imgproc.so.406 libopencv-4.6.0_1
-libopencv_core.so.406 libopencv-4.6.0_1
-libopencv_superres.so.406 libopencv-4.6.0_1
-libopencv_videostab.so.406 libopencv-4.6.0_1
-libopencv_gapi.so.406 libopencv-4.6.0_1
-libopencv_xobjdetect.so.406 libopencv-4.6.0_1
-libopencv_datasets.so.406 libopencv-4.6.0_1
-libopencv_dnn_objdetect.so.406 libopencv-4.6.0_1
-libopencv_dnn_superres.so.406 libopencv-4.6.0_1
-libopencv_dpm.so.406 libopencv-4.6.0_1
-libopencv_phase_unwrapping.so.406 libopencv-4.6.0_1
-libopencv_stereo.so.406 libopencv-4.6.0_1
-libopencv_rapid.so.406 libopencv-4.6.0_1
-libopencv_intensity_transform.so.406 libopencv-4.6.0_1
-libopencv_alphamat.so.406 libopencv-4.6.0_1
-libopencv_barcode.so.406 libopencv-4.6.0_1
-libopencv_mcc.so.406 libopencv-4.6.0_1
+libopencv_quality.so.407 libopencv-4.7.0_1
+libopencv_reg.so.407 libopencv-4.7.0_1
+libopencv_surface_matching.so.407 libopencv-4.7.0_1
+libopencv_xphoto.so.407 libopencv-4.7.0_1
+libopencv_freetype.so.407 libopencv-4.7.0_1
+libopencv_fuzzy.so.407 libopencv-4.7.0_1
+libopencv_hfs.so.407 libopencv-4.7.0_1
+libopencv_img_hash.so.407 libopencv-4.7.0_1
+libopencv_line_descriptor.so.407 libopencv-4.7.0_1
+libopencv_saliency.so.407 libopencv-4.7.0_1
+libopencv_structured_light.so.407 libopencv-4.7.0_1
+libopencv_aruco.so.407 libopencv-4.7.0_1
+libopencv_bgsegm.so.407 libopencv-4.7.0_1
+libopencv_bioinspired.so.407 libopencv-4.7.0_1
+libopencv_ccalib.so.407 libopencv-4.7.0_1
+libopencv_face.so.407 libopencv-4.7.0_1
+libopencv_tracking.so.407 libopencv-4.7.0_1
+libopencv_xfeatures2d.so.407 libopencv-4.7.0_1
+libopencv_optflow.so.407 libopencv-4.7.0_1
+libopencv_ximgproc.so.407 libopencv-4.7.0_1
+libopencv_plot.so.407 libopencv-4.7.0_1
+libopencv_text.so.407 libopencv-4.7.0_1
+libopencv_ml.so.407 libopencv-4.7.0_1
+libopencv_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn.so.407 libopencv-4.7.0_1
+libopencv_shape.so.407 libopencv-4.7.0_1
+libopencv_stitching.so.407 libopencv-4.7.0_1
+libopencv_photo.so.407 libopencv-4.7.0_1
+libopencv_video.so.407 libopencv-4.7.0_1
+libopencv_calib3d.so.407 libopencv-4.7.0_1
+libopencv_features2d.so.407 libopencv-4.7.0_1
+libopencv_flann.so.407 libopencv-4.7.0_1
+libopencv_highgui.so.407 libopencv-4.7.0_1
+libopencv_videoio.so.407 libopencv-4.7.0_1
+libopencv_imgcodecs.so.407 libopencv-4.7.0_1
+libopencv_imgproc.so.407 libopencv-4.7.0_1
+libopencv_core.so.407 libopencv-4.7.0_1
+libopencv_superres.so.407 libopencv-4.7.0_1
+libopencv_videostab.so.407 libopencv-4.7.0_1
+libopencv_gapi.so.407 libopencv-4.7.0_1
+libopencv_xobjdetect.so.407 libopencv-4.7.0_1
+libopencv_datasets.so.407 libopencv-4.7.0_1
+libopencv_dnn_objdetect.so.407 libopencv-4.7.0_1
+libopencv_dnn_superres.so.407 libopencv-4.7.0_1
+libopencv_dpm.so.407 libopencv-4.7.0_1
+libopencv_phase_unwrapping.so.407 libopencv-4.7.0_1
+libopencv_stereo.so.407 libopencv-4.7.0_1
+libopencv_rapid.so.407 libopencv-4.7.0_1
+libopencv_intensity_transform.so.407 libopencv-4.7.0_1
+libopencv_alphamat.so.407 libopencv-4.7.0_1
+libopencv_barcode.so.407 libopencv-4.7.0_1
+libopencv_mcc.so.407 libopencv-4.7.0_1
 libuniconf.so.4.6 wvstreams-4.6.1_20
 libwvbase.so.4.6 wvstreams-4.6.1_20
 libwvutils.so.4.6 wvstreams-4.6.1_20
diff --git a/srcpkgs/opencv/template b/srcpkgs/opencv/template
index aea4bfc3a265cf..ce94de9424d18d 100644
--- a/srcpkgs/opencv/template
+++ b/srcpkgs/opencv/template
@@ -1,7 +1,7 @@
 # Template file for 'opencv'
 pkgname=opencv
-version=4.6.0
-revision=6
+version=4.7.0
+revision=1
 create_wrksrc=yes
 build_wrksrc=${pkgname}-${version}
 build_style=cmake
@@ -24,8 +24,8 @@ homepage="https://opencv.org"
 changelog="https://github.com/opencv/opencv/wiki/ChangeLog"
 distfiles="https://github.com/opencv/opencv/archive/${version}.tar.gz
  https://github.com/opencv/opencv_contrib/archive/${version}.tar.gz>contrib.tar.gz"
-checksum="1ec1cba65f9f20fe5a41fda1586e01c70ea0c9a6d7b67c9e13edf0cfe2239277
- 1777d5fd2b59029cf537e5fd6f8aa68d707075822f90bde683fcde086f85f7a7"
+checksum="8df0079cdbe179748a18d44731af62a245a45ebf5085223dc03133954c662973
+ 42df840cf9055e59d0e22c249cfb19f04743e1bdad113d31b1573d3934d62584"
 patch_args="-Np1 -d ${build_wrksrc}"
 # tests hang indenfinitely, even with test data included
 make_check=no

From 2f7e609803d0a84f3654089a7b2e825845daf57a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:45 -0400
Subject: [PATCH 006/108] actiona: revbump for opencv-4.7.0

---
 srcpkgs/actiona/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/actiona/template b/srcpkgs/actiona/template
index cf5f0b7a2ae610..0d899311e6df75 100644
--- a/srcpkgs/actiona/template
+++ b/srcpkgs/actiona/template
@@ -1,7 +1,7 @@
 # Template file for 'actiona'
 pkgname=actiona
 version=3.10.1
-revision=2
+revision=3
 build_style=qmake
 configure_args="PKGCONFIG_OPENCV=opencv4"
 hostmakedepends="pkg-config qt5-plugin-mysql qt5-qmake qt5-host-tools"

From 48b8c33da56f6328a9a309fdf93218490f08fd05 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 007/108] retroshare: revbump for opencv-4.7.0

---
 srcpkgs/retroshare/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroshare/template b/srcpkgs/retroshare/template
index 35a2732c77f634..31a40a6ac6d4a7 100644
--- a/srcpkgs/retroshare/template
+++ b/srcpkgs/retroshare/template
@@ -1,7 +1,7 @@
 # Template file for 'retroshare'
 pkgname=retroshare
 version=0.6.6
-revision=4
+revision=5
 build_style=qmake
 #XXX broadcast feature requires an ancient udp-discovery-cpp which either needs
 # to be fetched+patched (FTBFS) here or packaged :/

From ac4e78d0177a5c2470509240277990d8fe6d3383 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 19:59:46 -0400
Subject: [PATCH 008/108] waifu2x-converter-cpp: revbump for opencv-4.7.0

---
 srcpkgs/waifu2x-converter-cpp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waifu2x-converter-cpp/template b/srcpkgs/waifu2x-converter-cpp/template
index 361b8a23b94977..c5ac17eb54ea4c 100644
--- a/srcpkgs/waifu2x-converter-cpp/template
+++ b/srcpkgs/waifu2x-converter-cpp/template
@@ -1,7 +1,7 @@
 # Template file for 'waifu2x-converter-cpp'
 pkgname=waifu2x-converter-cpp
 version=5.2.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DINSTALL_MODELS=ON"
 hostmakedepends="pkg-config"

From 0432d7cc7e086e85006aa054afd1f2a96c39f4a8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:38 -0400
Subject: [PATCH 009/108] vlc: revbump for ffmpeg4

---
 srcpkgs/vlc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/vlc/template b/srcpkgs/vlc/template
index 559b1c4fff339f..fc399f1a6e9bfc 100644
--- a/srcpkgs/vlc/template
+++ b/srcpkgs/vlc/template
@@ -1,7 +1,7 @@
 # Template file for 'vlc'
 pkgname=vlc
 version=3.0.20
-revision=4
+revision=5
 build_style=gnu-configure
 configure_args="--disable-gme --disable-libtar --enable-jack
  --enable-live555 --disable-fluidsynth --enable-dvdread
@@ -25,7 +25,7 @@ lib32disabled=yes
 hostmakedepends="automake libtool pkg-config flex gettext libgcrypt-devel
  live555-devel gettext-devel $(vopt_if lua lua52) $(vopt_if chromecast protobuf)"
 makedepends="
- avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg-devel freefont-ttf
+ avahi-libs-devel dbus-glib-devel faad2-devel ffmpeg4-devel freefont-ttf
  gnutls-devel jack-devel liba52-devel libass-devel libbluray-devel
  libcdio-devel libdca-devel libdvbpsi-devel libdvdnav-devel libmad-devel
  libmatroska-devel libmodplug-devel libmpcdec-devel libmpeg2-devel

From f163396624018966a7ddaa80af6a31c8742e2550 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:00:55 -0400
Subject: [PATCH 010/108] osg: revbump for ffmpeg4

---
 srcpkgs/osg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/osg/template b/srcpkgs/osg/template
index 8ef0efc599a1b1..a131ceaf7a867b 100644
--- a/srcpkgs/osg/template
+++ b/srcpkgs/osg/template
@@ -8,7 +8,7 @@ build_helper="qemu"
 configure_args="-DLIB_POSTFIX="
 hostmakedepends="pkg-config xrandr"
 makedepends="MesaLib-devel gtkglext-devel libcurl-devel giflib-devel librsvg-devel
- jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg-devel xine-lib-devel
+ jasper-devel tiff-devel libgdal-devel libgta-devel ffmpeg4-devel xine-lib-devel
  SDL2-devel gst-plugins-base1-devel
  $(vopt_if openexr libopenexr-devel)
  $(vopt_if poppler poppler-glib-devel)

From afe1a4dfd7eafd036bad186a43f5871705ee4811 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:13 -0400
Subject: [PATCH 011/108] xine-lib: revbump for ffmpeg4

---
 srcpkgs/xine-lib/template | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/xine-lib/template b/srcpkgs/xine-lib/template
index 3be4d08eac77a3..ed6194c17d11e8 100644
--- a/srcpkgs/xine-lib/template
+++ b/srcpkgs/xine-lib/template
@@ -1,14 +1,14 @@
 # Template file for 'xine-lib'
 pkgname=xine-lib
-version=1.2.12
-revision=3
+version=1.2.13
+revision=1
 build_style=gnu-configure
 configure_args="--disable-vcd --disable-gnomevfs --without-esound --disable-dxr3
  --disable-oss"
 hostmakedepends="automake gettext-devel libtool pkg-config perl"
 makedepends="
  zlib-devel alsa-lib-devel libxcb-devel libSM-devel libXext-devel libXv-devel
- libXvMC-devel liba52-devel libmad-devel ffmpeg-devel pulseaudio-devel
+ libXvMC-devel liba52-devel libmad-devel ffmpeg4-devel pulseaudio-devel
  jack-devel samba-devel libflac-devel libmodplug-devel libmpcdec-devel
  speex-devel libtheora-devel libvorbis-devel libdca-devel faad2-devel
  libcdio-devel libbluray-devel aalib-devel libcaca-devel libXinerama-devel
@@ -19,7 +19,7 @@ license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="http://www.xine-project.org"
 changelog="https://sourceforge.net/projects/xine/files/xine-lib/${version}/README.txt/view"
 distfiles="${SOURCEFORGE_SITE}/xine/${pkgname}-${version}.tar.xz"
-checksum=d606270468e1540c2a89c0d7f5fdf11e17ecc0c2698cc0bcb1065ff26abee098
+checksum=5f10d6d718a4a51c17ed1b32b031d4f9b80b061e8276535b2be31e5ac4b75e6f
 
 case "$XBPS_TARGET_MACHINE" in
 	i686-musl)

From b97f8a928946b5d9357c50707050fbfb1586a434 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 012/108] attract: revbump for ffmpeg6

---
 srcpkgs/attract/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/attract/template b/srcpkgs/attract/template
index e769fb15456217..776cbe4ebd2c93 100644
--- a/srcpkgs/attract/template
+++ b/srcpkgs/attract/template
@@ -1,7 +1,7 @@
 # Template file for 'attract'
 pkgname=attract
 version=2.7.0
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="VERBOSE=1"
 make_use_env=yes

From 2474571a34f5fbad02b82dc03abb9eb6d83eaf51 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 013/108] aubio: revbump for ffmpeg6

---
 srcpkgs/aubio/patches/ffmpeg5.patch | 25 +++++++++++++++++++++++++
 srcpkgs/aubio/template              |  2 +-
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/aubio/patches/ffmpeg5.patch

diff --git a/srcpkgs/aubio/patches/ffmpeg5.patch b/srcpkgs/aubio/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..aace41a6e6d9a4
--- /dev/null
+++ b/srcpkgs/aubio/patches/ffmpeg5.patch
@@ -0,0 +1,25 @@
+From 8a05420e5dd8c7b8b2447f82dc919765876511b3 Mon Sep 17 00:00:00 2001
+From: Paul Brossier <piem@piem.org>
+Date: Tue, 25 Jan 2022 18:30:27 +0100
+Subject: [PATCH] [source_avcodec] define FF_API_LAVF_AVCTX for libavcodec >
+ 59, thx @berolinux (closes gh-353)
+
+---
+ src/io/source_avcodec.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/io/source_avcodec.c b/src/io/source_avcodec.c
+index e0ae93b5..1421bd9a 100644
+--- a/src/io/source_avcodec.c
++++ b/src/io/source_avcodec.c
+@@ -68,6 +68,10 @@
+ #define AUBIO_AVCODEC_MAX_BUFFER_SIZE AV_INPUT_BUFFER_MIN_SIZE
+ #endif
+ 
++#if LIBAVCODEC_VERSION_MAJOR >= 59
++#define FF_API_LAVF_AVCTX 1
++#endif
++
+ struct _aubio_source_avcodec_t {
+   uint_t hop_size;
+   uint_t samplerate;
diff --git a/srcpkgs/aubio/template b/srcpkgs/aubio/template
index ad1c4b25699178..7d875cc02541a7 100644
--- a/srcpkgs/aubio/template
+++ b/srcpkgs/aubio/template
@@ -1,7 +1,7 @@
 # Template file for 'aubio'
 pkgname=aubio
 version=0.4.9
-revision=1
+revision=2
 build_style=waf3
 # XXX lash, pure and swig support.
 hostmakedepends="pkg-config txt2man"

From a6eb0a54c5b4c78e06887f7be249a8155fee99dc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 014/108] audacious-plugins: revbump for ffmpeg6

---
 .../audacious-plugins/patches/ffmpeg5.patch   | 43 +++++++++++++++++++
 srcpkgs/audacious-plugins/template            |  2 +-
 2 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/audacious-plugins/patches/ffmpeg5.patch

diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg5.patch b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..4e5e34099d71c4
--- /dev/null
+++ b/srcpkgs/audacious-plugins/patches/ffmpeg5.patch
@@ -0,0 +1,43 @@
+commit 298aa371c56c2f52c25a33d9bdec4918b11cebdc
+Author: tibequadorian <tibequadorian@posteo.de>
+Date:   Sat Mar 19 18:40:12 2022 +0100
+
+    audacious-plugins: rebuild against ffmpeg-5.0
+
+diff --git a/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+new file mode 100644
+index 0000000000..617c11215b
+--- /dev/null
++++ b/srcpkgs/audacious-plugins/patches/ffmpeg-5.0.patch
+@@ -0,0 +1,31 @@
++From f60beb400eeb1e4778bbfd738bc4a4ccef3de539 Mon Sep 17 00:00:00 2001
++From: John Lindgren <john@jlindgren.net>
++Date: Sat, 5 Mar 2022 12:05:34 -0500
++Subject: [PATCH] Fix build with FFmpeg 5.0
++
++---
++ src/ffaudio/ffaudio-core.cc | 4 ++--
++ 1 file changed, 2 insertions(+), 2 deletions(-)
++
++diff --git a/src/ffaudio/ffaudio-core.cc b/src/ffaudio/ffaudio-core.cc
++index 16dc63e3a..a2b95fd6c 100644
++--- a/src/ffaudio/ffaudio-core.cc
+++++ b/src/ffaudio/ffaudio-core.cc
++@@ -274,7 +274,7 @@ static AVInputFormat * get_format_by_content (const char * name, VFSFile & file)
++         AVProbeData d = {name, buf, filled};
++         score = target;
++ 
++-        f = av_probe_input_format2 (& d, true, & score);
+++        f = (AVInputFormat *) av_probe_input_format2 (& d, true, & score);
++         if (f)
++             break;
++ 
++@@ -347,7 +347,7 @@ static bool find_codec (AVFormatContext * c, CodecInfo * cinfo)
++ #endif
++         if (stream && stream->codecpar && stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
++         {
++-            AVCodec * codec = avcodec_find_decoder (stream->codecpar->codec_id);
+++            AVCodec * codec = (AVCodec *) avcodec_find_decoder (stream->codecpar->codec_id);
++ 
++             if (codec)
++             {
diff --git a/srcpkgs/audacious-plugins/template b/srcpkgs/audacious-plugins/template
index 05e53a9adf78ff..4b1968e03de781 100644
--- a/srcpkgs/audacious-plugins/template
+++ b/srcpkgs/audacious-plugins/template
@@ -2,7 +2,7 @@
 #Keep in sync with audacious!
 pkgname=audacious-plugins
 version=4.3.1
-revision=3
+revision=4
 build_style=meson
 configure_args="$(vopt_bool gtk3 gtk) $(vopt_bool gtk3)
  $(vopt_bool qt) $(vopt_bool qt qt6)"

From 4dd8b8148f0a2c898febef5b427b745301888a00 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 015/108] audacity: revbump for ffmpeg6

---
 srcpkgs/audacity/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/audacity/template b/srcpkgs/audacity/template
index 7b838119ab2611..84b49305edcef1 100644
--- a/srcpkgs/audacity/template
+++ b/srcpkgs/audacity/template
@@ -1,7 +1,7 @@
 # Template file for 'audacity'
 pkgname=audacity
 version=3.4.2
-revision=1
+revision=2
 build_style=cmake
 build_helper="cmake-wxWidgets-gtk3 qemu"
 configure_args="-Daudacity_use_ffmpeg=loaded -Daudacity_lib_preference=system

From 72ecfd7c8ba0f2363a9461534d8deeed6152f645 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:45 -0400
Subject: [PATCH 016/108] avidemux: revbump for ffmpeg6

---
 srcpkgs/avidemux/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/avidemux/template b/srcpkgs/avidemux/template
index 253a0243e22599..557285982d2b8f 100644
--- a/srcpkgs/avidemux/template
+++ b/srcpkgs/avidemux/template
@@ -1,7 +1,7 @@
 # Template file for 'avidemux'
 pkgname=avidemux
 version=2.8.0
-revision=2
+revision=3
 # Can't be compiled for aarch64, arm* or mips*
 archs="x86_64* i686*"
 hostmakedepends="cmake pkg-config qt5-host-tools qt5-devel tar yasm"

From 586359418655f8fda4baced4d4bb1bccfca5f34e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 017/108] blender: revbump for ffmpeg6

---
 srcpkgs/blender/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index 68787b76a26c18..e2e090e6dfa41c 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -1,7 +1,7 @@
 # Template file for 'blender'
 pkgname=blender
 version=4.0.2
-revision=2
+revision=3
 archs="x86_64* ppc64*"
 build_style="cmake"
 pycompile_dirs="usr/share/blender/${version%.*}/scripts"

From e431a052d5629de27c0918ccc4401d609a90f3c4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 018/108] cantata: revbump for ffmpeg6

---
 srcpkgs/cantata/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cantata/template b/srcpkgs/cantata/template
index 4b417d80d5c2da..8a90aaa4c07a2a 100644
--- a/srcpkgs/cantata/template
+++ b/srcpkgs/cantata/template
@@ -1,7 +1,7 @@
 # Template file for 'cantata'
 pkgname=cantata
 version=2.5.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools qt5-tools"
 makedepends="qt5-devel qt5-tools-devel qt5-svg-devel qt5-xmlpatterns-devel

From b9332bf9d7a99c7ff6e471d899949a5eca31eb3c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 019/108] ccextractor: revbump for ffmpeg6

---
 ...5-and-tesseract-5-compatibility-1479.patch | 168 ++++++++++++++++++
 srcpkgs/ccextractor/template                  |   2 +-
 2 files changed, 169 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ccextractor/patches/0001-fix-ffmpeg-5-and-tesseract-5-compatibility-1479.patch

diff --git a/srcpkgs/ccextractor/patches/0001-fix-ffmpeg-5-and-tesseract-5-compatibility-1479.patch b/srcpkgs/ccextractor/patches/0001-fix-ffmpeg-5-and-tesseract-5-compatibility-1479.patch
new file mode 100644
index 00000000000000..bcab4890554b9a
--- /dev/null
+++ b/srcpkgs/ccextractor/patches/0001-fix-ffmpeg-5-and-tesseract-5-compatibility-1479.patch
@@ -0,0 +1,168 @@
+From b1cbfcea9b9c687143bf0d80bc179b563e99d025 Mon Sep 17 00:00:00 2001
+From: Prateek Sunal <prtksunal@gmail.com>
+Date: Thu, 9 Mar 2023 01:44:53 +0530
+Subject: [PATCH] fix: ffmpeg 5 and tesseract 5 compatibility (#1479)
+
+* fix: replace deprecated `codec` property with `codecpar`
+
+* fix: replace deprecated method `avcodec_decode_video2` with `avcodec_receive_frame` and `avcodec_send_packet`
+
+* Update CHANGES.TXT
+
+* fix: remove deprecated `av_register_all` function
+
+* fix: formatting
+
+* fix: add support for tesseract 5
+
+* fix: tesseract v5
+
+* fix: hardsubx codec context error
+
+* fix: lint const warning
+---
+ docs/CHANGES.TXT               |  1 +
+ src/lib_ccx/ffmpeg_intgr.c     |  7 +++---
+ src/lib_ccx/hardsubx.c         | 25 ++++++++++++------
+ src/lib_ccx/hardsubx_decoder.c | 27 ++++++++------------
+ src/lib_ccx/ocr.c              | 46 ++++++++++++----------------------
+ 5 files changed, 47 insertions(+), 59 deletions(-)
+
+diff --git a/src/lib_ccx/ffmpeg_intgr.c b/src/lib_ccx/ffmpeg_intgr.c
+index be988890..e6f21e20 100644
+--- a/src/lib_ccx/ffmpeg_intgr.c
++++ b/src/lib_ccx/ffmpeg_intgr.c
+@@ -66,7 +66,6 @@ void *init_ffmpeg(const char *path)
+ 	struct ffmpeg_ctx *ctx;
+ 	AVCodec *dec = NULL;
+ 	avcodec_register_all();
+-	av_register_all();
+ 
+ 	if (ccx_options.debug_mask & CCX_DMT_VERBOSE)
+ 		av_log_set_level(AV_LOG_INFO);
+@@ -133,7 +132,6 @@ int ff_get_ccframe(void *arg, unsigned char *data, int maxlen)
+ 	struct ffmpeg_ctx *ctx = arg;
+ 	int len = 0;
+ 	int ret = 0;
+-	int got_frame;
+ 	AVPacket packet;
+ 
+ 	ret = av_read_frame(ctx->ifmt, &packet);
+@@ -151,12 +149,13 @@ int ff_get_ccframe(void *arg, unsigned char *data, int maxlen)
+ 		return AVERROR(EAGAIN);
+ 	}
+ 
+-	ret = avcodec_decode_video2(ctx->dec_ctx, ctx->frame, &got_frame, &packet);
++	avcodec_send_packet(ctx->codec_ctx, &ctx->packet);
++	ret = avcodec_receive_frame(ctx->dec_ctx, ctx->frame);
+ 	if (ret < 0)
+ 	{
+ 		av_log(NULL, AV_LOG_ERROR, "unable to decode packet\n");
+ 	}
+-	else if (!got_frame)
++	else if (ret != 0)
+ 	{
+ 		return AVERROR(EAGAIN);
+ 	}
+diff --git a/src/lib_ccx/hardsubx.c b/src/lib_ccx/hardsubx.c
+index 411377f9..fb844c91 100644
+--- a/src/lib_ccx/hardsubx.c
++++ b/src/lib_ccx/hardsubx.c
+@@ -12,9 +12,6 @@
+
+ int hardsubx_process_data(struct lib_hardsubx_ctx *ctx)
+ {
+-	// Get the required media attributes and initialize structures
+-	av_register_all();
+-
+ 	if (avformat_open_input(&ctx->format_ctx, ctx->inputfile[0], NULL, NULL) != 0)
+ 	{
+ 		fatal(EXIT_READ_ERROR, "Error reading input file!\n");
+@@ -32,7 +29,7 @@
+ 	ctx->video_stream_id = -1;
+ 	for (int i = 0; i < ctx->format_ctx->nb_streams; i++)
+ 	{
+-		if (ctx->format_ctx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO)
++		if (ctx->format_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
+ 		{
+ 			ctx->video_stream_id = i;
+ 			break;
+@@ -43,8 +40,21 @@
+ 		fatal(EXIT_READ_ERROR, "Video Stream not found!\n");
+ 	}
+
+-	ctx->codec_ctx = ctx->format_ctx->streams[ctx->video_stream_id]->codec;
+-	ctx->codec = avcodec_find_decoder(ctx->codec_ctx->codec_id);
++	ctx->codec_ctx = avcodec_alloc_context3(NULL);
++	if (!ctx->codec_ctx)
++	{
++		    fatal(EXIT_NOT_ENOUGH_MEMORY, "Could not allocate codec context!\n");
++	}
++
++	// Assign codec parameters to codec context
++	if (avcodec_parameters_to_context(ctx->codec_ctx, ctx->format_ctx->streams[ctx->video_stream_id]->codecpar) < 0)
++	{
++		    fatal(EXIT_READ_ERROR, "Could not initialize codec context!\n");
++	}
++
++	// Find decoder for the codec context
++	ctx->codec = (AVCodec *)avcodec_find_decoder(ctx->codec_ctx->codec_id);
++
+ 	if (ctx->codec == NULL)
+ 	{
+ 		fatal(EXIT_READ_ERROR, "Input codec is not supported!\n");
+diff --git a/src/lib_ccx/hardsubx_decoder.c b/src/lib_ccx/hardsubx_decoder.c
+index bd9b0980..b5dfaec4 100644
+--- a/src/lib_ccx/hardsubx_decoder.c
++++ b/src/lib_ccx/hardsubx_decoder.c
+@@ -371,7 +371,6 @@
+ int hardsubx_process_frames_tickertext(struct lib_hardsubx_ctx *ctx, struct encoder_ctx *enc_ctx)
+ {
+ 	// Search for ticker text at the bottom of the screen, such as in Russia TV1 or stock prices
+-	int got_frame;
+ 	int cur_sec = 0, total_sec, progress;
+ 	int frame_number = 0;
+ 	char *ticker_text = NULL;
+@@ -382,8 +381,8 @@
+ 		{
+ 			frame_number++;
+ 			//Decode the video stream packet
+-			avcodec_decode_video2(ctx->codec_ctx, ctx->frame, &got_frame, &ctx->packet);
+-			if (got_frame && frame_number % 1000 == 0)
++      avcodec_send_packet(ctx->codec_ctx, &ctx->packet);
++      if (avcodec_receive_frame(ctx->codec_ctx, ctx->frame) == 0 && frame_number % 1000 == 0)
+ 			{
+ 				// sws_scale is used to convert the pixel format to RGB24 from all other cases
+ 				sws_scale(
+@@ -434,9 +433,8 @@
+ 			frame_number++;
+
+ 			//Decode the video stream packet
+-			avcodec_decode_video2(ctx->codec_ctx, ctx->frame, &got_frame, &ctx->packet);
+-
+-			if (got_frame && frame_number % 25 == 0)
++			avcodec_send_packet(ctx->codec_ctx, &ctx->packet);
++      if (avcodec_receive_frame(ctx->codec_ctx, ctx->frame) == 0 && frame_number % 25 == 0)
+ 			{
+ 				float diff = (float)convert_pts_to_ms(ctx->packet.pts - prev_packet_pts, ctx->format_ctx->streams[ctx->video_stream_id]->time_base);
+ 				if (fabsf(diff) < 1000 * ctx->min_sub_duration) //If the minimum duration of a subtitle line is exceeded, process packet
+@@ -548,7 +546,6 @@
+ {
+ 	// Do a binary search over the input video for faster processing
+ 	// printf("Duration: %d\n", (int)ctx->format_ctx->duration);
+-	int got_frame;
+ 	int seconds_time = 0;
+ 	for (seconds_time = 0; seconds_time < 20; seconds_time++)
+ 	{
+@@ -568,8 +565,9 @@
+ 			{
+ 				if (ctx->packet.stream_index == ctx->video_stream_id)
+ 				{
+-					avcodec_decode_video2(ctx->codec_ctx, ctx->frame, &got_frame, &ctx->packet);
+-					if (got_frame)
++          avcodec_send_packet(ctx->codec_ctx, &ctx->packet);
++          if (avcodec_receive_frame(ctx->codec_ctx, ctx->frame) == 0)
++
+ 					{
+ 						// printf("%d\n", seek_time);
+ 						if (ctx->packet.pts < seek_time)
diff --git a/srcpkgs/ccextractor/template b/srcpkgs/ccextractor/template
index 84059ffd02398a..a670758bcbe41b 100644
--- a/srcpkgs/ccextractor/template
+++ b/srcpkgs/ccextractor/template
@@ -1,7 +1,7 @@
 # Template file for 'ccextractor'
 pkgname=ccextractor
 version=0.93
-revision=2
+revision=3
 build_wrksrc="linux"
 build_style=gnu-configure
 configure_args="--enable-ocr --enable-hardsubx"

From 78b24c7c7e74f4bb9de925200ba5e7ab05d21698 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 020/108] chromaprint: revbump for ffmpeg6

---
 srcpkgs/chromaprint/patches/ffmpeg5.patch | 569 ++++++++++++++++++++++
 srcpkgs/chromaprint/template              |   2 +-
 2 files changed, 570 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromaprint/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromaprint/patches/ffmpeg5.patch b/srcpkgs/chromaprint/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..a9fd307a23c8a4
--- /dev/null
+++ b/srcpkgs/chromaprint/patches/ffmpeg5.patch
@@ -0,0 +1,569 @@
+From 8ccad6937177b1b92e40ab8f4447ea27bac009a7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= <lalinsky@gmail.com>
+Date: Fri, 4 Nov 2022 21:47:38 +0100
+Subject: [PATCH] Use FFmpeg 5.x (#120)
+
+* Use FFmpeg 5.1.2 for CI builds
+
+* Build on Ubuntu 20.04
+
+* Upgrade code to FFmpeg 5.x APIs
+
+* Only set FFmpeg include dirs if building tools
+
+* No longer needed
+
+* Use ubuntu 20.04
+---
+ .github/workflows/build.yml                   |   6 +-
+ CMakeLists.txt                                |  16 --
+ package/build.sh                              |   4 +-
+ src/audio/ffmpeg_audio_processor.h            |   2 -
+ src/audio/ffmpeg_audio_processor_avresample.h |  72 -------
+ src/audio/ffmpeg_audio_processor_swresample.h |  18 +-
+ src/audio/ffmpeg_audio_reader.h               | 197 +++++++++---------
+ tests/CMakeLists.txt                          |   6 +
+ 8 files changed, 122 insertions(+), 199 deletions(-)
+ delete mode 100644 src/audio/ffmpeg_audio_processor_avresample.h
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index f8d6a32..4da2405 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -84,9 +84,6 @@ find_package(FFmpeg)
+ if(FFMPEG_LIBRARIES)
+ 	cmake_push_check_state(RESET)
+ 	set(CMAKE_REQUIRED_LIBRARIES ${FFMPEG_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -lm)
+-	check_function_exists(av_packet_unref HAVE_AV_PACKET_UNREF)
+-	check_function_exists(av_frame_alloc HAVE_AV_FRAME_ALLOC)
+-	check_function_exists(av_frame_free HAVE_AV_FRAME_FREE)
+ 	cmake_pop_check_state()
+ endif()
+
+@@ -163,14 +160,11 @@ message(STATUS "Using ${FFT_LIB} for FFT calculations")
+ if(NOT AUDIO_PROCESSOR_LIB)
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+ 		set(AUDIO_PROCESSOR_LIB "swresample")
+-	elseif(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(AUDIO_PROCESSOR_LIB "avresample")
+ 	endif()
+ endif()
+
+ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 	if(FFMPEG_LIBSWRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE OFF)
+ 		set(USE_SWRESAMPLE ON)
+ 		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBSWRESAMPLE_LIBRARIES})
+ 		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBSWRESAMPLE_INCLUDE_DIRS})
+@@ -178,16 +172,6 @@ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ 		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+ 	endif()
+ 	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+-elseif(AUDIO_PROCESSOR_LIB STREQUAL "avresample")
+-	if(FFMPEG_LIBAVRESAMPLE_FOUND)
+-		set(USE_AVRESAMPLE ON)
+-		set(USE_SWRESAMPLE OFF)
+-		set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBAVRESAMPLE_LIBRARIES})
+-		set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBAVRESAMPLE_INCLUDE_DIRS})
+-	else()
+-		message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+-	endif()
+-	message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+ else()
+ 	message(STATUS "Building without audio conversion support, please install FFmpeg with libswresample")
+ endif()
+diff --git a/package/build.sh b/package/build.sh
+index da631ae..b41d36e 100755
+--- a/package/build.sh
++++ b/package/build.sh
+@@ -7,8 +7,8 @@ set -eux
+
+ BASE_DIR=$(cd $(dirname $0)/.. && pwd)
+
+-FFMPEG_VERSION=4.4.1
+-FFMPEG_BUILD_TAG=v4.4.1-1
++FFMPEG_VERSION=5.1.2
++FFMPEG_BUILD_TAG=v${FFMPEG_VERSION}-1
+
+ TMP_BUILD_DIR=$BASE_DIR/$(mktemp -d build.XXXXXXXX)
+ trap 'rm -rf $TMP_BUILD_DIR' EXIT
+diff --git a/src/audio/ffmpeg_audio_processor.h b/src/audio/ffmpeg_audio_processor.h
+index 7628fc7..39f4f6d 100644
+--- a/src/audio/ffmpeg_audio_processor.h
++++ b/src/audio/ffmpeg_audio_processor.h
+@@ -10,8 +10,6 @@
+
+ #if defined(USE_SWRESAMPLE)
+ #include "audio/ffmpeg_audio_processor_swresample.h"
+-#elif defined(USE_AVRESAMPLE)
+-#include "audio/ffmpeg_audio_processor_avresample.h"
+ #else
+ #error "no audio processing library"
+ #endif
+diff --git a/src/audio/ffmpeg_audio_processor_avresample.h b/src/audio/ffmpeg_audio_processor_avresample.h
+deleted file mode 100644
+index bd85f92..0000000
+--- a/src/audio/ffmpeg_audio_processor_avresample.h
++++ /dev/null
+@@ -1,72 +0,0 @@
+-// Copyright (C) 2016  Lukas Lalinsky
+-// Distributed under the MIT license, see the LICENSE file for details.
+-
+-#ifndef CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-#define CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-
+-extern "C" {
+-#include <libavresample/avresample.h>
+-}
+-
+-namespace chromaprint {
+-
+-class FFmpegAudioProcessor {
+-public:
+-	FFmpegAudioProcessor() {
+-		m_resample_ctx = avresample_alloc_context();
+-	}
+-
+-	~FFmpegAudioProcessor() {
+-		avresample_free(&m_resample_ctx);
+-	}
+-
+-	void SetCompatibleMode() {
+-		av_opt_set_int(m_resample_ctx, "filter_size", 16, 0);
+-		av_opt_set_int(m_resample_ctx, "phase_shift", 8, 0);
+-		av_opt_set_int(m_resample_ctx, "linear_interp", 1, 0);
+-		av_opt_set_double(m_resample_ctx, "cutoff", 0.8, 0);
+-	}
+-
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "in_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "in_sample_rate", sample_rate, 0);
+-	}
+-
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_resample_ctx, "out_channel_layout", channel_layout, 0);
+-	}
+-
+-	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_format, 0);
+-	}
+-
+-	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_rate, 0);
+-	}
+-
+-	int Init() {
+-		return avresample_open(m_resample_ctx);
+-	}
+-
+-	int Convert(uint8_t **out, int out_count, const uint8_t **in, int in_count) {
+-		return avresample_convert(m_resample_ctx, out, 0, out_count, (uint8_t **) in, 0, in_count);
+-	}
+-
+-	int Flush(uint8_t **out, int out_count) {
+-		return avresample_read(m_resample_ctx, out, out_count);
+-	}
+-
+-private:
+-	AVAudioResampleContext *m_resample_ctx = nullptr;
+-};
+-
+-}; // namespace chromaprint
+-
+-#endif
+diff --git a/src/audio/ffmpeg_audio_processor_swresample.h b/src/audio/ffmpeg_audio_processor_swresample.h
+index b86266b..b1d4bea 100644
+--- a/src/audio/ffmpeg_audio_processor_swresample.h
++++ b/src/audio/ffmpeg_audio_processor_swresample.h
+@@ -28,30 +28,28 @@ public:
+ 		av_opt_set_double(m_swr_ctx, "cutoff", 0.8, 0);
+ 	}
+
+-	void SetInputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "icl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "ich", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetInputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "in_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetInputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "isf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "in_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetInputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "isr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "in_sample_rate", sample_rate, 0);
+ 	}
+
+-	void SetOutputChannelLayout(int64_t channel_layout) {
+-		av_opt_set_int(m_swr_ctx, "ocl", channel_layout, 0);
+-		av_opt_set_int(m_swr_ctx, "och", av_get_channel_layout_nb_channels(channel_layout), 0);
++	void SetOutputChannelLayout(AVChannelLayout *channel_layout) {
++		av_opt_set_int(m_swr_ctx, "out_channel_layout", channel_layout->u.mask, 0);
+ 	}
+
+ 	void SetOutputSampleFormat(AVSampleFormat sample_format) {
+-		av_opt_set_int(m_swr_ctx, "osf", sample_format, 0);
++		av_opt_set_sample_fmt(m_swr_ctx, "out_sample_fmt", sample_format, 0);
+ 	}
+
+ 	void SetOutputSampleRate(int sample_rate) {
+-		av_opt_set_int(m_swr_ctx, "osr", sample_rate, 0);
++		av_opt_set_int(m_swr_ctx, "out_sample_rate", sample_rate, 0);
+ 	}
+
+ 	int Init() {
+diff --git a/src/audio/ffmpeg_audio_reader.h b/src/audio/ffmpeg_audio_reader.h
+index 5550164..1c6b346 100644
+--- a/src/audio/ffmpeg_audio_reader.h
++++ b/src/audio/ffmpeg_audio_reader.h
+@@ -62,7 +62,7 @@ public:
+ 	bool Read(const int16_t **data, size_t *size);
+
+ 	bool IsOpen() const { return m_opened; }
+-	bool IsFinished() const { return m_finished && !m_got_frame; }
++	bool IsFinished() const { return !m_has_more_packets && !m_has_more_frames; }
+
+ 	std::string GetError() const { return m_error; }
+ 	int GetErrorCode() const { return m_error_code; }
+@@ -74,20 +74,19 @@ private:
+ 	uint8_t *m_convert_buffer[1] = { nullptr };
+ 	int m_convert_buffer_nb_samples = 0;
+
+-	AVInputFormat *m_input_fmt = nullptr;
++	const AVInputFormat *m_input_fmt = nullptr;
+ 	AVDictionary *m_input_opts = nullptr;
+
+ 	AVFormatContext *m_format_ctx = nullptr;
+ 	AVCodecContext *m_codec_ctx = nullptr;
+-	AVFrame *m_frame = nullptr;
+ 	int m_stream_index = -1;
+ 	std::string m_error;
+ 	int m_error_code = 0;
+-	bool m_finished = false;
+ 	bool m_opened = false;
+-	int m_got_frame = 0;
+-	AVPacket m_packet;
+-	AVPacket m_packet0;
++	bool m_has_more_packets = true;
++	bool m_has_more_frames = true;
++	AVPacket *m_packet = nullptr;
++	AVFrame *m_frame = nullptr;
+
+ 	int m_output_sample_rate = 0;
+ 	int m_output_channels = 0;
+@@ -98,19 +97,12 @@ private:
+
+ inline FFmpegAudioReader::FFmpegAudioReader() {
+ 	av_log_set_level(AV_LOG_QUIET);
+-
+-	av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
+ }
+
+ inline FFmpegAudioReader::~FFmpegAudioReader() {
+ 	Close();
+ 	av_dict_free(&m_input_opts);
+ 	av_freep(&m_convert_buffer[0]);
+-	av_packet_unref(&m_packet0);
+ }
+
+ inline bool FFmpegAudioReader::SetInputFormat(const char *name) {
+@@ -135,11 +127,10 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ 	Close();
+
+-    av_init_packet(&m_packet);
+-	m_packet.data = nullptr;
+-	m_packet.size = 0;
+-
+-	m_packet0 = m_packet;
++	m_packet = av_packet_alloc();
++	if (!m_packet) {
++		return false;
++	}
+
+ 	ret = avformat_open_input(&m_format_ctx, file_name.c_str(), m_input_fmt, &m_input_opts);
+ 	if (ret < 0) {
+@@ -153,26 +144,31 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		return false;
+ 	}
+
+-	AVCodec *codec;
++	const AVCodec *codec;
+ 	ret = av_find_best_stream(m_format_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &codec, 0);
+ 	if (ret < 0) {
+ 		SetError("Could not find any audio stream in the file", ret);
+ 		return false;
+ 	}
+ 	m_stream_index = ret;
++	auto stream = m_format_ctx->streams[m_stream_index];
+
+-	m_codec_ctx = m_format_ctx->streams[m_stream_index]->codec;
++	m_codec_ctx = avcodec_alloc_context3(codec);
+ 	m_codec_ctx->request_sample_fmt = AV_SAMPLE_FMT_S16;
+
++	ret = avcodec_parameters_to_context(m_codec_ctx, stream->codecpar);
++	if (ret < 0) {
++		SetError("Could not copy the stream parameters", ret);
++		return false;
++	}
++
+ 	ret = avcodec_open2(m_codec_ctx, codec, nullptr);
+ 	if (ret < 0) {
+ 		SetError("Could not open the codec", ret);
+ 		return false;
+ 	}
+
+-	if (!m_codec_ctx->channel_layout) {
+-		m_codec_ctx->channel_layout = av_get_default_channel_layout(m_codec_ctx->channels);
+-	}
++	av_dump_format(m_format_ctx, 0, "foo", 0);
+
+ 	m_frame = av_frame_alloc();
+ 	if (!m_frame) {
+@@ -183,19 +179,23 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		m_output_sample_rate = m_codec_ctx->sample_rate;
+ 	}
+
+-	if (!m_output_channels) {
+-		m_output_channels = m_codec_ctx->channels;
++	AVChannelLayout output_channel_layout;
++	if (m_output_channels) {
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
++	} else {
++		m_output_channels = m_codec_ctx->ch_layout.nb_channels;
++		av_channel_layout_default(&output_channel_layout, m_output_channels);
+ 	}
+
+-	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
++	if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->ch_layout.nb_channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
+ 		m_converter.reset(new FFmpegAudioProcessor());
+ 		m_converter->SetCompatibleMode();
+ 		m_converter->SetInputSampleFormat(m_codec_ctx->sample_fmt);
+ 		m_converter->SetInputSampleRate(m_codec_ctx->sample_rate);
+-		m_converter->SetInputChannelLayout(m_codec_ctx->channel_layout);
++		m_converter->SetInputChannelLayout(&(m_codec_ctx->ch_layout));
+ 		m_converter->SetOutputSampleFormat(AV_SAMPLE_FMT_S16);
+ 		m_converter->SetOutputSampleRate(m_output_sample_rate);
+-		m_converter->SetOutputChannelLayout(av_get_default_channel_layout(m_output_channels));
++		m_converter->SetOutputChannelLayout(&output_channel_layout);
+ 		auto ret = m_converter->Init();
+ 		if (ret != 0) {
+ 			SetError("Could not create an audio converter instance", ret);
+@@ -203,10 +203,11 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ 		}
+ 	}
+
++	av_channel_layout_uninit(&output_channel_layout);
++
+ 	m_opened = true;
+-	m_finished = false;
+-	m_got_frame = 0;
+-	m_nb_packets = 0;
++	m_has_more_packets = true;
++	m_has_more_frames = true;
+ 	m_decode_error = 0;
+
+ 	return true;
+@@ -214,6 +215,7 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ inline void FFmpegAudioReader::Close() {
+ 	av_frame_free(&m_frame);
++	av_packet_free(&m_packet);
+
+ 	m_stream_index = -1;
+
+@@ -252,91 +254,98 @@ inline bool FFmpegAudioReader::Read(const int16_t **data, size_t *size) {
+ 		return false;
+ 	}
+
++	*data = nullptr;
++	*size = 0;
++
+ 	int ret;
++	bool needs_packet = false;
+ 	while (true) {
+-		while (m_packet.size <= 0) {
+-			av_packet_unref(&m_packet0);
+-			av_init_packet(&m_packet);
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			ret = av_read_frame(m_format_ctx, &m_packet);
++		while (needs_packet && m_packet->size == 0) {
++			ret = av_read_frame(m_format_ctx, m_packet);
+ 			if (ret < 0) {
+ 				if (ret == AVERROR_EOF) {
+-					m_finished = true;
++					needs_packet = false;
++					m_has_more_packets = false;
+ 					break;
+-				} else {
++				}
++				SetError("Error reading from the audio source", ret);
++				return false;
++			}
++			if (m_packet->stream_index == m_stream_index) {
++				needs_packet = false;
++			} else {
++				av_packet_unref(m_packet);
++			}
++		}
++
++		if (m_packet->size != 0) {
++			ret = avcodec_send_packet(m_codec_ctx, m_packet);
++			if (ret < 0) {
++				if (ret != AVERROR(EAGAIN)) {
+ 					SetError("Error reading from the audio source", ret);
+ 					return false;
+ 				}
+-			}
+-			m_packet0 = m_packet;
+-			if (m_packet.stream_index != m_stream_index) {
+-				m_packet.data = nullptr;
+-				m_packet.size = 0;
+ 			} else {
+-				m_nb_packets++;
++				av_packet_unref(m_packet);
+ 			}
+ 		}
+
+-		ret = avcodec_decode_audio4(m_codec_ctx, m_frame, &m_got_frame, &m_packet);
++		ret = avcodec_receive_frame(m_codec_ctx, m_frame);
+ 		if (ret < 0) {
+-			if (m_decode_error) {
+-				SetError("Error decoding audio frame", m_decode_error);
+-				return false;
++			if (ret == AVERROR_EOF) {
++				m_has_more_frames = false;
++			} else if (ret == AVERROR(EAGAIN)) {
++				if (m_has_more_packets) {
++					needs_packet = true;
++					continue;
++				} else {
++					m_has_more_frames = false;
++				}
+ 			}
+-			m_decode_error = ret;
+-			m_packet.data = nullptr;
+-			m_packet.size = 0;
+-			continue;
++			SetError("Error decoding the audio source", ret);
++			return false;
+ 		}
+
+-		break;
+-	}
+-
+-	m_decode_error = 0;
+-
+-	const int decoded = std::min(ret, m_packet.size);
+-	m_packet.data += decoded;
+-	m_packet.size -= decoded;
+-
+-	if (m_got_frame) {
+-		if (m_converter) {
+-			if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
+-				int linsize;
+-				av_freep(&m_convert_buffer[0]);
+-				m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
+-				ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
+-				if (ret < 0) {
+-					SetError("Couldn't allocate audio converter buffer", ret);
++		if (m_frame->nb_samples > 0) {
++			if (m_converter) {
++				if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
++					int linsize;
++					av_freep(&m_convert_buffer[0]);
++					m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
++					ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->ch_layout.nb_channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
++					if (ret < 0) {
++						SetError("Couldn't allocate audio converter buffer", ret);
++						return false;
++					}
++				}
++				auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
++				if (nb_samples < 0) {
++					SetError("Couldn't convert audio", ret);
+ 					return false;
+ 				}
+-			}
+-			auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			}
+-			*data = (const int16_t *) m_convert_buffer[0];
+-			*size = nb_samples;
+-		} else {
+-			*data = (const int16_t *) m_frame->data[0];
+-			*size = m_frame->nb_samples;
+-		}
+-	} else {
+-		if (m_finished && m_converter) {
+-			auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
+-			if (nb_samples < 0) {
+-				SetError("Couldn't convert audio", ret);
+-				return false;
+-			} else if (nb_samples > 0) {
+-				m_got_frame = 1;
+ 				*data = (const int16_t *) m_convert_buffer[0];
+ 				*size = nb_samples;
++			} else {
++				*data = (const int16_t *) m_frame->data[0];
++				*size = m_frame->nb_samples;
++			}
++		} else {
++			if (m_converter) {
++				if (IsFinished()) {
++					auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
++					if (nb_samples < 0) {
++						SetError("Couldn't convert audio", ret);
++						return false;
++					} else if (nb_samples > 0) {
++						*data = (const int16_t *) m_convert_buffer[0];
++						*size = nb_samples;
++					}
++				}
+ 			}
+ 		}
+-	}
+
+-	return true;
++		return true;
++	}
+ }
+
+ inline void FFmpegAudioReader::SetError(const char *message, int errnum) {
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index a2b517b..123e643 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -38,6 +38,12 @@ set(SRCS
+
+ if(BUILD_TOOLS)
+ 	set(SRCS ${SRCS} ../src/audio/ffmpeg_audio_reader_test.cpp)
++    include_directories(
++        ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}
++        ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}
++        ${AUDIO_PROCESSOR_INCLUDE_DIRS}
++    )
+ 	link_libraries(fpcalc_libs)
+ endif()
+
+-- 
+2.38.1
+
+
diff --git a/srcpkgs/chromaprint/template b/srcpkgs/chromaprint/template
index 7ef7838949f3a3..1f7bbc70a22c80 100644
--- a/srcpkgs/chromaprint/template
+++ b/srcpkgs/chromaprint/template
@@ -1,7 +1,7 @@
 # Template file for 'chromaprint'
 pkgname=chromaprint
 version=1.5.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DBUILD_TOOLS=ON"
 make_check_target="check"

From 3cfbaab5ed054d50f4e4eea8e52005050710bbff Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 021/108] chromium: revbump for ffmpeg6

---
 srcpkgs/chromium/patches/ffmpeg5.patch | 47 ++++++++++++++++++++++++++
 srcpkgs/chromium/template              |  2 +-
 2 files changed, 48 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch

diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..24e2da38e34ca2
--- /dev/null
+++ b/srcpkgs/chromium/patches/ffmpeg5.patch
@@ -0,0 +1,47 @@
+--- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
++++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
+@@ -92,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+-  if (stream->start_time != kNoFFmpegTimestamp)
++  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -1597,7 +1585,7 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+@@ -1618,7 +1606,7 @@
+     if (stream->type() != DemuxerStream::VIDEO)
+       continue;
+ 
+-    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
+       continue;
+ 
+     if (!stream->IsEnabled())
diff --git a/srcpkgs/chromium/template b/srcpkgs/chromium/template
index ce0cdc70a4cee9..1737180bb3a062 100644
--- a/srcpkgs/chromium/template
+++ b/srcpkgs/chromium/template
@@ -2,7 +2,7 @@
 pkgname=chromium
 # See https://chromiumdash.appspot.com/releases?platform=Linux for the latest version
 version=124.0.6367.60
-revision=1
+revision=2
 archs="i686* x86_64* aarch64* armv7l*"
 hostmakedepends="
  $(vopt_if clang "clang17 lld17 llvm17 compiler-rt")

From 7496711cb9094c60a18b60fb98d25793f634983d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 022/108] cmus: revbump for ffmpeg6

---
 srcpkgs/chromium/patches/ffmpeg5.patch | 47 --------------------------
 srcpkgs/cmus/patches/ffmpeg6.patch     | 12 +++++++
 srcpkgs/cmus/template                  |  2 +-
 3 files changed, 13 insertions(+), 48 deletions(-)
 delete mode 100644 srcpkgs/chromium/patches/ffmpeg5.patch
 create mode 100644 srcpkgs/cmus/patches/ffmpeg6.patch

diff --git a/srcpkgs/chromium/patches/ffmpeg5.patch b/srcpkgs/chromium/patches/ffmpeg5.patch
deleted file mode 100644
index 24e2da38e34ca2..00000000000000
--- a/srcpkgs/chromium/patches/ffmpeg5.patch
+++ /dev/null
@@ -1,47 +0,0 @@
---- a/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:33:57.366213805 +0200
-+++ b/media/filters/ffmpeg_demuxer.cc	2023-01-23 17:43:09.283436983 +0200
-@@ -92,24 +92,12 @@
- 
- static base::TimeDelta ExtractStartTime(AVStream* stream) {
-   // The default start time is zero.
--  base::TimeDelta start_time;
-+  base::TimeDelta start_time = kNoTimestamp;
- 
-   // First try to use  the |start_time| value as is.
--  if (stream->start_time != kNoFFmpegTimestamp)
-+  if (stream->start_time != kNoFFmpegTimestamp) // AV_NOPTS_VALUE
-     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
- 
--  // Next try to use the first DTS value, for codecs where we know PTS == DTS
--  // (excludes all H26x codecs). The start time must be returned in PTS.
--  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
--      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
--      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
--      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
--    const base::TimeDelta first_pts =
--        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
--    if (first_pts < start_time)
--      start_time = first_pts;
--  }
--
-   return start_time;
- }
- 
-@@ -1597,7 +1585,7 @@
-   for (const auto& stream : streams_) {
-     if (!stream || stream->IsEnabled() != enabled)
-       continue;
--    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
-+    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
-       continue;
-     if (!lowest_start_time_stream ||
-         stream->start_time() < lowest_start_time_stream->start_time()) {
-@@ -1618,7 +1606,7 @@
-     if (stream->type() != DemuxerStream::VIDEO)
-       continue;
- 
--    if (av_stream_get_first_dts(stream->av_stream()) == kInvalidPTSMarker)
-+    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
-       continue;
- 
-     if (!stream->IsEnabled())
diff --git a/srcpkgs/cmus/patches/ffmpeg6.patch b/srcpkgs/cmus/patches/ffmpeg6.patch
new file mode 100644
index 00000000000000..ffa95ab811101b
--- /dev/null
+++ b/srcpkgs/cmus/patches/ffmpeg6.patch
@@ -0,0 +1,12 @@
+--- a/ip/ffmpeg.c
++++ b/ip/ffmpeg.c
+@@ -202,9 +202,6 @@ static int ffmpeg_open(struct input_plugin_data *ip_data)
+ 			break;
+ 		}
+ 
+-		if (codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+-			cc->flags |= AV_CODEC_FLAG_TRUNCATED;
+-
+ 		if (avcodec_open2(cc, codec, NULL) < 0) {
+ 			d_print("could not open codec: %d, %s\n", cc->codec_id, avcodec_get_name(cc->codec_id));
+ 			err = -IP_ERROR_UNSUPPORTED_FILE_TYPE;
diff --git a/srcpkgs/cmus/template b/srcpkgs/cmus/template
index 0d1436744f1b2c..a6e4b4fa86cb83 100644
--- a/srcpkgs/cmus/template
+++ b/srcpkgs/cmus/template
@@ -1,7 +1,7 @@
 # Template file for 'cmus'
 pkgname=cmus
 version=2.10.0
-revision=3
+revision=4
 build_style=configure
 configure_args="prefix=/usr LD=$CC"
 hostmakedepends="pkg-config"

From 0c4ec6ccb4262402823bbf2898d5409222cf3617 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 023/108] cyanrip: revbump for ffmpeg6

---
 srcpkgs/cyanrip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/cyanrip/template b/srcpkgs/cyanrip/template
index 9796e3461601a7..5db30e020d17ee 100644
--- a/srcpkgs/cyanrip/template
+++ b/srcpkgs/cyanrip/template
@@ -1,7 +1,7 @@
 # Template file for 'cyanrip'
 pkgname=cyanrip
 version=0.9.0
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config"
 makedepends="ffmpeg-devel libcdio-devel libcdio-paranoia-devel libcurl-devel libmusicbrainz5-devel"

From 2131123aa7d0a1d692e2d8efd147e36584b57418 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 024/108] deadbeef: revbump for ffmpeg4

---
 srcpkgs/deadbeef/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/deadbeef/template b/srcpkgs/deadbeef/template
index f5f4bf24b8cb6d..7b47e615cd48ef 100644
--- a/srcpkgs/deadbeef/template
+++ b/srcpkgs/deadbeef/template
@@ -1,14 +1,14 @@
 # Template file for 'deadbeef'
 pkgname=deadbeef
 version=1.8.8
-revision=3
+revision=4
 create_wrksrc=yes
 build_style=gnu-configure
 configure_args="--disable-oss --disable-lfm --disable-notify --disable-gtk2"
 hostmakedepends="automake libtool gettext gettext-devel intltool pkg-config
  yasm clang glib-devel"
 makedepends="
- alsa-lib-devel dbus-devel faad2-devel ffmpeg-devel gtk+3-devel imlib2-devel
+ alsa-lib-devel dbus-devel faad2-devel ffmpeg4-devel gtk+3-devel imlib2-devel
  jansson-devel libcddb-devel libcdio-devel libcurl-devel libflac-devel
  libmad-devel libpng-devel libsamplerate-devel libsndfile-devel libvorbis-devel
  libzip-devel mpg123-devel opusfile-devel pulseaudio-devel wavpack-devel"

From 78cc5f868e1bd316c36dcffbbb9f6672ffbce2f3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 025/108] droidcam-obs-plugin: revbump for ffmpeg6

---
 srcpkgs/droidcam-obs-plugin/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam-obs-plugin/template b/srcpkgs/droidcam-obs-plugin/template
index 9dc6648efe94ad..93a72adf3d3c30 100644
--- a/srcpkgs/droidcam-obs-plugin/template
+++ b/srcpkgs/droidcam-obs-plugin/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam-obs-plugin'
 pkgname=droidcam-obs-plugin
 version=2.3.2
-revision=1
+revision=2
 build_style=gnu-makefile
 make_use_env=yes
 make_build_args="ALLOW_STATIC=no"

From 93b76586511f2b8f6cf64730292a4827e0c138bb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:46 -0400
Subject: [PATCH 026/108] droidcam: revbump for ffmpeg6

---
 srcpkgs/droidcam/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/droidcam/template b/srcpkgs/droidcam/template
index 1c3f1b8b1fc676..32a9220b79a4d1 100644
--- a/srcpkgs/droidcam/template
+++ b/srcpkgs/droidcam/template
@@ -1,7 +1,7 @@
 # Template file for 'droidcam'
 pkgname=droidcam
 version=1.8.2
-revision=2
+revision=3
 build_style=gnu-makefile
 make_build_args="USBMUXD=-lusbmuxd-2.0 JPEG=-lturbojpeg"
 hostmakedepends="pkg-config"

From 1c010d50b75aa24ef6620f172832691fce65982c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 027/108] ffmpegthumbnailer: revbump for ffmpeg6

---
 .../ffmpegthumbnailer/patches/ffmpeg6.patch   | 202 ++++++++++++++++++
 srcpkgs/ffmpegthumbnailer/template            |   6 +-
 2 files changed, 205 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch

diff --git a/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
new file mode 100644
index 00000000000000..363ff35a28419d
--- /dev/null
+++ b/srcpkgs/ffmpegthumbnailer/patches/ffmpeg6.patch
@@ -0,0 +1,202 @@
+--- a/libffmpegthumbnailer/moviedecoder.cpp	2017-11-21 14:06:57.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.cpp	2023-05-05 13:14:47.946560668 -0400
+@@ -41,11 +41,6 @@
+ namespace ffmpegthumbnailer
+ {
+ 
+-struct SilenceLogLevel
+-{
+-    SilenceLogLevel() { av_log_set_level(AV_LOG_QUIET); }
+-};
+-
+ MovieDecoder::MovieDecoder(AVFormatContext* pavContext)
+ : m_VideoStream(-1)
+ , m_pFormatContext(pavContext)
+@@ -70,8 +65,6 @@
+ 
+ void MovieDecoder::initialize(const string& filename, bool preferEmbeddedMetadata)
+ {
+-    av_register_all();
+-    avcodec_register_all();
+     avformat_network_init();
+ 
+     string inputFile = filename == "-" ? "pipe:" : filename;
+@@ -97,8 +90,7 @@
+ {
+     if (m_pVideoCodecContext)
+     {
+-        avcodec_close(m_pVideoCodecContext);
+-        m_pVideoCodecContext = nullptr;
++        avcodec_free_context(&m_pVideoCodecContext);
+     }
+ 
+     if ((!m_FormatContextWasGiven) && m_pFormatContext)
+@@ -152,10 +144,10 @@
+     for (unsigned int i = 0; i < m_pFormatContext->nb_streams; ++i)
+     {
+         AVStream *stream = m_pFormatContext->streams[i];
+-        auto ctx = m_pFormatContext->streams[i]->codec;
+-        if (ctx->codec_type == AVMEDIA_TYPE_VIDEO)
++        auto par = m_pFormatContext->streams[i]->codecpar;
++        if (par->codec_type == AVMEDIA_TYPE_VIDEO)
+         {
+-            if (!preferEmbeddedMetadata || !isStillImageCodec(ctx->codec_id))
++            if (!preferEmbeddedMetadata || !isStillImageCodec(par->codec_id))
+             {
+                 videoStreams.push_back(i);
+                 continue;
+@@ -203,8 +195,7 @@
+     }
+ 
+     m_pVideoStream = m_pFormatContext->streams[m_VideoStream];
+-    m_pVideoCodecContext = m_pVideoStream->codec;
+-    m_pVideoCodec = avcodec_find_decoder(m_pVideoCodecContext->codec_id);
++    m_pVideoCodec = avcodec_find_decoder(m_pVideoStream->codecpar->codec_id);
+ 
+     if (m_pVideoCodec == nullptr)
+     {
+@@ -214,6 +205,20 @@
+         throw logic_error("Video Codec not found");
+     }
+ 
++    m_pVideoCodecContext = avcodec_alloc_context3(m_pVideoCodec);
++
++    if (m_pVideoCodecContext == nullptr)
++    {
++        destroy();
++        throw logic_error("Could not allocate video codec context");
++    }
++
++    if (avcodec_parameters_to_context(m_pVideoCodecContext, m_pVideoStream->codecpar) < 0)
++    {
++        destroy();
++        throw logic_error("Could not configure video codec context");
++    }
++
+     m_pVideoCodecContext->workaround_bugs = 1;
+ 
+     if (avcodec_open2(m_pVideoCodecContext, m_pVideoCodec, nullptr) < 0)
+@@ -386,13 +391,6 @@
+ 
+ void MovieDecoder::initializeFilterGraph(const AVRational& timeBase, const std::string& size, bool maintainAspectRatio)
+ {
+-    static const AVPixelFormat pixelFormats[] = { AV_PIX_FMT_RGB24, AV_PIX_FMT_NONE };
+-
+-    auto del = [] (AVBufferSinkParams* p) { av_freep(p); };
+-    std::unique_ptr<AVBufferSinkParams, decltype(del)> buffersinkParams(av_buffersink_params_alloc(), del);
+-
+-    avfilter_register_all();
+-
+     m_pFilterGraph = avfilter_graph_alloc();
+     assert(m_pFilterGraph);
+ 
+@@ -404,10 +402,8 @@
+ 
+     checkRc(avfilter_graph_create_filter(&m_pFilterSource, avfilter_get_by_name("buffer"), "thumb_buffer", ss.str().c_str(), nullptr, m_pFilterGraph),
+             "Failed to create filter source");
+-    buffersinkParams->pixel_fmts = pixelFormats;
+-    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, buffersinkParams.get(), m_pFilterGraph),
++    checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, nullptr, m_pFilterGraph),
+             "Failed to create filter sink");
+-    buffersinkParams.release();
+ 
+     AVFilterContext* yadifFilter = nullptr;
+     if (m_pFrame->interlaced_frame != 0)
+@@ -500,15 +496,15 @@
+     }
+ 
+     checkRc(av_seek_frame(m_pFormatContext, -1, timestamp, 0), "Seeking in video failed");
+-    avcodec_flush_buffers(m_pFormatContext->streams[m_VideoStream]->codec);
++    avcodec_flush_buffers(m_pVideoCodecContext);
+ 
+     int keyFrameAttempts = 0;
+-    bool gotFrame = 0;
++    bool gotFrame;
+ 
+     do
+     {
+         int count = 0;
+-        gotFrame = 0;
++        gotFrame = false;
+ 
+         while (!gotFrame && count < 20)
+         {
+@@ -552,17 +548,33 @@
+         return false;
+     }
+ 
+-    av_frame_unref(m_pFrame);
+-
+-    int frameFinished;
++    int rc = avcodec_send_packet(m_pVideoCodecContext, m_pPacket);
++    if(rc == AVERROR(EAGAIN))
++    {
++        rc = 0;
++    }
+ 
+-    int bytesDecoded = avcodec_decode_video2(m_pVideoCodecContext, m_pFrame, &frameFinished, m_pPacket);
+-    if (bytesDecoded < 0)
++    if(rc == AVERROR_EOF)
++    {
++        return false;
++    }
++    else if(rc < 0)
+     {
+-        throw logic_error("Failed to decode video frame: bytesDecoded < 0");
++        throw logic_error("Failed to decode video frame: avcodec_send_packet() < 0");
+     }
+ 
+-    return frameFinished > 0;
++    rc = avcodec_receive_frame(m_pVideoCodecContext, m_pFrame);
++    switch(rc)
++    {
++        case 0:
++            return true;
++
++        case AVERROR(EAGAIN):
++            return false;
++
++        default:
++            throw logic_error("Failed to decode video frame: avcodec_receive_frame() < 0");
++    }
+ }
+ 
+ bool MovieDecoder::getVideoPacket()
+@@ -570,8 +582,6 @@
+     bool framesAvailable = true;
+     bool frameDecoded = false;
+ 
+-    int attempts = 0;
+-
+     if (m_pPacket)
+     {
+         av_packet_unref(m_pPacket);
+@@ -580,6 +590,7 @@
+ 
+     m_pPacket = new AVPacket();
+ 
++
+     while (framesAvailable && !frameDecoded)
+     {
+         framesAvailable = av_read_frame(m_pFormatContext, m_pPacket) >= 0;
+@@ -644,7 +655,7 @@
+ 
+ int32_t MovieDecoder::getStreamRotation()
+ {
+-    int32_t* matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
++    auto matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
+     if (matrix)
+     {
+         auto angle = lround(av_display_rotation_get(matrix));
+
+--- a/libffmpegthumbnailer/moviedecoder.h	2017-11-12 04:23:38.000000000 -0500
++++ b/libffmpegthumbnailer/moviedecoder.h	2023-05-05 13:26:07.095529911 -0400
+@@ -78,7 +78,7 @@
+     int                     m_VideoStream;
+     AVFormatContext*        m_pFormatContext;
+     AVCodecContext*         m_pVideoCodecContext;
+-    AVCodec*                m_pVideoCodec;
++    const AVCodec*          m_pVideoCodec;
+     AVFilterGraph*          m_pFilterGraph;
+     AVFilterContext*        m_pFilterSource;
+     AVFilterContext*        m_pFilterSink;
diff --git a/srcpkgs/ffmpegthumbnailer/template b/srcpkgs/ffmpegthumbnailer/template
index 039eea7622b391..35d546018d12af 100644
--- a/srcpkgs/ffmpegthumbnailer/template
+++ b/srcpkgs/ffmpegthumbnailer/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbnailer'
 pkgname=ffmpegthumbnailer
 version=2.2.2
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libpng-devel libjpeg-turbo-devel ffmpeg-devel"
@@ -9,8 +9,8 @@ depends="ffmpeg"
 short_desc="Lightweight video thumbnailer"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-2.0-or-later"
-homepage="https://github.com/dirkvdb/${pkgname}"
-distfiles="${homepage}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
+homepage="https://github.com/dirkvdb"
+distfiles="${homepage}/${pkgname}/releases/download/${version}/${pkgname}-${version}.tar.bz2"
 checksum=1cb24059c38223f657b300c84dd80491b7040d4b69471c4fea69be862bc99b5b
 
 post_install() {

From c8048b7764899c22adb468b091f74fe48f88dc70 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 028/108] ffmpegthumbs: revbump for ffmpeg6

---
 srcpkgs/ffmpegthumbs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/ffmpegthumbs/template b/srcpkgs/ffmpegthumbs/template
index 2e2a96de83ce8a..dfd7e9dede36d3 100644
--- a/srcpkgs/ffmpegthumbs/template
+++ b/srcpkgs/ffmpegthumbs/template
@@ -1,7 +1,7 @@
 # Template file for 'ffmpegthumbs'
 pkgname=ffmpegthumbs
 version=23.08.5
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules kcoreaddons kconfig-devel
  pkg-config qt5-host-tools qt5-qmake gettext"

From 8f567c297e44f75f741bcc1455a534dd7f70b34b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 029/108] ffms2: revbump for ffmpeg6

---
 srcpkgs/ffms2/patches/ffmpeg5.patch | 424 ++++++++++++++++++++++++++++
 srcpkgs/ffms2/template              |   2 +-
 2 files changed, 425 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ffms2/patches/ffmpeg5.patch

diff --git a/srcpkgs/ffms2/patches/ffmpeg5.patch b/srcpkgs/ffms2/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..1479fabcafcb4e
--- /dev/null
+++ b/srcpkgs/ffms2/patches/ffmpeg5.patch
@@ -0,0 +1,424 @@
+From 45673149e9a2f5586855ad472e3059084eaa36b1 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:41:21 +0100
+Subject: [PATCH] Use auto for AVCodec
+
+The geniuses over at FFmpeg decided to constify this API, so old
+versions of the library will return AVCodec *, while new versions
+of the libary will return const AVCodec *, which, in C++, are not
+OK to convert between.
+
+Rather than use some macro hell in ffmscompat.h, we can work around
+this by using auto.
+
+Gross.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 2 +-
+ src/core/indexing.cpp    | 6 +++---
+ src/core/videosource.cpp | 2 +-
+ 3 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index e4ce97c..ac09666 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -469,7 +469,7 @@ void FFMS_AudioSource::OpenFile() {
+ 
+     LAVFOpenFile(SourceFile.c_str(), FormatContext, TrackNumber);
+ 
+-    AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
++    auto *Codec = avcodec_find_decoder(FormatContext->streams[TrackNumber]->codecpar->codec_id);
+     if (Codec == nullptr)
+         throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+             "Audio codec not found");
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index e547c5a..59fb4e8 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -384,7 +384,7 @@ FFMS_TrackType FFMS_Indexer::GetTrackType(int Track) {
+ }
+ 
+ const char *FFMS_Indexer::GetTrackCodec(int Track) {
+-    AVCodec *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
++    auto *codec = avcodec_find_decoder(FormatContext->streams[Track]->codecpar->codec_id);
+     return codec ? codec->name : nullptr;
+ }
+ 
+@@ -402,7 +402,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             UseDTS);
+ 
+         if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            AVCodec *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *VideoCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (!VideoCodec) {
+                 FormatContext->streams[i]->discard = AVDISCARD_ALL;
+                 IndexMask.erase(i);
+@@ -433,7 +433,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 IndexMask.insert(i);
+             }
+         } else if (IndexMask.count(i) && FormatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+-            AVCodec *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
++            auto *AudioCodec = avcodec_find_decoder(FormatContext->streams[i]->codecpar->codec_id);
+             if (AudioCodec == nullptr)
+                 throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_UNSUPPORTED,
+                     "Audio codec not found");
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index b889970..8956c22 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -171,7 +171,7 @@ FFMS_VideoSource::FFMS_VideoSource(const char *SourceFile, FFMS_Index &Index, in
+ 
+         LAVFOpenFile(SourceFile, FormatContext, VideoTrack);
+ 
+-        AVCodec *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
++        auto *Codec = avcodec_find_decoder(FormatContext->streams[VideoTrack]->codecpar->codec_id);
+         if (Codec == nullptr)
+             throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_CODEC,
+                 "Video codec not found");
+-- 
+2.40.0
+
+From 96cbf38ea9381829a1314f432a2c60495dcefaad Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:12:41 +0100
+Subject: [PATCH] all: Update AVPacket API usage
+
+AVPackets must all be on the heap now, since it is no longer
+part of the libav* ABI.
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ src/core/audiosource.cpp | 16 ++++++----
+ src/core/indexing.cpp    | 63 ++++++++++++++++++++++------------------
+ src/core/indexing.h      |  4 +--
+ src/core/utils.cpp       |  6 ----
+ src/core/utils.h         |  1 -
+ src/core/videosource.cpp | 30 ++++++++++---------
+ 6 files changed, 64 insertions(+), 56 deletions(-)
+
+diff --git a/src/core/audiosource.cpp b/src/core/audiosource.cpp
+index 37cf9ae..e4ce97c 100644
+--- a/src/core/audiosource.cpp
++++ b/src/core/audiosource.cpp
+@@ -285,10 +285,15 @@ FFMS_AudioSource::AudioBlock *FFMS_AudioSource::CacheBlock(CacheIterator &pos) {
+ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     CurrentFrame = &Frames[PacketNumber];
+ 
+-    AVPacket Packet;
+-    if (!ReadPacket(&Packet))
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++    if (!ReadPacket(Packet)) {
++        av_packet_free(&Packet);
+         throw FFMS_Exception(FFMS_ERROR_PARSER, FFMS_ERROR_UNKNOWN,
+             "ReadPacket unexpectedly failed to read a packet");
++    }
+ 
+     // ReadPacket may have changed the packet number
+     CurrentFrame = &Frames[PacketNumber];
+@@ -297,8 +302,9 @@ int FFMS_AudioSource::DecodeNextBlock(CacheIterator *pos) {
+     int NumberOfSamples = 0;
+     AudioBlock *CachedBlock = nullptr;
+     
+-    int Ret = avcodec_send_packet(CodecContext, &Packet);
+-    av_packet_unref(&Packet);
++    int Ret = avcodec_send_packet(CodecContext, Packet);
++    av_packet_unref(Packet);
++    av_packet_free(&Packet);
+ 
+     av_frame_unref(DecodeFrame);
+     Ret = avcodec_receive_frame(CodecContext, DecodeFrame);
+@@ -513,8 +519,6 @@ void FFMS_AudioSource::Seek() {
+ }
+ 
+ bool FFMS_AudioSource::ReadPacket(AVPacket *Packet) {
+-    InitNullPacket(*Packet);
+-
+     while (av_read_frame(FormatContext, Packet) >= 0) {
+         if (Packet->stream_index == TrackNumber) {
+             // Required because not all audio packets, especially in ogg, have a pts. Use the previous valid packet's pts instead.
+diff --git a/src/core/indexing.cpp b/src/core/indexing.cpp
+index 23fb95b..e547c5a 100644
+--- a/src/core/indexing.cpp
++++ b/src/core/indexing.cpp
+@@ -320,7 +320,7 @@ void FFMS_Indexer::CheckAudioProperties(int Track, AVCodecContext *Context) {
+     }
+ }
+ 
+-void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict,
++void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict,
+                                     int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct) {
+     if (VideoContext.Parser) {
+         uint8_t *OB;
+@@ -330,8 +330,8 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+         av_parser_parse2(VideoContext.Parser,
+             VideoContext.CodecContext,
+             &OB, &OBSize,
+-            pkt.data, pkt.size,
+-            pkt.pts, pkt.dts, pkt.pos);
++            pkt->data, pkt->size,
++            pkt->pts, pkt->dts, pkt->pos);
+ 
+         // H.264 (PAFF) and HEVC may have one field per packet, so we need to track
+         // when we have a full or half frame available, and mark one of them as
+@@ -351,15 +351,15 @@ void FFMS_Indexer::ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt
+ 
+         *RepeatPict = VideoContext.Parser->repeat_pict;
+         *FrameType = VideoContext.Parser->pict_type;
+-        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt.flags & AV_PKT_FLAG_DISCARD));
++        *Invisible = (IncompleteFrame || VideoContext.Parser->repeat_pict < 0 || (pkt->flags & AV_PKT_FLAG_DISCARD));
+     } else {
+-        *Invisible = !!(pkt.flags & AV_PKT_FLAG_DISCARD);
++        *Invisible = !!(pkt->flags & AV_PKT_FLAG_DISCARD);
+     }
+ 
+     if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP8)
+-        ParseVP8(pkt.data[0], Invisible, FrameType);
++        ParseVP8(pkt->data[0], Invisible, FrameType);
+     else if (VideoContext.CodecContext->codec_id == AV_CODEC_ID_VP9)
+-        ParseVP9(pkt.data[0], Invisible, FrameType);
++        ParseVP9(pkt->data[0], Invisible, FrameType);
+ }
+ 
+ void FFMS_Indexer::Free() {
+@@ -458,32 +458,36 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+         }
+     }
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_CODEC, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
+     std::vector<int64_t> LastValidTS(FormatContext->nb_streams, AV_NOPTS_VALUE);
+ 
+     int64_t filesize = avio_size(FormatContext->pb);
+     enum AVPictureStructure LastPicStruct = AV_PICTURE_STRUCTURE_UNKNOWN;
+-    while (av_read_frame(FormatContext, &Packet) >= 0) {
++    while (av_read_frame(FormatContext, Packet) >= 0) {
+         // Update progress
+         // FormatContext->pb can apparently be NULL when opening images.
+         if (IC && FormatContext->pb) {
+-            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate))
++            if ((*IC)(FormatContext->pb->pos, filesize, ICPrivate)) {
++                av_packet_free(&Packet);
+                 throw FFMS_Exception(FFMS_ERROR_CANCELLED, FFMS_ERROR_USER,
+                     "Cancelled by user");
++            }
+         }
+-        if (!IndexMask.count(Packet.stream_index)) {
+-            av_packet_unref(&Packet);
++        if (!IndexMask.count(Packet->stream_index)) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+-        int Track = Packet.stream_index;
++        int Track = Packet->stream_index;
+         FFMS_Track &TrackInfo = (*TrackIndices)[Track];
+-        bool KeyFrame = !!(Packet.flags & AV_PKT_FLAG_KEY);
++        bool KeyFrame = !!(Packet->flags & AV_PKT_FLAG_KEY);
+         ReadTS(Packet, LastValidTS[Track], (*TrackIndices)[Track].UseDTS);
+ 
+         if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+-            int64_t PTS = TrackInfo.UseDTS ? Packet.dts : Packet.pts;
++            int64_t PTS = TrackInfo.UseDTS ? Packet->dts : Packet->pts;
+             if (PTS == AV_NOPTS_VALUE) {
+                 // VPx alt-refs are output as packets which lack timestmps or durations, since
+                 // they are invisible. Currently, the timestamp mangling code in libavformat
+@@ -495,9 +499,11 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 // FFMS2 currently sorts packets by PTS, which will break decoding, otherwise.
+                 bool HasAltRefs = (FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP8 ||
+                                    FormatContext->streams[Track]->codecpar->codec_id == AV_CODEC_ID_VP9);
+-                if (Packet.duration == 0 && !HasAltRefs)
++                if (Packet->duration == 0 && !HasAltRefs) {
++                    av_packet_free(&Packet);
+                     throw FFMS_Exception(FFMS_ERROR_INDEXING, FFMS_ERROR_PARSER,
+                         "Invalid packet pts, dts, and duration");
++                }
+ 
+                 if (TrackInfo.empty())
+                     PTS = 0;
+@@ -513,7 +519,7 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+             ParseVideoPacket(AVContexts[Track], Packet, &RepeatPict, &FrameType, &Invisible, &LastPicStruct);
+ 
+             TrackInfo.AddVideoFrame(PTS, RepeatPict, KeyFrame,
+-                FrameType, Packet.pos, Invisible);
++                FrameType, Packet->pos, Invisible);
+         } else if (FormatContext->streams[Track]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+             // For video seeking timestamps are used only if all packets have
+             // timestamps, while for audio they're used if any have timestamps,
+@@ -522,28 +528,29 @@ FFMS_Index *FFMS_Indexer::DoIndexing() {
+                 TrackInfo.HasTS = true;
+ 
+             int64_t StartSample = AVContexts[Track].CurrentSample;
+-            uint32_t SampleCount = IndexAudioPacket(Track, &Packet, AVContexts[Track], *TrackIndices);
++            uint32_t SampleCount = IndexAudioPacket(Track, Packet, AVContexts[Track], *TrackIndices);
+             TrackInfo.SampleRate = AVContexts[Track].CodecContext->sample_rate;
+ 
+             TrackInfo.AddAudioFrame(LastValidTS[Track],
+-                StartSample, SampleCount, KeyFrame, Packet.pos, Packet.flags & AV_PKT_FLAG_DISCARD);
++                StartSample, SampleCount, KeyFrame, Packet->pos, Packet->flags & AV_PKT_FLAG_DISCARD);
+         }
+ 
+-        if (!(Packet.flags & AV_PKT_FLAG_DISCARD))
+-            TrackInfo.LastDuration = Packet.duration;
++        if (!(Packet->flags & AV_PKT_FLAG_DISCARD))
++            TrackInfo.LastDuration = Packet->duration;
+ 
+-        av_packet_unref(&Packet);
++        av_packet_unref(Packet);
+     }
++    av_packet_free(&Packet);
+ 
+     TrackIndices->Finalize(AVContexts, FormatContext->iformat->name);
+     return TrackIndices.release();
+ }
+ 
+-void FFMS_Indexer::ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS) {
+-    if (!UseDTS && Packet.pts != AV_NOPTS_VALUE)
+-        TS = Packet.pts;
++void FFMS_Indexer::ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS) {
++    if (!UseDTS && Packet->pts != AV_NOPTS_VALUE)
++        TS = Packet->pts;
+     if (TS == AV_NOPTS_VALUE)
+         UseDTS = true;
+-    if (UseDTS && Packet.dts != AV_NOPTS_VALUE)
+-        TS = Packet.dts;
++    if (UseDTS && Packet->dts != AV_NOPTS_VALUE)
++        TS = Packet->dts;
+ }
+diff --git a/src/core/indexing.h b/src/core/indexing.h
+index 3cfc3c3..5c06868 100644
+--- a/src/core/indexing.h
++++ b/src/core/indexing.h
+@@ -80,10 +80,10 @@ private:
+     int64_t Filesize;
+     uint8_t Digest[20];
+ 
+-    void ReadTS(const AVPacket &Packet, int64_t &TS, bool &UseDTS);
++    void ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS);
+     void CheckAudioProperties(int Track, AVCodecContext *Context);
+     uint32_t IndexAudioPacket(int Track, AVPacket *Packet, SharedAVContext &Context, FFMS_Index &TrackIndices);
+-    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket &pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
++    void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict, int *FrameType, bool *Invisible, enum AVPictureStructure *LastPicStruct);
+     void Free();
+ public:
+     FFMS_Indexer(const char *Filename);
+diff --git a/src/core/utils.cpp b/src/core/utils.cpp
+index ce67533..8a2e997 100644
+--- a/src/core/utils.cpp
++++ b/src/core/utils.cpp
+@@ -62,12 +62,6 @@ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo) {
+     }
+ }
+ 
+-void InitNullPacket(AVPacket &pkt) {
+-    av_init_packet(&pkt);
+-    pkt.data = nullptr;
+-    pkt.size = 0;
+-}
+-
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames) {
+     AP.SampleFormat = static_cast<FFMS_SampleFormat>(av_get_packed_sample_fmt(CTX->sample_fmt));
+     AP.BitsPerSample = av_get_bytes_per_sample(CTX->sample_fmt) * 8;
+diff --git a/src/core/utils.h b/src/core/utils.h
+index 9819dc7..003ab79 100644
+--- a/src/core/utils.h
++++ b/src/core/utils.h
+@@ -58,7 +58,6 @@ std::unique_ptr<T> make_unique(Args&&... args) {
+ }
+ 
+ void ClearErrorInfo(FFMS_ErrorInfo *ErrorInfo);
+-void InitNullPacket(AVPacket &pkt);
+ void FillAP(FFMS_AudioProperties &AP, AVCodecContext *CTX, FFMS_Track &Frames);
+ 
+ void LAVFOpenFile(const char *SourceFile, AVFormatContext *&FormatContext, int Track);
+diff --git a/src/core/videosource.cpp b/src/core/videosource.cpp
+index 06bd161..b889970 100644
+--- a/src/core/videosource.cpp
++++ b/src/core/videosource.cpp
+@@ -673,30 +673,34 @@ void FFMS_VideoSource::DecodeNextFrame(int64_t &AStartTime, int64_t &Pos) {
+     if (HasPendingDelayedFrames())
+         return;
+ 
+-    AVPacket Packet;
+-    InitNullPacket(Packet);
+-
+-    while (ReadFrame(&Packet) >= 0) {
+-        if (Packet.stream_index != VideoTrack) {
+-            av_packet_unref(&Packet);
++    AVPacket *Packet = av_packet_alloc();
++    if (!Packet)
++        throw FFMS_Exception(FFMS_ERROR_DECODING, FFMS_ERROR_ALLOCATION_FAILED,
++            "Could not allocate packet.");
++
++    while (ReadFrame(Packet) >= 0) {
++        if (Packet->stream_index != VideoTrack) {
++            av_packet_unref(Packet);
+             continue;
+         }
+ 
+         if (AStartTime < 0)
+-            AStartTime = Frames.UseDTS ? Packet.dts : Packet.pts;
++            AStartTime = Frames.UseDTS ? Packet->dts : Packet->pts;
+ 
+         if (Pos < 0)
+-            Pos = Packet.pos;
++            Pos = Packet->pos;
+ 
+-        bool FrameFinished = DecodePacket(&Packet);
+-        av_packet_unref(&Packet);
+-        if (FrameFinished)
++        bool FrameFinished = DecodePacket(Packet);
++        av_packet_unref(Packet);
++        if (FrameFinished) {
++            av_packet_free(&Packet);
+             return;
++        }
+     }
+ 
+     // Flush final frames
+-    InitNullPacket(Packet);
+-    DecodePacket(&Packet);
++    DecodePacket(Packet);
++    av_packet_free(&Packet);
+ }
+ 
+ bool FFMS_VideoSource::SeekTo(int n, int SeekOffset) {
+-- 
+2.40.0
+
+From bf9e03e9e08534c024e5a744a6437c4aac160201 Mon Sep 17 00:00:00 2001
+From: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+Date: Tue, 4 May 2021 14:20:47 +0100
+Subject: [PATCH 2/3] configure: Remove deprecated API use
+
+Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
+---
+ configure.ac | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index b35ef80bc..d19714d0f 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -102,10 +102,10 @@ CFLAGS="$_CFLAGS $FFMPEG_CFLAGS"
+
+ AC_DEFUN([TEST_FFMPEG],
+          [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+-            #include <libavcodec/avcodec.h>
++            #include <libavformat/avformat.h>
+             #include <libswscale/swscale.h>
+             ]],[[
+-                avcodec_register_all();
++                avformat_network_init();
+                 swscale_version();
+             ]])], [eval $1=yes], [eval $1=no])
+         ])
+
diff --git a/srcpkgs/ffms2/template b/srcpkgs/ffms2/template
index 365f64d10cbabf..1641ecf43be5bb 100644
--- a/srcpkgs/ffms2/template
+++ b/srcpkgs/ffms2/template
@@ -1,7 +1,7 @@
 # Template file for 'ffms2'
 pkgname=ffms2
 version=2.40
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-shared --disable-static"
 hostmakedepends="pkg-config autoconf automake libtool"

From b35dbd44b6e782ab61ed2806ac006a6ad52e9f80 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 030/108] freerdp: revbump for ffmpeg6

---
 .../freerdp/patches/ffmpeg6_aa2cb9aa.patch    | 42 +++++++++++++++++++
 srcpkgs/freerdp/template                      |  2 +-
 2 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch

diff --git a/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
new file mode 100644
index 00000000000000..a4324da3a8822b
--- /dev/null
+++ b/srcpkgs/freerdp/patches/ffmpeg6_aa2cb9aa.patch
@@ -0,0 +1,42 @@
+From aa2cb9aa5ff5562433598ba168a466e0752bca0e Mon Sep 17 00:00:00 2001
+From: akallabeth <akallabeth@posteo.net>
+Date: Tue, 14 Feb 2023 07:48:54 +0100
+Subject: [PATCH] Fixed #8686: Update h264 to use new FFMPEG API
+
+---
+ channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c | 2 ++
+ libfreerdp/codec/h264_ffmpeg.c            | 2 ++
+ 2 files changed, 4 insertions(+)
+
+diff --git a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+index 339462d865f..beea80b7a1e 100644
+--- a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
++++ b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
+@@ -239,8 +239,10 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYP
+ 		}
+ 	}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 	if (mdecoder->codec->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		mdecoder->codec_context->flags |= AV_CODEC_FLAG_TRUNCATED;
++#endif
+ 
+ 	return TRUE;
+ }
+diff --git a/libfreerdp/codec/h264_ffmpeg.c b/libfreerdp/codec/h264_ffmpeg.c
+index 8a23db2473c..896a333019b 100644
+--- a/libfreerdp/codec/h264_ffmpeg.c
++++ b/libfreerdp/codec/h264_ffmpeg.c
+@@ -615,10 +615,12 @@ static BOOL libavcodec_init(H264_CONTEXT* h264)
+ 			goto EXCEPTION;
+ 		}
+ 
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 18, 100)
+ 		if (sys->codecDecoder->capabilities & AV_CODEC_CAP_TRUNCATED)
+ 		{
+ 			sys->codecDecoderContext->flags |= AV_CODEC_FLAG_TRUNCATED;
+ 		}
++#endif
+ 
+ #ifdef WITH_VAAPI
+ 
diff --git a/srcpkgs/freerdp/template b/srcpkgs/freerdp/template
index 16fddfbe8f5287..bf3a4d2e2b3ae7 100644
--- a/srcpkgs/freerdp/template
+++ b/srcpkgs/freerdp/template
@@ -1,7 +1,7 @@
 # Template file for 'freerdp'
 pkgname=freerdp
 version=2.11.4
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_ALSA=ON -DWITH_CUPS=OFF -DWITH_FFMPEG=ON
  -DWITH_GSTREAMER_0_10=OFF -DWITH_GSTREAMER_1_0=OFF -DWITH_JPEG=ON

From c40d37e74a691f51b7561732cc63200799092f03 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 031/108] gerbera: revbump for ffmpeg6

---
 srcpkgs/gerbera/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gerbera/template b/srcpkgs/gerbera/template
index ae14f35c767c03..2dc0ac0ce03b55 100644
--- a/srcpkgs/gerbera/template
+++ b/srcpkgs/gerbera/template
@@ -1,7 +1,7 @@
 # Template file for 'gerbera'
 pkgname=gerbera
 version=1.12.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_SYSTEMD=0 -DWITH_AVCODEC=1"
 hostmakedepends="pkg-config"

From c0d4ea349ffa01339298cb952fa636ec13311834 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 032/108] goldendict: revbump for ffmpeg6

---
 srcpkgs/goldendict/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/goldendict/template b/srcpkgs/goldendict/template
index f4a05759f693d3..97f44347b03a6a 100644
--- a/srcpkgs/goldendict/template
+++ b/srcpkgs/goldendict/template
@@ -1,7 +1,7 @@
 # Template file for 'goldendict'
 pkgname=goldendict
 version=1.5.0
-revision=1
+revision=2
 build_style=qmake
 configure_args="CONFIG+=zim_support goldendict.pro"
 hostmakedepends="qt5-qmake pkg-config qt5-host-tools"
@@ -10,7 +10,7 @@ makedepends="tiff-devel qt5-devel libvorbis-devel zlib-devel
  qt5-webkit-devel lzo-devel bzip2-devel libao-devel qt5-svg-devel
  libeb-devel qt5-x11extras-devel ffmpeg-devel liblzma-devel
  qt5-multimedia-devel"
-short_desc="A feature-rich dictionary lookup program"
+short_desc="Feature-rich dictionary lookup program"
 maintainer="John <me@johnnynator.dev>"
 license="GPL-3.0-or-later"
 homepage="http://goldendict.org/"

From 5bf614e5ee2be90478ab146c0b2408d5471bafe5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 033/108] gst-libav: revbump for ffmpeg6

---
 srcpkgs/gst-libav/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-libav/template b/srcpkgs/gst-libav/template
index bb084291a6b0ba..e98d87d7c06838 100644
--- a/srcpkgs/gst-libav/template
+++ b/srcpkgs/gst-libav/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-libav'
 pkgname=gst-libav
 version=1.24.2
-revision=1
+revision=2
 build_style=meson
 hostmakedepends="pkg-config yasm"
 makedepends="orc-devel gst-plugins-base1-devel ffmpeg-devel"

From 51e9a5362f183fbd672fdcc2cf5bd40083e3bc5b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Feb 2024 01:52:46 -0500
Subject: [PATCH 034/108] gst-plugins-bad1: revbump for ffmpeg6

---
 srcpkgs/gst-plugins-bad1/template | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/gst-plugins-bad1/template b/srcpkgs/gst-plugins-bad1/template
index ac45a5ab80b12b..2a7d0ccf71d7dd 100644
--- a/srcpkgs/gst-plugins-bad1/template
+++ b/srcpkgs/gst-plugins-bad1/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-plugins-bad1'
 pkgname=gst-plugins-bad1
 version=1.24.2
-revision=1
+revision=2
 build_helper="gir"
 build_style=meson
 configure_args="-Dpackage-origin=https://voidlinux.org -Ddoc=disabled
@@ -27,8 +27,7 @@ makedepends="alsa-lib-devel celt-devel openssl-devel exempi-devel
  fdk-aac-devel flite-devel fluidsynth-devel liblrdf-devel ladspa-sdk
  lilv-devel lv2 libopenjpeg2-devel sbc-devel spandsp-devel vulkan-loader
  Vulkan-Headers webrtc-audio-processing-devel libzbar-devel ffmpeg-devel
- srt-devel libva-devel
- $(vopt_if gme libgme-devel)"
+ srt-devel libva-devel $(vopt_if onevpl oneVPL-devel) $(vopt_if gme libgme-devel)"
 depends="gst-plugins-base1>=${version}"
 short_desc="GStreamer plugins from the bad set (v1.x)"
 maintainer="Orphaned <orphan@voidlinux.org>"
@@ -38,7 +37,7 @@ changelog="https://gstreamer.freedesktop.org/releases/${version%.*}/#${version}"
 distfiles="https://gstreamer.freedesktop.org/src/gst-plugins-bad/gst-plugins-bad-${version}.tar.xz"
 checksum=448e32787bc82b586c6cb2f81c9a8ef404fea4f77f25566fe06e597a3f59136b
 
-build_options="gir gme wayland"
+build_options="gir gme onevpl wayland"
 build_options_default="gir wayland"
 desc_option_gme="Build with Game Music Emulator support"
 
@@ -46,6 +45,7 @@ CFLAGS="-fcommon"
 
 case "$XBPS_TARGET_MACHINE" in
 	mips*) ;; # libgme cannot be built for mips*
+	x86_64*) build_options_default+=" gme onevpl" ;; # onevpl only supports 64bit
 	*) build_options_default+=" gme" ;;
 esac
 

From 7004025961be53ea29e3be8a15bed08b4495609f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 035/108] gst-rtsp-server: revbump for ffmpeg6

---
 srcpkgs/gst-rtsp-server/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gst-rtsp-server/template b/srcpkgs/gst-rtsp-server/template
index ab0baf1e7d35ae..dde825fcf7fe12 100644
--- a/srcpkgs/gst-rtsp-server/template
+++ b/srcpkgs/gst-rtsp-server/template
@@ -1,7 +1,7 @@
 # Template file for 'gst-rtsp-server'
 pkgname=gst-rtsp-server
 version=1.24.2
-revision=1
+revision=2
 build_style=meson
 build_helper=gir
 configure_args="-Dintrospection=enabled"

From 752220b98fb48062db5ea11d4e786480194380a7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:47 -0400
Subject: [PATCH 036/108] guvcview: update to 2.0.8.

---
 srcpkgs/guvcview/patches/fix-include.patch | 10 ++++++++++
 srcpkgs/guvcview/template                  |  7 +++----
 2 files changed, 13 insertions(+), 4 deletions(-)
 create mode 100644 srcpkgs/guvcview/patches/fix-include.patch

diff --git a/srcpkgs/guvcview/patches/fix-include.patch b/srcpkgs/guvcview/patches/fix-include.patch
new file mode 100644
index 00000000000000..503c2af3b78c1a
--- /dev/null
+++ b/srcpkgs/guvcview/patches/fix-include.patch
@@ -0,0 +1,10 @@
+--- a/guvcview/guvcview.c
++++ b/guvcview/guvcview.c
+@@ -28,6 +28,7 @@
+ #include <sys/stat.h>
+ #include <sys/resource.h>
+ #include <errno.h>
++#include <locale.h>
+ 
+ #include "gview.h"
+ #include "gviewv4l2core.h"
diff --git a/srcpkgs/guvcview/template b/srcpkgs/guvcview/template
index d42fd38fa4ad12..86a7fd619612c8 100644
--- a/srcpkgs/guvcview/template
+++ b/srcpkgs/guvcview/template
@@ -1,8 +1,7 @@
 # Template file for 'guvcview'
 pkgname=guvcview
-version=2.0.7
-revision=2
-create_wrksrc=yes
+version=2.0.8
+revision=1
 build_style=gnu-configure
 configure_args="--disable-static --disable-debian-menu"
 hostmakedepends="pkg-config intltool autoconf automake libtool glib-devel"
@@ -14,7 +13,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"
 homepage="http://guvcview.sourceforge.net/"
 distfiles="${SOURCEFORGE_SITE}/${pkgname}/${pkgname}-src-${version}.tar.bz2"
-checksum=f47d51fbd06e44eeaa1a82f4a153c927527c90d94514197a70b2956028cc8ad4
+checksum=a21f4e448286666cf27bafef5290cc953a0a1796b752e5bbe521266dc1230c81
 
 post_patch() {
 	sed '31a#include <locale.h>' -i  guvcview/guvcview.c

From b0b8247436f6e37af5e8746f40925a53635e2505 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 037/108] handbrake: update to 1.6.1

---
 .../patches/fix-missing-x265-link-flag.patch    | 11 ++++++-----
 .../handbrake/patches/libhb-vpl-include.patch   | 15 +++++++++++++++
 srcpkgs/handbrake/template                      | 17 ++++++++++-------
 3 files changed, 31 insertions(+), 12 deletions(-)
 create mode 100644 srcpkgs/handbrake/patches/libhb-vpl-include.patch

diff --git a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
index 26db03867a0c83..d6bb2eda627a36 100644
--- a/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
+++ b/srcpkgs/handbrake/patches/fix-missing-x265-link-flag.patch
@@ -1,14 +1,15 @@
 --- a/gtk/configure.ac
 +++ b/gtk/configure.ac
 @@ -203,7 +203,7 @@
- 
+
  AM_CONDITIONAL([MINGW], [test "x$mingw_flag" = "xyes"])
- 
--HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg"
-+HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -ldl"
+
+-HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc"
++HB_LIBS="$HB_LIBS -lhandbrake -lavformat -lavfilter -lavcodec -lavutil -ldav1d -lswresample -lpostproc -ldvdnav -ldvdread -lmp3lame -lvorbis -lvorbisenc -logg -lswscale -ltheoraenc -ltheoradec -lvpx -lz -lbz2 -lbluray -lass -lfontconfig -lfreetype -lxml2 -ljansson -lopus -lspeex -lturbojpeg -llzma -lzimg -lSvtAv1Enc -ldl"
  HB_CPPFLAGS="$HB_CPPFLAGS $HBINC"
- 
+
  PKG_CHECK_MODULES([x264], [x264], sys_x264=yes, sys_x264=no)
+
 --- a/test/module.defs
 +++ b/test/module.defs
 @@ -69,6 +69,9 @@
diff --git a/srcpkgs/handbrake/patches/libhb-vpl-include.patch b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
new file mode 100644
index 00000000000000..298f9f4ab28f2a
--- /dev/null
+++ b/srcpkgs/handbrake/patches/libhb-vpl-include.patch
@@ -0,0 +1,15 @@
+--- a/libhb/module.defs	2023-01-22 11:36:49.000000000 -0500
++++ b/libhb/module.defs	2023-04-03 22:37:52.395467010 -0400
+@@ -46,11 +46,7 @@
+ LIBHB.GCC.I += $(LIBHB.build/) $(CONTRIB.build/)include
+ 
+ ifeq (1,$(FEATURE.qsv))
+-    ifeq ($(HOST.system),freebsd))
+-        LIBHB.GCC.I += $(LOCALBASE)/include/vpl
+-    else
+-        LIBHB.GCC.I += $(CONTRIB.build/)include/vpl
+-    endif
++    LIBHB.GCC.I += /usr/include/vpl
+ endif
+ 
+ ifneq (,$(filter $(HOST.system),freebsd netbsd openbsd))
diff --git a/srcpkgs/handbrake/template b/srcpkgs/handbrake/template
index ca5e4571e49c37..c32cb1bfa31f4b 100644
--- a/srcpkgs/handbrake/template
+++ b/srcpkgs/handbrake/template
@@ -1,10 +1,10 @@
 # Template file for 'handbrake'
 pkgname=handbrake
-version=1.5.1
+version=1.6.1
 revision=1
 build_style=gnu-configure
 configure_args="--force --disable-gtk-update-checks --disable-df-fetch --harden
- $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc)"
+ $(vopt_enable fdk_aac fdk-aac) $(vopt_enable nvenc) $(vopt_enable qsv)"
 make_build_args="-C ${XBPS_TRIPLET}"
 make_install_args="-C ${XBPS_TRIPLET}"
 hostmakedepends="automake cmake gettext-devel glib-devel intltool libtool m4 meson nasm pkg-config python3"
@@ -12,8 +12,11 @@ makedepends="bzip2-devel ffmpeg-devel gst-plugins-base1-devel gtk+3-devel
  jansson-devel lame-devel libass-devel libbluray-devel libdav1d-devel
  libdvdnav-devel libdvdread-devel libgudev-devel libnuma-devel
  libsamplerate-devel libtheora-devel libvorbis-devel libvpx-devel libxml2-devel
- opus-devel speex-devel x264-devel x265-devel zimg-devel
+ opus-devel speex-devel x264-devel x265-devel zimg-devel libsvt-av1-devel
  $(vopt_if fdk_aac fdk-aac-devel)
+ $(vopt_if qsv libva-devel)
+ $(vopt_if qsv libdrm-devel)
+ $(vopt_if qsv onevpl-devel)
  $(vopt_if nvenc nv-codec-headers)"
 depends="desktop-file-utils gst-plugins-good1 hicolor-icon-theme"
 short_desc="Multithreaded video transcoder"
@@ -21,15 +24,15 @@ maintainer="Enno Boland <gottox@voidlinux.org>"
 license="GPL-2.0-only"
 homepage="https://handbrake.fr/"
 distfiles="https://github.com/HandBrake/HandBrake/releases/download/${version}/HandBrake-${version}-source.tar.bz2"
-checksum=3999fe06d5309c819799a73a968a8ec3840e7840c2b64af8f5cdb7fd8c9430f0
+checksum=94ccfe03db917a91650000c510f7fd53f844da19f19ad4b4be1b8f6bc31a8d4c
 nocross=yes
 
-build_options="fdk_aac nvenc"
+build_options="fdk_aac nvenc qsv"
 
 case "$XBPS_TARGET_MACHINE" in
 	x86_64*|i686*)
 		CFLAGS="-msse"
-		build_options_default="nvenc"
+		build_options_default="nvenc qsv"
 		;;
 esac
 
@@ -37,7 +40,7 @@ pre_configure() {
 	# use system libraries, don't download them
 	rm -rf contrib/
 	for module in fdk-aac ffmpeg libbluray libdav1d libdvdnav libdvdread nvenc \
-		x265 zimg; do
+		x265 zimg svt-av1 libvpl; do
 	    vsed -i "/MODULES += contrib\/${module}/d" make/include/main.defs
 	done
 }

From 16940eca63671aebd7f411bd070697c84f497eea Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 038/108] hedgewars: revbump for ffmpeg4

---
 srcpkgs/hedgewars/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/hedgewars/template b/srcpkgs/hedgewars/template
index 94b6db673b0c3a..402ccfaaecbc2d 100644
--- a/srcpkgs/hedgewars/template
+++ b/srcpkgs/hedgewars/template
@@ -1,13 +1,13 @@
 # Template file for 'hedgewars'
 pkgname=hedgewars
 version=1.0.2
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DNOSERVER=1 -DDATA_INSTALL_DIR=/usr/share/${pkgname}
  -DPHYSFS_SYSTEM=1 -DMINIMAL_FLAGS=1"
 make_cmd=make
 hostmakedepends="lua51 pkg-config qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
+makedepends="ffmpeg4-devel lua51-devel physfs-devel qt5-tools-devel SDL2_image-devel
  SDL2_mixer-devel SDL2_net-devel SDL2_ttf-devel"
 depends="libfreeglut"
 short_desc="Funny turn-based artillery game, featuring fighting Hedgehogs!"

From b02d094cc9ce8634e853f9fdf8bc68fa5b5be47c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 039/108] idjc: revbump for ffmpeg4

---
 srcpkgs/idjc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/idjc/template b/srcpkgs/idjc/template
index a9cde0665d55b1..f41e1e4fabbae7 100644
--- a/srcpkgs/idjc/template
+++ b/srcpkgs/idjc/template
@@ -1,11 +1,11 @@
 # Template file for 'idjc'
 pkgname=idjc
 version=0.9.1
-revision=5
+revision=6
 build_style=gnu-configure
 hostmakedepends="pkg-config git python3 automake gettext-devel libtool"
 makedepends="libvorbis-devel libogg-devel jack-devel libsamplerate-devel
- libflac-devel libsndfile-devel mpg123-devel ffmpeg-devel speex-devel
+ libflac-devel libsndfile-devel mpg123-devel ffmpeg4-devel speex-devel
  glib-devel pixman-devel lame-devel python3-gobject-devel libshout-idjc-devel
  opus-devel twolame-devel python3-mutagen python3-devel"
 depends="python3-gobject python3-mutagen desktop-file-utils shared-mime-info python3-dbus jack"

From 62d54aac24fe1fc51bb89796cf335c78659bd67a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 040/108] kid3: revbump for ffmpeg6

---
 srcpkgs/kid3/patches/ffmpeg5.patch | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 srcpkgs/kid3/patches/ffmpeg5.patch

diff --git a/srcpkgs/kid3/patches/ffmpeg5.patch b/srcpkgs/kid3/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..135fc50e07c9ba
--- /dev/null
+++ b/srcpkgs/kid3/patches/ffmpeg5.patch
@@ -0,0 +1,17 @@
+# https://aur.archlinux.org/cgit/aur.git/diff/ffmpeg5.patch?h=kid3-cli&id=12410a74906612e7efc0ec8fbce739b4a0fef7e7
+diff --git a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+index e156d424..e12b9abd 100644
+--- a/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
++++ b/src/plugins/acoustidimport/ffmpegfingerprintdecoder.cpp
+@@ -232,7 +232,11 @@ private:
+   friend class Format;
+   friend class Converter;
+   AVCodecContext* m_ptr;
++#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 0, 0)
+   AVCodec* m_impl;
++#else
++  const AVCodec* m_impl;
++#endif
+   AVFrame* m_frame;
+   bool m_opened;
+ };

From b53c030879fcf2b7abdaf16b2f406f4f7f30d7da Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 041/108] kodi: revbump for ffmpeg4

---
 srcpkgs/kodi/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/kodi/template b/srcpkgs/kodi/template
index d37a5918cd6758..ea78e0aca0fe3e 100644
--- a/srcpkgs/kodi/template
+++ b/srcpkgs/kodi/template
@@ -1,7 +1,7 @@
 # Template file for 'kodi'
 pkgname=kodi
 version=19.4
-revision=9
+revision=10
 _codename="Matrix"
 build_style=cmake
 configure_args="-DWITH_FFMPEG=/usr -DENABLE_LDGOLD=OFF
@@ -54,7 +54,7 @@ makedepends="
  libmad-devel fontconfig-devel libXinerama-devel libsamplerate-devel libmms-devel
  enca-devel boost-devel libcurl-devel libva-devel libvdpau-devel libass-devel
  libbluetooth-devel yajl-devel libplist-devel librtmp-devel tinyxml-devel
- taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg-devel
+ taglib-devel libcap-devel lame-devel libbluray-devel libnfs-devel ffmpeg4-devel
  giflib-devel libxslt-devel gnutls-devel libssh-devel libmicrohttpd-devel
  libcec-devel dcadec-devel flatbuffers-devel fmt-devel lcms2-devel
  libfstrcmp-devel rapidjson libcdio-paranoia spdlog libwaylandpp-devel

From d41cd985a9fa95f9a0e9d1f9ad0099f4159967cb Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 042/108] kpipewire: revbump for ffmpeg6

---
 srcpkgs/kpipewire/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kpipewire/template b/srcpkgs/kpipewire/template
index 24f5f152749c97..d5ac3788ff586a 100644
--- a/srcpkgs/kpipewire/template
+++ b/srcpkgs/kpipewire/template
@@ -1,7 +1,7 @@
 # Template file for 'kpipewire'
 pkgname=kpipewire
 version=5.27.11
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="extra-cmake-modules plasma-wayland-protocols gettext
  qt5-qmake qt5-host-tools pkg-config wayland-devel kcoreaddons

From e72b336fdbb6955f2e5967ff7ce68b94a0e6ddfc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 043/108] libopenal: revbump for ffmpeg6

---
 srcpkgs/libopenal/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenal/template b/srcpkgs/libopenal/template
index 88d0f11307d81a..8308fca0393e33 100644
--- a/srcpkgs/libopenal/template
+++ b/srcpkgs/libopenal/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenal'
 pkgname=libopenal
 version=1.23.1
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DALSOFT_EXAMPLES=OFF"
 hostmakedepends="pkg-config"

From 2c0806061e6aff34ffefc138cba44e964832eb8b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 044/108] loudgain: revbump for ffmpeg6

---
 srcpkgs/loudgain/patches/ffmpeg5.patch | 11 +++++++++++
 srcpkgs/loudgain/template              |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/loudgain/patches/ffmpeg5.patch

diff --git a/srcpkgs/loudgain/patches/ffmpeg5.patch b/srcpkgs/loudgain/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..16d4510ee98faa
--- /dev/null
+++ b/srcpkgs/loudgain/patches/ffmpeg5.patch
@@ -0,0 +1,11 @@
+--- a/src/scan.c	2019-09-06 11:31:19.000000000 -0400
++++ b/src/scan.c	2023-03-23 11:15:40.867968521 -0400
+@@ -69,8 +69,6 @@
+ 	 * It is now useless
+ 	 * https://github.com/FFmpeg/FFmpeg/blob/70d25268c21cbee5f08304da95be1f647c630c15/doc/APIchanges#L86
+ 	 */
+-  if (avformat_version() < AV_VERSION_INT(58,9,100))
+-    av_register_all();
+ 
+ 	av_log_set_callback(scan_av_log);
+ 
diff --git a/srcpkgs/loudgain/template b/srcpkgs/loudgain/template
index da4f2d56e94c3d..4d6bf29efb4fdd 100644
--- a/srcpkgs/loudgain/template
+++ b/srcpkgs/loudgain/template
@@ -1,7 +1,7 @@
 # Template file for 'loudgain'
 pkgname=loudgain
 version=0.6.8
-revision=2
+revision=3
 build_style=cmake
 hostmakedepends="pkg-config"
 makedepends="libebur128-devel taglib-devel ffmpeg-devel"

From 53916a6413153d382319a298786f33fce1e0c8b6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 045/108] mediastreamer: revbump for ffmpeg4

---
 srcpkgs/mediastreamer/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mediastreamer/template b/srcpkgs/mediastreamer/template
index 0fcffa7653d18e..e888626b945e55 100644
--- a/srcpkgs/mediastreamer/template
+++ b/srcpkgs/mediastreamer/template
@@ -1,11 +1,11 @@
 # Template file for 'mediastreamer'
 pkgname=mediastreamer
 version=5.2.111
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DENABLE_STRICT=0 -DENABLE_UNIT_TESTS=0"
 hostmakedepends="python3"
-makedepends="bzrtp-devel ffmpeg-devel glew-devel libXv-devel libsrtp-devel
+makedepends="bzrtp-devel ffmpeg4-devel glew-devel libXv-devel libsrtp-devel
  libupnp-devel libvpx-devel mbedtls-devel opus-devel ortp-devel pulseaudio-devel
  libtheora-devel speex-devel v4l-utils-devel bcg729-devel bcmatroska2-devel libgsm-devel
  zxing-cpp-devel"

From 8f73bbbc1d41bff29f6d481d13ce4af699196e90 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:48 -0400
Subject: [PATCH 046/108] mgba: revbump for ffmpeg6

---
 srcpkgs/mgba/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mgba/template b/srcpkgs/mgba/template
index 6cd65650312543..93401adb618bd8 100644
--- a/srcpkgs/mgba/template
+++ b/srcpkgs/mgba/template
@@ -1,7 +1,7 @@
 # Template file for 'mgba'
 pkgname=mgba
 version=0.10.3
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake desktop-file-utils"
 makedepends="SDL2-devel ffmpeg-devel libedit-devel libepoxy-devel libmagick-devel

From 99623ed2414d2216afbfe1c8a3586a68d5c10327 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 047/108] mlt: revbump for ffmpeg4

---
 srcpkgs/mlt/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/mlt/template b/srcpkgs/mlt/template
index 73e3915aaab9ac..d7ed4c4b30a868 100644
--- a/srcpkgs/mlt/template
+++ b/srcpkgs/mlt/template
@@ -1,14 +1,14 @@
 # Template file for 'mlt'
 pkgname=mlt
 version=6.26.1
-revision=3
+revision=4
 build_style=configure
 configure_args="--prefix=/usr --libdir=/usr/lib$XBPS_TARGET_WORDSIZE
  --enable-gpl --enable-gpl3 --disable-swfdec --without-kde
  --swig-languages=python"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which"
 # XXX: movit vid.stab
-makedepends="alsa-lib-devel ffmpeg-devel gtk+-devel jack-devel ladspa-sdk
+makedepends="alsa-lib-devel ffmpeg4-devel gtk+-devel jack-devel ladspa-sdk
  libexif-devel libsamplerate-devel libxml2-devel sox-devel SDL_image-devel
  fftw-devel frei0r-plugins python3-devel pulseaudio-devel movit-devel
  libvidstab-devel"

From b1b56cb9cf75d47005c2a7c19c13e3381d02024b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 048/108] moc: revbump for ffmpeg4

---
 srcpkgs/moc/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/moc/template b/srcpkgs/moc/template
index 3a04932c8f1e61..838755f88db09e 100644
--- a/srcpkgs/moc/template
+++ b/srcpkgs/moc/template
@@ -1,10 +1,10 @@
 # Template file for 'moc'
 pkgname=moc
 version=2.5.2
-revision=7
+revision=8
 build_style=gnu-configure
 hostmakedepends="pkg-config"
-makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg-devel
+makedepends="db-devel ncurses-devel libcurl-devel popt-devel ffmpeg4-devel
  jack-devel alsa-lib-devel libltdl-devel libflac-devel libvorbis-devel
  libmad-devel libmpcdec-devel libmodplug-devel libid3tag-devel faad2-devel
  taglib-devel libsndfile-devel wavpack-devel speex-devel libsamplerate-devel

From 9b16f9243a2db6ad7060c4f6c10bd895f815d883 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 049/108] motion: revbump for ffmpeg6

---
 srcpkgs/motion/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/motion/template b/srcpkgs/motion/template
index 607ebeb3c7b242..bf63a91d9764f6 100644
--- a/srcpkgs/motion/template
+++ b/srcpkgs/motion/template
@@ -1,7 +1,7 @@
 # Template file for 'motion'
 pkgname=motion
 version=4.6.0
-revision=1
+revision=2
 build_style=gnu-configure
 hostmakedepends="automake pkg-config gettext-devel tar"
 makedepends="ffmpeg-devel libmicrohttpd-devel v4l-utils-devel gettext-devel"

From f01e9f2065f5174527b1f397f339d84493d31480 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:49 -0400
Subject: [PATCH 050/108] olive: revbump for ffmpeg4

---
 srcpkgs/olive/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/olive/template b/srcpkgs/olive/template
index 12a46936c99003..5c2917b9c51245 100644
--- a/srcpkgs/olive/template
+++ b/srcpkgs/olive/template
@@ -1,10 +1,10 @@
 # Template file for 'olive'
 pkgname=olive
 version=0.1.2
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools pkg-config"
-makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg-devel frei0r-plugins"
+makedepends="qt5-devel qt5-multimedia-devel qt5-svg-devel ffmpeg4-devel frei0r-plugins"
 short_desc="Non-linear video editor"
 maintainer="Orphaned <orphan@voidlinux.org>"
 license="GPL-3.0-or-later"

From b83b43a8f3d303068153e50202667995853e33ad Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 051/108] opentoonz: revbump for ffmpeg6

---
 srcpkgs/opentoonz/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/opentoonz/template b/srcpkgs/opentoonz/template
index ee9f7603f55fd8..3e81834ca0eddf 100644
--- a/srcpkgs/opentoonz/template
+++ b/srcpkgs/opentoonz/template
@@ -1,7 +1,7 @@
 # Template file for 'opentoonz'
 pkgname=opentoonz
 version=1.6.0
-revision=2
+revision=3
 build_wrksrc="toonz/sources"
 build_style=cmake
 make_cmd=make

From d98b41b292403db745f85f3057c571d59ca00c12 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 052/108] pianobar: revbump for ffmpeg6

---
 srcpkgs/pianobar/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pianobar/template b/srcpkgs/pianobar/template
index e3febb821a4510..1e3dc1bf9308ee 100644
--- a/srcpkgs/pianobar/template
+++ b/srcpkgs/pianobar/template
@@ -1,7 +1,7 @@
 # Template file for 'pianobar'
 pkgname=pianobar
 version=2022.04.01
-revision=1
+revision=2
 build_style=gnu-makefile
 make_build_args="V=1"
 hostmakedepends="pkg-config"

From 0d88f1d6398269d4807c4181fa3bc4a30cbac585 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 053/108] ppsspp: revbump for ffmpeg6

---
 srcpkgs/ppsspp/patches/ffmpeg6.patch | 15 +++++++++++++++
 srcpkgs/ppsspp/template              |  3 +--
 2 files changed, 16 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/ppsspp/patches/ffmpeg6.patch

diff --git a/srcpkgs/ppsspp/patches/ffmpeg6.patch b/srcpkgs/ppsspp/patches/ffmpeg6.patch
new file mode 100644
index 00000000000000..5803c7bf227309
--- /dev/null
+++ b/srcpkgs/ppsspp/patches/ffmpeg6.patch
@@ -0,0 +1,15 @@
+--- a/Core/HW/SimpleAudioDec.cpp	2024-02-04 08:08:02.000000000 -0500
++++ b/Core/HW/SimpleAudioDec.cpp	2024-02-15 14:48:27.114362051 -0500
+@@ -81,7 +81,11 @@
+ 		return;
+ 	}
+ 	// Find decoder
++#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(58, 18, 100)
+ 	codec_ = avcodec_find_decoder((AVCodecID)audioCodecId);
++#else // this is a macro to const in the header
++	codec_ = (AVCodec*)avcodec_find_decoder((AVCodecID)audioCodecId);
++#endif
+ 	if (!codec_) {
+ 		// Eh, we shouldn't even have managed to compile. But meh.
+ 		ERROR_LOG(ME, "This version of FFMPEG does not support AV_CODEC_ctx for audio (%s). Update your submodule.", GetCodecName(audioType));
+
diff --git a/srcpkgs/ppsspp/template b/srcpkgs/ppsspp/template
index 2238a7601c0af8..1fda55268a2d39 100644
--- a/srcpkgs/ppsspp/template
+++ b/srcpkgs/ppsspp/template
@@ -1,7 +1,7 @@
 # Template file for 'ppsspp'
 pkgname=ppsspp
 version=1.17.1
-revision=1
+revision=2
 _glslang_commit=b34f619e1c85810dcb3c578107d2e48ba4ee2b37
 _SPIRV_Cross_commit=4212eef67ed0ca048cb726a6767185504e7695e5
 _armips_commit=a8d71f0f279eb0d30ecf6af51473b66ae0cf8e8d
@@ -91,7 +91,6 @@ post_configure() {
 }
 
 do_install() {
-	vlicense LICENSE.TXT
 	vinstall icons/icon.svg 644 usr/share/pixmaps ppsspp.svg
 	vinstall Qt/PPSSPP.desktop 644 usr/share/applications
 	vbin build/PPSSPPHeadless ppsspp-headless

From 2077865f9b7dd481f5391e2ab3d44169bd663752 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 054/108] pqiv: revbump for ffmpeg6

---
 srcpkgs/pqiv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pqiv/template b/srcpkgs/pqiv/template
index f9f7751196d4ee..0d50777e56a2d8 100644
--- a/srcpkgs/pqiv/template
+++ b/srcpkgs/pqiv/template
@@ -1,7 +1,7 @@
 # Template file for 'pqiv'
 pkgname=pqiv
 version=2.13.1
-revision=1
+revision=2
 build_style=gnu-makefile
 hostmakedepends="pkg-config"
 makedepends="glib-devel gtk+3-devel $(vopt_if ffmpeg ffmpeg-devel)

From 7eca5d4a740f9cc9767f7a12498fd6636635ab84 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 055/108] qmmp: revbump for ffmpeg6

---
 srcpkgs/qmmp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qmmp/template b/srcpkgs/qmmp/template
index 53781ea3bc28ad..2da07f1e87eac0 100644
--- a/srcpkgs/qmmp/template
+++ b/srcpkgs/qmmp/template
@@ -1,7 +1,7 @@
 # Template file for 'qmmp'
 pkgname=qmmp
 version=1.6.1
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DUSE_HAL:BOOL=FALSE -DQMMP_DEFAULT_UI:STRING=simple"
 hostmakedepends="pkg-config qt5-host-tools qt5-qmake"

From 1c96bcce71b817eaccc22bed052cddc7fc8c1b78 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 14 Dec 2023 13:28:10 -0500
Subject: [PATCH 056/108] qt6-pdf: revbump for ffmpeg6

---
 srcpkgs/qt6-pdf/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-pdf/template b/srcpkgs/qt6-pdf/template
index ecda84afac1310..531b4e1d4fe84d 100644
--- a/srcpkgs/qt6-pdf/template
+++ b/srcpkgs/qt6-pdf/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-pdf'
 pkgname=qt6-pdf
 version=6.6.0
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DQT_FEATURE_qtpdf_build=ON
  -DQT_FEATURE_qtpdf_widgets_build=ON

From a14c2f8c7ff2bb9ff1f84db558005ca6e2f550c7 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:50 -0400
Subject: [PATCH 057/108] qt5-webengine: revbump for ffmpeg6

---
 .../chromium-media-filters-cpp14.patch        |  11 ++
 srcpkgs/qt5-webengine/patches/ffmpeg5.patch   | 179 ++++++++++++++++++
 .../qtwebengine-fix-ffmpeg5-build.patch       |  14 ++
 srcpkgs/qt5-webengine/template                |   4 +-
 4 files changed, 206 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/ffmpeg5.patch
 create mode 100644 srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch

diff --git a/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
new file mode 100644
index 00000000000000..04adc540f2cbc0
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/chromium-media-filters-cpp14.patch
@@ -0,0 +1,11 @@
+--- a/src/3rdparty/chromium/media/filters/BUILD.gn	2023-02-27 13:32:59.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/BUILD.gn	2023-04-02 17:21:39.204066384 -0400
+@@ -96,6 +96,8 @@
+     "//ui/gfx/geometry:geometry",
+   ]
+ 
++  cflags_cc = [ "-std=c++14" ]
++
+   libs = []
+ 
+   if (proprietary_codecs) {
diff --git a/srcpkgs/qt5-webengine/patches/ffmpeg5.patch b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
new file mode 100644
index 00000000000000..ac55e1634423a9
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/ffmpeg5.patch
@@ -0,0 +1,179 @@
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:57.732547446 -0400
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc	2023-04-02 16:50:09.486478995 -0400
+@@ -57,6 +57,8 @@
+ 
+ namespace {
+ 
++constexpr int64_t kRelativeTsBase = static_cast<int64_t>(0x7ffeffffffffffff);
++
+ void SetAVStreamDiscard(AVStream* stream, AVDiscard discard) {
+   DCHECK(stream);
+   stream->discard = discard;
+@@ -90,24 +92,12 @@
+ 
+ static base::TimeDelta ExtractStartTime(AVStream* stream) {
+   // The default start time is zero.
+-  base::TimeDelta start_time;
++  base::TimeDelta start_time = kNoTimestamp;
+ 
+   // First try to use  the |start_time| value as is.
+   if (stream->start_time != kNoFFmpegTimestamp)
+     start_time = ConvertFromTimeBase(stream->time_base, stream->start_time);
+ 
+-  // Next try to use the first DTS value, for codecs where we know PTS == DTS
+-  // (excludes all H26x codecs). The start time must be returned in PTS.
+-  if (stream->first_dts != kNoFFmpegTimestamp &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
+-      stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
+-    const base::TimeDelta first_pts =
+-        ConvertFromTimeBase(stream->time_base, stream->first_dts);
+-    if (first_pts < start_time)
+-      start_time = first_pts;
+-  }
+-
+   return start_time;
+ }
+ 
+@@ -408,11 +398,11 @@
+   scoped_refptr<DecoderBuffer> buffer;
+ 
+   if (type() == DemuxerStream::TEXT) {
+-    int id_size = 0;
++    size_t id_size = 0;
+     uint8_t* id_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
+ 
+-    int settings_size = 0;
++    size_t settings_size = 0;
+     uint8_t* settings_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
+ 
+@@ -424,7 +414,7 @@
+     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
+                                      side_data.data(), side_data.size());
+   } else {
+-    int side_data_size = 0;
++    size_t side_data_size = 0;
+     uint8_t* side_data = av_packet_get_side_data(
+         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
+ 
+@@ -485,7 +475,7 @@
+                                        packet->size - data_offset);
+     }
+ 
+-    int skip_samples_size = 0;
++    size_t skip_samples_size = 0;
+     const uint32_t* skip_samples_ptr =
+         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
+             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
+@@ -1587,6 +1577,8 @@
+   for (const auto& stream : streams_) {
+     if (!stream || stream->IsEnabled() != enabled)
+       continue;
++    if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++      continue;
+     if (!lowest_start_time_stream ||
+         stream->start_time() < lowest_start_time_stream->start_time()) {
+       lowest_start_time_stream = stream.get();
+@@ -1604,6 +1596,8 @@
+     if (stream && stream->type() == DemuxerStream::VIDEO &&
+         stream->IsEnabled()) {
+       video_stream = stream.get();
++      if (stream->av_stream()->start_time == AV_NOPTS_VALUE)
++        continue;
+       if (video_stream->start_time() <= seek_time) {
+         return video_stream;
+       }
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h qtwebengine-5.15.10/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h
+--- a/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h	2022-07-11 22:12:47.917192788 -0500
+@@ -29,6 +29,7 @@ extern "C" {
+ #include <libavformat/avformat.h>
+ #include <libavformat/avio.h>
+ #include <libavutil/avutil.h>
++#include <libavutil/channel_layout.h>
+ #include <libavutil/imgutils.h>
+ #include <libavutil/log.h>
+ #include <libavutil/mastering_display_metadata.h>
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/audio_file_reader.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/audio_file_reader.cc
+--- a/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/audio_file_reader.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -85,7 +85,7 @@ bool AudioFileReader::OpenDemuxer() {
+ }
+ 
+ bool AudioFileReader::OpenDecoder() {
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (codec) {
+     // MP3 decodes to S16P which we don't support, tell it to use S16 instead.
+     if (codec_context_->sample_fmt == AV_SAMPLE_FMT_S16P)
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc	2022-07-11 22:12:47.917192788 -0500
+@@ -329,7 +329,7 @@ bool FFmpegAudioDecoder::ConfigureDecode
+     }
+   }
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec ||
+       avcodec_open2(codec_context_.get(), codec, &codec_options) < 0) {
+     DLOG(ERROR) << "Could not initialize audio decoder: "
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_glue.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -59,7 +59,6 @@ static int64_t AVIOSeekOperation(void* o
+ }
+ 
+ void FFmpegGlue::InitializeFFmpeg() {
+-  av_register_all();
+ }
+ 
+ static void LogContainer(bool is_local_file,
+@@ -95,9 +94,6 @@ FFmpegGlue::FFmpegGlue(FFmpegURLProtocol
+   // Enable fast, but inaccurate seeks for MP3.
+   format_context_->flags |= AVFMT_FLAG_FAST_SEEK;
+ 
+-  // Ensures we can read out various metadata bits like vp8 alpha.
+-  format_context_->flags |= AVFMT_FLAG_KEEP_SIDE_DATA;
+-
+   // Ensures format parsing errors will bail out. From an audit on 11/2017, all
+   // instances were real failures. Solves bugs like http://crbug.com/710791.
+   format_context_->error_recognition |= AV_EF_EXPLODE;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc
+--- a/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -391,7 +391,7 @@ bool FFmpegVideoDecoder::ConfigureDecode
+   if (decode_nalus_)
+     codec_context_->flags2 |= AV_CODEC_FLAG2_CHUNKS;
+ 
+-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
+   if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
+     ReleaseFFmpegResources();
+     return false;
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/media/filters/media_file_checker.cc qtwebengine-5.15.10/src/3rdparty/chromium/media/filters/media_file_checker.cc
+--- a/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/media/filters/media_file_checker.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -68,7 +68,7 @@ bool MediaFileChecker::Start(base::TimeD
+       auto context = AVStreamToAVCodecContext(format_context->streams[i]);
+       if (!context)
+         continue;
+-      AVCodec* codec = avcodec_find_decoder(cp->codec_id);
++      const AVCodec* codec = avcodec_find_decoder(cp->codec_id);
+       if (codec && avcodec_open2(context.get(), codec, nullptr) >= 0) {
+         auto loop = std::make_unique<FFmpegDecodingLoop>(context.get());
+         stream_contexts[i] = {std::move(context), std::move(loop)};
+diff -Naurp qtwebengine-5.15.10.orig/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc qtwebengine-5.15.10/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc
+--- a/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-05-23 06:38:40.000000000 -0500
++++ b/src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc	2022-07-11 22:12:47.918192779 -0500
+@@ -203,7 +203,7 @@ int32_t H264DecoderImpl::InitDecode(cons
+   // a pointer |this|.
+   av_context_->opaque = this;
+ 
+-  AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
++  const AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
+   if (!codec) {
+     // This is an indication that FFmpeg has not been initialized or it has not
+     // been compiled/initialized with the correct set of codecs.
diff --git a/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch b/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch
new file mode 100644
index 00000000000000..bc24d5b9a29cb5
--- /dev/null
+++ b/srcpkgs/qt5-webengine/patches/qtwebengine-fix-ffmpeg5-build.patch
@@ -0,0 +1,14 @@
+--- a/src/buildtools/configure.json	2023-12-09 11:06:01.503058569 -0500
++++ b/src/buildtools/configure.json	2023-12-09 11:06:14.982361345 -0500
+@@ -779,11 +779,6 @@
+             "type": "warning",
+             "condition": "config.ios && config.simulator && config.device && features.build-qtpdf",
+             "message": "Building fat libray with device and simulator architectures will disable NEON."
+-        },
+-        {
+-            "type": "fatal",
+-            "condition": "features.webengine-system-ffmpeg && !libs.webengine-ffmpeg-support",
+-            "message": "Unmodified ffmpeg >= 5.0 is not supported. Please configure with -qt-webengine-ffmpeg."
+         }
+     ],
+     "summary": [
diff --git a/srcpkgs/qt5-webengine/template b/srcpkgs/qt5-webengine/template
index 3c0f5bda69c7ee..df6e441747cc43 100644
--- a/srcpkgs/qt5-webengine/template
+++ b/srcpkgs/qt5-webengine/template
@@ -1,14 +1,14 @@
 # Template file for 'qt5-webengine'
 pkgname=qt5-webengine
 version=5.15.16
-revision=1
+revision=2
 _version="${version}-lts"
 _chromium_commit=207c2ac45ca3386d153770c6b0d2ea2ec21ca880
 archs="x86_64* i686* armv[67]* ppc64* aarch64*"
 create_wrksrc=yes
 build_style=qmake
 configure_args="--
- -webengine-icu -webengine-ffmpeg -webengine-opus -webengine-webp
+ -webengine-icu -system-ffmpeg -webengine-opus -webengine-webp
  -webengine-pepper-plugins -webengine-printing-and-pdf -webengine-proprietary-codecs
  -webengine-pulseaudio -webengine-spellchecker -webengine-webrtc -webengine-geolocation
  -webengine-kerberos -no-webengine-embedded-build $(vopt_if sndio '' '-no')-webengine-sndio

From 70b17842974f7dd04c778bc96495acbd8e73c2f4 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 058/108] qt5: revbump for ffmpeg6

---
 srcpkgs/qt5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5/template b/srcpkgs/qt5/template
index 0f8203e899c63f..e57e1593445204 100644
--- a/srcpkgs/qt5/template
+++ b/srcpkgs/qt5/template
@@ -3,7 +3,7 @@
 # revbump libqtxdg after bumping patch version
 pkgname=qt5
 version=5.15.11+20231124
-revision=3
+revision=4
 # commit 4765fa1df7a837db9c1f89c4da0dd76b74bb5fab
 # base repo: https://invent.kde.org/qt/qt/qt5
 build_style=meta

From 533fdfab9efcd2e95931fd25de819a6468e07c72 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 059/108] qtav: revbump for ffmpeg4

---
 srcpkgs/qtav/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtav/template b/srcpkgs/qtav/template
index 775d5a139a9efa..aa69e213c984b0 100644
--- a/srcpkgs/qtav/template
+++ b/srcpkgs/qtav/template
@@ -1,10 +1,10 @@
 # Template file for 'qtav'
 pkgname=qtav
 version=1.13.0
-revision=2
+revision=3
 build_style=qmake
 hostmakedepends="qt5-qmake qt5-host-tools"
-makedepends="ffmpeg-devel libass-devel libopenal-devel
+makedepends="ffmpeg4-devel libass-devel libopenal-devel
  libva-glx-devel libXv-devel pulseaudio-devel
  qt5-declarative-devel qt5-svg-devel
  qt5-quickcontrols"

From 2b4cf44b641194de2abb57aad1f5d8996ae52bfd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 060/108] retroarch: revbump for ffmpeg6

---
 srcpkgs/retroarch/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/retroarch/template b/srcpkgs/retroarch/template
index cb3125c5dbf1ae..c65c26f7bf0332 100644
--- a/srcpkgs/retroarch/template
+++ b/srcpkgs/retroarch/template
@@ -1,7 +1,7 @@
 # Template file for 'retroarch'
 pkgname=retroarch
 version=1.16.0.3
-revision=3
+revision=4
 build_style=configure
 configure_args="--prefix=/usr --sysconfdir=/etc --enable-networking
  --enable-udev --disable-builtinflac --disable-builtinglslang

From c18b329c93a374b976d0d15cd179536301f1d178 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 061/108] scrcpy: revbump for ffmpeg6

---
 srcpkgs/scrcpy/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/scrcpy/template b/srcpkgs/scrcpy/template
index d40651ad8dc835..3ec7139be5c0c5 100644
--- a/srcpkgs/scrcpy/template
+++ b/srcpkgs/scrcpy/template
@@ -1,7 +1,7 @@
 # Template file for 'scrcpy'
 pkgname=scrcpy
 version=2.4
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcompile_server=false
  -Dprebuilt_server=/usr/share/scrcpy/scrcpy-server-v${version}"

From 0ee3c3c5647d6334dd12c9cc0d33e87e26507411 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 17 Oct 2023 08:54:11 -0400
Subject: [PATCH 062/108] New package: spex-x replaces spek-alternative for
 ffmpeg6

---
 srcpkgs/spek-alternative                      |  1 +
 srcpkgs/spek-x/patches/musl.patch             |  7 ++++++
 srcpkgs/{spek-alternative => spek-x}/template | 22 ++++++++++++-------
 3 files changed, 22 insertions(+), 8 deletions(-)
 create mode 120000 srcpkgs/spek-alternative
 create mode 100644 srcpkgs/spek-x/patches/musl.patch
 rename srcpkgs/{spek-alternative => spek-x}/template (52%)

diff --git a/srcpkgs/spek-alternative b/srcpkgs/spek-alternative
new file mode 120000
index 00000000000000..76648236da7017
--- /dev/null
+++ b/srcpkgs/spek-alternative
@@ -0,0 +1 @@
+spek-x
\ No newline at end of file
diff --git a/srcpkgs/spek-x/patches/musl.patch b/srcpkgs/spek-x/patches/musl.patch
new file mode 100644
index 00000000000000..662f45936febc6
--- /dev/null
+++ b/srcpkgs/spek-x/patches/musl.patch
@@ -0,0 +1,7 @@
+--- a/tests/perf.cc	2024-03-09 17:13:49.086603418 -0500
++++ b/tests/perf.cc	2024-03-09 17:13:59.453603753 -0500
+@@ -1,3 +1,4 @@
++#include <cstdint>
+ #include <cstdlib>
+ #include <iostream>
+ #include <fstream>
diff --git a/srcpkgs/spek-alternative/template b/srcpkgs/spek-x/template
similarity index 52%
rename from srcpkgs/spek-alternative/template
rename to srcpkgs/spek-x/template
index d7b55c776b1d43..3ded6c2c323e4f 100644
--- a/srcpkgs/spek-alternative/template
+++ b/srcpkgs/spek-x/template
@@ -1,18 +1,18 @@
-# Template file for 'spek-alternative'
-pkgname=spek-alternative
-version=0.8.2.3
-revision=2
+# Template file for 'spek-x'
+pkgname=spek-x
+version=0.9.3
+revision=1
 build_style=gnu-configure
 hostmakedepends="automake gettext-devel intltool libtool pkg-config
  wxWidgets-common wxWidgets-gtk3-devel"
 makedepends="ffmpeg-devel wxWidgets-gtk3-devel"
 depends="ffmpeg"
 short_desc="Acoustic spectrum analyser"
-maintainer="Kartik Singh <kartik.ynwa@gmail.com>"
+maintainer="zlice <zlice555@gmail.com>"
 license="GPL-3.0-or-later"
-homepage="https://github.com/withmorten/spek-alternative"
-distfiles="https://github.com/withmorten/spek-alternative/archive/${version}.tar.gz"
-checksum="007ba4b84a310b078e378aa84c8e80783db5821437a757a488c3ecec377e6b2a"
+homepage="https://github.com/MikeWang000000/spek-x"
+distfiles="https://github.com/MikeWang000000/spek-x/archive/v${version}.tar.gz"
+checksum="7f4b109903333cdd310ab2b9176f0dc49a565891376e281a233d342cedf90ef7"
 
 CXXFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
 
@@ -22,3 +22,9 @@ export WX_CONFIG_NAME="wx-config-gtk3"
 pre_configure() {
 	NOCONFIGURE=1 ./autogen.sh
 }
+
+spek-alternative_package() {
+	depends="spek-x"
+	short_desc+=" - transitional dummy package"
+	build_style=meta
+}

From fc2afd861d557193e06f234732d0bc8d42a4a0ba Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:51 -0400
Subject: [PATCH 063/108] ssr: revbump for ffmpeg6

---
 .../0001-Fix-build-with-ffmpeg-5.0.patch      | 241 ++++++++++++++++++
 srcpkgs/ssr/template                          |   2 +-
 2 files changed, 242 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/ssr/patches/0001-Fix-build-with-ffmpeg-5.0.patch

diff --git a/srcpkgs/ssr/patches/0001-Fix-build-with-ffmpeg-5.0.patch b/srcpkgs/ssr/patches/0001-Fix-build-with-ffmpeg-5.0.patch
new file mode 100644
index 00000000000000..4c069b5a9fc464
--- /dev/null
+++ b/srcpkgs/ssr/patches/0001-Fix-build-with-ffmpeg-5.0.patch
@@ -0,0 +1,241 @@
+From f4cbde38021d9330dc73d2e3dfa8a70da3ff5721 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Bernhard=20Rosenkr=C3=A4nzer?= <bero@lindev.ch>
+Date: Sun, 16 Jan 2022 02:40:04 +0100
+Subject: [PATCH] Fix build with ffmpeg 5.0
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Adapt to ffmpeg 5.0 requiring more const-ness for AVCodec.
+
+Signed-off-by: Bernhard Rosenkränzer <bero@lindev.ch>
+---
+ src/AV/Output/AudioEncoder.cpp |  6 +++---
+ src/AV/Output/AudioEncoder.h   |  4 ++--
+ src/AV/Output/BaseEncoder.cpp  |  4 ++--
+ src/AV/Output/BaseEncoder.h    |  4 ++--
+ src/AV/Output/Muxer.cpp        | 12 ++++++------
+ src/AV/Output/Muxer.h          |  4 ++--
+ src/AV/Output/VideoEncoder.cpp |  6 +++---
+ src/AV/Output/VideoEncoder.h   |  4 ++--
+ 8 files changed, 22 insertions(+), 22 deletions(-)
+
+diff --git a/src/AV/Output/AudioEncoder.cpp b/src/AV/Output/AudioEncoder.cpp
+index 34d015c..cefc2e0 100644
+--- a/src/AV/Output/AudioEncoder.cpp
++++ b/src/AV/Output/AudioEncoder.cpp
+@@ -34,7 +34,7 @@ const std::vector<AudioEncoder::SampleFormatData> AudioEncoder::SUPPORTED_SAMPLE
+ 
+ const unsigned int AudioEncoder::DEFAULT_FRAME_SAMPLES = 1024;
+ 
+-AudioEncoder::AudioEncoder(Muxer* muxer, AVStream* stream, AVCodecContext *codec_context, AVCodec* codec, AVDictionary** options)
++AudioEncoder::AudioEncoder(Muxer* muxer, AVStream* stream, AVCodecContext *codec_context, const AVCodec* codec, AVDictionary** options)
+ 	: BaseEncoder(muxer, stream, codec_context, codec, options) {
+ 
+ #if !SSR_USE_AVCODEC_ENCODE_AUDIO2
+@@ -77,7 +77,7 @@ unsigned int AudioEncoder::GetSampleRate() {
+ }
+ 
+ bool AudioEncoder::AVCodecIsSupported(const QString& codec_name) {
+-	AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
++	const AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
+ 	if(codec == NULL)
+ 		return false;
+ 	if(!av_codec_is_encoder(codec))
+@@ -93,7 +93,7 @@ bool AudioEncoder::AVCodecIsSupported(const QString& codec_name) {
+ 	return false;
+ }
+ 
+-void AudioEncoder::PrepareStream(AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
++void AudioEncoder::PrepareStream(AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
+ 								 unsigned int bit_rate, unsigned int channels, unsigned int sample_rate) {
+ 
+ 	if(channels == 0) {
+diff --git a/src/AV/Output/AudioEncoder.h b/src/AV/Output/AudioEncoder.h
+index c93278c..ae9c82e 100644
+--- a/src/AV/Output/AudioEncoder.h
++++ b/src/AV/Output/AudioEncoder.h
+@@ -40,7 +40,7 @@ private:
+ #endif
+ 
+ public:
+-	AudioEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options);
++	AudioEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options);
+ 	~AudioEncoder();
+ 
+ 	// Returns the required frame size, i.e. the number of samples (for each channel).
+@@ -57,7 +57,7 @@ public:
+ 
+ public:
+ 	static bool AVCodecIsSupported(const QString& codec_name);
+-	static void PrepareStream(AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
++	static void PrepareStream(AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
+ 							  unsigned int bit_rate, unsigned int channels, unsigned int sample_rate);
+ 
+ private:
+diff --git a/src/AV/Output/BaseEncoder.cpp b/src/AV/Output/BaseEncoder.cpp
+index 7c01ef3..4780aaf 100644
+--- a/src/AV/Output/BaseEncoder.cpp
++++ b/src/AV/Output/BaseEncoder.cpp
+@@ -42,7 +42,7 @@ double ParseCodecOptionDouble(const QString& key, const QString& value, double m
+ 	return clamp(value_double, min, max) * multiply;
+ }
+ 
+-BaseEncoder::BaseEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options) {
++BaseEncoder::BaseEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options) {
+ 
+ 	m_muxer = muxer;
+ 	m_stream = stream;
+@@ -157,7 +157,7 @@ void BaseEncoder::IncrementPacketCounter() {
+ 	++lock->m_total_packets;
+ }
+ 
+-void BaseEncoder::Init(AVCodec* codec, AVDictionary** options) {
++void BaseEncoder::Init(const AVCodec* codec, AVDictionary** options) {
+ 
+ 	// open codec
+ 	if(avcodec_open2(m_codec_context, codec, options) < 0) {
+diff --git a/src/AV/Output/BaseEncoder.h b/src/AV/Output/BaseEncoder.h
+index 3d92f29..7f02bbd 100644
+--- a/src/AV/Output/BaseEncoder.h
++++ b/src/AV/Output/BaseEncoder.h
+@@ -51,7 +51,7 @@ private:
+ 	std::atomic<bool> m_should_stop, m_should_finish, m_is_done, m_error_occurred;
+ 
+ protected:
+-	BaseEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options);
++	BaseEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options);
+ 
+ public:
+ 	virtual ~BaseEncoder(); // encoders will be deleted by Muxer, don't delete them yourself!
+@@ -117,7 +117,7 @@ protected:
+ 	void IncrementPacketCounter();
+ 
+ private:
+-	void Init(AVCodec* codec, AVDictionary** options);
++	void Init(const AVCodec* codec, AVDictionary** options);
+ 	void Free();
+ 
+ 	void EncoderThread();
+diff --git a/src/AV/Output/Muxer.cpp b/src/AV/Output/Muxer.cpp
+index ad58380..14650b0 100644
+--- a/src/AV/Output/Muxer.cpp
++++ b/src/AV/Output/Muxer.cpp
+@@ -87,7 +87,7 @@ Muxer::~Muxer() {
+ 
+ VideoEncoder* Muxer::AddVideoEncoder(const QString& codec_name, const std::vector<std::pair<QString, QString> >& codec_options,
+ 									 unsigned int bit_rate, unsigned int width, unsigned int height, unsigned int frame_rate) {
+-	AVCodec *codec = FindCodec(codec_name);
++	const AVCodec *codec = FindCodec(codec_name);
+ 	AVCodecContext *codec_context = NULL;
+ 	AVStream *stream = AddStream(codec, &codec_context);
+ 	VideoEncoder *encoder;
+@@ -111,7 +111,7 @@ VideoEncoder* Muxer::AddVideoEncoder(const QString& codec_name, const std::vecto
+ 
+ AudioEncoder* Muxer::AddAudioEncoder(const QString& codec_name, const std::vector<std::pair<QString, QString> >& codec_options,
+ 									 unsigned int bit_rate, unsigned int channels, unsigned int sample_rate) {
+-	AVCodec *codec = FindCodec(codec_name);
++	const AVCodec *codec = FindCodec(codec_name);
+ 	AVCodecContext *codec_context = NULL;
+ 	AVStream *stream = AddStream(codec, &codec_context);
+ 	AudioEncoder *encoder;
+@@ -194,7 +194,7 @@ unsigned int Muxer::GetQueuedPacketCount(unsigned int stream_index) {
+ void Muxer::Init() {
+ 
+ 	// get the format we want (this is just a pointer, we don't have to free this)
+-	AVOutputFormat *format = av_guess_format(m_container_name.toUtf8().constData(), NULL, NULL);
++	const AVOutputFormat *format = av_guess_format(m_container_name.toUtf8().constData(), NULL, NULL);
+ 	if(format == NULL) {
+ 		Logger::LogError("[Muxer::Init] " + Logger::tr("Error: Can't find chosen output format!"));
+ 		throw LibavException();
+@@ -261,8 +261,8 @@ void Muxer::Free() {
+ 	}
+ }
+ 
+-AVCodec* Muxer::FindCodec(const QString& codec_name) {
+-	AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
++const AVCodec* Muxer::FindCodec(const QString& codec_name) {
++	const AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
+ 	if(codec == NULL) {
+ 		Logger::LogError("[Muxer::FindCodec] " + Logger::tr("Error: Can't find codec!"));
+ 		throw LibavException();
+@@ -270,7 +270,7 @@ AVCodec* Muxer::FindCodec(const QString& codec_name) {
+ 	return codec;
+ }
+ 
+-AVStream* Muxer::AddStream(AVCodec* codec, AVCodecContext** codec_context) {
++AVStream* Muxer::AddStream(const AVCodec* codec, AVCodecContext** codec_context) {
+ 	assert(!m_started);
+ 	assert(m_format_context->nb_streams < MUXER_MAX_STREAMS);
+ 
+diff --git a/src/AV/Output/Muxer.h b/src/AV/Output/Muxer.h
+index d72347d..b104bcb 100644
+--- a/src/AV/Output/Muxer.h
++++ b/src/AV/Output/Muxer.h
+@@ -114,8 +114,8 @@ private:
+ 	void Init();
+ 	void Free();
+ 
+-	AVCodec* FindCodec(const QString& codec_name);
+-	AVStream* AddStream(AVCodec* codec, AVCodecContext** codec_context);
++	const AVCodec* FindCodec(const QString& codec_name);
++	AVStream* AddStream(const AVCodec* codec, AVCodecContext** codec_context);
+ 
+ 	void MuxerThread();
+ 
+diff --git a/src/AV/Output/VideoEncoder.cpp b/src/AV/Output/VideoEncoder.cpp
+index 8087e8e..fc8b5d1 100644
+--- a/src/AV/Output/VideoEncoder.cpp
++++ b/src/AV/Output/VideoEncoder.cpp
+@@ -34,7 +34,7 @@ const std::vector<VideoEncoder::PixelFormatData> VideoEncoder::SUPPORTED_PIXEL_F
+ 	{"rgb", AV_PIX_FMT_RGB24, false},
+ };
+ 
+-VideoEncoder::VideoEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options)
++VideoEncoder::VideoEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options)
+ 	: BaseEncoder(muxer, stream, codec_context, codec, options) {
+ 
+ #if !SSR_USE_AVCODEC_ENCODE_VIDEO2
+@@ -95,7 +95,7 @@ unsigned int VideoEncoder::GetFrameRate() {
+ }
+ 
+ bool VideoEncoder::AVCodecIsSupported(const QString& codec_name) {
+-	AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
++	const AVCodec *codec = avcodec_find_encoder_by_name(codec_name.toUtf8().constData());
+ 	if(codec == NULL)
+ 		return false;
+ 	if(!av_codec_is_encoder(codec))
+@@ -111,7 +111,7 @@ bool VideoEncoder::AVCodecIsSupported(const QString& codec_name) {
+ 	return false;
+ }
+ 
+-void VideoEncoder::PrepareStream(AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
++void VideoEncoder::PrepareStream(AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
+ 								 unsigned int bit_rate, unsigned int width, unsigned int height, unsigned int frame_rate) {
+ 
+ 	if(width == 0 || height == 0) {
+diff --git a/src/AV/Output/VideoEncoder.h b/src/AV/Output/VideoEncoder.h
+index cb7ca27..68d872e 100644
+--- a/src/AV/Output/VideoEncoder.h
++++ b/src/AV/Output/VideoEncoder.h
+@@ -40,7 +40,7 @@ private:
+ #endif
+ 
+ public:
+-	VideoEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options);
++	VideoEncoder(Muxer* muxer, AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options);
+ 	~VideoEncoder();
+ 
+ 	// Returns the required pixel format.
+@@ -55,7 +55,7 @@ public:
+ 
+ public:
+ 	static bool AVCodecIsSupported(const QString& codec_name);
+-	static void PrepareStream(AVStream* stream, AVCodecContext* codec_context, AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
++	static void PrepareStream(AVStream* stream, AVCodecContext* codec_context, const AVCodec* codec, AVDictionary** options, const std::vector<std::pair<QString, QString> >& codec_options,
+ 							  unsigned int bit_rate, unsigned int width, unsigned int height, unsigned int frame_rate);
+ 
+ private:
+-- 
+2.43.0
+
diff --git a/srcpkgs/ssr/template b/srcpkgs/ssr/template
index 3097754e3cbe54..e3c4261f1f5a64 100644
--- a/srcpkgs/ssr/template
+++ b/srcpkgs/ssr/template
@@ -1,7 +1,7 @@
 # Template file for 'ssr'
 pkgname=ssr
 version=0.4.4
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DWITH_QT5=ON"
 hostmakedepends="pkg-config"

From 0f8025cf0887037df46dcab73d9ff474b6bd4054 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 064/108] synfig: revbump for ffmpeg6 and mlt7

---
 srcpkgs/synfig/patches/ffmpeg6.patch | 71 ++++++++++++++++++++++++++++
 srcpkgs/synfig/template              |  6 +--
 2 files changed, 74 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/synfig/patches/ffmpeg6.patch

diff --git a/srcpkgs/synfig/patches/ffmpeg6.patch b/srcpkgs/synfig/patches/ffmpeg6.patch
new file mode 100644
index 00000000000000..10780b42782f4b
--- /dev/null
+++ b/srcpkgs/synfig/patches/ffmpeg6.patch
@@ -0,0 +1,71 @@
+--- a/src/modules/mod_libavcodec/trgt_av.cpp	2022-10-25 09:14:12.000000000 -0400
++++ b/src/modules/mod_libavcodec/trgt_av.cpp	2023-05-05 21:34:17.899194559 -0400
+@@ -38,6 +41,7 @@
+ extern "C"
+ {
+ #ifdef HAVE_LIBAVFORMAT_AVFORMAT_H
++#	include <libavcodec/avcodec.h>
+ #	include <libavformat/avformat.h>
+ #elif defined(HAVE_AVFORMAT_H)
+ #	include <avformat.h>
+@@ -155,11 +156,11 @@
+     }
+ 
+ 	bool open_video_stream() {
+-		if (avcodec_open2(video_context, NULL, NULL) < 0) {
++		if (avcodec_open2(video_context, nullptr, nullptr) < 0) {
+ 			synfig::error("Target_LibAVCodec: could not open video codec");
+ 			// seems the calling of avcodec_free_context after error will cause crash
+ 			// so just forget about this context
+-			video_context = NULL;
++			video_context = nullptr;
+ 			close();
+ 			return false;
+         }
+@@ -234,15 +235,21 @@
+ 		close();
+ 
+ 		if (!av_registered) {
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 			av_register_all();
++#endif
+ 			av_registered = true;
+ 		}
+ 
+ 		// guess format
+-		AVOutputFormat *format = av_guess_format(NULL, filename.c_str(), NULL);
++#if LIBAVCODEC_VERSION_MAJOR < 59 // FFMPEG < 5.0
++		AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#else
++		const AVOutputFormat* format = av_guess_format(nullptr, filename.c_str(), nullptr);
++#endif
+ 		if (!format) {
+ 			synfig::warning("Target_LibAVCodec: unable to guess the output format, defaulting to MPEG");
+-			format = av_guess_format("mpeg", NULL, NULL);
++			format = av_guess_format("mpeg", nullptr, nullptr);
+ 		}
+ 		if (!format) {
+ 			synfig::error("Target_LibAVCodec: unable to find 'mpeg' output format");
+@@ -254,6 +261,7 @@
+ 		context = avformat_alloc_context();
+ 		assert(context);
+ 		context->oformat = format;
++#if LIBAVCODEC_VERSION_MAJOR < 58 // FFMPEG < 4.0
+ 		if (filename.size() + 1 > sizeof(context->filename)) {
+ 			synfig::error(
+ 				"Target_LibAVCodec: filename too long, max length is %d, filename is '%s'",
+@@ -263,6 +271,14 @@
+ 			return false;
+ 		}
+ 		memcpy(context->filename, filename.c_str(), filename.size() + 1);
++#else
++		context->url = av_strndup(filename.c_str(), filename.size());
++		if (!context->url) {
++			synfig::error("Target_LibAVCodec: cannot allocate space for filename");
++			close();
++			return false;
++		}
++#endif
+ 
+ 		packet = av_packet_alloc();
+ 		assert(packet);
diff --git a/srcpkgs/synfig/template b/srcpkgs/synfig/template
index d4d3e341a20bf8..828b5cb32956ee 100644
--- a/srcpkgs/synfig/template
+++ b/srcpkgs/synfig/template
@@ -2,11 +2,11 @@
 # Should be kept in sync with 'synfigstudio' and 'ETL'
 pkgname=synfig
 version=1.4.4
-revision=4
+revision=5
 build_style=gnu-configure
 configure_args="--with-boost-libdir=${XBPS_CROSS_BASE}/usr/lib"
 hostmakedepends="boost-build ImageMagick pkg-config intltool"
-makedepends="ETL gettext-devel libxml++-devel mlt-devel libmagick-devel
+makedepends="ETL gettext-devel libxml++-devel mlt7-devel libmagick-devel
  libmng-devel boost-build boost-devel libopenexr-devel ffmpeg-devel"
 depends="ImageMagick"
 short_desc="CLI 2D vector and timeline-based animation software"
@@ -20,7 +20,7 @@ CXXFLAGS="-std=c++11 -DHAVE_LOCALE_H=1"
 
 synfig-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision}
-	 libopenexr-devel libxml++-devel mlt-devel"
+	 libopenexr-devel libxml++-devel mlt7-devel"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/bin/synfig-config

From f7639293929b28f4b0d75c05be5c9dae76a3d062 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 065/108] timg: revbump for ffmpeg6

---
 srcpkgs/timg/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/timg/template b/srcpkgs/timg/template
index 2a2ab763d2fddf..8fb4327535ef93 100644
--- a/srcpkgs/timg/template
+++ b/srcpkgs/timg/template
@@ -1,7 +1,7 @@
 # Template file for 'timg'
 pkgname=timg
 version=1.4.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DWITH_OPENSLIDE_SUPPORT=off -Wno-dev"
 hostmakedepends="pkg-config git"

From 7b4c3a7b5b7e23561b276ae2872d0ecb3e1a627e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 066/108] tvheadend: revbump for ffmpeg4

---
 srcpkgs/tvheadend/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tvheadend/template b/srcpkgs/tvheadend/template
index 9aea7de4ec7057..012d31c4879ff1 100644
--- a/srcpkgs/tvheadend/template
+++ b/srcpkgs/tvheadend/template
@@ -8,7 +8,7 @@ configure_args="--enable-dvbscan --disable-ffmpeg_static
 --disable-libx265_static --disable-libvpx_static --disable-libtheora_static
 --disable-libvorbis_static --disable-libfdkaac_static"
 hostmakedepends="gettext pkg-config python3 git which"
-makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg-devel"
+makedepends="avahi-libs-devel openssl-devel zlib-devel libcurl-devel ffmpeg4-devel"
 short_desc="TV streaming server"
 maintainer="lemmi <lemmi@nerd2nerd.org>"
 license="GPL-3.0-only"

From b72082bf013bbd36881a36e515d9456bfddac7b8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 067/108] unpaper: update to 7.0.0.

---
 srcpkgs/unpaper/template | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/srcpkgs/unpaper/template b/srcpkgs/unpaper/template
index 38ed47a5840165..1ff910e722afc8 100644
--- a/srcpkgs/unpaper/template
+++ b/srcpkgs/unpaper/template
@@ -1,13 +1,13 @@
 # Template file for 'unpaper'
 pkgname=unpaper
-version=6.1
-revision=3
-build_style=gnu-configure
+version=7.0.0
+revision=1
+build_style=meson
+hostmakedepends="pkg-config meson libxslt"
+makedepends="ffmpeg-devel python3-Sphinx"
+short_desc="Post-processing tool for scanned sheets of paper"
 maintainer="Orphaned <orphan@voidlinux.org>"
-hostmakedepends="pkg-config libxslt"
-makedepends="ffmpeg-devel"
-license="GPL-2"
+license="GPL-2.0-or-later"
 homepage="https://www.flameeyes.eu/projects/unpaper"
-short_desc="A post-processing tool for scanned sheets of paper"
 distfiles="https://www.flameeyes.eu/files/${pkgname}-${version}.tar.xz"
-checksum=237c84f5da544b3f7709827f9f12c37c346cdf029b1128fb4633f9bafa5cb930
+checksum=2575fbbf26c22719d1cb882b59602c9900c7f747118ac130883f63419be46a80

From d136bd2606930d0a9d1942c2f0b171c4870a2ec9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 068/108] vice: revbump for ffmpeg4

---
 srcpkgs/vice/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vice/template b/srcpkgs/vice/template
index 1c641d9ae9be22..4f43e85b5b8972 100644
--- a/srcpkgs/vice/template
+++ b/srcpkgs/vice/template
@@ -1,7 +1,7 @@
 # Template file for 'vice'
 pkgname=vice
 version=3.8
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--enable-cpuhistory --enable-x64 --disable-pdf-docs
  --libdir=/usr/lib$XBPS_TARGET_WORDSIZE $(vopt_enable sdl2 sdlui2)

From 124cd89455a364dd40d295950fb84756afd5974d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 069/108] waypipe: revbump for ffmpeg6

---
 srcpkgs/waypipe/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/waypipe/template b/srcpkgs/waypipe/template
index 6da88b21bf2a19..4da8058400b588 100644
--- a/srcpkgs/waypipe/template
+++ b/srcpkgs/waypipe/template
@@ -1,7 +1,7 @@
 # Template file for 'waypipe'
 pkgname=waypipe
 version=0.8.6
-revision=1
+revision=2
 build_style=meson
 # lto is off because it causes linking errors in armv6l and armv7l (due to NEON)
 configure_args="-Dwerror=false -Dwith_dmabuf=enabled -Dwith_lz4=enabled

From 52f8034884d29cfb14aaeeb13f1e779dbfe491c9 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 22 Mar 2023 20:01:52 -0400
Subject: [PATCH 070/108] xpra: revbump for ffmpeg6

---
 srcpkgs/xpra/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/xpra/template b/srcpkgs/xpra/template
index cc264b4ebd604c..ad53a093f09014 100644
--- a/srcpkgs/xpra/template
+++ b/srcpkgs/xpra/template
@@ -1,7 +1,7 @@
 # Template file for 'xpra'
 pkgname=xpra
 version=5.0.8
-revision=1
+revision=2
 build_style=python3-module
 make_build_args="--without-cuda_kernels --without-cuda_rebuild"
 make_install_args="$(vopt_with docs) ${make_build_args}"

From c5ebac61bd974a3d4c9d0d928a82f8fbedaca483 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:07:40 -0400
Subject: [PATCH 071/108] nv-codec-headers: update to 12.0.16.0

---
 srcpkgs/nv-codec-headers/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/nv-codec-headers/template b/srcpkgs/nv-codec-headers/template
index 3d422a61e48917..251e057f826fb8 100644
--- a/srcpkgs/nv-codec-headers/template
+++ b/srcpkgs/nv-codec-headers/template
@@ -1,6 +1,6 @@
 # Template file for 'nv-codec-headers'
 pkgname=nv-codec-headers
-version=11.1.5.1
+version=12.0.16.0
 revision=1
 build_style=gnu-makefile
 short_desc="FFmpeg version of headers required to interface with Nvidias codec APIs"
@@ -8,7 +8,7 @@ maintainer="Orphaned <orphan@voidlinux.org>"
 license="MIT"
 homepage="http://git.videolan.org/?p=ffmpeg/nv-codec-headers.git"
 distfiles="https://github.com/FFmpeg/nv-codec-headers/archive/n${version}.tar.gz"
-checksum=d095fbd56aa93772471a323be0ebe65504a0f43f06c76a30b6d25da77b06ae9c
+checksum=2a1533b65f55f9da52956faf0627ed3b74868ac0c7f269990edd21369113b48f
 
 post_install() {
 	sed -n '4,25p' include/ffnvcodec/nvEncodeAPI.h > LICENSE

From a08bdde1fbaf95b656ddcf60075fb3af8511c6a3 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 31 Mar 2023 09:08:40 -0400
Subject: [PATCH 072/108] openimagedenoise: revbump for ffmpeg6

---
 srcpkgs/openimagedenoise/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimagedenoise/template b/srcpkgs/openimagedenoise/template
index 109deb171c3f75..44edf38fb289d8 100644
--- a/srcpkgs/openimagedenoise/template
+++ b/srcpkgs/openimagedenoise/template
@@ -1,7 +1,7 @@
 # Template file for 'openimagedenoise'
 pkgname=openimagedenoise
 version=1.4.3
-revision=2
+revision=3
 archs="x86_64*"
 build_style=cmake
 hostmakedepends="ispc python3"

From c7d9c13115ccf1c8a305ba534978b039066c1460 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:31:45 -0400
Subject: [PATCH 073/108] shotcut: revbump for ffmpeg6

---
 srcpkgs/shotcut/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/shotcut/template b/srcpkgs/shotcut/template
index b0dc9377558941..13e8a08522b68f 100644
--- a/srcpkgs/shotcut/template
+++ b/srcpkgs/shotcut/template
@@ -1,7 +1,7 @@
 # Template file for 'shotcut'
 pkgname=shotcut
 version=23.09.29
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DSHOTCUT_VERSION=${version}"
 hostmakedepends="pkg-config qt6-base qt6-tools"

From 2d995e9b15b5ee92f3c395755bb409d59d64aa07 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:30 -0400
Subject: [PATCH 074/108] shiboken2: revbump for qt5-5.15.11

---
 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch | 1 +
 1 file changed, 1 insertion(+)
 create mode 120000 srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
new file mode 120000
index 00000000000000..efcf3249bd8854
--- /dev/null
+++ b/srcpkgs/shiboken2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1 @@
+../../python3-pyside2/patches/importlib-machinery-bypass.patch
\ No newline at end of file

From a970edcecee6e03c02ec27f5a1513caea15162d1 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 3 Apr 2023 23:33:53 -0400
Subject: [PATCH 075/108] python3-pyside2: revbump for qt5-5.15.11

---
 .../patches/importlib-machinery-bypass.patch      | 15 +++++++++++++++
 srcpkgs/python3-pyside2/template                  |  2 +-
 2 files changed, 16 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch

diff --git a/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
new file mode 100644
index 00000000000000..64c429584776b5
--- /dev/null
+++ b/srcpkgs/python3-pyside2/patches/importlib-machinery-bypass.patch
@@ -0,0 +1,15 @@
+Using this prevents an error around line 220 below it.
+"AttributeError: module 'importlib' has no attribute 'machinery'"
+The old backup logic is in place and compiles without issues.
+--- a/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:09:34.688912402 -0400
++++ b/sources/shiboken2/libshiboken/embed/signature_bootstrap.py	2023-04-02 23:10:03.395529582 -0400
+@@ -170,9 +170,6 @@
+
+     # 'zipstring_sequence' comes from signature.cpp
+     zipbytes = base64.b64decode(''.join(zipstring_sequence))
+-    if sys.version_info[0] >= 3:
+-        vzip = zipfile.ZipFile(io.BytesIO(zipbytes))
+-        return sys.meta_path, EmbeddableZipImporter(vzip)
+
+     # Old version for Python 2.7, only.
+     import os
diff --git a/srcpkgs/python3-pyside2/template b/srcpkgs/python3-pyside2/template
index 249efa90988425..52626436ce75f2 100644
--- a/srcpkgs/python3-pyside2/template
+++ b/srcpkgs/python3-pyside2/template
@@ -1,7 +1,7 @@
 # Template file for 'python3-pyside2'
 pkgname=python3-pyside2
 version=5.15.10
-revision=1
+revision=2
 _pkgname="pyside-setup-opensource-src-${version}"
 build_wrksrc="sources/pyside2"
 build_style=cmake

From 694290cea7738f43166a0973d9179a5f5b0c997e Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:35 -0400
Subject: [PATCH 076/108] konqueror: revbump for ffmpeg6

---
 srcpkgs/konqueror/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/konqueror/template b/srcpkgs/konqueror/template
index add972916753c6..50bbf4eec05e55 100644
--- a/srcpkgs/konqueror/template
+++ b/srcpkgs/konqueror/template
@@ -1,11 +1,11 @@
 # Template file for 'konqueror'
 pkgname=konqueror
 version=23.08.5
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DDESKTOPTOJSON_EXECUTABLE=/usr/bin/desktoptojson"
 hostmakedepends="extra-cmake-modules python3 qt5-host-tools qt5-qmake kdoctools
-kcoreaddons kconfig gettext"
+ kcoreaddons kconfig gettext"
 makedepends="qt5-devel qt5-webengine-devel qt5-declarative-devel
  qt5-webchannel-devel qt5-location-devel kcmutils-devel kdelibs4support-devel
  karchive-devel khtml-devel kdesu-devel kactivities5-devel"

From 326d1f4183845bd29ce8365d159cb8505466b37b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 4 Apr 2023 11:14:58 -0400
Subject: [PATCH 077/108] qt5-speech: revbump for qt5-5.15.11

---
 srcpkgs/qt5-speech/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt5-speech/template b/srcpkgs/qt5-speech/template
index 1228bb60c41db4..27a7da1dbdb91b 100644
--- a/srcpkgs/qt5-speech/template
+++ b/srcpkgs/qt5-speech/template
@@ -1,7 +1,7 @@
 # Template file for 'qt5-speech'
 pkgname=qt5-speech
 version=5.15.11
-revision=1
+revision=2
 _commit=d32f4a479d38a11f547598004b975f4356424a16
 build_style=qmake
 configure_args="-- -flite -flite-alsa -speechd"

From 5b2970d296ded0cc3aa5bfc2c5e8f8260d011ca0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 3 Jun 2023 08:20:22 -0400
Subject: [PATCH 078/108] gtk4: revbump for ffmpeg6

---
 srcpkgs/gtk4/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/gtk4/template b/srcpkgs/gtk4/template
index 050b6a14aa117a..7bbd1bff8ae7e6 100644
--- a/srcpkgs/gtk4/template
+++ b/srcpkgs/gtk4/template
@@ -1,7 +1,7 @@
 # Template file for 'gtk4'
 pkgname=gtk4
 version=4.14.2
-revision=3
+revision=4
 build_style=meson
 build_helper="gir"
 configure_args="-Dman-pages=true -Ddocumentation=true -Dbuild-tests=false

From c089dd7031a49eccd2d475c2b9da12725f7fe786 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 4 Jun 2023 11:28:26 -0400
Subject: [PATCH 079/108] siril: revbump for ffmpeg6

---
 srcpkgs/siril/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/siril/template b/srcpkgs/siril/template
index 84332f79d060d2..62750dd247548f 100644
--- a/srcpkgs/siril/template
+++ b/srcpkgs/siril/template
@@ -1,7 +1,7 @@
 # Template file for 'siril'
 pkgname=siril
 version=0.9.12
-revision=10
+revision=11
 build_style=gnu-configure
 hostmakedepends="pkg-config intltool autoconf automake gettext-devel"
 makedepends="fftw-devel libconfig-devel libopencv-devel libffms2-devel

From bb4332f846971b46ad5dd02f62fd979618b1238d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:20:59 -0400
Subject: [PATCH 080/108] tracker-miners: revbump for ffmpeg6

---
 srcpkgs/tracker-miners/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tracker-miners/template b/srcpkgs/tracker-miners/template
index 92b3863efd342c..f91c50598e90ba 100644
--- a/srcpkgs/tracker-miners/template
+++ b/srcpkgs/tracker-miners/template
@@ -1,7 +1,7 @@
 # Template file for 'tracker-miners'
 pkgname=tracker-miners
 version=3.7.1
-revision=2
+revision=3
 build_style=meson
 build_helper=qemu
 # missing libgrss for miner_rss

From 192da6f8059df73b9c61804c2207843798661dd5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sat, 8 Jul 2023 20:21:21 -0400
Subject: [PATCH 081/108] mpd: revbump for ffmpeg6

---
 srcpkgs/mdp/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mdp/template b/srcpkgs/mdp/template
index 3720bfae02f840..1c45395dca9b21 100644
--- a/srcpkgs/mdp/template
+++ b/srcpkgs/mdp/template
@@ -1,7 +1,7 @@
 # Template file for 'mdp'
 pkgname=mdp
 version=1.0.15
-revision=1
+revision=2
 build_style=gnu-makefile
 makedepends="ncurses-devel"
 short_desc="A command-line based markdown presentation tool"

From a2e968f8f1563eb461a5cbdda7517290c4908e69 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:02 -0400
Subject: [PATCH 082/108] tg_owt: revbump for ffmpeg6

---
 srcpkgs/tg_owt/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/tg_owt/template b/srcpkgs/tg_owt/template
index 34e8fef0540569..1a46a8bedf3473 100644
--- a/srcpkgs/tg_owt/template
+++ b/srcpkgs/tg_owt/template
@@ -1,7 +1,7 @@
 # Template file for 'tg_owt'
 pkgname=tg_owt
 version=0.0.0.20231221
-revision=2
+revision=3
 _commit=afd9d5d31798d3eacf9ed6c30601e91d0f1e4d60
 _libyuv_commit=04821d1e7d60845525e8db55c7bcd41ef5be9406
 _abseil_commit=8c0b94e793a66495e0b1f34a5eb26bd7dc672db0

From c3211badb6f95f52332c4f031661c65cd139156b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:10:44 -0400
Subject: [PATCH 083/108] telegram-desktop: revbump for ffmpeg6

---
 srcpkgs/telegram-desktop/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/telegram-desktop/template b/srcpkgs/telegram-desktop/template
index d9fc8e561a73a2..5a1365802922b2 100644
--- a/srcpkgs/telegram-desktop/template
+++ b/srcpkgs/telegram-desktop/template
@@ -1,7 +1,7 @@
 # Template file for 'telegram-desktop'
 pkgname=telegram-desktop
 version=4.16.8
-revision=1
+revision=2
 build_style=cmake
 build_helper="qemu gir"
 configure_args="-DTDESKTOP_API_ID=209235

From 2091feeb5e1eebd88ca4b7ac28e0acfdf3582f9b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:12:09 -0400
Subject: [PATCH 084/108] openmw: revbump for ffmpeg6

---
 srcpkgs/openmw/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openmw/template b/srcpkgs/openmw/template
index 0abf5ff7cdbecc..b57180f1a4446f 100644
--- a/srcpkgs/openmw/template
+++ b/srcpkgs/openmw/template
@@ -1,7 +1,7 @@
 # Template file for 'openmw'
 pkgname=openmw
 version=0.48.0
-revision=2
+revision=3
 build_style=cmake
 _recast_commit=e75adf86f91eb3082220085e42dda62679f9a3ea
 _bullet_tag=3.17

From f65b884470575dd4bb4a9aaad923184e7f68d3e8 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 30 Aug 2023 09:18:18 -0400
Subject: [PATCH 085/108] freecad: DELETE

---
 srcpkgs/freecad/patches/001-include.patch     | 112 ------------------
 .../154-revert-gui-tmp-redirect-stderr.patch  |  68 -----------
 ...d63c8c9b1280978be841d04e68a0a55cceb9.patch |  30 -----
 srcpkgs/freecad/template                      |  12 +-
 4 files changed, 7 insertions(+), 215 deletions(-)
 delete mode 100644 srcpkgs/freecad/patches/001-include.patch
 delete mode 100644 srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
 delete mode 100644 srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch

diff --git a/srcpkgs/freecad/patches/001-include.patch b/srcpkgs/freecad/patches/001-include.patch
deleted file mode 100644
index 28b5af54999b96..00000000000000
--- a/srcpkgs/freecad/patches/001-include.patch
+++ /dev/null
@@ -1,112 +0,0 @@
-From 9a41845a417189776741297c50a3827ce292bc4f Mon Sep 17 00:00:00 2001
-From: Uwe <donovaly@users.noreply.github.com>
-Date: Sun, 3 Jul 2022 22:51:16 +0200
-Subject: [PATCH] [Part] OCCError.h: remove unneeded includes
-
-- also sort includes
----
- src/Mod/Part/App/OCCError.h             | 36 +++----------------------
- src/Mod/Part/App/OffsetCurvePyImp.cpp   | 12 ++++-----
- src/Mod/Part/App/OffsetSurfacePyImp.cpp | 10 +++----
- 3 files changed, 12 insertions(+), 46 deletions(-)
-
---- a/src/Mod/Part/App/OCCError.h
-+++ b/src/Mod/Part/App/OCCError.h
-@@ -23,36 +23,8 @@
- #ifndef _OCCError_h_
- #define _OCCError_h_
- 
--# include <Standard_Version.hxx>
- # include <Standard_Failure.hxx>
--# include <Standard_AbortiveTransaction.hxx>
--# include <Standard_ConstructionError.hxx>
--# if OCC_VERSION_HEX >= 0x060500
--# include <Standard_DefineException.hxx>
--# endif
--# include <Standard_DimensionError.hxx>
--# include <Standard_DimensionMismatch.hxx>
--# include <Standard_DivideByZero.hxx>
--# include <Standard_DomainError.hxx>
--# include <Standard_ImmutableObject.hxx>
--# include <Standard_LicenseError.hxx>
--# include <Standard_LicenseNotFound.hxx>
--# include <Standard_MultiplyDefined.hxx>
--# include <Standard_NegativeValue.hxx>
--# include <Standard_NoMoreObject.hxx>
--# include <Standard_NoSuchObject.hxx>
--# include <Standard_NotImplemented.hxx>
--# include <Standard_NullObject.hxx>
--# include <Standard_NullValue.hxx>
--# include <Standard_NumericError.hxx>
--# include <Standard_OutOfMemory.hxx>
--# include <Standard_OutOfRange.hxx>
--# include <Standard_Overflow.hxx>
--# include <Standard_ProgramError.hxx>
--# include <Standard_RangeError.hxx>
--# include <Standard_TooManyUsers.hxx>
--# include <Standard_TypeMismatch.hxx>
--# include <Standard_Underflow.hxx>
-+# include <Standard_Version.hxx>
- 
- #include <Mod/Part/PartGlobal.h>
- #include <Base/Console.h>
-@@ -88,4 +60,3 @@ PartExport extern PyObject* PartExceptio
- 
- #define PY_CATCH_OCC _PY_CATCH_OCC(return(NULL))
- #endif  // _OCCError_h_
--
---- a/src/Mod/Part/App/OffsetCurvePyImp.cpp
-+++ b/src/Mod/Part/App/OffsetCurvePyImp.cpp
-@@ -20,20 +20,20 @@
-  *                                                                         *
-  ***************************************************************************/
- 
--
- #include "PreCompiled.h"
- #ifndef _PreComp_
- # include <Geom_OffsetCurve.hxx>
- #endif
- 
--#include "OCCError.h"
--#include "Geometry.h"
-+#include <Base/GeometryPyCXX.h>
-+#include <Base/Vector3D.h>
-+#include <Base/VectorPy.h>
-+
- #include "OffsetCurvePy.h"
- #include "OffsetCurvePy.cpp"
-+#include "Geometry.h"
-+#include "OCCError.h"
- 
--#include <Base/GeometryPyCXX.h>
--#include <Base/VectorPy.h>
--#include <Base/Vector3D.h>
- 
- using namespace Part;
- 
---- a/src/Mod/Part/App/OffsetSurfacePyImp.cpp
-+++ b/src/Mod/Part/App/OffsetSurfacePyImp.cpp
-@@ -20,20 +20,16 @@
-  *                                                                         *
-  ***************************************************************************/
- 
--
- #include "PreCompiled.h"
- #ifndef _PreComp_
- # include <Geom_OffsetSurface.hxx>
- # include <memory>
- #endif
- 
--#include <Base/VectorPy.h>
--#include <Base/Vector3D.h>
--
- #include "OCCError.h"
--#include "Geometry.h"
--#include <Mod/Part/App/OffsetSurfacePy.h>
--#include <Mod/Part/App/OffsetSurfacePy.cpp>
-+#include "OffsetSurfacePy.h"
-+#include "OffsetSurfacePy.cpp"
-+
- 
- using namespace Part;
- 
diff --git a/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch b/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
deleted file mode 100644
index d6a9adabdec830..00000000000000
--- a/srcpkgs/freecad/patches/154-revert-gui-tmp-redirect-stderr.patch
+++ /dev/null
@@ -1,68 +0,0 @@
-see https://github.com/FreeCAD/FreeCAD/commit/cfe94b00d3434f3e2c8b5114d2909f628c330fa8#commitcomment-71413407
-
-upstream: yes
-
-From 7b377a216b9185960e4cee980a6504dc1a755f50 Mon Sep 17 00:00:00 2001
-From: wmayer <wmayer@users.sourceforge.net>
-Date: Wed, 29 Jun 2022 15:19:18 +0200
-Subject: [PATCH] Gui: remove workaround for spnav 0.23 due to build failure
- with musl libc
-
----
- src/Gui/3Dconnexion/GuiNativeEventLinux.cpp | 27 ---------------------
- 1 file changed, 27 deletions(-)
-
---- a/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp
-+++ b/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp
-@@ -21,42 +21,17 @@
-  ***************************************************************************/
- 
- #include <FCConfig.h>
--#include <cstdio>
- 
- #include "GuiNativeEventLinux.h"
- 
- #include "GuiApplicationNativeEventAware.h"
- #include <Base/Console.h>
--#include <Base/FileInfo.h>
- #include <QMainWindow>
- 
- #include <QSocketNotifier>
- 
- #include <spnav.h>
- 
--namespace {
--class RedirectStdErr
--{
--public:
--    RedirectStdErr()
--        : fi(Base::FileInfo::getTempFileName())
--        , file(stderr)
--    {
--        stderr = fopen(fi.filePath().c_str(), "w");
--    }
--    ~RedirectStdErr()
--    {
--        fclose(stderr);
--        fi.deleteFile();
--        stderr = file;
--    }
--
--private:
--    Base::FileInfo fi;
--    FILE* file;
--};
--}
--
- Gui::GuiNativeEvent::GuiNativeEvent(Gui::GUIApplicationNativeEventAware *app)
- : GuiAbstractNativeEvent(app)
- {
-@@ -72,8 +47,6 @@ Gui::GuiNativeEvent::~GuiNativeEvent()
- 
- void Gui::GuiNativeEvent::initSpaceball(QMainWindow *window)
- {
--    // tmp. redirect stderr to a file to suppress an error message from spnav_open()
--    RedirectStdErr err;
-     Q_UNUSED(window)
-     if (spnav_open() == -1) {
-         Base::Console().Log("Couldn't connect to spacenav daemon. Please ignore if you don't have a spacemouse.\n");
diff --git a/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch b/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch
deleted file mode 100644
index d4acf370ca0a42..00000000000000
--- a/srcpkgs/freecad/patches/fe02d63c8c9b1280978be841d04e68a0a55cceb9.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-From fe02d63c8c9b1280978be841d04e68a0a55cceb9 Mon Sep 17 00:00:00 2001
-From: Roy-043 <70520633+Roy-043@users.noreply.github.com>
-Date: Thu, 29 Dec 2022 23:20:38 +0100
-Subject: [PATCH] Draft: update inspect.getargspec to inspect.getfullargspec
- (#8101)
-
----
- src/Mod/Draft/draftguitools/gui_snapper.py | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
---- a/src/Mod/Draft/draftguitools/gui_snapper.py
-+++ b/src/Mod/Draft/draftguitools/gui_snapper.py
-@@ -1426,7 +1426,7 @@ class Snapper:
-             Gui.Snapper.off()
-             self.ui.offUi()
-             if callback:
--                if len(inspect.getargspec(callback).args) > 1:
-+                if len(inspect.getfullargspec(callback).args) > 1:
-                     obj = None
-                     if self.snapInfo and ("Object" in self.snapInfo) and self.snapInfo["Object"]:
-                         obj = App.ActiveDocument.getObject(self.snapInfo["Object"])
-@@ -1445,7 +1445,7 @@ class Snapper:
-             Gui.Snapper.off()
-             self.ui.offUi()
-             if callback:
--                if len(inspect.getargspec(callback).args) > 1:
-+                if len(inspect.getfullargspec(callback).args) > 1:
-                     callback(None, None)
-                 else:
-                     callback(None)
diff --git a/srcpkgs/freecad/template b/srcpkgs/freecad/template
index c135701e38b9ad..7d5165f760bab9 100644
--- a/srcpkgs/freecad/template
+++ b/srcpkgs/freecad/template
@@ -1,7 +1,7 @@
 # Template file for 'freecad'
 pkgname=freecad
-version=0.20.2
-revision=7
+version=0.21.1
+revision=2
 build_wrksrc="FreeCAD-${version}"
 build_style=cmake
 pycompile_dirs="usr/lib/${pkgname}/Mod"
@@ -24,8 +24,10 @@ makedepends="python3-devel boost-devel libxerces-c-devel zlib-devel occt-devel
  coin3-devel libshiboken2-devel libspnav-devel pyside2-tools
  liblz4-devel libpyside2-python3-devel python3-matplotlib netcdf-devel
  jsoncpp-devel qt5-devel qt5-svg-devel qt5-tools-devel qt5-webkit-devel
- qt5-xmlpatterns-devel coin3-doc glew-devel python3-pivy"
-depends="python3-matplotlib python3-pyside2-webengine python3-pivy"
+ qt5-xmlpatterns-devel coin3-doc glew-devel python3-pivy qt5-webengine-devel
+ qt5-declarative-devel qt5-webchannel-devel qt5-location-devel"
+depends="python3-matplotlib python3-pyside2-webengine python3-pivy
+ python3-GitPython python3-Markdown"
 short_desc="General purpose 3D CAD modeler"
 maintainer="yopito <pierre.bourgin@free.fr>"
 license="LGPL-2.0-or-later"
@@ -35,7 +37,7 @@ distfiles="
  https://github.com/FreeCAD/FreeCAD/archive/${version}.tar.gz
  ${SOURCEFORGE_SITE}/cxx/pycxx-${_pycxxver}.tar.gz
 "
-checksum="46922f3a477e742e1a89cd5346692d63aebb2b67af887b3e463e094a4ae055da
+checksum="e9b1fd0323f101268c7f3be52db42e4a29222f2e306ae6c4a6fc309cb418d35a
  4b91e1e1141c23fbd5039df635c4bb6e75632168548f56b83ce177193c0c98c6"
 python_version=3
 patch_args="-Np1 -d ${build_wrksrc}"

From 3c05d2cfad82144da1a100712d5eee51b76a577d Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Sun, 15 Oct 2023 21:47:18 -0400
Subject: [PATCH 086/108] libopenshot: revbump for ffmpeg6

---
 srcpkgs/libopenshot/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/libopenshot/template b/srcpkgs/libopenshot/template
index fc45a258057079..7c1de694d06c00 100644
--- a/srcpkgs/libopenshot/template
+++ b/srcpkgs/libopenshot/template
@@ -1,7 +1,7 @@
 # Template file for 'libopenshot'
 pkgname=libopenshot
 version=0.3.2
-revision=1
+revision=2
 build_style=cmake
 # Builds fail with Ruby-2.4.1
 configure_args="-DENABLE_RUBY=OFF -DUSE_SYSTEM_JSONCPP=ON"

From a3bf76afc6110e78c9845575ba59f3a2db372036 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:10:30 -0500
Subject: [PATCH 087/108] openimageio: revbump for ffmpeg6

---
 srcpkgs/openimageio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/openimageio/template b/srcpkgs/openimageio/template
index 27d2131bc0a61a..61f44b43f9083e 100644
--- a/srcpkgs/openimageio/template
+++ b/srcpkgs/openimageio/template
@@ -1,7 +1,7 @@
 # Template file for 'openimageio'
 pkgname=openimageio
 version=2.4.9.0
-revision=8
+revision=9
 build_style=cmake
 build_helper=qemu
 configure_args="-DUSE_QT=0 -DUSE_PYTHON=0 -DOIIO_BUILD_TESTS=0

From 66e3c32f768aef61117a242e7bbaee7b37a4556b Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Wed, 8 Nov 2023 10:11:57 -0500
Subject: [PATCH 088/108] synfigstudio: revbump for ffmpeg6

---
 srcpkgs/synfigstudio/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/synfigstudio/template b/srcpkgs/synfigstudio/template
index 09e442da9a6805..2bc017cedca6b8 100644
--- a/srcpkgs/synfigstudio/template
+++ b/srcpkgs/synfigstudio/template
@@ -2,7 +2,7 @@
 # Should be kept in sync with 'synfig' and 'ETL'
 pkgname=synfigstudio
 version=1.4.4
-revision=4
+revision=5
 build_style=gnu-configure
 configure_args="--disable-update-mimedb"
 hostmakedepends="pkg-config intltool gettext synfig"

From 052d4112d1e7c1c2e95918769c806f0cc23cd2ae Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:10 -0500
Subject: [PATCH 089/108] mixxx: revbump for ffmpeg6

---
 srcpkgs/mixxx/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mixxx/template b/srcpkgs/mixxx/template
index 6a79b328c1abf0..9a5141856860b9 100644
--- a/srcpkgs/mixxx/template
+++ b/srcpkgs/mixxx/template
@@ -1,7 +1,7 @@
 # Template file for 'mixxx'
 pkgname=mixxx
 version=2.3.3
-revision=7
+revision=8
 build_style=cmake
 configure_args="-DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="extra-cmake-modules pkg-config protobuf qt5-host-tools qt5-qmake"

From 9f71545053e4eba94da77f12db7fad136fcc5ac5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:28 -0500
Subject: [PATCH 090/108] musikcube: revbump for ffmpeg6

---
 srcpkgs/musikcube/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/musikcube/template b/srcpkgs/musikcube/template
index 8c4a51840859ec..fb60dd2049089a 100644
--- a/srcpkgs/musikcube/template
+++ b/srcpkgs/musikcube/template
@@ -1,7 +1,7 @@
 # Template file for 'musikcube'
 pkgname=musikcube
 version=3.0.0
-revision=3
+revision=4
 build_style=cmake
 make_cmd=make
 configure_args="-DNO_NCURSESW=1"

From 67da14104f75e5786a849e23bfec4223df8b553f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:53:45 -0500
Subject: [PATCH 091/108] electron24: revbump for ffmpeg6

---
 srcpkgs/electron24/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron24/template b/srcpkgs/electron24/template
index eafb9a0c696131..42b57dc512d822 100644
--- a/srcpkgs/electron24/template
+++ b/srcpkgs/electron24/template
@@ -1,7 +1,7 @@
 # Template file for 'electron24'
 pkgname=electron24
 version=24.3.0
-revision=3
+revision=4
 _nodever=18.14.0
 _chromiumver=112.0.5615.165
 archs="x86_64* aarch64*"

From 92a818f31f98e003091808496e882a3c43f213a6 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:00 -0500
Subject: [PATCH 092/108] electron19: revbump for ffmpeg6

---
 srcpkgs/electron19/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/electron19/template b/srcpkgs/electron19/template
index b1fdb63cb67d46..881f04d7d825b7 100644
--- a/srcpkgs/electron19/template
+++ b/srcpkgs/electron19/template
@@ -1,7 +1,7 @@
 # Template file for 'electron19'
 pkgname=electron19
 version=19.0.8
-revision=4
+revision=5
 _nodever=16.14.2
 _chromiumver=102.0.5005.125
 archs="x86_64* aarch64* ppc64le*"

From dda26918031a9f48a75935879047953d79b824d0 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:13 -0500
Subject: [PATCH 093/108] wf-recorder: revbump for ffmpeg6

---
 srcpkgs/wf-recorder/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/wf-recorder/template b/srcpkgs/wf-recorder/template
index 08f986b0310067..63c45cf4b814d7 100644
--- a/srcpkgs/wf-recorder/template
+++ b/srcpkgs/wf-recorder/template
@@ -1,7 +1,7 @@
 # Template file for 'wf-recorder'
 pkgname=wf-recorder
 version=0.4.1
-revision=2
+revision=3
 build_style=meson
 hostmakedepends="pkg-config scdoc wayland-devel"
 makedepends="wayland-protocols wayland-devel ffmpeg-devel libgbm-devel x264-devel

From 7e2524153af3d3d4897fa8b9550328ac83a5d85f Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:26 -0500
Subject: [PATCH 094/108] obs: revbump for ffmpeg6

---
 srcpkgs/obs/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/obs/template b/srcpkgs/obs/template
index feb9649977a8d4..0888fb3aaaccfe 100644
--- a/srcpkgs/obs/template
+++ b/srcpkgs/obs/template
@@ -1,7 +1,7 @@
 # Template file for 'obs'
 pkgname=obs
 version=30.1.1
-revision=1
+revision=2
 archs="i686* x86_64* ppc64le* aarch64* riscv64*"
 build_style=cmake
 configure_args="-DOBS_VERSION_OVERRIDE=${version} -DENABLE_JACK=ON

From a6fb1d04d998c36e22d33098dc43effb98332117 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:36 -0500
Subject: [PATCH 095/108] mlt7: revbump for ffmpeg6

---
 srcpkgs/mlt7/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mlt7/template b/srcpkgs/mlt7/template
index 65eed998d39832..59f7ec147f0d04 100644
--- a/srcpkgs/mlt7/template
+++ b/srcpkgs/mlt7/template
@@ -1,7 +1,7 @@
 # Template file for 'mlt7'
 pkgname=mlt7
 version=7.20.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DSWIG_PYTHON=ON -DMOD_QT6=ON"
 hostmakedepends="doxygen pkg-config ladspa-sdk swig python3 which

From 2a599f4f7a027cab52119f273d483e948bf25848 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 14:54:48 -0500
Subject: [PATCH 096/108] qt6-multimedia: revbump for ffmpeg6

---
 srcpkgs/qt6-multimedia/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qt6-multimedia/template b/srcpkgs/qt6-multimedia/template
index 67a577e1300fea..1da626ecf515a8 100644
--- a/srcpkgs/qt6-multimedia/template
+++ b/srcpkgs/qt6-multimedia/template
@@ -1,7 +1,7 @@
 # Template file for 'qt6-multimedia'
 pkgname=qt6-multimedia
 version=6.6.0
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DQT_FEATURE_gstreamer=ON"
 hostmakedepends="perl qt6-declarative-host-tools pkg-config qt6-shadertools"

From e9fff0a045fbda2a12ed59281437c9f70a1f814a Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:00:15 -0500
Subject: [PATCH 097/108] baresip: revbump for ffmpeg6

---
 srcpkgs/baresip/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/baresip/template b/srcpkgs/baresip/template
index b16b67beab8d2b..fe21ebf40c03c1 100644
--- a/srcpkgs/baresip/template
+++ b/srcpkgs/baresip/template
@@ -1,7 +1,7 @@
 # Template file for 'baresip'
 pkgname=baresip
 version=3.6.0
-revision=3
+revision=4
 build_style=cmake
 hostmakedepends="pkg-config glib-devel"
 makedepends="libgsm-devel libpng-devel openssl-devel libsndfile-devel

From 0a6b8b74c448b79036867596949e213c60171f92 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:30 -0500
Subject: [PATCH 098/108] QMPlay2: revbump for ffmpeg6

---
 srcpkgs/QMPlay2/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/QMPlay2/template b/srcpkgs/QMPlay2/template
index 83a49d5b0b9415..00e659dc598831 100644
--- a/srcpkgs/QMPlay2/template
+++ b/srcpkgs/QMPlay2/template
@@ -1,7 +1,7 @@
 # Template file for 'QMPlay2'
 pkgname=QMPlay2
 version=24.04.07
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="pkg-config qt5-qmake qt5-host-tools"
 makedepends="alsa-lib-devel ffmpeg-devel libass-devel libcdio-devel libgme-devel

From 283e714cc8e59f4e5a5a35ea22571049584d1281 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:34 -0500
Subject: [PATCH 099/108] alsa-plugins: revbump for ffmpeg6

---
 srcpkgs/alsa-plugins/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/alsa-plugins/template b/srcpkgs/alsa-plugins/template
index a5708a7d82a8f0..7bfdad046c4830 100644
--- a/srcpkgs/alsa-plugins/template
+++ b/srcpkgs/alsa-plugins/template
@@ -1,7 +1,7 @@
 # Template file for 'alsa-plugins'
 pkgname=alsa-plugins
 version=1.2.7.1
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--disable-maemo-plugin"
 hostmakedepends="pkg-config"

From dddfa82333320c307bb4444131bd42a0f47fc640 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 10 Nov 2023 15:02:43 -0500
Subject: [PATCH 100/108] minidlna: revbump for ffmpeg6

---
 srcpkgs/minidlna/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/minidlna/template b/srcpkgs/minidlna/template
index 5fa929f3a0c124..742991ecd04afc 100644
--- a/srcpkgs/minidlna/template
+++ b/srcpkgs/minidlna/template
@@ -1,7 +1,7 @@
 # Template file for 'minidlna'
 pkgname=minidlna
 version=1.3.3
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="
  --sbindir=/usr/bin

From d59940d6f54bd8329424fc32649855651741b9ce Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 17:57:47 -0500
Subject: [PATCH 101/108] mpv: revbump for ffmpeg6

---
 srcpkgs/mpv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/mpv/template b/srcpkgs/mpv/template
index 78ab959982ee99..3d690f21482730 100644
--- a/srcpkgs/mpv/template
+++ b/srcpkgs/mpv/template
@@ -1,7 +1,7 @@
 # Template file for 'mpv'
 pkgname=mpv
 version=0.38.0
-revision=1
+revision=2
 build_style=meson
 configure_args="-Dcdda=enabled -Ddvbin=enabled -Ddvdnav=enabled
  -Dlibmpv=true -Dcplugins=enabled

From f61f2ae4d029129b0fc68d5dcb93b97beaadc47c Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 17:59:29 -0500
Subject: [PATCH 102/108] qimgv: revbump for ffmpeg6

---
 srcpkgs/qimgv/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/qimgv/template b/srcpkgs/qimgv/template
index dd341dfe1bfce8..8a7e1c081ef12f 100644
--- a/srcpkgs/qimgv/template
+++ b/srcpkgs/qimgv/template
@@ -1,7 +1,7 @@
 # Template file for 'qimgv'
 pkgname=qimgv
 version=1.0.2
-revision=3
+revision=4
 build_style=cmake
 configure_args="$(vopt_if video -DVIDEO_SUPPORT=ON -DVIDEO_SUPPORT=OFF)
  $(vopt_if scale -DOPENCV_SUPPORT=ON -DOPENCV_SUPPORT=OFF)

From 9c82e00bd98e73f3dc210b959f6cf3f05605fb99 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Mon, 20 Nov 2023 18:00:36 -0500
Subject: [PATCH 103/108] kfilemetadata5: revbump for ffmpeg6

---
 srcpkgs/kfilemetadata5/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/kfilemetadata5/template b/srcpkgs/kfilemetadata5/template
index a0c4d809395323..b584f85ff2058b 100644
--- a/srcpkgs/kfilemetadata5/template
+++ b/srcpkgs/kfilemetadata5/template
@@ -1,7 +1,7 @@
 # Template file for 'kfilemetadata5'
 pkgname=kfilemetadata5
 version=5.115.0
-revision=1
+revision=2
 build_style=cmake
 hostmakedepends="kcoreaddons extra-cmake-modules pkg-config qt5-host-tools qt5-qmake
  gettext kcoreaddons python3"

From e417e2dc99e129ff188c6cb5e9dcc0985ff38490 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 8 Dec 2023 11:46:01 -0500
Subject: [PATCH 104/108] vba-m: revbump for ffmpeg6

---
 srcpkgs/vba-m/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/vba-m/template b/srcpkgs/vba-m/template
index 3d135efa1d0b69..3c5a20db0fa984 100644
--- a/srcpkgs/vba-m/template
+++ b/srcpkgs/vba-m/template
@@ -2,7 +2,7 @@
 pkgname=vba-m
 reverts=1292_2
 version=2.1.9
-revision=1
+revision=2
 build_style=cmake
 configure_args="-DENABLE_GTK=TRUE -DENABLE_FFMPEG=TRUE -DENABLE_LINK=TRUE -DCMAKE_BUILD_TYPE=Release"
 hostmakedepends="gettext pkg-config unzip zip yasm wxWidgets-gtk3-devel"

From 7f1001fd7da318185937c5e6ed0791a55e96dffc Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Fri, 8 Dec 2023 11:46:19 -0500
Subject: [PATCH 105/108] dolphin-emu: revbump for ffmpeg6

---
 srcpkgs/dolphin-emu/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/dolphin-emu/template b/srcpkgs/dolphin-emu/template
index 862d3ae964eec4..a7ae0efb58fb75 100644
--- a/srcpkgs/dolphin-emu/template
+++ b/srcpkgs/dolphin-emu/template
@@ -1,7 +1,7 @@
 # Template file for 'dolphin-emu'
 pkgname=dolphin-emu
 version=5.0.19368
-revision=3
+revision=4
 _dolphin_commit=dadbeb4bae7e7fa23af2b46e0add4143094dc107
 _mgba_commit=44e074a15e9651481f7f652ac006a7c9d58cbeb9
 _googletest_commit=be03d00f5f0cc3a997d1a368bee8a1fe93651f48

From da235de2ead821bf73133860b1098f7c10be0bf5 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Tue, 19 Dec 2023 15:38:51 -0500
Subject: [PATCH 106/108] qtox: revbump for ffmpeg4

---
 srcpkgs/qtox/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/qtox/template b/srcpkgs/qtox/template
index bb70e7f51240a4..755e4462bc0137 100644
--- a/srcpkgs/qtox/template
+++ b/srcpkgs/qtox/template
@@ -1,13 +1,13 @@
 # Template file for 'qtox'
 pkgname=qtox
 version=1.17.6
-revision=3
+revision=4
 build_style=cmake
 configure_args="-DUPDATE_CHECK=OFF
  -DGIT_DESCRIBE=${version}
  $(vopt_if snorenotify -DDESKTOP_NOTIFICATIONS=ON)"
 hostmakedepends="pkg-config qt5-host-tools qt5-devel"
-makedepends="ffmpeg-devel libexif-devel libopenal-devel libsodium-devel
+makedepends="ffmpeg4-devel libexif-devel libopenal-devel libsodium-devel
  libvpx-devel opus-devel qrencode-devel qt5-svg-devel sonnet-devel
  sqlcipher-devel toxcore-devel
  $(vopt_if snorenotify snorenotify-devel)"

From 83668293b3f83603023a3acce7d05fdef5557714 Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 11 Jan 2024 11:52:00 -0500
Subject: [PATCH 107/108] arcan: revbump for ffmpeg6

---
 srcpkgs/arcan/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/arcan/template b/srcpkgs/arcan/template
index ff9091f90ebb10..030091a6cc9d0c 100644
--- a/srcpkgs/arcan/template
+++ b/srcpkgs/arcan/template
@@ -2,7 +2,7 @@
 # !! keep synced with: acfgfs aclip aloadimage
 pkgname=arcan
 version=0.6.2.1
-revision=2
+revision=3
 create_wrksrc=yes
 build_wrksrc=arcan/src
 build_style=cmake

From a8d3b4e98ff2bb3857e9695236f3fe95ff02f1cd Mon Sep 17 00:00:00 2001
From: zlice <zlice555@gmail.com>
Date: Thu, 11 Jan 2024 11:52:10 -0500
Subject: [PATCH 108/108] notcurses: revbump for ffmpeg6

---
 srcpkgs/notcurses/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/notcurses/template b/srcpkgs/notcurses/template
index 48a7463cb68eb9..515f316ab4576c 100644
--- a/srcpkgs/notcurses/template
+++ b/srcpkgs/notcurses/template
@@ -1,7 +1,7 @@
 # Template file for 'notcurses'
 pkgname=notcurses
 version=3.0.9
-revision=2
+revision=3
 build_style=cmake
 configure_args="-DUSE_STATIC=ON -DUSE_QRCODEGEN=On $(vopt_bool man USE_PANDOC)"
 hostmakedepends="pkg-config $(vopt_if man pandoc)"

^ permalink raw reply	[flat|nested] 99+ messages in thread

end of thread, other threads:[~2024-04-26 12:45 UTC | newest]

Thread overview: 99+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-05 13:20 [PR PATCH] ffmpeg6 split zlice
2023-05-05 13:27 ` [PR PATCH] [Updated] " zlice
2023-05-05 13:53 ` zlice
2023-05-05 18:04 ` [PR PATCH] [Updated] " zlice
2023-05-07 19:26 ` paper42
2023-05-07 22:00 ` zlice
2023-05-07 22:00 ` [PR PATCH] [Updated] " zlice
2023-05-08  0:23 ` zlice
2023-05-29  1:43 ` zlice
2023-06-04 15:47 ` zlice
2023-06-10  5:04 ` zlice
2023-06-17 19:17 ` zlice
2023-06-17 19:28 ` zlice
2023-06-19 20:19 ` zlice
2023-06-22 14:28 ` zlice
2023-06-23 20:37 ` [PR PATCH] [Updated] " zlice
2023-07-04 13:30 ` zlice
2023-07-04 14:18 ` zlice
2023-07-04 14:19 ` zlice
2023-07-09 14:54 ` zlice
2023-07-09 14:58 ` zlice
2023-07-17 19:52 ` [PR PATCH] [Updated] " zlice
2023-08-02 14:18 ` zlice
2023-08-30 13:18 ` zlice
2023-10-02  0:04 ` yoshiyoshyosh
2023-10-11 12:27 ` zlice
2023-10-11 17:06 ` SpidFightFR
2023-10-11 17:07 ` SpidFightFR
2023-10-16 12:11 ` [PR PATCH] [Updated] " zlice
2023-10-16 12:12 ` zlice
2023-10-16 12:19 ` SpidFightFR
2023-10-16 12:19 ` SpidFightFR
2023-10-16 12:26 ` SpidFightFR
2023-10-16 12:27 ` SpidFightFR
2023-10-16 12:27 ` SpidFightFR
2023-10-17 12:58 ` [PR PATCH] [Updated] " zlice
2023-10-17 12:59 ` zlice
2023-11-08 15:12 ` [PR PATCH] [Updated] " zlice
2023-11-10 20:08 ` zlice
2023-11-14 13:43 ` zlice
2023-11-20 23:00 ` zlice
2023-12-03 16:39 ` mhmdanas
2023-12-03 16:45 ` [PR PATCH] [Updated] " zlice
2023-12-03 16:59 ` zlice
2023-12-05 16:30 ` mhmdanas
2023-12-09 17:37 ` [PR PATCH] [Updated] " zlice
2023-12-09 17:39 ` zlice
2023-12-14 18:28 ` [PR PATCH] [Updated] " zlice
2023-12-19 20:48 ` zlice
2023-12-29 17:30 ` zlice
2023-12-29 17:30 ` zlice
2023-12-29 17:47 ` [PR PATCH] [Updated] " zlice
2024-01-05 13:07 ` zlice
2024-01-11 16:52 ` zlice
2024-01-17 22:35 ` zlice
2024-01-17 22:50 ` zlice
2024-01-28 18:46 ` zlice
2024-02-02 22:44 ` zlice
2024-02-02 22:46 ` zlice
2024-02-02 22:48 ` zlice
2024-02-03 20:31 ` [PR PATCH] [Updated] " zlice
2024-02-03 20:38 ` zlice
2024-02-03 22:46 ` [PR PATCH] [Updated] " zlice
2024-02-06  5:34 ` Luciogi
2024-02-11 17:28 ` [PR PATCH] [Updated] " zlice
2024-02-11 22:49 ` zlice
2024-02-15 19:52 ` zlice
2024-02-20 18:21 ` zlice
2024-02-22 17:25 ` yoshiyoshyosh
2024-02-22 17:34 ` zlice
2024-02-24  2:34 ` yoshiyoshyosh
2024-02-24  2:34 ` yoshiyoshyosh
2024-02-25 17:32 ` [PR PATCH] [Updated] " zlice
2024-02-25 17:33 ` zlice
2024-02-25 19:08 ` yoshiyoshyosh
2024-02-25 19:08 ` yoshiyoshyosh
2024-02-25 19:09 ` yoshiyoshyosh
2024-02-25 19:09 ` yoshiyoshyosh
2024-02-25 19:28 ` yoshiyoshyosh
2024-02-25 19:28 ` zlice
2024-02-25 19:32 ` yoshiyoshyosh
2024-02-25 19:33 ` yoshiyoshyosh
2024-02-25 20:20 ` yoshiyoshyosh
2024-02-25 21:45 ` yoshiyoshyosh
2024-02-25 21:58 ` yoshiyoshyosh
2024-03-01 15:58 ` [PR PATCH] [Updated] " zlice
2024-03-06 21:24 ` zlice
2024-03-09 22:24 ` yoshiyoshyosh
2024-03-09 22:41 ` [PR PATCH] [Updated] " zlice
2024-03-09 22:43 ` zlice
2024-03-09 22:56 ` yoshiyoshyosh
2024-03-10  0:03 ` zlice
2024-03-12 17:08 ` [PR PATCH] [Updated] " zlice
2024-03-18 20:07 ` zlice
2024-03-21 21:29 ` zlice
2024-03-21 21:51 ` zlice
2024-03-28 17:21 ` zlice
2024-04-13 14:47 ` zlice
2024-04-26 12:45 ` zlice

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).